diff --git a/.gitattributes b/.gitattributes index a41b48ee01d9fb2f0b692ab2751eef51b8927d19..4f357ac67c8abec21bf966633017e4f951bbc9ae 100644 --- a/.gitattributes +++ b/.gitattributes @@ -68,3 +68,5 @@ BigVul_sample_test_split/test_subsample_10k.csv filter=lfs diff=lfs merge=lfs -t BigVul_MSR_clean_test_split_subsample_new/BigVul_MSR_cleaned_subsample.csv filter=lfs diff=lfs merge=lfs -text Categorized_test_split/BigVul_Sample/BigVul_Sample_512_to_1024.csv filter=lfs diff=lfs merge=lfs -text Categorized_test_split/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text +categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.csv filter=lfs diff=lfs merge=lfs -text +categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv filter=lfs diff=lfs merge=lfs -text diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.csv new file mode 100644 index 0000000000000000000000000000000000000000..84f99a82563deb1cb934902e2636a2b3bba344f1 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.csv @@ -0,0 +1,161280 @@ +idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting +17808,"int ssl3_client_hello(SSL *s) +{ + unsigned char *buf; + unsigned char *p, *d; + int i; + unsigned long l; + int al = 0; +#ifndef OPENSSL_NO_COMP + int j; + SSL_COMP *comp; +#endif + + buf = (unsigned char *)s->init_buf->data; + if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { + SSL_SESSION *sess = s->session; + if ((sess == NULL) || + (sess->ssl_version != s->version) || + !sess->session_id_length || (sess->not_resumable)) { + if (!ssl_get_new_session(s, 0)) + goto err; + } + if (s->method->version == DTLS_ANY_VERSION) { + /* Determine which DTLS version to use */ + int options = s->options; + /* If DTLS 1.2 disabled correct the version number */ + if (options & SSL_OP_NO_DTLSv1_2) { + if (tls1_suiteb(s)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, + SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); + goto err; + } + /* + * Disabling all versions is silly: return an error. + */ + if (options & SSL_OP_NO_DTLSv1) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_WRONG_SSL_VERSION); + goto err; + } + /* + * Update method so we don't use any DTLS 1.2 features. + */ + s->method = DTLSv1_client_method(); + s->version = DTLS1_VERSION; + } else { + /* + * We only support one version: update method + */ + if (options & SSL_OP_NO_DTLSv1) + s->method = DTLSv1_2_client_method(); + s->version = DTLS1_2_VERSION; + } + s->client_version = s->version; + } + /* else use the pre-loaded session */ + + p = s->s3->client_random; + + /* + * for DTLS if client_random is initialized, reuse it, we are + * required to use same upon reply to HelloVerify + */ + if (SSL_IS_DTLS(s)) { + size_t idx; + i = 1; + for (idx = 0; idx < sizeof(s->s3->client_random); idx++) { + if (p[idx]) { + i = 0; + break; + } + } + } else + i = 1; + + if (i) + ssl_fill_hello_random(s, 0, p, sizeof(s->s3->client_random)); + + /* Do the message type and length last */ + d = p = ssl_handshake_start(s); + /*- + * version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ + *(p++) = s->client_version >> 8; + *(p++) = s->client_version & 0xff; + + /* Random stuff */ + memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); + p += SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i = 0; + else + i = s->session->session_id_length; + *(p++) = i; + if (i != 0) { + if (i > (int)sizeof(s->session->session_id)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + memcpy(p, s->session->session_id, i); + p += i; + } + + /* cookie stuff for DTLS */ + if (SSL_IS_DTLS(s)) { + if (s->d1->cookie_len > sizeof(s->d1->cookie)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + *(p++) = s->d1->cookie_len; + memcpy(p, s->d1->cookie, s->d1->cookie_len); + p += s->d1->cookie_len; + } + + /* Ciphers supported */ + i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0); + if (i == 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } +#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH + /* + * Some servers hang if client hello > 256 bytes as hack workaround + * chop number of supported ciphers to keep it well below this if we + * use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; +#endif + s2n(i, p); + p += i; + + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + *(p++) = 1; +#else + + if (!ssl_allow_compression(s) || !s->ctx->comp_methods) + j = 0; + else + j = sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++) = 1 + j; + for (i = 0; i < j; i++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); + *(p++) = comp->id; + } +#endif + *(p++) = 0; /* Add the NULL method */ + +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions */ + if (ssl_prepare_clienthello_tlsext(s) <= 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = + ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH, + &al)) == NULL) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } +#endif + + l = p - d; + ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l); + s->state = SSL3_ST_CW_CLNT_HELLO_B; + } + + /* SSL3_ST_CW_CLNT_HELLO_B */ + return ssl_do_write(s); + err: + return (-1); +} +",1,"int ssl3_client_hello(SSL *s) +{ + unsigned char *buf; + unsigned char *p, *d; + int i; + unsigned long l; + int al = 0; +#ifndef OPENSSL_NO_COMP + int j; + SSL_COMP *comp; +#endif + + buf = (unsigned char *)s->init_buf->data; + if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { + SSL_SESSION *sess = s->session; + if ((sess == NULL) || + (sess->ssl_version != s->version) || + !sess->session_id_length || (sess->not_resumable)) { + if (!ssl_get_new_session(s, 0)) + goto err; + } + if (s->method->version == DTLS_ANY_VERSION) { + /* Determine which DTLS version to use */ + int options = s->options; + /* If DTLS 1.2 disabled correct the version number */ + if (options & SSL_OP_NO_DTLSv1_2) { + if (tls1_suiteb(s)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, + SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); + goto err; + } + /* + * Disabling all versions is silly: return an error. + */ + if (options & SSL_OP_NO_DTLSv1) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_WRONG_SSL_VERSION); + goto err; + } + /* + * Update method so we don't use any DTLS 1.2 features. + */ + s->method = DTLSv1_client_method(); + s->version = DTLS1_VERSION; + } else { + /* + * We only support one version: update method + */ + if (options & SSL_OP_NO_DTLSv1) + s->method = DTLSv1_2_client_method(); + s->version = DTLS1_2_VERSION; + } + s->client_version = s->version; + } + /* else use the pre-loaded session */ + + p = s->s3->client_random; + + /* + * for DTLS if client_random is initialized, reuse it, we are + * required to use same upon reply to HelloVerify + */ + if (SSL_IS_DTLS(s)) { + size_t idx; + i = 1; + for (idx = 0; idx < sizeof(s->s3->client_random); idx++) { + if (p[idx]) { + i = 0; + break; + } + } + } else + i = 1; + + if (i && ssl_fill_hello_random(s, 0, p, + sizeof(s->s3->client_random)) <= 0) + goto err; + + /* Do the message type and length last */ + d = p = ssl_handshake_start(s); + /*- + * version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ + *(p++) = s->client_version >> 8; + *(p++) = s->client_version & 0xff; + + /* Random stuff */ + memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); + p += SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i = 0; + else + i = s->session->session_id_length; + *(p++) = i; + if (i != 0) { + if (i > (int)sizeof(s->session->session_id)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + memcpy(p, s->session->session_id, i); + p += i; + } + + /* cookie stuff for DTLS */ + if (SSL_IS_DTLS(s)) { + if (s->d1->cookie_len > sizeof(s->d1->cookie)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + *(p++) = s->d1->cookie_len; + memcpy(p, s->d1->cookie, s->d1->cookie_len); + p += s->d1->cookie_len; + } + + /* Ciphers supported */ + i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0); + if (i == 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } +#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH + /* + * Some servers hang if client hello > 256 bytes as hack workaround + * chop number of supported ciphers to keep it well below this if we + * use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; +#endif + s2n(i, p); + p += i; + + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + *(p++) = 1; +#else + + if (!ssl_allow_compression(s) || !s->ctx->comp_methods) + j = 0; + else + j = sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++) = 1 + j; + for (i = 0; i < j; i++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); + *(p++) = comp->id; + } +#endif + *(p++) = 0; /* Add the NULL method */ + +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions */ + if (ssl_prepare_clienthello_tlsext(s) <= 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = + ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH, + &al)) == NULL) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } +#endif + + l = p - d; + ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l); + s->state = SSL3_ST_CW_CLNT_HELLO_B; + } + + /* SSL3_ST_CW_CLNT_HELLO_B */ + return ssl_do_write(s); + err: + return (-1); +} +","@@ -719,8 +719,9 @@ int ssl3_client_hello(SSL *s) + } else + i = 1; + +- if (i) +- ssl_fill_hello_random(s, 0, p, sizeof(s->s3->client_random)); ++ if (i && ssl_fill_hello_random(s, 0, p, ++ sizeof(s->s3->client_random)) <= 0) ++ goto err; + + /* Do the message type and length last */ + d = p = ssl_handshake_start(s);",1772,2008,2048 +7369,"parse_args(int argc, char *argv[]) +{ + int r; + + static struct option longOptions[] = + { + {""receive-cmd"", required_argument, 0, 'v'}, + {""send-cmd"", required_argument, 0, 's'}, + {""imap"", required_argument, 0, 'I' }, + {""omap"", required_argument, 0, 'O' }, + {""emap"", required_argument, 0, 'E' }, + {""escape"", required_argument, 0, 'e'}, + {""echo"", no_argument, 0, 'c'}, + {""noinit"", no_argument, 0, 'i'}, + {""noreset"", no_argument, 0, 'r'}, + {""nolock"", no_argument, 0, 'l'}, + {""flow"", required_argument, 0, 'f'}, + {""baud"", required_argument, 0, 'b'}, + {""parity"", required_argument, 0, 'p'}, + {""databits"", required_argument, 0, 'd'}, + {""help"", no_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + + r = 0; + while (1) { + int optionIndex = 0; + int c; + int map; + + /* no default error messages printed. */ + opterr = 0; + + c = getopt_long(argc, argv, ""hirlcv:s:r:e:f:b:p:d:"", + longOptions, &optionIndex); + + if (c < 0) + break; + + switch (c) { + case 's': + strncpy(opts.send_cmd, optarg, sizeof(opts.send_cmd)); + opts.send_cmd[sizeof(opts.send_cmd) - 1] = '\0'; + break; + case 'v': + strncpy(opts.receive_cmd, optarg, sizeof(opts.receive_cmd)); + opts.receive_cmd[sizeof(opts.receive_cmd) - 1] = '\0'; + break; + case 'I': + map = parse_map(optarg); + if (map >= 0) opts.imap = map; + else { fprintf(stderr, ""Invalid --imap\n""); r = -1; } + break; + case 'O': + map = parse_map(optarg); + if (map >= 0) opts.omap = map; + else { fprintf(stderr, ""Invalid --omap\n""); r = -1; } + break; + case 'E': + map = parse_map(optarg); + if (map >= 0) opts.emap = map; + else { fprintf(stderr, ""Invalid --emap\n""); r = -1; } + break; + case 'c': + opts.lecho = 1; + break; + case 'i': + opts.noinit = 1; + break; + case 'r': + opts.noreset = 1; + break; + case 'l': +#if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) + opts.nolock = 1; +#endif + break; + case 'e': + opts.escape = optarg[0] & 0x1f; + break; + case 'f': + switch (optarg[0]) { + case 'X': + case 'x': + opts.flow = FC_XONXOFF; + break; + case 'H': + case 'h': + opts.flow = FC_RTSCTS; + break; + case 'N': + case 'n': + opts.flow = FC_NONE; + break; + default: + fprintf(stderr, ""Invalid --flow: %c\n"", optarg[0]); + r = -1; + break; + } + break; + case 'b': + opts.baud = atoi(optarg); + break; + case 'p': + switch (optarg[0]) { + case 'e': + opts.parity = P_EVEN; + break; + case 'o': + opts.parity = P_ODD; + break; + case 'n': + opts.parity = P_NONE; + break; + default: + fprintf(stderr, ""Invalid --parity: %c\n"", optarg[0]); + r = -1; + break; + } + break; + case 'd': + switch (optarg[0]) { + case '5': + opts.databits = 5; + break; + case '6': + opts.databits = 6; + break; + case '7': + opts.databits = 7; + break; + case '8': + opts.databits = 8; + break; + default: + fprintf(stderr, ""Invalid --databits: %c\n"", optarg[0]); + r = -1; + break; + } + break; + case 'h': + show_usage(argv[0]); + exit(EXIT_SUCCESS); + case '?': + default: + fprintf(stderr, ""Unrecognized option(s)\n""); + r = -1; + break; + } + if ( r < 0 ) { + fprintf(stderr, ""Run with '--help'.\n""); + exit(EXIT_FAILURE); + } + } /* while */ + + if ( (argc - optind) < 1) { + fprintf(stderr, ""No port given\n""); + fprintf(stderr, ""Run with '--help'.\n""); + exit(EXIT_FAILURE); + } + strncpy(opts.port, argv[optind], sizeof(opts.port) - 1); + opts.port[sizeof(opts.port) - 1] = '\0'; + + printf(""picocom v%s\n"", VERSION_STR); + printf(""\n""); + printf(""port is : %s\n"", opts.port); + printf(""flowcontrol : %s\n"", flow_str[opts.flow]); + printf(""baudrate is : %d\n"", opts.baud); + printf(""parity is : %s\n"", parity_str[opts.parity]); + printf(""databits are : %d\n"", opts.databits); + printf(""escape is : C-%c\n"", 'a' + opts.escape - 1); + printf(""local echo is : %s\n"", opts.lecho ? ""yes"" : ""no""); + printf(""noinit is : %s\n"", opts.noinit ? ""yes"" : ""no""); + printf(""noreset is : %s\n"", opts.noreset ? ""yes"" : ""no""); +#if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) + printf(""nolock is : %s\n"", opts.nolock ? ""yes"" : ""no""); +#endif + printf(""send_cmd is : %s\n"", + (opts.send_cmd[0] == '\0') ? ""disabled"" : opts.send_cmd); + printf(""receive_cmd is : %s\n"", + (opts.receive_cmd[0] == '\0') ? ""disabled"" : opts.receive_cmd); + printf(""imap is : ""); print_map(opts.imap); + printf(""omap is : ""); print_map(opts.omap); + printf(""emap is : ""); print_map(opts.emap); + printf(""\n""); +} +",0,"parse_args(int argc, char *argv[]) +{ + int r; + + static struct option longOptions[] = + { + {""receive-cmd"", required_argument, 0, 'v'}, + {""send-cmd"", required_argument, 0, 's'}, + {""imap"", required_argument, 0, 'I' }, + {""omap"", required_argument, 0, 'O' }, + {""emap"", required_argument, 0, 'E' }, + {""escape"", required_argument, 0, 'e'}, + {""echo"", no_argument, 0, 'c'}, + {""noinit"", no_argument, 0, 'i'}, + {""noreset"", no_argument, 0, 'r'}, + {""nolock"", no_argument, 0, 'l'}, + {""flow"", required_argument, 0, 'f'}, + {""baud"", required_argument, 0, 'b'}, + {""parity"", required_argument, 0, 'p'}, + {""databits"", required_argument, 0, 'd'}, + {""help"", no_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + + r = 0; + while (1) { + int optionIndex = 0; + int c; + int map; + + /* no default error messages printed. */ + opterr = 0; + + c = getopt_long(argc, argv, ""hirlcv:s:r:e:f:b:p:d:"", + longOptions, &optionIndex); + + if (c < 0) + break; + + switch (c) { + case 's': + strncpy(opts.send_cmd, optarg, sizeof(opts.send_cmd)); + opts.send_cmd[sizeof(opts.send_cmd) - 1] = '\0'; + break; + case 'v': + strncpy(opts.receive_cmd, optarg, sizeof(opts.receive_cmd)); + opts.receive_cmd[sizeof(opts.receive_cmd) - 1] = '\0'; + break; + case 'I': + map = parse_map(optarg); + if (map >= 0) opts.imap = map; + else { fprintf(stderr, ""Invalid --imap\n""); r = -1; } + break; + case 'O': + map = parse_map(optarg); + if (map >= 0) opts.omap = map; + else { fprintf(stderr, ""Invalid --omap\n""); r = -1; } + break; + case 'E': + map = parse_map(optarg); + if (map >= 0) opts.emap = map; + else { fprintf(stderr, ""Invalid --emap\n""); r = -1; } + break; + case 'c': + opts.lecho = 1; + break; + case 'i': + opts.noinit = 1; + break; + case 'r': + opts.noreset = 1; + break; + case 'l': +#if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) + opts.nolock = 1; +#endif + break; + case 'e': + opts.escape = optarg[0] & 0x1f; + break; + case 'f': + switch (optarg[0]) { + case 'X': + case 'x': + opts.flow = FC_XONXOFF; + break; + case 'H': + case 'h': + opts.flow = FC_RTSCTS; + break; + case 'N': + case 'n': + opts.flow = FC_NONE; + break; + default: + fprintf(stderr, ""Invalid --flow: %c\n"", optarg[0]); + r = -1; + break; + } + break; + case 'b': + opts.baud = atoi(optarg); + break; + case 'p': + switch (optarg[0]) { + case 'e': + opts.parity = P_EVEN; + break; + case 'o': + opts.parity = P_ODD; + break; + case 'n': + opts.parity = P_NONE; + break; + default: + fprintf(stderr, ""Invalid --parity: %c\n"", optarg[0]); + r = -1; + break; + } + break; + case 'd': + switch (optarg[0]) { + case '5': + opts.databits = 5; + break; + case '6': + opts.databits = 6; + break; + case '7': + opts.databits = 7; + break; + case '8': + opts.databits = 8; + break; + default: + fprintf(stderr, ""Invalid --databits: %c\n"", optarg[0]); + r = -1; + break; + } + break; + case 'h': + show_usage(argv[0]); + exit(EXIT_SUCCESS); + case '?': + default: + fprintf(stderr, ""Unrecognized option(s)\n""); + r = -1; + break; + } + if ( r < 0 ) { + fprintf(stderr, ""Run with '--help'.\n""); + exit(EXIT_FAILURE); + } + } /* while */ + + if ( (argc - optind) < 1) { + fprintf(stderr, ""No port given\n""); + fprintf(stderr, ""Run with '--help'.\n""); + exit(EXIT_FAILURE); + } + strncpy(opts.port, argv[optind], sizeof(opts.port) - 1); + opts.port[sizeof(opts.port) - 1] = '\0'; + + printf(""picocom v%s\n"", VERSION_STR); + printf(""\n""); + printf(""port is : %s\n"", opts.port); + printf(""flowcontrol : %s\n"", flow_str[opts.flow]); + printf(""baudrate is : %d\n"", opts.baud); + printf(""parity is : %s\n"", parity_str[opts.parity]); + printf(""databits are : %d\n"", opts.databits); + printf(""escape is : C-%c\n"", 'a' + opts.escape - 1); + printf(""local echo is : %s\n"", opts.lecho ? ""yes"" : ""no""); + printf(""noinit is : %s\n"", opts.noinit ? ""yes"" : ""no""); + printf(""noreset is : %s\n"", opts.noreset ? ""yes"" : ""no""); +#if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) + printf(""nolock is : %s\n"", opts.nolock ? ""yes"" : ""no""); +#endif + printf(""send_cmd is : %s\n"", + (opts.send_cmd[0] == '\0') ? ""disabled"" : opts.send_cmd); + printf(""receive_cmd is : %s\n"", + (opts.receive_cmd[0] == '\0') ? ""disabled"" : opts.receive_cmd); + printf(""imap is : ""); print_map(opts.imap); + printf(""omap is : ""); print_map(opts.omap); + printf(""emap is : ""); print_map(opts.emap); + printf(""\n""); +} +","@@ -48,6 +48,7 @@ + #define _GNU_SOURCE + #include + ++#include ""split.h"" + #include ""term.h"" + #ifdef LINENOISE + #include ""linenoise-1.0/linenoise.h"" +@@ -721,6 +722,9 @@ show_status (int dtr_up) + + /**********************************************************************/ + ++#define RUNCMD_ARGS_MAX 32 ++#define RUNCMD_EXEC_FAIL 126 ++ + void + establish_child_signal_handlers (void) + { +@@ -735,10 +739,8 @@ establish_child_signal_handlers (void) + sigaction (SIGTERM, &dfl_action, NULL); + } + +-#define EXEC ""exec "" +- + int +-run_cmd(int fd, ...) ++run_cmd(int fd, const char *cmd, const char *args_extra) + { + pid_t pid; + sigset_t sigm, sigm_old; +@@ -781,8 +783,10 @@ run_cmd(int fd, ...) + } else { + /* child: external program */ + long fl; +- char cmd[512]; +- ++ int argc; ++ char *argv[RUNCMD_ARGS_MAX + 1]; ++ int r; ++ + /* unmanage terminal, and reset it to canonical mode */ + term_remove(STI); + /* unmanage serial port fd, without reset */ +@@ -796,37 +800,36 @@ run_cmd(int fd, ...) + close(STO); + dup2(fd, STI); + dup2(fd, STO); +- { +- /* build command-line */ +- char *c, *ce; +- const char *s; +- int n; +- va_list vls; +- +- strcpy(cmd, EXEC); +- c = &cmd[sizeof(EXEC)- 1]; +- ce = cmd + sizeof(cmd) - 1; +- va_start(vls, fd); +- while ( (s = va_arg(vls, const char *)) ) { +- n = strlen(s); +- if ( c + n + 1 >= ce ) break; +- memcpy(c, s, n); c += n; +- *c++ = ' '; +- } +- va_end(vls); +- *c = '\0'; ++ ++ /* build command arguments vector */ ++ argc = 0; ++ r = split_quoted(cmd, &argc, argv, RUNCMD_ARGS_MAX); ++ if ( r < 0 ) { ++ fd_printf(STDERR_FILENO, ""Cannot parse command\n""); ++ exit(RUNCMD_EXEC_FAIL); ++ } ++ r = split_quoted(args_extra, &argc, argv, RUNCMD_ARGS_MAX); ++ if ( r < 0 ) { ++ fd_printf(STDERR_FILENO, ""Cannot parse extra args\n""); ++ exit(RUNCMD_EXEC_FAIL); + } ++ if ( argc < 1 ) { ++ fd_printf(STDERR_FILENO, ""No command given\n""); ++ exit(RUNCMD_EXEC_FAIL); ++ } ++ argv[argc] = NULL; ++ + /* run extenral command */ +- fd_printf(STDERR_FILENO, ""%s\n"", &cmd[sizeof(EXEC) - 1]); ++ fd_printf(STDERR_FILENO, ""$ %s %s\n"", cmd, args_extra); + establish_child_signal_handlers(); + sigprocmask(SIG_SETMASK, &sigm_old, NULL); +- execl(""/bin/sh"", ""sh"", ""-c"", cmd, NULL); +- exit(42); ++ execvp(argv[0], argv); ++ ++ fd_printf(STDERR_FILENO, ""exec: %s\n"", strerror(errno)); ++ exit(RUNCMD_EXEC_FAIL); + } + } + +-#undef EXEC +- + /**********************************************************************/ + + /* Process command key. Returns non-zero if command results in picocom +@@ -944,7 +947,7 @@ do_command (unsigned char c) + fd_printf(STO, ""*** cannot read filename ***\r\n""); + break; + } +- run_cmd(tty_fd, xfr_cmd, fname, NULL); ++ run_cmd(tty_fd, xfr_cmd, fname); + free(fname); + break; + case KEY_BREAK:",1508,1744,2048 +17574,"void bta_av_sig_chg(tBTA_AV_DATA* p_data) { + uint16_t event = p_data->str_msg.hdr.layer_specific; + tBTA_AV_CB* p_cb = &bta_av_cb; + uint32_t xx; + uint8_t mask; + tBTA_AV_LCB* p_lcb = NULL; + + APPL_TRACE_DEBUG(""%s: event: %d"", __func__, event); + if (event == AVDT_CONNECT_IND_EVT) { + APPL_TRACE_DEBUG(""%s: AVDT_CONNECT_IND_EVT: peer %s"", __func__, + p_data->str_msg.bd_addr.ToString().c_str()); + + p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FIND); + if (!p_lcb) { + /* if the address does not have an LCB yet, alloc one */ + xx = bta_av_find_lcb_index_by_scb_and_address(p_data->str_msg.bd_addr); + + /* check if we found something */ + if (xx >= BTA_AV_NUM_LINKS) { + /* We do not have scb for this avdt connection. */ + /* Silently close the connection. */ + APPL_TRACE_ERROR(""%s: av scb not available for avdt connection for %s"", + __func__, p_data->str_msg.bd_addr.ToString().c_str()); + AVDT_DisconnectReq(p_data->str_msg.bd_addr, NULL); + return; + } + LOG_INFO(LOG_TAG, + ""%s: AVDT_CONNECT_IND_EVT: peer %s selected lcb_index %d"", + __func__, p_data->str_msg.bd_addr.ToString().c_str(), xx); + + tBTA_AV_SCB* p_scb = p_cb->p_scb[xx]; + mask = 1 << xx; + p_lcb = &p_cb->lcb[xx]; + p_lcb->lidx = xx + 1; + p_lcb->addr = p_data->str_msg.bd_addr; + p_lcb->conn_msk = 0; /* clear the connect mask */ + /* start listening when the signal channel is open */ + if (p_cb->features & BTA_AV_FEAT_RCTG) { + bta_av_rc_create(p_cb, AVCT_ACP, 0, p_lcb->lidx); + } + /* this entry is not used yet. */ + p_cb->conn_lcb |= mask; /* mark it as used */ + APPL_TRACE_DEBUG(""%s: start sig timer %d"", __func__, p_data->hdr.offset); + if (p_data->hdr.offset == AVDT_ACP) { + APPL_TRACE_DEBUG(""%s: Incoming L2CAP acquired, set state as incoming"", + __func__); + p_scb->OnConnected(p_data->str_msg.bd_addr); + p_scb->use_rc = true; /* allowing RC for incoming connection */ + bta_av_ssm_execute(p_scb, BTA_AV_ACP_CONNECT_EVT, p_data); + + /* The Pending Event should be sent as soon as the L2CAP signalling + * channel + * is set up, which is NOW. Earlier this was done only after + * BTA_AV_SIGNALLING_TIMEOUT_MS. + * The following function shall send the event and start the + * recurring timer + */ + bta_av_signalling_timer(NULL); + + APPL_TRACE_DEBUG(""%s: Re-start timer for AVDTP service"", __func__); + bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); + /* Possible collision : need to avoid outgoing processing while the + * timer is running */ + p_scb->coll_mask = BTA_AV_COLL_INC_TMR; + alarm_set_on_mloop( + p_cb->accept_signalling_timer, BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS, + bta_av_accept_signalling_timer_cback, UINT_TO_PTR(xx)); + } + } + } +#if (BTA_AR_INCLUDED == TRUE) + else if (event == BTA_AR_AVDT_CONN_EVT) { + alarm_cancel(bta_av_cb.link_signalling_timer); + } +#endif + else { + /* disconnected. */ + APPL_TRACE_DEBUG(""%s: bta_av_cb.conn_lcb is %d"", __func__, + bta_av_cb.conn_lcb); + + p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FREE); + if (p_lcb && (p_lcb->conn_msk || bta_av_cb.conn_lcb)) { + APPL_TRACE_DEBUG(""%s: conn_msk: 0x%x"", __func__, p_lcb->conn_msk); + /* clean up ssm */ + for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) { + if (p_cb->p_scb[xx] && + p_cb->p_scb[xx]->PeerAddress() == p_data->str_msg.bd_addr) { + APPL_TRACE_DEBUG(""%s: Closing timer for AVDTP service"", __func__); + bta_sys_conn_close(BTA_ID_AV, p_cb->p_scb[xx]->app_id, + p_cb->p_scb[xx]->PeerAddress()); + } + mask = 1 << (xx + 1); + if (((mask & p_lcb->conn_msk) || bta_av_cb.conn_lcb) && + p_cb->p_scb[xx] && + p_cb->p_scb[xx]->PeerAddress() == p_data->str_msg.bd_addr) { + APPL_TRACE_WARNING(""%s: Sending AVDT_DISCONNECT_EVT peer_addr=%s"", + __func__, + p_cb->p_scb[xx]->PeerAddress().ToString().c_str()); + bta_av_ssm_execute(p_cb->p_scb[xx], BTA_AV_AVDT_DISCONNECT_EVT, NULL); + } + } + } + } + APPL_TRACE_DEBUG(""%s: sig_chg conn_lcb: 0x%x"", __func__, p_cb->conn_lcb); +} +",0,"void bta_av_sig_chg(tBTA_AV_DATA* p_data) { + uint16_t event = p_data->str_msg.hdr.layer_specific; + tBTA_AV_CB* p_cb = &bta_av_cb; + uint32_t xx; + uint8_t mask; + tBTA_AV_LCB* p_lcb = NULL; + + APPL_TRACE_DEBUG(""%s: event: %d"", __func__, event); + if (event == AVDT_CONNECT_IND_EVT) { + APPL_TRACE_DEBUG(""%s: AVDT_CONNECT_IND_EVT: peer %s"", __func__, + p_data->str_msg.bd_addr.ToString().c_str()); + + p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FIND); + if (!p_lcb) { + /* if the address does not have an LCB yet, alloc one */ + xx = bta_av_find_lcb_index_by_scb_and_address(p_data->str_msg.bd_addr); + + /* check if we found something */ + if (xx >= BTA_AV_NUM_LINKS) { + /* We do not have scb for this avdt connection. */ + /* Silently close the connection. */ + APPL_TRACE_ERROR(""%s: av scb not available for avdt connection for %s"", + __func__, p_data->str_msg.bd_addr.ToString().c_str()); + AVDT_DisconnectReq(p_data->str_msg.bd_addr, NULL); + return; + } + LOG_INFO(LOG_TAG, + ""%s: AVDT_CONNECT_IND_EVT: peer %s selected lcb_index %d"", + __func__, p_data->str_msg.bd_addr.ToString().c_str(), xx); + + tBTA_AV_SCB* p_scb = p_cb->p_scb[xx]; + mask = 1 << xx; + p_lcb = &p_cb->lcb[xx]; + p_lcb->lidx = xx + 1; + p_lcb->addr = p_data->str_msg.bd_addr; + p_lcb->conn_msk = 0; /* clear the connect mask */ + /* start listening when the signal channel is open */ + if (p_cb->features & BTA_AV_FEAT_RCTG) { + bta_av_rc_create(p_cb, AVCT_ACP, 0, p_lcb->lidx); + } + /* this entry is not used yet. */ + p_cb->conn_lcb |= mask; /* mark it as used */ + APPL_TRACE_DEBUG(""%s: start sig timer %d"", __func__, p_data->hdr.offset); + if (p_data->hdr.offset == AVDT_ACP) { + APPL_TRACE_DEBUG(""%s: Incoming L2CAP acquired, set state as incoming"", + __func__); + p_scb->OnConnected(p_data->str_msg.bd_addr); + p_scb->use_rc = true; /* allowing RC for incoming connection */ + bta_av_ssm_execute(p_scb, BTA_AV_ACP_CONNECT_EVT, p_data); + + /* The Pending Event should be sent as soon as the L2CAP signalling + * channel + * is set up, which is NOW. Earlier this was done only after + * BTA_AV_SIGNALLING_TIMEOUT_MS. + * The following function shall send the event and start the + * recurring timer + */ + bta_av_signalling_timer(NULL); + + APPL_TRACE_DEBUG(""%s: Re-start timer for AVDTP service"", __func__); + bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress()); + /* Possible collision : need to avoid outgoing processing while the + * timer is running */ + p_scb->coll_mask = BTA_AV_COLL_INC_TMR; + alarm_set_on_mloop( + p_cb->accept_signalling_timer, BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS, + bta_av_accept_signalling_timer_cback, UINT_TO_PTR(xx)); + } + } + } +#if (BTA_AR_INCLUDED == TRUE) + else if (event == BTA_AR_AVDT_CONN_EVT) { + alarm_cancel(bta_av_cb.link_signalling_timer); + } +#endif + else { + /* disconnected. */ + APPL_TRACE_DEBUG(""%s: bta_av_cb.conn_lcb is %d"", __func__, + bta_av_cb.conn_lcb); + + p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FREE); + if (p_lcb && (p_lcb->conn_msk || bta_av_cb.conn_lcb)) { + APPL_TRACE_DEBUG(""%s: conn_msk: 0x%x"", __func__, p_lcb->conn_msk); + /* clean up ssm */ + for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) { + if (p_cb->p_scb[xx] && + p_cb->p_scb[xx]->PeerAddress() == p_data->str_msg.bd_addr) { + APPL_TRACE_DEBUG(""%s: Closing timer for AVDTP service"", __func__); + bta_sys_conn_close(BTA_ID_AV, p_cb->p_scb[xx]->app_id, + p_cb->p_scb[xx]->PeerAddress()); + } + mask = 1 << (xx + 1); + if (((mask & p_lcb->conn_msk) || bta_av_cb.conn_lcb) && + p_cb->p_scb[xx] && + p_cb->p_scb[xx]->PeerAddress() == p_data->str_msg.bd_addr) { + APPL_TRACE_WARNING(""%s: Sending AVDT_DISCONNECT_EVT peer_addr=%s"", + __func__, + p_cb->p_scb[xx]->PeerAddress().ToString().c_str()); + bta_av_ssm_execute(p_cb->p_scb[xx], BTA_AV_AVDT_DISCONNECT_EVT, NULL); + } + } + } + } + APPL_TRACE_DEBUG(""%s: sig_chg conn_lcb: 0x%x"", __func__, p_cb->conn_lcb); +} +","@@ -35,6 +35,7 @@ + + #include ""bta_av_api.h"" + #include ""bta_av_int.h"" + #include ""l2c_api.h"" ++#include ""log/log.h"" + #include ""osi/include/list.h"" + #include ""osi/include/log.h"" + #include ""osi/include/osi.h"" +@@ -784,11 +785,16 @@ + + case AVRC_PDU_GET_CAPABILITIES: + /* process GetCapabilities command without reporting the event to app */ + evt = 0; ++ if (p_vendor->vendor_len != 5) { ++ android_errorWriteLog(0x534e4554, ""111893951""); ++ p_rc_rsp->get_caps.status = AVRC_STS_INTERNAL_ERR; ++ break; ++ } + u8 = *(p_vendor->p_vendor_data + 4); + p = p_vendor->p_vendor_data + 2; + p_rc_rsp->get_caps.capability_id = u8; + BE_STREAM_TO_UINT16(u16, p); +- if ((u16 != 1) || (p_vendor->vendor_len != 5)) { ++ if (u16 != 1) { + p_rc_rsp->get_caps.status = AVRC_STS_INTERNAL_ERR; + } else { + p_rc_rsp->get_caps.status = AVRC_STS_NO_ERROR; +",1268,1504,2048 +18283,"ZSTD_encodeSequences_body( + void* dst, size_t dstCapacity, + FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable, + FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable, + FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable, + seqDef const* sequences, size_t nbSeq, int longOffsets) +{ + BIT_CStream_t blockStream; + FSE_CState_t stateMatchLength; + FSE_CState_t stateOffsetBits; + FSE_CState_t stateLitLength; + + CHECK_E(BIT_initCStream(&blockStream, dst, dstCapacity), dstSize_tooSmall); /* not enough space remaining */ + + /* first symbols */ + FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]); + FSE_initCState2(&stateOffsetBits, CTable_OffsetBits, ofCodeTable[nbSeq-1]); + FSE_initCState2(&stateLitLength, CTable_LitLength, llCodeTable[nbSeq-1]); + BIT_addBits(&blockStream, sequences[nbSeq-1].litLength, LL_bits[llCodeTable[nbSeq-1]]); + if (MEM_32bits()) BIT_flushBits(&blockStream); + BIT_addBits(&blockStream, sequences[nbSeq-1].matchLength, ML_bits[mlCodeTable[nbSeq-1]]); + if (MEM_32bits()) BIT_flushBits(&blockStream); + if (longOffsets) { + U32 const ofBits = ofCodeTable[nbSeq-1]; + int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); + if (extraBits) { + BIT_addBits(&blockStream, sequences[nbSeq-1].offset, extraBits); + BIT_flushBits(&blockStream); + } + BIT_addBits(&blockStream, sequences[nbSeq-1].offset >> extraBits, + ofBits - extraBits); + } else { + BIT_addBits(&blockStream, sequences[nbSeq-1].offset, ofCodeTable[nbSeq-1]); + } + BIT_flushBits(&blockStream); + + { size_t n; + for (n=nbSeq-2 ; n= 64-7-(LLFSELog+MLFSELog+OffFSELog))) + BIT_flushBits(&blockStream); /* (7)*/ + BIT_addBits(&blockStream, sequences[n].litLength, llBits); + if (MEM_32bits() && ((llBits+mlBits)>24)) BIT_flushBits(&blockStream); + BIT_addBits(&blockStream, sequences[n].matchLength, mlBits); + if (MEM_32bits() || (ofBits+mlBits+llBits > 56)) BIT_flushBits(&blockStream); + if (longOffsets) { + int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); + if (extraBits) { + BIT_addBits(&blockStream, sequences[n].offset, extraBits); + BIT_flushBits(&blockStream); /* (7)*/ + } + BIT_addBits(&blockStream, sequences[n].offset >> extraBits, + ofBits - extraBits); /* 31 */ + } else { + BIT_addBits(&blockStream, sequences[n].offset, ofBits); /* 31 */ + } + BIT_flushBits(&blockStream); /* (7)*/ + } } + + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing ML state with %u bits"", stateMatchLength.stateLog); + FSE_flushCState(&blockStream, &stateMatchLength); + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing Off state with %u bits"", stateOffsetBits.stateLog); + FSE_flushCState(&blockStream, &stateOffsetBits); + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing LL state with %u bits"", stateLitLength.stateLog); + FSE_flushCState(&blockStream, &stateLitLength); + + { size_t const streamSize = BIT_closeCStream(&blockStream); + if (streamSize==0) return ERROR(dstSize_tooSmall); /* not enough space */ + return streamSize; + } +} +",1,"ZSTD_encodeSequences_body( + void* dst, size_t dstCapacity, + FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable, + FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable, + FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable, + seqDef const* sequences, size_t nbSeq, int longOffsets) +{ + BIT_CStream_t blockStream; + FSE_CState_t stateMatchLength; + FSE_CState_t stateOffsetBits; + FSE_CState_t stateLitLength; + + CHECK_E(BIT_initCStream(&blockStream, dst, dstCapacity), dstSize_tooSmall); /* not enough space remaining */ + DEBUGLOG(6, ""available space for bitstream : %i (dstCapacity=%u)"", + (int)(blockStream.endPtr - blockStream.startPtr), + (unsigned)dstCapacity); + + /* first symbols */ + FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]); + FSE_initCState2(&stateOffsetBits, CTable_OffsetBits, ofCodeTable[nbSeq-1]); + FSE_initCState2(&stateLitLength, CTable_LitLength, llCodeTable[nbSeq-1]); + BIT_addBits(&blockStream, sequences[nbSeq-1].litLength, LL_bits[llCodeTable[nbSeq-1]]); + if (MEM_32bits()) BIT_flushBits(&blockStream); + BIT_addBits(&blockStream, sequences[nbSeq-1].matchLength, ML_bits[mlCodeTable[nbSeq-1]]); + if (MEM_32bits()) BIT_flushBits(&blockStream); + if (longOffsets) { + U32 const ofBits = ofCodeTable[nbSeq-1]; + int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); + if (extraBits) { + BIT_addBits(&blockStream, sequences[nbSeq-1].offset, extraBits); + BIT_flushBits(&blockStream); + } + BIT_addBits(&blockStream, sequences[nbSeq-1].offset >> extraBits, + ofBits - extraBits); + } else { + BIT_addBits(&blockStream, sequences[nbSeq-1].offset, ofCodeTable[nbSeq-1]); + } + BIT_flushBits(&blockStream); + + { size_t n; + for (n=nbSeq-2 ; n= 64-7-(LLFSELog+MLFSELog+OffFSELog))) + BIT_flushBits(&blockStream); /* (7)*/ + BIT_addBits(&blockStream, sequences[n].litLength, llBits); + if (MEM_32bits() && ((llBits+mlBits)>24)) BIT_flushBits(&blockStream); + BIT_addBits(&blockStream, sequences[n].matchLength, mlBits); + if (MEM_32bits() || (ofBits+mlBits+llBits > 56)) BIT_flushBits(&blockStream); + if (longOffsets) { + int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); + if (extraBits) { + BIT_addBits(&blockStream, sequences[n].offset, extraBits); + BIT_flushBits(&blockStream); /* (7)*/ + } + BIT_addBits(&blockStream, sequences[n].offset >> extraBits, + ofBits - extraBits); /* 31 */ + } else { + BIT_addBits(&blockStream, sequences[n].offset, ofBits); /* 31 */ + } + BIT_flushBits(&blockStream); /* (7)*/ + DEBUGLOG(7, ""remaining space : %i"", (int)(blockStream.endPtr - blockStream.ptr)); + } } + + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing ML state with %u bits"", stateMatchLength.stateLog); + FSE_flushCState(&blockStream, &stateMatchLength); + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing Off state with %u bits"", stateOffsetBits.stateLog); + FSE_flushCState(&blockStream, &stateOffsetBits); + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing LL state with %u bits"", stateLitLength.stateLog); + FSE_flushCState(&blockStream, &stateLitLength); + + { size_t const streamSize = BIT_closeCStream(&blockStream); + if (streamSize==0) return ERROR(dstSize_tooSmall); /* not enough space */ + return streamSize; + } +} +","@@ -2008,11 +2008,13 @@ ZSTD_buildCTable(void* dst, size_t dstCapacity, + { + BYTE* op = (BYTE*)dst; + const BYTE* const oend = op + dstCapacity; ++ DEBUGLOG(6, ""ZSTD_buildCTable (dstCapacity=%u)"", (unsigned)dstCapacity); + + switch (type) { + case set_rle: +- *op = codeTable[0]; + CHECK_F(FSE_buildCTable_rle(nextCTable, (BYTE)max)); ++ if (dstCapacity==0) return ERROR(dstSize_tooSmall); ++ *op = codeTable[0]; + return 1; + case set_repeat: + memcpy(nextCTable, prevCTable, prevCTableSize); +@@ -2054,6 +2056,9 @@ ZSTD_encodeSequences_body( + FSE_CState_t stateLitLength; + + CHECK_E(BIT_initCStream(&blockStream, dst, dstCapacity), dstSize_tooSmall); /* not enough space remaining */ ++ DEBUGLOG(6, ""available space for bitstream : %i (dstCapacity=%u)"", ++ (int)(blockStream.endPtr - blockStream.startPtr), ++ (unsigned)dstCapacity); + + /* first symbols */ + FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]); +@@ -2113,6 +2118,7 @@ ZSTD_encodeSequences_body( + BIT_addBits(&blockStream, sequences[n].offset, ofBits); /* 31 */ + } + BIT_flushBits(&blockStream); /* (7)*/ ++ DEBUGLOG(7, ""remaining space : %i"", (int)(blockStream.endPtr - blockStream.ptr)); + } } + + DEBUGLOG(6, ""ZSTD_encodeSequences: flushing ML state with %u bits"", stateMatchLength.stateLog); +@@ -2170,6 +2176,7 @@ static size_t ZSTD_encodeSequences( + FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable, + seqDef const* sequences, size_t nbSeq, int longOffsets, int bmi2) + { ++ DEBUGLOG(5, ""ZSTD_encodeSequences: dstCapacity = %u"", (unsigned)dstCapacity); + #if DYNAMIC_BMI2 + if (bmi2) { + return ZSTD_encodeSequences_bmi2(dst, dstCapacity, +@@ -2290,7 +2297,7 @@ ZSTD_compressSequences_internal(seqStore_t* seqStorePtr, + /* build CTable for MatchLengths */ + { U32 max = MaxML; + size_t const mostFrequent = HIST_countFast_wksp(count, &max, mlCodeTable, nbSeq, workspace, wkspSize); /* can't fail */ +- DEBUGLOG(5, ""Building ML table""); ++ DEBUGLOG(5, ""Building ML table (remaining space : %i)"", (int)(oend-op)); + nextEntropy->fse.matchlength_repeatMode = prevEntropy->fse.matchlength_repeatMode; + MLtype = ZSTD_selectEncodingType(&nextEntropy->fse.matchlength_repeatMode, count, max, mostFrequent, nbSeq, MLFSELog, prevEntropy->fse.matchlengthCTable, ML_defaultNorm, ML_defaultNormLog, ZSTD_defaultAllowed, strategy); + assert(!(MLtype < set_compressed && nextEntropy->fse.matchlength_repeatMode != FSE_repeat_none)); /* We don't copy tables */",1244,1480,2048 +17804,"xps_init_truetype_font(xps_context_t *ctx, xps_font_t *font) +{ + int code = 0; + + font->font = (void*) gs_alloc_struct(ctx->memory, gs_font_type42, &st_gs_font_type42, ""xps_font type42""); + if (!font->font) + return gs_throw(gs_error_VMerror, ""out of memory""); + + /* no shortage of things to initialize */ + { + gs_font_type42 *p42 = (gs_font_type42*) font->font; + + /* Common to all fonts: */ + + p42->next = 0; + p42->prev = 0; + p42->memory = ctx->memory; + + p42->dir = ctx->fontdir; /* NB also set by gs_definefont later */ + p42->base = font->font; /* NB also set by gs_definefont later */ + p42->is_resource = false; + gs_notify_init(&p42->notify_list, gs_memory_stable(ctx->memory)); + p42->id = gs_next_ids(ctx->memory, 1); + + p42->client_data = font; /* that's us */ + + /* this is overwritten in grid_fit() */ + gs_make_identity(&p42->FontMatrix); + gs_make_identity(&p42->orig_FontMatrix); /* NB ... original or zeroes? */ + + p42->FontType = ft_TrueType; + p42->BitmapWidths = false; + p42->ExactSize = fbit_use_outlines; + p42->InBetweenSize = fbit_use_outlines; + p42->TransformedChar = fbit_use_outlines; + p42->WMode = 0; + p42->PaintType = 0; + p42->StrokeWidth = 0; + p42->is_cached = 0; + + p42->procs.define_font = gs_no_define_font; + p42->procs.make_font = gs_no_make_font; + p42->procs.font_info = gs_type42_font_info; + p42->procs.same_font = gs_default_same_font; + p42->procs.encode_char = xps_true_callback_encode_char; + p42->procs.decode_glyph = xps_true_callback_decode_glyph; + p42->procs.enumerate_glyph = gs_type42_enumerate_glyph; + p42->procs.glyph_info = gs_type42_glyph_info; + p42->procs.glyph_outline = gs_type42_glyph_outline; + p42->procs.glyph_name = xps_true_callback_glyph_name; + p42->procs.init_fstack = gs_default_init_fstack; + p42->procs.next_char_glyph = gs_default_next_char_glyph; + p42->procs.build_char = xps_true_callback_build_char; + + memset(p42->font_name.chars, 0, sizeof(p42->font_name.chars)); + xps_load_sfnt_name(font, (char*)p42->font_name.chars); + p42->font_name.size = strlen((char*)p42->font_name.chars); + + memset(p42->key_name.chars, 0, sizeof(p42->key_name.chars)); + strcpy((char*)p42->key_name.chars, (char*)p42->font_name.chars); + p42->key_name.size = strlen((char*)p42->key_name.chars); + + /* Base font specific: */ + + p42->FontBBox.p.x = 0; + p42->FontBBox.p.y = 0; + p42->FontBBox.q.x = 0; + p42->FontBBox.q.y = 0; + + uid_set_UniqueID(&p42->UID, p42->id); + + p42->encoding_index = ENCODING_INDEX_UNKNOWN; + p42->nearest_encoding_index = ENCODING_INDEX_ISOLATIN1; + + p42->FAPI = 0; + p42->FAPI_font_data = 0; + + /* Type 42 specific: */ + + p42->data.string_proc = xps_true_callback_string_proc; + p42->data.proc_data = font; + + gs_type42_font_init(p42, font->subfontid); + p42->data.get_glyph_index = xps_true_get_glyph_index; + } + + if ((code = gs_definefont(ctx->fontdir, font->font)) < 0) { + return(code); + } + + code = xps_fapi_passfont (font->font, NULL, NULL, font->data, font->length); + return code; +} +",1,"xps_init_truetype_font(xps_context_t *ctx, xps_font_t *font) +{ + int code = 0; + + font->font = (void*) gs_alloc_struct(ctx->memory, gs_font_type42, &st_gs_font_type42, ""xps_font type42""); + if (!font->font) + return gs_throw(gs_error_VMerror, ""out of memory""); + + /* no shortage of things to initialize */ + { + gs_font_type42 *p42 = (gs_font_type42*) font->font; + + /* Common to all fonts: */ + + p42->next = 0; + p42->prev = 0; + p42->memory = ctx->memory; + + p42->dir = ctx->fontdir; /* NB also set by gs_definefont later */ + p42->base = font->font; /* NB also set by gs_definefont later */ + p42->is_resource = false; + gs_notify_init(&p42->notify_list, gs_memory_stable(ctx->memory)); + p42->id = gs_next_ids(ctx->memory, 1); + + p42->client_data = font; /* that's us */ + + /* this is overwritten in grid_fit() */ + gs_make_identity(&p42->FontMatrix); + gs_make_identity(&p42->orig_FontMatrix); /* NB ... original or zeroes? */ + + p42->FontType = ft_TrueType; + p42->BitmapWidths = false; + p42->ExactSize = fbit_use_outlines; + p42->InBetweenSize = fbit_use_outlines; + p42->TransformedChar = fbit_use_outlines; + p42->WMode = 0; + p42->PaintType = 0; + p42->StrokeWidth = 0; + p42->is_cached = 0; + + p42->procs.define_font = gs_no_define_font; + p42->procs.make_font = gs_no_make_font; + p42->procs.font_info = gs_type42_font_info; + p42->procs.same_font = gs_default_same_font; + p42->procs.encode_char = xps_true_callback_encode_char; + p42->procs.decode_glyph = xps_true_callback_decode_glyph; + p42->procs.enumerate_glyph = gs_type42_enumerate_glyph; + p42->procs.glyph_info = gs_type42_glyph_info; + p42->procs.glyph_outline = gs_type42_glyph_outline; + p42->procs.glyph_name = xps_true_callback_glyph_name; + p42->procs.init_fstack = gs_default_init_fstack; + p42->procs.next_char_glyph = gs_default_next_char_glyph; + p42->procs.build_char = xps_true_callback_build_char; + + memset(p42->font_name.chars, 0, sizeof(p42->font_name.chars)); + xps_load_sfnt_name(font, (char*)p42->font_name.chars, sizeof(p42->font_name.chars)); + p42->font_name.size = strlen((char*)p42->font_name.chars); + + memset(p42->key_name.chars, 0, sizeof(p42->key_name.chars)); + strcpy((char*)p42->key_name.chars, (char*)p42->font_name.chars); + p42->key_name.size = strlen((char*)p42->key_name.chars); + + /* Base font specific: */ + + p42->FontBBox.p.x = 0; + p42->FontBBox.p.y = 0; + p42->FontBBox.q.x = 0; + p42->FontBBox.q.y = 0; + + uid_set_UniqueID(&p42->UID, p42->id); + + p42->encoding_index = ENCODING_INDEX_UNKNOWN; + p42->nearest_encoding_index = ENCODING_INDEX_ISOLATIN1; + + p42->FAPI = 0; + p42->FAPI_font_data = 0; + + /* Type 42 specific: */ + + p42->data.string_proc = xps_true_callback_string_proc; + p42->data.proc_data = font; + + gs_type42_font_init(p42, font->subfontid); + p42->data.get_glyph_index = xps_true_get_glyph_index; + } + + if ((code = gs_definefont(ctx->fontdir, font->font)) < 0) { + return(code); + } + + code = xps_fapi_passfont (font->font, NULL, NULL, font->data, font->length); + return code; +} +","@@ -385,7 +385,7 @@ xps_init_truetype_font(xps_context_t *ctx, xps_font_t *font) + p42->procs.build_char = xps_true_callback_build_char; + + memset(p42->font_name.chars, 0, sizeof(p42->font_name.chars)); +- xps_load_sfnt_name(font, (char*)p42->font_name.chars); ++ xps_load_sfnt_name(font, (char*)p42->font_name.chars, sizeof(p42->font_name.chars)); + p42->font_name.size = strlen((char*)p42->font_name.chars); + + memset(p42->key_name.chars, 0, sizeof(p42->key_name.chars));",1027,1263,2048 +7918,"static void cmd_parse_status(struct ImapData *idata, char *s) +{ + char *value = NULL; + struct Buffy *inc = NULL; + struct ImapMbox mx; + struct ImapStatus *status = NULL; + unsigned int olduv, oldun; + unsigned int litlen; + short new = 0; + short new_msg_count = 0; + + char *mailbox = imap_next_word(s); + + /* We need a real tokenizer. */ + if (imap_get_literal_count(mailbox, &litlen) == 0) + { + if (imap_cmd_step(idata) != IMAP_CMD_CONTINUE) + { + idata->status = IMAP_FATAL; + return; + } + mailbox = idata->buf; + s = mailbox + litlen; + *s = '\0'; + s++; + SKIPWS(s); + } + else + { + s = imap_next_word(mailbox); + *(s - 1) = '\0'; + imap_unmunge_mbox_name(idata, mailbox); + } + + status = imap_mboxcache_get(idata, mailbox, 1); + olduv = status->uidvalidity; + oldun = status->uidnext; + + if (*s++ != '(') + { + mutt_debug(1, ""Error parsing STATUS\n""); + return; + } + while (*s && *s != ')') + { + value = imap_next_word(s); + + errno = 0; + const unsigned long ulcount = strtoul(value, &value, 10); + if (((errno == ERANGE) && (ulcount == ULONG_MAX)) || ((unsigned int) ulcount != ulcount)) + { + mutt_debug(1, ""Error parsing STATUS number\n""); + return; + } + const unsigned int count = (unsigned int) ulcount; + + if (mutt_str_strncmp(""MESSAGES"", s, 8) == 0) + { + status->messages = count; + new_msg_count = 1; + } + else if (mutt_str_strncmp(""RECENT"", s, 6) == 0) + status->recent = count; + else if (mutt_str_strncmp(""UIDNEXT"", s, 7) == 0) + status->uidnext = count; + else if (mutt_str_strncmp(""UIDVALIDITY"", s, 11) == 0) + status->uidvalidity = count; + else if (mutt_str_strncmp(""UNSEEN"", s, 6) == 0) + status->unseen = count; + + s = value; + if (*s && *s != ')') + s = imap_next_word(s); + } + mutt_debug(3, ""%s (UIDVALIDITY: %u, UIDNEXT: %u) %d messages, %d recent, %d unseen\n"", + status->name, status->uidvalidity, status->uidnext, + status->messages, status->recent, status->unseen); + + /* caller is prepared to handle the result herself */ + if (idata->cmddata && idata->cmdtype == IMAP_CT_STATUS) + { + memcpy(idata->cmddata, status, sizeof(struct ImapStatus)); + return; + } + + mutt_debug(3, ""Running default STATUS handler\n""); + + /* should perhaps move this code back to imap_buffy_check */ + for (inc = Incoming; inc; inc = inc->next) + { + if (inc->magic != MUTT_IMAP) + continue; + + if (imap_parse_path(inc->path, &mx) < 0) + { + mutt_debug(1, ""Error parsing mailbox %s, skipping\n"", inc->path); + continue; + } + + if (imap_account_match(&idata->conn->account, &mx.account)) + { + if (mx.mbox) + { + value = mutt_str_strdup(mx.mbox); + imap_fix_path(idata, mx.mbox, value, mutt_str_strlen(value) + 1); + FREE(&mx.mbox); + } + else + value = mutt_str_strdup(""INBOX""); + + if (value && (imap_mxcmp(mailbox, value) == 0)) + { + mutt_debug(3, ""Found %s in buffy list (OV: %u ON: %u U: %d)\n"", mailbox, + olduv, oldun, status->unseen); + + if (MailCheckRecent) + { + if (olduv && olduv == status->uidvalidity) + { + if (oldun < status->uidnext) + new = (status->unseen > 0); + } + else if (!olduv && !oldun) + { + /* first check per session, use recent. might need a flag for this. */ + new = (status->recent > 0); + } + else + new = (status->unseen > 0); + } + else + new = (status->unseen > 0); + +#ifdef USE_SIDEBAR + if ((inc->new != new) || (inc->msg_count != status->messages) || + (inc->msg_unread != status->unseen)) + { + mutt_menu_set_current_redraw(REDRAW_SIDEBAR); + } +#endif + inc->new = new; + if (new_msg_count) + inc->msg_count = status->messages; + inc->msg_unread = status->unseen; + + if (inc->new) + { + /* force back to keep detecting new mail until the mailbox is + opened */ + status->uidnext = oldun; + } + + FREE(&value); + return; + } + + FREE(&value); + } + + FREE(&mx.mbox); + } +} +",0,"static void cmd_parse_status(struct ImapData *idata, char *s) +{ + char *value = NULL; + struct Buffy *inc = NULL; + struct ImapMbox mx; + struct ImapStatus *status = NULL; + unsigned int olduv, oldun; + unsigned int litlen; + short new = 0; + short new_msg_count = 0; + + char *mailbox = imap_next_word(s); + + /* We need a real tokenizer. */ + if (imap_get_literal_count(mailbox, &litlen) == 0) + { + if (imap_cmd_step(idata) != IMAP_CMD_CONTINUE) + { + idata->status = IMAP_FATAL; + return; + } + mailbox = idata->buf; + s = mailbox + litlen; + *s = '\0'; + s++; + SKIPWS(s); + } + else + { + s = imap_next_word(mailbox); + *(s - 1) = '\0'; + imap_unmunge_mbox_name(idata, mailbox); + } + + status = imap_mboxcache_get(idata, mailbox, 1); + olduv = status->uidvalidity; + oldun = status->uidnext; + + if (*s++ != '(') + { + mutt_debug(1, ""Error parsing STATUS\n""); + return; + } + while (*s && *s != ')') + { + value = imap_next_word(s); + + errno = 0; + const unsigned long ulcount = strtoul(value, &value, 10); + if (((errno == ERANGE) && (ulcount == ULONG_MAX)) || ((unsigned int) ulcount != ulcount)) + { + mutt_debug(1, ""Error parsing STATUS number\n""); + return; + } + const unsigned int count = (unsigned int) ulcount; + + if (mutt_str_strncmp(""MESSAGES"", s, 8) == 0) + { + status->messages = count; + new_msg_count = 1; + } + else if (mutt_str_strncmp(""RECENT"", s, 6) == 0) + status->recent = count; + else if (mutt_str_strncmp(""UIDNEXT"", s, 7) == 0) + status->uidnext = count; + else if (mutt_str_strncmp(""UIDVALIDITY"", s, 11) == 0) + status->uidvalidity = count; + else if (mutt_str_strncmp(""UNSEEN"", s, 6) == 0) + status->unseen = count; + + s = value; + if (*s && *s != ')') + s = imap_next_word(s); + } + mutt_debug(3, ""%s (UIDVALIDITY: %u, UIDNEXT: %u) %d messages, %d recent, %d unseen\n"", + status->name, status->uidvalidity, status->uidnext, + status->messages, status->recent, status->unseen); + + /* caller is prepared to handle the result herself */ + if (idata->cmddata && idata->cmdtype == IMAP_CT_STATUS) + { + memcpy(idata->cmddata, status, sizeof(struct ImapStatus)); + return; + } + + mutt_debug(3, ""Running default STATUS handler\n""); + + /* should perhaps move this code back to imap_buffy_check */ + for (inc = Incoming; inc; inc = inc->next) + { + if (inc->magic != MUTT_IMAP) + continue; + + if (imap_parse_path(inc->path, &mx) < 0) + { + mutt_debug(1, ""Error parsing mailbox %s, skipping\n"", inc->path); + continue; + } + + if (imap_account_match(&idata->conn->account, &mx.account)) + { + if (mx.mbox) + { + value = mutt_str_strdup(mx.mbox); + imap_fix_path(idata, mx.mbox, value, mutt_str_strlen(value) + 1); + FREE(&mx.mbox); + } + else + value = mutt_str_strdup(""INBOX""); + + if (value && (imap_mxcmp(mailbox, value) == 0)) + { + mutt_debug(3, ""Found %s in buffy list (OV: %u ON: %u U: %d)\n"", mailbox, + olduv, oldun, status->unseen); + + if (MailCheckRecent) + { + if (olduv && olduv == status->uidvalidity) + { + if (oldun < status->uidnext) + new = (status->unseen > 0); + } + else if (!olduv && !oldun) + { + /* first check per session, use recent. might need a flag for this. */ + new = (status->recent > 0); + } + else + new = (status->unseen > 0); + } + else + new = (status->unseen > 0); + +#ifdef USE_SIDEBAR + if ((inc->new != new) || (inc->msg_count != status->messages) || + (inc->msg_unread != status->unseen)) + { + mutt_menu_set_current_redraw(REDRAW_SIDEBAR); + } +#endif + inc->new = new; + if (new_msg_count) + inc->msg_count = status->messages; + inc->msg_unread = status->unseen; + + if (inc->new) + { + /* force back to keep detecting new mail until the mailbox is + opened */ + status->uidnext = oldun; + } + + FREE(&value); + return; + } + + FREE(&value); + } + + FREE(&mx.mbox); + } +} +","@@ -499,7 +499,7 @@ static void cmd_parse_lsub(struct ImapData *idata, char *s) + mutt_str_strfcpy(buf, ""mailboxes \"""", sizeof(buf)); + mutt_account_tourl(&idata->conn->account, &url); + /* escape \ and "" */ +- imap_quote_string(errstr, sizeof(errstr), list.name); ++ imap_quote_string(errstr, sizeof(errstr), list.name, true); + url.path = errstr + 1; + url.path[strlen(url.path) - 1] = '\0'; + if (mutt_str_strcmp(url.user, ImapUser) == 0)",1246,1482,2048 +11321,"xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){ + xmlXPathObjectPtr obj1, obj2; + + if (nargs != 2) { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, + ""key() : expects two arguments\n""); + ctxt->error = XPATH_INVALID_ARITY; + return; + } + + /* + * Get the key's value. + */ + obj2 = valuePop(ctxt); + xmlXPathStringFunction(ctxt, 1); + if ((obj2 == NULL) || + (ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, + ""key() : invalid arg expecting a string\n""); + ctxt->error = XPATH_INVALID_TYPE; + xmlXPathFreeObject(obj2); + + return; + } + /* + * Get the key's name. + */ + obj1 = valuePop(ctxt); + + if ((obj2->type == XPATH_NODESET) || (obj2->type == XPATH_XSLT_TREE)) { + int i; + xmlXPathObjectPtr newobj, ret; + + ret = xmlXPathNewNodeSet(NULL); + + if (obj2->nodesetval != NULL) { + for (i = 0; i < obj2->nodesetval->nodeNr; i++) { + valuePush(ctxt, xmlXPathObjectCopy(obj1)); + valuePush(ctxt, + xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[i])); + xmlXPathStringFunction(ctxt, 1); + xsltKeyFunction(ctxt, 2); + newobj = valuePop(ctxt); + ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval, + newobj->nodesetval); + xmlXPathFreeObject(newobj); + } + } + valuePush(ctxt, ret); + } else { + xmlNodeSetPtr nodelist = NULL; + xmlChar *key = NULL, *value; + const xmlChar *keyURI; + xsltTransformContextPtr tctxt; + xmlChar *qname, *prefix; + xmlXPathContextPtr xpctxt = ctxt->context; + xmlNodePtr tmpNode = NULL; + xsltDocumentPtr oldDocInfo; + + tctxt = xsltXPathGetTransformContext(ctxt); + + oldDocInfo = tctxt->document; + + if (xpctxt->node == NULL) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""Internal error in xsltKeyFunction(): "" + ""The context node is not set on the XPath context.\n""); + tctxt->state = XSLT_STATE_STOPPED; + goto error; + } + /* + * Get the associated namespace URI if qualified name + */ + qname = obj1->stringval; + key = xmlSplitQName2(qname, &prefix); + if (key == NULL) { + key = xmlStrdup(obj1->stringval); + keyURI = NULL; + if (prefix != NULL) + xmlFree(prefix); + } else { + if (prefix != NULL) { + keyURI = xmlXPathNsLookup(xpctxt, prefix); + if (keyURI == NULL) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""key() : prefix %s is not bound\n"", prefix); + /* + * TODO: Shouldn't we stop here? + */ + } + xmlFree(prefix); + } else { + keyURI = NULL; + } + } + + /* + * Force conversion of first arg to string + */ + valuePush(ctxt, obj2); + xmlXPathStringFunction(ctxt, 1); + if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""key() : invalid arg expecting a string\n""); + ctxt->error = XPATH_INVALID_TYPE; + goto error; + } + obj2 = valuePop(ctxt); + value = obj2->stringval; + + /* + * We need to ensure that ctxt->document is available for + * xsltGetKey(). + * First find the relevant doc, which is the context node's + * owner doc; using context->doc is not safe, since + * the doc could have been acquired via the document() function, + * or the doc might be a Result Tree Fragment. + * FUTURE INFO: In XSLT 2.0 the key() function takes an additional + * argument indicating the doc to use. + */ + if (xpctxt->node->type == XML_NAMESPACE_DECL) { + /* + * REVISIT: This is a libxml hack! Check xpath.c for details. + * The XPath module sets the owner element of a ns-node on + * the ns->next field. + */ + if ((((xmlNsPtr) xpctxt->node)->next != NULL) && + (((xmlNsPtr) xpctxt->node)->next->type == XML_ELEMENT_NODE)) + { + tmpNode = (xmlNodePtr) ((xmlNsPtr) xpctxt->node)->next; + } + } else + tmpNode = xpctxt->node; + + if ((tmpNode == NULL) || (tmpNode->doc == NULL)) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""Internal error in xsltKeyFunction(): "" + ""Couldn't get the doc of the XPath context node.\n""); + goto error; + } + + if ((tctxt->document == NULL) || + (tctxt->document->doc != tmpNode->doc)) + { + if (tmpNode->doc->name && (tmpNode->doc->name[0] == ' ')) { + /* + * This is a Result Tree Fragment. + */ + if (tmpNode->doc->_private == NULL) { + tmpNode->doc->_private = xsltNewDocument(tctxt, tmpNode->doc); + if (tmpNode->doc->_private == NULL) + goto error; + } + tctxt->document = (xsltDocumentPtr) tmpNode->doc->_private; + } else { + /* + * May be the initial source doc or a doc acquired via the + * document() function. + */ + tctxt->document = xsltFindDocument(tctxt, tmpNode->doc); + } + if (tctxt->document == NULL) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""Internal error in xsltKeyFunction(): "" + ""Could not get the document info of a context doc.\n""); + tctxt->state = XSLT_STATE_STOPPED; + goto error; + } + } + /* + * Get/compute the key value. + */ + nodelist = xsltGetKey(tctxt, key, keyURI, value); + +error: + tctxt->document = oldDocInfo; + valuePush(ctxt, xmlXPathWrapNodeSet( + xmlXPathNodeSetMerge(NULL, nodelist))); + if (key != NULL) + xmlFree(key); + } + + if (obj1 != NULL) + xmlXPathFreeObject(obj1); + if (obj2 != NULL) + xmlXPathFreeObject(obj2); +} +",0,"xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){ + xmlXPathObjectPtr obj1, obj2; + + if (nargs != 2) { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, + ""key() : expects two arguments\n""); + ctxt->error = XPATH_INVALID_ARITY; + return; + } + + /* + * Get the key's value. + */ + obj2 = valuePop(ctxt); + xmlXPathStringFunction(ctxt, 1); + if ((obj2 == NULL) || + (ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, + ""key() : invalid arg expecting a string\n""); + ctxt->error = XPATH_INVALID_TYPE; + xmlXPathFreeObject(obj2); + + return; + } + /* + * Get the key's name. + */ + obj1 = valuePop(ctxt); + + if ((obj2->type == XPATH_NODESET) || (obj2->type == XPATH_XSLT_TREE)) { + int i; + xmlXPathObjectPtr newobj, ret; + + ret = xmlXPathNewNodeSet(NULL); + + if (obj2->nodesetval != NULL) { + for (i = 0; i < obj2->nodesetval->nodeNr; i++) { + valuePush(ctxt, xmlXPathObjectCopy(obj1)); + valuePush(ctxt, + xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[i])); + xmlXPathStringFunction(ctxt, 1); + xsltKeyFunction(ctxt, 2); + newobj = valuePop(ctxt); + ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval, + newobj->nodesetval); + xmlXPathFreeObject(newobj); + } + } + valuePush(ctxt, ret); + } else { + xmlNodeSetPtr nodelist = NULL; + xmlChar *key = NULL, *value; + const xmlChar *keyURI; + xsltTransformContextPtr tctxt; + xmlChar *qname, *prefix; + xmlXPathContextPtr xpctxt = ctxt->context; + xmlNodePtr tmpNode = NULL; + xsltDocumentPtr oldDocInfo; + + tctxt = xsltXPathGetTransformContext(ctxt); + + oldDocInfo = tctxt->document; + + if (xpctxt->node == NULL) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""Internal error in xsltKeyFunction(): "" + ""The context node is not set on the XPath context.\n""); + tctxt->state = XSLT_STATE_STOPPED; + goto error; + } + /* + * Get the associated namespace URI if qualified name + */ + qname = obj1->stringval; + key = xmlSplitQName2(qname, &prefix); + if (key == NULL) { + key = xmlStrdup(obj1->stringval); + keyURI = NULL; + if (prefix != NULL) + xmlFree(prefix); + } else { + if (prefix != NULL) { + keyURI = xmlXPathNsLookup(xpctxt, prefix); + if (keyURI == NULL) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""key() : prefix %s is not bound\n"", prefix); + /* + * TODO: Shouldn't we stop here? + */ + } + xmlFree(prefix); + } else { + keyURI = NULL; + } + } + + /* + * Force conversion of first arg to string + */ + valuePush(ctxt, obj2); + xmlXPathStringFunction(ctxt, 1); + if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""key() : invalid arg expecting a string\n""); + ctxt->error = XPATH_INVALID_TYPE; + goto error; + } + obj2 = valuePop(ctxt); + value = obj2->stringval; + + /* + * We need to ensure that ctxt->document is available for + * xsltGetKey(). + * First find the relevant doc, which is the context node's + * owner doc; using context->doc is not safe, since + * the doc could have been acquired via the document() function, + * or the doc might be a Result Tree Fragment. + * FUTURE INFO: In XSLT 2.0 the key() function takes an additional + * argument indicating the doc to use. + */ + if (xpctxt->node->type == XML_NAMESPACE_DECL) { + /* + * REVISIT: This is a libxml hack! Check xpath.c for details. + * The XPath module sets the owner element of a ns-node on + * the ns->next field. + */ + if ((((xmlNsPtr) xpctxt->node)->next != NULL) && + (((xmlNsPtr) xpctxt->node)->next->type == XML_ELEMENT_NODE)) + { + tmpNode = (xmlNodePtr) ((xmlNsPtr) xpctxt->node)->next; + } + } else + tmpNode = xpctxt->node; + + if ((tmpNode == NULL) || (tmpNode->doc == NULL)) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""Internal error in xsltKeyFunction(): "" + ""Couldn't get the doc of the XPath context node.\n""); + goto error; + } + + if ((tctxt->document == NULL) || + (tctxt->document->doc != tmpNode->doc)) + { + if (tmpNode->doc->name && (tmpNode->doc->name[0] == ' ')) { + /* + * This is a Result Tree Fragment. + */ + if (tmpNode->doc->_private == NULL) { + tmpNode->doc->_private = xsltNewDocument(tctxt, tmpNode->doc); + if (tmpNode->doc->_private == NULL) + goto error; + } + tctxt->document = (xsltDocumentPtr) tmpNode->doc->_private; + } else { + /* + * May be the initial source doc or a doc acquired via the + * document() function. + */ + tctxt->document = xsltFindDocument(tctxt, tmpNode->doc); + } + if (tctxt->document == NULL) { + xsltTransformError(tctxt, NULL, tctxt->inst, + ""Internal error in xsltKeyFunction(): "" + ""Could not get the document info of a context doc.\n""); + tctxt->state = XSLT_STATE_STOPPED; + goto error; + } + } + /* + * Get/compute the key value. + */ + nodelist = xsltGetKey(tctxt, key, keyURI, value); + +error: + tctxt->document = oldDocInfo; + valuePush(ctxt, xmlXPathWrapNodeSet( + xmlXPathNodeSetMerge(NULL, nodelist))); + if (key != NULL) + xmlFree(key); + } + + if (obj1 != NULL) + xmlXPathFreeObject(obj1); + if (obj2 != NULL) + xmlXPathFreeObject(obj2); +} +","@@ -654,14 +654,14 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) + void + xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){ + xmlNodePtr cur = NULL; ++ xmlXPathObjectPtr obj = NULL; + long val; + xmlChar str[30]; + xmlDocPtr doc; + + if (nargs == 0) { + cur = ctxt->context->node; + } else if (nargs == 1) { +- xmlXPathObjectPtr obj; + xmlNodeSetPtr nodelist; + int i, ret; + +@@ -684,7 +684,6 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){ + if (ret == -1) + cur = nodelist->nodeTab[i]; + } +- xmlXPathFreeObject(obj); + } else { + xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, + ""generate-id() : invalid number of args %d\n"", nargs); +@@ -707,6 +706,9 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){ + + } + ++ if (obj) ++ xmlXPathFreeObject(obj); ++ + val = (long)((char *)cur - (char *)doc); + if (val >= 0) { + sprintf((char *)str, ""idp%ld"", val);",1561,1797,2048 +5045,"static void opj_get_encoding_parameters( const opj_image_t *p_image, + const opj_cp_t *p_cp, + OPJ_UINT32 p_tileno, + OPJ_INT32 * p_tx0, + OPJ_INT32 * p_tx1, + OPJ_INT32 * p_ty0, + OPJ_INT32 * p_ty1, + OPJ_UINT32 * p_dx_min, + OPJ_UINT32 * p_dy_min, + OPJ_UINT32 * p_max_prec, + OPJ_UINT32 * p_max_res ) +{ + /* loop */ + OPJ_UINT32 compno, resno; + /* pointers */ + const opj_tcp_t *l_tcp = 00; + const opj_tccp_t * l_tccp = 00; + const opj_image_comp_t * l_img_comp = 00; + + /* position in x and y of tile */ + OPJ_UINT32 p, q; + + /* preconditions */ + assert(p_cp != 00); + assert(p_image != 00); + assert(p_tileno < p_cp->tw * p_cp->th); + + /* initializations */ + l_tcp = &p_cp->tcps [p_tileno]; + l_img_comp = p_image->comps; + l_tccp = l_tcp->tccps; + + /* here calculation of tx0, tx1, ty0, ty1, maxprec, dx and dy */ + p = p_tileno % p_cp->tw; + q = p_tileno / p_cp->tw; + + /* find extent of tile */ + *p_tx0 = opj_int_max((OPJ_INT32)(p_cp->tx0 + p * p_cp->tdx), (OPJ_INT32)p_image->x0); + *p_tx1 = opj_int_min((OPJ_INT32)(p_cp->tx0 + (p + 1) * p_cp->tdx), (OPJ_INT32)p_image->x1); + *p_ty0 = opj_int_max((OPJ_INT32)(p_cp->ty0 + q * p_cp->tdy), (OPJ_INT32)p_image->y0); + *p_ty1 = opj_int_min((OPJ_INT32)(p_cp->ty0 + (q + 1) * p_cp->tdy), (OPJ_INT32)p_image->y1); + + /* max precision is 0 (can only grow) */ + *p_max_prec = 0; + *p_max_res = 0; + + /* take the largest value for dx_min and dy_min */ + *p_dx_min = 0x7fffffff; + *p_dy_min = 0x7fffffff; + + for (compno = 0; compno < p_image->numcomps; ++compno) { + /* arithmetic variables to calculate */ + OPJ_UINT32 l_level_no; + OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1; + OPJ_INT32 l_px0, l_py0, l_px1, py1; + OPJ_UINT32 l_pdx, l_pdy; + OPJ_UINT32 l_pw, l_ph; + OPJ_UINT32 l_product; + OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1; + + l_tcx0 = opj_int_ceildiv(*p_tx0, (OPJ_INT32)l_img_comp->dx); + l_tcy0 = opj_int_ceildiv(*p_ty0, (OPJ_INT32)l_img_comp->dy); + l_tcx1 = opj_int_ceildiv(*p_tx1, (OPJ_INT32)l_img_comp->dx); + l_tcy1 = opj_int_ceildiv(*p_ty1, (OPJ_INT32)l_img_comp->dy); + + if (l_tccp->numresolutions > *p_max_res) { + *p_max_res = l_tccp->numresolutions; + } + + /* use custom size for precincts */ + for (resno = 0; resno < l_tccp->numresolutions; ++resno) { + OPJ_UINT32 l_dx, l_dy; + + /* precinct width and height */ + l_pdx = l_tccp->prcw[resno]; + l_pdy = l_tccp->prch[resno]; + + l_dx = l_img_comp->dx * (1u << (l_pdx + l_tccp->numresolutions - 1 - resno)); + l_dy = l_img_comp->dy * (1u << (l_pdy + l_tccp->numresolutions - 1 - resno)); + + /* take the minimum size for dx for each comp and resolution */ + *p_dx_min = opj_uint_min(*p_dx_min, l_dx); + *p_dy_min = opj_uint_min(*p_dy_min, l_dy); + + /* various calculations of extents */ + l_level_no = l_tccp->numresolutions - 1 - resno; + + l_rx0 = opj_int_ceildivpow2(l_tcx0, (OPJ_INT32)l_level_no); + l_ry0 = opj_int_ceildivpow2(l_tcy0, (OPJ_INT32)l_level_no); + l_rx1 = opj_int_ceildivpow2(l_tcx1, (OPJ_INT32)l_level_no); + l_ry1 = opj_int_ceildivpow2(l_tcy1, (OPJ_INT32)l_level_no); + + l_px0 = opj_int_floordivpow2(l_rx0, (OPJ_INT32)l_pdx) << l_pdx; + l_py0 = opj_int_floordivpow2(l_ry0, (OPJ_INT32)l_pdy) << l_pdy; + l_px1 = opj_int_ceildivpow2(l_rx1, (OPJ_INT32)l_pdx) << l_pdx; + + py1 = opj_int_ceildivpow2(l_ry1, (OPJ_INT32)l_pdy) << l_pdy; + + l_pw = (l_rx0==l_rx1)?0:(OPJ_UINT32)((l_px1 - l_px0) >> l_pdx); + l_ph = (l_ry0==l_ry1)?0:(OPJ_UINT32)((py1 - l_py0) >> l_pdy); + + l_product = l_pw * l_ph; + + /* update precision */ + if (l_product > *p_max_prec) { + *p_max_prec = l_product; + } + } + ++l_img_comp; + ++l_tccp; + } +} +",0,"static void opj_get_encoding_parameters( const opj_image_t *p_image, + const opj_cp_t *p_cp, + OPJ_UINT32 p_tileno, + OPJ_INT32 * p_tx0, + OPJ_INT32 * p_tx1, + OPJ_INT32 * p_ty0, + OPJ_INT32 * p_ty1, + OPJ_UINT32 * p_dx_min, + OPJ_UINT32 * p_dy_min, + OPJ_UINT32 * p_max_prec, + OPJ_UINT32 * p_max_res ) +{ + /* loop */ + OPJ_UINT32 compno, resno; + /* pointers */ + const opj_tcp_t *l_tcp = 00; + const opj_tccp_t * l_tccp = 00; + const opj_image_comp_t * l_img_comp = 00; + + /* position in x and y of tile */ + OPJ_UINT32 p, q; + + /* preconditions */ + assert(p_cp != 00); + assert(p_image != 00); + assert(p_tileno < p_cp->tw * p_cp->th); + + /* initializations */ + l_tcp = &p_cp->tcps [p_tileno]; + l_img_comp = p_image->comps; + l_tccp = l_tcp->tccps; + + /* here calculation of tx0, tx1, ty0, ty1, maxprec, dx and dy */ + p = p_tileno % p_cp->tw; + q = p_tileno / p_cp->tw; + + /* find extent of tile */ + *p_tx0 = opj_int_max((OPJ_INT32)(p_cp->tx0 + p * p_cp->tdx), (OPJ_INT32)p_image->x0); + *p_tx1 = opj_int_min((OPJ_INT32)(p_cp->tx0 + (p + 1) * p_cp->tdx), (OPJ_INT32)p_image->x1); + *p_ty0 = opj_int_max((OPJ_INT32)(p_cp->ty0 + q * p_cp->tdy), (OPJ_INT32)p_image->y0); + *p_ty1 = opj_int_min((OPJ_INT32)(p_cp->ty0 + (q + 1) * p_cp->tdy), (OPJ_INT32)p_image->y1); + + /* max precision is 0 (can only grow) */ + *p_max_prec = 0; + *p_max_res = 0; + + /* take the largest value for dx_min and dy_min */ + *p_dx_min = 0x7fffffff; + *p_dy_min = 0x7fffffff; + + for (compno = 0; compno < p_image->numcomps; ++compno) { + /* arithmetic variables to calculate */ + OPJ_UINT32 l_level_no; + OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1; + OPJ_INT32 l_px0, l_py0, l_px1, py1; + OPJ_UINT32 l_pdx, l_pdy; + OPJ_UINT32 l_pw, l_ph; + OPJ_UINT32 l_product; + OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1; + + l_tcx0 = opj_int_ceildiv(*p_tx0, (OPJ_INT32)l_img_comp->dx); + l_tcy0 = opj_int_ceildiv(*p_ty0, (OPJ_INT32)l_img_comp->dy); + l_tcx1 = opj_int_ceildiv(*p_tx1, (OPJ_INT32)l_img_comp->dx); + l_tcy1 = opj_int_ceildiv(*p_ty1, (OPJ_INT32)l_img_comp->dy); + + if (l_tccp->numresolutions > *p_max_res) { + *p_max_res = l_tccp->numresolutions; + } + + /* use custom size for precincts */ + for (resno = 0; resno < l_tccp->numresolutions; ++resno) { + OPJ_UINT32 l_dx, l_dy; + + /* precinct width and height */ + l_pdx = l_tccp->prcw[resno]; + l_pdy = l_tccp->prch[resno]; + + l_dx = l_img_comp->dx * (1u << (l_pdx + l_tccp->numresolutions - 1 - resno)); + l_dy = l_img_comp->dy * (1u << (l_pdy + l_tccp->numresolutions - 1 - resno)); + + /* take the minimum size for dx for each comp and resolution */ + *p_dx_min = opj_uint_min(*p_dx_min, l_dx); + *p_dy_min = opj_uint_min(*p_dy_min, l_dy); + + /* various calculations of extents */ + l_level_no = l_tccp->numresolutions - 1 - resno; + + l_rx0 = opj_int_ceildivpow2(l_tcx0, (OPJ_INT32)l_level_no); + l_ry0 = opj_int_ceildivpow2(l_tcy0, (OPJ_INT32)l_level_no); + l_rx1 = opj_int_ceildivpow2(l_tcx1, (OPJ_INT32)l_level_no); + l_ry1 = opj_int_ceildivpow2(l_tcy1, (OPJ_INT32)l_level_no); + + l_px0 = opj_int_floordivpow2(l_rx0, (OPJ_INT32)l_pdx) << l_pdx; + l_py0 = opj_int_floordivpow2(l_ry0, (OPJ_INT32)l_pdy) << l_pdy; + l_px1 = opj_int_ceildivpow2(l_rx1, (OPJ_INT32)l_pdx) << l_pdx; + + py1 = opj_int_ceildivpow2(l_ry1, (OPJ_INT32)l_pdy) << l_pdy; + + l_pw = (l_rx0==l_rx1)?0:(OPJ_UINT32)((l_px1 - l_px0) >> l_pdx); + l_ph = (l_ry0==l_ry1)?0:(OPJ_UINT32)((py1 - l_py0) >> l_pdy); + + l_product = l_pw * l_ph; + + /* update precision */ + if (l_product > *p_max_prec) { + *p_max_prec = l_product; + } + } + ++l_img_comp; + ++l_tccp; + } +} +","@@ -1237,7 +1237,13 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image, + l_current_pi = l_pi; + + /* memory allocation for include */ +- l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16)); ++ /* prevent an integer overflow issue */ ++ l_current_pi->include = 00; ++ if (l_step_l <= (SIZE_MAX / (l_tcp->numlayers + 1U))) ++ { ++ l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16)); ++ } ++ + if + (!l_current_pi->include) + {",1521,1757,2048 +18161,"get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h, const ImageInfo *image_info ) { + ddjvu_format_t + *format; + + ddjvu_page_type_t + type; + + Image + *image; + + int + ret, + stride; + + unsigned char + *q; + + ddjvu_rect_t rect; + rect.x = x; + rect.y = y; + rect.w = (unsigned int) w; /* /10 */ + rect.h = (unsigned int) h; /* /10 */ + + image = lc->image; + type = ddjvu_page_get_type(lc->page); + + /* stride of this temporary buffer: */ + stride = (type == DDJVU_PAGETYPE_BITONAL)? + (image->columns + 7)/8 : image->columns *3; + + q = (unsigned char *) AcquireQuantumMemory(image->rows,stride); + if (q == (unsigned char *) NULL) + return; + + format = ddjvu_format_create( + (type == DDJVU_PAGETYPE_BITONAL)?DDJVU_FORMAT_LSBTOMSB : DDJVU_FORMAT_RGB24, + /* DDJVU_FORMAT_RGB24 + * DDJVU_FORMAT_RGBMASK32*/ + /* DDJVU_FORMAT_RGBMASK32 */ + 0, NULL); + +#if 0 + /* fixme: ThrowReaderException is a macro, which uses `exception' variable */ + if (format == NULL) + { + abort(); + /* ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); */ + } + +#endif + ddjvu_format_set_row_order(format, 1); + ddjvu_format_set_y_direction(format, 1); + + ret = ddjvu_page_render(page, + DDJVU_RENDER_COLOR, /* ddjvu_render_mode_t */ + &rect, + &rect, /* mmc: ?? */ + format, + stride, /* ?? */ + (char*)q); + (void) ret; + ddjvu_format_release(format); + + + if (type == DDJVU_PAGETYPE_BITONAL) { + /* */ +#if DEBUG + printf(""%s: expanding BITONAL page/image\n"", __FUNCTION__); +#endif + register IndexPacket *indexes; + size_t bit, byte; + + for (y=0; y < (ssize_t) image->rows; y++) + { + PixelPacket * o = QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception); + if (o == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + bit=0; + byte=0; + + /* fixme: the non-aligned, last =<7 bits ! that's ok!!!*/ + for (x= 0; x < (ssize_t) image->columns; x++) + { + if (bit == 0) byte= (size_t) q[(y * stride) + (x / 8)]; + + if (indexes != (IndexPacket *) NULL) + SetPixelIndex(indexes+x,(IndexPacket) (((byte & 0x01) != 0) ? 0x00 : 0x01)); + bit++; + if (bit == 8) + bit=0; + byte>>=1; + } + if (SyncAuthenticPixels(image,&image->exception) == MagickFalse) + break; + } + if (!image->ping) + SyncImage(image); + } else { + #if DEBUG + printf(""%s: expanding PHOTO page/image\n"", __FUNCTION__); +#endif + /* now transfer line-wise: */ + ssize_t i; +#if 0 + /* old: */ + char* r; +#else + register PixelPacket *r; + unsigned char *s; +#endif + s=q; + for (i = 0;i< (ssize_t) image->rows; i++) + { +#if DEBUG + if (i % 1000 == 0) printf(""%d\n"",i); +#endif + r = QueueAuthenticPixels(image,0,i,image->columns,1,&image->exception); + if (r == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(r,ScaleCharToQuantum(*s++)); + SetPixelGreen(r,ScaleCharToQuantum(*s++)); + SetPixelBlue(r,ScaleCharToQuantum(*s++)); + r++; + } + + (void) SyncAuthenticPixels(image,&image->exception); + } + } + q=(unsigned char *) RelinquishMagickMemory(q); +} +",1,"get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h, const ImageInfo *image_info ) { + ddjvu_format_t + *format; + + ddjvu_page_type_t + type; + + Image + *image; + + int + ret, + stride; + + unsigned char + *q; + + ddjvu_rect_t rect; + rect.x = x; + rect.y = y; + rect.w = (unsigned int) w; /* /10 */ + rect.h = (unsigned int) h; /* /10 */ + + image = lc->image; + type = ddjvu_page_get_type(lc->page); + + /* stride of this temporary buffer: */ + stride = (type == DDJVU_PAGETYPE_BITONAL)? + (image->columns + 7)/8 : image->columns *3; + + q = (unsigned char *) AcquireQuantumMemory(image->rows,stride); + if (q == (unsigned char *) NULL) + return; + + format = ddjvu_format_create( + (type == DDJVU_PAGETYPE_BITONAL)?DDJVU_FORMAT_LSBTOMSB : DDJVU_FORMAT_RGB24, + /* DDJVU_FORMAT_RGB24 + * DDJVU_FORMAT_RGBMASK32*/ + /* DDJVU_FORMAT_RGBMASK32 */ + 0, NULL); + +#if 0 + /* fixme: ThrowReaderException is a macro, which uses `exception' variable */ + if (format == NULL) + { + abort(); + /* ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); */ + } + +#endif + ddjvu_format_set_row_order(format, 1); + ddjvu_format_set_y_direction(format, 1); + + ret = ddjvu_page_render(page, + DDJVU_RENDER_COLOR, /* ddjvu_render_mode_t */ + &rect, + &rect, /* mmc: ?? */ + format, + stride, /* ?? */ + (char*)q); + (void) ret; + ddjvu_format_release(format); + + + if (type == DDJVU_PAGETYPE_BITONAL) { + /* */ +#if DEBUG + printf(""%s: expanding BITONAL page/image\n"", __FUNCTION__); +#endif + register IndexPacket *indexes; + size_t bit, byte; + + for (y=0; y < (ssize_t) image->rows; y++) + { + PixelPacket * o = QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception); + if (o == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + bit=0; + byte=0; + + /* fixme: the non-aligned, last =<7 bits ! that's ok!!!*/ + for (x= 0; x < (ssize_t) image->columns; x++) + { + if (bit == 0) byte= (size_t) q[(y * stride) + (x / 8)]; + + if (indexes != (IndexPacket *) NULL) + SetPixelIndex(indexes+x,(IndexPacket) (((byte & 0x01) != 0) ? 0x00 : 0x01)); + bit++; + if (bit == 8) + bit=0; + byte>>=1; + } + if (SyncAuthenticPixels(image,&image->exception) == MagickFalse) + break; + } + if (image->ping == MagickFalse) + SyncImage(image); + } else { + #if DEBUG + printf(""%s: expanding PHOTO page/image\n"", __FUNCTION__); +#endif + /* now transfer line-wise: */ + ssize_t i; +#if 0 + /* old: */ + char* r; +#else + register PixelPacket *r; + unsigned char *s; +#endif + s=q; + for (i = 0;i< (ssize_t) image->rows; i++) + { +#if DEBUG + if (i % 1000 == 0) printf(""%d\n"",i); +#endif + r = QueueAuthenticPixels(image,0,i,image->columns,1,&image->exception); + if (r == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(r,ScaleCharToQuantum(*s++)); + SetPixelGreen(r,ScaleCharToQuantum(*s++)); + SetPixelBlue(r,ScaleCharToQuantum(*s++)); + r++; + } + + (void) SyncAuthenticPixels(image,&image->exception); + } + } + q=(unsigned char *) RelinquishMagickMemory(q); +} +","@@ -418,7 +418,7 @@ get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h, + if (SyncAuthenticPixels(image,&image->exception) == MagickFalse) + break; + } +- if (!image->ping) ++ if (image->ping == MagickFalse) + SyncImage(image); + } else { + #if DEBUG +@@ -577,6 +577,7 @@ static Image *ReadOneDJVUImage(LoadContext* lc,const int pagenum, + Image *image; + int logging; + int tag; ++ MagickBooleanType status; + + /* so, we know that the page is there! Get its dimension, and */ + +@@ -667,6 +668,12 @@ static Image *ReadOneDJVUImage(LoadContext* lc,const int pagenum, + image->matte = MagickTrue; + /* is this useful? */ + } ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + #if DEBUG + printf(""now filling %.20g x %.20g\n"",(double) image->columns,(double) + image->rows);",1025,1261,2048 +17300,"perform_gamma_test(png_modifier *pm, int summary) +{ + /*TODO: remove this*/ + /* Save certain values for the temporary overrides below. */ + unsigned int calculations_use_input_precision = + pm->calculations_use_input_precision; +# ifdef PNG_READ_BACKGROUND_SUPPORTED + double maxout8 = pm->maxout8; +# endif + + /* First some arbitrary no-transform tests: */ + if (!pm->this.speed && pm->test_gamma_threshold) + { + perform_gamma_threshold_tests(pm); + + if (fail(pm)) + return; + } + + /* Now some real transforms. */ + if (pm->test_gamma_transform) + { + if (summary) + { + fflush(stderr); + printf(""Gamma correction error summary\n\n""); + printf(""The printed value is the maximum error in the pixel values\n""); + printf(""calculated by the libpng gamma correction code. The error\n""); + printf(""is calculated as the difference between the output pixel\n""); + printf(""value (always an integer) and the ideal value from the\n""); + printf(""libpng specification (typically not an integer).\n\n""); + + printf(""Expect this value to be less than .5 for 8 bit formats,\n""); + printf(""less than 1 for formats with fewer than 8 bits and a small\n""); + printf(""number (typically less than 5) for the 16 bit formats.\n""); + printf(""For performance reasons the value for 16 bit formats\n""); + printf(""increases when the image file includes an sBIT chunk.\n""); + fflush(stdout); + } + + init_gamma_errors(pm); + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + perform_gamma_transform_tests(pm); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, 0/*who*/, 1/*low bit depth*/, 1/*indexed*/); + + if (fail(pm)) + return; + } + + /* The sbit tests produce much larger errors: */ + if (pm->test_gamma_sbit) + { + init_gamma_errors(pm); + perform_gamma_sbit_tests(pm); + + if (summary) + summarize_gamma_errors(pm, ""sBIT"", pm->sbitlow < 8U, 1/*indexed*/); + + if (fail(pm)) + return; + } + +#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */ + if (pm->test_gamma_scale16) + { + /* The 16 to 8 bit strip operations: */ + init_gamma_errors(pm); + perform_gamma_scale16_tests(pm); + + if (summary) + { + fflush(stderr); + printf(""\nGamma correction with 16 to 8 bit reduction:\n""); + printf("" 16 bit gray: %.5f\n"", pm->error_gray_16); + printf("" 16 bit color: %.5f\n"", pm->error_color_16); + fflush(stdout); + } + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + if (pm->test_gamma_background) + { + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + { + pm->calculations_use_input_precision = 1; + pm->maxout8 = .499; /* because the 16 bit background is smashed */ + } + perform_gamma_composition_tests(pm, PNG_BACKGROUND_GAMMA_UNIQUE, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + pm->maxout8 = maxout8; + + if (summary) + summarize_gamma_errors(pm, ""background"", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if (pm->test_gamma_alpha_mode) + { + int do_background; + + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + for (do_background = ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD; + do_background <= ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN && !fail(pm); + ++do_background) + perform_gamma_composition_tests(pm, do_background, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, ""alpha mode"", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif +} +",0,"perform_gamma_test(png_modifier *pm, int summary) +{ + /*TODO: remove this*/ + /* Save certain values for the temporary overrides below. */ + unsigned int calculations_use_input_precision = + pm->calculations_use_input_precision; +# ifdef PNG_READ_BACKGROUND_SUPPORTED + double maxout8 = pm->maxout8; +# endif + + /* First some arbitrary no-transform tests: */ + if (!pm->this.speed && pm->test_gamma_threshold) + { + perform_gamma_threshold_tests(pm); + + if (fail(pm)) + return; + } + + /* Now some real transforms. */ + if (pm->test_gamma_transform) + { + if (summary) + { + fflush(stderr); + printf(""Gamma correction error summary\n\n""); + printf(""The printed value is the maximum error in the pixel values\n""); + printf(""calculated by the libpng gamma correction code. The error\n""); + printf(""is calculated as the difference between the output pixel\n""); + printf(""value (always an integer) and the ideal value from the\n""); + printf(""libpng specification (typically not an integer).\n\n""); + + printf(""Expect this value to be less than .5 for 8 bit formats,\n""); + printf(""less than 1 for formats with fewer than 8 bits and a small\n""); + printf(""number (typically less than 5) for the 16 bit formats.\n""); + printf(""For performance reasons the value for 16 bit formats\n""); + printf(""increases when the image file includes an sBIT chunk.\n""); + fflush(stdout); + } + + init_gamma_errors(pm); + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + perform_gamma_transform_tests(pm); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, 0/*who*/, 1/*low bit depth*/, 1/*indexed*/); + + if (fail(pm)) + return; + } + + /* The sbit tests produce much larger errors: */ + if (pm->test_gamma_sbit) + { + init_gamma_errors(pm); + perform_gamma_sbit_tests(pm); + + if (summary) + summarize_gamma_errors(pm, ""sBIT"", pm->sbitlow < 8U, 1/*indexed*/); + + if (fail(pm)) + return; + } + +#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */ + if (pm->test_gamma_scale16) + { + /* The 16 to 8 bit strip operations: */ + init_gamma_errors(pm); + perform_gamma_scale16_tests(pm); + + if (summary) + { + fflush(stderr); + printf(""\nGamma correction with 16 to 8 bit reduction:\n""); + printf("" 16 bit gray: %.5f\n"", pm->error_gray_16); + printf("" 16 bit color: %.5f\n"", pm->error_color_16); + fflush(stdout); + } + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + if (pm->test_gamma_background) + { + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + { + pm->calculations_use_input_precision = 1; + pm->maxout8 = .499; /* because the 16 bit background is smashed */ + } + perform_gamma_composition_tests(pm, PNG_BACKGROUND_GAMMA_UNIQUE, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + pm->maxout8 = maxout8; + + if (summary) + summarize_gamma_errors(pm, ""background"", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if (pm->test_gamma_alpha_mode) + { + int do_background; + + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + for (do_background = ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD; + do_background <= ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN && !fail(pm); + ++do_background) + perform_gamma_composition_tests(pm, do_background, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, ""alpha mode"", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif +} +","@@ -1,8 +1,8 @@ + + + /* pngvalid.c - validate libpng by constructing then reading png files. + * +- * Last changed in libpng 1.6.10 [March 6, 2014] +- * Copyright (c) 2014 Glenn Randers-Pehrson ++ * Last changed in libpng 1.5.25 [December 3, 2015] ++ * Copyright (c) 2014-2015 Glenn Randers-Pehrson + * Written by John Cunningham Bowler + * + * This code is released under the libpng license. +@@ -34,6 +34,16 @@ + + # include + #endif + ++#ifndef FE_DIVBYZERO ++# define FE_DIVBYZERO 0 ++#endif ++#ifndef FE_INVALID ++# define FE_INVALID 0 ++#endif ++#ifndef FE_OVERFLOW ++# define FE_OVERFLOW 0 ++#endif ++ + /* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +@@ -64,7 +74,7 @@ + + (defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED)) + + #if PNG_LIBPNG_VER < 10500 +-/* This deliberately lacks the PNG_CONST. */ ++/* This deliberately lacks the const. */ + typedef png_byte *png_const_bytep; + + /* This is copied from 1.5.1 png.h: */ +@@ -147,6 +157,31 @@ + + &(ps)->exception_context + #define context(ps,fault) anon_context(ps); png_store *fault + ++/* This macro returns the number of elements in an array as an (unsigned int), ++ * it is necessary to avoid the inability of certain versions of GCC to use ++ * the value of a compile-time constant when performing range checks. It must ++ * be passed an array name. ++ */ ++#define ARRAY_SIZE(a) ((unsigned int)((sizeof (a))/(sizeof (a)[0]))) ++ ++/* GCC BUG 66447 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66447) requires ++ * some broken GCC versions to be fixed up to avoid invalid whining about auto ++ * variables that are *not* changed within the scope of a setjmp being changed. ++ * ++ * Feel free to extend the list of broken versions. ++ */ ++#define is_gnu(major,minor)\ ++ (defined __GNUC__) && __GNUC__ == (major) && __GNUC_MINOR__ == (minor) ++#define is_gnu_patch(major,minor,patch)\ ++ is_gnu(major,minor) && __GNUC_PATCHLEVEL__ == 0 ++/* For the moment just do it always; all versions of GCC seem to be broken: */ ++#ifdef __GNUC__ ++ const void * volatile make_volatile_for_gnu; ++# define gnu_volatile(x) make_volatile_for_gnu = &x; ++#else /* !GNUC broken versions */ ++# define gnu_volatile(x) ++#endif /* !GNUC broken versions */ ++ + /******************************* UTILITIES ************************************/ + /* Error handling is particularly problematic in production code - error + * handlers often themselves have bugs which lead to programs that detect +@@ -155,7 +190,7 @@ + + * warning messages into buffers that are too small. + */ + static size_t safecat(char *buffer, size_t bufsize, size_t pos, +- PNG_CONST char *cat) ++ const char *cat) + { + while (pos < bufsize && cat != NULL && *cat != 0) + buffer[pos++] = *cat++; +@@ -184,16 +219,16 @@ + + } + #endif + +-static PNG_CONST char invalid[] = ""invalid""; +-static PNG_CONST char sep[] = "": ""; ++static const char invalid[] = ""invalid""; ++static const char sep[] = "": ""; + +-static PNG_CONST char *colour_types[8] = ++static const char *colour_types[8] = + { + ""grayscale"", invalid, ""truecolour"", ""indexed-colour"", + ""grayscale with alpha"", invalid, ""truecolour with alpha"", invalid + }; + +-#ifdef PNG_READ_SUPPORTED ++#ifdef PNG_READ_TRANSFORMS_SUPPORTED + /* Convert a double precision value to fixed point. */ + static png_fixed_point + fix(double d) +@@ -241,7 +276,7 @@ + + make_random_bytes(seed, bytes, 4); + } + +-#ifdef PNG_READ_SUPPORTED ++#if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED + static void + randomize(void *pv, size_t size) + { +@@ -250,7 +285,9 @@ + + } + + #define RANDOMIZE(this) randomize(&(this), sizeof (this)) ++#endif /* READ || WRITE_tRNS */ + ++#ifdef PNG_READ_TRANSFORMS_SUPPORTED + static unsigned int + random_mod(unsigned int max) + { +@@ -261,7 +298,8 @@ + + return x % max; /* 0 .. max-1 */ + } + +-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED ++#if (defined PNG_READ_RGB_TO_GRAY_SUPPORTED) ||\ ++ (defined PNG_READ_FILLER_SUPPORTED) + static int + random_choice(void) + { +@@ -277,7 +315,8 @@ + + /* A numeric ID based on PNG file characteristics. The 'do_interlace' field + * simply records whether pngvalid did the interlace itself or whether it + * was done by libpng. Width and height must be less than 256. 'palette' is an +- * index of the palette to use for formats with a palette (0 otherwise.) ++ * index of the palette to use for formats with a palette otherwise a boolean ++ * indicating if a tRNS chunk was generated. + */ + #define FILEID(col, depth, palette, interlace, width, height, do_interlace) \ + ((png_uint_32)((col) + ((depth)<<3) + ((palette)<<8) + ((interlace)<<13) + \ +@@ -286,7 +325,7 @@ + + #define COL_FROM_ID(id) ((png_byte)((id)& 0x7U)) + #define DEPTH_FROM_ID(id) ((png_byte)(((id) >> 3) & 0x1fU)) + #define PALETTE_FROM_ID(id) (((id) >> 8) & 0x1f) +-#define INTERLACE_FROM_ID(id) ((int)(((id) >> 13) & 0x3)) ++#define INTERLACE_FROM_ID(id) ((png_byte)(((id) >> 13) & 0x3)) + #define DO_INTERLACE_FROM_ID(id) ((int)(((id)>>15) & 1)) + #define WIDTH_FROM_ID(id) (((id)>>16) & 0xff) + #define HEIGHT_FROM_ID(id) (((id)>>24) & 0xff) +@@ -298,12 +337,16 @@ + + png_uint_32 w, png_uint_32 h, int do_interlace) + { + pos = safecat(buffer, bufsize, pos, colour_types[colour_type]); +- if (npalette > 0) ++ if (colour_type == 3) /* must have a palette */ + { + pos = safecat(buffer, bufsize, pos, ""[""); + pos = safecatn(buffer, bufsize, pos, npalette); + pos = safecat(buffer, bufsize, pos, ""]""); + } ++ ++ else if (npalette != 0) ++ pos = safecat(buffer, bufsize, pos, ""+tRNS""); ++ + pos = safecat(buffer, bufsize, pos, "" ""); + pos = safecatn(buffer, bufsize, pos, bit_depth); + pos = safecat(buffer, bufsize, pos, "" bit""); +@@ -360,25 +403,32 @@ + + + static int + next_format(png_bytep colour_type, png_bytep bit_depth, +- unsigned int* palette_number, int no_low_depth_gray) ++ unsigned int* palette_number, int low_depth_gray, int tRNS) + { + if (*bit_depth == 0) + { + *colour_type = 0; +- if (no_low_depth_gray) +- *bit_depth = 8; +- else ++ if (low_depth_gray) + *bit_depth = 1; ++ else ++ *bit_depth = 8; + *palette_number = 0; + return 1; + } + +- if (*colour_type == 3) ++ if (*colour_type < 4/*no alpha channel*/) + { +- /* Add multiple palettes for colour type 3. */ +- if (++*palette_number < PALETTE_COUNT(*bit_depth)) ++ /* Add multiple palettes for colour type 3, one image with tRNS ++ * and one without for other non-alpha formats: ++ */ ++ unsigned int pn = ++*palette_number; ++ png_byte ct = *colour_type; ++ ++ if (((ct == 0/*GRAY*/ || ct/*RGB*/ == 2) && tRNS && pn < 2) || ++ (ct == 3/*PALETTE*/ && pn < PALETTE_COUNT(*bit_depth))) + return 1; + ++ /* No: next bit depth */ + *palette_number = 0; + } + +@@ -386,9 +436,9 @@ + + + /* Palette images are restricted to 8 bit depth */ + if (*bit_depth <= 8 +-# ifdef DO_16BIT ++#ifdef DO_16BIT + || (*colour_type != 3 && *bit_depth <= 16) +-# endif ++#endif + ) + return 1; + +@@ -423,7 +473,7 @@ + + #ifdef PNG_READ_TRANSFORMS_SUPPORTED + static unsigned int + sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, +- png_uint_32 x, unsigned int sample_index) ++ png_uint_32 x, unsigned int sample_index, int swap16, int littleendian) + { + png_uint_32 bit_index, result; + +@@ -452,11 +502,23 @@ + + return result; + + else if (bit_depth > 8) +- return (result << 8) + *++row; ++ { ++ if (swap16) ++ return (*++row << 8) + result; ++ else ++ return (result << 8) + *++row; ++ } + +- /* Less than 8 bits per sample. */ ++ /* Less than 8 bits per sample. By default PNG has the big end of ++ * the egg on the left of the screen, but if littleendian is set ++ * then the big end is on the right. ++ */ + bit_index &= 7; +- return (result >> (8-bit_index-bit_depth)) & ((1U<> bit_index) & ((1U<> 3] & ~destMask; + unsigned int sourceByte = fromBuffer[fromIndex >> 3]; + + /* Don't rely on << or >> supporting '0' here, just in case: */ + fromIndex &= 7; +- if (fromIndex > 0) sourceByte <<= fromIndex; +- if ((toIndex & 7) > 0) sourceByte >>= toIndex & 7; ++ if (littleendian) ++ { ++ if (fromIndex > 0) sourceByte >>= fromIndex; ++ if ((toIndex & 7) > 0) sourceByte <<= toIndex & 7; ++ } ++ ++ else ++ { ++ if (fromIndex > 0) sourceByte <<= fromIndex; ++ if ((toIndex & 7) > 0) sourceByte >>= toIndex & 7; ++ } + + toBuffer[toIndex >> 3] = (png_byte)(destByte | (sourceByte & destMask)); + } +@@ -501,7 +574,8 @@ + + * bytes at the end. + */ + static void +-row_copy(png_bytep toBuffer, png_const_bytep fromBuffer, unsigned int bitWidth) ++row_copy(png_bytep toBuffer, png_const_bytep fromBuffer, unsigned int bitWidth, ++ int littleendian) + { + memcpy(toBuffer, fromBuffer, bitWidth >> 3); + +@@ -511,10 +585,10 @@ + + + toBuffer += bitWidth >> 3; + fromBuffer += bitWidth >> 3; +- /* The remaining bits are in the top of the byte, the mask is the bits to +- * retain. +- */ +- mask = 0xff >> (bitWidth & 7); ++ if (littleendian) ++ mask = 0xff << (bitWidth & 7); ++ else ++ mask = 0xff >> (bitWidth & 7); + *toBuffer = (png_byte)((*toBuffer & mask) | (*fromBuffer & ~mask)); + } + } +@@ -678,7 +752,7 @@ + + make_four_random_bytes(store_seed, mark); + } + +-#ifdef PNG_READ_SUPPORTED ++#ifdef PNG_READ_TRANSFORMS_SUPPORTED + /* Use this for random 32 bit values; this function makes sure the result is + * non-zero. + */ +@@ -686,7 +760,7 @@ + + random_32(void) + { + +- for(;;) ++ for (;;) + { + png_byte mark[4]; + png_uint_32 result; +@@ -836,7 +910,7 @@ + + /* Generate an error message (in the given buffer) */ + static size_t + store_message(png_store *ps, png_const_structp pp, char *buffer, size_t bufsize, +- size_t pos, PNG_CONST char *msg) ++ size_t pos, const char *msg) + { + if (pp != NULL && pp == ps->pread) + { +@@ -954,7 +1028,7 @@ + + */ + /* Return a single row from the correct image. */ + static png_bytep +-store_image_row(PNG_CONST png_store* ps, png_const_structp pp, int nImage, ++store_image_row(const png_store* ps, png_const_structp pp, int nImage, + png_uint_32 y) + { + png_size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2; +@@ -1058,7 +1132,7 @@ + + + #ifdef PNG_READ_SUPPORTED + static void +-store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage) ++store_image_check(const png_store* ps, png_const_structp pp, int iImage) + { + png_const_bytep image = ps->image; + +@@ -1275,7 +1349,10 @@ + + * operation.) + */ + if (ps->current == NULL) ++ { + store_log(ps, ps->pread, ""no current stream for palette"", 1); ++ return NULL; ++ } + + /* The result may be null if there is no palette. */ + *npalette = ps->current->npalette; +@@ -1305,7 +1382,7 @@ + + * all the memory. + */ + static void +-store_pool_error(png_store *ps, png_const_structp pp, PNG_CONST char *msg) ++store_pool_error(png_store *ps, png_const_structp pp, const char *msg) + { + if (pp != NULL) + png_error(pp, msg); +@@ -1369,7 +1446,7 @@ + + next->next = NULL; + + fprintf(stderr, ""\t%lu bytes @ %p\n"", +- (unsigned long)next->size, (PNG_CONST void*)(next+1)); ++ (unsigned long)next->size, (const void*)(next+1)); + /* The NULL means this will always return, even if the memory is + * corrupted. + */ +@@ -1524,8 +1601,7 @@ + + * returned libpng structures as destroyed by store_write_reset above. + */ + static png_structp +-set_store_for_write(png_store *ps, png_infopp ppi, +- PNG_CONST char * volatile name) ++set_store_for_write(png_store *ps, png_infopp ppi, const char *name) + { + anon_context(ps); + +@@ -1645,7 +1721,7 @@ + + */ + static png_structp + set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id, +- PNG_CONST char *name) ++ const char *name) + { + /* Set the name for png_error */ + safecat(ps->test, sizeof ps->test, 0, name); +@@ -1752,6 +1828,7 @@ + + } color_encoding; + + #ifdef PNG_READ_SUPPORTED ++#if defined PNG_READ_TRANSFORMS_SUPPORTED && defined PNG_READ_cHRM_SUPPORTED + static double + chromaticity_x(CIE_color c) + { +@@ -1765,7 +1842,7 @@ + + } + + static CIE_color +-white_point(PNG_CONST color_encoding *encoding) ++white_point(const color_encoding *encoding) + { + CIE_color white; + +@@ -1775,12 +1852,13 @@ + + + return white; + } ++#endif /* READ_TRANSFORMS && READ_cHRM */ + + #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + static void + normalize_color_encoding(color_encoding *encoding) + { +- PNG_CONST double whiteY = encoding->red.Y + encoding->green.Y + ++ const double whiteY = encoding->red.Y + encoding->green.Y + + encoding->blue.Y; + + if (whiteY != 1) +@@ -1798,9 +1876,10 @@ + + } + #endif + ++#ifdef PNG_READ_TRANSFORMS_SUPPORTED + static size_t + safecat_color_encoding(char *buffer, size_t bufsize, size_t pos, +- PNG_CONST color_encoding *e, double encoding_gamma) ++ const color_encoding *e, double encoding_gamma) + { + if (e != 0) + { +@@ -1837,6 +1916,7 @@ + + + return pos; + } ++#endif /* READ_TRANSFORMS */ + #endif /* PNG_READ_SUPPORTED */ + + typedef struct png_modifier +@@ -1861,9 +1941,9 @@ + + unsigned int ngammas; + unsigned int ngamma_tests; /* Number of gamma tests to run*/ + double current_gamma; /* 0 if not set */ +- PNG_CONST color_encoding *encodings; ++ const color_encoding *encodings; + unsigned int nencodings; +- PNG_CONST color_encoding *current_encoding; /* If an encoding has been set */ ++ const color_encoding *current_encoding; /* If an encoding has been set */ + unsigned int encoding_counter; /* For iteration */ + int encoding_ignored; /* Something overwrote it */ + +@@ -1874,7 +1954,7 @@ + + unsigned int repeat :1; /* Repeat this transform test. */ + unsigned int test_uses_encoding :1; + +- /* Lowest sbit to test (libpng fails for sbit < 8) */ ++ /* Lowest sbit to test (pre-1.7 libpng fails for sbit < 8) */ + png_byte sbitlow; + + /* Error control - these are the limits on errors accepted by the gamma tests +@@ -1929,6 +2009,7 @@ + + + /* Run tests on reading with a combination of transforms, */ + unsigned int test_transform :1; ++ unsigned int test_tRNS :1; /* Includes tRNS images */ + + /* When to use the use_input_precision option, this controls the gamma + * validation code checks. If set any value that is within the transformed +@@ -1960,6 +2041,16 @@ + + unsigned int test_gamma_expand16 :1; + unsigned int test_exhaustive :1; + ++ /* Whether or not to run the low-bit-depth grayscale tests. This fails on ++ * gamma images in some cases because of gross inaccuracies in the grayscale ++ * gamma handling for low bit depth. ++ */ ++ unsigned int test_lbg :1; ++ unsigned int test_lbg_gamma_threshold :1; ++ unsigned int test_lbg_gamma_transform :1; ++ unsigned int test_lbg_gamma_sbit :1; ++ unsigned int test_lbg_gamma_composition :1; ++ + unsigned int log :1; /* Log max error */ + + /* Buffer information, the buffer size limits the size of the chunks that can +@@ -2012,6 +2103,11 @@ + + pm->test_standard = 0; + pm->test_size = 0; + pm->test_transform = 0; ++# ifdef PNG_WRITE_tRNS_SUPPORTED ++ pm->test_tRNS = 1; ++# else ++ pm->test_tRNS = 0; ++# endif + pm->use_input_precision = 0; + pm->use_input_precision_sbit = 0; + pm->use_input_precision_16to8 = 0; +@@ -2024,6 +2120,11 @@ + + pm->test_gamma_background = 0; + pm->test_gamma_alpha_mode = 0; + pm->test_gamma_expand16 = 0; ++ pm->test_lbg = 1; ++ pm->test_lbg_gamma_threshold = 1; ++ pm->test_lbg_gamma_transform = 1; ++ pm->test_lbg_gamma_sbit = 1; ++ pm->test_lbg_gamma_composition = 1; + pm->test_exhaustive = 0; + pm->log = 0; + +@@ -2057,7 +2158,7 @@ + + * rounding and 'do_round' should be 1, if it is 0 the digitized value will + * be truncated. + */ +- PNG_CONST unsigned int digitization_factor = (1U << depth) -1; ++ const unsigned int digitization_factor = (1U << depth) -1; + + /* Limiting the range is done as a convenience to the caller - it's easier to + * do it once here than every time at the call site. +@@ -2076,7 +2177,7 @@ + + #endif /* RGB_TO_GRAY */ + + #ifdef PNG_READ_GAMMA_SUPPORTED +-static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) ++static double abserr(const png_modifier *pm, int in_depth, int out_depth) + { + /* Absolute error permitted in linear values - affected by the bit depth of + * the calculations. +@@ -2088,7 +2189,7 @@ + + return pm->maxabs8; + } + +-static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) ++static double calcerr(const png_modifier *pm, int in_depth, int out_depth) + { + /* Error in the linear composition arithmetic - only relevant when + * composition actually happens (0 < alpha < 1). +@@ -2101,7 +2202,7 @@ + + return pm->maxcalc8; + } + +-static double pcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) ++static double pcerr(const png_modifier *pm, int in_depth, int out_depth) + { + /* Percentage error permitted in the linear values. Note that the specified + * value is a percentage but this routine returns a simple number. +@@ -2124,7 +2225,7 @@ + + * The specified parameter does *not* include the base .5 digitization error but + * it is added here. + */ +-static double outerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) ++static double outerr(const png_modifier *pm, int in_depth, int out_depth) + { + /* There is a serious error in the 2 and 4 bit grayscale transform because + * the gamma table value (8 bits) is simply shifted, not rounded, so the +@@ -2156,7 +2257,7 @@ + + * rather than raising a warning. This is useful for debugging to track down + * exactly what set of parameters cause high error values. + */ +-static double outlog(PNG_CONST png_modifier *pm, int in_depth, int out_depth) ++static double outlog(const png_modifier *pm, int in_depth, int out_depth) + { + /* The command line parameters are either 8 bit (0..255) or 16 bit (0..65535) + * and so must be adjusted for low bit depth grayscale: +@@ -2194,7 +2295,7 @@ + + * but in the 8 bit calculation case it's actually quantization to a multiple of + * 257! + */ +-static int output_quantization_factor(PNG_CONST png_modifier *pm, int in_depth, ++static int output_quantization_factor(const png_modifier *pm, int in_depth, + int out_depth) + { + if (out_depth == 16 && in_depth != 16 && +@@ -2258,7 +2359,7 @@ + + + #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + static void +-modifier_current_encoding(PNG_CONST png_modifier *pm, color_encoding *ce) ++modifier_current_encoding(const png_modifier *pm, color_encoding *ce) + { + if (pm->current_encoding != 0) + *ce = *pm->current_encoding; +@@ -2270,9 +2371,10 @@ + + } + #endif + ++#ifdef PNG_READ_TRANSFORMS_SUPPORTED + static size_t + safecat_current_encoding(char *buffer, size_t bufsize, size_t pos, +- PNG_CONST png_modifier *pm) ++ const png_modifier *pm) + { + pos = safecat_color_encoding(buffer, bufsize, pos, pm->current_encoding, + pm->current_gamma); +@@ -2282,6 +2384,7 @@ + + + return pos; + } ++#endif + + /* Iterate through the usefully testable color encodings. An encoding is one + * of: +@@ -2301,7 +2404,7 @@ + + * caller of modifier_reset must reset it at the start of each run of the test! + */ + static unsigned int +-modifier_total_encodings(PNG_CONST png_modifier *pm) ++modifier_total_encodings(const png_modifier *pm) + { + return 1 + /* (1) nothing */ + pm->ngammas + /* (2) gamma values to test */ +@@ -2417,14 +2520,14 @@ + + * assumption below that the first encoding in the list is the one for sRGB. + */ + static int +-modifier_color_encoding_is_sRGB(PNG_CONST png_modifier *pm) ++modifier_color_encoding_is_sRGB(const png_modifier *pm) + { + return pm->current_encoding != 0 && pm->current_encoding == pm->encodings && + pm->current_encoding->gamma == pm->current_gamma; + } + + static int +-modifier_color_encoding_is_set(PNG_CONST png_modifier *pm) ++modifier_color_encoding_is_set(const png_modifier *pm) + { + return pm->current_gamma != 0; + } +@@ -2743,7 +2846,7 @@ + + /* Set up a modifier. */ + static png_structp + set_modifier_for_read(png_modifier *pm, png_infopp ppi, png_uint_32 id, +- PNG_CONST char *name) ++ const char *name) + { + /* Do this first so that the modifier fields are cleared even if an error + * happens allocating the png_struct. No allocation is done here so no +@@ -2803,7 +2906,7 @@ + + typedef struct chrm_modification + { + png_modification this; +- PNG_CONST color_encoding *encoding; ++ const color_encoding *encoding; + png_fixed_point wx, wy, rx, ry, gx, gy, bx, by; + } chrm_modification; + +@@ -2827,7 +2930,7 @@ + + + static void + chrm_modification_init(chrm_modification *me, png_modifier *pm, +- PNG_CONST color_encoding *encoding) ++ const color_encoding *encoding) + { + CIE_color white = white_point(encoding); + +@@ -3162,6 +3265,45 @@ + + } + } + ++#ifdef PNG_WRITE_tRNS_SUPPORTED ++static void ++set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type, ++ const int bit_depth) ++{ ++ /* To make this useful the tRNS color needs to match at least one pixel. ++ * Random values are fine for gray, including the 16-bit case where we know ++ * that the test image contains all the gray values. For RGB we need more ++ * method as only 65536 different RGB values are generated. ++ */ ++ png_color_16 tRNS; ++ const png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1); ++ ++ RANDOMIZE(tRNS); ++ ++ if (colour_type & 2/*RGB*/) ++ { ++ if (bit_depth == 8) ++ { ++ tRNS.blue = tRNS.red ^ tRNS.green; ++ tRNS.red &= mask; ++ tRNS.green &= mask; ++ tRNS.blue &= mask; ++ } ++ ++ else /* bit_depth == 16 */ ++ { ++ tRNS.green = (png_uint_16)(tRNS.red * 257); ++ tRNS.blue = (png_uint_16)(tRNS.green * 17); ++ } ++ } ++ ++ else ++ tRNS.gray &= mask; ++ ++ png_set_tRNS(pp, pi, NULL, 0, &tRNS); ++} ++#endif ++ + /* The number of passes is related to the interlace type. There was no libpng + * API to determine this prior to 1.5, so we need an inquiry function: + */ +@@ -3411,13 +3553,17 @@ + + #ifdef PNG_WRITE_INTERLACING_SUPPORTED + # define INTERLACE_LAST PNG_INTERLACE_LAST + # define check_interlace_type(type) ((void)(type)) +-#else +-# define INTERLACE_LAST (PNG_INTERLACE_NONE+1) +-# define png_set_interlace_handling(a) (1) +- ++# define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp) ++# define do_own_interlace 0 ++#elif PNG_LIBPNG_VER < 10700 ++# define set_write_interlace_handling(pp,type) (1) + static void +-check_interlace_type(int PNG_CONST interlace_type) ++check_interlace_type(int const interlace_type) + { ++ /* Prior to 1.7.0 libpng does not support the write of an interlaced image ++ * unless PNG_WRITE_INTERLACING_SUPPORTED, even with do_interlace so the ++ * code here does the pixel interlace itself, so: ++ */ + if (interlace_type != PNG_INTERLACE_NONE) + { + /* This is an internal error - --interlace tests should be skipped, not +@@ -3427,17 +3573,85 @@ + + exit(99); + } + } +-#endif ++# define INTERLACE_LAST (PNG_INTERLACE_NONE+1) ++# define do_own_interlace 0 ++#else /* libpng 1.7+ */ ++# define set_write_interlace_handling(pp,type)\ ++ npasses_from_interlace_type(pp,type) ++# define check_interlace_type(type) ((void)(type)) ++# define INTERLACE_LAST PNG_INTERLACE_LAST ++# define do_own_interlace 1 ++#endif /* WRITE_INTERLACING tests */ + +-/* Make a standardized image given a an image colour type, bit depth and ++#define CAN_WRITE_INTERLACE\ ++ PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED ++ ++/* Do the same thing for read interlacing; this controls whether read tests do ++ * their own de-interlace or use libpng. ++ */ ++#ifdef PNG_READ_INTERLACING_SUPPORTED ++# define do_read_interlace 0 ++#else /* no libpng read interlace support */ ++# define do_read_interlace 1 ++#endif ++/* The following two routines use the PNG interlace support macros from ++ * png.h to interlace or deinterlace rows. ++ */ ++static void ++interlace_row(png_bytep buffer, png_const_bytep imageRow, ++ unsigned int pixel_size, png_uint_32 w, int pass, int littleendian) ++{ ++ png_uint_32 xin, xout, xstep; ++ ++ /* Note that this can, trivially, be optimized to a memcpy on pass 7, the ++ * code is presented this way to make it easier to understand. In practice ++ * consult the code in the libpng source to see other ways of doing this. ++ * ++ * It is OK for buffer and imageRow to be identical, because 'xin' moves ++ * faster than 'xout' and we copy up. ++ */ ++ xin = PNG_PASS_START_COL(pass); ++ xstep = 1U< 0) ++ interlace_row(buffer, buffer, ++ bit_size(pp, colour_type, bit_depth), w, pass, ++ 0/*data always bigendian*/); ++ else ++ continue; ++ } ++# endif /* do_own_interlace */ ++ + png_write_row(pp, buffer); + } + } +@@ -3568,19 +3813,20 @@ + + } + + static void +-make_transform_images(png_store *ps) ++make_transform_images(png_modifier *pm) + { + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* This is in case of errors. */ +- safecat(ps->test, sizeof ps->test, 0, ""make standard images""); ++ safecat(pm->this.test, sizeof pm->this.test, 0, ""make standard images""); + + /* Use next_format to enumerate all the combinations we test, including +- * generating multiple low bit depth palette images. ++ * generating multiple low bit depth palette images. Non-A images (palette ++ * and direct) are created with and without tRNS chunks. + */ +- while (next_format(&colour_type, &bit_depth, &palette_number, 0)) ++ while (next_format(&colour_type, &bit_depth, &palette_number, 1, 1)) + { + int interlace_type; + +@@ -3590,59 +3836,13 @@ + + char name[FILE_NAME_SIZE]; + + standard_name(name, sizeof name, 0, colour_type, bit_depth, +- palette_number, interlace_type, 0, 0, 0); +- make_transform_image(ps, colour_type, bit_depth, palette_number, ++ palette_number, interlace_type, 0, 0, do_own_interlace); ++ make_transform_image(&pm->this, colour_type, bit_depth, palette_number, + interlace_type, name); + } + } + } + +-/* The following two routines use the PNG interlace support macros from +- * png.h to interlace or deinterlace rows. +- */ +-static void +-interlace_row(png_bytep buffer, png_const_bytep imageRow, +- unsigned int pixel_size, png_uint_32 w, int pass) +-{ +- png_uint_32 xin, xout, xstep; +- +- /* Note that this can, trivially, be optimized to a memcpy on pass 7, the +- * code is presented this way to make it easier to understand. In practice +- * consult the code in the libpng source to see other ways of doing this. +- */ +- xin = PNG_PASS_START_COL(pass); +- xstep = 1U<expect_error = !error_test[test].warning; + ps->expect_warning = error_test[test].warning; +@@ -4029,7 +4238,8 @@ + + } + + Catch (fault) +- ps = fault; /* expected exit, make sure ps is not clobbered */ ++ { /* expected exit */ ++ } + #undef exception__prev + #undef exception__env + +@@ -4046,8 +4256,7 @@ + + + else + { +- png_uint_32 h = transform_height(pp, colour_type, bit_depth); +- int npasses = png_set_interlace_handling(pp); ++ int npasses = set_write_interlace_handling(pp, interlace_type); + int pass; + + if (npasses != npasses_from_interlace_type(pp, interlace_type)) +@@ -4062,6 +4271,29 @@ + + png_byte buffer[TRANSFORM_ROWMAX]; + + transform_row(pp, buffer, colour_type, bit_depth, y); ++ ++# if do_own_interlace ++ /* If do_own_interlace *and* the image is interlaced we need a ++ * reduced interlace row; this may be reduced to empty. ++ */ ++ if (interlace_type == PNG_INTERLACE_ADAM7) ++ { ++ /* The row must not be written if it doesn't exist, notice ++ * that there are two conditions here, either the row isn't ++ * ever in the pass or the row would be but isn't wide ++ * enough to contribute any pixels. In fact the wPass test ++ * can be used to skip the whole y loop in this case. ++ */ ++ if (PNG_ROW_IN_INTERLACE_PASS(y, pass) && ++ PNG_PASS_COLS(w, pass) > 0) ++ interlace_row(buffer, buffer, ++ bit_size(pp, colour_type, bit_depth), w, pass, ++ 0/*data always bigendian*/); ++ else ++ continue; ++ } ++# endif /* do_own_interlace */ ++ + png_write_row(pp, buffer); + } + } +@@ -4080,8 +4312,8 @@ + + } + + static int +-make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type, +- int bdlo, int PNG_CONST bdhi) ++make_errors(png_modifier* const pm, png_byte const colour_type, ++ int bdlo, int const bdhi) + { + for (; bdlo <= bdhi; ++bdlo) + { +@@ -4094,9 +4326,9 @@ + + char name[FILE_NAME_SIZE]; + + standard_name(name, sizeof name, 0, colour_type, 1<this, colour_type, DEPTH(bdlo), interlace_type, + test, name); +@@ -4141,7 +4373,7 @@ + + * then the warning messages the library outputs will probably be garbage. + */ + static void +-perform_formatting_test(png_store *volatile ps) ++perform_formatting_test(png_store *ps) + { + #ifdef PNG_TIME_RFC1123_SUPPORTED + /* The handle into the formatting code is the RFC1123 support; this test does +@@ -4246,7 +4478,8 @@ + + png_byte green_sBIT; + png_byte blue_sBIT; + png_byte alpha_sBIT; +- int interlace_type; ++ png_byte interlace_type; ++ png_byte filler; /* Output has a filler */ + png_uint_32 id; /* Calculated file ID */ + png_uint_32 w; /* Width of image */ + png_uint_32 h; /* Height of image */ +@@ -4255,7 +4488,9 @@ + + png_uint_32 bit_width; /* Width of output row in bits */ + size_t cbRow; /* Bytes in a row of the output image */ + int do_interlace; /* Do interlacing internally */ ++ int littleendian; /* App (row) data is little endian */ + int is_transparent; /* Transparency information was present. */ ++ int has_tRNS; /* color type GRAY or RGB with a tRNS chunk. */ + int speed; /* Doing a speed test */ + int use_update_info;/* Call update_info, not start_image */ + struct +@@ -4296,6 +4531,7 @@ + + dp->bit_width = 0; + dp->cbRow = 0; + dp->do_interlace = do_interlace; ++ dp->littleendian = 0; + dp->is_transparent = 0; + dp->speed = ps->speed; + dp->use_update_info = use_update_info; +@@ -4588,14 +4824,14 @@ + + case 0: + dp->transparent.red = dp->transparent.green = dp->transparent.blue = + trans_color->gray; +- dp->is_transparent = 1; ++ dp->has_tRNS = 1; + break; + + case 2: + dp->transparent.red = trans_color->red; + dp->transparent.green = trans_color->green; + dp->transparent.blue = trans_color->blue; +- dp->is_transparent = 1; ++ dp->has_tRNS = 1; + break; + + case 3: +@@ -4616,8 +4852,19 @@ + + * turning on interlace handling (if do_interlace is not set.) + */ + dp->npasses = npasses_from_interlace_type(pp, dp->interlace_type); +- if (!dp->do_interlace && dp->npasses != png_set_interlace_handling(pp)) +- png_error(pp, ""validate: file changed interlace type""); ++ if (!dp->do_interlace) ++ { ++# ifdef PNG_READ_INTERLACING_SUPPORTED ++ if (dp->npasses != png_set_interlace_handling(pp)) ++ png_error(pp, ""validate: file changed interlace type""); ++# else /* !READ_INTERLACING */ ++ /* This should never happen: the relevant tests (!do_interlace) should ++ * not be run. ++ */ ++ if (dp->npasses > 1) ++ png_error(pp, ""validate: no libpng interlace support""); ++# endif /* !READ_INTERLACING */ ++ } + + /* Caller calls png_read_update_info or png_start_read_image now, then calls + * part2. +@@ -4633,8 +4880,16 @@ + + png_const_infop pi, int nImages) + { + /* Record cbRow now that it can be found. */ +- dp->pixel_size = bit_size(pp, png_get_color_type(pp, pi), +- png_get_bit_depth(pp, pi)); ++ { ++ png_byte ct = png_get_color_type(pp, pi); ++ png_byte bd = png_get_bit_depth(pp, pi); ++ ++ if (bd >= 8 && (ct == PNG_COLOR_TYPE_RGB || ct == PNG_COLOR_TYPE_GRAY) && ++ dp->filler) ++ ct |= 4; /* handle filler as faked alpha channel */ ++ ++ dp->pixel_size = bit_size(pp, ct, bd); ++ } + dp->bit_width = png_get_image_width(pp, pi) * dp->pixel_size; + dp->cbRow = png_get_rowbytes(pp, pi); + +@@ -4691,7 +4946,7 @@ + + progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass) + { + png_const_structp pp = ppIn; +- PNG_CONST standard_display *dp = voidcast(standard_display*, ++ const standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + /* When handling interlacing some rows will be absent in each pass, the +@@ -4715,7 +4970,7 @@ + + + if (pass != png_get_current_pass_number(pp)) + png_error(pp, ""png_get_current_pass_number is broken""); +-#endif ++#endif /* USER_TRANSFORM_INFO */ + + y = PNG_ROW_FROM_PASS_ROW(y, pass); + } +@@ -4726,38 +4981,39 @@ + + + row = store_image_row(dp->ps, pp, 0, y); + +-#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Combine the new row into the old: */ ++#ifdef PNG_READ_INTERLACING_SUPPORTED + if (dp->do_interlace) ++#endif /* READ_INTERLACING */ + { + if (dp->interlace_type == PNG_INTERLACE_ADAM7) +- deinterlace_row(row, new_row, dp->pixel_size, dp->w, pass); ++ deinterlace_row(row, new_row, dp->pixel_size, dp->w, pass, ++ dp->littleendian); + else +- row_copy(row, new_row, dp->pixel_size * dp->w); ++ row_copy(row, new_row, dp->pixel_size * dp->w, dp->littleendian); + } ++#ifdef PNG_READ_INTERLACING_SUPPORTED + else + png_progressive_combine_row(pp, row, new_row); + #endif /* PNG_READ_INTERLACING_SUPPORTED */ + } + +-#ifdef PNG_READ_INTERLACING_SUPPORTED + else if (dp->interlace_type == PNG_INTERLACE_ADAM7 && + PNG_ROW_IN_INTERLACE_PASS(y, pass) && + PNG_PASS_COLS(dp->w, pass) > 0) + png_error(pp, ""missing row in progressive de-interlacing""); +-#endif /* PNG_READ_INTERLACING_SUPPORTED */ + } + + static void + sequential_row(standard_display *dp, png_structp pp, png_infop pi, +- PNG_CONST int iImage, PNG_CONST int iDisplay) ++ const int iImage, const int iDisplay) + { +- PNG_CONST int npasses = dp->npasses; +- PNG_CONST int do_interlace = dp->do_interlace && ++ const int npasses = dp->npasses; ++ const int do_interlace = dp->do_interlace && + dp->interlace_type == PNG_INTERLACE_ADAM7; +- PNG_CONST png_uint_32 height = standard_height(pp, dp->id); +- PNG_CONST png_uint_32 width = standard_width(pp, dp->id); +- PNG_CONST png_store* ps = dp->ps; ++ const png_uint_32 height = standard_height(pp, dp->id); ++ const png_uint_32 width = standard_width(pp, dp->id); ++ const png_store* ps = dp->ps; + int pass; + + for (pass=0; pass= 0) + deinterlace_row(store_image_row(ps, pp, iImage, y), row, +- dp->pixel_size, dp->w, pass); ++ dp->pixel_size, dp->w, pass, dp->littleendian); + + if (iDisplay >= 0) + deinterlace_row(store_image_row(ps, pp, iDisplay, y), display, +- dp->pixel_size, dp->w, pass); ++ dp->pixel_size, dp->w, pass, dp->littleendian); + } + } + else +@@ -4943,14 +5199,6 @@ + + * In earlier passes 'row' will be partially filled in, with only the pixels + * that have been read so far, but 'display' will have those pixels + * replicated to fill the unread pixels while reading an interlaced image. +-#if PNG_LIBPNG_VER < 10506 +- * The side effect inside the libpng sequential reader is that the 'row' +- * array retains the correct values for unwritten pixels within the row +- * bytes, while the 'display' array gets bits off the end of the image (in +- * the last byte) trashed. Unfortunately in the progressive reader the +- * row bytes are always trashed, so we always do a pixel_cmp here even though +- * a memcmp of all cbRow bytes will succeed for the sequential reader. +-#endif + */ + if (iImage >= 0 && + (where = pixel_cmp(std, store_image_row(dp->ps, pp, iImage, y), +@@ -4963,19 +5211,12 @@ + + png_error(pp, msg); + } + +-#if PNG_LIBPNG_VER < 10506 +- /* In this case use pixel_cmp because we need to compare a partial +- * byte at the end of the row if the row is not an exact multiple +- * of 8 bits wide. (This is fixed in libpng-1.5.6 and pixel_cmp is +- * changed to match!) +- */ +-#endif + if (iDisplay >= 0 && + (where = pixel_cmp(std, store_image_row(dp->ps, pp, iDisplay, y), + dp->bit_width)) != 0) + { + char msg[64]; +- sprintf(msg, ""display row[%lu][%d] changed from %.2x to %.2x"", ++ sprintf(msg, ""display row[%lu][%d] changed from %.2x to %.2x"", + (unsigned long)y, where-1, std[where-1], + store_image_row(dp->ps, pp, iDisplay, y)[where-1]); + png_error(pp, msg); +@@ -5020,7 +5261,7 @@ + + + /* A single test run checking the standard image to ensure it is not damaged. */ + static void +-standard_test(png_store* PNG_CONST psIn, png_uint_32 PNG_CONST id, ++standard_test(png_store* const psIn, png_uint_32 const id, + int do_interlace, int use_update_info) + { + standard_display d; +@@ -5108,8 +5349,8 @@ + + } + + static int +-test_standard(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type, +- int bdlo, int PNG_CONST bdhi) ++test_standard(png_modifier* const pm, png_byte const colour_type, ++ int bdlo, int const bdhi) + { + for (; bdlo <= bdhi; ++bdlo) + { +@@ -5119,7 +5360,7 @@ + + interlace_type < INTERLACE_LAST; ++interlace_type) + { + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, +- interlace_type, 0, 0, 0), 0/*do_interlace*/, pm->use_update_info); ++ interlace_type, 0, 0, 0), do_read_interlace, pm->use_update_info); + + if (fail(pm)) + return 0; +@@ -5154,8 +5395,8 @@ + + + /********************************** SIZE TESTS ********************************/ + static int +-test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type, +- int bdlo, int PNG_CONST bdhi) ++test_size(png_modifier* const pm, png_byte const colour_type, ++ int bdlo, int const bdhi) + { + /* Run the tests on each combination. + * +@@ -5164,8 +5405,10 @@ + + * width and height. This is a waste of time in practice, hence the + * hinc and winc stuff: + */ +- static PNG_CONST png_byte hinc[] = {1, 3, 11, 1, 5}; +- static PNG_CONST png_byte winc[] = {1, 9, 5, 7, 1}; ++ static const png_byte hinc[] = {1, 3, 11, 1, 5}; ++ static const png_byte winc[] = {1, 9, 5, 7, 1}; ++ const int save_bdlo = bdlo; ++ + for (; bdlo <= bdhi; ++bdlo) + { + png_uint_32 h, w; +@@ -5191,22 +5434,6 @@ + + if (fail(pm)) + return 0; + +-# ifdef PNG_WRITE_INTERLACING_SUPPORTED +- standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, +- PNG_INTERLACE_ADAM7, w, h, 0), 0/*do_interlace*/, +- pm->use_update_info); +- +- if (fail(pm)) +- return 0; +- +- standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, +- PNG_INTERLACE_ADAM7, w, h, 1), 0/*do_interlace*/, +- pm->use_update_info); +- +- if (fail(pm)) +- return 0; +-# endif +- + /* Now validate the interlaced read side - do_interlace true, + * in the progressive case this does actually make a difference + * to the code used in the non-interlaced case too. +@@ -5218,7 +5445,45 @@ + + if (fail(pm)) + return 0; + ++# if CAN_WRITE_INTERLACE ++ /* Validate the pngvalid code itself: */ ++ standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, ++ PNG_INTERLACE_ADAM7, w, h, 1), 1/*do_interlace*/, ++ pm->use_update_info); ++ ++ if (fail(pm)) ++ return 0; ++# endif ++ } ++ } ++ ++ /* Now do the tests of libpng interlace handling, after we have made sure ++ * that the pngvalid version works: ++ */ ++ for (bdlo = save_bdlo; bdlo <= bdhi; ++bdlo) ++ { ++ png_uint_32 h, w; ++ ++ for (h=1; h<=16; h+=hinc[bdlo]) for (w=1; w<=16; w+=winc[bdlo]) ++ { ++# ifdef PNG_READ_INTERLACING_SUPPORTED ++ /* Test with pngvalid generated interlaced images first; we have ++ * already verify these are ok (unless pngvalid has self-consistent ++ * read/write errors, which is unlikely), so this detects errors in the ++ * read side first: ++ */ ++# if CAN_WRITE_INTERLACE ++ standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, ++ PNG_INTERLACE_ADAM7, w, h, 1), 0/*do_interlace*/, ++ pm->use_update_info); ++ ++ if (fail(pm)) ++ return 0; ++# endif ++# endif /* READ_INTERLACING */ ++ + # ifdef PNG_WRITE_INTERLACING_SUPPORTED ++ /* Test the libpng write side against the pngvalid read side: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 0), 1/*do_interlace*/, + pm->use_update_info); +@@ -5226,6 +5491,18 @@ + + if (fail(pm)) + return 0; + # endif ++ ++# ifdef PNG_READ_INTERLACING_SUPPORTED ++# ifdef PNG_WRITE_INTERLACING_SUPPORTED ++ /* Test both together: */ ++ standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, ++ PNG_INTERLACE_ADAM7, w, h, 0), 0/*do_interlace*/, ++ pm->use_update_info); ++ ++ if (fail(pm)) ++ return 0; ++# endif ++# endif /* READ_INTERLACING */ + } + } + +@@ -5274,10 +5551,17 @@ + + */ + unsigned int red, green, blue, alpha; /* For non-palette images. */ + unsigned int palette_index; /* For a palette image. */ +- png_byte colour_type; /* As in the spec. */ +- png_byte bit_depth; /* Defines bit size in row */ +- png_byte sample_depth; /* Scale of samples */ +- int have_tRNS; /* tRNS chunk may need processing */ ++ png_byte colour_type; /* As in the spec. */ ++ png_byte bit_depth; /* Defines bit size in row */ ++ png_byte sample_depth; /* Scale of samples */ ++ unsigned int have_tRNS :1; /* tRNS chunk may need processing */ ++ unsigned int swap_rgb :1; /* RGB swapped to BGR */ ++ unsigned int alpha_first :1; /* Alpha at start, not end */ ++ unsigned int alpha_inverted :1; /* Alpha channel inverted */ ++ unsigned int mono_inverted :1; /* Gray channel inverted */ ++ unsigned int swap16 :1; /* Byte swap 16-bit components */ ++ unsigned int littleendian :1; /* High bits on right */ ++ unsigned int sig_bits :1; /* Pixel shifted (sig bits only) */ + + /* For checking the code calculates double precision floating point values + * along with an error value, accumulated from the transforms. Because an +@@ -5285,6 +5569,9 @@ + + * up to just less than +/-1 in the scaled value) the *lowest* sBIT for each + * channel is stored. This sBIT value is folded in to the stored error value + * at the end of the application of the transforms to the pixel. ++ * ++ * If sig_bits is set above the red, green, blue and alpha values have been ++ * scaled so they only contain the significant bits of the component values. + */ + double redf, greenf, bluef, alphaf; + double rede, greene, bluee, alphae; +@@ -5293,26 +5580,27 @@ + + + /* Shared utility function, see below. */ + static void +-image_pixel_setf(image_pixel *this, unsigned int max) ++image_pixel_setf(image_pixel *this, unsigned int rMax, unsigned int gMax, ++ unsigned int bMax, unsigned int aMax) + { +- this->redf = this->red / (double)max; +- this->greenf = this->green / (double)max; +- this->bluef = this->blue / (double)max; +- this->alphaf = this->alpha / (double)max; ++ this->redf = this->red / (double)rMax; ++ this->greenf = this->green / (double)gMax; ++ this->bluef = this->blue / (double)bMax; ++ this->alphaf = this->alpha / (double)aMax; + +- if (this->red < max) ++ if (this->red < rMax) + this->rede = this->redf * DBL_EPSILON; + else + this->rede = 0; +- if (this->green < max) ++ if (this->green < gMax) + this->greene = this->greenf * DBL_EPSILON; + else + this->greene = 0; +- if (this->blue < max) ++ if (this->blue < bMax) + this->bluee = this->bluef * DBL_EPSILON; + else + this->bluee = 0; +- if (this->alpha < max) ++ if (this->alpha < aMax) + this->alphae = this->alphaf * DBL_EPSILON; + else + this->alphae = 0; +@@ -5324,18 +5612,22 @@ + + */ + static void + image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type, +- png_byte bit_depth, png_uint_32 x, store_palette palette) ++ png_byte bit_depth, png_uint_32 x, store_palette palette, ++ const image_pixel *format /*from pngvalid transform of input*/) + { +- PNG_CONST png_byte sample_depth = (png_byte)(colour_type == ++ const png_byte sample_depth = (png_byte)(colour_type == + PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth); +- PNG_CONST unsigned int max = (1U<swap16); ++ const int littleendian = (format != 0 && format->littleendian); ++ const int sig_bits = (format != 0 && format->sig_bits); + + /* Initially just set everything to the same number and the alpha to opaque. + * Note that this currently assumes a simple palette where entry x has colour + * rgb(x,x,x)! + */ + this->palette_index = this->red = this->green = this->blue = +- sample(row, colour_type, bit_depth, x, 0); ++ sample(row, colour_type, bit_depth, x, 0, swap16, littleendian); + this->alpha = max; + this->red_sBIT = this->green_sBIT = this->blue_sBIT = this->alpha_sBIT = + sample_depth; +@@ -5346,7 +5638,7 @@ + + /* This permits the caller to default to the sample value. */ + if (palette != 0) + { +- PNG_CONST unsigned int i = this->palette_index; ++ const unsigned int i = this->palette_index; + + this->red = palette[i].red; + this->green = palette[i].green; +@@ -5359,21 +5651,52 @@ + + { + unsigned int i = 0; + ++ if ((colour_type & 4) != 0 && format != 0 && format->alpha_first) ++ { ++ this->alpha = this->red; ++ /* This handles the gray case for 'AG' pixels */ ++ this->palette_index = this->red = this->green = this->blue = ++ sample(row, colour_type, bit_depth, x, 1, swap16, littleendian); ++ i = 1; ++ } ++ + if (colour_type & 2) + { +- this->green = sample(row, colour_type, bit_depth, x, 1); +- this->blue = sample(row, colour_type, bit_depth, x, 2); +- i = 2; ++ /* Green is second for both BGR and RGB: */ ++ this->green = sample(row, colour_type, bit_depth, x, ++i, swap16, ++ littleendian); ++ ++ if (format != 0 && format->swap_rgb) /* BGR */ ++ this->red = sample(row, colour_type, bit_depth, x, ++i, swap16, ++ littleendian); ++ else ++ this->blue = sample(row, colour_type, bit_depth, x, ++i, swap16, ++ littleendian); + } +- if (colour_type & 4) +- this->alpha = sample(row, colour_type, bit_depth, x, ++i); ++ ++ else /* grayscale */ if (format != 0 && format->mono_inverted) ++ this->red = this->green = this->blue = this->red ^ max; ++ ++ if ((colour_type & 4) != 0) /* alpha */ ++ { ++ if (format == 0 || !format->alpha_first) ++ this->alpha = sample(row, colour_type, bit_depth, x, ++i, swap16, ++ littleendian); ++ ++ if (format != 0 && format->alpha_inverted) ++ this->alpha ^= max; ++ } + } + + /* Calculate the scaled values, these are simply the values divided by + * 'max' and the error is initialized to the double precision epsilon value + * from the header file. + */ +- image_pixel_setf(this, max); ++ image_pixel_setf(this, ++ sig_bits ? (1U << format->red_sBIT)-1 : max, ++ sig_bits ? (1U << format->green_sBIT)-1 : max, ++ sig_bits ? (1U << format->blue_sBIT)-1 : max, ++ sig_bits ? (1U << format->alpha_sBIT)-1 : max); + + /* Store the input information for use in the transforms - these will + * modify the information. +@@ -5382,8 +5705,18 @@ + + this->bit_depth = bit_depth; + this->sample_depth = sample_depth; + this->have_tRNS = 0; ++ this->swap_rgb = 0; ++ this->alpha_first = 0; ++ this->alpha_inverted = 0; ++ this->mono_inverted = 0; ++ this->swap16 = 0; ++ this->littleendian = 0; ++ this->sig_bits = 0; + } + ++#if defined PNG_READ_EXPAND_SUPPORTED || defined PNG_READ_GRAY_TO_RGB_SUPPORTED\ ++ || defined PNG_READ_EXPAND_SUPPORTED || defined PNG_READ_EXPAND_16_SUPPORTED\ ++ || defined PNG_READ_BACKGROUND_SUPPORTED + /* Convert a palette image to an rgb image. This necessarily converts the tRNS + * chunk at the same time, because the tRNS will be in palette form. The way + * palette validation works means that the original palette is never updated, +@@ -5413,10 +5746,14 @@ + + + /* Add an alpha channel; this will import the tRNS information because tRNS is + * not valid in an alpha image. The bit depth will invariably be set to at +- * least 8. Palette images will be converted to alpha (using the above API). ++ * least 8 prior to 1.7.0. Palette images will be converted to alpha (using ++ * the above API). With png_set_background the alpha channel is never expanded ++ * but this routine is used by pngvalid to simplify code; 'for_background' ++ * records this. + */ + static void +-image_pixel_add_alpha(image_pixel *this, PNG_CONST standard_display *display) ++image_pixel_add_alpha(image_pixel *this, const standard_display *display, ++ int for_background) + { + if (this->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(this); +@@ -5425,11 +5762,21 @@ + + { + if (this->colour_type == PNG_COLOR_TYPE_GRAY) + { +- if (this->bit_depth < 8) +- this->bit_depth = 8; ++# if PNG_LIBPNG_VER < 10700 ++ if (!for_background && this->bit_depth < 8) ++ this->bit_depth = this->sample_depth = 8; ++# endif + + if (this->have_tRNS) + { ++ /* After 1.7 the expansion of bit depth only happens if there is a ++ * tRNS chunk to expand at this point. ++ */ ++# if PNG_LIBPNG_VER >= 10700 ++ if (!for_background && this->bit_depth < 8) ++ this->bit_depth = this->sample_depth = 8; ++# endif ++ + this->have_tRNS = 0; + + /* Check the input, original, channel value here against the +@@ -5461,9 +5808,11 @@ + + this->alphaf = 0; + else + this->alphaf = 1; +- +- this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + } ++ else ++ this->alphaf = 1; ++ ++ this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + } + + /* The error in the alpha is zero and the sBIT value comes from the +@@ -5473,18 +5822,19 @@ + + this->alpha_sBIT = display->alpha_sBIT; + } + } ++#endif /* transforms that need image_pixel_add_alpha */ + + struct transform_display; + typedef struct image_transform + { + /* The name of this transform: a string. */ +- PNG_CONST char *name; ++ const char *name; + + /* Each transform can be disabled from the command line: */ + int enable; + + /* The global list of transforms; read only. */ +- struct image_transform *PNG_CONST list; ++ struct image_transform *const list; + + /* The global count of the number of times this transform has been set on an + * image. +@@ -5497,7 +5847,7 @@ + + /* The next transform in the list, each transform must call its own next + * transform after it has processed the pixel successfully. + */ +- PNG_CONST struct image_transform *next; ++ const struct image_transform *next; + + /* A single transform for the image, expressed as a series of function + * callbacks and some space for values. +@@ -5505,12 +5855,12 @@ + + * First a callback to add any required modifications to the png_modifier; + * this gets called just before the modifier is set up for read. + */ +- void (*ini)(PNG_CONST struct image_transform *this, ++ void (*ini)(const struct image_transform *this, + struct transform_display *that); + + /* And a callback to set the transform on the current png_read_struct: + */ +- void (*set)(PNG_CONST struct image_transform *this, ++ void (*set)(const struct image_transform *this, + struct transform_display *that, png_structp pp, png_infop pi); + + /* Then a transform that takes an input pixel in one PNG format or another +@@ -5519,8 +5869,8 @@ + + * in the libpng implementation!) The png_structp is solely to allow error + * reporting via png_error and png_warning. + */ +- void (*mod)(PNG_CONST struct image_transform *this, image_pixel *that, +- png_const_structp pp, PNG_CONST struct transform_display *display); ++ void (*mod)(const struct image_transform *this, image_pixel *that, ++ png_const_structp pp, const struct transform_display *display); + + /* Add this transform to the list and return true if the transform is + * meaningful for this colour type and bit depth - if false then the +@@ -5528,7 +5878,7 @@ + + * point running it. + */ + int (*add)(struct image_transform *this, +- PNG_CONST struct image_transform **that, png_byte colour_type, ++ const struct image_transform **that, png_byte colour_type, + png_byte bit_depth); + } image_transform; + +@@ -5538,11 +5888,13 @@ + + + /* Parameters */ + png_modifier* pm; +- PNG_CONST image_transform* transform_list; ++ const image_transform* transform_list; ++ unsigned int max_gamma_8; + + /* Local variables */ + png_byte output_colour_type; + png_byte output_bit_depth; ++ png_byte unpacked; + + /* Modifications (not necessarily used.) */ + gama_modification gama_mod; +@@ -5579,7 +5931,7 @@ + + + /* Three functions to end the list: */ + static void +-image_transform_ini_end(PNG_CONST image_transform *this, ++image_transform_ini_end(const image_transform *this, + transform_display *that) + { + UNUSED(this) +@@ -5587,7 +5939,7 @@ + + } + + static void +-image_transform_set_end(PNG_CONST image_transform *this, ++image_transform_set_end(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + UNUSED(this) +@@ -5614,10 +5966,11 @@ + + } + + static void +-image_transform_mod_end(PNG_CONST image_transform *this, image_pixel *that, +- png_const_structp pp, PNG_CONST transform_display *display) ++image_transform_mod_end(const image_transform *this, image_pixel *that, ++ png_const_structp pp, const transform_display *display) + { +- PNG_CONST unsigned int scale = (1U<sample_depth)-1; ++ const unsigned int scale = (1U<sample_depth)-1; ++ const int sig_bits = that->sig_bits; + + UNUSED(this) + UNUSED(pp) +@@ -5632,6 +5985,13 @@ + + */ + that->red = sample_scale(that->redf, scale); + ++ /* This is a bit bogus; really the above calculation should use the red_sBIT ++ * value, not sample_depth, but because libpng does png_set_shift by just ++ * shifting the bits we get errors if we don't do it the same way. ++ */ ++ if (sig_bits && that->red_sBIT < that->sample_depth) ++ that->red >>= that->sample_depth - that->red_sBIT; ++ + /* The error value is increased, at the end, according to the lowest sBIT + * value seen. Common sense tells us that the intermediate integer + * representations are no more accurate than +/- 0.5 in the integral values, +@@ -5647,7 +6007,13 @@ + + if (that->colour_type & PNG_COLOR_MASK_COLOR) + { + that->green = sample_scale(that->greenf, scale); ++ if (sig_bits && that->green_sBIT < that->sample_depth) ++ that->green >>= that->sample_depth - that->green_sBIT; ++ + that->blue = sample_scale(that->bluef, scale); ++ if (sig_bits && that->blue_sBIT < that->sample_depth) ++ that->blue >>= that->sample_depth - that->blue_sBIT; ++ + that->greene += 1./(2*((1U<green_sBIT)-1)); + that->bluee += 1./(2*((1U<blue_sBIT)-1)); + } +@@ -5667,9 +6033,12 @@ + + else + { + that->alpha = scale; /* opaque */ +- that->alpha = 1; /* Override this. */ ++ that->alphaf = 1; /* Override this. */ + that->alphae = 0; /* It's exact ;-) */ + } ++ ++ if (sig_bits && that->alpha_sBIT < that->sample_depth) ++ that->alpha >>= that->sample_depth - that->alpha_sBIT; + } + + /* Static 'end' structure: */ +@@ -5692,21 +6061,23 @@ + + */ + static void + transform_display_init(transform_display *dp, png_modifier *pm, png_uint_32 id, +- PNG_CONST image_transform *transform_list) ++ const image_transform *transform_list) + { + memset(dp, 0, sizeof *dp); + + /* Standard fields */ +- standard_display_init(&dp->this, &pm->this, id, 0/*do_interlace*/, ++ standard_display_init(&dp->this, &pm->this, id, do_read_interlace, + pm->use_update_info); + + /* Parameter fields */ + dp->pm = pm; + dp->transform_list = transform_list; ++ dp->max_gamma_8 = 16; + + /* Local variable fields */ + dp->output_colour_type = 255; /* invalid */ + dp->output_bit_depth = 255; /* invalid */ ++ dp->unpacked = 0; /* not unpacked */ + } + + static void +@@ -5734,6 +6105,14 @@ + + dp->output_colour_type = png_get_color_type(pp, pi); + dp->output_bit_depth = png_get_bit_depth(pp, pi); + ++ /* If png_set_filler is in action then fake the output color type to include ++ * an alpha channel where appropriate. ++ */ ++ if (dp->output_bit_depth >= 8 && ++ (dp->output_colour_type == PNG_COLOR_TYPE_RGB || ++ dp->output_colour_type == PNG_COLOR_TYPE_GRAY) && dp->this.filler) ++ dp->output_colour_type |= 4; ++ + /* Validate the combination of colour type and bit depth that we are getting + * out of libpng; the semantics of something not in the PNG spec are, at + * best, unclear. +@@ -5768,7 +6147,8 @@ + + } + + /* Use a test pixel to check that the output agrees with what we expect - +- * this avoids running the whole test if the output is unexpected. ++ * this avoids running the whole test if the output is unexpected. This also ++ * checks for internal errors. + */ + { + image_pixel test_pixel; +@@ -5783,7 +6163,7 @@ + + /* Don't need sBIT here, but it must be set to non-zero to avoid + * arithmetic overflows. + */ +- test_pixel.have_tRNS = dp->this.is_transparent; ++ test_pixel.have_tRNS = dp->this.is_transparent != 0; + test_pixel.red_sBIT = test_pixel.green_sBIT = test_pixel.blue_sBIT = + test_pixel.alpha_sBIT = test_pixel.sample_depth; + +@@ -5814,22 +6194,41 @@ + + } + + /* If both bit depth and colour type are correct check the sample depth. +- * I believe these are both internal errors. + */ +- if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE) +- { +- if (test_pixel.sample_depth != 8) /* oops - internal error! */ +- png_error(pp, ""pngvalid: internal: palette sample depth not 8""); +- } +- else if (test_pixel.sample_depth != dp->output_bit_depth) ++ if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE && ++ test_pixel.sample_depth != 8) /* oops - internal error! */ ++ png_error(pp, ""pngvalid: internal: palette sample depth not 8""); ++ else if (dp->unpacked && test_pixel.bit_depth != 8) ++ png_error(pp, ""pngvalid: internal: bad unpacked pixel depth""); ++ else if (!dp->unpacked && test_pixel.colour_type != PNG_COLOR_TYPE_PALETTE ++ && test_pixel.bit_depth != test_pixel.sample_depth) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, + ""internal: sample depth ""); + ++ /* Because unless something has set 'unpacked' or the image is palette ++ * mapped we expect the transform to keep sample depth and bit depth ++ * the same. ++ */ ++ pos = safecatn(message, sizeof message, pos, test_pixel.sample_depth); ++ pos = safecat(message, sizeof message, pos, "" expected ""); ++ pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); ++ ++ png_error(pp, message); ++ } ++ else if (test_pixel.bit_depth != dp->output_bit_depth) ++ { ++ /* This could be a libpng error too; libpng has not produced what we ++ * expect for the output bit depth. ++ */ ++ char message[128]; ++ size_t pos = safecat(message, sizeof message, 0, ++ ""internal: bit depth ""); ++ + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + pos = safecat(message, sizeof message, pos, "" expected ""); +- pos = safecatn(message, sizeof message, pos, test_pixel.sample_depth); ++ pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } +@@ -5847,7 +6246,7 @@ + + transform_range_check(png_const_structp pp, unsigned int r, unsigned int g, + unsigned int b, unsigned int a, unsigned int in_digitized, double in, + unsigned int out, png_byte sample_depth, double err, double limit, +- PNG_CONST char *name, double digitization_error) ++ const char *name, double digitization_error) + { + /* Compare the scaled, digitzed, values of our local calculation (in+-err) + * with the digitized values libpng produced; 'sample_depth' is the actual +@@ -5891,20 +6290,20 @@ + + png_infop pi) + { + /* Constants for the loop below: */ +- PNG_CONST png_store* PNG_CONST ps = dp->this.ps; +- PNG_CONST png_byte in_ct = dp->this.colour_type; +- PNG_CONST png_byte in_bd = dp->this.bit_depth; +- PNG_CONST png_uint_32 w = dp->this.w; +- PNG_CONST png_uint_32 h = dp->this.h; +- PNG_CONST png_byte out_ct = dp->output_colour_type; +- PNG_CONST png_byte out_bd = dp->output_bit_depth; +- PNG_CONST png_byte sample_depth = (png_byte)(out_ct == ++ const png_store* const ps = dp->this.ps; ++ const png_byte in_ct = dp->this.colour_type; ++ const png_byte in_bd = dp->this.bit_depth; ++ const png_uint_32 w = dp->this.w; ++ const png_uint_32 h = dp->this.h; ++ const png_byte out_ct = dp->output_colour_type; ++ const png_byte out_bd = dp->output_bit_depth; ++ const png_byte sample_depth = (png_byte)(out_ct == + PNG_COLOR_TYPE_PALETTE ? 8 : out_bd); +- PNG_CONST png_byte red_sBIT = dp->this.red_sBIT; +- PNG_CONST png_byte green_sBIT = dp->this.green_sBIT; +- PNG_CONST png_byte blue_sBIT = dp->this.blue_sBIT; +- PNG_CONST png_byte alpha_sBIT = dp->this.alpha_sBIT; +- PNG_CONST int have_tRNS = dp->this.is_transparent; ++ const png_byte red_sBIT = dp->this.red_sBIT; ++ const png_byte green_sBIT = dp->this.green_sBIT; ++ const png_byte blue_sBIT = dp->this.blue_sBIT; ++ const png_byte alpha_sBIT = dp->this.alpha_sBIT; ++ const int have_tRNS = dp->this.is_transparent; + double digitization_error; + + store_palette out_palette; +@@ -5959,7 +6358,7 @@ + + + for (y=0; ythis.palette); ++ image_pixel_init(&in_pixel, std, in_ct, in_bd, x, dp->this.palette, ++ NULL); + + in_pixel.red_sBIT = red_sBIT; + in_pixel.green_sBIT = green_sBIT; + in_pixel.blue_sBIT = blue_sBIT; + in_pixel.alpha_sBIT = alpha_sBIT; +- in_pixel.have_tRNS = have_tRNS; ++ in_pixel.have_tRNS = have_tRNS != 0; + + /* For error detection, below. */ + r = in_pixel.red; +@@ -5990,12 +6390,18 @@ + + b = in_pixel.blue; + a = in_pixel.alpha; + ++ /* This applies the transforms to the input data, including output ++ * format operations which must be used when reading the output ++ * pixel that libpng produces. ++ */ + dp->transform_list->mod(dp->transform_list, &in_pixel, pp, dp); + + /* Read the output pixel and compare it to what we got, we don't +- * use the error field here, so no need to update sBIT. ++ * use the error field here, so no need to update sBIT. in_pixel ++ * says whether we expect libpng to change the output format. + */ +- image_pixel_init(&out_pixel, pRow, out_ct, out_bd, x, out_palette); ++ image_pixel_init(&out_pixel, pRow, out_ct, out_bd, x, out_palette, ++ &in_pixel); + + /* We don't expect changes to the index here even if the bit depth is + * changed. +@@ -6058,8 +6464,8 @@ + + + /* A single test run. */ + static void +-transform_test(png_modifier *pmIn, PNG_CONST png_uint_32 idIn, +- PNG_CONST image_transform* transform_listIn, PNG_CONST char * volatile name) ++transform_test(png_modifier *pmIn, const png_uint_32 idIn, ++ const image_transform* transform_listIn, const char * const name) + { + transform_display d; + context(&pmIn->this, fault); +@@ -6160,8 +6566,11 @@ + + #define PT ITSTRUCT(end) /* stores the previous transform */ + + /* To save code: */ +-static void +-image_transform_default_ini(PNG_CONST image_transform *this, ++extern void image_transform_default_ini(const image_transform *this, ++ transform_display *that); /* silence GCC warnings */ ++ ++void /* private, but almost always needed */ ++image_transform_default_ini(const image_transform *this, + transform_display *that) + { + this->next->ini(this->next, that); +@@ -6170,7 +6579,7 @@ + + #ifdef PNG_READ_BACKGROUND_SUPPORTED + static int + image_transform_default_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(colour_type) + UNUSED(bit_depth) +@@ -6185,7 +6594,7 @@ + + #ifdef PNG_READ_EXPAND_SUPPORTED + /* png_set_palette_to_rgb */ + static void +-image_transform_png_set_palette_to_rgb_set(PNG_CONST image_transform *this, ++image_transform_png_set_palette_to_rgb_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_palette_to_rgb(pp); +@@ -6193,9 +6602,9 @@ + + } + + static void +-image_transform_png_set_palette_to_rgb_mod(PNG_CONST image_transform *this, ++image_transform_png_set_palette_to_rgb_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); +@@ -6205,7 +6614,7 @@ + + + static int + image_transform_png_set_palette_to_rgb_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(bit_depth) + +@@ -6223,28 +6632,42 @@ + + #ifdef PNG_READ_EXPAND_SUPPORTED + /* png_set_tRNS_to_alpha */ + static void +-image_transform_png_set_tRNS_to_alpha_set(PNG_CONST image_transform *this, ++image_transform_png_set_tRNS_to_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_tRNS_to_alpha(pp); ++ ++ /* If there was a tRNS chunk that would get expanded and add an alpha ++ * channel is_transparent must be updated: ++ */ ++ if (that->this.has_tRNS) ++ that->this.is_transparent = 1; ++ + this->next->set(this->next, that, pp, pi); + } + + static void +-image_transform_png_set_tRNS_to_alpha_mod(PNG_CONST image_transform *this, ++image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { ++#if PNG_LIBPNG_VER < 10700 + /* LIBPNG BUG: this always forces palette images to RGB. */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); ++#endif + + /* This effectively does an 'expand' only if there is some transparency to + * convert to an alpha channel. + */ + if (that->have_tRNS) +- image_pixel_add_alpha(that, &display->this); ++# if PNG_LIBPNG_VER >= 10700 ++ if (that->colour_type != PNG_COLOR_TYPE_PALETTE && ++ (that->colour_type & PNG_COLOR_MASK_ALPHA) == 0) ++# endif ++ image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + ++#if PNG_LIBPNG_VER < 10700 + /* LIBPNG BUG: otherwise libpng still expands to 8 bits! */ + else + { +@@ -6253,13 +6676,14 @@ + + if (that->sample_depth < 8) + that->sample_depth = 8; + } ++#endif + + this->next->mod(this->next, that, pp, display); + } + + static int + image_transform_png_set_tRNS_to_alpha_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(bit_depth) + +@@ -6268,9 +6692,14 @@ + + + /* We don't know yet whether there will be a tRNS chunk, but we know that + * this transformation should do nothing if there already is an alpha +- * channel. ++ * channel. In addition, after the bug fix in 1.7.0, there is no longer ++ * any action on a palette image. + */ +- return (colour_type & PNG_COLOR_MASK_ALPHA) == 0; ++ return ++# if PNG_LIBPNG_VER >= 10700 ++ colour_type != PNG_COLOR_TYPE_PALETTE && ++# endif ++ (colour_type & PNG_COLOR_MASK_ALPHA) == 0; + } + + IT(tRNS_to_alpha); +@@ -6281,17 +6710,18 @@ + + #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + /* png_set_gray_to_rgb */ + static void +-image_transform_png_set_gray_to_rgb_set(PNG_CONST image_transform *this, ++image_transform_png_set_gray_to_rgb_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_gray_to_rgb(pp); ++ /* NOTE: this doesn't result in tRNS expansion. */ + this->next->set(this->next, that, pp, pi); + } + + static void +-image_transform_png_set_gray_to_rgb_mod(PNG_CONST image_transform *this, ++image_transform_png_set_gray_to_rgb_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + /* NOTE: we can actually pend the tRNS processing at this point because we + * can correctly recognize the original pixel value even though we have +@@ -6299,7 +6729,7 @@ + + * doesn't do this, so we don't either. + */ + if ((that->colour_type & PNG_COLOR_MASK_COLOR) == 0 && that->have_tRNS) +- image_pixel_add_alpha(that, &display->this); ++ image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + /* Simply expand the bit depth and alter the colour type as required. */ + if (that->colour_type == PNG_COLOR_TYPE_GRAY) +@@ -6322,7 +6752,7 @@ + + + static int + image_transform_png_set_gray_to_rgb_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(bit_depth) + +@@ -6340,17 +6770,21 @@ + + #ifdef PNG_READ_EXPAND_SUPPORTED + /* png_set_expand */ + static void +-image_transform_png_set_expand_set(PNG_CONST image_transform *this, ++image_transform_png_set_expand_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_expand(pp); ++ ++ if (that->this.has_tRNS) ++ that->this.is_transparent = 1; ++ + this->next->set(this->next, that, pp, pi); + } + + static void +-image_transform_png_set_expand_mod(PNG_CONST image_transform *this, ++image_transform_png_set_expand_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + /* The general expand case depends on what the colour type is: */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) +@@ -6359,14 +6793,14 @@ + + that->sample_depth = that->bit_depth = 8; + + if (that->have_tRNS) +- image_pixel_add_alpha(that, &display->this); ++ image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + this->next->mod(this->next, that, pp, display); + } + + static int + image_transform_png_set_expand_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(bit_depth) + +@@ -6386,31 +6820,53 @@ + + + #ifdef PNG_READ_EXPAND_SUPPORTED + /* png_set_expand_gray_1_2_4_to_8 +- * LIBPNG BUG: this just does an 'expand' ++ * Pre 1.7.0 LIBPNG BUG: this just does an 'expand' + */ + static void + image_transform_png_set_expand_gray_1_2_4_to_8_set( +- PNG_CONST image_transform *this, transform_display *that, png_structp pp, ++ const image_transform *this, transform_display *that, png_structp pp, + png_infop pi) + { + png_set_expand_gray_1_2_4_to_8(pp); ++ /* NOTE: don't expect this to expand tRNS */ + this->next->set(this->next, that, pp, pi); + } + + static void + image_transform_png_set_expand_gray_1_2_4_to_8_mod( +- PNG_CONST image_transform *this, image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const image_transform *this, image_pixel *that, png_const_structp pp, ++ const transform_display *display) + { ++#if PNG_LIBPNG_VER < 10700 + image_transform_png_set_expand_mod(this, that, pp, display); ++#else ++ /* Only expand grayscale of bit depth less than 8: */ ++ if (that->colour_type == PNG_COLOR_TYPE_GRAY && ++ that->bit_depth < 8) ++ that->sample_depth = that->bit_depth = 8; ++ ++ this->next->mod(this->next, that, pp, display); ++#endif /* 1.7 or later */ + } + + static int + image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { ++#if PNG_LIBPNG_VER < 10700 + return image_transform_png_set_expand_add(this, that, colour_type, + bit_depth); ++#else ++ UNUSED(bit_depth) ++ ++ this->next = *that; ++ *that = this; ++ ++ /* This should do nothing unless the color type is gray and the bit depth is ++ * less than 8: ++ */ ++ return colour_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8; ++#endif /* 1.7 or later */ + } + + IT(expand_gray_1_2_4_to_8); +@@ -6421,17 +6877,24 @@ + + #ifdef PNG_READ_EXPAND_16_SUPPORTED + /* png_set_expand_16 */ + static void +-image_transform_png_set_expand_16_set(PNG_CONST image_transform *this, ++image_transform_png_set_expand_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_expand_16(pp); ++ ++ /* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */ ++# if PNG_LIBPNG_VER < 10700 ++ if (that->this.has_tRNS) ++ that->this.is_transparent = 1; ++# endif ++ + this->next->set(this->next, that, pp, pi); + } + + static void +-image_transform_png_set_expand_16_mod(PNG_CONST image_transform *this, ++image_transform_png_set_expand_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + /* Expect expand_16 to expand everything to 16 bits as a result of also + * causing 'expand' to happen. +@@ -6440,7 +6903,7 @@ + + image_pixel_convert_PLTE(that); + + if (that->have_tRNS) +- image_pixel_add_alpha(that, &display->this); ++ image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + if (that->bit_depth < 16) + that->sample_depth = that->bit_depth = 16; +@@ -6450,7 +6913,7 @@ + + + static int + image_transform_png_set_expand_16_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(colour_type) + +@@ -6469,17 +6932,21 @@ + + #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* API added in 1.5.4 */ + /* png_set_scale_16 */ + static void +-image_transform_png_set_scale_16_set(PNG_CONST image_transform *this, ++image_transform_png_set_scale_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_scale_16(pp); ++# if PNG_LIBPNG_VER < 10700 ++ /* libpng will limit the gamma table size: */ ++ that->max_gamma_8 = PNG_MAX_GAMMA_8; ++# endif + this->next->set(this->next, that, pp, pi); + } + + static void +-image_transform_png_set_scale_16_mod(PNG_CONST image_transform *this, ++image_transform_png_set_scale_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + if (that->bit_depth == 16) + { +@@ -6495,7 +6962,7 @@ + + + static int + image_transform_png_set_scale_16_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(colour_type) + +@@ -6513,17 +6980,21 @@ + + #ifdef PNG_READ_16_TO_8_SUPPORTED /* the default before 1.5.4 */ + /* png_set_strip_16 */ + static void +-image_transform_png_set_strip_16_set(PNG_CONST image_transform *this, ++image_transform_png_set_strip_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_strip_16(pp); ++# if PNG_LIBPNG_VER < 10700 ++ /* libpng will limit the gamma table size: */ ++ that->max_gamma_8 = PNG_MAX_GAMMA_8; ++# endif + this->next->set(this->next, that, pp, pi); + } + + static void +-image_transform_png_set_strip_16_mod(PNG_CONST image_transform *this, ++image_transform_png_set_strip_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + if (that->bit_depth == 16) + { +@@ -6548,7 +7019,7 @@ + + * png_set_scale_16 API in 1.5.4 (but 1.5.4+ always defines the above!) + */ + { +- PNG_CONST double d = (255-128.5)/65535; ++ const double d = (255-128.5)/65535; + that->rede += d; + that->greene += d; + that->bluee += d; +@@ -6562,7 +7033,7 @@ + + + static int + image_transform_png_set_strip_16_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(colour_type) + +@@ -6580,7 +7051,7 @@ + + #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + /* png_set_strip_alpha */ + static void +-image_transform_png_set_strip_alpha_set(PNG_CONST image_transform *this, ++image_transform_png_set_strip_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_set_strip_alpha(pp); +@@ -6588,9 +7059,9 @@ + + } + + static void +-image_transform_png_set_strip_alpha_mod(PNG_CONST image_transform *this, ++image_transform_png_set_strip_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY; +@@ -6605,7 +7076,7 @@ + + + static int + image_transform_png_set_strip_alpha_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(bit_depth) + +@@ -6626,7 +7097,8 @@ + + * png_fixed_point green) + * png_get_rgb_to_gray_status + * +- * The 'default' test here uses values known to be used inside libpng: ++ * The 'default' test here uses values known to be used inside libpng prior to ++ * 1.7.0: + * + * red: 6968 + * green: 23434 +@@ -6663,11 +7135,11 @@ + + #undef image_transform_ini + #define image_transform_ini image_transform_png_set_rgb_to_gray_ini + static void +-image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this, ++image_transform_png_set_rgb_to_gray_ini(const image_transform *this, + transform_display *that) + { + png_modifier *pm = that->pm; +- PNG_CONST color_encoding *e = pm->current_encoding; ++ const color_encoding *e = pm->current_encoding; + + UNUSED(this) + +@@ -6682,7 +7154,7 @@ + + /* Coefficients come from the encoding, but may need to be normalized to a + * white point Y of 1.0 + */ +- PNG_CONST double whiteY = e->red.Y + e->green.Y + e->blue.Y; ++ const double whiteY = e->red.Y + e->green.Y + e->blue.Y; + + data.red_coefficient = e->red.Y; + data.green_coefficient = e->green.Y; +@@ -6699,9 +7171,15 @@ + + else + { + /* The default (built in) coeffcients, as above: */ +- data.red_coefficient = 6968 / 32768.; +- data.green_coefficient = 23434 / 32768.; +- data.blue_coefficient = 2366 / 32768.; ++# if PNG_LIBPNG_VER < 10700 ++ data.red_coefficient = 6968 / 32768.; ++ data.green_coefficient = 23434 / 32768.; ++ data.blue_coefficient = 2366 / 32768.; ++# else ++ data.red_coefficient = .2126; ++ data.green_coefficient = .7152; ++ data.blue_coefficient = .0722; ++# endif + } + + data.gamma = pm->current_gamma; +@@ -6776,14 +7254,15 @@ + + * conversion adds another +/-2 in the 16-bit case and + * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. + */ ++# if PNG_LIBPNG_VER < 10700 ++ if (that->this.bit_depth < 16) ++ that->max_gamma_8 = PNG_MAX_GAMMA_8; ++# endif + that->pm->limit += pow( +-# if PNG_MAX_GAMMA_8 < 14 +- (that->this.bit_depth == 16 ? 8. : +- 6. + (1<<(15-PNG_MAX_GAMMA_8))) +-# else +- 8. +-# endif +- /65535, data.gamma); ++ (that->this.bit_depth == 16 || that->max_gamma_8 > 14 ? ++ 8. : ++ 6. + (1<<(15-that->max_gamma_8)) ++ )/65535, data.gamma); + } + + else +@@ -6795,19 +7274,18 @@ + + * When DIGITIZE is set because a pre-1.7 version of libpng is being + * tested allow a bigger slack. + * +- * NOTE: this magic number was determined by experiment to be 1.1 (when +- * using fixed point arithmetic). There's no great merit to the value +- * below, however it only affects the limit used for checking for +- * internal calculation errors, not the actual limit imposed by +- * pngvalid on the output errors. ++ * NOTE: this magic number was determined by experiment to be about ++ * 1.263. There's no great merit to the value below, however it only ++ * affects the limit used for checking for internal calculation errors, ++ * not the actual limit imposed by pngvalid on the output errors. + */ + that->pm->limit += pow( +-# if DIGITIZE +- 1.1 +-# else +- 1. +-# endif +- /255, data.gamma); ++# if DIGITIZE ++ 1.3 ++# else ++ 1.0 ++# endif ++ /255, data.gamma); + } + } + +@@ -6822,10 +7300,10 @@ + + } + + static void +-image_transform_png_set_rgb_to_gray_set(PNG_CONST image_transform *this, ++image_transform_png_set_rgb_to_gray_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { +- PNG_CONST int error_action = 1; /* no error, no defines in png.h */ ++ const int error_action = 1; /* no error, no defines in png.h */ + + # ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_rgb_to_gray(pp, error_action, data.red_to_set, data.green_to_set); +@@ -6862,7 +7340,7 @@ + + & PNG_INFO_cHRM) != 0) + { + double maxe; +- PNG_CONST char *el; ++ const char *el; + color_encoding e, o; + + /* Expect libpng to return a normalized result, but the original +@@ -6949,26 +7427,32 @@ + + } + + static void +-image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this, ++image_transform_png_set_rgb_to_gray_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + if ((that->colour_type & PNG_COLOR_MASK_COLOR) != 0) + { + double gray, err; + +- if (that->colour_type == PNG_COLOR_TYPE_PALETTE) +- image_pixel_convert_PLTE(that); ++# if PNG_LIBPNG_VER < 10700 ++ if (that->colour_type == PNG_COLOR_TYPE_PALETTE) ++ image_pixel_convert_PLTE(that); ++# endif + + /* Image now has RGB channels... */ + # if DIGITIZE + { +- PNG_CONST png_modifier *pm = display->pm; ++ const png_modifier *pm = display->pm; + const unsigned int sample_depth = that->sample_depth; + const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 : + sample_depth); +- const unsigned int gamma_depth = (sample_depth == 16 ? 16 : +- (pm->assume_16_bit_calculations ? PNG_MAX_GAMMA_8 : sample_depth)); ++ const unsigned int gamma_depth = ++ (sample_depth == 16 ? ++ display->max_gamma_8 : ++ (pm->assume_16_bit_calculations ? ++ display->max_gamma_8 : ++ sample_depth)); + int isgray; + double r, g, b; + double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi; +@@ -6981,56 +7465,73 @@ + + * will be identical after this operation if there is only one + * transform, feel free to delete the png_error checks on this below in + * the future (this is just me trying to ensure it works!) ++ * ++ * Interval arithmetic is exact, but to implement it it must be ++ * possible to control the floating point implementation rounding mode. ++ * This cannot be done in ANSI-C, so instead I reduce the 'lo' values ++ * by DBL_EPSILON and increase the 'hi' values by the same. + */ ++# define DD(v,d,r) (digitize(v*(1-DBL_EPSILON), d, r) * (1-DBL_EPSILON)) ++# define DU(v,d,r) (digitize(v*(1+DBL_EPSILON), d, r) * (1+DBL_EPSILON)) ++ + r = rlo = rhi = that->redf; + rlo -= that->rede; +- rlo = digitize(rlo, calc_depth, 1/*round*/); ++ rlo = DD(rlo, calc_depth, 1/*round*/); + rhi += that->rede; +- rhi = digitize(rhi, calc_depth, 1/*round*/); ++ rhi = DU(rhi, calc_depth, 1/*round*/); + + g = glo = ghi = that->greenf; + glo -= that->greene; +- glo = digitize(glo, calc_depth, 1/*round*/); ++ glo = DD(glo, calc_depth, 1/*round*/); + ghi += that->greene; +- ghi = digitize(ghi, calc_depth, 1/*round*/); ++ ghi = DU(ghi, calc_depth, 1/*round*/); + + b = blo = bhi = that->bluef; + blo -= that->bluee; +- blo = digitize(blo, calc_depth, 1/*round*/); +- bhi += that->greene; +- bhi = digitize(bhi, calc_depth, 1/*round*/); ++ blo = DD(blo, calc_depth, 1/*round*/); ++ bhi += that->bluee; ++ bhi = DU(bhi, calc_depth, 1/*round*/); + + isgray = r==g && g==b; + + if (data.gamma != 1) + { +- PNG_CONST double power = 1/data.gamma; +- PNG_CONST double abse = calc_depth == 16 ? .5/65535 : .5/255; ++ const double power = 1/data.gamma; ++ const double abse = .5/(sample_depth == 16 ? 65535 : 255); + +- /* 'abse' is the absolute error permitted in linear calculations. It +- * is used here to capture the error permitted in the handling +- * (undoing) of the gamma encoding. Once again digitization occurs +- * to handle the upper and lower bounds of the values. This is +- * where the real errors are introduced. ++ /* If a gamma calculation is done it is done using lookup tables of ++ * precision gamma_depth, so the already digitized value above may ++ * need to be further digitized here. + */ ++ if (gamma_depth != calc_depth) ++ { ++ rlo = DD(rlo, gamma_depth, 0/*truncate*/); ++ rhi = DU(rhi, gamma_depth, 0/*truncate*/); ++ glo = DD(glo, gamma_depth, 0/*truncate*/); ++ ghi = DU(ghi, gamma_depth, 0/*truncate*/); ++ blo = DD(blo, gamma_depth, 0/*truncate*/); ++ bhi = DU(bhi, gamma_depth, 0/*truncate*/); ++ } ++ ++ /* 'abse' is the error in the gamma table calculation itself. */ + r = pow(r, power); +- rlo = digitize(pow(rlo, power)-abse, calc_depth, 1); +- rhi = digitize(pow(rhi, power)+abse, calc_depth, 1); ++ rlo = DD(pow(rlo, power)-abse, calc_depth, 1); ++ rhi = DU(pow(rhi, power)+abse, calc_depth, 1); + + g = pow(g, power); +- glo = digitize(pow(glo, power)-abse, calc_depth, 1); +- ghi = digitize(pow(ghi, power)+abse, calc_depth, 1); ++ glo = DD(pow(glo, power)-abse, calc_depth, 1); ++ ghi = DU(pow(ghi, power)+abse, calc_depth, 1); + + b = pow(b, power); +- blo = digitize(pow(blo, power)-abse, calc_depth, 1); +- bhi = digitize(pow(bhi, power)+abse, calc_depth, 1); ++ blo = DD(pow(blo, power)-abse, calc_depth, 1); ++ bhi = DU(pow(bhi, power)+abse, calc_depth, 1); + } + + /* Now calculate the actual gray values. Although the error in the + * coefficients depends on whether they were specified on the command + * line (in which case truncation to 15 bits happened) or not (rounding + * was used) the maxium error in an individual coefficient is always +- * 1/32768, because even in the rounding case the requirement that ++ * 2/32768, because even in the rounding case the requirement that + * coefficients add up to 32768 can cause a larger rounding error. + * + * The only time when rounding doesn't occur in 1.5.5 and later is when +@@ -7040,32 +7541,46 @@ + + b * data.blue_coefficient; + + { +- PNG_CONST int do_round = data.gamma != 1 || calc_depth == 16; +- PNG_CONST double ce = 1. / 32768; ++ const int do_round = data.gamma != 1 || calc_depth == 16; ++ const double ce = 2. / 32768; + +- graylo = digitize(rlo * (data.red_coefficient-ce) + ++ graylo = DD(rlo * (data.red_coefficient-ce) + + glo * (data.green_coefficient-ce) + +- blo * (data.blue_coefficient-ce), gamma_depth, do_round); +- if (graylo <= 0) +- graylo = 0; ++ blo * (data.blue_coefficient-ce), calc_depth, do_round); ++ if (graylo > gray) /* always accept the right answer */ ++ graylo = gray; + +- grayhi = digitize(rhi * (data.red_coefficient+ce) + ++ grayhi = DU(rhi * (data.red_coefficient+ce) + + ghi * (data.green_coefficient+ce) + +- bhi * (data.blue_coefficient+ce), gamma_depth, do_round); +- if (grayhi >= 1) +- grayhi = 1; ++ bhi * (data.blue_coefficient+ce), calc_depth, do_round); ++ if (grayhi < gray) ++ grayhi = gray; + } + + /* And invert the gamma. */ + if (data.gamma != 1) + { +- PNG_CONST double power = data.gamma; ++ const double power = data.gamma; ++ ++ /* And this happens yet again, shifting the values once more. */ ++ if (gamma_depth != sample_depth) ++ { ++ rlo = DD(rlo, gamma_depth, 0/*truncate*/); ++ rhi = DU(rhi, gamma_depth, 0/*truncate*/); ++ glo = DD(glo, gamma_depth, 0/*truncate*/); ++ ghi = DU(ghi, gamma_depth, 0/*truncate*/); ++ blo = DD(blo, gamma_depth, 0/*truncate*/); ++ bhi = DU(bhi, gamma_depth, 0/*truncate*/); ++ } + + gray = pow(gray, power); +- graylo = digitize(pow(graylo, power), sample_depth, 1); +- grayhi = digitize(pow(grayhi, power), sample_depth, 1); ++ graylo = DD(pow(graylo, power), sample_depth, 1); ++ grayhi = DU(pow(grayhi, power), sample_depth, 1); + } + ++# undef DD ++# undef DU ++ + /* Now the error can be calculated. + * + * If r==g==b because there is no overall gamma correction libpng +@@ -7103,29 +7618,46 @@ + + double b = that->bluef; + double be = that->bluee; + +- /* The true gray case involves no math. */ +- if (r == g && r == b) +- { +- gray = r; +- err = re; +- if (err < ge) err = ge; +- if (err < be) err = be; +- } ++# if PNG_LIBPNG_VER < 10700 ++ /* The true gray case involves no math in earlier versions (not ++ * true, there was some if gamma correction was happening too.) ++ */ ++ if (r == g && r == b) ++ { ++ gray = r; ++ err = re; ++ if (err < ge) err = ge; ++ if (err < be) err = be; ++ } + +- else if (data.gamma == 1) ++ else ++# endif /* before 1.7 */ ++ if (data.gamma == 1) + { + /* There is no need to do the conversions to and from linear space, + * so the calculation should be a lot more accurate. There is a +- * built in 1/32768 error in the coefficients because they only have +- * 15 bits and are adjusted to make sure they add up to 32768, so +- * the result may have an additional error up to 1/32768. (Note +- * that adding the 1/32768 here avoids needing to increase the +- * global error limits to take this into account.) ++ * built in error in the coefficients because they only have 15 bits ++ * and are adjusted to make sure they add up to 32768. This ++ * involves a integer calculation with truncation of the form: ++ * ++ * ((int)(coefficient * 100000) * 32768)/100000 ++ * ++ * This is done to the red and green coefficients (the ones ++ * provided to the API) then blue is calculated from them so the ++ * result adds up to 32768. In the worst case this can result in ++ * a -1 error in red and green and a +2 error in blue. Consequently ++ * the worst case in the calculation below is 2/32768 error. ++ * ++ * TODO: consider fixing this in libpng by rounding the calculation ++ * limiting the error to 1/32768. ++ * ++ * Handling this by adding 2/32768 here avoids needing to increase ++ * the global error limits to take this into account.) + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient; + err = re * data.red_coefficient + ge * data.green_coefficient + +- be * data.blue_coefficient + 1./32768 + gray * 5 * DBL_EPSILON; ++ be * data.blue_coefficient + 2./32768 + gray * 5 * DBL_EPSILON; + } + + else +@@ -7136,10 +7668,10 @@ + + * lookups in the calculation and each introduces a quantization + * error defined by the table size. + */ +- PNG_CONST png_modifier *pm = display->pm; ++ const png_modifier *pm = display->pm; + double in_qe = (that->sample_depth > 8 ? .5/65535 : .5/255); + double out_qe = (that->sample_depth > 8 ? .5/65535 : +- (pm->assume_16_bit_calculations ? .5/(1<assume_16_bit_calculations ? .5/(1<max_gamma_8) : + .5/255)); + double rhi, ghi, bhi, grayhi; + double g1 = 1/data.gamma; +@@ -7160,7 +7692,7 @@ + + * previously added input quantization error at this point. + */ + gray = r * data.red_coefficient + g * data.green_coefficient + +- b * data.blue_coefficient - 1./32768 - out_qe; ++ b * data.blue_coefficient - 2./32768 - out_qe; + if (gray <= 0) + gray = 0; + else +@@ -7170,7 +7702,7 @@ + + } + + grayhi = rhi * data.red_coefficient + ghi * data.green_coefficient + +- bhi * data.blue_coefficient + 1./32768 + out_qe; ++ bhi * data.blue_coefficient + 2./32768 + out_qe; + grayhi *= (1 + 6 * DBL_EPSILON); + if (grayhi >= 1) + grayhi = 1; +@@ -7226,7 +7758,7 @@ + + + static int + image_transform_png_set_rgb_to_gray_add(image_transform *this, +- PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) + { + UNUSED(bit_depth) + +@@ -7257,7 +7789,7 @@ + + static image_pixel data; + + static void +-image_transform_png_set_background_set(PNG_CONST image_transform *this, ++image_transform_png_set_background_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) + { + png_byte colour_type, bit_depth; +@@ -7285,12 +7817,15 @@ + + + else + { ++ if (that->this.has_tRNS) ++ that->this.is_transparent = 1; ++ + bit_depth = that->this.bit_depth; + expand = 1; + } + + image_pixel_init(&data, random_bytes, colour_type, +- bit_depth, 0/*x*/, 0/*unused: palette*/); ++ bit_depth, 0/*x*/, 0/*unused: palette*/, NULL/*format*/); + + /* Extract the background colour from this image_pixel, but make sure the + * unused fields of 'back' are garbage. +@@ -7317,13 +7852,13 @@ + + } + + static void +-image_transform_png_set_background_mod(PNG_CONST image_transform *this, ++image_transform_png_set_background_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) ++ const transform_display *display) + { + /* Check for tRNS first: */ + if (that->have_tRNS && that->colour_type != PNG_COLOR_TYPE_PALETTE) +- image_pixel_add_alpha(that, &display->this); ++ image_pixel_add_alpha(that, &display->this, 1/*for background*/); + + /* This is only necessary if the alpha value is less than 1. */ + if (that->alphaf < 1) +@@ -7362,14 +7897,14 @@ + + /* Remove the alpha type and set the alpha (not in that order.) */ + that->alphaf = 1; + that->alphae = 0; +- +- if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) +- that->colour_type = PNG_COLOR_TYPE_RGB; +- else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) +- that->colour_type = PNG_COLOR_TYPE_GRAY; +- /* PNG_COLOR_TYPE_PALETTE is not changed */ + } + ++ if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) ++ that->colour_type = PNG_COLOR_TYPE_RGB; ++ else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) ++ that->colour_type = PNG_COLOR_TYPE_GRAY; ++ /* PNG_COLOR_TYPE_PALETTE is not changed */ ++ + this->next->mod(this->next, that, pp, display); + } + +@@ -7381,11 +7916,604 @@ + + #define PT ITSTRUCT(background) + #endif /* PNG_READ_BACKGROUND_SUPPORTED */ + +-/* This may just be 'end' if all the transforms are disabled! */ +-static image_transform *PNG_CONST image_transform_first = &PT; ++/* png_set_quantize(png_structp, png_colorp palette, int num_palette, ++ * int maximum_colors, png_const_uint_16p histogram, int full_quantize) ++ * ++ * Very difficult to validate this! ++ */ ++/*NOTE: TBD NYI */ ++ ++/* The data layout transforms are handled by swapping our own channel data, ++ * necessarily these need to happen at the end of the transform list because the ++ * semantic of the channels changes after these are executed. Some of these, ++ * like set_shift and set_packing, can't be done at present because they change ++ * the layout of the data at the sub-sample level so sample() won't get the ++ * right answer. ++ */ ++/* png_set_invert_alpha */ ++#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED ++/* Invert the alpha channel ++ * ++ * png_set_invert_alpha(png_structrp png_ptr) ++ */ ++static void ++image_transform_png_set_invert_alpha_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_invert_alpha(pp); ++ this->next->set(this->next, that, pp, pi); ++} + + static void +-transform_enable(PNG_CONST char *name) ++image_transform_png_set_invert_alpha_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->colour_type & 4) ++ that->alpha_inverted = 1; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_invert_alpha_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(bit_depth) ++ ++ this->next = *that; ++ *that = this; ++ ++ /* Only has an effect on pixels with alpha: */ ++ return (colour_type & 4) != 0; ++} ++ ++IT(invert_alpha); ++#undef PT ++#define PT ITSTRUCT(invert_alpha) ++ ++#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */ ++ ++/* png_set_bgr */ ++#ifdef PNG_READ_BGR_SUPPORTED ++/* Swap R,G,B channels to order B,G,R. ++ * ++ * png_set_bgr(png_structrp png_ptr) ++ * ++ * This only has an effect on RGB and RGBA pixels. ++ */ ++static void ++image_transform_png_set_bgr_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_bgr(pp); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_bgr_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->colour_type == PNG_COLOR_TYPE_RGB || ++ that->colour_type == PNG_COLOR_TYPE_RGBA) ++ that->swap_rgb = 1; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_bgr_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(bit_depth) ++ ++ this->next = *that; ++ *that = this; ++ ++ return colour_type == PNG_COLOR_TYPE_RGB || ++ colour_type == PNG_COLOR_TYPE_RGBA; ++} ++ ++IT(bgr); ++#undef PT ++#define PT ITSTRUCT(bgr) ++ ++#endif /* PNG_READ_BGR_SUPPORTED */ ++ ++/* png_set_swap_alpha */ ++#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED ++/* Put the alpha channel first. ++ * ++ * png_set_swap_alpha(png_structrp png_ptr) ++ * ++ * This only has an effect on GA and RGBA pixels. ++ */ ++static void ++image_transform_png_set_swap_alpha_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_swap_alpha(pp); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_swap_alpha_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->colour_type == PNG_COLOR_TYPE_GA || ++ that->colour_type == PNG_COLOR_TYPE_RGBA) ++ that->alpha_first = 1; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_swap_alpha_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(bit_depth) ++ ++ this->next = *that; ++ *that = this; ++ ++ return colour_type == PNG_COLOR_TYPE_GA || ++ colour_type == PNG_COLOR_TYPE_RGBA; ++} ++ ++IT(swap_alpha); ++#undef PT ++#define PT ITSTRUCT(swap_alpha) ++ ++#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED */ ++ ++/* png_set_swap */ ++#ifdef PNG_READ_SWAP_SUPPORTED ++/* Byte swap 16-bit components. ++ * ++ * png_set_swap(png_structrp png_ptr) ++ */ ++static void ++image_transform_png_set_swap_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_swap(pp); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_swap_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->bit_depth == 16) ++ that->swap16 = 1; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_swap_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(colour_type) ++ ++ this->next = *that; ++ *that = this; ++ ++ return bit_depth == 16; ++} ++ ++IT(swap); ++#undef PT ++#define PT ITSTRUCT(swap) ++ ++#endif /* PNG_READ_SWAP_SUPPORTED */ ++ ++#ifdef PNG_READ_FILLER_SUPPORTED ++/* Add a filler byte to 8-bit Gray or 24-bit RGB images. ++ * ++ * png_set_filler, (png_structp png_ptr, png_uint_32 filler, int flags)); ++ * ++ * Flags: ++ * ++ * PNG_FILLER_BEFORE ++ * PNG_FILLER_AFTER ++ */ ++#define data ITDATA(filler) ++static struct ++{ ++ png_uint_32 filler; ++ int flags; ++} data; ++ ++static void ++image_transform_png_set_filler_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ /* Need a random choice for 'before' and 'after' as well as for the ++ * filler. The 'filler' value has all 32 bits set, but only bit_depth ++ * will be used. At this point we don't know bit_depth. ++ */ ++ RANDOMIZE(data.filler); ++ data.flags = random_choice(); ++ ++ png_set_filler(pp, data.filler, data.flags); ++ ++ /* The standard display handling stuff also needs to know that ++ * there is a filler, so set that here. ++ */ ++ that->this.filler = 1; ++ ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_filler_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->bit_depth >= 8 && ++ (that->colour_type == PNG_COLOR_TYPE_RGB || ++ that->colour_type == PNG_COLOR_TYPE_GRAY)) ++ { ++ const unsigned int max = (1U << that->bit_depth)-1; ++ that->alpha = data.filler & max; ++ that->alphaf = ((double)that->alpha) / max; ++ that->alphae = 0; ++ ++ /* The filler has been stored in the alpha channel, we must record ++ * that this has been done for the checking later on, the color ++ * type is faked to have an alpha channel, but libpng won't report ++ * this; the app has to know the extra channel is there and this ++ * was recording in standard_display::filler above. ++ */ ++ that->colour_type |= 4; /* alpha added */ ++ that->alpha_first = data.flags == PNG_FILLER_BEFORE; ++ } ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_filler_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ this->next = *that; ++ *that = this; ++ ++ return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || ++ colour_type == PNG_COLOR_TYPE_GRAY); ++} ++ ++#undef data ++IT(filler); ++#undef PT ++#define PT ITSTRUCT(filler) ++ ++/* png_set_add_alpha, (png_structp png_ptr, png_uint_32 filler, int flags)); */ ++/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ ++#define data ITDATA(add_alpha) ++static struct ++{ ++ png_uint_32 filler; ++ int flags; ++} data; ++ ++static void ++image_transform_png_set_add_alpha_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ /* Need a random choice for 'before' and 'after' as well as for the ++ * filler. The 'filler' value has all 32 bits set, but only bit_depth ++ * will be used. At this point we don't know bit_depth. ++ */ ++ RANDOMIZE(data.filler); ++ data.flags = random_choice(); ++ ++ png_set_add_alpha(pp, data.filler, data.flags); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_add_alpha_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->bit_depth >= 8 && ++ (that->colour_type == PNG_COLOR_TYPE_RGB || ++ that->colour_type == PNG_COLOR_TYPE_GRAY)) ++ { ++ const unsigned int max = (1U << that->bit_depth)-1; ++ that->alpha = data.filler & max; ++ that->alphaf = ((double)that->alpha) / max; ++ that->alphae = 0; ++ ++ that->colour_type |= 4; /* alpha added */ ++ that->alpha_first = data.flags == PNG_FILLER_BEFORE; ++ } ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_add_alpha_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ this->next = *that; ++ *that = this; ++ ++ return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || ++ colour_type == PNG_COLOR_TYPE_GRAY); ++} ++ ++#undef data ++IT(add_alpha); ++#undef PT ++#define PT ITSTRUCT(add_alpha) ++ ++#endif /* PNG_READ_FILLER_SUPPORTED */ ++ ++/* png_set_packing */ ++#ifdef PNG_READ_PACK_SUPPORTED ++/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. ++ * ++ * png_set_packing(png_structrp png_ptr) ++ * ++ * This should only affect grayscale and palette images with less than 8 bits ++ * per pixel. ++ */ ++static void ++image_transform_png_set_packing_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_packing(pp); ++ that->unpacked = 1; ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_packing_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ /* The general expand case depends on what the colour type is, ++ * low bit-depth pixel values are unpacked into bytes without ++ * scaling, so sample_depth is not changed. ++ */ ++ if (that->bit_depth < 8) /* grayscale or palette */ ++ that->bit_depth = 8; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_packing_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(colour_type) ++ ++ this->next = *that; ++ *that = this; ++ ++ /* Nothing should happen unless the bit depth is less than 8: */ ++ return bit_depth < 8; ++} ++ ++IT(packing); ++#undef PT ++#define PT ITSTRUCT(packing) ++ ++#endif /* PNG_READ_PACK_SUPPORTED */ ++ ++/* png_set_packswap */ ++#ifdef PNG_READ_PACKSWAP_SUPPORTED ++/* Swap pixels packed into bytes; reverses the order on screen so that ++ * the high order bits correspond to the rightmost pixels. ++ * ++ * png_set_packswap(png_structrp png_ptr) ++ */ ++static void ++image_transform_png_set_packswap_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_packswap(pp); ++ that->this.littleendian = 1; ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_packswap_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->bit_depth < 8) ++ that->littleendian = 1; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_packswap_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(colour_type) ++ ++ this->next = *that; ++ *that = this; ++ ++ return bit_depth < 8; ++} ++ ++IT(packswap); ++#undef PT ++#define PT ITSTRUCT(packswap) ++ ++#endif /* PNG_READ_PACKSWAP_SUPPORTED */ ++ ++ ++/* png_set_invert_mono */ ++#ifdef PNG_READ_INVERT_MONO_SUPPORTED ++/* Invert the gray channel ++ * ++ * png_set_invert_mono(png_structrp png_ptr) ++ */ ++static void ++image_transform_png_set_invert_mono_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_invert_mono(pp); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_invert_mono_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ if (that->colour_type & 4) ++ that->mono_inverted = 1; ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_invert_mono_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(bit_depth) ++ ++ this->next = *that; ++ *that = this; ++ ++ /* Only has an effect on pixels with no colour: */ ++ return (colour_type & 2) == 0; ++} ++ ++IT(invert_mono); ++#undef PT ++#define PT ITSTRUCT(invert_mono) ++ ++#endif /* PNG_READ_INVERT_MONO_SUPPORTED */ ++ ++#ifdef PNG_READ_SHIFT_SUPPORTED ++/* png_set_shift(png_structp, png_const_color_8p true_bits) ++ * ++ * The output pixels will be shifted by the given true_bits ++ * values. ++ */ ++#define data ITDATA(shift) ++static png_color_8 data; ++ ++static void ++image_transform_png_set_shift_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ /* Get a random set of shifts. The shifts need to do something ++ * to test the transform, so they are limited to the bit depth ++ * of the input image. Notice that in the following the 'gray' ++ * field is randomized independently. This acts as a check that ++ * libpng does use the correct field. ++ */ ++ const unsigned int depth = that->this.bit_depth; ++ ++ data.red = (png_byte)/*SAFE*/(random_mod(depth)+1); ++ data.green = (png_byte)/*SAFE*/(random_mod(depth)+1); ++ data.blue = (png_byte)/*SAFE*/(random_mod(depth)+1); ++ data.gray = (png_byte)/*SAFE*/(random_mod(depth)+1); ++ data.alpha = (png_byte)/*SAFE*/(random_mod(depth)+1); ++ ++ png_set_shift(pp, &data); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_shift_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ /* Copy the correct values into the sBIT fields, libpng does not do ++ * anything to palette data: ++ */ ++ if (that->colour_type != PNG_COLOR_TYPE_PALETTE) ++ { ++ that->sig_bits = 1; ++ ++ /* The sBIT fields are reset to the values previously sent to ++ * png_set_shift according to the colour type. ++ * does. ++ */ ++ if (that->colour_type & 2) /* RGB channels */ ++ { ++ that->red_sBIT = data.red; ++ that->green_sBIT = data.green; ++ that->blue_sBIT = data.blue; ++ } ++ ++ else /* One grey channel */ ++ that->red_sBIT = that->green_sBIT = that->blue_sBIT = data.gray; ++ ++ that->alpha_sBIT = data.alpha; ++ } ++ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_shift_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ UNUSED(bit_depth) ++ ++ this->next = *that; ++ *that = this; ++ ++ return colour_type != PNG_COLOR_TYPE_PALETTE; ++} ++ ++IT(shift); ++#undef PT ++#define PT ITSTRUCT(shift) ++ ++#endif /* PNG_READ_SHIFT_SUPPORTED */ ++ ++#ifdef THIS_IS_THE_PROFORMA ++static void ++image_transform_png_set_@_set(const image_transform *this, ++ transform_display *that, png_structp pp, png_infop pi) ++{ ++ png_set_@(pp); ++ this->next->set(this->next, that, pp, pi); ++} ++ ++static void ++image_transform_png_set_@_mod(const image_transform *this, ++ image_pixel *that, png_const_structp pp, ++ const transform_display *display) ++{ ++ this->next->mod(this->next, that, pp, display); ++} ++ ++static int ++image_transform_png_set_@_add(image_transform *this, ++ const image_transform **that, png_byte colour_type, png_byte bit_depth) ++{ ++ this->next = *that; ++ *that = this; ++ ++ return 1; ++} ++ ++IT(@); ++#endif ++ ++ ++/* This may just be 'end' if all the transforms are disabled! */ ++static image_transform *const image_transform_first = &PT; ++ ++static void ++transform_enable(const char *name) + { + /* Everything starts out enabled, so if we see an 'enable' disabled + * everything else the first time round. +@@ -7418,7 +8546,7 @@ + + } + + static void +-transform_disable(PNG_CONST char *name) ++transform_disable(const char *name) + { + image_transform *list = image_transform_first; + +@@ -7481,7 +8609,7 @@ + + } + + static png_uint_32 +-image_transform_add(PNG_CONST image_transform **this, unsigned int max, ++image_transform_add(const image_transform **this, unsigned int max, + png_uint_32 counter, char *name, size_t sizeof_name, size_t *pos, + png_byte colour_type, png_byte bit_depth) + { +@@ -7558,83 +8686,6 @@ + + } + } + +-#ifdef THIS_IS_THE_PROFORMA +-static void +-image_transform_png_set_@_set(PNG_CONST image_transform *this, +- transform_display *that, png_structp pp, png_infop pi) +-{ +- png_set_@(pp); +- this->next->set(this->next, that, pp, pi); +-} +- +-static void +-image_transform_png_set_@_mod(PNG_CONST image_transform *this, +- image_pixel *that, png_const_structp pp, +- PNG_CONST transform_display *display) +-{ +- this->next->mod(this->next, that, pp, display); +-} +- +-static int +-image_transform_png_set_@_add(image_transform *this, +- PNG_CONST image_transform **that, char *name, size_t sizeof_name, +- size_t *pos, png_byte colour_type, png_byte bit_depth) +-{ +- this->next = *that; +- *that = this; +- +- *pos = safecat(name, sizeof_name, *pos, "" +@""); +- +- return 1; +-} +- +-IT(@); +-#endif +- +-/* png_set_quantize(png_structp, png_colorp palette, int num_palette, +- * int maximum_colors, png_const_uint_16p histogram, int full_quantize) +- * +- * Very difficult to validate this! +- */ +-/*NOTE: TBD NYI */ +- +-/* The data layout transforms are handled by swapping our own channel data, +- * necessarily these need to happen at the end of the transform list because the +- * semantic of the channels changes after these are executed. Some of these, +- * like set_shift and set_packing, can't be done at present because they change +- * the layout of the data at the sub-sample level so sample() won't get the +- * right answer. +- */ +-/* png_set_invert_alpha */ +-/*NOTE: TBD NYI */ +- +-/* png_set_bgr */ +-/*NOTE: TBD NYI */ +- +-/* png_set_swap_alpha */ +-/*NOTE: TBD NYI */ +- +-/* png_set_swap */ +-/*NOTE: TBD NYI */ +- +-/* png_set_filler, (png_structp png_ptr, png_uint_32 filler, int flags)); */ +-/*NOTE: TBD NYI */ +- +-/* png_set_add_alpha, (png_structp png_ptr, png_uint_32 filler, int flags)); */ +-/*NOTE: TBD NYI */ +- +-/* png_set_packing */ +-/*NOTE: TBD NYI */ +- +-/* png_set_packswap */ +-/*NOTE: TBD NYI */ +- +-/* png_set_invert_mono */ +-/*NOTE: TBD NYI */ +- +-/* png_set_shift(png_structp, png_const_color_8p true_bits) */ +-/*NOTE: TBD NYI */ +- + static void + perform_transform_test(png_modifier *pm) + { +@@ -7642,7 +8693,8 @@ + + png_byte bit_depth = 0; + unsigned int palette_number = 0; + +- while (next_format(&colour_type, &bit_depth, &palette_number, 0)) ++ while (next_format(&colour_type, &bit_depth, &palette_number, pm->test_lbg, ++ pm->test_tRNS)) + { + png_uint_32 counter = 0; + size_t base_pos; +@@ -7653,7 +8705,7 @@ + + for (;;) + { + size_t pos = base_pos; +- PNG_CONST image_transform *list = 0; ++ const image_transform *list = 0; + + /* 'max' is currently hardwired to '1'; this should be settable on the + * command line. +@@ -7714,11 +8766,11 @@ + + gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id, + double file_gamma, double screen_gamma, png_byte sbit, int threshold_test, + int use_input_precision, int scale16, int expand16, +- int do_background, PNG_CONST png_color_16 *pointer_to_the_background_color, ++ int do_background, const png_color_16 *pointer_to_the_background_color, + double background_gamma) + { + /* Standard fields */ +- standard_display_init(&dp->this, &pm->this, id, 0/*do_interlace*/, ++ standard_display_init(&dp->this, &pm->this, id, do_read_interlace, + pm->use_update_info); + + /* Parameter fields */ +@@ -7750,7 +8802,7 @@ + + /* If requested strip 16 to 8 bits - this is handled automagically below + * because the output bit depth is read from the library. Note that there + * are interactions with sBIT but, internally, libpng makes sbit at most +- * PNG_MAX_GAMMA_8 when doing the following. ++ * PNG_MAX_GAMMA_8 prior to 1.7 when doing the following. + */ + if (dp->scale16) + # ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +@@ -7782,9 +8834,9 @@ + + * non-inverted, represenation. It provides a default for the PNG file + * gamma, but since the file has a gAMA chunk this does not matter. + */ +- PNG_CONST double sg = dp->screen_gamma; ++ const double sg = dp->screen_gamma; + # ifndef PNG_FLOATING_POINT_SUPPORTED +- PNG_CONST png_fixed_point g = fix(sg); ++ const png_fixed_point g = fix(sg); + # endif + + # ifdef PNG_FLOATING_POINT_SUPPORTED +@@ -7830,9 +8882,9 @@ + + # ifdef PNG_READ_BACKGROUND_SUPPORTED + /* NOTE: this assumes the caller provided the correct background gamma! + */ +- PNG_CONST double bg = dp->background_gamma; ++ const double bg = dp->background_gamma; + # ifndef PNG_FLOATING_POINT_SUPPORTED +- PNG_CONST png_fixed_point g = fix(bg); ++ const png_fixed_point g = fix(bg); + # endif + + # ifdef PNG_FLOATING_POINT_SUPPORTED +@@ -7906,7 +8958,7 @@ + + init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp, + int in_depth, int out_depth) + { +- PNG_CONST unsigned int outmax = (1U<pp = pp; + vi->dp = dp; +@@ -7945,13 +8997,15 @@ + + vi->outlog = outlog(dp->pm, in_depth, out_depth); + + if ((dp->this.colour_type & PNG_COLOR_MASK_ALPHA) != 0 || +- (dp->this.colour_type == 3 && dp->this.is_transparent)) ++ (dp->this.colour_type == 3 && dp->this.is_transparent) || ++ ((dp->this.colour_type == 0 || dp->this.colour_type == 2) && ++ dp->this.has_tRNS)) + { + vi->do_background = dp->do_background; + + if (vi->do_background != 0) + { +- PNG_CONST double bg_inverse = 1/dp->background_gamma; ++ const double bg_inverse = 1/dp->background_gamma; + double r, g, b; + + /* Caller must at least put the gray value into the red channel */ +@@ -7975,7 +9029,7 @@ + + vi->background_blue = b; + } + } +- else ++ else /* Do not expect any background processing */ + vi->do_background = 0; + + if (vi->do_background == 0) +@@ -8065,15 +9119,15 @@ + + + /* This API returns the encoded *input* component, in the range 0..1 */ + static double +-gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi, +- PNG_CONST unsigned int id, PNG_CONST unsigned int od, +- PNG_CONST double alpha /* <0 for the alpha channel itself */, +- PNG_CONST double background /* component background value */) ++gamma_component_validate(const char *name, const validate_info *vi, ++ const unsigned int id, const unsigned int od, ++ const double alpha /* <0 for the alpha channel itself */, ++ const double background /* component background value */) + { +- PNG_CONST unsigned int isbit = id >> vi->isbit_shift; +- PNG_CONST unsigned int sbit_max = vi->sbit_max; +- PNG_CONST unsigned int outmax = vi->outmax; +- PNG_CONST int do_background = vi->do_background; ++ const unsigned int isbit = id >> vi->isbit_shift; ++ const unsigned int sbit_max = vi->sbit_max; ++ const unsigned int outmax = vi->outmax; ++ const int do_background = vi->do_background; + + double i; + +@@ -8638,14 +9692,14 @@ + + png_infop pi) + { + /* Get some constants derived from the input and output file formats: */ +- PNG_CONST png_store* PNG_CONST ps = dp->this.ps; +- PNG_CONST png_byte in_ct = dp->this.colour_type; +- PNG_CONST png_byte in_bd = dp->this.bit_depth; +- PNG_CONST png_uint_32 w = dp->this.w; +- PNG_CONST png_uint_32 h = dp->this.h; +- PNG_CONST size_t cbRow = dp->this.cbRow; +- PNG_CONST png_byte out_ct = png_get_color_type(pp, pi); +- PNG_CONST png_byte out_bd = png_get_bit_depth(pp, pi); ++ const png_store* const ps = dp->this.ps; ++ const png_byte in_ct = dp->this.colour_type; ++ const png_byte in_bd = dp->this.bit_depth; ++ const png_uint_32 w = dp->this.w; ++ const png_uint_32 h = dp->this.h; ++ const size_t cbRow = dp->this.cbRow; ++ const png_byte out_ct = png_get_color_type(pp, pi); ++ const png_byte out_bd = png_get_bit_depth(pp, pi); + + /* There are three sources of error, firstly the quantization in the + * file encoding, determined by sbit and/or the file depth, secondly +@@ -8686,11 +9740,12 @@ + + * The basic tests below do not do this, however if 'use_input_precision' + * is set a subsequent test is performed above. + */ +- PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U; ++ const unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U; + int processing; + png_uint_32 y; +- PNG_CONST store_palette_entry *in_palette = dp->this.palette; +- PNG_CONST int in_is_transparent = dp->this.is_transparent; ++ const store_palette_entry *in_palette = dp->this.palette; ++ const int in_is_transparent = dp->this.is_transparent; ++ int process_tRNS; + int out_npalette = -1; + int out_is_transparent = 0; /* Just refers to the palette case */ + store_palette out_palette; +@@ -8706,6 +9761,7 @@ + + + processing = (vi.gamma_correction > 0 && !dp->threshold_test) + || in_bd != out_bd || in_ct != out_ct || vi.do_background; ++ process_tRNS = dp->this.has_tRNS && vi.do_background; + + /* TODO: FIX THIS: MAJOR BUG! If the transformations all happen inside + * the palette there is no way of finding out, because libpng fails to +@@ -8736,20 +9792,20 @@ + + double alpha = 1; /* serves as a flag value */ + + /* Record the palette index for index images. */ +- PNG_CONST unsigned int in_index = +- in_ct == 3 ? sample(std, 3, in_bd, x, 0) : 256; +- PNG_CONST unsigned int out_index = +- out_ct == 3 ? sample(std, 3, out_bd, x, 0) : 256; ++ const unsigned int in_index = ++ in_ct == 3 ? sample(std, 3, in_bd, x, 0, 0, 0) : 256; ++ const unsigned int out_index = ++ out_ct == 3 ? sample(std, 3, out_bd, x, 0, 0, 0) : 256; + + /* Handle input alpha - png_set_background will cause the output + * alpha to disappear so there is nothing to check. + */ +- if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 || (in_ct == 3 && +- in_is_transparent)) ++ if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 || ++ (in_ct == 3 && in_is_transparent)) + { +- PNG_CONST unsigned int input_alpha = in_ct == 3 ? ++ const unsigned int input_alpha = in_ct == 3 ? + dp->this.palette[in_index].alpha : +- sample(std, in_ct, in_bd, x, samples_per_pixel); ++ sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0); + + unsigned int output_alpha = 65536 /* as a flag value */; + +@@ -8761,7 +9817,7 @@ + + + else if ((out_ct & PNG_COLOR_MASK_ALPHA) != 0) + output_alpha = sample(pRow, out_ct, out_bd, x, +- samples_per_pixel); ++ samples_per_pixel, 0, 0); + + if (output_alpha != 65536) + alpha = gamma_component_validate(""alpha"", &vi, input_alpha, +@@ -8777,33 +9833,62 @@ + + } + } + ++ else if (process_tRNS) ++ { ++ /* alpha needs to be set appropriately for this pixel, it is ++ * currently 1 and needs to be 0 for an input pixel which matches ++ * the values in tRNS. ++ */ ++ switch (in_ct) ++ { ++ case 0: /* gray */ ++ if (sample(std, in_ct, in_bd, x, 0, 0, 0) == ++ dp->this.transparent.red) ++ alpha = 0; ++ break; ++ ++ case 2: /* RGB */ ++ if (sample(std, in_ct, in_bd, x, 0, 0, 0) == ++ dp->this.transparent.red && ++ sample(std, in_ct, in_bd, x, 1, 0, 0) == ++ dp->this.transparent.green && ++ sample(std, in_ct, in_bd, x, 2, 0, 0) == ++ dp->this.transparent.blue) ++ alpha = 0; ++ break; ++ ++ default: ++ break; ++ } ++ } ++ + /* Handle grayscale or RGB components. */ + if ((in_ct & PNG_COLOR_MASK_COLOR) == 0) /* grayscale */ + (void)gamma_component_validate(""gray"", &vi, +- sample(std, in_ct, in_bd, x, 0), +- sample(pRow, out_ct, out_bd, x, 0), alpha/*component*/, +- vi.background_red); ++ sample(std, in_ct, in_bd, x, 0, 0, 0), ++ sample(pRow, out_ct, out_bd, x, 0, 0, 0), ++ alpha/*component*/, vi.background_red); + else /* RGB or palette */ + { + (void)gamma_component_validate(""red"", &vi, + in_ct == 3 ? in_palette[in_index].red : +- sample(std, in_ct, in_bd, x, 0), ++ sample(std, in_ct, in_bd, x, 0, 0, 0), + out_ct == 3 ? out_palette[out_index].red : +- sample(pRow, out_ct, out_bd, x, 0), ++ sample(pRow, out_ct, out_bd, x, 0, 0, 0), + alpha/*component*/, vi.background_red); + + (void)gamma_component_validate(""green"", &vi, + in_ct == 3 ? in_palette[in_index].green : +- sample(std, in_ct, in_bd, x, 1), ++ sample(std, in_ct, in_bd, x, 1, 0, 0), + out_ct == 3 ? out_palette[out_index].green : +- sample(pRow, out_ct, out_bd, x, 1), ++ sample(pRow, out_ct, out_bd, x, 1, 0, 0), + alpha/*component*/, vi.background_green); + + (void)gamma_component_validate(""blue"", &vi, + in_ct == 3 ? in_palette[in_index].blue : +- sample(std, in_ct, in_bd, x, 2), ++ sample(std, in_ct, in_bd, x, 2, 0, 0), + out_ct == 3 ? out_palette[out_index].blue : +- sample(pRow, out_ct, out_bd, x, 2), ++ sample(pRow, out_ct, out_bd, x, 2, 0, 0), + alpha/*component*/, vi.background_blue); + } + } +@@ -8843,15 +9928,15 @@ + + * maxpc: maximum percentage error (as a percentage) + */ + static void +-gamma_test(png_modifier *pmIn, PNG_CONST png_byte colour_typeIn, +- PNG_CONST png_byte bit_depthIn, PNG_CONST int palette_numberIn, +- PNG_CONST int interlace_typeIn, +- PNG_CONST double file_gammaIn, PNG_CONST double screen_gammaIn, +- PNG_CONST png_byte sbitIn, PNG_CONST int threshold_testIn, +- PNG_CONST char *name, +- PNG_CONST int use_input_precisionIn, PNG_CONST int scale16In, +- PNG_CONST int expand16In, PNG_CONST int do_backgroundIn, +- PNG_CONST png_color_16 *bkgd_colorIn, double bkgd_gammaIn) ++gamma_test(png_modifier *pmIn, const png_byte colour_typeIn, ++ const png_byte bit_depthIn, const int palette_numberIn, ++ const int interlace_typeIn, ++ const double file_gammaIn, const double screen_gammaIn, ++ const png_byte sbitIn, const int threshold_testIn, ++ const char *name, ++ const int use_input_precisionIn, const int scale16In, ++ const int expand16In, const int do_backgroundIn, ++ const png_color_16 *bkgd_colorIn, double bkgd_gammaIn) + { + gamma_display d; + context(&pmIn->this, fault); +@@ -8886,7 +9971,7 @@ + + + modification_reset(d.pm->modifications); + +- /* Get a png_struct for writing the image. */ ++ /* Get a png_struct for reading the image. */ + pp = set_modifier_for_read(d.pm, &pi, d.this.id, name); + standard_palette_init(&d.this); + +@@ -9025,9 +10110,13 @@ + + /* Don't test more than one instance of each palette - it's pointless, in + * fact this test is somewhat excessive since libpng doesn't make this + * decision based on colour type or bit depth! ++ * ++ * CHANGED: now test two palettes and, as a side effect, images with and ++ * without tRNS. + */ +- while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/)) +- if (palette_number == 0) ++ while (next_format(&colour_type, &bit_depth, &palette_number, ++ pm->test_lbg_gamma_threshold, pm->test_tRNS)) ++ if (palette_number < 2) + { + double test_gamma = 1.0; + while (test_gamma >= .4) +@@ -9050,11 +10139,11 @@ + + } + + static void gamma_transform_test(png_modifier *pm, +- PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth, +- PNG_CONST int palette_number, +- PNG_CONST int interlace_type, PNG_CONST double file_gamma, +- PNG_CONST double screen_gamma, PNG_CONST png_byte sbit, +- PNG_CONST int use_input_precision, PNG_CONST int scale16) ++ const png_byte colour_type, const png_byte bit_depth, ++ const int palette_number, ++ const int interlace_type, const double file_gamma, ++ const double screen_gamma, const png_byte sbit, ++ const int use_input_precision, const int scale16) + { + size_t pos = 0; + char name[64]; +@@ -9087,7 +10176,8 @@ + + png_byte bit_depth = 0; + unsigned int palette_number = 0; + +- while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/)) ++ while (next_format(&colour_type, &bit_depth, &palette_number, ++ pm->test_lbg_gamma_transform, pm->test_tRNS)) + { + unsigned int i, j; + +@@ -9117,7 +10207,8 @@ + + png_byte colour_type = 0, bit_depth = 0; + unsigned int npalette = 0; + +- while (next_format(&colour_type, &bit_depth, &npalette, 1/*gamma*/)) ++ while (next_format(&colour_type, &bit_depth, &npalette, ++ pm->test_lbg_gamma_sbit, pm->test_tRNS)) + if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 && + ((colour_type == 3 && sbit < 8) || + (colour_type != 3 && sbit < bit_depth))) +@@ -9152,7 +10243,11 @@ + + # ifndef PNG_MAX_GAMMA_8 + # define PNG_MAX_GAMMA_8 11 + # endif +-# define SBIT_16_TO_8 PNG_MAX_GAMMA_8 ++# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700 ++# define SBIT_16_TO_8 PNG_MAX_GAMMA_8 ++# else ++# define SBIT_16_TO_8 16 ++# endif + /* Include the alpha cases here. Note that sbit matches the internal value + * used by the library - otherwise we will get spurious errors from the + * internal sbit style approximation. +@@ -9205,12 +10300,12 @@ + + #if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) + static void gamma_composition_test(png_modifier *pm, +- PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth, +- PNG_CONST int palette_number, +- PNG_CONST int interlace_type, PNG_CONST double file_gamma, +- PNG_CONST double screen_gamma, +- PNG_CONST int use_input_precision, PNG_CONST int do_background, +- PNG_CONST int expand_16) ++ const png_byte colour_type, const png_byte bit_depth, ++ const int palette_number, ++ const int interlace_type, const double file_gamma, ++ const double screen_gamma, ++ const int use_input_precision, const int do_background, ++ const int expand_16) + { + size_t pos = 0; + png_const_charp base; +@@ -9308,8 +10403,17 @@ + + } + + background.index = 193; /* rgb(193,193,193) to detect errors */ ++ + if (!(colour_type & PNG_COLOR_MASK_COLOR)) + { ++ /* Because, currently, png_set_background is always called with ++ * 'need_expand' false in this case and because the gamma test itself ++ * doesn't cause an expand to 8-bit for lower bit depths the colour must ++ * be reduced to the correct range. ++ */ ++ if (bit_depth < 8) ++ background.gray &= (png_uint_16)((1U << bit_depth)-1); ++ + /* Grayscale input, we do not convert to RGB (TBD), so we must set the + * background to gray - else libpng seems to fail. + */ +@@ -9358,9 +10462,18 @@ + + + /* Skip the non-alpha cases - there is no setting of a transparency colour at + * present. ++ * ++ * TODO: incorrect; the palette case sets tRNS and, now RGB and gray do, ++ * however the palette case fails miserably so is commented out below. + */ +- while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/)) +- if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0) ++ while (next_format(&colour_type, &bit_depth, &palette_number, ++ pm->test_lbg_gamma_composition, pm->test_tRNS)) ++ if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0 ++#if 0 /* TODO: FIXME */ ++ /*TODO: FIXME: this should work */ ++ || colour_type == 3 ++#endif ++ || (colour_type != 3 && palette_number != 0)) + { + unsigned int i, j; + +@@ -9579,7 +10692,7 @@ + + * be indexed adam7[y][x] and notice that the pass numbers are based at + * 1, not 0 - the base libpng uses. + */ +-static PNG_CONST ++static const + png_byte adam7[8][8] = + { + { 1,6,4,6,2,6,4,6 }, +@@ -9930,7 +11043,7 @@ + + * The png_modifier code assumes that encodings[0] is sRGB and treats it + * specially: do not change the first entry in this list! + */ +-static PNG_CONST color_encoding test_encodings[] = ++static const color_encoding test_encodings[] = + { + /* sRGB: must be first in this list! */ + /*gamma:*/ { 1/2.2, +@@ -9952,6 +11065,11 @@ + + /*red: */ { 0.716500716779386, 0.258728243040113, 0.000000000000000 }, + /*green:*/ { 0.101020574397477, 0.724682314948566, 0.051211818965388 }, + /*blue: */ { 0.146774385252705, 0.016589442011321, 0.773892783545073} }, ++/* Fake encoding which selects just the green channel */ ++/*gamma:*/ { 1.45/2.2, /* the 'Mac' gamma */ ++/*red: */ { 0.716500716779386, 0.000000000000000, 0.000000000000000 }, ++/*green:*/ { 0.101020574397477, 1.000000000000000, 0.051211818965388 }, ++/*blue: */ { 0.146774385252705, 0.000000000000000, 0.773892783545073} }, + }; + + /* signal handler +@@ -10023,11 +11141,11 @@ + + /* main program */ + int main(int argc, char **argv) + { +- volatile int summary = 1; /* Print the error summary at the end */ +- volatile int memstats = 0; /* Print memory statistics at the end */ ++ int summary = 1; /* Print the error summary at the end */ ++ int memstats = 0; /* Print memory statistics at the end */ + + /* Create the given output file on success: */ +- PNG_CONST char *volatile touch = NULL; ++ const char *touch = NULL; + + /* This is an array of standard gamma values (believe it or not I've seen + * every one of these mentioned somewhere.) +@@ -10043,6 +11161,10 @@ + + + anon_context(&pm.this); + ++ gnu_volatile(summary) ++ gnu_volatile(memstats) ++ gnu_volatile(touch) ++ + /* Add appropriate signal handlers, just the ANSI specified ones: */ + signal(SIGABRT, signal_handler); + signal(SIGFPE, signal_handler); +@@ -10089,14 +11211,30 @@ + + + /* Store the test gammas */ + pm.gammas = gammas; +- pm.ngammas = (sizeof gammas) / (sizeof gammas[0]); ++ pm.ngammas = ARRAY_SIZE(gammas); + pm.ngamma_tests = 0; /* default to off */ + ++ /* Low bit depth gray images don't do well in the gamma tests, until ++ * this is fixed turn them off for some gamma cases: ++ */ ++# ifdef PNG_WRITE_tRNS_SUPPORTED ++ pm.test_tRNS = 1; ++# endif ++ pm.test_lbg = PNG_LIBPNG_VER >= 10600; ++ pm.test_lbg_gamma_threshold = 1; ++ pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600; ++ pm.test_lbg_gamma_sbit = 1; ++ pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700; ++ + /* And the test encodings */ + pm.encodings = test_encodings; +- pm.nencodings = (sizeof test_encodings) / (sizeof test_encodings[0]); ++ pm.nencodings = ARRAY_SIZE(test_encodings); + +- pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ ++# if PNG_LIBPNG_VER < 10700 ++ pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ ++# else ++ pm.sbitlow = 1U; ++# endif + + /* The following allows results to pass if they correspond to anything in the + * transformed range [input-.5,input+.5]; this is is required because of the +@@ -10122,7 +11260,11 @@ + + pm.maxout16 = .499; /* Error in *encoded* value */ + pm.maxabs16 = .00005;/* 1/20000 */ + pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */ +- pm.maxcalcG = 1./((1<s3->tmp.new_cipher->algorithm_mkey; + alg_a = s->s3->tmp.new_cipher->algorithm_auth; + + /* we don't have a certificate */ + if ((alg_a & (SSL_aDH | SSL_aNULL | SSL_aKRB5)) || (alg_k & SSL_kPSK)) + return (1); + + sc = s->session->sess_cert; + if (sc == NULL) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto err; + } +#ifndef OPENSSL_NO_RSA + rsa = s->session->sess_cert->peer_rsa_tmp; +#endif +#ifndef OPENSSL_NO_DH + dh = s->session->sess_cert->peer_dh_tmp; +#endif + + /* This is the passed certificate */ + + idx = sc->peer_cert_type; +#ifndef OPENSSL_NO_ECDH + if (idx == SSL_PKEY_ECC) { + if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, s) == 0) { + /* check failed */ + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_BAD_ECC_CERT); + goto f_err; + } else { + return 1; + } + } +#endif + pkey = X509_get_pubkey(sc->peer_pkeys[idx].x509); + pkey_bits = EVP_PKEY_bits(pkey); + i = X509_certificate_type(sc->peer_pkeys[idx].x509, pkey); + EVP_PKEY_free(pkey); + + /* Check that we have a certificate if we require one */ + if ((alg_a & SSL_aRSA) && !has_bits(i, EVP_PK_RSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_SIGNING_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DSA_SIGNING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) { + if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + !has_bits(i, EVP_PK_RSA | EVP_PKT_ENC)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } else if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) { + if (pkey_bits <= SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + if (!has_bits(i, EVP_PK_RSA | EVP_PKT_ENC)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } + if (rsa != NULL) { + /* server key exchange is not allowed. */ + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto f_err; + } + } + } + } +#endif +#ifndef OPENSSL_NO_DH + if ((alg_k & SSL_kEDH) && dh == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto f_err; + } + if ((alg_k & SSL_kDHr) && !has_bits(i, EVP_PK_DH | EVP_PKS_RSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_RSA_CERT); + goto f_err; + } +# ifndef OPENSSL_NO_DSA + if ((alg_k & SSL_kDHd) && !has_bits(i, EVP_PK_DH | EVP_PKS_DSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_DSA_CERT); + goto f_err; + } +# endif + + /* Check DHE only: static DH not implemented. */ + if (alg_k & SSL_kEDH) { + int dh_size = BN_num_bits(dh->p); + if ((!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && dh_size < 1024) + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && dh_size < 512)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_DH_KEY_TOO_SMALL); + goto f_err; + } + } +#endif /* !OPENSSL_NO_DH */ + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + pkey_bits > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) { + if (rsa == NULL) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } else if (BN_num_bits(rsa->n) > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + /* We have a temporary RSA key but it's too large. */ + al = SSL_AD_EXPORT_RESTRICTION; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & SSL_kEDH) { + if (BN_num_bits(dh->p) > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + /* We have a temporary DH key but it's too large. */ + al = SSL_AD_EXPORT_RESTRICTION; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } + } else if (alg_k & (SSL_kDHr | SSL_kDHd)) { + /* The cert should have had an export DH key. */ + al = SSL_AD_EXPORT_RESTRICTION; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } else +#endif + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + } + return (1); + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + err: + return (0); +} +",0,"int ssl3_check_cert_and_algorithm(SSL *s) +{ + int i, idx; + long alg_k, alg_a; + EVP_PKEY *pkey = NULL; + int pkey_bits; + SESS_CERT *sc; +#ifndef OPENSSL_NO_RSA + RSA *rsa; +#endif +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + int al = SSL_AD_HANDSHAKE_FAILURE; + + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + alg_a = s->s3->tmp.new_cipher->algorithm_auth; + + /* we don't have a certificate */ + if ((alg_a & (SSL_aDH | SSL_aNULL | SSL_aKRB5)) || (alg_k & SSL_kPSK)) + return (1); + + sc = s->session->sess_cert; + if (sc == NULL) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto err; + } +#ifndef OPENSSL_NO_RSA + rsa = s->session->sess_cert->peer_rsa_tmp; +#endif +#ifndef OPENSSL_NO_DH + dh = s->session->sess_cert->peer_dh_tmp; +#endif + + /* This is the passed certificate */ + + idx = sc->peer_cert_type; +#ifndef OPENSSL_NO_ECDH + if (idx == SSL_PKEY_ECC) { + if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, s) == 0) { + /* check failed */ + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_BAD_ECC_CERT); + goto f_err; + } else { + return 1; + } + } +#endif + pkey = X509_get_pubkey(sc->peer_pkeys[idx].x509); + pkey_bits = EVP_PKEY_bits(pkey); + i = X509_certificate_type(sc->peer_pkeys[idx].x509, pkey); + EVP_PKEY_free(pkey); + + /* Check that we have a certificate if we require one */ + if ((alg_a & SSL_aRSA) && !has_bits(i, EVP_PK_RSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_SIGNING_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DSA_SIGNING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) { + if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + !has_bits(i, EVP_PK_RSA | EVP_PKT_ENC)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } else if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) { + if (pkey_bits <= SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + if (!has_bits(i, EVP_PK_RSA | EVP_PKT_ENC)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } + if (rsa != NULL) { + /* server key exchange is not allowed. */ + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto f_err; + } + } + } + } +#endif +#ifndef OPENSSL_NO_DH + if ((alg_k & SSL_kEDH) && dh == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto f_err; + } + if ((alg_k & SSL_kDHr) && !has_bits(i, EVP_PK_DH | EVP_PKS_RSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_RSA_CERT); + goto f_err; + } +# ifndef OPENSSL_NO_DSA + if ((alg_k & SSL_kDHd) && !has_bits(i, EVP_PK_DH | EVP_PKS_DSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_DSA_CERT); + goto f_err; + } +# endif + + /* Check DHE only: static DH not implemented. */ + if (alg_k & SSL_kEDH) { + int dh_size = BN_num_bits(dh->p); + if ((!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && dh_size < 1024) + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && dh_size < 512)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_DH_KEY_TOO_SMALL); + goto f_err; + } + } +#endif /* !OPENSSL_NO_DH */ + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + pkey_bits > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) { + if (rsa == NULL) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } else if (BN_num_bits(rsa->n) > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + /* We have a temporary RSA key but it's too large. */ + al = SSL_AD_EXPORT_RESTRICTION; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & SSL_kEDH) { + if (BN_num_bits(dh->p) > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + /* We have a temporary DH key but it's too large. */ + al = SSL_AD_EXPORT_RESTRICTION; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } + } else if (alg_k & (SSL_kDHr | SSL_kDHd)) { + /* The cert should have had an export DH key. */ + al = SSL_AD_EXPORT_RESTRICTION; + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } else +#endif + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + } + return (1); + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + err: + return (0); +} +","@@ -1143,6 +1143,12 @@ int ssl3_get_server_certificate(SSL *s) + goto f_err; + } + for (nc = 0; nc < llen;) { ++ if (nc + 3 > llen) { ++ al = SSL_AD_DECODE_ERROR; ++ SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ++ SSL_R_CERT_LENGTH_MISMATCH); ++ goto f_err; ++ } + n2l3(p, l); + if ((l + nc + 3) > llen) { + al = SSL_AD_DECODE_ERROR; +@@ -2072,6 +2078,11 @@ int ssl3_get_certificate_request(SSL *s) + } + + for (nc = 0; nc < llen;) { ++ if (nc + 2 > llen) { ++ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); ++ SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_CA_DN_TOO_LONG); ++ goto err; ++ } + n2s(p, l); + if ((l + nc + 2) > llen) { + if ((s->options & SSL_OP_NETSCAPE_CA_DN_BUG))",1534,1770,2048 +18140,"IPV6DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len) +{ + int i; + int ret = 0; + + DefragInit(); + + /* + * Build the packets. + */ + + int id = 1; + Packet *packets[17]; + memset(packets, 0x00, sizeof(packets)); + + /* + * Original fragments. + */ + + /* A*24 at 0. */ + packets[0] = IPV6BuildTestPacket(id, 0, 1, 'A', 24); + + /* B*15 at 32. */ + packets[1] = IPV6BuildTestPacket(id, 32 >> 3, 1, 'B', 16); + + /* C*24 at 48. */ + packets[2] = IPV6BuildTestPacket(id, 48 >> 3, 1, 'C', 24); + + /* D*8 at 80. */ + packets[3] = IPV6BuildTestPacket(id, 80 >> 3, 1, 'D', 8); + + /* E*16 at 104. */ + packets[4] = IPV6BuildTestPacket(id, 104 >> 3, 1, 'E', 16); + + /* F*24 at 120. */ + packets[5] = IPV6BuildTestPacket(id, 120 >> 3, 1, 'F', 24); + + /* G*16 at 144. */ + packets[6] = IPV6BuildTestPacket(id, 144 >> 3, 1, 'G', 16); + + /* H*16 at 160. */ + packets[7] = IPV6BuildTestPacket(id, 160 >> 3, 1, 'H', 16); + + /* I*8 at 176. */ + packets[8] = IPV6BuildTestPacket(id, 176 >> 3, 1, 'I', 8); + + /* + * Overlapping subsequent fragments. + */ + + /* J*32 at 8. */ + packets[9] = IPV6BuildTestPacket(id, 8 >> 3, 1, 'J', 32); + + /* K*24 at 48. */ + packets[10] = IPV6BuildTestPacket(id, 48 >> 3, 1, 'K', 24); + + /* L*24 at 72. */ + packets[11] = IPV6BuildTestPacket(id, 72 >> 3, 1, 'L', 24); + + /* M*24 at 96. */ + packets[12] = IPV6BuildTestPacket(id, 96 >> 3, 1, 'M', 24); + + /* N*8 at 128. */ + packets[13] = IPV6BuildTestPacket(id, 128 >> 3, 1, 'N', 8); + + /* O*8 at 152. */ + packets[14] = IPV6BuildTestPacket(id, 152 >> 3, 1, 'O', 8); + + /* P*8 at 160. */ + packets[15] = IPV6BuildTestPacket(id, 160 >> 3, 1, 'P', 8); + + /* Q*16 at 176. */ + packets[16] = IPV6BuildTestPacket(id, 176 >> 3, 0, 'Q', 16); + + default_policy = policy; + + /* Send all but the last. */ + for (i = 0; i < 9; i++) { + Packet *tp = Defrag(NULL, NULL, packets[i], NULL); + if (tp != NULL) { + SCFree(tp); + goto end; + } + if (ENGINE_ISSET_EVENT(packets[i], IPV6_FRAG_OVERLAP)) { + goto end; + } + } + int overlap = 0; + for (; i < 16; i++) { + Packet *tp = Defrag(NULL, NULL, packets[i], NULL); + if (tp != NULL) { + SCFree(tp); + goto end; + } + if (ENGINE_ISSET_EVENT(packets[i], IPV6_FRAG_OVERLAP)) { + overlap++; + } + } + if (!overlap) + goto end; + + /* And now the last one. */ + Packet *reassembled = Defrag(NULL, NULL, packets[16], NULL); + if (reassembled == NULL) + goto end; + if (memcmp(GET_PKT_DATA(reassembled) + 40, expected, expected_len) != 0) + goto end; + + if (IPV6_GET_PLEN(reassembled) != 192) + goto end; + + SCFree(reassembled); + + /* Make sure all frags were returned to the pool. */ + if (defrag_context->frag_pool->outstanding != 0) { + printf(""defrag_context->frag_pool->outstanding %u: "", defrag_context->frag_pool->outstanding); + goto end; + } + + ret = 1; + +end: + for (i = 0; i < 17; i++) { + SCFree(packets[i]); + } + DefragDestroy(); + return ret; +} +",1,"IPV6DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len) +{ + int i; + int ret = 0; + + DefragInit(); + + /* + * Build the packets. + */ + + int id = 1; + Packet *packets[17]; + memset(packets, 0x00, sizeof(packets)); + + /* + * Original fragments. + */ + + /* A*24 at 0. */ + packets[0] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 0, 1, 'A', 24); + + /* B*15 at 32. */ + packets[1] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 32 >> 3, 1, 'B', 16); + + /* C*24 at 48. */ + packets[2] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 48 >> 3, 1, 'C', 24); + + /* D*8 at 80. */ + packets[3] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 80 >> 3, 1, 'D', 8); + + /* E*16 at 104. */ + packets[4] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 104 >> 3, 1, 'E', 16); + + /* F*24 at 120. */ + packets[5] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 120 >> 3, 1, 'F', 24); + + /* G*16 at 144. */ + packets[6] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 144 >> 3, 1, 'G', 16); + + /* H*16 at 160. */ + packets[7] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 160 >> 3, 1, 'H', 16); + + /* I*8 at 176. */ + packets[8] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 176 >> 3, 1, 'I', 8); + + /* + * Overlapping subsequent fragments. + */ + + /* J*32 at 8. */ + packets[9] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 8 >> 3, 1, 'J', 32); + + /* K*24 at 48. */ + packets[10] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 48 >> 3, 1, 'K', 24); + + /* L*24 at 72. */ + packets[11] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 72 >> 3, 1, 'L', 24); + + /* M*24 at 96. */ + packets[12] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 96 >> 3, 1, 'M', 24); + + /* N*8 at 128. */ + packets[13] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 128 >> 3, 1, 'N', 8); + + /* O*8 at 152. */ + packets[14] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 152 >> 3, 1, 'O', 8); + + /* P*8 at 160. */ + packets[15] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 160 >> 3, 1, 'P', 8); + + /* Q*16 at 176. */ + packets[16] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 176 >> 3, 0, 'Q', 16); + + default_policy = policy; + + /* Send all but the last. */ + for (i = 0; i < 9; i++) { + Packet *tp = Defrag(NULL, NULL, packets[i], NULL); + if (tp != NULL) { + SCFree(tp); + goto end; + } + if (ENGINE_ISSET_EVENT(packets[i], IPV6_FRAG_OVERLAP)) { + goto end; + } + } + int overlap = 0; + for (; i < 16; i++) { + Packet *tp = Defrag(NULL, NULL, packets[i], NULL); + if (tp != NULL) { + SCFree(tp); + goto end; + } + if (ENGINE_ISSET_EVENT(packets[i], IPV6_FRAG_OVERLAP)) { + overlap++; + } + } + if (!overlap) + goto end; + + /* And now the last one. */ + Packet *reassembled = Defrag(NULL, NULL, packets[16], NULL); + if (reassembled == NULL) + goto end; + if (memcmp(GET_PKT_DATA(reassembled) + 40, expected, expected_len) != 0) + goto end; + + if (IPV6_GET_PLEN(reassembled) != 192) + goto end; + + SCFree(reassembled); + + /* Make sure all frags were returned to the pool. */ + if (defrag_context->frag_pool->outstanding != 0) { + printf(""defrag_context->frag_pool->outstanding %u: "", defrag_context->frag_pool->outstanding); + goto end; + } + + ret = 1; + +end: + for (i = 0; i < 17; i++) { + SCFree(packets[i]); + } + DefragDestroy(); + return ret; +} +","@@ -996,8 +996,8 @@ void DefragDestroy(void) + * with some payload of no particular protocol. + */ + static Packet * +-BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content, +- int content_len) ++BuildTestPacket(uint8_t proto, uint16_t id, uint16_t off, int mf, ++ const char content, int content_len) + { + Packet *p = NULL; + int hlen = 20; +@@ -1023,7 +1023,7 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content, + else + ip4h.ip_off = htons(off); + ip4h.ip_ttl = ttl; +- ip4h.ip_proto = IPPROTO_ICMP; ++ ip4h.ip_proto = proto; + + ip4h.s_ip_src.s_addr = 0x01010101; /* 1.1.1.1 */ + ip4h.s_ip_dst.s_addr = 0x02020202; /* 2.2.2.2 */ +@@ -1059,7 +1059,7 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content, + goto error; + if (IPV4_GET_IPTTL(p) != ttl) + goto error; +- if (IPV4_GET_IPPROTO(p) != IPPROTO_ICMP) ++ if (IPV4_GET_IPPROTO(p) != proto) + goto error; + + return p; +@@ -1074,8 +1074,8 @@ void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt, + uint16_t prev_hdrextlen); + + static Packet * +-IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content, +- int content_len) ++IPV6BuildTestPacket(uint8_t proto, uint32_t id, uint16_t off, int mf, ++ const char content, int content_len) + { + Packet *p = NULL; + uint8_t *pcontent; +@@ -1109,7 +1109,7 @@ IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content, + IPV6_SET_RAW_VER(p->ip6h, 6); + /* Fragmentation header. */ + IPV6FragHdr *fh = (IPV6FragHdr *)(GET_PKT_DATA(p) + sizeof(IPV6Hdr)); +- fh->ip6fh_nxt = IPPROTO_ICMP; ++ fh->ip6fh_nxt = proto; + fh->ip6fh_ident = htonl(id); + fh->ip6fh_offlg = htons((off << 3) | mf); + +@@ -1159,13 +1159,13 @@ DefragInOrderSimpleTest(void) + + DefragInit(); + +- p1 = BuildTestPacket(id, 0, 1, 'A', 8); ++ p1 = BuildTestPacket(IPPROTO_ICMP, id, 0, 1, 'A', 8); + if (p1 == NULL) + goto end; +- p2 = BuildTestPacket(id, 1, 1, 'B', 8); ++ p2 = BuildTestPacket(IPPROTO_ICMP, id, 1, 1, 'B', 8); + if (p2 == NULL) + goto end; +- p3 = BuildTestPacket(id, 2, 0, 'C', 3); ++ p3 = BuildTestPacket(IPPROTO_ICMP, id, 2, 0, 'C', 3); + if (p3 == NULL) + goto end; + +@@ -1236,13 +1236,13 @@ DefragReverseSimpleTest(void) + + DefragInit(); + +- p1 = BuildTestPacket(id, 0, 1, 'A', 8); ++ p1 = BuildTestPacket(IPPROTO_ICMP, id, 0, 1, 'A', 8); + if (p1 == NULL) + goto end; +- p2 = BuildTestPacket(id, 1, 1, 'B', 8); ++ p2 = BuildTestPacket(IPPROTO_ICMP, id, 1, 1, 'B', 8); + if (p2 == NULL) + goto end; +- p3 = BuildTestPacket(id, 2, 0, 'C', 3); ++ p3 = BuildTestPacket(IPPROTO_ICMP, id, 2, 0, 'C', 3); + if (p3 == NULL) + goto end; + +@@ -1308,13 +1308,13 @@ IPV6DefragInOrderSimpleTest(void) + + DefragInit(); + +- p1 = IPV6BuildTestPacket(id, 0, 1, 'A', 8); ++ p1 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 0, 1, 'A', 8); + if (p1 == NULL) + goto end; +- p2 = IPV6BuildTestPacket(id, 1, 1, 'B', 8); ++ p2 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 1, 1, 'B', 8); + if (p2 == NULL) + goto end; +- p3 = IPV6BuildTestPacket(id, 2, 0, 'C', 3); ++ p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 2, 0, 'C', 3); + if (p3 == NULL) + goto end; + +@@ -1378,13 +1378,13 @@ IPV6DefragReverseSimpleTest(void) + if (dc == NULL) + goto end; + +- p1 = IPV6BuildTestPacket(id, 0, 1, 'A', 8); ++ p1 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 0, 1, 'A', 8); + if (p1 == NULL) + goto end; +- p2 = IPV6BuildTestPacket(id, 1, 1, 'B', 8); ++ p2 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 1, 1, 'B', 8); + if (p2 == NULL) + goto end; +- p3 = IPV6BuildTestPacket(id, 2, 0, 'C', 3); ++ p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 2, 0, 'C', 3); + if (p3 == NULL) + goto end; + +@@ -1452,59 +1452,59 @@ DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len) + */ + + /* A*24 at 0. */ +- packets[0] = BuildTestPacket(id, 0, 1, 'A', 24); ++ packets[0] = BuildTestPacket(IPPROTO_ICMP, id, 0, 1, 'A', 24); + + /* B*15 at 32. */ +- packets[1] = BuildTestPacket(id, 32 >> 3, 1, 'B', 16); ++ packets[1] = BuildTestPacket(IPPROTO_ICMP, id, 32 >> 3, 1, 'B', 16); + + /* C*24 at 48. */ +- packets[2] = BuildTestPacket(id, 48 >> 3, 1, 'C', 24); ++ packets[2] = BuildTestPacket(IPPROTO_ICMP, id, 48 >> 3, 1, 'C', 24); + + /* D*8 at 80. */ +- packets[3] = BuildTestPacket(id, 80 >> 3, 1, 'D', 8); ++ packets[3] = BuildTestPacket(IPPROTO_ICMP, id, 80 >> 3, 1, 'D', 8); + + /* E*16 at 104. */ +- packets[4] = BuildTestPacket(id, 104 >> 3, 1, 'E', 16); ++ packets[4] = BuildTestPacket(IPPROTO_ICMP, id, 104 >> 3, 1, 'E', 16); + + /* F*24 at 120. */ +- packets[5] = BuildTestPacket(id, 120 >> 3, 1, 'F', 24); ++ packets[5] = BuildTestPacket(IPPROTO_ICMP, id, 120 >> 3, 1, 'F', 24); + + /* G*16 at 144. */ +- packets[6] = BuildTestPacket(id, 144 >> 3, 1, 'G', 16); ++ packets[6] = BuildTestPacket(IPPROTO_ICMP, id, 144 >> 3, 1, 'G', 16); + + /* H*16 at 160. */ +- packets[7] = BuildTestPacket(id, 160 >> 3, 1, 'H', 16); ++ packets[7] = BuildTestPacket(IPPROTO_ICMP, id, 160 >> 3, 1, 'H', 16); + + /* I*8 at 176. */ +- packets[8] = BuildTestPacket(id, 176 >> 3, 1, 'I', 8); ++ packets[8] = BuildTestPacket(IPPROTO_ICMP, id, 176 >> 3, 1, 'I', 8); + + /* + * Overlapping subsequent fragments. + */ + + /* J*32 at 8. */ +- packets[9] = BuildTestPacket(id, 8 >> 3, 1, 'J', 32); ++ packets[9] = BuildTestPacket(IPPROTO_ICMP, id, 8 >> 3, 1, 'J', 32); + + /* K*24 at 48. */ +- packets[10] = BuildTestPacket(id, 48 >> 3, 1, 'K', 24); ++ packets[10] = BuildTestPacket(IPPROTO_ICMP, id, 48 >> 3, 1, 'K', 24); + + /* L*24 at 72. */ +- packets[11] = BuildTestPacket(id, 72 >> 3, 1, 'L', 24); ++ packets[11] = BuildTestPacket(IPPROTO_ICMP, id, 72 >> 3, 1, 'L', 24); + + /* M*24 at 96. */ +- packets[12] = BuildTestPacket(id, 96 >> 3, 1, 'M', 24); ++ packets[12] = BuildTestPacket(IPPROTO_ICMP, id, 96 >> 3, 1, 'M', 24); + + /* N*8 at 128. */ +- packets[13] = BuildTestPacket(id, 128 >> 3, 1, 'N', 8); ++ packets[13] = BuildTestPacket(IPPROTO_ICMP, id, 128 >> 3, 1, 'N', 8); + + /* O*8 at 152. */ +- packets[14] = BuildTestPacket(id, 152 >> 3, 1, 'O', 8); ++ packets[14] = BuildTestPacket(IPPROTO_ICMP, id, 152 >> 3, 1, 'O', 8); + + /* P*8 at 160. */ +- packets[15] = BuildTestPacket(id, 160 >> 3, 1, 'P', 8); ++ packets[15] = BuildTestPacket(IPPROTO_ICMP, id, 160 >> 3, 1, 'P', 8); + + /* Q*16 at 176. */ +- packets[16] = BuildTestPacket(id, 176 >> 3, 0, 'Q', 16); ++ packets[16] = BuildTestPacket(IPPROTO_ICMP, id, 176 >> 3, 0, 'Q', 16); + + default_policy = policy; + +@@ -1587,59 +1587,59 @@ IPV6DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len) + */ + + /* A*24 at 0. */ +- packets[0] = IPV6BuildTestPacket(id, 0, 1, 'A', 24); ++ packets[0] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 0, 1, 'A', 24); + + /* B*15 at 32. */ +- packets[1] = IPV6BuildTestPacket(id, 32 >> 3, 1, 'B', 16); ++ packets[1] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 32 >> 3, 1, 'B', 16); + + /* C*24 at 48. */ +- packets[2] = IPV6BuildTestPacket(id, 48 >> 3, 1, 'C', 24); ++ packets[2] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 48 >> 3, 1, 'C', 24); + + /* D*8 at 80. */ +- packets[3] = IPV6BuildTestPacket(id, 80 >> 3, 1, 'D', 8); ++ packets[3] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 80 >> 3, 1, 'D', 8); + + /* E*16 at 104. */ +- packets[4] = IPV6BuildTestPacket(id, 104 >> 3, 1, 'E', 16); ++ packets[4] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 104 >> 3, 1, 'E', 16); + + /* F*24 at 120. */ +- packets[5] = IPV6BuildTestPacket(id, 120 >> 3, 1, 'F', 24); ++ packets[5] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 120 >> 3, 1, 'F', 24); + + /* G*16 at 144. */ +- packets[6] = IPV6BuildTestPacket(id, 144 >> 3, 1, 'G', 16); ++ packets[6] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 144 >> 3, 1, 'G', 16); + + /* H*16 at 160. */ +- packets[7] = IPV6BuildTestPacket(id, 160 >> 3, 1, 'H', 16); ++ packets[7] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 160 >> 3, 1, 'H', 16); + + /* I*8 at 176. */ +- packets[8] = IPV6BuildTestPacket(id, 176 >> 3, 1, 'I', 8); ++ packets[8] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 176 >> 3, 1, 'I', 8); + + /* + * Overlapping subsequent fragments. + */ + + /* J*32 at 8. */ +- packets[9] = IPV6BuildTestPacket(id, 8 >> 3, 1, 'J', 32); ++ packets[9] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 8 >> 3, 1, 'J', 32); + + /* K*24 at 48. */ +- packets[10] = IPV6BuildTestPacket(id, 48 >> 3, 1, 'K', 24); ++ packets[10] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 48 >> 3, 1, 'K', 24); + + /* L*24 at 72. */ +- packets[11] = IPV6BuildTestPacket(id, 72 >> 3, 1, 'L', 24); ++ packets[11] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 72 >> 3, 1, 'L', 24); + + /* M*24 at 96. */ +- packets[12] = IPV6BuildTestPacket(id, 96 >> 3, 1, 'M', 24); ++ packets[12] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 96 >> 3, 1, 'M', 24); + + /* N*8 at 128. */ +- packets[13] = IPV6BuildTestPacket(id, 128 >> 3, 1, 'N', 8); ++ packets[13] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 128 >> 3, 1, 'N', 8); + + /* O*8 at 152. */ +- packets[14] = IPV6BuildTestPacket(id, 152 >> 3, 1, 'O', 8); ++ packets[14] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 152 >> 3, 1, 'O', 8); + + /* P*8 at 160. */ +- packets[15] = IPV6BuildTestPacket(id, 160 >> 3, 1, 'P', 8); ++ packets[15] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 160 >> 3, 1, 'P', 8); + + /* Q*16 at 176. */ +- packets[16] = IPV6BuildTestPacket(id, 176 >> 3, 0, 'Q', 16); ++ packets[16] = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 176 >> 3, 0, 'Q', 16); + + default_policy = policy; + +@@ -2125,7 +2125,7 @@ DefragTimeoutTest(void) + + /* Load in 16 packets. */ + for (i = 0; i < 16; i++) { +- Packet *p = BuildTestPacket(i, 0, 1, 'A' + i, 16); ++ Packet *p = BuildTestPacket(IPPROTO_ICMP,i, 0, 1, 'A' + i, 16); + if (p == NULL) + goto end; + +@@ -2141,7 +2141,7 @@ DefragTimeoutTest(void) + + /* Build a new packet but push the timestamp out by our timeout. + * This should force our previous fragments to be timed out. */ +- Packet *p = BuildTestPacket(99, 0, 1, 'A' + i, 16); ++ Packet *p = BuildTestPacket(IPPROTO_ICMP, 99, 0, 1, 'A' + i, 16); + if (p == NULL) + goto end; + +@@ -2189,7 +2189,7 @@ DefragIPv4NoDataTest(void) + goto end; + + /* This packet has an offset > 0, more frags set to 0 and no data. */ +- p = BuildTestPacket(id, 1, 0, 'A', 0); ++ p = BuildTestPacket(IPPROTO_ICMP, id, 1, 0, 'A', 0); + if (p == NULL) + goto end; + +@@ -2228,7 +2228,7 @@ DefragIPv4TooLargeTest(void) + + /* Create a fragment that would extend past the max allowable size + * for an IPv4 packet. */ +- p = BuildTestPacket(1, 8183, 0, 'A', 71); ++ p = BuildTestPacket(IPPROTO_ICMP, 1, 8183, 0, 'A', 71); + if (p == NULL) + goto end; + +@@ -2267,10 +2267,10 @@ DefragVlanTest(void) + + DefragInit(); + +- p1 = BuildTestPacket(1, 0, 1, 'A', 8); ++ p1 = BuildTestPacket(IPPROTO_ICMP, 1, 0, 1, 'A', 8); + if (p1 == NULL) + goto end; +- p2 = BuildTestPacket(1, 1, 0, 'B', 8); ++ p2 = BuildTestPacket(IPPROTO_ICMP, 1, 1, 0, 'B', 8); + if (p2 == NULL) + goto end; + +@@ -2313,10 +2313,10 @@ DefragVlanQinQTest(void) + + DefragInit(); + +- p1 = BuildTestPacket(1, 0, 1, 'A', 8); ++ p1 = BuildTestPacket(IPPROTO_ICMP, 1, 0, 1, 'A', 8); + if (p1 == NULL) + goto end; +- p2 = BuildTestPacket(1, 1, 0, 'B', 8); ++ p2 = BuildTestPacket(IPPROTO_ICMP, 1, 1, 0, 'B', 8); + if (p2 == NULL) + goto end; + +@@ -2361,7 +2361,7 @@ static int DefragTrackerReuseTest(void) + + /* Build a packet, its not a fragment but shouldn't matter for + * this test. */ +- p1 = BuildTestPacket(id, 0, 0, 'A', 8); ++ p1 = BuildTestPacket(IPPROTO_ICMP, id, 0, 0, 'A', 8); + if (p1 == NULL) { + goto end; + } +@@ -2431,9 +2431,9 @@ static int DefragMfIpv4Test(void) + + DefragInit(); + +- Packet *p1 = BuildTestPacket(ip_id, 2, 1, 'C', 8); +- Packet *p2 = BuildTestPacket(ip_id, 0, 1, 'A', 8); +- Packet *p3 = BuildTestPacket(ip_id, 1, 0, 'B', 8); ++ Packet *p1 = BuildTestPacket(IPPROTO_ICMP, ip_id, 2, 1, 'C', 8); ++ Packet *p2 = BuildTestPacket(IPPROTO_ICMP, ip_id, 0, 1, 'A', 8); ++ Packet *p3 = BuildTestPacket(IPPROTO_ICMP, ip_id, 1, 0, 'B', 8); + if (p1 == NULL || p2 == NULL || p3 == NULL) { + goto end; + } +@@ -2495,9 +2495,9 @@ static int DefragMfIpv6Test(void) + + DefragInit(); + +- Packet *p1 = IPV6BuildTestPacket(ip_id, 2, 1, 'C', 8); +- Packet *p2 = IPV6BuildTestPacket(ip_id, 0, 1, 'A', 8); +- Packet *p3 = IPV6BuildTestPacket(ip_id, 1, 0, 'B', 8); ++ Packet *p1 = IPV6BuildTestPacket(IPPROTO_ICMPV6, ip_id, 2, 1, 'C', 8); ++ Packet *p2 = IPV6BuildTestPacket(IPPROTO_ICMPV6, ip_id, 0, 1, 'A', 8); ++ Packet *p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, ip_id, 1, 0, 'B', 8); + if (p1 == NULL || p2 == NULL || p3 == NULL) { + goto end; + } +@@ -2542,6 +2542,39 @@ static int DefragMfIpv6Test(void) + return retval; + } + ++/** ++ * \brief Test that fragments that match other than the proto don't ++ * actually get matched. ++ */ ++static int DefragTestBadProto(void) ++{ ++ Packet *p1 = NULL, *p2 = NULL, *p3 = NULL; ++ int id = 12; ++ ++ DefragInit(); ++ ++ p1 = BuildTestPacket(IPPROTO_ICMP, id, 0, 1, 'A', 8); ++ FAIL_IF_NULL(p1); ++ p2 = BuildTestPacket(IPPROTO_UDP, id, 1, 1, 'B', 8); ++ FAIL_IF_NULL(p2); ++ p3 = BuildTestPacket(IPPROTO_ICMP, id, 2, 0, 'C', 3); ++ FAIL_IF_NULL(p3); ++ ++ FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p1, NULL)); ++ FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p2, NULL)); ++ FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p3, NULL)); ++ ++ if (p1 != NULL) ++ SCFree(p1); ++ if (p2 != NULL) ++ SCFree(p2); ++ if (p3 != NULL) ++ SCFree(p3); ++ ++ DefragDestroy(); ++ PASS; ++} ++ + #endif /* UNITTESTS */ + + void +@@ -2583,6 +2616,7 @@ DefragRegisterTests(void) + UtRegisterTest(""DefragTimeoutTest"", DefragTimeoutTest); + UtRegisterTest(""DefragMfIpv4Test"", DefragMfIpv4Test); + UtRegisterTest(""DefragMfIpv6Test"", DefragMfIpv6Test); ++ UtRegisterTest(""DefragTestBadProto"", DefragTestBadProto); + #endif /* UNITTESTS */ + } + ",1234,1470,2048 +18076,"static void gmc_mmx(uint8_t *dst, uint8_t *src, + int stride, int h, int ox, int oy, + int dxx, int dxy, int dyx, int dyy, + int shift, int r, int width, int height) +{ + const int w = 8; + const int ix = ox >> (16 + shift); + const int iy = oy >> (16 + shift); + const int oxs = ox >> 4; + const int oys = oy >> 4; + const int dxxs = dxx >> 4; + const int dxys = dxy >> 4; + const int dyxs = dyx >> 4; + const int dyys = dyy >> 4; + const uint16_t r4[4] = { r, r, r, r }; + const uint16_t dxy4[4] = { dxys, dxys, dxys, dxys }; + const uint16_t dyy4[4] = { dyys, dyys, dyys, dyys }; + const uint64_t shift2 = 2 * shift; +#define MAX_STRIDE 4096U +#define MAX_H 8U + uint8_t edge_buf[(MAX_H + 1) * MAX_STRIDE]; + int x, y; + + const int dxw = (dxx - (1 << (16 + shift))) * (w - 1); + const int dyh = (dyy - (1 << (16 + shift))) * (h - 1); + const int dxh = dxy * (h - 1); + const int dyw = dyx * (w - 1); + int need_emu = (unsigned) ix >= width - w || + (unsigned) iy >= height - h; + + if ( // non-constant fullpel offset (3% of blocks) + ((ox ^ (ox + dxw)) | (ox ^ (ox + dxh)) | (ox ^ (ox + dxw + dxh)) | + (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift) || + (dxx | dxy | dyx | dyy) & 15 || + (need_emu && (h > MAX_H || stride > MAX_STRIDE))) { + ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, + shift, r, width, height); + return; + } + + src += ix + iy * stride; + if (need_emu) { + ff_emulated_edge_mc_8(edge_buf, src, stride, stride, w + 1, h + 1, ix, iy, width, height); + src = edge_buf; + } + + __asm__ volatile ( + ""movd %0, %%mm6 \n\t"" + ""pxor %%mm7, %%mm7 \n\t"" + ""punpcklwd %%mm6, %%mm6 \n\t"" + ""punpcklwd %%mm6, %%mm6 \n\t"" + :: ""r"" (1 << shift)); + + for (x = 0; x < w; x += 4) { + uint16_t dx4[4] = { oxs - dxys + dxxs * (x + 0), + oxs - dxys + dxxs * (x + 1), + oxs - dxys + dxxs * (x + 2), + oxs - dxys + dxxs * (x + 3) }; + uint16_t dy4[4] = { oys - dyys + dyxs * (x + 0), + oys - dyys + dyxs * (x + 1), + oys - dyys + dyxs * (x + 2), + oys - dyys + dyxs * (x + 3) }; + + for (y = 0; y < h; y++) { + __asm__ volatile ( + ""movq %0, %%mm4 \n\t"" + ""movq %1, %%mm5 \n\t"" + ""paddw %2, %%mm4 \n\t"" + ""paddw %3, %%mm5 \n\t"" + ""movq %%mm4, %0 \n\t"" + ""movq %%mm5, %1 \n\t"" + ""psrlw $12, %%mm4 \n\t"" + ""psrlw $12, %%mm5 \n\t"" + : ""+m"" (*dx4), ""+m"" (*dy4) + : ""m"" (*dxy4), ""m"" (*dyy4)); + + __asm__ volatile ( + ""movq %%mm6, %%mm2 \n\t"" + ""movq %%mm6, %%mm1 \n\t"" + ""psubw %%mm4, %%mm2 \n\t"" + ""psubw %%mm5, %%mm1 \n\t"" + ""movq %%mm2, %%mm0 \n\t"" + ""movq %%mm4, %%mm3 \n\t"" + ""pmullw %%mm1, %%mm0 \n\t"" // (s - dx) * (s - dy) + ""pmullw %%mm5, %%mm3 \n\t"" // dx * dy + ""pmullw %%mm5, %%mm2 \n\t"" // (s - dx) * dy + ""pmullw %%mm4, %%mm1 \n\t"" // dx * (s - dy) + + ""movd %4, %%mm5 \n\t"" + ""movd %3, %%mm4 \n\t"" + ""punpcklbw %%mm7, %%mm5 \n\t"" + ""punpcklbw %%mm7, %%mm4 \n\t"" + ""pmullw %%mm5, %%mm3 \n\t"" // src[1, 1] * dx * dy + ""pmullw %%mm4, %%mm2 \n\t"" // src[0, 1] * (s - dx) * dy + + ""movd %2, %%mm5 \n\t"" + ""movd %1, %%mm4 \n\t"" + ""punpcklbw %%mm7, %%mm5 \n\t"" + ""punpcklbw %%mm7, %%mm4 \n\t"" + ""pmullw %%mm5, %%mm1 \n\t"" // src[1, 0] * dx * (s - dy) + ""pmullw %%mm4, %%mm0 \n\t"" // src[0, 0] * (s - dx) * (s - dy) + ""paddw %5, %%mm1 \n\t"" + ""paddw %%mm3, %%mm2 \n\t"" + ""paddw %%mm1, %%mm0 \n\t"" + ""paddw %%mm2, %%mm0 \n\t"" + + ""psrlw %6, %%mm0 \n\t"" + ""packuswb %%mm0, %%mm0 \n\t"" + ""movd %%mm0, %0 \n\t"" + + : ""=m"" (dst[x + y * stride]) + : ""m"" (src[0]), ""m"" (src[1]), + ""m"" (src[stride]), ""m"" (src[stride + 1]), + ""m"" (*r4), ""m"" (shift2)); + src += stride; + } + src += 4 - h * stride; + } +} +",1,"static void gmc_mmx(uint8_t *dst, uint8_t *src, + int stride, int h, int ox, int oy, + int dxx, int dxy, int dyx, int dyy, + int shift, int r, int width, int height) +{ + const int w = 8; + const int ix = ox >> (16 + shift); + const int iy = oy >> (16 + shift); + const int oxs = ox >> 4; + const int oys = oy >> 4; + const int dxxs = dxx >> 4; + const int dxys = dxy >> 4; + const int dyxs = dyx >> 4; + const int dyys = dyy >> 4; + const uint16_t r4[4] = { r, r, r, r }; + const uint16_t dxy4[4] = { dxys, dxys, dxys, dxys }; + const uint16_t dyy4[4] = { dyys, dyys, dyys, dyys }; + const uint64_t shift2 = 2 * shift; +#define MAX_STRIDE 4096U +#define MAX_H 8U + uint8_t edge_buf[(MAX_H + 1) * MAX_STRIDE]; + int x, y; + + const int dxw = (dxx - (1 << (16 + shift))) * (w - 1); + const int dyh = (dyy - (1 << (16 + shift))) * (h - 1); + const int dxh = dxy * (h - 1); + const int dyw = dyx * (w - 1); + int need_emu = (unsigned) ix >= width - w || width < w || + (unsigned) iy >= height - h || height< h + ; + + if ( // non-constant fullpel offset (3% of blocks) + ((ox ^ (ox + dxw)) | (ox ^ (ox + dxh)) | (ox ^ (ox + dxw + dxh)) | + (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift) || + (dxx | dxy | dyx | dyy) & 15 || + (need_emu && (h > MAX_H || stride > MAX_STRIDE))) { + ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, + shift, r, width, height); + return; + } + + src += ix + iy * stride; + if (need_emu) { + ff_emulated_edge_mc_8(edge_buf, src, stride, stride, w + 1, h + 1, ix, iy, width, height); + src = edge_buf; + } + + __asm__ volatile ( + ""movd %0, %%mm6 \n\t"" + ""pxor %%mm7, %%mm7 \n\t"" + ""punpcklwd %%mm6, %%mm6 \n\t"" + ""punpcklwd %%mm6, %%mm6 \n\t"" + :: ""r"" (1 << shift)); + + for (x = 0; x < w; x += 4) { + uint16_t dx4[4] = { oxs - dxys + dxxs * (x + 0), + oxs - dxys + dxxs * (x + 1), + oxs - dxys + dxxs * (x + 2), + oxs - dxys + dxxs * (x + 3) }; + uint16_t dy4[4] = { oys - dyys + dyxs * (x + 0), + oys - dyys + dyxs * (x + 1), + oys - dyys + dyxs * (x + 2), + oys - dyys + dyxs * (x + 3) }; + + for (y = 0; y < h; y++) { + __asm__ volatile ( + ""movq %0, %%mm4 \n\t"" + ""movq %1, %%mm5 \n\t"" + ""paddw %2, %%mm4 \n\t"" + ""paddw %3, %%mm5 \n\t"" + ""movq %%mm4, %0 \n\t"" + ""movq %%mm5, %1 \n\t"" + ""psrlw $12, %%mm4 \n\t"" + ""psrlw $12, %%mm5 \n\t"" + : ""+m"" (*dx4), ""+m"" (*dy4) + : ""m"" (*dxy4), ""m"" (*dyy4)); + + __asm__ volatile ( + ""movq %%mm6, %%mm2 \n\t"" + ""movq %%mm6, %%mm1 \n\t"" + ""psubw %%mm4, %%mm2 \n\t"" + ""psubw %%mm5, %%mm1 \n\t"" + ""movq %%mm2, %%mm0 \n\t"" + ""movq %%mm4, %%mm3 \n\t"" + ""pmullw %%mm1, %%mm0 \n\t"" // (s - dx) * (s - dy) + ""pmullw %%mm5, %%mm3 \n\t"" // dx * dy + ""pmullw %%mm5, %%mm2 \n\t"" // (s - dx) * dy + ""pmullw %%mm4, %%mm1 \n\t"" // dx * (s - dy) + + ""movd %4, %%mm5 \n\t"" + ""movd %3, %%mm4 \n\t"" + ""punpcklbw %%mm7, %%mm5 \n\t"" + ""punpcklbw %%mm7, %%mm4 \n\t"" + ""pmullw %%mm5, %%mm3 \n\t"" // src[1, 1] * dx * dy + ""pmullw %%mm4, %%mm2 \n\t"" // src[0, 1] * (s - dx) * dy + + ""movd %2, %%mm5 \n\t"" + ""movd %1, %%mm4 \n\t"" + ""punpcklbw %%mm7, %%mm5 \n\t"" + ""punpcklbw %%mm7, %%mm4 \n\t"" + ""pmullw %%mm5, %%mm1 \n\t"" // src[1, 0] * dx * (s - dy) + ""pmullw %%mm4, %%mm0 \n\t"" // src[0, 0] * (s - dx) * (s - dy) + ""paddw %5, %%mm1 \n\t"" + ""paddw %%mm3, %%mm2 \n\t"" + ""paddw %%mm1, %%mm0 \n\t"" + ""paddw %%mm2, %%mm0 \n\t"" + + ""psrlw %6, %%mm0 \n\t"" + ""packuswb %%mm0, %%mm0 \n\t"" + ""movd %%mm0, %0 \n\t"" + + : ""=m"" (dst[x + y * stride]) + : ""m"" (src[0]), ""m"" (src[1]), + ""m"" (src[stride]), ""m"" (src[stride + 1]), + ""m"" (*r4), ""m"" (shift2)); + src += stride; + } + src += 4 - h * stride; + } +} +","@@ -52,8 +52,9 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, + const int dyh = (dyy - (1 << (16 + shift))) * (h - 1); + const int dxh = dxy * (h - 1); + const int dyw = dyx * (w - 1); +- int need_emu = (unsigned) ix >= width - w || +- (unsigned) iy >= height - h; ++ int need_emu = (unsigned) ix >= width - w || width < w || ++ (unsigned) iy >= height - h || height< h ++ ; + + if ( // non-constant fullpel offset (3% of blocks) + ((ox ^ (ox + dxw)) | (ox ^ (ox + dxh)) | (ox ^ (ox + dxw + dxh)) |",1774,2010,2048 +1115,"static int usb_xhci_initfn(struct PCIDevice *dev) +{ + int i, ret; + + XHCIState *xhci = XHCI(dev); + + dev->config[PCI_CLASS_PROG] = 0x30; /* xHCI */ + dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */ + dev->config[PCI_CACHE_LINE_SIZE] = 0x10; + dev->config[0x60] = 0x30; /* release number */ + + usb_xhci_init(xhci); + + if (xhci->numintrs > MAXINTRS) { + xhci->numintrs = MAXINTRS; + } + while (xhci->numintrs & (xhci->numintrs - 1)) { /* ! power of 2 */ + xhci->numintrs++; + } + if (xhci->numintrs < 1) { + xhci->numintrs = 1; + } + if (xhci->numslots > MAXSLOTS) { + xhci->numslots = MAXSLOTS; + } + if (xhci->numslots < 1) { + xhci->numslots = 1; + } + + xhci->mfwrap_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_mfwrap_timer, xhci); + + memory_region_init(&xhci->mem, OBJECT(xhci), ""xhci"", LEN_REGS); + memory_region_init_io(&xhci->mem_cap, OBJECT(xhci), &xhci_cap_ops, xhci, + ""capabilities"", LEN_CAP); + memory_region_init_io(&xhci->mem_oper, OBJECT(xhci), &xhci_oper_ops, xhci, + ""operational"", 0x400); + memory_region_init_io(&xhci->mem_runtime, OBJECT(xhci), &xhci_runtime_ops, xhci, + ""runtime"", LEN_RUNTIME); + memory_region_init_io(&xhci->mem_doorbell, OBJECT(xhci), &xhci_doorbell_ops, xhci, + ""doorbell"", LEN_DOORBELL); + + memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap); + memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper); + memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime); + memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell); + + for (i = 0; i < xhci->numports; i++) { + XHCIPort *port = &xhci->ports[i]; + uint32_t offset = OFF_OPER + 0x400 + 0x10 * i; + port->xhci = xhci; + memory_region_init_io(&port->mem, OBJECT(xhci), &xhci_port_ops, port, + port->name, 0x10); + memory_region_add_subregion(&xhci->mem, offset, &port->mem); + } + + pci_register_bar(dev, 0, + PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64, + &xhci->mem); + + if (pci_bus_is_express(dev->bus)) { + ret = pcie_endpoint_cap_init(dev, 0xa0); + assert(ret >= 0); + } + + if (xhci_get_flag(xhci, XHCI_FLAG_USE_MSI)) { + msi_init(dev, 0x70, xhci->numintrs, true, false); + } + if (xhci_get_flag(xhci, XHCI_FLAG_USE_MSI_X)) { + msix_init(dev, xhci->numintrs, + &xhci->mem, 0, OFF_MSIX_TABLE, + &xhci->mem, 0, OFF_MSIX_PBA, + 0x90); + } + + return 0; +} +",0,"static int usb_xhci_initfn(struct PCIDevice *dev) +{ + int i, ret; + + XHCIState *xhci = XHCI(dev); + + dev->config[PCI_CLASS_PROG] = 0x30; /* xHCI */ + dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */ + dev->config[PCI_CACHE_LINE_SIZE] = 0x10; + dev->config[0x60] = 0x30; /* release number */ + + usb_xhci_init(xhci); + + if (xhci->numintrs > MAXINTRS) { + xhci->numintrs = MAXINTRS; + } + while (xhci->numintrs & (xhci->numintrs - 1)) { /* ! power of 2 */ + xhci->numintrs++; + } + if (xhci->numintrs < 1) { + xhci->numintrs = 1; + } + if (xhci->numslots > MAXSLOTS) { + xhci->numslots = MAXSLOTS; + } + if (xhci->numslots < 1) { + xhci->numslots = 1; + } + + xhci->mfwrap_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_mfwrap_timer, xhci); + + memory_region_init(&xhci->mem, OBJECT(xhci), ""xhci"", LEN_REGS); + memory_region_init_io(&xhci->mem_cap, OBJECT(xhci), &xhci_cap_ops, xhci, + ""capabilities"", LEN_CAP); + memory_region_init_io(&xhci->mem_oper, OBJECT(xhci), &xhci_oper_ops, xhci, + ""operational"", 0x400); + memory_region_init_io(&xhci->mem_runtime, OBJECT(xhci), &xhci_runtime_ops, xhci, + ""runtime"", LEN_RUNTIME); + memory_region_init_io(&xhci->mem_doorbell, OBJECT(xhci), &xhci_doorbell_ops, xhci, + ""doorbell"", LEN_DOORBELL); + + memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap); + memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper); + memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime); + memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell); + + for (i = 0; i < xhci->numports; i++) { + XHCIPort *port = &xhci->ports[i]; + uint32_t offset = OFF_OPER + 0x400 + 0x10 * i; + port->xhci = xhci; + memory_region_init_io(&port->mem, OBJECT(xhci), &xhci_port_ops, port, + port->name, 0x10); + memory_region_add_subregion(&xhci->mem, offset, &port->mem); + } + + pci_register_bar(dev, 0, + PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64, + &xhci->mem); + + if (pci_bus_is_express(dev->bus)) { + ret = pcie_endpoint_cap_init(dev, 0xa0); + assert(ret >= 0); + } + + if (xhci_get_flag(xhci, XHCI_FLAG_USE_MSI)) { + msi_init(dev, 0x70, xhci->numintrs, true, false); + } + if (xhci_get_flag(xhci, XHCI_FLAG_USE_MSI_X)) { + msix_init(dev, xhci->numintrs, + &xhci->mem, 0, OFF_MSIX_TABLE, + &xhci->mem, 0, OFF_MSIX_PBA, + 0x90); + } + + return 0; +} +","@@ -3737,6 +3737,7 @@ static const VMStateDescription vmstate_xhci_event = { + VMSTATE_UINT32(flags, XHCIEvent), + VMSTATE_UINT8(slotid, XHCIEvent), + VMSTATE_UINT8(epid, XHCIEvent), ++ VMSTATE_END_OF_LIST() + } + };",862,1098,2048 +1362,"c_pdf14trans_clist_write_update(const gs_composite_t * pcte, gx_device * dev, + gx_device ** pcdev, gs_gstate * pgs, gs_memory_t * mem) +{ + gx_device_clist_writer * const cdev = &((gx_device_clist *)dev)->writer; + const gs_pdf14trans_t * pdf14pct = (const gs_pdf14trans_t *) pcte; + int code = 0; + + /* We only handle the push/pop operations */ + switch (pdf14pct->params.pdf14_op) { + case PDF14_PUSH_DEVICE: + return gs_pdf14_clist_device_push(mem, pgs, pcdev, dev, pdf14pct); + + case PDF14_POP_DEVICE: +# if 0 /* Disabled because pdf14_clist_create_compositor does so. */ + /* + * Ensure that the tranfer functions, etc. are current before we + * dump our transparency image to the output device. + */ + if (pgs->dev_ht) + code = cmd_put_halftone((gx_device_clist_writer *) + (((pdf14_clist_device *)dev)->target), pgs->dev_ht); +# else + code = 0; +# endif + code = clist_writer_check_empty_cropping_stack(cdev); + break; + + case PDF14_BEGIN_TRANS_GROUP: + { /* HACK: store mask_id into our params for subsequent + calls of c_pdf14trans_write. To do this we must + break const. */ + gs_pdf14trans_t * pdf14pct_noconst; + + pdf14pct_noconst = (gs_pdf14trans_t *) pcte; + /* What ever the current mask ID is, that is the + softmask group through which this transparency + group must be rendered. Store it now. */ + pdf14pct_noconst->params.mask_id = cdev->mask_id; + if_debug1m('v', pgs->memory, + ""[v]c_pdf14trans_clist_write_update group mask_id=%d \n"", + cdev->mask_id); + } + break; + case PDF14_END_TRANS_GROUP: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_BEGIN_TRANS_MASK: + /* A new mask has been started */ + cdev->mask_id = ++cdev->mask_id_count; + /* replacing is set everytime that we + have a zpushtransparencymaskgroup */ + { /* HACK: store mask_id into our params for subsequent + calls of c_pdf14trans_write. To do this we must + break const. */ + gs_pdf14trans_t * pdf14pct_noconst; + + pdf14pct_noconst = (gs_pdf14trans_t *) pcte; + pdf14pct_noconst->params.mask_id = cdev->mask_id; + if_debug1m('v', pgs->memory, + ""[v]c_pdf14trans_clist_write_update mask mask_id=%d \n"", + cdev->mask_id); + } + break; + case PDF14_END_TRANS_MASK: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_PUSH_TRANS_STATE: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_POP_TRANS_STATE: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_ABORT_DEVICE: + code = 0; + break; + case PDF14_PUSH_SMASK_COLOR: + return 0; + break; + case PDF14_POP_SMASK_COLOR: + return 0; + break; + default: + break; /* do nothing for remaining ops */ + } + *pcdev = dev; + if (code < 0) + return code; + /* See c_pdf14trans_write, c_pdf14trans_adjust_ctm, and + apply_create_compositor. */ + code = gs_gstate_setmatrix(&cdev->gs_gstate, &pdf14pct->params.ctm); + /* Wrote an extra ctm. */ + cmd_clear_known(cdev, ctm_known); + + return code; +} +",0,"c_pdf14trans_clist_write_update(const gs_composite_t * pcte, gx_device * dev, + gx_device ** pcdev, gs_gstate * pgs, gs_memory_t * mem) +{ + gx_device_clist_writer * const cdev = &((gx_device_clist *)dev)->writer; + const gs_pdf14trans_t * pdf14pct = (const gs_pdf14trans_t *) pcte; + int code = 0; + + /* We only handle the push/pop operations */ + switch (pdf14pct->params.pdf14_op) { + case PDF14_PUSH_DEVICE: + return gs_pdf14_clist_device_push(mem, pgs, pcdev, dev, pdf14pct); + + case PDF14_POP_DEVICE: +# if 0 /* Disabled because pdf14_clist_create_compositor does so. */ + /* + * Ensure that the tranfer functions, etc. are current before we + * dump our transparency image to the output device. + */ + if (pgs->dev_ht) + code = cmd_put_halftone((gx_device_clist_writer *) + (((pdf14_clist_device *)dev)->target), pgs->dev_ht); +# else + code = 0; +# endif + code = clist_writer_check_empty_cropping_stack(cdev); + break; + + case PDF14_BEGIN_TRANS_GROUP: + { /* HACK: store mask_id into our params for subsequent + calls of c_pdf14trans_write. To do this we must + break const. */ + gs_pdf14trans_t * pdf14pct_noconst; + + pdf14pct_noconst = (gs_pdf14trans_t *) pcte; + /* What ever the current mask ID is, that is the + softmask group through which this transparency + group must be rendered. Store it now. */ + pdf14pct_noconst->params.mask_id = cdev->mask_id; + if_debug1m('v', pgs->memory, + ""[v]c_pdf14trans_clist_write_update group mask_id=%d \n"", + cdev->mask_id); + } + break; + case PDF14_END_TRANS_GROUP: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_BEGIN_TRANS_MASK: + /* A new mask has been started */ + cdev->mask_id = ++cdev->mask_id_count; + /* replacing is set everytime that we + have a zpushtransparencymaskgroup */ + { /* HACK: store mask_id into our params for subsequent + calls of c_pdf14trans_write. To do this we must + break const. */ + gs_pdf14trans_t * pdf14pct_noconst; + + pdf14pct_noconst = (gs_pdf14trans_t *) pcte; + pdf14pct_noconst->params.mask_id = cdev->mask_id; + if_debug1m('v', pgs->memory, + ""[v]c_pdf14trans_clist_write_update mask mask_id=%d \n"", + cdev->mask_id); + } + break; + case PDF14_END_TRANS_MASK: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_PUSH_TRANS_STATE: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_POP_TRANS_STATE: + code = 0; /* A place for breakpoint. */ + break; + case PDF14_ABORT_DEVICE: + code = 0; + break; + case PDF14_PUSH_SMASK_COLOR: + return 0; + break; + case PDF14_POP_SMASK_COLOR: + return 0; + break; + default: + break; /* do nothing for remaining ops */ + } + *pcdev = dev; + if (code < 0) + return code; + /* See c_pdf14trans_write, c_pdf14trans_adjust_ctm, and + apply_create_compositor. */ + code = gs_gstate_setmatrix(&cdev->gs_gstate, &pdf14pct->params.ctm); + /* Wrote an extra ctm. */ + cmd_clear_known(cdev, ctm_known); + + return code; +} +","@@ -1066,6 +1066,9 @@ pdf14_pop_transparency_group(gs_gstate *pgs, pdf14_ctx *ctx, + gx_color_index drawn_comps = pdev->drawn_comps; + bool nonicc_conversion = true; + ++ if (nos == NULL) ++ return_error(gs_error_unknownerror); /* Unmatched group pop */ ++ + nos_num_color_comp = nos->parent_color_info_procs->num_components - nos->num_spots; + tos_num_color_comp = tos_num_color_comp - tos->num_spots;",935,1171,2048 +18119,"int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct vmw_private *dev_priv = vmw_priv(dev); + struct vmw_user_surface *user_srf; + struct vmw_surface *srf; + struct vmw_resource *res; + struct vmw_resource *tmp; + union drm_vmw_gb_surface_create_arg *arg = + (union drm_vmw_gb_surface_create_arg *)data; + struct drm_vmw_gb_surface_create_req *req = &arg->req; + struct drm_vmw_gb_surface_create_rep *rep = &arg->rep; + struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; + int ret; + uint32_t size; + uint32_t backup_handle; + + if (req->multisample_count != 0) + return -EINVAL; + + if (req->mip_levels > DRM_VMW_MAX_MIP_LEVELS) + return -EINVAL; + + if (unlikely(vmw_user_surface_size == 0)) + vmw_user_surface_size = ttm_round_pot(sizeof(*user_srf)) + + 128; + + size = vmw_user_surface_size + 128; + + /* Define a surface based on the parameters. */ + ret = vmw_surface_gb_priv_define(dev, + size, + req->svga3d_flags, + req->format, + req->drm_surface_flags & drm_vmw_surface_flag_scanout, + req->mip_levels, + req->multisample_count, + req->array_size, + req->base_size, + &srf); + if (unlikely(ret != 0)) + return ret; + + user_srf = container_of(srf, struct vmw_user_surface, srf); + if (drm_is_primary_client(file_priv)) + user_srf->master = drm_master_get(file_priv->master); + + ret = ttm_read_lock(&dev_priv->reservation_sem, true); + if (unlikely(ret != 0)) + return ret; + + res = &user_srf->srf.res; + + + if (req->buffer_handle != SVGA3D_INVALID_ID) { + ret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle, + &res->backup, + &user_srf->backup_base); + if (ret == 0 && res->backup->base.num_pages * PAGE_SIZE < + res->backup_size) { + DRM_ERROR(""Surface backup buffer is too small.\n""); + vmw_dmabuf_unreference(&res->backup); + ret = -EINVAL; + goto out_unlock; + } + } else if (req->drm_surface_flags & drm_vmw_surface_flag_create_buffer) + ret = vmw_user_dmabuf_alloc(dev_priv, tfile, + res->backup_size, + req->drm_surface_flags & + drm_vmw_surface_flag_shareable, + &backup_handle, + &res->backup, + &user_srf->backup_base); + + if (unlikely(ret != 0)) { + vmw_resource_unreference(&res); + goto out_unlock; + } + + tmp = vmw_resource_reference(res); + ret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime, + req->drm_surface_flags & + drm_vmw_surface_flag_shareable, + VMW_RES_SURFACE, + &vmw_user_surface_base_release, NULL); + + if (unlikely(ret != 0)) { + vmw_resource_unreference(&tmp); + vmw_resource_unreference(&res); + goto out_unlock; + } + + rep->handle = user_srf->prime.base.hash.key; + rep->backup_size = res->backup_size; + if (res->backup) { + rep->buffer_map_handle = + drm_vma_node_offset_addr(&res->backup->base.vma_node); + rep->buffer_size = res->backup->base.num_pages * PAGE_SIZE; + rep->buffer_handle = backup_handle; + } else { + rep->buffer_map_handle = 0; + rep->buffer_size = 0; + rep->buffer_handle = SVGA3D_INVALID_ID; + } + + vmw_resource_unreference(&res); + +out_unlock: + ttm_read_unlock(&dev_priv->reservation_sem); + return ret; +} +",1,"int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct vmw_private *dev_priv = vmw_priv(dev); + struct vmw_user_surface *user_srf; + struct vmw_surface *srf; + struct vmw_resource *res; + struct vmw_resource *tmp; + union drm_vmw_gb_surface_create_arg *arg = + (union drm_vmw_gb_surface_create_arg *)data; + struct drm_vmw_gb_surface_create_req *req = &arg->req; + struct drm_vmw_gb_surface_create_rep *rep = &arg->rep; + struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; + int ret; + uint32_t size; + uint32_t backup_handle = 0; + + if (req->multisample_count != 0) + return -EINVAL; + + if (req->mip_levels > DRM_VMW_MAX_MIP_LEVELS) + return -EINVAL; + + if (unlikely(vmw_user_surface_size == 0)) + vmw_user_surface_size = ttm_round_pot(sizeof(*user_srf)) + + 128; + + size = vmw_user_surface_size + 128; + + /* Define a surface based on the parameters. */ + ret = vmw_surface_gb_priv_define(dev, + size, + req->svga3d_flags, + req->format, + req->drm_surface_flags & drm_vmw_surface_flag_scanout, + req->mip_levels, + req->multisample_count, + req->array_size, + req->base_size, + &srf); + if (unlikely(ret != 0)) + return ret; + + user_srf = container_of(srf, struct vmw_user_surface, srf); + if (drm_is_primary_client(file_priv)) + user_srf->master = drm_master_get(file_priv->master); + + ret = ttm_read_lock(&dev_priv->reservation_sem, true); + if (unlikely(ret != 0)) + return ret; + + res = &user_srf->srf.res; + + + if (req->buffer_handle != SVGA3D_INVALID_ID) { + ret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle, + &res->backup, + &user_srf->backup_base); + if (ret == 0) { + if (res->backup->base.num_pages * PAGE_SIZE < + res->backup_size) { + DRM_ERROR(""Surface backup buffer is too small.\n""); + vmw_dmabuf_unreference(&res->backup); + ret = -EINVAL; + goto out_unlock; + } else { + backup_handle = req->buffer_handle; + } + } + } else if (req->drm_surface_flags & drm_vmw_surface_flag_create_buffer) + ret = vmw_user_dmabuf_alloc(dev_priv, tfile, + res->backup_size, + req->drm_surface_flags & + drm_vmw_surface_flag_shareable, + &backup_handle, + &res->backup, + &user_srf->backup_base); + + if (unlikely(ret != 0)) { + vmw_resource_unreference(&res); + goto out_unlock; + } + + tmp = vmw_resource_reference(res); + ret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime, + req->drm_surface_flags & + drm_vmw_surface_flag_shareable, + VMW_RES_SURFACE, + &vmw_user_surface_base_release, NULL); + + if (unlikely(ret != 0)) { + vmw_resource_unreference(&tmp); + vmw_resource_unreference(&res); + goto out_unlock; + } + + rep->handle = user_srf->prime.base.hash.key; + rep->backup_size = res->backup_size; + if (res->backup) { + rep->buffer_map_handle = + drm_vma_node_offset_addr(&res->backup->base.vma_node); + rep->buffer_size = res->backup->base.num_pages * PAGE_SIZE; + rep->buffer_handle = backup_handle; + } else { + rep->buffer_map_handle = 0; + rep->buffer_size = 0; + rep->buffer_handle = SVGA3D_INVALID_ID; + } + + vmw_resource_unreference(&res); + +out_unlock: + ttm_read_unlock(&dev_priv->reservation_sem); + return ret; +} +","@@ -1274,7 +1274,7 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, + struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; + int ret; + uint32_t size; +- uint32_t backup_handle; ++ uint32_t backup_handle = 0; + + if (req->multisample_count != 0) + return -EINVAL; +@@ -1317,12 +1317,16 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, + ret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle, + &res->backup, + &user_srf->backup_base); +- if (ret == 0 && res->backup->base.num_pages * PAGE_SIZE < +- res->backup_size) { +- DRM_ERROR(""Surface backup buffer is too small.\n""); +- vmw_dmabuf_unreference(&res->backup); +- ret = -EINVAL; +- goto out_unlock; ++ if (ret == 0) { ++ if (res->backup->base.num_pages * PAGE_SIZE < ++ res->backup_size) { ++ DRM_ERROR(""Surface backup buffer is too small.\n""); ++ vmw_dmabuf_unreference(&res->backup); ++ ret = -EINVAL; ++ goto out_unlock; ++ } else { ++ backup_handle = req->buffer_handle; ++ } + } + } else if (req->drm_surface_flags & drm_vmw_surface_flag_create_buffer) + ret = vmw_user_dmabuf_alloc(dev_priv, tfile,",896,1132,2048 +17776,"static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree) +{ + int i; + + switch (tree->operation) { + case LDB_OP_AND: + case LDB_OP_OR: + asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1)); + for (i=0; iu.list.num_elements; i++) { + if (!ldap_push_filter(data, tree->u.list.elements[i])) { + return false; + } + } + asn1_pop_tag(data); + break; + + case LDB_OP_NOT: + asn1_push_tag(data, ASN1_CONTEXT(2)); + if (!ldap_push_filter(data, tree->u.isnot.child)) { + return false; + } + asn1_pop_tag(data); + break; + + case LDB_OP_EQUALITY: + /* equality test */ + asn1_push_tag(data, ASN1_CONTEXT(3)); + asn1_write_OctetString(data, tree->u.equality.attr, + strlen(tree->u.equality.attr)); + asn1_write_OctetString(data, tree->u.equality.value.data, + tree->u.equality.value.length); + asn1_pop_tag(data); + break; + + case LDB_OP_SUBSTRING: + /* + SubstringFilter ::= SEQUENCE { + type AttributeDescription, + -- at least one must be present + substrings SEQUENCE OF CHOICE { + initial [0] LDAPString, + any [1] LDAPString, + final [2] LDAPString } } + */ + asn1_push_tag(data, ASN1_CONTEXT(4)); + asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr)); + asn1_push_tag(data, ASN1_SEQUENCE(0)); + + if (tree->u.substring.chunks && tree->u.substring.chunks[0]) { + i = 0; + if (!tree->u.substring.start_with_wildcard) { + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); + asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); + asn1_pop_tag(data); + i++; + } + while (tree->u.substring.chunks[i]) { + int ctx; + + if (( ! tree->u.substring.chunks[i + 1]) && + (tree->u.substring.end_with_wildcard == 0)) { + ctx = 2; + } else { + ctx = 1; + } + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx)); + asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); + asn1_pop_tag(data); + i++; + } + } + asn1_pop_tag(data); + asn1_pop_tag(data); + break; + + case LDB_OP_GREATER: + /* greaterOrEqual test */ + asn1_push_tag(data, ASN1_CONTEXT(5)); + asn1_write_OctetString(data, tree->u.comparison.attr, + strlen(tree->u.comparison.attr)); + asn1_write_OctetString(data, tree->u.comparison.value.data, + tree->u.comparison.value.length); + asn1_pop_tag(data); + break; + + case LDB_OP_LESS: + /* lessOrEqual test */ + asn1_push_tag(data, ASN1_CONTEXT(6)); + asn1_write_OctetString(data, tree->u.comparison.attr, + strlen(tree->u.comparison.attr)); + asn1_write_OctetString(data, tree->u.comparison.value.data, + tree->u.comparison.value.length); + asn1_pop_tag(data); + break; + + case LDB_OP_PRESENT: + /* present test */ + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(7)); + asn1_write_LDAPString(data, tree->u.present.attr); + asn1_pop_tag(data); + return !data->has_error; + + case LDB_OP_APPROX: + /* approx test */ + asn1_push_tag(data, ASN1_CONTEXT(8)); + asn1_write_OctetString(data, tree->u.comparison.attr, + strlen(tree->u.comparison.attr)); + asn1_write_OctetString(data, tree->u.comparison.value.data, + tree->u.comparison.value.length); + asn1_pop_tag(data); + break; + + case LDB_OP_EXTENDED: + /* + MatchingRuleAssertion ::= SEQUENCE { + matchingRule [1] MatchingRuleID OPTIONAL, + type [2] AttributeDescription OPTIONAL, + matchValue [3] AssertionValue, + dnAttributes [4] BOOLEAN DEFAULT FALSE + } + */ + asn1_push_tag(data, ASN1_CONTEXT(9)); + if (tree->u.extended.rule_id) { + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1)); + asn1_write_LDAPString(data, tree->u.extended.rule_id); + asn1_pop_tag(data); + } + if (tree->u.extended.attr) { + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(2)); + asn1_write_LDAPString(data, tree->u.extended.attr); + asn1_pop_tag(data); + } + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3)); + asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value); + asn1_pop_tag(data); + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4)); + asn1_write_uint8(data, tree->u.extended.dnAttributes); + asn1_pop_tag(data); + asn1_pop_tag(data); + break; + + default: + return false; + } + return !data->has_error; + } +",1,"static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree) +{ + int i; + + switch (tree->operation) { + case LDB_OP_AND: + case LDB_OP_OR: + if (!asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1))) return false; + for (i=0; iu.list.num_elements; i++) { + if (!ldap_push_filter(data, tree->u.list.elements[i])) { + return false; + } + } + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_NOT: + if (!asn1_push_tag(data, ASN1_CONTEXT(2))) return false; + if (!ldap_push_filter(data, tree->u.isnot.child)) { + return false; + } + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_EQUALITY: + /* equality test */ + if (!asn1_push_tag(data, ASN1_CONTEXT(3))) return false; + if (!asn1_write_OctetString(data, tree->u.equality.attr, + strlen(tree->u.equality.attr))) return false; + if (!asn1_write_OctetString(data, tree->u.equality.value.data, + tree->u.equality.value.length)) return false; + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_SUBSTRING: + /* + SubstringFilter ::= SEQUENCE { + type AttributeDescription, + -- at least one must be present + substrings SEQUENCE OF CHOICE { + initial [0] LDAPString, + any [1] LDAPString, + final [2] LDAPString } } + */ + if (!asn1_push_tag(data, ASN1_CONTEXT(4))) return false; + if (!asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr))) return false; + if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) return false; + + if (tree->u.substring.chunks && tree->u.substring.chunks[0]) { + i = 0; + if (!tree->u.substring.start_with_wildcard) { + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) return false; + if (!asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i])) return false; + if (!asn1_pop_tag(data)) return false; + i++; + } + while (tree->u.substring.chunks[i]) { + int ctx; + + if (( ! tree->u.substring.chunks[i + 1]) && + (tree->u.substring.end_with_wildcard == 0)) { + ctx = 2; + } else { + ctx = 1; + } + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx))) return false; + if (!asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i])) return false; + if (!asn1_pop_tag(data)) return false; + i++; + } + } + if (!asn1_pop_tag(data)) return false; + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_GREATER: + /* greaterOrEqual test */ + if (!asn1_push_tag(data, ASN1_CONTEXT(5))) return false; + if (!asn1_write_OctetString(data, tree->u.comparison.attr, + strlen(tree->u.comparison.attr))) return false; + if (!asn1_write_OctetString(data, tree->u.comparison.value.data, + tree->u.comparison.value.length)) return false; + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_LESS: + /* lessOrEqual test */ + if (!asn1_push_tag(data, ASN1_CONTEXT(6))) return false; + if (!asn1_write_OctetString(data, tree->u.comparison.attr, + strlen(tree->u.comparison.attr))) return false; + if (!asn1_write_OctetString(data, tree->u.comparison.value.data, + tree->u.comparison.value.length)) return false; + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_PRESENT: + /* present test */ + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(7))) return false; + if (!asn1_write_LDAPString(data, tree->u.present.attr)) return false; + if (!asn1_pop_tag(data)) return false; + return !data->has_error; + + case LDB_OP_APPROX: + /* approx test */ + if (!asn1_push_tag(data, ASN1_CONTEXT(8))) return false; + if (!asn1_write_OctetString(data, tree->u.comparison.attr, + strlen(tree->u.comparison.attr))) return false; + if (!asn1_write_OctetString(data, tree->u.comparison.value.data, + tree->u.comparison.value.length)) return false; + if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_EXTENDED: + /* + MatchingRuleAssertion ::= SEQUENCE { + matchingRule [1] MatchingRuleID OPTIONAL, + type [2] AttributeDescription OPTIONAL, + matchValue [3] AssertionValue, + dnAttributes [4] BOOLEAN DEFAULT FALSE + } + */ + if (!asn1_push_tag(data, ASN1_CONTEXT(9))) return false; + if (tree->u.extended.rule_id) { + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1))) return false; + if (!asn1_write_LDAPString(data, tree->u.extended.rule_id)) return false; + if (!asn1_pop_tag(data)) return false; + } + if (tree->u.extended.attr) { + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(2))) return false; + if (!asn1_write_LDAPString(data, tree->u.extended.attr)) return false; + if (!asn1_pop_tag(data)) return false; + } + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3))) return false; + if (!asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value)) return false; + if (!asn1_pop_tag(data)) return false; + if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4))) return false; + if (!asn1_write_uint8(data, tree->u.extended.dnAttributes)) return false; + if (!asn1_pop_tag(data)) return false; + if (!asn1_pop_tag(data)) return false; + break; + + default: + return false; + } + return !data->has_error; + } +","@@ -229,31 +229,31 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree + switch (tree->operation) { + case LDB_OP_AND: + case LDB_OP_OR: +- asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1)); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(tree->operation==LDB_OP_AND?0:1))) return false; + for (i=0; iu.list.num_elements; i++) { + if (!ldap_push_filter(data, tree->u.list.elements[i])) { + return false; + } + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_NOT: +- asn1_push_tag(data, ASN1_CONTEXT(2)); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(2))) return false; + if (!ldap_push_filter(data, tree->u.isnot.child)) { + return false; + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_EQUALITY: + /* equality test */ +- asn1_push_tag(data, ASN1_CONTEXT(3)); +- asn1_write_OctetString(data, tree->u.equality.attr, +- strlen(tree->u.equality.attr)); +- asn1_write_OctetString(data, tree->u.equality.value.data, +- tree->u.equality.value.length); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(3))) return false; ++ if (!asn1_write_OctetString(data, tree->u.equality.attr, ++ strlen(tree->u.equality.attr))) return false; ++ if (!asn1_write_OctetString(data, tree->u.equality.value.data, ++ tree->u.equality.value.length)) return false; ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_SUBSTRING: +@@ -266,16 +266,16 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree + any [1] LDAPString, + final [2] LDAPString } } + */ +- asn1_push_tag(data, ASN1_CONTEXT(4)); +- asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr)); +- asn1_push_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(4))) return false; ++ if (!asn1_write_OctetString(data, tree->u.substring.attr, strlen(tree->u.substring.attr))) return false; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) return false; + + if (tree->u.substring.chunks && tree->u.substring.chunks[0]) { + i = 0; + if (!tree->u.substring.start_with_wildcard) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); +- asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) return false; ++ if (!asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i])) return false; ++ if (!asn1_pop_tag(data)) return false; + i++; + } + while (tree->u.substring.chunks[i]) { +@@ -287,51 +287,51 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree + } else { + ctx = 1; + } +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx)); +- asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i]); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx))) return false; ++ if (!asn1_write_DATA_BLOB_LDAPString(data, tree->u.substring.chunks[i])) return false; ++ if (!asn1_pop_tag(data)) return false; + i++; + } + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) return false; ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_GREATER: + /* greaterOrEqual test */ +- asn1_push_tag(data, ASN1_CONTEXT(5)); +- asn1_write_OctetString(data, tree->u.comparison.attr, +- strlen(tree->u.comparison.attr)); +- asn1_write_OctetString(data, tree->u.comparison.value.data, +- tree->u.comparison.value.length); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(5))) return false; ++ if (!asn1_write_OctetString(data, tree->u.comparison.attr, ++ strlen(tree->u.comparison.attr))) return false; ++ if (!asn1_write_OctetString(data, tree->u.comparison.value.data, ++ tree->u.comparison.value.length)) return false; ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_LESS: + /* lessOrEqual test */ +- asn1_push_tag(data, ASN1_CONTEXT(6)); +- asn1_write_OctetString(data, tree->u.comparison.attr, +- strlen(tree->u.comparison.attr)); +- asn1_write_OctetString(data, tree->u.comparison.value.data, +- tree->u.comparison.value.length); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(6))) return false; ++ if (!asn1_write_OctetString(data, tree->u.comparison.attr, ++ strlen(tree->u.comparison.attr))) return false; ++ if (!asn1_write_OctetString(data, tree->u.comparison.value.data, ++ tree->u.comparison.value.length)) return false; ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_PRESENT: + /* present test */ +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(7)); +- asn1_write_LDAPString(data, tree->u.present.attr); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(7))) return false; ++ if (!asn1_write_LDAPString(data, tree->u.present.attr)) return false; ++ if (!asn1_pop_tag(data)) return false; + return !data->has_error; + + case LDB_OP_APPROX: + /* approx test */ +- asn1_push_tag(data, ASN1_CONTEXT(8)); +- asn1_write_OctetString(data, tree->u.comparison.attr, +- strlen(tree->u.comparison.attr)); +- asn1_write_OctetString(data, tree->u.comparison.value.data, +- tree->u.comparison.value.length); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(8))) return false; ++ if (!asn1_write_OctetString(data, tree->u.comparison.attr, ++ strlen(tree->u.comparison.attr))) return false; ++ if (!asn1_write_OctetString(data, tree->u.comparison.value.data, ++ tree->u.comparison.value.length)) return false; ++ if (!asn1_pop_tag(data)) return false; + break; + + case LDB_OP_EXTENDED: +@@ -343,24 +343,24 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree + dnAttributes [4] BOOLEAN DEFAULT FALSE + } + */ +- asn1_push_tag(data, ASN1_CONTEXT(9)); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(9))) return false; + if (tree->u.extended.rule_id) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1)); +- asn1_write_LDAPString(data, tree->u.extended.rule_id); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1))) return false; ++ if (!asn1_write_LDAPString(data, tree->u.extended.rule_id)) return false; ++ if (!asn1_pop_tag(data)) return false; + } + if (tree->u.extended.attr) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(2)); +- asn1_write_LDAPString(data, tree->u.extended.attr); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(2))) return false; ++ if (!asn1_write_LDAPString(data, tree->u.extended.attr)) return false; ++ if (!asn1_pop_tag(data)) return false; + } +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3)); +- asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value); +- asn1_pop_tag(data); +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4)); +- asn1_write_uint8(data, tree->u.extended.dnAttributes); +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3))) return false; ++ if (!asn1_write_DATA_BLOB_LDAPString(data, &tree->u.extended.value)) return false; ++ if (!asn1_pop_tag(data)) return false; ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4))) return false; ++ if (!asn1_write_uint8(data, tree->u.extended.dnAttributes)) return false; ++ if (!asn1_pop_tag(data)) return false; ++ if (!asn1_pop_tag(data)) return false; + break; + + default: +@@ -369,20 +369,21 @@ static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree + return !data->has_error; + } + +-static void ldap_encode_response(struct asn1_data *data, struct ldap_Result *result) ++static bool ldap_encode_response(struct asn1_data *data, struct ldap_Result *result) + { +- asn1_write_enumerated(data, result->resultcode); +- asn1_write_OctetString(data, result->dn, +- (result->dn) ? strlen(result->dn) : 0); +- asn1_write_OctetString(data, result->errormessage, ++ if (!asn1_write_enumerated(data, result->resultcode)) return false; ++ if (!asn1_write_OctetString(data, result->dn, ++ (result->dn) ? strlen(result->dn) : 0)) return false; ++ if (!asn1_write_OctetString(data, result->errormessage, + (result->errormessage) ? +- strlen(result->errormessage) : 0); ++ strlen(result->errormessage) : 0)) return false; + if (result->referral) { +- asn1_push_tag(data, ASN1_CONTEXT(3)); +- asn1_write_OctetString(data, result->referral, +- strlen(result->referral)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(3))) return false; ++ if (!asn1_write_OctetString(data, result->referral, ++ strlen(result->referral))) return false; ++ if (!asn1_pop_tag(data)) return false; + } ++ return true; + } + + _PUBLIC_ bool ldap_encode(struct ldap_message *msg, +@@ -394,286 +395,286 @@ _PUBLIC_ bool ldap_encode(struct ldap_message *msg, + + if (!data) return false; + +- asn1_push_tag(data, ASN1_SEQUENCE(0)); +- asn1_write_Integer(data, msg->messageid); ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; ++ if (!asn1_write_Integer(data, msg->messageid)) goto err; + + switch (msg->type) { + case LDAP_TAG_BindRequest: { + struct ldap_BindRequest *r = &msg->r.BindRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_Integer(data, r->version); +- asn1_write_OctetString(data, r->dn, +- (r->dn != NULL) ? strlen(r->dn) : 0); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_Integer(data, r->version)) goto err; ++ if (!asn1_write_OctetString(data, r->dn, ++ (r->dn != NULL) ? strlen(r->dn) : 0)) goto err; + + switch (r->mechanism) { + case LDAP_AUTH_MECH_SIMPLE: + /* context, primitive */ +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); +- asn1_write(data, r->creds.password, +- strlen(r->creds.password)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto err; ++ if (!asn1_write(data, r->creds.password, ++ strlen(r->creds.password))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + case LDAP_AUTH_MECH_SASL: + /* context, constructed */ +- asn1_push_tag(data, ASN1_CONTEXT(3)); +- asn1_write_OctetString(data, r->creds.SASL.mechanism, +- strlen(r->creds.SASL.mechanism)); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(3))) goto err; ++ if (!asn1_write_OctetString(data, r->creds.SASL.mechanism, ++ strlen(r->creds.SASL.mechanism))) goto err; + if (r->creds.SASL.secblob) { +- asn1_write_OctetString(data, r->creds.SASL.secblob->data, +- r->creds.SASL.secblob->length); ++ if (!asn1_write_OctetString(data, r->creds.SASL.secblob->data, ++ r->creds.SASL.secblob->length)) goto err; + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + break; + default: +- return false; ++ goto err; + } + +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_BindResponse: { + struct ldap_BindResponse *r = &msg->r.BindResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, &r->response); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, &r->response)) goto err; + if (r->SASL.secblob) { +- asn1_write_ContextSimple(data, 7, r->SASL.secblob); ++ if (!asn1_write_ContextSimple(data, 7, r->SASL.secblob)) goto err; + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_UnbindRequest: { + /* struct ldap_UnbindRequest *r = &msg->r.UnbindRequest; */ +- asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_SearchRequest: { + struct ldap_SearchRequest *r = &msg->r.SearchRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->basedn, strlen(r->basedn)); +- asn1_write_enumerated(data, r->scope); +- asn1_write_enumerated(data, r->deref); +- asn1_write_Integer(data, r->sizelimit); +- asn1_write_Integer(data, r->timelimit); +- asn1_write_BOOLEAN(data, r->attributesonly); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->basedn, strlen(r->basedn))) goto err; ++ if (!asn1_write_enumerated(data, r->scope)) goto err; ++ if (!asn1_write_enumerated(data, r->deref)) goto err; ++ if (!asn1_write_Integer(data, r->sizelimit)) goto err; ++ if (!asn1_write_Integer(data, r->timelimit)) goto err; ++ if (!asn1_write_BOOLEAN(data, r->attributesonly)) goto err; + + if (!ldap_push_filter(data, r->tree)) { +- return false; ++ goto err; + } + +- asn1_push_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; + for (i=0; inum_attributes; i++) { +- asn1_write_OctetString(data, r->attributes[i], +- strlen(r->attributes[i])); ++ if (!asn1_write_OctetString(data, r->attributes[i], ++ strlen(r->attributes[i]))) goto err; + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_SearchResultEntry: { + struct ldap_SearchResEntry *r = &msg->r.SearchResultEntry; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->dn, strlen(r->dn)); +- asn1_push_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; + for (i=0; inum_attributes; i++) { + struct ldb_message_element *attr = &r->attributes[i]; +- asn1_push_tag(data, ASN1_SEQUENCE(0)); +- asn1_write_OctetString(data, attr->name, +- strlen(attr->name)); +- asn1_push_tag(data, ASN1_SEQUENCE(1)); ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; ++ if (!asn1_write_OctetString(data, attr->name, ++ strlen(attr->name))) goto err; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(1))) goto err; + for (j=0; jnum_values; j++) { +- asn1_write_OctetString(data, ++ if (!asn1_write_OctetString(data, + attr->values[j].data, +- attr->values[j].length); ++ attr->values[j].length)) goto err; + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_SearchResultDone: { + struct ldap_Result *r = &msg->r.SearchResultDone; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, r); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, r)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_ModifyRequest: { + struct ldap_ModifyRequest *r = &msg->r.ModifyRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->dn, strlen(r->dn)); +- asn1_push_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; + + for (i=0; inum_mods; i++) { + struct ldb_message_element *attrib = &r->mods[i].attrib; +- asn1_push_tag(data, ASN1_SEQUENCE(0)); +- asn1_write_enumerated(data, r->mods[i].type); +- asn1_push_tag(data, ASN1_SEQUENCE(0)); +- asn1_write_OctetString(data, attrib->name, +- strlen(attrib->name)); +- asn1_push_tag(data, ASN1_SET); ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; ++ if (!asn1_write_enumerated(data, r->mods[i].type)) goto err; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; ++ if (!asn1_write_OctetString(data, attrib->name, ++ strlen(attrib->name))) goto err; ++ if (!asn1_push_tag(data, ASN1_SET)) goto err; + for (j=0; jnum_values; j++) { +- asn1_write_OctetString(data, ++ if (!asn1_write_OctetString(data, + attrib->values[j].data, +- attrib->values[j].length); ++ attrib->values[j].length)) goto err; + + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } + +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_ModifyResponse: { + struct ldap_Result *r = &msg->r.ModifyResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, r); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, r)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_AddRequest: { + struct ldap_AddRequest *r = &msg->r.AddRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->dn, strlen(r->dn)); +- asn1_push_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; + + for (i=0; inum_attributes; i++) { + struct ldb_message_element *attrib = &r->attributes[i]; +- asn1_push_tag(data, ASN1_SEQUENCE(0)); +- asn1_write_OctetString(data, attrib->name, +- strlen(attrib->name)); +- asn1_push_tag(data, ASN1_SET); ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; ++ if (!asn1_write_OctetString(data, attrib->name, ++ strlen(attrib->name))) goto err; ++ if (!asn1_push_tag(data, ASN1_SET)) goto err; + for (j=0; jattributes[i].num_values; j++) { +- asn1_write_OctetString(data, ++ if (!asn1_write_OctetString(data, + attrib->values[j].data, +- attrib->values[j].length); ++ attrib->values[j].length)) goto err; + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_AddResponse: { + struct ldap_Result *r = &msg->r.AddResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, r); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, r)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_DelRequest: { + struct ldap_DelRequest *r = &msg->r.DelRequest; +- asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type)); +- asn1_write(data, r->dn, strlen(r->dn)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type))) goto err; ++ if (!asn1_write(data, r->dn, strlen(r->dn))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_DelResponse: { + struct ldap_Result *r = &msg->r.DelResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, r); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, r)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_ModifyDNRequest: { + struct ldap_ModifyDNRequest *r = &msg->r.ModifyDNRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->dn, strlen(r->dn)); +- asn1_write_OctetString(data, r->newrdn, strlen(r->newrdn)); +- asn1_write_BOOLEAN(data, r->deleteolddn); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err; ++ if (!asn1_write_OctetString(data, r->newrdn, strlen(r->newrdn))) goto err; ++ if (!asn1_write_BOOLEAN(data, r->deleteolddn)) goto err; + if (r->newsuperior) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); +- asn1_write(data, r->newsuperior, +- strlen(r->newsuperior)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto err; ++ if (!asn1_write(data, r->newsuperior, ++ strlen(r->newsuperior))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_ModifyDNResponse: { + struct ldap_Result *r = &msg->r.ModifyDNResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, r); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, r)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_CompareRequest: { + struct ldap_CompareRequest *r = &msg->r.CompareRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->dn, strlen(r->dn)); +- asn1_push_tag(data, ASN1_SEQUENCE(0)); +- asn1_write_OctetString(data, r->attribute, +- strlen(r->attribute)); +- asn1_write_OctetString(data, r->value.data, +- r->value.length); +- asn1_pop_tag(data); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->dn, strlen(r->dn))) goto err; ++ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) goto err; ++ if (!asn1_write_OctetString(data, r->attribute, ++ strlen(r->attribute))) goto err; ++ if (!asn1_write_OctetString(data, r->value.data, ++ r->value.length)) goto err; ++ if (!asn1_pop_tag(data)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_CompareResponse: { + struct ldap_Result *r = &msg->r.ModifyDNResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, r); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, r)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_AbandonRequest: { + struct ldap_AbandonRequest *r = &msg->r.AbandonRequest; +- asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type)); +- asn1_write_implicit_Integer(data, r->messageid); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type))) goto err; ++ if (!asn1_write_implicit_Integer(data, r->messageid)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_SearchResultReference: { + struct ldap_SearchResRef *r = &msg->r.SearchResultReference; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_write_OctetString(data, r->referral, strlen(r->referral)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_write_OctetString(data, r->referral, strlen(r->referral))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_ExtendedRequest: { + struct ldap_ExtendedRequest *r = &msg->r.ExtendedRequest; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0)); +- asn1_write(data, r->oid, strlen(r->oid)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto err; ++ if (!asn1_write(data, r->oid, strlen(r->oid))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + if (r->value) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1)); +- asn1_write(data, r->value->data, r->value->length); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1))) goto err; ++ if (!asn1_write(data, r->value->data, r->value->length)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + break; + } + case LDAP_TAG_ExtendedResponse: { + struct ldap_ExtendedResponse *r = &msg->r.ExtendedResponse; +- asn1_push_tag(data, ASN1_APPLICATION(msg->type)); +- ldap_encode_response(data, &r->response); ++ if (!asn1_push_tag(data, ASN1_APPLICATION(msg->type))) goto err; ++ if (!ldap_encode_response(data, &r->response)) goto err; + if (r->oid) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(10)); +- asn1_write(data, r->oid, strlen(r->oid)); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(10))) goto err; ++ if (!asn1_write(data, r->oid, strlen(r->oid))) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } + if (r->value) { +- asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(11)); +- asn1_write(data, r->value->data, r->value->length); +- asn1_pop_tag(data); ++ if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(11))) goto err; ++ if (!asn1_write(data, r->value->data, r->value->length)) goto err; ++ if (!asn1_pop_tag(data)) goto err; + } +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + break; + } + default: +- return false; ++ goto err; + } + + if (msg->controls != NULL) { +- asn1_push_tag(data, ASN1_CONTEXT(0)); ++ if (!asn1_push_tag(data, ASN1_CONTEXT(0))) goto err; + + for (i = 0; msg->controls[i] != NULL; i++) { + if (!ldap_encode_control(mem_ctx, data, +@@ -681,23 +682,24 @@ _PUBLIC_ bool ldap_encode(struct ldap_message *msg, + msg->controls[i])) { + DEBUG(0,(""Unable to encode control %s\n"", + msg->controls[i]->oid)); +- return false; ++ goto err; + } + } + +- asn1_pop_tag(data); ++ if (!asn1_pop_tag(data)) goto err; + } + +- asn1_pop_tag(data); +- +- if (data->has_error) { +- asn1_free(data); +- return false; +- } ++ if (!asn1_pop_tag(data)) goto err; + + *result = data_blob_talloc(mem_ctx, data->data, data->length); + asn1_free(data); ++ + return true; ++ ++ err: ++ ++ asn1_free(data); ++ return false; + } + + static const char *blob2string_talloc(TALLOC_CTX *mem_ctx, +@@ -721,20 +723,21 @@ bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx, + return true; + } + +-static void ldap_decode_response(TALLOC_CTX *mem_ctx, ++static bool ldap_decode_response(TALLOC_CTX *mem_ctx, + struct asn1_data *data, + struct ldap_Result *result) + { +- asn1_read_enumerated(data, &result->resultcode); +- asn1_read_OctetString_talloc(mem_ctx, data, &result->dn); +- asn1_read_OctetString_talloc(mem_ctx, data, &result->errormessage); ++ if (!asn1_read_enumerated(data, &result->resultcode)) return false; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &result->dn)) return false; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &result->errormessage)) return false; + if (asn1_peek_tag(data, ASN1_CONTEXT(3))) { +- asn1_start_tag(data, ASN1_CONTEXT(3)); +- asn1_read_OctetString_talloc(mem_ctx, data, &result->referral); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(3))) return false; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &result->referral)) return false; ++ if (!asn1_end_tag(data)) return false; + } else { + result->referral = NULL; + } ++ return true; + } + + static struct ldb_val **ldap_decode_substring(TALLOC_CTX *mem_ctx, struct ldb_val **chunks, int chunk_num, char *value) +@@ -835,10 +838,10 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + const char *attrib; + DATA_BLOB value; + +- asn1_start_tag(data, ASN1_CONTEXT(filter_tag)); +- asn1_read_OctetString_talloc(mem_ctx, data, &attrib); +- asn1_read_OctetString(data, mem_ctx, &value); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed; ++ if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) { + goto failed; + } +@@ -874,13 +877,13 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + } + + while (asn1_tag_remaining(data)) { +- asn1_peek_uint8(data, &subs_tag); ++ if (!asn1_peek_uint8(data, &subs_tag)) goto failed; + subs_tag &= 0x1f; /* strip off the asn1 stuff */ + if (subs_tag > 2) goto failed; + +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(subs_tag)); +- asn1_read_LDAPString(data, mem_ctx, &value); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(subs_tag))) goto failed; ++ if (!asn1_read_LDAPString(data, mem_ctx, &value)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + + switch (subs_tag) { + case 0: +@@ -947,10 +950,10 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + const char *attrib; + DATA_BLOB value; + +- asn1_start_tag(data, ASN1_CONTEXT(filter_tag)); +- asn1_read_OctetString_talloc(mem_ctx, data, &attrib); +- asn1_read_OctetString(data, mem_ctx, &value); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed; ++ if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) { + goto failed; + } +@@ -966,10 +969,10 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + const char *attrib; + DATA_BLOB value; + +- asn1_start_tag(data, ASN1_CONTEXT(filter_tag)); +- asn1_read_OctetString_talloc(mem_ctx, data, &attrib); +- asn1_read_OctetString(data, mem_ctx, &value); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed; ++ if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) { + goto failed; + } +@@ -1004,10 +1007,10 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + const char *attrib; + DATA_BLOB value; + +- asn1_start_tag(data, ASN1_CONTEXT(filter_tag)); +- asn1_read_OctetString_talloc(mem_ctx, data, &attrib); +- asn1_read_OctetString(data, mem_ctx, &value); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(filter_tag))) goto failed; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib)) goto failed; ++ if (!asn1_read_OctetString(data, mem_ctx, &value)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + if ((data->has_error) || (attrib == NULL) || (value.data == NULL)) { + goto failed; + } +@@ -1030,18 +1033,18 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + we need to check we properly implement --SSS */ + /* either oid or type must be defined */ + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(1))) { /* optional */ +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(1)); +- asn1_read_LDAPString(data, ret, &oid); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(1))) goto failed; ++ if (!asn1_read_LDAPString(data, ret, &oid)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + } + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(2))) { /* optional */ +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(2)); +- asn1_read_LDAPString(data, ret, &attr); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(2))) goto failed; ++ if (!asn1_read_LDAPString(data, ret, &attr)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + } +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(3)); +- asn1_read_LDAPString(data, ret, &value); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(3))) goto failed; ++ if (!asn1_read_LDAPString(data, ret, &value)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + /* dnAttributes is marked as BOOLEAN DEFAULT FALSE + it is not marked as OPTIONAL but openldap tools + do not set this unless it is to be set as TRUE +@@ -1049,9 +1052,9 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx, + seems that AD always requires the dnAttributes + boolean value to be set */ + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(4))) { +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(4)); +- asn1_read_uint8(data, &dnAttributes); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(4))) goto failed; ++ if (!asn1_read_uint8(data, &dnAttributes)) goto failed; ++ if (!asn1_end_tag(data)) goto failed; + } else { + dnAttributes = 0; + } +@@ -1099,45 +1102,45 @@ failed: + } + + /* Decode a single LDAP attribute, possibly containing multiple values */ +-static void ldap_decode_attrib(TALLOC_CTX *mem_ctx, struct asn1_data *data, ++static bool ldap_decode_attrib(TALLOC_CTX *mem_ctx, struct asn1_data *data, + struct ldb_message_element *attrib) + { +- asn1_start_tag(data, ASN1_SEQUENCE(0)); +- asn1_read_OctetString_talloc(mem_ctx, data, &attrib->name); +- asn1_start_tag(data, ASN1_SET); ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) return false; ++ if (!asn1_read_OctetString_talloc(mem_ctx, data, &attrib->name)) return false; ++ if (!asn1_start_tag(data, ASN1_SET)) return false; + while (asn1_peek_tag(data, ASN1_OCTET_STRING)) { + DATA_BLOB blob; +- asn1_read_OctetString(data, mem_ctx, &blob); ++ if (!asn1_read_OctetString(data, mem_ctx, &blob)) return false; + add_value_to_attrib(mem_ctx, &blob, attrib); + } +- asn1_end_tag(data); +- asn1_end_tag(data); +- ++ if (!asn1_end_tag(data)) return false; ++ return asn1_end_tag(data); + } + + /* Decode a set of LDAP attributes, as found in the dereference control */ +-void ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data, ++bool ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data, + struct ldb_message_element **attributes, + int *num_attributes) + { + while (asn1_peek_tag(data, ASN1_SEQUENCE(0))) { + struct ldb_message_element attrib; + ZERO_STRUCT(attrib); +- ldap_decode_attrib(mem_ctx, data, &attrib); ++ if (!ldap_decode_attrib(mem_ctx, data, &attrib)) return false; + add_attrib_to_array_talloc(mem_ctx, &attrib, + attributes, num_attributes); + } ++ return true; + } + + /* Decode a set of LDAP attributes, as found in a search entry */ +-static void ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data, ++static bool ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data, + struct ldb_message_element **attributes, + int *num_attributes) + { +- asn1_start_tag(data, ASN1_SEQUENCE(0)); +- ldap_decode_attribs_bare(mem_ctx, data, +- attributes, num_attributes); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) return false; ++ if (!ldap_decode_attribs_bare(mem_ctx, data, ++ attributes, num_attributes)) return false; ++ return asn1_end_tag(data); + } + + /* This routine returns LDAP status codes */ +@@ -1148,46 +1151,45 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + { + uint8_t tag; + +- asn1_start_tag(data, ASN1_SEQUENCE(0)); +- asn1_read_Integer(data, &msg->messageid); ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err; ++ if (!asn1_read_Integer(data, &msg->messageid)) goto prot_err; + +- if (!asn1_peek_uint8(data, &tag)) +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ if (!asn1_peek_uint8(data, &tag)) goto prot_err; + + switch(tag) { + + case ASN1_APPLICATION(LDAP_TAG_BindRequest): { + struct ldap_BindRequest *r = &msg->r.BindRequest; + msg->type = LDAP_TAG_BindRequest; +- asn1_start_tag(data, tag); +- asn1_read_Integer(data, &r->version); +- asn1_read_OctetString_talloc(msg, data, &r->dn); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_read_Integer(data, &r->version)) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err; + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(0))) { + int pwlen; + r->creds.password = """"; + r->mechanism = LDAP_AUTH_MECH_SIMPLE; +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0)); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto prot_err; + pwlen = asn1_tag_remaining(data); + if (pwlen == -1) { +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } + if (pwlen != 0) { + char *pw = talloc_array(msg, char, pwlen+1); + if (!pw) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); + } +- asn1_read(data, pw, pwlen); ++ if (!asn1_read(data, pw, pwlen)) goto prot_err; + pw[pwlen] = '\0'; + r->creds.password = pw; + } +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + } else if (asn1_peek_tag(data, ASN1_CONTEXT(3))){ +- asn1_start_tag(data, ASN1_CONTEXT(3)); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(3))) goto prot_err; + r->mechanism = LDAP_AUTH_MECH_SASL; +- asn1_read_OctetString_talloc(msg, data, &r->creds.SASL.mechanism); ++ if (!asn1_read_OctetString_talloc(msg, data, &r->creds.SASL.mechanism)) goto prot_err; + if (asn1_peek_tag(data, ASN1_OCTET_STRING)) { /* optional */ + DATA_BLOB tmp_blob = data_blob(NULL, 0); +- asn1_read_OctetString(data, msg, &tmp_blob); ++ if (!asn1_read_OctetString(data, msg, &tmp_blob)) goto prot_err; + r->creds.SASL.secblob = talloc(msg, DATA_BLOB); + if (!r->creds.SASL.secblob) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); +@@ -1198,23 +1200,23 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + } else { + r->creds.SASL.secblob = NULL; + } +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + } else { + /* Neither Simple nor SASL bind */ +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_BindResponse): { + struct ldap_BindResponse *r = &msg->r.BindResponse; + msg->type = LDAP_TAG_BindResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, &r->response); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, &r->response)) goto prot_err; + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(7))) { + DATA_BLOB tmp_blob = data_blob(NULL, 0); +- asn1_read_ContextSimple(data, 7, &tmp_blob); ++ if (!asn1_read_ContextSimple(data, 7, &tmp_blob)) goto prot_err; + r->SASL.secblob = talloc(msg, DATA_BLOB); + if (!r->SASL.secblob) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); +@@ -1225,14 +1227,14 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + } else { + r->SASL.secblob = NULL; + } +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION_SIMPLE(LDAP_TAG_UnbindRequest): { + msg->type = LDAP_TAG_UnbindRequest; +- asn1_start_tag(data, tag); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + +@@ -1241,41 +1243,41 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + int sizelimit, timelimit; + const char **attrs = NULL; + msg->type = LDAP_TAG_SearchRequest; +- asn1_start_tag(data, tag); +- asn1_read_OctetString_talloc(msg, data, &r->basedn); +- asn1_read_enumerated(data, (int *)(void *)&(r->scope)); +- asn1_read_enumerated(data, (int *)(void *)&(r->deref)); +- asn1_read_Integer(data, &sizelimit); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->basedn)) goto prot_err; ++ if (!asn1_read_enumerated(data, (int *)(void *)&(r->scope))) goto prot_err; ++ if (!asn1_read_enumerated(data, (int *)(void *)&(r->deref))) goto prot_err; ++ if (!asn1_read_Integer(data, &sizelimit)) goto prot_err; + r->sizelimit = sizelimit; +- asn1_read_Integer(data, &timelimit); ++ if (!asn1_read_Integer(data, &timelimit)) goto prot_err; + r->timelimit = timelimit; +- asn1_read_BOOLEAN(data, &r->attributesonly); ++ if (!asn1_read_BOOLEAN(data, &r->attributesonly)) goto prot_err; + + r->tree = ldap_decode_filter_tree(msg, data); + if (r->tree == NULL) { +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } + +- asn1_start_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err; + + r->num_attributes = 0; + r->attributes = NULL; + +- while (asn1_tag_remaining(data) > 0) { ++ while (asn1_tag_remaining(data) > 0) { + + const char *attr; + if (!asn1_read_OctetString_talloc(msg, data, + &attr)) +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + if (!add_string_to_array(msg, attr, + &attrs, + &r->num_attributes)) +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } + r->attributes = attrs; + +- asn1_end_tag(data); +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + +@@ -1284,38 +1286,38 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + msg->type = LDAP_TAG_SearchResultEntry; + r->attributes = NULL; + r->num_attributes = 0; +- asn1_start_tag(data, tag); +- asn1_read_OctetString_talloc(msg, data, &r->dn); +- ldap_decode_attribs(msg, data, &r->attributes, +- &r->num_attributes); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err; ++ if (!ldap_decode_attribs(msg, data, &r->attributes, ++ &r->num_attributes)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_SearchResultDone): { + struct ldap_Result *r = &msg->r.SearchResultDone; + msg->type = LDAP_TAG_SearchResultDone; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, r); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, r)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_SearchResultReference): { + struct ldap_SearchResRef *r = &msg->r.SearchResultReference; + msg->type = LDAP_TAG_SearchResultReference; +- asn1_start_tag(data, tag); +- asn1_read_OctetString_talloc(msg, data, &r->referral); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->referral)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_ModifyRequest): { + struct ldap_ModifyRequest *r = &msg->r.ModifyRequest; + msg->type = LDAP_TAG_ModifyRequest; +- asn1_start_tag(data, ASN1_APPLICATION(LDAP_TAG_ModifyRequest)); +- asn1_read_OctetString_talloc(msg, data, &r->dn); +- asn1_start_tag(data, ASN1_SEQUENCE(0)); ++ if (!asn1_start_tag(data, ASN1_APPLICATION(LDAP_TAG_ModifyRequest))) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err; ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err; + + r->num_mods = 0; + r->mods = NULL; +@@ -1324,52 +1326,52 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + struct ldap_mod mod; + int v; + ZERO_STRUCT(mod); +- asn1_start_tag(data, ASN1_SEQUENCE(0)); +- asn1_read_enumerated(data, &v); ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err; ++ if (!asn1_read_enumerated(data, &v)) goto prot_err; + mod.type = v; +- ldap_decode_attrib(msg, data, &mod.attrib); +- asn1_end_tag(data); ++ if (!ldap_decode_attrib(msg, data, &mod.attrib)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + if (!add_mod_to_array_talloc(msg, &mod, + &r->mods, &r->num_mods)) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); + } + } + +- asn1_end_tag(data); +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_ModifyResponse): { + struct ldap_Result *r = &msg->r.ModifyResponse; + msg->type = LDAP_TAG_ModifyResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, r); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, r)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_AddRequest): { + struct ldap_AddRequest *r = &msg->r.AddRequest; + msg->type = LDAP_TAG_AddRequest; +- asn1_start_tag(data, tag); +- asn1_read_OctetString_talloc(msg, data, &r->dn); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err; + + r->attributes = NULL; + r->num_attributes = 0; +- ldap_decode_attribs(msg, data, &r->attributes, +- &r->num_attributes); ++ if (!ldap_decode_attribs(msg, data, &r->attributes, ++ &r->num_attributes)) goto prot_err; + +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_AddResponse): { + struct ldap_Result *r = &msg->r.AddResponse; + msg->type = LDAP_TAG_AddResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, r); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, r)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + +@@ -1378,102 +1380,102 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + int len; + char *dn; + msg->type = LDAP_TAG_DelRequest; +- asn1_start_tag(data, +- ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest)); ++ if (!asn1_start_tag(data, ++ ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest))) goto prot_err; + len = asn1_tag_remaining(data); + if (len == -1) { +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } + dn = talloc_array(msg, char, len+1); + if (dn == NULL) + break; +- asn1_read(data, dn, len); ++ if (!asn1_read(data, dn, len)) goto prot_err; + dn[len] = '\0'; + r->dn = dn; +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_DelResponse): { + struct ldap_Result *r = &msg->r.DelResponse; + msg->type = LDAP_TAG_DelResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, r); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, r)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_ModifyDNRequest): { + struct ldap_ModifyDNRequest *r = &msg->r.ModifyDNRequest; + msg->type = LDAP_TAG_ModifyDNRequest; +- asn1_start_tag(data, +- ASN1_APPLICATION(LDAP_TAG_ModifyDNRequest)); +- asn1_read_OctetString_talloc(msg, data, &r->dn); +- asn1_read_OctetString_talloc(msg, data, &r->newrdn); +- asn1_read_BOOLEAN(data, &r->deleteolddn); ++ if (!asn1_start_tag(data, ++ ASN1_APPLICATION(LDAP_TAG_ModifyDNRequest))) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->newrdn)) goto prot_err; ++ if (!asn1_read_BOOLEAN(data, &r->deleteolddn)) goto prot_err; + r->newsuperior = NULL; + if (asn1_tag_remaining(data) > 0) { + int len; + char *newsup; +- asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0)); ++ if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(0))) goto prot_err; + len = asn1_tag_remaining(data); + if (len == -1) { +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } + newsup = talloc_array(msg, char, len+1); + if (newsup == NULL) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); + } +- asn1_read(data, newsup, len); ++ if (!asn1_read(data, newsup, len)) goto prot_err; + newsup[len] = '\0'; + r->newsuperior = newsup; +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + } +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_ModifyDNResponse): { + struct ldap_Result *r = &msg->r.ModifyDNResponse; + msg->type = LDAP_TAG_ModifyDNResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, r); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, r)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_CompareRequest): { + struct ldap_CompareRequest *r = &msg->r.CompareRequest; + msg->type = LDAP_TAG_CompareRequest; +- asn1_start_tag(data, +- ASN1_APPLICATION(LDAP_TAG_CompareRequest)); +- asn1_read_OctetString_talloc(msg, data, &r->dn); +- asn1_start_tag(data, ASN1_SEQUENCE(0)); +- asn1_read_OctetString_talloc(msg, data, &r->attribute); +- asn1_read_OctetString(data, msg, &r->value); ++ if (!asn1_start_tag(data, ++ ASN1_APPLICATION(LDAP_TAG_CompareRequest))) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->dn)) goto prot_err; ++ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) goto prot_err; ++ if (!asn1_read_OctetString_talloc(msg, data, &r->attribute)) goto prot_err; ++ if (!asn1_read_OctetString(data, msg, &r->value)) goto prot_err; + if (r->value.data) { + talloc_steal(msg, r->value.data); + } +- asn1_end_tag(data); +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION(LDAP_TAG_CompareResponse): { + struct ldap_Result *r = &msg->r.CompareResponse; + msg->type = LDAP_TAG_CompareResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, r); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, r)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + + case ASN1_APPLICATION_SIMPLE(LDAP_TAG_AbandonRequest): { + struct ldap_AbandonRequest *r = &msg->r.AbandonRequest; + msg->type = LDAP_TAG_AbandonRequest; +- asn1_start_tag(data, tag); +- asn1_read_implicit_Integer(data, &r->messageid); +- asn1_end_tag(data); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!asn1_read_implicit_Integer(data, &r->messageid)) goto prot_err; ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + +@@ -1482,9 +1484,9 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + DATA_BLOB tmp_blob = data_blob(NULL, 0); + + msg->type = LDAP_TAG_ExtendedRequest; +- asn1_start_tag(data,tag); ++ if (!asn1_start_tag(data,tag)) goto prot_err; + if (!asn1_read_ContextSimple(data, 0, &tmp_blob)) { +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } + r->oid = blob2string_talloc(msg, tmp_blob); + data_blob_free(&tmp_blob); +@@ -1493,7 +1495,7 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + } + + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(1))) { +- asn1_read_ContextSimple(data, 1, &tmp_blob); ++ if (!asn1_read_ContextSimple(data, 1, &tmp_blob)) goto prot_err; + r->value = talloc(msg, DATA_BLOB); + if (!r->value) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); +@@ -1504,7 +1506,7 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + r->value = NULL; + } + +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } + +@@ -1513,11 +1515,11 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + DATA_BLOB tmp_blob = data_blob(NULL, 0); + + msg->type = LDAP_TAG_ExtendedResponse; +- asn1_start_tag(data, tag); +- ldap_decode_response(msg, data, &r->response); ++ if (!asn1_start_tag(data, tag)) goto prot_err; ++ if (!ldap_decode_response(msg, data, &r->response)) goto prot_err; + + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(10))) { +- asn1_read_ContextSimple(data, 1, &tmp_blob); ++ if (!asn1_read_ContextSimple(data, 1, &tmp_blob)) goto prot_err; + r->oid = blob2string_talloc(msg, tmp_blob); + data_blob_free(&tmp_blob); + if (!r->oid) { +@@ -1528,7 +1530,7 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + } + + if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(11))) { +- asn1_read_ContextSimple(data, 1, &tmp_blob); ++ if (!asn1_read_ContextSimple(data, 1, &tmp_blob)) goto prot_err; + r->value = talloc(msg, DATA_BLOB); + if (!r->value) { + return NT_STATUS_LDAP(LDAP_OPERATIONS_ERROR); +@@ -1539,11 +1541,11 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + r->value = NULL; + } + +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + break; + } +- default: +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ default: ++ goto prot_err; + } + + msg->controls = NULL; +@@ -1554,7 +1556,7 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + struct ldb_control **ctrl = NULL; + bool *decoded = NULL; + +- asn1_start_tag(data, ASN1_CONTEXT(0)); ++ if (!asn1_start_tag(data, ASN1_CONTEXT(0))) goto prot_err; + + while (asn1_peek_tag(data, ASN1_SEQUENCE(0))) { + DATA_BLOB value; +@@ -1576,9 +1578,9 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + } + + if (!ldap_decode_control_wrapper(ctrl[i], data, ctrl[i], &value)) { +- return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); ++ goto prot_err; + } +- ++ + if (!ldap_decode_control_value(ctrl[i], value, + control_handlers, + ctrl[i])) { +@@ -1603,14 +1605,18 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, + msg->controls = ctrl; + msg->controls_decoded = decoded; + +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + } + +- asn1_end_tag(data); ++ if (!asn1_end_tag(data)) goto prot_err; + if ((data->has_error) || (data->nesting != NULL)) { + return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); + } + return NT_STATUS_OK; ++ ++ prot_err: ++ ++ return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR); + }",1223,1459,2048 +6927,"int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold) +{ + /* + * If extend == 0, obtain new n-byte packet; if extend == 1, increase + * packet by another n bytes. The packet will be in the sub-array of + * s->s3->rbuf.buf specified by s->packet and s->packet_length. (If + * s->rlayer.read_ahead is set, 'max' bytes may be stored in rbuf [plus + * s->packet_length bytes if extend == 1].) + * if clearold == 1, move the packet to the start of the buffer; if + * clearold == 0 then leave any old packets where they were + */ + int i, len, left; + size_t align = 0; + unsigned char *pkt; + SSL3_BUFFER *rb; + + if (n <= 0) + return n; + + rb = &s->rlayer.rbuf; + if (rb->buf == NULL) + if (!ssl3_setup_read_buffer(s)) + return -1; + + left = rb->left; +#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 + align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH; + align = SSL3_ALIGN_PAYLOAD - 1 - ((align - 1) % SSL3_ALIGN_PAYLOAD); +#endif + + if (!extend) { + /* start with empty packet ... */ + if (left == 0) + rb->offset = align; + else if (align != 0 && left >= SSL3_RT_HEADER_LENGTH) { + /* + * check if next packet length is large enough to justify payload + * alignment... + */ + pkt = rb->buf + rb->offset; + if (pkt[0] == SSL3_RT_APPLICATION_DATA + && (pkt[3] << 8 | pkt[4]) >= 128) { + /* + * Note that even if packet is corrupted and its length field + * is insane, we can only be led to wrong decision about + * whether memmove will occur or not. Header values has no + * effect on memmove arguments and therefore no buffer + * overrun can be triggered. + */ + memmove(rb->buf + align, pkt, left); + rb->offset = align; + } + } + s->rlayer.packet = rb->buf + rb->offset; + s->rlayer.packet_length = 0; + /* ... now we can act as if 'extend' was set */ + } + + len = s->rlayer.packet_length; + pkt = rb->buf + align; + /* + * Move any available bytes to front of buffer: 'len' bytes already + * pointed to by 'packet', 'left' extra ones at the end + */ + if (s->rlayer.packet != pkt && clearold == 1) { + memmove(pkt, s->rlayer.packet, len + left); + s->rlayer.packet = pkt; + rb->offset = len + align; + } + + /* + * For DTLS/UDP reads should not span multiple packets because the read + * operation returns the whole packet at once (as long as it fits into + * the buffer). + */ + if (SSL_IS_DTLS(s)) { + if (left == 0 && extend) + return 0; + if (left > 0 && n > left) + n = left; + } + + /* if there is enough in the buffer from a previous read, take some */ + if (left >= n) { + s->rlayer.packet_length += n; + rb->left = left - n; + rb->offset += n; + return (n); + } + + /* else we need to read more data */ + + if (n > (int)(rb->len - rb->offset)) { /* does not happen */ + SSLerr(SSL_F_SSL3_READ_N, ERR_R_INTERNAL_ERROR); + return -1; + } + + /* We always act like read_ahead is set for DTLS */ + if (!s->rlayer.read_ahead && !SSL_IS_DTLS(s)) + /* ignore max parameter */ + max = n; + else { + if (max < n) + max = n; + if (max > (int)(rb->len - rb->offset)) + max = rb->len - rb->offset; + } + + while (left < n) { + /* + * Now we have len+left bytes at the front of s->s3->rbuf.buf and + * need to read in more until we have len+n (up to len+max if + * possible) + */ + + clear_sys_error(); + if (s->rbio != NULL) { + s->rwstate = SSL_READING; + i = BIO_read(s->rbio, pkt + len + left, max - left); + } else { + SSLerr(SSL_F_SSL3_READ_N, SSL_R_READ_BIO_NOT_SET); + i = -1; + } + + if (i <= 0) { + rb->left = left; + if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_IS_DTLS(s)) + if (len + left == 0) + ssl3_release_read_buffer(s); + return i; + } + left += i; + /* + * reads should *never* span multiple packets for DTLS because the + * underlying transport protocol is message oriented as opposed to + * byte oriented as in the TLS case. + */ + if (SSL_IS_DTLS(s)) { + if (n > left) + n = left; /* makes the while condition false */ + } + } + + /* done reading, now the book-keeping */ + rb->offset += n; + rb->left = left - n; + s->rlayer.packet_length += n; + s->rwstate = SSL_NOTHING; + return (n); +} +",0,"int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold) +{ + /* + * If extend == 0, obtain new n-byte packet; if extend == 1, increase + * packet by another n bytes. The packet will be in the sub-array of + * s->s3->rbuf.buf specified by s->packet and s->packet_length. (If + * s->rlayer.read_ahead is set, 'max' bytes may be stored in rbuf [plus + * s->packet_length bytes if extend == 1].) + * if clearold == 1, move the packet to the start of the buffer; if + * clearold == 0 then leave any old packets where they were + */ + int i, len, left; + size_t align = 0; + unsigned char *pkt; + SSL3_BUFFER *rb; + + if (n <= 0) + return n; + + rb = &s->rlayer.rbuf; + if (rb->buf == NULL) + if (!ssl3_setup_read_buffer(s)) + return -1; + + left = rb->left; +#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 + align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH; + align = SSL3_ALIGN_PAYLOAD - 1 - ((align - 1) % SSL3_ALIGN_PAYLOAD); +#endif + + if (!extend) { + /* start with empty packet ... */ + if (left == 0) + rb->offset = align; + else if (align != 0 && left >= SSL3_RT_HEADER_LENGTH) { + /* + * check if next packet length is large enough to justify payload + * alignment... + */ + pkt = rb->buf + rb->offset; + if (pkt[0] == SSL3_RT_APPLICATION_DATA + && (pkt[3] << 8 | pkt[4]) >= 128) { + /* + * Note that even if packet is corrupted and its length field + * is insane, we can only be led to wrong decision about + * whether memmove will occur or not. Header values has no + * effect on memmove arguments and therefore no buffer + * overrun can be triggered. + */ + memmove(rb->buf + align, pkt, left); + rb->offset = align; + } + } + s->rlayer.packet = rb->buf + rb->offset; + s->rlayer.packet_length = 0; + /* ... now we can act as if 'extend' was set */ + } + + len = s->rlayer.packet_length; + pkt = rb->buf + align; + /* + * Move any available bytes to front of buffer: 'len' bytes already + * pointed to by 'packet', 'left' extra ones at the end + */ + if (s->rlayer.packet != pkt && clearold == 1) { + memmove(pkt, s->rlayer.packet, len + left); + s->rlayer.packet = pkt; + rb->offset = len + align; + } + + /* + * For DTLS/UDP reads should not span multiple packets because the read + * operation returns the whole packet at once (as long as it fits into + * the buffer). + */ + if (SSL_IS_DTLS(s)) { + if (left == 0 && extend) + return 0; + if (left > 0 && n > left) + n = left; + } + + /* if there is enough in the buffer from a previous read, take some */ + if (left >= n) { + s->rlayer.packet_length += n; + rb->left = left - n; + rb->offset += n; + return (n); + } + + /* else we need to read more data */ + + if (n > (int)(rb->len - rb->offset)) { /* does not happen */ + SSLerr(SSL_F_SSL3_READ_N, ERR_R_INTERNAL_ERROR); + return -1; + } + + /* We always act like read_ahead is set for DTLS */ + if (!s->rlayer.read_ahead && !SSL_IS_DTLS(s)) + /* ignore max parameter */ + max = n; + else { + if (max < n) + max = n; + if (max > (int)(rb->len - rb->offset)) + max = rb->len - rb->offset; + } + + while (left < n) { + /* + * Now we have len+left bytes at the front of s->s3->rbuf.buf and + * need to read in more until we have len+n (up to len+max if + * possible) + */ + + clear_sys_error(); + if (s->rbio != NULL) { + s->rwstate = SSL_READING; + i = BIO_read(s->rbio, pkt + len + left, max - left); + } else { + SSLerr(SSL_F_SSL3_READ_N, SSL_R_READ_BIO_NOT_SET); + i = -1; + } + + if (i <= 0) { + rb->left = left; + if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_IS_DTLS(s)) + if (len + left == 0) + ssl3_release_read_buffer(s); + return i; + } + left += i; + /* + * reads should *never* span multiple packets for DTLS because the + * underlying transport protocol is message oriented as opposed to + * byte oriented as in the TLS case. + */ + if (SSL_IS_DTLS(s)) { + if (n > left) + n = left; /* makes the while condition false */ + } + } + + /* done reading, now the book-keeping */ + rb->offset += n; + rb->left = left - n; + s->rlayer.packet_length += n; + s->rwstate = SSL_NOTHING; + return (n); +} +","@@ -395,7 +395,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) + if (type == SSL3_RT_APPLICATION_DATA && + u_len >= 4 * (max_send_fragment = s->max_send_fragment) && + s->compress == NULL && s->msg_callback == NULL && +- !SSL_USE_ETM(s) && SSL_USE_EXPLICIT_IV(s) && ++ !SSL_WRITE_ETM(s) && SSL_USE_EXPLICIT_IV(s) && + EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(s->enc_write_ctx)) & + EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK) { + unsigned char aad[13]; +@@ -791,7 +791,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, + * wb->buf + */ + +- if (!SSL_USE_ETM(s) && mac_size != 0) { ++ if (!SSL_WRITE_ETM(s) && mac_size != 0) { + if (s->method->ssl3_enc->mac(s, &wr[j], + &(outbuf[j][wr[j].length + eivlen]), + 1) < 0) +@@ -814,7 +814,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, + goto err; + + for (j = 0; j < numpipes; j++) { +- if (SSL_USE_ETM(s) && mac_size != 0) { ++ if (SSL_WRITE_ETM(s) && mac_size != 0) { + if (s->method->ssl3_enc->mac(s, &wr[j], + outbuf[j] + wr[j].length, 1) < 0) + goto err;",1287,1523,2048 +4878,"tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output){ + + tsize_t written=0; + char buffer[32]; + int buflen=0; + + if(t2p->pdf_compression==T2P_COMPRESS_NONE){ + return(written); + } + written += t2pWriteFile(output, (tdata_t) ""/Filter "", 8); + switch(t2p->pdf_compression){ +#ifdef CCITT_SUPPORT + case T2P_COMPRESS_G4: + written += t2pWriteFile(output, (tdata_t) ""/CCITTFaxDecode "", 16); + written += t2pWriteFile(output, (tdata_t) ""/DecodeParms "", 13); + written += t2pWriteFile(output, (tdata_t) ""<< /K -1 "", 9); + if(tile==0){ + written += t2pWriteFile(output, (tdata_t) ""/Columns "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_width); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /Rows "", 7); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_length); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ + written += t2pWriteFile(output, (tdata_t) ""/Columns "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + written += t2pWriteFile(output, (tdata_t) ""/Columns "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ + written += t2pWriteFile(output, (tdata_t) "" /Rows "", 7); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + written += t2pWriteFile(output, (tdata_t) "" /Rows "", 7); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + } + if(t2p->pdf_switchdecode == 0){ + written += t2pWriteFile(output, (tdata_t) "" /BlackIs1 true "", 16); + } + written += t2pWriteFile(output, (tdata_t) "">>\n"", 3); + break; +#endif +#ifdef JPEG_SUPPORT + case T2P_COMPRESS_JPEG: + written += t2pWriteFile(output, (tdata_t) ""/DCTDecode "", 11); + + if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR) { + written += t2pWriteFile(output, (tdata_t) ""/DecodeParms "", 13); + written += t2pWriteFile(output, (tdata_t) ""<< /ColorTransform 1 >>\n"", 24); + } + break; +#endif +#ifdef ZIP_SUPPORT + case T2P_COMPRESS_ZIP: + written += t2pWriteFile(output, (tdata_t) ""/FlateDecode "", 13); + if(t2p->pdf_compressionquality%100){ + written += t2pWriteFile(output, (tdata_t) ""/DecodeParms "", 13); + written += t2pWriteFile(output, (tdata_t) ""<< /Predictor "", 14); + buflen=snprintf(buffer, sizeof(buffer), ""%u"", t2p->pdf_compressionquality%100); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /Columns "", 10); + buflen = snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_width); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /Colors "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%u"", t2p->tiff_samplesperpixel); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /BitsPerComponent "", 19); + buflen=snprintf(buffer, sizeof(buffer), ""%u"", t2p->tiff_bitspersample); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "">>\n"", 3); + } + break; +#endif + default: + break; + } + + return(written); +} +",0,"tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output){ + + tsize_t written=0; + char buffer[32]; + int buflen=0; + + if(t2p->pdf_compression==T2P_COMPRESS_NONE){ + return(written); + } + written += t2pWriteFile(output, (tdata_t) ""/Filter "", 8); + switch(t2p->pdf_compression){ +#ifdef CCITT_SUPPORT + case T2P_COMPRESS_G4: + written += t2pWriteFile(output, (tdata_t) ""/CCITTFaxDecode "", 16); + written += t2pWriteFile(output, (tdata_t) ""/DecodeParms "", 13); + written += t2pWriteFile(output, (tdata_t) ""<< /K -1 "", 9); + if(tile==0){ + written += t2pWriteFile(output, (tdata_t) ""/Columns "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_width); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /Rows "", 7); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_length); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ + written += t2pWriteFile(output, (tdata_t) ""/Columns "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + written += t2pWriteFile(output, (tdata_t) ""/Columns "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ + written += t2pWriteFile(output, (tdata_t) "" /Rows "", 7); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + written += t2pWriteFile(output, (tdata_t) "" /Rows "", 7); + buflen=snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + } + if(t2p->pdf_switchdecode == 0){ + written += t2pWriteFile(output, (tdata_t) "" /BlackIs1 true "", 16); + } + written += t2pWriteFile(output, (tdata_t) "">>\n"", 3); + break; +#endif +#ifdef JPEG_SUPPORT + case T2P_COMPRESS_JPEG: + written += t2pWriteFile(output, (tdata_t) ""/DCTDecode "", 11); + + if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR) { + written += t2pWriteFile(output, (tdata_t) ""/DecodeParms "", 13); + written += t2pWriteFile(output, (tdata_t) ""<< /ColorTransform 1 >>\n"", 24); + } + break; +#endif +#ifdef ZIP_SUPPORT + case T2P_COMPRESS_ZIP: + written += t2pWriteFile(output, (tdata_t) ""/FlateDecode "", 13); + if(t2p->pdf_compressionquality%100){ + written += t2pWriteFile(output, (tdata_t) ""/DecodeParms "", 13); + written += t2pWriteFile(output, (tdata_t) ""<< /Predictor "", 14); + buflen=snprintf(buffer, sizeof(buffer), ""%u"", t2p->pdf_compressionquality%100); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /Columns "", 10); + buflen = snprintf(buffer, sizeof(buffer), ""%lu"", + (unsigned long)t2p->tiff_width); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /Colors "", 9); + buflen=snprintf(buffer, sizeof(buffer), ""%u"", t2p->tiff_samplesperpixel); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "" /BitsPerComponent "", 19); + buflen=snprintf(buffer, sizeof(buffer), ""%u"", t2p->tiff_bitspersample); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "">>\n"", 3); + } + break; +#endif + default: + break; + } + + return(written); +} +","@@ -286,7 +286,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P*, TIFF*, TIFF*, ttile_t); + int t2p_process_ojpeg_tables(T2P*, TIFF*); + #endif + #ifdef JPEG_SUPPORT +-int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t*, tstrip_t, uint32); ++int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32); + #endif + void t2p_tile_collapse_left(tdata_t, tsize_t, uint32, uint32, uint32); + void t2p_write_advance_directory(T2P*, TIFF*); +@@ -2408,7 +2408,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ + if(!t2p_process_jpeg_strip( + stripbuffer, + &striplength, +- buffer, ++ buffer, ++ t2p->tiff_datasize, + &bufferoffset, + i, + t2p->tiff_length)){ +@@ -3439,6 +3440,7 @@ int t2p_process_jpeg_strip( + unsigned char* strip, + tsize_t* striplength, + unsigned char* buffer, ++ tsize_t buffersize, + tsize_t* bufferoffset, + tstrip_t no, + uint32 height){ +@@ -3473,6 +3475,8 @@ int t2p_process_jpeg_strip( + } + switch( strip[i] ){ + case 0xd8: /* SOI - start of image */ ++ if( *bufferoffset + 2 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), 2); + *bufferoffset+=2; + break; +@@ -3482,12 +3486,18 @@ int t2p_process_jpeg_strip( + case 0xc9: /* SOF9 */ + case 0xca: /* SOF10 */ + if(no==0){ ++ if( *bufferoffset + datalen + 2 + 6 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); ++ if( *bufferoffset + 9 >= buffersize ) ++ return(0); + ncomp = buffer[*bufferoffset+9]; + if (ncomp < 1 || ncomp > 4) + return(0); + v_samp=1; + h_samp=1; ++ if( *bufferoffset + 11 + 3*(ncomp-1) >= buffersize ) ++ return(0); + for(j=0;j>4) > h_samp) +@@ -3519,20 +3529,28 @@ int t2p_process_jpeg_strip( + break; + case 0xc4: /* DHT */ + case 0xdb: /* DQT */ ++ if( *bufferoffset + datalen + 2 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + *bufferoffset+=datalen+2; + break; + case 0xda: /* SOS */ + if(no==0){ ++ if( *bufferoffset + datalen + 2 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + *bufferoffset+=datalen+2; + } else { ++ if( *bufferoffset + 2 > buffersize ) ++ return(0); + buffer[(*bufferoffset)++]=0xff; + buffer[(*bufferoffset)++]= + (unsigned char)(0xd0 | ((no-1)%8)); + } + i += datalen + 1; + /* copy remainder of strip */ ++ if( *bufferoffset + *striplength - i > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i]), *striplength - i); + *bufferoffset+= *striplength - i; + return(1);",1469,1705,2048 +736," cf2_glyphpath_computeIntersection( CF2_GlyphPath glyphpath, + const FT_Vector* u1, + const FT_Vector* u2, + const FT_Vector* v1, + const FT_Vector* v2, + FT_Vector* intersection ) + { + /* + * Let `u' be a zero-based vector from the first segment, `v' from the + * second segment. + * Let `w 'be the zero-based vector from `u1' to `v1'. + * `perp' is the `perpendicular dot product'; see + * http://mathworld.wolfram.com/PerpDotProduct.html. + * `s' is the parameter for the parametric line for the first segment + * (`u'). + * + * See notation in + * http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm. + * Calculations are done in 16.16, but must handle the squaring of + * line lengths in character space. We scale all vectors by 1/32 to + * avoid overflow. This allows values up to 4095 to be squared. The + * scale factor cancels in the divide. + * + * TODO: the scale factor could be computed from UnitsPerEm. + * + */ + +#define cf2_perp( a, b ) \ + ( FT_MulFix( a.x, b.y ) - FT_MulFix( a.y, b.x ) ) + + /* round and divide by 32 */ +#define CF2_CS_SCALE( x ) \ + ( ( (x) + 0x10 ) >> 5 ) + + FT_Vector u, v, w; /* scaled vectors */ + CF2_Fixed denominator, s; + + + u.x = CF2_CS_SCALE( u2->x - u1->x ); + u.y = CF2_CS_SCALE( u2->y - u1->y ); + v.x = CF2_CS_SCALE( v2->x - v1->x ); + v.y = CF2_CS_SCALE( v2->y - v1->y ); + w.x = CF2_CS_SCALE( v1->x - u1->x ); + w.y = CF2_CS_SCALE( v1->y - u1->y ); + + denominator = cf2_perp( u, v ); + + if ( denominator == 0 ) + return FALSE; /* parallel or coincident lines */ + + s = FT_DivFix( cf2_perp( w, v ), denominator ); + + intersection->x = u1->x + FT_MulFix( s, u2->x - u1->x ); + intersection->y = u1->y + FT_MulFix( s, u2->y - u1->y ); + + /* + * Special case snapping for horizontal and vertical lines. + * This cleans up intersections and reduces problems with winding + * order detection. + * Sample case is sbc cd KozGoPr6N-Medium.otf 20 16685. + * Note: these calculations are in character space. + * + */ + + if ( u1->x == u2->x && + cf2_fixedAbs( intersection->x - u1->x ) < glyphpath->snapThreshold ) + intersection->x = u1->x; + if ( u1->y == u2->y && + cf2_fixedAbs( intersection->y - u1->y ) < glyphpath->snapThreshold ) + intersection->y = u1->y; + + if ( v1->x == v2->x && + cf2_fixedAbs( intersection->x - v1->x ) < glyphpath->snapThreshold ) + intersection->x = v1->x; + if ( v1->y == v2->y && + cf2_fixedAbs( intersection->y - v1->y ) < glyphpath->snapThreshold ) + intersection->y = v1->y; + + /* limit the intersection distance from midpoint of u2 and v1 */ + if ( cf2_fixedAbs( intersection->x - ( u2->x + v1->x ) / 2 ) > + glyphpath->miterLimit || + cf2_fixedAbs( intersection->y - ( u2->y + v1->y ) / 2 ) > + glyphpath->miterLimit ) + return FALSE; + + return TRUE; + } +",0," cf2_glyphpath_computeIntersection( CF2_GlyphPath glyphpath, + const FT_Vector* u1, + const FT_Vector* u2, + const FT_Vector* v1, + const FT_Vector* v2, + FT_Vector* intersection ) + { + /* + * Let `u' be a zero-based vector from the first segment, `v' from the + * second segment. + * Let `w 'be the zero-based vector from `u1' to `v1'. + * `perp' is the `perpendicular dot product'; see + * http://mathworld.wolfram.com/PerpDotProduct.html. + * `s' is the parameter for the parametric line for the first segment + * (`u'). + * + * See notation in + * http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm. + * Calculations are done in 16.16, but must handle the squaring of + * line lengths in character space. We scale all vectors by 1/32 to + * avoid overflow. This allows values up to 4095 to be squared. The + * scale factor cancels in the divide. + * + * TODO: the scale factor could be computed from UnitsPerEm. + * + */ + +#define cf2_perp( a, b ) \ + ( FT_MulFix( a.x, b.y ) - FT_MulFix( a.y, b.x ) ) + + /* round and divide by 32 */ +#define CF2_CS_SCALE( x ) \ + ( ( (x) + 0x10 ) >> 5 ) + + FT_Vector u, v, w; /* scaled vectors */ + CF2_Fixed denominator, s; + + + u.x = CF2_CS_SCALE( u2->x - u1->x ); + u.y = CF2_CS_SCALE( u2->y - u1->y ); + v.x = CF2_CS_SCALE( v2->x - v1->x ); + v.y = CF2_CS_SCALE( v2->y - v1->y ); + w.x = CF2_CS_SCALE( v1->x - u1->x ); + w.y = CF2_CS_SCALE( v1->y - u1->y ); + + denominator = cf2_perp( u, v ); + + if ( denominator == 0 ) + return FALSE; /* parallel or coincident lines */ + + s = FT_DivFix( cf2_perp( w, v ), denominator ); + + intersection->x = u1->x + FT_MulFix( s, u2->x - u1->x ); + intersection->y = u1->y + FT_MulFix( s, u2->y - u1->y ); + + /* + * Special case snapping for horizontal and vertical lines. + * This cleans up intersections and reduces problems with winding + * order detection. + * Sample case is sbc cd KozGoPr6N-Medium.otf 20 16685. + * Note: these calculations are in character space. + * + */ + + if ( u1->x == u2->x && + cf2_fixedAbs( intersection->x - u1->x ) < glyphpath->snapThreshold ) + intersection->x = u1->x; + if ( u1->y == u2->y && + cf2_fixedAbs( intersection->y - u1->y ) < glyphpath->snapThreshold ) + intersection->y = u1->y; + + if ( v1->x == v2->x && + cf2_fixedAbs( intersection->x - v1->x ) < glyphpath->snapThreshold ) + intersection->x = v1->x; + if ( v1->y == v2->y && + cf2_fixedAbs( intersection->y - v1->y ) < glyphpath->snapThreshold ) + intersection->y = v1->y; + + /* limit the intersection distance from midpoint of u2 and v1 */ + if ( cf2_fixedAbs( intersection->x - ( u2->x + v1->x ) / 2 ) > + glyphpath->miterLimit || + cf2_fixedAbs( intersection->y - ( u2->y + v1->y ) / 2 ) > + glyphpath->miterLimit ) + return FALSE; + + return TRUE; + } +","@@ -794,9 +794,12 @@ + maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask ); + + /* use the hStem hints only, which are first in the mask */ +- /* TODO: compare this to cffhintmaskGetBitCount */ + bitCount = cf2_arrstack_size( hStemHintArray ); + ++ /* Defense-in-depth. Should never return here. */ ++ if ( bitCount > hintMask->bitCount ) ++ return; ++ + /* synthetic embox hints get highest priority */ + if ( font->blues.doEmBoxHints ) + {",982,1218,2048 +2488,"static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) +{ + unsigned long mem_start, mem_len, aux_start, aux_len; + int rc = -1; + int i; + dma_addr_t busaddroff; + unsigned char *vpackoff; + unsigned char __iomem *pciaddroff; + + mem_start = pci_resource_start(pci, 1); + mem_len = pci_resource_len(pci, 1); + aux_start = pci_resource_start(pci, 2); + aux_len = AUXMEMSIZE; + + if (!request_mem_region(mem_start, mem_len, DRV_NAME)) { + airo_print_err("""", ""Couldn't get region %x[%x]"", + (int)mem_start, (int)mem_len); + goto out; + } + if (!request_mem_region(aux_start, aux_len, DRV_NAME)) { + airo_print_err("""", ""Couldn't get region %x[%x]"", + (int)aux_start, (int)aux_len); + goto free_region1; + } + + ai->pcimem = ioremap(mem_start, mem_len); + if (!ai->pcimem) { + airo_print_err("""", ""Couldn't map region %x[%x]"", + (int)mem_start, (int)mem_len); + goto free_region2; + } + ai->pciaux = ioremap(aux_start, aux_len); + if (!ai->pciaux) { + airo_print_err("""", ""Couldn't map region %x[%x]"", + (int)aux_start, (int)aux_len); + goto free_memmap; + } + + /* Reserve PKTSIZE for each fid and 2K for the Rids */ + ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); + if (!ai->shared) { + airo_print_err("""", ""Couldn't alloc_consistent %d"", + PCI_SHARED_LEN); + goto free_auxmap; + } + + /* + * Setup descriptor RX, TX, CONFIG + */ + busaddroff = ai->shared_dma; + pciaddroff = ai->pciaux + AUX_OFFSET; + vpackoff = ai->shared; + + /* RX descriptor setup */ + for(i = 0; i < MPI_MAX_FIDS; i++) { + ai->rxfids[i].pending = 0; + ai->rxfids[i].card_ram_off = pciaddroff; + ai->rxfids[i].virtual_host_addr = vpackoff; + ai->rxfids[i].rx_desc.host_addr = busaddroff; + ai->rxfids[i].rx_desc.valid = 1; + ai->rxfids[i].rx_desc.len = PKTSIZE; + ai->rxfids[i].rx_desc.rdy = 0; + + pciaddroff += sizeof(RxFid); + busaddroff += PKTSIZE; + vpackoff += PKTSIZE; + } + + /* TX descriptor setup */ + for(i = 0; i < MPI_MAX_FIDS; i++) { + ai->txfids[i].card_ram_off = pciaddroff; + ai->txfids[i].virtual_host_addr = vpackoff; + ai->txfids[i].tx_desc.valid = 1; + ai->txfids[i].tx_desc.host_addr = busaddroff; + memcpy(ai->txfids[i].virtual_host_addr, + &wifictlhdr8023, sizeof(wifictlhdr8023)); + + pciaddroff += sizeof(TxFid); + busaddroff += PKTSIZE; + vpackoff += PKTSIZE; + } + ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ + + /* Rid descriptor setup */ + ai->config_desc.card_ram_off = pciaddroff; + ai->config_desc.virtual_host_addr = vpackoff; + ai->config_desc.rid_desc.host_addr = busaddroff; + ai->ridbus = busaddroff; + ai->config_desc.rid_desc.rid = 0; + ai->config_desc.rid_desc.len = RIDSIZE; + ai->config_desc.rid_desc.valid = 1; + pciaddroff += sizeof(Rid); + busaddroff += RIDSIZE; + vpackoff += RIDSIZE; + + /* Tell card about descriptors */ + if (mpi_init_descriptors (ai) != SUCCESS) + goto free_shared; + + return 0; + free_shared: + pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); + free_auxmap: + iounmap(ai->pciaux); + free_memmap: + iounmap(ai->pcimem); + free_region2: + release_mem_region(aux_start, aux_len); + free_region1: + release_mem_region(mem_start, mem_len); + out: + return rc; +} +",0,"static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) +{ + unsigned long mem_start, mem_len, aux_start, aux_len; + int rc = -1; + int i; + dma_addr_t busaddroff; + unsigned char *vpackoff; + unsigned char __iomem *pciaddroff; + + mem_start = pci_resource_start(pci, 1); + mem_len = pci_resource_len(pci, 1); + aux_start = pci_resource_start(pci, 2); + aux_len = AUXMEMSIZE; + + if (!request_mem_region(mem_start, mem_len, DRV_NAME)) { + airo_print_err("""", ""Couldn't get region %x[%x]"", + (int)mem_start, (int)mem_len); + goto out; + } + if (!request_mem_region(aux_start, aux_len, DRV_NAME)) { + airo_print_err("""", ""Couldn't get region %x[%x]"", + (int)aux_start, (int)aux_len); + goto free_region1; + } + + ai->pcimem = ioremap(mem_start, mem_len); + if (!ai->pcimem) { + airo_print_err("""", ""Couldn't map region %x[%x]"", + (int)mem_start, (int)mem_len); + goto free_region2; + } + ai->pciaux = ioremap(aux_start, aux_len); + if (!ai->pciaux) { + airo_print_err("""", ""Couldn't map region %x[%x]"", + (int)aux_start, (int)aux_len); + goto free_memmap; + } + + /* Reserve PKTSIZE for each fid and 2K for the Rids */ + ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); + if (!ai->shared) { + airo_print_err("""", ""Couldn't alloc_consistent %d"", + PCI_SHARED_LEN); + goto free_auxmap; + } + + /* + * Setup descriptor RX, TX, CONFIG + */ + busaddroff = ai->shared_dma; + pciaddroff = ai->pciaux + AUX_OFFSET; + vpackoff = ai->shared; + + /* RX descriptor setup */ + for(i = 0; i < MPI_MAX_FIDS; i++) { + ai->rxfids[i].pending = 0; + ai->rxfids[i].card_ram_off = pciaddroff; + ai->rxfids[i].virtual_host_addr = vpackoff; + ai->rxfids[i].rx_desc.host_addr = busaddroff; + ai->rxfids[i].rx_desc.valid = 1; + ai->rxfids[i].rx_desc.len = PKTSIZE; + ai->rxfids[i].rx_desc.rdy = 0; + + pciaddroff += sizeof(RxFid); + busaddroff += PKTSIZE; + vpackoff += PKTSIZE; + } + + /* TX descriptor setup */ + for(i = 0; i < MPI_MAX_FIDS; i++) { + ai->txfids[i].card_ram_off = pciaddroff; + ai->txfids[i].virtual_host_addr = vpackoff; + ai->txfids[i].tx_desc.valid = 1; + ai->txfids[i].tx_desc.host_addr = busaddroff; + memcpy(ai->txfids[i].virtual_host_addr, + &wifictlhdr8023, sizeof(wifictlhdr8023)); + + pciaddroff += sizeof(TxFid); + busaddroff += PKTSIZE; + vpackoff += PKTSIZE; + } + ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ + + /* Rid descriptor setup */ + ai->config_desc.card_ram_off = pciaddroff; + ai->config_desc.virtual_host_addr = vpackoff; + ai->config_desc.rid_desc.host_addr = busaddroff; + ai->ridbus = busaddroff; + ai->config_desc.rid_desc.rid = 0; + ai->config_desc.rid_desc.len = RIDSIZE; + ai->config_desc.rid_desc.valid = 1; + pciaddroff += sizeof(Rid); + busaddroff += RIDSIZE; + vpackoff += RIDSIZE; + + /* Tell card about descriptors */ + if (mpi_init_descriptors (ai) != SUCCESS) + goto free_shared; + + return 0; + free_shared: + pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); + free_auxmap: + iounmap(ai->pciaux); + free_memmap: + iounmap(ai->pcimem); + free_region2: + release_mem_region(aux_start, aux_len); + free_region1: + release_mem_region(mem_start, mem_len); + out: + return rc; +} +","@@ -2823,6 +2823,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, + dev->wireless_data = &ai->wireless_data; + dev->irq = irq; + dev->base_addr = port; ++ dev->priv_flags &= ~IFF_TX_SKB_SHARING; + + SET_NETDEV_DEV(dev, dmdev); + ",1058,1294,2048 +18316,"int dtls1_get_record(SSL *s) + { + int ssl_major,ssl_minor; + int i,n; + SSL3_RECORD *rr; + unsigned char *p = NULL; + unsigned short version; + DTLS1_BITMAP *bitmap; + unsigned int is_next_epoch; + + rr= &(s->s3->rrec); + + /* The epoch may have changed. If so, process all the + * pending records. This is a non-blocking operation. */ + dtls1_process_buffered_records(s); + + /* if we're renegotiating, then there may be buffered records */ + if (dtls1_get_processed_record(s)) + return 1; + + /* get something from the wire */ +again: + /* check if we have the header */ + if ( (s->rstate != SSL_ST_READ_BODY) || + (s->packet_length < DTLS1_RT_HEADER_LENGTH)) + { + n=ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH, s->s3->rbuf.len, 0); + /* read timeout is handled by dtls1_read_bytes */ + if (n <= 0) return(n); /* error or non-blocking */ + + /* this packet contained a partial record, dump it */ + if (s->packet_length != DTLS1_RT_HEADER_LENGTH) + { + s->packet_length = 0; + goto again; + } + + s->rstate=SSL_ST_READ_BODY; + + p=s->packet; + + if (s->msg_callback) + s->msg_callback(0, 0, SSL3_RT_HEADER, p, DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg); + + /* Pull apart the header into the DTLS1_RECORD */ + rr->type= *(p++); + ssl_major= *(p++); + ssl_minor= *(p++); + version=(ssl_major<<8)|ssl_minor; + + /* sequence number is 64 bits, with top 2 bytes = epoch */ + n2s(p,rr->epoch); + + memcpy(&(s->s3->read_sequence[2]), p, 6); + p+=6; + + n2s(p,rr->length); + + /* Lets check version */ + if (!s->first_packet) + { + if (version != s->version) + { + /* unexpected version, silently discard */ + rr->length = 0; + s->packet_length = 0; + goto again; + } + } + + if ((version & 0xff00) != (s->version & 0xff00)) + { + /* wrong version, silently discard record */ + rr->length = 0; + s->packet_length = 0; + goto again; + } + + if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) + { + /* record too long, silently discard it */ + rr->length = 0; + s->packet_length = 0; + goto again; + } + + /* now s->rstate == SSL_ST_READ_BODY */ + } + + /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ + + if (rr->length > s->packet_length-DTLS1_RT_HEADER_LENGTH) + { + /* now s->packet_length == DTLS1_RT_HEADER_LENGTH */ + i=rr->length; + n=ssl3_read_n(s,i,i,1); + if (n <= 0) return(n); /* error or non-blocking io */ + /* this packet contained a partial record, dump it */ + if ( n != i) + { + rr->length = 0; + s->packet_length = 0; + goto again; + } + + /* now n == rr->length, + * and s->packet_length == DTLS1_RT_HEADER_LENGTH + rr->length */ + } + s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */ + + /* match epochs. NULL means the packet is dropped on the floor */ + bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch); + if ( bitmap == NULL) + { + rr->length = 0; + s->packet_length = 0; /* dump this record */ + goto again; /* get another record */ + } + +#ifndef OPENSSL_NO_SCTP + /* Only do replay check if no SCTP bio */ + if (!BIO_dgram_is_sctp(SSL_get_rbio(s))) + { +#endif + /* Check whether this is a repeat, or aged record. + * Don't check if we're listening and this message is + * a ClientHello. They can look as if they're replayed, + * since they arrive from different connections and + * would be dropped unnecessarily. + */ + if (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE && + *p == SSL3_MT_CLIENT_HELLO) && + !dtls1_record_replay_check(s, bitmap)) + { + rr->length = 0; + s->packet_length=0; /* dump this record */ + goto again; /* get another record */ + } +#ifndef OPENSSL_NO_SCTP + } +#endif + + /* just read a 0 length packet */ + if (rr->length == 0) goto again; + + /* If this record is from the next epoch (either HM or ALERT), + * and a handshake is currently in progress, buffer it since it + * cannot be processed at this time. However, do not buffer + * anything while listening. + */ + if (is_next_epoch) + { + if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen) + { + dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num); + } + rr->length = 0; + s->packet_length = 0; + goto again; + } + + if (!dtls1_process_record(s)) + { + rr->length = 0; + s->packet_length = 0; /* dump this record */ + goto again; /* get another record */ + } + + return(1); + + } +",1,"int dtls1_get_record(SSL *s) + { + int ssl_major,ssl_minor; + int i,n; + SSL3_RECORD *rr; + unsigned char *p = NULL; + unsigned short version; + DTLS1_BITMAP *bitmap; + unsigned int is_next_epoch; + + rr= &(s->s3->rrec); + + /* The epoch may have changed. If so, process all the + * pending records. This is a non-blocking operation. */ + dtls1_process_buffered_records(s); + + /* if we're renegotiating, then there may be buffered records */ + if (dtls1_get_processed_record(s)) + return 1; + + /* get something from the wire */ +again: + /* check if we have the header */ + if ( (s->rstate != SSL_ST_READ_BODY) || + (s->packet_length < DTLS1_RT_HEADER_LENGTH)) + { + n=ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH, s->s3->rbuf.len, 0); + /* read timeout is handled by dtls1_read_bytes */ + if (n <= 0) return(n); /* error or non-blocking */ + + /* this packet contained a partial record, dump it */ + if (s->packet_length != DTLS1_RT_HEADER_LENGTH) + { + s->packet_length = 0; + goto again; + } + + s->rstate=SSL_ST_READ_BODY; + + p=s->packet; + + if (s->msg_callback) + s->msg_callback(0, 0, SSL3_RT_HEADER, p, DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg); + + /* Pull apart the header into the DTLS1_RECORD */ + rr->type= *(p++); + ssl_major= *(p++); + ssl_minor= *(p++); + version=(ssl_major<<8)|ssl_minor; + + /* sequence number is 64 bits, with top 2 bytes = epoch */ + n2s(p,rr->epoch); + + memcpy(&(s->s3->read_sequence[2]), p, 6); + p+=6; + + n2s(p,rr->length); + + /* Lets check version */ + if (!s->first_packet) + { + if (version != s->version) + { + /* unexpected version, silently discard */ + rr->length = 0; + s->packet_length = 0; + goto again; + } + } + + if ((version & 0xff00) != (s->version & 0xff00)) + { + /* wrong version, silently discard record */ + rr->length = 0; + s->packet_length = 0; + goto again; + } + + if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) + { + /* record too long, silently discard it */ + rr->length = 0; + s->packet_length = 0; + goto again; + } + + /* now s->rstate == SSL_ST_READ_BODY */ + } + + /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ + + if (rr->length > s->packet_length-DTLS1_RT_HEADER_LENGTH) + { + /* now s->packet_length == DTLS1_RT_HEADER_LENGTH */ + i=rr->length; + n=ssl3_read_n(s,i,i,1); + /* this packet contained a partial record, dump it */ + if ( n != i) + { + rr->length = 0; + s->packet_length = 0; + goto again; + } + + /* now n == rr->length, + * and s->packet_length == DTLS1_RT_HEADER_LENGTH + rr->length */ + } + s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */ + + /* match epochs. NULL means the packet is dropped on the floor */ + bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch); + if ( bitmap == NULL) + { + rr->length = 0; + s->packet_length = 0; /* dump this record */ + goto again; /* get another record */ + } + +#ifndef OPENSSL_NO_SCTP + /* Only do replay check if no SCTP bio */ + if (!BIO_dgram_is_sctp(SSL_get_rbio(s))) + { +#endif + /* Check whether this is a repeat, or aged record. + * Don't check if we're listening and this message is + * a ClientHello. They can look as if they're replayed, + * since they arrive from different connections and + * would be dropped unnecessarily. + */ + if (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE && + *p == SSL3_MT_CLIENT_HELLO) && + !dtls1_record_replay_check(s, bitmap)) + { + rr->length = 0; + s->packet_length=0; /* dump this record */ + goto again; /* get another record */ + } +#ifndef OPENSSL_NO_SCTP + } +#endif + + /* just read a 0 length packet */ + if (rr->length == 0) goto again; + + /* If this record is from the next epoch (either HM or ALERT), + * and a handshake is currently in progress, buffer it since it + * cannot be processed at this time. However, do not buffer + * anything while listening. + */ + if (is_next_epoch) + { + if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen) + { + dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num); + } + rr->length = 0; + s->packet_length = 0; + goto again; + } + + if (!dtls1_process_record(s)) + { + rr->length = 0; + s->packet_length = 0; /* dump this record */ + goto again; /* get another record */ + } + + return(1); + + } +","@@ -645,8 +645,6 @@ int dtls1_get_record(SSL *s) + /* now s->packet_length == DTLS1_RT_HEADER_LENGTH */ + i=rr->length; + n=ssl3_read_n(s,i,i,1); +- if (n <= 0) return(n); /* error or non-blocking io */ +- + /* this packet contained a partial record, dump it */ + if ( n != i) + {",1353,1589,2048 +18122,"static void print_bpf_insn(struct bpf_insn *insn) + { + u8 class = BPF_CLASS(insn->code); + + if (class == BPF_ALU || class == BPF_ALU64) { + if (BPF_SRC(insn->code) == BPF_X) + verbose(""(%02x) %sr%d %s %sr%d\n"", + insn->code, class == BPF_ALU ? ""(u32) "" : """", + insn->dst_reg, + bpf_alu_string[BPF_OP(insn->code) >> 4], + class == BPF_ALU ? ""(u32) "" : """", + insn->src_reg); + else + verbose(""(%02x) %sr%d %s %s%d\n"", + insn->code, class == BPF_ALU ? ""(u32) "" : """", + insn->dst_reg, + bpf_alu_string[BPF_OP(insn->code) >> 4], + class == BPF_ALU ? ""(u32) "" : """", + insn->imm); + } else if (class == BPF_STX) { + if (BPF_MODE(insn->code) == BPF_MEM) + verbose(""(%02x) *(%s *)(r%d %+d) = r%d\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->dst_reg, + insn->off, insn->src_reg); + else if (BPF_MODE(insn->code) == BPF_XADD) + verbose(""(%02x) lock *(%s *)(r%d %+d) += r%d\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->dst_reg, insn->off, + insn->src_reg); + else + verbose(""BUG_%02x\n"", insn->code); + } else if (class == BPF_ST) { + if (BPF_MODE(insn->code) != BPF_MEM) { + verbose(""BUG_st_%02x\n"", insn->code); + return; + } + verbose(""(%02x) *(%s *)(r%d %+d) = %d\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->dst_reg, + insn->off, insn->imm); + } else if (class == BPF_LDX) { + if (BPF_MODE(insn->code) != BPF_MEM) { + verbose(""BUG_ldx_%02x\n"", insn->code); + return; + } + verbose(""(%02x) r%d = *(%s *)(r%d %+d)\n"", + insn->code, insn->dst_reg, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->off); + } else if (class == BPF_LD) { + if (BPF_MODE(insn->code) == BPF_ABS) { + verbose(""(%02x) r0 = *(%s *)skb[%d]\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->imm); + } else if (BPF_MODE(insn->code) == BPF_IND) { + verbose(""(%02x) r0 = *(%s *)skb[r%d + %d]\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->imm); + } else if (BPF_MODE(insn->code) == BPF_IMM) { + verbose(""(%02x) r%d = 0x%x\n"", + insn->code, insn->dst_reg, insn->imm); + } else { + verbose(""BUG_ld_%02x\n"", insn->code); + return; + } + } else if (class == BPF_JMP) { + u8 opcode = BPF_OP(insn->code); + + if (opcode == BPF_CALL) { + verbose(""(%02x) call %s#%d\n"", insn->code, + func_id_name(insn->imm), insn->imm); + } else if (insn->code == (BPF_JMP | BPF_JA)) { + verbose(""(%02x) goto pc%+d\n"", + insn->code, insn->off); + } else if (insn->code == (BPF_JMP | BPF_EXIT)) { + verbose(""(%02x) exit\n"", insn->code); + } else if (BPF_SRC(insn->code) == BPF_X) { + verbose(""(%02x) if r%d %s r%d goto pc%+d\n"", + insn->code, insn->dst_reg, + bpf_jmp_string[BPF_OP(insn->code) >> 4], + insn->src_reg, insn->off); + } else { + verbose(""(%02x) if r%d %s 0x%x goto pc%+d\n"", + insn->code, insn->dst_reg, + bpf_jmp_string[BPF_OP(insn->code) >> 4], + insn->imm, insn->off); + } + } else { + verbose(""(%02x) %s\n"", insn->code, bpf_class_string[class]); + } +} +",1,"static void print_bpf_insn(struct bpf_insn *insn) +static void print_bpf_insn(const struct bpf_verifier_env *env, + const struct bpf_insn *insn) + { + u8 class = BPF_CLASS(insn->code); + + if (class == BPF_ALU || class == BPF_ALU64) { + if (BPF_SRC(insn->code) == BPF_X) + verbose(""(%02x) %sr%d %s %sr%d\n"", + insn->code, class == BPF_ALU ? ""(u32) "" : """", + insn->dst_reg, + bpf_alu_string[BPF_OP(insn->code) >> 4], + class == BPF_ALU ? ""(u32) "" : """", + insn->src_reg); + else + verbose(""(%02x) %sr%d %s %s%d\n"", + insn->code, class == BPF_ALU ? ""(u32) "" : """", + insn->dst_reg, + bpf_alu_string[BPF_OP(insn->code) >> 4], + class == BPF_ALU ? ""(u32) "" : """", + insn->imm); + } else if (class == BPF_STX) { + if (BPF_MODE(insn->code) == BPF_MEM) + verbose(""(%02x) *(%s *)(r%d %+d) = r%d\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->dst_reg, + insn->off, insn->src_reg); + else if (BPF_MODE(insn->code) == BPF_XADD) + verbose(""(%02x) lock *(%s *)(r%d %+d) += r%d\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->dst_reg, insn->off, + insn->src_reg); + else + verbose(""BUG_%02x\n"", insn->code); + } else if (class == BPF_ST) { + if (BPF_MODE(insn->code) != BPF_MEM) { + verbose(""BUG_st_%02x\n"", insn->code); + return; + } + verbose(""(%02x) *(%s *)(r%d %+d) = %d\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->dst_reg, + insn->off, insn->imm); + } else if (class == BPF_LDX) { + if (BPF_MODE(insn->code) != BPF_MEM) { + verbose(""BUG_ldx_%02x\n"", insn->code); + return; + } + verbose(""(%02x) r%d = *(%s *)(r%d %+d)\n"", + insn->code, insn->dst_reg, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->off); + } else if (class == BPF_LD) { + if (BPF_MODE(insn->code) == BPF_ABS) { + verbose(""(%02x) r0 = *(%s *)skb[%d]\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->imm); + } else if (BPF_MODE(insn->code) == BPF_IND) { + verbose(""(%02x) r0 = *(%s *)skb[r%d + %d]\n"", + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->imm); + } else if (BPF_MODE(insn->code) == BPF_IMM && + BPF_SIZE(insn->code) == BPF_DW) { + /* At this point, we already made sure that the second + * part of the ldimm64 insn is accessible. + */ + u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm; + bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD; + + if (map_ptr && !env->allow_ptr_leaks) + imm = 0; + + verbose(""(%02x) r%d = 0x%llx\n"", insn->code, + insn->dst_reg, (unsigned long long)imm); + } else { + verbose(""BUG_ld_%02x\n"", insn->code); + return; + } + } else if (class == BPF_JMP) { + u8 opcode = BPF_OP(insn->code); + + if (opcode == BPF_CALL) { + verbose(""(%02x) call %s#%d\n"", insn->code, + func_id_name(insn->imm), insn->imm); + } else if (insn->code == (BPF_JMP | BPF_JA)) { + verbose(""(%02x) goto pc%+d\n"", + insn->code, insn->off); + } else if (insn->code == (BPF_JMP | BPF_EXIT)) { + verbose(""(%02x) exit\n"", insn->code); + } else if (BPF_SRC(insn->code) == BPF_X) { + verbose(""(%02x) if r%d %s r%d goto pc%+d\n"", + insn->code, insn->dst_reg, + bpf_jmp_string[BPF_OP(insn->code) >> 4], + insn->src_reg, insn->off); + } else { + verbose(""(%02x) if r%d %s 0x%x goto pc%+d\n"", + insn->code, insn->dst_reg, + bpf_jmp_string[BPF_OP(insn->code) >> 4], + insn->imm, insn->off); + } + } else { + verbose(""(%02x) %s\n"", insn->code, bpf_class_string[class]); + } +} +","@@ -298,7 +298,8 @@ static const char *const bpf_jmp_string[16] = { + [BPF_EXIT >> 4] = ""exit"", + }; + +-static void print_bpf_insn(struct bpf_insn *insn) ++static void print_bpf_insn(const struct bpf_verifier_env *env, ++ const struct bpf_insn *insn) + { + u8 class = BPF_CLASS(insn->code); + +@@ -362,9 +363,19 @@ static void print_bpf_insn(struct bpf_insn *insn) + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->imm); +- } else if (BPF_MODE(insn->code) == BPF_IMM) { +- verbose(""(%02x) r%d = 0x%x\n"", +- insn->code, insn->dst_reg, insn->imm); ++ } else if (BPF_MODE(insn->code) == BPF_IMM && ++ BPF_SIZE(insn->code) == BPF_DW) { ++ /* At this point, we already made sure that the second ++ * part of the ldimm64 insn is accessible. ++ */ ++ u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm; ++ bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD; ++ ++ if (map_ptr && !env->allow_ptr_leaks) ++ imm = 0; ++ ++ verbose(""(%02x) r%d = 0x%llx\n"", insn->code, ++ insn->dst_reg, (unsigned long long)imm); + } else { + verbose(""BUG_ld_%02x\n"", insn->code); + return; +@@ -2853,7 +2864,7 @@ static int do_check(struct bpf_verifier_env *env) + + if (log_level) { + verbose(""%d: "", insn_idx); +- print_bpf_insn(insn); ++ print_bpf_insn(env, insn); + } + + err = ext_analyzer_insn_hook(env, insn_idx, prev_insn_idx);",1234,1470,2048 +4077,"static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, + struct msghdr *msg, size_t len) +{ + struct ipv6_txoptions opt_space; + struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name; + struct in6_addr *daddr, *final_p, final; + struct inet_sock *inet = inet_sk(sk); + struct ipv6_pinfo *np = inet6_sk(sk); + struct raw6_sock *rp = raw6_sk(sk); + struct ipv6_txoptions *opt = NULL; + struct ip6_flowlabel *flowlabel = NULL; + struct dst_entry *dst = NULL; + struct flowi6 fl6; + int addr_len = msg->msg_namelen; + int hlimit = -1; + int tclass = -1; + int dontfrag = -1; + u16 proto; + int err; + + /* Rough check on arithmetic overflow, + better check is made in ip6_append_data(). + */ + if (len > INT_MAX) + return -EMSGSIZE; + + /* Mirror BSD error message compatibility */ + if (msg->msg_flags & MSG_OOB) + return -EOPNOTSUPP; + + /* + * Get and verify the address. + */ + memset(&fl6, 0, sizeof(fl6)); + + fl6.flowi6_mark = sk->sk_mark; + + if (sin6) { + if (addr_len < SIN6_LEN_RFC2133) + return -EINVAL; + + if (sin6->sin6_family && sin6->sin6_family != AF_INET6) + return -EAFNOSUPPORT; + + /* port is the proto value [0..255] carried in nexthdr */ + proto = ntohs(sin6->sin6_port); + + if (!proto) + proto = inet->inet_num; + else if (proto != inet->inet_num) + return -EINVAL; + + if (proto > 255) + return -EINVAL; + + daddr = &sin6->sin6_addr; + if (np->sndflow) { + fl6.flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK; + if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + daddr = &flowlabel->dst; + } + } + + /* + * Otherwise it will be difficult to maintain + * sk->sk_dst_cache. + */ + if (sk->sk_state == TCP_ESTABLISHED && + ipv6_addr_equal(daddr, &sk->sk_v6_daddr)) + daddr = &sk->sk_v6_daddr; + + if (addr_len >= sizeof(struct sockaddr_in6) && + sin6->sin6_scope_id && + __ipv6_addr_needs_scope_id(__ipv6_addr_type(daddr))) + fl6.flowi6_oif = sin6->sin6_scope_id; + } else { + if (sk->sk_state != TCP_ESTABLISHED) + return -EDESTADDRREQ; + + proto = inet->inet_num; + daddr = &sk->sk_v6_daddr; + fl6.flowlabel = np->flow_label; + } + + if (fl6.flowi6_oif == 0) + fl6.flowi6_oif = sk->sk_bound_dev_if; + + if (msg->msg_controllen) { + opt = &opt_space; + memset(opt, 0, sizeof(struct ipv6_txoptions)); + opt->tot_len = sizeof(struct ipv6_txoptions); + + err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt, + &hlimit, &tclass, &dontfrag); + if (err < 0) { + fl6_sock_release(flowlabel); + return err; + } + if ((fl6.flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + } + if (!(opt->opt_nflen|opt->opt_flen)) + opt = NULL; + } + if (opt == NULL) + opt = np->opt; + if (flowlabel) + opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = ipv6_fixup_options(&opt_space, opt); + + fl6.flowi6_proto = proto; + err = rawv6_probe_proto_opt(&fl6, msg); + if (err) + goto out; + + if (!ipv6_addr_any(daddr)) + fl6.daddr = *daddr; + else + fl6.daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */ + if (ipv6_addr_any(&fl6.saddr) && !ipv6_addr_any(&np->saddr)) + fl6.saddr = np->saddr; + + final_p = fl6_update_dst(&fl6, opt, &final); + + if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) + fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; + security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); + + dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true); + if (IS_ERR(dst)) { + err = PTR_ERR(dst); + goto out; + } + if (hlimit < 0) { + if (ipv6_addr_is_multicast(&fl6.daddr)) + hlimit = np->mcast_hops; + else + hlimit = np->hop_limit; + if (hlimit < 0) + hlimit = ip6_dst_hoplimit(dst); + } + + if (tclass < 0) + tclass = np->tclass; + + if (dontfrag < 0) + dontfrag = np->dontfrag; + + if (msg->msg_flags&MSG_CONFIRM) + goto do_confirm; + +back_from_confirm: + if (inet->hdrincl) + err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl6, &dst, msg->msg_flags); + else { + lock_sock(sk); + err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, + len, 0, hlimit, tclass, opt, &fl6, (struct rt6_info*)dst, + msg->msg_flags, dontfrag); + + if (err) + ip6_flush_pending_frames(sk); + else if (!(msg->msg_flags & MSG_MORE)) + err = rawv6_push_pending_frames(sk, &fl6, rp); + release_sock(sk); + } +done: + dst_release(dst); +out: + fl6_sock_release(flowlabel); + return err<0?err:len; +do_confirm: + dst_confirm(dst); + if (!(msg->msg_flags & MSG_PROBE) || len) + goto back_from_confirm; + err = 0; + goto done; +} +",0,"static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, + struct msghdr *msg, size_t len) +{ + struct ipv6_txoptions opt_space; + struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name; + struct in6_addr *daddr, *final_p, final; + struct inet_sock *inet = inet_sk(sk); + struct ipv6_pinfo *np = inet6_sk(sk); + struct raw6_sock *rp = raw6_sk(sk); + struct ipv6_txoptions *opt = NULL; + struct ip6_flowlabel *flowlabel = NULL; + struct dst_entry *dst = NULL; + struct flowi6 fl6; + int addr_len = msg->msg_namelen; + int hlimit = -1; + int tclass = -1; + int dontfrag = -1; + u16 proto; + int err; + + /* Rough check on arithmetic overflow, + better check is made in ip6_append_data(). + */ + if (len > INT_MAX) + return -EMSGSIZE; + + /* Mirror BSD error message compatibility */ + if (msg->msg_flags & MSG_OOB) + return -EOPNOTSUPP; + + /* + * Get and verify the address. + */ + memset(&fl6, 0, sizeof(fl6)); + + fl6.flowi6_mark = sk->sk_mark; + + if (sin6) { + if (addr_len < SIN6_LEN_RFC2133) + return -EINVAL; + + if (sin6->sin6_family && sin6->sin6_family != AF_INET6) + return -EAFNOSUPPORT; + + /* port is the proto value [0..255] carried in nexthdr */ + proto = ntohs(sin6->sin6_port); + + if (!proto) + proto = inet->inet_num; + else if (proto != inet->inet_num) + return -EINVAL; + + if (proto > 255) + return -EINVAL; + + daddr = &sin6->sin6_addr; + if (np->sndflow) { + fl6.flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK; + if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + daddr = &flowlabel->dst; + } + } + + /* + * Otherwise it will be difficult to maintain + * sk->sk_dst_cache. + */ + if (sk->sk_state == TCP_ESTABLISHED && + ipv6_addr_equal(daddr, &sk->sk_v6_daddr)) + daddr = &sk->sk_v6_daddr; + + if (addr_len >= sizeof(struct sockaddr_in6) && + sin6->sin6_scope_id && + __ipv6_addr_needs_scope_id(__ipv6_addr_type(daddr))) + fl6.flowi6_oif = sin6->sin6_scope_id; + } else { + if (sk->sk_state != TCP_ESTABLISHED) + return -EDESTADDRREQ; + + proto = inet->inet_num; + daddr = &sk->sk_v6_daddr; + fl6.flowlabel = np->flow_label; + } + + if (fl6.flowi6_oif == 0) + fl6.flowi6_oif = sk->sk_bound_dev_if; + + if (msg->msg_controllen) { + opt = &opt_space; + memset(opt, 0, sizeof(struct ipv6_txoptions)); + opt->tot_len = sizeof(struct ipv6_txoptions); + + err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt, + &hlimit, &tclass, &dontfrag); + if (err < 0) { + fl6_sock_release(flowlabel); + return err; + } + if ((fl6.flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + } + if (!(opt->opt_nflen|opt->opt_flen)) + opt = NULL; + } + if (opt == NULL) + opt = np->opt; + if (flowlabel) + opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = ipv6_fixup_options(&opt_space, opt); + + fl6.flowi6_proto = proto; + err = rawv6_probe_proto_opt(&fl6, msg); + if (err) + goto out; + + if (!ipv6_addr_any(daddr)) + fl6.daddr = *daddr; + else + fl6.daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */ + if (ipv6_addr_any(&fl6.saddr) && !ipv6_addr_any(&np->saddr)) + fl6.saddr = np->saddr; + + final_p = fl6_update_dst(&fl6, opt, &final); + + if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) + fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; + security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); + + dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true); + if (IS_ERR(dst)) { + err = PTR_ERR(dst); + goto out; + } + if (hlimit < 0) { + if (ipv6_addr_is_multicast(&fl6.daddr)) + hlimit = np->mcast_hops; + else + hlimit = np->hop_limit; + if (hlimit < 0) + hlimit = ip6_dst_hoplimit(dst); + } + + if (tclass < 0) + tclass = np->tclass; + + if (dontfrag < 0) + dontfrag = np->dontfrag; + + if (msg->msg_flags&MSG_CONFIRM) + goto do_confirm; + +back_from_confirm: + if (inet->hdrincl) + err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl6, &dst, msg->msg_flags); + else { + lock_sock(sk); + err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, + len, 0, hlimit, tclass, opt, &fl6, (struct rt6_info*)dst, + msg->msg_flags, dontfrag); + + if (err) + ip6_flush_pending_frames(sk); + else if (!(msg->msg_flags & MSG_MORE)) + err = rawv6_push_pending_frames(sk, &fl6, rp); + release_sock(sk); + } +done: + dst_release(dst); +out: + fl6_sock_release(flowlabel); + return err<0?err:len; +do_confirm: + dst_confirm(dst); + if (!(msg->msg_flags & MSG_PROBE) || len) + goto back_from_confirm; + err = 0; + goto done; +} +","@@ -465,9 +465,6 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, + if (flags & MSG_OOB) + return -EOPNOTSUPP; + +- if (addr_len) +- *addr_len=sizeof(*sin6); +- + if (flags & MSG_ERRQUEUE) + return ipv6_recv_error(sk, msg, len); + +@@ -506,6 +503,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, + sin6->sin6_flowinfo = 0; + sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, + IP6CB(skb)->iif); ++ *addr_len = sizeof(*sin6); + } + + sock_recv_ts_and_drops(msg, sk, skb);",1557,1793,2048 +6808,"static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) +{ + struct sock *sk = sock->sk; + DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg->msg_name); + struct sk_buff *skb; + struct net_device *dev; + __be16 proto; + unsigned char *addr; + int err, reserve = 0; + struct sockcm_cookie sockc; + struct virtio_net_hdr vnet_hdr = { 0 }; + int offset = 0; + struct packet_sock *po = pkt_sk(sk); + int hlen, tlen, linear; + int extra_len = 0; + + /* + * Get and verify the address. + */ + + if (likely(saddr == NULL)) { + dev = packet_cached_dev_get(po); + proto = po->num; + addr = NULL; + } else { + err = -EINVAL; + if (msg->msg_namelen < sizeof(struct sockaddr_ll)) + goto out; + if (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll, sll_addr))) + goto out; + proto = saddr->sll_protocol; + addr = saddr->sll_addr; + dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); + } + + err = -ENXIO; + if (unlikely(dev == NULL)) + goto out_unlock; + err = -ENETDOWN; + if (unlikely(!(dev->flags & IFF_UP))) + goto out_unlock; + + sockc.tsflags = sk->sk_tsflags; + sockc.mark = sk->sk_mark; + if (msg->msg_controllen) { + err = sock_cmsg_send(sk, msg, &sockc); + if (unlikely(err)) + goto out_unlock; + } + + if (sock->type == SOCK_RAW) + reserve = dev->hard_header_len; + if (po->has_vnet_hdr) { + err = packet_snd_vnet_parse(msg, &len, &vnet_hdr); + if (err) + goto out_unlock; + } + + if (unlikely(sock_flag(sk, SOCK_NOFCS))) { + if (!netif_supports_nofcs(dev)) { + err = -EPROTONOSUPPORT; + goto out_unlock; + } + extra_len = 4; /* We're doing our own CRC */ + } + + err = -EMSGSIZE; + if (!vnet_hdr.gso_type && + (len > dev->mtu + reserve + VLAN_HLEN + extra_len)) + goto out_unlock; + + err = -ENOBUFS; + hlen = LL_RESERVED_SPACE(dev); + tlen = dev->needed_tailroom; + linear = __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len); + linear = max(linear, min_t(int, len, dev->hard_header_len)); + skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, linear, + msg->msg_flags & MSG_DONTWAIT, &err); + if (skb == NULL) + goto out_unlock; + + skb_set_network_header(skb, reserve); + + err = -EINVAL; + if (sock->type == SOCK_DGRAM) { + offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len); + if (unlikely(offset < 0)) + goto out_free; + } + + /* Returns -EFAULT on error */ + err = skb_copy_datagram_from_iter(skb, offset, &msg->msg_iter, len); + if (err) + goto out_free; + + if (sock->type == SOCK_RAW && + !dev_validate_header(dev, skb->data, len)) { + err = -EINVAL; + goto out_free; + } + + sock_tx_timestamp(sk, sockc.tsflags, &skb_shinfo(skb)->tx_flags); + + if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) && + !packet_extra_vlan_len_allowed(dev, skb)) { + err = -EMSGSIZE; + goto out_free; + } + + skb->protocol = proto; + skb->dev = dev; + skb->priority = sk->sk_priority; + skb->mark = sockc.mark; + + packet_pick_tx_queue(dev, skb); + + if (po->has_vnet_hdr) { + err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le()); + if (err) + goto out_free; + len += sizeof(vnet_hdr); + } + + skb_probe_transport_header(skb, reserve); + + if (unlikely(extra_len == 4)) + skb->no_fcs = 1; + + err = po->xmit(skb); + if (err > 0 && (err = net_xmit_errno(err)) != 0) + goto out_unlock; + + dev_put(dev); + + return len; + +out_free: + kfree_skb(skb); +out_unlock: + if (dev) + dev_put(dev); +out: + return err; +} +",0,"static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) +{ + struct sock *sk = sock->sk; + DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg->msg_name); + struct sk_buff *skb; + struct net_device *dev; + __be16 proto; + unsigned char *addr; + int err, reserve = 0; + struct sockcm_cookie sockc; + struct virtio_net_hdr vnet_hdr = { 0 }; + int offset = 0; + struct packet_sock *po = pkt_sk(sk); + int hlen, tlen, linear; + int extra_len = 0; + + /* + * Get and verify the address. + */ + + if (likely(saddr == NULL)) { + dev = packet_cached_dev_get(po); + proto = po->num; + addr = NULL; + } else { + err = -EINVAL; + if (msg->msg_namelen < sizeof(struct sockaddr_ll)) + goto out; + if (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll, sll_addr))) + goto out; + proto = saddr->sll_protocol; + addr = saddr->sll_addr; + dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); + } + + err = -ENXIO; + if (unlikely(dev == NULL)) + goto out_unlock; + err = -ENETDOWN; + if (unlikely(!(dev->flags & IFF_UP))) + goto out_unlock; + + sockc.tsflags = sk->sk_tsflags; + sockc.mark = sk->sk_mark; + if (msg->msg_controllen) { + err = sock_cmsg_send(sk, msg, &sockc); + if (unlikely(err)) + goto out_unlock; + } + + if (sock->type == SOCK_RAW) + reserve = dev->hard_header_len; + if (po->has_vnet_hdr) { + err = packet_snd_vnet_parse(msg, &len, &vnet_hdr); + if (err) + goto out_unlock; + } + + if (unlikely(sock_flag(sk, SOCK_NOFCS))) { + if (!netif_supports_nofcs(dev)) { + err = -EPROTONOSUPPORT; + goto out_unlock; + } + extra_len = 4; /* We're doing our own CRC */ + } + + err = -EMSGSIZE; + if (!vnet_hdr.gso_type && + (len > dev->mtu + reserve + VLAN_HLEN + extra_len)) + goto out_unlock; + + err = -ENOBUFS; + hlen = LL_RESERVED_SPACE(dev); + tlen = dev->needed_tailroom; + linear = __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len); + linear = max(linear, min_t(int, len, dev->hard_header_len)); + skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, linear, + msg->msg_flags & MSG_DONTWAIT, &err); + if (skb == NULL) + goto out_unlock; + + skb_set_network_header(skb, reserve); + + err = -EINVAL; + if (sock->type == SOCK_DGRAM) { + offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len); + if (unlikely(offset < 0)) + goto out_free; + } + + /* Returns -EFAULT on error */ + err = skb_copy_datagram_from_iter(skb, offset, &msg->msg_iter, len); + if (err) + goto out_free; + + if (sock->type == SOCK_RAW && + !dev_validate_header(dev, skb->data, len)) { + err = -EINVAL; + goto out_free; + } + + sock_tx_timestamp(sk, sockc.tsflags, &skb_shinfo(skb)->tx_flags); + + if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) && + !packet_extra_vlan_len_allowed(dev, skb)) { + err = -EMSGSIZE; + goto out_free; + } + + skb->protocol = proto; + skb->dev = dev; + skb->priority = sk->sk_priority; + skb->mark = sockc.mark; + + packet_pick_tx_queue(dev, skb); + + if (po->has_vnet_hdr) { + err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le()); + if (err) + goto out_free; + len += sizeof(vnet_hdr); + } + + skb_probe_transport_header(skb, reserve); + + if (unlikely(extra_len == 4)) + skb->no_fcs = 1; + + err = po->xmit(skb); + if (err > 0 && (err = net_xmit_errno(err)) != 0) + goto out_unlock; + + dev_put(dev); + + return len; + +out_free: + kfree_skb(skb); +out_unlock: + if (dev) + dev_put(dev); +out: + return err; +} +","@@ -1619,6 +1619,7 @@ static void fanout_release_data(struct packet_fanout *f) + + static int fanout_add(struct sock *sk, u16 id, u16 type_flags) + { ++ struct packet_rollover *rollover = NULL; + struct packet_sock *po = pkt_sk(sk); + struct packet_fanout *f, *match; + u8 type = type_flags & 0xff; +@@ -1641,23 +1642,28 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) + return -EINVAL; + } + ++ mutex_lock(&fanout_mutex); ++ ++ err = -EINVAL; + if (!po->running) +- return -EINVAL; ++ goto out; + ++ err = -EALREADY; + if (po->fanout) +- return -EALREADY; ++ goto out; + + if (type == PACKET_FANOUT_ROLLOVER || + (type_flags & PACKET_FANOUT_FLAG_ROLLOVER)) { +- po->rollover = kzalloc(sizeof(*po->rollover), GFP_KERNEL); +- if (!po->rollover) +- return -ENOMEM; +- atomic_long_set(&po->rollover->num, 0); +- atomic_long_set(&po->rollover->num_huge, 0); +- atomic_long_set(&po->rollover->num_failed, 0); ++ err = -ENOMEM; ++ rollover = kzalloc(sizeof(*rollover), GFP_KERNEL); ++ if (!rollover) ++ goto out; ++ atomic_long_set(&rollover->num, 0); ++ atomic_long_set(&rollover->num_huge, 0); ++ atomic_long_set(&rollover->num_failed, 0); ++ po->rollover = rollover; + } + +- mutex_lock(&fanout_mutex); + match = NULL; + list_for_each_entry(f, &fanout_list, list) { + if (f->id == id && +@@ -1704,11 +1710,11 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) + } + } + out: +- mutex_unlock(&fanout_mutex); +- if (err) { +- kfree(po->rollover); ++ if (err && rollover) { ++ kfree(rollover); + po->rollover = NULL; + } ++ mutex_unlock(&fanout_mutex); + return err; + } + +@@ -1717,23 +1723,22 @@ static void fanout_release(struct sock *sk) + struct packet_sock *po = pkt_sk(sk); + struct packet_fanout *f; + +- f = po->fanout; +- if (!f) +- return; +- + mutex_lock(&fanout_mutex); +- po->fanout = NULL; ++ f = po->fanout; ++ if (f) { ++ po->fanout = NULL; ++ ++ if (atomic_dec_and_test(&f->sk_ref)) { ++ list_del(&f->list); ++ dev_remove_pack(&f->prot_hook); ++ fanout_release_data(f); ++ kfree(f); ++ } + +- if (atomic_dec_and_test(&f->sk_ref)) { +- list_del(&f->list); +- dev_remove_pack(&f->prot_hook); +- fanout_release_data(f); +- kfree(f); ++ if (po->rollover) ++ kfree_rcu(po->rollover, rcu); + } + mutex_unlock(&fanout_mutex); +- +- if (po->rollover) +- kfree_rcu(po->rollover, rcu); + } + + static bool packet_extra_vlan_len_allowed(const struct net_device *dev,",1038,1274,2048 +18340,"static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image + *image; + + MagickBooleanType + status, + cubemap = MagickFalse, + volume = MagickFalse, + matte; + + CompressionType + compression; + + DDSInfo + dds_info; + + DDSDecoder + *decoder; + + size_t + n, + num_images; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + + /* + Initialize image structure. + */ + if (ReadDDSInfo(image, &dds_info) != MagickTrue) { + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP) + cubemap = MagickTrue; + + if (dds_info.ddscaps2 & DDSCAPS2_VOLUME && dds_info.depth > 0) + volume = MagickTrue; + + (void) SeekBlob(image, 128, SEEK_SET); + + /* + Determine pixel format + */ + if (dds_info.pixelformat.flags & DDPF_RGB) + { + compression = NoCompression; + if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS) + { + matte = MagickTrue; + decoder = ReadUncompressedRGBA; + } + else + { + matte = MagickTrue; + decoder = ReadUncompressedRGB; + } + } + else if (dds_info.pixelformat.flags & DDPF_LUMINANCE) + { + compression = NoCompression; + if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS) + { + /* Not sure how to handle this */ + ThrowReaderException(CorruptImageError, ""ImageTypeNotSupported""); + } + else + { + matte = MagickFalse; + decoder = ReadUncompressedRGB; + } + } + else if (dds_info.pixelformat.flags & DDPF_FOURCC) + { + switch (dds_info.pixelformat.fourcc) + { + case FOURCC_DXT1: + { + matte = MagickFalse; + compression = DXT1Compression; + decoder = ReadDXT1; + break; + } + case FOURCC_DXT3: + { + matte = MagickTrue; + compression = DXT3Compression; + decoder = ReadDXT3; + break; + } + case FOURCC_DXT5: + { + matte = MagickTrue; + compression = DXT5Compression; + decoder = ReadDXT5; + break; + } + default: + { + /* Unknown FOURCC */ + ThrowReaderException(CorruptImageError, ""ImageTypeNotSupported""); + } + } + } + else + { + /* Neither compressed nor uncompressed... thus unsupported */ + ThrowReaderException(CorruptImageError, ""ImageTypeNotSupported""); + } + + num_images = 1; + if (cubemap) + { + /* + Determine number of faces defined in the cubemap + */ + num_images = 0; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) num_images++; + } + + if (volume) + num_images = dds_info.depth; + + for (n = 0; n < num_images; n++) + { + if (n != 0) + { + /* Start a new image */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + return(DestroyImageList(image)); + image=SyncNextImageInList(image); + } + + image->matte = matte; + image->compression = compression; + image->columns = dds_info.width; + image->rows = dds_info.height; + image->storage_class = DirectClass; + image->endian = LSBEndian; + image->depth = 8; + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + + if ((decoder)(image, &dds_info, exception) != MagickTrue) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + } + + if (EOFBlob(image) != MagickFalse) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image + *image; + + MagickBooleanType + status, + cubemap = MagickFalse, + volume = MagickFalse, + matte; + + CompressionType + compression; + + DDSInfo + dds_info; + + DDSDecoder + *decoder; + + size_t + n, + num_images; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + + /* + Initialize image structure. + */ + if (ReadDDSInfo(image, &dds_info) != MagickTrue) { + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP) + cubemap = MagickTrue; + + if (dds_info.ddscaps2 & DDSCAPS2_VOLUME && dds_info.depth > 0) + volume = MagickTrue; + + (void) SeekBlob(image, 128, SEEK_SET); + + /* + Determine pixel format + */ + if (dds_info.pixelformat.flags & DDPF_RGB) + { + compression = NoCompression; + if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS) + { + matte = MagickTrue; + decoder = ReadUncompressedRGBA; + } + else + { + matte = MagickTrue; + decoder = ReadUncompressedRGB; + } + } + else if (dds_info.pixelformat.flags & DDPF_LUMINANCE) + { + compression = NoCompression; + if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS) + { + /* Not sure how to handle this */ + ThrowReaderException(CorruptImageError, ""ImageTypeNotSupported""); + } + else + { + matte = MagickFalse; + decoder = ReadUncompressedRGB; + } + } + else if (dds_info.pixelformat.flags & DDPF_FOURCC) + { + switch (dds_info.pixelformat.fourcc) + { + case FOURCC_DXT1: + { + matte = MagickFalse; + compression = DXT1Compression; + decoder = ReadDXT1; + break; + } + case FOURCC_DXT3: + { + matte = MagickTrue; + compression = DXT3Compression; + decoder = ReadDXT3; + break; + } + case FOURCC_DXT5: + { + matte = MagickTrue; + compression = DXT5Compression; + decoder = ReadDXT5; + break; + } + default: + { + /* Unknown FOURCC */ + ThrowReaderException(CorruptImageError, ""ImageTypeNotSupported""); + } + } + } + else + { + /* Neither compressed nor uncompressed... thus unsupported */ + ThrowReaderException(CorruptImageError, ""ImageTypeNotSupported""); + } + + num_images = 1; + if (cubemap) + { + /* + Determine number of faces defined in the cubemap + */ + num_images = 0; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) num_images++; + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) num_images++; + } + + if (volume) + num_images = dds_info.depth; + + for (n = 0; n < num_images; n++) + { + if (n != 0) + { + if (EOFBlob(image) != MagickFalse) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + /* Start a new image */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + return(DestroyImageList(image)); + image=SyncNextImageInList(image); + } + + image->matte = matte; + image->compression = compression; + image->columns = dds_info.width; + image->rows = dds_info.height; + image->storage_class = DirectClass; + image->endian = LSBEndian; + image->depth = 8; + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + + if ((decoder)(image, &dds_info, exception) != MagickTrue) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + } + + if (EOFBlob(image) != MagickFalse) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -1836,6 +1836,8 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) + { + if (n != 0) + { ++ if (EOFBlob(image) != MagickFalse) ++ ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + /* Start a new image */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL)",1259,1495,2048 +5950,"static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur, + struct idpair *idmap) +{ + if (!(rold->live & REG_LIVE_READ)) + /* explored state didn't use this */ + return true; + + if (memcmp(rold, rcur, offsetof(struct bpf_reg_state, live)) == 0) + return true; + + if (rold->type == NOT_INIT) + /* explored state can't have used this */ + return true; + if (rcur->type == NOT_INIT) + return false; + switch (rold->type) { + case SCALAR_VALUE: + if (rcur->type == SCALAR_VALUE) { + /* new val must satisfy old val knowledge */ + return range_within(rold, rcur) && + tnum_in(rold->var_off, rcur->var_off); + } else { + /* We're trying to use a pointer in place of a scalar. + * Even if the scalar was unbounded, this could lead to + * pointer leaks because scalars are allowed to leak + * while pointers are not. We could make this safe in + * special cases if root is calling us, but it's + * probably not worth the hassle. + */ + return false; + } + case PTR_TO_MAP_VALUE: + /* If the new min/max/var_off satisfy the old ones and + * everything else matches, we are OK. + * We don't care about the 'id' value, because nothing + * uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL) + */ + return memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 && + range_within(rold, rcur) && + tnum_in(rold->var_off, rcur->var_off); + case PTR_TO_MAP_VALUE_OR_NULL: + /* a PTR_TO_MAP_VALUE could be safe to use as a + * PTR_TO_MAP_VALUE_OR_NULL into the same map. + * However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL- + * checked, doing so could have affected others with the same + * id, and we can't check for that because we lost the id when + * we converted to a PTR_TO_MAP_VALUE. + */ + if (rcur->type != PTR_TO_MAP_VALUE_OR_NULL) + return false; + if (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id))) + return false; + /* Check our ids match any regs they're supposed to */ + return check_ids(rold->id, rcur->id, idmap); + case PTR_TO_PACKET_META: + case PTR_TO_PACKET: + if (rcur->type != rold->type) + return false; + /* We must have at least as much range as the old ptr + * did, so that any accesses which were safe before are + * still safe. This is true even if old range < old off, + * since someone could have accessed through (ptr - k), or + * even done ptr -= k in a register, to get a safe access. + */ + if (rold->range > rcur->range) + return false; + /* If the offsets don't match, we can't trust our alignment; + * nor can we be sure that we won't fall out of range. + */ + if (rold->off != rcur->off) + return false; + /* id relations must be preserved */ + if (rold->id && !check_ids(rold->id, rcur->id, idmap)) + return false; + /* new val must satisfy old val knowledge */ + return range_within(rold, rcur) && + tnum_in(rold->var_off, rcur->var_off); + case PTR_TO_CTX: + case CONST_PTR_TO_MAP: + case PTR_TO_STACK: + case PTR_TO_PACKET_END: + /* Only valid matches are exact, which memcmp() above + * would have accepted + */ + default: + /* Don't know what's going on, just say it's not safe */ + return false; + } + + /* Shouldn't get here; if we do, say it's not safe */ + WARN_ON_ONCE(1); + return false; +} +",0,"static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur, + struct idpair *idmap) +{ + if (!(rold->live & REG_LIVE_READ)) + /* explored state didn't use this */ + return true; + + if (memcmp(rold, rcur, offsetof(struct bpf_reg_state, live)) == 0) + return true; + + if (rold->type == NOT_INIT) + /* explored state can't have used this */ + return true; + if (rcur->type == NOT_INIT) + return false; + switch (rold->type) { + case SCALAR_VALUE: + if (rcur->type == SCALAR_VALUE) { + /* new val must satisfy old val knowledge */ + return range_within(rold, rcur) && + tnum_in(rold->var_off, rcur->var_off); + } else { + /* We're trying to use a pointer in place of a scalar. + * Even if the scalar was unbounded, this could lead to + * pointer leaks because scalars are allowed to leak + * while pointers are not. We could make this safe in + * special cases if root is calling us, but it's + * probably not worth the hassle. + */ + return false; + } + case PTR_TO_MAP_VALUE: + /* If the new min/max/var_off satisfy the old ones and + * everything else matches, we are OK. + * We don't care about the 'id' value, because nothing + * uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL) + */ + return memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 && + range_within(rold, rcur) && + tnum_in(rold->var_off, rcur->var_off); + case PTR_TO_MAP_VALUE_OR_NULL: + /* a PTR_TO_MAP_VALUE could be safe to use as a + * PTR_TO_MAP_VALUE_OR_NULL into the same map. + * However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL- + * checked, doing so could have affected others with the same + * id, and we can't check for that because we lost the id when + * we converted to a PTR_TO_MAP_VALUE. + */ + if (rcur->type != PTR_TO_MAP_VALUE_OR_NULL) + return false; + if (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id))) + return false; + /* Check our ids match any regs they're supposed to */ + return check_ids(rold->id, rcur->id, idmap); + case PTR_TO_PACKET_META: + case PTR_TO_PACKET: + if (rcur->type != rold->type) + return false; + /* We must have at least as much range as the old ptr + * did, so that any accesses which were safe before are + * still safe. This is true even if old range < old off, + * since someone could have accessed through (ptr - k), or + * even done ptr -= k in a register, to get a safe access. + */ + if (rold->range > rcur->range) + return false; + /* If the offsets don't match, we can't trust our alignment; + * nor can we be sure that we won't fall out of range. + */ + if (rold->off != rcur->off) + return false; + /* id relations must be preserved */ + if (rold->id && !check_ids(rold->id, rcur->id, idmap)) + return false; + /* new val must satisfy old val knowledge */ + return range_within(rold, rcur) && + tnum_in(rold->var_off, rcur->var_off); + case PTR_TO_CTX: + case CONST_PTR_TO_MAP: + case PTR_TO_STACK: + case PTR_TO_PACKET_END: + /* Only valid matches are exact, which memcmp() above + * would have accepted + */ + default: + /* Don't know what's going on, just say it's not safe */ + return false; + } + + /* Shouldn't get here; if we do, say it's not safe */ + WARN_ON_ONCE(1); + return false; +} +","@@ -1819,6 +1819,41 @@ static bool signed_sub_overflows(s64 a, s64 b) + return res > a; + } + ++static bool check_reg_sane_offset(struct bpf_verifier_env *env, ++ const struct bpf_reg_state *reg, ++ enum bpf_reg_type type) ++{ ++ bool known = tnum_is_const(reg->var_off); ++ s64 val = reg->var_off.value; ++ s64 smin = reg->smin_value; ++ ++ if (known && (val >= BPF_MAX_VAR_OFF || val <= -BPF_MAX_VAR_OFF)) { ++ verbose(env, ""math between %s pointer and %lld is not allowed\n"", ++ reg_type_str[type], val); ++ return false; ++ } ++ ++ if (reg->off >= BPF_MAX_VAR_OFF || reg->off <= -BPF_MAX_VAR_OFF) { ++ verbose(env, ""%s pointer offset %d is not allowed\n"", ++ reg_type_str[type], reg->off); ++ return false; ++ } ++ ++ if (smin == S64_MIN) { ++ verbose(env, ""math between %s pointer and register with unbounded min value is not allowed\n"", ++ reg_type_str[type]); ++ return false; ++ } ++ ++ if (smin >= BPF_MAX_VAR_OFF || smin <= -BPF_MAX_VAR_OFF) { ++ verbose(env, ""value %lld makes %s pointer be out of bounds\n"", ++ smin, reg_type_str[type]); ++ return false; ++ } ++ ++ return true; ++} ++ + /* Handles arithmetic on a pointer and a scalar: computes new min/max and var_off. + * Caller should also handle BPF_MOV case separately. + * If we return -EACCES, caller may want to try again treating pointer as a +@@ -1887,6 +1922,10 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, + dst_reg->type = ptr_reg->type; + dst_reg->id = ptr_reg->id; + ++ if (!check_reg_sane_offset(env, off_reg, ptr_reg->type) || ++ !check_reg_sane_offset(env, ptr_reg, ptr_reg->type)) ++ return -EINVAL; ++ + switch (opcode) { + case BPF_ADD: + /* We can take a fixed offset as long as it doesn't overflow +@@ -2017,6 +2056,9 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, + return -EACCES; + } + ++ if (!check_reg_sane_offset(env, dst_reg, ptr_reg->type)) ++ return -EINVAL; ++ + __update_reg_bounds(dst_reg); + __reg_deduce_bounds(dst_reg); + __reg_bound_offset(dst_reg); +@@ -2046,6 +2088,12 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + src_known = tnum_is_const(src_reg.var_off); + dst_known = tnum_is_const(dst_reg->var_off); + ++ if (!src_known && ++ opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND) { ++ __mark_reg_unknown(dst_reg); ++ return 0; ++ } ++ + switch (opcode) { + case BPF_ADD: + if (signed_add_overflows(dst_reg->smin_value, smin_val) ||",918,1154,2048 +6806,"static int do_ip_getsockopt(struct sock *sk, int level, int optname, + char __user *optval, int __user *optlen, unsigned int flags) +{ + struct inet_sock *inet = inet_sk(sk); + bool needs_rtnl = getsockopt_needs_rtnl(optname); + int val, err = 0; + int len; + + if (level != SOL_IP) + return -EOPNOTSUPP; + + if (ip_mroute_opt(optname)) + return ip_mroute_getsockopt(sk, optname, optval, optlen); + + if (get_user(len, optlen)) + return -EFAULT; + if (len < 0) + return -EINVAL; + + if (needs_rtnl) + rtnl_lock(); + lock_sock(sk); + + switch (optname) { + case IP_OPTIONS: + { + unsigned char optbuf[sizeof(struct ip_options)+40]; + struct ip_options *opt = (struct ip_options *)optbuf; + struct ip_options_rcu *inet_opt; + + inet_opt = rcu_dereference_protected(inet->inet_opt, + lockdep_sock_is_held(sk)); + opt->optlen = 0; + if (inet_opt) + memcpy(optbuf, &inet_opt->opt, + sizeof(struct ip_options) + + inet_opt->opt.optlen); + release_sock(sk); + + if (opt->optlen == 0) + return put_user(0, optlen); + + ip_options_undo(opt); + + len = min_t(unsigned int, len, opt->optlen); + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, opt->__data, len)) + return -EFAULT; + return 0; + } + case IP_PKTINFO: + val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0; + break; + case IP_RECVTTL: + val = (inet->cmsg_flags & IP_CMSG_TTL) != 0; + break; + case IP_RECVTOS: + val = (inet->cmsg_flags & IP_CMSG_TOS) != 0; + break; + case IP_RECVOPTS: + val = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0; + break; + case IP_RETOPTS: + val = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0; + break; + case IP_PASSSEC: + val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0; + break; + case IP_RECVORIGDSTADDR: + val = (inet->cmsg_flags & IP_CMSG_ORIGDSTADDR) != 0; + break; + case IP_CHECKSUM: + val = (inet->cmsg_flags & IP_CMSG_CHECKSUM) != 0; + break; + case IP_RECVFRAGSIZE: + val = (inet->cmsg_flags & IP_CMSG_RECVFRAGSIZE) != 0; + break; + case IP_TOS: + val = inet->tos; + break; + case IP_TTL: + { + struct net *net = sock_net(sk); + val = (inet->uc_ttl == -1 ? + net->ipv4.sysctl_ip_default_ttl : + inet->uc_ttl); + break; + } + case IP_HDRINCL: + val = inet->hdrincl; + break; + case IP_NODEFRAG: + val = inet->nodefrag; + break; + case IP_BIND_ADDRESS_NO_PORT: + val = inet->bind_address_no_port; + break; + case IP_MTU_DISCOVER: + val = inet->pmtudisc; + break; + case IP_MTU: + { + struct dst_entry *dst; + val = 0; + dst = sk_dst_get(sk); + if (dst) { + val = dst_mtu(dst); + dst_release(dst); + } + if (!val) { + release_sock(sk); + return -ENOTCONN; + } + break; + } + case IP_RECVERR: + val = inet->recverr; + break; + case IP_MULTICAST_TTL: + val = inet->mc_ttl; + break; + case IP_MULTICAST_LOOP: + val = inet->mc_loop; + break; + case IP_UNICAST_IF: + val = (__force int)htonl((__u32) inet->uc_index); + break; + case IP_MULTICAST_IF: + { + struct in_addr addr; + len = min_t(unsigned int, len, sizeof(struct in_addr)); + addr.s_addr = inet->mc_addr; + release_sock(sk); + + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, &addr, len)) + return -EFAULT; + return 0; + } + case IP_MSFILTER: + { + struct ip_msfilter msf; + + if (len < IP_MSFILTER_SIZE(0)) { + err = -EINVAL; + goto out; + } + if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) { + err = -EFAULT; + goto out; + } + err = ip_mc_msfget(sk, &msf, + (struct ip_msfilter __user *)optval, optlen); + goto out; + } + case MCAST_MSFILTER: + { + struct group_filter gsf; + + if (len < GROUP_FILTER_SIZE(0)) { + err = -EINVAL; + goto out; + } + if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) { + err = -EFAULT; + goto out; + } + err = ip_mc_gsfget(sk, &gsf, + (struct group_filter __user *)optval, + optlen); + goto out; + } + case IP_MULTICAST_ALL: + val = inet->mc_all; + break; + case IP_PKTOPTIONS: + { + struct msghdr msg; + + release_sock(sk); + + if (sk->sk_type != SOCK_STREAM) + return -ENOPROTOOPT; + + msg.msg_control = (__force void *) optval; + msg.msg_controllen = len; + msg.msg_flags = flags; + + if (inet->cmsg_flags & IP_CMSG_PKTINFO) { + struct in_pktinfo info; + + info.ipi_addr.s_addr = inet->inet_rcv_saddr; + info.ipi_spec_dst.s_addr = inet->inet_rcv_saddr; + info.ipi_ifindex = inet->mc_index; + put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); + } + if (inet->cmsg_flags & IP_CMSG_TTL) { + int hlim = inet->mc_ttl; + put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim); + } + if (inet->cmsg_flags & IP_CMSG_TOS) { + int tos = inet->rcv_tos; + put_cmsg(&msg, SOL_IP, IP_TOS, sizeof(tos), &tos); + } + len -= msg.msg_controllen; + return put_user(len, optlen); + } + case IP_FREEBIND: + val = inet->freebind; + break; + case IP_TRANSPARENT: + val = inet->transparent; + break; + case IP_MINTTL: + val = inet->min_ttl; + break; + default: + release_sock(sk); + return -ENOPROTOOPT; + } + release_sock(sk); + + if (len < sizeof(int) && len > 0 && val >= 0 && val <= 255) { + unsigned char ucval = (unsigned char)val; + len = 1; + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, &ucval, 1)) + return -EFAULT; + } else { + len = min_t(unsigned int, sizeof(int), len); + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, &val, len)) + return -EFAULT; + } + return 0; + +out: + release_sock(sk); + if (needs_rtnl) + rtnl_unlock(); + return err; +} +",0,"static int do_ip_getsockopt(struct sock *sk, int level, int optname, + char __user *optval, int __user *optlen, unsigned int flags) +{ + struct inet_sock *inet = inet_sk(sk); + bool needs_rtnl = getsockopt_needs_rtnl(optname); + int val, err = 0; + int len; + + if (level != SOL_IP) + return -EOPNOTSUPP; + + if (ip_mroute_opt(optname)) + return ip_mroute_getsockopt(sk, optname, optval, optlen); + + if (get_user(len, optlen)) + return -EFAULT; + if (len < 0) + return -EINVAL; + + if (needs_rtnl) + rtnl_lock(); + lock_sock(sk); + + switch (optname) { + case IP_OPTIONS: + { + unsigned char optbuf[sizeof(struct ip_options)+40]; + struct ip_options *opt = (struct ip_options *)optbuf; + struct ip_options_rcu *inet_opt; + + inet_opt = rcu_dereference_protected(inet->inet_opt, + lockdep_sock_is_held(sk)); + opt->optlen = 0; + if (inet_opt) + memcpy(optbuf, &inet_opt->opt, + sizeof(struct ip_options) + + inet_opt->opt.optlen); + release_sock(sk); + + if (opt->optlen == 0) + return put_user(0, optlen); + + ip_options_undo(opt); + + len = min_t(unsigned int, len, opt->optlen); + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, opt->__data, len)) + return -EFAULT; + return 0; + } + case IP_PKTINFO: + val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0; + break; + case IP_RECVTTL: + val = (inet->cmsg_flags & IP_CMSG_TTL) != 0; + break; + case IP_RECVTOS: + val = (inet->cmsg_flags & IP_CMSG_TOS) != 0; + break; + case IP_RECVOPTS: + val = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0; + break; + case IP_RETOPTS: + val = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0; + break; + case IP_PASSSEC: + val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0; + break; + case IP_RECVORIGDSTADDR: + val = (inet->cmsg_flags & IP_CMSG_ORIGDSTADDR) != 0; + break; + case IP_CHECKSUM: + val = (inet->cmsg_flags & IP_CMSG_CHECKSUM) != 0; + break; + case IP_RECVFRAGSIZE: + val = (inet->cmsg_flags & IP_CMSG_RECVFRAGSIZE) != 0; + break; + case IP_TOS: + val = inet->tos; + break; + case IP_TTL: + { + struct net *net = sock_net(sk); + val = (inet->uc_ttl == -1 ? + net->ipv4.sysctl_ip_default_ttl : + inet->uc_ttl); + break; + } + case IP_HDRINCL: + val = inet->hdrincl; + break; + case IP_NODEFRAG: + val = inet->nodefrag; + break; + case IP_BIND_ADDRESS_NO_PORT: + val = inet->bind_address_no_port; + break; + case IP_MTU_DISCOVER: + val = inet->pmtudisc; + break; + case IP_MTU: + { + struct dst_entry *dst; + val = 0; + dst = sk_dst_get(sk); + if (dst) { + val = dst_mtu(dst); + dst_release(dst); + } + if (!val) { + release_sock(sk); + return -ENOTCONN; + } + break; + } + case IP_RECVERR: + val = inet->recverr; + break; + case IP_MULTICAST_TTL: + val = inet->mc_ttl; + break; + case IP_MULTICAST_LOOP: + val = inet->mc_loop; + break; + case IP_UNICAST_IF: + val = (__force int)htonl((__u32) inet->uc_index); + break; + case IP_MULTICAST_IF: + { + struct in_addr addr; + len = min_t(unsigned int, len, sizeof(struct in_addr)); + addr.s_addr = inet->mc_addr; + release_sock(sk); + + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, &addr, len)) + return -EFAULT; + return 0; + } + case IP_MSFILTER: + { + struct ip_msfilter msf; + + if (len < IP_MSFILTER_SIZE(0)) { + err = -EINVAL; + goto out; + } + if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) { + err = -EFAULT; + goto out; + } + err = ip_mc_msfget(sk, &msf, + (struct ip_msfilter __user *)optval, optlen); + goto out; + } + case MCAST_MSFILTER: + { + struct group_filter gsf; + + if (len < GROUP_FILTER_SIZE(0)) { + err = -EINVAL; + goto out; + } + if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) { + err = -EFAULT; + goto out; + } + err = ip_mc_gsfget(sk, &gsf, + (struct group_filter __user *)optval, + optlen); + goto out; + } + case IP_MULTICAST_ALL: + val = inet->mc_all; + break; + case IP_PKTOPTIONS: + { + struct msghdr msg; + + release_sock(sk); + + if (sk->sk_type != SOCK_STREAM) + return -ENOPROTOOPT; + + msg.msg_control = (__force void *) optval; + msg.msg_controllen = len; + msg.msg_flags = flags; + + if (inet->cmsg_flags & IP_CMSG_PKTINFO) { + struct in_pktinfo info; + + info.ipi_addr.s_addr = inet->inet_rcv_saddr; + info.ipi_spec_dst.s_addr = inet->inet_rcv_saddr; + info.ipi_ifindex = inet->mc_index; + put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); + } + if (inet->cmsg_flags & IP_CMSG_TTL) { + int hlim = inet->mc_ttl; + put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim); + } + if (inet->cmsg_flags & IP_CMSG_TOS) { + int tos = inet->rcv_tos; + put_cmsg(&msg, SOL_IP, IP_TOS, sizeof(tos), &tos); + } + len -= msg.msg_controllen; + return put_user(len, optlen); + } + case IP_FREEBIND: + val = inet->freebind; + break; + case IP_TRANSPARENT: + val = inet->transparent; + break; + case IP_MINTTL: + val = inet->min_ttl; + break; + default: + release_sock(sk); + return -ENOPROTOOPT; + } + release_sock(sk); + + if (len < sizeof(int) && len > 0 && val >= 0 && val <= 255) { + unsigned char ucval = (unsigned char)val; + len = 1; + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, &ucval, 1)) + return -EFAULT; + } else { + len = min_t(unsigned int, sizeof(int), len); + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, &val, len)) + return -EFAULT; + } + return 0; + +out: + release_sock(sk); + if (needs_rtnl) + rtnl_unlock(); + return err; +} +","@@ -116,10 +116,10 @@ static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb, + if (skb->ip_summed != CHECKSUM_COMPLETE) + return; + +- if (offset != 0) +- csum = csum_sub(csum, +- csum_partial(skb_transport_header(skb) + tlen, +- offset, 0)); ++ if (offset != 0) { ++ int tend_off = skb_transport_offset(skb) + tlen; ++ csum = csum_sub(csum, skb_checksum(skb, tend_off, offset, 0)); ++ } + + put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum); + }",1775,2011,2048 +5703,"static void ext4_put_super(struct super_block *sb) +{ + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_super_block *es = sbi->s_es; + int i, err; + + ext4_unregister_li_request(sb); + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + + flush_workqueue(sbi->rsv_conversion_wq); + destroy_workqueue(sbi->rsv_conversion_wq); + + if (sbi->s_journal) { + err = jbd2_journal_destroy(sbi->s_journal); + sbi->s_journal = NULL; + if (err < 0) + ext4_abort(sb, ""Couldn't clean up the journal""); + } + + ext4_unregister_sysfs(sb); + ext4_es_unregister_shrinker(sbi); + del_timer_sync(&sbi->s_err_report); + ext4_release_system_zone(sb); + ext4_mb_release(sb); + ext4_ext_release(sb); + ext4_xattr_put_super(sb); + + if (!(sb->s_flags & MS_RDONLY)) { + ext4_clear_feature_journal_needs_recovery(sb); + es->s_state = cpu_to_le16(sbi->s_mount_state); + } + if (!(sb->s_flags & MS_RDONLY)) + ext4_commit_super(sb, 1); + + for (i = 0; i < sbi->s_gdb_count; i++) + brelse(sbi->s_group_desc[i]); + kvfree(sbi->s_group_desc); + kvfree(sbi->s_flex_groups); + percpu_counter_destroy(&sbi->s_freeclusters_counter); + percpu_counter_destroy(&sbi->s_freeinodes_counter); + percpu_counter_destroy(&sbi->s_dirs_counter); + percpu_counter_destroy(&sbi->s_dirtyclusters_counter); + brelse(sbi->s_sbh); +#ifdef CONFIG_QUOTA + for (i = 0; i < EXT4_MAXQUOTAS; i++) + kfree(sbi->s_qf_names[i]); +#endif + + /* Debugging code just in case the in-memory inode orphan list + * isn't empty. The on-disk one can be non-empty if we've + * detected an error and taken the fs readonly, but the + * in-memory list had better be clean by this point. */ + if (!list_empty(&sbi->s_orphan)) + dump_orphan_list(sb, sbi); + J_ASSERT(list_empty(&sbi->s_orphan)); + + sync_blockdev(sb->s_bdev); + invalidate_bdev(sb->s_bdev); + if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) { + /* + * Invalidate the journal device's buffers. We don't want them + * floating about in memory - the physical journal device may + * hotswapped, and it breaks the `ro-after' testing code. + */ + sync_blockdev(sbi->journal_bdev); + invalidate_bdev(sbi->journal_bdev); + ext4_blkdev_remove(sbi); + } + if (sbi->s_mb_cache) { + ext4_xattr_destroy_cache(sbi->s_mb_cache); + sbi->s_mb_cache = NULL; + } + if (sbi->s_mmp_tsk) + kthread_stop(sbi->s_mmp_tsk); + sb->s_fs_info = NULL; + /* + * Now that we are completely done shutting down the + * superblock, we need to actually destroy the kobject. + */ + kobject_put(&sbi->s_kobj); + wait_for_completion(&sbi->s_kobj_unregister); + if (sbi->s_chksum_driver) + crypto_free_shash(sbi->s_chksum_driver); + kfree(sbi->s_blockgroup_lock); + kfree(sbi); +} +",0,"static void ext4_put_super(struct super_block *sb) +{ + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_super_block *es = sbi->s_es; + int i, err; + + ext4_unregister_li_request(sb); + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + + flush_workqueue(sbi->rsv_conversion_wq); + destroy_workqueue(sbi->rsv_conversion_wq); + + if (sbi->s_journal) { + err = jbd2_journal_destroy(sbi->s_journal); + sbi->s_journal = NULL; + if (err < 0) + ext4_abort(sb, ""Couldn't clean up the journal""); + } + + ext4_unregister_sysfs(sb); + ext4_es_unregister_shrinker(sbi); + del_timer_sync(&sbi->s_err_report); + ext4_release_system_zone(sb); + ext4_mb_release(sb); + ext4_ext_release(sb); + ext4_xattr_put_super(sb); + + if (!(sb->s_flags & MS_RDONLY)) { + ext4_clear_feature_journal_needs_recovery(sb); + es->s_state = cpu_to_le16(sbi->s_mount_state); + } + if (!(sb->s_flags & MS_RDONLY)) + ext4_commit_super(sb, 1); + + for (i = 0; i < sbi->s_gdb_count; i++) + brelse(sbi->s_group_desc[i]); + kvfree(sbi->s_group_desc); + kvfree(sbi->s_flex_groups); + percpu_counter_destroy(&sbi->s_freeclusters_counter); + percpu_counter_destroy(&sbi->s_freeinodes_counter); + percpu_counter_destroy(&sbi->s_dirs_counter); + percpu_counter_destroy(&sbi->s_dirtyclusters_counter); + brelse(sbi->s_sbh); +#ifdef CONFIG_QUOTA + for (i = 0; i < EXT4_MAXQUOTAS; i++) + kfree(sbi->s_qf_names[i]); +#endif + + /* Debugging code just in case the in-memory inode orphan list + * isn't empty. The on-disk one can be non-empty if we've + * detected an error and taken the fs readonly, but the + * in-memory list had better be clean by this point. */ + if (!list_empty(&sbi->s_orphan)) + dump_orphan_list(sb, sbi); + J_ASSERT(list_empty(&sbi->s_orphan)); + + sync_blockdev(sb->s_bdev); + invalidate_bdev(sb->s_bdev); + if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) { + /* + * Invalidate the journal device's buffers. We don't want them + * floating about in memory - the physical journal device may + * hotswapped, and it breaks the `ro-after' testing code. + */ + sync_blockdev(sbi->journal_bdev); + invalidate_bdev(sbi->journal_bdev); + ext4_blkdev_remove(sbi); + } + if (sbi->s_mb_cache) { + ext4_xattr_destroy_cache(sbi->s_mb_cache); + sbi->s_mb_cache = NULL; + } + if (sbi->s_mmp_tsk) + kthread_stop(sbi->s_mmp_tsk); + sb->s_fs_info = NULL; + /* + * Now that we are completely done shutting down the + * superblock, we need to actually destroy the kobject. + */ + kobject_put(&sbi->s_kobj); + wait_for_completion(&sbi->s_kobj_unregister); + if (sbi->s_chksum_driver) + crypto_free_shash(sbi->s_chksum_driver); + kfree(sbi->s_blockgroup_lock); + kfree(sbi); +} +","@@ -958,6 +958,7 @@ static void init_once(void *foo) + INIT_LIST_HEAD(&ei->i_orphan); + init_rwsem(&ei->xattr_sem); + init_rwsem(&ei->i_data_sem); ++ init_rwsem(&ei->i_mmap_sem); + inode_init_once(&ei->vfs_inode); + } + ",813,1049,2048 +5719,"static void process_mpa_reply(struct iwch_ep *ep, struct sk_buff *skb) +{ + struct mpa_message *mpa; + u16 plen; + struct iwch_qp_attributes attrs; + enum iwch_qp_attr_mask mask; + int err; + + PDBG(""%s ep %p\n"", __func__, ep); + + /* + * Stop mpa timer. If it expired, then the state has + * changed and we bail since ep_timeout already aborted + * the connection. + */ + stop_ep_timer(ep); + if (state_read(&ep->com) != MPA_REQ_SENT) + return; + + /* + * If we get more than the supported amount of private data + * then we must fail this connection. + */ + if (ep->mpa_pkt_len + skb->len > sizeof(ep->mpa_pkt)) { + err = -EINVAL; + goto err; + } + + /* + * copy the new data into our accumulation buffer. + */ + skb_copy_from_linear_data(skb, &(ep->mpa_pkt[ep->mpa_pkt_len]), + skb->len); + ep->mpa_pkt_len += skb->len; + + /* + * if we don't even have the mpa message, then bail. + */ + if (ep->mpa_pkt_len < sizeof(*mpa)) + return; + mpa = (struct mpa_message *) ep->mpa_pkt; + + /* Validate MPA header. */ + if (mpa->revision != mpa_rev) { + err = -EPROTO; + goto err; + } + if (memcmp(mpa->key, MPA_KEY_REP, sizeof(mpa->key))) { + err = -EPROTO; + goto err; + } + + plen = ntohs(mpa->private_data_size); + + /* + * Fail if there's too much private data. + */ + if (plen > MPA_MAX_PRIVATE_DATA) { + err = -EPROTO; + goto err; + } + + /* + * If plen does not account for pkt size + */ + if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) { + err = -EPROTO; + goto err; + } + + ep->plen = (u8) plen; + + /* + * If we don't have all the pdata yet, then bail. + * We'll continue process when more data arrives. + */ + if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) + return; + + if (mpa->flags & MPA_REJECT) { + err = -ECONNREFUSED; + goto err; + } + + /* + * If we get here we have accumulated the entire mpa + * start reply message including private data. And + * the MPA header is valid. + */ + state_set(&ep->com, FPDU_MODE); + ep->mpa_attr.initiator = 1; + ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; + ep->mpa_attr.recv_marker_enabled = markers_enabled; + ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0; + ep->mpa_attr.version = mpa_rev; + PDBG(""%s - crc_enabled=%d, recv_marker_enabled=%d, "" + ""xmit_marker_enabled=%d, version=%d\n"", __func__, + ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled, + ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version); + + attrs.mpa_attr = ep->mpa_attr; + attrs.max_ird = ep->ird; + attrs.max_ord = ep->ord; + attrs.llp_stream_handle = ep; + attrs.next_state = IWCH_QP_STATE_RTS; + + mask = IWCH_QP_ATTR_NEXT_STATE | + IWCH_QP_ATTR_LLP_STREAM_HANDLE | IWCH_QP_ATTR_MPA_ATTR | + IWCH_QP_ATTR_MAX_IRD | IWCH_QP_ATTR_MAX_ORD; + + /* bind QP and TID with INIT_WR */ + err = iwch_modify_qp(ep->com.qp->rhp, + ep->com.qp, mask, &attrs, 1); + if (err) + goto err; + + if (peer2peer && iwch_rqes_posted(ep->com.qp) == 0) { + iwch_post_zb_read(ep); + } + + goto out; +err: + abort_connection(ep, skb, GFP_KERNEL); +out: + connect_reply_upcall(ep, err); + return; +} +",0,"static void process_mpa_reply(struct iwch_ep *ep, struct sk_buff *skb) +{ + struct mpa_message *mpa; + u16 plen; + struct iwch_qp_attributes attrs; + enum iwch_qp_attr_mask mask; + int err; + + PDBG(""%s ep %p\n"", __func__, ep); + + /* + * Stop mpa timer. If it expired, then the state has + * changed and we bail since ep_timeout already aborted + * the connection. + */ + stop_ep_timer(ep); + if (state_read(&ep->com) != MPA_REQ_SENT) + return; + + /* + * If we get more than the supported amount of private data + * then we must fail this connection. + */ + if (ep->mpa_pkt_len + skb->len > sizeof(ep->mpa_pkt)) { + err = -EINVAL; + goto err; + } + + /* + * copy the new data into our accumulation buffer. + */ + skb_copy_from_linear_data(skb, &(ep->mpa_pkt[ep->mpa_pkt_len]), + skb->len); + ep->mpa_pkt_len += skb->len; + + /* + * if we don't even have the mpa message, then bail. + */ + if (ep->mpa_pkt_len < sizeof(*mpa)) + return; + mpa = (struct mpa_message *) ep->mpa_pkt; + + /* Validate MPA header. */ + if (mpa->revision != mpa_rev) { + err = -EPROTO; + goto err; + } + if (memcmp(mpa->key, MPA_KEY_REP, sizeof(mpa->key))) { + err = -EPROTO; + goto err; + } + + plen = ntohs(mpa->private_data_size); + + /* + * Fail if there's too much private data. + */ + if (plen > MPA_MAX_PRIVATE_DATA) { + err = -EPROTO; + goto err; + } + + /* + * If plen does not account for pkt size + */ + if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) { + err = -EPROTO; + goto err; + } + + ep->plen = (u8) plen; + + /* + * If we don't have all the pdata yet, then bail. + * We'll continue process when more data arrives. + */ + if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) + return; + + if (mpa->flags & MPA_REJECT) { + err = -ECONNREFUSED; + goto err; + } + + /* + * If we get here we have accumulated the entire mpa + * start reply message including private data. And + * the MPA header is valid. + */ + state_set(&ep->com, FPDU_MODE); + ep->mpa_attr.initiator = 1; + ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; + ep->mpa_attr.recv_marker_enabled = markers_enabled; + ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0; + ep->mpa_attr.version = mpa_rev; + PDBG(""%s - crc_enabled=%d, recv_marker_enabled=%d, "" + ""xmit_marker_enabled=%d, version=%d\n"", __func__, + ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled, + ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version); + + attrs.mpa_attr = ep->mpa_attr; + attrs.max_ird = ep->ird; + attrs.max_ord = ep->ord; + attrs.llp_stream_handle = ep; + attrs.next_state = IWCH_QP_STATE_RTS; + + mask = IWCH_QP_ATTR_NEXT_STATE | + IWCH_QP_ATTR_LLP_STREAM_HANDLE | IWCH_QP_ATTR_MPA_ATTR | + IWCH_QP_ATTR_MAX_IRD | IWCH_QP_ATTR_MAX_ORD; + + /* bind QP and TID with INIT_WR */ + err = iwch_modify_qp(ep->com.qp->rhp, + ep->com.qp, mask, &attrs, 1); + if (err) + goto err; + + if (peer2peer && iwch_rqes_posted(ep->com.qp) == 0) { + iwch_post_zb_read(ep); + } + + goto out; +err: + abort_connection(ep, skb, GFP_KERNEL); +out: + connect_reply_upcall(ep, err); + return; +} +","@@ -149,7 +149,7 @@ static int iwch_l2t_send(struct t3cdev *tdev, struct sk_buff *skb, struct l2t_en + error = l2t_send(tdev, skb, l2e); + if (error < 0) + kfree_skb(skb); +- return error; ++ return error < 0 ? error : 0; + } + + int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb) +@@ -165,7 +165,7 @@ int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb) + error = cxgb3_ofld_send(tdev, skb); + if (error < 0) + kfree_skb(skb); +- return error; ++ return error < 0 ? error : 0; + } + + static void release_tid(struct t3cdev *tdev, u32 hwtid, struct sk_buff *skb)",972,1208,2048 +10274,"void Browser::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + switch (type.value) { + case NotificationType::TAB_CONTENTS_DISCONNECTED: + if (is_attempting_to_close_browser_) { + ClearUnloadState(Source(source).ptr(), false); + } + break; + + case NotificationType::SSL_VISIBLE_STATE_CHANGED: + if (GetSelectedTabContents() && + &GetSelectedTabContents()->controller() == + Source(source).ptr()) + UpdateToolbar(false); + break; + + case NotificationType::EXTENSION_UPDATE_DISABLED: { + Profile* profile = Source(source).ptr(); + if (profile_->IsSameProfile(profile)) { + ExtensionService* service = profile->GetExtensionService(); + DCHECK(service); + const Extension* extension = Details(details).ptr(); + if (service->extension_prefs()->DidExtensionEscalatePermissions( + extension->id())) + ShowExtensionDisabledUI(service, profile_, extension); + } + break; + } + + case NotificationType::EXTENSION_UNLOADED: { + window()->GetLocationBar()->UpdatePageActions(); + + const Extension* extension = + Details(details)->extension; + TabStripModel* model = tab_handler_->GetTabStripModel(); + for (int i = model->count() - 1; i >= 0; --i) { + TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); + if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && + tc->GetURL().host() == extension->id()) { + CloseTabContents(tc); + } + } + + break; + } + + case NotificationType::EXTENSION_PROCESS_TERMINATED: { + window()->GetLocationBar()->InvalidatePageActions(); + break; + } + + case NotificationType::EXTENSION_UNINSTALLED: + case NotificationType::EXTENSION_LOADED: + window()->GetLocationBar()->UpdatePageActions(); + break; + + case NotificationType::BROWSER_THEME_CHANGED: + window()->UserChangedTheme(); + break; + + case NotificationType::EXTENSION_READY_FOR_INSTALL: { + if (BrowserList::FindBrowserWithType(profile(), + Browser::TYPE_NORMAL, + true) != this) + break; + + GURL download_url = *(Details(details).ptr()); + if (ExtensionService::IsDownloadFromMiniGallery(download_url)) + window()->ShowThemeInstallBubble(); + break; + } + + case NotificationType::PREF_CHANGED: { + const std::string& pref_name = *Details(details).ptr(); + if (pref_name == prefs::kUseVerticalTabs) { + UseVerticalTabsChanged(); + } else if (pref_name == prefs::kPrintingEnabled) { + UpdatePrintingState(GetContentRestrictionsForSelectedTab()); + } else if (pref_name == prefs::kInstantEnabled) { + if (!InstantController::IsEnabled(profile())) { + if (instant()) { + instant()->DestroyPreviewContents(); + instant_.reset(); + instant_unload_handler_.reset(); + } + } else { + CreateInstantIfNecessary(); + } + } else if (pref_name == prefs::kDevToolsDisabled) { + UpdateCommandsForDevTools(); + if (dev_tools_disabled_.GetValue()) + g_browser_process->devtools_manager()->CloseAllClientHosts(); + } else if (pref_name == prefs::kIncognitoEnabled) { + break; // No further action is required. + } else if (pref_name == prefs::kEditBookmarksEnabled) { + UpdateCommandsForBookmarkEditing(); + } else { + NOTREACHED(); + } + break; + } + + default: + NOTREACHED() << ""Got a notification we didn't register for.""; + } +} +",0,"void Browser::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + switch (type.value) { + case NotificationType::TAB_CONTENTS_DISCONNECTED: + if (is_attempting_to_close_browser_) { + ClearUnloadState(Source(source).ptr(), false); + } + break; + + case NotificationType::SSL_VISIBLE_STATE_CHANGED: + if (GetSelectedTabContents() && + &GetSelectedTabContents()->controller() == + Source(source).ptr()) + UpdateToolbar(false); + break; + + case NotificationType::EXTENSION_UPDATE_DISABLED: { + Profile* profile = Source(source).ptr(); + if (profile_->IsSameProfile(profile)) { + ExtensionService* service = profile->GetExtensionService(); + DCHECK(service); + const Extension* extension = Details(details).ptr(); + if (service->extension_prefs()->DidExtensionEscalatePermissions( + extension->id())) + ShowExtensionDisabledUI(service, profile_, extension); + } + break; + } + + case NotificationType::EXTENSION_UNLOADED: { + window()->GetLocationBar()->UpdatePageActions(); + + const Extension* extension = + Details(details)->extension; + TabStripModel* model = tab_handler_->GetTabStripModel(); + for (int i = model->count() - 1; i >= 0; --i) { + TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); + if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && + tc->GetURL().host() == extension->id()) { + CloseTabContents(tc); + } + } + + break; + } + + case NotificationType::EXTENSION_PROCESS_TERMINATED: { + window()->GetLocationBar()->InvalidatePageActions(); + break; + } + + case NotificationType::EXTENSION_UNINSTALLED: + case NotificationType::EXTENSION_LOADED: + window()->GetLocationBar()->UpdatePageActions(); + break; + + case NotificationType::BROWSER_THEME_CHANGED: + window()->UserChangedTheme(); + break; + + case NotificationType::EXTENSION_READY_FOR_INSTALL: { + if (BrowserList::FindBrowserWithType(profile(), + Browser::TYPE_NORMAL, + true) != this) + break; + + GURL download_url = *(Details(details).ptr()); + if (ExtensionService::IsDownloadFromMiniGallery(download_url)) + window()->ShowThemeInstallBubble(); + break; + } + + case NotificationType::PREF_CHANGED: { + const std::string& pref_name = *Details(details).ptr(); + if (pref_name == prefs::kUseVerticalTabs) { + UseVerticalTabsChanged(); + } else if (pref_name == prefs::kPrintingEnabled) { + UpdatePrintingState(GetContentRestrictionsForSelectedTab()); + } else if (pref_name == prefs::kInstantEnabled) { + if (!InstantController::IsEnabled(profile())) { + if (instant()) { + instant()->DestroyPreviewContents(); + instant_.reset(); + instant_unload_handler_.reset(); + } + } else { + CreateInstantIfNecessary(); + } + } else if (pref_name == prefs::kDevToolsDisabled) { + UpdateCommandsForDevTools(); + if (dev_tools_disabled_.GetValue()) + g_browser_process->devtools_manager()->CloseAllClientHosts(); + } else if (pref_name == prefs::kIncognitoEnabled) { + break; // No further action is required. + } else if (pref_name == prefs::kEditBookmarksEnabled) { + UpdateCommandsForBookmarkEditing(); + } else { + NOTREACHED(); + } + break; + } + + default: + NOTREACHED() << ""Got a notification we didn't register for.""; + } +} +","@@ -2635,16 +2635,25 @@ bool Browser::CanReloadContents(TabContents* source) const { + return type() != TYPE_DEVTOOLS; + } + +-bool Browser::CanCloseContentsAt(int index) { +- if (!CanCloseTab()) ++bool Browser::CanCloseContents(std::vector* indices) { ++ DCHECK(!indices->empty()); ++ TabCloseableStateWatcher* watcher = ++ g_browser_process->tab_closeable_state_watcher(); ++ bool can_close_all = !watcher || watcher->CanCloseTabs(this, indices); ++ if (indices->empty()) // Cannot close any tab. + return false; +- if (tab_handler_->GetTabStripModel()->count() > 1) +- return true; +- // We are closing the last tab for this browser. Make sure to check for ++ // Now, handle cases where at least one tab can be closed. ++ // If we are closing all the tabs for this browser, make sure to check for + // in-progress downloads. + // Note that the next call when it returns false will ask the user for + // confirmation before closing the browser if the user decides so. +- return CanCloseWithInProgressDownloads(); ++ if (tab_handler_->GetTabStripModel()->count() == ++ static_cast(indices->size()) && ++ !CanCloseWithInProgressDownloads()) { ++ indices->clear(); ++ can_close_all = false; ++ } ++ return can_close_all; + } + + bool Browser::CanBookmarkAllTabs() const {",807,1043,2048 +4872,"void t2p_read_tiff_size(T2P* t2p, TIFF* input){ + + uint64* sbc=NULL; +#if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT) + unsigned char* jpt=NULL; + tstrip_t i=0; + tstrip_t stripcount=0; +#endif + uint64 k = 0; + + if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ +#ifdef CCITT_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_G4 ){ + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + t2p->tiff_datasize=(tmsize_t)sbc[0]; + return; + } +#endif +#ifdef ZIP_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + t2p->tiff_datasize=(tmsize_t)sbc[0]; + return; + } +#endif +#ifdef OJPEG_SUPPORT + if(t2p->tiff_compression == COMPRESSION_OJPEG){ + if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ + TIFFError(TIFF2PDF_MODULE, + ""Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS"", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + stripcount=TIFFNumberOfStrips(input); + for(i=0;itiff_dataoffset))){ + if(t2p->tiff_dataoffset != 0){ + if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){ + if((uint64)t2p->tiff_datasize < k) { + TIFFWarning(TIFF2PDF_MODULE, + ""Input file %s has short JPEG interchange file byte count"", + TIFFFileName(input)); + t2p->pdf_ojpegiflength=t2p->tiff_datasize; + k = checkAdd64(k, t2p->tiff_datasize, t2p); + k = checkAdd64(k, 6, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } + return; + }else { + TIFFError(TIFF2PDF_MODULE, + ""Input file %s missing field: TIFFTAG_JPEGIFBYTECOUNT"", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } + } + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, 2048, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } +#endif +#ifdef JPEG_SUPPORT + if(t2p->tiff_compression == COMPRESSION_JPEG) { + uint32 count = 0; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){ + if(count > 4){ + k += count; + k -= 2; /* don't use EOI of header */ + } + } else { + k = 2; /* SOI for first strip */ + } + stripcount=TIFFNumberOfStrips(input); + if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ + TIFFError(TIFF2PDF_MODULE, + ""Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS"", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + for(i=0;itiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } +#endif + (void) 0; + } + k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p); + if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ + k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); + } + if (k == 0) { + /* Assume we had overflow inside TIFFScanlineSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } + + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + + return; +} +",0,"void t2p_read_tiff_size(T2P* t2p, TIFF* input){ + + uint64* sbc=NULL; +#if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT) + unsigned char* jpt=NULL; + tstrip_t i=0; + tstrip_t stripcount=0; +#endif + uint64 k = 0; + + if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ +#ifdef CCITT_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_G4 ){ + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + t2p->tiff_datasize=(tmsize_t)sbc[0]; + return; + } +#endif +#ifdef ZIP_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + t2p->tiff_datasize=(tmsize_t)sbc[0]; + return; + } +#endif +#ifdef OJPEG_SUPPORT + if(t2p->tiff_compression == COMPRESSION_OJPEG){ + if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ + TIFFError(TIFF2PDF_MODULE, + ""Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS"", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + stripcount=TIFFNumberOfStrips(input); + for(i=0;itiff_dataoffset))){ + if(t2p->tiff_dataoffset != 0){ + if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){ + if((uint64)t2p->tiff_datasize < k) { + TIFFWarning(TIFF2PDF_MODULE, + ""Input file %s has short JPEG interchange file byte count"", + TIFFFileName(input)); + t2p->pdf_ojpegiflength=t2p->tiff_datasize; + k = checkAdd64(k, t2p->tiff_datasize, t2p); + k = checkAdd64(k, 6, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } + return; + }else { + TIFFError(TIFF2PDF_MODULE, + ""Input file %s missing field: TIFFTAG_JPEGIFBYTECOUNT"", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } + } + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, 2048, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } +#endif +#ifdef JPEG_SUPPORT + if(t2p->tiff_compression == COMPRESSION_JPEG) { + uint32 count = 0; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){ + if(count > 4){ + k += count; + k -= 2; /* don't use EOI of header */ + } + } else { + k = 2; /* SOI for first strip */ + } + stripcount=TIFFNumberOfStrips(input); + if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ + TIFFError(TIFF2PDF_MODULE, + ""Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS"", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + for(i=0;itiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } +#endif + (void) 0; + } + k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p); + if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ + k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); + } + if (k == 0) { + /* Assume we had overflow inside TIFFScanlineSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } + + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, ""Integer overflow""); + t2p->t2p_error = T2P_ERR_ERROR; + } + + return; +} +","@@ -286,7 +286,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P*, TIFF*, TIFF*, ttile_t); + int t2p_process_ojpeg_tables(T2P*, TIFF*); + #endif + #ifdef JPEG_SUPPORT +-int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t*, tstrip_t, uint32); ++int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32); + #endif + void t2p_tile_collapse_left(tdata_t, tsize_t, uint32, uint32, uint32); + void t2p_write_advance_directory(T2P*, TIFF*); +@@ -2408,7 +2408,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ + if(!t2p_process_jpeg_strip( + stripbuffer, + &striplength, +- buffer, ++ buffer, ++ t2p->tiff_datasize, + &bufferoffset, + i, + t2p->tiff_length)){ +@@ -3439,6 +3440,7 @@ int t2p_process_jpeg_strip( + unsigned char* strip, + tsize_t* striplength, + unsigned char* buffer, ++ tsize_t buffersize, + tsize_t* bufferoffset, + tstrip_t no, + uint32 height){ +@@ -3473,6 +3475,8 @@ int t2p_process_jpeg_strip( + } + switch( strip[i] ){ + case 0xd8: /* SOI - start of image */ ++ if( *bufferoffset + 2 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), 2); + *bufferoffset+=2; + break; +@@ -3482,12 +3486,18 @@ int t2p_process_jpeg_strip( + case 0xc9: /* SOF9 */ + case 0xca: /* SOF10 */ + if(no==0){ ++ if( *bufferoffset + datalen + 2 + 6 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); ++ if( *bufferoffset + 9 >= buffersize ) ++ return(0); + ncomp = buffer[*bufferoffset+9]; + if (ncomp < 1 || ncomp > 4) + return(0); + v_samp=1; + h_samp=1; ++ if( *bufferoffset + 11 + 3*(ncomp-1) >= buffersize ) ++ return(0); + for(j=0;j>4) > h_samp) +@@ -3519,20 +3529,28 @@ int t2p_process_jpeg_strip( + break; + case 0xc4: /* DHT */ + case 0xdb: /* DQT */ ++ if( *bufferoffset + datalen + 2 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + *bufferoffset+=datalen+2; + break; + case 0xda: /* SOS */ + if(no==0){ ++ if( *bufferoffset + datalen + 2 > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + *bufferoffset+=datalen+2; + } else { ++ if( *bufferoffset + 2 > buffersize ) ++ return(0); + buffer[(*bufferoffset)++]=0xff; + buffer[(*bufferoffset)++]= + (unsigned char)(0xd0 | ((no-1)%8)); + } + i += datalen + 1; + /* copy remainder of strip */ ++ if( *bufferoffset + *striplength - i > buffersize ) ++ return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i]), *striplength - i); + *bufferoffset+= *striplength - i; + return(1);",1410,1646,2048 +5020,"static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) +{ + uint32_t cdb_phyaddr, cdb_phyaddr_hi32; + dma_addr_t dma_coherent_handle; + + /* + ******************************************************************** + ** here we need to tell iop 331 our freeccb.HighPart + ** if freeccb.HighPart is not zero + ******************************************************************** + */ + switch (acb->adapter_type) { + case ACB_ADAPTER_TYPE_B: + case ACB_ADAPTER_TYPE_D: + dma_coherent_handle = acb->dma_coherent_handle2; + break; + default: + dma_coherent_handle = acb->dma_coherent_handle; + break; + } + cdb_phyaddr = lower_32_bits(dma_coherent_handle); + cdb_phyaddr_hi32 = upper_32_bits(dma_coherent_handle); + acb->cdb_phyaddr_hi32 = cdb_phyaddr_hi32; + /* + *********************************************************************** + ** if adapter type B, set window of ""post command Q"" + *********************************************************************** + */ + switch (acb->adapter_type) { + + case ACB_ADAPTER_TYPE_A: { + if (cdb_phyaddr_hi32 != 0) { + struct MessageUnit_A __iomem *reg = acb->pmuA; + writel(ARCMSR_SIGNATURE_SET_CONFIG, \ + ®->message_rwbuffer[0]); + writel(cdb_phyaddr_hi32, ®->message_rwbuffer[1]); + writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, \ + ®->inbound_msgaddr0); + if (!arcmsr_hbaA_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: """"set ccb high \ + part physical address timeout\n"", + acb->host->host_no); + return 1; + } + } + } + break; + + case ACB_ADAPTER_TYPE_B: { + uint32_t __iomem *rwbuffer; + + struct MessageUnit_B *reg = acb->pmuB; + reg->postq_index = 0; + reg->doneq_index = 0; + writel(ARCMSR_MESSAGE_SET_POST_WINDOW, reg->drv2iop_doorbell); + if (!arcmsr_hbaB_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: cannot set driver mode\n"", \ + acb->host->host_no); + return 1; + } + rwbuffer = reg->message_rwbuffer; + /* driver ""set config"" signature */ + writel(ARCMSR_SIGNATURE_SET_CONFIG, rwbuffer++); + /* normal should be zero */ + writel(cdb_phyaddr_hi32, rwbuffer++); + /* postQ size (256 + 8)*4 */ + writel(cdb_phyaddr, rwbuffer++); + /* doneQ size (256 + 8)*4 */ + writel(cdb_phyaddr + 1056, rwbuffer++); + /* ccb maxQ size must be --> [(256 + 8)*4]*/ + writel(1056, rwbuffer); + + writel(ARCMSR_MESSAGE_SET_CONFIG, reg->drv2iop_doorbell); + if (!arcmsr_hbaB_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: 'set command Q window' \ + timeout \n"",acb->host->host_no); + return 1; + } + writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell); + if (!arcmsr_hbaB_wait_msgint_ready(acb)) { + pr_err(""arcmsr%d: can't set driver mode.\n"", + acb->host->host_no); + return 1; + } + } + break; + case ACB_ADAPTER_TYPE_C: { + if (cdb_phyaddr_hi32 != 0) { + struct MessageUnit_C __iomem *reg = acb->pmuC; + + printk(KERN_NOTICE ""arcmsr%d: cdb_phyaddr_hi32=0x%x\n"", + acb->adapter_index, cdb_phyaddr_hi32); + writel(ARCMSR_SIGNATURE_SET_CONFIG, ®->msgcode_rwbuffer[0]); + writel(cdb_phyaddr_hi32, ®->msgcode_rwbuffer[1]); + writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, ®->inbound_msgaddr0); + writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, ®->inbound_doorbell); + if (!arcmsr_hbaC_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: 'set command Q window' \ + timeout \n"", acb->host->host_no); + return 1; + } + } + } + break; + case ACB_ADAPTER_TYPE_D: { + uint32_t __iomem *rwbuffer; + struct MessageUnit_D *reg = acb->pmuD; + reg->postq_index = 0; + reg->doneq_index = 0; + rwbuffer = reg->msgcode_rwbuffer; + writel(ARCMSR_SIGNATURE_SET_CONFIG, rwbuffer++); + writel(cdb_phyaddr_hi32, rwbuffer++); + writel(cdb_phyaddr, rwbuffer++); + writel(cdb_phyaddr + (ARCMSR_MAX_ARC1214_POSTQUEUE * + sizeof(struct InBound_SRB)), rwbuffer++); + writel(0x100, rwbuffer); + writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, reg->inbound_msgaddr0); + if (!arcmsr_hbaD_wait_msgint_ready(acb)) { + pr_notice(""arcmsr%d: 'set command Q window' timeout\n"", + acb->host->host_no); + return 1; + } + } + break; + } + return 0; +} +",0,"static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) +{ + uint32_t cdb_phyaddr, cdb_phyaddr_hi32; + dma_addr_t dma_coherent_handle; + + /* + ******************************************************************** + ** here we need to tell iop 331 our freeccb.HighPart + ** if freeccb.HighPart is not zero + ******************************************************************** + */ + switch (acb->adapter_type) { + case ACB_ADAPTER_TYPE_B: + case ACB_ADAPTER_TYPE_D: + dma_coherent_handle = acb->dma_coherent_handle2; + break; + default: + dma_coherent_handle = acb->dma_coherent_handle; + break; + } + cdb_phyaddr = lower_32_bits(dma_coherent_handle); + cdb_phyaddr_hi32 = upper_32_bits(dma_coherent_handle); + acb->cdb_phyaddr_hi32 = cdb_phyaddr_hi32; + /* + *********************************************************************** + ** if adapter type B, set window of ""post command Q"" + *********************************************************************** + */ + switch (acb->adapter_type) { + + case ACB_ADAPTER_TYPE_A: { + if (cdb_phyaddr_hi32 != 0) { + struct MessageUnit_A __iomem *reg = acb->pmuA; + writel(ARCMSR_SIGNATURE_SET_CONFIG, \ + ®->message_rwbuffer[0]); + writel(cdb_phyaddr_hi32, ®->message_rwbuffer[1]); + writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, \ + ®->inbound_msgaddr0); + if (!arcmsr_hbaA_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: """"set ccb high \ + part physical address timeout\n"", + acb->host->host_no); + return 1; + } + } + } + break; + + case ACB_ADAPTER_TYPE_B: { + uint32_t __iomem *rwbuffer; + + struct MessageUnit_B *reg = acb->pmuB; + reg->postq_index = 0; + reg->doneq_index = 0; + writel(ARCMSR_MESSAGE_SET_POST_WINDOW, reg->drv2iop_doorbell); + if (!arcmsr_hbaB_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: cannot set driver mode\n"", \ + acb->host->host_no); + return 1; + } + rwbuffer = reg->message_rwbuffer; + /* driver ""set config"" signature */ + writel(ARCMSR_SIGNATURE_SET_CONFIG, rwbuffer++); + /* normal should be zero */ + writel(cdb_phyaddr_hi32, rwbuffer++); + /* postQ size (256 + 8)*4 */ + writel(cdb_phyaddr, rwbuffer++); + /* doneQ size (256 + 8)*4 */ + writel(cdb_phyaddr + 1056, rwbuffer++); + /* ccb maxQ size must be --> [(256 + 8)*4]*/ + writel(1056, rwbuffer); + + writel(ARCMSR_MESSAGE_SET_CONFIG, reg->drv2iop_doorbell); + if (!arcmsr_hbaB_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: 'set command Q window' \ + timeout \n"",acb->host->host_no); + return 1; + } + writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell); + if (!arcmsr_hbaB_wait_msgint_ready(acb)) { + pr_err(""arcmsr%d: can't set driver mode.\n"", + acb->host->host_no); + return 1; + } + } + break; + case ACB_ADAPTER_TYPE_C: { + if (cdb_phyaddr_hi32 != 0) { + struct MessageUnit_C __iomem *reg = acb->pmuC; + + printk(KERN_NOTICE ""arcmsr%d: cdb_phyaddr_hi32=0x%x\n"", + acb->adapter_index, cdb_phyaddr_hi32); + writel(ARCMSR_SIGNATURE_SET_CONFIG, ®->msgcode_rwbuffer[0]); + writel(cdb_phyaddr_hi32, ®->msgcode_rwbuffer[1]); + writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, ®->inbound_msgaddr0); + writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, ®->inbound_doorbell); + if (!arcmsr_hbaC_wait_msgint_ready(acb)) { + printk(KERN_NOTICE ""arcmsr%d: 'set command Q window' \ + timeout \n"", acb->host->host_no); + return 1; + } + } + } + break; + case ACB_ADAPTER_TYPE_D: { + uint32_t __iomem *rwbuffer; + struct MessageUnit_D *reg = acb->pmuD; + reg->postq_index = 0; + reg->doneq_index = 0; + rwbuffer = reg->msgcode_rwbuffer; + writel(ARCMSR_SIGNATURE_SET_CONFIG, rwbuffer++); + writel(cdb_phyaddr_hi32, rwbuffer++); + writel(cdb_phyaddr, rwbuffer++); + writel(cdb_phyaddr + (ARCMSR_MAX_ARC1214_POSTQUEUE * + sizeof(struct InBound_SRB)), rwbuffer++); + writel(0x100, rwbuffer); + writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, reg->inbound_msgaddr0); + if (!arcmsr_hbaD_wait_msgint_ready(acb)) { + pr_notice(""arcmsr%d: 'set command Q window' timeout\n"", + acb->host->host_no); + return 1; + } + } + break; + } + return 0; +} +","@@ -2388,7 +2388,8 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, + } + case ARCMSR_MESSAGE_WRITE_WQBUFFER: { + unsigned char *ver_addr; +- int32_t user_len, cnt2end; ++ uint32_t user_len; ++ int32_t cnt2end; + uint8_t *pQbuffer, *ptmpuserbuffer; + ver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC); + if (!ver_addr) { +@@ -2397,6 +2398,11 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, + } + ptmpuserbuffer = ver_addr; + user_len = pcmdmessagefld->cmdmessage.Length; ++ if (user_len > ARCMSR_API_DATA_BUFLEN) { ++ retvalue = ARCMSR_MESSAGE_FAIL; ++ kfree(ver_addr); ++ goto message_out; ++ } + memcpy(ptmpuserbuffer, + pcmdmessagefld->messagedatabuffer, user_len); + spin_lock_irqsave(&acb->wqbuffer_lock, flags);",1294,1530,2048 +6847,"server_response(struct httpd *httpd, struct client *clt) +{ + char path[PATH_MAX]; + char hostname[HOST_NAME_MAX+1]; + struct http_descriptor *desc = clt->clt_descreq; + struct http_descriptor *resp = clt->clt_descresp; + struct server *srv = clt->clt_srv; + struct server_config *srv_conf = &srv->srv_conf; + struct kv *kv, key, *host; + struct str_find sm; + int portval = -1, ret; + char *hostval; + const char *errstr = NULL; + + /* Canonicalize the request path */ + if (desc->http_path == NULL || + url_decode(desc->http_path) == NULL || + canonicalize_path(desc->http_path, path, sizeof(path)) == NULL) + goto fail; + free(desc->http_path); + if ((desc->http_path = strdup(path)) == NULL) + goto fail; + + key.kv_key = ""Host""; + if ((host = kv_find(&desc->http_headers, &key)) != NULL && + host->kv_value == NULL) + host = NULL; + + if (strcmp(desc->http_version, ""HTTP/1.1"") == 0) { + /* Host header is mandatory */ + if (host == NULL) + goto fail; + + /* Is the connection persistent? */ + key.kv_key = ""Connection""; + if ((kv = kv_find(&desc->http_headers, &key)) != NULL && + strcasecmp(""close"", kv->kv_value) == 0) + clt->clt_persist = 0; + else + clt->clt_persist++; + } else { + /* Is the connection persistent? */ + key.kv_key = ""Connection""; + if ((kv = kv_find(&desc->http_headers, &key)) != NULL && + strcasecmp(""keep-alive"", kv->kv_value) == 0) + clt->clt_persist++; + else + clt->clt_persist = 0; + } + + if (clt->clt_persist >= srv_conf->maxrequests) + clt->clt_persist = 0; + + /* + * Do we have a Host header and matching configuration? + * XXX the Host can also appear in the URL path. + */ + if (host != NULL) { + if ((hostval = server_http_parsehost(host->kv_value, + hostname, sizeof(hostname), &portval)) == NULL) + goto fail; + + TAILQ_FOREACH(srv_conf, &srv->srv_hosts, entry) { +#ifdef DEBUG + if ((srv_conf->flags & SRVFLAG_LOCATION) == 0) { + DPRINTF(""%s: virtual host \""%s:%u\"""" + "" host \""%s\"" (\""%s\"")"", + __func__, srv_conf->name, + ntohs(srv_conf->port), host->kv_value, + hostname); + } +#endif + if (srv_conf->flags & SRVFLAG_LOCATION) + continue; + else if (srv_conf->flags & SRVFLAG_SERVER_MATCH) { + str_find(hostname, srv_conf->name, + &sm, 1, &errstr); + ret = errstr == NULL ? 0 : -1; + } else { + ret = fnmatch(srv_conf->name, + hostname, FNM_CASEFOLD); + } + if (ret == 0 && + (portval == -1 || + (portval != -1 && portval == srv_conf->port))) { + /* Replace host configuration */ + clt->clt_srv_conf = srv_conf; + srv_conf = NULL; + break; + } + } + } + + if (srv_conf != NULL) { + /* Use the actual server IP address */ + if (server_http_host(&clt->clt_srv_ss, hostname, + sizeof(hostname)) == NULL) + goto fail; + } else { + /* Host header was valid and found */ + if (strlcpy(hostname, host->kv_value, sizeof(hostname)) >= + sizeof(hostname)) + goto fail; + srv_conf = clt->clt_srv_conf; + } + + if ((desc->http_host = strdup(hostname)) == NULL) + goto fail; + + /* Now fill in the mandatory parts of the response descriptor */ + resp->http_method = desc->http_method; + if ((resp->http_version = strdup(desc->http_version)) == NULL) + goto fail; + + /* Now search for the location */ + srv_conf = server_getlocation(clt, desc->http_path); + + if (srv_conf->flags & SRVFLAG_BLOCK) { + server_abort_http(clt, srv_conf->return_code, + srv_conf->return_uri); + return (-1); + } else if (srv_conf->flags & SRVFLAG_AUTH && + server_http_authenticate(srv_conf, clt) == -1) { + server_abort_http(clt, 401, srv_conf->auth_realm); + return (-1); + } else + return (server_file(httpd, clt)); + fail: + server_abort_http(clt, 400, ""bad request""); + return (-1); +} +",0,"server_response(struct httpd *httpd, struct client *clt) +{ + char path[PATH_MAX]; + char hostname[HOST_NAME_MAX+1]; + struct http_descriptor *desc = clt->clt_descreq; + struct http_descriptor *resp = clt->clt_descresp; + struct server *srv = clt->clt_srv; + struct server_config *srv_conf = &srv->srv_conf; + struct kv *kv, key, *host; + struct str_find sm; + int portval = -1, ret; + char *hostval; + const char *errstr = NULL; + + /* Canonicalize the request path */ + if (desc->http_path == NULL || + url_decode(desc->http_path) == NULL || + canonicalize_path(desc->http_path, path, sizeof(path)) == NULL) + goto fail; + free(desc->http_path); + if ((desc->http_path = strdup(path)) == NULL) + goto fail; + + key.kv_key = ""Host""; + if ((host = kv_find(&desc->http_headers, &key)) != NULL && + host->kv_value == NULL) + host = NULL; + + if (strcmp(desc->http_version, ""HTTP/1.1"") == 0) { + /* Host header is mandatory */ + if (host == NULL) + goto fail; + + /* Is the connection persistent? */ + key.kv_key = ""Connection""; + if ((kv = kv_find(&desc->http_headers, &key)) != NULL && + strcasecmp(""close"", kv->kv_value) == 0) + clt->clt_persist = 0; + else + clt->clt_persist++; + } else { + /* Is the connection persistent? */ + key.kv_key = ""Connection""; + if ((kv = kv_find(&desc->http_headers, &key)) != NULL && + strcasecmp(""keep-alive"", kv->kv_value) == 0) + clt->clt_persist++; + else + clt->clt_persist = 0; + } + + if (clt->clt_persist >= srv_conf->maxrequests) + clt->clt_persist = 0; + + /* + * Do we have a Host header and matching configuration? + * XXX the Host can also appear in the URL path. + */ + if (host != NULL) { + if ((hostval = server_http_parsehost(host->kv_value, + hostname, sizeof(hostname), &portval)) == NULL) + goto fail; + + TAILQ_FOREACH(srv_conf, &srv->srv_hosts, entry) { +#ifdef DEBUG + if ((srv_conf->flags & SRVFLAG_LOCATION) == 0) { + DPRINTF(""%s: virtual host \""%s:%u\"""" + "" host \""%s\"" (\""%s\"")"", + __func__, srv_conf->name, + ntohs(srv_conf->port), host->kv_value, + hostname); + } +#endif + if (srv_conf->flags & SRVFLAG_LOCATION) + continue; + else if (srv_conf->flags & SRVFLAG_SERVER_MATCH) { + str_find(hostname, srv_conf->name, + &sm, 1, &errstr); + ret = errstr == NULL ? 0 : -1; + } else { + ret = fnmatch(srv_conf->name, + hostname, FNM_CASEFOLD); + } + if (ret == 0 && + (portval == -1 || + (portval != -1 && portval == srv_conf->port))) { + /* Replace host configuration */ + clt->clt_srv_conf = srv_conf; + srv_conf = NULL; + break; + } + } + } + + if (srv_conf != NULL) { + /* Use the actual server IP address */ + if (server_http_host(&clt->clt_srv_ss, hostname, + sizeof(hostname)) == NULL) + goto fail; + } else { + /* Host header was valid and found */ + if (strlcpy(hostname, host->kv_value, sizeof(hostname)) >= + sizeof(hostname)) + goto fail; + srv_conf = clt->clt_srv_conf; + } + + if ((desc->http_host = strdup(hostname)) == NULL) + goto fail; + + /* Now fill in the mandatory parts of the response descriptor */ + resp->http_method = desc->http_method; + if ((resp->http_version = strdup(desc->http_version)) == NULL) + goto fail; + + /* Now search for the location */ + srv_conf = server_getlocation(clt, desc->http_path); + + if (srv_conf->flags & SRVFLAG_BLOCK) { + server_abort_http(clt, srv_conf->return_code, + srv_conf->return_uri); + return (-1); + } else if (srv_conf->flags & SRVFLAG_AUTH && + server_http_authenticate(srv_conf, clt) == -1) { + server_abort_http(clt, 401, srv_conf->auth_realm); + return (-1); + } else + return (server_file(httpd, clt)); + fail: + server_abort_http(clt, 400, ""bad request""); + return (-1); +} +","@@ -1,7 +1,7 @@ +-/* $OpenBSD: server_http.c,v 1.111 2017/01/31 12:21:27 reyk Exp $ */ ++/* $OpenBSD: server_http.c,v 1.112 2017/01/31 14:39:47 reyk Exp $ */ + + /* +- * Copyright (c) 2006 - 2015 Reyk Floeter ++ * Copyright (c) 2006 - 2017 Reyk Floeter + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above +@@ -609,6 +609,101 @@ server_read_httpchunks(struct bufferevent *bev, void *arg) + server_close(clt, strerror(errno)); + } + ++void ++server_read_httprange(struct bufferevent *bev, void *arg) ++{ ++ struct client *clt = arg; ++ struct evbuffer *src = EVBUFFER_INPUT(bev); ++ size_t size; ++ struct media_type *media; ++ struct range_data *r = &clt->clt_ranges; ++ struct range *range; ++ ++ getmonotime(&clt->clt_tv_last); ++ ++ if (r->range_toread > 0) { ++ size = EVBUFFER_LENGTH(src); ++ if (!size) ++ return; ++ ++ /* Read chunk data */ ++ if ((off_t)size > r->range_toread) { ++ size = r->range_toread; ++ if (server_bufferevent_write_chunk(clt, src, size) ++ == -1) ++ goto fail; ++ r->range_toread = 0; ++ } else { ++ if (server_bufferevent_write_buffer(clt, src) == -1) ++ goto fail; ++ r->range_toread -= size; ++ } ++ if (r->range_toread < 1) ++ r->range_toread = TOREAD_HTTP_RANGE; ++ DPRINTF(""%s: done, size %lu, to read %lld"", __func__, ++ size, r->range_toread); ++ } ++ ++ switch (r->range_toread) { ++ case TOREAD_HTTP_RANGE: ++ if (r->range_index >= r->range_count) { ++ if (r->range_count > 1) { ++ /* Add end marker */ ++ if (server_bufferevent_printf(clt, ++ ""\r\n--%llu--\r\n"", ++ clt->clt_boundary) == -1) ++ goto fail; ++ } ++ r->range_toread = TOREAD_HTTP_NONE; ++ break; ++ } ++ ++ range = &r->range[r->range_index]; ++ ++ if (r->range_count > 1) { ++ media = r->range_media; ++ if (server_bufferevent_printf(clt, ++ ""\r\n--%llu\r\n"" ++ ""Content-Type: %s/%s\r\n"" ++ ""Content-Range: bytes %lld-%lld/%zu\r\n\r\n"", ++ clt->clt_boundary, ++ media->media_type, media->media_subtype, ++ range->start, range->end, r->range_total) == -1) ++ goto fail; ++ } ++ r->range_toread = range->end - range->start + 1; ++ ++ if (lseek(clt->clt_fd, range->start, SEEK_SET) == -1) ++ goto fail; ++ ++ /* Throw away bytes that are already in the input buffer */ ++ evbuffer_drain(src, EVBUFFER_LENGTH(src)); ++ ++ /* Increment for the next part */ ++ r->range_index++; ++ break; ++ case TOREAD_HTTP_NONE: ++ case 0: ++ break; ++ } ++ ++ if (clt->clt_done) ++ goto done; ++ ++ if (EVBUFFER_LENGTH(EVBUFFER_OUTPUT(clt->clt_bev)) > (size_t) ++ SERVER_MAX_PREFETCH * clt->clt_sndbufsiz) { ++ bufferevent_disable(clt->clt_srvbev, EV_READ); ++ clt->clt_srvbev_throttled = 1; ++ } ++ ++ return; ++ done: ++ (*bev->errorcb)(bev, EVBUFFER_READ, bev->cbarg); ++ return; ++ fail: ++ server_close(clt, strerror(errno)); ++} ++ + void + server_reset_http(struct client *clt) + {",1118,1354,2048 +247,"NTSTATUS smb1cli_req_chain_submit(struct tevent_req **reqs, int num_reqs) +{ + struct smbXcli_req_state *first_state = + tevent_req_data(reqs[0], + struct smbXcli_req_state); + struct smbXcli_req_state *state; + size_t wct_offset; + size_t chain_padding = 0; + int i, iovlen; + struct iovec *iov = NULL; + struct iovec *this_iov; + NTSTATUS status; + ssize_t nbt_len; + + if (num_reqs == 1) { + return smb1cli_req_writev_submit(reqs[0], first_state, + first_state->smb1.iov, + first_state->smb1.iov_count); + } + + iovlen = 0; + for (i=0; ismb1.iov_count < 4) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + if (i == 0) { + /* + * The NBT and SMB header + */ + iovlen += 2; + } else { + /* + * Chain padding + */ + iovlen += 1; + } + + /* + * words and bytes + */ + iovlen += state->smb1.iov_count - 2; + } + + iov = talloc_zero_array(first_state, struct iovec, iovlen); + if (iov == NULL) { + return NT_STATUS_NO_MEMORY; + } + + first_state->smb1.chained_requests = (struct tevent_req **)talloc_memdup( + first_state, reqs, sizeof(*reqs) * num_reqs); + if (first_state->smb1.chained_requests == NULL) { + TALLOC_FREE(iov); + return NT_STATUS_NO_MEMORY; + } + + wct_offset = HDR_WCT; + this_iov = iov; + + for (i=0; ismb1.hdr, HDR_COM)) + || CVAL(state->smb1.hdr, HDR_WCT) < 2) { + TALLOC_FREE(iov); + TALLOC_FREE(first_state->smb1.chained_requests); + return NT_STATUS_INVALID_PARAMETER_MIX; + } + } + + wct_offset += smbXcli_iov_len(state->smb1.iov+2, + state->smb1.iov_count-2) + 1; + if ((wct_offset % 4) != 0) { + next_padding = 4 - (wct_offset % 4); + } + wct_offset += next_padding; + vwv = state->smb1.vwv; + + if (i < num_reqs-1) { + struct smbXcli_req_state *next_state = + tevent_req_data(reqs[i+1], + struct smbXcli_req_state); + SCVAL(vwv+0, 0, CVAL(next_state->smb1.hdr, HDR_COM)); + SCVAL(vwv+0, 1, 0); + SSVAL(vwv+1, 0, wct_offset); + } else if (smb1cli_is_andx_req(CVAL(state->smb1.hdr, HDR_COM))) { + /* properly end the chain */ + SCVAL(vwv+0, 0, 0xff); + SCVAL(vwv+0, 1, 0xff); + SSVAL(vwv+1, 0, 0); + } + + if (i == 0) { + /* + * The NBT and SMB header + */ + this_iov[0] = state->smb1.iov[0]; + this_iov[1] = state->smb1.iov[1]; + this_iov += 2; + } else { + /* + * This one is a bit subtle. We have to add + * chain_padding bytes between the requests, and we + * have to also include the wct field of the + * subsequent requests. We use the subsequent header + * for the padding, it contains the wct field in its + * last byte. + */ + this_iov[0].iov_len = chain_padding+1; + this_iov[0].iov_base = (void *)&state->smb1.hdr[ + sizeof(state->smb1.hdr) - this_iov[0].iov_len]; + memset(this_iov[0].iov_base, 0, this_iov[0].iov_len-1); + this_iov += 1; + } + + /* + * copy the words and bytes + */ + memcpy(this_iov, state->smb1.iov+2, + sizeof(struct iovec) * (state->smb1.iov_count-2)); + this_iov += state->smb1.iov_count - 2; + chain_padding = next_padding; + } + + nbt_len = iov_buflen(&iov[1], iovlen-1); + if ((nbt_len == -1) || (nbt_len > first_state->conn->smb1.max_xmit)) { + TALLOC_FREE(iov); + TALLOC_FREE(first_state->smb1.chained_requests); + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + status = smb1cli_req_writev_submit(reqs[0], first_state, iov, iovlen); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(iov); + TALLOC_FREE(first_state->smb1.chained_requests); + return status; + } + + return NT_STATUS_OK; +} +",0,"NTSTATUS smb1cli_req_chain_submit(struct tevent_req **reqs, int num_reqs) +{ + struct smbXcli_req_state *first_state = + tevent_req_data(reqs[0], + struct smbXcli_req_state); + struct smbXcli_req_state *state; + size_t wct_offset; + size_t chain_padding = 0; + int i, iovlen; + struct iovec *iov = NULL; + struct iovec *this_iov; + NTSTATUS status; + ssize_t nbt_len; + + if (num_reqs == 1) { + return smb1cli_req_writev_submit(reqs[0], first_state, + first_state->smb1.iov, + first_state->smb1.iov_count); + } + + iovlen = 0; + for (i=0; ismb1.iov_count < 4) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + if (i == 0) { + /* + * The NBT and SMB header + */ + iovlen += 2; + } else { + /* + * Chain padding + */ + iovlen += 1; + } + + /* + * words and bytes + */ + iovlen += state->smb1.iov_count - 2; + } + + iov = talloc_zero_array(first_state, struct iovec, iovlen); + if (iov == NULL) { + return NT_STATUS_NO_MEMORY; + } + + first_state->smb1.chained_requests = (struct tevent_req **)talloc_memdup( + first_state, reqs, sizeof(*reqs) * num_reqs); + if (first_state->smb1.chained_requests == NULL) { + TALLOC_FREE(iov); + return NT_STATUS_NO_MEMORY; + } + + wct_offset = HDR_WCT; + this_iov = iov; + + for (i=0; ismb1.hdr, HDR_COM)) + || CVAL(state->smb1.hdr, HDR_WCT) < 2) { + TALLOC_FREE(iov); + TALLOC_FREE(first_state->smb1.chained_requests); + return NT_STATUS_INVALID_PARAMETER_MIX; + } + } + + wct_offset += smbXcli_iov_len(state->smb1.iov+2, + state->smb1.iov_count-2) + 1; + if ((wct_offset % 4) != 0) { + next_padding = 4 - (wct_offset % 4); + } + wct_offset += next_padding; + vwv = state->smb1.vwv; + + if (i < num_reqs-1) { + struct smbXcli_req_state *next_state = + tevent_req_data(reqs[i+1], + struct smbXcli_req_state); + SCVAL(vwv+0, 0, CVAL(next_state->smb1.hdr, HDR_COM)); + SCVAL(vwv+0, 1, 0); + SSVAL(vwv+1, 0, wct_offset); + } else if (smb1cli_is_andx_req(CVAL(state->smb1.hdr, HDR_COM))) { + /* properly end the chain */ + SCVAL(vwv+0, 0, 0xff); + SCVAL(vwv+0, 1, 0xff); + SSVAL(vwv+1, 0, 0); + } + + if (i == 0) { + /* + * The NBT and SMB header + */ + this_iov[0] = state->smb1.iov[0]; + this_iov[1] = state->smb1.iov[1]; + this_iov += 2; + } else { + /* + * This one is a bit subtle. We have to add + * chain_padding bytes between the requests, and we + * have to also include the wct field of the + * subsequent requests. We use the subsequent header + * for the padding, it contains the wct field in its + * last byte. + */ + this_iov[0].iov_len = chain_padding+1; + this_iov[0].iov_base = (void *)&state->smb1.hdr[ + sizeof(state->smb1.hdr) - this_iov[0].iov_len]; + memset(this_iov[0].iov_base, 0, this_iov[0].iov_len-1); + this_iov += 1; + } + + /* + * copy the words and bytes + */ + memcpy(this_iov, state->smb1.iov+2, + sizeof(struct iovec) * (state->smb1.iov_count-2)); + this_iov += state->smb1.iov_count - 2; + chain_padding = next_padding; + } + + nbt_len = iov_buflen(&iov[1], iovlen-1); + if ((nbt_len == -1) || (nbt_len > first_state->conn->smb1.max_xmit)) { + TALLOC_FREE(iov); + TALLOC_FREE(first_state->smb1.chained_requests); + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + status = smb1cli_req_writev_submit(reqs[0], first_state, iov, iovlen); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(iov); + TALLOC_FREE(first_state->smb1.chained_requests); + return status; + } + + return NT_STATUS_OK; +} +","@@ -5446,6 +5446,9 @@ uint8_t smb2cli_session_security_mode(struct smbXcli_session *session) + if (conn->mandatory_signing) { + security_mode |= SMB2_NEGOTIATE_SIGNING_REQUIRED; + } ++ if (session->smb2->should_sign) { ++ security_mode |= SMB2_NEGOTIATE_SIGNING_REQUIRED; ++ } + + return security_mode; + } +@@ -5877,6 +5880,14 @@ NTSTATUS smb2cli_session_set_channel_key(struct smbXcli_session *session, + + NTSTATUS smb2cli_session_encryption_on(struct smbXcli_session *session) + { ++ if (!session->smb2->should_sign) { ++ /* ++ * We need required signing on the session ++ * in order to prevent man in the middle attacks. ++ */ ++ return NT_STATUS_INVALID_PARAMETER_MIX; ++ } ++ + if (session->smb2->should_encrypt) { + return NT_STATUS_OK; + }",1330,1566,2048 +4580,"static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + int data_size, int empty, + struct extent_buffer *right, + int free_space, u32 left_nritems, + u32 min_slot) +{ + struct extent_buffer *left = path->nodes[0]; + struct extent_buffer *upper = path->nodes[1]; + struct btrfs_map_token token; + struct btrfs_disk_key disk_key; + int slot; + u32 i; + int push_space = 0; + int push_items = 0; + struct btrfs_item *item; + u32 nr; + u32 right_nritems; + u32 data_end; + u32 this_item_size; + + btrfs_init_map_token(&token); + + if (empty) + nr = 0; + else + nr = max_t(u32, 1, min_slot); + + if (path->slots[0] >= left_nritems) + push_space += data_size; + + slot = path->slots[1]; + i = left_nritems - 1; + while (i >= nr) { + item = btrfs_item_nr(i); + + if (!empty && push_items > 0) { + if (path->slots[0] > i) + break; + if (path->slots[0] == i) { + int space = btrfs_leaf_free_space(root, left); + if (space + push_space * 2 > free_space) + break; + } + } + + if (path->slots[0] == i) + push_space += data_size; + + this_item_size = btrfs_item_size(left, item); + if (this_item_size + sizeof(*item) + push_space > free_space) + break; + + push_items++; + push_space += this_item_size + sizeof(*item); + if (i == 0) + break; + i--; + } + + if (push_items == 0) + goto out_unlock; + + WARN_ON(!empty && push_items == left_nritems); + + /* push left to right */ + right_nritems = btrfs_header_nritems(right); + + push_space = btrfs_item_end_nr(left, left_nritems - push_items); + push_space -= leaf_data_end(root, left); + + /* make room in the right data area */ + data_end = leaf_data_end(root, right); + memmove_extent_buffer(right, + btrfs_leaf_data(right) + data_end - push_space, + btrfs_leaf_data(right) + data_end, + BTRFS_LEAF_DATA_SIZE(root) - data_end); + + /* copy from the left data area */ + copy_extent_buffer(right, left, btrfs_leaf_data(right) + + BTRFS_LEAF_DATA_SIZE(root) - push_space, + btrfs_leaf_data(left) + leaf_data_end(root, left), + push_space); + + memmove_extent_buffer(right, btrfs_item_nr_offset(push_items), + btrfs_item_nr_offset(0), + right_nritems * sizeof(struct btrfs_item)); + + /* copy the items from left to right */ + copy_extent_buffer(right, left, btrfs_item_nr_offset(0), + btrfs_item_nr_offset(left_nritems - push_items), + push_items * sizeof(struct btrfs_item)); + + /* update the item pointers */ + right_nritems += push_items; + btrfs_set_header_nritems(right, right_nritems); + push_space = BTRFS_LEAF_DATA_SIZE(root); + for (i = 0; i < right_nritems; i++) { + item = btrfs_item_nr(i); + push_space -= btrfs_token_item_size(right, item, &token); + btrfs_set_token_item_offset(right, item, push_space, &token); + } + + left_nritems -= push_items; + btrfs_set_header_nritems(left, left_nritems); + + if (left_nritems) + btrfs_mark_buffer_dirty(left); + else + clean_tree_block(trans, root, left); + + btrfs_mark_buffer_dirty(right); + + btrfs_item_key(right, &disk_key, 0); + btrfs_set_node_key(upper, &disk_key, slot + 1); + btrfs_mark_buffer_dirty(upper); + + /* then fixup the leaf pointer in the path */ + if (path->slots[0] >= left_nritems) { + path->slots[0] -= left_nritems; + if (btrfs_header_nritems(path->nodes[0]) == 0) + clean_tree_block(trans, root, path->nodes[0]); + btrfs_tree_unlock(path->nodes[0]); + free_extent_buffer(path->nodes[0]); + path->nodes[0] = right; + path->slots[1] += 1; + } else { + btrfs_tree_unlock(right); + free_extent_buffer(right); + } + return 0; + +out_unlock: + btrfs_tree_unlock(right); + free_extent_buffer(right); + return 1; +} +",0,"static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + int data_size, int empty, + struct extent_buffer *right, + int free_space, u32 left_nritems, + u32 min_slot) +{ + struct extent_buffer *left = path->nodes[0]; + struct extent_buffer *upper = path->nodes[1]; + struct btrfs_map_token token; + struct btrfs_disk_key disk_key; + int slot; + u32 i; + int push_space = 0; + int push_items = 0; + struct btrfs_item *item; + u32 nr; + u32 right_nritems; + u32 data_end; + u32 this_item_size; + + btrfs_init_map_token(&token); + + if (empty) + nr = 0; + else + nr = max_t(u32, 1, min_slot); + + if (path->slots[0] >= left_nritems) + push_space += data_size; + + slot = path->slots[1]; + i = left_nritems - 1; + while (i >= nr) { + item = btrfs_item_nr(i); + + if (!empty && push_items > 0) { + if (path->slots[0] > i) + break; + if (path->slots[0] == i) { + int space = btrfs_leaf_free_space(root, left); + if (space + push_space * 2 > free_space) + break; + } + } + + if (path->slots[0] == i) + push_space += data_size; + + this_item_size = btrfs_item_size(left, item); + if (this_item_size + sizeof(*item) + push_space > free_space) + break; + + push_items++; + push_space += this_item_size + sizeof(*item); + if (i == 0) + break; + i--; + } + + if (push_items == 0) + goto out_unlock; + + WARN_ON(!empty && push_items == left_nritems); + + /* push left to right */ + right_nritems = btrfs_header_nritems(right); + + push_space = btrfs_item_end_nr(left, left_nritems - push_items); + push_space -= leaf_data_end(root, left); + + /* make room in the right data area */ + data_end = leaf_data_end(root, right); + memmove_extent_buffer(right, + btrfs_leaf_data(right) + data_end - push_space, + btrfs_leaf_data(right) + data_end, + BTRFS_LEAF_DATA_SIZE(root) - data_end); + + /* copy from the left data area */ + copy_extent_buffer(right, left, btrfs_leaf_data(right) + + BTRFS_LEAF_DATA_SIZE(root) - push_space, + btrfs_leaf_data(left) + leaf_data_end(root, left), + push_space); + + memmove_extent_buffer(right, btrfs_item_nr_offset(push_items), + btrfs_item_nr_offset(0), + right_nritems * sizeof(struct btrfs_item)); + + /* copy the items from left to right */ + copy_extent_buffer(right, left, btrfs_item_nr_offset(0), + btrfs_item_nr_offset(left_nritems - push_items), + push_items * sizeof(struct btrfs_item)); + + /* update the item pointers */ + right_nritems += push_items; + btrfs_set_header_nritems(right, right_nritems); + push_space = BTRFS_LEAF_DATA_SIZE(root); + for (i = 0; i < right_nritems; i++) { + item = btrfs_item_nr(i); + push_space -= btrfs_token_item_size(right, item, &token); + btrfs_set_token_item_offset(right, item, push_space, &token); + } + + left_nritems -= push_items; + btrfs_set_header_nritems(left, left_nritems); + + if (left_nritems) + btrfs_mark_buffer_dirty(left); + else + clean_tree_block(trans, root, left); + + btrfs_mark_buffer_dirty(right); + + btrfs_item_key(right, &disk_key, 0); + btrfs_set_node_key(upper, &disk_key, slot + 1); + btrfs_mark_buffer_dirty(upper); + + /* then fixup the leaf pointer in the path */ + if (path->slots[0] >= left_nritems) { + path->slots[0] -= left_nritems; + if (btrfs_header_nritems(path->nodes[0]) == 0) + clean_tree_block(trans, root, path->nodes[0]); + btrfs_tree_unlock(path->nodes[0]); + free_extent_buffer(path->nodes[0]); + path->nodes[0] = right; + path->slots[1] += 1; + } else { + btrfs_tree_unlock(right); + free_extent_buffer(right); + } + return 0; + +out_unlock: + btrfs_tree_unlock(right); + free_extent_buffer(right); + return 1; +} +","@@ -2939,7 +2939,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root + */ + if (!p->leave_spinning) + btrfs_set_path_blocking(p); +- if (ret < 0) ++ if (ret < 0 && !p->skip_release_on_error) + btrfs_release_path(p); + return ret; + }",1050,1286,2048 +5684,"ext4_swap_extents(handle_t *handle, struct inode *inode1, + struct inode *inode2, ext4_lblk_t lblk1, ext4_lblk_t lblk2, + ext4_lblk_t count, int unwritten, int *erp) +{ + struct ext4_ext_path *path1 = NULL; + struct ext4_ext_path *path2 = NULL; + int replaced_count = 0; + + BUG_ON(!rwsem_is_locked(&EXT4_I(inode1)->i_data_sem)); + BUG_ON(!rwsem_is_locked(&EXT4_I(inode2)->i_data_sem)); + BUG_ON(!mutex_is_locked(&inode1->i_mutex)); + BUG_ON(!mutex_is_locked(&inode2->i_mutex)); + + *erp = ext4_es_remove_extent(inode1, lblk1, count); + if (unlikely(*erp)) + return 0; + *erp = ext4_es_remove_extent(inode2, lblk2, count); + if (unlikely(*erp)) + return 0; + + while (count) { + struct ext4_extent *ex1, *ex2, tmp_ex; + ext4_lblk_t e1_blk, e2_blk; + int e1_len, e2_len, len; + int split = 0; + + path1 = ext4_find_extent(inode1, lblk1, NULL, EXT4_EX_NOCACHE); + if (IS_ERR(path1)) { + *erp = PTR_ERR(path1); + path1 = NULL; + finish: + count = 0; + goto repeat; + } + path2 = ext4_find_extent(inode2, lblk2, NULL, EXT4_EX_NOCACHE); + if (IS_ERR(path2)) { + *erp = PTR_ERR(path2); + path2 = NULL; + goto finish; + } + ex1 = path1[path1->p_depth].p_ext; + ex2 = path2[path2->p_depth].p_ext; + /* Do we have somthing to swap ? */ + if (unlikely(!ex2 || !ex1)) + goto finish; + + e1_blk = le32_to_cpu(ex1->ee_block); + e2_blk = le32_to_cpu(ex2->ee_block); + e1_len = ext4_ext_get_actual_len(ex1); + e2_len = ext4_ext_get_actual_len(ex2); + + /* Hole handling */ + if (!in_range(lblk1, e1_blk, e1_len) || + !in_range(lblk2, e2_blk, e2_len)) { + ext4_lblk_t next1, next2; + + /* if hole after extent, then go to next extent */ + next1 = ext4_ext_next_allocated_block(path1); + next2 = ext4_ext_next_allocated_block(path2); + /* If hole before extent, then shift to that extent */ + if (e1_blk > lblk1) + next1 = e1_blk; + if (e2_blk > lblk2) + next2 = e1_blk; + /* Do we have something to swap */ + if (next1 == EXT_MAX_BLOCKS || next2 == EXT_MAX_BLOCKS) + goto finish; + /* Move to the rightest boundary */ + len = next1 - lblk1; + if (len < next2 - lblk2) + len = next2 - lblk2; + if (len > count) + len = count; + lblk1 += len; + lblk2 += len; + count -= len; + goto repeat; + } + + /* Prepare left boundary */ + if (e1_blk < lblk1) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode1, + &path1, lblk1, 0); + if (unlikely(*erp)) + goto finish; + } + if (e2_blk < lblk2) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode2, + &path2, lblk2, 0); + if (unlikely(*erp)) + goto finish; + } + /* ext4_split_extent_at() may result in leaf extent split, + * path must to be revalidated. */ + if (split) + goto repeat; + + /* Prepare right boundary */ + len = count; + if (len > e1_blk + e1_len - lblk1) + len = e1_blk + e1_len - lblk1; + if (len > e2_blk + e2_len - lblk2) + len = e2_blk + e2_len - lblk2; + + if (len != e1_len) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode1, + &path1, lblk1 + len, 0); + if (unlikely(*erp)) + goto finish; + } + if (len != e2_len) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode2, + &path2, lblk2 + len, 0); + if (*erp) + goto finish; + } + /* ext4_split_extent_at() may result in leaf extent split, + * path must to be revalidated. */ + if (split) + goto repeat; + + BUG_ON(e2_len != e1_len); + *erp = ext4_ext_get_access(handle, inode1, path1 + path1->p_depth); + if (unlikely(*erp)) + goto finish; + *erp = ext4_ext_get_access(handle, inode2, path2 + path2->p_depth); + if (unlikely(*erp)) + goto finish; + + /* Both extents are fully inside boundaries. Swap it now */ + tmp_ex = *ex1; + ext4_ext_store_pblock(ex1, ext4_ext_pblock(ex2)); + ext4_ext_store_pblock(ex2, ext4_ext_pblock(&tmp_ex)); + ex1->ee_len = cpu_to_le16(e2_len); + ex2->ee_len = cpu_to_le16(e1_len); + if (unwritten) + ext4_ext_mark_unwritten(ex2); + if (ext4_ext_is_unwritten(&tmp_ex)) + ext4_ext_mark_unwritten(ex1); + + ext4_ext_try_to_merge(handle, inode2, path2, ex2); + ext4_ext_try_to_merge(handle, inode1, path1, ex1); + *erp = ext4_ext_dirty(handle, inode2, path2 + + path2->p_depth); + if (unlikely(*erp)) + goto finish; + *erp = ext4_ext_dirty(handle, inode1, path1 + + path1->p_depth); + /* + * Looks scarry ah..? second inode already points to new blocks, + * and it was successfully dirtied. But luckily error may happen + * only due to journal error, so full transaction will be + * aborted anyway. + */ + if (unlikely(*erp)) + goto finish; + lblk1 += len; + lblk2 += len; + replaced_count += len; + count -= len; + + repeat: + ext4_ext_drop_refs(path1); + kfree(path1); + ext4_ext_drop_refs(path2); + kfree(path2); + path1 = path2 = NULL; + } + return replaced_count; +} +",0,"ext4_swap_extents(handle_t *handle, struct inode *inode1, + struct inode *inode2, ext4_lblk_t lblk1, ext4_lblk_t lblk2, + ext4_lblk_t count, int unwritten, int *erp) +{ + struct ext4_ext_path *path1 = NULL; + struct ext4_ext_path *path2 = NULL; + int replaced_count = 0; + + BUG_ON(!rwsem_is_locked(&EXT4_I(inode1)->i_data_sem)); + BUG_ON(!rwsem_is_locked(&EXT4_I(inode2)->i_data_sem)); + BUG_ON(!mutex_is_locked(&inode1->i_mutex)); + BUG_ON(!mutex_is_locked(&inode2->i_mutex)); + + *erp = ext4_es_remove_extent(inode1, lblk1, count); + if (unlikely(*erp)) + return 0; + *erp = ext4_es_remove_extent(inode2, lblk2, count); + if (unlikely(*erp)) + return 0; + + while (count) { + struct ext4_extent *ex1, *ex2, tmp_ex; + ext4_lblk_t e1_blk, e2_blk; + int e1_len, e2_len, len; + int split = 0; + + path1 = ext4_find_extent(inode1, lblk1, NULL, EXT4_EX_NOCACHE); + if (IS_ERR(path1)) { + *erp = PTR_ERR(path1); + path1 = NULL; + finish: + count = 0; + goto repeat; + } + path2 = ext4_find_extent(inode2, lblk2, NULL, EXT4_EX_NOCACHE); + if (IS_ERR(path2)) { + *erp = PTR_ERR(path2); + path2 = NULL; + goto finish; + } + ex1 = path1[path1->p_depth].p_ext; + ex2 = path2[path2->p_depth].p_ext; + /* Do we have somthing to swap ? */ + if (unlikely(!ex2 || !ex1)) + goto finish; + + e1_blk = le32_to_cpu(ex1->ee_block); + e2_blk = le32_to_cpu(ex2->ee_block); + e1_len = ext4_ext_get_actual_len(ex1); + e2_len = ext4_ext_get_actual_len(ex2); + + /* Hole handling */ + if (!in_range(lblk1, e1_blk, e1_len) || + !in_range(lblk2, e2_blk, e2_len)) { + ext4_lblk_t next1, next2; + + /* if hole after extent, then go to next extent */ + next1 = ext4_ext_next_allocated_block(path1); + next2 = ext4_ext_next_allocated_block(path2); + /* If hole before extent, then shift to that extent */ + if (e1_blk > lblk1) + next1 = e1_blk; + if (e2_blk > lblk2) + next2 = e1_blk; + /* Do we have something to swap */ + if (next1 == EXT_MAX_BLOCKS || next2 == EXT_MAX_BLOCKS) + goto finish; + /* Move to the rightest boundary */ + len = next1 - lblk1; + if (len < next2 - lblk2) + len = next2 - lblk2; + if (len > count) + len = count; + lblk1 += len; + lblk2 += len; + count -= len; + goto repeat; + } + + /* Prepare left boundary */ + if (e1_blk < lblk1) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode1, + &path1, lblk1, 0); + if (unlikely(*erp)) + goto finish; + } + if (e2_blk < lblk2) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode2, + &path2, lblk2, 0); + if (unlikely(*erp)) + goto finish; + } + /* ext4_split_extent_at() may result in leaf extent split, + * path must to be revalidated. */ + if (split) + goto repeat; + + /* Prepare right boundary */ + len = count; + if (len > e1_blk + e1_len - lblk1) + len = e1_blk + e1_len - lblk1; + if (len > e2_blk + e2_len - lblk2) + len = e2_blk + e2_len - lblk2; + + if (len != e1_len) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode1, + &path1, lblk1 + len, 0); + if (unlikely(*erp)) + goto finish; + } + if (len != e2_len) { + split = 1; + *erp = ext4_force_split_extent_at(handle, inode2, + &path2, lblk2 + len, 0); + if (*erp) + goto finish; + } + /* ext4_split_extent_at() may result in leaf extent split, + * path must to be revalidated. */ + if (split) + goto repeat; + + BUG_ON(e2_len != e1_len); + *erp = ext4_ext_get_access(handle, inode1, path1 + path1->p_depth); + if (unlikely(*erp)) + goto finish; + *erp = ext4_ext_get_access(handle, inode2, path2 + path2->p_depth); + if (unlikely(*erp)) + goto finish; + + /* Both extents are fully inside boundaries. Swap it now */ + tmp_ex = *ex1; + ext4_ext_store_pblock(ex1, ext4_ext_pblock(ex2)); + ext4_ext_store_pblock(ex2, ext4_ext_pblock(&tmp_ex)); + ex1->ee_len = cpu_to_le16(e2_len); + ex2->ee_len = cpu_to_le16(e1_len); + if (unwritten) + ext4_ext_mark_unwritten(ex2); + if (ext4_ext_is_unwritten(&tmp_ex)) + ext4_ext_mark_unwritten(ex1); + + ext4_ext_try_to_merge(handle, inode2, path2, ex2); + ext4_ext_try_to_merge(handle, inode1, path1, ex1); + *erp = ext4_ext_dirty(handle, inode2, path2 + + path2->p_depth); + if (unlikely(*erp)) + goto finish; + *erp = ext4_ext_dirty(handle, inode1, path1 + + path1->p_depth); + /* + * Looks scarry ah..? second inode already points to new blocks, + * and it was successfully dirtied. But luckily error may happen + * only due to journal error, so full transaction will be + * aborted anyway. + */ + if (unlikely(*erp)) + goto finish; + lblk1 += len; + lblk2 += len; + replaced_count += len; + count -= len; + + repeat: + ext4_ext_drop_refs(path1); + kfree(path1); + ext4_ext_drop_refs(path2); + kfree(path2); + path1 = path2 = NULL; + } + return replaced_count; +} +","@@ -4770,7 +4770,6 @@ static long ext4_zero_range(struct file *file, loff_t offset, + int partial_begin, partial_end; + loff_t start, end; + ext4_lblk_t lblk; +- struct address_space *mapping = inode->i_mapping; + unsigned int blkbits = inode->i_blkbits; + + trace_ext4_zero_range(inode, offset, len, mode); +@@ -4785,17 +4784,6 @@ static long ext4_zero_range(struct file *file, loff_t offset, + return ret; + } + +- /* +- * Write out all dirty pages to avoid race conditions +- * Then release them. +- */ +- if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { +- ret = filemap_write_and_wait_range(mapping, offset, +- offset + len - 1); +- if (ret) +- return ret; +- } +- + /* + * Round up offset. This is not fallocate, we neet to zero out + * blocks, so convert interior block aligned part of the range to +@@ -4856,16 +4844,22 @@ static long ext4_zero_range(struct file *file, loff_t offset, + flags |= (EXT4_GET_BLOCKS_CONVERT_UNWRITTEN | + EXT4_EX_NOCACHE); + +- /* Now release the pages and zero block aligned part of pages*/ +- truncate_pagecache_range(inode, start, end - 1); +- inode->i_mtime = inode->i_ctime = ext4_current_time(inode); +- + /* Wait all existing dio workers, newcomers will block on i_mutex */ + ext4_inode_block_unlocked_dio(inode); + inode_dio_wait(inode); + ++ /* ++ * Prevent page faults from reinstantiating pages we have ++ * released from page cache. ++ */ ++ down_write(&EXT4_I(inode)->i_mmap_sem); ++ /* Now release the pages and zero block aligned part of pages */ ++ truncate_pagecache_range(inode, start, end - 1); ++ inode->i_mtime = inode->i_ctime = ext4_current_time(inode); ++ + ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size, + flags, mode); ++ up_write(&EXT4_I(inode)->i_mmap_sem); + if (ret) + goto out_dio; + } +@@ -5524,17 +5518,22 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) + goto out_mutex; + } + +- truncate_pagecache(inode, ioffset); +- + /* Wait for existing dio to complete */ + ext4_inode_block_unlocked_dio(inode); + inode_dio_wait(inode); + ++ /* ++ * Prevent page faults from reinstantiating pages we have released from ++ * page cache. ++ */ ++ down_write(&EXT4_I(inode)->i_mmap_sem); ++ truncate_pagecache(inode, ioffset); ++ + credits = ext4_writepage_trans_blocks(inode); + handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); +- goto out_dio; ++ goto out_mmap; + } + + down_write(&EXT4_I(inode)->i_data_sem); +@@ -5573,7 +5572,8 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) + + out_stop: + ext4_journal_stop(handle); +-out_dio: ++out_mmap: ++ up_write(&EXT4_I(inode)->i_mmap_sem); + ext4_inode_resume_unlocked_dio(inode); + out_mutex: + mutex_unlock(&inode->i_mutex); +@@ -5660,17 +5660,22 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) + goto out_mutex; + } + +- truncate_pagecache(inode, ioffset); +- + /* Wait for existing dio to complete */ + ext4_inode_block_unlocked_dio(inode); + inode_dio_wait(inode); + ++ /* ++ * Prevent page faults from reinstantiating pages we have released from ++ * page cache. ++ */ ++ down_write(&EXT4_I(inode)->i_mmap_sem); ++ truncate_pagecache(inode, ioffset); ++ + credits = ext4_writepage_trans_blocks(inode); + handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); +- goto out_dio; ++ goto out_mmap; + } + + /* Expand file to avoid data loss if there is error while shifting */ +@@ -5741,7 +5746,8 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) + + out_stop: + ext4_journal_stop(handle); +-out_dio: ++out_mmap: ++ up_write(&EXT4_I(inode)->i_mmap_sem); + ext4_inode_resume_unlocked_dio(inode); + out_mutex: + mutex_unlock(&inode->i_mutex);",1607,1843,2048 +794,"static void cirrus_vga_write_sr(CirrusVGAState * s, uint32_t val) +{ + switch (s->vga.sr_index) { + case 0x00: // Standard VGA + case 0x01: // Standard VGA + case 0x02: // Standard VGA + case 0x03: // Standard VGA + case 0x04: // Standard VGA + s->vga.sr[s->vga.sr_index] = val & sr_mask[s->vga.sr_index]; + if (s->vga.sr_index == 1) + s->vga.update_retrace_info(&s->vga); + break; + case 0x06: // Unlock Cirrus extensions + val &= 0x17; + if (val == 0x12) { + s->vga.sr[s->vga.sr_index] = 0x12; + } else { + s->vga.sr[s->vga.sr_index] = 0x0f; + } + break; + case 0x10: + case 0x30: + case 0x50: + case 0x70: // Graphics Cursor X + case 0x90: + case 0xb0: + case 0xd0: + case 0xf0: // Graphics Cursor X + s->vga.sr[0x10] = val; + s->hw_cursor_x = (val << 3) | (s->vga.sr_index >> 5); + break; + case 0x11: + case 0x31: + case 0x51: + case 0x71: // Graphics Cursor Y + case 0x91: + case 0xb1: + case 0xd1: + case 0xf1: // Graphics Cursor Y + s->vga.sr[0x11] = val; + s->hw_cursor_y = (val << 3) | (s->vga.sr_index >> 5); + break; + case 0x07: // Extended Sequencer Mode + cirrus_update_memory_access(s); + case 0x08: // EEPROM Control + case 0x09: // Scratch Register 0 + case 0x0a: // Scratch Register 1 + case 0x0b: // VCLK 0 + case 0x0c: // VCLK 1 + case 0x0d: // VCLK 2 + case 0x0e: // VCLK 3 + case 0x0f: // DRAM Control + case 0x12: // Graphics Cursor Attribute + case 0x13: // Graphics Cursor Pattern Address + case 0x14: // Scratch Register 2 + case 0x15: // Scratch Register 3 + case 0x16: // Performance Tuning Register + case 0x18: // Signature Generator Control + case 0x19: // Signature Generator Result + case 0x1a: // Signature Generator Result + case 0x1b: // VCLK 0 Denominator & Post + case 0x1c: // VCLK 1 Denominator & Post + case 0x1d: // VCLK 2 Denominator & Post + case 0x1e: // VCLK 3 Denominator & Post + case 0x1f: // BIOS Write Enable and MCLK select + s->vga.sr[s->vga.sr_index] = val; +#ifdef DEBUG_CIRRUS + printf(""cirrus: handled outport sr_index %02x, sr_value %02x\n"", + s->vga.sr_index, val); +#endif + break; + case 0x17: // Configuration Readback and Extended Control + s->vga.sr[s->vga.sr_index] = (s->vga.sr[s->vga.sr_index] & 0x38) + | (val & 0xc7); + cirrus_update_memory_access(s); + break; + default: +#ifdef DEBUG_CIRRUS + printf(""cirrus: outport sr_index %02x, sr_value %02x\n"", + s->vga.sr_index, val); +#endif + break; + } +} +",0,"static void cirrus_vga_write_sr(CirrusVGAState * s, uint32_t val) +{ + switch (s->vga.sr_index) { + case 0x00: // Standard VGA + case 0x01: // Standard VGA + case 0x02: // Standard VGA + case 0x03: // Standard VGA + case 0x04: // Standard VGA + s->vga.sr[s->vga.sr_index] = val & sr_mask[s->vga.sr_index]; + if (s->vga.sr_index == 1) + s->vga.update_retrace_info(&s->vga); + break; + case 0x06: // Unlock Cirrus extensions + val &= 0x17; + if (val == 0x12) { + s->vga.sr[s->vga.sr_index] = 0x12; + } else { + s->vga.sr[s->vga.sr_index] = 0x0f; + } + break; + case 0x10: + case 0x30: + case 0x50: + case 0x70: // Graphics Cursor X + case 0x90: + case 0xb0: + case 0xd0: + case 0xf0: // Graphics Cursor X + s->vga.sr[0x10] = val; + s->hw_cursor_x = (val << 3) | (s->vga.sr_index >> 5); + break; + case 0x11: + case 0x31: + case 0x51: + case 0x71: // Graphics Cursor Y + case 0x91: + case 0xb1: + case 0xd1: + case 0xf1: // Graphics Cursor Y + s->vga.sr[0x11] = val; + s->hw_cursor_y = (val << 3) | (s->vga.sr_index >> 5); + break; + case 0x07: // Extended Sequencer Mode + cirrus_update_memory_access(s); + case 0x08: // EEPROM Control + case 0x09: // Scratch Register 0 + case 0x0a: // Scratch Register 1 + case 0x0b: // VCLK 0 + case 0x0c: // VCLK 1 + case 0x0d: // VCLK 2 + case 0x0e: // VCLK 3 + case 0x0f: // DRAM Control + case 0x12: // Graphics Cursor Attribute + case 0x13: // Graphics Cursor Pattern Address + case 0x14: // Scratch Register 2 + case 0x15: // Scratch Register 3 + case 0x16: // Performance Tuning Register + case 0x18: // Signature Generator Control + case 0x19: // Signature Generator Result + case 0x1a: // Signature Generator Result + case 0x1b: // VCLK 0 Denominator & Post + case 0x1c: // VCLK 1 Denominator & Post + case 0x1d: // VCLK 2 Denominator & Post + case 0x1e: // VCLK 3 Denominator & Post + case 0x1f: // BIOS Write Enable and MCLK select + s->vga.sr[s->vga.sr_index] = val; +#ifdef DEBUG_CIRRUS + printf(""cirrus: handled outport sr_index %02x, sr_value %02x\n"", + s->vga.sr_index, val); +#endif + break; + case 0x17: // Configuration Readback and Extended Control + s->vga.sr[s->vga.sr_index] = (s->vga.sr[s->vga.sr_index] & 0x38) + | (val & 0xc7); + cirrus_update_memory_access(s); + break; + default: +#ifdef DEBUG_CIRRUS + printf(""cirrus: outport sr_index %02x, sr_value %02x\n"", + s->vga.sr_index, val); +#endif + break; + } +} +","@@ -293,6 +293,10 @@ static bool blit_is_unsafe(struct CirrusVGAState *s) + assert(s->cirrus_blt_width > 0); + assert(s->cirrus_blt_height > 0); + ++ if (s->cirrus_blt_width > CIRRUS_BLTBUFSIZE) { ++ return true; ++ } ++ + if (blit_region_is_unsafe(s, s->cirrus_blt_dstpitch, + s->cirrus_blt_dstaddr & s->cirrus_addr_mask)) { + return true;",1043,1279,2048 +16394,"xmlBufResize(xmlBufPtr buf, size_t size) +{ + unsigned int newSize; + xmlChar* rebuf = NULL; + size_t start_buf; + + if ((buf == NULL) || (buf->error)) + return(0); + CHECK_COMPAT(buf) + + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); + if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { + /* + * Used to provide parsing limits + */ + if (size >= XML_MAX_TEXT_LENGTH) { + xmlBufMemoryError(buf, ""buffer error: text too long\n""); + return(0); + } + } + + /* Don't resize if we don't have to */ + if (size < buf->size) + return 1; + + /* figure out new size */ + switch (buf->alloc){ + case XML_BUFFER_ALLOC_IO: + case XML_BUFFER_ALLOC_DOUBLEIT: + /*take care of empty case*/ + newSize = (buf->size ? buf->size*2 : size + 10); + while (size > newSize) { + if (newSize > UINT_MAX / 2) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + newSize *= 2; + } + break; + case XML_BUFFER_ALLOC_EXACT: + newSize = size+10; + break; + case XML_BUFFER_ALLOC_HYBRID: + if (buf->use < BASE_BUFFER_SIZE) + newSize = size; + else { + newSize = buf->size * 2; + while (size > newSize) { + if (newSize > UINT_MAX / 2) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + newSize *= 2; + } + } + break; + + default: + newSize = size+10; + break; + } + + if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { + start_buf = buf->content - buf->contentIO; + + if (start_buf > newSize) { + /* move data back to start */ + memmove(buf->contentIO, buf->content, buf->use); + buf->content = buf->contentIO; + buf->content[buf->use] = 0; + buf->size += start_buf; + } else { + rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize); + if (rebuf == NULL) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + buf->contentIO = rebuf; + buf->content = rebuf + start_buf; + } + } else { + if (buf->content == NULL) { + rebuf = (xmlChar *) xmlMallocAtomic(newSize); + } else if (buf->size - buf->use < 100) { + rebuf = (xmlChar *) xmlRealloc(buf->content, newSize); + } else { + /* + * if we are reallocating a buffer far from being full, it's + * better to make a new allocation and copy only the used range + * and free the old one. + */ + rebuf = (xmlChar *) xmlMallocAtomic(newSize); + if (rebuf != NULL) { + memcpy(rebuf, buf->content, buf->use); + xmlFree(buf->content); + rebuf[buf->use] = 0; + } + } + if (rebuf == NULL) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + buf->content = rebuf; + } + buf->size = newSize; + UPDATE_COMPAT(buf) + + return 1; +} +",0,"xmlBufResize(xmlBufPtr buf, size_t size) +{ + unsigned int newSize; + xmlChar* rebuf = NULL; + size_t start_buf; + + if ((buf == NULL) || (buf->error)) + return(0); + CHECK_COMPAT(buf) + + if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); + if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) { + /* + * Used to provide parsing limits + */ + if (size >= XML_MAX_TEXT_LENGTH) { + xmlBufMemoryError(buf, ""buffer error: text too long\n""); + return(0); + } + } + + /* Don't resize if we don't have to */ + if (size < buf->size) + return 1; + + /* figure out new size */ + switch (buf->alloc){ + case XML_BUFFER_ALLOC_IO: + case XML_BUFFER_ALLOC_DOUBLEIT: + /*take care of empty case*/ + newSize = (buf->size ? buf->size*2 : size + 10); + while (size > newSize) { + if (newSize > UINT_MAX / 2) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + newSize *= 2; + } + break; + case XML_BUFFER_ALLOC_EXACT: + newSize = size+10; + break; + case XML_BUFFER_ALLOC_HYBRID: + if (buf->use < BASE_BUFFER_SIZE) + newSize = size; + else { + newSize = buf->size * 2; + while (size > newSize) { + if (newSize > UINT_MAX / 2) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + newSize *= 2; + } + } + break; + + default: + newSize = size+10; + break; + } + + if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) { + start_buf = buf->content - buf->contentIO; + + if (start_buf > newSize) { + /* move data back to start */ + memmove(buf->contentIO, buf->content, buf->use); + buf->content = buf->contentIO; + buf->content[buf->use] = 0; + buf->size += start_buf; + } else { + rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize); + if (rebuf == NULL) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + buf->contentIO = rebuf; + buf->content = rebuf + start_buf; + } + } else { + if (buf->content == NULL) { + rebuf = (xmlChar *) xmlMallocAtomic(newSize); + } else if (buf->size - buf->use < 100) { + rebuf = (xmlChar *) xmlRealloc(buf->content, newSize); + } else { + /* + * if we are reallocating a buffer far from being full, it's + * better to make a new allocation and copy only the used range + * and free the old one. + */ + rebuf = (xmlChar *) xmlMallocAtomic(newSize); + if (rebuf != NULL) { + memcpy(rebuf, buf->content, buf->use); + xmlFree(buf->content); + rebuf[buf->use] = 0; + } + } + if (rebuf == NULL) { + xmlBufMemoryError(buf, ""growing buffer""); + return 0; + } + buf->content = rebuf; + } + buf->size = newSize; + UPDATE_COMPAT(buf) + + return 1; +} +","@@ -231,7 +231,7 @@ xmlBufPtr + xmlBufCreateStatic(void *mem, size_t size) { + xmlBufPtr ret; + +- if ((mem == NULL) || (size == 0)) ++ if (mem == NULL) + return(NULL); + + ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));",792,1028,2048 +9072,"static MagickBooleanType LoadLocaleCache(SplayTreeInfo *cache,const char *xml, + const char *filename,const char *locale,const size_t depth,ExceptionInfo *exception) +{ + char + keyword[MagickLocaleExtent], + message[MagickLocaleExtent], + tag[MagickLocaleExtent], + *token; + + const char + *q; + + FatalErrorHandler + fatal_handler; + + LocaleInfo + *locale_info; + + MagickStatusType + status; + + register char + *p; + + size_t + extent; + + /* + Read the locale configure file. + */ + (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), + ""Loading locale configure file \""%s\"" ..."",filename); + if (xml == (const char *) NULL) + return(MagickFalse); + status=MagickTrue; + locale_info=(LocaleInfo *) NULL; + *tag='\0'; + *message='\0'; + *keyword='\0'; + fatal_handler=SetFatalErrorHandler(LocaleFatalErrorHandler); + token=AcquireString(xml); + extent=strlen(token)+MagickPathExtent; + for (q=(char *) xml; *q != '\0'; ) + { + /* + Interpret XML. + */ + GetNextToken(q,&q,extent,token); + if (*token == '\0') + break; + (void) CopyMagickString(keyword,token,MagickLocaleExtent); + if (LocaleNCompare(keyword,"""",2) != 0) && (*q != '\0')) + { + GetNextToken(q,&q,extent,token); + while (isspace((int) ((unsigned char) *q)) != 0) + q++; + } + continue; + } + if (LocaleNCompare(keyword,"" TOTAL PROCESSING TIME""); +@@ -5074,6 +5076,9 @@ + + index = bufferHdr - m_inp_mem_ptr; + DEBUG_PRINT_LOW(""Free Input Buffer index = %d"",index); + ++ auto_lock l(buf_lock); ++ bufferHdr->pInputPortPrivate = NULL; ++ + if (index < drv_ctx.ip_buf.actualcount && drv_ctx.ptr_inputbuffer) { + DEBUG_PRINT_LOW(""Free Input Buffer index = %d"",index); + if (drv_ctx.ptr_inputbuffer[index].pmem_fd > 0) { +@@ -6022,7 +6027,9 @@ + + OMX_ERRORTYPE ret1 = OMX_ErrorNone; + unsigned int nBufferIndex = drv_ctx.ip_buf.actualcount; + +- if (m_state == OMX_StateInvalid) { ++ if (m_state != OMX_StateExecuting && ++ m_state != OMX_StatePause && ++ m_state != OMX_StateIdle) { + DEBUG_PRINT_ERROR(""Empty this buffer in Invalid State""); + return OMX_ErrorInvalidState; + } +@@ -6156,9 +6163,10 @@ + + return OMX_ErrorNone; + } + ++ auto_lock l(buf_lock); + temp_buffer = (struct vdec_bufferpayload *)buffer->pInputPortPrivate; + +- if ((temp_buffer - drv_ctx.ptr_inputbuffer) > (int)drv_ctx.ip_buf.actualcount) { ++ if (!temp_buffer || (temp_buffer - drv_ctx.ptr_inputbuffer) > (int)drv_ctx.ip_buf.actualcount) { + return OMX_ErrorBadParameter; + } + /* If its first frame, H264 codec and reject is true, then parse the nal +@@ -6184,7 +6192,7 @@ + + /*for use buffer we need to memcpy the data*/ + temp_buffer->buffer_len = buffer->nFilledLen; + +- if (input_use_buffer) { ++ if (input_use_buffer && temp_buffer->bufferaddr) { + if (buffer->nFilledLen <= temp_buffer->buffer_len) { + if (arbitrary_bytes) { + memcpy (temp_buffer->bufferaddr, (buffer->pBuffer + buffer->nOffset),buffer->nFilledLen); +@@ -6352,6 +6360,18 @@ + + OMX_ERRORTYPE omx_vdec::fill_this_buffer(OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_BUFFERHEADERTYPE* buffer) + { ++ if (m_state != OMX_StateExecuting && ++ m_state != OMX_StatePause && ++ m_state != OMX_StateIdle) { ++ DEBUG_PRINT_ERROR(""FTB in Invalid State""); ++ return OMX_ErrorInvalidState; ++ } ++ ++ if (!m_out_bEnabled) { ++ DEBUG_PRINT_ERROR(""ERROR:FTB incorrect state operation, output port is disabled.""); ++ return OMX_ErrorIncorrectStateOperation; ++ } ++ + unsigned nPortIndex = 0; + if (dynamic_buf_mode) { + private_handle_t *handle = NULL; +@@ -6389,17 +6409,6 @@ + + buffer->nAllocLen = handle->size; + } + +- +- if (m_state == OMX_StateInvalid) { +- DEBUG_PRINT_ERROR(""FTB in Invalid State""); +- return OMX_ErrorInvalidState; +- } +- +- if (!m_out_bEnabled) { +- DEBUG_PRINT_ERROR(""ERROR:FTB incorrect state operation, output port is disabled.""); +- return OMX_ErrorIncorrectStateOperation; +- } +- + nPortIndex = buffer - client_buffers.get_il_buf_hdr(); + if (buffer == NULL || + (nPortIndex >= drv_ctx.op_buf.actualcount)) { +",1009,1245,2048 +17420,"FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode) +{ + FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; + FLAC__int32 i32; + FLAC__uint32 u32; + unsigned u; + + decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; + + subframe->residual = decoder->private_->residual[channel]; + subframe->order = order; + + /* read warm-up samples */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps)) + return false; /* read_callback_ sets the state for us */ + subframe->warmup[u] = i32; + } + + /* read qlp coeff precision */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN)) + return false; /* read_callback_ sets the state for us */ + if(u32 == (1u << FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN) - 1) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + subframe->qlp_coeff_precision = u32+1; + + /* read qlp shift */ + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->quantization_level = i32; + + /* read quantized lp coefficiencts */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) + return false; /* read_callback_ sets the state for us */ + subframe->qlp_coeff[u] = i32; + } + + /* read entropy coding method info */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32; + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->entropy_coding_method.data.partitioned_rice.order = u32; + subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel]; + break; + default: + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + + /* read residual */ + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2)) + return false; + break; + default: + FLAC__ASSERT(0); + } + + /* decode the subframe */ + if(do_full_decode) { + memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); + /*@@@@@@ technically not pessimistic enough, should be more like + if( (FLAC__uint64)order * ((((FLAC__uint64)1)<qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) ) + */ + if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32) + if(bps <= 16 && subframe->qlp_coeff_precision <= 16) + decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + else + decoder->private_->local_lpc_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + else + decoder->private_->local_lpc_restore_signal_64bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + } + + return true; +} +",0,"FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode) +{ + FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; + FLAC__int32 i32; + FLAC__uint32 u32; + unsigned u; + + decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; + + subframe->residual = decoder->private_->residual[channel]; + subframe->order = order; + + /* read warm-up samples */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps)) + return false; /* read_callback_ sets the state for us */ + subframe->warmup[u] = i32; + } + + /* read qlp coeff precision */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN)) + return false; /* read_callback_ sets the state for us */ + if(u32 == (1u << FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN) - 1) { + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + subframe->qlp_coeff_precision = u32+1; + + /* read qlp shift */ + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->quantization_level = i32; + + /* read quantized lp coefficiencts */ + for(u = 0; u < order; u++) { + if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) + return false; /* read_callback_ sets the state for us */ + subframe->qlp_coeff[u] = i32; + } + + /* read entropy coding method info */ + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32; + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) + return false; /* read_callback_ sets the state for us */ + subframe->entropy_coding_method.data.partitioned_rice.order = u32; + subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel]; + break; + default: + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + + /* read residual */ + switch(subframe->entropy_coding_method.type) { + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: + case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: + if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2)) + return false; + break; + default: + FLAC__ASSERT(0); + } + + /* decode the subframe */ + if(do_full_decode) { + memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); + /*@@@@@@ technically not pessimistic enough, should be more like + if( (FLAC__uint64)order * ((((FLAC__uint64)1)<qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) ) + */ + if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32) + if(bps <= 16 && subframe->qlp_coeff_precision <= 16) + decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + else + decoder->private_->local_lpc_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + else + decoder->private_->local_lpc_restore_signal_64bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); + } + + return true; +} +","@@ -1739,6 +1739,7 @@ + + if (obj->num_comments > 0) { + if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; ++ obj->num_comments = 0; + return false; + } + for (i = 0; i < obj->num_comments; i++) { +",1237,1473,2048 +8510,"static int ocfs2_write_cluster(struct address_space *mapping, + u32 *phys, unsigned int new, + unsigned int clear_unwritten, + unsigned int should_zero, + struct ocfs2_alloc_context *data_ac, + struct ocfs2_alloc_context *meta_ac, + struct ocfs2_write_ctxt *wc, u32 cpos, + loff_t user_pos, unsigned user_len) +{ + int ret, i; + u64 p_blkno; + struct inode *inode = mapping->host; + struct ocfs2_extent_tree et; + int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); + + if (new) { + u32 tmp_pos; + + /* + * This is safe to call with the page locks - it won't take + * any additional semaphores or cluster locks. + */ + tmp_pos = cpos; + ret = ocfs2_add_inode_data(OCFS2_SB(inode->i_sb), inode, + &tmp_pos, 1, !clear_unwritten, + wc->w_di_bh, wc->w_handle, + data_ac, meta_ac, NULL); + /* + * This shouldn't happen because we must have already + * calculated the correct meta data allocation required. The + * internal tree allocation code should know how to increase + * transaction credits itself. + * + * If need be, we could handle -EAGAIN for a + * RESTART_TRANS here. + */ + mlog_bug_on_msg(ret == -EAGAIN, + ""Inode %llu: EAGAIN return during allocation.\n"", + (unsigned long long)OCFS2_I(inode)->ip_blkno); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } else if (clear_unwritten) { + ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), + wc->w_di_bh); + ret = ocfs2_mark_extent_written(inode, &et, + wc->w_handle, cpos, 1, *phys, + meta_ac, &wc->w_dealloc); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } + + /* + * The only reason this should fail is due to an inability to + * find the extent added. + */ + ret = ocfs2_get_clusters(inode, cpos, phys, NULL, NULL); + if (ret < 0) { + mlog(ML_ERROR, ""Get physical blkno failed for inode %llu, "" + ""at logical cluster %u"", + (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos); + goto out; + } + + BUG_ON(*phys == 0); + + p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, *phys); + if (!should_zero) + p_blkno += (user_pos >> inode->i_sb->s_blocksize_bits) & (u64)(bpc - 1); + + for(i = 0; i < wc->w_num_pages; i++) { + int tmpret; + + /* This is the direct io target page. */ + if (wc->w_pages[i] == NULL) { + p_blkno++; + continue; + } + + tmpret = ocfs2_prepare_page_for_write(inode, &p_blkno, wc, + wc->w_pages[i], cpos, + user_pos, user_len, + should_zero); + if (tmpret) { + mlog_errno(tmpret); + if (ret == 0) + ret = tmpret; + } + } + + /* + * We only have cleanup to do in case of allocating write. + */ + if (ret && new) + ocfs2_write_failure(inode, wc, user_pos, user_len); + +out: + + return ret; +} +",0,"static int ocfs2_write_cluster(struct address_space *mapping, + u32 *phys, unsigned int new, + unsigned int clear_unwritten, + unsigned int should_zero, + struct ocfs2_alloc_context *data_ac, + struct ocfs2_alloc_context *meta_ac, + struct ocfs2_write_ctxt *wc, u32 cpos, + loff_t user_pos, unsigned user_len) +{ + int ret, i; + u64 p_blkno; + struct inode *inode = mapping->host; + struct ocfs2_extent_tree et; + int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); + + if (new) { + u32 tmp_pos; + + /* + * This is safe to call with the page locks - it won't take + * any additional semaphores or cluster locks. + */ + tmp_pos = cpos; + ret = ocfs2_add_inode_data(OCFS2_SB(inode->i_sb), inode, + &tmp_pos, 1, !clear_unwritten, + wc->w_di_bh, wc->w_handle, + data_ac, meta_ac, NULL); + /* + * This shouldn't happen because we must have already + * calculated the correct meta data allocation required. The + * internal tree allocation code should know how to increase + * transaction credits itself. + * + * If need be, we could handle -EAGAIN for a + * RESTART_TRANS here. + */ + mlog_bug_on_msg(ret == -EAGAIN, + ""Inode %llu: EAGAIN return during allocation.\n"", + (unsigned long long)OCFS2_I(inode)->ip_blkno); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } else if (clear_unwritten) { + ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), + wc->w_di_bh); + ret = ocfs2_mark_extent_written(inode, &et, + wc->w_handle, cpos, 1, *phys, + meta_ac, &wc->w_dealloc); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } + + /* + * The only reason this should fail is due to an inability to + * find the extent added. + */ + ret = ocfs2_get_clusters(inode, cpos, phys, NULL, NULL); + if (ret < 0) { + mlog(ML_ERROR, ""Get physical blkno failed for inode %llu, "" + ""at logical cluster %u"", + (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos); + goto out; + } + + BUG_ON(*phys == 0); + + p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, *phys); + if (!should_zero) + p_blkno += (user_pos >> inode->i_sb->s_blocksize_bits) & (u64)(bpc - 1); + + for(i = 0; i < wc->w_num_pages; i++) { + int tmpret; + + /* This is the direct io target page. */ + if (wc->w_pages[i] == NULL) { + p_blkno++; + continue; + } + + tmpret = ocfs2_prepare_page_for_write(inode, &p_blkno, wc, + wc->w_pages[i], cpos, + user_pos, user_len, + should_zero); + if (tmpret) { + mlog_errno(tmpret); + if (ret == 0) + ret = tmpret; + } + } + + /* + * We only have cleanup to do in case of allocating write. + */ + if (ret && new) + ocfs2_write_failure(inode, wc, user_pos, user_len); + +out: + + return ret; +} +","@@ -134,6 +134,19 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, + return err; + } + ++static int ocfs2_lock_get_block(struct inode *inode, sector_t iblock, ++ struct buffer_head *bh_result, int create) ++{ ++ int ret = 0; ++ struct ocfs2_inode_info *oi = OCFS2_I(inode); ++ ++ down_read(&oi->ip_alloc_sem); ++ ret = ocfs2_get_block(inode, iblock, bh_result, create); ++ up_read(&oi->ip_alloc_sem); ++ ++ return ret; ++} ++ + int ocfs2_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { +@@ -2128,7 +2141,7 @@ static void ocfs2_dio_free_write_ctx(struct inode *inode, + * called like this: dio->get_blocks(dio->inode, fs_startblk, + * fs_count, map_bh, dio->rw == WRITE); + */ +-static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, ++static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); +@@ -2154,12 +2167,9 @@ static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, + * while file size will be changed. + */ + if (pos + total_len <= i_size_read(inode)) { +- down_read(&oi->ip_alloc_sem); +- /* This is the fast path for re-write. */ +- ret = ocfs2_get_block(inode, iblock, bh_result, create); +- +- up_read(&oi->ip_alloc_sem); + ++ /* This is the fast path for re-write. */ ++ ret = ocfs2_lock_get_block(inode, iblock, bh_result, create); + if (buffer_mapped(bh_result) && + !buffer_new(bh_result) && + ret == 0) +@@ -2424,9 +2434,9 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) + return 0; + + if (iov_iter_rw(iter) == READ) +- get_block = ocfs2_get_block; ++ get_block = ocfs2_lock_get_block; + else +- get_block = ocfs2_dio_get_block; ++ get_block = ocfs2_dio_wr_get_block; + + return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, + iter, get_block,",825,1061,2048 +16107,"void RenderFrameImpl::CommitNavigation( + const network::ResourceResponseHead& head, + const GURL& body_url, + const CommonNavigationParams& common_params, + const RequestNavigationParams& request_params, + network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints, + std::unique_ptr subresource_loader_factories, + mojom::ControllerServiceWorkerInfoPtr controller_service_worker_info, + const base::UnguessableToken& devtools_navigation_token) { + DCHECK(!IsRendererDebugURL(common_params.url)); + if (!browser_side_navigation_pending_ && + !browser_side_navigation_pending_url_.is_empty() && + browser_side_navigation_pending_url_ == request_params.original_url && + request_params.nav_entry_id == 0) { + browser_side_navigation_pending_url_ = GURL(); + return; + } + + controller_service_worker_info_ = std::move(controller_service_worker_info); + + std::unique_ptr gesture( + common_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) + : nullptr); + + browser_side_navigation_pending_ = false; + browser_side_navigation_pending_url_ = GURL(); + + pending_navigation_info_.reset(nullptr); + + base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); + + bool is_reload = + FrameMsg_Navigate_Type::IsReload(common_params.navigation_type); + bool is_history_navigation = request_params.page_state.IsValid(); + auto cache_mode = blink::mojom::FetchCacheMode::kDefault; + RenderFrameImpl::PrepareRenderViewForNavigation(common_params.url, + request_params); + + GetContentClient()->SetActiveURL( + common_params.url, frame_->Top()->GetSecurityOrigin().ToString().Utf8()); + + if (is_reload && current_history_item_.IsNull()) { + is_reload = false; + cache_mode = blink::mojom::FetchCacheMode::kValidateCache; + } + + if (request_params.is_view_source) + frame_->EnableViewSourceMode(true); + + pending_navigation_params_.reset( + new NavigationParams(common_params, request_params)); + + pending_navigation_params_->common_params.navigation_start = + SanitizeNavigationTiming(common_params.navigation_start, + renderer_navigation_start); + + blink::WebFrameLoadType load_type = + common_params.should_replace_current_entry + ? blink::WebFrameLoadType::kReplaceCurrentItem + : blink::WebFrameLoadType::kStandard; + blink::WebHistoryLoadType history_load_type = + blink::kWebHistoryDifferentDocumentLoad; + bool should_load_request = false; + WebHistoryItem item_for_history_navigation; + bool is_same_document = + FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type); + + DCHECK(is_same_document || + common_params.url.SchemeIs(url::kJavaScriptScheme) || + !base::FeatureList::IsEnabled(network::features::kNetworkService) || + subresource_loader_factories); + + SetupLoaderFactoryBundle(std::move(subresource_loader_factories)); + + bool has_history_navigation_in_frame = false; + + if (is_reload) { + load_type = ReloadFrameLoadTypeFor(common_params.navigation_type); + should_load_request = true; + } else if (is_history_navigation) { + DCHECK_NE(0, request_params.nav_entry_id); + std::unique_ptr entry = + PageStateToHistoryEntry(request_params.page_state); + if (entry) { + item_for_history_navigation = entry->root(); + switch (common_params.navigation_type) { + case FrameMsg_Navigate_Type::RELOAD: + case FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE: + case FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL: + case FrameMsg_Navigate_Type::RESTORE: + case FrameMsg_Navigate_Type::RESTORE_WITH_POST: + case FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT: + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + break; + case FrameMsg_Navigate_Type::HISTORY_SAME_DOCUMENT: + history_load_type = blink::kWebHistorySameDocumentLoad; + break; + default: + NOTREACHED(); + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + } + load_type = request_params.is_history_navigation_in_new_child + ? blink::WebFrameLoadType::kInitialHistoryLoad + : blink::WebFrameLoadType::kBackForward; + should_load_request = true; + + history_subframe_unique_names_ = request_params.subframe_unique_names; + + if (history_load_type == blink::kWebHistorySameDocumentLoad) { + if (current_history_item_.IsNull()) { + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + NOTREACHED(); + } else { + if (current_history_item_.DocumentSequenceNumber() != + item_for_history_navigation.DocumentSequenceNumber()) { + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + } + } + } + + bool interrupted_by_client_redirect = + frame_->IsNavigationScheduledWithin(0) || + frame_->GetProvisionalDocumentLoader() || + !current_history_item_.IsNull(); + if (request_params.is_history_navigation_in_new_child && + interrupted_by_client_redirect) { + should_load_request = false; + has_history_navigation_in_frame = false; + } + } + } else { + should_load_request = true; + } + + if (should_load_request) { + base::WeakPtr weak_this = weak_factory_.GetWeakPtr(); + bool is_client_redirect = + !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT); + + bool should_load_data_url = !common_params.base_url_for_data_url.is_empty(); +#if defined(OS_ANDROID) + should_load_data_url |= !request_params.data_url_as_string.empty(); +#endif + if (is_main_frame_ && should_load_data_url) { + LoadDataURL(common_params, request_params, frame_, load_type, + item_for_history_navigation, history_load_type, + is_client_redirect); + } else { + WebURLRequest request = CreateURLRequestForCommit( + common_params, request_params, std::move(url_loader_client_endpoints), + head, body_url, is_same_document); + + frame_->Load(request, load_type, item_for_history_navigation, + history_load_type, is_client_redirect, + devtools_navigation_token); + + if (!weak_this) + return; + } + } else { + if (frame_ && !frame_->IsLoading() && !has_history_navigation_in_frame) + Send(new FrameHostMsg_DidStopLoading(routing_id_)); + } + + pending_navigation_params_.reset(); + + frame_->GetDocumentLoader()->ResetSourceLocation(); + if (frame_->GetProvisionalDocumentLoader()) + frame_->GetProvisionalDocumentLoader()->ResetSourceLocation(); +} +",0,"void RenderFrameImpl::CommitNavigation( + const network::ResourceResponseHead& head, + const GURL& body_url, + const CommonNavigationParams& common_params, + const RequestNavigationParams& request_params, + network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints, + std::unique_ptr subresource_loader_factories, + mojom::ControllerServiceWorkerInfoPtr controller_service_worker_info, + const base::UnguessableToken& devtools_navigation_token) { + DCHECK(!IsRendererDebugURL(common_params.url)); + if (!browser_side_navigation_pending_ && + !browser_side_navigation_pending_url_.is_empty() && + browser_side_navigation_pending_url_ == request_params.original_url && + request_params.nav_entry_id == 0) { + browser_side_navigation_pending_url_ = GURL(); + return; + } + + controller_service_worker_info_ = std::move(controller_service_worker_info); + + std::unique_ptr gesture( + common_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) + : nullptr); + + browser_side_navigation_pending_ = false; + browser_side_navigation_pending_url_ = GURL(); + + pending_navigation_info_.reset(nullptr); + + base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); + + bool is_reload = + FrameMsg_Navigate_Type::IsReload(common_params.navigation_type); + bool is_history_navigation = request_params.page_state.IsValid(); + auto cache_mode = blink::mojom::FetchCacheMode::kDefault; + RenderFrameImpl::PrepareRenderViewForNavigation(common_params.url, + request_params); + + GetContentClient()->SetActiveURL( + common_params.url, frame_->Top()->GetSecurityOrigin().ToString().Utf8()); + + if (is_reload && current_history_item_.IsNull()) { + is_reload = false; + cache_mode = blink::mojom::FetchCacheMode::kValidateCache; + } + + if (request_params.is_view_source) + frame_->EnableViewSourceMode(true); + + pending_navigation_params_.reset( + new NavigationParams(common_params, request_params)); + + pending_navigation_params_->common_params.navigation_start = + SanitizeNavigationTiming(common_params.navigation_start, + renderer_navigation_start); + + blink::WebFrameLoadType load_type = + common_params.should_replace_current_entry + ? blink::WebFrameLoadType::kReplaceCurrentItem + : blink::WebFrameLoadType::kStandard; + blink::WebHistoryLoadType history_load_type = + blink::kWebHistoryDifferentDocumentLoad; + bool should_load_request = false; + WebHistoryItem item_for_history_navigation; + bool is_same_document = + FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type); + + DCHECK(is_same_document || + common_params.url.SchemeIs(url::kJavaScriptScheme) || + !base::FeatureList::IsEnabled(network::features::kNetworkService) || + subresource_loader_factories); + + SetupLoaderFactoryBundle(std::move(subresource_loader_factories)); + + bool has_history_navigation_in_frame = false; + + if (is_reload) { + load_type = ReloadFrameLoadTypeFor(common_params.navigation_type); + should_load_request = true; + } else if (is_history_navigation) { + DCHECK_NE(0, request_params.nav_entry_id); + std::unique_ptr entry = + PageStateToHistoryEntry(request_params.page_state); + if (entry) { + item_for_history_navigation = entry->root(); + switch (common_params.navigation_type) { + case FrameMsg_Navigate_Type::RELOAD: + case FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE: + case FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL: + case FrameMsg_Navigate_Type::RESTORE: + case FrameMsg_Navigate_Type::RESTORE_WITH_POST: + case FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT: + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + break; + case FrameMsg_Navigate_Type::HISTORY_SAME_DOCUMENT: + history_load_type = blink::kWebHistorySameDocumentLoad; + break; + default: + NOTREACHED(); + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + } + load_type = request_params.is_history_navigation_in_new_child + ? blink::WebFrameLoadType::kInitialHistoryLoad + : blink::WebFrameLoadType::kBackForward; + should_load_request = true; + + history_subframe_unique_names_ = request_params.subframe_unique_names; + + if (history_load_type == blink::kWebHistorySameDocumentLoad) { + if (current_history_item_.IsNull()) { + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + NOTREACHED(); + } else { + if (current_history_item_.DocumentSequenceNumber() != + item_for_history_navigation.DocumentSequenceNumber()) { + history_load_type = blink::kWebHistoryDifferentDocumentLoad; + } + } + } + + bool interrupted_by_client_redirect = + frame_->IsNavigationScheduledWithin(0) || + frame_->GetProvisionalDocumentLoader() || + !current_history_item_.IsNull(); + if (request_params.is_history_navigation_in_new_child && + interrupted_by_client_redirect) { + should_load_request = false; + has_history_navigation_in_frame = false; + } + } + } else { + should_load_request = true; + } + + if (should_load_request) { + base::WeakPtr weak_this = weak_factory_.GetWeakPtr(); + bool is_client_redirect = + !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT); + + bool should_load_data_url = !common_params.base_url_for_data_url.is_empty(); +#if defined(OS_ANDROID) + should_load_data_url |= !request_params.data_url_as_string.empty(); +#endif + if (is_main_frame_ && should_load_data_url) { + LoadDataURL(common_params, request_params, frame_, load_type, + item_for_history_navigation, history_load_type, + is_client_redirect); + } else { + WebURLRequest request = CreateURLRequestForCommit( + common_params, request_params, std::move(url_loader_client_endpoints), + head, body_url, is_same_document); + + frame_->Load(request, load_type, item_for_history_navigation, + history_load_type, is_client_redirect, + devtools_navigation_token); + + if (!weak_this) + return; + } + } else { + if (frame_ && !frame_->IsLoading() && !has_history_navigation_in_frame) + Send(new FrameHostMsg_DidStopLoading(routing_id_)); + } + + pending_navigation_params_.reset(); + + frame_->GetDocumentLoader()->ResetSourceLocation(); + if (frame_->GetProvisionalDocumentLoader()) + frame_->GetProvisionalDocumentLoader()->ResetSourceLocation(); +} +","@@ -7046,6 +7046,10 @@ int RenderFrameImpl::GetEnabledBindings() const { + return enabled_bindings_; + } + ++void RenderFrameImpl::FrameDidCallFocus() { ++ Send(new FrameHostMsg_FrameDidCallFocus(routing_id_)); ++} ++ + void RenderFrameImpl::SetAccessibilityModeForTest(ui::AXMode new_mode) { + OnSetAccessibilityMode(new_mode); + }",1421,1657,2048 +4467,"int ssl3_check_cert_and_algorithm(SSL *s) +{ + int i, idx; + long alg_k, alg_a; + EVP_PKEY *pkey = NULL; + int pkey_bits; + SESS_CERT *sc; +#ifndef OPENSSL_NO_RSA + RSA *rsa; +#endif +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + alg_a = s->s3->tmp.new_cipher->algorithm_auth; + + /* we don't have a certificate */ + if ((alg_a & SSL_aNULL) || (alg_k & SSL_kPSK)) + return (1); + + sc = s->session->sess_cert; + if (sc == NULL) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto err; + } +#ifndef OPENSSL_NO_RSA + rsa = s->session->sess_cert->peer_rsa_tmp; +#endif +#ifndef OPENSSL_NO_DH + dh = s->session->sess_cert->peer_dh_tmp; +#endif + + /* This is the passed certificate */ + + idx = sc->peer_cert_type; +#ifndef OPENSSL_NO_EC + if (idx == SSL_PKEY_ECC) { + if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, s) == 0) { + /* check failed */ + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_BAD_ECC_CERT); + goto f_err; + } else { + return 1; + } + } else if (alg_a & SSL_aECDSA) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_ECDSA_SIGNING_CERT); + goto f_err; + } else if (alg_k & (SSL_kECDHr | SSL_kECDHe)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_ECDH_CERT); + goto f_err; + } +#endif + pkey = X509_get_pubkey(sc->peer_pkeys[idx].x509); + pkey_bits = EVP_PKEY_bits(pkey); + i = X509_certificate_type(sc->peer_pkeys[idx].x509, pkey); + EVP_PKEY_free(pkey); + + /* Check that we have a certificate if we require one */ + if ((alg_a & SSL_aRSA) && !has_bits(i, EVP_PK_RSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_SIGNING_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DSA_SIGNING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_RSA + if ((alg_k & SSL_kRSA) && + !(has_bits(i, EVP_PK_RSA | EVP_PKT_ENC) || (rsa != NULL))) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_DH + if ((alg_k & SSL_kDHE) && + !(has_bits(i, EVP_PK_DH | EVP_PKT_EXCH) || (dh != NULL))) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_KEY); + goto f_err; + } else if ((alg_k & SSL_kDHr) && !SSL_USE_SIGALGS(s) && + !has_bits(i, EVP_PK_DH | EVP_PKS_RSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_RSA_CERT); + goto f_err; + } +# ifndef OPENSSL_NO_DSA + else if ((alg_k & SSL_kDHd) && !SSL_USE_SIGALGS(s) && + !has_bits(i, EVP_PK_DH | EVP_PKS_DSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_DSA_CERT); + goto f_err; + } +# endif +#endif + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + pkey_bits > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) { + if (rsa == NULL + || RSA_size(rsa) * 8 > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & (SSL_kDHE | SSL_kDHr | SSL_kDHd)) { + if (dh == NULL + || DH_size(dh) * 8 > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } + } else +#endif + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + } + return (1); + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + err: + return (0); +} +",0,"int ssl3_check_cert_and_algorithm(SSL *s) +{ + int i, idx; + long alg_k, alg_a; + EVP_PKEY *pkey = NULL; + int pkey_bits; + SESS_CERT *sc; +#ifndef OPENSSL_NO_RSA + RSA *rsa; +#endif +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + alg_a = s->s3->tmp.new_cipher->algorithm_auth; + + /* we don't have a certificate */ + if ((alg_a & SSL_aNULL) || (alg_k & SSL_kPSK)) + return (1); + + sc = s->session->sess_cert; + if (sc == NULL) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); + goto err; + } +#ifndef OPENSSL_NO_RSA + rsa = s->session->sess_cert->peer_rsa_tmp; +#endif +#ifndef OPENSSL_NO_DH + dh = s->session->sess_cert->peer_dh_tmp; +#endif + + /* This is the passed certificate */ + + idx = sc->peer_cert_type; +#ifndef OPENSSL_NO_EC + if (idx == SSL_PKEY_ECC) { + if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, s) == 0) { + /* check failed */ + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_BAD_ECC_CERT); + goto f_err; + } else { + return 1; + } + } else if (alg_a & SSL_aECDSA) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_ECDSA_SIGNING_CERT); + goto f_err; + } else if (alg_k & (SSL_kECDHr | SSL_kECDHe)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_ECDH_CERT); + goto f_err; + } +#endif + pkey = X509_get_pubkey(sc->peer_pkeys[idx].x509); + pkey_bits = EVP_PKEY_bits(pkey); + i = X509_certificate_type(sc->peer_pkeys[idx].x509, pkey); + EVP_PKEY_free(pkey); + + /* Check that we have a certificate if we require one */ + if ((alg_a & SSL_aRSA) && !has_bits(i, EVP_PK_RSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_SIGNING_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA | EVP_PKT_SIGN)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DSA_SIGNING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_RSA + if ((alg_k & SSL_kRSA) && + !(has_bits(i, EVP_PK_RSA | EVP_PKT_ENC) || (rsa != NULL))) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_DH + if ((alg_k & SSL_kDHE) && + !(has_bits(i, EVP_PK_DH | EVP_PKT_EXCH) || (dh != NULL))) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_KEY); + goto f_err; + } else if ((alg_k & SSL_kDHr) && !SSL_USE_SIGALGS(s) && + !has_bits(i, EVP_PK_DH | EVP_PKS_RSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_RSA_CERT); + goto f_err; + } +# ifndef OPENSSL_NO_DSA + else if ((alg_k & SSL_kDHd) && !SSL_USE_SIGALGS(s) && + !has_bits(i, EVP_PK_DH | EVP_PKS_DSA)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_DH_DSA_CERT); + goto f_err; + } +# endif +#endif + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + pkey_bits > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) { + if (rsa == NULL + || RSA_size(rsa) * 8 > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & (SSL_kDHE | SSL_kDHr | SSL_kDHd)) { + if (dh == NULL + || DH_size(dh) * 8 > + SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } + } else +#endif + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, + SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + } + return (1); + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + err: + return (0); +} +","@@ -2238,6 +2238,38 @@ int ssl3_get_new_session_ticket(SSL *s) + } + + p = d = (unsigned char *)s->init_msg; ++ ++ if (s->session->session_id_length > 0) { ++ int i = s->session_ctx->session_cache_mode; ++ SSL_SESSION *new_sess; ++ /* ++ * We reused an existing session, so we need to replace it with a new ++ * one ++ */ ++ if (i & SSL_SESS_CACHE_CLIENT) { ++ /* ++ * Remove the old session from the cache ++ */ ++ if (i & SSL_SESS_CACHE_NO_INTERNAL_STORE) { ++ if (s->session_ctx->remove_session_cb != NULL) ++ s->session_ctx->remove_session_cb(s->session_ctx, ++ s->session); ++ } else { ++ /* We carry on if this fails */ ++ SSL_CTX_remove_session(s->session_ctx, s->session); ++ } ++ } ++ ++ if ((new_sess = ssl_session_dup(s->session, 0)) == 0) { ++ al = SSL_AD_INTERNAL_ERROR; ++ SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); ++ goto f_err; ++ } ++ ++ SSL_SESSION_free(s->session); ++ s->session = new_sess; ++ } ++ + n2l(p, s->session->tlsext_tick_lifetime_hint); + n2s(p, ticklen); + /* ticket_lifetime_hint + ticket_length + ticket */",1220,1456,2048 +13166,"void RenderFrameImpl::willSendRequest( + blink::WebLocalFrame* frame, + unsigned identifier, + blink::WebURLRequest& request, + const blink::WebURLResponse& redirect_response) { + DCHECK(!frame_ || frame_ == frame); + if (request.url().isEmpty()) + return; + + if (request.firstPartyForCookies().isEmpty()) { + if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { + request.setFirstPartyForCookies(request.url()); + } else { + WebFrame* top = frame->top(); + if (top->isWebLocalFrame()) { + request.setFirstPartyForCookies( + frame->top()->document().firstPartyForCookies()); + } + } + } + + WebDataSource* provisional_data_source = frame->provisionalDataSource(); + WebDataSource* data_source = + provisional_data_source ? provisional_data_source : frame->dataSource(); + + DocumentState* document_state = DocumentState::FromDataSource(data_source); + DCHECK(document_state); + InternalDocumentStateData* internal_data = + InternalDocumentStateData::FromDocumentState(document_state); + NavigationStateImpl* navigation_state = + static_cast(document_state->navigation_state()); + ui::PageTransition transition_type = navigation_state->GetTransitionType(); + if (provisional_data_source && provisional_data_source->isClientRedirect()) { + transition_type = ui::PageTransitionFromInt( + transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); + } + + GURL request_url(request.url()); + GURL new_url; + if (GetContentClient()->renderer()->WillSendRequest( + frame, + transition_type, + request_url, + request.firstPartyForCookies(), + &new_url)) { + request.setURL(WebURL(new_url)); + } + + if (internal_data->is_cache_policy_override_set()) + request.setCachePolicy(internal_data->cache_policy_override()); + + WebString custom_user_agent; + WebString requested_with; + scoped_ptr stream_override; + if (request.extraData()) { + RequestExtraData* old_extra_data = + static_cast(request.extraData()); + + custom_user_agent = old_extra_data->custom_user_agent(); + if (!custom_user_agent.isNull()) { + if (custom_user_agent.isEmpty()) + request.clearHTTPHeaderField(""User-Agent""); + else + request.setHTTPHeaderField(""User-Agent"", custom_user_agent); + } + + requested_with = old_extra_data->requested_with(); + if (!requested_with.isNull()) { + if (requested_with.isEmpty()) + request.clearHTTPHeaderField(""X-Requested-With""); + else + request.setHTTPHeaderField(""X-Requested-With"", requested_with); + } + stream_override = old_extra_data->TakeStreamOverrideOwnership(); + } + + if ((request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || + request.frameType() == blink::WebURLRequest::FrameTypeNested) && + request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) { + request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader), + WebString::fromUTF8(kDefaultAcceptHeader)); + } + + request.addHTTPOriginIfNeeded(WebString()); + + bool should_replace_current_entry = false; + if (navigation_state->IsContentInitiated()) { + should_replace_current_entry = data_source->replacesCurrentHistoryItem(); + } else { + should_replace_current_entry = + navigation_state->common_params().should_replace_current_entry; + } + + int provider_id = kInvalidServiceWorkerProviderId; + if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || + request.frameType() == blink::WebURLRequest::FrameTypeNested) { + if (frame->provisionalDataSource()) { + ServiceWorkerNetworkProvider* provider = + ServiceWorkerNetworkProvider::FromDocumentState( + DocumentState::FromDataSource(frame->provisionalDataSource())); + provider_id = provider->provider_id(); + } + } else if (frame->dataSource()) { + ServiceWorkerNetworkProvider* provider = + ServiceWorkerNetworkProvider::FromDocumentState( + DocumentState::FromDataSource(frame->dataSource())); + provider_id = provider->provider_id(); + } + + WebFrame* parent = frame->parent(); + int parent_routing_id = MSG_ROUTING_NONE; + if (!parent) { + parent_routing_id = -1; + } else if (parent->isWebLocalFrame()) { + parent_routing_id = FromWebFrame(parent)->GetRoutingID(); + } else { + parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id(); + } + + RequestExtraData* extra_data = new RequestExtraData(); + extra_data->set_visibility_state(render_view_->visibilityState()); + extra_data->set_custom_user_agent(custom_user_agent); + extra_data->set_requested_with(requested_with); + extra_data->set_render_frame_id(routing_id_); + extra_data->set_is_main_frame(!parent); + extra_data->set_frame_origin( + GURL(frame->document().securityOrigin().toString())); + extra_data->set_parent_is_main_frame(parent && !parent->parent()); + extra_data->set_parent_render_frame_id(parent_routing_id); + extra_data->set_allow_download( + navigation_state->common_params().allow_download); + extra_data->set_transition_type(transition_type); + extra_data->set_should_replace_current_entry(should_replace_current_entry); + extra_data->set_transferred_request_child_id( + navigation_state->start_params().transferred_request_child_id); + extra_data->set_transferred_request_request_id( + navigation_state->start_params().transferred_request_request_id); + extra_data->set_service_worker_provider_id(provider_id); + extra_data->set_stream_override(stream_override.Pass()); + request.setExtraData(extra_data); + + WebFrame* top_frame = frame->top(); + if (top_frame && top_frame->isWebLocalFrame()) { + DocumentState* top_document_state = + DocumentState::FromDataSource(top_frame->dataSource()); + if (top_document_state) { + if (request.requestContext() == WebURLRequest::RequestContextPrefetch) + top_document_state->set_was_prefetcher(true); + } + } + + request.setRequestorID(render_view_->GetRoutingID()); + request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); + + if (!navigation_state->start_params().extra_headers.empty()) { + for (net::HttpUtil::HeadersIterator i( + navigation_state->start_params().extra_headers.begin(), + navigation_state->start_params().extra_headers.end(), ""\n""); + i.GetNext();) { + if (base::LowerCaseEqualsASCII(i.name(), ""referer"")) { + WebString referrer = WebSecurityPolicy::generateReferrerHeader( + blink::WebReferrerPolicyDefault, + request.url(), + WebString::fromUTF8(i.values())); + request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); + } else { + request.setHTTPHeaderField(WebString::fromUTF8(i.name()), + WebString::fromUTF8(i.values())); + } + } + } + + if (!render_view_->renderer_preferences_.enable_referrers) + request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); +} +",0,"void RenderFrameImpl::willSendRequest( + blink::WebLocalFrame* frame, + unsigned identifier, + blink::WebURLRequest& request, + const blink::WebURLResponse& redirect_response) { + DCHECK(!frame_ || frame_ == frame); + if (request.url().isEmpty()) + return; + + if (request.firstPartyForCookies().isEmpty()) { + if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { + request.setFirstPartyForCookies(request.url()); + } else { + WebFrame* top = frame->top(); + if (top->isWebLocalFrame()) { + request.setFirstPartyForCookies( + frame->top()->document().firstPartyForCookies()); + } + } + } + + WebDataSource* provisional_data_source = frame->provisionalDataSource(); + WebDataSource* data_source = + provisional_data_source ? provisional_data_source : frame->dataSource(); + + DocumentState* document_state = DocumentState::FromDataSource(data_source); + DCHECK(document_state); + InternalDocumentStateData* internal_data = + InternalDocumentStateData::FromDocumentState(document_state); + NavigationStateImpl* navigation_state = + static_cast(document_state->navigation_state()); + ui::PageTransition transition_type = navigation_state->GetTransitionType(); + if (provisional_data_source && provisional_data_source->isClientRedirect()) { + transition_type = ui::PageTransitionFromInt( + transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); + } + + GURL request_url(request.url()); + GURL new_url; + if (GetContentClient()->renderer()->WillSendRequest( + frame, + transition_type, + request_url, + request.firstPartyForCookies(), + &new_url)) { + request.setURL(WebURL(new_url)); + } + + if (internal_data->is_cache_policy_override_set()) + request.setCachePolicy(internal_data->cache_policy_override()); + + WebString custom_user_agent; + WebString requested_with; + scoped_ptr stream_override; + if (request.extraData()) { + RequestExtraData* old_extra_data = + static_cast(request.extraData()); + + custom_user_agent = old_extra_data->custom_user_agent(); + if (!custom_user_agent.isNull()) { + if (custom_user_agent.isEmpty()) + request.clearHTTPHeaderField(""User-Agent""); + else + request.setHTTPHeaderField(""User-Agent"", custom_user_agent); + } + + requested_with = old_extra_data->requested_with(); + if (!requested_with.isNull()) { + if (requested_with.isEmpty()) + request.clearHTTPHeaderField(""X-Requested-With""); + else + request.setHTTPHeaderField(""X-Requested-With"", requested_with); + } + stream_override = old_extra_data->TakeStreamOverrideOwnership(); + } + + if ((request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || + request.frameType() == blink::WebURLRequest::FrameTypeNested) && + request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) { + request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader), + WebString::fromUTF8(kDefaultAcceptHeader)); + } + + request.addHTTPOriginIfNeeded(WebString()); + + bool should_replace_current_entry = false; + if (navigation_state->IsContentInitiated()) { + should_replace_current_entry = data_source->replacesCurrentHistoryItem(); + } else { + should_replace_current_entry = + navigation_state->common_params().should_replace_current_entry; + } + + int provider_id = kInvalidServiceWorkerProviderId; + if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || + request.frameType() == blink::WebURLRequest::FrameTypeNested) { + if (frame->provisionalDataSource()) { + ServiceWorkerNetworkProvider* provider = + ServiceWorkerNetworkProvider::FromDocumentState( + DocumentState::FromDataSource(frame->provisionalDataSource())); + provider_id = provider->provider_id(); + } + } else if (frame->dataSource()) { + ServiceWorkerNetworkProvider* provider = + ServiceWorkerNetworkProvider::FromDocumentState( + DocumentState::FromDataSource(frame->dataSource())); + provider_id = provider->provider_id(); + } + + WebFrame* parent = frame->parent(); + int parent_routing_id = MSG_ROUTING_NONE; + if (!parent) { + parent_routing_id = -1; + } else if (parent->isWebLocalFrame()) { + parent_routing_id = FromWebFrame(parent)->GetRoutingID(); + } else { + parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id(); + } + + RequestExtraData* extra_data = new RequestExtraData(); + extra_data->set_visibility_state(render_view_->visibilityState()); + extra_data->set_custom_user_agent(custom_user_agent); + extra_data->set_requested_with(requested_with); + extra_data->set_render_frame_id(routing_id_); + extra_data->set_is_main_frame(!parent); + extra_data->set_frame_origin( + GURL(frame->document().securityOrigin().toString())); + extra_data->set_parent_is_main_frame(parent && !parent->parent()); + extra_data->set_parent_render_frame_id(parent_routing_id); + extra_data->set_allow_download( + navigation_state->common_params().allow_download); + extra_data->set_transition_type(transition_type); + extra_data->set_should_replace_current_entry(should_replace_current_entry); + extra_data->set_transferred_request_child_id( + navigation_state->start_params().transferred_request_child_id); + extra_data->set_transferred_request_request_id( + navigation_state->start_params().transferred_request_request_id); + extra_data->set_service_worker_provider_id(provider_id); + extra_data->set_stream_override(stream_override.Pass()); + request.setExtraData(extra_data); + + WebFrame* top_frame = frame->top(); + if (top_frame && top_frame->isWebLocalFrame()) { + DocumentState* top_document_state = + DocumentState::FromDataSource(top_frame->dataSource()); + if (top_document_state) { + if (request.requestContext() == WebURLRequest::RequestContextPrefetch) + top_document_state->set_was_prefetcher(true); + } + } + + request.setRequestorID(render_view_->GetRoutingID()); + request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); + + if (!navigation_state->start_params().extra_headers.empty()) { + for (net::HttpUtil::HeadersIterator i( + navigation_state->start_params().extra_headers.begin(), + navigation_state->start_params().extra_headers.end(), ""\n""); + i.GetNext();) { + if (base::LowerCaseEqualsASCII(i.name(), ""referer"")) { + WebString referrer = WebSecurityPolicy::generateReferrerHeader( + blink::WebReferrerPolicyDefault, + request.url(), + WebString::fromUTF8(i.values())); + request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); + } else { + request.setHTTPHeaderField(WebString::fromUTF8(i.name()), + WebString::fromUTF8(i.values())); + } + } + } + + if (!render_view_->renderer_preferences_.enable_referrers) + request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); +} +","@@ -115,6 +115,7 @@ + #include ""media/blink/webmediaplayer_impl.h"" + #include ""media/blink/webmediaplayer_params.h"" + #include ""media/renderers/gpu_video_accelerator_factories.h"" ++#include ""mojo/common/url_type_converters.h"" + #include ""net/base/data_url.h"" + #include ""net/base/net_errors.h"" + #include ""net/base/registry_controlled_domains/registry_controlled_domain.h"" +@@ -125,6 +126,7 @@ + #include ""third_party/WebKit/public/platform/WebURLError.h"" + #include ""third_party/WebKit/public/platform/WebURLResponse.h"" + #include ""third_party/WebKit/public/platform/WebVector.h"" ++#include ""third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h"" + #include ""third_party/WebKit/public/web/WebColorSuggestion.h"" + #include ""third_party/WebKit/public/web/WebDocument.h"" + #include ""third_party/WebKit/public/web/WebFrameWidget.h"" +@@ -174,6 +176,8 @@ + #include ""content/renderer/media/android/webmediaplayer_android.h"" + #else + #include ""cc/blink/context_provider_web_context.h"" ++#include ""content/renderer/usb/web_usb_client_impl.h"" ++#include ""device/devices_app/public/cpp/constants.h"" + #endif + + #if defined(ENABLE_PEPPER_CDMS) +@@ -705,6 +709,8 @@ RenderFrameImpl::RenderFrameImpl(const CreateParams& params) + #endif + + manifest_manager_ = new ManifestManager(this); ++ ++ GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_)); + } + + RenderFrameImpl::~RenderFrameImpl() { +@@ -3812,6 +3818,17 @@ blink::WebBluetooth* RenderFrameImpl::bluetooth() { + return bluetooth_.get(); + } + ++blink::WebUSBClient* RenderFrameImpl::usbClient() { ++#if !defined(OS_ANDROID) ++ if (!usb_client_) { ++ mojo::ServiceProviderPtr device_services = ++ ConnectToApplication(GURL(device::kDevicesMojoAppUrl)); ++ usb_client_.reset(new WebUSBClientImpl(device_services.Pass())); ++ } ++#endif ++ return usb_client_.get(); ++} ++ + #if defined(ENABLE_WEBVR) + blink::WebVRClient* RenderFrameImpl::webVRClient() { + if (!vr_dispatcher_) +@@ -5003,17 +5020,9 @@ media::MediaPermission* RenderFrameImpl::GetMediaPermission() { + #if defined(ENABLE_MOJO_MEDIA) + media::interfaces::ServiceFactory* RenderFrameImpl::GetMediaServiceFactory() { + if (!media_service_factory_) { +- mojo::InterfacePtr shell_ptr; +- GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&shell_ptr)); +- +- mojo::ServiceProviderPtr service_provider; +- mojo::URLRequestPtr request(mojo::URLRequest::New()); +- request->url = mojo::String::From(""mojo:media""); +- shell_ptr->ConnectToApplication(request.Pass(), GetProxy(&service_provider), +- nullptr, nullptr); +- ++ mojo::ServiceProviderPtr service_provider = ++ ConnectToApplication(GURL(""mojo:media"")); + mojo::ConnectToService(service_provider.get(), &media_service_factory_); +- + media_service_factory_.set_connection_error_handler( + base::Bind(&RenderFrameImpl::OnMediaServiceFactoryConnectionError, + base::Unretained(this))); +@@ -5075,4 +5084,15 @@ void RenderFrameImpl::RegisterMojoServices() { + } + } + ++mojo::ServiceProviderPtr RenderFrameImpl::ConnectToApplication( ++ const GURL& url) { ++ DCHECK(mojo_shell_); ++ mojo::ServiceProviderPtr service_provider; ++ mojo::URLRequestPtr request(mojo::URLRequest::New()); ++ request->url = mojo::String::From(url); ++ mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), ++ nullptr, nullptr); ++ return service_provider.Pass(); ++} ++ + } // namespace content",1510,1746,2048 +17282,"int main(int argc, const char **argv) +{ + /* This program uses the default, based, libpng error handling + * mechanism, therefore any local variable that exists before the call to + * setjmp and is changed after the call to setjmp returns successfully must + * be declared with 'volatile' to ensure that their values don't get + * destroyed by longjmp: + */ + volatile int result = 1/*fail*/; + + if (argc == 4) + { + long x = atol(argv[1]); + long y = atol(argv[2]); + FILE *f = fopen(argv[3], ""rb""); + volatile png_bytep row = NULL; + + if (f != NULL) + { + /* libpng requires a callback function for handling errors; this + * callback must not return. The default callback function uses a + * stored style jmp_buf which is held in a png_struct and + * writes error messages to stderr. Creating the png_struct is a + * little tricky; just copy the following code. + */ + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL); + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + /* Declare stack variables to hold pointers to locally allocated + * data. + */ + + /* Initialize the error control buffer: */ + if (setjmp(png_jmpbuf(png_ptr)) == 0) + { + png_uint_32 width, height; + int bit_depth, color_type, interlace_method, + compression_method, filter_method; + png_bytep row_tmp; + + /* Now associate the recently opened (FILE*) with the default + * libpng initialization functions. Sometimes libpng is + * compiled without stdio support (it can be difficult to do + * in some environments); in that case you will have to write + * your own read callback to read data from the (FILE*). + */ + png_init_io(png_ptr, f); + + /* And read the first part of the PNG file - the header and + * all the information up to the first pixel. + */ + png_read_info(png_ptr, info_ptr); + + /* This fills in enough information to tell us the width of + * each row in bytes, allocate the appropriate amount of + * space. In this case png_malloc is used - it will not + * return if memory isn't available. + */ + row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, + info_ptr)); + + /* To avoid the overhead of using a volatile auto copy row_tmp + * to a local here - just use row for the png_free below. + */ + row_tmp = row; + + /* All the information we need is in the header is returned by + * png_get_IHDR, if this fails we can now use 'png_error' to + * signal the error and return control to the setjmp above. + */ + if (png_get_IHDR(png_ptr, info_ptr, &width, &height, + &bit_depth, &color_type, &interlace_method, + &compression_method, &filter_method)) + { + int passes, pass; + + /* png_set_interlace_handling returns the number of + * passes required as well as turning on libpng's + * handling, but since we do it ourselves this is + * necessary: + */ + switch (interlace_method) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, ""pngpixel: unknown interlace""); + } + + /* Now read the pixels, pass-by-pass, row-by-row: */ + png_start_read_image(png_ptr); + + for (pass=0; pass based, libpng error handling + * mechanism, therefore any local variable that exists before the call to + * setjmp and is changed after the call to setjmp returns successfully must + * be declared with 'volatile' to ensure that their values don't get + * destroyed by longjmp: + */ + volatile int result = 1/*fail*/; + + if (argc == 4) + { + long x = atol(argv[1]); + long y = atol(argv[2]); + FILE *f = fopen(argv[3], ""rb""); + volatile png_bytep row = NULL; + + if (f != NULL) + { + /* libpng requires a callback function for handling errors; this + * callback must not return. The default callback function uses a + * stored style jmp_buf which is held in a png_struct and + * writes error messages to stderr. Creating the png_struct is a + * little tricky; just copy the following code. + */ + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL); + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + /* Declare stack variables to hold pointers to locally allocated + * data. + */ + + /* Initialize the error control buffer: */ + if (setjmp(png_jmpbuf(png_ptr)) == 0) + { + png_uint_32 width, height; + int bit_depth, color_type, interlace_method, + compression_method, filter_method; + png_bytep row_tmp; + + /* Now associate the recently opened (FILE*) with the default + * libpng initialization functions. Sometimes libpng is + * compiled without stdio support (it can be difficult to do + * in some environments); in that case you will have to write + * your own read callback to read data from the (FILE*). + */ + png_init_io(png_ptr, f); + + /* And read the first part of the PNG file - the header and + * all the information up to the first pixel. + */ + png_read_info(png_ptr, info_ptr); + + /* This fills in enough information to tell us the width of + * each row in bytes, allocate the appropriate amount of + * space. In this case png_malloc is used - it will not + * return if memory isn't available. + */ + row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, + info_ptr)); + + /* To avoid the overhead of using a volatile auto copy row_tmp + * to a local here - just use row for the png_free below. + */ + row_tmp = row; + + /* All the information we need is in the header is returned by + * png_get_IHDR, if this fails we can now use 'png_error' to + * signal the error and return control to the setjmp above. + */ + if (png_get_IHDR(png_ptr, info_ptr, &width, &height, + &bit_depth, &color_type, &interlace_method, + &compression_method, &filter_method)) + { + int passes, pass; + + /* png_set_interlace_handling returns the number of + * passes required as well as turning on libpng's + * handling, but since we do it ourselves this is + * necessary: + */ + switch (interlace_method) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, ""pngpixel: unknown interlace""); + } + + /* Now read the pixels, pass-by-pass, row-by-row: */ + png_start_read_image(png_ptr); + + for (pass=0; passcurpol->type == QI_VAL) + { + QueryOperand *curpol = &in->curpol->qoperand; + char *op = in->op + curpol->distance; + int clen; + + RESIZEBUF(in, curpol->length * (pg_database_encoding_max_length() + 1) + 2 + 6); + *(in->cur) = '\''; + in->cur++; + while (*op) + { + if (t_iseq(op, '\'')) + { + *(in->cur) = '\''; + in->cur++; + } + else if (t_iseq(op, '\\')) + { + *(in->cur) = '\\'; + in->cur++; + } + COPYCHAR(in->cur, op); + + clen = pg_mblen(op); + op += clen; + in->cur += clen; + } + *(in->cur) = '\''; + in->cur++; + if (curpol->weight || curpol->prefix) + { + *(in->cur) = ':'; + in->cur++; + if (curpol->prefix) + { + *(in->cur) = '*'; + in->cur++; + } + if (curpol->weight & (1 << 3)) + { + *(in->cur) = 'A'; + in->cur++; + } + if (curpol->weight & (1 << 2)) + { + *(in->cur) = 'B'; + in->cur++; + } + if (curpol->weight & (1 << 1)) + { + *(in->cur) = 'C'; + in->cur++; + } + if (curpol->weight & 1) + { + *(in->cur) = 'D'; + in->cur++; + } + } + *(in->cur) = '\0'; + in->curpol++; + } + else if (in->curpol->qoperator.oper == OP_NOT) + { + bool isopr = false; + + RESIZEBUF(in, 1); + *(in->cur) = '!'; + in->cur++; + *(in->cur) = '\0'; + in->curpol++; + + if (in->curpol->type == QI_OPR) + { + isopr = true; + RESIZEBUF(in, 2); + sprintf(in->cur, ""( ""); + in->cur = strchr(in->cur, '\0'); + } + + infix(in, isopr); + if (isopr) + { + RESIZEBUF(in, 2); + sprintf(in->cur, "" )""); + in->cur = strchr(in->cur, '\0'); + } + } + else + { + int8 op = in->curpol->qoperator.oper; + INFIX nrm; + + in->curpol++; + if (op == OP_OR && !first) + { + RESIZEBUF(in, 2); + sprintf(in->cur, ""( ""); + in->cur = strchr(in->cur, '\0'); + } + + nrm.curpol = in->curpol; + nrm.op = in->op; + nrm.buflen = 16; + nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen); + + /* get right operand */ + infix(&nrm, false); + + /* get & print left operand */ + in->curpol = nrm.curpol; + infix(in, false); + + /* print operator & right operand */ + RESIZEBUF(in, 3 + (nrm.cur - nrm.buf)); + switch (op) + { + case OP_OR: + sprintf(in->cur, "" | %s"", nrm.buf); + break; + case OP_AND: + sprintf(in->cur, "" & %s"", nrm.buf); + break; + default: + /* OP_NOT is handled in above if-branch */ + elog(ERROR, ""unrecognized operator type: %d"", op); + } + in->cur = strchr(in->cur, '\0'); + pfree(nrm.buf); + + if (op == OP_OR && !first) + { + RESIZEBUF(in, 2); + sprintf(in->cur, "" )""); + in->cur = strchr(in->cur, '\0'); + } + } +} +",0,"infix(INFIX *in, bool first) +{ + /* since this function recurses, it could be driven to stack overflow. */ + check_stack_depth(); + + if (in->curpol->type == QI_VAL) + { + QueryOperand *curpol = &in->curpol->qoperand; + char *op = in->op + curpol->distance; + int clen; + + RESIZEBUF(in, curpol->length * (pg_database_encoding_max_length() + 1) + 2 + 6); + *(in->cur) = '\''; + in->cur++; + while (*op) + { + if (t_iseq(op, '\'')) + { + *(in->cur) = '\''; + in->cur++; + } + else if (t_iseq(op, '\\')) + { + *(in->cur) = '\\'; + in->cur++; + } + COPYCHAR(in->cur, op); + + clen = pg_mblen(op); + op += clen; + in->cur += clen; + } + *(in->cur) = '\''; + in->cur++; + if (curpol->weight || curpol->prefix) + { + *(in->cur) = ':'; + in->cur++; + if (curpol->prefix) + { + *(in->cur) = '*'; + in->cur++; + } + if (curpol->weight & (1 << 3)) + { + *(in->cur) = 'A'; + in->cur++; + } + if (curpol->weight & (1 << 2)) + { + *(in->cur) = 'B'; + in->cur++; + } + if (curpol->weight & (1 << 1)) + { + *(in->cur) = 'C'; + in->cur++; + } + if (curpol->weight & 1) + { + *(in->cur) = 'D'; + in->cur++; + } + } + *(in->cur) = '\0'; + in->curpol++; + } + else if (in->curpol->qoperator.oper == OP_NOT) + { + bool isopr = false; + + RESIZEBUF(in, 1); + *(in->cur) = '!'; + in->cur++; + *(in->cur) = '\0'; + in->curpol++; + + if (in->curpol->type == QI_OPR) + { + isopr = true; + RESIZEBUF(in, 2); + sprintf(in->cur, ""( ""); + in->cur = strchr(in->cur, '\0'); + } + + infix(in, isopr); + if (isopr) + { + RESIZEBUF(in, 2); + sprintf(in->cur, "" )""); + in->cur = strchr(in->cur, '\0'); + } + } + else + { + int8 op = in->curpol->qoperator.oper; + INFIX nrm; + + in->curpol++; + if (op == OP_OR && !first) + { + RESIZEBUF(in, 2); + sprintf(in->cur, ""( ""); + in->cur = strchr(in->cur, '\0'); + } + + nrm.curpol = in->curpol; + nrm.op = in->op; + nrm.buflen = 16; + nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen); + + /* get right operand */ + infix(&nrm, false); + + /* get & print left operand */ + in->curpol = nrm.curpol; + infix(in, false); + + /* print operator & right operand */ + RESIZEBUF(in, 3 + (nrm.cur - nrm.buf)); + switch (op) + { + case OP_OR: + sprintf(in->cur, "" | %s"", nrm.buf); + break; + case OP_AND: + sprintf(in->cur, "" & %s"", nrm.buf); + break; + default: + /* OP_NOT is handled in above if-branch */ + elog(ERROR, ""unrecognized operator type: %d"", op); + } + in->cur = strchr(in->cur, '\0'); + pfree(nrm.buf); + + if (op == OP_OR && !first) + { + RESIZEBUF(in, 2); + sprintf(in->cur, "" )""); + in->cur = strchr(in->cur, '\0'); + } + } +} +","@@ -514,8 +514,13 @@ parse_tsquery(char *buf, + return query; + } + +- /* Pack the QueryItems in the final TSQuery struct to return to caller */ ++ if (TSQUERY_TOO_BIG(list_length(state.polstr), state.sumlen)) ++ ereport(ERROR, ++ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), ++ errmsg(""tsquery is too large""))); + commonlen = COMPUTESIZE(list_length(state.polstr), state.sumlen); ++ ++ /* Pack the QueryItems in the final TSQuery struct to return to caller */ + query = (TSQuery) palloc0(commonlen); + SET_VARSIZE(query, commonlen); + query->size = list_length(state.polstr);",1022,1258,2048 +18614,"bool IDNSpoofChecker::SafeToDisplayAsUnicode(base::StringPiece16 label, + bool is_tld_ascii) { + UErrorCode status = U_ZERO_ERROR; + int32_t result = + uspoof_check(checker_, label.data(), + base::checked_cast(label.size()), NULL, &status); + if (U_FAILURE(status) || (result & USPOOF_ALL_CHECKS)) + return false; + + icu::UnicodeString label_string(FALSE, label.data(), + base::checked_cast(label.size())); + + if (deviation_characters_.containsSome(label_string)) + return false; + + result &= USPOOF_RESTRICTION_LEVEL_MASK; + if (result == USPOOF_ASCII) + return true; + if (result == USPOOF_SINGLE_SCRIPT_RESTRICTIVE && + kana_letters_exceptions_.containsNone(label_string) && + combining_diacritics_exceptions_.containsNone(label_string)) { + return !is_tld_ascii || !IsMadeOfLatinAlikeCyrillic(label_string); + } + + if (non_ascii_latin_letters_.containsSome(label_string) && + !lgc_letters_n_ascii_.containsAll(label_string)) + return false; + + if (!tls_index.initialized()) + tls_index.Initialize(&OnThreadTermination); + icu::RegexMatcher* dangerous_pattern = + reinterpret_cast(tls_index.Get()); + if (!dangerous_pattern) { + dangerous_pattern = new icu::RegexMatcher( + icu::UnicodeString( + R""([^\p{scx=kana}\p{scx=hira}\p{scx=hani}])"" + R""([\u30ce\u30f3\u30bd\u30be])"" + R""([^\p{scx=kana}\p{scx=hira}\p{scx=hani}]|)"" + R""([^\p{scx=kana}\p{scx=hira}]\u30fc|^\u30fc|)"" + R""([^\p{scx=kana}][\u30fd\u30fe]|^[\u30fd\u30fe]|)"" + R""(^[\p{scx=kana}]+[\u3078-\u307a][\p{scx=kana}]+$|)"" + R""(^[\p{scx=hira}]+[\u30d8-\u30da][\p{scx=hira}]+$|)"" + R""([a-z]\u30fb|\u30fb[a-z]|)"" + R""(^[\u0585\u0581]+[a-z]|[a-z][\u0585\u0581]+$|)"" + R""([a-z][\u0585\u0581]+[a-z]|)"" + R""(^[og]+[\p{scx=armn}]|[\p{scx=armn}][og]+$|)"" + R""([\p{scx=armn}][og]+[\p{scx=armn}]|)"" + R""([\p{sc=cans}].*[a-z]|[a-z].*[\p{sc=cans}]|)"" + R""([^\p{scx=latn}\p{scx=grek}\p{scx=cyrl}][\u0300-\u0339])"", + -1, US_INV), + 0, status); + tls_index.Set(dangerous_pattern); + } + dangerous_pattern->reset(label_string); + return !dangerous_pattern->find(); +} +",1,"bool IDNSpoofChecker::SafeToDisplayAsUnicode(base::StringPiece16 label, + bool is_tld_ascii) { + UErrorCode status = U_ZERO_ERROR; + int32_t result = + uspoof_check(checker_, label.data(), + base::checked_cast(label.size()), NULL, &status); + if (U_FAILURE(status) || (result & USPOOF_ALL_CHECKS)) + return false; + + icu::UnicodeString label_string(FALSE, label.data(), + base::checked_cast(label.size())); + + if (deviation_characters_.containsSome(label_string)) + return false; + + result &= USPOOF_RESTRICTION_LEVEL_MASK; + if (result == USPOOF_ASCII) + return true; + if (result == USPOOF_SINGLE_SCRIPT_RESTRICTIVE && + kana_letters_exceptions_.containsNone(label_string) && + combining_diacritics_exceptions_.containsNone(label_string)) { + return !is_tld_ascii || !IsMadeOfLatinAlikeCyrillic(label_string); + } + + if (non_ascii_latin_letters_.containsSome(label_string) && + !lgc_letters_n_ascii_.containsAll(label_string)) + return false; + + if (!tls_index.initialized()) + tls_index.Initialize(&OnThreadTermination); + icu::RegexMatcher* dangerous_pattern = + reinterpret_cast(tls_index.Get()); + if (!dangerous_pattern) { + // - Disalow mixing of Latin and Tifinagh. + dangerous_pattern = new icu::RegexMatcher( + icu::UnicodeString( + R""([^\p{scx=kana}\p{scx=hira}\p{scx=hani}])"" + R""([\u30ce\u30f3\u30bd\u30be])"" + R""([^\p{scx=kana}\p{scx=hira}\p{scx=hani}]|)"" + R""([^\p{scx=kana}\p{scx=hira}]\u30fc|^\u30fc|)"" + R""([^\p{scx=kana}][\u30fd\u30fe]|^[\u30fd\u30fe]|)"" + R""(^[\p{scx=kana}]+[\u3078-\u307a][\p{scx=kana}]+$|)"" + R""(^[\p{scx=hira}]+[\u30d8-\u30da][\p{scx=hira}]+$|)"" + R""([a-z]\u30fb|\u30fb[a-z]|)"" + R""(^[\u0585\u0581]+[a-z]|[a-z][\u0585\u0581]+$|)"" + R""([a-z][\u0585\u0581]+[a-z]|)"" + R""(^[og]+[\p{scx=armn}]|[\p{scx=armn}][og]+$|)"" + R""([\p{scx=armn}][og]+[\p{scx=armn}]|)"" + R""([\p{sc=cans}].*[a-z]|[a-z].*[\p{sc=cans}]|)"" + R""([\p{sc=tfng}].*[a-z]|[a-z].*[\p{sc=tfng}]|)"" + R""([^\p{scx=latn}\p{scx=grek}\p{scx=cyrl}][\u0300-\u0339])"", + -1, US_INV), + 0, status); + tls_index.Set(dangerous_pattern); + } + dangerous_pattern->reset(label_string); + return !dangerous_pattern->find(); +} +","@@ -236,6 +236,7 @@ bool IDNSpoofChecker::SafeToDisplayAsUnicode(base::StringPiece16 label, + // Letter Co) to be next to Latin. + // - Disallow Latin 'o' and 'g' next to Armenian. + // - Disalow mixing of Latin and Canadian Syllabary. ++ // - Disalow mixing of Latin and Tifinagh. + // - Disallow combining diacritical mark (U+0300-U+0339) after a non-LGC + // character. Other combining diacritical marks are not in the allowed + // character set. +@@ -254,6 +255,7 @@ bool IDNSpoofChecker::SafeToDisplayAsUnicode(base::StringPiece16 label, + R""(^[og]+[\p{scx=armn}]|[\p{scx=armn}][og]+$|)"" + R""([\p{scx=armn}][og]+[\p{scx=armn}]|)"" + R""([\p{sc=cans}].*[a-z]|[a-z].*[\p{sc=cans}]|)"" ++ R""([\p{sc=tfng}].*[a-z]|[a-z].*[\p{sc=tfng}]|)"" + R""([^\p{scx=latn}\p{scx=grek}\p{scx=cyrl}][\u0300-\u0339])"", + -1, US_INV), + 0, status);",797,1033,2048 +7887,"static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track) +{ + int tag = track->par->codec_tag; + int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE; + AVStream *st = track->st; + int rate = defined_frame_rate(s, st); + + if (!tag) + tag = MKTAG('a', 'v', 'c', 'i'); //fallback tag + + if (track->par->format == AV_PIX_FMT_YUV420P10) { + if (track->par->width == 960 && track->par->height == 720) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','5','p'); + else if (rate == 25) tag = MKTAG('a','i','5','q'); + else if (rate == 30) tag = MKTAG('a','i','5','p'); + else if (rate == 50) tag = MKTAG('a','i','5','q'); + else if (rate == 60) tag = MKTAG('a','i','5','p'); + } + } else if (track->par->width == 1440 && track->par->height == 1080) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','5','3'); + else if (rate == 25) tag = MKTAG('a','i','5','2'); + else if (rate == 30) tag = MKTAG('a','i','5','3'); + } else { + if (rate == 50) tag = MKTAG('a','i','5','5'); + else if (rate == 60) tag = MKTAG('a','i','5','6'); + } + } + } else if (track->par->format == AV_PIX_FMT_YUV422P10) { + if (track->par->width == 1280 && track->par->height == 720) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','1','p'); + else if (rate == 25) tag = MKTAG('a','i','1','q'); + else if (rate == 30) tag = MKTAG('a','i','1','p'); + else if (rate == 50) tag = MKTAG('a','i','1','q'); + else if (rate == 60) tag = MKTAG('a','i','1','p'); + } + } else if (track->par->width == 1920 && track->par->height == 1080) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','1','3'); + else if (rate == 25) tag = MKTAG('a','i','1','2'); + else if (rate == 30) tag = MKTAG('a','i','1','3'); + } else { + if (rate == 25) tag = MKTAG('a','i','1','5'); + else if (rate == 50) tag = MKTAG('a','i','1','5'); + else if (rate == 60) tag = MKTAG('a','i','1','6'); + } + } else if ( track->par->width == 4096 && track->par->height == 2160 + || track->par->width == 3840 && track->par->height == 2160 + || track->par->width == 2048 && track->par->height == 1080) { + tag = MKTAG('a','i','v','x'); + } + } + + return tag; +} +",0,"static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track) +{ + int tag = track->par->codec_tag; + int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE; + AVStream *st = track->st; + int rate = defined_frame_rate(s, st); + + if (!tag) + tag = MKTAG('a', 'v', 'c', 'i'); //fallback tag + + if (track->par->format == AV_PIX_FMT_YUV420P10) { + if (track->par->width == 960 && track->par->height == 720) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','5','p'); + else if (rate == 25) tag = MKTAG('a','i','5','q'); + else if (rate == 30) tag = MKTAG('a','i','5','p'); + else if (rate == 50) tag = MKTAG('a','i','5','q'); + else if (rate == 60) tag = MKTAG('a','i','5','p'); + } + } else if (track->par->width == 1440 && track->par->height == 1080) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','5','3'); + else if (rate == 25) tag = MKTAG('a','i','5','2'); + else if (rate == 30) tag = MKTAG('a','i','5','3'); + } else { + if (rate == 50) tag = MKTAG('a','i','5','5'); + else if (rate == 60) tag = MKTAG('a','i','5','6'); + } + } + } else if (track->par->format == AV_PIX_FMT_YUV422P10) { + if (track->par->width == 1280 && track->par->height == 720) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','1','p'); + else if (rate == 25) tag = MKTAG('a','i','1','q'); + else if (rate == 30) tag = MKTAG('a','i','1','p'); + else if (rate == 50) tag = MKTAG('a','i','1','q'); + else if (rate == 60) tag = MKTAG('a','i','1','p'); + } + } else if (track->par->width == 1920 && track->par->height == 1080) { + if (!interlaced) { + if (rate == 24) tag = MKTAG('a','i','1','3'); + else if (rate == 25) tag = MKTAG('a','i','1','2'); + else if (rate == 30) tag = MKTAG('a','i','1','3'); + } else { + if (rate == 25) tag = MKTAG('a','i','1','5'); + else if (rate == 50) tag = MKTAG('a','i','1','5'); + else if (rate == 60) tag = MKTAG('a','i','1','6'); + } + } else if ( track->par->width == 4096 && track->par->height == 2160 + || track->par->width == 3840 && track->par->height == 2160 + || track->par->width == 2048 && track->par->height == 1080) { + tag = MKTAG('a','i','v','x'); + } + } + + return tag; +} +","@@ -1022,7 +1022,7 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex + uint32_t tag = track->tag; + + if (track->mode == MODE_MOV) { +- if (track->timescale > UINT16_MAX) { ++ if (track->timescale > UINT16_MAX || !track->par->channels) { + if (mov_get_lpcm_flags(track->par->codec_id)) + tag = AV_RL32(""lpcm""); + version = 2;",895,1131,2048 +8882,"WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) +{ + const char /* extracted option args from args */ + *arg1, + *arg2; + + CommandOptionFlags + option_type; + + assert(cli_wand != (MagickCLI *) NULL); + assert(cli_wand->signature == MagickWandSignature); + assert(cli_wand->wand.signature == MagickWandSignature); + + do { /* Break Code Block for error handling */ + + /* get information about option */ + if ( cli_wand->command == (const OptionInfo *) NULL ) + cli_wand->command = GetCommandOptionInfo(option); +#if 0 + (void) FormatLocaleFile(stderr, ""CLIOption \""%s\"" matched \""%s\""\n"", + option, cli_wand->command->mnemonic ); +#endif + option_type=(CommandOptionFlags) cli_wand->command->flags; + + if ( option_type == UndefinedOptionFlag ) + CLIWandExceptionReturn(OptionFatalError,""UnrecognizedOption"",option); + + assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); + + /* deprecated options */ + if ( (option_type & DeprecateOptionFlag) != 0 ) + CLIWandExceptionBreak(OptionError,""DeprecatedOptionNoCode"",option); + + /* options that this module does not handle */ + if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) + CLIWandExceptionBreak(OptionFatalError,""InvalidUseOfOption"",option); + + /* Get argument strings from VarArgs + How can you determine if enough arguments was supplied? + What happens if not enough arguments were supplied? + */ + { size_t + count = (size_t) cli_wand->command->type; + + va_list + operands; + + va_start(operands,option); + + arg1=arg2=NULL; + if ( count >= 1 ) + arg1=(const char *) va_arg(operands, const char *); + if ( count >= 2 ) + arg2=(const char *) va_arg(operands, const char *); + + va_end(operands); +#if 0 + (void) FormatLocaleFile(stderr, + ""CLIOption: \""%s\"" Count: %ld Flags: %04x Args: \""%s\"" \""%s\""\n"", + option,(long) count,option_type,arg1,arg2); +#endif + } + + /* + Call the appropriate option handler + */ + + /* FUTURE: this is temporary - get 'settings' to handle distribution of + settings to images attributes,proprieties,artifacts */ + if ( cli_wand->wand.images != (Image *) NULL ) + (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, + cli_wand->wand.exception); + + if ( (option_type & SettingOptionFlags) != 0 ) { + CLISettingOptionInfo(cli_wand, option, arg1, arg2); + /* + FUTURE: Sync Specific Settings into Image Properities (not global) + */ + } + + /* Operators that do not need images - read, write, stack, clone */ + if ((option_type & NoImageOperatorFlag) != 0) + CLINoImageOperator(cli_wand, option, arg1, arg2); + + /* FUTURE: The not a setting part below is a temporary hack due to + * some options being both a Setting and a Simple operator. + * Specifically -monitor, -depth, and -colorspace */ + if ( cli_wand->wand.images == (Image *) NULL ) + if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && + ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ + CLIWandExceptionBreak(OptionError,""NoImagesFound"",option); + + /* Operators which loop of individual images, simply */ + if ( (option_type & SimpleOperatorFlag) != 0 && + cli_wand->wand.images != (Image *) NULL) /* temp hack */ + { + ExceptionInfo *exception=AcquireExceptionInfo(); + (void) CLISimpleOperatorImages(cli_wand, option, arg1, arg2,exception); + exception=DestroyExceptionInfo(exception); + } + + /* Operators that work on the image list as a whole */ + if ( (option_type & ListOperatorFlag) != 0 ) + (void) CLIListOperatorImages(cli_wand, option, arg1, arg2); + +DisableMSCWarning(4127) + } while (0); /* end Break code block */ +RestoreMSCWarning + + cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ +} +",0,"WandExport void CLIOption(MagickCLI *cli_wand,const char *option,...) +{ + const char /* extracted option args from args */ + *arg1, + *arg2; + + CommandOptionFlags + option_type; + + assert(cli_wand != (MagickCLI *) NULL); + assert(cli_wand->signature == MagickWandSignature); + assert(cli_wand->wand.signature == MagickWandSignature); + + do { /* Break Code Block for error handling */ + + /* get information about option */ + if ( cli_wand->command == (const OptionInfo *) NULL ) + cli_wand->command = GetCommandOptionInfo(option); +#if 0 + (void) FormatLocaleFile(stderr, ""CLIOption \""%s\"" matched \""%s\""\n"", + option, cli_wand->command->mnemonic ); +#endif + option_type=(CommandOptionFlags) cli_wand->command->flags; + + if ( option_type == UndefinedOptionFlag ) + CLIWandExceptionReturn(OptionFatalError,""UnrecognizedOption"",option); + + assert( LocaleCompare(cli_wand->command->mnemonic,option) == 0 ); + + /* deprecated options */ + if ( (option_type & DeprecateOptionFlag) != 0 ) + CLIWandExceptionBreak(OptionError,""DeprecatedOptionNoCode"",option); + + /* options that this module does not handle */ + if ((option_type & (SpecialOptionFlag|GenesisOptionFlag)) != 0 ) + CLIWandExceptionBreak(OptionFatalError,""InvalidUseOfOption"",option); + + /* Get argument strings from VarArgs + How can you determine if enough arguments was supplied? + What happens if not enough arguments were supplied? + */ + { size_t + count = (size_t) cli_wand->command->type; + + va_list + operands; + + va_start(operands,option); + + arg1=arg2=NULL; + if ( count >= 1 ) + arg1=(const char *) va_arg(operands, const char *); + if ( count >= 2 ) + arg2=(const char *) va_arg(operands, const char *); + + va_end(operands); +#if 0 + (void) FormatLocaleFile(stderr, + ""CLIOption: \""%s\"" Count: %ld Flags: %04x Args: \""%s\"" \""%s\""\n"", + option,(long) count,option_type,arg1,arg2); +#endif + } + + /* + Call the appropriate option handler + */ + + /* FUTURE: this is temporary - get 'settings' to handle distribution of + settings to images attributes,proprieties,artifacts */ + if ( cli_wand->wand.images != (Image *) NULL ) + (void) SyncImagesSettings(cli_wand->wand.image_info,cli_wand->wand.images, + cli_wand->wand.exception); + + if ( (option_type & SettingOptionFlags) != 0 ) { + CLISettingOptionInfo(cli_wand, option, arg1, arg2); + /* + FUTURE: Sync Specific Settings into Image Properities (not global) + */ + } + + /* Operators that do not need images - read, write, stack, clone */ + if ((option_type & NoImageOperatorFlag) != 0) + CLINoImageOperator(cli_wand, option, arg1, arg2); + + /* FUTURE: The not a setting part below is a temporary hack due to + * some options being both a Setting and a Simple operator. + * Specifically -monitor, -depth, and -colorspace */ + if ( cli_wand->wand.images == (Image *) NULL ) + if ( ((option_type & (SimpleOperatorFlag|ListOperatorFlag)) != 0 ) && + ((option_type & SettingOptionFlags) == 0 )) /* temp hack */ + CLIWandExceptionBreak(OptionError,""NoImagesFound"",option); + + /* Operators which loop of individual images, simply */ + if ( (option_type & SimpleOperatorFlag) != 0 && + cli_wand->wand.images != (Image *) NULL) /* temp hack */ + { + ExceptionInfo *exception=AcquireExceptionInfo(); + (void) CLISimpleOperatorImages(cli_wand, option, arg1, arg2,exception); + exception=DestroyExceptionInfo(exception); + } + + /* Operators that work on the image list as a whole */ + if ( (option_type & ListOperatorFlag) != 0 ) + (void) CLIListOperatorImages(cli_wand, option, arg1, arg2); + +DisableMSCWarning(4127) + } while (0); /* end Break code block */ +RestoreMSCWarning + + cli_wand->command = (const OptionInfo *) NULL; /* prevent re-use later */ +} +","@@ -3868,7 +3868,10 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + reconstruct_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (reconstruct_image == (Image *) NULL) +- break; ++ { ++ image=DestroyImage(image); ++ break; ++ } + metric=UndefinedErrorMetric; + option=GetImageOption(_image_info,""metric""); + if (option != (const char *) NULL)",1009,1245,2048 +8886,"static ThresholdMap *GetThresholdMapFile(const char *xml,const char *filename, + const char *map_id,ExceptionInfo *exception) +{ + char + *p; + + const char + *attribute, + *content; + + double + value; + + register ssize_t + i; + + ThresholdMap + *map; + + XMLTreeInfo + *description, + *levels, + *threshold, + *thresholds; + + (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), + ""Loading threshold map file \""%s\"" ..."",filename); + map=(ThresholdMap *) NULL; + thresholds=NewXMLTree(xml,exception); + if (thresholds == (XMLTreeInfo *) NULL) + return(map); + for (threshold=GetXMLTreeChild(thresholds,""threshold""); + threshold != (XMLTreeInfo *) NULL; + threshold=GetNextXMLTreeTag(threshold)) + { + attribute=GetXMLTreeAttribute(threshold,""map""); + if ((attribute != (char *) NULL) && (LocaleCompare(map_id,attribute) == 0)) + break; + attribute=GetXMLTreeAttribute(threshold,""alias""); + if ((attribute != (char *) NULL) && (LocaleCompare(map_id,attribute) == 0)) + break; + } + if (threshold == (XMLTreeInfo *) NULL) + { + thresholds=DestroyXMLTree(thresholds); + return(map); + } + description=GetXMLTreeChild(threshold,""description""); + if (description == (XMLTreeInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingElement"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + return(map); + } + levels=GetXMLTreeChild(threshold,""levels""); + if (levels == (XMLTreeInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingElement"", "", map \""%s\"""", map_id); + thresholds=DestroyXMLTree(thresholds); + return(map); + } + map=(ThresholdMap *) AcquireCriticalMemory(sizeof(*map)); + map->map_id=(char *) NULL; + map->description=(char *) NULL; + map->levels=(ssize_t *) NULL; + attribute=GetXMLTreeAttribute(threshold,""map""); + if (attribute != (char *) NULL) + map->map_id=ConstantString(attribute); + content=GetXMLTreeContent(description); + if (content != (char *) NULL) + map->description=ConstantString(content); + attribute=GetXMLTreeAttribute(levels,""width""); + if (attribute == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->width=StringToUnsignedLong(attribute); + if (map->width == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + attribute=GetXMLTreeAttribute(levels,""height""); + if (attribute == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->height=StringToUnsignedLong(attribute); + if (map->height == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + attribute=GetXMLTreeAttribute(levels,""divisor""); + if (attribute == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->divisor=(ssize_t) StringToLong(attribute); + if (map->divisor < 2) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + content=GetXMLTreeContent(levels); + if (content == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingContent"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->levels=(ssize_t *) AcquireQuantumMemory((size_t) map->width,map->height* + sizeof(*map->levels)); + if (map->levels == (ssize_t *) NULL) + ThrowFatalException(ResourceLimitFatalError,""UnableToAcquireThresholdMap""); + for (i=0; i < (ssize_t) (map->width*map->height); i++) + { + map->levels[i]=(ssize_t) strtol(content,&p,10); + if (p == content) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidContent"", "" too few values, map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + if ((map->levels[i] < 0) || (map->levels[i] > map->divisor)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidContent"", "" %.20g out of range, map \""%s\"""", + (double) map->levels[i],map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + content=p; + } + value=(double) strtol(content,&p,10); + (void) value; + if (p != content) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidContent"", "" too many values, map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + thresholds=DestroyXMLTree(thresholds); + return(map); +} +",0,"static ThresholdMap *GetThresholdMapFile(const char *xml,const char *filename, + const char *map_id,ExceptionInfo *exception) +{ + char + *p; + + const char + *attribute, + *content; + + double + value; + + register ssize_t + i; + + ThresholdMap + *map; + + XMLTreeInfo + *description, + *levels, + *threshold, + *thresholds; + + (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), + ""Loading threshold map file \""%s\"" ..."",filename); + map=(ThresholdMap *) NULL; + thresholds=NewXMLTree(xml,exception); + if (thresholds == (XMLTreeInfo *) NULL) + return(map); + for (threshold=GetXMLTreeChild(thresholds,""threshold""); + threshold != (XMLTreeInfo *) NULL; + threshold=GetNextXMLTreeTag(threshold)) + { + attribute=GetXMLTreeAttribute(threshold,""map""); + if ((attribute != (char *) NULL) && (LocaleCompare(map_id,attribute) == 0)) + break; + attribute=GetXMLTreeAttribute(threshold,""alias""); + if ((attribute != (char *) NULL) && (LocaleCompare(map_id,attribute) == 0)) + break; + } + if (threshold == (XMLTreeInfo *) NULL) + { + thresholds=DestroyXMLTree(thresholds); + return(map); + } + description=GetXMLTreeChild(threshold,""description""); + if (description == (XMLTreeInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingElement"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + return(map); + } + levels=GetXMLTreeChild(threshold,""levels""); + if (levels == (XMLTreeInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingElement"", "", map \""%s\"""", map_id); + thresholds=DestroyXMLTree(thresholds); + return(map); + } + map=(ThresholdMap *) AcquireCriticalMemory(sizeof(*map)); + map->map_id=(char *) NULL; + map->description=(char *) NULL; + map->levels=(ssize_t *) NULL; + attribute=GetXMLTreeAttribute(threshold,""map""); + if (attribute != (char *) NULL) + map->map_id=ConstantString(attribute); + content=GetXMLTreeContent(description); + if (content != (char *) NULL) + map->description=ConstantString(content); + attribute=GetXMLTreeAttribute(levels,""width""); + if (attribute == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->width=StringToUnsignedLong(attribute); + if (map->width == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + attribute=GetXMLTreeAttribute(levels,""height""); + if (attribute == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->height=StringToUnsignedLong(attribute); + if (map->height == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + attribute=GetXMLTreeAttribute(levels,""divisor""); + if (attribute == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->divisor=(ssize_t) StringToLong(attribute); + if (map->divisor < 2) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidAttribute"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + content=GetXMLTreeContent(levels); + if (content == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlMissingContent"", "", map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + map->levels=(ssize_t *) AcquireQuantumMemory((size_t) map->width,map->height* + sizeof(*map->levels)); + if (map->levels == (ssize_t *) NULL) + ThrowFatalException(ResourceLimitFatalError,""UnableToAcquireThresholdMap""); + for (i=0; i < (ssize_t) (map->width*map->height); i++) + { + map->levels[i]=(ssize_t) strtol(content,&p,10); + if (p == content) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidContent"", "" too few values, map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + if ((map->levels[i] < 0) || (map->levels[i] > map->divisor)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidContent"", "" %.20g out of range, map \""%s\"""", + (double) map->levels[i],map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + content=p; + } + value=(double) strtol(content,&p,10); + (void) value; + if (p != content) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""XmlInvalidContent"", "" too many values, map \""%s\"""",map_id); + thresholds=DestroyXMLTree(thresholds); + map=DestroyThresholdMap(map); + return(map); + } + thresholds=DestroyXMLTree(thresholds); + return(map); +} +","@@ -212,6 +212,8 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image, + threshold_image=CloneImage(image,0,0,MagickTrue,exception); + if (threshold_image == (Image *) NULL) + return((Image *) NULL); ++ if (width == 0) ++ return(threshold_image); + status=SetImageStorageClass(threshold_image,DirectClass,exception); + if (status == MagickFalse) + {",1522,1758,2048 +17619,"WORD32 ih264d_insert_lt_node(dpb_manager_t *ps_dpb_mgr, + struct dpb_info_t *ps_mov_node, + UWORD32 u4_lt_idx, + UWORD8 u1_fld_pic_flag) +{ + UWORD8 u1_mark_top_field_long_term = 0; + UWORD8 u1_mark_bot_field_long_term = 0; + + { + if(u1_fld_pic_flag) + { + /* Assign corresponding field (top or bottom) long_term_frame_idx */ + + if((ps_mov_node->s_top_field.u1_reference_info == IS_LONG_TERM) + && (ps_mov_node->s_bot_field.u1_reference_info + == IS_LONG_TERM)) + { + if(ps_mov_node->u1_lt_idx == u4_lt_idx) + u1_mark_bot_field_long_term = 1; + else + { + + UWORD32 i4_error_code; + i4_error_code = ERROR_DBP_MANAGER_T; + + return i4_error_code; + + } + } + else if(ps_mov_node->s_top_field.u1_reference_info == IS_LONG_TERM) + { + u1_mark_top_field_long_term = 1; + } + + if(!(u1_mark_top_field_long_term || u1_mark_bot_field_long_term)) + { + UWORD32 i4_error_code; + i4_error_code = ERROR_DBP_MANAGER_T; + return i4_error_code; + } + } + else + { + ps_mov_node->s_top_field.u1_reference_info = IS_LONG_TERM; + ps_mov_node->s_bot_field.u1_reference_info = IS_LONG_TERM; + ps_mov_node->s_top_field.u1_long_term_frame_idx = u4_lt_idx; + ps_mov_node->s_bot_field.u1_long_term_frame_idx = u4_lt_idx; + u1_mark_bot_field_long_term = 1; + u1_mark_top_field_long_term = 1; + } + + ps_mov_node->u1_lt_idx = u4_lt_idx; //Assign the LT index to the node + ps_mov_node->ps_pic_buf->u1_long_term_frm_idx = u4_lt_idx; + ps_mov_node->u1_used_as_ref = IS_LONG_TERM; + + /* Insert the new long term in the LT list with u4_lt_idx */ + /* in ascending order. */ + if(ps_dpb_mgr->u1_num_lt_ref_bufs > 0) + { + struct dpb_info_t *ps_next_dpb = ps_dpb_mgr->ps_dpb_ht_head; + if(u4_lt_idx < ps_next_dpb->u1_lt_idx) + { + ps_mov_node->ps_prev_long = ps_next_dpb; + ps_dpb_mgr->ps_dpb_ht_head = ps_mov_node; + } + else + { + WORD32 i; + struct dpb_info_t *ps_nxtDPB = ps_next_dpb; + ps_next_dpb = ps_next_dpb->ps_prev_long; + for(i = 1; i < ps_dpb_mgr->u1_num_lt_ref_bufs; i++) + { + if(ps_next_dpb->u1_lt_idx > u4_lt_idx) + break; + ps_nxtDPB = ps_next_dpb; + ps_next_dpb = ps_next_dpb->ps_prev_long; + } + + ps_nxtDPB->ps_prev_long = ps_mov_node; + ps_mov_node->ps_prev_long = ps_next_dpb; + } + } + else + { + ps_dpb_mgr->ps_dpb_ht_head = ps_mov_node; + ps_mov_node->ps_prev_long = NULL; + } + /* Identify the picture buffer as a long term picture buffer */ + ps_mov_node->ps_pic_buf->u1_is_short = 0; + + /* Increment LT buf count only if new LT node inserted */ + /* If Increment during top_field is done, don't increment */ + /* for bottom field, as both them are part of same pic. */ + if(u1_mark_bot_field_long_term) + ps_dpb_mgr->u1_num_lt_ref_bufs++; + + } + return OK; +} +",0,"WORD32 ih264d_insert_lt_node(dpb_manager_t *ps_dpb_mgr, + struct dpb_info_t *ps_mov_node, + UWORD32 u4_lt_idx, + UWORD8 u1_fld_pic_flag) +{ + UWORD8 u1_mark_top_field_long_term = 0; + UWORD8 u1_mark_bot_field_long_term = 0; + + { + if(u1_fld_pic_flag) + { + /* Assign corresponding field (top or bottom) long_term_frame_idx */ + + if((ps_mov_node->s_top_field.u1_reference_info == IS_LONG_TERM) + && (ps_mov_node->s_bot_field.u1_reference_info + == IS_LONG_TERM)) + { + if(ps_mov_node->u1_lt_idx == u4_lt_idx) + u1_mark_bot_field_long_term = 1; + else + { + + UWORD32 i4_error_code; + i4_error_code = ERROR_DBP_MANAGER_T; + + return i4_error_code; + + } + } + else if(ps_mov_node->s_top_field.u1_reference_info == IS_LONG_TERM) + { + u1_mark_top_field_long_term = 1; + } + + if(!(u1_mark_top_field_long_term || u1_mark_bot_field_long_term)) + { + UWORD32 i4_error_code; + i4_error_code = ERROR_DBP_MANAGER_T; + return i4_error_code; + } + } + else + { + ps_mov_node->s_top_field.u1_reference_info = IS_LONG_TERM; + ps_mov_node->s_bot_field.u1_reference_info = IS_LONG_TERM; + ps_mov_node->s_top_field.u1_long_term_frame_idx = u4_lt_idx; + ps_mov_node->s_bot_field.u1_long_term_frame_idx = u4_lt_idx; + u1_mark_bot_field_long_term = 1; + u1_mark_top_field_long_term = 1; + } + + ps_mov_node->u1_lt_idx = u4_lt_idx; //Assign the LT index to the node + ps_mov_node->ps_pic_buf->u1_long_term_frm_idx = u4_lt_idx; + ps_mov_node->u1_used_as_ref = IS_LONG_TERM; + + /* Insert the new long term in the LT list with u4_lt_idx */ + /* in ascending order. */ + if(ps_dpb_mgr->u1_num_lt_ref_bufs > 0) + { + struct dpb_info_t *ps_next_dpb = ps_dpb_mgr->ps_dpb_ht_head; + if(u4_lt_idx < ps_next_dpb->u1_lt_idx) + { + ps_mov_node->ps_prev_long = ps_next_dpb; + ps_dpb_mgr->ps_dpb_ht_head = ps_mov_node; + } + else + { + WORD32 i; + struct dpb_info_t *ps_nxtDPB = ps_next_dpb; + ps_next_dpb = ps_next_dpb->ps_prev_long; + for(i = 1; i < ps_dpb_mgr->u1_num_lt_ref_bufs; i++) + { + if(ps_next_dpb->u1_lt_idx > u4_lt_idx) + break; + ps_nxtDPB = ps_next_dpb; + ps_next_dpb = ps_next_dpb->ps_prev_long; + } + + ps_nxtDPB->ps_prev_long = ps_mov_node; + ps_mov_node->ps_prev_long = ps_next_dpb; + } + } + else + { + ps_dpb_mgr->ps_dpb_ht_head = ps_mov_node; + ps_mov_node->ps_prev_long = NULL; + } + /* Identify the picture buffer as a long term picture buffer */ + ps_mov_node->ps_pic_buf->u1_is_short = 0; + + /* Increment LT buf count only if new LT node inserted */ + /* If Increment during top_field is done, don't increment */ + /* for bottom field, as both them are part of same pic. */ + if(u1_mark_bot_field_long_term) + ps_dpb_mgr->u1_num_lt_ref_bufs++; + + } + return OK; +} +","@@ -843,7 +843,7 @@ + + WORD32 ih264d_read_mmco_commands(struct _DecStruct * ps_dec) + { + dec_bit_stream_t *ps_bitstrm = ps_dec->ps_bitstrm; +- dpb_commands_t *ps_dpb_cmds = ps_dec->ps_dpb_cmds; ++ dpb_commands_t *ps_dpb_cmds = &(ps_dec->s_dpb_cmds_scratch); + dec_slice_params_t * ps_slice = ps_dec->ps_cur_slice; + WORD32 j; + UWORD8 u1_buf_mode; +",833,1069,2048 +8471,"static int f2fs_write_cache_pages(struct address_space *mapping, + struct writeback_control *wbc) +{ + int ret = 0; + int done = 0; + struct pagevec pvec; + int nr_pages; + pgoff_t uninitialized_var(writeback_index); + pgoff_t index; + pgoff_t end; /* Inclusive */ + pgoff_t done_index; + int cycled; + int range_whole = 0; + int tag; + int nwritten = 0; + + pagevec_init(&pvec, 0); + + if (wbc->range_cyclic) { + writeback_index = mapping->writeback_index; /* prev offset */ + index = writeback_index; + if (index == 0) + cycled = 1; + else + cycled = 0; + end = -1; + } else { + index = wbc->range_start >> PAGE_SHIFT; + end = wbc->range_end >> PAGE_SHIFT; + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) + range_whole = 1; + cycled = 1; /* ignore range_cyclic tests */ + } + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + tag = PAGECACHE_TAG_TOWRITE; + else + tag = PAGECACHE_TAG_DIRTY; +retry: + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + tag_pages_for_writeback(mapping, index, end); + done_index = index; + while (!done && (index <= end)) { + int i; + + nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag, + min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1); + if (nr_pages == 0) + break; + + for (i = 0; i < nr_pages; i++) { + struct page *page = pvec.pages[i]; + + if (page->index > end) { + done = 1; + break; + } + + done_index = page->index; + + lock_page(page); + + if (unlikely(page->mapping != mapping)) { +continue_unlock: + unlock_page(page); + continue; + } + + if (!PageDirty(page)) { + /* someone wrote it for us */ + goto continue_unlock; + } + + if (PageWriteback(page)) { + if (wbc->sync_mode != WB_SYNC_NONE) + f2fs_wait_on_page_writeback(page, + DATA, true); + else + goto continue_unlock; + } + + BUG_ON(PageWriteback(page)); + if (!clear_page_dirty_for_io(page)) + goto continue_unlock; + + ret = mapping->a_ops->writepage(page, wbc); + if (unlikely(ret)) { + /* + * keep nr_to_write, since vfs uses this to + * get # of written pages. + */ + if (ret == AOP_WRITEPAGE_ACTIVATE) { + unlock_page(page); + ret = 0; + continue; + } + done_index = page->index + 1; + done = 1; + break; + } else { + nwritten++; + } + + if (--wbc->nr_to_write <= 0 && + wbc->sync_mode == WB_SYNC_NONE) { + done = 1; + break; + } + } + pagevec_release(&pvec); + cond_resched(); + } + + if (!cycled && !done) { + cycled = 1; + index = 0; + end = writeback_index - 1; + goto retry; + } + if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) + mapping->writeback_index = done_index; + + if (nwritten) + f2fs_submit_merged_bio_cond(F2FS_M_SB(mapping), mapping->host, + NULL, 0, DATA, WRITE); + + return ret; +} +",0,"static int f2fs_write_cache_pages(struct address_space *mapping, + struct writeback_control *wbc) +{ + int ret = 0; + int done = 0; + struct pagevec pvec; + int nr_pages; + pgoff_t uninitialized_var(writeback_index); + pgoff_t index; + pgoff_t end; /* Inclusive */ + pgoff_t done_index; + int cycled; + int range_whole = 0; + int tag; + int nwritten = 0; + + pagevec_init(&pvec, 0); + + if (wbc->range_cyclic) { + writeback_index = mapping->writeback_index; /* prev offset */ + index = writeback_index; + if (index == 0) + cycled = 1; + else + cycled = 0; + end = -1; + } else { + index = wbc->range_start >> PAGE_SHIFT; + end = wbc->range_end >> PAGE_SHIFT; + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) + range_whole = 1; + cycled = 1; /* ignore range_cyclic tests */ + } + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + tag = PAGECACHE_TAG_TOWRITE; + else + tag = PAGECACHE_TAG_DIRTY; +retry: + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + tag_pages_for_writeback(mapping, index, end); + done_index = index; + while (!done && (index <= end)) { + int i; + + nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag, + min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1); + if (nr_pages == 0) + break; + + for (i = 0; i < nr_pages; i++) { + struct page *page = pvec.pages[i]; + + if (page->index > end) { + done = 1; + break; + } + + done_index = page->index; + + lock_page(page); + + if (unlikely(page->mapping != mapping)) { +continue_unlock: + unlock_page(page); + continue; + } + + if (!PageDirty(page)) { + /* someone wrote it for us */ + goto continue_unlock; + } + + if (PageWriteback(page)) { + if (wbc->sync_mode != WB_SYNC_NONE) + f2fs_wait_on_page_writeback(page, + DATA, true); + else + goto continue_unlock; + } + + BUG_ON(PageWriteback(page)); + if (!clear_page_dirty_for_io(page)) + goto continue_unlock; + + ret = mapping->a_ops->writepage(page, wbc); + if (unlikely(ret)) { + /* + * keep nr_to_write, since vfs uses this to + * get # of written pages. + */ + if (ret == AOP_WRITEPAGE_ACTIVATE) { + unlock_page(page); + ret = 0; + continue; + } + done_index = page->index + 1; + done = 1; + break; + } else { + nwritten++; + } + + if (--wbc->nr_to_write <= 0 && + wbc->sync_mode == WB_SYNC_NONE) { + done = 1; + break; + } + } + pagevec_release(&pvec); + cond_resched(); + } + + if (!cycled && !done) { + cycled = 1; + index = 0; + end = writeback_index - 1; + goto retry; + } + if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) + mapping->writeback_index = done_index; + + if (nwritten) + f2fs_submit_merged_bio_cond(F2FS_M_SB(mapping), mapping->host, + NULL, 0, DATA, WRITE); + + return ret; +} +","@@ -964,7 +964,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock, + if (!err) { + map_bh(bh, inode->i_sb, map.m_pblk); + bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags; +- bh->b_size = map.m_len << inode->i_blkbits; ++ bh->b_size = (u64)map.m_len << inode->i_blkbits; + } + return err; + }",863,1099,2048 +4069,"stf_status ikev2parent_outI1(int whack_sock, + struct connection *c, + struct state *predecessor, + lset_t policy, + unsigned long try, + enum crypto_importance importance +#ifdef HAVE_LABELED_IPSEC + , struct xfrm_user_sec_ctx_ike * uctx +#endif + ) +{ + struct state *st = new_state(); + struct db_sa *sadb; + int groupnum; + int policy_index = POLICY_ISAKMP(policy, + c->spd.this.xauth_server, + c->spd.this.xauth_client); + + /* set up new state */ + get_cookie(TRUE, st->st_icookie, COOKIE_SIZE, &c->spd.that.host_addr); + initialize_new_state(st, c, policy, try, whack_sock, importance); + st->st_ikev2 = TRUE; + change_state(st, STATE_PARENT_I1); + st->st_msgid_lastack = INVALID_MSGID; + st->st_msgid_nextuse = 0; + st->st_try = try; + + if (HAS_IPSEC_POLICY(policy)) { +#ifdef HAVE_LABELED_IPSEC + st->sec_ctx = NULL; + if ( uctx != NULL) + libreswan_log( + ""Labeled ipsec is not supported with ikev2 yet""); + + +#endif + + add_pending(dup_any( + whack_sock), st, c, policy, 1, + predecessor == NULL ? SOS_NOBODY : predecessor->st_serialno +#ifdef HAVE_LABELED_IPSEC + , st->sec_ctx +#endif + ); + } + + if (predecessor == NULL) + libreswan_log(""initiating v2 parent SA""); + else + libreswan_log(""initiating v2 parent SA to replace #%lu"", + predecessor->st_serialno); + + if (predecessor != NULL) { + update_pending(predecessor, st); + whack_log(RC_NEW_STATE + STATE_PARENT_I1, + ""%s: initiate, replacing #%lu"", + enum_name(&state_names, st->st_state), + predecessor->st_serialno); + } else { + whack_log(RC_NEW_STATE + STATE_PARENT_I1, + ""%s: initiate"", + enum_name(&state_names, st->st_state)); + } + + /* + * now, we need to initialize st->st_oakley, specifically, the group + * number needs to be initialized. + */ + groupnum = 0; + + st->st_sadb = &oakley_sadb[policy_index]; + sadb = oakley_alg_makedb(st->st_connection->alg_info_ike, + st->st_sadb, 0); + if (sadb != NULL) + st->st_sadb = sadb; + sadb = st->st_sadb = sa_v2_convert(st->st_sadb); + { + unsigned int pc_cnt; + + /* look at all the proposals */ + if (st->st_sadb->prop_disj != NULL) { + for (pc_cnt = 0; + pc_cnt < st->st_sadb->prop_disj_cnt && groupnum == + 0; + pc_cnt++) { + struct db_v2_prop *vp = + &st->st_sadb->prop_disj[pc_cnt]; + unsigned int pr_cnt; + + /* look at all the proposals */ + if (vp->props != NULL) { + for (pr_cnt = 0; + pr_cnt < vp->prop_cnt && + groupnum == 0; + pr_cnt++) { + unsigned int ts_cnt; + struct db_v2_prop_conj *vpc = + &vp->props[pr_cnt]; + + for (ts_cnt = 0; + ts_cnt < vpc->trans_cnt && + groupnum == 0; ts_cnt++) { + struct db_v2_trans *tr + = + &vpc-> + trans[ + ts_cnt + ]; + if (tr != NULL && + tr->transform_type + == + IKEv2_TRANS_TYPE_DH) + { + groupnum = + tr-> + transid; + } + } + } + } + } + } + } + if (groupnum == 0) + groupnum = OAKLEY_GROUP_MODP2048; + st->st_oakley.group = lookup_group(groupnum); + st->st_oakley.groupnum = groupnum; + + /* now. we need to go calculate the nonce, and the KE */ + { + struct ke_continuation *ke = alloc_thing( + struct ke_continuation, + ""ikev2_outI1 KE""); + stf_status e; + + ke->md = alloc_md(); + ke->md->from_state = STATE_IKEv2_BASE; + ke->md->svm = ikev2_parent_firststate(); + ke->md->st = st; + set_suspended(st, ke->md); + + if (!st->st_sec_in_use) { + pcrc_init(&ke->ke_pcrc); + ke->ke_pcrc.pcrc_func = ikev2_parent_outI1_continue; + e = build_ke(&ke->ke_pcrc, st, st->st_oakley.group, + importance); + if ( (e != STF_SUSPEND && + e != STF_INLINE) || (e == STF_TOOMUCHCRYPTO)) { + loglog(RC_CRYPTOFAILED, + ""system too busy - Enabling dcookies [TODO]""); + delete_state(st); + } + } else { + e = + ikev2_parent_outI1_tail( + (struct pluto_crypto_req_cont *)ke, + NULL); + } + + reset_globals(); + + return e; + } +} +",0,"stf_status ikev2parent_outI1(int whack_sock, + struct connection *c, + struct state *predecessor, + lset_t policy, + unsigned long try, + enum crypto_importance importance +#ifdef HAVE_LABELED_IPSEC + , struct xfrm_user_sec_ctx_ike * uctx +#endif + ) +{ + struct state *st = new_state(); + struct db_sa *sadb; + int groupnum; + int policy_index = POLICY_ISAKMP(policy, + c->spd.this.xauth_server, + c->spd.this.xauth_client); + + /* set up new state */ + get_cookie(TRUE, st->st_icookie, COOKIE_SIZE, &c->spd.that.host_addr); + initialize_new_state(st, c, policy, try, whack_sock, importance); + st->st_ikev2 = TRUE; + change_state(st, STATE_PARENT_I1); + st->st_msgid_lastack = INVALID_MSGID; + st->st_msgid_nextuse = 0; + st->st_try = try; + + if (HAS_IPSEC_POLICY(policy)) { +#ifdef HAVE_LABELED_IPSEC + st->sec_ctx = NULL; + if ( uctx != NULL) + libreswan_log( + ""Labeled ipsec is not supported with ikev2 yet""); + + +#endif + + add_pending(dup_any( + whack_sock), st, c, policy, 1, + predecessor == NULL ? SOS_NOBODY : predecessor->st_serialno +#ifdef HAVE_LABELED_IPSEC + , st->sec_ctx +#endif + ); + } + + if (predecessor == NULL) + libreswan_log(""initiating v2 parent SA""); + else + libreswan_log(""initiating v2 parent SA to replace #%lu"", + predecessor->st_serialno); + + if (predecessor != NULL) { + update_pending(predecessor, st); + whack_log(RC_NEW_STATE + STATE_PARENT_I1, + ""%s: initiate, replacing #%lu"", + enum_name(&state_names, st->st_state), + predecessor->st_serialno); + } else { + whack_log(RC_NEW_STATE + STATE_PARENT_I1, + ""%s: initiate"", + enum_name(&state_names, st->st_state)); + } + + /* + * now, we need to initialize st->st_oakley, specifically, the group + * number needs to be initialized. + */ + groupnum = 0; + + st->st_sadb = &oakley_sadb[policy_index]; + sadb = oakley_alg_makedb(st->st_connection->alg_info_ike, + st->st_sadb, 0); + if (sadb != NULL) + st->st_sadb = sadb; + sadb = st->st_sadb = sa_v2_convert(st->st_sadb); + { + unsigned int pc_cnt; + + /* look at all the proposals */ + if (st->st_sadb->prop_disj != NULL) { + for (pc_cnt = 0; + pc_cnt < st->st_sadb->prop_disj_cnt && groupnum == + 0; + pc_cnt++) { + struct db_v2_prop *vp = + &st->st_sadb->prop_disj[pc_cnt]; + unsigned int pr_cnt; + + /* look at all the proposals */ + if (vp->props != NULL) { + for (pr_cnt = 0; + pr_cnt < vp->prop_cnt && + groupnum == 0; + pr_cnt++) { + unsigned int ts_cnt; + struct db_v2_prop_conj *vpc = + &vp->props[pr_cnt]; + + for (ts_cnt = 0; + ts_cnt < vpc->trans_cnt && + groupnum == 0; ts_cnt++) { + struct db_v2_trans *tr + = + &vpc-> + trans[ + ts_cnt + ]; + if (tr != NULL && + tr->transform_type + == + IKEv2_TRANS_TYPE_DH) + { + groupnum = + tr-> + transid; + } + } + } + } + } + } + } + if (groupnum == 0) + groupnum = OAKLEY_GROUP_MODP2048; + st->st_oakley.group = lookup_group(groupnum); + st->st_oakley.groupnum = groupnum; + + /* now. we need to go calculate the nonce, and the KE */ + { + struct ke_continuation *ke = alloc_thing( + struct ke_continuation, + ""ikev2_outI1 KE""); + stf_status e; + + ke->md = alloc_md(); + ke->md->from_state = STATE_IKEv2_BASE; + ke->md->svm = ikev2_parent_firststate(); + ke->md->st = st; + set_suspended(st, ke->md); + + if (!st->st_sec_in_use) { + pcrc_init(&ke->ke_pcrc); + ke->ke_pcrc.pcrc_func = ikev2_parent_outI1_continue; + e = build_ke(&ke->ke_pcrc, st, st->st_oakley.group, + importance); + if ( (e != STF_SUSPEND && + e != STF_INLINE) || (e == STF_TOOMUCHCRYPTO)) { + loglog(RC_CRYPTOFAILED, + ""system too busy - Enabling dcookies [TODO]""); + delete_state(st); + } + } else { + e = + ikev2_parent_outI1_tail( + (struct pluto_crypto_req_cont *)ke, + NULL); + } + + reset_globals(); + + return e; + } +} +","@@ -306,8 +306,6 @@ static void ikev2_parent_outI1_continue(struct pluto_crypto_req_cont *pcrc, + } + reset_cur_state(); + reset_globals(); +- +- passert(GLOBALS_ARE_RESET()); + } + + /* +@@ -729,18 +727,31 @@ stf_status ikev2parent_inI1outR1(struct msg_digest *md) + */ + { + struct ikev2_ke *ke; ++ char fromname[ADDRTOT_BUF]; ++ addrtot(&md->sender, 0, fromname, ADDRTOT_BUF); ++ ++ if (!md->chain[ISAKMP_NEXT_v2KE]) { ++ /* is this a notify? If so, log it */ ++ if(md->chain[ISAKMP_NEXT_v2N]) { ++ libreswan_log(""Received Notify(%d): %s"", ++ md->chain[ISAKMP_NEXT_v2N]->payload.v2n.isan_type, ++ enum_name(&ikev2_notify_names, ++ md->chain[ISAKMP_NEXT_v2N]->payload.v2n.isan_type)); ++ } ++ libreswan_log( ++ ""rejecting I1 from %s:%u, no KE payload present"", ++ fromname, md->sender_port); ++ return STF_FAIL + v2N_INVALID_KE_PAYLOAD; ++ } + ke = &md->chain[ISAKMP_NEXT_v2KE]->payload.v2ke; + + st->st_oakley.group = lookup_group(ke->isak_group); + if (st->st_oakley.group == NULL) { +- char fromname[ADDRTOT_BUF]; +- +- addrtot(&md->sender, 0, fromname, ADDRTOT_BUF); + libreswan_log( + ""rejecting I1 from %s:%u, invalid DH group=%u"", + fromname, md->sender_port, + ke->isak_group); +- return v2N_INVALID_KE_PAYLOAD; ++ return STF_FAIL + v2N_INVALID_KE_PAYLOAD; + } + } + +@@ -819,8 +830,6 @@ static void ikev2_parent_inI1outR1_continue(struct pluto_crypto_req_cont *pcrc, + release_md(ke->md); + } + reset_globals(); +- +- passert(GLOBALS_ARE_RESET()); + } + + static stf_status ikev2_parent_inI1outR1_tail( +@@ -1145,8 +1154,6 @@ static void ikev2_parent_inR1outI2_continue(struct pluto_crypto_req_cont *pcrc, + release_md(dh->md); + } + reset_globals(); +- +- passert(GLOBALS_ARE_RESET()); + } + + static void ikev2_padup_pre_encrypt(struct msg_digest *md, +@@ -1714,7 +1721,7 @@ stf_status ikev2parent_inI2outR2(struct msg_digest *md) + /* verify that there is in fact an encrypted payload */ + if (!md->chain[ISAKMP_NEXT_v2E]) { + libreswan_log(""R2 state should receive an encrypted payload""); +- reset_globals(); ++ reset_globals(); /* XXX suspicious - why was this deemed neccessary? */ + return STF_FATAL; + } + +@@ -1794,8 +1801,6 @@ static void ikev2_parent_inI2outR2_continue(struct pluto_crypto_req_cont *pcrc, + release_md(dh->md); + } + reset_globals(); +- +- passert(GLOBALS_ARE_RESET()); + } + + static stf_status ikev2_parent_inI2outR2_tail(",1232,1468,2048 +4237,"static int call_sbin_request_key(struct key_construction *cons, + const char *op, + void *aux) +{ + const struct cred *cred = current_cred(); + key_serial_t prkey, sskey; + struct key *key = cons->key, *authkey = cons->authkey, *keyring, + *session; + char *argv[9], *envp[3], uid_str[12], gid_str[12]; + char key_str[12], keyring_str[3][12]; + char desc[20]; + int ret, i; + + kenter(""{%d},{%d},%s"", key->serial, authkey->serial, op); + + ret = install_user_keyrings(); + if (ret < 0) + goto error_alloc; + + /* allocate a new session keyring */ + sprintf(desc, ""_req.%u"", key->serial); + + cred = get_current_cred(); + keyring = keyring_alloc(desc, cred->fsuid, cred->fsgid, cred, + KEY_POS_ALL | KEY_USR_VIEW | KEY_USR_READ, + KEY_ALLOC_QUOTA_OVERRUN, NULL); + put_cred(cred); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); + goto error_alloc; + } + + /* attach the auth key to the session keyring */ + ret = key_link(keyring, authkey); + if (ret < 0) + goto error_link; + + /* record the UID and GID */ + sprintf(uid_str, ""%d"", from_kuid(&init_user_ns, cred->fsuid)); + sprintf(gid_str, ""%d"", from_kgid(&init_user_ns, cred->fsgid)); + + /* we say which key is under construction */ + sprintf(key_str, ""%d"", key->serial); + + /* we specify the process's default keyrings */ + sprintf(keyring_str[0], ""%d"", + cred->thread_keyring ? cred->thread_keyring->serial : 0); + + prkey = 0; + if (cred->process_keyring) + prkey = cred->process_keyring->serial; + sprintf(keyring_str[1], ""%d"", prkey); + + rcu_read_lock(); + session = rcu_dereference(cred->session_keyring); + if (!session) + session = cred->user->session_keyring; + sskey = session->serial; + rcu_read_unlock(); + + sprintf(keyring_str[2], ""%d"", sskey); + + /* set up a minimal environment */ + i = 0; + envp[i++] = ""HOME=/""; + envp[i++] = ""PATH=/sbin:/bin:/usr/sbin:/usr/bin""; + envp[i] = NULL; + + /* set up the argument list */ + i = 0; + argv[i++] = ""/sbin/request-key""; + argv[i++] = (char *) op; + argv[i++] = key_str; + argv[i++] = uid_str; + argv[i++] = gid_str; + argv[i++] = keyring_str[0]; + argv[i++] = keyring_str[1]; + argv[i++] = keyring_str[2]; + argv[i] = NULL; + + /* do it */ + ret = call_usermodehelper_keys(argv[0], argv, envp, keyring, + UMH_WAIT_PROC); + kdebug(""usermode -> 0x%x"", ret); + if (ret >= 0) { + /* ret is the exit/wait code */ + if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) || + key_validate(key) < 0) + ret = -ENOKEY; + else + /* ignore any errors from userspace if the key was + * instantiated */ + ret = 0; + } + +error_link: + key_put(keyring); + +error_alloc: + complete_request_key(cons, ret); + kleave("" = %d"", ret); + return ret; +} +",0,"static int call_sbin_request_key(struct key_construction *cons, + const char *op, + void *aux) +{ + const struct cred *cred = current_cred(); + key_serial_t prkey, sskey; + struct key *key = cons->key, *authkey = cons->authkey, *keyring, + *session; + char *argv[9], *envp[3], uid_str[12], gid_str[12]; + char key_str[12], keyring_str[3][12]; + char desc[20]; + int ret, i; + + kenter(""{%d},{%d},%s"", key->serial, authkey->serial, op); + + ret = install_user_keyrings(); + if (ret < 0) + goto error_alloc; + + /* allocate a new session keyring */ + sprintf(desc, ""_req.%u"", key->serial); + + cred = get_current_cred(); + keyring = keyring_alloc(desc, cred->fsuid, cred->fsgid, cred, + KEY_POS_ALL | KEY_USR_VIEW | KEY_USR_READ, + KEY_ALLOC_QUOTA_OVERRUN, NULL); + put_cred(cred); + if (IS_ERR(keyring)) { + ret = PTR_ERR(keyring); + goto error_alloc; + } + + /* attach the auth key to the session keyring */ + ret = key_link(keyring, authkey); + if (ret < 0) + goto error_link; + + /* record the UID and GID */ + sprintf(uid_str, ""%d"", from_kuid(&init_user_ns, cred->fsuid)); + sprintf(gid_str, ""%d"", from_kgid(&init_user_ns, cred->fsgid)); + + /* we say which key is under construction */ + sprintf(key_str, ""%d"", key->serial); + + /* we specify the process's default keyrings */ + sprintf(keyring_str[0], ""%d"", + cred->thread_keyring ? cred->thread_keyring->serial : 0); + + prkey = 0; + if (cred->process_keyring) + prkey = cred->process_keyring->serial; + sprintf(keyring_str[1], ""%d"", prkey); + + rcu_read_lock(); + session = rcu_dereference(cred->session_keyring); + if (!session) + session = cred->user->session_keyring; + sskey = session->serial; + rcu_read_unlock(); + + sprintf(keyring_str[2], ""%d"", sskey); + + /* set up a minimal environment */ + i = 0; + envp[i++] = ""HOME=/""; + envp[i++] = ""PATH=/sbin:/bin:/usr/sbin:/usr/bin""; + envp[i] = NULL; + + /* set up the argument list */ + i = 0; + argv[i++] = ""/sbin/request-key""; + argv[i++] = (char *) op; + argv[i++] = key_str; + argv[i++] = uid_str; + argv[i++] = gid_str; + argv[i++] = keyring_str[0]; + argv[i++] = keyring_str[1]; + argv[i++] = keyring_str[2]; + argv[i] = NULL; + + /* do it */ + ret = call_usermodehelper_keys(argv[0], argv, envp, keyring, + UMH_WAIT_PROC); + kdebug(""usermode -> 0x%x"", ret); + if (ret >= 0) { + /* ret is the exit/wait code */ + if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) || + key_validate(key) < 0) + ret = -ENOKEY; + else + /* ignore any errors from userspace if the key was + * instantiated */ + ret = 0; + } + +error_link: + key_put(keyring); + +error_alloc: + complete_request_key(cons, ret); + kleave("" = %d"", ret); + return ret; +} +","@@ -440,6 +440,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx, + + kenter(""""); + ++ if (ctx->index_key.type == &key_type_keyring) ++ return ERR_PTR(-EPERM); ++ + user = key_user_lookup(current_fsuid()); + if (!user) + return ERR_PTR(-ENOMEM);",813,1049,2048 +17872,"void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) +{ + struct iphdr *iph; + int room; + struct icmp_bxm icmp_param; + struct rtable *rt = skb_rtable(skb_in); + struct ipcm_cookie ipc; + __be32 saddr; + u8 tos; + struct net *net; + struct sock *sk; + + if (!rt) + goto out; + net = dev_net(rt->dst.dev); + + /* + * Find the original header. It is expected to be valid, of course. + * Check this, icmp_send is called from the most obscure devices + * sometimes. + */ + iph = ip_hdr(skb_in); + + if ((u8 *)iph < skb_in->head || + (skb_in->network_header + sizeof(*iph)) > skb_in->tail) + goto out; + + /* + * No replies to physical multicast/broadcast + */ + if (skb_in->pkt_type != PACKET_HOST) + goto out; + + /* + * Now check at the protocol level + */ + if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) + goto out; + + /* + * Only reply to fragment 0. We byte re-order the constant + * mask for efficiency. + */ + if (iph->frag_off & htons(IP_OFFSET)) + goto out; + + /* + * If we send an ICMP error to an ICMP error a mess would result.. + */ + if (icmp_pointers[type].error) { + /* + * We are an error, check if we are replying to an + * ICMP error + */ + if (iph->protocol == IPPROTO_ICMP) { + u8 _inner_type, *itp; + + itp = skb_header_pointer(skb_in, + skb_network_header(skb_in) + + (iph->ihl << 2) + + offsetof(struct icmphdr, + type) - + skb_in->data, + sizeof(_inner_type), + &_inner_type); + if (itp == NULL) + goto out; + + /* + * Assume any unknown ICMP type is an error. This + * isn't specified by the RFC, but think about it.. + */ + if (*itp > NR_ICMP_TYPES || + icmp_pointers[*itp].error) + goto out; + } + } + + sk = icmp_xmit_lock(net); + if (sk == NULL) + return; + + /* + * Construct source address and options. + */ + + saddr = iph->daddr; + if (!(rt->rt_flags & RTCF_LOCAL)) { + struct net_device *dev = NULL; + + rcu_read_lock(); + if (rt_is_input_route(rt) && + net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr) + dev = dev_get_by_index_rcu(net, rt->rt_iif); + + if (dev) + saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); + else + saddr = 0; + rcu_read_unlock(); + } + + tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) | + IPTOS_PREC_INTERNETCONTROL) : + iph->tos; + + if (ip_options_echo(&icmp_param.replyopts, skb_in)) + goto out_unlock; + + + /* + * Prepare data for ICMP header. + */ + + icmp_param.data.icmph.type = type; + icmp_param.data.icmph.code = code; + icmp_param.data.icmph.un.gateway = info; + icmp_param.data.icmph.checksum = 0; + icmp_param.skb = skb_in; + icmp_param.offset = skb_network_offset(skb_in); + inet_sk(sk)->tos = tos; + ipc.addr = iph->saddr; + ipc.opt = &icmp_param.replyopts; + ipc.tx_flags = 0; + + rt = icmp_route_lookup(net, skb_in, iph, saddr, tos, + type, code, &icmp_param); + if (IS_ERR(rt)) + goto out_unlock; + + if (!icmpv4_xrlim_allow(net, rt, type, code)) + goto ende; + + /* RFC says return as much as we can without exceeding 576 bytes. */ + + room = dst_mtu(&rt->dst); + if (room > 576) + room = 576; + room -= sizeof(struct iphdr) + icmp_param.replyopts.optlen; + room -= sizeof(struct icmphdr); + + icmp_param.data_len = skb_in->len - icmp_param.offset; + if (icmp_param.data_len > room) + icmp_param.data_len = room; + icmp_param.head_len = sizeof(struct icmphdr); + + icmp_push_reply(&icmp_param, &ipc, &rt); +ende: + ip_rt_put(rt); +out_unlock: + icmp_xmit_unlock(sk); +out:; +} +",1,"void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) +{ + struct iphdr *iph; + int room; + struct icmp_bxm icmp_param; + struct rtable *rt = skb_rtable(skb_in); + struct ipcm_cookie ipc; + __be32 saddr; + u8 tos; + struct net *net; + struct sock *sk; + + if (!rt) + goto out; + net = dev_net(rt->dst.dev); + + /* + * Find the original header. It is expected to be valid, of course. + * Check this, icmp_send is called from the most obscure devices + * sometimes. + */ + iph = ip_hdr(skb_in); + + if ((u8 *)iph < skb_in->head || + (skb_in->network_header + sizeof(*iph)) > skb_in->tail) + goto out; + + /* + * No replies to physical multicast/broadcast + */ + if (skb_in->pkt_type != PACKET_HOST) + goto out; + + /* + * Now check at the protocol level + */ + if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) + goto out; + + /* + * Only reply to fragment 0. We byte re-order the constant + * mask for efficiency. + */ + if (iph->frag_off & htons(IP_OFFSET)) + goto out; + + /* + * If we send an ICMP error to an ICMP error a mess would result.. + */ + if (icmp_pointers[type].error) { + /* + * We are an error, check if we are replying to an + * ICMP error + */ + if (iph->protocol == IPPROTO_ICMP) { + u8 _inner_type, *itp; + + itp = skb_header_pointer(skb_in, + skb_network_header(skb_in) + + (iph->ihl << 2) + + offsetof(struct icmphdr, + type) - + skb_in->data, + sizeof(_inner_type), + &_inner_type); + if (itp == NULL) + goto out; + + /* + * Assume any unknown ICMP type is an error. This + * isn't specified by the RFC, but think about it.. + */ + if (*itp > NR_ICMP_TYPES || + icmp_pointers[*itp].error) + goto out; + } + } + + sk = icmp_xmit_lock(net); + if (sk == NULL) + return; + + /* + * Construct source address and options. + */ + + saddr = iph->daddr; + if (!(rt->rt_flags & RTCF_LOCAL)) { + struct net_device *dev = NULL; + + rcu_read_lock(); + if (rt_is_input_route(rt) && + net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr) + dev = dev_get_by_index_rcu(net, rt->rt_iif); + + if (dev) + saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); + else + saddr = 0; + rcu_read_unlock(); + } + + tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) | + IPTOS_PREC_INTERNETCONTROL) : + iph->tos; + + if (ip_options_echo(&icmp_param.replyopts.opt.opt, skb_in)) + goto out_unlock; + + + /* + * Prepare data for ICMP header. + */ + + icmp_param.data.icmph.type = type; + icmp_param.data.icmph.code = code; + icmp_param.data.icmph.un.gateway = info; + icmp_param.data.icmph.checksum = 0; + icmp_param.skb = skb_in; + icmp_param.offset = skb_network_offset(skb_in); + inet_sk(sk)->tos = tos; + ipc.addr = iph->saddr; + ipc.opt = &icmp_param.replyopts.opt; + ipc.tx_flags = 0; + + rt = icmp_route_lookup(net, skb_in, iph, saddr, tos, + type, code, &icmp_param); + if (IS_ERR(rt)) + goto out_unlock; + + if (!icmpv4_xrlim_allow(net, rt, type, code)) + goto ende; + + /* RFC says return as much as we can without exceeding 576 bytes. */ + + room = dst_mtu(&rt->dst); + if (room > 576) + room = 576; + room -= sizeof(struct iphdr) + icmp_param.replyopts.opt.opt.optlen; + room -= sizeof(struct icmphdr); + + icmp_param.data_len = skb_in->len - icmp_param.offset; + if (icmp_param.data_len > room) + icmp_param.data_len = room; + icmp_param.head_len = sizeof(struct icmphdr); + + icmp_push_reply(&icmp_param, &ipc, &rt); +ende: + ip_rt_put(rt); +out_unlock: + icmp_xmit_unlock(sk); +out:; +} +","@@ -108,8 +108,7 @@ struct icmp_bxm { + __be32 times[3]; + } data; + int head_len; +- struct ip_options replyopts; +- unsigned char optbuf[40]; ++ struct ip_options_data replyopts; + }; + + /* An array of errno for error messages from dest unreach. */ +@@ -333,7 +332,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) + struct inet_sock *inet; + __be32 daddr; + +- if (ip_options_echo(&icmp_param->replyopts, skb)) ++ if (ip_options_echo(&icmp_param->replyopts.opt.opt, skb)) + return; + + sk = icmp_xmit_lock(net); +@@ -347,10 +346,10 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) + daddr = ipc.addr = rt->rt_src; + ipc.opt = NULL; + ipc.tx_flags = 0; +- if (icmp_param->replyopts.optlen) { +- ipc.opt = &icmp_param->replyopts; +- if (ipc.opt->srr) +- daddr = icmp_param->replyopts.faddr; ++ if (icmp_param->replyopts.opt.opt.optlen) { ++ ipc.opt = &icmp_param->replyopts.opt; ++ if (ipc.opt->opt.srr) ++ daddr = icmp_param->replyopts.opt.opt.faddr; + } + { + struct flowi4 fl4 = { +@@ -379,8 +378,8 @@ static struct rtable *icmp_route_lookup(struct net *net, struct sk_buff *skb_in, + struct icmp_bxm *param) + { + struct flowi4 fl4 = { +- .daddr = (param->replyopts.srr ? +- param->replyopts.faddr : iph->saddr), ++ .daddr = (param->replyopts.opt.opt.srr ? ++ param->replyopts.opt.opt.faddr : iph->saddr), + .saddr = saddr, + .flowi4_tos = RT_TOS(tos), + .flowi4_proto = IPPROTO_ICMP, +@@ -581,7 +580,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) + IPTOS_PREC_INTERNETCONTROL) : + iph->tos; + +- if (ip_options_echo(&icmp_param.replyopts, skb_in)) ++ if (ip_options_echo(&icmp_param.replyopts.opt.opt, skb_in)) + goto out_unlock; + + +@@ -597,7 +596,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) + icmp_param.offset = skb_network_offset(skb_in); + inet_sk(sk)->tos = tos; + ipc.addr = iph->saddr; +- ipc.opt = &icmp_param.replyopts; ++ ipc.opt = &icmp_param.replyopts.opt; + ipc.tx_flags = 0; + + rt = icmp_route_lookup(net, skb_in, iph, saddr, tos, +@@ -613,7 +612,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) + room = dst_mtu(&rt->dst); + if (room > 576) + room = 576; +- room -= sizeof(struct iphdr) + icmp_param.replyopts.optlen; ++ room -= sizeof(struct iphdr) + icmp_param.replyopts.opt.opt.optlen; + room -= sizeof(struct icmphdr); + + icmp_param.data_len = skb_in->len - icmp_param.offset;",1059,1295,2048 +9102,"u2fh_devs_discover (u2fh_devs * devs, unsigned *max_index) +{ + struct hid_device_info *di, *cur_dev; + u2fh_rc res = U2FH_NO_U2F_DEVICE; + struct u2fdevice *dev; + + di = hid_enumerate (0, 0); + for (cur_dev = di; cur_dev; cur_dev = cur_dev->next) + { + int found = 0; + unsigned short usage_page = 0, usage = 0; + + /* check if we already opened this device */ + for (dev = devs->first; dev != NULL; dev = dev->next) + { + if (strcmp (dev->device_path, cur_dev->path) == 0) + { + if (ping_device (devs, dev->id) == U2FH_OK) + { + found = 1; + res = U2FH_OK; + } + else + { + if (debug) + { + fprintf (stderr, ""Device %s failed ping, dead.\n"", + dev->device_path); + } + close_device (devs, dev); + } + break; + } + } + if (found) + { + continue; + } + + get_usages (cur_dev, &usage_page, &usage); + if (usage_page == FIDO_USAGE_PAGE && usage == FIDO_USAGE_U2FHID) + { + dev = new_device (devs); + dev->devh = hid_open_path (cur_dev->path); + if (dev->devh != NULL) + { + dev->device_path = strdup (cur_dev->path); + if (dev->device_path == NULL) + { + close_device (devs, dev); + goto out; + } + if (init_device (devs, dev) == U2FH_OK) + { + if (cur_dev->product_string) + { + size_t len = + wcstombs (NULL, cur_dev->product_string, 0); + dev->device_string = malloc (len + 1); + if (dev->device_string == NULL) + { + close_device (devs, dev); + goto out; + } + memset (dev->device_string, 0, len + 1); + wcstombs (dev->device_string, cur_dev->product_string, + len); + if (debug) + { + fprintf (stderr, ""device %s discovered as '%s'\n"", + dev->device_path, dev->device_string); + fprintf (stderr, + "" version (Interface, Major, "" + ""Minor, Build): %d, %d, "" + ""%d, %d capFlags: %d\n"", + dev->versionInterface, + dev->versionMajor, + dev->versionMinor, + dev->versionBuild, dev->capFlags); + } + } + res = U2FH_OK; + continue; + } + } + close_device (devs, dev); + } + } + + + /* loop through all open devices and make sure we find them in the enumeration */ + dev = devs->first; + while (dev) + { + int found = 0; + + for (cur_dev = di; cur_dev; cur_dev = cur_dev->next) + { + if (strcmp (cur_dev->path, dev->device_path) == 0) + { + found = 1; + dev = dev->next; + break; + } + } + if (!found) + { + if (debug) + { + fprintf (stderr, ""device %s looks dead.\n"", dev->device_path); + } + dev = close_device (devs, dev); + } + } + +out: + hid_free_enumeration (di); + if (res == U2FH_OK && max_index) + *max_index = devs->max_id - 1; + + return res; +} +",0,"u2fh_devs_discover (u2fh_devs * devs, unsigned *max_index) +{ + struct hid_device_info *di, *cur_dev; + u2fh_rc res = U2FH_NO_U2F_DEVICE; + struct u2fdevice *dev; + + di = hid_enumerate (0, 0); + for (cur_dev = di; cur_dev; cur_dev = cur_dev->next) + { + int found = 0; + unsigned short usage_page = 0, usage = 0; + + /* check if we already opened this device */ + for (dev = devs->first; dev != NULL; dev = dev->next) + { + if (strcmp (dev->device_path, cur_dev->path) == 0) + { + if (ping_device (devs, dev->id) == U2FH_OK) + { + found = 1; + res = U2FH_OK; + } + else + { + if (debug) + { + fprintf (stderr, ""Device %s failed ping, dead.\n"", + dev->device_path); + } + close_device (devs, dev); + } + break; + } + } + if (found) + { + continue; + } + + get_usages (cur_dev, &usage_page, &usage); + if (usage_page == FIDO_USAGE_PAGE && usage == FIDO_USAGE_U2FHID) + { + dev = new_device (devs); + dev->devh = hid_open_path (cur_dev->path); + if (dev->devh != NULL) + { + dev->device_path = strdup (cur_dev->path); + if (dev->device_path == NULL) + { + close_device (devs, dev); + goto out; + } + if (init_device (devs, dev) == U2FH_OK) + { + if (cur_dev->product_string) + { + size_t len = + wcstombs (NULL, cur_dev->product_string, 0); + dev->device_string = malloc (len + 1); + if (dev->device_string == NULL) + { + close_device (devs, dev); + goto out; + } + memset (dev->device_string, 0, len + 1); + wcstombs (dev->device_string, cur_dev->product_string, + len); + if (debug) + { + fprintf (stderr, ""device %s discovered as '%s'\n"", + dev->device_path, dev->device_string); + fprintf (stderr, + "" version (Interface, Major, "" + ""Minor, Build): %d, %d, "" + ""%d, %d capFlags: %d\n"", + dev->versionInterface, + dev->versionMajor, + dev->versionMinor, + dev->versionBuild, dev->capFlags); + } + } + res = U2FH_OK; + continue; + } + } + close_device (devs, dev); + } + } + + + /* loop through all open devices and make sure we find them in the enumeration */ + dev = devs->first; + while (dev) + { + int found = 0; + + for (cur_dev = di; cur_dev; cur_dev = cur_dev->next) + { + if (strcmp (cur_dev->path, dev->device_path) == 0) + { + found = 1; + dev = dev->next; + break; + } + } + if (!found) + { + if (debug) + { + fprintf (stderr, ""device %s looks dead.\n"", dev->device_path); + } + dev = close_device (devs, dev); + } + } + +out: + hid_free_enumeration (di); + if (res == U2FH_OK && max_index) + *max_index = devs->max_id - 1; + + return res; +} +","@@ -302,17 +302,29 @@ init_device (u2fh_devs * devs, struct u2fdevice *dev) + (devs, dev->id, U2FHID_INIT, nonce, sizeof (nonce), resp, + &resplen) == U2FH_OK) + { +- U2FHID_INIT_RESP initresp; +- if (resplen > sizeof (initresp)) ++ int offs = sizeof (nonce); ++ /* the response has to be atleast 17 bytes, if it's more we discard that */ ++ if (resplen < 17) + { +- return U2FH_MEMORY_ERROR; ++ return U2FH_SIZE_ERROR; + } +- memcpy (&initresp, resp, resplen); +- dev->cid = initresp.cid; +- dev->versionInterface = initresp.versionInterface; +- dev->versionMajor = initresp.versionMajor; +- dev->versionMinor = initresp.versionMinor; +- dev->capFlags = initresp.capFlags; ++ ++ /* incoming and outgoing nonce has to match */ ++ if (memcmp (nonce, resp, sizeof (nonce)) != 0) ++ { ++ return U2FH_TRANSPORT_ERROR; ++ } ++ ++ dev->cid = ++ resp[offs] << 24 | resp[offs + 1] << 16 | resp[offs + ++ 2] << 8 | resp[offs + ++ 3]; ++ offs += 4; ++ dev->versionInterface = resp[offs++]; ++ dev->versionMajor = resp[offs++]; ++ dev->versionMinor = resp[offs++]; ++ dev->versionBuild = resp[offs++]; ++ dev->capFlags = resp[offs++]; + } + else + {",850,1086,2048 +18817,"void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) { + if (mSignalledError || mOutputPortSettingsChange != NONE) { + return; + } + + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + while (!inQueue.empty() && outQueue.size() == kNumOutputBuffers) { + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + if (inHeader == NULL) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + continue; + } + + PortInfo *port = editPortInfo(1); + + OMX_BUFFERHEADERTYPE *outHeader = + port->mBuffers.editItemAt(mNumSamplesOutput & 1).mHeader; + + if (inHeader->nFilledLen == 0) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + + ++mInputBufferCount; + + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + outHeader->nFilledLen = 0; + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + + List::iterator it = outQueue.begin(); + while ((*it)->mHeader != outHeader) { + ++it; + } + + BufferInfo *outInfo = *it; + outInfo->mOwnedByUs = false; + outQueue.erase(it); + outInfo = NULL; + + notifyFillBufferDone(outHeader); + outHeader = NULL; + } + return; + } + + uint8_t *bitstream = inHeader->pBuffer + inHeader->nOffset; + uint32_t *start_code = (uint32_t *)bitstream; + bool volHeader = *start_code == 0xB0010000; + if (volHeader) { + PVCleanUpVideoDecoder(mHandle); + mInitialized = false; + } + + if (!mInitialized) { + uint8_t *vol_data[1]; + int32_t vol_size = 0; + + vol_data[0] = NULL; + + if ((inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) || volHeader) { + vol_data[0] = bitstream; + vol_size = inHeader->nFilledLen; + } + + MP4DecodingMode mode = + (mMode == MODE_MPEG4) ? MPEG4_MODE : H263_MODE; + + Bool success = PVInitVideoDecoder( + mHandle, vol_data, &vol_size, 1, + outputBufferWidth(), outputBufferHeight(), mode); + + if (!success) { + ALOGW(""PVInitVideoDecoder failed. Unsupported content?""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + MP4DecodingMode actualMode = PVGetDecBitstreamMode(mHandle); + if (mode != actualMode) { + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + PVSetPostProcType((VideoDecControls *) mHandle, 0); + + bool hasFrameData = false; + if (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } else if (volHeader) { + hasFrameData = true; + } + + mInitialized = true; + + if (mode == MPEG4_MODE && handlePortSettingsChange()) { + return; + } + + if (!hasFrameData) { + continue; + } + } + + if (!mFramesConfigured) { + PortInfo *port = editPortInfo(1); + OMX_BUFFERHEADERTYPE *outHeader = port->mBuffers.editItemAt(1).mHeader; + + PVSetReferenceYUV(mHandle, outHeader->pBuffer); + + mFramesConfigured = true; + } + + uint32_t useExtTimestamp = (inHeader->nOffset == 0); + + uint32_t timestamp = 0xFFFFFFFF; + if (useExtTimestamp) { + mPvToOmxTimeMap.add(mPvTime, inHeader->nTimeStamp); + timestamp = mPvTime; + mPvTime++; + } + + + int32_t bufferSize = inHeader->nFilledLen; + int32_t tmp = bufferSize; + + if (PVDecodeVideoFrame( + mHandle, &bitstream, ×tamp, &tmp, + &useExtTimestamp, + outHeader->pBuffer) != PV_TRUE) { + ALOGE(""failed to decode video frame.""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + if (handlePortSettingsChange()) { + return; + } + + outHeader->nTimeStamp = mPvToOmxTimeMap.valueFor(timestamp); + mPvToOmxTimeMap.removeItem(timestamp); + + inHeader->nOffset += bufferSize; + inHeader->nFilledLen = 0; + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + } else { + outHeader->nFlags = 0; + } + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + + + ++mInputBufferCount; + + outHeader->nOffset = 0; + outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; + + List::iterator it = outQueue.begin(); + while ((*it)->mHeader != outHeader) { + ++it; + } + + BufferInfo *outInfo = *it; + outInfo->mOwnedByUs = false; + outQueue.erase(it); + outInfo = NULL; + + notifyFillBufferDone(outHeader); + outHeader = NULL; + + ++mNumSamplesOutput; + } +} +",1,"void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) { + if (mSignalledError || mOutputPortSettingsChange != NONE) { + return; + } + + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + while (!inQueue.empty() && outQueue.size() == kNumOutputBuffers) { + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + if (inHeader == NULL) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + continue; + } + + PortInfo *port = editPortInfo(1); + + OMX_BUFFERHEADERTYPE *outHeader = + port->mBuffers.editItemAt(mNumSamplesOutput & 1).mHeader; + + if (inHeader->nFilledLen == 0) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + + ++mInputBufferCount; + + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + outHeader->nFilledLen = 0; + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + + List::iterator it = outQueue.begin(); + while ((*it)->mHeader != outHeader) { + ++it; + } + + BufferInfo *outInfo = *it; + outInfo->mOwnedByUs = false; + outQueue.erase(it); + outInfo = NULL; + + notifyFillBufferDone(outHeader); + outHeader = NULL; + } + return; + } + + uint8_t *bitstream = inHeader->pBuffer + inHeader->nOffset; + uint32_t *start_code = (uint32_t *)bitstream; + bool volHeader = *start_code == 0xB0010000; + if (volHeader) { + PVCleanUpVideoDecoder(mHandle); + mInitialized = false; + } + + if (!mInitialized) { + uint8_t *vol_data[1]; + int32_t vol_size = 0; + + vol_data[0] = NULL; + + if ((inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) || volHeader) { + vol_data[0] = bitstream; + vol_size = inHeader->nFilledLen; + } + + MP4DecodingMode mode = + (mMode == MODE_MPEG4) ? MPEG4_MODE : H263_MODE; + + Bool success = PVInitVideoDecoder( + mHandle, vol_data, &vol_size, 1, + outputBufferWidth(), outputBufferHeight(), mode); + + if (!success) { + ALOGW(""PVInitVideoDecoder failed. Unsupported content?""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + MP4DecodingMode actualMode = PVGetDecBitstreamMode(mHandle); + if (mode != actualMode) { + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + PVSetPostProcType((VideoDecControls *) mHandle, 0); + + bool hasFrameData = false; + if (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } else if (volHeader) { + hasFrameData = true; + } + + mInitialized = true; + + if (mode == MPEG4_MODE && handlePortSettingsChange()) { + return; + } + + if (!hasFrameData) { + continue; + } + } + + if (!mFramesConfigured) { + PortInfo *port = editPortInfo(1); + OMX_BUFFERHEADERTYPE *outHeader = port->mBuffers.editItemAt(1).mHeader; + + PVSetReferenceYUV(mHandle, outHeader->pBuffer); + + mFramesConfigured = true; + } + + uint32_t useExtTimestamp = (inHeader->nOffset == 0); + + uint32_t timestamp = 0xFFFFFFFF; + if (useExtTimestamp) { + mPvToOmxTimeMap.add(mPvTime, inHeader->nTimeStamp); + timestamp = mPvTime; + mPvTime++; + } + + + int32_t bufferSize = inHeader->nFilledLen; + int32_t tmp = bufferSize; + + OMX_U32 frameSize = (mWidth * mHeight * 3) / 2; + if (outHeader->nAllocLen < frameSize) { + android_errorWriteLog(0x534e4554, ""27833616""); + ALOGE(""Insufficient output buffer size""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + if (PVDecodeVideoFrame( + mHandle, &bitstream, ×tamp, &tmp, + &useExtTimestamp, + outHeader->pBuffer) != PV_TRUE) { + ALOGE(""failed to decode video frame.""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + if (handlePortSettingsChange()) { + return; + } + + outHeader->nTimeStamp = mPvToOmxTimeMap.valueFor(timestamp); + mPvToOmxTimeMap.removeItem(timestamp); + + inHeader->nOffset += bufferSize; + inHeader->nFilledLen = 0; + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + } else { + outHeader->nFlags = 0; + } + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + + + ++mInputBufferCount; + + outHeader->nOffset = 0; + outHeader->nFilledLen = frameSize; + + List::iterator it = outQueue.begin(); + while ((*it)->mHeader != outHeader) { + ++it; + } + + BufferInfo *outInfo = *it; + outInfo->mOwnedByUs = false; + outQueue.erase(it); + outInfo = NULL; + + notifyFillBufferDone(outHeader); + outHeader = NULL; + + ++mNumSamplesOutput; + } +} +","@@ -229,6 +229,14 @@ + + int32_t bufferSize = inHeader->nFilledLen; + int32_t tmp = bufferSize; + ++ OMX_U32 frameSize = (mWidth * mHeight * 3) / 2; ++ if (outHeader->nAllocLen < frameSize) { ++ android_errorWriteLog(0x534e4554, ""27833616""); ++ ALOGE(""Insufficient output buffer size""); ++ notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); ++ mSignalledError = true; ++ return; ++ } + // The PV decoder is lying to us, sometimes it'll claim to only have + // consumed a subset of the buffer when it clearly consumed all of it. + // ignore whatever it says... +@@ -272,7 +280,7 @@ + + ++mInputBufferCount; + + outHeader->nOffset = 0; +- outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; ++ outHeader->nFilledLen = frameSize; + + List::iterator it = outQueue.begin(); + while ((*it)->mHeader != outHeader) { +",1307,1543,2048 +6341,"gssint_wrap_aead_iov_shim(gss_mechanism mech, + OM_uint32 *minor_status, + gss_ctx_id_t context_handle, + int conf_req_flag, + gss_qop_t qop_req, + gss_buffer_t input_assoc_buffer, + gss_buffer_t input_payload_buffer, + int *conf_state, + gss_buffer_t output_message_buffer) +{ + gss_iov_buffer_desc iov[5]; + OM_uint32 status; + size_t offset; + int i = 0, iov_count; + + /* HEADER | SIGN_ONLY_DATA | DATA | PADDING | TRAILER */ + + iov[i].type = GSS_IOV_BUFFER_TYPE_HEADER; + iov[i].buffer.value = NULL; + iov[i].buffer.length = 0; + i++; + + if (input_assoc_buffer != GSS_C_NO_BUFFER) { + iov[i].type = GSS_IOV_BUFFER_TYPE_SIGN_ONLY; + iov[i].buffer = *input_assoc_buffer; + i++; + } + + iov[i].type = GSS_IOV_BUFFER_TYPE_DATA; + iov[i].buffer = *input_payload_buffer; + i++; + + iov[i].type = GSS_IOV_BUFFER_TYPE_PADDING; + iov[i].buffer.value = NULL; + iov[i].buffer.length = 0; + i++; + + iov[i].type = GSS_IOV_BUFFER_TYPE_TRAILER; + iov[i].buffer.value = NULL; + iov[i].buffer.length = 0; + i++; + + iov_count = i; + + assert(mech->gss_wrap_iov_length); + + status = mech->gss_wrap_iov_length(minor_status, context_handle, + conf_req_flag, qop_req, + NULL, iov, iov_count); + if (status != GSS_S_COMPLETE) { + map_error(minor_status, mech); + return status; + } + + /* Format output token (does not include associated data) */ + for (i = 0, output_message_buffer->length = 0; i < iov_count; i++) { + if (GSS_IOV_BUFFER_TYPE(iov[i].type) == GSS_IOV_BUFFER_TYPE_SIGN_ONLY) + continue; + + output_message_buffer->length += iov[i].buffer.length; + } + + output_message_buffer->value = gssalloc_malloc(output_message_buffer->length); + if (output_message_buffer->value == NULL) { + *minor_status = ENOMEM; + return GSS_S_FAILURE; + } + + i = 0, offset = 0; + + /* HEADER */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + i++; + + /* SIGN_ONLY_DATA */ + if (input_assoc_buffer != GSS_C_NO_BUFFER) + i++; + + /* DATA */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + + memcpy(iov[i].buffer.value, input_payload_buffer->value, iov[i].buffer.length); + i++; + + /* PADDING */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + i++; + + /* TRAILER */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + i++; + + assert(offset == output_message_buffer->length); + + assert(mech->gss_wrap_iov); + + status = mech->gss_wrap_iov(minor_status, context_handle, + conf_req_flag, qop_req, + conf_state, iov, iov_count); + if (status != GSS_S_COMPLETE) { + OM_uint32 minor; + + map_error(minor_status, mech); + gss_release_buffer(&minor, output_message_buffer); + } + + return status; +} +",0,"gssint_wrap_aead_iov_shim(gss_mechanism mech, + OM_uint32 *minor_status, + gss_ctx_id_t context_handle, + int conf_req_flag, + gss_qop_t qop_req, + gss_buffer_t input_assoc_buffer, + gss_buffer_t input_payload_buffer, + int *conf_state, + gss_buffer_t output_message_buffer) +{ + gss_iov_buffer_desc iov[5]; + OM_uint32 status; + size_t offset; + int i = 0, iov_count; + + /* HEADER | SIGN_ONLY_DATA | DATA | PADDING | TRAILER */ + + iov[i].type = GSS_IOV_BUFFER_TYPE_HEADER; + iov[i].buffer.value = NULL; + iov[i].buffer.length = 0; + i++; + + if (input_assoc_buffer != GSS_C_NO_BUFFER) { + iov[i].type = GSS_IOV_BUFFER_TYPE_SIGN_ONLY; + iov[i].buffer = *input_assoc_buffer; + i++; + } + + iov[i].type = GSS_IOV_BUFFER_TYPE_DATA; + iov[i].buffer = *input_payload_buffer; + i++; + + iov[i].type = GSS_IOV_BUFFER_TYPE_PADDING; + iov[i].buffer.value = NULL; + iov[i].buffer.length = 0; + i++; + + iov[i].type = GSS_IOV_BUFFER_TYPE_TRAILER; + iov[i].buffer.value = NULL; + iov[i].buffer.length = 0; + i++; + + iov_count = i; + + assert(mech->gss_wrap_iov_length); + + status = mech->gss_wrap_iov_length(minor_status, context_handle, + conf_req_flag, qop_req, + NULL, iov, iov_count); + if (status != GSS_S_COMPLETE) { + map_error(minor_status, mech); + return status; + } + + /* Format output token (does not include associated data) */ + for (i = 0, output_message_buffer->length = 0; i < iov_count; i++) { + if (GSS_IOV_BUFFER_TYPE(iov[i].type) == GSS_IOV_BUFFER_TYPE_SIGN_ONLY) + continue; + + output_message_buffer->length += iov[i].buffer.length; + } + + output_message_buffer->value = gssalloc_malloc(output_message_buffer->length); + if (output_message_buffer->value == NULL) { + *minor_status = ENOMEM; + return GSS_S_FAILURE; + } + + i = 0, offset = 0; + + /* HEADER */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + i++; + + /* SIGN_ONLY_DATA */ + if (input_assoc_buffer != GSS_C_NO_BUFFER) + i++; + + /* DATA */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + + memcpy(iov[i].buffer.value, input_payload_buffer->value, iov[i].buffer.length); + i++; + + /* PADDING */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + i++; + + /* TRAILER */ + iov[i].buffer.value = (unsigned char *)output_message_buffer->value + offset; + offset += iov[i].buffer.length; + i++; + + assert(offset == output_message_buffer->length); + + assert(mech->gss_wrap_iov); + + status = mech->gss_wrap_iov(minor_status, context_handle, + conf_req_flag, qop_req, + conf_state, iov, iov_count); + if (status != GSS_S_COMPLETE) { + OM_uint32 minor; + + map_error(minor_status, mech); + gss_release_buffer(&minor, output_message_buffer); + } + + return status; +} +","@@ -256,6 +256,8 @@ gss_buffer_t output_message_buffer; + * call it. + */ + ctx = (gss_union_ctx_id_t)context_handle; ++ if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT) ++ return (GSS_S_NO_CONTEXT); + mech = gssint_get_mechanism (ctx->mech_type); + if (!mech) + return (GSS_S_BAD_MECH);",817,1053,2048 +15912,"void GLES2DecoderImpl::DoSwapBuffers(uint64_t swap_id, GLbitfield flags) { + bool is_offscreen = !!offscreen_target_frame_buffer_.get(); + + int this_frame_number = frame_number_++; + TRACE_EVENT_INSTANT2( + ""test_gpu"", ""SwapBuffersLatency"", TRACE_EVENT_SCOPE_THREAD, ""GLImpl"", + static_cast(gl::GetGLImplementation()), ""width"", + (is_offscreen ? offscreen_size_.width() : surface_->GetSize().width())); + TRACE_EVENT2(""gpu"", ""GLES2DecoderImpl::DoSwapBuffers"", + ""offscreen"", is_offscreen, + ""frame"", this_frame_number); + + ScopedGPUTrace scoped_gpu_trace(gpu_tracer_.get(), kTraceDecoder, + ""GLES2Decoder"", ""SwapBuffer""); + + bool is_tracing; + TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT(""gpu.debug""), + &is_tracing); + if (is_tracing) { + ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId()); + gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( + is_offscreen ? offscreen_size_ : surface_->GetSize()); + } + + ClearScheduleCALayerState(); + ClearScheduleDCLayerState(); + + if (is_offscreen) { + TRACE_EVENT2(""gpu"", ""Offscreen"", + ""width"", offscreen_size_.width(), ""height"", offscreen_size_.height()); + + if (offscreen_single_buffer_) + return; + + if (offscreen_size_ != offscreen_saved_color_texture_->size()) { + if (workarounds().needs_offscreen_buffer_workaround) { + offscreen_saved_frame_buffer_->Create(); + api()->glFinishFn(); + } + + ReleaseNotInUseBackTextures(); + + DCHECK(offscreen_saved_color_format_); + offscreen_saved_color_texture_->AllocateStorage( + offscreen_size_, offscreen_saved_color_format_, false); + + offscreen_saved_frame_buffer_->AttachRenderTexture( + offscreen_saved_color_texture_.get()); + if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { + if (offscreen_saved_frame_buffer_->CheckStatus() != + GL_FRAMEBUFFER_COMPLETE) { + LOG(ERROR) << ""GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "" + << ""because offscreen saved FBO was incomplete.""; + MarkContextLost(error::kUnknown); + group_->LoseContexts(error::kUnknown); + return; + } + + { + ScopedFramebufferBinder binder(this, + offscreen_saved_frame_buffer_->id()); + api()->glClearColorFn(0, 0, 0, BackBufferAlphaClearColor()); + state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); + ClearDeviceWindowRectangles(); + api()->glClearFn(GL_COLOR_BUFFER_BIT); + RestoreClearState(); + } + } + } + + if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) + return; + ScopedGLErrorSuppressor suppressor( + ""GLES2DecoderImpl::DoSwapBuffers"", GetErrorState()); + + if (IsOffscreenBufferMultisampled()) { + ScopedResolvedFramebufferBinder binder(this, true, false); + } else { + ScopedFramebufferBinder binder(this, + offscreen_target_frame_buffer_->id()); + + if (offscreen_target_buffer_preserved_) { + offscreen_saved_color_texture_->Copy(); + } else { + offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); + offscreen_target_frame_buffer_->AttachRenderTexture( + offscreen_target_color_texture_.get()); + offscreen_saved_frame_buffer_->AttachRenderTexture( + offscreen_saved_color_texture_.get()); + } + + if (!gl_version_info().is_angle) + api()->glFlushFn(); + } + } else if (supports_async_swap_) { + TRACE_EVENT_ASYNC_BEGIN0(""gpu"", ""AsyncSwapBuffers"", swap_id); + + client_->OnSwapBuffers(swap_id, flags); + surface_->SwapBuffersAsync( + base::Bind(&GLES2DecoderImpl::FinishAsyncSwapBuffers, + weak_ptr_factory_.GetWeakPtr(), swap_id), + base::DoNothing()); + } else { + client_->OnSwapBuffers(swap_id, flags); + FinishSwapBuffers(surface_->SwapBuffers(base::DoNothing())); + } + + ExitCommandProcessingEarly(); +} +",0,"void GLES2DecoderImpl::DoSwapBuffers(uint64_t swap_id, GLbitfield flags) { + bool is_offscreen = !!offscreen_target_frame_buffer_.get(); + + int this_frame_number = frame_number_++; + TRACE_EVENT_INSTANT2( + ""test_gpu"", ""SwapBuffersLatency"", TRACE_EVENT_SCOPE_THREAD, ""GLImpl"", + static_cast(gl::GetGLImplementation()), ""width"", + (is_offscreen ? offscreen_size_.width() : surface_->GetSize().width())); + TRACE_EVENT2(""gpu"", ""GLES2DecoderImpl::DoSwapBuffers"", + ""offscreen"", is_offscreen, + ""frame"", this_frame_number); + + ScopedGPUTrace scoped_gpu_trace(gpu_tracer_.get(), kTraceDecoder, + ""GLES2Decoder"", ""SwapBuffer""); + + bool is_tracing; + TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT(""gpu.debug""), + &is_tracing); + if (is_tracing) { + ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId()); + gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( + is_offscreen ? offscreen_size_ : surface_->GetSize()); + } + + ClearScheduleCALayerState(); + ClearScheduleDCLayerState(); + + if (is_offscreen) { + TRACE_EVENT2(""gpu"", ""Offscreen"", + ""width"", offscreen_size_.width(), ""height"", offscreen_size_.height()); + + if (offscreen_single_buffer_) + return; + + if (offscreen_size_ != offscreen_saved_color_texture_->size()) { + if (workarounds().needs_offscreen_buffer_workaround) { + offscreen_saved_frame_buffer_->Create(); + api()->glFinishFn(); + } + + ReleaseNotInUseBackTextures(); + + DCHECK(offscreen_saved_color_format_); + offscreen_saved_color_texture_->AllocateStorage( + offscreen_size_, offscreen_saved_color_format_, false); + + offscreen_saved_frame_buffer_->AttachRenderTexture( + offscreen_saved_color_texture_.get()); + if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { + if (offscreen_saved_frame_buffer_->CheckStatus() != + GL_FRAMEBUFFER_COMPLETE) { + LOG(ERROR) << ""GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "" + << ""because offscreen saved FBO was incomplete.""; + MarkContextLost(error::kUnknown); + group_->LoseContexts(error::kUnknown); + return; + } + + { + ScopedFramebufferBinder binder(this, + offscreen_saved_frame_buffer_->id()); + api()->glClearColorFn(0, 0, 0, BackBufferAlphaClearColor()); + state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); + ClearDeviceWindowRectangles(); + api()->glClearFn(GL_COLOR_BUFFER_BIT); + RestoreClearState(); + } + } + } + + if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) + return; + ScopedGLErrorSuppressor suppressor( + ""GLES2DecoderImpl::DoSwapBuffers"", GetErrorState()); + + if (IsOffscreenBufferMultisampled()) { + ScopedResolvedFramebufferBinder binder(this, true, false); + } else { + ScopedFramebufferBinder binder(this, + offscreen_target_frame_buffer_->id()); + + if (offscreen_target_buffer_preserved_) { + offscreen_saved_color_texture_->Copy(); + } else { + offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); + offscreen_target_frame_buffer_->AttachRenderTexture( + offscreen_target_color_texture_.get()); + offscreen_saved_frame_buffer_->AttachRenderTexture( + offscreen_saved_color_texture_.get()); + } + + if (!gl_version_info().is_angle) + api()->glFlushFn(); + } + } else if (supports_async_swap_) { + TRACE_EVENT_ASYNC_BEGIN0(""gpu"", ""AsyncSwapBuffers"", swap_id); + + client_->OnSwapBuffers(swap_id, flags); + surface_->SwapBuffersAsync( + base::Bind(&GLES2DecoderImpl::FinishAsyncSwapBuffers, + weak_ptr_factory_.GetWeakPtr(), swap_id), + base::DoNothing()); + } else { + client_->OnSwapBuffers(swap_id, flags); + FinishSwapBuffers(surface_->SwapBuffers(base::DoNothing())); + } + + ExitCommandProcessingEarly(); +} +","@@ -11384,29 +11384,24 @@ void GLES2DecoderImpl::GetTexParameterImpl( + return; + } + break; +- // Get the level information from the texture to avoid a Mac driver +- // bug where they store the levels in int16_t, making values bigger +- // than 2^15-1 overflow in the negative range. + case GL_TEXTURE_BASE_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->base_level()); +- } else { +- iparams[0] = texture->base_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_base_level()); ++ } else { ++ iparams[0] = texture->unclamped_base_level(); + } +- break; ++ return; + case GL_TEXTURE_MAX_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->max_level()); +- } else { +- iparams[0] = texture->max_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_max_level()); ++ } else { ++ iparams[0] = texture->unclamped_max_level(); + } +- break; ++ return; + case GL_TEXTURE_SWIZZLE_R: + if (fparams) { + fparams[0] = static_cast(texture->swizzle_r()); +@@ -17573,25 +17568,6 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + compatibility_internal_format = format_info->decompressed_internal_format; + } + +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); +- +- // TODO(zmo): We might need to emulate TexStorage using TexImage or +- // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying +- // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. +- if (dimension == ContextState::k2D) { +- api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, +- width, height); +- } else { +- api()->glTexStorage3DFn(target, levels, compatibility_internal_format, +- width, height, depth); +- } +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, +- texture->base_level()); +- + { + GLsizei level_width = width; + GLsizei level_height = height; +@@ -17620,6 +17596,29 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + texture->ApplyFormatWorkarounds(feature_info_.get()); + texture->SetImmutable(true); + } ++ ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); ++ ++ // TODO(zmo): We might need to emulate TexStorage using TexImage or ++ // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying ++ // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. ++ if (dimension == ContextState::k2D) { ++ api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, ++ width, height); ++ } else { ++ api()->glTexStorage3DFn(target, levels, compatibility_internal_format, ++ width, height, depth); ++ } ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) { ++ // Note base_level is already clamped due to texture->SetImmutable(true). ++ // This is necessary for certain NVidia Linux drivers; otherwise they ++ // may trigger segmentation fault. See https://crbug.com/877874. ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, ++ texture->base_level()); ++ } + } + + void GLES2DecoderImpl::DoTexStorage2DEXT(GLenum target,",934,1170,2048 +17982,"sd2_parse_rsrc_fork (SF_PRIVATE *psf) +{ SD2_RSRC rsrc ; + int k, marker, error = 0 ; + + psf_use_rsrc (psf, SF_TRUE) ; + + memset (&rsrc, 0, sizeof (rsrc)) ; + + rsrc.rsrc_len = psf_get_filelen (psf) ; + psf_log_printf (psf, ""Resource length : %d (0x%04X)\n"", rsrc.rsrc_len, rsrc.rsrc_len) ; + + if (rsrc.rsrc_len > SIGNED_SIZEOF (psf->header)) + { rsrc.rsrc_data = calloc (1, rsrc.rsrc_len) ; + rsrc.need_to_free_rsrc_data = SF_TRUE ; + } + else + { + rsrc.rsrc_data = psf->header ; + rsrc.need_to_free_rsrc_data = SF_FALSE ; + } ; + + /* Read in the whole lot. */ + psf_fread (rsrc.rsrc_data, rsrc.rsrc_len, 1, psf) ; + + /* Reset the header storage because we have changed to the rsrcdes. */ + psf->headindex = psf->headend = rsrc.rsrc_len ; + + rsrc.data_offset = read_rsrc_int (&rsrc, 0) ; + rsrc.map_offset = read_rsrc_int (&rsrc, 4) ; + rsrc.data_length = read_rsrc_int (&rsrc, 8) ; + rsrc.map_length = read_rsrc_int (&rsrc, 12) ; + + if (rsrc.data_offset == 0x51607 && rsrc.map_offset == 0x20000) + { psf_log_printf (psf, ""Trying offset of 0x52 bytes.\n"") ; + rsrc.data_offset = read_rsrc_int (&rsrc, 0x52 + 0) + 0x52 ; + rsrc.map_offset = read_rsrc_int (&rsrc, 0x52 + 4) + 0x52 ; + rsrc.data_length = read_rsrc_int (&rsrc, 0x52 + 8) ; + rsrc.map_length = read_rsrc_int (&rsrc, 0x52 + 12) ; + } ; + + psf_log_printf (psf, "" data offset : 0x%04X\n map offset : 0x%04X\n"" + "" data length : 0x%04X\n map length : 0x%04X\n"", + rsrc.data_offset, rsrc.map_offset, rsrc.data_length, rsrc.map_length) ; + + if (rsrc.data_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.data_offset (%d, 0x%x) > len\n"", rsrc.data_offset, rsrc.data_offset) ; + error = SFE_SD2_BAD_DATA_OFFSET ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.map_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.map_offset > len\n"") ; + error = SFE_SD2_BAD_MAP_OFFSET ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.data_length > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.data_length > len\n"") ; + error = SFE_SD2_BAD_DATA_LENGTH ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.map_length > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.map_length > len\n"") ; + error = SFE_SD2_BAD_MAP_LENGTH ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.data_offset + rsrc.data_length != rsrc.map_offset || rsrc.map_offset + rsrc.map_length != rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : This does not look like a MacOSX resource fork.\n"") ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.map_offset + 28 >= rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad map offset (%d + 28 > %d).\n"", rsrc.map_offset, rsrc.rsrc_len) ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.string_offset = rsrc.map_offset + read_rsrc_short (&rsrc, rsrc.map_offset + 26) ; + if (rsrc.string_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad string offset (%d).\n"", rsrc.string_offset) ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.type_offset = rsrc.map_offset + 30 ; + + rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ; + if (rsrc.type_count < 1) + { psf_log_printf (psf, ""Bad type count.\n"") ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.item_offset = rsrc.type_offset + rsrc.type_count * 8 ; + if (rsrc.item_offset < 0 || rsrc.item_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad item offset (%d).\n"", rsrc.item_offset) ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.str_index = -1 ; + for (k = 0 ; k < rsrc.type_count ; k ++) + { marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ; + + if (marker == STR_MARKER) + { rsrc.str_index = k ; + rsrc.str_count = read_rsrc_short (&rsrc, rsrc.type_offset + k * 8 + 4) + 1 ; + error = parse_str_rsrc (psf, &rsrc) ; + goto parse_rsrc_fork_cleanup ; + } ; + } ; + + psf_log_printf (psf, ""No 'STR ' resource.\n"") ; + error = SFE_SD2_BAD_RSRC ; + +parse_rsrc_fork_cleanup : + + psf_use_rsrc (psf, SF_FALSE) ; + + if (rsrc.need_to_free_rsrc_data) + free (rsrc.rsrc_data) ; + + return error ; +} /* sd2_parse_rsrc_fork */ +",1,"sd2_parse_rsrc_fork (SF_PRIVATE *psf) +{ SD2_RSRC rsrc ; + int k, marker, error = 0 ; + + psf_use_rsrc (psf, SF_TRUE) ; + + memset (&rsrc, 0, sizeof (rsrc)) ; + + rsrc.rsrc_len = psf_get_filelen (psf) ; + psf_log_printf (psf, ""Resource length : %d (0x%04X)\n"", rsrc.rsrc_len, rsrc.rsrc_len) ; + + if (rsrc.rsrc_len > SIGNED_SIZEOF (psf->header)) + { rsrc.rsrc_data = calloc (1, rsrc.rsrc_len) ; + rsrc.need_to_free_rsrc_data = SF_TRUE ; + } + else + { + rsrc.rsrc_data = psf->header ; + rsrc.need_to_free_rsrc_data = SF_FALSE ; + } ; + + /* Read in the whole lot. */ + psf_fread (rsrc.rsrc_data, rsrc.rsrc_len, 1, psf) ; + + /* Reset the header storage because we have changed to the rsrcdes. */ + psf->headindex = psf->headend = rsrc.rsrc_len ; + + rsrc.data_offset = read_rsrc_int (&rsrc, 0) ; + rsrc.map_offset = read_rsrc_int (&rsrc, 4) ; + rsrc.data_length = read_rsrc_int (&rsrc, 8) ; + rsrc.map_length = read_rsrc_int (&rsrc, 12) ; + + if (rsrc.data_offset == 0x51607 && rsrc.map_offset == 0x20000) + { psf_log_printf (psf, ""Trying offset of 0x52 bytes.\n"") ; + rsrc.data_offset = read_rsrc_int (&rsrc, 0x52 + 0) + 0x52 ; + rsrc.map_offset = read_rsrc_int (&rsrc, 0x52 + 4) + 0x52 ; + rsrc.data_length = read_rsrc_int (&rsrc, 0x52 + 8) ; + rsrc.map_length = read_rsrc_int (&rsrc, 0x52 + 12) ; + } ; + + psf_log_printf (psf, "" data offset : 0x%04X\n map offset : 0x%04X\n"" + "" data length : 0x%04X\n map length : 0x%04X\n"", + rsrc.data_offset, rsrc.map_offset, rsrc.data_length, rsrc.map_length) ; + + if (rsrc.data_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.data_offset (%d, 0x%x) > len\n"", rsrc.data_offset, rsrc.data_offset) ; + error = SFE_SD2_BAD_DATA_OFFSET ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.map_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.map_offset > len\n"") ; + error = SFE_SD2_BAD_MAP_OFFSET ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.data_length > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.data_length > len\n"") ; + error = SFE_SD2_BAD_DATA_LENGTH ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.map_length > rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : rsrc.map_length > len\n"") ; + error = SFE_SD2_BAD_MAP_LENGTH ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.data_offset + rsrc.data_length != rsrc.map_offset || rsrc.map_offset + rsrc.map_length != rsrc.rsrc_len) + { psf_log_printf (psf, ""Error : This does not look like a MacOSX resource fork.\n"") ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + if (rsrc.map_offset + 28 >= rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad map offset (%d + 28 > %d).\n"", rsrc.map_offset, rsrc.rsrc_len) ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.string_offset = rsrc.map_offset + read_rsrc_short (&rsrc, rsrc.map_offset + 26) ; + if (rsrc.string_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad string offset (%d).\n"", rsrc.string_offset) ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.type_offset = rsrc.map_offset + 30 ; + + if (rsrc.map_offset + 28 > rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad map offset.\n"") ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ; + if (rsrc.type_count < 1) + { psf_log_printf (psf, ""Bad type count.\n"") ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.item_offset = rsrc.type_offset + rsrc.type_count * 8 ; + if (rsrc.item_offset < 0 || rsrc.item_offset > rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad item offset (%d).\n"", rsrc.item_offset) ; + error = SFE_SD2_BAD_RSRC ; + goto parse_rsrc_fork_cleanup ; + } ; + + rsrc.str_index = -1 ; + for (k = 0 ; k < rsrc.type_count ; k ++) + { if (rsrc.type_offset + k * 8 > rsrc.rsrc_len) + { psf_log_printf (psf, ""Bad rsrc marker.\n"") ; + goto parse_rsrc_fork_cleanup ; + } ; + + marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ; + + if (marker == STR_MARKER) + { rsrc.str_index = k ; + rsrc.str_count = read_rsrc_short (&rsrc, rsrc.type_offset + k * 8 + 4) + 1 ; + error = parse_str_rsrc (psf, &rsrc) ; + goto parse_rsrc_fork_cleanup ; + } ; + } ; + + psf_log_printf (psf, ""No 'STR ' resource.\n"") ; + error = SFE_SD2_BAD_RSRC ; + +parse_rsrc_fork_cleanup : + + psf_use_rsrc (psf, SF_FALSE) ; + + if (rsrc.need_to_free_rsrc_data) + free (rsrc.rsrc_data) ; + + return error ; +} /* sd2_parse_rsrc_fork */ +","@@ -517,6 +517,11 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf) + + rsrc.type_offset = rsrc.map_offset + 30 ; + ++ if (rsrc.map_offset + 28 > rsrc.rsrc_len) ++ { psf_log_printf (psf, ""Bad map offset.\n"") ; ++ goto parse_rsrc_fork_cleanup ; ++ } ; ++ + rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ; + if (rsrc.type_count < 1) + { psf_log_printf (psf, ""Bad type count.\n"") ; +@@ -533,7 +538,12 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf) + + rsrc.str_index = -1 ; + for (k = 0 ; k < rsrc.type_count ; k ++) +- { marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ; ++ { if (rsrc.type_offset + k * 8 > rsrc.rsrc_len) ++ { psf_log_printf (psf, ""Bad rsrc marker.\n"") ; ++ goto parse_rsrc_fork_cleanup ; ++ } ; ++ ++ marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ; + + if (marker == STR_MARKER) + { rsrc.str_index = k ;",1501,1737,2048 +7034,"static int jpc_pi_nextrpcl(register jpc_pi_t *pi) +{ + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + int compno; + jpc_picomp_t *picomp; + int xstep; + int ystep; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + uint_fast32_t trx0; + uint_fast32_t try0; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->xstep = 0; + pi->ystep = 0; + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn + + picomp->numrlvls - rlvlno - 1)); + ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn + + picomp->numrlvls - rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; + } + + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend && + pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) { + for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += + pi->ystep - (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += + pi->xstep - (pi->x % pi->xstep)) { + for (pi->compno = pchg->compnostart, + pi->picomp = &pi->picomps[pi->compno]; + pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < + pi->numcomps; ++pi->compno, ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) + || !(pi->x % (1 << rpx))) && + ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) + || !(pi->y % (1 << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp + << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, + pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp + << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, + pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < + pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } +skip: + ; + } + } + } + } + } + } + return 1; +} +",0,"static int jpc_pi_nextrpcl(register jpc_pi_t *pi) +{ + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + int compno; + jpc_picomp_t *picomp; + int xstep; + int ystep; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + uint_fast32_t trx0; + uint_fast32_t try0; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->xstep = 0; + pi->ystep = 0; + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn + + picomp->numrlvls - rlvlno - 1)); + ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn + + picomp->numrlvls - rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; + } + + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend && + pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) { + for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += + pi->ystep - (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += + pi->xstep - (pi->x % pi->xstep)) { + for (pi->compno = pchg->compnostart, + pi->picomp = &pi->picomps[pi->compno]; + pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < + pi->numcomps; ++pi->compno, ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) + || !(pi->x % (1 << rpx))) && + ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) + || !(pi->y % (1 << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp + << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, + pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp + << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, + pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < + pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } +skip: + ; + } + } + } + } + } + } + return 1; +} +","@@ -432,18 +432,18 @@ static int jpc_pi_nextcprl(register jpc_pi_t *pi) + &pi->picomps[pi->compno]; pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++pi->compno, + ++pi->picomp) { + pirlvl = pi->picomp->pirlvls; +- pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn + +- pi->picomp->numrlvls - 1)); +- pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn + +- pi->picomp->numrlvls - 1)); ++ pi->xstep = pi->picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) << ++ (pirlvl->prcwidthexpn + pi->picomp->numrlvls - 1)); ++ pi->ystep = pi->picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) << ++ (pirlvl->prcheightexpn + pi->picomp->numrlvls - 1)); + for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1]; + rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) { +- pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 << +- (pirlvl->prcwidthexpn + pi->picomp->numrlvls - +- rlvlno - 1))); +- pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 << +- (pirlvl->prcheightexpn + pi->picomp->numrlvls - +- rlvlno - 1))); ++ pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * ++ (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcwidthexpn + ++ pi->picomp->numrlvls - rlvlno - 1))); ++ pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * ++ (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcheightexpn + ++ pi->picomp->numrlvls - rlvlno - 1))); + } + for (pi->y = pi->ystart; pi->y < pi->yend; + pi->y += pi->ystep - (pi->y % pi->ystep)) {",1206,1442,2048 +7198,"pubkey_prepare(Authctxt *authctxt) +{ + struct identity *id, *id2, *tmp; + struct idlist agent, files, *preferred; + struct sshkey *key; + int agent_fd = -1, i, r, found; + size_t j; + struct ssh_identitylist *idlist; + + TAILQ_INIT(&agent); /* keys from the agent */ + TAILQ_INIT(&files); /* keys from the config file */ + preferred = &authctxt->keys; + TAILQ_INIT(preferred); /* preferred order of keys */ + + /* list of keys stored in the filesystem and PKCS#11 */ + for (i = 0; i < options.num_identity_files; i++) { + key = options.identity_keys[i]; + if (key && key->type == KEY_RSA1) + continue; + if (key && key->cert && key->cert->type != SSH2_CERT_TYPE_USER) + continue; + options.identity_keys[i] = NULL; + id = xcalloc(1, sizeof(*id)); + id->agent_fd = -1; + id->key = key; + id->filename = xstrdup(options.identity_files[i]); + id->userprovided = options.identity_file_userprovided[i]; + TAILQ_INSERT_TAIL(&files, id, next); + } + /* list of certificates specified by user */ + for (i = 0; i < options.num_certificate_files; i++) { + key = options.certificates[i]; + if (!key_is_cert(key) || key->cert == NULL || + key->cert->type != SSH2_CERT_TYPE_USER) + continue; + id = xcalloc(1, sizeof(*id)); + id->agent_fd = -1; + id->key = key; + id->filename = xstrdup(options.certificate_files[i]); + id->userprovided = options.certificate_file_userprovided[i]; + TAILQ_INSERT_TAIL(preferred, id, next); + } + /* list of keys supported by the agent */ + if ((r = ssh_get_authentication_socket(&agent_fd)) != 0) { + if (r != SSH_ERR_AGENT_NOT_PRESENT) + debug(""%s: ssh_get_authentication_socket: %s"", + __func__, ssh_err(r)); + } else if ((r = ssh_fetch_identitylist(agent_fd, 2, &idlist)) != 0) { + if (r != SSH_ERR_AGENT_NO_IDENTITIES) + debug(""%s: ssh_fetch_identitylist: %s"", + __func__, ssh_err(r)); + close(agent_fd); + } else { + for (j = 0; j < idlist->nkeys; j++) { + found = 0; + TAILQ_FOREACH(id, &files, next) { + /* + * agent keys from the config file are + * preferred + */ + if (sshkey_equal(idlist->keys[j], id->key)) { + TAILQ_REMOVE(&files, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + id->agent_fd = agent_fd; + found = 1; + break; + } + } + if (!found && !options.identities_only) { + id = xcalloc(1, sizeof(*id)); + /* XXX ""steals"" key/comment from idlist */ + id->key = idlist->keys[j]; + id->filename = idlist->comments[j]; + idlist->keys[j] = NULL; + idlist->comments[j] = NULL; + id->agent_fd = agent_fd; + TAILQ_INSERT_TAIL(&agent, id, next); + } + } + ssh_free_identitylist(idlist); + /* append remaining agent keys */ + for (id = TAILQ_FIRST(&agent); id; id = TAILQ_FIRST(&agent)) { + TAILQ_REMOVE(&agent, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + } + authctxt->agent_fd = agent_fd; + } + /* Prefer PKCS11 keys that are explicitly listed */ + TAILQ_FOREACH_SAFE(id, &files, next, tmp) { + if (id->key == NULL || (id->key->flags & SSHKEY_FLAG_EXT) == 0) + continue; + found = 0; + TAILQ_FOREACH(id2, &files, next) { + if (id2->key == NULL || + (id2->key->flags & SSHKEY_FLAG_EXT) == 0) + continue; + if (sshkey_equal(id->key, id2->key)) { + TAILQ_REMOVE(&files, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + found = 1; + break; + } + } + /* If IdentitiesOnly set and key not found then don't use it */ + if (!found && options.identities_only) { + TAILQ_REMOVE(&files, id, next); + explicit_bzero(id, sizeof(*id)); + free(id); + } + } + /* append remaining keys from the config file */ + for (id = TAILQ_FIRST(&files); id; id = TAILQ_FIRST(&files)) { + TAILQ_REMOVE(&files, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + } + /* finally, filter by PubkeyAcceptedKeyTypes */ + TAILQ_FOREACH_SAFE(id, preferred, next, id2) { + if (id->key != NULL && + match_pattern_list(sshkey_ssh_name(id->key), + options.pubkey_key_types, 0) != 1) { + debug(""Skipping %s key %s - "" + ""not in PubkeyAcceptedKeyTypes"", + sshkey_ssh_name(id->key), id->filename); + TAILQ_REMOVE(preferred, id, next); + sshkey_free(id->key); + free(id->filename); + memset(id, 0, sizeof(*id)); + continue; + } + debug2(""key: %s (%p)%s%s"", id->filename, id->key, + id->userprovided ? "", explicit"" : """", + id->agent_fd != -1 ? "", agent"" : """"); + } +} +",0,"pubkey_prepare(Authctxt *authctxt) +{ + struct identity *id, *id2, *tmp; + struct idlist agent, files, *preferred; + struct sshkey *key; + int agent_fd = -1, i, r, found; + size_t j; + struct ssh_identitylist *idlist; + + TAILQ_INIT(&agent); /* keys from the agent */ + TAILQ_INIT(&files); /* keys from the config file */ + preferred = &authctxt->keys; + TAILQ_INIT(preferred); /* preferred order of keys */ + + /* list of keys stored in the filesystem and PKCS#11 */ + for (i = 0; i < options.num_identity_files; i++) { + key = options.identity_keys[i]; + if (key && key->type == KEY_RSA1) + continue; + if (key && key->cert && key->cert->type != SSH2_CERT_TYPE_USER) + continue; + options.identity_keys[i] = NULL; + id = xcalloc(1, sizeof(*id)); + id->agent_fd = -1; + id->key = key; + id->filename = xstrdup(options.identity_files[i]); + id->userprovided = options.identity_file_userprovided[i]; + TAILQ_INSERT_TAIL(&files, id, next); + } + /* list of certificates specified by user */ + for (i = 0; i < options.num_certificate_files; i++) { + key = options.certificates[i]; + if (!key_is_cert(key) || key->cert == NULL || + key->cert->type != SSH2_CERT_TYPE_USER) + continue; + id = xcalloc(1, sizeof(*id)); + id->agent_fd = -1; + id->key = key; + id->filename = xstrdup(options.certificate_files[i]); + id->userprovided = options.certificate_file_userprovided[i]; + TAILQ_INSERT_TAIL(preferred, id, next); + } + /* list of keys supported by the agent */ + if ((r = ssh_get_authentication_socket(&agent_fd)) != 0) { + if (r != SSH_ERR_AGENT_NOT_PRESENT) + debug(""%s: ssh_get_authentication_socket: %s"", + __func__, ssh_err(r)); + } else if ((r = ssh_fetch_identitylist(agent_fd, 2, &idlist)) != 0) { + if (r != SSH_ERR_AGENT_NO_IDENTITIES) + debug(""%s: ssh_fetch_identitylist: %s"", + __func__, ssh_err(r)); + close(agent_fd); + } else { + for (j = 0; j < idlist->nkeys; j++) { + found = 0; + TAILQ_FOREACH(id, &files, next) { + /* + * agent keys from the config file are + * preferred + */ + if (sshkey_equal(idlist->keys[j], id->key)) { + TAILQ_REMOVE(&files, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + id->agent_fd = agent_fd; + found = 1; + break; + } + } + if (!found && !options.identities_only) { + id = xcalloc(1, sizeof(*id)); + /* XXX ""steals"" key/comment from idlist */ + id->key = idlist->keys[j]; + id->filename = idlist->comments[j]; + idlist->keys[j] = NULL; + idlist->comments[j] = NULL; + id->agent_fd = agent_fd; + TAILQ_INSERT_TAIL(&agent, id, next); + } + } + ssh_free_identitylist(idlist); + /* append remaining agent keys */ + for (id = TAILQ_FIRST(&agent); id; id = TAILQ_FIRST(&agent)) { + TAILQ_REMOVE(&agent, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + } + authctxt->agent_fd = agent_fd; + } + /* Prefer PKCS11 keys that are explicitly listed */ + TAILQ_FOREACH_SAFE(id, &files, next, tmp) { + if (id->key == NULL || (id->key->flags & SSHKEY_FLAG_EXT) == 0) + continue; + found = 0; + TAILQ_FOREACH(id2, &files, next) { + if (id2->key == NULL || + (id2->key->flags & SSHKEY_FLAG_EXT) == 0) + continue; + if (sshkey_equal(id->key, id2->key)) { + TAILQ_REMOVE(&files, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + found = 1; + break; + } + } + /* If IdentitiesOnly set and key not found then don't use it */ + if (!found && options.identities_only) { + TAILQ_REMOVE(&files, id, next); + explicit_bzero(id, sizeof(*id)); + free(id); + } + } + /* append remaining keys from the config file */ + for (id = TAILQ_FIRST(&files); id; id = TAILQ_FIRST(&files)) { + TAILQ_REMOVE(&files, id, next); + TAILQ_INSERT_TAIL(preferred, id, next); + } + /* finally, filter by PubkeyAcceptedKeyTypes */ + TAILQ_FOREACH_SAFE(id, preferred, next, id2) { + if (id->key != NULL && + match_pattern_list(sshkey_ssh_name(id->key), + options.pubkey_key_types, 0) != 1) { + debug(""Skipping %s key %s - "" + ""not in PubkeyAcceptedKeyTypes"", + sshkey_ssh_name(id->key), id->filename); + TAILQ_REMOVE(preferred, id, next); + sshkey_free(id->key); + free(id->filename); + memset(id, 0, sizeof(*id)); + continue; + } + debug2(""key: %s (%p)%s%s"", id->filename, id->key, + id->userprovided ? "", explicit"" : """", + id->agent_fd != -1 ? "", agent"" : """"); + } +} +","@@ -1,4 +1,4 @@ +-/* $OpenBSD: sshconnect2.c,v 1.248 2016/09/22 02:29:57 dtucker Exp $ */ ++/* $OpenBSD: sshconnect2.c,v 1.249 2016/09/28 16:33:07 djm Exp $ */ + /* + * Copyright (c) 2000 Markus Friedl. All rights reserved. + * Copyright (c) 2008 Damien Miller. All rights reserved. +@@ -168,7 +168,7 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port) + compat_cipher_proposal(options.ciphers); + myproposal[PROPOSAL_COMP_ALGS_CTOS] = + myproposal[PROPOSAL_COMP_ALGS_STOC] = options.compression ? +- ""zlib@openssh.com,zlib,none"" : ""none,zlib@openssh.com,zlib""; ++ ""zlib@openssh.com,none"" : ""none,zlib@openssh.com""; + myproposal[PROPOSAL_MAC_ALGS_CTOS] = + myproposal[PROPOSAL_MAC_ALGS_STOC] = options.macs; + if (options.hostkeyalgorithms != NULL) {",1331,1567,2048 +18790,"void btm_sec_pin_code_request (UINT8 *p_bda) +{ + + tBTM_SEC_DEV_REC *p_dev_rec; + tBTM_CB *p_cb = &btm_cb; + +#ifdef PORCHE_PAIRING_CONFLICT + UINT8 default_pin_code_len = 4; + PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30}; +#endif + BTM_TRACE_EVENT (""btm_sec_pin_code_request() State: %s, BDA:%04x%08x"", + btm_pair_state_descr(btm_cb.pairing_state), + (p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] ); + + if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) + { + + if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) && + (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) ) + { + /* fake this out - porshe carkit issue - */ + if(! btm_cb.pin_code_len_saved) + { + btsnd_hcic_pin_code_neg_reply (p_bda); + return; + } + else + { + btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code); + return; + } + } + else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) + || memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) + { + + BTM_TRACE_WARNING (""btm_sec_pin_code_request() rejected - state: %s"", + btm_pair_state_descr(btm_cb.pairing_state)); + +#ifdef PORCHE_PAIRING_CONFLICT + /* reply pin code again due to counter in_rand when local initiates pairing */ + BTM_TRACE_EVENT (""btm_sec_pin_code_request from remote dev. for local initiated pairing""); + if(! btm_cb.pin_code_len_saved) + { + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + btsnd_hcic_pin_code_req_reply (p_bda, default_pin_code_len, default_pin_code); + } + else + { + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code); + } +#else + btsnd_hcic_pin_code_neg_reply (p_bda); +#endif + return; + } + } + + p_dev_rec = btm_find_or_alloc_dev (p_bda); + /* received PIN code request. must be non-sm4 */ + p_dev_rec->sm4 = BTM_SM4_KNOWN; + + if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) + { + memcpy (btm_cb.pairing_bda, p_bda, BD_ADDR_LEN); + + btm_cb.pairing_flags = BTM_PAIR_FLAGS_PEER_STARTED_DD; + /* Make sure we reset the trusted mask to help against attacks */ + BTM_SEC_CLR_TRUSTED_DEVICE(p_dev_rec->trusted_mask); + } + + if (!p_cb->pairing_disabled && (p_cb->cfg.pin_type == HCI_PIN_TYPE_FIXED)) + { + BTM_TRACE_EVENT (""btm_sec_pin_code_request fixed pin replying""); + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + btsnd_hcic_pin_code_req_reply (p_bda, p_cb->cfg.pin_code_len, p_cb->cfg.pin_code); + return; + } + + /* Use the connecting device's CoD for the connection */ + if ( (!memcmp (p_bda, p_cb->connecting_bda, BD_ADDR_LEN)) + && (p_cb->connecting_dc[0] || p_cb->connecting_dc[1] || p_cb->connecting_dc[2]) ) + memcpy (p_dev_rec->dev_class, p_cb->connecting_dc, DEV_CLASS_LEN); + + /* We could have started connection after asking user for the PIN code */ + if (btm_cb.pin_code_len != 0) + { + + BTM_TRACE_EVENT (""btm_sec_pin_code_request bonding sending reply""); + btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len, p_cb->pin_code); + +#ifdef PORCHE_PAIRING_CONFLICT + btm_cb.pin_code_len_saved = btm_cb.pin_code_len; +#endif + /* Mark that we forwarded received from the user PIN code */ + btm_cb.pin_code_len = 0; + + /* We can change mode back right away, that other connection being established */ + /* is not forced to be secure - found a FW issue, so we can not do this + btm_restore_mode(); */ + + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + } + + /* If pairing disabled OR (no PIN callback and not bonding) */ + /* OR we could not allocate entry in the database reject pairing request */ + else if (p_cb->pairing_disabled + || (p_cb->api.p_pin_callback == NULL) + + /* OR Microsoft keyboard can for some reason try to establish connection */ + /* the only thing we can do here is to shut it up. Normally we will be originator */ + /* for keyboard bonding */ + || (!p_dev_rec->is_originator + && ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == BTM_COD_MAJOR_PERIPHERAL) + && (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD)) ) + { + BTM_TRACE_WARNING(""btm_sec_pin_code_request(): Pairing disabled:%d; PIN callback:%x, Dev Rec:%x!"", + p_cb->pairing_disabled, p_cb->api.p_pin_callback, p_dev_rec); + + btsnd_hcic_pin_code_neg_reply (p_bda); + } + + /* Notify upper layer of PIN request and start expiration timer */ + else + { + btm_cb.pin_code_len_saved = 0; + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); + /* Pin code request can not come at the same time as connection request */ + memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN); + memcpy (p_cb->connecting_dc, p_dev_rec->dev_class, DEV_CLASS_LEN); + + /* Check if the name is known */ + /* Even if name is not known we might not be able to get one */ + /* this is the case when we are already getting something from the */ + /* device, so HCI level is flow controlled */ + /* Also cannot send remote name request while paging, i.e. connection is not completed */ + if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) + { + BTM_TRACE_EVENT (""btm_sec_pin_code_request going for callback""); + + btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; + if (p_cb->api.p_pin_callback) + (*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name); + } + else + { + BTM_TRACE_EVENT (""btm_sec_pin_code_request going for remote name""); + + /* We received PIN code request for the device with unknown name */ + /* it is not user friendly just to ask for the PIN without name */ + /* try to get name at first */ + if (!btsnd_hcic_rmt_name_req (p_dev_rec->bd_addr, + HCI_PAGE_SCAN_REP_MODE_R1, + HCI_MANDATARY_PAGE_SCAN_MODE, 0)) + { + p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; + p_dev_rec->sec_bd_name[0] = 'f'; + p_dev_rec->sec_bd_name[1] = '0'; + BTM_TRACE_ERROR (""can not send rmt_name_req?? fake a name and call callback""); + + btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; + if (p_cb->api.p_pin_callback) + (*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name); + } + } + } + + return; +} +",1,"void btm_sec_pin_code_request (UINT8 *p_bda) +{ + + tBTM_SEC_DEV_REC *p_dev_rec; + tBTM_CB *p_cb = &btm_cb; + + BTM_TRACE_EVENT (""btm_sec_pin_code_request() State: %s, BDA:%04x%08x"", + btm_pair_state_descr(btm_cb.pairing_state), + (p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] ); + + if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) + { + + if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) && + (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) ) + { + btsnd_hcic_pin_code_neg_reply (p_bda); + return; + } + else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) + || memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) + { + + BTM_TRACE_WARNING (""btm_sec_pin_code_request() rejected - state: %s"", + btm_pair_state_descr(btm_cb.pairing_state)); + + btsnd_hcic_pin_code_neg_reply (p_bda); + return; + } + } + + p_dev_rec = btm_find_or_alloc_dev (p_bda); + /* received PIN code request. must be non-sm4 */ + p_dev_rec->sm4 = BTM_SM4_KNOWN; + + if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) + { + memcpy (btm_cb.pairing_bda, p_bda, BD_ADDR_LEN); + + btm_cb.pairing_flags = BTM_PAIR_FLAGS_PEER_STARTED_DD; + /* Make sure we reset the trusted mask to help against attacks */ + BTM_SEC_CLR_TRUSTED_DEVICE(p_dev_rec->trusted_mask); + } + + if (!p_cb->pairing_disabled && (p_cb->cfg.pin_type == HCI_PIN_TYPE_FIXED)) + { + BTM_TRACE_EVENT (""btm_sec_pin_code_request fixed pin replying""); + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + btsnd_hcic_pin_code_req_reply (p_bda, p_cb->cfg.pin_code_len, p_cb->cfg.pin_code); + return; + } + + /* Use the connecting device's CoD for the connection */ + if ( (!memcmp (p_bda, p_cb->connecting_bda, BD_ADDR_LEN)) + && (p_cb->connecting_dc[0] || p_cb->connecting_dc[1] || p_cb->connecting_dc[2]) ) + memcpy (p_dev_rec->dev_class, p_cb->connecting_dc, DEV_CLASS_LEN); + + /* We could have started connection after asking user for the PIN code */ + if (btm_cb.pin_code_len != 0) + { + + BTM_TRACE_EVENT (""btm_sec_pin_code_request bonding sending reply""); + btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len, p_cb->pin_code); + + /* Mark that we forwarded received from the user PIN code */ + btm_cb.pin_code_len = 0; + + /* We can change mode back right away, that other connection being established */ + /* is not forced to be secure - found a FW issue, so we can not do this + btm_restore_mode(); */ + + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + } + + /* If pairing disabled OR (no PIN callback and not bonding) */ + /* OR we could not allocate entry in the database reject pairing request */ + else if (p_cb->pairing_disabled + || (p_cb->api.p_pin_callback == NULL) + + /* OR Microsoft keyboard can for some reason try to establish connection */ + /* the only thing we can do here is to shut it up. Normally we will be originator */ + /* for keyboard bonding */ + || (!p_dev_rec->is_originator + && ((p_dev_rec->dev_class[1] & BTM_COD_MAJOR_CLASS_MASK) == BTM_COD_MAJOR_PERIPHERAL) + && (p_dev_rec->dev_class[2] & BTM_COD_MINOR_KEYBOARD)) ) + { + BTM_TRACE_WARNING(""btm_sec_pin_code_request(): Pairing disabled:%d; PIN callback:%x, Dev Rec:%x!"", + p_cb->pairing_disabled, p_cb->api.p_pin_callback, p_dev_rec); + + btsnd_hcic_pin_code_neg_reply (p_bda); + } + + /* Notify upper layer of PIN request and start expiration timer */ + else + { + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); + /* Pin code request can not come at the same time as connection request */ + memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN); + memcpy (p_cb->connecting_dc, p_dev_rec->dev_class, DEV_CLASS_LEN); + + /* Check if the name is known */ + /* Even if name is not known we might not be able to get one */ + /* this is the case when we are already getting something from the */ + /* device, so HCI level is flow controlled */ + /* Also cannot send remote name request while paging, i.e. connection is not completed */ + if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) + { + BTM_TRACE_EVENT (""btm_sec_pin_code_request going for callback""); + + btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; + if (p_cb->api.p_pin_callback) + (*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name); + } + else + { + BTM_TRACE_EVENT (""btm_sec_pin_code_request going for remote name""); + + /* We received PIN code request for the device with unknown name */ + /* it is not user friendly just to ask for the PIN without name */ + /* try to get name at first */ + if (!btsnd_hcic_rmt_name_req (p_dev_rec->bd_addr, + HCI_PAGE_SCAN_REP_MODE_R1, + HCI_MANDATARY_PAGE_SCAN_MODE, 0)) + { + p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; + p_dev_rec->sec_bd_name[0] = 'f'; + p_dev_rec->sec_bd_name[1] = '0'; + BTM_TRACE_ERROR (""can not send rmt_name_req?? fake a name and call callback""); + + btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; + if (p_cb->api.p_pin_callback) + (*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name); + } + } + } + + return; +} +","@@ -1074,13 +1074,6 @@ + + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + btm_cb.acl_disc_reason = HCI_SUCCESS; + +-#ifdef PORCHE_PAIRING_CONFLICT +- BTM_TRACE_EVENT(""BTM_PINCodeReply(): Saving pin_len: %d btm_cb.pin_code_len: %d"", pin_len, btm_cb.pin_code_len); +- /* if this was not pre-fetched, save the PIN */ +- if (btm_cb.pin_code_len == 0) +- memcpy (btm_cb.pin_code, p_pin, pin_len); +- btm_cb.pin_code_len_saved = pin_len; +-#endif + btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin); + } + +@@ -5057,10 +5050,6 @@ + + tBTM_SEC_DEV_REC *p_dev_rec; + tBTM_CB *p_cb = &btm_cb; + +-#ifdef PORCHE_PAIRING_CONFLICT +- UINT8 default_pin_code_len = 4; +- PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30}; +-#endif + BTM_TRACE_EVENT (""btm_sec_pin_code_request() State: %s, BDA:%04x%08x"", + btm_pair_state_descr(btm_cb.pairing_state), + (p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] ); +@@ -5070,18 +5059,8 @@ + + if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) && + (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) ) + { +- /* fake this out - porshe carkit issue - */ +-// btm_cb.pairing_state = BTM_PAIR_STATE_IDLE; +- if(! btm_cb.pin_code_len_saved) +- { +- btsnd_hcic_pin_code_neg_reply (p_bda); +- return; +- } +- else +- { +- btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code); +- return; +- } ++ btsnd_hcic_pin_code_neg_reply (p_bda); ++ return; + } + else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) + || memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) +@@ -5089,22 +5068,7 @@ + + BTM_TRACE_WARNING (""btm_sec_pin_code_request() rejected - state: %s"", + btm_pair_state_descr(btm_cb.pairing_state)); + +-#ifdef PORCHE_PAIRING_CONFLICT +- /* reply pin code again due to counter in_rand when local initiates pairing */ +- BTM_TRACE_EVENT (""btm_sec_pin_code_request from remote dev. for local initiated pairing""); +- if(! btm_cb.pin_code_len_saved) +- { +- btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); +- btsnd_hcic_pin_code_req_reply (p_bda, default_pin_code_len, default_pin_code); +- } +- else +- { +- btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); +- btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code); +- } +-#else + btsnd_hcic_pin_code_neg_reply (p_bda); +-#endif + return; + } + } +@@ -5141,10 +5105,6 @@ + + BTM_TRACE_EVENT (""btm_sec_pin_code_request bonding sending reply""); + btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len, p_cb->pin_code); + +-#ifdef PORCHE_PAIRING_CONFLICT +- btm_cb.pin_code_len_saved = btm_cb.pin_code_len; +-#endif +- + /* Mark that we forwarded received from the user PIN code */ + btm_cb.pin_code_len = 0; + +@@ -5175,7 +5135,6 @@ + + /* Notify upper layer of PIN request and start expiration timer */ + else + { +- btm_cb.pin_code_len_saved = 0; + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); + /* Pin code request can not come at the same time as connection request */ + memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN); +",1790,2026,2048 +4949,"brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) +{ + struct brcmf_if *ifp = netdev_priv(ndev); + s32 val; + s32 err; + const struct brcmf_tlv *rsn_ie; + const u8 *ie; + u32 ie_len; + u32 offset; + u16 rsn_cap; + u32 mfp; + u16 count; + + if (!sme->crypto.n_akm_suites) + return 0; + + err = brcmf_fil_bsscfg_int_get(netdev_priv(ndev), ""wpa_auth"", &val); + if (err) { + brcmf_err(""could not get wpa_auth (%d)\n"", err); + return err; + } + if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) { + switch (sme->crypto.akm_suites[0]) { + case WLAN_AKM_SUITE_8021X: + val = WPA_AUTH_UNSPECIFIED; + break; + case WLAN_AKM_SUITE_PSK: + val = WPA_AUTH_PSK; + break; + default: + brcmf_err(""invalid cipher group (%d)\n"", + sme->crypto.cipher_group); + return -EINVAL; + } + } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) { + switch (sme->crypto.akm_suites[0]) { + case WLAN_AKM_SUITE_8021X: + val = WPA2_AUTH_UNSPECIFIED; + break; + case WLAN_AKM_SUITE_8021X_SHA256: + val = WPA2_AUTH_1X_SHA256; + break; + case WLAN_AKM_SUITE_PSK_SHA256: + val = WPA2_AUTH_PSK_SHA256; + break; + case WLAN_AKM_SUITE_PSK: + val = WPA2_AUTH_PSK; + break; + default: + brcmf_err(""invalid cipher group (%d)\n"", + sme->crypto.cipher_group); + return -EINVAL; + } + } + + if (!brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MFP)) + goto skip_mfp_config; + /* The MFP mode (1 or 2) needs to be determined, parse IEs. The + * IE will not be verified, just a quick search for MFP config + */ + rsn_ie = brcmf_parse_tlvs((const u8 *)sme->ie, sme->ie_len, + WLAN_EID_RSN); + if (!rsn_ie) + goto skip_mfp_config; + ie = (const u8 *)rsn_ie; + ie_len = rsn_ie->len + TLV_HDR_LEN; + /* Skip unicast suite */ + offset = TLV_HDR_LEN + WPA_IE_VERSION_LEN + WPA_IE_MIN_OUI_LEN; + if (offset + WPA_IE_SUITE_COUNT_LEN >= ie_len) + goto skip_mfp_config; + /* Skip multicast suite */ + count = ie[offset] + (ie[offset + 1] << 8); + offset += WPA_IE_SUITE_COUNT_LEN + (count * WPA_IE_MIN_OUI_LEN); + if (offset + WPA_IE_SUITE_COUNT_LEN >= ie_len) + goto skip_mfp_config; + /* Skip auth key management suite(s) */ + count = ie[offset] + (ie[offset + 1] << 8); + offset += WPA_IE_SUITE_COUNT_LEN + (count * WPA_IE_MIN_OUI_LEN); + if (offset + WPA_IE_SUITE_COUNT_LEN > ie_len) + goto skip_mfp_config; + /* Ready to read capabilities */ + mfp = BRCMF_MFP_NONE; + rsn_cap = ie[offset] + (ie[offset + 1] << 8); + if (rsn_cap & RSN_CAP_MFPR_MASK) + mfp = BRCMF_MFP_REQUIRED; + else if (rsn_cap & RSN_CAP_MFPC_MASK) + mfp = BRCMF_MFP_CAPABLE; + brcmf_fil_bsscfg_int_set(netdev_priv(ndev), ""mfp"", mfp); + +skip_mfp_config: + brcmf_dbg(CONN, ""setting wpa_auth to %d\n"", val); + err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), ""wpa_auth"", val); + if (err) { + brcmf_err(""could not set wpa_auth (%d)\n"", err); + return err; + } + + return err; +} +",0,"brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) +{ + struct brcmf_if *ifp = netdev_priv(ndev); + s32 val; + s32 err; + const struct brcmf_tlv *rsn_ie; + const u8 *ie; + u32 ie_len; + u32 offset; + u16 rsn_cap; + u32 mfp; + u16 count; + + if (!sme->crypto.n_akm_suites) + return 0; + + err = brcmf_fil_bsscfg_int_get(netdev_priv(ndev), ""wpa_auth"", &val); + if (err) { + brcmf_err(""could not get wpa_auth (%d)\n"", err); + return err; + } + if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) { + switch (sme->crypto.akm_suites[0]) { + case WLAN_AKM_SUITE_8021X: + val = WPA_AUTH_UNSPECIFIED; + break; + case WLAN_AKM_SUITE_PSK: + val = WPA_AUTH_PSK; + break; + default: + brcmf_err(""invalid cipher group (%d)\n"", + sme->crypto.cipher_group); + return -EINVAL; + } + } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) { + switch (sme->crypto.akm_suites[0]) { + case WLAN_AKM_SUITE_8021X: + val = WPA2_AUTH_UNSPECIFIED; + break; + case WLAN_AKM_SUITE_8021X_SHA256: + val = WPA2_AUTH_1X_SHA256; + break; + case WLAN_AKM_SUITE_PSK_SHA256: + val = WPA2_AUTH_PSK_SHA256; + break; + case WLAN_AKM_SUITE_PSK: + val = WPA2_AUTH_PSK; + break; + default: + brcmf_err(""invalid cipher group (%d)\n"", + sme->crypto.cipher_group); + return -EINVAL; + } + } + + if (!brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MFP)) + goto skip_mfp_config; + /* The MFP mode (1 or 2) needs to be determined, parse IEs. The + * IE will not be verified, just a quick search for MFP config + */ + rsn_ie = brcmf_parse_tlvs((const u8 *)sme->ie, sme->ie_len, + WLAN_EID_RSN); + if (!rsn_ie) + goto skip_mfp_config; + ie = (const u8 *)rsn_ie; + ie_len = rsn_ie->len + TLV_HDR_LEN; + /* Skip unicast suite */ + offset = TLV_HDR_LEN + WPA_IE_VERSION_LEN + WPA_IE_MIN_OUI_LEN; + if (offset + WPA_IE_SUITE_COUNT_LEN >= ie_len) + goto skip_mfp_config; + /* Skip multicast suite */ + count = ie[offset] + (ie[offset + 1] << 8); + offset += WPA_IE_SUITE_COUNT_LEN + (count * WPA_IE_MIN_OUI_LEN); + if (offset + WPA_IE_SUITE_COUNT_LEN >= ie_len) + goto skip_mfp_config; + /* Skip auth key management suite(s) */ + count = ie[offset] + (ie[offset + 1] << 8); + offset += WPA_IE_SUITE_COUNT_LEN + (count * WPA_IE_MIN_OUI_LEN); + if (offset + WPA_IE_SUITE_COUNT_LEN > ie_len) + goto skip_mfp_config; + /* Ready to read capabilities */ + mfp = BRCMF_MFP_NONE; + rsn_cap = ie[offset] + (ie[offset + 1] << 8); + if (rsn_cap & RSN_CAP_MFPR_MASK) + mfp = BRCMF_MFP_REQUIRED; + else if (rsn_cap & RSN_CAP_MFPC_MASK) + mfp = BRCMF_MFP_CAPABLE; + brcmf_fil_bsscfg_int_set(netdev_priv(ndev), ""mfp"", mfp); + +skip_mfp_config: + brcmf_dbg(CONN, ""setting wpa_auth to %d\n"", val); + err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), ""wpa_auth"", val); + if (err) { + brcmf_err(""could not set wpa_auth (%d)\n"", err); + return err; + } + + return err; +} +","@@ -4527,7 +4527,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev, + (u8 *)&settings->beacon.head[ie_offset], + settings->beacon.head_len - ie_offset, + WLAN_EID_SSID); +- if (!ssid_ie) ++ if (!ssid_ie || ssid_ie->len > IEEE80211_MAX_SSID_LEN) + return -EINVAL; + + memcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len);",989,1225,2048 +18594," static void GetLoadTimes(const v8::FunctionCallbackInfo& args) { + WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext(); + if (!frame) { + args.GetReturnValue().SetNull(); + return; + } + WebDataSource* data_source = frame->dataSource(); + if (!data_source) { + args.GetReturnValue().SetNull(); + return; + } + DocumentState* document_state = DocumentState::FromDataSource(data_source); + if (!document_state) { + args.GetReturnValue().SetNull(); + return; + } + double request_time = document_state->request_time().ToDoubleT(); + double start_load_time = document_state->start_load_time().ToDoubleT(); + double commit_load_time = document_state->commit_load_time().ToDoubleT(); + double finish_document_load_time = + document_state->finish_document_load_time().ToDoubleT(); + double finish_load_time = document_state->finish_load_time().ToDoubleT(); + double first_paint_time = document_state->first_paint_time().ToDoubleT(); + double first_paint_after_load_time = + document_state->first_paint_after_load_time().ToDoubleT(); + std::string navigation_type = + GetNavigationType(data_source->navigationType()); + bool was_fetched_via_spdy = document_state->was_fetched_via_spdy(); + bool was_npn_negotiated = document_state->was_npn_negotiated(); + std::string npn_negotiated_protocol = + document_state->npn_negotiated_protocol(); + bool was_alternate_protocol_available = + document_state->was_alternate_protocol_available(); + std::string connection_info = net::HttpResponseInfo::ConnectionInfoToString( + document_state->connection_info()); + v8::Isolate* isolate = args.GetIsolate(); + v8::Local load_times = v8::Object::New(isolate); + load_times->Set(v8::String::NewFromUtf8(isolate, ""requestTime""), + v8::Number::New(isolate, request_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""startLoadTime""), + v8::Number::New(isolate, start_load_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""commitLoadTime""), + v8::Number::New(isolate, commit_load_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""finishDocumentLoadTime""), + v8::Number::New(isolate, finish_document_load_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""finishLoadTime""), + v8::Number::New(isolate, finish_load_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""firstPaintTime""), + v8::Number::New(isolate, first_paint_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""firstPaintAfterLoadTime""), + v8::Number::New(isolate, first_paint_after_load_time)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""navigationType""), + v8::String::NewFromUtf8(isolate, navigation_type.c_str())); + load_times->Set(v8::String::NewFromUtf8(isolate, ""wasFetchedViaSpdy""), + v8::Boolean::New(isolate, was_fetched_via_spdy)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""wasNpnNegotiated""), + v8::Boolean::New(isolate, was_npn_negotiated)); + load_times->Set( + v8::String::NewFromUtf8(isolate, ""npnNegotiatedProtocol""), + v8::String::NewFromUtf8(isolate, npn_negotiated_protocol.c_str())); + load_times->Set( + v8::String::NewFromUtf8(isolate, ""wasAlternateProtocolAvailable""), + v8::Boolean::New(isolate, was_alternate_protocol_available)); + load_times->Set(v8::String::NewFromUtf8(isolate, ""connectionInfo""), + v8::String::NewFromUtf8(isolate, connection_info.c_str())); + args.GetReturnValue().Set(load_times); + } +",1," static void GetLoadTimes(const v8::FunctionCallbackInfo& args) { + args.GetReturnValue().SetNull(); + WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext(); + if (!frame) { + return; + } + WebDataSource* data_source = frame->dataSource(); + if (!data_source) { + return; + } + DocumentState* document_state = DocumentState::FromDataSource(data_source); + if (!document_state) { + return; + } + double request_time = document_state->request_time().ToDoubleT(); + double start_load_time = document_state->start_load_time().ToDoubleT(); + double commit_load_time = document_state->commit_load_time().ToDoubleT(); + double finish_document_load_time = + document_state->finish_document_load_time().ToDoubleT(); + double finish_load_time = document_state->finish_load_time().ToDoubleT(); + double first_paint_time = document_state->first_paint_time().ToDoubleT(); + double first_paint_after_load_time = + document_state->first_paint_after_load_time().ToDoubleT(); + std::string navigation_type = + GetNavigationType(data_source->navigationType()); + bool was_fetched_via_spdy = document_state->was_fetched_via_spdy(); + bool was_npn_negotiated = document_state->was_npn_negotiated(); + std::string npn_negotiated_protocol = + document_state->npn_negotiated_protocol(); + bool was_alternate_protocol_available = + document_state->was_alternate_protocol_available(); + std::string connection_info = net::HttpResponseInfo::ConnectionInfoToString( + document_state->connection_info()); + v8::Isolate* isolate = args.GetIsolate(); + v8::Local ctx = isolate->GetCurrentContext(); + v8::Local load_times = v8::Object::New(isolate); + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""requestTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, request_time)) + .FromMaybe(false)) { + return; + } + + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""startLoadTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, start_load_time)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""commitLoadTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, commit_load_time)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, + v8::String::NewFromUtf8(isolate, ""finishDocumentLoadTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, finish_document_load_time)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""finishLoadTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, finish_load_time)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""firstPaintTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, first_paint_time)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, + v8::String::NewFromUtf8(isolate, ""firstPaintAfterLoadTime"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Number::New(isolate, first_paint_after_load_time)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""navigationType"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::String::NewFromUtf8(isolate, navigation_type.c_str(), + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""wasFetchedViaSpdy"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Boolean::New(isolate, was_fetched_via_spdy)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""wasNpnNegotiated"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Boolean::New(isolate, was_npn_negotiated)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, + v8::String::NewFromUtf8(isolate, ""npnNegotiatedProtocol"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::String::NewFromUtf8(isolate, + npn_negotiated_protocol.c_str(), + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, + ""wasAlternateProtocolAvailable"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Boolean::New(isolate, was_alternate_protocol_available)) + .FromMaybe(false)) { + return; + } + if (!load_times + ->Set(ctx, v8::String::NewFromUtf8(isolate, ""connectionInfo"", + v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::String::NewFromUtf8(isolate, connection_info.c_str(), + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromMaybe(false)) { + return; + } + args.GetReturnValue().Set(load_times); + } +","@@ -98,19 +98,17 @@ class LoadTimesExtensionWrapper : public v8::Extension { + } + + static void GetLoadTimes(const v8::FunctionCallbackInfo& args) { ++ args.GetReturnValue().SetNull(); + WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext(); + if (!frame) { +- args.GetReturnValue().SetNull(); + return; + } + WebDataSource* data_source = frame->dataSource(); + if (!data_source) { +- args.GetReturnValue().SetNull(); + return; + } + DocumentState* document_state = DocumentState::FromDataSource(data_source); + if (!document_state) { +- args.GetReturnValue().SetNull(); + return; + } + double request_time = document_state->request_time().ToDoubleT(); +@@ -136,70 +134,183 @@ class LoadTimesExtensionWrapper : public v8::Extension { + // referred to below this line, as JS setters below can invalidate these + // pointers. + v8::Isolate* isolate = args.GetIsolate(); ++ v8::Local ctx = isolate->GetCurrentContext(); + v8::Local load_times = v8::Object::New(isolate); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""requestTime""), +- v8::Number::New(isolate, request_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""startLoadTime""), +- v8::Number::New(isolate, start_load_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""commitLoadTime""), +- v8::Number::New(isolate, commit_load_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""finishDocumentLoadTime""), +- v8::Number::New(isolate, finish_document_load_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""finishLoadTime""), +- v8::Number::New(isolate, finish_load_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""firstPaintTime""), +- v8::Number::New(isolate, first_paint_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""firstPaintAfterLoadTime""), +- v8::Number::New(isolate, first_paint_after_load_time)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""navigationType""), +- v8::String::NewFromUtf8(isolate, navigation_type.c_str())); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""wasFetchedViaSpdy""), +- v8::Boolean::New(isolate, was_fetched_via_spdy)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""wasNpnNegotiated""), +- v8::Boolean::New(isolate, was_npn_negotiated)); +- load_times->Set( +- v8::String::NewFromUtf8(isolate, ""npnNegotiatedProtocol""), +- v8::String::NewFromUtf8(isolate, npn_negotiated_protocol.c_str())); +- load_times->Set( +- v8::String::NewFromUtf8(isolate, ""wasAlternateProtocolAvailable""), +- v8::Boolean::New(isolate, was_alternate_protocol_available)); +- load_times->Set(v8::String::NewFromUtf8(isolate, ""connectionInfo""), +- v8::String::NewFromUtf8(isolate, connection_info.c_str())); ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""requestTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, request_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""startLoadTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, start_load_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""commitLoadTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, commit_load_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, ++ v8::String::NewFromUtf8(isolate, ""finishDocumentLoadTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, finish_document_load_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""finishLoadTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, finish_load_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""firstPaintTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, first_paint_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, ++ v8::String::NewFromUtf8(isolate, ""firstPaintAfterLoadTime"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, first_paint_after_load_time)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""navigationType"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::String::NewFromUtf8(isolate, navigation_type.c_str(), ++ v8::NewStringType::kNormal) ++ .ToLocalChecked()) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""wasFetchedViaSpdy"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Boolean::New(isolate, was_fetched_via_spdy)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""wasNpnNegotiated"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Boolean::New(isolate, was_npn_negotiated)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, ++ v8::String::NewFromUtf8(isolate, ""npnNegotiatedProtocol"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::String::NewFromUtf8(isolate, ++ npn_negotiated_protocol.c_str(), ++ v8::NewStringType::kNormal) ++ .ToLocalChecked()) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ++ ""wasAlternateProtocolAvailable"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Boolean::New(isolate, was_alternate_protocol_available)) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!load_times ++ ->Set(ctx, v8::String::NewFromUtf8(isolate, ""connectionInfo"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::String::NewFromUtf8(isolate, connection_info.c_str(), ++ v8::NewStringType::kNormal) ++ .ToLocalChecked()) ++ .FromMaybe(false)) { ++ return; ++ } + args.GetReturnValue().Set(load_times); + } + + static void GetCSI(const v8::FunctionCallbackInfo& args) { ++ args.GetReturnValue().SetNull(); + WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext(); +- if (frame) { +- WebDataSource* data_source = frame->dataSource(); +- if (data_source) { +- DocumentState* document_state = +- DocumentState::FromDataSource(data_source); +- v8::Isolate* isolate = args.GetIsolate(); +- v8::Local csi = v8::Object::New(isolate); +- base::Time now = base::Time::Now(); +- base::Time start = document_state->request_time().is_null() ? +- document_state->start_load_time() : +- document_state->request_time(); +- base::Time onload = document_state->finish_document_load_time(); +- base::TimeDelta page = now - start; +- csi->Set(v8::String::NewFromUtf8(isolate, ""startE""), +- v8::Number::New(isolate, floor(start.ToDoubleT() * 1000))); +- csi->Set(v8::String::NewFromUtf8(isolate, ""onloadT""), +- v8::Number::New(isolate, floor(onload.ToDoubleT() * 1000))); +- csi->Set(v8::String::NewFromUtf8(isolate, ""pageT""), +- v8::Number::New(isolate, page.InMillisecondsF())); +- csi->Set( +- v8::String::NewFromUtf8(isolate, ""tran""), +- v8::Number::New( +- isolate, GetCSITransitionType(data_source->navigationType()))); +- +- args.GetReturnValue().Set(csi); +- return; +- } ++ if (!frame) { ++ return; + } +- args.GetReturnValue().SetNull(); +- return; ++ WebDataSource* data_source = frame->dataSource(); ++ if (!data_source) { ++ return; ++ } ++ DocumentState* document_state = DocumentState::FromDataSource(data_source); ++ if (!document_state) { ++ return; ++ } ++ base::Time now = base::Time::Now(); ++ base::Time start = document_state->request_time().is_null() ++ ? document_state->start_load_time() ++ : document_state->request_time(); ++ base::Time onload = document_state->finish_document_load_time(); ++ base::TimeDelta page = now - start; ++ int navigation_type = GetCSITransitionType(data_source->navigationType()); ++ // Important: |frame|, |data_source| and |document_state| should not be ++ // referred to below this line, as JS setters below can invalidate these ++ // pointers. ++ v8::Isolate* isolate = args.GetIsolate(); ++ v8::Local ctx = isolate->GetCurrentContext(); ++ v8::Local csi = v8::Object::New(isolate); ++ if (!csi->Set(ctx, v8::String::NewFromUtf8(isolate, ""startE"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, floor(start.ToDoubleT() * 1000))) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!csi->Set(ctx, v8::String::NewFromUtf8(isolate, ""onloadT"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, floor(onload.ToDoubleT() * 1000))) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!csi->Set(ctx, v8::String::NewFromUtf8(isolate, ""pageT"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, page.InMillisecondsF())) ++ .FromMaybe(false)) { ++ return; ++ } ++ if (!csi->Set(ctx, v8::String::NewFromUtf8(isolate, ""tran"", ++ v8::NewStringType::kNormal) ++ .ToLocalChecked(), ++ v8::Number::New(isolate, navigation_type)) ++ .FromMaybe(false)) { ++ return; ++ } ++ args.GetReturnValue().Set(csi); + } + }; + ",893,1129,2048 +17945,"static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, + unsigned int dataoff, enum ip_conntrack_info ctinfo, + u_int8_t pf, unsigned int hooknum, + unsigned int *timeouts) +{ + struct net *net = nf_ct_net(ct); + enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); + struct dccp_hdr _dh, *dh; + u_int8_t type, old_state, new_state; + enum ct_dccp_roles role; + + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh); + BUG_ON(dh == NULL); + type = dh->dccph_type; + + if (type == DCCP_PKT_RESET && + !test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { + /* Tear down connection immediately if only reply is a RESET */ + nf_ct_kill_acct(ct, ctinfo, skb); + return NF_ACCEPT; + } + + spin_lock_bh(&ct->lock); + + role = ct->proto.dccp.role[dir]; + old_state = ct->proto.dccp.state; + new_state = dccp_state_table[role][type][old_state]; + + switch (new_state) { + case CT_DCCP_REQUEST: + if (old_state == CT_DCCP_TIMEWAIT && + role == CT_DCCP_ROLE_SERVER) { + /* Reincarnation in the reverse direction: reopen and + * reverse client/server roles. */ + ct->proto.dccp.role[dir] = CT_DCCP_ROLE_CLIENT; + ct->proto.dccp.role[!dir] = CT_DCCP_ROLE_SERVER; + } + break; + case CT_DCCP_RESPOND: + if (old_state == CT_DCCP_REQUEST) + ct->proto.dccp.handshake_seq = dccp_hdr_seq(dh); + break; + case CT_DCCP_PARTOPEN: + if (old_state == CT_DCCP_RESPOND && + type == DCCP_PKT_ACK && + dccp_ack_seq(dh) == ct->proto.dccp.handshake_seq) + set_bit(IPS_ASSURED_BIT, &ct->status); + break; + case CT_DCCP_IGNORE: + /* + * Connection tracking might be out of sync, so we ignore + * packets that might establish a new connection and resync + * if the server responds with a valid Response. + */ + if (ct->proto.dccp.last_dir == !dir && + ct->proto.dccp.last_pkt == DCCP_PKT_REQUEST && + type == DCCP_PKT_RESPONSE) { + ct->proto.dccp.role[!dir] = CT_DCCP_ROLE_CLIENT; + ct->proto.dccp.role[dir] = CT_DCCP_ROLE_SERVER; + ct->proto.dccp.handshake_seq = dccp_hdr_seq(dh); + new_state = CT_DCCP_RESPOND; + break; + } + ct->proto.dccp.last_dir = dir; + ct->proto.dccp.last_pkt = type; + + spin_unlock_bh(&ct->lock); + if (LOG_INVALID(net, IPPROTO_DCCP)) + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, + ""nf_ct_dccp: invalid packet ignored ""); + return NF_ACCEPT; + case CT_DCCP_INVALID: + spin_unlock_bh(&ct->lock); + if (LOG_INVALID(net, IPPROTO_DCCP)) + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, + ""nf_ct_dccp: invalid state transition ""); + return -NF_ACCEPT; + } + + ct->proto.dccp.last_dir = dir; + ct->proto.dccp.last_pkt = type; + ct->proto.dccp.state = new_state; + spin_unlock_bh(&ct->lock); + + if (new_state != old_state) + nf_conntrack_event_cache(IPCT_PROTOINFO, ct); + + nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[new_state]); + + return NF_ACCEPT; +} +",1,"static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, + unsigned int dataoff, enum ip_conntrack_info ctinfo, + u_int8_t pf, unsigned int hooknum, + unsigned int *timeouts) +{ + struct net *net = nf_ct_net(ct); + enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); + struct dccp_hdr _dh, *dh; + u_int8_t type, old_state, new_state; + enum ct_dccp_roles role; + + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh); + BUG_ON(dh == NULL); + type = dh->dccph_type; + + if (type == DCCP_PKT_RESET && + !test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { + /* Tear down connection immediately if only reply is a RESET */ + nf_ct_kill_acct(ct, ctinfo, skb); + return NF_ACCEPT; + } + + spin_lock_bh(&ct->lock); + + role = ct->proto.dccp.role[dir]; + old_state = ct->proto.dccp.state; + new_state = dccp_state_table[role][type][old_state]; + + switch (new_state) { + case CT_DCCP_REQUEST: + if (old_state == CT_DCCP_TIMEWAIT && + role == CT_DCCP_ROLE_SERVER) { + /* Reincarnation in the reverse direction: reopen and + * reverse client/server roles. */ + ct->proto.dccp.role[dir] = CT_DCCP_ROLE_CLIENT; + ct->proto.dccp.role[!dir] = CT_DCCP_ROLE_SERVER; + } + break; + case CT_DCCP_RESPOND: + if (old_state == CT_DCCP_REQUEST) + ct->proto.dccp.handshake_seq = dccp_hdr_seq(dh); + break; + case CT_DCCP_PARTOPEN: + if (old_state == CT_DCCP_RESPOND && + type == DCCP_PKT_ACK && + dccp_ack_seq(dh) == ct->proto.dccp.handshake_seq) + set_bit(IPS_ASSURED_BIT, &ct->status); + break; + case CT_DCCP_IGNORE: + /* + * Connection tracking might be out of sync, so we ignore + * packets that might establish a new connection and resync + * if the server responds with a valid Response. + */ + if (ct->proto.dccp.last_dir == !dir && + ct->proto.dccp.last_pkt == DCCP_PKT_REQUEST && + type == DCCP_PKT_RESPONSE) { + ct->proto.dccp.role[!dir] = CT_DCCP_ROLE_CLIENT; + ct->proto.dccp.role[dir] = CT_DCCP_ROLE_SERVER; + ct->proto.dccp.handshake_seq = dccp_hdr_seq(dh); + new_state = CT_DCCP_RESPOND; + break; + } + ct->proto.dccp.last_dir = dir; + ct->proto.dccp.last_pkt = type; + + spin_unlock_bh(&ct->lock); + if (LOG_INVALID(net, IPPROTO_DCCP)) + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, + ""nf_ct_dccp: invalid packet ignored ""); + return NF_ACCEPT; + case CT_DCCP_INVALID: + spin_unlock_bh(&ct->lock); + if (LOG_INVALID(net, IPPROTO_DCCP)) + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, + ""nf_ct_dccp: invalid state transition ""); + return -NF_ACCEPT; + } + + ct->proto.dccp.last_dir = dir; + ct->proto.dccp.last_pkt = type; + ct->proto.dccp.state = new_state; + spin_unlock_bh(&ct->lock); + + if (new_state != old_state) + nf_conntrack_event_cache(IPCT_PROTOINFO, ct); + + nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[new_state]); + + return NF_ACCEPT; +} +","@@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb, + const char *msg; + u_int8_t state; + +- dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh); ++ dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh); + BUG_ON(dh == NULL); + + state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE]; +@@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, + u_int8_t type, old_state, new_state; + enum ct_dccp_roles role; + +- dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh); ++ dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh); + BUG_ON(dh == NULL); + type = dh->dccph_type; + +@@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl, + unsigned int cscov; + const char *msg; + +- dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh); ++ dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh); + if (dh == NULL) { + msg = ""nf_ct_dccp: short packet ""; + goto out_invalid;",863,1099,2048 +484,"static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */ +{ +/* + This is how the time string is formatted: + + snprintf(p, sizeof(p), ""%02d%02d%02d%02d%02d%02dZ"",ts->tm_year%100, + ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); +*/ + + time_t ret; + struct tm thetime; + char * strbuf; + char * thestr; + long gmadjust = 0; + + if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME && ASN1_STRING_type(timestr) != V_ASN1_GENERALIZEDTIME) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""illegal ASN1 data type for timestamp""); + return (time_t)-1; + } + + if (ASN1_STRING_length(timestr) != strlen((const char*)ASN1_STRING_data(timestr))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""illegal length in timestamp""); + return (time_t)-1; + } + + if (ASN1_STRING_length(timestr) < 13) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + if (ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME && ASN1_STRING_length(timestr) < 15) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + strbuf = estrdup((char *)ASN1_STRING_data(timestr)); + + memset(&thetime, 0, sizeof(thetime)); + + /* we work backwards so that we can use atoi more easily */ + + thestr = strbuf + ASN1_STRING_length(timestr) - 3; + + thetime.tm_sec = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_min = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_hour = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mday = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mon = atoi(thestr)-1; + + *thestr = '\0'; + if( ASN1_STRING_type(timestr) == V_ASN1_UTCTIME ) { + thestr -= 2; + thetime.tm_year = atoi(thestr); + + if (thetime.tm_year < 68) { + thetime.tm_year += 100; + } + } else if( ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME ) { + thestr -= 4; + thetime.tm_year = atoi(thestr) - 1900; + } + + + thetime.tm_isdst = -1; + ret = mktime(&thetime); + +#if HAVE_TM_GMTOFF + gmadjust = thetime.tm_gmtoff; +#else + /* + ** If correcting for daylight savings time, we set the adjustment to + ** the value of timezone - 3600 seconds. Otherwise, we need to overcorrect and + ** set the adjustment to the main timezone + 3600 seconds. + */ + gmadjust = -(thetime.tm_isdst ? (long)timezone - 3600 : (long)timezone + 3600); +#endif + ret += gmadjust; + + efree(strbuf); + + return ret; +} +/* }}} */ +",0,"static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */ +{ +/* + This is how the time string is formatted: + + snprintf(p, sizeof(p), ""%02d%02d%02d%02d%02d%02dZ"",ts->tm_year%100, + ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); +*/ + + time_t ret; + struct tm thetime; + char * strbuf; + char * thestr; + long gmadjust = 0; + + if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME && ASN1_STRING_type(timestr) != V_ASN1_GENERALIZEDTIME) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""illegal ASN1 data type for timestamp""); + return (time_t)-1; + } + + if (ASN1_STRING_length(timestr) != strlen((const char*)ASN1_STRING_data(timestr))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""illegal length in timestamp""); + return (time_t)-1; + } + + if (ASN1_STRING_length(timestr) < 13) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + if (ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME && ASN1_STRING_length(timestr) < 15) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + strbuf = estrdup((char *)ASN1_STRING_data(timestr)); + + memset(&thetime, 0, sizeof(thetime)); + + /* we work backwards so that we can use atoi more easily */ + + thestr = strbuf + ASN1_STRING_length(timestr) - 3; + + thetime.tm_sec = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_min = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_hour = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mday = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mon = atoi(thestr)-1; + + *thestr = '\0'; + if( ASN1_STRING_type(timestr) == V_ASN1_UTCTIME ) { + thestr -= 2; + thetime.tm_year = atoi(thestr); + + if (thetime.tm_year < 68) { + thetime.tm_year += 100; + } + } else if( ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME ) { + thestr -= 4; + thetime.tm_year = atoi(thestr) - 1900; + } + + + thetime.tm_isdst = -1; + ret = mktime(&thetime); + +#if HAVE_TM_GMTOFF + gmadjust = thetime.tm_gmtoff; +#else + /* + ** If correcting for daylight savings time, we set the adjustment to + ** the value of timezone - 3600 seconds. Otherwise, we need to overcorrect and + ** set the adjustment to the main timezone + 3600 seconds. + */ + gmadjust = -(thetime.tm_isdst ? (long)timezone - 3600 : (long)timezone + 3600); +#endif + ret += gmadjust; + + efree(strbuf); + + return ret; +} +/* }}} */ +","@@ -4982,15 +4982,15 @@ PHP_FUNCTION(openssl_seal) + buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx)); + EVP_CIPHER_CTX_cleanup(&ctx); + +- if (!EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) || !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) { ++ if (EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) <= 0 || ++ !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len) || ++ !EVP_SealFinal(&ctx, buf + len1, &len2)) { + RETVAL_FALSE; + efree(buf); + EVP_CIPHER_CTX_cleanup(&ctx); + goto clean_exit; + } + +- EVP_SealFinal(&ctx, buf + len1, &len2); +- + if (len1 + len2 > 0) { + zval_dtor(sealdata); + buf[len1 + len2] = '\0';",821,1057,2048 +7588,"xfs_attr_node_removename(xfs_da_args_t *args) +{ + xfs_da_state_t *state; + xfs_da_state_blk_t *blk; + xfs_inode_t *dp; + struct xfs_buf *bp; + int retval, error, forkoff; + + trace_xfs_attr_node_removename(args); + + /* + * Tie a string around our finger to remind us where we are. + */ + dp = args->dp; + state = xfs_da_state_alloc(); + state->args = args; + state->mp = dp->i_mount; + + /* + * Search to see if name exists, and get back a pointer to it. + */ + error = xfs_da3_node_lookup_int(state, &retval); + if (error || (retval != -EEXIST)) { + if (error == 0) + error = retval; + goto out; + } + + /* + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a deadlock. + */ + blk = &state->path.blk[ state->path.active-1 ]; + ASSERT(blk->bp != NULL); + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + if (args->rmtblkno > 0) { + /* + * Fill in disk block numbers in the state structure + * so that we can get the buffers back after we commit + * several transactions in the following calls. + */ + error = xfs_attr_fillstate(state); + if (error) + goto out; + + /* + * Mark the attribute as INCOMPLETE, then bunmapi() the + * remote value. + */ + error = xfs_attr3_leaf_setflag(args); + if (error) + goto out; + error = xfs_attr_rmtval_remove(args); + if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior calls + * released our buffers. + */ + error = xfs_attr_refillstate(state); + if (error) + goto out; + } + + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[ state->path.active-1 ]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + /* + * Check to see if the tree needs to be collapsed. + */ + if (retval && (state->path.active > 1)) { + xfs_defer_init(args->dfops, args->firstblock); + error = xfs_da3_join(state); + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; + /* + * Commit the Btree join operation and start a new trans. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + goto out; + } + + /* + * If the result is small enough, push it all into the inode. + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + /* + * Have to get rid of the copy of this dabuf in the state. + */ + ASSERT(state->path.active == 1); + ASSERT(state->path.blk[0].bp); + state->path.blk[0].bp = NULL; + + error = xfs_attr3_leaf_read(args->trans, args->dp, 0, -1, &bp); + if (error) + goto out; + + if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { + xfs_defer_init(args->dfops, args->firstblock); + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; + } else + xfs_trans_brelse(args->trans, bp); + } + error = 0; + +out: + xfs_da_state_free(state); + return error; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + goto out; +} +",0,"xfs_attr_node_removename(xfs_da_args_t *args) +{ + xfs_da_state_t *state; + xfs_da_state_blk_t *blk; + xfs_inode_t *dp; + struct xfs_buf *bp; + int retval, error, forkoff; + + trace_xfs_attr_node_removename(args); + + /* + * Tie a string around our finger to remind us where we are. + */ + dp = args->dp; + state = xfs_da_state_alloc(); + state->args = args; + state->mp = dp->i_mount; + + /* + * Search to see if name exists, and get back a pointer to it. + */ + error = xfs_da3_node_lookup_int(state, &retval); + if (error || (retval != -EEXIST)) { + if (error == 0) + error = retval; + goto out; + } + + /* + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a deadlock. + */ + blk = &state->path.blk[ state->path.active-1 ]; + ASSERT(blk->bp != NULL); + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + if (args->rmtblkno > 0) { + /* + * Fill in disk block numbers in the state structure + * so that we can get the buffers back after we commit + * several transactions in the following calls. + */ + error = xfs_attr_fillstate(state); + if (error) + goto out; + + /* + * Mark the attribute as INCOMPLETE, then bunmapi() the + * remote value. + */ + error = xfs_attr3_leaf_setflag(args); + if (error) + goto out; + error = xfs_attr_rmtval_remove(args); + if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior calls + * released our buffers. + */ + error = xfs_attr_refillstate(state); + if (error) + goto out; + } + + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[ state->path.active-1 ]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + /* + * Check to see if the tree needs to be collapsed. + */ + if (retval && (state->path.active > 1)) { + xfs_defer_init(args->dfops, args->firstblock); + error = xfs_da3_join(state); + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; + /* + * Commit the Btree join operation and start a new trans. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + goto out; + } + + /* + * If the result is small enough, push it all into the inode. + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + /* + * Have to get rid of the copy of this dabuf in the state. + */ + ASSERT(state->path.active == 1); + ASSERT(state->path.blk[0].bp); + state->path.blk[0].bp = NULL; + + error = xfs_attr3_leaf_read(args->trans, args->dp, 0, -1, &bp); + if (error) + goto out; + + if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { + xfs_defer_init(args->dfops, args->firstblock); + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; + } else + xfs_trans_brelse(args->trans, bp); + } + error = 0; + +out: + xfs_da_state_free(state); + return error; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + goto out; +} +","@@ -511,7 +511,14 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) + if (args->flags & ATTR_CREATE) + return retval; + retval = xfs_attr_shortform_remove(args); +- ASSERT(retval == 0); ++ if (retval) ++ return retval; ++ /* ++ * Since we have removed the old attr, clear ATTR_REPLACE so ++ * that the leaf format add routine won't trip over the attr ++ * not being around. ++ */ ++ args->flags &= ~ATTR_REPLACE; + } + + if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||",999,1235,2048 +18607,"void NavigationRequest::OnStartChecksComplete( + NavigationThrottle::ThrottleCheckResult result) { + DCHECK(result.action() != NavigationThrottle::DEFER); + DCHECK(result.action() != NavigationThrottle::BLOCK_RESPONSE); + + if (on_start_checks_complete_closure_) + on_start_checks_complete_closure_.Run(); + if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE || + result.action() == NavigationThrottle::CANCEL || + result.action() == NavigationThrottle::BLOCK_REQUEST || + result.action() == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) { +#if DCHECK_IS_ON() + if (result.action() == NavigationThrottle::BLOCK_REQUEST) { + DCHECK(result.net_error_code() == net::ERR_BLOCKED_BY_CLIENT || + result.net_error_code() == net::ERR_BLOCKED_BY_ADMINISTRATOR); + } + else if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE) { + DCHECK_EQ(result.net_error_code(), net::ERR_ABORTED); + } +#endif + + bool collapse_frame = + result.action() == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE; + + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::BindOnce( + &NavigationRequest::OnRequestFailedInternal, + weak_factory_.GetWeakPtr(), + network::URLLoaderCompletionStatus(result.net_error_code()), + true /* skip_throttles */, result.error_page_content(), + collapse_frame)); + + return; + } + + DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); + RenderFrameHostImpl* navigating_frame_host = + associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE + ? frame_tree_node_->render_manager()->speculative_frame_host() + : frame_tree_node_->current_frame_host(); + DCHECK(navigating_frame_host); + + navigation_handle_->SetExpectedProcess(navigating_frame_host->GetProcess()); + + BrowserContext* browser_context = + frame_tree_node_->navigator()->GetController()->GetBrowserContext(); + StoragePartition* partition = BrowserContext::GetStoragePartition( + browser_context, navigating_frame_host->GetSiteInstance()); + DCHECK(partition); + + DCHECK(!loader_); + + bool can_create_service_worker = + (frame_tree_node_->pending_frame_policy().sandbox_flags & + blink::WebSandboxFlags::kOrigin) != blink::WebSandboxFlags::kOrigin; + request_params_.should_create_service_worker = can_create_service_worker; + if (can_create_service_worker) { + ServiceWorkerContextWrapper* service_worker_context = + static_cast( + partition->GetServiceWorkerContext()); + navigation_handle_->InitServiceWorkerHandle(service_worker_context); + } + + if (IsSchemeSupportedForAppCache(common_params_.url)) { + if (navigating_frame_host->GetRenderViewHost() + ->GetWebkitPreferences() + .application_cache_enabled) { + navigation_handle_->InitAppCacheHandle( + static_cast(partition->GetAppCacheService())); + } + } + + request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); + + GURL base_url; +#if defined(OS_ANDROID) + NavigationEntry* last_committed_entry = + frame_tree_node_->navigator()->GetController()->GetLastCommittedEntry(); + if (last_committed_entry) + base_url = last_committed_entry->GetBaseURLForDataURL(); +#endif + const GURL& top_document_url = + !base_url.is_empty() + ? base_url + : frame_tree_node_->frame_tree()->root()->current_url(); + + const FrameTreeNode* current = frame_tree_node_->parent(); + bool ancestors_are_same_site = true; + while (current && ancestors_are_same_site) { + if (!net::registry_controlled_domains::SameDomainOrHost( + top_document_url, current->current_url(), + net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) { + ancestors_are_same_site = false; + } + current = current->parent(); + } + const GURL& site_for_cookies = + ancestors_are_same_site + ? (frame_tree_node_->IsMainFrame() ? common_params_.url + : top_document_url) + : GURL::EmptyGURL(); + bool parent_is_main_frame = !frame_tree_node_->parent() + ? false + : frame_tree_node_->parent()->IsMainFrame(); + + std::unique_ptr navigation_ui_data; + if (navigation_handle_->GetNavigationUIData()) + navigation_ui_data = navigation_handle_->GetNavigationUIData()->Clone(); + + bool is_for_guests_only = + navigation_handle_->GetStartingSiteInstance()->GetSiteURL(). + SchemeIs(kGuestScheme); + + bool report_raw_headers = false; + RenderFrameDevToolsAgentHost::ApplyOverrides( + frame_tree_node_, begin_params_.get(), &report_raw_headers); + RenderFrameDevToolsAgentHost::OnNavigationRequestWillBeSent(*this); + + loader_ = NavigationURLLoader::Create( + browser_context->GetResourceContext(), partition, + std::make_unique( + common_params_, begin_params_.Clone(), site_for_cookies, + frame_tree_node_->IsMainFrame(), parent_is_main_frame, + IsSecureFrame(frame_tree_node_->parent()), + frame_tree_node_->frame_tree_node_id(), is_for_guests_only, + report_raw_headers, + navigating_frame_host->GetVisibilityState() == + blink::mojom::PageVisibilityState::kPrerender, + upgrade_if_insecure_, + blob_url_loader_factory_ ? blob_url_loader_factory_->Clone() + : nullptr, + devtools_navigation_token(), + frame_tree_node_->devtools_frame_token()), + std::move(navigation_ui_data), + navigation_handle_->service_worker_handle(), + navigation_handle_->appcache_handle(), this); +} +",1,"void NavigationRequest::OnStartChecksComplete( + NavigationThrottle::ThrottleCheckResult result) { + DCHECK(result.action() != NavigationThrottle::DEFER); + DCHECK(result.action() != NavigationThrottle::BLOCK_RESPONSE); + + if (on_start_checks_complete_closure_) + on_start_checks_complete_closure_.Run(); + if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE || + result.action() == NavigationThrottle::CANCEL || + result.action() == NavigationThrottle::BLOCK_REQUEST || + result.action() == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) { +#if DCHECK_IS_ON() + if (result.action() == NavigationThrottle::BLOCK_REQUEST) { + DCHECK(result.net_error_code() == net::ERR_BLOCKED_BY_CLIENT || + result.net_error_code() == net::ERR_BLOCKED_BY_ADMINISTRATOR); + } + else if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE) { + DCHECK_EQ(result.net_error_code(), net::ERR_ABORTED); + } +#endif + + bool collapse_frame = + result.action() == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE; + + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::BindOnce( + &NavigationRequest::OnRequestFailedInternal, + weak_factory_.GetWeakPtr(), + network::URLLoaderCompletionStatus(result.net_error_code()), + true /* skip_throttles */, result.error_page_content(), + collapse_frame)); + + return; + } + + DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); + RenderFrameHostImpl* navigating_frame_host = + associated_site_instance_type_ == AssociatedSiteInstanceType::SPECULATIVE + ? frame_tree_node_->render_manager()->speculative_frame_host() + : frame_tree_node_->current_frame_host(); + DCHECK(navigating_frame_host); + + navigation_handle_->SetExpectedProcess(navigating_frame_host->GetProcess()); + + BrowserContext* browser_context = + frame_tree_node_->navigator()->GetController()->GetBrowserContext(); + StoragePartition* partition = BrowserContext::GetStoragePartition( + browser_context, navigating_frame_host->GetSiteInstance()); + DCHECK(partition); + + DCHECK(!loader_); + + bool can_create_service_worker = + (frame_tree_node_->pending_frame_policy().sandbox_flags & + blink::WebSandboxFlags::kOrigin) != blink::WebSandboxFlags::kOrigin; + request_params_.should_create_service_worker = can_create_service_worker; + if (can_create_service_worker) { + ServiceWorkerContextWrapper* service_worker_context = + static_cast( + partition->GetServiceWorkerContext()); + navigation_handle_->InitServiceWorkerHandle(service_worker_context); + } + + if (IsSchemeSupportedForAppCache(common_params_.url)) { + if (navigating_frame_host->GetRenderViewHost() + ->GetWebkitPreferences() + .application_cache_enabled) { + navigation_handle_->InitAppCacheHandle( + static_cast(partition->GetAppCacheService())); + } + } + + request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); + + GURL base_url; +#if defined(OS_ANDROID) + NavigationEntry* last_committed_entry = + frame_tree_node_->navigator()->GetController()->GetLastCommittedEntry(); + if (last_committed_entry) + base_url = last_committed_entry->GetBaseURLForDataURL(); +#endif + const GURL& top_document_url = + !base_url.is_empty() + ? base_url + : frame_tree_node_->frame_tree()->root()->current_url(); + + // not, the |site_for_cookies| is set to an opaque URL. + const FrameTreeNode* current = frame_tree_node_->parent(); + bool ancestors_are_same_site = true; + while (current && ancestors_are_same_site) { + if (!net::registry_controlled_domains::SameDomainOrHost( + top_document_url, current->current_url(), + net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) { + ancestors_are_same_site = false; + } + current = current->parent(); + } + + const GURL& site_for_cookies = + (ancestors_are_same_site || !base_url.is_empty()) + ? (frame_tree_node_->IsMainFrame() ? common_params_.url + : top_document_url) + : GURL(""data:,""); + bool parent_is_main_frame = !frame_tree_node_->parent() + ? false + : frame_tree_node_->parent()->IsMainFrame(); + + std::unique_ptr navigation_ui_data; + if (navigation_handle_->GetNavigationUIData()) + navigation_ui_data = navigation_handle_->GetNavigationUIData()->Clone(); + + bool is_for_guests_only = + navigation_handle_->GetStartingSiteInstance()->GetSiteURL(). + SchemeIs(kGuestScheme); + + bool report_raw_headers = false; + RenderFrameDevToolsAgentHost::ApplyOverrides( + frame_tree_node_, begin_params_.get(), &report_raw_headers); + RenderFrameDevToolsAgentHost::OnNavigationRequestWillBeSent(*this); + + loader_ = NavigationURLLoader::Create( + browser_context->GetResourceContext(), partition, + std::make_unique( + common_params_, begin_params_.Clone(), site_for_cookies, + frame_tree_node_->IsMainFrame(), parent_is_main_frame, + IsSecureFrame(frame_tree_node_->parent()), + frame_tree_node_->frame_tree_node_id(), is_for_guests_only, + report_raw_headers, + navigating_frame_host->GetVisibilityState() == + blink::mojom::PageVisibilityState::kPrerender, + upgrade_if_insecure_, + blob_url_loader_factory_ ? blob_url_loader_factory_->Clone() + : nullptr, + devtools_navigation_token(), + frame_tree_node_->devtools_frame_token()), + std::move(navigation_ui_data), + navigation_handle_->service_worker_handle(), + navigation_handle_->appcache_handle(), this); +} +","@@ -1345,7 +1345,7 @@ void NavigationRequest::OnStartChecksComplete( + : frame_tree_node_->frame_tree()->root()->current_url(); + + // Walk the ancestor chain to determine whether all frames are same-site. If +- // not, the |site_for_cookies| is set to an empty URL. ++ // not, the |site_for_cookies| is set to an opaque URL. + // + // TODO(mkwst): This is incorrect. It ought to use the definition from + // 'Document::SiteForCookies()' in Blink, which special-cases extension +@@ -1360,11 +1360,12 @@ void NavigationRequest::OnStartChecksComplete( + } + current = current->parent(); + } ++ + const GURL& site_for_cookies = +- ancestors_are_same_site ++ (ancestors_are_same_site || !base_url.is_empty()) + ? (frame_tree_node_->IsMainFrame() ? common_params_.url + : top_document_url) +- : GURL::EmptyGURL(); ++ : GURL(""data:,""); + bool parent_is_main_frame = !frame_tree_node_->parent() + ? false + : frame_tree_node_->parent()->IsMainFrame();",1205,1441,2048 +16346,"void NavigationControllerImpl::LoadURLWithParams(const LoadURLParams& params) { + TRACE_EVENT1(""browser,navigation"", + ""NavigationControllerImpl::LoadURLWithParams"", + ""url"", params.url.possibly_invalid_spec()); + if (HandleDebugURL(params.url, params.transition_type)) { + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( + cc::switches::kEnableGpuBenchmarking)) + return; + } + + switch (params.load_type) { + case LOAD_TYPE_DEFAULT: + case LOAD_TYPE_HTTP_POST: + break; + case LOAD_TYPE_DATA: + if (!params.url.SchemeIs(url::kDataScheme)) { + NOTREACHED() << ""Data load must use data scheme.""; + return; + } + break; + default: + NOTREACHED(); + break; + }; + + needs_reload_ = false; + + bool override = false; + switch (params.override_user_agent) { + case UA_OVERRIDE_INHERIT: + override = ShouldKeepOverride(GetLastCommittedEntry()); + break; + case UA_OVERRIDE_TRUE: + override = true; + break; + case UA_OVERRIDE_FALSE: + override = false; + break; + default: + NOTREACHED(); + break; + } + + std::unique_ptr entry; + + int frame_tree_node_id = params.frame_tree_node_id; + if (frame_tree_node_id != -1 || !params.frame_name.empty()) { + FrameTreeNode* node = + params.frame_tree_node_id != -1 + ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) + : delegate_->GetFrameTree()->FindByName(params.frame_name); + if (node && !node->IsMainFrame()) { + DCHECK(GetLastCommittedEntry()); + + frame_tree_node_id = node->frame_tree_node_id(); + + entry = GetLastCommittedEntry()->Clone(); + entry->AddOrUpdateFrameEntry( + node, -1, -1, nullptr, + static_cast(params.source_site_instance.get()), + params.url, params.referrer, params.redirect_chain, PageState(), + ""GET"", -1); + } + } + + if (!entry) { + std::string extra_headers_crlf; + base::ReplaceChars(params.extra_headers, ""\n"", ""\r\n"", &extra_headers_crlf); + entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( + params.url, params.referrer, params.transition_type, + params.is_renderer_initiated, extra_headers_crlf, browser_context_)); + entry->set_source_site_instance( + static_cast(params.source_site_instance.get())); + entry->SetRedirectChain(params.redirect_chain); + } + + entry->set_frame_tree_node_id(frame_tree_node_id); + if (params.should_replace_current_entry && entries_.size() > 0) + entry->set_should_replace_entry(true); + entry->set_should_clear_history_list(params.should_clear_history_list); + entry->SetIsOverridingUserAgent(override); + entry->set_transferred_global_request_id( + params.transferred_global_request_id); + +#if defined(OS_ANDROID) + if (params.intent_received_timestamp > 0) { + entry->set_intent_received_timestamp( + base::TimeTicks() + + base::TimeDelta::FromMilliseconds(params.intent_received_timestamp)); + } + entry->set_has_user_gesture(params.has_user_gesture); +#endif + + switch (params.load_type) { + case LOAD_TYPE_DEFAULT: + break; + case LOAD_TYPE_HTTP_POST: + entry->SetHasPostData(true); + entry->SetPostData(params.post_data); + break; + case LOAD_TYPE_DATA: + entry->SetBaseURLForDataURL(params.base_url_for_data_url); + entry->SetVirtualURL(params.virtual_url_for_data_url); +#if defined(OS_ANDROID) + entry->SetDataURLAsString(params.data_url_as_string); +#endif + entry->SetCanLoadLocalResources(params.can_load_local_resources); + break; + default: + NOTREACHED(); + break; + }; + + entry->set_started_from_context_menu(params.started_from_context_menu); + LoadEntry(std::move(entry)); +} +",0,"void NavigationControllerImpl::LoadURLWithParams(const LoadURLParams& params) { + TRACE_EVENT1(""browser,navigation"", + ""NavigationControllerImpl::LoadURLWithParams"", + ""url"", params.url.possibly_invalid_spec()); + if (HandleDebugURL(params.url, params.transition_type)) { + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( + cc::switches::kEnableGpuBenchmarking)) + return; + } + + switch (params.load_type) { + case LOAD_TYPE_DEFAULT: + case LOAD_TYPE_HTTP_POST: + break; + case LOAD_TYPE_DATA: + if (!params.url.SchemeIs(url::kDataScheme)) { + NOTREACHED() << ""Data load must use data scheme.""; + return; + } + break; + default: + NOTREACHED(); + break; + }; + + needs_reload_ = false; + + bool override = false; + switch (params.override_user_agent) { + case UA_OVERRIDE_INHERIT: + override = ShouldKeepOverride(GetLastCommittedEntry()); + break; + case UA_OVERRIDE_TRUE: + override = true; + break; + case UA_OVERRIDE_FALSE: + override = false; + break; + default: + NOTREACHED(); + break; + } + + std::unique_ptr entry; + + int frame_tree_node_id = params.frame_tree_node_id; + if (frame_tree_node_id != -1 || !params.frame_name.empty()) { + FrameTreeNode* node = + params.frame_tree_node_id != -1 + ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) + : delegate_->GetFrameTree()->FindByName(params.frame_name); + if (node && !node->IsMainFrame()) { + DCHECK(GetLastCommittedEntry()); + + frame_tree_node_id = node->frame_tree_node_id(); + + entry = GetLastCommittedEntry()->Clone(); + entry->AddOrUpdateFrameEntry( + node, -1, -1, nullptr, + static_cast(params.source_site_instance.get()), + params.url, params.referrer, params.redirect_chain, PageState(), + ""GET"", -1); + } + } + + if (!entry) { + std::string extra_headers_crlf; + base::ReplaceChars(params.extra_headers, ""\n"", ""\r\n"", &extra_headers_crlf); + entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( + params.url, params.referrer, params.transition_type, + params.is_renderer_initiated, extra_headers_crlf, browser_context_)); + entry->set_source_site_instance( + static_cast(params.source_site_instance.get())); + entry->SetRedirectChain(params.redirect_chain); + } + + entry->set_frame_tree_node_id(frame_tree_node_id); + if (params.should_replace_current_entry && entries_.size() > 0) + entry->set_should_replace_entry(true); + entry->set_should_clear_history_list(params.should_clear_history_list); + entry->SetIsOverridingUserAgent(override); + entry->set_transferred_global_request_id( + params.transferred_global_request_id); + +#if defined(OS_ANDROID) + if (params.intent_received_timestamp > 0) { + entry->set_intent_received_timestamp( + base::TimeTicks() + + base::TimeDelta::FromMilliseconds(params.intent_received_timestamp)); + } + entry->set_has_user_gesture(params.has_user_gesture); +#endif + + switch (params.load_type) { + case LOAD_TYPE_DEFAULT: + break; + case LOAD_TYPE_HTTP_POST: + entry->SetHasPostData(true); + entry->SetPostData(params.post_data); + break; + case LOAD_TYPE_DATA: + entry->SetBaseURLForDataURL(params.base_url_for_data_url); + entry->SetVirtualURL(params.virtual_url_for_data_url); +#if defined(OS_ANDROID) + entry->SetDataURLAsString(params.data_url_as_string); +#endif + entry->SetCanLoadLocalResources(params.can_load_local_resources); + break; + default: + NOTREACHED(); + break; + }; + + entry->set_started_from_context_menu(params.started_from_context_menu); + LoadEntry(std::move(entry)); +} +","@@ -159,26 +159,6 @@ bool ShouldTreatNavigationAsReload(const NavigationEntry* entry) { + return false; + } + +-// Returns true if the error code indicates an error condition that is not +-// recoverable or navigation is blocked. In such cases, session history +-// navigations to the same NavigationEntry should not attempt to load the +-// original URL. +-// TODO(nasko): Find a better way to distinguish blocked vs failed navigations, +-// as this is a very hacky way of accomplishing this. For now, a handful of +-// error codes are considered, which are more or less known to be cases of +-// blocked navigations. +-bool IsBlockedNavigation(net::Error error_code) { +- switch (error_code) { +- case net::ERR_BLOCKED_BY_CLIENT: +- case net::ERR_BLOCKED_BY_RESPONSE: +- case net::ERR_BLOCKED_BY_XSS_AUDITOR: +- case net::ERR_UNSAFE_REDIRECT: +- return true; +- default: +- return false; +- } +-} +- + } // namespace + + // NavigationControllerImpl ---------------------------------------------------- +@@ -950,24 +930,6 @@ bool NavigationControllerImpl::RendererDidNavigate( + DCHECK(params.page_state == frame_entry->page_state()); + } + +- // When a navigation in the main frame is blocked, it will display an error +- // page. To avoid loading the blocked URL on back/forward navigations, +- // do not store it in the FrameNavigationEntry's URL or PageState. Instead, +- // make it visible to the user as the virtual URL. Store a safe URL +- // (about:blank) as the one to load if the entry is revisited. +- // TODO(nasko): Consider supporting similar behavior for subframe +- // navigations, including AUTO_SUBFRAME. +- if (!rfh->GetParent() && +- IsBlockedNavigation(navigation_handle->GetNetErrorCode())) { +- DCHECK(params.url_is_unreachable); +- active_entry->SetURL(GURL(url::kAboutBlankURL)); +- active_entry->SetVirtualURL(params.url); +- if (frame_entry) { +- frame_entry->SetPageState( +- PageState::CreateFromURL(active_entry->GetURL())); +- } +- } +- + // Use histogram to track memory impact of redirect chain because it's now + // not cleared for committed entries. + size_t redirect_chain_size = 0;",865,1101,2048 +17846,"polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority *authority, + PolkitSubject *caller, + PolkitSubject *subject, + const gchar *action_id, + PolkitDetails *details, + PolkitCheckAuthorizationFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + PolkitBackendInteractiveAuthority *interactive_authority; + PolkitBackendInteractiveAuthorityPrivate *priv; + gchar *caller_str; + gchar *subject_str; + PolkitIdentity *user_of_caller; + PolkitIdentity *user_of_subject; + gchar *user_of_caller_str; + gchar *user_of_subject_str; + PolkitAuthorizationResult *result; + GError *error; + GSimpleAsyncResult *simple; + gboolean has_details; + gchar **detail_keys; + + interactive_authority = POLKIT_BACKEND_INTERACTIVE_AUTHORITY (authority); + priv = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_PRIVATE (interactive_authority); + + error = NULL; + caller_str = NULL; + subject_str = NULL; + user_of_caller = NULL; + user_of_subject = NULL; + user_of_caller_str = NULL; + user_of_subject_str = NULL; + result = NULL; + + simple = g_simple_async_result_new (G_OBJECT (authority), + callback, + user_data, + polkit_backend_interactive_authority_check_authorization); + + /* handle being called from ourselves */ + if (caller == NULL) + { + /* TODO: this is kind of a hack */ + GDBusConnection *system_bus; + system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); + caller = polkit_system_bus_name_new (g_dbus_connection_get_unique_name (system_bus)); + g_object_unref (system_bus); + } + + caller_str = polkit_subject_to_string (caller); + subject_str = polkit_subject_to_string (subject); + + g_debug (""%s is inquiring whether %s is authorized for %s"", + caller_str, + subject_str, + action_id); + action_id); + + user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, + caller, + &error); + if (error != NULL) + { + g_simple_async_result_complete (simple); + g_object_unref (simple); + g_error_free (error); + goto out; + } + + user_of_caller_str = polkit_identity_to_string (user_of_caller); + g_debug ("" user of caller is %s"", user_of_caller_str); + g_debug ("" user of caller is %s"", user_of_caller_str); + + user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, + subject, + &error); + if (error != NULL) + { + g_simple_async_result_complete (simple); + g_object_unref (simple); + g_error_free (error); + goto out; + } + + user_of_subject_str = polkit_identity_to_string (user_of_subject); + g_debug ("" user of subject is %s"", user_of_subject_str); + + has_details = FALSE; + if (details != NULL) + { + detail_keys = polkit_details_get_keys (details); + if (detail_keys != NULL) + { + if (g_strv_length (detail_keys) > 0) + has_details = TRUE; + g_strfreev (detail_keys); + } + } + + /* Not anyone is allowed to check that process XYZ is allowed to do ABC. + * We only allow this if, and only if, + * We only allow this if, and only if, + * + * - processes may check for another process owned by the *same* user but not + * if details are passed (otherwise you'd be able to spoof the dialog) + * + * - processes running as uid 0 may check anything and pass any details + * + if (!polkit_identity_equal (user_of_caller, user_of_subject) || has_details) + * then any uid referenced by that annotation is also allowed to check + * to check anything and pass any details + */ + if (!polkit_identity_equal (user_of_caller, user_of_subject) || has_details) + { + if (!may_identity_check_authorization (interactive_authority, action_id, user_of_caller)) + { + ""pass details""); + } + else + { + g_simple_async_result_set_error (simple, + POLKIT_ERROR, + POLKIT_ERROR_NOT_AUTHORIZED, + ""Only trusted callers (e.g. uid 0 or an action owner) can use CheckAuthorization() for "" + ""subjects belonging to other identities""); + } + g_simple_async_result_complete (simple); + g_object_unref (simple); + goto out; + } + } +",1,"polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority *authority, + PolkitSubject *caller, + PolkitSubject *subject, + const gchar *action_id, + PolkitDetails *details, + PolkitCheckAuthorizationFlags flags, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + PolkitBackendInteractiveAuthority *interactive_authority; + PolkitBackendInteractiveAuthorityPrivate *priv; + gchar *caller_str; + gchar *subject_str; + PolkitIdentity *user_of_caller; + PolkitIdentity *user_of_subject; + gboolean user_of_subject_matches; + gchar *user_of_caller_str; + gchar *user_of_subject_str; + PolkitAuthorizationResult *result; + GError *error; + GSimpleAsyncResult *simple; + gboolean has_details; + gchar **detail_keys; + + interactive_authority = POLKIT_BACKEND_INTERACTIVE_AUTHORITY (authority); + priv = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_PRIVATE (interactive_authority); + + error = NULL; + caller_str = NULL; + subject_str = NULL; + user_of_caller = NULL; + user_of_subject = NULL; + user_of_caller_str = NULL; + user_of_subject_str = NULL; + result = NULL; + + simple = g_simple_async_result_new (G_OBJECT (authority), + callback, + user_data, + polkit_backend_interactive_authority_check_authorization); + + /* handle being called from ourselves */ + if (caller == NULL) + { + /* TODO: this is kind of a hack */ + GDBusConnection *system_bus; + system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); + caller = polkit_system_bus_name_new (g_dbus_connection_get_unique_name (system_bus)); + g_object_unref (system_bus); + } + + caller_str = polkit_subject_to_string (caller); + subject_str = polkit_subject_to_string (subject); + + g_debug (""%s is inquiring whether %s is authorized for %s"", + caller_str, + subject_str, + action_id); + action_id); + + user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, + caller, NULL, + &error); + if (error != NULL) + { + g_simple_async_result_complete (simple); + g_object_unref (simple); + g_error_free (error); + goto out; + } + + user_of_caller_str = polkit_identity_to_string (user_of_caller); + g_debug ("" user of caller is %s"", user_of_caller_str); + g_debug ("" user of caller is %s"", user_of_caller_str); + + user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, + subject, &user_of_subject_matches, + &error); + if (error != NULL) + { + g_simple_async_result_complete (simple); + g_object_unref (simple); + g_error_free (error); + goto out; + } + + user_of_subject_str = polkit_identity_to_string (user_of_subject); + g_debug ("" user of subject is %s"", user_of_subject_str); + + has_details = FALSE; + if (details != NULL) + { + detail_keys = polkit_details_get_keys (details); + if (detail_keys != NULL) + { + if (g_strv_length (detail_keys) > 0) + has_details = TRUE; + g_strfreev (detail_keys); + } + } + + /* Not anyone is allowed to check that process XYZ is allowed to do ABC. + * We only allow this if, and only if, + * We only allow this if, and only if, + * + * - processes may check for another process owned by the *same* user but not + * if details are passed (otherwise you'd be able to spoof the dialog); + * the caller supplies the user_of_subject value, so we additionally + * require it to match at least at one point in time (via + * user_of_subject_matches). + * + * - processes running as uid 0 may check anything and pass any details + * + if (!polkit_identity_equal (user_of_caller, user_of_subject) || has_details) + * then any uid referenced by that annotation is also allowed to check + * to check anything and pass any details + */ + if (!user_of_subject_matches + || !polkit_identity_equal (user_of_caller, user_of_subject) + || has_details) + { + if (!may_identity_check_authorization (interactive_authority, action_id, user_of_caller)) + { + ""pass details""); + } + else + { + g_simple_async_result_set_error (simple, + POLKIT_ERROR, + POLKIT_ERROR_NOT_AUTHORIZED, + ""Only trusted callers (e.g. uid 0 or an action owner) can use CheckAuthorization() for "" + ""subjects belonging to other identities""); + } + g_simple_async_result_complete (simple); + g_object_unref (simple); + goto out; + } + } +","@@ -575,7 +575,7 @@ log_result (PolkitBackendInteractiveAuthority *authority, + if (polkit_authorization_result_get_is_authorized (result)) + log_result_str = ""ALLOWING""; + +- user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, subject, NULL); ++ user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, subject, NULL, NULL); + + subject_str = polkit_subject_to_string (subject); + +@@ -847,6 +847,7 @@ polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority + gchar *subject_str; + PolkitIdentity *user_of_caller; + PolkitIdentity *user_of_subject; ++ gboolean user_of_subject_matches; + gchar *user_of_caller_str; + gchar *user_of_subject_str; + PolkitAuthorizationResult *result; +@@ -892,7 +893,7 @@ polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority + action_id); + + user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, +- caller, ++ caller, NULL, + &error); + if (error != NULL) + { +@@ -907,7 +908,7 @@ polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority + g_debug ("" user of caller is %s"", user_of_caller_str); + + user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, +- subject, ++ subject, &user_of_subject_matches, + &error); + if (error != NULL) + { +@@ -937,7 +938,10 @@ polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority + * We only allow this if, and only if, + * + * - processes may check for another process owned by the *same* user but not +- * if details are passed (otherwise you'd be able to spoof the dialog) ++ * if details are passed (otherwise you'd be able to spoof the dialog); ++ * the caller supplies the user_of_subject value, so we additionally ++ * require it to match at least at one point in time (via ++ * user_of_subject_matches). + * + * - processes running as uid 0 may check anything and pass any details + * +@@ -945,7 +949,9 @@ polkit_backend_interactive_authority_check_authorization (PolkitBackendAuthority + * then any uid referenced by that annotation is also allowed to check + * to check anything and pass any details + */ +- if (!polkit_identity_equal (user_of_caller, user_of_subject) || has_details) ++ if (!user_of_subject_matches ++ || !polkit_identity_equal (user_of_caller, user_of_subject) ++ || has_details) + { + if (!may_identity_check_authorization (interactive_authority, action_id, user_of_caller)) + { +@@ -1110,9 +1116,10 @@ check_authorization_sync (PolkitBackendAuthority *authority, + goto out; + } + +- /* every subject has a user */ ++ /* every subject has a user; this is supplied by the client, so we rely ++ * on the caller to validate its acceptability. */ + user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, +- subject, ++ subject, NULL, + error); + if (user_of_subject == NULL) + goto out; +@@ -2480,6 +2487,7 @@ polkit_backend_interactive_authority_register_authentication_agent (PolkitBacken + PolkitSubject *session_for_caller; + PolkitIdentity *user_of_caller; + PolkitIdentity *user_of_subject; ++ gboolean user_of_subject_matches; + AuthenticationAgent *agent; + gboolean ret; + gchar *caller_cmdline; +@@ -2532,7 +2540,7 @@ polkit_backend_interactive_authority_register_authentication_agent (PolkitBacken + goto out; + } + +- user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, caller, NULL); ++ user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, caller, NULL, NULL); + if (user_of_caller == NULL) + { + g_set_error (error, +@@ -2541,7 +2549,7 @@ polkit_backend_interactive_authority_register_authentication_agent (PolkitBacken + ""Cannot determine user of caller""); + goto out; + } +- user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, subject, NULL); ++ user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, subject, &user_of_subject_matches, NULL); + if (user_of_subject == NULL) + { + g_set_error (error, +@@ -2550,7 +2558,8 @@ polkit_backend_interactive_authority_register_authentication_agent (PolkitBacken + ""Cannot determine user of subject""); + goto out; + } +- if (!polkit_identity_equal (user_of_caller, user_of_subject)) ++ if (!user_of_subject_matches ++ || !polkit_identity_equal (user_of_caller, user_of_subject)) + { + if (identity_is_root_user (user_of_caller)) + { +@@ -2643,6 +2652,7 @@ polkit_backend_interactive_authority_unregister_authentication_agent (PolkitBack + PolkitSubject *session_for_caller; + PolkitIdentity *user_of_caller; + PolkitIdentity *user_of_subject; ++ gboolean user_of_subject_matches; + AuthenticationAgent *agent; + gboolean ret; + gchar *scope_str; +@@ -2691,7 +2701,7 @@ polkit_backend_interactive_authority_unregister_authentication_agent (PolkitBack + goto out; + } + +- user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, caller, NULL); ++ user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, caller, NULL, NULL); + if (user_of_caller == NULL) + { + g_set_error (error, +@@ -2700,7 +2710,7 @@ polkit_backend_interactive_authority_unregister_authentication_agent (PolkitBack + ""Cannot determine user of caller""); + goto out; + } +- user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, subject, NULL); ++ user_of_subject = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, subject, &user_of_subject_matches, NULL); + if (user_of_subject == NULL) + { + g_set_error (error, +@@ -2709,7 +2719,8 @@ polkit_backend_interactive_authority_unregister_authentication_agent (PolkitBack + ""Cannot determine user of subject""); + goto out; + } +- if (!polkit_identity_equal (user_of_caller, user_of_subject)) ++ if (!user_of_subject_matches ++ || !polkit_identity_equal (user_of_caller, user_of_subject)) + { + if (identity_is_root_user (user_of_caller)) + { +@@ -2819,7 +2830,7 @@ polkit_backend_interactive_authority_authentication_agent_response (PolkitBacken + identity_str); + + user_of_caller = polkit_backend_session_monitor_get_user_for_subject (priv->session_monitor, +- caller, ++ caller, NULL, + error); + if (user_of_caller == NULL) + goto out;",1025,1261,2048 +8877,"MagickExport MagickBooleanType ClutImage(Image *image,const Image *clut_image, + const PixelInterpolateMethod method,ExceptionInfo *exception) +{ +#define ClutImageTag ""Clut/Image"" + + CacheView + *clut_view, + *image_view; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + PixelInfo + *clut_map; + + register ssize_t + i; + + ssize_t adjust, + y; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(clut_image != (Image *) NULL); + assert(clut_image->signature == MagickCoreSignature); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + if ((IsGrayColorspace(image->colorspace) != MagickFalse) && + (IsGrayColorspace(clut_image->colorspace) == MagickFalse)) + (void) SetImageColorspace(image,sRGBColorspace,exception); + clut_map=(PixelInfo *) AcquireQuantumMemory(MaxMap+1UL,sizeof(*clut_map)); + if (clut_map == (PixelInfo *) NULL) + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + /* + Clut image. + */ + status=MagickTrue; + progress=0; + adjust=(ssize_t) (clut_image->interpolate == IntegerInterpolatePixel ? 0 : 1); + clut_view=AcquireVirtualCacheView(clut_image,exception); + for (i=0; i <= (ssize_t) MaxMap; i++) + { + GetPixelInfo(clut_image,clut_map+i); + status=InterpolatePixelInfo(clut_image,clut_view,method, + (double) i*(clut_image->columns-adjust)/MaxMap,(double) i* + (clut_image->rows-adjust)/MaxMap,clut_map+i,exception); + if (status == MagickFalse) + break; + } + clut_view=DestroyCacheView(clut_view); + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + PixelInfo + pixel; + + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + GetPixelInfo(image,&pixel); + for (x=0; x < (ssize_t) image->columns; x++) + { + PixelTrait + traits; + + GetPixelInfoPixel(image,q,&pixel); + traits=GetPixelChannelTraits(image,RedPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.red=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.red))].red; + traits=GetPixelChannelTraits(image,GreenPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.green=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.green))].green; + traits=GetPixelChannelTraits(image,BluePixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.blue=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.blue))].blue; + traits=GetPixelChannelTraits(image,BlackPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.black=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.black))].black; + traits=GetPixelChannelTraits(image,AlphaPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.alpha=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.alpha))].alpha; + SetPixelViaPixelInfo(image,&pixel,q); + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,ClutImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + clut_map=(PixelInfo *) RelinquishMagickMemory(clut_map); + if ((clut_image->alpha_trait != UndefinedPixelTrait) && + ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)) + (void) SetImageAlphaChannel(image,ActivateAlphaChannel,exception); + return(status); +} +",0,"MagickExport MagickBooleanType ClutImage(Image *image,const Image *clut_image, + const PixelInterpolateMethod method,ExceptionInfo *exception) +{ +#define ClutImageTag ""Clut/Image"" + + CacheView + *clut_view, + *image_view; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + PixelInfo + *clut_map; + + register ssize_t + i; + + ssize_t adjust, + y; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(clut_image != (Image *) NULL); + assert(clut_image->signature == MagickCoreSignature); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + if ((IsGrayColorspace(image->colorspace) != MagickFalse) && + (IsGrayColorspace(clut_image->colorspace) == MagickFalse)) + (void) SetImageColorspace(image,sRGBColorspace,exception); + clut_map=(PixelInfo *) AcquireQuantumMemory(MaxMap+1UL,sizeof(*clut_map)); + if (clut_map == (PixelInfo *) NULL) + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + /* + Clut image. + */ + status=MagickTrue; + progress=0; + adjust=(ssize_t) (clut_image->interpolate == IntegerInterpolatePixel ? 0 : 1); + clut_view=AcquireVirtualCacheView(clut_image,exception); + for (i=0; i <= (ssize_t) MaxMap; i++) + { + GetPixelInfo(clut_image,clut_map+i); + status=InterpolatePixelInfo(clut_image,clut_view,method, + (double) i*(clut_image->columns-adjust)/MaxMap,(double) i* + (clut_image->rows-adjust)/MaxMap,clut_map+i,exception); + if (status == MagickFalse) + break; + } + clut_view=DestroyCacheView(clut_view); + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + PixelInfo + pixel; + + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + GetPixelInfo(image,&pixel); + for (x=0; x < (ssize_t) image->columns; x++) + { + PixelTrait + traits; + + GetPixelInfoPixel(image,q,&pixel); + traits=GetPixelChannelTraits(image,RedPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.red=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.red))].red; + traits=GetPixelChannelTraits(image,GreenPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.green=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.green))].green; + traits=GetPixelChannelTraits(image,BluePixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.blue=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.blue))].blue; + traits=GetPixelChannelTraits(image,BlackPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.black=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.black))].black; + traits=GetPixelChannelTraits(image,AlphaPixelChannel); + if ((traits & UpdatePixelTrait) != 0) + pixel.alpha=clut_map[ScaleQuantumToMap(ClampToQuantum( + pixel.alpha))].alpha; + SetPixelViaPixelInfo(image,&pixel,q); + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,ClutImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + clut_map=(PixelInfo *) RelinquishMagickMemory(clut_map); + if ((clut_image->alpha_trait != UndefinedPixelTrait) && + ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)) + (void) SetImageAlphaChannel(image,ActivateAlphaChannel,exception); + return(status); +} +","@@ -1973,7 +1973,7 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception) + pixel.black=((aggregate.black+total_weight/2.0)/total_weight); + pixel.alpha=((aggregate.alpha+total_weight/2.0)/total_weight); + } +- SetPixelViaPixelInfo(image,&pixel,q); ++ SetPixelViaPixelInfo(enhance_image,&pixel,q); + p+=GetPixelChannels(image); + q+=GetPixelChannels(enhance_image); + }",1158,1394,2048 +17950,"cifs_iovec_write(struct file *file, const struct iovec *iov, + unsigned long nr_segs, loff_t *poffset) + { + unsigned long nr_pages, i; + size_t copied, len, cur_len; + ssize_t total_written = 0; + loff_t offset; + struct iov_iter it; + struct cifsFileInfo *open_file; + struct cifs_tcon *tcon; + struct cifs_sb_info *cifs_sb; + struct cifs_writedata *wdata, *tmp; + struct list_head wdata_list; + int rc; + pid_t pid; + + len = iov_length(iov, nr_segs); + if (!len) + return 0; + + rc = generic_write_checks(file, poffset, &len, 0); + if (rc) + return rc; + + INIT_LIST_HEAD(&wdata_list); + cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); + open_file = file->private_data; + tcon = tlink_tcon(open_file->tlink); + + if (!tcon->ses->server->ops->async_writev) + return -ENOSYS; + + offset = *poffset; + + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) + pid = open_file->pid; + else + pid = current->tgid; + + iov_iter_init(&it, iov, nr_segs, len, 0); + do { + size_t save_len; + + nr_pages = get_numpages(cifs_sb->wsize, len, &cur_len); + wdata = cifs_writedata_alloc(nr_pages, + cifs_uncached_writev_complete); + if (!wdata) { + rc = -ENOMEM; + break; + } + + rc = cifs_write_allocate_pages(wdata->pages, nr_pages); + if (rc) { + kfree(wdata); + break; + } + + save_len = cur_len; + for (i = 0; i < nr_pages; i++) { + copied = min_t(const size_t, cur_len, PAGE_SIZE); + copied = iov_iter_copy_from_user(wdata->pages[i], &it, + 0, copied); + cur_len -= copied; + iov_iter_advance(&it, copied); + } + cur_len = save_len - cur_len; + + wdata->sync_mode = WB_SYNC_ALL; + wdata->nr_pages = nr_pages; + wdata->offset = (__u64)offset; + wdata->cfile = cifsFileInfo_get(open_file); + wdata->pid = pid; + wdata->bytes = cur_len; + wdata->pagesz = PAGE_SIZE; + wdata->tailsz = cur_len - ((nr_pages - 1) * PAGE_SIZE); + rc = cifs_uncached_retry_writev(wdata); + if (rc) { + kref_put(&wdata->refcount, + cifs_uncached_writedata_release); + break; + } + + list_add_tail(&wdata->list, &wdata_list); + offset += cur_len; + len -= cur_len; + } while (len > 0); + + /* + * If at least one write was successfully sent, then discard any rc + * value from the later writes. If the other write succeeds, then + * we'll end up returning whatever was written. If it fails, then + * we'll get a new rc value from that. + */ + if (!list_empty(&wdata_list)) + rc = 0; + + /* + * Wait for and collect replies for any successful sends in order of + * increasing offset. Once an error is hit or we get a fatal signal + * while waiting, then return without waiting for any more replies. + */ +restart_loop: + list_for_each_entry_safe(wdata, tmp, &wdata_list, list) { + if (!rc) { + /* FIXME: freezable too? */ + rc = wait_for_completion_killable(&wdata->done); + if (rc) + rc = -EINTR; + else if (wdata->result) + rc = wdata->result; + else + total_written += wdata->bytes; + + /* resend call if it's a retryable error */ + if (rc == -EAGAIN) { + rc = cifs_uncached_retry_writev(wdata); + goto restart_loop; + } + } + list_del_init(&wdata->list); + kref_put(&wdata->refcount, cifs_uncached_writedata_release); + } + + if (total_written > 0) + *poffset += total_written; + + cifs_stats_bytes_written(tcon, total_written); + return total_written ? total_written : (ssize_t)rc; +} +",1,"cifs_iovec_write(struct file *file, const struct iovec *iov, + unsigned long nr_segs, loff_t *poffset) + { + unsigned long nr_pages, i; + size_t bytes, copied, len, cur_len; + ssize_t total_written = 0; + loff_t offset; + struct iov_iter it; + struct cifsFileInfo *open_file; + struct cifs_tcon *tcon; + struct cifs_sb_info *cifs_sb; + struct cifs_writedata *wdata, *tmp; + struct list_head wdata_list; + int rc; + pid_t pid; + + len = iov_length(iov, nr_segs); + if (!len) + return 0; + + rc = generic_write_checks(file, poffset, &len, 0); + if (rc) + return rc; + + INIT_LIST_HEAD(&wdata_list); + cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); + open_file = file->private_data; + tcon = tlink_tcon(open_file->tlink); + + if (!tcon->ses->server->ops->async_writev) + return -ENOSYS; + + offset = *poffset; + + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) + pid = open_file->pid; + else + pid = current->tgid; + + iov_iter_init(&it, iov, nr_segs, len, 0); + do { + size_t save_len; + + nr_pages = get_numpages(cifs_sb->wsize, len, &cur_len); + wdata = cifs_writedata_alloc(nr_pages, + cifs_uncached_writev_complete); + if (!wdata) { + rc = -ENOMEM; + break; + } + + rc = cifs_write_allocate_pages(wdata->pages, nr_pages); + if (rc) { + kfree(wdata); + break; + } + + save_len = cur_len; + for (i = 0; i < nr_pages; i++) { + bytes = min_t(const size_t, cur_len, PAGE_SIZE); + copied = iov_iter_copy_from_user(wdata->pages[i], &it, + 0, bytes); + cur_len -= copied; + iov_iter_advance(&it, copied); + /* + * If we didn't copy as much as we expected, then that + * may mean we trod into an unmapped area. Stop copying + * at that point. On the next pass through the big + * loop, we'll likely end up getting a zero-length + * write and bailing out of it. + */ + if (copied < bytes) + break; + } + cur_len = save_len - cur_len; + + /* + * If we have no data to send, then that probably means that + * the copy above failed altogether. That's most likely because + * the address in the iovec was bogus. Set the rc to -EFAULT, + * free anything we allocated and bail out. + */ + if (!cur_len) { + for (i = 0; i < nr_pages; i++) + put_page(wdata->pages[i]); + kfree(wdata); + rc = -EFAULT; + break; + } + + /* + * i + 1 now represents the number of pages we actually used in + * the copy phase above. Bring nr_pages down to that, and free + * any pages that we didn't use. + */ + for ( ; nr_pages > i + 1; nr_pages--) + put_page(wdata->pages[nr_pages - 1]); + + wdata->sync_mode = WB_SYNC_ALL; + wdata->nr_pages = nr_pages; + wdata->offset = (__u64)offset; + wdata->cfile = cifsFileInfo_get(open_file); + wdata->pid = pid; + wdata->bytes = cur_len; + wdata->pagesz = PAGE_SIZE; + wdata->tailsz = cur_len - ((nr_pages - 1) * PAGE_SIZE); + rc = cifs_uncached_retry_writev(wdata); + if (rc) { + kref_put(&wdata->refcount, + cifs_uncached_writedata_release); + break; + } + + list_add_tail(&wdata->list, &wdata_list); + offset += cur_len; + len -= cur_len; + } while (len > 0); + + /* + * If at least one write was successfully sent, then discard any rc + * value from the later writes. If the other write succeeds, then + * we'll end up returning whatever was written. If it fails, then + * we'll get a new rc value from that. + */ + if (!list_empty(&wdata_list)) + rc = 0; + + /* + * Wait for and collect replies for any successful sends in order of + * increasing offset. Once an error is hit or we get a fatal signal + * while waiting, then return without waiting for any more replies. + */ +restart_loop: + list_for_each_entry_safe(wdata, tmp, &wdata_list, list) { + if (!rc) { + /* FIXME: freezable too? */ + rc = wait_for_completion_killable(&wdata->done); + if (rc) + rc = -EINTR; + else if (wdata->result) + rc = wdata->result; + else + total_written += wdata->bytes; + + /* resend call if it's a retryable error */ + if (rc == -EAGAIN) { + rc = cifs_uncached_retry_writev(wdata); + goto restart_loop; + } + } + list_del_init(&wdata->list); + kref_put(&wdata->refcount, cifs_uncached_writedata_release); + } + + if (total_written > 0) + *poffset += total_written; + + cifs_stats_bytes_written(tcon, total_written); + return total_written ? total_written : (ssize_t)rc; +} +","@@ -2389,7 +2389,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, + unsigned long nr_segs, loff_t *poffset) + { + unsigned long nr_pages, i; +- size_t copied, len, cur_len; ++ size_t bytes, copied, len, cur_len; + ssize_t total_written = 0; + loff_t offset; + struct iov_iter it; +@@ -2444,14 +2444,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, + + save_len = cur_len; + for (i = 0; i < nr_pages; i++) { +- copied = min_t(const size_t, cur_len, PAGE_SIZE); ++ bytes = min_t(const size_t, cur_len, PAGE_SIZE); + copied = iov_iter_copy_from_user(wdata->pages[i], &it, +- 0, copied); ++ 0, bytes); + cur_len -= copied; + iov_iter_advance(&it, copied); ++ /* ++ * If we didn't copy as much as we expected, then that ++ * may mean we trod into an unmapped area. Stop copying ++ * at that point. On the next pass through the big ++ * loop, we'll likely end up getting a zero-length ++ * write and bailing out of it. ++ */ ++ if (copied < bytes) ++ break; + } + cur_len = save_len - cur_len; + ++ /* ++ * If we have no data to send, then that probably means that ++ * the copy above failed altogether. That's most likely because ++ * the address in the iovec was bogus. Set the rc to -EFAULT, ++ * free anything we allocated and bail out. ++ */ ++ if (!cur_len) { ++ for (i = 0; i < nr_pages; i++) ++ put_page(wdata->pages[i]); ++ kfree(wdata); ++ rc = -EFAULT; ++ break; ++ } ++ ++ /* ++ * i + 1 now represents the number of pages we actually used in ++ * the copy phase above. Bring nr_pages down to that, and free ++ * any pages that we didn't use. ++ */ ++ for ( ; nr_pages > i + 1; nr_pages--) ++ put_page(wdata->pages[nr_pages - 1]); ++ + wdata->sync_mode = WB_SYNC_ALL; + wdata->nr_pages = nr_pages; + wdata->offset = (__u64)offset;",1022,1258,2048 +18730,"static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, + const uint8_t *data, + unsigned int data_sz, + void *user_priv, + long deadline) +{ + vpx_codec_err_t res = VPX_CODEC_OK; + unsigned int resolution_change = 0; + unsigned int w, h; + + if (!ctx->fragments.enabled && (data == NULL && data_sz == 0)) + { + return 0; + } + + /* Update the input fragment data */ + if(update_fragments(ctx, data, data_sz, &res) <= 0) + return res; + + /* Determine the stream parameters. Note that we rely on peek_si to + * validate that we have a buffer that does not wrap around the top + * of the heap. + */ + w = ctx->si.w; + h = ctx->si.h; + + res = vp8_peek_si_internal(ctx->fragments.ptrs[0], ctx->fragments.sizes[0], + &ctx->si, ctx->decrypt_cb, ctx->decrypt_state); + + if((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf) + { + /* the peek function returns an error for non keyframes, however for + * this case, it is not an error */ + res = VPX_CODEC_OK; + } + + if(!ctx->decoder_init && !ctx->si.is_kf) + res = VPX_CODEC_UNSUP_BITSTREAM; + + if ((ctx->si.h != h) || (ctx->si.w != w)) + resolution_change = 1; + + /* Initialize the decoder instance on the first frame*/ + if (!res && !ctx->decoder_init) + { + VP8D_CONFIG oxcf; + + oxcf.Width = ctx->si.w; + oxcf.Height = ctx->si.h; + oxcf.Version = 9; + oxcf.postprocess = 0; + oxcf.max_threads = ctx->cfg.threads; + oxcf.error_concealment = + (ctx->base.init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT); + + /* If postprocessing was enabled by the application and a + * configuration has not been provided, default it. + */ + if (!ctx->postproc_cfg_set + && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) { + ctx->postproc_cfg.post_proc_flag = + VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE; + ctx->postproc_cfg.deblocking_level = 4; + ctx->postproc_cfg.noise_level = 0; + } + + res = vp8_create_decoder_instances(&ctx->yv12_frame_buffers, &oxcf); + ctx->decoder_init = 1; + } + + /* Set these even if already initialized. The caller may have changed the + * decrypt config between frames. + */ + if (ctx->decoder_init) { + ctx->yv12_frame_buffers.pbi[0]->decrypt_cb = ctx->decrypt_cb; + ctx->yv12_frame_buffers.pbi[0]->decrypt_state = ctx->decrypt_state; + } + + if (!res) + { + VP8D_COMP *pbi = ctx->yv12_frame_buffers.pbi[0]; + if (resolution_change) + { + VP8_COMMON *const pc = & pbi->common; + MACROBLOCKD *const xd = & pbi->mb; +#if CONFIG_MULTITHREAD + int i; +#endif + pc->Width = ctx->si.w; + pc->Height = ctx->si.h; + { + int prev_mb_rows = pc->mb_rows; + + + if (setjmp(pbi->common.error.jmp)) + { + pbi->common.error.setjmp = 0; + vp8_clear_system_state(); + /* same return value as used in vp8dx_receive_compressed_data */ + return -1; + } + + pbi->common.error.setjmp = 1; + + if (pc->Width <= 0) + { + pc->Width = w; + vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + ""Invalid frame width""); + } + + if (pc->Height <= 0) + { + pc->Height = h; + vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + ""Invalid frame height""); + } + + if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height)) + vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + ""Failed to allocate frame buffers""); + + xd->pre = pc->yv12_fb[pc->lst_fb_idx]; + xd->dst = pc->yv12_fb[pc->new_fb_idx]; + +#if CONFIG_MULTITHREAD + for (i = 0; i < pbi->allocated_decoding_thread_count; i++) + { + pbi->mb_row_di[i].mbd.dst = pc->yv12_fb[pc->new_fb_idx]; + vp8_build_block_doffsets(&pbi->mb_row_di[i].mbd); + } +#endif + vp8_build_block_doffsets(&pbi->mb); + + /* allocate memory for last frame MODE_INFO array */ +#if CONFIG_ERROR_CONCEALMENT + + if (pbi->ec_enabled) + { + /* old prev_mip was released by vp8_de_alloc_frame_buffers() + * called in vp8_alloc_frame_buffers() */ + pc->prev_mip = vpx_calloc( + (pc->mb_cols + 1) * (pc->mb_rows + 1), + sizeof(MODE_INFO)); + + if (!pc->prev_mip) + { + vp8_de_alloc_frame_buffers(pc); + vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + ""Failed to allocate"" + ""last frame MODE_INFO array""); + } + + pc->prev_mi = pc->prev_mip + pc->mode_info_stride + 1; + + if (vp8_alloc_overlap_lists(pbi)) + vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + ""Failed to allocate overlap lists "" + ""for error concealment""); + } + +#endif + +#if CONFIG_MULTITHREAD + if (pbi->b_multithreaded_rd) + vp8mt_alloc_temp_buffers(pbi, pc->Width, prev_mb_rows); +#else + (void)prev_mb_rows; +#endif + } + + pbi->common.error.setjmp = 0; + + /* required to get past the first get_free_fb() call */ + pbi->common.fb_idx_ref_cnt[0] = 0; + } + + /* update the pbi fragment data */ + pbi->fragments = ctx->fragments; + + ctx->user_priv = user_priv; + if (vp8dx_receive_compressed_data(pbi, data_sz, data, deadline)) + { + res = update_error_state(ctx, &pbi->common.error); + } + + /* get ready for the next series of fragments */ + ctx->fragments.count = 0; + } + + return res; +} +",1,"static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, + const uint8_t *data, + unsigned int data_sz, + void *user_priv, + long deadline) +{ + vpx_codec_err_t res = VPX_CODEC_OK; + unsigned int resolution_change = 0; + unsigned int w, h; + + if (!ctx->fragments.enabled && (data == NULL && data_sz == 0)) + { + return 0; + } + + /* Update the input fragment data */ + if(update_fragments(ctx, data, data_sz, &res) <= 0) + return res; + + /* Determine the stream parameters. Note that we rely on peek_si to + * validate that we have a buffer that does not wrap around the top + * of the heap. + */ + w = ctx->si.w; + h = ctx->si.h; + + res = vp8_peek_si_internal(ctx->fragments.ptrs[0], ctx->fragments.sizes[0], + &ctx->si, ctx->decrypt_cb, ctx->decrypt_state); + + if((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf) + { + /* the peek function returns an error for non keyframes, however for + * this case, it is not an error */ + res = VPX_CODEC_OK; + } + + if(!ctx->decoder_init && !ctx->si.is_kf) + res = VPX_CODEC_UNSUP_BITSTREAM; + + if ((ctx->si.h != h) || (ctx->si.w != w)) + resolution_change = 1; + + /* Initialize the decoder instance on the first frame*/ + if (!res && !ctx->decoder_init) + { + VP8D_CONFIG oxcf; + + oxcf.Width = ctx->si.w; + oxcf.Height = ctx->si.h; + oxcf.Version = 9; + oxcf.postprocess = 0; + oxcf.max_threads = ctx->cfg.threads; + oxcf.error_concealment = + (ctx->base.init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT); + + /* If postprocessing was enabled by the application and a + * configuration has not been provided, default it. + */ + if (!ctx->postproc_cfg_set + && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) { + ctx->postproc_cfg.post_proc_flag = + VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE; + ctx->postproc_cfg.deblocking_level = 4; + ctx->postproc_cfg.noise_level = 0; + } + + res = vp8_create_decoder_instances(&ctx->yv12_frame_buffers, &oxcf); + ctx->decoder_init = 1; + } + + /* Set these even if already initialized. The caller may have changed the + * decrypt config between frames. + */ + if (ctx->decoder_init) { + ctx->yv12_frame_buffers.pbi[0]->decrypt_cb = ctx->decrypt_cb; + ctx->yv12_frame_buffers.pbi[0]->decrypt_state = ctx->decrypt_state; + } + + if (!res) + { + VP8D_COMP *pbi = ctx->yv12_frame_buffers.pbi[0]; + if (resolution_change) + { + VP8_COMMON *const pc = & pbi->common; + MACROBLOCKD *const xd = & pbi->mb; +#if CONFIG_MULTITHREAD + int i; +#endif + pc->Width = ctx->si.w; + pc->Height = ctx->si.h; + { + int prev_mb_rows = pc->mb_rows; + + + if (setjmp(pbi->common.error.jmp)) + { + pbi->common.error.setjmp = 0; + /* on failure clear the cached resolution to ensure a full + * reallocation is attempted on resync. */ + ctx->si.w = 0; + ctx->si.h = 0; + vp8_clear_system_state(); + /* same return value as used in vp8dx_receive_compressed_data */ + return -1; + } + + pbi->common.error.setjmp = 1; + + if (pc->Width <= 0) + { + pc->Width = w; + vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + ""Invalid frame width""); + } + + if (pc->Height <= 0) + { + pc->Height = h; + vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + ""Invalid frame height""); + } + + if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height)) + vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + ""Failed to allocate frame buffers""); + + xd->pre = pc->yv12_fb[pc->lst_fb_idx]; + xd->dst = pc->yv12_fb[pc->new_fb_idx]; + +#if CONFIG_MULTITHREAD + for (i = 0; i < pbi->allocated_decoding_thread_count; i++) + { + pbi->mb_row_di[i].mbd.dst = pc->yv12_fb[pc->new_fb_idx]; + vp8_build_block_doffsets(&pbi->mb_row_di[i].mbd); + } +#endif + vp8_build_block_doffsets(&pbi->mb); + + /* allocate memory for last frame MODE_INFO array */ +#if CONFIG_ERROR_CONCEALMENT + + if (pbi->ec_enabled) + { + /* old prev_mip was released by vp8_de_alloc_frame_buffers() + * called in vp8_alloc_frame_buffers() */ + pc->prev_mip = vpx_calloc( + (pc->mb_cols + 1) * (pc->mb_rows + 1), + sizeof(MODE_INFO)); + + if (!pc->prev_mip) + { + vp8_de_alloc_frame_buffers(pc); + vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + ""Failed to allocate"" + ""last frame MODE_INFO array""); + } + + pc->prev_mi = pc->prev_mip + pc->mode_info_stride + 1; + + if (vp8_alloc_overlap_lists(pbi)) + vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + ""Failed to allocate overlap lists "" + ""for error concealment""); + } + +#endif + +#if CONFIG_MULTITHREAD + if (pbi->b_multithreaded_rd) + vp8mt_alloc_temp_buffers(pbi, pc->Width, prev_mb_rows); +#else + (void)prev_mb_rows; +#endif + } + + pbi->common.error.setjmp = 0; + + /* required to get past the first get_free_fb() call */ + pbi->common.fb_idx_ref_cnt[0] = 0; + } + + /* update the pbi fragment data */ + pbi->fragments = ctx->fragments; + + ctx->user_priv = user_priv; + if (vp8dx_receive_compressed_data(pbi, data_sz, data, deadline)) + { + res = update_error_state(ctx, &pbi->common.error); + } + + /* get ready for the next series of fragments */ + ctx->fragments.count = 0; + } + + return res; +} +","@@ -198,8 +198,8 @@ + + si->h = (clear[8] | (clear[9] << 8)) & 0x3fff; + + /*printf(""w=%d, h=%d\n"", si->w, si->h);*/ +- if (!(si->h | si->w)) +- res = VPX_CODEC_UNSUP_BITSTREAM; ++ if (!(si->h && si->w)) ++ res = VPX_CODEC_CORRUPT_FRAME; + } + else + { +@@ -421,6 +421,10 @@ + + if (setjmp(pbi->common.error.jmp)) + { + pbi->common.error.setjmp = 0; ++ /* on failure clear the cached resolution to ensure a full ++ * reallocation is attempted on resync. */ ++ ctx->si.w = 0; ++ ctx->si.h = 0; + vp8_clear_system_state(); + /* same return value as used in vp8dx_receive_compressed_data */ + return -1; +",1448,1684,2048 +18301,"bgp_capabilities_print(netdissect_options *ndo, + const u_char *opt, int caps_len) +{ + int cap_type, cap_len, tcap_len, cap_offset; + int i = 0; + + while (i < caps_len) { + ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE); + cap_type=opt[i]; + cap_len=opt[i+1]; + tcap_len=cap_len; + ND_PRINT((ndo, ""\n\t %s (%u), length: %u"", + tok2str(bgp_capcode_values, ""Unknown"", + cap_type), + cap_type, + cap_len)); + ND_TCHECK2(opt[i+2], cap_len); + switch (cap_type) { + case BGP_CAPCODE_MP: + ND_PRINT((ndo, ""\n\t\tAFI %s (%u), SAFI %s (%u)"", + tok2str(af_values, ""Unknown"", + EXTRACT_16BITS(opt+i+2)), + EXTRACT_16BITS(opt+i+2), + tok2str(bgp_safi_values, ""Unknown"", + opt[i+5]), + opt[i+5])); + break; + case BGP_CAPCODE_RESTART: + /* Restart Flags (4 bits), Restart Time in seconds (12 bits) */ + ND_TCHECK_16BITS(opt + i + 2); + ND_PRINT((ndo, ""\n\t\tRestart Flags: [%s], Restart Time %us"", + ((opt[i+2])&0x80) ? ""R"" : ""none"", + EXTRACT_16BITS(opt+i+2)&0xfff)); + tcap_len-=2; + cap_offset=4; + while(tcap_len>=4) { + ND_PRINT((ndo, ""\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s"", + tok2str(af_values,""Unknown"", + EXTRACT_16BITS(opt+i+cap_offset)), + EXTRACT_16BITS(opt+i+cap_offset), + tok2str(bgp_safi_values,""Unknown"", + opt[i+cap_offset+2]), + opt[i+cap_offset+2], + ((opt[i+cap_offset+3])&0x80) ? ""yes"" : ""no"" )); + tcap_len-=4; + cap_offset+=4; + } + break; + case BGP_CAPCODE_RR: + case BGP_CAPCODE_RR_CISCO: + break; + case BGP_CAPCODE_AS_NEW: + + /* + * Extract the 4 byte AS number encoded. + */ + if (cap_len == 4) { + ND_PRINT((ndo, ""\n\t\t 4 Byte AS %s"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(opt + i + 2)))); + } + break; + case BGP_CAPCODE_ADD_PATH: + cap_offset=2; + if (tcap_len == 0) { + ND_PRINT((ndo, "" (bogus)"")); /* length */ + break; + } + while (tcap_len > 0) { + if (tcap_len < 4) { + ND_PRINT((ndo, ""\n\t\t(invalid)"")); + break; + } + ND_PRINT((ndo, ""\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s"", + tok2str(af_values,""Unknown"",EXTRACT_16BITS(opt+i+cap_offset)), + EXTRACT_16BITS(opt+i+cap_offset), + tok2str(bgp_safi_values,""Unknown"",opt[i+cap_offset+2]), + opt[i+cap_offset+2], + tok2str(bgp_add_path_recvsend,""Bogus (0x%02x)"",opt[i+cap_offset+3]) + )); + tcap_len-=4; + cap_offset+=4; + } + break; + default: + ND_PRINT((ndo, ""\n\t\tno decoder for Capability %u"", + cap_type)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, &opt[i+2], ""\n\t\t"", cap_len); + break; + } + if (ndo->ndo_vflag > 1 && cap_len > 0) { + print_unknown_data(ndo, &opt[i+2], ""\n\t\t"", cap_len); + } + i += BGP_CAP_HEADER_SIZE + cap_len; + } + return; + +trunc: + ND_PRINT((ndo, ""[|BGP]"")); +} +",1,"bgp_capabilities_print(netdissect_options *ndo, + const u_char *opt, int caps_len) +{ + int cap_type, cap_len, tcap_len, cap_offset; + int i = 0; + + while (i < caps_len) { + ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE); + cap_type=opt[i]; + cap_len=opt[i+1]; + tcap_len=cap_len; + ND_PRINT((ndo, ""\n\t %s (%u), length: %u"", + tok2str(bgp_capcode_values, ""Unknown"", + cap_type), + cap_type, + cap_len)); + ND_TCHECK2(opt[i+2], cap_len); + switch (cap_type) { + case BGP_CAPCODE_MP: + /* AFI (16 bits), Reserved (8 bits), SAFI (8 bits) */ + ND_TCHECK_8BITS(opt + i + 5); + ND_PRINT((ndo, ""\n\t\tAFI %s (%u), SAFI %s (%u)"", + tok2str(af_values, ""Unknown"", + EXTRACT_16BITS(opt+i+2)), + EXTRACT_16BITS(opt+i+2), + tok2str(bgp_safi_values, ""Unknown"", + opt[i+5]), + opt[i+5])); + break; + case BGP_CAPCODE_RESTART: + /* Restart Flags (4 bits), Restart Time in seconds (12 bits) */ + ND_TCHECK_16BITS(opt + i + 2); + ND_PRINT((ndo, ""\n\t\tRestart Flags: [%s], Restart Time %us"", + ((opt[i+2])&0x80) ? ""R"" : ""none"", + EXTRACT_16BITS(opt+i+2)&0xfff)); + tcap_len-=2; + cap_offset=4; + while(tcap_len>=4) { + ND_PRINT((ndo, ""\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s"", + tok2str(af_values,""Unknown"", + EXTRACT_16BITS(opt+i+cap_offset)), + EXTRACT_16BITS(opt+i+cap_offset), + tok2str(bgp_safi_values,""Unknown"", + opt[i+cap_offset+2]), + opt[i+cap_offset+2], + ((opt[i+cap_offset+3])&0x80) ? ""yes"" : ""no"" )); + tcap_len-=4; + cap_offset+=4; + } + break; + case BGP_CAPCODE_RR: + case BGP_CAPCODE_RR_CISCO: + break; + case BGP_CAPCODE_AS_NEW: + + /* + * Extract the 4 byte AS number encoded. + */ + if (cap_len == 4) { + ND_PRINT((ndo, ""\n\t\t 4 Byte AS %s"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(opt + i + 2)))); + } + break; + case BGP_CAPCODE_ADD_PATH: + cap_offset=2; + if (tcap_len == 0) { + ND_PRINT((ndo, "" (bogus)"")); /* length */ + break; + } + while (tcap_len > 0) { + if (tcap_len < 4) { + ND_PRINT((ndo, ""\n\t\t(invalid)"")); + break; + } + ND_PRINT((ndo, ""\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s"", + tok2str(af_values,""Unknown"",EXTRACT_16BITS(opt+i+cap_offset)), + EXTRACT_16BITS(opt+i+cap_offset), + tok2str(bgp_safi_values,""Unknown"",opt[i+cap_offset+2]), + opt[i+cap_offset+2], + tok2str(bgp_add_path_recvsend,""Bogus (0x%02x)"",opt[i+cap_offset+3]) + )); + tcap_len-=4; + cap_offset+=4; + } + break; + default: + ND_PRINT((ndo, ""\n\t\tno decoder for Capability %u"", + cap_type)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, &opt[i+2], ""\n\t\t"", cap_len); + break; + } + if (ndo->ndo_vflag > 1 && cap_len > 0) { + print_unknown_data(ndo, &opt[i+2], ""\n\t\t"", cap_len); + } + i += BGP_CAP_HEADER_SIZE + cap_len; + } + return; + +trunc: + ND_PRINT((ndo, ""[|BGP]"")); +} +","@@ -2342,6 +2342,8 @@ bgp_capabilities_print(netdissect_options *ndo, + ND_TCHECK2(opt[i+2], cap_len); + switch (cap_type) { + case BGP_CAPCODE_MP: ++ /* AFI (16 bits), Reserved (8 bits), SAFI (8 bits) */ ++ ND_TCHECK_8BITS(opt + i + 5); + ND_PRINT((ndo, ""\n\t\tAFI %s (%u), SAFI %s (%u)"", + tok2str(af_values, ""Unknown"", + EXTRACT_16BITS(opt+i+2)),",993,1229,2048 +1675,"CStarter::Init( JobInfoCommunicator* my_jic, const char* original_cwd, + bool is_gsh, int stdin_fd, int stdout_fd, + int stderr_fd ) +{ + if( ! my_jic ) { + EXCEPT( ""CStarter::Init() called with no JobInfoCommunicator!"" ); + } + if( jic ) { + delete( jic ); + } + jic = my_jic; + + if( original_cwd ) { + this->orig_cwd = strdup( original_cwd ); + } + this->is_gridshell = is_gsh; + starter_stdin_fd = stdin_fd; + starter_stdout_fd = stdout_fd; + starter_stderr_fd = stderr_fd; + + Config(); + + + if( is_gridshell ) { + WorkingDir = Execute; + } else { + WorkingDir.sprintf( ""%s%cdir_%ld"", Execute, DIR_DELIM_CHAR, + (long)daemonCore->getpid() ); + } + + daemonCore->Register_Signal(DC_SIGSUSPEND, ""DC_SIGSUSPEND"", + (SignalHandlercpp)&CStarter::RemoteSuspend, ""RemoteSuspend"", + this); + daemonCore->Register_Signal(DC_SIGCONTINUE, ""DC_SIGCONTINUE"", + (SignalHandlercpp)&CStarter::RemoteContinue, ""RemoteContinue"", + this); + daemonCore->Register_Signal(DC_SIGHARDKILL, ""DC_SIGHARDKILL"", + (SignalHandlercpp)&CStarter::RemoteShutdownFast, ""RemoteShutdownFast"", + this); + daemonCore->Register_Signal(DC_SIGSOFTKILL, ""DC_SIGSOFTKILL"", + (SignalHandlercpp)&CStarter::RemoteShutdownGraceful, ""RemoteShutdownGraceful"", + this); + daemonCore->Register_Signal(DC_SIGPCKPT, ""DC_SIGPCKPT"", + (SignalHandlercpp)&CStarter::RemotePeriodicCkpt, ""RemotePeriodicCkpt"", + this); + daemonCore->Register_Signal(DC_SIGREMOVE, ""DC_SIGREMOVE"", + (SignalHandlercpp)&CStarter::RemoteRemove, ""RemoteRemove"", + this); + daemonCore->Register_Signal(SIGUSR1, ""SIGUSR1"", + (SignalHandlercpp)&CStarter::RemoteRemove, ""RemoteRemove"", + this); + daemonCore->Register_Signal(DC_SIGHOLD, ""DC_SIGHOLD"", + (SignalHandlercpp)&CStarter::RemoteHold, ""RemoteHold"", + this); + daemonCore->Register_Reaper(""Reaper"", (ReaperHandlercpp)&CStarter::Reaper, + ""Reaper"", this); + + daemonCore-> + Register_Command( CA_CMD, ""CA_CMD"", + (CommandHandlercpp)&CStarter::classadCommand, + ""CStarter::classadCommand"", this, WRITE ); + daemonCore-> + Register_Command( UPDATE_GSI_CRED, ""UPDATE_GSI_CRED"", + (CommandHandlercpp)&CStarter::updateX509Proxy, + ""CStarter::updateX509Proxy"", this, WRITE ); + daemonCore-> + Register_Command( DELEGATE_GSI_CRED_STARTER, + ""DELEGATE_GSI_CRED_STARTER"", + (CommandHandlercpp)&CStarter::updateX509Proxy, + ""CStarter::updateX509Proxy"", this, WRITE ); + daemonCore-> + Register_Command( STARTER_HOLD_JOB, + ""STARTER_HOLD_JOB"", + (CommandHandlercpp)&CStarter::remoteHoldCommand, + ""CStarter::remoteHoldCommand"", this, DAEMON ); + daemonCore-> + Register_Command( CREATE_JOB_OWNER_SEC_SESSION, + ""CREATE_JOB_OWNER_SEC_SESSION"", + (CommandHandlercpp)&CStarter::createJobOwnerSecSession, + ""CStarter::createJobOwnerSecSession"", this, DAEMON ); + + daemonCore-> + Register_Command( START_SSHD, + ""START_SSHD"", + (CommandHandlercpp)&CStarter::startSSHD, + ""CStarter::startSSHD"", this, READ ); + if( ! jic->init() ) { + dprintf( D_ALWAYS, + ""Failed to initialize JobInfoCommunicator, aborting\n"" ); + return false; + } + sysapi_set_resource_limits(jic->getStackSize()); + + jic->setupJobEnvironment(); + return true; +} +",0,"CStarter::Init( JobInfoCommunicator* my_jic, const char* original_cwd, + bool is_gsh, int stdin_fd, int stdout_fd, + int stderr_fd ) +{ + if( ! my_jic ) { + EXCEPT( ""CStarter::Init() called with no JobInfoCommunicator!"" ); + } + if( jic ) { + delete( jic ); + } + jic = my_jic; + + if( original_cwd ) { + this->orig_cwd = strdup( original_cwd ); + } + this->is_gridshell = is_gsh; + starter_stdin_fd = stdin_fd; + starter_stdout_fd = stdout_fd; + starter_stderr_fd = stderr_fd; + + Config(); + + + if( is_gridshell ) { + WorkingDir = Execute; + } else { + WorkingDir.sprintf( ""%s%cdir_%ld"", Execute, DIR_DELIM_CHAR, + (long)daemonCore->getpid() ); + } + + daemonCore->Register_Signal(DC_SIGSUSPEND, ""DC_SIGSUSPEND"", + (SignalHandlercpp)&CStarter::RemoteSuspend, ""RemoteSuspend"", + this); + daemonCore->Register_Signal(DC_SIGCONTINUE, ""DC_SIGCONTINUE"", + (SignalHandlercpp)&CStarter::RemoteContinue, ""RemoteContinue"", + this); + daemonCore->Register_Signal(DC_SIGHARDKILL, ""DC_SIGHARDKILL"", + (SignalHandlercpp)&CStarter::RemoteShutdownFast, ""RemoteShutdownFast"", + this); + daemonCore->Register_Signal(DC_SIGSOFTKILL, ""DC_SIGSOFTKILL"", + (SignalHandlercpp)&CStarter::RemoteShutdownGraceful, ""RemoteShutdownGraceful"", + this); + daemonCore->Register_Signal(DC_SIGPCKPT, ""DC_SIGPCKPT"", + (SignalHandlercpp)&CStarter::RemotePeriodicCkpt, ""RemotePeriodicCkpt"", + this); + daemonCore->Register_Signal(DC_SIGREMOVE, ""DC_SIGREMOVE"", + (SignalHandlercpp)&CStarter::RemoteRemove, ""RemoteRemove"", + this); + daemonCore->Register_Signal(SIGUSR1, ""SIGUSR1"", + (SignalHandlercpp)&CStarter::RemoteRemove, ""RemoteRemove"", + this); + daemonCore->Register_Signal(DC_SIGHOLD, ""DC_SIGHOLD"", + (SignalHandlercpp)&CStarter::RemoteHold, ""RemoteHold"", + this); + daemonCore->Register_Reaper(""Reaper"", (ReaperHandlercpp)&CStarter::Reaper, + ""Reaper"", this); + + daemonCore-> + Register_Command( CA_CMD, ""CA_CMD"", + (CommandHandlercpp)&CStarter::classadCommand, + ""CStarter::classadCommand"", this, WRITE ); + daemonCore-> + Register_Command( UPDATE_GSI_CRED, ""UPDATE_GSI_CRED"", + (CommandHandlercpp)&CStarter::updateX509Proxy, + ""CStarter::updateX509Proxy"", this, WRITE ); + daemonCore-> + Register_Command( DELEGATE_GSI_CRED_STARTER, + ""DELEGATE_GSI_CRED_STARTER"", + (CommandHandlercpp)&CStarter::updateX509Proxy, + ""CStarter::updateX509Proxy"", this, WRITE ); + daemonCore-> + Register_Command( STARTER_HOLD_JOB, + ""STARTER_HOLD_JOB"", + (CommandHandlercpp)&CStarter::remoteHoldCommand, + ""CStarter::remoteHoldCommand"", this, DAEMON ); + daemonCore-> + Register_Command( CREATE_JOB_OWNER_SEC_SESSION, + ""CREATE_JOB_OWNER_SEC_SESSION"", + (CommandHandlercpp)&CStarter::createJobOwnerSecSession, + ""CStarter::createJobOwnerSecSession"", this, DAEMON ); + + daemonCore-> + Register_Command( START_SSHD, + ""START_SSHD"", + (CommandHandlercpp)&CStarter::startSSHD, + ""CStarter::startSSHD"", this, READ ); + if( ! jic->init() ) { + dprintf( D_ALWAYS, + ""Failed to initialize JobInfoCommunicator, aborting\n"" ); + return false; + } + sysapi_set_resource_limits(jic->getStackSize()); + + jic->setupJobEnvironment(); + return true; +} +","@@ -1800,7 +1800,7 @@ CStarter::removeDeferredJobs() { + error += this->jic->jobCluster(); + error += "".""; + error += this->jic->jobProc(); +- EXCEPT( error.Value() ); ++ EXCEPT( ""%s"", error.Value() ); + ret = false; + } + return ( ret );",974,1210,2048 +8816,"addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, + const XML_Char *uri, BINDING **bindingsPtr) { + static const XML_Char xmlNamespace[] + = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, + ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, + ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, + ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, + ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, + ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, + ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, + ASCII_e, '\0'}; + static const int xmlLen = (int)sizeof(xmlNamespace) / sizeof(XML_Char) - 1; + static const XML_Char xmlnsNamespace[] + = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, + ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, + ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, + ASCII_2, ASCII_0, ASCII_0, ASCII_0, ASCII_SLASH, ASCII_x, + ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'}; + static const int xmlnsLen + = (int)sizeof(xmlnsNamespace) / sizeof(XML_Char) - 1; + + XML_Bool mustBeXML = XML_FALSE; + XML_Bool isXML = XML_TRUE; + XML_Bool isXMLNS = XML_TRUE; + + BINDING *b; + int len; + + /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */ + if (*uri == XML_T('\0') && prefix->name) + return XML_ERROR_UNDECLARING_PREFIX; + + if (prefix->name && prefix->name[0] == XML_T(ASCII_x) + && prefix->name[1] == XML_T(ASCII_m) + && prefix->name[2] == XML_T(ASCII_l)) { + /* Not allowed to bind xmlns */ + if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s) + && prefix->name[5] == XML_T('\0')) + return XML_ERROR_RESERVED_PREFIX_XMLNS; + + if (prefix->name[3] == XML_T('\0')) + mustBeXML = XML_TRUE; + } + + for (len = 0; uri[len]; len++) { + if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) + isXML = XML_FALSE; + + if (! mustBeXML && isXMLNS + && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) + isXMLNS = XML_FALSE; + } + isXML = isXML && len == xmlLen; + isXMLNS = isXMLNS && len == xmlnsLen; + + if (mustBeXML != isXML) + return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML + : XML_ERROR_RESERVED_NAMESPACE_URI; + + if (isXMLNS) + return XML_ERROR_RESERVED_NAMESPACE_URI; + + if (parser->m_namespaceSeparator) + len++; + if (parser->m_freeBindingList) { + b = parser->m_freeBindingList; + if (len > b->uriAlloc) { + XML_Char *temp = (XML_Char *)REALLOC( + parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE)); + if (temp == NULL) + return XML_ERROR_NO_MEMORY; + b->uri = temp; + b->uriAlloc = len + EXPAND_SPARE; + } + parser->m_freeBindingList = b->nextTagBinding; + } else { + b = (BINDING *)MALLOC(parser, sizeof(BINDING)); + if (! b) + return XML_ERROR_NO_MEMORY; + b->uri + = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE)); + if (! b->uri) { + FREE(parser, b); + return XML_ERROR_NO_MEMORY; + } + b->uriAlloc = len + EXPAND_SPARE; + } + b->uriLen = len; + memcpy(b->uri, uri, len * sizeof(XML_Char)); + if (parser->m_namespaceSeparator) + b->uri[len - 1] = parser->m_namespaceSeparator; + b->prefix = prefix; + b->attId = attId; + b->prevPrefixBinding = prefix->binding; + /* NULL binding when default namespace undeclared */ + if (*uri == XML_T('\0') && prefix == &parser->m_dtd->defaultPrefix) + prefix->binding = NULL; + else + prefix->binding = b; + b->nextTagBinding = *bindingsPtr; + *bindingsPtr = b; + /* if attId == NULL then we are not starting a namespace scope */ + if (attId && parser->m_startNamespaceDeclHandler) + parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name, + prefix->binding ? uri : 0); + return XML_ERROR_NONE; +} +",0,"addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, + const XML_Char *uri, BINDING **bindingsPtr) { + static const XML_Char xmlNamespace[] + = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, + ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, + ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, + ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, + ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, + ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, + ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, + ASCII_e, '\0'}; + static const int xmlLen = (int)sizeof(xmlNamespace) / sizeof(XML_Char) - 1; + static const XML_Char xmlnsNamespace[] + = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, + ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, + ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, + ASCII_2, ASCII_0, ASCII_0, ASCII_0, ASCII_SLASH, ASCII_x, + ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'}; + static const int xmlnsLen + = (int)sizeof(xmlnsNamespace) / sizeof(XML_Char) - 1; + + XML_Bool mustBeXML = XML_FALSE; + XML_Bool isXML = XML_TRUE; + XML_Bool isXMLNS = XML_TRUE; + + BINDING *b; + int len; + + /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */ + if (*uri == XML_T('\0') && prefix->name) + return XML_ERROR_UNDECLARING_PREFIX; + + if (prefix->name && prefix->name[0] == XML_T(ASCII_x) + && prefix->name[1] == XML_T(ASCII_m) + && prefix->name[2] == XML_T(ASCII_l)) { + /* Not allowed to bind xmlns */ + if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s) + && prefix->name[5] == XML_T('\0')) + return XML_ERROR_RESERVED_PREFIX_XMLNS; + + if (prefix->name[3] == XML_T('\0')) + mustBeXML = XML_TRUE; + } + + for (len = 0; uri[len]; len++) { + if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) + isXML = XML_FALSE; + + if (! mustBeXML && isXMLNS + && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) + isXMLNS = XML_FALSE; + } + isXML = isXML && len == xmlLen; + isXMLNS = isXMLNS && len == xmlnsLen; + + if (mustBeXML != isXML) + return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML + : XML_ERROR_RESERVED_NAMESPACE_URI; + + if (isXMLNS) + return XML_ERROR_RESERVED_NAMESPACE_URI; + + if (parser->m_namespaceSeparator) + len++; + if (parser->m_freeBindingList) { + b = parser->m_freeBindingList; + if (len > b->uriAlloc) { + XML_Char *temp = (XML_Char *)REALLOC( + parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE)); + if (temp == NULL) + return XML_ERROR_NO_MEMORY; + b->uri = temp; + b->uriAlloc = len + EXPAND_SPARE; + } + parser->m_freeBindingList = b->nextTagBinding; + } else { + b = (BINDING *)MALLOC(parser, sizeof(BINDING)); + if (! b) + return XML_ERROR_NO_MEMORY; + b->uri + = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE)); + if (! b->uri) { + FREE(parser, b); + return XML_ERROR_NO_MEMORY; + } + b->uriAlloc = len + EXPAND_SPARE; + } + b->uriLen = len; + memcpy(b->uri, uri, len * sizeof(XML_Char)); + if (parser->m_namespaceSeparator) + b->uri[len - 1] = parser->m_namespaceSeparator; + b->prefix = prefix; + b->attId = attId; + b->prevPrefixBinding = prefix->binding; + /* NULL binding when default namespace undeclared */ + if (*uri == XML_T('\0') && prefix == &parser->m_dtd->defaultPrefix) + prefix->binding = NULL; + else + prefix->binding = b; + b->nextTagBinding = *bindingsPtr; + *bindingsPtr = b; + /* if attId == NULL then we are not starting a namespace scope */ + if (attId && parser->m_startNamespaceDeclHandler) + parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name, + prefix->binding ? uri : 0); + return XML_ERROR_NONE; +} +","@@ -401,7 +401,7 @@ static enum XML_Error initializeEncoding(XML_Parser parser); + static enum XML_Error doProlog(XML_Parser parser, const ENCODING *enc, + const char *s, const char *end, int tok, + const char *next, const char **nextPtr, +- XML_Bool haveMore); ++ XML_Bool haveMore, XML_Bool allowClosingDoctype); + static enum XML_Error processInternalEntity(XML_Parser parser, ENTITY *entity, + XML_Bool betweenDecl); + static enum XML_Error doContent(XML_Parser parser, int startTagLevel, +@@ -4046,7 +4046,7 @@ externalParEntProcessor(XML_Parser parser, const char *s, const char *end, + + parser->m_processor = prologProcessor; + return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, +- (XML_Bool)! parser->m_parsingStatus.finalBuffer); ++ (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE); + } + + static enum XML_Error PTRCALL +@@ -4090,12 +4090,13 @@ prologProcessor(XML_Parser parser, const char *s, const char *end, + const char *next = s; + int tok = XmlPrologTok(parser->m_encoding, s, end, &next); + return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, +- (XML_Bool)! parser->m_parsingStatus.finalBuffer); ++ (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE); + } + + static enum XML_Error + doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, +- int tok, const char *next, const char **nextPtr, XML_Bool haveMore) { ++ int tok, const char *next, const char **nextPtr, XML_Bool haveMore, ++ XML_Bool allowClosingDoctype) { + #ifdef XML_DTD + static const XML_Char externalSubsetName[] = {ASCII_HASH, '\0'}; + #endif /* XML_DTD */ +@@ -4271,6 +4272,11 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, + } + break; + case XML_ROLE_DOCTYPE_CLOSE: ++ if (allowClosingDoctype != XML_TRUE) { ++ /* Must not close doctype from within expanded parameter entities */ ++ return XML_ERROR_INVALID_TOKEN; ++ } ++ + if (parser->m_doctypeName) { + parser->m_startDoctypeDeclHandler( + parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid, +@@ -5174,7 +5180,7 @@ processInternalEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl) { + int tok + = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); + result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, +- tok, next, &next, XML_FALSE); ++ tok, next, &next, XML_FALSE, XML_FALSE); + } else + #endif /* XML_DTD */ + result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding, +@@ -5217,7 +5223,7 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end, + int tok + = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); + result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, +- tok, next, &next, XML_FALSE); ++ tok, next, &next, XML_FALSE, XML_TRUE); + } else + #endif /* XML_DTD */ + result = doContent(parser, openEntity->startTagLevel, +@@ -5244,7 +5250,7 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end, + parser->m_processor = prologProcessor; + tok = XmlPrologTok(parser->m_encoding, s, end, &next); + return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, +- (XML_Bool)! parser->m_parsingStatus.finalBuffer); ++ (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE); + } else + #endif /* XML_DTD */ + {",1178,1414,2048 +6369,"httpd_initialize( + char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, + unsigned short port, char* cgi_pattern, int cgi_limit, char* charset, + char* p3p, int max_age, char* cwd, int no_log, FILE* logfp, + int no_symlink_check, int vhost, int global_passwd, char* url_pattern, + char* local_pattern, int no_empty_referers ) + { + httpd_server* hs; + static char ghnbuf[256]; + char* cp; + + check_options(); + + hs = NEW( httpd_server, 1 ); + if ( hs == (httpd_server*) 0 ) + { + syslog( LOG_CRIT, ""out of memory allocating an httpd_server"" ); + return (httpd_server*) 0; + } + + if ( hostname != (char*) 0 ) + { + hs->binding_hostname = strdup( hostname ); + if ( hs->binding_hostname == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying hostname"" ); + return (httpd_server*) 0; + } + hs->server_hostname = hs->binding_hostname; + } + else + { + hs->binding_hostname = (char*) 0; + hs->server_hostname = (char*) 0; + if ( gethostname( ghnbuf, sizeof(ghnbuf) ) < 0 ) + ghnbuf[0] = '\0'; +#ifdef SERVER_NAME_LIST + if ( ghnbuf[0] != '\0' ) + hs->server_hostname = hostname_map( ghnbuf ); +#endif /* SERVER_NAME_LIST */ + if ( hs->server_hostname == (char*) 0 ) + { +#ifdef SERVER_NAME + hs->server_hostname = SERVER_NAME; +#else /* SERVER_NAME */ + if ( ghnbuf[0] != '\0' ) + hs->server_hostname = ghnbuf; +#endif /* SERVER_NAME */ + } + } + + hs->port = port; + if ( cgi_pattern == (char*) 0 ) + hs->cgi_pattern = (char*) 0; + else + { + /* Nuke any leading slashes. */ + if ( cgi_pattern[0] == '/' ) + ++cgi_pattern; + hs->cgi_pattern = strdup( cgi_pattern ); + if ( hs->cgi_pattern == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying cgi_pattern"" ); + return (httpd_server*) 0; + } + /* Nuke any leading slashes in the cgi pattern. */ + while ( ( cp = strstr( hs->cgi_pattern, ""|/"" ) ) != (char*) 0 ) + /* -2 for the offset, +1 for the '\0' */ + (void) memmove( cp + 1, cp + 2, strlen( cp ) - 1 ); + } + hs->cgi_limit = cgi_limit; + hs->cgi_count = 0; + hs->charset = strdup( charset ); + hs->p3p = strdup( p3p ); + hs->max_age = max_age; + hs->cwd = strdup( cwd ); + if ( hs->cwd == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying cwd"" ); + return (httpd_server*) 0; + } + if ( url_pattern == (char*) 0 ) + hs->url_pattern = (char*) 0; + else + { + hs->url_pattern = strdup( url_pattern ); + if ( hs->url_pattern == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying url_pattern"" ); + return (httpd_server*) 0; + } + } + if ( local_pattern == (char*) 0 ) + hs->local_pattern = (char*) 0; + else + { + hs->local_pattern = strdup( local_pattern ); + if ( hs->local_pattern == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying local_pattern"" ); + return (httpd_server*) 0; + } + } + hs->no_log = no_log; + hs->logfp = (FILE*) 0; + httpd_set_logfp( hs, logfp ); + hs->no_symlink_check = no_symlink_check; + hs->vhost = vhost; + hs->global_passwd = global_passwd; + hs->no_empty_referers = no_empty_referers; + + /* Initialize listen sockets. Try v6 first because of a Linux peculiarity; + ** like some other systems, it has magical v6 sockets that also listen for + ** v4, but in Linux if you bind a v4 socket first then the v6 bind fails. + */ + if ( sa6P == (httpd_sockaddr*) 0 ) + hs->listen6_fd = -1; + else + hs->listen6_fd = initialize_listen_socket( sa6P ); + if ( sa4P == (httpd_sockaddr*) 0 ) + hs->listen4_fd = -1; + else + hs->listen4_fd = initialize_listen_socket( sa4P ); + /* If we didn't get any valid sockets, fail. */ + if ( hs->listen4_fd == -1 && hs->listen6_fd == -1 ) + { + free_httpd_server( hs ); + return (httpd_server*) 0; + } + + init_mime(); + + /* Done initializing. */ + if ( hs->binding_hostname == (char*) 0 ) + syslog( + LOG_NOTICE, ""%.80s starting on port %d"", SERVER_SOFTWARE, + (int) hs->port ); + else + syslog( + LOG_NOTICE, ""%.80s starting on %.80s, port %d"", SERVER_SOFTWARE, + httpd_ntoa( hs->listen4_fd != -1 ? sa4P : sa6P ), + (int) hs->port ); + return hs; + } +",0,"httpd_initialize( + char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, + unsigned short port, char* cgi_pattern, int cgi_limit, char* charset, + char* p3p, int max_age, char* cwd, int no_log, FILE* logfp, + int no_symlink_check, int vhost, int global_passwd, char* url_pattern, + char* local_pattern, int no_empty_referers ) + { + httpd_server* hs; + static char ghnbuf[256]; + char* cp; + + check_options(); + + hs = NEW( httpd_server, 1 ); + if ( hs == (httpd_server*) 0 ) + { + syslog( LOG_CRIT, ""out of memory allocating an httpd_server"" ); + return (httpd_server*) 0; + } + + if ( hostname != (char*) 0 ) + { + hs->binding_hostname = strdup( hostname ); + if ( hs->binding_hostname == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying hostname"" ); + return (httpd_server*) 0; + } + hs->server_hostname = hs->binding_hostname; + } + else + { + hs->binding_hostname = (char*) 0; + hs->server_hostname = (char*) 0; + if ( gethostname( ghnbuf, sizeof(ghnbuf) ) < 0 ) + ghnbuf[0] = '\0'; +#ifdef SERVER_NAME_LIST + if ( ghnbuf[0] != '\0' ) + hs->server_hostname = hostname_map( ghnbuf ); +#endif /* SERVER_NAME_LIST */ + if ( hs->server_hostname == (char*) 0 ) + { +#ifdef SERVER_NAME + hs->server_hostname = SERVER_NAME; +#else /* SERVER_NAME */ + if ( ghnbuf[0] != '\0' ) + hs->server_hostname = ghnbuf; +#endif /* SERVER_NAME */ + } + } + + hs->port = port; + if ( cgi_pattern == (char*) 0 ) + hs->cgi_pattern = (char*) 0; + else + { + /* Nuke any leading slashes. */ + if ( cgi_pattern[0] == '/' ) + ++cgi_pattern; + hs->cgi_pattern = strdup( cgi_pattern ); + if ( hs->cgi_pattern == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying cgi_pattern"" ); + return (httpd_server*) 0; + } + /* Nuke any leading slashes in the cgi pattern. */ + while ( ( cp = strstr( hs->cgi_pattern, ""|/"" ) ) != (char*) 0 ) + /* -2 for the offset, +1 for the '\0' */ + (void) memmove( cp + 1, cp + 2, strlen( cp ) - 1 ); + } + hs->cgi_limit = cgi_limit; + hs->cgi_count = 0; + hs->charset = strdup( charset ); + hs->p3p = strdup( p3p ); + hs->max_age = max_age; + hs->cwd = strdup( cwd ); + if ( hs->cwd == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying cwd"" ); + return (httpd_server*) 0; + } + if ( url_pattern == (char*) 0 ) + hs->url_pattern = (char*) 0; + else + { + hs->url_pattern = strdup( url_pattern ); + if ( hs->url_pattern == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying url_pattern"" ); + return (httpd_server*) 0; + } + } + if ( local_pattern == (char*) 0 ) + hs->local_pattern = (char*) 0; + else + { + hs->local_pattern = strdup( local_pattern ); + if ( hs->local_pattern == (char*) 0 ) + { + syslog( LOG_CRIT, ""out of memory copying local_pattern"" ); + return (httpd_server*) 0; + } + } + hs->no_log = no_log; + hs->logfp = (FILE*) 0; + httpd_set_logfp( hs, logfp ); + hs->no_symlink_check = no_symlink_check; + hs->vhost = vhost; + hs->global_passwd = global_passwd; + hs->no_empty_referers = no_empty_referers; + + /* Initialize listen sockets. Try v6 first because of a Linux peculiarity; + ** like some other systems, it has magical v6 sockets that also listen for + ** v4, but in Linux if you bind a v4 socket first then the v6 bind fails. + */ + if ( sa6P == (httpd_sockaddr*) 0 ) + hs->listen6_fd = -1; + else + hs->listen6_fd = initialize_listen_socket( sa6P ); + if ( sa4P == (httpd_sockaddr*) 0 ) + hs->listen4_fd = -1; + else + hs->listen4_fd = initialize_listen_socket( sa4P ); + /* If we didn't get any valid sockets, fail. */ + if ( hs->listen4_fd == -1 && hs->listen6_fd == -1 ) + { + free_httpd_server( hs ); + return (httpd_server*) 0; + } + + init_mime(); + + /* Done initializing. */ + if ( hs->binding_hostname == (char*) 0 ) + syslog( + LOG_NOTICE, ""%.80s starting on port %d"", SERVER_SOFTWARE, + (int) hs->port ); + else + syslog( + LOG_NOTICE, ""%.80s starting on %.80s, port %d"", SERVER_SOFTWARE, + httpd_ntoa( hs->listen4_fd != -1 ? sa4P : sa6P ), + (int) hs->port ); + return hs; + } +","@@ -2410,7 +2410,7 @@ de_dotdot( char* file ) + while ( strncmp( file, ""./"", 2 ) == 0 ) + (void) memmove( file, file + 2, strlen( file ) - 1 ); + while ( ( cp = strstr( file, ""/./"") ) != (char*) 0 ) +- (void) memmove( cp, cp + 2, strlen( file ) - 1 ); ++ (void) memmove( cp, cp + 2, strlen( cp ) - 1 ); + + /* Alternate between removing leading ../ and removing xxx/../ */ + for (;;)",1276,1512,2048 +18324,"static int x509_crt_verify_child( + mbedtls_x509_crt *child, mbedtls_x509_crt *parent, + mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + int path_cnt, int self_cnt, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + int ret; + uint32_t parent_flags = 0; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + mbedtls_x509_crt *grandparent; + const mbedtls_md_info_t *md_info; + + /* Counting intermediate self signed certificates */ + if( ( path_cnt != 0 ) && x509_name_cmp( &child->issuer, &child->subject ) == 0 ) + self_cnt++; + + /* path_cnt is 0 for the first intermediate CA */ + if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA ) + { + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ); + } + + if( mbedtls_x509_time_is_past( &child->valid_to ) ) + *flags |= MBEDTLS_X509_BADCERT_EXPIRED; + + if( mbedtls_x509_time_is_future( &child->valid_from ) ) + *flags |= MBEDTLS_X509_BADCERT_FUTURE; + + if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_MD; + + if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_PK; + + md_info = mbedtls_md_info_from_type( child->sig_md ); + if( md_info == NULL ) + { + /* + * Cannot check 'unknown' hash + */ + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + else + { + mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ); + + if( x509_profile_check_key( profile, child->sig_pk, &parent->pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + + if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &parent->pk, + child->sig_md, hash, mbedtls_md_get_size( md_info ), + child->sig.p, child->sig.len ) != 0 ) + { + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + } + +#if defined(MBEDTLS_X509_CRL_PARSE_C) + /* Check trusted CA's CRL for the given crt */ + *flags |= x509_crt_verifycrl(child, parent, ca_crl, profile ); +#endif + + /* Look for a grandparent in trusted CAs */ + for( grandparent = trust_ca; + grandparent != NULL; + grandparent = grandparent->next ) + { + if( x509_crt_check_parent( parent, grandparent, + 0, path_cnt == 0 ) == 0 ) + break; + } + + if( grandparent != NULL ) + { + ret = x509_crt_verify_top( parent, grandparent, ca_crl, profile, + path_cnt + 1, self_cnt, &parent_flags, f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + /* Look for a grandparent upwards the chain */ + for( grandparent = parent->next; + grandparent != NULL; + grandparent = grandparent->next ) + { + /* +2 because the current step is not yet accounted for + * and because max_pathlen is one higher than it should be. + * Also self signed certificates do not count to the limit. */ + if( grandparent->max_pathlen > 0 && + grandparent->max_pathlen < 2 + path_cnt - self_cnt ) + { + continue; + } + + if( x509_crt_check_parent( parent, grandparent, + 0, path_cnt == 0 ) == 0 ) + break; + } + + /* Is our parent part of the chain or at the top? */ + if( grandparent != NULL ) + { + ret = x509_crt_verify_child( parent, grandparent, trust_ca, ca_crl, + profile, path_cnt + 1, self_cnt, &parent_flags, + f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + ret = x509_crt_verify_top( parent, trust_ca, ca_crl, profile, + path_cnt + 1, self_cnt, &parent_flags, + f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + } + + /* child is verified to be a child of the parent, call verify callback */ + if( NULL != f_vrfy ) + if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 ) + return( ret ); + + *flags |= parent_flags; + + return( 0 ); +} +",1,"static int x509_crt_verify_child( + mbedtls_x509_crt *child, mbedtls_x509_crt *parent, + mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + int path_cnt, int self_cnt, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + int ret; + uint32_t parent_flags = 0; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + mbedtls_x509_crt *grandparent; + const mbedtls_md_info_t *md_info; + + /* Counting intermediate self signed certificates */ + if( ( path_cnt != 0 ) && x509_name_cmp( &child->issuer, &child->subject ) == 0 ) + self_cnt++; + + /* path_cnt is 0 for the first intermediate CA */ + if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA ) + { + /* return immediately as the goal is to avoid unbounded recursion */ + return( MBEDTLS_ERR_X509_FATAL_ERROR ); + } + + if( mbedtls_x509_time_is_past( &child->valid_to ) ) + *flags |= MBEDTLS_X509_BADCERT_EXPIRED; + + if( mbedtls_x509_time_is_future( &child->valid_from ) ) + *flags |= MBEDTLS_X509_BADCERT_FUTURE; + + if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_MD; + + if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_PK; + + md_info = mbedtls_md_info_from_type( child->sig_md ); + if( md_info == NULL ) + { + /* + * Cannot check 'unknown' hash + */ + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + else + { + mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ); + + if( x509_profile_check_key( profile, child->sig_pk, &parent->pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + + if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &parent->pk, + child->sig_md, hash, mbedtls_md_get_size( md_info ), + child->sig.p, child->sig.len ) != 0 ) + { + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + } + +#if defined(MBEDTLS_X509_CRL_PARSE_C) + /* Check trusted CA's CRL for the given crt */ + *flags |= x509_crt_verifycrl(child, parent, ca_crl, profile ); +#endif + + /* Look for a grandparent in trusted CAs */ + for( grandparent = trust_ca; + grandparent != NULL; + grandparent = grandparent->next ) + { + if( x509_crt_check_parent( parent, grandparent, + 0, path_cnt == 0 ) == 0 ) + break; + } + + if( grandparent != NULL ) + { + ret = x509_crt_verify_top( parent, grandparent, ca_crl, profile, + path_cnt + 1, self_cnt, &parent_flags, f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + /* Look for a grandparent upwards the chain */ + for( grandparent = parent->next; + grandparent != NULL; + grandparent = grandparent->next ) + { + /* +2 because the current step is not yet accounted for + * and because max_pathlen is one higher than it should be. + * Also self signed certificates do not count to the limit. */ + if( grandparent->max_pathlen > 0 && + grandparent->max_pathlen < 2 + path_cnt - self_cnt ) + { + continue; + } + + if( x509_crt_check_parent( parent, grandparent, + 0, path_cnt == 0 ) == 0 ) + break; + } + + /* Is our parent part of the chain or at the top? */ + if( grandparent != NULL ) + { + ret = x509_crt_verify_child( parent, grandparent, trust_ca, ca_crl, + profile, path_cnt + 1, self_cnt, &parent_flags, + f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + else + { + ret = x509_crt_verify_top( parent, trust_ca, ca_crl, profile, + path_cnt + 1, self_cnt, &parent_flags, + f_vrfy, p_vrfy ); + if( ret != 0 ) + return( ret ); + } + } + + /* child is verified to be a child of the parent, call verify callback */ + if( NULL != f_vrfy ) + if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 ) + return( ret ); + + *flags |= parent_flags; + + return( 0 ); +} +","@@ -2057,8 +2057,8 @@ static int x509_crt_verify_child( + /* path_cnt is 0 for the first intermediate CA */ + if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA ) + { +- *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; +- return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ); ++ /* return immediately as the goal is to avoid unbounded recursion */ ++ return( MBEDTLS_ERR_X509_FATAL_ERROR ); + } + + if( mbedtls_x509_time_is_past( &child->valid_to ) ) +@@ -2310,6 +2310,10 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, + } + + exit: ++ /* prevent misuse of the vrfy callback */ ++ if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ) ++ ret = MBEDTLS_ERR_X509_FATAL_ERROR; ++ + if( ret != 0 ) + { + *flags = (uint32_t) -1;",1231,1467,2048 +1554,"static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) +{ + BIGNUM *kinv = NULL; + BIGNUM *m, *blind, *blindm, *tmp; + BN_CTX *ctx = NULL; + int reason = ERR_R_BN_LIB; + DSA_SIG *ret = NULL; + int rv = 0; + + if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) { + reason = DSA_R_MISSING_PARAMETERS; + goto err; + } + + ret = DSA_SIG_new(); + if (ret == NULL) + goto err; + ret->r = BN_new(); + ret->s = BN_new(); + if (ret->r == NULL || ret->s == NULL) + goto err; + + ctx = BN_CTX_new(); + if (ctx == NULL) + goto err; + m = BN_CTX_get(ctx); + blind = BN_CTX_get(ctx); + blindm = BN_CTX_get(ctx); + tmp = BN_CTX_get(ctx); + if (tmp == NULL) + goto err; + + redo: + if (!dsa_sign_setup(dsa, ctx, &kinv, &ret->r, dgst, dlen)) + goto err; + + if (dlen > BN_num_bytes(dsa->q)) + /* + * if the digest length is greater than the size of q use the + * BN_num_bits(dsa->q) leftmost bits of the digest, see fips 186-3, + * 4.2 + */ + dlen = BN_num_bytes(dsa->q); + if (BN_bin2bn(dgst, dlen, m) == NULL) + goto err; + + /* + * The normal signature calculation is: + * + * s := k^-1 * (m + r * priv_key) mod q + * + * We will blind this to protect against side channel attacks + * + * s := blind^-1 * k^-1 * (blind * m + blind * r * priv_key) mod q + */ + + /* Generate a blinding value */ + do { + if (!BN_priv_rand(blind, BN_num_bits(dsa->q) - 1, + BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) + goto err; + } while (BN_is_zero(blind)); + BN_set_flags(blind, BN_FLG_CONSTTIME); + BN_set_flags(blindm, BN_FLG_CONSTTIME); + BN_set_flags(tmp, BN_FLG_CONSTTIME); + + /* tmp := blind * priv_key * r mod q */ + if (!BN_mod_mul(tmp, blind, dsa->priv_key, dsa->q, ctx)) + goto err; + if (!BN_mod_mul(tmp, tmp, ret->r, dsa->q, ctx)) + goto err; + + /* blindm := blind * m mod q */ + if (!BN_mod_mul(blindm, blind, m, dsa->q, ctx)) + goto err; + + /* s : = (blind * priv_key * r) + (blind * m) mod q */ + if (!BN_mod_add_quick(ret->s, tmp, blindm, dsa->q)) + goto err; + + /* s := s * k^-1 mod q */ + if (!BN_mod_mul(ret->s, ret->s, kinv, dsa->q, ctx)) + goto err; + + /* s:= s * blind^-1 mod q */ + if (BN_mod_inverse(blind, blind, dsa->q, ctx) == NULL) + goto err; + if (!BN_mod_mul(ret->s, ret->s, blind, dsa->q, ctx)) + goto err; + + /* + * Redo if r or s is zero as required by FIPS 186-3: this is very + * unlikely. + */ + if (BN_is_zero(ret->r) || BN_is_zero(ret->s)) + goto redo; + + rv = 1; + + err: + if (rv == 0) { + DSAerr(DSA_F_DSA_DO_SIGN, reason); + DSA_SIG_free(ret); + ret = NULL; + } + BN_CTX_free(ctx); + BN_clear_free(kinv); + return ret; +} +",0,"static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) +{ + BIGNUM *kinv = NULL; + BIGNUM *m, *blind, *blindm, *tmp; + BN_CTX *ctx = NULL; + int reason = ERR_R_BN_LIB; + DSA_SIG *ret = NULL; + int rv = 0; + + if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) { + reason = DSA_R_MISSING_PARAMETERS; + goto err; + } + + ret = DSA_SIG_new(); + if (ret == NULL) + goto err; + ret->r = BN_new(); + ret->s = BN_new(); + if (ret->r == NULL || ret->s == NULL) + goto err; + + ctx = BN_CTX_new(); + if (ctx == NULL) + goto err; + m = BN_CTX_get(ctx); + blind = BN_CTX_get(ctx); + blindm = BN_CTX_get(ctx); + tmp = BN_CTX_get(ctx); + if (tmp == NULL) + goto err; + + redo: + if (!dsa_sign_setup(dsa, ctx, &kinv, &ret->r, dgst, dlen)) + goto err; + + if (dlen > BN_num_bytes(dsa->q)) + /* + * if the digest length is greater than the size of q use the + * BN_num_bits(dsa->q) leftmost bits of the digest, see fips 186-3, + * 4.2 + */ + dlen = BN_num_bytes(dsa->q); + if (BN_bin2bn(dgst, dlen, m) == NULL) + goto err; + + /* + * The normal signature calculation is: + * + * s := k^-1 * (m + r * priv_key) mod q + * + * We will blind this to protect against side channel attacks + * + * s := blind^-1 * k^-1 * (blind * m + blind * r * priv_key) mod q + */ + + /* Generate a blinding value */ + do { + if (!BN_priv_rand(blind, BN_num_bits(dsa->q) - 1, + BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) + goto err; + } while (BN_is_zero(blind)); + BN_set_flags(blind, BN_FLG_CONSTTIME); + BN_set_flags(blindm, BN_FLG_CONSTTIME); + BN_set_flags(tmp, BN_FLG_CONSTTIME); + + /* tmp := blind * priv_key * r mod q */ + if (!BN_mod_mul(tmp, blind, dsa->priv_key, dsa->q, ctx)) + goto err; + if (!BN_mod_mul(tmp, tmp, ret->r, dsa->q, ctx)) + goto err; + + /* blindm := blind * m mod q */ + if (!BN_mod_mul(blindm, blind, m, dsa->q, ctx)) + goto err; + + /* s : = (blind * priv_key * r) + (blind * m) mod q */ + if (!BN_mod_add_quick(ret->s, tmp, blindm, dsa->q)) + goto err; + + /* s := s * k^-1 mod q */ + if (!BN_mod_mul(ret->s, ret->s, kinv, dsa->q, ctx)) + goto err; + + /* s:= s * blind^-1 mod q */ + if (BN_mod_inverse(blind, blind, dsa->q, ctx) == NULL) + goto err; + if (!BN_mod_mul(ret->s, ret->s, blind, dsa->q, ctx)) + goto err; + + /* + * Redo if r or s is zero as required by FIPS 186-3: this is very + * unlikely. + */ + if (BN_is_zero(ret->r) || BN_is_zero(ret->s)) + goto redo; + + rv = 1; + + err: + if (rv == 0) { + DSAerr(DSA_F_DSA_DO_SIGN, reason); + DSA_SIG_free(ret); + ret = NULL; + } + BN_CTX_free(ctx); + BN_clear_free(kinv); + return ret; +} +","@@ -9,6 +9,7 @@ + + #include + #include ""internal/cryptlib.h"" ++#include ""internal/bn_int.h"" + #include + #include + #include ""dsa_locl.h"" +@@ -180,9 +181,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, + { + BN_CTX *ctx = NULL; + BIGNUM *k, *kinv = NULL, *r = *rp; +- BIGNUM *l, *m; ++ BIGNUM *l; + int ret = 0; +- int q_bits; ++ int q_bits, q_words; + + if (!dsa->p || !dsa->q || !dsa->g) { + DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_MISSING_PARAMETERS); +@@ -191,8 +192,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, + + k = BN_new(); + l = BN_new(); +- m = BN_new(); +- if (k == NULL || l == NULL || m == NULL) ++ if (k == NULL || l == NULL) + goto err; + + if (ctx_in == NULL) { +@@ -203,9 +203,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, + + /* Preallocate space */ + q_bits = BN_num_bits(dsa->q); +- if (!BN_set_bit(k, q_bits) +- || !BN_set_bit(l, q_bits) +- || !BN_set_bit(m, q_bits)) ++ q_words = bn_get_top(dsa->q); ++ if (!bn_wexpand(k, q_words + 2) ++ || !bn_wexpand(l, q_words + 2)) + goto err; + + /* Get random k */ +@@ -240,14 +240,17 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, + * small timing information leakage. We then choose the sum that is + * one bit longer than the modulus. + * +- * TODO: revisit the BN_copy aiming for a memory access agnostic +- * conditional copy. ++ * There are some concerns about the efficacy of doing this. More ++ * specificly refer to the discussion starting with: ++ * https://github.com/openssl/openssl/pull/7486#discussion_r228323705 ++ * The fix is to rework BN so these gymnastics aren't required. + */ + if (!BN_add(l, k, dsa->q) +- || !BN_add(m, l, dsa->q) +- || !BN_copy(k, BN_num_bits(l) > q_bits ? l : m)) ++ || !BN_add(k, l, dsa->q)) + goto err; + ++ BN_consttime_swap(BN_is_bit_set(l, q_bits), k, l, q_words + 2); ++ + if ((dsa)->meth->bn_mod_exp != NULL) { + if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, k, dsa->p, ctx, + dsa->method_mont_p)) +@@ -260,7 +263,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, + if (!BN_mod(r, r, dsa->q, ctx)) + goto err; + +- /* Compute part of 's = inv(k) (m + xr) mod q' */ ++ /* Compute part of 's = inv(k) (m + xr) mod q' */ + if ((kinv = dsa_mod_inverse_fermat(k, dsa->q, ctx)) == NULL) + goto err; + +@@ -275,7 +278,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, + BN_CTX_free(ctx); + BN_clear_free(k); + BN_clear_free(l); +- BN_clear_free(m); + return ret; + }",923,1159,2048 +6872,"static void klsi_105_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, + struct ktermios *old_termios) +{ + struct klsi_105_private *priv = usb_get_serial_port_data(port); + struct device *dev = &port->dev; + unsigned int iflag = tty->termios.c_iflag; + unsigned int old_iflag = old_termios->c_iflag; + unsigned int cflag = tty->termios.c_cflag; + unsigned int old_cflag = old_termios->c_cflag; + struct klsi_105_port_settings *cfg; + unsigned long flags; + speed_t baud; + + cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return; + + /* lock while we are modifying the settings */ + spin_lock_irqsave(&priv->lock, flags); + + /* + * Update baud rate + */ + baud = tty_get_baud_rate(tty); + + if ((cflag & CBAUD) != (old_cflag & CBAUD)) { + /* reassert DTR and (maybe) RTS on transition from B0 */ + if ((old_cflag & CBAUD) == B0) { + dev_dbg(dev, ""%s: baud was B0\n"", __func__); +#if 0 + priv->control_state |= TIOCM_DTR; + /* don't set RTS if using hardware flow control */ + if (!(old_cflag & CRTSCTS)) + priv->control_state |= TIOCM_RTS; + mct_u232_set_modem_ctrl(serial, priv->control_state); +#endif + } + } + switch (baud) { + case 0: /* handled below */ + break; + case 1200: + priv->cfg.baudrate = kl5kusb105a_sio_b1200; + break; + case 2400: + priv->cfg.baudrate = kl5kusb105a_sio_b2400; + break; + case 4800: + priv->cfg.baudrate = kl5kusb105a_sio_b4800; + break; + case 9600: + priv->cfg.baudrate = kl5kusb105a_sio_b9600; + break; + case 19200: + priv->cfg.baudrate = kl5kusb105a_sio_b19200; + break; + case 38400: + priv->cfg.baudrate = kl5kusb105a_sio_b38400; + break; + case 57600: + priv->cfg.baudrate = kl5kusb105a_sio_b57600; + break; + case 115200: + priv->cfg.baudrate = kl5kusb105a_sio_b115200; + break; + default: + dev_dbg(dev, ""unsupported baudrate, using 9600\n""); + priv->cfg.baudrate = kl5kusb105a_sio_b9600; + baud = 9600; + break; + } + if ((cflag & CBAUD) == B0) { + dev_dbg(dev, ""%s: baud is B0\n"", __func__); + /* Drop RTS and DTR */ + /* maybe this should be simulated by sending read + * disable and read enable messages? + */ +#if 0 + priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); + mct_u232_set_modem_ctrl(serial, priv->control_state); +#endif + } + tty_encode_baud_rate(tty, baud, baud); + + if ((cflag & CSIZE) != (old_cflag & CSIZE)) { + /* set the number of data bits */ + switch (cflag & CSIZE) { + case CS5: + dev_dbg(dev, ""%s - 5 bits/byte not supported\n"", __func__); + spin_unlock_irqrestore(&priv->lock, flags); + goto err; + case CS6: + dev_dbg(dev, ""%s - 6 bits/byte not supported\n"", __func__); + spin_unlock_irqrestore(&priv->lock, flags); + goto err; + case CS7: + priv->cfg.databits = kl5kusb105a_dtb_7; + break; + case CS8: + priv->cfg.databits = kl5kusb105a_dtb_8; + break; + default: + dev_err(dev, ""CSIZE was not CS5-CS8, using default of 8\n""); + priv->cfg.databits = kl5kusb105a_dtb_8; + break; + } + } + + /* + * Update line control register (LCR) + */ + if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) + || (cflag & CSTOPB) != (old_cflag & CSTOPB)) { + /* Not currently supported */ + tty->termios.c_cflag &= ~(PARENB|PARODD|CSTOPB); +#if 0 + priv->last_lcr = 0; + + /* set the parity */ + if (cflag & PARENB) + priv->last_lcr |= (cflag & PARODD) ? + MCT_U232_PARITY_ODD : MCT_U232_PARITY_EVEN; + else + priv->last_lcr |= MCT_U232_PARITY_NONE; + + /* set the number of stop bits */ + priv->last_lcr |= (cflag & CSTOPB) ? + MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; + + mct_u232_set_line_ctrl(serial, priv->last_lcr); +#endif + } + /* + * Set flow control: well, I do not really now how to handle DTR/RTS. + * Just do what we have seen with SniffUSB on Win98. + */ + if ((iflag & IXOFF) != (old_iflag & IXOFF) + || (iflag & IXON) != (old_iflag & IXON) + || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { + /* Not currently supported */ + tty->termios.c_cflag &= ~CRTSCTS; + /* Drop DTR/RTS if no flow control otherwise assert */ +#if 0 + if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) + priv->control_state |= TIOCM_DTR | TIOCM_RTS; + else + priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); + mct_u232_set_modem_ctrl(serial, priv->control_state); +#endif + } + memcpy(cfg, &priv->cfg, sizeof(*cfg)); + spin_unlock_irqrestore(&priv->lock, flags); + + /* now commit changes to device */ + klsi_105_chg_port_settings(port, cfg); +err: + kfree(cfg); +} +",0,"static void klsi_105_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, + struct ktermios *old_termios) +{ + struct klsi_105_private *priv = usb_get_serial_port_data(port); + struct device *dev = &port->dev; + unsigned int iflag = tty->termios.c_iflag; + unsigned int old_iflag = old_termios->c_iflag; + unsigned int cflag = tty->termios.c_cflag; + unsigned int old_cflag = old_termios->c_cflag; + struct klsi_105_port_settings *cfg; + unsigned long flags; + speed_t baud; + + cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return; + + /* lock while we are modifying the settings */ + spin_lock_irqsave(&priv->lock, flags); + + /* + * Update baud rate + */ + baud = tty_get_baud_rate(tty); + + if ((cflag & CBAUD) != (old_cflag & CBAUD)) { + /* reassert DTR and (maybe) RTS on transition from B0 */ + if ((old_cflag & CBAUD) == B0) { + dev_dbg(dev, ""%s: baud was B0\n"", __func__); +#if 0 + priv->control_state |= TIOCM_DTR; + /* don't set RTS if using hardware flow control */ + if (!(old_cflag & CRTSCTS)) + priv->control_state |= TIOCM_RTS; + mct_u232_set_modem_ctrl(serial, priv->control_state); +#endif + } + } + switch (baud) { + case 0: /* handled below */ + break; + case 1200: + priv->cfg.baudrate = kl5kusb105a_sio_b1200; + break; + case 2400: + priv->cfg.baudrate = kl5kusb105a_sio_b2400; + break; + case 4800: + priv->cfg.baudrate = kl5kusb105a_sio_b4800; + break; + case 9600: + priv->cfg.baudrate = kl5kusb105a_sio_b9600; + break; + case 19200: + priv->cfg.baudrate = kl5kusb105a_sio_b19200; + break; + case 38400: + priv->cfg.baudrate = kl5kusb105a_sio_b38400; + break; + case 57600: + priv->cfg.baudrate = kl5kusb105a_sio_b57600; + break; + case 115200: + priv->cfg.baudrate = kl5kusb105a_sio_b115200; + break; + default: + dev_dbg(dev, ""unsupported baudrate, using 9600\n""); + priv->cfg.baudrate = kl5kusb105a_sio_b9600; + baud = 9600; + break; + } + if ((cflag & CBAUD) == B0) { + dev_dbg(dev, ""%s: baud is B0\n"", __func__); + /* Drop RTS and DTR */ + /* maybe this should be simulated by sending read + * disable and read enable messages? + */ +#if 0 + priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); + mct_u232_set_modem_ctrl(serial, priv->control_state); +#endif + } + tty_encode_baud_rate(tty, baud, baud); + + if ((cflag & CSIZE) != (old_cflag & CSIZE)) { + /* set the number of data bits */ + switch (cflag & CSIZE) { + case CS5: + dev_dbg(dev, ""%s - 5 bits/byte not supported\n"", __func__); + spin_unlock_irqrestore(&priv->lock, flags); + goto err; + case CS6: + dev_dbg(dev, ""%s - 6 bits/byte not supported\n"", __func__); + spin_unlock_irqrestore(&priv->lock, flags); + goto err; + case CS7: + priv->cfg.databits = kl5kusb105a_dtb_7; + break; + case CS8: + priv->cfg.databits = kl5kusb105a_dtb_8; + break; + default: + dev_err(dev, ""CSIZE was not CS5-CS8, using default of 8\n""); + priv->cfg.databits = kl5kusb105a_dtb_8; + break; + } + } + + /* + * Update line control register (LCR) + */ + if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) + || (cflag & CSTOPB) != (old_cflag & CSTOPB)) { + /* Not currently supported */ + tty->termios.c_cflag &= ~(PARENB|PARODD|CSTOPB); +#if 0 + priv->last_lcr = 0; + + /* set the parity */ + if (cflag & PARENB) + priv->last_lcr |= (cflag & PARODD) ? + MCT_U232_PARITY_ODD : MCT_U232_PARITY_EVEN; + else + priv->last_lcr |= MCT_U232_PARITY_NONE; + + /* set the number of stop bits */ + priv->last_lcr |= (cflag & CSTOPB) ? + MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; + + mct_u232_set_line_ctrl(serial, priv->last_lcr); +#endif + } + /* + * Set flow control: well, I do not really now how to handle DTR/RTS. + * Just do what we have seen with SniffUSB on Win98. + */ + if ((iflag & IXOFF) != (old_iflag & IXOFF) + || (iflag & IXON) != (old_iflag & IXON) + || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { + /* Not currently supported */ + tty->termios.c_cflag &= ~CRTSCTS; + /* Drop DTR/RTS if no flow control otherwise assert */ +#if 0 + if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) + priv->control_state |= TIOCM_DTR | TIOCM_RTS; + else + priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); + mct_u232_set_modem_ctrl(serial, priv->control_state); +#endif + } + memcpy(cfg, &priv->cfg, sizeof(*cfg)); + spin_unlock_irqrestore(&priv->lock, flags); + + /* now commit changes to device */ + klsi_105_chg_port_settings(port, cfg); +err: + kfree(cfg); +} +","@@ -192,10 +192,11 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, + status_buf, KLSI_STATUSBUF_LEN, + 10000 + ); +- if (rc < 0) +- dev_err(&port->dev, ""Reading line status failed (error = %d)\n"", +- rc); +- else { ++ if (rc != KLSI_STATUSBUF_LEN) { ++ dev_err(&port->dev, ""reading line status failed: %d\n"", rc); ++ if (rc >= 0) ++ rc = -EIO; ++ } else { + status = get_unaligned_le16(status_buf); + + dev_info(&port->serial->dev->dev, ""read status %x %x\n"",",1588,1824,2048 +17841,"xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node, + struct stop *stops, int maxcount) + { + fz_colorspace *colorspace; + float sample[8]; + float rgb[3]; + int before, after; + int count; + int i; + + /* We may have to insert 2 extra stops when postprocessing */ + maxcount -= 2; + + count = 0; + while (node && count < maxcount) + { + if (!strcmp(fz_xml_tag(node), ""GradientStop"")) + { + char *offset = fz_xml_att(node, ""Offset""); + char *color = fz_xml_att(node, ""Color""); + if (offset && color) + { + stops[count].offset = fz_atof(offset); + stops[count].index = count; + + xps_parse_color(doc, base_uri, color, &colorspace, sample); + + fz_convert_color(doc->ctx, fz_device_rgb(doc->ctx), rgb, colorspace, sample + 1); + + stops[count].r = rgb[0]; + stops[count].g = rgb[1]; + stops[count].b = rgb[2]; + stops[count].a = sample[0]; + + count ++; + } + } + node = fz_xml_next(node); + } + + if (count == 0) + { + fz_warn(doc->ctx, ""gradient brush has no gradient stops""); + stops[0].offset = 0; + stops[0].r = 0; + stops[0].g = 0; + stops[0].b = 0; + stops[0].a = 1; + stops[1].offset = 1; + stops[1].r = 1; + stops[1].g = 1; + stops[1].b = 1; + stops[1].a = 1; + return 2; + } + + if (count == maxcount) + fz_warn(doc->ctx, ""gradient brush exceeded maximum number of gradient stops""); + + /* Postprocess to make sure the range of offsets is 0.0 to 1.0 */ + + qsort(stops, count, sizeof(struct stop), cmp_stop); + + before = -1; + after = -1; + + for (i = 0; i < count; i++) + { + if (stops[i].offset < 0) + before = i; + if (stops[i].offset > 1) + { + after = i; + break; + } + } + + /* Remove all stops < 0 except the largest one */ + if (before > 0) + { + memmove(stops, stops + before, (count - before) * sizeof(struct stop)); + count -= before; + } + + /* Remove all stops > 1 except the smallest one */ + if (after >= 0) + count = after + 1; + + /* Expand single stop to 0 .. 1 */ + if (count == 1) + { + stops[1] = stops[0]; + stops[0].offset = 0; + stops[1].offset = 1; + return 2; + } + + /* First stop < 0 -- interpolate value to 0 */ + if (stops[0].offset < 0) + { + float d = -stops[0].offset / (stops[1].offset - stops[0].offset); + stops[0].offset = 0; + stops[0].r = lerp(stops[0].r, stops[1].r, d); + stops[0].g = lerp(stops[0].g, stops[1].g, d); + stops[0].b = lerp(stops[0].b, stops[1].b, d); + stops[0].a = lerp(stops[0].a, stops[1].a, d); + } + + /* Last stop > 1 -- interpolate value to 1 */ + if (stops[count-1].offset > 1) + { + float d = (1 - stops[count-2].offset) / (stops[count-1].offset - stops[count-2].offset); + stops[count-1].offset = 1; + stops[count-1].r = lerp(stops[count-2].r, stops[count-1].r, d); + stops[count-1].g = lerp(stops[count-2].g, stops[count-1].g, d); + stops[count-1].b = lerp(stops[count-2].b, stops[count-1].b, d); + stops[count-1].a = lerp(stops[count-2].a, stops[count-1].a, d); + } + + /* First stop > 0 -- insert a duplicate at 0 */ + if (stops[0].offset > 0) + { + memmove(stops + 1, stops, count * sizeof(struct stop)); + stops[0] = stops[1]; + stops[0].offset = 0; + count++; + } + + /* Last stop < 1 -- insert a duplicate at 1 */ + if (stops[count-1].offset < 1) + { + stops[count] = stops[count-1]; + stops[count].offset = 1; + count++; + } + + return count; +} +",1,"xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node, + struct stop *stops, int maxcount) + { + fz_colorspace *colorspace; + float sample[FZ_MAX_COLORS]; + float rgb[3]; + int before, after; + int count; + int i; + + /* We may have to insert 2 extra stops when postprocessing */ + maxcount -= 2; + + count = 0; + while (node && count < maxcount) + { + if (!strcmp(fz_xml_tag(node), ""GradientStop"")) + { + char *offset = fz_xml_att(node, ""Offset""); + char *color = fz_xml_att(node, ""Color""); + if (offset && color) + { + stops[count].offset = fz_atof(offset); + stops[count].index = count; + + xps_parse_color(doc, base_uri, color, &colorspace, sample); + + fz_convert_color(doc->ctx, fz_device_rgb(doc->ctx), rgb, colorspace, sample + 1); + + stops[count].r = rgb[0]; + stops[count].g = rgb[1]; + stops[count].b = rgb[2]; + stops[count].a = sample[0]; + + count ++; + } + } + node = fz_xml_next(node); + } + + if (count == 0) + { + fz_warn(doc->ctx, ""gradient brush has no gradient stops""); + stops[0].offset = 0; + stops[0].r = 0; + stops[0].g = 0; + stops[0].b = 0; + stops[0].a = 1; + stops[1].offset = 1; + stops[1].r = 1; + stops[1].g = 1; + stops[1].b = 1; + stops[1].a = 1; + return 2; + } + + if (count == maxcount) + fz_warn(doc->ctx, ""gradient brush exceeded maximum number of gradient stops""); + + /* Postprocess to make sure the range of offsets is 0.0 to 1.0 */ + + qsort(stops, count, sizeof(struct stop), cmp_stop); + + before = -1; + after = -1; + + for (i = 0; i < count; i++) + { + if (stops[i].offset < 0) + before = i; + if (stops[i].offset > 1) + { + after = i; + break; + } + } + + /* Remove all stops < 0 except the largest one */ + if (before > 0) + { + memmove(stops, stops + before, (count - before) * sizeof(struct stop)); + count -= before; + } + + /* Remove all stops > 1 except the smallest one */ + if (after >= 0) + count = after + 1; + + /* Expand single stop to 0 .. 1 */ + if (count == 1) + { + stops[1] = stops[0]; + stops[0].offset = 0; + stops[1].offset = 1; + return 2; + } + + /* First stop < 0 -- interpolate value to 0 */ + if (stops[0].offset < 0) + { + float d = -stops[0].offset / (stops[1].offset - stops[0].offset); + stops[0].offset = 0; + stops[0].r = lerp(stops[0].r, stops[1].r, d); + stops[0].g = lerp(stops[0].g, stops[1].g, d); + stops[0].b = lerp(stops[0].b, stops[1].b, d); + stops[0].a = lerp(stops[0].a, stops[1].a, d); + } + + /* Last stop > 1 -- interpolate value to 1 */ + if (stops[count-1].offset > 1) + { + float d = (1 - stops[count-2].offset) / (stops[count-1].offset - stops[count-2].offset); + stops[count-1].offset = 1; + stops[count-1].r = lerp(stops[count-2].r, stops[count-1].r, d); + stops[count-1].g = lerp(stops[count-2].g, stops[count-1].g, d); + stops[count-1].b = lerp(stops[count-2].b, stops[count-1].b, d); + stops[count-1].a = lerp(stops[count-2].a, stops[count-1].a, d); + } + + /* First stop > 0 -- insert a duplicate at 0 */ + if (stops[0].offset > 0) + { + memmove(stops + 1, stops, count * sizeof(struct stop)); + stops[0] = stops[1]; + stops[0].offset = 0; + count++; + } + + /* Last stop < 1 -- insert a duplicate at 1 */ + if (stops[count-1].offset < 1) + { + stops[count] = stops[count-1]; + stops[count].offset = 1; + count++; + } + + return count; +} +","@@ -39,7 +39,7 @@ xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node, + struct stop *stops, int maxcount) + { + fz_colorspace *colorspace; +- float sample[8]; ++ float sample[FZ_MAX_COLORS]; + float rgb[3]; + int before, after; + int count;",1174,1410,2048 +3111,"vmci_transport_recv_connecting_server(struct sock *listener, + struct sock *pending, + struct vmci_transport_packet *pkt) +{ + struct vsock_sock *vpending; + struct vmci_handle handle; + struct vmci_qp *qpair; + bool is_local; + u32 flags; + u32 detach_sub_id; + int err; + int skerr; + + vpending = vsock_sk(pending); + detach_sub_id = VMCI_INVALID_ID; + + switch (pkt->type) { + case VMCI_TRANSPORT_PACKET_TYPE_OFFER: + if (vmci_handle_is_invalid(pkt->u.handle)) { + vmci_transport_send_reset(pending, pkt); + skerr = EPROTO; + err = -EINVAL; + goto destroy; + } + break; + default: + /* Close and cleanup the connection. */ + vmci_transport_send_reset(pending, pkt); + skerr = EPROTO; + err = pkt->type == VMCI_TRANSPORT_PACKET_TYPE_RST ? 0 : -EINVAL; + goto destroy; + } + + /* In order to complete the connection we need to attach to the offered + * queue pair and send an attach notification. We also subscribe to the + * detach event so we know when our peer goes away, and we do that + * before attaching so we don't miss an event. If all this succeeds, + * we update our state and wakeup anything waiting in accept() for a + * connection. + */ + + /* We don't care about attach since we ensure the other side has + * attached by specifying the ATTACH_ONLY flag below. + */ + err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_DETACH, + vmci_transport_peer_detach_cb, + pending, &detach_sub_id); + if (err < VMCI_SUCCESS) { + vmci_transport_send_reset(pending, pkt); + err = vmci_transport_error_to_vsock_error(err); + skerr = -err; + goto destroy; + } + + vmci_trans(vpending)->detach_sub_id = detach_sub_id; + + /* Now attach to the queue pair the client created. */ + handle = pkt->u.handle; + + /* vpending->local_addr always has a context id so we do not need to + * worry about VMADDR_CID_ANY in this case. + */ + is_local = + vpending->remote_addr.svm_cid == vpending->local_addr.svm_cid; + flags = VMCI_QPFLAG_ATTACH_ONLY; + flags |= is_local ? VMCI_QPFLAG_LOCAL : 0; + + err = vmci_transport_queue_pair_alloc( + &qpair, + &handle, + vmci_trans(vpending)->produce_size, + vmci_trans(vpending)->consume_size, + pkt->dg.src.context, + flags, + vmci_transport_is_trusted( + vpending, + vpending->remote_addr.svm_cid)); + if (err < 0) { + vmci_transport_send_reset(pending, pkt); + skerr = -err; + goto destroy; + } + + vmci_trans(vpending)->qp_handle = handle; + vmci_trans(vpending)->qpair = qpair; + + /* When we send the attach message, we must be ready to handle incoming + * control messages on the newly connected socket. So we move the + * pending socket to the connected state before sending the attach + * message. Otherwise, an incoming packet triggered by the attach being + * received by the peer may be processed concurrently with what happens + * below after sending the attach message, and that incoming packet + * will find the listening socket instead of the (currently) pending + * socket. Note that enqueueing the socket increments the reference + * count, so even if a reset comes before the connection is accepted, + * the socket will be valid until it is removed from the queue. + * + * If we fail sending the attach below, we remove the socket from the + * connected list and move the socket to SS_UNCONNECTED before + * releasing the lock, so a pending slow path processing of an incoming + * packet will not see the socket in the connected state in that case. + */ + pending->sk_state = SS_CONNECTED; + + vsock_insert_connected(vpending); + + /* Notify our peer of our attach. */ + err = vmci_transport_send_attach(pending, handle); + if (err < 0) { + vsock_remove_connected(vpending); + pr_err(""Could not send attach\n""); + vmci_transport_send_reset(pending, pkt); + err = vmci_transport_error_to_vsock_error(err); + skerr = -err; + goto destroy; + } + + /* We have a connection. Move the now connected socket from the + * listener's pending list to the accept queue so callers of accept() + * can find it. + */ + vsock_remove_pending(listener, pending); + vsock_enqueue_accept(listener, pending); + + /* Callers of accept() will be be waiting on the listening socket, not + * the pending socket. + */ + listener->sk_state_change(listener); + + return 0; + +destroy: + pending->sk_err = skerr; + pending->sk_state = SS_UNCONNECTED; + /* As long as we drop our reference, all necessary cleanup will handle + * when the cleanup function drops its reference and our destruct + * implementation is called. Note that since the listen handler will + * remove pending from the pending list upon our failure, the cleanup + * function won't drop the additional reference, which is why we do it + * here. + */ + sock_put(pending); + + return err; +} +",0,"vmci_transport_recv_connecting_server(struct sock *listener, + struct sock *pending, + struct vmci_transport_packet *pkt) +{ + struct vsock_sock *vpending; + struct vmci_handle handle; + struct vmci_qp *qpair; + bool is_local; + u32 flags; + u32 detach_sub_id; + int err; + int skerr; + + vpending = vsock_sk(pending); + detach_sub_id = VMCI_INVALID_ID; + + switch (pkt->type) { + case VMCI_TRANSPORT_PACKET_TYPE_OFFER: + if (vmci_handle_is_invalid(pkt->u.handle)) { + vmci_transport_send_reset(pending, pkt); + skerr = EPROTO; + err = -EINVAL; + goto destroy; + } + break; + default: + /* Close and cleanup the connection. */ + vmci_transport_send_reset(pending, pkt); + skerr = EPROTO; + err = pkt->type == VMCI_TRANSPORT_PACKET_TYPE_RST ? 0 : -EINVAL; + goto destroy; + } + + /* In order to complete the connection we need to attach to the offered + * queue pair and send an attach notification. We also subscribe to the + * detach event so we know when our peer goes away, and we do that + * before attaching so we don't miss an event. If all this succeeds, + * we update our state and wakeup anything waiting in accept() for a + * connection. + */ + + /* We don't care about attach since we ensure the other side has + * attached by specifying the ATTACH_ONLY flag below. + */ + err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_DETACH, + vmci_transport_peer_detach_cb, + pending, &detach_sub_id); + if (err < VMCI_SUCCESS) { + vmci_transport_send_reset(pending, pkt); + err = vmci_transport_error_to_vsock_error(err); + skerr = -err; + goto destroy; + } + + vmci_trans(vpending)->detach_sub_id = detach_sub_id; + + /* Now attach to the queue pair the client created. */ + handle = pkt->u.handle; + + /* vpending->local_addr always has a context id so we do not need to + * worry about VMADDR_CID_ANY in this case. + */ + is_local = + vpending->remote_addr.svm_cid == vpending->local_addr.svm_cid; + flags = VMCI_QPFLAG_ATTACH_ONLY; + flags |= is_local ? VMCI_QPFLAG_LOCAL : 0; + + err = vmci_transport_queue_pair_alloc( + &qpair, + &handle, + vmci_trans(vpending)->produce_size, + vmci_trans(vpending)->consume_size, + pkt->dg.src.context, + flags, + vmci_transport_is_trusted( + vpending, + vpending->remote_addr.svm_cid)); + if (err < 0) { + vmci_transport_send_reset(pending, pkt); + skerr = -err; + goto destroy; + } + + vmci_trans(vpending)->qp_handle = handle; + vmci_trans(vpending)->qpair = qpair; + + /* When we send the attach message, we must be ready to handle incoming + * control messages on the newly connected socket. So we move the + * pending socket to the connected state before sending the attach + * message. Otherwise, an incoming packet triggered by the attach being + * received by the peer may be processed concurrently with what happens + * below after sending the attach message, and that incoming packet + * will find the listening socket instead of the (currently) pending + * socket. Note that enqueueing the socket increments the reference + * count, so even if a reset comes before the connection is accepted, + * the socket will be valid until it is removed from the queue. + * + * If we fail sending the attach below, we remove the socket from the + * connected list and move the socket to SS_UNCONNECTED before + * releasing the lock, so a pending slow path processing of an incoming + * packet will not see the socket in the connected state in that case. + */ + pending->sk_state = SS_CONNECTED; + + vsock_insert_connected(vpending); + + /* Notify our peer of our attach. */ + err = vmci_transport_send_attach(pending, handle); + if (err < 0) { + vsock_remove_connected(vpending); + pr_err(""Could not send attach\n""); + vmci_transport_send_reset(pending, pkt); + err = vmci_transport_error_to_vsock_error(err); + skerr = -err; + goto destroy; + } + + /* We have a connection. Move the now connected socket from the + * listener's pending list to the accept queue so callers of accept() + * can find it. + */ + vsock_remove_pending(listener, pending); + vsock_enqueue_accept(listener, pending); + + /* Callers of accept() will be be waiting on the listening socket, not + * the pending socket. + */ + listener->sk_state_change(listener); + + return 0; + +destroy: + pending->sk_err = skerr; + pending->sk_state = SS_UNCONNECTED; + /* As long as we drop our reference, all necessary cleanup will handle + * when the cleanup function drops its reference and our destruct + * implementation is called. Note that since the listen handler will + * remove pending from the pending list upon our failure, the cleanup + * function won't drop the additional reference, which is why we do it + * here. + */ + sock_put(pending); + + return err; +} +","@@ -1736,6 +1736,8 @@ static int vmci_transport_dgram_dequeue(struct kiocb *kiocb, + if (flags & MSG_OOB || flags & MSG_ERRQUEUE) + return -EOPNOTSUPP; + ++ msg->msg_namelen = 0; ++ + /* Retrieve the head sk_buff from the socket's receive queue. */ + err = 0; + skb = skb_recv_datagram(&vsk->sk, flags, noblock, &err); +@@ -1768,7 +1770,6 @@ static int vmci_transport_dgram_dequeue(struct kiocb *kiocb, + if (err) + goto out; + +- msg->msg_namelen = 0; + if (msg->msg_name) { + struct sockaddr_vm *vm_addr; + ",1182,1418,2048 +18003,"SPL_METHOD(Array, unserialize) +{ + spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + + char *buf; + int buf_len; + const unsigned char *p, *s; + php_unserialize_data_t var_hash; + zval *pmembers, *pflags = NULL; + HashTable *aht; + long flags; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""s"", &buf, &buf_len) == FAILURE) { + return; + } + + if (buf_len == 0) { + return; + } + + aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); + if (aht->nApplyCount > 0) { + zend_error(E_WARNING, ""Modification of ArrayObject during sorting is prohibited""); + return; + } + + /* storage */ + s = p = (const unsigned char*)buf; + PHP_VAR_UNSERIALIZE_INIT(var_hash); + + if (*p!= 'x' || *++p != ':') { + goto outexcept; + } + ++p; + + ALLOC_INIT_ZVAL(pflags); + if (!php_var_unserialize(&pflags, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pflags) != IS_LONG) { + goto outexcept; + } + + var_push_dtor(&var_hash, &pflags); + --p; /* for ';' */ + flags = Z_LVAL_P(pflags); + /* flags needs to be verified and we also need to verify whether the next + * thing we get is ';'. After that we require an 'm' or somethign else + * where 'm' stands for members and anything else should be an array. If + * neither 'a' or 'm' follows we have an error. */ + + if (*p != ';') { + goto outexcept; + } + ++p; + + if (*p!='m') { + if (*p!='a' && *p!='O' && *p!='C' && *p!='r') { + goto outexcept; + } + intern->ar_flags &= ~SPL_ARRAY_CLONE_MASK; + intern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK; + zval_ptr_dtor(&intern->array); + ALLOC_INIT_ZVAL(intern->array); + if (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash TSRMLS_CC)) { + goto outexcept; + } + var_push_dtor(&var_hash, &intern->array); + } + if (*p != ';') { + goto outexcept; + } + ++p; + + /* members */ + if (*p!= 'm' || *++p != ':') { + goto outexcept; + } + ++p; + + ALLOC_INIT_ZVAL(pmembers); + if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) { + zval_ptr_dtor(&pmembers); + goto outexcept; + } + + var_push_dtor(&var_hash, &pmembers); + /* copy members */ + if (!intern->std.properties) { + rebuild_object_properties(&intern->std); + } + zend_hash_copy(intern->std.properties, Z_ARRVAL_P(pmembers), (copy_ctor_func_t) zval_add_ref, (void *) NULL, sizeof(zval *)); + zval_ptr_dtor(&pmembers); + + /* done reading $serialized */ + + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + if (pflags) { + zval_ptr_dtor(&pflags); + } + return; + +outexcept: + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + if (pflags) { + zval_ptr_dtor(&pflags); + } + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Error at offset %ld of %d bytes"", (long)((char*)p - buf), buf_len); + return; + +} /* }}} */ + +/* {{{ arginfo and function table */ +",1,"SPL_METHOD(Array, unserialize) +{ + spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + + char *buf; + int buf_len; + const unsigned char *p, *s; + php_unserialize_data_t var_hash; + zval *pmembers, *pflags = NULL; + HashTable *aht; + long flags; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""s"", &buf, &buf_len) == FAILURE) { + return; + } + + if (buf_len == 0) { + return; + } + + aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); + if (aht->nApplyCount > 0) { + zend_error(E_WARNING, ""Modification of ArrayObject during sorting is prohibited""); + return; + } + + /* storage */ + s = p = (const unsigned char*)buf; + PHP_VAR_UNSERIALIZE_INIT(var_hash); + + if (*p!= 'x' || *++p != ':') { + goto outexcept; + } + ++p; + + ALLOC_INIT_ZVAL(pflags); + if (!php_var_unserialize(&pflags, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pflags) != IS_LONG) { + goto outexcept; + } + + var_push_dtor(&var_hash, &pflags); + --p; /* for ';' */ + flags = Z_LVAL_P(pflags); + /* flags needs to be verified and we also need to verify whether the next + * thing we get is ';'. After that we require an 'm' or somethign else + * where 'm' stands for members and anything else should be an array. If + * neither 'a' or 'm' follows we have an error. */ + + if (*p != ';') { + goto outexcept; + } + ++p; + + if (*p!='m') { + if (*p!='a' && *p!='O' && *p!='C' && *p!='r') { + goto outexcept; + } + intern->ar_flags &= ~SPL_ARRAY_CLONE_MASK; + intern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK; + zval_ptr_dtor(&intern->array); + ALLOC_INIT_ZVAL(intern->array); + if (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash TSRMLS_CC) + || (Z_TYPE_P(intern->array) != IS_ARRAY && Z_TYPE_P(intern->array) != IS_OBJECT)) { + zval_ptr_dtor(&intern->array); + goto outexcept; + } + var_push_dtor(&var_hash, &intern->array); + } + if (*p != ';') { + goto outexcept; + } + ++p; + + /* members */ + if (*p!= 'm' || *++p != ':') { + goto outexcept; + } + ++p; + + ALLOC_INIT_ZVAL(pmembers); + if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) { + zval_ptr_dtor(&pmembers); + goto outexcept; + } + + var_push_dtor(&var_hash, &pmembers); + /* copy members */ + if (!intern->std.properties) { + rebuild_object_properties(&intern->std); + } + zend_hash_copy(intern->std.properties, Z_ARRVAL_P(pmembers), (copy_ctor_func_t) zval_add_ref, (void *) NULL, sizeof(zval *)); + zval_ptr_dtor(&pmembers); + + /* done reading $serialized */ + + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + if (pflags) { + zval_ptr_dtor(&pflags); + } + return; + +outexcept: + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + if (pflags) { + zval_ptr_dtor(&pflags); + } + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Error at offset %ld of %d bytes"", (long)((char*)p - buf), buf_len); + return; + +} /* }}} */ + +/* {{{ arginfo and function table */ +","@@ -308,7 +308,7 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object, + long index; + HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); + +- if (!offset) { ++ if (!offset || !ht) { + return &EG(uninitialized_zval_ptr); + } + +@@ -626,7 +626,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o + HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); + + switch(Z_TYPE_P(offset)) { +- case IS_STRING: ++ case IS_STRING: + if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE) { + if (check_empty == 2) { + return 1; +@@ -638,7 +638,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o + + case IS_DOUBLE: + case IS_RESOURCE: +- case IS_BOOL: ++ case IS_BOOL: + case IS_LONG: + if (offset->type == IS_DOUBLE) { + index = (long)Z_DVAL_P(offset); +@@ -1810,7 +1810,9 @@ SPL_METHOD(Array, unserialize) + intern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK; + zval_ptr_dtor(&intern->array); + ALLOC_INIT_ZVAL(intern->array); +- if (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash TSRMLS_CC)) { ++ if (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash TSRMLS_CC) ++ || (Z_TYPE_P(intern->array) != IS_ARRAY && Z_TYPE_P(intern->array) != IS_OBJECT)) { ++ zval_ptr_dtor(&intern->array); + goto outexcept; + } + var_push_dtor(&var_hash, &intern->array);",861,1097,2048 +17814,"int v9fs_device_realize_common(V9fsState *s, Error **errp) +{ + V9fsVirtioState *v = container_of(s, V9fsVirtioState, state); + int i, len; + struct stat stat; + FsDriverEntry *fse; + V9fsPath path; + int rc = 1; + + /* initialize pdu allocator */ + QLIST_INIT(&s->free_list); + QLIST_INIT(&s->active_list); + for (i = 0; i < (MAX_REQ - 1); i++) { + QLIST_INSERT_HEAD(&s->free_list, &v->pdus[i], next); + v->pdus[i].s = s; + v->pdus[i].idx = i; + } + + v9fs_path_init(&path); + + fse = get_fsdev_fsentry(s->fsconf.fsdev_id); + + if (!fse) { + /* We don't have a fsdev identified by fsdev_id */ + error_setg(errp, ""9pfs device couldn't find fsdev with the "" + ""id = %s"", + s->fsconf.fsdev_id ? s->fsconf.fsdev_id : ""NULL""); + goto out; + } + + if (!s->fsconf.tag) { + /* we haven't specified a mount_tag */ + error_setg(errp, ""fsdev with id %s needs mount_tag arguments"", + s->fsconf.fsdev_id); + goto out; + } + + s->ctx.export_flags = fse->export_flags; + s->ctx.fs_root = g_strdup(fse->path); + s->ctx.exops.get_st_gen = NULL; + len = strlen(s->fsconf.tag); + if (len > MAX_TAG_LEN - 1) { + error_setg(errp, ""mount tag '%s' (%d bytes) is longer than "" + ""maximum (%d bytes)"", s->fsconf.tag, len, MAX_TAG_LEN - 1); + goto out; + } + + s->tag = g_strdup(s->fsconf.tag); + s->ctx.uid = -1; + + s->ops = fse->ops; + + s->fid_list = NULL; + qemu_co_rwlock_init(&s->rename_lock); + + if (s->ops->init(&s->ctx) < 0) { + error_setg(errp, ""9pfs Failed to initialize fs-driver with id:%s"" + "" and export path:%s"", s->fsconf.fsdev_id, s->ctx.fs_root); + goto out; + } + + /* + * Check details of export path, We need to use fs driver + * call back to do that. Since we are in the init path, we don't + * use co-routines here. + */ + if (s->ops->name_to_path(&s->ctx, NULL, ""/"", &path) < 0) { + error_setg(errp, + ""error in converting name to path %s"", strerror(errno)); + goto out; + } + if (s->ops->lstat(&s->ctx, &path, &stat)) { + error_setg(errp, ""share path %s does not exist"", fse->path); + goto out; + } else if (!S_ISDIR(stat.st_mode)) { + error_setg(errp, ""share path %s is not a directory"", fse->path); + goto out; + } + v9fs_path_free(&path); + + rc = 0; + out: + if (rc) { + g_free(s->ctx.fs_root); + g_free(s->tag); + v9fs_path_free(&path); + } + return rc; +} +",1,"int v9fs_device_realize_common(V9fsState *s, Error **errp) +{ + V9fsVirtioState *v = container_of(s, V9fsVirtioState, state); + int i, len; + struct stat stat; + FsDriverEntry *fse; + V9fsPath path; + int rc = 1; + + /* initialize pdu allocator */ + QLIST_INIT(&s->free_list); + QLIST_INIT(&s->active_list); + for (i = 0; i < (MAX_REQ - 1); i++) { + QLIST_INSERT_HEAD(&s->free_list, &v->pdus[i], next); + v->pdus[i].s = s; + v->pdus[i].idx = i; + } + + v9fs_path_init(&path); + + fse = get_fsdev_fsentry(s->fsconf.fsdev_id); + + if (!fse) { + /* We don't have a fsdev identified by fsdev_id */ + error_setg(errp, ""9pfs device couldn't find fsdev with the "" + ""id = %s"", + s->fsconf.fsdev_id ? s->fsconf.fsdev_id : ""NULL""); + goto out; + } + + if (!s->fsconf.tag) { + /* we haven't specified a mount_tag */ + error_setg(errp, ""fsdev with id %s needs mount_tag arguments"", + s->fsconf.fsdev_id); + goto out; + } + + s->ctx.export_flags = fse->export_flags; + s->ctx.fs_root = g_strdup(fse->path); + s->ctx.exops.get_st_gen = NULL; + len = strlen(s->fsconf.tag); + if (len > MAX_TAG_LEN - 1) { + error_setg(errp, ""mount tag '%s' (%d bytes) is longer than "" + ""maximum (%d bytes)"", s->fsconf.tag, len, MAX_TAG_LEN - 1); + goto out; + } + + s->tag = g_strdup(s->fsconf.tag); + s->ctx.uid = -1; + + s->ops = fse->ops; + + s->fid_list = NULL; + qemu_co_rwlock_init(&s->rename_lock); + + if (s->ops->init(&s->ctx) < 0) { + error_setg(errp, ""9pfs Failed to initialize fs-driver with id:%s"" + "" and export path:%s"", s->fsconf.fsdev_id, s->ctx.fs_root); + goto out; + } + + /* + * Check details of export path, We need to use fs driver + * call back to do that. Since we are in the init path, we don't + * use co-routines here. + */ + if (s->ops->name_to_path(&s->ctx, NULL, ""/"", &path) < 0) { + error_setg(errp, + ""error in converting name to path %s"", strerror(errno)); + goto out; + } + if (s->ops->lstat(&s->ctx, &path, &stat)) { + error_setg(errp, ""share path %s does not exist"", fse->path); + goto out; + } else if (!S_ISDIR(stat.st_mode)) { + error_setg(errp, ""share path %s is not a directory"", fse->path); + goto out; + } + v9fs_path_free(&path); + + rc = 0; + out: + if (rc) { + g_free(s->tag); + g_free(s->ctx.fs_root); + v9fs_path_free(&path); + } + return rc; +} +","@@ -3521,8 +3521,8 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp) + rc = 0; + out: + if (rc) { +- g_free(s->ctx.fs_root); + g_free(s->tag); ++ g_free(s->ctx.fs_root); + v9fs_path_free(&path); + } + return rc; +@@ -3530,8 +3530,8 @@ out: + + void v9fs_device_unrealize_common(V9fsState *s, Error **errp) + { +- g_free(s->ctx.fs_root); + g_free(s->tag); ++ g_free(s->ctx.fs_root); + } + + typedef struct VirtfsCoResetData {",795,1031,2048 +18550,"void CompositingLayerPropertyUpdater::Update(const LayoutObject& object) { + if (!RuntimeEnabledFeatures::SlimmingPaintV175Enabled() || + RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) + return; + + if (object.GetDocument().Printing() && + !RuntimeEnabledFeatures::PrintBrowserEnabled()) + return; + + if (!object.HasLayer()) + return; + const auto* paint_layer = ToLayoutBoxModelObject(object).Layer(); + const auto* mapping = paint_layer->GetCompositedLayerMapping(); + if (!mapping) + return; + + const FragmentData& fragment_data = object.FirstFragment(); + DCHECK(fragment_data.HasLocalBorderBoxProperties()); + DCHECK(!fragment_data.NextFragment()); + + LayoutPoint layout_snapped_paint_offset = + fragment_data.PaintOffset() - mapping->SubpixelAccumulation(); + IntPoint snapped_paint_offset = RoundedIntPoint(layout_snapped_paint_offset); + +#if 0 + bool subpixel_accumulation_may_be_bogus = paint_layer->SubtreeIsInvisible(); + DCHECK(layout_snapped_paint_offset == snapped_paint_offset || + subpixel_accumulation_may_be_bogus); +#endif + + base::Optional container_layer_state; + auto SetContainerLayerState = + [&fragment_data, &snapped_paint_offset, + &container_layer_state](GraphicsLayer* graphics_layer) { + if (graphics_layer) { + if (!container_layer_state) { + container_layer_state = fragment_data.LocalBorderBoxProperties(); + if (const auto* properties = fragment_data.PaintProperties()) { + if (const auto* css_clip = properties->CssClip()) + container_layer_state->SetClip(css_clip->Parent()); + } + } + graphics_layer->SetLayerState( + *container_layer_state, + snapped_paint_offset + graphics_layer->OffsetFromLayoutObject()); + } + }; + SetContainerLayerState(mapping->MainGraphicsLayer()); + SetContainerLayerState(mapping->DecorationOutlineLayer()); + SetContainerLayerState(mapping->ChildClippingMaskLayer()); + + base::Optional scrollbar_layer_state; + + auto SetContainerLayerStateForScrollbars = + [&fragment_data, &snapped_paint_offset, &container_layer_state, + &scrollbar_layer_state](GraphicsLayer* graphics_layer) { + if (graphics_layer) { + if (!scrollbar_layer_state) { + if (container_layer_state) { + scrollbar_layer_state = container_layer_state; + } else { + scrollbar_layer_state = fragment_data.LocalBorderBoxProperties(); + } + + if (const auto* properties = fragment_data.PaintProperties()) { + if (const auto* clip = properties->OverflowControlsClip()) { + scrollbar_layer_state->SetClip(clip); + } else if (const auto* css_clip = properties->CssClip()) { + scrollbar_layer_state->SetClip(css_clip->Parent()); + } + } + } + graphics_layer->SetLayerState( + *scrollbar_layer_state, + snapped_paint_offset + graphics_layer->OffsetFromLayoutObject()); + } + }; + + SetContainerLayerStateForScrollbars(mapping->LayerForHorizontalScrollbar()); + SetContainerLayerStateForScrollbars(mapping->LayerForVerticalScrollbar()); + SetContainerLayerStateForScrollbars(mapping->LayerForScrollCorner()); + + if (mapping->ScrollingContentsLayer()) { + auto paint_offset = snapped_paint_offset; + + if (object.IsBox() && object.HasFlippedBlocksWritingMode()) + paint_offset.Move(ToLayoutBox(object).VerticalScrollbarWidth(), 0); + + auto SetContentsLayerState = + [&fragment_data, &paint_offset](GraphicsLayer* graphics_layer) { + if (graphics_layer) { + graphics_layer->SetLayerState( + fragment_data.ContentsProperties(), + paint_offset + graphics_layer->OffsetFromLayoutObject()); + } + }; + SetContentsLayerState(mapping->ScrollingContentsLayer()); + SetContentsLayerState(mapping->ForegroundLayer()); + } else { + SetContainerLayerState(mapping->ForegroundLayer()); + } + + if (auto* squashing_layer = mapping->SquashingLayer()) { + auto state = fragment_data.PreEffectProperties(); + const auto* clipping_container = paint_layer->ClippingContainer(); + state.SetClip( + clipping_container + ? clipping_container->FirstFragment().ContentsProperties().Clip() + : ClipPaintPropertyNode::Root()); + squashing_layer->SetLayerState( + state, + snapped_paint_offset + mapping->SquashingLayerOffsetFromLayoutObject()); + } + + if (auto* mask_layer = mapping->MaskLayer()) { + auto state = fragment_data.LocalBorderBoxProperties(); + const auto* properties = fragment_data.PaintProperties(); + DCHECK(properties && properties->Mask()); + state.SetEffect(properties->Mask()); + state.SetClip(properties->MaskClip()); + + mask_layer->SetLayerState( + state, snapped_paint_offset + mask_layer->OffsetFromLayoutObject()); + } + + if (auto* ancestor_clipping_mask_layer = + mapping->AncestorClippingMaskLayer()) { + PropertyTreeState state( + fragment_data.PreTransform(), + mapping->ClipInheritanceAncestor() + ->GetLayoutObject() + .FirstFragment() + .PostOverflowClip(), + fragment_data.PreFilter()); + ancestor_clipping_mask_layer->SetLayerState( + state, snapped_paint_offset + + ancestor_clipping_mask_layer->OffsetFromLayoutObject()); + } + + if (auto* child_clipping_mask_layer = mapping->ChildClippingMaskLayer()) { + PropertyTreeState state = fragment_data.LocalBorderBoxProperties(); + state.SetEffect(fragment_data.PreFilter()); + child_clipping_mask_layer->SetLayerState( + state, snapped_paint_offset + + child_clipping_mask_layer->OffsetFromLayoutObject()); + } +} +",1,"void CompositingLayerPropertyUpdater::Update(const LayoutObject& object) { + if (!RuntimeEnabledFeatures::SlimmingPaintV175Enabled() || + RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) + return; + + if (object.GetDocument().Printing() && + !RuntimeEnabledFeatures::PrintBrowserEnabled()) + return; + + if (!object.HasLayer()) + return; + const auto* paint_layer = ToLayoutBoxModelObject(object).Layer(); + const auto* mapping = paint_layer->GetCompositedLayerMapping(); + if (!mapping) + return; + + const FragmentData& fragment_data = object.FirstFragment(); + DCHECK(fragment_data.HasLocalBorderBoxProperties()); + DCHECK(!fragment_data.NextFragment()); + + LayoutPoint layout_snapped_paint_offset = + fragment_data.PaintOffset() - mapping->SubpixelAccumulation(); + IntPoint snapped_paint_offset = RoundedIntPoint(layout_snapped_paint_offset); + +#if 0 + bool subpixel_accumulation_may_be_bogus = paint_layer->SubtreeIsInvisible(); + DCHECK(layout_snapped_paint_offset == snapped_paint_offset || + subpixel_accumulation_may_be_bogus); +#endif + + base::Optional container_layer_state; + auto SetContainerLayerState = + [&fragment_data, &snapped_paint_offset, + &container_layer_state](GraphicsLayer* graphics_layer) { + if (graphics_layer) { + if (!container_layer_state) { + container_layer_state = fragment_data.LocalBorderBoxProperties(); + if (const auto* properties = fragment_data.PaintProperties()) { + if (const auto* css_clip = properties->CssClip()) + container_layer_state->SetClip(css_clip->Parent()); + } + } + graphics_layer->SetLayerState( + *container_layer_state, + snapped_paint_offset + graphics_layer->OffsetFromLayoutObject()); + } + }; + SetContainerLayerState(mapping->MainGraphicsLayer()); + SetContainerLayerState(mapping->DecorationOutlineLayer()); + SetContainerLayerState(mapping->ChildClippingMaskLayer()); + + base::Optional scrollbar_layer_state; + + auto SetContainerLayerStateForScrollbars = + [&fragment_data, &snapped_paint_offset, &container_layer_state, + &scrollbar_layer_state](GraphicsLayer* graphics_layer) { + if (graphics_layer) { + if (!scrollbar_layer_state) { + if (container_layer_state) { + scrollbar_layer_state = container_layer_state; + } else { + scrollbar_layer_state = fragment_data.LocalBorderBoxProperties(); + } + + if (const auto* properties = fragment_data.PaintProperties()) { + if (const auto* clip = properties->OverflowControlsClip()) { + scrollbar_layer_state->SetClip(clip); + } else if (const auto* css_clip = properties->CssClip()) { + scrollbar_layer_state->SetClip(css_clip->Parent()); + } + } + } + graphics_layer->SetLayerState( + *scrollbar_layer_state, + snapped_paint_offset + graphics_layer->OffsetFromLayoutObject()); + } + }; + + SetContainerLayerStateForScrollbars(mapping->LayerForHorizontalScrollbar()); + SetContainerLayerStateForScrollbars(mapping->LayerForVerticalScrollbar()); + SetContainerLayerStateForScrollbars(mapping->LayerForScrollCorner()); + + if (mapping->ScrollingContentsLayer()) { + auto paint_offset = snapped_paint_offset; + + if (object.IsBox() && object.HasFlippedBlocksWritingMode()) + paint_offset.Move(ToLayoutBox(object).VerticalScrollbarWidth(), 0); + + auto SetContentsLayerState = + [&fragment_data, &paint_offset](GraphicsLayer* graphics_layer) { + if (graphics_layer) { + graphics_layer->SetLayerState( + fragment_data.ContentsProperties(), + paint_offset + graphics_layer->OffsetFromLayoutObject()); + } + }; + SetContentsLayerState(mapping->ScrollingContentsLayer()); + SetContentsLayerState(mapping->ForegroundLayer()); + } else { + SetContainerLayerState(mapping->ForegroundLayer()); + } + + if (auto* squashing_layer = mapping->SquashingLayer()) { + auto state = fragment_data.PreEffectProperties(); + const auto* clipping_container = paint_layer->ClippingContainer(); + state.SetClip( + clipping_container + ? clipping_container->FirstFragment().ContentsProperties().Clip() + : &ClipPaintPropertyNode::Root()); + squashing_layer->SetLayerState( + state, + snapped_paint_offset + mapping->SquashingLayerOffsetFromLayoutObject()); + } + + if (auto* mask_layer = mapping->MaskLayer()) { + auto state = fragment_data.LocalBorderBoxProperties(); + const auto* properties = fragment_data.PaintProperties(); + DCHECK(properties && properties->Mask()); + state.SetEffect(properties->Mask()); + state.SetClip(properties->MaskClip()); + + mask_layer->SetLayerState( + state, snapped_paint_offset + mask_layer->OffsetFromLayoutObject()); + } + + if (auto* ancestor_clipping_mask_layer = + mapping->AncestorClippingMaskLayer()) { + PropertyTreeState state( + fragment_data.PreTransform(), + mapping->ClipInheritanceAncestor() + ->GetLayoutObject() + .FirstFragment() + .PostOverflowClip(), + fragment_data.PreFilter()); + ancestor_clipping_mask_layer->SetLayerState( + state, snapped_paint_offset + + ancestor_clipping_mask_layer->OffsetFromLayoutObject()); + } + + if (auto* child_clipping_mask_layer = mapping->ChildClippingMaskLayer()) { + PropertyTreeState state = fragment_data.LocalBorderBoxProperties(); + state.SetEffect(fragment_data.PreFilter()); + child_clipping_mask_layer->SetLayerState( + state, snapped_paint_offset + + child_clipping_mask_layer->OffsetFromLayoutObject()); + } +} +","@@ -139,7 +139,7 @@ void CompositingLayerPropertyUpdater::Update(const LayoutObject& object) { + state.SetClip( + clipping_container + ? clipping_container->FirstFragment().ContentsProperties().Clip() +- : ClipPaintPropertyNode::Root()); ++ : &ClipPaintPropertyNode::Root()); + squashing_layer->SetLayerState( + state, + snapped_paint_offset + mapping->SquashingLayerOffsetFromLayoutObject());",1192,1428,2048 +7379,"bool handle_auth_response(PgSocket *client, PktHdr *pkt) { + uint16_t columns; + uint32_t length; + const char *username, *password; + PgUser user; + PgSocket *server = client->link; + + switch(pkt->type) { + case 'T': /* RowDescription */ + if (!mbuf_get_uint16be(&pkt->data, &columns)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (columns != 2u) { + disconnect_server(server, false, ""expected 1 column from login query, not %hu"", columns); + return false; + } + break; + case 'D': /* DataRow */ + memset(&user, 0, sizeof(user)); + if (!mbuf_get_uint16be(&pkt->data, &columns)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (columns != 2u) { + disconnect_server(server, false, ""expected 1 column from login query, not %hu"", columns); + return false; + } + if (!mbuf_get_uint32be(&pkt->data, &length)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (!mbuf_get_chars(&pkt->data, length, &username)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (sizeof(user.name) - 1 < length) + length = sizeof(user.name) - 1; + memcpy(user.name, username, length); + if (!mbuf_get_uint32be(&pkt->data, &length)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (length == (uint32_t)-1) { + /* + * NULL - set an md5 password with an impossible value, + * so that nothing will ever match + */ + password = ""md5""; + length = 3; + } else { + if (!mbuf_get_chars(&pkt->data, length, &password)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + } + if (sizeof(user.passwd) - 1 < length) + length = sizeof(user.passwd) - 1; + memcpy(user.passwd, password, length); + + client->auth_user = add_db_user(client->db, user.name, user.passwd); + if (!client->auth_user) { + disconnect_server(server, false, ""unable to allocate new user for auth""); + return false; + } + break; + case 'N': /* NoticeResponse */ + break; + case 'C': /* CommandComplete */ + break; + case '1': /* ParseComplete */ + break; + case '2': /* BindComplete */ + break; + case 'Z': /* ReadyForQuery */ + sbuf_prepare_skip(&client->link->sbuf, pkt->len); + if (!client->auth_user) { + if (cf_log_connections) + slog_info(client, ""login failed: db=%s"", client->db->name); + disconnect_client(client, true, ""No such user""); + } else { + slog_noise(client, ""auth query complete""); + client->link->resetting = true; + sbuf_continue(&client->sbuf); + } + /* + * either sbuf_continue or disconnect_client could disconnect the server + * way down in their bowels of other callbacks. so check that, and + * return appropriately (similar to reuse_on_release) + */ + if (server->state == SV_FREE || server->state == SV_JUSTFREE) + return false; + return true; + default: + disconnect_server(server, false, ""unexpected response from login query""); + return false; + } + sbuf_prepare_skip(&server->sbuf, pkt->len); + return true; +} +",0,"bool handle_auth_response(PgSocket *client, PktHdr *pkt) { + uint16_t columns; + uint32_t length; + const char *username, *password; + PgUser user; + PgSocket *server = client->link; + + switch(pkt->type) { + case 'T': /* RowDescription */ + if (!mbuf_get_uint16be(&pkt->data, &columns)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (columns != 2u) { + disconnect_server(server, false, ""expected 1 column from login query, not %hu"", columns); + return false; + } + break; + case 'D': /* DataRow */ + memset(&user, 0, sizeof(user)); + if (!mbuf_get_uint16be(&pkt->data, &columns)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (columns != 2u) { + disconnect_server(server, false, ""expected 1 column from login query, not %hu"", columns); + return false; + } + if (!mbuf_get_uint32be(&pkt->data, &length)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (!mbuf_get_chars(&pkt->data, length, &username)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (sizeof(user.name) - 1 < length) + length = sizeof(user.name) - 1; + memcpy(user.name, username, length); + if (!mbuf_get_uint32be(&pkt->data, &length)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + if (length == (uint32_t)-1) { + /* + * NULL - set an md5 password with an impossible value, + * so that nothing will ever match + */ + password = ""md5""; + length = 3; + } else { + if (!mbuf_get_chars(&pkt->data, length, &password)) { + disconnect_server(server, false, ""bad packet""); + return false; + } + } + if (sizeof(user.passwd) - 1 < length) + length = sizeof(user.passwd) - 1; + memcpy(user.passwd, password, length); + + client->auth_user = add_db_user(client->db, user.name, user.passwd); + if (!client->auth_user) { + disconnect_server(server, false, ""unable to allocate new user for auth""); + return false; + } + break; + case 'N': /* NoticeResponse */ + break; + case 'C': /* CommandComplete */ + break; + case '1': /* ParseComplete */ + break; + case '2': /* BindComplete */ + break; + case 'Z': /* ReadyForQuery */ + sbuf_prepare_skip(&client->link->sbuf, pkt->len); + if (!client->auth_user) { + if (cf_log_connections) + slog_info(client, ""login failed: db=%s"", client->db->name); + disconnect_client(client, true, ""No such user""); + } else { + slog_noise(client, ""auth query complete""); + client->link->resetting = true; + sbuf_continue(&client->sbuf); + } + /* + * either sbuf_continue or disconnect_client could disconnect the server + * way down in their bowels of other callbacks. so check that, and + * return appropriately (similar to reuse_on_release) + */ + if (server->state == SV_FREE || server->state == SV_JUSTFREE) + return false; + return true; + default: + disconnect_server(server, false, ""unexpected response from login query""); + return false; + } + sbuf_prepare_skip(&server->sbuf, pkt->len); + return true; +} +","@@ -83,7 +83,6 @@ static void start_auth_request(PgSocket *client, const char *username) + int res; + PktBuf *buf; + +- client->auth_user = client->db->auth_user; + /* have to fetch user info from db */ + client->pool = get_pool(client->db, client->db->auth_user); + if (!find_server(client)) {",863,1099,2048 +6062,"R_API void r_flag_list(RFlag *f, int rad, const char *pfx) { + bool in_range = false; + ut64 range_from = UT64_MAX; + ut64 range_to = UT64_MAX; + int fs = -1; + RListIter *iter; + RFlagItem *flag; + if (rad == 'i') { + char *sp, *arg = strdup (pfx + 1); + sp = strchr (arg, ' '); + if (sp) { + *sp++ = 0; + range_from = r_num_math (f->num, arg); + range_to = r_num_math (f->num, sp); + } else { + const int bsize = 4096; + range_from = r_num_math (f->num, arg); + range_to = range_from + bsize; + } + in_range = true; + free (arg); + rad = pfx[0]; + pfx = NULL; + } + + if (pfx && !*pfx) { + pfx = NULL; + } + + switch (rad) { + case 'j': { + int first = 1; + f->cb_printf (""[""); + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + f->cb_printf (""%s{\""name\"":\""%s\"",\""size\"":%""PFMT64d"","", + first?"""":"","", flag->name, flag->size); + if (flag->alias) { + f->cb_printf (""\""alias\"":\""%s\"""", flag->alias); + } else { + f->cb_printf (""\""offset\"":%""PFMT64d, flag->offset); + } + if (flag->comment) + f->cb_printf ("",\""comment\"":\""}""); + else f->cb_printf (""}""); + first = 0; + } + f->cb_printf (""]\n""); + } + break; + case 1: + case '*': + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + if (fs == -1 || flag->space != fs) { + const char *flagspace; + fs = flag->space; + flagspace = r_flag_space_get_i (f, fs); + if (!flagspace || !*flagspace) + flagspace = ""*""; + f->cb_printf (""fs %s\n"", flagspace); + } + if (flag->alias) { + f->cb_printf (""fa %s %s\n"", flag->name, flag->alias); + if (flag->comment && *flag->comment) + f->cb_printf (""\""fC %s %s\""\n"", + flag->name, flag->comment); + } else { + f->cb_printf (""f %s %""PFMT64d"" 0x%08""PFMT64x""%s%s %s\n"", + flag->name, flag->size, flag->offset, + pfx?""+"":"""", pfx?pfx:"""", + flag->comment? flag->comment:""""); + } + } + break; + case 'n': // show original name + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + if (flag->alias) { + f->cb_printf (""%s %""PFMT64d"" %s\n"", + flag->alias, flag->size, flag->realname); + } else { + f->cb_printf (""0x%08""PFMT64x"" %""PFMT64d"" %s\n"", + flag->offset, flag->size, flag->realname); + } + } + break; + default: + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + if (flag->alias) { + f->cb_printf (""%s %""PFMT64d"" %s\n"", + flag->alias, flag->size, flag->name); + } else { + f->cb_printf (""0x%08""PFMT64x"" %""PFMT64d"" %s\n"", + flag->offset, flag->size, flag->name); + } + } + break; + } +",0,"R_API void r_flag_list(RFlag *f, int rad, const char *pfx) { + bool in_range = false; + ut64 range_from = UT64_MAX; + ut64 range_to = UT64_MAX; + int fs = -1; + RListIter *iter; + RFlagItem *flag; + if (rad == 'i') { + char *sp, *arg = strdup (pfx + 1); + sp = strchr (arg, ' '); + if (sp) { + *sp++ = 0; + range_from = r_num_math (f->num, arg); + range_to = r_num_math (f->num, sp); + } else { + const int bsize = 4096; + range_from = r_num_math (f->num, arg); + range_to = range_from + bsize; + } + in_range = true; + free (arg); + rad = pfx[0]; + pfx = NULL; + } + + if (pfx && !*pfx) { + pfx = NULL; + } + + switch (rad) { + case 'j': { + int first = 1; + f->cb_printf (""[""); + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + f->cb_printf (""%s{\""name\"":\""%s\"",\""size\"":%""PFMT64d"","", + first?"""":"","", flag->name, flag->size); + if (flag->alias) { + f->cb_printf (""\""alias\"":\""%s\"""", flag->alias); + } else { + f->cb_printf (""\""offset\"":%""PFMT64d, flag->offset); + } + if (flag->comment) + f->cb_printf ("",\""comment\"":\""}""); + else f->cb_printf (""}""); + first = 0; + } + f->cb_printf (""]\n""); + } + break; + case 1: + case '*': + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + if (fs == -1 || flag->space != fs) { + const char *flagspace; + fs = flag->space; + flagspace = r_flag_space_get_i (f, fs); + if (!flagspace || !*flagspace) + flagspace = ""*""; + f->cb_printf (""fs %s\n"", flagspace); + } + if (flag->alias) { + f->cb_printf (""fa %s %s\n"", flag->name, flag->alias); + if (flag->comment && *flag->comment) + f->cb_printf (""\""fC %s %s\""\n"", + flag->name, flag->comment); + } else { + f->cb_printf (""f %s %""PFMT64d"" 0x%08""PFMT64x""%s%s %s\n"", + flag->name, flag->size, flag->offset, + pfx?""+"":"""", pfx?pfx:"""", + flag->comment? flag->comment:""""); + } + } + break; + case 'n': // show original name + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + if (flag->alias) { + f->cb_printf (""%s %""PFMT64d"" %s\n"", + flag->alias, flag->size, flag->realname); + } else { + f->cb_printf (""0x%08""PFMT64x"" %""PFMT64d"" %s\n"", + flag->offset, flag->size, flag->realname); + } + } + break; + default: + r_list_foreach (f->flags, iter, flag) { + if (IS_IN_SPACE (f, flag)) { + continue; + } + if (in_range && (flag->offset < range_from || flag->offset >= range_to)) { + continue; + } + if (flag->alias) { + f->cb_printf (""%s %""PFMT64d"" %s\n"", + flag->alias, flag->size, flag->name); + } else { + f->cb_printf (""0x%08""PFMT64x"" %""PFMT64d"" %s\n"", + flag->offset, flag->size, flag->name); + } + } + break; + } +","@@ -74,7 +74,7 @@ static ut64 num_callback(RNum *user, const char *name, int *ok) { + dir == -1 -> result <= off + dir == 0 -> result == off + dir == 1 -> result >= off*/ +-static RFlagsAtOffset* r_flag_get_nearest_list(RFlag *f, ut64 off, int dir) { ++static RFlagsAtOffset* r_flag_get_nearest_list(RFlag *f, ut64 off, int dir) { + RFlagsAtOffset *flags = NULL; + RFlagsAtOffset key; + key.off = off;",1084,1320,2048 +17954,"static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, + struct msghdr *msg, size_t len, int flags) +{ + struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name; + const int nonblock = flags & MSG_DONTWAIT; + struct sk_buff *skb = NULL; + struct sock *sk = sock->sk; + struct llc_sock *llc = llc_sk(sk); + unsigned long cpu_flags; + size_t copied = 0; + u32 peek_seq = 0; + u32 *seq; + unsigned long used; + int target; /* Read at least this many bytes */ + long timeo; + + msg->msg_namelen = 0; + lock_sock(sk); + copied = -ENOTCONN; + if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN)) + goto out; + + timeo = sock_rcvtimeo(sk, nonblock); + + seq = &llc->copied_seq; + if (flags & MSG_PEEK) { + peek_seq = llc->copied_seq; + seq = &peek_seq; + } + + target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); + copied = 0; + + do { + u32 offset; + + /* + * We need to check signals first, to get correct SIGURG + * handling. FIXME: Need to check this doesn't impact 1003.1g + * and move it down to the bottom of the loop + */ + if (signal_pending(current)) { + if (copied) + break; + copied = timeo ? sock_intr_errno(timeo) : -EAGAIN; + break; + } + + /* Next get a buffer. */ + + skb = skb_peek(&sk->sk_receive_queue); + if (skb) { + offset = *seq; + goto found_ok_skb; + } + /* Well, if we have backlog, try to process it now yet. */ + + if (copied >= target && !sk->sk_backlog.tail) + break; + + if (copied) { + if (sk->sk_err || + sk->sk_state == TCP_CLOSE || + (sk->sk_shutdown & RCV_SHUTDOWN) || + !timeo || + (flags & MSG_PEEK)) + break; + } else { + if (sock_flag(sk, SOCK_DONE)) + break; + + if (sk->sk_err) { + copied = sock_error(sk); + break; + } + if (sk->sk_shutdown & RCV_SHUTDOWN) + break; + + if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSE) { + if (!sock_flag(sk, SOCK_DONE)) { + /* + * This occurs when user tries to read + * from never connected socket. + */ + copied = -ENOTCONN; + break; + } + break; + } + if (!timeo) { + copied = -EAGAIN; + break; + } + } + + if (copied >= target) { /* Do not sleep, just process backlog. */ + release_sock(sk); + lock_sock(sk); + } else + sk_wait_data(sk, &timeo); + + if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) { + net_dbg_ratelimited(""LLC(%s:%d): Application bug, race in MSG_PEEK\n"", + current->comm, + task_pid_nr(current)); + peek_seq = llc->copied_seq; + } + continue; + found_ok_skb: + /* Ok so how much can we use? */ + used = skb->len - offset; + if (len < used) + used = len; + + if (!(flags & MSG_TRUNC)) { + int rc = skb_copy_datagram_iovec(skb, offset, + msg->msg_iov, used); + if (rc) { + /* Exception. Bailout! */ + if (!copied) + copied = -EFAULT; + break; + } + } + + *seq += used; + copied += used; + len -= used; + + /* For non stream protcols we get one packet per recvmsg call */ + if (sk->sk_type != SOCK_STREAM) + goto copy_uaddr; + + if (!(flags & MSG_PEEK)) { + spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); + sk_eat_skb(sk, skb, false); + spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); + *seq = 0; + } + + /* Partial read */ + if (used + offset < skb->len) + continue; + } while (len > 0); + +out: + release_sock(sk); + return copied; +copy_uaddr: + if (uaddr != NULL && skb != NULL) { + memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); + msg->msg_namelen = sizeof(*uaddr); + } + if (llc_sk(sk)->cmsg_flags) + llc_cmsg_rcv(msg, skb); + + if (!(flags & MSG_PEEK)) { + spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); + sk_eat_skb(sk, skb, false); + spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); + *seq = 0; + } + + goto out; +} +",1,"static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, + struct msghdr *msg, size_t len, int flags) +{ + struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name; + const int nonblock = flags & MSG_DONTWAIT; + struct sk_buff *skb = NULL; + struct sock *sk = sock->sk; + struct llc_sock *llc = llc_sk(sk); + unsigned long cpu_flags; + size_t copied = 0; + u32 peek_seq = 0; + u32 *seq; + unsigned long used; + int target; /* Read at least this many bytes */ + long timeo; + + lock_sock(sk); + copied = -ENOTCONN; + if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN)) + goto out; + + timeo = sock_rcvtimeo(sk, nonblock); + + seq = &llc->copied_seq; + if (flags & MSG_PEEK) { + peek_seq = llc->copied_seq; + seq = &peek_seq; + } + + target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); + copied = 0; + + do { + u32 offset; + + /* + * We need to check signals first, to get correct SIGURG + * handling. FIXME: Need to check this doesn't impact 1003.1g + * and move it down to the bottom of the loop + */ + if (signal_pending(current)) { + if (copied) + break; + copied = timeo ? sock_intr_errno(timeo) : -EAGAIN; + break; + } + + /* Next get a buffer. */ + + skb = skb_peek(&sk->sk_receive_queue); + if (skb) { + offset = *seq; + goto found_ok_skb; + } + /* Well, if we have backlog, try to process it now yet. */ + + if (copied >= target && !sk->sk_backlog.tail) + break; + + if (copied) { + if (sk->sk_err || + sk->sk_state == TCP_CLOSE || + (sk->sk_shutdown & RCV_SHUTDOWN) || + !timeo || + (flags & MSG_PEEK)) + break; + } else { + if (sock_flag(sk, SOCK_DONE)) + break; + + if (sk->sk_err) { + copied = sock_error(sk); + break; + } + if (sk->sk_shutdown & RCV_SHUTDOWN) + break; + + if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSE) { + if (!sock_flag(sk, SOCK_DONE)) { + /* + * This occurs when user tries to read + * from never connected socket. + */ + copied = -ENOTCONN; + break; + } + break; + } + if (!timeo) { + copied = -EAGAIN; + break; + } + } + + if (copied >= target) { /* Do not sleep, just process backlog. */ + release_sock(sk); + lock_sock(sk); + } else + sk_wait_data(sk, &timeo); + + if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) { + net_dbg_ratelimited(""LLC(%s:%d): Application bug, race in MSG_PEEK\n"", + current->comm, + task_pid_nr(current)); + peek_seq = llc->copied_seq; + } + continue; + found_ok_skb: + /* Ok so how much can we use? */ + used = skb->len - offset; + if (len < used) + used = len; + + if (!(flags & MSG_TRUNC)) { + int rc = skb_copy_datagram_iovec(skb, offset, + msg->msg_iov, used); + if (rc) { + /* Exception. Bailout! */ + if (!copied) + copied = -EFAULT; + break; + } + } + + *seq += used; + copied += used; + len -= used; + + /* For non stream protcols we get one packet per recvmsg call */ + if (sk->sk_type != SOCK_STREAM) + goto copy_uaddr; + + if (!(flags & MSG_PEEK)) { + spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); + sk_eat_skb(sk, skb, false); + spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); + *seq = 0; + } + + /* Partial read */ + if (used + offset < skb->len) + continue; + } while (len > 0); + +out: + release_sock(sk); + return copied; +copy_uaddr: + if (uaddr != NULL && skb != NULL) { + memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); + msg->msg_namelen = sizeof(*uaddr); + } + if (llc_sk(sk)->cmsg_flags) + llc_cmsg_rcv(msg, skb); + + if (!(flags & MSG_PEEK)) { + spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); + sk_eat_skb(sk, skb, false); + spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); + *seq = 0; + } + + goto out; +} +","@@ -720,8 +720,6 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, + int target; /* Read at least this many bytes */ + long timeo; + +- msg->msg_namelen = 0; +- + lock_sock(sk); + copied = -ENOTCONN; + if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN))",1195,1431,2048 +5709,"static int hub_port_reset(struct usb_hub *hub, int port1, + struct usb_device *udev, unsigned int delay, bool warm) +{ + int i, status; + u16 portchange, portstatus; + struct usb_port *port_dev = hub->ports[port1 - 1]; + + if (!hub_is_superspeed(hub->hdev)) { + if (warm) { + dev_err(hub->intfdev, ""only USB3 hub support "" + ""warm reset\n""); + return -EINVAL; + } + /* Block EHCI CF initialization during the port reset. + * Some companion controllers don't like it when they mix. + */ + down_read(&ehci_cf_port_reset_rwsem); + } else if (!warm) { + /* + * If the caller hasn't explicitly requested a warm reset, + * double check and see if one is needed. + */ + if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) + if (hub_port_warm_reset_required(hub, port1, + portstatus)) + warm = true; + } + clear_bit(port1, hub->warm_reset_bits); + + /* Reset the port */ + for (i = 0; i < PORT_RESET_TRIES; i++) { + status = set_port_feature(hub->hdev, port1, (warm ? + USB_PORT_FEAT_BH_PORT_RESET : + USB_PORT_FEAT_RESET)); + if (status == -ENODEV) { + ; /* The hub is gone */ + } else if (status) { + dev_err(&port_dev->dev, + ""cannot %sreset (err = %d)\n"", + warm ? ""warm "" : """", status); + } else { + status = hub_port_wait_reset(hub, port1, udev, delay, + warm); + if (status && status != -ENOTCONN && status != -ENODEV) + dev_dbg(hub->intfdev, + ""port_wait_reset: err = %d\n"", + status); + } + + /* Check for disconnect or reset */ + if (status == 0 || status == -ENOTCONN || status == -ENODEV) { + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_RESET); + + if (!hub_is_superspeed(hub->hdev)) + goto done; + + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_BH_PORT_RESET); + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_PORT_LINK_STATE); + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_CONNECTION); + + /* + * If a USB 3.0 device migrates from reset to an error + * state, re-issue the warm reset. + */ + if (hub_port_status(hub, port1, + &portstatus, &portchange) < 0) + goto done; + + if (!hub_port_warm_reset_required(hub, port1, + portstatus)) + goto done; + + /* + * If the port is in SS.Inactive or Compliance Mode, the + * hot or warm reset failed. Try another warm reset. + */ + if (!warm) { + dev_dbg(&port_dev->dev, + ""hot reset failed, warm reset\n""); + warm = true; + } + } + + dev_dbg(&port_dev->dev, + ""not enabled, trying %sreset again...\n"", + warm ? ""warm "" : """"); + delay = HUB_LONG_RESET_TIME; + } + + dev_err(&port_dev->dev, ""Cannot enable. Maybe the USB cable is bad?\n""); + +done: + if (status == 0) { + /* TRSTRCY = 10 ms; plus some extra */ + msleep(10 + 40); + if (udev) { + struct usb_hcd *hcd = bus_to_hcd(udev->bus); + + update_devnum(udev, 0); + /* The xHC may think the device is already reset, + * so ignore the status. + */ + if (hcd->driver->reset_device) + hcd->driver->reset_device(hcd, udev); + + usb_set_device_state(udev, USB_STATE_DEFAULT); + } + } else { + if (udev) + usb_set_device_state(udev, USB_STATE_NOTATTACHED); + } + + if (!hub_is_superspeed(hub->hdev)) + up_read(&ehci_cf_port_reset_rwsem); + + return status; +} +",0,"static int hub_port_reset(struct usb_hub *hub, int port1, + struct usb_device *udev, unsigned int delay, bool warm) +{ + int i, status; + u16 portchange, portstatus; + struct usb_port *port_dev = hub->ports[port1 - 1]; + + if (!hub_is_superspeed(hub->hdev)) { + if (warm) { + dev_err(hub->intfdev, ""only USB3 hub support "" + ""warm reset\n""); + return -EINVAL; + } + /* Block EHCI CF initialization during the port reset. + * Some companion controllers don't like it when they mix. + */ + down_read(&ehci_cf_port_reset_rwsem); + } else if (!warm) { + /* + * If the caller hasn't explicitly requested a warm reset, + * double check and see if one is needed. + */ + if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) + if (hub_port_warm_reset_required(hub, port1, + portstatus)) + warm = true; + } + clear_bit(port1, hub->warm_reset_bits); + + /* Reset the port */ + for (i = 0; i < PORT_RESET_TRIES; i++) { + status = set_port_feature(hub->hdev, port1, (warm ? + USB_PORT_FEAT_BH_PORT_RESET : + USB_PORT_FEAT_RESET)); + if (status == -ENODEV) { + ; /* The hub is gone */ + } else if (status) { + dev_err(&port_dev->dev, + ""cannot %sreset (err = %d)\n"", + warm ? ""warm "" : """", status); + } else { + status = hub_port_wait_reset(hub, port1, udev, delay, + warm); + if (status && status != -ENOTCONN && status != -ENODEV) + dev_dbg(hub->intfdev, + ""port_wait_reset: err = %d\n"", + status); + } + + /* Check for disconnect or reset */ + if (status == 0 || status == -ENOTCONN || status == -ENODEV) { + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_RESET); + + if (!hub_is_superspeed(hub->hdev)) + goto done; + + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_BH_PORT_RESET); + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_PORT_LINK_STATE); + usb_clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_CONNECTION); + + /* + * If a USB 3.0 device migrates from reset to an error + * state, re-issue the warm reset. + */ + if (hub_port_status(hub, port1, + &portstatus, &portchange) < 0) + goto done; + + if (!hub_port_warm_reset_required(hub, port1, + portstatus)) + goto done; + + /* + * If the port is in SS.Inactive or Compliance Mode, the + * hot or warm reset failed. Try another warm reset. + */ + if (!warm) { + dev_dbg(&port_dev->dev, + ""hot reset failed, warm reset\n""); + warm = true; + } + } + + dev_dbg(&port_dev->dev, + ""not enabled, trying %sreset again...\n"", + warm ? ""warm "" : """"); + delay = HUB_LONG_RESET_TIME; + } + + dev_err(&port_dev->dev, ""Cannot enable. Maybe the USB cable is bad?\n""); + +done: + if (status == 0) { + /* TRSTRCY = 10 ms; plus some extra */ + msleep(10 + 40); + if (udev) { + struct usb_hcd *hcd = bus_to_hcd(udev->bus); + + update_devnum(udev, 0); + /* The xHC may think the device is already reset, + * so ignore the status. + */ + if (hcd->driver->reset_device) + hcd->driver->reset_device(hcd, udev); + + usb_set_device_state(udev, USB_STATE_DEFAULT); + } + } else { + if (udev) + usb_set_device_state(udev, USB_STATE_NOTATTACHED); + } + + if (!hub_is_superspeed(hub->hdev)) + up_read(&ehci_cf_port_reset_rwsem); + + return status; +} +","@@ -1035,10 +1035,20 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) + unsigned delay; + + /* Continue a partial initialization */ +- if (type == HUB_INIT2) +- goto init2; +- if (type == HUB_INIT3) ++ if (type == HUB_INIT2 || type == HUB_INIT3) { ++ device_lock(hub->intfdev); ++ ++ /* Was the hub disconnected while we were waiting? */ ++ if (hub->disconnected) { ++ device_unlock(hub->intfdev); ++ kref_put(&hub->kref, hub_release); ++ return; ++ } ++ if (type == HUB_INIT2) ++ goto init2; + goto init3; ++ } ++ kref_get(&hub->kref); + + /* The superspeed hub except for root hub has to use Hub Depth + * value as an offset into the route string to locate the bits +@@ -1236,6 +1246,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) + queue_delayed_work(system_power_efficient_wq, + &hub->init_work, + msecs_to_jiffies(delay)); ++ device_unlock(hub->intfdev); + return; /* Continues at init3: below */ + } else { + msleep(delay); +@@ -1257,6 +1268,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) + /* Allow autosuspend if it was suppressed */ + if (type <= HUB_INIT3) + usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); ++ ++ if (type == HUB_INIT2 || type == HUB_INIT3) ++ device_unlock(hub->intfdev); ++ ++ kref_put(&hub->kref, hub_release); + } + + /* Implement the continuations for the delays above */",1013,1249,2048 +3617,"static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, + u16 tss_selector, int idt_index, int reason, + bool has_error_code, u32 error_code) +{ + const struct x86_emulate_ops *ops = ctxt->ops; + struct desc_struct curr_tss_desc, next_tss_desc; + int ret; + u16 old_tss_sel = get_segment_selector(ctxt, VCPU_SREG_TR); + ulong old_tss_base = + ops->get_cached_segment_base(ctxt, VCPU_SREG_TR); + u32 desc_limit; + ulong desc_addr; + + /* FIXME: old_tss_base == ~0 ? */ + + ret = read_segment_descriptor(ctxt, tss_selector, &next_tss_desc, &desc_addr); + if (ret != X86EMUL_CONTINUE) + return ret; + ret = read_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc, &desc_addr); + if (ret != X86EMUL_CONTINUE) + return ret; + + /* FIXME: check that next_tss_desc is tss */ + + /* + * Check privileges. The three cases are task switch caused by... + * + * 1. jmp/call/int to task gate: Check against DPL of the task gate + * 2. Exception/IRQ/iret: No check is performed + * 3. jmp/call to TSS: Check against DPL of the TSS + */ + if (reason == TASK_SWITCH_GATE) { + if (idt_index != -1) { + /* Software interrupts */ + struct desc_struct task_gate_desc; + int dpl; + + ret = read_interrupt_descriptor(ctxt, idt_index, + &task_gate_desc); + if (ret != X86EMUL_CONTINUE) + return ret; + + dpl = task_gate_desc.dpl; + if ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl) + return emulate_gp(ctxt, (idt_index << 3) | 0x2); + } + } else if (reason != TASK_SWITCH_IRET) { + int dpl = next_tss_desc.dpl; + if ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl) + return emulate_gp(ctxt, tss_selector); + } + + + desc_limit = desc_limit_scaled(&next_tss_desc); + if (!next_tss_desc.p || + ((desc_limit < 0x67 && (next_tss_desc.type & 8)) || + desc_limit < 0x2b)) { + return emulate_ts(ctxt, tss_selector & 0xfffc); + } + + if (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) { + curr_tss_desc.type &= ~(1 << 1); /* clear busy flag */ + write_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc); + } + + if (reason == TASK_SWITCH_IRET) + ctxt->eflags = ctxt->eflags & ~X86_EFLAGS_NT; + + /* set back link to prev task only if NT bit is set in eflags + note that old_tss_sel is not used after this point */ + if (reason != TASK_SWITCH_CALL && reason != TASK_SWITCH_GATE) + old_tss_sel = 0xffff; + + if (next_tss_desc.type & 8) + ret = task_switch_32(ctxt, tss_selector, old_tss_sel, + old_tss_base, &next_tss_desc); + else + ret = task_switch_16(ctxt, tss_selector, old_tss_sel, + old_tss_base, &next_tss_desc); + if (ret != X86EMUL_CONTINUE) + return ret; + + if (reason == TASK_SWITCH_CALL || reason == TASK_SWITCH_GATE) + ctxt->eflags = ctxt->eflags | X86_EFLAGS_NT; + + if (reason != TASK_SWITCH_IRET) { + next_tss_desc.type |= (1 << 1); /* set busy flag */ + write_segment_descriptor(ctxt, tss_selector, &next_tss_desc); + } + + ops->set_cr(ctxt, 0, ops->get_cr(ctxt, 0) | X86_CR0_TS); + ops->set_segment(ctxt, tss_selector, &next_tss_desc, 0, VCPU_SREG_TR); + + if (has_error_code) { + ctxt->op_bytes = ctxt->ad_bytes = (next_tss_desc.type & 8) ? 4 : 2; + ctxt->lock_prefix = 0; + ctxt->src.val = (unsigned long) error_code; + ret = em_push(ctxt); + } + + return ret; +} +",0,"static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, + u16 tss_selector, int idt_index, int reason, + bool has_error_code, u32 error_code) +{ + const struct x86_emulate_ops *ops = ctxt->ops; + struct desc_struct curr_tss_desc, next_tss_desc; + int ret; + u16 old_tss_sel = get_segment_selector(ctxt, VCPU_SREG_TR); + ulong old_tss_base = + ops->get_cached_segment_base(ctxt, VCPU_SREG_TR); + u32 desc_limit; + ulong desc_addr; + + /* FIXME: old_tss_base == ~0 ? */ + + ret = read_segment_descriptor(ctxt, tss_selector, &next_tss_desc, &desc_addr); + if (ret != X86EMUL_CONTINUE) + return ret; + ret = read_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc, &desc_addr); + if (ret != X86EMUL_CONTINUE) + return ret; + + /* FIXME: check that next_tss_desc is tss */ + + /* + * Check privileges. The three cases are task switch caused by... + * + * 1. jmp/call/int to task gate: Check against DPL of the task gate + * 2. Exception/IRQ/iret: No check is performed + * 3. jmp/call to TSS: Check against DPL of the TSS + */ + if (reason == TASK_SWITCH_GATE) { + if (idt_index != -1) { + /* Software interrupts */ + struct desc_struct task_gate_desc; + int dpl; + + ret = read_interrupt_descriptor(ctxt, idt_index, + &task_gate_desc); + if (ret != X86EMUL_CONTINUE) + return ret; + + dpl = task_gate_desc.dpl; + if ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl) + return emulate_gp(ctxt, (idt_index << 3) | 0x2); + } + } else if (reason != TASK_SWITCH_IRET) { + int dpl = next_tss_desc.dpl; + if ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl) + return emulate_gp(ctxt, tss_selector); + } + + + desc_limit = desc_limit_scaled(&next_tss_desc); + if (!next_tss_desc.p || + ((desc_limit < 0x67 && (next_tss_desc.type & 8)) || + desc_limit < 0x2b)) { + return emulate_ts(ctxt, tss_selector & 0xfffc); + } + + if (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) { + curr_tss_desc.type &= ~(1 << 1); /* clear busy flag */ + write_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc); + } + + if (reason == TASK_SWITCH_IRET) + ctxt->eflags = ctxt->eflags & ~X86_EFLAGS_NT; + + /* set back link to prev task only if NT bit is set in eflags + note that old_tss_sel is not used after this point */ + if (reason != TASK_SWITCH_CALL && reason != TASK_SWITCH_GATE) + old_tss_sel = 0xffff; + + if (next_tss_desc.type & 8) + ret = task_switch_32(ctxt, tss_selector, old_tss_sel, + old_tss_base, &next_tss_desc); + else + ret = task_switch_16(ctxt, tss_selector, old_tss_sel, + old_tss_base, &next_tss_desc); + if (ret != X86EMUL_CONTINUE) + return ret; + + if (reason == TASK_SWITCH_CALL || reason == TASK_SWITCH_GATE) + ctxt->eflags = ctxt->eflags | X86_EFLAGS_NT; + + if (reason != TASK_SWITCH_IRET) { + next_tss_desc.type |= (1 << 1); /* set busy flag */ + write_segment_descriptor(ctxt, tss_selector, &next_tss_desc); + } + + ops->set_cr(ctxt, 0, ops->get_cr(ctxt, 0) | X86_CR0_TS); + ops->set_segment(ctxt, tss_selector, &next_tss_desc, 0, VCPU_SREG_TR); + + if (has_error_code) { + ctxt->op_bytes = ctxt->ad_bytes = (next_tss_desc.type & 8) ? 4 : 2; + ctxt->lock_prefix = 0; + ctxt->src.val = (unsigned long) error_code; + ret = em_push(ctxt); + } + + return ret; +} +","@@ -4580,10 +4580,10 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) + /* Decode and fetch the destination operand: register or memory. */ + rc = decode_operand(ctxt, &ctxt->dst, (ctxt->d >> DstShift) & OpMask); + +-done: + if (ctxt->rip_relative) + ctxt->memopp->addr.mem.ea += ctxt->_eip; + ++done: + return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK; + } + ",1028,1264,2048 +2616,"static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx, + mips_instruction ir, void *__user *fault_addr) +{ + unsigned rcsr = 0; /* resulting csr */ + + MIPS_FPU_EMU_INC_STATS(cp1xops); + + switch (MIPSInst_FMA_FFMT(ir)) { + case s_fmt:{ /* 0 */ + + ieee754sp(*handler) (ieee754sp, ieee754sp, ieee754sp); + ieee754sp fd, fr, fs, ft; + u32 __user *va; + u32 val; + + switch (MIPSInst_FUNC(ir)) { + case lwxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(loads); + if (!access_ok(VERIFY_READ, va, sizeof(u32))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (__get_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + SITOREG(val, MIPSInst_FD(ir)); + break; + + case swxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(stores); + + SIFROMREG(val, MIPSInst_FS(ir)); + if (!access_ok(VERIFY_WRITE, va, sizeof(u32))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (put_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + break; + + case madd_s_op: + handler = fpemu_sp_madd; + goto scoptop; + case msub_s_op: + handler = fpemu_sp_msub; + goto scoptop; + case nmadd_s_op: + handler = fpemu_sp_nmadd; + goto scoptop; + case nmsub_s_op: + handler = fpemu_sp_nmsub; + goto scoptop; + + scoptop: + SPFROMREG(fr, MIPSInst_FR(ir)); + SPFROMREG(fs, MIPSInst_FS(ir)); + SPFROMREG(ft, MIPSInst_FT(ir)); + fd = (*handler) (fr, fs, ft); + SPTOREG(fd, MIPSInst_FD(ir)); + + copcsr: + if (ieee754_cxtest(IEEE754_INEXACT)) + rcsr |= FPU_CSR_INE_X | FPU_CSR_INE_S; + if (ieee754_cxtest(IEEE754_UNDERFLOW)) + rcsr |= FPU_CSR_UDF_X | FPU_CSR_UDF_S; + if (ieee754_cxtest(IEEE754_OVERFLOW)) + rcsr |= FPU_CSR_OVF_X | FPU_CSR_OVF_S; + if (ieee754_cxtest(IEEE754_INVALID_OPERATION)) + rcsr |= FPU_CSR_INV_X | FPU_CSR_INV_S; + + ctx->fcr31 = (ctx->fcr31 & ~FPU_CSR_ALL_X) | rcsr; + if ((ctx->fcr31 >> 5) & ctx->fcr31 & FPU_CSR_ALL_E) { + /*printk (""SIGFPE: fpu csr = %08x\n"", + ctx->fcr31); */ + return SIGFPE; + } + + break; + + default: + return SIGILL; + } + break; + } + + case d_fmt:{ /* 1 */ + ieee754dp(*handler) (ieee754dp, ieee754dp, ieee754dp); + ieee754dp fd, fr, fs, ft; + u64 __user *va; + u64 val; + + switch (MIPSInst_FUNC(ir)) { + case ldxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(loads); + if (!access_ok(VERIFY_READ, va, sizeof(u64))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (__get_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + DITOREG(val, MIPSInst_FD(ir)); + break; + + case sdxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(stores); + DIFROMREG(val, MIPSInst_FS(ir)); + if (!access_ok(VERIFY_WRITE, va, sizeof(u64))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (__put_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + break; + + case madd_d_op: + handler = fpemu_dp_madd; + goto dcoptop; + case msub_d_op: + handler = fpemu_dp_msub; + goto dcoptop; + case nmadd_d_op: + handler = fpemu_dp_nmadd; + goto dcoptop; + case nmsub_d_op: + handler = fpemu_dp_nmsub; + goto dcoptop; + + dcoptop: + DPFROMREG(fr, MIPSInst_FR(ir)); + DPFROMREG(fs, MIPSInst_FS(ir)); + DPFROMREG(ft, MIPSInst_FT(ir)); + fd = (*handler) (fr, fs, ft); + DPTOREG(fd, MIPSInst_FD(ir)); + goto copcsr; + + default: + return SIGILL; + } + break; + } + + case 0x7: /* 7 */ + if (MIPSInst_FUNC(ir) != pfetch_op) { + return SIGILL; + } + /* ignore prefx operation */ + break; + + default: + return SIGILL; + } + + return 0; +} +",0,"static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx, + mips_instruction ir, void *__user *fault_addr) +{ + unsigned rcsr = 0; /* resulting csr */ + + MIPS_FPU_EMU_INC_STATS(cp1xops); + + switch (MIPSInst_FMA_FFMT(ir)) { + case s_fmt:{ /* 0 */ + + ieee754sp(*handler) (ieee754sp, ieee754sp, ieee754sp); + ieee754sp fd, fr, fs, ft; + u32 __user *va; + u32 val; + + switch (MIPSInst_FUNC(ir)) { + case lwxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(loads); + if (!access_ok(VERIFY_READ, va, sizeof(u32))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (__get_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + SITOREG(val, MIPSInst_FD(ir)); + break; + + case swxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(stores); + + SIFROMREG(val, MIPSInst_FS(ir)); + if (!access_ok(VERIFY_WRITE, va, sizeof(u32))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (put_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + break; + + case madd_s_op: + handler = fpemu_sp_madd; + goto scoptop; + case msub_s_op: + handler = fpemu_sp_msub; + goto scoptop; + case nmadd_s_op: + handler = fpemu_sp_nmadd; + goto scoptop; + case nmsub_s_op: + handler = fpemu_sp_nmsub; + goto scoptop; + + scoptop: + SPFROMREG(fr, MIPSInst_FR(ir)); + SPFROMREG(fs, MIPSInst_FS(ir)); + SPFROMREG(ft, MIPSInst_FT(ir)); + fd = (*handler) (fr, fs, ft); + SPTOREG(fd, MIPSInst_FD(ir)); + + copcsr: + if (ieee754_cxtest(IEEE754_INEXACT)) + rcsr |= FPU_CSR_INE_X | FPU_CSR_INE_S; + if (ieee754_cxtest(IEEE754_UNDERFLOW)) + rcsr |= FPU_CSR_UDF_X | FPU_CSR_UDF_S; + if (ieee754_cxtest(IEEE754_OVERFLOW)) + rcsr |= FPU_CSR_OVF_X | FPU_CSR_OVF_S; + if (ieee754_cxtest(IEEE754_INVALID_OPERATION)) + rcsr |= FPU_CSR_INV_X | FPU_CSR_INV_S; + + ctx->fcr31 = (ctx->fcr31 & ~FPU_CSR_ALL_X) | rcsr; + if ((ctx->fcr31 >> 5) & ctx->fcr31 & FPU_CSR_ALL_E) { + /*printk (""SIGFPE: fpu csr = %08x\n"", + ctx->fcr31); */ + return SIGFPE; + } + + break; + + default: + return SIGILL; + } + break; + } + + case d_fmt:{ /* 1 */ + ieee754dp(*handler) (ieee754dp, ieee754dp, ieee754dp); + ieee754dp fd, fr, fs, ft; + u64 __user *va; + u64 val; + + switch (MIPSInst_FUNC(ir)) { + case ldxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(loads); + if (!access_ok(VERIFY_READ, va, sizeof(u64))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (__get_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + DITOREG(val, MIPSInst_FD(ir)); + break; + + case sdxc1_op: + va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] + + xcp->regs[MIPSInst_FT(ir)]); + + MIPS_FPU_EMU_INC_STATS(stores); + DIFROMREG(val, MIPSInst_FS(ir)); + if (!access_ok(VERIFY_WRITE, va, sizeof(u64))) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGBUS; + } + if (__put_user(val, va)) { + MIPS_FPU_EMU_INC_STATS(errors); + *fault_addr = va; + return SIGSEGV; + } + break; + + case madd_d_op: + handler = fpemu_dp_madd; + goto dcoptop; + case msub_d_op: + handler = fpemu_dp_msub; + goto dcoptop; + case nmadd_d_op: + handler = fpemu_dp_nmadd; + goto dcoptop; + case nmsub_d_op: + handler = fpemu_dp_nmsub; + goto dcoptop; + + dcoptop: + DPFROMREG(fr, MIPSInst_FR(ir)); + DPFROMREG(fs, MIPSInst_FS(ir)); + DPFROMREG(ft, MIPSInst_FT(ir)); + fd = (*handler) (fr, fs, ft); + DPTOREG(fd, MIPSInst_FD(ir)); + goto copcsr; + + default: + return SIGILL; + } + break; + } + + case 0x7: /* 7 */ + if (MIPSInst_FUNC(ir) != pfetch_op) { + return SIGILL; + } + /* ignore prefx operation */ + break; + + default: + return SIGILL; + } + + return 0; +} +","@@ -272,8 +272,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx, + } + + emul: +- perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, +- 1, 0, xcp, 0); ++ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, xcp, 0); + MIPS_FPU_EMU_INC_STATS(emulated); + switch (MIPSInst_OPCODE(ir)) { + case ldc1_op:{",1475,1711,2048 +17842,"XpmCreateDataFromXpmImage( + char ***data_return, + XpmImage *image, + XpmInfo *info) +{ + /* calculation variables */ + int ErrorStatus; + char buf[BUFSIZ]; + char **header = NULL, **data, **sptr, **sptr2, *s; + unsigned int header_size, header_nlines; + unsigned int data_size, data_nlines; + unsigned int extensions = 0, ext_size = 0, ext_nlines = 0; + unsigned int offset, l, n; + + *data_return = NULL; + + extensions = info && (info->valuemask & XpmExtensions) + && info->nextensions; + + /* compute the number of extensions lines and size */ + if (extensions) + CountExtensions(info->extensions, info->nextensions, + &ext_size, &ext_nlines); + + /* + * alloc a temporary array of char pointer for the header section which + */ + header_nlines = 1 + image->ncolors; /* this may wrap and/or become 0 */ + + /* 2nd check superfluous if we do not need header_nlines any further */ + if(header_nlines <= image->ncolors || + header_nlines >= UINT_MAX / sizeof(char *)) + return(XpmNoMemory); + + header_size = sizeof(char *) * header_nlines; + if (header_size >= UINT_MAX / sizeof(char *)) + return (XpmNoMemory); + header = (char **) XpmCalloc(header_size, sizeof(char *)); /* can we trust image->ncolors */ + if (!header) + return (XpmNoMemory); + + /* print the hints line */ + s = buf; +#ifndef VOID_SPRINTF + s += +#endif + sprintf(s, ""%d %d %d %d"", image->width, image->height, + image->ncolors, image->cpp); +#ifdef VOID_SPRINTF + s += strlen(s); +#endif + + if (info && (info->valuemask & XpmHotspot)) { +#ifndef VOID_SPRINTF + s += +#endif + sprintf(s, "" %d %d"", info->x_hotspot, info->y_hotspot); +#ifdef VOID_SPRINTF + s += strlen(s); +#endif + } + if (extensions) { + strcpy(s, "" XPMEXT""); + s += 7; + } + l = s - buf + 1; + *header = (char *) XpmMalloc(l); + if (!*header) + RETURN(XpmNoMemory); + header_size += l; + strcpy(*header, buf); + + /* print colors */ + ErrorStatus = CreateColors(header + 1, &header_size, + image->colorTable, image->ncolors, image->cpp); + + if (ErrorStatus != XpmSuccess) + RETURN(ErrorStatus); + + /* now we know the size needed, alloc the data and copy the header lines */ + offset = image->width * image->cpp + 1; + + if(offset <= image->width || offset <= image->cpp) + if(offset <= image->width || offset <= image->cpp) + RETURN(XpmNoMemory); + + if( (image->height + ext_nlines) >= UINT_MAX / sizeof(char *)) + RETURN(XpmNoMemory); + data_size = (image->height + ext_nlines) * sizeof(char *); + + RETURN(XpmNoMemory); + data_size += image->height * offset; + RETURN(XpmNoMemory); + data_size += image->height * offset; + + if( (header_size + ext_size) >= (UINT_MAX - data_size) ) + RETURN(XpmNoMemory); + data_size += header_size + ext_size; + + + data_nlines = header_nlines + image->height + ext_nlines; + *data = (char *) (data + data_nlines); + + /* can header have less elements then n suggests? */ + n = image->ncolors; + for (l = 0, sptr = data, sptr2 = header; l <= n && sptr && sptr2; l++, sptr++, sptr2++) { + strcpy(*sptr, *sptr2); + *(sptr + 1) = *sptr + strlen(*sptr2) + 1; + } + + /* print pixels */ + data[header_nlines] = (char *) data + header_size + + (image->height + ext_nlines) * sizeof(char *); + + CreatePixels(data + header_nlines, data_size-header_nlines, image->width, image->height, + image->cpp, image->data, image->colorTable); + + /* print extensions */ + if (extensions) + CreateExtensions(data + header_nlines + image->height - 1, + data_size - header_nlines - image->height + 1, offset, + info->extensions, info->nextensions, + ext_nlines); + + *data_return = data; + ErrorStatus = XpmSuccess; + +/* exit point, free only locally allocated variables */ +exit: + if (header) { + for (l = 0; l < header_nlines; l++) + if (header[l]) + XpmFree(header[l]); + XpmFree(header); + } + return(ErrorStatus); +} +",1,"XpmCreateDataFromXpmImage( + char ***data_return, + XpmImage *image, + XpmInfo *info) +{ + /* calculation variables */ + int ErrorStatus; + char buf[BUFSIZ]; + char **header = NULL, **data, **sptr, **sptr2, *s; + unsigned int header_size, header_nlines; + unsigned int data_size, data_nlines; + unsigned int extensions = 0, ext_size = 0, ext_nlines = 0; + unsigned int offset, l, n; + + *data_return = NULL; + + extensions = info && (info->valuemask & XpmExtensions) + && info->nextensions; + + /* compute the number of extensions lines and size */ + if (extensions) + if (CountExtensions(info->extensions, info->nextensions, + &ext_size, &ext_nlines)) + return(XpmNoMemory); + + /* + * alloc a temporary array of char pointer for the header section which + */ + header_nlines = 1 + image->ncolors; /* this may wrap and/or become 0 */ + + /* 2nd check superfluous if we do not need header_nlines any further */ + if(header_nlines <= image->ncolors || + header_nlines >= UINT_MAX / sizeof(char *)) + return(XpmNoMemory); + + header_size = sizeof(char *) * header_nlines; + if (header_size >= UINT_MAX / sizeof(char *)) + return (XpmNoMemory); + header = (char **) XpmCalloc(header_size, sizeof(char *)); /* can we trust image->ncolors */ + if (!header) + return (XpmNoMemory); + + /* print the hints line */ + s = buf; +#ifndef VOID_SPRINTF + s += +#endif + sprintf(s, ""%d %d %d %d"", image->width, image->height, + image->ncolors, image->cpp); +#ifdef VOID_SPRINTF + s += strlen(s); +#endif + + if (info && (info->valuemask & XpmHotspot)) { +#ifndef VOID_SPRINTF + s += +#endif + sprintf(s, "" %d %d"", info->x_hotspot, info->y_hotspot); +#ifdef VOID_SPRINTF + s += strlen(s); +#endif + } + if (extensions) { + strcpy(s, "" XPMEXT""); + s += 7; + } + l = s - buf + 1; + *header = (char *) XpmMalloc(l); + if (!*header) + RETURN(XpmNoMemory); + header_size += l; + strcpy(*header, buf); + + /* print colors */ + ErrorStatus = CreateColors(header + 1, &header_size, + image->colorTable, image->ncolors, image->cpp); + + if (ErrorStatus != XpmSuccess) + RETURN(ErrorStatus); + + /* now we know the size needed, alloc the data and copy the header lines */ + offset = image->width * image->cpp + 1; + + if(offset <= image->width || offset <= image->cpp) + if(offset <= image->width || offset <= image->cpp) + RETURN(XpmNoMemory); + + if (image->height > UINT_MAX - ext_nlines || + image->height + ext_nlines >= UINT_MAX / sizeof(char *)) + RETURN(XpmNoMemory); + data_size = (image->height + ext_nlines) * sizeof(char *); + + RETURN(XpmNoMemory); + data_size += image->height * offset; + RETURN(XpmNoMemory); + data_size += image->height * offset; + + if (header_size > UINT_MAX - ext_size || + header_size + ext_size >= (UINT_MAX - data_size) ) + RETURN(XpmNoMemory); + data_size += header_size + ext_size; + + + data_nlines = header_nlines + image->height + ext_nlines; + *data = (char *) (data + data_nlines); + + /* can header have less elements then n suggests? */ + n = image->ncolors; + for (l = 0, sptr = data, sptr2 = header; l <= n && sptr && sptr2; l++, sptr++, sptr2++) { + strcpy(*sptr, *sptr2); + *(sptr + 1) = *sptr + strlen(*sptr2) + 1; + } + + /* print pixels */ + data[header_nlines] = (char *) data + header_size + + (image->height + ext_nlines) * sizeof(char *); + + CreatePixels(data + header_nlines, data_size-header_nlines, image->width, image->height, + image->cpp, image->data, image->colorTable); + + /* print extensions */ + if (extensions) + CreateExtensions(data + header_nlines + image->height - 1, + data_size - header_nlines - image->height + 1, offset, + info->extensions, info->nextensions, + ext_nlines); + + *data_return = data; + ErrorStatus = XpmSuccess; + +/* exit point, free only locally allocated variables */ +exit: + if (header) { + for (l = 0; l < header_nlines; l++) + if (header[l]) + XpmFree(header[l]); + XpmFree(header); + } + return(ErrorStatus); +} +","@@ -48,7 +48,7 @@ LFUNC(CreatePixels, void, (char **dataptr, unsigned int data_size, + unsigned int height, unsigned int cpp, + unsigned int *pixels, XpmColor *colors)); + +-LFUNC(CountExtensions, void, (XpmExtension *ext, unsigned int num, ++LFUNC(CountExtensions, int, (XpmExtension *ext, unsigned int num, + unsigned int *ext_size, + unsigned int *ext_nlines)); + +@@ -122,8 +122,9 @@ XpmCreateDataFromXpmImage( + + /* compute the number of extensions lines and size */ + if (extensions) +- CountExtensions(info->extensions, info->nextensions, +- &ext_size, &ext_nlines); ++ if (CountExtensions(info->extensions, info->nextensions, ++ &ext_size, &ext_nlines)) ++ return(XpmNoMemory); + + /* + * alloc a temporary array of char pointer for the header section which +@@ -187,7 +188,8 @@ XpmCreateDataFromXpmImage( + if(offset <= image->width || offset <= image->cpp) + RETURN(XpmNoMemory); + +- if( (image->height + ext_nlines) >= UINT_MAX / sizeof(char *)) ++ if (image->height > UINT_MAX - ext_nlines || ++ image->height + ext_nlines >= UINT_MAX / sizeof(char *)) + RETURN(XpmNoMemory); + data_size = (image->height + ext_nlines) * sizeof(char *); + +@@ -196,7 +198,8 @@ XpmCreateDataFromXpmImage( + RETURN(XpmNoMemory); + data_size += image->height * offset; + +- if( (header_size + ext_size) >= (UINT_MAX - data_size) ) ++ if (header_size > UINT_MAX - ext_size || ++ header_size + ext_size >= (UINT_MAX - data_size) ) + RETURN(XpmNoMemory); + data_size += header_size + ext_size; + +@@ -343,13 +346,14 @@ CreatePixels( + *s = '\0'; + } + +-static void ++static int + CountExtensions( + XpmExtension *ext, + unsigned int num, + unsigned int *ext_size, + unsigned int *ext_nlines) + { ++ size_t len; + unsigned int x, y, a, size, nlines; + char **line; + +@@ -357,16 +361,28 @@ CountExtensions( + nlines = 0; + for (x = 0; x < num; x++, ext++) { + /* 1 for the name */ ++ if (ext->nlines == UINT_MAX || nlines > UINT_MAX - ext->nlines - 1) ++ return (1); + nlines += ext->nlines + 1; + /* 8 = 7 (for ""XPMEXT "") + 1 (for 0) */ +- size += strlen(ext->name) + 8; ++ len = strlen(ext->name) + 8; ++ if (len > UINT_MAX - size) ++ return (1); ++ size += len; + a = ext->nlines; +- for (y = 0, line = ext->lines; y < a; y++, line++) +- size += strlen(*line) + 1; ++ for (y = 0, line = ext->lines; y < a; y++, line++) { ++ len = strlen(*line) + 1; ++ if (len > UINT_MAX - size) ++ return (1); ++ size += len; ++ } + } ++ if (size > UINT_MAX - 10 || nlines > UINT_MAX - 1) ++ return (1); + /* 10 and 1 are for the ending ""XPMENDEXT"" */ + *ext_size = size + 10; + *ext_nlines = nlines + 1; ++ return (0); + } + + static void",1122,1358,2048 +7912,"int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno) +{ + struct Envelope *newenv = NULL; + char buf[LONG_STRING]; + char path[PATH_MAX]; + char *pc = NULL; + unsigned int bytes; + struct Progress progressbar; + unsigned int uid; + int cacheno; + struct ImapCache *cache = NULL; + bool retried = false; + bool read; + int rc; + + /* Sam's weird courier server returns an OK response even when FETCH + * fails. Thanks Sam. */ + bool fetched = false; + int output_progress; + + struct ImapData *idata = ctx->data; + struct Header *h = ctx->hdrs[msgno]; + + msg->fp = msg_cache_get(idata, h); + if (msg->fp) + { + if (HEADER_DATA(h)->parsed) + return 0; + else + goto parsemsg; + } + + /* we still do some caching even if imap_cachedir is unset */ + /* see if we already have the message in our cache */ + cacheno = HEADER_DATA(h)->uid % IMAP_CACHE_LEN; + cache = &idata->cache[cacheno]; + + if (cache->path) + { + /* don't treat cache errors as fatal, just fall back. */ + if (cache->uid == HEADER_DATA(h)->uid && (msg->fp = fopen(cache->path, ""r""))) + return 0; + else + { + unlink(cache->path); + FREE(&cache->path); + } + } + + /* This function is called in a few places after endwin() + * e.g. mutt_pipe_message(). */ + output_progress = !isendwin(); + if (output_progress) + mutt_message(_(""Fetching message..."")); + + msg->fp = msg_cache_put(idata, h); + if (!msg->fp) + { + cache->uid = HEADER_DATA(h)->uid; + mutt_mktemp(path, sizeof(path)); + cache->path = mutt_str_strdup(path); + msg->fp = mutt_file_fopen(path, ""w+""); + if (!msg->fp) + { + FREE(&cache->path); + return -1; + } + } + + /* mark this header as currently inactive so the command handler won't + * also try to update it. HACK until all this code can be moved into the + * command handler */ + h->active = false; + + snprintf(buf, sizeof(buf), ""UID FETCH %u %s"", HEADER_DATA(h)->uid, + (mutt_bit_isset(idata->capabilities, IMAP4REV1) ? + (ImapPeek ? ""BODY.PEEK[]"" : ""BODY[]"") : + ""RFC822"")); + + imap_cmd_start(idata, buf); + do + { + rc = imap_cmd_step(idata); + if (rc != IMAP_CMD_CONTINUE) + break; + + pc = idata->buf; + pc = imap_next_word(pc); + pc = imap_next_word(pc); + + if (mutt_str_strncasecmp(""FETCH"", pc, 5) == 0) + { + while (*pc) + { + pc = imap_next_word(pc); + if (pc[0] == '(') + pc++; + if (mutt_str_strncasecmp(""UID"", pc, 3) == 0) + { + pc = imap_next_word(pc); + if (mutt_str_atoui(pc, &uid) < 0) + goto bail; + if (uid != HEADER_DATA(h)->uid) + { + mutt_error(_( + ""The message index is incorrect. Try reopening the mailbox."")); + } + } + else if ((mutt_str_strncasecmp(""RFC822"", pc, 6) == 0) || + (mutt_str_strncasecmp(""BODY[]"", pc, 6) == 0)) + { + pc = imap_next_word(pc); + if (imap_get_literal_count(pc, &bytes) < 0) + { + imap_error(""imap_msg_open()"", buf); + goto bail; + } + if (output_progress) + { + mutt_progress_init(&progressbar, _(""Fetching message...""), + MUTT_PROGRESS_SIZE, NetInc, bytes); + } + if (imap_read_literal(msg->fp, idata, bytes, + output_progress ? &progressbar : NULL) < 0) + { + goto bail; + } + /* pick up trailing line */ + rc = imap_cmd_step(idata); + if (rc != IMAP_CMD_CONTINUE) + goto bail; + pc = idata->buf; + + fetched = true; + } + /* UW-IMAP will provide a FLAGS update here if the FETCH causes a + * change (eg from \Unseen to \Seen). + * Uncommitted changes in neomutt take precedence. If we decide to + * incrementally update flags later, this won't stop us syncing */ + else if ((mutt_str_strncasecmp(""FLAGS"", pc, 5) == 0) && !h->changed) + { + pc = imap_set_flags(idata, h, pc, NULL); + if (!pc) + goto bail; + } + } + } + } while (rc == IMAP_CMD_CONTINUE); + + /* see comment before command start. */ + h->active = true; + + fflush(msg->fp); + if (ferror(msg->fp)) + { + mutt_perror(cache->path); + goto bail; + } + + if (rc != IMAP_CMD_OK) + goto bail; + + if (!fetched || !imap_code(idata->buf)) + goto bail; + + msg_cache_commit(idata, h); + +parsemsg: + /* Update the header information. Previously, we only downloaded a + * portion of the headers, those required for the main display. + */ + rewind(msg->fp); + /* It may be that the Status header indicates a message is read, but the + * IMAP server doesn't know the message has been \Seen. So we capture + * the server's notion of 'read' and if it differs from the message info + * picked up in mutt_rfc822_read_header, we mark the message (and context + * changed). Another possibility: ignore Status on IMAP? */ + read = h->read; + newenv = mutt_rfc822_read_header(msg->fp, h, 0, 0); + mutt_env_merge(h->env, &newenv); + + /* see above. We want the new status in h->read, so we unset it manually + * and let mutt_set_flag set it correctly, updating context. */ + if (read != h->read) + { + h->read = read; + mutt_set_flag(ctx, h, MUTT_NEW, read); + } + + h->lines = 0; + fgets(buf, sizeof(buf), msg->fp); + while (!feof(msg->fp)) + { + h->lines++; + fgets(buf, sizeof(buf), msg->fp); + } + + h->content->length = ftell(msg->fp) - h->content->offset; + + mutt_clear_error(); + rewind(msg->fp); + HEADER_DATA(h)->parsed = true; + + /* retry message parse if cached message is empty */ + if (!retried && ((h->lines == 0) || (h->content->length == 0))) + { + imap_cache_del(idata, h); + retried = true; + goto parsemsg; + } + + return 0; + +bail: + mutt_file_fclose(&msg->fp); + imap_cache_del(idata, h); + if (cache->path) + { + unlink(cache->path); + FREE(&cache->path); + } + + return -1; +} +",0,"int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno) +{ + struct Envelope *newenv = NULL; + char buf[LONG_STRING]; + char path[PATH_MAX]; + char *pc = NULL; + unsigned int bytes; + struct Progress progressbar; + unsigned int uid; + int cacheno; + struct ImapCache *cache = NULL; + bool retried = false; + bool read; + int rc; + + /* Sam's weird courier server returns an OK response even when FETCH + * fails. Thanks Sam. */ + bool fetched = false; + int output_progress; + + struct ImapData *idata = ctx->data; + struct Header *h = ctx->hdrs[msgno]; + + msg->fp = msg_cache_get(idata, h); + if (msg->fp) + { + if (HEADER_DATA(h)->parsed) + return 0; + else + goto parsemsg; + } + + /* we still do some caching even if imap_cachedir is unset */ + /* see if we already have the message in our cache */ + cacheno = HEADER_DATA(h)->uid % IMAP_CACHE_LEN; + cache = &idata->cache[cacheno]; + + if (cache->path) + { + /* don't treat cache errors as fatal, just fall back. */ + if (cache->uid == HEADER_DATA(h)->uid && (msg->fp = fopen(cache->path, ""r""))) + return 0; + else + { + unlink(cache->path); + FREE(&cache->path); + } + } + + /* This function is called in a few places after endwin() + * e.g. mutt_pipe_message(). */ + output_progress = !isendwin(); + if (output_progress) + mutt_message(_(""Fetching message..."")); + + msg->fp = msg_cache_put(idata, h); + if (!msg->fp) + { + cache->uid = HEADER_DATA(h)->uid; + mutt_mktemp(path, sizeof(path)); + cache->path = mutt_str_strdup(path); + msg->fp = mutt_file_fopen(path, ""w+""); + if (!msg->fp) + { + FREE(&cache->path); + return -1; + } + } + + /* mark this header as currently inactive so the command handler won't + * also try to update it. HACK until all this code can be moved into the + * command handler */ + h->active = false; + + snprintf(buf, sizeof(buf), ""UID FETCH %u %s"", HEADER_DATA(h)->uid, + (mutt_bit_isset(idata->capabilities, IMAP4REV1) ? + (ImapPeek ? ""BODY.PEEK[]"" : ""BODY[]"") : + ""RFC822"")); + + imap_cmd_start(idata, buf); + do + { + rc = imap_cmd_step(idata); + if (rc != IMAP_CMD_CONTINUE) + break; + + pc = idata->buf; + pc = imap_next_word(pc); + pc = imap_next_word(pc); + + if (mutt_str_strncasecmp(""FETCH"", pc, 5) == 0) + { + while (*pc) + { + pc = imap_next_word(pc); + if (pc[0] == '(') + pc++; + if (mutt_str_strncasecmp(""UID"", pc, 3) == 0) + { + pc = imap_next_word(pc); + if (mutt_str_atoui(pc, &uid) < 0) + goto bail; + if (uid != HEADER_DATA(h)->uid) + { + mutt_error(_( + ""The message index is incorrect. Try reopening the mailbox."")); + } + } + else if ((mutt_str_strncasecmp(""RFC822"", pc, 6) == 0) || + (mutt_str_strncasecmp(""BODY[]"", pc, 6) == 0)) + { + pc = imap_next_word(pc); + if (imap_get_literal_count(pc, &bytes) < 0) + { + imap_error(""imap_msg_open()"", buf); + goto bail; + } + if (output_progress) + { + mutt_progress_init(&progressbar, _(""Fetching message...""), + MUTT_PROGRESS_SIZE, NetInc, bytes); + } + if (imap_read_literal(msg->fp, idata, bytes, + output_progress ? &progressbar : NULL) < 0) + { + goto bail; + } + /* pick up trailing line */ + rc = imap_cmd_step(idata); + if (rc != IMAP_CMD_CONTINUE) + goto bail; + pc = idata->buf; + + fetched = true; + } + /* UW-IMAP will provide a FLAGS update here if the FETCH causes a + * change (eg from \Unseen to \Seen). + * Uncommitted changes in neomutt take precedence. If we decide to + * incrementally update flags later, this won't stop us syncing */ + else if ((mutt_str_strncasecmp(""FLAGS"", pc, 5) == 0) && !h->changed) + { + pc = imap_set_flags(idata, h, pc, NULL); + if (!pc) + goto bail; + } + } + } + } while (rc == IMAP_CMD_CONTINUE); + + /* see comment before command start. */ + h->active = true; + + fflush(msg->fp); + if (ferror(msg->fp)) + { + mutt_perror(cache->path); + goto bail; + } + + if (rc != IMAP_CMD_OK) + goto bail; + + if (!fetched || !imap_code(idata->buf)) + goto bail; + + msg_cache_commit(idata, h); + +parsemsg: + /* Update the header information. Previously, we only downloaded a + * portion of the headers, those required for the main display. + */ + rewind(msg->fp); + /* It may be that the Status header indicates a message is read, but the + * IMAP server doesn't know the message has been \Seen. So we capture + * the server's notion of 'read' and if it differs from the message info + * picked up in mutt_rfc822_read_header, we mark the message (and context + * changed). Another possibility: ignore Status on IMAP? */ + read = h->read; + newenv = mutt_rfc822_read_header(msg->fp, h, 0, 0); + mutt_env_merge(h->env, &newenv); + + /* see above. We want the new status in h->read, so we unset it manually + * and let mutt_set_flag set it correctly, updating context. */ + if (read != h->read) + { + h->read = read; + mutt_set_flag(ctx, h, MUTT_NEW, read); + } + + h->lines = 0; + fgets(buf, sizeof(buf), msg->fp); + while (!feof(msg->fp)) + { + h->lines++; + fgets(buf, sizeof(buf), msg->fp); + } + + h->content->length = ftell(msg->fp) - h->content->offset; + + mutt_clear_error(); + rewind(msg->fp); + HEADER_DATA(h)->parsed = true; + + /* retry message parse if cached message is empty */ + if (!retried && ((h->lines == 0) || (h->content->length == 0))) + { + imap_cache_del(idata, h); + retried = true; + goto parsemsg; + } + + return 0; + +bail: + mutt_file_fclose(&msg->fp); + imap_cache_del(idata, h); + if (cache->path) + { + unlink(cache->path); + FREE(&cache->path); + } + + return -1; +} +","@@ -330,7 +330,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) + } + s++; + ptmp = tmp; +- while (*s && *s != '\""') ++ while (*s && (*s != '\""') && (ptmp != (tmp + sizeof(tmp) - 1))) + *ptmp++ = *s++; + if (*s != '\""') + return -1; +@@ -343,7 +343,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) + s += 11; + SKIPWS(s); + ptmp = tmp; +- while (isdigit((unsigned char) *s)) ++ while (isdigit((unsigned char) *s) && (ptmp != (tmp + sizeof(tmp) - 1))) + *ptmp++ = *s++; + *ptmp = '\0'; + if (mutt_str_atol(tmp, &h->content_length) < 0)",1676,1912,2048 +6300,"static __init int hardware_setup(void) +{ + int r = -ENOMEM, i, msr; + + rdmsrl_safe(MSR_EFER, &host_efer); + + for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i) + kvm_define_shared_msr(i, vmx_msr_index[i]); + + for (i = 0; i < VMX_BITMAP_NR; i++) { + vmx_bitmap[i] = (unsigned long *)__get_free_page(GFP_KERNEL); + if (!vmx_bitmap[i]) + goto out; + } + + vmx_io_bitmap_b = (unsigned long *)__get_free_page(GFP_KERNEL); + memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE); + memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE); + + /* + * Allow direct access to the PC debug port (it is often used for I/O + * delays, but the vmexits simply slow things down). + */ + memset(vmx_io_bitmap_a, 0xff, PAGE_SIZE); + clear_bit(0x80, vmx_io_bitmap_a); + + memset(vmx_io_bitmap_b, 0xff, PAGE_SIZE); + + memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE); + memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE); + + if (setup_vmcs_config(&vmcs_config) < 0) { + r = -EIO; + goto out; + } + + if (boot_cpu_has(X86_FEATURE_NX)) + kvm_enable_efer_bits(EFER_NX); + + if (!cpu_has_vmx_vpid() || !cpu_has_vmx_invvpid() || + !(cpu_has_vmx_invvpid_single() || cpu_has_vmx_invvpid_global())) + enable_vpid = 0; + + if (!cpu_has_vmx_shadow_vmcs()) + enable_shadow_vmcs = 0; + if (enable_shadow_vmcs) + init_vmcs_shadow_fields(); + + if (!cpu_has_vmx_ept() || + !cpu_has_vmx_ept_4levels() || + !cpu_has_vmx_ept_mt_wb()) { + enable_ept = 0; + enable_unrestricted_guest = 0; + enable_ept_ad_bits = 0; + } + + if (!cpu_has_vmx_ept_ad_bits() || !enable_ept) + enable_ept_ad_bits = 0; + + if (!cpu_has_vmx_unrestricted_guest()) + enable_unrestricted_guest = 0; + + if (!cpu_has_vmx_flexpriority()) + flexpriority_enabled = 0; + + /* + * set_apic_access_page_addr() is used to reload apic access + * page upon invalidation. No need to do anything if not + * using the APIC_ACCESS_ADDR VMCS field. + */ + if (!flexpriority_enabled) + kvm_x86_ops->set_apic_access_page_addr = NULL; + + if (!cpu_has_vmx_tpr_shadow()) + kvm_x86_ops->update_cr8_intercept = NULL; + + if (enable_ept && !cpu_has_vmx_ept_2m_page()) + kvm_disable_largepages(); + + if (!cpu_has_vmx_ple()) + ple_gap = 0; + + if (!cpu_has_vmx_apicv()) { + enable_apicv = 0; + kvm_x86_ops->sync_pir_to_irr = NULL; + } + + if (cpu_has_vmx_tsc_scaling()) { + kvm_has_tsc_control = true; + kvm_max_tsc_scaling_ratio = KVM_VMX_TSC_MULTIPLIER_MAX; + kvm_tsc_scaling_ratio_frac_bits = 48; + } + + vmx_disable_intercept_for_msr(MSR_FS_BASE, false); + vmx_disable_intercept_for_msr(MSR_GS_BASE, false); + vmx_disable_intercept_for_msr(MSR_KERNEL_GS_BASE, true); + vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_CS, false); + vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_ESP, false); + vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false); + + memcpy(vmx_msr_bitmap_legacy_x2apic_apicv, + vmx_msr_bitmap_legacy, PAGE_SIZE); + memcpy(vmx_msr_bitmap_longmode_x2apic_apicv, + vmx_msr_bitmap_longmode, PAGE_SIZE); + memcpy(vmx_msr_bitmap_legacy_x2apic, + vmx_msr_bitmap_legacy, PAGE_SIZE); + memcpy(vmx_msr_bitmap_longmode_x2apic, + vmx_msr_bitmap_longmode, PAGE_SIZE); + + set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ + + for (msr = 0x800; msr <= 0x8ff; msr++) { + if (msr == 0x839 /* TMCCT */) + continue; + vmx_disable_intercept_msr_x2apic(msr, MSR_TYPE_R, true); + } + + /* + * TPR reads and writes can be virtualized even if virtual interrupt + * delivery is not in use. + */ + vmx_disable_intercept_msr_x2apic(0x808, MSR_TYPE_W, true); + vmx_disable_intercept_msr_x2apic(0x808, MSR_TYPE_R | MSR_TYPE_W, false); + + /* EOI */ + vmx_disable_intercept_msr_x2apic(0x80b, MSR_TYPE_W, true); + /* SELF-IPI */ + vmx_disable_intercept_msr_x2apic(0x83f, MSR_TYPE_W, true); + + if (enable_ept) + vmx_enable_tdp(); + else + kvm_disable_tdp(); + + update_ple_window_actual_max(); + + /* + * Only enable PML when hardware supports PML feature, and both EPT + * and EPT A/D bit features are enabled -- PML depends on them to work. + */ + if (!enable_ept || !enable_ept_ad_bits || !cpu_has_vmx_pml()) + enable_pml = 0; + + if (!enable_pml) { + kvm_x86_ops->slot_enable_log_dirty = NULL; + kvm_x86_ops->slot_disable_log_dirty = NULL; + kvm_x86_ops->flush_log_dirty = NULL; + kvm_x86_ops->enable_log_dirty_pt_masked = NULL; + } + + if (cpu_has_vmx_preemption_timer() && enable_preemption_timer) { + u64 vmx_msr; + + rdmsrl(MSR_IA32_VMX_MISC, vmx_msr); + cpu_preemption_timer_multi = + vmx_msr & VMX_MISC_PREEMPTION_TIMER_RATE_MASK; + } else { + kvm_x86_ops->set_hv_timer = NULL; + kvm_x86_ops->cancel_hv_timer = NULL; + } + + kvm_set_posted_intr_wakeup_handler(wakeup_handler); + + kvm_mce_cap_supported |= MCG_LMCE_P; + + return alloc_kvm_area(); + +out: + for (i = 0; i < VMX_BITMAP_NR; i++) + free_page((unsigned long)vmx_bitmap[i]); + + return r; +} +",0,"static __init int hardware_setup(void) +{ + int r = -ENOMEM, i, msr; + + rdmsrl_safe(MSR_EFER, &host_efer); + + for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i) + kvm_define_shared_msr(i, vmx_msr_index[i]); + + for (i = 0; i < VMX_BITMAP_NR; i++) { + vmx_bitmap[i] = (unsigned long *)__get_free_page(GFP_KERNEL); + if (!vmx_bitmap[i]) + goto out; + } + + vmx_io_bitmap_b = (unsigned long *)__get_free_page(GFP_KERNEL); + memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE); + memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE); + + /* + * Allow direct access to the PC debug port (it is often used for I/O + * delays, but the vmexits simply slow things down). + */ + memset(vmx_io_bitmap_a, 0xff, PAGE_SIZE); + clear_bit(0x80, vmx_io_bitmap_a); + + memset(vmx_io_bitmap_b, 0xff, PAGE_SIZE); + + memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE); + memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE); + + if (setup_vmcs_config(&vmcs_config) < 0) { + r = -EIO; + goto out; + } + + if (boot_cpu_has(X86_FEATURE_NX)) + kvm_enable_efer_bits(EFER_NX); + + if (!cpu_has_vmx_vpid() || !cpu_has_vmx_invvpid() || + !(cpu_has_vmx_invvpid_single() || cpu_has_vmx_invvpid_global())) + enable_vpid = 0; + + if (!cpu_has_vmx_shadow_vmcs()) + enable_shadow_vmcs = 0; + if (enable_shadow_vmcs) + init_vmcs_shadow_fields(); + + if (!cpu_has_vmx_ept() || + !cpu_has_vmx_ept_4levels() || + !cpu_has_vmx_ept_mt_wb()) { + enable_ept = 0; + enable_unrestricted_guest = 0; + enable_ept_ad_bits = 0; + } + + if (!cpu_has_vmx_ept_ad_bits() || !enable_ept) + enable_ept_ad_bits = 0; + + if (!cpu_has_vmx_unrestricted_guest()) + enable_unrestricted_guest = 0; + + if (!cpu_has_vmx_flexpriority()) + flexpriority_enabled = 0; + + /* + * set_apic_access_page_addr() is used to reload apic access + * page upon invalidation. No need to do anything if not + * using the APIC_ACCESS_ADDR VMCS field. + */ + if (!flexpriority_enabled) + kvm_x86_ops->set_apic_access_page_addr = NULL; + + if (!cpu_has_vmx_tpr_shadow()) + kvm_x86_ops->update_cr8_intercept = NULL; + + if (enable_ept && !cpu_has_vmx_ept_2m_page()) + kvm_disable_largepages(); + + if (!cpu_has_vmx_ple()) + ple_gap = 0; + + if (!cpu_has_vmx_apicv()) { + enable_apicv = 0; + kvm_x86_ops->sync_pir_to_irr = NULL; + } + + if (cpu_has_vmx_tsc_scaling()) { + kvm_has_tsc_control = true; + kvm_max_tsc_scaling_ratio = KVM_VMX_TSC_MULTIPLIER_MAX; + kvm_tsc_scaling_ratio_frac_bits = 48; + } + + vmx_disable_intercept_for_msr(MSR_FS_BASE, false); + vmx_disable_intercept_for_msr(MSR_GS_BASE, false); + vmx_disable_intercept_for_msr(MSR_KERNEL_GS_BASE, true); + vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_CS, false); + vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_ESP, false); + vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false); + + memcpy(vmx_msr_bitmap_legacy_x2apic_apicv, + vmx_msr_bitmap_legacy, PAGE_SIZE); + memcpy(vmx_msr_bitmap_longmode_x2apic_apicv, + vmx_msr_bitmap_longmode, PAGE_SIZE); + memcpy(vmx_msr_bitmap_legacy_x2apic, + vmx_msr_bitmap_legacy, PAGE_SIZE); + memcpy(vmx_msr_bitmap_longmode_x2apic, + vmx_msr_bitmap_longmode, PAGE_SIZE); + + set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ + + for (msr = 0x800; msr <= 0x8ff; msr++) { + if (msr == 0x839 /* TMCCT */) + continue; + vmx_disable_intercept_msr_x2apic(msr, MSR_TYPE_R, true); + } + + /* + * TPR reads and writes can be virtualized even if virtual interrupt + * delivery is not in use. + */ + vmx_disable_intercept_msr_x2apic(0x808, MSR_TYPE_W, true); + vmx_disable_intercept_msr_x2apic(0x808, MSR_TYPE_R | MSR_TYPE_W, false); + + /* EOI */ + vmx_disable_intercept_msr_x2apic(0x80b, MSR_TYPE_W, true); + /* SELF-IPI */ + vmx_disable_intercept_msr_x2apic(0x83f, MSR_TYPE_W, true); + + if (enable_ept) + vmx_enable_tdp(); + else + kvm_disable_tdp(); + + update_ple_window_actual_max(); + + /* + * Only enable PML when hardware supports PML feature, and both EPT + * and EPT A/D bit features are enabled -- PML depends on them to work. + */ + if (!enable_ept || !enable_ept_ad_bits || !cpu_has_vmx_pml()) + enable_pml = 0; + + if (!enable_pml) { + kvm_x86_ops->slot_enable_log_dirty = NULL; + kvm_x86_ops->slot_disable_log_dirty = NULL; + kvm_x86_ops->flush_log_dirty = NULL; + kvm_x86_ops->enable_log_dirty_pt_masked = NULL; + } + + if (cpu_has_vmx_preemption_timer() && enable_preemption_timer) { + u64 vmx_msr; + + rdmsrl(MSR_IA32_VMX_MISC, vmx_msr); + cpu_preemption_timer_multi = + vmx_msr & VMX_MISC_PREEMPTION_TIMER_RATE_MASK; + } else { + kvm_x86_ops->set_hv_timer = NULL; + kvm_x86_ops->cancel_hv_timer = NULL; + } + + kvm_set_posted_intr_wakeup_handler(wakeup_handler); + + kvm_mce_cap_supported |= MCG_LMCE_P; + + return alloc_kvm_area(); + +out: + for (i = 0; i < VMX_BITMAP_NR; i++) + free_page((unsigned long)vmx_bitmap[i]); + + return r; +} +","@@ -10525,6 +10525,11 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, + if (exec_control & CPU_BASED_TPR_SHADOW) { + vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, -1ull); + vmcs_write32(TPR_THRESHOLD, vmcs12->tpr_threshold); ++ } else { ++#ifdef CONFIG_X86_64 ++ exec_control |= CPU_BASED_CR8_LOAD_EXITING | ++ CPU_BASED_CR8_STORE_EXITING; ++#endif + } + + /*",1563,1799,2048 +9571,"static pack_t *FS_LoadZipFile(const char *zipfile, const char *basename) +{ + fileInPack_t *buildBuffer; + pack_t *pack; + unzFile uf; + int err; + unz_global_info gi; + char filename_inzip[MAX_ZPATH]; + unz_file_info file_info; + int i, len; + long hash; + int fs_numHeaderLongs; + int *fs_headerLongs; + char *namePtr; + + fs_numHeaderLongs = 0; + + uf = unzOpen( zipfile ); + err = unzGetGlobalInfo( uf,&gi ); + + if ( err != UNZ_OK ) { + return NULL; + } + + fs_packFiles += gi.number_entry; + + len = 0; + unzGoToFirstFile( uf ); + for ( i = 0; i < gi.number_entry; i++ ) + { + err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL, 0, NULL, 0 ); + if ( err != UNZ_OK ) { + break; + } + len += strlen( filename_inzip ) + 1; + unzGoToNextFile( uf ); + } + + buildBuffer = Z_Malloc( ( gi.number_entry * sizeof( fileInPack_t ) ) + len ); + namePtr = ( (char *) buildBuffer ) + gi.number_entry * sizeof( fileInPack_t ); + fs_headerLongs = Z_Malloc( ( gi.number_entry + 1 ) * sizeof(int) ); + fs_headerLongs[ fs_numHeaderLongs++ ] = LittleLong( fs_checksumFeed ); + + for ( i = 1; i <= MAX_FILEHASH_SIZE; i <<= 1 ) { + if ( i > gi.number_entry ) { + break; + } + } + + pack = Z_Malloc( sizeof( pack_t ) + i * sizeof( fileInPack_t * ) ); + pack->hashSize = i; + pack->hashTable = ( fileInPack_t ** )( ( (char *) pack ) + sizeof( pack_t ) ); + for ( i = 0; i < pack->hashSize; i++ ) { + pack->hashTable[i] = NULL; + } + + Q_strncpyz( pack->pakFilename, zipfile, sizeof( pack->pakFilename ) ); + Q_strncpyz( pack->pakBasename, basename, sizeof( pack->pakBasename ) ); + + if ( strlen( pack->pakBasename ) > 4 && !Q_stricmp( pack->pakBasename + strlen( pack->pakBasename ) - 4, "".pk3"" ) ) { + pack->pakBasename[strlen( pack->pakBasename ) - 4] = 0; + } + + pack->handle = uf; + pack->numfiles = gi.number_entry; + unzGoToFirstFile( uf ); + + for ( i = 0; i < gi.number_entry; i++ ) + { + err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL, 0, NULL, 0 ); + if ( err != UNZ_OK ) { + break; + } + if ( file_info.uncompressed_size > 0 ) { + fs_headerLongs[fs_numHeaderLongs++] = LittleLong( file_info.crc ); + } + Q_strlwr( filename_inzip ); + hash = FS_HashFileName( filename_inzip, pack->hashSize ); + buildBuffer[i].name = namePtr; + strcpy( buildBuffer[i].name, filename_inzip ); + namePtr += strlen( filename_inzip ) + 1; + buildBuffer[i].pos = unzGetOffset(uf); + buildBuffer[i].len = file_info.uncompressed_size; + buildBuffer[i].next = pack->hashTable[hash]; + pack->hashTable[hash] = &buildBuffer[i]; + unzGoToNextFile( uf ); + } + + pack->checksum = Com_BlockChecksum( &fs_headerLongs[ 1 ], sizeof(*fs_headerLongs) * ( fs_numHeaderLongs - 1 ) ); + pack->pure_checksum = Com_BlockChecksum( fs_headerLongs, sizeof(*fs_headerLongs) * fs_numHeaderLongs ); + pack->checksum = LittleLong( pack->checksum ); + pack->pure_checksum = LittleLong( pack->pure_checksum ); + + Z_Free( fs_headerLongs ); + + pack->buildBuffer = buildBuffer; + return pack; +} +",0,"static pack_t *FS_LoadZipFile(const char *zipfile, const char *basename) +{ + fileInPack_t *buildBuffer; + pack_t *pack; + unzFile uf; + int err; + unz_global_info gi; + char filename_inzip[MAX_ZPATH]; + unz_file_info file_info; + int i, len; + long hash; + int fs_numHeaderLongs; + int *fs_headerLongs; + char *namePtr; + + fs_numHeaderLongs = 0; + + uf = unzOpen( zipfile ); + err = unzGetGlobalInfo( uf,&gi ); + + if ( err != UNZ_OK ) { + return NULL; + } + + fs_packFiles += gi.number_entry; + + len = 0; + unzGoToFirstFile( uf ); + for ( i = 0; i < gi.number_entry; i++ ) + { + err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL, 0, NULL, 0 ); + if ( err != UNZ_OK ) { + break; + } + len += strlen( filename_inzip ) + 1; + unzGoToNextFile( uf ); + } + + buildBuffer = Z_Malloc( ( gi.number_entry * sizeof( fileInPack_t ) ) + len ); + namePtr = ( (char *) buildBuffer ) + gi.number_entry * sizeof( fileInPack_t ); + fs_headerLongs = Z_Malloc( ( gi.number_entry + 1 ) * sizeof(int) ); + fs_headerLongs[ fs_numHeaderLongs++ ] = LittleLong( fs_checksumFeed ); + + for ( i = 1; i <= MAX_FILEHASH_SIZE; i <<= 1 ) { + if ( i > gi.number_entry ) { + break; + } + } + + pack = Z_Malloc( sizeof( pack_t ) + i * sizeof( fileInPack_t * ) ); + pack->hashSize = i; + pack->hashTable = ( fileInPack_t ** )( ( (char *) pack ) + sizeof( pack_t ) ); + for ( i = 0; i < pack->hashSize; i++ ) { + pack->hashTable[i] = NULL; + } + + Q_strncpyz( pack->pakFilename, zipfile, sizeof( pack->pakFilename ) ); + Q_strncpyz( pack->pakBasename, basename, sizeof( pack->pakBasename ) ); + + if ( strlen( pack->pakBasename ) > 4 && !Q_stricmp( pack->pakBasename + strlen( pack->pakBasename ) - 4, "".pk3"" ) ) { + pack->pakBasename[strlen( pack->pakBasename ) - 4] = 0; + } + + pack->handle = uf; + pack->numfiles = gi.number_entry; + unzGoToFirstFile( uf ); + + for ( i = 0; i < gi.number_entry; i++ ) + { + err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL, 0, NULL, 0 ); + if ( err != UNZ_OK ) { + break; + } + if ( file_info.uncompressed_size > 0 ) { + fs_headerLongs[fs_numHeaderLongs++] = LittleLong( file_info.crc ); + } + Q_strlwr( filename_inzip ); + hash = FS_HashFileName( filename_inzip, pack->hashSize ); + buildBuffer[i].name = namePtr; + strcpy( buildBuffer[i].name, filename_inzip ); + namePtr += strlen( filename_inzip ) + 1; + buildBuffer[i].pos = unzGetOffset(uf); + buildBuffer[i].len = file_info.uncompressed_size; + buildBuffer[i].next = pack->hashTable[hash]; + pack->hashTable[hash] = &buildBuffer[i]; + unzGoToNextFile( uf ); + } + + pack->checksum = Com_BlockChecksum( &fs_headerLongs[ 1 ], sizeof(*fs_headerLongs) * ( fs_numHeaderLongs - 1 ) ); + pack->pure_checksum = Com_BlockChecksum( fs_headerLongs, sizeof(*fs_headerLongs) * fs_numHeaderLongs ); + pack->checksum = LittleLong( pack->checksum ); + pack->pure_checksum = LittleLong( pack->pure_checksum ); + + Z_Free( fs_headerLongs ); + + pack->buildBuffer = buildBuffer; + return pack; +} +","@@ -1591,12 +1591,18 @@ long FS_FOpenFileRead(const char *filename, fileHandle_t *file, qboolean uniqueF + { + searchpath_t *search; + long len; ++ qboolean isLocalConfig; + + if(!fs_searchpaths) + Com_Error(ERR_FATAL, ""Filesystem call made without initialization""); + ++ isLocalConfig = !strcmp(filename, ""autoexec.cfg"") || !strcmp(filename, Q3CONFIG_CFG); + for(search = fs_searchpaths; search; search = search->next) + { ++ // autoexec.cfg and wolfconfig.cfg can only be loaded outside of pk3 files. ++ if (isLocalConfig && search->pack) ++ continue; ++ + len = FS_FOpenFileReadDir(filename, search, file, uniqueFILE, qfalse); + + if(file == NULL)",953,1189,2048 +10992,"error::Error GLES2DecoderImpl::DoTexImage2D( + GLenum target, + GLint level, + GLenum internal_format, + GLsizei width, + GLsizei height, + GLint border, + GLenum format, + GLenum type, + const void* pixels, + uint32 pixels_size) { + if (!validators_->texture_target.IsValid(target)) { + SetGLErrorInvalidEnum(""glTexImage2D"", target, ""target""); + return error::kNoError; + } + if (!validators_->texture_format.IsValid(internal_format)) { + SetGLErrorInvalidEnum(""glTexImage2D"", internal_format, ""internal_format""); + return error::kNoError; + } + if (!validators_->texture_format.IsValid(format)) { + SetGLErrorInvalidEnum(""glTexImage2D"", format, ""format""); + return error::kNoError; + } + if (!validators_->pixel_type.IsValid(type)) { + SetGLErrorInvalidEnum(""glTexImage2D"", type, ""type""); + return error::kNoError; + } + if (format != internal_format) { + SetGLError(GL_INVALID_OPERATION, + ""glTexImage2D"", ""format != internalFormat""); + return error::kNoError; + } + if (!ValidateTextureParameters(""glTexImage2D"", target, format, type, level)) { + return error::kNoError; + } + if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || + border != 0) { + SetGLError(GL_INVALID_VALUE, ""glTexImage2D"", ""dimensions out of range""); + return error::kNoError; + } + if ((GLES2Util::GetChannelsForFormat(format) & + (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && pixels) { + SetGLError( + GL_INVALID_OPERATION, + ""glTexImage2D"", ""can not supply data for depth or stencil textures""); + return error::kNoError; + } + TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); + if (!info) { + SetGLError(GL_INVALID_OPERATION, + ""glTexImage2D"", ""unknown texture for target""); + return error::kNoError; + } + + if (info->IsImmutable()) { + SetGLError(GL_INVALID_OPERATION, + ""glTexImage2D"", ""texture is immutable""); + return error::kNoError; + } + + GLsizei tex_width = 0; + GLsizei tex_height = 0; + GLenum tex_type = 0; + GLenum tex_format = 0; + bool level_is_same = + info->GetLevelSize(target, level, &tex_width, &tex_height) && + info->GetLevelType(target, level, &tex_type, &tex_format) && + width == tex_width && height == tex_height && + type == tex_type && format == tex_format; + + if (level_is_same && !pixels) { + texture_manager()->SetLevelInfo( + info, + target, level, internal_format, width, height, 1, border, format, type, + false); + tex_image_2d_failed_ = false; + return error::kNoError; + } + + if (info->IsAttachedToFramebuffer()) { + state_dirty_ = true; + framebuffer_manager()->IncFramebufferStateChangeCount(); + } + + if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) { + glTexSubImage2D(target, level, 0, 0, width, height, format, type, pixels); + texture_manager()->SetLevelCleared(info, target, level); + tex_image_2d_failed_ = false; + return error::kNoError; + } + + CopyRealGLErrorsToWrapper(); + WrappedTexImage2D( + target, level, internal_format, width, height, border, format, type, + pixels); + GLenum error = PeekGLError(); + if (error == GL_NO_ERROR) { + texture_manager()->SetLevelInfo( + info, + target, level, internal_format, width, height, 1, border, format, type, + pixels != NULL); + tex_image_2d_failed_ = false; + } + return error::kNoError; +} +",0,"error::Error GLES2DecoderImpl::DoTexImage2D( + GLenum target, + GLint level, + GLenum internal_format, + GLsizei width, + GLsizei height, + GLint border, + GLenum format, + GLenum type, + const void* pixels, + uint32 pixels_size) { + if (!validators_->texture_target.IsValid(target)) { + SetGLErrorInvalidEnum(""glTexImage2D"", target, ""target""); + return error::kNoError; + } + if (!validators_->texture_format.IsValid(internal_format)) { + SetGLErrorInvalidEnum(""glTexImage2D"", internal_format, ""internal_format""); + return error::kNoError; + } + if (!validators_->texture_format.IsValid(format)) { + SetGLErrorInvalidEnum(""glTexImage2D"", format, ""format""); + return error::kNoError; + } + if (!validators_->pixel_type.IsValid(type)) { + SetGLErrorInvalidEnum(""glTexImage2D"", type, ""type""); + return error::kNoError; + } + if (format != internal_format) { + SetGLError(GL_INVALID_OPERATION, + ""glTexImage2D"", ""format != internalFormat""); + return error::kNoError; + } + if (!ValidateTextureParameters(""glTexImage2D"", target, format, type, level)) { + return error::kNoError; + } + if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || + border != 0) { + SetGLError(GL_INVALID_VALUE, ""glTexImage2D"", ""dimensions out of range""); + return error::kNoError; + } + if ((GLES2Util::GetChannelsForFormat(format) & + (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && pixels) { + SetGLError( + GL_INVALID_OPERATION, + ""glTexImage2D"", ""can not supply data for depth or stencil textures""); + return error::kNoError; + } + TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); + if (!info) { + SetGLError(GL_INVALID_OPERATION, + ""glTexImage2D"", ""unknown texture for target""); + return error::kNoError; + } + + if (info->IsImmutable()) { + SetGLError(GL_INVALID_OPERATION, + ""glTexImage2D"", ""texture is immutable""); + return error::kNoError; + } + + GLsizei tex_width = 0; + GLsizei tex_height = 0; + GLenum tex_type = 0; + GLenum tex_format = 0; + bool level_is_same = + info->GetLevelSize(target, level, &tex_width, &tex_height) && + info->GetLevelType(target, level, &tex_type, &tex_format) && + width == tex_width && height == tex_height && + type == tex_type && format == tex_format; + + if (level_is_same && !pixels) { + texture_manager()->SetLevelInfo( + info, + target, level, internal_format, width, height, 1, border, format, type, + false); + tex_image_2d_failed_ = false; + return error::kNoError; + } + + if (info->IsAttachedToFramebuffer()) { + state_dirty_ = true; + framebuffer_manager()->IncFramebufferStateChangeCount(); + } + + if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) { + glTexSubImage2D(target, level, 0, 0, width, height, format, type, pixels); + texture_manager()->SetLevelCleared(info, target, level); + tex_image_2d_failed_ = false; + return error::kNoError; + } + + CopyRealGLErrorsToWrapper(); + WrappedTexImage2D( + target, level, internal_format, width, height, border, format, type, + pixels); + GLenum error = PeekGLError(); + if (error == GL_NO_ERROR) { + texture_manager()->SetLevelInfo( + info, + target, level, internal_format, width, height, 1, border, format, type, + pixels != NULL); + tex_image_2d_failed_ = false; + } + return error::kNoError; +} +","@@ -5435,11 +5435,10 @@ bool GLES2DecoderImpl::SimulateAttrib0( + typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; + + GLuint num_vertices = max_vertex_accessed + 1; +- GLuint size_needed = 0; ++ uint32 size_needed = 0; + + if (num_vertices == 0 || +- !SafeMultiply(num_vertices, static_cast(sizeof(Vec4)), +- &size_needed) || ++ !SafeMultiplyUint32(num_vertices, sizeof(Vec4), &size_needed) || + size_needed > 0x7FFFFFFFU) { + SetGLError(GL_OUT_OF_MEMORY, function_name, ""Simulating attrib 0""); + return false; +@@ -5549,20 +5548,19 @@ bool GLES2DecoderImpl::SimulateFixedAttribs( + if (attrib_info && + info->CanAccess(max_accessed) && + info->type() == GL_FIXED) { +- GLuint elements_used = 0; +- if (!SafeMultiply(num_vertices, +- static_cast(info->size()), &elements_used) || +- !SafeAdd(elements_needed, elements_used, &elements_needed)) { ++ uint32 elements_used = 0; ++ if (!SafeMultiplyUint32(num_vertices, info->size(), &elements_used) || ++ !SafeAddUint32(elements_needed, elements_used, &elements_needed)) { + SetGLError( + GL_OUT_OF_MEMORY, function_name, ""simulating GL_FIXED attribs""); + return false; + } + } + } + +- const GLuint kSizeOfFloat = sizeof(float); // NOLINT +- GLuint size_needed = 0; +- if (!SafeMultiply(elements_needed, kSizeOfFloat, &size_needed) || ++ const uint32 kSizeOfFloat = sizeof(float); // NOLINT ++ uint32 size_needed = 0; ++ if (!SafeMultiplyUint32(elements_needed, kSizeOfFloat, &size_needed) || + size_needed > 0x7FFFFFFFU) { + SetGLError(GL_OUT_OF_MEMORY, function_name, ""simulating GL_FIXED attribs""); + return false; +@@ -6481,9 +6479,9 @@ error::Error GLES2DecoderImpl::HandleReadPixels( + // Get the size of the current fbo or backbuffer. + gfx::Size max_size = GetBoundReadFrameBufferSize(); + +- GLint max_x; +- GLint max_y; +- if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { ++ int32 max_x; ++ int32 max_y; ++ if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { + SetGLError(GL_INVALID_VALUE, ""glReadPixels"", ""dimensions out of range""); + return error::kNoError; + } +@@ -8536,7 +8534,7 @@ error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( + } + // Num will never be more than 4. + DCHECK_LE(num, 4u); +- if (!SafeAdd(num_results, num, &num_results)) { ++ if (!SafeAddUint32(num_results, num, &num_results)) { + return error::kOutOfBounds; + } + }",907,1143,2048 +17225,"static void onRttResults(wifi_request_id id, unsigned num_results, wifi_rtt_result* results[]) { + + JNIHelper helper(mVM); + + ALOGD(""onRttResults called, vm = %p, obj = %p"", mVM, mCls); + + JNIObject rttResults = helper.newObjectArray( + num_results, ""android/net/wifi/RttManager$RttResult"", NULL); + if (rttResults == NULL) { + ALOGE(""Error in allocating array""); + return; + } + + for (unsigned i = 0; i < num_results; i++) { + + wifi_rtt_result *result = results[i]; + + JNIObject rttResult = helper.createObject(""android/net/wifi/RttManager$RttResult""); + if (rttResult == NULL) { + ALOGE(""Error in creating rtt result""); + return; + } + + char bssid[32]; + sprintf(bssid, ""%02x:%02x:%02x:%02x:%02x:%02x"", result->addr[0], result->addr[1], + result->addr[2], result->addr[3], result->addr[4], result->addr[5]); + + helper.setStringField(rttResult, ""bssid"", bssid); + helper.setIntField( rttResult, ""burstNumber"", result->burst_num); + helper.setIntField( rttResult, ""measurementFrameNumber"", result->measurement_number); + helper.setIntField( rttResult, ""successMeasurementFrameNumber"", result->success_number); + helper.setIntField(rttResult, ""frameNumberPerBurstPeer"", result->number_per_burst_peer); + helper.setIntField( rttResult, ""status"", result->status); + helper.setIntField( rttResult, ""measurementType"", result->type); + helper.setIntField(rttResult, ""retryAfterDuration"", result->retry_after_duration); + helper.setLongField(rttResult, ""ts"", result->ts); + helper.setIntField( rttResult, ""rssi"", result->rssi); + helper.setIntField( rttResult, ""rssiSpread"", result->rssi_spread); + helper.setIntField( rttResult, ""txRate"", result->tx_rate.bitrate); + helper.setIntField( rttResult, ""rxRate"", result->rx_rate.bitrate); + helper.setLongField(rttResult, ""rtt"", result->rtt); + helper.setLongField(rttResult, ""rttStandardDeviation"", result->rtt_sd); + helper.setIntField( rttResult, ""distance"", result->distance); + helper.setIntField( rttResult, ""distanceStandardDeviation"", result->distance_sd); + helper.setIntField( rttResult, ""distanceSpread"", result->distance_spread); + helper.setIntField( rttResult, ""burstDuration"", result->burst_duration); + helper.setIntField( rttResult, ""negotiatedBurstNum"", result->negotiated_burst_num); + + JNIObject LCI = helper.createObject( + ""android/net/wifi/RttManager$WifiInformationElement""); + if (result->LCI != NULL && result->LCI->len > 0) { + ALOGD(""Add LCI in result""); + helper.setByteField(LCI, ""id"", result->LCI->id); + JNIObject elements = helper.newByteArray(result->LCI->len); + jbyte *bytes = (jbyte *)&(result->LCI->data[0]); + helper.setByteArrayRegion(elements, 0, result->LCI->len, bytes); + helper.setObjectField(LCI, ""data"", ""[B"", elements); + } else { + ALOGD(""No LCI in result""); + helper.setByteField(LCI, ""id"", (byte)(0xff)); + } + helper.setObjectField(rttResult, ""LCI"", + ""Landroid/net/wifi/RttManager$WifiInformationElement;"", LCI); + + JNIObject LCR = helper.createObject( + ""android/net/wifi/RttManager$WifiInformationElement""); + if (result->LCR != NULL && result->LCR->len > 0) { + ALOGD(""Add LCR in result""); + helper.setByteField(LCR, ""id"", result->LCR->id); + JNIObject elements = helper.newByteArray(result->LCI->len); + jbyte *bytes = (jbyte *)&(result->LCR->data[0]); + helper.setByteArrayRegion(elements, 0, result->LCI->len, bytes); + helper.setObjectField(LCR, ""data"", ""[B"", elements); + } else { + ALOGD(""No LCR in result""); + helper.setByteField(LCR, ""id"", (byte)(0xff)); + } + helper.setObjectField(rttResult, ""LCR"", + ""Landroid/net/wifi/RttManager$WifiInformationElement;"", LCR); + + helper.setObjectArrayElement(rttResults, i, rttResult); + } + + helper.reportEvent(mCls, ""onRttResults"", ""(I[Landroid/net/wifi/RttManager$RttResult;)V"", + id, rttResults.get()); +} +",0,"static void onRttResults(wifi_request_id id, unsigned num_results, wifi_rtt_result* results[]) { + + JNIHelper helper(mVM); + + ALOGD(""onRttResults called, vm = %p, obj = %p"", mVM, mCls); + + JNIObject rttResults = helper.newObjectArray( + num_results, ""android/net/wifi/RttManager$RttResult"", NULL); + if (rttResults == NULL) { + ALOGE(""Error in allocating array""); + return; + } + + for (unsigned i = 0; i < num_results; i++) { + + wifi_rtt_result *result = results[i]; + + JNIObject rttResult = helper.createObject(""android/net/wifi/RttManager$RttResult""); + if (rttResult == NULL) { + ALOGE(""Error in creating rtt result""); + return; + } + + char bssid[32]; + sprintf(bssid, ""%02x:%02x:%02x:%02x:%02x:%02x"", result->addr[0], result->addr[1], + result->addr[2], result->addr[3], result->addr[4], result->addr[5]); + + helper.setStringField(rttResult, ""bssid"", bssid); + helper.setIntField( rttResult, ""burstNumber"", result->burst_num); + helper.setIntField( rttResult, ""measurementFrameNumber"", result->measurement_number); + helper.setIntField( rttResult, ""successMeasurementFrameNumber"", result->success_number); + helper.setIntField(rttResult, ""frameNumberPerBurstPeer"", result->number_per_burst_peer); + helper.setIntField( rttResult, ""status"", result->status); + helper.setIntField( rttResult, ""measurementType"", result->type); + helper.setIntField(rttResult, ""retryAfterDuration"", result->retry_after_duration); + helper.setLongField(rttResult, ""ts"", result->ts); + helper.setIntField( rttResult, ""rssi"", result->rssi); + helper.setIntField( rttResult, ""rssiSpread"", result->rssi_spread); + helper.setIntField( rttResult, ""txRate"", result->tx_rate.bitrate); + helper.setIntField( rttResult, ""rxRate"", result->rx_rate.bitrate); + helper.setLongField(rttResult, ""rtt"", result->rtt); + helper.setLongField(rttResult, ""rttStandardDeviation"", result->rtt_sd); + helper.setIntField( rttResult, ""distance"", result->distance); + helper.setIntField( rttResult, ""distanceStandardDeviation"", result->distance_sd); + helper.setIntField( rttResult, ""distanceSpread"", result->distance_spread); + helper.setIntField( rttResult, ""burstDuration"", result->burst_duration); + helper.setIntField( rttResult, ""negotiatedBurstNum"", result->negotiated_burst_num); + + JNIObject LCI = helper.createObject( + ""android/net/wifi/RttManager$WifiInformationElement""); + if (result->LCI != NULL && result->LCI->len > 0) { + ALOGD(""Add LCI in result""); + helper.setByteField(LCI, ""id"", result->LCI->id); + JNIObject elements = helper.newByteArray(result->LCI->len); + jbyte *bytes = (jbyte *)&(result->LCI->data[0]); + helper.setByteArrayRegion(elements, 0, result->LCI->len, bytes); + helper.setObjectField(LCI, ""data"", ""[B"", elements); + } else { + ALOGD(""No LCI in result""); + helper.setByteField(LCI, ""id"", (byte)(0xff)); + } + helper.setObjectField(rttResult, ""LCI"", + ""Landroid/net/wifi/RttManager$WifiInformationElement;"", LCI); + + JNIObject LCR = helper.createObject( + ""android/net/wifi/RttManager$WifiInformationElement""); + if (result->LCR != NULL && result->LCR->len > 0) { + ALOGD(""Add LCR in result""); + helper.setByteField(LCR, ""id"", result->LCR->id); + JNIObject elements = helper.newByteArray(result->LCI->len); + jbyte *bytes = (jbyte *)&(result->LCR->data[0]); + helper.setByteArrayRegion(elements, 0, result->LCI->len, bytes); + helper.setObjectField(LCR, ""data"", ""[B"", elements); + } else { + ALOGD(""No LCR in result""); + helper.setByteField(LCR, ""id"", (byte)(0xff)); + } + helper.setObjectField(rttResult, ""LCR"", + ""Landroid/net/wifi/RttManager$WifiInformationElement;"", LCR); + + helper.setObjectArrayElement(rttResults, i, rttResult); + } + + helper.reportEvent(mCls, ""onRttResults"", ""(I[Landroid/net/wifi/RttManager$RttResult;)V"", + id, rttResults.get()); +} +","@@ -697,15 +697,23 @@ + + } + + static byte parseHexByte(const char * &str) { ++ if (str[0] == '\0') { ++ ALOGE(""Passed an empty string""); ++ return 0; ++ } + byte b = parseHexChar(str[0]); +- if (str[1] == ':' || str[1] == '\0') { +- str += 2; +- return b; ++ if (str[1] == '\0' || str[1] == ':') { ++ str ++; + } else { + b = b << 4 | parseHexChar(str[1]); +- str += 3; +- return b; ++ str += 2; + } ++ ++ // Skip trailing delimiter if not at the end of the string. ++ if (str[0] != '\0') { ++ str++; ++ } ++ return b; + } + + static void parseMacAddress(const char *str, mac_addr addr) { +",1128,1364,2048 +3821,"static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, + struct vmcs12 *vmcs12) +{ + struct kvm_segment seg; + + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER) + vcpu->arch.efer = vmcs12->host_ia32_efer; + else if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE) + vcpu->arch.efer |= (EFER_LMA | EFER_LME); + else + vcpu->arch.efer &= ~(EFER_LMA | EFER_LME); + vmx_set_efer(vcpu, vcpu->arch.efer); + + kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->host_rsp); + kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->host_rip); + vmx_set_rflags(vcpu, X86_EFLAGS_FIXED); + /* + * Note that calling vmx_set_cr0 is important, even if cr0 hasn't + * actually changed, because it depends on the current state of + * fpu_active (which may have changed). + * Note that vmx_set_cr0 refers to efer set above. + */ + kvm_set_cr0(vcpu, vmcs12->host_cr0); + /* + * If we did fpu_activate()/fpu_deactivate() during L2's run, we need + * to apply the same changes to L1's vmcs. We just set cr0 correctly, + * but we also need to update cr0_guest_host_mask and exception_bitmap. + */ + update_exception_bitmap(vcpu); + vcpu->arch.cr0_guest_owned_bits = (vcpu->fpu_active ? X86_CR0_TS : 0); + vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits); + + /* + * Note that CR4_GUEST_HOST_MASK is already set in the original vmcs01 + * (KVM doesn't change it)- no reason to call set_cr4_guest_host_mask(); + */ + vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK); + kvm_set_cr4(vcpu, vmcs12->host_cr4); + + if (nested_cpu_has_ept(vmcs12)) + nested_ept_uninit_mmu_context(vcpu); + + kvm_set_cr3(vcpu, vmcs12->host_cr3); + kvm_mmu_reset_context(vcpu); + + if (enable_vpid) { + /* + * Trivially support vpid by letting L2s share their parent + * L1's vpid. TODO: move to a more elaborate solution, giving + * each L2 its own vpid and exposing the vpid feature to L1. + */ + vmx_flush_tlb(vcpu); + } + + + vmcs_write32(GUEST_SYSENTER_CS, vmcs12->host_ia32_sysenter_cs); + vmcs_writel(GUEST_SYSENTER_ESP, vmcs12->host_ia32_sysenter_esp); + vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->host_ia32_sysenter_eip); + vmcs_writel(GUEST_IDTR_BASE, vmcs12->host_idtr_base); + vmcs_writel(GUEST_GDTR_BASE, vmcs12->host_gdtr_base); + + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PAT) + vmcs_write64(GUEST_IA32_PAT, vmcs12->host_ia32_pat); + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL) + vmcs_write64(GUEST_IA32_PERF_GLOBAL_CTRL, + vmcs12->host_ia32_perf_global_ctrl); + + /* Set L1 segment info according to Intel SDM + 27.5.2 Loading Host Segment and Descriptor-Table Registers */ + seg = (struct kvm_segment) { + .base = 0, + .limit = 0xFFFFFFFF, + .selector = vmcs12->host_cs_selector, + .type = 11, + .present = 1, + .s = 1, + .g = 1 + }; + if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE) + seg.l = 1; + else + seg.db = 1; + vmx_set_segment(vcpu, &seg, VCPU_SREG_CS); + seg = (struct kvm_segment) { + .base = 0, + .limit = 0xFFFFFFFF, + .type = 3, + .present = 1, + .s = 1, + .db = 1, + .g = 1 + }; + seg.selector = vmcs12->host_ds_selector; + vmx_set_segment(vcpu, &seg, VCPU_SREG_DS); + seg.selector = vmcs12->host_es_selector; + vmx_set_segment(vcpu, &seg, VCPU_SREG_ES); + seg.selector = vmcs12->host_ss_selector; + vmx_set_segment(vcpu, &seg, VCPU_SREG_SS); + seg.selector = vmcs12->host_fs_selector; + seg.base = vmcs12->host_fs_base; + vmx_set_segment(vcpu, &seg, VCPU_SREG_FS); + seg.selector = vmcs12->host_gs_selector; + seg.base = vmcs12->host_gs_base; + vmx_set_segment(vcpu, &seg, VCPU_SREG_GS); + seg = (struct kvm_segment) { + .base = vmcs12->host_tr_base, + .limit = 0x67, + .selector = vmcs12->host_tr_selector, + .type = 11, + .present = 1 + }; + vmx_set_segment(vcpu, &seg, VCPU_SREG_TR); + + kvm_set_dr(vcpu, 7, 0x400); + vmcs_write64(GUEST_IA32_DEBUGCTL, 0); +} +",0,"static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, + struct vmcs12 *vmcs12) +{ + struct kvm_segment seg; + + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER) + vcpu->arch.efer = vmcs12->host_ia32_efer; + else if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE) + vcpu->arch.efer |= (EFER_LMA | EFER_LME); + else + vcpu->arch.efer &= ~(EFER_LMA | EFER_LME); + vmx_set_efer(vcpu, vcpu->arch.efer); + + kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->host_rsp); + kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->host_rip); + vmx_set_rflags(vcpu, X86_EFLAGS_FIXED); + /* + * Note that calling vmx_set_cr0 is important, even if cr0 hasn't + * actually changed, because it depends on the current state of + * fpu_active (which may have changed). + * Note that vmx_set_cr0 refers to efer set above. + */ + kvm_set_cr0(vcpu, vmcs12->host_cr0); + /* + * If we did fpu_activate()/fpu_deactivate() during L2's run, we need + * to apply the same changes to L1's vmcs. We just set cr0 correctly, + * but we also need to update cr0_guest_host_mask and exception_bitmap. + */ + update_exception_bitmap(vcpu); + vcpu->arch.cr0_guest_owned_bits = (vcpu->fpu_active ? X86_CR0_TS : 0); + vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits); + + /* + * Note that CR4_GUEST_HOST_MASK is already set in the original vmcs01 + * (KVM doesn't change it)- no reason to call set_cr4_guest_host_mask(); + */ + vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK); + kvm_set_cr4(vcpu, vmcs12->host_cr4); + + if (nested_cpu_has_ept(vmcs12)) + nested_ept_uninit_mmu_context(vcpu); + + kvm_set_cr3(vcpu, vmcs12->host_cr3); + kvm_mmu_reset_context(vcpu); + + if (enable_vpid) { + /* + * Trivially support vpid by letting L2s share their parent + * L1's vpid. TODO: move to a more elaborate solution, giving + * each L2 its own vpid and exposing the vpid feature to L1. + */ + vmx_flush_tlb(vcpu); + } + + + vmcs_write32(GUEST_SYSENTER_CS, vmcs12->host_ia32_sysenter_cs); + vmcs_writel(GUEST_SYSENTER_ESP, vmcs12->host_ia32_sysenter_esp); + vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->host_ia32_sysenter_eip); + vmcs_writel(GUEST_IDTR_BASE, vmcs12->host_idtr_base); + vmcs_writel(GUEST_GDTR_BASE, vmcs12->host_gdtr_base); + + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PAT) + vmcs_write64(GUEST_IA32_PAT, vmcs12->host_ia32_pat); + if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL) + vmcs_write64(GUEST_IA32_PERF_GLOBAL_CTRL, + vmcs12->host_ia32_perf_global_ctrl); + + /* Set L1 segment info according to Intel SDM + 27.5.2 Loading Host Segment and Descriptor-Table Registers */ + seg = (struct kvm_segment) { + .base = 0, + .limit = 0xFFFFFFFF, + .selector = vmcs12->host_cs_selector, + .type = 11, + .present = 1, + .s = 1, + .g = 1 + }; + if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE) + seg.l = 1; + else + seg.db = 1; + vmx_set_segment(vcpu, &seg, VCPU_SREG_CS); + seg = (struct kvm_segment) { + .base = 0, + .limit = 0xFFFFFFFF, + .type = 3, + .present = 1, + .s = 1, + .db = 1, + .g = 1 + }; + seg.selector = vmcs12->host_ds_selector; + vmx_set_segment(vcpu, &seg, VCPU_SREG_DS); + seg.selector = vmcs12->host_es_selector; + vmx_set_segment(vcpu, &seg, VCPU_SREG_ES); + seg.selector = vmcs12->host_ss_selector; + vmx_set_segment(vcpu, &seg, VCPU_SREG_SS); + seg.selector = vmcs12->host_fs_selector; + seg.base = vmcs12->host_fs_base; + vmx_set_segment(vcpu, &seg, VCPU_SREG_FS); + seg.selector = vmcs12->host_gs_selector; + seg.base = vmcs12->host_gs_base; + vmx_set_segment(vcpu, &seg, VCPU_SREG_GS); + seg = (struct kvm_segment) { + .base = vmcs12->host_tr_base, + .limit = 0x67, + .selector = vmcs12->host_tr_selector, + .type = 11, + .present = 1 + }; + vmx_set_segment(vcpu, &seg, VCPU_SREG_TR); + + kvm_set_dr(vcpu, 7, 0x400); + vmcs_write64(GUEST_IA32_DEBUGCTL, 0); +} +","@@ -712,6 +712,7 @@ static void nested_release_page_clean(struct page *page) + kvm_release_page_clean(page); + } + ++static unsigned long nested_ept_get_cr3(struct kvm_vcpu *vcpu); + static u64 construct_eptp(unsigned long root_hpa); + static void kvm_cpu_vmxon(u64 addr); + static void kvm_cpu_vmxoff(void); +@@ -2161,6 +2162,7 @@ static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high; + static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high; + static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high; + static u32 nested_vmx_misc_low, nested_vmx_misc_high; ++static u32 nested_vmx_ept_caps; + static __init void nested_vmx_setup_ctls_msrs(void) + { + /* +@@ -6279,6 +6281,74 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu) + return 1; + } + ++/* Emulate the INVEPT instruction */ ++static int handle_invept(struct kvm_vcpu *vcpu) ++{ ++ u32 vmx_instruction_info, types; ++ unsigned long type; ++ gva_t gva; ++ struct x86_exception e; ++ struct { ++ u64 eptp, gpa; ++ } operand; ++ u64 eptp_mask = ((1ull << 51) - 1) & PAGE_MASK; ++ ++ if (!(nested_vmx_secondary_ctls_high & SECONDARY_EXEC_ENABLE_EPT) || ++ !(nested_vmx_ept_caps & VMX_EPT_INVEPT_BIT)) { ++ kvm_queue_exception(vcpu, UD_VECTOR); ++ return 1; ++ } ++ ++ if (!nested_vmx_check_permission(vcpu)) ++ return 1; ++ ++ if (!kvm_read_cr0_bits(vcpu, X86_CR0_PE)) { ++ kvm_queue_exception(vcpu, UD_VECTOR); ++ return 1; ++ } ++ ++ vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); ++ type = kvm_register_read(vcpu, (vmx_instruction_info >> 28) & 0xf); ++ ++ types = (nested_vmx_ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6; ++ ++ if (!(types & (1UL << type))) { ++ nested_vmx_failValid(vcpu, ++ VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); ++ return 1; ++ } ++ ++ /* According to the Intel VMX instruction reference, the memory ++ * operand is read even if it isn't needed (e.g., for type==global) ++ */ ++ if (get_vmx_mem_address(vcpu, vmcs_readl(EXIT_QUALIFICATION), ++ vmx_instruction_info, &gva)) ++ return 1; ++ if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &operand, ++ sizeof(operand), &e)) { ++ kvm_inject_page_fault(vcpu, &e); ++ return 1; ++ } ++ ++ switch (type) { ++ case VMX_EPT_EXTENT_CONTEXT: ++ if ((operand.eptp & eptp_mask) != ++ (nested_ept_get_cr3(vcpu) & eptp_mask)) ++ break; ++ case VMX_EPT_EXTENT_GLOBAL: ++ kvm_mmu_sync_roots(vcpu); ++ kvm_mmu_flush_tlb(vcpu); ++ nested_vmx_succeed(vcpu); ++ break; ++ default: ++ BUG_ON(1); ++ break; ++ } ++ ++ skip_emulated_instruction(vcpu); ++ return 1; ++} ++ + /* + * The exit handlers return 1 if the exit was handled fully and guest execution + * may resume. Otherwise they set the kvm_run parameter to indicate what needs +@@ -6323,6 +6393,7 @@ static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { + [EXIT_REASON_PAUSE_INSTRUCTION] = handle_pause, + [EXIT_REASON_MWAIT_INSTRUCTION] = handle_invalid_op, + [EXIT_REASON_MONITOR_INSTRUCTION] = handle_invalid_op, ++ [EXIT_REASON_INVEPT] = handle_invept, + }; + + static const int kvm_vmx_max_exit_handlers = +@@ -6549,6 +6620,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) + case EXIT_REASON_VMPTRST: case EXIT_REASON_VMREAD: + case EXIT_REASON_VMRESUME: case EXIT_REASON_VMWRITE: + case EXIT_REASON_VMOFF: case EXIT_REASON_VMON: ++ case EXIT_REASON_INVEPT: + /* + * VMX instructions trap unconditionally. This allows L1 to + * emulate them for its L2 guest, i.e., allows 3-level nesting!",1342,1578,2048 +5936,"int main(int argc, char **argv) +{ + darray(struct tcmulib_handler) handlers = darray_new(); + struct tcmulib_context *tcmulib_context; + struct tcmur_handler **tmp_r_handler; + GMainLoop *loop; + GIOChannel *libtcmu_gio; + guint reg_id; + int ret; + + tcmu_cfg = tcmu_config_new(); + if (!tcmu_cfg) + exit(1); + ret = tcmu_load_config(tcmu_cfg, NULL); + if (ret == -1) + goto err_out; + + while (1) { + int option_index = 0; + int c; + + c = getopt_long(argc, argv, ""dhlV"", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 0: + if (option_index == 1) + handler_path = strdup(optarg); + break; + case 'l': + if (strlen(optarg) > PATH_MAX - TCMU_LOG_FILENAME_MAX) { + tcmu_err(""--tcmu-log-dir='%s' cannot exceed %d characters\n"", + optarg, PATH_MAX - TCMU_LOG_FILENAME_MAX); + } + if (!tcmu_logdir_create(optarg)) { + goto err_out; + } + tcmu_log_dir = strdup(optarg); + break; + case 'd': + tcmu_set_log_level(TCMU_CONF_LOG_DEBUG_SCSI_CMD); + break; + case 'V': + printf(""tcmu-runner %s\n"", TCMUR_VERSION); + goto err_out; + default: + case 'h': + usage(); + goto err_out; + } + } + + tcmu_dbg(""handler path: %s\n"", handler_path); + + ret = load_our_module(); + if (ret < 0) { + tcmu_err(""couldn't load module\n""); + goto err_out; + } + + ret = open_handlers(); + if (ret < 0) { + tcmu_err(""couldn't open handlers\n""); + goto err_out; + } + tcmu_dbg(""%d runner handlers found\n"", ret); + + /* + * Convert from tcmu-runner's handler struct to libtcmu's + * handler struct, an array of which we pass in, below. + */ + darray_foreach(tmp_r_handler, g_runner_handlers) { + struct tcmulib_handler tmp_handler; + + tmp_handler.name = (*tmp_r_handler)->name; + tmp_handler.subtype = (*tmp_r_handler)->subtype; + tmp_handler.cfg_desc = (*tmp_r_handler)->cfg_desc; + tmp_handler.check_config = (*tmp_r_handler)->check_config; + tmp_handler.reconfig = (*tmp_r_handler)->reconfig; + tmp_handler.added = dev_added; + tmp_handler.removed = dev_removed; + + /* + * Can hand out a ref to an internal pointer to the + * darray b/c handlers will never be added or removed + * once open_handlers() is done. + */ + tmp_handler.hm_private = *tmp_r_handler; + + darray_append(handlers, tmp_handler); + } + + tcmulib_context = tcmulib_initialize(handlers.item, handlers.size); + if (!tcmulib_context) { + tcmu_err(""tcmulib_initialize failed\n""); + goto err_out; + } + + loop = g_main_loop_new(NULL, FALSE); + if (g_unix_signal_add(SIGINT, sighandler, loop) <= 0 || + g_unix_signal_add(SIGTERM, sighandler, loop) <= 0) { + tcmu_err(""couldn't setup signal handlers\n""); + goto err_tcmulib_close; + } + + /* Set up event for libtcmu */ + libtcmu_gio = g_io_channel_unix_new(tcmulib_get_master_fd(tcmulib_context)); + g_io_add_watch(libtcmu_gio, G_IO_IN, tcmulib_callback, tcmulib_context); + + /* Set up DBus name, see callback */ + reg_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, + ""org.kernel.TCMUService1"", + G_BUS_NAME_OWNER_FLAGS_NONE, + dbus_bus_acquired, + dbus_name_acquired, // name acquired + dbus_name_lost, // name lost + NULL, // user data + NULL // user date free func + ); + + g_main_loop_run(loop); + + tcmu_dbg(""Exiting...\n""); + g_bus_unown_name(reg_id); + g_main_loop_unref(loop); + tcmulib_close(tcmulib_context); + tcmu_config_destroy(tcmu_cfg); + + return 0; + +err_tcmulib_close: + tcmulib_close(tcmulib_context); +err_out: + tcmu_config_destroy(tcmu_cfg); + exit(1); +} +",0,"int main(int argc, char **argv) +{ + darray(struct tcmulib_handler) handlers = darray_new(); + struct tcmulib_context *tcmulib_context; + struct tcmur_handler **tmp_r_handler; + GMainLoop *loop; + GIOChannel *libtcmu_gio; + guint reg_id; + int ret; + + tcmu_cfg = tcmu_config_new(); + if (!tcmu_cfg) + exit(1); + ret = tcmu_load_config(tcmu_cfg, NULL); + if (ret == -1) + goto err_out; + + while (1) { + int option_index = 0; + int c; + + c = getopt_long(argc, argv, ""dhlV"", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 0: + if (option_index == 1) + handler_path = strdup(optarg); + break; + case 'l': + if (strlen(optarg) > PATH_MAX - TCMU_LOG_FILENAME_MAX) { + tcmu_err(""--tcmu-log-dir='%s' cannot exceed %d characters\n"", + optarg, PATH_MAX - TCMU_LOG_FILENAME_MAX); + } + if (!tcmu_logdir_create(optarg)) { + goto err_out; + } + tcmu_log_dir = strdup(optarg); + break; + case 'd': + tcmu_set_log_level(TCMU_CONF_LOG_DEBUG_SCSI_CMD); + break; + case 'V': + printf(""tcmu-runner %s\n"", TCMUR_VERSION); + goto err_out; + default: + case 'h': + usage(); + goto err_out; + } + } + + tcmu_dbg(""handler path: %s\n"", handler_path); + + ret = load_our_module(); + if (ret < 0) { + tcmu_err(""couldn't load module\n""); + goto err_out; + } + + ret = open_handlers(); + if (ret < 0) { + tcmu_err(""couldn't open handlers\n""); + goto err_out; + } + tcmu_dbg(""%d runner handlers found\n"", ret); + + /* + * Convert from tcmu-runner's handler struct to libtcmu's + * handler struct, an array of which we pass in, below. + */ + darray_foreach(tmp_r_handler, g_runner_handlers) { + struct tcmulib_handler tmp_handler; + + tmp_handler.name = (*tmp_r_handler)->name; + tmp_handler.subtype = (*tmp_r_handler)->subtype; + tmp_handler.cfg_desc = (*tmp_r_handler)->cfg_desc; + tmp_handler.check_config = (*tmp_r_handler)->check_config; + tmp_handler.reconfig = (*tmp_r_handler)->reconfig; + tmp_handler.added = dev_added; + tmp_handler.removed = dev_removed; + + /* + * Can hand out a ref to an internal pointer to the + * darray b/c handlers will never be added or removed + * once open_handlers() is done. + */ + tmp_handler.hm_private = *tmp_r_handler; + + darray_append(handlers, tmp_handler); + } + + tcmulib_context = tcmulib_initialize(handlers.item, handlers.size); + if (!tcmulib_context) { + tcmu_err(""tcmulib_initialize failed\n""); + goto err_out; + } + + loop = g_main_loop_new(NULL, FALSE); + if (g_unix_signal_add(SIGINT, sighandler, loop) <= 0 || + g_unix_signal_add(SIGTERM, sighandler, loop) <= 0) { + tcmu_err(""couldn't setup signal handlers\n""); + goto err_tcmulib_close; + } + + /* Set up event for libtcmu */ + libtcmu_gio = g_io_channel_unix_new(tcmulib_get_master_fd(tcmulib_context)); + g_io_add_watch(libtcmu_gio, G_IO_IN, tcmulib_callback, tcmulib_context); + + /* Set up DBus name, see callback */ + reg_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, + ""org.kernel.TCMUService1"", + G_BUS_NAME_OWNER_FLAGS_NONE, + dbus_bus_acquired, + dbus_name_acquired, // name acquired + dbus_name_lost, // name lost + NULL, // user data + NULL // user date free func + ); + + g_main_loop_run(loop); + + tcmu_dbg(""Exiting...\n""); + g_bus_unown_name(reg_id); + g_main_loop_unref(loop); + tcmulib_close(tcmulib_context); + tcmu_config_destroy(tcmu_cfg); + + return 0; + +err_tcmulib_close: + tcmulib_close(tcmulib_context); +err_out: + tcmu_config_destroy(tcmu_cfg); + exit(1); +} +","@@ -386,7 +386,7 @@ on_unregister_handler(TCMUService1HandlerManager1 *interface, + gpointer user_data) + { + struct tcmur_handler *handler = find_handler_by_subtype(subtype); +- struct dbus_info *info = handler->opaque; ++ struct dbus_info *info = handler ? handler->opaque : NULL; + + if (!handler) { + g_dbus_method_invocation_return_value(invocation,",1032,1268,2048 +1686,"condor_net_remap_config( bool force_param ) +{ + char *str = NULL; + if( ! force_param && getenv(""NET_REMAP_ENABLE"") ) { + /* + this stuff is already set. unless the caller is forcing + us to call param() again (e.g. the master is trying to + re-bind() if the GCB broker is down and it's got a list + to try) we should return immediately and leave our + environment alone. this way, the master can choose what + GCB broker to use for itself and all its children, even + if there's a list and we're using $RANDOM_CHOICE(). + */ + return; + } + + /* + this method is only called if we're enabling a network remap + service. if we do, we always need to force condor to bind() + to all interfaces (INADDR_ANY). since we don't want to rely + on users to set this themselves to get GCB working, we'll + set it automatically. the only harm of setting this is that + we need Condor to automatically handle hostallow stuff for + ""localhost"", or users need to add localhost to their + hostallow settings as appropriate. we can't rely on the + later, and the former only works on some platforms. + luckily, the automatic localhost stuff works on all + platforms where GCB works (linux, and we hope, solaris), so + it's safe to turn this on whenever we're using GCB + */ + insert( ""BIND_ALL_INTERFACES"", ""TRUE"", ConfigTab, TABLESIZE ); + extra_info->AddInternalParam(""BIND_ALL_INTERFACES""); + + SetEnv( ""NET_REMAP_ENABLE"", ""true""); + str = param(""NET_REMAP_SERVICE""); + if (str) { + if (!strcasecmp(str, ""GCB"")) { + SetEnv( ""GCB_ENABLE"", ""true"" ); + free(str); + str = NULL; + if( (str = param(""NET_REMAP_INAGENT"")) ) { + const char *next_broker; + StringList all_brokers( str ); + StringList working_brokers; + + all_brokers.rewind(); + while ( (next_broker = all_brokers.next()) ) { + int rc = 0; + +#if HAVE_EXT_GCB + int num_slots = 0; /* only used w/HAVE_EXT_GCB */ + rc = GCB_broker_query( next_broker, + GCB_DATA_QUERY_FREE_SOCKS, + &num_slots ); +#endif + if ( rc == 0 ) { + working_brokers.append( next_broker ); + } + } + + if ( working_brokers.number() > 0 ) { + int rand_entry = (get_random_int() % working_brokers.number()) + 1; + int i = 0; + working_brokers.rewind(); + while ( (i < rand_entry) && + (next_broker=working_brokers.next()) ) { + i++; + } + + dprintf( D_FULLDEBUG,""Using GCB broker %s\n"",next_broker ); + SetEnv( ""GCB_INAGENT"", next_broker ); + } else { + dprintf( D_ALWAYS,""No usable GCB brokers were found. "" + ""Setting GCB_INAGENT=%s\n"", + CONDOR_GCB_INVALID_BROKER ); + SetEnv( ""GCB_INAGENT"", CONDOR_GCB_INVALID_BROKER ); + } + free( str ); + str = NULL; + } + if( (str = param(""NET_REMAP_ROUTE"")) ) { + SetEnv( ""GCB_ROUTE"", str ); + free( str ); + str = NULL; + } + } else if (!strcasecmp(str, ""DPF"")) { + SetEnv( ""DPF_ENABLE"", ""true"" ); + free(str); + str = NULL; + if( (str = param(""NET_REMAP_INAGENT"")) ) { + SetEnv( ""DPF_INAGENT"", str ); + free(str); + str = NULL; + } + if( (str = param(""NET_REMAP_ROUTE"")) ) { + SetEnv( ""DPF_ROUTE"", str ); + free(str); + str = NULL; + } + } + } +} +",0,"condor_net_remap_config( bool force_param ) +{ + char *str = NULL; + if( ! force_param && getenv(""NET_REMAP_ENABLE"") ) { + /* + this stuff is already set. unless the caller is forcing + us to call param() again (e.g. the master is trying to + re-bind() if the GCB broker is down and it's got a list + to try) we should return immediately and leave our + environment alone. this way, the master can choose what + GCB broker to use for itself and all its children, even + if there's a list and we're using $RANDOM_CHOICE(). + */ + return; + } + + /* + this method is only called if we're enabling a network remap + service. if we do, we always need to force condor to bind() + to all interfaces (INADDR_ANY). since we don't want to rely + on users to set this themselves to get GCB working, we'll + set it automatically. the only harm of setting this is that + we need Condor to automatically handle hostallow stuff for + ""localhost"", or users need to add localhost to their + hostallow settings as appropriate. we can't rely on the + later, and the former only works on some platforms. + luckily, the automatic localhost stuff works on all + platforms where GCB works (linux, and we hope, solaris), so + it's safe to turn this on whenever we're using GCB + */ + insert( ""BIND_ALL_INTERFACES"", ""TRUE"", ConfigTab, TABLESIZE ); + extra_info->AddInternalParam(""BIND_ALL_INTERFACES""); + + SetEnv( ""NET_REMAP_ENABLE"", ""true""); + str = param(""NET_REMAP_SERVICE""); + if (str) { + if (!strcasecmp(str, ""GCB"")) { + SetEnv( ""GCB_ENABLE"", ""true"" ); + free(str); + str = NULL; + if( (str = param(""NET_REMAP_INAGENT"")) ) { + const char *next_broker; + StringList all_brokers( str ); + StringList working_brokers; + + all_brokers.rewind(); + while ( (next_broker = all_brokers.next()) ) { + int rc = 0; + +#if HAVE_EXT_GCB + int num_slots = 0; /* only used w/HAVE_EXT_GCB */ + rc = GCB_broker_query( next_broker, + GCB_DATA_QUERY_FREE_SOCKS, + &num_slots ); +#endif + if ( rc == 0 ) { + working_brokers.append( next_broker ); + } + } + + if ( working_brokers.number() > 0 ) { + int rand_entry = (get_random_int() % working_brokers.number()) + 1; + int i = 0; + working_brokers.rewind(); + while ( (i < rand_entry) && + (next_broker=working_brokers.next()) ) { + i++; + } + + dprintf( D_FULLDEBUG,""Using GCB broker %s\n"",next_broker ); + SetEnv( ""GCB_INAGENT"", next_broker ); + } else { + dprintf( D_ALWAYS,""No usable GCB brokers were found. "" + ""Setting GCB_INAGENT=%s\n"", + CONDOR_GCB_INVALID_BROKER ); + SetEnv( ""GCB_INAGENT"", CONDOR_GCB_INVALID_BROKER ); + } + free( str ); + str = NULL; + } + if( (str = param(""NET_REMAP_ROUTE"")) ) { + SetEnv( ""GCB_ROUTE"", str ); + free( str ); + str = NULL; + } + } else if (!strcasecmp(str, ""DPF"")) { + SetEnv( ""DPF_ENABLE"", ""true"" ); + free(str); + str = NULL; + if( (str = param(""NET_REMAP_INAGENT"")) ) { + SetEnv( ""DPF_INAGENT"", str ); + free(str); + str = NULL; + } + if( (str = param(""NET_REMAP_ROUTE"")) ) { + SetEnv( ""DPF_ROUTE"", str ); + free(str); + str = NULL; + } + } + } +} +","@@ -240,7 +240,7 @@ validate_entries( bool ignore_invalid_entry ) { + if(ignore_invalid_entry) { + dprintf(D_ALWAYS, ""%s"", output.Value()); + } else { +- EXCEPT(output.Value()); ++ EXCEPT(""%s"", output.Value()); + } + } + }",934,1170,2048 +18328,"void CL_InitRef( void ) { + refimport_t ri; + refexport_t *ret; +#ifdef USE_RENDERER_DLOPEN + GetRefAPI_t GetRefAPI; + char dllName[MAX_OSPATH]; +#endif + + Com_Printf( ""----- Initializing Renderer ----\n"" ); + + #ifdef USE_RENDERER_DLOPEN + cl_renderer = Cvar_Get(""cl_renderer"", ""opengl1"", CVAR_ARCHIVE | CVAR_LATCH); + + Com_sprintf(dllName, sizeof(dllName), ""renderer_mp_%s_"" ARCH_STRING DLL_EXT, cl_renderer->string); + + if(!(rendererLib = Sys_LoadDll(dllName, qfalse)) && strcmp(cl_renderer->string, cl_renderer->resetString)) + { + Com_Printf(""failed:\n\""%s\""\n"", Sys_LibraryError()); + Cvar_ForceReset(""cl_renderer""); + + Com_sprintf(dllName, sizeof(dllName), ""renderer_mp_opengl1_"" ARCH_STRING DLL_EXT); + rendererLib = Sys_LoadDll(dllName, qfalse); + } + + if(!rendererLib) + { + Com_Printf(""failed:\n\""%s\""\n"", Sys_LibraryError()); + Com_Error(ERR_FATAL, ""Failed to load renderer""); + } + + GetRefAPI = Sys_LoadFunction(rendererLib, ""GetRefAPI""); + if(!GetRefAPI) + { + Com_Error(ERR_FATAL, ""Can't load symbol GetRefAPI: '%s'"", Sys_LibraryError()); + } +#endif + + ri.Cmd_AddCommand = Cmd_AddCommand; + ri.Cmd_RemoveCommand = Cmd_RemoveCommand; + ri.Cmd_Argc = Cmd_Argc; + ri.Cmd_Argv = Cmd_Argv; + ri.Cmd_ExecuteText = Cbuf_ExecuteText; + ri.Printf = CL_RefPrintf; + ri.Error = Com_Error; + ri.Milliseconds = CL_ScaledMilliseconds; +#ifdef ZONE_DEBUG + ri.Z_MallocDebug = CL_RefMallocDebug; +#else + ri.Z_Malloc = CL_RefMalloc; +#endif + ri.Free = Z_Free; + ri.Tag_Free = CL_RefTagFree; + ri.Hunk_Clear = Hunk_ClearToMark; +#ifdef HUNK_DEBUG + ri.Hunk_AllocDebug = Hunk_AllocDebug; +#else + ri.Hunk_Alloc = Hunk_Alloc; +#endif + ri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory; + ri.Hunk_FreeTempMemory = Hunk_FreeTempMemory; + + ri.CM_ClusterPVS = CM_ClusterPVS; + ri.CM_DrawDebugSurface = CM_DrawDebugSurface; + ri.FS_ReadFile = FS_ReadFile; + ri.FS_FreeFile = FS_FreeFile; + ri.FS_WriteFile = FS_WriteFile; + ri.FS_FreeFileList = FS_FreeFileList; + ri.FS_ListFiles = FS_ListFiles; + ri.FS_FileIsInPAK = FS_FileIsInPAK; + ri.FS_FileExists = FS_FileExists; + ri.Cvar_Get = Cvar_Get; + ri.Cvar_Set = Cvar_Set; + ri.Cvar_SetValue = Cvar_SetValue; + ri.Cvar_CheckRange = Cvar_CheckRange; + ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue; + + + ri.CIN_UploadCinematic = CIN_UploadCinematic; + ri.CIN_PlayCinematic = CIN_PlayCinematic; + ri.CIN_RunCinematic = CIN_RunCinematic; + + ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame; + + ri.IN_Init = IN_Init; + ri.IN_Shutdown = IN_Shutdown; + ri.IN_Restart = IN_Restart; + + ri.ftol = Q_ftol; + + ri.Sys_SetEnv = Sys_SetEnv; + ri.Sys_GLimpSafeInit = Sys_GLimpSafeInit; + ri.Sys_GLimpInit = Sys_GLimpInit; + ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory; + + ret = GetRefAPI( REF_API_VERSION, &ri ); + + if ( !ret ) { + Com_Error( ERR_FATAL, ""Couldn't initialize refresh"" ); + } + + re = *ret; + + Com_Printf( ""---- Renderer Initialization Complete ----\n"" ); + + Cvar_Set( ""cl_paused"", ""0"" ); +} +",1,"void CL_InitRef( void ) { + refimport_t ri; + refexport_t *ret; +#ifdef USE_RENDERER_DLOPEN + GetRefAPI_t GetRefAPI; + char dllName[MAX_OSPATH]; +#endif + + Com_Printf( ""----- Initializing Renderer ----\n"" ); + + #ifdef USE_RENDERER_DLOPEN + cl_renderer = Cvar_Get(""cl_renderer"", ""opengl1"", CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED); + + Com_sprintf(dllName, sizeof(dllName), ""renderer_mp_%s_"" ARCH_STRING DLL_EXT, cl_renderer->string); + + if(!(rendererLib = Sys_LoadDll(dllName, qfalse)) && strcmp(cl_renderer->string, cl_renderer->resetString)) + { + Com_Printf(""failed:\n\""%s\""\n"", Sys_LibraryError()); + Cvar_ForceReset(""cl_renderer""); + + Com_sprintf(dllName, sizeof(dllName), ""renderer_mp_opengl1_"" ARCH_STRING DLL_EXT); + rendererLib = Sys_LoadDll(dllName, qfalse); + } + + if(!rendererLib) + { + Com_Printf(""failed:\n\""%s\""\n"", Sys_LibraryError()); + Com_Error(ERR_FATAL, ""Failed to load renderer""); + } + + GetRefAPI = Sys_LoadFunction(rendererLib, ""GetRefAPI""); + if(!GetRefAPI) + { + Com_Error(ERR_FATAL, ""Can't load symbol GetRefAPI: '%s'"", Sys_LibraryError()); + } +#endif + + ri.Cmd_AddCommand = Cmd_AddCommand; + ri.Cmd_RemoveCommand = Cmd_RemoveCommand; + ri.Cmd_Argc = Cmd_Argc; + ri.Cmd_Argv = Cmd_Argv; + ri.Cmd_ExecuteText = Cbuf_ExecuteText; + ri.Printf = CL_RefPrintf; + ri.Error = Com_Error; + ri.Milliseconds = CL_ScaledMilliseconds; +#ifdef ZONE_DEBUG + ri.Z_MallocDebug = CL_RefMallocDebug; +#else + ri.Z_Malloc = CL_RefMalloc; +#endif + ri.Free = Z_Free; + ri.Tag_Free = CL_RefTagFree; + ri.Hunk_Clear = Hunk_ClearToMark; +#ifdef HUNK_DEBUG + ri.Hunk_AllocDebug = Hunk_AllocDebug; +#else + ri.Hunk_Alloc = Hunk_Alloc; +#endif + ri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory; + ri.Hunk_FreeTempMemory = Hunk_FreeTempMemory; + + ri.CM_ClusterPVS = CM_ClusterPVS; + ri.CM_DrawDebugSurface = CM_DrawDebugSurface; + ri.FS_ReadFile = FS_ReadFile; + ri.FS_FreeFile = FS_FreeFile; + ri.FS_WriteFile = FS_WriteFile; + ri.FS_FreeFileList = FS_FreeFileList; + ri.FS_ListFiles = FS_ListFiles; + ri.FS_FileIsInPAK = FS_FileIsInPAK; + ri.FS_FileExists = FS_FileExists; + ri.Cvar_Get = Cvar_Get; + ri.Cvar_Set = Cvar_Set; + ri.Cvar_SetValue = Cvar_SetValue; + ri.Cvar_CheckRange = Cvar_CheckRange; + ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue; + + + ri.CIN_UploadCinematic = CIN_UploadCinematic; + ri.CIN_PlayCinematic = CIN_PlayCinematic; + ri.CIN_RunCinematic = CIN_RunCinematic; + + ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame; + + ri.IN_Init = IN_Init; + ri.IN_Shutdown = IN_Shutdown; + ri.IN_Restart = IN_Restart; + + ri.ftol = Q_ftol; + + ri.Sys_SetEnv = Sys_SetEnv; + ri.Sys_GLimpSafeInit = Sys_GLimpSafeInit; + ri.Sys_GLimpInit = Sys_GLimpInit; + ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory; + + ret = GetRefAPI( REF_API_VERSION, &ri ); + + if ( !ret ) { + Com_Error( ERR_FATAL, ""Couldn't initialize refresh"" ); + } + + re = *ret; + + Com_Printf( ""---- Renderer Initialization Complete ----\n"" ); + + Cvar_Set( ""cl_paused"", ""0"" ); +} +","@@ -3674,7 +3674,7 @@ void CL_InitRef( void ) { + Com_Printf( ""----- Initializing Renderer ----\n"" ); + + #ifdef USE_RENDERER_DLOPEN +- cl_renderer = Cvar_Get(""cl_renderer"", ""opengl1"", CVAR_ARCHIVE | CVAR_LATCH); ++ cl_renderer = Cvar_Get(""cl_renderer"", ""opengl1"", CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED); + + Com_sprintf(dllName, sizeof(dllName), ""renderer_mp_%s_"" ARCH_STRING DLL_EXT, cl_renderer->string); + +@@ -4014,7 +4014,7 @@ void CL_Init( void ) { + + cl_allowDownload = Cvar_Get( ""cl_allowDownload"", ""1"", CVAR_ARCHIVE ); + #ifdef USE_CURL_DLOPEN +- cl_cURLLib = Cvar_Get(""cl_cURLLib"", DEFAULT_CURL_LIB, CVAR_ARCHIVE); ++ cl_cURLLib = Cvar_Get(""cl_cURLLib"", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED); + #endif + + // init autoswitch so the ui will have it correctly even",917,1153,2048 +17522,"int start_input_stream(struct stream_in *in) +{ + /* Enable output device and stream routing controls */ + int ret = 0; + bool recreate_resampler = false; + struct audio_usecase *uc_info; + struct audio_device *adev = in->dev; + struct pcm_device_profile *pcm_profile; + struct pcm_device *pcm_device; + + ALOGV(""%s: enter: usecase(%d)"", __func__, in->usecase); + adev->active_input = in; + pcm_profile = get_pcm_device(in->usecase_type, in->devices); + if (pcm_profile == NULL) { + ALOGE(""%s: Could not find PCM device id for the usecase(%d)"", + __func__, in->usecase); + ret = -EINVAL; + goto error_config; + } + + if (in->input_flags & AUDIO_INPUT_FLAG_FAST) { + ALOGV(""%s: change capture period size to low latency size %d"", + __func__, CAPTURE_PERIOD_SIZE_LOW_LATENCY); + pcm_profile->config.period_size = CAPTURE_PERIOD_SIZE_LOW_LATENCY; + } + + uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase)); + uc_info->id = in->usecase; + uc_info->type = PCM_CAPTURE; + uc_info->stream = (struct audio_stream *)in; + uc_info->devices = in->devices; + uc_info->in_snd_device = SND_DEVICE_NONE; + uc_info->out_snd_device = SND_DEVICE_NONE; + + pcm_device = (struct pcm_device *)calloc(1, sizeof(struct pcm_device)); + pcm_device->pcm_profile = pcm_profile; + list_init(&in->pcm_dev_list); + list_add_tail(&in->pcm_dev_list, &pcm_device->stream_list_node); + + list_init(&uc_info->mixer_list); + list_add_tail(&uc_info->mixer_list, + &adev_get_mixer_for_card(adev, + pcm_device->pcm_profile->card)->uc_list_node[uc_info->id]); + + list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); + + select_devices(adev, in->usecase); + + /* Config should be updated as profile can be changed between different calls + * to this function: + * - Trigger resampler creation + * - Config needs to be updated */ + if (in->config.rate != pcm_profile->config.rate) { + recreate_resampler = true; + } + in->config = pcm_profile->config; + +#ifdef PREPROCESSING_ENABLED + if (in->aux_channels_changed) { + in->config.channels = audio_channel_count_from_in_mask(in->aux_channels); + recreate_resampler = true; + } +#endif + + if (in->requested_rate != in->config.rate) { + recreate_resampler = true; + } + + if (recreate_resampler) { + if (in->resampler) { + release_resampler(in->resampler); + in->resampler = NULL; + } + in->buf_provider.get_next_buffer = get_next_buffer; + in->buf_provider.release_buffer = release_buffer; + ret = create_resampler(in->config.rate, + in->requested_rate, + in->config.channels, + RESAMPLER_QUALITY_DEFAULT, + &in->buf_provider, + &in->resampler); + } + + /* Open the PCM device. + * The HW is limited to support only the default pcm_profile settings. + * As such a change in aux_channels will not have an effect. + */ + ALOGV(""%s: Opening PCM device card_id(%d) device_id(%d), channels %d, smp rate %d format %d, \ + period_size %d"", __func__, pcm_device->pcm_profile->card, pcm_device->pcm_profile->device, + pcm_device->pcm_profile->config.channels,pcm_device->pcm_profile->config.rate, + pcm_device->pcm_profile->config.format, pcm_device->pcm_profile->config.period_size); + + if (pcm_profile->type == PCM_HOTWORD_STREAMING) { + if (!adev->sound_trigger_open_for_streaming) { + ALOGE(""%s: No handle to sound trigger HAL"", __func__); + ret = -EIO; + goto error_open; + } + pcm_device->pcm = NULL; + pcm_device->sound_trigger_handle = + adev->sound_trigger_open_for_streaming(); + if (pcm_device->sound_trigger_handle <= 0) { + ALOGE(""%s: Failed to open DSP for streaming"", __func__); + ret = -EIO; + goto error_open; + } + ALOGV(""Opened DSP successfully""); + } else { + pcm_device->sound_trigger_handle = 0; + pcm_device->pcm = pcm_open(pcm_device->pcm_profile->card, + pcm_device->pcm_profile->device, + PCM_IN | PCM_MONOTONIC, + &pcm_device->pcm_profile->config); + if (pcm_device->pcm && !pcm_is_ready(pcm_device->pcm)) { + ALOGE(""%s: %s"", __func__, pcm_get_error(pcm_device->pcm)); + pcm_close(pcm_device->pcm); + pcm_device->pcm = NULL; + ret = -EIO; + goto error_open; + } + } + + /* force read and proc buffer reallocation in case of frame size or + * channel count change */ +#ifdef PREPROCESSING_ENABLED + in->proc_buf_frames = 0; +#endif + in->proc_buf_size = 0; + in->read_buf_size = 0; + in->read_buf_frames = 0; + + /* if no supported sample rate is available, use the resampler */ + if (in->resampler) { + in->resampler->reset(in->resampler); + } + + ALOGV(""%s: exit"", __func__); + return ret; + +error_open: + if (in->resampler) { + release_resampler(in->resampler); + in->resampler = NULL; + } + stop_input_stream(in); + +error_config: + ALOGV(""%s: exit: status(%d)"", __func__, ret); + adev->active_input = NULL; + return ret; +} +",0,"int start_input_stream(struct stream_in *in) +{ + /* Enable output device and stream routing controls */ + int ret = 0; + bool recreate_resampler = false; + struct audio_usecase *uc_info; + struct audio_device *adev = in->dev; + struct pcm_device_profile *pcm_profile; + struct pcm_device *pcm_device; + + ALOGV(""%s: enter: usecase(%d)"", __func__, in->usecase); + adev->active_input = in; + pcm_profile = get_pcm_device(in->usecase_type, in->devices); + if (pcm_profile == NULL) { + ALOGE(""%s: Could not find PCM device id for the usecase(%d)"", + __func__, in->usecase); + ret = -EINVAL; + goto error_config; + } + + if (in->input_flags & AUDIO_INPUT_FLAG_FAST) { + ALOGV(""%s: change capture period size to low latency size %d"", + __func__, CAPTURE_PERIOD_SIZE_LOW_LATENCY); + pcm_profile->config.period_size = CAPTURE_PERIOD_SIZE_LOW_LATENCY; + } + + uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase)); + uc_info->id = in->usecase; + uc_info->type = PCM_CAPTURE; + uc_info->stream = (struct audio_stream *)in; + uc_info->devices = in->devices; + uc_info->in_snd_device = SND_DEVICE_NONE; + uc_info->out_snd_device = SND_DEVICE_NONE; + + pcm_device = (struct pcm_device *)calloc(1, sizeof(struct pcm_device)); + pcm_device->pcm_profile = pcm_profile; + list_init(&in->pcm_dev_list); + list_add_tail(&in->pcm_dev_list, &pcm_device->stream_list_node); + + list_init(&uc_info->mixer_list); + list_add_tail(&uc_info->mixer_list, + &adev_get_mixer_for_card(adev, + pcm_device->pcm_profile->card)->uc_list_node[uc_info->id]); + + list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); + + select_devices(adev, in->usecase); + + /* Config should be updated as profile can be changed between different calls + * to this function: + * - Trigger resampler creation + * - Config needs to be updated */ + if (in->config.rate != pcm_profile->config.rate) { + recreate_resampler = true; + } + in->config = pcm_profile->config; + +#ifdef PREPROCESSING_ENABLED + if (in->aux_channels_changed) { + in->config.channels = audio_channel_count_from_in_mask(in->aux_channels); + recreate_resampler = true; + } +#endif + + if (in->requested_rate != in->config.rate) { + recreate_resampler = true; + } + + if (recreate_resampler) { + if (in->resampler) { + release_resampler(in->resampler); + in->resampler = NULL; + } + in->buf_provider.get_next_buffer = get_next_buffer; + in->buf_provider.release_buffer = release_buffer; + ret = create_resampler(in->config.rate, + in->requested_rate, + in->config.channels, + RESAMPLER_QUALITY_DEFAULT, + &in->buf_provider, + &in->resampler); + } + + /* Open the PCM device. + * The HW is limited to support only the default pcm_profile settings. + * As such a change in aux_channels will not have an effect. + */ + ALOGV(""%s: Opening PCM device card_id(%d) device_id(%d), channels %d, smp rate %d format %d, \ + period_size %d"", __func__, pcm_device->pcm_profile->card, pcm_device->pcm_profile->device, + pcm_device->pcm_profile->config.channels,pcm_device->pcm_profile->config.rate, + pcm_device->pcm_profile->config.format, pcm_device->pcm_profile->config.period_size); + + if (pcm_profile->type == PCM_HOTWORD_STREAMING) { + if (!adev->sound_trigger_open_for_streaming) { + ALOGE(""%s: No handle to sound trigger HAL"", __func__); + ret = -EIO; + goto error_open; + } + pcm_device->pcm = NULL; + pcm_device->sound_trigger_handle = + adev->sound_trigger_open_for_streaming(); + if (pcm_device->sound_trigger_handle <= 0) { + ALOGE(""%s: Failed to open DSP for streaming"", __func__); + ret = -EIO; + goto error_open; + } + ALOGV(""Opened DSP successfully""); + } else { + pcm_device->sound_trigger_handle = 0; + pcm_device->pcm = pcm_open(pcm_device->pcm_profile->card, + pcm_device->pcm_profile->device, + PCM_IN | PCM_MONOTONIC, + &pcm_device->pcm_profile->config); + if (pcm_device->pcm && !pcm_is_ready(pcm_device->pcm)) { + ALOGE(""%s: %s"", __func__, pcm_get_error(pcm_device->pcm)); + pcm_close(pcm_device->pcm); + pcm_device->pcm = NULL; + ret = -EIO; + goto error_open; + } + } + + /* force read and proc buffer reallocation in case of frame size or + * channel count change */ +#ifdef PREPROCESSING_ENABLED + in->proc_buf_frames = 0; +#endif + in->proc_buf_size = 0; + in->read_buf_size = 0; + in->read_buf_frames = 0; + + /* if no supported sample rate is available, use the resampler */ + if (in->resampler) { + in->resampler->reset(in->resampler); + } + + ALOGV(""%s: exit"", __func__); + return ret; + +error_open: + if (in->resampler) { + release_resampler(in->resampler); + in->resampler = NULL; + } + stop_input_stream(in); + +error_config: + ALOGV(""%s: exit: status(%d)"", __func__, ret); + adev->active_input = NULL; + return ret; +} +","@@ -1023,12 +1023,7 @@ + + ssize_t frames_wr = 0; /* Number of frames actually read */ + size_t bytes_per_sample = audio_bytes_per_sample(stream->common.get_format(&stream->common)); + void *proc_buf_out = buffer; +-#ifdef PREPROCESSING_ENABLED +- audio_buffer_t in_buf; +- audio_buffer_t out_buf; +- int i; +- bool has_processing = in->num_preprocessors != 0; +-#endif ++ + /* Additional channels might be added on top of main_channels: + * - aux_channels (by processing effects) + * - extra channels due to HW limitations +@@ -1037,7 +1032,34 @@ + + size_t src_channels = in->config.channels; + size_t dst_channels = audio_channel_count_from_in_mask(in->main_channels); + bool channel_remapping_needed = (dst_channels != src_channels); +- size_t src_buffer_size = frames_num * src_channels * bytes_per_sample; ++ const size_t src_frame_size = src_channels * bytes_per_sample; ++ ++#ifdef PREPROCESSING_ENABLED ++ const bool has_processing = in->num_preprocessors != 0; ++#else ++ const bool has_processing = false; ++#endif ++ ++ /* With additional channels or processing, we need intermediate buffers */ ++ if (channel_remapping_needed || has_processing) { ++ const size_t src_buffer_size = frames_num * src_frame_size; ++ ++ if (in->proc_buf_size < src_buffer_size) { ++ in->proc_buf_size = src_buffer_size; ++#ifdef PREPROCESSING_ENABLED ++ /* we always reallocate both buffers in case # of effects change dynamically. */ ++ in->proc_buf_in = realloc(in->proc_buf_in, src_buffer_size); ++ ALOG_ASSERT((in->proc_buf_in != NULL), ++ ""process_frames() failed to reallocate proc_buf_in""); ++#endif ++ in->proc_buf_out = realloc(in->proc_buf_out, src_buffer_size); ++ ALOG_ASSERT((in->proc_buf_out != NULL), ++ ""process_frames() failed to reallocate proc_buf_out""); ++ } ++ if (channel_remapping_needed) { ++ proc_buf_out = in->proc_buf_out; ++ } ++ } + + #ifdef PREPROCESSING_ENABLED + if (has_processing) { +@@ -1046,24 +1068,10 @@ + + while (frames_wr < frames_num) { + /* first reload enough frames at the end of process input buffer */ + if (in->proc_buf_frames < (size_t)frames_num) { +- ssize_t frames_rd; +- if (in->proc_buf_size < (size_t)frames_num) { +- in->proc_buf_size = (size_t)frames_num; +- in->proc_buf_in = realloc(in->proc_buf_in, src_buffer_size); +- ALOG_ASSERT((in->proc_buf_in != NULL), +- ""process_frames() failed to reallocate proc_buf_in""); +- if (channel_remapping_needed) { +- in->proc_buf_out = realloc(in->proc_buf_out, src_buffer_size); +- ALOG_ASSERT((in->proc_buf_out != NULL), +- ""process_frames() failed to reallocate proc_buf_out""); +- proc_buf_out = in->proc_buf_out; +- } +- } +- frames_rd = read_frames(in, +- in->proc_buf_in + +- in->proc_buf_frames * src_channels * bytes_per_sample, +- frames_num - in->proc_buf_frames); +- if (frames_rd < 0) { ++ ssize_t frames_rd = read_frames(in, ++ (char *)in->proc_buf_in + in->proc_buf_frames * src_frame_size, ++ frames_num - in->proc_buf_frames); ++ if (frames_rd < 0) { + /* Return error code */ + frames_wr = frames_rd; + break; +@@ -1073,17 +1081,20 @@ + + + /* in_buf.frameCount and out_buf.frameCount indicate respectively + * the maximum number of frames to be consumed and produced by process() */ ++ audio_buffer_t in_buf; ++ audio_buffer_t out_buf; ++ + in_buf.frameCount = in->proc_buf_frames; +- in_buf.s16 = in->proc_buf_in; ++ in_buf.s16 = in->proc_buf_in; /* currently assumes PCM 16 effects */ + out_buf.frameCount = frames_num - frames_wr; +- out_buf.s16 = (int16_t *)proc_buf_out + frames_wr * in->config.channels; ++ out_buf.s16 = (int16_t *)proc_buf_out + frames_wr * src_channels; + + /* FIXME: this works because of current pre processing library implementation that + * does the actual process only when the last enabled effect process is called. + * The generic solution is to have an output buffer for each effect and pass it as + * input to the next. + */ +- for (i = 0; i < in->num_preprocessors; i++) { ++ for (int i = 0; i < in->num_preprocessors; i++) { + (*in->preprocessors[i].effect_itfe)->process(in->preprocessors[i].effect_itfe, + &in_buf, + &out_buf); +@@ -1096,8 +1107,8 @@ + + + if (in->proc_buf_frames) { + memcpy(in->proc_buf_in, +- in->proc_buf_in + in_buf.frameCount * src_channels * bytes_per_sample, +- in->proc_buf_frames * in->config.channels * audio_bytes_per_sample(in_get_format(in))); ++ (char *)in->proc_buf_in + in_buf.frameCount * src_frame_size, ++ in->proc_buf_frames * src_frame_size); + } + + /* if not enough frames were passed to process(), read more and retry. */ +@@ -1120,23 +1131,14 @@ + + #endif //PREPROCESSING_ENABLED + { + /* No processing effects attached */ +- if (channel_remapping_needed) { +- /* With additional channels, we cannot use original buffer */ +- if (in->proc_buf_size < src_buffer_size) { +- in->proc_buf_size = src_buffer_size; +- in->proc_buf_out = realloc(in->proc_buf_out, src_buffer_size); +- ALOG_ASSERT((in->proc_buf_out != NULL), +- ""process_frames() failed to reallocate proc_buf_out""); +- } +- proc_buf_out = in->proc_buf_out; +- } + frames_wr = read_frames(in, proc_buf_out, frames_num); + ALOG_ASSERT(frames_wr <= frames_num, ""read more frames than requested""); + } + +- if (channel_remapping_needed) { ++ /* check negative frames_wr (error) before channel remapping to avoid overwriting memory. */ ++ if (channel_remapping_needed && frames_wr > 0) { + size_t ret = adjust_channels(proc_buf_out, src_channels, buffer, dst_channels, +- bytes_per_sample, frames_wr * src_channels * bytes_per_sample); ++ bytes_per_sample, frames_wr * src_frame_size); + ALOG_ASSERT(ret == (frames_wr * dst_channels * bytes_per_sample)); + } + +",1264,1500,2048 +17949,"struct sk_buff *skb_segment(struct sk_buff *head_skb, + netdev_features_t features) +{ + struct sk_buff *segs = NULL; + struct sk_buff *tail = NULL; + struct sk_buff *list_skb = skb_shinfo(head_skb)->frag_list; + skb_frag_t *frag = skb_shinfo(head_skb)->frags; + unsigned int mss = skb_shinfo(head_skb)->gso_size; + unsigned int doffset = head_skb->data - skb_mac_header(head_skb); + unsigned int offset = doffset; + unsigned int tnl_hlen = skb_tnl_header_len(head_skb); + unsigned int headroom; + unsigned int len; + __be16 proto; + bool csum; + int sg = !!(features & NETIF_F_SG); + int nfrags = skb_shinfo(head_skb)->nr_frags; + int err = -ENOMEM; + int i = 0; + int pos; + + proto = skb_network_protocol(head_skb); + if (unlikely(!proto)) + return ERR_PTR(-EINVAL); + + csum = !!can_checksum_protocol(features, proto); + __skb_push(head_skb, doffset); + headroom = skb_headroom(head_skb); + pos = skb_headlen(head_skb); + + do { + struct sk_buff *nskb; + skb_frag_t *nskb_frag; + int hsize; + int size; + + len = head_skb->len - offset; + if (len > mss) + len = mss; + + hsize = skb_headlen(head_skb) - offset; + if (hsize < 0) + hsize = 0; + if (hsize > len || !sg) + hsize = len; + + if (!hsize && i >= nfrags && skb_headlen(list_skb) && + (skb_headlen(list_skb) == len || sg)) { + BUG_ON(skb_headlen(list_skb) > len); + + i = 0; + nfrags = skb_shinfo(list_skb)->nr_frags; + frag = skb_shinfo(list_skb)->frags; + pos += skb_headlen(list_skb); + + while (pos < offset + len) { + BUG_ON(i >= nfrags); + + size = skb_frag_size(frag); + if (pos + size > offset + len) + break; + + i++; + pos += size; + frag++; + } + + nskb = skb_clone(list_skb, GFP_ATOMIC); + list_skb = list_skb->next; + + if (unlikely(!nskb)) + goto err; + + if (unlikely(pskb_trim(nskb, len))) { + kfree_skb(nskb); + goto err; + } + + hsize = skb_end_offset(nskb); + if (skb_cow_head(nskb, doffset + headroom)) { + kfree_skb(nskb); + goto err; + } + + nskb->truesize += skb_end_offset(nskb) - hsize; + skb_release_head_state(nskb); + __skb_push(nskb, doffset); + } else { + nskb = __alloc_skb(hsize + doffset + headroom, + GFP_ATOMIC, skb_alloc_rx_flag(head_skb), + NUMA_NO_NODE); + + if (unlikely(!nskb)) + goto err; + + skb_reserve(nskb, headroom); + __skb_put(nskb, doffset); + } + + if (segs) + tail->next = nskb; + else + segs = nskb; + tail = nskb; + + __copy_skb_header(nskb, head_skb); + nskb->mac_len = head_skb->mac_len; + + skb_headers_offset_update(nskb, skb_headroom(nskb) - headroom); + + skb_copy_from_linear_data_offset(head_skb, -tnl_hlen, + nskb->data - tnl_hlen, + doffset + tnl_hlen); + + if (nskb->len == len + doffset) + goto perform_csum_check; + + if (!sg) { + nskb->ip_summed = CHECKSUM_NONE; + nskb->csum = skb_copy_and_csum_bits(head_skb, offset, + skb_put(nskb, len), + len, 0); + continue; + } + + nskb_frag = skb_shinfo(nskb)->frags; + + skb_copy_from_linear_data_offset(head_skb, offset, + skb_put(nskb, hsize), hsize); + + skb_shinfo(nskb)->tx_flags = skb_shinfo(head_skb)->tx_flags & + SKBTX_SHARED_FRAG; + + while (pos < offset + len) { + if (i >= nfrags) { + BUG_ON(skb_headlen(list_skb)); + + i = 0; + nfrags = skb_shinfo(list_skb)->nr_frags; + frag = skb_shinfo(list_skb)->frags; + + BUG_ON(!nfrags); + + list_skb = list_skb->next; + } + + if (unlikely(skb_shinfo(nskb)->nr_frags >= + MAX_SKB_FRAGS)) { + net_warn_ratelimited( + ""skb_segment: too many frags: %u %u\n"", + pos, mss); + goto err; + } + + *nskb_frag = *frag; + __skb_frag_ref(nskb_frag); + size = skb_frag_size(nskb_frag); + + if (pos < offset) { + nskb_frag->page_offset += offset - pos; + skb_frag_size_sub(nskb_frag, offset - pos); + } + + skb_shinfo(nskb)->nr_frags++; + + if (pos + size <= offset + len) { + i++; + frag++; + pos += size; + } else { + skb_frag_size_sub(nskb_frag, pos + size - (offset + len)); + goto skip_fraglist; + } + + nskb_frag++; + } + +skip_fraglist: + nskb->data_len = len - hsize; + nskb->len += nskb->data_len; + nskb->truesize += nskb->data_len; + +perform_csum_check: + if (!csum) { + nskb->csum = skb_checksum(nskb, doffset, + nskb->len - doffset, 0); + nskb->ip_summed = CHECKSUM_NONE; + } + } while ((offset += len) < head_skb->len); + + return segs; + +err: + kfree_skb_list(segs); + return ERR_PTR(err); +} +",1,"struct sk_buff *skb_segment(struct sk_buff *head_skb, + netdev_features_t features) +{ + struct sk_buff *segs = NULL; + struct sk_buff *tail = NULL; + struct sk_buff *list_skb = skb_shinfo(head_skb)->frag_list; + skb_frag_t *frag = skb_shinfo(head_skb)->frags; + unsigned int mss = skb_shinfo(head_skb)->gso_size; + unsigned int doffset = head_skb->data - skb_mac_header(head_skb); + struct sk_buff *frag_skb = head_skb; + unsigned int offset = doffset; + unsigned int tnl_hlen = skb_tnl_header_len(head_skb); + unsigned int headroom; + unsigned int len; + __be16 proto; + bool csum; + int sg = !!(features & NETIF_F_SG); + int nfrags = skb_shinfo(head_skb)->nr_frags; + int err = -ENOMEM; + int i = 0; + int pos; + + proto = skb_network_protocol(head_skb); + if (unlikely(!proto)) + return ERR_PTR(-EINVAL); + + csum = !!can_checksum_protocol(features, proto); + __skb_push(head_skb, doffset); + headroom = skb_headroom(head_skb); + pos = skb_headlen(head_skb); + + do { + struct sk_buff *nskb; + skb_frag_t *nskb_frag; + int hsize; + int size; + + len = head_skb->len - offset; + if (len > mss) + len = mss; + + hsize = skb_headlen(head_skb) - offset; + if (hsize < 0) + hsize = 0; + if (hsize > len || !sg) + hsize = len; + + if (!hsize && i >= nfrags && skb_headlen(list_skb) && + (skb_headlen(list_skb) == len || sg)) { + BUG_ON(skb_headlen(list_skb) > len); + + i = 0; + nfrags = skb_shinfo(list_skb)->nr_frags; + frag = skb_shinfo(list_skb)->frags; + frag_skb = list_skb; + pos += skb_headlen(list_skb); + + while (pos < offset + len) { + BUG_ON(i >= nfrags); + + size = skb_frag_size(frag); + if (pos + size > offset + len) + break; + + i++; + pos += size; + frag++; + } + + nskb = skb_clone(list_skb, GFP_ATOMIC); + list_skb = list_skb->next; + + if (unlikely(!nskb)) + goto err; + + if (unlikely(pskb_trim(nskb, len))) { + kfree_skb(nskb); + goto err; + } + + hsize = skb_end_offset(nskb); + if (skb_cow_head(nskb, doffset + headroom)) { + kfree_skb(nskb); + goto err; + } + + nskb->truesize += skb_end_offset(nskb) - hsize; + skb_release_head_state(nskb); + __skb_push(nskb, doffset); + } else { + nskb = __alloc_skb(hsize + doffset + headroom, + GFP_ATOMIC, skb_alloc_rx_flag(head_skb), + NUMA_NO_NODE); + + if (unlikely(!nskb)) + goto err; + + skb_reserve(nskb, headroom); + __skb_put(nskb, doffset); + } + + if (segs) + tail->next = nskb; + else + segs = nskb; + tail = nskb; + + __copy_skb_header(nskb, head_skb); + nskb->mac_len = head_skb->mac_len; + + skb_headers_offset_update(nskb, skb_headroom(nskb) - headroom); + + skb_copy_from_linear_data_offset(head_skb, -tnl_hlen, + nskb->data - tnl_hlen, + doffset + tnl_hlen); + + if (nskb->len == len + doffset) + goto perform_csum_check; + + if (!sg) { + nskb->ip_summed = CHECKSUM_NONE; + nskb->csum = skb_copy_and_csum_bits(head_skb, offset, + skb_put(nskb, len), + len, 0); + continue; + } + + nskb_frag = skb_shinfo(nskb)->frags; + + skb_copy_from_linear_data_offset(head_skb, offset, + skb_put(nskb, hsize), hsize); + + skb_shinfo(nskb)->tx_flags = skb_shinfo(head_skb)->tx_flags & + SKBTX_SHARED_FRAG; + + while (pos < offset + len) { + if (i >= nfrags) { + BUG_ON(skb_headlen(list_skb)); + + i = 0; + nfrags = skb_shinfo(list_skb)->nr_frags; + frag = skb_shinfo(list_skb)->frags; + frag_skb = list_skb; + + BUG_ON(!nfrags); + + list_skb = list_skb->next; + } + + if (unlikely(skb_shinfo(nskb)->nr_frags >= + MAX_SKB_FRAGS)) { + net_warn_ratelimited( + ""skb_segment: too many frags: %u %u\n"", + pos, mss); + goto err; + } + + if (unlikely(skb_orphan_frags(frag_skb, GFP_ATOMIC))) + goto err; + + *nskb_frag = *frag; + __skb_frag_ref(nskb_frag); + size = skb_frag_size(nskb_frag); + + if (pos < offset) { + nskb_frag->page_offset += offset - pos; + skb_frag_size_sub(nskb_frag, offset - pos); + } + + skb_shinfo(nskb)->nr_frags++; + + if (pos + size <= offset + len) { + i++; + frag++; + pos += size; + } else { + skb_frag_size_sub(nskb_frag, pos + size - (offset + len)); + goto skip_fraglist; + } + + nskb_frag++; + } + +skip_fraglist: + nskb->data_len = len - hsize; + nskb->len += nskb->data_len; + nskb->truesize += nskb->data_len; + +perform_csum_check: + if (!csum) { + nskb->csum = skb_checksum(nskb, doffset, + nskb->len - doffset, 0); + nskb->ip_summed = CHECKSUM_NONE; + } + } while ((offset += len) < head_skb->len); + + return segs; + +err: + kfree_skb_list(segs); + return ERR_PTR(err); +} +","@@ -2854,6 +2854,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, + skb_frag_t *frag = skb_shinfo(head_skb)->frags; + unsigned int mss = skb_shinfo(head_skb)->gso_size; + unsigned int doffset = head_skb->data - skb_mac_header(head_skb); ++ struct sk_buff *frag_skb = head_skb; + unsigned int offset = doffset; + unsigned int tnl_hlen = skb_tnl_header_len(head_skb); + unsigned int headroom; +@@ -2898,6 +2899,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, + i = 0; + nfrags = skb_shinfo(list_skb)->nr_frags; + frag = skb_shinfo(list_skb)->frags; ++ frag_skb = list_skb; + pos += skb_headlen(list_skb); + + while (pos < offset + len) { +@@ -2985,6 +2987,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, + i = 0; + nfrags = skb_shinfo(list_skb)->nr_frags; + frag = skb_shinfo(list_skb)->frags; ++ frag_skb = list_skb; + + BUG_ON(!nfrags); + +@@ -2999,6 +3002,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, + goto err; + } + ++ if (unlikely(skb_orphan_frags(frag_skb, GFP_ATOMIC))) ++ goto err; ++ + *nskb_frag = *frag; + __skb_frag_ref(nskb_frag); + size = skb_frag_size(nskb_frag);",1387,1623,2048 +3873,"static int logi_dj_probe(struct hid_device *hdev, + const struct hid_device_id *id) +{ + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); + struct dj_receiver_dev *djrcv_dev; + int retval; + + if (is_dj_device((struct dj_device *)hdev->driver_data)) + return -ENODEV; + + dbg_hid(""%s called for ifnum %d\n"", __func__, + intf->cur_altsetting->desc.bInterfaceNumber); + + /* Ignore interfaces 0 and 1, they will not carry any data, dont create + * any hid_device for them */ + if (intf->cur_altsetting->desc.bInterfaceNumber != + LOGITECH_DJ_INTERFACE_NUMBER) { + dbg_hid(""%s: ignoring ifnum %d\n"", __func__, + intf->cur_altsetting->desc.bInterfaceNumber); + return -ENODEV; + } + + /* Treat interface 2 */ + + djrcv_dev = kzalloc(sizeof(struct dj_receiver_dev), GFP_KERNEL); + if (!djrcv_dev) { + dev_err(&hdev->dev, + ""%s:failed allocating dj_receiver_dev\n"", __func__); + return -ENOMEM; + } + djrcv_dev->hdev = hdev; + INIT_WORK(&djrcv_dev->work, delayedwork_callback); + spin_lock_init(&djrcv_dev->lock); + if (kfifo_alloc(&djrcv_dev->notif_fifo, + DJ_MAX_NUMBER_NOTIFICATIONS * sizeof(struct dj_report), + GFP_KERNEL)) { + dev_err(&hdev->dev, + ""%s:failed allocating notif_fifo\n"", __func__); + kfree(djrcv_dev); + return -ENOMEM; + } + hid_set_drvdata(hdev, djrcv_dev); + + /* Call to usbhid to fetch the HID descriptors of interface 2 and + * subsequently call to the hid/hid-core to parse the fetched + * descriptors, this will in turn create the hidraw and hiddev nodes + * for interface 2 of the receiver */ + retval = hid_parse(hdev); + if (retval) { + dev_err(&hdev->dev, + ""%s:parse of interface 2 failed\n"", __func__); + goto hid_parse_fail; + } + + if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT, + 0, DJREPORT_SHORT_LENGTH - 1)) { + retval = -ENODEV; + goto hid_parse_fail; + } + + /* Starts the usb device and connects to upper interfaces hiddev and + * hidraw */ + retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); + if (retval) { + dev_err(&hdev->dev, + ""%s:hid_hw_start returned error\n"", __func__); + goto hid_hw_start_fail; + } + + retval = logi_dj_recv_switch_to_dj_mode(djrcv_dev, 0); + if (retval < 0) { + dev_err(&hdev->dev, + ""%s:logi_dj_recv_switch_to_dj_mode returned error:%d\n"", + __func__, retval); + goto switch_to_dj_mode_fail; + } + + /* This is enabling the polling urb on the IN endpoint */ + retval = hid_hw_open(hdev); + if (retval < 0) { + dev_err(&hdev->dev, ""%s:hid_hw_open returned error:%d\n"", + __func__, retval); + goto llopen_failed; + } + + /* Allow incoming packets to arrive: */ + hid_device_io_start(hdev); + + retval = logi_dj_recv_query_paired_devices(djrcv_dev); + if (retval < 0) { + dev_err(&hdev->dev, ""%s:logi_dj_recv_query_paired_devices "" + ""error:%d\n"", __func__, retval); + goto logi_dj_recv_query_paired_devices_failed; + } + + return retval; + +logi_dj_recv_query_paired_devices_failed: + hid_hw_close(hdev); + +llopen_failed: +switch_to_dj_mode_fail: + hid_hw_stop(hdev); + +hid_hw_start_fail: +hid_parse_fail: + kfifo_free(&djrcv_dev->notif_fifo); + kfree(djrcv_dev); + hid_set_drvdata(hdev, NULL); + return retval; + +} +",0,"static int logi_dj_probe(struct hid_device *hdev, + const struct hid_device_id *id) +{ + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); + struct dj_receiver_dev *djrcv_dev; + int retval; + + if (is_dj_device((struct dj_device *)hdev->driver_data)) + return -ENODEV; + + dbg_hid(""%s called for ifnum %d\n"", __func__, + intf->cur_altsetting->desc.bInterfaceNumber); + + /* Ignore interfaces 0 and 1, they will not carry any data, dont create + * any hid_device for them */ + if (intf->cur_altsetting->desc.bInterfaceNumber != + LOGITECH_DJ_INTERFACE_NUMBER) { + dbg_hid(""%s: ignoring ifnum %d\n"", __func__, + intf->cur_altsetting->desc.bInterfaceNumber); + return -ENODEV; + } + + /* Treat interface 2 */ + + djrcv_dev = kzalloc(sizeof(struct dj_receiver_dev), GFP_KERNEL); + if (!djrcv_dev) { + dev_err(&hdev->dev, + ""%s:failed allocating dj_receiver_dev\n"", __func__); + return -ENOMEM; + } + djrcv_dev->hdev = hdev; + INIT_WORK(&djrcv_dev->work, delayedwork_callback); + spin_lock_init(&djrcv_dev->lock); + if (kfifo_alloc(&djrcv_dev->notif_fifo, + DJ_MAX_NUMBER_NOTIFICATIONS * sizeof(struct dj_report), + GFP_KERNEL)) { + dev_err(&hdev->dev, + ""%s:failed allocating notif_fifo\n"", __func__); + kfree(djrcv_dev); + return -ENOMEM; + } + hid_set_drvdata(hdev, djrcv_dev); + + /* Call to usbhid to fetch the HID descriptors of interface 2 and + * subsequently call to the hid/hid-core to parse the fetched + * descriptors, this will in turn create the hidraw and hiddev nodes + * for interface 2 of the receiver */ + retval = hid_parse(hdev); + if (retval) { + dev_err(&hdev->dev, + ""%s:parse of interface 2 failed\n"", __func__); + goto hid_parse_fail; + } + + if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT, + 0, DJREPORT_SHORT_LENGTH - 1)) { + retval = -ENODEV; + goto hid_parse_fail; + } + + /* Starts the usb device and connects to upper interfaces hiddev and + * hidraw */ + retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); + if (retval) { + dev_err(&hdev->dev, + ""%s:hid_hw_start returned error\n"", __func__); + goto hid_hw_start_fail; + } + + retval = logi_dj_recv_switch_to_dj_mode(djrcv_dev, 0); + if (retval < 0) { + dev_err(&hdev->dev, + ""%s:logi_dj_recv_switch_to_dj_mode returned error:%d\n"", + __func__, retval); + goto switch_to_dj_mode_fail; + } + + /* This is enabling the polling urb on the IN endpoint */ + retval = hid_hw_open(hdev); + if (retval < 0) { + dev_err(&hdev->dev, ""%s:hid_hw_open returned error:%d\n"", + __func__, retval); + goto llopen_failed; + } + + /* Allow incoming packets to arrive: */ + hid_device_io_start(hdev); + + retval = logi_dj_recv_query_paired_devices(djrcv_dev); + if (retval < 0) { + dev_err(&hdev->dev, ""%s:logi_dj_recv_query_paired_devices "" + ""error:%d\n"", __func__, retval); + goto logi_dj_recv_query_paired_devices_failed; + } + + return retval; + +logi_dj_recv_query_paired_devices_failed: + hid_hw_close(hdev); + +llopen_failed: +switch_to_dj_mode_fail: + hid_hw_stop(hdev); + +hid_hw_start_fail: +hid_parse_fail: + kfifo_free(&djrcv_dev->notif_fifo); + kfree(djrcv_dev); + hid_set_drvdata(hdev, NULL); + return retval; + +} +","@@ -557,7 +557,7 @@ static int logi_dj_ll_raw_request(struct hid_device *hid, + if (!out_buf) + return -ENOMEM; + +- if (count < DJREPORT_SHORT_LENGTH - 2) ++ if (count > DJREPORT_SHORT_LENGTH - 2) + count = DJREPORT_SHORT_LENGTH - 2; + + out_buf[0] = REPORT_ID_DJ_SHORT;",915,1151,2048 +17924,"static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock, + struct buffer_head *bh_map, struct metapath *mp, + const unsigned int sheight, + const unsigned int height, + const unsigned int maxlen) + { + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); + struct buffer_head *dibh = mp->mp_bh[0]; + u64 bn, dblock = 0; + unsigned n, i, blks, alloced = 0, iblks = 0, branch_start = 0; + unsigned dblks = 0; + unsigned ptrs_per_blk; + const unsigned end_of_metadata = height - 1; + int eob = 0; + enum alloc_state state; + __be64 *ptr; + __be64 zero_bn = 0; + + BUG_ON(sheight < 1); + BUG_ON(dibh == NULL); + + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + + if (height == sheight) { + struct buffer_head *bh; + /* Bottom indirect block exists, find unalloced extent size */ + ptr = metapointer(end_of_metadata, mp); + bh = mp->mp_bh[end_of_metadata]; + dblks = gfs2_extent_length(bh->b_data, bh->b_size, ptr, maxlen, + &eob); + BUG_ON(dblks < 1); + state = ALLOC_DATA; + } else { + /* Need to allocate indirect blocks */ + ptrs_per_blk = height > 1 ? sdp->sd_inptrs : sdp->sd_diptrs; + dblks = min(maxlen, ptrs_per_blk - mp->mp_list[end_of_metadata]); + if (height == ip->i_height) { + /* Writing into existing tree, extend tree down */ + iblks = height - sheight; + state = ALLOC_GROW_DEPTH; + } else { + /* Building up tree height */ + state = ALLOC_GROW_HEIGHT; + iblks = height - ip->i_height; + branch_start = metapath_branch_start(mp); + iblks += (height - branch_start); + } + } + + /* start of the second part of the function (state machine) */ + + blks = dblks + iblks; + i = sheight; + do { + int error; + n = blks - alloced; + error = gfs2_alloc_block(ip, &bn, &n); + if (error) + return error; + alloced += n; + if (state != ALLOC_DATA || gfs2_is_jdata(ip)) + gfs2_trans_add_unrevoke(sdp, bn, n); + switch (state) { + /* Growing height of tree */ + case ALLOC_GROW_HEIGHT: + if (i == 1) { + ptr = (__be64 *)(dibh->b_data + + sizeof(struct gfs2_dinode)); + zero_bn = *ptr; + } + for (; i - 1 < height - ip->i_height && n > 0; i++, n--) + gfs2_indirect_init(mp, ip->i_gl, i, 0, bn++); + if (i - 1 == height - ip->i_height) { + i--; + gfs2_buffer_copy_tail(mp->mp_bh[i], + sizeof(struct gfs2_meta_header), + dibh, sizeof(struct gfs2_dinode)); + gfs2_buffer_clear_tail(dibh, + sizeof(struct gfs2_dinode) + + sizeof(__be64)); + ptr = (__be64 *)(mp->mp_bh[i]->b_data + + sizeof(struct gfs2_meta_header)); + *ptr = zero_bn; + state = ALLOC_GROW_DEPTH; + for(i = branch_start; i < height; i++) { + if (mp->mp_bh[i] == NULL) + break; + brelse(mp->mp_bh[i]); + mp->mp_bh[i] = NULL; + } + i = branch_start; + } + if (n == 0) + break; + /* Branching from existing tree */ + case ALLOC_GROW_DEPTH: + if (i > 1 && i < height) + gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[i-1], 1); + for (; i < height && n > 0; i++, n--) + gfs2_indirect_init(mp, ip->i_gl, i, + mp->mp_list[i-1], bn++); + if (i == height) + state = ALLOC_DATA; + if (n == 0) + break; + /* Tree complete, adding data blocks */ + case ALLOC_DATA: + BUG_ON(n > dblks); + BUG_ON(mp->mp_bh[end_of_metadata] == NULL); + gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[end_of_metadata], 1); + dblks = n; + ptr = metapointer(end_of_metadata, mp); + dblock = bn; + while (n-- > 0) + *ptr++ = cpu_to_be64(bn++); + break; + } + } while ((state != ALLOC_DATA) || !dblock); + + ip->i_height = height; + gfs2_add_inode_blocks(&ip->i_inode, alloced); + gfs2_dinode_out(ip, mp->mp_bh[0]->b_data); + map_bh(bh_map, inode->i_sb, dblock); + bh_map->b_size = dblks << inode->i_blkbits; + set_buffer_new(bh_map); + return 0; +} +",1,"static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock, + struct buffer_head *bh_map, struct metapath *mp, + const unsigned int sheight, + const unsigned int height, + const unsigned int maxlen) + { + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); + struct super_block *sb = sdp->sd_vfs; + struct buffer_head *dibh = mp->mp_bh[0]; + u64 bn, dblock = 0; + unsigned n, i, blks, alloced = 0, iblks = 0, branch_start = 0; + unsigned dblks = 0; + unsigned ptrs_per_blk; + const unsigned end_of_metadata = height - 1; + int ret; + int eob = 0; + enum alloc_state state; + __be64 *ptr; + __be64 zero_bn = 0; + + BUG_ON(sheight < 1); + BUG_ON(dibh == NULL); + + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + + if (height == sheight) { + struct buffer_head *bh; + /* Bottom indirect block exists, find unalloced extent size */ + ptr = metapointer(end_of_metadata, mp); + bh = mp->mp_bh[end_of_metadata]; + dblks = gfs2_extent_length(bh->b_data, bh->b_size, ptr, maxlen, + &eob); + BUG_ON(dblks < 1); + state = ALLOC_DATA; + } else { + /* Need to allocate indirect blocks */ + ptrs_per_blk = height > 1 ? sdp->sd_inptrs : sdp->sd_diptrs; + dblks = min(maxlen, ptrs_per_blk - mp->mp_list[end_of_metadata]); + if (height == ip->i_height) { + /* Writing into existing tree, extend tree down */ + iblks = height - sheight; + state = ALLOC_GROW_DEPTH; + } else { + /* Building up tree height */ + state = ALLOC_GROW_HEIGHT; + iblks = height - ip->i_height; + branch_start = metapath_branch_start(mp); + iblks += (height - branch_start); + } + } + + /* start of the second part of the function (state machine) */ + + blks = dblks + iblks; + i = sheight; + do { + int error; + n = blks - alloced; + error = gfs2_alloc_block(ip, &bn, &n); + if (error) + return error; + alloced += n; + if (state != ALLOC_DATA || gfs2_is_jdata(ip)) + gfs2_trans_add_unrevoke(sdp, bn, n); + switch (state) { + /* Growing height of tree */ + case ALLOC_GROW_HEIGHT: + if (i == 1) { + ptr = (__be64 *)(dibh->b_data + + sizeof(struct gfs2_dinode)); + zero_bn = *ptr; + } + for (; i - 1 < height - ip->i_height && n > 0; i++, n--) + gfs2_indirect_init(mp, ip->i_gl, i, 0, bn++); + if (i - 1 == height - ip->i_height) { + i--; + gfs2_buffer_copy_tail(mp->mp_bh[i], + sizeof(struct gfs2_meta_header), + dibh, sizeof(struct gfs2_dinode)); + gfs2_buffer_clear_tail(dibh, + sizeof(struct gfs2_dinode) + + sizeof(__be64)); + ptr = (__be64 *)(mp->mp_bh[i]->b_data + + sizeof(struct gfs2_meta_header)); + *ptr = zero_bn; + state = ALLOC_GROW_DEPTH; + for(i = branch_start; i < height; i++) { + if (mp->mp_bh[i] == NULL) + break; + brelse(mp->mp_bh[i]); + mp->mp_bh[i] = NULL; + } + i = branch_start; + } + if (n == 0) + break; + /* Branching from existing tree */ + case ALLOC_GROW_DEPTH: + if (i > 1 && i < height) + gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[i-1], 1); + for (; i < height && n > 0; i++, n--) + gfs2_indirect_init(mp, ip->i_gl, i, + mp->mp_list[i-1], bn++); + if (i == height) + state = ALLOC_DATA; + if (n == 0) + break; + /* Tree complete, adding data blocks */ + case ALLOC_DATA: + BUG_ON(n > dblks); + BUG_ON(mp->mp_bh[end_of_metadata] == NULL); + gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[end_of_metadata], 1); + dblks = n; + ptr = metapointer(end_of_metadata, mp); + dblock = bn; + while (n-- > 0) + *ptr++ = cpu_to_be64(bn++); + if (buffer_zeronew(bh_map)) { + ret = sb_issue_zeroout(sb, dblock, dblks, + GFP_NOFS); + if (ret) { + fs_err(sdp, + ""Failed to zero data buffers\n""); + clear_buffer_zeronew(bh_map); + } + } + break; + } + } while ((state != ALLOC_DATA) || !dblock); + + ip->i_height = height; + gfs2_add_inode_blocks(&ip->i_inode, alloced); + gfs2_dinode_out(ip, mp->mp_bh[0]->b_data); + map_bh(bh_map, inode->i_sb, dblock); + bh_map->b_size = dblks << inode->i_blkbits; + set_buffer_new(bh_map); + return 0; +} +","@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -427,12 +428,14 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock, + { + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); ++ struct super_block *sb = sdp->sd_vfs; + struct buffer_head *dibh = mp->mp_bh[0]; + u64 bn, dblock = 0; + unsigned n, i, blks, alloced = 0, iblks = 0, branch_start = 0; + unsigned dblks = 0; + unsigned ptrs_per_blk; + const unsigned end_of_metadata = height - 1; ++ int ret; + int eob = 0; + enum alloc_state state; + __be64 *ptr; +@@ -535,6 +538,15 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock, + dblock = bn; + while (n-- > 0) + *ptr++ = cpu_to_be64(bn++); ++ if (buffer_zeronew(bh_map)) { ++ ret = sb_issue_zeroout(sb, dblock, dblks, ++ GFP_NOFS); ++ if (ret) { ++ fs_err(sdp, ++ ""Failed to zero data buffers\n""); ++ clear_buffer_zeronew(bh_map); ++ } ++ } + break; + } + } while ((state != ALLOC_DATA) || !dblock);",1264,1500,2048 +17873,"int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) + { + struct ip_options *sopt; + unsigned char *sptr, *dptr; + int soffset, doffset; + int optlen; + __be32 daddr; + + memset(dopt, 0, sizeof(struct ip_options)); + + sopt = &(IPCB(skb)->opt); + + if (sopt->optlen == 0) { + dopt->optlen = 0; + return 0; + } + + sptr = skb_network_header(skb); + dptr = dopt->__data; + + daddr = skb_rtable(skb)->rt_spec_dst; + + if (sopt->rr) { + optlen = sptr[sopt->rr+1]; + soffset = sptr[sopt->rr+2]; + dopt->rr = dopt->optlen + sizeof(struct iphdr); + memcpy(dptr, sptr+sopt->rr, optlen); + if (sopt->rr_needaddr && soffset <= optlen) { + if (soffset + 3 > optlen) + return -EINVAL; + dptr[2] = soffset + 4; + dopt->rr_needaddr = 1; + } + dptr += optlen; + dopt->optlen += optlen; + } + if (sopt->ts) { + optlen = sptr[sopt->ts+1]; + soffset = sptr[sopt->ts+2]; + dopt->ts = dopt->optlen + sizeof(struct iphdr); + memcpy(dptr, sptr+sopt->ts, optlen); + if (soffset <= optlen) { + if (sopt->ts_needaddr) { + if (soffset + 3 > optlen) + return -EINVAL; + dopt->ts_needaddr = 1; + soffset += 4; + } + if (sopt->ts_needtime) { + if (soffset + 3 > optlen) + return -EINVAL; + if ((dptr[3]&0xF) != IPOPT_TS_PRESPEC) { + dopt->ts_needtime = 1; + soffset += 4; + } else { + dopt->ts_needtime = 0; + + if (soffset + 7 <= optlen) { + __be32 addr; + + memcpy(&addr, dptr+soffset-1, 4); + if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_UNICAST) { + dopt->ts_needtime = 1; + soffset += 8; + } + } + } + } + dptr[2] = soffset; + } + dptr += optlen; + dopt->optlen += optlen; + } + if (sopt->srr) { + unsigned char * start = sptr+sopt->srr; + __be32 faddr; + + optlen = start[1]; + soffset = start[2]; + doffset = 0; + if (soffset > optlen) + soffset = optlen + 1; + soffset -= 4; + if (soffset > 3) { + memcpy(&faddr, &start[soffset-1], 4); + for (soffset-=4, doffset=4; soffset > 3; soffset-=4, doffset+=4) + memcpy(&dptr[doffset-1], &start[soffset-1], 4); + /* + * RFC1812 requires to fix illegal source routes. + */ + if (memcmp(&ip_hdr(skb)->saddr, + &start[soffset + 3], 4) == 0) + doffset -= 4; + } + if (doffset > 3) { + memcpy(&start[doffset-1], &daddr, 4); + dopt->faddr = faddr; + dptr[0] = start[0]; + dptr[1] = doffset+3; + dptr[2] = 4; + dptr += doffset+3; + dopt->srr = dopt->optlen + sizeof(struct iphdr); + dopt->optlen += doffset+3; + dopt->is_strictroute = sopt->is_strictroute; + } + } + if (sopt->cipso) { + optlen = sptr[sopt->cipso+1]; + dopt->cipso = dopt->optlen+sizeof(struct iphdr); + memcpy(dptr, sptr+sopt->cipso, optlen); + dptr += optlen; + dopt->optlen += optlen; + } + while (dopt->optlen & 3) { + *dptr++ = IPOPT_END; + dopt->optlen++; + } + return 0; +} +",1,"int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) +int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb) + { + const struct ip_options *sopt; + unsigned char *sptr, *dptr; + int soffset, doffset; + int optlen; + __be32 daddr; + + memset(dopt, 0, sizeof(struct ip_options)); + + sopt = &(IPCB(skb)->opt); + + if (sopt->optlen == 0) + return 0; + + sptr = skb_network_header(skb); + dptr = dopt->__data; + + daddr = skb_rtable(skb)->rt_spec_dst; + + if (sopt->rr) { + optlen = sptr[sopt->rr+1]; + soffset = sptr[sopt->rr+2]; + dopt->rr = dopt->optlen + sizeof(struct iphdr); + memcpy(dptr, sptr+sopt->rr, optlen); + if (sopt->rr_needaddr && soffset <= optlen) { + if (soffset + 3 > optlen) + return -EINVAL; + dptr[2] = soffset + 4; + dopt->rr_needaddr = 1; + } + dptr += optlen; + dopt->optlen += optlen; + } + if (sopt->ts) { + optlen = sptr[sopt->ts+1]; + soffset = sptr[sopt->ts+2]; + dopt->ts = dopt->optlen + sizeof(struct iphdr); + memcpy(dptr, sptr+sopt->ts, optlen); + if (soffset <= optlen) { + if (sopt->ts_needaddr) { + if (soffset + 3 > optlen) + return -EINVAL; + dopt->ts_needaddr = 1; + soffset += 4; + } + if (sopt->ts_needtime) { + if (soffset + 3 > optlen) + return -EINVAL; + if ((dptr[3]&0xF) != IPOPT_TS_PRESPEC) { + dopt->ts_needtime = 1; + soffset += 4; + } else { + dopt->ts_needtime = 0; + + if (soffset + 7 <= optlen) { + __be32 addr; + + memcpy(&addr, dptr+soffset-1, 4); + if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_UNICAST) { + dopt->ts_needtime = 1; + soffset += 8; + } + } + } + } + dptr[2] = soffset; + } + dptr += optlen; + dopt->optlen += optlen; + } + if (sopt->srr) { + unsigned char *start = sptr+sopt->srr; + __be32 faddr; + + optlen = start[1]; + soffset = start[2]; + doffset = 0; + if (soffset > optlen) + soffset = optlen + 1; + soffset -= 4; + if (soffset > 3) { + memcpy(&faddr, &start[soffset-1], 4); + for (soffset-=4, doffset=4; soffset > 3; soffset-=4, doffset+=4) + memcpy(&dptr[doffset-1], &start[soffset-1], 4); + /* + * RFC1812 requires to fix illegal source routes. + */ + if (memcmp(&ip_hdr(skb)->saddr, + &start[soffset + 3], 4) == 0) + doffset -= 4; + } + if (doffset > 3) { + memcpy(&start[doffset-1], &daddr, 4); + dopt->faddr = faddr; + dptr[0] = start[0]; + dptr[1] = doffset+3; + dptr[2] = 4; + dptr += doffset+3; + dopt->srr = dopt->optlen + sizeof(struct iphdr); + dopt->optlen += doffset+3; + dopt->is_strictroute = sopt->is_strictroute; + } + } + if (sopt->cipso) { + optlen = sptr[sopt->cipso+1]; + dopt->cipso = dopt->optlen+sizeof(struct iphdr); + memcpy(dptr, sptr+sopt->cipso, optlen); + dptr += optlen; + dopt->optlen += optlen; + } + while (dopt->optlen & 3) { + *dptr++ = IPOPT_END; + dopt->optlen++; + } + return 0; +} +","@@ -36,7 +36,7 @@ + * saddr is address of outgoing interface. + */ + +-void ip_options_build(struct sk_buff * skb, struct ip_options * opt, ++void ip_options_build(struct sk_buff *skb, struct ip_options *opt, + __be32 daddr, struct rtable *rt, int is_frag) + { + unsigned char *iph = skb_network_header(skb); +@@ -83,9 +83,9 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt, + * NOTE: dopt cannot point to skb. + */ + +-int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) ++int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb) + { +- struct ip_options *sopt; ++ const struct ip_options *sopt; + unsigned char *sptr, *dptr; + int soffset, doffset; + int optlen; +@@ -95,10 +95,8 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) + + sopt = &(IPCB(skb)->opt); + +- if (sopt->optlen == 0) { +- dopt->optlen = 0; ++ if (sopt->optlen == 0) + return 0; +- } + + sptr = skb_network_header(skb); + dptr = dopt->__data; +@@ -157,7 +155,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) + dopt->optlen += optlen; + } + if (sopt->srr) { +- unsigned char * start = sptr+sopt->srr; ++ unsigned char *start = sptr+sopt->srr; + __be32 faddr; + + optlen = start[1]; +@@ -499,19 +497,19 @@ void ip_options_undo(struct ip_options * opt) + } + } + +-static struct ip_options *ip_options_get_alloc(const int optlen) ++static struct ip_options_rcu *ip_options_get_alloc(const int optlen) + { +- return kzalloc(sizeof(struct ip_options) + ((optlen + 3) & ~3), ++ return kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3), + GFP_KERNEL); + } + +-static int ip_options_get_finish(struct net *net, struct ip_options **optp, +- struct ip_options *opt, int optlen) ++static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp, ++ struct ip_options_rcu *opt, int optlen) + { + while (optlen & 3) +- opt->__data[optlen++] = IPOPT_END; +- opt->optlen = optlen; +- if (optlen && ip_options_compile(net, opt, NULL)) { ++ opt->opt.__data[optlen++] = IPOPT_END; ++ opt->opt.optlen = optlen; ++ if (optlen && ip_options_compile(net, &opt->opt, NULL)) { + kfree(opt); + return -EINVAL; + } +@@ -520,29 +518,29 @@ static int ip_options_get_finish(struct net *net, struct ip_options **optp, + return 0; + } + +-int ip_options_get_from_user(struct net *net, struct ip_options **optp, ++int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, + unsigned char __user *data, int optlen) + { +- struct ip_options *opt = ip_options_get_alloc(optlen); ++ struct ip_options_rcu *opt = ip_options_get_alloc(optlen); + + if (!opt) + return -ENOMEM; +- if (optlen && copy_from_user(opt->__data, data, optlen)) { ++ if (optlen && copy_from_user(opt->opt.__data, data, optlen)) { + kfree(opt); + return -EFAULT; + } + return ip_options_get_finish(net, optp, opt, optlen); + } + +-int ip_options_get(struct net *net, struct ip_options **optp, ++int ip_options_get(struct net *net, struct ip_options_rcu **optp, + unsigned char *data, int optlen) + { +- struct ip_options *opt = ip_options_get_alloc(optlen); ++ struct ip_options_rcu *opt = ip_options_get_alloc(optlen); + + if (!opt) + return -ENOMEM; + if (optlen) +- memcpy(opt->__data, data, optlen); ++ memcpy(opt->opt.__data, data, optlen); + return ip_options_get_finish(net, optp, opt, optlen); + } + ",1101,1337,2048 +3468,"static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) +{ + struct sock *sk; + struct tun_struct *tun; + struct net_device *dev; + int err; + + dev = __dev_get_by_name(net, ifr->ifr_name); + if (dev) { + const struct cred *cred = current_cred(); + + if (ifr->ifr_flags & IFF_TUN_EXCL) + return -EBUSY; + if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops) + tun = netdev_priv(dev); + else if ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops) + tun = netdev_priv(dev); + else + return -EINVAL; + + if (((tun->owner != -1 && cred->euid != tun->owner) || + (tun->group != -1 && !in_egroup_p(tun->group))) && + !capable(CAP_NET_ADMIN)) + return -EPERM; + err = security_tun_dev_attach(tun->socket.sk); + if (err < 0) + return err; + + err = tun_attach(tun, file); + if (err < 0) + return err; + } + else { + char *name; + unsigned long flags = 0; + + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + err = security_tun_dev_create(); + if (err < 0) + return err; + + /* Set dev type */ + if (ifr->ifr_flags & IFF_TUN) { + /* TUN device */ + flags |= TUN_TUN_DEV; + name = ""tun%d""; + } else if (ifr->ifr_flags & IFF_TAP) { + /* TAP device */ + flags |= TUN_TAP_DEV; + name = ""tap%d""; + } else + return -EINVAL; + + if (*ifr->ifr_name) + name = ifr->ifr_name; + + dev = alloc_netdev(sizeof(struct tun_struct), name, + tun_setup); + if (!dev) + return -ENOMEM; + + dev_net_set(dev, net); + dev->rtnl_link_ops = &tun_link_ops; + + tun = netdev_priv(dev); + tun->dev = dev; + tun->flags = flags; + tun->txflt.count = 0; + tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr); + set_bit(SOCK_EXTERNALLY_ALLOCATED, &tun->socket.flags); + + err = -ENOMEM; + sk = sk_alloc(&init_net, AF_UNSPEC, GFP_KERNEL, &tun_proto); + if (!sk) + goto err_free_dev; + + sk_change_net(sk, net); + tun->socket.wq = &tun->wq; + init_waitqueue_head(&tun->wq.wait); + tun->socket.ops = &tun_socket_ops; + sock_init_data(&tun->socket, sk); + sk->sk_write_space = tun_sock_write_space; + sk->sk_sndbuf = INT_MAX; + sock_set_flag(sk, SOCK_ZEROCOPY); + + tun_sk(sk)->tun = tun; + + security_tun_dev_post_create(sk); + + tun_net_init(dev); + + dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | + TUN_USER_FEATURES; + dev->features = dev->hw_features; + + err = register_netdevice(tun->dev); + if (err < 0) + goto err_free_sk; + + if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) || + device_create_file(&tun->dev->dev, &dev_attr_owner) || + device_create_file(&tun->dev->dev, &dev_attr_group)) + pr_err(""Failed to create tun sysfs files\n""); + + sk->sk_destruct = tun_sock_destruct; + + err = tun_attach(tun, file); + if (err < 0) + goto failed; + } + + tun_debug(KERN_INFO, tun, ""tun_set_iff\n""); + + if (ifr->ifr_flags & IFF_NO_PI) + tun->flags |= TUN_NO_PI; + else + tun->flags &= ~TUN_NO_PI; + + if (ifr->ifr_flags & IFF_ONE_QUEUE) + tun->flags |= TUN_ONE_QUEUE; + else + tun->flags &= ~TUN_ONE_QUEUE; + + if (ifr->ifr_flags & IFF_VNET_HDR) + tun->flags |= TUN_VNET_HDR; + else + tun->flags &= ~TUN_VNET_HDR; + + /* Make sure persistent devices do not get stuck in + * xoff state. + */ + if (netif_running(tun->dev)) + netif_wake_queue(tun->dev); + + strcpy(ifr->ifr_name, tun->dev->name); + return 0; + + err_free_sk: + tun_free_netdev(dev); + err_free_dev: + free_netdev(dev); + failed: + return err; +} +",0,"static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) +{ + struct sock *sk; + struct tun_struct *tun; + struct net_device *dev; + int err; + + dev = __dev_get_by_name(net, ifr->ifr_name); + if (dev) { + const struct cred *cred = current_cred(); + + if (ifr->ifr_flags & IFF_TUN_EXCL) + return -EBUSY; + if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops) + tun = netdev_priv(dev); + else if ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops) + tun = netdev_priv(dev); + else + return -EINVAL; + + if (((tun->owner != -1 && cred->euid != tun->owner) || + (tun->group != -1 && !in_egroup_p(tun->group))) && + !capable(CAP_NET_ADMIN)) + return -EPERM; + err = security_tun_dev_attach(tun->socket.sk); + if (err < 0) + return err; + + err = tun_attach(tun, file); + if (err < 0) + return err; + } + else { + char *name; + unsigned long flags = 0; + + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + err = security_tun_dev_create(); + if (err < 0) + return err; + + /* Set dev type */ + if (ifr->ifr_flags & IFF_TUN) { + /* TUN device */ + flags |= TUN_TUN_DEV; + name = ""tun%d""; + } else if (ifr->ifr_flags & IFF_TAP) { + /* TAP device */ + flags |= TUN_TAP_DEV; + name = ""tap%d""; + } else + return -EINVAL; + + if (*ifr->ifr_name) + name = ifr->ifr_name; + + dev = alloc_netdev(sizeof(struct tun_struct), name, + tun_setup); + if (!dev) + return -ENOMEM; + + dev_net_set(dev, net); + dev->rtnl_link_ops = &tun_link_ops; + + tun = netdev_priv(dev); + tun->dev = dev; + tun->flags = flags; + tun->txflt.count = 0; + tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr); + set_bit(SOCK_EXTERNALLY_ALLOCATED, &tun->socket.flags); + + err = -ENOMEM; + sk = sk_alloc(&init_net, AF_UNSPEC, GFP_KERNEL, &tun_proto); + if (!sk) + goto err_free_dev; + + sk_change_net(sk, net); + tun->socket.wq = &tun->wq; + init_waitqueue_head(&tun->wq.wait); + tun->socket.ops = &tun_socket_ops; + sock_init_data(&tun->socket, sk); + sk->sk_write_space = tun_sock_write_space; + sk->sk_sndbuf = INT_MAX; + sock_set_flag(sk, SOCK_ZEROCOPY); + + tun_sk(sk)->tun = tun; + + security_tun_dev_post_create(sk); + + tun_net_init(dev); + + dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | + TUN_USER_FEATURES; + dev->features = dev->hw_features; + + err = register_netdevice(tun->dev); + if (err < 0) + goto err_free_sk; + + if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) || + device_create_file(&tun->dev->dev, &dev_attr_owner) || + device_create_file(&tun->dev->dev, &dev_attr_group)) + pr_err(""Failed to create tun sysfs files\n""); + + sk->sk_destruct = tun_sock_destruct; + + err = tun_attach(tun, file); + if (err < 0) + goto failed; + } + + tun_debug(KERN_INFO, tun, ""tun_set_iff\n""); + + if (ifr->ifr_flags & IFF_NO_PI) + tun->flags |= TUN_NO_PI; + else + tun->flags &= ~TUN_NO_PI; + + if (ifr->ifr_flags & IFF_ONE_QUEUE) + tun->flags |= TUN_ONE_QUEUE; + else + tun->flags &= ~TUN_ONE_QUEUE; + + if (ifr->ifr_flags & IFF_VNET_HDR) + tun->flags |= TUN_VNET_HDR; + else + tun->flags &= ~TUN_VNET_HDR; + + /* Make sure persistent devices do not get stuck in + * xoff state. + */ + if (netif_running(tun->dev)) + netif_wake_queue(tun->dev); + + strcpy(ifr->ifr_name, tun->dev->name); + return 0; + + err_free_sk: + tun_free_netdev(dev); + err_free_dev: + free_netdev(dev); + failed: + return err; +} +","@@ -1379,9 +1379,11 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, + int vnet_hdr_sz; + int ret; + +- if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) ++ if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) { + if (copy_from_user(&ifr, argp, ifreq_len)) + return -EFAULT; ++ } else ++ memset(&ifr, 0, sizeof(ifr)); + + if (cmd == TUNGETFEATURES) { + /* Currently this just means: ""what IFF flags are valid?"".",1107,1343,2048 +2570,"CIFSGetDFSRefer(const int xid, struct cifs_ses *ses, + const unsigned char *searchName, + struct dfs_info3_param **target_nodes, + unsigned int *num_of_nodes, + const struct nls_table *nls_codepage, int remap) +{ +/* TRANS2_GET_DFS_REFERRAL */ + TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; + TRANSACTION2_GET_DFS_REFER_RSP *pSMBr = NULL; + int rc = 0; + int bytes_returned; + int name_len; + __u16 params, byte_count; + *num_of_nodes = 0; + *target_nodes = NULL; + + cFYI(1, ""In GetDFSRefer the path %s"", searchName); + if (ses == NULL) + return -ENODEV; +getDFSRetry: + rc = smb_init(SMB_COM_TRANSACTION2, 15, NULL, (void **) &pSMB, + (void **) &pSMBr); + if (rc) + return rc; + + /* server pointer checked in called function, + but should never be null here anyway */ + pSMB->hdr.Mid = GetNextMid(ses->server); + pSMB->hdr.Tid = ses->ipc_tid; + pSMB->hdr.Uid = ses->Suid; + if (ses->capabilities & CAP_STATUS32) + pSMB->hdr.Flags2 |= SMBFLG2_ERR_STATUS; + if (ses->capabilities & CAP_DFS) + pSMB->hdr.Flags2 |= SMBFLG2_DFS; + + if (ses->capabilities & CAP_UNICODE) { + pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; + name_len = + cifsConvertToUCS((__le16 *) pSMB->RequestFileName, + searchName, PATH_MAX, nls_codepage, remap); + name_len++; /* trailing null */ + name_len *= 2; + } else { /* BB improve the check for buffer overruns BB */ + name_len = strnlen(searchName, PATH_MAX); + name_len++; /* trailing null */ + strncpy(pSMB->RequestFileName, searchName, name_len); + } + + if (ses->server) { + if (ses->server->sec_mode & + (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) + pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; + } + + pSMB->hdr.Uid = ses->Suid; + + params = 2 /* level */ + name_len /*includes null */ ; + pSMB->TotalDataCount = 0; + pSMB->DataCount = 0; + pSMB->DataOffset = 0; + pSMB->MaxParameterCount = 0; + /* BB find exact max SMB PDU from sess structure BB */ + pSMB->MaxDataCount = cpu_to_le16(4000); + pSMB->MaxSetupCount = 0; + pSMB->Reserved = 0; + pSMB->Flags = 0; + pSMB->Timeout = 0; + pSMB->Reserved2 = 0; + pSMB->ParameterOffset = cpu_to_le16(offsetof( + struct smb_com_transaction2_get_dfs_refer_req, MaxReferralLevel) - 4); + pSMB->SetupCount = 1; + pSMB->Reserved3 = 0; + pSMB->SubCommand = cpu_to_le16(TRANS2_GET_DFS_REFERRAL); + byte_count = params + 3 /* pad */ ; + pSMB->ParameterCount = cpu_to_le16(params); + pSMB->TotalParameterCount = pSMB->ParameterCount; + pSMB->MaxReferralLevel = cpu_to_le16(3); + inc_rfc1001_len(pSMB, byte_count); + pSMB->ByteCount = cpu_to_le16(byte_count); + + rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, + (struct smb_hdr *) pSMBr, &bytes_returned, 0); + if (rc) { + cFYI(1, ""Send error in GetDFSRefer = %d"", rc); + goto GetDFSRefExit; + } + rc = validate_t2((struct smb_t2_rsp *)pSMBr); + + /* BB Also check if enough total bytes returned? */ + if (rc || get_bcc(&pSMBr->hdr) < 17) { + rc = -EIO; /* bad smb */ + goto GetDFSRefExit; + } + + cFYI(1, ""Decoding GetDFSRefer response BCC: %d Offset %d"", + get_bcc(&pSMBr->hdr), + le16_to_cpu(pSMBr->t2.DataOffset)); + + /* parse returned result into more usable form */ + rc = parse_DFS_referrals(pSMBr, num_of_nodes, + target_nodes, nls_codepage, remap, + searchName); + +GetDFSRefExit: + cifs_buf_release(pSMB); + + if (rc == -EAGAIN) + goto getDFSRetry; + + return rc; +} +",0,"CIFSGetDFSRefer(const int xid, struct cifs_ses *ses, + const unsigned char *searchName, + struct dfs_info3_param **target_nodes, + unsigned int *num_of_nodes, + const struct nls_table *nls_codepage, int remap) +{ +/* TRANS2_GET_DFS_REFERRAL */ + TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; + TRANSACTION2_GET_DFS_REFER_RSP *pSMBr = NULL; + int rc = 0; + int bytes_returned; + int name_len; + __u16 params, byte_count; + *num_of_nodes = 0; + *target_nodes = NULL; + + cFYI(1, ""In GetDFSRefer the path %s"", searchName); + if (ses == NULL) + return -ENODEV; +getDFSRetry: + rc = smb_init(SMB_COM_TRANSACTION2, 15, NULL, (void **) &pSMB, + (void **) &pSMBr); + if (rc) + return rc; + + /* server pointer checked in called function, + but should never be null here anyway */ + pSMB->hdr.Mid = GetNextMid(ses->server); + pSMB->hdr.Tid = ses->ipc_tid; + pSMB->hdr.Uid = ses->Suid; + if (ses->capabilities & CAP_STATUS32) + pSMB->hdr.Flags2 |= SMBFLG2_ERR_STATUS; + if (ses->capabilities & CAP_DFS) + pSMB->hdr.Flags2 |= SMBFLG2_DFS; + + if (ses->capabilities & CAP_UNICODE) { + pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; + name_len = + cifsConvertToUCS((__le16 *) pSMB->RequestFileName, + searchName, PATH_MAX, nls_codepage, remap); + name_len++; /* trailing null */ + name_len *= 2; + } else { /* BB improve the check for buffer overruns BB */ + name_len = strnlen(searchName, PATH_MAX); + name_len++; /* trailing null */ + strncpy(pSMB->RequestFileName, searchName, name_len); + } + + if (ses->server) { + if (ses->server->sec_mode & + (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) + pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; + } + + pSMB->hdr.Uid = ses->Suid; + + params = 2 /* level */ + name_len /*includes null */ ; + pSMB->TotalDataCount = 0; + pSMB->DataCount = 0; + pSMB->DataOffset = 0; + pSMB->MaxParameterCount = 0; + /* BB find exact max SMB PDU from sess structure BB */ + pSMB->MaxDataCount = cpu_to_le16(4000); + pSMB->MaxSetupCount = 0; + pSMB->Reserved = 0; + pSMB->Flags = 0; + pSMB->Timeout = 0; + pSMB->Reserved2 = 0; + pSMB->ParameterOffset = cpu_to_le16(offsetof( + struct smb_com_transaction2_get_dfs_refer_req, MaxReferralLevel) - 4); + pSMB->SetupCount = 1; + pSMB->Reserved3 = 0; + pSMB->SubCommand = cpu_to_le16(TRANS2_GET_DFS_REFERRAL); + byte_count = params + 3 /* pad */ ; + pSMB->ParameterCount = cpu_to_le16(params); + pSMB->TotalParameterCount = pSMB->ParameterCount; + pSMB->MaxReferralLevel = cpu_to_le16(3); + inc_rfc1001_len(pSMB, byte_count); + pSMB->ByteCount = cpu_to_le16(byte_count); + + rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, + (struct smb_hdr *) pSMBr, &bytes_returned, 0); + if (rc) { + cFYI(1, ""Send error in GetDFSRefer = %d"", rc); + goto GetDFSRefExit; + } + rc = validate_t2((struct smb_t2_rsp *)pSMBr); + + /* BB Also check if enough total bytes returned? */ + if (rc || get_bcc(&pSMBr->hdr) < 17) { + rc = -EIO; /* bad smb */ + goto GetDFSRefExit; + } + + cFYI(1, ""Decoding GetDFSRefer response BCC: %d Offset %d"", + get_bcc(&pSMBr->hdr), + le16_to_cpu(pSMBr->t2.DataOffset)); + + /* parse returned result into more usable form */ + rc = parse_DFS_referrals(pSMBr, num_of_nodes, + target_nodes, nls_codepage, remap, + searchName); + +GetDFSRefExit: + cifs_buf_release(pSMB); + + if (rc == -EAGAIN) + goto getDFSRetry; + + return rc; +} +","@@ -4079,7 +4079,8 @@ int CIFSFindNext(const int xid, struct cifs_tcon *tcon, + T2_FNEXT_RSP_PARMS *parms; + char *response_data; + int rc = 0; +- int bytes_returned, name_len; ++ int bytes_returned; ++ unsigned int name_len; + __u16 params, byte_count; + + cFYI(1, ""In FindNext"");",1094,1330,2048 +2372,"static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const struct nfs_server *server) +{ + char owner_name[IDMAP_NAMESZ]; + char owner_group[IDMAP_NAMESZ]; + int owner_namelen = 0; + int owner_grouplen = 0; + __be32 *p; + __be32 *q; + int len; + uint32_t bmval0 = 0; + uint32_t bmval1 = 0; + int status; + + /* + * We reserve enough space to write the entire attribute buffer at once. + * In the worst-case, this would be + * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) + * = 36 bytes, plus any contribution from variable-length fields + * such as owner/group. + */ + len = 16; + + /* Sigh */ + if (iap->ia_valid & ATTR_SIZE) + len += 8; + if (iap->ia_valid & ATTR_MODE) + len += 4; + if (iap->ia_valid & ATTR_UID) { + owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name); + if (owner_namelen < 0) { + dprintk(""nfs: couldn't resolve uid %d to string\n"", + iap->ia_uid); + /* XXX */ + strcpy(owner_name, ""nobody""); + owner_namelen = sizeof(""nobody"") - 1; + /* goto out; */ + } + len += 4 + (XDR_QUADLEN(owner_namelen) << 2); + } + if (iap->ia_valid & ATTR_GID) { + owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group); + if (owner_grouplen < 0) { + dprintk(""nfs: couldn't resolve gid %d to string\n"", + iap->ia_gid); + strcpy(owner_group, ""nobody""); + owner_grouplen = sizeof(""nobody"") - 1; + /* goto out; */ + } + len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); + } + if (iap->ia_valid & ATTR_ATIME_SET) + len += 16; + else if (iap->ia_valid & ATTR_ATIME) + len += 4; + if (iap->ia_valid & ATTR_MTIME_SET) + len += 16; + else if (iap->ia_valid & ATTR_MTIME) + len += 4; + RESERVE_SPACE(len); + + /* + * We write the bitmap length now, but leave the bitmap and the attribute + * buffer length to be backfilled at the end of this routine. + */ + WRITE32(2); + q = p; + p += 3; + + if (iap->ia_valid & ATTR_SIZE) { + bmval0 |= FATTR4_WORD0_SIZE; + WRITE64(iap->ia_size); + } + if (iap->ia_valid & ATTR_MODE) { + bmval1 |= FATTR4_WORD1_MODE; + WRITE32(iap->ia_mode & S_IALLUGO); + } + if (iap->ia_valid & ATTR_UID) { + bmval1 |= FATTR4_WORD1_OWNER; + WRITE32(owner_namelen); + WRITEMEM(owner_name, owner_namelen); + } + if (iap->ia_valid & ATTR_GID) { + bmval1 |= FATTR4_WORD1_OWNER_GROUP; + WRITE32(owner_grouplen); + WRITEMEM(owner_group, owner_grouplen); + } + if (iap->ia_valid & ATTR_ATIME_SET) { + bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; + WRITE32(NFS4_SET_TO_CLIENT_TIME); + WRITE32(0); + WRITE32(iap->ia_mtime.tv_sec); + WRITE32(iap->ia_mtime.tv_nsec); + } + else if (iap->ia_valid & ATTR_ATIME) { + bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; + WRITE32(NFS4_SET_TO_SERVER_TIME); + } + if (iap->ia_valid & ATTR_MTIME_SET) { + bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; + WRITE32(NFS4_SET_TO_CLIENT_TIME); + WRITE32(0); + WRITE32(iap->ia_mtime.tv_sec); + WRITE32(iap->ia_mtime.tv_nsec); + } + else if (iap->ia_valid & ATTR_MTIME) { + bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; + WRITE32(NFS4_SET_TO_SERVER_TIME); + } + + /* + * Now we backfill the bitmap and the attribute buffer length. + */ + if (len != ((char *)p - (char *)q) + 4) { + printk(KERN_ERR ""nfs: Attr length error, %u != %Zu\n"", + len, ((char *)p - (char *)q) + 4); + BUG(); + } + len = (char *)p - (char *)q - 12; + *q++ = htonl(bmval0); + *q++ = htonl(bmval1); + *q++ = htonl(len); + + status = 0; +/* out: */ + return status; +} +",0,"static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const struct nfs_server *server) +{ + char owner_name[IDMAP_NAMESZ]; + char owner_group[IDMAP_NAMESZ]; + int owner_namelen = 0; + int owner_grouplen = 0; + __be32 *p; + __be32 *q; + int len; + uint32_t bmval0 = 0; + uint32_t bmval1 = 0; + int status; + + /* + * We reserve enough space to write the entire attribute buffer at once. + * In the worst-case, this would be + * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) + * = 36 bytes, plus any contribution from variable-length fields + * such as owner/group. + */ + len = 16; + + /* Sigh */ + if (iap->ia_valid & ATTR_SIZE) + len += 8; + if (iap->ia_valid & ATTR_MODE) + len += 4; + if (iap->ia_valid & ATTR_UID) { + owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name); + if (owner_namelen < 0) { + dprintk(""nfs: couldn't resolve uid %d to string\n"", + iap->ia_uid); + /* XXX */ + strcpy(owner_name, ""nobody""); + owner_namelen = sizeof(""nobody"") - 1; + /* goto out; */ + } + len += 4 + (XDR_QUADLEN(owner_namelen) << 2); + } + if (iap->ia_valid & ATTR_GID) { + owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group); + if (owner_grouplen < 0) { + dprintk(""nfs: couldn't resolve gid %d to string\n"", + iap->ia_gid); + strcpy(owner_group, ""nobody""); + owner_grouplen = sizeof(""nobody"") - 1; + /* goto out; */ + } + len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); + } + if (iap->ia_valid & ATTR_ATIME_SET) + len += 16; + else if (iap->ia_valid & ATTR_ATIME) + len += 4; + if (iap->ia_valid & ATTR_MTIME_SET) + len += 16; + else if (iap->ia_valid & ATTR_MTIME) + len += 4; + RESERVE_SPACE(len); + + /* + * We write the bitmap length now, but leave the bitmap and the attribute + * buffer length to be backfilled at the end of this routine. + */ + WRITE32(2); + q = p; + p += 3; + + if (iap->ia_valid & ATTR_SIZE) { + bmval0 |= FATTR4_WORD0_SIZE; + WRITE64(iap->ia_size); + } + if (iap->ia_valid & ATTR_MODE) { + bmval1 |= FATTR4_WORD1_MODE; + WRITE32(iap->ia_mode & S_IALLUGO); + } + if (iap->ia_valid & ATTR_UID) { + bmval1 |= FATTR4_WORD1_OWNER; + WRITE32(owner_namelen); + WRITEMEM(owner_name, owner_namelen); + } + if (iap->ia_valid & ATTR_GID) { + bmval1 |= FATTR4_WORD1_OWNER_GROUP; + WRITE32(owner_grouplen); + WRITEMEM(owner_group, owner_grouplen); + } + if (iap->ia_valid & ATTR_ATIME_SET) { + bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; + WRITE32(NFS4_SET_TO_CLIENT_TIME); + WRITE32(0); + WRITE32(iap->ia_mtime.tv_sec); + WRITE32(iap->ia_mtime.tv_nsec); + } + else if (iap->ia_valid & ATTR_ATIME) { + bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; + WRITE32(NFS4_SET_TO_SERVER_TIME); + } + if (iap->ia_valid & ATTR_MTIME_SET) { + bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; + WRITE32(NFS4_SET_TO_CLIENT_TIME); + WRITE32(0); + WRITE32(iap->ia_mtime.tv_sec); + WRITE32(iap->ia_mtime.tv_nsec); + } + else if (iap->ia_valid & ATTR_MTIME) { + bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; + WRITE32(NFS4_SET_TO_SERVER_TIME); + } + + /* + * Now we backfill the bitmap and the attribute buffer length. + */ + if (len != ((char *)p - (char *)q) + 4) { + printk(KERN_ERR ""nfs: Attr length error, %u != %Zu\n"", + len, ((char *)p - (char *)q) + 4); + BUG(); + } + len = (char *)p - (char *)q - 12; + *q++ = htonl(bmval0); + *q++ = htonl(bmval1); + *q++ = htonl(len); + + status = 0; +/* out: */ + return status; +} +","@@ -953,12 +953,12 @@ static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name) + return 0; + } + +-static void encode_share_access(struct xdr_stream *xdr, int open_flags) ++static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) + { + __be32 *p; + + RESERVE_SPACE(8); +- switch (open_flags & (FMODE_READ|FMODE_WRITE)) { ++ switch (fmode & (FMODE_READ|FMODE_WRITE)) { + case FMODE_READ: + WRITE32(NFS4_SHARE_ACCESS_READ); + break; +@@ -969,7 +969,7 @@ static void encode_share_access(struct xdr_stream *xdr, int open_flags) + WRITE32(NFS4_SHARE_ACCESS_BOTH); + break; + default: +- BUG(); ++ WRITE32(0); + } + WRITE32(0); /* for linux, share_deny = 0 always */ + } +@@ -984,7 +984,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena + RESERVE_SPACE(8); + WRITE32(OP_OPEN); + WRITE32(arg->seqid->sequence->counter); +- encode_share_access(xdr, arg->open_flags); ++ encode_share_access(xdr, arg->fmode); + RESERVE_SPACE(28); + WRITE64(arg->clientid); + WRITE32(16); +@@ -1112,7 +1112,7 @@ static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closea + WRITE32(OP_OPEN_DOWNGRADE); + WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE); + WRITE32(arg->seqid->sequence->counter); +- encode_share_access(xdr, arg->open_flags); ++ encode_share_access(xdr, arg->fmode); + return 0; + } + ",1202,1438,2048 +7911,"int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int delete) +{ + struct Buffer cmd, sync_cmd; + char mbox[PATH_MAX]; + char mmbox[PATH_MAX]; + char prompt[PATH_MAX + 64]; + int rc; + struct ImapMbox mx; + int err_continue = MUTT_NO; + int triedcreate = 0; + + struct ImapData *idata = ctx->data; + + if (imap_parse_path(dest, &mx)) + { + mutt_debug(1, ""bad destination %s\n"", dest); + return -1; + } + + /* check that the save-to folder is in the same account */ + if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0) + { + mutt_debug(3, ""%s not same server as %s\n"", dest, ctx->path); + return 1; + } + + if (h && h->attach_del) + { + mutt_debug(3, ""#1 Message contains attachments to be deleted\n""); + return 1; + } + + imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox)); + if (!*mbox) + mutt_str_strfcpy(mbox, ""INBOX"", sizeof(mbox)); + imap_munge_mbox_name(idata, mmbox, sizeof(mmbox), mbox); + + /* loop in case of TRYCREATE */ + do + { + mutt_buffer_init(&sync_cmd); + mutt_buffer_init(&cmd); + + /* Null Header* means copy tagged messages */ + if (!h) + { + /* if any messages have attachments to delete, fall through to FETCH + * and APPEND. TODO: Copy what we can with COPY, fall through for the + * remainder. */ + for (int i = 0; i < ctx->msgcount; i++) + { + if (!message_is_tagged(ctx, i)) + continue; + + if (ctx->hdrs[i]->attach_del) + { + mutt_debug(3, ""#2 Message contains attachments to be deleted\n""); + return 1; + } + + if (ctx->hdrs[i]->active && ctx->hdrs[i]->changed) + { + rc = imap_sync_message_for_copy(idata, ctx->hdrs[i], &sync_cmd, &err_continue); + if (rc < 0) + { + mutt_debug(1, ""#1 could not sync\n""); + goto out; + } + } + } + + rc = imap_exec_msgset(idata, ""UID COPY"", mmbox, MUTT_TAG, 0, 0); + if (!rc) + { + mutt_debug(1, ""No messages tagged\n""); + rc = -1; + goto out; + } + else if (rc < 0) + { + mutt_debug(1, ""#1 could not queue copy\n""); + goto out; + } + else + { + mutt_message(ngettext(""Copying %d message to %s..."", ""Copying %d messages to %s..."", rc), + rc, mbox); + } + } + else + { + mutt_message(_(""Copying message %d to %s...""), h->index + 1, mbox); + mutt_buffer_printf(&cmd, ""UID COPY %u %s"", HEADER_DATA(h)->uid, mmbox); + + if (h->active && h->changed) + { + rc = imap_sync_message_for_copy(idata, h, &sync_cmd, &err_continue); + if (rc < 0) + { + mutt_debug(1, ""#2 could not sync\n""); + goto out; + } + } + rc = imap_exec(idata, cmd.data, IMAP_CMD_QUEUE); + if (rc < 0) + { + mutt_debug(1, ""#2 could not queue copy\n""); + goto out; + } + } + + /* let's get it on */ + rc = imap_exec(idata, NULL, IMAP_CMD_FAIL_OK); + if (rc == -2) + { + if (triedcreate) + { + mutt_debug(1, ""Already tried to create mailbox %s\n"", mbox); + break; + } + /* bail out if command failed for reasons other than nonexistent target */ + if (mutt_str_strncasecmp(imap_get_qualifier(idata->buf), ""[TRYCREATE]"", 11) != 0) + break; + mutt_debug(3, ""server suggests TRYCREATE\n""); + snprintf(prompt, sizeof(prompt), _(""Create %s?""), mbox); + if (Confirmcreate && mutt_yesorno(prompt, 1) != MUTT_YES) + { + mutt_clear_error(); + goto out; + } + if (imap_create_mailbox(idata, mbox) < 0) + break; + triedcreate = 1; + } + } while (rc == -2); + + if (rc != 0) + { + imap_error(""imap_copy_messages"", idata->buf); + goto out; + } + + /* cleanup */ + if (delete) + { + if (!h) + { + for (int i = 0; i < ctx->msgcount; i++) + { + if (!message_is_tagged(ctx, i)) + continue; + + mutt_set_flag(ctx, ctx->hdrs[i], MUTT_DELETE, 1); + mutt_set_flag(ctx, ctx->hdrs[i], MUTT_PURGE, 1); + if (DeleteUntag) + mutt_set_flag(ctx, ctx->hdrs[i], MUTT_TAG, 0); + } + } + else + { + mutt_set_flag(ctx, h, MUTT_DELETE, 1); + mutt_set_flag(ctx, h, MUTT_PURGE, 1); + if (DeleteUntag) + mutt_set_flag(ctx, h, MUTT_TAG, 0); + } + } + + rc = 0; + +out: + if (cmd.data) + FREE(&cmd.data); + if (sync_cmd.data) + FREE(&sync_cmd.data); + FREE(&mx.mbox); + + return (rc < 0) ? -1 : rc; +} +",0,"int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int delete) +{ + struct Buffer cmd, sync_cmd; + char mbox[PATH_MAX]; + char mmbox[PATH_MAX]; + char prompt[PATH_MAX + 64]; + int rc; + struct ImapMbox mx; + int err_continue = MUTT_NO; + int triedcreate = 0; + + struct ImapData *idata = ctx->data; + + if (imap_parse_path(dest, &mx)) + { + mutt_debug(1, ""bad destination %s\n"", dest); + return -1; + } + + /* check that the save-to folder is in the same account */ + if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0) + { + mutt_debug(3, ""%s not same server as %s\n"", dest, ctx->path); + return 1; + } + + if (h && h->attach_del) + { + mutt_debug(3, ""#1 Message contains attachments to be deleted\n""); + return 1; + } + + imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox)); + if (!*mbox) + mutt_str_strfcpy(mbox, ""INBOX"", sizeof(mbox)); + imap_munge_mbox_name(idata, mmbox, sizeof(mmbox), mbox); + + /* loop in case of TRYCREATE */ + do + { + mutt_buffer_init(&sync_cmd); + mutt_buffer_init(&cmd); + + /* Null Header* means copy tagged messages */ + if (!h) + { + /* if any messages have attachments to delete, fall through to FETCH + * and APPEND. TODO: Copy what we can with COPY, fall through for the + * remainder. */ + for (int i = 0; i < ctx->msgcount; i++) + { + if (!message_is_tagged(ctx, i)) + continue; + + if (ctx->hdrs[i]->attach_del) + { + mutt_debug(3, ""#2 Message contains attachments to be deleted\n""); + return 1; + } + + if (ctx->hdrs[i]->active && ctx->hdrs[i]->changed) + { + rc = imap_sync_message_for_copy(idata, ctx->hdrs[i], &sync_cmd, &err_continue); + if (rc < 0) + { + mutt_debug(1, ""#1 could not sync\n""); + goto out; + } + } + } + + rc = imap_exec_msgset(idata, ""UID COPY"", mmbox, MUTT_TAG, 0, 0); + if (!rc) + { + mutt_debug(1, ""No messages tagged\n""); + rc = -1; + goto out; + } + else if (rc < 0) + { + mutt_debug(1, ""#1 could not queue copy\n""); + goto out; + } + else + { + mutt_message(ngettext(""Copying %d message to %s..."", ""Copying %d messages to %s..."", rc), + rc, mbox); + } + } + else + { + mutt_message(_(""Copying message %d to %s...""), h->index + 1, mbox); + mutt_buffer_printf(&cmd, ""UID COPY %u %s"", HEADER_DATA(h)->uid, mmbox); + + if (h->active && h->changed) + { + rc = imap_sync_message_for_copy(idata, h, &sync_cmd, &err_continue); + if (rc < 0) + { + mutt_debug(1, ""#2 could not sync\n""); + goto out; + } + } + rc = imap_exec(idata, cmd.data, IMAP_CMD_QUEUE); + if (rc < 0) + { + mutt_debug(1, ""#2 could not queue copy\n""); + goto out; + } + } + + /* let's get it on */ + rc = imap_exec(idata, NULL, IMAP_CMD_FAIL_OK); + if (rc == -2) + { + if (triedcreate) + { + mutt_debug(1, ""Already tried to create mailbox %s\n"", mbox); + break; + } + /* bail out if command failed for reasons other than nonexistent target */ + if (mutt_str_strncasecmp(imap_get_qualifier(idata->buf), ""[TRYCREATE]"", 11) != 0) + break; + mutt_debug(3, ""server suggests TRYCREATE\n""); + snprintf(prompt, sizeof(prompt), _(""Create %s?""), mbox); + if (Confirmcreate && mutt_yesorno(prompt, 1) != MUTT_YES) + { + mutt_clear_error(); + goto out; + } + if (imap_create_mailbox(idata, mbox) < 0) + break; + triedcreate = 1; + } + } while (rc == -2); + + if (rc != 0) + { + imap_error(""imap_copy_messages"", idata->buf); + goto out; + } + + /* cleanup */ + if (delete) + { + if (!h) + { + for (int i = 0; i < ctx->msgcount; i++) + { + if (!message_is_tagged(ctx, i)) + continue; + + mutt_set_flag(ctx, ctx->hdrs[i], MUTT_DELETE, 1); + mutt_set_flag(ctx, ctx->hdrs[i], MUTT_PURGE, 1); + if (DeleteUntag) + mutt_set_flag(ctx, ctx->hdrs[i], MUTT_TAG, 0); + } + } + else + { + mutt_set_flag(ctx, h, MUTT_DELETE, 1); + mutt_set_flag(ctx, h, MUTT_PURGE, 1); + if (DeleteUntag) + mutt_set_flag(ctx, h, MUTT_TAG, 0); + } + } + + rc = 0; + +out: + if (cmd.data) + FREE(&cmd.data); + if (sync_cmd.data) + FREE(&sync_cmd.data); + FREE(&mx.mbox); + + return (rc < 0) ? -1 : rc; +} +","@@ -330,7 +330,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) + } + s++; + ptmp = tmp; +- while (*s && *s != '\""') ++ while (*s && (*s != '\""') && (ptmp != (tmp + sizeof(tmp) - 1))) + *ptmp++ = *s++; + if (*s != '\""') + return -1; +@@ -343,7 +343,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) + s += 11; + SKIPWS(s); + ptmp = tmp; +- while (isdigit((unsigned char) *s)) ++ while (isdigit((unsigned char) *s) && (ptmp != (tmp + sizeof(tmp) - 1))) + *ptmp++ = *s++; + *ptmp = '\0'; + if (mutt_str_atol(tmp, &h->content_length) < 0)",1327,1563,2048 +9377,"xfs_do_writepage( + struct page *page, + struct writeback_control *wbc, + void *data) +{ + struct xfs_writepage_ctx *wpc = data; + struct inode *inode = page->mapping->host; + loff_t offset; + __uint64_t end_offset; + pgoff_t end_index; + + trace_xfs_writepage(inode, page, 0, 0); + + ASSERT(page_has_buffers(page)); + + /* + * Refuse to write the page out if we are called from reclaim context. + * + * This avoids stack overflows when called from deeply used stacks in + * random callers for direct reclaim or memcg reclaim. We explicitly + * allow reclaim from kswapd as the stack usage there is relatively low. + * + * This should never happen except in the case of a VM regression so + * warn about it. + */ + if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == + PF_MEMALLOC)) + goto redirty; + + /* + * Given that we do not allow direct reclaim to call us, we should + * never be called while in a filesystem transaction. + */ + if (WARN_ON_ONCE(current->flags & PF_FSTRANS)) + goto redirty; + + /* + * Is this page beyond the end of the file? + * + * The page index is less than the end_index, adjust the end_offset + * to the highest offset that this page should represent. + * ----------------------------------------------------- + * | file mapping | | + * ----------------------------------------------------- + * | Page ... | Page N-2 | Page N-1 | Page N | | + * ^--------------------------------^----------|-------- + * | desired writeback range | see else | + * ---------------------------------^------------------| + */ + offset = i_size_read(inode); + end_index = offset >> PAGE_SHIFT; + if (page->index < end_index) + end_offset = (xfs_off_t)(page->index + 1) << PAGE_SHIFT; + else { + /* + * Check whether the page to write out is beyond or straddles + * i_size or not. + * ------------------------------------------------------- + * | file mapping | | + * ------------------------------------------------------- + * | Page ... | Page N-2 | Page N-1 | Page N | Beyond | + * ^--------------------------------^-----------|--------- + * | | Straddles | + * ---------------------------------^-----------|--------| + */ + unsigned offset_into_page = offset & (PAGE_SIZE - 1); + + /* + * Skip the page if it is fully outside i_size, e.g. due to a + * truncate operation that is in progress. We must redirty the + * page so that reclaim stops reclaiming it. Otherwise + * xfs_vm_releasepage() is called on it and gets confused. + * + * Note that the end_index is unsigned long, it would overflow + * if the given offset is greater than 16TB on 32-bit system + * and if we do check the page is fully outside i_size or not + * via ""if (page->index >= end_index + 1)"" as ""end_index + 1"" + * will be evaluated to 0. Hence this page will be redirtied + * and be written out repeatedly which would result in an + * infinite loop, the user program that perform this operation + * will hang. Instead, we can verify this situation by checking + * if the page to write is totally beyond the i_size or if it's + * offset is just equal to the EOF. + */ + if (page->index > end_index || + (page->index == end_index && offset_into_page == 0)) + goto redirty; + + /* + * The page straddles i_size. It must be zeroed out on each + * and every writepage invocation because it may be mmapped. + * ""A file is mapped in multiples of the page size. For a file + * that is not a multiple of the page size, the remaining + * memory is zeroed when mapped, and writes to that region are + * not written out to the file."" + */ + zero_user_segment(page, offset_into_page, PAGE_SIZE); + + /* Adjust the end_offset to the end of file */ + end_offset = offset; + } + + return xfs_writepage_map(wpc, wbc, inode, page, offset, end_offset); + +redirty: + redirty_page_for_writepage(wbc, page); + unlock_page(page); + return 0; +} +",0,"xfs_do_writepage( + struct page *page, + struct writeback_control *wbc, + void *data) +{ + struct xfs_writepage_ctx *wpc = data; + struct inode *inode = page->mapping->host; + loff_t offset; + __uint64_t end_offset; + pgoff_t end_index; + + trace_xfs_writepage(inode, page, 0, 0); + + ASSERT(page_has_buffers(page)); + + /* + * Refuse to write the page out if we are called from reclaim context. + * + * This avoids stack overflows when called from deeply used stacks in + * random callers for direct reclaim or memcg reclaim. We explicitly + * allow reclaim from kswapd as the stack usage there is relatively low. + * + * This should never happen except in the case of a VM regression so + * warn about it. + */ + if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == + PF_MEMALLOC)) + goto redirty; + + /* + * Given that we do not allow direct reclaim to call us, we should + * never be called while in a filesystem transaction. + */ + if (WARN_ON_ONCE(current->flags & PF_FSTRANS)) + goto redirty; + + /* + * Is this page beyond the end of the file? + * + * The page index is less than the end_index, adjust the end_offset + * to the highest offset that this page should represent. + * ----------------------------------------------------- + * | file mapping | | + * ----------------------------------------------------- + * | Page ... | Page N-2 | Page N-1 | Page N | | + * ^--------------------------------^----------|-------- + * | desired writeback range | see else | + * ---------------------------------^------------------| + */ + offset = i_size_read(inode); + end_index = offset >> PAGE_SHIFT; + if (page->index < end_index) + end_offset = (xfs_off_t)(page->index + 1) << PAGE_SHIFT; + else { + /* + * Check whether the page to write out is beyond or straddles + * i_size or not. + * ------------------------------------------------------- + * | file mapping | | + * ------------------------------------------------------- + * | Page ... | Page N-2 | Page N-1 | Page N | Beyond | + * ^--------------------------------^-----------|--------- + * | | Straddles | + * ---------------------------------^-----------|--------| + */ + unsigned offset_into_page = offset & (PAGE_SIZE - 1); + + /* + * Skip the page if it is fully outside i_size, e.g. due to a + * truncate operation that is in progress. We must redirty the + * page so that reclaim stops reclaiming it. Otherwise + * xfs_vm_releasepage() is called on it and gets confused. + * + * Note that the end_index is unsigned long, it would overflow + * if the given offset is greater than 16TB on 32-bit system + * and if we do check the page is fully outside i_size or not + * via ""if (page->index >= end_index + 1)"" as ""end_index + 1"" + * will be evaluated to 0. Hence this page will be redirtied + * and be written out repeatedly which would result in an + * infinite loop, the user program that perform this operation + * will hang. Instead, we can verify this situation by checking + * if the page to write is totally beyond the i_size or if it's + * offset is just equal to the EOF. + */ + if (page->index > end_index || + (page->index == end_index && offset_into_page == 0)) + goto redirty; + + /* + * The page straddles i_size. It must be zeroed out on each + * and every writepage invocation because it may be mmapped. + * ""A file is mapped in multiples of the page size. For a file + * that is not a multiple of the page size, the remaining + * memory is zeroed when mapped, and writes to that region are + * not written out to the file."" + */ + zero_user_segment(page, offset_into_page, PAGE_SIZE); + + /* Adjust the end_offset to the end of file */ + end_offset = offset; + } + + return xfs_writepage_map(wpc, wbc, inode, page, offset, end_offset); + +redirty: + redirty_page_for_writepage(wbc, page); + unlock_page(page); + return 0; +} +","@@ -1361,6 +1361,26 @@ __xfs_get_blocks( + if (error) + goto out_unlock; + ++ /* ++ * The only time we can ever safely find delalloc blocks on direct I/O ++ * is a dio write to post-eof speculative preallocation. All other ++ * scenarios are indicative of a problem or misuse (such as mixing ++ * direct and mapped I/O). ++ * ++ * The file may be unmapped by the time we get here so we cannot ++ * reliably fail the I/O based on mapping. Instead, fail the I/O if this ++ * is a read or a write within eof. Otherwise, carry on but warn as a ++ * precuation if the file happens to be mapped. ++ */ ++ if (direct && imap.br_startblock == DELAYSTARTBLOCK) { ++ if (!create || offset < i_size_read(VFS_I(ip))) { ++ WARN_ON_ONCE(1); ++ error = -EIO; ++ goto out_unlock; ++ } ++ WARN_ON_ONCE(mapping_mapped(VFS_I(ip)->i_mapping)); ++ } ++ + /* for DAX, we convert unwritten extents directly */ + if (create && + (!nimaps || +@@ -1450,8 +1470,6 @@ __xfs_get_blocks( + (new || ISUNWRITTEN(&imap)))) + set_buffer_new(bh_result); + +- BUG_ON(direct && imap.br_startblock == DELAYSTARTBLOCK); +- + return 0; + + out_unlock:",1006,1242,2048 +493,"user_update_from_pwent (User *user, + struct passwd *pwent, + struct spwd *spent) +{ + g_autofree gchar *real_name = NULL; + gboolean is_system_account; + const gchar *passwd; + gboolean locked; + PasswordMode mode; + AccountType account_type; + + g_object_freeze_notify (G_OBJECT (user)); + + if (pwent->pw_gecos && pwent->pw_gecos[0] != '\0') { + gchar *first_comma = NULL; + gchar *valid_utf8_name = NULL; + + if (g_utf8_validate (pwent->pw_gecos, -1, NULL)) { + valid_utf8_name = pwent->pw_gecos; + first_comma = g_utf8_strchr (valid_utf8_name, -1, ','); + } + else { + g_warning (""User %s has invalid UTF-8 in GECOS field. "" + ""It would be a good thing to check /etc/passwd."", + pwent->pw_name ? pwent->pw_name : """"); + } + + if (first_comma) { + real_name = g_strndup (valid_utf8_name, + (first_comma - valid_utf8_name)); + } + else if (valid_utf8_name) { + real_name = g_strdup (valid_utf8_name); + } + else { + real_name = NULL; + } + + if (real_name && real_name[0] == '\0') { + g_clear_pointer (&real_name, g_free); + } + } + else { + real_name = NULL; + } + + accounts_user_set_real_name (ACCOUNTS_USER (user), real_name); + accounts_user_set_uid (ACCOUNTS_USER (user), pwent->pw_uid); + + user->gid = pwent->pw_gid; + + account_type = account_type_from_pwent (pwent); + accounts_user_set_account_type (ACCOUNTS_USER (user), account_type); + + accounts_user_set_user_name (ACCOUNTS_USER (user), pwent->pw_name); + accounts_user_set_home_directory (ACCOUNTS_USER (user), pwent->pw_dir); + user_reset_icon_file (user); + + accounts_user_set_shell (ACCOUNTS_USER (user), pwent->pw_shell); + + passwd = NULL; + if (spent) + passwd = spent->sp_pwdp; + + if (passwd && passwd[0] == '!') { + locked = TRUE; + } + else { + locked = FALSE; + } + + accounts_user_set_locked (ACCOUNTS_USER (user), locked); + + if (passwd == NULL || passwd[0] != 0) { + mode = PASSWORD_MODE_REGULAR; + } + else { + mode = PASSWORD_MODE_NONE; + } + + if (spent) { + if (spent->sp_lstchg == 0) { + mode = PASSWORD_MODE_SET_AT_LOGIN; + } + + user->expiration_time = spent->sp_expire; + user->last_change_time = spent->sp_lstchg; + user->min_days_between_changes = spent->sp_min; + user->max_days_between_changes = spent->sp_max; + user->days_to_warn = spent->sp_warn; + user->days_after_expiration_until_lock = spent->sp_inact; + user->account_expiration_policy_known = TRUE; + } + + accounts_user_set_password_mode (ACCOUNTS_USER (user), mode); + is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)), + accounts_user_get_user_name (ACCOUNTS_USER (user)), + accounts_user_get_shell (ACCOUNTS_USER (user)), + passwd); + accounts_user_set_system_account (ACCOUNTS_USER (user), is_system_account); + + g_object_thaw_notify (G_OBJECT (user)); +} +",0,"user_update_from_pwent (User *user, + struct passwd *pwent, + struct spwd *spent) +{ + g_autofree gchar *real_name = NULL; + gboolean is_system_account; + const gchar *passwd; + gboolean locked; + PasswordMode mode; + AccountType account_type; + + g_object_freeze_notify (G_OBJECT (user)); + + if (pwent->pw_gecos && pwent->pw_gecos[0] != '\0') { + gchar *first_comma = NULL; + gchar *valid_utf8_name = NULL; + + if (g_utf8_validate (pwent->pw_gecos, -1, NULL)) { + valid_utf8_name = pwent->pw_gecos; + first_comma = g_utf8_strchr (valid_utf8_name, -1, ','); + } + else { + g_warning (""User %s has invalid UTF-8 in GECOS field. "" + ""It would be a good thing to check /etc/passwd."", + pwent->pw_name ? pwent->pw_name : """"); + } + + if (first_comma) { + real_name = g_strndup (valid_utf8_name, + (first_comma - valid_utf8_name)); + } + else if (valid_utf8_name) { + real_name = g_strdup (valid_utf8_name); + } + else { + real_name = NULL; + } + + if (real_name && real_name[0] == '\0') { + g_clear_pointer (&real_name, g_free); + } + } + else { + real_name = NULL; + } + + accounts_user_set_real_name (ACCOUNTS_USER (user), real_name); + accounts_user_set_uid (ACCOUNTS_USER (user), pwent->pw_uid); + + user->gid = pwent->pw_gid; + + account_type = account_type_from_pwent (pwent); + accounts_user_set_account_type (ACCOUNTS_USER (user), account_type); + + accounts_user_set_user_name (ACCOUNTS_USER (user), pwent->pw_name); + accounts_user_set_home_directory (ACCOUNTS_USER (user), pwent->pw_dir); + user_reset_icon_file (user); + + accounts_user_set_shell (ACCOUNTS_USER (user), pwent->pw_shell); + + passwd = NULL; + if (spent) + passwd = spent->sp_pwdp; + + if (passwd && passwd[0] == '!') { + locked = TRUE; + } + else { + locked = FALSE; + } + + accounts_user_set_locked (ACCOUNTS_USER (user), locked); + + if (passwd == NULL || passwd[0] != 0) { + mode = PASSWORD_MODE_REGULAR; + } + else { + mode = PASSWORD_MODE_NONE; + } + + if (spent) { + if (spent->sp_lstchg == 0) { + mode = PASSWORD_MODE_SET_AT_LOGIN; + } + + user->expiration_time = spent->sp_expire; + user->last_change_time = spent->sp_lstchg; + user->min_days_between_changes = spent->sp_min; + user->max_days_between_changes = spent->sp_max; + user->days_to_warn = spent->sp_warn; + user->days_after_expiration_until_lock = spent->sp_inact; + user->account_expiration_policy_known = TRUE; + } + + accounts_user_set_password_mode (ACCOUNTS_USER (user), mode); + is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)), + accounts_user_get_user_name (ACCOUNTS_USER (user)), + accounts_user_get_shell (ACCOUNTS_USER (user)), + passwd); + accounts_user_set_system_account (ACCOUNTS_USER (user), is_system_account); + + g_object_thaw_notify (G_OBJECT (user)); +} +","@@ -1334,6 +1334,14 @@ user_change_icon_file_authorized_cb (Daemon *daemon, + } + + file = g_file_new_for_path (filename); ++ g_clear_pointer (&filename, g_free); ++ ++ /* Canonicalize path so we can call g_str_has_prefix on it ++ * below without concern for ../ path components moving outside ++ * the prefix ++ */ ++ filename = g_file_get_path (file); ++ + info = g_file_query_info (file, G_FILE_ATTRIBUTE_UNIX_MODE "","" + G_FILE_ATTRIBUTE_STANDARD_TYPE "","" + G_FILE_ATTRIBUTE_STANDARD_SIZE,",801,1037,2048 +7238,"static Image *ReadTEXTImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + char + filename[MagickPathExtent], + geometry[MagickPathExtent], + *p, + text[MagickPathExtent]; + + DrawInfo + *draw_info; + + Image + *image, + *texture; + + MagickBooleanType + status; + + PointInfo + delta; + + RectangleInfo + page; + + ssize_t + offset; + + TypeMetric + metrics; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + (void) ResetMagickMemory(text,0,sizeof(text)); + (void) ReadBlobString(image,text); + /* + Set the page geometry. + */ + delta.x=DefaultResolution; + delta.y=DefaultResolution; + if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0)) + { + GeometryInfo + geometry_info; + + MagickStatusType + flags; + + flags=ParseGeometry(PSDensityGeometry,&geometry_info); + image->resolution.x=geometry_info.rho; + image->resolution.y=geometry_info.sigma; + if ((flags & SigmaValue) == 0) + image->resolution.y=image->resolution.x; + } + page.width=612; + page.height=792; + page.x=43; + page.y=43; + if (image_info->page != (char *) NULL) + (void) ParseAbsoluteGeometry(image_info->page,&page); + /* + Initialize Image structure. + */ + image->columns=(size_t) floor((((double) page.width*image->resolution.x)/ + delta.x)+0.5); + image->rows=(size_t) floor((((double) page.height*image->resolution.y)/ + delta.y)+0.5); + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + image->page.x=0; + image->page.y=0; + texture=(Image *) NULL; + if (image_info->texture != (char *) NULL) + { + ImageInfo + *read_info; + + read_info=CloneImageInfo(image_info); + SetImageInfoBlob(read_info,(void *) NULL,0); + (void) CopyMagickString(read_info->filename,image_info->texture, + MagickPathExtent); + texture=ReadImage(read_info,exception); + read_info=DestroyImageInfo(read_info); + } + /* + Annotate the text image. + */ + (void) SetImageBackgroundColor(image,exception); + draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); + (void) CloneString(&draw_info->text,image_info->filename); + (void) FormatLocaleString(geometry,MagickPathExtent,""%gx%g%+g%+g"",(double) + image->columns,(double) image->rows,(double) page.x,(double) page.y); + (void) CloneString(&draw_info->geometry,geometry); + status=GetTypeMetrics(image,draw_info,&metrics,exception); + if (status == MagickFalse) + ThrowReaderException(TypeError,""UnableToGetTypeMetrics""); + page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5); + (void) FormatLocaleString(geometry,MagickPathExtent,""%gx%g%+g%+g"",(double) + image->columns,(double) image->rows,(double) page.x,(double) page.y); + (void) CloneString(&draw_info->geometry,geometry); + (void) CopyMagickString(filename,image_info->filename,MagickPathExtent); + if (*draw_info->text != '\0') + *draw_info->text='\0'; + p=text; + for (offset=2*page.y; p != (char *) NULL; ) + { + /* + Annotate image with text. + */ + (void) ConcatenateString(&draw_info->text,text); + (void) ConcatenateString(&draw_info->text,""\n""); + offset+=(ssize_t) (metrics.ascent-metrics.descent); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset, + image->rows); + if (status == MagickFalse) + break; + } + p=ReadBlobString(image,text); + if ((offset < (ssize_t) image->rows) && (p != (char *) NULL)) + continue; + if (texture != (Image *) NULL) + { + MagickProgressMonitor + progress_monitor; + + progress_monitor=SetImageProgressMonitor(image, + (MagickProgressMonitor) NULL,image->client_data); + (void) TextureImage(image,texture,exception); + (void) SetImageProgressMonitor(image,progress_monitor, + image->client_data); + } + (void) AnnotateImage(image,draw_info,exception); + if (p == (char *) NULL) + break; + /* + Page is full-- allocate next image structure. + */ + *draw_info->text='\0'; + offset=2*page.y; + AcquireNextImage(image_info,image,exception); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image->next->columns=image->columns; + image->next->rows=image->rows; + image=SyncNextImageInList(image); + (void) CopyMagickString(image->filename,filename,MagickPathExtent); + (void) SetImageBackgroundColor(image,exception); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + if (texture != (Image *) NULL) + { + MagickProgressMonitor + progress_monitor; + + progress_monitor=SetImageProgressMonitor(image, + (MagickProgressMonitor) NULL,image->client_data); + (void) TextureImage(image,texture,exception); + (void) SetImageProgressMonitor(image,progress_monitor,image->client_data); + } + (void) AnnotateImage(image,draw_info,exception); + if (texture != (Image *) NULL) + texture=DestroyImage(texture); + draw_info=DestroyDrawInfo(draw_info); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",0,"static Image *ReadTEXTImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + char + filename[MagickPathExtent], + geometry[MagickPathExtent], + *p, + text[MagickPathExtent]; + + DrawInfo + *draw_info; + + Image + *image, + *texture; + + MagickBooleanType + status; + + PointInfo + delta; + + RectangleInfo + page; + + ssize_t + offset; + + TypeMetric + metrics; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + (void) ResetMagickMemory(text,0,sizeof(text)); + (void) ReadBlobString(image,text); + /* + Set the page geometry. + */ + delta.x=DefaultResolution; + delta.y=DefaultResolution; + if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0)) + { + GeometryInfo + geometry_info; + + MagickStatusType + flags; + + flags=ParseGeometry(PSDensityGeometry,&geometry_info); + image->resolution.x=geometry_info.rho; + image->resolution.y=geometry_info.sigma; + if ((flags & SigmaValue) == 0) + image->resolution.y=image->resolution.x; + } + page.width=612; + page.height=792; + page.x=43; + page.y=43; + if (image_info->page != (char *) NULL) + (void) ParseAbsoluteGeometry(image_info->page,&page); + /* + Initialize Image structure. + */ + image->columns=(size_t) floor((((double) page.width*image->resolution.x)/ + delta.x)+0.5); + image->rows=(size_t) floor((((double) page.height*image->resolution.y)/ + delta.y)+0.5); + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + image->page.x=0; + image->page.y=0; + texture=(Image *) NULL; + if (image_info->texture != (char *) NULL) + { + ImageInfo + *read_info; + + read_info=CloneImageInfo(image_info); + SetImageInfoBlob(read_info,(void *) NULL,0); + (void) CopyMagickString(read_info->filename,image_info->texture, + MagickPathExtent); + texture=ReadImage(read_info,exception); + read_info=DestroyImageInfo(read_info); + } + /* + Annotate the text image. + */ + (void) SetImageBackgroundColor(image,exception); + draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); + (void) CloneString(&draw_info->text,image_info->filename); + (void) FormatLocaleString(geometry,MagickPathExtent,""%gx%g%+g%+g"",(double) + image->columns,(double) image->rows,(double) page.x,(double) page.y); + (void) CloneString(&draw_info->geometry,geometry); + status=GetTypeMetrics(image,draw_info,&metrics,exception); + if (status == MagickFalse) + ThrowReaderException(TypeError,""UnableToGetTypeMetrics""); + page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5); + (void) FormatLocaleString(geometry,MagickPathExtent,""%gx%g%+g%+g"",(double) + image->columns,(double) image->rows,(double) page.x,(double) page.y); + (void) CloneString(&draw_info->geometry,geometry); + (void) CopyMagickString(filename,image_info->filename,MagickPathExtent); + if (*draw_info->text != '\0') + *draw_info->text='\0'; + p=text; + for (offset=2*page.y; p != (char *) NULL; ) + { + /* + Annotate image with text. + */ + (void) ConcatenateString(&draw_info->text,text); + (void) ConcatenateString(&draw_info->text,""\n""); + offset+=(ssize_t) (metrics.ascent-metrics.descent); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset, + image->rows); + if (status == MagickFalse) + break; + } + p=ReadBlobString(image,text); + if ((offset < (ssize_t) image->rows) && (p != (char *) NULL)) + continue; + if (texture != (Image *) NULL) + { + MagickProgressMonitor + progress_monitor; + + progress_monitor=SetImageProgressMonitor(image, + (MagickProgressMonitor) NULL,image->client_data); + (void) TextureImage(image,texture,exception); + (void) SetImageProgressMonitor(image,progress_monitor, + image->client_data); + } + (void) AnnotateImage(image,draw_info,exception); + if (p == (char *) NULL) + break; + /* + Page is full-- allocate next image structure. + */ + *draw_info->text='\0'; + offset=2*page.y; + AcquireNextImage(image_info,image,exception); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image->next->columns=image->columns; + image->next->rows=image->rows; + image=SyncNextImageInList(image); + (void) CopyMagickString(image->filename,filename,MagickPathExtent); + (void) SetImageBackgroundColor(image,exception); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + if (texture != (Image *) NULL) + { + MagickProgressMonitor + progress_monitor; + + progress_monitor=SetImageProgressMonitor(image, + (MagickProgressMonitor) NULL,image->client_data); + (void) TextureImage(image,texture,exception); + (void) SetImageProgressMonitor(image,progress_monitor,image->client_data); + } + (void) AnnotateImage(image,draw_info,exception); + if (texture != (Image *) NULL) + texture=DestroyImage(texture); + draw_info=DestroyDrawInfo(draw_info); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -793,8 +793,7 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, + (void) WriteBlobString(image,buffer); + (void) CopyMagickString(tuple,""("",MagickPathExtent); + if (pixel.colorspace == GRAYColorspace) +- ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance, +- tuple); ++ ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,tuple); + else + { + ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple);",1516,1752,2048 +18099,"pimv1_join_prune_print(netdissect_options *ndo, + register const u_char *bp, register u_int len) +{ + int ngroups, njoin, nprune; + int njp; + + /* If it's a single group and a single source, use 1-line output. */ + if (ND_TTEST2(bp[0], 30) && bp[11] == 1 && + ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { + int hold; + + ND_PRINT((ndo, "" RPF %s "", ipaddr_string(ndo, bp))); + hold = EXTRACT_16BITS(&bp[6]); + if (hold != 180) { + ND_PRINT((ndo, ""Hold "")); + unsigned_relts_print(ndo, hold); + } + ND_PRINT((ndo, ""%s (%s/%d, %s"", njoin ? ""Join"" : ""Prune"", + ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f, + ipaddr_string(ndo, &bp[12]))); + if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) + ND_PRINT((ndo, ""/%s"", ipaddr_string(ndo, &bp[16]))); + ND_PRINT((ndo, "") %s%s %s"", + (bp[24] & 0x01) ? ""Sparse"" : ""Dense"", + (bp[25] & 0x80) ? "" WC"" : """", + (bp[25] & 0x40) ? ""RP"" : ""SPT"")); + return; + } + + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n"")); + ND_PRINT((ndo, "" Upstream Nbr: %s"", ipaddr_string(ndo, bp))); + ND_TCHECK2(bp[6], 2); + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n"")); + ND_PRINT((ndo, "" Hold time: "")); + unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[6])); + if (ndo->ndo_vflag < 2) + return; + bp += 8; + len -= 8; + + ND_TCHECK2(bp[0], 4); + ngroups = bp[3]; + bp += 4; + len -= 4; + while (ngroups--) { + /* + * XXX - does the address have length ""addrlen"" and the + * mask length ""maddrlen""? + */ + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\tGroup: %s"", ipaddr_string(ndo, bp))); + ND_TCHECK2(bp[4], sizeof(struct in_addr)); + if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) + ND_PRINT((ndo, ""/%s"", ipaddr_string(ndo, &bp[4]))); + ND_TCHECK2(bp[8], 4); + njoin = EXTRACT_16BITS(&bp[8]); + nprune = EXTRACT_16BITS(&bp[10]); + ND_PRINT((ndo, "" joined: %d pruned: %d"", njoin, nprune)); + bp += 12; + len -= 12; + for (njp = 0; njp < (njoin + nprune); njp++) { + const char *type; + + if (njp < njoin) + type = ""Join ""; + else + type = ""Prune""; + ND_TCHECK2(bp[0], 6); + ND_PRINT((ndo, ""\n\t%s %s%s%s%s/%d"", type, + (bp[0] & 0x01) ? ""Sparse "" : ""Dense "", + (bp[1] & 0x80) ? ""WC "" : """", + (bp[1] & 0x40) ? ""RP "" : ""SPT "", + ipaddr_string(ndo, &bp[2]), bp[1] & 0x3f)); + bp += 6; + len -= 6; + } + } + return; +trunc: + ND_PRINT((ndo, ""[|pim]"")); + return; +} +",1,"pimv1_join_prune_print(netdissect_options *ndo, + register const u_char *bp, register u_int len) +{ + int ngroups, njoin, nprune; + int njp; + + /* If it's a single group and a single source, use 1-line output. */ + if (ND_TTEST2(bp[0], 30) && bp[11] == 1 && + ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { + int hold; + + ND_PRINT((ndo, "" RPF %s "", ipaddr_string(ndo, bp))); + hold = EXTRACT_16BITS(&bp[6]); + if (hold != 180) { + ND_PRINT((ndo, ""Hold "")); + unsigned_relts_print(ndo, hold); + } + ND_PRINT((ndo, ""%s (%s/%d, %s"", njoin ? ""Join"" : ""Prune"", + ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f, + ipaddr_string(ndo, &bp[12]))); + if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) + ND_PRINT((ndo, ""/%s"", ipaddr_string(ndo, &bp[16]))); + ND_PRINT((ndo, "") %s%s %s"", + (bp[24] & 0x01) ? ""Sparse"" : ""Dense"", + (bp[25] & 0x80) ? "" WC"" : """", + (bp[25] & 0x40) ? ""RP"" : ""SPT"")); + return; + } + + if (len < sizeof(struct in_addr)) + goto trunc; + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n"")); + ND_PRINT((ndo, "" Upstream Nbr: %s"", ipaddr_string(ndo, bp))); + bp += 4; + len -= 4; + if (len < 4) + goto trunc; + ND_TCHECK2(bp[2], 2); + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n"")); + ND_PRINT((ndo, "" Hold time: "")); + unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2])); + if (ndo->ndo_vflag < 2) + return; + bp += 4; + len -= 4; + + if (len < 4) + goto trunc; + ND_TCHECK2(bp[0], 4); + ngroups = bp[3]; + bp += 4; + len -= 4; + while (ngroups--) { + /* + * XXX - does the address have length ""addrlen"" and the + * mask length ""maddrlen""? + */ + if (len < 4) + goto trunc; + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\tGroup: %s"", ipaddr_string(ndo, bp))); + bp += 4; + len -= 4; + if (len < 4) + goto trunc; + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + if (EXTRACT_32BITS(&bp[0]) != 0xffffffff) + ND_PRINT((ndo, ""/%s"", ipaddr_string(ndo, &bp[0]))); + bp += 4; + len -= 4; + if (len < 4) + goto trunc; + ND_TCHECK2(bp[0], 4); + njoin = EXTRACT_16BITS(&bp[0]); + nprune = EXTRACT_16BITS(&bp[2]); + ND_PRINT((ndo, "" joined: %d pruned: %d"", njoin, nprune)); + bp += 4; + len -= 4; + for (njp = 0; njp < (njoin + nprune); njp++) { + const char *type; + + if (njp < njoin) + type = ""Join ""; + else + type = ""Prune""; + if (len < 6) + goto trunc; + ND_TCHECK2(bp[0], 6); + ND_PRINT((ndo, ""\n\t%s %s%s%s%s/%d"", type, + (bp[0] & 0x01) ? ""Sparse "" : ""Dense "", + (bp[1] & 0x80) ? ""WC "" : """", + (bp[1] & 0x40) ? ""RP "" : ""SPT "", + ipaddr_string(ndo, &bp[2]), + bp[1] & 0x3f)); + bp += 6; + len -= 6; + } + } + return; +trunc: + ND_PRINT((ndo, ""[|pim]"")); + return; +} +","@@ -169,20 +169,28 @@ pimv1_join_prune_print(netdissect_options *ndo, + return; + } + ++ if (len < sizeof(struct in_addr)) ++ goto trunc; + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n"")); + ND_PRINT((ndo, "" Upstream Nbr: %s"", ipaddr_string(ndo, bp))); +- ND_TCHECK2(bp[6], 2); ++ bp += 4; ++ len -= 4; ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK2(bp[2], 2); + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n"")); + ND_PRINT((ndo, "" Hold time: "")); +- unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[6])); ++ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2])); + if (ndo->ndo_vflag < 2) + return; +- bp += 8; +- len -= 8; ++ bp += 4; ++ len -= 4; + ++ if (len < 4) ++ goto trunc; + ND_TCHECK2(bp[0], 4); + ngroups = bp[3]; + bp += 4; +@@ -192,30 +200,43 @@ pimv1_join_prune_print(netdissect_options *ndo, + * XXX - does the address have length ""addrlen"" and the + * mask length ""maddrlen""? + */ ++ if (len < 4) ++ goto trunc; + ND_TCHECK2(bp[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\tGroup: %s"", ipaddr_string(ndo, bp))); +- ND_TCHECK2(bp[4], sizeof(struct in_addr)); +- if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) +- ND_PRINT((ndo, ""/%s"", ipaddr_string(ndo, &bp[4]))); +- ND_TCHECK2(bp[8], 4); +- njoin = EXTRACT_16BITS(&bp[8]); +- nprune = EXTRACT_16BITS(&bp[10]); ++ bp += 4; ++ len -= 4; ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK2(bp[0], sizeof(struct in_addr)); ++ if (EXTRACT_32BITS(&bp[0]) != 0xffffffff) ++ ND_PRINT((ndo, ""/%s"", ipaddr_string(ndo, &bp[0]))); ++ bp += 4; ++ len -= 4; ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK2(bp[0], 4); ++ njoin = EXTRACT_16BITS(&bp[0]); ++ nprune = EXTRACT_16BITS(&bp[2]); + ND_PRINT((ndo, "" joined: %d pruned: %d"", njoin, nprune)); +- bp += 12; +- len -= 12; ++ bp += 4; ++ len -= 4; + for (njp = 0; njp < (njoin + nprune); njp++) { + const char *type; + + if (njp < njoin) + type = ""Join ""; + else + type = ""Prune""; ++ if (len < 6) ++ goto trunc; + ND_TCHECK2(bp[0], 6); + ND_PRINT((ndo, ""\n\t%s %s%s%s%s/%d"", type, + (bp[0] & 0x01) ? ""Sparse "" : ""Dense "", + (bp[1] & 0x80) ? ""WC "" : """", + (bp[1] & 0x40) ? ""RP "" : ""SPT "", +- ipaddr_string(ndo, &bp[2]), bp[1] & 0x3f)); ++ ipaddr_string(ndo, &bp[2]), ++ bp[1] & 0x3f)); + bp += 6; + len -= 6; + } +@@ -230,13 +251,8 @@ void + pimv1_print(netdissect_options *ndo, + register const u_char *bp, register u_int len) + { +- register const u_char *ep; + register u_char type; + +- ep = (const u_char *)ndo->ndo_snapend; +- if (bp >= ep) +- return; +- + ND_TCHECK(bp[1]); + type = bp[1]; + +@@ -302,8 +318,11 @@ pimv1_print(netdissect_options *ndo, + case PIMV1_TYPE_JOIN_PRUNE: + case PIMV1_TYPE_GRAFT: + case PIMV1_TYPE_GRAFT_ACK: +- if (ndo->ndo_vflag) ++ if (ndo->ndo_vflag) { ++ if (len < 8) ++ goto trunc; + pimv1_join_prune_print(ndo, &bp[8], len - 8); ++ } + break; + } + ND_TCHECK(bp[4]); +@@ -330,6 +349,8 @@ cisco_autorp_print(netdissect_options *ndo, + int numrps; + int hold; + ++ if (len < 8) ++ goto trunc; + ND_TCHECK(bp[0]); + ND_PRINT((ndo, "" auto-rp "")); + type = bp[0]; +@@ -377,10 +398,16 @@ cisco_autorp_print(netdissect_options *ndo, + int nentries; + char s; + ++ if (len < 4) ++ goto trunc; + ND_TCHECK2(bp[0], 4); + ND_PRINT((ndo, "" RP %s"", ipaddr_string(ndo, bp))); +- ND_TCHECK(bp[4]); +- switch (bp[4] & 0x3) { ++ bp += 4; ++ len -= 4; ++ if (len < 1) ++ goto trunc; ++ ND_TCHECK(bp[0]); ++ switch (bp[0] & 0x3) { + case 0: ND_PRINT((ndo, "" PIMv?"")); + break; + case 1: ND_PRINT((ndo, "" PIMv1"")); +@@ -390,13 +417,20 @@ cisco_autorp_print(netdissect_options *ndo, + case 3: ND_PRINT((ndo, "" PIMv1+2"")); + break; + } +- if (bp[4] & 0xfc) +- ND_PRINT((ndo, "" [rsvd=0x%02x]"", bp[4] & 0xfc)); +- ND_TCHECK(bp[5]); +- nentries = bp[5]; +- bp += 6; len -= 6; ++ if (bp[0] & 0xfc) ++ ND_PRINT((ndo, "" [rsvd=0x%02x]"", bp[0] & 0xfc)); ++ bp += 1; ++ len -= 1; ++ if (len < 1) ++ goto trunc; ++ ND_TCHECK(bp[0]); ++ nentries = bp[0]; ++ bp += 1; ++ len -= 1; + s = ' '; + for (; nentries; nentries--) { ++ if (len < 6) ++ goto trunc; + ND_TCHECK2(bp[0], 6); + ND_PRINT((ndo, ""%c%s%s/%d"", s, bp[0] & 1 ? ""!"" : """", + ipaddr_string(ndo, &bp[2]), bp[1])); +@@ -421,16 +455,13 @@ void + pim_print(netdissect_options *ndo, + register const u_char *bp, register u_int len, const u_char *bp2) + { +- register const u_char *ep; + register const struct pim *pim = (const struct pim *)bp; + +- ep = (const u_char *)ndo->ndo_snapend; +- if (bp >= ep) +- return; + #ifdef notyet /* currently we see only version and type */ + ND_TCHECK(pim->pim_rsv); + #endif + ++ ND_TCHECK(pim->pim_typever); + switch (PIM_VER(pim->pim_typever)) { + case 2: + if (!ndo->ndo_vflag) { +@@ -454,6 +485,10 @@ pim_print(netdissect_options *ndo, + break; + } + return; ++ ++trunc: ++ ND_PRINT((ndo, ""[|pim]"")); ++ return; + } + + /* +@@ -496,8 +531,6 @@ pim_print(netdissect_options *ndo, + * + */ + +-static int pimv2_addr_len; +- + enum pimv2_addrtype { + pimv2_unicast, pimv2_group, pimv2_source + }; +@@ -524,23 +557,24 @@ enum pimv2_addrtype { + */ + static int + pimv2_addr_print(netdissect_options *ndo, +- const u_char *bp, enum pimv2_addrtype at, int silent) ++ const u_char *bp, u_int len, enum pimv2_addrtype at, ++ u_int addr_len, int silent) + { + int af; +- int len, hdrlen; ++ int hdrlen; + +- ND_TCHECK(bp[0]); +- +- if (pimv2_addr_len == 0) { ++ if (addr_len == 0) { ++ if (len < 2) ++ goto trunc; + ND_TCHECK(bp[1]); + switch (bp[0]) { + case 1: + af = AF_INET; +- len = sizeof(struct in_addr); ++ addr_len = (u_int)sizeof(struct in_addr); + break; + case 2: + af = AF_INET6; +- len = sizeof(struct in6_addr); ++ addr_len = (u_int)sizeof(struct in6_addr); + break; + default: + return -1; +@@ -549,7 +583,7 @@ pimv2_addr_print(netdissect_options *ndo, + return -1; + hdrlen = 2; + } else { +- switch (pimv2_addr_len) { ++ switch (addr_len) { + case sizeof(struct in_addr): + af = AF_INET; + break; +@@ -560,14 +594,16 @@ pimv2_addr_print(netdissect_options *ndo, + return -1; + break; + } +- len = pimv2_addr_len; + hdrlen = 0; + } + + bp += hdrlen; ++ len -= hdrlen; + switch (at) { + case pimv2_unicast: +- ND_TCHECK2(bp[0], len); ++ if (len < addr_len) ++ goto trunc; ++ ND_TCHECK2(bp[0], addr_len); + if (af == AF_INET) { + if (!silent) + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, bp))); +@@ -576,10 +612,12 @@ pimv2_addr_print(netdissect_options *ndo, + if (!silent) + ND_PRINT((ndo, ""%s"", ip6addr_string(ndo, bp))); + } +- return hdrlen + len; ++ return hdrlen + addr_len; + case pimv2_group: + case pimv2_source: +- ND_TCHECK2(bp[0], len + 2); ++ if (len < addr_len + 2) ++ goto trunc; ++ ND_TCHECK2(bp[0], addr_len + 2); + if (af == AF_INET) { + if (!silent) { + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, bp + 2))); +@@ -608,7 +646,7 @@ pimv2_addr_print(netdissect_options *ndo, + ND_PRINT((ndo, "")"")); + } + } +- return hdrlen + 2 + len; ++ return hdrlen + 2 + addr_len; + default: + return -1; + } +@@ -660,17 +698,23 @@ pimv2_print(netdissect_options *ndo, + register const struct pim *pim = (const struct pim *)bp; + int advance; + enum checksum_status cksum_status; ++ int pimv2_addr_len; + + ep = (const u_char *)ndo->ndo_snapend; + if (bp >= ep) + return; + if (ep > bp + len) + ep = bp + len; ++ if (len < 2) ++ goto trunc; + ND_TCHECK(pim->pim_rsv); + pimv2_addr_len = pim->pim_rsv; + if (pimv2_addr_len != 0) + ND_PRINT((ndo, "", RFC2117-encoding"")); + ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK(pim->pim_cksum); + ND_PRINT((ndo, "", cksum 0x%04x "", EXTRACT_16BITS(&pim->pim_cksum))); + if (EXTRACT_16BITS(&pim->pim_cksum) == 0) { + ND_PRINT((ndo, ""(unverified)"")); +@@ -711,23 +755,29 @@ pimv2_print(netdissect_options *ndo, + break; + } + } ++ bp += 4; ++ len -= 4; + + switch (PIM_TYPE(pim->pim_typever)) { + case PIMV2_TYPE_HELLO: + { + uint16_t otype, olen; +- bp += 4; +- while (bp < ep) { ++ while (len > 0) { ++ if (len < 4) ++ goto trunc; + ND_TCHECK2(bp[0], 4); + otype = EXTRACT_16BITS(&bp[0]); + olen = EXTRACT_16BITS(&bp[2]); +- ND_TCHECK2(bp[0], 4 + olen); + ND_PRINT((ndo, ""\n\t %s Option (%u), length %u, Value: "", + tok2str(pimv2_hello_option_values, ""Unknown"", otype), + otype, + olen)); + bp += 4; ++ len -= 4; + ++ if (len < olen) ++ goto trunc; ++ ND_TCHECK2(bp[0], olen); + switch (otype) { + case PIMV2_HELLO_OPTION_HOLDTIME: + if (olen != 2) { +@@ -797,14 +847,14 @@ pimv2_print(netdissect_options *ndo, + case PIMV2_HELLO_OPTION_ADDRESS_LIST: + if (ndo->ndo_vflag > 1) { + const u_char *ptr = bp; ++ u_int plen = len; + while (ptr < (bp+olen)) { + ND_PRINT((ndo, ""\n\t "")); +- advance = pimv2_addr_print(ndo, ptr, pimv2_unicast, 0); +- if (advance < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ advance = pimv2_addr_print(ndo, ptr, plen, pimv2_unicast, pimv2_addr_len, 0); ++ if (advance < 0) ++ goto trunc; + ptr += advance; ++ plen -= advance; + } + } + break; +@@ -817,6 +867,7 @@ pimv2_print(netdissect_options *ndo, + if (ndo->ndo_vflag> 1) + print_unknown_data(ndo, bp, ""\n\t "", olen); + bp += olen; ++ len -= olen; + } + break; + } +@@ -825,18 +876,24 @@ pimv2_print(netdissect_options *ndo, + { + const struct ip *ip; + +- ND_TCHECK2(*(bp + 4), PIMV2_REGISTER_FLAG_LEN); ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK2(*bp, PIMV2_REGISTER_FLAG_LEN); + + ND_PRINT((ndo, "", Flags [ %s ]\n\t"", + tok2str(pimv2_register_flag_values, + ""none"", +- EXTRACT_32BITS(bp+4)))); ++ EXTRACT_32BITS(bp)))); + +- bp += 8; len -= 8; ++ bp += 4; len -= 4; + /* encapsulated multicast packet */ ++ if (len == 0) ++ goto trunc; + ip = (const struct ip *)bp; ++ ND_TCHECK(ip->ip_vhl); + switch (IP_V(ip)) { + case 0: /* Null header */ ++ ND_TCHECK(ip->ip_dst); + ND_PRINT((ndo, ""IP-Null-header %s > %s"", + ipaddr_string(ndo, &ip->ip_src), + ipaddr_string(ndo, &ip->ip_dst))); +@@ -858,22 +915,13 @@ pimv2_print(netdissect_options *ndo, + } + + case PIMV2_TYPE_REGISTER_STOP: +- bp += 4; len -= 4; +- if (bp >= ep) +- break; + ND_PRINT((ndo, "" group="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; +- if (bp >= ep) +- break; + ND_PRINT((ndo, "" source="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; + break; + +@@ -924,19 +972,15 @@ pimv2_print(netdissect_options *ndo, + uint16_t nprune; + int i, j; + +- bp += 4; len -= 4; + if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ +- if (bp >= ep) +- break; + ND_PRINT((ndo, "", upstream-neighbor: "")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; + } +- if (bp + 4 > ep) +- break; ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK2(*bp, 4); + ngroup = bp[1]; + holdtime = EXTRACT_16BITS(&bp[2]); + ND_PRINT((ndo, ""\n\t %u group(s)"", ngroup)); +@@ -949,139 +993,125 @@ pimv2_print(netdissect_options *ndo, + } + bp += 4; len -= 4; + for (i = 0; i < ngroup; i++) { +- if (bp >= ep) +- goto jp_done; + ND_PRINT((ndo, ""\n\t group #%u: "", i+1)); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) { +- ND_PRINT((ndo, ""...)"")); +- goto jp_done; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; +- if (bp + 4 > ep) { +- ND_PRINT((ndo, ""...)"")); +- goto jp_done; +- } ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK2(*bp, 4); + njoin = EXTRACT_16BITS(&bp[0]); + nprune = EXTRACT_16BITS(&bp[2]); + ND_PRINT((ndo, "", joined sources: %u, pruned sources: %u"", njoin, nprune)); + bp += 4; len -= 4; + for (j = 0; j < njoin; j++) { + ND_PRINT((ndo, ""\n\t joined source #%u: "", j+1)); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) { +- ND_PRINT((ndo, ""...)"")); +- goto jp_done; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_source, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; + } + for (j = 0; j < nprune; j++) { + ND_PRINT((ndo, ""\n\t pruned source #%u: "", j+1)); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) { +- ND_PRINT((ndo, ""...)"")); +- goto jp_done; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_source, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; + } + } +- jp_done: + break; + } + + case PIMV2_TYPE_BOOTSTRAP: + { + int i, j, frpcnt; +- bp += 4; + + /* Fragment Tag, Hash Mask len, and BSR-priority */ +- if (bp + sizeof(uint16_t) >= ep) break; ++ if (len < 2) ++ goto trunc; ++ ND_TCHECK_16BITS(bp); + ND_PRINT((ndo, "" tag=%x"", EXTRACT_16BITS(bp))); +- bp += sizeof(uint16_t); +- if (bp >= ep) break; ++ bp += 2; ++ len -= 2; ++ if (len < 1) ++ goto trunc; ++ ND_TCHECK(bp[0]); + ND_PRINT((ndo, "" hashmlen=%d"", bp[0])); +- if (bp + 1 >= ep) break; ++ if (len < 2) ++ goto trunc; ++ ND_TCHECK(bp[2]); + ND_PRINT((ndo, "" BSRprio=%d"", bp[1])); + bp += 2; ++ len -= 2; + + /* Encoded-Unicast-BSR-Address */ +- if (bp >= ep) break; + ND_PRINT((ndo, "" BSR="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + + for (i = 0; bp < ep; i++) { + /* Encoded-Group Address */ + ND_PRINT((ndo, "" (group%d: "", i)); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) +- < 0) { +- ND_PRINT((ndo, ""...)"")); +- goto bs_done; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + + /* RP-Count, Frag RP-Cnt, and rsvd */ +- if (bp >= ep) { +- ND_PRINT((ndo, ""...)"")); +- goto bs_done; +- } ++ if (len < 1) ++ goto trunc; ++ ND_TCHECK(bp[0]); + ND_PRINT((ndo, "" RPcnt=%d"", bp[0])); +- if (bp + 1 >= ep) { +- ND_PRINT((ndo, ""...)"")); +- goto bs_done; +- } ++ if (len < 2) ++ goto trunc; ++ ND_TCHECK(bp[1]); + ND_PRINT((ndo, "" FRPcnt=%d"", frpcnt = bp[1])); ++ if (len < 4) ++ goto trunc; + bp += 4; ++ len -= 4; + + for (j = 0; j < frpcnt && bp < ep; j++) { + /* each RP info */ + ND_PRINT((ndo, "" RP%d="", j)); +- if ((advance = pimv2_addr_print(ndo, bp, ++ if ((advance = pimv2_addr_print(ndo, bp, len, + pimv2_unicast, +- 0)) < 0) { +- ND_PRINT((ndo, ""...)"")); +- goto bs_done; +- } ++ pimv2_addr_len, ++ 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + +- if (bp + 1 >= ep) { +- ND_PRINT((ndo, ""...)"")); +- goto bs_done; +- } ++ if (len < 2) ++ goto trunc; ++ ND_TCHECK_16BITS(bp); + ND_PRINT((ndo, "",holdtime="")); + unsigned_relts_print(ndo, EXTRACT_16BITS(bp)); +- if (bp + 2 >= ep) { +- ND_PRINT((ndo, ""...)"")); +- goto bs_done; +- } ++ if (len < 3) ++ goto trunc; ++ ND_TCHECK(bp[2]); + ND_PRINT((ndo, "",prio=%d"", bp[2])); ++ if (len < 4) ++ goto trunc; + bp += 4; ++ len -= 4; + } + ND_PRINT((ndo, "")"")); + } +- bs_done: + break; + } + case PIMV2_TYPE_ASSERT: +- bp += 4; len -= 4; +- if (bp >= ep) +- break; + ND_PRINT((ndo, "" group="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; +- if (bp >= ep) +- break; + ND_PRINT((ndo, "" src="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; len -= advance; +- if (bp + 8 > ep) +- break; ++ if (len < 8) ++ goto trunc; ++ ND_TCHECK2(*bp, 8); + if (bp[0] & 0x80) + ND_PRINT((ndo, "" RPT"")); + ND_PRINT((ndo, "" pref=%u"", EXTRACT_32BITS(&bp[0]) & 0x7fffffff)); +@@ -1091,61 +1121,62 @@ pimv2_print(netdissect_options *ndo, + case PIMV2_TYPE_CANDIDATE_RP: + { + int i, pfxcnt; +- bp += 4; + + /* Prefix-Cnt, Priority, and Holdtime */ +- if (bp >= ep) break; ++ if (len < 1) ++ goto trunc; ++ ND_TCHECK(bp[0]); + ND_PRINT((ndo, "" prefix-cnt=%d"", bp[0])); + pfxcnt = bp[0]; +- if (bp + 1 >= ep) break; ++ if (len < 2) ++ goto trunc; ++ ND_TCHECK(bp[1]); + ND_PRINT((ndo, "" prio=%d"", bp[1])); +- if (bp + 3 >= ep) break; ++ if (len < 4) ++ goto trunc; ++ ND_TCHECK_16BITS(&bp[2]); + ND_PRINT((ndo, "" holdtime="")); + unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2])); + bp += 4; ++ len -= 4; + + /* Encoded-Unicast-RP-Address */ +- if (bp >= ep) break; + ND_PRINT((ndo, "" RP="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + + /* Encoded-Group Addresses */ + for (i = 0; i < pfxcnt && bp < ep; i++) { + ND_PRINT((ndo, "" Group%d="", i)); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) +- < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + } + break; + } + + case PIMV2_TYPE_PRUNE_REFRESH: + ND_PRINT((ndo, "" src="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + ND_PRINT((ndo, "" grp="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; ++ len -= advance; + ND_PRINT((ndo, "" forwarder="")); +- if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) { +- ND_PRINT((ndo, ""..."")); +- break; +- } ++ if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) ++ goto trunc; + bp += advance; +- ND_TCHECK2(bp[0], 2); ++ len -= advance; ++ if (len < 2) ++ goto trunc; ++ ND_TCHECK_16BITS(bp); + ND_PRINT((ndo, "" TUNR "")); + unsigned_relts_print(ndo, EXTRACT_16BITS(bp)); + break;",1012,1248,2048 +14619,"bool WebGLRenderingContextBase::ValidateTexFuncData( + const char* function_name, + TexImageDimension tex_dimension, + GLint level, + GLsizei width, + GLsizei height, + GLsizei depth, + GLenum format, + GLenum type, + DOMArrayBufferView* pixels, + NullDisposition disposition, + GLuint src_offset) { + if (!pixels) { + DCHECK_NE(disposition, kNullNotReachable); + if (disposition == kNullAllowed) + return true; + SynthesizeGLError(GL_INVALID_VALUE, function_name, ""no pixels""); + return false; + } + + if (!ValidateSettableTexFormat(function_name, format)) + return false; + + switch (type) { + case GL_BYTE: + if (pixels->GetType() != DOMArrayBufferView::kTypeInt8) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type BYTE but ArrayBufferView not Int8Array""); + return false; + } + break; + case GL_UNSIGNED_BYTE: + if (pixels->GetType() != DOMArrayBufferView::kTypeUint8) { + SynthesizeGLError( + GL_INVALID_OPERATION, function_name, + ""type UNSIGNED_BYTE but ArrayBufferView not Uint8Array""); + return false; + } + break; + case GL_SHORT: + if (pixels->GetType() != DOMArrayBufferView::kTypeInt16) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type SHORT but ArrayBufferView not Int16Array""); + return false; + } + break; + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (pixels->GetType() != DOMArrayBufferView::kTypeUint16) { + SynthesizeGLError( + GL_INVALID_OPERATION, function_name, + ""type UNSIGNED_SHORT but ArrayBufferView not Uint16Array""); + return false; + } + break; + case GL_INT: + if (pixels->GetType() != DOMArrayBufferView::kTypeInt32) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type INT but ArrayBufferView not Int32Array""); + return false; + } + break; + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL_UNSIGNED_INT_5_9_9_9_REV: + case GL_UNSIGNED_INT_24_8: + if (pixels->GetType() != DOMArrayBufferView::kTypeUint32) { + SynthesizeGLError( + GL_INVALID_OPERATION, function_name, + ""type UNSIGNED_INT but ArrayBufferView not Uint32Array""); + return false; + } + break; + case GL_FLOAT: // OES_texture_float + if (pixels->GetType() != DOMArrayBufferView::kTypeFloat32) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type FLOAT but ArrayBufferView not Float32Array""); + return false; + } + break; + case GL_HALF_FLOAT: + case GL_HALF_FLOAT_OES: // OES_texture_half_float + if (pixels->GetType() != DOMArrayBufferView::kTypeUint16) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type HALF_FLOAT_OES but ArrayBufferView is not NULL "" + ""and not Uint16Array""); + return false; + } + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type FLOAT_32_UNSIGNED_INT_24_8_REV but "" + ""ArrayBufferView is not NULL""); + return false; + default: + NOTREACHED(); + } + + unsigned total_bytes_required, skip_bytes; + GLenum error = WebGLImageConversion::ComputeImageSizeInBytes( + format, type, width, height, depth, + GetUnpackPixelStoreParams(tex_dimension), &total_bytes_required, 0, + &skip_bytes); + if (error != GL_NO_ERROR) { + SynthesizeGLError(error, function_name, ""invalid texture dimensions""); + return false; + } + CheckedNumeric total = src_offset; + total *= pixels->TypeSize(); + total += total_bytes_required; + total += skip_bytes; + if (!total.IsValid() || pixels->byteLength() < total.ValueOrDie()) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""ArrayBufferView not big enough for request""); + return false; + } + return true; +} +",0,"bool WebGLRenderingContextBase::ValidateTexFuncData( + const char* function_name, + TexImageDimension tex_dimension, + GLint level, + GLsizei width, + GLsizei height, + GLsizei depth, + GLenum format, + GLenum type, + DOMArrayBufferView* pixels, + NullDisposition disposition, + GLuint src_offset) { + if (!pixels) { + DCHECK_NE(disposition, kNullNotReachable); + if (disposition == kNullAllowed) + return true; + SynthesizeGLError(GL_INVALID_VALUE, function_name, ""no pixels""); + return false; + } + + if (!ValidateSettableTexFormat(function_name, format)) + return false; + + switch (type) { + case GL_BYTE: + if (pixels->GetType() != DOMArrayBufferView::kTypeInt8) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type BYTE but ArrayBufferView not Int8Array""); + return false; + } + break; + case GL_UNSIGNED_BYTE: + if (pixels->GetType() != DOMArrayBufferView::kTypeUint8) { + SynthesizeGLError( + GL_INVALID_OPERATION, function_name, + ""type UNSIGNED_BYTE but ArrayBufferView not Uint8Array""); + return false; + } + break; + case GL_SHORT: + if (pixels->GetType() != DOMArrayBufferView::kTypeInt16) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type SHORT but ArrayBufferView not Int16Array""); + return false; + } + break; + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (pixels->GetType() != DOMArrayBufferView::kTypeUint16) { + SynthesizeGLError( + GL_INVALID_OPERATION, function_name, + ""type UNSIGNED_SHORT but ArrayBufferView not Uint16Array""); + return false; + } + break; + case GL_INT: + if (pixels->GetType() != DOMArrayBufferView::kTypeInt32) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type INT but ArrayBufferView not Int32Array""); + return false; + } + break; + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL_UNSIGNED_INT_5_9_9_9_REV: + case GL_UNSIGNED_INT_24_8: + if (pixels->GetType() != DOMArrayBufferView::kTypeUint32) { + SynthesizeGLError( + GL_INVALID_OPERATION, function_name, + ""type UNSIGNED_INT but ArrayBufferView not Uint32Array""); + return false; + } + break; + case GL_FLOAT: // OES_texture_float + if (pixels->GetType() != DOMArrayBufferView::kTypeFloat32) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type FLOAT but ArrayBufferView not Float32Array""); + return false; + } + break; + case GL_HALF_FLOAT: + case GL_HALF_FLOAT_OES: // OES_texture_half_float + if (pixels->GetType() != DOMArrayBufferView::kTypeUint16) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type HALF_FLOAT_OES but ArrayBufferView is not NULL "" + ""and not Uint16Array""); + return false; + } + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""type FLOAT_32_UNSIGNED_INT_24_8_REV but "" + ""ArrayBufferView is not NULL""); + return false; + default: + NOTREACHED(); + } + + unsigned total_bytes_required, skip_bytes; + GLenum error = WebGLImageConversion::ComputeImageSizeInBytes( + format, type, width, height, depth, + GetUnpackPixelStoreParams(tex_dimension), &total_bytes_required, 0, + &skip_bytes); + if (error != GL_NO_ERROR) { + SynthesizeGLError(error, function_name, ""invalid texture dimensions""); + return false; + } + CheckedNumeric total = src_offset; + total *= pixels->TypeSize(); + total += total_bytes_required; + total += skip_bytes; + if (!total.IsValid() || pixels->byteLength() < total.ValueOrDie()) { + SynthesizeGLError(GL_INVALID_OPERATION, function_name, + ""ArrayBufferView not big enough for request""); + return false; + } + return true; +} +","@@ -6344,7 +6344,8 @@ void WebGLRenderingContextBase::DrawingBufferClientRestoreMaskAndClearValues() { + ContextGL()->ClearStencil(clear_stencil_); + } + +-void WebGLRenderingContextBase::DrawingBufferClientRestorePixelPackAlignment() { ++void WebGLRenderingContextBase:: ++ DrawingBufferClientRestorePixelPackParameters() { + if (!ContextGL()) + return; + ContextGL()->PixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); +@@ -6372,6 +6373,8 @@ void WebGLRenderingContextBase::DrawingBufferClientRestoreFramebufferBinding() { + + void WebGLRenderingContextBase:: + DrawingBufferClientRestorePixelUnpackBufferBinding() {} ++void WebGLRenderingContextBase:: ++ DrawingBufferClientRestorePixelPackBufferBinding() {} + + ScriptValue WebGLRenderingContextBase::GetBooleanParameter( + ScriptState* script_state,",1004,1240,2048 +18307,"static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, + struct dvb_diseqc_master_cmd *d) +{ + struct cx24116_state *state = fe->demodulator_priv; + int i, ret; + + /* Dump DiSEqC message */ + if (debug) { + printk(KERN_INFO ""cx24116: %s("", __func__); + for (i = 0 ; i < d->msg_len ;) { + printk(KERN_INFO ""0x%02x"", d->msg[i]); + if (++i < d->msg_len) + printk(KERN_INFO "", ""); + } + printk("") toneburst=%d\n"", toneburst); + } + + /* Validate length */ + if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) + return -EINVAL; + /* DiSEqC message */ + for (i = 0; i < d->msg_len; i++) + state->dsec_cmd.args[CX24116_DISEQC_MSGOFS + i] = d->msg[i]; + + /* DiSEqC message length */ + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; + + /* Command length */ + state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; + + /* DiSEqC toneburst */ + if (toneburst == CX24116_DISEQC_MESGCACHE) + /* Message is cached */ + return 0; + + else if (toneburst == CX24116_DISEQC_TONEOFF) + /* Message is sent without burst */ + state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; + + else if (toneburst == CX24116_DISEQC_TONECACHE) { + /* + * Message is sent with derived else cached burst + * + * WRITE PORT GROUP COMMAND 38 + * + * 0/A/A: E0 10 38 F0..F3 + * 1/B/B: E0 10 38 F4..F7 + * 2/C/A: E0 10 38 F8..FB + * 3/D/B: E0 10 38 FC..FF + * + * databyte[3]= 8421:8421 + * ABCD:WXYZ + * CLR :SET + * + * WX= PORT SELECT 0..3 (X=TONEBURST) + * Y = VOLTAGE (0=13V, 1=18V) + * Z = BAND (0=LOW, 1=HIGH(22K)) + */ + if (d->msg_len >= 4 && d->msg[2] == 0x38) + state->dsec_cmd.args[CX24116_DISEQC_BURST] = + ((d->msg[3] & 4) >> 2); + if (debug) + dprintk(""%s burst=%d\n"", __func__, + state->dsec_cmd.args[CX24116_DISEQC_BURST]); + } + + /* Wait for LNB ready */ + ret = cx24116_wait_for_lnb(fe); + if (ret != 0) + return ret; + + /* Wait for voltage/min repeat delay */ + msleep(100); + + /* Command */ + ret = cx24116_cmd_execute(fe, &state->dsec_cmd); + if (ret != 0) + return ret; + /* + * Wait for send + * + * Eutelsat spec: + * >15ms delay + (XXX determine if FW does this, see set_tone) + * 13.5ms per byte + + * >15ms delay + + * 12.5ms burst + + * >15ms delay (XXX determine if FW does this, see set_tone) + */ + msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60)); + + return 0; +} +",1,"static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, + struct dvb_diseqc_master_cmd *d) +{ + struct cx24116_state *state = fe->demodulator_priv; + int i, ret; + + /* Validate length */ + if (d->msg_len > sizeof(d->msg)) + return -EINVAL; + + /* Dump DiSEqC message */ + if (debug) { + printk(KERN_INFO ""cx24116: %s("", __func__); + for (i = 0 ; i < d->msg_len ;) { + printk(KERN_INFO ""0x%02x"", d->msg[i]); + if (++i < d->msg_len) + printk(KERN_INFO "", ""); + } + printk("") toneburst=%d\n"", toneburst); + } + + /* DiSEqC message */ + for (i = 0; i < d->msg_len; i++) + state->dsec_cmd.args[CX24116_DISEQC_MSGOFS + i] = d->msg[i]; + + /* DiSEqC message length */ + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; + + /* Command length */ + state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; + + /* DiSEqC toneburst */ + if (toneburst == CX24116_DISEQC_MESGCACHE) + /* Message is cached */ + return 0; + + else if (toneburst == CX24116_DISEQC_TONEOFF) + /* Message is sent without burst */ + state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; + + else if (toneburst == CX24116_DISEQC_TONECACHE) { + /* + * Message is sent with derived else cached burst + * + * WRITE PORT GROUP COMMAND 38 + * + * 0/A/A: E0 10 38 F0..F3 + * 1/B/B: E0 10 38 F4..F7 + * 2/C/A: E0 10 38 F8..FB + * 3/D/B: E0 10 38 FC..FF + * + * databyte[3]= 8421:8421 + * ABCD:WXYZ + * CLR :SET + * + * WX= PORT SELECT 0..3 (X=TONEBURST) + * Y = VOLTAGE (0=13V, 1=18V) + * Z = BAND (0=LOW, 1=HIGH(22K)) + */ + if (d->msg_len >= 4 && d->msg[2] == 0x38) + state->dsec_cmd.args[CX24116_DISEQC_BURST] = + ((d->msg[3] & 4) >> 2); + if (debug) + dprintk(""%s burst=%d\n"", __func__, + state->dsec_cmd.args[CX24116_DISEQC_BURST]); + } + + /* Wait for LNB ready */ + ret = cx24116_wait_for_lnb(fe); + if (ret != 0) + return ret; + + /* Wait for voltage/min repeat delay */ + msleep(100); + + /* Command */ + ret = cx24116_cmd_execute(fe, &state->dsec_cmd); + if (ret != 0) + return ret; + /* + * Wait for send + * + * Eutelsat spec: + * >15ms delay + (XXX determine if FW does this, see set_tone) + * 13.5ms per byte + + * >15ms delay + + * 12.5ms burst + + * >15ms delay (XXX determine if FW does this, see set_tone) + */ + msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60)); + + return 0; +} +","@@ -963,6 +963,10 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, + struct cx24116_state *state = fe->demodulator_priv; + int i, ret; + ++ /* Validate length */ ++ if (d->msg_len > sizeof(d->msg)) ++ return -EINVAL; ++ + /* Dump DiSEqC message */ + if (debug) { + printk(KERN_INFO ""cx24116: %s("", __func__); +@@ -974,10 +978,6 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, + printk("") toneburst=%d\n"", toneburst); + } + +- /* Validate length */ +- if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) +- return -EINVAL; +- + /* DiSEqC message */ + for (i = 0; i < d->msg_len; i++) + state->dsec_cmd.args[CX24116_DISEQC_MSGOFS + i] = d->msg[i];",1005,1241,2048 +1558,"__imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm, + int depth, DATA8 r, DATA8 g, DATA8 b) +{ + Context *ct; + + ct = __imlib_GetContext(d, v, cm, depth); + + if (ct->palette) + { + switch (ct->palette_type) + { + case 0: /* 332 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 1: /* 232 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 2: /* 222 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 3: /* 221 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 4: /* 121 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 5: /* 111 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 6: /* 1 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 7: /* 666 */ + return ct->palette[((int)(((double)r / 255) * 5.0) * 36) + + ((int)(((double)g / 255) * 5.0) * 6) + + ((int)(((double)b / 255) * 5.0))]; + break; + default: + return 0; + } + } + else + { + unsigned int rm, gm, bm; + int i, rshift = 0, gshift = 0, bshift = 0; + DATA32 val; + + rm = v->red_mask; + gm = v->green_mask; + bm = v->blue_mask; + if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f)) /* 565 */ + { + return (((r << 8) & 0xf800) | + ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f)); + } + if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff)) /* 888 */ + { + return (((r << 16) & 0xff0000) | + ((g << 8) & 0x00ff00) | ((r) & 0x0000ff)); + } + if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f)) /* 555 */ + { + return (((r << 7) & 0x7c00) | + ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f)); + } + for (i = 31; i >= 0; i--) + { + if (rm >= (1U << i)) + { + rshift = i - 7; + break; + } + } + for (i = 31; i >= 0; i--) + { + if (gm >= (1U << i)) + { + gshift = i - 7; + break; + } + } + for (i = 31; i >= 0; i--) + { + if (bm >= (1U << i)) + { + bshift = i - 7; + break; + } + } + if (rshift >= 0) + val = ((r << rshift) & rm); + else + val = ((r >> (-rshift)) & rm); + if (gshift >= 0) + val |= ((g << gshift) & gm); + else + val |= ((g >> (-gshift)) & gm); + if (bshift >= 0) + val |= ((b << bshift) & bm); + else + val |= ((b >> (-bshift)) & bm); + return val; + } + return 0; +} +",0,"__imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm, + int depth, DATA8 r, DATA8 g, DATA8 b) +{ + Context *ct; + + ct = __imlib_GetContext(d, v, cm, depth); + + if (ct->palette) + { + switch (ct->palette_type) + { + case 0: /* 332 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 1: /* 232 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 2: /* 222 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 3: /* 221 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 4: /* 121 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 5: /* 111 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 6: /* 1 */ + return ct->palette[((r >> 0) & 0xe0) | + ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)]; + break; + case 7: /* 666 */ + return ct->palette[((int)(((double)r / 255) * 5.0) * 36) + + ((int)(((double)g / 255) * 5.0) * 6) + + ((int)(((double)b / 255) * 5.0))]; + break; + default: + return 0; + } + } + else + { + unsigned int rm, gm, bm; + int i, rshift = 0, gshift = 0, bshift = 0; + DATA32 val; + + rm = v->red_mask; + gm = v->green_mask; + bm = v->blue_mask; + if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f)) /* 565 */ + { + return (((r << 8) & 0xf800) | + ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f)); + } + if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff)) /* 888 */ + { + return (((r << 16) & 0xff0000) | + ((g << 8) & 0x00ff00) | ((r) & 0x0000ff)); + } + if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f)) /* 555 */ + { + return (((r << 7) & 0x7c00) | + ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f)); + } + for (i = 31; i >= 0; i--) + { + if (rm >= (1U << i)) + { + rshift = i - 7; + break; + } + } + for (i = 31; i >= 0; i--) + { + if (gm >= (1U << i)) + { + gshift = i - 7; + break; + } + } + for (i = 31; i >= 0; i--) + { + if (bm >= (1U << i)) + { + bshift = i - 7; + break; + } + } + if (rshift >= 0) + val = ((r << rshift) & rm); + else + val = ((r >> (-rshift)) & rm); + if (gshift >= 0) + val |= ((g << gshift) & gm); + else + val |= ((g >> (-gshift)) & gm); + if (bshift >= 0) + val |= ((b << bshift) & bm); + else + val |= ((b >> (-bshift)) & bm); + return val; + } + return 0; +} +","@@ -16,10 +16,6 @@ + #include ""scale.h"" + #include ""ximage.h"" + +-/* The maximum pixmap dimension is 65535. */ +-/* However, for now, use 46340 (46340^2 < 2^31) to avoid buffer overflow issues. */ +-#define X_MAX_DIM 46340 +- + /* size of the lines per segment we scale / render at a time */ + #define LINESIZE 16",1213,1449,2048 +4351,"static int xmit_skb(struct send_queue *sq, struct sk_buff *skb) +{ + struct virtio_net_hdr_mrg_rxbuf *hdr; + const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; + struct virtnet_info *vi = sq->vq->vdev->priv; + unsigned num_sg; + unsigned hdr_len = vi->hdr_len; + bool can_push; + + pr_debug(""%s: xmit %p %pM\n"", vi->dev->name, skb, dest); + + can_push = vi->any_header_sg && + !((unsigned long)skb->data & (__alignof__(*hdr) - 1)) && + !skb_header_cloned(skb) && skb_headroom(skb) >= hdr_len; + /* Even if we can, don't push here yet as this would skew + * csum_start offset below. */ + if (can_push) + hdr = (struct virtio_net_hdr_mrg_rxbuf *)(skb->data - hdr_len); + else + hdr = skb_vnet_hdr(skb); + + if (skb->ip_summed == CHECKSUM_PARTIAL) { + hdr->hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; + hdr->hdr.csum_start = cpu_to_virtio16(vi->vdev, + skb_checksum_start_offset(skb)); + hdr->hdr.csum_offset = cpu_to_virtio16(vi->vdev, + skb->csum_offset); + } else { + hdr->hdr.flags = 0; + hdr->hdr.csum_offset = hdr->hdr.csum_start = 0; + } + + if (skb_is_gso(skb)) { + hdr->hdr.hdr_len = cpu_to_virtio16(vi->vdev, skb_headlen(skb)); + hdr->hdr.gso_size = cpu_to_virtio16(vi->vdev, + skb_shinfo(skb)->gso_size); + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; + else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; + else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP) + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP; + else + BUG(); + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN) + hdr->hdr.gso_type |= VIRTIO_NET_HDR_GSO_ECN; + } else { + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE; + hdr->hdr.gso_size = hdr->hdr.hdr_len = 0; + } + + if (vi->mergeable_rx_bufs) + hdr->num_buffers = 0; + + sg_init_table(sq->sg, MAX_SKB_FRAGS + 2); + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + } + return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC); +} +",0,"static int xmit_skb(struct send_queue *sq, struct sk_buff *skb) +{ + struct virtio_net_hdr_mrg_rxbuf *hdr; + const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; + struct virtnet_info *vi = sq->vq->vdev->priv; + unsigned num_sg; + unsigned hdr_len = vi->hdr_len; + bool can_push; + + pr_debug(""%s: xmit %p %pM\n"", vi->dev->name, skb, dest); + + can_push = vi->any_header_sg && + !((unsigned long)skb->data & (__alignof__(*hdr) - 1)) && + !skb_header_cloned(skb) && skb_headroom(skb) >= hdr_len; + /* Even if we can, don't push here yet as this would skew + * csum_start offset below. */ + if (can_push) + hdr = (struct virtio_net_hdr_mrg_rxbuf *)(skb->data - hdr_len); + else + hdr = skb_vnet_hdr(skb); + + if (skb->ip_summed == CHECKSUM_PARTIAL) { + hdr->hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; + hdr->hdr.csum_start = cpu_to_virtio16(vi->vdev, + skb_checksum_start_offset(skb)); + hdr->hdr.csum_offset = cpu_to_virtio16(vi->vdev, + skb->csum_offset); + } else { + hdr->hdr.flags = 0; + hdr->hdr.csum_offset = hdr->hdr.csum_start = 0; + } + + if (skb_is_gso(skb)) { + hdr->hdr.hdr_len = cpu_to_virtio16(vi->vdev, skb_headlen(skb)); + hdr->hdr.gso_size = cpu_to_virtio16(vi->vdev, + skb_shinfo(skb)->gso_size); + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; + else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; + else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP) + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP; + else + BUG(); + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN) + hdr->hdr.gso_type |= VIRTIO_NET_HDR_GSO_ECN; + } else { + hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE; + hdr->hdr.gso_size = hdr->hdr.hdr_len = 0; + } + + if (vi->mergeable_rx_bufs) + hdr->num_buffers = 0; + + sg_init_table(sq->sg, MAX_SKB_FRAGS + 2); + if (can_push) { + __skb_push(skb, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len); + /* Pull header back to avoid skew in tx bytes calculations. */ + __skb_pull(skb, hdr_len); + } else { + sg_set_buf(sq->sg, hdr, hdr_len); + num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; + } + return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC); +} +","@@ -1756,9 +1756,9 @@ static int virtnet_probe(struct virtio_device *vdev) + /* Do we support ""hardware"" checksums? */ + if (virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) { + /* This opens up the world of extra features. */ +- dev->hw_features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; ++ dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG; + if (csum) +- dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; ++ dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; + + if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) { + dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO",795,1031,2048 +263,"make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *state) +{ + Datum *values; + bool *nulls; + int i; + RecordIOData *my_extra = state->my_extra; + int ncolumns = my_extra->ncolumns; + TupleDesc tupdesc = state->ret_tdesc; + HeapTupleHeader rec = state->rec; + HeapTuple rettuple; + + values = (Datum *) palloc(ncolumns * sizeof(Datum)); + nulls = (bool *) palloc(ncolumns * sizeof(bool)); + + if (state->rec) + { + HeapTupleData tuple; + + /* Build a temporary HeapTuple control structure */ + tuple.t_len = HeapTupleHeaderGetDatumLength(state->rec); + ItemPointerSetInvalid(&(tuple.t_self)); + tuple.t_tableOid = InvalidOid; + tuple.t_data = state->rec; + + /* Break down the tuple into fields */ + heap_deform_tuple(&tuple, tupdesc, values, nulls); + } + else + { + for (i = 0; i < ncolumns; ++i) + { + values[i] = (Datum) 0; + nulls[i] = true; + } + } + + for (i = 0; i < ncolumns; ++i) + { + ColumnIOData *column_info = &my_extra->columns[i]; + Oid column_type = tupdesc->attrs[i]->atttypid; + JsonbValue *v = NULL; + char *key; + + /* Ignore dropped columns in datatype */ + if (tupdesc->attrs[i]->attisdropped) + { + nulls[i] = true; + continue; + } + + key = NameStr(tupdesc->attrs[i]->attname); + + v = findJsonbValueFromContainerLen(&element->root, JB_FOBJECT, + key, strlen(key)); + + /* + * We can't just skip here if the key wasn't found since we might have + * a domain to deal with. If we were passed in a non-null record + * datum, we assume that the existing values are valid (if they're + * not, then it's not our fault), but if we were passed in a null, + * then every field which we don't populate needs to be run through + * the input function just in case it's a domain type. + */ + if (v == NULL && rec) + continue; + + /* + * Prepare to convert the column value from text + */ + if (column_info->column_type != column_type) + { + getTypeInputInfo(column_type, + &column_info->typiofunc, + &column_info->typioparam); + fmgr_info_cxt(column_info->typiofunc, &column_info->proc, + state->fn_mcxt); + column_info->column_type = column_type; + } + if (v == NULL || v->type == jbvNull) + { + /* + * Need InputFunctionCall to happen even for nulls, so that domain + * checks are done + */ + values[i] = InputFunctionCall(&column_info->proc, NULL, + column_info->typioparam, + tupdesc->attrs[i]->atttypmod); + nulls[i] = true; + } + else + { + char *s = NULL; + + if (v->type == jbvString) + s = pnstrdup(v->val.string.val, v->val.string.len); + else if (v->type == jbvBool) + s = pnstrdup((v->val.boolean) ? ""t"" : ""f"", 1); + else if (v->type == jbvNumeric) + s = DatumGetCString(DirectFunctionCall1(numeric_out, + PointerGetDatum(v->val.numeric))); + else if (v->type == jbvBinary) + s = JsonbToCString(NULL, (JsonbContainer *) v->val.binary.data, v->val.binary.len); + else + elog(ERROR, ""unrecognized jsonb type: %d"", (int) v->type); + + values[i] = InputFunctionCall(&column_info->proc, s, + column_info->typioparam, + tupdesc->attrs[i]->atttypmod); + nulls[i] = false; + } + } + + rettuple = heap_form_tuple(tupdesc, values, nulls); + + tuplestore_puttuple(state->tuple_store, rettuple); +} +",0,"make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *state) +{ + Datum *values; + bool *nulls; + int i; + RecordIOData *my_extra = state->my_extra; + int ncolumns = my_extra->ncolumns; + TupleDesc tupdesc = state->ret_tdesc; + HeapTupleHeader rec = state->rec; + HeapTuple rettuple; + + values = (Datum *) palloc(ncolumns * sizeof(Datum)); + nulls = (bool *) palloc(ncolumns * sizeof(bool)); + + if (state->rec) + { + HeapTupleData tuple; + + /* Build a temporary HeapTuple control structure */ + tuple.t_len = HeapTupleHeaderGetDatumLength(state->rec); + ItemPointerSetInvalid(&(tuple.t_self)); + tuple.t_tableOid = InvalidOid; + tuple.t_data = state->rec; + + /* Break down the tuple into fields */ + heap_deform_tuple(&tuple, tupdesc, values, nulls); + } + else + { + for (i = 0; i < ncolumns; ++i) + { + values[i] = (Datum) 0; + nulls[i] = true; + } + } + + for (i = 0; i < ncolumns; ++i) + { + ColumnIOData *column_info = &my_extra->columns[i]; + Oid column_type = tupdesc->attrs[i]->atttypid; + JsonbValue *v = NULL; + char *key; + + /* Ignore dropped columns in datatype */ + if (tupdesc->attrs[i]->attisdropped) + { + nulls[i] = true; + continue; + } + + key = NameStr(tupdesc->attrs[i]->attname); + + v = findJsonbValueFromContainerLen(&element->root, JB_FOBJECT, + key, strlen(key)); + + /* + * We can't just skip here if the key wasn't found since we might have + * a domain to deal with. If we were passed in a non-null record + * datum, we assume that the existing values are valid (if they're + * not, then it's not our fault), but if we were passed in a null, + * then every field which we don't populate needs to be run through + * the input function just in case it's a domain type. + */ + if (v == NULL && rec) + continue; + + /* + * Prepare to convert the column value from text + */ + if (column_info->column_type != column_type) + { + getTypeInputInfo(column_type, + &column_info->typiofunc, + &column_info->typioparam); + fmgr_info_cxt(column_info->typiofunc, &column_info->proc, + state->fn_mcxt); + column_info->column_type = column_type; + } + if (v == NULL || v->type == jbvNull) + { + /* + * Need InputFunctionCall to happen even for nulls, so that domain + * checks are done + */ + values[i] = InputFunctionCall(&column_info->proc, NULL, + column_info->typioparam, + tupdesc->attrs[i]->atttypmod); + nulls[i] = true; + } + else + { + char *s = NULL; + + if (v->type == jbvString) + s = pnstrdup(v->val.string.val, v->val.string.len); + else if (v->type == jbvBool) + s = pnstrdup((v->val.boolean) ? ""t"" : ""f"", 1); + else if (v->type == jbvNumeric) + s = DatumGetCString(DirectFunctionCall1(numeric_out, + PointerGetDatum(v->val.numeric))); + else if (v->type == jbvBinary) + s = JsonbToCString(NULL, (JsonbContainer *) v->val.binary.data, v->val.binary.len); + else + elog(ERROR, ""unrecognized jsonb type: %d"", (int) v->type); + + values[i] = InputFunctionCall(&column_info->proc, s, + column_info->typioparam, + tupdesc->attrs[i]->atttypmod); + nulls[i] = false; + } + } + + rettuple = heap_form_tuple(tupdesc, values, nulls); + + tuplestore_puttuple(state->tuple_store, rettuple); +} +","@@ -3724,6 +3724,8 @@ setPath(JsonbIterator **it, Datum *path_elems, + JsonbValue *res = NULL; + int r; + ++ check_stack_depth(); ++ + if (path_nulls[level]) + elog(ERROR, ""path element at the position %d is NULL"", level + 1);",986,1222,2048 +18308,"bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, + struct drm_display_mode *mode) +{ + struct radeon_mode_info *mode_info = &rdev->mode_info; + ATOM_ANALOG_TV_INFO *tv_info; + ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2; + ATOM_DTD_FORMAT *dtd_timings; + int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); + u8 frev, crev; + u16 data_offset, misc; + + if (!atom_parse_data_header(mode_info->atom_context, data_index, NULL, + &frev, &crev, &data_offset)) + return false; + + switch (crev) { + case 1: + tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); + if (index > MAX_SUPPORTED_TV_TIMING) + return false; + + mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); + mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp); + mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart); + mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) + + le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth); + + mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total); + mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp); + mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart); + mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) + + le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth); + + mode->flags = 0; + misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess); + if (misc & ATOM_VSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NVSYNC; + if (misc & ATOM_HSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NHSYNC; + if (misc & ATOM_COMPOSITESYNC) + mode->flags |= DRM_MODE_FLAG_CSYNC; + if (misc & ATOM_INTERLACE) + mode->flags |= DRM_MODE_FLAG_INTERLACE; + if (misc & ATOM_DOUBLE_CLOCK_MODE) + mode->flags |= DRM_MODE_FLAG_DBLSCAN; + + mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10; + + if (index == 1) { + /* PAL timings appear to have wrong values for totals */ + mode->crtc_htotal -= 1; + mode->crtc_vtotal -= 1; + } + break; + case 2: + tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); + if (index > MAX_SUPPORTED_TV_TIMING_V1_2) + return false; + + dtd_timings = &tv_info_v1_2->aModeTimings[index]; + mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) + + le16_to_cpu(dtd_timings->usHBlanking_Time); + mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive); + mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) + + le16_to_cpu(dtd_timings->usHSyncOffset); + mode->crtc_hsync_end = mode->crtc_hsync_start + + le16_to_cpu(dtd_timings->usHSyncWidth); + + mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) + + le16_to_cpu(dtd_timings->usVBlanking_Time); + mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive); + mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) + + le16_to_cpu(dtd_timings->usVSyncOffset); + mode->crtc_vsync_end = mode->crtc_vsync_start + + le16_to_cpu(dtd_timings->usVSyncWidth); + + mode->flags = 0; + misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess); + if (misc & ATOM_VSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NVSYNC; + if (misc & ATOM_HSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NHSYNC; + if (misc & ATOM_COMPOSITESYNC) + mode->flags |= DRM_MODE_FLAG_CSYNC; + if (misc & ATOM_INTERLACE) + mode->flags |= DRM_MODE_FLAG_INTERLACE; + if (misc & ATOM_DOUBLE_CLOCK_MODE) + mode->flags |= DRM_MODE_FLAG_DBLSCAN; + + mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10; + break; + } + return true; +} +",1,"bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, + struct drm_display_mode *mode) +{ + struct radeon_mode_info *mode_info = &rdev->mode_info; + ATOM_ANALOG_TV_INFO *tv_info; + ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2; + ATOM_DTD_FORMAT *dtd_timings; + int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); + u8 frev, crev; + u16 data_offset, misc; + + if (!atom_parse_data_header(mode_info->atom_context, data_index, NULL, + &frev, &crev, &data_offset)) + return false; + + switch (crev) { + case 1: + tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); + if (index >= MAX_SUPPORTED_TV_TIMING) + return false; + + mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); + mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp); + mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart); + mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) + + le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth); + + mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total); + mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp); + mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart); + mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) + + le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth); + + mode->flags = 0; + misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess); + if (misc & ATOM_VSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NVSYNC; + if (misc & ATOM_HSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NHSYNC; + if (misc & ATOM_COMPOSITESYNC) + mode->flags |= DRM_MODE_FLAG_CSYNC; + if (misc & ATOM_INTERLACE) + mode->flags |= DRM_MODE_FLAG_INTERLACE; + if (misc & ATOM_DOUBLE_CLOCK_MODE) + mode->flags |= DRM_MODE_FLAG_DBLSCAN; + + mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10; + + if (index == 1) { + /* PAL timings appear to have wrong values for totals */ + mode->crtc_htotal -= 1; + mode->crtc_vtotal -= 1; + } + break; + case 2: + tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); + if (index >= MAX_SUPPORTED_TV_TIMING_V1_2) + return false; + + dtd_timings = &tv_info_v1_2->aModeTimings[index]; + mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) + + le16_to_cpu(dtd_timings->usHBlanking_Time); + mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive); + mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) + + le16_to_cpu(dtd_timings->usHSyncOffset); + mode->crtc_hsync_end = mode->crtc_hsync_start + + le16_to_cpu(dtd_timings->usHSyncWidth); + + mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) + + le16_to_cpu(dtd_timings->usVBlanking_Time); + mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive); + mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) + + le16_to_cpu(dtd_timings->usVSyncOffset); + mode->crtc_vsync_end = mode->crtc_vsync_start + + le16_to_cpu(dtd_timings->usVSyncWidth); + + mode->flags = 0; + misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess); + if (misc & ATOM_VSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NVSYNC; + if (misc & ATOM_HSYNC_POLARITY) + mode->flags |= DRM_MODE_FLAG_NHSYNC; + if (misc & ATOM_COMPOSITESYNC) + mode->flags |= DRM_MODE_FLAG_CSYNC; + if (misc & ATOM_INTERLACE) + mode->flags |= DRM_MODE_FLAG_INTERLACE; + if (misc & ATOM_DOUBLE_CLOCK_MODE) + mode->flags |= DRM_MODE_FLAG_DBLSCAN; + + mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10; + break; + } + return true; +} +","@@ -1264,7 +1264,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, + switch (crev) { + case 1: + tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); +- if (index > MAX_SUPPORTED_TV_TIMING) ++ if (index >= MAX_SUPPORTED_TV_TIMING) + return false; + + mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); +@@ -1302,7 +1302,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, + break; + case 2: + tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); +- if (index > MAX_SUPPORTED_TV_TIMING_V1_2) ++ if (index >= MAX_SUPPORTED_TV_TIMING_V1_2) + return false; + + dtd_timings = &tv_info_v1_2->aModeTimings[index];",1247,1483,2048 +18242,"SQLRETURN SQLSetDescField( SQLHDESC descriptor_handle, + SQLSMALLINT rec_number, + SQLSMALLINT field_identifier, + SQLPOINTER value, + SQLINTEGER buffer_length ) +{ + /* + * not quite sure how the descriptor can be + * allocated to a statement, all the documentation talks + * about state transitions on statement states, but the + * descriptor may be allocated with more than one statement + * at one time. Which one should I check ? + */ + DMHDESC descriptor = (DMHDESC) descriptor_handle; + SQLRETURN ret; + SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ]; + int isStrField = 0; + + /* + * check descriptor + */ + + if ( !__validate_desc( descriptor )) + { + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: SQL_INVALID_HANDLE"" ); + + return SQL_INVALID_HANDLE; + } + + function_entry( descriptor ); + + if ( log_info.log_flag ) + { + sprintf( descriptor -> msg, ""\n\t\tEntry:\ +\n\t\t\tDescriptor = %p\ +\n\t\t\tRec Number = %d\ +\n\t\t\tField Ident = %s\ +\n\t\t\tValue = %p\ +\n\t\t\tBuffer Length = %d"", + descriptor, + rec_number, + __desc_attr_as_string( s1, field_identifier ), + value, + (int)buffer_length ); + + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + descriptor -> msg ); + } + + thread_protect( SQL_HANDLE_DESC, descriptor ); + + if ( descriptor -> connection -> state < STATE_C4 ) + { + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: HY010"" ); + + __post_internal_error( &descriptor -> error, + ERROR_HY010, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + /* + * check status of statements associated with this descriptor + */ + + if( __check_stmt_from_desc( descriptor, STATE_S8 ) || + __check_stmt_from_desc( descriptor, STATE_S9 ) || + __check_stmt_from_desc( descriptor, STATE_S10 ) || + __check_stmt_from_desc( descriptor, STATE_S11 ) || + __check_stmt_from_desc( descriptor, STATE_S12 ) || + __check_stmt_from_desc( descriptor, STATE_S13 ) || + __check_stmt_from_desc( descriptor, STATE_S14 ) || + __check_stmt_from_desc( descriptor, STATE_S15 )) { + + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: HY010"" ); + + __post_internal_error( &descriptor -> error, + ERROR_HY010, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + + if ( rec_number < 0 ) + { + __post_internal_error( &descriptor -> error, + ERROR_07009, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + switch ( field_identifier ) + { + /* Fixed-length fields: buffer_length is ignored */ + case SQL_DESC_ALLOC_TYPE: + case SQL_DESC_ARRAY_SIZE: + case SQL_DESC_ARRAY_STATUS_PTR: + case SQL_DESC_BIND_OFFSET_PTR: + case SQL_DESC_BIND_TYPE: + case SQL_DESC_COUNT: + case SQL_DESC_ROWS_PROCESSED_PTR: + case SQL_DESC_AUTO_UNIQUE_VALUE: + case SQL_DESC_CASE_SENSITIVE: + case SQL_DESC_CONCISE_TYPE: + case SQL_DESC_DATA_PTR: + case SQL_DESC_DATETIME_INTERVAL_CODE: + case SQL_DESC_DATETIME_INTERVAL_PRECISION: + case SQL_DESC_DISPLAY_SIZE: + case SQL_DESC_FIXED_PREC_SCALE: + case SQL_DESC_INDICATOR_PTR: + case SQL_DESC_LENGTH: + case SQL_DESC_NULLABLE: + case SQL_DESC_NUM_PREC_RADIX: + case SQL_DESC_OCTET_LENGTH: + case SQL_DESC_OCTET_LENGTH_PTR: + case SQL_DESC_PARAMETER_TYPE: + case SQL_DESC_PRECISION: + case SQL_DESC_ROWVER: + case SQL_DESC_SCALE: + case SQL_DESC_SEARCHABLE: + case SQL_DESC_TYPE: + case SQL_DESC_UNNAMED: + case SQL_DESC_UNSIGNED: + case SQL_DESC_UPDATABLE: + isStrField = 0; + break; + /* Pointer to data: buffer_length must be valid */ + case SQL_DESC_BASE_COLUMN_NAME: + case SQL_DESC_BASE_TABLE_NAME: + case SQL_DESC_CATALOG_NAME: + case SQL_DESC_LABEL: + case SQL_DESC_LITERAL_PREFIX: + case SQL_DESC_LITERAL_SUFFIX: + case SQL_DESC_LOCAL_TYPE_NAME: + case SQL_DESC_NAME: + case SQL_DESC_SCHEMA_NAME: + case SQL_DESC_TABLE_NAME: + case SQL_DESC_TYPE_NAME: + isStrField = 1; + break; + default: + isStrField = buffer_length != SQL_IS_POINTER && buffer_length != SQL_IS_INTEGER + && buffer_length != SQL_IS_UINTEGER && buffer_length != SQL_IS_SMALLINT && + buffer_length != SQL_IS_USMALLINT; + } + + if ( isStrField && buffer_length < 0 && buffer_length != SQL_NTS) + { + __post_internal_error( &descriptor -> error, + ERROR_HY090, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( field_identifier == SQL_DESC_COUNT && (SQLINTEGER)value < 0 ) + { + __post_internal_error( &descriptor -> error, + ERROR_07009, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT + && value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT && + value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM ) + { + __post_internal_error( &descriptor -> error, + ERROR_HY105, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( CHECK_SQLSETDESCFIELD( descriptor -> connection )) + { + ret = SQLSETDESCFIELD( descriptor -> connection, + descriptor -> driver_desc, + rec_number, + field_identifier, + value, + buffer_length ); + } + else if ( CHECK_SQLSETDESCFIELDW( descriptor -> connection )) + { + SQLWCHAR *s1 = NULL; + + if (isStrField) + { + s1 = ansi_to_unicode_alloc( value, buffer_length, descriptor -> connection, NULL ); + if (SQL_NTS != buffer_length) + { + buffer_length *= sizeof(SQLWCHAR); + } + } + else + { + s1 = value; + } + ret = SQLSETDESCFIELDW( descriptor -> connection, + descriptor -> driver_desc, + rec_number, + field_identifier, + s1, + buffer_length ); + + if (isStrField) + { + if (s1) + free(s1); + } + } + else + { + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: IM001"" ); + + __post_internal_error( &descriptor -> error, + ERROR_IM001, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( log_info.log_flag ) + { + sprintf( descriptor -> msg, + ""\n\t\tExit:[%s]"", + __get_return_status( ret, s1 )); + + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + descriptor -> msg ); + } + + return function_return( SQL_HANDLE_DESC, descriptor, ret ); +} +",1,"SQLRETURN SQLSetDescField( SQLHDESC descriptor_handle, + SQLSMALLINT rec_number, + SQLSMALLINT field_identifier, + SQLPOINTER value, + SQLINTEGER buffer_length ) +{ + /* + * not quite sure how the descriptor can be + * allocated to a statement, all the documentation talks + * about state transitions on statement states, but the + * descriptor may be allocated with more than one statement + * at one time. Which one should I check ? + */ + DMHDESC descriptor = (DMHDESC) descriptor_handle; + SQLRETURN ret; + SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ]; + int isStrField = 0; + + /* + * check descriptor + */ + + if ( !__validate_desc( descriptor )) + { + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: SQL_INVALID_HANDLE"" ); + + return SQL_INVALID_HANDLE; + } + + function_entry( descriptor ); + + if ( log_info.log_flag ) + { + sprintf( descriptor -> msg, ""\n\t\tEntry:\ +\n\t\t\tDescriptor = %p\ +\n\t\t\tRec Number = %d\ +\n\t\t\tField Ident = %s\ +\n\t\t\tValue = %p\ +\n\t\t\tBuffer Length = %d"", + descriptor, + rec_number, + __desc_attr_as_string( s1, field_identifier ), + value, + (int)buffer_length ); + + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + descriptor -> msg ); + } + + thread_protect( SQL_HANDLE_DESC, descriptor ); + + if ( descriptor -> connection -> state < STATE_C4 ) + { + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: HY010"" ); + + __post_internal_error( &descriptor -> error, + ERROR_HY010, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + /* + * check status of statements associated with this descriptor + */ + + if( __check_stmt_from_desc( descriptor, STATE_S8 ) || + __check_stmt_from_desc( descriptor, STATE_S9 ) || + __check_stmt_from_desc( descriptor, STATE_S10 ) || + __check_stmt_from_desc( descriptor, STATE_S11 ) || + __check_stmt_from_desc( descriptor, STATE_S12 ) || + __check_stmt_from_desc( descriptor, STATE_S13 ) || + __check_stmt_from_desc( descriptor, STATE_S14 ) || + __check_stmt_from_desc( descriptor, STATE_S15 )) { + + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: HY010"" ); + + __post_internal_error( &descriptor -> error, + ERROR_HY010, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + + if ( rec_number < 0 ) + { + __post_internal_error( &descriptor -> error, + ERROR_07009, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + switch ( field_identifier ) + { + /* Fixed-length fields: buffer_length is ignored */ + case SQL_DESC_ALLOC_TYPE: + case SQL_DESC_ARRAY_SIZE: + case SQL_DESC_ARRAY_STATUS_PTR: + case SQL_DESC_BIND_OFFSET_PTR: + case SQL_DESC_BIND_TYPE: + case SQL_DESC_COUNT: + case SQL_DESC_ROWS_PROCESSED_PTR: + case SQL_DESC_AUTO_UNIQUE_VALUE: + case SQL_DESC_CASE_SENSITIVE: + case SQL_DESC_CONCISE_TYPE: + case SQL_DESC_DATA_PTR: + case SQL_DESC_DATETIME_INTERVAL_CODE: + case SQL_DESC_DATETIME_INTERVAL_PRECISION: + case SQL_DESC_DISPLAY_SIZE: + case SQL_DESC_FIXED_PREC_SCALE: + case SQL_DESC_INDICATOR_PTR: + case SQL_DESC_LENGTH: + case SQL_DESC_NULLABLE: + case SQL_DESC_NUM_PREC_RADIX: + case SQL_DESC_OCTET_LENGTH: + case SQL_DESC_OCTET_LENGTH_PTR: + case SQL_DESC_PARAMETER_TYPE: + case SQL_DESC_PRECISION: + case SQL_DESC_ROWVER: + case SQL_DESC_SCALE: + case SQL_DESC_SEARCHABLE: + case SQL_DESC_TYPE: + case SQL_DESC_UNNAMED: + case SQL_DESC_UNSIGNED: + case SQL_DESC_UPDATABLE: + isStrField = 0; + break; + /* Pointer to data: buffer_length must be valid */ + case SQL_DESC_BASE_COLUMN_NAME: + case SQL_DESC_BASE_TABLE_NAME: + case SQL_DESC_CATALOG_NAME: + case SQL_DESC_LABEL: + case SQL_DESC_LITERAL_PREFIX: + case SQL_DESC_LITERAL_SUFFIX: + case SQL_DESC_LOCAL_TYPE_NAME: + case SQL_DESC_NAME: + case SQL_DESC_SCHEMA_NAME: + case SQL_DESC_TABLE_NAME: + case SQL_DESC_TYPE_NAME: + isStrField = 1; + break; + default: + isStrField = buffer_length != SQL_IS_POINTER && buffer_length != SQL_IS_INTEGER + && buffer_length != SQL_IS_UINTEGER && buffer_length != SQL_IS_SMALLINT && + buffer_length != SQL_IS_USMALLINT; + } + + if ( isStrField && buffer_length < 0 && buffer_length != SQL_NTS) + { + __post_internal_error( &descriptor -> error, + ERROR_HY090, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( field_identifier == SQL_DESC_COUNT && (intptr_t)value < 0 ) + { + __post_internal_error( &descriptor -> error, + ERROR_07009, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( field_identifier == SQL_DESC_PARAMETER_TYPE && (intptr_t)value != SQL_PARAM_INPUT + && (intptr_t)value != SQL_PARAM_OUTPUT && (intptr_t)value != SQL_PARAM_INPUT_OUTPUT && + (intptr_t)value != SQL_PARAM_INPUT_OUTPUT_STREAM && (intptr_t)value != SQL_PARAM_OUTPUT_STREAM ) + { + __post_internal_error( &descriptor -> error, + ERROR_HY105, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( CHECK_SQLSETDESCFIELD( descriptor -> connection )) + { + ret = SQLSETDESCFIELD( descriptor -> connection, + descriptor -> driver_desc, + rec_number, + field_identifier, + value, + buffer_length ); + } + else if ( CHECK_SQLSETDESCFIELDW( descriptor -> connection )) + { + SQLWCHAR *s1 = NULL; + + if (isStrField) + { + s1 = ansi_to_unicode_alloc( value, buffer_length, descriptor -> connection, NULL ); + if (SQL_NTS != buffer_length) + { + buffer_length *= sizeof(SQLWCHAR); + } + } + else + { + s1 = value; + } + ret = SQLSETDESCFIELDW( descriptor -> connection, + descriptor -> driver_desc, + rec_number, + field_identifier, + s1, + buffer_length ); + + if (isStrField) + { + if (s1) + free(s1); + } + } + else + { + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + ""Error: IM001"" ); + + __post_internal_error( &descriptor -> error, + ERROR_IM001, NULL, + descriptor -> connection -> environment -> requested_version ); + + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + + if ( log_info.log_flag ) + { + sprintf( descriptor -> msg, + ""\n\t\tExit:[%s]"", + __get_return_status( ret, s1 )); + + dm_log_write( __FILE__, + __LINE__, + LOG_INFO, + LOG_INFO, + descriptor -> msg ); + } + + return function_return( SQL_HANDLE_DESC, descriptor, ret ); +} +","@@ -306,7 +306,7 @@ SQLRETURN SQLSetDescField( SQLHDESC descriptor_handle, + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + +- if ( field_identifier == SQL_DESC_COUNT && (SQLINTEGER)value < 0 ) ++ if ( field_identifier == SQL_DESC_COUNT && (intptr_t)value < 0 ) + { + __post_internal_error( &descriptor -> error, + ERROR_07009, NULL, +@@ -315,9 +315,9 @@ SQLRETURN SQLSetDescField( SQLHDESC descriptor_handle, + return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR ); + } + +- if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT +- && value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT && +- value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM ) ++ if ( field_identifier == SQL_DESC_PARAMETER_TYPE && (intptr_t)value != SQL_PARAM_INPUT ++ && (intptr_t)value != SQL_PARAM_OUTPUT && (intptr_t)value != SQL_PARAM_INPUT_OUTPUT && ++ (intptr_t)value != SQL_PARAM_INPUT_OUTPUT_STREAM && (intptr_t)value != SQL_PARAM_OUTPUT_STREAM ) + { + __post_internal_error( &descriptor -> error, + ERROR_HY105, NULL,",1789,2025,2048 +1604,"void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, + struct timeval t, void *private_data) +{ + struct ctdb_node *node = talloc_get_type(private_data, + struct ctdb_node); + struct ctdb_tcp_node *tnode = talloc_get_type(node->private_data, + struct ctdb_tcp_node); + struct ctdb_context *ctdb = node->ctdb; + ctdb_sock_addr sock_in; + int sockin_size; + int sockout_size; + ctdb_sock_addr sock_out; + + ctdb_tcp_stop_connection(node); + + ZERO_STRUCT(sock_out); +#ifdef HAVE_SOCK_SIN_LEN + sock_out.ip.sin_len = sizeof(sock_out); +#endif + if (ctdb_tcp_get_address(ctdb, node->address.address, &sock_out) != 0) { + return; + } + switch (sock_out.sa.sa_family) { + case AF_INET: + sock_out.ip.sin_port = htons(node->address.port); + break; + case AF_INET6: + sock_out.ip6.sin6_port = htons(node->address.port); + break; + default: + DEBUG(DEBUG_ERR, (__location__ "" unknown family %u\n"", + sock_out.sa.sa_family)); + return; + } + + tnode->fd = socket(sock_out.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); + if (tnode->fd == -1) { + DEBUG(DEBUG_ERR, (__location__ ""Failed to create socket\n"")); + return; + } + set_nonblocking(tnode->fd); + set_close_on_exec(tnode->fd); + + DEBUG(DEBUG_DEBUG, (__location__ "" Created TCP SOCKET FD:%d\n"", tnode->fd)); + + /* Bind our side of the socketpair to the same address we use to listen + * on incoming CTDB traffic. + * We must specify this address to make sure that the address we expose to + * the remote side is actually routable in case CTDB traffic will run on + * a dedicated non-routeable network. + */ + ZERO_STRUCT(sock_in); + if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in) != 0) { + DEBUG(DEBUG_ERR, (__location__ "" Failed to find our address. Failing bind.\n"")); + close(tnode->fd); + return; + } + + /* AIX libs check to see if the socket address and length + arguments are consistent with each other on calls like + connect(). Can not get by with just sizeof(sock_in), + need sizeof(sock_in.ip). + */ + switch (sock_in.sa.sa_family) { + case AF_INET: + sockin_size = sizeof(sock_in.ip); + sockout_size = sizeof(sock_out.ip); + break; + case AF_INET6: + sockin_size = sizeof(sock_in.ip6); + sockout_size = sizeof(sock_out.ip6); + break; + default: + DEBUG(DEBUG_ERR, (__location__ "" unknown family %u\n"", + sock_in.sa.sa_family)); + close(tnode->fd); + return; + } +#ifdef HAVE_SOCK_SIN_LEN + sock_in.ip.sin_len = sockin_size; + sock_out.ip.sin_len = sockout_size; +#endif + if (bind(tnode->fd, (struct sockaddr *)&sock_in, sockin_size) == -1) { + DEBUG(DEBUG_ERR, (__location__ ""Failed to bind socket %s(%d)\n"", + strerror(errno), errno)); + close(tnode->fd); + return; + } + + if (connect(tnode->fd, (struct sockaddr *)&sock_out, sockout_size) != 0 && + errno != EINPROGRESS) { + ctdb_tcp_stop_connection(node); + tnode->connect_te = event_add_timed(ctdb->ev, tnode, + timeval_current_ofs(1, 0), + ctdb_tcp_node_connect, node); + return; + } + + /* non-blocking connect - wait for write event */ + tnode->connect_fde = event_add_fd(node->ctdb->ev, tnode, tnode->fd, + EVENT_FD_WRITE|EVENT_FD_READ, + ctdb_node_connect_write, node); + + /* don't give it long to connect - retry in one second. This ensures + that we find a node is up quickly (tcp normally backs off a syn reply + delay by quite a lot) */ + tnode->connect_te = event_add_timed(ctdb->ev, tnode, timeval_current_ofs(1, 0), + ctdb_tcp_node_connect, node); +} +",0,"void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, + struct timeval t, void *private_data) +{ + struct ctdb_node *node = talloc_get_type(private_data, + struct ctdb_node); + struct ctdb_tcp_node *tnode = talloc_get_type(node->private_data, + struct ctdb_tcp_node); + struct ctdb_context *ctdb = node->ctdb; + ctdb_sock_addr sock_in; + int sockin_size; + int sockout_size; + ctdb_sock_addr sock_out; + + ctdb_tcp_stop_connection(node); + + ZERO_STRUCT(sock_out); +#ifdef HAVE_SOCK_SIN_LEN + sock_out.ip.sin_len = sizeof(sock_out); +#endif + if (ctdb_tcp_get_address(ctdb, node->address.address, &sock_out) != 0) { + return; + } + switch (sock_out.sa.sa_family) { + case AF_INET: + sock_out.ip.sin_port = htons(node->address.port); + break; + case AF_INET6: + sock_out.ip6.sin6_port = htons(node->address.port); + break; + default: + DEBUG(DEBUG_ERR, (__location__ "" unknown family %u\n"", + sock_out.sa.sa_family)); + return; + } + + tnode->fd = socket(sock_out.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); + if (tnode->fd == -1) { + DEBUG(DEBUG_ERR, (__location__ ""Failed to create socket\n"")); + return; + } + set_nonblocking(tnode->fd); + set_close_on_exec(tnode->fd); + + DEBUG(DEBUG_DEBUG, (__location__ "" Created TCP SOCKET FD:%d\n"", tnode->fd)); + + /* Bind our side of the socketpair to the same address we use to listen + * on incoming CTDB traffic. + * We must specify this address to make sure that the address we expose to + * the remote side is actually routable in case CTDB traffic will run on + * a dedicated non-routeable network. + */ + ZERO_STRUCT(sock_in); + if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in) != 0) { + DEBUG(DEBUG_ERR, (__location__ "" Failed to find our address. Failing bind.\n"")); + close(tnode->fd); + return; + } + + /* AIX libs check to see if the socket address and length + arguments are consistent with each other on calls like + connect(). Can not get by with just sizeof(sock_in), + need sizeof(sock_in.ip). + */ + switch (sock_in.sa.sa_family) { + case AF_INET: + sockin_size = sizeof(sock_in.ip); + sockout_size = sizeof(sock_out.ip); + break; + case AF_INET6: + sockin_size = sizeof(sock_in.ip6); + sockout_size = sizeof(sock_out.ip6); + break; + default: + DEBUG(DEBUG_ERR, (__location__ "" unknown family %u\n"", + sock_in.sa.sa_family)); + close(tnode->fd); + return; + } +#ifdef HAVE_SOCK_SIN_LEN + sock_in.ip.sin_len = sockin_size; + sock_out.ip.sin_len = sockout_size; +#endif + if (bind(tnode->fd, (struct sockaddr *)&sock_in, sockin_size) == -1) { + DEBUG(DEBUG_ERR, (__location__ ""Failed to bind socket %s(%d)\n"", + strerror(errno), errno)); + close(tnode->fd); + return; + } + + if (connect(tnode->fd, (struct sockaddr *)&sock_out, sockout_size) != 0 && + errno != EINPROGRESS) { + ctdb_tcp_stop_connection(node); + tnode->connect_te = event_add_timed(ctdb->ev, tnode, + timeval_current_ofs(1, 0), + ctdb_tcp_node_connect, node); + return; + } + + /* non-blocking connect - wait for write event */ + tnode->connect_fde = event_add_fd(node->ctdb->ev, tnode, tnode->fd, + EVENT_FD_WRITE|EVENT_FD_READ, + ctdb_node_connect_write, node); + + /* don't give it long to connect - retry in one second. This ensures + that we find a node is up quickly (tcp normally backs off a syn reply + delay by quite a lot) */ + tnode->connect_te = event_add_timed(ctdb->ev, tnode, timeval_current_ofs(1, 0), + ctdb_tcp_node_connect, node); +} +","@@ -284,7 +284,7 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb) + struct ctdb_tcp); + ctdb_sock_addr sock; + int lock_fd, i; +- const char *lock_path = ""/tmp/.ctdb_socket_lock""; ++ const char *lock_path = VARDIR ""/run/ctdb/.socket_lock""; + struct flock lock; + int one = 1; + int sock_size;",965,1201,2048 +1158,"int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete) /* {{{ */ +{ + const char *pos, *slash; + + *ext_str = NULL; + *ext_len = 0; + + if (!filename_len || filename_len == 1) { + return FAILURE; + } + + phar_request_initialize(); + /* first check for alias in first segment */ + pos = memchr(filename, '/', filename_len); + + if (pos && pos != filename) { + /* check for url like http:// or phar:// */ + if (*(pos - 1) == ':' && (pos - filename) < filename_len - 1 && *(pos + 1) == '/') { + *ext_len = -2; + *ext_str = NULL; + return FAILURE; + } + if (zend_hash_str_exists(&(PHAR_G(phar_alias_map)), (char *) filename, pos - filename)) { + *ext_str = pos; + *ext_len = -1; + return FAILURE; + } + + if (PHAR_G(manifest_cached) && zend_hash_str_exists(&cached_alias, (char *) filename, pos - filename)) { + *ext_str = pos; + *ext_len = -1; + return FAILURE; + } + } + + if (zend_hash_num_elements(&(PHAR_G(phar_fname_map))) || PHAR_G(manifest_cached)) { + phar_archive_data *pphar; + + if (is_complete) { + if (NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), (char *) filename, filename_len))) { + *ext_str = filename + (filename_len - pphar->ext_len); +woohoo: + *ext_len = pphar->ext_len; + + if (executable == 2) { + return SUCCESS; + } + + if (executable == 1 && !pphar->is_data) { + return SUCCESS; + } + + if (!executable && pphar->is_data) { + return SUCCESS; + } + + return FAILURE; + } + + if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, (char *) filename, filename_len))) { + *ext_str = filename + (filename_len - pphar->ext_len); + goto woohoo; + } + } else { + zend_string *str_key; + zend_ulong unused; + + for (zend_hash_internal_pointer_reset(&(PHAR_G(phar_fname_map))); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&(PHAR_G(phar_fname_map)), &str_key, &unused); + zend_hash_move_forward(&(PHAR_G(phar_fname_map))) + ) { + if (ZSTR_LEN(str_key) > (uint) filename_len) { + continue; + } + + if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key) + || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) { + if (NULL == (pphar = zend_hash_get_current_data_ptr(&(PHAR_G(phar_fname_map))))) { + break; + } + *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len); + goto woohoo; + } + } + + if (PHAR_G(manifest_cached)) { + for (zend_hash_internal_pointer_reset(&cached_phars); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&cached_phars, &str_key, &unused); + zend_hash_move_forward(&cached_phars) + ) { + if (ZSTR_LEN(str_key) > (uint) filename_len) { + continue; + } + + if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key) + || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) { + if (NULL == (pphar = zend_hash_get_current_data_ptr(&cached_phars))) { + break; + } + *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len); + goto woohoo; + } + } + } + } + } + + pos = memchr(filename + 1, '.', filename_len); +next_extension: + if (!pos) { + return FAILURE; + } + + while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { + pos = memchr(pos + 1, '.', filename_len - (pos - filename) + 1); + if (!pos) { + return FAILURE; + } + } + + slash = memchr(pos, '/', filename_len - (pos - filename)); + + if (!slash) { + /* this is a url like ""phar://blah.phar"" with no directory */ + *ext_str = pos; + *ext_len = strlen(pos); + + /* file extension must contain ""phar"" */ + switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create)) { + case SUCCESS: + return SUCCESS; + case FAILURE: + /* we are at the end of the string, so we fail */ + return FAILURE; + } + } + + /* we've found an extension that ends at a directory separator */ + *ext_str = pos; + *ext_len = slash - pos; + + switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create)) { + case SUCCESS: + return SUCCESS; + case FAILURE: + /* look for more extensions */ + pos = strchr(pos + 1, '.'); + if (pos) { + *ext_str = NULL; + *ext_len = 0; + } + goto next_extension; + } + + return FAILURE; +} +/* }}} */ +",0,"int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete) /* {{{ */ +{ + const char *pos, *slash; + + *ext_str = NULL; + *ext_len = 0; + + if (!filename_len || filename_len == 1) { + return FAILURE; + } + + phar_request_initialize(); + /* first check for alias in first segment */ + pos = memchr(filename, '/', filename_len); + + if (pos && pos != filename) { + /* check for url like http:// or phar:// */ + if (*(pos - 1) == ':' && (pos - filename) < filename_len - 1 && *(pos + 1) == '/') { + *ext_len = -2; + *ext_str = NULL; + return FAILURE; + } + if (zend_hash_str_exists(&(PHAR_G(phar_alias_map)), (char *) filename, pos - filename)) { + *ext_str = pos; + *ext_len = -1; + return FAILURE; + } + + if (PHAR_G(manifest_cached) && zend_hash_str_exists(&cached_alias, (char *) filename, pos - filename)) { + *ext_str = pos; + *ext_len = -1; + return FAILURE; + } + } + + if (zend_hash_num_elements(&(PHAR_G(phar_fname_map))) || PHAR_G(manifest_cached)) { + phar_archive_data *pphar; + + if (is_complete) { + if (NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), (char *) filename, filename_len))) { + *ext_str = filename + (filename_len - pphar->ext_len); +woohoo: + *ext_len = pphar->ext_len; + + if (executable == 2) { + return SUCCESS; + } + + if (executable == 1 && !pphar->is_data) { + return SUCCESS; + } + + if (!executable && pphar->is_data) { + return SUCCESS; + } + + return FAILURE; + } + + if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, (char *) filename, filename_len))) { + *ext_str = filename + (filename_len - pphar->ext_len); + goto woohoo; + } + } else { + zend_string *str_key; + zend_ulong unused; + + for (zend_hash_internal_pointer_reset(&(PHAR_G(phar_fname_map))); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&(PHAR_G(phar_fname_map)), &str_key, &unused); + zend_hash_move_forward(&(PHAR_G(phar_fname_map))) + ) { + if (ZSTR_LEN(str_key) > (uint) filename_len) { + continue; + } + + if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key) + || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) { + if (NULL == (pphar = zend_hash_get_current_data_ptr(&(PHAR_G(phar_fname_map))))) { + break; + } + *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len); + goto woohoo; + } + } + + if (PHAR_G(manifest_cached)) { + for (zend_hash_internal_pointer_reset(&cached_phars); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&cached_phars, &str_key, &unused); + zend_hash_move_forward(&cached_phars) + ) { + if (ZSTR_LEN(str_key) > (uint) filename_len) { + continue; + } + + if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key) + || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) { + if (NULL == (pphar = zend_hash_get_current_data_ptr(&cached_phars))) { + break; + } + *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len); + goto woohoo; + } + } + } + } + } + + pos = memchr(filename + 1, '.', filename_len); +next_extension: + if (!pos) { + return FAILURE; + } + + while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { + pos = memchr(pos + 1, '.', filename_len - (pos - filename) + 1); + if (!pos) { + return FAILURE; + } + } + + slash = memchr(pos, '/', filename_len - (pos - filename)); + + if (!slash) { + /* this is a url like ""phar://blah.phar"" with no directory */ + *ext_str = pos; + *ext_len = strlen(pos); + + /* file extension must contain ""phar"" */ + switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create)) { + case SUCCESS: + return SUCCESS; + case FAILURE: + /* we are at the end of the string, so we fail */ + return FAILURE; + } + } + + /* we've found an extension that ends at a directory separator */ + *ext_str = pos; + *ext_len = slash - pos; + + switch (phar_check_str(filename, *ext_str, *ext_len, executable, for_create)) { + case SUCCESS: + return SUCCESS; + case FAILURE: + /* look for more extensions */ + pos = strchr(pos + 1, '.'); + if (pos) { + *ext_str = NULL; + *ext_len = 0; + } + goto next_extension; + } + + return FAILURE; +} +/* }}} */ +","@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a + #endif + int ext_len; + ++ if (CHECK_NULL_PATH(filename, filename_len)) { ++ return FAILURE; ++ } ++ + if (!strncasecmp(filename, ""phar://"", 7)) { + filename += 7; + filename_len -= 7;",1320,1556,2048 +3301,"static long kvm_vcpu_ioctl(struct file *filp, + unsigned int ioctl, unsigned long arg) +{ + struct kvm_vcpu *vcpu = filp->private_data; + void __user *argp = (void __user *)arg; + int r; + struct kvm_fpu *fpu = NULL; + struct kvm_sregs *kvm_sregs = NULL; + + if (vcpu->kvm->mm != current->mm) + return -EIO; + +#if defined(CONFIG_S390) || defined(CONFIG_PPC) + /* + * Special cases: vcpu ioctls that are asynchronous to vcpu execution, + * so vcpu_load() would break it. + */ + if (ioctl == KVM_S390_INTERRUPT || ioctl == KVM_INTERRUPT) + return kvm_arch_vcpu_ioctl(filp, ioctl, arg); +#endif + + + vcpu_load(vcpu); + switch (ioctl) { + case KVM_RUN: + r = -EINVAL; + if (arg) + goto out; + r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run); + trace_kvm_userspace_exit(vcpu->run->exit_reason, r); + break; + case KVM_GET_REGS: { + struct kvm_regs *kvm_regs; + + r = -ENOMEM; + kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL); + if (!kvm_regs) + goto out; + r = kvm_arch_vcpu_ioctl_get_regs(vcpu, kvm_regs); + if (r) + goto out_free1; + r = -EFAULT; + if (copy_to_user(argp, kvm_regs, sizeof(struct kvm_regs))) + goto out_free1; + r = 0; +out_free1: + kfree(kvm_regs); + break; + } + case KVM_SET_REGS: { + struct kvm_regs *kvm_regs; + + r = -ENOMEM; + kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL); + if (!kvm_regs) + goto out; + r = -EFAULT; + if (copy_from_user(kvm_regs, argp, sizeof(struct kvm_regs))) + goto out_free2; + r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs); + if (r) + goto out_free2; + r = 0; +out_free2: + kfree(kvm_regs); + break; + } + case KVM_GET_SREGS: { + kvm_sregs = kzalloc(sizeof(struct kvm_sregs), GFP_KERNEL); + r = -ENOMEM; + if (!kvm_sregs) + goto out; + r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, kvm_sregs); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, kvm_sregs, sizeof(struct kvm_sregs))) + goto out; + r = 0; + break; + } + case KVM_SET_SREGS: { + kvm_sregs = kmalloc(sizeof(struct kvm_sregs), GFP_KERNEL); + r = -ENOMEM; + if (!kvm_sregs) + goto out; + r = -EFAULT; + if (copy_from_user(kvm_sregs, argp, sizeof(struct kvm_sregs))) + goto out; + r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs); + if (r) + goto out; + r = 0; + break; + } + case KVM_GET_MP_STATE: { + struct kvm_mp_state mp_state; + + r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, &mp_state, sizeof mp_state)) + goto out; + r = 0; + break; + } + case KVM_SET_MP_STATE: { + struct kvm_mp_state mp_state; + + r = -EFAULT; + if (copy_from_user(&mp_state, argp, sizeof mp_state)) + goto out; + r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state); + if (r) + goto out; + r = 0; + break; + } + case KVM_TRANSLATE: { + struct kvm_translation tr; + + r = -EFAULT; + if (copy_from_user(&tr, argp, sizeof tr)) + goto out; + r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, &tr, sizeof tr)) + goto out; + r = 0; + break; + } + case KVM_SET_GUEST_DEBUG: { + struct kvm_guest_debug dbg; + + r = -EFAULT; + if (copy_from_user(&dbg, argp, sizeof dbg)) + goto out; + r = kvm_arch_vcpu_ioctl_set_guest_debug(vcpu, &dbg); + if (r) + goto out; + r = 0; + break; + } + case KVM_SET_SIGNAL_MASK: { + struct kvm_signal_mask __user *sigmask_arg = argp; + struct kvm_signal_mask kvm_sigmask; + sigset_t sigset, *p; + + p = NULL; + if (argp) { + r = -EFAULT; + if (copy_from_user(&kvm_sigmask, argp, + sizeof kvm_sigmask)) + goto out; + r = -EINVAL; + if (kvm_sigmask.len != sizeof sigset) + goto out; + r = -EFAULT; + if (copy_from_user(&sigset, sigmask_arg->sigset, + sizeof sigset)) + goto out; + p = &sigset; + } + r = kvm_vcpu_ioctl_set_sigmask(vcpu, p); + break; + } + case KVM_GET_FPU: { + fpu = kzalloc(sizeof(struct kvm_fpu), GFP_KERNEL); + r = -ENOMEM; + if (!fpu) + goto out; + r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, fpu); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, fpu, sizeof(struct kvm_fpu))) + goto out; + r = 0; + break; + } + case KVM_SET_FPU: { + fpu = kmalloc(sizeof(struct kvm_fpu), GFP_KERNEL); + r = -ENOMEM; + if (!fpu) + goto out; + r = -EFAULT; + if (copy_from_user(fpu, argp, sizeof(struct kvm_fpu))) + goto out; + r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu); + if (r) + goto out; + r = 0; + break; + } + default: + r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); + } +out: + vcpu_put(vcpu); + kfree(fpu); + kfree(kvm_sregs); + return r; +} +",0,"static long kvm_vcpu_ioctl(struct file *filp, + unsigned int ioctl, unsigned long arg) +{ + struct kvm_vcpu *vcpu = filp->private_data; + void __user *argp = (void __user *)arg; + int r; + struct kvm_fpu *fpu = NULL; + struct kvm_sregs *kvm_sregs = NULL; + + if (vcpu->kvm->mm != current->mm) + return -EIO; + +#if defined(CONFIG_S390) || defined(CONFIG_PPC) + /* + * Special cases: vcpu ioctls that are asynchronous to vcpu execution, + * so vcpu_load() would break it. + */ + if (ioctl == KVM_S390_INTERRUPT || ioctl == KVM_INTERRUPT) + return kvm_arch_vcpu_ioctl(filp, ioctl, arg); +#endif + + + vcpu_load(vcpu); + switch (ioctl) { + case KVM_RUN: + r = -EINVAL; + if (arg) + goto out; + r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run); + trace_kvm_userspace_exit(vcpu->run->exit_reason, r); + break; + case KVM_GET_REGS: { + struct kvm_regs *kvm_regs; + + r = -ENOMEM; + kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL); + if (!kvm_regs) + goto out; + r = kvm_arch_vcpu_ioctl_get_regs(vcpu, kvm_regs); + if (r) + goto out_free1; + r = -EFAULT; + if (copy_to_user(argp, kvm_regs, sizeof(struct kvm_regs))) + goto out_free1; + r = 0; +out_free1: + kfree(kvm_regs); + break; + } + case KVM_SET_REGS: { + struct kvm_regs *kvm_regs; + + r = -ENOMEM; + kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL); + if (!kvm_regs) + goto out; + r = -EFAULT; + if (copy_from_user(kvm_regs, argp, sizeof(struct kvm_regs))) + goto out_free2; + r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs); + if (r) + goto out_free2; + r = 0; +out_free2: + kfree(kvm_regs); + break; + } + case KVM_GET_SREGS: { + kvm_sregs = kzalloc(sizeof(struct kvm_sregs), GFP_KERNEL); + r = -ENOMEM; + if (!kvm_sregs) + goto out; + r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, kvm_sregs); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, kvm_sregs, sizeof(struct kvm_sregs))) + goto out; + r = 0; + break; + } + case KVM_SET_SREGS: { + kvm_sregs = kmalloc(sizeof(struct kvm_sregs), GFP_KERNEL); + r = -ENOMEM; + if (!kvm_sregs) + goto out; + r = -EFAULT; + if (copy_from_user(kvm_sregs, argp, sizeof(struct kvm_sregs))) + goto out; + r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs); + if (r) + goto out; + r = 0; + break; + } + case KVM_GET_MP_STATE: { + struct kvm_mp_state mp_state; + + r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, &mp_state, sizeof mp_state)) + goto out; + r = 0; + break; + } + case KVM_SET_MP_STATE: { + struct kvm_mp_state mp_state; + + r = -EFAULT; + if (copy_from_user(&mp_state, argp, sizeof mp_state)) + goto out; + r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state); + if (r) + goto out; + r = 0; + break; + } + case KVM_TRANSLATE: { + struct kvm_translation tr; + + r = -EFAULT; + if (copy_from_user(&tr, argp, sizeof tr)) + goto out; + r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, &tr, sizeof tr)) + goto out; + r = 0; + break; + } + case KVM_SET_GUEST_DEBUG: { + struct kvm_guest_debug dbg; + + r = -EFAULT; + if (copy_from_user(&dbg, argp, sizeof dbg)) + goto out; + r = kvm_arch_vcpu_ioctl_set_guest_debug(vcpu, &dbg); + if (r) + goto out; + r = 0; + break; + } + case KVM_SET_SIGNAL_MASK: { + struct kvm_signal_mask __user *sigmask_arg = argp; + struct kvm_signal_mask kvm_sigmask; + sigset_t sigset, *p; + + p = NULL; + if (argp) { + r = -EFAULT; + if (copy_from_user(&kvm_sigmask, argp, + sizeof kvm_sigmask)) + goto out; + r = -EINVAL; + if (kvm_sigmask.len != sizeof sigset) + goto out; + r = -EFAULT; + if (copy_from_user(&sigset, sigmask_arg->sigset, + sizeof sigset)) + goto out; + p = &sigset; + } + r = kvm_vcpu_ioctl_set_sigmask(vcpu, p); + break; + } + case KVM_GET_FPU: { + fpu = kzalloc(sizeof(struct kvm_fpu), GFP_KERNEL); + r = -ENOMEM; + if (!fpu) + goto out; + r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, fpu); + if (r) + goto out; + r = -EFAULT; + if (copy_to_user(argp, fpu, sizeof(struct kvm_fpu))) + goto out; + r = 0; + break; + } + case KVM_SET_FPU: { + fpu = kmalloc(sizeof(struct kvm_fpu), GFP_KERNEL); + r = -ENOMEM; + if (!fpu) + goto out; + r = -EFAULT; + if (copy_from_user(fpu, argp, sizeof(struct kvm_fpu))) + goto out; + r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu); + if (r) + goto out; + r = 0; + break; + } + default: + r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); + } +out: + vcpu_put(vcpu); + kfree(fpu); + kfree(kvm_sregs); + return r; +} +","@@ -648,7 +648,10 @@ int __kvm_set_memory_region(struct kvm *kvm, + goto out; + if (mem->guest_phys_addr & (PAGE_SIZE - 1)) + goto out; +- if (user_alloc && (mem->userspace_addr & (PAGE_SIZE - 1))) ++ /* We can read the guest memory with __xxx_user() later on. */ ++ if (user_alloc && ++ ((mem->userspace_addr & (PAGE_SIZE - 1)) || ++ !access_ok(VERIFY_WRITE, mem->userspace_addr, mem->memory_size))) + goto out; + if (mem->slot >= KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS) + goto out; +@@ -1283,7 +1286,7 @@ int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, + addr = gfn_to_hva(kvm, gfn); + if (kvm_is_error_hva(addr)) + return -EFAULT; +- r = copy_from_user(data, (void __user *)addr + offset, len); ++ r = __copy_from_user(data, (void __user *)addr + offset, len); + if (r) + return -EFAULT; + return 0;",1475,1711,2048 +18322,"int gdTransformAffineCopy(gdImagePtr dst, + int dst_x, int dst_y, + const gdImagePtr src, + gdRectPtr src_region, + const double affine[6]) +{ + int c1x,c1y,c2x,c2y; + int backclip = 0; + int backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2; + register int x, y, src_offset_x, src_offset_y; + double inv[6]; + int *dst_p; + gdPointF pt, src_pt; + gdRect bbox; + int end_x, end_y; + gdInterpolationMethod interpolation_id_bak = GD_DEFAULT; + interpolation_method interpolation_bak; + + /* These methods use special implementations */ + if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) { + interpolation_id_bak = src->interpolation_id; + interpolation_bak = src->interpolation; + gdImageSetInterpolationMethod(src, GD_BICUBIC); + } + + + gdImageClipRectangle(src, src_region); + + if (src_region->x > 0 || src_region->y > 0 + || src_region->width < gdImageSX(src) + || src_region->height < gdImageSY(src)) { + backclip = 1; + + gdImageGetClip(src, &backup_clipx1, &backup_clipy1, + &backup_clipx2, &backup_clipy2); + + gdImageSetClip(src, src_region->x, src_region->y, + src_region->x + src_region->width - 1, + src_region->y + src_region->height - 1); + } + + if (!gdTransformAffineBoundingBox(src_region, affine, &bbox)) { + if (backclip) { + gdImageSetClip(src, backup_clipx1, backup_clipy1, + backup_clipx2, backup_clipy2); + } + gdImageSetInterpolationMethod(src, interpolation_id_bak); + return GD_FALSE; + } + + gdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y); + + end_x = bbox.width + (int) fabs(bbox.x); + end_y = bbox.height + (int) fabs(bbox.y); + + /* Get inverse affine to let us work with destination -> source */ + gdAffineInvert(inv, affine); + + src_offset_x = src_region->x; + src_offset_y = src_region->y; + + if (dst->alphaBlendingFlag) { + for (y = bbox.y; y <= end_y; y++) { + pt.y = y + 0.5; + for (x = 0; x <= end_x; x++) { + pt.x = x + 0.5; + gdAffineApplyToPointF(&src_pt, &pt, inv); + gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, 0)); + } + } + } else { + for (y = 0; y <= end_y; y++) { + pt.y = y + 0.5 + bbox.y; + if ((dst_y + y) < 0 || ((dst_y + y) > gdImageSY(dst) -1)) { + continue; + } + dst_p = dst->tpixels[dst_y + y] + dst_x; + + for (x = 0; x <= end_x; x++) { + pt.x = x + 0.5 + bbox.x; + gdAffineApplyToPointF(&src_pt, &pt, inv); + + if ((dst_x + x) < 0 || (dst_x + x) > (gdImageSX(dst) - 1)) { + break; + } + *(dst_p++) = getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, -1); + } + } + } + + /* Restore clip if required */ + if (backclip) { + gdImageSetClip(src, backup_clipx1, backup_clipy1, + backup_clipx2, backup_clipy2); + } + + gdImageSetInterpolationMethod(src, interpolation_id_bak); + return GD_TRUE; +} +",1,"int gdTransformAffineCopy(gdImagePtr dst, + int dst_x, int dst_y, + const gdImagePtr src, + gdRectPtr src_region, + const double affine[6]) +{ + int c1x,c1y,c2x,c2y; + int backclip = 0; + int backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2; + register int x, y, src_offset_x, src_offset_y; + double inv[6]; + int *dst_p; + gdPointF pt, src_pt; + gdRect bbox; + int end_x, end_y; + gdInterpolationMethod interpolation_id_bak = GD_DEFAULT; + interpolation_method interpolation_bak; + + /* These methods use special implementations */ + if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) { + interpolation_id_bak = src->interpolation_id; + interpolation_bak = src->interpolation; + + gdImageSetInterpolationMethod(src, GD_BICUBIC); + } + + + gdImageClipRectangle(src, src_region); + + if (src_region->x > 0 || src_region->y > 0 + || src_region->width < gdImageSX(src) + || src_region->height < gdImageSY(src)) { + backclip = 1; + + gdImageGetClip(src, &backup_clipx1, &backup_clipy1, + &backup_clipx2, &backup_clipy2); + + gdImageSetClip(src, src_region->x, src_region->y, + src_region->x + src_region->width - 1, + src_region->y + src_region->height - 1); + } + + if (!gdTransformAffineBoundingBox(src_region, affine, &bbox)) { + if (backclip) { + gdImageSetClip(src, backup_clipx1, backup_clipy1, + backup_clipx2, backup_clipy2); + } + gdImageSetInterpolationMethod(src, interpolation_id_bak); + return GD_FALSE; + } + + gdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y); + + end_x = bbox.width + (int) fabs(bbox.x); + end_y = bbox.height + (int) fabs(bbox.y); + + /* Get inverse affine to let us work with destination -> source */ + gdAffineInvert(inv, affine); + + src_offset_x = src_region->x; + src_offset_y = src_region->y; + + if (dst->alphaBlendingFlag) { + for (y = bbox.y; y <= end_y; y++) { + pt.y = y + 0.5; + for (x = 0; x <= end_x; x++) { + pt.x = x + 0.5; + gdAffineApplyToPointF(&src_pt, &pt, inv); + gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, 0)); + } + } + } else { + for (y = 0; y <= end_y; y++) { + pt.y = y + 0.5 + bbox.y; + if ((dst_y + y) < 0 || ((dst_y + y) > gdImageSY(dst) -1)) { + continue; + } + dst_p = dst->tpixels[dst_y + y] + dst_x; + + for (x = 0; x <= end_x; x++) { + pt.x = x + 0.5 + bbox.x; + gdAffineApplyToPointF(&src_pt, &pt, inv); + + if ((dst_x + x) < 0 || (dst_x + x) > (gdImageSX(dst) - 1)) { + break; + } + *(dst_p++) = getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, -1); + } + } + } + + /* Restore clip if required */ + if (backclip) { + gdImageSetClip(src, backup_clipx1, backup_clipy1, + backup_clipx2, backup_clipy2); + } + + gdImageSetInterpolationMethod(src, interpolation_id_bak); + return GD_TRUE; +} +","@@ -39,8 +39,8 @@ + downscaling using the fixed point implementations are usually much faster + than the existing gdImageCopyResampled while having a similar or better + quality. +- +- For image rotations, the optimized versions have a lazy antialiasing for ++ ++ For image rotations, the optimized versions have a lazy antialiasing for + the edges of the images. For a much better antialiased result, the affine + function is recommended. + */ +@@ -633,7 +633,7 @@ static inline int _color_blend (const int dst, const int src) + } + } + +-static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor) ++static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor) + { + const gdFixed f_127 = gd_itofx(127); + register int c = src->tpixels[y][x]; +@@ -934,9 +934,6 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi + double dTotalWeight = 0.0; + int iSrc; + +- res->ContribRow[u].Left = iLeft; +- res->ContribRow[u].Right = iRight; +- + /* Cut edge points to fit in filter window in case of spill-off */ + if (iRight - iLeft + 1 > windows_size) { + if (iLeft < ((int)src_size - 1 / 2)) { +@@ -946,6 +943,9 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi + } + } + ++ res->ContribRow[u].Left = iLeft; ++ res->ContribRow[u].Right = iRight; ++ + for (iSrc = iLeft; iSrc <= iRight; iSrc++) { + dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc))); + } +@@ -2273,7 +2273,7 @@ int gdTransformAffineGetImage(gdImagePtr *dst, + if (!src->trueColor) { + gdImagePaletteToTrueColor(src); + } +- ++ + /* Translate to dst origin (0,0) */ + gdAffineTranslate(m, -bbox.x, -bbox.y); + gdAffineConcat(m, affine, m); +@@ -2332,7 +2332,7 @@ int gdTransformAffineCopy(gdImagePtr dst, + if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) { + interpolation_id_bak = src->interpolation_id; + interpolation_bak = src->interpolation; +- ++ + gdImageSetInterpolationMethod(src, GD_BICUBIC); + } + ",968,1204,2048 +440,"void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData, + SplashColorMode srcMode, int nComps, + GBool srcAlpha, int srcWidth, int srcHeight, + int scaledWidth, int scaledHeight, + SplashBitmap *dest) { + Guchar *srcBuf, *lineBuf1, *lineBuf2, *alphaSrcBuf, *alphaLineBuf1, *alphaLineBuf2; + Guint pix[splashMaxColorComps]; + Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; + int i; + + srcBuf = (Guchar *)gmallocn(srcWidth+1, nComps); // + 1 pixel of padding + lineBuf1 = (Guchar *)gmallocn(scaledWidth, nComps); + lineBuf2 = (Guchar *)gmallocn(scaledWidth, nComps); + if (srcAlpha) { + alphaSrcBuf = (Guchar *)gmalloc(srcWidth+1); // + 1 pixel of padding + alphaLineBuf1 = (Guchar *)gmalloc(scaledWidth); + alphaLineBuf2 = (Guchar *)gmalloc(scaledWidth); + } else { + alphaSrcBuf = NULL; + alphaLineBuf1 = NULL; + alphaLineBuf2 = NULL; + } + + double ySrc = 0.0; + double yStep = (double)srcHeight/scaledHeight; + double yFrac, yInt; + int currentSrcRow = -1; + (*src)(srcData, srcBuf, alphaSrcBuf); + expandRow(srcBuf, lineBuf2, srcWidth, scaledWidth, nComps); + if (srcAlpha) + expandRow(alphaSrcBuf, alphaLineBuf2, srcWidth, scaledWidth, 1); + + destPtr0 = dest->data; + destAlphaPtr0 = dest->alpha; + for (int y = 0; y < scaledHeight; y++) { + yFrac = modf(ySrc, &yInt); + if ((int)yInt > currentSrcRow) { + currentSrcRow++; + memcpy(lineBuf1, lineBuf2, scaledWidth * nComps); + if (srcAlpha) + memcpy(alphaLineBuf1, alphaLineBuf2, scaledWidth); + if (currentSrcRow < srcHeight) { + (*src)(srcData, srcBuf, alphaSrcBuf); + expandRow(srcBuf, lineBuf2, srcWidth, scaledWidth, nComps); + if (srcAlpha) + expandRow(alphaSrcBuf, alphaLineBuf2, srcWidth, scaledWidth, 1); + } + } + + for (int x = 0; x < scaledWidth; ++x) { + for (i = 0; i < nComps; ++i) { + pix[i] = lineBuf1[x*nComps + i]*(1.0 - yFrac) + lineBuf2[x*nComps + i]*yFrac; + } + + destPtr = destPtr0 + (y * scaledWidth + x) * nComps; + switch (srcMode) { + case splashModeMono1: // mono1 is not allowed + break; + case splashModeMono8: + *destPtr++ = (Guchar)pix[0]; + break; + case splashModeRGB8: + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + break; + case splashModeXBGR8: + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)255; + break; + case splashModeBGR8: + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[3]; + break; + case splashModeDeviceN8: + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *destPtr++ = (Guchar)pix[cp]; + break; +#endif + } + + if (srcAlpha) { + destAlphaPtr = destAlphaPtr0 + y*scaledWidth + x; + *destAlphaPtr = alphaLineBuf1[x]*(1.0 - yFrac) + alphaLineBuf2[x]*yFrac; + } + } + + ySrc += yStep; + } + + gfree(alphaSrcBuf); + gfree(alphaLineBuf1); + gfree(alphaLineBuf2); + gfree(srcBuf); + gfree(lineBuf1); + gfree(lineBuf2); +} +",0,"void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData, + SplashColorMode srcMode, int nComps, + GBool srcAlpha, int srcWidth, int srcHeight, + int scaledWidth, int scaledHeight, + SplashBitmap *dest) { + Guchar *srcBuf, *lineBuf1, *lineBuf2, *alphaSrcBuf, *alphaLineBuf1, *alphaLineBuf2; + Guint pix[splashMaxColorComps]; + Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; + int i; + + srcBuf = (Guchar *)gmallocn(srcWidth+1, nComps); // + 1 pixel of padding + lineBuf1 = (Guchar *)gmallocn(scaledWidth, nComps); + lineBuf2 = (Guchar *)gmallocn(scaledWidth, nComps); + if (srcAlpha) { + alphaSrcBuf = (Guchar *)gmalloc(srcWidth+1); // + 1 pixel of padding + alphaLineBuf1 = (Guchar *)gmalloc(scaledWidth); + alphaLineBuf2 = (Guchar *)gmalloc(scaledWidth); + } else { + alphaSrcBuf = NULL; + alphaLineBuf1 = NULL; + alphaLineBuf2 = NULL; + } + + double ySrc = 0.0; + double yStep = (double)srcHeight/scaledHeight; + double yFrac, yInt; + int currentSrcRow = -1; + (*src)(srcData, srcBuf, alphaSrcBuf); + expandRow(srcBuf, lineBuf2, srcWidth, scaledWidth, nComps); + if (srcAlpha) + expandRow(alphaSrcBuf, alphaLineBuf2, srcWidth, scaledWidth, 1); + + destPtr0 = dest->data; + destAlphaPtr0 = dest->alpha; + for (int y = 0; y < scaledHeight; y++) { + yFrac = modf(ySrc, &yInt); + if ((int)yInt > currentSrcRow) { + currentSrcRow++; + memcpy(lineBuf1, lineBuf2, scaledWidth * nComps); + if (srcAlpha) + memcpy(alphaLineBuf1, alphaLineBuf2, scaledWidth); + if (currentSrcRow < srcHeight) { + (*src)(srcData, srcBuf, alphaSrcBuf); + expandRow(srcBuf, lineBuf2, srcWidth, scaledWidth, nComps); + if (srcAlpha) + expandRow(alphaSrcBuf, alphaLineBuf2, srcWidth, scaledWidth, 1); + } + } + + for (int x = 0; x < scaledWidth; ++x) { + for (i = 0; i < nComps; ++i) { + pix[i] = lineBuf1[x*nComps + i]*(1.0 - yFrac) + lineBuf2[x*nComps + i]*yFrac; + } + + destPtr = destPtr0 + (y * scaledWidth + x) * nComps; + switch (srcMode) { + case splashModeMono1: // mono1 is not allowed + break; + case splashModeMono8: + *destPtr++ = (Guchar)pix[0]; + break; + case splashModeRGB8: + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + break; + case splashModeXBGR8: + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)255; + break; + case splashModeBGR8: + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[3]; + break; + case splashModeDeviceN8: + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *destPtr++ = (Guchar)pix[cp]; + break; +#endif + } + + if (srcAlpha) { + destAlphaPtr = destAlphaPtr0 + y*scaledWidth + x; + *destAlphaPtr = alphaLineBuf1[x]*(1.0 - yFrac) + alphaLineBuf2[x]*yFrac; + } + } + + ySrc += yStep; + } + + gfree(alphaSrcBuf); + gfree(alphaLineBuf1); + gfree(alphaLineBuf2); + gfree(srcBuf); + gfree(lineBuf1); + gfree(lineBuf2); +} +","@@ -2955,7 +2955,7 @@ void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); + if (scaledMask->data == NULL) { +- error(errInternal, -1, ""scaledMask->data is NULL in Splash::scaleMaskYuXu""); ++ error(errInternal, -1, ""scaledMask->data is NULL in Splash::arbitraryTransformMask""); + delete scaledMask; + return; + } +@@ -3461,11 +3461,15 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + + w = src->getWidth(); + h = src->getHeight(); ++ p = src->getDataPtr(); ++ if (p == NULL) { ++ error(errInternal, -1, ""src->getDataPtr() is NULL in Splash::blitMask""); ++ return; ++ } + if (vectorAntialias && clipRes != splashClipAllInside) { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); + drawAAPixelInit(); +- p = src->getDataPtr(); + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + pipe.shape = *p++; +@@ -3475,7 +3479,6 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + } else { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); +- p = src->getDataPtr(); + if (clipRes == splashClipAllInside) { + for (y = 0; y < h; ++y) { + pipeSetXY(&pipe, xDest, yDest + y);",1133,1369,2048 +4288,"static int md_seq_show(struct seq_file *seq, void *v) +{ + struct mddev *mddev = v; + sector_t sectors; + struct md_rdev *rdev; + + if (v == (void*)1) { + struct md_personality *pers; + seq_printf(seq, ""Personalities : ""); + spin_lock(&pers_lock); + list_for_each_entry(pers, &pers_list, list) + seq_printf(seq, ""[%s] "", pers->name); + + spin_unlock(&pers_lock); + seq_printf(seq, ""\n""); + seq->poll_event = atomic_read(&md_event_count); + return 0; + } + if (v == (void*)2) { + status_unused(seq); + return 0; + } + + spin_lock(&mddev->lock); + if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { + seq_printf(seq, ""%s : %sactive"", mdname(mddev), + mddev->pers ? """" : ""in""); + if (mddev->pers) { + if (mddev->ro==1) + seq_printf(seq, "" (read-only)""); + if (mddev->ro==2) + seq_printf(seq, "" (auto-read-only)""); + seq_printf(seq, "" %s"", mddev->pers->name); + } + + sectors = 0; + rcu_read_lock(); + rdev_for_each_rcu(rdev, mddev) { + char b[BDEVNAME_SIZE]; + seq_printf(seq, "" %s[%d]"", + bdevname(rdev->bdev,b), rdev->desc_nr); + if (test_bit(WriteMostly, &rdev->flags)) + seq_printf(seq, ""(W)""); + if (test_bit(Faulty, &rdev->flags)) { + seq_printf(seq, ""(F)""); + continue; + } + if (rdev->raid_disk < 0) + seq_printf(seq, ""(S)""); /* spare */ + if (test_bit(Replacement, &rdev->flags)) + seq_printf(seq, ""(R)""); + sectors += rdev->sectors; + } + rcu_read_unlock(); + + if (!list_empty(&mddev->disks)) { + if (mddev->pers) + seq_printf(seq, ""\n %llu blocks"", + (unsigned long long) + mddev->array_sectors / 2); + else + seq_printf(seq, ""\n %llu blocks"", + (unsigned long long)sectors / 2); + } + if (mddev->persistent) { + if (mddev->major_version != 0 || + mddev->minor_version != 90) { + seq_printf(seq,"" super %d.%d"", + mddev->major_version, + mddev->minor_version); + } + } else if (mddev->external) + seq_printf(seq, "" super external:%s"", + mddev->metadata_type); + else + seq_printf(seq, "" super non-persistent""); + + if (mddev->pers) { + mddev->pers->status(seq, mddev); + seq_printf(seq, ""\n ""); + if (mddev->pers->sync_request) { + if (mddev->curr_resync > 2) { + status_resync(seq, mddev); + seq_printf(seq, ""\n ""); + } else if (mddev->curr_resync >= 1) + seq_printf(seq, ""\tresync=DELAYED\n ""); + else if (mddev->recovery_cp < MaxSector) + seq_printf(seq, ""\tresync=PENDING\n ""); + } + } else + seq_printf(seq, ""\n ""); + + bitmap_status(seq, mddev->bitmap); + + seq_printf(seq, ""\n""); + } + spin_unlock(&mddev->lock); + + return 0; +} +",0,"static int md_seq_show(struct seq_file *seq, void *v) +{ + struct mddev *mddev = v; + sector_t sectors; + struct md_rdev *rdev; + + if (v == (void*)1) { + struct md_personality *pers; + seq_printf(seq, ""Personalities : ""); + spin_lock(&pers_lock); + list_for_each_entry(pers, &pers_list, list) + seq_printf(seq, ""[%s] "", pers->name); + + spin_unlock(&pers_lock); + seq_printf(seq, ""\n""); + seq->poll_event = atomic_read(&md_event_count); + return 0; + } + if (v == (void*)2) { + status_unused(seq); + return 0; + } + + spin_lock(&mddev->lock); + if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { + seq_printf(seq, ""%s : %sactive"", mdname(mddev), + mddev->pers ? """" : ""in""); + if (mddev->pers) { + if (mddev->ro==1) + seq_printf(seq, "" (read-only)""); + if (mddev->ro==2) + seq_printf(seq, "" (auto-read-only)""); + seq_printf(seq, "" %s"", mddev->pers->name); + } + + sectors = 0; + rcu_read_lock(); + rdev_for_each_rcu(rdev, mddev) { + char b[BDEVNAME_SIZE]; + seq_printf(seq, "" %s[%d]"", + bdevname(rdev->bdev,b), rdev->desc_nr); + if (test_bit(WriteMostly, &rdev->flags)) + seq_printf(seq, ""(W)""); + if (test_bit(Faulty, &rdev->flags)) { + seq_printf(seq, ""(F)""); + continue; + } + if (rdev->raid_disk < 0) + seq_printf(seq, ""(S)""); /* spare */ + if (test_bit(Replacement, &rdev->flags)) + seq_printf(seq, ""(R)""); + sectors += rdev->sectors; + } + rcu_read_unlock(); + + if (!list_empty(&mddev->disks)) { + if (mddev->pers) + seq_printf(seq, ""\n %llu blocks"", + (unsigned long long) + mddev->array_sectors / 2); + else + seq_printf(seq, ""\n %llu blocks"", + (unsigned long long)sectors / 2); + } + if (mddev->persistent) { + if (mddev->major_version != 0 || + mddev->minor_version != 90) { + seq_printf(seq,"" super %d.%d"", + mddev->major_version, + mddev->minor_version); + } + } else if (mddev->external) + seq_printf(seq, "" super external:%s"", + mddev->metadata_type); + else + seq_printf(seq, "" super non-persistent""); + + if (mddev->pers) { + mddev->pers->status(seq, mddev); + seq_printf(seq, ""\n ""); + if (mddev->pers->sync_request) { + if (mddev->curr_resync > 2) { + status_resync(seq, mddev); + seq_printf(seq, ""\n ""); + } else if (mddev->curr_resync >= 1) + seq_printf(seq, ""\tresync=DELAYED\n ""); + else if (mddev->recovery_cp < MaxSector) + seq_printf(seq, ""\tresync=PENDING\n ""); + } + } else + seq_printf(seq, ""\n ""); + + bitmap_status(seq, mddev->bitmap); + + seq_printf(seq, ""\n""); + } + spin_unlock(&mddev->lock); + + return 0; +} +","@@ -5759,7 +5759,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg) + char *ptr; + int err; + +- file = kmalloc(sizeof(*file), GFP_NOIO); ++ file = kzalloc(sizeof(*file), GFP_NOIO); + if (!file) + return -ENOMEM; + ",837,1073,2048 +18151,"vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) +{ + struct drm_vc4_submit_cl *args = exec->args; + void *temp = NULL; + void *bin; + int ret = 0; + uint32_t bin_offset = 0; + uint32_t shader_rec_offset = roundup(bin_offset + args->bin_cl_size, + 16); + uint32_t uniforms_offset = shader_rec_offset + args->shader_rec_size; + uint32_t exec_size = uniforms_offset + args->uniforms_size; + uint32_t temp_size = exec_size + (sizeof(struct vc4_shader_state) * + args->shader_rec_count); + struct vc4_bo *bo; + + if (shader_rec_offset < args->bin_cl_size || + uniforms_offset < shader_rec_offset || + exec_size < uniforms_offset || + args->shader_rec_count >= (UINT_MAX / + sizeof(struct vc4_shader_state)) || + temp_size < exec_size) { + DRM_ERROR(""overflow in exec arguments\n""); + goto fail; + } + + /* Allocate space where we'll store the copied in user command lists + * and shader records. + * + * We don't just copy directly into the BOs because we need to + * read the contents back for validation, and I think the + * bo->vaddr is uncached access. + */ + temp = drm_malloc_ab(temp_size, 1); + if (!temp) { + DRM_ERROR(""Failed to allocate storage for copying "" + ""in bin/render CLs.\n""); + ret = -ENOMEM; + goto fail; + } + bin = temp + bin_offset; + exec->shader_rec_u = temp + shader_rec_offset; + exec->uniforms_u = temp + uniforms_offset; + exec->shader_state = temp + exec_size; + exec->shader_state_size = args->shader_rec_count; + + if (copy_from_user(bin, + (void __user *)(uintptr_t)args->bin_cl, + args->bin_cl_size)) { + ret = -EFAULT; + goto fail; + } + + if (copy_from_user(exec->shader_rec_u, + (void __user *)(uintptr_t)args->shader_rec, + args->shader_rec_size)) { + ret = -EFAULT; + goto fail; + } + + if (copy_from_user(exec->uniforms_u, + (void __user *)(uintptr_t)args->uniforms, + args->uniforms_size)) { + ret = -EFAULT; + goto fail; + } + + bo = vc4_bo_create(dev, exec_size, true); + if (IS_ERR(bo)) { + DRM_ERROR(""Couldn't allocate BO for binning\n""); + ret = PTR_ERR(bo); + goto fail; + } + exec->exec_bo = &bo->base; + + list_add_tail(&to_vc4_bo(&exec->exec_bo->base)->unref_head, + &exec->unref_list); + + exec->ct0ca = exec->exec_bo->paddr + bin_offset; + + exec->bin_u = bin; + + exec->shader_rec_v = exec->exec_bo->vaddr + shader_rec_offset; + exec->shader_rec_p = exec->exec_bo->paddr + shader_rec_offset; + exec->shader_rec_size = args->shader_rec_size; + + exec->uniforms_v = exec->exec_bo->vaddr + uniforms_offset; + exec->uniforms_p = exec->exec_bo->paddr + uniforms_offset; + exec->uniforms_size = args->uniforms_size; + + ret = vc4_validate_bin_cl(dev, + exec->exec_bo->vaddr + bin_offset, + bin, + exec); + if (ret) + goto fail; + + ret = vc4_validate_shader_recs(dev, exec); + if (ret) + goto fail; + + /* Block waiting on any previous rendering into the CS's VBO, + * IB, or textures, so that pixels are actually written by the + * time we try to read them. + */ + ret = vc4_wait_for_seqno(dev, exec->bin_dep_seqno, ~0ull, true); + +fail: + drm_free_large(temp); + return ret; +} +",1,"vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) +{ + struct drm_vc4_submit_cl *args = exec->args; + void *temp = NULL; + void *bin; + int ret = 0; + uint32_t bin_offset = 0; + uint32_t shader_rec_offset = roundup(bin_offset + args->bin_cl_size, + 16); + uint32_t uniforms_offset = shader_rec_offset + args->shader_rec_size; + uint32_t exec_size = uniforms_offset + args->uniforms_size; + uint32_t temp_size = exec_size + (sizeof(struct vc4_shader_state) * + args->shader_rec_count); + struct vc4_bo *bo; + + if (shader_rec_offset < args->bin_cl_size || + uniforms_offset < shader_rec_offset || + exec_size < uniforms_offset || + args->shader_rec_count >= (UINT_MAX / + sizeof(struct vc4_shader_state)) || + temp_size < exec_size) { + DRM_ERROR(""overflow in exec arguments\n""); + ret = -EINVAL; + goto fail; + } + + /* Allocate space where we'll store the copied in user command lists + * and shader records. + * + * We don't just copy directly into the BOs because we need to + * read the contents back for validation, and I think the + * bo->vaddr is uncached access. + */ + temp = drm_malloc_ab(temp_size, 1); + if (!temp) { + DRM_ERROR(""Failed to allocate storage for copying "" + ""in bin/render CLs.\n""); + ret = -ENOMEM; + goto fail; + } + bin = temp + bin_offset; + exec->shader_rec_u = temp + shader_rec_offset; + exec->uniforms_u = temp + uniforms_offset; + exec->shader_state = temp + exec_size; + exec->shader_state_size = args->shader_rec_count; + + if (copy_from_user(bin, + (void __user *)(uintptr_t)args->bin_cl, + args->bin_cl_size)) { + ret = -EFAULT; + goto fail; + } + + if (copy_from_user(exec->shader_rec_u, + (void __user *)(uintptr_t)args->shader_rec, + args->shader_rec_size)) { + ret = -EFAULT; + goto fail; + } + + if (copy_from_user(exec->uniforms_u, + (void __user *)(uintptr_t)args->uniforms, + args->uniforms_size)) { + ret = -EFAULT; + goto fail; + } + + bo = vc4_bo_create(dev, exec_size, true); + if (IS_ERR(bo)) { + DRM_ERROR(""Couldn't allocate BO for binning\n""); + ret = PTR_ERR(bo); + goto fail; + } + exec->exec_bo = &bo->base; + + list_add_tail(&to_vc4_bo(&exec->exec_bo->base)->unref_head, + &exec->unref_list); + + exec->ct0ca = exec->exec_bo->paddr + bin_offset; + + exec->bin_u = bin; + + exec->shader_rec_v = exec->exec_bo->vaddr + shader_rec_offset; + exec->shader_rec_p = exec->exec_bo->paddr + shader_rec_offset; + exec->shader_rec_size = args->shader_rec_size; + + exec->uniforms_v = exec->exec_bo->vaddr + uniforms_offset; + exec->uniforms_p = exec->exec_bo->paddr + uniforms_offset; + exec->uniforms_size = args->uniforms_size; + + ret = vc4_validate_bin_cl(dev, + exec->exec_bo->vaddr + bin_offset, + bin, + exec); + if (ret) + goto fail; + + ret = vc4_validate_shader_recs(dev, exec); + if (ret) + goto fail; + + /* Block waiting on any previous rendering into the CS's VBO, + * IB, or textures, so that pixels are actually written by the + * time we try to read them. + */ + ret = vc4_wait_for_seqno(dev, exec->bin_dep_seqno, ~0ull, true); + +fail: + drm_free_large(temp); + return ret; +} +","@@ -601,6 +601,7 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) + sizeof(struct vc4_shader_state)) || + temp_size < exec_size) { + DRM_ERROR(""overflow in exec arguments\n""); ++ ret = -EINVAL; + goto fail; + } + ",865,1101,2048 +18338,"tChecksumCheckResult ParaNdis_CheckRxChecksum( + PARANDIS_ADAPTER *pContext, + ULONG virtioFlags, + tCompletePhysicalAddress *pPacketPages, + ULONG ulPacketLength, + ULONG ulDataOffset) + { + tOffloadSettingsFlags f = pContext->Offload.flags; + tChecksumCheckResult res; + tTcpIpPacketParsingResult ppr; + ULONG flagsToCalculate = 0; + res.value = 0; + + + if (f.fRxIPChecksum) flagsToCalculate |= pcrIpChecksum; // check only + + if (!(virtioFlags & VIRTIO_NET_HDR_F_DATA_VALID)) + { + if (virtioFlags & VIRTIO_NET_HDR_F_NEEDS_CSUM) + { + flagsToCalculate |= pcrFixXxpChecksum | pcrTcpChecksum | pcrUdpChecksum; + } + else + { + if (f.fRxTCPChecksum) flagsToCalculate |= pcrTcpV4Checksum; + if (f.fRxUDPChecksum) flagsToCalculate |= pcrUdpV4Checksum; + if (f.fRxTCPv6Checksum) flagsToCalculate |= pcrTcpV6Checksum; + if (f.fRxUDPv6Checksum) flagsToCalculate |= pcrUdpV6Checksum; + } + } + + ppr = ParaNdis_CheckSumVerify(pPacketPages, ulPacketLength - ETH_HEADER_SIZE, ulDataOffset + ETH_HEADER_SIZE, flagsToCalculate, __FUNCTION__); + + if (ppr.ipCheckSum == ppresIPTooShort || ppr.xxpStatus == ppresXxpIncomplete) + { + res.flags.IpOK = FALSE; + res.flags.IpFailed = TRUE; + return res; + } + + if (virtioFlags & VIRTIO_NET_HDR_F_DATA_VALID) + { + pContext->extraStatistics.framesRxCSHwOK++; + ppr.xxpCheckSum = ppresCSOK; + } + + if (ppr.ipStatus == ppresIPV4 && !ppr.IsFragment) + { + if (f.fRxIPChecksum) + { + res.flags.IpOK = ppr.ipCheckSum == ppresCSOK; + res.flags.IpFailed = ppr.ipCheckSum == ppresCSBad; + } + if(ppr.xxpStatus == ppresXxpKnown) + { + if(ppr.TcpUdp == ppresIsTCP) /* TCP */ + { + if (f.fRxTCPChecksum) + { + res.flags.TcpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.TcpFailed = !res.flags.TcpOK; + } + } + else /* UDP */ + { + if (f.fRxUDPChecksum) + { + res.flags.UdpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.UdpFailed = !res.flags.UdpOK; + } + } + } + } + else if (ppr.ipStatus == ppresIPV6) + { + if(ppr.xxpStatus == ppresXxpKnown) + { + if(ppr.TcpUdp == ppresIsTCP) /* TCP */ + { + if (f.fRxTCPv6Checksum) + { + res.flags.TcpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.TcpFailed = !res.flags.TcpOK; + } + } + else /* UDP */ + { + if (f.fRxUDPv6Checksum) + { + res.flags.UdpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.UdpFailed = !res.flags.UdpOK; + } + } + } + } + + return res; +} +",1,"tChecksumCheckResult ParaNdis_CheckRxChecksum( + PARANDIS_ADAPTER *pContext, + ULONG virtioFlags, + tCompletePhysicalAddress *pPacketPages, + ULONG ulPacketLength, + ULONG ulDataOffset, + BOOLEAN verifyLength) + { + tOffloadSettingsFlags f = pContext->Offload.flags; + tChecksumCheckResult res; + tTcpIpPacketParsingResult ppr; + ULONG flagsToCalculate = 0; + res.value = 0; + + + if (f.fRxIPChecksum) flagsToCalculate |= pcrIpChecksum; // check only + + if (!(virtioFlags & VIRTIO_NET_HDR_F_DATA_VALID)) + { + if (virtioFlags & VIRTIO_NET_HDR_F_NEEDS_CSUM) + { + flagsToCalculate |= pcrFixXxpChecksum | pcrTcpChecksum | pcrUdpChecksum; + } + else + { + if (f.fRxTCPChecksum) flagsToCalculate |= pcrTcpV4Checksum; + if (f.fRxUDPChecksum) flagsToCalculate |= pcrUdpV4Checksum; + if (f.fRxTCPv6Checksum) flagsToCalculate |= pcrTcpV6Checksum; + if (f.fRxUDPv6Checksum) flagsToCalculate |= pcrUdpV6Checksum; + } + } + + ppr = ParaNdis_CheckSumVerify(pPacketPages, ulPacketLength - ETH_HEADER_SIZE, ulDataOffset + ETH_HEADER_SIZE, flagsToCalculate, + verifyLength, __FUNCTION__); + + if (ppr.ipCheckSum == ppresIPTooShort || ppr.xxpStatus == ppresXxpIncomplete) + { + res.flags.IpOK = FALSE; + res.flags.IpFailed = TRUE; + return res; + } + + if (virtioFlags & VIRTIO_NET_HDR_F_DATA_VALID) + { + pContext->extraStatistics.framesRxCSHwOK++; + ppr.xxpCheckSum = ppresCSOK; + } + + if (ppr.ipStatus == ppresIPV4 && !ppr.IsFragment) + { + if (f.fRxIPChecksum) + { + res.flags.IpOK = ppr.ipCheckSum == ppresCSOK; + res.flags.IpFailed = ppr.ipCheckSum == ppresCSBad; + } + if(ppr.xxpStatus == ppresXxpKnown) + { + if(ppr.TcpUdp == ppresIsTCP) /* TCP */ + { + if (f.fRxTCPChecksum) + { + res.flags.TcpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.TcpFailed = !res.flags.TcpOK; + } + } + else /* UDP */ + { + if (f.fRxUDPChecksum) + { + res.flags.UdpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.UdpFailed = !res.flags.UdpOK; + } + } + } + } + else if (ppr.ipStatus == ppresIPV6) + { + if(ppr.xxpStatus == ppresXxpKnown) + { + if(ppr.TcpUdp == ppresIsTCP) /* TCP */ + { + if (f.fRxTCPv6Checksum) + { + res.flags.TcpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.TcpFailed = !res.flags.TcpOK; + } + } + else /* UDP */ + { + if (f.fRxUDPv6Checksum) + { + res.flags.UdpOK = ppr.xxpCheckSum == ppresCSOK || ppr.fixedXxpCS; + res.flags.UdpFailed = !res.flags.UdpOK; + } + } + } + } + + return res; +} +","@@ -2219,7 +2219,8 @@ tChecksumCheckResult ParaNdis_CheckRxChecksum( + ULONG virtioFlags, + tCompletePhysicalAddress *pPacketPages, + ULONG ulPacketLength, +- ULONG ulDataOffset) ++ ULONG ulDataOffset, ++ BOOLEAN verifyLength) + { + tOffloadSettingsFlags f = pContext->Offload.flags; + tChecksumCheckResult res; +@@ -2247,7 +2248,8 @@ tChecksumCheckResult ParaNdis_CheckRxChecksum( + } + } + +- ppr = ParaNdis_CheckSumVerify(pPacketPages, ulPacketLength - ETH_HEADER_SIZE, ulDataOffset + ETH_HEADER_SIZE, flagsToCalculate, __FUNCTION__); ++ ppr = ParaNdis_CheckSumVerify(pPacketPages, ulPacketLength - ETH_HEADER_SIZE, ulDataOffset + ETH_HEADER_SIZE, flagsToCalculate, ++ verifyLength, __FUNCTION__); + + if (ppr.ipCheckSum == ppresIPTooShort || ppr.xxpStatus == ppresXxpIncomplete) + {",825,1061,2048 +18803,"void SoftAACEncoder2::onQueueFilled(OMX_U32 /* portIndex */) { + if (mSignalledError) { + return; + } + + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + if (!mSentCodecSpecificData) { + + if (outQueue.empty()) { + return; + } + + if (AACENC_OK != aacEncEncode(mAACEncoder, NULL, NULL, NULL, NULL)) { + ALOGE(""Unable to initialize encoder for profile / sample-rate / bit-rate / channels""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + OMX_U32 actualBitRate = aacEncoder_GetParam(mAACEncoder, AACENC_BITRATE); + if (mBitRate != actualBitRate) { + ALOGW(""Requested bitrate %u unsupported, using %u"", mBitRate, actualBitRate); + } + + AACENC_InfoStruct encInfo; + if (AACENC_OK != aacEncInfo(mAACEncoder, &encInfo)) { + ALOGE(""Failed to get AAC encoder info""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + outHeader->nFilledLen = encInfo.confSize; + outHeader->nFlags = OMX_BUFFERFLAG_CODECCONFIG; + + uint8_t *out = outHeader->pBuffer + outHeader->nOffset; + memcpy(out, encInfo.confBuf, encInfo.confSize); + + outQueue.erase(outQueue.begin()); + outInfo->mOwnedByUs = false; + notifyFillBufferDone(outHeader); + + mSentCodecSpecificData = true; + } + + size_t numBytesPerInputFrame = + mNumChannels * kNumSamplesPerFrame * sizeof(int16_t); + + if (mAACProfile == OMX_AUDIO_AACObjectELD && numBytesPerInputFrame > 512) { + numBytesPerInputFrame = 512; + } + + for (;;) { + + while (mInputSize < numBytesPerInputFrame) { + + if (mSawInputEOS || inQueue.empty()) { + return; + } + + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + + const void *inData = inHeader->pBuffer + inHeader->nOffset; + + size_t copy = numBytesPerInputFrame - mInputSize; + if (copy > inHeader->nFilledLen) { + copy = inHeader->nFilledLen; + } + + if (mInputFrame == NULL) { + mInputFrame = new int16_t[numBytesPerInputFrame / sizeof(int16_t)]; + } + + if (mInputSize == 0) { + mInputTimeUs = inHeader->nTimeStamp; + } + + memcpy((uint8_t *)mInputFrame + mInputSize, inData, copy); + mInputSize += copy; + + inHeader->nOffset += copy; + inHeader->nFilledLen -= copy; + + inHeader->nTimeStamp += + (copy * 1000000ll / mSampleRate) + / (mNumChannels * sizeof(int16_t)); + + if (inHeader->nFilledLen == 0) { + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + mSawInputEOS = true; + + memset((uint8_t *)mInputFrame + mInputSize, + 0, + numBytesPerInputFrame - mInputSize); + + mInputSize = numBytesPerInputFrame; + } + + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + + inData = NULL; + inHeader = NULL; + inInfo = NULL; + } + } + + + if (outQueue.empty()) { + return; + } + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + + uint8_t *outPtr = (uint8_t *)outHeader->pBuffer + outHeader->nOffset; + size_t outAvailable = outHeader->nAllocLen - outHeader->nOffset; + + AACENC_InArgs inargs; + AACENC_OutArgs outargs; + memset(&inargs, 0, sizeof(inargs)); + memset(&outargs, 0, sizeof(outargs)); + inargs.numInSamples = numBytesPerInputFrame / sizeof(int16_t); + + void* inBuffer[] = { (unsigned char *)mInputFrame }; + INT inBufferIds[] = { IN_AUDIO_DATA }; + INT inBufferSize[] = { (INT)numBytesPerInputFrame }; + INT inBufferElSize[] = { sizeof(int16_t) }; + + AACENC_BufDesc inBufDesc; + inBufDesc.numBufs = sizeof(inBuffer) / sizeof(void*); + inBufDesc.bufs = (void**)&inBuffer; + inBufDesc.bufferIdentifiers = inBufferIds; + inBufDesc.bufSizes = inBufferSize; + inBufDesc.bufElSizes = inBufferElSize; + + void* outBuffer[] = { outPtr }; + INT outBufferIds[] = { OUT_BITSTREAM_DATA }; + INT outBufferSize[] = { 0 }; + INT outBufferElSize[] = { sizeof(UCHAR) }; + + AACENC_BufDesc outBufDesc; + outBufDesc.numBufs = sizeof(outBuffer) / sizeof(void*); + outBufDesc.bufs = (void**)&outBuffer; + outBufDesc.bufferIdentifiers = outBufferIds; + outBufDesc.bufSizes = outBufferSize; + outBufDesc.bufElSizes = outBufferElSize; + + AACENC_ERROR encoderErr = AACENC_OK; + size_t nOutputBytes = 0; + + do { + memset(&outargs, 0, sizeof(outargs)); + + outBuffer[0] = outPtr; + outBufferSize[0] = outAvailable - nOutputBytes; + + encoderErr = aacEncEncode(mAACEncoder, + &inBufDesc, + &outBufDesc, + &inargs, + &outargs); + + if (encoderErr == AACENC_OK) { + outPtr += outargs.numOutBytes; + nOutputBytes += outargs.numOutBytes; + + if (outargs.numInSamples > 0) { + int numRemainingSamples = inargs.numInSamples - outargs.numInSamples; + if (numRemainingSamples > 0) { + memmove(mInputFrame, + &mInputFrame[outargs.numInSamples], + sizeof(int16_t) * numRemainingSamples); + } + inargs.numInSamples -= outargs.numInSamples; + } + } + } while (encoderErr == AACENC_OK && inargs.numInSamples > 0); + + outHeader->nFilledLen = nOutputBytes; + + outHeader->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; + + if (mSawInputEOS) { + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + } + + outHeader->nTimeStamp = mInputTimeUs; + +#if 0 + ALOGI(""sending %d bytes of data (time = %lld us, flags = 0x%08lx)"", + nOutputBytes, mInputTimeUs, outHeader->nFlags); + + hexdump(outHeader->pBuffer + outHeader->nOffset, outHeader->nFilledLen); +#endif + + outQueue.erase(outQueue.begin()); + outInfo->mOwnedByUs = false; + notifyFillBufferDone(outHeader); + + outHeader = NULL; + outInfo = NULL; + + mInputSize = 0; + } +} +",1,"void SoftAACEncoder2::onQueueFilled(OMX_U32 /* portIndex */) { + if (mSignalledError) { + return; + } + + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + if (!mSentCodecSpecificData) { + + if (outQueue.empty()) { + return; + } + + if (AACENC_OK != aacEncEncode(mAACEncoder, NULL, NULL, NULL, NULL)) { + ALOGE(""Unable to initialize encoder for profile / sample-rate / bit-rate / channels""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + OMX_U32 actualBitRate = aacEncoder_GetParam(mAACEncoder, AACENC_BITRATE); + if (mBitRate != actualBitRate) { + ALOGW(""Requested bitrate %u unsupported, using %u"", mBitRate, actualBitRate); + } + + AACENC_InfoStruct encInfo; + if (AACENC_OK != aacEncInfo(mAACEncoder, &encInfo)) { + ALOGE(""Failed to get AAC encoder info""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + + if (outHeader->nOffset + encInfo.confSize > outHeader->nAllocLen) { + ALOGE(""b/34617444""); + android_errorWriteLog(0x534e4554,""34617444""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + return; + } + + outHeader->nFilledLen = encInfo.confSize; + outHeader->nFlags = OMX_BUFFERFLAG_CODECCONFIG; + + uint8_t *out = outHeader->pBuffer + outHeader->nOffset; + memcpy(out, encInfo.confBuf, encInfo.confSize); + + outQueue.erase(outQueue.begin()); + outInfo->mOwnedByUs = false; + notifyFillBufferDone(outHeader); + + mSentCodecSpecificData = true; + } + + size_t numBytesPerInputFrame = + mNumChannels * kNumSamplesPerFrame * sizeof(int16_t); + + if (mAACProfile == OMX_AUDIO_AACObjectELD && numBytesPerInputFrame > 512) { + numBytesPerInputFrame = 512; + } + + for (;;) { + + while (mInputSize < numBytesPerInputFrame) { + + if (mSawInputEOS || inQueue.empty()) { + return; + } + + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + + const void *inData = inHeader->pBuffer + inHeader->nOffset; + + size_t copy = numBytesPerInputFrame - mInputSize; + if (copy > inHeader->nFilledLen) { + copy = inHeader->nFilledLen; + } + + if (mInputFrame == NULL) { + mInputFrame = new int16_t[numBytesPerInputFrame / sizeof(int16_t)]; + } + + if (mInputSize == 0) { + mInputTimeUs = inHeader->nTimeStamp; + } + + memcpy((uint8_t *)mInputFrame + mInputSize, inData, copy); + mInputSize += copy; + + inHeader->nOffset += copy; + inHeader->nFilledLen -= copy; + + inHeader->nTimeStamp += + (copy * 1000000ll / mSampleRate) + / (mNumChannels * sizeof(int16_t)); + + if (inHeader->nFilledLen == 0) { + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + mSawInputEOS = true; + + memset((uint8_t *)mInputFrame + mInputSize, + 0, + numBytesPerInputFrame - mInputSize); + + mInputSize = numBytesPerInputFrame; + } + + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + + inData = NULL; + inHeader = NULL; + inInfo = NULL; + } + } + + + if (outQueue.empty()) { + return; + } + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + + uint8_t *outPtr = (uint8_t *)outHeader->pBuffer + outHeader->nOffset; + size_t outAvailable = outHeader->nAllocLen - outHeader->nOffset; + + AACENC_InArgs inargs; + AACENC_OutArgs outargs; + memset(&inargs, 0, sizeof(inargs)); + memset(&outargs, 0, sizeof(outargs)); + inargs.numInSamples = numBytesPerInputFrame / sizeof(int16_t); + + void* inBuffer[] = { (unsigned char *)mInputFrame }; + INT inBufferIds[] = { IN_AUDIO_DATA }; + INT inBufferSize[] = { (INT)numBytesPerInputFrame }; + INT inBufferElSize[] = { sizeof(int16_t) }; + + AACENC_BufDesc inBufDesc; + inBufDesc.numBufs = sizeof(inBuffer) / sizeof(void*); + inBufDesc.bufs = (void**)&inBuffer; + inBufDesc.bufferIdentifiers = inBufferIds; + inBufDesc.bufSizes = inBufferSize; + inBufDesc.bufElSizes = inBufferElSize; + + void* outBuffer[] = { outPtr }; + INT outBufferIds[] = { OUT_BITSTREAM_DATA }; + INT outBufferSize[] = { 0 }; + INT outBufferElSize[] = { sizeof(UCHAR) }; + + AACENC_BufDesc outBufDesc; + outBufDesc.numBufs = sizeof(outBuffer) / sizeof(void*); + outBufDesc.bufs = (void**)&outBuffer; + outBufDesc.bufferIdentifiers = outBufferIds; + outBufDesc.bufSizes = outBufferSize; + outBufDesc.bufElSizes = outBufferElSize; + + AACENC_ERROR encoderErr = AACENC_OK; + size_t nOutputBytes = 0; + + do { + memset(&outargs, 0, sizeof(outargs)); + + outBuffer[0] = outPtr; + outBufferSize[0] = outAvailable - nOutputBytes; + + encoderErr = aacEncEncode(mAACEncoder, + &inBufDesc, + &outBufDesc, + &inargs, + &outargs); + + if (encoderErr == AACENC_OK) { + outPtr += outargs.numOutBytes; + nOutputBytes += outargs.numOutBytes; + + if (outargs.numInSamples > 0) { + int numRemainingSamples = inargs.numInSamples - outargs.numInSamples; + if (numRemainingSamples > 0) { + memmove(mInputFrame, + &mInputFrame[outargs.numInSamples], + sizeof(int16_t) * numRemainingSamples); + } + inargs.numInSamples -= outargs.numInSamples; + } + } + } while (encoderErr == AACENC_OK && inargs.numInSamples > 0); + + outHeader->nFilledLen = nOutputBytes; + + outHeader->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; + + if (mSawInputEOS) { + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + } + + outHeader->nTimeStamp = mInputTimeUs; + +#if 0 + ALOGI(""sending %d bytes of data (time = %lld us, flags = 0x%08lx)"", + nOutputBytes, mInputTimeUs, outHeader->nFlags); + + hexdump(outHeader->pBuffer + outHeader->nOffset, outHeader->nFilledLen); +#endif + + outQueue.erase(outQueue.begin()); + outInfo->mOwnedByUs = false; + notifyFillBufferDone(outHeader); + + outHeader = NULL; + outInfo = NULL; + + mInputSize = 0; + } +} +","@@ -510,6 +510,15 @@ + + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; ++ ++ if (outHeader->nOffset + encInfo.confSize > outHeader->nAllocLen) { ++ ALOGE(""b/34617444""); ++ android_errorWriteLog(0x534e4554,""34617444""); ++ notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); ++ mSignalledError = true; ++ return; ++ } ++ + outHeader->nFilledLen = encInfo.confSize; + outHeader->nFlags = OMX_BUFFERFLAG_CODECCONFIG; + +",1658,1894,2048 +6803,"static int __sctp_connect(struct sock *sk, + struct sockaddr *kaddrs, + int addrs_size, + sctp_assoc_t *assoc_id) +{ + struct net *net = sock_net(sk); + struct sctp_sock *sp; + struct sctp_endpoint *ep; + struct sctp_association *asoc = NULL; + struct sctp_association *asoc2; + struct sctp_transport *transport; + union sctp_addr to; + sctp_scope_t scope; + long timeo; + int err = 0; + int addrcnt = 0; + int walk_size = 0; + union sctp_addr *sa_addr = NULL; + void *addr_buf; + unsigned short port; + unsigned int f_flags = 0; + + sp = sctp_sk(sk); + ep = sp->ep; + + /* connect() cannot be done on a socket that is already in ESTABLISHED + * state - UDP-style peeled off socket or a TCP-style socket that + * is already connected. + * It cannot be done even on a TCP-style listening socket. + */ + if (sctp_sstate(sk, ESTABLISHED) || sctp_sstate(sk, CLOSING) || + (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))) { + err = -EISCONN; + goto out_free; + } + + /* Walk through the addrs buffer and count the number of addresses. */ + addr_buf = kaddrs; + while (walk_size < addrs_size) { + struct sctp_af *af; + + if (walk_size + sizeof(sa_family_t) > addrs_size) { + err = -EINVAL; + goto out_free; + } + + sa_addr = addr_buf; + af = sctp_get_af_specific(sa_addr->sa.sa_family); + + /* If the address family is not supported or if this address + * causes the address buffer to overflow return EINVAL. + */ + if (!af || (walk_size + af->sockaddr_len) > addrs_size) { + err = -EINVAL; + goto out_free; + } + + port = ntohs(sa_addr->v4.sin_port); + + /* Save current address so we can work with it */ + memcpy(&to, sa_addr, af->sockaddr_len); + + err = sctp_verify_addr(sk, &to, af->sockaddr_len); + if (err) + goto out_free; + + /* Make sure the destination port is correctly set + * in all addresses. + */ + if (asoc && asoc->peer.port && asoc->peer.port != port) { + err = -EINVAL; + goto out_free; + } + + /* Check if there already is a matching association on the + * endpoint (other than the one created here). + */ + asoc2 = sctp_endpoint_lookup_assoc(ep, &to, &transport); + if (asoc2 && asoc2 != asoc) { + if (asoc2->state >= SCTP_STATE_ESTABLISHED) + err = -EISCONN; + else + err = -EALREADY; + goto out_free; + } + + /* If we could not find a matching association on the endpoint, + * make sure that there is no peeled-off association matching + * the peer address even on another socket. + */ + if (sctp_endpoint_is_peeled_off(ep, &to)) { + err = -EADDRNOTAVAIL; + goto out_free; + } + + if (!asoc) { + /* If a bind() or sctp_bindx() is not called prior to + * an sctp_connectx() call, the system picks an + * ephemeral port and will choose an address set + * equivalent to binding with a wildcard address. + */ + if (!ep->base.bind_addr.port) { + if (sctp_autobind(sk)) { + err = -EAGAIN; + goto out_free; + } + } else { + /* + * If an unprivileged user inherits a 1-many + * style socket with open associations on a + * privileged port, it MAY be permitted to + * accept new associations, but it SHOULD NOT + * be permitted to open new associations. + */ + if (ep->base.bind_addr.port < + inet_prot_sock(net) && + !ns_capable(net->user_ns, + CAP_NET_BIND_SERVICE)) { + err = -EACCES; + goto out_free; + } + } + + scope = sctp_scope(&to); + asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL); + if (!asoc) { + err = -ENOMEM; + goto out_free; + } + + err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, + GFP_KERNEL); + if (err < 0) { + goto out_free; + } + + } + + /* Prime the peer's transport structures. */ + transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, + SCTP_UNKNOWN); + if (!transport) { + err = -ENOMEM; + goto out_free; + } + + addrcnt++; + addr_buf += af->sockaddr_len; + walk_size += af->sockaddr_len; + } + + /* In case the user of sctp_connectx() wants an association + * id back, assign one now. + */ + if (assoc_id) { + err = sctp_assoc_set_id(asoc, GFP_KERNEL); + if (err < 0) + goto out_free; + } + + err = sctp_primitive_ASSOCIATE(net, asoc, NULL); + if (err < 0) { + goto out_free; + } + + /* Initialize sk's dport and daddr for getpeername() */ + inet_sk(sk)->inet_dport = htons(asoc->peer.port); + sp->pf->to_sk_daddr(sa_addr, sk); + sk->sk_err = 0; + + /* in-kernel sockets don't generally have a file allocated to them + * if all they do is call sock_create_kern(). + */ + if (sk->sk_socket->file) + f_flags = sk->sk_socket->file->f_flags; + + timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK); + + if (assoc_id) + *assoc_id = asoc->assoc_id; + err = sctp_wait_for_connect(asoc, &timeo); + /* Note: the asoc may be freed after the return of + * sctp_wait_for_connect. + */ + + /* Don't free association on exit. */ + asoc = NULL; + +out_free: + pr_debug(""%s: took out_free path with asoc:%p kaddrs:%p err:%d\n"", + __func__, asoc, kaddrs, err); + + if (asoc) { + /* sctp_primitive_ASSOCIATE may have added this association + * To the hash table, try to unhash it, just in case, its a noop + * if it wasn't hashed so we're safe + */ + sctp_association_free(asoc); + } + return err; +} +",0,"static int __sctp_connect(struct sock *sk, + struct sockaddr *kaddrs, + int addrs_size, + sctp_assoc_t *assoc_id) +{ + struct net *net = sock_net(sk); + struct sctp_sock *sp; + struct sctp_endpoint *ep; + struct sctp_association *asoc = NULL; + struct sctp_association *asoc2; + struct sctp_transport *transport; + union sctp_addr to; + sctp_scope_t scope; + long timeo; + int err = 0; + int addrcnt = 0; + int walk_size = 0; + union sctp_addr *sa_addr = NULL; + void *addr_buf; + unsigned short port; + unsigned int f_flags = 0; + + sp = sctp_sk(sk); + ep = sp->ep; + + /* connect() cannot be done on a socket that is already in ESTABLISHED + * state - UDP-style peeled off socket or a TCP-style socket that + * is already connected. + * It cannot be done even on a TCP-style listening socket. + */ + if (sctp_sstate(sk, ESTABLISHED) || sctp_sstate(sk, CLOSING) || + (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))) { + err = -EISCONN; + goto out_free; + } + + /* Walk through the addrs buffer and count the number of addresses. */ + addr_buf = kaddrs; + while (walk_size < addrs_size) { + struct sctp_af *af; + + if (walk_size + sizeof(sa_family_t) > addrs_size) { + err = -EINVAL; + goto out_free; + } + + sa_addr = addr_buf; + af = sctp_get_af_specific(sa_addr->sa.sa_family); + + /* If the address family is not supported or if this address + * causes the address buffer to overflow return EINVAL. + */ + if (!af || (walk_size + af->sockaddr_len) > addrs_size) { + err = -EINVAL; + goto out_free; + } + + port = ntohs(sa_addr->v4.sin_port); + + /* Save current address so we can work with it */ + memcpy(&to, sa_addr, af->sockaddr_len); + + err = sctp_verify_addr(sk, &to, af->sockaddr_len); + if (err) + goto out_free; + + /* Make sure the destination port is correctly set + * in all addresses. + */ + if (asoc && asoc->peer.port && asoc->peer.port != port) { + err = -EINVAL; + goto out_free; + } + + /* Check if there already is a matching association on the + * endpoint (other than the one created here). + */ + asoc2 = sctp_endpoint_lookup_assoc(ep, &to, &transport); + if (asoc2 && asoc2 != asoc) { + if (asoc2->state >= SCTP_STATE_ESTABLISHED) + err = -EISCONN; + else + err = -EALREADY; + goto out_free; + } + + /* If we could not find a matching association on the endpoint, + * make sure that there is no peeled-off association matching + * the peer address even on another socket. + */ + if (sctp_endpoint_is_peeled_off(ep, &to)) { + err = -EADDRNOTAVAIL; + goto out_free; + } + + if (!asoc) { + /* If a bind() or sctp_bindx() is not called prior to + * an sctp_connectx() call, the system picks an + * ephemeral port and will choose an address set + * equivalent to binding with a wildcard address. + */ + if (!ep->base.bind_addr.port) { + if (sctp_autobind(sk)) { + err = -EAGAIN; + goto out_free; + } + } else { + /* + * If an unprivileged user inherits a 1-many + * style socket with open associations on a + * privileged port, it MAY be permitted to + * accept new associations, but it SHOULD NOT + * be permitted to open new associations. + */ + if (ep->base.bind_addr.port < + inet_prot_sock(net) && + !ns_capable(net->user_ns, + CAP_NET_BIND_SERVICE)) { + err = -EACCES; + goto out_free; + } + } + + scope = sctp_scope(&to); + asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL); + if (!asoc) { + err = -ENOMEM; + goto out_free; + } + + err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, + GFP_KERNEL); + if (err < 0) { + goto out_free; + } + + } + + /* Prime the peer's transport structures. */ + transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, + SCTP_UNKNOWN); + if (!transport) { + err = -ENOMEM; + goto out_free; + } + + addrcnt++; + addr_buf += af->sockaddr_len; + walk_size += af->sockaddr_len; + } + + /* In case the user of sctp_connectx() wants an association + * id back, assign one now. + */ + if (assoc_id) { + err = sctp_assoc_set_id(asoc, GFP_KERNEL); + if (err < 0) + goto out_free; + } + + err = sctp_primitive_ASSOCIATE(net, asoc, NULL); + if (err < 0) { + goto out_free; + } + + /* Initialize sk's dport and daddr for getpeername() */ + inet_sk(sk)->inet_dport = htons(asoc->peer.port); + sp->pf->to_sk_daddr(sa_addr, sk); + sk->sk_err = 0; + + /* in-kernel sockets don't generally have a file allocated to them + * if all they do is call sock_create_kern(). + */ + if (sk->sk_socket->file) + f_flags = sk->sk_socket->file->f_flags; + + timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK); + + if (assoc_id) + *assoc_id = asoc->assoc_id; + err = sctp_wait_for_connect(asoc, &timeo); + /* Note: the asoc may be freed after the return of + * sctp_wait_for_connect. + */ + + /* Don't free association on exit. */ + asoc = NULL; + +out_free: + pr_debug(""%s: took out_free path with asoc:%p kaddrs:%p err:%d\n"", + __func__, asoc, kaddrs, err); + + if (asoc) { + /* sctp_primitive_ASSOCIATE may have added this association + * To the hash table, try to unhash it, just in case, its a noop + * if it wasn't hashed so we're safe + */ + sctp_association_free(asoc); + } + return err; +} +","@@ -4862,6 +4862,12 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp) + if (!asoc) + return -EINVAL; + ++ /* If there is a thread waiting on more sndbuf space for ++ * sending on this asoc, it cannot be peeled. ++ */ ++ if (waitqueue_active(&asoc->wait)) ++ return -EBUSY; ++ + /* An association cannot be branched off from an already peeled-off + * socket, nor is this supported for tcp style sockets. + */ +@@ -7599,8 +7605,6 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, + */ + release_sock(sk); + current_timeo = schedule_timeout(current_timeo); +- if (sk != asoc->base.sk) +- goto do_error; + lock_sock(sk); + + *timeo_p = current_timeo;",1527,1763,2048 +1437,"static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * passphrase, int makeresource, long * resourceval TSRMLS_DC) +{ + EVP_PKEY * key = NULL; + X509 * cert = NULL; + int free_cert = 0; + long cert_res = -1; + char * filename = NULL; + zval tmp; + + Z_TYPE(tmp) = IS_NULL; + +#define TMP_CLEAN \ + if (Z_TYPE(tmp) == IS_STRING) {\ + zval_dtor(&tmp); \ + } \ + return NULL; + + if (resourceval) { + *resourceval = -1; + } + if (Z_TYPE_PP(val) == IS_ARRAY) { + zval ** zphrase; + + /* get passphrase */ + + if (zend_hash_index_find(HASH_OF(*val), 1, (void **)&zphrase) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""key array must be of the form array(0 => key, 1 => phrase)""); + return NULL; + } + + if (Z_TYPE_PP(zphrase) == IS_STRING) { + passphrase = Z_STRVAL_PP(zphrase); + } else { + tmp = **zphrase; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + passphrase = Z_STRVAL(tmp); + } + + /* now set val to be the key param and continue */ + if (zend_hash_index_find(HASH_OF(*val), 0, (void **)&val) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""key array must be of the form array(0 => key, 1 => phrase)""); + TMP_CLEAN; + } + } + + if (Z_TYPE_PP(val) == IS_RESOURCE) { + void * what; + int type; + + what = zend_fetch_resource(val TSRMLS_CC, -1, ""OpenSSL X.509/key"", &type, 2, le_x509, le_key); + if (!what) { + TMP_CLEAN; + } + if (resourceval) { + *resourceval = Z_LVAL_PP(val); + } + if (type == le_x509) { + /* extract key from cert, depending on public_key param */ + cert = (X509*)what; + free_cert = 0; + } else if (type == le_key) { + int is_priv; + + is_priv = php_openssl_is_private_key((EVP_PKEY*)what TSRMLS_CC); + + /* check whether it is actually a private key if requested */ + if (!public_key && !is_priv) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""supplied key param is a public key""); + TMP_CLEAN; + } + + if (public_key && is_priv) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Don't know how to get public key from this private key""); + TMP_CLEAN; + } else { + if (Z_TYPE(tmp) == IS_STRING) { + zval_dtor(&tmp); + } + /* got the key - return it */ + return (EVP_PKEY*)what; + } + } else { + /* other types could be used here - eg: file pointers and read in the data from them */ + TMP_CLEAN; + } + } else { + /* force it to be a string and check if it refers to a file */ + /* passing non string values leaks, object uses toString, it returns NULL + * See bug38255.phpt + */ + if (!(Z_TYPE_PP(val) == IS_STRING || Z_TYPE_PP(val) == IS_OBJECT)) { + TMP_CLEAN; + } + convert_to_string_ex(val); + + if (Z_STRLEN_PP(val) > 7 && memcmp(Z_STRVAL_PP(val), ""file://"", sizeof(""file://"") - 1) == 0) { + filename = Z_STRVAL_PP(val) + (sizeof(""file://"") - 1); + } + /* it's an X509 file/cert of some kind, and we need to extract the data from that */ + if (public_key) { + cert = php_openssl_x509_from_zval(val, 0, &cert_res TSRMLS_CC); + free_cert = (cert_res == -1); + /* actual extraction done later */ + if (!cert) { + /* not a X509 certificate, try to retrieve public key */ + BIO* in; + if (filename) { + in = BIO_new_file(filename, ""r""); + } else { + in = BIO_new_mem_buf(Z_STRVAL_PP(val), Z_STRLEN_PP(val)); + } + if (in == NULL) { + TMP_CLEAN; + } + key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL); + BIO_free(in); + } + } else { + /* we want the private key */ + BIO *in; + + if (filename) { + if (php_openssl_open_base_dir_chk(filename TSRMLS_CC)) { + TMP_CLEAN; + } + in = BIO_new_file(filename, ""r""); + } else { + in = BIO_new_mem_buf(Z_STRVAL_PP(val), Z_STRLEN_PP(val)); + } + + if (in == NULL) { + TMP_CLEAN; + } + key = PEM_read_bio_PrivateKey(in, NULL,NULL, passphrase); + BIO_free(in); + } + } + + if (public_key && cert && key == NULL) { + /* extract public key from X509 cert */ + key = (EVP_PKEY *) X509_get_pubkey(cert); + } + + if (free_cert && cert) { + X509_free(cert); + } + if (key && makeresource && resourceval) { + *resourceval = ZEND_REGISTER_RESOURCE(NULL, key, le_key); + } + if (Z_TYPE(tmp) == IS_STRING) { + zval_dtor(&tmp); + } + return key; +} +",0,"static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * passphrase, int makeresource, long * resourceval TSRMLS_DC) +{ + EVP_PKEY * key = NULL; + X509 * cert = NULL; + int free_cert = 0; + long cert_res = -1; + char * filename = NULL; + zval tmp; + + Z_TYPE(tmp) = IS_NULL; + +#define TMP_CLEAN \ + if (Z_TYPE(tmp) == IS_STRING) {\ + zval_dtor(&tmp); \ + } \ + return NULL; + + if (resourceval) { + *resourceval = -1; + } + if (Z_TYPE_PP(val) == IS_ARRAY) { + zval ** zphrase; + + /* get passphrase */ + + if (zend_hash_index_find(HASH_OF(*val), 1, (void **)&zphrase) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""key array must be of the form array(0 => key, 1 => phrase)""); + return NULL; + } + + if (Z_TYPE_PP(zphrase) == IS_STRING) { + passphrase = Z_STRVAL_PP(zphrase); + } else { + tmp = **zphrase; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + passphrase = Z_STRVAL(tmp); + } + + /* now set val to be the key param and continue */ + if (zend_hash_index_find(HASH_OF(*val), 0, (void **)&val) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""key array must be of the form array(0 => key, 1 => phrase)""); + TMP_CLEAN; + } + } + + if (Z_TYPE_PP(val) == IS_RESOURCE) { + void * what; + int type; + + what = zend_fetch_resource(val TSRMLS_CC, -1, ""OpenSSL X.509/key"", &type, 2, le_x509, le_key); + if (!what) { + TMP_CLEAN; + } + if (resourceval) { + *resourceval = Z_LVAL_PP(val); + } + if (type == le_x509) { + /* extract key from cert, depending on public_key param */ + cert = (X509*)what; + free_cert = 0; + } else if (type == le_key) { + int is_priv; + + is_priv = php_openssl_is_private_key((EVP_PKEY*)what TSRMLS_CC); + + /* check whether it is actually a private key if requested */ + if (!public_key && !is_priv) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""supplied key param is a public key""); + TMP_CLEAN; + } + + if (public_key && is_priv) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Don't know how to get public key from this private key""); + TMP_CLEAN; + } else { + if (Z_TYPE(tmp) == IS_STRING) { + zval_dtor(&tmp); + } + /* got the key - return it */ + return (EVP_PKEY*)what; + } + } else { + /* other types could be used here - eg: file pointers and read in the data from them */ + TMP_CLEAN; + } + } else { + /* force it to be a string and check if it refers to a file */ + /* passing non string values leaks, object uses toString, it returns NULL + * See bug38255.phpt + */ + if (!(Z_TYPE_PP(val) == IS_STRING || Z_TYPE_PP(val) == IS_OBJECT)) { + TMP_CLEAN; + } + convert_to_string_ex(val); + + if (Z_STRLEN_PP(val) > 7 && memcmp(Z_STRVAL_PP(val), ""file://"", sizeof(""file://"") - 1) == 0) { + filename = Z_STRVAL_PP(val) + (sizeof(""file://"") - 1); + } + /* it's an X509 file/cert of some kind, and we need to extract the data from that */ + if (public_key) { + cert = php_openssl_x509_from_zval(val, 0, &cert_res TSRMLS_CC); + free_cert = (cert_res == -1); + /* actual extraction done later */ + if (!cert) { + /* not a X509 certificate, try to retrieve public key */ + BIO* in; + if (filename) { + in = BIO_new_file(filename, ""r""); + } else { + in = BIO_new_mem_buf(Z_STRVAL_PP(val), Z_STRLEN_PP(val)); + } + if (in == NULL) { + TMP_CLEAN; + } + key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL); + BIO_free(in); + } + } else { + /* we want the private key */ + BIO *in; + + if (filename) { + if (php_openssl_open_base_dir_chk(filename TSRMLS_CC)) { + TMP_CLEAN; + } + in = BIO_new_file(filename, ""r""); + } else { + in = BIO_new_mem_buf(Z_STRVAL_PP(val), Z_STRLEN_PP(val)); + } + + if (in == NULL) { + TMP_CLEAN; + } + key = PEM_read_bio_PrivateKey(in, NULL,NULL, passphrase); + BIO_free(in); + } + } + + if (public_key && cert && key == NULL) { + /* extract public key from X509 cert */ + key = (EVP_PKEY *) X509_get_pubkey(cert); + } + + if (free_cert && cert) { + X509_free(cert); + } + if (key && makeresource && resourceval) { + *resourceval = ZEND_REGISTER_RESOURCE(NULL, key, le_key); + } + if (Z_TYPE(tmp) == IS_STRING) { + zval_dtor(&tmp); + } + return key; +} +","@@ -5070,7 +5070,6 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) + long buffer_length; + unsigned char *buffer = NULL; + zval *zstrong_result_returned = NULL; +- int strong_result = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""l|z"", &buffer_length, &zstrong_result_returned) == FAILURE) { + return; +@@ -5088,7 +5087,6 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) + buffer = emalloc(buffer_length + 1); + + #ifdef PHP_WIN32 +- strong_result = 1; + /* random/urandom equivalent on Windows */ + if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE) { + efree(buffer); +@@ -5098,7 +5096,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) + RETURN_FALSE; + } + #else +- if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) { ++ if (RAND_bytes(buffer, buffer_length) <= 0) { + efree(buffer); + if (zstrong_result_returned) { + ZVAL_BOOL(zstrong_result_returned, 0); +@@ -5111,7 +5109,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) + RETVAL_STRINGL((char *)buffer, buffer_length, 0); + + if (zstrong_result_returned) { +- ZVAL_BOOL(zstrong_result_returned, strong_result); ++ ZVAL_BOOL(zstrong_result_returned, 1); + } + } + /* }}} */",1329,1565,2048 +17883,"NORET_TYPE void do_exit(long code) +{ + struct task_struct *tsk = current; + int group_dead; + + profile_task_exit(tsk); + + WARN_ON(atomic_read(&tsk->fs_excl)); + + if (unlikely(in_interrupt())) + panic(""Aiee, killing interrupt handler!""); + if (unlikely(!tsk->pid)) + panic(""Attempted to kill the idle task!""); + + tracehook_report_exit(&code); + + /* + * We're taking recursive faults here in do_exit. Safest is to just + * leave this task alone and wait for reboot. + */ + if (unlikely(tsk->flags & PF_EXITING)) { + printk(KERN_ALERT + ""Fixing recursive fault but reboot is needed!\n""); + /* + * We can do this unlocked here. The futex code uses + * this flag just to verify whether the pi state + * cleanup has been done or not. In the worst case it + * loops once more. We pretend that the cleanup was + * done as there is no way to return. Either the + * OWNER_DIED bit is set by now or we push the blocked + * task into the wait for ever nirwana as well. + */ + tsk->flags |= PF_EXITPIDONE; + if (tsk->io_context) + exit_io_context(); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule(); + } + + exit_signals(tsk); /* sets PF_EXITING */ + /* + * tsk->flags are checked in the futex code to protect against + * an exiting task cleaning up the robust pi futexes. + */ + smp_mb(); + spin_unlock_wait(&tsk->pi_lock); + + if (unlikely(in_atomic())) + printk(KERN_INFO ""note: %s[%d] exited with preempt_count %d\n"", + current->comm, task_pid_nr(current), + preempt_count()); + + acct_update_integrals(tsk); + if (tsk->mm) { + update_hiwater_rss(tsk->mm); + update_hiwater_vm(tsk->mm); + } + group_dead = atomic_dec_and_test(&tsk->signal->live); + if (group_dead) { + hrtimer_cancel(&tsk->signal->real_timer); + exit_itimers(tsk->signal); + } + acct_collect(code, group_dead); +#ifdef CONFIG_FUTEX + if (unlikely(tsk->robust_list)) + exit_robust_list(tsk); +#ifdef CONFIG_COMPAT + if (unlikely(tsk->compat_robust_list)) + compat_exit_robust_list(tsk); +#endif +#endif + if (group_dead) + tty_audit_exit(); + if (unlikely(tsk->audit_context)) + audit_free(tsk); + + tsk->exit_code = code; + taskstats_exit(tsk, group_dead); + + exit_mm(tsk); + + if (group_dead) + acct_process(); + trace_sched_process_exit(tsk); + + exit_sem(tsk); + exit_files(tsk); + exit_fs(tsk); + check_stack_usage(); + exit_thread(); + cgroup_exit(tsk, 1); + exit_keys(tsk); + + if (group_dead && tsk->signal->leader) + disassociate_ctty(1); + + module_put(task_thread_info(tsk)->exec_domain->module); + if (tsk->binfmt) + module_put(tsk->binfmt->module); + + proc_exit_connector(tsk); + exit_notify(tsk, group_dead); +#ifdef CONFIG_NUMA + mpol_put(tsk->mempolicy); + tsk->mempolicy = NULL; +#endif +#ifdef CONFIG_FUTEX + /* + * This must happen late, after the PID is not + * hashed anymore: + */ + if (unlikely(!list_empty(&tsk->pi_state_list))) + exit_pi_state_list(tsk); + if (unlikely(current->pi_state_cache)) + kfree(current->pi_state_cache); +#endif + /* + * Make sure we are holding no locks: + */ + debug_check_no_locks_held(tsk); + /* + * We can do this unlocked here. The futex code uses this flag + * just to verify whether the pi state cleanup has been done + * or not. In the worst case it loops once more. + */ + tsk->flags |= PF_EXITPIDONE; + + if (tsk->io_context) + exit_io_context(); + + if (tsk->splice_pipe) + __free_pipe_info(tsk->splice_pipe); + + preempt_disable(); + /* causes final put_task_struct in finish_task_switch(). */ + tsk->state = TASK_DEAD; + + schedule(); + BUG(); + /* Avoid ""noreturn function does return"". */ + for (;;) + cpu_relax(); /* For when BUG is null */ +} +",1,"NORET_TYPE void do_exit(long code) +{ + struct task_struct *tsk = current; + int group_dead; + + profile_task_exit(tsk); + + WARN_ON(atomic_read(&tsk->fs_excl)); + + if (unlikely(in_interrupt())) + panic(""Aiee, killing interrupt handler!""); + if (unlikely(!tsk->pid)) + panic(""Attempted to kill the idle task!""); + + tracehook_report_exit(&code); + + /* + * We're taking recursive faults here in do_exit. Safest is to just + * leave this task alone and wait for reboot. + */ + if (unlikely(tsk->flags & PF_EXITING)) { + printk(KERN_ALERT + ""Fixing recursive fault but reboot is needed!\n""); + /* + * We can do this unlocked here. The futex code uses + * this flag just to verify whether the pi state + * cleanup has been done or not. In the worst case it + * loops once more. We pretend that the cleanup was + * done as there is no way to return. Either the + * OWNER_DIED bit is set by now or we push the blocked + * task into the wait for ever nirwana as well. + */ + tsk->flags |= PF_EXITPIDONE; + if (tsk->io_context) + exit_io_context(); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule(); + } + + exit_signals(tsk); /* sets PF_EXITING */ + /* + * tsk->flags are checked in the futex code to protect against + * an exiting task cleaning up the robust pi futexes. + */ + smp_mb(); + spin_unlock_wait(&tsk->pi_lock); + + if (unlikely(in_atomic())) + printk(KERN_INFO ""note: %s[%d] exited with preempt_count %d\n"", + current->comm, task_pid_nr(current), + preempt_count()); + + acct_update_integrals(tsk); + if (tsk->mm) { + update_hiwater_rss(tsk->mm); + update_hiwater_vm(tsk->mm); + } + group_dead = atomic_dec_and_test(&tsk->signal->live); + if (group_dead) { + hrtimer_cancel(&tsk->signal->real_timer); + exit_itimers(tsk->signal); + } + acct_collect(code, group_dead); + if (group_dead) + tty_audit_exit(); + if (unlikely(tsk->audit_context)) + audit_free(tsk); + + tsk->exit_code = code; + taskstats_exit(tsk, group_dead); + + exit_mm(tsk); + + if (group_dead) + acct_process(); + trace_sched_process_exit(tsk); + + exit_sem(tsk); + exit_files(tsk); + exit_fs(tsk); + check_stack_usage(); + exit_thread(); + cgroup_exit(tsk, 1); + exit_keys(tsk); + + if (group_dead && tsk->signal->leader) + disassociate_ctty(1); + + module_put(task_thread_info(tsk)->exec_domain->module); + if (tsk->binfmt) + module_put(tsk->binfmt->module); + + proc_exit_connector(tsk); + exit_notify(tsk, group_dead); +#ifdef CONFIG_NUMA + mpol_put(tsk->mempolicy); + tsk->mempolicy = NULL; +#endif +#ifdef CONFIG_FUTEX + /* + * This must happen late, after the PID is not + * hashed anymore: + */ + if (unlikely(!list_empty(&tsk->pi_state_list))) + exit_pi_state_list(tsk); + if (unlikely(current->pi_state_cache)) + kfree(current->pi_state_cache); +#endif + /* + * Make sure we are holding no locks: + */ + debug_check_no_locks_held(tsk); + /* + * We can do this unlocked here. The futex code uses this flag + * just to verify whether the pi state cleanup has been done + * or not. In the worst case it loops once more. + */ + tsk->flags |= PF_EXITPIDONE; + + if (tsk->io_context) + exit_io_context(); + + if (tsk->splice_pipe) + __free_pipe_info(tsk->splice_pipe); + + preempt_disable(); + /* causes final put_task_struct in finish_task_switch(). */ + tsk->state = TASK_DEAD; + + schedule(); + BUG(); + /* Avoid ""noreturn function does return"". */ + for (;;) + cpu_relax(); /* For when BUG is null */ +} +","@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + #include + #include /* for audit_free() */ + #include +@@ -1059,14 +1058,6 @@ NORET_TYPE void do_exit(long code) + exit_itimers(tsk->signal); + } + acct_collect(code, group_dead); +-#ifdef CONFIG_FUTEX +- if (unlikely(tsk->robust_list)) +- exit_robust_list(tsk); +-#ifdef CONFIG_COMPAT +- if (unlikely(tsk->compat_robust_list)) +- compat_exit_robust_list(tsk); +-#endif +-#endif + if (group_dead) + tty_audit_exit(); + if (unlikely(tsk->audit_context))",996,1232,2048 +18097,"decode_multicast_vpn(netdissect_options *ndo, + const u_char *pptr, char *buf, u_int buflen) +{ + uint8_t route_type, route_length, addr_length, sg_length; + u_int offset; + + ND_TCHECK2(pptr[0], 2); + route_type = *pptr++; + route_length = *pptr++; + + snprintf(buf, buflen, ""Route-Type: %s (%u), length: %u"", + tok2str(bgp_multicast_vpn_route_type_values, + ""Unknown"", route_type), + route_type, route_length); + + switch(route_type) { + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Originator %s"", + bgp_vpn_rd_print(ndo, pptr), + bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN, + (route_length - BGP_VPN_RD_LEN) << 3)); + break; + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Source-AS %s"", + bgp_vpn_rd_print(ndo, pptr), + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s"", + bgp_vpn_rd_print(ndo, pptr)); + pptr += BGP_VPN_RD_LEN; + + sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen); + addr_length = route_length - sg_length; + + ND_TCHECK2(pptr[0], addr_length); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", Originator %s"", + bgp_vpn_ip_print(ndo, pptr, addr_length << 3)); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s"", + bgp_vpn_rd_print(ndo, pptr)); + pptr += BGP_VPN_RD_LEN; + + bgp_vpn_sg_print(ndo, pptr, buf, buflen); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Source-AS %s"", + bgp_vpn_rd_print(ndo, pptr), + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); + pptr += BGP_VPN_RD_LEN; + + bgp_vpn_sg_print(ndo, pptr, buf, buflen); + break; + + /* + * no per route-type printing yet. + */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF: + default: + break; + } + + return route_length + 2; + +trunc: + return -2; +} +",1,"decode_multicast_vpn(netdissect_options *ndo, + const u_char *pptr, char *buf, u_int buflen) +{ + uint8_t route_type, route_length, addr_length, sg_length; + u_int offset; + + ND_TCHECK2(pptr[0], 2); + route_type = *pptr++; + route_length = *pptr++; + + snprintf(buf, buflen, ""Route-Type: %s (%u), length: %u"", + tok2str(bgp_multicast_vpn_route_type_values, + ""Unknown"", route_type), + route_type, route_length); + + switch(route_type) { + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Originator %s"", + bgp_vpn_rd_print(ndo, pptr), + bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN, + (route_length - BGP_VPN_RD_LEN) << 3)); + break; + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Source-AS %s"", + bgp_vpn_rd_print(ndo, pptr), + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s"", + bgp_vpn_rd_print(ndo, pptr)); + pptr += BGP_VPN_RD_LEN; + + sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen); + addr_length = route_length - sg_length; + + ND_TCHECK2(pptr[0], addr_length); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", Originator %s"", + bgp_vpn_ip_print(ndo, pptr, addr_length << 3)); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s"", + bgp_vpn_rd_print(ndo, pptr)); + pptr += BGP_VPN_RD_LEN; + + bgp_vpn_sg_print(ndo, pptr, buf, buflen); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN: + ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Source-AS %s"", + bgp_vpn_rd_print(ndo, pptr), + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); + pptr += BGP_VPN_RD_LEN + 4; + + bgp_vpn_sg_print(ndo, pptr, buf, buflen); + break; + + /* + * no per route-type printing yet. + */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF: + default: + break; + } + + return route_length + 2; + +trunc: + return -2; +} +","@@ -965,13 +965,13 @@ decode_multicast_vpn(netdissect_options *ndo, + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN: +- ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); ++ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, "", RD: %s, Source-AS %s"", + bgp_vpn_rd_print(ndo, pptr), + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); +- pptr += BGP_VPN_RD_LEN; ++ pptr += BGP_VPN_RD_LEN + 4; + + bgp_vpn_sg_print(ndo, pptr, buf, buflen); + break;",833,1069,2048 +2334,"static int power_check_constraints(struct cpu_hw_events *cpuhw, + u64 event_id[], unsigned int cflags[], + int n_ev) +{ + unsigned long mask, value, nv; + unsigned long smasks[MAX_HWEVENTS], svalues[MAX_HWEVENTS]; + int n_alt[MAX_HWEVENTS], choice[MAX_HWEVENTS]; + int i, j; + unsigned long addf = ppmu->add_fields; + unsigned long tadd = ppmu->test_adder; + + if (n_ev > ppmu->n_counter) + return -1; + + /* First see if the events will go on as-is */ + for (i = 0; i < n_ev; ++i) { + if ((cflags[i] & PPMU_LIMITED_PMC_REQD) + && !ppmu->limited_pmc_event(event_id[i])) { + ppmu->get_alternatives(event_id[i], cflags[i], + cpuhw->alternatives[i]); + event_id[i] = cpuhw->alternatives[i][0]; + } + if (ppmu->get_constraint(event_id[i], &cpuhw->amasks[i][0], + &cpuhw->avalues[i][0])) + return -1; + } + value = mask = 0; + for (i = 0; i < n_ev; ++i) { + nv = (value | cpuhw->avalues[i][0]) + + (value & cpuhw->avalues[i][0] & addf); + if ((((nv + tadd) ^ value) & mask) != 0 || + (((nv + tadd) ^ cpuhw->avalues[i][0]) & + cpuhw->amasks[i][0]) != 0) + break; + value = nv; + mask |= cpuhw->amasks[i][0]; + } + if (i == n_ev) + return 0; /* all OK */ + + /* doesn't work, gather alternatives... */ + if (!ppmu->get_alternatives) + return -1; + for (i = 0; i < n_ev; ++i) { + choice[i] = 0; + n_alt[i] = ppmu->get_alternatives(event_id[i], cflags[i], + cpuhw->alternatives[i]); + for (j = 1; j < n_alt[i]; ++j) + ppmu->get_constraint(cpuhw->alternatives[i][j], + &cpuhw->amasks[i][j], + &cpuhw->avalues[i][j]); + } + + /* enumerate all possibilities and see if any will work */ + i = 0; + j = -1; + value = mask = nv = 0; + while (i < n_ev) { + if (j >= 0) { + /* we're backtracking, restore context */ + value = svalues[i]; + mask = smasks[i]; + j = choice[i]; + } + /* + * See if any alternative k for event_id i, + * where k > j, will satisfy the constraints. + */ + while (++j < n_alt[i]) { + nv = (value | cpuhw->avalues[i][j]) + + (value & cpuhw->avalues[i][j] & addf); + if ((((nv + tadd) ^ value) & mask) == 0 && + (((nv + tadd) ^ cpuhw->avalues[i][j]) + & cpuhw->amasks[i][j]) == 0) + break; + } + if (j >= n_alt[i]) { + /* + * No feasible alternative, backtrack + * to event_id i-1 and continue enumerating its + * alternatives from where we got up to. + */ + if (--i < 0) + return -1; + } else { + /* + * Found a feasible alternative for event_id i, + * remember where we got up to with this event_id, + * go on to the next event_id, and start with + * the first alternative for it. + */ + choice[i] = j; + svalues[i] = value; + smasks[i] = mask; + value = nv; + mask |= cpuhw->amasks[i][j]; + ++i; + j = -1; + } + } + + /* OK, we have a feasible combination, tell the caller the solution */ + for (i = 0; i < n_ev; ++i) + event_id[i] = cpuhw->alternatives[i][choice[i]]; + return 0; +} +",0,"static int power_check_constraints(struct cpu_hw_events *cpuhw, + u64 event_id[], unsigned int cflags[], + int n_ev) +{ + unsigned long mask, value, nv; + unsigned long smasks[MAX_HWEVENTS], svalues[MAX_HWEVENTS]; + int n_alt[MAX_HWEVENTS], choice[MAX_HWEVENTS]; + int i, j; + unsigned long addf = ppmu->add_fields; + unsigned long tadd = ppmu->test_adder; + + if (n_ev > ppmu->n_counter) + return -1; + + /* First see if the events will go on as-is */ + for (i = 0; i < n_ev; ++i) { + if ((cflags[i] & PPMU_LIMITED_PMC_REQD) + && !ppmu->limited_pmc_event(event_id[i])) { + ppmu->get_alternatives(event_id[i], cflags[i], + cpuhw->alternatives[i]); + event_id[i] = cpuhw->alternatives[i][0]; + } + if (ppmu->get_constraint(event_id[i], &cpuhw->amasks[i][0], + &cpuhw->avalues[i][0])) + return -1; + } + value = mask = 0; + for (i = 0; i < n_ev; ++i) { + nv = (value | cpuhw->avalues[i][0]) + + (value & cpuhw->avalues[i][0] & addf); + if ((((nv + tadd) ^ value) & mask) != 0 || + (((nv + tadd) ^ cpuhw->avalues[i][0]) & + cpuhw->amasks[i][0]) != 0) + break; + value = nv; + mask |= cpuhw->amasks[i][0]; + } + if (i == n_ev) + return 0; /* all OK */ + + /* doesn't work, gather alternatives... */ + if (!ppmu->get_alternatives) + return -1; + for (i = 0; i < n_ev; ++i) { + choice[i] = 0; + n_alt[i] = ppmu->get_alternatives(event_id[i], cflags[i], + cpuhw->alternatives[i]); + for (j = 1; j < n_alt[i]; ++j) + ppmu->get_constraint(cpuhw->alternatives[i][j], + &cpuhw->amasks[i][j], + &cpuhw->avalues[i][j]); + } + + /* enumerate all possibilities and see if any will work */ + i = 0; + j = -1; + value = mask = nv = 0; + while (i < n_ev) { + if (j >= 0) { + /* we're backtracking, restore context */ + value = svalues[i]; + mask = smasks[i]; + j = choice[i]; + } + /* + * See if any alternative k for event_id i, + * where k > j, will satisfy the constraints. + */ + while (++j < n_alt[i]) { + nv = (value | cpuhw->avalues[i][j]) + + (value & cpuhw->avalues[i][j] & addf); + if ((((nv + tadd) ^ value) & mask) == 0 && + (((nv + tadd) ^ cpuhw->avalues[i][j]) + & cpuhw->amasks[i][j]) == 0) + break; + } + if (j >= n_alt[i]) { + /* + * No feasible alternative, backtrack + * to event_id i-1 and continue enumerating its + * alternatives from where we got up to. + */ + if (--i < 0) + return -1; + } else { + /* + * Found a feasible alternative for event_id i, + * remember where we got up to with this event_id, + * go on to the next event_id, and start with + * the first alternative for it. + */ + choice[i] = j; + svalues[i] = value; + smasks[i] = mask; + value = nv; + mask |= cpuhw->amasks[i][j]; + ++i; + j = -1; + } + } + + /* OK, we have a feasible combination, tell the caller the solution */ + for (i = 0; i < n_ev; ++i) + event_id[i] = cpuhw->alternatives[i][choice[i]]; + return 0; +} +","@@ -1269,6 +1269,28 @@ unsigned long perf_instruction_pointer(struct pt_regs *regs) + return ip; + } + ++static bool pmc_overflow(unsigned long val) ++{ ++ if ((int)val < 0) ++ return true; ++ ++ /* ++ * Events on POWER7 can roll back if a speculative event doesn't ++ * eventually complete. Unfortunately in some rare cases they will ++ * raise a performance monitor exception. We need to catch this to ++ * ensure we reset the PMC. In all cases the PMC will be 256 or less ++ * cycles from overflow. ++ * ++ * We only do this if the first pass fails to find any overflowing ++ * PMCs because a user might set a period of less than 256 and we ++ * don't want to mistakenly reset them. ++ */ ++ if (__is_processor(PV_POWER7) && ((0x80000000 - val) <= 256)) ++ return true; ++ ++ return false; ++} ++ + /* + * Performance monitor interrupt stuff + */ +@@ -1316,7 +1338,7 @@ static void perf_event_interrupt(struct pt_regs *regs) + if (is_limited_pmc(i + 1)) + continue; + val = read_pmc(i + 1); +- if ((int)val < 0) ++ if (pmc_overflow(val)) + write_pmc(i + 1, 0); + } + }",980,1216,2048 +1901,"static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) +{ + int error = 0; + char if_file[128]; + FILE *file; + char cmd[512]; + char *mac_addr; + + /* + * Set the configuration for the specified interface with + * the information provided. Since there is no standard + * way to configure an interface, we will have an external + * script that does the job of configuring the interface and + * flushing the configuration. + * + * The parameters passed to this external script are: + * 1. A configuration file that has the specified configuration. + * + * We will embed the name of the interface in the configuration + * file: ifcfg-ethx (where ethx is the interface name). + * + * The information provided here may be more than what is needed + * in a given distro to configure the interface and so are free + * ignore information that may not be relevant. + * + * Here is the format of the ip configuration file: + * + * HWADDR=macaddr + * IF_NAME=interface name + * DHCP=yes (This is optional; if yes, DHCP is configured) + * + * IPADDR=ipaddr1 + * IPADDR_1=ipaddr2 + * IPADDR_x=ipaddry (where y = x + 1) + * + * NETMASK=netmask1 + * NETMASK_x=netmasky (where y = x + 1) + * + * GATEWAY=ipaddr1 + * GATEWAY_x=ipaddry (where y = x + 1) + * + * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) + * + * IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be + * tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as + * IPV6NETMASK. + * + * The host can specify multiple ipv4 and ipv6 addresses to be + * configured for the interface. Furthermore, the configuration + * needs to be persistent. A subsequent GET call on the interface + * is expected to return the configuration that is set via the SET + * call. + */ + + snprintf(if_file, sizeof(if_file), ""%s%s%s"", KVP_CONFIG_LOC, + ""hyperv/ifcfg-"", if_name); + + file = fopen(if_file, ""w""); + + if (file == NULL) { + syslog(LOG_ERR, ""Failed to open config file""); + return HV_E_FAIL; + } + + /* + * First write out the MAC address. + */ + + mac_addr = kvp_if_name_to_mac(if_name); + if (mac_addr == NULL) { + error = HV_E_FAIL; + goto setval_error; + } + + error = kvp_write_file(file, ""HWADDR"", """", mac_addr); + if (error) + goto setval_error; + + error = kvp_write_file(file, ""IF_NAME"", """", if_name); + if (error) + goto setval_error; + + if (new_val->dhcp_enabled) { + error = kvp_write_file(file, ""DHCP"", """", ""yes""); + if (error) + goto setval_error; + + /* + * We are done!. + */ + goto setval_done; + } + + /* + * Write the configuration for ipaddress, netmask, gateway and + * name servers. + */ + + error = process_ip_string(file, (char *)new_val->ip_addr, IPADDR); + if (error) + goto setval_error; + + error = process_ip_string(file, (char *)new_val->sub_net, NETMASK); + if (error) + goto setval_error; + + error = process_ip_string(file, (char *)new_val->gate_way, GATEWAY); + if (error) + goto setval_error; + + error = process_ip_string(file, (char *)new_val->dns_addr, DNS); + if (error) + goto setval_error; + +setval_done: + free(mac_addr); + fclose(file); + + /* + * Now that we have populated the configuration file, + * invoke the external script to do its magic. + */ + + snprintf(cmd, sizeof(cmd), ""%s %s"", ""hv_set_ifconfig"", if_file); + system(cmd); + return 0; + +setval_error: + syslog(LOG_ERR, ""Failed to write config file""); + free(mac_addr); + fclose(file); + return error; +} +",0,"static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) +{ + int error = 0; + char if_file[128]; + FILE *file; + char cmd[512]; + char *mac_addr; + + /* + * Set the configuration for the specified interface with + * the information provided. Since there is no standard + * way to configure an interface, we will have an external + * script that does the job of configuring the interface and + * flushing the configuration. + * + * The parameters passed to this external script are: + * 1. A configuration file that has the specified configuration. + * + * We will embed the name of the interface in the configuration + * file: ifcfg-ethx (where ethx is the interface name). + * + * The information provided here may be more than what is needed + * in a given distro to configure the interface and so are free + * ignore information that may not be relevant. + * + * Here is the format of the ip configuration file: + * + * HWADDR=macaddr + * IF_NAME=interface name + * DHCP=yes (This is optional; if yes, DHCP is configured) + * + * IPADDR=ipaddr1 + * IPADDR_1=ipaddr2 + * IPADDR_x=ipaddry (where y = x + 1) + * + * NETMASK=netmask1 + * NETMASK_x=netmasky (where y = x + 1) + * + * GATEWAY=ipaddr1 + * GATEWAY_x=ipaddry (where y = x + 1) + * + * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) + * + * IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be + * tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as + * IPV6NETMASK. + * + * The host can specify multiple ipv4 and ipv6 addresses to be + * configured for the interface. Furthermore, the configuration + * needs to be persistent. A subsequent GET call on the interface + * is expected to return the configuration that is set via the SET + * call. + */ + + snprintf(if_file, sizeof(if_file), ""%s%s%s"", KVP_CONFIG_LOC, + ""hyperv/ifcfg-"", if_name); + + file = fopen(if_file, ""w""); + + if (file == NULL) { + syslog(LOG_ERR, ""Failed to open config file""); + return HV_E_FAIL; + } + + /* + * First write out the MAC address. + */ + + mac_addr = kvp_if_name_to_mac(if_name); + if (mac_addr == NULL) { + error = HV_E_FAIL; + goto setval_error; + } + + error = kvp_write_file(file, ""HWADDR"", """", mac_addr); + if (error) + goto setval_error; + + error = kvp_write_file(file, ""IF_NAME"", """", if_name); + if (error) + goto setval_error; + + if (new_val->dhcp_enabled) { + error = kvp_write_file(file, ""DHCP"", """", ""yes""); + if (error) + goto setval_error; + + /* + * We are done!. + */ + goto setval_done; + } + + /* + * Write the configuration for ipaddress, netmask, gateway and + * name servers. + */ + + error = process_ip_string(file, (char *)new_val->ip_addr, IPADDR); + if (error) + goto setval_error; + + error = process_ip_string(file, (char *)new_val->sub_net, NETMASK); + if (error) + goto setval_error; + + error = process_ip_string(file, (char *)new_val->gate_way, GATEWAY); + if (error) + goto setval_error; + + error = process_ip_string(file, (char *)new_val->dns_addr, DNS); + if (error) + goto setval_error; + +setval_done: + free(mac_addr); + fclose(file); + + /* + * Now that we have populated the configuration file, + * invoke the external script to do its magic. + */ + + snprintf(cmd, sizeof(cmd), ""%s %s"", ""hv_set_ifconfig"", if_file); + system(cmd); + return 0; + +setval_error: + syslog(LOG_ERR, ""Failed to write config file""); + free(mac_addr); + fclose(file); + return error; +} +","@@ -1486,13 +1486,19 @@ int main(void) + len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0, + addr_p, &addr_l); + +- if (len < 0 || addr.nl_pid) { ++ if (len < 0) { + syslog(LOG_ERR, ""recvfrom failed; pid:%u error:%d %s"", + addr.nl_pid, errno, strerror(errno)); + close(fd); + return -1; + } + ++ if (addr.nl_pid) { ++ syslog(LOG_WARNING, ""Received packet from untrusted pid:%u"", ++ addr.nl_pid); ++ continue; ++ } ++ + incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; + incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); + hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data;",947,1183,2048 +4450,"__xml_build_changes(xmlNode * xml, xmlNode *patchset) +{ + xmlNode *cIter = NULL; + xmlAttr *pIter = NULL; + xmlNode *change = NULL; + xml_private_t *p = xml->_private; + + if(patchset && is_set(p->flags, xpf_created)) { + int offset = 0; + char buffer[XML_BUFFER_SIZE]; + + if(__get_prefix(NULL, xml->parent, buffer, offset) > 0) { + int position = __xml_offset_no_deletions(xml); + + change = create_xml_node(patchset, XML_DIFF_CHANGE); + + crm_xml_add(change, XML_DIFF_OP, ""create""); + crm_xml_add(change, XML_DIFF_PATH, buffer); + crm_xml_add_int(change, XML_DIFF_POSITION, position); + add_node_copy(change, xml); + } + + return; + } + + for (pIter = crm_first_attr(xml); pIter != NULL; pIter = pIter->next) { + xmlNode *attr = NULL; + + p = pIter->_private; + if(is_not_set(p->flags, xpf_deleted) && is_not_set(p->flags, xpf_dirty)) { + continue; + } + + if(change == NULL) { + int offset = 0; + char buffer[XML_BUFFER_SIZE]; + + if(__get_prefix(NULL, xml, buffer, offset) > 0) { + change = create_xml_node(patchset, XML_DIFF_CHANGE); + + crm_xml_add(change, XML_DIFF_OP, ""modify""); + crm_xml_add(change, XML_DIFF_PATH, buffer); + + change = create_xml_node(change, XML_DIFF_LIST); + } + } + + attr = create_xml_node(change, XML_DIFF_ATTR); + + crm_xml_add(attr, XML_NVPAIR_ATTR_NAME, (const char *)pIter->name); + if(p->flags & xpf_deleted) { + crm_xml_add(attr, XML_DIFF_OP, ""unset""); + + } else { + const char *value = crm_element_value(xml, (const char *)pIter->name); + + crm_xml_add(attr, XML_DIFF_OP, ""set""); + crm_xml_add(attr, XML_NVPAIR_ATTR_VALUE, value); + } + } + + if(change) { + xmlNode *result = NULL; + + change = create_xml_node(change->parent, XML_DIFF_RESULT); + result = create_xml_node(change, (const char *)xml->name); + + for (pIter = crm_first_attr(xml); pIter != NULL; pIter = pIter->next) { + const char *value = crm_element_value(xml, (const char *)pIter->name); + + p = pIter->_private; + if (is_not_set(p->flags, xpf_deleted)) { + crm_xml_add(result, (const char *)pIter->name, value); + } + } + } + + for (cIter = __xml_first_child(xml); cIter != NULL; cIter = __xml_next(cIter)) { + __xml_build_changes(cIter, patchset); + } + + p = xml->_private; + if(patchset && is_set(p->flags, xpf_moved)) { + int offset = 0; + char buffer[XML_BUFFER_SIZE]; + + crm_trace(""%s.%s moved to position %d"", xml->name, ID(xml), __xml_offset(xml)); + if(__get_prefix(NULL, xml, buffer, offset) > 0) { + change = create_xml_node(patchset, XML_DIFF_CHANGE); + + crm_xml_add(change, XML_DIFF_OP, ""move""); + crm_xml_add(change, XML_DIFF_PATH, buffer); + crm_xml_add_int(change, XML_DIFF_POSITION, __xml_offset_no_deletions(xml)); + } + } +} +",0,"__xml_build_changes(xmlNode * xml, xmlNode *patchset) +{ + xmlNode *cIter = NULL; + xmlAttr *pIter = NULL; + xmlNode *change = NULL; + xml_private_t *p = xml->_private; + + if(patchset && is_set(p->flags, xpf_created)) { + int offset = 0; + char buffer[XML_BUFFER_SIZE]; + + if(__get_prefix(NULL, xml->parent, buffer, offset) > 0) { + int position = __xml_offset_no_deletions(xml); + + change = create_xml_node(patchset, XML_DIFF_CHANGE); + + crm_xml_add(change, XML_DIFF_OP, ""create""); + crm_xml_add(change, XML_DIFF_PATH, buffer); + crm_xml_add_int(change, XML_DIFF_POSITION, position); + add_node_copy(change, xml); + } + + return; + } + + for (pIter = crm_first_attr(xml); pIter != NULL; pIter = pIter->next) { + xmlNode *attr = NULL; + + p = pIter->_private; + if(is_not_set(p->flags, xpf_deleted) && is_not_set(p->flags, xpf_dirty)) { + continue; + } + + if(change == NULL) { + int offset = 0; + char buffer[XML_BUFFER_SIZE]; + + if(__get_prefix(NULL, xml, buffer, offset) > 0) { + change = create_xml_node(patchset, XML_DIFF_CHANGE); + + crm_xml_add(change, XML_DIFF_OP, ""modify""); + crm_xml_add(change, XML_DIFF_PATH, buffer); + + change = create_xml_node(change, XML_DIFF_LIST); + } + } + + attr = create_xml_node(change, XML_DIFF_ATTR); + + crm_xml_add(attr, XML_NVPAIR_ATTR_NAME, (const char *)pIter->name); + if(p->flags & xpf_deleted) { + crm_xml_add(attr, XML_DIFF_OP, ""unset""); + + } else { + const char *value = crm_element_value(xml, (const char *)pIter->name); + + crm_xml_add(attr, XML_DIFF_OP, ""set""); + crm_xml_add(attr, XML_NVPAIR_ATTR_VALUE, value); + } + } + + if(change) { + xmlNode *result = NULL; + + change = create_xml_node(change->parent, XML_DIFF_RESULT); + result = create_xml_node(change, (const char *)xml->name); + + for (pIter = crm_first_attr(xml); pIter != NULL; pIter = pIter->next) { + const char *value = crm_element_value(xml, (const char *)pIter->name); + + p = pIter->_private; + if (is_not_set(p->flags, xpf_deleted)) { + crm_xml_add(result, (const char *)pIter->name, value); + } + } + } + + for (cIter = __xml_first_child(xml); cIter != NULL; cIter = __xml_next(cIter)) { + __xml_build_changes(cIter, patchset); + } + + p = xml->_private; + if(patchset && is_set(p->flags, xpf_moved)) { + int offset = 0; + char buffer[XML_BUFFER_SIZE]; + + crm_trace(""%s.%s moved to position %d"", xml->name, ID(xml), __xml_offset(xml)); + if(__get_prefix(NULL, xml, buffer, offset) > 0) { + change = create_xml_node(patchset, XML_DIFF_CHANGE); + + crm_xml_add(change, XML_DIFF_OP, ""move""); + crm_xml_add(change, XML_DIFF_PATH, buffer); + crm_xml_add_int(change, XML_DIFF_POSITION, __xml_offset_no_deletions(xml)); + } + } +} +","@@ -1020,13 +1020,16 @@ __xml_acl_post_process(xmlNode * xml) + + if(is_set(p->flags, xpf_created)) { + xmlAttr *xIter = NULL; ++ char *path = xml_get_path(xml); + +- /* Always allow new scaffolding, ie. node with no attributes or only an 'id' */ ++ /* Always allow new scaffolding, ie. node with no attributes or only an 'id' ++ * Except in the ACLs section ++ */ + + for (xIter = crm_first_attr(xml); xIter != NULL; xIter = xIter->next) { + const char *prop_name = (const char *)xIter->name; + +- if (strcmp(prop_name, XML_ATTR_ID) == 0) { ++ if (strcmp(prop_name, XML_ATTR_ID) == 0 && strstr(path, ""/""XML_CIB_TAG_ACLS""/"") == NULL) { + /* Delay the acl check */ + continue; + +@@ -1035,7 +1038,6 @@ __xml_acl_post_process(xmlNode * xml) + break; + + } else { +- char *path = xml_get_path(xml); + crm_trace(""Cannot add new node %s at %s"", crm_element_name(xml), path); + + if(xml != xmlDocGetRootElement(xml->doc)) { +@@ -1046,6 +1048,7 @@ __xml_acl_post_process(xmlNode * xml) + return; + } + } ++ free(path); + } + + while (cIter != NULL) {",798,1034,2048 +18571,"ResourceFetcher::DetermineRevalidationPolicy(Resource::Type type, + const FetchRequest& fetch_request, + Resource* existing_resource, + bool is_static_data) const { + const ResourceRequest& request = fetch_request.GetResourceRequest(); + + if (!existing_resource) + return kLoad; + + if (existing_resource->Loader() && + existing_resource->Loader()->Fetcher() != this) { + return kReload; + } + + RecordSriResourceIntegrityMismatchEvent(kCheckingForIntegrityMismatch); + if (existing_resource->MustRefetchDueToIntegrityMetadata(fetch_request)) { + RecordSriResourceIntegrityMismatchEvent(kRefetchDueToIntegrityMismatch); + return kReload; + } + + if (existing_resource->GetResponse().WasFallbackRequiredByServiceWorker()) + return kReload; + + if (existing_resource->GetType() != type) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to type mismatch.""; + return kReload; + } + + if (fetch_request.IsSpeculativePreload() && existing_resource->IsPreloaded()) + return kUse; + + if (existing_resource->IsImage() && + !Context().AllowImage(images_enabled_, existing_resource->Url())) { + return kReload; + } + + if (request.DownloadToFile() || request.UseStreamOnResponse()) + return kReload; + + if (existing_resource->GetResponse().WasFetchedViaServiceWorker() && + existing_resource->GetResponse().ServiceWorkerResponseType() == + kWebServiceWorkerResponseTypeOpaque && + request.GetFetchRequestMode() != WebURLRequest::kFetchRequestModeNoCORS) { + return kReload; + } + + if (is_static_data) + return kUse; + + if (!existing_resource->CanReuse(fetch_request)) + return kReload; + + if (request.IsConditional() || + existing_resource->GetResponse().HttpStatusCode() == 304) { + return kReload; + } + + if (allow_stale_resources_) + return kUse; + + if (!fetch_request.Options().CanReuseRequest(existing_resource->Options())) + return kReload; + + if (existing_resource->IsPreloaded()) + return kUse; + + if (request.GetCachePolicy() == WebCachePolicy::kReturnCacheDataElseLoad) + return kUse; + + if (existing_resource->HasCacheControlNoStoreHeader()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to Cache-control: no-store.""; + return kReload; + } + + if (existing_resource->GetResourceRequest().AllowStoredCredentials() != + request.AllowStoredCredentials()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to difference in credentials "" + ""settings.""; + return kReload; + } + + if (type != Resource::kRaw) { + if (!Context().IsLoadComplete() && + validated_ur_ls_.Contains(existing_resource->Url())) + return kUse; + if (existing_resource->IsLoading()) + return kUse; + } + + if (request.GetCachePolicy() == WebCachePolicy::kBypassingCache) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to "" + ""WebCachePolicy::BypassingCache.""; + return kReload; + } + + if (existing_resource->ErrorOccurred()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to resource being in the error "" + ""state""; + return kReload; + } + + if (type == Resource::kImage && + existing_resource == CachedResource(request.Url())) { + return kUse; + } + + if (existing_resource->MustReloadDueToVaryHeader(request)) + return kReload; + + if (!existing_resource->CanReuseRedirectChain()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to an uncacheable redirect""; + return kReload; + } + + if (request.GetCachePolicy() == WebCachePolicy::kValidatingCacheData || + existing_resource->MustRevalidateDueToCacheHeaders() || + request.CacheControlContainsNoCache()) { + if (existing_resource->CanUseCacheValidator() && + !Context().IsControlledByServiceWorker()) { + if (existing_resource->IsCacheValidator()) { + DCHECK(existing_resource->StillNeedsLoad()); + return kUse; + } + return kRevalidate; + } + + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to missing cache validators.""; + return kReload; + } + + return kUse; +} +",1,"ResourceFetcher::DetermineRevalidationPolicy(Resource::Type type, + const FetchRequest& fetch_request, + Resource* existing_resource, + bool is_static_data) const { + const ResourceRequest& request = fetch_request.GetResourceRequest(); + + if (!existing_resource) + return kLoad; + + if (existing_resource->Loader() && + existing_resource->Loader()->Fetcher() != this) { + return kReload; + } + + RecordSriResourceIntegrityMismatchEvent(kCheckingForIntegrityMismatch); + if (existing_resource->MustRefetchDueToIntegrityMetadata(fetch_request)) { + RecordSriResourceIntegrityMismatchEvent(kRefetchDueToIntegrityMismatch); + return kReload; + } + + if (existing_resource->GetResponse().WasFallbackRequiredByServiceWorker()) + return kReload; + + if (existing_resource->GetType() != type) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to type mismatch.""; + return kReload; + } + + if (fetch_request.IsSpeculativePreload() && existing_resource->IsPreloaded()) + return kUse; + + if (existing_resource->IsImage() && + !Context().AllowImage(images_enabled_, existing_resource->Url())) { + return kReload; + } + + if (request.DownloadToFile() || request.UseStreamOnResponse()) + return kReload; + + if (existing_resource->GetResponse().WasFetchedViaServiceWorker() && + existing_resource->GetResponse().ServiceWorkerResponseType() == + kWebServiceWorkerResponseTypeOpaque && + request.GetFetchRequestMode() != WebURLRequest::kFetchRequestModeNoCORS) { + return kReload; + } + + if (is_static_data) + return kUse; + + if (!existing_resource->CanReuse(fetch_request)) + return kReload; + + if (request.IsConditional() || + existing_resource->GetResponse().HttpStatusCode() == 304) { + return kReload; + } + + if (allow_stale_resources_) + return kUse; + + if (!fetch_request.Options().CanReuseRequest(existing_resource->Options())) + return kReload; + + if (existing_resource->IsPreloaded()) + return kUse; + + if (request.GetCachePolicy() == WebCachePolicy::kReturnCacheDataElseLoad) + return kUse; + + if (existing_resource->HasCacheControlNoStoreHeader()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to Cache-control: no-store.""; + return kReload; + } + + if (existing_resource->GetResourceRequest().AllowStoredCredentials() != + request.AllowStoredCredentials()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to difference in credentials "" + ""settings.""; + return kReload; + } + + if (type != Resource::kRaw) { + if (!Context().IsLoadComplete() && + validated_urls_.Contains(existing_resource->Url())) + return kUse; + if (existing_resource->IsLoading()) + return kUse; + } + + if (request.GetCachePolicy() == WebCachePolicy::kBypassingCache) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to "" + ""WebCachePolicy::BypassingCache.""; + return kReload; + } + + if (existing_resource->ErrorOccurred()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to resource being in the error "" + ""state""; + return kReload; + } + + if (type == Resource::kImage && + existing_resource == CachedResource(request.Url())) { + return kUse; + } + + if (existing_resource->MustReloadDueToVaryHeader(request)) + return kReload; + + if (!existing_resource->CanReuseRedirectChain()) { + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to an uncacheable redirect""; + return kReload; + } + + if (request.GetCachePolicy() == WebCachePolicy::kValidatingCacheData || + existing_resource->MustRevalidateDueToCacheHeaders() || + request.CacheControlContainsNoCache()) { + if (existing_resource->CanUseCacheValidator() && + !Context().IsControlledByServiceWorker()) { + if (existing_resource->IsCacheValidator()) { + DCHECK(existing_resource->StillNeedsLoad()); + return kUse; + } + return kRevalidate; + } + + RESOURCE_LOADING_DVLOG(1) << ""ResourceFetcher::determineRevalidationPolicy "" + ""reloading due to missing cache validators.""; + return kReload; + } + + return kUse; +} +","@@ -305,7 +305,7 @@ void ResourceFetcher::RequestLoadStarted(unsigned long identifier, + RevalidationPolicy policy, + bool is_static_data) { + if (policy == kUse && resource->GetStatus() == ResourceStatus::kCached && +- !validated_ur_ls_.Contains(resource->Url())) { ++ !validated_urls_.Contains(resource->Url())) { + // Loaded from MemoryCache. + DidLoadResourceFromMemoryCache(identifier, resource, + request.GetResourceRequest()); +@@ -315,7 +315,7 @@ void ResourceFetcher::RequestLoadStarted(unsigned long identifier, + return; + + if (policy == kUse && !resource->StillNeedsLoad() && +- !validated_ur_ls_.Contains(request.GetResourceRequest().Url())) { ++ !validated_urls_.Contains(request.GetResourceRequest().Url())) { + // Resources loaded from memory cache should be reported the first time + // they're used. + RefPtr info = ResourceTimingInfo::Create( +@@ -329,10 +329,10 @@ void ResourceFetcher::RequestLoadStarted(unsigned long identifier, + resource_timing_report_timer_.StartOneShot(0, BLINK_FROM_HERE); + } + +- if (validated_ur_ls_.size() >= kMaxValidatedURLsSize) { +- validated_ur_ls_.Clear(); ++ if (validated_urls_.size() >= kMaxValidatedURLsSize) { ++ validated_urls_.Clear(); + } +- validated_ur_ls_.insert(request.GetResourceRequest().Url()); ++ validated_urls_.insert(request.GetResourceRequest().Url()); + } + + void ResourceFetcher::DidLoadResourceFromMemoryCache( +@@ -968,7 +968,7 @@ ResourceFetcher::DetermineRevalidationPolicy(Resource::Type type, + // or other factors that require separate requests. + if (type != Resource::kRaw) { + if (!Context().IsLoadComplete() && +- validated_ur_ls_.Contains(existing_resource->Url())) ++ validated_urls_.Contains(existing_resource->Url())) + return kUse; + if (existing_resource->IsLoading()) + return kUse; +@@ -1096,24 +1096,24 @@ void ResourceFetcher::PreloadStarted(Resource* resource) { + preloads_ = new HeapListHashSet>; + preloads_->insert(resource); + +- if (preloaded_ur_ls_for_test_) +- preloaded_ur_ls_for_test_->insert(resource->Url().GetString()); ++ if (preloaded_urls_for_test_) ++ preloaded_urls_for_test_->insert(resource->Url().GetString()); + } + + void ResourceFetcher::EnableIsPreloadedForTest() { +- if (preloaded_ur_ls_for_test_) ++ if (preloaded_urls_for_test_) + return; +- preloaded_ur_ls_for_test_ = WTF::WrapUnique(new HashSet); ++ preloaded_urls_for_test_ = WTF::WrapUnique(new HashSet); + + if (preloads_) { + for (const auto& resource : *preloads_) +- preloaded_ur_ls_for_test_->insert(resource->Url().GetString()); ++ preloaded_urls_for_test_->insert(resource->Url().GetString()); + } + } + + bool ResourceFetcher::IsPreloadedForTest(const KURL& url) const { +- DCHECK(preloaded_ur_ls_for_test_); +- return preloaded_ur_ls_for_test_->Contains(url.GetString()); ++ DCHECK(preloaded_urls_for_test_); ++ return preloaded_urls_for_test_->Contains(url.GetString()); + } + + void ResourceFetcher::ClearPreloads(ClearPreloadsPolicy policy) {",1009,1245,2048 +17971,"static int rt_fill_info(struct net *net, __be32 dst, __be32 src, + struct flowi4 *fl4, struct sk_buff *skb, u32 portid, + u32 seq, int event, int nowait, unsigned int flags) +{ + struct rtable *rt = skb_rtable(skb); + struct rtmsg *r; + struct nlmsghdr *nlh; + unsigned long expires = 0; + u32 error; + u32 metrics[RTAX_MAX]; + + nlh = nlmsg_put(skb, portid, seq, event, sizeof(*r), flags); + if (nlh == NULL) + return -EMSGSIZE; + + r = nlmsg_data(nlh); + r->rtm_family = AF_INET; + r->rtm_dst_len = 32; + r->rtm_src_len = 0; + r->rtm_tos = fl4->flowi4_tos; + r->rtm_table = RT_TABLE_MAIN; + if (nla_put_u32(skb, RTA_TABLE, RT_TABLE_MAIN)) + goto nla_put_failure; + r->rtm_type = rt->rt_type; + r->rtm_scope = RT_SCOPE_UNIVERSE; + r->rtm_protocol = RTPROT_UNSPEC; + r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; + if (rt->rt_flags & RTCF_NOTIFY) + r->rtm_flags |= RTM_F_NOTIFY; + + if (nla_put_be32(skb, RTA_DST, dst)) + goto nla_put_failure; + if (src) { + r->rtm_src_len = 32; + if (nla_put_be32(skb, RTA_SRC, src)) + goto nla_put_failure; + } + if (rt->dst.dev && + nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) + goto nla_put_failure; +#ifdef CONFIG_IP_ROUTE_CLASSID + if (rt->dst.tclassid && + nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) + goto nla_put_failure; +#endif + if (!rt_is_input_route(rt) && + fl4->saddr != src) { + if (nla_put_be32(skb, RTA_PREFSRC, fl4->saddr)) + goto nla_put_failure; + } + if (rt->rt_uses_gateway && + nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway)) + goto nla_put_failure; + + expires = rt->dst.expires; + if (expires) { + unsigned long now = jiffies; + + if (time_before(now, expires)) + expires -= now; + else + expires = 0; + } + + memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); + if (rt->rt_pmtu && expires) + metrics[RTAX_MTU - 1] = rt->rt_pmtu; + if (rtnetlink_put_metrics(skb, metrics) < 0) + goto nla_put_failure; + + if (fl4->flowi4_mark && + nla_put_u32(skb, RTA_MARK, fl4->flowi4_mark)) + goto nla_put_failure; + + error = rt->dst.error; + + if (rt_is_input_route(rt)) { +#ifdef CONFIG_IP_MROUTE + if (ipv4_is_multicast(dst) && !ipv4_is_local_multicast(dst) && + IPV4_DEVCONF_ALL(net, MC_FORWARDING)) { + int err = ipmr_get_route(net, skb, + fl4->saddr, fl4->daddr, + r, nowait); + if (err <= 0) { + if (!nowait) { + if (err == 0) + return 0; + goto nla_put_failure; + } else { + if (err == -EMSGSIZE) + goto nla_put_failure; + error = err; + } + } + } else +#endif + if (nla_put_u32(skb, RTA_IIF, skb->dev->ifindex)) + goto nla_put_failure; + } + + if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) + goto nla_put_failure; + + return nlmsg_end(skb, nlh); + +nla_put_failure: + nlmsg_cancel(skb, nlh); + return -EMSGSIZE; +} +",1,"static int rt_fill_info(struct net *net, __be32 dst, __be32 src, + struct flowi4 *fl4, struct sk_buff *skb, u32 portid, + u32 seq, int event, int nowait, unsigned int flags) +{ + struct rtable *rt = skb_rtable(skb); + struct rtmsg *r; + struct nlmsghdr *nlh; + unsigned long expires = 0; + u32 error; + u32 metrics[RTAX_MAX]; + + nlh = nlmsg_put(skb, portid, seq, event, sizeof(*r), flags); + if (nlh == NULL) + return -EMSGSIZE; + + r = nlmsg_data(nlh); + r->rtm_family = AF_INET; + r->rtm_dst_len = 32; + r->rtm_src_len = 0; + r->rtm_tos = fl4->flowi4_tos; + r->rtm_table = RT_TABLE_MAIN; + if (nla_put_u32(skb, RTA_TABLE, RT_TABLE_MAIN)) + goto nla_put_failure; + r->rtm_type = rt->rt_type; + r->rtm_scope = RT_SCOPE_UNIVERSE; + r->rtm_protocol = RTPROT_UNSPEC; + r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; + if (rt->rt_flags & RTCF_NOTIFY) + r->rtm_flags |= RTM_F_NOTIFY; + if (IPCB(skb)->flags & IPSKB_DOREDIRECT) + r->rtm_flags |= RTCF_DOREDIRECT; + + if (nla_put_be32(skb, RTA_DST, dst)) + goto nla_put_failure; + if (src) { + r->rtm_src_len = 32; + if (nla_put_be32(skb, RTA_SRC, src)) + goto nla_put_failure; + } + if (rt->dst.dev && + nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) + goto nla_put_failure; +#ifdef CONFIG_IP_ROUTE_CLASSID + if (rt->dst.tclassid && + nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) + goto nla_put_failure; +#endif + if (!rt_is_input_route(rt) && + fl4->saddr != src) { + if (nla_put_be32(skb, RTA_PREFSRC, fl4->saddr)) + goto nla_put_failure; + } + if (rt->rt_uses_gateway && + nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway)) + goto nla_put_failure; + + expires = rt->dst.expires; + if (expires) { + unsigned long now = jiffies; + + if (time_before(now, expires)) + expires -= now; + else + expires = 0; + } + + memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); + if (rt->rt_pmtu && expires) + metrics[RTAX_MTU - 1] = rt->rt_pmtu; + if (rtnetlink_put_metrics(skb, metrics) < 0) + goto nla_put_failure; + + if (fl4->flowi4_mark && + nla_put_u32(skb, RTA_MARK, fl4->flowi4_mark)) + goto nla_put_failure; + + error = rt->dst.error; + + if (rt_is_input_route(rt)) { +#ifdef CONFIG_IP_MROUTE + if (ipv4_is_multicast(dst) && !ipv4_is_local_multicast(dst) && + IPV4_DEVCONF_ALL(net, MC_FORWARDING)) { + int err = ipmr_get_route(net, skb, + fl4->saddr, fl4->daddr, + r, nowait); + if (err <= 0) { + if (!nowait) { + if (err == 0) + return 0; + goto nla_put_failure; + } else { + if (err == -EMSGSIZE) + goto nla_put_failure; + error = err; + } + } + } else +#endif + if (nla_put_u32(skb, RTA_IIF, skb->dev->ifindex)) + goto nla_put_failure; + } + + if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) + goto nla_put_failure; + + return nlmsg_end(skb, nlh); + +nla_put_failure: + nlmsg_cancel(skb, nlh); + return -EMSGSIZE; +} +","@@ -1554,11 +1554,10 @@ static int __mkroute_input(struct sk_buff *skb, + + do_cache = res->fi && !itag; + if (out_dev == in_dev && err && IN_DEV_TX_REDIRECTS(out_dev) && ++ skb->protocol == htons(ETH_P_IP) && + (IN_DEV_SHARED_MEDIA(out_dev) || +- inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) { +- flags |= RTCF_DOREDIRECT; +- do_cache = false; +- } ++ inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) ++ IPCB(skb)->flags |= IPSKB_DOREDIRECT; + + if (skb->protocol != htons(ETH_P_IP)) { + /* Not IP (i.e. ARP). Do not create route, if it is +@@ -2303,6 +2302,8 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src, + r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; + if (rt->rt_flags & RTCF_NOTIFY) + r->rtm_flags |= RTM_F_NOTIFY; ++ if (IPCB(skb)->flags & IPSKB_DOREDIRECT) ++ r->rtm_flags |= RTCF_DOREDIRECT; + + if (nla_put_be32(skb, RTA_DST, dst)) + goto nla_put_failure;",970,1206,2048 +18321,"ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + struct ext2_xattr_header *header) +{ + struct super_block *sb = inode->i_sb; + struct buffer_head *new_bh = NULL; + int error; + + if (header) { + new_bh = ext2_xattr_cache_find(inode, header); + if (new_bh) { + /* We found an identical block in the cache. */ + if (new_bh == old_bh) { + ea_bdebug(new_bh, ""keeping this block""); + } else { + /* The old block is released after updating + the inode. */ + ea_bdebug(new_bh, ""reusing block""); + + error = dquot_alloc_block(inode, 1); + if (error) { + unlock_buffer(new_bh); + goto cleanup; + } + le32_add_cpu(&HDR(new_bh)->h_refcount, 1); + ea_bdebug(new_bh, ""refcount now=%d"", + le32_to_cpu(HDR(new_bh)->h_refcount)); + } + unlock_buffer(new_bh); + } else if (old_bh && header == HDR(old_bh)) { + /* Keep this block. No need to lock the block as we + don't need to change the reference count. */ + new_bh = old_bh; + get_bh(new_bh); + ext2_xattr_cache_insert(new_bh); + } else { + /* We need to allocate a new block */ + ext2_fsblk_t goal = ext2_group_first_block_no(sb, + EXT2_I(inode)->i_block_group); + int block = ext2_new_block(inode, goal, &error); + if (error) + goto cleanup; + ea_idebug(inode, ""creating block %d"", block); + + new_bh = sb_getblk(sb, block); + if (unlikely(!new_bh)) { + ext2_free_blocks(inode, block, 1); + mark_inode_dirty(inode); + error = -ENOMEM; + goto cleanup; + } + lock_buffer(new_bh); + memcpy(new_bh->b_data, header, new_bh->b_size); + set_buffer_uptodate(new_bh); + unlock_buffer(new_bh); + ext2_xattr_cache_insert(new_bh); + + ext2_xattr_update_super_block(sb); + } + mark_buffer_dirty(new_bh); + if (IS_SYNC(inode)) { + sync_dirty_buffer(new_bh); + error = -EIO; + if (buffer_req(new_bh) && !buffer_uptodate(new_bh)) + goto cleanup; + } + } + + /* Update the inode. */ + EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0; + inode->i_ctime = CURRENT_TIME_SEC; + if (IS_SYNC(inode)) { + error = sync_inode_metadata(inode, 1); + /* In case sync failed due to ENOSPC the inode was actually + * written (only some dirty data were not) so we just proceed + * as if nothing happened and cleanup the unused block */ + if (error && error != -ENOSPC) { + if (new_bh && new_bh != old_bh) { + dquot_free_block_nodirty(inode, 1); + mark_inode_dirty(inode); + } + goto cleanup; + } + } else + mark_inode_dirty(inode); + + error = 0; + if (old_bh && old_bh != new_bh) { + struct mb_cache_entry *ce; + /* + * If there was an old block and we are no longer using it, + * release the old block. + */ + ce = mb_cache_entry_get(ext2_xattr_cache, old_bh->b_bdev, + old_bh->b_blocknr); + lock_buffer(old_bh); + if (HDR(old_bh)->h_refcount == cpu_to_le32(1)) { + /* Free the old block. */ + if (ce) + mb_cache_entry_free(ce); + ea_bdebug(old_bh, ""freeing""); + ext2_free_blocks(inode, old_bh->b_blocknr, 1); + mark_inode_dirty(inode); + /* We let our caller release old_bh, so we + * need to duplicate the buffer before. */ + get_bh(old_bh); + bforget(old_bh); + } else { + /* Decrement the refcount only. */ + le32_add_cpu(&HDR(old_bh)->h_refcount, -1); + if (ce) + mb_cache_entry_release(ce); + dquot_free_block_nodirty(inode, 1); + mark_inode_dirty(inode); + mark_buffer_dirty(old_bh); + ea_bdebug(old_bh, ""refcount now=%d"", + le32_to_cpu(HDR(old_bh)->h_refcount)); + } + unlock_buffer(old_bh); + } + +cleanup: + brelse(new_bh); + + return error; +} +",1,"ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + struct ext2_xattr_header *header) +{ + struct super_block *sb = inode->i_sb; + struct buffer_head *new_bh = NULL; + int error; + struct mb2_cache *ext2_mb_cache = EXT2_SB(sb)->s_mb_cache; + + if (header) { + new_bh = ext2_xattr_cache_find(inode, header); + if (new_bh) { + /* We found an identical block in the cache. */ + if (new_bh == old_bh) { + ea_bdebug(new_bh, ""keeping this block""); + } else { + /* The old block is released after updating + the inode. */ + ea_bdebug(new_bh, ""reusing block""); + + error = dquot_alloc_block(inode, 1); + if (error) { + unlock_buffer(new_bh); + goto cleanup; + } + le32_add_cpu(&HDR(new_bh)->h_refcount, 1); + ea_bdebug(new_bh, ""refcount now=%d"", + le32_to_cpu(HDR(new_bh)->h_refcount)); + } + unlock_buffer(new_bh); + } else if (old_bh && header == HDR(old_bh)) { + /* Keep this block. No need to lock the block as we + don't need to change the reference count. */ + new_bh = old_bh; + get_bh(new_bh); + ext2_xattr_cache_insert(ext2_mb_cache, new_bh); + } else { + /* We need to allocate a new block */ + ext2_fsblk_t goal = ext2_group_first_block_no(sb, + EXT2_I(inode)->i_block_group); + int block = ext2_new_block(inode, goal, &error); + if (error) + goto cleanup; + ea_idebug(inode, ""creating block %d"", block); + + new_bh = sb_getblk(sb, block); + if (unlikely(!new_bh)) { + ext2_free_blocks(inode, block, 1); + mark_inode_dirty(inode); + error = -ENOMEM; + goto cleanup; + } + lock_buffer(new_bh); + memcpy(new_bh->b_data, header, new_bh->b_size); + set_buffer_uptodate(new_bh); + unlock_buffer(new_bh); + ext2_xattr_cache_insert(ext2_mb_cache, new_bh); + + ext2_xattr_update_super_block(sb); + } + mark_buffer_dirty(new_bh); + if (IS_SYNC(inode)) { + sync_dirty_buffer(new_bh); + error = -EIO; + if (buffer_req(new_bh) && !buffer_uptodate(new_bh)) + goto cleanup; + } + } + + /* Update the inode. */ + EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0; + inode->i_ctime = CURRENT_TIME_SEC; + if (IS_SYNC(inode)) { + error = sync_inode_metadata(inode, 1); + /* In case sync failed due to ENOSPC the inode was actually + * written (only some dirty data were not) so we just proceed + * as if nothing happened and cleanup the unused block */ + if (error && error != -ENOSPC) { + if (new_bh && new_bh != old_bh) { + dquot_free_block_nodirty(inode, 1); + mark_inode_dirty(inode); + } + goto cleanup; + } + } else + mark_inode_dirty(inode); + + error = 0; + if (old_bh && old_bh != new_bh) { + /* + * If there was an old block and we are no longer using it, + * release the old block. + */ + lock_buffer(old_bh); + if (HDR(old_bh)->h_refcount == cpu_to_le32(1)) { + __u32 hash = le32_to_cpu(HDR(old_bh)->h_hash); + + /* + * This must happen under buffer lock for + * ext2_xattr_set2() to reliably detect freed block + */ + mb2_cache_entry_delete_block(ext2_mb_cache, + hash, old_bh->b_blocknr); + /* Free the old block. */ + ea_bdebug(old_bh, ""freeing""); + ext2_free_blocks(inode, old_bh->b_blocknr, 1); + mark_inode_dirty(inode); + /* We let our caller release old_bh, so we + * need to duplicate the buffer before. */ + get_bh(old_bh); + bforget(old_bh); + } else { + /* Decrement the refcount only. */ + le32_add_cpu(&HDR(old_bh)->h_refcount, -1); + dquot_free_block_nodirty(inode, 1); + mark_inode_dirty(inode); + mark_buffer_dirty(old_bh); + ea_bdebug(old_bh, ""refcount now=%d"", + le32_to_cpu(HDR(old_bh)->h_refcount)); + } + unlock_buffer(old_bh); + } + +cleanup: + brelse(new_bh); + + return error; +} +","@@ -56,7 +56,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -90,14 +90,12 @@ + static int ext2_xattr_set2(struct inode *, struct buffer_head *, + struct ext2_xattr_header *); + +-static int ext2_xattr_cache_insert(struct buffer_head *); ++static int ext2_xattr_cache_insert(struct mb2_cache *, struct buffer_head *); + static struct buffer_head *ext2_xattr_cache_find(struct inode *, + struct ext2_xattr_header *); + static void ext2_xattr_rehash(struct ext2_xattr_header *, + struct ext2_xattr_entry *); + +-static struct mb_cache *ext2_xattr_cache; +- + static const struct xattr_handler *ext2_xattr_handler_map[] = { + [EXT2_XATTR_INDEX_USER] = &ext2_xattr_user_handler, + #ifdef CONFIG_EXT2_FS_POSIX_ACL +@@ -152,6 +150,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name, + size_t name_len, size; + char *end; + int error; ++ struct mb2_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; + + ea_idebug(inode, ""name=%d.%s, buffer=%p, buffer_size=%ld"", + name_index, name, buffer, (long)buffer_size); +@@ -196,7 +195,7 @@ bad_block: ext2_error(inode->i_sb, ""ext2_xattr_get"", + goto found; + entry = next; + } +- if (ext2_xattr_cache_insert(bh)) ++ if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) + ea_idebug(inode, ""cache insert failed""); + error = -ENODATA; + goto cleanup; +@@ -209,7 +208,7 @@ bad_block: ext2_error(inode->i_sb, ""ext2_xattr_get"", + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize) + goto bad_block; + +- if (ext2_xattr_cache_insert(bh)) ++ if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) + ea_idebug(inode, ""cache insert failed""); + if (buffer) { + error = -ERANGE; +@@ -247,6 +246,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) + char *end; + size_t rest = buffer_size; + int error; ++ struct mb2_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; + + ea_idebug(inode, ""buffer=%p, buffer_size=%ld"", + buffer, (long)buffer_size); +@@ -281,7 +281,7 @@ bad_block: ext2_error(inode->i_sb, ""ext2_xattr_list"", + goto bad_block; + entry = next; + } +- if (ext2_xattr_cache_insert(bh)) ++ if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) + ea_idebug(inode, ""cache insert failed""); + + /* list the attribute names */ +@@ -483,22 +483,23 @@ bad_block: ext2_error(sb, ""ext2_xattr_set"", + /* Here we know that we can set the new attribute. */ + + if (header) { +- struct mb_cache_entry *ce; +- + /* assert(header == HDR(bh)); */ +- ce = mb_cache_entry_get(ext2_xattr_cache, bh->b_bdev, +- bh->b_blocknr); + lock_buffer(bh); + if (header->h_refcount == cpu_to_le32(1)) { ++ __u32 hash = le32_to_cpu(header->h_hash); ++ + ea_bdebug(bh, ""modifying in-place""); +- if (ce) +- mb_cache_entry_free(ce); ++ /* ++ * This must happen under buffer lock for ++ * ext2_xattr_set2() to reliably detect modified block ++ */ ++ mb2_cache_entry_delete_block(EXT2_SB(sb)->s_mb_cache, ++ hash, bh->b_blocknr); ++ + /* keep the buffer locked while modifying it. */ + } else { + int offset; + +- if (ce) +- mb_cache_entry_release(ce); + unlock_buffer(bh); + ea_bdebug(bh, ""cloning""); + header = kmalloc(bh->b_size, GFP_KERNEL); +@@ -626,6 +627,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + struct super_block *sb = inode->i_sb; + struct buffer_head *new_bh = NULL; + int error; ++ struct mb2_cache *ext2_mb_cache = EXT2_SB(sb)->s_mb_cache; + + if (header) { + new_bh = ext2_xattr_cache_find(inode, header); +@@ -653,7 +655,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + don't need to change the reference count. */ + new_bh = old_bh; + get_bh(new_bh); +- ext2_xattr_cache_insert(new_bh); ++ ext2_xattr_cache_insert(ext2_mb_cache, new_bh); + } else { + /* We need to allocate a new block */ + ext2_fsblk_t goal = ext2_group_first_block_no(sb, +@@ -674,7 +676,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + memcpy(new_bh->b_data, header, new_bh->b_size); + set_buffer_uptodate(new_bh); + unlock_buffer(new_bh); +- ext2_xattr_cache_insert(new_bh); ++ ext2_xattr_cache_insert(ext2_mb_cache, new_bh); + + ext2_xattr_update_super_block(sb); + } +@@ -707,19 +709,21 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + + error = 0; + if (old_bh && old_bh != new_bh) { +- struct mb_cache_entry *ce; +- + /* + * If there was an old block and we are no longer using it, + * release the old block. + */ +- ce = mb_cache_entry_get(ext2_xattr_cache, old_bh->b_bdev, +- old_bh->b_blocknr); + lock_buffer(old_bh); + if (HDR(old_bh)->h_refcount == cpu_to_le32(1)) { ++ __u32 hash = le32_to_cpu(HDR(old_bh)->h_hash); ++ ++ /* ++ * This must happen under buffer lock for ++ * ext2_xattr_set2() to reliably detect freed block ++ */ ++ mb2_cache_entry_delete_block(ext2_mb_cache, ++ hash, old_bh->b_blocknr); + /* Free the old block. */ +- if (ce) +- mb_cache_entry_free(ce); + ea_bdebug(old_bh, ""freeing""); + ext2_free_blocks(inode, old_bh->b_blocknr, 1); + mark_inode_dirty(inode); +@@ -730,8 +734,6 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, + } else { + /* Decrement the refcount only. */ + le32_add_cpu(&HDR(old_bh)->h_refcount, -1); +- if (ce) +- mb_cache_entry_release(ce); + dquot_free_block_nodirty(inode, 1); + mark_inode_dirty(inode); + mark_buffer_dirty(old_bh); +@@ -757,7 +759,6 @@ void + ext2_xattr_delete_inode(struct inode *inode) + { + struct buffer_head *bh = NULL; +- struct mb_cache_entry *ce; + + down_write(&EXT2_I(inode)->xattr_sem); + if (!EXT2_I(inode)->i_file_acl) +@@ -777,19 +778,22 @@ ext2_xattr_delete_inode(struct inode *inode) + EXT2_I(inode)->i_file_acl); + goto cleanup; + } +- ce = mb_cache_entry_get(ext2_xattr_cache, bh->b_bdev, bh->b_blocknr); + lock_buffer(bh); + if (HDR(bh)->h_refcount == cpu_to_le32(1)) { +- if (ce) +- mb_cache_entry_free(ce); ++ __u32 hash = le32_to_cpu(HDR(bh)->h_hash); ++ ++ /* ++ * This must happen under buffer lock for ext2_xattr_set2() to ++ * reliably detect freed block ++ */ ++ mb2_cache_entry_delete_block(EXT2_SB(inode->i_sb)->s_mb_cache, ++ hash, bh->b_blocknr); + ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1); + get_bh(bh); + bforget(bh); + unlock_buffer(bh); + } else { + le32_add_cpu(&HDR(bh)->h_refcount, -1); +- if (ce) +- mb_cache_entry_release(ce); + ea_bdebug(bh, ""refcount now=%d"", + le32_to_cpu(HDR(bh)->h_refcount)); + unlock_buffer(bh); +@@ -805,18 +809,6 @@ ext2_xattr_delete_inode(struct inode *inode) + up_write(&EXT2_I(inode)->xattr_sem); + } + +-/* +- * ext2_xattr_put_super() +- * +- * This is called when a file system is unmounted. +- */ +-void +-ext2_xattr_put_super(struct super_block *sb) +-{ +- mb_cache_shrink(sb->s_bdev); +-} +- +- + /* + * ext2_xattr_cache_insert() + * +@@ -826,28 +818,20 @@ ext2_xattr_put_super(struct super_block *sb) + * Returns 0, or a negative error number on failure. + */ + static int +-ext2_xattr_cache_insert(struct buffer_head *bh) ++ext2_xattr_cache_insert(struct mb2_cache *cache, struct buffer_head *bh) + { + __u32 hash = le32_to_cpu(HDR(bh)->h_hash); +- struct mb_cache_entry *ce; + int error; + +- ce = mb_cache_entry_alloc(ext2_xattr_cache, GFP_NOFS); +- if (!ce) +- return -ENOMEM; +- error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, hash); ++ error = mb2_cache_entry_create(cache, GFP_NOFS, hash, bh->b_blocknr); + if (error) { +- mb_cache_entry_free(ce); + if (error == -EBUSY) { + ea_bdebug(bh, ""already in cache (%d cache entries)"", + atomic_read(&ext2_xattr_cache->c_entry_count)); + error = 0; + } +- } else { +- ea_bdebug(bh, ""inserting [%x] (%d cache entries)"", (int)hash, +- atomic_read(&ext2_xattr_cache->c_entry_count)); +- mb_cache_entry_release(ce); +- } ++ } else ++ ea_bdebug(bh, ""inserting [%x]"", (int)hash); + return error; + } + +@@ -903,31 +887,39 @@ static struct buffer_head * + ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header) + { + __u32 hash = le32_to_cpu(header->h_hash); +- struct mb_cache_entry *ce; ++ struct mb2_cache_entry *ce; ++ struct mb2_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; + + if (!header->h_hash) + return NULL; /* never share */ + ea_idebug(inode, ""looking for cached blocks [%x]"", (int)hash); + again: +- ce = mb_cache_entry_find_first(ext2_xattr_cache, inode->i_sb->s_bdev, +- hash); ++ ce = mb2_cache_entry_find_first(ext2_mb_cache, hash); + while (ce) { + struct buffer_head *bh; + +- if (IS_ERR(ce)) { +- if (PTR_ERR(ce) == -EAGAIN) +- goto again; +- break; +- } +- + bh = sb_bread(inode->i_sb, ce->e_block); + if (!bh) { + ext2_error(inode->i_sb, ""ext2_xattr_cache_find"", + ""inode %ld: block %ld read error"", + inode->i_ino, (unsigned long) ce->e_block); + } else { + lock_buffer(bh); +- if (le32_to_cpu(HDR(bh)->h_refcount) > ++ /* ++ * We have to be careful about races with freeing or ++ * rehashing of xattr block. Once we hold buffer lock ++ * xattr block's state is stable so we can check ++ * whether the block got freed / rehashed or not. ++ * Since we unhash mbcache entry under buffer lock when ++ * freeing / rehashing xattr block, checking whether ++ * entry is still hashed is reliable. ++ */ ++ if (hlist_bl_unhashed(&ce->e_hash_list)) { ++ mb2_cache_entry_put(ext2_mb_cache, ce); ++ unlock_buffer(bh); ++ brelse(bh); ++ goto again; ++ } else if (le32_to_cpu(HDR(bh)->h_refcount) > + EXT2_XATTR_REFCOUNT_MAX) { + ea_idebug(inode, ""block %ld refcount %d>%d"", + (unsigned long) ce->e_block, +@@ -936,13 +928,14 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header) + } else if (!ext2_xattr_cmp(header, HDR(bh))) { + ea_bdebug(bh, ""b_count=%d"", + atomic_read(&(bh->b_count))); +- mb_cache_entry_release(ce); ++ mb2_cache_entry_touch(ext2_mb_cache, ce); ++ mb2_cache_entry_put(ext2_mb_cache, ce); + return bh; + } + unlock_buffer(bh); + brelse(bh); + } +- ce = mb_cache_entry_find_next(ce, inode->i_sb->s_bdev, hash); ++ ce = mb2_cache_entry_find_next(ext2_mb_cache, ce); + } + return NULL; + } +@@ -1015,17 +1008,15 @@ static void ext2_xattr_rehash(struct ext2_xattr_header *header, + + #undef BLOCK_HASH_SHIFT + +-int __init +-init_ext2_xattr(void) ++#define HASH_BUCKET_BITS 10 ++ ++struct mb2_cache *ext2_xattr_create_cache(void) + { +- ext2_xattr_cache = mb_cache_create(""ext2_xattr"", 6); +- if (!ext2_xattr_cache) +- return -ENOMEM; +- return 0; ++ return mb2_cache_create(HASH_BUCKET_BITS); + } + +-void +-exit_ext2_xattr(void) ++void ext2_xattr_destroy_cache(struct mb2_cache *cache) + { +- mb_cache_destroy(ext2_xattr_cache); ++ if (cache) ++ mb2_cache_destroy(cache); + }",1077,1313,2048 +3,"int do_print(const char *path_p, const struct stat *st, int walk_flags, void *unused) +{ + const char *default_prefix = NULL; + acl_t acl = NULL, default_acl = NULL; + int error = 0; + + if (walk_flags & WALK_TREE_FAILED) { + fprintf(stderr, ""%s: %s: %s\n"", progname, xquote(path_p, ""\n\r""), + strerror(errno)); + return 1; + } + + /* + * Symlinks can never have ACLs, so when doing a physical walk, we + * skip symlinks altogether, and when doing a half-logical walk, we + * skip all non-toplevel symlinks. + */ + if ((walk_flags & WALK_TREE_SYMLINK) && + ((walk_flags & WALK_TREE_PHYSICAL) || + !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL)))) + return 0; + + if (opt_print_acl) { + acl = acl_get_file(path_p, ACL_TYPE_ACCESS); + if (acl == NULL && (errno == ENOSYS || errno == ENOTSUP)) + acl = acl_get_file_mode(path_p); + if (acl == NULL) + goto fail; + } + + if (opt_print_default_acl && S_ISDIR(st->st_mode)) { + default_acl = acl_get_file(path_p, ACL_TYPE_DEFAULT); + if (default_acl == NULL) { + if (errno != ENOSYS && errno != ENOTSUP) + goto fail; + } else if (acl_entries(default_acl) == 0) { + acl_free(default_acl); + default_acl = NULL; + } + } + + if (opt_skip_base && + (!acl || acl_equiv_mode(acl, NULL) == 0) && !default_acl) + return 0; + + if (opt_print_acl && opt_print_default_acl) + default_prefix = ""default:""; + + if (opt_strip_leading_slash) { + if (*path_p == '/') { + if (!absolute_warning) { + fprintf(stderr, _(""%s: Removing leading "" + ""'/' from absolute path names\n""), + progname); + absolute_warning = 1; + } + while (*path_p == '/') + path_p++; + } else if (*path_p == '.' && *(path_p+1) == '/') + while (*++path_p == '/') + /* nothing */ ; + if (*path_p == '\0') + path_p = "".""; + } + + if (opt_tabular) { + if (do_show(stdout, path_p, st, acl, default_acl) != 0) + goto fail; + } else { + if (opt_comments) { + printf(""# file: %s\n"", xquote(path_p, ""\n\r"")); + printf(""# owner: %s\n"", + xquote(user_name(st->st_uid, opt_numeric), "" \t\n\r"")); + printf(""# group: %s\n"", + xquote(group_name(st->st_gid, opt_numeric), "" \t\n\r"")); + } + if (acl != NULL) { + char *acl_text = acl_to_any_text(acl, NULL, '\n', + print_options); + if (!acl_text) + goto fail; + if (puts(acl_text) < 0) { + acl_free(acl_text); + goto fail; + } + acl_free(acl_text); + } + if (default_acl != NULL) { + char *acl_text = acl_to_any_text(default_acl, + default_prefix, '\n', + print_options); + if (!acl_text) + goto fail; + if (puts(acl_text) < 0) { + acl_free(acl_text); + goto fail; + } + acl_free(acl_text); + } + } + if (acl || default_acl || opt_comments) + printf(""\n""); + +cleanup: + if (acl) + acl_free(acl); + if (default_acl) + acl_free(default_acl); + return error; + +fail: + fprintf(stderr, ""%s: %s: %s\n"", progname, xquote(path_p, ""\n\r""), + strerror(errno)); + error = -1; + goto cleanup; +} +",0,"int do_print(const char *path_p, const struct stat *st, int walk_flags, void *unused) +{ + const char *default_prefix = NULL; + acl_t acl = NULL, default_acl = NULL; + int error = 0; + + if (walk_flags & WALK_TREE_FAILED) { + fprintf(stderr, ""%s: %s: %s\n"", progname, xquote(path_p, ""\n\r""), + strerror(errno)); + return 1; + } + + /* + * Symlinks can never have ACLs, so when doing a physical walk, we + * skip symlinks altogether, and when doing a half-logical walk, we + * skip all non-toplevel symlinks. + */ + if ((walk_flags & WALK_TREE_SYMLINK) && + ((walk_flags & WALK_TREE_PHYSICAL) || + !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL)))) + return 0; + + if (opt_print_acl) { + acl = acl_get_file(path_p, ACL_TYPE_ACCESS); + if (acl == NULL && (errno == ENOSYS || errno == ENOTSUP)) + acl = acl_get_file_mode(path_p); + if (acl == NULL) + goto fail; + } + + if (opt_print_default_acl && S_ISDIR(st->st_mode)) { + default_acl = acl_get_file(path_p, ACL_TYPE_DEFAULT); + if (default_acl == NULL) { + if (errno != ENOSYS && errno != ENOTSUP) + goto fail; + } else if (acl_entries(default_acl) == 0) { + acl_free(default_acl); + default_acl = NULL; + } + } + + if (opt_skip_base && + (!acl || acl_equiv_mode(acl, NULL) == 0) && !default_acl) + return 0; + + if (opt_print_acl && opt_print_default_acl) + default_prefix = ""default:""; + + if (opt_strip_leading_slash) { + if (*path_p == '/') { + if (!absolute_warning) { + fprintf(stderr, _(""%s: Removing leading "" + ""'/' from absolute path names\n""), + progname); + absolute_warning = 1; + } + while (*path_p == '/') + path_p++; + } else if (*path_p == '.' && *(path_p+1) == '/') + while (*++path_p == '/') + /* nothing */ ; + if (*path_p == '\0') + path_p = "".""; + } + + if (opt_tabular) { + if (do_show(stdout, path_p, st, acl, default_acl) != 0) + goto fail; + } else { + if (opt_comments) { + printf(""# file: %s\n"", xquote(path_p, ""\n\r"")); + printf(""# owner: %s\n"", + xquote(user_name(st->st_uid, opt_numeric), "" \t\n\r"")); + printf(""# group: %s\n"", + xquote(group_name(st->st_gid, opt_numeric), "" \t\n\r"")); + } + if (acl != NULL) { + char *acl_text = acl_to_any_text(acl, NULL, '\n', + print_options); + if (!acl_text) + goto fail; + if (puts(acl_text) < 0) { + acl_free(acl_text); + goto fail; + } + acl_free(acl_text); + } + if (default_acl != NULL) { + char *acl_text = acl_to_any_text(default_acl, + default_prefix, '\n', + print_options); + if (!acl_text) + goto fail; + if (puts(acl_text) < 0) { + acl_free(acl_text); + goto fail; + } + acl_free(acl_text); + } + } + if (acl || default_acl || opt_comments) + printf(""\n""); + +cleanup: + if (acl) + acl_free(acl); + if (default_acl) + acl_free(default_acl); + return error; + +fail: + fprintf(stderr, ""%s: %s: %s\n"", progname, xquote(path_p, ""\n\r""), + strerror(errno)); + error = -1; + goto cleanup; +} +","@@ -1,3 +1,6 @@+* Make sure that getfacl -R only calls stat(2) on symlinks when it needs to.+ This fixes http://oss.sgi.com/bugzilla/show_bug.cgi?id=790 ""getfacl follows+ symlinks, even without -L"". * Stop quoting nonprintable characters in the getfacl output: what is printable or not depends on the locale settings, and getfacl often gets it wrong. We still need to quote a few special characters like newlines so that setfacldiff --git a/getfacl/getfacl.c b/getfacl/getfacl.c +index fc650e3..b3e6200 100644 +--- a/getfacl/getfacl.c ++++ b/getfacl/getfacl.c@@ -70,7 +70,7 @@ struct option long_options[] = { const char *progname; const char *cmd_line_options; -int walk_flags = WALK_TREE_DEREFERENCE;+int walk_flags = WALK_TREE_DEREFERENCE_TOPLEVEL; int opt_print_acl; int opt_print_default_acl; int opt_strip_leading_slash = 1;@@ -642,7 +642,7 @@ int main(int argc, char *argv[]) case 'L': /* follow all symlinks */ if (posixly_correct) goto synopsis;- walk_flags |= WALK_TREE_LOGICAL;+ walk_flags |= WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE; walk_flags &= ~WALK_TREE_PHYSICAL; break; @@ -650,7 +650,8 @@ int main(int argc, char *argv[]) if (posixly_correct) goto synopsis; walk_flags |= WALK_TREE_PHYSICAL;- walk_flags &= ~WALK_TREE_LOGICAL;+ walk_flags &= ~(WALK_TREE_LOGICAL | WALK_TREE_DEREFERENCE |+ WALK_TREE_DEREFERENCE_TOPLEVEL); break; case 's': /* skip files with only base entries */",900,1136,2048 +16599,"void RenderFrameImpl::CommitNavigation( + const network::ResourceResponseHead& head, + const CommonNavigationParams& common_params, + const RequestNavigationParams& request_params, + network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints, + std::unique_ptr subresource_loader_factories, + base::Optional> + subresource_overrides, + blink::mojom::ControllerServiceWorkerInfoPtr controller_service_worker_info, + network::mojom::URLLoaderFactoryPtr prefetch_loader_factory, + const base::UnguessableToken& devtools_navigation_token, + CommitNavigationCallback callback) { + DCHECK(!IsRendererDebugURL(common_params.url)); + DCHECK( + !FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type)); + if (!browser_side_navigation_pending_ && + !browser_side_navigation_pending_url_.is_empty() && + browser_side_navigation_pending_url_ == request_params.original_url && + request_params.nav_entry_id == 0) { + browser_side_navigation_pending_url_ = GURL(); + std::move(callback).Run(blink::mojom::CommitResult::Aborted); + return; + } + + DCHECK(common_params.url.SchemeIs(url::kJavaScriptScheme) || + !base::FeatureList::IsEnabled(network::features::kNetworkService) || + subresource_loader_factories); + + SetupLoaderFactoryBundle(std::move(subresource_loader_factories), + std::move(subresource_overrides), + std::move(prefetch_loader_factory)); + + if (request_params.is_view_source) + frame_->EnableViewSourceMode(true); + + PrepareFrameForCommit(common_params.url, request_params); + + const network::ResourceResponseHead* response_head = nullptr; + if (!frame_->Parent() && !frame_->IsViewSourceModeEnabled()) + response_head = &head; + std::unique_ptr document_state(BuildDocumentStateFromParams( + common_params, request_params, base::TimeTicks::Now(), + std::move(callback), response_head)); + + blink::WebFrameLoadType load_type = NavigationTypeToLoadType( + common_params.navigation_type, common_params.should_replace_current_entry, + request_params.page_state.IsValid()); + + WebHistoryItem item_for_history_navigation; + blink::mojom::CommitResult commit_status = blink::mojom::CommitResult::Ok; + + if (load_type == WebFrameLoadType::kBackForward) { + DCHECK_NE(0, request_params.nav_entry_id); + + commit_status = PrepareForHistoryNavigationCommit( + common_params.navigation_type, request_params, + &item_for_history_navigation, &load_type); + } + + if (commit_status != blink::mojom::CommitResult::Ok) { + if (frame_ && !frame_->IsLoading()) + Send(new FrameHostMsg_DidStopLoading(routing_id_)); + return; + } + + base::WeakPtr weak_this = weak_factory_.GetWeakPtr(); + bool is_client_redirect = + !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT); + + auto navigation_params = + std::make_unique(devtools_navigation_token); + navigation_params->frame_load_type = load_type; + navigation_params->history_item = item_for_history_navigation; + navigation_params->is_client_redirect = is_client_redirect; + navigation_params->service_worker_network_provider = + BuildServiceWorkerNetworkProviderForNavigation( + &request_params, std::move(controller_service_worker_info)); + FillNavigationParams(common_params, request_params, navigation_params.get()); + + bool should_load_data_url = !common_params.base_url_for_data_url.is_empty(); +#if defined(OS_ANDROID) + should_load_data_url |= !request_params.data_url_as_string.empty(); +#endif + if (is_main_frame_ && should_load_data_url) { + std::string mime_type, charset, data; + GURL base_url; + DecodeDataURL(common_params, request_params, &mime_type, &charset, &data, + &base_url); + navigation_params->request = WebURLRequest(base_url); + navigation_params->data = WebData(data.c_str(), data.length()); + navigation_params->mime_type = WebString::FromUTF8(mime_type); + navigation_params->text_encoding = WebString::FromUTF8(charset); + navigation_params->unreachable_url = common_params.history_url_for_data_url; + } else { + navigation_params->request = + CreateURLRequestForCommit(common_params, request_params, + std::move(url_loader_client_endpoints), head); + } + + committing_main_request_ = true; + frame_->CommitNavigation(std::move(navigation_params), + std::move(document_state)); + if (!weak_this) + return; + committing_main_request_ = false; +} +",0,"void RenderFrameImpl::CommitNavigation( + const network::ResourceResponseHead& head, + const CommonNavigationParams& common_params, + const RequestNavigationParams& request_params, + network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints, + std::unique_ptr subresource_loader_factories, + base::Optional> + subresource_overrides, + blink::mojom::ControllerServiceWorkerInfoPtr controller_service_worker_info, + network::mojom::URLLoaderFactoryPtr prefetch_loader_factory, + const base::UnguessableToken& devtools_navigation_token, + CommitNavigationCallback callback) { + DCHECK(!IsRendererDebugURL(common_params.url)); + DCHECK( + !FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type)); + if (!browser_side_navigation_pending_ && + !browser_side_navigation_pending_url_.is_empty() && + browser_side_navigation_pending_url_ == request_params.original_url && + request_params.nav_entry_id == 0) { + browser_side_navigation_pending_url_ = GURL(); + std::move(callback).Run(blink::mojom::CommitResult::Aborted); + return; + } + + DCHECK(common_params.url.SchemeIs(url::kJavaScriptScheme) || + !base::FeatureList::IsEnabled(network::features::kNetworkService) || + subresource_loader_factories); + + SetupLoaderFactoryBundle(std::move(subresource_loader_factories), + std::move(subresource_overrides), + std::move(prefetch_loader_factory)); + + if (request_params.is_view_source) + frame_->EnableViewSourceMode(true); + + PrepareFrameForCommit(common_params.url, request_params); + + const network::ResourceResponseHead* response_head = nullptr; + if (!frame_->Parent() && !frame_->IsViewSourceModeEnabled()) + response_head = &head; + std::unique_ptr document_state(BuildDocumentStateFromParams( + common_params, request_params, base::TimeTicks::Now(), + std::move(callback), response_head)); + + blink::WebFrameLoadType load_type = NavigationTypeToLoadType( + common_params.navigation_type, common_params.should_replace_current_entry, + request_params.page_state.IsValid()); + + WebHistoryItem item_for_history_navigation; + blink::mojom::CommitResult commit_status = blink::mojom::CommitResult::Ok; + + if (load_type == WebFrameLoadType::kBackForward) { + DCHECK_NE(0, request_params.nav_entry_id); + + commit_status = PrepareForHistoryNavigationCommit( + common_params.navigation_type, request_params, + &item_for_history_navigation, &load_type); + } + + if (commit_status != blink::mojom::CommitResult::Ok) { + if (frame_ && !frame_->IsLoading()) + Send(new FrameHostMsg_DidStopLoading(routing_id_)); + return; + } + + base::WeakPtr weak_this = weak_factory_.GetWeakPtr(); + bool is_client_redirect = + !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT); + + auto navigation_params = + std::make_unique(devtools_navigation_token); + navigation_params->frame_load_type = load_type; + navigation_params->history_item = item_for_history_navigation; + navigation_params->is_client_redirect = is_client_redirect; + navigation_params->service_worker_network_provider = + BuildServiceWorkerNetworkProviderForNavigation( + &request_params, std::move(controller_service_worker_info)); + FillNavigationParams(common_params, request_params, navigation_params.get()); + + bool should_load_data_url = !common_params.base_url_for_data_url.is_empty(); +#if defined(OS_ANDROID) + should_load_data_url |= !request_params.data_url_as_string.empty(); +#endif + if (is_main_frame_ && should_load_data_url) { + std::string mime_type, charset, data; + GURL base_url; + DecodeDataURL(common_params, request_params, &mime_type, &charset, &data, + &base_url); + navigation_params->request = WebURLRequest(base_url); + navigation_params->data = WebData(data.c_str(), data.length()); + navigation_params->mime_type = WebString::FromUTF8(mime_type); + navigation_params->text_encoding = WebString::FromUTF8(charset); + navigation_params->unreachable_url = common_params.history_url_for_data_url; + } else { + navigation_params->request = + CreateURLRequestForCommit(common_params, request_params, + std::move(url_loader_client_endpoints), head); + } + + committing_main_request_ = true; + frame_->CommitNavigation(std::move(navigation_params), + std::move(document_state)); + if (!weak_this) + return; + committing_main_request_ = false; +} +","@@ -6378,8 +6378,12 @@ void RenderFrameImpl::OnSelectPopupMenuItem(int selected_index) { + return; + + blink::WebScopedUserGesture gesture(frame_); +- external_popup_menu_->DidSelectItem(selected_index); +- external_popup_menu_.reset(); ++ // We need to reset |external_popup_menu_| before calling DidSelectItem(), ++ // which might delete |this|. ++ // See ExternalPopupMenuRemoveTest.RemoveFrameOnChange ++ std::unique_ptr popup; ++ popup.swap(external_popup_menu_); ++ popup->DidSelectItem(selected_index); + } + #else + void RenderFrameImpl::OnSelectPopupMenuItems( +@@ -6393,8 +6397,12 @@ void RenderFrameImpl::OnSelectPopupMenuItems( + return; + + blink::WebScopedUserGesture gesture(frame_); +- external_popup_menu_->DidSelectItems(canceled, selected_indices); +- external_popup_menu_.reset(); ++ // We need to reset |external_popup_menu_| before calling DidSelectItems(), ++ // which might delete |this|. ++ // See ExternalPopupMenuRemoveTest.RemoveFrameOnChange ++ std::unique_ptr popup; ++ popup.swap(external_popup_menu_); ++ popup->DidSelectItems(canceled, selected_indices); + } + #endif + #endif",990,1226,2048 +14654,"void Document::InheritHtmlAndBodyElementStyles(StyleRecalcChange change) { + DCHECK(InStyleRecalc()); + DCHECK(documentElement()); + + bool did_recalc_document_element = false; + RefPtr document_element_style = + documentElement()->MutableComputedStyle(); + if (change == kForce) + documentElement()->ClearAnimationStyleChange(); + if (!document_element_style || documentElement()->NeedsStyleRecalc() || + change == kForce) { + document_element_style = + EnsureStyleResolver().StyleForElement(documentElement()); + did_recalc_document_element = true; + } + + WritingMode root_writing_mode = document_element_style->GetWritingMode(); + TextDirection root_direction = document_element_style->Direction(); + + HTMLElement* body = this->body(); + RefPtr body_style; + + if (body) { + body_style = body->MutableComputedStyle(); + if (did_recalc_document_element) + body->ClearAnimationStyleChange(); + if (!body_style || body->NeedsStyleRecalc() || + did_recalc_document_element) { + body_style = EnsureStyleResolver().StyleForElement( + body, document_element_style.Get(), document_element_style.Get()); + } + root_writing_mode = body_style->GetWritingMode(); + root_direction = body_style->Direction(); + } + + const ComputedStyle* background_style = document_element_style.Get(); + if (isHTMLHtmlElement(documentElement()) && isHTMLBodyElement(body) && + !background_style->HasBackground()) + background_style = body_style.Get(); + + Node& root_scroller = GetRootScrollerController().EffectiveRootScroller(); + RefPtr root_scroller_style; + if (this != &root_scroller) { + DCHECK(root_scroller.IsElementNode()); + Element* root_scroller_element = ToElement(&root_scroller); + root_scroller_style = root_scroller_element->MutableComputedStyle(); + + if (!root_scroller_style || root_scroller_element->NeedsStyleRecalc()) { + root_scroller_style = + EnsureStyleResolver().StyleForElement(root_scroller_element); + } + + background_style = root_scroller_style.Get(); + } + + Color background_color = + background_style->VisitedDependentColor(CSSPropertyBackgroundColor); + FillLayer background_layers = background_style->BackgroundLayers(); + for (auto current_layer = &background_layers; current_layer; + current_layer = current_layer->Next()) { + current_layer->SetClip(kBorderFillBox); + + if (current_layer->Attachment() == kScrollBackgroundAttachment) + current_layer->SetAttachment(kLocalBackgroundAttachment); + } + EImageRendering image_rendering = background_style->ImageRendering(); + + const ComputedStyle* overflow_style = nullptr; + if (Element* element = + ViewportDefiningElement(document_element_style.Get())) { + if (element == body) { + overflow_style = body_style.Get(); + } else { + DCHECK_EQ(element, documentElement()); + overflow_style = document_element_style.Get(); + + if (body_style && !body_style->IsOverflowVisible()) + UseCounter::Count(*this, WebFeature::kBodyScrollsInAdditionToViewport); + } + } + + if (GetStyleEngine().UsesRemUnits() && + (documentElement()->NeedsAttach() || + !documentElement()->GetComputedStyle() || + documentElement()->GetComputedStyle()->FontSize() != + document_element_style->FontSize())) { + EnsureStyleResolver().InvalidateMatchedPropertiesCache(); + documentElement()->SetNeedsStyleRecalc( + kSubtreeStyleChange, StyleChangeReasonForTracing::Create( + StyleChangeReason::kFontSizeChange)); + } + + EOverflowAnchor overflow_anchor = EOverflowAnchor::kAuto; + EOverflow overflow_x = EOverflow::kAuto; + EOverflow overflow_y = EOverflow::kAuto; + float column_gap = 0; + if (overflow_style) { + overflow_anchor = overflow_style->OverflowAnchor(); + overflow_x = overflow_style->OverflowX(); + overflow_y = overflow_style->OverflowY(); + if (overflow_x == EOverflow::kVisible) + overflow_x = EOverflow::kAuto; + if (overflow_y == EOverflow::kVisible) + overflow_y = EOverflow::kAuto; + if (overflow_anchor == EOverflowAnchor::kVisible) + overflow_anchor = EOverflowAnchor::kAuto; + column_gap = overflow_style->ColumnGap(); + } + + ScrollSnapType snap_type = overflow_style->GetScrollSnapType(); + + RefPtr viewport_style = GetLayoutViewItem().MutableStyle(); + if (viewport_style->GetWritingMode() != root_writing_mode || + viewport_style->Direction() != root_direction || + viewport_style->VisitedDependentColor(CSSPropertyBackgroundColor) != + background_color || + viewport_style->BackgroundLayers() != background_layers || + viewport_style->ImageRendering() != image_rendering || + viewport_style->OverflowAnchor() != overflow_anchor || + viewport_style->OverflowX() != overflow_x || + viewport_style->OverflowY() != overflow_y || + viewport_style->ColumnGap() != column_gap || + viewport_style->GetScrollSnapType() != snap_type) { + RefPtr new_style = ComputedStyle::Clone(*viewport_style); + new_style->SetWritingMode(root_writing_mode); + new_style->SetDirection(root_direction); + new_style->SetBackgroundColor(background_color); + new_style->AccessBackgroundLayers() = background_layers; + new_style->SetImageRendering(image_rendering); + new_style->SetOverflowAnchor(overflow_anchor); + new_style->SetOverflowX(overflow_x); + new_style->SetOverflowY(overflow_y); + new_style->SetColumnGap(column_gap); + new_style->SetScrollSnapType(snap_type); + GetLayoutViewItem().SetStyle(new_style); + SetupFontBuilder(*new_style); + } + + if (body) { + if (const ComputedStyle* style = body->GetComputedStyle()) { + if (style->Direction() != root_direction || + style->GetWritingMode() != root_writing_mode) + body->SetNeedsStyleRecalc(kSubtreeStyleChange, + StyleChangeReasonForTracing::Create( + StyleChangeReason::kWritingModeChange)); + } + } + + if (const ComputedStyle* style = documentElement()->GetComputedStyle()) { + if (style->Direction() != root_direction || + style->GetWritingMode() != root_writing_mode) + documentElement()->SetNeedsStyleRecalc( + kSubtreeStyleChange, StyleChangeReasonForTracing::Create( + StyleChangeReason::kWritingModeChange)); + } +} +",0,"void Document::InheritHtmlAndBodyElementStyles(StyleRecalcChange change) { + DCHECK(InStyleRecalc()); + DCHECK(documentElement()); + + bool did_recalc_document_element = false; + RefPtr document_element_style = + documentElement()->MutableComputedStyle(); + if (change == kForce) + documentElement()->ClearAnimationStyleChange(); + if (!document_element_style || documentElement()->NeedsStyleRecalc() || + change == kForce) { + document_element_style = + EnsureStyleResolver().StyleForElement(documentElement()); + did_recalc_document_element = true; + } + + WritingMode root_writing_mode = document_element_style->GetWritingMode(); + TextDirection root_direction = document_element_style->Direction(); + + HTMLElement* body = this->body(); + RefPtr body_style; + + if (body) { + body_style = body->MutableComputedStyle(); + if (did_recalc_document_element) + body->ClearAnimationStyleChange(); + if (!body_style || body->NeedsStyleRecalc() || + did_recalc_document_element) { + body_style = EnsureStyleResolver().StyleForElement( + body, document_element_style.Get(), document_element_style.Get()); + } + root_writing_mode = body_style->GetWritingMode(); + root_direction = body_style->Direction(); + } + + const ComputedStyle* background_style = document_element_style.Get(); + if (isHTMLHtmlElement(documentElement()) && isHTMLBodyElement(body) && + !background_style->HasBackground()) + background_style = body_style.Get(); + + Node& root_scroller = GetRootScrollerController().EffectiveRootScroller(); + RefPtr root_scroller_style; + if (this != &root_scroller) { + DCHECK(root_scroller.IsElementNode()); + Element* root_scroller_element = ToElement(&root_scroller); + root_scroller_style = root_scroller_element->MutableComputedStyle(); + + if (!root_scroller_style || root_scroller_element->NeedsStyleRecalc()) { + root_scroller_style = + EnsureStyleResolver().StyleForElement(root_scroller_element); + } + + background_style = root_scroller_style.Get(); + } + + Color background_color = + background_style->VisitedDependentColor(CSSPropertyBackgroundColor); + FillLayer background_layers = background_style->BackgroundLayers(); + for (auto current_layer = &background_layers; current_layer; + current_layer = current_layer->Next()) { + current_layer->SetClip(kBorderFillBox); + + if (current_layer->Attachment() == kScrollBackgroundAttachment) + current_layer->SetAttachment(kLocalBackgroundAttachment); + } + EImageRendering image_rendering = background_style->ImageRendering(); + + const ComputedStyle* overflow_style = nullptr; + if (Element* element = + ViewportDefiningElement(document_element_style.Get())) { + if (element == body) { + overflow_style = body_style.Get(); + } else { + DCHECK_EQ(element, documentElement()); + overflow_style = document_element_style.Get(); + + if (body_style && !body_style->IsOverflowVisible()) + UseCounter::Count(*this, WebFeature::kBodyScrollsInAdditionToViewport); + } + } + + if (GetStyleEngine().UsesRemUnits() && + (documentElement()->NeedsAttach() || + !documentElement()->GetComputedStyle() || + documentElement()->GetComputedStyle()->FontSize() != + document_element_style->FontSize())) { + EnsureStyleResolver().InvalidateMatchedPropertiesCache(); + documentElement()->SetNeedsStyleRecalc( + kSubtreeStyleChange, StyleChangeReasonForTracing::Create( + StyleChangeReason::kFontSizeChange)); + } + + EOverflowAnchor overflow_anchor = EOverflowAnchor::kAuto; + EOverflow overflow_x = EOverflow::kAuto; + EOverflow overflow_y = EOverflow::kAuto; + float column_gap = 0; + if (overflow_style) { + overflow_anchor = overflow_style->OverflowAnchor(); + overflow_x = overflow_style->OverflowX(); + overflow_y = overflow_style->OverflowY(); + if (overflow_x == EOverflow::kVisible) + overflow_x = EOverflow::kAuto; + if (overflow_y == EOverflow::kVisible) + overflow_y = EOverflow::kAuto; + if (overflow_anchor == EOverflowAnchor::kVisible) + overflow_anchor = EOverflowAnchor::kAuto; + column_gap = overflow_style->ColumnGap(); + } + + ScrollSnapType snap_type = overflow_style->GetScrollSnapType(); + + RefPtr viewport_style = GetLayoutViewItem().MutableStyle(); + if (viewport_style->GetWritingMode() != root_writing_mode || + viewport_style->Direction() != root_direction || + viewport_style->VisitedDependentColor(CSSPropertyBackgroundColor) != + background_color || + viewport_style->BackgroundLayers() != background_layers || + viewport_style->ImageRendering() != image_rendering || + viewport_style->OverflowAnchor() != overflow_anchor || + viewport_style->OverflowX() != overflow_x || + viewport_style->OverflowY() != overflow_y || + viewport_style->ColumnGap() != column_gap || + viewport_style->GetScrollSnapType() != snap_type) { + RefPtr new_style = ComputedStyle::Clone(*viewport_style); + new_style->SetWritingMode(root_writing_mode); + new_style->SetDirection(root_direction); + new_style->SetBackgroundColor(background_color); + new_style->AccessBackgroundLayers() = background_layers; + new_style->SetImageRendering(image_rendering); + new_style->SetOverflowAnchor(overflow_anchor); + new_style->SetOverflowX(overflow_x); + new_style->SetOverflowY(overflow_y); + new_style->SetColumnGap(column_gap); + new_style->SetScrollSnapType(snap_type); + GetLayoutViewItem().SetStyle(new_style); + SetupFontBuilder(*new_style); + } + + if (body) { + if (const ComputedStyle* style = body->GetComputedStyle()) { + if (style->Direction() != root_direction || + style->GetWritingMode() != root_writing_mode) + body->SetNeedsStyleRecalc(kSubtreeStyleChange, + StyleChangeReasonForTracing::Create( + StyleChangeReason::kWritingModeChange)); + } + } + + if (const ComputedStyle* style = documentElement()->GetComputedStyle()) { + if (style->Direction() != root_direction || + style->GetWritingMode() != root_writing_mode) + documentElement()->SetNeedsStyleRecalc( + kSubtreeStyleChange, StyleChangeReasonForTracing::Create( + StyleChangeReason::kWritingModeChange)); + } +} +","@@ -5839,6 +5839,8 @@ void Document::InitSecurityContext(const DocumentInit& initializer) { + AddInsecureNavigationUpgrade(to_upgrade); + } + ++ ContentSecurityPolicy* policy_to_inherit = nullptr; ++ + if (IsSandboxed(kSandboxOrigin)) { + cookie_url_ = url_; + SetSecurityOrigin(SecurityOrigin::CreateUnique()); +@@ -5854,12 +5856,14 @@ void Document::InitSecurityContext(const DocumentInit& initializer) { + GetSecurityOrigin()->SetUniqueOriginIsPotentiallyTrustworthy(true); + if (owner->GetSecurityOrigin()->CanLoadLocalResources()) + GetSecurityOrigin()->GrantLoadLocalResources(); ++ policy_to_inherit = owner->GetContentSecurityPolicy(); + } + } else if (Document* owner = initializer.OwnerDocument()) { + cookie_url_ = owner->CookieURL(); + // We alias the SecurityOrigins to match Firefox, see Bug 15313 + // https://bugs.webkit.org/show_bug.cgi?id=15313 + SetSecurityOrigin(owner->GetSecurityOrigin()); ++ policy_to_inherit = owner->GetContentSecurityPolicy(); + } else { + cookie_url_ = url_; + SetSecurityOrigin(SecurityOrigin::Create(url_)); +@@ -5891,7 +5895,7 @@ void Document::InitSecurityContext(const DocumentInit& initializer) { + SetContentSecurityPolicy( + ImportsController()->Master()->GetContentSecurityPolicy()); + } else { +- InitContentSecurityPolicy(); ++ InitContentSecurityPolicy(nullptr, policy_to_inherit); + } + + if (GetSecurityOrigin()->HasSuborigin()) +@@ -5926,7 +5930,13 @@ void Document::InitSecurityContext(const DocumentInit& initializer) { + SetFeaturePolicy(g_empty_string); + } + +-void Document::InitContentSecurityPolicy(ContentSecurityPolicy* csp) { ++// the first parameter specifies a policy to use as the document csp meaning ++// the document will take ownership of the policy ++// the second parameter specifies a policy to inherit meaning the document ++// will attempt to copy over the policy ++void Document::InitContentSecurityPolicy( ++ ContentSecurityPolicy* csp, ++ const ContentSecurityPolicy* policy_to_inherit) { + SetContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::Create()); + + // We inherit the parent/opener's CSP for documents with ""local"" schemes: +@@ -5938,24 +5948,27 @@ void Document::InitContentSecurityPolicy(ContentSecurityPolicy* csp) { + // + // TODO(dcheng): This is similar enough to work we're doing in + // 'DocumentLoader::ensureWriter' that it might make sense to combine them. +- if (frame_) { ++ if (policy_to_inherit) { ++ GetContentSecurityPolicy()->CopyStateFrom(policy_to_inherit); ++ } else if (frame_) { + Frame* inherit_from = frame_->Tree().Parent() ? frame_->Tree().Parent() + : frame_->Client()->Opener(); + if (inherit_from && frame_ != inherit_from) { + DCHECK(inherit_from->GetSecurityContext() && + inherit_from->GetSecurityContext()->GetContentSecurityPolicy()); +- ContentSecurityPolicy* policy_to_inherit = ++ policy_to_inherit = + inherit_from->GetSecurityContext()->GetContentSecurityPolicy(); + if (url_.IsEmpty() || url_.ProtocolIsAbout() || url_.ProtocolIsData() || + url_.ProtocolIs(""blob"") || url_.ProtocolIs(""filesystem"")) { + GetContentSecurityPolicy()->CopyStateFrom(policy_to_inherit); + } +- // Plugin documents inherit their parent/opener's 'plugin-types' directive +- // regardless of URL. +- if (IsPluginDocument()) +- GetContentSecurityPolicy()->CopyPluginTypesFrom(policy_to_inherit); + } + } ++ // Plugin documents inherit their parent/opener's 'plugin-types' directive ++ // regardless of URL. ++ if (policy_to_inherit && IsPluginDocument()) ++ GetContentSecurityPolicy()->CopyPluginTypesFrom(policy_to_inherit); ++ + GetContentSecurityPolicy()->BindToExecutionContext(this); + } + ",1391,1627,2048 +18300,"ikev1_n_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, uint32_t phase _U_, uint32_t doi0 _U_, + uint32_t proto0 _U_, int depth _U_) +{ + const struct ikev1_pl_n *p; + struct ikev1_pl_n n; + const u_char *cp; + const u_char *ep2; + uint32_t doi; + uint32_t proto; + static const char *notify_error_str[] = { + NULL, ""INVALID-PAYLOAD-TYPE"", + ""DOI-NOT-SUPPORTED"", ""SITUATION-NOT-SUPPORTED"", + ""INVALID-COOKIE"", ""INVALID-MAJOR-VERSION"", + ""INVALID-MINOR-VERSION"", ""INVALID-EXCHANGE-TYPE"", + ""INVALID-FLAGS"", ""INVALID-MESSAGE-ID"", + ""INVALID-PROTOCOL-ID"", ""INVALID-SPI"", + ""INVALID-TRANSFORM-ID"", ""ATTRIBUTES-NOT-SUPPORTED"", + ""NO-PROPOSAL-CHOSEN"", ""BAD-PROPOSAL-SYNTAX"", + ""PAYLOAD-MALFORMED"", ""INVALID-KEY-INFORMATION"", + ""INVALID-ID-INFORMATION"", ""INVALID-CERT-ENCODING"", + ""INVALID-CERTIFICATE"", ""CERT-TYPE-UNSUPPORTED"", + ""INVALID-CERT-AUTHORITY"", ""INVALID-HASH-INFORMATION"", + ""AUTHENTICATION-FAILED"", ""INVALID-SIGNATURE"", + ""ADDRESS-NOTIFICATION"", ""NOTIFY-SA-LIFETIME"", + ""CERTIFICATE-UNAVAILABLE"", ""UNSUPPORTED-EXCHANGE-TYPE"", + ""UNEQUAL-PAYLOAD-LENGTHS"", + }; + static const char *ipsec_notify_error_str[] = { + ""RESERVED"", + }; + static const char *notify_status_str[] = { + ""CONNECTED"", + }; + static const char *ipsec_notify_status_str[] = { + ""RESPONDER-LIFETIME"", ""REPLAY-STATUS"", + ""INITIAL-CONTACT"", + }; +/* NOTE: these macro must be called with x in proper range */ + +/* 0 - 8191 */ +#define NOTIFY_ERROR_STR(x) \ + STR_OR_ID((x), notify_error_str) + +/* 8192 - 16383 */ +#define IPSEC_NOTIFY_ERROR_STR(x) \ + STR_OR_ID((u_int)((x) - 8192), ipsec_notify_error_str) + +/* 16384 - 24575 */ +#define NOTIFY_STATUS_STR(x) \ + STR_OR_ID((u_int)((x) - 16384), notify_status_str) + +/* 24576 - 32767 */ +#define IPSEC_NOTIFY_STATUS_STR(x) \ + STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str) + + ND_PRINT((ndo,""%s:"", NPSTR(ISAKMP_NPTYPE_N))); + + p = (const struct ikev1_pl_n *)ext; + ND_TCHECK(*p); + UNALIGNED_MEMCPY(&n, ext, sizeof(n)); + doi = ntohl(n.doi); + proto = n.prot_id; + if (doi != 1) { + ND_PRINT((ndo,"" doi=%d"", doi)); + ND_PRINT((ndo,"" proto=%d"", proto)); + if (ntohs(n.type) < 8192) + ND_PRINT((ndo,"" type=%s"", NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 16384) + ND_PRINT((ndo,"" type=%s"", numstr(ntohs(n.type)))); + else if (ntohs(n.type) < 24576) + ND_PRINT((ndo,"" type=%s"", NOTIFY_STATUS_STR(ntohs(n.type)))); + else + ND_PRINT((ndo,"" type=%s"", numstr(ntohs(n.type)))); + if (n.spi_size) { + ND_PRINT((ndo,"" spi="")); + if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) + goto trunc; + } + return (const u_char *)(p + 1) + n.spi_size; + } + + ND_PRINT((ndo,"" doi=ipsec"")); + ND_PRINT((ndo,"" proto=%s"", PROTOIDSTR(proto))); + if (ntohs(n.type) < 8192) + ND_PRINT((ndo,"" type=%s"", NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 16384) + ND_PRINT((ndo,"" type=%s"", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 24576) + ND_PRINT((ndo,"" type=%s"", NOTIFY_STATUS_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 32768) + ND_PRINT((ndo,"" type=%s"", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type)))); + else + ND_PRINT((ndo,"" type=%s"", numstr(ntohs(n.type)))); + if (n.spi_size) { + ND_PRINT((ndo,"" spi="")); + if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) + goto trunc; + } + + cp = (const u_char *)(p + 1) + n.spi_size; + ep2 = (const u_char *)p + item_len; + + if (cp < ep) { + switch (ntohs(n.type)) { + case IPSECDOI_NTYPE_RESPONDER_LIFETIME: + { + const struct attrmap *map = oakley_t_map; + size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); + ND_PRINT((ndo,"" attrs=("")); + while (cp < ep && cp < ep2) { + cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); + if (cp == NULL) { + ND_PRINT((ndo,"")"")); + goto trunc; + } + } + ND_PRINT((ndo,"")"")); + break; + } + case IPSECDOI_NTYPE_REPLAY_STATUS: + ND_PRINT((ndo,"" status=("")); + ND_PRINT((ndo,""replay detection %sabled"", + EXTRACT_32BITS(cp) ? ""en"" : ""dis"")); + ND_PRINT((ndo,"")"")); + break; + default: + /* + * XXX - fill in more types here; see, for example, + * draft-ietf-ipsec-notifymsg-04. + */ + if (ndo->ndo_vflag > 3) { + ND_PRINT((ndo,"" data=("")); + if (!rawprint(ndo, (const uint8_t *)(cp), ep - cp)) + goto trunc; + ND_PRINT((ndo,"")"")); + } else { + if (!ike_show_somedata(ndo, cp, ep)) + goto trunc; + } + break; + } + } + return (const u_char *)ext + item_len; +trunc: + ND_PRINT((ndo,"" [|%s]"", NPSTR(ISAKMP_NPTYPE_N))); + return NULL; +} +",1,"ikev1_n_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len, + const u_char *ep, uint32_t phase _U_, uint32_t doi0 _U_, + uint32_t proto0 _U_, int depth _U_) +{ + const struct ikev1_pl_n *p; + struct ikev1_pl_n n; + const u_char *cp; + const u_char *ep2; + uint32_t doi; + uint32_t proto; + static const char *notify_error_str[] = { + NULL, ""INVALID-PAYLOAD-TYPE"", + ""DOI-NOT-SUPPORTED"", ""SITUATION-NOT-SUPPORTED"", + ""INVALID-COOKIE"", ""INVALID-MAJOR-VERSION"", + ""INVALID-MINOR-VERSION"", ""INVALID-EXCHANGE-TYPE"", + ""INVALID-FLAGS"", ""INVALID-MESSAGE-ID"", + ""INVALID-PROTOCOL-ID"", ""INVALID-SPI"", + ""INVALID-TRANSFORM-ID"", ""ATTRIBUTES-NOT-SUPPORTED"", + ""NO-PROPOSAL-CHOSEN"", ""BAD-PROPOSAL-SYNTAX"", + ""PAYLOAD-MALFORMED"", ""INVALID-KEY-INFORMATION"", + ""INVALID-ID-INFORMATION"", ""INVALID-CERT-ENCODING"", + ""INVALID-CERTIFICATE"", ""CERT-TYPE-UNSUPPORTED"", + ""INVALID-CERT-AUTHORITY"", ""INVALID-HASH-INFORMATION"", + ""AUTHENTICATION-FAILED"", ""INVALID-SIGNATURE"", + ""ADDRESS-NOTIFICATION"", ""NOTIFY-SA-LIFETIME"", + ""CERTIFICATE-UNAVAILABLE"", ""UNSUPPORTED-EXCHANGE-TYPE"", + ""UNEQUAL-PAYLOAD-LENGTHS"", + }; + static const char *ipsec_notify_error_str[] = { + ""RESERVED"", + }; + static const char *notify_status_str[] = { + ""CONNECTED"", + }; + static const char *ipsec_notify_status_str[] = { + ""RESPONDER-LIFETIME"", ""REPLAY-STATUS"", + ""INITIAL-CONTACT"", + }; +/* NOTE: these macro must be called with x in proper range */ + +/* 0 - 8191 */ +#define NOTIFY_ERROR_STR(x) \ + STR_OR_ID((x), notify_error_str) + +/* 8192 - 16383 */ +#define IPSEC_NOTIFY_ERROR_STR(x) \ + STR_OR_ID((u_int)((x) - 8192), ipsec_notify_error_str) + +/* 16384 - 24575 */ +#define NOTIFY_STATUS_STR(x) \ + STR_OR_ID((u_int)((x) - 16384), notify_status_str) + +/* 24576 - 32767 */ +#define IPSEC_NOTIFY_STATUS_STR(x) \ + STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str) + + ND_PRINT((ndo,""%s:"", NPSTR(ISAKMP_NPTYPE_N))); + + p = (const struct ikev1_pl_n *)ext; + ND_TCHECK(*p); + UNALIGNED_MEMCPY(&n, ext, sizeof(n)); + doi = ntohl(n.doi); + proto = n.prot_id; + if (doi != 1) { + ND_PRINT((ndo,"" doi=%d"", doi)); + ND_PRINT((ndo,"" proto=%d"", proto)); + if (ntohs(n.type) < 8192) + ND_PRINT((ndo,"" type=%s"", NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 16384) + ND_PRINT((ndo,"" type=%s"", numstr(ntohs(n.type)))); + else if (ntohs(n.type) < 24576) + ND_PRINT((ndo,"" type=%s"", NOTIFY_STATUS_STR(ntohs(n.type)))); + else + ND_PRINT((ndo,"" type=%s"", numstr(ntohs(n.type)))); + if (n.spi_size) { + ND_PRINT((ndo,"" spi="")); + if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) + goto trunc; + } + return (const u_char *)(p + 1) + n.spi_size; + } + + ND_PRINT((ndo,"" doi=ipsec"")); + ND_PRINT((ndo,"" proto=%s"", PROTOIDSTR(proto))); + if (ntohs(n.type) < 8192) + ND_PRINT((ndo,"" type=%s"", NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 16384) + ND_PRINT((ndo,"" type=%s"", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 24576) + ND_PRINT((ndo,"" type=%s"", NOTIFY_STATUS_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 32768) + ND_PRINT((ndo,"" type=%s"", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type)))); + else + ND_PRINT((ndo,"" type=%s"", numstr(ntohs(n.type)))); + if (n.spi_size) { + ND_PRINT((ndo,"" spi="")); + if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) + goto trunc; + } + + cp = (const u_char *)(p + 1) + n.spi_size; + ep2 = (const u_char *)p + item_len; + + if (cp < ep) { + switch (ntohs(n.type)) { + case IPSECDOI_NTYPE_RESPONDER_LIFETIME: + { + const struct attrmap *map = oakley_t_map; + size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); + ND_PRINT((ndo,"" attrs=("")); + while (cp < ep && cp < ep2) { + cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); + if (cp == NULL) { + ND_PRINT((ndo,"")"")); + goto trunc; + } + } + ND_PRINT((ndo,"")"")); + break; + } + case IPSECDOI_NTYPE_REPLAY_STATUS: + ND_PRINT((ndo,"" status=("")); + ND_TCHECK_32BITS(cp); + ND_PRINT((ndo,""replay detection %sabled"", + EXTRACT_32BITS(cp) ? ""en"" : ""dis"")); + ND_PRINT((ndo,"")"")); + break; + default: + /* + * XXX - fill in more types here; see, for example, + * draft-ietf-ipsec-notifymsg-04. + */ + if (ndo->ndo_vflag > 3) { + ND_PRINT((ndo,"" data=("")); + if (!rawprint(ndo, (const uint8_t *)(cp), ep - cp)) + goto trunc; + ND_PRINT((ndo,"")"")); + } else { + if (!ike_show_somedata(ndo, cp, ep)) + goto trunc; + } + break; + } + } + return (const u_char *)ext + item_len; +trunc: + ND_PRINT((ndo,"" [|%s]"", NPSTR(ISAKMP_NPTYPE_N))); + return NULL; +} +","@@ -1769,6 +1769,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_, + } + case IPSECDOI_NTYPE_REPLAY_STATUS: + ND_PRINT((ndo,"" status=("")); ++ ND_TCHECK_32BITS(cp); + ND_PRINT((ndo,""replay detection %sabled"", + EXTRACT_32BITS(cp) ? ""en"" : ""dis"")); + ND_PRINT((ndo,"")""));",1633,1869,2048 +18495,"xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + int c, l; + xmlChar stop; + xmlChar *ret = NULL; + const xmlChar *cur = NULL; + xmlParserInputPtr input; + + if (RAW == '""') stop = '""'; + else if (RAW == '\'') stop = '\''; + else { + xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_STARTED, NULL); + return(NULL); + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + + /* + * The content of the entity definition is copied in a buffer. + */ + + ctxt->instate = XML_PARSER_ENTITY_VALUE; + input = ctxt->input; + GROW; + NEXT; + c = CUR_CHAR(l); + /* + * NOTE: 4.4.5 Included in Literal + * When a parameter entity reference appears in a literal entity + * value, ... a single or double quote character in the replacement + * text is always treated as a normal data character and will not + * terminate the literal. + * In practice it means we stop the loop only when back at parsing + * the initial entity and the quote is found + */ + while ((IS_CHAR(c)) && ((c != stop) || /* checked */ + (ctxt->input != input))) { + if (len + 5 >= size) { + xmlChar *tmp; + + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + return(NULL); + } + buf = tmp; + } + COPY_BUF(l,buf,len,c); + NEXTL(l); + /* + * Pop-up of finished entities. + */ + while ((RAW == 0) && (ctxt->inputNr > 1)) /* non input consuming */ + xmlPopInput(ctxt); + + GROW; + c = CUR_CHAR(l); + if (c == 0) { + GROW; + c = CUR_CHAR(l); + } + } + buf[len] = 0; + + /* + * Raise problem w.r.t. '&' and '%' being used in non-entities + * reference constructs. Note Charref will be handled in + * xmlStringDecodeEntities() + */ + cur = buf; + while (*cur != 0) { /* non input consuming */ + if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) { + xmlChar *name; + xmlChar tmp = *cur; + + cur++; + name = xmlParseStringName(ctxt, &cur); + if ((name == NULL) || (*cur != ';')) { + xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR, + ""EntityValue: '%c' forbidden except for entities references\n"", + tmp); + } + if ((tmp == '%') && (ctxt->inSubset == 1) && + (ctxt->inputNr == 1)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_PE_INTERNAL, NULL); + } + if (name != NULL) + xmlFree(name); + if (*cur == 0) + break; + } + cur++; + } + + /* + * Then PEReference entities are substituted. + */ + if (c != stop) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL); + xmlFree(buf); + } else { + NEXT; + /* + * NOTE: 4.4.7 Bypassed + * When a general entity reference appears in the EntityValue in + * an entity declaration, it is bypassed and left as is. + * so XML_SUBSTITUTE_REF is not set here. + */ + ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, + 0, 0, 0); + if (orig != NULL) + *orig = buf; + else + xmlFree(buf); + } + return(ret); + } +",1,"xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + int c, l; + xmlChar stop; + xmlChar *ret = NULL; + const xmlChar *cur = NULL; + xmlParserInputPtr input; + + if (RAW == '""') stop = '""'; + else if (RAW == '\'') stop = '\''; + else { + xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_STARTED, NULL); + return(NULL); + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + return(NULL); + } + + /* + * The content of the entity definition is copied in a buffer. + */ + + ctxt->instate = XML_PARSER_ENTITY_VALUE; + input = ctxt->input; + GROW; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return(NULL); + } + NEXT; + c = CUR_CHAR(l); + /* + * NOTE: 4.4.5 Included in Literal + * When a parameter entity reference appears in a literal entity + * value, ... a single or double quote character in the replacement + * text is always treated as a normal data character and will not + * terminate the literal. + * In practice it means we stop the loop only when back at parsing + * the initial entity and the quote is found + */ + while (((IS_CHAR(c)) && ((c != stop) || /* checked */ + (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) { + if (len + 5 >= size) { + xmlChar *tmp; + + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + return(NULL); + } + buf = tmp; + } + COPY_BUF(l,buf,len,c); + NEXTL(l); + /* + * Pop-up of finished entities. + */ + while ((RAW == 0) && (ctxt->inputNr > 1)) /* non input consuming */ + xmlPopInput(ctxt); + + GROW; + c = CUR_CHAR(l); + if (c == 0) { + GROW; + c = CUR_CHAR(l); + } + } + buf[len] = 0; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return(NULL); + } + + /* + * Raise problem w.r.t. '&' and '%' being used in non-entities + * reference constructs. Note Charref will be handled in + * xmlStringDecodeEntities() + */ + cur = buf; + while (*cur != 0) { /* non input consuming */ + if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) { + xmlChar *name; + xmlChar tmp = *cur; + + cur++; + name = xmlParseStringName(ctxt, &cur); + if ((name == NULL) || (*cur != ';')) { + xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR, + ""EntityValue: '%c' forbidden except for entities references\n"", + tmp); + } + if ((tmp == '%') && (ctxt->inSubset == 1) && + (ctxt->inputNr == 1)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_PE_INTERNAL, NULL); + } + if (name != NULL) + xmlFree(name); + if (*cur == 0) + break; + } + cur++; + } + + /* + * Then PEReference entities are substituted. + */ + if (c != stop) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL); + xmlFree(buf); + } else { + NEXT; + /* + * NOTE: 4.4.7 Bypassed + * When a general entity reference appears in the EntityValue in + * an entity declaration, it is bypassed and left as is. + * so XML_SUBSTITUTE_REF is not set here. + */ + ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, + 0, 0, 0); + if (orig != NULL) + *orig = buf; + else + xmlFree(buf); + } + + return(ret); + } +","@@ -2013,6 +2013,8 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) { + ""Pushing input %d : %.30s\n"", ctxt->inputNr+1, input->cur); + } + ret = inputPush(ctxt, input); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + GROW; + return(ret); + } +@@ -2049,6 +2051,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) { + if (count++ > 20) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 16 + (CUR - '0'); +@@ -2080,6 +2084,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) { + if (count++ > 20) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 10 + (CUR - '0'); +@@ -2366,6 +2372,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + NEXT; + if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL)) + entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (entity == NULL) { + + /* +@@ -2428,6 +2436,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + * the amount of data in the buffer. + */ + GROW ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if ((ctxt->input->end - ctxt->input->cur)>=4) { + start[0] = RAW; + start[1] = NXT(1); +@@ -3046,6 +3056,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + * Handler for more complex cases + */ + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + c = CUR_CHAR(l); + if ((ctxt->options & XML_PARSE_OLD10) == 0) { + /* +@@ -3097,6 +3109,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3121,6 +3135,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3214,6 +3230,8 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3294,6 +3312,8 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) { + const xmlChar *ret; + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + + in = ctxt->input->cur; + while (*in != 0 && *in == *cmp) { +@@ -3421,6 +3441,8 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + #endif + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + c = CUR_CHAR(l); + + while (xmlIsNameChar(ctxt, c)) { +@@ -3449,6 +3471,10 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buffer); ++ return(NULL); ++ } + } + if (len + 10 > max) { + xmlChar *tmp; +@@ -3519,6 +3545,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + ctxt->instate = XML_PARSER_ENTITY_VALUE; + input = ctxt->input; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + NEXT; + c = CUR_CHAR(l); + /* +@@ -3530,8 +3560,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + * In practice it means we stop the loop only when back at parsing + * the initial entity and the quote is found + */ +- while ((IS_CHAR(c)) && ((c != stop) || /* checked */ +- (ctxt->input != input))) { ++ while (((IS_CHAR(c)) && ((c != stop) || /* checked */ ++ (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) { + if (len + 5 >= size) { + xmlChar *tmp; + +@@ -3560,6 +3590,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + } + } + buf[len] = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + + /* + * Raise problem w.r.t. '&' and '%' being used in non-entities +@@ -3607,12 +3641,12 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + */ + ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, + 0, 0, 0); +- if (orig != NULL) ++ if (orig != NULL) + *orig = buf; + else + xmlFree(buf); + } +- ++ + return(ret); + } + +@@ -3663,8 +3697,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + * OK loop until we reach one of the ending char or a size limit. + */ + c = CUR_CHAR(l); +- while ((NXT(0) != limit) && /* checked */ +- (IS_CHAR(c)) && (c != '<')) { ++ while (((NXT(0) != limit) && /* checked */ ++ (IS_CHAR(c)) && (c != '<')) && ++ (ctxt->instate != XML_PARSER_EOF)) { + if (c == 0) break; + if (c == '&') { + in_space = 0; +@@ -3799,6 +3834,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + GROW; + c = CUR_CHAR(l); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto error; ++ + if ((in_space) && (normalize)) { + while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } +@@ -3820,6 +3858,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + + mem_error: + xmlErrMemory(ctxt, NULL); ++error: + if (buf != NULL) + xmlFree(buf); + if (rep != NULL) +@@ -3925,6 +3964,10 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); +@@ -4002,6 +4045,10 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + } + NEXT; + cur = CUR; +@@ -4208,6 +4255,8 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) { + } + SHRINK; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + in = ctxt->input->cur; + } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09)); + nbchar = 0; +@@ -4276,6 +4325,8 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + } + NEXTL(l); + cur = CUR_CHAR(l); +@@ -4476,6 +4527,10 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + } + NEXTL(l); + cur = CUR_CHAR(l); +@@ -4626,6 +4681,10 @@ xmlParseComment(xmlParserCtxtPtr ctxt) { + } + SHRINK; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + in = ctxt->input->cur; + if (*in == '-') { + if (in[1] == '-') { +@@ -4644,7 +4703,8 @@ xmlParseComment(xmlParserCtxtPtr ctxt) { + } + if (buf != NULL) + xmlFree(buf); +- ctxt->instate = state; ++ if (ctxt->instate != XML_PARSER_EOF) ++ ctxt->instate = state; + return; + } + if (buf != NULL) +@@ -4862,6 +4922,10 @@ xmlParsePI(xmlParserCtxtPtr ctxt) { + count++; + if (count > 50) { + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + count = 0; + } + COPY_BUF(l,buf,len,cur); +@@ -5211,6 +5275,8 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { + } + } + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + SKIP_BLANKS; + if (RAW != '>') { + xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, +@@ -5602,7 +5668,7 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) { + } + SKIP_BLANKS; + GROW; +- while (RAW != '>') { ++ while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + int type; + int def; +@@ -5751,7 +5817,7 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) { + ret = cur = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA); + if (ret == NULL) return(NULL); + } +- while (RAW == '|') { ++ while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) { + NEXT; + if (elem == NULL) { + ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR); +@@ -5895,7 +5961,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, + } + SKIP_BLANKS; + SHRINK; +- while (RAW != ')') { ++ while ((RAW != ')') && (ctxt->instate != XML_PARSER_EOF)) { + /* + * Each loop we parse one separator and one element. + */ +@@ -6174,6 +6240,8 @@ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, + } + NEXT; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + SKIP_BLANKS; + if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) { + tree = xmlParseElementMixedContentDecl(ctxt, inputid); +@@ -6341,8 +6409,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + ""Entering INCLUDE Conditional Section\n""); + } + +- while ((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') || +- (NXT(2) != '>'))) { ++ while (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') || ++ (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -6410,7 +6478,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + if (ctxt->recovery == 0) ctxt->disableSAX = 1; + ctxt->instate = XML_PARSER_IGNORE; + +- while ((depth >= 0) && (RAW != 0)) { ++ while (((depth >= 0) && (RAW != 0)) && ++ (ctxt->instate != XML_PARSER_EOF)) { + if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) { + depth++; + SKIP(3); +@@ -6681,7 +6750,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, + break; + } + } +- ++ + if (RAW != 0) { + xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL); + } +@@ -7127,6 +7196,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { + xmlEntityPtr ent = NULL; + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + + if (RAW != '&') + return(NULL); +@@ -7172,6 +7243,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { + ent = xmlSAX2GetEntity(ctxt, name); + } + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + /* + * [ WFC: Entity Declared ] + * In a document without any DTD, a document with only an +@@ -7362,6 +7435,10 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) { + ent = xmlSAX2GetEntity(ctxt, name); + } + } ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(name); ++ return(NULL); ++ } + + /* + * [ WFC: Entity Declared ] +@@ -7523,8 +7600,9 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) + */ + if ((ctxt->sax != NULL) && + (ctxt->sax->getParameterEntity != NULL)) +- entity = ctxt->sax->getParameterEntity(ctxt->userData, +- name); ++ entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (entity == NULL) { + /* + * [ WFC: Entity Declared ] +@@ -7657,6 +7735,10 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlBufferFree(buf); ++ return(-1); ++ } + } + NEXTL(l); + c = CUR_CHAR(l); +@@ -7748,8 +7830,11 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { + */ + if ((ctxt->sax != NULL) && + (ctxt->sax->getParameterEntity != NULL)) +- entity = ctxt->sax->getParameterEntity(ctxt->userData, +- name); ++ entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(name); ++ return(NULL); ++ } + if (entity == NULL) { + /* + * [ WFC: Entity Declared ] +@@ -7851,6 +7936,8 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) { + if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) && + (!ctxt->disableSAX)) + ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + + /* + * Is there any internal subset declarations ? +@@ -7890,7 +7977,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) { + * PEReferences. + * Subsequence (markupdecl | PEReference | S)* + */ +- while (RAW != ']') { ++ while ((RAW != ']') && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -8076,9 +8163,9 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) { + SKIP_BLANKS; + GROW; + +- while ((RAW != '>') && ++ while (((RAW != '>') && + ((RAW != '/') || (NXT(1) != '>')) && +- (IS_BYTE_CHAR(RAW))) { ++ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *q = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -8502,6 +8589,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8516,6 +8605,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8536,6 +8627,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8553,6 +8646,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8784,9 +8879,9 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, + GROW; + if (ctxt->input->base != base) goto base_changed; + +- while ((RAW != '>') && ++ while (((RAW != '>') && + ((RAW != '/') || (NXT(1) != '>')) && +- (IS_BYTE_CHAR(RAW))) { ++ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *q = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + int len = -1, alloc = 0; +@@ -8957,6 +9052,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, + failed: + + GROW ++ if (ctxt->instate == XML_PARSER_EOF) ++ break; + if (ctxt->input->base != base) goto base_changed; + if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) + break; +@@ -9194,6 +9291,8 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, + * We should definitely be at the ending ""S? '>'"" part + */ + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + SKIP_BLANKS; + if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) { + xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL); +@@ -9302,6 +9401,10 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { + count++; + if (count > 50) { + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + count = 0; + } + NEXTL(l); +@@ -9550,6 +9653,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { + * Parse the content of the element: + */ + xmlParseContent(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (!IS_BYTE_CHAR(RAW)) { + xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED, + ""Premature end of data in tag %s line %d\n"", +@@ -10065,9 +10170,10 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) { + + void + xmlParseMisc(xmlParserCtxtPtr ctxt) { +- while (((RAW == '<') && (NXT(1) == '?')) || +- (CMP4(CUR_PTR, '<', '!', '-', '-')) || +- IS_BLANK_CH(CUR)) { ++ while ((ctxt->instate != XML_PARSER_EOF) && ++ (((RAW == '<') && (NXT(1) == '?')) || ++ (CMP4(CUR_PTR, '<', '!', '-', '-')) || ++ IS_BLANK_CH(CUR))) { + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParsePI(ctxt); + } else if (IS_BLANK_CH(CUR)) { +@@ -10114,6 +10220,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + */ + if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) + ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) && + ((ctxt->input->end - ctxt->input->cur) >= 4)) { +@@ -10165,6 +10273,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + /* + * The Misc part of the Prolog +@@ -10184,6 +10294,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + xmlParseInternalSubset(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + } + + /* +@@ -10194,6 +10306,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + (!ctxt->disableSAX)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + ctxt->inSubset = 0; + + xmlCleanSpecialAttr(ctxt); +@@ -10334,6 +10448,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + /* + * Doing validity checking on chunk doesn't make sense +@@ -10344,6 +10460,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { + ctxt->depth = 0; + + xmlParseContent(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + if ((RAW == '<') && (NXT(1) == '/')) { + xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL); +@@ -10651,7 +10769,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + } + xmlParseGetLasts(ctxt, &lastlt, &lastgt); + +- while (1) { ++ while (ctxt->instate != XML_PARSER_EOF) { + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(0); + +@@ -10891,6 +11009,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->endElement(ctxt->userData, name); + #endif /* LIBXML_SAX1_ENABLED */ + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + spacePop(ctxt); + if (ctxt->nameNr == 0) { + ctxt->instate = XML_PARSER_EPILOG; +@@ -11072,6 +11192,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, tmp); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + SKIPL(tmp); + ctxt->checkIndex = 0; + } +@@ -11107,6 +11229,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, base); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + SKIPL(base + 3); + ctxt->checkIndex = 0; + ctxt->instate = XML_PARSER_CONTENT; +@@ -11138,6 +11262,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->checkIndex = 0; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && +@@ -11150,6 +11276,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_MISC; + ctxt->checkIndex = 0; + } else if ((cur == '<') && (next == '!') && +@@ -11169,6 +11297,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + #endif + ctxt->inSubset = 1; + xmlParseDocTypeDecl(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + #ifdef DEBUG_PUSH +@@ -11225,6 +11355,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) { + if ((!terminate) && +@@ -11235,6 +11367,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_PROLOG; + } else if ((cur == '<') && (next == '!') && + (avail < 4)) { +@@ -11269,6 +11403,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_EPILOG; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) { +@@ -11280,6 +11416,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_EPILOG; + } else if ((cur == '<') && (next == '!') && + (avail < 4)) { +@@ -11408,13 +11546,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + + found_end_int_subset: + xmlParseInternalSubset(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->inSubset = 2; + if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && + (ctxt->sax->externalSubset != NULL)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); + ctxt->inSubset = 0; + xmlCleanSpecialAttr(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_PROLOG; + ctxt->checkIndex = 0; + #ifdef DEBUG_PUSH +@@ -11537,6 +11679,8 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, + return(XML_ERR_INTERNAL_ERROR); + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(ctxt->errNo); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + if (ctxt->instate == XML_PARSER_START) + xmlDetectSAX2(ctxt); + if ((size > 0) && (chunk != NULL) && (!terminate) && +@@ -11623,6 +11767,8 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, + xmlParseTryOrFinish(ctxt, 0); + else + xmlParseTryOrFinish(ctxt, terminate); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(ctxt->errNo); + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(ctxt->errNo); + +@@ -11816,6 +11962,7 @@ xmlStopParser(xmlParserCtxtPtr ctxt) { + if (ctxt == NULL) + return; + ctxt->instate = XML_PARSER_EOF; ++ ctxt->errNo = XML_ERR_USER_STOP; + ctxt->disableSAX = 1; + if (ctxt->input != NULL) { + ctxt->input->cur = BAD_CAST"""";",903,1139,2048 +18117,"static int cdxl_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *pkt) +{ + CDXLVideoContext *c = avctx->priv_data; + AVFrame * const p = data; + int ret, w, h, encoding, aligned_width, buf_size = pkt->size; + const uint8_t *buf = pkt->data; + + if (buf_size < 32) + return AVERROR_INVALIDDATA; + encoding = buf[1] & 7; + c->format = buf[1] & 0xE0; + w = AV_RB16(&buf[14]); + h = AV_RB16(&buf[16]); + c->bpp = buf[19]; + c->palette_size = AV_RB16(&buf[20]); + c->palette = buf + 32; + c->video = c->palette + c->palette_size; + c->video_size = buf_size - c->palette_size - 32; + + if (c->palette_size > 512) + return AVERROR_INVALIDDATA; + if (buf_size < c->palette_size + 32) + return AVERROR_INVALIDDATA; + if (c->bpp < 1) + return AVERROR_INVALIDDATA; + if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) { + avpriv_request_sample(avctx, ""Pixel format 0x%0x"", c->format); + return AVERROR_PATCHWELCOME; + } + + if ((ret = ff_set_dimensions(avctx, w, h)) < 0) + return ret; + + if (c->format == CHUNKY) + aligned_width = avctx->width; + else + aligned_width = FFALIGN(c->avctx->width, 16); + c->padded_bits = aligned_width - c->avctx->width; + if (c->video_size < aligned_width * avctx->height * (int64_t)c->bpp / 8) + return AVERROR_INVALIDDATA; + if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) { + avctx->pix_fmt = AV_PIX_FMT_PAL8; + } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8)) { + if (c->palette_size != (1 << (c->bpp - 1))) + return AVERROR_INVALIDDATA; + avctx->pix_fmt = AV_PIX_FMT_BGR24; + } else if (!encoding && c->bpp == 24 && c->format == CHUNKY && + !c->palette_size) { + avctx->pix_fmt = AV_PIX_FMT_RGB24; + } else { + avpriv_request_sample(avctx, ""Encoding %d, bpp %d and format 0x%x"", + encoding, c->bpp, c->format); + return AVERROR_PATCHWELCOME; + } + + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) + return ret; + p->pict_type = AV_PICTURE_TYPE_I; + + if (encoding) { + av_fast_padded_malloc(&c->new_video, &c->new_video_size, + h * w + AV_INPUT_BUFFER_PADDING_SIZE); + if (!c->new_video) + return AVERROR(ENOMEM); + if (c->bpp == 8) + cdxl_decode_ham8(c, p); + else + cdxl_decode_ham6(c, p); + } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { + cdxl_decode_rgb(c, p); + } else { + cdxl_decode_raw(c, p); + } + *got_frame = 1; + + return buf_size; +} +",1,"static int cdxl_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *pkt) +{ + CDXLVideoContext *c = avctx->priv_data; + AVFrame * const p = data; + int ret, w, h, encoding, aligned_width, buf_size = pkt->size; + const uint8_t *buf = pkt->data; + + if (buf_size < 32) + return AVERROR_INVALIDDATA; + encoding = buf[1] & 7; + c->format = buf[1] & 0xE0; + w = AV_RB16(&buf[14]); + h = AV_RB16(&buf[16]); + c->bpp = buf[19]; + c->palette_size = AV_RB16(&buf[20]); + c->palette = buf + 32; + c->video = c->palette + c->palette_size; + c->video_size = buf_size - c->palette_size - 32; + + if (c->palette_size > 512) + return AVERROR_INVALIDDATA; + if (buf_size < c->palette_size + 32) + return AVERROR_INVALIDDATA; + if (c->bpp < 1) + return AVERROR_INVALIDDATA; + if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) { + avpriv_request_sample(avctx, ""Pixel format 0x%0x"", c->format); + return AVERROR_PATCHWELCOME; + } + + if ((ret = ff_set_dimensions(avctx, w, h)) < 0) + return ret; + + if (c->format == CHUNKY) + aligned_width = avctx->width; + else + aligned_width = FFALIGN(c->avctx->width, 16); + c->padded_bits = aligned_width - c->avctx->width; + if (c->video_size < aligned_width * avctx->height * (int64_t)c->bpp / 8) + return AVERROR_INVALIDDATA; + if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) { + avctx->pix_fmt = AV_PIX_FMT_PAL8; + } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8) && c->format != CHUNKY) { + if (c->palette_size != (1 << (c->bpp - 1))) + return AVERROR_INVALIDDATA; + avctx->pix_fmt = AV_PIX_FMT_BGR24; + } else if (!encoding && c->bpp == 24 && c->format == CHUNKY && + !c->palette_size) { + avctx->pix_fmt = AV_PIX_FMT_RGB24; + } else { + avpriv_request_sample(avctx, ""Encoding %d, bpp %d and format 0x%x"", + encoding, c->bpp, c->format); + return AVERROR_PATCHWELCOME; + } + + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) + return ret; + p->pict_type = AV_PICTURE_TYPE_I; + + if (encoding) { + av_fast_padded_malloc(&c->new_video, &c->new_video_size, + h * w + AV_INPUT_BUFFER_PADDING_SIZE); + if (!c->new_video) + return AVERROR(ENOMEM); + if (c->bpp == 8) + cdxl_decode_ham8(c, p); + else + cdxl_decode_ham6(c, p); + } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { + cdxl_decode_rgb(c, p); + } else { + cdxl_decode_raw(c, p); + } + *got_frame = 1; + + return buf_size; +} +","@@ -279,7 +279,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, + return AVERROR_INVALIDDATA; + if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) { + avctx->pix_fmt = AV_PIX_FMT_PAL8; +- } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8)) { ++ } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8) && c->format != CHUNKY) { + if (c->palette_size != (1 << (c->bpp - 1))) + return AVERROR_INVALIDDATA; + avctx->pix_fmt = AV_PIX_FMT_BGR24;",844,1080,2048 +18421,"bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, + bool* message_was_ok) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, *message_was_ok) +#if !defined(DISABLE_NACL) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_LaunchNaCl, OnLaunchNaCl) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetReadonlyPnaclFD, + OnGetReadonlyPnaclFd) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_NaClCreateTemporaryFile, + OnNaClCreateTemporaryFile) +#endif + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DnsPrefetch, OnDnsPrefetch) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ResourceTypeStats, + OnResourceTypeStats) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdatedCacheStats, + OnUpdatedCacheStats) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FPS, OnFPS) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_V8HeapStats, OnV8HeapStats) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, + OnOpenChannelToExtension) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToTab, OnOpenChannelToTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ExtensionHostMsg_GetMessageBundle, + OnGetExtensionMessageBundle) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddListener, OnExtensionAddListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveListener, + OnExtensionRemoveListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddLazyListener, + OnExtensionAddLazyListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveLazyListener, + OnExtensionRemoveLazyListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddFilteredListener, + OnExtensionAddFilteredListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveFilteredListener, + OnExtensionRemoveFilteredListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_CloseChannel, OnExtensionCloseChannel) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RequestForIOThread, + OnExtensionRequestForIOThread) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_ShouldUnloadAck, + OnExtensionShouldUnloadAck) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_GenerateUniqueID, + OnExtensionGenerateUniqueID) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_UnloadAck, OnExtensionUnloadAck) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests, + OnExtensionResumeRequests); +#if defined(USE_TCMALLOC) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK, + OnWriteTcmallocHeapProfile) +#endif + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowFileSystem, OnAllowFileSystem) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardRead, + OnCanTriggerClipboardRead) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardWrite, + OnCanTriggerClipboardWrite) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + +#if defined(ENABLE_AUTOMATION) + if ((message.type() == ChromeViewHostMsg_GetCookies::ID || + message.type() == ChromeViewHostMsg_SetCookie::ID) && + AutomationResourceMessageFilter::ShouldFilterCookieMessages( + render_process_id_, message.routing_id())) { + IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, + *message_was_ok) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetCookies, + OnGetCookies) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetCookie, OnSetCookie) + IPC_END_MESSAGE_MAP() + handled = true; + } +#endif + + return handled; +} +",1,"bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, + bool* message_was_ok) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, *message_was_ok) +#if !defined(DISABLE_NACL) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_LaunchNaCl, OnLaunchNaCl) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetReadonlyPnaclFD, + OnGetReadonlyPnaclFd) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_NaClCreateTemporaryFile, + OnNaClCreateTemporaryFile) +#endif + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DnsPrefetch, OnDnsPrefetch) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ResourceTypeStats, + OnResourceTypeStats) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdatedCacheStats, + OnUpdatedCacheStats) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FPS, OnFPS) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_V8HeapStats, OnV8HeapStats) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, + OnOpenChannelToExtension) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToTab, OnOpenChannelToTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ExtensionHostMsg_GetMessageBundle, + OnGetExtensionMessageBundle) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddListener, OnExtensionAddListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveListener, + OnExtensionRemoveListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddLazyListener, + OnExtensionAddLazyListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveLazyListener, + OnExtensionRemoveLazyListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddFilteredListener, + OnExtensionAddFilteredListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveFilteredListener, + OnExtensionRemoveFilteredListener) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_CloseChannel, OnExtensionCloseChannel) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_RequestForIOThread, + OnExtensionRequestForIOThread) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_ShouldUnloadAck, + OnExtensionShouldUnloadAck) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_GenerateUniqueID, + OnExtensionGenerateUniqueID) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_UnloadAck, OnExtensionUnloadAck) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests, + OnExtensionResumeRequests); + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowFileSystem, OnAllowFileSystem) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardRead, + OnCanTriggerClipboardRead) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardWrite, + OnCanTriggerClipboardWrite) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + +#if defined(ENABLE_AUTOMATION) + if ((message.type() == ChromeViewHostMsg_GetCookies::ID || + message.type() == ChromeViewHostMsg_SetCookie::ID) && + AutomationResourceMessageFilter::ShouldFilterCookieMessages( + render_process_id_, message.routing_id())) { + IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, + *message_was_ok) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetCookies, + OnGetCookies) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetCookie, OnSetCookie) + IPC_END_MESSAGE_MAP() + handled = true; + } +#endif + + return handled; +} +","@@ -112,10 +112,6 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, + IPC_MESSAGE_HANDLER(ExtensionHostMsg_UnloadAck, OnExtensionUnloadAck) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests, + OnExtensionResumeRequests); +-#if defined(USE_TCMALLOC) +- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK, +- OnWriteTcmallocHeapProfile) +-#endif + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowFileSystem, OnAllowFileSystem) +@@ -473,15 +469,6 @@ void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) { + render_process_id_, route_id); + } + +-#if defined(USE_TCMALLOC) +-void ChromeRenderMessageFilter::OnWriteTcmallocHeapProfile( +- const FilePath::StringType& filepath, +- const std::string& output) { +- VLOG(0) << ""Writing renderer heap profile dump to: "" << filepath; +- file_util::WriteFile(FilePath(filepath), output.c_str(), output.size()); +-} +-#endif +- + void ChromeRenderMessageFilter::OnAllowDatabase(int render_view_id, + const GURL& origin_url, + const GURL& top_origin_url,",814,1050,2048 +5363,"static void lex_scan_string(lex_t *lex, json_error_t *error) +{ + int c; + const char *p; + char *t; + int i; + + lex->value.string.val = NULL; + lex->token = TOKEN_INVALID; + + c = lex_get_save(lex, error); + + while(c != '""') { + if(c == STREAM_STATE_ERROR) + goto out; + + else if(c == STREAM_STATE_EOF) { + error_set(error, lex, ""premature end of input""); + goto out; + } + + else if(0 <= c && c <= 0x1F) { + /* control character */ + lex_unget_unsave(lex, c); + if(c == '\n') + error_set(error, lex, ""unexpected newline"", c); + else + error_set(error, lex, ""control character 0x%x"", c); + goto out; + } + + else if(c == '\\') { + c = lex_get_save(lex, error); + if(c == 'u') { + c = lex_get_save(lex, error); + for(i = 0; i < 4; i++) { + if(!l_isxdigit(c)) { + error_set(error, lex, ""invalid escape""); + goto out; + } + c = lex_get_save(lex, error); + } + } + else if(c == '""' || c == '\\' || c == '/' || c == 'b' || + c == 'f' || c == 'n' || c == 'r' || c == 't') + c = lex_get_save(lex, error); + else { + error_set(error, lex, ""invalid escape""); + goto out; + } + } + else + c = lex_get_save(lex, error); + } + + /* the actual value is at most of the same length as the source + string, because: + - shortcut escapes (e.g. ""\t"") (length 2) are converted to 1 byte + - a single \uXXXX escape (length 6) is converted to at most 3 bytes + - two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair + are converted to 4 bytes + */ + t = jsonp_malloc(lex->saved_text.length + 1); + if(!t) { + /* this is not very nice, since TOKEN_INVALID is returned */ + goto out; + } + lex->value.string.val = t; + + /* + 1 to skip the "" */ + p = strbuffer_value(&lex->saved_text) + 1; + + while(*p != '""') { + if(*p == '\\') { + p++; + if(*p == 'u') { + size_t length; + int32_t value; + + value = decode_unicode_escape(p); + if(value < 0) { + error_set(error, lex, ""invalid Unicode escape '%.6s'"", p - 1); + goto out; + } + p += 5; + + if(0xD800 <= value && value <= 0xDBFF) { + /* surrogate pair */ + if(*p == '\\' && *(p + 1) == 'u') { + int32_t value2 = decode_unicode_escape(++p); + if(value2 < 0) { + error_set(error, lex, ""invalid Unicode escape '%.6s'"", p - 1); + goto out; + } + p += 5; + + if(0xDC00 <= value2 && value2 <= 0xDFFF) { + /* valid second surrogate */ + value = + ((value - 0xD800) << 10) + + (value2 - 0xDC00) + + 0x10000; + } + else { + /* invalid second surrogate */ + error_set(error, lex, + ""invalid Unicode '\\u%04X\\u%04X'"", + value, value2); + goto out; + } + } + else { + /* no second surrogate */ + error_set(error, lex, ""invalid Unicode '\\u%04X'"", + value); + goto out; + } + } + else if(0xDC00 <= value && value <= 0xDFFF) { + error_set(error, lex, ""invalid Unicode '\\u%04X'"", value); + goto out; + } + + if(utf8_encode(value, t, &length)) + assert(0); + t += length; + } + else { + switch(*p) { + case '""': case '\\': case '/': + *t = *p; break; + case 'b': *t = '\b'; break; + case 'f': *t = '\f'; break; + case 'n': *t = '\n'; break; + case 'r': *t = '\r'; break; + case 't': *t = '\t'; break; + default: assert(0); + } + t++; + p++; + } + } + else + *(t++) = *(p++); + } + *t = '\0'; + lex->value.string.len = t - lex->value.string.val; + lex->token = TOKEN_STRING; + return; + +out: + lex_free_string(lex); +} +",0,"static void lex_scan_string(lex_t *lex, json_error_t *error) +{ + int c; + const char *p; + char *t; + int i; + + lex->value.string.val = NULL; + lex->token = TOKEN_INVALID; + + c = lex_get_save(lex, error); + + while(c != '""') { + if(c == STREAM_STATE_ERROR) + goto out; + + else if(c == STREAM_STATE_EOF) { + error_set(error, lex, ""premature end of input""); + goto out; + } + + else if(0 <= c && c <= 0x1F) { + /* control character */ + lex_unget_unsave(lex, c); + if(c == '\n') + error_set(error, lex, ""unexpected newline"", c); + else + error_set(error, lex, ""control character 0x%x"", c); + goto out; + } + + else if(c == '\\') { + c = lex_get_save(lex, error); + if(c == 'u') { + c = lex_get_save(lex, error); + for(i = 0; i < 4; i++) { + if(!l_isxdigit(c)) { + error_set(error, lex, ""invalid escape""); + goto out; + } + c = lex_get_save(lex, error); + } + } + else if(c == '""' || c == '\\' || c == '/' || c == 'b' || + c == 'f' || c == 'n' || c == 'r' || c == 't') + c = lex_get_save(lex, error); + else { + error_set(error, lex, ""invalid escape""); + goto out; + } + } + else + c = lex_get_save(lex, error); + } + + /* the actual value is at most of the same length as the source + string, because: + - shortcut escapes (e.g. ""\t"") (length 2) are converted to 1 byte + - a single \uXXXX escape (length 6) is converted to at most 3 bytes + - two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair + are converted to 4 bytes + */ + t = jsonp_malloc(lex->saved_text.length + 1); + if(!t) { + /* this is not very nice, since TOKEN_INVALID is returned */ + goto out; + } + lex->value.string.val = t; + + /* + 1 to skip the "" */ + p = strbuffer_value(&lex->saved_text) + 1; + + while(*p != '""') { + if(*p == '\\') { + p++; + if(*p == 'u') { + size_t length; + int32_t value; + + value = decode_unicode_escape(p); + if(value < 0) { + error_set(error, lex, ""invalid Unicode escape '%.6s'"", p - 1); + goto out; + } + p += 5; + + if(0xD800 <= value && value <= 0xDBFF) { + /* surrogate pair */ + if(*p == '\\' && *(p + 1) == 'u') { + int32_t value2 = decode_unicode_escape(++p); + if(value2 < 0) { + error_set(error, lex, ""invalid Unicode escape '%.6s'"", p - 1); + goto out; + } + p += 5; + + if(0xDC00 <= value2 && value2 <= 0xDFFF) { + /* valid second surrogate */ + value = + ((value - 0xD800) << 10) + + (value2 - 0xDC00) + + 0x10000; + } + else { + /* invalid second surrogate */ + error_set(error, lex, + ""invalid Unicode '\\u%04X\\u%04X'"", + value, value2); + goto out; + } + } + else { + /* no second surrogate */ + error_set(error, lex, ""invalid Unicode '\\u%04X'"", + value); + goto out; + } + } + else if(0xDC00 <= value && value <= 0xDFFF) { + error_set(error, lex, ""invalid Unicode '\\u%04X'"", value); + goto out; + } + + if(utf8_encode(value, t, &length)) + assert(0); + t += length; + } + else { + switch(*p) { + case '""': case '\\': case '/': + *t = *p; break; + case 'b': *t = '\b'; break; + case 'f': *t = '\f'; break; + case 'n': *t = '\n'; break; + case 'r': *t = '\r'; break; + case 't': *t = '\t'; break; + default: assert(0); + } + t++; + p++; + } + } + else + *(t++) = *(p++); + } + *t = '\0'; + lex->value.string.len = t - lex->value.string.val; + lex->token = TOKEN_STRING; + return; + +out: + lex_free_string(lex); +} +","@@ -62,6 +62,7 @@ typedef struct { + stream_t stream; + strbuffer_t saved_text; + size_t flags; ++ size_t depth; + int token; + union { + struct { +@@ -803,6 +804,12 @@ static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error) + { + json_t *json; + ++ lex->depth++; ++ if(lex->depth > JSON_PARSER_MAX_DEPTH) { ++ error_set(error, lex, ""maximum parsing depth reached""); ++ return NULL; ++ } ++ + switch(lex->token) { + case TOKEN_STRING: { + const char *value = lex->value.string.val; +@@ -865,13 +872,16 @@ static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error) + if(!json) + return NULL; + ++ lex->depth--; + return json; + } + + static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error) + { + json_t *result; + ++ lex->depth = 0; ++ + lex_scan(lex, error); + if(!(flags & JSON_DECODE_ANY)) { + if(lex->token != '[' && lex->token != '{') {",1135,1371,2048 +18066,"static int tty_open(struct inode *inode, struct file *filp) +{ + struct tty_struct *tty = NULL; + int noctty, retval; + struct tty_driver *driver; + int index; + dev_t device = inode->i_rdev; + unsigned saved_flags = filp->f_flags; + + nonseekable_open(inode, filp); + +retry_open: + noctty = filp->f_flags & O_NOCTTY; + index = -1; + retval = 0; + + mutex_lock(&tty_mutex); + tty_lock(); + + if (device == MKDEV(TTYAUX_MAJOR, 0)) { + tty = get_current_tty(); + if (!tty) { + tty_unlock(); + mutex_unlock(&tty_mutex); + return -ENXIO; + } + driver = tty_driver_kref_get(tty->driver); + index = tty->index; + filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ + /* noctty = 1; */ + /* FIXME: Should we take a driver reference ? */ + tty_kref_put(tty); + goto got_driver; + } +#ifdef CONFIG_VT + if (device == MKDEV(TTY_MAJOR, 0)) { + extern struct tty_driver *console_driver; + driver = tty_driver_kref_get(console_driver); + index = fg_console; + noctty = 1; + goto got_driver; + } +#endif + if (device == MKDEV(TTYAUX_MAJOR, 1)) { + struct tty_driver *console_driver = console_device(&index); + if (console_driver) { + driver = tty_driver_kref_get(console_driver); + if (driver) { + /* Don't let /dev/console block */ + filp->f_flags |= O_NONBLOCK; + noctty = 1; + goto got_driver; + } + } + tty_unlock(); + mutex_unlock(&tty_mutex); + return -ENODEV; + } + + driver = get_tty_driver(device, &index); + if (!driver) { + tty_unlock(); + mutex_unlock(&tty_mutex); + return -ENODEV; + } +got_driver: + if (!tty) { + /* check whether we're reopening an existing tty */ + tty = tty_driver_lookup_tty(driver, inode, index); + + if (IS_ERR(tty)) { + tty_unlock(); + mutex_unlock(&tty_mutex); + return PTR_ERR(tty); + } + } + + if (tty) { + retval = tty_reopen(tty); + if (retval) + tty = ERR_PTR(retval); + } else + tty = tty_init_dev(driver, index, 0); + + mutex_unlock(&tty_mutex); + tty_driver_kref_put(driver); + if (IS_ERR(tty)) { + tty_unlock(); + return PTR_ERR(tty); + } + + retval = tty_add_file(tty, filp); + if (retval) { + tty_unlock(); + tty_release(inode, filp); + return retval; + } + + check_tty_count(tty, ""tty_open""); + if (tty->driver->type == TTY_DRIVER_TYPE_PTY && + tty->driver->subtype == PTY_TYPE_MASTER) + noctty = 1; +#ifdef TTY_DEBUG_HANGUP + printk(KERN_DEBUG ""opening %s..."", tty->name); +#endif + if (tty->ops->open) + retval = tty->ops->open(tty, filp); + else + retval = -ENODEV; + filp->f_flags = saved_flags; + + if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && + !capable(CAP_SYS_ADMIN)) + retval = -EBUSY; + + if (retval) { +#ifdef TTY_DEBUG_HANGUP + printk(KERN_DEBUG ""error %d in opening %s..."", retval, + tty->name); +#endif + tty_unlock(); /* need to call tty_release without BTM */ + tty_release(inode, filp); + if (retval != -ERESTARTSYS) + return retval; + + if (signal_pending(current)) + return retval; + + schedule(); + /* + * Need to reset f_op in case a hangup happened. + */ + tty_lock(); + if (filp->f_op == &hung_up_tty_fops) + filp->f_op = &tty_fops; + tty_unlock(); + goto retry_open; + } + tty_unlock(); + + + mutex_lock(&tty_mutex); + tty_lock(); + spin_lock_irq(¤t->sighand->siglock); + if (!noctty && + current->signal->leader && + !current->signal->tty && + tty->session == NULL) + __proc_set_tty(current, tty); + spin_unlock_irq(¤t->sighand->siglock); + tty_unlock(); + mutex_unlock(&tty_mutex); + return 0; +} +",1,"static int tty_open(struct inode *inode, struct file *filp) +{ + struct tty_struct *tty = NULL; + int noctty, retval; + struct tty_driver *driver; + int index; + dev_t device = inode->i_rdev; + unsigned saved_flags = filp->f_flags; + + nonseekable_open(inode, filp); + +retry_open: + noctty = filp->f_flags & O_NOCTTY; + index = -1; + retval = 0; + + mutex_lock(&tty_mutex); + tty_lock(); + + if (device == MKDEV(TTYAUX_MAJOR, 0)) { + tty = get_current_tty(); + if (!tty) { + tty_unlock(); + mutex_unlock(&tty_mutex); + return -ENXIO; + } + driver = tty_driver_kref_get(tty->driver); + index = tty->index; + filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ + /* noctty = 1; */ + /* FIXME: Should we take a driver reference ? */ + tty_kref_put(tty); + goto got_driver; + } +#ifdef CONFIG_VT + if (device == MKDEV(TTY_MAJOR, 0)) { + extern struct tty_driver *console_driver; + driver = tty_driver_kref_get(console_driver); + index = fg_console; + noctty = 1; + goto got_driver; + } +#endif + if (device == MKDEV(TTYAUX_MAJOR, 1)) { + struct tty_driver *console_driver = console_device(&index); + if (console_driver) { + driver = tty_driver_kref_get(console_driver); + if (driver) { + /* Don't let /dev/console block */ + filp->f_flags |= O_NONBLOCK; + noctty = 1; + goto got_driver; + } + } + tty_unlock(); + mutex_unlock(&tty_mutex); + return -ENODEV; + } + + driver = get_tty_driver(device, &index); + if (!driver) { + tty_unlock(); + mutex_unlock(&tty_mutex); + return -ENODEV; + } +got_driver: + if (!tty) { + /* check whether we're reopening an existing tty */ + tty = tty_driver_lookup_tty(driver, inode, index); + + if (IS_ERR(tty)) { + tty_unlock(); + mutex_unlock(&tty_mutex); + tty_driver_kref_put(driver); + return PTR_ERR(tty); + } + } + + if (tty) { + retval = tty_reopen(tty); + if (retval) + tty = ERR_PTR(retval); + } else + tty = tty_init_dev(driver, index, 0); + + mutex_unlock(&tty_mutex); + tty_driver_kref_put(driver); + if (IS_ERR(tty)) { + tty_unlock(); + return PTR_ERR(tty); + } + + retval = tty_add_file(tty, filp); + if (retval) { + tty_unlock(); + tty_release(inode, filp); + return retval; + } + + check_tty_count(tty, ""tty_open""); + if (tty->driver->type == TTY_DRIVER_TYPE_PTY && + tty->driver->subtype == PTY_TYPE_MASTER) + noctty = 1; +#ifdef TTY_DEBUG_HANGUP + printk(KERN_DEBUG ""opening %s..."", tty->name); +#endif + if (tty->ops->open) + retval = tty->ops->open(tty, filp); + else + retval = -ENODEV; + filp->f_flags = saved_flags; + + if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && + !capable(CAP_SYS_ADMIN)) + retval = -EBUSY; + + if (retval) { +#ifdef TTY_DEBUG_HANGUP + printk(KERN_DEBUG ""error %d in opening %s..."", retval, + tty->name); +#endif + tty_unlock(); /* need to call tty_release without BTM */ + tty_release(inode, filp); + if (retval != -ERESTARTSYS) + return retval; + + if (signal_pending(current)) + return retval; + + schedule(); + /* + * Need to reset f_op in case a hangup happened. + */ + tty_lock(); + if (filp->f_op == &hung_up_tty_fops) + filp->f_op = &tty_fops; + tty_unlock(); + goto retry_open; + } + tty_unlock(); + + + mutex_lock(&tty_mutex); + tty_lock(); + spin_lock_irq(¤t->sighand->siglock); + if (!noctty && + current->signal->leader && + !current->signal->tty && + tty->session == NULL) + __proc_set_tty(current, tty); + spin_unlock_irq(¤t->sighand->siglock); + tty_unlock(); + mutex_unlock(&tty_mutex); + return 0; +} +","@@ -1873,6 +1873,7 @@ static int tty_open(struct inode *inode, struct file *filp) + if (IS_ERR(tty)) { + tty_unlock(); + mutex_unlock(&tty_mutex); ++ tty_driver_kref_put(driver); + return PTR_ERR(tty); + } + }",1033,1269,2048 +17454,"IMPEG2D_ERROR_CODES_T impeg2d_vld_inv_quant_mpeg2( + void *pv_dec, /* Decoder State */ + WORD16 *pi2_out_addr, /*!< Address where decoded symbols will be stored */ + const UWORD8 *pu1_scan, /*!< Scan table to be used */ + UWORD16 u2_intra_flag, /*!< Intra Macroblock or not */ + UWORD16 u2_colr_comp, /*!< 0 - Luma,1 - U comp, 2 - V comp */ + UWORD16 u2_d_picture /*!< D Picture or not */ + ) +{ + UWORD8 *pu1_weighting_matrix; + WORD32 u4_sum_is_even; + dec_state_t *ps_dec = (dec_state_t *)pv_dec; + IMPEG2D_ERROR_CODES_T e_error = (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE; + + WORD16 pi2_coeffs[NUM_COEFFS]; + UWORD8 pi4_pos[NUM_COEFFS]; + WORD32 i4_num_coeffs; + + /* Perform VLD on the stream to get the coefficients and their positions */ + e_error = impeg2d_vld_decode(ps_dec, pi2_coeffs, pu1_scan, pi4_pos, u2_intra_flag, + u2_colr_comp, u2_d_picture, ps_dec->u2_intra_vlc_format, + ps_dec->u2_is_mpeg2, &i4_num_coeffs); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + /* For YUV420 format,Select the weighting matrix according to Table 7.5 */ + pu1_weighting_matrix = (u2_intra_flag == 1) ? ps_dec->au1_intra_quant_matrix: + ps_dec->au1_inter_quant_matrix; + + /*mismatch control for mpeg2*/ + /* Check if the block has only one non-zero coeff which is DC */ + ps_dec->i4_last_value_one = 0; + + IMPEG2D_IQNT_INP_STATISTICS(pi2_out_addr, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + /* Inverse Quantize the Output of VLD */ + PROFILE_DISABLE_INVQUANT_IF0 + + { + /* Clear output matrix */ + PROFILE_DISABLE_MEMSET_RESBUF_IF0 + if (1 != (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + { + ps_dec->pf_memset_16bit_8x8_linear_block (pi2_out_addr); + } + + u4_sum_is_even = impeg2d_inv_quant_mpeg2(pi2_out_addr, pu1_weighting_matrix, + ps_dec->u1_quant_scale, u2_intra_flag, + i4_num_coeffs, pi2_coeffs, + pi4_pos, pu1_scan, + &ps_dec->u2_def_dc_pred[u2_colr_comp], + ps_dec->u2_intra_dc_precision); + + if (0 != pi2_out_addr[0]) + { + /* The first coeff might've become non-zero due to intra_dc_decision + * value. So, check here after inverse quantization. + */ + ps_dec->u4_non_zero_cols |= 0x1; + ps_dec->u4_non_zero_rows |= 0x1; + } + + if (1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + { + ps_dec->i4_last_value_one = 1 - (pi2_out_addr[0] & 1); + } + else + { + /*toggle last bit if sum is even ,else retain it as it is*/ + pi2_out_addr[63] ^= (u4_sum_is_even & 1); + + if (0 != pi2_out_addr[63]) + { + ps_dec->u4_non_zero_cols |= 0x80; + ps_dec->u4_non_zero_rows |= 0x80; + } + } + } + + return e_error; +} +",0,"IMPEG2D_ERROR_CODES_T impeg2d_vld_inv_quant_mpeg2( + void *pv_dec, /* Decoder State */ + WORD16 *pi2_out_addr, /*!< Address where decoded symbols will be stored */ + const UWORD8 *pu1_scan, /*!< Scan table to be used */ + UWORD16 u2_intra_flag, /*!< Intra Macroblock or not */ + UWORD16 u2_colr_comp, /*!< 0 - Luma,1 - U comp, 2 - V comp */ + UWORD16 u2_d_picture /*!< D Picture or not */ + ) +{ + UWORD8 *pu1_weighting_matrix; + WORD32 u4_sum_is_even; + dec_state_t *ps_dec = (dec_state_t *)pv_dec; + IMPEG2D_ERROR_CODES_T e_error = (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE; + + WORD16 pi2_coeffs[NUM_COEFFS]; + UWORD8 pi4_pos[NUM_COEFFS]; + WORD32 i4_num_coeffs; + + /* Perform VLD on the stream to get the coefficients and their positions */ + e_error = impeg2d_vld_decode(ps_dec, pi2_coeffs, pu1_scan, pi4_pos, u2_intra_flag, + u2_colr_comp, u2_d_picture, ps_dec->u2_intra_vlc_format, + ps_dec->u2_is_mpeg2, &i4_num_coeffs); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + /* For YUV420 format,Select the weighting matrix according to Table 7.5 */ + pu1_weighting_matrix = (u2_intra_flag == 1) ? ps_dec->au1_intra_quant_matrix: + ps_dec->au1_inter_quant_matrix; + + /*mismatch control for mpeg2*/ + /* Check if the block has only one non-zero coeff which is DC */ + ps_dec->i4_last_value_one = 0; + + IMPEG2D_IQNT_INP_STATISTICS(pi2_out_addr, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + /* Inverse Quantize the Output of VLD */ + PROFILE_DISABLE_INVQUANT_IF0 + + { + /* Clear output matrix */ + PROFILE_DISABLE_MEMSET_RESBUF_IF0 + if (1 != (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + { + ps_dec->pf_memset_16bit_8x8_linear_block (pi2_out_addr); + } + + u4_sum_is_even = impeg2d_inv_quant_mpeg2(pi2_out_addr, pu1_weighting_matrix, + ps_dec->u1_quant_scale, u2_intra_flag, + i4_num_coeffs, pi2_coeffs, + pi4_pos, pu1_scan, + &ps_dec->u2_def_dc_pred[u2_colr_comp], + ps_dec->u2_intra_dc_precision); + + if (0 != pi2_out_addr[0]) + { + /* The first coeff might've become non-zero due to intra_dc_decision + * value. So, check here after inverse quantization. + */ + ps_dec->u4_non_zero_cols |= 0x1; + ps_dec->u4_non_zero_rows |= 0x1; + } + + if (1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + { + ps_dec->i4_last_value_one = 1 - (pi2_out_addr[0] & 1); + } + else + { + /*toggle last bit if sum is even ,else retain it as it is*/ + pi2_out_addr[63] ^= (u4_sum_is_even & 1); + + if (0 != pi2_out_addr[63]) + { + ps_dec->u4_non_zero_cols |= 0x80; + ps_dec->u4_non_zero_rows |= 0x80; + } + } + } + + return e_error; +} +","@@ -789,13 +789,13 @@ + + u4_nz_cols |= 1 << (u4_pos & 0x7); + u4_nz_rows |= 1 << (u4_pos >> 0x3); + ++ if (u4_numCoeffs > 64) ++ { ++ return IMPEG2D_MB_TEX_DECODE_ERR; ++ } + + } + IBITS_GET(u4_buf,u4_buf_nxt,u4_offset,u4_bits,pu4_buf_aligned,u4_sym_len) +- if (u4_numCoeffs > 64) +- { +- return IMPEG2D_MB_TEX_DECODE_ERR; +- } + } + else + { +@@ -957,10 +957,11 @@ + + + u4_nz_cols |= 1 << (u4_pos & 0x7); + u4_nz_rows |= 1 << (u4_pos >> 0x3); +- } +- if (u4_numCoeffs > 64) +- { +- return IMPEG2D_MB_TEX_DECODE_ERR; ++ if (u4_numCoeffs > 64) ++ { ++ return IMPEG2D_MB_TEX_DECODE_ERR; ++ } ++ + } + + IBITS_GET(u4_buf,u4_buf_nxt,u4_offset,u4_bits,pu4_buf_aligned,u4_sym_len) +",865,1101,2048 +6556,"nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, + struct iattr *iattr, struct nfs4_acl **acl, + struct xdr_netobj *label, int *umask) +{ + int expected_len, len = 0; + u32 dummy32; + char *buf; + + DECODE_HEAD; + iattr->ia_valid = 0; + if ((status = nfsd4_decode_bitmap(argp, bmval))) + return status; + + if (bmval[0] & ~NFSD_WRITEABLE_ATTRS_WORD0 + || bmval[1] & ~NFSD_WRITEABLE_ATTRS_WORD1 + || bmval[2] & ~NFSD_WRITEABLE_ATTRS_WORD2) { + if (nfsd_attrs_supported(argp->minorversion, bmval)) + return nfserr_inval; + return nfserr_attrnotsupp; + } + + READ_BUF(4); + expected_len = be32_to_cpup(p++); + + if (bmval[0] & FATTR4_WORD0_SIZE) { + READ_BUF(8); + len += 8; + p = xdr_decode_hyper(p, &iattr->ia_size); + iattr->ia_valid |= ATTR_SIZE; + } + if (bmval[0] & FATTR4_WORD0_ACL) { + u32 nace; + struct nfs4_ace *ace; + + READ_BUF(4); len += 4; + nace = be32_to_cpup(p++); + + if (nace > NFS4_ACL_MAX) + return nfserr_fbig; + + *acl = svcxdr_tmpalloc(argp, nfs4_acl_bytes(nace)); + if (*acl == NULL) + return nfserr_jukebox; + + (*acl)->naces = nace; + for (ace = (*acl)->aces; ace < (*acl)->aces + nace; ace++) { + READ_BUF(16); len += 16; + ace->type = be32_to_cpup(p++); + ace->flag = be32_to_cpup(p++); + ace->access_mask = be32_to_cpup(p++); + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + len += XDR_QUADLEN(dummy32) << 2; + READMEM(buf, dummy32); + ace->whotype = nfs4_acl_get_whotype(buf, dummy32); + status = nfs_ok; + if (ace->whotype != NFS4_ACL_WHO_NAMED) + ; + else if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) + status = nfsd_map_name_to_gid(argp->rqstp, + buf, dummy32, &ace->who_gid); + else + status = nfsd_map_name_to_uid(argp->rqstp, + buf, dummy32, &ace->who_uid); + if (status) + return status; + } + } else + *acl = NULL; + if (bmval[1] & FATTR4_WORD1_MODE) { + READ_BUF(4); + len += 4; + iattr->ia_mode = be32_to_cpup(p++); + iattr->ia_mode &= (S_IFMT | S_IALLUGO); + iattr->ia_valid |= ATTR_MODE; + } + if (bmval[1] & FATTR4_WORD1_OWNER) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + len += (XDR_QUADLEN(dummy32) << 2); + READMEM(buf, dummy32); + if ((status = nfsd_map_name_to_uid(argp->rqstp, buf, dummy32, &iattr->ia_uid))) + return status; + iattr->ia_valid |= ATTR_UID; + } + if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + len += (XDR_QUADLEN(dummy32) << 2); + READMEM(buf, dummy32); + if ((status = nfsd_map_name_to_gid(argp->rqstp, buf, dummy32, &iattr->ia_gid))) + return status; + iattr->ia_valid |= ATTR_GID; + } + if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + switch (dummy32) { + case NFS4_SET_TO_CLIENT_TIME: + len += 12; + status = nfsd4_decode_time(argp, &iattr->ia_atime); + if (status) + return status; + iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); + break; + case NFS4_SET_TO_SERVER_TIME: + iattr->ia_valid |= ATTR_ATIME; + break; + default: + goto xdr_error; + } + } + if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + switch (dummy32) { + case NFS4_SET_TO_CLIENT_TIME: + len += 12; + status = nfsd4_decode_time(argp, &iattr->ia_mtime); + if (status) + return status; + iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET); + break; + case NFS4_SET_TO_SERVER_TIME: + iattr->ia_valid |= ATTR_MTIME; + break; + default: + goto xdr_error; + } + } + + label->len = 0; +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL + if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); /* lfs: we don't use it */ + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); /* pi: we don't use it either */ + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + if (dummy32 > NFS4_MAXLABELLEN) + return nfserr_badlabel; + len += (XDR_QUADLEN(dummy32) << 2); + READMEM(buf, dummy32); + label->len = dummy32; + label->data = svcxdr_dupstr(argp, buf, dummy32); + if (!label->data) + return nfserr_jukebox; + } +#endif + if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { + if (!umask) + goto xdr_error; + READ_BUF(8); + len += 8; + dummy32 = be32_to_cpup(p++); + iattr->ia_mode = dummy32 & (S_IFMT | S_IALLUGO); + dummy32 = be32_to_cpup(p++); + *umask = dummy32 & S_IRWXUGO; + iattr->ia_valid |= ATTR_MODE; + } + if (len != expected_len) + goto xdr_error; + + DECODE_TAIL; +} +",0,"nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, + struct iattr *iattr, struct nfs4_acl **acl, + struct xdr_netobj *label, int *umask) +{ + int expected_len, len = 0; + u32 dummy32; + char *buf; + + DECODE_HEAD; + iattr->ia_valid = 0; + if ((status = nfsd4_decode_bitmap(argp, bmval))) + return status; + + if (bmval[0] & ~NFSD_WRITEABLE_ATTRS_WORD0 + || bmval[1] & ~NFSD_WRITEABLE_ATTRS_WORD1 + || bmval[2] & ~NFSD_WRITEABLE_ATTRS_WORD2) { + if (nfsd_attrs_supported(argp->minorversion, bmval)) + return nfserr_inval; + return nfserr_attrnotsupp; + } + + READ_BUF(4); + expected_len = be32_to_cpup(p++); + + if (bmval[0] & FATTR4_WORD0_SIZE) { + READ_BUF(8); + len += 8; + p = xdr_decode_hyper(p, &iattr->ia_size); + iattr->ia_valid |= ATTR_SIZE; + } + if (bmval[0] & FATTR4_WORD0_ACL) { + u32 nace; + struct nfs4_ace *ace; + + READ_BUF(4); len += 4; + nace = be32_to_cpup(p++); + + if (nace > NFS4_ACL_MAX) + return nfserr_fbig; + + *acl = svcxdr_tmpalloc(argp, nfs4_acl_bytes(nace)); + if (*acl == NULL) + return nfserr_jukebox; + + (*acl)->naces = nace; + for (ace = (*acl)->aces; ace < (*acl)->aces + nace; ace++) { + READ_BUF(16); len += 16; + ace->type = be32_to_cpup(p++); + ace->flag = be32_to_cpup(p++); + ace->access_mask = be32_to_cpup(p++); + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + len += XDR_QUADLEN(dummy32) << 2; + READMEM(buf, dummy32); + ace->whotype = nfs4_acl_get_whotype(buf, dummy32); + status = nfs_ok; + if (ace->whotype != NFS4_ACL_WHO_NAMED) + ; + else if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) + status = nfsd_map_name_to_gid(argp->rqstp, + buf, dummy32, &ace->who_gid); + else + status = nfsd_map_name_to_uid(argp->rqstp, + buf, dummy32, &ace->who_uid); + if (status) + return status; + } + } else + *acl = NULL; + if (bmval[1] & FATTR4_WORD1_MODE) { + READ_BUF(4); + len += 4; + iattr->ia_mode = be32_to_cpup(p++); + iattr->ia_mode &= (S_IFMT | S_IALLUGO); + iattr->ia_valid |= ATTR_MODE; + } + if (bmval[1] & FATTR4_WORD1_OWNER) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + len += (XDR_QUADLEN(dummy32) << 2); + READMEM(buf, dummy32); + if ((status = nfsd_map_name_to_uid(argp->rqstp, buf, dummy32, &iattr->ia_uid))) + return status; + iattr->ia_valid |= ATTR_UID; + } + if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + len += (XDR_QUADLEN(dummy32) << 2); + READMEM(buf, dummy32); + if ((status = nfsd_map_name_to_gid(argp->rqstp, buf, dummy32, &iattr->ia_gid))) + return status; + iattr->ia_valid |= ATTR_GID; + } + if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + switch (dummy32) { + case NFS4_SET_TO_CLIENT_TIME: + len += 12; + status = nfsd4_decode_time(argp, &iattr->ia_atime); + if (status) + return status; + iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); + break; + case NFS4_SET_TO_SERVER_TIME: + iattr->ia_valid |= ATTR_ATIME; + break; + default: + goto xdr_error; + } + } + if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + switch (dummy32) { + case NFS4_SET_TO_CLIENT_TIME: + len += 12; + status = nfsd4_decode_time(argp, &iattr->ia_mtime); + if (status) + return status; + iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET); + break; + case NFS4_SET_TO_SERVER_TIME: + iattr->ia_valid |= ATTR_MTIME; + break; + default: + goto xdr_error; + } + } + + label->len = 0; +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL + if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); /* lfs: we don't use it */ + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); /* pi: we don't use it either */ + READ_BUF(4); + len += 4; + dummy32 = be32_to_cpup(p++); + READ_BUF(dummy32); + if (dummy32 > NFS4_MAXLABELLEN) + return nfserr_badlabel; + len += (XDR_QUADLEN(dummy32) << 2); + READMEM(buf, dummy32); + label->len = dummy32; + label->data = svcxdr_dupstr(argp, buf, dummy32); + if (!label->data) + return nfserr_jukebox; + } +#endif + if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { + if (!umask) + goto xdr_error; + READ_BUF(8); + len += 8; + dummy32 = be32_to_cpup(p++); + iattr->ia_mode = dummy32 & (S_IFMT | S_IALLUGO); + dummy32 = be32_to_cpup(p++); + *umask = dummy32 & S_IRWXUGO; + iattr->ia_valid |= ATTR_MODE; + } + if (len != expected_len) + goto xdr_error; + + DECODE_TAIL; +} +","@@ -2831,9 +2831,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, + } + #endif /* CONFIG_NFSD_PNFS */ + if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { +- status = nfsd4_encode_bitmap(xdr, NFSD_SUPPATTR_EXCLCREAT_WORD0, +- NFSD_SUPPATTR_EXCLCREAT_WORD1, +- NFSD_SUPPATTR_EXCLCREAT_WORD2); ++ u32 supp[3]; ++ ++ memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp)); ++ supp[0] &= NFSD_SUPPATTR_EXCLCREAT_WORD0; ++ supp[1] &= NFSD_SUPPATTR_EXCLCREAT_WORD1; ++ supp[2] &= NFSD_SUPPATTR_EXCLCREAT_WORD2; ++ ++ status = nfsd4_encode_bitmap(xdr, supp[0], supp[1], supp[2]); + if (status) + goto out; + } +@@ -4119,8 +4124,7 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, + struct nfsd4_getdeviceinfo *gdev) + { + struct xdr_stream *xdr = &resp->xdr; +- const struct nfsd4_layout_ops *ops = +- nfsd4_layout_ops[gdev->gd_layout_type]; ++ const struct nfsd4_layout_ops *ops; + u32 starting_len = xdr->buf->len, needed_len; + __be32 *p; + +@@ -4137,6 +4141,7 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, + + /* If maxcount is 0 then just update notifications */ + if (gdev->gd_maxcount != 0) { ++ ops = nfsd4_layout_ops[gdev->gd_layout_type]; + nfserr = ops->encode_getdeviceinfo(xdr, gdev); + if (nfserr) { + /* +@@ -4189,8 +4194,7 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, + struct nfsd4_layoutget *lgp) + { + struct xdr_stream *xdr = &resp->xdr; +- const struct nfsd4_layout_ops *ops = +- nfsd4_layout_ops[lgp->lg_layout_type]; ++ const struct nfsd4_layout_ops *ops; + __be32 *p; + + dprintk(""%s: err %d\n"", __func__, nfserr); +@@ -4213,6 +4217,7 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, + *p++ = cpu_to_be32(lgp->lg_seg.iomode); + *p++ = cpu_to_be32(lgp->lg_layout_type); + ++ ops = nfsd4_layout_ops[lgp->lg_layout_type]; + nfserr = ops->encode_layoutget(xdr, lgp); + out: + kfree(lgp->lg_content);",1676,1912,2048 +16815,"void AutofillManager::FillOrPreviewDataModelForm( + AutofillDriver::RendererFormDataAction action, + int query_id, + const FormData& form, + const FormFieldData& field, + const AutofillDataModel& data_model, + bool is_credit_card, + const base::string16& cvc, + FormStructure* form_structure, + AutofillField* autofill_field, + bool is_refill) { + DCHECK(form_structure); + DCHECK(autofill_field); + + FormData result = form; + + if (base::FeatureList::IsEnabled(kAutofillRationalizeFieldTypePredictions)) { + form_structure->RationalizePhoneNumbersInSection(autofill_field->section); + } + + DCHECK_EQ(form_structure->field_count(), form.fields.size()); + + FillingContext* filling_context = nullptr; + auto itr = + filling_contexts_map_.find(form_structure->GetIdentifierForRefill()); + if (itr != filling_contexts_map_.end()) + filling_context = itr->second.get(); + bool could_attempt_refill = + base::FeatureList::IsEnabled(features::kAutofillDynamicForms) && + filling_context != nullptr && !filling_context->attempted_refill && + !is_refill && !is_credit_card; + + for (size_t i = 0; i < form_structure->field_count(); ++i) { + if (form_structure->field(i)->section != autofill_field->section) + continue; + + if (form_structure->field(i)->only_fill_when_focused() && + !form_structure->field(i)->SameFieldAs(field)) { + continue; + } + + DCHECK(form_structure->field(i)->SameFieldAs(result.fields[i])); + + AutofillField* cached_field = form_structure->field(i); + FieldTypeGroup field_group_type = cached_field->Type().group(); + + if (!cached_field->IsVisible()) { + bool skip = result.fields[i].form_control_type != ""select-one""; + form_interactions_ukm_logger_->LogHiddenRepresentationalFieldSkipDecision( + *form_structure, *cached_field, skip); + if (skip) + continue; + } + + if (result.fields[i].is_autofilled && !cached_field->SameFieldAs(field) && + !is_refill) { + continue; + } + + if (field_group_type == NO_GROUP) + continue; + + if (is_refill && + !base::ContainsKey(filling_context->type_groups_originally_filled, + field_group_type)) { + continue; + } + + if (IsCreditCardExpirationType(cached_field->Type().GetStorableType()) && + static_cast(&data_model) + ->IsExpired(AutofillClock::Now())) { + continue; + } + + if (could_attempt_refill) + filling_context->type_groups_originally_filled.insert(field_group_type); + + bool should_notify = !is_credit_card && + (result.fields[i].SameFieldAs(field) || + result.fields[i].form_control_type == ""select-one"" || + result.fields[i].value.empty()); + + FillFieldWithValue(cached_field, data_model, &result.fields[i], + should_notify, cvc); + if (result.fields[i].is_autofilled) + result.fields[i].section = form_structure->field(i)->section; + + if (!cached_field->IsVisible() && result.fields[i].is_autofilled) { + AutofillMetrics::LogHiddenOrPresentationalSelectFieldsFilled(); + } + } + + autofilled_form_signatures_.push_front(form_structure->FormSignatureAsStr()); + if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) + autofilled_form_signatures_.pop_back(); + + if (action == AutofillDriver::FORM_DATA_ACTION_FILL && !is_refill) + personal_data_->RecordUseOf(data_model); + + driver()->SendFormDataToRenderer(query_id, action, result); +} +",0,"void AutofillManager::FillOrPreviewDataModelForm( + AutofillDriver::RendererFormDataAction action, + int query_id, + const FormData& form, + const FormFieldData& field, + const AutofillDataModel& data_model, + bool is_credit_card, + const base::string16& cvc, + FormStructure* form_structure, + AutofillField* autofill_field, + bool is_refill) { + DCHECK(form_structure); + DCHECK(autofill_field); + + FormData result = form; + + if (base::FeatureList::IsEnabled(kAutofillRationalizeFieldTypePredictions)) { + form_structure->RationalizePhoneNumbersInSection(autofill_field->section); + } + + DCHECK_EQ(form_structure->field_count(), form.fields.size()); + + FillingContext* filling_context = nullptr; + auto itr = + filling_contexts_map_.find(form_structure->GetIdentifierForRefill()); + if (itr != filling_contexts_map_.end()) + filling_context = itr->second.get(); + bool could_attempt_refill = + base::FeatureList::IsEnabled(features::kAutofillDynamicForms) && + filling_context != nullptr && !filling_context->attempted_refill && + !is_refill && !is_credit_card; + + for (size_t i = 0; i < form_structure->field_count(); ++i) { + if (form_structure->field(i)->section != autofill_field->section) + continue; + + if (form_structure->field(i)->only_fill_when_focused() && + !form_structure->field(i)->SameFieldAs(field)) { + continue; + } + + DCHECK(form_structure->field(i)->SameFieldAs(result.fields[i])); + + AutofillField* cached_field = form_structure->field(i); + FieldTypeGroup field_group_type = cached_field->Type().group(); + + if (!cached_field->IsVisible()) { + bool skip = result.fields[i].form_control_type != ""select-one""; + form_interactions_ukm_logger_->LogHiddenRepresentationalFieldSkipDecision( + *form_structure, *cached_field, skip); + if (skip) + continue; + } + + if (result.fields[i].is_autofilled && !cached_field->SameFieldAs(field) && + !is_refill) { + continue; + } + + if (field_group_type == NO_GROUP) + continue; + + if (is_refill && + !base::ContainsKey(filling_context->type_groups_originally_filled, + field_group_type)) { + continue; + } + + if (IsCreditCardExpirationType(cached_field->Type().GetStorableType()) && + static_cast(&data_model) + ->IsExpired(AutofillClock::Now())) { + continue; + } + + if (could_attempt_refill) + filling_context->type_groups_originally_filled.insert(field_group_type); + + bool should_notify = !is_credit_card && + (result.fields[i].SameFieldAs(field) || + result.fields[i].form_control_type == ""select-one"" || + result.fields[i].value.empty()); + + FillFieldWithValue(cached_field, data_model, &result.fields[i], + should_notify, cvc); + if (result.fields[i].is_autofilled) + result.fields[i].section = form_structure->field(i)->section; + + if (!cached_field->IsVisible() && result.fields[i].is_autofilled) { + AutofillMetrics::LogHiddenOrPresentationalSelectFieldsFilled(); + } + } + + autofilled_form_signatures_.push_front(form_structure->FormSignatureAsStr()); + if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) + autofilled_form_signatures_.pop_back(); + + if (action == AutofillDriver::FORM_DATA_ACTION_FILL && !is_refill) + personal_data_->RecordUseOf(data_model); + + driver()->SendFormDataToRenderer(query_id, action, result); +} +","@@ -96,23 +96,6 @@ const size_t kWaitTimeForDynamicFormsMs = 200; + // The time limit, in ms, between a fill and when a refill can happen. + const int kLimitBeforeRefillMs = 1000; + +-// Precondition: |form_structure| and |form| should correspond to the same +-// logical form. Returns true if any field in the given |section| within |form| +-// is auto-filled. +-bool SectionHasAutofilledField(const FormStructure& form_structure, +- const FormData& form, +- const std::string& section) { +- DCHECK_EQ(form_structure.field_count(), form.fields.size()); +- for (size_t i = 0; i < form_structure.field_count(); ++i) { +- if (form_structure.field(i)->section == section && +- form.fields[i].is_autofilled) { +- return true; +- } +- } +- +- return false; +-} +- + // Returns the credit card field |value| trimmed from whitespace and with stop + // characters removed. + base::string16 SanitizeCreditCardFieldValue(const base::string16& value) { +@@ -562,8 +545,7 @@ void AutofillManager::OnQueryFormFieldAutofillImpl( + // suggestions available. + // TODO(mathp): Differentiate between number of suggestions available + // (current metric) and number shown to the user. +- if (!has_logged_address_suggestions_count_ && +- !context.section_has_autofilled_field) { ++ if (!has_logged_address_suggestions_count_) { + AutofillMetrics::LogAddressSuggestionsCount(suggestions.size()); + has_logged_address_suggestions_count_ = true; + } +@@ -2079,27 +2061,6 @@ void AutofillManager::GetAvailableSuggestions( + warning_suggestion.frontend_id = + POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE; + suggestions->assign(1, warning_suggestion); +- } else { +- context->section_has_autofilled_field = SectionHasAutofilledField( +- *context->form_structure, form, context->focused_field->section); +- if (context->section_has_autofilled_field) { +- // If the relevant section has auto-filled fields and the renderer is +- // querying for suggestions, then for some fields, the user is editing +- // the value of a field. In this case, mimic autocomplete: don't +- // display labels or icons, as that information is redundant. +- // Moreover, filter out duplicate suggestions. +- std::set seen_values; +- for (auto iter = suggestions->begin(); iter != suggestions->end();) { +- if (!seen_values.insert(iter->value).second) { +- // If we've seen this suggestion value before, remove it. +- iter = suggestions->erase(iter); +- } else { +- iter->label.clear(); +- iter->icon.clear(); +- ++iter; +- } +- } +- } + } + } + ",828,1064,2048 +18622,"bool ResourceLoader::WillFollowRedirect( + const WebURL& new_url, + const WebURL& new_site_for_cookies, + const WebString& new_referrer, + WebReferrerPolicy new_referrer_policy, + const WebString& new_method, + const WebURLResponse& passed_redirect_response, + bool& report_raw_headers) { + DCHECK(!passed_redirect_response.IsNull()); + + if (is_cache_aware_loading_activated_) { + HandleError( + ResourceError::CacheMissError(resource_->LastResourceRequest().Url())); + return false; + } + + const ResourceRequest& last_request = resource_->LastResourceRequest(); + ResourceRequest new_request(new_url); + new_request.SetSiteForCookies(new_site_for_cookies); + new_request.SetDownloadToFile(last_request.DownloadToFile()); + new_request.SetUseStreamOnResponse(last_request.UseStreamOnResponse()); + new_request.SetRequestContext(last_request.GetRequestContext()); + new_request.SetFrameType(last_request.GetFrameType()); + new_request.SetServiceWorkerMode( + passed_redirect_response.WasFetchedViaServiceWorker() + ? WebURLRequest::ServiceWorkerMode::kAll + : WebURLRequest::ServiceWorkerMode::kNone); + new_request.SetShouldResetAppCache(last_request.ShouldResetAppCache()); + new_request.SetFetchRequestMode(last_request.GetFetchRequestMode()); + new_request.SetFetchCredentialsMode(last_request.GetFetchCredentialsMode()); + new_request.SetKeepalive(last_request.GetKeepalive()); + String referrer = + new_referrer.IsEmpty() ? Referrer::NoReferrer() : String(new_referrer); + new_request.SetHTTPReferrer( + Referrer(referrer, static_cast(new_referrer_policy))); + new_request.SetPriority(last_request.Priority()); + new_request.SetHTTPMethod(new_method); + if (new_request.HttpMethod() == last_request.HttpMethod()) + new_request.SetHTTPBody(last_request.HttpBody()); + new_request.SetCheckForBrowserSideNavigation( + last_request.CheckForBrowserSideNavigation()); + + Resource::Type resource_type = resource_->GetType(); + + const ResourceRequest& initial_request = resource_->GetResourceRequest(); + WebURLRequest::RequestContext request_context = + initial_request.GetRequestContext(); + WebURLRequest::FrameType frame_type = initial_request.GetFrameType(); + WebURLRequest::FetchRequestMode fetch_request_mode = + initial_request.GetFetchRequestMode(); + WebURLRequest::FetchCredentialsMode fetch_credentials_mode = + initial_request.GetFetchCredentialsMode(); + + const ResourceLoaderOptions& options = resource_->Options(); + + const ResourceResponse& redirect_response( + passed_redirect_response.ToResourceResponse()); + + new_request.SetRedirectStatus( + ResourceRequest::RedirectStatus::kFollowedRedirect); + + if (!IsManualRedirectFetchRequest(initial_request)) { + bool unused_preload = resource_->IsUnusedPreload(); + + SecurityViolationReportingPolicy reporting_policy = + unused_preload ? SecurityViolationReportingPolicy::kSuppressReporting + : SecurityViolationReportingPolicy::kReport; + + Context().CheckCSPForRequest( + request_context, new_url, options, reporting_policy, + ResourceRequest::RedirectStatus::kFollowedRedirect); + + ResourceRequestBlockedReason blocked_reason = Context().CanRequest( + resource_type, new_request, new_url, options, reporting_policy, + FetchParameters::kUseDefaultOriginRestrictionForType, + ResourceRequest::RedirectStatus::kFollowedRedirect); + if (blocked_reason != ResourceRequestBlockedReason::kNone) { + CancelForRedirectAccessCheckError(new_url, blocked_reason); + return false; + } + + if (options.cors_handling_by_resource_fetcher == + kEnableCORSHandlingByResourceFetcher && + fetch_request_mode == WebURLRequest::kFetchRequestModeCORS) { + RefPtr source_origin = options.security_origin; + if (!source_origin.get()) + source_origin = Context().GetSecurityOrigin(); + WebSecurityOrigin source_web_origin(source_origin.get()); + WrappedResourceRequest new_request_wrapper(new_request); + WebString cors_error_msg; + if (!WebCORS::HandleRedirect( + source_web_origin, new_request_wrapper, redirect_response.Url(), + redirect_response.HttpStatusCode(), + redirect_response.HttpHeaderFields(), fetch_credentials_mode, + resource_->MutableOptions(), cors_error_msg)) { + resource_->SetCORSStatus(CORSStatus::kFailed); + + if (!unused_preload) { + Context().AddErrorConsoleMessage(cors_error_msg, + FetchContext::kJSSource); + } + + CancelForRedirectAccessCheckError(new_url, + ResourceRequestBlockedReason::kOther); + return false; + } + + source_origin = source_web_origin; + } + if (resource_type == Resource::kImage && + fetcher_->ShouldDeferImageLoad(new_url)) { + CancelForRedirectAccessCheckError(new_url, + ResourceRequestBlockedReason::kOther); + return false; + } + } + + bool cross_origin = + !SecurityOrigin::AreSameSchemeHostPort(redirect_response.Url(), new_url); + fetcher_->RecordResourceTimingOnRedirect(resource_.Get(), redirect_response, + cross_origin); + + if (options.cors_handling_by_resource_fetcher == + kEnableCORSHandlingByResourceFetcher && + fetch_request_mode == WebURLRequest::kFetchRequestModeCORS) { + bool allow_stored_credentials = false; + switch (fetch_credentials_mode) { + case WebURLRequest::kFetchCredentialsModeOmit: + break; + case WebURLRequest::kFetchCredentialsModeSameOrigin: + allow_stored_credentials = !options.cors_flag; + break; + case WebURLRequest::kFetchCredentialsModeInclude: + case WebURLRequest::kFetchCredentialsModePassword: + allow_stored_credentials = true; + break; + } + new_request.SetAllowStoredCredentials(allow_stored_credentials); + } + + + Context().PrepareRequest(new_request, + FetchContext::RedirectType::kForRedirect); + Context().DispatchWillSendRequest(resource_->Identifier(), new_request, + redirect_response, options.initiator_info); + + DCHECK(KURL(new_site_for_cookies) == new_request.SiteForCookies()); + + DCHECK_EQ(new_request.GetRequestContext(), request_context); + DCHECK_EQ(new_request.GetFrameType(), frame_type); + DCHECK_EQ(new_request.GetFetchRequestMode(), fetch_request_mode); + DCHECK_EQ(new_request.GetFetchCredentialsMode(), fetch_credentials_mode); + + if (new_request.Url() != KURL(new_url)) { + CancelForRedirectAccessCheckError(new_request.Url(), + ResourceRequestBlockedReason::kOther); + return false; + } + + if (!resource_->WillFollowRedirect(new_request, redirect_response)) { + CancelForRedirectAccessCheckError(new_request.Url(), + ResourceRequestBlockedReason::kOther); + return false; + } + + report_raw_headers = new_request.ReportRawHeaders(); + + return true; +} +",1,"bool ResourceLoader::WillFollowRedirect( + const WebURL& new_url, + const WebURL& new_site_for_cookies, + const WebString& new_referrer, + WebReferrerPolicy new_referrer_policy, + const WebString& new_method, + const WebURLResponse& passed_redirect_response, + bool& report_raw_headers) { + DCHECK(!passed_redirect_response.IsNull()); + + if (is_cache_aware_loading_activated_) { + HandleError( + ResourceError::CacheMissError(resource_->LastResourceRequest().Url())); + return false; + } + + const ResourceRequest& last_request = resource_->LastResourceRequest(); + ResourceRequest new_request(new_url); + new_request.SetSiteForCookies(new_site_for_cookies); + new_request.SetDownloadToFile(last_request.DownloadToFile()); + new_request.SetUseStreamOnResponse(last_request.UseStreamOnResponse()); + new_request.SetRequestContext(last_request.GetRequestContext()); + new_request.SetFrameType(last_request.GetFrameType()); + new_request.SetServiceWorkerMode( + passed_redirect_response.WasFetchedViaServiceWorker() + ? WebURLRequest::ServiceWorkerMode::kAll + : WebURLRequest::ServiceWorkerMode::kNone); + new_request.SetShouldResetAppCache(last_request.ShouldResetAppCache()); + new_request.SetFetchRequestMode(last_request.GetFetchRequestMode()); + new_request.SetFetchCredentialsMode(last_request.GetFetchCredentialsMode()); + new_request.SetKeepalive(last_request.GetKeepalive()); + String referrer = + new_referrer.IsEmpty() ? Referrer::NoReferrer() : String(new_referrer); + new_request.SetHTTPReferrer( + Referrer(referrer, static_cast(new_referrer_policy))); + new_request.SetPriority(last_request.Priority()); + new_request.SetHTTPMethod(new_method); + if (new_request.HttpMethod() == last_request.HttpMethod()) + new_request.SetHTTPBody(last_request.HttpBody()); + new_request.SetCheckForBrowserSideNavigation( + last_request.CheckForBrowserSideNavigation()); + + Resource::Type resource_type = resource_->GetType(); + + const ResourceRequest& initial_request = resource_->GetResourceRequest(); + WebURLRequest::RequestContext request_context = + initial_request.GetRequestContext(); + WebURLRequest::FrameType frame_type = initial_request.GetFrameType(); + WebURLRequest::FetchRequestMode fetch_request_mode = + initial_request.GetFetchRequestMode(); + WebURLRequest::FetchCredentialsMode fetch_credentials_mode = + initial_request.GetFetchCredentialsMode(); + + const ResourceLoaderOptions& options = resource_->Options(); + + const ResourceResponse& redirect_response( + passed_redirect_response.ToResourceResponse()); + + new_request.SetRedirectStatus( + ResourceRequest::RedirectStatus::kFollowedRedirect); + + if (!IsManualRedirectFetchRequest(initial_request)) { + bool unused_preload = resource_->IsUnusedPreload(); + + SecurityViolationReportingPolicy reporting_policy = + unused_preload ? SecurityViolationReportingPolicy::kSuppressReporting + : SecurityViolationReportingPolicy::kReport; + + Context().CheckCSPForRequest( + request_context, new_url, options, reporting_policy, + ResourceRequest::RedirectStatus::kFollowedRedirect); + + ResourceRequestBlockedReason blocked_reason = Context().CanRequest( + resource_type, new_request, new_url, options, reporting_policy, + FetchParameters::kUseDefaultOriginRestrictionForType, + ResourceRequest::RedirectStatus::kFollowedRedirect); + if (blocked_reason != ResourceRequestBlockedReason::kNone) { + CancelForRedirectAccessCheckError(new_url, blocked_reason); + return false; + } + + if (options.cors_handling_by_resource_fetcher == + kEnableCORSHandlingByResourceFetcher && + fetch_request_mode == WebURLRequest::kFetchRequestModeCORS) { + RefPtr source_origin = options.security_origin; + if (!source_origin.get()) + source_origin = Context().GetSecurityOrigin(); + WebSecurityOrigin source_web_origin(source_origin.get()); + WrappedResourceRequest new_request_wrapper(new_request); + WebString cors_error_msg; + if (!WebCORS::HandleRedirect( + source_web_origin, new_request_wrapper, redirect_response.Url(), + redirect_response.HttpStatusCode(), + redirect_response.HttpHeaderFields(), fetch_credentials_mode, + resource_->MutableOptions(), cors_error_msg)) { + resource_->SetCORSStatus(CORSStatus::kFailed); + + if (!unused_preload) { + Context().AddErrorConsoleMessage(cors_error_msg, + FetchContext::kJSSource); + } + + CancelForRedirectAccessCheckError(new_url, + ResourceRequestBlockedReason::kOther); + return false; + } + + source_origin = source_web_origin; + } + if (resource_type == Resource::kImage && + fetcher_->ShouldDeferImageLoad(new_url)) { + CancelForRedirectAccessCheckError(new_url, + ResourceRequestBlockedReason::kOther); + return false; + } + } + + bool cross_origin = + !SecurityOrigin::AreSameSchemeHostPort(redirect_response.Url(), new_url); + fetcher_->RecordResourceTimingOnRedirect(resource_.Get(), redirect_response, + cross_origin); + + if (options.cors_handling_by_resource_fetcher == + kEnableCORSHandlingByResourceFetcher && + fetch_request_mode == WebURLRequest::kFetchRequestModeCORS) { + bool allow_stored_credentials = false; + switch (fetch_credentials_mode) { + case WebURLRequest::kFetchCredentialsModeOmit: + break; + case WebURLRequest::kFetchCredentialsModeSameOrigin: + allow_stored_credentials = !options.cors_flag; + break; + case WebURLRequest::kFetchCredentialsModeInclude: + case WebURLRequest::kFetchCredentialsModePassword: + allow_stored_credentials = true; + break; + } + new_request.SetAllowStoredCredentials(allow_stored_credentials); + } + + + Context().PrepareRequest(new_request, + FetchContext::RedirectType::kForRedirect); + Context().DispatchWillSendRequest(resource_->Identifier(), new_request, + redirect_response, resource_->GetType(), + options.initiator_info); + + DCHECK(KURL(new_site_for_cookies) == new_request.SiteForCookies()); + + DCHECK_EQ(new_request.GetRequestContext(), request_context); + DCHECK_EQ(new_request.GetFrameType(), frame_type); + DCHECK_EQ(new_request.GetFetchRequestMode(), fetch_request_mode); + DCHECK_EQ(new_request.GetFetchCredentialsMode(), fetch_credentials_mode); + + if (new_request.Url() != KURL(new_url)) { + CancelForRedirectAccessCheckError(new_request.Url(), + ResourceRequestBlockedReason::kOther); + return false; + } + + if (!resource_->WillFollowRedirect(new_request, redirect_response)) { + CancelForRedirectAccessCheckError(new_request.Url(), + ResourceRequestBlockedReason::kOther); + return false; + } + + report_raw_headers = new_request.ReportRawHeaders(); + + return true; +} +","@@ -364,7 +364,8 @@ bool ResourceLoader::WillFollowRedirect( + Context().PrepareRequest(new_request, + FetchContext::RedirectType::kForRedirect); + Context().DispatchWillSendRequest(resource_->Identifier(), new_request, +- redirect_response, options.initiator_info); ++ redirect_response, resource_->GetType(), ++ options.initiator_info); + + // First-party cookie logic moved from DocumentLoader in Blink to + // net::URLRequest in the browser. Assert that Blink didn't try to change it",1397,1633,2048 +9015,"static void megasas_detach_one(struct pci_dev *pdev) +{ + int i; + struct Scsi_Host *host; + struct megasas_instance *instance; + struct fusion_context *fusion; + u32 pd_seq_map_sz; + + instance = pci_get_drvdata(pdev); + host = instance->host; + fusion = instance->ctrl_context; + + /* Shutdown SR-IOV heartbeat timer */ + if (instance->requestorId && !instance->skip_heartbeat_timer_del) + del_timer_sync(&instance->sriov_heartbeat_timer); + + /* Stop the FW fault detection watchdog */ + if (instance->adapter_type != MFI_SERIES) + megasas_fusion_stop_watchdog(instance); + + if (instance->fw_crash_state != UNAVAILABLE) + megasas_free_host_crash_buffer(instance); + scsi_remove_host(instance->host); + instance->unload = 1; + + if (megasas_wait_for_adapter_operational(instance)) + goto skip_firing_dcmds; + + megasas_flush_cache(instance); + megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); + +skip_firing_dcmds: + /* cancel the delayed work if this work still in queue*/ + if (instance->ev != NULL) { + struct megasas_aen_event *ev = instance->ev; + cancel_delayed_work_sync(&ev->hotplug_work); + instance->ev = NULL; + } + + /* cancel all wait events */ + wake_up_all(&instance->int_cmd_wait_q); + + tasklet_kill(&instance->isr_tasklet); + + /* + * Take the instance off the instance array. Note that we will not + * decrement the max_index. We let this array be sparse array + */ + for (i = 0; i < megasas_mgmt_info.max_index; i++) { + if (megasas_mgmt_info.instance[i] == instance) { + megasas_mgmt_info.count--; + megasas_mgmt_info.instance[i] = NULL; + + break; + } + } + + instance->instancet->disable_intr(instance); + + megasas_destroy_irqs(instance); + + if (instance->msix_vectors) + pci_free_irq_vectors(instance->pdev); + + if (instance->adapter_type >= VENTURA_SERIES) { + for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) + kfree(fusion->stream_detect_by_ld[i]); + kfree(fusion->stream_detect_by_ld); + fusion->stream_detect_by_ld = NULL; + } + + + if (instance->adapter_type != MFI_SERIES) { + megasas_release_fusion(instance); + pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + + (sizeof(struct MR_PD_CFG_SEQ) * + (MAX_PHYSICAL_DEVICES - 1)); + for (i = 0; i < 2 ; i++) { + if (fusion->ld_map[i]) + dma_free_coherent(&instance->pdev->dev, + fusion->max_map_sz, + fusion->ld_map[i], + fusion->ld_map_phys[i]); + if (fusion->ld_drv_map[i]) { + if (is_vmalloc_addr(fusion->ld_drv_map[i])) + vfree(fusion->ld_drv_map[i]); + else + free_pages((ulong)fusion->ld_drv_map[i], + fusion->drv_map_pages); + } + + if (fusion->pd_seq_sync[i]) + dma_free_coherent(&instance->pdev->dev, + pd_seq_map_sz, + fusion->pd_seq_sync[i], + fusion->pd_seq_phys[i]); + } + } else { + megasas_release_mfi(instance); + } + + if (instance->vf_affiliation) + dma_free_coherent(&pdev->dev, (MAX_LOGICAL_DRIVES + 1) * + sizeof(struct MR_LD_VF_AFFILIATION), + instance->vf_affiliation, + instance->vf_affiliation_h); + + if (instance->vf_affiliation_111) + dma_free_coherent(&pdev->dev, + sizeof(struct MR_LD_VF_AFFILIATION_111), + instance->vf_affiliation_111, + instance->vf_affiliation_111_h); + + if (instance->hb_host_mem) + dma_free_coherent(&pdev->dev, sizeof(struct MR_CTRL_HB_HOST_MEM), + instance->hb_host_mem, + instance->hb_host_mem_h); + + megasas_free_ctrl_dma_buffers(instance); + + megasas_free_ctrl_mem(instance); + + scsi_host_put(host); + + pci_disable_device(pdev); +} +",0,"static void megasas_detach_one(struct pci_dev *pdev) +{ + int i; + struct Scsi_Host *host; + struct megasas_instance *instance; + struct fusion_context *fusion; + u32 pd_seq_map_sz; + + instance = pci_get_drvdata(pdev); + host = instance->host; + fusion = instance->ctrl_context; + + /* Shutdown SR-IOV heartbeat timer */ + if (instance->requestorId && !instance->skip_heartbeat_timer_del) + del_timer_sync(&instance->sriov_heartbeat_timer); + + /* Stop the FW fault detection watchdog */ + if (instance->adapter_type != MFI_SERIES) + megasas_fusion_stop_watchdog(instance); + + if (instance->fw_crash_state != UNAVAILABLE) + megasas_free_host_crash_buffer(instance); + scsi_remove_host(instance->host); + instance->unload = 1; + + if (megasas_wait_for_adapter_operational(instance)) + goto skip_firing_dcmds; + + megasas_flush_cache(instance); + megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); + +skip_firing_dcmds: + /* cancel the delayed work if this work still in queue*/ + if (instance->ev != NULL) { + struct megasas_aen_event *ev = instance->ev; + cancel_delayed_work_sync(&ev->hotplug_work); + instance->ev = NULL; + } + + /* cancel all wait events */ + wake_up_all(&instance->int_cmd_wait_q); + + tasklet_kill(&instance->isr_tasklet); + + /* + * Take the instance off the instance array. Note that we will not + * decrement the max_index. We let this array be sparse array + */ + for (i = 0; i < megasas_mgmt_info.max_index; i++) { + if (megasas_mgmt_info.instance[i] == instance) { + megasas_mgmt_info.count--; + megasas_mgmt_info.instance[i] = NULL; + + break; + } + } + + instance->instancet->disable_intr(instance); + + megasas_destroy_irqs(instance); + + if (instance->msix_vectors) + pci_free_irq_vectors(instance->pdev); + + if (instance->adapter_type >= VENTURA_SERIES) { + for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) + kfree(fusion->stream_detect_by_ld[i]); + kfree(fusion->stream_detect_by_ld); + fusion->stream_detect_by_ld = NULL; + } + + + if (instance->adapter_type != MFI_SERIES) { + megasas_release_fusion(instance); + pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + + (sizeof(struct MR_PD_CFG_SEQ) * + (MAX_PHYSICAL_DEVICES - 1)); + for (i = 0; i < 2 ; i++) { + if (fusion->ld_map[i]) + dma_free_coherent(&instance->pdev->dev, + fusion->max_map_sz, + fusion->ld_map[i], + fusion->ld_map_phys[i]); + if (fusion->ld_drv_map[i]) { + if (is_vmalloc_addr(fusion->ld_drv_map[i])) + vfree(fusion->ld_drv_map[i]); + else + free_pages((ulong)fusion->ld_drv_map[i], + fusion->drv_map_pages); + } + + if (fusion->pd_seq_sync[i]) + dma_free_coherent(&instance->pdev->dev, + pd_seq_map_sz, + fusion->pd_seq_sync[i], + fusion->pd_seq_phys[i]); + } + } else { + megasas_release_mfi(instance); + } + + if (instance->vf_affiliation) + dma_free_coherent(&pdev->dev, (MAX_LOGICAL_DRIVES + 1) * + sizeof(struct MR_LD_VF_AFFILIATION), + instance->vf_affiliation, + instance->vf_affiliation_h); + + if (instance->vf_affiliation_111) + dma_free_coherent(&pdev->dev, + sizeof(struct MR_LD_VF_AFFILIATION_111), + instance->vf_affiliation_111, + instance->vf_affiliation_111_h); + + if (instance->hb_host_mem) + dma_free_coherent(&pdev->dev, sizeof(struct MR_CTRL_HB_HOST_MEM), + instance->hb_host_mem, + instance->hb_host_mem_h); + + megasas_free_ctrl_dma_buffers(instance); + + megasas_free_ctrl_mem(instance); + + scsi_host_put(host); + + pci_disable_device(pdev); +} +","@@ -4188,6 +4188,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance) + if (megasas_create_frame_pool(instance)) { + dev_printk(KERN_DEBUG, &instance->pdev->dev, ""Error creating frame DMA pool\n""); + megasas_free_cmds(instance); ++ return -ENOMEM; + } + + return 0;",954,1190,2048 +1043," main( int argc, + char* argv[] ) + { + grEvent event; + + + parse_cmdline( &argc, &argv ); + +#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 && FREETYPE_PATCH <= 8 + if ( status.debug ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + FT_SetTraceLevel( trace_any, (FT_Byte)status.trace_level ); +#else + status.trace_level = 0; +#endif + } +#elif 0 + /* `setenv' and `putenv' is not ANSI and I don't want to mess */ + /* with this portability issue right now... */ + if ( status.debug ) + { + char temp[32]; + + sprintf( temp, ""any=%d"", status.trace_level ); + setenv( ""FT2_DEBUG"", temp ); + } +#endif + + /* Initialize engine */ + handle = FTDemo_New( status.encoding ); + + FT_Library_SetLcdFilter( handle->library, FT_LCD_FILTER_DEFAULT ); + + if ( status.preload ) + FTDemo_Set_Preload( handle, 1 ); + + for ( ; argc > 0; argc--, argv++ ) + FTDemo_Install_Font( handle, argv[0] ); + + if ( handle->num_fonts == 0 ) + Fatal( ""could not find/open any font file"" ); + + display = FTDemo_Display_New( gr_pixel_mode_rgb24 ); + if ( !display ) + Fatal( ""could not allocate display surface"" ); + + memset( display->fore_color.chroma, 0, 4 ); + memset( display->back_color.chroma, 0xff, 4 ); + grSetTitle( display->surface, + ""FreeType Glyph Viewer - press F1 for help"" ); + + status.Fail = 0; + + event_font_change( 0 ); + + if ( status.lcd_mode >= 0 ) + handle->lcd_mode = status.lcd_mode; + + FTDemo_Update_Current_Flags( handle ); + + for ( ;; ) + { + FTDemo_Display_Clear( display ); + + switch ( status.render_mode ) + { + case RENDER_MODE_ALL: + error = Render_All( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_EMBOLDEN: + error = Render_Embolden( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_SLANTED: + error = Render_Slanted( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_STROKE: + error = Render_Stroke( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_TEXT: + error = Render_Text( -1, status.Num ); + break; + + case RENDER_MODE_WATERFALL: + error = Render_Waterfall( status.ptsize ); + break; + } + + write_header( error ); + +#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR < 2 + if ( status.dump_cache_stats ) + { + /* dump simple cache manager statistics */ + fprintf( stderr, ""cache manager [ nodes, bytes, average ] = "" + "" [ %d, %ld, %f ]\n"", + handle->cache_manager->num_nodes, + handle->cache_manager->cur_weight, + handle->cache_manager->num_nodes > 0 + ? handle->cache_manager->cur_weight * 1.0 / + handle->cache_manager->num_nodes + : 0.0 ); + } +#endif + + status.header = 0; + grListenSurface( display->surface, 0, &event ); + if ( Process_Event( &event ) ) + break; + } + + printf( ""Execution completed successfully.\n"" ); + printf( ""Fails = %d\n"", status.Fail ); + + FTDemo_Display_Done( display ); + FTDemo_Done( handle ); + exit( 0 ); /* for safety reasons */ + + return 0; /* never reached */ + } +",0," main( int argc, + char* argv[] ) + { + grEvent event; + + + parse_cmdline( &argc, &argv ); + +#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 && FREETYPE_PATCH <= 8 + if ( status.debug ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + FT_SetTraceLevel( trace_any, (FT_Byte)status.trace_level ); +#else + status.trace_level = 0; +#endif + } +#elif 0 + /* `setenv' and `putenv' is not ANSI and I don't want to mess */ + /* with this portability issue right now... */ + if ( status.debug ) + { + char temp[32]; + + sprintf( temp, ""any=%d"", status.trace_level ); + setenv( ""FT2_DEBUG"", temp ); + } +#endif + + /* Initialize engine */ + handle = FTDemo_New( status.encoding ); + + FT_Library_SetLcdFilter( handle->library, FT_LCD_FILTER_DEFAULT ); + + if ( status.preload ) + FTDemo_Set_Preload( handle, 1 ); + + for ( ; argc > 0; argc--, argv++ ) + FTDemo_Install_Font( handle, argv[0] ); + + if ( handle->num_fonts == 0 ) + Fatal( ""could not find/open any font file"" ); + + display = FTDemo_Display_New( gr_pixel_mode_rgb24 ); + if ( !display ) + Fatal( ""could not allocate display surface"" ); + + memset( display->fore_color.chroma, 0, 4 ); + memset( display->back_color.chroma, 0xff, 4 ); + grSetTitle( display->surface, + ""FreeType Glyph Viewer - press F1 for help"" ); + + status.Fail = 0; + + event_font_change( 0 ); + + if ( status.lcd_mode >= 0 ) + handle->lcd_mode = status.lcd_mode; + + FTDemo_Update_Current_Flags( handle ); + + for ( ;; ) + { + FTDemo_Display_Clear( display ); + + switch ( status.render_mode ) + { + case RENDER_MODE_ALL: + error = Render_All( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_EMBOLDEN: + error = Render_Embolden( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_SLANTED: + error = Render_Slanted( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_STROKE: + error = Render_Stroke( handle->current_font->num_indices, + status.Num ); + break; + + case RENDER_MODE_TEXT: + error = Render_Text( -1, status.Num ); + break; + + case RENDER_MODE_WATERFALL: + error = Render_Waterfall( status.ptsize ); + break; + } + + write_header( error ); + +#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR < 2 + if ( status.dump_cache_stats ) + { + /* dump simple cache manager statistics */ + fprintf( stderr, ""cache manager [ nodes, bytes, average ] = "" + "" [ %d, %ld, %f ]\n"", + handle->cache_manager->num_nodes, + handle->cache_manager->cur_weight, + handle->cache_manager->num_nodes > 0 + ? handle->cache_manager->cur_weight * 1.0 / + handle->cache_manager->num_nodes + : 0.0 ); + } +#endif + + status.header = 0; + grListenSurface( display->surface, 0, &event ); + if ( Process_Event( &event ) ) + break; + } + + printf( ""Execution completed successfully.\n"" ); + printf( ""Fails = %d\n"", status.Fail ); + + FTDemo_Display_Done( display ); + FTDemo_Done( handle ); + exit( 0 ); /* for safety reasons */ + + return 0; /* never reached */ + } +","@@ -1145,19 +1145,19 @@ + switch ( error_code ) + { + case FT_Err_Ok: +- sprintf( status.header_buffer, ""%s %s (file `%s')"", ++ sprintf( status.header_buffer, ""%.50s %.50s (file `%.100s')"", + face->family_name, face->style_name, basename ); + break; + case FT_Err_Invalid_Pixel_Size: +- sprintf( status.header_buffer, ""Invalid pixel size (file `%s')"", ++ sprintf( status.header_buffer, ""Invalid pixel size (file `%.100s')"", + basename ); + break; + case FT_Err_Invalid_PPem: +- sprintf( status.header_buffer, ""Invalid ppem value (file `%s')"", ++ sprintf( status.header_buffer, ""Invalid ppem value (file `%.100s')"", + basename ); + break; + default: +- sprintf( status.header_buffer, ""File `%s': error 0x%04x"", ++ sprintf( status.header_buffer, ""File `%.100s': error 0x%04x"", + basename, (FT_UShort)error_code ); + break; + }",863,1099,2048 +6485,"static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env) +{ + struct bpf_insn *insn = env->prog->insnsi; + int insn_cnt = env->prog->len; + int i, j, err; + + err = bpf_prog_calc_tag(env->prog); + if (err) + return err; + + for (i = 0; i < insn_cnt; i++, insn++) { + if (BPF_CLASS(insn->code) == BPF_LDX && + (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) { + verbose(""BPF_LDX uses reserved fields\n""); + return -EINVAL; + } + + if (BPF_CLASS(insn->code) == BPF_STX && + ((BPF_MODE(insn->code) != BPF_MEM && + BPF_MODE(insn->code) != BPF_XADD) || insn->imm != 0)) { + verbose(""BPF_STX uses reserved fields\n""); + return -EINVAL; + } + + if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) { + struct bpf_map *map; + struct fd f; + + if (i == insn_cnt - 1 || insn[1].code != 0 || + insn[1].dst_reg != 0 || insn[1].src_reg != 0 || + insn[1].off != 0) { + verbose(""invalid bpf_ld_imm64 insn\n""); + return -EINVAL; + } + + if (insn->src_reg == 0) + /* valid generic load 64-bit imm */ + goto next_insn; + + if (insn->src_reg != BPF_PSEUDO_MAP_FD) { + verbose(""unrecognized bpf_ld_imm64 insn\n""); + return -EINVAL; + } + + f = fdget(insn->imm); + map = __bpf_map_get(f); + if (IS_ERR(map)) { + verbose(""fd %d is not pointing to valid bpf_map\n"", + insn->imm); + return PTR_ERR(map); + } + + err = check_map_prog_compatibility(map, env->prog); + if (err) { + fdput(f); + return err; + } + + /* store map pointer inside BPF_LD_IMM64 instruction */ + insn[0].imm = (u32) (unsigned long) map; + insn[1].imm = ((u64) (unsigned long) map) >> 32; + + /* check whether we recorded this map already */ + for (j = 0; j < env->used_map_cnt; j++) + if (env->used_maps[j] == map) { + fdput(f); + goto next_insn; + } + + if (env->used_map_cnt >= MAX_USED_MAPS) { + fdput(f); + return -E2BIG; + } + + /* hold the map. If the program is rejected by verifier, + * the map will be released by release_maps() or it + * will be used by the valid program until it's unloaded + * and all maps are released in free_bpf_prog_info() + */ + map = bpf_map_inc(map, false); + if (IS_ERR(map)) { + fdput(f); + return PTR_ERR(map); + } + env->used_maps[env->used_map_cnt++] = map; + + fdput(f); +next_insn: + insn++; + i++; + } + } + + /* now all pseudo BPF_LD_IMM64 instructions load valid + * 'struct bpf_map *' into a register instead of user map_fd. + * These pointers will be used later by verifier to validate map access. + */ + return 0; +} +",0,"static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env) +{ + struct bpf_insn *insn = env->prog->insnsi; + int insn_cnt = env->prog->len; + int i, j, err; + + err = bpf_prog_calc_tag(env->prog); + if (err) + return err; + + for (i = 0; i < insn_cnt; i++, insn++) { + if (BPF_CLASS(insn->code) == BPF_LDX && + (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) { + verbose(""BPF_LDX uses reserved fields\n""); + return -EINVAL; + } + + if (BPF_CLASS(insn->code) == BPF_STX && + ((BPF_MODE(insn->code) != BPF_MEM && + BPF_MODE(insn->code) != BPF_XADD) || insn->imm != 0)) { + verbose(""BPF_STX uses reserved fields\n""); + return -EINVAL; + } + + if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) { + struct bpf_map *map; + struct fd f; + + if (i == insn_cnt - 1 || insn[1].code != 0 || + insn[1].dst_reg != 0 || insn[1].src_reg != 0 || + insn[1].off != 0) { + verbose(""invalid bpf_ld_imm64 insn\n""); + return -EINVAL; + } + + if (insn->src_reg == 0) + /* valid generic load 64-bit imm */ + goto next_insn; + + if (insn->src_reg != BPF_PSEUDO_MAP_FD) { + verbose(""unrecognized bpf_ld_imm64 insn\n""); + return -EINVAL; + } + + f = fdget(insn->imm); + map = __bpf_map_get(f); + if (IS_ERR(map)) { + verbose(""fd %d is not pointing to valid bpf_map\n"", + insn->imm); + return PTR_ERR(map); + } + + err = check_map_prog_compatibility(map, env->prog); + if (err) { + fdput(f); + return err; + } + + /* store map pointer inside BPF_LD_IMM64 instruction */ + insn[0].imm = (u32) (unsigned long) map; + insn[1].imm = ((u64) (unsigned long) map) >> 32; + + /* check whether we recorded this map already */ + for (j = 0; j < env->used_map_cnt; j++) + if (env->used_maps[j] == map) { + fdput(f); + goto next_insn; + } + + if (env->used_map_cnt >= MAX_USED_MAPS) { + fdput(f); + return -E2BIG; + } + + /* hold the map. If the program is rejected by verifier, + * the map will be released by release_maps() or it + * will be used by the valid program until it's unloaded + * and all maps are released in free_bpf_prog_info() + */ + map = bpf_map_inc(map, false); + if (IS_ERR(map)) { + fdput(f); + return PTR_ERR(map); + } + env->used_maps[env->used_map_cnt++] = map; + + fdput(f); +next_insn: + insn++; + i++; + } + } + + /* now all pseudo BPF_LD_IMM64 instructions load valid + * 'struct bpf_map *' into a register instead of user map_fd. + * These pointers will be used later by verifier to validate map access. + */ + return 0; +} +","@@ -298,7 +298,8 @@ static const char *const bpf_jmp_string[16] = { + [BPF_EXIT >> 4] = ""exit"", + }; + +-static void print_bpf_insn(struct bpf_insn *insn) ++static void print_bpf_insn(const struct bpf_verifier_env *env, ++ const struct bpf_insn *insn) + { + u8 class = BPF_CLASS(insn->code); + +@@ -362,9 +363,19 @@ static void print_bpf_insn(struct bpf_insn *insn) + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->imm); +- } else if (BPF_MODE(insn->code) == BPF_IMM) { +- verbose(""(%02x) r%d = 0x%x\n"", +- insn->code, insn->dst_reg, insn->imm); ++ } else if (BPF_MODE(insn->code) == BPF_IMM && ++ BPF_SIZE(insn->code) == BPF_DW) { ++ /* At this point, we already made sure that the second ++ * part of the ldimm64 insn is accessible. ++ */ ++ u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm; ++ bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD; ++ ++ if (map_ptr && !env->allow_ptr_leaks) ++ imm = 0; ++ ++ verbose(""(%02x) r%d = 0x%llx\n"", insn->code, ++ insn->dst_reg, (unsigned long long)imm); + } else { + verbose(""BUG_ld_%02x\n"", insn->code); + return; +@@ -2853,7 +2864,7 @@ static int do_check(struct bpf_verifier_env *env) + + if (log_level) { + verbose(""%d: "", insn_idx); +- print_bpf_insn(insn); ++ print_bpf_insn(env, insn); + } + + err = ext_analyzer_insn_hook(env, insn_idx, prev_insn_idx);",820,1056,2048 +889,"X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, + EVP_PKEY *skey, const EVP_MD *md, unsigned int flags) +{ + X509_CRL *crl = NULL; + int i; + STACK_OF(X509_REVOKED) *revs = NULL; + /* CRLs can't be delta already */ + if (base->base_crl_number || newer->base_crl_number) { + X509err(X509_F_X509_CRL_DIFF, X509_R_CRL_ALREADY_DELTA); + return NULL; + } + /* Base and new CRL must have a CRL number */ + if (!base->crl_number || !newer->crl_number) { + X509err(X509_F_X509_CRL_DIFF, X509_R_NO_CRL_NUMBER); + return NULL; + } + /* Issuer names must match */ + if (X509_NAME_cmp(X509_CRL_get_issuer(base), X509_CRL_get_issuer(newer))) { + X509err(X509_F_X509_CRL_DIFF, X509_R_ISSUER_MISMATCH); + return NULL; + } + /* AKID and IDP must match */ + if (!crl_extension_match(base, newer, NID_authority_key_identifier)) { + X509err(X509_F_X509_CRL_DIFF, X509_R_AKID_MISMATCH); + return NULL; + } + if (!crl_extension_match(base, newer, NID_issuing_distribution_point)) { + X509err(X509_F_X509_CRL_DIFF, X509_R_IDP_MISMATCH); + return NULL; + } + /* Newer CRL number must exceed full CRL number */ + if (ASN1_INTEGER_cmp(newer->crl_number, base->crl_number) <= 0) { + X509err(X509_F_X509_CRL_DIFF, X509_R_NEWER_CRL_NOT_NEWER); + return NULL; + } + /* CRLs must verify */ + if (skey && (X509_CRL_verify(base, skey) <= 0 || + X509_CRL_verify(newer, skey) <= 0)) { + X509err(X509_F_X509_CRL_DIFF, X509_R_CRL_VERIFY_FAILURE); + return NULL; + } + /* Create new CRL */ + crl = X509_CRL_new(); + if (!crl || !X509_CRL_set_version(crl, 1)) + goto memerr; + /* Set issuer name */ + if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer))) + goto memerr; + + if (!X509_CRL_set_lastUpdate(crl, X509_CRL_get_lastUpdate(newer))) + goto memerr; + if (!X509_CRL_set_nextUpdate(crl, X509_CRL_get_nextUpdate(newer))) + goto memerr; + + /* Set base CRL number: must be critical */ + + if (!X509_CRL_add1_ext_i2d(crl, NID_delta_crl, base->crl_number, 1, 0)) + goto memerr; + + /* + * Copy extensions across from newest CRL to delta: this will set CRL + * number to correct value too. + */ + + for (i = 0; i < X509_CRL_get_ext_count(newer); i++) { + X509_EXTENSION *ext; + ext = X509_CRL_get_ext(newer, i); + if (!X509_CRL_add_ext(crl, ext, -1)) + goto memerr; + } + + /* Go through revoked entries, copying as needed */ + + revs = X509_CRL_get_REVOKED(newer); + + for (i = 0; i < sk_X509_REVOKED_num(revs); i++) { + X509_REVOKED *rvn, *rvtmp; + rvn = sk_X509_REVOKED_value(revs, i); + /* + * Add only if not also in base. TODO: need something cleverer here + * for some more complex CRLs covering multiple CAs. + */ + if (!X509_CRL_get0_by_serial(base, &rvtmp, rvn->serialNumber)) { + rvtmp = X509_REVOKED_dup(rvn); + if (!rvtmp) + goto memerr; + if (!X509_CRL_add0_revoked(crl, rvtmp)) { + X509_REVOKED_free(rvtmp); + goto memerr; + } + } + } + /* TODO: optionally prune deleted entries */ + + if (skey && md && !X509_CRL_sign(crl, skey, md)) + goto memerr; + + return crl; + + memerr: + X509err(X509_F_X509_CRL_DIFF, ERR_R_MALLOC_FAILURE); + if (crl) + X509_CRL_free(crl); + return NULL; +} +",0,"X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, + EVP_PKEY *skey, const EVP_MD *md, unsigned int flags) +{ + X509_CRL *crl = NULL; + int i; + STACK_OF(X509_REVOKED) *revs = NULL; + /* CRLs can't be delta already */ + if (base->base_crl_number || newer->base_crl_number) { + X509err(X509_F_X509_CRL_DIFF, X509_R_CRL_ALREADY_DELTA); + return NULL; + } + /* Base and new CRL must have a CRL number */ + if (!base->crl_number || !newer->crl_number) { + X509err(X509_F_X509_CRL_DIFF, X509_R_NO_CRL_NUMBER); + return NULL; + } + /* Issuer names must match */ + if (X509_NAME_cmp(X509_CRL_get_issuer(base), X509_CRL_get_issuer(newer))) { + X509err(X509_F_X509_CRL_DIFF, X509_R_ISSUER_MISMATCH); + return NULL; + } + /* AKID and IDP must match */ + if (!crl_extension_match(base, newer, NID_authority_key_identifier)) { + X509err(X509_F_X509_CRL_DIFF, X509_R_AKID_MISMATCH); + return NULL; + } + if (!crl_extension_match(base, newer, NID_issuing_distribution_point)) { + X509err(X509_F_X509_CRL_DIFF, X509_R_IDP_MISMATCH); + return NULL; + } + /* Newer CRL number must exceed full CRL number */ + if (ASN1_INTEGER_cmp(newer->crl_number, base->crl_number) <= 0) { + X509err(X509_F_X509_CRL_DIFF, X509_R_NEWER_CRL_NOT_NEWER); + return NULL; + } + /* CRLs must verify */ + if (skey && (X509_CRL_verify(base, skey) <= 0 || + X509_CRL_verify(newer, skey) <= 0)) { + X509err(X509_F_X509_CRL_DIFF, X509_R_CRL_VERIFY_FAILURE); + return NULL; + } + /* Create new CRL */ + crl = X509_CRL_new(); + if (!crl || !X509_CRL_set_version(crl, 1)) + goto memerr; + /* Set issuer name */ + if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer))) + goto memerr; + + if (!X509_CRL_set_lastUpdate(crl, X509_CRL_get_lastUpdate(newer))) + goto memerr; + if (!X509_CRL_set_nextUpdate(crl, X509_CRL_get_nextUpdate(newer))) + goto memerr; + + /* Set base CRL number: must be critical */ + + if (!X509_CRL_add1_ext_i2d(crl, NID_delta_crl, base->crl_number, 1, 0)) + goto memerr; + + /* + * Copy extensions across from newest CRL to delta: this will set CRL + * number to correct value too. + */ + + for (i = 0; i < X509_CRL_get_ext_count(newer); i++) { + X509_EXTENSION *ext; + ext = X509_CRL_get_ext(newer, i); + if (!X509_CRL_add_ext(crl, ext, -1)) + goto memerr; + } + + /* Go through revoked entries, copying as needed */ + + revs = X509_CRL_get_REVOKED(newer); + + for (i = 0; i < sk_X509_REVOKED_num(revs); i++) { + X509_REVOKED *rvn, *rvtmp; + rvn = sk_X509_REVOKED_value(revs, i); + /* + * Add only if not also in base. TODO: need something cleverer here + * for some more complex CRLs covering multiple CAs. + */ + if (!X509_CRL_get0_by_serial(base, &rvtmp, rvn->serialNumber)) { + rvtmp = X509_REVOKED_dup(rvn); + if (!rvtmp) + goto memerr; + if (!X509_CRL_add0_revoked(crl, rvtmp)) { + X509_REVOKED_free(rvtmp); + goto memerr; + } + } + } + /* TODO: optionally prune deleted entries */ + + if (skey && md && !X509_CRL_sign(crl, skey, md)) + goto memerr; + + return crl; + + memerr: + X509err(X509_F_X509_CRL_DIFF, ERR_R_MALLOC_FAILURE); + if (crl) + X509_CRL_free(crl); + return NULL; +} +","@@ -1124,10 +1124,10 @@ static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl, + crl = sk_X509_CRL_value(crls, i); + reasons = *preasons; + crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x); +- if (crl_score < best_score) ++ if (crl_score < best_score || crl_score == 0) + continue; + /* If current CRL is equivalent use it if it is newer */ +- if (crl_score == best_score) { ++ if (crl_score == best_score && best_crl != NULL) { + int day, sec; + if (ASN1_TIME_diff(&day, &sec, X509_CRL_get_lastUpdate(best_crl), + X509_CRL_get_lastUpdate(crl)) == 0)",1193,1429,2048 +1718,"int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) +{ + BDRVQcowState *s = bs->opaque; + QCowSnapshot *sn; + int i, snapshot_index; + int cur_l1_bytes, sn_l1_bytes; + int ret; + uint64_t *sn_l1_table = NULL; + + /* Search the snapshot */ + snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id); + if (snapshot_index < 0) { + return -ENOENT; + } + sn = &s->snapshots[snapshot_index]; + + if (sn->disk_size != bs->total_sectors * BDRV_SECTOR_SIZE) { + error_report(""qcow2: Loading snapshots with different disk "" + ""size is not implemented""); + ret = -ENOTSUP; + goto fail; + } + + /* + * Make sure that the current L1 table is big enough to contain the whole + * L1 table of the snapshot. If the snapshot L1 table is smaller, the + * current one must be padded with zeros. + */ + ret = qcow2_grow_l1_table(bs, sn->l1_size, true); + if (ret < 0) { + goto fail; + } + + cur_l1_bytes = s->l1_size * sizeof(uint64_t); + sn_l1_bytes = sn->l1_size * sizeof(uint64_t); + + /* + * Copy the snapshot L1 table to the current L1 table. + * + * Before overwriting the old current L1 table on disk, make sure to + * increase all refcounts for the clusters referenced by the new one. + * Decrease the refcount referenced by the old one only when the L1 + * table is overwritten. + */ + sn_l1_table = g_malloc0(cur_l1_bytes); + + ret = bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_table, sn_l1_bytes); + if (ret < 0) { + goto fail; + } + + ret = qcow2_update_snapshot_refcount(bs, sn->l1_table_offset, + sn->l1_size, 1); + if (ret < 0) { + goto fail; + } + + ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L1, + s->l1_table_offset, cur_l1_bytes); + if (ret < 0) { + goto fail; + } + + ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset, sn_l1_table, + cur_l1_bytes); + if (ret < 0) { + goto fail; + } + + /* + * Decrease refcount of clusters of current L1 table. + * + * At this point, the in-memory s->l1_table points to the old L1 table, + * whereas on disk we already have the new one. + * + * qcow2_update_snapshot_refcount special cases the current L1 table to use + * the in-memory data instead of really using the offset to load a new one, + * which is why this works. + */ + ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, + s->l1_size, -1); + + /* + * Now update the in-memory L1 table to be in sync with the on-disk one. We + * need to do this even if updating refcounts failed. + */ + for(i = 0;i < s->l1_size; i++) { + s->l1_table[i] = be64_to_cpu(sn_l1_table[i]); + } + + if (ret < 0) { + goto fail; + } + + g_free(sn_l1_table); + sn_l1_table = NULL; + + /* + * Update QCOW_OFLAG_COPIED in the active L1 table (it may have changed + * when we decreased the refcount of the old snapshot. + */ + ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0); + if (ret < 0) { + goto fail; + } + +#ifdef DEBUG_ALLOC + { + BdrvCheckResult result = {0}; + qcow2_check_refcounts(bs, &result, 0); + } +#endif + return 0; + +fail: + g_free(sn_l1_table); + return ret; +} +",0,"int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) +{ + BDRVQcowState *s = bs->opaque; + QCowSnapshot *sn; + int i, snapshot_index; + int cur_l1_bytes, sn_l1_bytes; + int ret; + uint64_t *sn_l1_table = NULL; + + /* Search the snapshot */ + snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id); + if (snapshot_index < 0) { + return -ENOENT; + } + sn = &s->snapshots[snapshot_index]; + + if (sn->disk_size != bs->total_sectors * BDRV_SECTOR_SIZE) { + error_report(""qcow2: Loading snapshots with different disk "" + ""size is not implemented""); + ret = -ENOTSUP; + goto fail; + } + + /* + * Make sure that the current L1 table is big enough to contain the whole + * L1 table of the snapshot. If the snapshot L1 table is smaller, the + * current one must be padded with zeros. + */ + ret = qcow2_grow_l1_table(bs, sn->l1_size, true); + if (ret < 0) { + goto fail; + } + + cur_l1_bytes = s->l1_size * sizeof(uint64_t); + sn_l1_bytes = sn->l1_size * sizeof(uint64_t); + + /* + * Copy the snapshot L1 table to the current L1 table. + * + * Before overwriting the old current L1 table on disk, make sure to + * increase all refcounts for the clusters referenced by the new one. + * Decrease the refcount referenced by the old one only when the L1 + * table is overwritten. + */ + sn_l1_table = g_malloc0(cur_l1_bytes); + + ret = bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_table, sn_l1_bytes); + if (ret < 0) { + goto fail; + } + + ret = qcow2_update_snapshot_refcount(bs, sn->l1_table_offset, + sn->l1_size, 1); + if (ret < 0) { + goto fail; + } + + ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L1, + s->l1_table_offset, cur_l1_bytes); + if (ret < 0) { + goto fail; + } + + ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset, sn_l1_table, + cur_l1_bytes); + if (ret < 0) { + goto fail; + } + + /* + * Decrease refcount of clusters of current L1 table. + * + * At this point, the in-memory s->l1_table points to the old L1 table, + * whereas on disk we already have the new one. + * + * qcow2_update_snapshot_refcount special cases the current L1 table to use + * the in-memory data instead of really using the offset to load a new one, + * which is why this works. + */ + ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, + s->l1_size, -1); + + /* + * Now update the in-memory L1 table to be in sync with the on-disk one. We + * need to do this even if updating refcounts failed. + */ + for(i = 0;i < s->l1_size; i++) { + s->l1_table[i] = be64_to_cpu(sn_l1_table[i]); + } + + if (ret < 0) { + goto fail; + } + + g_free(sn_l1_table); + sn_l1_table = NULL; + + /* + * Update QCOW_OFLAG_COPIED in the active L1 table (it may have changed + * when we decreased the refcount of the old snapshot. + */ + ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0); + if (ret < 0) { + goto fail; + } + +#ifdef DEBUG_ALLOC + { + BdrvCheckResult result = {0}; + qcow2_check_refcounts(bs, &result, 0); + } +#endif + return 0; + +fail: + g_free(sn_l1_table); + return ret; +} +","@@ -680,7 +680,7 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, + sn = &s->snapshots[snapshot_index]; + + /* Allocate and read in the snapshot's L1 table */ +- new_l1_bytes = s->l1_size * sizeof(uint64_t); ++ new_l1_bytes = sn->l1_size * sizeof(uint64_t); + new_l1_table = g_malloc0(align_offset(new_l1_bytes, 512)); + + ret = bdrv_pread(bs->file, sn->l1_table_offset, new_l1_table, new_l1_bytes);",956,1192,2048 +9284,"sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size, + uint8 ** server_random, uint8 * modulus, uint8 * exponent) +{ + uint32 crypt_level, random_len, rsa_info_len; + uint32 cacert_len, cert_len, flags; + RDSSL_CERT *cacert, *server_cert; + RDSSL_RKEY *server_public_key; + uint16 tag, length; + uint8 *next_tag, *end; + + logger(Protocol, Debug, ""%s()"", __func__); + + in_uint32_le(s, *rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */ + in_uint32_le(s, crypt_level); /* 1 = low, 2 = medium, 3 = high */ + if (crypt_level == 0) + { + /* no encryption */ + logger(Protocol, Debug, ""sec_parse_crypt_info(), got ENCRYPTION_LEVEL_NONE""); + return False; + } + + in_uint32_le(s, random_len); + in_uint32_le(s, rsa_info_len); + + if (random_len != SEC_RANDOM_SIZE) + { + logger(Protocol, Error, ""sec_parse_crypt_info(), got random len %d, expected %d"", + random_len, SEC_RANDOM_SIZE); + return False; + } + + in_uint8p(s, *server_random, random_len); + + /* RSA info */ + end = s->p + rsa_info_len; + if (end > s->end) + { + logger(Protocol, Error, ""sec_parse_crypt_info(), end > s->end""); + return False; + } + + in_uint32_le(s, flags); /* 1 = RDP4-style, 0x80000002 = X.509 */ + if (flags & 1) + { + logger(Protocol, Debug, + ""sec_parse_crypt_info(), We're going for the RDP4-style encryption""); + in_uint8s(s, 8); /* unknown */ + + while (s->p < end) + { + in_uint16_le(s, tag); + in_uint16_le(s, length); + + next_tag = s->p + length; + + switch (tag) + { + case SEC_TAG_PUBKEY: + if (!sec_parse_public_key(s, modulus, exponent)) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), invalid public key""); + return False; + } + logger(Protocol, Debug, + ""sec_parse_crypt_info(), got public key""); + + break; + + case SEC_TAG_KEYSIG: + if (!sec_parse_public_sig(s, length, modulus, exponent)) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), invalid public sig""); + return False; + } + break; + + default: + logger(Protocol, Warning, + ""sec_parse_crypt_info(), unhandled crypt tag 0x%x"", + tag); + } + + s->p = next_tag; + } + } + else + { + uint32 certcount; + + logger(Protocol, Debug, + ""sec_parse_crypt_info(), We're going for the RDP5-style encryption""); + in_uint32_le(s, certcount); /* Number of certificates */ + if (certcount < 2) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), server didn't send enough x509 certificates""); + return False; + } + for (; certcount > 2; certcount--) + { /* ignore all the certificates between the root and the signing CA */ + uint32 ignorelen; + RDSSL_CERT *ignorecert; + + in_uint32_le(s, ignorelen); + ignorecert = rdssl_cert_read(s->p, ignorelen); + in_uint8s(s, ignorelen); + if (ignorecert == NULL) + { /* XXX: error out? */ + logger(Protocol, Error, + ""sec_parse_crypt_info(), got a bad cert: this will probably screw up the rest of the communication""); + } + } + /* Do da funky X.509 stuffy + + ""How did I find out about this? I looked up and saw a + bright light and when I came to I had a scar on my forehead + and knew about X.500"" + - Peter Gutman in a early version of + http://www.cs.auckland.ac.nz/~pgut001/pubs/x509guide.txt + */ + in_uint32_le(s, cacert_len); + logger(Protocol, Debug, + ""sec_parse_crypt_info(), server CA Certificate length is %d"", cacert_len); + cacert = rdssl_cert_read(s->p, cacert_len); + in_uint8s(s, cacert_len); + if (NULL == cacert) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), couldn't load CA Certificate from server""); + return False; + } + in_uint32_le(s, cert_len); + logger(Protocol, Debug, ""sec_parse_crypt_info(), certificate length is %d"", + cert_len); + server_cert = rdssl_cert_read(s->p, cert_len); + in_uint8s(s, cert_len); + if (NULL == server_cert) + { + rdssl_cert_free(cacert); + logger(Protocol, Error, + ""sec_parse_crypt_info(), couldn't load Certificate from server""); + return False; + } + if (!rdssl_certs_ok(server_cert, cacert)) + { + rdssl_cert_free(server_cert); + rdssl_cert_free(cacert); + logger(Protocol, Error, + ""sec_parse_crypt_info(), security error, CA Certificate invalid""); + return False; + } + rdssl_cert_free(cacert); + in_uint8s(s, 16); /* Padding */ + server_public_key = rdssl_cert_to_rkey(server_cert, &g_server_public_key_len); + if (NULL == server_public_key) + { + logger(Protocol, Debug, + ""sec_parse_crypt_info(). failed to parse X509 correctly""); + rdssl_cert_free(server_cert); + return False; + } + rdssl_cert_free(server_cert); + if ((g_server_public_key_len < SEC_MODULUS_SIZE) || + (g_server_public_key_len > SEC_MAX_MODULUS_SIZE)) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), bad server public key size (%u bits)"", + g_server_public_key_len * 8); + rdssl_rkey_free(server_public_key); + return False; + } + if (rdssl_rkey_get_exp_mod(server_public_key, exponent, SEC_EXPONENT_SIZE, + modulus, SEC_MAX_MODULUS_SIZE) != 0) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), problem extracting RSA exponent, modulus""); + rdssl_rkey_free(server_public_key); + return False; + } + rdssl_rkey_free(server_public_key); + return True; /* There's some garbage here we don't care about */ + } + return s_check_end(s); +} +",0,"sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size, + uint8 ** server_random, uint8 * modulus, uint8 * exponent) +{ + uint32 crypt_level, random_len, rsa_info_len; + uint32 cacert_len, cert_len, flags; + RDSSL_CERT *cacert, *server_cert; + RDSSL_RKEY *server_public_key; + uint16 tag, length; + uint8 *next_tag, *end; + + logger(Protocol, Debug, ""%s()"", __func__); + + in_uint32_le(s, *rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */ + in_uint32_le(s, crypt_level); /* 1 = low, 2 = medium, 3 = high */ + if (crypt_level == 0) + { + /* no encryption */ + logger(Protocol, Debug, ""sec_parse_crypt_info(), got ENCRYPTION_LEVEL_NONE""); + return False; + } + + in_uint32_le(s, random_len); + in_uint32_le(s, rsa_info_len); + + if (random_len != SEC_RANDOM_SIZE) + { + logger(Protocol, Error, ""sec_parse_crypt_info(), got random len %d, expected %d"", + random_len, SEC_RANDOM_SIZE); + return False; + } + + in_uint8p(s, *server_random, random_len); + + /* RSA info */ + end = s->p + rsa_info_len; + if (end > s->end) + { + logger(Protocol, Error, ""sec_parse_crypt_info(), end > s->end""); + return False; + } + + in_uint32_le(s, flags); /* 1 = RDP4-style, 0x80000002 = X.509 */ + if (flags & 1) + { + logger(Protocol, Debug, + ""sec_parse_crypt_info(), We're going for the RDP4-style encryption""); + in_uint8s(s, 8); /* unknown */ + + while (s->p < end) + { + in_uint16_le(s, tag); + in_uint16_le(s, length); + + next_tag = s->p + length; + + switch (tag) + { + case SEC_TAG_PUBKEY: + if (!sec_parse_public_key(s, modulus, exponent)) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), invalid public key""); + return False; + } + logger(Protocol, Debug, + ""sec_parse_crypt_info(), got public key""); + + break; + + case SEC_TAG_KEYSIG: + if (!sec_parse_public_sig(s, length, modulus, exponent)) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), invalid public sig""); + return False; + } + break; + + default: + logger(Protocol, Warning, + ""sec_parse_crypt_info(), unhandled crypt tag 0x%x"", + tag); + } + + s->p = next_tag; + } + } + else + { + uint32 certcount; + + logger(Protocol, Debug, + ""sec_parse_crypt_info(), We're going for the RDP5-style encryption""); + in_uint32_le(s, certcount); /* Number of certificates */ + if (certcount < 2) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), server didn't send enough x509 certificates""); + return False; + } + for (; certcount > 2; certcount--) + { /* ignore all the certificates between the root and the signing CA */ + uint32 ignorelen; + RDSSL_CERT *ignorecert; + + in_uint32_le(s, ignorelen); + ignorecert = rdssl_cert_read(s->p, ignorelen); + in_uint8s(s, ignorelen); + if (ignorecert == NULL) + { /* XXX: error out? */ + logger(Protocol, Error, + ""sec_parse_crypt_info(), got a bad cert: this will probably screw up the rest of the communication""); + } + } + /* Do da funky X.509 stuffy + + ""How did I find out about this? I looked up and saw a + bright light and when I came to I had a scar on my forehead + and knew about X.500"" + - Peter Gutman in a early version of + http://www.cs.auckland.ac.nz/~pgut001/pubs/x509guide.txt + */ + in_uint32_le(s, cacert_len); + logger(Protocol, Debug, + ""sec_parse_crypt_info(), server CA Certificate length is %d"", cacert_len); + cacert = rdssl_cert_read(s->p, cacert_len); + in_uint8s(s, cacert_len); + if (NULL == cacert) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), couldn't load CA Certificate from server""); + return False; + } + in_uint32_le(s, cert_len); + logger(Protocol, Debug, ""sec_parse_crypt_info(), certificate length is %d"", + cert_len); + server_cert = rdssl_cert_read(s->p, cert_len); + in_uint8s(s, cert_len); + if (NULL == server_cert) + { + rdssl_cert_free(cacert); + logger(Protocol, Error, + ""sec_parse_crypt_info(), couldn't load Certificate from server""); + return False; + } + if (!rdssl_certs_ok(server_cert, cacert)) + { + rdssl_cert_free(server_cert); + rdssl_cert_free(cacert); + logger(Protocol, Error, + ""sec_parse_crypt_info(), security error, CA Certificate invalid""); + return False; + } + rdssl_cert_free(cacert); + in_uint8s(s, 16); /* Padding */ + server_public_key = rdssl_cert_to_rkey(server_cert, &g_server_public_key_len); + if (NULL == server_public_key) + { + logger(Protocol, Debug, + ""sec_parse_crypt_info(). failed to parse X509 correctly""); + rdssl_cert_free(server_cert); + return False; + } + rdssl_cert_free(server_cert); + if ((g_server_public_key_len < SEC_MODULUS_SIZE) || + (g_server_public_key_len > SEC_MAX_MODULUS_SIZE)) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), bad server public key size (%u bits)"", + g_server_public_key_len * 8); + rdssl_rkey_free(server_public_key); + return False; + } + if (rdssl_rkey_get_exp_mod(server_public_key, exponent, SEC_EXPONENT_SIZE, + modulus, SEC_MAX_MODULUS_SIZE) != 0) + { + logger(Protocol, Error, + ""sec_parse_crypt_info(), problem extracting RSA exponent, modulus""); + rdssl_rkey_free(server_public_key); + return False; + } + rdssl_rkey_free(server_public_key); + return True; /* There's some garbage here we don't care about */ + } + return s_check_end(s); +} +","@@ -296,6 +296,9 @@ sec_encrypt(uint8 * data, int length) + void + sec_decrypt(uint8 * data, int length) + { ++ if (length <= 0) ++ return; ++ + if (g_sec_decrypt_use_count == 4096) + { + sec_update(g_sec_decrypt_key, g_sec_decrypt_update_key); +@@ -848,9 +851,11 @@ sec_recv(RD_BOOL * is_fastpath) + uint16 sec_flags; + uint16 channel; + STREAM s; ++ struct stream packet; + + while ((s = mcs_recv(&channel, is_fastpath, &fastpath_hdr)) != NULL) + { ++ packet = *s; + if (*is_fastpath == True) + { + /* If fastpath packet is encrypted, read data +@@ -859,6 +864,10 @@ sec_recv(RD_BOOL * is_fastpath) + fastpath_flags = (fastpath_hdr & 0xC0) >> 6; + if (fastpath_flags & FASTPATH_OUTPUT_ENCRYPTED) + { ++ if (!s_check_rem(s, 8)) { ++ rdp_protocol_error(""sec_recv(), consume fastpath signature from stream would overrun"", &packet); ++ } ++ + in_uint8s(s, 8); /* signature */ + sec_decrypt(s->p, s->end - s->p); + } +@@ -875,6 +884,10 @@ sec_recv(RD_BOOL * is_fastpath) + { + if (sec_flags & SEC_ENCRYPT) + { ++ if (!s_check_rem(s, 8)) { ++ rdp_protocol_error(""sec_recv(), consume encrypt signature from stream would overrun"", &packet); ++ } ++ + in_uint8s(s, 8); /* signature */ + sec_decrypt(s->p, s->end - s->p); + } +@@ -889,6 +902,10 @@ sec_recv(RD_BOOL * is_fastpath) + { + uint8 swapbyte; + ++ if (!s_check_rem(s, 8)) { ++ rdp_protocol_error(""sec_recv(), consume redirect signature from stream would overrun"", &packet); ++ } ++ + in_uint8s(s, 8); /* signature */ + sec_decrypt(s->p, s->end - s->p); + ",1572,1808,2048 +18279,"compile_length_bag_node(BagNode* node, regex_t* reg) +{ + int len; + int tlen; + + if (node->type == BAG_OPTION) + return compile_length_option_node(node, reg); + + if (NODE_BAG_BODY(node)) { + tlen = compile_length_tree(NODE_BAG_BODY(node), reg); + if (tlen < 0) return tlen; + } + else + tlen = 0; + + switch (node->type) { + case BAG_MEMORY: +#ifdef USE_CALL + + if (node->m.regnum == 0 && NODE_IS_CALLED(node)) { + len = tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; + return len; + } + + if (NODE_IS_CALLED(node)) { + len = SIZE_OP_MEMORY_START_PUSH + tlen + + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; + if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) + len += (NODE_IS_RECURSION(node) + ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH); + else + len += (NODE_IS_RECURSION(node) + ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END); + } + else if (NODE_IS_RECURSION(node)) { + len = SIZE_OP_MEMORY_START_PUSH; + len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) + ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_REC); + } + else +#endif + { + if (MEM_STATUS_AT0(reg->bt_mem_start, node->m.regnum)) + len = SIZE_OP_MEMORY_START_PUSH; + else + len = SIZE_OP_MEMORY_START; + + len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) + ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END); + } + break; + + case BAG_STOP_BACKTRACK: + if (NODE_IS_STOP_BT_SIMPLE_REPEAT(node)) { + int v; + QuantNode* qn; + + qn = QUANT_(NODE_BAG_BODY(node)); + tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg); + if (tlen < 0) return tlen; + + v = onig_positive_int_multiply(qn->lower, tlen); + if (v < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE; + len = v + SIZE_OP_PUSH + tlen + SIZE_OP_POP_OUT + SIZE_OP_JUMP; + } + else { + len = SIZE_OP_ATOMIC_START + tlen + SIZE_OP_ATOMIC_END; + } + break; + + case BAG_IF_ELSE: + { + Node* cond = NODE_BAG_BODY(node); + Node* Then = node->te.Then; + Node* Else = node->te.Else; + + len = compile_length_tree(cond, reg); + if (len < 0) return len; + len += SIZE_OP_PUSH; + len += SIZE_OP_ATOMIC_START + SIZE_OP_ATOMIC_END; + + if (IS_NOT_NULL(Then)) { + tlen = compile_length_tree(Then, reg); + if (tlen < 0) return tlen; + len += tlen; + } + + if (IS_NOT_NULL(Else)) { + len += SIZE_OP_JUMP; + tlen = compile_length_tree(Else, reg); + if (tlen < 0) return tlen; + len += tlen; + } + } + break; + + case BAG_OPTION: + /* never come here, but set for escape warning */ + len = 0; + break; + } + + return len; +} +",1,"compile_length_bag_node(BagNode* node, regex_t* reg) +{ + int len; + int tlen; + + if (node->type == BAG_OPTION) + return compile_length_option_node(node, reg); + + if (NODE_BAG_BODY(node)) { + tlen = compile_length_tree(NODE_BAG_BODY(node), reg); + if (tlen < 0) return tlen; + } + else + tlen = 0; + + switch (node->type) { + case BAG_MEMORY: +#ifdef USE_CALL + + if (node->m.regnum == 0 && NODE_IS_CALLED(node)) { + len = tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; + return len; + } + + if (NODE_IS_CALLED(node)) { + len = SIZE_OP_MEMORY_START_PUSH + tlen + + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; + if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) + len += (NODE_IS_RECURSION(node) + ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH); + else + len += (NODE_IS_RECURSION(node) + ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END); + } + else if (NODE_IS_RECURSION(node)) { + len = SIZE_OP_MEMORY_START_PUSH; + len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) + ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_REC); + } + else +#endif + { + if (MEM_STATUS_AT0(reg->bt_mem_start, node->m.regnum)) + len = SIZE_OP_MEMORY_START_PUSH; + else + len = SIZE_OP_MEMORY_START; + + len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) + ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END); + } + break; + + case BAG_STOP_BACKTRACK: + if (NODE_IS_STOP_BT_SIMPLE_REPEAT(node)) { + int v; + QuantNode* qn; + + qn = QUANT_(NODE_BAG_BODY(node)); + tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg); + if (tlen < 0) return tlen; + + v = onig_positive_int_multiply(qn->lower, tlen); + if (v < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE; + len = v + SIZE_OP_PUSH + tlen + SIZE_OP_POP_OUT + SIZE_OP_JUMP; + } + else { + len = SIZE_OP_ATOMIC_START + tlen + SIZE_OP_ATOMIC_END; + } + break; + + case BAG_IF_ELSE: + { + Node* cond = NODE_BAG_BODY(node); + Node* Then = node->te.Then; + Node* Else = node->te.Else; + + len = compile_length_tree(cond, reg); + if (len < 0) return len; + len += SIZE_OP_PUSH; + len += SIZE_OP_ATOMIC_START + SIZE_OP_ATOMIC_END; + + if (IS_NOT_NULL(Then)) { + tlen = compile_length_tree(Then, reg); + if (tlen < 0) return tlen; + len += tlen; + } + + len += SIZE_OP_JUMP + SIZE_OP_ATOMIC_END; + + if (IS_NOT_NULL(Else)) { + tlen = compile_length_tree(Else, reg); + if (tlen < 0) return tlen; + len += tlen; + } + } + break; + + case BAG_OPTION: + /* never come here, but set for escape warning */ + len = 0; + break; + } + + return len; +} +","@@ -1307,8 +1307,9 @@ compile_length_bag_node(BagNode* node, regex_t* reg) + len += tlen; + } + ++ len += SIZE_OP_JUMP + SIZE_OP_ATOMIC_END; ++ + if (IS_NOT_NULL(Else)) { +- len += SIZE_OP_JUMP; + tlen = compile_length_tree(Else, reg); + if (tlen < 0) return tlen; + len += tlen; +@@ -1455,7 +1456,7 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + + case BAG_IF_ELSE: + { +- int cond_len, then_len, jump_len; ++ int cond_len, then_len, else_len, jump_len; + Node* cond = NODE_BAG_BODY(node); + Node* Then = node->te.Then; + Node* Else = node->te.Else; +@@ -1472,8 +1473,7 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + else + then_len = 0; + +- jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END; +- if (IS_NOT_NULL(Else)) jump_len += SIZE_OP_JUMP; ++ jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END + SIZE_OP_JUMP; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; +@@ -1490,11 +1490,20 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + } + + if (IS_NOT_NULL(Else)) { +- int else_len = compile_length_tree(Else, reg); +- r = add_op(reg, OP_JUMP); +- if (r != 0) return r; +- COP(reg)->jump.addr = else_len + SIZE_INC_OP; ++ else_len = compile_length_tree(Else, reg); ++ if (else_len < 0) return else_len; ++ } ++ else ++ else_len = 0; + ++ r = add_op(reg, OP_JUMP); ++ if (r != 0) return r; ++ COP(reg)->jump.addr = SIZE_OP_ATOMIC_END + else_len + SIZE_INC_OP; ++ ++ r = add_op(reg, OP_ATOMIC_END); ++ if (r != 0) return r; ++ ++ if (IS_NOT_NULL(Else)) { + r = compile_tree(Else, reg, env); + } + }",788,1024,2048 +16101,"RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, + RenderViewHostImpl* render_view_host, + RenderFrameHostDelegate* delegate, + RenderWidgetHostDelegate* rwh_delegate, + FrameTree* frame_tree, + FrameTreeNode* frame_tree_node, + int32_t routing_id, + int32_t widget_routing_id, + bool hidden, + bool renderer_initiated_creation) + : render_view_host_(render_view_host), + delegate_(delegate), + site_instance_(static_cast(site_instance)), + process_(site_instance->GetProcess()), + frame_tree_(frame_tree), + frame_tree_node_(frame_tree_node), + parent_(nullptr), + render_widget_host_(nullptr), + routing_id_(routing_id), + is_waiting_for_swapout_ack_(false), + render_frame_created_(false), + is_waiting_for_beforeunload_ack_(false), + unload_ack_is_for_navigation_(false), + is_loading_(false), + pending_commit_(false), + nav_entry_id_(0), + accessibility_reset_token_(0), + accessibility_reset_count_(0), + browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID), + no_create_browser_accessibility_manager_for_testing_(false), + web_ui_type_(WebUI::kNoWebUI), + pending_web_ui_type_(WebUI::kNoWebUI), + should_reuse_web_ui_(false), + has_selection_(false), + is_audible_(false), + last_navigation_previews_state_(PREVIEWS_UNSPECIFIED), + frame_host_associated_binding_(this), + waiting_for_init_(renderer_initiated_creation), + has_focused_editable_element_(false), + active_sandbox_flags_(blink::WebSandboxFlags::kNone), + document_scoped_interface_provider_binding_(this), + keep_alive_timeout_(base::TimeDelta::FromSeconds(30)), + weak_ptr_factory_(this) { + frame_tree_->AddRenderViewHostRef(render_view_host_); + GetProcess()->AddRoute(routing_id_, this); + g_routing_id_frame_map.Get().insert(std::make_pair( + RenderFrameHostID(GetProcess()->GetID(), routing_id_), + this)); + site_instance_->AddObserver(this); + GetSiteInstance()->IncrementActiveFrameCount(); + + if (frame_tree_node_->parent()) { + parent_ = frame_tree_node_->parent()->current_frame_host(); + + if (parent_->GetEnabledBindings()) + enabled_bindings_ = parent_->GetEnabledBindings(); + + set_nav_entry_id( + frame_tree_node_->parent()->current_frame_host()->nav_entry_id()); + } + + SetUpMojoIfNeeded(); + + swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( + &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr()))); + beforeunload_timeout_.reset( + new TimeoutMonitor(base::Bind(&RenderFrameHostImpl::BeforeUnloadTimeout, + weak_ptr_factory_.GetWeakPtr()))); + + if (widget_routing_id != MSG_ROUTING_NONE) { + mojom::WidgetPtr widget; + GetRemoteInterfaces()->GetInterface(&widget); + + render_widget_host_ = + RenderWidgetHostImpl::FromID(GetProcess()->GetID(), widget_routing_id); + + mojom::WidgetInputHandlerAssociatedPtr widget_handler; + mojom::WidgetInputHandlerHostRequest host_request; + if (frame_input_handler_) { + mojom::WidgetInputHandlerHostPtr host; + host_request = mojo::MakeRequest(&host); + frame_input_handler_->GetWidgetInputHandler( + mojo::MakeRequest(&widget_handler), std::move(host)); + } + if (!render_widget_host_) { + DCHECK(frame_tree_node->parent()); + render_widget_host_ = RenderWidgetHostFactory::Create( + rwh_delegate, GetProcess(), widget_routing_id, std::move(widget), + hidden); + render_widget_host_->set_owned_by_render_frame_host(true); + } else { + DCHECK(!render_widget_host_->owned_by_render_frame_host()); + render_widget_host_->SetWidget(std::move(widget)); + } + render_widget_host_->SetWidgetInputHandler(std::move(widget_handler), + std::move(host_request)); + render_widget_host_->input_router()->SetFrameTreeNodeId( + frame_tree_node_->frame_tree_node_id()); + } + ResetFeaturePolicy(); + + ax_tree_id_ = ui::AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( + GetProcess()->GetID(), routing_id_); +} +",0,"RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, + RenderViewHostImpl* render_view_host, + RenderFrameHostDelegate* delegate, + RenderWidgetHostDelegate* rwh_delegate, + FrameTree* frame_tree, + FrameTreeNode* frame_tree_node, + int32_t routing_id, + int32_t widget_routing_id, + bool hidden, + bool renderer_initiated_creation) + : render_view_host_(render_view_host), + delegate_(delegate), + site_instance_(static_cast(site_instance)), + process_(site_instance->GetProcess()), + frame_tree_(frame_tree), + frame_tree_node_(frame_tree_node), + parent_(nullptr), + render_widget_host_(nullptr), + routing_id_(routing_id), + is_waiting_for_swapout_ack_(false), + render_frame_created_(false), + is_waiting_for_beforeunload_ack_(false), + unload_ack_is_for_navigation_(false), + is_loading_(false), + pending_commit_(false), + nav_entry_id_(0), + accessibility_reset_token_(0), + accessibility_reset_count_(0), + browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID), + no_create_browser_accessibility_manager_for_testing_(false), + web_ui_type_(WebUI::kNoWebUI), + pending_web_ui_type_(WebUI::kNoWebUI), + should_reuse_web_ui_(false), + has_selection_(false), + is_audible_(false), + last_navigation_previews_state_(PREVIEWS_UNSPECIFIED), + frame_host_associated_binding_(this), + waiting_for_init_(renderer_initiated_creation), + has_focused_editable_element_(false), + active_sandbox_flags_(blink::WebSandboxFlags::kNone), + document_scoped_interface_provider_binding_(this), + keep_alive_timeout_(base::TimeDelta::FromSeconds(30)), + weak_ptr_factory_(this) { + frame_tree_->AddRenderViewHostRef(render_view_host_); + GetProcess()->AddRoute(routing_id_, this); + g_routing_id_frame_map.Get().insert(std::make_pair( + RenderFrameHostID(GetProcess()->GetID(), routing_id_), + this)); + site_instance_->AddObserver(this); + GetSiteInstance()->IncrementActiveFrameCount(); + + if (frame_tree_node_->parent()) { + parent_ = frame_tree_node_->parent()->current_frame_host(); + + if (parent_->GetEnabledBindings()) + enabled_bindings_ = parent_->GetEnabledBindings(); + + set_nav_entry_id( + frame_tree_node_->parent()->current_frame_host()->nav_entry_id()); + } + + SetUpMojoIfNeeded(); + + swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( + &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr()))); + beforeunload_timeout_.reset( + new TimeoutMonitor(base::Bind(&RenderFrameHostImpl::BeforeUnloadTimeout, + weak_ptr_factory_.GetWeakPtr()))); + + if (widget_routing_id != MSG_ROUTING_NONE) { + mojom::WidgetPtr widget; + GetRemoteInterfaces()->GetInterface(&widget); + + render_widget_host_ = + RenderWidgetHostImpl::FromID(GetProcess()->GetID(), widget_routing_id); + + mojom::WidgetInputHandlerAssociatedPtr widget_handler; + mojom::WidgetInputHandlerHostRequest host_request; + if (frame_input_handler_) { + mojom::WidgetInputHandlerHostPtr host; + host_request = mojo::MakeRequest(&host); + frame_input_handler_->GetWidgetInputHandler( + mojo::MakeRequest(&widget_handler), std::move(host)); + } + if (!render_widget_host_) { + DCHECK(frame_tree_node->parent()); + render_widget_host_ = RenderWidgetHostFactory::Create( + rwh_delegate, GetProcess(), widget_routing_id, std::move(widget), + hidden); + render_widget_host_->set_owned_by_render_frame_host(true); + } else { + DCHECK(!render_widget_host_->owned_by_render_frame_host()); + render_widget_host_->SetWidget(std::move(widget)); + } + render_widget_host_->SetWidgetInputHandler(std::move(widget_handler), + std::move(host_request)); + render_widget_host_->input_router()->SetFrameTreeNodeId( + frame_tree_node_->frame_tree_node_id()); + } + ResetFeaturePolicy(); + + ax_tree_id_ = ui::AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( + GetProcess()->GetID(), routing_id_); +} +","@@ -960,6 +960,7 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { + OnSetHasReceivedUserGestureBeforeNavigation) + IPC_MESSAGE_HANDLER(FrameHostMsg_ScrollRectToVisibleInParentFrame, + OnScrollRectToVisibleInParentFrame) ++ IPC_MESSAGE_HANDLER(FrameHostMsg_FrameDidCallFocus, OnFrameDidCallFocus) + #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) + IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) + IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) +@@ -2824,6 +2825,10 @@ void RenderFrameHostImpl::OnScrollRectToVisibleInParentFrame( + proxy->ScrollRectToVisible(rect_to_scroll, params); + } + ++void RenderFrameHostImpl::OnFrameDidCallFocus() { ++ delegate_->DidCallFocus(); ++} ++ + #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) + void RenderFrameHostImpl::OnShowPopup( + const FrameHostMsg_ShowPopup_Params& params) {",935,1171,2048 +18148,"mapi_attr_read (size_t len, unsigned char *buf) +{ + size_t idx = 0; + uint32 i,j; + assert(len > 4); + uint32 num_properties = GETINT32(buf+idx); + MAPI_Attr** attrs = CHECKED_XMALLOC (MAPI_Attr*, (num_properties + 1)); + + idx += 4; + + if (!attrs) return NULL; + for (i = 0; i < num_properties; i++) + { + MAPI_Attr* a = attrs[i] = CHECKED_XCALLOC(MAPI_Attr, 1); + MAPI_Value* v = NULL; + + CHECKINT16(idx, len); a->type = GETINT16(buf+idx); idx += 2; + CHECKINT16(idx, len); a->name = GETINT16(buf+idx); idx += 2; + + /* handle special case of GUID prefixed properties */ + if (a->name & GUID_EXISTS_FLAG) + { + /* copy GUID */ + a->guid = CHECKED_XMALLOC(GUID, 1); + copy_guid_from_buf(a->guid, buf+idx, len); + idx += sizeof (GUID); + + CHECKINT32(idx, len); a->num_names = GETINT32(buf+idx); idx += 4; + if (a->num_names > 0) + { + /* FIXME: do something useful here! */ + size_t i; + + a->names = CHECKED_XCALLOC(VarLenData, a->num_names); + + for (i = 0; i < a->num_names; i++) + { + size_t j; + + CHECKINT32(idx, len); a->names[i].len = GETINT32(buf+idx); idx += 4; + + /* read the data into a buffer */ + a->names[i].data + = CHECKED_XMALLOC(unsigned char, a->names[i].len); + for (j = 0; j < (a->names[i].len >> 1); j++) + a->names[i].data[j] = (buf+idx)[j*2]; + + /* But what are we going to do with it? */ + + idx += pad_to_4byte(a->names[i].len); + } + } + else + { + /* get the 'real' name */ + CHECKINT32(idx, len); a->name = GETINT32(buf+idx); idx+= 4; + } + } + + /* + * Multi-value types and string/object/binary types have + * multiple values + */ + if (a->type & MULTI_VALUE_FLAG || + a->type == szMAPI_STRING || + a->type == szMAPI_UNICODE_STRING || + a->type == szMAPI_OBJECT || + a->type == szMAPI_BINARY) + { + CHECKINT32(idx, len); a->num_values = GETINT32(buf+idx); + idx += 4; + } + else + { + a->num_values = 1; + } + + /* Amend the type in case of multi-value type */ + if (a->type & MULTI_VALUE_FLAG) + { + a->type -= MULTI_VALUE_FLAG; + } + + + v = alloc_mapi_values (a); + + for (j = 0; j < a->num_values; j++) + { + switch (a->type) + { + case szMAPI_SHORT: /* 2 bytes */ + v->len = 2; + CHECKINT16(idx, len); v->data.bytes2 = GETINT16(buf+idx); + idx += 4; /* assume padding of 2, advance by 4! */ + break; + + case szMAPI_INT: /* 4 bytes */ + v->len = 4; + CHECKINT32(idx, len); v->data.bytes4 = GETINT32(buf+idx); + idx += 4; + v++; + break; + + case szMAPI_FLOAT: /* 4 bytes */ + case szMAPI_BOOLEAN: /* this should be 2 bytes + 2 padding */ + v->len = 4; + CHECKINT32(idx, len); v->data.bytes4 = GETINT32(buf+idx); + idx += v->len; + break; + + case szMAPI_SYSTIME: /* 8 bytes */ + v->len = 8; + CHECKINT32(idx, len); v->data.bytes8[0] = GETINT32(buf+idx); + CHECKINT32(idx+4, len); v->data.bytes8[1] = GETINT32(buf+idx+4); + idx += 8; + v++; + break; + + case szMAPI_DOUBLE: /* 8 bytes */ + case szMAPI_APPTIME: + case szMAPI_CURRENCY: + case szMAPI_INT8BYTE: + v->len = 8; + CHECKINT32(idx, len); v->data.bytes8[0] = GETINT32(buf+idx); + CHECKINT32(idx+4, len); v->data.bytes8[1] = GETINT32(buf+idx+4); + idx += v->len; + break; + + case szMAPI_CLSID: + v->len = sizeof (GUID); + copy_guid_from_buf(&v->data.guid, buf+idx, len); + idx += v->len; + break; + + case szMAPI_STRING: + case szMAPI_UNICODE_STRING: + case szMAPI_OBJECT: + case szMAPI_BINARY: + CHECKINT32(idx, len); v->len = GETINT32(buf+idx); idx += 4; + + if (a->type == szMAPI_UNICODE_STRING) + { + v->data.buf = (unsigned char*)unicode_to_utf8(v->len, buf+idx); + } + else + { + v->data.buf = CHECKED_XMALLOC(unsigned char, v->len); + memmove (v->data.buf, buf+idx, v->len); + } + + idx += pad_to_4byte(v->len); + v++; + break; + + case szMAPI_NULL: /* illegal in input tnef streams */ + case szMAPI_ERROR: + case szMAPI_UNSPECIFIED: + fprintf (stderr, + ""Invalid attribute, input file may be corrupted\n""); + if (!ENCODE_SKIP) exit (1); + + return NULL; + + default: /* should never get here */ + fprintf (stderr, + ""Undefined attribute, input file may be corrupted\n""); + if (!ENCODE_SKIP) exit (1); + + return NULL; + + } + if (DEBUG_ON) mapi_attr_dump (attrs[i]); + } + } + attrs[i] = NULL; + + return attrs; +} +",1,"mapi_attr_read (size_t len, unsigned char *buf) +{ + size_t idx = 0; + uint32 i,j; + assert(len > 4); + uint32 num_properties = GETINT32(buf+idx); + assert((num_properties+1) != 0); + MAPI_Attr** attrs = CHECKED_XMALLOC (MAPI_Attr*, (num_properties + 1)); + + idx += 4; + + if (!attrs) return NULL; + for (i = 0; i < num_properties; i++) + { + MAPI_Attr* a = attrs[i] = CHECKED_XCALLOC(MAPI_Attr, 1); + MAPI_Value* v = NULL; + + CHECKINT16(idx, len); a->type = GETINT16(buf+idx); idx += 2; + CHECKINT16(idx, len); a->name = GETINT16(buf+idx); idx += 2; + + /* handle special case of GUID prefixed properties */ + if (a->name & GUID_EXISTS_FLAG) + { + /* copy GUID */ + a->guid = CHECKED_XMALLOC(GUID, 1); + copy_guid_from_buf(a->guid, buf+idx, len); + idx += sizeof (GUID); + + CHECKINT32(idx, len); a->num_names = GETINT32(buf+idx); idx += 4; + if (a->num_names > 0) + { + /* FIXME: do something useful here! */ + size_t i; + + a->names = CHECKED_XCALLOC(VarLenData, a->num_names); + + for (i = 0; i < a->num_names; i++) + { + size_t j; + + CHECKINT32(idx, len); a->names[i].len = GETINT32(buf+idx); idx += 4; + + /* read the data into a buffer */ + a->names[i].data + = CHECKED_XMALLOC(unsigned char, a->names[i].len); + assert((idx+(a->names[i].len*2)) <= len); + for (j = 0; j < (a->names[i].len >> 1); j++) + a->names[i].data[j] = (buf+idx)[j*2]; + + /* But what are we going to do with it? */ + + idx += pad_to_4byte(a->names[i].len); + } + } + else + { + /* get the 'real' name */ + CHECKINT32(idx, len); a->name = GETINT32(buf+idx); idx+= 4; + } + } + + /* + * Multi-value types and string/object/binary types have + * multiple values + */ + if (a->type & MULTI_VALUE_FLAG || + a->type == szMAPI_STRING || + a->type == szMAPI_UNICODE_STRING || + a->type == szMAPI_OBJECT || + a->type == szMAPI_BINARY) + { + CHECKINT32(idx, len); a->num_values = GETINT32(buf+idx); + idx += 4; + } + else + { + a->num_values = 1; + } + + /* Amend the type in case of multi-value type */ + if (a->type & MULTI_VALUE_FLAG) + { + a->type -= MULTI_VALUE_FLAG; + } + + + v = alloc_mapi_values (a); + + for (j = 0; j < a->num_values; j++) + { + switch (a->type) + { + case szMAPI_SHORT: /* 2 bytes */ + v->len = 2; + CHECKINT16(idx, len); v->data.bytes2 = GETINT16(buf+idx); + idx += 4; /* assume padding of 2, advance by 4! */ + break; + + case szMAPI_INT: /* 4 bytes */ + v->len = 4; + CHECKINT32(idx, len); v->data.bytes4 = GETINT32(buf+idx); + idx += 4; + v++; + break; + + case szMAPI_FLOAT: /* 4 bytes */ + case szMAPI_BOOLEAN: /* this should be 2 bytes + 2 padding */ + v->len = 4; + CHECKINT32(idx, len); v->data.bytes4 = GETINT32(buf+idx); + idx += v->len; + break; + + case szMAPI_SYSTIME: /* 8 bytes */ + v->len = 8; + CHECKINT32(idx, len); v->data.bytes8[0] = GETINT32(buf+idx); + CHECKINT32(idx+4, len); v->data.bytes8[1] = GETINT32(buf+idx+4); + idx += 8; + v++; + break; + + case szMAPI_DOUBLE: /* 8 bytes */ + case szMAPI_APPTIME: + case szMAPI_CURRENCY: + case szMAPI_INT8BYTE: + v->len = 8; + CHECKINT32(idx, len); v->data.bytes8[0] = GETINT32(buf+idx); + CHECKINT32(idx+4, len); v->data.bytes8[1] = GETINT32(buf+idx+4); + idx += v->len; + break; + + case szMAPI_CLSID: + v->len = sizeof (GUID); + copy_guid_from_buf(&v->data.guid, buf+idx, len); + idx += v->len; + break; + + case szMAPI_STRING: + case szMAPI_UNICODE_STRING: + case szMAPI_OBJECT: + case szMAPI_BINARY: + CHECKINT32(idx, len); v->len = GETINT32(buf+idx); idx += 4; + + assert(v->len + idx <= len); + + if (a->type == szMAPI_UNICODE_STRING) + { + assert(v->len != 0); + v->data.buf = (unsigned char*)unicode_to_utf8(v->len, buf+idx); + } + else + { + v->data.buf = CHECKED_XMALLOC(unsigned char, v->len); + memmove (v->data.buf, buf+idx, v->len); + } + + idx += pad_to_4byte(v->len); + v++; + break; + + case szMAPI_NULL: /* illegal in input tnef streams */ + case szMAPI_ERROR: + case szMAPI_UNSPECIFIED: + fprintf (stderr, + ""Invalid attribute, input file may be corrupted\n""); + if (!ENCODE_SKIP) exit (1); + + return NULL; + + default: /* should never get here */ + fprintf (stderr, + ""Undefined attribute, input file may be corrupted\n""); + if (!ENCODE_SKIP) exit (1); + + return NULL; + + } + if (DEBUG_ON) mapi_attr_dump (attrs[i]); + } + } + attrs[i] = NULL; + + return attrs; +} +","@@ -174,6 +174,7 @@ mapi_attr_read (size_t len, unsigned char *buf) + uint32 i,j; + assert(len > 4); + uint32 num_properties = GETINT32(buf+idx); ++ assert((num_properties+1) != 0); + MAPI_Attr** attrs = CHECKED_XMALLOC (MAPI_Attr*, (num_properties + 1)); + + idx += 4; +@@ -212,6 +213,7 @@ mapi_attr_read (size_t len, unsigned char *buf) + /* read the data into a buffer */ + a->names[i].data + = CHECKED_XMALLOC(unsigned char, a->names[i].len); ++ assert((idx+(a->names[i].len*2)) <= len); + for (j = 0; j < (a->names[i].len >> 1); j++) + a->names[i].data[j] = (buf+idx)[j*2]; + +@@ -308,8 +310,11 @@ mapi_attr_read (size_t len, unsigned char *buf) + case szMAPI_BINARY: + CHECKINT32(idx, len); v->len = GETINT32(buf+idx); idx += 4; + ++ assert(v->len + idx <= len); ++ + if (a->type == szMAPI_UNICODE_STRING) + { ++ assert(v->len != 0); + v->data.buf = (unsigned char*)unicode_to_utf8(v->len, buf+idx); + } + else",1486,1722,2048 +17957,"vsock_stream_recvmsg(struct kiocb *kiocb, + struct socket *sock, + struct msghdr *msg, size_t len, int flags) +{ + struct sock *sk; + struct vsock_sock *vsk; + int err; + size_t target; + ssize_t copied; + long timeout; + struct vsock_transport_recv_notify_data recv_data; + + DEFINE_WAIT(wait); + + sk = sock->sk; + vsk = vsock_sk(sk); + err = 0; + + msg->msg_namelen = 0; + lock_sock(sk); + + if (sk->sk_state != SS_CONNECTED) { + /* Recvmsg is supposed to return 0 if a peer performs an + * orderly shutdown. Differentiate between that case and when a + * peer has not connected or a local shutdown occured with the + * SOCK_DONE flag. + */ + if (sock_flag(sk, SOCK_DONE)) + err = 0; + else + err = -ENOTCONN; + + goto out; + } + + if (flags & MSG_OOB) { + err = -EOPNOTSUPP; + goto out; + } + + /* We don't check peer_shutdown flag here since peer may actually shut + * down, but there can be data in the queue that a local socket can + * receive. + */ + if (sk->sk_shutdown & RCV_SHUTDOWN) { + err = 0; + goto out; + } + + /* It is valid on Linux to pass in a zero-length receive buffer. This + * is not an error. We may as well bail out now. + */ + if (!len) { + err = 0; + goto out; + } + + /* We must not copy less than target bytes into the user's buffer + * before returning successfully, so we wait for the consume queue to + * have that much data to consume before dequeueing. Note that this + * makes it impossible to handle cases where target is greater than the + * queue size. + */ + target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); + if (target >= transport->stream_rcvhiwat(vsk)) { + err = -ENOMEM; + goto out; + } + timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); + copied = 0; + + err = transport->notify_recv_init(vsk, target, &recv_data); + if (err < 0) + goto out; + + prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); + + while (1) { + s64 ready = vsock_stream_has_data(vsk); + + if (ready < 0) { + /* Invalid queue pair content. XXX This should be + * changed to a connection reset in a later change. + */ + + err = -ENOMEM; + goto out_wait; + } else if (ready > 0) { + ssize_t read; + + err = transport->notify_recv_pre_dequeue( + vsk, target, &recv_data); + if (err < 0) + break; + + read = transport->stream_dequeue( + vsk, msg->msg_iov, + len - copied, flags); + if (read < 0) { + err = -ENOMEM; + break; + } + + copied += read; + + err = transport->notify_recv_post_dequeue( + vsk, target, read, + !(flags & MSG_PEEK), &recv_data); + if (err < 0) + goto out_wait; + + if (read >= target || flags & MSG_PEEK) + break; + + target -= read; + } else { + if (sk->sk_err != 0 || (sk->sk_shutdown & RCV_SHUTDOWN) + || (vsk->peer_shutdown & SEND_SHUTDOWN)) { + break; + } + /* Don't wait for non-blocking sockets. */ + if (timeout == 0) { + err = -EAGAIN; + break; + } + + err = transport->notify_recv_pre_block( + vsk, target, &recv_data); + if (err < 0) + break; + + release_sock(sk); + timeout = schedule_timeout(timeout); + lock_sock(sk); + + if (signal_pending(current)) { + err = sock_intr_errno(timeout); + break; + } else if (timeout == 0) { + err = -EAGAIN; + break; + } + + prepare_to_wait(sk_sleep(sk), &wait, + TASK_INTERRUPTIBLE); + } + } + + if (sk->sk_err) + err = -sk->sk_err; + else if (sk->sk_shutdown & RCV_SHUTDOWN) + err = 0; + + if (copied > 0) { + /* We only do these additional bookkeeping/notification steps + * if we actually copied something out of the queue pair + * instead of just peeking ahead. + */ + + if (!(flags & MSG_PEEK)) { + /* If the other side has shutdown for sending and there + * is nothing more to read, then modify the socket + * state. + */ + if (vsk->peer_shutdown & SEND_SHUTDOWN) { + if (vsock_stream_has_data(vsk) <= 0) { + sk->sk_state = SS_UNCONNECTED; + sock_set_flag(sk, SOCK_DONE); + sk->sk_state_change(sk); + } + } + } + err = copied; + } + +out_wait: + finish_wait(sk_sleep(sk), &wait); +out: + release_sock(sk); + return err; +} +",1,"vsock_stream_recvmsg(struct kiocb *kiocb, + struct socket *sock, + struct msghdr *msg, size_t len, int flags) +{ + struct sock *sk; + struct vsock_sock *vsk; + int err; + size_t target; + ssize_t copied; + long timeout; + struct vsock_transport_recv_notify_data recv_data; + + DEFINE_WAIT(wait); + + sk = sock->sk; + vsk = vsock_sk(sk); + err = 0; + + lock_sock(sk); + + if (sk->sk_state != SS_CONNECTED) { + /* Recvmsg is supposed to return 0 if a peer performs an + * orderly shutdown. Differentiate between that case and when a + * peer has not connected or a local shutdown occured with the + * SOCK_DONE flag. + */ + if (sock_flag(sk, SOCK_DONE)) + err = 0; + else + err = -ENOTCONN; + + goto out; + } + + if (flags & MSG_OOB) { + err = -EOPNOTSUPP; + goto out; + } + + /* We don't check peer_shutdown flag here since peer may actually shut + * down, but there can be data in the queue that a local socket can + * receive. + */ + if (sk->sk_shutdown & RCV_SHUTDOWN) { + err = 0; + goto out; + } + + /* It is valid on Linux to pass in a zero-length receive buffer. This + * is not an error. We may as well bail out now. + */ + if (!len) { + err = 0; + goto out; + } + + /* We must not copy less than target bytes into the user's buffer + * before returning successfully, so we wait for the consume queue to + * have that much data to consume before dequeueing. Note that this + * makes it impossible to handle cases where target is greater than the + * queue size. + */ + target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); + if (target >= transport->stream_rcvhiwat(vsk)) { + err = -ENOMEM; + goto out; + } + timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); + copied = 0; + + err = transport->notify_recv_init(vsk, target, &recv_data); + if (err < 0) + goto out; + + prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); + + while (1) { + s64 ready = vsock_stream_has_data(vsk); + + if (ready < 0) { + /* Invalid queue pair content. XXX This should be + * changed to a connection reset in a later change. + */ + + err = -ENOMEM; + goto out_wait; + } else if (ready > 0) { + ssize_t read; + + err = transport->notify_recv_pre_dequeue( + vsk, target, &recv_data); + if (err < 0) + break; + + read = transport->stream_dequeue( + vsk, msg->msg_iov, + len - copied, flags); + if (read < 0) { + err = -ENOMEM; + break; + } + + copied += read; + + err = transport->notify_recv_post_dequeue( + vsk, target, read, + !(flags & MSG_PEEK), &recv_data); + if (err < 0) + goto out_wait; + + if (read >= target || flags & MSG_PEEK) + break; + + target -= read; + } else { + if (sk->sk_err != 0 || (sk->sk_shutdown & RCV_SHUTDOWN) + || (vsk->peer_shutdown & SEND_SHUTDOWN)) { + break; + } + /* Don't wait for non-blocking sockets. */ + if (timeout == 0) { + err = -EAGAIN; + break; + } + + err = transport->notify_recv_pre_block( + vsk, target, &recv_data); + if (err < 0) + break; + + release_sock(sk); + timeout = schedule_timeout(timeout); + lock_sock(sk); + + if (signal_pending(current)) { + err = sock_intr_errno(timeout); + break; + } else if (timeout == 0) { + err = -EAGAIN; + break; + } + + prepare_to_wait(sk_sleep(sk), &wait, + TASK_INTERRUPTIBLE); + } + } + + if (sk->sk_err) + err = -sk->sk_err; + else if (sk->sk_shutdown & RCV_SHUTDOWN) + err = 0; + + if (copied > 0) { + /* We only do these additional bookkeeping/notification steps + * if we actually copied something out of the queue pair + * instead of just peeking ahead. + */ + + if (!(flags & MSG_PEEK)) { + /* If the other side has shutdown for sending and there + * is nothing more to read, then modify the socket + * state. + */ + if (vsk->peer_shutdown & SEND_SHUTDOWN) { + if (vsock_stream_has_data(vsk) <= 0) { + sk->sk_state = SS_UNCONNECTED; + sock_set_flag(sk, SOCK_DONE); + sk->sk_state_change(sk); + } + } + } + err = copied; + } + +out_wait: + finish_wait(sk_sleep(sk), &wait); +out: + release_sock(sk); + return err; +} +","@@ -1662,8 +1662,6 @@ vsock_stream_recvmsg(struct kiocb *kiocb, + vsk = vsock_sk(sk); + err = 0; + +- msg->msg_namelen = 0; +- + lock_sock(sk); + + if (sk->sk_state != SS_CONNECTED) {",1197,1433,2048 +1426,"gs_main_finit(gs_main_instance * minst, int exit_status, int code) +{ + i_ctx_t *i_ctx_p = minst->i_ctx_p; + int exit_code; + ref error_object; + char *tempnames; + + /* NB: need to free gs_name_table + */ + + /* + * Previous versions of this code closed the devices in the + * device list here. Since these devices are now prototypes, + * they cannot be opened, so they do not need to be closed; + * alloc_restore_all will close dynamically allocated devices. + */ + tempnames = gs_main_tempnames(minst); + +#ifndef PSI_INCLUDED + /* We have to disable BGPrint before we call interp_reclaim() to prevent the + * parent rendering thread initialising for the next page, whilst we are + * removing objects it may want to access - for example, the I/O device table. + * We also have to mess with the BeginPage/EndPage procs so that we don't + * trigger a spurious extra page to be emitted. + */ + if (minst->init_done >= 1) { + gs_main_run_string(minst, + ""/systemdict .systemexec /begin .systemexec \ + /BGPrint /GetDeviceParam .special_op \ + {{ <> setpagedevice} if} if \ + serverdict /.jobsavelevel get 0 eq {/quit} {/stop} ifelse end \ + .systemvar exec"", + 0 , &exit_code, &error_object); + } +#endif + + /* + * Close the ""main"" device, because it may need to write out + * data before destruction. pdfwrite needs so. + */ + if (minst->init_done >= 1) { + int code = 0; + + if (idmemory->reclaim != 0) { + code = interp_reclaim(&minst->i_ctx_p, avm_global); + + if (code < 0) { + ref error_name; + if (tempnames) + free(tempnames); + + if (gs_errorname(i_ctx_p, code, &error_name) >= 0) { + char err_str[32] = {0}; + name_string_ref(imemory, &error_name, &error_name); + memcpy(err_str, error_name.value.const_bytes, r_size(&error_name)); + emprintf2(imemory, ""ERROR: %s (%d) reclaiming the memory while the interpreter finalization.\n"", err_str, code); + } + else { + emprintf1(imemory, ""UNKNOWN ERROR %d reclaiming the memory while the interpreter finalization.\n"", code); + } + return gs_error_Fatal; + } + i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */ + } +#ifndef PSI_INCLUDED + if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) { + gx_device *pdev = i_ctx_p->pgs->device; + const char * dname = pdev->dname; + + /* make sure device doesn't isn't freed by .uninstalldevice */ + rc_adjust(pdev, 1, ""gs_main_finit""); + /* deactivate the device just before we close it for the last time */ + gs_main_run_string(minst, + /* we need to do the 'quit' so we don't loop for input (double quit) */ + "".uninstallpagedevice serverdict \ + /.jobsavelevel get 0 eq {/quit} {/stop} ifelse .systemvar exec"", + 0 , &exit_code, &error_object); + code = gs_closedevice(pdev); + if (code < 0) { + ref error_name; + if (gs_errorname(i_ctx_p, code, &error_name) >= 0) { + char err_str[32] = {0}; + name_string_ref(imemory, &error_name, &error_name); + memcpy(err_str, error_name.value.const_bytes, r_size(&error_name)); + emprintf3(imemory, ""ERROR: %s (%d) on closing %s device.\n"", err_str, code, dname); + } + else { + emprintf2(imemory, ""UNKNOWN ERROR %d closing %s device.\n"", code, dname); + } + } + rc_decrement(pdev, ""gs_main_finit""); /* device might be freed */ + if (exit_status == 0 || exit_status == gs_error_Quit) + exit_status = code; + } +#endif + } + /* Flush stdout and stderr */ + if (minst->init_done >= 2) + gs_main_run_string(minst, + ""(%stdout) (w) file closefile (%stderr) (w) file closefile \ + /systemdict .systemexec /begin .systemexec \ + serverdict /.jobsavelevel get 0 eq {/quit} {/stop} ifelse .systemexec \ + systemdict /savedinitialgstate .forceundef \ + end "", + 0 , &exit_code, &error_object); + gp_readline_finit(minst->readline_data); + i_ctx_p = minst->i_ctx_p; /* get current interp context */ + if (gs_debug_c(':')) { + print_resource_usage(minst, &gs_imemory, ""Final""); + dmprintf1(minst->heap, ""%% Exiting instance 0x%p\n"", minst); + } + /* Do the equivalent of a restore ""past the bottom"". */ + /* This will release all memory, close all open files, etc. */ + if (minst->init_done >= 1) { + gs_memory_t *mem_raw = i_ctx_p->memory.current->non_gc_memory; + i_plugin_holder *h = i_ctx_p->plugin_list; + code = alloc_restore_all(i_ctx_p); + if (code < 0) + emprintf1(mem_raw, + ""ERROR %d while the final restore. See gs/psi/ierrors.h for code explanation.\n"", + code); + i_plugin_finit(mem_raw, h); + } +#ifndef PSI_INCLUDED + /* clean up redirected stdout */ + if (minst->heap->gs_lib_ctx->fstdout2 + && (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstdout) + && (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstderr)) { + fclose(minst->heap->gs_lib_ctx->fstdout2); + minst->heap->gs_lib_ctx->fstdout2 = (FILE *)NULL; + } +#endif + minst->heap->gs_lib_ctx->stdout_is_redirected = 0; + minst->heap->gs_lib_ctx->stdout_to_stderr = 0; + /* remove any temporary files, after ghostscript has closed files */ + if (tempnames) { + char *p = tempnames; + while (*p) { + unlink(p); + p += strlen(p) + 1; + } + free(tempnames); + } +#ifndef PSI_INCLUDED + gs_lib_finit(exit_status, code, minst->heap); +#endif + return exit_status; +} +",0,"gs_main_finit(gs_main_instance * minst, int exit_status, int code) +{ + i_ctx_t *i_ctx_p = minst->i_ctx_p; + int exit_code; + ref error_object; + char *tempnames; + + /* NB: need to free gs_name_table + */ + + /* + * Previous versions of this code closed the devices in the + * device list here. Since these devices are now prototypes, + * they cannot be opened, so they do not need to be closed; + * alloc_restore_all will close dynamically allocated devices. + */ + tempnames = gs_main_tempnames(minst); + +#ifndef PSI_INCLUDED + /* We have to disable BGPrint before we call interp_reclaim() to prevent the + * parent rendering thread initialising for the next page, whilst we are + * removing objects it may want to access - for example, the I/O device table. + * We also have to mess with the BeginPage/EndPage procs so that we don't + * trigger a spurious extra page to be emitted. + */ + if (minst->init_done >= 1) { + gs_main_run_string(minst, + ""/systemdict .systemexec /begin .systemexec \ + /BGPrint /GetDeviceParam .special_op \ + {{ <> setpagedevice} if} if \ + serverdict /.jobsavelevel get 0 eq {/quit} {/stop} ifelse end \ + .systemvar exec"", + 0 , &exit_code, &error_object); + } +#endif + + /* + * Close the ""main"" device, because it may need to write out + * data before destruction. pdfwrite needs so. + */ + if (minst->init_done >= 1) { + int code = 0; + + if (idmemory->reclaim != 0) { + code = interp_reclaim(&minst->i_ctx_p, avm_global); + + if (code < 0) { + ref error_name; + if (tempnames) + free(tempnames); + + if (gs_errorname(i_ctx_p, code, &error_name) >= 0) { + char err_str[32] = {0}; + name_string_ref(imemory, &error_name, &error_name); + memcpy(err_str, error_name.value.const_bytes, r_size(&error_name)); + emprintf2(imemory, ""ERROR: %s (%d) reclaiming the memory while the interpreter finalization.\n"", err_str, code); + } + else { + emprintf1(imemory, ""UNKNOWN ERROR %d reclaiming the memory while the interpreter finalization.\n"", code); + } + return gs_error_Fatal; + } + i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */ + } +#ifndef PSI_INCLUDED + if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) { + gx_device *pdev = i_ctx_p->pgs->device; + const char * dname = pdev->dname; + + /* make sure device doesn't isn't freed by .uninstalldevice */ + rc_adjust(pdev, 1, ""gs_main_finit""); + /* deactivate the device just before we close it for the last time */ + gs_main_run_string(minst, + /* we need to do the 'quit' so we don't loop for input (double quit) */ + "".uninstallpagedevice serverdict \ + /.jobsavelevel get 0 eq {/quit} {/stop} ifelse .systemvar exec"", + 0 , &exit_code, &error_object); + code = gs_closedevice(pdev); + if (code < 0) { + ref error_name; + if (gs_errorname(i_ctx_p, code, &error_name) >= 0) { + char err_str[32] = {0}; + name_string_ref(imemory, &error_name, &error_name); + memcpy(err_str, error_name.value.const_bytes, r_size(&error_name)); + emprintf3(imemory, ""ERROR: %s (%d) on closing %s device.\n"", err_str, code, dname); + } + else { + emprintf2(imemory, ""UNKNOWN ERROR %d closing %s device.\n"", code, dname); + } + } + rc_decrement(pdev, ""gs_main_finit""); /* device might be freed */ + if (exit_status == 0 || exit_status == gs_error_Quit) + exit_status = code; + } +#endif + } + /* Flush stdout and stderr */ + if (minst->init_done >= 2) + gs_main_run_string(minst, + ""(%stdout) (w) file closefile (%stderr) (w) file closefile \ + /systemdict .systemexec /begin .systemexec \ + serverdict /.jobsavelevel get 0 eq {/quit} {/stop} ifelse .systemexec \ + systemdict /savedinitialgstate .forceundef \ + end "", + 0 , &exit_code, &error_object); + gp_readline_finit(minst->readline_data); + i_ctx_p = minst->i_ctx_p; /* get current interp context */ + if (gs_debug_c(':')) { + print_resource_usage(minst, &gs_imemory, ""Final""); + dmprintf1(minst->heap, ""%% Exiting instance 0x%p\n"", minst); + } + /* Do the equivalent of a restore ""past the bottom"". */ + /* This will release all memory, close all open files, etc. */ + if (minst->init_done >= 1) { + gs_memory_t *mem_raw = i_ctx_p->memory.current->non_gc_memory; + i_plugin_holder *h = i_ctx_p->plugin_list; + code = alloc_restore_all(i_ctx_p); + if (code < 0) + emprintf1(mem_raw, + ""ERROR %d while the final restore. See gs/psi/ierrors.h for code explanation.\n"", + code); + i_plugin_finit(mem_raw, h); + } +#ifndef PSI_INCLUDED + /* clean up redirected stdout */ + if (minst->heap->gs_lib_ctx->fstdout2 + && (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstdout) + && (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstderr)) { + fclose(minst->heap->gs_lib_ctx->fstdout2); + minst->heap->gs_lib_ctx->fstdout2 = (FILE *)NULL; + } +#endif + minst->heap->gs_lib_ctx->stdout_is_redirected = 0; + minst->heap->gs_lib_ctx->stdout_to_stderr = 0; + /* remove any temporary files, after ghostscript has closed files */ + if (tempnames) { + char *p = tempnames; + while (*p) { + unlink(p); + p += strlen(p) + 1; + } + free(tempnames); + } +#ifndef PSI_INCLUDED + gs_lib_finit(exit_status, code, minst->heap); +#endif + return exit_status; +} +","@@ -57,6 +57,7 @@ + #include ""ivmspace.h"" + #include ""idisp.h"" /* for setting display device callback */ + #include ""iplugin.h"" ++#include ""zfile.h"" + + #ifdef PACIFY_VALGRIND + #include ""valgrind.h"" +@@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) + ""the_gs_name_table""); + if (code < 0) + return code; ++ mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; + } + code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ + if (code < 0)",1576,1812,2048 +5916,"static ssize_t generic_perform_write_2copy(struct file *file, + struct iov_iter *i, loff_t pos) +{ + struct address_space *mapping = file->f_mapping; + const struct address_space_operations *a_ops = mapping->a_ops; + struct inode *inode = mapping->host; + long status = 0; + ssize_t written = 0; + + do { + struct page *src_page; + struct page *page; + pgoff_t index; /* Pagecache index for current page */ + unsigned long offset; /* Offset into pagecache page */ + unsigned long bytes; /* Bytes to write to page */ + size_t copied; /* Bytes copied from user */ + + offset = (pos & (PAGE_CACHE_SIZE - 1)); + index = pos >> PAGE_CACHE_SHIFT; + bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset, + iov_iter_count(i)); + + /* + * a non-NULL src_page indicates that we're doing the + * copy via get_user_pages and kmap. + */ + src_page = NULL; + + /* + * Bring in the user page that we will copy from _first_. + * Otherwise there's a nasty deadlock on copying from the + * same page as we're writing to, without it being marked + * up-to-date. + * + * Not only is this an optimisation, but it is also required + * to check that the address is actually valid, when atomic + * usercopies are used, below. + */ + if (unlikely(iov_iter_fault_in_readable(i, bytes))) { + status = -EFAULT; + break; + } + + page = __grab_cache_page(mapping, index); + if (!page) { + status = -ENOMEM; + break; + } + + /* + * non-uptodate pages cannot cope with short copies, and we + * cannot take a pagefault with the destination page locked. + * So pin the source page to copy it. + */ + if (!PageUptodate(page) && !segment_eq(get_fs(), KERNEL_DS)) { + unlock_page(page); + + src_page = alloc_page(GFP_KERNEL); + if (!src_page) { + page_cache_release(page); + status = -ENOMEM; + break; + } + + /* + * Cannot get_user_pages with a page locked for the + * same reason as we can't take a page fault with a + * page locked (as explained below). + */ + copied = iov_iter_copy_from_user(src_page, i, + offset, bytes); + if (unlikely(copied == 0)) { + status = -EFAULT; + page_cache_release(page); + page_cache_release(src_page); + break; + } + bytes = copied; + + lock_page(page); + /* + * Can't handle the page going uptodate here, because + * that means we would use non-atomic usercopies, which + * zero out the tail of the page, which can cause + * zeroes to become transiently visible. We could just + * use a non-zeroing copy, but the APIs aren't too + * consistent. + */ + if (unlikely(!page->mapping || PageUptodate(page))) { + unlock_page(page); + page_cache_release(page); + page_cache_release(src_page); + continue; + } + } + + status = a_ops->prepare_write(file, page, offset, offset+bytes); + if (unlikely(status)) + goto fs_write_aop_error; + + if (!src_page) { + /* + * Must not enter the pagefault handler here, because + * we hold the page lock, so we might recursively + * deadlock on the same lock, or get an ABBA deadlock + * against a different lock, or against the mmap_sem + * (which nests outside the page lock). So increment + * preempt count, and use _atomic usercopies. + * + * The page is uptodate so we are OK to encounter a + * short copy: if unmodified parts of the page are + * marked dirty and written out to disk, it doesn't + * really matter. + */ + pagefault_disable(); + copied = iov_iter_copy_from_user_atomic(page, i, + offset, bytes); + pagefault_enable(); + } else { + void *src, *dst; + src = kmap_atomic(src_page, KM_USER0); + dst = kmap_atomic(page, KM_USER1); + memcpy(dst + offset, src + offset, bytes); + kunmap_atomic(dst, KM_USER1); + kunmap_atomic(src, KM_USER0); + copied = bytes; + } + flush_dcache_page(page); + + status = a_ops->commit_write(file, page, offset, offset+bytes); + if (unlikely(status < 0)) + goto fs_write_aop_error; + if (unlikely(status > 0)) /* filesystem did partial write */ + copied = min_t(size_t, copied, status); + + unlock_page(page); + mark_page_accessed(page); + page_cache_release(page); + if (src_page) + page_cache_release(src_page); + + iov_iter_advance(i, copied); + pos += copied; + written += copied; + + balance_dirty_pages_ratelimited(mapping); + cond_resched(); + continue; + +fs_write_aop_error: + unlock_page(page); + page_cache_release(page); + if (src_page) + page_cache_release(src_page); + + /* + * prepare_write() may have instantiated a few blocks + * outside i_size. Trim these off again. Don't need + * i_size_read because we hold i_mutex. + */ + if (pos + bytes > inode->i_size) + vmtruncate(inode, inode->i_size); + break; + } while (iov_iter_count(i)); + + return written ? written : status; +} +",0,"static ssize_t generic_perform_write_2copy(struct file *file, + struct iov_iter *i, loff_t pos) +{ + struct address_space *mapping = file->f_mapping; + const struct address_space_operations *a_ops = mapping->a_ops; + struct inode *inode = mapping->host; + long status = 0; + ssize_t written = 0; + + do { + struct page *src_page; + struct page *page; + pgoff_t index; /* Pagecache index for current page */ + unsigned long offset; /* Offset into pagecache page */ + unsigned long bytes; /* Bytes to write to page */ + size_t copied; /* Bytes copied from user */ + + offset = (pos & (PAGE_CACHE_SIZE - 1)); + index = pos >> PAGE_CACHE_SHIFT; + bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset, + iov_iter_count(i)); + + /* + * a non-NULL src_page indicates that we're doing the + * copy via get_user_pages and kmap. + */ + src_page = NULL; + + /* + * Bring in the user page that we will copy from _first_. + * Otherwise there's a nasty deadlock on copying from the + * same page as we're writing to, without it being marked + * up-to-date. + * + * Not only is this an optimisation, but it is also required + * to check that the address is actually valid, when atomic + * usercopies are used, below. + */ + if (unlikely(iov_iter_fault_in_readable(i, bytes))) { + status = -EFAULT; + break; + } + + page = __grab_cache_page(mapping, index); + if (!page) { + status = -ENOMEM; + break; + } + + /* + * non-uptodate pages cannot cope with short copies, and we + * cannot take a pagefault with the destination page locked. + * So pin the source page to copy it. + */ + if (!PageUptodate(page) && !segment_eq(get_fs(), KERNEL_DS)) { + unlock_page(page); + + src_page = alloc_page(GFP_KERNEL); + if (!src_page) { + page_cache_release(page); + status = -ENOMEM; + break; + } + + /* + * Cannot get_user_pages with a page locked for the + * same reason as we can't take a page fault with a + * page locked (as explained below). + */ + copied = iov_iter_copy_from_user(src_page, i, + offset, bytes); + if (unlikely(copied == 0)) { + status = -EFAULT; + page_cache_release(page); + page_cache_release(src_page); + break; + } + bytes = copied; + + lock_page(page); + /* + * Can't handle the page going uptodate here, because + * that means we would use non-atomic usercopies, which + * zero out the tail of the page, which can cause + * zeroes to become transiently visible. We could just + * use a non-zeroing copy, but the APIs aren't too + * consistent. + */ + if (unlikely(!page->mapping || PageUptodate(page))) { + unlock_page(page); + page_cache_release(page); + page_cache_release(src_page); + continue; + } + } + + status = a_ops->prepare_write(file, page, offset, offset+bytes); + if (unlikely(status)) + goto fs_write_aop_error; + + if (!src_page) { + /* + * Must not enter the pagefault handler here, because + * we hold the page lock, so we might recursively + * deadlock on the same lock, or get an ABBA deadlock + * against a different lock, or against the mmap_sem + * (which nests outside the page lock). So increment + * preempt count, and use _atomic usercopies. + * + * The page is uptodate so we are OK to encounter a + * short copy: if unmodified parts of the page are + * marked dirty and written out to disk, it doesn't + * really matter. + */ + pagefault_disable(); + copied = iov_iter_copy_from_user_atomic(page, i, + offset, bytes); + pagefault_enable(); + } else { + void *src, *dst; + src = kmap_atomic(src_page, KM_USER0); + dst = kmap_atomic(page, KM_USER1); + memcpy(dst + offset, src + offset, bytes); + kunmap_atomic(dst, KM_USER1); + kunmap_atomic(src, KM_USER0); + copied = bytes; + } + flush_dcache_page(page); + + status = a_ops->commit_write(file, page, offset, offset+bytes); + if (unlikely(status < 0)) + goto fs_write_aop_error; + if (unlikely(status > 0)) /* filesystem did partial write */ + copied = min_t(size_t, copied, status); + + unlock_page(page); + mark_page_accessed(page); + page_cache_release(page); + if (src_page) + page_cache_release(src_page); + + iov_iter_advance(i, copied); + pos += copied; + written += copied; + + balance_dirty_pages_ratelimited(mapping); + cond_resched(); + continue; + +fs_write_aop_error: + unlock_page(page); + page_cache_release(page); + if (src_page) + page_cache_release(src_page); + + /* + * prepare_write() may have instantiated a few blocks + * outside i_size. Trim these off again. Don't need + * i_size_read because we hold i_mutex. + */ + if (pos + bytes > inode->i_size) + vmtruncate(inode, inode->i_size); + break; + } while (iov_iter_count(i)); + + return written ? written : status; +} +","@@ -1750,7 +1750,11 @@ static void __iov_iter_advance_iov(struct iov_iter *i, size_t bytes) + const struct iovec *iov = i->iov; + size_t base = i->iov_offset; + +- while (bytes) { ++ /* ++ * The !iov->iov_len check ensures we skip over unlikely ++ * zero-length segments. ++ */ ++ while (bytes || !iov->iov_len) { + int copy = min(bytes, iov->iov_len - base); + + bytes -= copy; +@@ -2268,6 +2272,7 @@ static ssize_t generic_perform_write(struct file *file, + + cond_resched(); + ++ iov_iter_advance(i, copied); + if (unlikely(copied == 0)) { + /* + * If we were unable to copy any data at all, we must +@@ -2281,7 +2286,6 @@ static ssize_t generic_perform_write(struct file *file, + iov_iter_single_seg_count(i)); + goto again; + } +- iov_iter_advance(i, copied); + pos += copied; + written += copied; + ",1267,1503,2048 +17788,"datum_to_json(Datum val, bool is_null, StringInfo result, + JsonTypeCategory tcategory, Oid outfuncoid, + bool key_scalar) +{ + char *outputstr; + text *jsontext; + + /* callers are expected to ensure that null keys are not passed in */ + char *outputstr; + text *jsontext; + + /* callers are expected to ensure that null keys are not passed in */ + Assert(!(key_scalar && is_null)); + + if (key_scalar && + (tcategory == JSONTYPE_ARRAY || + tcategory == JSONTYPE_COMPOSITE || + tcategory == JSONTYPE_JSON || + tcategory == JSONTYPE_CAST)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg(""key value must be scalar, not array, composite, or json""))); + + switch (tcategory) + { + case JSONTYPE_ARRAY: + array_to_json_internal(val, result, false); + break; + case JSONTYPE_COMPOSITE: + composite_to_json(val, result, false); + break; + case JSONTYPE_BOOL: + outputstr = DatumGetBool(val) ? ""true"" : ""false""; + if (key_scalar) + escape_json(result, outputstr); + else + appendStringInfoString(result, outputstr); + break; + case JSONTYPE_NUMERIC: + outputstr = OidOutputFunctionCall(outfuncoid, val); + + /* + * Don't call escape_json for a non-key if it's a valid JSON + * number. + */ + if (!key_scalar && IsValidJsonNumber(outputstr, strlen(outputstr))) + appendStringInfoString(result, outputstr); + else + escape_json(result, outputstr); + pfree(outputstr); + break; + case JSONTYPE_DATE: + { + DateADT date; + struct pg_tm tm; + char buf[MAXDATELEN + 1]; + + date = DatumGetDateADT(val); + + if (DATE_NOT_FINITE(date)) + { + /* we have to format infinity ourselves */ + appendStringInfoString(result, DT_INFINITY); + } + else + { + j2date(date + POSTGRES_EPOCH_JDATE, + &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday)); + EncodeDateOnly(&tm, USE_XSD_DATES, buf); + appendStringInfo(result, ""\""%s\"""", buf); + } + } + break; + case JSONTYPE_TIMESTAMP: + { + Timestamp timestamp; + struct pg_tm tm; + fsec_t fsec; + char buf[MAXDATELEN + 1]; + + timestamp = DatumGetTimestamp(val); + + if (TIMESTAMP_NOT_FINITE(timestamp)) + { + /* we have to format infinity ourselves */ + appendStringInfoString(result, DT_INFINITY); + } + else if (timestamp2tm(timestamp, NULL, &tm, &fsec, NULL, NULL) == 0) + { + EncodeDateTime(&tm, fsec, false, 0, NULL, USE_XSD_DATES, buf); + appendStringInfo(result, ""\""%s\"""", buf); + } + else + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg(""timestamp out of range""))); + } + break; + case JSONTYPE_TIMESTAMPTZ: + { + TimestampTz timestamp; + struct pg_tm tm; + int tz; + fsec_t fsec; + const char *tzn = NULL; + char buf[MAXDATELEN + 1]; + + timestamp = DatumGetTimestamp(val); + + if (TIMESTAMP_NOT_FINITE(timestamp)) + { + /* we have to format infinity ourselves */ + appendStringInfoString(result, DT_INFINITY); + } + else if (timestamp2tm(timestamp, &tz, &tm, &fsec, &tzn, NULL) == 0) + { + EncodeDateTime(&tm, fsec, true, tz, tzn, USE_XSD_DATES, buf); + appendStringInfo(result, ""\""%s\"""", buf); + } + else + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg(""timestamp out of range""))); + } + break; + case JSONTYPE_JSON: + /* JSON and JSONB output will already be escaped */ + outputstr = OidOutputFunctionCall(outfuncoid, val); + appendStringInfoString(result, outputstr); + pfree(outputstr); + break; + case JSONTYPE_CAST: + /* outfuncoid refers to a cast function, not an output function */ + jsontext = DatumGetTextP(OidFunctionCall1(outfuncoid, val)); + outputstr = text_to_cstring(jsontext); + appendStringInfoString(result, outputstr); + pfree(outputstr); + pfree(jsontext); + break; + default: + outputstr = OidOutputFunctionCall(outfuncoid, val); + escape_json(result, outputstr); + pfree(outputstr); + break; + } +} +",1,"datum_to_json(Datum val, bool is_null, StringInfo result, + JsonTypeCategory tcategory, Oid outfuncoid, + bool key_scalar) +{ + char *outputstr; + text *jsontext; + + /* callers are expected to ensure that null keys are not passed in */ + char *outputstr; + text *jsontext; + + check_stack_depth(); + + /* callers are expected to ensure that null keys are not passed in */ + Assert(!(key_scalar && is_null)); + + if (key_scalar && + (tcategory == JSONTYPE_ARRAY || + tcategory == JSONTYPE_COMPOSITE || + tcategory == JSONTYPE_JSON || + tcategory == JSONTYPE_CAST)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg(""key value must be scalar, not array, composite, or json""))); + + switch (tcategory) + { + case JSONTYPE_ARRAY: + array_to_json_internal(val, result, false); + break; + case JSONTYPE_COMPOSITE: + composite_to_json(val, result, false); + break; + case JSONTYPE_BOOL: + outputstr = DatumGetBool(val) ? ""true"" : ""false""; + if (key_scalar) + escape_json(result, outputstr); + else + appendStringInfoString(result, outputstr); + break; + case JSONTYPE_NUMERIC: + outputstr = OidOutputFunctionCall(outfuncoid, val); + + /* + * Don't call escape_json for a non-key if it's a valid JSON + * number. + */ + if (!key_scalar && IsValidJsonNumber(outputstr, strlen(outputstr))) + appendStringInfoString(result, outputstr); + else + escape_json(result, outputstr); + pfree(outputstr); + break; + case JSONTYPE_DATE: + { + DateADT date; + struct pg_tm tm; + char buf[MAXDATELEN + 1]; + + date = DatumGetDateADT(val); + + if (DATE_NOT_FINITE(date)) + { + /* we have to format infinity ourselves */ + appendStringInfoString(result, DT_INFINITY); + } + else + { + j2date(date + POSTGRES_EPOCH_JDATE, + &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday)); + EncodeDateOnly(&tm, USE_XSD_DATES, buf); + appendStringInfo(result, ""\""%s\"""", buf); + } + } + break; + case JSONTYPE_TIMESTAMP: + { + Timestamp timestamp; + struct pg_tm tm; + fsec_t fsec; + char buf[MAXDATELEN + 1]; + + timestamp = DatumGetTimestamp(val); + + if (TIMESTAMP_NOT_FINITE(timestamp)) + { + /* we have to format infinity ourselves */ + appendStringInfoString(result, DT_INFINITY); + } + else if (timestamp2tm(timestamp, NULL, &tm, &fsec, NULL, NULL) == 0) + { + EncodeDateTime(&tm, fsec, false, 0, NULL, USE_XSD_DATES, buf); + appendStringInfo(result, ""\""%s\"""", buf); + } + else + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg(""timestamp out of range""))); + } + break; + case JSONTYPE_TIMESTAMPTZ: + { + TimestampTz timestamp; + struct pg_tm tm; + int tz; + fsec_t fsec; + const char *tzn = NULL; + char buf[MAXDATELEN + 1]; + + timestamp = DatumGetTimestamp(val); + + if (TIMESTAMP_NOT_FINITE(timestamp)) + { + /* we have to format infinity ourselves */ + appendStringInfoString(result, DT_INFINITY); + } + else if (timestamp2tm(timestamp, &tz, &tm, &fsec, &tzn, NULL) == 0) + { + EncodeDateTime(&tm, fsec, true, tz, tzn, USE_XSD_DATES, buf); + appendStringInfo(result, ""\""%s\"""", buf); + } + else + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg(""timestamp out of range""))); + } + break; + case JSONTYPE_JSON: + /* JSON and JSONB output will already be escaped */ + outputstr = OidOutputFunctionCall(outfuncoid, val); + appendStringInfoString(result, outputstr); + pfree(outputstr); + break; + case JSONTYPE_CAST: + /* outfuncoid refers to a cast function, not an output function */ + jsontext = DatumGetTextP(OidFunctionCall1(outfuncoid, val)); + outputstr = text_to_cstring(jsontext); + appendStringInfoString(result, outputstr); + pfree(outputstr); + pfree(jsontext); + break; + default: + outputstr = OidOutputFunctionCall(outfuncoid, val); + escape_json(result, outputstr); + pfree(outputstr); + break; + } +} +","@@ -490,6 +490,8 @@ parse_object(JsonLexContext *lex, JsonSemAction *sem) + json_struct_action oend = sem->object_end; + JsonTokenType tok; + ++ check_stack_depth(); ++ + if (ostart != NULL) + (*ostart) (sem->semstate); + +@@ -568,6 +570,8 @@ parse_array(JsonLexContext *lex, JsonSemAction *sem) + json_struct_action astart = sem->array_start; + json_struct_action aend = sem->array_end; + ++ check_stack_depth(); ++ + if (astart != NULL) + (*astart) (sem->semstate); + +@@ -1433,6 +1437,8 @@ datum_to_json(Datum val, bool is_null, StringInfo result, + char *outputstr; + text *jsontext; + ++ check_stack_depth(); ++ + /* callers are expected to ensure that null keys are not passed in */ + Assert(!(key_scalar && is_null)); + ",1099,1335,2048 +8126,"void xinfoCommand(client *c) { + const char *help[] = { +""CONSUMERS -- Show consumer groups of group ."", +""GROUPS -- Show the stream consumer groups."", +""STREAM -- Show information about the stream."", +""HELP -- Print this help."", +NULL + }; + stream *s = NULL; + char *opt; + robj *key; + + /* HELP is special. Handle it ASAP. */ + if (!strcasecmp(c->argv[1]->ptr,""HELP"")) { + addReplyHelp(c, help); + return; + } else if (c->argc < 3) { + addReplyError(c,""syntax error, try 'XINFO HELP'""); + return; + } + + /* With the exception of HELP handled before any other sub commands, all + * the ones are in the form of "" "". */ + opt = c->argv[1]->ptr; + key = c->argv[2]; + + /* Lookup the key now, this is common for all the subcommands but HELP. */ + robj *o = lookupKeyWriteOrReply(c,key,shared.nokeyerr); + if (o == NULL) return; + s = o->ptr; + + /* Dispatch the different subcommands. */ + if (!strcasecmp(opt,""CONSUMERS"") && c->argc == 4) { + /* XINFO CONSUMERS . */ + streamCG *cg = streamLookupCG(s,c->argv[3]->ptr); + if (cg == NULL) { + addReplyErrorFormat(c, ""-NOGROUP No such consumer group '%s' "" + ""for key name '%s'"", + (char*)c->argv[3]->ptr, (char*)key->ptr); + return; + } + + addReplyMultiBulkLen(c,raxSize(cg->consumers)); + raxIterator ri; + raxStart(&ri,cg->consumers); + raxSeek(&ri,""^"",NULL,0); + mstime_t now = mstime(); + while(raxNext(&ri)) { + streamConsumer *consumer = ri.data; + mstime_t idle = now - consumer->seen_time; + if (idle < 0) idle = 0; + + addReplyMultiBulkLen(c,6); + addReplyStatus(c,""name""); + addReplyBulkCBuffer(c,consumer->name,sdslen(consumer->name)); + addReplyStatus(c,""pending""); + addReplyLongLong(c,raxSize(consumer->pel)); + addReplyStatus(c,""idle""); + addReplyLongLong(c,idle); + } + raxStop(&ri); + } else if (!strcasecmp(opt,""GROUPS"") && c->argc == 3) { + /* XINFO GROUPS . */ + if (s->cgroups == NULL) { + addReplyMultiBulkLen(c,0); + return; + } + + addReplyMultiBulkLen(c,raxSize(s->cgroups)); + raxIterator ri; + raxStart(&ri,s->cgroups); + raxSeek(&ri,""^"",NULL,0); + while(raxNext(&ri)) { + streamCG *cg = ri.data; + addReplyMultiBulkLen(c,6); + addReplyStatus(c,""name""); + addReplyBulkCBuffer(c,ri.key,ri.key_len); + addReplyStatus(c,""consumers""); + addReplyLongLong(c,raxSize(cg->consumers)); + addReplyStatus(c,""pending""); + addReplyLongLong(c,raxSize(cg->pel)); + } + raxStop(&ri); + } else if (!strcasecmp(opt,""STREAM"") && c->argc == 3) { + /* XINFO STREAM (or the alias XINFO ). */ + addReplyMultiBulkLen(c,12); + addReplyStatus(c,""length""); + addReplyLongLong(c,s->length); + addReplyStatus(c,""radix-tree-keys""); + addReplyLongLong(c,raxSize(s->rax)); + addReplyStatus(c,""radix-tree-nodes""); + addReplyLongLong(c,s->rax->numnodes); + addReplyStatus(c,""groups""); + addReplyLongLong(c,s->cgroups ? raxSize(s->cgroups) : 0); + + /* To emit the first/last entry we us the streamReplyWithRange() + * API. */ + int count; + streamID start, end; + start.ms = start.seq = 0; + end.ms = end.seq = UINT64_MAX; + addReplyStatus(c,""first-entry""); + count = streamReplyWithRange(c,s,&start,&end,1,0,NULL,NULL, + STREAM_RWR_RAWENTRIES,NULL); + if (!count) addReply(c,shared.nullbulk); + addReplyStatus(c,""last-entry""); + count = streamReplyWithRange(c,s,&start,&end,1,1,NULL,NULL, + STREAM_RWR_RAWENTRIES,NULL); + if (!count) addReply(c,shared.nullbulk); + } else { + addReplyError(c,""syntax error, try 'XINFO HELP'""); + } +} +",0,"void xinfoCommand(client *c) { + const char *help[] = { +""CONSUMERS -- Show consumer groups of group ."", +""GROUPS -- Show the stream consumer groups."", +""STREAM -- Show information about the stream."", +""HELP -- Print this help."", +NULL + }; + stream *s = NULL; + char *opt; + robj *key; + + /* HELP is special. Handle it ASAP. */ + if (!strcasecmp(c->argv[1]->ptr,""HELP"")) { + addReplyHelp(c, help); + return; + } else if (c->argc < 3) { + addReplyError(c,""syntax error, try 'XINFO HELP'""); + return; + } + + /* With the exception of HELP handled before any other sub commands, all + * the ones are in the form of "" "". */ + opt = c->argv[1]->ptr; + key = c->argv[2]; + + /* Lookup the key now, this is common for all the subcommands but HELP. */ + robj *o = lookupKeyWriteOrReply(c,key,shared.nokeyerr); + if (o == NULL) return; + s = o->ptr; + + /* Dispatch the different subcommands. */ + if (!strcasecmp(opt,""CONSUMERS"") && c->argc == 4) { + /* XINFO CONSUMERS . */ + streamCG *cg = streamLookupCG(s,c->argv[3]->ptr); + if (cg == NULL) { + addReplyErrorFormat(c, ""-NOGROUP No such consumer group '%s' "" + ""for key name '%s'"", + (char*)c->argv[3]->ptr, (char*)key->ptr); + return; + } + + addReplyMultiBulkLen(c,raxSize(cg->consumers)); + raxIterator ri; + raxStart(&ri,cg->consumers); + raxSeek(&ri,""^"",NULL,0); + mstime_t now = mstime(); + while(raxNext(&ri)) { + streamConsumer *consumer = ri.data; + mstime_t idle = now - consumer->seen_time; + if (idle < 0) idle = 0; + + addReplyMultiBulkLen(c,6); + addReplyStatus(c,""name""); + addReplyBulkCBuffer(c,consumer->name,sdslen(consumer->name)); + addReplyStatus(c,""pending""); + addReplyLongLong(c,raxSize(consumer->pel)); + addReplyStatus(c,""idle""); + addReplyLongLong(c,idle); + } + raxStop(&ri); + } else if (!strcasecmp(opt,""GROUPS"") && c->argc == 3) { + /* XINFO GROUPS . */ + if (s->cgroups == NULL) { + addReplyMultiBulkLen(c,0); + return; + } + + addReplyMultiBulkLen(c,raxSize(s->cgroups)); + raxIterator ri; + raxStart(&ri,s->cgroups); + raxSeek(&ri,""^"",NULL,0); + while(raxNext(&ri)) { + streamCG *cg = ri.data; + addReplyMultiBulkLen(c,6); + addReplyStatus(c,""name""); + addReplyBulkCBuffer(c,ri.key,ri.key_len); + addReplyStatus(c,""consumers""); + addReplyLongLong(c,raxSize(cg->consumers)); + addReplyStatus(c,""pending""); + addReplyLongLong(c,raxSize(cg->pel)); + } + raxStop(&ri); + } else if (!strcasecmp(opt,""STREAM"") && c->argc == 3) { + /* XINFO STREAM (or the alias XINFO ). */ + addReplyMultiBulkLen(c,12); + addReplyStatus(c,""length""); + addReplyLongLong(c,s->length); + addReplyStatus(c,""radix-tree-keys""); + addReplyLongLong(c,raxSize(s->rax)); + addReplyStatus(c,""radix-tree-nodes""); + addReplyLongLong(c,s->rax->numnodes); + addReplyStatus(c,""groups""); + addReplyLongLong(c,s->cgroups ? raxSize(s->cgroups) : 0); + + /* To emit the first/last entry we us the streamReplyWithRange() + * API. */ + int count; + streamID start, end; + start.ms = start.seq = 0; + end.ms = end.seq = UINT64_MAX; + addReplyStatus(c,""first-entry""); + count = streamReplyWithRange(c,s,&start,&end,1,0,NULL,NULL, + STREAM_RWR_RAWENTRIES,NULL); + if (!count) addReply(c,shared.nullbulk); + addReplyStatus(c,""last-entry""); + count = streamReplyWithRange(c,s,&start,&end,1,1,NULL,NULL, + STREAM_RWR_RAWENTRIES,NULL); + if (!count) addReply(c,shared.nullbulk); + } else { + addReplyError(c,""syntax error, try 'XINFO HELP'""); + } +} +","@@ -1576,7 +1576,7 @@ NULL + /* Lookup the key now, this is common for all the subcommands but HELP. */ + if (c->argc >= 4) { + robj *o = lookupKeyWriteOrReply(c,c->argv[2],shared.nokeyerr); +- if (o == NULL) return; ++ if (o == NULL || checkType(c,o,OBJ_STREAM)) return; + s = o->ptr; + grpname = c->argv[3]->ptr; + ",1109,1345,2048 +978,"static NOINLINE void ntp_init(char **argv) +{ + unsigned opts; + llist_t *peers; + + srand(getpid()); + + if (getuid()) + bb_error_msg_and_die(bb_msg_you_must_be_root); + + /* Set some globals */ + G.discipline_jitter = G_precision_sec; + G.stratum = MAXSTRAT; + if (BURSTPOLL != 0) + G.poll_exp = BURSTPOLL; /* speeds up initial sync */ + G.last_script_run = G.reftime = G.last_update_recv_time = gettime1900d(); /* sets G.cur_time too */ + + /* Parse options */ + peers = NULL; + opt_complementary = ""dd:wn"" /* -d: counter; -p: list; -w implies -n */ + IF_FEATURE_NTPD_SERVER("":Il""); /* -I implies -l */ + opts = getopt32(argv, + ""nqNx"" /* compat */ + ""wp:*S:""IF_FEATURE_NTPD_SERVER(""l"") /* NOT compat */ + IF_FEATURE_NTPD_SERVER(""I:"") /* compat */ + ""d"" /* compat */ + ""46aAbgL"", /* compat, ignored */ + &peers,&G.script_name, +#if ENABLE_FEATURE_NTPD_SERVER + &G.if_name, +#endif + &G.verbose); + + +#if ENABLE_FEATURE_NTPD_SERVER + G_listen_fd = -1; + if (opts & OPT_l) { + G_listen_fd = create_and_bind_dgram_or_die(NULL, 123); + if (G.if_name) { + if (setsockopt_bindtodevice(G_listen_fd, G.if_name)) + xfunc_die(); + } + socket_want_pktinfo(G_listen_fd); + setsockopt_int(G_listen_fd, IPPROTO_IP, IP_TOS, IPTOS_LOWDELAY); + } +#endif + /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */ + if (opts & OPT_N) + setpriority(PRIO_PROCESS, 0, -15); + + /* add_peers() calls can retry DNS resolution (possibly forever). + * Daemonize before them, or else boot can stall forever. + */ + if (!(opts & OPT_n)) { + bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv); + logmode = LOGMODE_NONE; + } + + if (peers) { + while (peers) + add_peers(llist_pop(&peers)); + } +#if ENABLE_FEATURE_NTPD_CONF + else { + parser_t *parser; + char *token[3]; + + parser = config_open(""/etc/ntp.conf""); + while (config_read(parser, token, 3, 1, ""# \t"", PARSE_NORMAL)) { + if (strcmp(token[0], ""server"") == 0 && token[1]) { + add_peers(token[1]); + continue; + } + bb_error_msg(""skipping %s:%u: unimplemented command '%s'"", + ""/etc/ntp.conf"", parser->lineno, token[0] + ); + } + config_close(parser); + } +#endif + if (G.peer_cnt == 0) { + if (!(opts & OPT_l)) + bb_show_usage(); + /* -l but no peers: ""stratum 1 server"" mode */ + G.stratum = 1; + } + /* If network is up, syncronization occurs in ~10 seconds. + * We give ""ntpd -q"" 10 seconds to get first reply, + * then another 50 seconds to finish syncing. + * + * I tested ntpd 4.2.6p1 and apparently it never exits + * (will try forever), but it does not feel right. + * The goal of -q is to act like ntpdate: set time + * after a reasonably small period of polling, or fail. + */ + if (opts & OPT_q) { + option_mask32 |= OPT_qq; + alarm(10); + } + + bb_signals(0 + | (1 << SIGTERM) + | (1 << SIGINT) + | (1 << SIGALRM) + , record_signo + ); + bb_signals(0 + | (1 << SIGPIPE) + | (1 << SIGCHLD) + , SIG_IGN + ); +} +",0,"static NOINLINE void ntp_init(char **argv) +{ + unsigned opts; + llist_t *peers; + + srand(getpid()); + + if (getuid()) + bb_error_msg_and_die(bb_msg_you_must_be_root); + + /* Set some globals */ + G.discipline_jitter = G_precision_sec; + G.stratum = MAXSTRAT; + if (BURSTPOLL != 0) + G.poll_exp = BURSTPOLL; /* speeds up initial sync */ + G.last_script_run = G.reftime = G.last_update_recv_time = gettime1900d(); /* sets G.cur_time too */ + + /* Parse options */ + peers = NULL; + opt_complementary = ""dd:wn"" /* -d: counter; -p: list; -w implies -n */ + IF_FEATURE_NTPD_SERVER("":Il""); /* -I implies -l */ + opts = getopt32(argv, + ""nqNx"" /* compat */ + ""wp:*S:""IF_FEATURE_NTPD_SERVER(""l"") /* NOT compat */ + IF_FEATURE_NTPD_SERVER(""I:"") /* compat */ + ""d"" /* compat */ + ""46aAbgL"", /* compat, ignored */ + &peers,&G.script_name, +#if ENABLE_FEATURE_NTPD_SERVER + &G.if_name, +#endif + &G.verbose); + + +#if ENABLE_FEATURE_NTPD_SERVER + G_listen_fd = -1; + if (opts & OPT_l) { + G_listen_fd = create_and_bind_dgram_or_die(NULL, 123); + if (G.if_name) { + if (setsockopt_bindtodevice(G_listen_fd, G.if_name)) + xfunc_die(); + } + socket_want_pktinfo(G_listen_fd); + setsockopt_int(G_listen_fd, IPPROTO_IP, IP_TOS, IPTOS_LOWDELAY); + } +#endif + /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */ + if (opts & OPT_N) + setpriority(PRIO_PROCESS, 0, -15); + + /* add_peers() calls can retry DNS resolution (possibly forever). + * Daemonize before them, or else boot can stall forever. + */ + if (!(opts & OPT_n)) { + bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv); + logmode = LOGMODE_NONE; + } + + if (peers) { + while (peers) + add_peers(llist_pop(&peers)); + } +#if ENABLE_FEATURE_NTPD_CONF + else { + parser_t *parser; + char *token[3]; + + parser = config_open(""/etc/ntp.conf""); + while (config_read(parser, token, 3, 1, ""# \t"", PARSE_NORMAL)) { + if (strcmp(token[0], ""server"") == 0 && token[1]) { + add_peers(token[1]); + continue; + } + bb_error_msg(""skipping %s:%u: unimplemented command '%s'"", + ""/etc/ntp.conf"", parser->lineno, token[0] + ); + } + config_close(parser); + } +#endif + if (G.peer_cnt == 0) { + if (!(opts & OPT_l)) + bb_show_usage(); + /* -l but no peers: ""stratum 1 server"" mode */ + G.stratum = 1; + } + /* If network is up, syncronization occurs in ~10 seconds. + * We give ""ntpd -q"" 10 seconds to get first reply, + * then another 50 seconds to finish syncing. + * + * I tested ntpd 4.2.6p1 and apparently it never exits + * (will try forever), but it does not feel right. + * The goal of -q is to act like ntpdate: set time + * after a reasonably small period of polling, or fail. + */ + if (opts & OPT_q) { + option_mask32 |= OPT_qq; + alarm(10); + } + + bb_signals(0 + | (1 << SIGTERM) + | (1 << SIGINT) + | (1 << SIGALRM) + , record_signo + ); + bb_signals(0 + | (1 << SIGPIPE) + | (1 << SIGCHLD) + , SIG_IGN + ); +} +","@@ -2051,6 +2051,13 @@ recv_and_process_client_pkt(void /*int fd*/) + goto bail; + } + ++ /* Respond only to client and symmetric active packets */ ++ if ((msg.m_status & MODE_MASK) != MODE_CLIENT ++ && (msg.m_status & MODE_MASK) != MODE_SYM_ACT ++ ) { ++ goto bail; ++ } ++ + query_status = msg.m_status; + query_xmttime = msg.m_xmttime;",951,1187,2048 +16368,"void RenderThreadImpl::RequestNewLayerTreeFrameSink( + int routing_id, + scoped_refptr frame_swap_message_queue, + const GURL& url, + const LayerTreeFrameSinkCallback& callback) { + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + + viz::ClientLayerTreeFrameSink::InitParams params; + params.enable_surface_synchronization = + command_line.HasSwitch(switches::kEnableSurfaceSynchronization); + params.local_surface_id_provider = + std::make_unique(); + + if (command_line.HasSwitch(switches::kDisableGpuVsync) && + command_line.GetSwitchValueASCII(switches::kDisableGpuVsync) != ""gpu"") { + params.synthetic_begin_frame_source = CreateSyntheticBeginFrameSource(); + } + +#if defined(USE_AURA) + if (IsRunningInMash()) { + if (!RendererWindowTreeClient::Get(routing_id)) { + callback.Run(nullptr); + return; + } + bool connection_error = false; + scoped_refptr channel = + EstablishGpuChannelSync(&connection_error); + if (connection_error) + return; + if (!channel) { + callback.Run(nullptr); + return; + } + RendererWindowTreeClient::Get(routing_id) + ->RequestLayerTreeFrameSink( + gpu_->CreateContextProvider(std::move(channel)), + GetGpuMemoryBufferManager(), callback); + return; + } +#endif + + viz::mojom::CompositorFrameSinkRequest sink_request = + mojo::MakeRequest(¶ms.pipes.compositor_frame_sink_info); + viz::mojom::CompositorFrameSinkClientPtr client; + params.pipes.client_request = mojo::MakeRequest(&client); + + if (command_line.HasSwitch(switches::kEnableVulkan)) { + scoped_refptr vulkan_context_provider = + viz::VulkanInProcessContextProvider::Create(); + if (vulkan_context_provider) { + DCHECK(!layout_test_mode()); + frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), + std::move(client)); + callback.Run(std::make_unique( + std::move(vulkan_context_provider), ¶ms)); + return; + } + } + + if (is_gpu_compositing_disabled_) { + DCHECK(!layout_test_mode()); + frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), + std::move(client)); + params.shared_bitmap_manager = shared_bitmap_manager(); + callback.Run(std::make_unique( + nullptr, nullptr, ¶ms)); + return; + } + + bool connection_error = false; + scoped_refptr gpu_channel_host = + EstablishGpuChannelSync(&connection_error); + if (connection_error) + return; + if (!gpu_channel_host) { + callback.Run(nullptr); + return; + } + + scoped_refptr worker_context_provider = + SharedCompositorWorkerContextProvider(); + if (!worker_context_provider) { + callback.Run(nullptr); + return; + } + + gpu::SharedMemoryLimits limits = gpu::SharedMemoryLimits::ForMailboxContext(); + + gpu::gles2::ContextCreationAttribHelper attributes; + attributes.alpha_size = -1; + attributes.depth_size = 0; + attributes.stencil_size = 0; + attributes.samples = 0; + attributes.sample_buffers = 0; + attributes.bind_generates_resource = false; + attributes.lose_context_when_out_of_memory = true; + + constexpr bool automatic_flushes = false; + constexpr bool support_locking = false; + + ui::ContextProviderCommandBuffer* share_context = + worker_context_provider.get(); + if (IsAsyncWorkerContextEnabled()) + share_context = nullptr; + + scoped_refptr context_provider( + new ui::ContextProviderCommandBuffer( + gpu_channel_host, kGpuStreamIdDefault, kGpuStreamPriorityDefault, + gpu::kNullSurfaceHandle, url, automatic_flushes, support_locking, + limits, attributes, share_context, + ui::command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); + + if (layout_test_deps_) { + callback.Run(layout_test_deps_->CreateLayerTreeFrameSink( + routing_id, std::move(gpu_channel_host), std::move(context_provider), + std::move(worker_context_provider), GetGpuMemoryBufferManager(), this)); + return; + } + +#if defined(OS_ANDROID) + if (sync_compositor_message_filter_) { + std::unique_ptr begin_frame_source = + params.synthetic_begin_frame_source + ? std::move(params.synthetic_begin_frame_source) + : CreateExternalBeginFrameSource(routing_id); + callback.Run(std::make_unique( + std::move(context_provider), std::move(worker_context_provider), + GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id, + g_next_layer_tree_frame_sink_id++, std::move(begin_frame_source), + sync_compositor_message_filter_.get(), + std::move(frame_swap_message_queue))); + return; + } +#endif + frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), + std::move(client)); + params.gpu_memory_buffer_manager = GetGpuMemoryBufferManager(); + callback.Run(std::make_unique( + std::move(context_provider), std::move(worker_context_provider), + ¶ms)); +} +",0,"void RenderThreadImpl::RequestNewLayerTreeFrameSink( + int routing_id, + scoped_refptr frame_swap_message_queue, + const GURL& url, + const LayerTreeFrameSinkCallback& callback) { + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + + viz::ClientLayerTreeFrameSink::InitParams params; + params.enable_surface_synchronization = + command_line.HasSwitch(switches::kEnableSurfaceSynchronization); + params.local_surface_id_provider = + std::make_unique(); + + if (command_line.HasSwitch(switches::kDisableGpuVsync) && + command_line.GetSwitchValueASCII(switches::kDisableGpuVsync) != ""gpu"") { + params.synthetic_begin_frame_source = CreateSyntheticBeginFrameSource(); + } + +#if defined(USE_AURA) + if (IsRunningInMash()) { + if (!RendererWindowTreeClient::Get(routing_id)) { + callback.Run(nullptr); + return; + } + bool connection_error = false; + scoped_refptr channel = + EstablishGpuChannelSync(&connection_error); + if (connection_error) + return; + if (!channel) { + callback.Run(nullptr); + return; + } + RendererWindowTreeClient::Get(routing_id) + ->RequestLayerTreeFrameSink( + gpu_->CreateContextProvider(std::move(channel)), + GetGpuMemoryBufferManager(), callback); + return; + } +#endif + + viz::mojom::CompositorFrameSinkRequest sink_request = + mojo::MakeRequest(¶ms.pipes.compositor_frame_sink_info); + viz::mojom::CompositorFrameSinkClientPtr client; + params.pipes.client_request = mojo::MakeRequest(&client); + + if (command_line.HasSwitch(switches::kEnableVulkan)) { + scoped_refptr vulkan_context_provider = + viz::VulkanInProcessContextProvider::Create(); + if (vulkan_context_provider) { + DCHECK(!layout_test_mode()); + frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), + std::move(client)); + callback.Run(std::make_unique( + std::move(vulkan_context_provider), ¶ms)); + return; + } + } + + if (is_gpu_compositing_disabled_) { + DCHECK(!layout_test_mode()); + frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), + std::move(client)); + params.shared_bitmap_manager = shared_bitmap_manager(); + callback.Run(std::make_unique( + nullptr, nullptr, ¶ms)); + return; + } + + bool connection_error = false; + scoped_refptr gpu_channel_host = + EstablishGpuChannelSync(&connection_error); + if (connection_error) + return; + if (!gpu_channel_host) { + callback.Run(nullptr); + return; + } + + scoped_refptr worker_context_provider = + SharedCompositorWorkerContextProvider(); + if (!worker_context_provider) { + callback.Run(nullptr); + return; + } + + gpu::SharedMemoryLimits limits = gpu::SharedMemoryLimits::ForMailboxContext(); + + gpu::gles2::ContextCreationAttribHelper attributes; + attributes.alpha_size = -1; + attributes.depth_size = 0; + attributes.stencil_size = 0; + attributes.samples = 0; + attributes.sample_buffers = 0; + attributes.bind_generates_resource = false; + attributes.lose_context_when_out_of_memory = true; + + constexpr bool automatic_flushes = false; + constexpr bool support_locking = false; + + ui::ContextProviderCommandBuffer* share_context = + worker_context_provider.get(); + if (IsAsyncWorkerContextEnabled()) + share_context = nullptr; + + scoped_refptr context_provider( + new ui::ContextProviderCommandBuffer( + gpu_channel_host, kGpuStreamIdDefault, kGpuStreamPriorityDefault, + gpu::kNullSurfaceHandle, url, automatic_flushes, support_locking, + limits, attributes, share_context, + ui::command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); + + if (layout_test_deps_) { + callback.Run(layout_test_deps_->CreateLayerTreeFrameSink( + routing_id, std::move(gpu_channel_host), std::move(context_provider), + std::move(worker_context_provider), GetGpuMemoryBufferManager(), this)); + return; + } + +#if defined(OS_ANDROID) + if (sync_compositor_message_filter_) { + std::unique_ptr begin_frame_source = + params.synthetic_begin_frame_source + ? std::move(params.synthetic_begin_frame_source) + : CreateExternalBeginFrameSource(routing_id); + callback.Run(std::make_unique( + std::move(context_provider), std::move(worker_context_provider), + GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id, + g_next_layer_tree_frame_sink_id++, std::move(begin_frame_source), + sync_compositor_message_filter_.get(), + std::move(frame_swap_message_queue))); + return; + } +#endif + frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), + std::move(client)); + params.gpu_memory_buffer_manager = GetGpuMemoryBufferManager(); + callback.Run(std::make_unique( + std::move(context_provider), std::move(worker_context_provider), + ¶ms)); +} +","@@ -994,9 +994,6 @@ void RenderThreadImpl::Init( + if (!command_line.HasSwitch(switches::kSingleProcess)) + base::SequencedWorkerPool::EnableForProcess(); + +- EVP_set_buggy_rsa_parser( +- base::FeatureList::IsEnabled(features::kBuggyRSAParser)); +- + GetConnector()->BindInterface(mojom::kBrowserServiceName, + mojo::MakeRequest(&frame_sink_provider_)); + ",1181,1417,2048 +12128,"void IOThread::InitAsync() { + TRACE_EVENT0(""startup"", ""IOThread::InitAsync""); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + +#if defined(USE_NSS) || defined(OS_IOS) + net::SetMessageLoopForNSSHttpIO(); +#endif + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + DCHECK(!globals_); + globals_ = new Globals; + + network_change_observer_.reset( + new LoggingNetworkChangeObserver(net_log_)); + + net::NetworkChangeNotifier::InitHistogramWatcher(); + + globals_->extension_event_router_forwarder = + extension_event_router_forwarder_; + ChromeNetworkDelegate* network_delegate = + new ChromeNetworkDelegate(extension_event_router_forwarder_, + &system_enable_referrers_); + if (command_line.HasSwitch(switches::kEnableClientHints)) + network_delegate->SetEnableClientHints(); + if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) + network_delegate->NeverThrottleRequests(); + globals_->system_network_delegate.reset(network_delegate); + globals_->host_resolver = CreateGlobalHostResolver(net_log_); + UpdateDnsClientEnabled(); + globals_->cert_verifier.reset(net::CertVerifier::CreateDefault()); + globals_->transport_security_state.reset(new net::TransportSecurityState()); +#if !defined(USE_OPENSSL) + net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); + globals_->cert_transparency_verifier.reset(ct_verifier); + + ct_verifier->AddLog(net::ct::CreateGooglePilotLogVerifier().Pass()); + ct_verifier->AddLog(net::ct::CreateGoogleAviatorLogVerifier().Pass()); + ct_verifier->AddLog(net::ct::CreateGoogleRocketeerLogVerifier().Pass()); + + if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { + std::string switch_value = command_line.GetSwitchValueASCII( + switches::kCertificateTransparencyLog); + size_t delim_pos = switch_value.find("":""); + CHECK(delim_pos != std::string::npos) + << ""CT log description not provided (switch format"" + "" is 'description:base64_key')""; + std::string log_description(switch_value.substr(0, delim_pos)); + std::string ct_public_key_data; + CHECK(base::Base64Decode( + switch_value.substr(delim_pos + 1), + &ct_public_key_data)) << ""Unable to decode CT public key.""; + scoped_ptr external_log_verifier( + net::CTLogVerifier::Create(ct_public_key_data, log_description)); + CHECK(external_log_verifier) << ""Unable to parse CT public key.""; + ct_verifier->AddLog(external_log_verifier.Pass()); + } +#else + if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { + LOG(DFATAL) << ""Certificate Transparency is not yet supported in Chrome "" + ""builds using OpenSSL.""; + } +#endif + globals_->ssl_config_service = GetSSLConfigService(); +#if defined(OS_ANDROID) || defined(OS_IOS) + if (DataReductionProxySettings::IsDataReductionProxyAllowed()) { + spdyproxy_auth_origins_ = + DataReductionProxySettings::GetDataReductionProxies(); + } +#endif // defined(OS_ANDROID) || defined(OS_IOS) + globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( + globals_->host_resolver.get())); + globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); + globals_->proxy_script_fetcher_proxy_service.reset( + net::ProxyService::CreateDirectWithNetLog(net_log_)); + globals_->system_cookie_store = new net::CookieMonster(NULL, NULL); + globals_->system_server_bound_cert_service.reset( + new net::ServerBoundCertService( + new net::DefaultServerBoundCertStore(NULL), + base::WorkerPool::GetTaskRunner(true))); + globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); + globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); + globals_->host_mapping_rules.reset(new net::HostMappingRules()); + globals_->http_user_agent_settings.reset( + new BasicHttpUserAgentSettings(std::string())); + if (command_line.HasSwitch(switches::kHostRules)) { + TRACE_EVENT_BEGIN0(""startup"", ""IOThread::InitAsync:SetRulesFromString""); + globals_->host_mapping_rules->SetRulesFromString( + command_line.GetSwitchValueASCII(switches::kHostRules)); + TRACE_EVENT_END0(""startup"", ""IOThread::InitAsync:SetRulesFromString""); + } + if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) + globals_->ignore_certificate_errors = true; + if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { + globals_->testing_fixed_http_port = + GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); + } + if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { + globals_->testing_fixed_https_port = + GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); + } + ConfigureQuic(command_line); + if (command_line.HasSwitch( + switches::kEnableUserAlternateProtocolPorts)) { + globals_->enable_user_alternate_protocol_ports = true; + } + InitializeNetworkOptions(command_line); + + net::HttpNetworkSession::Params session_params; + InitializeNetworkSessionParams(&session_params); + session_params.net_log = net_log_; + session_params.proxy_service = + globals_->proxy_script_fetcher_proxy_service.get(); + + TRACE_EVENT_BEGIN0(""startup"", ""IOThread::InitAsync:HttpNetworkSession""); + scoped_refptr network_session( + new net::HttpNetworkSession(session_params)); + globals_->proxy_script_fetcher_http_transaction_factory + .reset(new net::HttpNetworkLayer(network_session.get())); + TRACE_EVENT_END0(""startup"", ""IOThread::InitAsync:HttpNetworkSession""); + scoped_ptr job_factory( + new net::URLRequestJobFactoryImpl()); + job_factory->SetProtocolHandler(chrome::kDataScheme, + new net::DataProtocolHandler()); + job_factory->SetProtocolHandler( + chrome::kFileScheme, + new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool()-> + GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); +#if !defined(DISABLE_FTP_SUPPORT) + globals_->proxy_script_fetcher_ftp_transaction_factory.reset( + new net::FtpNetworkLayer(globals_->host_resolver.get())); + job_factory->SetProtocolHandler( + content::kFtpScheme, + new net::FtpProtocolHandler( + globals_->proxy_script_fetcher_ftp_transaction_factory.get())); +#endif + globals_->proxy_script_fetcher_url_request_job_factory = + job_factory.PassAs(); + + globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); + globals_->throttler_manager->set_net_log(net_log_); + globals_->throttler_manager->set_enable_thread_checks(true); + + globals_->proxy_script_fetcher_context.reset( + ConstructProxyScriptFetcherContext(globals_, net_log_)); + + globals_->network_time_notifier.reset( + new net::NetworkTimeNotifier( + scoped_ptr(new base::DefaultTickClock()))); + + sdch_manager_ = new net::SdchManager(); + +#if defined(OS_MACOSX) && !defined(OS_IOS) + BrowserThread::PostTask(BrowserThread::UI, + FROM_HERE, + base::Bind(&ObserveKeychainEvents)); +#endif + + BrowserThread::PostTask(BrowserThread::UI, + FROM_HERE, + base::Bind(&IOThread::InitSystemRequestContext, + weak_factory_.GetWeakPtr())); +} +",0,"void IOThread::InitAsync() { + TRACE_EVENT0(""startup"", ""IOThread::InitAsync""); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + +#if defined(USE_NSS) || defined(OS_IOS) + net::SetMessageLoopForNSSHttpIO(); +#endif + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + DCHECK(!globals_); + globals_ = new Globals; + + network_change_observer_.reset( + new LoggingNetworkChangeObserver(net_log_)); + + net::NetworkChangeNotifier::InitHistogramWatcher(); + + globals_->extension_event_router_forwarder = + extension_event_router_forwarder_; + ChromeNetworkDelegate* network_delegate = + new ChromeNetworkDelegate(extension_event_router_forwarder_, + &system_enable_referrers_); + if (command_line.HasSwitch(switches::kEnableClientHints)) + network_delegate->SetEnableClientHints(); + if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) + network_delegate->NeverThrottleRequests(); + globals_->system_network_delegate.reset(network_delegate); + globals_->host_resolver = CreateGlobalHostResolver(net_log_); + UpdateDnsClientEnabled(); + globals_->cert_verifier.reset(net::CertVerifier::CreateDefault()); + globals_->transport_security_state.reset(new net::TransportSecurityState()); +#if !defined(USE_OPENSSL) + net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); + globals_->cert_transparency_verifier.reset(ct_verifier); + + ct_verifier->AddLog(net::ct::CreateGooglePilotLogVerifier().Pass()); + ct_verifier->AddLog(net::ct::CreateGoogleAviatorLogVerifier().Pass()); + ct_verifier->AddLog(net::ct::CreateGoogleRocketeerLogVerifier().Pass()); + + if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { + std::string switch_value = command_line.GetSwitchValueASCII( + switches::kCertificateTransparencyLog); + size_t delim_pos = switch_value.find("":""); + CHECK(delim_pos != std::string::npos) + << ""CT log description not provided (switch format"" + "" is 'description:base64_key')""; + std::string log_description(switch_value.substr(0, delim_pos)); + std::string ct_public_key_data; + CHECK(base::Base64Decode( + switch_value.substr(delim_pos + 1), + &ct_public_key_data)) << ""Unable to decode CT public key.""; + scoped_ptr external_log_verifier( + net::CTLogVerifier::Create(ct_public_key_data, log_description)); + CHECK(external_log_verifier) << ""Unable to parse CT public key.""; + ct_verifier->AddLog(external_log_verifier.Pass()); + } +#else + if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { + LOG(DFATAL) << ""Certificate Transparency is not yet supported in Chrome "" + ""builds using OpenSSL.""; + } +#endif + globals_->ssl_config_service = GetSSLConfigService(); +#if defined(OS_ANDROID) || defined(OS_IOS) + if (DataReductionProxySettings::IsDataReductionProxyAllowed()) { + spdyproxy_auth_origins_ = + DataReductionProxySettings::GetDataReductionProxies(); + } +#endif // defined(OS_ANDROID) || defined(OS_IOS) + globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( + globals_->host_resolver.get())); + globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); + globals_->proxy_script_fetcher_proxy_service.reset( + net::ProxyService::CreateDirectWithNetLog(net_log_)); + globals_->system_cookie_store = new net::CookieMonster(NULL, NULL); + globals_->system_server_bound_cert_service.reset( + new net::ServerBoundCertService( + new net::DefaultServerBoundCertStore(NULL), + base::WorkerPool::GetTaskRunner(true))); + globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); + globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); + globals_->host_mapping_rules.reset(new net::HostMappingRules()); + globals_->http_user_agent_settings.reset( + new BasicHttpUserAgentSettings(std::string())); + if (command_line.HasSwitch(switches::kHostRules)) { + TRACE_EVENT_BEGIN0(""startup"", ""IOThread::InitAsync:SetRulesFromString""); + globals_->host_mapping_rules->SetRulesFromString( + command_line.GetSwitchValueASCII(switches::kHostRules)); + TRACE_EVENT_END0(""startup"", ""IOThread::InitAsync:SetRulesFromString""); + } + if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) + globals_->ignore_certificate_errors = true; + if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { + globals_->testing_fixed_http_port = + GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); + } + if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { + globals_->testing_fixed_https_port = + GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); + } + ConfigureQuic(command_line); + if (command_line.HasSwitch( + switches::kEnableUserAlternateProtocolPorts)) { + globals_->enable_user_alternate_protocol_ports = true; + } + InitializeNetworkOptions(command_line); + + net::HttpNetworkSession::Params session_params; + InitializeNetworkSessionParams(&session_params); + session_params.net_log = net_log_; + session_params.proxy_service = + globals_->proxy_script_fetcher_proxy_service.get(); + + TRACE_EVENT_BEGIN0(""startup"", ""IOThread::InitAsync:HttpNetworkSession""); + scoped_refptr network_session( + new net::HttpNetworkSession(session_params)); + globals_->proxy_script_fetcher_http_transaction_factory + .reset(new net::HttpNetworkLayer(network_session.get())); + TRACE_EVENT_END0(""startup"", ""IOThread::InitAsync:HttpNetworkSession""); + scoped_ptr job_factory( + new net::URLRequestJobFactoryImpl()); + job_factory->SetProtocolHandler(chrome::kDataScheme, + new net::DataProtocolHandler()); + job_factory->SetProtocolHandler( + chrome::kFileScheme, + new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool()-> + GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); +#if !defined(DISABLE_FTP_SUPPORT) + globals_->proxy_script_fetcher_ftp_transaction_factory.reset( + new net::FtpNetworkLayer(globals_->host_resolver.get())); + job_factory->SetProtocolHandler( + content::kFtpScheme, + new net::FtpProtocolHandler( + globals_->proxy_script_fetcher_ftp_transaction_factory.get())); +#endif + globals_->proxy_script_fetcher_url_request_job_factory = + job_factory.PassAs(); + + globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); + globals_->throttler_manager->set_net_log(net_log_); + globals_->throttler_manager->set_enable_thread_checks(true); + + globals_->proxy_script_fetcher_context.reset( + ConstructProxyScriptFetcherContext(globals_, net_log_)); + + globals_->network_time_notifier.reset( + new net::NetworkTimeNotifier( + scoped_ptr(new base::DefaultTickClock()))); + + sdch_manager_ = new net::SdchManager(); + +#if defined(OS_MACOSX) && !defined(OS_IOS) + BrowserThread::PostTask(BrowserThread::UI, + FROM_HERE, + base::Bind(&ObserveKeychainEvents)); +#endif + + BrowserThread::PostTask(BrowserThread::UI, + FROM_HERE, + base::Bind(&IOThread::InitSystemRequestContext, + weak_factory_.GetWeakPtr())); +} +","@@ -879,6 +879,14 @@ void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { + prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled); + registry->RegisterListPref( + prefs::kDailyContentLengthWithDataReductionProxyEnabled); ++ registry->RegisterListPref( ++ prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled); ++ registry->RegisterListPref( ++ prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled); ++ registry->RegisterListPref( ++ prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled); ++ registry->RegisterListPref( ++ prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled); + registry->RegisterListPref( + prefs::kDailyOriginalContentLengthViaDataReductionProxy); + registry->RegisterListPref(",1661,1897,2048 +1921,"static int dccp_v4_rcv(struct sk_buff *skb) +{ + const struct dccp_hdr *dh; + const struct iphdr *iph; + struct sock *sk; + int min_cov; + + /* Step 1: Check header basics */ + + if (dccp_invalid_packet(skb)) + goto discard_it; + + iph = ip_hdr(skb); + /* Step 1: If header checksum is incorrect, drop packet and return */ + if (dccp_v4_csum_finish(skb, iph->saddr, iph->daddr)) { + DCCP_WARN(""dropped packet with invalid checksum\n""); + goto discard_it; + } + + dh = dccp_hdr(skb); + + DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh); + DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; + + dccp_pr_debug(""%8.8s src=%pI4@%-5d dst=%pI4@%-5d seq=%llu"", + dccp_packet_name(dh->dccph_type), + &iph->saddr, ntohs(dh->dccph_sport), + &iph->daddr, ntohs(dh->dccph_dport), + (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq); + + if (dccp_packet_without_ack(skb)) { + DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ; + dccp_pr_debug_cat(""\n""); + } else { + DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb); + dccp_pr_debug_cat("", ack=%llu\n"", (unsigned long long) + DCCP_SKB_CB(skb)->dccpd_ack_seq); + } + + /* Step 2: + * Look up flow ID in table and get corresponding socket */ + sk = __inet_lookup_skb(&dccp_hashinfo, skb, + dh->dccph_sport, dh->dccph_dport); + /* + * Step 2: + * If no socket ... + */ + if (sk == NULL) { + dccp_pr_debug(""failed to look up flow ID in table and "" + ""get corresponding socket\n""); + goto no_dccp_socket; + } + + /* + * Step 2: + * ... or S.state == TIMEWAIT, + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + if (sk->sk_state == DCCP_TIME_WAIT) { + dccp_pr_debug(""sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n""); + inet_twsk_put(inet_twsk(sk)); + goto no_dccp_socket; + } + + /* + * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage + * o if MinCsCov = 0, only packets with CsCov = 0 are accepted + * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov + */ + min_cov = dccp_sk(sk)->dccps_pcrlen; + if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) { + dccp_pr_debug(""Packet CsCov %d does not satisfy MinCsCov %d\n"", + dh->dccph_cscov, min_cov); + /* FIXME: ""Such packets SHOULD be reported using Data Dropped + * options (Section 11.7) with Drop Code 0, Protocol + * Constraints."" */ + goto discard_and_relse; + } + + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) + goto discard_and_relse; + nf_reset(skb); + + return sk_receive_skb(sk, skb, 1); + +no_dccp_socket: + if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto discard_it; + /* + * Step 2: + * If no socket ... + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + if (dh->dccph_type != DCCP_PKT_RESET) { + DCCP_SKB_CB(skb)->dccpd_reset_code = + DCCP_RESET_CODE_NO_CONNECTION; + dccp_v4_ctl_send_reset(sk, skb); + } + +discard_it: + kfree_skb(skb); + return 0; + +discard_and_relse: + sock_put(sk); + goto discard_it; +} +",0,"static int dccp_v4_rcv(struct sk_buff *skb) +{ + const struct dccp_hdr *dh; + const struct iphdr *iph; + struct sock *sk; + int min_cov; + + /* Step 1: Check header basics */ + + if (dccp_invalid_packet(skb)) + goto discard_it; + + iph = ip_hdr(skb); + /* Step 1: If header checksum is incorrect, drop packet and return */ + if (dccp_v4_csum_finish(skb, iph->saddr, iph->daddr)) { + DCCP_WARN(""dropped packet with invalid checksum\n""); + goto discard_it; + } + + dh = dccp_hdr(skb); + + DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh); + DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; + + dccp_pr_debug(""%8.8s src=%pI4@%-5d dst=%pI4@%-5d seq=%llu"", + dccp_packet_name(dh->dccph_type), + &iph->saddr, ntohs(dh->dccph_sport), + &iph->daddr, ntohs(dh->dccph_dport), + (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq); + + if (dccp_packet_without_ack(skb)) { + DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ; + dccp_pr_debug_cat(""\n""); + } else { + DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb); + dccp_pr_debug_cat("", ack=%llu\n"", (unsigned long long) + DCCP_SKB_CB(skb)->dccpd_ack_seq); + } + + /* Step 2: + * Look up flow ID in table and get corresponding socket */ + sk = __inet_lookup_skb(&dccp_hashinfo, skb, + dh->dccph_sport, dh->dccph_dport); + /* + * Step 2: + * If no socket ... + */ + if (sk == NULL) { + dccp_pr_debug(""failed to look up flow ID in table and "" + ""get corresponding socket\n""); + goto no_dccp_socket; + } + + /* + * Step 2: + * ... or S.state == TIMEWAIT, + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + if (sk->sk_state == DCCP_TIME_WAIT) { + dccp_pr_debug(""sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n""); + inet_twsk_put(inet_twsk(sk)); + goto no_dccp_socket; + } + + /* + * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage + * o if MinCsCov = 0, only packets with CsCov = 0 are accepted + * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov + */ + min_cov = dccp_sk(sk)->dccps_pcrlen; + if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) { + dccp_pr_debug(""Packet CsCov %d does not satisfy MinCsCov %d\n"", + dh->dccph_cscov, min_cov); + /* FIXME: ""Such packets SHOULD be reported using Data Dropped + * options (Section 11.7) with Drop Code 0, Protocol + * Constraints."" */ + goto discard_and_relse; + } + + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) + goto discard_and_relse; + nf_reset(skb); + + return sk_receive_skb(sk, skb, 1); + +no_dccp_socket: + if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto discard_it; + /* + * Step 2: + * If no socket ... + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + if (dh->dccph_type != DCCP_PKT_RESET) { + DCCP_SKB_CB(skb)->dccpd_reset_code = + DCCP_RESET_CODE_NO_CONNECTION; + dccp_v4_ctl_send_reset(sk, skb); + } + +discard_it: + kfree_skb(skb); + return 0; + +discard_and_relse: + sock_put(sk); + goto discard_it; +} +","@@ -48,6 +48,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) + struct flowi4 fl4; + struct rtable *rt; + int err; ++ struct ip_options_rcu *inet_opt; + + dp->dccps_role = DCCP_ROLE_CLIENT; + +@@ -58,10 +59,13 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) + return -EAFNOSUPPORT; + + nexthop = daddr = usin->sin_addr.s_addr; +- if (inet->opt != NULL && inet->opt->srr) { ++ ++ inet_opt = rcu_dereference_protected(inet->inet_opt, ++ sock_owned_by_user(sk)); ++ if (inet_opt != NULL && inet_opt->opt.srr) { + if (daddr == 0) + return -EINVAL; +- nexthop = inet->opt->faddr; ++ nexthop = inet_opt->opt.faddr; + } + + orig_sport = inet->inet_sport; +@@ -78,7 +82,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) + return -ENETUNREACH; + } + +- if (inet->opt == NULL || !inet->opt->srr) ++ if (inet_opt == NULL || !inet_opt->opt.srr) + daddr = rt->rt_dst; + + if (inet->inet_saddr == 0) +@@ -89,8 +93,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) + inet->inet_daddr = daddr; + + inet_csk(sk)->icsk_ext_hdr_len = 0; +- if (inet->opt != NULL) +- inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen; ++ if (inet_opt) ++ inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen; + /* + * Socket identity is still unknown (sport may be zero). + * However we set state to DCCP_REQUESTING and not releasing socket +@@ -405,7 +409,7 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, + newinet->inet_daddr = ireq->rmt_addr; + newinet->inet_rcv_saddr = ireq->loc_addr; + newinet->inet_saddr = ireq->loc_addr; +- newinet->opt = ireq->opt; ++ newinet->inet_opt = ireq->opt; + ireq->opt = NULL; + newinet->mc_index = inet_iif(skb); + newinet->mc_ttl = ip_hdr(skb)->ttl;",979,1215,2048 +18203," UriSuite() { + TEST_ADD(UriSuite::testDistinction) + TEST_ADD(UriSuite::testIpFour) + TEST_ADD(UriSuite::testIpSixPass) + TEST_ADD(UriSuite::testIpSixFail) + TEST_ADD(UriSuite::testUri) + TEST_ADD(UriSuite::testUriUserInfoHostPort1) + TEST_ADD(UriSuite::testUriUserInfoHostPort2) + TEST_ADD(UriSuite::testUriUserInfoHostPort22_Bug1948038) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_1) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_2) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_3) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_4) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_related_1) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_related_12) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_related_2) + TEST_ADD(UriSuite::testUriUserInfoHostPort3) + TEST_ADD(UriSuite::testUriUserInfoHostPort4) + TEST_ADD(UriSuite::testUriUserInfoHostPort5) + TEST_ADD(UriSuite::testUriUserInfoHostPort6) + TEST_ADD(UriSuite::testUriHostRegname) + TEST_ADD(UriSuite::testUriHostIpFour1) + TEST_ADD(UriSuite::testUriHostIpFour2) + TEST_ADD(UriSuite::testUriHostIpSix1) + TEST_ADD(UriSuite::testUriHostIpSix2) + TEST_ADD(UriSuite::testUriHostIpFuture) + TEST_ADD(UriSuite::testUriHostEmpty) + TEST_ADD(UriSuite::testUriComponents) + TEST_ADD(UriSuite::testUriComponents_Bug20070701) + TEST_ADD(UriSuite::testEscaping) + TEST_ADD(UriSuite::testUnescaping) + TEST_ADD(UriSuite::testTrailingSlash) + TEST_ADD(UriSuite::testAddBase) + TEST_ADD(UriSuite::testToString) + TEST_ADD(UriSuite::testToString_Bug1950126) + TEST_ADD(UriSuite::testToStringCharsRequired) + TEST_ADD(UriSuite::testToStringCharsRequired) + TEST_ADD(UriSuite::testNormalizeSyntaxMaskRequired) + TEST_ADD(UriSuite::testNormalizeSyntax) + TEST_ADD(UriSuite::testNormalizeSyntaxComponents) + TEST_ADD(UriSuite::testNormalizeCrash_Bug20080224) + TEST_ADD(UriSuite::testFilenameUriConversion) + TEST_ADD(UriSuite::testCrash_FreeUriMembers_Bug20080116) + TEST_ADD(UriSuite::testCrash_Report2418192) + TEST_ADD(UriSuite::testPervertedQueryString); + TEST_ADD(UriSuite::testQueryStringEndingInEqualSign_NonBug32); + TEST_ADD(UriSuite::testCrash_MakeOwner_Bug20080207) + TEST_ADD(UriSuite::testQueryList) + TEST_ADD(UriSuite::testQueryListPair) + TEST_ADD(UriSuite::testQueryDissection_Bug3590761) + TEST_ADD(UriSuite::testFreeCrash_Bug20080827) + TEST_ADD(UriSuite::testParseInvalid_Bug16) + TEST_ADD(UriSuite::testRangeComparison) + TEST_ADD(UriSuite::testRangeComparison_RemoveBaseUri_Issue19) + TEST_ADD(UriSuite::testEquals) + TEST_ADD(UriSuite::testHostTextTermination_Issue15) + } +",1," UriSuite() { + TEST_ADD(UriSuite::testDistinction) + TEST_ADD(UriSuite::testIpFour) + TEST_ADD(UriSuite::testIpSixPass) + TEST_ADD(UriSuite::testIpSixFail) + TEST_ADD(UriSuite::testUri) + TEST_ADD(UriSuite::testUriUserInfoHostPort1) + TEST_ADD(UriSuite::testUriUserInfoHostPort2) + TEST_ADD(UriSuite::testUriUserInfoHostPort22_Bug1948038) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_1) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_2) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_3) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_4) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_related_1) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_related_12) + TEST_ADD(UriSuite::testUriUserInfoHostPort23_Bug3510198_related_2) + TEST_ADD(UriSuite::testUriUserInfoHostPort3) + TEST_ADD(UriSuite::testUriUserInfoHostPort4) + TEST_ADD(UriSuite::testUriUserInfoHostPort5) + TEST_ADD(UriSuite::testUriUserInfoHostPort6) + TEST_ADD(UriSuite::testUriHostRegname) + TEST_ADD(UriSuite::testUriHostIpFour1) + TEST_ADD(UriSuite::testUriHostIpFour2) + TEST_ADD(UriSuite::testUriHostIpSix1) + TEST_ADD(UriSuite::testUriHostIpSix2) + TEST_ADD(UriSuite::testUriHostIpFuture) + TEST_ADD(UriSuite::testUriHostEmpty) + TEST_ADD(UriSuite::testUriComponents) + TEST_ADD(UriSuite::testUriComponents_Bug20070701) + TEST_ADD(UriSuite::testEscaping) + TEST_ADD(UriSuite::testUnescaping) + TEST_ADD(UriSuite::testTrailingSlash) + TEST_ADD(UriSuite::testAddBase) + TEST_ADD(UriSuite::testToString) + TEST_ADD(UriSuite::testToString_Bug1950126) + TEST_ADD(UriSuite::testToStringCharsRequired) + TEST_ADD(UriSuite::testToStringCharsRequired) + TEST_ADD(UriSuite::testNormalizeSyntaxMaskRequired) + TEST_ADD(UriSuite::testNormalizeSyntax) + TEST_ADD(UriSuite::testNormalizeSyntaxComponents) + TEST_ADD(UriSuite::testNormalizeCrash_Bug20080224) + TEST_ADD(UriSuite::testFilenameUriConversion) + TEST_ADD(UriSuite::testCrash_FreeUriMembers_Bug20080116) + TEST_ADD(UriSuite::testCrash_Report2418192) + TEST_ADD(UriSuite::testPervertedQueryString); + TEST_ADD(UriSuite::testQueryStringEndingInEqualSign_NonBug32); + TEST_ADD(UriSuite::testCrash_MakeOwner_Bug20080207) + TEST_ADD(UriSuite::testQueryList) + TEST_ADD(UriSuite::testQueryListPair) + TEST_ADD(UriSuite::testQueryDissection_Bug3590761) + TEST_ADD(UriSuite::testQueryCompositionMathWrite_GoogleAutofuzz113244572) + TEST_ADD(UriSuite::testFreeCrash_Bug20080827) + TEST_ADD(UriSuite::testParseInvalid_Bug16) + TEST_ADD(UriSuite::testRangeComparison) + TEST_ADD(UriSuite::testRangeComparison_RemoveBaseUri_Issue19) + TEST_ADD(UriSuite::testEquals) + TEST_ADD(UriSuite::testHostTextTermination_Issue15) + } +","@@ -104,6 +104,7 @@ class UriSuite : public Suite { + TEST_ADD(UriSuite::testQueryList) + TEST_ADD(UriSuite::testQueryListPair) + TEST_ADD(UriSuite::testQueryDissection_Bug3590761) ++ TEST_ADD(UriSuite::testQueryCompositionMathWrite_GoogleAutofuzz113244572) + TEST_ADD(UriSuite::testFreeCrash_Bug20080827) + TEST_ADD(UriSuite::testParseInvalid_Bug16) + TEST_ADD(UriSuite::testRangeComparison) +@@ -1749,6 +1750,37 @@ Rule | Example | hostSet | absPath | emptySeg + uriFreeQueryListA(queryList); + } + ++ void testQueryCompositionMathWrite_GoogleAutofuzz113244572() { ++ UriQueryListA second = { .key = ""\x11"", .value = NULL, .next = NULL }; ++ UriQueryListA first = { .key = ""\x01"", .value = ""\x02"", .next = &second }; ++ ++ const UriBool spaceToPlus = URI_TRUE; ++ const UriBool normalizeBreaks = URI_FALSE; /* for factor 3 but 6 */ ++ ++ const int charsRequired = (3 + 1 + 3) + 1 + (3); ++ ++ { ++ // Minimum space to hold everything fine ++ const char * const expected = ""%01=%02"" ""&"" ""%11""; ++ char dest[charsRequired + 1]; ++ int charsWritten; ++ TEST_ASSERT(uriComposeQueryExA(dest, &first, sizeof(dest), ++ &charsWritten, spaceToPlus, normalizeBreaks) ++ == URI_SUCCESS); ++ TEST_ASSERT(! strcmp(dest, expected)); ++ TEST_ASSERT(charsWritten == strlen(expected) + 1); ++ } ++ ++ { ++ // Previous math failed to take ampersand into account ++ char dest[charsRequired + 1 - 1]; ++ int charsWritten; ++ TEST_ASSERT(uriComposeQueryExA(dest, &first, sizeof(dest), ++ &charsWritten, spaceToPlus, normalizeBreaks) ++ == URI_ERROR_OUTPUT_TOO_LARGE); ++ } ++ } ++ + void testFreeCrash_Bug20080827() { + char const * const sourceUri = ""abc""; + char const * const baseUri = ""http://www.example.org/"";",831,1067,2048 +17480,"WORD32 ih264d_parse_islice(dec_struct_t *ps_dec, + UWORD16 u2_first_mb_in_slice) +{ + dec_pic_params_t * ps_pps = ps_dec->ps_cur_pps; + dec_slice_params_t * ps_slice = ps_dec->ps_cur_slice; + UWORD32 *pu4_bitstrm_buf = ps_dec->ps_bitstrm->pu4_buffer; + UWORD32 *pu4_bitstrm_ofst = &ps_dec->ps_bitstrm->u4_ofst; + UWORD32 u4_temp; + WORD32 i_temp; + WORD32 ret; + + /*--------------------------------------------------------------------*/ + /* Read remaining contents of the slice header */ + /*--------------------------------------------------------------------*/ + /* dec_ref_pic_marking function */ + /* G050 */ + if(ps_slice->u1_nal_ref_idc != 0) + { + if(!ps_dec->ps_dpb_cmds->u1_dpb_commands_read) + ps_dec->u4_bitoffset = ih264d_read_mmco_commands( + ps_dec); + else + ps_dec->ps_bitstrm->u4_ofst += ps_dec->u4_bitoffset; + } + /* G050 */ + + /* Read slice_qp_delta */ + i_temp = ps_pps->u1_pic_init_qp + + ih264d_sev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if((i_temp < 0) || (i_temp > 51)) + return ERROR_INV_RANGE_QP_T; + ps_slice->u1_slice_qp = i_temp; + COPYTHECONTEXT(""SH: slice_qp_delta"", + ps_slice->u1_slice_qp - ps_pps->u1_pic_init_qp); + + if(ps_pps->u1_deblocking_filter_parameters_present_flag == 1) + { + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: disable_deblocking_filter_idc"", u4_temp); + + if(u4_temp > SLICE_BOUNDARY_DBLK_DISABLED) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_slice->u1_disable_dblk_filter_idc = u4_temp; + if(u4_temp != 1) + { + i_temp = ih264d_sev(pu4_bitstrm_ofst, pu4_bitstrm_buf) + << 1; + if((MIN_DBLK_FIL_OFF > i_temp) || (i_temp > MAX_DBLK_FIL_OFF)) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_slice->i1_slice_alpha_c0_offset = i_temp; + COPYTHECONTEXT(""SH: slice_alpha_c0_offset_div2"", + ps_slice->i1_slice_alpha_c0_offset >> 1); + + i_temp = ih264d_sev(pu4_bitstrm_ofst, pu4_bitstrm_buf) + << 1; + if((MIN_DBLK_FIL_OFF > i_temp) || (i_temp > MAX_DBLK_FIL_OFF)) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_slice->i1_slice_beta_offset = i_temp; + COPYTHECONTEXT(""SH: slice_beta_offset_div2"", + ps_slice->i1_slice_beta_offset >> 1); + + } + else + { + ps_slice->i1_slice_alpha_c0_offset = 0; + ps_slice->i1_slice_beta_offset = 0; + } + } + else + { + ps_slice->u1_disable_dblk_filter_idc = 0; + ps_slice->i1_slice_alpha_c0_offset = 0; + ps_slice->i1_slice_beta_offset = 0; + } + + /* Initialization to check if number of motion vector per 2 Mbs */ + /* are exceeding the range or not */ + ps_dec->u2_mv_2mb[0] = 0; + ps_dec->u2_mv_2mb[1] = 0; + + + /*set slice header cone to 2 ,to indicate correct header*/ + ps_dec->u1_slice_header_done = 2; + + if(ps_pps->u1_entropy_coding_mode) + { + SWITCHOFFTRACE; SWITCHONTRACECABAC; + if(ps_dec->ps_cur_slice->u1_mbaff_frame_flag) + { + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cabac_mbaff; + } + else + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cabac_nonmbaff; + + ret = ih264d_parse_islice_data_cabac(ps_dec, ps_slice, + u2_first_mb_in_slice); + if(ret != OK) + return ret; + SWITCHONTRACE; SWITCHOFFTRACECABAC; + } + else + { + if(ps_dec->ps_cur_slice->u1_mbaff_frame_flag) + { + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cavlc_mbaff; + } + else + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cavlc_nonmbaff; + ret = ih264d_parse_islice_data_cavlc(ps_dec, ps_slice, + u2_first_mb_in_slice); + if(ret != OK) + return ret; + } + + return OK; +} +",0,"WORD32 ih264d_parse_islice(dec_struct_t *ps_dec, + UWORD16 u2_first_mb_in_slice) +{ + dec_pic_params_t * ps_pps = ps_dec->ps_cur_pps; + dec_slice_params_t * ps_slice = ps_dec->ps_cur_slice; + UWORD32 *pu4_bitstrm_buf = ps_dec->ps_bitstrm->pu4_buffer; + UWORD32 *pu4_bitstrm_ofst = &ps_dec->ps_bitstrm->u4_ofst; + UWORD32 u4_temp; + WORD32 i_temp; + WORD32 ret; + + /*--------------------------------------------------------------------*/ + /* Read remaining contents of the slice header */ + /*--------------------------------------------------------------------*/ + /* dec_ref_pic_marking function */ + /* G050 */ + if(ps_slice->u1_nal_ref_idc != 0) + { + if(!ps_dec->ps_dpb_cmds->u1_dpb_commands_read) + ps_dec->u4_bitoffset = ih264d_read_mmco_commands( + ps_dec); + else + ps_dec->ps_bitstrm->u4_ofst += ps_dec->u4_bitoffset; + } + /* G050 */ + + /* Read slice_qp_delta */ + i_temp = ps_pps->u1_pic_init_qp + + ih264d_sev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if((i_temp < 0) || (i_temp > 51)) + return ERROR_INV_RANGE_QP_T; + ps_slice->u1_slice_qp = i_temp; + COPYTHECONTEXT(""SH: slice_qp_delta"", + ps_slice->u1_slice_qp - ps_pps->u1_pic_init_qp); + + if(ps_pps->u1_deblocking_filter_parameters_present_flag == 1) + { + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: disable_deblocking_filter_idc"", u4_temp); + + if(u4_temp > SLICE_BOUNDARY_DBLK_DISABLED) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_slice->u1_disable_dblk_filter_idc = u4_temp; + if(u4_temp != 1) + { + i_temp = ih264d_sev(pu4_bitstrm_ofst, pu4_bitstrm_buf) + << 1; + if((MIN_DBLK_FIL_OFF > i_temp) || (i_temp > MAX_DBLK_FIL_OFF)) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_slice->i1_slice_alpha_c0_offset = i_temp; + COPYTHECONTEXT(""SH: slice_alpha_c0_offset_div2"", + ps_slice->i1_slice_alpha_c0_offset >> 1); + + i_temp = ih264d_sev(pu4_bitstrm_ofst, pu4_bitstrm_buf) + << 1; + if((MIN_DBLK_FIL_OFF > i_temp) || (i_temp > MAX_DBLK_FIL_OFF)) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_slice->i1_slice_beta_offset = i_temp; + COPYTHECONTEXT(""SH: slice_beta_offset_div2"", + ps_slice->i1_slice_beta_offset >> 1); + + } + else + { + ps_slice->i1_slice_alpha_c0_offset = 0; + ps_slice->i1_slice_beta_offset = 0; + } + } + else + { + ps_slice->u1_disable_dblk_filter_idc = 0; + ps_slice->i1_slice_alpha_c0_offset = 0; + ps_slice->i1_slice_beta_offset = 0; + } + + /* Initialization to check if number of motion vector per 2 Mbs */ + /* are exceeding the range or not */ + ps_dec->u2_mv_2mb[0] = 0; + ps_dec->u2_mv_2mb[1] = 0; + + + /*set slice header cone to 2 ,to indicate correct header*/ + ps_dec->u1_slice_header_done = 2; + + if(ps_pps->u1_entropy_coding_mode) + { + SWITCHOFFTRACE; SWITCHONTRACECABAC; + if(ps_dec->ps_cur_slice->u1_mbaff_frame_flag) + { + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cabac_mbaff; + } + else + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cabac_nonmbaff; + + ret = ih264d_parse_islice_data_cabac(ps_dec, ps_slice, + u2_first_mb_in_slice); + if(ret != OK) + return ret; + SWITCHONTRACE; SWITCHOFFTRACECABAC; + } + else + { + if(ps_dec->ps_cur_slice->u1_mbaff_frame_flag) + { + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cavlc_mbaff; + } + else + ps_dec->pf_get_mb_info = ih264d_get_mb_info_cavlc_nonmbaff; + ret = ih264d_parse_islice_data_cavlc(ps_dec, ps_slice, + u2_first_mb_in_slice); + if(ret != OK) + return ret; + } + + return OK; +} +","@@ -899,7 +899,6 @@ + + (UWORD16)(u1_num_mbs >> u1_mbaff)); + } + u1_num_mbs++; +- ps_dec->u2_total_mbs_coded++; + + /****************************************************************/ + /* Check for End Of Row */ +@@ -929,7 +928,7 @@ + + u1_num_mbs_next, u1_tfr_n_mb, + u1_end_of_row); + } +- ++ ps_dec->u2_total_mbs_coded += u1_num_mbs; + if(u1_tfr_n_mb) + u1_num_mbs = 0; + u1_mb_idx = u1_num_mbs; +@@ -1119,7 +1118,6 @@ + + (UWORD16)(u1_num_mbs >> u1_mbaff)); + } + u1_num_mbs++; +- ps_dec->u2_total_mbs_coded++; + + } + +@@ -1148,7 +1146,7 @@ + + u1_num_mbs_next, u1_tfr_n_mb, + u1_end_of_row); + } +- ++ ps_dec->u2_total_mbs_coded += u1_num_mbs; + if(u1_tfr_n_mb) + u1_num_mbs = 0; + u1_mb_idx = u1_num_mbs; +",1117,1353,2048 +17897,"int handle_ldf_stq(u32 insn, struct pt_regs *regs) +{ + unsigned long addr = compute_effective_address(regs, insn, 0); + int freg = ((insn >> 25) & 0x1e) | ((insn >> 20) & 0x20); + struct fpustate *f = FPUSTATE; + int asi = decode_asi(insn, regs); + int flag = (freg < 32) ? FPRS_DL : FPRS_DU; + + perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); + + save_and_clear_fpu(); + current_thread_info()->xfsr[0] &= ~0x1c000; + if (freg & 3) { + current_thread_info()->xfsr[0] |= (6 << 14) /* invalid_fp_register */; + do_fpother(regs); + return 0; + } + if (insn & 0x200000) { + /* STQ */ + u64 first = 0, second = 0; + + if (current_thread_info()->fpsaved[0] & flag) { + first = *(u64 *)&f->regs[freg]; + second = *(u64 *)&f->regs[freg+2]; + } + if (asi < 0x80) { + do_privact(regs); + return 1; + } + switch (asi) { + case ASI_P: + case ASI_S: break; + case ASI_PL: + case ASI_SL: + { + /* Need to convert endians */ + u64 tmp = __swab64p(&first); + + first = __swab64p(&second); + second = tmp; + break; + } + default: + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + if (put_user (first >> 32, (u32 __user *)addr) || + __put_user ((u32)first, (u32 __user *)(addr + 4)) || + __put_user (second >> 32, (u32 __user *)(addr + 8)) || + __put_user ((u32)second, (u32 __user *)(addr + 12))) { + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + } else { + /* LDF, LDDF, LDQF */ + u32 data[4] __attribute__ ((aligned(8))); + int size, i; + int err; + + if (asi < 0x80) { + do_privact(regs); + return 1; + } else if (asi > ASI_SNFL) { + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + switch (insn & 0x180000) { + case 0x000000: size = 1; break; + case 0x100000: size = 4; break; + default: size = 2; break; + } + for (i = 0; i < size; i++) + data[i] = 0; + + err = get_user (data[0], (u32 __user *) addr); + if (!err) { + for (i = 1; i < size; i++) + err |= __get_user (data[i], (u32 __user *)(addr + 4*i)); + } + if (err && !(asi & 0x2 /* NF */)) { + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + if (asi & 0x8) /* Little */ { + u64 tmp; + + switch (size) { + case 1: data[0] = le32_to_cpup(data + 0); break; + default:*(u64 *)(data + 0) = le64_to_cpup((u64 *)(data + 0)); + break; + case 4: tmp = le64_to_cpup((u64 *)(data + 0)); + *(u64 *)(data + 0) = le64_to_cpup((u64 *)(data + 2)); + *(u64 *)(data + 2) = tmp; + break; + } + } + if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) { + current_thread_info()->fpsaved[0] = FPRS_FEF; + current_thread_info()->gsr[0] = 0; + } + if (!(current_thread_info()->fpsaved[0] & flag)) { + if (freg < 32) + memset(f->regs, 0, 32*sizeof(u32)); + else + memset(f->regs+32, 0, 32*sizeof(u32)); + } + memcpy(f->regs + freg, data, size * 4); + current_thread_info()->fpsaved[0] |= flag; + } + advance(regs); + return 1; +} +",1,"int handle_ldf_stq(u32 insn, struct pt_regs *regs) +{ + unsigned long addr = compute_effective_address(regs, insn, 0); + int freg = ((insn >> 25) & 0x1e) | ((insn >> 20) & 0x20); + struct fpustate *f = FPUSTATE; + int asi = decode_asi(insn, regs); + int flag = (freg < 32) ? FPRS_DL : FPRS_DU; + + perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); + + save_and_clear_fpu(); + current_thread_info()->xfsr[0] &= ~0x1c000; + if (freg & 3) { + current_thread_info()->xfsr[0] |= (6 << 14) /* invalid_fp_register */; + do_fpother(regs); + return 0; + } + if (insn & 0x200000) { + /* STQ */ + u64 first = 0, second = 0; + + if (current_thread_info()->fpsaved[0] & flag) { + first = *(u64 *)&f->regs[freg]; + second = *(u64 *)&f->regs[freg+2]; + } + if (asi < 0x80) { + do_privact(regs); + return 1; + } + switch (asi) { + case ASI_P: + case ASI_S: break; + case ASI_PL: + case ASI_SL: + { + /* Need to convert endians */ + u64 tmp = __swab64p(&first); + + first = __swab64p(&second); + second = tmp; + break; + } + default: + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + if (put_user (first >> 32, (u32 __user *)addr) || + __put_user ((u32)first, (u32 __user *)(addr + 4)) || + __put_user (second >> 32, (u32 __user *)(addr + 8)) || + __put_user ((u32)second, (u32 __user *)(addr + 12))) { + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + } else { + /* LDF, LDDF, LDQF */ + u32 data[4] __attribute__ ((aligned(8))); + int size, i; + int err; + + if (asi < 0x80) { + do_privact(regs); + return 1; + } else if (asi > ASI_SNFL) { + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + switch (insn & 0x180000) { + case 0x000000: size = 1; break; + case 0x100000: size = 4; break; + default: size = 2; break; + } + for (i = 0; i < size; i++) + data[i] = 0; + + err = get_user (data[0], (u32 __user *) addr); + if (!err) { + for (i = 1; i < size; i++) + err |= __get_user (data[i], (u32 __user *)(addr + 4*i)); + } + if (err && !(asi & 0x2 /* NF */)) { + if (tlb_type == hypervisor) + sun4v_data_access_exception(regs, addr, 0); + else + spitfire_data_access_exception(regs, 0, addr); + return 1; + } + if (asi & 0x8) /* Little */ { + u64 tmp; + + switch (size) { + case 1: data[0] = le32_to_cpup(data + 0); break; + default:*(u64 *)(data + 0) = le64_to_cpup((u64 *)(data + 0)); + break; + case 4: tmp = le64_to_cpup((u64 *)(data + 0)); + *(u64 *)(data + 0) = le64_to_cpup((u64 *)(data + 2)); + *(u64 *)(data + 2) = tmp; + break; + } + } + if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) { + current_thread_info()->fpsaved[0] = FPRS_FEF; + current_thread_info()->gsr[0] = 0; + } + if (!(current_thread_info()->fpsaved[0] & flag)) { + if (freg < 32) + memset(f->regs, 0, 32*sizeof(u32)); + else + memset(f->regs+32, 0, 32*sizeof(u32)); + } + memcpy(f->regs + freg, data, size * 4); + current_thread_info()->fpsaved[0] |= flag; + } + advance(regs); + return 1; +} +","@@ -317,7 +317,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) + + addr = compute_effective_address(regs, insn, + ((insn >> 25) & 0x1f)); +- perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); ++ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr); + switch (asi) { + case ASI_NL: + case ASI_AIUPL: +@@ -384,7 +384,7 @@ int handle_popc(u32 insn, struct pt_regs *regs) + int ret, i, rd = ((insn >> 25) & 0x1f); + int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; + +- perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); ++ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); + if (insn & 0x2000) { + maybe_flush_windows(0, 0, rd, from_kernel); + value = sign_extend_imm13(insn); +@@ -431,7 +431,7 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs) + int asi = decode_asi(insn, regs); + int flag = (freg < 32) ? FPRS_DL : FPRS_DU; + +- perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); ++ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); + + save_and_clear_fpu(); + current_thread_info()->xfsr[0] &= ~0x1c000; +@@ -554,7 +554,7 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs) + int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; + unsigned long *reg; + +- perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); ++ perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); + + maybe_flush_windows(0, 0, rd, from_kernel); + reg = fetch_reg_addr(rd, regs); +@@ -586,7 +586,7 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr + + if (tstate & TSTATE_PRIV) + die_if_kernel(""lddfmna from kernel"", regs); +- perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar); ++ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, sfar); + if (test_thread_flag(TIF_32BIT)) + pc = (u32)pc; + if (get_user(insn, (u32 __user *) pc) != -EFAULT) { +@@ -647,7 +647,7 @@ void handle_stdfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr + + if (tstate & TSTATE_PRIV) + die_if_kernel(""stdfmna from kernel"", regs); +- perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar); ++ perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, sfar); + if (test_thread_flag(TIF_32BIT)) + pc = (u32)pc; + if (get_user(insn, (u32 __user *) pc) != -EFAULT) {",1291,1527,2048 +7377,"enum nss_status _nss_mymachines_gethostbyname3_r( + const char *name, + int af, + struct hostent *result, + char *buffer, size_t buflen, + int *errnop, int *h_errnop, + int32_t *ttlp, + char **canonp) { + + _cleanup_bus_message_unref_ sd_bus_message* reply = NULL; + _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL; + _cleanup_free_ char *class = NULL; + unsigned c = 0, i = 0; + char *r_name, *r_aliases, *r_addr, *r_addr_list; + size_t l, idx, ms, alen; + int r; + + assert(name); + assert(result); + assert(buffer); + assert(errnop); + assert(h_errnop); + + if (af == AF_UNSPEC) + af = AF_INET; + + if (af != AF_INET && af != AF_INET6) { + r = -EAFNOSUPPORT; + goto fail; + } + + r = sd_machine_get_class(name, &class); + if (r < 0) + goto fail; + if (!streq(class, ""container"")) { + r = -ENOTTY; + goto fail; + } + + r = sd_bus_open_system(&bus); + if (r < 0) + goto fail; + + r = sd_bus_call_method(bus, + ""org.freedesktop.machine1"", + ""/org/freedesktop/machine1"", + ""org.freedesktop.machine1.Manager"", + ""GetMachineAddresses"", + NULL, + &reply, + ""s"", name); + if (r < 0) + goto fail; + + r = sd_bus_message_enter_container(reply, 'a', ""(iay)""); + if (r < 0) + goto fail; + + r = count_addresses(reply, af, &c); + if (r < 0) + goto fail; + + if (c <= 0) { + *errnop = ENOENT; + *h_errnop = HOST_NOT_FOUND; + return NSS_STATUS_NOTFOUND; + } + + alen = FAMILY_ADDRESS_SIZE(af); + l = strlen(name); + + ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*); + + if (buflen < ms) { + *errnop = ENOMEM; + *h_errnop = NO_RECOVERY; + return NSS_STATUS_TRYAGAIN; + } + + /* First, append name */ + r_name = buffer; + memcpy(r_name, name, l+1); + idx = ALIGN(l+1); + + /* Second, create aliases array */ + r_aliases = buffer + idx; + ((char**) r_aliases)[0] = NULL; + idx += sizeof(char*); + + /* Third, append addresses */ + r_addr = buffer + idx; + while ((r = sd_bus_message_enter_container(reply, 'r', ""iay"")) > 0) { + int family; + const void *a; + size_t sz; + + r = sd_bus_message_read(reply, ""i"", &family); + if (r < 0) + goto fail; + + r = sd_bus_message_read_array(reply, 'y', &a, &sz); + if (r < 0) + goto fail; + + r = sd_bus_message_exit_container(reply); + if (r < 0) + goto fail; + + if (family != af) + continue; + + if (sz != alen) { + r = -EINVAL; + goto fail; + } + + memcpy(r_addr + i*ALIGN(alen), a, alen); + i++; + } + + assert(i == c); + idx += c * ALIGN(alen); + + r = sd_bus_message_exit_container(reply); + if (r < 0) + goto fail; + + /* Third, append address pointer array */ + r_addr_list = buffer + idx; + for (i = 0; i < c; i++) + ((char**) r_addr_list)[i] = r_addr + i*ALIGN(alen); + + ((char**) r_addr_list)[i] = NULL; + idx += (c+1) * sizeof(char*); + + assert(idx == ms); + + result->h_name = r_name; + result->h_aliases = (char**) r_aliases; + result->h_addrtype = af; + result->h_length = alen; + result->h_addr_list = (char**) r_addr_list; + + if (ttlp) + *ttlp = 0; + + if (canonp) + *canonp = r_name; + + /* Explicitly reset all error variables */ + *errnop = 0; + *h_errnop = NETDB_SUCCESS; + h_errno = 0; + + return NSS_STATUS_SUCCESS; + +fail: + *errnop = -r; + *h_errnop = NO_DATA; + return NSS_STATUS_UNAVAIL; +} +",0,"enum nss_status _nss_mymachines_gethostbyname3_r( + const char *name, + int af, + struct hostent *result, + char *buffer, size_t buflen, + int *errnop, int *h_errnop, + int32_t *ttlp, + char **canonp) { + + _cleanup_bus_message_unref_ sd_bus_message* reply = NULL; + _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL; + _cleanup_free_ char *class = NULL; + unsigned c = 0, i = 0; + char *r_name, *r_aliases, *r_addr, *r_addr_list; + size_t l, idx, ms, alen; + int r; + + assert(name); + assert(result); + assert(buffer); + assert(errnop); + assert(h_errnop); + + if (af == AF_UNSPEC) + af = AF_INET; + + if (af != AF_INET && af != AF_INET6) { + r = -EAFNOSUPPORT; + goto fail; + } + + r = sd_machine_get_class(name, &class); + if (r < 0) + goto fail; + if (!streq(class, ""container"")) { + r = -ENOTTY; + goto fail; + } + + r = sd_bus_open_system(&bus); + if (r < 0) + goto fail; + + r = sd_bus_call_method(bus, + ""org.freedesktop.machine1"", + ""/org/freedesktop/machine1"", + ""org.freedesktop.machine1.Manager"", + ""GetMachineAddresses"", + NULL, + &reply, + ""s"", name); + if (r < 0) + goto fail; + + r = sd_bus_message_enter_container(reply, 'a', ""(iay)""); + if (r < 0) + goto fail; + + r = count_addresses(reply, af, &c); + if (r < 0) + goto fail; + + if (c <= 0) { + *errnop = ENOENT; + *h_errnop = HOST_NOT_FOUND; + return NSS_STATUS_NOTFOUND; + } + + alen = FAMILY_ADDRESS_SIZE(af); + l = strlen(name); + + ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*); + + if (buflen < ms) { + *errnop = ENOMEM; + *h_errnop = NO_RECOVERY; + return NSS_STATUS_TRYAGAIN; + } + + /* First, append name */ + r_name = buffer; + memcpy(r_name, name, l+1); + idx = ALIGN(l+1); + + /* Second, create aliases array */ + r_aliases = buffer + idx; + ((char**) r_aliases)[0] = NULL; + idx += sizeof(char*); + + /* Third, append addresses */ + r_addr = buffer + idx; + while ((r = sd_bus_message_enter_container(reply, 'r', ""iay"")) > 0) { + int family; + const void *a; + size_t sz; + + r = sd_bus_message_read(reply, ""i"", &family); + if (r < 0) + goto fail; + + r = sd_bus_message_read_array(reply, 'y', &a, &sz); + if (r < 0) + goto fail; + + r = sd_bus_message_exit_container(reply); + if (r < 0) + goto fail; + + if (family != af) + continue; + + if (sz != alen) { + r = -EINVAL; + goto fail; + } + + memcpy(r_addr + i*ALIGN(alen), a, alen); + i++; + } + + assert(i == c); + idx += c * ALIGN(alen); + + r = sd_bus_message_exit_container(reply); + if (r < 0) + goto fail; + + /* Third, append address pointer array */ + r_addr_list = buffer + idx; + for (i = 0; i < c; i++) + ((char**) r_addr_list)[i] = r_addr + i*ALIGN(alen); + + ((char**) r_addr_list)[i] = NULL; + idx += (c+1) * sizeof(char*); + + assert(idx == ms); + + result->h_name = r_name; + result->h_aliases = (char**) r_aliases; + result->h_addrtype = af; + result->h_length = alen; + result->h_addr_list = (char**) r_addr_list; + + if (ttlp) + *ttlp = 0; + + if (canonp) + *canonp = r_name; + + /* Explicitly reset all error variables */ + *errnop = 0; + *h_errnop = NETDB_SUCCESS; + h_errno = 0; + + return NSS_STATUS_SUCCESS; + +fail: + *errnop = -r; + *h_errnop = NO_DATA; + return NSS_STATUS_UNAVAIL; +} +","@@ -416,6 +416,9 @@ enum nss_status _nss_mymachines_getpwnam_r( + if (!e || e == p) + goto not_found; + ++ if (e - p > HOST_NAME_MAX - 1) /* -1 for the last dash */ ++ goto not_found; ++ + r = parse_uid(e + 1, &uid); + if (r < 0) + goto not_found; +@@ -573,6 +576,9 @@ enum nss_status _nss_mymachines_getgrnam_r( + if (!e || e == p) + goto not_found; + ++ if (e - p > HOST_NAME_MAX - 1) /* -1 for the last dash */ ++ goto not_found; ++ + r = parse_gid(e + 1, &gid); + if (r < 0) + goto not_found;",1058,1294,2048 +15218,"void RenderFrameImpl::BeginNavigationInternal( + std::unique_ptr info) { + std::unique_ptr document_state_owned = BuildDocumentState(); + DocumentState* document_state = document_state_owned.get(); + if (!frame_->CreatePlaceholderDocumentLoader( + *info, std::move(document_state_owned))) { + return; + } + + browser_side_navigation_pending_ = true; + browser_side_navigation_pending_url_ = info->url_request.Url(); + + blink::WebURLRequest& request = info->url_request; + + WebDocument frame_document = frame_->GetDocument(); + if (info->frame_type == network::mojom::RequestContextFrameType::kTopLevel) + request.SetSiteForCookies(request.Url()); + else + request.SetSiteForCookies(frame_document.SiteForCookies()); + + ui::PageTransition transition_type = GetTransitionType( + ui::PAGE_TRANSITION_LINK, + info->frame_load_type == WebFrameLoadType::kReplaceCurrentItem, + IsMainFrame(), info->navigation_type); + if (info->is_client_redirect) { + transition_type = ui::PageTransitionFromInt( + transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); + } + + WillSendRequestInternal( + request, + frame_->Parent() ? ResourceType::kSubFrame : ResourceType::kMainFrame, + document_state, transition_type); + + if (!info->url_request.GetExtraData()) + info->url_request.SetExtraData(std::make_unique()); + + DCHECK_EQ(network::mojom::FetchRequestMode::kNavigate, + info->url_request.GetFetchRequestMode()); + DCHECK_EQ(network::mojom::FetchCredentialsMode::kInclude, + info->url_request.GetFetchCredentialsMode()); + DCHECK_EQ(network::mojom::FetchRedirectMode::kManual, + info->url_request.GetFetchRedirectMode()); + DCHECK(frame_->Parent() || + info->frame_type == + network::mojom::RequestContextFrameType::kTopLevel); + DCHECK(!frame_->Parent() || + info->frame_type == network::mojom::RequestContextFrameType::kNested); + + bool is_form_submission = + info->navigation_type == blink::kWebNavigationTypeFormSubmitted || + info->navigation_type == blink::kWebNavigationTypeFormResubmitted; + + GURL searchable_form_url; + std::string searchable_form_encoding; + if (!info->form.IsNull()) { + WebSearchableFormData web_searchable_form_data(info->form); + searchable_form_url = web_searchable_form_data.Url(); + searchable_form_encoding = web_searchable_form_data.Encoding().Utf8(); + } + + GURL client_side_redirect_url; + if (info->is_client_redirect) + client_side_redirect_url = frame_->GetDocument().Url(); + + blink::mojom::BlobURLTokenPtr blob_url_token( + CloneBlobURLToken(info->blob_url_token.get())); + + int load_flags = info->url_request.GetLoadFlagsForWebUrlRequest(); + std::unique_ptr initiator = + GetDevToolsInitiator(info->devtools_initiator_info); + mojom::BeginNavigationParamsPtr begin_navigation_params = + mojom::BeginNavigationParams::New( + GetWebURLRequestHeadersAsString(info->url_request), load_flags, + info->url_request.GetSkipServiceWorker(), + GetRequestContextTypeForWebURLRequest(info->url_request), + GetMixedContentContextTypeForWebURLRequest(info->url_request), + is_form_submission, searchable_form_url, searchable_form_encoding, + client_side_redirect_url, + initiator ? base::make_optional(std::move(*initiator)) + : base::nullopt); + + mojom::NavigationClientAssociatedPtrInfo navigation_client_info; + if (IsPerNavigationMojoInterfaceEnabled()) { + BindNavigationClient(mojo::MakeRequest(&navigation_client_info)); + navigation_client_impl_->MarkWasInitiatedInThisFrame(); + } + + blink::mojom::NavigationInitiatorPtr initiator_ptr( + blink::mojom::NavigationInitiatorPtrInfo( + std::move(info->navigation_initiator_handle), 0)); + + bool current_frame_has_download_sandbox_flag = + !frame_->IsAllowedToDownloadWithoutUserActivation(); + bool has_download_sandbox_flag = + info->initiator_frame_has_download_sandbox_flag || + current_frame_has_download_sandbox_flag; + bool from_ad = info->initiator_frame_is_ad || frame_->IsAdSubframe(); + + GetFrameHost()->BeginNavigation( + MakeCommonNavigationParams(frame_->GetSecurityOrigin(), std::move(info), + load_flags, has_download_sandbox_flag, + from_ad), + std::move(begin_navigation_params), std::move(blob_url_token), + std::move(navigation_client_info), std::move(initiator_ptr)); +} +",0,"void RenderFrameImpl::BeginNavigationInternal( + std::unique_ptr info) { + std::unique_ptr document_state_owned = BuildDocumentState(); + DocumentState* document_state = document_state_owned.get(); + if (!frame_->CreatePlaceholderDocumentLoader( + *info, std::move(document_state_owned))) { + return; + } + + browser_side_navigation_pending_ = true; + browser_side_navigation_pending_url_ = info->url_request.Url(); + + blink::WebURLRequest& request = info->url_request; + + WebDocument frame_document = frame_->GetDocument(); + if (info->frame_type == network::mojom::RequestContextFrameType::kTopLevel) + request.SetSiteForCookies(request.Url()); + else + request.SetSiteForCookies(frame_document.SiteForCookies()); + + ui::PageTransition transition_type = GetTransitionType( + ui::PAGE_TRANSITION_LINK, + info->frame_load_type == WebFrameLoadType::kReplaceCurrentItem, + IsMainFrame(), info->navigation_type); + if (info->is_client_redirect) { + transition_type = ui::PageTransitionFromInt( + transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); + } + + WillSendRequestInternal( + request, + frame_->Parent() ? ResourceType::kSubFrame : ResourceType::kMainFrame, + document_state, transition_type); + + if (!info->url_request.GetExtraData()) + info->url_request.SetExtraData(std::make_unique()); + + DCHECK_EQ(network::mojom::FetchRequestMode::kNavigate, + info->url_request.GetFetchRequestMode()); + DCHECK_EQ(network::mojom::FetchCredentialsMode::kInclude, + info->url_request.GetFetchCredentialsMode()); + DCHECK_EQ(network::mojom::FetchRedirectMode::kManual, + info->url_request.GetFetchRedirectMode()); + DCHECK(frame_->Parent() || + info->frame_type == + network::mojom::RequestContextFrameType::kTopLevel); + DCHECK(!frame_->Parent() || + info->frame_type == network::mojom::RequestContextFrameType::kNested); + + bool is_form_submission = + info->navigation_type == blink::kWebNavigationTypeFormSubmitted || + info->navigation_type == blink::kWebNavigationTypeFormResubmitted; + + GURL searchable_form_url; + std::string searchable_form_encoding; + if (!info->form.IsNull()) { + WebSearchableFormData web_searchable_form_data(info->form); + searchable_form_url = web_searchable_form_data.Url(); + searchable_form_encoding = web_searchable_form_data.Encoding().Utf8(); + } + + GURL client_side_redirect_url; + if (info->is_client_redirect) + client_side_redirect_url = frame_->GetDocument().Url(); + + blink::mojom::BlobURLTokenPtr blob_url_token( + CloneBlobURLToken(info->blob_url_token.get())); + + int load_flags = info->url_request.GetLoadFlagsForWebUrlRequest(); + std::unique_ptr initiator = + GetDevToolsInitiator(info->devtools_initiator_info); + mojom::BeginNavigationParamsPtr begin_navigation_params = + mojom::BeginNavigationParams::New( + GetWebURLRequestHeadersAsString(info->url_request), load_flags, + info->url_request.GetSkipServiceWorker(), + GetRequestContextTypeForWebURLRequest(info->url_request), + GetMixedContentContextTypeForWebURLRequest(info->url_request), + is_form_submission, searchable_form_url, searchable_form_encoding, + client_side_redirect_url, + initiator ? base::make_optional(std::move(*initiator)) + : base::nullopt); + + mojom::NavigationClientAssociatedPtrInfo navigation_client_info; + if (IsPerNavigationMojoInterfaceEnabled()) { + BindNavigationClient(mojo::MakeRequest(&navigation_client_info)); + navigation_client_impl_->MarkWasInitiatedInThisFrame(); + } + + blink::mojom::NavigationInitiatorPtr initiator_ptr( + blink::mojom::NavigationInitiatorPtrInfo( + std::move(info->navigation_initiator_handle), 0)); + + bool current_frame_has_download_sandbox_flag = + !frame_->IsAllowedToDownloadWithoutUserActivation(); + bool has_download_sandbox_flag = + info->initiator_frame_has_download_sandbox_flag || + current_frame_has_download_sandbox_flag; + bool from_ad = info->initiator_frame_is_ad || frame_->IsAdSubframe(); + + GetFrameHost()->BeginNavigation( + MakeCommonNavigationParams(frame_->GetSecurityOrigin(), std::move(info), + load_flags, has_download_sandbox_flag, + from_ad), + std::move(begin_navigation_params), std::move(blob_url_token), + std::move(navigation_client_info), std::move(initiator_ptr)); +} +","@@ -4545,9 +4545,9 @@ void RenderFrameImpl::DidAddMessageToConsole( + } + } + +- Send(new FrameHostMsg_DidAddMessageToConsole( +- routing_id_, static_cast(log_severity), message.text.Utf16(), +- static_cast(source_line), source_name.Utf16())); ++ GetFrameHost()->DidAddMessageToConsole(message.level, message.text.Utf16(), ++ static_cast(source_line), ++ source_name.Utf16()); + } + + void RenderFrameImpl::DownloadURL(",990,1226,2048 +4739,"static int __driver_rfc4106_decrypt(struct aead_request *req) +{ + u8 one_entry_in_sg = 0; + u8 *src, *dst, *assoc; + unsigned long tempCipherLen = 0; + __be32 counter = cpu_to_be32(1); + int retval = 0; + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); + void *aes_ctx = &(ctx->aes_key_expanded); + unsigned long auth_tag_len = crypto_aead_authsize(tfm); + u8 iv_and_authTag[32+AESNI_ALIGN]; + u8 *iv = (u8 *) PTR_ALIGN((u8 *)iv_and_authTag, AESNI_ALIGN); + u8 *authTag = iv + 16; + struct scatter_walk src_sg_walk; + struct scatter_walk assoc_sg_walk; + struct scatter_walk dst_sg_walk; + unsigned int i; + + if (unlikely((req->cryptlen < auth_tag_len) || + (req->assoclen != 8 && req->assoclen != 12))) + return -EINVAL; + /* Assuming we are supporting rfc4106 64-bit extended */ + /* sequence numbers We need to have the AAD length */ + /* equal to 8 or 12 bytes */ + + tempCipherLen = (unsigned long)(req->cryptlen - auth_tag_len); + /* IV below built */ + for (i = 0; i < 4; i++) + *(iv+i) = ctx->nonce[i]; + for (i = 0; i < 8; i++) + *(iv+4+i) = req->iv[i]; + *((__be32 *)(iv+12)) = counter; + + if ((sg_is_last(req->src)) && (sg_is_last(req->assoc))) { + one_entry_in_sg = 1; + scatterwalk_start(&src_sg_walk, req->src); + scatterwalk_start(&assoc_sg_walk, req->assoc); + src = scatterwalk_map(&src_sg_walk); + assoc = scatterwalk_map(&assoc_sg_walk); + dst = src; + if (unlikely(req->src != req->dst)) { + scatterwalk_start(&dst_sg_walk, req->dst); + dst = scatterwalk_map(&dst_sg_walk); + } + + } else { + /* Allocate memory for src, dst, assoc */ + src = kmalloc(req->cryptlen + req->assoclen, GFP_ATOMIC); + if (!src) + return -ENOMEM; + assoc = (src + req->cryptlen + auth_tag_len); + scatterwalk_map_and_copy(src, req->src, 0, req->cryptlen, 0); + scatterwalk_map_and_copy(assoc, req->assoc, 0, + req->assoclen, 0); + dst = src; + } + + aesni_gcm_dec_tfm(aes_ctx, dst, src, tempCipherLen, iv, + ctx->hash_subkey, assoc, (unsigned long)req->assoclen, + authTag, auth_tag_len); + + /* Compare generated tag with passed in tag. */ + retval = crypto_memneq(src + tempCipherLen, authTag, auth_tag_len) ? + -EBADMSG : 0; + + if (one_entry_in_sg) { + if (unlikely(req->src != req->dst)) { + scatterwalk_unmap(dst); + scatterwalk_done(&dst_sg_walk, 0, 0); + } + scatterwalk_unmap(src); + scatterwalk_unmap(assoc); + scatterwalk_done(&src_sg_walk, 0, 0); + scatterwalk_done(&assoc_sg_walk, 0, 0); + } else { + scatterwalk_map_and_copy(dst, req->dst, 0, req->cryptlen, 1); + kfree(src); + } + return retval; +} +",0,"static int __driver_rfc4106_decrypt(struct aead_request *req) +{ + u8 one_entry_in_sg = 0; + u8 *src, *dst, *assoc; + unsigned long tempCipherLen = 0; + __be32 counter = cpu_to_be32(1); + int retval = 0; + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); + void *aes_ctx = &(ctx->aes_key_expanded); + unsigned long auth_tag_len = crypto_aead_authsize(tfm); + u8 iv_and_authTag[32+AESNI_ALIGN]; + u8 *iv = (u8 *) PTR_ALIGN((u8 *)iv_and_authTag, AESNI_ALIGN); + u8 *authTag = iv + 16; + struct scatter_walk src_sg_walk; + struct scatter_walk assoc_sg_walk; + struct scatter_walk dst_sg_walk; + unsigned int i; + + if (unlikely((req->cryptlen < auth_tag_len) || + (req->assoclen != 8 && req->assoclen != 12))) + return -EINVAL; + /* Assuming we are supporting rfc4106 64-bit extended */ + /* sequence numbers We need to have the AAD length */ + /* equal to 8 or 12 bytes */ + + tempCipherLen = (unsigned long)(req->cryptlen - auth_tag_len); + /* IV below built */ + for (i = 0; i < 4; i++) + *(iv+i) = ctx->nonce[i]; + for (i = 0; i < 8; i++) + *(iv+4+i) = req->iv[i]; + *((__be32 *)(iv+12)) = counter; + + if ((sg_is_last(req->src)) && (sg_is_last(req->assoc))) { + one_entry_in_sg = 1; + scatterwalk_start(&src_sg_walk, req->src); + scatterwalk_start(&assoc_sg_walk, req->assoc); + src = scatterwalk_map(&src_sg_walk); + assoc = scatterwalk_map(&assoc_sg_walk); + dst = src; + if (unlikely(req->src != req->dst)) { + scatterwalk_start(&dst_sg_walk, req->dst); + dst = scatterwalk_map(&dst_sg_walk); + } + + } else { + /* Allocate memory for src, dst, assoc */ + src = kmalloc(req->cryptlen + req->assoclen, GFP_ATOMIC); + if (!src) + return -ENOMEM; + assoc = (src + req->cryptlen + auth_tag_len); + scatterwalk_map_and_copy(src, req->src, 0, req->cryptlen, 0); + scatterwalk_map_and_copy(assoc, req->assoc, 0, + req->assoclen, 0); + dst = src; + } + + aesni_gcm_dec_tfm(aes_ctx, dst, src, tempCipherLen, iv, + ctx->hash_subkey, assoc, (unsigned long)req->assoclen, + authTag, auth_tag_len); + + /* Compare generated tag with passed in tag. */ + retval = crypto_memneq(src + tempCipherLen, authTag, auth_tag_len) ? + -EBADMSG : 0; + + if (one_entry_in_sg) { + if (unlikely(req->src != req->dst)) { + scatterwalk_unmap(dst); + scatterwalk_done(&dst_sg_walk, 0, 0); + } + scatterwalk_unmap(src); + scatterwalk_unmap(assoc); + scatterwalk_done(&src_sg_walk, 0, 0); + scatterwalk_done(&assoc_sg_walk, 0, 0); + } else { + scatterwalk_map_and_copy(dst, req->dst, 0, req->cryptlen, 1); + kfree(src); + } + return retval; +} +","@@ -1546,4 +1546,4 @@ module_exit(aesni_exit); + + MODULE_DESCRIPTION(""Rijndael (AES) Cipher Algorithm, Intel AES-NI instructions optimized""); + MODULE_LICENSE(""GPL""); +-MODULE_ALIAS(""aes""); ++MODULE_ALIAS_CRYPTO(""aes"");",858,1094,2048 +18060,"static int mpage_da_map_blocks(struct mpage_da_data *mpd) +{ + int err, blks, get_blocks_flags; + struct buffer_head new; + sector_t next = mpd->b_blocknr; + unsigned max_blocks = mpd->b_size >> mpd->inode->i_blkbits; + loff_t disksize = EXT4_I(mpd->inode)->i_disksize; + handle_t *handle = NULL; + + /* + * We consider only non-mapped and non-allocated blocks + */ + if ((mpd->b_state & (1 << BH_Mapped)) && + !(mpd->b_state & (1 << BH_Delay)) && + !(mpd->b_state & (1 << BH_Unwritten))) + return 0; + + /* + * If we didn't accumulate anything to write simply return + */ + if (!mpd->b_size) + return 0; + + handle = ext4_journal_current_handle(); + BUG_ON(!handle); + + /* + * Call ext4_get_blocks() to allocate any delayed allocation + * blocks, or to convert an uninitialized extent to be + * initialized (in the case where we have written into + * one or more preallocated blocks). + * + * We pass in the magic EXT4_GET_BLOCKS_DELALLOC_RESERVE to + * indicate that we are on the delayed allocation path. This + * affects functions in many different parts of the allocation + * call path. This flag exists primarily because we don't + * want to change *many* call functions, so ext4_get_blocks() + * will set the magic i_delalloc_reserved_flag once the + * inode's allocation semaphore is taken. + * + * If the blocks in questions were delalloc blocks, set + * EXT4_GET_BLOCKS_DELALLOC_RESERVE so the delalloc accounting + * variables are updated after the blocks have been allocated. + */ + new.b_state = 0; + get_blocks_flags = EXT4_GET_BLOCKS_CREATE; + if (mpd->b_state & (1 << BH_Delay)) + get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE; + + blks = ext4_get_blocks(handle, mpd->inode, next, max_blocks, + &new, get_blocks_flags); + if (blks < 0) { + err = blks; + /* + * If get block returns with error we simply + * return. Later writepage will redirty the page and + * writepages will find the dirty page again + */ + if (err == -EAGAIN) + return 0; + + if (err == -ENOSPC && + ext4_count_free_blocks(mpd->inode->i_sb)) { + mpd->retval = err; + return 0; + } + + /* + * get block failure will cause us to loop in + * writepages, because a_ops->writepage won't be able + * to make progress. The page will be redirtied by + * writepage and writepages will again try to write + * the same. + */ + ext4_msg(mpd->inode->i_sb, KERN_CRIT, + ""delayed block allocation failed for inode %lu at "" + ""logical offset %llu with max blocks %zd with "" + ""error %d\n"", mpd->inode->i_ino, + (unsigned long long) next, + mpd->b_size >> mpd->inode->i_blkbits, err); + printk(KERN_CRIT ""This should not happen!! "" + ""Data will be lost\n""); + if (err == -ENOSPC) { + ext4_print_free_blocks(mpd->inode); + } + /* invalidate all the pages */ + ext4_da_block_invalidatepages(mpd, next, + mpd->b_size >> mpd->inode->i_blkbits); + return err; + } + BUG_ON(blks == 0); + + new.b_size = (blks << mpd->inode->i_blkbits); + + if (buffer_new(&new)) + __unmap_underlying_blocks(mpd->inode, &new); + + /* + * If blocks are delayed marked, we need to + * put actual blocknr and drop delayed bit + */ + if ((mpd->b_state & (1 << BH_Delay)) || + (mpd->b_state & (1 << BH_Unwritten))) + mpage_put_bnr_to_bhs(mpd, next, &new); + + if (ext4_should_order_data(mpd->inode)) { + err = ext4_jbd2_file_inode(handle, mpd->inode); + if (err) + return err; + } + + /* + * Update on-disk size along with block allocation. + */ + disksize = ((loff_t) next + blks) << mpd->inode->i_blkbits; + if (disksize > i_size_read(mpd->inode)) + disksize = i_size_read(mpd->inode); + if (disksize > EXT4_I(mpd->inode)->i_disksize) { + ext4_update_i_disksize(mpd->inode, disksize); + return ext4_mark_inode_dirty(handle, mpd->inode); + } + + return 0; +} +",1,"static int mpage_da_map_blocks(struct mpage_da_data *mpd) +{ + int err, blks, get_blocks_flags; + struct buffer_head new; + sector_t next = mpd->b_blocknr; + unsigned max_blocks = mpd->b_size >> mpd->inode->i_blkbits; + loff_t disksize = EXT4_I(mpd->inode)->i_disksize; + handle_t *handle = NULL; + + /* + * We consider only non-mapped and non-allocated blocks + */ + if ((mpd->b_state & (1 << BH_Mapped)) && + !(mpd->b_state & (1 << BH_Delay)) && + !(mpd->b_state & (1 << BH_Unwritten))) + return 0; + + /* + * If we didn't accumulate anything to write simply return + */ + if (!mpd->b_size) + return 0; + + handle = ext4_journal_current_handle(); + BUG_ON(!handle); + + /* + * Call ext4_get_blocks() to allocate any delayed allocation + * blocks, or to convert an uninitialized extent to be + * initialized (in the case where we have written into + * one or more preallocated blocks). + * + * We pass in the magic EXT4_GET_BLOCKS_DELALLOC_RESERVE to + * indicate that we are on the delayed allocation path. This + * affects functions in many different parts of the allocation + * call path. This flag exists primarily because we don't + * want to change *many* call functions, so ext4_get_blocks() + * will set the magic i_delalloc_reserved_flag once the + * inode's allocation semaphore is taken. + * + * If the blocks in questions were delalloc blocks, set + * EXT4_GET_BLOCKS_DELALLOC_RESERVE so the delalloc accounting + * variables are updated after the blocks have been allocated. + */ + new.b_state = 0; + get_blocks_flags = EXT4_GET_BLOCKS_CREATE; + if (ext4_should_dioread_nolock(mpd->inode)) + get_blocks_flags |= EXT4_GET_BLOCKS_IO_CREATE_EXT; + if (mpd->b_state & (1 << BH_Delay)) + get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE; + + blks = ext4_get_blocks(handle, mpd->inode, next, max_blocks, + &new, get_blocks_flags); + if (blks < 0) { + err = blks; + /* + * If get block returns with error we simply + * return. Later writepage will redirty the page and + * writepages will find the dirty page again + */ + if (err == -EAGAIN) + return 0; + + if (err == -ENOSPC && + ext4_count_free_blocks(mpd->inode->i_sb)) { + mpd->retval = err; + return 0; + } + + /* + * get block failure will cause us to loop in + * writepages, because a_ops->writepage won't be able + * to make progress. The page will be redirtied by + * writepage and writepages will again try to write + * the same. + */ + ext4_msg(mpd->inode->i_sb, KERN_CRIT, + ""delayed block allocation failed for inode %lu at "" + ""logical offset %llu with max blocks %zd with "" + ""error %d\n"", mpd->inode->i_ino, + (unsigned long long) next, + mpd->b_size >> mpd->inode->i_blkbits, err); + printk(KERN_CRIT ""This should not happen!! "" + ""Data will be lost\n""); + if (err == -ENOSPC) { + ext4_print_free_blocks(mpd->inode); + } + /* invalidate all the pages */ + ext4_da_block_invalidatepages(mpd, next, + mpd->b_size >> mpd->inode->i_blkbits); + return err; + } + BUG_ON(blks == 0); + + new.b_size = (blks << mpd->inode->i_blkbits); + + if (buffer_new(&new)) + __unmap_underlying_blocks(mpd->inode, &new); + + /* + * If blocks are delayed marked, we need to + * put actual blocknr and drop delayed bit + */ + if ((mpd->b_state & (1 << BH_Delay)) || + (mpd->b_state & (1 << BH_Unwritten))) + mpage_put_bnr_to_bhs(mpd, next, &new); + + if (ext4_should_order_data(mpd->inode)) { + err = ext4_jbd2_file_inode(handle, mpd->inode); + if (err) + return err; + } + + /* + * Update on-disk size along with block allocation. + */ + disksize = ((loff_t) next + blks) << mpd->inode->i_blkbits; + if (disksize > i_size_read(mpd->inode)) + disksize = i_size_read(mpd->inode); + if (disksize > EXT4_I(mpd->inode)->i_disksize) { + ext4_update_i_disksize(mpd->inode, disksize); + return ext4_mark_inode_dirty(handle, mpd->inode); + } + + return 0; +} +","@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + + #include ""ext4_jbd2.h"" + #include ""xattr.h"" +@@ -1534,6 +1535,8 @@ static void ext4_truncate_failed_write(struct inode *inode) + ext4_truncate(inode); + } + ++static int ext4_get_block_write(struct inode *inode, sector_t iblock, ++ struct buffer_head *bh_result, int create); + static int ext4_write_begin(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, unsigned flags, + struct page **pagep, void **fsdata) +@@ -1575,8 +1578,12 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, + } + *pagep = page; + +- ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, +- ext4_get_block); ++ if (ext4_should_dioread_nolock(inode)) ++ ret = block_write_begin(file, mapping, pos, len, flags, pagep, ++ fsdata, ext4_get_block_write); ++ else ++ ret = block_write_begin(file, mapping, pos, len, flags, pagep, ++ fsdata, ext4_get_block); + + if (!ret && ext4_should_journal_data(inode)) { + ret = walk_page_buffers(handle, page_buffers(page), +@@ -2092,6 +2099,8 @@ static void mpage_put_bnr_to_bhs(struct mpage_da_data *mpd, sector_t logical, + } else if (buffer_mapped(bh)) + BUG_ON(bh->b_blocknr != pblock); + ++ if (buffer_uninit(exbh)) ++ set_buffer_uninit(bh); + cur_logical++; + pblock++; + } while ((bh = bh->b_this_page) != head); +@@ -2221,6 +2230,8 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd) + */ + new.b_state = 0; + get_blocks_flags = EXT4_GET_BLOCKS_CREATE; ++ if (ext4_should_dioread_nolock(mpd->inode)) ++ get_blocks_flags |= EXT4_GET_BLOCKS_IO_CREATE_EXT; + if (mpd->b_state & (1 << BH_Delay)) + get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE; + +@@ -2636,6 +2647,9 @@ static int __ext4_journalled_writepage(struct page *page, + return ret; + } + ++static int ext4_set_bh_endio(struct buffer_head *bh, struct inode *inode); ++static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate); ++ + /* + * Note that we don't need to start a transaction unless we're journaling data + * because we should have holes filled from ext4_page_mkwrite(). We even don't +@@ -2683,7 +2697,7 @@ static int ext4_writepage(struct page *page, + int ret = 0; + loff_t size; + unsigned int len; +- struct buffer_head *page_bufs; ++ struct buffer_head *page_bufs = NULL; + struct inode *inode = page->mapping->host; + + trace_ext4_writepage(inode, page); +@@ -2759,7 +2773,11 @@ static int ext4_writepage(struct page *page, + + if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) + ret = nobh_writepage(page, noalloc_get_block_write, wbc); +- else ++ else if (page_bufs && buffer_uninit(page_bufs)) { ++ ext4_set_bh_endio(page_bufs, inode); ++ ret = block_write_full_page_endio(page, noalloc_get_block_write, ++ wbc, ext4_end_io_buffer_write); ++ } else + ret = block_write_full_page(page, noalloc_get_block_write, + wbc); + +@@ -3347,10 +3365,44 @@ ext4_readpages(struct file *file, struct address_space *mapping, + return mpage_readpages(mapping, pages, nr_pages, ext4_get_block); + } + ++static void ext4_free_io_end(ext4_io_end_t *io) ++{ ++ BUG_ON(!io); ++ if (io->page) ++ put_page(io->page); ++ iput(io->inode); ++ kfree(io); ++} ++ ++static void ext4_invalidatepage_free_endio(struct page *page, unsigned long offset) ++{ ++ struct buffer_head *head, *bh; ++ unsigned int curr_off = 0; ++ ++ if (!page_has_buffers(page)) ++ return; ++ head = bh = page_buffers(page); ++ do { ++ if (offset <= curr_off && test_clear_buffer_uninit(bh) ++ && bh->b_private) { ++ ext4_free_io_end(bh->b_private); ++ bh->b_private = NULL; ++ bh->b_end_io = NULL; ++ } ++ curr_off = curr_off + bh->b_size; ++ bh = bh->b_this_page; ++ } while (bh != head); ++} ++ + static void ext4_invalidatepage(struct page *page, unsigned long offset) + { + journal_t *journal = EXT4_JOURNAL(page->mapping->host); + ++ /* ++ * free any io_end structure allocated for buffers to be discarded ++ */ ++ if (ext4_should_dioread_nolock(page->mapping->host)) ++ ext4_invalidatepage_free_endio(page, offset); + /* + * If it's a full truncate we just forget about the pending dirtying + */ +@@ -3471,10 +3523,11 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, + static int ext4_get_block_write(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { +- handle_t *handle = NULL; ++ handle_t *handle = ext4_journal_current_handle(); + int ret = 0; + unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; + int dio_credits; ++ int started = 0; + + ext4_debug(""ext4_get_block_write: inode %lu, create flag %d\n"", + inode->i_ino, create); +@@ -3485,44 +3538,44 @@ static int ext4_get_block_write(struct inode *inode, sector_t iblock, + */ + create = EXT4_GET_BLOCKS_IO_CREATE_EXT; + +- if (max_blocks > DIO_MAX_BLOCKS) +- max_blocks = DIO_MAX_BLOCKS; +- dio_credits = ext4_chunk_trans_blocks(inode, max_blocks); +- handle = ext4_journal_start(inode, dio_credits); +- if (IS_ERR(handle)) { +- ret = PTR_ERR(handle); +- goto out; ++ if (!handle) { ++ if (max_blocks > DIO_MAX_BLOCKS) ++ max_blocks = DIO_MAX_BLOCKS; ++ dio_credits = ext4_chunk_trans_blocks(inode, max_blocks); ++ handle = ext4_journal_start(inode, dio_credits); ++ if (IS_ERR(handle)) { ++ ret = PTR_ERR(handle); ++ goto out; ++ } ++ started = 1; + } ++ + ret = ext4_get_blocks(handle, inode, iblock, max_blocks, bh_result, + create); + if (ret > 0) { + bh_result->b_size = (ret << inode->i_blkbits); + ret = 0; + } +- ext4_journal_stop(handle); ++ if (started) ++ ext4_journal_stop(handle); + out: + return ret; + } + +-static void ext4_free_io_end(ext4_io_end_t *io) +-{ +- BUG_ON(!io); +- iput(io->inode); +- kfree(io); +-} +- + static void dump_completed_IO(struct inode * inode) + { + #ifdef EXT4_DEBUG + struct list_head *cur, *before, *after; + ext4_io_end_t *io, *io0, *io1; ++ unsigned long flags; + + if (list_empty(&EXT4_I(inode)->i_completed_io_list)){ + ext4_debug(""inode %lu completed_io list is empty\n"", inode->i_ino); + return; + } + + ext4_debug(""Dump inode %lu completed_io list \n"", inode->i_ino); ++ spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); + list_for_each_entry(io, &EXT4_I(inode)->i_completed_io_list, list){ + cur = &io->list; + before = cur->prev; +@@ -3533,6 +3586,7 @@ static void dump_completed_IO(struct inode * inode) + ext4_debug(""io 0x%p from inode %lu,prev 0x%p,next 0x%p\n"", + io, inode->i_ino, io0, io1); + } ++ spin_unlock_irqrestore(&EXT4_I(inode)->i_completed_io_lock, flags); + #endif + } + +@@ -3556,9 +3610,7 @@ static int ext4_end_io_nolock(ext4_io_end_t *io) + if (io->flag != EXT4_IO_UNWRITTEN) + return ret; + +- if (offset + size <= i_size_read(inode)) +- ret = ext4_convert_unwritten_extents(inode, offset, size); +- ++ ret = ext4_convert_unwritten_extents(inode, offset, size); + if (ret < 0) { + printk(KERN_EMERG ""%s: failed to convert unwritten"" + ""extents to written extents, error is %d"" +@@ -3577,18 +3629,25 @@ static int ext4_end_io_nolock(ext4_io_end_t *io) + */ + static void ext4_end_io_work(struct work_struct *work) + { +- ext4_io_end_t *io = container_of(work, ext4_io_end_t, work); +- struct inode *inode = io->inode; +- int ret = 0; ++ ext4_io_end_t *io = container_of(work, ext4_io_end_t, work); ++ struct inode *inode = io->inode; ++ struct ext4_inode_info *ei = EXT4_I(inode); ++ unsigned long flags; ++ int ret; + + mutex_lock(&inode->i_mutex); + ret = ext4_end_io_nolock(io); +- if (ret >= 0) { +- if (!list_empty(&io->list)) +- list_del_init(&io->list); +- ext4_free_io_end(io); ++ if (ret < 0) { ++ mutex_unlock(&inode->i_mutex); ++ return; + } ++ ++ spin_lock_irqsave(&ei->i_completed_io_lock, flags); ++ if (!list_empty(&io->list)) ++ list_del_init(&io->list); ++ spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); + mutex_unlock(&inode->i_mutex); ++ ext4_free_io_end(io); + } + + /* +@@ -3607,15 +3666,18 @@ static void ext4_end_io_work(struct work_struct *work) + int flush_completed_IO(struct inode *inode) + { + ext4_io_end_t *io; ++ struct ext4_inode_info *ei = EXT4_I(inode); ++ unsigned long flags; + int ret = 0; + int ret2 = 0; + +- if (list_empty(&EXT4_I(inode)->i_completed_io_list)) ++ if (list_empty(&ei->i_completed_io_list)) + return ret; + + dump_completed_IO(inode); +- while (!list_empty(&EXT4_I(inode)->i_completed_io_list)){ +- io = list_entry(EXT4_I(inode)->i_completed_io_list.next, ++ spin_lock_irqsave(&ei->i_completed_io_lock, flags); ++ while (!list_empty(&ei->i_completed_io_list)){ ++ io = list_entry(ei->i_completed_io_list.next, + ext4_io_end_t, list); + /* + * Calling ext4_end_io_nolock() to convert completed +@@ -3631,28 +3693,31 @@ int flush_completed_IO(struct inode *inode) + * avoid double converting from both fsync and background work + * queue work. + */ ++ spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); + ret = ext4_end_io_nolock(io); ++ spin_lock_irqsave(&ei->i_completed_io_lock, flags); + if (ret < 0) + ret2 = ret; + else + list_del_init(&io->list); + } ++ spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); + return (ret2 < 0) ? ret2 : 0; + } + +-static ext4_io_end_t *ext4_init_io_end (struct inode *inode) ++static ext4_io_end_t *ext4_init_io_end (struct inode *inode, gfp_t flags) + { + ext4_io_end_t *io = NULL; + +- io = kmalloc(sizeof(*io), GFP_NOFS); ++ io = kmalloc(sizeof(*io), flags); + + if (io) { + igrab(inode); + io->inode = inode; + io->flag = 0; + io->offset = 0; + io->size = 0; +- io->error = 0; ++ io->page = NULL; + INIT_WORK(&io->work, ext4_end_io_work); + INIT_LIST_HEAD(&io->list); + } +@@ -3665,6 +3730,8 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, + { + ext4_io_end_t *io_end = iocb->private; + struct workqueue_struct *wq; ++ unsigned long flags; ++ struct ext4_inode_info *ei; + + /* if not async direct IO or dio with 0 bytes write, just return */ + if (!io_end || !size) +@@ -3684,17 +3751,85 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, + + io_end->offset = offset; + io_end->size = size; ++ io_end->flag = EXT4_IO_UNWRITTEN; + wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq; + + /* queue the work to convert unwritten extents to written */ + queue_work(wq, &io_end->work); + + /* Add the io_end to per-inode completed aio dio list*/ +- list_add_tail(&io_end->list, +- &EXT4_I(io_end->inode)->i_completed_io_list); ++ ei = EXT4_I(io_end->inode); ++ spin_lock_irqsave(&ei->i_completed_io_lock, flags); ++ list_add_tail(&io_end->list, &ei->i_completed_io_list); ++ spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); + iocb->private = NULL; + } + ++static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate) ++{ ++ ext4_io_end_t *io_end = bh->b_private; ++ struct workqueue_struct *wq; ++ struct inode *inode; ++ unsigned long flags; ++ ++ if (!test_clear_buffer_uninit(bh) || !io_end) ++ goto out; ++ ++ if (!(io_end->inode->i_sb->s_flags & MS_ACTIVE)) { ++ printk(""sb umounted, discard end_io request for inode %lu\n"", ++ io_end->inode->i_ino); ++ ext4_free_io_end(io_end); ++ goto out; ++ } ++ ++ io_end->flag = EXT4_IO_UNWRITTEN; ++ inode = io_end->inode; ++ ++ /* Add the io_end to per-inode completed io list*/ ++ spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); ++ list_add_tail(&io_end->list, &EXT4_I(inode)->i_completed_io_list); ++ spin_unlock_irqrestore(&EXT4_I(inode)->i_completed_io_lock, flags); ++ ++ wq = EXT4_SB(inode->i_sb)->dio_unwritten_wq; ++ /* queue the work to convert unwritten extents to written */ ++ queue_work(wq, &io_end->work); ++out: ++ bh->b_private = NULL; ++ bh->b_end_io = NULL; ++ clear_buffer_uninit(bh); ++ end_buffer_async_write(bh, uptodate); ++} ++ ++static int ext4_set_bh_endio(struct buffer_head *bh, struct inode *inode) ++{ ++ ext4_io_end_t *io_end; ++ struct page *page = bh->b_page; ++ loff_t offset = (sector_t)page->index << PAGE_CACHE_SHIFT; ++ size_t size = bh->b_size; ++ ++retry: ++ io_end = ext4_init_io_end(inode, GFP_ATOMIC); ++ if (!io_end) { ++ if (printk_ratelimit()) ++ printk(KERN_WARNING ""%s: allocation fail\n"", __func__); ++ schedule(); ++ goto retry; ++ } ++ io_end->offset = offset; ++ io_end->size = size; ++ /* ++ * We need to hold a reference to the page to make sure it ++ * doesn't get evicted before ext4_end_io_work() has a chance ++ * to convert the extent from written to unwritten. ++ */ ++ io_end->page = page; ++ get_page(io_end->page); ++ ++ bh->b_private = io_end; ++ bh->b_end_io = ext4_end_io_buffer_write; ++ return 0; ++} ++ + /* + * For ext4 extent files, ext4 will do direct-io write to holes, + * preallocated extents, and those write extend the file, no need to +@@ -3748,7 +3883,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, + iocb->private = NULL; + EXT4_I(inode)->cur_aio_dio = NULL; + if (!is_sync_kiocb(iocb)) { +- iocb->private = ext4_init_io_end(inode); ++ iocb->private = ext4_init_io_end(inode, GFP_NOFS); + if (!iocb->private) + return -ENOMEM; + /*",1112,1348,2048 +18734,"void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { + if (mSignalledError || mOutputPortSettingsChange != NONE) { + return; + } + + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + while ((!inQueue.empty() || (mSawInputEos && !mSignalledOutputEos)) && !outQueue.empty()) { + BufferInfo *inInfo = NULL; + OMX_BUFFERHEADERTYPE *inHeader = NULL; + if (!inQueue.empty()) { + inInfo = *inQueue.begin(); + inHeader = inInfo->mHeader; + } + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + outHeader->nFlags = 0; + + if (inHeader) { + if (inHeader->nOffset == 0 && inHeader->nFilledLen) { + mAnchorTimeUs = inHeader->nTimeStamp; + mNumFramesOutput = 0; + } + + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + mSawInputEos = true; + } + + mConfig->pInputBuffer = + inHeader->pBuffer + inHeader->nOffset; + + mConfig->inputBufferCurrentLength = inHeader->nFilledLen; + } else { + mConfig->pInputBuffer = NULL; + mConfig->inputBufferCurrentLength = 0; + } + mConfig->inputBufferMaxLength = 0; + mConfig->inputBufferUsedLength = 0; + + mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); + if ((int32)outHeader->nAllocLen < mConfig->outputFrameSize) { + ALOGE(""input buffer too small: got %u, expected %u"", + outHeader->nAllocLen, mConfig->outputFrameSize); + android_errorWriteLog(0x534e4554, ""27793371""); + notify(OMX_EventError, OMX_ErrorUndefined, OUTPUT_BUFFER_TOO_SMALL, NULL); + mSignalledError = true; + return; + } + + mConfig->pOutputBuffer = + reinterpret_cast(outHeader->pBuffer); + + ERROR_CODE decoderErr; + if ((decoderErr = pvmp3_framedecoder(mConfig, mDecoderBuf)) + != NO_DECODING_ERROR) { + ALOGV(""mp3 decoder returned error %d"", decoderErr); + + if (decoderErr != NO_ENOUGH_MAIN_DATA_ERROR + && decoderErr != SIDE_INFO_ERROR) { + ALOGE(""mp3 decoder returned error %d"", decoderErr); + + notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL); + mSignalledError = true; + return; + } + + if (mConfig->outputFrameSize == 0) { + mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); + } + + if (decoderErr == NO_ENOUGH_MAIN_DATA_ERROR && mSawInputEos) { + if (!mIsFirst) { + + outHeader->nOffset = 0; + outHeader->nFilledLen = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + + memset(outHeader->pBuffer, 0, outHeader->nFilledLen); + } + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + mSignalledOutputEos = true; + } else { + + + ALOGV_IF(mIsFirst, ""insufficient data for first frame, sending silence""); + memset(outHeader->pBuffer, + 0, + mConfig->outputFrameSize * sizeof(int16_t)); + + if (inHeader) { + mConfig->inputBufferUsedLength = inHeader->nFilledLen; + } + } + } else if (mConfig->samplingRate != mSamplingRate + || mConfig->num_channels != mNumChannels) { + mSamplingRate = mConfig->samplingRate; + mNumChannels = mConfig->num_channels; + + notify(OMX_EventPortSettingsChanged, 1, 0, NULL); + mOutputPortSettingsChange = AWAITING_DISABLED; + return; + } + + if (mIsFirst) { + mIsFirst = false; + outHeader->nOffset = + kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + + outHeader->nFilledLen = + mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset; + } else if (!mSignalledOutputEos) { + outHeader->nOffset = 0; + outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t); + } + + outHeader->nTimeStamp = + mAnchorTimeUs + (mNumFramesOutput * 1000000ll) / mSamplingRate; + + if (inHeader) { + CHECK_GE(inHeader->nFilledLen, mConfig->inputBufferUsedLength); + + inHeader->nOffset += mConfig->inputBufferUsedLength; + inHeader->nFilledLen -= mConfig->inputBufferUsedLength; + + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + } + + mNumFramesOutput += mConfig->outputFrameSize / mNumChannels; + + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + } +} +",1,"void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { + if (mSignalledError || mOutputPortSettingsChange != NONE) { + return; + } + + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + while ((!inQueue.empty() || (mSawInputEos && !mSignalledOutputEos)) && !outQueue.empty()) { + BufferInfo *inInfo = NULL; + OMX_BUFFERHEADERTYPE *inHeader = NULL; + if (!inQueue.empty()) { + inInfo = *inQueue.begin(); + inHeader = inInfo->mHeader; + } + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + outHeader->nFlags = 0; + + if (inHeader) { + if (inHeader->nOffset == 0 && inHeader->nFilledLen) { + mAnchorTimeUs = inHeader->nTimeStamp; + mNumFramesOutput = 0; + } + + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + mSawInputEos = true; + } + + mConfig->pInputBuffer = + inHeader->pBuffer + inHeader->nOffset; + + mConfig->inputBufferCurrentLength = inHeader->nFilledLen; + } else { + mConfig->pInputBuffer = NULL; + mConfig->inputBufferCurrentLength = 0; + } + mConfig->inputBufferMaxLength = 0; + mConfig->inputBufferUsedLength = 0; + + mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); + if ((int32)outHeader->nAllocLen < mConfig->outputFrameSize) { + ALOGE(""input buffer too small: got %u, expected %u"", + outHeader->nAllocLen, mConfig->outputFrameSize); + android_errorWriteLog(0x534e4554, ""27793371""); + notify(OMX_EventError, OMX_ErrorUndefined, OUTPUT_BUFFER_TOO_SMALL, NULL); + mSignalledError = true; + return; + } + + mConfig->pOutputBuffer = + reinterpret_cast(outHeader->pBuffer); + + ERROR_CODE decoderErr; + if ((decoderErr = pvmp3_framedecoder(mConfig, mDecoderBuf)) + != NO_DECODING_ERROR) { + ALOGV(""mp3 decoder returned error %d"", decoderErr); + + if (decoderErr != NO_ENOUGH_MAIN_DATA_ERROR + && decoderErr != SIDE_INFO_ERROR) { + ALOGE(""mp3 decoder returned error %d"", decoderErr); + + notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL); + mSignalledError = true; + return; + } + + if (mConfig->outputFrameSize == 0) { + mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); + } + + if (decoderErr == NO_ENOUGH_MAIN_DATA_ERROR && mSawInputEos) { + if (!mIsFirst) { + + outHeader->nOffset = 0; + outHeader->nFilledLen = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + + if (!memsetSafe(outHeader, 0, outHeader->nFilledLen)) { + return; + } + + } + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + mSignalledOutputEos = true; + } else { + + + ALOGV_IF(mIsFirst, ""insufficient data for first frame, sending silence""); + if (!memsetSafe(outHeader, 0, mConfig->outputFrameSize * sizeof(int16_t))) { + return; + } + + if (inHeader) { + mConfig->inputBufferUsedLength = inHeader->nFilledLen; + } + } + } else if (mConfig->samplingRate != mSamplingRate + || mConfig->num_channels != mNumChannels) { + mSamplingRate = mConfig->samplingRate; + mNumChannels = mConfig->num_channels; + + notify(OMX_EventPortSettingsChanged, 1, 0, NULL); + mOutputPortSettingsChange = AWAITING_DISABLED; + return; + } + + if (mIsFirst) { + mIsFirst = false; + outHeader->nOffset = + kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + + outHeader->nFilledLen = + mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset; + } else if (!mSignalledOutputEos) { + outHeader->nOffset = 0; + outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t); + } + + outHeader->nTimeStamp = + mAnchorTimeUs + (mNumFramesOutput * 1000000ll) / mSamplingRate; + + if (inHeader) { + CHECK_GE(inHeader->nFilledLen, mConfig->inputBufferUsedLength); + + inHeader->nOffset += mConfig->inputBufferUsedLength; + inHeader->nFilledLen -= mConfig->inputBufferUsedLength; + + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + } + + mNumFramesOutput += mConfig->outputFrameSize / mNumChannels; + + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + } +} +","@@ -120,6 +120,17 @@ + + mIsFirst = true; + } + ++void *SoftMP3::memsetSafe(OMX_BUFFERHEADERTYPE *outHeader, int c, size_t len) { ++ if (len > outHeader->nAllocLen) { ++ ALOGE(""memset buffer too small: got %lu, expected %zu"", outHeader->nAllocLen, len); ++ android_errorWriteLog(0x534e4554, ""29422022""); ++ notify(OMX_EventError, OMX_ErrorUndefined, OUTPUT_BUFFER_TOO_SMALL, NULL); ++ mSignalledError = true; ++ return NULL; ++ } ++ return memset(outHeader->pBuffer, c, len); ++} ++ + OMX_ERRORTYPE SoftMP3::internalGetParameter( + OMX_INDEXTYPE index, OMX_PTR params) { + switch (index) { +@@ -300,7 +311,10 @@ + + outHeader->nOffset = 0; + outHeader->nFilledLen = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + +- memset(outHeader->pBuffer, 0, outHeader->nFilledLen); ++ if (!memsetSafe(outHeader, 0, outHeader->nFilledLen)) { ++ return; ++ } ++ + } + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + mSignalledOutputEos = true; +@@ -312,9 +326,9 @@ + + // if mIsFirst is true as we may not have a valid + // mConfig->samplingRate and mConfig->num_channels? + ALOGV_IF(mIsFirst, ""insufficient data for first frame, sending silence""); +- memset(outHeader->pBuffer, +- 0, +- mConfig->outputFrameSize * sizeof(int16_t)); ++ if (!memsetSafe(outHeader, 0, mConfig->outputFrameSize * sizeof(int16_t))) { ++ return; ++ } + + if (inHeader) { + mConfig->inputBufferUsedLength = inHeader->nFilledLen; +",1209,1445,2048 +7471,"conn *conn_new(const int sfd, enum conn_states init_state, + const int event_flags, + const int read_buffer_size, enum network_transport transport, + struct event_base *base) { + conn *c; + + assert(sfd >= 0 && sfd < max_fds); + c = conns[sfd]; + + if (NULL == c) { + if (!(c = (conn *)calloc(1, sizeof(conn)))) { + STATS_LOCK(); + stats.malloc_fails++; + STATS_UNLOCK(); + fprintf(stderr, ""Failed to allocate connection object\n""); + return NULL; + } + MEMCACHED_CONN_CREATE(c); + + c->rbuf = c->wbuf = 0; + c->ilist = 0; + c->suffixlist = 0; + c->iov = 0; + c->msglist = 0; + c->hdrbuf = 0; + + c->rsize = read_buffer_size; + c->wsize = DATA_BUFFER_SIZE; + c->isize = ITEM_LIST_INITIAL; + c->suffixsize = SUFFIX_LIST_INITIAL; + c->iovsize = IOV_LIST_INITIAL; + c->msgsize = MSG_LIST_INITIAL; + c->hdrsize = 0; + + c->rbuf = (char *)malloc((size_t)c->rsize); + c->wbuf = (char *)malloc((size_t)c->wsize); + c->ilist = (item **)malloc(sizeof(item *) * c->isize); + c->suffixlist = (char **)malloc(sizeof(char *) * c->suffixsize); + c->iov = (struct iovec *)malloc(sizeof(struct iovec) * c->iovsize); + c->msglist = (struct msghdr *)malloc(sizeof(struct msghdr) * c->msgsize); + + if (c->rbuf == 0 || c->wbuf == 0 || c->ilist == 0 || c->iov == 0 || + c->msglist == 0 || c->suffixlist == 0) { + conn_free(c); + STATS_LOCK(); + stats.malloc_fails++; + STATS_UNLOCK(); + fprintf(stderr, ""Failed to allocate buffers for connection\n""); + return NULL; + } + + STATS_LOCK(); + stats_state.conn_structs++; + STATS_UNLOCK(); + + c->sfd = sfd; + conns[sfd] = c; + } + + c->transport = transport; + c->protocol = settings.binding_protocol; + + /* unix socket mode doesn't need this, so zeroed out. but why + * is this done for every command? presumably for UDP + * mode. */ + if (!settings.socketpath) { + c->request_addr_size = sizeof(c->request_addr); + } else { + c->request_addr_size = 0; + } + + if (transport == tcp_transport && init_state == conn_new_cmd) { + if (getpeername(sfd, (struct sockaddr *) &c->request_addr, + &c->request_addr_size)) { + perror(""getpeername""); + memset(&c->request_addr, 0, sizeof(c->request_addr)); + } + } + + if (settings.verbose > 1) { + if (init_state == conn_listening) { + fprintf(stderr, ""<%d server listening (%s)\n"", sfd, + prot_text(c->protocol)); + } else if (IS_UDP(transport)) { + fprintf(stderr, ""<%d server listening (udp)\n"", sfd); + } else if (c->protocol == negotiating_prot) { + fprintf(stderr, ""<%d new auto-negotiating client connection\n"", + sfd); + } else if (c->protocol == ascii_prot) { + fprintf(stderr, ""<%d new ascii client connection.\n"", sfd); + } else if (c->protocol == binary_prot) { + fprintf(stderr, ""<%d new binary client connection.\n"", sfd); + } else { + fprintf(stderr, ""<%d new unknown (%d) client connection\n"", + sfd, c->protocol); + assert(false); + } + } + + c->state = init_state; + c->rlbytes = 0; + c->cmd = -1; + c->rbytes = c->wbytes = 0; + c->wcurr = c->wbuf; + c->rcurr = c->rbuf; + c->ritem = 0; + c->icurr = c->ilist; + c->suffixcurr = c->suffixlist; + c->ileft = 0; + c->suffixleft = 0; + c->iovused = 0; + c->msgcurr = 0; + c->msgused = 0; + c->authenticated = false; + c->last_cmd_time = current_time; /* initialize for idle kicker */ + + c->write_and_go = init_state; + c->write_and_free = 0; + c->item = 0; + + c->noreply = false; + + event_set(&c->event, sfd, event_flags, event_handler, (void *)c); + event_base_set(base, &c->event); + c->ev_flags = event_flags; + + if (event_add(&c->event, 0) == -1) { + perror(""event_add""); + return NULL; + } + + STATS_LOCK(); + stats_state.curr_conns++; + stats.total_conns++; + STATS_UNLOCK(); + + MEMCACHED_CONN_ALLOCATE(c->sfd); + + return c; +} +",0,"conn *conn_new(const int sfd, enum conn_states init_state, + const int event_flags, + const int read_buffer_size, enum network_transport transport, + struct event_base *base) { + conn *c; + + assert(sfd >= 0 && sfd < max_fds); + c = conns[sfd]; + + if (NULL == c) { + if (!(c = (conn *)calloc(1, sizeof(conn)))) { + STATS_LOCK(); + stats.malloc_fails++; + STATS_UNLOCK(); + fprintf(stderr, ""Failed to allocate connection object\n""); + return NULL; + } + MEMCACHED_CONN_CREATE(c); + + c->rbuf = c->wbuf = 0; + c->ilist = 0; + c->suffixlist = 0; + c->iov = 0; + c->msglist = 0; + c->hdrbuf = 0; + + c->rsize = read_buffer_size; + c->wsize = DATA_BUFFER_SIZE; + c->isize = ITEM_LIST_INITIAL; + c->suffixsize = SUFFIX_LIST_INITIAL; + c->iovsize = IOV_LIST_INITIAL; + c->msgsize = MSG_LIST_INITIAL; + c->hdrsize = 0; + + c->rbuf = (char *)malloc((size_t)c->rsize); + c->wbuf = (char *)malloc((size_t)c->wsize); + c->ilist = (item **)malloc(sizeof(item *) * c->isize); + c->suffixlist = (char **)malloc(sizeof(char *) * c->suffixsize); + c->iov = (struct iovec *)malloc(sizeof(struct iovec) * c->iovsize); + c->msglist = (struct msghdr *)malloc(sizeof(struct msghdr) * c->msgsize); + + if (c->rbuf == 0 || c->wbuf == 0 || c->ilist == 0 || c->iov == 0 || + c->msglist == 0 || c->suffixlist == 0) { + conn_free(c); + STATS_LOCK(); + stats.malloc_fails++; + STATS_UNLOCK(); + fprintf(stderr, ""Failed to allocate buffers for connection\n""); + return NULL; + } + + STATS_LOCK(); + stats_state.conn_structs++; + STATS_UNLOCK(); + + c->sfd = sfd; + conns[sfd] = c; + } + + c->transport = transport; + c->protocol = settings.binding_protocol; + + /* unix socket mode doesn't need this, so zeroed out. but why + * is this done for every command? presumably for UDP + * mode. */ + if (!settings.socketpath) { + c->request_addr_size = sizeof(c->request_addr); + } else { + c->request_addr_size = 0; + } + + if (transport == tcp_transport && init_state == conn_new_cmd) { + if (getpeername(sfd, (struct sockaddr *) &c->request_addr, + &c->request_addr_size)) { + perror(""getpeername""); + memset(&c->request_addr, 0, sizeof(c->request_addr)); + } + } + + if (settings.verbose > 1) { + if (init_state == conn_listening) { + fprintf(stderr, ""<%d server listening (%s)\n"", sfd, + prot_text(c->protocol)); + } else if (IS_UDP(transport)) { + fprintf(stderr, ""<%d server listening (udp)\n"", sfd); + } else if (c->protocol == negotiating_prot) { + fprintf(stderr, ""<%d new auto-negotiating client connection\n"", + sfd); + } else if (c->protocol == ascii_prot) { + fprintf(stderr, ""<%d new ascii client connection.\n"", sfd); + } else if (c->protocol == binary_prot) { + fprintf(stderr, ""<%d new binary client connection.\n"", sfd); + } else { + fprintf(stderr, ""<%d new unknown (%d) client connection\n"", + sfd, c->protocol); + assert(false); + } + } + + c->state = init_state; + c->rlbytes = 0; + c->cmd = -1; + c->rbytes = c->wbytes = 0; + c->wcurr = c->wbuf; + c->rcurr = c->rbuf; + c->ritem = 0; + c->icurr = c->ilist; + c->suffixcurr = c->suffixlist; + c->ileft = 0; + c->suffixleft = 0; + c->iovused = 0; + c->msgcurr = 0; + c->msgused = 0; + c->authenticated = false; + c->last_cmd_time = current_time; /* initialize for idle kicker */ + + c->write_and_go = init_state; + c->write_and_free = 0; + c->item = 0; + + c->noreply = false; + + event_set(&c->event, sfd, event_flags, event_handler, (void *)c); + event_base_set(base, &c->event); + c->ev_flags = event_flags; + + if (event_add(&c->event, 0) == -1) { + perror(""event_add""); + return NULL; + } + + STATS_LOCK(); + stats_state.curr_conns++; + stats.total_conns++; + STATS_UNLOCK(); + + MEMCACHED_CONN_ALLOCATE(c->sfd); + + return c; +} +","@@ -3249,6 +3249,16 @@ static inline int make_ascii_get_suffix(char *suffix, item *it, bool return_cas) + return (p - suffix) + 2; + } + ++#define IT_REFCOUNT_LIMIT 60000 ++static inline item* limited_get(char *key, size_t nkey, conn *c) { ++ item *it = item_get(key, nkey, c, DO_UPDATE); ++ if (it && it->refcount > IT_REFCOUNT_LIMIT) { ++ item_remove(it); ++ it = NULL; ++ } ++ return it; ++} ++ + /* ntokens is overwritten here... shrug.. */ + static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, bool return_cas) { + char *key; +@@ -3273,7 +3283,7 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, + return; + } + +- it = item_get(key, nkey, c, DO_UPDATE); ++ it = limited_get(key, nkey, c); + if (settings.detail_enabled) { + stats_prefix_record_get(key, nkey, NULL != it); + }",1183,1419,2048 +12554,"Browser::Browser(const CreateParams& params) + : type_(params.type), + profile_(params.profile), + window_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST( + tab_strip_model_delegate_( + new chrome::BrowserTabStripModelDelegate(this))), + tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(), + params.profile)), + app_name_(params.app_name), + app_type_(params.app_type), + chrome_updater_factory_(this), + cancel_download_confirmation_state_(NOT_PROMPTED), + override_bounds_(params.initial_bounds), + initial_show_state_(params.initial_show_state), + is_session_restore_(params.is_session_restore), + host_desktop_type_(params.host_desktop_type), + ALLOW_THIS_IN_INITIALIZER_LIST( + unload_controller_(new chrome::UnloadController(this))), + weak_factory_(this), + ALLOW_THIS_IN_INITIALIZER_LIST( + content_setting_bubble_model_delegate_( + new BrowserContentSettingBubbleModelDelegate(this))), + ALLOW_THIS_IN_INITIALIZER_LIST( + toolbar_model_delegate_( + new BrowserToolbarModelDelegate(this))), + ALLOW_THIS_IN_INITIALIZER_LIST( + tab_restore_service_delegate_( + new BrowserTabRestoreServiceDelegate(this))), + ALLOW_THIS_IN_INITIALIZER_LIST( + synced_window_delegate_( + new BrowserSyncedWindowDelegate(this))), + bookmark_bar_state_(BookmarkBar::HIDDEN), + ALLOW_THIS_IN_INITIALIZER_LIST( + command_controller_(new chrome::BrowserCommandController(this))), + window_has_shown_(false) { + if (!app_name_.empty()) + chrome::RegisterAppPrefs(app_name_, profile_); + tab_strip_model_->AddObserver(this); + + toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); + search_model_.reset(new chrome::search::SearchModel(NULL)); + search_delegate_.reset( + new chrome::search::SearchDelegate(search_model_.get(), + toolbar_model_.get())); + + registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, + content::NotificationService::AllSources()); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, + content::Source(profile_->GetOriginalProfile())); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, + content::Source(profile_->GetOriginalProfile())); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, + content::Source(profile_->GetOriginalProfile())); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, + content::NotificationService::AllSources()); +#if defined(ENABLE_THEMES) + registrar_.Add( + this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, + content::Source( + ThemeServiceFactory::GetForProfile(profile_))); +#endif + registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::NotificationService::AllSources()); + + profile_pref_registrar_.Init(profile_->GetPrefs()); + profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); + profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); + profile_pref_registrar_.Add(prefs::kHomePage, this); + + BrowserList::AddBrowser(this); + + encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, + profile_->GetPrefs(), NULL); + + instant_controller_.reset(new chrome::BrowserInstantController(this)); + +#if 0 + device_attached_intent_source_.reset( + new DeviceAttachedIntentSource(this, (this))); +#endif + + UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); + + FilePath profile_path = profile_->GetPath(); + ProfileMetrics::LogProfileLaunch(profile_path); + + window_ = params.window ? params.window : CreateBrowserWindow(this); + +#if defined(OS_WIN) && !defined(USE_AURA) + ui::win::SetAppIdForWindow( + is_app() && !is_type_panel() ? + ShellIntegration::GetAppModelIdForProfile(UTF8ToWide(app_name_), + profile_->GetPath()) : + ShellIntegration::GetChromiumModelIdForProfile(profile_->GetPath()), + window()->GetNativeWindow()); + + if (is_type_panel()) { + ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), + window()->GetNativeWindow()); + } +#endif + + extension_window_controller_.reset( + new BrowserExtensionWindowController(this)); + + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_BROWSER_WINDOW_READY, + content::Source(this), + content::NotificationService::NoDetails()); + + PrefService* local_state = g_browser_process->local_state(); + if (local_state && local_state->FindPreference( + prefs::kAutofillPersonalDataManagerFirstRun) && + local_state->GetBoolean(prefs::kAutofillPersonalDataManagerFirstRun)) { +#if defined(OS_WIN) + ImportAutofillDataWin(PersonalDataManagerFactory::GetForProfile(profile_)); +#endif // defined(OS_WIN) + local_state->ClearPref(prefs::kAutofillPersonalDataManagerFirstRun); + } + + fullscreen_controller_.reset(new FullscreenController(this)); + search_model_->AddObserver(this); +} +",0,"Browser::Browser(const CreateParams& params) + : type_(params.type), + profile_(params.profile), + window_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST( + tab_strip_model_delegate_( + new chrome::BrowserTabStripModelDelegate(this))), + tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(), + params.profile)), + app_name_(params.app_name), + app_type_(params.app_type), + chrome_updater_factory_(this), + cancel_download_confirmation_state_(NOT_PROMPTED), + override_bounds_(params.initial_bounds), + initial_show_state_(params.initial_show_state), + is_session_restore_(params.is_session_restore), + host_desktop_type_(params.host_desktop_type), + ALLOW_THIS_IN_INITIALIZER_LIST( + unload_controller_(new chrome::UnloadController(this))), + weak_factory_(this), + ALLOW_THIS_IN_INITIALIZER_LIST( + content_setting_bubble_model_delegate_( + new BrowserContentSettingBubbleModelDelegate(this))), + ALLOW_THIS_IN_INITIALIZER_LIST( + toolbar_model_delegate_( + new BrowserToolbarModelDelegate(this))), + ALLOW_THIS_IN_INITIALIZER_LIST( + tab_restore_service_delegate_( + new BrowserTabRestoreServiceDelegate(this))), + ALLOW_THIS_IN_INITIALIZER_LIST( + synced_window_delegate_( + new BrowserSyncedWindowDelegate(this))), + bookmark_bar_state_(BookmarkBar::HIDDEN), + ALLOW_THIS_IN_INITIALIZER_LIST( + command_controller_(new chrome::BrowserCommandController(this))), + window_has_shown_(false) { + if (!app_name_.empty()) + chrome::RegisterAppPrefs(app_name_, profile_); + tab_strip_model_->AddObserver(this); + + toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); + search_model_.reset(new chrome::search::SearchModel(NULL)); + search_delegate_.reset( + new chrome::search::SearchDelegate(search_model_.get(), + toolbar_model_.get())); + + registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, + content::NotificationService::AllSources()); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, + content::Source(profile_->GetOriginalProfile())); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, + content::Source(profile_->GetOriginalProfile())); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, + content::Source(profile_->GetOriginalProfile())); + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, + content::NotificationService::AllSources()); +#if defined(ENABLE_THEMES) + registrar_.Add( + this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, + content::Source( + ThemeServiceFactory::GetForProfile(profile_))); +#endif + registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::NotificationService::AllSources()); + + profile_pref_registrar_.Init(profile_->GetPrefs()); + profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); + profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); + profile_pref_registrar_.Add(prefs::kHomePage, this); + + BrowserList::AddBrowser(this); + + encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, + profile_->GetPrefs(), NULL); + + instant_controller_.reset(new chrome::BrowserInstantController(this)); + +#if 0 + device_attached_intent_source_.reset( + new DeviceAttachedIntentSource(this, (this))); +#endif + + UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); + + FilePath profile_path = profile_->GetPath(); + ProfileMetrics::LogProfileLaunch(profile_path); + + window_ = params.window ? params.window : CreateBrowserWindow(this); + +#if defined(OS_WIN) && !defined(USE_AURA) + ui::win::SetAppIdForWindow( + is_app() && !is_type_panel() ? + ShellIntegration::GetAppModelIdForProfile(UTF8ToWide(app_name_), + profile_->GetPath()) : + ShellIntegration::GetChromiumModelIdForProfile(profile_->GetPath()), + window()->GetNativeWindow()); + + if (is_type_panel()) { + ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), + window()->GetNativeWindow()); + } +#endif + + extension_window_controller_.reset( + new BrowserExtensionWindowController(this)); + + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_BROWSER_WINDOW_READY, + content::Source(this), + content::NotificationService::NoDetails()); + + PrefService* local_state = g_browser_process->local_state(); + if (local_state && local_state->FindPreference( + prefs::kAutofillPersonalDataManagerFirstRun) && + local_state->GetBoolean(prefs::kAutofillPersonalDataManagerFirstRun)) { +#if defined(OS_WIN) + ImportAutofillDataWin(PersonalDataManagerFactory::GetForProfile(profile_)); +#endif // defined(OS_WIN) + local_state->ClearPref(prefs::kAutofillPersonalDataManagerFirstRun); + } + + fullscreen_controller_.reset(new FullscreenController(this)); + search_model_->AddObserver(this); +} +","@@ -1055,7 +1055,7 @@ void Browser::TabClosingAt(TabStripModel* tab_strip_model, + SetAsDelegate(contents, NULL); + } + +-void Browser::TabDetachedAt(TabContents* contents, int index) { ++void Browser::TabDetachedAt(WebContents* contents, int index) { + TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); + } + +@@ -1149,7 +1149,7 @@ void Browser::TabReplacedAt(TabStripModel* tab_strip_model, + TabContents* old_contents, + TabContents* new_contents, + int index) { +- TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); ++ TabDetachedAtImpl(old_contents->web_contents(), index, DETACH_TYPE_REPLACE); + SessionService* session_service = + SessionServiceFactory::GetForProfile(profile_); + if (session_service) +@@ -2162,37 +2162,38 @@ void Browser::CloseFrame() { + window_->Close(); + } + +-void Browser::TabDetachedAtImpl(TabContents* contents, int index, ++void Browser::TabDetachedAtImpl(content::WebContents* contents, ++ int index, + DetachType type) { + if (type == DETACH_TYPE_DETACH) { + // Save the current location bar state, but only if the tab being detached + // is the selected tab. Because saving state can conditionally revert the + // location bar, saving the current tab's location bar state to a + // non-selected tab can corrupt both tabs. +- if (contents == chrome::GetActiveTabContents(this)) { ++ if (contents == chrome::GetActiveWebContents(this)) { + LocationBar* location_bar = window()->GetLocationBar(); + if (location_bar) +- location_bar->SaveStateToContents(contents->web_contents()); ++ location_bar->SaveStateToContents(contents); + } + + if (!tab_strip_model_->closing_all()) + SyncHistoryWithTabs(0); + } + +- SetAsDelegate(contents->web_contents(), NULL); +- RemoveScheduledUpdatesFor(contents->web_contents()); ++ SetAsDelegate(contents, NULL); ++ RemoveScheduledUpdatesFor(contents); + + if (find_bar_controller_.get() && index == active_index()) { + find_bar_controller_->ChangeWebContents(NULL); + } + + // Stop observing search model changes for this tab. +- search_delegate_->OnTabDetached(contents->web_contents()); ++ search_delegate_->OnTabDetached(contents); + + registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, +- content::Source(contents->web_contents())); ++ content::Source(contents)); + registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_DETACHED, +- content::Source(contents->web_contents())); ++ content::Source(contents)); + } + + bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,",1061,1297,2048 +5064,"PHP_FUNCTION(imagepsbbox) +{ + zval *fnt; + long sz = 0, sp = 0, wd = 0; + char *str; + int i, space = 0, add_width = 0, char_width, amount_kern; + int cur_x, cur_y, dx, dy; + int x1, y1, x2, y2, x3, y3, x4, y4; + int *f_ind; + int str_len, per_char = 0; + int argc = ZEND_NUM_ARGS(); + double angle = 0, sin_a = 0, cos_a = 0; + BBox char_bbox, str_bbox = {0, 0, 0, 0}; + + if (argc != 3 && argc != 6) { + ZEND_WRONG_PARAM_COUNT(); + } + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""srl|lld"", &str, &str_len, &fnt, &sz, &sp, &wd, &angle) == FAILURE) { + return; + } + + if (argc == 6) { + space = sp; + add_width = wd; + angle = angle * M_PI / 180; + sin_a = sin(angle); + cos_a = cos(angle); + per_char = add_width || angle ? 1 : 0; + } + + ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, ""Type 1 font"", le_ps_font); + +#define max(a, b) (a > b ? a : b) +#define min(a, b) (a < b ? a : b) +#define new_x(a, b) (int) ((a) * cos_a - (b) * sin_a) +#define new_y(a, b) (int) ((a) * sin_a + (b) * cos_a) + + if (per_char) { + space += T1_GetCharWidth(*f_ind, ' '); + cur_x = cur_y = 0; + + for (i = 0; i < str_len; i++) { + if (str[i] == ' ') { + char_bbox.llx = char_bbox.lly = char_bbox.ury = 0; + char_bbox.urx = char_width = space; + } else { + char_bbox = T1_GetCharBBox(*f_ind, str[i]); + char_width = T1_GetCharWidth(*f_ind, str[i]); + } + amount_kern = i ? T1_GetKerning(*f_ind, str[i - 1], str[i]) : 0; + + /* Transfer character bounding box to right place */ + x1 = new_x(char_bbox.llx, char_bbox.lly) + cur_x; + y1 = new_y(char_bbox.llx, char_bbox.lly) + cur_y; + x2 = new_x(char_bbox.llx, char_bbox.ury) + cur_x; + y2 = new_y(char_bbox.llx, char_bbox.ury) + cur_y; + x3 = new_x(char_bbox.urx, char_bbox.ury) + cur_x; + y3 = new_y(char_bbox.urx, char_bbox.ury) + cur_y; + x4 = new_x(char_bbox.urx, char_bbox.lly) + cur_x; + y4 = new_y(char_bbox.urx, char_bbox.lly) + cur_y; + + /* Find min & max values and compare them with current bounding box */ + str_bbox.llx = min(str_bbox.llx, min(x1, min(x2, min(x3, x4)))); + str_bbox.lly = min(str_bbox.lly, min(y1, min(y2, min(y3, y4)))); + str_bbox.urx = max(str_bbox.urx, max(x1, max(x2, max(x3, x4)))); + str_bbox.ury = max(str_bbox.ury, max(y1, max(y2, max(y3, y4)))); + + /* Move to the next base point */ + dx = new_x(char_width + add_width + amount_kern, 0); + dy = new_y(char_width + add_width + amount_kern, 0); + cur_x += dx; + cur_y += dy; + /* + printf(""%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n"", x1, y1, x2, y2, x3, y3, x4, y4, char_bbox.llx, char_bbox.lly, char_bbox.urx, char_bbox.ury, char_width, amount_kern, cur_x, cur_y, dx, dy); + */ + } + + } else { + str_bbox = T1_GetStringBBox(*f_ind, str, str_len, space, T1_KERNING); + } + + if (T1_errno) { + RETURN_FALSE; + } + + array_init(return_value); + /* + printf(""%d %d %d %d\n"", str_bbox.llx, str_bbox.lly, str_bbox.urx, str_bbox.ury); + */ + add_next_index_long(return_value, (int) ceil(((double) str_bbox.llx)*sz/1000)); + add_next_index_long(return_value, (int) ceil(((double) str_bbox.lly)*sz/1000)); + add_next_index_long(return_value, (int) ceil(((double) str_bbox.urx)*sz/1000)); + add_next_index_long(return_value, (int) ceil(((double) str_bbox.ury)*sz/1000)); +} +",0,"PHP_FUNCTION(imagepsbbox) +{ + zval *fnt; + long sz = 0, sp = 0, wd = 0; + char *str; + int i, space = 0, add_width = 0, char_width, amount_kern; + int cur_x, cur_y, dx, dy; + int x1, y1, x2, y2, x3, y3, x4, y4; + int *f_ind; + int str_len, per_char = 0; + int argc = ZEND_NUM_ARGS(); + double angle = 0, sin_a = 0, cos_a = 0; + BBox char_bbox, str_bbox = {0, 0, 0, 0}; + + if (argc != 3 && argc != 6) { + ZEND_WRONG_PARAM_COUNT(); + } + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""srl|lld"", &str, &str_len, &fnt, &sz, &sp, &wd, &angle) == FAILURE) { + return; + } + + if (argc == 6) { + space = sp; + add_width = wd; + angle = angle * M_PI / 180; + sin_a = sin(angle); + cos_a = cos(angle); + per_char = add_width || angle ? 1 : 0; + } + + ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, ""Type 1 font"", le_ps_font); + +#define max(a, b) (a > b ? a : b) +#define min(a, b) (a < b ? a : b) +#define new_x(a, b) (int) ((a) * cos_a - (b) * sin_a) +#define new_y(a, b) (int) ((a) * sin_a + (b) * cos_a) + + if (per_char) { + space += T1_GetCharWidth(*f_ind, ' '); + cur_x = cur_y = 0; + + for (i = 0; i < str_len; i++) { + if (str[i] == ' ') { + char_bbox.llx = char_bbox.lly = char_bbox.ury = 0; + char_bbox.urx = char_width = space; + } else { + char_bbox = T1_GetCharBBox(*f_ind, str[i]); + char_width = T1_GetCharWidth(*f_ind, str[i]); + } + amount_kern = i ? T1_GetKerning(*f_ind, str[i - 1], str[i]) : 0; + + /* Transfer character bounding box to right place */ + x1 = new_x(char_bbox.llx, char_bbox.lly) + cur_x; + y1 = new_y(char_bbox.llx, char_bbox.lly) + cur_y; + x2 = new_x(char_bbox.llx, char_bbox.ury) + cur_x; + y2 = new_y(char_bbox.llx, char_bbox.ury) + cur_y; + x3 = new_x(char_bbox.urx, char_bbox.ury) + cur_x; + y3 = new_y(char_bbox.urx, char_bbox.ury) + cur_y; + x4 = new_x(char_bbox.urx, char_bbox.lly) + cur_x; + y4 = new_y(char_bbox.urx, char_bbox.lly) + cur_y; + + /* Find min & max values and compare them with current bounding box */ + str_bbox.llx = min(str_bbox.llx, min(x1, min(x2, min(x3, x4)))); + str_bbox.lly = min(str_bbox.lly, min(y1, min(y2, min(y3, y4)))); + str_bbox.urx = max(str_bbox.urx, max(x1, max(x2, max(x3, x4)))); + str_bbox.ury = max(str_bbox.ury, max(y1, max(y2, max(y3, y4)))); + + /* Move to the next base point */ + dx = new_x(char_width + add_width + amount_kern, 0); + dy = new_y(char_width + add_width + amount_kern, 0); + cur_x += dx; + cur_y += dy; + /* + printf(""%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n"", x1, y1, x2, y2, x3, y3, x4, y4, char_bbox.llx, char_bbox.lly, char_bbox.urx, char_bbox.ury, char_width, amount_kern, cur_x, cur_y, dx, dy); + */ + } + + } else { + str_bbox = T1_GetStringBBox(*f_ind, str, str_len, space, T1_KERNING); + } + + if (T1_errno) { + RETURN_FALSE; + } + + array_init(return_value); + /* + printf(""%d %d %d %d\n"", str_bbox.llx, str_bbox.lly, str_bbox.urx, str_bbox.ury); + */ + add_next_index_long(return_value, (int) ceil(((double) str_bbox.llx)*sz/1000)); + add_next_index_long(return_value, (int) ceil(((double) str_bbox.lly)*sz/1000)); + add_next_index_long(return_value, (int) ceil(((double) str_bbox.urx)*sz/1000)); + add_next_index_long(return_value, (int) ceil(((double) str_bbox.ury)*sz/1000)); +} +","@@ -3082,6 +3082,11 @@ PHP_FUNCTION(imagegammacorrect) + return; + } + ++ if ( input <= 0.0 || output <= 0.0 ) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Gamma values should be positive""); ++ RETURN_FALSE; ++ } ++ + ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, ""Image"", le_gd); + + if (gdImageTrueColor(im)) {",1210,1446,2048 +8541,"static struct mapped_device *alloc_dev(int minor) +{ + int r, numa_node_id = dm_get_numa_node(); + struct dax_device *dax_dev; + struct mapped_device *md; + void *old_md; + + md = kvzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id); + if (!md) { + DMWARN(""unable to allocate device, out of memory.""); + return NULL; + } + + if (!try_module_get(THIS_MODULE)) + goto bad_module_get; + + /* get a minor number for the dev */ + if (minor == DM_ANY_MINOR) + r = next_free_minor(&minor); + else + r = specific_minor(minor); + if (r < 0) + goto bad_minor; + + r = init_srcu_struct(&md->io_barrier); + if (r < 0) + goto bad_io_barrier; + + md->numa_node_id = numa_node_id; + md->use_blk_mq = dm_use_blk_mq_default(); + md->init_tio_pdu = false; + md->type = DM_TYPE_NONE; + mutex_init(&md->suspend_lock); + mutex_init(&md->type_lock); + mutex_init(&md->table_devices_lock); + spin_lock_init(&md->deferred_lock); + atomic_set(&md->holders, 1); + atomic_set(&md->open_count, 0); + atomic_set(&md->event_nr, 0); + atomic_set(&md->uevent_seq, 0); + INIT_LIST_HEAD(&md->uevent_list); + INIT_LIST_HEAD(&md->table_devices); + spin_lock_init(&md->uevent_lock); + + md->queue = blk_alloc_queue_node(GFP_KERNEL, numa_node_id); + if (!md->queue) + goto bad; + + dm_init_md_queue(md); + + md->disk = alloc_disk_node(1, numa_node_id); + if (!md->disk) + goto bad; + + atomic_set(&md->pending[0], 0); + atomic_set(&md->pending[1], 0); + init_waitqueue_head(&md->wait); + INIT_WORK(&md->work, dm_wq_work); + init_waitqueue_head(&md->eventq); + init_completion(&md->kobj_holder.completion); + md->kworker_task = NULL; + + md->disk->major = _major; + md->disk->first_minor = minor; + md->disk->fops = &dm_blk_dops; + md->disk->queue = md->queue; + md->disk->private_data = md; + sprintf(md->disk->disk_name, ""dm-%d"", minor); + + dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev) + goto bad; + md->dax_dev = dax_dev; + + add_disk(md->disk); + format_dev_t(md->name, MKDEV(_major, minor)); + + md->wq = alloc_workqueue(""kdmflush"", WQ_MEM_RECLAIM, 0); + if (!md->wq) + goto bad; + + md->bdev = bdget_disk(md->disk, 0); + if (!md->bdev) + goto bad; + + bio_init(&md->flush_bio, NULL, 0); + bio_set_dev(&md->flush_bio, md->bdev); + md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC; + + dm_stats_init(&md->stats); + + /* Populate the mapping, nobody knows we exist yet */ + spin_lock(&_minor_lock); + old_md = idr_replace(&_minor_idr, md, minor); + spin_unlock(&_minor_lock); + + BUG_ON(old_md != MINOR_ALLOCED); + + return md; + +bad: + cleanup_mapped_device(md); +bad_io_barrier: + free_minor(minor); +bad_minor: + module_put(THIS_MODULE); +bad_module_get: + kvfree(md); + return NULL; +} +",0,"static struct mapped_device *alloc_dev(int minor) +{ + int r, numa_node_id = dm_get_numa_node(); + struct dax_device *dax_dev; + struct mapped_device *md; + void *old_md; + + md = kvzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id); + if (!md) { + DMWARN(""unable to allocate device, out of memory.""); + return NULL; + } + + if (!try_module_get(THIS_MODULE)) + goto bad_module_get; + + /* get a minor number for the dev */ + if (minor == DM_ANY_MINOR) + r = next_free_minor(&minor); + else + r = specific_minor(minor); + if (r < 0) + goto bad_minor; + + r = init_srcu_struct(&md->io_barrier); + if (r < 0) + goto bad_io_barrier; + + md->numa_node_id = numa_node_id; + md->use_blk_mq = dm_use_blk_mq_default(); + md->init_tio_pdu = false; + md->type = DM_TYPE_NONE; + mutex_init(&md->suspend_lock); + mutex_init(&md->type_lock); + mutex_init(&md->table_devices_lock); + spin_lock_init(&md->deferred_lock); + atomic_set(&md->holders, 1); + atomic_set(&md->open_count, 0); + atomic_set(&md->event_nr, 0); + atomic_set(&md->uevent_seq, 0); + INIT_LIST_HEAD(&md->uevent_list); + INIT_LIST_HEAD(&md->table_devices); + spin_lock_init(&md->uevent_lock); + + md->queue = blk_alloc_queue_node(GFP_KERNEL, numa_node_id); + if (!md->queue) + goto bad; + + dm_init_md_queue(md); + + md->disk = alloc_disk_node(1, numa_node_id); + if (!md->disk) + goto bad; + + atomic_set(&md->pending[0], 0); + atomic_set(&md->pending[1], 0); + init_waitqueue_head(&md->wait); + INIT_WORK(&md->work, dm_wq_work); + init_waitqueue_head(&md->eventq); + init_completion(&md->kobj_holder.completion); + md->kworker_task = NULL; + + md->disk->major = _major; + md->disk->first_minor = minor; + md->disk->fops = &dm_blk_dops; + md->disk->queue = md->queue; + md->disk->private_data = md; + sprintf(md->disk->disk_name, ""dm-%d"", minor); + + dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev) + goto bad; + md->dax_dev = dax_dev; + + add_disk(md->disk); + format_dev_t(md->name, MKDEV(_major, minor)); + + md->wq = alloc_workqueue(""kdmflush"", WQ_MEM_RECLAIM, 0); + if (!md->wq) + goto bad; + + md->bdev = bdget_disk(md->disk, 0); + if (!md->bdev) + goto bad; + + bio_init(&md->flush_bio, NULL, 0); + bio_set_dev(&md->flush_bio, md->bdev); + md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC; + + dm_stats_init(&md->stats); + + /* Populate the mapping, nobody knows we exist yet */ + spin_lock(&_minor_lock); + old_md = idr_replace(&_minor_idr, md, minor); + spin_unlock(&_minor_lock); + + BUG_ON(old_md != MINOR_ALLOCED); + + return md; + +bad: + cleanup_mapped_device(md); +bad_io_barrier: + free_minor(minor); +bad_minor: + module_put(THIS_MODULE); +bad_module_get: + kvfree(md); + return NULL; +} +","@@ -2711,11 +2711,15 @@ struct mapped_device *dm_get_from_kobject(struct kobject *kobj) + + md = container_of(kobj, struct mapped_device, kobj_holder.kobj); + +- if (test_bit(DMF_FREEING, &md->flags) || +- dm_deleting_md(md)) +- return NULL; +- ++ spin_lock(&_minor_lock); ++ if (test_bit(DMF_FREEING, &md->flags) || dm_deleting_md(md)) { ++ md = NULL; ++ goto out; ++ } + dm_get(md); ++out: ++ spin_unlock(&_minor_lock); ++ + return md; + } + ",795,1031,2048 +2846,"static void seq_chn_common_event(unsigned char *event_rec) +{ + unsigned char dev = event_rec[1]; + unsigned char cmd = event_rec[2]; + unsigned char chn = event_rec[3]; + unsigned char p1 = event_rec[4]; + + /* unsigned char p2 = event_rec[5]; */ + unsigned short w14 = *(short *) &event_rec[6]; + + if ((int) dev > max_synthdev || synth_devs[dev] == NULL) + return; + if (!(synth_open_mask & (1 << dev))) + return; + if (!synth_devs[dev]) + return; + + switch (cmd) + { + case MIDI_PGM_CHANGE: + if (seq_mode == SEQ_2) + { + synth_devs[dev]->chn_info[chn].pgm_num = p1; + if ((int) dev >= num_synths) + synth_devs[dev]->set_instr(dev, chn, p1); + } + else + synth_devs[dev]->set_instr(dev, chn, p1); + + break; + + case MIDI_CTL_CHANGE: + if (seq_mode == SEQ_2) + { + if (chn > 15 || p1 > 127) + break; + + synth_devs[dev]->chn_info[chn].controllers[p1] = w14 & 0x7f; + + if (p1 < 32) /* Setting MSB should clear LSB to 0 */ + synth_devs[dev]->chn_info[chn].controllers[p1 + 32] = 0; + + if ((int) dev < num_synths) + { + int val = w14 & 0x7f; + int i, key; + + if (p1 < 64) /* Combine MSB and LSB */ + { + val = ((synth_devs[dev]-> + chn_info[chn].controllers[p1 & ~32] & 0x7f) << 7) + | (synth_devs[dev]-> + chn_info[chn].controllers[p1 | 32] & 0x7f); + p1 &= ~32; + } + /* Handle all playing notes on this channel */ + + key = ((int) chn << 8); + + for (i = 0; i < synth_devs[dev]->alloc.max_voice; i++) + if ((synth_devs[dev]->alloc.map[i] & 0xff00) == key) + synth_devs[dev]->controller(dev, i, p1, val); + } + else + synth_devs[dev]->controller(dev, chn, p1, w14); + } + else /* Mode 1 */ + synth_devs[dev]->controller(dev, chn, p1, w14); + break; + + case MIDI_PITCH_BEND: + if (seq_mode == SEQ_2) + { + synth_devs[dev]->chn_info[chn].bender_value = w14; + + if ((int) dev < num_synths) + { + /* Handle all playing notes on this channel */ + int i, key; + + key = (chn << 8); + + for (i = 0; i < synth_devs[dev]->alloc.max_voice; i++) + if ((synth_devs[dev]->alloc.map[i] & 0xff00) == key) + synth_devs[dev]->bender(dev, i, w14); + } + else + synth_devs[dev]->bender(dev, chn, w14); + } + else /* MODE 1 */ + synth_devs[dev]->bender(dev, chn, w14); + break; + + default:; + } +} +",0,"static void seq_chn_common_event(unsigned char *event_rec) +{ + unsigned char dev = event_rec[1]; + unsigned char cmd = event_rec[2]; + unsigned char chn = event_rec[3]; + unsigned char p1 = event_rec[4]; + + /* unsigned char p2 = event_rec[5]; */ + unsigned short w14 = *(short *) &event_rec[6]; + + if ((int) dev > max_synthdev || synth_devs[dev] == NULL) + return; + if (!(synth_open_mask & (1 << dev))) + return; + if (!synth_devs[dev]) + return; + + switch (cmd) + { + case MIDI_PGM_CHANGE: + if (seq_mode == SEQ_2) + { + synth_devs[dev]->chn_info[chn].pgm_num = p1; + if ((int) dev >= num_synths) + synth_devs[dev]->set_instr(dev, chn, p1); + } + else + synth_devs[dev]->set_instr(dev, chn, p1); + + break; + + case MIDI_CTL_CHANGE: + if (seq_mode == SEQ_2) + { + if (chn > 15 || p1 > 127) + break; + + synth_devs[dev]->chn_info[chn].controllers[p1] = w14 & 0x7f; + + if (p1 < 32) /* Setting MSB should clear LSB to 0 */ + synth_devs[dev]->chn_info[chn].controllers[p1 + 32] = 0; + + if ((int) dev < num_synths) + { + int val = w14 & 0x7f; + int i, key; + + if (p1 < 64) /* Combine MSB and LSB */ + { + val = ((synth_devs[dev]-> + chn_info[chn].controllers[p1 & ~32] & 0x7f) << 7) + | (synth_devs[dev]-> + chn_info[chn].controllers[p1 | 32] & 0x7f); + p1 &= ~32; + } + /* Handle all playing notes on this channel */ + + key = ((int) chn << 8); + + for (i = 0; i < synth_devs[dev]->alloc.max_voice; i++) + if ((synth_devs[dev]->alloc.map[i] & 0xff00) == key) + synth_devs[dev]->controller(dev, i, p1, val); + } + else + synth_devs[dev]->controller(dev, chn, p1, w14); + } + else /* Mode 1 */ + synth_devs[dev]->controller(dev, chn, p1, w14); + break; + + case MIDI_PITCH_BEND: + if (seq_mode == SEQ_2) + { + synth_devs[dev]->chn_info[chn].bender_value = w14; + + if ((int) dev < num_synths) + { + /* Handle all playing notes on this channel */ + int i, key; + + key = (chn << 8); + + for (i = 0; i < synth_devs[dev]->alloc.max_voice; i++) + if ((synth_devs[dev]->alloc.map[i] & 0xff00) == key) + synth_devs[dev]->bender(dev, i, w14); + } + else + synth_devs[dev]->bender(dev, chn, w14); + } + else /* MODE 1 */ + synth_devs[dev]->bender(dev, chn, w14); + break; + + default:; + } +} +","@@ -241,7 +241,7 @@ int sequencer_write(int dev, struct file *file, const char __user *buf, int coun + return -ENXIO; + + fmt = (*(short *) &event_rec[0]) & 0xffff; +- err = synth_devs[dev]->load_patch(dev, fmt, buf, p + 4, c, 0); ++ err = synth_devs[dev]->load_patch(dev, fmt, buf + p, c, 0); + if (err < 0) + return err; + ",843,1079,2048 +18083,"long keyctl_chown_key(key_serial_t id, uid_t user, gid_t group) +{ + struct key_user *newowner, *zapowner = NULL; + struct key *key; + key_ref_t key_ref; + long ret; + kuid_t uid; + kgid_t gid; + + uid = make_kuid(current_user_ns(), user); + gid = make_kgid(current_user_ns(), group); + ret = -EINVAL; + if ((user != (uid_t) -1) && !uid_valid(uid)) + goto error; + if ((group != (gid_t) -1) && !gid_valid(gid)) + goto error; + + ret = 0; + if (user == (uid_t) -1 && group == (gid_t) -1) + goto error; + + key_ref = lookup_user_key(id, KEY_LOOKUP_CREATE | KEY_LOOKUP_PARTIAL, + KEY_NEED_SETATTR); + if (IS_ERR(key_ref)) { + ret = PTR_ERR(key_ref); + goto error; + } + + key = key_ref_to_ptr(key_ref); + + /* make the changes with the locks held to prevent chown/chown races */ + ret = -EACCES; + down_write(&key->sem); + + if (!capable(CAP_SYS_ADMIN)) { + /* only the sysadmin can chown a key to some other UID */ + if (user != (uid_t) -1 && !uid_eq(key->uid, uid)) + goto error_put; + + /* only the sysadmin can set the key's GID to a group other + * than one of those that the current process subscribes to */ + if (group != (gid_t) -1 && !gid_eq(gid, key->gid) && !in_group_p(gid)) + goto error_put; + } + + /* change the UID */ + if (user != (uid_t) -1 && !uid_eq(uid, key->uid)) { + ret = -ENOMEM; + newowner = key_user_lookup(uid); + if (!newowner) + goto error_put; + + /* transfer the quota burden to the new user */ + if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { + unsigned maxkeys = uid_eq(uid, GLOBAL_ROOT_UID) ? + key_quota_root_maxkeys : key_quota_maxkeys; + unsigned maxbytes = uid_eq(uid, GLOBAL_ROOT_UID) ? + key_quota_root_maxbytes : key_quota_maxbytes; + + spin_lock(&newowner->lock); + if (newowner->qnkeys + 1 >= maxkeys || + newowner->qnbytes + key->quotalen >= maxbytes || + newowner->qnbytes + key->quotalen < + newowner->qnbytes) + goto quota_overrun; + + newowner->qnkeys++; + newowner->qnbytes += key->quotalen; + spin_unlock(&newowner->lock); + + spin_lock(&key->user->lock); + key->user->qnkeys--; + key->user->qnbytes -= key->quotalen; + spin_unlock(&key->user->lock); + } + + atomic_dec(&key->user->nkeys); + atomic_inc(&newowner->nkeys); + + if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { + atomic_dec(&key->user->nikeys); + atomic_inc(&newowner->nikeys); + } + + zapowner = key->user; + key->user = newowner; + key->uid = uid; + } + + /* change the GID */ + if (group != (gid_t) -1) + key->gid = gid; + + ret = 0; + +error_put: + up_write(&key->sem); + key_put(key); + if (zapowner) + key_user_put(zapowner); +error: + return ret; + +quota_overrun: + spin_unlock(&newowner->lock); + zapowner = newowner; + ret = -EDQUOT; + goto error_put; +} +",1,"long keyctl_chown_key(key_serial_t id, uid_t user, gid_t group) +{ + struct key_user *newowner, *zapowner = NULL; + struct key *key; + key_ref_t key_ref; + long ret; + kuid_t uid; + kgid_t gid; + + uid = make_kuid(current_user_ns(), user); + gid = make_kgid(current_user_ns(), group); + ret = -EINVAL; + if ((user != (uid_t) -1) && !uid_valid(uid)) + goto error; + if ((group != (gid_t) -1) && !gid_valid(gid)) + goto error; + + ret = 0; + if (user == (uid_t) -1 && group == (gid_t) -1) + goto error; + + key_ref = lookup_user_key(id, KEY_LOOKUP_CREATE | KEY_LOOKUP_PARTIAL, + KEY_NEED_SETATTR); + if (IS_ERR(key_ref)) { + ret = PTR_ERR(key_ref); + goto error; + } + + key = key_ref_to_ptr(key_ref); + + /* make the changes with the locks held to prevent chown/chown races */ + ret = -EACCES; + down_write(&key->sem); + + if (!capable(CAP_SYS_ADMIN)) { + /* only the sysadmin can chown a key to some other UID */ + if (user != (uid_t) -1 && !uid_eq(key->uid, uid)) + goto error_put; + + /* only the sysadmin can set the key's GID to a group other + * than one of those that the current process subscribes to */ + if (group != (gid_t) -1 && !gid_eq(gid, key->gid) && !in_group_p(gid)) + goto error_put; + } + + /* change the UID */ + if (user != (uid_t) -1 && !uid_eq(uid, key->uid)) { + ret = -ENOMEM; + newowner = key_user_lookup(uid); + if (!newowner) + goto error_put; + + /* transfer the quota burden to the new user */ + if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { + unsigned maxkeys = uid_eq(uid, GLOBAL_ROOT_UID) ? + key_quota_root_maxkeys : key_quota_maxkeys; + unsigned maxbytes = uid_eq(uid, GLOBAL_ROOT_UID) ? + key_quota_root_maxbytes : key_quota_maxbytes; + + spin_lock(&newowner->lock); + if (newowner->qnkeys + 1 >= maxkeys || + newowner->qnbytes + key->quotalen >= maxbytes || + newowner->qnbytes + key->quotalen < + newowner->qnbytes) + goto quota_overrun; + + newowner->qnkeys++; + newowner->qnbytes += key->quotalen; + spin_unlock(&newowner->lock); + + spin_lock(&key->user->lock); + key->user->qnkeys--; + key->user->qnbytes -= key->quotalen; + spin_unlock(&key->user->lock); + } + + atomic_dec(&key->user->nkeys); + atomic_inc(&newowner->nkeys); + + if (key->state != KEY_IS_UNINSTANTIATED) { + atomic_dec(&key->user->nikeys); + atomic_inc(&newowner->nikeys); + } + + zapowner = key->user; + key->user = newowner; + key->uid = uid; + } + + /* change the GID */ + if (group != (gid_t) -1) + key->gid = gid; + + ret = 0; + +error_put: + up_write(&key->sem); + key_put(key); + if (zapowner) + key_user_put(zapowner); +error: + return ret; + +quota_overrun: + spin_unlock(&newowner->lock); + zapowner = newowner; + ret = -EDQUOT; + goto error_put; +} +","@@ -766,10 +766,9 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) + + key = key_ref_to_ptr(key_ref); + +- if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { +- ret = -ENOKEY; +- goto error2; +- } ++ ret = key_read_state(key); ++ if (ret < 0) ++ goto error2; /* Negatively instantiated */ + + /* see if we can read it directly */ + ret = key_permission(key_ref, KEY_NEED_READ); +@@ -901,7 +900,7 @@ long keyctl_chown_key(key_serial_t id, uid_t user, gid_t group) + atomic_dec(&key->user->nkeys); + atomic_inc(&newowner->nkeys); + +- if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { ++ if (key->state != KEY_IS_UNINSTANTIATED) { + atomic_dec(&key->user->nikeys); + atomic_inc(&newowner->nikeys); + }",824,1060,2048 +4121,"static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev) +{ + struct sock *sk; + struct packet_sock *po; + struct sockaddr_ll *sll; + union tpacket_uhdr h; + u8 *skb_head = skb->data; + int skb_len = skb->len; + unsigned int snaplen, res; + unsigned long status = TP_STATUS_USER; + unsigned short macoff, netoff, hdrlen; + struct sk_buff *copy_skb = NULL; + struct timespec ts; + __u32 ts_status; + + if (skb->pkt_type == PACKET_LOOPBACK) + goto drop; + + sk = pt->af_packet_priv; + po = pkt_sk(sk); + + if (!net_eq(dev_net(dev), sock_net(sk))) + goto drop; + + if (dev->header_ops) { + if (sk->sk_type != SOCK_DGRAM) + skb_push(skb, skb->data - skb_mac_header(skb)); + else if (skb->pkt_type == PACKET_OUTGOING) { + /* Special case: outgoing packets have ll header at head */ + skb_pull(skb, skb_network_offset(skb)); + } + } + + if (skb->ip_summed == CHECKSUM_PARTIAL) + status |= TP_STATUS_CSUMNOTREADY; + + snaplen = skb->len; + + res = run_filter(skb, sk, snaplen); + if (!res) + goto drop_n_restore; + if (snaplen > res) + snaplen = res; + + if (sk->sk_type == SOCK_DGRAM) { + macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 + + po->tp_reserve; + } else { + unsigned int maclen = skb_network_offset(skb); + netoff = TPACKET_ALIGN(po->tp_hdrlen + + (maclen < 16 ? 16 : maclen)) + + po->tp_reserve; + macoff = netoff - maclen; + } + if (po->tp_version <= TPACKET_V2) { + if (macoff + snaplen > po->rx_ring.frame_size) { + if (po->copy_thresh && + atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { + if (skb_shared(skb)) { + copy_skb = skb_clone(skb, GFP_ATOMIC); + } else { + copy_skb = skb_get(skb); + skb_head = skb->data; + } + if (copy_skb) + skb_set_owner_r(copy_skb, sk); + } + snaplen = po->rx_ring.frame_size - macoff; + if ((int)snaplen < 0) + snaplen = 0; + } + } + spin_lock(&sk->sk_receive_queue.lock); + h.raw = packet_current_rx_frame(po, skb, + TP_STATUS_KERNEL, (macoff+snaplen)); + if (!h.raw) + goto ring_is_full; + if (po->tp_version <= TPACKET_V2) { + packet_increment_rx_head(po, &po->rx_ring); + /* + * LOSING will be reported till you read the stats, + * because it's COR - Clear On Read. + * Anyways, moving it for V1/V2 only as V3 doesn't need this + * at packet level. + */ + if (po->stats.stats1.tp_drops) + status |= TP_STATUS_LOSING; + } + po->stats.stats1.tp_packets++; + if (copy_skb) { + status |= TP_STATUS_COPY; + __skb_queue_tail(&sk->sk_receive_queue, copy_skb); + } + spin_unlock(&sk->sk_receive_queue.lock); + + skb_copy_bits(skb, 0, h.raw + macoff, snaplen); + + if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) + getnstimeofday(&ts); + + status |= ts_status; + + switch (po->tp_version) { + case TPACKET_V1: + h.h1->tp_len = skb->len; + h.h1->tp_snaplen = snaplen; + h.h1->tp_mac = macoff; + h.h1->tp_net = netoff; + h.h1->tp_sec = ts.tv_sec; + h.h1->tp_usec = ts.tv_nsec / NSEC_PER_USEC; + hdrlen = sizeof(*h.h1); + break; + case TPACKET_V2: + h.h2->tp_len = skb->len; + h.h2->tp_snaplen = snaplen; + h.h2->tp_mac = macoff; + h.h2->tp_net = netoff; + h.h2->tp_sec = ts.tv_sec; + h.h2->tp_nsec = ts.tv_nsec; + if (vlan_tx_tag_present(skb)) { + h.h2->tp_vlan_tci = vlan_tx_tag_get(skb); + status |= TP_STATUS_VLAN_VALID; + } else { + h.h2->tp_vlan_tci = 0; + } + h.h2->tp_padding = 0; + hdrlen = sizeof(*h.h2); + break; + case TPACKET_V3: + /* tp_nxt_offset,vlan are already populated above. + * So DONT clear those fields here + */ + h.h3->tp_status |= status; + h.h3->tp_len = skb->len; + h.h3->tp_snaplen = snaplen; + h.h3->tp_mac = macoff; + h.h3->tp_net = netoff; + h.h3->tp_sec = ts.tv_sec; + h.h3->tp_nsec = ts.tv_nsec; + hdrlen = sizeof(*h.h3); + break; + default: + BUG(); + } + + sll = h.raw + TPACKET_ALIGN(hdrlen); + sll->sll_halen = dev_parse_header(skb, sll->sll_addr); + sll->sll_family = AF_PACKET; + sll->sll_hatype = dev->type; + sll->sll_protocol = skb->protocol; + sll->sll_pkttype = skb->pkt_type; + if (unlikely(po->origdev)) + sll->sll_ifindex = orig_dev->ifindex; + else + sll->sll_ifindex = dev->ifindex; + + smp_mb(); +#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 + { + u8 *start, *end; + + if (po->tp_version <= TPACKET_V2) { + end = (u8 *)PAGE_ALIGN((unsigned long)h.raw + + macoff + snaplen); + for (start = h.raw; start < end; start += PAGE_SIZE) + flush_dcache_page(pgv_to_page(start)); + } + smp_wmb(); + } +#endif + if (po->tp_version <= TPACKET_V2) + __packet_set_status(po, h.raw, status); + else + prb_clear_blk_fill_status(&po->rx_ring); + + sk->sk_data_ready(sk, 0); + +drop_n_restore: + if (skb_head != skb->data && skb_shared(skb)) { + skb->data = skb_head; + skb->len = skb_len; + } +drop: + kfree_skb(skb); + return 0; + +ring_is_full: + po->stats.stats1.tp_drops++; + spin_unlock(&sk->sk_receive_queue.lock); + + sk->sk_data_ready(sk, 0); + kfree_skb(copy_skb); + goto drop_n_restore; +} +",0,"static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev) +{ + struct sock *sk; + struct packet_sock *po; + struct sockaddr_ll *sll; + union tpacket_uhdr h; + u8 *skb_head = skb->data; + int skb_len = skb->len; + unsigned int snaplen, res; + unsigned long status = TP_STATUS_USER; + unsigned short macoff, netoff, hdrlen; + struct sk_buff *copy_skb = NULL; + struct timespec ts; + __u32 ts_status; + + if (skb->pkt_type == PACKET_LOOPBACK) + goto drop; + + sk = pt->af_packet_priv; + po = pkt_sk(sk); + + if (!net_eq(dev_net(dev), sock_net(sk))) + goto drop; + + if (dev->header_ops) { + if (sk->sk_type != SOCK_DGRAM) + skb_push(skb, skb->data - skb_mac_header(skb)); + else if (skb->pkt_type == PACKET_OUTGOING) { + /* Special case: outgoing packets have ll header at head */ + skb_pull(skb, skb_network_offset(skb)); + } + } + + if (skb->ip_summed == CHECKSUM_PARTIAL) + status |= TP_STATUS_CSUMNOTREADY; + + snaplen = skb->len; + + res = run_filter(skb, sk, snaplen); + if (!res) + goto drop_n_restore; + if (snaplen > res) + snaplen = res; + + if (sk->sk_type == SOCK_DGRAM) { + macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 + + po->tp_reserve; + } else { + unsigned int maclen = skb_network_offset(skb); + netoff = TPACKET_ALIGN(po->tp_hdrlen + + (maclen < 16 ? 16 : maclen)) + + po->tp_reserve; + macoff = netoff - maclen; + } + if (po->tp_version <= TPACKET_V2) { + if (macoff + snaplen > po->rx_ring.frame_size) { + if (po->copy_thresh && + atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { + if (skb_shared(skb)) { + copy_skb = skb_clone(skb, GFP_ATOMIC); + } else { + copy_skb = skb_get(skb); + skb_head = skb->data; + } + if (copy_skb) + skb_set_owner_r(copy_skb, sk); + } + snaplen = po->rx_ring.frame_size - macoff; + if ((int)snaplen < 0) + snaplen = 0; + } + } + spin_lock(&sk->sk_receive_queue.lock); + h.raw = packet_current_rx_frame(po, skb, + TP_STATUS_KERNEL, (macoff+snaplen)); + if (!h.raw) + goto ring_is_full; + if (po->tp_version <= TPACKET_V2) { + packet_increment_rx_head(po, &po->rx_ring); + /* + * LOSING will be reported till you read the stats, + * because it's COR - Clear On Read. + * Anyways, moving it for V1/V2 only as V3 doesn't need this + * at packet level. + */ + if (po->stats.stats1.tp_drops) + status |= TP_STATUS_LOSING; + } + po->stats.stats1.tp_packets++; + if (copy_skb) { + status |= TP_STATUS_COPY; + __skb_queue_tail(&sk->sk_receive_queue, copy_skb); + } + spin_unlock(&sk->sk_receive_queue.lock); + + skb_copy_bits(skb, 0, h.raw + macoff, snaplen); + + if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) + getnstimeofday(&ts); + + status |= ts_status; + + switch (po->tp_version) { + case TPACKET_V1: + h.h1->tp_len = skb->len; + h.h1->tp_snaplen = snaplen; + h.h1->tp_mac = macoff; + h.h1->tp_net = netoff; + h.h1->tp_sec = ts.tv_sec; + h.h1->tp_usec = ts.tv_nsec / NSEC_PER_USEC; + hdrlen = sizeof(*h.h1); + break; + case TPACKET_V2: + h.h2->tp_len = skb->len; + h.h2->tp_snaplen = snaplen; + h.h2->tp_mac = macoff; + h.h2->tp_net = netoff; + h.h2->tp_sec = ts.tv_sec; + h.h2->tp_nsec = ts.tv_nsec; + if (vlan_tx_tag_present(skb)) { + h.h2->tp_vlan_tci = vlan_tx_tag_get(skb); + status |= TP_STATUS_VLAN_VALID; + } else { + h.h2->tp_vlan_tci = 0; + } + h.h2->tp_padding = 0; + hdrlen = sizeof(*h.h2); + break; + case TPACKET_V3: + /* tp_nxt_offset,vlan are already populated above. + * So DONT clear those fields here + */ + h.h3->tp_status |= status; + h.h3->tp_len = skb->len; + h.h3->tp_snaplen = snaplen; + h.h3->tp_mac = macoff; + h.h3->tp_net = netoff; + h.h3->tp_sec = ts.tv_sec; + h.h3->tp_nsec = ts.tv_nsec; + hdrlen = sizeof(*h.h3); + break; + default: + BUG(); + } + + sll = h.raw + TPACKET_ALIGN(hdrlen); + sll->sll_halen = dev_parse_header(skb, sll->sll_addr); + sll->sll_family = AF_PACKET; + sll->sll_hatype = dev->type; + sll->sll_protocol = skb->protocol; + sll->sll_pkttype = skb->pkt_type; + if (unlikely(po->origdev)) + sll->sll_ifindex = orig_dev->ifindex; + else + sll->sll_ifindex = dev->ifindex; + + smp_mb(); +#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 + { + u8 *start, *end; + + if (po->tp_version <= TPACKET_V2) { + end = (u8 *)PAGE_ALIGN((unsigned long)h.raw + + macoff + snaplen); + for (start = h.raw; start < end; start += PAGE_SIZE) + flush_dcache_page(pgv_to_page(start)); + } + smp_wmb(); + } +#endif + if (po->tp_version <= TPACKET_V2) + __packet_set_status(po, h.raw, status); + else + prb_clear_blk_fill_status(&po->rx_ring); + + sk->sk_data_ready(sk, 0); + +drop_n_restore: + if (skb_head != skb->data && skb_shared(skb)) { + skb->data = skb_head; + skb->len = skb_len; + } +drop: + kfree_skb(skb); + return 0; + +ring_is_full: + po->stats.stats1.tp_drops++; + spin_unlock(&sk->sk_receive_queue.lock); + + sk->sk_data_ready(sk, 0); + kfree_skb(copy_skb); + goto drop_n_restore; +} +","@@ -2660,7 +2660,6 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, + struct sock *sk = sock->sk; + struct sk_buff *skb; + int copied, err; +- struct sockaddr_ll *sll; + int vnet_hdr_len = 0; + + err = -EINVAL; +@@ -2744,22 +2743,10 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, + goto out_free; + } + +- /* +- * If the address length field is there to be filled in, we fill +- * it in now. +- */ +- +- sll = &PACKET_SKB_CB(skb)->sa.ll; +- if (sock->type == SOCK_PACKET) +- msg->msg_namelen = sizeof(struct sockaddr_pkt); +- else +- msg->msg_namelen = sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr); +- +- /* +- * You lose any data beyond the buffer you gave. If it worries a +- * user program they can ask the device for its MTU anyway. ++ /* You lose any data beyond the buffer you gave. If it worries ++ * a user program they can ask the device for its MTU ++ * anyway. + */ +- + copied = skb->len; + if (copied > len) { + copied = len; +@@ -2772,9 +2759,20 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, + + sock_recv_ts_and_drops(msg, sk, skb); + +- if (msg->msg_name) ++ if (msg->msg_name) { ++ /* If the address length field is there to be filled ++ * in, we fill it in now. ++ */ ++ if (sock->type == SOCK_PACKET) { ++ msg->msg_namelen = sizeof(struct sockaddr_pkt); ++ } else { ++ struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll; ++ msg->msg_namelen = sll->sll_halen + ++ offsetof(struct sockaddr_ll, sll_addr); ++ } + memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, + msg->msg_namelen); ++ } + + if (pkt_sk(sk)->auxdata) { + struct tpacket_auxdata aux;",1611,1847,2048 +17863,"jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t *p_header_size) +{ + Jbig2Segment *result; + uint8_t rtscarf; + uint32_t rtscarf_long; + uint32_t *referred_to_segments; + int referred_to_segment_count; + int referred_to_segment_size; + int pa_size; + int offset; + + /* minimum possible size of a jbig2 segment header */ + if (buf_size < 11) + return NULL; + + result = jbig2_new(ctx, Jbig2Segment, 1); + if (result == NULL) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, ""failed to allocate segment in jbig2_parse_segment_header""); + return result; + } + + /* 7.2.2 */ + result->number = jbig2_get_uint32(buf); + + /* 7.2.3 */ + result->flags = buf[4]; + + /* 7.2.4 referred-to segments */ + rtscarf = buf[5]; + if ((rtscarf & 0xe0) == 0xe0) { + rtscarf_long = jbig2_get_uint32(buf + 5); + referred_to_segment_count = rtscarf_long & 0x1fffffff; + offset = 5 + 4 + (referred_to_segment_count + 1) / 8; + } else { + referred_to_segment_count = (rtscarf >> 5); + offset = 5 + 1; + } + result->referred_to_segment_count = referred_to_segment_count; + + /* we now have enough information to compute the full header length */ + referred_to_segment_size = result->number <= 256 ? 1 : result->number <= 65536 ? 2 : 4; /* 7.2.5 */ + pa_size = result->flags & 0x40 ? 4 : 1; /* 7.2.6 */ + if (offset + referred_to_segment_count * referred_to_segment_size + pa_size + 4 > buf_size) { + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, result->number, ""jbig2_parse_segment_header() called with insufficient data"", -1); + jbig2_free(ctx->allocator, result); + return NULL; + } + + /* 7.2.5 */ + if (referred_to_segment_count) { + int i; + + referred_to_segments = jbig2_new(ctx, uint32_t, referred_to_segment_count * referred_to_segment_size); + if (referred_to_segments == NULL) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, ""could not allocate referred_to_segments "" ""in jbig2_parse_segment_header""); + return NULL; + } + + for (i = 0; i < referred_to_segment_count; i++) { + referred_to_segments[i] = + (referred_to_segment_size == 1) ? buf[offset] : + (referred_to_segment_size == 2) ? jbig2_get_uint16(buf + offset) : jbig2_get_uint32(buf + offset); + offset += referred_to_segment_size; + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, result->number, ""segment %d refers to segment %d"", result->number, referred_to_segments[i]); + } + result->referred_to_segments = referred_to_segments; + } else { /* no referred-to segments */ + + result->referred_to_segments = NULL; + } + + /* 7.2.6 */ + if (result->flags & 0x40) { + result->page_association = jbig2_get_uint32(buf + offset); + offset += 4; + } else { + result->page_association = buf[offset++]; + } + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, result->number, ""segment %d is associated with page %d"", result->number, result->page_association); + + /* 7.2.7 */ + result->data_length = jbig2_get_uint32(buf + offset); + *p_header_size = offset + 4; + + /* no body parsing results yet */ + result->result = NULL; + + return result; +} +",1,"jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t *p_header_size) +{ + Jbig2Segment *result; + uint8_t rtscarf; + uint32_t rtscarf_long; + uint32_t *referred_to_segments; + uint32_t referred_to_segment_count; + uint32_t referred_to_segment_size; + uint32_t pa_size; + uint32_t offset; + + /* minimum possible size of a jbig2 segment header */ + if (buf_size < 11) + return NULL; + + result = jbig2_new(ctx, Jbig2Segment, 1); + if (result == NULL) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, ""failed to allocate segment in jbig2_parse_segment_header""); + return result; + } + + /* 7.2.2 */ + result->number = jbig2_get_uint32(buf); + + /* 7.2.3 */ + result->flags = buf[4]; + + /* 7.2.4 referred-to segments */ + rtscarf = buf[5]; + if ((rtscarf & 0xe0) == 0xe0) { + rtscarf_long = jbig2_get_uint32(buf + 5); + referred_to_segment_count = rtscarf_long & 0x1fffffff; + offset = 5 + 4 + (referred_to_segment_count + 1) / 8; + } else { + referred_to_segment_count = (rtscarf >> 5); + offset = 5 + 1; + } + result->referred_to_segment_count = referred_to_segment_count; + + /* we now have enough information to compute the full header length */ + referred_to_segment_size = result->number <= 256 ? 1 : result->number <= 65536 ? 2 : 4; /* 7.2.5 */ + pa_size = result->flags & 0x40 ? 4 : 1; /* 7.2.6 */ + if (offset + referred_to_segment_count * referred_to_segment_size + pa_size + 4 > buf_size) { + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, result->number, ""jbig2_parse_segment_header() called with insufficient data"", -1); + jbig2_free(ctx->allocator, result); + return NULL; + } + + /* 7.2.5 */ + if (referred_to_segment_count) { + uint32_t i; + + referred_to_segments = jbig2_new(ctx, uint32_t, referred_to_segment_count * referred_to_segment_size); + if (referred_to_segments == NULL) { + jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, ""could not allocate referred_to_segments "" ""in jbig2_parse_segment_header""); + return NULL; + } + + for (i = 0; i < referred_to_segment_count; i++) { + referred_to_segments[i] = + (referred_to_segment_size == 1) ? buf[offset] : + (referred_to_segment_size == 2) ? jbig2_get_uint16(buf + offset) : jbig2_get_uint32(buf + offset); + offset += referred_to_segment_size; + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, result->number, ""segment %d refers to segment %d"", result->number, referred_to_segments[i]); + } + result->referred_to_segments = referred_to_segments; + } else { /* no referred-to segments */ + + result->referred_to_segments = NULL; + } + + /* 7.2.6 */ + if (result->flags & 0x40) { + result->page_association = jbig2_get_uint32(buf + offset); + offset += 4; + } else { + result->page_association = buf[offset++]; + } + jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, result->number, ""segment %d is associated with page %d"", result->number, result->page_association); + + /* 7.2.7 */ + result->data_length = jbig2_get_uint32(buf + offset); + *p_header_size = offset + 4; + + /* no body parsing results yet */ + result->result = NULL; + + return result; +} +","@@ -39,10 +39,10 @@ jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t + uint8_t rtscarf; + uint32_t rtscarf_long; + uint32_t *referred_to_segments; +- int referred_to_segment_count; +- int referred_to_segment_size; +- int pa_size; +- int offset; ++ uint32_t referred_to_segment_count; ++ uint32_t referred_to_segment_size; ++ uint32_t pa_size; ++ uint32_t offset; + + /* minimum possible size of a jbig2 segment header */ + if (buf_size < 11) +@@ -83,7 +83,7 @@ jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t + + /* 7.2.5 */ + if (referred_to_segment_count) { +- int i; ++ uint32_t i; + + referred_to_segments = jbig2_new(ctx, uint32_t, referred_to_segment_count * referred_to_segment_size); + if (referred_to_segments == NULL) {",950,1186,2048 +1261,"_gnutls_compressed2ciphertext (gnutls_session_t session, + opaque * cipher_data, int cipher_size, + gnutls_datum_t compressed, + content_type_t _type, int random_pad) +{ + uint8_t MAC[MAX_HASH_SIZE]; + uint16_t c_length; + uint8_t pad; + int length, ret; + digest_hd_st td; + uint8_t type = _type; + uint8_t major, minor; + int hash_size = + _gnutls_hash_get_algo_len (session->security_parameters. + write_mac_algorithm); + gnutls_protocol_t ver; + int blocksize = + _gnutls_cipher_get_block_size (session->security_parameters. + write_bulk_cipher_algorithm); + cipher_type_t block_algo = + _gnutls_cipher_is_block (session->security_parameters. + write_bulk_cipher_algorithm); + opaque *data_ptr; + + + ver = gnutls_protocol_get_version (session); + minor = _gnutls_version_get_minor (ver); + major = _gnutls_version_get_major (ver); + + + /* Initialize MAC */ + ret = mac_init (&td, session->security_parameters.write_mac_algorithm, + session->connection_state.write_mac_secret.data, + session->connection_state.write_mac_secret.size, ver); + + if (ret < 0 && session->security_parameters.write_mac_algorithm != GNUTLS_MAC_NULL) + { + gnutls_assert (); + return ret; + } + + c_length = _gnutls_conv_uint16 (compressed.size); + + if (session->security_parameters.write_mac_algorithm != GNUTLS_MAC_NULL) + { /* actually when the algorithm in not the NULL one */ + _gnutls_hmac (&td, + UINT64DATA (session->connection_state. + write_sequence_number), 8); + + _gnutls_hmac (&td, &type, 1); + if (ver >= GNUTLS_TLS1) + { /* TLS 1.0 or higher */ + _gnutls_hmac (&td, &major, 1); + _gnutls_hmac (&td, &minor, 1); + } + _gnutls_hmac (&td, &c_length, 2); + _gnutls_hmac (&td, compressed.data, compressed.size); + mac_deinit (&td, MAC, ver); + } + + + /* Calculate the encrypted length (padding etc.) + */ + length = + calc_enc_length (session, compressed.size, hash_size, &pad, + random_pad, block_algo, blocksize); + if (length < 0) + { + gnutls_assert (); + return length; + } + + /* copy the encrypted data to cipher_data. + */ + if (cipher_size < length) + { + gnutls_assert (); + return GNUTLS_E_MEMORY_ERROR; + } + + data_ptr = cipher_data; + if (block_algo == CIPHER_BLOCK && + session->security_parameters.version >= GNUTLS_TLS1_1) + { + /* copy the random IV. + */ + ret = _gnutls_rnd (RND_NONCE, data_ptr, blocksize); + if (ret < 0) + { + gnutls_assert (); + return ret; + } + + data_ptr += blocksize; + } + + memcpy (data_ptr, compressed.data, compressed.size); + data_ptr += compressed.size; + + if (hash_size > 0) + { + memcpy (data_ptr, MAC, hash_size); + data_ptr += hash_size; + } + if (block_algo == CIPHER_BLOCK && pad > 0) + { + memset (data_ptr, pad - 1, pad); + } + + + /* Actual encryption (inplace). + */ + ret = _gnutls_cipher_encrypt (&session->connection_state. + write_cipher_state, cipher_data, length); + if (ret < 0) + { + gnutls_assert (); + return ret; + } + + return length; +} +",0,"_gnutls_compressed2ciphertext (gnutls_session_t session, + opaque * cipher_data, int cipher_size, + gnutls_datum_t compressed, + content_type_t _type, int random_pad) +{ + uint8_t MAC[MAX_HASH_SIZE]; + uint16_t c_length; + uint8_t pad; + int length, ret; + digest_hd_st td; + uint8_t type = _type; + uint8_t major, minor; + int hash_size = + _gnutls_hash_get_algo_len (session->security_parameters. + write_mac_algorithm); + gnutls_protocol_t ver; + int blocksize = + _gnutls_cipher_get_block_size (session->security_parameters. + write_bulk_cipher_algorithm); + cipher_type_t block_algo = + _gnutls_cipher_is_block (session->security_parameters. + write_bulk_cipher_algorithm); + opaque *data_ptr; + + + ver = gnutls_protocol_get_version (session); + minor = _gnutls_version_get_minor (ver); + major = _gnutls_version_get_major (ver); + + + /* Initialize MAC */ + ret = mac_init (&td, session->security_parameters.write_mac_algorithm, + session->connection_state.write_mac_secret.data, + session->connection_state.write_mac_secret.size, ver); + + if (ret < 0 && session->security_parameters.write_mac_algorithm != GNUTLS_MAC_NULL) + { + gnutls_assert (); + return ret; + } + + c_length = _gnutls_conv_uint16 (compressed.size); + + if (session->security_parameters.write_mac_algorithm != GNUTLS_MAC_NULL) + { /* actually when the algorithm in not the NULL one */ + _gnutls_hmac (&td, + UINT64DATA (session->connection_state. + write_sequence_number), 8); + + _gnutls_hmac (&td, &type, 1); + if (ver >= GNUTLS_TLS1) + { /* TLS 1.0 or higher */ + _gnutls_hmac (&td, &major, 1); + _gnutls_hmac (&td, &minor, 1); + } + _gnutls_hmac (&td, &c_length, 2); + _gnutls_hmac (&td, compressed.data, compressed.size); + mac_deinit (&td, MAC, ver); + } + + + /* Calculate the encrypted length (padding etc.) + */ + length = + calc_enc_length (session, compressed.size, hash_size, &pad, + random_pad, block_algo, blocksize); + if (length < 0) + { + gnutls_assert (); + return length; + } + + /* copy the encrypted data to cipher_data. + */ + if (cipher_size < length) + { + gnutls_assert (); + return GNUTLS_E_MEMORY_ERROR; + } + + data_ptr = cipher_data; + if (block_algo == CIPHER_BLOCK && + session->security_parameters.version >= GNUTLS_TLS1_1) + { + /* copy the random IV. + */ + ret = _gnutls_rnd (RND_NONCE, data_ptr, blocksize); + if (ret < 0) + { + gnutls_assert (); + return ret; + } + + data_ptr += blocksize; + } + + memcpy (data_ptr, compressed.data, compressed.size); + data_ptr += compressed.size; + + if (hash_size > 0) + { + memcpy (data_ptr, MAC, hash_size); + data_ptr += hash_size; + } + if (block_algo == CIPHER_BLOCK && pad > 0) + { + memset (data_ptr, pad - 1, pad); + } + + + /* Actual encryption (inplace). + */ + ret = _gnutls_cipher_encrypt (&session->connection_state. + write_cipher_state, cipher_data, length); + if (ret < 0) + { + gnutls_assert (); + return ret; + } + + return length; +} +","@@ -459,6 +459,14 @@ _gnutls_ciphertext2compressed (gnutls_session_t session, + return GNUTLS_E_INTERNAL_ERROR; + } + ++ if (ciphertext.size < (unsigned) blocksize + hash_size) ++ { ++ _gnutls_record_log ++ (""REC[%x]: Short record length %d < %d + %d (under attack?)\n"", ++ session, ciphertext.size, blocksize, hash_size); ++ gnutls_assert (); ++ return GNUTLS_E_DECRYPTION_FAILED; ++ } + + /* actual decryption (inplace) + */ +@@ -510,9 +518,7 @@ _gnutls_ciphertext2compressed (gnutls_session_t session, + + pad = ciphertext.data[ciphertext.size - 1] + 1; /* pad */ + +- length = ciphertext.size - hash_size - pad; +- +- if (pad > ciphertext.size - hash_size) ++ if ((int)pad > (int)ciphertext.size - hash_size) + { + gnutls_assert (); + /* We do not fail here. We check below for the +@@ -521,6 +527,8 @@ _gnutls_ciphertext2compressed (gnutls_session_t session, + pad_failed = GNUTLS_E_DECRYPTION_FAILED; + } + ++ length = ciphertext.size - hash_size - pad; ++ + /* Check the pading bytes (TLS 1.x) + */ + if (ver >= GNUTLS_TLS1 && pad_failed == 0)",845,1081,2048 +17,"SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ */ +{ + zval **val = NULL; + char *cafile = NULL; + char *capath = NULL; + char *certfile = NULL; + char *cipherlist = NULL; + int ok = 1; + + ERR_clear_error(); + + /* look at context options in the stream and set appropriate verification flags */ + if (GET_VER_OPT(""verify_peer"") && zval_is_true(*val)) { + + /* turn on verification callback */ + SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, verify_callback); + + /* CA stuff */ + GET_VER_OPT_STRING(""cafile"", cafile); + GET_VER_OPT_STRING(""capath"", capath); + + if (cafile || capath) { + if (!SSL_CTX_load_verify_locations(ctx, cafile, capath)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set verify locations `%s' `%s'"", cafile, capath); + return NULL; + } + } + + if (GET_VER_OPT(""verify_depth"")) { + convert_to_long_ex(val); + SSL_CTX_set_verify_depth(ctx, Z_LVAL_PP(val)); + } + } else { + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); + } + + /* callback for the passphrase (for localcert) */ + if (GET_VER_OPT(""passphrase"")) { + SSL_CTX_set_default_passwd_cb_userdata(ctx, stream); + SSL_CTX_set_default_passwd_cb(ctx, passwd_callback); + } + + GET_VER_OPT_STRING(""ciphers"", cipherlist); + if (!cipherlist) { + cipherlist = ""DEFAULT""; + } + if (SSL_CTX_set_cipher_list(ctx, cipherlist) != 1) { + return NULL; + } + + GET_VER_OPT_STRING(""local_cert"", certfile); + if (certfile) { + X509 *cert = NULL; + EVP_PKEY *key = NULL; + SSL *tmpssl; + char resolved_path_buff[MAXPATHLEN]; + const char * private_key = NULL; + + if (VCWD_REALPATH(certfile, resolved_path_buff)) { + /* a certificate to use for authentication */ + if (SSL_CTX_use_certificate_chain_file(ctx, resolved_path_buff) != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set local cert chain file `%s'; Check that your cafile/capath settings include details of your certificate and its issuer"", certfile); + return NULL; + } + GET_VER_OPT_STRING(""local_pk"", private_key); + + if (private_key) { + char resolved_path_buff_pk[MAXPATHLEN]; + if (VCWD_REALPATH(private_key, resolved_path_buff_pk)) { + if (SSL_CTX_use_PrivateKey_file(ctx, resolved_path_buff_pk, SSL_FILETYPE_PEM) != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set private key file `%s'"", resolved_path_buff_pk); + return NULL; + } + } + } else { + if (SSL_CTX_use_PrivateKey_file(ctx, resolved_path_buff, SSL_FILETYPE_PEM) != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set private key file `%s'"", resolved_path_buff); + return NULL; + } + } + + tmpssl = SSL_new(ctx); + cert = SSL_get_certificate(tmpssl); + + if (cert) { + key = X509_get_pubkey(cert); + EVP_PKEY_copy_parameters(key, SSL_get_privatekey(tmpssl)); + EVP_PKEY_free(key); + } + SSL_free(tmpssl); + + if (!SSL_CTX_check_private_key(ctx)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Private key does not match certificate!""); + } + } + } + if (ok) { + SSL *ssl = SSL_new(ctx); + + if (ssl) { + /* map SSL => stream */ + SSL_set_ex_data(ssl, ssl_stream_data_index, stream); + } + return ssl; + } + + return NULL; +} +/* }}} */ +",0,"SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ */ +{ + zval **val = NULL; + char *cafile = NULL; + char *capath = NULL; + char *certfile = NULL; + char *cipherlist = NULL; + int ok = 1; + + ERR_clear_error(); + + /* look at context options in the stream and set appropriate verification flags */ + if (GET_VER_OPT(""verify_peer"") && zval_is_true(*val)) { + + /* turn on verification callback */ + SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, verify_callback); + + /* CA stuff */ + GET_VER_OPT_STRING(""cafile"", cafile); + GET_VER_OPT_STRING(""capath"", capath); + + if (cafile || capath) { + if (!SSL_CTX_load_verify_locations(ctx, cafile, capath)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set verify locations `%s' `%s'"", cafile, capath); + return NULL; + } + } + + if (GET_VER_OPT(""verify_depth"")) { + convert_to_long_ex(val); + SSL_CTX_set_verify_depth(ctx, Z_LVAL_PP(val)); + } + } else { + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); + } + + /* callback for the passphrase (for localcert) */ + if (GET_VER_OPT(""passphrase"")) { + SSL_CTX_set_default_passwd_cb_userdata(ctx, stream); + SSL_CTX_set_default_passwd_cb(ctx, passwd_callback); + } + + GET_VER_OPT_STRING(""ciphers"", cipherlist); + if (!cipherlist) { + cipherlist = ""DEFAULT""; + } + if (SSL_CTX_set_cipher_list(ctx, cipherlist) != 1) { + return NULL; + } + + GET_VER_OPT_STRING(""local_cert"", certfile); + if (certfile) { + X509 *cert = NULL; + EVP_PKEY *key = NULL; + SSL *tmpssl; + char resolved_path_buff[MAXPATHLEN]; + const char * private_key = NULL; + + if (VCWD_REALPATH(certfile, resolved_path_buff)) { + /* a certificate to use for authentication */ + if (SSL_CTX_use_certificate_chain_file(ctx, resolved_path_buff) != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set local cert chain file `%s'; Check that your cafile/capath settings include details of your certificate and its issuer"", certfile); + return NULL; + } + GET_VER_OPT_STRING(""local_pk"", private_key); + + if (private_key) { + char resolved_path_buff_pk[MAXPATHLEN]; + if (VCWD_REALPATH(private_key, resolved_path_buff_pk)) { + if (SSL_CTX_use_PrivateKey_file(ctx, resolved_path_buff_pk, SSL_FILETYPE_PEM) != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set private key file `%s'"", resolved_path_buff_pk); + return NULL; + } + } + } else { + if (SSL_CTX_use_PrivateKey_file(ctx, resolved_path_buff, SSL_FILETYPE_PEM) != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to set private key file `%s'"", resolved_path_buff); + return NULL; + } + } + + tmpssl = SSL_new(ctx); + cert = SSL_get_certificate(tmpssl); + + if (cert) { + key = X509_get_pubkey(cert); + EVP_PKEY_copy_parameters(key, SSL_get_privatekey(tmpssl)); + EVP_PKEY_free(key); + } + SSL_free(tmpssl); + + if (!SSL_CTX_check_private_key(ctx)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Private key does not match certificate!""); + } + } + } + if (ok) { + SSL *ssl = SSL_new(ctx); + + if (ssl) { + /* map SSL => stream */ + SSL_set_ex_data(ssl, ssl_stream_data_index, stream); + } + return ssl; + } + + return NULL; +} +/* }}} */ +","@@ -644,18 +644,28 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */ + char * thestr; + long gmadjust = 0; + +- if (timestr->length < 13) { +- php_error_docref(NULL TSRMLS_CC, E_WARNING, ""extension author too lazy to parse %s correctly"", timestr->data); ++ if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, ""illegal ASN1 data type for timestamp""); + return (time_t)-1; + } + +- strbuf = estrdup((char *)timestr->data); ++ if (ASN1_STRING_length(timestr) != strlen(ASN1_STRING_data(timestr))) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, ""illegal length in timestamp""); ++ return (time_t)-1; ++ } ++ ++ if (ASN1_STRING_length(timestr) < 13) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); ++ return (time_t)-1; ++ } ++ ++ strbuf = estrdup((char *)ASN1_STRING_data(timestr)); + + memset(&thetime, 0, sizeof(thetime)); + + /* we work backwards so that we can use atoi more easily */ + +- thestr = strbuf + timestr->length - 3; ++ thestr = strbuf + ASN1_STRING_length(timestr) - 3; + + thetime.tm_sec = atoi(thestr); + *thestr = '\0';",894,1130,2048 +4170,"static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, + struct tcp_sacktag_state *state, + u32 start_seq, u32 end_seq, + int dup_sack) +{ + struct tcp_sock *tp = tcp_sk(sk); + struct sk_buff *prev; + int mss; + int pcount = 0; + int len; + int in_sack; + + if (!sk_can_gso(sk)) + goto fallback; + + /* Normally R but no L won't result in plain S */ + if (!dup_sack && + (TCP_SKB_CB(skb)->sacked & (TCPCB_LOST|TCPCB_SACKED_RETRANS)) == TCPCB_SACKED_RETRANS) + goto fallback; + if (!skb_can_shift(skb)) + goto fallback; + /* This frame is about to be dropped (was ACKed). */ + if (!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una)) + goto fallback; + + /* Can only happen with delayed DSACK + discard craziness */ + if (unlikely(skb == tcp_write_queue_head(sk))) + goto fallback; + prev = tcp_write_queue_prev(sk, skb); + + if ((TCP_SKB_CB(prev)->sacked & TCPCB_TAGBITS) != TCPCB_SACKED_ACKED) + goto fallback; + + in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq) && + !before(end_seq, TCP_SKB_CB(skb)->end_seq); + + if (in_sack) { + len = skb->len; + pcount = tcp_skb_pcount(skb); + mss = tcp_skb_seglen(skb); + + /* TODO: Fix DSACKs to not fragment already SACKed and we can + * drop this restriction as unnecessary + */ + if (mss != tcp_skb_seglen(prev)) + goto fallback; + } else { + if (!after(TCP_SKB_CB(skb)->end_seq, start_seq)) + goto noop; + /* CHECKME: This is non-MSS split case only?, this will + * cause skipped skbs due to advancing loop btw, original + * has that feature too + */ + if (tcp_skb_pcount(skb) <= 1) + goto noop; + + in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq); + if (!in_sack) { + /* TODO: head merge to next could be attempted here + * if (!after(TCP_SKB_CB(skb)->end_seq, end_seq)), + * though it might not be worth of the additional hassle + * + * ...we can probably just fallback to what was done + * previously. We could try merging non-SACKed ones + * as well but it probably isn't going to buy off + * because later SACKs might again split them, and + * it would make skb timestamp tracking considerably + * harder problem. + */ + goto fallback; + } + + len = end_seq - TCP_SKB_CB(skb)->seq; + BUG_ON(len < 0); + BUG_ON(len > skb->len); + + /* MSS boundaries should be honoured or else pcount will + * severely break even though it makes things bit trickier. + * Optimize common case to avoid most of the divides + */ + mss = tcp_skb_mss(skb); + + /* TODO: Fix DSACKs to not fragment already SACKed and we can + * drop this restriction as unnecessary + */ + if (mss != tcp_skb_seglen(prev)) + goto fallback; + + if (len == mss) { + pcount = 1; + } else if (len < mss) { + goto noop; + } else { + pcount = len / mss; + len = pcount * mss; + } + } + + if (!skb_shift(prev, skb, len)) + goto fallback; + if (!tcp_shifted_skb(sk, skb, state, pcount, len, mss, dup_sack)) + goto out; + + /* Hole filled allows collapsing with the next as well, this is very + * useful when hole on every nth skb pattern happens + */ + if (prev == tcp_write_queue_tail(sk)) + goto out; + skb = tcp_write_queue_next(sk, prev); + + if (!skb_can_shift(skb) || + (skb == tcp_send_head(sk)) || + ((TCP_SKB_CB(skb)->sacked & TCPCB_TAGBITS) != TCPCB_SACKED_ACKED) || + (mss != tcp_skb_seglen(skb))) + goto out; + + len = skb->len; + if (skb_shift(prev, skb, len)) { + pcount += tcp_skb_pcount(skb); + tcp_shifted_skb(sk, skb, state, tcp_skb_pcount(skb), len, mss, 0); + } + +out: + state->fack_count += pcount; + return prev; + +noop: + return skb; + +fallback: + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SACKSHIFTFALLBACK); + return NULL; +} +",0,"static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, + struct tcp_sacktag_state *state, + u32 start_seq, u32 end_seq, + int dup_sack) +{ + struct tcp_sock *tp = tcp_sk(sk); + struct sk_buff *prev; + int mss; + int pcount = 0; + int len; + int in_sack; + + if (!sk_can_gso(sk)) + goto fallback; + + /* Normally R but no L won't result in plain S */ + if (!dup_sack && + (TCP_SKB_CB(skb)->sacked & (TCPCB_LOST|TCPCB_SACKED_RETRANS)) == TCPCB_SACKED_RETRANS) + goto fallback; + if (!skb_can_shift(skb)) + goto fallback; + /* This frame is about to be dropped (was ACKed). */ + if (!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una)) + goto fallback; + + /* Can only happen with delayed DSACK + discard craziness */ + if (unlikely(skb == tcp_write_queue_head(sk))) + goto fallback; + prev = tcp_write_queue_prev(sk, skb); + + if ((TCP_SKB_CB(prev)->sacked & TCPCB_TAGBITS) != TCPCB_SACKED_ACKED) + goto fallback; + + in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq) && + !before(end_seq, TCP_SKB_CB(skb)->end_seq); + + if (in_sack) { + len = skb->len; + pcount = tcp_skb_pcount(skb); + mss = tcp_skb_seglen(skb); + + /* TODO: Fix DSACKs to not fragment already SACKed and we can + * drop this restriction as unnecessary + */ + if (mss != tcp_skb_seglen(prev)) + goto fallback; + } else { + if (!after(TCP_SKB_CB(skb)->end_seq, start_seq)) + goto noop; + /* CHECKME: This is non-MSS split case only?, this will + * cause skipped skbs due to advancing loop btw, original + * has that feature too + */ + if (tcp_skb_pcount(skb) <= 1) + goto noop; + + in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq); + if (!in_sack) { + /* TODO: head merge to next could be attempted here + * if (!after(TCP_SKB_CB(skb)->end_seq, end_seq)), + * though it might not be worth of the additional hassle + * + * ...we can probably just fallback to what was done + * previously. We could try merging non-SACKed ones + * as well but it probably isn't going to buy off + * because later SACKs might again split them, and + * it would make skb timestamp tracking considerably + * harder problem. + */ + goto fallback; + } + + len = end_seq - TCP_SKB_CB(skb)->seq; + BUG_ON(len < 0); + BUG_ON(len > skb->len); + + /* MSS boundaries should be honoured or else pcount will + * severely break even though it makes things bit trickier. + * Optimize common case to avoid most of the divides + */ + mss = tcp_skb_mss(skb); + + /* TODO: Fix DSACKs to not fragment already SACKed and we can + * drop this restriction as unnecessary + */ + if (mss != tcp_skb_seglen(prev)) + goto fallback; + + if (len == mss) { + pcount = 1; + } else if (len < mss) { + goto noop; + } else { + pcount = len / mss; + len = pcount * mss; + } + } + + if (!skb_shift(prev, skb, len)) + goto fallback; + if (!tcp_shifted_skb(sk, skb, state, pcount, len, mss, dup_sack)) + goto out; + + /* Hole filled allows collapsing with the next as well, this is very + * useful when hole on every nth skb pattern happens + */ + if (prev == tcp_write_queue_tail(sk)) + goto out; + skb = tcp_write_queue_next(sk, prev); + + if (!skb_can_shift(skb) || + (skb == tcp_send_head(sk)) || + ((TCP_SKB_CB(skb)->sacked & TCPCB_TAGBITS) != TCPCB_SACKED_ACKED) || + (mss != tcp_skb_seglen(skb))) + goto out; + + len = skb->len; + if (skb_shift(prev, skb, len)) { + pcount += tcp_skb_pcount(skb); + tcp_shifted_skb(sk, skb, state, tcp_skb_pcount(skb), len, mss, 0); + } + +out: + state->fack_count += pcount; + return prev; + +noop: + return skb; + +fallback: + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SACKSHIFTFALLBACK); + return NULL; +} +","@@ -5811,6 +5811,8 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, + goto discard; + + if (th->syn) { ++ if (th->fin) ++ goto discard; + if (icsk->icsk_af_ops->conn_request(sk, skb) < 0) + return 1; + ",1075,1311,2048 +8165,"SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) +{ + unsigned long a[AUDITSC_ARGS]; + unsigned long a0, a1; + int err; + unsigned int len; + + if (call < 1 || call > SYS_SENDMMSG) + return -EINVAL; + + len = nargs[call]; + if (len > sizeof(a)) + return -EINVAL; + + /* copy_from_user should be SMP safe. */ + if (copy_from_user(a, args, len)) + return -EFAULT; + + err = audit_socketcall(nargs[call] / sizeof(unsigned long), a); + if (err) + return err; + + a0 = a[0]; + a1 = a[1]; + + switch (call) { + case SYS_SOCKET: + err = __sys_socket(a0, a1, a[2]); + break; + case SYS_BIND: + err = __sys_bind(a0, (struct sockaddr __user *)a1, a[2]); + break; + case SYS_CONNECT: + err = __sys_connect(a0, (struct sockaddr __user *)a1, a[2]); + break; + case SYS_LISTEN: + err = __sys_listen(a0, a1); + break; + case SYS_ACCEPT: + err = __sys_accept4(a0, (struct sockaddr __user *)a1, + (int __user *)a[2], 0); + break; + case SYS_GETSOCKNAME: + err = + __sys_getsockname(a0, (struct sockaddr __user *)a1, + (int __user *)a[2]); + break; + case SYS_GETPEERNAME: + err = + __sys_getpeername(a0, (struct sockaddr __user *)a1, + (int __user *)a[2]); + break; + case SYS_SOCKETPAIR: + err = __sys_socketpair(a0, a1, a[2], (int __user *)a[3]); + break; + case SYS_SEND: + err = __sys_sendto(a0, (void __user *)a1, a[2], a[3], + NULL, 0); + break; + case SYS_SENDTO: + err = __sys_sendto(a0, (void __user *)a1, a[2], a[3], + (struct sockaddr __user *)a[4], a[5]); + break; + case SYS_RECV: + err = __sys_recvfrom(a0, (void __user *)a1, a[2], a[3], + NULL, NULL); + break; + case SYS_RECVFROM: + err = __sys_recvfrom(a0, (void __user *)a1, a[2], a[3], + (struct sockaddr __user *)a[4], + (int __user *)a[5]); + break; + case SYS_SHUTDOWN: + err = __sys_shutdown(a0, a1); + break; + case SYS_SETSOCKOPT: + err = __sys_setsockopt(a0, a1, a[2], (char __user *)a[3], + a[4]); + break; + case SYS_GETSOCKOPT: + err = + __sys_getsockopt(a0, a1, a[2], (char __user *)a[3], + (int __user *)a[4]); + break; + case SYS_SENDMSG: + err = __sys_sendmsg(a0, (struct user_msghdr __user *)a1, + a[2], true); + break; + case SYS_SENDMMSG: + err = __sys_sendmmsg(a0, (struct mmsghdr __user *)a1, a[2], + a[3], true); + break; + case SYS_RECVMSG: + err = __sys_recvmsg(a0, (struct user_msghdr __user *)a1, + a[2], true); + break; + case SYS_RECVMMSG: + err = do_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], + a[3], (struct timespec __user *)a[4]); + break; + case SYS_ACCEPT4: + err = __sys_accept4(a0, (struct sockaddr __user *)a1, + (int __user *)a[2], a[3]); + break; + default: + err = -EINVAL; + break; + } + return err; +} +",0,"SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) +{ + unsigned long a[AUDITSC_ARGS]; + unsigned long a0, a1; + int err; + unsigned int len; + + if (call < 1 || call > SYS_SENDMMSG) + return -EINVAL; + + len = nargs[call]; + if (len > sizeof(a)) + return -EINVAL; + + /* copy_from_user should be SMP safe. */ + if (copy_from_user(a, args, len)) + return -EFAULT; + + err = audit_socketcall(nargs[call] / sizeof(unsigned long), a); + if (err) + return err; + + a0 = a[0]; + a1 = a[1]; + + switch (call) { + case SYS_SOCKET: + err = __sys_socket(a0, a1, a[2]); + break; + case SYS_BIND: + err = __sys_bind(a0, (struct sockaddr __user *)a1, a[2]); + break; + case SYS_CONNECT: + err = __sys_connect(a0, (struct sockaddr __user *)a1, a[2]); + break; + case SYS_LISTEN: + err = __sys_listen(a0, a1); + break; + case SYS_ACCEPT: + err = __sys_accept4(a0, (struct sockaddr __user *)a1, + (int __user *)a[2], 0); + break; + case SYS_GETSOCKNAME: + err = + __sys_getsockname(a0, (struct sockaddr __user *)a1, + (int __user *)a[2]); + break; + case SYS_GETPEERNAME: + err = + __sys_getpeername(a0, (struct sockaddr __user *)a1, + (int __user *)a[2]); + break; + case SYS_SOCKETPAIR: + err = __sys_socketpair(a0, a1, a[2], (int __user *)a[3]); + break; + case SYS_SEND: + err = __sys_sendto(a0, (void __user *)a1, a[2], a[3], + NULL, 0); + break; + case SYS_SENDTO: + err = __sys_sendto(a0, (void __user *)a1, a[2], a[3], + (struct sockaddr __user *)a[4], a[5]); + break; + case SYS_RECV: + err = __sys_recvfrom(a0, (void __user *)a1, a[2], a[3], + NULL, NULL); + break; + case SYS_RECVFROM: + err = __sys_recvfrom(a0, (void __user *)a1, a[2], a[3], + (struct sockaddr __user *)a[4], + (int __user *)a[5]); + break; + case SYS_SHUTDOWN: + err = __sys_shutdown(a0, a1); + break; + case SYS_SETSOCKOPT: + err = __sys_setsockopt(a0, a1, a[2], (char __user *)a[3], + a[4]); + break; + case SYS_GETSOCKOPT: + err = + __sys_getsockopt(a0, a1, a[2], (char __user *)a[3], + (int __user *)a[4]); + break; + case SYS_SENDMSG: + err = __sys_sendmsg(a0, (struct user_msghdr __user *)a1, + a[2], true); + break; + case SYS_SENDMMSG: + err = __sys_sendmmsg(a0, (struct mmsghdr __user *)a1, a[2], + a[3], true); + break; + case SYS_RECVMSG: + err = __sys_recvmsg(a0, (struct user_msghdr __user *)a1, + a[2], true); + break; + case SYS_RECVMMSG: + err = do_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], + a[3], (struct timespec __user *)a[4]); + break; + case SYS_ACCEPT4: + err = __sys_accept4(a0, (struct sockaddr __user *)a1, + (int __user *)a[2], a[3]); + break; + default: + err = -EINVAL; + break; + } + return err; +} +","@@ -541,7 +541,10 @@ static int sockfs_setattr(struct dentry *dentry, struct iattr *iattr) + if (!err && (iattr->ia_valid & ATTR_UID)) { + struct socket *sock = SOCKET_I(d_inode(dentry)); + +- sock->sk->sk_uid = iattr->ia_uid; ++ if (sock->sk) ++ sock->sk->sk_uid = iattr->ia_uid; ++ else ++ err = -ENOENT; + } + + return err; +@@ -590,12 +593,16 @@ EXPORT_SYMBOL(sock_alloc); + * an inode not a file. + */ + +-void sock_release(struct socket *sock) ++static void __sock_release(struct socket *sock, struct inode *inode) + { + if (sock->ops) { + struct module *owner = sock->ops->owner; + ++ if (inode) ++ inode_lock(inode); + sock->ops->release(sock); ++ if (inode) ++ inode_unlock(inode); + sock->ops = NULL; + module_put(owner); + } +@@ -609,6 +616,11 @@ void sock_release(struct socket *sock) + } + sock->file = NULL; + } ++ ++void sock_release(struct socket *sock) ++{ ++ __sock_release(sock, NULL); ++} + EXPORT_SYMBOL(sock_release); + + void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags) +@@ -1171,7 +1183,7 @@ static int sock_mmap(struct file *file, struct vm_area_struct *vma) + + static int sock_close(struct inode *inode, struct file *filp) + { +- sock_release(SOCKET_I(inode)); ++ __sock_release(SOCKET_I(inode), inode); + return 0; + } + ",922,1158,2048 +6187,"int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, + AVStream *st, RMStream *rst, + unsigned int codec_data_size, const uint8_t *mime) +{ + unsigned int v; + int size; + int64_t codec_pos; + int ret; + + if (codec_data_size > INT_MAX) + return AVERROR_INVALIDDATA; + if (codec_data_size == 0) + return 0; + + avpriv_set_pts_info(st, 64, 1, 1000); + codec_pos = avio_tell(pb); + v = avio_rb32(pb); + + if (v == MKTAG(0xfd, 'a', 'r', '.')) { + /* ra type header */ + if (rm_read_audio_stream_info(s, pb, st, rst, 0)) + return -1; + } else if (v == MKBETAG('L', 'S', 'D', ':')) { + avio_seek(pb, -4, SEEK_CUR); + if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size)) < 0) + return ret; + + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = AV_RL32(st->codecpar->extradata); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); + } else if(mime && !strcmp(mime, ""logical-fileinfo"")){ + int stream_count, rule_count, property_count, i; + ff_free_stream(s, st); + if (avio_rb16(pb) != 0) { + av_log(s, AV_LOG_WARNING, ""Unsupported version\n""); + goto skip; + } + stream_count = avio_rb16(pb); + avio_skip(pb, 6*stream_count); + rule_count = avio_rb16(pb); + avio_skip(pb, 2*rule_count); + property_count = avio_rb16(pb); + for(i=0; imetadata, name, val, 0); + break; + default: avio_skip(pb, avio_rb16(pb)); + } + } + } else { + int fps; + if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) { + fail1: + av_log(s, AV_LOG_WARNING, ""Unsupported stream type %08x\n"", v); + goto skip; + } + st->codecpar->codec_tag = avio_rl32(pb); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); + av_log(s, AV_LOG_TRACE, ""%""PRIX32"" %X\n"", + st->codecpar->codec_tag, MKTAG('R', 'V', '2', '0')); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + goto fail1; + st->codecpar->width = avio_rb16(pb); + st->codecpar->height = avio_rb16(pb); + avio_skip(pb, 2); // looks like bits per sample + avio_skip(pb, 4); // always zero? + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; + fps = avio_rb32(pb); + + if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) + return ret; + + if (fps > 0) { + av_reduce(&st->avg_frame_rate.den, &st->avg_frame_rate.num, + 0x10000, fps, (1 << 30) - 1); +#if FF_API_R_FRAME_RATE + st->r_frame_rate = st->avg_frame_rate; +#endif + } else if (s->error_recognition & AV_EF_EXPLODE) { + av_log(s, AV_LOG_ERROR, ""Invalid framerate\n""); + return AVERROR_INVALIDDATA; + } + } + +skip: + /* skip codec info */ + size = avio_tell(pb) - codec_pos; + if (codec_data_size >= size) { + avio_skip(pb, codec_data_size - size); + } else { + av_log(s, AV_LOG_WARNING, ""codec_data_size %u < size %d\n"", codec_data_size, size); + } + + return 0; +} +",0,"int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, + AVStream *st, RMStream *rst, + unsigned int codec_data_size, const uint8_t *mime) +{ + unsigned int v; + int size; + int64_t codec_pos; + int ret; + + if (codec_data_size > INT_MAX) + return AVERROR_INVALIDDATA; + if (codec_data_size == 0) + return 0; + + avpriv_set_pts_info(st, 64, 1, 1000); + codec_pos = avio_tell(pb); + v = avio_rb32(pb); + + if (v == MKTAG(0xfd, 'a', 'r', '.')) { + /* ra type header */ + if (rm_read_audio_stream_info(s, pb, st, rst, 0)) + return -1; + } else if (v == MKBETAG('L', 'S', 'D', ':')) { + avio_seek(pb, -4, SEEK_CUR); + if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size)) < 0) + return ret; + + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = AV_RL32(st->codecpar->extradata); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); + } else if(mime && !strcmp(mime, ""logical-fileinfo"")){ + int stream_count, rule_count, property_count, i; + ff_free_stream(s, st); + if (avio_rb16(pb) != 0) { + av_log(s, AV_LOG_WARNING, ""Unsupported version\n""); + goto skip; + } + stream_count = avio_rb16(pb); + avio_skip(pb, 6*stream_count); + rule_count = avio_rb16(pb); + avio_skip(pb, 2*rule_count); + property_count = avio_rb16(pb); + for(i=0; imetadata, name, val, 0); + break; + default: avio_skip(pb, avio_rb16(pb)); + } + } + } else { + int fps; + if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) { + fail1: + av_log(s, AV_LOG_WARNING, ""Unsupported stream type %08x\n"", v); + goto skip; + } + st->codecpar->codec_tag = avio_rl32(pb); + st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags, + st->codecpar->codec_tag); + av_log(s, AV_LOG_TRACE, ""%""PRIX32"" %X\n"", + st->codecpar->codec_tag, MKTAG('R', 'V', '2', '0')); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + goto fail1; + st->codecpar->width = avio_rb16(pb); + st->codecpar->height = avio_rb16(pb); + avio_skip(pb, 2); // looks like bits per sample + avio_skip(pb, 4); // always zero? + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; + fps = avio_rb32(pb); + + if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) + return ret; + + if (fps > 0) { + av_reduce(&st->avg_frame_rate.den, &st->avg_frame_rate.num, + 0x10000, fps, (1 << 30) - 1); +#if FF_API_R_FRAME_RATE + st->r_frame_rate = st->avg_frame_rate; +#endif + } else if (s->error_recognition & AV_EF_EXPLODE) { + av_log(s, AV_LOG_ERROR, ""Invalid framerate\n""); + return AVERROR_INVALIDDATA; + } + } + +skip: + /* skip codec info */ + size = avio_tell(pb) - codec_pos; + if (codec_data_size >= size) { + avio_skip(pb, codec_data_size - size); + } else { + av_log(s, AV_LOG_WARNING, ""codec_data_size %u < size %d\n"", codec_data_size, size); + } + + return 0; +} +","@@ -1223,8 +1223,11 @@ static int ivr_read_header(AVFormatContext *s) + av_log(s, AV_LOG_DEBUG, ""%s = '%s'\n"", key, val); + } else if (type == 4) { + av_log(s, AV_LOG_DEBUG, ""%s = '0x"", key); +- for (j = 0; j < len; j++) ++ for (j = 0; j < len; j++) { ++ if (avio_feof(pb)) ++ return AVERROR_INVALIDDATA; + av_log(s, AV_LOG_DEBUG, ""%X"", avio_r8(pb)); ++ } + av_log(s, AV_LOG_DEBUG, ""'\n""); + } else if (len == 4 && type == 3 && !strncmp(key, ""StreamCount"", tlen)) { + nb_streams = value = avio_rb32(pb);",1129,1365,2048 +17915,"prep_reprocess_req(krb5_kdc_req *request, krb5_principal *krbtgt_princ) +{ + krb5_error_code retval = KRB5KRB_AP_ERR_BADMATCH; + char **realms, **cpp, *temp_buf=NULL; + krb5_data *comp1 = NULL, *comp2 = NULL; + char *comp1_str = NULL; + + /* By now we know that server principal name is unknown. + * If CANONICALIZE flag is set in the request + * If req is not U2U authn. req + * the requested server princ. has exactly two components + * either + * the name type is NT-SRV-HST + * or name type is NT-UNKNOWN and + * the 1st component is listed in conf file under host_based_services + * the 1st component is not in a list in conf under ""no_host_referral"" + * the 2d component looks like fully-qualified domain name (FQDN) + * If all of these conditions are satisfied - try mapping the FQDN and + * re-process the request as if client had asked for cross-realm TGT. + */ + if (isflagset(request->kdc_options, KDC_OPT_CANONICALIZE) && + !isflagset(request->kdc_options, KDC_OPT_ENC_TKT_IN_SKEY) && + krb5_princ_size(kdc_context, request->server) == 2) { + + comp1 = krb5_princ_component(kdc_context, request->server, 0); + comp2 = krb5_princ_component(kdc_context, request->server, 1); + + comp1_str = calloc(1,comp1->length+1); + if (!comp1_str) { + retval = ENOMEM; + goto cleanup; + } + strlcpy(comp1_str,comp1->data,comp1->length+1); + + if ((krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_HST || + krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_INST || + (krb5_princ_type(kdc_context, request->server) == KRB5_NT_UNKNOWN && + kdc_active_realm->realm_host_based_services != NULL && + (krb5_match_config_pattern(kdc_active_realm->realm_host_based_services, + comp1_str) == TRUE || + krb5_match_config_pattern(kdc_active_realm->realm_host_based_services, + KRB5_CONF_ASTERISK) == TRUE))) && + (kdc_active_realm->realm_no_host_referral == NULL || + (krb5_match_config_pattern(kdc_active_realm->realm_no_host_referral, + KRB5_CONF_ASTERISK) == FALSE && + krb5_match_config_pattern(kdc_active_realm->realm_no_host_referral, + comp1_str) == FALSE))) { + + if (memchr(comp2->data, '.', comp2->length) == NULL) + goto cleanup; + temp_buf = calloc(1, comp2->length+1); + if (!temp_buf) { + retval = ENOMEM; + goto cleanup; + } + strlcpy(temp_buf, comp2->data,comp2->length+1); + retval = krb5int_get_domain_realm_mapping(kdc_context, temp_buf, &realms); + free(temp_buf); + if (retval) { + /* no match found */ + kdc_err(kdc_context, retval, ""unable to find realm of host""); + goto cleanup; + } + if (realms == 0) { + retval = KRB5KRB_AP_ERR_BADMATCH; + goto cleanup; + } + /* Don't return a referral to the null realm or the service + * realm. */ + if (realms[0] == 0 || + data_eq_string(request->server->realm, realms[0])) { + free(realms[0]); + free(realms); + retval = KRB5KRB_AP_ERR_BADMATCH; + goto cleanup; + } + /* Modify request. + * Construct cross-realm tgt : krbtgt/REMOTE_REALM@LOCAL_REALM + * and use it as a principal in this req. + */ + retval = krb5_build_principal(kdc_context, krbtgt_princ, + (*request->server).realm.length, + (*request->server).realm.data, + ""krbtgt"", realms[0], (char *)0); + for (cpp = realms; *cpp; cpp++) + free(*cpp); + } + } +cleanup: + free(comp1_str); + + return retval; +} +",1,"prep_reprocess_req(krb5_kdc_req *request, krb5_principal *krbtgt_princ) +{ + krb5_error_code retval = KRB5KRB_AP_ERR_BADMATCH; + char **realms, **cpp, *temp_buf=NULL; + krb5_data *comp1 = NULL, *comp2 = NULL; + char *comp1_str = NULL; + + /* By now we know that server principal name is unknown. + * If CANONICALIZE flag is set in the request + * If req is not U2U authn. req + * the requested server princ. has exactly two components + * either + * the name type is NT-SRV-HST + * or name type is NT-UNKNOWN and + * the 1st component is listed in conf file under host_based_services + * the 1st component is not in a list in conf under ""no_host_referral"" + * the 2d component looks like fully-qualified domain name (FQDN) + * If all of these conditions are satisfied - try mapping the FQDN and + * re-process the request as if client had asked for cross-realm TGT. + */ + if (isflagset(request->kdc_options, KDC_OPT_CANONICALIZE) && + !isflagset(request->kdc_options, KDC_OPT_ENC_TKT_IN_SKEY) && + krb5_princ_size(kdc_context, request->server) == 2) { + + comp1 = krb5_princ_component(kdc_context, request->server, 0); + comp2 = krb5_princ_component(kdc_context, request->server, 1); + + comp1_str = calloc(1,comp1->length+1); + if (!comp1_str) { + retval = ENOMEM; + goto cleanup; + } + if (comp1->data != NULL) + memcpy(comp1_str, comp1->data, comp1->length); + + if ((krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_HST || + krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_INST || + (krb5_princ_type(kdc_context, request->server) == KRB5_NT_UNKNOWN && + kdc_active_realm->realm_host_based_services != NULL && + (krb5_match_config_pattern(kdc_active_realm->realm_host_based_services, + comp1_str) == TRUE || + krb5_match_config_pattern(kdc_active_realm->realm_host_based_services, + KRB5_CONF_ASTERISK) == TRUE))) && + (kdc_active_realm->realm_no_host_referral == NULL || + (krb5_match_config_pattern(kdc_active_realm->realm_no_host_referral, + KRB5_CONF_ASTERISK) == FALSE && + krb5_match_config_pattern(kdc_active_realm->realm_no_host_referral, + comp1_str) == FALSE))) { + + if (memchr(comp2->data, '.', comp2->length) == NULL) + goto cleanup; + temp_buf = calloc(1, comp2->length+1); + if (!temp_buf) { + retval = ENOMEM; + goto cleanup; + } + if (comp2->data != NULL) + memcpy(temp_buf, comp2->data, comp2->length); + retval = krb5int_get_domain_realm_mapping(kdc_context, temp_buf, &realms); + free(temp_buf); + if (retval) { + /* no match found */ + kdc_err(kdc_context, retval, ""unable to find realm of host""); + goto cleanup; + } + if (realms == 0) { + retval = KRB5KRB_AP_ERR_BADMATCH; + goto cleanup; + } + /* Don't return a referral to the null realm or the service + * realm. */ + if (realms[0] == 0 || + data_eq_string(request->server->realm, realms[0])) { + free(realms[0]); + free(realms); + retval = KRB5KRB_AP_ERR_BADMATCH; + goto cleanup; + } + /* Modify request. + * Construct cross-realm tgt : krbtgt/REMOTE_REALM@LOCAL_REALM + * and use it as a principal in this req. + */ + retval = krb5_build_principal(kdc_context, krbtgt_princ, + (*request->server).realm.length, + (*request->server).realm.data, + ""krbtgt"", realms[0], (char *)0); + for (cpp = realms; *cpp; cpp++) + free(*cpp); + } + } +cleanup: + free(comp1_str); + + return retval; +} +","@@ -1141,7 +1141,8 @@ prep_reprocess_req(krb5_kdc_req *request, krb5_principal *krbtgt_princ) + retval = ENOMEM; + goto cleanup; + } +- strlcpy(comp1_str,comp1->data,comp1->length+1); ++ if (comp1->data != NULL) ++ memcpy(comp1_str, comp1->data, comp1->length); + + if ((krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_HST || + krb5_princ_type(kdc_context, request->server) == KRB5_NT_SRV_INST || +@@ -1164,7 +1165,8 @@ prep_reprocess_req(krb5_kdc_req *request, krb5_principal *krbtgt_princ) + retval = ENOMEM; + goto cleanup; + } +- strlcpy(temp_buf, comp2->data,comp2->length+1); ++ if (comp2->data != NULL) ++ memcpy(temp_buf, comp2->data, comp2->length); + retval = krb5int_get_domain_realm_mapping(kdc_context, temp_buf, &realms); + free(temp_buf); + if (retval) {",1002,1238,2048 +18659,"bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitSlice( + const H264PPS* pps, + const H264SliceHeader* slice_hdr, + const H264Picture::Vector& ref_pic_list0, + const H264Picture::Vector& ref_pic_list1, + const scoped_refptr& pic, + const uint8_t* data, + size_t size) { + VASliceParameterBufferH264 slice_param; + memset(&slice_param, 0, sizeof(slice_param)); + + slice_param.slice_data_size = slice_hdr->nalu_size; + slice_param.slice_data_offset = 0; + slice_param.slice_data_flag = VA_SLICE_DATA_FLAG_ALL; + slice_param.slice_data_bit_offset = slice_hdr->header_bit_size; + +#define SHDRToSP(a) slice_param.a = slice_hdr->a + SHDRToSP(first_mb_in_slice); + slice_param.slice_type = slice_hdr->slice_type % 5; + SHDRToSP(direct_spatial_mv_pred_flag); + + SHDRToSP(num_ref_idx_l0_active_minus1); + SHDRToSP(num_ref_idx_l1_active_minus1); + SHDRToSP(cabac_init_idc); + SHDRToSP(slice_qp_delta); + SHDRToSP(disable_deblocking_filter_idc); + SHDRToSP(slice_alpha_c0_offset_div2); + SHDRToSP(slice_beta_offset_div2); + + if (((slice_hdr->IsPSlice() || slice_hdr->IsSPSlice()) && + pps->weighted_pred_flag) || + (slice_hdr->IsBSlice() && pps->weighted_bipred_idc == 1)) { + SHDRToSP(luma_log2_weight_denom); + SHDRToSP(chroma_log2_weight_denom); + + SHDRToSP(luma_weight_l0_flag); + SHDRToSP(luma_weight_l1_flag); + + SHDRToSP(chroma_weight_l0_flag); + SHDRToSP(chroma_weight_l1_flag); + + for (int i = 0; i <= slice_param.num_ref_idx_l0_active_minus1; ++i) { + slice_param.luma_weight_l0[i] = + slice_hdr->pred_weight_table_l0.luma_weight[i]; + slice_param.luma_offset_l0[i] = + slice_hdr->pred_weight_table_l0.luma_offset[i]; + + for (int j = 0; j < 2; ++j) { + slice_param.chroma_weight_l0[i][j] = + slice_hdr->pred_weight_table_l0.chroma_weight[i][j]; + slice_param.chroma_offset_l0[i][j] = + slice_hdr->pred_weight_table_l0.chroma_offset[i][j]; + } + } + + if (slice_hdr->IsBSlice()) { + for (int i = 0; i <= slice_param.num_ref_idx_l1_active_minus1; ++i) { + slice_param.luma_weight_l1[i] = + slice_hdr->pred_weight_table_l1.luma_weight[i]; + slice_param.luma_offset_l1[i] = + slice_hdr->pred_weight_table_l1.luma_offset[i]; + + for (int j = 0; j < 2; ++j) { + slice_param.chroma_weight_l1[i][j] = + slice_hdr->pred_weight_table_l1.chroma_weight[i][j]; + slice_param.chroma_offset_l1[i][j] = + slice_hdr->pred_weight_table_l1.chroma_offset[i][j]; + } + } + } + } + + static_assert( + arraysize(slice_param.RefPicList0) == arraysize(slice_param.RefPicList1), + ""Invalid RefPicList sizes""); + + for (size_t i = 0; i < arraysize(slice_param.RefPicList0); ++i) { + InitVAPicture(&slice_param.RefPicList0[i]); + InitVAPicture(&slice_param.RefPicList1[i]); + } + + for (size_t i = 0; + i < ref_pic_list0.size() && i < arraysize(slice_param.RefPicList0); + ++i) { + if (ref_pic_list0[i]) + FillVAPicture(&slice_param.RefPicList0[i], ref_pic_list0[i]); + } + for (size_t i = 0; + i < ref_pic_list1.size() && i < arraysize(slice_param.RefPicList1); + ++i) { + if (ref_pic_list1[i]) + FillVAPicture(&slice_param.RefPicList1[i], ref_pic_list1[i]); + } + + if (!vaapi_wrapper_->SubmitBuffer(VASliceParameterBufferType, + sizeof(slice_param), &slice_param)) + return false; + + void* non_const_ptr = const_cast(data); + return vaapi_wrapper_->SubmitBuffer(VASliceDataBufferType, size, + non_const_ptr); +} +",1,"bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitSlice( + const H264PPS* pps, + const H264SliceHeader* slice_hdr, + const H264Picture::Vector& ref_pic_list0, + const H264Picture::Vector& ref_pic_list1, + const scoped_refptr& pic, + const uint8_t* data, + size_t size) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VASliceParameterBufferH264 slice_param; + memset(&slice_param, 0, sizeof(slice_param)); + + slice_param.slice_data_size = slice_hdr->nalu_size; + slice_param.slice_data_offset = 0; + slice_param.slice_data_flag = VA_SLICE_DATA_FLAG_ALL; + slice_param.slice_data_bit_offset = slice_hdr->header_bit_size; + +#define SHDRToSP(a) slice_param.a = slice_hdr->a + SHDRToSP(first_mb_in_slice); + slice_param.slice_type = slice_hdr->slice_type % 5; + SHDRToSP(direct_spatial_mv_pred_flag); + + SHDRToSP(num_ref_idx_l0_active_minus1); + SHDRToSP(num_ref_idx_l1_active_minus1); + SHDRToSP(cabac_init_idc); + SHDRToSP(slice_qp_delta); + SHDRToSP(disable_deblocking_filter_idc); + SHDRToSP(slice_alpha_c0_offset_div2); + SHDRToSP(slice_beta_offset_div2); + + if (((slice_hdr->IsPSlice() || slice_hdr->IsSPSlice()) && + pps->weighted_pred_flag) || + (slice_hdr->IsBSlice() && pps->weighted_bipred_idc == 1)) { + SHDRToSP(luma_log2_weight_denom); + SHDRToSP(chroma_log2_weight_denom); + + SHDRToSP(luma_weight_l0_flag); + SHDRToSP(luma_weight_l1_flag); + + SHDRToSP(chroma_weight_l0_flag); + SHDRToSP(chroma_weight_l1_flag); + + for (int i = 0; i <= slice_param.num_ref_idx_l0_active_minus1; ++i) { + slice_param.luma_weight_l0[i] = + slice_hdr->pred_weight_table_l0.luma_weight[i]; + slice_param.luma_offset_l0[i] = + slice_hdr->pred_weight_table_l0.luma_offset[i]; + + for (int j = 0; j < 2; ++j) { + slice_param.chroma_weight_l0[i][j] = + slice_hdr->pred_weight_table_l0.chroma_weight[i][j]; + slice_param.chroma_offset_l0[i][j] = + slice_hdr->pred_weight_table_l0.chroma_offset[i][j]; + } + } + + if (slice_hdr->IsBSlice()) { + for (int i = 0; i <= slice_param.num_ref_idx_l1_active_minus1; ++i) { + slice_param.luma_weight_l1[i] = + slice_hdr->pred_weight_table_l1.luma_weight[i]; + slice_param.luma_offset_l1[i] = + slice_hdr->pred_weight_table_l1.luma_offset[i]; + + for (int j = 0; j < 2; ++j) { + slice_param.chroma_weight_l1[i][j] = + slice_hdr->pred_weight_table_l1.chroma_weight[i][j]; + slice_param.chroma_offset_l1[i][j] = + slice_hdr->pred_weight_table_l1.chroma_offset[i][j]; + } + } + } + } + + static_assert( + arraysize(slice_param.RefPicList0) == arraysize(slice_param.RefPicList1), + ""Invalid RefPicList sizes""); + + for (size_t i = 0; i < arraysize(slice_param.RefPicList0); ++i) { + InitVAPicture(&slice_param.RefPicList0[i]); + InitVAPicture(&slice_param.RefPicList1[i]); + } + + for (size_t i = 0; + i < ref_pic_list0.size() && i < arraysize(slice_param.RefPicList0); + ++i) { + if (ref_pic_list0[i]) + FillVAPicture(&slice_param.RefPicList0[i], ref_pic_list0[i]); + } + for (size_t i = 0; + i < ref_pic_list1.size() && i < arraysize(slice_param.RefPicList1); + ++i) { + if (ref_pic_list1[i]) + FillVAPicture(&slice_param.RefPicList1[i], ref_pic_list1[i]); + } + + if (!vaapi_wrapper_->SubmitBuffer(VASliceParameterBufferType, + sizeof(slice_param), &slice_param)) + return false; + + void* non_const_ptr = const_cast(data); + return vaapi_wrapper_->SubmitBuffer(VASliceDataBufferType, size, + non_const_ptr); +} +","@@ -171,6 +171,8 @@ class VaapiVideoDecodeAccelerator::VaapiH264Accelerator + VaapiWrapper* vaapi_wrapper_; + VaapiVideoDecodeAccelerator* vaapi_dec_; + ++ SEQUENCE_CHECKER(sequence_checker_); ++ + DISALLOW_COPY_AND_ASSIGN(VaapiH264Accelerator); + }; + +@@ -218,6 +220,8 @@ class VaapiVideoDecodeAccelerator::VaapiVP8Accelerator + VaapiWrapper* vaapi_wrapper_; + VaapiVideoDecodeAccelerator* vaapi_dec_; + ++ SEQUENCE_CHECKER(sequence_checker_); ++ + DISALLOW_COPY_AND_ASSIGN(VaapiVP8Accelerator); + }; + +@@ -270,6 +274,8 @@ class VaapiVideoDecodeAccelerator::VaapiVP9Accelerator + VaapiWrapper* vaapi_wrapper_; + VaapiVideoDecodeAccelerator* vaapi_dec_; + ++ SEQUENCE_CHECKER(sequence_checker_); ++ + DISALLOW_COPY_AND_ASSIGN(VaapiVP9Accelerator); + }; + +@@ -1061,6 +1067,18 @@ void VaapiVideoDecodeAccelerator::Cleanup() { + client_ptr_factory_.reset(); + weak_this_factory_.InvalidateWeakPtrs(); + ++ decoder_thread_task_runner_->DeleteSoon(FROM_HERE, decoder_.release()); ++ if (h264_accelerator_) { ++ decoder_thread_task_runner_->DeleteSoon(FROM_HERE, ++ h264_accelerator_.release()); ++ } else if (vp8_accelerator_) { ++ decoder_thread_task_runner_->DeleteSoon(FROM_HERE, ++ vp8_accelerator_.release()); ++ } else if (vp9_accelerator_) { ++ decoder_thread_task_runner_->DeleteSoon(FROM_HERE, ++ vp9_accelerator_.release()); ++ } ++ + // Signal all potential waiters on the decoder_thread_, let them early-exit, + // as we've just moved to the kDestroying state, and wait for all tasks + // to finish. +@@ -1144,12 +1162,16 @@ VaapiVideoDecodeAccelerator::VaapiH264Accelerator::VaapiH264Accelerator( + : vaapi_wrapper_(vaapi_wrapper), vaapi_dec_(vaapi_dec) { + DCHECK(vaapi_wrapper_); + DCHECK(vaapi_dec_); ++ DETACH_FROM_SEQUENCE(sequence_checker_); + } + +-VaapiVideoDecodeAccelerator::VaapiH264Accelerator::~VaapiH264Accelerator() {} ++VaapiVideoDecodeAccelerator::VaapiH264Accelerator::~VaapiH264Accelerator() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); ++} + + scoped_refptr + VaapiVideoDecodeAccelerator::VaapiH264Accelerator::CreateH264Picture() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr va_surface = vaapi_dec_->CreateSurface(); + if (!va_surface) + return nullptr; +@@ -1172,6 +1194,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitFrameMetadata( + const H264Picture::Vector& ref_pic_listb0, + const H264Picture::Vector& ref_pic_listb1, + const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VAPictureParameterBufferH264 pic_param; + memset(&pic_param, 0, sizeof(pic_param)); + +@@ -1286,6 +1309,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitSlice( + const scoped_refptr& pic, + const uint8_t* data, + size_t size) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VASliceParameterBufferH264 slice_param; + memset(&slice_param, 0, sizeof(slice_param)); + +@@ -1387,6 +1411,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitSlice( + bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitDecode( + const scoped_refptr& pic) { + VLOGF(4) << ""Decoding POC "" << pic->pic_order_cnt; ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr dec_surface = + H264PictureToVaapiDecodeSurface(pic); + +@@ -1395,6 +1420,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitDecode( + + bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::OutputPicture( + const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr dec_surface = + H264PictureToVaapiDecodeSurface(pic); + dec_surface->set_visible_rect(pic->visible_rect); +@@ -1404,12 +1430,14 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::OutputPicture( + } + + void VaapiVideoDecodeAccelerator::VaapiH264Accelerator::Reset() { ++ DETACH_FROM_SEQUENCE(sequence_checker_); + vaapi_wrapper_->DestroyPendingBuffers(); + } + + scoped_refptr + VaapiVideoDecodeAccelerator::VaapiH264Accelerator:: + H264PictureToVaapiDecodeSurface(const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VaapiH264Picture* vaapi_pic = pic->AsVaapiH264Picture(); + CHECK(vaapi_pic); + return vaapi_pic->dec_surface(); +@@ -1418,6 +1446,7 @@ VaapiVideoDecodeAccelerator::VaapiH264Accelerator:: + void VaapiVideoDecodeAccelerator::VaapiH264Accelerator::FillVAPicture( + VAPictureH264* va_pic, + scoped_refptr pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VASurfaceID va_surface_id = VA_INVALID_SURFACE; + + if (!pic->nonexisting) { +@@ -1454,6 +1483,7 @@ int VaapiVideoDecodeAccelerator::VaapiH264Accelerator::FillVARefFramesFromDPB( + const H264DPB& dpb, + VAPictureH264* va_pics, + int num_pics) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + H264Picture::Vector::const_reverse_iterator rit; + int i; + +@@ -1474,12 +1504,16 @@ VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::VaapiVP8Accelerator( + : vaapi_wrapper_(vaapi_wrapper), vaapi_dec_(vaapi_dec) { + DCHECK(vaapi_wrapper_); + DCHECK(vaapi_dec_); ++ DETACH_FROM_SEQUENCE(sequence_checker_); + } + +-VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::~VaapiVP8Accelerator() {} ++VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::~VaapiVP8Accelerator() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); ++} + + scoped_refptr + VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::CreateVP8Picture() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr va_surface = vaapi_dec_->CreateSurface(); + if (!va_surface) + return nullptr; +@@ -1500,6 +1534,7 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::SubmitDecode( + const scoped_refptr& last_frame, + const scoped_refptr& golden_frame, + const scoped_refptr& alt_frame) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VAIQMatrixBufferVP8 iq_matrix_buf; + memset(&iq_matrix_buf, 0, sizeof(VAIQMatrixBufferVP8)); + +@@ -1682,6 +1717,7 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::SubmitDecode( + + bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::OutputPicture( + const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr dec_surface = + VP8PictureToVaapiDecodeSurface(pic); + dec_surface->set_visible_rect(pic->visible_rect); +@@ -1692,6 +1728,7 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::OutputPicture( + scoped_refptr + VaapiVideoDecodeAccelerator::VaapiVP8Accelerator:: + VP8PictureToVaapiDecodeSurface(const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VaapiVP8Picture* vaapi_pic = pic->AsVaapiVP8Picture(); + CHECK(vaapi_pic); + return vaapi_pic->dec_surface(); +@@ -1703,12 +1740,16 @@ VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::VaapiVP9Accelerator( + : vaapi_wrapper_(vaapi_wrapper), vaapi_dec_(vaapi_dec) { + DCHECK(vaapi_wrapper_); + DCHECK(vaapi_dec_); ++ DETACH_FROM_SEQUENCE(sequence_checker_); + } + +-VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::~VaapiVP9Accelerator() {} ++VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::~VaapiVP9Accelerator() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); ++} + + scoped_refptr + VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::CreateVP9Picture() { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr va_surface = vaapi_dec_->CreateSurface(); + if (!va_surface) + return nullptr; +@@ -1722,6 +1763,7 @@ bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::SubmitDecode( + const Vp9LoopFilterParams& lf, + const std::vector>& ref_pictures, + const base::Closure& done_cb) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + // |done_cb| should be null as we return false from IsFrameContextRequired(). + DCHECK(done_cb.is_null()); + +@@ -1844,6 +1886,7 @@ bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::SubmitDecode( + + bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::OutputPicture( + const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + scoped_refptr dec_surface = + VP9PictureToVaapiDecodeSurface(pic); + dec_surface->set_visible_rect(pic->visible_rect); +@@ -1854,13 +1897,15 @@ bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::OutputPicture( + bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::GetFrameContext( + const scoped_refptr& pic, + Vp9FrameContext* frame_ctx) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + NOTIMPLEMENTED() << ""Frame context update not supported""; + return false; + } + + scoped_refptr + VaapiVideoDecodeAccelerator::VaapiVP9Accelerator:: + VP9PictureToVaapiDecodeSurface(const scoped_refptr& pic) { ++ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + VaapiVP9Picture* vaapi_pic = pic->AsVaapiVP9Picture(); + CHECK(vaapi_pic); + return vaapi_pic->dec_surface();",1061,1297,2048 +17118,"status_t AudioFlinger::EffectModule::configure() +{ + status_t status; + sp thread; + uint32_t size; + audio_channel_mask_t channelMask; + + if (mEffectInterface == NULL) { + status = NO_INIT; + goto exit; + } + + thread = mThread.promote(); + if (thread == 0) { + status = DEAD_OBJECT; + goto exit; + } + + channelMask = thread->channelMask(); + mConfig.outputCfg.channels = channelMask; + + if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) { + mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO; + } else { + mConfig.inputCfg.channels = channelMask; + if (channelMask == AUDIO_CHANNEL_OUT_MONO) { + mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; + mConfig.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; + ALOGV(""Overriding effect input and output as STEREO""); + } + } + + mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; + mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; + mConfig.inputCfg.samplingRate = thread->sampleRate(); + mConfig.outputCfg.samplingRate = mConfig.inputCfg.samplingRate; + mConfig.inputCfg.bufferProvider.cookie = NULL; + mConfig.inputCfg.bufferProvider.getBuffer = NULL; + mConfig.inputCfg.bufferProvider.releaseBuffer = NULL; + mConfig.outputCfg.bufferProvider.cookie = NULL; + mConfig.outputCfg.bufferProvider.getBuffer = NULL; + mConfig.outputCfg.bufferProvider.releaseBuffer = NULL; + mConfig.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; + if (mConfig.inputCfg.buffer.raw != mConfig.outputCfg.buffer.raw) { + mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; + } else { + mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_WRITE; + } + mConfig.inputCfg.mask = EFFECT_CONFIG_ALL; + mConfig.outputCfg.mask = EFFECT_CONFIG_ALL; + mConfig.inputCfg.buffer.frameCount = thread->frameCount(); + mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount; + + ALOGV(""configure() %p thread %p buffer %p framecount %zu"", + this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount); + + status_t cmdStatus; + size = sizeof(int); + status = (*mEffectInterface)->command(mEffectInterface, + EFFECT_CMD_SET_CONFIG, + sizeof(effect_config_t), + &mConfig, + &size, + &cmdStatus); + if (status == 0) { + status = cmdStatus; + } + + if (status == 0 && + (memcmp(&mDescriptor.type, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0)) { + uint32_t buf32[sizeof(effect_param_t) / sizeof(uint32_t) + 2]; + effect_param_t *p = (effect_param_t *)buf32; + + p->psize = sizeof(uint32_t); + p->vsize = sizeof(uint32_t); + size = sizeof(int); + *(int32_t *)p->data = VISUALIZER_PARAM_LATENCY; + + uint32_t latency = 0; + PlaybackThread *pbt = thread->mAudioFlinger->checkPlaybackThread_l(thread->mId); + if (pbt != NULL) { + latency = pbt->latency_l(); + } + + *((int32_t *)p->data + 1)= latency; + (*mEffectInterface)->command(mEffectInterface, + EFFECT_CMD_SET_PARAM, + sizeof(effect_param_t) + 8, + &buf32, + &size, + &cmdStatus); + } + + mMaxDisableWaitCnt = (MAX_DISABLE_TIME_MS * mConfig.outputCfg.samplingRate) / + (1000 * mConfig.outputCfg.buffer.frameCount); + +exit: + mStatus = status; + return status; +} +",0,"status_t AudioFlinger::EffectModule::configure() +{ + status_t status; + sp thread; + uint32_t size; + audio_channel_mask_t channelMask; + + if (mEffectInterface == NULL) { + status = NO_INIT; + goto exit; + } + + thread = mThread.promote(); + if (thread == 0) { + status = DEAD_OBJECT; + goto exit; + } + + channelMask = thread->channelMask(); + mConfig.outputCfg.channels = channelMask; + + if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) { + mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO; + } else { + mConfig.inputCfg.channels = channelMask; + if (channelMask == AUDIO_CHANNEL_OUT_MONO) { + mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; + mConfig.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; + ALOGV(""Overriding effect input and output as STEREO""); + } + } + + mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; + mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; + mConfig.inputCfg.samplingRate = thread->sampleRate(); + mConfig.outputCfg.samplingRate = mConfig.inputCfg.samplingRate; + mConfig.inputCfg.bufferProvider.cookie = NULL; + mConfig.inputCfg.bufferProvider.getBuffer = NULL; + mConfig.inputCfg.bufferProvider.releaseBuffer = NULL; + mConfig.outputCfg.bufferProvider.cookie = NULL; + mConfig.outputCfg.bufferProvider.getBuffer = NULL; + mConfig.outputCfg.bufferProvider.releaseBuffer = NULL; + mConfig.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; + if (mConfig.inputCfg.buffer.raw != mConfig.outputCfg.buffer.raw) { + mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; + } else { + mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_WRITE; + } + mConfig.inputCfg.mask = EFFECT_CONFIG_ALL; + mConfig.outputCfg.mask = EFFECT_CONFIG_ALL; + mConfig.inputCfg.buffer.frameCount = thread->frameCount(); + mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount; + + ALOGV(""configure() %p thread %p buffer %p framecount %zu"", + this, thread.get(), mConfig.inputCfg.buffer.raw, mConfig.inputCfg.buffer.frameCount); + + status_t cmdStatus; + size = sizeof(int); + status = (*mEffectInterface)->command(mEffectInterface, + EFFECT_CMD_SET_CONFIG, + sizeof(effect_config_t), + &mConfig, + &size, + &cmdStatus); + if (status == 0) { + status = cmdStatus; + } + + if (status == 0 && + (memcmp(&mDescriptor.type, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0)) { + uint32_t buf32[sizeof(effect_param_t) / sizeof(uint32_t) + 2]; + effect_param_t *p = (effect_param_t *)buf32; + + p->psize = sizeof(uint32_t); + p->vsize = sizeof(uint32_t); + size = sizeof(int); + *(int32_t *)p->data = VISUALIZER_PARAM_LATENCY; + + uint32_t latency = 0; + PlaybackThread *pbt = thread->mAudioFlinger->checkPlaybackThread_l(thread->mId); + if (pbt != NULL) { + latency = pbt->latency_l(); + } + + *((int32_t *)p->data + 1)= latency; + (*mEffectInterface)->command(mEffectInterface, + EFFECT_CMD_SET_PARAM, + sizeof(effect_param_t) + 8, + &buf32, + &size, + &cmdStatus); + } + + mMaxDisableWaitCnt = (MAX_DISABLE_TIME_MS * mConfig.outputCfg.samplingRate) / + (1000 * mConfig.outputCfg.buffer.frameCount); + +exit: + mStatus = status; + return status; +} +","@@ -543,6 +543,13 @@ + + return NO_ERROR; + } + ++// round up delta valid if value and divisor are positive. ++template ++static T roundUpDelta(const T &value, const T &divisor) { ++ T remainder = value % divisor; ++ return remainder == 0 ? 0 : divisor - remainder; ++} ++ + status_t AudioFlinger::EffectModule::command(uint32_t cmdCode, + uint32_t cmdSize, + void *pCmdData, +@@ -564,6 +571,22 @@ + + android_errorWriteLog(0x534e4554, ""29251553""); + return -EINVAL; + } ++ if ((cmdCode == EFFECT_CMD_SET_PARAM ++ || cmdCode == EFFECT_CMD_SET_PARAM_DEFERRED) && // DEFERRED not generally used ++ (sizeof(effect_param_t) > cmdSize ++ || ((effect_param_t *)pCmdData)->psize > cmdSize ++ - sizeof(effect_param_t) ++ || ((effect_param_t *)pCmdData)->vsize > cmdSize ++ - sizeof(effect_param_t) ++ - ((effect_param_t *)pCmdData)->psize ++ || roundUpDelta(((effect_param_t *)pCmdData)->psize, (uint32_t)sizeof(int)) > ++ cmdSize ++ - sizeof(effect_param_t) ++ - ((effect_param_t *)pCmdData)->psize ++ - ((effect_param_t *)pCmdData)->vsize)) { ++ android_errorWriteLog(0x534e4554, ""30204301""); ++ return -EINVAL; ++ } + status_t status = (*mEffectInterface)->command(mEffectInterface, + cmdCode, + cmdSize, +",817,1053,2048 +438,"void Splash::scaleImageYuXd(SplashImageSource src, void *srcData, + SplashColorMode srcMode, int nComps, + GBool srcAlpha, int srcWidth, int srcHeight, + int scaledWidth, int scaledHeight, + SplashBitmap *dest) { + Guchar *lineBuf, *alphaLineBuf; + Guint pix[splashMaxColorComps]; + Guint alpha; + Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; + int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, xxa, d, d0, d1; + int i, j; + + yp = scaledHeight / srcHeight; + yq = scaledHeight % srcHeight; + + xp = srcWidth / scaledWidth; + xq = srcWidth % scaledWidth; + + lineBuf = (Guchar *)gmallocn(srcWidth, nComps); + if (srcAlpha) { + alphaLineBuf = (Guchar *)gmalloc(srcWidth); + } else { + alphaLineBuf = NULL; + } + + yt = 0; + + destPtr0 = dest->data; + destAlphaPtr0 = dest->alpha; + for (y = 0; y < srcHeight; ++y) { + + if ((yt += yq) >= srcHeight) { + yt -= srcHeight; + yStep = yp + 1; + } else { + yStep = yp; + } + + (*src)(srcData, lineBuf, alphaLineBuf); + + xt = 0; + d0 = (1 << 23) / xp; + d1 = (1 << 23) / (xp + 1); + + xx = xxa = 0; + for (x = 0; x < scaledWidth; ++x) { + + if ((xt += xq) >= scaledWidth) { + xt -= scaledWidth; + xStep = xp + 1; + d = d1; + } else { + xStep = xp; + d = d0; + } + + for (i = 0; i < nComps; ++i) { + pix[i] = 0; + } + for (i = 0; i < xStep; ++i) { + for (j = 0; j < nComps; ++j, ++xx) { + pix[j] += lineBuf[xx]; + } + } + for (i = 0; i < nComps; ++i) { + pix[i] = (pix[i] * d) >> 23; + } + + switch (srcMode) { + case splashModeMono1: // mono1 is not allowed + break; + case splashModeMono8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[0]; + } + break; + case splashModeRGB8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + } + break; + case splashModeXBGR8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)255; + } + break; + case splashModeBGR8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[3]; + } + break; + case splashModeDeviceN8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *destPtr++ = (Guchar)pix[cp]; + } + break; +#endif + } + + if (srcAlpha) { + alpha = 0; + for (i = 0; i < xStep; ++i, ++xxa) { + alpha += alphaLineBuf[xxa]; + } + alpha = (alpha * d) >> 23; + for (i = 0; i < yStep; ++i) { + destAlphaPtr = destAlphaPtr0 + i * scaledWidth + x; + *destAlphaPtr = (Guchar)alpha; + } + } + } + + destPtr0 += yStep * scaledWidth * nComps; + if (srcAlpha) { + destAlphaPtr0 += yStep * scaledWidth; + } + } + + gfree(alphaLineBuf); + gfree(lineBuf); +} +",0,"void Splash::scaleImageYuXd(SplashImageSource src, void *srcData, + SplashColorMode srcMode, int nComps, + GBool srcAlpha, int srcWidth, int srcHeight, + int scaledWidth, int scaledHeight, + SplashBitmap *dest) { + Guchar *lineBuf, *alphaLineBuf; + Guint pix[splashMaxColorComps]; + Guint alpha; + Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; + int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, xxa, d, d0, d1; + int i, j; + + yp = scaledHeight / srcHeight; + yq = scaledHeight % srcHeight; + + xp = srcWidth / scaledWidth; + xq = srcWidth % scaledWidth; + + lineBuf = (Guchar *)gmallocn(srcWidth, nComps); + if (srcAlpha) { + alphaLineBuf = (Guchar *)gmalloc(srcWidth); + } else { + alphaLineBuf = NULL; + } + + yt = 0; + + destPtr0 = dest->data; + destAlphaPtr0 = dest->alpha; + for (y = 0; y < srcHeight; ++y) { + + if ((yt += yq) >= srcHeight) { + yt -= srcHeight; + yStep = yp + 1; + } else { + yStep = yp; + } + + (*src)(srcData, lineBuf, alphaLineBuf); + + xt = 0; + d0 = (1 << 23) / xp; + d1 = (1 << 23) / (xp + 1); + + xx = xxa = 0; + for (x = 0; x < scaledWidth; ++x) { + + if ((xt += xq) >= scaledWidth) { + xt -= scaledWidth; + xStep = xp + 1; + d = d1; + } else { + xStep = xp; + d = d0; + } + + for (i = 0; i < nComps; ++i) { + pix[i] = 0; + } + for (i = 0; i < xStep; ++i) { + for (j = 0; j < nComps; ++j, ++xx) { + pix[j] += lineBuf[xx]; + } + } + for (i = 0; i < nComps; ++i) { + pix[i] = (pix[i] * d) >> 23; + } + + switch (srcMode) { + case splashModeMono1: // mono1 is not allowed + break; + case splashModeMono8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[0]; + } + break; + case splashModeRGB8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + } + break; + case splashModeXBGR8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)255; + } + break; + case splashModeBGR8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[3]; + } + break; + case splashModeDeviceN8: + for (i = 0; i < yStep; ++i) { + destPtr = destPtr0 + (i * scaledWidth + x) * nComps; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *destPtr++ = (Guchar)pix[cp]; + } + break; +#endif + } + + if (srcAlpha) { + alpha = 0; + for (i = 0; i < xStep; ++i, ++xxa) { + alpha += alphaLineBuf[xxa]; + } + alpha = (alpha * d) >> 23; + for (i = 0; i < yStep; ++i) { + destAlphaPtr = destAlphaPtr0 + i * scaledWidth + x; + *destAlphaPtr = (Guchar)alpha; + } + } + } + + destPtr0 += yStep * scaledWidth * nComps; + if (srcAlpha) { + destAlphaPtr0 += yStep * scaledWidth; + } + } + + gfree(alphaLineBuf); + gfree(lineBuf); +} +","@@ -2955,7 +2955,7 @@ void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); + if (scaledMask->data == NULL) { +- error(errInternal, -1, ""scaledMask->data is NULL in Splash::scaleMaskYuXu""); ++ error(errInternal, -1, ""scaledMask->data is NULL in Splash::arbitraryTransformMask""); + delete scaledMask; + return; + } +@@ -3461,11 +3461,15 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + + w = src->getWidth(); + h = src->getHeight(); ++ p = src->getDataPtr(); ++ if (p == NULL) { ++ error(errInternal, -1, ""src->getDataPtr() is NULL in Splash::blitMask""); ++ return; ++ } + if (vectorAntialias && clipRes != splashClipAllInside) { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); + drawAAPixelInit(); +- p = src->getDataPtr(); + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + pipe.shape = *p++; +@@ -3475,7 +3479,6 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + } else { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); +- p = src->getDataPtr(); + if (clipRes == splashClipAllInside) { + for (y = 0; y < h; ++y) { + pipeSetXY(&pipe, xDest, yDest + y);",1301,1537,2048 +6087,"cms_envelopeddata_verify(krb5_context context, + pkinit_plg_crypto_context plg_cryptoctx, + pkinit_req_crypto_context req_cryptoctx, + pkinit_identity_crypto_context id_cryptoctx, + krb5_preauthtype pa_type, + int require_crl_checking, + unsigned char *enveloped_data, + unsigned int enveloped_data_len, + unsigned char **data, + unsigned int *data_len) +{ + krb5_error_code retval = KRB5KDC_ERR_PREAUTH_FAILED; + PKCS7 *p7 = NULL; + BIO *out = NULL; + int i = 0; + unsigned int size = 0; + const unsigned char *p = enveloped_data; + unsigned int tmp_buf_len = 0, tmp_buf2_len = 0, vfy_buf_len = 0; + unsigned char *tmp_buf = NULL, *tmp_buf2 = NULL, *vfy_buf = NULL; + int msg_type = 0; + +#ifdef DEBUG_ASN1 + print_buffer_bin(enveloped_data, enveloped_data_len, + ""/tmp/client_envelopeddata""); +#endif + /* decode received PKCS7 message */ + if ((p7 = d2i_PKCS7(NULL, &p, (int)enveloped_data_len)) == NULL) { + retval = oerr(context, 0, _(""Failed to decode PKCS7"")); + goto cleanup; + } + + /* verify that the received message is PKCS7 EnvelopedData message */ + if (OBJ_obj2nid(p7->type) != NID_pkcs7_enveloped) { + pkiDebug(""Expected id-enveloped PKCS7 msg (received type = %d)\n"", + OBJ_obj2nid(p7->type)); + krb5_set_error_message(context, retval, ""wrong oid\n""); + goto cleanup; + } + + /* decrypt received PKCS7 message */ + out = BIO_new(BIO_s_mem()); + if (pkcs7_decrypt(context, id_cryptoctx, p7, out)) { + pkiDebug(""PKCS7 decryption successful\n""); + } else { + retval = oerr(context, 0, _(""Failed to decrypt PKCS7 message"")); + goto cleanup; + } + + /* transfer the decoded PKCS7 SignedData message into a separate buffer */ + for (;;) { + if ((tmp_buf = realloc(tmp_buf, size + 1024 * 10)) == NULL) + goto cleanup; + i = BIO_read(out, &(tmp_buf[size]), 1024 * 10); + if (i <= 0) + break; + else + size += i; + } + tmp_buf_len = size; + +#ifdef DEBUG_ASN1 + print_buffer_bin(tmp_buf, tmp_buf_len, ""/tmp/client_enc_keypack""); +#endif + /* verify PKCS7 SignedData message */ + switch (pa_type) { + case KRB5_PADATA_PK_AS_REP: + msg_type = CMS_ENVEL_SERVER; + + break; + case KRB5_PADATA_PK_AS_REP_OLD: + msg_type = CMS_SIGN_DRAFT9; + break; + default: + pkiDebug(""%s: unrecognized pa_type = %d\n"", __FUNCTION__, pa_type); + retval = KRB5KDC_ERR_PREAUTH_FAILED; + goto cleanup; + } + /* + * If this is the RFC style, wrap the signed data to make + * decoding easier in the verify routine. + * For draft9-compatible, we don't do anything because it + * is already wrapped. + */ + if (msg_type == CMS_ENVEL_SERVER) { + retval = wrap_signeddata(tmp_buf, tmp_buf_len, + &tmp_buf2, &tmp_buf2_len); + if (retval) { + pkiDebug(""failed to encode signeddata\n""); + goto cleanup; + } + vfy_buf = tmp_buf2; + vfy_buf_len = tmp_buf2_len; + + } else { + vfy_buf = tmp_buf; + vfy_buf_len = tmp_buf_len; + } + +#ifdef DEBUG_ASN1 + print_buffer_bin(vfy_buf, vfy_buf_len, ""/tmp/client_enc_keypack2""); +#endif + + retval = cms_signeddata_verify(context, plg_cryptoctx, req_cryptoctx, + id_cryptoctx, msg_type, + require_crl_checking, + vfy_buf, vfy_buf_len, + data, data_len, NULL, NULL, NULL); + + if (!retval) + pkiDebug(""PKCS7 Verification Success\n""); + else { + pkiDebug(""PKCS7 Verification Failure\n""); + goto cleanup; + } + + retval = 0; + +cleanup: + + if (p7 != NULL) + PKCS7_free(p7); + if (out != NULL) + BIO_free(out); + free(tmp_buf); + free(tmp_buf2); + + return retval; +} +",0,"cms_envelopeddata_verify(krb5_context context, + pkinit_plg_crypto_context plg_cryptoctx, + pkinit_req_crypto_context req_cryptoctx, + pkinit_identity_crypto_context id_cryptoctx, + krb5_preauthtype pa_type, + int require_crl_checking, + unsigned char *enveloped_data, + unsigned int enveloped_data_len, + unsigned char **data, + unsigned int *data_len) +{ + krb5_error_code retval = KRB5KDC_ERR_PREAUTH_FAILED; + PKCS7 *p7 = NULL; + BIO *out = NULL; + int i = 0; + unsigned int size = 0; + const unsigned char *p = enveloped_data; + unsigned int tmp_buf_len = 0, tmp_buf2_len = 0, vfy_buf_len = 0; + unsigned char *tmp_buf = NULL, *tmp_buf2 = NULL, *vfy_buf = NULL; + int msg_type = 0; + +#ifdef DEBUG_ASN1 + print_buffer_bin(enveloped_data, enveloped_data_len, + ""/tmp/client_envelopeddata""); +#endif + /* decode received PKCS7 message */ + if ((p7 = d2i_PKCS7(NULL, &p, (int)enveloped_data_len)) == NULL) { + retval = oerr(context, 0, _(""Failed to decode PKCS7"")); + goto cleanup; + } + + /* verify that the received message is PKCS7 EnvelopedData message */ + if (OBJ_obj2nid(p7->type) != NID_pkcs7_enveloped) { + pkiDebug(""Expected id-enveloped PKCS7 msg (received type = %d)\n"", + OBJ_obj2nid(p7->type)); + krb5_set_error_message(context, retval, ""wrong oid\n""); + goto cleanup; + } + + /* decrypt received PKCS7 message */ + out = BIO_new(BIO_s_mem()); + if (pkcs7_decrypt(context, id_cryptoctx, p7, out)) { + pkiDebug(""PKCS7 decryption successful\n""); + } else { + retval = oerr(context, 0, _(""Failed to decrypt PKCS7 message"")); + goto cleanup; + } + + /* transfer the decoded PKCS7 SignedData message into a separate buffer */ + for (;;) { + if ((tmp_buf = realloc(tmp_buf, size + 1024 * 10)) == NULL) + goto cleanup; + i = BIO_read(out, &(tmp_buf[size]), 1024 * 10); + if (i <= 0) + break; + else + size += i; + } + tmp_buf_len = size; + +#ifdef DEBUG_ASN1 + print_buffer_bin(tmp_buf, tmp_buf_len, ""/tmp/client_enc_keypack""); +#endif + /* verify PKCS7 SignedData message */ + switch (pa_type) { + case KRB5_PADATA_PK_AS_REP: + msg_type = CMS_ENVEL_SERVER; + + break; + case KRB5_PADATA_PK_AS_REP_OLD: + msg_type = CMS_SIGN_DRAFT9; + break; + default: + pkiDebug(""%s: unrecognized pa_type = %d\n"", __FUNCTION__, pa_type); + retval = KRB5KDC_ERR_PREAUTH_FAILED; + goto cleanup; + } + /* + * If this is the RFC style, wrap the signed data to make + * decoding easier in the verify routine. + * For draft9-compatible, we don't do anything because it + * is already wrapped. + */ + if (msg_type == CMS_ENVEL_SERVER) { + retval = wrap_signeddata(tmp_buf, tmp_buf_len, + &tmp_buf2, &tmp_buf2_len); + if (retval) { + pkiDebug(""failed to encode signeddata\n""); + goto cleanup; + } + vfy_buf = tmp_buf2; + vfy_buf_len = tmp_buf2_len; + + } else { + vfy_buf = tmp_buf; + vfy_buf_len = tmp_buf_len; + } + +#ifdef DEBUG_ASN1 + print_buffer_bin(vfy_buf, vfy_buf_len, ""/tmp/client_enc_keypack2""); +#endif + + retval = cms_signeddata_verify(context, plg_cryptoctx, req_cryptoctx, + id_cryptoctx, msg_type, + require_crl_checking, + vfy_buf, vfy_buf_len, + data, data_len, NULL, NULL, NULL); + + if (!retval) + pkiDebug(""PKCS7 Verification Success\n""); + else { + pkiDebug(""PKCS7 Verification Failure\n""); + goto cleanup; + } + + retval = 0; + +cleanup: + + if (p7 != NULL) + PKCS7_free(p7); + if (out != NULL) + BIO_free(out); + free(tmp_buf); + free(tmp_buf2); + + return retval; +} +","@@ -5002,33 +5002,29 @@ crypto_retrieve_X509_key_usage(krb5_context context, + return retval; + } + +-/* +- * Return a string format of an X509_NAME in buf where +- * size is an in/out parameter. On input it is the size +- * of the buffer, and on output it is the actual length +- * of the name. +- * If buf is NULL, returns the length req'd to hold name +- */ +-static char * +-X509_NAME_oneline_ex(X509_NAME * a, +- char *buf, +- unsigned int *size, +- unsigned long flag) ++static krb5_error_code ++rfc2253_name(X509_NAME *name, char **str_out) + { +- BIO *out = NULL; ++ BIO *b = NULL; ++ char *str; + +- out = BIO_new(BIO_s_mem ()); +- if (X509_NAME_print_ex(out, a, 0, flag) > 0) { +- if (buf != NULL && (*size) > (unsigned int) BIO_number_written(out)) { +- memset(buf, 0, *size); +- BIO_read(out, buf, (int) BIO_number_written(out)); +- } +- else { +- *size = BIO_number_written(out); +- } +- } +- BIO_free(out); +- return (buf); ++ *str_out = NULL; ++ b = BIO_new(BIO_s_mem()); ++ if (b == NULL) ++ return ENOMEM; ++ if (X509_NAME_print_ex(b, name, 0, XN_FLAG_SEP_COMMA_PLUS) < 0) ++ goto error; ++ str = calloc(BIO_number_written(b) + 1, 1); ++ if (str == NULL) ++ goto error; ++ BIO_read(b, str, BIO_number_written(b)); ++ BIO_free(b); ++ *str_out = str; ++ return 0; ++ ++error: ++ BIO_free(b); ++ return ENOMEM; + } + + /* +@@ -5094,32 +5090,19 @@ get_matching_data(krb5_context context, + pkinit_cert_matching_data *md = NULL; + krb5_principal *pkinit_sans = NULL, *upn_sans = NULL; + size_t i, j; +- char buf[DN_BUF_LEN]; +- unsigned int bufsize = sizeof(buf); + + *md_out = NULL; + + md = calloc(1, sizeof(*md)); + if (md == NULL) + goto cleanup; + +- /* Get the subject name (in rfc2253 format). */ +- X509_NAME_oneline_ex(X509_get_subject_name(cert), buf, &bufsize, +- XN_FLAG_SEP_COMMA_PLUS); +- md->subject_dn = strdup(buf); +- if (md->subject_dn == NULL) { +- ret = ENOMEM; ++ ret = rfc2253_name(X509_get_subject_name(cert), &md->subject_dn); ++ if (ret) + goto cleanup; +- } +- +- /* Get the issuer name (in rfc2253 format). */ +- X509_NAME_oneline_ex(X509_get_issuer_name(cert), buf, &bufsize, +- XN_FLAG_SEP_COMMA_PLUS); +- md->issuer_dn = strdup(buf); +- if (md->issuer_dn == NULL) { +- ret = ENOMEM; ++ ret = rfc2253_name(X509_get_issuer_name(cert), &md->issuer_dn); ++ if (ret) + goto cleanup; +- } + + /* Get the SAN data. */ + ret = crypto_retrieve_X509_sans(context, plg_cryptoctx, req_cryptoctx,",1041,1277,2048 +7033,"TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) +{ + register TIFFDirectory *td = &tif->tif_dir; + uint32 strip; + int whole_strip; + tmsize_t read_ahead = 0; + + /* + ** Establish what strip we are working from. + */ + if (row >= td->td_imagelength) { /* out of range */ + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + ""%lu: Row out of range, max %lu"", + (unsigned long) row, + (unsigned long) td->td_imagelength); + return (0); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + ""%lu: Sample out of range, max %lu"", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + return (0); + } + strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; + } else + strip = row / td->td_rowsperstrip; + + /* + * Do we want to treat this strip as one whole chunk or + * read it a few lines at a time? + */ +#if defined(CHUNKY_STRIP_READ_SUPPORT) + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + whole_strip = tif->tif_dir.td_stripbytecount[strip] < 10 + || isMapped(tif); +#else + whole_strip = 1; +#endif + + if( !whole_strip ) + { + read_ahead = tif->tif_scanlinesize * 16 + 5000; + } + + /* + * If we haven't loaded this strip, do so now, possibly + * only reading the first part. + */ + if (strip != tif->tif_curstrip) { /* different strip, refill */ + + if( whole_strip ) + { + if (!TIFFFillStrip(tif, strip)) + return (0); + } + else + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + } + + /* + ** If we already have some data loaded, do we need to read some more? + */ + else if( !whole_strip ) + { + if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead + && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < td->td_stripbytecount[strip] ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,0) ) + return 0; + } + } + + if (row < tif->tif_row) { + /* + * Moving backwards within the same strip: backup + * to the start and then decode forward (below). + * + * NB: If you're planning on lots of random access within a + * strip, it's better to just read and decode the entire + * strip, and then access the decoded data in a random fashion. + */ + + if( tif->tif_rawdataoff != 0 ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + else + { + if (!TIFFStartStrip(tif, strip)) + return (0); + } + } + + if (row != tif->tif_row) { + /* + * Seek forward to the desired row. + */ + + /* TODO: Will this really work with partial buffers? */ + + if (!(*tif->tif_seek)(tif, row - tif->tif_row)) + return (0); + tif->tif_row = row; + } + + return (1); +} +",0,"TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) +{ + register TIFFDirectory *td = &tif->tif_dir; + uint32 strip; + int whole_strip; + tmsize_t read_ahead = 0; + + /* + ** Establish what strip we are working from. + */ + if (row >= td->td_imagelength) { /* out of range */ + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + ""%lu: Row out of range, max %lu"", + (unsigned long) row, + (unsigned long) td->td_imagelength); + return (0); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + ""%lu: Sample out of range, max %lu"", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + return (0); + } + strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; + } else + strip = row / td->td_rowsperstrip; + + /* + * Do we want to treat this strip as one whole chunk or + * read it a few lines at a time? + */ +#if defined(CHUNKY_STRIP_READ_SUPPORT) + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; + whole_strip = tif->tif_dir.td_stripbytecount[strip] < 10 + || isMapped(tif); +#else + whole_strip = 1; +#endif + + if( !whole_strip ) + { + read_ahead = tif->tif_scanlinesize * 16 + 5000; + } + + /* + * If we haven't loaded this strip, do so now, possibly + * only reading the first part. + */ + if (strip != tif->tif_curstrip) { /* different strip, refill */ + + if( whole_strip ) + { + if (!TIFFFillStrip(tif, strip)) + return (0); + } + else + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + } + + /* + ** If we already have some data loaded, do we need to read some more? + */ + else if( !whole_strip ) + { + if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead + && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < td->td_stripbytecount[strip] ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,0) ) + return 0; + } + } + + if (row < tif->tif_row) { + /* + * Moving backwards within the same strip: backup + * to the start and then decode forward (below). + * + * NB: If you're planning on lots of random access within a + * strip, it's better to just read and decode the entire + * strip, and then access the decoded data in a random fashion. + */ + + if( tif->tif_rawdataoff != 0 ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + else + { + if (!TIFFStartStrip(tif, strip)) + return (0); + } + } + + if (row != tif->tif_row) { + /* + * Seek forward to the desired row. + */ + + /* TODO: Will this really work with partial buffers? */ + + if (!(*tif->tif_seek)(tif, row - tif->tif_row)) + return (0); + tif->tif_row = row; + } + + return (1); +} +","@@ -346,7 +346,7 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) + rowsperstrip=td->td_rowsperstrip; + if (rowsperstrip>td->td_imagelength) + rowsperstrip=td->td_imagelength; +- stripsperplane=((td->td_imagelength+rowsperstrip-1)/rowsperstrip); ++ stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); + stripinplane=(strip%stripsperplane); + plane=(uint16)(strip/stripsperplane); + rows=td->td_imagelength-stripinplane*rowsperstrip;",894,1130,2048 +127,"void JBIG2Stream::readSegments() { + Guint segNum, segFlags, segType, page, segLength; + Guint refFlags, nRefSegs; + Guint *refSegs; + int segDataPos; + int c1, c2, c3; + Guint i; + + while (readULong(&segNum)) { + + if (!readUByte(&segFlags)) { + goto eofError1; + } + segType = segFlags & 0x3f; + + if (!readUByte(&refFlags)) { + goto eofError1; + } + nRefSegs = refFlags >> 5; + if (nRefSegs == 7) { + if ((c1 = curStr->getChar()) == EOF || + (c2 = curStr->getChar()) == EOF || + (c3 = curStr->getChar()) == EOF) { + goto eofError1; + } + refFlags = (refFlags << 24) | (c1 << 16) | (c2 << 8) | c3; + nRefSegs = refFlags & 0x1fffffff; + for (i = 0; i < (nRefSegs + 9) >> 3; ++i) { + c1 = curStr->getChar(); + } + } + + refSegs = (Guint *)gmallocn(nRefSegs, sizeof(Guint)); + if (segNum <= 256) { + for (i = 0; i < nRefSegs; ++i) { + if (!readUByte(&refSegs[i])) { + goto eofError2; + } + } + } else if (segNum <= 65536) { + for (i = 0; i < nRefSegs; ++i) { + if (!readUWord(&refSegs[i])) { + goto eofError2; + } + } + } else { + for (i = 0; i < nRefSegs; ++i) { + if (!readULong(&refSegs[i])) { + goto eofError2; + } + } + } + + if (segFlags & 0x40) { + if (!readULong(&page)) { + goto eofError2; + } + } else { + if (!readUByte(&page)) { + goto eofError2; + } + } + + if (!readULong(&segLength)) { + goto eofError2; + } + + segDataPos = getPos(); + + switch (segType) { + case 0: + if (!readSymbolDictSeg(segNum, segLength, refSegs, nRefSegs)) { + goto syntaxError; + } + break; + case 4: + readTextRegionSeg(segNum, gFalse, gFalse, segLength, refSegs, nRefSegs); + break; + case 6: + readTextRegionSeg(segNum, gTrue, gFalse, segLength, refSegs, nRefSegs); + break; + case 7: + readTextRegionSeg(segNum, gTrue, gTrue, segLength, refSegs, nRefSegs); + break; + case 16: + readPatternDictSeg(segNum, segLength); + break; + case 20: + readHalftoneRegionSeg(segNum, gFalse, gFalse, segLength, + refSegs, nRefSegs); + break; + case 22: + readHalftoneRegionSeg(segNum, gTrue, gFalse, segLength, + refSegs, nRefSegs); + break; + case 23: + readHalftoneRegionSeg(segNum, gTrue, gTrue, segLength, + refSegs, nRefSegs); + break; + case 36: + readGenericRegionSeg(segNum, gFalse, gFalse, segLength); + break; + case 38: + readGenericRegionSeg(segNum, gTrue, gFalse, segLength); + break; + case 39: + readGenericRegionSeg(segNum, gTrue, gTrue, segLength); + break; + case 40: + readGenericRefinementRegionSeg(segNum, gFalse, gFalse, segLength, + refSegs, nRefSegs); + break; + case 42: + readGenericRefinementRegionSeg(segNum, gTrue, gFalse, segLength, + refSegs, nRefSegs); + break; + case 43: + readGenericRefinementRegionSeg(segNum, gTrue, gTrue, segLength, + refSegs, nRefSegs); + break; + case 48: + readPageInfoSeg(segLength); + break; + case 50: + readEndOfStripeSeg(segLength); + break; + case 52: + readProfilesSeg(segLength); + break; + case 53: + readCodeTableSeg(segNum, segLength); + break; + case 62: + readExtensionSeg(segLength); + break; + default: + error(getPos(), ""Unknown segment type in JBIG2 stream""); + for (i = 0; i < segLength; ++i) { + if ((c1 = curStr->getChar()) == EOF) { + goto eofError2; + } + } + break; + } + + + if (segLength != 0xffffffff) { + + int segExtraBytes = segDataPos + segLength - getPos(); + if (segExtraBytes > 0) { + + + + error(getPos(), ""%d extraneous byte%s after segment"", + segExtraBytes, (segExtraBytes > 1) ? ""s"" : """"); + + + int trash; + for (int i = segExtraBytes; i > 0; i--) { + readByte(&trash); + } + + } else if (segExtraBytes < 0) { + + + error(getPos(), ""Previous segment handler read too many bytes""); + + } + + } + + gfree(refSegs); + } + + return; + + syntaxError: + gfree(refSegs); + return; + + eofError2: + gfree(refSegs); + eofError1: + error(getPos(), ""Unexpected EOF in JBIG2 stream""); +} +",0,"void JBIG2Stream::readSegments() { + Guint segNum, segFlags, segType, page, segLength; + Guint refFlags, nRefSegs; + Guint *refSegs; + int segDataPos; + int c1, c2, c3; + Guint i; + + while (readULong(&segNum)) { + + if (!readUByte(&segFlags)) { + goto eofError1; + } + segType = segFlags & 0x3f; + + if (!readUByte(&refFlags)) { + goto eofError1; + } + nRefSegs = refFlags >> 5; + if (nRefSegs == 7) { + if ((c1 = curStr->getChar()) == EOF || + (c2 = curStr->getChar()) == EOF || + (c3 = curStr->getChar()) == EOF) { + goto eofError1; + } + refFlags = (refFlags << 24) | (c1 << 16) | (c2 << 8) | c3; + nRefSegs = refFlags & 0x1fffffff; + for (i = 0; i < (nRefSegs + 9) >> 3; ++i) { + c1 = curStr->getChar(); + } + } + + refSegs = (Guint *)gmallocn(nRefSegs, sizeof(Guint)); + if (segNum <= 256) { + for (i = 0; i < nRefSegs; ++i) { + if (!readUByte(&refSegs[i])) { + goto eofError2; + } + } + } else if (segNum <= 65536) { + for (i = 0; i < nRefSegs; ++i) { + if (!readUWord(&refSegs[i])) { + goto eofError2; + } + } + } else { + for (i = 0; i < nRefSegs; ++i) { + if (!readULong(&refSegs[i])) { + goto eofError2; + } + } + } + + if (segFlags & 0x40) { + if (!readULong(&page)) { + goto eofError2; + } + } else { + if (!readUByte(&page)) { + goto eofError2; + } + } + + if (!readULong(&segLength)) { + goto eofError2; + } + + segDataPos = getPos(); + + switch (segType) { + case 0: + if (!readSymbolDictSeg(segNum, segLength, refSegs, nRefSegs)) { + goto syntaxError; + } + break; + case 4: + readTextRegionSeg(segNum, gFalse, gFalse, segLength, refSegs, nRefSegs); + break; + case 6: + readTextRegionSeg(segNum, gTrue, gFalse, segLength, refSegs, nRefSegs); + break; + case 7: + readTextRegionSeg(segNum, gTrue, gTrue, segLength, refSegs, nRefSegs); + break; + case 16: + readPatternDictSeg(segNum, segLength); + break; + case 20: + readHalftoneRegionSeg(segNum, gFalse, gFalse, segLength, + refSegs, nRefSegs); + break; + case 22: + readHalftoneRegionSeg(segNum, gTrue, gFalse, segLength, + refSegs, nRefSegs); + break; + case 23: + readHalftoneRegionSeg(segNum, gTrue, gTrue, segLength, + refSegs, nRefSegs); + break; + case 36: + readGenericRegionSeg(segNum, gFalse, gFalse, segLength); + break; + case 38: + readGenericRegionSeg(segNum, gTrue, gFalse, segLength); + break; + case 39: + readGenericRegionSeg(segNum, gTrue, gTrue, segLength); + break; + case 40: + readGenericRefinementRegionSeg(segNum, gFalse, gFalse, segLength, + refSegs, nRefSegs); + break; + case 42: + readGenericRefinementRegionSeg(segNum, gTrue, gFalse, segLength, + refSegs, nRefSegs); + break; + case 43: + readGenericRefinementRegionSeg(segNum, gTrue, gTrue, segLength, + refSegs, nRefSegs); + break; + case 48: + readPageInfoSeg(segLength); + break; + case 50: + readEndOfStripeSeg(segLength); + break; + case 52: + readProfilesSeg(segLength); + break; + case 53: + readCodeTableSeg(segNum, segLength); + break; + case 62: + readExtensionSeg(segLength); + break; + default: + error(getPos(), ""Unknown segment type in JBIG2 stream""); + for (i = 0; i < segLength; ++i) { + if ((c1 = curStr->getChar()) == EOF) { + goto eofError2; + } + } + break; + } + + + if (segLength != 0xffffffff) { + + int segExtraBytes = segDataPos + segLength - getPos(); + if (segExtraBytes > 0) { + + + + error(getPos(), ""%d extraneous byte%s after segment"", + segExtraBytes, (segExtraBytes > 1) ? ""s"" : """"); + + + int trash; + for (int i = segExtraBytes; i > 0; i--) { + readByte(&trash); + } + + } else if (segExtraBytes < 0) { + + + error(getPos(), ""Previous segment handler read too many bytes""); + + } + + } + + gfree(refSegs); + } + + return; + + syntaxError: + gfree(refSegs); + return; + + eofError2: + gfree(refSegs); + eofError1: + error(getPos(), ""Unexpected EOF in JBIG2 stream""); +} +","@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): + return; + } + // need to allocate one extra guard byte for use in combine() +- data = (Guchar *)gmalloc(h * line + 1); ++ data = (Guchar *)gmallocn(h, line + 1); + data[h * line] = 0; + } + +@@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): + return; + } + // need to allocate one extra guard byte for use in combine() +- data = (Guchar *)gmalloc(h * line + 1); ++ data = (Guchar *)gmallocn(h, line + 1); + memcpy(data, bitmap->data, h * line); + data[h * line] = 0; + }",1364,1600,2048 +4393,"void ping_err(struct sk_buff *skb, int offset, u32 info) +{ + int family; + struct icmphdr *icmph; + struct inet_sock *inet_sock; + int type; + int code; + struct net *net = dev_net(skb->dev); + struct sock *sk; + int harderr; + int err; + + if (skb->protocol == htons(ETH_P_IP)) { + family = AF_INET; + type = icmp_hdr(skb)->type; + code = icmp_hdr(skb)->code; + icmph = (struct icmphdr *)(skb->data + offset); + } else if (skb->protocol == htons(ETH_P_IPV6)) { + family = AF_INET6; + type = icmp6_hdr(skb)->icmp6_type; + code = icmp6_hdr(skb)->icmp6_code; + icmph = (struct icmphdr *) (skb->data + offset); + } else { + BUG(); + } + + /* We assume the packet has already been checked by icmp_unreach */ + + if (!ping_supported(family, icmph->type, icmph->code)) + return; + + pr_debug(""ping_err(proto=0x%x,type=%d,code=%d,id=%04x,seq=%04x)\n"", + skb->protocol, type, code, ntohs(icmph->un.echo.id), + ntohs(icmph->un.echo.sequence)); + + sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); + if (!sk) { + pr_debug(""no socket, dropping\n""); + return; /* No socket for error */ + } + pr_debug(""err on socket %p\n"", sk); + + err = 0; + harderr = 0; + inet_sock = inet_sk(sk); + + if (skb->protocol == htons(ETH_P_IP)) { + switch (type) { + default: + case ICMP_TIME_EXCEEDED: + err = EHOSTUNREACH; + break; + case ICMP_SOURCE_QUENCH: + /* This is not a real error but ping wants to see it. + * Report it with some fake errno. + */ + err = EREMOTEIO; + break; + case ICMP_PARAMETERPROB: + err = EPROTO; + harderr = 1; + break; + case ICMP_DEST_UNREACH: + if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */ + ipv4_sk_update_pmtu(skb, sk, info); + if (inet_sock->pmtudisc != IP_PMTUDISC_DONT) { + err = EMSGSIZE; + harderr = 1; + break; + } + goto out; + } + err = EHOSTUNREACH; + if (code <= NR_ICMP_UNREACH) { + harderr = icmp_err_convert[code].fatal; + err = icmp_err_convert[code].errno; + } + break; + case ICMP_REDIRECT: + /* See ICMP_SOURCE_QUENCH */ + ipv4_sk_redirect(skb, sk); + err = EREMOTEIO; + break; + } +#if IS_ENABLED(CONFIG_IPV6) + } else if (skb->protocol == htons(ETH_P_IPV6)) { + harderr = pingv6_ops.icmpv6_err_convert(type, code, &err); +#endif + } + + /* + * RFC1122: OK. Passes ICMP errors back to application, as per + * 4.1.3.3. + */ + if ((family == AF_INET && !inet_sock->recverr) || + (family == AF_INET6 && !inet6_sk(sk)->recverr)) { + if (!harderr || sk->sk_state != TCP_ESTABLISHED) + goto out; + } else { + if (family == AF_INET) { + ip_icmp_error(sk, skb, err, 0 /* no remote port */, + info, (u8 *)icmph); +#if IS_ENABLED(CONFIG_IPV6) + } else if (family == AF_INET6) { + pingv6_ops.ipv6_icmp_error(sk, skb, err, 0, + info, (u8 *)icmph); +#endif + } + } + sk->sk_err = err; + sk->sk_error_report(sk); +out: + sock_put(sk); +} +",0,"void ping_err(struct sk_buff *skb, int offset, u32 info) +{ + int family; + struct icmphdr *icmph; + struct inet_sock *inet_sock; + int type; + int code; + struct net *net = dev_net(skb->dev); + struct sock *sk; + int harderr; + int err; + + if (skb->protocol == htons(ETH_P_IP)) { + family = AF_INET; + type = icmp_hdr(skb)->type; + code = icmp_hdr(skb)->code; + icmph = (struct icmphdr *)(skb->data + offset); + } else if (skb->protocol == htons(ETH_P_IPV6)) { + family = AF_INET6; + type = icmp6_hdr(skb)->icmp6_type; + code = icmp6_hdr(skb)->icmp6_code; + icmph = (struct icmphdr *) (skb->data + offset); + } else { + BUG(); + } + + /* We assume the packet has already been checked by icmp_unreach */ + + if (!ping_supported(family, icmph->type, icmph->code)) + return; + + pr_debug(""ping_err(proto=0x%x,type=%d,code=%d,id=%04x,seq=%04x)\n"", + skb->protocol, type, code, ntohs(icmph->un.echo.id), + ntohs(icmph->un.echo.sequence)); + + sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); + if (!sk) { + pr_debug(""no socket, dropping\n""); + return; /* No socket for error */ + } + pr_debug(""err on socket %p\n"", sk); + + err = 0; + harderr = 0; + inet_sock = inet_sk(sk); + + if (skb->protocol == htons(ETH_P_IP)) { + switch (type) { + default: + case ICMP_TIME_EXCEEDED: + err = EHOSTUNREACH; + break; + case ICMP_SOURCE_QUENCH: + /* This is not a real error but ping wants to see it. + * Report it with some fake errno. + */ + err = EREMOTEIO; + break; + case ICMP_PARAMETERPROB: + err = EPROTO; + harderr = 1; + break; + case ICMP_DEST_UNREACH: + if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */ + ipv4_sk_update_pmtu(skb, sk, info); + if (inet_sock->pmtudisc != IP_PMTUDISC_DONT) { + err = EMSGSIZE; + harderr = 1; + break; + } + goto out; + } + err = EHOSTUNREACH; + if (code <= NR_ICMP_UNREACH) { + harderr = icmp_err_convert[code].fatal; + err = icmp_err_convert[code].errno; + } + break; + case ICMP_REDIRECT: + /* See ICMP_SOURCE_QUENCH */ + ipv4_sk_redirect(skb, sk); + err = EREMOTEIO; + break; + } +#if IS_ENABLED(CONFIG_IPV6) + } else if (skb->protocol == htons(ETH_P_IPV6)) { + harderr = pingv6_ops.icmpv6_err_convert(type, code, &err); +#endif + } + + /* + * RFC1122: OK. Passes ICMP errors back to application, as per + * 4.1.3.3. + */ + if ((family == AF_INET && !inet_sock->recverr) || + (family == AF_INET6 && !inet6_sk(sk)->recverr)) { + if (!harderr || sk->sk_state != TCP_ESTABLISHED) + goto out; + } else { + if (family == AF_INET) { + ip_icmp_error(sk, skb, err, 0 /* no remote port */, + info, (u8 *)icmph); +#if IS_ENABLED(CONFIG_IPV6) + } else if (family == AF_INET6) { + pingv6_ops.ipv6_icmp_error(sk, skb, err, 0, + info, (u8 *)icmph); +#endif + } + } + sk->sk_err = err; + sk->sk_error_report(sk); +out: + sock_put(sk); +} +","@@ -158,6 +158,7 @@ void ping_unhash(struct sock *sk) + if (sk_hashed(sk)) { + write_lock_bh(&ping_table.lock); + hlist_nulls_del(&sk->sk_nulls_node); ++ sk_nulls_node_init(&sk->sk_nulls_node); + sock_put(sk); + isk->inet_num = 0; + isk->inet_sport = 0;",914,1150,2048 +18809,"WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) { + WORD32 idx; + WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size; + WORD32 N = (10 * anal_size); + + for (idx = 0; idx < (ptr_hbe_txposer->no_bins >> 1); idx++) { + WORD32 i, j, k, l; + FLOAT32 window_output[640]; + FLOAT32 u[128], u_in[256], u_out[256]; + FLOAT32 accu_r, accu_i; + const FLOAT32 *inp_signal; + FLOAT32 *anal_buf; + + FLOAT32 *analy_cos_sin_tab = ptr_hbe_txposer->analy_cos_sin_tab; + const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->analy_wind_coeff; + FLOAT32 *x = ptr_hbe_txposer->analy_buf; + + memset(ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1], 0, + TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + + inp_signal = ptr_hbe_txposer->ptr_input_buf + + idx * 2 * ptr_hbe_txposer->synth_size + 1; + anal_buf = &ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1] + [4 * ptr_hbe_txposer->k_start]; + + for (i = N - 1; i >= anal_size; i--) { + x[i] = x[i - anal_size]; + } + + for (i = anal_size - 1; i >= 0; i--) { + x[i] = inp_signal[anal_size - 1 - i]; + } + + for (i = 0; i < N; i++) { + window_output[i] = x[i] * interp_window_coeff[i]; + } + + for (i = 0; i < 2 * anal_size; i++) { + accu_r = 0.0; + for (j = 0; j < 5; j++) { + accu_r = accu_r + window_output[i + j * 2 * anal_size]; + } + u[i] = accu_r; + } + + if (anal_size == 40) { + for (i = 1; i < anal_size; i++) { + FLOAT32 temp1 = u[i] + u[2 * anal_size - i]; + FLOAT32 temp2 = u[i] - u[2 * anal_size - i]; + u[i] = temp1; + u[2 * anal_size - i] = temp2; + } + + for (k = 0; k < anal_size; k++) { + accu_r = u[anal_size]; + if (k & 1) + accu_i = u[0]; + else + accu_i = -u[0]; + for (l = 1; l < anal_size; l++) { + accu_r = accu_r + u[0 + l] * analy_cos_sin_tab[2 * l + 0]; + accu_i = accu_i + u[2 * anal_size - l] * analy_cos_sin_tab[2 * l + 1]; + } + analy_cos_sin_tab += (2 * anal_size); + *anal_buf++ = (FLOAT32)accu_r; + *anal_buf++ = (FLOAT32)accu_i; + } + } else { + FLOAT32 *ptr_u = u_in; + FLOAT32 *ptr_v = u_out; + for (k = 0; k < anal_size * 2; k++) { + + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + } + if (ixheaacd_cmplx_anal_fft != NULL) + (*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2); + else + return -1; + + for (k = 0; k < anal_size / 2; k++) { + *(anal_buf + 1) = -*ptr_v++; + *anal_buf = *ptr_v++; + + anal_buf += 2; + + *(anal_buf + 1) = *ptr_v++; + *anal_buf = -*ptr_v++; + + anal_buf += 2; + } + } + } + return 0; +} +",1,"WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) { + WORD32 idx; + WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size; + WORD32 N = (10 * anal_size); + + for (idx = 0; idx < (ptr_hbe_txposer->no_bins >> 1); idx++) { + WORD32 i, j, k, l; + FLOAT32 window_output[640]; + FLOAT32 u[128], u_in[256], u_out[256]; + FLOAT32 accu_r, accu_i; + const FLOAT32 *inp_signal; + FLOAT32 *anal_buf; + + FLOAT32 *analy_cos_sin_tab = ptr_hbe_txposer->analy_cos_sin_tab; + const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->analy_wind_coeff; + FLOAT32 *x = ptr_hbe_txposer->analy_buf; + + memset(ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1], 0, + TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); + + inp_signal = ptr_hbe_txposer->ptr_input_buf + + idx * 2 * ptr_hbe_txposer->synth_size + 1; + anal_buf = &ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1] + [4 * ptr_hbe_txposer->k_start]; + + for (i = N - 1; i >= anal_size; i--) { + x[i] = x[i - anal_size]; + } + + for (i = anal_size - 1; i >= 0; i--) { + x[i] = inp_signal[anal_size - 1 - i]; + } + + for (i = 0; i < N; i++) { + window_output[i] = x[i] * interp_window_coeff[i]; + } + + for (i = 0; i < 2 * anal_size; i++) { + accu_r = 0.0; + for (j = 0; j < 5; j++) { + accu_r = accu_r + window_output[i + j * 2 * anal_size]; + } + u[i] = accu_r; + } + + if (anal_size == 40) { + for (i = 1; i < anal_size; i++) { + FLOAT32 temp1 = u[i] + u[2 * anal_size - i]; + FLOAT32 temp2 = u[i] - u[2 * anal_size - i]; + u[i] = temp1; + u[2 * anal_size - i] = temp2; + } + + for (k = 0; k < anal_size; k++) { + accu_r = u[anal_size]; + if (k & 1) + accu_i = u[0]; + else + accu_i = -u[0]; + for (l = 1; l < anal_size; l++) { + accu_r = accu_r + u[0 + l] * analy_cos_sin_tab[2 * l + 0]; + accu_i = accu_i + u[2 * anal_size - l] * analy_cos_sin_tab[2 * l + 1]; + } + analy_cos_sin_tab += (2 * anal_size); + *anal_buf++ = (FLOAT32)accu_r; + *anal_buf++ = (FLOAT32)accu_i; + } + } else { + FLOAT32 *ptr_u = u_in; + FLOAT32 *ptr_v = u_out; + for (k = 0; k < anal_size * 2; k++) { + + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + } + if (ptr_hbe_txposer->ixheaacd_cmplx_anal_fft != NULL) + (*(ptr_hbe_txposer->ixheaacd_cmplx_anal_fft))(u_in, u_out, + anal_size * 2); + else + return -1; + + for (k = 0; k < anal_size / 2; k++) { + *(anal_buf + 1) = -*ptr_v++; + *anal_buf = *ptr_v++; + + anal_buf += 2; + + *(anal_buf + 1) = *ptr_v++; + *anal_buf = -*ptr_v++; + + anal_buf += 2; + } + } + } + return 0; +} +","@@ -120,8 +120,9 @@ + + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]); + } +- if (ixheaacd_cmplx_anal_fft != NULL) +- (*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2); ++ if (ptr_hbe_txposer->ixheaacd_cmplx_anal_fft != NULL) ++ (*(ptr_hbe_txposer->ixheaacd_cmplx_anal_fft))(u_in, u_out, ++ anal_size * 2); + else + return -1; + +@@ -209,8 +210,9 @@ + + FLOAT32 *syn_buf = &buffer[kmax]; + kmax += synth_size; + +- if (ixheaacd_real_synth_fft != NULL) +- (*ixheaacd_real_synth_fft)(synth_buf_r, synth_out, synth_size * 2); ++ if (ptr_hbe_txposer->ixheaacd_real_synth_fft != NULL) ++ (*(ptr_hbe_txposer->ixheaacd_real_synth_fft))(synth_buf_r, synth_out, ++ synth_size * 2); + else + return -1; + +",964,1200,2048 +18535,"void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) +{ + TRACE_EVENT2(""blink,benchmark"", ""DisplayItemList::commitNewDisplayItems"", ""current_display_list_size"", (int)m_currentDisplayItems.size(), + ""num_non_cached_new_items"", (int)m_newDisplayItems.size() - m_numCachedItems); + + if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { + for (const auto& invalidation : m_invalidations) + graphicsLayer->setNeedsDisplayInRect(invalidation.rect, invalidation.invalidationReason); + m_invalidations.clear(); + } + + ASSERT(m_scopeStack.isEmpty()); + m_scopeStack.clear(); + m_nextScope = 1; + ASSERT(!skippingCache()); +#if ENABLE(ASSERT) + m_newDisplayItemIndicesByClient.clear(); +#endif + + if (m_currentDisplayItems.isEmpty()) { +#if ENABLE(ASSERT) + for (const auto& item : m_newDisplayItems) + ASSERT(!item.isCached()); + #endif + m_currentDisplayItems.swap(m_newDisplayItems); + m_validlyCachedClientsDirty = true; + m_numCachedItems = 0; + return; + } + + updateValidlyCachedClientsIfNeeded(); + + OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin()); + + DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes())); + DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); + DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); + for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) { + const DisplayItem& newDisplayItem = *newIt; + const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); + bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayItemId.type; + + bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matches(*currentIt); + + if (newDisplayItemHasCachedType) { + ASSERT(newDisplayItem.isCached()); + ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !paintOffsetWasInvalidated(newDisplayItem.client()))); + if (!isSynchronized) { + currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrderIndexContext); + + if (currentIt == currentEnd) { +#ifndef NDEBUG + showDebugData(); + WTFLogAlways(""%s not found in m_currentDisplayItems\n"", newDisplayItem.asDebugString().utf8().data()); +#endif + ASSERT_NOT_REACHED(); + continue; + } + } +#if ENABLE(ASSERT) + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { + DisplayItems::iterator temp = currentIt; + checkUnderInvalidation(newIt, temp); + } +#endif + if (newDisplayItem.isCachedDrawing()) { + updatedList.appendByMoving(*currentIt); + ++currentIt; + } else { + ASSERT(newDisplayItem.isCachedSubsequence()); + copyCachedSubsequence(currentIt, updatedList); + ASSERT(updatedList.last().isEndSubsequence()); + } + } else { + ASSERT(!newDisplayItem.isDrawing() + || newDisplayItem.skippedCache() + || !clientCacheIsValid(newDisplayItem.client()) + || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && paintOffsetWasInvalidated(newDisplayItem.client()))); + + updatedList.appendByMoving(*newIt); + + if (isSynchronized) + ++currentIt; + } + if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) + outOfOrderIndexContext.nextItemToIndex = currentIt; + } + +#if ENABLE(ASSERT) + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) + checkNoRemainingCachedDisplayItems(); + #endif // ENABLE(ASSERT) + + m_newDisplayItems.clear(); + m_validlyCachedClientsDirty = true; + m_currentDisplayItems.swap(updatedList); + m_numCachedItems = 0; + +#if ENABLE(ASSERT) + m_clientsWithPaintOffsetInvalidations.clear(); +#endif +} +",1,"void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) +{ + TRACE_EVENT2(""blink,benchmark"", ""DisplayItemList::commitNewDisplayItems"", ""current_display_list_size"", (int)m_currentDisplayItems.size(), + ""num_non_cached_new_items"", (int)m_newDisplayItems.size() - m_numCachedItems); + + if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { + for (const auto& invalidation : m_invalidations) + graphicsLayer->setNeedsDisplayInRect(invalidation.rect, invalidation.invalidationReason); + m_invalidations.clear(); + } + + ASSERT(m_scopeStack.isEmpty()); + m_scopeStack.clear(); + m_nextScope = 1; + ASSERT(!skippingCache()); +#if ENABLE(ASSERT) + m_newDisplayItemIndicesByClient.clear(); +#endif + + if (m_currentDisplayItems.isEmpty()) { +#if ENABLE(ASSERT) + for (const auto& item : m_newDisplayItems) + ASSERT(!item.isCached()); + #endif + m_currentDisplayItems.swap(m_newDisplayItems); + m_currentPaintChunks = m_newPaintChunks.releasePaintChunks(); + m_validlyCachedClientsDirty = true; + m_numCachedItems = 0; + return; + } + + updateValidlyCachedClientsIfNeeded(); + + OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin()); + + DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes())); + Vector updatedPaintChunks; + DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); + DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); + for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) { + const DisplayItem& newDisplayItem = *newIt; + const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); + bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayItemId.type; + + bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matches(*currentIt); + + if (newDisplayItemHasCachedType) { + ASSERT(newDisplayItem.isCached()); + ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !paintOffsetWasInvalidated(newDisplayItem.client()))); + if (!isSynchronized) { + currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrderIndexContext); + + if (currentIt == currentEnd) { +#ifndef NDEBUG + showDebugData(); + WTFLogAlways(""%s not found in m_currentDisplayItems\n"", newDisplayItem.asDebugString().utf8().data()); +#endif + ASSERT_NOT_REACHED(); + continue; + } + } +#if ENABLE(ASSERT) + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { + DisplayItems::iterator temp = currentIt; + checkUnderInvalidation(newIt, temp); + } +#endif + if (newDisplayItem.isCachedDrawing()) { + updatedList.appendByMoving(*currentIt); + ++currentIt; + } else { + ASSERT(newDisplayItem.isCachedSubsequence()); + copyCachedSubsequence(currentIt, updatedList); + ASSERT(updatedList.last().isEndSubsequence()); + } + } else { + ASSERT(!newDisplayItem.isDrawing() + || newDisplayItem.skippedCache() + || !clientCacheIsValid(newDisplayItem.client()) + || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && paintOffsetWasInvalidated(newDisplayItem.client()))); + + updatedList.appendByMoving(*newIt); + + if (isSynchronized) + ++currentIt; + } + if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) + outOfOrderIndexContext.nextItemToIndex = currentIt; + } + +#if ENABLE(ASSERT) + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) + checkNoRemainingCachedDisplayItems(); + #endif // ENABLE(ASSERT) + + // TODO(jbroman): When subsequence caching applies to SPv2, we'll need to + // merge the paint chunks as well. + m_currentPaintChunks = m_newPaintChunks.releasePaintChunks(); + + m_newDisplayItems.clear(); + m_validlyCachedClientsDirty = true; + m_currentDisplayItems.swap(updatedList); + m_numCachedItems = 0; + +#if ENABLE(ASSERT) + m_clientsWithPaintOffsetInvalidations.clear(); +#endif +} +","@@ -24,6 +24,12 @@ const DisplayItems& DisplayItemList::displayItems() const + return m_currentDisplayItems; + } + ++const Vector& DisplayItemList::paintChunks() const ++{ ++ ASSERT(m_newPaintChunks.isInInitialState()); ++ return m_currentPaintChunks; ++} ++ + bool DisplayItemList::lastDisplayItemIsNoopBegin() const + { + if (m_newDisplayItems.isEmpty()) +@@ -48,6 +54,9 @@ void DisplayItemList::removeLastDisplayItem() + } + #endif + m_newDisplayItems.removeLast(); ++ ++ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) ++ m_newPaintChunks.decrementDisplayItemIndex(); + } + + void DisplayItemList::processNewItem(DisplayItem& displayItem) +@@ -85,6 +94,14 @@ void DisplayItemList::processNewItem(DisplayItem& displayItem) + + if (skippingCache()) + displayItem.setSkippedCache(); ++ ++ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) ++ m_newPaintChunks.incrementDisplayItemIndex(); ++} ++ ++void DisplayItemList::updateCurrentPaintProperties(const PaintProperties& newPaintProperties) ++{ ++ m_newPaintChunks.updateCurrentPaintProperties(newPaintProperties); + } + + void DisplayItemList::beginScope() +@@ -287,6 +304,7 @@ void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) + ASSERT(!item.isCached()); + #endif + m_currentDisplayItems.swap(m_newDisplayItems); ++ m_currentPaintChunks = m_newPaintChunks.releasePaintChunks(); + m_validlyCachedClientsDirty = true; + m_numCachedItems = 0; + return; +@@ -303,6 +321,7 @@ void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) + + // TODO(jbroman): Consider revisiting this heuristic. + DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes())); ++ Vector updatedPaintChunks; + DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); + DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); + for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) { +@@ -365,6 +384,10 @@ void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) + checkNoRemainingCachedDisplayItems(); + #endif // ENABLE(ASSERT) + ++ // TODO(jbroman): When subsequence caching applies to SPv2, we'll need to ++ // merge the paint chunks as well. ++ m_currentPaintChunks = m_newPaintChunks.releasePaintChunks(); ++ + m_newDisplayItems.clear(); + m_validlyCachedClientsDirty = true; + m_currentDisplayItems.swap(updatedList);",885,1121,2048 +439,"void Splash::scaleImageYuXu(SplashImageSource src, void *srcData, + SplashColorMode srcMode, int nComps, + GBool srcAlpha, int srcWidth, int srcHeight, + int scaledWidth, int scaledHeight, + SplashBitmap *dest) { + Guchar *lineBuf, *alphaLineBuf; + Guint pix[splashMaxColorComps]; + Guint alpha; + Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; + int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx; + int i, j; + + yp = scaledHeight / srcHeight; + yq = scaledHeight % srcHeight; + + xp = scaledWidth / srcWidth; + xq = scaledWidth % srcWidth; + + lineBuf = (Guchar *)gmallocn(srcWidth, nComps); + if (srcAlpha) { + alphaLineBuf = (Guchar *)gmalloc(srcWidth); + } else { + alphaLineBuf = NULL; + } + + yt = 0; + + destPtr0 = dest->data; + destAlphaPtr0 = dest->alpha; + for (y = 0; y < srcHeight; ++y) { + + if ((yt += yq) >= srcHeight) { + yt -= srcHeight; + yStep = yp + 1; + } else { + yStep = yp; + } + + (*src)(srcData, lineBuf, alphaLineBuf); + + xt = 0; + + xx = 0; + for (x = 0; x < srcWidth; ++x) { + + if ((xt += xq) >= srcWidth) { + xt -= srcWidth; + xStep = xp + 1; + } else { + xStep = xp; + } + + for (i = 0; i < nComps; ++i) { + pix[i] = lineBuf[x * nComps + i]; + } + + switch (srcMode) { + case splashModeMono1: // mono1 is not allowed + break; + case splashModeMono8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[0]; + } + } + break; + case splashModeRGB8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + } + } + break; + case splashModeXBGR8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)255; + } + } + break; + case splashModeBGR8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + } + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[3]; + } + } + break; + case splashModeDeviceN8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *destPtr++ = (Guchar)pix[cp]; + } + } + break; +#endif + } + + if (srcAlpha) { + alpha = alphaLineBuf[x]; + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destAlphaPtr = destAlphaPtr0 + i * scaledWidth + xx + j; + *destAlphaPtr = (Guchar)alpha; + } + } + } + + xx += xStep; + } + + destPtr0 += yStep * scaledWidth * nComps; + if (srcAlpha) { + destAlphaPtr0 += yStep * scaledWidth; + } + } + + gfree(alphaLineBuf); + gfree(lineBuf); +} +",0,"void Splash::scaleImageYuXu(SplashImageSource src, void *srcData, + SplashColorMode srcMode, int nComps, + GBool srcAlpha, int srcWidth, int srcHeight, + int scaledWidth, int scaledHeight, + SplashBitmap *dest) { + Guchar *lineBuf, *alphaLineBuf; + Guint pix[splashMaxColorComps]; + Guint alpha; + Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; + int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx; + int i, j; + + yp = scaledHeight / srcHeight; + yq = scaledHeight % srcHeight; + + xp = scaledWidth / srcWidth; + xq = scaledWidth % srcWidth; + + lineBuf = (Guchar *)gmallocn(srcWidth, nComps); + if (srcAlpha) { + alphaLineBuf = (Guchar *)gmalloc(srcWidth); + } else { + alphaLineBuf = NULL; + } + + yt = 0; + + destPtr0 = dest->data; + destAlphaPtr0 = dest->alpha; + for (y = 0; y < srcHeight; ++y) { + + if ((yt += yq) >= srcHeight) { + yt -= srcHeight; + yStep = yp + 1; + } else { + yStep = yp; + } + + (*src)(srcData, lineBuf, alphaLineBuf); + + xt = 0; + + xx = 0; + for (x = 0; x < srcWidth; ++x) { + + if ((xt += xq) >= srcWidth) { + xt -= srcWidth; + xStep = xp + 1; + } else { + xStep = xp; + } + + for (i = 0; i < nComps; ++i) { + pix[i] = lineBuf[x * nComps + i]; + } + + switch (srcMode) { + case splashModeMono1: // mono1 is not allowed + break; + case splashModeMono8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[0]; + } + } + break; + case splashModeRGB8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + } + } + break; + case splashModeXBGR8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)255; + } + } + break; + case splashModeBGR8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[0]; + } + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + *destPtr++ = (Guchar)pix[0]; + *destPtr++ = (Guchar)pix[1]; + *destPtr++ = (Guchar)pix[2]; + *destPtr++ = (Guchar)pix[3]; + } + } + break; + case splashModeDeviceN8: + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *destPtr++ = (Guchar)pix[cp]; + } + } + break; +#endif + } + + if (srcAlpha) { + alpha = alphaLineBuf[x]; + for (i = 0; i < yStep; ++i) { + for (j = 0; j < xStep; ++j) { + destAlphaPtr = destAlphaPtr0 + i * scaledWidth + xx + j; + *destAlphaPtr = (Guchar)alpha; + } + } + } + + xx += xStep; + } + + destPtr0 += yStep * scaledWidth * nComps; + if (srcAlpha) { + destAlphaPtr0 += yStep * scaledWidth; + } + } + + gfree(alphaLineBuf); + gfree(lineBuf); +} +","@@ -2955,7 +2955,7 @@ void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); + if (scaledMask->data == NULL) { +- error(errInternal, -1, ""scaledMask->data is NULL in Splash::scaleMaskYuXu""); ++ error(errInternal, -1, ""scaledMask->data is NULL in Splash::arbitraryTransformMask""); + delete scaledMask; + return; + } +@@ -3461,11 +3461,15 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + + w = src->getWidth(); + h = src->getHeight(); ++ p = src->getDataPtr(); ++ if (p == NULL) { ++ error(errInternal, -1, ""src->getDataPtr() is NULL in Splash::blitMask""); ++ return; ++ } + if (vectorAntialias && clipRes != splashClipAllInside) { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); + drawAAPixelInit(); +- p = src->getDataPtr(); + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + pipe.shape = *p++; +@@ -3475,7 +3479,6 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + } else { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); +- p = src->getDataPtr(); + if (clipRes == splashClipAllInside) { + for (y = 0; y < h; ++y) { + pipeSetXY(&pipe, xDest, yDest + y);",1276,1512,2048 +5271,"static inline int arp_packet_match(const struct arphdr *arphdr, + struct net_device *dev, + const char *indev, + const char *outdev, + const struct arpt_arp *arpinfo) +{ + const char *arpptr = (char *)(arphdr + 1); + const char *src_devaddr, *tgt_devaddr; + __be32 src_ipaddr, tgt_ipaddr; + long ret; + +#define FWINV(bool, invflg) ((bool) ^ !!(arpinfo->invflags & (invflg))) + + if (FWINV((arphdr->ar_op & arpinfo->arpop_mask) != arpinfo->arpop, + ARPT_INV_ARPOP)) { + dprintf(""ARP operation field mismatch.\n""); + dprintf(""ar_op: %04x info->arpop: %04x info->arpop_mask: %04x\n"", + arphdr->ar_op, arpinfo->arpop, arpinfo->arpop_mask); + return 0; + } + + if (FWINV((arphdr->ar_hrd & arpinfo->arhrd_mask) != arpinfo->arhrd, + ARPT_INV_ARPHRD)) { + dprintf(""ARP hardware address format mismatch.\n""); + dprintf(""ar_hrd: %04x info->arhrd: %04x info->arhrd_mask: %04x\n"", + arphdr->ar_hrd, arpinfo->arhrd, arpinfo->arhrd_mask); + return 0; + } + + if (FWINV((arphdr->ar_pro & arpinfo->arpro_mask) != arpinfo->arpro, + ARPT_INV_ARPPRO)) { + dprintf(""ARP protocol address format mismatch.\n""); + dprintf(""ar_pro: %04x info->arpro: %04x info->arpro_mask: %04x\n"", + arphdr->ar_pro, arpinfo->arpro, arpinfo->arpro_mask); + return 0; + } + + if (FWINV((arphdr->ar_hln & arpinfo->arhln_mask) != arpinfo->arhln, + ARPT_INV_ARPHLN)) { + dprintf(""ARP hardware address length mismatch.\n""); + dprintf(""ar_hln: %02x info->arhln: %02x info->arhln_mask: %02x\n"", + arphdr->ar_hln, arpinfo->arhln, arpinfo->arhln_mask); + return 0; + } + + src_devaddr = arpptr; + arpptr += dev->addr_len; + memcpy(&src_ipaddr, arpptr, sizeof(u32)); + arpptr += sizeof(u32); + tgt_devaddr = arpptr; + arpptr += dev->addr_len; + memcpy(&tgt_ipaddr, arpptr, sizeof(u32)); + + if (FWINV(arp_devaddr_compare(&arpinfo->src_devaddr, src_devaddr, dev->addr_len), + ARPT_INV_SRCDEVADDR) || + FWINV(arp_devaddr_compare(&arpinfo->tgt_devaddr, tgt_devaddr, dev->addr_len), + ARPT_INV_TGTDEVADDR)) { + dprintf(""Source or target device address mismatch.\n""); + + return 0; + } + + if (FWINV((src_ipaddr & arpinfo->smsk.s_addr) != arpinfo->src.s_addr, + ARPT_INV_SRCIP) || + FWINV(((tgt_ipaddr & arpinfo->tmsk.s_addr) != arpinfo->tgt.s_addr), + ARPT_INV_TGTIP)) { + dprintf(""Source or target IP address mismatch.\n""); + + dprintf(""SRC: %pI4. Mask: %pI4. Target: %pI4.%s\n"", + &src_ipaddr, + &arpinfo->smsk.s_addr, + &arpinfo->src.s_addr, + arpinfo->invflags & ARPT_INV_SRCIP ? "" (INV)"" : """"); + dprintf(""TGT: %pI4 Mask: %pI4 Target: %pI4.%s\n"", + &tgt_ipaddr, + &arpinfo->tmsk.s_addr, + &arpinfo->tgt.s_addr, + arpinfo->invflags & ARPT_INV_TGTIP ? "" (INV)"" : """"); + return 0; + } + + /* Look for ifname matches. */ + ret = ifname_compare(indev, arpinfo->iniface, arpinfo->iniface_mask); + + if (FWINV(ret != 0, ARPT_INV_VIA_IN)) { + dprintf(""VIA in mismatch (%s vs %s).%s\n"", + indev, arpinfo->iniface, + arpinfo->invflags & ARPT_INV_VIA_IN ? "" (INV)"" : """"); + return 0; + } + + ret = ifname_compare(outdev, arpinfo->outiface, arpinfo->outiface_mask); + + if (FWINV(ret != 0, ARPT_INV_VIA_OUT)) { + dprintf(""VIA out mismatch (%s vs %s).%s\n"", + outdev, arpinfo->outiface, + arpinfo->invflags & ARPT_INV_VIA_OUT ? "" (INV)"" : """"); + return 0; + } + + return 1; +#undef FWINV +} +",0,"static inline int arp_packet_match(const struct arphdr *arphdr, + struct net_device *dev, + const char *indev, + const char *outdev, + const struct arpt_arp *arpinfo) +{ + const char *arpptr = (char *)(arphdr + 1); + const char *src_devaddr, *tgt_devaddr; + __be32 src_ipaddr, tgt_ipaddr; + long ret; + +#define FWINV(bool, invflg) ((bool) ^ !!(arpinfo->invflags & (invflg))) + + if (FWINV((arphdr->ar_op & arpinfo->arpop_mask) != arpinfo->arpop, + ARPT_INV_ARPOP)) { + dprintf(""ARP operation field mismatch.\n""); + dprintf(""ar_op: %04x info->arpop: %04x info->arpop_mask: %04x\n"", + arphdr->ar_op, arpinfo->arpop, arpinfo->arpop_mask); + return 0; + } + + if (FWINV((arphdr->ar_hrd & arpinfo->arhrd_mask) != arpinfo->arhrd, + ARPT_INV_ARPHRD)) { + dprintf(""ARP hardware address format mismatch.\n""); + dprintf(""ar_hrd: %04x info->arhrd: %04x info->arhrd_mask: %04x\n"", + arphdr->ar_hrd, arpinfo->arhrd, arpinfo->arhrd_mask); + return 0; + } + + if (FWINV((arphdr->ar_pro & arpinfo->arpro_mask) != arpinfo->arpro, + ARPT_INV_ARPPRO)) { + dprintf(""ARP protocol address format mismatch.\n""); + dprintf(""ar_pro: %04x info->arpro: %04x info->arpro_mask: %04x\n"", + arphdr->ar_pro, arpinfo->arpro, arpinfo->arpro_mask); + return 0; + } + + if (FWINV((arphdr->ar_hln & arpinfo->arhln_mask) != arpinfo->arhln, + ARPT_INV_ARPHLN)) { + dprintf(""ARP hardware address length mismatch.\n""); + dprintf(""ar_hln: %02x info->arhln: %02x info->arhln_mask: %02x\n"", + arphdr->ar_hln, arpinfo->arhln, arpinfo->arhln_mask); + return 0; + } + + src_devaddr = arpptr; + arpptr += dev->addr_len; + memcpy(&src_ipaddr, arpptr, sizeof(u32)); + arpptr += sizeof(u32); + tgt_devaddr = arpptr; + arpptr += dev->addr_len; + memcpy(&tgt_ipaddr, arpptr, sizeof(u32)); + + if (FWINV(arp_devaddr_compare(&arpinfo->src_devaddr, src_devaddr, dev->addr_len), + ARPT_INV_SRCDEVADDR) || + FWINV(arp_devaddr_compare(&arpinfo->tgt_devaddr, tgt_devaddr, dev->addr_len), + ARPT_INV_TGTDEVADDR)) { + dprintf(""Source or target device address mismatch.\n""); + + return 0; + } + + if (FWINV((src_ipaddr & arpinfo->smsk.s_addr) != arpinfo->src.s_addr, + ARPT_INV_SRCIP) || + FWINV(((tgt_ipaddr & arpinfo->tmsk.s_addr) != arpinfo->tgt.s_addr), + ARPT_INV_TGTIP)) { + dprintf(""Source or target IP address mismatch.\n""); + + dprintf(""SRC: %pI4. Mask: %pI4. Target: %pI4.%s\n"", + &src_ipaddr, + &arpinfo->smsk.s_addr, + &arpinfo->src.s_addr, + arpinfo->invflags & ARPT_INV_SRCIP ? "" (INV)"" : """"); + dprintf(""TGT: %pI4 Mask: %pI4 Target: %pI4.%s\n"", + &tgt_ipaddr, + &arpinfo->tmsk.s_addr, + &arpinfo->tgt.s_addr, + arpinfo->invflags & ARPT_INV_TGTIP ? "" (INV)"" : """"); + return 0; + } + + /* Look for ifname matches. */ + ret = ifname_compare(indev, arpinfo->iniface, arpinfo->iniface_mask); + + if (FWINV(ret != 0, ARPT_INV_VIA_IN)) { + dprintf(""VIA in mismatch (%s vs %s).%s\n"", + indev, arpinfo->iniface, + arpinfo->invflags & ARPT_INV_VIA_IN ? "" (INV)"" : """"); + return 0; + } + + ret = ifname_compare(outdev, arpinfo->outiface, arpinfo->outiface_mask); + + if (FWINV(ret != 0, ARPT_INV_VIA_OUT)) { + dprintf(""VIA out mismatch (%s vs %s).%s\n"", + outdev, arpinfo->outiface, + arpinfo->invflags & ARPT_INV_VIA_OUT ? "" (INV)"" : """"); + return 0; + } + + return 1; +#undef FWINV +} +","@@ -573,7 +573,8 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e, + int err; + + if ((unsigned long)e % __alignof__(struct arpt_entry) != 0 || +- (unsigned char *)e + sizeof(struct arpt_entry) >= limit) { ++ (unsigned char *)e + sizeof(struct arpt_entry) >= limit || ++ (unsigned char *)e + e->next_offset > limit) { + duprintf(""Bad offset %p\n"", e); + return -EINVAL; + } +@@ -1232,7 +1233,8 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e, + + duprintf(""check_compat_entry_size_and_hooks %p\n"", e); + if ((unsigned long)e % __alignof__(struct compat_arpt_entry) != 0 || +- (unsigned char *)e + sizeof(struct compat_arpt_entry) >= limit) { ++ (unsigned char *)e + sizeof(struct compat_arpt_entry) >= limit || ++ (unsigned char *)e + e->next_offset > limit) { + duprintf(""Bad offset %p, limit = %p\n"", e, limit); + return -EINVAL; + }",1179,1415,2048 +18343,"MagickExport Image *MeanShiftImage(const Image *image,const size_t width, + const size_t height,const double color_distance,ExceptionInfo *exception) +{ +#define MaxMeanShiftIterations 100 +#define MeanShiftImageTag ""MeanShift/Image"" + + CacheView + *image_view, + *mean_view, + *pixel_view; + + Image + *mean_image; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + ssize_t + y; + + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + mean_image=CloneImage(image,0,0,MagickTrue,exception); + if (mean_image == (Image *) NULL) + return((Image *) NULL); + if (SetImageStorageClass(mean_image,DirectClass,exception) == MagickFalse) + { + mean_image=DestroyImage(mean_image); + return((Image *) NULL); + } + status=MagickTrue; + progress=0; + image_view=AcquireVirtualCacheView(image,exception); + pixel_view=AcquireVirtualCacheView(image,exception); + mean_view=AcquireAuthenticCacheView(mean_image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(status,progress) \ + magick_number_threads(mean_image,mean_image,mean_image->rows,1) +#endif + for (y=0; y < (ssize_t) mean_image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); + q=GetCacheViewAuthenticPixels(mean_view,0,y,mean_image->columns,1, + exception); + if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL)) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) mean_image->columns; x++) + { + PixelInfo + mean_pixel, + previous_pixel; + + PointInfo + mean_location, + previous_location; + + register ssize_t + i; + + GetPixelInfo(image,&mean_pixel); + GetPixelInfoPixel(image,p,&mean_pixel); + mean_location.x=(double) x; + mean_location.y=(double) y; + for (i=0; i < MaxMeanShiftIterations; i++) + { + double + distance, + gamma; + + PixelInfo + sum_pixel; + + PointInfo + sum_location; + + ssize_t + count, + v; + + sum_location.x=0.0; + sum_location.y=0.0; + GetPixelInfo(image,&sum_pixel); + previous_location=mean_location; + previous_pixel=mean_pixel; + count=0; + for (v=(-((ssize_t) height/2)); v <= (((ssize_t) height/2)); v++) + { + ssize_t + u; + + for (u=(-((ssize_t) width/2)); u <= (((ssize_t) width/2)); u++) + { + if ((v*v+u*u) <= (ssize_t) ((width/2)*(height/2))) + { + PixelInfo + pixel; + + status=GetOneCacheViewVirtualPixelInfo(pixel_view,(ssize_t) + MagickRound(mean_location.x+u),(ssize_t) MagickRound( + mean_location.y+v),&pixel,exception); + distance=(mean_pixel.red-pixel.red)*(mean_pixel.red-pixel.red)+ + (mean_pixel.green-pixel.green)*(mean_pixel.green-pixel.green)+ + (mean_pixel.blue-pixel.blue)*(mean_pixel.blue-pixel.blue); + if (distance <= (color_distance*color_distance)) + { + sum_location.x+=mean_location.x+u; + sum_location.y+=mean_location.y+v; + sum_pixel.red+=pixel.red; + sum_pixel.green+=pixel.green; + sum_pixel.blue+=pixel.blue; + sum_pixel.alpha+=pixel.alpha; + count++; + } + } + } + } + gamma=1.0/count; + mean_location.x=gamma*sum_location.x; + mean_location.y=gamma*sum_location.y; + mean_pixel.red=gamma*sum_pixel.red; + mean_pixel.green=gamma*sum_pixel.green; + mean_pixel.blue=gamma*sum_pixel.blue; + mean_pixel.alpha=gamma*sum_pixel.alpha; + distance=(mean_location.x-previous_location.x)* + (mean_location.x-previous_location.x)+ + (mean_location.y-previous_location.y)* + (mean_location.y-previous_location.y)+ + 255.0*QuantumScale*(mean_pixel.red-previous_pixel.red)* + 255.0*QuantumScale*(mean_pixel.red-previous_pixel.red)+ + 255.0*QuantumScale*(mean_pixel.green-previous_pixel.green)* + 255.0*QuantumScale*(mean_pixel.green-previous_pixel.green)+ + 255.0*QuantumScale*(mean_pixel.blue-previous_pixel.blue)* + 255.0*QuantumScale*(mean_pixel.blue-previous_pixel.blue); + if (distance <= 3.0) + break; + } + SetPixelRed(mean_image,ClampToQuantum(mean_pixel.red),q); + SetPixelGreen(mean_image,ClampToQuantum(mean_pixel.green),q); + SetPixelBlue(mean_image,ClampToQuantum(mean_pixel.blue),q); + SetPixelAlpha(mean_image,ClampToQuantum(mean_pixel.alpha),q); + p+=GetPixelChannels(image); + q+=GetPixelChannels(mean_image); + } + if (SyncCacheViewAuthenticPixels(mean_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,MeanShiftImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + mean_view=DestroyCacheView(mean_view); + pixel_view=DestroyCacheView(pixel_view); + image_view=DestroyCacheView(image_view); + return(mean_image); +} +",1,"MagickExport Image *MeanShiftImage(const Image *image,const size_t width, + const size_t height,const double color_distance,ExceptionInfo *exception) +{ +#define MaxMeanShiftIterations 100 +#define MeanShiftImageTag ""MeanShift/Image"" + + CacheView + *image_view, + *mean_view, + *pixel_view; + + Image + *mean_image; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + ssize_t + y; + + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + mean_image=CloneImage(image,0,0,MagickTrue,exception); + if (mean_image == (Image *) NULL) + return((Image *) NULL); + if (SetImageStorageClass(mean_image,DirectClass,exception) == MagickFalse) + { + mean_image=DestroyImage(mean_image); + return((Image *) NULL); + } + status=MagickTrue; + progress=0; + image_view=AcquireVirtualCacheView(image,exception); + pixel_view=AcquireVirtualCacheView(image,exception); + mean_view=AcquireAuthenticCacheView(mean_image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(status,progress) \ + magick_number_threads(mean_image,mean_image,mean_image->rows,1) +#endif + for (y=0; y < (ssize_t) mean_image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); + q=GetCacheViewAuthenticPixels(mean_view,0,y,mean_image->columns,1, + exception); + if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL)) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) mean_image->columns; x++) + { + PixelInfo + mean_pixel, + previous_pixel; + + PointInfo + mean_location, + previous_location; + + register ssize_t + i; + + GetPixelInfo(image,&mean_pixel); + GetPixelInfoPixel(image,p,&mean_pixel); + mean_location.x=(double) x; + mean_location.y=(double) y; + for (i=0; i < MaxMeanShiftIterations; i++) + { + double + distance, + gamma; + + PixelInfo + sum_pixel; + + PointInfo + sum_location; + + ssize_t + count, + v; + + sum_location.x=0.0; + sum_location.y=0.0; + GetPixelInfo(image,&sum_pixel); + previous_location=mean_location; + previous_pixel=mean_pixel; + count=0; + for (v=(-((ssize_t) height/2)); v <= (((ssize_t) height/2)); v++) + { + ssize_t + u; + + for (u=(-((ssize_t) width/2)); u <= (((ssize_t) width/2)); u++) + { + if ((v*v+u*u) <= (ssize_t) ((width/2)*(height/2))) + { + PixelInfo + pixel; + + status=GetOneCacheViewVirtualPixelInfo(pixel_view,(ssize_t) + MagickRound(mean_location.x+u),(ssize_t) MagickRound( + mean_location.y+v),&pixel,exception); + distance=(mean_pixel.red-pixel.red)*(mean_pixel.red-pixel.red)+ + (mean_pixel.green-pixel.green)*(mean_pixel.green-pixel.green)+ + (mean_pixel.blue-pixel.blue)*(mean_pixel.blue-pixel.blue); + if (distance <= (color_distance*color_distance)) + { + sum_location.x+=mean_location.x+u; + sum_location.y+=mean_location.y+v; + sum_pixel.red+=pixel.red; + sum_pixel.green+=pixel.green; + sum_pixel.blue+=pixel.blue; + sum_pixel.alpha+=pixel.alpha; + count++; + } + } + } + } + gamma=PerceptibleReciprocal(count); + mean_location.x=gamma*sum_location.x; + mean_location.y=gamma*sum_location.y; + mean_pixel.red=gamma*sum_pixel.red; + mean_pixel.green=gamma*sum_pixel.green; + mean_pixel.blue=gamma*sum_pixel.blue; + mean_pixel.alpha=gamma*sum_pixel.alpha; + distance=(mean_location.x-previous_location.x)* + (mean_location.x-previous_location.x)+ + (mean_location.y-previous_location.y)* + (mean_location.y-previous_location.y)+ + 255.0*QuantumScale*(mean_pixel.red-previous_pixel.red)* + 255.0*QuantumScale*(mean_pixel.red-previous_pixel.red)+ + 255.0*QuantumScale*(mean_pixel.green-previous_pixel.green)* + 255.0*QuantumScale*(mean_pixel.green-previous_pixel.green)+ + 255.0*QuantumScale*(mean_pixel.blue-previous_pixel.blue)* + 255.0*QuantumScale*(mean_pixel.blue-previous_pixel.blue); + if (distance <= 3.0) + break; + } + SetPixelRed(mean_image,ClampToQuantum(mean_pixel.red),q); + SetPixelGreen(mean_image,ClampToQuantum(mean_pixel.green),q); + SetPixelBlue(mean_image,ClampToQuantum(mean_pixel.blue),q); + SetPixelAlpha(mean_image,ClampToQuantum(mean_pixel.alpha),q); + p+=GetPixelChannels(image); + q+=GetPixelChannels(mean_image); + } + if (SyncCacheViewAuthenticPixels(mean_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,MeanShiftImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + mean_view=DestroyCacheView(mean_view); + pixel_view=DestroyCacheView(pixel_view); + image_view=DestroyCacheView(image_view); + return(mean_image); +} +","@@ -2288,7 +2288,7 @@ MagickExport Image *MeanShiftImage(const Image *image,const size_t width, + } + } + } +- gamma=1.0/count; ++ gamma=PerceptibleReciprocal(count); + mean_location.x=gamma*sum_location.x; + mean_location.y=gamma*sum_location.y; + mean_pixel.red=gamma*sum_pixel.red;",1442,1678,2048 +17229,"OMX_ERRORTYPE omx_video::get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType) +{ + OMX_ERRORTYPE eRet = OMX_ErrorNone; + if (!profileLevelType) + return OMX_ErrorBadParameter; + + if (profileLevelType->nPortIndex == 1) { + if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { +#if defined _MSM8974_ && !defined _MSM8226_ + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else if (profileLevelType->nProfileIndex == 2) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileHigh; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else if (profileLevelType->nProfileIndex == 3) { + profileLevelType->eProfile = QOMX_VIDEO_AVCProfileConstrainedBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else { + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", + (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } +#else + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; + + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; + } else if (profileLevelType->nProfileIndex == 2) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileHigh; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; +#ifdef _MSM8226_ + } else if (profileLevelType->nProfileIndex == 3) { + profileLevelType->eProfile = QOMX_VIDEO_AVCProfileConstrainedBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; +#endif + } else { + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %d"", + (int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } +#endif + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_H263ProfileBaseline; + profileLevelType->eLevel = OMX_VIDEO_H263Level70; + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_MPEG4ProfileSimple; + profileLevelType->eLevel = OMX_VIDEO_MPEG4Level5; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; + profileLevelType->eLevel = OMX_VIDEO_MPEG4Level5; + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingVP8) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_VP8ProfileMain; + profileLevelType->eLevel = OMX_VIDEO_VP8Level_Version0; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_VP8ProfileMain; + profileLevelType->eLevel = OMX_VIDEO_VP8Level_Version1; + } else { + DEBUG_PRINT_LOW(""VP8: get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", + (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingHEVC) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_HEVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_HEVCMainTierLevel52; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_HEVCProfileMain10; + profileLevelType->eLevel = OMX_VIDEO_HEVCMainTierLevel52; + } else { + DEBUG_PRINT_LOW(""HEVC: get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", + (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported ret NoMore""); + eRet = OMX_ErrorNoMore; + } + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported should be queried on Input port only %u"", (unsigned int)profileLevelType->nPortIndex); + eRet = OMX_ErrorBadPortIndex; + } + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported for Input port returned Profile:%u, Level:%u"", + (unsigned int)profileLevelType->eProfile, (unsigned int)profileLevelType->eLevel); + return eRet; +} +",0,"OMX_ERRORTYPE omx_video::get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType) +{ + OMX_ERRORTYPE eRet = OMX_ErrorNone; + if (!profileLevelType) + return OMX_ErrorBadParameter; + + if (profileLevelType->nPortIndex == 1) { + if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { +#if defined _MSM8974_ && !defined _MSM8226_ + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else if (profileLevelType->nProfileIndex == 2) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileHigh; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else if (profileLevelType->nProfileIndex == 3) { + profileLevelType->eProfile = QOMX_VIDEO_AVCProfileConstrainedBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel52; + } else { + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", + (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } +#else + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; + + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; + } else if (profileLevelType->nProfileIndex == 2) { + profileLevelType->eProfile = OMX_VIDEO_AVCProfileHigh; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; +#ifdef _MSM8226_ + } else if (profileLevelType->nProfileIndex == 3) { + profileLevelType->eProfile = QOMX_VIDEO_AVCProfileConstrainedBaseline; + profileLevelType->eLevel = OMX_VIDEO_AVCLevel4; +#endif + } else { + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %d"", + (int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } +#endif + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_H263ProfileBaseline; + profileLevelType->eLevel = OMX_VIDEO_H263Level70; + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_MPEG4ProfileSimple; + profileLevelType->eLevel = OMX_VIDEO_MPEG4Level5; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; + profileLevelType->eLevel = OMX_VIDEO_MPEG4Level5; + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingVP8) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_VP8ProfileMain; + profileLevelType->eLevel = OMX_VIDEO_VP8Level_Version0; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_VP8ProfileMain; + profileLevelType->eLevel = OMX_VIDEO_VP8Level_Version1; + } else { + DEBUG_PRINT_LOW(""VP8: get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", + (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else if (m_sOutPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingHEVC) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_HEVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_HEVCMainTierLevel52; + } else if (profileLevelType->nProfileIndex == 1) { + profileLevelType->eProfile = OMX_VIDEO_HEVCProfileMain10; + profileLevelType->eLevel = OMX_VIDEO_HEVCMainTierLevel52; + } else { + DEBUG_PRINT_LOW(""HEVC: get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u"", + (unsigned int)profileLevelType->nProfileIndex); + eRet = OMX_ErrorNoMore; + } + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported ret NoMore""); + eRet = OMX_ErrorNoMore; + } + } else { + DEBUG_PRINT_ERROR(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported should be queried on Input port only %u"", (unsigned int)profileLevelType->nPortIndex); + eRet = OMX_ErrorBadPortIndex; + } + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported for Input port returned Profile:%u, Level:%u"", + (unsigned int)profileLevelType->eProfile, (unsigned int)profileLevelType->eLevel); + return eRet; +} +","@@ -80,7 +80,6 @@ + + + #define SZ_4K 0x1000 + #define SZ_1M 0x100000 +-#define SECURE_BUFPTR 0xDEADBEEF + + typedef struct OMXComponentCapabilityFlagsType { + ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS +@@ -2252,7 +2251,7 @@ + + m_pInput_pmem[i].size = m_sInPortDef.nBufferSize; + m_pInput_pmem[i].offset = 0; + +- m_pInput_pmem[i].buffer = (OMX_U8 *)SECURE_BUFPTR; ++ m_pInput_pmem[i].buffer = NULL; + if(!secure_session) { + m_pInput_pmem[i].buffer = (unsigned char *)mmap( + NULL,m_pInput_pmem[i].size,PROT_READ|PROT_WRITE, +@@ -2260,6 +2259,7 @@ + + + if (m_pInput_pmem[i].buffer == MAP_FAILED) { + DEBUG_PRINT_ERROR(""ERROR: mmap() Failed""); ++ m_pInput_pmem[i].buffer = NULL; + close(m_pInput_pmem[i].fd); + #ifdef USE_ION + free_ion_memory(&m_pInput_ion[i]); +@@ -2443,7 +2443,7 @@ + + m_pOutput_pmem[i].size = m_sOutPortDef.nBufferSize; + m_pOutput_pmem[i].offset = 0; + +- m_pOutput_pmem[i].buffer = (OMX_U8 *)SECURE_BUFPTR; ++ m_pOutput_pmem[i].buffer = NULL; + if(!secure_session) { + #ifdef _MSM8974_ + m_pOutput_pmem[i].buffer = (unsigned char *)mmap(NULL, +@@ -2456,6 +2456,7 @@ + + #endif + if (m_pOutput_pmem[i].buffer == MAP_FAILED) { + DEBUG_PRINT_ERROR(""ERROR: mmap() Failed""); ++ m_pOutput_pmem[i].buffer = NULL; + close(m_pOutput_pmem[i].fd); + #ifdef USE_ION + free_ion_memory(&m_pOutput_ion[i]); +@@ -2854,13 +2855,14 @@ + + m_pInput_pmem[i].size = m_sInPortDef.nBufferSize; + m_pInput_pmem[i].offset = 0; + +- m_pInput_pmem[i].buffer = (OMX_U8 *)SECURE_BUFPTR; ++ m_pInput_pmem[i].buffer = NULL; + if(!secure_session) { + m_pInput_pmem[i].buffer = (unsigned char *)mmap(NULL, + m_pInput_pmem[i].size,PROT_READ|PROT_WRITE, + MAP_SHARED,m_pInput_pmem[i].fd,0); + if (m_pInput_pmem[i].buffer == MAP_FAILED) { + DEBUG_PRINT_ERROR(""ERROR: mmap FAILED= %d"", errno); ++ m_pInput_pmem[i].buffer = NULL; + close(m_pInput_pmem[i].fd); + #ifdef USE_ION + free_ion_memory(&m_pInput_ion[i]); +@@ -2871,6 +2873,10 @@ + + //This should only be used for passing reference to source type and + //secure handle fd struct native_handle_t* + m_pInput_pmem[i].buffer = malloc(sizeof(OMX_U32) + sizeof(native_handle_t*)); ++ if (m_pInput_pmem[i].buffer == NULL) { ++ DEBUG_PRINT_ERROR(""%s: failed to allocate native-handle"", __func__); ++ return OMX_ErrorInsufficientResources; ++ } + (*bufferHdr)->nAllocLen = sizeof(OMX_U32) + sizeof(native_handle_t*); + } + +@@ -3016,7 +3022,7 @@ + + m_pOutput_pmem[i].size = m_sOutPortDef.nBufferSize; + m_pOutput_pmem[i].offset = 0; + +- m_pOutput_pmem[i].buffer = (OMX_U8 *)SECURE_BUFPTR; ++ m_pOutput_pmem[i].buffer = NULL; + if(!secure_session) { + #ifdef _MSM8974_ + m_pOutput_pmem[i].buffer = (unsigned char *)mmap(NULL, +@@ -3029,6 +3035,7 @@ + + #endif + if (m_pOutput_pmem[i].buffer == MAP_FAILED) { + DEBUG_PRINT_ERROR(""ERROR: MMAP_FAILED in o/p alloc buffer""); ++ m_pOutput_pmem[i].buffer = NULL; + close (m_pOutput_pmem[i].fd); + #ifdef USE_ION + free_ion_memory(&m_pOutput_ion[i]); +@@ -3040,6 +3047,10 @@ + + //This should only be used for passing reference to source type and + //secure handle fd struct native_handle_t* + m_pOutput_pmem[i].buffer = malloc(sizeof(OMX_U32) + sizeof(native_handle_t*)); ++ if (m_pOutput_pmem[i].buffer == NULL) { ++ DEBUG_PRINT_ERROR(""%s: Failed to allocate native-handle"", __func__); ++ return OMX_ErrorInsufficientResources; ++ } + (*bufferHdr)->nAllocLen = sizeof(OMX_U32) + sizeof(native_handle_t*); + native_handle_t *handle = native_handle_create(1, 0); + handle->data[0] = m_pOutput_pmem[i].fd; +",1395,1631,2048 +1483,"void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y, + Guint combOp) { + int x0, x1, y0, y1, xx, yy; + Guchar *srcPtr, *destPtr; + Guint src0, src1, src, dest, s1, s2, m1, m2, m3; + GBool oneByte; + + if (y < -0x7fffffff) { + return; + } + if (y < 0) { + y0 = -y; + } else { + y0 = 0; + } + if (y + bitmap->h > h) { + y1 = h - y; + } else { + y1 = bitmap->h; + } + if (y0 >= y1) { + return; + } + + if (x >= 0) { + x0 = x & ~7; + } else { + x0 = 0; + } + x1 = x + bitmap->w; + if (x1 > w) { + x1 = w; + } + if (x0 >= x1) { + return; + } + + s1 = x & 7; + s2 = 8 - s1; + m1 = 0xff >> (x1 & 7); + m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); + m3 = (0xff >> s1) & m2; + + oneByte = x0 == ((x1 - 1) & ~7); + + for (yy = y0; yy < y1; ++yy) { + + if (oneByte) { + if (x >= 0) { + destPtr = data + (y + yy) * line + (x >> 3); + srcPtr = bitmap->data + yy * bitmap->line; + dest = *destPtr; + src1 = *srcPtr; + switch (combOp) { + case 0: // or + dest |= (src1 >> s1) & m2; + break; + case 1: // and + dest &= ((0xff00 | src1) >> s1) | m1; + break; + case 2: // xor + dest ^= (src1 >> s1) & m2; + break; + case 3: // xnor + dest ^= ((src1 ^ 0xff) >> s1) & m2; + break; + case 4: // replace + dest = (dest & ~m3) | ((src1 >> s1) & m3); + break; + } + *destPtr = dest; + } else { + destPtr = data + (y + yy) * line; + srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); + dest = *destPtr; + src1 = *srcPtr; + switch (combOp) { + case 0: // or + dest |= src1 & m2; + break; + case 1: // and + dest &= src1 | m1; + break; + case 2: // xor + dest ^= src1 & m2; + break; + case 3: // xnor + dest ^= (src1 ^ 0xff) & m2; + break; + case 4: // replace + dest = (src1 & m2) | (dest & m1); + break; + } + *destPtr = dest; + } + + } else { + + if (x >= 0) { + destPtr = data + (y + yy) * line + (x >> 3); + srcPtr = bitmap->data + yy * bitmap->line; + src1 = *srcPtr++; + dest = *destPtr; + switch (combOp) { + case 0: // or + dest |= src1 >> s1; + break; + case 1: // and + dest &= (0xff00 | src1) >> s1; + break; + case 2: // xor + dest ^= src1 >> s1; + break; + case 3: // xnor + dest ^= (src1 ^ 0xff) >> s1; + break; + case 4: // replace + dest = (dest & (0xff << s2)) | (src1 >> s1); + break; + } + *destPtr++ = dest; + xx = x0 + 8; + } else { + destPtr = data + (y + yy) * line; + srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); + src1 = *srcPtr++; + xx = x0; + } + + for (; xx < x1 - 8; xx += 8) { + dest = *destPtr; + src0 = src1; + src1 = *srcPtr++; + src = (((src0 << 8) | src1) >> s1) & 0xff; + switch (combOp) { + case 0: // or + dest |= src; + break; + case 1: // and + dest &= src; + break; + case 2: // xor + dest ^= src; + break; + case 3: // xnor + dest ^= src ^ 0xff; + break; + case 4: // replace + dest = src; + break; + } + *destPtr++ = dest; + } + + dest = *destPtr; + src0 = src1; + src1 = *srcPtr++; + src = (((src0 << 8) | src1) >> s1) & 0xff; + switch (combOp) { + case 0: // or + dest |= src & m2; + break; + case 1: // and + dest &= src | m1; + break; + case 2: // xor + dest ^= src & m2; + break; + case 3: // xnor + dest ^= (src ^ 0xff) & m2; + break; + case 4: // replace + dest = (src & m2) | (dest & m1); + break; + } + *destPtr = dest; + } + } +} +",0,"void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y, + Guint combOp) { + int x0, x1, y0, y1, xx, yy; + Guchar *srcPtr, *destPtr; + Guint src0, src1, src, dest, s1, s2, m1, m2, m3; + GBool oneByte; + + if (y < -0x7fffffff) { + return; + } + if (y < 0) { + y0 = -y; + } else { + y0 = 0; + } + if (y + bitmap->h > h) { + y1 = h - y; + } else { + y1 = bitmap->h; + } + if (y0 >= y1) { + return; + } + + if (x >= 0) { + x0 = x & ~7; + } else { + x0 = 0; + } + x1 = x + bitmap->w; + if (x1 > w) { + x1 = w; + } + if (x0 >= x1) { + return; + } + + s1 = x & 7; + s2 = 8 - s1; + m1 = 0xff >> (x1 & 7); + m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); + m3 = (0xff >> s1) & m2; + + oneByte = x0 == ((x1 - 1) & ~7); + + for (yy = y0; yy < y1; ++yy) { + + if (oneByte) { + if (x >= 0) { + destPtr = data + (y + yy) * line + (x >> 3); + srcPtr = bitmap->data + yy * bitmap->line; + dest = *destPtr; + src1 = *srcPtr; + switch (combOp) { + case 0: // or + dest |= (src1 >> s1) & m2; + break; + case 1: // and + dest &= ((0xff00 | src1) >> s1) | m1; + break; + case 2: // xor + dest ^= (src1 >> s1) & m2; + break; + case 3: // xnor + dest ^= ((src1 ^ 0xff) >> s1) & m2; + break; + case 4: // replace + dest = (dest & ~m3) | ((src1 >> s1) & m3); + break; + } + *destPtr = dest; + } else { + destPtr = data + (y + yy) * line; + srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); + dest = *destPtr; + src1 = *srcPtr; + switch (combOp) { + case 0: // or + dest |= src1 & m2; + break; + case 1: // and + dest &= src1 | m1; + break; + case 2: // xor + dest ^= src1 & m2; + break; + case 3: // xnor + dest ^= (src1 ^ 0xff) & m2; + break; + case 4: // replace + dest = (src1 & m2) | (dest & m1); + break; + } + *destPtr = dest; + } + + } else { + + if (x >= 0) { + destPtr = data + (y + yy) * line + (x >> 3); + srcPtr = bitmap->data + yy * bitmap->line; + src1 = *srcPtr++; + dest = *destPtr; + switch (combOp) { + case 0: // or + dest |= src1 >> s1; + break; + case 1: // and + dest &= (0xff00 | src1) >> s1; + break; + case 2: // xor + dest ^= src1 >> s1; + break; + case 3: // xnor + dest ^= (src1 ^ 0xff) >> s1; + break; + case 4: // replace + dest = (dest & (0xff << s2)) | (src1 >> s1); + break; + } + *destPtr++ = dest; + xx = x0 + 8; + } else { + destPtr = data + (y + yy) * line; + srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); + src1 = *srcPtr++; + xx = x0; + } + + for (; xx < x1 - 8; xx += 8) { + dest = *destPtr; + src0 = src1; + src1 = *srcPtr++; + src = (((src0 << 8) | src1) >> s1) & 0xff; + switch (combOp) { + case 0: // or + dest |= src; + break; + case 1: // and + dest &= src; + break; + case 2: // xor + dest ^= src; + break; + case 3: // xnor + dest ^= src ^ 0xff; + break; + case 4: // replace + dest = src; + break; + } + *destPtr++ = dest; + } + + dest = *destPtr; + src0 = src1; + src1 = *srcPtr++; + src = (((src0 << 8) | src1) >> s1) & 0xff; + switch (combOp) { + case 0: // or + dest |= src & m2; + break; + case 1: // and + dest &= src | m1; + break; + case 2: // xor + dest ^= src & m2; + break; + case 3: // xnor + dest ^= (src ^ 0xff) & m2; + break; + case 4: // replace + dest = (src & m2) | (dest & m1); + break; + } + *destPtr = dest; + } + } +} +","@@ -1495,7 +1495,7 @@ void JBIG2Stream::readSegments() { + // arithmetic-coded symbol dictionary segments when numNewSyms + // == 0. Segments like this often occur for blank pages. + +- error(errSyntaxError, curStr->getPos(), ""{0:d} extraneous byte{1:s} after segment"", ++ error(errSyntaxError, curStr->getPos(), ""{0:lld} extraneous byte{1:s} after segment"", + segExtraBytes, (segExtraBytes > 1) ? ""s"" : """"); + + // Burn through the remaining bytes -- inefficient, but",1344,1580,2048 +7324,"static MagickBooleanType ReadOneLayer(const ImageInfo *image_info,Image* image, + XCFDocInfo* inDocInfo,XCFLayerInfo *outLayer,const ssize_t layer, + ExceptionInfo *exception) +{ + MagickOffsetType + offset; + + unsigned int + foundPropEnd = 0; + + size_t + hierarchy_offset, + layer_mask_offset; + + /* clear the block! */ + (void) ResetMagickMemory( outLayer, 0, sizeof( XCFLayerInfo ) ); + /* read in the layer width, height, type and name */ + outLayer->width = ReadBlobMSBLong(image); + outLayer->height = ReadBlobMSBLong(image); + outLayer->type = ReadBlobMSBLong(image); + (void) ReadBlobStringWithLongSize(image, outLayer->name, + sizeof(outLayer->name),exception); + /* read the layer properties! */ + foundPropEnd = 0; + while ( (foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse) ) { + PropType prop_type = (PropType) ReadBlobMSBLong(image); + size_t prop_size = ReadBlobMSBLong(image); + switch (prop_type) + { + case PROP_END: + foundPropEnd = 1; + break; + case PROP_ACTIVE_LAYER: + outLayer->active = 1; + break; + case PROP_FLOATING_SELECTION: + outLayer->floating_offset = ReadBlobMSBLong(image); + break; + case PROP_OPACITY: + outLayer->alpha = ReadBlobMSBLong(image); + break; + case PROP_VISIBLE: + outLayer->visible = ReadBlobMSBLong(image); + break; + case PROP_LINKED: + outLayer->linked = ReadBlobMSBLong(image); + break; + case PROP_PRESERVE_TRANSPARENCY: + outLayer->preserve_trans = ReadBlobMSBLong(image); + break; + case PROP_APPLY_MASK: + outLayer->apply_mask = ReadBlobMSBLong(image); + break; + case PROP_EDIT_MASK: + outLayer->edit_mask = ReadBlobMSBLong(image); + break; + case PROP_SHOW_MASK: + outLayer->show_mask = ReadBlobMSBLong(image); + break; + case PROP_OFFSETS: + outLayer->offset_x = (int) ReadBlobMSBLong(image); + outLayer->offset_y = (int) ReadBlobMSBLong(image); + break; + case PROP_MODE: + outLayer->mode = ReadBlobMSBLong(image); + break; + case PROP_TATTOO: + outLayer->preserve_trans = ReadBlobMSBLong(image); + break; + case PROP_PARASITES: + { + if (DiscardBlobBytes(image,prop_size) == MagickFalse) + ThrowFileException(exception,CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + + /* + ssize_t base = info->cp; + GimpParasite *p; + while (info->cp - base < prop_size) + { + p = xcf_load_parasite(info); + gimp_drawable_parasite_attach(GIMP_DRAWABLE(layer), p); + gimp_parasite_free(p); + } + if (info->cp - base != prop_size) + g_message (""Error detected while loading a layer's parasites""); + */ + } + break; + default: + /* g_message (""unexpected/unknown layer property: %d (skipping)"", + prop_type); */ + + { + int buf[16]; + ssize_t amount; + + /* read over it... */ + while ((prop_size > 0) && (EOFBlob(image) == MagickFalse)) + { + amount = (ssize_t) MagickMin(16, prop_size); + amount = ReadBlob(image, (size_t) amount, (unsigned char *) &buf); + if (!amount) + ThrowBinaryException(CorruptImageError,""CorruptImage"", + image->filename); + prop_size -= (size_t) MagickMin(16, (size_t) amount); + } + } + break; + } + } + + if (foundPropEnd == MagickFalse) + return(MagickFalse); + /* allocate the image for this layer */ + if (image_info->number_scenes != 0) + { + ssize_t + scene; + + scene=inDocInfo->number_layers-layer-1; + if (scene > (ssize_t) (image_info->scene+image_info->number_scenes-1)) + { + outLayer->image=CloneImage(image,0,0,MagickTrue,exception); + if (outLayer->image == (Image *) NULL) + return(MagickFalse); + InitXCFImage(outLayer,exception); + return(MagickTrue); + } + } + outLayer->image=CloneImage(image,outLayer->width, outLayer->height,MagickTrue, + exception); + if (outLayer->image == (Image *) NULL) + return(MagickFalse); + /* clear the image based on the layer opacity */ + outLayer->image->background_color.alpha= + ScaleCharToQuantum((unsigned char) outLayer->alpha); + (void) SetImageBackgroundColor(outLayer->image,exception); + + InitXCFImage(outLayer,exception); + + /* set the compositing mode */ + outLayer->image->compose = GIMPBlendModeToCompositeOperator( outLayer->mode ); + if ( outLayer->visible == MagickFalse ) + { + /* BOGUS: should really be separate member var! */ + outLayer->image->compose = NoCompositeOp; + } + + /* read the hierarchy and layer mask offsets */ + hierarchy_offset = ReadBlobMSBLong(image); + layer_mask_offset = ReadBlobMSBLong(image); + + /* read in the hierarchy */ + offset=SeekBlob(image, (MagickOffsetType) hierarchy_offset, SEEK_SET); + if (offset < 0) + (void) ThrowMagickException(exception,GetMagickModule(), + CorruptImageError,""InvalidImageHeader"",""`%s'"",image->filename); + if (load_hierarchy (image, inDocInfo, outLayer, exception) == 0) + return(MagickFalse); + + /* read in the layer mask */ + if (layer_mask_offset != 0) + { + offset=SeekBlob(image, (MagickOffsetType) layer_mask_offset, SEEK_SET); + +#if 0 /* BOGUS: support layer masks! */ + layer_mask = xcf_load_layer_mask (info, gimage); + if (layer_mask == 0) + goto error; + + /* set the offsets of the layer_mask */ + GIMP_DRAWABLE (layer_mask)->offset_x = GIMP_DRAWABLE (layer)->offset_x; + GIMP_DRAWABLE (layer_mask)->offset_y = GIMP_DRAWABLE (layer)->offset_y; + + gimp_layer_add_mask (layer, layer_mask, MagickFalse); + + layer->mask->apply_mask = apply_mask; + layer->mask->edit_mask = edit_mask; + layer->mask->show_mask = show_mask; +#endif + } + + /* attach the floating selection... */ +#if 0 /* BOGUS: we may need to read this, even if we don't support it! */ + if (add_floating_sel) + { + GimpLayer *floating_sel; + + floating_sel = info->floating_sel; + floating_sel_attach (floating_sel, GIMP_DRAWABLE (layer)); + } +#endif + + return MagickTrue; +} +",0,"static MagickBooleanType ReadOneLayer(const ImageInfo *image_info,Image* image, + XCFDocInfo* inDocInfo,XCFLayerInfo *outLayer,const ssize_t layer, + ExceptionInfo *exception) +{ + MagickOffsetType + offset; + + unsigned int + foundPropEnd = 0; + + size_t + hierarchy_offset, + layer_mask_offset; + + /* clear the block! */ + (void) ResetMagickMemory( outLayer, 0, sizeof( XCFLayerInfo ) ); + /* read in the layer width, height, type and name */ + outLayer->width = ReadBlobMSBLong(image); + outLayer->height = ReadBlobMSBLong(image); + outLayer->type = ReadBlobMSBLong(image); + (void) ReadBlobStringWithLongSize(image, outLayer->name, + sizeof(outLayer->name),exception); + /* read the layer properties! */ + foundPropEnd = 0; + while ( (foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse) ) { + PropType prop_type = (PropType) ReadBlobMSBLong(image); + size_t prop_size = ReadBlobMSBLong(image); + switch (prop_type) + { + case PROP_END: + foundPropEnd = 1; + break; + case PROP_ACTIVE_LAYER: + outLayer->active = 1; + break; + case PROP_FLOATING_SELECTION: + outLayer->floating_offset = ReadBlobMSBLong(image); + break; + case PROP_OPACITY: + outLayer->alpha = ReadBlobMSBLong(image); + break; + case PROP_VISIBLE: + outLayer->visible = ReadBlobMSBLong(image); + break; + case PROP_LINKED: + outLayer->linked = ReadBlobMSBLong(image); + break; + case PROP_PRESERVE_TRANSPARENCY: + outLayer->preserve_trans = ReadBlobMSBLong(image); + break; + case PROP_APPLY_MASK: + outLayer->apply_mask = ReadBlobMSBLong(image); + break; + case PROP_EDIT_MASK: + outLayer->edit_mask = ReadBlobMSBLong(image); + break; + case PROP_SHOW_MASK: + outLayer->show_mask = ReadBlobMSBLong(image); + break; + case PROP_OFFSETS: + outLayer->offset_x = (int) ReadBlobMSBLong(image); + outLayer->offset_y = (int) ReadBlobMSBLong(image); + break; + case PROP_MODE: + outLayer->mode = ReadBlobMSBLong(image); + break; + case PROP_TATTOO: + outLayer->preserve_trans = ReadBlobMSBLong(image); + break; + case PROP_PARASITES: + { + if (DiscardBlobBytes(image,prop_size) == MagickFalse) + ThrowFileException(exception,CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + + /* + ssize_t base = info->cp; + GimpParasite *p; + while (info->cp - base < prop_size) + { + p = xcf_load_parasite(info); + gimp_drawable_parasite_attach(GIMP_DRAWABLE(layer), p); + gimp_parasite_free(p); + } + if (info->cp - base != prop_size) + g_message (""Error detected while loading a layer's parasites""); + */ + } + break; + default: + /* g_message (""unexpected/unknown layer property: %d (skipping)"", + prop_type); */ + + { + int buf[16]; + ssize_t amount; + + /* read over it... */ + while ((prop_size > 0) && (EOFBlob(image) == MagickFalse)) + { + amount = (ssize_t) MagickMin(16, prop_size); + amount = ReadBlob(image, (size_t) amount, (unsigned char *) &buf); + if (!amount) + ThrowBinaryException(CorruptImageError,""CorruptImage"", + image->filename); + prop_size -= (size_t) MagickMin(16, (size_t) amount); + } + } + break; + } + } + + if (foundPropEnd == MagickFalse) + return(MagickFalse); + /* allocate the image for this layer */ + if (image_info->number_scenes != 0) + { + ssize_t + scene; + + scene=inDocInfo->number_layers-layer-1; + if (scene > (ssize_t) (image_info->scene+image_info->number_scenes-1)) + { + outLayer->image=CloneImage(image,0,0,MagickTrue,exception); + if (outLayer->image == (Image *) NULL) + return(MagickFalse); + InitXCFImage(outLayer,exception); + return(MagickTrue); + } + } + outLayer->image=CloneImage(image,outLayer->width, outLayer->height,MagickTrue, + exception); + if (outLayer->image == (Image *) NULL) + return(MagickFalse); + /* clear the image based on the layer opacity */ + outLayer->image->background_color.alpha= + ScaleCharToQuantum((unsigned char) outLayer->alpha); + (void) SetImageBackgroundColor(outLayer->image,exception); + + InitXCFImage(outLayer,exception); + + /* set the compositing mode */ + outLayer->image->compose = GIMPBlendModeToCompositeOperator( outLayer->mode ); + if ( outLayer->visible == MagickFalse ) + { + /* BOGUS: should really be separate member var! */ + outLayer->image->compose = NoCompositeOp; + } + + /* read the hierarchy and layer mask offsets */ + hierarchy_offset = ReadBlobMSBLong(image); + layer_mask_offset = ReadBlobMSBLong(image); + + /* read in the hierarchy */ + offset=SeekBlob(image, (MagickOffsetType) hierarchy_offset, SEEK_SET); + if (offset < 0) + (void) ThrowMagickException(exception,GetMagickModule(), + CorruptImageError,""InvalidImageHeader"",""`%s'"",image->filename); + if (load_hierarchy (image, inDocInfo, outLayer, exception) == 0) + return(MagickFalse); + + /* read in the layer mask */ + if (layer_mask_offset != 0) + { + offset=SeekBlob(image, (MagickOffsetType) layer_mask_offset, SEEK_SET); + +#if 0 /* BOGUS: support layer masks! */ + layer_mask = xcf_load_layer_mask (info, gimage); + if (layer_mask == 0) + goto error; + + /* set the offsets of the layer_mask */ + GIMP_DRAWABLE (layer_mask)->offset_x = GIMP_DRAWABLE (layer)->offset_x; + GIMP_DRAWABLE (layer_mask)->offset_y = GIMP_DRAWABLE (layer)->offset_y; + + gimp_layer_add_mask (layer, layer_mask, MagickFalse); + + layer->mask->apply_mask = apply_mask; + layer->mask->edit_mask = edit_mask; + layer->mask->show_mask = show_mask; +#endif + } + + /* attach the floating selection... */ +#if 0 /* BOGUS: we may need to read this, even if we don't support it! */ + if (add_floating_sel) + { + GimpLayer *floating_sel; + + floating_sel = info->floating_sel; + floating_sel_attach (floating_sel, GIMP_DRAWABLE (layer)); + } +#endif + + return MagickTrue; +} +","@@ -347,7 +347,8 @@ static MagickBooleanType load_tile(Image *image,Image *tile_image, + *xcfdata, + *xcfodata; + +- xcfdata=(XCFPixelInfo *) AcquireQuantumMemory(data_length,sizeof(*xcfdata)); ++ xcfdata=(XCFPixelInfo *) AcquireQuantumMemory(MagickMax(data_length, ++ tile_image->columns*tile_image->rows),sizeof(*xcfdata)); + if (xcfdata == (XCFPixelInfo *) NULL) + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename);",1616,1852,2048 +7438,"static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64]) +{ + Mpeg4DecContext *ctx = s->avctx->priv_data; + int cbp, mb_type; + const int xy = s->mb_x + s->mb_y * s->mb_stride; + + av_assert2(s == (void*)ctx); + + mb_type = s->current_picture.mb_type[xy]; + cbp = s->cbp_table[xy]; + + ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold; + + if (s->current_picture.qscale_table[xy] != s->qscale) + ff_set_qscale(s, s->current_picture.qscale_table[xy]); + + if (s->pict_type == AV_PICTURE_TYPE_P || + s->pict_type == AV_PICTURE_TYPE_S) { + int i; + for (i = 0; i < 4; i++) { + s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; + s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; + } + s->mb_intra = IS_INTRA(mb_type); + + if (IS_SKIP(mb_type)) { + /* skip mb */ + for (i = 0; i < 6; i++) + s->block_last_index[i] = -1; + s->mv_dir = MV_DIR_FORWARD; + s->mv_type = MV_TYPE_16X16; + if (s->pict_type == AV_PICTURE_TYPE_S + && ctx->vol_sprite_usage == GMC_SPRITE) { + s->mcsel = 1; + s->mb_skipped = 0; + } else { + s->mcsel = 0; + s->mb_skipped = 1; + } + } else if (s->mb_intra) { + s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); + } else if (!s->mb_intra) { + + s->mv_dir = MV_DIR_FORWARD; + if (IS_8X8(mb_type)) { + s->mv_type = MV_TYPE_8X8; + } else { + s->mv_type = MV_TYPE_16X16; + } + } + } else { /* I-Frame */ + s->mb_intra = 1; + s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); + } + + if (!IS_SKIP(mb_type)) { + int i; + s->bdsp.clear_blocks(s->block[0]); + /* decode each block */ + for (i = 0; i < 6; i++) { + if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) { + av_log(s->avctx, AV_LOG_ERROR, + ""texture corrupted at %d %d %d\n"", + s->mb_x, s->mb_y, s->mb_intra); + return AVERROR_INVALIDDATA; + } + cbp += cbp; + } + } + + /* per-MB end of slice check */ + if (--s->mb_num_left <= 0) { + if (mpeg4_is_resync(ctx)) + return SLICE_END; + else + return SLICE_NOEND; + } else { + if (mpeg4_is_resync(ctx)) { + const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1; + if (s->cbp_table[xy + delta]) + return SLICE_END; + } + return SLICE_OK; + } +} +",0,"static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64]) +{ + Mpeg4DecContext *ctx = s->avctx->priv_data; + int cbp, mb_type; + const int xy = s->mb_x + s->mb_y * s->mb_stride; + + av_assert2(s == (void*)ctx); + + mb_type = s->current_picture.mb_type[xy]; + cbp = s->cbp_table[xy]; + + ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold; + + if (s->current_picture.qscale_table[xy] != s->qscale) + ff_set_qscale(s, s->current_picture.qscale_table[xy]); + + if (s->pict_type == AV_PICTURE_TYPE_P || + s->pict_type == AV_PICTURE_TYPE_S) { + int i; + for (i = 0; i < 4; i++) { + s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; + s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; + } + s->mb_intra = IS_INTRA(mb_type); + + if (IS_SKIP(mb_type)) { + /* skip mb */ + for (i = 0; i < 6; i++) + s->block_last_index[i] = -1; + s->mv_dir = MV_DIR_FORWARD; + s->mv_type = MV_TYPE_16X16; + if (s->pict_type == AV_PICTURE_TYPE_S + && ctx->vol_sprite_usage == GMC_SPRITE) { + s->mcsel = 1; + s->mb_skipped = 0; + } else { + s->mcsel = 0; + s->mb_skipped = 1; + } + } else if (s->mb_intra) { + s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); + } else if (!s->mb_intra) { + + s->mv_dir = MV_DIR_FORWARD; + if (IS_8X8(mb_type)) { + s->mv_type = MV_TYPE_8X8; + } else { + s->mv_type = MV_TYPE_16X16; + } + } + } else { /* I-Frame */ + s->mb_intra = 1; + s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]); + } + + if (!IS_SKIP(mb_type)) { + int i; + s->bdsp.clear_blocks(s->block[0]); + /* decode each block */ + for (i = 0; i < 6; i++) { + if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) { + av_log(s->avctx, AV_LOG_ERROR, + ""texture corrupted at %d %d %d\n"", + s->mb_x, s->mb_y, s->mb_intra); + return AVERROR_INVALIDDATA; + } + cbp += cbp; + } + } + + /* per-MB end of slice check */ + if (--s->mb_num_left <= 0) { + if (mpeg4_is_resync(ctx)) + return SLICE_END; + else + return SLICE_NOEND; + } else { + if (mpeg4_is_resync(ctx)) { + const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1; + if (s->cbp_table[xy + delta]) + return SLICE_END; + } + return SLICE_OK; + } +} +","@@ -2867,11 +2867,13 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) + return 0; + } + +-static void read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb) ++static int read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb) + { + int i, j, v; + + if (get_bits1(gb)) { ++ if (get_bits_left(gb) < 64*8) ++ return AVERROR_INVALIDDATA; + /* intra_quantiser_matrix */ + for (i = 0; i < 64; i++) { + v = get_bits(gb, 8); +@@ -2882,13 +2884,17 @@ static void read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb) + } + + if (get_bits1(gb)) { ++ if (get_bits_left(gb) < 64*8) ++ return AVERROR_INVALIDDATA; + /* non_intra_quantiser_matrix */ + for (i = 0; i < 64; i++) { + get_bits(gb, 8); + } + } + + if (get_bits1(gb)) { ++ if (get_bits_left(gb) < 64*8) ++ return AVERROR_INVALIDDATA; + /* chroma_intra_quantiser_matrix */ + for (i = 0; i < 64; i++) { + v = get_bits(gb, 8); +@@ -2898,13 +2904,16 @@ static void read_quant_matrix_ext(MpegEncContext *s, GetBitContext *gb) + } + + if (get_bits1(gb)) { ++ if (get_bits_left(gb) < 64*8) ++ return AVERROR_INVALIDDATA; + /* chroma_non_intra_quantiser_matrix */ + for (i = 0; i < 64; i++) { + get_bits(gb, 8); + } + } + + next_start_code_studio(gb); ++ return 0; + } + + static void extension_and_user_data(MpegEncContext *s, GetBitContext *gb, int id)",837,1073,2048 +6011,"usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + struct usb_device *udev; + struct usbtest_dev *dev; + struct usbtest_info *info; + char *rtest, *wtest; + char *irtest, *iwtest; + char *intrtest, *intwtest; + + udev = interface_to_usbdev(intf); + +#ifdef GENERIC + /* specify devices by module parameters? */ + if (id->match_flags == 0) { + /* vendor match required, product match optional */ + if (!vendor || le16_to_cpu(udev->descriptor.idVendor) != (u16)vendor) + return -ENODEV; + if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) + return -ENODEV; + dev_info(&intf->dev, ""matched module params, "" + ""vend=0x%04x prod=0x%04x\n"", + le16_to_cpu(udev->descriptor.idVendor), + le16_to_cpu(udev->descriptor.idProduct)); + } +#endif + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + info = (struct usbtest_info *) id->driver_info; + dev->info = info; + mutex_init(&dev->lock); + + dev->intf = intf; + + /* cacheline-aligned scratch for i/o */ + dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); + if (dev->buf == NULL) { + kfree(dev); + return -ENOMEM; + } + + /* NOTE this doesn't yet test the handful of difference that are + * visible with high speed interrupts: bigger maxpacket (1K) and + * ""high bandwidth"" modes (up to 3 packets/uframe). + */ + rtest = wtest = """"; + irtest = iwtest = """"; + intrtest = intwtest = """"; + if (force_interrupt || udev->speed == USB_SPEED_LOW) { + if (info->ep_in) { + dev->in_pipe = usb_rcvintpipe(udev, info->ep_in); + rtest = "" intr-in""; + } + if (info->ep_out) { + dev->out_pipe = usb_sndintpipe(udev, info->ep_out); + wtest = "" intr-out""; + } + } else { + if (override_alt >= 0 || info->autoconf) { + int status; + + status = get_endpoints(dev, intf); + if (status < 0) { + WARNING(dev, ""couldn't get endpoints, %d\n"", + status); + kfree(dev->buf); + kfree(dev); + return status; + } + /* may find bulk or ISO pipes */ + } else { + if (info->ep_in) + dev->in_pipe = usb_rcvbulkpipe(udev, + info->ep_in); + if (info->ep_out) + dev->out_pipe = usb_sndbulkpipe(udev, + info->ep_out); + } + if (dev->in_pipe) + rtest = "" bulk-in""; + if (dev->out_pipe) + wtest = "" bulk-out""; + if (dev->in_iso_pipe) + irtest = "" iso-in""; + if (dev->out_iso_pipe) + iwtest = "" iso-out""; + if (dev->in_int_pipe) + intrtest = "" int-in""; + if (dev->out_int_pipe) + intwtest = "" int-out""; + } + + usb_set_intfdata(intf, dev); + dev_info(&intf->dev, ""%s\n"", info->name); + dev_info(&intf->dev, ""%s {control%s%s%s%s%s%s%s} tests%s\n"", + usb_speed_string(udev->speed), + info->ctrl_out ? "" in/out"" : """", + rtest, wtest, + irtest, iwtest, + intrtest, intwtest, + info->alt >= 0 ? "" (+alt)"" : """"); + return 0; +} +",0,"usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + struct usb_device *udev; + struct usbtest_dev *dev; + struct usbtest_info *info; + char *rtest, *wtest; + char *irtest, *iwtest; + char *intrtest, *intwtest; + + udev = interface_to_usbdev(intf); + +#ifdef GENERIC + /* specify devices by module parameters? */ + if (id->match_flags == 0) { + /* vendor match required, product match optional */ + if (!vendor || le16_to_cpu(udev->descriptor.idVendor) != (u16)vendor) + return -ENODEV; + if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) + return -ENODEV; + dev_info(&intf->dev, ""matched module params, "" + ""vend=0x%04x prod=0x%04x\n"", + le16_to_cpu(udev->descriptor.idVendor), + le16_to_cpu(udev->descriptor.idProduct)); + } +#endif + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + info = (struct usbtest_info *) id->driver_info; + dev->info = info; + mutex_init(&dev->lock); + + dev->intf = intf; + + /* cacheline-aligned scratch for i/o */ + dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); + if (dev->buf == NULL) { + kfree(dev); + return -ENOMEM; + } + + /* NOTE this doesn't yet test the handful of difference that are + * visible with high speed interrupts: bigger maxpacket (1K) and + * ""high bandwidth"" modes (up to 3 packets/uframe). + */ + rtest = wtest = """"; + irtest = iwtest = """"; + intrtest = intwtest = """"; + if (force_interrupt || udev->speed == USB_SPEED_LOW) { + if (info->ep_in) { + dev->in_pipe = usb_rcvintpipe(udev, info->ep_in); + rtest = "" intr-in""; + } + if (info->ep_out) { + dev->out_pipe = usb_sndintpipe(udev, info->ep_out); + wtest = "" intr-out""; + } + } else { + if (override_alt >= 0 || info->autoconf) { + int status; + + status = get_endpoints(dev, intf); + if (status < 0) { + WARNING(dev, ""couldn't get endpoints, %d\n"", + status); + kfree(dev->buf); + kfree(dev); + return status; + } + /* may find bulk or ISO pipes */ + } else { + if (info->ep_in) + dev->in_pipe = usb_rcvbulkpipe(udev, + info->ep_in); + if (info->ep_out) + dev->out_pipe = usb_sndbulkpipe(udev, + info->ep_out); + } + if (dev->in_pipe) + rtest = "" bulk-in""; + if (dev->out_pipe) + wtest = "" bulk-out""; + if (dev->in_iso_pipe) + irtest = "" iso-in""; + if (dev->out_iso_pipe) + iwtest = "" iso-out""; + if (dev->in_int_pipe) + intrtest = "" int-in""; + if (dev->out_int_pipe) + intwtest = "" int-out""; + } + + usb_set_intfdata(intf, dev); + dev_info(&intf->dev, ""%s\n"", info->name); + dev_info(&intf->dev, ""%s {control%s%s%s%s%s%s%s} tests%s\n"", + usb_speed_string(udev->speed), + info->ctrl_out ? "" in/out"" : """", + rtest, wtest, + irtest, iwtest, + intrtest, intwtest, + info->alt >= 0 ? "" (+alt)"" : """"); + return 0; +} +","@@ -202,12 +202,13 @@ get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) + return tmp; + } + +- if (in) { ++ if (in) + dev->in_pipe = usb_rcvbulkpipe(udev, + in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); ++ if (out) + dev->out_pipe = usb_sndbulkpipe(udev, + out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); +- } ++ + if (iso_in) { + dev->iso_in = &iso_in->desc; + dev->in_iso_pipe = usb_rcvisocpipe(udev,",886,1122,2048 +7740,"bson_iter_visit_all (bson_iter_t *iter, /* INOUT */ + const bson_visitor_t *visitor, /* IN */ + void *data) /* IN */ +{ + uint32_t bson_type; + const char *key; + bool unsupported; + + BSON_ASSERT (iter); + BSON_ASSERT (visitor); + + while (_bson_iter_next_internal (iter, 0, &key, &bson_type, &unsupported)) { + if (*key && !bson_utf8_validate (key, strlen (key), false)) { + iter->err_off = iter->off; + break; + } + + if (VISIT_BEFORE (iter, key, data)) { + return true; + } + + switch (bson_type) { + case BSON_TYPE_DOUBLE: + + if (VISIT_DOUBLE (iter, key, bson_iter_double (iter), data)) { + return true; + } + + break; + case BSON_TYPE_UTF8: { + uint32_t utf8_len; + const char *utf8; + + utf8 = bson_iter_utf8 (iter, &utf8_len); + + if (!bson_utf8_validate (utf8, utf8_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_UTF8 (iter, key, utf8_len, utf8, data)) { + return true; + } + } break; + case BSON_TYPE_DOCUMENT: { + const uint8_t *docbuf = NULL; + uint32_t doclen = 0; + bson_t b; + + bson_iter_document (iter, &doclen, &docbuf); + + if (bson_init_static (&b, docbuf, doclen) && + VISIT_DOCUMENT (iter, key, &b, data)) { + return true; + } + } break; + case BSON_TYPE_ARRAY: { + const uint8_t *docbuf = NULL; + uint32_t doclen = 0; + bson_t b; + + bson_iter_array (iter, &doclen, &docbuf); + + if (bson_init_static (&b, docbuf, doclen) && + VISIT_ARRAY (iter, key, &b, data)) { + return true; + } + } break; + case BSON_TYPE_BINARY: { + const uint8_t *binary = NULL; + bson_subtype_t subtype = BSON_SUBTYPE_BINARY; + uint32_t binary_len = 0; + + bson_iter_binary (iter, &subtype, &binary_len, &binary); + + if (VISIT_BINARY (iter, key, subtype, binary_len, binary, data)) { + return true; + } + } break; + case BSON_TYPE_UNDEFINED: + + if (VISIT_UNDEFINED (iter, key, data)) { + return true; + } + + break; + case BSON_TYPE_OID: + + if (VISIT_OID (iter, key, bson_iter_oid (iter), data)) { + return true; + } + + break; + case BSON_TYPE_BOOL: + + if (VISIT_BOOL (iter, key, bson_iter_bool (iter), data)) { + return true; + } + + break; + case BSON_TYPE_DATE_TIME: + + if (VISIT_DATE_TIME (iter, key, bson_iter_date_time (iter), data)) { + return true; + } + + break; + case BSON_TYPE_NULL: + + if (VISIT_NULL (iter, key, data)) { + return true; + } + + break; + case BSON_TYPE_REGEX: { + const char *regex = NULL; + const char *options = NULL; + regex = bson_iter_regex (iter, &options); + + if (!bson_utf8_validate (regex, strlen (regex), true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_REGEX (iter, key, regex, options, data)) { + return true; + } + } break; + case BSON_TYPE_DBPOINTER: { + uint32_t collection_len = 0; + const char *collection = NULL; + const bson_oid_t *oid = NULL; + + bson_iter_dbpointer (iter, &collection_len, &collection, &oid); + + if (!bson_utf8_validate (collection, collection_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_DBPOINTER ( + iter, key, collection_len, collection, oid, data)) { + return true; + } + } break; + case BSON_TYPE_CODE: { + uint32_t code_len; + const char *code; + + code = bson_iter_code (iter, &code_len); + + if (!bson_utf8_validate (code, code_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_CODE (iter, key, code_len, code, data)) { + return true; + } + } break; + case BSON_TYPE_SYMBOL: { + uint32_t symbol_len; + const char *symbol; + + symbol = bson_iter_symbol (iter, &symbol_len); + + if (!bson_utf8_validate (symbol, symbol_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_SYMBOL (iter, key, symbol_len, symbol, data)) { + return true; + } + } break; + case BSON_TYPE_CODEWSCOPE: { + uint32_t length = 0; + const char *code; + const uint8_t *docbuf = NULL; + uint32_t doclen = 0; + bson_t b; + + code = bson_iter_codewscope (iter, &length, &doclen, &docbuf); + + if (!bson_utf8_validate (code, length, true)) { + iter->err_off = iter->off; + return true; + } + + if (bson_init_static (&b, docbuf, doclen) && + VISIT_CODEWSCOPE (iter, key, length, code, &b, data)) { + return true; + } + } break; + case BSON_TYPE_INT32: + + if (VISIT_INT32 (iter, key, bson_iter_int32 (iter), data)) { + return true; + } + + break; + case BSON_TYPE_TIMESTAMP: { + uint32_t timestamp; + uint32_t increment; + bson_iter_timestamp (iter, ×tamp, &increment); + + if (VISIT_TIMESTAMP (iter, key, timestamp, increment, data)) { + return true; + } + } break; + case BSON_TYPE_INT64: + + if (VISIT_INT64 (iter, key, bson_iter_int64 (iter), data)) { + return true; + } + + break; + case BSON_TYPE_DECIMAL128: { + bson_decimal128_t dec; + bson_iter_decimal128 (iter, &dec); + + if (VISIT_DECIMAL128 (iter, key, &dec, data)) { + return true; + } + } break; + case BSON_TYPE_MAXKEY: + + if (VISIT_MAXKEY (iter, bson_iter_key_unsafe (iter), data)) { + return true; + } + + break; + case BSON_TYPE_MINKEY: + + if (VISIT_MINKEY (iter, bson_iter_key_unsafe (iter), data)) { + return true; + } + + break; + case BSON_TYPE_EOD: + default: + break; + } + + if (VISIT_AFTER (iter, bson_iter_key_unsafe (iter), data)) { + return true; + } + } + + if (iter->err_off) { + if (unsupported && visitor->visit_unsupported_type && + bson_utf8_validate (key, strlen (key), false)) { + visitor->visit_unsupported_type (iter, key, bson_type, data); + return false; + } + + VISIT_CORRUPT (iter, data); + } + +#undef VISIT_FIELD + + return false; +} +",0,"bson_iter_visit_all (bson_iter_t *iter, /* INOUT */ + const bson_visitor_t *visitor, /* IN */ + void *data) /* IN */ +{ + uint32_t bson_type; + const char *key; + bool unsupported; + + BSON_ASSERT (iter); + BSON_ASSERT (visitor); + + while (_bson_iter_next_internal (iter, 0, &key, &bson_type, &unsupported)) { + if (*key && !bson_utf8_validate (key, strlen (key), false)) { + iter->err_off = iter->off; + break; + } + + if (VISIT_BEFORE (iter, key, data)) { + return true; + } + + switch (bson_type) { + case BSON_TYPE_DOUBLE: + + if (VISIT_DOUBLE (iter, key, bson_iter_double (iter), data)) { + return true; + } + + break; + case BSON_TYPE_UTF8: { + uint32_t utf8_len; + const char *utf8; + + utf8 = bson_iter_utf8 (iter, &utf8_len); + + if (!bson_utf8_validate (utf8, utf8_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_UTF8 (iter, key, utf8_len, utf8, data)) { + return true; + } + } break; + case BSON_TYPE_DOCUMENT: { + const uint8_t *docbuf = NULL; + uint32_t doclen = 0; + bson_t b; + + bson_iter_document (iter, &doclen, &docbuf); + + if (bson_init_static (&b, docbuf, doclen) && + VISIT_DOCUMENT (iter, key, &b, data)) { + return true; + } + } break; + case BSON_TYPE_ARRAY: { + const uint8_t *docbuf = NULL; + uint32_t doclen = 0; + bson_t b; + + bson_iter_array (iter, &doclen, &docbuf); + + if (bson_init_static (&b, docbuf, doclen) && + VISIT_ARRAY (iter, key, &b, data)) { + return true; + } + } break; + case BSON_TYPE_BINARY: { + const uint8_t *binary = NULL; + bson_subtype_t subtype = BSON_SUBTYPE_BINARY; + uint32_t binary_len = 0; + + bson_iter_binary (iter, &subtype, &binary_len, &binary); + + if (VISIT_BINARY (iter, key, subtype, binary_len, binary, data)) { + return true; + } + } break; + case BSON_TYPE_UNDEFINED: + + if (VISIT_UNDEFINED (iter, key, data)) { + return true; + } + + break; + case BSON_TYPE_OID: + + if (VISIT_OID (iter, key, bson_iter_oid (iter), data)) { + return true; + } + + break; + case BSON_TYPE_BOOL: + + if (VISIT_BOOL (iter, key, bson_iter_bool (iter), data)) { + return true; + } + + break; + case BSON_TYPE_DATE_TIME: + + if (VISIT_DATE_TIME (iter, key, bson_iter_date_time (iter), data)) { + return true; + } + + break; + case BSON_TYPE_NULL: + + if (VISIT_NULL (iter, key, data)) { + return true; + } + + break; + case BSON_TYPE_REGEX: { + const char *regex = NULL; + const char *options = NULL; + regex = bson_iter_regex (iter, &options); + + if (!bson_utf8_validate (regex, strlen (regex), true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_REGEX (iter, key, regex, options, data)) { + return true; + } + } break; + case BSON_TYPE_DBPOINTER: { + uint32_t collection_len = 0; + const char *collection = NULL; + const bson_oid_t *oid = NULL; + + bson_iter_dbpointer (iter, &collection_len, &collection, &oid); + + if (!bson_utf8_validate (collection, collection_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_DBPOINTER ( + iter, key, collection_len, collection, oid, data)) { + return true; + } + } break; + case BSON_TYPE_CODE: { + uint32_t code_len; + const char *code; + + code = bson_iter_code (iter, &code_len); + + if (!bson_utf8_validate (code, code_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_CODE (iter, key, code_len, code, data)) { + return true; + } + } break; + case BSON_TYPE_SYMBOL: { + uint32_t symbol_len; + const char *symbol; + + symbol = bson_iter_symbol (iter, &symbol_len); + + if (!bson_utf8_validate (symbol, symbol_len, true)) { + iter->err_off = iter->off; + return true; + } + + if (VISIT_SYMBOL (iter, key, symbol_len, symbol, data)) { + return true; + } + } break; + case BSON_TYPE_CODEWSCOPE: { + uint32_t length = 0; + const char *code; + const uint8_t *docbuf = NULL; + uint32_t doclen = 0; + bson_t b; + + code = bson_iter_codewscope (iter, &length, &doclen, &docbuf); + + if (!bson_utf8_validate (code, length, true)) { + iter->err_off = iter->off; + return true; + } + + if (bson_init_static (&b, docbuf, doclen) && + VISIT_CODEWSCOPE (iter, key, length, code, &b, data)) { + return true; + } + } break; + case BSON_TYPE_INT32: + + if (VISIT_INT32 (iter, key, bson_iter_int32 (iter), data)) { + return true; + } + + break; + case BSON_TYPE_TIMESTAMP: { + uint32_t timestamp; + uint32_t increment; + bson_iter_timestamp (iter, ×tamp, &increment); + + if (VISIT_TIMESTAMP (iter, key, timestamp, increment, data)) { + return true; + } + } break; + case BSON_TYPE_INT64: + + if (VISIT_INT64 (iter, key, bson_iter_int64 (iter), data)) { + return true; + } + + break; + case BSON_TYPE_DECIMAL128: { + bson_decimal128_t dec; + bson_iter_decimal128 (iter, &dec); + + if (VISIT_DECIMAL128 (iter, key, &dec, data)) { + return true; + } + } break; + case BSON_TYPE_MAXKEY: + + if (VISIT_MAXKEY (iter, bson_iter_key_unsafe (iter), data)) { + return true; + } + + break; + case BSON_TYPE_MINKEY: + + if (VISIT_MINKEY (iter, bson_iter_key_unsafe (iter), data)) { + return true; + } + + break; + case BSON_TYPE_EOD: + default: + break; + } + + if (VISIT_AFTER (iter, bson_iter_key_unsafe (iter), data)) { + return true; + } + } + + if (iter->err_off) { + if (unsupported && visitor->visit_unsupported_type && + bson_utf8_validate (key, strlen (key), false)) { + visitor->visit_unsupported_type (iter, key, bson_type, data); + return false; + } + + VISIT_CORRUPT (iter, data); + } + +#undef VISIT_FIELD + + return false; +} +","@@ -618,7 +618,7 @@ _bson_iter_next_internal (bson_iter_t *iter, /* INOUT */ + memcpy (&l, iter->raw + iter->d1, sizeof (l)); + l = BSON_UINT32_FROM_LE (l); + +- if (l >= (len - o)) { ++ if (l >= (len - o - 4)) { + iter->err_off = o; + goto mark_invalid; + }",1696,1932,2048 +9098,"static MagickBooleanType WriteMETAImage(const ImageInfo *image_info, + Image *image,ExceptionInfo *exception) +{ + const StringInfo + *profile; + + MagickBooleanType + status; + + size_t + length; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + length=0; + if (LocaleCompare(image_info->magick,""8BIM"") == 0) + { + /* + Write 8BIM image. + */ + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""iptc"") == 0) + { + size_t + length; + + unsigned char + *info; + + profile=GetImageProfile(image,""iptc""); + if (profile == (StringInfo *) NULL) + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + info=GetStringInfoDatum(profile); + length=GetStringInfoLength(profile); + length=GetIPTCStream(&info,length); + if (length == 0) + ThrowWriterException(CoderError,""NoIPTCProfileAvailable""); + (void) WriteBlob(image,length,info); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""8BIMTEXT"") == 0) + { + Image + *buff; + + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + buff=AcquireImage((ImageInfo *) NULL,exception); + if (buff == (Image *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + AttachBlob(buff->blob,GetStringInfoDatum(profile), + GetStringInfoLength(profile)); + format8BIM(buff,image); + (void) DetachBlob(buff->blob); + buff=DestroyImage(buff); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""8BIMWTEXT"") == 0) + return(MagickFalse); + if (LocaleCompare(image_info->magick,""IPTCTEXT"") == 0) + { + Image + *buff; + + unsigned char + *info; + + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + info=GetStringInfoDatum(profile); + length=GetStringInfoLength(profile); + length=GetIPTCStream(&info,length); + if (length == 0) + ThrowWriterException(CoderError,""NoIPTCProfileAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + buff=AcquireImage((ImageInfo *) NULL,exception); + if (buff == (Image *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + AttachBlob(buff->blob,info,length); + formatIPTC(buff,image); + (void) DetachBlob(buff->blob); + buff=DestroyImage(buff); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""IPTCWTEXT"") == 0) + return(MagickFalse); + if ((LocaleCompare(image_info->magick,""APP1"") == 0) || + (LocaleCompare(image_info->magick,""EXIF"") == 0) || + (LocaleCompare(image_info->magick,""XMP"") == 0)) + { + /* + (void) Write APP1 image. + */ + profile=GetImageProfile(image,image_info->magick); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""NoAPP1DataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) CloseBlob(image); + return(MagickTrue); + } + if ((LocaleCompare(image_info->magick,""ICC"") == 0) || + (LocaleCompare(image_info->magick,""ICM"") == 0)) + { + /* + Write ICM image. + */ + profile=GetImageProfile(image,""icc""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""NoColorProfileIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) CloseBlob(image); + return(MagickTrue); + } + return(MagickFalse); +} +",0,"static MagickBooleanType WriteMETAImage(const ImageInfo *image_info, + Image *image,ExceptionInfo *exception) +{ + const StringInfo + *profile; + + MagickBooleanType + status; + + size_t + length; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + length=0; + if (LocaleCompare(image_info->magick,""8BIM"") == 0) + { + /* + Write 8BIM image. + */ + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""iptc"") == 0) + { + size_t + length; + + unsigned char + *info; + + profile=GetImageProfile(image,""iptc""); + if (profile == (StringInfo *) NULL) + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + info=GetStringInfoDatum(profile); + length=GetStringInfoLength(profile); + length=GetIPTCStream(&info,length); + if (length == 0) + ThrowWriterException(CoderError,""NoIPTCProfileAvailable""); + (void) WriteBlob(image,length,info); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""8BIMTEXT"") == 0) + { + Image + *buff; + + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + buff=AcquireImage((ImageInfo *) NULL,exception); + if (buff == (Image *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + AttachBlob(buff->blob,GetStringInfoDatum(profile), + GetStringInfoLength(profile)); + format8BIM(buff,image); + (void) DetachBlob(buff->blob); + buff=DestroyImage(buff); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""8BIMWTEXT"") == 0) + return(MagickFalse); + if (LocaleCompare(image_info->magick,""IPTCTEXT"") == 0) + { + Image + *buff; + + unsigned char + *info; + + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""No8BIMDataIsAvailable""); + info=GetStringInfoDatum(profile); + length=GetStringInfoLength(profile); + length=GetIPTCStream(&info,length); + if (length == 0) + ThrowWriterException(CoderError,""NoIPTCProfileAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + buff=AcquireImage((ImageInfo *) NULL,exception); + if (buff == (Image *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + AttachBlob(buff->blob,info,length); + formatIPTC(buff,image); + (void) DetachBlob(buff->blob); + buff=DestroyImage(buff); + (void) CloseBlob(image); + return(MagickTrue); + } + if (LocaleCompare(image_info->magick,""IPTCWTEXT"") == 0) + return(MagickFalse); + if ((LocaleCompare(image_info->magick,""APP1"") == 0) || + (LocaleCompare(image_info->magick,""EXIF"") == 0) || + (LocaleCompare(image_info->magick,""XMP"") == 0)) + { + /* + (void) Write APP1 image. + */ + profile=GetImageProfile(image,image_info->magick); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""NoAPP1DataIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) CloseBlob(image); + return(MagickTrue); + } + if ((LocaleCompare(image_info->magick,""ICC"") == 0) || + (LocaleCompare(image_info->magick,""ICM"") == 0)) + { + /* + Write ICM image. + */ + profile=GetImageProfile(image,""icc""); + if (profile == (StringInfo *) NULL) + ThrowWriterException(CoderError,""NoColorProfileIsAvailable""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) CloseBlob(image); + return(MagickTrue); + } + return(MagickFalse); +} +","@@ -2204,7 +2204,7 @@ static int format8BIM(Image *ifile, Image *ofile) + return -1; + } + /* make a buffer to hold the data and snag it from the input stream */ +- str=(unsigned char *) AcquireQuantumMemory((size_t) count,sizeof(*str)); ++ str=(unsigned char *) AcquireQuantumMemory((size_t) count+1,sizeof(*str)); + if (str == (unsigned char *) NULL) + { + PString=(unsigned char *) RelinquishMagickMemory(PString);",1404,1640,2048 +7919,"int imap_cmd_step(struct ImapData *idata) +{ + size_t len = 0; + int c; + int rc; + int stillrunning = 0; + struct ImapCommand *cmd = NULL; + + if (idata->status == IMAP_FATAL) + { + cmd_handle_fatal(idata); + return IMAP_CMD_BAD; + } + + /* read into buffer, expanding buffer as necessary until we have a full + * line */ + do + { + if (len == idata->blen) + { + mutt_mem_realloc(&idata->buf, idata->blen + IMAP_CMD_BUFSIZE); + idata->blen = idata->blen + IMAP_CMD_BUFSIZE; + mutt_debug(3, ""grew buffer to %u bytes\n"", idata->blen); + } + + /* back up over '\0' */ + if (len) + len--; + c = mutt_socket_readln(idata->buf + len, idata->blen - len, idata->conn); + if (c <= 0) + { + mutt_debug(1, ""Error reading server response.\n""); + cmd_handle_fatal(idata); + return IMAP_CMD_BAD; + } + + len += c; + } + /* if we've read all the way to the end of the buffer, we haven't read a + * full line (mutt_socket_readln strips the \r, so we always have at least + * one character free when we've read a full line) */ + while (len == idata->blen); + + /* don't let one large string make cmd->buf hog memory forever */ + if ((idata->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE)) + { + mutt_mem_realloc(&idata->buf, IMAP_CMD_BUFSIZE); + idata->blen = IMAP_CMD_BUFSIZE; + mutt_debug(3, ""shrank buffer to %u bytes\n"", idata->blen); + } + + idata->lastread = time(NULL); + + /* handle untagged messages. The caller still gets its shot afterwards. */ + if (((mutt_str_strncmp(idata->buf, ""* "", 2) == 0) || + (mutt_str_strncmp(imap_next_word(idata->buf), ""OK ["", 4) == 0)) && + cmd_handle_untagged(idata)) + { + return IMAP_CMD_BAD; + } + + /* server demands a continuation response from us */ + if (idata->buf[0] == '+') + return IMAP_CMD_RESPOND; + + /* Look for tagged command completions. + * + * Some response handlers can end up recursively calling + * imap_cmd_step() and end up handling all tagged command + * completions. + * (e.g. FETCH->set_flag->set_header_color->~h pattern match.) + * + * Other callers don't even create an idata->cmds entry. + * + * For both these cases, we default to returning OK */ + rc = IMAP_CMD_OK; + c = idata->lastcmd; + do + { + cmd = &idata->cmds[c]; + if (cmd->state == IMAP_CMD_NEW) + { + if (mutt_str_strncmp(idata->buf, cmd->seq, SEQLEN) == 0) + { + if (!stillrunning) + { + /* first command in queue has finished - move queue pointer up */ + idata->lastcmd = (idata->lastcmd + 1) % idata->cmdslots; + } + cmd->state = cmd_status(idata->buf); + /* bogus - we don't know which command result to return here. Caller + * should provide a tag. */ + rc = cmd->state; + } + else + stillrunning++; + } + + c = (c + 1) % idata->cmdslots; + } while (c != idata->nextcmd); + + if (stillrunning) + rc = IMAP_CMD_CONTINUE; + else + { + mutt_debug(3, ""IMAP queue drained\n""); + imap_cmd_finish(idata); + } + + return rc; +} +",0,"int imap_cmd_step(struct ImapData *idata) +{ + size_t len = 0; + int c; + int rc; + int stillrunning = 0; + struct ImapCommand *cmd = NULL; + + if (idata->status == IMAP_FATAL) + { + cmd_handle_fatal(idata); + return IMAP_CMD_BAD; + } + + /* read into buffer, expanding buffer as necessary until we have a full + * line */ + do + { + if (len == idata->blen) + { + mutt_mem_realloc(&idata->buf, idata->blen + IMAP_CMD_BUFSIZE); + idata->blen = idata->blen + IMAP_CMD_BUFSIZE; + mutt_debug(3, ""grew buffer to %u bytes\n"", idata->blen); + } + + /* back up over '\0' */ + if (len) + len--; + c = mutt_socket_readln(idata->buf + len, idata->blen - len, idata->conn); + if (c <= 0) + { + mutt_debug(1, ""Error reading server response.\n""); + cmd_handle_fatal(idata); + return IMAP_CMD_BAD; + } + + len += c; + } + /* if we've read all the way to the end of the buffer, we haven't read a + * full line (mutt_socket_readln strips the \r, so we always have at least + * one character free when we've read a full line) */ + while (len == idata->blen); + + /* don't let one large string make cmd->buf hog memory forever */ + if ((idata->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE)) + { + mutt_mem_realloc(&idata->buf, IMAP_CMD_BUFSIZE); + idata->blen = IMAP_CMD_BUFSIZE; + mutt_debug(3, ""shrank buffer to %u bytes\n"", idata->blen); + } + + idata->lastread = time(NULL); + + /* handle untagged messages. The caller still gets its shot afterwards. */ + if (((mutt_str_strncmp(idata->buf, ""* "", 2) == 0) || + (mutt_str_strncmp(imap_next_word(idata->buf), ""OK ["", 4) == 0)) && + cmd_handle_untagged(idata)) + { + return IMAP_CMD_BAD; + } + + /* server demands a continuation response from us */ + if (idata->buf[0] == '+') + return IMAP_CMD_RESPOND; + + /* Look for tagged command completions. + * + * Some response handlers can end up recursively calling + * imap_cmd_step() and end up handling all tagged command + * completions. + * (e.g. FETCH->set_flag->set_header_color->~h pattern match.) + * + * Other callers don't even create an idata->cmds entry. + * + * For both these cases, we default to returning OK */ + rc = IMAP_CMD_OK; + c = idata->lastcmd; + do + { + cmd = &idata->cmds[c]; + if (cmd->state == IMAP_CMD_NEW) + { + if (mutt_str_strncmp(idata->buf, cmd->seq, SEQLEN) == 0) + { + if (!stillrunning) + { + /* first command in queue has finished - move queue pointer up */ + idata->lastcmd = (idata->lastcmd + 1) % idata->cmdslots; + } + cmd->state = cmd_status(idata->buf); + /* bogus - we don't know which command result to return here. Caller + * should provide a tag. */ + rc = cmd->state; + } + else + stillrunning++; + } + + c = (c + 1) % idata->cmdslots; + } while (c != idata->nextcmd); + + if (stillrunning) + rc = IMAP_CMD_CONTINUE; + else + { + mutt_debug(3, ""IMAP queue drained\n""); + imap_cmd_finish(idata); + } + + return rc; +} +","@@ -499,7 +499,7 @@ static void cmd_parse_lsub(struct ImapData *idata, char *s) + mutt_str_strfcpy(buf, ""mailboxes \"""", sizeof(buf)); + mutt_account_tourl(&idata->conn->account, &url); + /* escape \ and "" */ +- imap_quote_string(errstr, sizeof(errstr), list.name); ++ imap_quote_string(errstr, sizeof(errstr), list.name, true); + url.path = errstr + 1; + url.path[strlen(url.path) - 1] = '\0'; + if (mutt_str_strcmp(url.user, ImapUser) == 0)",908,1144,2048 +879,"static uint32_t vmsvga_value_read(void *opaque, uint32_t address) +{ + uint32_t caps; + struct vmsvga_state_s *s = opaque; + DisplaySurface *surface = qemu_console_surface(s->vga.con); + PixelFormat pf; + uint32_t ret; + + switch (s->index) { + case SVGA_REG_ID: + ret = s->svgaid; + break; + + case SVGA_REG_ENABLE: + ret = s->enable; + break; + + case SVGA_REG_WIDTH: + ret = s->new_width ? s->new_width : surface_width(surface); + break; + + case SVGA_REG_HEIGHT: + ret = s->new_height ? s->new_height : surface_height(surface); + break; + + case SVGA_REG_MAX_WIDTH: + ret = SVGA_MAX_WIDTH; + break; + + case SVGA_REG_MAX_HEIGHT: + ret = SVGA_MAX_HEIGHT; + break; + + case SVGA_REG_DEPTH: + ret = (s->new_depth == 32) ? 24 : s->new_depth; + break; + + case SVGA_REG_BITS_PER_PIXEL: + case SVGA_REG_HOST_BITS_PER_PIXEL: + ret = s->new_depth; + break; + + case SVGA_REG_PSEUDOCOLOR: + ret = 0x0; + break; + + case SVGA_REG_RED_MASK: + pf = qemu_default_pixelformat(s->new_depth); + ret = pf.rmask; + break; + + case SVGA_REG_GREEN_MASK: + pf = qemu_default_pixelformat(s->new_depth); + ret = pf.gmask; + break; + + case SVGA_REG_BLUE_MASK: + pf = qemu_default_pixelformat(s->new_depth); + ret = pf.bmask; + break; + + case SVGA_REG_BYTES_PER_LINE: + if (s->new_width) { + ret = (s->new_depth * s->new_width) / 8; + } else { + ret = surface_stride(surface); + } + break; + + case SVGA_REG_FB_START: { + struct pci_vmsvga_state_s *pci_vmsvga + = container_of(s, struct pci_vmsvga_state_s, chip); + ret = pci_get_bar_addr(PCI_DEVICE(pci_vmsvga), 1); + break; + } + + case SVGA_REG_FB_OFFSET: + ret = 0x0; + break; + + case SVGA_REG_VRAM_SIZE: + ret = s->vga.vram_size; /* No physical VRAM besides the framebuffer */ + break; + + case SVGA_REG_FB_SIZE: + ret = s->vga.vram_size; + break; + + case SVGA_REG_CAPABILITIES: + caps = SVGA_CAP_NONE; +#ifdef HW_RECT_ACCEL + caps |= SVGA_CAP_RECT_COPY; +#endif +#ifdef HW_FILL_ACCEL + caps |= SVGA_CAP_RECT_FILL; +#endif +#ifdef HW_MOUSE_ACCEL + if (dpy_cursor_define_supported(s->vga.con)) { + caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | + SVGA_CAP_CURSOR_BYPASS; + } +#endif + ret = caps; + break; + + case SVGA_REG_MEM_START: { + struct pci_vmsvga_state_s *pci_vmsvga + = container_of(s, struct pci_vmsvga_state_s, chip); + ret = pci_get_bar_addr(PCI_DEVICE(pci_vmsvga), 2); + break; + } + + case SVGA_REG_MEM_SIZE: + ret = s->fifo_size; + break; + + case SVGA_REG_CONFIG_DONE: + ret = s->config; + break; + + case SVGA_REG_SYNC: + case SVGA_REG_BUSY: + ret = s->syncing; + break; + + case SVGA_REG_GUEST_ID: + ret = s->guest; + break; + + case SVGA_REG_CURSOR_ID: + ret = s->cursor.id; + break; + + case SVGA_REG_CURSOR_X: + ret = s->cursor.x; + break; + + case SVGA_REG_CURSOR_Y: + ret = s->cursor.y; + break; + + case SVGA_REG_CURSOR_ON: + ret = s->cursor.on; + break; + + case SVGA_REG_SCRATCH_SIZE: + ret = s->scratch_size; + break; + + case SVGA_REG_MEM_REGS: + case SVGA_REG_NUM_DISPLAYS: + case SVGA_REG_PITCHLOCK: + case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: + ret = 0; + break; + + default: + if (s->index >= SVGA_SCRATCH_BASE && + s->index < SVGA_SCRATCH_BASE + s->scratch_size) { + ret = s->scratch[s->index - SVGA_SCRATCH_BASE]; + break; + } + printf(""%s: Bad register %02x\n"", __func__, s->index); + ret = 0; + break; + } + + if (s->index >= SVGA_SCRATCH_BASE) { + trace_vmware_scratch_read(s->index, ret); + } else if (s->index >= SVGA_PALETTE_BASE) { + trace_vmware_palette_read(s->index, ret); + } else { + trace_vmware_value_read(s->index, ret); + } + return ret; +} +",0,"static uint32_t vmsvga_value_read(void *opaque, uint32_t address) +{ + uint32_t caps; + struct vmsvga_state_s *s = opaque; + DisplaySurface *surface = qemu_console_surface(s->vga.con); + PixelFormat pf; + uint32_t ret; + + switch (s->index) { + case SVGA_REG_ID: + ret = s->svgaid; + break; + + case SVGA_REG_ENABLE: + ret = s->enable; + break; + + case SVGA_REG_WIDTH: + ret = s->new_width ? s->new_width : surface_width(surface); + break; + + case SVGA_REG_HEIGHT: + ret = s->new_height ? s->new_height : surface_height(surface); + break; + + case SVGA_REG_MAX_WIDTH: + ret = SVGA_MAX_WIDTH; + break; + + case SVGA_REG_MAX_HEIGHT: + ret = SVGA_MAX_HEIGHT; + break; + + case SVGA_REG_DEPTH: + ret = (s->new_depth == 32) ? 24 : s->new_depth; + break; + + case SVGA_REG_BITS_PER_PIXEL: + case SVGA_REG_HOST_BITS_PER_PIXEL: + ret = s->new_depth; + break; + + case SVGA_REG_PSEUDOCOLOR: + ret = 0x0; + break; + + case SVGA_REG_RED_MASK: + pf = qemu_default_pixelformat(s->new_depth); + ret = pf.rmask; + break; + + case SVGA_REG_GREEN_MASK: + pf = qemu_default_pixelformat(s->new_depth); + ret = pf.gmask; + break; + + case SVGA_REG_BLUE_MASK: + pf = qemu_default_pixelformat(s->new_depth); + ret = pf.bmask; + break; + + case SVGA_REG_BYTES_PER_LINE: + if (s->new_width) { + ret = (s->new_depth * s->new_width) / 8; + } else { + ret = surface_stride(surface); + } + break; + + case SVGA_REG_FB_START: { + struct pci_vmsvga_state_s *pci_vmsvga + = container_of(s, struct pci_vmsvga_state_s, chip); + ret = pci_get_bar_addr(PCI_DEVICE(pci_vmsvga), 1); + break; + } + + case SVGA_REG_FB_OFFSET: + ret = 0x0; + break; + + case SVGA_REG_VRAM_SIZE: + ret = s->vga.vram_size; /* No physical VRAM besides the framebuffer */ + break; + + case SVGA_REG_FB_SIZE: + ret = s->vga.vram_size; + break; + + case SVGA_REG_CAPABILITIES: + caps = SVGA_CAP_NONE; +#ifdef HW_RECT_ACCEL + caps |= SVGA_CAP_RECT_COPY; +#endif +#ifdef HW_FILL_ACCEL + caps |= SVGA_CAP_RECT_FILL; +#endif +#ifdef HW_MOUSE_ACCEL + if (dpy_cursor_define_supported(s->vga.con)) { + caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 | + SVGA_CAP_CURSOR_BYPASS; + } +#endif + ret = caps; + break; + + case SVGA_REG_MEM_START: { + struct pci_vmsvga_state_s *pci_vmsvga + = container_of(s, struct pci_vmsvga_state_s, chip); + ret = pci_get_bar_addr(PCI_DEVICE(pci_vmsvga), 2); + break; + } + + case SVGA_REG_MEM_SIZE: + ret = s->fifo_size; + break; + + case SVGA_REG_CONFIG_DONE: + ret = s->config; + break; + + case SVGA_REG_SYNC: + case SVGA_REG_BUSY: + ret = s->syncing; + break; + + case SVGA_REG_GUEST_ID: + ret = s->guest; + break; + + case SVGA_REG_CURSOR_ID: + ret = s->cursor.id; + break; + + case SVGA_REG_CURSOR_X: + ret = s->cursor.x; + break; + + case SVGA_REG_CURSOR_Y: + ret = s->cursor.y; + break; + + case SVGA_REG_CURSOR_ON: + ret = s->cursor.on; + break; + + case SVGA_REG_SCRATCH_SIZE: + ret = s->scratch_size; + break; + + case SVGA_REG_MEM_REGS: + case SVGA_REG_NUM_DISPLAYS: + case SVGA_REG_PITCHLOCK: + case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: + ret = 0; + break; + + default: + if (s->index >= SVGA_SCRATCH_BASE && + s->index < SVGA_SCRATCH_BASE + s->scratch_size) { + ret = s->scratch[s->index - SVGA_SCRATCH_BASE]; + break; + } + printf(""%s: Bad register %02x\n"", __func__, s->index); + ret = 0; + break; + } + + if (s->index >= SVGA_SCRATCH_BASE) { + trace_vmware_scratch_read(s->index, ret); + } else if (s->index >= SVGA_PALETTE_BASE) { + trace_vmware_palette_read(s->index, ret); + } else { + trace_vmware_value_read(s->index, ret); + } + return ret; +} +","@@ -676,11 +676,13 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) + cursor.bpp = vmsvga_fifo_read(s); + + args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp); +- if (cursor.width > 256 || +- cursor.height > 256 || +- cursor.bpp > 32 || +- SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask || +- SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) { ++ if (cursor.width > 256 ++ || cursor.height > 256 ++ || cursor.bpp > 32 ++ || SVGA_BITMAP_SIZE(x, y) ++ > sizeof(cursor.mask) / sizeof(cursor.mask[0]) ++ || SVGA_PIXMAP_SIZE(x, y, cursor.bpp) ++ > sizeof(cursor.image) / sizeof(cursor.image[0])) { + goto badcmd; + }",1144,1380,2048 +8380,"static inline int DetectRunInspectRuleHeader( + const Packet *p, + const Flow *f, + const Signature *s, + const uint32_t sflags, + const uint8_t s_proto_flags) +{ + /* check if this signature has a requirement for flowvars of some type + * and if so, if we actually have any in the flow. If not, the sig + * can't match and we skip it. */ + if ((p->flags & PKT_HAS_FLOW) && (sflags & SIG_FLAG_REQUIRE_FLOWVAR)) { + int m = f->flowvar ? 1 : 0; + + /* no flowvars? skip this sig */ + if (m == 0) { + SCLogDebug(""skipping sig as the flow has no flowvars and sig "" + ""has SIG_FLAG_REQUIRE_FLOWVAR flag set.""); + return 0; + } + } + + if ((s_proto_flags & DETECT_PROTO_IPV4) && !PKT_IS_IPV4(p)) { + SCLogDebug(""ip version didn't match""); + return 0; + } + if ((s_proto_flags & DETECT_PROTO_IPV6) && !PKT_IS_IPV6(p)) { + SCLogDebug(""ip version didn't match""); + return 0; + } + + if (DetectProtoContainsProto(&s->proto, IP_GET_IPPROTO(p)) == 0) { + SCLogDebug(""proto didn't match""); + return 0; + } + + /* check the source & dst port in the sig */ + if (p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP || p->proto == IPPROTO_SCTP) { + if (!(sflags & SIG_FLAG_DP_ANY)) { + if (p->flags & PKT_IS_FRAGMENT) + return 0; + DetectPort *dport = DetectPortLookupGroup(s->dp,p->dp); + if (dport == NULL) { + SCLogDebug(""dport didn't match.""); + return 0; + } + } + if (!(sflags & SIG_FLAG_SP_ANY)) { + if (p->flags & PKT_IS_FRAGMENT) + return 0; + DetectPort *sport = DetectPortLookupGroup(s->sp,p->sp); + if (sport == NULL) { + SCLogDebug(""sport didn't match.""); + return 0; + } + } + } else if ((sflags & (SIG_FLAG_DP_ANY|SIG_FLAG_SP_ANY)) != (SIG_FLAG_DP_ANY|SIG_FLAG_SP_ANY)) { + SCLogDebug(""port-less protocol and sig needs ports""); + return 0; + } + + /* check the destination address */ + if (!(sflags & SIG_FLAG_DST_ANY)) { + if (PKT_IS_IPV4(p)) { + if (DetectAddressMatchIPv4(s->addr_dst_match4, s->addr_dst_match4_cnt, &p->dst) == 0) + return 0; + } else if (PKT_IS_IPV6(p)) { + if (DetectAddressMatchIPv6(s->addr_dst_match6, s->addr_dst_match6_cnt, &p->dst) == 0) + return 0; + } + } + /* check the source address */ + if (!(sflags & SIG_FLAG_SRC_ANY)) { + if (PKT_IS_IPV4(p)) { + if (DetectAddressMatchIPv4(s->addr_src_match4, s->addr_src_match4_cnt, &p->src) == 0) + return 0; + } else if (PKT_IS_IPV6(p)) { + if (DetectAddressMatchIPv6(s->addr_src_match6, s->addr_src_match6_cnt, &p->src) == 0) + return 0; + } + } + + return 1; +} +",0,"static inline int DetectRunInspectRuleHeader( + const Packet *p, + const Flow *f, + const Signature *s, + const uint32_t sflags, + const uint8_t s_proto_flags) +{ + /* check if this signature has a requirement for flowvars of some type + * and if so, if we actually have any in the flow. If not, the sig + * can't match and we skip it. */ + if ((p->flags & PKT_HAS_FLOW) && (sflags & SIG_FLAG_REQUIRE_FLOWVAR)) { + int m = f->flowvar ? 1 : 0; + + /* no flowvars? skip this sig */ + if (m == 0) { + SCLogDebug(""skipping sig as the flow has no flowvars and sig "" + ""has SIG_FLAG_REQUIRE_FLOWVAR flag set.""); + return 0; + } + } + + if ((s_proto_flags & DETECT_PROTO_IPV4) && !PKT_IS_IPV4(p)) { + SCLogDebug(""ip version didn't match""); + return 0; + } + if ((s_proto_flags & DETECT_PROTO_IPV6) && !PKT_IS_IPV6(p)) { + SCLogDebug(""ip version didn't match""); + return 0; + } + + if (DetectProtoContainsProto(&s->proto, IP_GET_IPPROTO(p)) == 0) { + SCLogDebug(""proto didn't match""); + return 0; + } + + /* check the source & dst port in the sig */ + if (p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP || p->proto == IPPROTO_SCTP) { + if (!(sflags & SIG_FLAG_DP_ANY)) { + if (p->flags & PKT_IS_FRAGMENT) + return 0; + DetectPort *dport = DetectPortLookupGroup(s->dp,p->dp); + if (dport == NULL) { + SCLogDebug(""dport didn't match.""); + return 0; + } + } + if (!(sflags & SIG_FLAG_SP_ANY)) { + if (p->flags & PKT_IS_FRAGMENT) + return 0; + DetectPort *sport = DetectPortLookupGroup(s->sp,p->sp); + if (sport == NULL) { + SCLogDebug(""sport didn't match.""); + return 0; + } + } + } else if ((sflags & (SIG_FLAG_DP_ANY|SIG_FLAG_SP_ANY)) != (SIG_FLAG_DP_ANY|SIG_FLAG_SP_ANY)) { + SCLogDebug(""port-less protocol and sig needs ports""); + return 0; + } + + /* check the destination address */ + if (!(sflags & SIG_FLAG_DST_ANY)) { + if (PKT_IS_IPV4(p)) { + if (DetectAddressMatchIPv4(s->addr_dst_match4, s->addr_dst_match4_cnt, &p->dst) == 0) + return 0; + } else if (PKT_IS_IPV6(p)) { + if (DetectAddressMatchIPv6(s->addr_dst_match6, s->addr_dst_match6_cnt, &p->dst) == 0) + return 0; + } + } + /* check the source address */ + if (!(sflags & SIG_FLAG_SRC_ANY)) { + if (PKT_IS_IPV4(p)) { + if (DetectAddressMatchIPv4(s->addr_src_match4, s->addr_src_match4_cnt, &p->src) == 0) + return 0; + } else if (PKT_IS_IPV6(p)) { + if (DetectAddressMatchIPv6(s->addr_src_match6, s->addr_src_match6_cnt, &p->src) == 0) + return 0; + } + } + + return 1; +} +","@@ -1610,10 +1610,7 @@ static void DetectFlow(ThreadVars *tv, + DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, + Packet *p) + { +- /* No need to perform any detection on this packet, if the the given flag is set.*/ +- if ((p->flags & PKT_NOPACKET_INSPECTION) || +- (PACKET_TEST_ACTION(p, ACTION_DROP))) +- { ++ if (p->flags & PKT_NOPACKET_INSPECTION) { + /* hack: if we are in pass the entire flow mode, we need to still + * update the inspect_id forward. So test for the condition here, + * and call the update code if necessary. */ +@@ -1629,6 +1626,8 @@ static void DetectFlow(ThreadVars *tv, + flags = FlowGetDisruptionFlags(p->flow, flags); + DeStateUpdateInspectTransactionId(p->flow, flags, true); + } ++ SCLogDebug(""p->pcap %""PRIu64"": no detection on packet, "" ++ ""PKT_NOPACKET_INSPECTION is set"", p->pcap_cnt); + return; + } + ",801,1037,2048 +18304,"static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) +{ + struct tun_struct *tun; + struct tun_file *tfile = file->private_data; + struct net_device *dev; + int err; + + if (tfile->detached) + return -EINVAL; + + dev = __dev_get_by_name(net, ifr->ifr_name); + if (dev) { + if (ifr->ifr_flags & IFF_TUN_EXCL) + return -EBUSY; + if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops) + tun = netdev_priv(dev); + else if ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops) + tun = netdev_priv(dev); + else + return -EINVAL; + + if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) != + !!(tun->flags & IFF_MULTI_QUEUE)) + return -EINVAL; + + if (tun_not_capable(tun)) + return -EPERM; + err = security_tun_dev_open(tun->security); + if (err < 0) + return err; + + err = tun_attach(tun, file, ifr->ifr_flags & IFF_NOFILTER); + if (err < 0) + return err; + + if (tun->flags & IFF_MULTI_QUEUE && + (tun->numqueues + tun->numdisabled > 1)) { + /* One or more queue has already been attached, no need + * to initialize the device again. + */ + return 0; + } + } + else { + char *name; + unsigned long flags = 0; + int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ? + MAX_TAP_QUEUES : 1; + + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) + return -EPERM; + err = security_tun_dev_create(); + if (err < 0) + return err; + + /* Set dev type */ + if (ifr->ifr_flags & IFF_TUN) { + /* TUN device */ + flags |= IFF_TUN; + name = ""tun%d""; + } else if (ifr->ifr_flags & IFF_TAP) { + /* TAP device */ + flags |= IFF_TAP; + name = ""tap%d""; + } else + return -EINVAL; + + if (*ifr->ifr_name) + name = ifr->ifr_name; + + dev = alloc_netdev_mqs(sizeof(struct tun_struct), name, + NET_NAME_UNKNOWN, tun_setup, queues, + queues); + + if (!dev) + return -ENOMEM; + + dev_net_set(dev, net); + dev->rtnl_link_ops = &tun_link_ops; + dev->ifindex = tfile->ifindex; + dev->sysfs_groups[0] = &tun_attr_group; + + tun = netdev_priv(dev); + tun->dev = dev; + tun->flags = flags; + tun->txflt.count = 0; + tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr); + + tun->align = NET_SKB_PAD; + tun->filter_attached = false; + tun->sndbuf = tfile->socket.sk->sk_sndbuf; + tun->rx_batched = 0; + + tun->pcpu_stats = netdev_alloc_pcpu_stats(struct tun_pcpu_stats); + if (!tun->pcpu_stats) { + err = -ENOMEM; + goto err_free_dev; + } + + spin_lock_init(&tun->lock); + + err = security_tun_dev_alloc_security(&tun->security); + if (err < 0) + goto err_free_stat; + + tun_net_init(dev); + tun_flow_init(tun); + + dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | + TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX; + dev->features = dev->hw_features | NETIF_F_LLTX; + dev->vlan_features = dev->features & + ~(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX); + + INIT_LIST_HEAD(&tun->disabled); + err = tun_attach(tun, file, false); + if (err < 0) + goto err_free_flow; + + err = register_netdevice(tun->dev); + if (err < 0) + goto err_detach; + } + + netif_carrier_on(tun->dev); + + tun_debug(KERN_INFO, tun, ""tun_set_iff\n""); + + tun->flags = (tun->flags & ~TUN_FEATURES) | + (ifr->ifr_flags & TUN_FEATURES); + + /* Make sure persistent devices do not get stuck in + * xoff state. + */ + if (netif_running(tun->dev)) + netif_tx_wake_all_queues(tun->dev); + + strcpy(ifr->ifr_name, tun->dev->name); + return 0; + +err_detach: + tun_detach_all(dev); + /* register_netdevice() already called tun_free_netdev() */ + goto err_free_dev; + +err_free_flow: + tun_flow_uninit(tun); + security_tun_dev_free_security(tun->security); +err_free_stat: + free_percpu(tun->pcpu_stats); +err_free_dev: + free_netdev(dev); + return err; +} +",1,"static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) +{ + struct tun_struct *tun; + struct tun_file *tfile = file->private_data; + struct net_device *dev; + int err; + + if (tfile->detached) + return -EINVAL; + + dev = __dev_get_by_name(net, ifr->ifr_name); + if (dev) { + if (ifr->ifr_flags & IFF_TUN_EXCL) + return -EBUSY; + if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops) + tun = netdev_priv(dev); + else if ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops) + tun = netdev_priv(dev); + else + return -EINVAL; + + if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) != + !!(tun->flags & IFF_MULTI_QUEUE)) + return -EINVAL; + + if (tun_not_capable(tun)) + return -EPERM; + err = security_tun_dev_open(tun->security); + if (err < 0) + return err; + + err = tun_attach(tun, file, ifr->ifr_flags & IFF_NOFILTER); + if (err < 0) + return err; + + if (tun->flags & IFF_MULTI_QUEUE && + (tun->numqueues + tun->numdisabled > 1)) { + /* One or more queue has already been attached, no need + * to initialize the device again. + */ + return 0; + } + } + else { + char *name; + unsigned long flags = 0; + int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ? + MAX_TAP_QUEUES : 1; + + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) + return -EPERM; + err = security_tun_dev_create(); + if (err < 0) + return err; + + /* Set dev type */ + if (ifr->ifr_flags & IFF_TUN) { + /* TUN device */ + flags |= IFF_TUN; + name = ""tun%d""; + } else if (ifr->ifr_flags & IFF_TAP) { + /* TAP device */ + flags |= IFF_TAP; + name = ""tap%d""; + } else + return -EINVAL; + + if (*ifr->ifr_name) + name = ifr->ifr_name; + + dev = alloc_netdev_mqs(sizeof(struct tun_struct), name, + NET_NAME_UNKNOWN, tun_setup, queues, + queues); + + if (!dev) + return -ENOMEM; + err = dev_get_valid_name(net, dev, name); + if (err) + goto err_free_dev; + + dev_net_set(dev, net); + dev->rtnl_link_ops = &tun_link_ops; + dev->ifindex = tfile->ifindex; + dev->sysfs_groups[0] = &tun_attr_group; + + tun = netdev_priv(dev); + tun->dev = dev; + tun->flags = flags; + tun->txflt.count = 0; + tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr); + + tun->align = NET_SKB_PAD; + tun->filter_attached = false; + tun->sndbuf = tfile->socket.sk->sk_sndbuf; + tun->rx_batched = 0; + + tun->pcpu_stats = netdev_alloc_pcpu_stats(struct tun_pcpu_stats); + if (!tun->pcpu_stats) { + err = -ENOMEM; + goto err_free_dev; + } + + spin_lock_init(&tun->lock); + + err = security_tun_dev_alloc_security(&tun->security); + if (err < 0) + goto err_free_stat; + + tun_net_init(dev); + tun_flow_init(tun); + + dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | + TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX; + dev->features = dev->hw_features | NETIF_F_LLTX; + dev->vlan_features = dev->features & + ~(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX); + + INIT_LIST_HEAD(&tun->disabled); + err = tun_attach(tun, file, false); + if (err < 0) + goto err_free_flow; + + err = register_netdevice(tun->dev); + if (err < 0) + goto err_detach; + } + + netif_carrier_on(tun->dev); + + tun_debug(KERN_INFO, tun, ""tun_set_iff\n""); + + tun->flags = (tun->flags & ~TUN_FEATURES) | + (ifr->ifr_flags & TUN_FEATURES); + + /* Make sure persistent devices do not get stuck in + * xoff state. + */ + if (netif_running(tun->dev)) + netif_tx_wake_all_queues(tun->dev); + + strcpy(ifr->ifr_name, tun->dev->name); + return 0; + +err_detach: + tun_detach_all(dev); + /* register_netdevice() already called tun_free_netdev() */ + goto err_free_dev; + +err_free_flow: + tun_flow_uninit(tun); + security_tun_dev_free_security(tun->security); +err_free_stat: + free_percpu(tun->pcpu_stats); +err_free_dev: + free_netdev(dev); + return err; +} +","@@ -2027,6 +2027,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) + + if (!dev) + return -ENOMEM; ++ err = dev_get_valid_name(net, dev, name); ++ if (err) ++ goto err_free_dev; + + dev_net_set(dev, net); + dev->rtnl_link_ops = &tun_link_ops;",1188,1424,2048 +15542,"content::PreviewsState ChromeContentBrowserClient::DetermineAllowedPreviews( + content::PreviewsState initial_state, + content::NavigationHandle* navigation_handle, + const GURL& current_navigation_url) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(!navigation_handle->HasCommitted()); + + if (!navigation_handle->IsInMainFrame() || + navigation_handle->IsSameDocument()) { + return initial_state; + } + + if (!current_navigation_url.SchemeIsHTTPOrHTTPS()) + return content::PREVIEWS_OFF; + + if (navigation_handle->IsPost()) + return content::PREVIEWS_OFF; + + content::WebContents* web_contents = navigation_handle->GetWebContents(); + content::WebContentsDelegate* delegate = web_contents->GetDelegate(); + + auto* browser_context = web_contents->GetBrowserContext(); + + PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile( + Profile::FromBrowserContext(browser_context)); + auto* data_reduction_proxy_settings = + DataReductionProxyChromeSettingsFactory::GetForBrowserContext( + browser_context); + if (!previews_service || !previews_service->previews_ui_service() || + !data_reduction_proxy_settings) { + return content::PREVIEWS_OFF; + } + + PreviewsUITabHelper* ui_tab_helper = + PreviewsUITabHelper::FromWebContents(web_contents); + if (!ui_tab_helper) + return content::PREVIEWS_OFF; + + DCHECK(!browser_context->IsOffTheRecord()); + + previews::PreviewsDeciderImpl* previews_decider_impl = + previews_service->previews_ui_service()->previews_decider_impl(); + DCHECK(previews_decider_impl); + + content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; + + previews::PreviewsUserData* previews_data = + ui_tab_helper->GetPreviewsUserData(navigation_handle); + + bool is_redirect = false; + if (previews_data) { + is_redirect = !previews_data->server_lite_page_info(); + } else { + previews_data = ui_tab_helper->CreatePreviewsUserDataForNavigationHandle( + navigation_handle, previews_decider_impl->GeneratePageId()); + } + + DCHECK(previews_data); + + bool is_reload = + navigation_handle->GetReloadType() != content::ReloadType::NONE; + + content::PreviewsState server_previews_enabled_state = + content::SERVER_LOFI_ON | content::SERVER_LITE_PAGE_ON; + + if (is_redirect) { + previews_state |= (previews_data->allowed_previews_state() & + server_previews_enabled_state); + } else { + if (previews_decider_impl->ShouldAllowPreviewAtNavigationStart( + previews_data, current_navigation_url, is_reload, + previews::PreviewsType::LITE_PAGE)) { + previews_state |= server_previews_enabled_state; + } + } + + previews_state |= previews::DetermineAllowedClientPreviewsState( + previews_data, current_navigation_url, is_reload, is_redirect, + data_reduction_proxy_settings->IsDataReductionProxyEnabled(), + previews_decider_impl, navigation_handle); + + if (previews_state & content::PREVIEWS_OFF) { + previews_data->set_allowed_previews_state(content::PREVIEWS_OFF); + return content::PREVIEWS_OFF; + } + + if (previews_state & content::PREVIEWS_NO_TRANSFORM) { + previews_data->set_allowed_previews_state(content::PREVIEWS_NO_TRANSFORM); + return content::PREVIEWS_NO_TRANSFORM; + } + + if (previews_state == content::PREVIEWS_UNSPECIFIED) { + previews_data->set_allowed_previews_state(content::PREVIEWS_OFF); + return content::PREVIEWS_OFF; + } + + content::PreviewsState embedder_state = content::PREVIEWS_UNSPECIFIED; + if (delegate) { + delegate->AdjustPreviewsStateForNavigation(web_contents, &embedder_state); + } + + if (embedder_state != content::PREVIEWS_UNSPECIFIED) { + previews_state = previews_state & embedder_state; + if (previews_state == content::PREVIEWS_UNSPECIFIED) + previews_state = content::PREVIEWS_OFF; + } + previews_data->set_allowed_previews_state(previews_state); + return previews_state; +} +",0,"content::PreviewsState ChromeContentBrowserClient::DetermineAllowedPreviews( + content::PreviewsState initial_state, + content::NavigationHandle* navigation_handle, + const GURL& current_navigation_url) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(!navigation_handle->HasCommitted()); + + if (!navigation_handle->IsInMainFrame() || + navigation_handle->IsSameDocument()) { + return initial_state; + } + + if (!current_navigation_url.SchemeIsHTTPOrHTTPS()) + return content::PREVIEWS_OFF; + + if (navigation_handle->IsPost()) + return content::PREVIEWS_OFF; + + content::WebContents* web_contents = navigation_handle->GetWebContents(); + content::WebContentsDelegate* delegate = web_contents->GetDelegate(); + + auto* browser_context = web_contents->GetBrowserContext(); + + PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile( + Profile::FromBrowserContext(browser_context)); + auto* data_reduction_proxy_settings = + DataReductionProxyChromeSettingsFactory::GetForBrowserContext( + browser_context); + if (!previews_service || !previews_service->previews_ui_service() || + !data_reduction_proxy_settings) { + return content::PREVIEWS_OFF; + } + + PreviewsUITabHelper* ui_tab_helper = + PreviewsUITabHelper::FromWebContents(web_contents); + if (!ui_tab_helper) + return content::PREVIEWS_OFF; + + DCHECK(!browser_context->IsOffTheRecord()); + + previews::PreviewsDeciderImpl* previews_decider_impl = + previews_service->previews_ui_service()->previews_decider_impl(); + DCHECK(previews_decider_impl); + + content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; + + previews::PreviewsUserData* previews_data = + ui_tab_helper->GetPreviewsUserData(navigation_handle); + + bool is_redirect = false; + if (previews_data) { + is_redirect = !previews_data->server_lite_page_info(); + } else { + previews_data = ui_tab_helper->CreatePreviewsUserDataForNavigationHandle( + navigation_handle, previews_decider_impl->GeneratePageId()); + } + + DCHECK(previews_data); + + bool is_reload = + navigation_handle->GetReloadType() != content::ReloadType::NONE; + + content::PreviewsState server_previews_enabled_state = + content::SERVER_LOFI_ON | content::SERVER_LITE_PAGE_ON; + + if (is_redirect) { + previews_state |= (previews_data->allowed_previews_state() & + server_previews_enabled_state); + } else { + if (previews_decider_impl->ShouldAllowPreviewAtNavigationStart( + previews_data, current_navigation_url, is_reload, + previews::PreviewsType::LITE_PAGE)) { + previews_state |= server_previews_enabled_state; + } + } + + previews_state |= previews::DetermineAllowedClientPreviewsState( + previews_data, current_navigation_url, is_reload, is_redirect, + data_reduction_proxy_settings->IsDataReductionProxyEnabled(), + previews_decider_impl, navigation_handle); + + if (previews_state & content::PREVIEWS_OFF) { + previews_data->set_allowed_previews_state(content::PREVIEWS_OFF); + return content::PREVIEWS_OFF; + } + + if (previews_state & content::PREVIEWS_NO_TRANSFORM) { + previews_data->set_allowed_previews_state(content::PREVIEWS_NO_TRANSFORM); + return content::PREVIEWS_NO_TRANSFORM; + } + + if (previews_state == content::PREVIEWS_UNSPECIFIED) { + previews_data->set_allowed_previews_state(content::PREVIEWS_OFF); + return content::PREVIEWS_OFF; + } + + content::PreviewsState embedder_state = content::PREVIEWS_UNSPECIFIED; + if (delegate) { + delegate->AdjustPreviewsStateForNavigation(web_contents, &embedder_state); + } + + if (embedder_state != content::PREVIEWS_UNSPECIFIED) { + previews_state = previews_state & embedder_state; + if (previews_state == content::PREVIEWS_UNSPECIFIED) + previews_state = content::PREVIEWS_OFF; + } + previews_data->set_allowed_previews_state(previews_state); + return previews_state; +} +","@@ -2282,12 +2282,9 @@ const gfx::ImageSkia* ChromeContentBrowserClient::GetDefaultFavicon() { + + bool ChromeContentBrowserClient::IsDataSaverEnabled( + content::BrowserContext* browser_context) { +- data_reduction_proxy::DataReductionProxySettings* +- data_reduction_proxy_settings = +- DataReductionProxyChromeSettingsFactory::GetForBrowserContext( +- browser_context); +- return data_reduction_proxy_settings && +- data_reduction_proxy_settings->IsDataSaverEnabledByUser(); ++ Profile* profile = Profile::FromBrowserContext(browser_context); ++ return profile && data_reduction_proxy::DataReductionProxySettings:: ++ IsDataSaverEnabledByUser(profile->GetPrefs()); + } + + void ChromeContentBrowserClient::UpdateRendererPreferencesForWorker(",901,1137,2048 +15010,"void TabletModeWindowState::OnWMEvent(wm::WindowState* window_state, + const wm::WMEvent* event) { + if (ignore_wm_events_) { + return; + } + + switch (event->type()) { + case wm::WM_EVENT_TOGGLE_FULLSCREEN: + ToggleFullScreen(window_state, window_state->delegate()); + break; + case wm::WM_EVENT_FULLSCREEN: + UpdateWindow(window_state, WindowStateType::kFullscreen, + true /* animated */); + break; + case wm::WM_EVENT_PIN: + if (!Shell::Get()->screen_pinning_controller()->IsPinned()) + UpdateWindow(window_state, WindowStateType::kPinned, + true /* animated */); + break; + case wm::WM_EVENT_PIP: + if (!window_state->IsPip()) { + UpdateWindow(window_state, WindowStateType::kPip, true /* animated */); + } + break; + case wm::WM_EVENT_TRUSTED_PIN: + if (!Shell::Get()->screen_pinning_controller()->IsPinned()) + UpdateWindow(window_state, WindowStateType::kTrustedPinned, + true /* animated */); + break; + case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: + case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: + case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: + case wm::WM_EVENT_TOGGLE_MAXIMIZE: + case wm::WM_EVENT_CYCLE_SNAP_LEFT: + case wm::WM_EVENT_CYCLE_SNAP_RIGHT: + case wm::WM_EVENT_CENTER: + case wm::WM_EVENT_NORMAL: + case wm::WM_EVENT_MAXIMIZE: + UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), + true /* animated */); + return; + case wm::WM_EVENT_SNAP_LEFT: + window_state->set_bounds_changed_by_user(true); + UpdateWindow(window_state, + GetSnappedWindowStateType(window_state, + WindowStateType::kLeftSnapped), + false /* animated */); + return; + case wm::WM_EVENT_SNAP_RIGHT: + window_state->set_bounds_changed_by_user(true); + UpdateWindow(window_state, + GetSnappedWindowStateType(window_state, + WindowStateType::kRightSnapped), + false /* animated */); + return; + case wm::WM_EVENT_MINIMIZE: + UpdateWindow(window_state, WindowStateType::kMinimized, + true /* animated */); + return; + case wm::WM_EVENT_SHOW_INACTIVE: + case wm::WM_EVENT_SYSTEM_UI_AREA_CHANGED: + return; + case wm::WM_EVENT_SET_BOUNDS: { + gfx::Rect bounds_in_parent = + (static_cast(event))->requested_bounds(); + if (bounds_in_parent.IsEmpty()) + return; + + if (wm::IsDraggingTabs(window_state->window()) || + IsTabDraggingSourceWindow(window_state->window())) { + window_state->SetBoundsDirect(bounds_in_parent); + } else if (current_state_type_ == WindowStateType::kMaximized) { + window_state->SetRestoreBoundsInParent(bounds_in_parent); + } else if (current_state_type_ != WindowStateType::kMinimized && + current_state_type_ != WindowStateType::kFullscreen && + current_state_type_ != WindowStateType::kPinned && + current_state_type_ != WindowStateType::kTrustedPinned && + current_state_type_ != WindowStateType::kLeftSnapped && + current_state_type_ != WindowStateType::kRightSnapped) { + bounds_in_parent = GetCenteredBounds(bounds_in_parent, window_state); + if (bounds_in_parent != window_state->window()->bounds()) { + const wm::SetBoundsEvent* bounds_event = + static_cast(event); + if (window_state->window()->IsVisible() && bounds_event->animate()) + window_state->SetBoundsDirectAnimated(bounds_in_parent); + else + window_state->SetBoundsDirect(bounds_in_parent); + } + } + break; + } + case wm::WM_EVENT_ADDED_TO_WORKSPACE: + if (current_state_type_ != WindowStateType::kMaximized && + current_state_type_ != WindowStateType::kFullscreen && + current_state_type_ != WindowStateType::kMinimized) { + WindowStateType new_state = + GetMaximizedOrCenteredWindowType(window_state); + UpdateWindow(window_state, new_state, true /* animated */); + } + break; + case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED: + if (current_state_type_ != WindowStateType::kMinimized) + UpdateBounds(window_state, true /* animated */); + break; + case wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED: + if (current_state_type_ != WindowStateType::kMinimized) + UpdateBounds(window_state, false /* animated */); + break; + } +} +",0,"void TabletModeWindowState::OnWMEvent(wm::WindowState* window_state, + const wm::WMEvent* event) { + if (ignore_wm_events_) { + return; + } + + switch (event->type()) { + case wm::WM_EVENT_TOGGLE_FULLSCREEN: + ToggleFullScreen(window_state, window_state->delegate()); + break; + case wm::WM_EVENT_FULLSCREEN: + UpdateWindow(window_state, WindowStateType::kFullscreen, + true /* animated */); + break; + case wm::WM_EVENT_PIN: + if (!Shell::Get()->screen_pinning_controller()->IsPinned()) + UpdateWindow(window_state, WindowStateType::kPinned, + true /* animated */); + break; + case wm::WM_EVENT_PIP: + if (!window_state->IsPip()) { + UpdateWindow(window_state, WindowStateType::kPip, true /* animated */); + } + break; + case wm::WM_EVENT_TRUSTED_PIN: + if (!Shell::Get()->screen_pinning_controller()->IsPinned()) + UpdateWindow(window_state, WindowStateType::kTrustedPinned, + true /* animated */); + break; + case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: + case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: + case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: + case wm::WM_EVENT_TOGGLE_MAXIMIZE: + case wm::WM_EVENT_CYCLE_SNAP_LEFT: + case wm::WM_EVENT_CYCLE_SNAP_RIGHT: + case wm::WM_EVENT_CENTER: + case wm::WM_EVENT_NORMAL: + case wm::WM_EVENT_MAXIMIZE: + UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), + true /* animated */); + return; + case wm::WM_EVENT_SNAP_LEFT: + window_state->set_bounds_changed_by_user(true); + UpdateWindow(window_state, + GetSnappedWindowStateType(window_state, + WindowStateType::kLeftSnapped), + false /* animated */); + return; + case wm::WM_EVENT_SNAP_RIGHT: + window_state->set_bounds_changed_by_user(true); + UpdateWindow(window_state, + GetSnappedWindowStateType(window_state, + WindowStateType::kRightSnapped), + false /* animated */); + return; + case wm::WM_EVENT_MINIMIZE: + UpdateWindow(window_state, WindowStateType::kMinimized, + true /* animated */); + return; + case wm::WM_EVENT_SHOW_INACTIVE: + case wm::WM_EVENT_SYSTEM_UI_AREA_CHANGED: + return; + case wm::WM_EVENT_SET_BOUNDS: { + gfx::Rect bounds_in_parent = + (static_cast(event))->requested_bounds(); + if (bounds_in_parent.IsEmpty()) + return; + + if (wm::IsDraggingTabs(window_state->window()) || + IsTabDraggingSourceWindow(window_state->window())) { + window_state->SetBoundsDirect(bounds_in_parent); + } else if (current_state_type_ == WindowStateType::kMaximized) { + window_state->SetRestoreBoundsInParent(bounds_in_parent); + } else if (current_state_type_ != WindowStateType::kMinimized && + current_state_type_ != WindowStateType::kFullscreen && + current_state_type_ != WindowStateType::kPinned && + current_state_type_ != WindowStateType::kTrustedPinned && + current_state_type_ != WindowStateType::kLeftSnapped && + current_state_type_ != WindowStateType::kRightSnapped) { + bounds_in_parent = GetCenteredBounds(bounds_in_parent, window_state); + if (bounds_in_parent != window_state->window()->bounds()) { + const wm::SetBoundsEvent* bounds_event = + static_cast(event); + if (window_state->window()->IsVisible() && bounds_event->animate()) + window_state->SetBoundsDirectAnimated(bounds_in_parent); + else + window_state->SetBoundsDirect(bounds_in_parent); + } + } + break; + } + case wm::WM_EVENT_ADDED_TO_WORKSPACE: + if (current_state_type_ != WindowStateType::kMaximized && + current_state_type_ != WindowStateType::kFullscreen && + current_state_type_ != WindowStateType::kMinimized) { + WindowStateType new_state = + GetMaximizedOrCenteredWindowType(window_state); + UpdateWindow(window_state, new_state, true /* animated */); + } + break; + case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED: + if (current_state_type_ != WindowStateType::kMinimized) + UpdateBounds(window_state, true /* animated */); + break; + case wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED: + if (current_state_type_ != WindowStateType::kMinimized) + UpdateBounds(window_state, false /* animated */); + break; + } +} +","@@ -198,12 +198,15 @@ TabletModeWindowState::~TabletModeWindowState() { + creator_->WindowStateDestroyed(window_); + } + +-void TabletModeWindowState::LeaveTabletMode(wm::WindowState* window_state) { +- // Only do bounds change animation if the window is the top window or a window +- // showing in splitview, and the window has changed its state. Otherwise, +- // restore its bounds immediately. ++void TabletModeWindowState::LeaveTabletMode(wm::WindowState* window_state, ++ bool was_in_overview) { ++ // Only do bounds change animation if the window was showing in overview, ++ // or the top window or a window showing in splitview before leaving tablet ++ // mode, and the window has changed its state. Otherwise, restore its bounds ++ // immediately. + EnterAnimationType animation_type = +- window_state->IsSnapped() || IsTopWindow(window_state->window()) ++ was_in_overview || window_state->IsSnapped() || ++ IsTopWindow(window_state->window()) + ? DEFAULT + : IMMEDIATE; + if (old_state_->GetType() == window_state->GetStateType() &&",1017,1253,2048 +4299,"int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +{ + struct udp_sock *up = udp_sk(sk); + int rc; + int is_udplite = IS_UDPLITE(sk); + + /* + * Charge it to the socket, dropping if the queue is full. + */ + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) + goto drop; + nf_reset(skb); + + if (static_key_false(&udp_encap_needed) && up->encap_type) { + int (*encap_rcv)(struct sock *sk, struct sk_buff *skb); + + /* + * This is an encapsulation socket so pass the skb to + * the socket's udp_encap_rcv() hook. Otherwise, just + * fall through and pass this up the UDP socket. + * up->encap_rcv() returns the following value: + * =0 if skb was successfully passed to the encap + * handler or was discarded by it. + * >0 if skb should be passed on to UDP. + * <0 if skb should be resubmitted as proto -N + */ + + /* if we're overly short, let UDP handle it */ + encap_rcv = ACCESS_ONCE(up->encap_rcv); + if (skb->len > sizeof(struct udphdr) && encap_rcv) { + int ret; + + /* Verify checksum before giving to encap */ + if (udp_lib_checksum_complete(skb)) + goto csum_error; + + ret = encap_rcv(sk, skb); + if (ret <= 0) { + UDP_INC_STATS_BH(sock_net(sk), + UDP_MIB_INDATAGRAMS, + is_udplite); + return -ret; + } + } + + /* FALLTHROUGH -- it's a UDP Packet */ + } + + /* + * UDP-Lite specific tests, ignored on UDP sockets + */ + if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { + + /* + * MIB statistics other than incrementing the error count are + * disabled for the following two types of errors: these depend + * on the application settings, not on the functioning of the + * protocol stack as such. + * + * RFC 3828 here recommends (sec 3.3): ""There should also be a + * way ... to ... at least let the receiving application block + * delivery of packets with coverage values less than a value + * provided by the application."" + */ + if (up->pcrlen == 0) { /* full coverage was set */ + net_dbg_ratelimited(""UDPLite: partial coverage %d while full coverage %d requested\n"", + UDP_SKB_CB(skb)->cscov, skb->len); + goto drop; + } + /* The next case involves violating the min. coverage requested + * by the receiver. This is subtle: if receiver wants x and x is + * greater than the buffersize/MTU then receiver will complain + * that it wants x while sender emits packets of smaller size y. + * Therefore the above ...()->partial_cov statement is essential. + */ + if (UDP_SKB_CB(skb)->cscov < up->pcrlen) { + net_dbg_ratelimited(""UDPLite: coverage %d too small, need min %d\n"", + UDP_SKB_CB(skb)->cscov, up->pcrlen); + goto drop; + } + } + + if (rcu_access_pointer(sk->sk_filter) && + udp_lib_checksum_complete(skb)) + goto csum_error; + + if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { + UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS, + is_udplite); + goto drop; + } + + rc = 0; + + ipv4_pktinfo_prepare(sk, skb); + bh_lock_sock(sk); + if (!sock_owned_by_user(sk)) + rc = __udp_queue_rcv_skb(sk, skb); + else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) { + bh_unlock_sock(sk); + goto drop; + } + bh_unlock_sock(sk); + + return rc; + +csum_error: + UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite); +drop: + UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite); + atomic_inc(&sk->sk_drops); + kfree_skb(skb); + return -1; +} +",0,"int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +{ + struct udp_sock *up = udp_sk(sk); + int rc; + int is_udplite = IS_UDPLITE(sk); + + /* + * Charge it to the socket, dropping if the queue is full. + */ + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) + goto drop; + nf_reset(skb); + + if (static_key_false(&udp_encap_needed) && up->encap_type) { + int (*encap_rcv)(struct sock *sk, struct sk_buff *skb); + + /* + * This is an encapsulation socket so pass the skb to + * the socket's udp_encap_rcv() hook. Otherwise, just + * fall through and pass this up the UDP socket. + * up->encap_rcv() returns the following value: + * =0 if skb was successfully passed to the encap + * handler or was discarded by it. + * >0 if skb should be passed on to UDP. + * <0 if skb should be resubmitted as proto -N + */ + + /* if we're overly short, let UDP handle it */ + encap_rcv = ACCESS_ONCE(up->encap_rcv); + if (skb->len > sizeof(struct udphdr) && encap_rcv) { + int ret; + + /* Verify checksum before giving to encap */ + if (udp_lib_checksum_complete(skb)) + goto csum_error; + + ret = encap_rcv(sk, skb); + if (ret <= 0) { + UDP_INC_STATS_BH(sock_net(sk), + UDP_MIB_INDATAGRAMS, + is_udplite); + return -ret; + } + } + + /* FALLTHROUGH -- it's a UDP Packet */ + } + + /* + * UDP-Lite specific tests, ignored on UDP sockets + */ + if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { + + /* + * MIB statistics other than incrementing the error count are + * disabled for the following two types of errors: these depend + * on the application settings, not on the functioning of the + * protocol stack as such. + * + * RFC 3828 here recommends (sec 3.3): ""There should also be a + * way ... to ... at least let the receiving application block + * delivery of packets with coverage values less than a value + * provided by the application."" + */ + if (up->pcrlen == 0) { /* full coverage was set */ + net_dbg_ratelimited(""UDPLite: partial coverage %d while full coverage %d requested\n"", + UDP_SKB_CB(skb)->cscov, skb->len); + goto drop; + } + /* The next case involves violating the min. coverage requested + * by the receiver. This is subtle: if receiver wants x and x is + * greater than the buffersize/MTU then receiver will complain + * that it wants x while sender emits packets of smaller size y. + * Therefore the above ...()->partial_cov statement is essential. + */ + if (UDP_SKB_CB(skb)->cscov < up->pcrlen) { + net_dbg_ratelimited(""UDPLite: coverage %d too small, need min %d\n"", + UDP_SKB_CB(skb)->cscov, up->pcrlen); + goto drop; + } + } + + if (rcu_access_pointer(sk->sk_filter) && + udp_lib_checksum_complete(skb)) + goto csum_error; + + if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { + UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS, + is_udplite); + goto drop; + } + + rc = 0; + + ipv4_pktinfo_prepare(sk, skb); + bh_lock_sock(sk); + if (!sock_owned_by_user(sk)) + rc = __udp_queue_rcv_skb(sk, skb); + else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) { + bh_unlock_sock(sk); + goto drop; + } + bh_unlock_sock(sk); + + return rc; + +csum_error: + UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite); +drop: + UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite); + atomic_inc(&sk->sk_drops); + kfree_skb(skb); + return -1; +} +","@@ -1345,10 +1345,8 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, + } + unlock_sock_fast(sk, slow); + +- if (noblock) +- return -EAGAIN; +- +- /* starting over for a new packet */ ++ /* starting over for a new packet, but check if we need to yield */ ++ cond_resched(); + msg->msg_flags &= ~MSG_TRUNC; + goto try_again; + }",991,1227,2048 +17648,"xmlParsePI(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + size_t len = 0; + size_t size = XML_PARSER_BUFFER_SIZE; + int cur, l; + const xmlChar *target; + xmlParserInputState state; + int count = 0; + + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParserInputPtr input = ctxt->input; + state = ctxt->instate; + ctxt->instate = XML_PARSER_PI; + /* + * this is a Processing Instruction. + */ + SKIP(2); + SHRINK; + + /* + * Parse the target name and check for special support like + * namespace. + */ + target = xmlParsePITarget(ctxt); + if (target != NULL) { + if ((RAW == '?') && (NXT(1) == '>')) { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, NULL); + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + return; + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->instate = state; + return; + } + cur = CUR; + if (!IS_BLANK(cur)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED, + ""ParsePI: PI %s space expected\n"", target); + } + SKIP_BLANKS; + cur = CUR_CHAR(l); + while (IS_CHAR(cur) && /* checked */ + ((cur != '?') || (NXT(1) != '>'))) { + if (len + 5 >= size) { + xmlChar *tmp; + size_t new_size = size * 2; + tmp = (xmlChar *) xmlRealloc(buf, new_size); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + ctxt->instate = state; + return; + } + buf = tmp; + size = new_size; + } + count++; + if (count > 50) { + GROW; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return; + } + count = 0; + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""PI %s too big found"", target); + xmlFree(buf); + ctxt->instate = state; + return; + } + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); + cur = CUR_CHAR(l); + if (cur == 0) { + SHRINK; + GROW; + cur = CUR_CHAR(l); + } + } + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""PI %s too big found"", target); + xmlFree(buf); + ctxt->instate = state; + return; + } + buf[len] = 0; + if (cur != '?') { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""ParsePI: PI %s never end ...\n"", target); + } else { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + +#ifdef LIBXML_CATALOG_ENABLED + if (((state == XML_PARSER_MISC) || + (state == XML_PARSER_START)) && + (xmlStrEqual(target, XML_CATALOG_PI))) { + xmlCatalogAllow allow = xmlCatalogGetDefaults(); + if ((allow == XML_CATA_ALLOW_DOCUMENT) || + (allow == XML_CATA_ALLOW_ALL)) + xmlParseCatalogPI(ctxt, buf); + } +#endif + + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, buf); + } + xmlFree(buf); + } else { + xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); + } + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + } +} +",0,"xmlParsePI(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + size_t len = 0; + size_t size = XML_PARSER_BUFFER_SIZE; + int cur, l; + const xmlChar *target; + xmlParserInputState state; + int count = 0; + + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParserInputPtr input = ctxt->input; + state = ctxt->instate; + ctxt->instate = XML_PARSER_PI; + /* + * this is a Processing Instruction. + */ + SKIP(2); + SHRINK; + + /* + * Parse the target name and check for special support like + * namespace. + */ + target = xmlParsePITarget(ctxt); + if (target != NULL) { + if ((RAW == '?') && (NXT(1) == '>')) { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, NULL); + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + return; + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->instate = state; + return; + } + cur = CUR; + if (!IS_BLANK(cur)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED, + ""ParsePI: PI %s space expected\n"", target); + } + SKIP_BLANKS; + cur = CUR_CHAR(l); + while (IS_CHAR(cur) && /* checked */ + ((cur != '?') || (NXT(1) != '>'))) { + if (len + 5 >= size) { + xmlChar *tmp; + size_t new_size = size * 2; + tmp = (xmlChar *) xmlRealloc(buf, new_size); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + ctxt->instate = state; + return; + } + buf = tmp; + size = new_size; + } + count++; + if (count > 50) { + GROW; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return; + } + count = 0; + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""PI %s too big found"", target); + xmlFree(buf); + ctxt->instate = state; + return; + } + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); + cur = CUR_CHAR(l); + if (cur == 0) { + SHRINK; + GROW; + cur = CUR_CHAR(l); + } + } + if ((len > XML_MAX_TEXT_LENGTH) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""PI %s too big found"", target); + xmlFree(buf); + ctxt->instate = state; + return; + } + buf[len] = 0; + if (cur != '?') { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""ParsePI: PI %s never end ...\n"", target); + } else { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + +#ifdef LIBXML_CATALOG_ENABLED + if (((state == XML_PARSER_MISC) || + (state == XML_PARSER_START)) && + (xmlStrEqual(target, XML_CATALOG_PI))) { + xmlCatalogAllow allow = xmlCatalogGetDefaults(); + if ((allow == XML_CATA_ALLOW_DOCUMENT) || + (allow == XML_CATA_ALLOW_ALL)) + xmlParseCatalogPI(ctxt, buf); + } +#endif + + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, buf); + } + xmlFree(buf); + } else { + xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); + } + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + } +} +","@@ -8130,6 +8130,14 @@ + + if (xmlPushInput(ctxt, input) < 0) + return; + } else { ++ if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && ++ ((ctxt->options & XML_PARSE_NOENT) == 0) && ++ ((ctxt->options & XML_PARSE_DTDVALID) == 0) && ++ ((ctxt->options & XML_PARSE_DTDLOAD) == 0) && ++ ((ctxt->options & XML_PARSE_DTDATTR) == 0) && ++ (ctxt->replaceEntities == 0) && ++ (ctxt->validate == 0)) ++ return; + /* + * TODO !!! + * handle the extra spaces added before and after +",1005,1241,2048 +17965,"static void init_vmcb(struct vcpu_svm *svm) +{ + struct vmcb_control_area *control = &svm->vmcb->control; + struct vmcb_save_area *save = &svm->vmcb->save; + + svm->vcpu.fpu_active = 1; + svm->vcpu.arch.hflags = 0; + + set_cr_intercept(svm, INTERCEPT_CR0_READ); + set_cr_intercept(svm, INTERCEPT_CR3_READ); + set_cr_intercept(svm, INTERCEPT_CR4_READ); + set_cr_intercept(svm, INTERCEPT_CR0_WRITE); + set_cr_intercept(svm, INTERCEPT_CR3_WRITE); + set_cr_intercept(svm, INTERCEPT_CR4_WRITE); + set_cr_intercept(svm, INTERCEPT_CR8_WRITE); + + set_dr_intercepts(svm); + + set_exception_intercept(svm, PF_VECTOR); + set_exception_intercept(svm, UD_VECTOR); + set_exception_intercept(svm, MC_VECTOR); + + set_intercept(svm, INTERCEPT_INTR); + set_intercept(svm, INTERCEPT_NMI); + set_intercept(svm, INTERCEPT_SMI); + set_intercept(svm, INTERCEPT_SELECTIVE_CR0); + set_intercept(svm, INTERCEPT_RDPMC); + set_intercept(svm, INTERCEPT_CPUID); + set_intercept(svm, INTERCEPT_INVD); + set_intercept(svm, INTERCEPT_HLT); + set_intercept(svm, INTERCEPT_INVLPG); + set_intercept(svm, INTERCEPT_INVLPGA); + set_intercept(svm, INTERCEPT_IOIO_PROT); + set_intercept(svm, INTERCEPT_MSR_PROT); + set_intercept(svm, INTERCEPT_TASK_SWITCH); + set_intercept(svm, INTERCEPT_SHUTDOWN); + set_intercept(svm, INTERCEPT_VMRUN); + set_intercept(svm, INTERCEPT_VMMCALL); + set_intercept(svm, INTERCEPT_VMLOAD); + set_intercept(svm, INTERCEPT_VMSAVE); + set_intercept(svm, INTERCEPT_STGI); + set_intercept(svm, INTERCEPT_CLGI); + set_intercept(svm, INTERCEPT_SKINIT); + set_intercept(svm, INTERCEPT_WBINVD); + set_intercept(svm, INTERCEPT_MONITOR); + set_intercept(svm, INTERCEPT_MWAIT); + set_intercept(svm, INTERCEPT_XSETBV); + + control->iopm_base_pa = iopm_base; + control->msrpm_base_pa = __pa(svm->msrpm); + control->int_ctl = V_INTR_MASKING_MASK; + + init_seg(&save->es); + init_seg(&save->ss); + init_seg(&save->ds); + init_seg(&save->fs); + init_seg(&save->gs); + + save->cs.selector = 0xf000; + save->cs.base = 0xffff0000; + /* Executable/Readable Code Segment */ + save->cs.attrib = SVM_SELECTOR_READ_MASK | SVM_SELECTOR_P_MASK | + SVM_SELECTOR_S_MASK | SVM_SELECTOR_CODE_MASK; + save->cs.limit = 0xffff; + + save->gdtr.limit = 0xffff; + save->idtr.limit = 0xffff; + + init_sys_seg(&save->ldtr, SEG_TYPE_LDT); + init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); + + svm_set_efer(&svm->vcpu, 0); + save->dr6 = 0xffff0ff0; + kvm_set_rflags(&svm->vcpu, 2); + save->rip = 0x0000fff0; + svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip; + + /* + * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0. + * It also updates the guest-visible cr0 value. + */ + svm_set_cr0(&svm->vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET); + kvm_mmu_reset_context(&svm->vcpu); + + save->cr4 = X86_CR4_PAE; + /* rdx = ?? */ + + if (npt_enabled) { + /* Setup VMCB for Nested Paging */ + control->nested_ctl = 1; + clr_intercept(svm, INTERCEPT_INVLPG); + clr_exception_intercept(svm, PF_VECTOR); + clr_cr_intercept(svm, INTERCEPT_CR3_READ); + clr_cr_intercept(svm, INTERCEPT_CR3_WRITE); + save->g_pat = svm->vcpu.arch.pat; + save->cr3 = 0; + save->cr4 = 0; + } + svm->asid_generation = 0; + + svm->nested.vmcb = 0; + svm->vcpu.arch.hflags = 0; + + if (boot_cpu_has(X86_FEATURE_PAUSEFILTER)) { + control->pause_filter_count = 3000; + set_intercept(svm, INTERCEPT_PAUSE); + } + + mark_all_dirty(svm->vmcb); + + enable_gif(svm); +} +",1,"static void init_vmcb(struct vcpu_svm *svm) +{ + struct vmcb_control_area *control = &svm->vmcb->control; + struct vmcb_save_area *save = &svm->vmcb->save; + + svm->vcpu.fpu_active = 1; + svm->vcpu.arch.hflags = 0; + + set_cr_intercept(svm, INTERCEPT_CR0_READ); + set_cr_intercept(svm, INTERCEPT_CR3_READ); + set_cr_intercept(svm, INTERCEPT_CR4_READ); + set_cr_intercept(svm, INTERCEPT_CR0_WRITE); + set_cr_intercept(svm, INTERCEPT_CR3_WRITE); + set_cr_intercept(svm, INTERCEPT_CR4_WRITE); + set_cr_intercept(svm, INTERCEPT_CR8_WRITE); + + set_dr_intercepts(svm); + + set_exception_intercept(svm, PF_VECTOR); + set_exception_intercept(svm, UD_VECTOR); + set_exception_intercept(svm, MC_VECTOR); + set_exception_intercept(svm, AC_VECTOR); + + set_intercept(svm, INTERCEPT_INTR); + set_intercept(svm, INTERCEPT_NMI); + set_intercept(svm, INTERCEPT_SMI); + set_intercept(svm, INTERCEPT_SELECTIVE_CR0); + set_intercept(svm, INTERCEPT_RDPMC); + set_intercept(svm, INTERCEPT_CPUID); + set_intercept(svm, INTERCEPT_INVD); + set_intercept(svm, INTERCEPT_HLT); + set_intercept(svm, INTERCEPT_INVLPG); + set_intercept(svm, INTERCEPT_INVLPGA); + set_intercept(svm, INTERCEPT_IOIO_PROT); + set_intercept(svm, INTERCEPT_MSR_PROT); + set_intercept(svm, INTERCEPT_TASK_SWITCH); + set_intercept(svm, INTERCEPT_SHUTDOWN); + set_intercept(svm, INTERCEPT_VMRUN); + set_intercept(svm, INTERCEPT_VMMCALL); + set_intercept(svm, INTERCEPT_VMLOAD); + set_intercept(svm, INTERCEPT_VMSAVE); + set_intercept(svm, INTERCEPT_STGI); + set_intercept(svm, INTERCEPT_CLGI); + set_intercept(svm, INTERCEPT_SKINIT); + set_intercept(svm, INTERCEPT_WBINVD); + set_intercept(svm, INTERCEPT_MONITOR); + set_intercept(svm, INTERCEPT_MWAIT); + set_intercept(svm, INTERCEPT_XSETBV); + + control->iopm_base_pa = iopm_base; + control->msrpm_base_pa = __pa(svm->msrpm); + control->int_ctl = V_INTR_MASKING_MASK; + + init_seg(&save->es); + init_seg(&save->ss); + init_seg(&save->ds); + init_seg(&save->fs); + init_seg(&save->gs); + + save->cs.selector = 0xf000; + save->cs.base = 0xffff0000; + /* Executable/Readable Code Segment */ + save->cs.attrib = SVM_SELECTOR_READ_MASK | SVM_SELECTOR_P_MASK | + SVM_SELECTOR_S_MASK | SVM_SELECTOR_CODE_MASK; + save->cs.limit = 0xffff; + + save->gdtr.limit = 0xffff; + save->idtr.limit = 0xffff; + + init_sys_seg(&save->ldtr, SEG_TYPE_LDT); + init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); + + svm_set_efer(&svm->vcpu, 0); + save->dr6 = 0xffff0ff0; + kvm_set_rflags(&svm->vcpu, 2); + save->rip = 0x0000fff0; + svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip; + + /* + * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0. + * It also updates the guest-visible cr0 value. + */ + svm_set_cr0(&svm->vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET); + kvm_mmu_reset_context(&svm->vcpu); + + save->cr4 = X86_CR4_PAE; + /* rdx = ?? */ + + if (npt_enabled) { + /* Setup VMCB for Nested Paging */ + control->nested_ctl = 1; + clr_intercept(svm, INTERCEPT_INVLPG); + clr_exception_intercept(svm, PF_VECTOR); + clr_cr_intercept(svm, INTERCEPT_CR3_READ); + clr_cr_intercept(svm, INTERCEPT_CR3_WRITE); + save->g_pat = svm->vcpu.arch.pat; + save->cr3 = 0; + save->cr4 = 0; + } + svm->asid_generation = 0; + + svm->nested.vmcb = 0; + svm->vcpu.arch.hflags = 0; + + if (boot_cpu_has(X86_FEATURE_PAUSEFILTER)) { + control->pause_filter_count = 3000; + set_intercept(svm, INTERCEPT_PAUSE); + } + + mark_all_dirty(svm->vmcb); + + enable_gif(svm); +} +","@@ -1019,6 +1019,7 @@ static void init_vmcb(struct vcpu_svm *svm) + set_exception_intercept(svm, PF_VECTOR); + set_exception_intercept(svm, UD_VECTOR); + set_exception_intercept(svm, MC_VECTOR); ++ set_exception_intercept(svm, AC_VECTOR); + + set_intercept(svm, INTERCEPT_INTR); + set_intercept(svm, INTERCEPT_NMI); +@@ -1707,6 +1708,12 @@ static int ud_interception(struct vcpu_svm *svm) + return 1; + } + ++static int ac_interception(struct vcpu_svm *svm) ++{ ++ kvm_queue_exception_e(&svm->vcpu, AC_VECTOR, 0); ++ return 1; ++} ++ + static void svm_fpu_activate(struct kvm_vcpu *vcpu) + { + struct vcpu_svm *svm = to_svm(vcpu); +@@ -3270,6 +3277,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = { + [SVM_EXIT_EXCP_BASE + PF_VECTOR] = pf_interception, + [SVM_EXIT_EXCP_BASE + NM_VECTOR] = nm_interception, + [SVM_EXIT_EXCP_BASE + MC_VECTOR] = mc_interception, ++ [SVM_EXIT_EXCP_BASE + AC_VECTOR] = ac_interception, + [SVM_EXIT_INTR] = intr_interception, + [SVM_EXIT_NMI] = nmi_interception, + [SVM_EXIT_SMI] = nop_on_interception,",1066,1302,2048 +7827,"static int setcos_set_security_env2(sc_card_t *card, + const sc_security_env_t *env, int se_num) +{ + sc_apdu_t apdu; + u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; + u8 *p; + int r, locked = 0; + + assert(card != NULL && env != NULL); + + if (card->type == SC_CARD_TYPE_SETCOS_44 || + card->type == SC_CARD_TYPE_SETCOS_NIDEL || + SETCOS_IS_EID_APPLET(card)) { + if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, ""symmetric keyref not supported.\n""); + return SC_ERROR_NOT_SUPPORTED; + } + if (se_num > 0) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, ""restore security environment not supported.\n""); + return SC_ERROR_NOT_SUPPORTED; + } + } + + sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0, 0); + switch (env->operation) { + case SC_SEC_OPERATION_DECIPHER: + /* Should be 0x81 */ + apdu.p1 = 0x41; + apdu.p2 = 0xB8; + break; + case SC_SEC_OPERATION_SIGN: + /* Should be 0x41 */ + apdu.p1 = ((card->type == SC_CARD_TYPE_SETCOS_FINEID_V2) || + (card->type == SC_CARD_TYPE_SETCOS_FINEID_V2_2048) || + (card->type == SC_CARD_TYPE_SETCOS_44) || + (card->type == SC_CARD_TYPE_SETCOS_NIDEL) || + SETCOS_IS_EID_APPLET(card)) ? 0x41 : 0x81; + apdu.p2 = 0xB6; + break; + default: + return SC_ERROR_INVALID_ARGUMENTS; + } + apdu.le = 0; + p = sbuf; + if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) { + *p++ = 0x80; /* algorithm reference */ + *p++ = 0x01; + *p++ = env->algorithm_ref & 0xFF; + } + if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) { + *p++ = 0x81; + *p++ = env->file_ref.len; + memcpy(p, env->file_ref.value, env->file_ref.len); + p += env->file_ref.len; + } + if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT && + !(card->type == SC_CARD_TYPE_SETCOS_NIDEL || + card->type == SC_CARD_TYPE_SETCOS_FINEID_V2_2048)) { + if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) + *p++ = 0x83; + else + *p++ = 0x84; + *p++ = env->key_ref_len; + memcpy(p, env->key_ref, env->key_ref_len); + p += env->key_ref_len; + } + r = p - sbuf; + apdu.lc = r; + apdu.datalen = r; + apdu.data = sbuf; + apdu.resplen = 0; + if (se_num > 0) { + r = sc_lock(card); + SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, ""sc_lock() failed""); + locked = 1; + } + if (apdu.datalen != 0) { + r = sc_transmit_apdu(card, &apdu); + if (r) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + ""%s: APDU transmit failed"", sc_strerror(r)); + goto err; + } + r = sc_check_sw(card, apdu.sw1, apdu.sw2); + if (r) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + ""%s: Card returned error"", sc_strerror(r)); + goto err; + } + } + if (se_num <= 0) + return 0; + sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xF2, se_num); + r = sc_transmit_apdu(card, &apdu); + sc_unlock(card); + SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, ""APDU transmit failed""); + return sc_check_sw(card, apdu.sw1, apdu.sw2); +err: + if (locked) + sc_unlock(card); + return r; +} +",0,"static int setcos_set_security_env2(sc_card_t *card, + const sc_security_env_t *env, int se_num) +{ + sc_apdu_t apdu; + u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; + u8 *p; + int r, locked = 0; + + assert(card != NULL && env != NULL); + + if (card->type == SC_CARD_TYPE_SETCOS_44 || + card->type == SC_CARD_TYPE_SETCOS_NIDEL || + SETCOS_IS_EID_APPLET(card)) { + if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, ""symmetric keyref not supported.\n""); + return SC_ERROR_NOT_SUPPORTED; + } + if (se_num > 0) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, ""restore security environment not supported.\n""); + return SC_ERROR_NOT_SUPPORTED; + } + } + + sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0, 0); + switch (env->operation) { + case SC_SEC_OPERATION_DECIPHER: + /* Should be 0x81 */ + apdu.p1 = 0x41; + apdu.p2 = 0xB8; + break; + case SC_SEC_OPERATION_SIGN: + /* Should be 0x41 */ + apdu.p1 = ((card->type == SC_CARD_TYPE_SETCOS_FINEID_V2) || + (card->type == SC_CARD_TYPE_SETCOS_FINEID_V2_2048) || + (card->type == SC_CARD_TYPE_SETCOS_44) || + (card->type == SC_CARD_TYPE_SETCOS_NIDEL) || + SETCOS_IS_EID_APPLET(card)) ? 0x41 : 0x81; + apdu.p2 = 0xB6; + break; + default: + return SC_ERROR_INVALID_ARGUMENTS; + } + apdu.le = 0; + p = sbuf; + if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) { + *p++ = 0x80; /* algorithm reference */ + *p++ = 0x01; + *p++ = env->algorithm_ref & 0xFF; + } + if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) { + *p++ = 0x81; + *p++ = env->file_ref.len; + memcpy(p, env->file_ref.value, env->file_ref.len); + p += env->file_ref.len; + } + if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT && + !(card->type == SC_CARD_TYPE_SETCOS_NIDEL || + card->type == SC_CARD_TYPE_SETCOS_FINEID_V2_2048)) { + if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) + *p++ = 0x83; + else + *p++ = 0x84; + *p++ = env->key_ref_len; + memcpy(p, env->key_ref, env->key_ref_len); + p += env->key_ref_len; + } + r = p - sbuf; + apdu.lc = r; + apdu.datalen = r; + apdu.data = sbuf; + apdu.resplen = 0; + if (se_num > 0) { + r = sc_lock(card); + SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, ""sc_lock() failed""); + locked = 1; + } + if (apdu.datalen != 0) { + r = sc_transmit_apdu(card, &apdu); + if (r) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + ""%s: APDU transmit failed"", sc_strerror(r)); + goto err; + } + r = sc_check_sw(card, apdu.sw1, apdu.sw2); + if (r) { + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + ""%s: Card returned error"", sc_strerror(r)); + goto err; + } + } + if (se_num <= 0) + return 0; + sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xF2, se_num); + r = sc_transmit_apdu(card, &apdu); + sc_unlock(card); + SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, ""APDU transmit failed""); + return sc_check_sw(card, apdu.sw1, apdu.sw2); +err: + if (locked) + sc_unlock(card); + return r; +} +","@@ -789,6 +789,8 @@ static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len) + /* Check all sub-AC definitions within the total AC */ + while (len > 1) { /* minimum length = 2 */ + int iACLen = buf[iOffset] & 0x0F; ++ if ((size_t) iACLen > len) ++ break; + + iPinCount = -1; /* default no pin required */ + iMethod = SC_AC_NONE; /* default no authentication required */ +@@ -806,7 +808,10 @@ static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len) + + /* Get KeyNumber if available */ + if(iKeyLen) { +- int iSC = buf[iOffset+iACLen]; ++ int iSC; ++ if (len < 1+iACLen) ++ break; ++ iSC = buf[iOffset+iACLen]; + + switch( (iSC>>5) & 0x03 ){ + case 0: +@@ -825,11 +830,15 @@ static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len) + + /* Get PinNumber if available */ + if (iACLen > (1+iParmLen+iKeyLen)) { /* check via total length if pin is present */ ++ if (len < 1+1+1+iParmLen) ++ break; + iKeyRef = buf[iOffset+1+1+iParmLen]; /* PTL + AM-header + parameter-bytes */ + iMethod = SC_AC_CHV; + } + + /* Convert SETCOS command to OpenSC command group */ ++ if (len < 1+2) ++ break; + switch(buf[iOffset+2]){ + case 0x2A: /* crypto operation */ + iOperation = SC_AC_OP_CRYPTO; +@@ -863,7 +872,10 @@ static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len) + iPinCount = iACLen - 1; + + if (buf[iOffset] & 0x20) { +- int iSC = buf[iOffset + iACLen]; ++ int iSC; ++ if (len < 1 + iACLen) ++ break; ++ iSC = buf[iOffset + iACLen]; + + switch( (iSC>>5) & 0x03 ) { + case 0: +@@ -884,6 +896,8 @@ static void parse_sec_attr_44(sc_file_t *file, const u8 *buf, size_t len) + + /* Pin present ? */ + if ( iPinCount > 0 ) { ++ if (len < 1 + 2) ++ break; + iKeyRef = buf[iOffset + 2]; /* pin ref */ + iMethod = SC_AC_CHV; + }",1018,1254,2048 +8247,"int WriteRiffHeader (FILE *outfile, WavpackContext *wpc, int64_t total_samples, int qmode) +{ + int do_rf64 = 0, write_junk = 1, table_length = 0; + ChunkHeader ds64hdr, datahdr, fmthdr; + RiffChunkHeader riffhdr; + DS64Chunk ds64_chunk; + CS64Chunk cs64_chunk; + JunkChunk junkchunk; + WaveHeader wavhdr; + uint32_t bcount; + + int64_t total_data_bytes, total_riff_bytes; + int num_channels = WavpackGetNumChannels (wpc); + int32_t channel_mask = WavpackGetChannelMask (wpc); + int32_t sample_rate = WavpackGetSampleRate (wpc); + int bytes_per_sample = WavpackGetBytesPerSample (wpc); + int bits_per_sample = WavpackGetBitsPerSample (wpc); + int format = WavpackGetFloatNormExp (wpc) ? 3 : 1; + int wavhdrsize = 16; + + if (format == 3 && WavpackGetFloatNormExp (wpc) != 127) { + error_line (""can't create valid RIFF wav header for non-normalized floating data!""); + return FALSE; + } + + if (total_samples == -1) + total_samples = 0x7ffff000 / (bytes_per_sample * num_channels); + + total_data_bytes = total_samples * bytes_per_sample * num_channels; + + if (total_data_bytes > 0xff000000) { + if (debug_logging_mode) + error_line (""total_data_bytes = %lld, so rf64"", total_data_bytes); + write_junk = 0; + do_rf64 = 1; + } + else if (debug_logging_mode) + error_line (""total_data_bytes = %lld, so riff"", total_data_bytes); + + CLEAR (wavhdr); + + wavhdr.FormatTag = format; + wavhdr.NumChannels = num_channels; + wavhdr.SampleRate = sample_rate; + wavhdr.BytesPerSecond = sample_rate * num_channels * bytes_per_sample; + wavhdr.BlockAlign = bytes_per_sample * num_channels; + wavhdr.BitsPerSample = bits_per_sample; + + if (num_channels > 2 || channel_mask != 0x5 - num_channels) { + wavhdrsize = sizeof (wavhdr); + wavhdr.cbSize = 22; + wavhdr.ValidBitsPerSample = bits_per_sample; + wavhdr.SubFormat = format; + wavhdr.ChannelMask = channel_mask; + wavhdr.FormatTag = 0xfffe; + wavhdr.BitsPerSample = bytes_per_sample * 8; + wavhdr.GUID [4] = 0x10; + wavhdr.GUID [6] = 0x80; + wavhdr.GUID [9] = 0xaa; + wavhdr.GUID [11] = 0x38; + wavhdr.GUID [12] = 0x9b; + wavhdr.GUID [13] = 0x71; + } + + strncpy (riffhdr.ckID, do_rf64 ? ""RF64"" : ""RIFF"", sizeof (riffhdr.ckID)); + strncpy (riffhdr.formType, ""WAVE"", sizeof (riffhdr.formType)); + total_riff_bytes = sizeof (riffhdr) + wavhdrsize + sizeof (datahdr) + ((total_data_bytes + 1) & ~(int64_t)1); + if (do_rf64) total_riff_bytes += sizeof (ds64hdr) + sizeof (ds64_chunk); + total_riff_bytes += table_length * sizeof (CS64Chunk); + if (write_junk) total_riff_bytes += sizeof (junkchunk); + strncpy (fmthdr.ckID, ""fmt "", sizeof (fmthdr.ckID)); + strncpy (datahdr.ckID, ""data"", sizeof (datahdr.ckID)); + fmthdr.ckSize = wavhdrsize; + + if (write_junk) { + CLEAR (junkchunk); + strncpy (junkchunk.ckID, ""junk"", sizeof (junkchunk.ckID)); + junkchunk.ckSize = sizeof (junkchunk) - 8; + WavpackNativeToLittleEndian (&junkchunk, ChunkHeaderFormat); + } + + if (do_rf64) { + strncpy (ds64hdr.ckID, ""ds64"", sizeof (ds64hdr.ckID)); + ds64hdr.ckSize = sizeof (ds64_chunk) + (table_length * sizeof (CS64Chunk)); + CLEAR (ds64_chunk); + ds64_chunk.riffSize64 = total_riff_bytes; + ds64_chunk.dataSize64 = total_data_bytes; + ds64_chunk.sampleCount64 = total_samples; + ds64_chunk.tableLength = table_length; + riffhdr.ckSize = (uint32_t) -1; + datahdr.ckSize = (uint32_t) -1; + WavpackNativeToLittleEndian (&ds64hdr, ChunkHeaderFormat); + WavpackNativeToLittleEndian (&ds64_chunk, DS64ChunkFormat); + } + else { + riffhdr.ckSize = (uint32_t) total_riff_bytes; + datahdr.ckSize = (uint32_t) total_data_bytes; + } + + + if (table_length) { + strncpy (cs64_chunk.ckID, ""dmmy"", sizeof (cs64_chunk.ckID)); + cs64_chunk.chunkSize64 = 12345678; + WavpackNativeToLittleEndian (&cs64_chunk, CS64ChunkFormat); + } + + + WavpackNativeToLittleEndian (&riffhdr, ChunkHeaderFormat); + WavpackNativeToLittleEndian (&fmthdr, ChunkHeaderFormat); + WavpackNativeToLittleEndian (&wavhdr, WaveHeaderFormat); + WavpackNativeToLittleEndian (&datahdr, ChunkHeaderFormat); + + if (!DoWriteFile (outfile, &riffhdr, sizeof (riffhdr), &bcount) || bcount != sizeof (riffhdr) || + (do_rf64 && (!DoWriteFile (outfile, &ds64hdr, sizeof (ds64hdr), &bcount) || bcount != sizeof (ds64hdr))) || + (do_rf64 && (!DoWriteFile (outfile, &ds64_chunk, sizeof (ds64_chunk), &bcount) || bcount != sizeof (ds64_chunk)))) { + error_line (""can't write .WAV data, disk probably full!""); + return FALSE; + } + + + while (table_length--) + if (!DoWriteFile (outfile, &cs64_chunk, sizeof (cs64_chunk), &bcount) || bcount != sizeof (cs64_chunk)) { + error_line (""can't write .WAV data, disk probably full!""); + return FALSE; + } + + + if ((write_junk && (!DoWriteFile (outfile, &junkchunk, sizeof (junkchunk), &bcount) || bcount != sizeof (junkchunk))) || + !DoWriteFile (outfile, &fmthdr, sizeof (fmthdr), &bcount) || bcount != sizeof (fmthdr) || + !DoWriteFile (outfile, &wavhdr, wavhdrsize, &bcount) || bcount != wavhdrsize || + !DoWriteFile (outfile, &datahdr, sizeof (datahdr), &bcount) || bcount != sizeof (datahdr)) { + error_line (""can't write .WAV data, disk probably full!""); + return FALSE; + } + + return TRUE; +} +",0,"int WriteRiffHeader (FILE *outfile, WavpackContext *wpc, int64_t total_samples, int qmode) +{ + int do_rf64 = 0, write_junk = 1, table_length = 0; + ChunkHeader ds64hdr, datahdr, fmthdr; + RiffChunkHeader riffhdr; + DS64Chunk ds64_chunk; + CS64Chunk cs64_chunk; + JunkChunk junkchunk; + WaveHeader wavhdr; + uint32_t bcount; + + int64_t total_data_bytes, total_riff_bytes; + int num_channels = WavpackGetNumChannels (wpc); + int32_t channel_mask = WavpackGetChannelMask (wpc); + int32_t sample_rate = WavpackGetSampleRate (wpc); + int bytes_per_sample = WavpackGetBytesPerSample (wpc); + int bits_per_sample = WavpackGetBitsPerSample (wpc); + int format = WavpackGetFloatNormExp (wpc) ? 3 : 1; + int wavhdrsize = 16; + + if (format == 3 && WavpackGetFloatNormExp (wpc) != 127) { + error_line (""can't create valid RIFF wav header for non-normalized floating data!""); + return FALSE; + } + + if (total_samples == -1) + total_samples = 0x7ffff000 / (bytes_per_sample * num_channels); + + total_data_bytes = total_samples * bytes_per_sample * num_channels; + + if (total_data_bytes > 0xff000000) { + if (debug_logging_mode) + error_line (""total_data_bytes = %lld, so rf64"", total_data_bytes); + write_junk = 0; + do_rf64 = 1; + } + else if (debug_logging_mode) + error_line (""total_data_bytes = %lld, so riff"", total_data_bytes); + + CLEAR (wavhdr); + + wavhdr.FormatTag = format; + wavhdr.NumChannels = num_channels; + wavhdr.SampleRate = sample_rate; + wavhdr.BytesPerSecond = sample_rate * num_channels * bytes_per_sample; + wavhdr.BlockAlign = bytes_per_sample * num_channels; + wavhdr.BitsPerSample = bits_per_sample; + + if (num_channels > 2 || channel_mask != 0x5 - num_channels) { + wavhdrsize = sizeof (wavhdr); + wavhdr.cbSize = 22; + wavhdr.ValidBitsPerSample = bits_per_sample; + wavhdr.SubFormat = format; + wavhdr.ChannelMask = channel_mask; + wavhdr.FormatTag = 0xfffe; + wavhdr.BitsPerSample = bytes_per_sample * 8; + wavhdr.GUID [4] = 0x10; + wavhdr.GUID [6] = 0x80; + wavhdr.GUID [9] = 0xaa; + wavhdr.GUID [11] = 0x38; + wavhdr.GUID [12] = 0x9b; + wavhdr.GUID [13] = 0x71; + } + + strncpy (riffhdr.ckID, do_rf64 ? ""RF64"" : ""RIFF"", sizeof (riffhdr.ckID)); + strncpy (riffhdr.formType, ""WAVE"", sizeof (riffhdr.formType)); + total_riff_bytes = sizeof (riffhdr) + wavhdrsize + sizeof (datahdr) + ((total_data_bytes + 1) & ~(int64_t)1); + if (do_rf64) total_riff_bytes += sizeof (ds64hdr) + sizeof (ds64_chunk); + total_riff_bytes += table_length * sizeof (CS64Chunk); + if (write_junk) total_riff_bytes += sizeof (junkchunk); + strncpy (fmthdr.ckID, ""fmt "", sizeof (fmthdr.ckID)); + strncpy (datahdr.ckID, ""data"", sizeof (datahdr.ckID)); + fmthdr.ckSize = wavhdrsize; + + if (write_junk) { + CLEAR (junkchunk); + strncpy (junkchunk.ckID, ""junk"", sizeof (junkchunk.ckID)); + junkchunk.ckSize = sizeof (junkchunk) - 8; + WavpackNativeToLittleEndian (&junkchunk, ChunkHeaderFormat); + } + + if (do_rf64) { + strncpy (ds64hdr.ckID, ""ds64"", sizeof (ds64hdr.ckID)); + ds64hdr.ckSize = sizeof (ds64_chunk) + (table_length * sizeof (CS64Chunk)); + CLEAR (ds64_chunk); + ds64_chunk.riffSize64 = total_riff_bytes; + ds64_chunk.dataSize64 = total_data_bytes; + ds64_chunk.sampleCount64 = total_samples; + ds64_chunk.tableLength = table_length; + riffhdr.ckSize = (uint32_t) -1; + datahdr.ckSize = (uint32_t) -1; + WavpackNativeToLittleEndian (&ds64hdr, ChunkHeaderFormat); + WavpackNativeToLittleEndian (&ds64_chunk, DS64ChunkFormat); + } + else { + riffhdr.ckSize = (uint32_t) total_riff_bytes; + datahdr.ckSize = (uint32_t) total_data_bytes; + } + + + if (table_length) { + strncpy (cs64_chunk.ckID, ""dmmy"", sizeof (cs64_chunk.ckID)); + cs64_chunk.chunkSize64 = 12345678; + WavpackNativeToLittleEndian (&cs64_chunk, CS64ChunkFormat); + } + + + WavpackNativeToLittleEndian (&riffhdr, ChunkHeaderFormat); + WavpackNativeToLittleEndian (&fmthdr, ChunkHeaderFormat); + WavpackNativeToLittleEndian (&wavhdr, WaveHeaderFormat); + WavpackNativeToLittleEndian (&datahdr, ChunkHeaderFormat); + + if (!DoWriteFile (outfile, &riffhdr, sizeof (riffhdr), &bcount) || bcount != sizeof (riffhdr) || + (do_rf64 && (!DoWriteFile (outfile, &ds64hdr, sizeof (ds64hdr), &bcount) || bcount != sizeof (ds64hdr))) || + (do_rf64 && (!DoWriteFile (outfile, &ds64_chunk, sizeof (ds64_chunk), &bcount) || bcount != sizeof (ds64_chunk)))) { + error_line (""can't write .WAV data, disk probably full!""); + return FALSE; + } + + + while (table_length--) + if (!DoWriteFile (outfile, &cs64_chunk, sizeof (cs64_chunk), &bcount) || bcount != sizeof (cs64_chunk)) { + error_line (""can't write .WAV data, disk probably full!""); + return FALSE; + } + + + if ((write_junk && (!DoWriteFile (outfile, &junkchunk, sizeof (junkchunk), &bcount) || bcount != sizeof (junkchunk))) || + !DoWriteFile (outfile, &fmthdr, sizeof (fmthdr), &bcount) || bcount != sizeof (fmthdr) || + !DoWriteFile (outfile, &wavhdr, wavhdrsize, &bcount) || bcount != wavhdrsize || + !DoWriteFile (outfile, &datahdr, sizeof (datahdr), &bcount) || bcount != sizeof (datahdr)) { + error_line (""can't write .WAV data, disk probably full!""); + return FALSE; + } + + return TRUE; +} +","@@ -286,7 +286,14 @@ int ParseRiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpack + else { // just copy unknown chunks to output file + + int bytes_to_copy = (chunk_header.ckSize + 1) & ~1L; +- char *buff = malloc (bytes_to_copy); ++ char *buff; ++ ++ if (bytes_to_copy < 0 || bytes_to_copy > 4194304) { ++ error_line (""%s is not a valid .WAV file!"", infilename); ++ return WAVPACK_SOFT_ERROR; ++ } ++ ++ buff = malloc (bytes_to_copy); + + if (debug_logging_mode) + error_line (""extra unknown chunk \""%c%c%c%c\"" of %d bytes"",",1727,1963,2048 +18271,"double GetGPMFSampleRate(size_t handle, uint32_t fourcc, uint32_t flags) + { + mp4object *mp4 = (mp4object *)handle; + if (mp4 == NULL) return 0.0; + + GPMF_stream metadata_stream, *ms = &metadata_stream; + uint32_t teststart = 0; + uint32_t testend = mp4->indexcount; + double rate = 0.0; + + if (mp4->indexcount < 1) + return 0.0; + + if (mp4->indexcount > 3) // samples after first and before last are statistically the best, avoiding camera start up or shutdown anomollies. + { + teststart++; + testend--; + } + uint32_t *payload = GetPayload(handle, NULL, teststart); // second payload + uint32_t payloadsize = GetPayloadSize(handle, teststart); + int32_t ret = GPMF_Init(ms, payload, payloadsize); + + if (ret != GPMF_OK) + goto cleanup; + + { + uint32_t startsamples = 0; + uint32_t endsamples = 0; + uint32_t missing_samples = 0; + + while (ret == GPMF_OK && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { + missing_samples = 1; + teststart++; + payload = GetPayload(handle, payload, teststart); // second last payload + payloadsize = GetPayloadSize(handle, teststart); + ret = GPMF_Init(ms, payload, payloadsize); + } + + if (missing_samples) + { + teststart++; //samples after sensor start are statistically the best + payload = GetPayload(handle, payload, teststart); + payloadsize = GetPayloadSize(handle, teststart); + ret = GPMF_Init(ms, payload, payloadsize); + } + if (ret == GPMF_OK) + { + uint32_t samples = GPMF_Repeat(ms); + GPMF_stream find_stream; + GPMF_CopyState(ms, &find_stream); + + if (!(flags & GPMF_SAMPLE_RATE_PRECISE) && GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) + { + startsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)) - samples; + + payload = GetPayload(handle, payload, testend); // second last payload + payloadsize = GetPayloadSize(handle, testend); + ret = GPMF_Init(ms, payload, payloadsize); + if (ret != GPMF_OK) + goto cleanup; + + if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { + GPMF_CopyState(ms, &find_stream); + if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) + { + endsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)); + rate = (double)(endsamples - startsamples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + goto cleanup; + } + } + rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + } + else // for increased precision, for older GPMF streams sometimes missing the total sample count + { + uint32_t payloadpos = 0, payloadcount = 0; + double slope, top = 0.0, bot = 0.0, meanX = 0, meanY = 0; + uint32_t *repeatarray = malloc(mp4->indexcount * 4 + 4); + memset(repeatarray, 0, mp4->indexcount * 4 + 4); + + samples = 0; + + for (payloadpos = teststart; payloadpos < testend; payloadcount++, payloadpos++) + { + payload = GetPayload(handle, payload, payloadpos); // second last payload + payloadsize = GetPayloadSize(handle, payloadpos); + ret = GPMF_Init(ms, payload, payloadsize); + + if (ret != GPMF_OK) + goto cleanup; + + if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { + GPMF_stream find_stream2; + GPMF_CopyState(ms, &find_stream2); + + if (GPMF_OK == GPMF_FindNext(&find_stream2, fourcc, GPMF_CURRENT_LEVEL)) // Count the instances, not the repeats + { + if (repeatarray) + { + float in, out; + + do + { + samples++; + } while (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_CURRENT_LEVEL)); + + repeatarray[payloadpos] = samples; + meanY += (double)samples; + + GetPayloadTime(handle, payloadpos, &in, &out); + meanX += out; + } + } + else + { + uint32_t repeat = GPMF_Repeat(ms); + samples += repeat; + + if (repeatarray) + { + float in, out; + + repeatarray[payloadpos] = samples; + meanY += (double)samples; + + GetPayloadTime(handle, payloadpos, &in, &out); + meanX += out; + } + } + } + } + if (repeatarray) + { + meanY /= (double)payloadcount; + meanX /= (double)payloadcount; + + for (payloadpos = teststart; payloadpos < testend; payloadpos++) + { + float in, out; + GetPayloadTime(handle, payloadpos, &in, &out); + + top += ((double)out - meanX)*((double)repeatarray[payloadpos] - meanY); + bot += ((double)out - meanX)*((double)out - meanX); + } + + slope = top / bot; + + #if 0 + { + double intercept; + intercept = meanY - slope*meanX; + printf(""%c%c%c%c start offset = %f (%.3fms)\n"", PRINTF_4CC(fourcc), intercept, 1000.0 * intercept / slope); + } +#endif + rate = slope; + } + else + { + rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + } + free(repeatarray); + + goto cleanup; + } + } + } + +cleanup: + if (payload) + { + FreePayload(payload); + payload = NULL; + } + return rate; +} +",1,"double GetGPMFSampleRate(size_t handle, uint32_t fourcc, uint32_t flags) +double GetGPMFSampleRate(size_t handle, uint32_t fourcc, uint32_t flags, double *firstsampletime, double *lastsampletime) + { + mp4object *mp4 = (mp4object *)handle; + if (mp4 == NULL) return 0.0; + + GPMF_stream metadata_stream, *ms = &metadata_stream; + uint32_t teststart = 0; + uint32_t testend = mp4->indexcount; + double rate = 0.0; + + uint32_t *payload; + uint32_t payloadsize; + int32_t ret; + + if (mp4->indexcount < 1) + return 0.0; + + payload = GetPayload(handle, NULL, teststart); + payloadsize = GetPayloadSize(handle, teststart); + ret = GPMF_Init(ms, payload, payloadsize); + + if (ret != GPMF_OK) + goto cleanup; + + { + uint64_t minimumtimestamp = 0; + uint64_t starttimestamp = 0; + uint64_t endtimestamp = 0; + uint32_t startsamples = 0; + uint32_t endsamples = 0; + double intercept = 0.0; + + + + while (teststart < mp4->indexcount && ret == GPMF_OK && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { + teststart++; + payload = GetPayload(handle, payload, teststart); // second last payload + payloadsize = GetPayloadSize(handle, teststart); + ret = GPMF_Init(ms, payload, payloadsize); + } + + if (ret == GPMF_OK && payload) + { + uint32_t samples = GPMF_PayloadSampleCount(ms); + GPMF_stream find_stream; + GPMF_CopyState(ms, &find_stream); + if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) + startsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)) - samples; + + GPMF_CopyState(ms, &find_stream); + if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TIME_STAMP, GPMF_CURRENT_LEVEL)) + starttimestamp = BYTESWAP64(*(uint64_t *)GPMF_RawData(&find_stream)); + + if (starttimestamp) // is this earliest in the payload, examine the other streams in this early payload. + { + GPMF_stream any_stream; + GPMF_Init(&any_stream, payload, payloadsize); + + minimumtimestamp = starttimestamp; + while (GPMF_OK == GPMF_FindNext(&any_stream, GPMF_KEY_TIME_STAMP, GPMF_RECURSE_LEVELS)) + { + uint64_t timestamp = BYTESWAP64(*(uint64_t *)GPMF_RawData(&any_stream)); + if (timestamp < minimumtimestamp) + minimumtimestamp = timestamp; + } + } + + testend = mp4->indexcount; + do + { + testend--;// last payload with the fourcc needed + payload = GetPayload(handle, payload, testend); + payloadsize = GetPayloadSize(handle, testend); + ret = GPMF_Init(ms, payload, payloadsize); + } while (testend > 0 && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)); + + GPMF_CopyState(ms, &find_stream); + if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) + endsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)); + else // If there is no TSMP we have to count the samples. + { + uint32_t i; + for (i = teststart; i <= testend; i++) + { + payload = GetPayload(handle,payload, i); // second last payload + payloadsize = GetPayloadSize(handle, i); + if (GPMF_OK == GPMF_Init(ms, payload, payloadsize)) + if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + endsamples += GPMF_PayloadSampleCount(ms); + } + } + + if (starttimestamp != 0) + { + uint32_t last_samples = GPMF_PayloadSampleCount(ms); + uint32_t totaltimestamped_samples = endsamples - last_samples - startsamples; + double time_stamp_scale = 1000000000.0; // scan for nanoseconds, microseconds to seconds, all base 10. + + GPMF_CopyState(ms, &find_stream); + if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TIME_STAMP, GPMF_CURRENT_LEVEL)) + endtimestamp = BYTESWAP64(*(uint64_t *)GPMF_RawData(&find_stream)); + + if (endtimestamp) + { + double approxrate = 0.0; + if (endsamples > startsamples) + approxrate = (double)(endsamples - startsamples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + + if (approxrate == 0.0) + approxrate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + + + while (time_stamp_scale >= 1) + { + rate = (double)(totaltimestamped_samples) / ((double)(endtimestamp - starttimestamp) / time_stamp_scale); + if (rate*0.9 < approxrate && approxrate < rate*1.1) + break; + + time_stamp_scale *= 0.1; + } + if (time_stamp_scale < 1.0) rate = 0.0; + intercept = (((double)minimumtimestamp - (double)starttimestamp) / time_stamp_scale) * rate; + } + } + + if (rate == 0.0) //Timestamps didn't help weren't available + { + if (!(flags & GPMF_SAMPLE_RATE_PRECISE)) + { + if (endsamples > startsamples) + rate = (double)(endsamples - startsamples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + + if (rate == 0.0) + rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + + double in, out; + if (GPMF_OK == GetPayloadTime(handle, teststart, &in, &out)) + intercept = (double)-in * rate; + } + else // for increased precision, for older GPMF streams sometimes missing the total sample count + { + uint32_t payloadpos = 0, payloadcount = 0; + double slope, top = 0.0, bot = 0.0, meanX = 0, meanY = 0; + uint32_t *repeatarray = malloc(mp4->indexcount * 4 + 4); + memset(repeatarray, 0, mp4->indexcount * 4 + 4); + + samples = 0; + + for (payloadpos = teststart; payloadpos <= testend; payloadpos++) + { + payload = GetPayload(handle, payload, payloadpos); // second last payload + payloadsize = GetPayloadSize(handle, payloadpos); + ret = GPMF_Init(ms, payload, payloadsize); + + if (ret != GPMF_OK) + goto cleanup; + + if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { + GPMF_stream find_stream2; + GPMF_CopyState(ms, &find_stream2); + + payloadcount++; + + if (GPMF_OK == GPMF_FindNext(&find_stream2, fourcc, GPMF_CURRENT_LEVEL)) // Count the instances, not the repeats + { + if (repeatarray) + { + double in, out; + + do + { + samples++; + } while (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_CURRENT_LEVEL)); + + repeatarray[payloadpos] = samples; + meanY += (double)samples; + + if (GPMF_OK == GetPayloadTime(handle, payloadpos, &in, &out)) + meanX += out; + } + } + else + { + uint32_t repeat = GPMF_PayloadSampleCount(ms); + samples += repeat; + + if (repeatarray) + { + double in, out; + + repeatarray[payloadpos] = samples; + meanY += (double)samples; + + if (GPMF_OK == GetPayloadTime(handle, payloadpos, &in, &out)) + meanX += out; + } + } + } + else + { + repeatarray[payloadpos] = 0; + } + } + + // Compute the line of best fit for a jitter removed sample rate. + // This does assume an unchanging clock, even though the IMU data can thermally impacted causing small clock changes. + // TODO: Next enhancement would be a low order polynominal fit the compensate for any thermal clock drift. + if (repeatarray) + { + meanY /= (double)payloadcount; + meanX /= (double)payloadcount; + + for (payloadpos = teststart; payloadpos <= testend; payloadpos++) + { + double in, out; + if (repeatarray[payloadpos] && GPMF_OK == GetPayloadTime(handle, payloadpos, &in, &out)) + { + top += ((double)out - meanX)*((double)repeatarray[payloadpos] - meanY); + bot += ((double)out - meanX)*((double)out - meanX); + } + } + + slope = top / bot; + rate = slope; + + // This sample code might be useful for compare data latency between channels. + intercept = meanY - slope * meanX; + #if 0 + printf(""%c%c%c%c start offset = %f (%.3fms) rate = %f\n"", PRINTF_4CC(fourcc), intercept, 1000.0 * intercept / slope, rate); + printf(""%c%c%c%c first sample at time %.3fms\n"", PRINTF_4CC(fourcc), -1000.0 * intercept / slope); +#endif + } + else + { + rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + } + + free(repeatarray); + } + } + +","@@ -2,15 +2,14 @@ + * + * @brief Way Too Crude MP4|MOV reader + * +-* @version 1.2.1 ++* @version 1.3.1 + * +-* (C) Copyright 2017 GoPro Inc (http://gopro.com/). ++* (C) Copyright 2017-2019 GoPro Inc (http://gopro.com/). + * +-* Licensed under the Apache License, Version 2.0 (the ""License""); +-* you may not use this file except in compliance with the License. +-* You may obtain a copy of the License at +-* +-* http://www.apache.org/licenses/LICENSE-2.0 ++* Licensed under either: ++* - Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0 ++* - MIT license, http://opensource.org/licenses/MIT ++* at your option. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an ""AS IS"" BASIS, +@@ -20,21 +19,24 @@ + * + */ + +-/* This is not an elegant MP4 parser, only used to help demonstrate extraction of MP4 */ +- ++/* This is not an elegant MP4 parser, only used to help demonstrate extraction of GPMF */ + + #include + #include + #include + #include ++#include ++#include ++ + #include ""GPMF_mp4reader.h"" + + #define PRINT_MP4_STRUCTURE 0 + + #ifdef WIN32 +-#define LONGSEEK _fseeki64 ++#define LONGSEEK _fseeki64 ++#define stat64 _stat64 + #else +-#define LONGSEEK fseeko ++#define LONGSEEK fseeko + #endif + + +@@ -50,7 +52,6 @@ uint32_t GetNumberPayloads(size_t handle) + return 0; + } + +- + uint32_t *GetPayload(size_t handle, uint32_t *lastpayload, uint32_t index) + { + mp4object *mp4 = (mp4object *)handle; +@@ -63,31 +64,35 @@ uint32_t *GetPayload(size_t handle, uint32_t *lastpayload, uint32_t index) + + if (MP4buffer) + { +- LONGSEEK(mp4->mediafp, mp4->metaoffsets[index], SEEK_SET); +- fread(MP4buffer, 1, mp4->metasizes[index], mp4->mediafp); +- return MP4buffer; ++ if (mp4->filesize > mp4->metaoffsets[index]+mp4->metasizes[index]) ++ { ++ LONGSEEK(mp4->mediafp, mp4->metaoffsets[index], SEEK_SET); ++ fread(MP4buffer, 1, mp4->metasizes[index], mp4->mediafp); ++ mp4->filepos = mp4->metaoffsets[index] + mp4->metasizes[index]; ++ return MP4buffer; ++ } + } + } + return NULL; + } + + +-void SavePayload(size_t handle, uint32_t *payload, uint32_t index) ++void LongSeek(mp4object *mp4, int64_t offset) + { +- mp4object *mp4 = (mp4object *)handle; +- if (mp4 == NULL) return; +- +- uint32_t *MP4buffer = NULL; +- if (index < mp4->indexcount && mp4->mediafp && payload) ++ if (mp4 && offset) + { +- LONGSEEK(mp4->mediafp, mp4->metaoffsets[index], SEEK_SET); +- fwrite(payload, 1, mp4->metasizes[index], mp4->mediafp); ++ if (mp4->filepos + offset < mp4->filesize) ++ { ++ LONGSEEK(mp4->mediafp, offset, SEEK_CUR); ++ mp4->filepos += offset; ++ } ++ else ++ { ++ mp4->filepos = mp4->filesize; ++ } + } +- return; + } + +- +- + void FreePayload(uint32_t *lastpayload) + { + if (lastpayload) +@@ -106,6 +111,7 @@ uint32_t GetPayloadSize(size_t handle, uint32_t index) + return 0; + } + ++ + #define MAX_NEST_LEVEL 20 + + size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) //RAW or within MP4 +@@ -115,6 +121,12 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + + memset(mp4, 0, sizeof(mp4object)); + ++ struct stat64 mp4stat; ++ stat64(filename, &mp4stat); ++ mp4->filesize = mp4stat.st_size; ++ ++ if (mp4->filesize < 64) return 0; ++ + #ifdef _WINDOWS + fopen_s(&mp4->mediafp, filename, ""rb""); + #else +@@ -129,25 +141,27 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + uint64_t nestsize[MAX_NEST_LEVEL] = { 0 }; + uint64_t lastsize = 0, qtsize; + ++ + do + { + len = fread(&qtsize32, 1, 4, mp4->mediafp); + len += fread(&qttag, 1, 4, mp4->mediafp); +- if (len == 8) ++ mp4->filepos += len; ++ if (len == 8 && mp4->filepos < mp4->filesize) + { + if (!VALID_FOURCC(qttag)) + { +- LONGSEEK(mp4->mediafp, lastsize - 8 - 8, SEEK_CUR); +- +- NESTSIZE(lastsize - 8); +- continue; ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; + } + + qtsize32 = BYTESWAP32(qtsize32); + + if (qtsize32 == 1) // 64-bit Atom + { +- fread(&qtsize, 1, 8, mp4->mediafp); ++ len = fread(&qtsize, 1, 8, mp4->mediafp); ++ mp4->filepos += len; + qtsize = BYTESWAP64(qtsize) - 8; + } + else +@@ -168,9 +182,10 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + + if (qttag == MAKEID('m', 'd', 'a', 't') || + qttag == MAKEID('f', 't', 'y', 'p') || +- qttag == MAKEID('u', 'd', 't', 'a')) ++ qttag == MAKEID('u', 'd', 't', 'a') || ++ qttag == MAKEID('f', 'r', 'e', 'e')) + { +- LONGSEEK(mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + +@@ -187,8 +202,6 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + qttag != MAKEID('d', 'i', 'n', 'f') && + qttag != MAKEID('a', 'l', 'i', 's') && + qttag != MAKEID('s', 't', 's', 'd') && +- qttag != MAKEID('a', 'l', 'i', 's') && +- qttag != MAKEID('a', 'l', 'i', 's') && + qttag != MAKEID('s', 't', 'b', 'l') && + qttag != MAKEID('s', 't', 't', 's') && + qttag != MAKEID('s', 't', 's', 'c') && +@@ -197,7 +210,7 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + qttag != MAKEID('c', 'o', '6', '4') && + qttag != MAKEID('h', 'd', 'l', 'r')) + { +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -210,7 +223,9 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + len += fread(&skip, 1, 4, mp4->mediafp); + len += fread(&mp4->clockdemon, 1, 4, mp4->mediafp); mp4->clockdemon = BYTESWAP32(mp4->clockdemon); + len += fread(&mp4->clockcount, 1, 4, mp4->mediafp); mp4->clockcount = BYTESWAP32(mp4->clockcount); +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over mvhd ++ ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over mvhd + + NESTSIZE(qtsize); + } +@@ -233,7 +248,9 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + mp4->videolength = (float)((double)mp4->trak_clockcount / (double)mp4->trak_clockdemon); + } + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over mvhd ++ ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over mvhd + + NESTSIZE(qtsize); + } +@@ -244,10 +261,11 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + len += fread(&skip, 1, 4, mp4->mediafp); + len += fread(&temp, 1, 4, mp4->mediafp); // type will be 'meta' for the correct trak. + +- if (temp != MAKEID('a', 'l', 'i', 's')) ++ if (temp != MAKEID('a', 'l', 'i', 's') && temp != MAKEID('u', 'r', 'l', ' ')) + type = temp; + +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over hldr ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over hldr + + NESTSIZE(qtsize); + +@@ -267,10 +285,11 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + type = 0; // MP4 + } + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over stsd ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over stsd + } + else +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -286,32 +305,35 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + { + mp4->metastsc_count = num; + if (mp4->metastsc) free(mp4->metastsc); +- mp4->metastsc = (SampleToChunk *)malloc(num * 12); +- if (mp4->metastsc) ++ if (num > 0) + { +- uint32_t total_stsc = num; +- len += fread(mp4->metastsc, 1, num * sizeof(SampleToChunk), mp4->mediafp); +- +- do ++ mp4->metastsc = (SampleToChunk *)malloc(num * sizeof(SampleToChunk)); ++ if (mp4->metastsc) + { +- num--; +- mp4->metastsc[num].chunk_num = BYTESWAP32(mp4->metastsc[num].chunk_num); +- mp4->metastsc[num].samples = BYTESWAP32(mp4->metastsc[num].samples); +- mp4->metastsc[num].id = BYTESWAP32(mp4->metastsc[num].id); +- } while (num > 0); +- } ++ len += fread(mp4->metastsc, 1, num * sizeof(SampleToChunk), mp4->mediafp); + +- if (mp4->metastsc_count == 1 && mp4->metastsc[0].samples == 1) // Simplify if the stsc is not reporting any grouped chunks. ++ do ++ { ++ num--; ++ mp4->metastsc[num].chunk_num = BYTESWAP32(mp4->metastsc[num].chunk_num); ++ mp4->metastsc[num].samples = BYTESWAP32(mp4->metastsc[num].samples); ++ mp4->metastsc[num].id = BYTESWAP32(mp4->metastsc[num].id); ++ } while (num > 0); ++ } ++ } ++ else + { +- if (mp4->metastsc) free(mp4->metastsc); +- mp4->metastsc = NULL; +- mp4->metastsc_count = 0; ++ //size of null ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; + } + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over stsx ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over stsx + } + else +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -330,33 +352,44 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + { + mp4->metasize_count = num; + if (mp4->metasizes) free(mp4->metasizes); +- mp4->metasizes = (uint32_t *)malloc(num * 4); +- if (mp4->metasizes) ++ if(num > 0) + { +- if (equalsamplesize == 0) ++ mp4->metasizes = (uint32_t *)malloc(num * 4); ++ if (mp4->metasizes) + { +- len += fread(mp4->metasizes, 1, num * 4, mp4->mediafp); +- do ++ if (equalsamplesize == 0) + { +- num--; +- mp4->metasizes[num] = BYTESWAP32(mp4->metasizes[num]); +- } while (num > 0); +- } +- else +- { +- equalsamplesize = BYTESWAP32(equalsamplesize); +- do ++ len += fread(mp4->metasizes, 1, num * 4, mp4->mediafp); ++ do ++ { ++ num--; ++ mp4->metasizes[num] = BYTESWAP32(mp4->metasizes[num]); ++ } while (num > 0); ++ } ++ else + { +- num--; +- mp4->metasizes[num] = equalsamplesize; +- } while (num > 0); ++ equalsamplesize = BYTESWAP32(equalsamplesize); ++ do ++ { ++ num--; ++ mp4->metasizes[num] = equalsamplesize; ++ } while (num > 0); ++ } + } + } ++ else ++ { ++ //size of null ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; ++ } + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over stsz ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over stsz + } + else +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -369,93 +402,121 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + num = BYTESWAP32(num); + if (num * 4 <= qtsize - 8 - len) + { ++ uint32_t metastco_count = num; ++ + if (mp4->metastsc_count > 0 && num != mp4->metasize_count) + { +- mp4->indexcount = mp4->metasize_count; ++ mp4->indexcount = num; + if (mp4->metaoffsets) free(mp4->metaoffsets); +- mp4->metaoffsets = (uint64_t *)malloc(mp4->metasize_count * 8); +- if (mp4->metaoffsets) ++ if(num > 0) + { +- uint32_t *metaoffsets32 = NULL; +- metaoffsets32 = (uint32_t *)malloc(num * 4); +- if (metaoffsets32) ++ mp4->metaoffsets = (uint64_t *)malloc(num * 8); ++ if (mp4->metaoffsets) + { +- uint64_t fileoffset = 0; +- int stsc_pos = 0; +- int stco_pos = 0; +- int repeat = 1; +- len += fread(metaoffsets32, 1, num * 4, mp4->mediafp); +- do +- { +- num--; +- metaoffsets32[num] = BYTESWAP32(metaoffsets32[num]); +- } while (num > 0); +- +- mp4->metaoffsets[0] = fileoffset = metaoffsets32[stco_pos]; +- num = 1; +- while (num < mp4->metasize_count) ++ uint32_t *metaoffsets32 = NULL; ++ metaoffsets32 = (uint32_t *)malloc(num * 4); ++ if (metaoffsets32) + { +- if (stsc_pos + 1 < (int)mp4->metastsc_count && num == stsc_pos) ++ uint64_t fileoffset = 0; ++ int stsc_pos = 0; ++ int stco_pos = 0; ++ int repeat = 1; ++ len += fread(metaoffsets32, 1, num * 4, mp4->mediafp); ++ do + { +- stco_pos++; stsc_pos++; +- fileoffset = (uint64_t)metaoffsets32[stco_pos]; +- repeat = 1; +- } +- else if (repeat == mp4->metastsc[stsc_pos].samples) +- { +- stco_pos++; +- fileoffset = (uint64_t)metaoffsets32[stco_pos]; +- repeat = 1; +- } +- else ++ num--; ++ metaoffsets32[num] = BYTESWAP32(metaoffsets32[num]); ++ } while (num > 0); ++ ++ mp4->metaoffsets[0] = fileoffset = metaoffsets32[stco_pos]; ++ num = 1; ++ while (num < mp4->indexcount) + { +- fileoffset += (uint64_t)mp4->metasizes[num - 1]; +- repeat++; ++ if ((uint32_t)repeat == mp4->metastsc[stsc_pos].samples) ++ { ++ if ((uint32_t)stco_pos + 1 < metastco_count) ++ { ++ stco_pos++; ++ fileoffset = (uint64_t)metaoffsets32[stco_pos]; ++ } ++ else ++ { ++ fileoffset += (uint64_t)mp4->metasizes[num - 1]; ++ } ++ if ((uint32_t)stsc_pos + 1 < mp4->metastsc_count) ++ if (mp4->metastsc[stsc_pos + 1].chunk_num == (uint32_t)stco_pos + 1) ++ stsc_pos++; ++ ++ repeat = 1; ++ } ++ else ++ { ++ fileoffset += (uint64_t)mp4->metasizes[num - 1]; ++ repeat++; ++ } ++ ++ mp4->metaoffsets[num] = fileoffset; ++ //int delta = metaoffsets[num] - metaoffsets[num - 1]; ++ //printf(""%3d:%08x, delta = %08x\n"", num, (int)fileoffset, delta); ++ ++ num++; + } + +- mp4->metaoffsets[num] = fileoffset; +- //int delta = metaoffsets[num] - metaoffsets[num - 1]; +- //printf(""%3d:%08x, delta = %08x\n"", num, (int)fileoffset, delta); ++ if (mp4->metastsc) free(mp4->metastsc); ++ mp4->metastsc = NULL; ++ mp4->metastsc_count = 0; + +- num++; ++ free(metaoffsets32); + } +- +- if (mp4->metastsc) free(mp4->metastsc); +- mp4->metastsc = NULL; +- mp4->metastsc_count = 0; +- +- free(metaoffsets32); + } + } ++ else ++ { ++ //size of null ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; ++ } + } + else + { + mp4->indexcount = num; + if (mp4->metaoffsets) free(mp4->metaoffsets); +- mp4->metaoffsets = (uint64_t *)malloc(num * 8); +- if (mp4->metaoffsets) ++ if (num > 0) + { +- uint32_t *metaoffsets32 = NULL; +- metaoffsets32 = (uint32_t *)malloc(num * 4); +- if (metaoffsets32) ++ mp4->metaoffsets = (uint64_t *)malloc(num * 8); ++ if (mp4->metaoffsets) + { +- size_t readlen = fread(metaoffsets32, 1, num * 4, mp4->mediafp); +- len += readlen; +- do ++ uint32_t *metaoffsets32 = NULL; ++ metaoffsets32 = (uint32_t *)malloc(num * 4); ++ if (metaoffsets32) + { +- num--; +- mp4->metaoffsets[num] = BYTESWAP32(metaoffsets32[num]); +- } while (num > 0); ++ size_t readlen = fread(metaoffsets32, 1, num * 4, mp4->mediafp); ++ len += readlen; ++ do ++ { ++ num--; ++ mp4->metaoffsets[num] = BYTESWAP32(metaoffsets32[num]); ++ } while (num > 0); + +- free(metaoffsets32); ++ free(metaoffsets32); ++ } + } + } ++ else ++ { ++ //size of null ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; ++ } + } + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over stco ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over stco + } + else +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -467,60 +528,79 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + len = fread(&skip, 1, 4, mp4->mediafp); + len += fread(&num, 1, 4, mp4->mediafp); + num = BYTESWAP32(num); ++ ++ if(num == 0) ++ { ++ //size of null ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; ++ } ++ + if (num * 8 <= qtsize - 8 - len) + { + if (mp4->metastsc_count > 0 && num != mp4->metasize_count) + { + mp4->indexcount = mp4->metasize_count; + if (mp4->metaoffsets) free(mp4->metaoffsets); +- mp4->metaoffsets = (uint64_t *)malloc(mp4->metasize_count * 8); +- if (mp4->metaoffsets) ++ if (mp4->metasize_count) + { +- uint64_t *metaoffsets64 = NULL; +- metaoffsets64 = (uint64_t *)malloc(num * 8); +- if (metaoffsets64) ++ mp4->metaoffsets = (uint64_t *)malloc(mp4->metasize_count * 8); ++ if (mp4->metaoffsets) + { +- uint64_t fileoffset = 0; +- int stsc_pos = 0; +- int stco_pos = 0; +- len += fread(metaoffsets64, 1, num * 8, mp4->mediafp); +- do ++ uint64_t *metaoffsets64 = NULL; ++ metaoffsets64 = (uint64_t *)malloc(num * 8); ++ if (metaoffsets64) + { +- num--; +- metaoffsets64[num] = BYTESWAP64(metaoffsets64[num]); +- } while (num > 0); ++ uint64_t fileoffset = 0; ++ int stsc_pos = 0; ++ int stco_pos = 0; ++ len += fread(metaoffsets64, 1, num * 8, mp4->mediafp); ++ do ++ { ++ num--; ++ metaoffsets64[num] = BYTESWAP64(metaoffsets64[num]); ++ } while (num > 0); + +- fileoffset = metaoffsets64[0]; +- mp4->metaoffsets[0] = fileoffset; +- //printf(""%3d:%08x, delta = %08x\n"", 0, (int)fileoffset, 0); ++ fileoffset = metaoffsets64[0]; ++ mp4->metaoffsets[0] = fileoffset; ++ //printf(""%3d:%08x, delta = %08x\n"", 0, (int)fileoffset, 0); + +- num = 1; +- while (num < mp4->metasize_count) +- { +- if (num != mp4->metastsc[stsc_pos].chunk_num - 1 && 0 == (num - (mp4->metastsc[stsc_pos].chunk_num - 1)) % mp4->metastsc[stsc_pos].samples) +- { +- stco_pos++; +- fileoffset = (uint64_t)metaoffsets64[stco_pos]; +- } +- else ++ num = 1; ++ while (num < mp4->metasize_count) + { +- fileoffset += (uint64_t)mp4->metasizes[num - 1]; ++ if (num != mp4->metastsc[stsc_pos].chunk_num - 1 && 0 == (num - (mp4->metastsc[stsc_pos].chunk_num - 1)) % mp4->metastsc[stsc_pos].samples) ++ { ++ stco_pos++; ++ fileoffset = (uint64_t)metaoffsets64[stco_pos]; ++ } ++ else ++ { ++ fileoffset += (uint64_t)mp4->metasizes[num - 1]; ++ } ++ ++ mp4->metaoffsets[num] = fileoffset; ++ //int delta = metaoffsets[num] - metaoffsets[num - 1]; ++ //printf(""%3d:%08x, delta = %08x\n"", num, (int)fileoffset, delta); ++ ++ num++; + } + +- mp4->metaoffsets[num] = fileoffset; +- //int delta = metaoffsets[num] - metaoffsets[num - 1]; +- //printf(""%3d:%08x, delta = %08x\n"", num, (int)fileoffset, delta); ++ if (mp4->metastsc) free(mp4->metastsc); ++ mp4->metastsc = NULL; ++ mp4->metastsc_count = 0; + +- num++; ++ free(metaoffsets64); + } +- +- if (mp4->metastsc) free(mp4->metastsc); +- mp4->metastsc = NULL; +- mp4->metastsc_count = 0; +- +- free(metaoffsets64); + } + } ++ else ++ { ++ //size of null ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ break; ++ } + } + else + { +@@ -538,10 +618,11 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + } + } + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over stco ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over stco + } + else +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -578,10 +659,11 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + } + mp4->basemetadataduration = mp4->metadatalength * (double)mp4->meta_clockdemon / (double)samples; + } +- LONGSEEK(mp4->mediafp, qtsize - 8 - len, SEEK_CUR); // skip over stco ++ mp4->filepos += len; ++ LongSeek(mp4, qtsize - 8 - len); // skip over stco + } + else +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + + NESTSIZE(qtsize); + } +@@ -595,6 +677,15 @@ size_t OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) / + break; + } + } while (len > 0); ++ ++ if (mp4) ++ { ++ if (mp4->metasizes == NULL || mp4->metaoffsets == NULL) ++ { ++ CloseSource((size_t)mp4); ++ mp4 = NULL; ++ } ++ } + } + else + { +@@ -631,20 +722,32 @@ void CloseSource(size_t handle) + } + + +-uint32_t GetPayloadTime(size_t handle, uint32_t index, float *in, float *out) ++uint32_t GetPayloadTime(size_t handle, uint32_t index, double *in, double *out) + { + mp4object *mp4 = (mp4object *)handle; +- if (mp4 == NULL) return 0; ++ if (mp4 == NULL) return GPMF_ERROR_MEMORY; + +- if (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return 1; ++ if (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return GPMF_ERROR_MEMORY; + +- *in = (float)((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon); +- *out = (float)((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon); +- return 0; ++ *in = ((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon); ++ *out = ((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon); ++ return GPMF_OK; + } + + +- ++uint32_t GetPayloadRationalTime(size_t handle, uint32_t index, uint32_t *in_numerator, uint32_t *out_numerator, uint32_t *denominator) ++{ ++ mp4object *mp4 = (mp4object *)handle; ++ if (mp4 == NULL) return GPMF_ERROR_MEMORY; ++ ++ if (mp4->metaoffsets == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in_numerator == NULL || out_numerator == NULL) return GPMF_ERROR_MEMORY; ++ ++ *in_numerator = (uint32_t)(index * mp4->basemetadataduration); ++ *out_numerator = (uint32_t)((index + 1) * mp4->basemetadataduration); ++ *denominator = (uint32_t)mp4->meta_clockdemon; ++ ++ return GPMF_OK; ++} + + size_t OpenMP4SourceUDTA(char *filename) + { +@@ -661,7 +764,8 @@ size_t OpenMP4SourceUDTA(char *filename) + + if (mp4->mediafp) + { +- uint32_t qttag, qtsize32, len; ++ uint32_t qttag, qtsize32; ++ size_t len; + int32_t nest = 0; + uint64_t nestsize[MAX_NEST_LEVEL] = { 0 }; + uint64_t lastsize = 0, qtsize; +@@ -674,7 +778,7 @@ size_t OpenMP4SourceUDTA(char *filename) + { + if (!GPMF_VALID_FOURCC(qttag)) + { +- LONGSEEK(mp4->mediafp, lastsize - 8 - 8, SEEK_CUR); ++ LongSeek(mp4, lastsize - 8 - 8); + + NESTSIZE(lastsize - 8); + continue; +@@ -701,7 +805,7 @@ size_t OpenMP4SourceUDTA(char *filename) + if (qttag == MAKEID('m', 'd', 'a', 't') || + qttag == MAKEID('f', 't', 'y', 'p')) + { +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + NESTSIZE(qtsize); + continue; + } +@@ -725,7 +829,7 @@ size_t OpenMP4SourceUDTA(char *filename) + if (qttag != MAKEID('m', 'o', 'o', 'v') && //skip over all but these atoms + qttag != MAKEID('u', 'd', 't', 'a')) + { +- LONGSEEK(mp4->mediafp, qtsize - 8, SEEK_CUR); ++ LongSeek(mp4, qtsize - 8); + NESTSIZE(qtsize); + continue; + } +@@ -740,7 +844,7 @@ size_t OpenMP4SourceUDTA(char *filename) + } + + +-double GetGPMFSampleRate(size_t handle, uint32_t fourcc, uint32_t flags) ++double GetGPMFSampleRate(size_t handle, uint32_t fourcc, uint32_t flags, double *firstsampletime, double *lastsampletime) + { + mp4object *mp4 = (mp4object *)handle; + if (mp4 == NULL) return 0.0; +@@ -750,221 +854,278 @@ double GetGPMFSampleRate(size_t handle, uint32_t fourcc, uint32_t flags) + uint32_t testend = mp4->indexcount; + double rate = 0.0; + ++ uint32_t *payload; ++ uint32_t payloadsize; ++ int32_t ret; ++ + if (mp4->indexcount < 1) + return 0.0; + +- if (mp4->indexcount > 3) // samples after first and before last are statistically the best, avoiding camera start up or shutdown anomollies. +- { +- teststart++; +- testend--; +- } +- +- uint32_t *payload = GetPayload(handle, NULL, teststart); // second payload +- uint32_t payloadsize = GetPayloadSize(handle, teststart); +- int32_t ret = GPMF_Init(ms, payload, payloadsize); ++ payload = GetPayload(handle, NULL, teststart); ++ payloadsize = GetPayloadSize(handle, teststart); ++ ret = GPMF_Init(ms, payload, payloadsize); + + if (ret != GPMF_OK) + goto cleanup; + + { ++ uint64_t minimumtimestamp = 0; ++ uint64_t starttimestamp = 0; ++ uint64_t endtimestamp = 0; + uint32_t startsamples = 0; + uint32_t endsamples = 0; +- uint32_t missing_samples = 0; ++ double intercept = 0.0; ++ ++ + +- while (ret == GPMF_OK && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) ++ while (teststart < mp4->indexcount && ret == GPMF_OK && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { +- missing_samples = 1; + teststart++; + payload = GetPayload(handle, payload, teststart); // second last payload + payloadsize = GetPayloadSize(handle, teststart); + ret = GPMF_Init(ms, payload, payloadsize); + } + +- if (missing_samples) +- { +- teststart++; //samples after sensor start are statistically the best +- payload = GetPayload(handle, payload, teststart); +- payloadsize = GetPayloadSize(handle, teststart); +- ret = GPMF_Init(ms, payload, payloadsize); +- } +- +- if (ret == GPMF_OK) ++ if (ret == GPMF_OK && payload) + { +- uint32_t samples = GPMF_Repeat(ms); ++ uint32_t samples = GPMF_PayloadSampleCount(ms); + GPMF_stream find_stream; + GPMF_CopyState(ms, &find_stream); ++ if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) ++ startsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)) - samples; + +- if (!(flags & GPMF_SAMPLE_RATE_PRECISE) && GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) ++ GPMF_CopyState(ms, &find_stream); ++ if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TIME_STAMP, GPMF_CURRENT_LEVEL)) ++ starttimestamp = BYTESWAP64(*(uint64_t *)GPMF_RawData(&find_stream)); ++ ++ if (starttimestamp) // is this earliest in the payload, examine the other streams in this early payload. + { +- startsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)) - samples; ++ GPMF_stream any_stream; ++ GPMF_Init(&any_stream, payload, payloadsize); ++ ++ minimumtimestamp = starttimestamp; ++ while (GPMF_OK == GPMF_FindNext(&any_stream, GPMF_KEY_TIME_STAMP, GPMF_RECURSE_LEVELS)) ++ { ++ uint64_t timestamp = BYTESWAP64(*(uint64_t *)GPMF_RawData(&any_stream)); ++ if (timestamp < minimumtimestamp) ++ minimumtimestamp = timestamp; ++ } ++ } + +- payload = GetPayload(handle, payload, testend); // second last payload ++ testend = mp4->indexcount; ++ do ++ { ++ testend--;// last payload with the fourcc needed ++ payload = GetPayload(handle, payload, testend); + payloadsize = GetPayloadSize(handle, testend); + ret = GPMF_Init(ms, payload, payloadsize); +- if (ret != GPMF_OK) +- goto cleanup; ++ } while (testend > 0 && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)); + +- if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) ++ GPMF_CopyState(ms, &find_stream); ++ if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) ++ endsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)); ++ else // If there is no TSMP we have to count the samples. ++ { ++ uint32_t i; ++ for (i = teststart; i <= testend; i++) + { +- GPMF_CopyState(ms, &find_stream); +- if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) ++ payload = GetPayload(handle,payload, i); // second last payload ++ payloadsize = GetPayloadSize(handle, i); ++ if (GPMF_OK == GPMF_Init(ms, payload, payloadsize)) ++ if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) ++ endsamples += GPMF_PayloadSampleCount(ms); ++ } ++ } ++ ++ if (starttimestamp != 0) ++ { ++ uint32_t last_samples = GPMF_PayloadSampleCount(ms); ++ uint32_t totaltimestamped_samples = endsamples - last_samples - startsamples; ++ double time_stamp_scale = 1000000000.0; // scan for nanoseconds, microseconds to seconds, all base 10. ++ ++ GPMF_CopyState(ms, &find_stream); ++ if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TIME_STAMP, GPMF_CURRENT_LEVEL)) ++ endtimestamp = BYTESWAP64(*(uint64_t *)GPMF_RawData(&find_stream)); ++ ++ if (endtimestamp) ++ { ++ double approxrate = 0.0; ++ if (endsamples > startsamples) ++ approxrate = (double)(endsamples - startsamples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); ++ ++ if (approxrate == 0.0) ++ approxrate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); ++ ++ ++ while (time_stamp_scale >= 1) + { +- endsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)); +- rate = (double)(endsamples - startsamples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); +- goto cleanup; ++ rate = (double)(totaltimestamped_samples) / ((double)(endtimestamp - starttimestamp) / time_stamp_scale); ++ if (rate*0.9 < approxrate && approxrate < rate*1.1) ++ break; ++ ++ time_stamp_scale *= 0.1; + } ++ if (time_stamp_scale < 1.0) rate = 0.0; ++ intercept = (((double)minimumtimestamp - (double)starttimestamp) / time_stamp_scale) * rate; + } +- +- rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + } +- else // for increased precision, for older GPMF streams sometimes missing the total sample count ++ ++ if (rate == 0.0) //Timestamps didn't help weren't available + { +- uint32_t payloadpos = 0, payloadcount = 0; +- double slope, top = 0.0, bot = 0.0, meanX = 0, meanY = 0; +- uint32_t *repeatarray = malloc(mp4->indexcount * 4 + 4); +- memset(repeatarray, 0, mp4->indexcount * 4 + 4); ++ if (!(flags & GPMF_SAMPLE_RATE_PRECISE)) ++ { ++ if (endsamples > startsamples) ++ rate = (double)(endsamples - startsamples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + +- samples = 0; ++ if (rate == 0.0) ++ rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + +- for (payloadpos = teststart; payloadpos < testend; payloadcount++, payloadpos++) ++ double in, out; ++ if (GPMF_OK == GetPayloadTime(handle, teststart, &in, &out)) ++ intercept = (double)-in * rate; ++ } ++ else // for increased precision, for older GPMF streams sometimes missing the total sample count + { +- payload = GetPayload(handle, payload, payloadpos); // second last payload +- payloadsize = GetPayloadSize(handle, payloadpos); +- ret = GPMF_Init(ms, payload, payloadsize); ++ uint32_t payloadpos = 0, payloadcount = 0; ++ double slope, top = 0.0, bot = 0.0, meanX = 0, meanY = 0; ++ uint32_t *repeatarray = malloc(mp4->indexcount * 4 + 4); ++ memset(repeatarray, 0, mp4->indexcount * 4 + 4); + +- if (ret != GPMF_OK) +- goto cleanup; ++ samples = 0; + +- if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) ++ for (payloadpos = teststart; payloadpos <= testend; payloadpos++) + { +- GPMF_stream find_stream2; +- GPMF_CopyState(ms, &find_stream2); ++ payload = GetPayload(handle, payload, payloadpos); // second last payload ++ payloadsize = GetPayloadSize(handle, payloadpos); ++ ret = GPMF_Init(ms, payload, payloadsize); + +- if (GPMF_OK == GPMF_FindNext(&find_stream2, fourcc, GPMF_CURRENT_LEVEL)) // Count the instances, not the repeats ++ if (ret != GPMF_OK) ++ goto cleanup; ++ ++ if (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)) + { +- if (repeatarray) +- { +- float in, out; ++ GPMF_stream find_stream2; ++ GPMF_CopyState(ms, &find_stream2); ++ ++ payloadcount++; + +- do ++ if (GPMF_OK == GPMF_FindNext(&find_stream2, fourcc, GPMF_CURRENT_LEVEL)) // Count the instances, not the repeats ++ { ++ if (repeatarray) + { +- samples++; +- } while (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_CURRENT_LEVEL)); ++ double in, out; + +- repeatarray[payloadpos] = samples; +- meanY += (double)samples; ++ do ++ { ++ samples++; ++ } while (GPMF_OK == GPMF_FindNext(ms, fourcc, GPMF_CURRENT_LEVEL)); + +- GetPayloadTime(handle, payloadpos, &in, &out); +- meanX += out; +- } +- } +- else +- { +- uint32_t repeat = GPMF_Repeat(ms); +- samples += repeat; ++ repeatarray[payloadpos] = samples; ++ meanY += (double)samples; + +- if (repeatarray) ++ if (GPMF_OK == GetPayloadTime(handle, payloadpos, &in, &out)) ++ meanX += out; ++ } ++ } ++ else + { +- float in, out; ++ uint32_t repeat = GPMF_PayloadSampleCount(ms); ++ samples += repeat; ++ ++ if (repeatarray) ++ { ++ double in, out; + +- repeatarray[payloadpos] = samples; +- meanY += (double)samples; ++ repeatarray[payloadpos] = samples; ++ meanY += (double)samples; + +- GetPayloadTime(handle, payloadpos, &in, &out); +- meanX += out; ++ if (GPMF_OK == GetPayloadTime(handle, payloadpos, &in, &out)) ++ meanX += out; ++ } + } + } ++ else ++ { ++ repeatarray[payloadpos] = 0; ++ } + } +- } +- +- // Compute the line of best fit for a jitter removed sample rate. +- // This does assume an unchanging clock, even though the IMU data can thermally impacted causing small clock changes. +- // TODO: Next enhancement would be a low order polynominal fit the compensate for any thermal clock drift. +- if (repeatarray) +- { +- meanY /= (double)payloadcount; +- meanX /= (double)payloadcount; + +- for (payloadpos = teststart; payloadpos < testend; payloadpos++) ++ // Compute the line of best fit for a jitter removed sample rate. ++ // This does assume an unchanging clock, even though the IMU data can thermally impacted causing small clock changes. ++ // TODO: Next enhancement would be a low order polynominal fit the compensate for any thermal clock drift. ++ if (repeatarray) + { +- float in, out; +- GetPayloadTime(handle, payloadpos, &in, &out); ++ meanY /= (double)payloadcount; ++ meanX /= (double)payloadcount; + +- top += ((double)out - meanX)*((double)repeatarray[payloadpos] - meanY); +- bot += ((double)out - meanX)*((double)out - meanX); +- } ++ for (payloadpos = teststart; payloadpos <= testend; payloadpos++) ++ { ++ double in, out; ++ if (repeatarray[payloadpos] && GPMF_OK == GetPayloadTime(handle, payloadpos, &in, &out)) ++ { ++ top += ((double)out - meanX)*((double)repeatarray[payloadpos] - meanY); ++ bot += ((double)out - meanX)*((double)out - meanX); ++ } ++ } + +- slope = top / bot; ++ slope = top / bot; ++ rate = slope; + ++ // This sample code might be useful for compare data latency between channels. ++ intercept = meanY - slope * meanX; + #if 0 +- // This sample code might be useful for compare data latency between channels. ++ printf(""%c%c%c%c start offset = %f (%.3fms) rate = %f\n"", PRINTF_4CC(fourcc), intercept, 1000.0 * intercept / slope, rate); ++ printf(""%c%c%c%c first sample at time %.3fms\n"", PRINTF_4CC(fourcc), -1000.0 * intercept / slope); ++#endif ++ } ++ else + { +- double intercept; +- intercept = meanY - slope*meanX; +- printf(""%c%c%c%c start offset = %f (%.3fms)\n"", PRINTF_4CC(fourcc), intercept, 1000.0 * intercept / slope); ++ rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); + } +-#endif +- rate = slope; +- } +- else +- { +- rate = (double)(samples) / (mp4->metadatalength * ((double)(testend - teststart + 1)) / (double)mp4->indexcount); +- } +- +- free(repeatarray); + +- goto cleanup; ++ free(repeatarray); ++ } + } +- } +- } + +-cleanup: +- if (payload) +- { +- FreePayload(payload); +- payload = NULL; +- } +- +- return rate; +-} ++ if (firstsampletime && lastsampletime) ++ { ++ uint32_t endpayload = mp4->indexcount; ++ do ++ { ++ endpayload--;// last payload with the fourcc needed ++ payload = GetPayload(handle, payload, endpayload); ++ payloadsize = GetPayloadSize(handle, endpayload); ++ ret = GPMF_Init(ms, payload, payloadsize); ++ } while (endpayload > 0 && GPMF_OK != GPMF_FindNext(ms, fourcc, GPMF_RECURSE_LEVELS)); + ++ if (endpayload > 0 && ret == GPMF_OK) ++ { ++ uint32_t totalsamples = endsamples - startsamples; ++ float timo = 0.0; + +-double GetGPMFSampleRateAndTimes(size_t handle, GPMF_stream *gs, double rate, uint32_t index, double *in, double *out) +-{ +- mp4object *mp4 = (mp4object *)handle; +- if (mp4 == NULL) return 0.0; ++ GPMF_CopyState(ms, &find_stream); ++ if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TIME_OFFSET, GPMF_CURRENT_LEVEL)) ++ GPMF_FormattedData(&find_stream, &timo, 4, 0, 1); + +- uint32_t key, insamples; +- uint32_t repeat, outsamples; +- GPMF_stream find_stream; ++ double first, last; ++ first = -intercept / rate - timo; ++ last = first + (double)totalsamples / rate; + +- if (gs == NULL || mp4->metaoffsets == 0 || mp4->indexcount == 0 || mp4->basemetadataduration == 0 || mp4->meta_clockdemon == 0 || in == NULL || out == NULL) return 0.0; ++ //printf(""%c%c%c%c first sample at time %.3fms, last at %.3fms\n"", PRINTF_4CC(fourcc), 1000.0*first, 1000.0*last); + +- key = GPMF_Key(gs); +- repeat = GPMF_Repeat(gs); +- if (rate == 0.0) +- rate = GetGPMFSampleRate(handle, key, GPMF_SAMPLE_RATE_FAST); ++ if (firstsampletime) *firstsampletime = first; + +- if (rate == 0.0) +- { +- *in = *out = 0.0; +- return 0.0; ++ if (lastsampletime) *lastsampletime = last; ++ } ++ } ++ } + } + +- GPMF_CopyState(gs, &find_stream); +- if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TOTAL_SAMPLES, GPMF_CURRENT_LEVEL)) +- { +- outsamples = BYTESWAP32(*(uint32_t *)GPMF_RawData(&find_stream)); +- insamples = outsamples - repeat; ++cleanup: ++ if (payload) ++ FreePayload(payload); ++ payload = NULL; + +- *in = ((double)insamples / (double)rate); +- *out = ((double)outsamples / (double)rate); +- } +- else +- { +- // might too costly in some applications read all the samples to determine the clock jitter, here I return the estimate from the MP4 track. +- *in = ((double)index * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon); +- *out = ((double)(index + 1) * (double)mp4->basemetadataduration / (double)mp4->meta_clockdemon); +- } + return rate; + } ++",1625,1861,2048 +18493,"xmlParseDocument(xmlParserCtxtPtr ctxt) { + xmlChar start[4]; + xmlCharEncoding enc; + + xmlInitParser(); + + if ((ctxt == NULL) || (ctxt->input == NULL)) + return(-1); + + GROW; + + /* + * SAX: detecting the level. + */ + xmlDetectSAX2(ctxt); + + /* + * SAX: beginning of the document processing. + */ + if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) + ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator); + + if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) && + ((ctxt->input->end - ctxt->input->cur) >= 4)) { + /* + * Get the 4 first bytes and decode the charset + * if enc != XML_CHAR_ENCODING_NONE + * plug some encoding conversion routines. + */ + start[0] = RAW; + start[1] = NXT(1); + start[2] = NXT(2); + start[3] = NXT(3); + enc = xmlDetectCharEncoding(&start[0], 4); + if (enc != XML_CHAR_ENCODING_NONE) { + xmlSwitchEncoding(ctxt, enc); + } + } + + + if (CUR == 0) { + xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL); + } + + /* + * Check for the XMLDecl in the Prolog. + * do not GROW here to avoid the detected encoder to decode more + * than just the first line, unless the amount of data is really + * too small to hold ""input->end - ctxt->input->cur) < 35) { + GROW; + } + if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) { + + /* + * Note that we will switch encoding on the fly. + */ + xmlParseXMLDecl(ctxt); + if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) { + /* + * The XML REC instructs us to stop parsing right here + */ + return(-1); + } + ctxt->standalone = ctxt->input->standalone; + SKIP_BLANKS; + } else { + ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION); + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); + + /* + * The Misc part of the Prolog + */ + GROW; + xmlParseMisc(ctxt); + + /* + * Then possibly doc type declaration(s) and more Misc + * (doctypedecl Misc*)? + */ + GROW; + if (CMP9(CUR_PTR, '<', '!', 'D', 'O', 'C', 'T', 'Y', 'P', 'E')) { + + ctxt->inSubset = 1; + xmlParseDocTypeDecl(ctxt); + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + xmlParseInternalSubset(ctxt); + } + + /* + * Create and update the external subset. + */ + ctxt->inSubset = 2; + if ((ctxt->sax != NULL) && (ctxt->sax->externalSubset != NULL) && + (!ctxt->disableSAX)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); + ctxt->inSubset = 0; + + xmlCleanSpecialAttr(ctxt); + + ctxt->instate = XML_PARSER_PROLOG; + xmlParseMisc(ctxt); + } + + /* + * Time to start parsing the tree itself + */ + GROW; + if (RAW != '<') { + xmlFatalErrMsg(ctxt, XML_ERR_DOCUMENT_EMPTY, + ""Start tag expected, '<' not found\n""); + } else { + ctxt->instate = XML_PARSER_CONTENT; + xmlParseElement(ctxt); + ctxt->instate = XML_PARSER_EPILOG; + + + /* + * The Misc part at the end + */ + xmlParseMisc(ctxt); + + if (RAW != 0) { + xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL); + } + ctxt->instate = XML_PARSER_EOF; + } + + /* + * SAX: end of the document processing. + */ + if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) + ctxt->sax->endDocument(ctxt->userData); + + /* + * Remove locally kept entity definitions if the tree was not built + */ + if ((ctxt->myDoc != NULL) && + (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE))) { + xmlFreeDoc(ctxt->myDoc); + ctxt->myDoc = NULL; + } + + if ((ctxt->wellFormed) && (ctxt->myDoc != NULL)) { + ctxt->myDoc->properties |= XML_DOC_WELLFORMED; + if (ctxt->valid) + ctxt->myDoc->properties |= XML_DOC_DTDVALID; + if (ctxt->nsWellFormed) + ctxt->myDoc->properties |= XML_DOC_NSVALID; + if (ctxt->options & XML_PARSE_OLD10) + ctxt->myDoc->properties |= XML_DOC_OLD10; + } + if (! ctxt->wellFormed) { + ctxt->valid = 0; + return(-1); + } + return(0); +} +",1,"xmlParseDocument(xmlParserCtxtPtr ctxt) { + xmlChar start[4]; + xmlCharEncoding enc; + + xmlInitParser(); + + if ((ctxt == NULL) || (ctxt->input == NULL)) + return(-1); + + GROW; + + /* + * SAX: detecting the level. + */ + xmlDetectSAX2(ctxt); + + /* + * SAX: beginning of the document processing. + */ + if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) + ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator); + if (ctxt->instate == XML_PARSER_EOF) + return(-1); + + if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) && + ((ctxt->input->end - ctxt->input->cur) >= 4)) { + /* + * Get the 4 first bytes and decode the charset + * if enc != XML_CHAR_ENCODING_NONE + * plug some encoding conversion routines. + */ + start[0] = RAW; + start[1] = NXT(1); + start[2] = NXT(2); + start[3] = NXT(3); + enc = xmlDetectCharEncoding(&start[0], 4); + if (enc != XML_CHAR_ENCODING_NONE) { + xmlSwitchEncoding(ctxt, enc); + } + } + + + if (CUR == 0) { + xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL); + } + + /* + * Check for the XMLDecl in the Prolog. + * do not GROW here to avoid the detected encoder to decode more + * than just the first line, unless the amount of data is really + * too small to hold ""input->end - ctxt->input->cur) < 35) { + GROW; + } + if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) { + + /* + * Note that we will switch encoding on the fly. + */ + xmlParseXMLDecl(ctxt); + if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) { + /* + * The XML REC instructs us to stop parsing right here + */ + return(-1); + } + ctxt->standalone = ctxt->input->standalone; + SKIP_BLANKS; + } else { + ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION); + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); + if (ctxt->instate == XML_PARSER_EOF) + return(-1); + + /* + * The Misc part of the Prolog + */ + GROW; + xmlParseMisc(ctxt); + + /* + * Then possibly doc type declaration(s) and more Misc + * (doctypedecl Misc*)? + */ + GROW; + if (CMP9(CUR_PTR, '<', '!', 'D', 'O', 'C', 'T', 'Y', 'P', 'E')) { + + ctxt->inSubset = 1; + xmlParseDocTypeDecl(ctxt); + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + xmlParseInternalSubset(ctxt); + if (ctxt->instate == XML_PARSER_EOF) + return(-1); + } + + /* + * Create and update the external subset. + */ + ctxt->inSubset = 2; + if ((ctxt->sax != NULL) && (ctxt->sax->externalSubset != NULL) && + (!ctxt->disableSAX)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); + if (ctxt->instate == XML_PARSER_EOF) + return(-1); + ctxt->inSubset = 0; + + xmlCleanSpecialAttr(ctxt); + + ctxt->instate = XML_PARSER_PROLOG; + xmlParseMisc(ctxt); + } + + /* + * Time to start parsing the tree itself + */ + GROW; + if (RAW != '<') { + xmlFatalErrMsg(ctxt, XML_ERR_DOCUMENT_EMPTY, + ""Start tag expected, '<' not found\n""); + } else { + ctxt->instate = XML_PARSER_CONTENT; + xmlParseElement(ctxt); + ctxt->instate = XML_PARSER_EPILOG; + + + /* + * The Misc part at the end + */ + xmlParseMisc(ctxt); + + if (RAW != 0) { + xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL); + } + ctxt->instate = XML_PARSER_EOF; + } + + /* + * SAX: end of the document processing. + */ + if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) + ctxt->sax->endDocument(ctxt->userData); + + /* + * Remove locally kept entity definitions if the tree was not built + */ + if ((ctxt->myDoc != NULL) && + (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE))) { + xmlFreeDoc(ctxt->myDoc); + ctxt->myDoc = NULL; + } + + if ((ctxt->wellFormed) && (ctxt->myDoc != NULL)) { + ctxt->myDoc->properties |= XML_DOC_WELLFORMED; + if (ctxt->valid) + ctxt->myDoc->properties |= XML_DOC_DTDVALID; + if (ctxt->nsWellFormed) + ctxt->myDoc->properties |= XML_DOC_NSVALID; + if (ctxt->options & XML_PARSE_OLD10) + ctxt->myDoc->properties |= XML_DOC_OLD10; + } + if (! ctxt->wellFormed) { + ctxt->valid = 0; + return(-1); + } + return(0); +} +","@@ -2013,6 +2013,8 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) { + ""Pushing input %d : %.30s\n"", ctxt->inputNr+1, input->cur); + } + ret = inputPush(ctxt, input); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + GROW; + return(ret); + } +@@ -2049,6 +2051,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) { + if (count++ > 20) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 16 + (CUR - '0'); +@@ -2080,6 +2084,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) { + if (count++ > 20) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 10 + (CUR - '0'); +@@ -2366,6 +2372,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + NEXT; + if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL)) + entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (entity == NULL) { + + /* +@@ -2428,6 +2436,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + * the amount of data in the buffer. + */ + GROW ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if ((ctxt->input->end - ctxt->input->cur)>=4) { + start[0] = RAW; + start[1] = NXT(1); +@@ -3046,6 +3056,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + * Handler for more complex cases + */ + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + c = CUR_CHAR(l); + if ((ctxt->options & XML_PARSE_OLD10) == 0) { + /* +@@ -3097,6 +3109,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3121,6 +3135,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3214,6 +3230,8 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3294,6 +3312,8 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) { + const xmlChar *ret; + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + + in = ctxt->input->cur; + while (*in != 0 && *in == *cmp) { +@@ -3421,6 +3441,8 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + #endif + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + c = CUR_CHAR(l); + + while (xmlIsNameChar(ctxt, c)) { +@@ -3449,6 +3471,10 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buffer); ++ return(NULL); ++ } + } + if (len + 10 > max) { + xmlChar *tmp; +@@ -3519,6 +3545,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + ctxt->instate = XML_PARSER_ENTITY_VALUE; + input = ctxt->input; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + NEXT; + c = CUR_CHAR(l); + /* +@@ -3530,8 +3560,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + * In practice it means we stop the loop only when back at parsing + * the initial entity and the quote is found + */ +- while ((IS_CHAR(c)) && ((c != stop) || /* checked */ +- (ctxt->input != input))) { ++ while (((IS_CHAR(c)) && ((c != stop) || /* checked */ ++ (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) { + if (len + 5 >= size) { + xmlChar *tmp; + +@@ -3560,6 +3590,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + } + } + buf[len] = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + + /* + * Raise problem w.r.t. '&' and '%' being used in non-entities +@@ -3607,12 +3641,12 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + */ + ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, + 0, 0, 0); +- if (orig != NULL) ++ if (orig != NULL) + *orig = buf; + else + xmlFree(buf); + } +- ++ + return(ret); + } + +@@ -3663,8 +3697,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + * OK loop until we reach one of the ending char or a size limit. + */ + c = CUR_CHAR(l); +- while ((NXT(0) != limit) && /* checked */ +- (IS_CHAR(c)) && (c != '<')) { ++ while (((NXT(0) != limit) && /* checked */ ++ (IS_CHAR(c)) && (c != '<')) && ++ (ctxt->instate != XML_PARSER_EOF)) { + if (c == 0) break; + if (c == '&') { + in_space = 0; +@@ -3799,6 +3834,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + GROW; + c = CUR_CHAR(l); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto error; ++ + if ((in_space) && (normalize)) { + while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } +@@ -3820,6 +3858,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + + mem_error: + xmlErrMemory(ctxt, NULL); ++error: + if (buf != NULL) + xmlFree(buf); + if (rep != NULL) +@@ -3925,6 +3964,10 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); +@@ -4002,6 +4045,10 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + } + NEXT; + cur = CUR; +@@ -4208,6 +4255,8 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) { + } + SHRINK; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + in = ctxt->input->cur; + } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09)); + nbchar = 0; +@@ -4276,6 +4325,8 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + } + NEXTL(l); + cur = CUR_CHAR(l); +@@ -4476,6 +4527,10 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + } + NEXTL(l); + cur = CUR_CHAR(l); +@@ -4626,6 +4681,10 @@ xmlParseComment(xmlParserCtxtPtr ctxt) { + } + SHRINK; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + in = ctxt->input->cur; + if (*in == '-') { + if (in[1] == '-') { +@@ -4644,7 +4703,8 @@ xmlParseComment(xmlParserCtxtPtr ctxt) { + } + if (buf != NULL) + xmlFree(buf); +- ctxt->instate = state; ++ if (ctxt->instate != XML_PARSER_EOF) ++ ctxt->instate = state; + return; + } + if (buf != NULL) +@@ -4862,6 +4922,10 @@ xmlParsePI(xmlParserCtxtPtr ctxt) { + count++; + if (count > 50) { + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + count = 0; + } + COPY_BUF(l,buf,len,cur); +@@ -5211,6 +5275,8 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { + } + } + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + SKIP_BLANKS; + if (RAW != '>') { + xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, +@@ -5602,7 +5668,7 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) { + } + SKIP_BLANKS; + GROW; +- while (RAW != '>') { ++ while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + int type; + int def; +@@ -5751,7 +5817,7 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) { + ret = cur = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA); + if (ret == NULL) return(NULL); + } +- while (RAW == '|') { ++ while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) { + NEXT; + if (elem == NULL) { + ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR); +@@ -5895,7 +5961,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, + } + SKIP_BLANKS; + SHRINK; +- while (RAW != ')') { ++ while ((RAW != ')') && (ctxt->instate != XML_PARSER_EOF)) { + /* + * Each loop we parse one separator and one element. + */ +@@ -6174,6 +6240,8 @@ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, + } + NEXT; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + SKIP_BLANKS; + if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) { + tree = xmlParseElementMixedContentDecl(ctxt, inputid); +@@ -6341,8 +6409,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + ""Entering INCLUDE Conditional Section\n""); + } + +- while ((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') || +- (NXT(2) != '>'))) { ++ while (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') || ++ (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -6410,7 +6478,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + if (ctxt->recovery == 0) ctxt->disableSAX = 1; + ctxt->instate = XML_PARSER_IGNORE; + +- while ((depth >= 0) && (RAW != 0)) { ++ while (((depth >= 0) && (RAW != 0)) && ++ (ctxt->instate != XML_PARSER_EOF)) { + if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) { + depth++; + SKIP(3); +@@ -6681,7 +6750,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, + break; + } + } +- ++ + if (RAW != 0) { + xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL); + } +@@ -7127,6 +7196,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { + xmlEntityPtr ent = NULL; + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + + if (RAW != '&') + return(NULL); +@@ -7172,6 +7243,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { + ent = xmlSAX2GetEntity(ctxt, name); + } + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + /* + * [ WFC: Entity Declared ] + * In a document without any DTD, a document with only an +@@ -7362,6 +7435,10 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) { + ent = xmlSAX2GetEntity(ctxt, name); + } + } ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(name); ++ return(NULL); ++ } + + /* + * [ WFC: Entity Declared ] +@@ -7523,8 +7600,9 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) + */ + if ((ctxt->sax != NULL) && + (ctxt->sax->getParameterEntity != NULL)) +- entity = ctxt->sax->getParameterEntity(ctxt->userData, +- name); ++ entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (entity == NULL) { + /* + * [ WFC: Entity Declared ] +@@ -7657,6 +7735,10 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlBufferFree(buf); ++ return(-1); ++ } + } + NEXTL(l); + c = CUR_CHAR(l); +@@ -7748,8 +7830,11 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { + */ + if ((ctxt->sax != NULL) && + (ctxt->sax->getParameterEntity != NULL)) +- entity = ctxt->sax->getParameterEntity(ctxt->userData, +- name); ++ entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(name); ++ return(NULL); ++ } + if (entity == NULL) { + /* + * [ WFC: Entity Declared ] +@@ -7851,6 +7936,8 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) { + if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) && + (!ctxt->disableSAX)) + ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + + /* + * Is there any internal subset declarations ? +@@ -7890,7 +7977,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) { + * PEReferences. + * Subsequence (markupdecl | PEReference | S)* + */ +- while (RAW != ']') { ++ while ((RAW != ']') && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -8076,9 +8163,9 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) { + SKIP_BLANKS; + GROW; + +- while ((RAW != '>') && ++ while (((RAW != '>') && + ((RAW != '/') || (NXT(1) != '>')) && +- (IS_BYTE_CHAR(RAW))) { ++ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *q = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -8502,6 +8589,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8516,6 +8605,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8536,6 +8627,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8553,6 +8646,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8784,9 +8879,9 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, + GROW; + if (ctxt->input->base != base) goto base_changed; + +- while ((RAW != '>') && ++ while (((RAW != '>') && + ((RAW != '/') || (NXT(1) != '>')) && +- (IS_BYTE_CHAR(RAW))) { ++ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *q = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + int len = -1, alloc = 0; +@@ -8957,6 +9052,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, + failed: + + GROW ++ if (ctxt->instate == XML_PARSER_EOF) ++ break; + if (ctxt->input->base != base) goto base_changed; + if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) + break; +@@ -9194,6 +9291,8 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, + * We should definitely be at the ending ""S? '>'"" part + */ + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + SKIP_BLANKS; + if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) { + xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL); +@@ -9302,6 +9401,10 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { + count++; + if (count > 50) { + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + count = 0; + } + NEXTL(l); +@@ -9550,6 +9653,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { + * Parse the content of the element: + */ + xmlParseContent(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (!IS_BYTE_CHAR(RAW)) { + xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED, + ""Premature end of data in tag %s line %d\n"", +@@ -10065,9 +10170,10 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) { + + void + xmlParseMisc(xmlParserCtxtPtr ctxt) { +- while (((RAW == '<') && (NXT(1) == '?')) || +- (CMP4(CUR_PTR, '<', '!', '-', '-')) || +- IS_BLANK_CH(CUR)) { ++ while ((ctxt->instate != XML_PARSER_EOF) && ++ (((RAW == '<') && (NXT(1) == '?')) || ++ (CMP4(CUR_PTR, '<', '!', '-', '-')) || ++ IS_BLANK_CH(CUR))) { + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParsePI(ctxt); + } else if (IS_BLANK_CH(CUR)) { +@@ -10114,6 +10220,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + */ + if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) + ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) && + ((ctxt->input->end - ctxt->input->cur) >= 4)) { +@@ -10165,6 +10273,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + /* + * The Misc part of the Prolog +@@ -10184,6 +10294,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + xmlParseInternalSubset(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + } + + /* +@@ -10194,6 +10306,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + (!ctxt->disableSAX)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + ctxt->inSubset = 0; + + xmlCleanSpecialAttr(ctxt); +@@ -10334,6 +10448,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + /* + * Doing validity checking on chunk doesn't make sense +@@ -10344,6 +10460,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { + ctxt->depth = 0; + + xmlParseContent(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + if ((RAW == '<') && (NXT(1) == '/')) { + xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL); +@@ -10651,7 +10769,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + } + xmlParseGetLasts(ctxt, &lastlt, &lastgt); + +- while (1) { ++ while (ctxt->instate != XML_PARSER_EOF) { + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(0); + +@@ -10891,6 +11009,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->endElement(ctxt->userData, name); + #endif /* LIBXML_SAX1_ENABLED */ + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + spacePop(ctxt); + if (ctxt->nameNr == 0) { + ctxt->instate = XML_PARSER_EPILOG; +@@ -11072,6 +11192,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, tmp); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + SKIPL(tmp); + ctxt->checkIndex = 0; + } +@@ -11107,6 +11229,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, base); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + SKIPL(base + 3); + ctxt->checkIndex = 0; + ctxt->instate = XML_PARSER_CONTENT; +@@ -11138,6 +11262,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->checkIndex = 0; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && +@@ -11150,6 +11276,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_MISC; + ctxt->checkIndex = 0; + } else if ((cur == '<') && (next == '!') && +@@ -11169,6 +11297,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + #endif + ctxt->inSubset = 1; + xmlParseDocTypeDecl(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + #ifdef DEBUG_PUSH +@@ -11225,6 +11355,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) { + if ((!terminate) && +@@ -11235,6 +11367,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_PROLOG; + } else if ((cur == '<') && (next == '!') && + (avail < 4)) { +@@ -11269,6 +11403,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_EPILOG; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) { +@@ -11280,6 +11416,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_EPILOG; + } else if ((cur == '<') && (next == '!') && + (avail < 4)) { +@@ -11408,13 +11546,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + + found_end_int_subset: + xmlParseInternalSubset(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->inSubset = 2; + if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && + (ctxt->sax->externalSubset != NULL)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); + ctxt->inSubset = 0; + xmlCleanSpecialAttr(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_PROLOG; + ctxt->checkIndex = 0; + #ifdef DEBUG_PUSH +@@ -11537,6 +11679,8 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, + return(XML_ERR_INTERNAL_ERROR); + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(ctxt->errNo); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + if (ctxt->instate == XML_PARSER_START) + xmlDetectSAX2(ctxt); + if ((size > 0) && (chunk != NULL) && (!terminate) && +@@ -11623,6 +11767,8 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, + xmlParseTryOrFinish(ctxt, 0); + else + xmlParseTryOrFinish(ctxt, terminate); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(ctxt->errNo); + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(ctxt->errNo); + +@@ -11816,6 +11962,7 @@ xmlStopParser(xmlParserCtxtPtr ctxt) { + if (ctxt == NULL) + return; + ctxt->instate = XML_PARSER_EOF; ++ ctxt->errNo = XML_ERR_USER_STOP; + ctxt->disableSAX = 1; + if (ctxt->input != NULL) { + ctxt->input->cur = BAD_CAST"""";",1211,1447,2048 +17859," static int zrle_send_framebuffer_update(VncState *vs, int x, int y, + int w, int h) + { + bool be = !!(vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG); + size_t bytes; + int zywrle_level; + + if (vs->zrle.type == VNC_ENCODING_ZYWRLE) { + if (!vs->vd->lossy || vs->tight.quality == (uint8_t)-1 + || vs->tight.quality == 9) { + zywrle_level = 0; + vs->zrle.type = VNC_ENCODING_ZRLE; + } else if (vs->tight.quality < 3) { + zywrle_level = 3; + } else if (vs->tight.quality < 6) { + zywrle_level = 2; + } else { + zywrle_level = 1; + } + } else { + zywrle_level = 0; + } + + vnc_zrle_start(vs); + + switch(vs->clientds.pf.bytes_per_pixel) { + case 1: + zrle_encode_8ne(vs, x, y, w, h, zywrle_level); + break; + + case 2: + if (vs->clientds.pf.gmax > 0x1F) { + if (be) { + zrle_encode_16be(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_16le(vs, x, y, w, h, zywrle_level); + } + } else { + if (be) { + zrle_encode_15be(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_15le(vs, x, y, w, h, zywrle_level); + } + } + break; + + case 4: + { + bool fits_in_ls3bytes; + bool fits_in_ms3bytes; + + fits_in_ls3bytes = + ((vs->clientds.pf.rmax << vs->clientds.pf.rshift) < (1 << 24) && + (vs->clientds.pf.gmax << vs->clientds.pf.gshift) < (1 << 24) && + (vs->clientds.pf.bmax << vs->clientds.pf.bshift) < (1 << 24)); + + fits_in_ms3bytes = (vs->clientds.pf.rshift > 7 && + vs->clientds.pf.gshift > 7 && + vs->clientds.pf.bshift > 7); + + if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) { + if (be) { + zrle_encode_24abe(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_24ale(vs, x, y, w, h, zywrle_level); + } + } else if ((fits_in_ls3bytes && be) || (fits_in_ms3bytes && !be)) { + if (be) { + zrle_encode_24bbe(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_24ble(vs, x, y, w, h, zywrle_level); + } + } else { + if (be) { + zrle_encode_32be(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_32le(vs, x, y, w, h, zywrle_level); + } + } + } + break; + } + + vnc_zrle_stop(vs); + bytes = zrle_compress_data(vs, Z_DEFAULT_COMPRESSION); + vnc_framebuffer_update(vs, x, y, w, h, vs->zrle.type); + vnc_write_u32(vs, bytes); + vnc_write(vs, vs->zrle.zlib.buffer, vs->zrle.zlib.offset); + return 1; +} +",1," static int zrle_send_framebuffer_update(VncState *vs, int x, int y, + int w, int h) + { + bool be = vs->client_be; + size_t bytes; + int zywrle_level; + + if (vs->zrle.type == VNC_ENCODING_ZYWRLE) { + if (!vs->vd->lossy || vs->tight.quality == (uint8_t)-1 + || vs->tight.quality == 9) { + zywrle_level = 0; + vs->zrle.type = VNC_ENCODING_ZRLE; + } else if (vs->tight.quality < 3) { + zywrle_level = 3; + } else if (vs->tight.quality < 6) { + zywrle_level = 2; + } else { + zywrle_level = 1; + } + } else { + zywrle_level = 0; + } + + vnc_zrle_start(vs); + + switch (vs->client_pf.bytes_per_pixel) { + case 1: + zrle_encode_8ne(vs, x, y, w, h, zywrle_level); + break; + + case 2: + if (vs->client_pf.gmax > 0x1F) { + if (be) { + zrle_encode_16be(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_16le(vs, x, y, w, h, zywrle_level); + } + } else { + if (be) { + zrle_encode_15be(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_15le(vs, x, y, w, h, zywrle_level); + } + } + break; + + case 4: + { + bool fits_in_ls3bytes; + bool fits_in_ms3bytes; + + fits_in_ls3bytes = + ((vs->client_pf.rmax << vs->client_pf.rshift) < (1 << 24) && + (vs->client_pf.gmax << vs->client_pf.gshift) < (1 << 24) && + (vs->client_pf.bmax << vs->client_pf.bshift) < (1 << 24)); + + fits_in_ms3bytes = (vs->client_pf.rshift > 7 && + vs->client_pf.gshift > 7 && + vs->client_pf.bshift > 7); + + if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) { + if (be) { + zrle_encode_24abe(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_24ale(vs, x, y, w, h, zywrle_level); + } + } else if ((fits_in_ls3bytes && be) || (fits_in_ms3bytes && !be)) { + if (be) { + zrle_encode_24bbe(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_24ble(vs, x, y, w, h, zywrle_level); + } + } else { + if (be) { + zrle_encode_32be(vs, x, y, w, h, zywrle_level); + } else { + zrle_encode_32le(vs, x, y, w, h, zywrle_level); + } + } + } + break; + } + + vnc_zrle_stop(vs); + bytes = zrle_compress_data(vs, Z_DEFAULT_COMPRESSION); + vnc_framebuffer_update(vs, x, y, w, h, vs->zrle.type); + vnc_write_u32(vs, bytes); + vnc_write(vs, vs->zrle.zlib.buffer, vs->zrle.zlib.offset); + return 1; +} +","@@ -255,7 +255,7 @@ static void zrle_write_u8(VncState *vs, uint8_t value) + static int zrle_send_framebuffer_update(VncState *vs, int x, int y, + int w, int h) + { +- bool be = !!(vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG); ++ bool be = vs->client_be; + size_t bytes; + int zywrle_level; + +@@ -277,13 +277,13 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y, + + vnc_zrle_start(vs); + +- switch(vs->clientds.pf.bytes_per_pixel) { ++ switch (vs->client_pf.bytes_per_pixel) { + case 1: + zrle_encode_8ne(vs, x, y, w, h, zywrle_level); + break; + + case 2: +- if (vs->clientds.pf.gmax > 0x1F) { ++ if (vs->client_pf.gmax > 0x1F) { + if (be) { + zrle_encode_16be(vs, x, y, w, h, zywrle_level); + } else { +@@ -304,13 +304,13 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y, + bool fits_in_ms3bytes; + + fits_in_ls3bytes = +- ((vs->clientds.pf.rmax << vs->clientds.pf.rshift) < (1 << 24) && +- (vs->clientds.pf.gmax << vs->clientds.pf.gshift) < (1 << 24) && +- (vs->clientds.pf.bmax << vs->clientds.pf.bshift) < (1 << 24)); ++ ((vs->client_pf.rmax << vs->client_pf.rshift) < (1 << 24) && ++ (vs->client_pf.gmax << vs->client_pf.gshift) < (1 << 24) && ++ (vs->client_pf.bmax << vs->client_pf.bshift) < (1 << 24)); + +- fits_in_ms3bytes = (vs->clientds.pf.rshift > 7 && +- vs->clientds.pf.gshift > 7 && +- vs->clientds.pf.bshift > 7); ++ fits_in_ms3bytes = (vs->client_pf.rshift > 7 && ++ vs->client_pf.gshift > 7 && ++ vs->client_pf.bshift > 7); + + if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) { + if (be) {",932,1168,2048 +9676,"static struct rtable *__mkroute_output(const struct fib_result *res, + const struct flowi4 *fl4, int orig_oif, + struct net_device *dev_out, + unsigned int flags) +{ + struct fib_info *fi = res->fi; + struct fib_nh_exception *fnhe; + struct in_device *in_dev; + u16 type = res->type; + struct rtable *rth; + bool do_cache; + + in_dev = __in_dev_get_rcu(dev_out); + if (!in_dev) + return ERR_PTR(-EINVAL); + + if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev))) + if (ipv4_is_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK)) + return ERR_PTR(-EINVAL); + + if (ipv4_is_lbcast(fl4->daddr)) + type = RTN_BROADCAST; + else if (ipv4_is_multicast(fl4->daddr)) + type = RTN_MULTICAST; + else if (ipv4_is_zeronet(fl4->daddr)) + return ERR_PTR(-EINVAL); + + if (dev_out->flags & IFF_LOOPBACK) + flags |= RTCF_LOCAL; + + do_cache = true; + if (type == RTN_BROADCAST) { + flags |= RTCF_BROADCAST | RTCF_LOCAL; + fi = NULL; + } else if (type == RTN_MULTICAST) { + flags |= RTCF_MULTICAST | RTCF_LOCAL; + if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr, + fl4->flowi4_proto)) + flags &= ~RTCF_LOCAL; + else + do_cache = false; + /* If multicast route do not exist use + * default one, but do not gateway in this case. + * Yes, it is hack. + */ + if (fi && res->prefixlen < 4) + fi = NULL; + } else if ((type == RTN_LOCAL) && (orig_oif != 0) && + (orig_oif != dev_out->ifindex)) { + /* For local routes that require a particular output interface + * we do not want to cache the result. Caching the result + * causes incorrect behaviour when there are multiple source + * addresses on the interface, the end result being that if the + * intended recipient is waiting on that interface for the + * packet he won't receive it because it will be delivered on + * the loopback interface and the IP_PKTINFO ipi_ifindex will + * be set to the loopback interface as well. + */ + fi = NULL; + } + + fnhe = NULL; + do_cache &= fi != NULL; + if (do_cache) { + struct rtable __rcu **prth; + struct fib_nh *nh = &FIB_RES_NH(*res); + + fnhe = find_exception(nh, fl4->daddr); + if (fnhe) + prth = &fnhe->fnhe_rth_output; + else { + if (unlikely(fl4->flowi4_flags & + FLOWI_FLAG_KNOWN_NH && + !(nh->nh_gw && + nh->nh_scope == RT_SCOPE_LINK))) { + do_cache = false; + goto add; + } + prth = raw_cpu_ptr(nh->nh_pcpu_rth_output); + } + rth = rcu_dereference(*prth); + if (rt_cache_valid(rth)) { + dst_hold(&rth->dst); + return rth; + } + } + +add: + rth = rt_dst_alloc(dev_out, + IN_DEV_CONF_GET(in_dev, NOPOLICY), + IN_DEV_CONF_GET(in_dev, NOXFRM), + do_cache); + if (!rth) + return ERR_PTR(-ENOBUFS); + + rth->dst.output = ip_output; + + rth->rt_genid = rt_genid_ipv4(dev_net(dev_out)); + rth->rt_flags = flags; + rth->rt_type = type; + rth->rt_is_input = 0; + rth->rt_iif = orig_oif ? : 0; + rth->rt_pmtu = 0; + rth->rt_gateway = 0; + rth->rt_uses_gateway = 0; + INIT_LIST_HEAD(&rth->rt_uncached); + + RT_CACHE_STAT_INC(out_slow_tot); + + if (flags & RTCF_LOCAL) + rth->dst.input = ip_local_deliver; + if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) { + if (flags & RTCF_LOCAL && + !(dev_out->flags & IFF_LOOPBACK)) { + rth->dst.output = ip_mc_output; + RT_CACHE_STAT_INC(out_slow_mc); + } +#ifdef CONFIG_IP_MROUTE + if (type == RTN_MULTICAST) { + if (IN_DEV_MFORWARD(in_dev) && + !ipv4_is_local_multicast(fl4->daddr)) { + rth->dst.input = ip_mr_input; + rth->dst.output = ip_mc_output; + } + } +#endif + } + + rt_set_nexthop(rth, fl4->daddr, res, fnhe, fi, type, 0); + + return rth; +} +",0,"static struct rtable *__mkroute_output(const struct fib_result *res, + const struct flowi4 *fl4, int orig_oif, + struct net_device *dev_out, + unsigned int flags) +{ + struct fib_info *fi = res->fi; + struct fib_nh_exception *fnhe; + struct in_device *in_dev; + u16 type = res->type; + struct rtable *rth; + bool do_cache; + + in_dev = __in_dev_get_rcu(dev_out); + if (!in_dev) + return ERR_PTR(-EINVAL); + + if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev))) + if (ipv4_is_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK)) + return ERR_PTR(-EINVAL); + + if (ipv4_is_lbcast(fl4->daddr)) + type = RTN_BROADCAST; + else if (ipv4_is_multicast(fl4->daddr)) + type = RTN_MULTICAST; + else if (ipv4_is_zeronet(fl4->daddr)) + return ERR_PTR(-EINVAL); + + if (dev_out->flags & IFF_LOOPBACK) + flags |= RTCF_LOCAL; + + do_cache = true; + if (type == RTN_BROADCAST) { + flags |= RTCF_BROADCAST | RTCF_LOCAL; + fi = NULL; + } else if (type == RTN_MULTICAST) { + flags |= RTCF_MULTICAST | RTCF_LOCAL; + if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr, + fl4->flowi4_proto)) + flags &= ~RTCF_LOCAL; + else + do_cache = false; + /* If multicast route do not exist use + * default one, but do not gateway in this case. + * Yes, it is hack. + */ + if (fi && res->prefixlen < 4) + fi = NULL; + } else if ((type == RTN_LOCAL) && (orig_oif != 0) && + (orig_oif != dev_out->ifindex)) { + /* For local routes that require a particular output interface + * we do not want to cache the result. Caching the result + * causes incorrect behaviour when there are multiple source + * addresses on the interface, the end result being that if the + * intended recipient is waiting on that interface for the + * packet he won't receive it because it will be delivered on + * the loopback interface and the IP_PKTINFO ipi_ifindex will + * be set to the loopback interface as well. + */ + fi = NULL; + } + + fnhe = NULL; + do_cache &= fi != NULL; + if (do_cache) { + struct rtable __rcu **prth; + struct fib_nh *nh = &FIB_RES_NH(*res); + + fnhe = find_exception(nh, fl4->daddr); + if (fnhe) + prth = &fnhe->fnhe_rth_output; + else { + if (unlikely(fl4->flowi4_flags & + FLOWI_FLAG_KNOWN_NH && + !(nh->nh_gw && + nh->nh_scope == RT_SCOPE_LINK))) { + do_cache = false; + goto add; + } + prth = raw_cpu_ptr(nh->nh_pcpu_rth_output); + } + rth = rcu_dereference(*prth); + if (rt_cache_valid(rth)) { + dst_hold(&rth->dst); + return rth; + } + } + +add: + rth = rt_dst_alloc(dev_out, + IN_DEV_CONF_GET(in_dev, NOPOLICY), + IN_DEV_CONF_GET(in_dev, NOXFRM), + do_cache); + if (!rth) + return ERR_PTR(-ENOBUFS); + + rth->dst.output = ip_output; + + rth->rt_genid = rt_genid_ipv4(dev_net(dev_out)); + rth->rt_flags = flags; + rth->rt_type = type; + rth->rt_is_input = 0; + rth->rt_iif = orig_oif ? : 0; + rth->rt_pmtu = 0; + rth->rt_gateway = 0; + rth->rt_uses_gateway = 0; + INIT_LIST_HEAD(&rth->rt_uncached); + + RT_CACHE_STAT_INC(out_slow_tot); + + if (flags & RTCF_LOCAL) + rth->dst.input = ip_local_deliver; + if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) { + if (flags & RTCF_LOCAL && + !(dev_out->flags & IFF_LOOPBACK)) { + rth->dst.output = ip_mc_output; + RT_CACHE_STAT_INC(out_slow_mc); + } +#ifdef CONFIG_IP_MROUTE + if (type == RTN_MULTICAST) { + if (IN_DEV_MFORWARD(in_dev) && + !ipv4_is_local_multicast(fl4->daddr)) { + rth->dst.input = ip_mr_input; + rth->dst.output = ip_mc_output; + } + } +#endif + } + + rt_set_nexthop(rth, fl4->daddr, res, fnhe, fi, type, 0); + + return rth; +} +","@@ -488,13 +488,15 @@ EXPORT_SYMBOL(ip_idents_reserve); + void __ip_select_ident(struct iphdr *iph, int segs) + { + static u32 ip_idents_hashrnd __read_mostly; ++ static u32 ip_idents_hashrnd_extra __read_mostly; + u32 hash, id; + + net_get_random_once(&ip_idents_hashrnd, sizeof(ip_idents_hashrnd)); ++ net_get_random_once(&ip_idents_hashrnd_extra, sizeof(ip_idents_hashrnd_extra)); + + hash = jhash_3words((__force u32)iph->daddr, + (__force u32)iph->saddr, +- iph->protocol, ++ iph->protocol ^ ip_idents_hashrnd_extra, + ip_idents_hashrnd); + id = ip_idents_reserve(hash, segs); + iph->id = htons(id);",1120,1356,2048 +979,"int ntpd_main(int argc UNUSED_PARAM, char **argv) +{ +#undef G + struct globals G; + struct pollfd *pfd; + peer_t **idx2peer; + unsigned cnt; + + memset(&G, 0, sizeof(G)); + SET_PTR_TO_GLOBALS(&G); + + ntp_init(argv); + + /* If ENABLE_FEATURE_NTPD_SERVER, + 1 for listen_fd: */ + cnt = G.peer_cnt + ENABLE_FEATURE_NTPD_SERVER; + idx2peer = xzalloc(sizeof(idx2peer[0]) * cnt); + pfd = xzalloc(sizeof(pfd[0]) * cnt); + + /* Countdown: we never sync before we sent INITIAL_SAMPLES+1 + * packets to each peer. + * NB: if some peer is not responding, we may end up sending + * fewer packets to it and more to other peers. + * NB2: sync usually happens using INITIAL_SAMPLES packets, + * since last reply does not come back instantaneously. + */ + cnt = G.peer_cnt * (INITIAL_SAMPLES + 1); + + write_pidfile(CONFIG_PID_FILE_PATH ""/ntpd.pid""); + + while (!bb_got_signal) { + llist_t *item; + unsigned i, j; + int nfds, timeout; + double nextaction; + + /* Nothing between here and poll() blocks for any significant time */ + + nextaction = G.cur_time + 3600; + + i = 0; +#if ENABLE_FEATURE_NTPD_SERVER + if (G_listen_fd != -1) { + pfd[0].fd = G_listen_fd; + pfd[0].events = POLLIN; + i++; + } +#endif + /* Pass over peer list, send requests, time out on receives */ + for (item = G.ntp_peers; item != NULL; item = item->link) { + peer_t *p = (peer_t *) item->data; + + if (p->next_action_time <= G.cur_time) { + if (p->p_fd == -1) { + /* Time to send new req */ + if (--cnt == 0) { + VERB4 bb_error_msg(""disabling burst mode""); + G.polladj_count = 0; + G.poll_exp = MINPOLL; + } + send_query_to_peer(p); + } else { + /* Timed out waiting for reply */ + close(p->p_fd); + p->p_fd = -1; + /* If poll interval is small, increase it */ + if (G.poll_exp < BIGPOLL) + adjust_poll(MINPOLL); + timeout = poll_interval(NOREPLY_INTERVAL); + bb_error_msg(""timed out waiting for %s, reach 0x%02x, next query in %us"", + p->p_dotted, p->reachable_bits, timeout); + + /* What if don't see it because it changed its IP? */ + if (p->reachable_bits == 0) + resolve_peer_hostname(p, /*loop_on_fail=*/ 0); + + set_next(p, timeout); + } + } + + if (p->next_action_time < nextaction) + nextaction = p->next_action_time; + + if (p->p_fd >= 0) { + /* Wait for reply from this peer */ + pfd[i].fd = p->p_fd; + pfd[i].events = POLLIN; + idx2peer[i] = p; + i++; + } + } + + timeout = nextaction - G.cur_time; + if (timeout < 0) + timeout = 0; + timeout++; /* (nextaction - G.cur_time) rounds down, compensating */ + + /* Here we may block */ + VERB2 { + if (i > (ENABLE_FEATURE_NTPD_SERVER && G_listen_fd != -1)) { + /* We wait for at least one reply. + * Poll for it, without wasting time for message. + * Since replies often come under 1 second, this also + * reduces clutter in logs. + */ + nfds = poll(pfd, i, 1000); + if (nfds != 0) + goto did_poll; + if (--timeout <= 0) + goto did_poll; + } + bb_error_msg(""poll:%us sockets:%u interval:%us"", timeout, i, 1 << G.poll_exp); + } + nfds = poll(pfd, i, timeout * 1000); + did_poll: + gettime1900d(); /* sets G.cur_time */ + if (nfds <= 0) { + if (!bb_got_signal /* poll wasn't interrupted by a signal */ + && G.cur_time - G.last_script_run > 11*60 + ) { + /* Useful for updating battery-backed RTC and such */ + run_script(""periodic"", G.last_update_offset); + gettime1900d(); /* sets G.cur_time */ + } + goto check_unsync; + } + + /* Process any received packets */ + j = 0; +#if ENABLE_FEATURE_NTPD_SERVER + if (G.listen_fd != -1) { + if (pfd[0].revents /* & (POLLIN|POLLERR)*/) { + nfds--; + recv_and_process_client_pkt(/*G.listen_fd*/); + gettime1900d(); /* sets G.cur_time */ + } + j = 1; + } +#endif + for (; nfds != 0 && j < i; j++) { + if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { + /* + * At init, alarm was set to 10 sec. + * Now we did get a reply. + * Increase timeout to 50 seconds to finish syncing. + */ + if (option_mask32 & OPT_qq) { + option_mask32 &= ~OPT_qq; + alarm(50); + } + nfds--; + recv_and_process_peer_pkt(idx2peer[j]); + gettime1900d(); /* sets G.cur_time */ + } + } + + check_unsync: + if (G.ntp_peers && G.stratum != MAXSTRAT) { + for (item = G.ntp_peers; item != NULL; item = item->link) { + peer_t *p = (peer_t *) item->data; + if (p->reachable_bits) + goto have_reachable_peer; + } + /* No peer responded for last 8 packets, panic */ + clamp_pollexp_and_set_MAXSTRAT(); + run_script(""unsync"", 0.0); + have_reachable_peer: ; + } + } /* while (!bb_got_signal) */ + + remove_pidfile(CONFIG_PID_FILE_PATH ""/ntpd.pid""); + kill_myself_with_sig(bb_got_signal); +} +",0,"int ntpd_main(int argc UNUSED_PARAM, char **argv) +{ +#undef G + struct globals G; + struct pollfd *pfd; + peer_t **idx2peer; + unsigned cnt; + + memset(&G, 0, sizeof(G)); + SET_PTR_TO_GLOBALS(&G); + + ntp_init(argv); + + /* If ENABLE_FEATURE_NTPD_SERVER, + 1 for listen_fd: */ + cnt = G.peer_cnt + ENABLE_FEATURE_NTPD_SERVER; + idx2peer = xzalloc(sizeof(idx2peer[0]) * cnt); + pfd = xzalloc(sizeof(pfd[0]) * cnt); + + /* Countdown: we never sync before we sent INITIAL_SAMPLES+1 + * packets to each peer. + * NB: if some peer is not responding, we may end up sending + * fewer packets to it and more to other peers. + * NB2: sync usually happens using INITIAL_SAMPLES packets, + * since last reply does not come back instantaneously. + */ + cnt = G.peer_cnt * (INITIAL_SAMPLES + 1); + + write_pidfile(CONFIG_PID_FILE_PATH ""/ntpd.pid""); + + while (!bb_got_signal) { + llist_t *item; + unsigned i, j; + int nfds, timeout; + double nextaction; + + /* Nothing between here and poll() blocks for any significant time */ + + nextaction = G.cur_time + 3600; + + i = 0; +#if ENABLE_FEATURE_NTPD_SERVER + if (G_listen_fd != -1) { + pfd[0].fd = G_listen_fd; + pfd[0].events = POLLIN; + i++; + } +#endif + /* Pass over peer list, send requests, time out on receives */ + for (item = G.ntp_peers; item != NULL; item = item->link) { + peer_t *p = (peer_t *) item->data; + + if (p->next_action_time <= G.cur_time) { + if (p->p_fd == -1) { + /* Time to send new req */ + if (--cnt == 0) { + VERB4 bb_error_msg(""disabling burst mode""); + G.polladj_count = 0; + G.poll_exp = MINPOLL; + } + send_query_to_peer(p); + } else { + /* Timed out waiting for reply */ + close(p->p_fd); + p->p_fd = -1; + /* If poll interval is small, increase it */ + if (G.poll_exp < BIGPOLL) + adjust_poll(MINPOLL); + timeout = poll_interval(NOREPLY_INTERVAL); + bb_error_msg(""timed out waiting for %s, reach 0x%02x, next query in %us"", + p->p_dotted, p->reachable_bits, timeout); + + /* What if don't see it because it changed its IP? */ + if (p->reachable_bits == 0) + resolve_peer_hostname(p, /*loop_on_fail=*/ 0); + + set_next(p, timeout); + } + } + + if (p->next_action_time < nextaction) + nextaction = p->next_action_time; + + if (p->p_fd >= 0) { + /* Wait for reply from this peer */ + pfd[i].fd = p->p_fd; + pfd[i].events = POLLIN; + idx2peer[i] = p; + i++; + } + } + + timeout = nextaction - G.cur_time; + if (timeout < 0) + timeout = 0; + timeout++; /* (nextaction - G.cur_time) rounds down, compensating */ + + /* Here we may block */ + VERB2 { + if (i > (ENABLE_FEATURE_NTPD_SERVER && G_listen_fd != -1)) { + /* We wait for at least one reply. + * Poll for it, without wasting time for message. + * Since replies often come under 1 second, this also + * reduces clutter in logs. + */ + nfds = poll(pfd, i, 1000); + if (nfds != 0) + goto did_poll; + if (--timeout <= 0) + goto did_poll; + } + bb_error_msg(""poll:%us sockets:%u interval:%us"", timeout, i, 1 << G.poll_exp); + } + nfds = poll(pfd, i, timeout * 1000); + did_poll: + gettime1900d(); /* sets G.cur_time */ + if (nfds <= 0) { + if (!bb_got_signal /* poll wasn't interrupted by a signal */ + && G.cur_time - G.last_script_run > 11*60 + ) { + /* Useful for updating battery-backed RTC and such */ + run_script(""periodic"", G.last_update_offset); + gettime1900d(); /* sets G.cur_time */ + } + goto check_unsync; + } + + /* Process any received packets */ + j = 0; +#if ENABLE_FEATURE_NTPD_SERVER + if (G.listen_fd != -1) { + if (pfd[0].revents /* & (POLLIN|POLLERR)*/) { + nfds--; + recv_and_process_client_pkt(/*G.listen_fd*/); + gettime1900d(); /* sets G.cur_time */ + } + j = 1; + } +#endif + for (; nfds != 0 && j < i; j++) { + if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { + /* + * At init, alarm was set to 10 sec. + * Now we did get a reply. + * Increase timeout to 50 seconds to finish syncing. + */ + if (option_mask32 & OPT_qq) { + option_mask32 &= ~OPT_qq; + alarm(50); + } + nfds--; + recv_and_process_peer_pkt(idx2peer[j]); + gettime1900d(); /* sets G.cur_time */ + } + } + + check_unsync: + if (G.ntp_peers && G.stratum != MAXSTRAT) { + for (item = G.ntp_peers; item != NULL; item = item->link) { + peer_t *p = (peer_t *) item->data; + if (p->reachable_bits) + goto have_reachable_peer; + } + /* No peer responded for last 8 packets, panic */ + clamp_pollexp_and_set_MAXSTRAT(); + run_script(""unsync"", 0.0); + have_reachable_peer: ; + } + } /* while (!bb_got_signal) */ + + remove_pidfile(CONFIG_PID_FILE_PATH ""/ntpd.pid""); + kill_myself_with_sig(bb_got_signal); +} +","@@ -2051,6 +2051,13 @@ recv_and_process_client_pkt(void /*int fd*/) + goto bail; + } + ++ /* Respond only to client and symmetric active packets */ ++ if ((msg.m_status & MODE_MASK) != MODE_CLIENT ++ && (msg.m_status & MODE_MASK) != MODE_SYM_ACT ++ ) { ++ goto bail; ++ } ++ + query_status = msg.m_status; + query_xmttime = msg.m_xmttime;",1486,1722,2048 +17968,"iakerb_gss_init_sec_context(OM_uint32 *minor_status, + gss_cred_id_t claimant_cred_handle, + gss_ctx_id_t *context_handle, + gss_name_t target_name, + gss_OID mech_type, + OM_uint32 req_flags, + OM_uint32 time_req, + gss_channel_bindings_t input_chan_bindings, + gss_buffer_t input_token, + gss_OID *actual_mech_type, + gss_buffer_t output_token, + OM_uint32 *ret_flags, + OM_uint32 *time_rec) +{ + OM_uint32 major_status = GSS_S_FAILURE; + krb5_error_code code; + iakerb_ctx_id_t ctx; + krb5_gss_cred_id_t kcred; + krb5_gss_name_t kname; + krb5_boolean cred_locked = FALSE; + int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT); + + if (initialContextToken) { + code = iakerb_alloc_context(&ctx); + if (code != 0) { + *minor_status = code; + goto cleanup; + } + if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) { + major_status = iakerb_gss_acquire_cred(minor_status, NULL, + GSS_C_INDEFINITE, + GSS_C_NULL_OID_SET, + GSS_C_INITIATE, + &ctx->defcred, NULL, NULL); + if (GSS_ERROR(major_status)) + goto cleanup; + claimant_cred_handle = ctx->defcred; + } + } else { + ctx = (iakerb_ctx_id_t)*context_handle; + if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) + claimant_cred_handle = ctx->defcred; + } + + kname = (krb5_gss_name_t)target_name; + + major_status = kg_cred_resolve(minor_status, ctx->k5c, + claimant_cred_handle, target_name); + if (GSS_ERROR(major_status)) + goto cleanup; + cred_locked = TRUE; + kcred = (krb5_gss_cred_id_t)claimant_cred_handle; + + major_status = GSS_S_FAILURE; + + if (initialContextToken) { + code = iakerb_get_initial_state(ctx, kcred, kname, time_req, + &ctx->state); + if (code != 0) { + *minor_status = code; + goto cleanup; + } + *context_handle = (gss_ctx_id_t)ctx; + } + + if (ctx->state != IAKERB_AP_REQ) { + /* We need to do IAKERB. */ + code = iakerb_initiator_step(ctx, + kcred, + kname, + time_req, + input_token, + output_token); + if (code == KRB5_BAD_MSIZE) + major_status = GSS_S_DEFECTIVE_TOKEN; + if (code != 0) { + *minor_status = code; + goto cleanup; + } + } + + if (ctx->state == IAKERB_AP_REQ) { + krb5_gss_ctx_ext_rec exts; + + if (cred_locked) { + k5_mutex_unlock(&kcred->lock); + cred_locked = FALSE; + } + + iakerb_make_exts(ctx, &exts); + + if (ctx->gssc == GSS_C_NO_CONTEXT) + input_token = GSS_C_NO_BUFFER; + + /* IAKERB is finished, or we skipped to Kerberos directly. */ + major_status = krb5_gss_init_sec_context_ext(minor_status, + (gss_cred_id_t) kcred, + &ctx->gssc, + target_name, + (gss_OID)gss_mech_iakerb, + req_flags, + time_req, + input_chan_bindings, + input_token, + NULL, + output_token, + ret_flags, + time_rec, + &exts); + if (major_status == GSS_S_COMPLETE) { + *context_handle = ctx->gssc; + ctx->gssc = GSS_C_NO_CONTEXT; + iakerb_release_context(ctx); + } + if (actual_mech_type != NULL) + *actual_mech_type = (gss_OID)gss_mech_krb5; + } else { + if (actual_mech_type != NULL) + *actual_mech_type = (gss_OID)gss_mech_iakerb; + if (ret_flags != NULL) + *ret_flags = 0; + if (time_rec != NULL) + *time_rec = 0; + major_status = GSS_S_CONTINUE_NEEDED; + } + +cleanup: + if (cred_locked) + k5_mutex_unlock(&kcred->lock); + if (initialContextToken && GSS_ERROR(major_status)) { + iakerb_release_context(ctx); + *context_handle = GSS_C_NO_CONTEXT; + } + + return major_status; + } +",1,"iakerb_gss_init_sec_context(OM_uint32 *minor_status, + gss_cred_id_t claimant_cred_handle, + gss_ctx_id_t *context_handle, + gss_name_t target_name, + gss_OID mech_type, + OM_uint32 req_flags, + OM_uint32 time_req, + gss_channel_bindings_t input_chan_bindings, + gss_buffer_t input_token, + gss_OID *actual_mech_type, + gss_buffer_t output_token, + OM_uint32 *ret_flags, + OM_uint32 *time_rec) +{ + OM_uint32 major_status = GSS_S_FAILURE; + krb5_error_code code; + iakerb_ctx_id_t ctx; + krb5_gss_cred_id_t kcred; + krb5_gss_name_t kname; + krb5_boolean cred_locked = FALSE; + int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT); + + if (initialContextToken) { + code = iakerb_alloc_context(&ctx, 1); + if (code != 0) { + *minor_status = code; + goto cleanup; + } + if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) { + major_status = iakerb_gss_acquire_cred(minor_status, NULL, + GSS_C_INDEFINITE, + GSS_C_NULL_OID_SET, + GSS_C_INITIATE, + &ctx->defcred, NULL, NULL); + if (GSS_ERROR(major_status)) + goto cleanup; + claimant_cred_handle = ctx->defcred; + } + } else { + ctx = (iakerb_ctx_id_t)*context_handle; + if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) + claimant_cred_handle = ctx->defcred; + } + + kname = (krb5_gss_name_t)target_name; + + major_status = kg_cred_resolve(minor_status, ctx->k5c, + claimant_cred_handle, target_name); + if (GSS_ERROR(major_status)) + goto cleanup; + cred_locked = TRUE; + kcred = (krb5_gss_cred_id_t)claimant_cred_handle; + + major_status = GSS_S_FAILURE; + + if (initialContextToken) { + code = iakerb_get_initial_state(ctx, kcred, kname, time_req, + &ctx->state); + if (code != 0) { + *minor_status = code; + goto cleanup; + } + *context_handle = (gss_ctx_id_t)ctx; + } + + if (ctx->state != IAKERB_AP_REQ) { + /* We need to do IAKERB. */ + code = iakerb_initiator_step(ctx, + kcred, + kname, + time_req, + input_token, + output_token); + if (code == KRB5_BAD_MSIZE) + major_status = GSS_S_DEFECTIVE_TOKEN; + if (code != 0) { + *minor_status = code; + goto cleanup; + } + } + + if (ctx->state == IAKERB_AP_REQ) { + krb5_gss_ctx_ext_rec exts; + + if (cred_locked) { + k5_mutex_unlock(&kcred->lock); + cred_locked = FALSE; + } + + iakerb_make_exts(ctx, &exts); + + if (ctx->gssc == GSS_C_NO_CONTEXT) + input_token = GSS_C_NO_BUFFER; + + /* IAKERB is finished, or we skipped to Kerberos directly. */ + major_status = krb5_gss_init_sec_context_ext(minor_status, + (gss_cred_id_t) kcred, + &ctx->gssc, + target_name, + (gss_OID)gss_mech_iakerb, + req_flags, + time_req, + input_chan_bindings, + input_token, + NULL, + output_token, + ret_flags, + time_rec, + &exts); + if (major_status == GSS_S_COMPLETE) + ctx->established = 1; + if (actual_mech_type != NULL) + *actual_mech_type = (gss_OID)gss_mech_krb5; + } else { + if (actual_mech_type != NULL) + *actual_mech_type = (gss_OID)gss_mech_iakerb; + if (ret_flags != NULL) + *ret_flags = 0; + if (time_rec != NULL) + *time_rec = 0; + major_status = GSS_S_CONTINUE_NEEDED; + } + +cleanup: + if (cred_locked) + k5_mutex_unlock(&kcred->lock); + if (initialContextToken && GSS_ERROR(major_status)) { + iakerb_release_context(ctx); + *context_handle = GSS_C_NO_CONTEXT; + } + + return major_status; + } +","@@ -47,6 +47,8 @@ struct _iakerb_ctx_id_rec { + gss_ctx_id_t gssc; + krb5_data conv; /* conversation for checksumming */ + unsigned int count; /* number of round trips */ ++ int initiate; ++ int established; + krb5_get_init_creds_opt *gic_opts; + }; + +@@ -695,7 +697,7 @@ iakerb_get_initial_state(iakerb_ctx_id_t ctx, + * Allocate and initialise an IAKERB context + */ + static krb5_error_code +-iakerb_alloc_context(iakerb_ctx_id_t *pctx) ++iakerb_alloc_context(iakerb_ctx_id_t *pctx, int initiate) + { + iakerb_ctx_id_t ctx; + krb5_error_code code; +@@ -709,6 +711,8 @@ iakerb_alloc_context(iakerb_ctx_id_t *pctx) + ctx->magic = KG_IAKERB_CONTEXT; + ctx->state = IAKERB_AS_REQ; + ctx->count = 0; ++ ctx->initiate = initiate; ++ ctx->established = 0; + + code = krb5_gss_init_context(&ctx->k5c); + if (code != 0) +@@ -732,31 +736,18 @@ iakerb_gss_delete_sec_context(OM_uint32 *minor_status, + gss_ctx_id_t *context_handle, + gss_buffer_t output_token) + { +- OM_uint32 major_status = GSS_S_COMPLETE; ++ iakerb_ctx_id_t iakerb_ctx = (iakerb_ctx_id_t)*context_handle; + + if (output_token != GSS_C_NO_BUFFER) { + output_token->length = 0; + output_token->value = NULL; + } + + *minor_status = 0; ++ *context_handle = GSS_C_NO_CONTEXT; ++ iakerb_release_context(iakerb_ctx); + +- if (*context_handle != GSS_C_NO_CONTEXT) { +- iakerb_ctx_id_t iakerb_ctx = (iakerb_ctx_id_t)*context_handle; +- +- if (iakerb_ctx->magic == KG_IAKERB_CONTEXT) { +- iakerb_release_context(iakerb_ctx); +- *context_handle = GSS_C_NO_CONTEXT; +- } else { +- assert(iakerb_ctx->magic == KG_CONTEXT); +- +- major_status = krb5_gss_delete_sec_context(minor_status, +- context_handle, +- output_token); +- } +- } +- +- return major_status; ++ return GSS_S_COMPLETE; + } + + static krb5_boolean +@@ -802,7 +793,7 @@ iakerb_gss_accept_sec_context(OM_uint32 *minor_status, + int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT); + + if (initialContextToken) { +- code = iakerb_alloc_context(&ctx); ++ code = iakerb_alloc_context(&ctx, 0); + if (code != 0) + goto cleanup; + +@@ -854,11 +845,8 @@ iakerb_gss_accept_sec_context(OM_uint32 *minor_status, + time_rec, + delegated_cred_handle, + &exts); +- if (major_status == GSS_S_COMPLETE) { +- *context_handle = ctx->gssc; +- ctx->gssc = NULL; +- iakerb_release_context(ctx); +- } ++ if (major_status == GSS_S_COMPLETE) ++ ctx->established = 1; + if (mech_type != NULL) + *mech_type = (gss_OID)gss_mech_krb5; + } +@@ -897,7 +885,7 @@ iakerb_gss_init_sec_context(OM_uint32 *minor_status, + int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT); + + if (initialContextToken) { +- code = iakerb_alloc_context(&ctx); ++ code = iakerb_alloc_context(&ctx, 1); + if (code != 0) { + *minor_status = code; + goto cleanup; +@@ -983,11 +971,8 @@ iakerb_gss_init_sec_context(OM_uint32 *minor_status, + ret_flags, + time_rec, + &exts); +- if (major_status == GSS_S_COMPLETE) { +- *context_handle = ctx->gssc; +- ctx->gssc = GSS_C_NO_CONTEXT; +- iakerb_release_context(ctx); +- } ++ if (major_status == GSS_S_COMPLETE) ++ ctx->established = 1; + if (actual_mech_type != NULL) + *actual_mech_type = (gss_OID)gss_mech_krb5; + } else { +@@ -1010,3 +995,309 @@ iakerb_gss_init_sec_context(OM_uint32 *minor_status, + + return major_status; + } ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_unwrap(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ gss_buffer_t input_message_buffer, ++ gss_buffer_t output_message_buffer, int *conf_state, ++ gss_qop_t *qop_state) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_unwrap(minor_status, ctx->gssc, input_message_buffer, ++ output_message_buffer, conf_state, qop_state); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_wrap(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ int conf_req_flag, gss_qop_t qop_req, ++ gss_buffer_t input_message_buffer, int *conf_state, ++ gss_buffer_t output_message_buffer) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_wrap(minor_status, ctx->gssc, conf_req_flag, qop_req, ++ input_message_buffer, conf_state, ++ output_message_buffer); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_process_context_token(OM_uint32 *minor_status, ++ const gss_ctx_id_t context_handle, ++ const gss_buffer_t token_buffer) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_DEFECTIVE_TOKEN; ++ ++ return krb5_gss_process_context_token(minor_status, ctx->gssc, ++ token_buffer); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_context_time(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ OM_uint32 *time_rec) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_context_time(minor_status, ctx->gssc, time_rec); ++} ++ ++#ifndef LEAN_CLIENT ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_export_sec_context(OM_uint32 *minor_status, ++ gss_ctx_id_t *context_handle, ++ gss_buffer_t interprocess_token) ++{ ++ OM_uint32 maj; ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ /* We don't currently support exporting partially established contexts. */ ++ if (!ctx->established) ++ return GSS_S_UNAVAILABLE; ++ ++ maj = krb5_gss_export_sec_context(minor_status, &ctx->gssc, ++ interprocess_token); ++ if (ctx->gssc == GSS_C_NO_CONTEXT) { ++ iakerb_release_context(ctx); ++ *context_handle = GSS_C_NO_CONTEXT; ++ } ++ return maj; ++} ++ ++/* ++ * Until we implement partial context exports, there are no SPNEGO exported ++ * context tokens, only tokens for the underlying krb5 context. So we do not ++ * need to implement an iakerb_gss_import_sec_context() yet; it would be ++ * unreachable except via a manually constructed token. ++ */ ++ ++#endif /* LEAN_CLIENT */ ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_inquire_context(OM_uint32 *minor_status, ++ gss_ctx_id_t context_handle, gss_name_t *src_name, ++ gss_name_t *targ_name, OM_uint32 *lifetime_rec, ++ gss_OID *mech_type, OM_uint32 *ctx_flags, ++ int *initiate, int *opened) ++{ ++ OM_uint32 ret; ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (src_name != NULL) ++ *src_name = GSS_C_NO_NAME; ++ if (targ_name != NULL) ++ *targ_name = GSS_C_NO_NAME; ++ if (lifetime_rec != NULL) ++ *lifetime_rec = 0; ++ if (mech_type != NULL) ++ *mech_type = (gss_OID)gss_mech_iakerb; ++ if (ctx_flags != NULL) ++ *ctx_flags = 0; ++ if (initiate != NULL) ++ *initiate = ctx->initiate; ++ if (opened != NULL) ++ *opened = ctx->established; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_COMPLETE; ++ ++ ret = krb5_gss_inquire_context(minor_status, ctx->gssc, src_name, ++ targ_name, lifetime_rec, mech_type, ++ ctx_flags, initiate, opened); ++ ++ if (!ctx->established) { ++ /* Report IAKERB as the mech OID until the context is established. */ ++ if (mech_type != NULL) ++ *mech_type = (gss_OID)gss_mech_iakerb; ++ ++ /* We don't support exporting partially-established contexts. */ ++ if (ctx_flags != NULL) ++ *ctx_flags &= ~GSS_C_TRANS_FLAG; ++ } ++ ++ return ret; ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_wrap_size_limit(OM_uint32 *minor_status, ++ gss_ctx_id_t context_handle, int conf_req_flag, ++ gss_qop_t qop_req, OM_uint32 req_output_size, ++ OM_uint32 *max_input_size) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_wrap_size_limit(minor_status, ctx->gssc, conf_req_flag, ++ qop_req, req_output_size, max_input_size); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_get_mic(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ gss_qop_t qop_req, gss_buffer_t message_buffer, ++ gss_buffer_t message_token) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_get_mic(minor_status, ctx->gssc, qop_req, message_buffer, ++ message_token); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_verify_mic(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ gss_buffer_t msg_buffer, gss_buffer_t token_buffer, ++ gss_qop_t *qop_state) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_verify_mic(minor_status, ctx->gssc, msg_buffer, ++ token_buffer, qop_state); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_inquire_sec_context_by_oid(OM_uint32 *minor_status, ++ const gss_ctx_id_t context_handle, ++ const gss_OID desired_object, ++ gss_buffer_set_t *data_set) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_UNAVAILABLE; ++ ++ return krb5_gss_inquire_sec_context_by_oid(minor_status, ctx->gssc, ++ desired_object, data_set); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_set_sec_context_option(OM_uint32 *minor_status, ++ gss_ctx_id_t *context_handle, ++ const gss_OID desired_object, ++ const gss_buffer_t value) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)*context_handle; ++ ++ if (ctx == NULL || ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_UNAVAILABLE; ++ ++ return krb5_gss_set_sec_context_option(minor_status, &ctx->gssc, ++ desired_object, value); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_wrap_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ int conf_req_flag, gss_qop_t qop_req, int *conf_state, ++ gss_iov_buffer_desc *iov, int iov_count) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_wrap_iov(minor_status, ctx->gssc, conf_req_flag, qop_req, ++ conf_state, iov, iov_count); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_unwrap_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ int *conf_state, gss_qop_t *qop_state, ++ gss_iov_buffer_desc *iov, int iov_count) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_unwrap_iov(minor_status, ctx->gssc, conf_state, qop_state, ++ iov, iov_count); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_wrap_iov_length(OM_uint32 *minor_status, ++ gss_ctx_id_t context_handle, int conf_req_flag, ++ gss_qop_t qop_req, int *conf_state, ++ gss_iov_buffer_desc *iov, int iov_count) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_wrap_iov_length(minor_status, ctx->gssc, conf_req_flag, ++ qop_req, conf_state, iov, iov_count); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_pseudo_random(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ int prf_key, const gss_buffer_t prf_in, ++ ssize_t desired_output_len, gss_buffer_t prf_out) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_pseudo_random(minor_status, ctx->gssc, prf_key, prf_in, ++ desired_output_len, prf_out); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_get_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ gss_qop_t qop_req, gss_iov_buffer_desc *iov, ++ int iov_count) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_get_mic_iov(minor_status, ctx->gssc, qop_req, iov, ++ iov_count); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_verify_mic_iov(OM_uint32 *minor_status, gss_ctx_id_t context_handle, ++ gss_qop_t *qop_state, gss_iov_buffer_desc *iov, ++ int iov_count) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_verify_mic_iov(minor_status, ctx->gssc, qop_state, iov, ++ iov_count); ++} ++ ++OM_uint32 KRB5_CALLCONV ++iakerb_gss_get_mic_iov_length(OM_uint32 *minor_status, ++ gss_ctx_id_t context_handle, gss_qop_t qop_req, ++ gss_iov_buffer_desc *iov, int iov_count) ++{ ++ iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle; ++ ++ if (ctx->gssc == GSS_C_NO_CONTEXT) ++ return GSS_S_NO_CONTEXT; ++ ++ return krb5_gss_get_mic_iov_length(minor_status, ctx->gssc, qop_req, iov, ++ iov_count); ++}",1058,1294,2048 +295,"get_pdf14_device_proto(gx_device * dev, pdf14_device ** pdevproto, + pdf14_device * ptempdevproto, gs_gstate * pgs, + const gs_pdf14trans_t * pdf14pct, bool use_pdf14_accum) +{ + bool using_blend_cs; + pdf14_default_colorspace_t dev_cs = + pdf14_determine_default_blend_cs(dev, use_pdf14_accum, + &using_blend_cs); + + switch (dev_cs) { + case PDF14_DeviceGray: + *pdevproto = (pdf14_device *)&gs_pdf14_Gray_device; + *ptempdevproto = **pdevproto; + ptempdevproto->color_info.max_components = 1; + ptempdevproto->color_info.num_components = + ptempdevproto->color_info.max_components; + ptempdevproto->color_info.max_gray = 255; + ptempdevproto->color_info.gray_index = 0; /* Avoid halftoning */ + ptempdevproto->color_info.dither_grays = 256; + ptempdevproto->sep_device = false; + *pdevproto = ptempdevproto; + break; + case PDF14_DeviceRGB: + *pdevproto = (pdf14_device *)&gs_pdf14_RGB_device; + *ptempdevproto = **pdevproto; + ptempdevproto->sep_device = false; + *pdevproto = ptempdevproto; + break; + case PDF14_DeviceCMYK: + *pdevproto = (pdf14_device *)&gs_pdf14_CMYK_device; + *ptempdevproto = **pdevproto; + ptempdevproto->sep_device = false; + *pdevproto = ptempdevproto; + break; + case PDF14_DeviceCMYKspot: + *pdevproto = (pdf14_device *)&gs_pdf14_CMYKspot_device; + /* Need to figure out how we want to handle the device profile + for this case */ + /* + * The number of components for the PDF14 device is the sum + * of the process components and the number of spot colors + * for the page. + */ + if (pdf14pct->params.num_spot_colors >= 0) { + *ptempdevproto = **pdevproto; + ptempdevproto->devn_params.page_spot_colors = + pdf14pct->params.num_spot_colors; + ptempdevproto->color_info.num_components = + ptempdevproto->devn_params.num_std_colorant_names + + pdf14pct->params.num_spot_colors; + if (ptempdevproto->color_info.num_components > + GS_CLIENT_COLOR_MAX_COMPONENTS) + ptempdevproto->color_info.num_components = + GS_CLIENT_COLOR_MAX_COMPONENTS; + ptempdevproto->color_info.depth = + ptempdevproto->color_info.num_components * 8; + ptempdevproto->sep_device = true; + *pdevproto = ptempdevproto; + } + break; + case PDF14_DeviceCustom: + /* + * We are using the output device's process color model. The + * color_info for the PDF 1.4 compositing device needs to match + * the output device. + */ + *ptempdevproto = gs_pdf14_custom_device; + ptempdevproto->color_info = dev->color_info; + /* The pdf14 device has to be 8 bit continuous tone. Force it */ + ptempdevproto->color_info.depth = + ptempdevproto->color_info.num_components * 8; + ptempdevproto->color_info.max_gray = 255; + ptempdevproto->color_info.max_color = 255; + ptempdevproto->color_info.dither_grays = 256; + ptempdevproto->color_info.dither_colors = 256; + + *pdevproto = ptempdevproto; + break; + default: /* Should not occur */ + return_error(gs_error_rangecheck); + } + ptempdevproto->using_blend_cs = using_blend_cs; + return 0; +} +",0,"get_pdf14_device_proto(gx_device * dev, pdf14_device ** pdevproto, + pdf14_device * ptempdevproto, gs_gstate * pgs, + const gs_pdf14trans_t * pdf14pct, bool use_pdf14_accum) +{ + bool using_blend_cs; + pdf14_default_colorspace_t dev_cs = + pdf14_determine_default_blend_cs(dev, use_pdf14_accum, + &using_blend_cs); + + switch (dev_cs) { + case PDF14_DeviceGray: + *pdevproto = (pdf14_device *)&gs_pdf14_Gray_device; + *ptempdevproto = **pdevproto; + ptempdevproto->color_info.max_components = 1; + ptempdevproto->color_info.num_components = + ptempdevproto->color_info.max_components; + ptempdevproto->color_info.max_gray = 255; + ptempdevproto->color_info.gray_index = 0; /* Avoid halftoning */ + ptempdevproto->color_info.dither_grays = 256; + ptempdevproto->sep_device = false; + *pdevproto = ptempdevproto; + break; + case PDF14_DeviceRGB: + *pdevproto = (pdf14_device *)&gs_pdf14_RGB_device; + *ptempdevproto = **pdevproto; + ptempdevproto->sep_device = false; + *pdevproto = ptempdevproto; + break; + case PDF14_DeviceCMYK: + *pdevproto = (pdf14_device *)&gs_pdf14_CMYK_device; + *ptempdevproto = **pdevproto; + ptempdevproto->sep_device = false; + *pdevproto = ptempdevproto; + break; + case PDF14_DeviceCMYKspot: + *pdevproto = (pdf14_device *)&gs_pdf14_CMYKspot_device; + /* Need to figure out how we want to handle the device profile + for this case */ + /* + * The number of components for the PDF14 device is the sum + * of the process components and the number of spot colors + * for the page. + */ + if (pdf14pct->params.num_spot_colors >= 0) { + *ptempdevproto = **pdevproto; + ptempdevproto->devn_params.page_spot_colors = + pdf14pct->params.num_spot_colors; + ptempdevproto->color_info.num_components = + ptempdevproto->devn_params.num_std_colorant_names + + pdf14pct->params.num_spot_colors; + if (ptempdevproto->color_info.num_components > + GS_CLIENT_COLOR_MAX_COMPONENTS) + ptempdevproto->color_info.num_components = + GS_CLIENT_COLOR_MAX_COMPONENTS; + ptempdevproto->color_info.depth = + ptempdevproto->color_info.num_components * 8; + ptempdevproto->sep_device = true; + *pdevproto = ptempdevproto; + } + break; + case PDF14_DeviceCustom: + /* + * We are using the output device's process color model. The + * color_info for the PDF 1.4 compositing device needs to match + * the output device. + */ + *ptempdevproto = gs_pdf14_custom_device; + ptempdevproto->color_info = dev->color_info; + /* The pdf14 device has to be 8 bit continuous tone. Force it */ + ptempdevproto->color_info.depth = + ptempdevproto->color_info.num_components * 8; + ptempdevproto->color_info.max_gray = 255; + ptempdevproto->color_info.max_color = 255; + ptempdevproto->color_info.dither_grays = 256; + ptempdevproto->color_info.dither_colors = 256; + + *pdevproto = ptempdevproto; + break; + default: /* Should not occur */ + return_error(gs_error_rangecheck); + } + ptempdevproto->using_blend_cs = using_blend_cs; + return 0; +} +","@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask); + static dev_proc_stroke_path(pdf14_stroke_path); + static dev_proc_begin_typed_image(pdf14_begin_typed_image); + static dev_proc_text_begin(pdf14_text_begin); ++static dev_proc_finish_copydevice(pdf14_finish_copydevice); + static dev_proc_create_compositor(pdf14_create_compositor); + static dev_proc_create_compositor(pdf14_forward_create_compositor); + static dev_proc_begin_transparency_group(pdf14_begin_transparency_group); +@@ -245,7 +246,7 @@ static const gx_color_map_procs * + pdf14_create_compositor, /* create_compositor */\ + NULL, /* get_hardware_params */\ + pdf14_text_begin, /* text_begin */\ +- NULL, /* finish_copydevice */\ ++ pdf14_finish_copydevice, /* finish_copydevice */\ + pdf14_begin_transparency_group,\ + pdf14_end_transparency_group,\ + pdf14_begin_transparency_mask,\ +@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs, + return code; + } + ++static int ++pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev) ++{ ++ pdf14_device *pdev = (pdf14_device*)new_dev; ++ ++ pdev->ctx = NULL; ++ pdev->trans_group_parent_cmap_procs = NULL; ++ pdev->smaskcolor = NULL; ++ ++ /* Only allow copying the prototype. */ ++ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0); ++} ++ + /* + * Implement copy_mono by filling lots of small rectangles. + */ +@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev, + before reopening the device */ + if (p14dev->ctx != NULL) { + pdf14_ctx_free(p14dev->ctx); ++ p14dev->ctx = NULL; + } + dev_proc(tdev, open_device) (tdev); + }",904,1140,2048 +14367,"png_push_process_row(png_structp png_ptr) +{ + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); + + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); + + if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) + png_do_read_transformations(png_ptr); + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Blow up interlaced rows to full size */ + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + { + if (png_ptr->pass < 6) +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); + + switch (png_ptr->pass) + { + case 0: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 0; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ + } + + if (png_ptr->pass == 2) /* Pass 1 might be empty */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + if (png_ptr->pass == 4 && png_ptr->height <= 4) + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + if (png_ptr->pass == 6 && png_ptr->height <= 4) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + case 1: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 1; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 2) /* Skip top 4 generated rows */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 2: + { + int i; + + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 4) /* Pass 3 might be empty */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 3: + { + int i; + + for (i = 0; i < 4 && png_ptr->pass == 3; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 4) /* Skip top two generated rows */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 4: + { + int i; + + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 6) /* Pass 5 might be empty */ + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + case 5: + { + int i; + + for (i = 0; i < 2 && png_ptr->pass == 5; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 6) /* Skip top generated row */ + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + case 6: + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + + if (png_ptr->pass != 6) + break; + + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + } + else +#endif + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } +} +",0,"png_push_process_row(png_structp png_ptr) +{ + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + + png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, + png_ptr->row_info.width); + + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); + + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); + + if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) + png_do_read_transformations(png_ptr); + +#ifdef PNG_READ_INTERLACING_SUPPORTED + /* Blow up interlaced rows to full size */ + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + { + if (png_ptr->pass < 6) +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); + + switch (png_ptr->pass) + { + case 0: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 0; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ + } + + if (png_ptr->pass == 2) /* Pass 1 might be empty */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + if (png_ptr->pass == 4 && png_ptr->height <= 4) + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + if (png_ptr->pass == 6 && png_ptr->height <= 4) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + case 1: + { + int i; + for (i = 0; i < 8 && png_ptr->pass == 1; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 2) /* Skip top 4 generated rows */ + { + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 2: + { + int i; + + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + for (i = 0; i < 4 && png_ptr->pass == 2; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 4) /* Pass 3 might be empty */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 3: + { + int i; + + for (i = 0; i < 4 && png_ptr->pass == 3; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 4) /* Skip top two generated rows */ + { + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + + break; + } + + case 4: + { + int i; + + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + for (i = 0; i < 2 && png_ptr->pass == 4; i++) + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 6) /* Pass 5 might be empty */ + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + + case 5: + { + int i; + + for (i = 0; i < 2 && png_ptr->pass == 5; i++) + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } + + if (png_ptr->pass == 6) /* Skip top generated row */ + { + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + + break; + } + case 6: + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + + if (png_ptr->pass != 6) + break; + + png_push_have_row(png_ptr, png_bytep_NULL); + png_read_push_finish_row(png_ptr); + } + } + } + else +#endif + { + png_push_have_row(png_ptr, png_ptr->row_buf + 1); + png_read_push_finish_row(png_ptr); + } +} +","@@ -685,9 +685,12 @@ png_push_save_buffer(png_structp png_ptr) + png_free(png_ptr, old_buffer); + png_error(png_ptr, ""Insufficient memory for save_buffer""); + } +- png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); +- png_free(png_ptr, old_buffer); +- png_ptr->save_buffer_max = new_max; ++ else ++ { ++ png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); ++ png_free(png_ptr, old_buffer); ++ png_ptr->save_buffer_max = new_max; ++ } + } + if (png_ptr->current_buffer_size) + {",1459,1695,2048 +7914,"static int cmd_handle_untagged(struct ImapData *idata) +{ + unsigned int count = 0; + char *s = imap_next_word(idata->buf); + char *pn = imap_next_word(s); + + if ((idata->state >= IMAP_SELECTED) && isdigit((unsigned char) *s)) + { + pn = s; + s = imap_next_word(s); + + /* EXISTS and EXPUNGE are always related to the SELECTED mailbox for the + * connection, so update that one. + */ + if (mutt_str_strncasecmp(""EXISTS"", s, 6) == 0) + { + mutt_debug(2, ""Handling EXISTS\n""); + + /* new mail arrived */ + if (mutt_str_atoui(pn, &count) < 0) + { + mutt_debug(1, ""Malformed EXISTS: '%s'\n"", pn); + } + + if (!(idata->reopen & IMAP_EXPUNGE_PENDING) && count < idata->max_msn) + { + /* Notes 6.0.3 has a tendency to report fewer messages exist than + * it should. */ + mutt_debug(1, ""Message count is out of sync\n""); + return 0; + } + /* at least the InterChange server sends EXISTS messages freely, + * even when there is no new mail */ + else if (count == idata->max_msn) + mutt_debug(3, ""superfluous EXISTS message.\n""); + else + { + if (!(idata->reopen & IMAP_EXPUNGE_PENDING)) + { + mutt_debug(2, ""New mail in %s - %d messages total.\n"", idata->mailbox, count); + idata->reopen |= IMAP_NEWMAIL_PENDING; + } + idata->new_mail_count = count; + } + } + /* pn vs. s: need initial seqno */ + else if (mutt_str_strncasecmp(""EXPUNGE"", s, 7) == 0) + cmd_parse_expunge(idata, pn); + else if (mutt_str_strncasecmp(""FETCH"", s, 5) == 0) + cmd_parse_fetch(idata, pn); + } + else if (mutt_str_strncasecmp(""CAPABILITY"", s, 10) == 0) + cmd_parse_capability(idata, s); + else if (mutt_str_strncasecmp(""OK [CAPABILITY"", s, 14) == 0) + cmd_parse_capability(idata, pn); + else if (mutt_str_strncasecmp(""OK [CAPABILITY"", pn, 14) == 0) + cmd_parse_capability(idata, imap_next_word(pn)); + else if (mutt_str_strncasecmp(""LIST"", s, 4) == 0) + cmd_parse_list(idata, s); + else if (mutt_str_strncasecmp(""LSUB"", s, 4) == 0) + cmd_parse_lsub(idata, s); + else if (mutt_str_strncasecmp(""MYRIGHTS"", s, 8) == 0) + cmd_parse_myrights(idata, s); + else if (mutt_str_strncasecmp(""SEARCH"", s, 6) == 0) + cmd_parse_search(idata, s); + else if (mutt_str_strncasecmp(""STATUS"", s, 6) == 0) + cmd_parse_status(idata, s); + else if (mutt_str_strncasecmp(""ENABLED"", s, 7) == 0) + cmd_parse_enabled(idata, s); + else if (mutt_str_strncasecmp(""BYE"", s, 3) == 0) + { + mutt_debug(2, ""Handling BYE\n""); + + /* check if we're logging out */ + if (idata->status == IMAP_BYE) + return 0; + + /* server shut down our connection */ + s += 3; + SKIPWS(s); + mutt_error(""%s"", s); + cmd_handle_fatal(idata); + + return -1; + } + else if (ImapServernoise && (mutt_str_strncasecmp(""NO"", s, 2) == 0)) + { + mutt_debug(2, ""Handling untagged NO\n""); + + /* Display the warning message from the server */ + mutt_error(""%s"", s + 3); + } + + return 0; +} +",0,"static int cmd_handle_untagged(struct ImapData *idata) +{ + unsigned int count = 0; + char *s = imap_next_word(idata->buf); + char *pn = imap_next_word(s); + + if ((idata->state >= IMAP_SELECTED) && isdigit((unsigned char) *s)) + { + pn = s; + s = imap_next_word(s); + + /* EXISTS and EXPUNGE are always related to the SELECTED mailbox for the + * connection, so update that one. + */ + if (mutt_str_strncasecmp(""EXISTS"", s, 6) == 0) + { + mutt_debug(2, ""Handling EXISTS\n""); + + /* new mail arrived */ + if (mutt_str_atoui(pn, &count) < 0) + { + mutt_debug(1, ""Malformed EXISTS: '%s'\n"", pn); + } + + if (!(idata->reopen & IMAP_EXPUNGE_PENDING) && count < idata->max_msn) + { + /* Notes 6.0.3 has a tendency to report fewer messages exist than + * it should. */ + mutt_debug(1, ""Message count is out of sync\n""); + return 0; + } + /* at least the InterChange server sends EXISTS messages freely, + * even when there is no new mail */ + else if (count == idata->max_msn) + mutt_debug(3, ""superfluous EXISTS message.\n""); + else + { + if (!(idata->reopen & IMAP_EXPUNGE_PENDING)) + { + mutt_debug(2, ""New mail in %s - %d messages total.\n"", idata->mailbox, count); + idata->reopen |= IMAP_NEWMAIL_PENDING; + } + idata->new_mail_count = count; + } + } + /* pn vs. s: need initial seqno */ + else if (mutt_str_strncasecmp(""EXPUNGE"", s, 7) == 0) + cmd_parse_expunge(idata, pn); + else if (mutt_str_strncasecmp(""FETCH"", s, 5) == 0) + cmd_parse_fetch(idata, pn); + } + else if (mutt_str_strncasecmp(""CAPABILITY"", s, 10) == 0) + cmd_parse_capability(idata, s); + else if (mutt_str_strncasecmp(""OK [CAPABILITY"", s, 14) == 0) + cmd_parse_capability(idata, pn); + else if (mutt_str_strncasecmp(""OK [CAPABILITY"", pn, 14) == 0) + cmd_parse_capability(idata, imap_next_word(pn)); + else if (mutt_str_strncasecmp(""LIST"", s, 4) == 0) + cmd_parse_list(idata, s); + else if (mutt_str_strncasecmp(""LSUB"", s, 4) == 0) + cmd_parse_lsub(idata, s); + else if (mutt_str_strncasecmp(""MYRIGHTS"", s, 8) == 0) + cmd_parse_myrights(idata, s); + else if (mutt_str_strncasecmp(""SEARCH"", s, 6) == 0) + cmd_parse_search(idata, s); + else if (mutt_str_strncasecmp(""STATUS"", s, 6) == 0) + cmd_parse_status(idata, s); + else if (mutt_str_strncasecmp(""ENABLED"", s, 7) == 0) + cmd_parse_enabled(idata, s); + else if (mutt_str_strncasecmp(""BYE"", s, 3) == 0) + { + mutt_debug(2, ""Handling BYE\n""); + + /* check if we're logging out */ + if (idata->status == IMAP_BYE) + return 0; + + /* server shut down our connection */ + s += 3; + SKIPWS(s); + mutt_error(""%s"", s); + cmd_handle_fatal(idata); + + return -1; + } + else if (ImapServernoise && (mutt_str_strncasecmp(""NO"", s, 2) == 0)) + { + mutt_debug(2, ""Handling untagged NO\n""); + + /* Display the warning message from the server */ + mutt_error(""%s"", s + 3); + } + + return 0; +} +","@@ -499,7 +499,7 @@ static void cmd_parse_lsub(struct ImapData *idata, char *s) + mutt_str_strfcpy(buf, ""mailboxes \"""", sizeof(buf)); + mutt_account_tourl(&idata->conn->account, &url); + /* escape \ and "" */ +- imap_quote_string(errstr, sizeof(errstr), list.name); ++ imap_quote_string(errstr, sizeof(errstr), list.name, true); + url.path = errstr + 1; + url.path[strlen(url.path) - 1] = '\0'; + if (mutt_str_strcmp(url.user, ImapUser) == 0)",970,1206,2048 +720," pcf_read_TOC( FT_Stream stream, + PCF_Face face ) + { + FT_Error error; + PCF_Toc toc = &face->toc; + PCF_Table tables; + + FT_Memory memory = FT_FACE( face )->memory; + FT_UInt n; + + + if ( FT_STREAM_SEEK ( 0 ) || + FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) ) + return FT_THROW( Cannot_Open_Resource ); + + if ( toc->version != PCF_FILE_VERSION || + toc->count > FT_ARRAY_MAX( face->toc.tables ) || + toc->count == 0 ) + return FT_THROW( Invalid_File_Format ); + + if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) ) + return FT_THROW( Out_Of_Memory ); + + tables = face->toc.tables; + for ( n = 0; n < toc->count; n++ ) + { + if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) ) + goto Exit; + tables++; + } + + /* Sort tables and check for overlaps. Because they are almost */ + /* always ordered already, an in-place bubble sort with simultaneous */ + /* boundary checking seems appropriate. */ + tables = face->toc.tables; + + for ( n = 0; n < toc->count - 1; n++ ) + { + FT_UInt i, have_change; + + + have_change = 0; + + for ( i = 0; i < toc->count - 1 - n; i++ ) + { + PCF_TableRec tmp; + + + if ( tables[i].offset > tables[i + 1].offset ) + { + tmp = tables[i]; + tables[i] = tables[i + 1]; + tables[i + 1] = tmp; + + have_change = 1; + } + + if ( ( tables[i].size > tables[i + 1].offset ) || + ( tables[i].offset > tables[i + 1].offset - tables[i].size ) ) + { + error = FT_THROW( Invalid_Offset ); + goto Exit; + } + } + + if ( !have_change ) + break; + } + + /* we now check whether the `size' and `offset' values are reasonable: */ + /* `offset' + `size' must not exceed the stream size */ + tables = face->toc.tables; + for ( n = 0; n < toc->count; n++ ) + { + /* we need two checks to avoid overflow */ + if ( ( tables->size > stream->size ) || + ( tables->offset > stream->size - tables->size ) ) + { + error = FT_THROW( Invalid_Table ); + goto Exit; + } + tables++; + } + +#ifdef FT_DEBUG_LEVEL_TRACE + + { + FT_UInt i, j; + const char* name = ""?""; + + + FT_TRACE4(( ""pcf_read_TOC:\n"" )); + + FT_TRACE4(( "" number of tables: %ld\n"", face->toc.count )); + + tables = face->toc.tables; + for ( i = 0; i < toc->count; i++ ) + { + for ( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] ); + j++ ) + if ( tables[i].type == (FT_UInt)( 1 << j ) ) + name = tableNames[j]; + + FT_TRACE4(( "" %d: type=%s, format=0x%X, "" + ""size=%ld (0x%lX), offset=%ld (0x%lX)\n"", + i, name, + tables[i].format, + tables[i].size, tables[i].size, + tables[i].offset, tables[i].offset )); + } + } + +#endif + + return FT_Err_Ok; + + Exit: + FT_FREE( face->toc.tables ); + return error; + } +",0," pcf_read_TOC( FT_Stream stream, + PCF_Face face ) + { + FT_Error error; + PCF_Toc toc = &face->toc; + PCF_Table tables; + + FT_Memory memory = FT_FACE( face )->memory; + FT_UInt n; + + + if ( FT_STREAM_SEEK ( 0 ) || + FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) ) + return FT_THROW( Cannot_Open_Resource ); + + if ( toc->version != PCF_FILE_VERSION || + toc->count > FT_ARRAY_MAX( face->toc.tables ) || + toc->count == 0 ) + return FT_THROW( Invalid_File_Format ); + + if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) ) + return FT_THROW( Out_Of_Memory ); + + tables = face->toc.tables; + for ( n = 0; n < toc->count; n++ ) + { + if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) ) + goto Exit; + tables++; + } + + /* Sort tables and check for overlaps. Because they are almost */ + /* always ordered already, an in-place bubble sort with simultaneous */ + /* boundary checking seems appropriate. */ + tables = face->toc.tables; + + for ( n = 0; n < toc->count - 1; n++ ) + { + FT_UInt i, have_change; + + + have_change = 0; + + for ( i = 0; i < toc->count - 1 - n; i++ ) + { + PCF_TableRec tmp; + + + if ( tables[i].offset > tables[i + 1].offset ) + { + tmp = tables[i]; + tables[i] = tables[i + 1]; + tables[i + 1] = tmp; + + have_change = 1; + } + + if ( ( tables[i].size > tables[i + 1].offset ) || + ( tables[i].offset > tables[i + 1].offset - tables[i].size ) ) + { + error = FT_THROW( Invalid_Offset ); + goto Exit; + } + } + + if ( !have_change ) + break; + } + + /* we now check whether the `size' and `offset' values are reasonable: */ + /* `offset' + `size' must not exceed the stream size */ + tables = face->toc.tables; + for ( n = 0; n < toc->count; n++ ) + { + /* we need two checks to avoid overflow */ + if ( ( tables->size > stream->size ) || + ( tables->offset > stream->size - tables->size ) ) + { + error = FT_THROW( Invalid_Table ); + goto Exit; + } + tables++; + } + +#ifdef FT_DEBUG_LEVEL_TRACE + + { + FT_UInt i, j; + const char* name = ""?""; + + + FT_TRACE4(( ""pcf_read_TOC:\n"" )); + + FT_TRACE4(( "" number of tables: %ld\n"", face->toc.count )); + + tables = face->toc.tables; + for ( i = 0; i < toc->count; i++ ) + { + for ( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] ); + j++ ) + if ( tables[i].type == (FT_UInt)( 1 << j ) ) + name = tableNames[j]; + + FT_TRACE4(( "" %d: type=%s, format=0x%X, "" + ""size=%ld (0x%lX), offset=%ld (0x%lX)\n"", + i, name, + tables[i].format, + tables[i].size, tables[i].size, + tables[i].offset, tables[i].offset )); + } + } + +#endif + + return FT_Err_Ok; + + Exit: + FT_FREE( face->toc.tables ); + return error; + } +","@@ -830,6 +830,15 @@ THE SOFTWARE. + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) + return FT_THROW( Invalid_File_Format ); + ++ /* sanity checks */ ++ if ( firstCol < 0 || ++ firstCol > lastCol || ++ lastCol > 0xFF || ++ firstRow < 0 || ++ firstRow > lastRow || ++ lastRow > 0xFF ) ++ return FT_THROW( Invalid_Table ); ++ + FT_TRACE4(( ""pdf_get_encodings:\n"" )); + + FT_TRACE4(( "" firstCol %d, lastCol %d, firstRow %d, lastRow %d\n"",",855,1091,2048 +17948,"file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf, + size_t nbytes) +{ + cdf_info_t info; + cdf_header_t h; + cdf_sat_t sat, ssat; + cdf_stream_t sst, scn; + cdf_dir_t dir; + int i; + const char *expn = """"; + const char *corrupt = ""corrupt: ""; + + info.i_fd = fd; + info.i_buf = buf; + info.i_len = nbytes; + if (ms->flags & MAGIC_APPLE) + return 0; + if (cdf_read_header(&info, &h) == -1) + return 0; +#ifdef CDF_DEBUG + cdf_dump_header(&h); +#endif + + if ((i = cdf_read_sat(&info, &h, &sat)) == -1) { + expn = ""Can't read SAT""; + goto out0; + } +#ifdef CDF_DEBUG + cdf_dump_sat(""SAT"", &sat, CDF_SEC_SIZE(&h)); +#endif + + if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) { + expn = ""Can't read SSAT""; + goto out1; + } +#ifdef CDF_DEBUG + cdf_dump_sat(""SSAT"", &ssat, CDF_SHORT_SEC_SIZE(&h)); +#endif + + if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) { + expn = ""Can't read directory""; + goto out2; + } + + const cdf_directory_t *root_storage; + if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst, + &root_storage)) == -1) { + expn = ""Cannot read short stream""; + goto out3; + } +#ifdef CDF_DEBUG + cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir); +#endif +#ifdef notdef + if (root_storage) { + if (NOTMIME(ms)) { + char clsbuf[128]; + if (file_printf(ms, ""CLSID %s, "", + format_clsid(clsbuf, sizeof(clsbuf), + root_storage->d_storage_uuid)) == -1) + return -1; + } + } +#endif + + if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir, + &scn)) == -1) { + if (errno == ESRCH) { + corrupt = expn; + expn = ""No summary info""; + } else { + expn = ""Cannot read summary info""; + } + goto out4; + } + #ifdef CDF_DEBUG + cdf_dump_summary_info(&h, &scn); + #endif + if ((i = cdf_file_summary_info(ms, &h, &scn, + root_storage->d_storage_uuid)) < 0) + expn = ""Can't expand summary_info""; + + if (i == 0) { + const char *str = NULL; + cdf_directory_t *d; + char name[__arraycount(d->d_name)]; + size_t j, k; + + for (j = 0; str == NULL && j < dir.dir_len; j++) { + d = &dir.dir_tab[j]; + for (k = 0; k < sizeof(name); k++) + name[k] = (char)cdf_tole2(d->d_name[k]); + str = cdf_app_to_mime(name, + NOTMIME(ms) ? name2desc : name2mime); + } + if (NOTMIME(ms)) { + if (str != NULL) { + if (file_printf(ms, ""%s"", str) == -1) + return -1; + i = 1; + } + } else { + if (str == NULL) + str = ""vnd.ms-office""; + if (file_printf(ms, ""application/%s"", str) == -1) + return -1; + i = 1; + } + } + free(scn.sst_tab); +out4: + free(sst.sst_tab); +out3: + free(dir.dir_tab); +out2: + free(ssat.sat_tab); +out1: + free(sat.sat_tab); +out0: + if (i == -1) { + if (NOTMIME(ms)) { + if (file_printf(ms, + ""Composite Document File V2 Document"") == -1) + return -1; + if (*expn) + if (file_printf(ms, "", %s%s"", corrupt, expn) == -1) + return -1; + } else { + if (file_printf(ms, ""application/CDFV2-corrupt"") == -1) + return -1; + } + i = 1; + } + return i; +} +",1,"file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf, + size_t nbytes) +{ + cdf_info_t info; + cdf_header_t h; + cdf_sat_t sat, ssat; + cdf_stream_t sst, scn; + cdf_dir_t dir; + int i; + const char *expn = """"; + const char *corrupt = ""corrupt: ""; + + info.i_fd = fd; + info.i_buf = buf; + info.i_len = nbytes; + if (ms->flags & MAGIC_APPLE) + return 0; + if (cdf_read_header(&info, &h) == -1) + return 0; +#ifdef CDF_DEBUG + cdf_dump_header(&h); +#endif + + if ((i = cdf_read_sat(&info, &h, &sat)) == -1) { + expn = ""Can't read SAT""; + goto out0; + } +#ifdef CDF_DEBUG + cdf_dump_sat(""SAT"", &sat, CDF_SEC_SIZE(&h)); +#endif + + if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) { + expn = ""Can't read SSAT""; + goto out1; + } +#ifdef CDF_DEBUG + cdf_dump_sat(""SSAT"", &ssat, CDF_SHORT_SEC_SIZE(&h)); +#endif + + if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) { + expn = ""Can't read directory""; + goto out2; + } + + const cdf_directory_t *root_storage; + if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst, + &root_storage)) == -1) { + expn = ""Cannot read short stream""; + goto out3; + } +#ifdef CDF_DEBUG + cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir); +#endif +#ifdef notdef + if (root_storage) { + if (NOTMIME(ms)) { + char clsbuf[128]; + if (file_printf(ms, ""CLSID %s, "", + format_clsid(clsbuf, sizeof(clsbuf), + root_storage->d_storage_uuid)) == -1) + return -1; + } + } +#endif + + if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir, + &scn)) == -1) { + if (errno == ESRCH) { + corrupt = expn; + expn = ""No summary info""; + } else { + expn = ""Cannot read summary info""; + } + goto out4; + } + #ifdef CDF_DEBUG + cdf_dump_summary_info(&h, &scn); + #endif + if ((i = cdf_file_summary_info(ms, &h, &scn, root_storage)) < 0) + expn = ""Can't expand summary_info""; + + if (i == 0) { + const char *str = NULL; + cdf_directory_t *d; + char name[__arraycount(d->d_name)]; + size_t j, k; + + for (j = 0; str == NULL && j < dir.dir_len; j++) { + d = &dir.dir_tab[j]; + for (k = 0; k < sizeof(name); k++) + name[k] = (char)cdf_tole2(d->d_name[k]); + str = cdf_app_to_mime(name, + NOTMIME(ms) ? name2desc : name2mime); + } + if (NOTMIME(ms)) { + if (str != NULL) { + if (file_printf(ms, ""%s"", str) == -1) + return -1; + i = 1; + } + } else { + if (str == NULL) + str = ""vnd.ms-office""; + if (file_printf(ms, ""application/%s"", str) == -1) + return -1; + i = 1; + } + } + free(scn.sst_tab); +out4: + free(sst.sst_tab); +out3: + free(dir.dir_tab); +out2: + free(ssat.sat_tab); +out1: + free(sat.sat_tab); +out0: + if (i == -1) { + if (NOTMIME(ms)) { + if (file_printf(ms, + ""Composite Document File V2 Document"") == -1) + return -1; + if (*expn) + if (file_printf(ms, "", %s%s"", corrupt, expn) == -1) + return -1; + } else { + if (file_printf(ms, ""application/CDFV2-corrupt"") == -1) + return -1; + } + i = 1; + } + return i; +} +","@@ -26,7 +26,7 @@ + #include ""file.h"" + + #ifndef lint +-FILE_RCSID(""@(#)$File: readcdf.c,v 1.39 2014/02/27 23:26:18 christos Exp $"") ++FILE_RCSID(""@(#)$File: readcdf.c,v 1.40 2014/03/06 15:23:33 christos Exp $"") + #endif + + #include +@@ -120,7 +120,7 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv) + + private int + cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, +- size_t count, const uint64_t clsid[2]) ++ size_t count, const cdf_directory_t *root_storage) + { + size_t i; + cdf_timestamp_t tp; +@@ -130,8 +130,8 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, + const char *s; + int len; + +- if (!NOTMIME(ms)) +- str = cdf_clsid_to_mime(clsid, clsid2mime); ++ if (!NOTMIME(ms) && root_storage) ++ str = cdf_clsid_to_mime(root_storage->d_storage_uuid, clsid2mime); + + for (i = 0; i < count; i++) { + cdf_print_property_name(buf, sizeof(buf), info[i].pi_id); +@@ -236,7 +236,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, + + private int + cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h, +- const cdf_stream_t *sst, const uint64_t clsid[2]) ++ const cdf_stream_t *sst, const cdf_directory_t *root_storage) + { + cdf_summary_info_header_t si; + cdf_property_info_t *info; +@@ -276,13 +276,15 @@ cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h, + return -2; + break; + } +- str = cdf_clsid_to_mime(clsid, clsid2desc); +- if (str) +- if (file_printf(ms, "", %s"", str) == -1) +- return -2; +- } ++ if (root_storage) { ++ str = cdf_clsid_to_mime(root_storage->d_storage_uuid, clsid2desc); ++ if (str) ++ if (file_printf(ms, "", %s"", str) == -1) ++ return -2; ++ } ++ } + +- m = cdf_file_property_info(ms, info, count, clsid); ++ m = cdf_file_property_info(ms, info, count, root_storage); + free(info); + + return m == -1 ? -2 : m; +@@ -381,9 +383,8 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf, + #ifdef CDF_DEBUG + cdf_dump_summary_info(&h, &scn); + #endif +- if ((i = cdf_file_summary_info(ms, &h, &scn, +- root_storage->d_storage_uuid)) < 0) +- expn = ""Can't expand summary_info""; ++ if ((i = cdf_file_summary_info(ms, &h, &scn, root_storage)) < 0) ++ expn = ""Can't expand summary_info""; + + if (i == 0) { + const char *str = NULL;",1071,1307,2048 +428,"void DCTStream::readScan() { + int data[64]; + int x1, y1, dx1, dy1, x2, y2, y3, cc, i; + int h, v, horiz, vert, vSub; + int *p1; + int c; + + if (scanInfo.numComps == 1) { + for (cc = 0; cc < numComps; ++cc) { + if (scanInfo.comp[cc]) { + break; + } + } + dx1 = mcuWidth / compInfo[cc].hSample; + dy1 = mcuHeight / compInfo[cc].vSample; + } else { + dx1 = mcuWidth; + dy1 = mcuHeight; + } + + for (y1 = 0; y1 < height; y1 += dy1) { + for (x1 = 0; x1 < width; x1 += dx1) { + + if (restartInterval > 0 && restartCtr == 0) { + c = readMarker(); + if (c != restartMarker) { + error(errSyntaxError, getPos(), + ""Bad DCT data: incorrect restart marker""); + return; + } + if (++restartMarker == 0xd8) { + restartMarker = 0xd0; + } + restart(); + } + + for (cc = 0; cc < numComps; ++cc) { + if (!scanInfo.comp[cc]) { + continue; + } + + h = compInfo[cc].hSample; + v = compInfo[cc].vSample; + horiz = mcuWidth / h; + vert = mcuHeight / v; + vSub = vert / 8; + for (y2 = 0; y2 < dy1; y2 += vert) { + for (x2 = 0; x2 < dx1; x2 += horiz) { + + p1 = &frameBuf[cc][(y1+y2) * bufWidth + (x1+x2)]; + for (y3 = 0, i = 0; y3 < 8; ++y3, i += 8) { + data[i] = p1[0]; + data[i+1] = p1[1]; + data[i+2] = p1[2]; + data[i+3] = p1[3]; + data[i+4] = p1[4]; + data[i+5] = p1[5]; + data[i+6] = p1[6]; + data[i+7] = p1[7]; + p1 += bufWidth * vSub; + } + + if (progressive) { + if (!readProgressiveDataUnit( + &dcHuffTables[scanInfo.dcHuffTable[cc]], + &acHuffTables[scanInfo.acHuffTable[cc]], + &compInfo[cc].prevDC, + data)) { + return; + } + } else { + if (!readDataUnit(&dcHuffTables[scanInfo.dcHuffTable[cc]], + &acHuffTables[scanInfo.acHuffTable[cc]], + &compInfo[cc].prevDC, + data)) { + return; + } + } + + p1 = &frameBuf[cc][(y1+y2) * bufWidth + (x1+x2)]; + for (y3 = 0, i = 0; y3 < 8; ++y3, i += 8) { + p1[0] = data[i]; + p1[1] = data[i+1]; + p1[2] = data[i+2]; + p1[3] = data[i+3]; + p1[4] = data[i+4]; + p1[5] = data[i+5]; + p1[6] = data[i+6]; + p1[7] = data[i+7]; + p1 += bufWidth * vSub; + } + } + } + } + --restartCtr; + } + } +} +",0,"void DCTStream::readScan() { + int data[64]; + int x1, y1, dx1, dy1, x2, y2, y3, cc, i; + int h, v, horiz, vert, vSub; + int *p1; + int c; + + if (scanInfo.numComps == 1) { + for (cc = 0; cc < numComps; ++cc) { + if (scanInfo.comp[cc]) { + break; + } + } + dx1 = mcuWidth / compInfo[cc].hSample; + dy1 = mcuHeight / compInfo[cc].vSample; + } else { + dx1 = mcuWidth; + dy1 = mcuHeight; + } + + for (y1 = 0; y1 < height; y1 += dy1) { + for (x1 = 0; x1 < width; x1 += dx1) { + + if (restartInterval > 0 && restartCtr == 0) { + c = readMarker(); + if (c != restartMarker) { + error(errSyntaxError, getPos(), + ""Bad DCT data: incorrect restart marker""); + return; + } + if (++restartMarker == 0xd8) { + restartMarker = 0xd0; + } + restart(); + } + + for (cc = 0; cc < numComps; ++cc) { + if (!scanInfo.comp[cc]) { + continue; + } + + h = compInfo[cc].hSample; + v = compInfo[cc].vSample; + horiz = mcuWidth / h; + vert = mcuHeight / v; + vSub = vert / 8; + for (y2 = 0; y2 < dy1; y2 += vert) { + for (x2 = 0; x2 < dx1; x2 += horiz) { + + p1 = &frameBuf[cc][(y1+y2) * bufWidth + (x1+x2)]; + for (y3 = 0, i = 0; y3 < 8; ++y3, i += 8) { + data[i] = p1[0]; + data[i+1] = p1[1]; + data[i+2] = p1[2]; + data[i+3] = p1[3]; + data[i+4] = p1[4]; + data[i+5] = p1[5]; + data[i+6] = p1[6]; + data[i+7] = p1[7]; + p1 += bufWidth * vSub; + } + + if (progressive) { + if (!readProgressiveDataUnit( + &dcHuffTables[scanInfo.dcHuffTable[cc]], + &acHuffTables[scanInfo.acHuffTable[cc]], + &compInfo[cc].prevDC, + data)) { + return; + } + } else { + if (!readDataUnit(&dcHuffTables[scanInfo.dcHuffTable[cc]], + &acHuffTables[scanInfo.acHuffTable[cc]], + &compInfo[cc].prevDC, + data)) { + return; + } + } + + p1 = &frameBuf[cc][(y1+y2) * bufWidth + (x1+x2)]; + for (y3 = 0, i = 0; y3 < 8; ++y3, i += 8) { + p1[0] = data[i]; + p1[1] = data[i+1]; + p1[2] = data[i+2]; + p1[3] = data[i+3]; + p1[4] = data[i+4]; + p1[5] = data[i+5]; + p1[6] = data[i+6]; + p1[7] = data[i+7]; + p1 += bufWidth * vSub; + } + } + } + } + --restartCtr; + } + } +} +","@@ -14,7 +14,7 @@ + // under GPL version 2 or later + // + // Copyright (C) 2005 Jeff Muizelaar +-// Copyright (C) 2006-2010, 2012 Albert Astals Cid ++// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid + // Copyright (C) 2007 Krzysztof Kowalczyk + // Copyright (C) 2008 Julien Rebetez + // Copyright (C) 2009 Carlos Garcia Campos +@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() { + for (i = 0; i < columns && codingLine[i] < columns; ++i) { + refLine[i] = codingLine[i]; + } +- refLine[i++] = columns; +- refLine[i] = columns; ++ for (; i < columns + 2; ++i) { ++ refLine[i] = columns; ++ } + codingLine[0] = 0; + a0i = 0; + b1i = 0;",882,1118,2048 +825,"static void do_key_event(VncState *vs, int down, int keycode, int sym) +{ + /* QEMU console switch */ + switch(keycode) { + case 0x2a: /* Left Shift */ + case 0x36: /* Right Shift */ + case 0x1d: /* Left CTRL */ + case 0x9d: /* Right CTRL */ + case 0x38: /* Left ALT */ + case 0xb8: /* Right ALT */ + if (down) + vs->modifiers_state[keycode] = 1; + else + vs->modifiers_state[keycode] = 0; + break; + case 0x02 ... 0x0a: /* '1' to '9' keys */ + if (down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) { + /* Reset the modifiers sent to the current console */ + reset_keys(vs); + console_select(keycode - 0x02); + return; + } + break; + case 0x3a: /* CapsLock */ + case 0x45: /* NumLock */ + if (down) + vs->modifiers_state[keycode] ^= 1; + break; + } + + /* Turn off the lock state sync logic if the client support the led + state extension. + */ + if (down && vs->vd->lock_key_sync && + !vnc_has_feature(vs, VNC_FEATURE_LED_STATE) && + keycode_is_keypad(vs->vd->kbd_layout, keycode)) { + /* If the numlock state needs to change then simulate an additional + keypress before sending this one. This will happen if the user + toggles numlock away from the VNC window. + */ + if (keysym_is_numlock(vs->vd->kbd_layout, sym & 0xFFFF)) { + if (!vs->modifiers_state[0x45]) { + trace_vnc_key_sync_numlock(true); + vs->modifiers_state[0x45] = 1; + press_key(vs, 0xff7f); + } + } else { + if (vs->modifiers_state[0x45]) { + trace_vnc_key_sync_numlock(false); + vs->modifiers_state[0x45] = 0; + press_key(vs, 0xff7f); + } + } + } + + if (down && vs->vd->lock_key_sync && + !vnc_has_feature(vs, VNC_FEATURE_LED_STATE) && + ((sym >= 'A' && sym <= 'Z') || (sym >= 'a' && sym <= 'z'))) { + /* If the capslock state needs to change then simulate an additional + keypress before sending this one. This will happen if the user + toggles capslock away from the VNC window. + */ + int uppercase = !!(sym >= 'A' && sym <= 'Z'); + int shift = !!(vs->modifiers_state[0x2a] | vs->modifiers_state[0x36]); + int capslock = !!(vs->modifiers_state[0x3a]); + if (capslock) { + if (uppercase == shift) { + trace_vnc_key_sync_capslock(false); + vs->modifiers_state[0x3a] = 0; + press_key(vs, 0xffe5); + } + } else { + if (uppercase != shift) { + trace_vnc_key_sync_capslock(true); + vs->modifiers_state[0x3a] = 1; + press_key(vs, 0xffe5); + } + } + } + + if (qemu_console_is_graphic(NULL)) { + qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down); + } else { + bool numlock = vs->modifiers_state[0x45]; + bool control = (vs->modifiers_state[0x1d] || + vs->modifiers_state[0x9d]); + /* QEMU console emulation */ + if (down) { + switch (keycode) { + case 0x2a: /* Left Shift */ + case 0x36: /* Right Shift */ + case 0x1d: /* Left CTRL */ + case 0x9d: /* Right CTRL */ + case 0x38: /* Left ALT */ + case 0xb8: /* Right ALT */ + break; + case 0xc8: + kbd_put_keysym(QEMU_KEY_UP); + break; + case 0xd0: + kbd_put_keysym(QEMU_KEY_DOWN); + break; + case 0xcb: + kbd_put_keysym(QEMU_KEY_LEFT); + break; + case 0xcd: + kbd_put_keysym(QEMU_KEY_RIGHT); + break; + case 0xd3: + kbd_put_keysym(QEMU_KEY_DELETE); + break; + case 0xc7: + kbd_put_keysym(QEMU_KEY_HOME); + break; + case 0xcf: + kbd_put_keysym(QEMU_KEY_END); + break; + case 0xc9: + kbd_put_keysym(QEMU_KEY_PAGEUP); + break; + case 0xd1: + kbd_put_keysym(QEMU_KEY_PAGEDOWN); + break; + + case 0x47: + kbd_put_keysym(numlock ? '7' : QEMU_KEY_HOME); + break; + case 0x48: + kbd_put_keysym(numlock ? '8' : QEMU_KEY_UP); + break; + case 0x49: + kbd_put_keysym(numlock ? '9' : QEMU_KEY_PAGEUP); + break; + case 0x4b: + kbd_put_keysym(numlock ? '4' : QEMU_KEY_LEFT); + break; + case 0x4c: + kbd_put_keysym('5'); + break; + case 0x4d: + kbd_put_keysym(numlock ? '6' : QEMU_KEY_RIGHT); + break; + case 0x4f: + kbd_put_keysym(numlock ? '1' : QEMU_KEY_END); + break; + case 0x50: + kbd_put_keysym(numlock ? '2' : QEMU_KEY_DOWN); + break; + case 0x51: + kbd_put_keysym(numlock ? '3' : QEMU_KEY_PAGEDOWN); + break; + case 0x52: + kbd_put_keysym('0'); + break; + case 0x53: + kbd_put_keysym(numlock ? '.' : QEMU_KEY_DELETE); + break; + + case 0xb5: + kbd_put_keysym('/'); + break; + case 0x37: + kbd_put_keysym('*'); + break; + case 0x4a: + kbd_put_keysym('-'); + break; + case 0x4e: + kbd_put_keysym('+'); + break; + case 0x9c: + kbd_put_keysym('\n'); + break; + + default: + if (control) { + kbd_put_keysym(sym & 0x1f); + } else { + kbd_put_keysym(sym); + } + break; + } + } + } +} +",0,"static void do_key_event(VncState *vs, int down, int keycode, int sym) +{ + /* QEMU console switch */ + switch(keycode) { + case 0x2a: /* Left Shift */ + case 0x36: /* Right Shift */ + case 0x1d: /* Left CTRL */ + case 0x9d: /* Right CTRL */ + case 0x38: /* Left ALT */ + case 0xb8: /* Right ALT */ + if (down) + vs->modifiers_state[keycode] = 1; + else + vs->modifiers_state[keycode] = 0; + break; + case 0x02 ... 0x0a: /* '1' to '9' keys */ + if (down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) { + /* Reset the modifiers sent to the current console */ + reset_keys(vs); + console_select(keycode - 0x02); + return; + } + break; + case 0x3a: /* CapsLock */ + case 0x45: /* NumLock */ + if (down) + vs->modifiers_state[keycode] ^= 1; + break; + } + + /* Turn off the lock state sync logic if the client support the led + state extension. + */ + if (down && vs->vd->lock_key_sync && + !vnc_has_feature(vs, VNC_FEATURE_LED_STATE) && + keycode_is_keypad(vs->vd->kbd_layout, keycode)) { + /* If the numlock state needs to change then simulate an additional + keypress before sending this one. This will happen if the user + toggles numlock away from the VNC window. + */ + if (keysym_is_numlock(vs->vd->kbd_layout, sym & 0xFFFF)) { + if (!vs->modifiers_state[0x45]) { + trace_vnc_key_sync_numlock(true); + vs->modifiers_state[0x45] = 1; + press_key(vs, 0xff7f); + } + } else { + if (vs->modifiers_state[0x45]) { + trace_vnc_key_sync_numlock(false); + vs->modifiers_state[0x45] = 0; + press_key(vs, 0xff7f); + } + } + } + + if (down && vs->vd->lock_key_sync && + !vnc_has_feature(vs, VNC_FEATURE_LED_STATE) && + ((sym >= 'A' && sym <= 'Z') || (sym >= 'a' && sym <= 'z'))) { + /* If the capslock state needs to change then simulate an additional + keypress before sending this one. This will happen if the user + toggles capslock away from the VNC window. + */ + int uppercase = !!(sym >= 'A' && sym <= 'Z'); + int shift = !!(vs->modifiers_state[0x2a] | vs->modifiers_state[0x36]); + int capslock = !!(vs->modifiers_state[0x3a]); + if (capslock) { + if (uppercase == shift) { + trace_vnc_key_sync_capslock(false); + vs->modifiers_state[0x3a] = 0; + press_key(vs, 0xffe5); + } + } else { + if (uppercase != shift) { + trace_vnc_key_sync_capslock(true); + vs->modifiers_state[0x3a] = 1; + press_key(vs, 0xffe5); + } + } + } + + if (qemu_console_is_graphic(NULL)) { + qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down); + } else { + bool numlock = vs->modifiers_state[0x45]; + bool control = (vs->modifiers_state[0x1d] || + vs->modifiers_state[0x9d]); + /* QEMU console emulation */ + if (down) { + switch (keycode) { + case 0x2a: /* Left Shift */ + case 0x36: /* Right Shift */ + case 0x1d: /* Left CTRL */ + case 0x9d: /* Right CTRL */ + case 0x38: /* Left ALT */ + case 0xb8: /* Right ALT */ + break; + case 0xc8: + kbd_put_keysym(QEMU_KEY_UP); + break; + case 0xd0: + kbd_put_keysym(QEMU_KEY_DOWN); + break; + case 0xcb: + kbd_put_keysym(QEMU_KEY_LEFT); + break; + case 0xcd: + kbd_put_keysym(QEMU_KEY_RIGHT); + break; + case 0xd3: + kbd_put_keysym(QEMU_KEY_DELETE); + break; + case 0xc7: + kbd_put_keysym(QEMU_KEY_HOME); + break; + case 0xcf: + kbd_put_keysym(QEMU_KEY_END); + break; + case 0xc9: + kbd_put_keysym(QEMU_KEY_PAGEUP); + break; + case 0xd1: + kbd_put_keysym(QEMU_KEY_PAGEDOWN); + break; + + case 0x47: + kbd_put_keysym(numlock ? '7' : QEMU_KEY_HOME); + break; + case 0x48: + kbd_put_keysym(numlock ? '8' : QEMU_KEY_UP); + break; + case 0x49: + kbd_put_keysym(numlock ? '9' : QEMU_KEY_PAGEUP); + break; + case 0x4b: + kbd_put_keysym(numlock ? '4' : QEMU_KEY_LEFT); + break; + case 0x4c: + kbd_put_keysym('5'); + break; + case 0x4d: + kbd_put_keysym(numlock ? '6' : QEMU_KEY_RIGHT); + break; + case 0x4f: + kbd_put_keysym(numlock ? '1' : QEMU_KEY_END); + break; + case 0x50: + kbd_put_keysym(numlock ? '2' : QEMU_KEY_DOWN); + break; + case 0x51: + kbd_put_keysym(numlock ? '3' : QEMU_KEY_PAGEDOWN); + break; + case 0x52: + kbd_put_keysym('0'); + break; + case 0x53: + kbd_put_keysym(numlock ? '.' : QEMU_KEY_DELETE); + break; + + case 0xb5: + kbd_put_keysym('/'); + break; + case 0x37: + kbd_put_keysym('*'); + break; + case 0x4a: + kbd_put_keysym('-'); + break; + case 0x4e: + kbd_put_keysym('+'); + break; + case 0x9c: + kbd_put_keysym('\n'); + break; + + default: + if (control) { + kbd_put_keysym(sym & 0x1f); + } else { + kbd_put_keysym(sym); + } + break; + } + } + } +} +","@@ -2026,6 +2026,16 @@ static void set_pixel_format(VncState *vs, + return; + } + ++ switch (bits_per_pixel) { ++ case 8: ++ case 16: ++ case 32: ++ break; ++ default: ++ vnc_client_error(vs); ++ return; ++ } ++ + vs->client_pf.rmax = red_max; + vs->client_pf.rbits = hweight_long(red_max); + vs->client_pf.rshift = red_shift;",1602,1838,2048 +432,"SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc, + int xDest, int yDest, int w, int h) { + SplashColorPtr p, sp; + Guchar *q; + int x, y, mask, srcMask; + + if (src->mode != bitmap->mode) { + return splashErrModeMismatch; + } + + switch (bitmap->mode) { + case splashModeMono1: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + (xDest >> 3)]; + mask = 0x80 >> (xDest & 7); + sp = &src->data[(ySrc + y) * src->rowSize + (xSrc >> 3)]; + srcMask = 0x80 >> (xSrc & 7); + for (x = 0; x < w; ++x) { + if (*sp & srcMask) { + *p |= mask; + } else { + *p &= ~mask; + } + if (!(mask >>= 1)) { + mask = 0x80; + ++p; + } + if (!(srcMask >>= 1)) { + srcMask = 0x80; + ++sp; + } + } + } + break; + case splashModeMono8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + xDest]; + sp = &src->data[(ySrc + y) * bitmap->rowSize + xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + } + } + break; + case splashModeRGB8: + case splashModeBGR8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + 3 * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + 3 * xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + } + } + break; + case splashModeXBGR8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + *p++ = 255; + sp++; + } + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + } + } + break; + case splashModeDeviceN8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + (SPOT_NCOMPS+4) * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + (SPOT_NCOMPS+4) * xSrc]; + for (x = 0; x < w; ++x) { + for (int cp=0; cp < SPOT_NCOMPS+4; cp++) + *p++ = *sp++; + } + } + break; +#endif + } + + if (bitmap->alpha) { + for (y = 0; y < h; ++y) { + q = &bitmap->alpha[(yDest + y) * bitmap->width + xDest]; + memset(q, 0x00, w); + } + } + + return splashOk; +} +",0,"SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc, + int xDest, int yDest, int w, int h) { + SplashColorPtr p, sp; + Guchar *q; + int x, y, mask, srcMask; + + if (src->mode != bitmap->mode) { + return splashErrModeMismatch; + } + + switch (bitmap->mode) { + case splashModeMono1: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + (xDest >> 3)]; + mask = 0x80 >> (xDest & 7); + sp = &src->data[(ySrc + y) * src->rowSize + (xSrc >> 3)]; + srcMask = 0x80 >> (xSrc & 7); + for (x = 0; x < w; ++x) { + if (*sp & srcMask) { + *p |= mask; + } else { + *p &= ~mask; + } + if (!(mask >>= 1)) { + mask = 0x80; + ++p; + } + if (!(srcMask >>= 1)) { + srcMask = 0x80; + ++sp; + } + } + } + break; + case splashModeMono8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + xDest]; + sp = &src->data[(ySrc + y) * bitmap->rowSize + xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + } + } + break; + case splashModeRGB8: + case splashModeBGR8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + 3 * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + 3 * xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + } + } + break; + case splashModeXBGR8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + *p++ = 255; + sp++; + } + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc]; + for (x = 0; x < w; ++x) { + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + *p++ = *sp++; + } + } + break; + case splashModeDeviceN8: + for (y = 0; y < h; ++y) { + p = &bitmap->data[(yDest + y) * bitmap->rowSize + (SPOT_NCOMPS+4) * xDest]; + sp = &src->data[(ySrc + y) * src->rowSize + (SPOT_NCOMPS+4) * xSrc]; + for (x = 0; x < w; ++x) { + for (int cp=0; cp < SPOT_NCOMPS+4; cp++) + *p++ = *sp++; + } + } + break; +#endif + } + + if (bitmap->alpha) { + for (y = 0; y < h; ++y) { + q = &bitmap->alpha[(yDest + y) * bitmap->width + xDest]; + memset(q, 0x00, w); + } + } + + return splashOk; +} +","@@ -2955,7 +2955,7 @@ void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); + if (scaledMask->data == NULL) { +- error(errInternal, -1, ""scaledMask->data is NULL in Splash::scaleMaskYuXu""); ++ error(errInternal, -1, ""scaledMask->data is NULL in Splash::arbitraryTransformMask""); + delete scaledMask; + return; + } +@@ -3461,11 +3461,15 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + + w = src->getWidth(); + h = src->getHeight(); ++ p = src->getDataPtr(); ++ if (p == NULL) { ++ error(errInternal, -1, ""src->getDataPtr() is NULL in Splash::blitMask""); ++ return; ++ } + if (vectorAntialias && clipRes != splashClipAllInside) { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); + drawAAPixelInit(); +- p = src->getDataPtr(); + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + pipe.shape = *p++; +@@ -3475,7 +3479,6 @@ void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, + } else { + pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, + (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); +- p = src->getDataPtr(); + if (clipRes == splashClipAllInside) { + for (y = 0; y < h; ++y) { + pipeSetXY(&pipe, xDest, yDest + y);",991,1227,2048 +18290,"static MagickBooleanType DecodeImage(Image *image,unsigned char *luma, + unsigned char *chroma1,unsigned char *chroma2,ExceptionInfo *exception) +{ +#define IsSync(sum) ((sum & 0xffffff00UL) == 0xfffffe00UL) +#define PCDGetBits(n) \ +{ \ + sum=(sum << n) & 0xffffffff; \ + bits-=n; \ + while (bits <= 24) \ + { \ + if (p >= (buffer+0x800)) \ + { \ + count=ReadBlob(image,0x800,buffer); \ + p=buffer; \ + } \ + sum|=((unsigned int) (*p) << (24-bits)); \ + bits+=8; \ + p++; \ + } \ +} + + typedef struct PCDTable + { + unsigned int + length, + sequence; + + MagickStatusType + mask; + + unsigned char + key; + } PCDTable; + + PCDTable + *pcd_table[3]; + + register ssize_t + i, + j; + + register PCDTable + *r; + + register unsigned char + *p, + *q; + + size_t + bits, + length, + plane, + pcd_length[3], + row, + sum; + + ssize_t + count, + quantum; + + unsigned char + *buffer; + + /* + Initialize Huffman tables. + */ + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(luma != (unsigned char *) NULL); + assert(chroma1 != (unsigned char *) NULL); + assert(chroma2 != (unsigned char *) NULL); + buffer=(unsigned char *) AcquireQuantumMemory(0x800,sizeof(*buffer)); + if (buffer == (unsigned char *) NULL) + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + sum=0; + bits=32; + p=buffer+0x800; + for (i=0; i < 3; i++) + { + pcd_table[i]=(PCDTable *) NULL; + pcd_length[i]=0; + } + for (i=0; i < (image->columns > 1536 ? 3 : 1); i++) + { + PCDGetBits(8); + length=(sum & 0xff)+1; + pcd_table[i]=(PCDTable *) AcquireQuantumMemory(length, + sizeof(*pcd_table[i])); + if (pcd_table[i] == (PCDTable *) NULL) + { + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + r=pcd_table[i]; + for (j=0; j < (ssize_t) length; j++) + { + PCDGetBits(8); + r->length=(unsigned int) (sum & 0xff)+1; + if (r->length > 16) + { + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + return(MagickFalse); + } + PCDGetBits(16); + r->sequence=(unsigned int) (sum & 0xffff) << 16; + PCDGetBits(8); + r->key=(unsigned char) (sum & 0xff); + r->mask=(~((1U << (32-r->length))-1)); + r++; + } + pcd_length[i]=(size_t) length; + } + /* + Search for Sync byte. + */ + for (i=0; i < 1; i++) + PCDGetBits(16); + for (i=0; i < 1; i++) + PCDGetBits(16); + while ((sum & 0x00fff000UL) != 0x00fff000UL) + PCDGetBits(8); + while (IsSync(sum) == 0) + PCDGetBits(1); + /* + Recover the Huffman encoded luminance and chrominance deltas. + */ + count=0; + length=0; + plane=0; + row=0; + q=luma; + for ( ; ; ) + { + if (IsSync(sum) != 0) + { + /* + Determine plane and row number. + */ + PCDGetBits(16); + row=((sum >> 9) & 0x1fff); + if (row == image->rows) + break; + PCDGetBits(8); + plane=sum >> 30; + PCDGetBits(16); + switch (plane) + { + case 0: + { + q=luma+row*image->columns; + count=(ssize_t) image->columns; + break; + } + case 2: + { + q=chroma1+(row >> 1)*image->columns; + count=(ssize_t) (image->columns >> 1); + plane--; + break; + } + case 3: + { + q=chroma2+(row >> 1)*image->columns; + count=(ssize_t) (image->columns >> 1); + plane--; + break; + } + default: + { + for (i=0; i < (image->columns > 1536 ? 3 : 1); i++) + pcd_table[i]=(PCDTable *) RelinquishMagickMemory(pcd_table[i]); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + ThrowBinaryException(CorruptImageError,""CorruptImage"", + image->filename); + } + } + length=pcd_length[plane]; + continue; + } + /* + Decode luminance or chrominance deltas. + */ + r=pcd_table[plane]; + for (i=0; ((i < (ssize_t) length) && ((sum & r->mask) != r->sequence)); i++) + r++; + if ((row > image->rows) || (r == (PCDTable *) NULL)) + { + (void) ThrowMagickException(exception,GetMagickModule(), + CorruptImageWarning,""SkipToSyncByte"",""`%s'"",image->filename); + while ((sum & 0x00fff000) != 0x00fff000) + PCDGetBits(8); + while (IsSync(sum) == 0) + PCDGetBits(1); + continue; + } + if (r->key < 128) + quantum=(ssize_t) (*q)+r->key; + else + quantum=(ssize_t) (*q)+r->key-256; + *q=(unsigned char) ((quantum < 0) ? 0 : (quantum > 255) ? 255 : quantum); + q++; + PCDGetBits(r->length); + count--; + } + /* + Relinquish resources. + */ + for (i=0; i < (image->columns > 1536 ? 3 : 1); i++) + pcd_table[i]=(PCDTable *) RelinquishMagickMemory(pcd_table[i]); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + return(MagickTrue); +} +",1,"static MagickBooleanType DecodeImage(Image *image,unsigned char *luma, + unsigned char *chroma1,unsigned char *chroma2,ExceptionInfo *exception) +{ +#define IsSync(sum) ((sum & 0xffffff00UL) == 0xfffffe00UL) +#define PCDGetBits(n) \ +{ \ + sum=(sum << n) & 0xffffffff; \ + bits-=n; \ + while (bits <= 24) \ + { \ + if (p >= (buffer+0x800)) \ + { \ + count=ReadBlob(image,0x800,buffer); \ + p=buffer; \ + } \ + sum|=((unsigned int) (*p) << (24-bits)); \ + bits+=8; \ + p++; \ + } \ +} + + typedef struct PCDTable + { + unsigned int + length, + sequence; + + MagickStatusType + mask; + + unsigned char + key; + } PCDTable; + + PCDTable + *pcd_table[3]; + + register ssize_t + i, + j; + + register PCDTable + *r; + + register unsigned char + *p, + *q; + + size_t + bits, + length, + plane, + pcd_length[3], + row, + sum; + + ssize_t + count, + quantum; + + unsigned char + *buffer; + + /* + Initialize Huffman tables. + */ + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(luma != (unsigned char *) NULL); + assert(chroma1 != (unsigned char *) NULL); + assert(chroma2 != (unsigned char *) NULL); + buffer=(unsigned char *) AcquireQuantumMemory(0x800,sizeof(*buffer)); + if (buffer == (unsigned char *) NULL) + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + sum=0; + bits=32; + p=buffer+0x800; + for (i=0; i < 3; i++) + { + pcd_table[i]=(PCDTable *) NULL; + pcd_length[i]=0; + } + for (i=0; i < (image->columns > 1536 ? 3 : 1); i++) + { + PCDGetBits(8); + length=(sum & 0xff)+1; + pcd_table[i]=(PCDTable *) AcquireQuantumMemory(length, + sizeof(*pcd_table[i])); + if (pcd_table[i] == (PCDTable *) NULL) + { + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + for (j=0; j < i; j++) + pcd_table[j]=(PCDTable *) RelinquishMagickMemory(pcd_table[j]); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + r=pcd_table[i]; + for (j=0; j < (ssize_t) length; j++) + { + PCDGetBits(8); + r->length=(unsigned int) (sum & 0xff)+1; + if (r->length > 16) + { + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + for (j=0; j <= i; j++) + pcd_table[j]=(PCDTable *) RelinquishMagickMemory(pcd_table[j]); + return(MagickFalse); + } + PCDGetBits(16); + r->sequence=(unsigned int) (sum & 0xffff) << 16; + PCDGetBits(8); + r->key=(unsigned char) (sum & 0xff); + r->mask=(~((1U << (32-r->length))-1)); + r++; + } + pcd_length[i]=(size_t) length; + } + /* + Search for Sync byte. + */ + for (i=0; i < 1; i++) + PCDGetBits(16); + for (i=0; i < 1; i++) + PCDGetBits(16); + while ((sum & 0x00fff000UL) != 0x00fff000UL) + PCDGetBits(8); + while (IsSync(sum) == 0) + PCDGetBits(1); + /* + Recover the Huffman encoded luminance and chrominance deltas. + */ + count=0; + length=0; + plane=0; + row=0; + q=luma; + for ( ; ; ) + { + if (IsSync(sum) != 0) + { + /* + Determine plane and row number. + */ + PCDGetBits(16); + row=((sum >> 9) & 0x1fff); + if (row == image->rows) + break; + PCDGetBits(8); + plane=sum >> 30; + PCDGetBits(16); + switch (plane) + { + case 0: + { + q=luma+row*image->columns; + count=(ssize_t) image->columns; + break; + } + case 2: + { + q=chroma1+(row >> 1)*image->columns; + count=(ssize_t) (image->columns >> 1); + plane--; + break; + } + case 3: + { + q=chroma2+(row >> 1)*image->columns; + count=(ssize_t) (image->columns >> 1); + plane--; + break; + } + default: + { + for (i=0; i < (image->columns > 1536 ? 3 : 1); i++) + pcd_table[i]=(PCDTable *) RelinquishMagickMemory(pcd_table[i]); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + ThrowBinaryException(CorruptImageError,""CorruptImage"", + image->filename); + } + } + length=pcd_length[plane]; + continue; + } + /* + Decode luminance or chrominance deltas. + */ + r=pcd_table[plane]; + for (i=0; ((i < (ssize_t) length) && ((sum & r->mask) != r->sequence)); i++) + r++; + if ((row > image->rows) || (r == (PCDTable *) NULL)) + { + (void) ThrowMagickException(exception,GetMagickModule(), + CorruptImageWarning,""SkipToSyncByte"",""`%s'"",image->filename); + while ((sum & 0x00fff000) != 0x00fff000) + PCDGetBits(8); + while (IsSync(sum) == 0) + PCDGetBits(1); + continue; + } + if (r->key < 128) + quantum=(ssize_t) (*q)+r->key; + else + quantum=(ssize_t) (*q)+r->key-256; + *q=(unsigned char) ((quantum < 0) ? 0 : (quantum > 255) ? 255 : quantum); + q++; + PCDGetBits(r->length); + count--; + } + /* + Relinquish resources. + */ + for (i=0; i < (image->columns > 1536 ? 3 : 1); i++) + pcd_table[i]=(PCDTable *) RelinquishMagickMemory(pcd_table[i]); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + return(MagickTrue); +} +","@@ -204,6 +204,8 @@ static MagickBooleanType DecodeImage(Image *image,unsigned char *luma, + if (pcd_table[i] == (PCDTable *) NULL) + { + buffer=(unsigned char *) RelinquishMagickMemory(buffer); ++ for (j=0; j < i; j++) ++ pcd_table[j]=(PCDTable *) RelinquishMagickMemory(pcd_table[j]); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } +@@ -215,6 +217,8 @@ static MagickBooleanType DecodeImage(Image *image,unsigned char *luma, + if (r->length > 16) + { + buffer=(unsigned char *) RelinquishMagickMemory(buffer); ++ for (j=0; j <= i; j++) ++ pcd_table[j]=(PCDTable *) RelinquishMagickMemory(pcd_table[j]); + return(MagickFalse); + } + PCDGetBits(16);",1646,1882,2048 +18224,"M_fs_error_t M_fs_delete(const char *path, M_bool remove_children, M_fs_progress_cb_t cb, M_uint32 progress_flags) +{ + char *norm_path; + char *join_path; + M_fs_dir_entries_t *entries; + const M_fs_dir_entry_t *entry; + M_fs_info_t *info; + M_fs_progress_t *progress = NULL; + M_fs_dir_walk_filter_t filter = M_FS_DIR_WALK_FILTER_ALL|M_FS_DIR_WALK_FILTER_RECURSE; + M_fs_type_t type; + /* The result that will be returned by this function. */ + M_fs_error_t res; + /* The result of the delete itself. */ + M_fs_error_t res2; + size_t len; + size_t i; + M_uint64 total_size = 0; + M_uint64 total_size_progress = 0; + M_uint64 entry_size; + + /* Normalize the path we are going to delete so we have a valid path to pass around. */ + res = M_fs_path_norm(&norm_path, path, M_FS_PATH_NORM_HOME, M_FS_SYSTEM_AUTO); + if (res != M_FS_ERROR_SUCCESS) { + M_free(norm_path); + return res; + } + + /* We need the info to determine if the path is valid and because we need the type. */ + res = M_fs_info(&info, norm_path, M_FS_PATH_INFO_FLAGS_BASIC); + if (res != M_FS_ERROR_SUCCESS) { + M_free(norm_path); + return res; + } + + /* We must know the type because there are different functions for deleting a file and deleting a directory. */ + type = M_fs_info_get_type(info); + if (type == M_FS_TYPE_UNKNOWN) { + M_fs_info_destroy(info); + M_free(norm_path); + return M_FS_ERROR_GENERIC; + } + + /* Create a list of entries to store all the places we need to delete. */ + entries = M_fs_dir_entries_create(); + + /* Recursive directory deletion isn't intuitive. We have to generate a list of files and delete the list. + * We cannot delete as walk because not all file systems support that operation. The walk; delete; behavior + * is undefined in Posix and HFS is known to skip files if the directory contents is modifies as the + * directory is being walked. */ + if (type == M_FS_TYPE_DIR && remove_children) { + /* We need to read the basic info if the we need to report the size totals to the cb. */ + if (cb && progress_flags & (M_FS_PROGRESS_SIZE_TOTAL|M_FS_PROGRESS_SIZE_CUR)) { + filter |= M_FS_DIR_WALK_FILTER_READ_INFO_BASIC; + } + M_fs_dir_entries_merge(&entries, M_fs_dir_walk_entries(norm_path, NULL, filter)); + } + + /* Add the original path to the list of entries. This may be the only entry in the list. We need to add + * it after a potential walk because we can't delete a directory that isn't empty. + * Note: + * - The info will be owned by the entry and destroyed when it is destroyed. + * - The basic info param doesn't get the info in this case. it's set so the info is stored in the entry. */ + M_fs_dir_entries_insert(entries, M_fs_dir_walk_fill_entry(norm_path, NULL, type, info, M_FS_DIR_WALK_FILTER_READ_INFO_BASIC)); + + len = M_fs_dir_entries_len(entries); + if (cb) { + /* Create the progress. The same progress will be used for the entire operation. It will be updated with + * new info as necessary. */ + progress = M_fs_progress_create(); + + /* Get the total size of all files to be deleted if using the progress cb and size totals is set. */ + if (progress_flags & M_FS_PROGRESS_SIZE_TOTAL) { + for (i=0; ilen; + register u_int caplen = h->caplen; + uint16_t ptype; + const u_char *q; + int i; + + if (caplen < PPP_BSDI_HDRLEN) { + ND_PRINT((ndo, ""[|ppp]"")); + return (caplen) + } + + hdrlength = 0; + +#if 0 + if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) { + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%02x %02x "", p[0], p[1])); + p += 2; + hdrlength = 2; + } + + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%d "", length)); + /* Retrieve the protocol type */ + if (*p & 01) { + /* Compressed protocol field */ + ptype = *p; + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%02x "", ptype)); + p++; + hdrlength += 1; + } else { + /* Un-compressed protocol field */ + ptype = EXTRACT_16BITS(p); + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%04x "", ptype)); + p += 2; + hdrlength += 2; + } +#else + ptype = 0; /*XXX*/ + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%c "", p[SLC_DIR] ? 'O' : 'I')); + if (p[SLC_LLHL]) { + /* link level header */ + struct ppp_header *ph; + + q = p + SLC_BPFHDRLEN; + ph = (struct ppp_header *)q; + if (ph->phdr_addr == PPP_ADDRESS + && ph->phdr_ctl == PPP_CONTROL) { + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%02x %02x "", q[0], q[1])); + ptype = EXTRACT_16BITS(&ph->phdr_type); + if (ndo->ndo_eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) { + ND_PRINT((ndo, ""%s "", tok2str(ppptype2str, + ""proto-#%d"", ptype))); + } + } else { + if (ndo->ndo_eflag) { + ND_PRINT((ndo, ""LLH=["")); + for (i = 0; i < p[SLC_LLHL]; i++) + ND_PRINT((ndo, ""%02x"", q[i])); + ND_PRINT((ndo, ""] "")); + } + } + } + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%d "", length)); + if (p[SLC_CHL]) { + q = p + SLC_BPFHDRLEN + p[SLC_LLHL]; + + switch (ptype) { + case PPP_VJC: + ptype = vjc_print(ndo, q, ptype); + hdrlength = PPP_BSDI_HDRLEN; + p += hdrlength; + switch (ptype) { + case PPP_IP: + ip_print(ndo, p, length); + break; + case PPP_IPV6: + ip6_print(ndo, p, length); + break; + case PPP_MPLS_UCAST: + case PPP_MPLS_MCAST: + mpls_print(ndo, p, length); + break; + } + goto printx; + case PPP_VJNC: + ptype = vjc_print(ndo, q, ptype); + hdrlength = PPP_BSDI_HDRLEN; + p += hdrlength; + switch (ptype) { + case PPP_IP: + ip_print(ndo, p, length); + break; + case PPP_IPV6: + ip6_print(ndo, p, length); + break; + case PPP_MPLS_UCAST: + case PPP_MPLS_MCAST: + mpls_print(ndo, p, length); + break; + } + goto printx; + default: + if (ndo->ndo_eflag) { + ND_PRINT((ndo, ""CH=["")); + for (i = 0; i < p[SLC_LLHL]; i++) + ND_PRINT((ndo, ""%02x"", q[i])); + ND_PRINT((ndo, ""] "")); + } + break; + } + } + + hdrlength = PPP_BSDI_HDRLEN; +#endif + + length -= hdrlength; + p += hdrlength; + + switch (ptype) { + case PPP_IP: + ip_print(p, length); + break; + case PPP_IPV6: + ip6_print(ndo, p, length); + break; + case PPP_MPLS_UCAST: + case PPP_MPLS_MCAST: + mpls_print(ndo, p, length); + break; + default: + ND_PRINT((ndo, ""%s "", tok2str(ppptype2str, ""unknown PPP protocol (0x%04x)"", ptype))); + } + +printx: +#else /* __bsdi */ + hdrlength = 0; +#endif /* __bsdi__ */ + return (hdrlength); +} +",0,"ppp_bsdos_if_print(netdissect_options *ndo _U_, + const struct pcap_pkthdr *h _U_, register const u_char *p _U_) +{ + register int hdrlength; +#ifdef __bsdi__ + register u_int length = h->len; + register u_int caplen = h->caplen; + uint16_t ptype; + const u_char *q; + int i; + + if (caplen < PPP_BSDI_HDRLEN) { + ND_PRINT((ndo, ""[|ppp]"")); + return (caplen) + } + + hdrlength = 0; + +#if 0 + if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) { + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%02x %02x "", p[0], p[1])); + p += 2; + hdrlength = 2; + } + + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%d "", length)); + /* Retrieve the protocol type */ + if (*p & 01) { + /* Compressed protocol field */ + ptype = *p; + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%02x "", ptype)); + p++; + hdrlength += 1; + } else { + /* Un-compressed protocol field */ + ptype = EXTRACT_16BITS(p); + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%04x "", ptype)); + p += 2; + hdrlength += 2; + } +#else + ptype = 0; /*XXX*/ + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%c "", p[SLC_DIR] ? 'O' : 'I')); + if (p[SLC_LLHL]) { + /* link level header */ + struct ppp_header *ph; + + q = p + SLC_BPFHDRLEN; + ph = (struct ppp_header *)q; + if (ph->phdr_addr == PPP_ADDRESS + && ph->phdr_ctl == PPP_CONTROL) { + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%02x %02x "", q[0], q[1])); + ptype = EXTRACT_16BITS(&ph->phdr_type); + if (ndo->ndo_eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) { + ND_PRINT((ndo, ""%s "", tok2str(ppptype2str, + ""proto-#%d"", ptype))); + } + } else { + if (ndo->ndo_eflag) { + ND_PRINT((ndo, ""LLH=["")); + for (i = 0; i < p[SLC_LLHL]; i++) + ND_PRINT((ndo, ""%02x"", q[i])); + ND_PRINT((ndo, ""] "")); + } + } + } + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%d "", length)); + if (p[SLC_CHL]) { + q = p + SLC_BPFHDRLEN + p[SLC_LLHL]; + + switch (ptype) { + case PPP_VJC: + ptype = vjc_print(ndo, q, ptype); + hdrlength = PPP_BSDI_HDRLEN; + p += hdrlength; + switch (ptype) { + case PPP_IP: + ip_print(ndo, p, length); + break; + case PPP_IPV6: + ip6_print(ndo, p, length); + break; + case PPP_MPLS_UCAST: + case PPP_MPLS_MCAST: + mpls_print(ndo, p, length); + break; + } + goto printx; + case PPP_VJNC: + ptype = vjc_print(ndo, q, ptype); + hdrlength = PPP_BSDI_HDRLEN; + p += hdrlength; + switch (ptype) { + case PPP_IP: + ip_print(ndo, p, length); + break; + case PPP_IPV6: + ip6_print(ndo, p, length); + break; + case PPP_MPLS_UCAST: + case PPP_MPLS_MCAST: + mpls_print(ndo, p, length); + break; + } + goto printx; + default: + if (ndo->ndo_eflag) { + ND_PRINT((ndo, ""CH=["")); + for (i = 0; i < p[SLC_LLHL]; i++) + ND_PRINT((ndo, ""%02x"", q[i])); + ND_PRINT((ndo, ""] "")); + } + break; + } + } + + hdrlength = PPP_BSDI_HDRLEN; +#endif + + length -= hdrlength; + p += hdrlength; + + switch (ptype) { + case PPP_IP: + ip_print(p, length); + break; + case PPP_IPV6: + ip6_print(ndo, p, length); + break; + case PPP_MPLS_UCAST: + case PPP_MPLS_MCAST: + mpls_print(ndo, p, length); + break; + default: + ND_PRINT((ndo, ""%s "", tok2str(ppptype2str, ""unknown PPP protocol (0x%04x)"", ptype))); + } + +printx: +#else /* __bsdi */ + hdrlength = 0; +#endif /* __bsdi__ */ + return (hdrlength); +} +","@@ -1351,14 +1351,15 @@ static void + ppp_hdlc(netdissect_options *ndo, + const u_char *p, int length) + { +- u_char *b, *s, *t, c; ++ u_char *b, *t, c; ++ const u_char *s; + int i, proto; + const void *se; + + if (length <= 0) + return; + +- b = (uint8_t *)malloc(length); ++ b = (u_char *)malloc(length); + if (b == NULL) + return; + +@@ -1367,14 +1368,13 @@ ppp_hdlc(netdissect_options *ndo, + * Do this so that we dont overwrite the original packet + * contents. + */ +- for (s = (u_char *)p, t = b, i = length; i > 0; i--) { ++ for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) { + c = *s++; + if (c == 0x7d) { +- if (i > 1) { +- i--; +- c = *s++ ^ 0x20; +- } else +- continue; ++ if (i <= 1 || !ND_TTEST(*s)) ++ break; ++ i--; ++ c = *s++ ^ 0x20; + } + *t++ = c; + }",1202,1438,2048 +8603,"int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, unsigned int flags) +{ + pte_t *ptep, entry; + spinlock_t *ptl; + int ret; + u32 hash; + pgoff_t idx; + struct page *page = NULL; + struct page *pagecache_page = NULL; + struct hstate *h = hstate_vma(vma); + struct address_space *mapping; + int need_wait_lock = 0; + + address &= huge_page_mask(h); + + ptep = huge_pte_offset(mm, address, huge_page_size(h)); + if (ptep) { + entry = huge_ptep_get(ptep); + if (unlikely(is_hugetlb_entry_migration(entry))) { + migration_entry_wait_huge(vma, mm, ptep); + return 0; + } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) + return VM_FAULT_HWPOISON_LARGE | + VM_FAULT_SET_HINDEX(hstate_index(h)); + } else { + ptep = huge_pte_alloc(mm, address, huge_page_size(h)); + if (!ptep) + return VM_FAULT_OOM; + } + + mapping = vma->vm_file->f_mapping; + idx = vma_hugecache_offset(h, vma, address); + + /* + * Serialize hugepage allocation and instantiation, so that we don't + * get spurious allocation failures if two CPUs race to instantiate + * the same page in the page cache. + */ + hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, address); + mutex_lock(&hugetlb_fault_mutex_table[hash]); + + entry = huge_ptep_get(ptep); + if (huge_pte_none(entry)) { + ret = hugetlb_no_page(mm, vma, mapping, idx, address, ptep, flags); + goto out_mutex; + } + + ret = 0; + + /* + * entry could be a migration/hwpoison entry at this point, so this + * check prevents the kernel from going below assuming that we have + * a active hugepage in pagecache. This goto expects the 2nd page fault, + * and is_hugetlb_entry_(migration|hwpoisoned) check will properly + * handle it. + */ + if (!pte_present(entry)) + goto out_mutex; + + /* + * If we are going to COW the mapping later, we examine the pending + * reservations for this page now. This will ensure that any + * allocations necessary to record that reservation occur outside the + * spinlock. For private mappings, we also lookup the pagecache + * page now as it is used to determine if a reservation has been + * consumed. + */ + if ((flags & FAULT_FLAG_WRITE) && !huge_pte_write(entry)) { + if (vma_needs_reservation(h, vma, address) < 0) { + ret = VM_FAULT_OOM; + goto out_mutex; + } + /* Just decrements count, does not deallocate */ + vma_end_reservation(h, vma, address); + + if (!(vma->vm_flags & VM_MAYSHARE)) + pagecache_page = hugetlbfs_pagecache_page(h, + vma, address); + } + + ptl = huge_pte_lock(h, mm, ptep); + + /* Check for a racing update before calling hugetlb_cow */ + if (unlikely(!pte_same(entry, huge_ptep_get(ptep)))) + goto out_ptl; + + /* + * hugetlb_cow() requires page locks of pte_page(entry) and + * pagecache_page, so here we need take the former one + * when page != pagecache_page or !pagecache_page. + */ + page = pte_page(entry); + if (page != pagecache_page) + if (!trylock_page(page)) { + need_wait_lock = 1; + goto out_ptl; + } + + get_page(page); + + if (flags & FAULT_FLAG_WRITE) { + if (!huge_pte_write(entry)) { + ret = hugetlb_cow(mm, vma, address, ptep, + pagecache_page, ptl); + goto out_put_page; + } + entry = huge_pte_mkdirty(entry); + } + entry = pte_mkyoung(entry); + if (huge_ptep_set_access_flags(vma, address, ptep, entry, + flags & FAULT_FLAG_WRITE)) + update_mmu_cache(vma, address, ptep); +out_put_page: + if (page != pagecache_page) + unlock_page(page); + put_page(page); +out_ptl: + spin_unlock(ptl); + + if (pagecache_page) { + unlock_page(pagecache_page); + put_page(pagecache_page); + } +out_mutex: + mutex_unlock(&hugetlb_fault_mutex_table[hash]); + /* + * Generally it's safe to hold refcount during waiting page lock. But + * here we just wait to defer the next page fault to avoid busy loop and + * the page is not used after unlocked before returning from the current + * page fault. So we are safe from accessing freed page, even if we wait + * here without taking refcount. + */ + if (need_wait_lock) + wait_on_page_locked(page); + return ret; +} +",0,"int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, unsigned int flags) +{ + pte_t *ptep, entry; + spinlock_t *ptl; + int ret; + u32 hash; + pgoff_t idx; + struct page *page = NULL; + struct page *pagecache_page = NULL; + struct hstate *h = hstate_vma(vma); + struct address_space *mapping; + int need_wait_lock = 0; + + address &= huge_page_mask(h); + + ptep = huge_pte_offset(mm, address, huge_page_size(h)); + if (ptep) { + entry = huge_ptep_get(ptep); + if (unlikely(is_hugetlb_entry_migration(entry))) { + migration_entry_wait_huge(vma, mm, ptep); + return 0; + } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) + return VM_FAULT_HWPOISON_LARGE | + VM_FAULT_SET_HINDEX(hstate_index(h)); + } else { + ptep = huge_pte_alloc(mm, address, huge_page_size(h)); + if (!ptep) + return VM_FAULT_OOM; + } + + mapping = vma->vm_file->f_mapping; + idx = vma_hugecache_offset(h, vma, address); + + /* + * Serialize hugepage allocation and instantiation, so that we don't + * get spurious allocation failures if two CPUs race to instantiate + * the same page in the page cache. + */ + hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, address); + mutex_lock(&hugetlb_fault_mutex_table[hash]); + + entry = huge_ptep_get(ptep); + if (huge_pte_none(entry)) { + ret = hugetlb_no_page(mm, vma, mapping, idx, address, ptep, flags); + goto out_mutex; + } + + ret = 0; + + /* + * entry could be a migration/hwpoison entry at this point, so this + * check prevents the kernel from going below assuming that we have + * a active hugepage in pagecache. This goto expects the 2nd page fault, + * and is_hugetlb_entry_(migration|hwpoisoned) check will properly + * handle it. + */ + if (!pte_present(entry)) + goto out_mutex; + + /* + * If we are going to COW the mapping later, we examine the pending + * reservations for this page now. This will ensure that any + * allocations necessary to record that reservation occur outside the + * spinlock. For private mappings, we also lookup the pagecache + * page now as it is used to determine if a reservation has been + * consumed. + */ + if ((flags & FAULT_FLAG_WRITE) && !huge_pte_write(entry)) { + if (vma_needs_reservation(h, vma, address) < 0) { + ret = VM_FAULT_OOM; + goto out_mutex; + } + /* Just decrements count, does not deallocate */ + vma_end_reservation(h, vma, address); + + if (!(vma->vm_flags & VM_MAYSHARE)) + pagecache_page = hugetlbfs_pagecache_page(h, + vma, address); + } + + ptl = huge_pte_lock(h, mm, ptep); + + /* Check for a racing update before calling hugetlb_cow */ + if (unlikely(!pte_same(entry, huge_ptep_get(ptep)))) + goto out_ptl; + + /* + * hugetlb_cow() requires page locks of pte_page(entry) and + * pagecache_page, so here we need take the former one + * when page != pagecache_page or !pagecache_page. + */ + page = pte_page(entry); + if (page != pagecache_page) + if (!trylock_page(page)) { + need_wait_lock = 1; + goto out_ptl; + } + + get_page(page); + + if (flags & FAULT_FLAG_WRITE) { + if (!huge_pte_write(entry)) { + ret = hugetlb_cow(mm, vma, address, ptep, + pagecache_page, ptl); + goto out_put_page; + } + entry = huge_pte_mkdirty(entry); + } + entry = pte_mkyoung(entry); + if (huge_ptep_set_access_flags(vma, address, ptep, entry, + flags & FAULT_FLAG_WRITE)) + update_mmu_cache(vma, address, ptep); +out_put_page: + if (page != pagecache_page) + unlock_page(page); + put_page(page); +out_ptl: + spin_unlock(ptl); + + if (pagecache_page) { + unlock_page(pagecache_page); + put_page(pagecache_page); + } +out_mutex: + mutex_unlock(&hugetlb_fault_mutex_table[hash]); + /* + * Generally it's safe to hold refcount during waiting page lock. But + * here we just wait to defer the next page fault to avoid busy loop and + * the page is not used after unlocked before returning from the current + * page fault. So we are safe from accessing freed page, even if we wait + * here without taking refcount. + */ + if (need_wait_lock) + wait_on_page_locked(page); + return ret; +} +","@@ -3984,6 +3984,9 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, + unsigned long src_addr, + struct page **pagep) + { ++ struct address_space *mapping; ++ pgoff_t idx; ++ unsigned long size; + int vm_shared = dst_vma->vm_flags & VM_SHARED; + struct hstate *h = hstate_vma(dst_vma); + pte_t _dst_pte; +@@ -4021,13 +4024,24 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, + __SetPageUptodate(page); + set_page_huge_active(page); + ++ mapping = dst_vma->vm_file->f_mapping; ++ idx = vma_hugecache_offset(h, dst_vma, dst_addr); ++ + /* + * If shared, add to page cache + */ + if (vm_shared) { +- struct address_space *mapping = dst_vma->vm_file->f_mapping; +- pgoff_t idx = vma_hugecache_offset(h, dst_vma, dst_addr); ++ size = i_size_read(mapping->host) >> huge_page_shift(h); ++ ret = -EFAULT; ++ if (idx >= size) ++ goto out_release_nounlock; + ++ /* ++ * Serialization between remove_inode_hugepages() and ++ * huge_add_to_page_cache() below happens through the ++ * hugetlb_fault_mutex_table that here must be hold by ++ * the caller. ++ */ + ret = huge_add_to_page_cache(page, mapping, idx); + if (ret) + goto out_release_nounlock; +@@ -4036,6 +4050,20 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, + ptl = huge_pte_lockptr(h, dst_mm, dst_pte); + spin_lock(ptl); + ++ /* ++ * Recheck the i_size after holding PT lock to make sure not ++ * to leave any page mapped (as page_mapped()) beyond the end ++ * of the i_size (remove_inode_hugepages() is strict about ++ * enforcing that). If we bail out here, we'll also leave a ++ * page in the radix tree in the vm_shared case beyond the end ++ * of the i_size, but remove_inode_hugepages() will take care ++ * of it as soon as we drop the hugetlb_fault_mutex_table. ++ */ ++ size = i_size_read(mapping->host) >> huge_page_shift(h); ++ ret = -EFAULT; ++ if (idx >= size) ++ goto out_release_unlock; ++ + ret = -EEXIST; + if (!huge_pte_none(huge_ptep_get(dst_pte))) + goto out_release_unlock;",1131,1367,2048 +8375,"static int attach_to_pi_state(u32 __user *uaddr, u32 uval, + struct futex_pi_state *pi_state, + struct futex_pi_state **ps) +{ + pid_t pid = uval & FUTEX_TID_MASK; + u32 uval2; + int ret; + + /* + * Userspace might have messed up non-PI and PI futexes [3] + */ + if (unlikely(!pi_state)) + return -EINVAL; + + /* + * We get here with hb->lock held, and having found a + * futex_top_waiter(). This means that futex_lock_pi() of said futex_q + * has dropped the hb->lock in between queue_me() and unqueue_me_pi(), + * which in turn means that futex_lock_pi() still has a reference on + * our pi_state. + * + * The waiter holding a reference on @pi_state also protects against + * the unlocked put_pi_state() in futex_unlock_pi(), futex_lock_pi() + * and futex_wait_requeue_pi() as it cannot go to 0 and consequently + * free pi_state before we can take a reference ourselves. + */ + WARN_ON(!atomic_read(&pi_state->refcount)); + + /* + * Now that we have a pi_state, we can acquire wait_lock + * and do the state validation. + */ + raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock); + + /* + * Since {uval, pi_state} is serialized by wait_lock, and our current + * uval was read without holding it, it can have changed. Verify it + * still is what we expect it to be, otherwise retry the entire + * operation. + */ + if (get_futex_value_locked(&uval2, uaddr)) + goto out_efault; + + if (uval != uval2) + goto out_eagain; + + /* + * Handle the owner died case: + */ + if (uval & FUTEX_OWNER_DIED) { + /* + * exit_pi_state_list sets owner to NULL and wakes the + * topmost waiter. The task which acquires the + * pi_state->rt_mutex will fixup owner. + */ + if (!pi_state->owner) { + /* + * No pi state owner, but the user space TID + * is not 0. Inconsistent state. [5] + */ + if (pid) + goto out_einval; + /* + * Take a ref on the state and return success. [4] + */ + goto out_attach; + } + + /* + * If TID is 0, then either the dying owner has not + * yet executed exit_pi_state_list() or some waiter + * acquired the rtmutex in the pi state, but did not + * yet fixup the TID in user space. + * + * Take a ref on the state and return success. [6] + */ + if (!pid) + goto out_attach; + } else { + /* + * If the owner died bit is not set, then the pi_state + * must have an owner. [7] + */ + if (!pi_state->owner) + goto out_einval; + } + + /* + * Bail out if user space manipulated the futex value. If pi + * state exists then the owner TID must be the same as the + * user space TID. [9/10] + */ + if (pid != task_pid_vnr(pi_state->owner)) + goto out_einval; + +out_attach: + get_pi_state(pi_state); + raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); + *ps = pi_state; + return 0; + +out_einval: + ret = -EINVAL; + goto out_error; + +out_eagain: + ret = -EAGAIN; + goto out_error; + +out_efault: + ret = -EFAULT; + goto out_error; + +out_error: + raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); + return ret; +} +",0,"static int attach_to_pi_state(u32 __user *uaddr, u32 uval, + struct futex_pi_state *pi_state, + struct futex_pi_state **ps) +{ + pid_t pid = uval & FUTEX_TID_MASK; + u32 uval2; + int ret; + + /* + * Userspace might have messed up non-PI and PI futexes [3] + */ + if (unlikely(!pi_state)) + return -EINVAL; + + /* + * We get here with hb->lock held, and having found a + * futex_top_waiter(). This means that futex_lock_pi() of said futex_q + * has dropped the hb->lock in between queue_me() and unqueue_me_pi(), + * which in turn means that futex_lock_pi() still has a reference on + * our pi_state. + * + * The waiter holding a reference on @pi_state also protects against + * the unlocked put_pi_state() in futex_unlock_pi(), futex_lock_pi() + * and futex_wait_requeue_pi() as it cannot go to 0 and consequently + * free pi_state before we can take a reference ourselves. + */ + WARN_ON(!atomic_read(&pi_state->refcount)); + + /* + * Now that we have a pi_state, we can acquire wait_lock + * and do the state validation. + */ + raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock); + + /* + * Since {uval, pi_state} is serialized by wait_lock, and our current + * uval was read without holding it, it can have changed. Verify it + * still is what we expect it to be, otherwise retry the entire + * operation. + */ + if (get_futex_value_locked(&uval2, uaddr)) + goto out_efault; + + if (uval != uval2) + goto out_eagain; + + /* + * Handle the owner died case: + */ + if (uval & FUTEX_OWNER_DIED) { + /* + * exit_pi_state_list sets owner to NULL and wakes the + * topmost waiter. The task which acquires the + * pi_state->rt_mutex will fixup owner. + */ + if (!pi_state->owner) { + /* + * No pi state owner, but the user space TID + * is not 0. Inconsistent state. [5] + */ + if (pid) + goto out_einval; + /* + * Take a ref on the state and return success. [4] + */ + goto out_attach; + } + + /* + * If TID is 0, then either the dying owner has not + * yet executed exit_pi_state_list() or some waiter + * acquired the rtmutex in the pi state, but did not + * yet fixup the TID in user space. + * + * Take a ref on the state and return success. [6] + */ + if (!pid) + goto out_attach; + } else { + /* + * If the owner died bit is not set, then the pi_state + * must have an owner. [7] + */ + if (!pi_state->owner) + goto out_einval; + } + + /* + * Bail out if user space manipulated the futex value. If pi + * state exists then the owner TID must be the same as the + * user space TID. [9/10] + */ + if (pid != task_pid_vnr(pi_state->owner)) + goto out_einval; + +out_attach: + get_pi_state(pi_state); + raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); + *ps = pi_state; + return 0; + +out_einval: + ret = -EINVAL; + goto out_error; + +out_eagain: + ret = -EAGAIN; + goto out_error; + +out_efault: + ret = -EFAULT; + goto out_error; + +out_error: + raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); + return ret; +} +","@@ -1878,6 +1878,9 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, + struct futex_q *this, *next; + DEFINE_WAKE_Q(wake_q); + ++ if (nr_wake < 0 || nr_requeue < 0) ++ return -EINVAL; ++ + /* + * When PI not supported: return -ENOSYS if requeue_pi is true, + * consequently the compiler knows requeue_pi is always false past",861,1097,2048 +14554,"static BrotliResult DecodeContextMap(uint32_t context_map_size, + uint32_t* num_htrees, + uint8_t** context_map_arg, + BrotliState* s) { + BrotliBitReader* br = &s->br; + BrotliResult result = BROTLI_RESULT_SUCCESS; + + switch((int)s->substate_context_map) { + case BROTLI_STATE_CONTEXT_MAP_NONE: + result = DecodeVarLenUint8(s, br, num_htrees); + if (result != BROTLI_RESULT_SUCCESS) { + return result; + } + (*num_htrees)++; + s->context_index = 0; + BROTLI_LOG_UINT(context_map_size); + BROTLI_LOG_UINT(*num_htrees); + *context_map_arg = (uint8_t*)BROTLI_ALLOC(s, (size_t)context_map_size); + if (*context_map_arg == 0) { + return BROTLI_FAILURE(); + } + if (*num_htrees <= 1) { + memset(*context_map_arg, 0, (size_t)context_map_size); + return BROTLI_RESULT_SUCCESS; + } + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_READ_PREFIX; + /* No break, continue to next state. */ + case BROTLI_STATE_CONTEXT_MAP_READ_PREFIX: { + uint32_t bits; + /* In next stage ReadHuffmanCode uses at least 4 bits, so it is safe + to peek 4 bits ahead. */ + if (!BrotliSafeGetBits(br, 5, &bits)) { + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + if ((bits & 1) != 0) { /* Use RLE for zeroes. */ + s->max_run_length_prefix = (bits >> 1) + 1; + BrotliDropBits(br, 5); + } else { + s->max_run_length_prefix = 0; + BrotliDropBits(br, 1); + } + BROTLI_LOG_UINT(s->max_run_length_prefix); + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_HUFFMAN; + /* No break, continue to next state. */ + } + case BROTLI_STATE_CONTEXT_MAP_HUFFMAN: + result = ReadHuffmanCode(*num_htrees + s->max_run_length_prefix, + s->context_map_table, NULL, s); + if (result != BROTLI_RESULT_SUCCESS) return result; + s->code = 0xFFFF; + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_DECODE; + /* No break, continue to next state. */ + case BROTLI_STATE_CONTEXT_MAP_DECODE: { + uint32_t context_index = s->context_index; + uint32_t max_run_length_prefix = s->max_run_length_prefix; + uint8_t* context_map = *context_map_arg; + uint32_t code = s->code; + if (code != 0xFFFF) { + goto rleCode; + } + while (context_index < context_map_size) { + if (!SafeReadSymbol(s->context_map_table, br, &code)) { + s->code = 0xFFFF; + s->context_index = context_index; + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + BROTLI_LOG_UINT(code); + + if (code == 0) { + context_map[context_index++] = 0; + continue; + } + if (code > max_run_length_prefix) { + context_map[context_index++] = + (uint8_t)(code - max_run_length_prefix); + continue; + } +rleCode: + { + uint32_t reps; + if (!BrotliSafeReadBits(br, code, &reps)) { + s->code = code; + s->context_index = context_index; + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + reps += 1U << code; + BROTLI_LOG_UINT(reps); + if (context_index + reps > context_map_size) { + return BROTLI_FAILURE(); + } + do { + context_map[context_index++] = 0; + } while (--reps); + } + } + /* No break, continue to next state. */ + } + case BROTLI_STATE_CONTEXT_MAP_TRANSFORM: { + uint32_t bits; + if (!BrotliSafeReadBits(br, 1, &bits)) { + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_TRANSFORM; + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + if (bits != 0) { + InverseMoveToFrontTransform(*context_map_arg, context_map_size, s); + } + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; + return BROTLI_RESULT_SUCCESS; + } + } + + return BROTLI_FAILURE(); +} +",0,"static BrotliResult DecodeContextMap(uint32_t context_map_size, + uint32_t* num_htrees, + uint8_t** context_map_arg, + BrotliState* s) { + BrotliBitReader* br = &s->br; + BrotliResult result = BROTLI_RESULT_SUCCESS; + + switch((int)s->substate_context_map) { + case BROTLI_STATE_CONTEXT_MAP_NONE: + result = DecodeVarLenUint8(s, br, num_htrees); + if (result != BROTLI_RESULT_SUCCESS) { + return result; + } + (*num_htrees)++; + s->context_index = 0; + BROTLI_LOG_UINT(context_map_size); + BROTLI_LOG_UINT(*num_htrees); + *context_map_arg = (uint8_t*)BROTLI_ALLOC(s, (size_t)context_map_size); + if (*context_map_arg == 0) { + return BROTLI_FAILURE(); + } + if (*num_htrees <= 1) { + memset(*context_map_arg, 0, (size_t)context_map_size); + return BROTLI_RESULT_SUCCESS; + } + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_READ_PREFIX; + /* No break, continue to next state. */ + case BROTLI_STATE_CONTEXT_MAP_READ_PREFIX: { + uint32_t bits; + /* In next stage ReadHuffmanCode uses at least 4 bits, so it is safe + to peek 4 bits ahead. */ + if (!BrotliSafeGetBits(br, 5, &bits)) { + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + if ((bits & 1) != 0) { /* Use RLE for zeroes. */ + s->max_run_length_prefix = (bits >> 1) + 1; + BrotliDropBits(br, 5); + } else { + s->max_run_length_prefix = 0; + BrotliDropBits(br, 1); + } + BROTLI_LOG_UINT(s->max_run_length_prefix); + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_HUFFMAN; + /* No break, continue to next state. */ + } + case BROTLI_STATE_CONTEXT_MAP_HUFFMAN: + result = ReadHuffmanCode(*num_htrees + s->max_run_length_prefix, + s->context_map_table, NULL, s); + if (result != BROTLI_RESULT_SUCCESS) return result; + s->code = 0xFFFF; + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_DECODE; + /* No break, continue to next state. */ + case BROTLI_STATE_CONTEXT_MAP_DECODE: { + uint32_t context_index = s->context_index; + uint32_t max_run_length_prefix = s->max_run_length_prefix; + uint8_t* context_map = *context_map_arg; + uint32_t code = s->code; + if (code != 0xFFFF) { + goto rleCode; + } + while (context_index < context_map_size) { + if (!SafeReadSymbol(s->context_map_table, br, &code)) { + s->code = 0xFFFF; + s->context_index = context_index; + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + BROTLI_LOG_UINT(code); + + if (code == 0) { + context_map[context_index++] = 0; + continue; + } + if (code > max_run_length_prefix) { + context_map[context_index++] = + (uint8_t)(code - max_run_length_prefix); + continue; + } +rleCode: + { + uint32_t reps; + if (!BrotliSafeReadBits(br, code, &reps)) { + s->code = code; + s->context_index = context_index; + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + reps += 1U << code; + BROTLI_LOG_UINT(reps); + if (context_index + reps > context_map_size) { + return BROTLI_FAILURE(); + } + do { + context_map[context_index++] = 0; + } while (--reps); + } + } + /* No break, continue to next state. */ + } + case BROTLI_STATE_CONTEXT_MAP_TRANSFORM: { + uint32_t bits; + if (!BrotliSafeReadBits(br, 1, &bits)) { + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_TRANSFORM; + return BROTLI_RESULT_NEEDS_MORE_INPUT; + } + if (bits != 0) { + InverseMoveToFrontTransform(*context_map_arg, context_map_size, s); + } + s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE; + return BROTLI_RESULT_SUCCESS; + } + } + + return BROTLI_FAILURE(); +} +","@@ -1700,6 +1700,10 @@ static BROTLI_INLINE BrotliResult ProcessCommandsInternal(int safe, + uint8_t* copy_src = &s->ringbuffer[ + (pos - s->distance_code) & s->ringbuffer_mask]; + uint8_t* copy_dst = &s->ringbuffer[pos]; ++ /* Check for possible underflow and clamp the pointer to 0. */ ++ if (PREDICT_FALSE(s->ringbuffer_end < (const uint8_t*)0 + i)) { ++ ringbuffer_end_minus_copy_length = 0; ++ } + /* update the recent distances cache */ + s->dist_rb[s->dist_rb_idx & 3] = s->distance_code; + ++s->dist_rb_idx;",1052,1288,2048 +11679,"png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_int_32 X0, X1; + png_byte type, nparams; + png_charp buf, units, endptr; + png_charpp params; + png_size_t slength; + int i; + + png_debug(1, ""in png_handle_pCAL""); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, ""Missing IHDR before pCAL""); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, ""Invalid pCAL after IDAT""); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) + { + png_warning(png_ptr, ""Duplicate pCAL chunk""); + png_crc_finish(png_ptr, length); + return; + } + + png_debug1(2, ""Allocating and reading pCAL chunk data (%lu bytes)"", + length + 1); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) + { + png_warning(png_ptr, ""No memory for pCAL purpose.""); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); + + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; + } + + png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ + + png_debug(3, ""Finding end of pCAL purpose string""); + for (buf = png_ptr->chunkdata; *buf; buf++) + /* Empty loop */ ; + + endptr = png_ptr->chunkdata + slength; + + /* We need to have at least 12 bytes after the purpose string + in order to get the parameter information. */ + if (endptr <= buf + 12) + { + png_warning(png_ptr, ""Invalid pCAL data""); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; + } + + png_debug(3, ""Reading pCAL X0, X1, type, nparams, and units""); + X0 = png_get_int_32((png_bytep)buf+1); + X1 = png_get_int_32((png_bytep)buf+5); + type = buf[9]; + nparams = buf[10]; + units = buf + 11; + + png_debug(3, ""Checking pCAL equation type and number of parameters""); + /* Check that we have the right number of parameters for known + equation types. */ + if ((type == PNG_EQUATION_LINEAR && nparams != 2) || + (type == PNG_EQUATION_BASE_E && nparams != 3) || + (type == PNG_EQUATION_ARBITRARY && nparams != 3) || + (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) + { + png_warning(png_ptr, ""Invalid pCAL parameters for equation type""); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; + } + else if (type >= PNG_EQUATION_LAST) + { + png_warning(png_ptr, ""Unrecognized equation type for pCAL chunk""); + } + + for (buf = units; *buf; buf++) + /* Empty loop to move past the units string. */ ; + + png_debug(3, ""Allocating pCAL parameters array""); + params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)(nparams * png_sizeof(png_charp))) ; + if (params == NULL) + { + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_warning(png_ptr, ""No memory for pCAL params.""); + return; + } + + /* Get pointers to the start of each parameter string. */ + for (i = 0; i < (int)nparams; i++) + { + buf++; /* Skip the null string terminator from previous parameter. */ + + png_debug1(3, ""Reading pCAL parameter %d"", i); + for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++) + /* Empty loop to move past each parameter string */ ; + + /* Make sure we haven't run out of data yet */ + if (buf > endptr) + { + png_warning(png_ptr, ""Invalid pCAL data""); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_free(png_ptr, params); + return; + } + } + + png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams, + units, params); + + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_free(png_ptr, params); +} +",0,"png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_int_32 X0, X1; + png_byte type, nparams; + png_charp buf, units, endptr; + png_charpp params; + png_size_t slength; + int i; + + png_debug(1, ""in png_handle_pCAL""); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, ""Missing IHDR before pCAL""); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, ""Invalid pCAL after IDAT""); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) + { + png_warning(png_ptr, ""Duplicate pCAL chunk""); + png_crc_finish(png_ptr, length); + return; + } + + png_debug1(2, ""Allocating and reading pCAL chunk data (%lu bytes)"", + length + 1); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) + { + png_warning(png_ptr, ""No memory for pCAL purpose.""); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); + + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; + } + + png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ + + png_debug(3, ""Finding end of pCAL purpose string""); + for (buf = png_ptr->chunkdata; *buf; buf++) + /* Empty loop */ ; + + endptr = png_ptr->chunkdata + slength; + + /* We need to have at least 12 bytes after the purpose string + in order to get the parameter information. */ + if (endptr <= buf + 12) + { + png_warning(png_ptr, ""Invalid pCAL data""); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; + } + + png_debug(3, ""Reading pCAL X0, X1, type, nparams, and units""); + X0 = png_get_int_32((png_bytep)buf+1); + X1 = png_get_int_32((png_bytep)buf+5); + type = buf[9]; + nparams = buf[10]; + units = buf + 11; + + png_debug(3, ""Checking pCAL equation type and number of parameters""); + /* Check that we have the right number of parameters for known + equation types. */ + if ((type == PNG_EQUATION_LINEAR && nparams != 2) || + (type == PNG_EQUATION_BASE_E && nparams != 3) || + (type == PNG_EQUATION_ARBITRARY && nparams != 3) || + (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) + { + png_warning(png_ptr, ""Invalid pCAL parameters for equation type""); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; + } + else if (type >= PNG_EQUATION_LAST) + { + png_warning(png_ptr, ""Unrecognized equation type for pCAL chunk""); + } + + for (buf = units; *buf; buf++) + /* Empty loop to move past the units string. */ ; + + png_debug(3, ""Allocating pCAL parameters array""); + params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)(nparams * png_sizeof(png_charp))) ; + if (params == NULL) + { + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_warning(png_ptr, ""No memory for pCAL params.""); + return; + } + + /* Get pointers to the start of each parameter string. */ + for (i = 0; i < (int)nparams; i++) + { + buf++; /* Skip the null string terminator from previous parameter. */ + + png_debug1(3, ""Reading pCAL parameter %d"", i); + for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++) + /* Empty loop to move past each parameter string */ ; + + /* Make sure we haven't run out of data yet */ + if (buf > endptr) + { + png_warning(png_ptr, ""Invalid pCAL data""); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_free(png_ptr, params); + return; + } + } + + png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams, + units, params); + + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_free(png_ptr, params); +} +","@@ -247,8 +247,8 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size, + { + if (output != 0 && output_size > count) + { +- int copy = output_size - count; +- if (avail < copy) copy = avail; ++ png_size_t copy = output_size - count; ++ if ((png_size_t) avail < copy) copy = (png_size_t) avail; + png_memcpy(output + count, png_ptr->zbuf, copy); + } + count += avail;",1151,1387,2048 +2519,"static void ieee80211_assign_perm_addr(struct ieee80211_local *local, + struct net_device *dev, + enum nl80211_iftype type) +{ + struct ieee80211_sub_if_data *sdata; + u64 mask, start, addr, val, inc; + u8 *m; + u8 tmp_addr[ETH_ALEN]; + int i; + + /* default ... something at least */ + memcpy(dev->perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN); + + if (is_zero_ether_addr(local->hw.wiphy->addr_mask) && + local->hw.wiphy->n_addresses <= 1) + return; + + + mutex_lock(&local->iflist_mtx); + + switch (type) { + case NL80211_IFTYPE_MONITOR: + /* doesn't matter */ + break; + case NL80211_IFTYPE_WDS: + case NL80211_IFTYPE_AP_VLAN: + /* match up with an AP interface */ + list_for_each_entry(sdata, &local->interfaces, list) { + if (sdata->vif.type != NL80211_IFTYPE_AP) + continue; + memcpy(dev->perm_addr, sdata->vif.addr, ETH_ALEN); + break; + } + /* keep default if no AP interface present */ + break; + default: + /* assign a new address if possible -- try n_addresses first */ + for (i = 0; i < local->hw.wiphy->n_addresses; i++) { + bool used = false; + + list_for_each_entry(sdata, &local->interfaces, list) { + if (memcmp(local->hw.wiphy->addresses[i].addr, + sdata->vif.addr, ETH_ALEN) == 0) { + used = true; + break; + } + } + + if (!used) { + memcpy(dev->perm_addr, + local->hw.wiphy->addresses[i].addr, + ETH_ALEN); + break; + } + } + + /* try mask if available */ + if (is_zero_ether_addr(local->hw.wiphy->addr_mask)) + break; + + m = local->hw.wiphy->addr_mask; + mask = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) | + ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) | + ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8); + + if (__ffs64(mask) + hweight64(mask) != fls64(mask)) { + /* not a contiguous mask ... not handled now! */ + printk(KERN_DEBUG ""not contiguous\n""); + break; + } + + m = local->hw.wiphy->perm_addr; + start = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) | + ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) | + ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8); + + inc = 1ULL<<__ffs64(mask); + val = (start & mask); + addr = (start & ~mask) | (val & mask); + do { + bool used = false; + + tmp_addr[5] = addr >> 0*8; + tmp_addr[4] = addr >> 1*8; + tmp_addr[3] = addr >> 2*8; + tmp_addr[2] = addr >> 3*8; + tmp_addr[1] = addr >> 4*8; + tmp_addr[0] = addr >> 5*8; + + val += inc; + + list_for_each_entry(sdata, &local->interfaces, list) { + if (memcmp(tmp_addr, sdata->vif.addr, + ETH_ALEN) == 0) { + used = true; + break; + } + } + + if (!used) { + memcpy(dev->perm_addr, tmp_addr, ETH_ALEN); + break; + } + addr = (start & ~mask) | (val & mask); + } while (addr != start); + + break; + } + + mutex_unlock(&local->iflist_mtx); +} +",0,"static void ieee80211_assign_perm_addr(struct ieee80211_local *local, + struct net_device *dev, + enum nl80211_iftype type) +{ + struct ieee80211_sub_if_data *sdata; + u64 mask, start, addr, val, inc; + u8 *m; + u8 tmp_addr[ETH_ALEN]; + int i; + + /* default ... something at least */ + memcpy(dev->perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN); + + if (is_zero_ether_addr(local->hw.wiphy->addr_mask) && + local->hw.wiphy->n_addresses <= 1) + return; + + + mutex_lock(&local->iflist_mtx); + + switch (type) { + case NL80211_IFTYPE_MONITOR: + /* doesn't matter */ + break; + case NL80211_IFTYPE_WDS: + case NL80211_IFTYPE_AP_VLAN: + /* match up with an AP interface */ + list_for_each_entry(sdata, &local->interfaces, list) { + if (sdata->vif.type != NL80211_IFTYPE_AP) + continue; + memcpy(dev->perm_addr, sdata->vif.addr, ETH_ALEN); + break; + } + /* keep default if no AP interface present */ + break; + default: + /* assign a new address if possible -- try n_addresses first */ + for (i = 0; i < local->hw.wiphy->n_addresses; i++) { + bool used = false; + + list_for_each_entry(sdata, &local->interfaces, list) { + if (memcmp(local->hw.wiphy->addresses[i].addr, + sdata->vif.addr, ETH_ALEN) == 0) { + used = true; + break; + } + } + + if (!used) { + memcpy(dev->perm_addr, + local->hw.wiphy->addresses[i].addr, + ETH_ALEN); + break; + } + } + + /* try mask if available */ + if (is_zero_ether_addr(local->hw.wiphy->addr_mask)) + break; + + m = local->hw.wiphy->addr_mask; + mask = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) | + ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) | + ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8); + + if (__ffs64(mask) + hweight64(mask) != fls64(mask)) { + /* not a contiguous mask ... not handled now! */ + printk(KERN_DEBUG ""not contiguous\n""); + break; + } + + m = local->hw.wiphy->perm_addr; + start = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) | + ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) | + ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8); + + inc = 1ULL<<__ffs64(mask); + val = (start & mask); + addr = (start & ~mask) | (val & mask); + do { + bool used = false; + + tmp_addr[5] = addr >> 0*8; + tmp_addr[4] = addr >> 1*8; + tmp_addr[3] = addr >> 2*8; + tmp_addr[2] = addr >> 3*8; + tmp_addr[1] = addr >> 4*8; + tmp_addr[0] = addr >> 5*8; + + val += inc; + + list_for_each_entry(sdata, &local->interfaces, list) { + if (memcmp(tmp_addr, sdata->vif.addr, + ETH_ALEN) == 0) { + used = true; + break; + } + } + + if (!used) { + memcpy(dev->perm_addr, tmp_addr, ETH_ALEN); + break; + } + addr = (start & ~mask) | (val & mask); + } while (addr != start); + + break; + } + + mutex_unlock(&local->iflist_mtx); +} +","@@ -698,6 +698,7 @@ static const struct net_device_ops ieee80211_monitorif_ops = { + static void ieee80211_if_setup(struct net_device *dev) + { + ether_setup(dev); ++ dev->priv_flags &= ~IFF_TX_SKB_SHARING; + dev->netdev_ops = &ieee80211_dataif_ops; + dev->destructor = free_netdev; + }",993,1229,2048 +17925,"static long gfs2_fallocate(struct file *file, int mode, loff_t offset, + loff_t len) +{ + struct inode *inode = file->f_path.dentry->d_inode; + struct gfs2_sbd *sdp = GFS2_SB(inode); + struct gfs2_inode *ip = GFS2_I(inode); + unsigned int data_blocks = 0, ind_blocks = 0, rblocks; + loff_t bytes, max_bytes; + struct gfs2_alloc *al; + int error; + loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); + loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; + next = (next + 1) << sdp->sd_sb.sb_bsize_shift; + + /* We only support the FALLOC_FL_KEEP_SIZE mode */ + if (mode & ~FALLOC_FL_KEEP_SIZE) + return -EOPNOTSUPP; + + offset &= bsize_mask; + + len = next - offset; + bytes = sdp->sd_max_rg_data * sdp->sd_sb.sb_bsize / 2; + if (!bytes) + bytes = UINT_MAX; + bytes &= bsize_mask; + if (bytes == 0) + bytes = sdp->sd_sb.sb_bsize; + + gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); + error = gfs2_glock_nq(&ip->i_gh); + if (unlikely(error)) + goto out_uninit; + + if (!gfs2_write_alloc_required(ip, offset, len)) + goto out_unlock; + + while (len > 0) { + if (len < bytes) + bytes = len; + al = gfs2_alloc_get(ip); + if (!al) { + error = -ENOMEM; + goto out_unlock; + } + + error = gfs2_quota_lock_check(ip); + if (error) + goto out_alloc_put; + +retry: + gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); + + al->al_requested = data_blocks + ind_blocks; + error = gfs2_inplace_reserve(ip); + if (error) { + if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { + bytes >>= 1; + bytes &= bsize_mask; + if (bytes == 0) + bytes = sdp->sd_sb.sb_bsize; + goto retry; + } + goto out_qunlock; + } + max_bytes = bytes; + calc_max_reserv(ip, len, &max_bytes, &data_blocks, &ind_blocks); + al->al_requested = data_blocks + ind_blocks; + + rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + + RES_RG_HDR + gfs2_rg_blocks(ip); + if (gfs2_is_jdata(ip)) + rblocks += data_blocks ? data_blocks : 1; + + error = gfs2_trans_begin(sdp, rblocks, + PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize); + if (error) + goto out_trans_fail; + + error = fallocate_chunk(inode, offset, max_bytes, mode); + gfs2_trans_end(sdp); + + if (error) + goto out_trans_fail; + + len -= max_bytes; + offset += max_bytes; + gfs2_inplace_release(ip); + gfs2_quota_unlock(ip); + gfs2_alloc_put(ip); + } + goto out_unlock; + +out_trans_fail: + gfs2_inplace_release(ip); +out_qunlock: + gfs2_quota_unlock(ip); +out_alloc_put: + gfs2_alloc_put(ip); +out_unlock: + gfs2_glock_dq(&ip->i_gh); +out_uninit: + gfs2_holder_uninit(&ip->i_gh); + return error; +} +",1,"static long gfs2_fallocate(struct file *file, int mode, loff_t offset, + loff_t len) +{ + struct inode *inode = file->f_path.dentry->d_inode; + struct gfs2_sbd *sdp = GFS2_SB(inode); + struct gfs2_inode *ip = GFS2_I(inode); + unsigned int data_blocks = 0, ind_blocks = 0, rblocks; + loff_t bytes, max_bytes; + struct gfs2_alloc *al; + int error; + loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); + loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; + loff_t max_chunk_size = UINT_MAX & bsize_mask; + next = (next + 1) << sdp->sd_sb.sb_bsize_shift; + + /* We only support the FALLOC_FL_KEEP_SIZE mode */ + if (mode & ~FALLOC_FL_KEEP_SIZE) + return -EOPNOTSUPP; + + offset &= bsize_mask; + + len = next - offset; + bytes = sdp->sd_max_rg_data * sdp->sd_sb.sb_bsize / 2; + if (!bytes) + bytes = UINT_MAX; + bytes &= bsize_mask; + if (bytes == 0) + bytes = sdp->sd_sb.sb_bsize; + + gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); + error = gfs2_glock_nq(&ip->i_gh); + if (unlikely(error)) + goto out_uninit; + + if (!gfs2_write_alloc_required(ip, offset, len)) + goto out_unlock; + + while (len > 0) { + if (len < bytes) + bytes = len; + al = gfs2_alloc_get(ip); + if (!al) { + error = -ENOMEM; + goto out_unlock; + } + + error = gfs2_quota_lock_check(ip); + if (error) + goto out_alloc_put; + +retry: + gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); + + al->al_requested = data_blocks + ind_blocks; + error = gfs2_inplace_reserve(ip); + if (error) { + if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { + bytes >>= 1; + bytes &= bsize_mask; + if (bytes == 0) + bytes = sdp->sd_sb.sb_bsize; + goto retry; + } + goto out_qunlock; + } + max_bytes = bytes; + calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len, + &max_bytes, &data_blocks, &ind_blocks); + al->al_requested = data_blocks + ind_blocks; + + rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + + RES_RG_HDR + gfs2_rg_blocks(ip); + if (gfs2_is_jdata(ip)) + rblocks += data_blocks ? data_blocks : 1; + + error = gfs2_trans_begin(sdp, rblocks, + PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize); + if (error) + goto out_trans_fail; + + error = fallocate_chunk(inode, offset, max_bytes, mode); + gfs2_trans_end(sdp); + + if (error) + goto out_trans_fail; + + len -= max_bytes; + offset += max_bytes; + gfs2_inplace_release(ip); + gfs2_quota_unlock(ip); + gfs2_alloc_put(ip); + } + goto out_unlock; + +out_trans_fail: + gfs2_inplace_release(ip); +out_qunlock: + gfs2_quota_unlock(ip); +out_alloc_put: + gfs2_alloc_put(ip); +out_unlock: + gfs2_glock_dq(&ip->i_gh); +out_uninit: + gfs2_holder_uninit(&ip->i_gh); + return error; +} +","@@ -669,135 +669,18 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, + return generic_file_aio_write(iocb, iov, nr_segs, pos); + } + +-static int empty_write_end(struct page *page, unsigned from, +- unsigned to, int mode) +-{ +- struct inode *inode = page->mapping->host; +- struct gfs2_inode *ip = GFS2_I(inode); +- struct buffer_head *bh; +- unsigned offset, blksize = 1 << inode->i_blkbits; +- pgoff_t end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT; +- +- zero_user(page, from, to-from); +- mark_page_accessed(page); +- +- if (page->index < end_index || !(mode & FALLOC_FL_KEEP_SIZE)) { +- if (!gfs2_is_writeback(ip)) +- gfs2_page_add_databufs(ip, page, from, to); +- +- block_commit_write(page, from, to); +- return 0; +- } +- +- offset = 0; +- bh = page_buffers(page); +- while (offset < to) { +- if (offset >= from) { +- set_buffer_uptodate(bh); +- mark_buffer_dirty(bh); +- clear_buffer_new(bh); +- write_dirty_buffer(bh, WRITE); +- } +- offset += blksize; +- bh = bh->b_this_page; +- } +- +- offset = 0; +- bh = page_buffers(page); +- while (offset < to) { +- if (offset >= from) { +- wait_on_buffer(bh); +- if (!buffer_uptodate(bh)) +- return -EIO; +- } +- offset += blksize; +- bh = bh->b_this_page; +- } +- return 0; +-} +- +-static int needs_empty_write(sector_t block, struct inode *inode) +-{ +- int error; +- struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 }; +- +- bh_map.b_size = 1 << inode->i_blkbits; +- error = gfs2_block_map(inode, block, &bh_map, 0); +- if (unlikely(error)) +- return error; +- return !buffer_mapped(&bh_map); +-} +- +-static int write_empty_blocks(struct page *page, unsigned from, unsigned to, +- int mode) +-{ +- struct inode *inode = page->mapping->host; +- unsigned start, end, next, blksize; +- sector_t block = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); +- int ret; +- +- blksize = 1 << inode->i_blkbits; +- next = end = 0; +- while (next < from) { +- next += blksize; +- block++; +- } +- start = next; +- do { +- next += blksize; +- ret = needs_empty_write(block, inode); +- if (unlikely(ret < 0)) +- return ret; +- if (ret == 0) { +- if (end) { +- ret = __block_write_begin(page, start, end - start, +- gfs2_block_map); +- if (unlikely(ret)) +- return ret; +- ret = empty_write_end(page, start, end, mode); +- if (unlikely(ret)) +- return ret; +- end = 0; +- } +- start = next; +- } +- else +- end = next; +- block++; +- } while (next < to); +- +- if (end) { +- ret = __block_write_begin(page, start, end - start, gfs2_block_map); +- if (unlikely(ret)) +- return ret; +- ret = empty_write_end(page, start, end, mode); +- if (unlikely(ret)) +- return ret; +- } +- +- return 0; +-} +- + static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len, + int mode) + { + struct gfs2_inode *ip = GFS2_I(inode); + struct buffer_head *dibh; + int error; +- u64 start = offset >> PAGE_CACHE_SHIFT; +- unsigned int start_offset = offset & ~PAGE_CACHE_MASK; +- u64 end = (offset + len - 1) >> PAGE_CACHE_SHIFT; +- pgoff_t curr; +- struct page *page; +- unsigned int end_offset = (offset + len) & ~PAGE_CACHE_MASK; +- unsigned int from, to; +- +- if (!end_offset) +- end_offset = PAGE_CACHE_SIZE; ++ unsigned int nr_blks; ++ sector_t lblock = offset >> inode->i_blkbits; + + error = gfs2_meta_inode_buffer(ip, &dibh); + if (unlikely(error)) +- goto out; ++ return error; + + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + +@@ -807,39 +690,31 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len, + goto out; + } + +- curr = start; +- offset = start << PAGE_CACHE_SHIFT; +- from = start_offset; +- to = PAGE_CACHE_SIZE; +- while (curr <= end) { +- page = grab_cache_page_write_begin(inode->i_mapping, curr, +- AOP_FLAG_NOFS); +- if (unlikely(!page)) { +- error = -ENOMEM; +- goto out; +- } ++ while (len) { ++ struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 }; ++ bh_map.b_size = len; ++ set_buffer_zeronew(&bh_map); + +- if (curr == end) +- to = end_offset; +- error = write_empty_blocks(page, from, to, mode); +- if (!error && offset + to > inode->i_size && +- !(mode & FALLOC_FL_KEEP_SIZE)) { +- i_size_write(inode, offset + to); +- } +- unlock_page(page); +- page_cache_release(page); +- if (error) ++ error = gfs2_block_map(inode, lblock, &bh_map, 1); ++ if (unlikely(error)) + goto out; +- curr++; +- offset += PAGE_CACHE_SIZE; +- from = 0; ++ len -= bh_map.b_size; ++ nr_blks = bh_map.b_size >> inode->i_blkbits; ++ lblock += nr_blks; ++ if (!buffer_new(&bh_map)) ++ continue; ++ if (unlikely(!buffer_zeronew(&bh_map))) { ++ error = -EIO; ++ goto out; ++ } + } ++ if (offset + len > inode->i_size && !(mode & FALLOC_FL_KEEP_SIZE)) ++ i_size_write(inode, offset + len); + + mark_inode_dirty(inode); + +- brelse(dibh); +- + out: ++ brelse(dibh); + return error; + } + +@@ -879,6 +754,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, + int error; + loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); + loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; ++ loff_t max_chunk_size = UINT_MAX & bsize_mask; + next = (next + 1) << sdp->sd_sb.sb_bsize_shift; + + /* We only support the FALLOC_FL_KEEP_SIZE mode */ +@@ -932,7 +808,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, + goto out_qunlock; + } + max_bytes = bytes; +- calc_max_reserv(ip, len, &max_bytes, &data_blocks, &ind_blocks); ++ calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len, ++ &max_bytes, &data_blocks, &ind_blocks); + al->al_requested = data_blocks + ind_blocks; + + rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA +",832,1068,2048 +3794,"sctp_disposition_t sctp_sf_do_5_1B_init(struct net *net, + const struct sctp_endpoint *ep, + const struct sctp_association *asoc, + const sctp_subtype_t type, + void *arg, + sctp_cmd_seq_t *commands) +{ + struct sctp_chunk *chunk = arg; + struct sctp_chunk *repl; + struct sctp_association *new_asoc; + struct sctp_chunk *err_chunk; + struct sctp_packet *packet; + sctp_unrecognized_param_t *unk_param; + int len; + + /* 6.10 Bundling + * An endpoint MUST NOT bundle INIT, INIT ACK or + * SHUTDOWN COMPLETE with any other chunks. + * + * IG Section 2.11.2 + * Furthermore, we require that the receiver of an INIT chunk MUST + * enforce these rules by silently discarding an arriving packet + * with an INIT chunk that is bundled with other chunks. + */ + if (!chunk->singleton) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + /* If the packet is an OOTB packet which is temporarily on the + * control endpoint, respond with an ABORT. + */ + if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { + SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + } + + /* 3.1 A packet containing an INIT chunk MUST have a zero Verification + * Tag. + */ + if (chunk->sctp_hdr->vtag != 0) + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + + /* Make sure that the INIT chunk has a valid length. + * Normally, this would cause an ABORT with a Protocol Violation + * error, but since we don't have an association, we'll + * just discard the packet. + */ + if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + /* If the INIT is coming toward a closing socket, we'll send back + * and ABORT. Essentially, this catches the race of INIT being + * backloged to the socket at the same time as the user isses close(). + * Since the socket and all its associations are going away, we + * can treat this OOTB + */ + if (sctp_sstate(ep->base.sk, CLOSING)) + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + + /* Verify the INIT chunk before processing it. */ + err_chunk = NULL; + if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, + (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, + &err_chunk)) { + /* This chunk contains fatal error. It is to be discarded. + * Send an ABORT, with causes if there is any. + */ + if (err_chunk) { + packet = sctp_abort_pkt_new(net, ep, asoc, arg, + (__u8 *)(err_chunk->chunk_hdr) + + sizeof(sctp_chunkhdr_t), + ntohs(err_chunk->chunk_hdr->length) - + sizeof(sctp_chunkhdr_t)); + + sctp_chunk_free(err_chunk); + + if (packet) { + sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, + SCTP_PACKET(packet)); + SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); + return SCTP_DISPOSITION_CONSUME; + } else { + return SCTP_DISPOSITION_NOMEM; + } + } else { + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, + commands); + } + } + + /* Grab the INIT header. */ + chunk->subh.init_hdr = (sctp_inithdr_t *)chunk->skb->data; + + /* Tag the variable length parameters. */ + chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(sctp_inithdr_t)); + + new_asoc = sctp_make_temp_asoc(ep, chunk, GFP_ATOMIC); + if (!new_asoc) + goto nomem; + + if (sctp_assoc_set_bind_addr_from_ep(new_asoc, + sctp_scope(sctp_source(chunk)), + GFP_ATOMIC) < 0) + goto nomem_init; + + /* The call, sctp_process_init(), can fail on memory allocation. */ + if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), + (sctp_init_chunk_t *)chunk->chunk_hdr, + GFP_ATOMIC)) + goto nomem_init; + + /* B) ""Z"" shall respond immediately with an INIT ACK chunk. */ + + /* If there are errors need to be reported for unknown parameters, + * make sure to reserve enough room in the INIT ACK for them. + */ + len = 0; + if (err_chunk) + len = ntohs(err_chunk->chunk_hdr->length) - + sizeof(sctp_chunkhdr_t); + + repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); + if (!repl) + goto nomem_init; + + /* If there are errors need to be reported for unknown parameters, + * include them in the outgoing INIT ACK as ""Unrecognized parameter"" + * parameter. + */ + if (err_chunk) { + /* Get the ""Unrecognized parameter"" parameter(s) out of the + * ERROR chunk generated by sctp_verify_init(). Since the + * error cause code for ""unknown parameter"" and the + * ""Unrecognized parameter"" type is the same, we can + * construct the parameters in INIT ACK by copying the + * ERROR causes over. + */ + unk_param = (sctp_unrecognized_param_t *) + ((__u8 *)(err_chunk->chunk_hdr) + + sizeof(sctp_chunkhdr_t)); + /* Replace the cause code with the ""Unrecognized parameter"" + * parameter type. + */ + sctp_addto_chunk(repl, len, unk_param); + sctp_chunk_free(err_chunk); + } + + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); + + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); + + /* + * Note: After sending out INIT ACK with the State Cookie parameter, + * ""Z"" MUST NOT allocate any resources, nor keep any states for the + * new association. Otherwise, ""Z"" will be vulnerable to resource + * attacks. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); + + return SCTP_DISPOSITION_DELETE_TCB; + +nomem_init: + sctp_association_free(new_asoc); +nomem: + if (err_chunk) + sctp_chunk_free(err_chunk); + return SCTP_DISPOSITION_NOMEM; +} +",0,"sctp_disposition_t sctp_sf_do_5_1B_init(struct net *net, + const struct sctp_endpoint *ep, + const struct sctp_association *asoc, + const sctp_subtype_t type, + void *arg, + sctp_cmd_seq_t *commands) +{ + struct sctp_chunk *chunk = arg; + struct sctp_chunk *repl; + struct sctp_association *new_asoc; + struct sctp_chunk *err_chunk; + struct sctp_packet *packet; + sctp_unrecognized_param_t *unk_param; + int len; + + /* 6.10 Bundling + * An endpoint MUST NOT bundle INIT, INIT ACK or + * SHUTDOWN COMPLETE with any other chunks. + * + * IG Section 2.11.2 + * Furthermore, we require that the receiver of an INIT chunk MUST + * enforce these rules by silently discarding an arriving packet + * with an INIT chunk that is bundled with other chunks. + */ + if (!chunk->singleton) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + /* If the packet is an OOTB packet which is temporarily on the + * control endpoint, respond with an ABORT. + */ + if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { + SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + } + + /* 3.1 A packet containing an INIT chunk MUST have a zero Verification + * Tag. + */ + if (chunk->sctp_hdr->vtag != 0) + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + + /* Make sure that the INIT chunk has a valid length. + * Normally, this would cause an ABORT with a Protocol Violation + * error, but since we don't have an association, we'll + * just discard the packet. + */ + if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + /* If the INIT is coming toward a closing socket, we'll send back + * and ABORT. Essentially, this catches the race of INIT being + * backloged to the socket at the same time as the user isses close(). + * Since the socket and all its associations are going away, we + * can treat this OOTB + */ + if (sctp_sstate(ep->base.sk, CLOSING)) + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + + /* Verify the INIT chunk before processing it. */ + err_chunk = NULL; + if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, + (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, + &err_chunk)) { + /* This chunk contains fatal error. It is to be discarded. + * Send an ABORT, with causes if there is any. + */ + if (err_chunk) { + packet = sctp_abort_pkt_new(net, ep, asoc, arg, + (__u8 *)(err_chunk->chunk_hdr) + + sizeof(sctp_chunkhdr_t), + ntohs(err_chunk->chunk_hdr->length) - + sizeof(sctp_chunkhdr_t)); + + sctp_chunk_free(err_chunk); + + if (packet) { + sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, + SCTP_PACKET(packet)); + SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); + return SCTP_DISPOSITION_CONSUME; + } else { + return SCTP_DISPOSITION_NOMEM; + } + } else { + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, + commands); + } + } + + /* Grab the INIT header. */ + chunk->subh.init_hdr = (sctp_inithdr_t *)chunk->skb->data; + + /* Tag the variable length parameters. */ + chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(sctp_inithdr_t)); + + new_asoc = sctp_make_temp_asoc(ep, chunk, GFP_ATOMIC); + if (!new_asoc) + goto nomem; + + if (sctp_assoc_set_bind_addr_from_ep(new_asoc, + sctp_scope(sctp_source(chunk)), + GFP_ATOMIC) < 0) + goto nomem_init; + + /* The call, sctp_process_init(), can fail on memory allocation. */ + if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), + (sctp_init_chunk_t *)chunk->chunk_hdr, + GFP_ATOMIC)) + goto nomem_init; + + /* B) ""Z"" shall respond immediately with an INIT ACK chunk. */ + + /* If there are errors need to be reported for unknown parameters, + * make sure to reserve enough room in the INIT ACK for them. + */ + len = 0; + if (err_chunk) + len = ntohs(err_chunk->chunk_hdr->length) - + sizeof(sctp_chunkhdr_t); + + repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); + if (!repl) + goto nomem_init; + + /* If there are errors need to be reported for unknown parameters, + * include them in the outgoing INIT ACK as ""Unrecognized parameter"" + * parameter. + */ + if (err_chunk) { + /* Get the ""Unrecognized parameter"" parameter(s) out of the + * ERROR chunk generated by sctp_verify_init(). Since the + * error cause code for ""unknown parameter"" and the + * ""Unrecognized parameter"" type is the same, we can + * construct the parameters in INIT ACK by copying the + * ERROR causes over. + */ + unk_param = (sctp_unrecognized_param_t *) + ((__u8 *)(err_chunk->chunk_hdr) + + sizeof(sctp_chunkhdr_t)); + /* Replace the cause code with the ""Unrecognized parameter"" + * parameter type. + */ + sctp_addto_chunk(repl, len, unk_param); + sctp_chunk_free(err_chunk); + } + + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); + + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); + + /* + * Note: After sending out INIT ACK with the State Cookie parameter, + * ""Z"" MUST NOT allocate any resources, nor keep any states for the + * new association. Otherwise, ""Z"" will be vulnerable to resource + * attacks. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); + + return SCTP_DISPOSITION_DELETE_TCB; + +nomem_init: + sctp_association_free(new_asoc); +nomem: + if (err_chunk) + sctp_chunk_free(err_chunk); + return SCTP_DISPOSITION_NOMEM; +} +","@@ -170,6 +170,9 @@ sctp_chunk_length_valid(struct sctp_chunk *chunk, + { + __u16 chunk_length = ntohs(chunk->chunk_hdr->length); + ++ /* Previously already marked? */ ++ if (unlikely(chunk->pdiscard)) ++ return 0; + if (unlikely(chunk_length < required_length)) + return 0; + ",1529,1765,2048 +8878,"MagickExport MagickBooleanType HaldClutImage(Image *image, + const Image *hald_image,ExceptionInfo *exception) +{ +#define HaldClutImageTag ""Clut/Image"" + + typedef struct _HaldInfo + { + double + x, + y, + z; + } HaldInfo; + + CacheView + *hald_view, + *image_view; + + double + width; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + PixelInfo + zero; + + size_t + cube_size, + length, + level; + + ssize_t + y; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(hald_image != (Image *) NULL); + assert(hald_image->signature == MagickCoreSignature); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + if (image->alpha_trait == UndefinedPixelTrait) + (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); + /* + Hald clut image. + */ + status=MagickTrue; + progress=0; + length=(size_t) MagickMin((MagickRealType) hald_image->columns, + (MagickRealType) hald_image->rows); + for (level=2; (level*level*level) < length; level++) ; + level*=level; + cube_size=level*level; + width=(double) hald_image->columns; + GetPixelInfo(hald_image,&zero); + hald_view=AcquireVirtualCacheView(hald_image,exception); + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + double + offset; + + HaldInfo + point; + + PixelInfo + pixel, + pixel1, + pixel2, + pixel3, + pixel4; + + point.x=QuantumScale*(level-1.0)*GetPixelRed(image,q); + point.y=QuantumScale*(level-1.0)*GetPixelGreen(image,q); + point.z=QuantumScale*(level-1.0)*GetPixelBlue(image,q); + offset=point.x+level*floor(point.y)+cube_size*floor(point.z); + point.x-=floor(point.x); + point.y-=floor(point.y); + point.z-=floor(point.z); + pixel1=zero; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset,width),floor(offset/width),&pixel1,exception); + if (status == MagickFalse) + break; + pixel2=zero; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset+level,width),floor((offset+level)/width),&pixel2,exception); + if (status == MagickFalse) + break; + pixel3=zero; + CompositePixelInfoAreaBlend(&pixel1,pixel1.alpha,&pixel2,pixel2.alpha, + point.y,&pixel3); + offset+=cube_size; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset,width),floor(offset/width),&pixel1,exception); + if (status == MagickFalse) + break; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset+level,width),floor((offset+level)/width),&pixel2,exception); + if (status == MagickFalse) + break; + pixel4=zero; + CompositePixelInfoAreaBlend(&pixel1,pixel1.alpha,&pixel2,pixel2.alpha, + point.y,&pixel4); + pixel=zero; + CompositePixelInfoAreaBlend(&pixel3,pixel3.alpha,&pixel4,pixel4.alpha, + point.z,&pixel); + if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) + SetPixelRed(image,ClampToQuantum(pixel.red),q); + if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) + SetPixelGreen(image,ClampToQuantum(pixel.green),q); + if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) + SetPixelBlue(image,ClampToQuantum(pixel.blue),q); + if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && + (image->colorspace == CMYKColorspace)) + SetPixelBlack(image,ClampToQuantum(pixel.black),q); + if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && + (image->alpha_trait != UndefinedPixelTrait)) + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,HaldClutImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + hald_view=DestroyCacheView(hald_view); + image_view=DestroyCacheView(image_view); + return(status); +} +",0,"MagickExport MagickBooleanType HaldClutImage(Image *image, + const Image *hald_image,ExceptionInfo *exception) +{ +#define HaldClutImageTag ""Clut/Image"" + + typedef struct _HaldInfo + { + double + x, + y, + z; + } HaldInfo; + + CacheView + *hald_view, + *image_view; + + double + width; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + PixelInfo + zero; + + size_t + cube_size, + length, + level; + + ssize_t + y; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(hald_image != (Image *) NULL); + assert(hald_image->signature == MagickCoreSignature); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + if (image->alpha_trait == UndefinedPixelTrait) + (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); + /* + Hald clut image. + */ + status=MagickTrue; + progress=0; + length=(size_t) MagickMin((MagickRealType) hald_image->columns, + (MagickRealType) hald_image->rows); + for (level=2; (level*level*level) < length; level++) ; + level*=level; + cube_size=level*level; + width=(double) hald_image->columns; + GetPixelInfo(hald_image,&zero); + hald_view=AcquireVirtualCacheView(hald_image,exception); + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + double + offset; + + HaldInfo + point; + + PixelInfo + pixel, + pixel1, + pixel2, + pixel3, + pixel4; + + point.x=QuantumScale*(level-1.0)*GetPixelRed(image,q); + point.y=QuantumScale*(level-1.0)*GetPixelGreen(image,q); + point.z=QuantumScale*(level-1.0)*GetPixelBlue(image,q); + offset=point.x+level*floor(point.y)+cube_size*floor(point.z); + point.x-=floor(point.x); + point.y-=floor(point.y); + point.z-=floor(point.z); + pixel1=zero; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset,width),floor(offset/width),&pixel1,exception); + if (status == MagickFalse) + break; + pixel2=zero; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset+level,width),floor((offset+level)/width),&pixel2,exception); + if (status == MagickFalse) + break; + pixel3=zero; + CompositePixelInfoAreaBlend(&pixel1,pixel1.alpha,&pixel2,pixel2.alpha, + point.y,&pixel3); + offset+=cube_size; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset,width),floor(offset/width),&pixel1,exception); + if (status == MagickFalse) + break; + status=InterpolatePixelInfo(hald_image,hald_view,hald_image->interpolate, + fmod(offset+level,width),floor((offset+level)/width),&pixel2,exception); + if (status == MagickFalse) + break; + pixel4=zero; + CompositePixelInfoAreaBlend(&pixel1,pixel1.alpha,&pixel2,pixel2.alpha, + point.y,&pixel4); + pixel=zero; + CompositePixelInfoAreaBlend(&pixel3,pixel3.alpha,&pixel4,pixel4.alpha, + point.z,&pixel); + if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) + SetPixelRed(image,ClampToQuantum(pixel.red),q); + if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) + SetPixelGreen(image,ClampToQuantum(pixel.green),q); + if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) + SetPixelBlue(image,ClampToQuantum(pixel.blue),q); + if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && + (image->colorspace == CMYKColorspace)) + SetPixelBlack(image,ClampToQuantum(pixel.black),q); + if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && + (image->alpha_trait != UndefinedPixelTrait)) + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,HaldClutImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + hald_view=DestroyCacheView(hald_view); + image_view=DestroyCacheView(image_view); + return(status); +} +","@@ -1973,7 +1973,7 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception) + pixel.black=((aggregate.black+total_weight/2.0)/total_weight); + pixel.alpha=((aggregate.alpha+total_weight/2.0)/total_weight); + } +- SetPixelViaPixelInfo(image,&pixel,q); ++ SetPixelViaPixelInfo(enhance_image,&pixel,q); + p+=GetPixelChannels(image); + q+=GetPixelChannels(enhance_image); + }",1366,1602,2048 +18156,"static int http_receive_data(HTTPContext *c) +{ + HTTPContext *c1; + int len, loop_run = 0; + + while (c->chunked_encoding && !c->chunk_size && + c->buffer_end > c->buffer_ptr) { + /* read chunk header, if present */ + len = recv(c->fd, c->buffer_ptr, 1, 0); + + if (len < 0) { + if (ff_neterrno() != AVERROR(EAGAIN) && + ff_neterrno() != AVERROR(EINTR)) + /* error : close connection */ + goto fail; + return 0; + } else if (len == 0) { + /* end of connection : close it */ + goto fail; + } else if (c->buffer_ptr - c->buffer >= 2 && + !memcmp(c->buffer_ptr - 1, ""\r\n"", 2)) { + c->chunk_size = strtol(c->buffer, 0, 16); + if (c->chunk_size == 0) // end of stream + goto fail; + c->buffer_ptr = c->buffer; + break; + } else if (++loop_run > 10) + /* no chunk header, abort */ + goto fail; + else + c->buffer_ptr++; + } + + if (c->buffer_end > c->buffer_ptr) { + len = recv(c->fd, c->buffer_ptr, + FFMIN(c->chunk_size, c->buffer_end - c->buffer_ptr), 0); + if (len < 0) { + if (ff_neterrno() != AVERROR(EAGAIN) && + ff_neterrno() != AVERROR(EINTR)) + /* error : close connection */ + goto fail; + } else if (len == 0) + /* end of connection : close it */ + goto fail; + else { + c->chunk_size -= len; + c->buffer_ptr += len; + c->data_count += len; + update_datarate(&c->datarate, c->data_count); + } + } + + if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) { + if (c->buffer[0] != 'f' || + c->buffer[1] != 'm') { + http_log(""Feed stream has become desynchronized -- disconnecting\n""); + goto fail; + } + } + + if (c->buffer_ptr >= c->buffer_end) { + FFServerStream *feed = c->stream; + /* a packet has been received : write it in the store, except + * if header */ + if (c->data_count > FFM_PACKET_SIZE) { + /* XXX: use llseek or url_seek + * XXX: Should probably fail? */ + if (lseek(c->feed_fd, feed->feed_write_index, SEEK_SET) == -1) + http_log(""Seek to %""PRId64"" failed\n"", feed->feed_write_index); + + if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) { + http_log(""Error writing to feed file: %s\n"", strerror(errno)); + goto fail; + } + + feed->feed_write_index += FFM_PACKET_SIZE; + /* update file size */ + if (feed->feed_write_index > c->stream->feed_size) + feed->feed_size = feed->feed_write_index; + + /* handle wrap around if max file size reached */ + if (c->stream->feed_max_size && + feed->feed_write_index >= c->stream->feed_max_size) + feed->feed_write_index = FFM_PACKET_SIZE; + + /* write index */ + if (ffm_write_write_index(c->feed_fd, feed->feed_write_index) < 0) { + http_log(""Error writing index to feed file: %s\n"", + strerror(errno)); + goto fail; + } + + /* wake up any waiting connections */ + for(c1 = first_http_ctx; c1; c1 = c1->next) { + if (c1->state == HTTPSTATE_WAIT_FEED && + c1->stream->feed == c->stream->feed) + c1->state = HTTPSTATE_SEND_DATA; + } + } else { + /* We have a header in our hands that contains useful data */ + AVFormatContext *s = avformat_alloc_context(); + AVIOContext *pb; + AVInputFormat *fmt_in; + int i; + + if (!s) + goto fail; + + /* use feed output format name to find corresponding input format */ + fmt_in = av_find_input_format(feed->fmt->name); + if (!fmt_in) + goto fail; + + pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer, + 0, NULL, NULL, NULL, NULL); + if (!pb) + goto fail; + + pb->seekable = 0; + + s->pb = pb; + if (avformat_open_input(&s, c->stream->feed_filename, fmt_in, NULL) < 0) { + av_freep(&pb); + goto fail; + } + + /* Now we have the actual streams */ + if (s->nb_streams != feed->nb_streams) { + avformat_close_input(&s); + av_freep(&pb); + http_log(""Feed '%s' stream number does not match registered feed\n"", + c->stream->feed_filename); + goto fail; + } + + for (i = 0; i < s->nb_streams; i++) { + LayeredAVStream *fst = feed->streams[i]; + AVStream *st = s->streams[i]; + avcodec_parameters_to_context(fst->codec, st->codecpar); + avcodec_parameters_from_context(fst->codecpar, fst->codec); + } + + avformat_close_input(&s); + av_freep(&pb); + } + c->buffer_ptr = c->buffer; + } + + return 0; + fail: + c->stream->feed_opened = 0; + close(c->feed_fd); + /* wake up any waiting connections to stop waiting for feed */ + for(c1 = first_http_ctx; c1; c1 = c1->next) { + if (c1->state == HTTPSTATE_WAIT_FEED && + c1->stream->feed == c->stream->feed) + c1->state = HTTPSTATE_SEND_DATA_TRAILER; + } + return -1; +} +",1,"static int http_receive_data(HTTPContext *c) +{ + HTTPContext *c1; + int len, loop_run = 0; + + while (c->chunked_encoding && !c->chunk_size && + c->buffer_end > c->buffer_ptr) { + /* read chunk header, if present */ + len = recv(c->fd, c->buffer_ptr, 1, 0); + + if (len < 0) { + if (ff_neterrno() != AVERROR(EAGAIN) && + ff_neterrno() != AVERROR(EINTR)) + /* error : close connection */ + goto fail; + return 0; + } else if (len == 0) { + /* end of connection : close it */ + goto fail; + } else if (c->buffer_ptr - c->buffer >= 2 && + !memcmp(c->buffer_ptr - 1, ""\r\n"", 2)) { + c->chunk_size = strtol(c->buffer, 0, 16); + if (c->chunk_size <= 0) { // end of stream or invalid chunk size + c->chunk_size = 0; + goto fail; + } + c->buffer_ptr = c->buffer; + break; + } else if (++loop_run > 10) + /* no chunk header, abort */ + goto fail; + else + c->buffer_ptr++; + } + + if (c->buffer_end > c->buffer_ptr) { + len = recv(c->fd, c->buffer_ptr, + FFMIN(c->chunk_size, c->buffer_end - c->buffer_ptr), 0); + if (len < 0) { + if (ff_neterrno() != AVERROR(EAGAIN) && + ff_neterrno() != AVERROR(EINTR)) + /* error : close connection */ + goto fail; + } else if (len == 0) + /* end of connection : close it */ + goto fail; + else { + av_assert0(len <= c->chunk_size); + c->chunk_size -= len; + c->buffer_ptr += len; + c->data_count += len; + update_datarate(&c->datarate, c->data_count); + } + } + + if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) { + if (c->buffer[0] != 'f' || + c->buffer[1] != 'm') { + http_log(""Feed stream has become desynchronized -- disconnecting\n""); + goto fail; + } + } + + if (c->buffer_ptr >= c->buffer_end) { + FFServerStream *feed = c->stream; + /* a packet has been received : write it in the store, except + * if header */ + if (c->data_count > FFM_PACKET_SIZE) { + /* XXX: use llseek or url_seek + * XXX: Should probably fail? */ + if (lseek(c->feed_fd, feed->feed_write_index, SEEK_SET) == -1) + http_log(""Seek to %""PRId64"" failed\n"", feed->feed_write_index); + + if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) { + http_log(""Error writing to feed file: %s\n"", strerror(errno)); + goto fail; + } + + feed->feed_write_index += FFM_PACKET_SIZE; + /* update file size */ + if (feed->feed_write_index > c->stream->feed_size) + feed->feed_size = feed->feed_write_index; + + /* handle wrap around if max file size reached */ + if (c->stream->feed_max_size && + feed->feed_write_index >= c->stream->feed_max_size) + feed->feed_write_index = FFM_PACKET_SIZE; + + /* write index */ + if (ffm_write_write_index(c->feed_fd, feed->feed_write_index) < 0) { + http_log(""Error writing index to feed file: %s\n"", + strerror(errno)); + goto fail; + } + + /* wake up any waiting connections */ + for(c1 = first_http_ctx; c1; c1 = c1->next) { + if (c1->state == HTTPSTATE_WAIT_FEED && + c1->stream->feed == c->stream->feed) + c1->state = HTTPSTATE_SEND_DATA; + } + } else { + /* We have a header in our hands that contains useful data */ + AVFormatContext *s = avformat_alloc_context(); + AVIOContext *pb; + AVInputFormat *fmt_in; + int i; + + if (!s) + goto fail; + + /* use feed output format name to find corresponding input format */ + fmt_in = av_find_input_format(feed->fmt->name); + if (!fmt_in) + goto fail; + + pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer, + 0, NULL, NULL, NULL, NULL); + if (!pb) + goto fail; + + pb->seekable = 0; + + s->pb = pb; + if (avformat_open_input(&s, c->stream->feed_filename, fmt_in, NULL) < 0) { + av_freep(&pb); + goto fail; + } + + /* Now we have the actual streams */ + if (s->nb_streams != feed->nb_streams) { + avformat_close_input(&s); + av_freep(&pb); + http_log(""Feed '%s' stream number does not match registered feed\n"", + c->stream->feed_filename); + goto fail; + } + + for (i = 0; i < s->nb_streams; i++) { + LayeredAVStream *fst = feed->streams[i]; + AVStream *st = s->streams[i]; + avcodec_parameters_to_context(fst->codec, st->codecpar); + avcodec_parameters_from_context(fst->codecpar, fst->codec); + } + + avformat_close_input(&s); + av_freep(&pb); + } + c->buffer_ptr = c->buffer; + } + + return 0; + fail: + c->stream->feed_opened = 0; + close(c->feed_fd); + /* wake up any waiting connections to stop waiting for feed */ + for(c1 = first_http_ctx; c1; c1 = c1->next) { + if (c1->state == HTTPSTATE_WAIT_FEED && + c1->stream->feed == c->stream->feed) + c1->state = HTTPSTATE_SEND_DATA_TRAILER; + } + return -1; +} +","@@ -2738,8 +2738,10 @@ static int http_receive_data(HTTPContext *c) + } else if (c->buffer_ptr - c->buffer >= 2 && + !memcmp(c->buffer_ptr - 1, ""\r\n"", 2)) { + c->chunk_size = strtol(c->buffer, 0, 16); +- if (c->chunk_size == 0) // end of stream ++ if (c->chunk_size <= 0) { // end of stream or invalid chunk size ++ c->chunk_size = 0; + goto fail; ++ } + c->buffer_ptr = c->buffer; + break; + } else if (++loop_run > 10) +@@ -2761,6 +2763,7 @@ static int http_receive_data(HTTPContext *c) + /* end of connection : close it */ + goto fail; + else { ++ av_assert0(len <= c->chunk_size); + c->chunk_size -= len; + c->buffer_ptr += len; + c->data_count += len;",1380,1616,2048 +4568,"int ssl3_send_server_hello(SSL *s) + { + unsigned char *buf; + unsigned char *p,*d; + int i,sl; + int al = 0; + unsigned long l; + + if (s->state == SSL3_ST_SW_SRVR_HELLO_A) + { + buf=(unsigned char *)s->init_buf->data; +#ifdef OPENSSL_NO_TLSEXT + p=s->s3->server_random; + if (ssl_fill_hello_random(s, 1, p, SSL3_RANDOM_SIZE) <= 0) + return -1; +#endif + /* Do the message type and length last */ + d=p= ssl_handshake_start(s); + + *(p++)=s->version>>8; + *(p++)=s->version&0xff; + + /* Random stuff */ + memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); + p+=SSL3_RANDOM_SIZE; + + /*- + * There are several cases for the session ID to send + * back in the server hello: + * - For session reuse from the session cache, + * we send back the old session ID. + * - If stateless session reuse (using a session ticket) + * is successful, we send back the client's ""session ID"" + * (which doesn't actually identify the session). + * - If it is a new session, we send back the new + * session ID. + * - However, if we want the new session to be single-use, + * we send back a 0-length session ID. + * s->hit is non-zero in either case of session reuse, + * so the following won't overwrite an ID that we're supposed + * to send back. + */ + if (s->session->not_resumable || + (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER) + && !s->hit)) + s->session->session_id_length=0; + + sl=s->session->session_id_length; + if (sl > (int)sizeof(s->session->session_id)) + { + SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + return -1; + } + *(p++)=sl; + memcpy(p,s->session->session_id,sl); + p+=sl; + + /* put the cipher */ + i=ssl3_put_cipher_by_char(s->s3->tmp.new_cipher,p); + p+=i; + + /* put the compression method */ +#ifdef OPENSSL_NO_COMP + *(p++)=0; +#else + if (s->s3->tmp.new_compression == NULL) + *(p++)=0; + else + *(p++)=s->s3->tmp.new_compression->id; +#endif +#ifndef OPENSSL_NO_TLSEXT + if (ssl_prepare_serverhello_tlsext(s) <= 0) + { + SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO,SSL_R_SERVERHELLO_TLSEXT); + return -1; + } + if ((p = ssl_add_serverhello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH, &al)) == NULL) + { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO,ERR_R_INTERNAL_ERROR); + return -1; + } +#endif + /* do the header */ + l=(p-d); + ssl_set_handshake_header(s, SSL3_MT_SERVER_HELLO, l); + s->state=SSL3_ST_SW_SRVR_HELLO_B; + } + + /* SSL3_ST_SW_SRVR_HELLO_B */ + return ssl_do_write(s); + } +",0,"int ssl3_send_server_hello(SSL *s) + { + unsigned char *buf; + unsigned char *p,*d; + int i,sl; + int al = 0; + unsigned long l; + + if (s->state == SSL3_ST_SW_SRVR_HELLO_A) + { + buf=(unsigned char *)s->init_buf->data; +#ifdef OPENSSL_NO_TLSEXT + p=s->s3->server_random; + if (ssl_fill_hello_random(s, 1, p, SSL3_RANDOM_SIZE) <= 0) + return -1; +#endif + /* Do the message type and length last */ + d=p= ssl_handshake_start(s); + + *(p++)=s->version>>8; + *(p++)=s->version&0xff; + + /* Random stuff */ + memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); + p+=SSL3_RANDOM_SIZE; + + /*- + * There are several cases for the session ID to send + * back in the server hello: + * - For session reuse from the session cache, + * we send back the old session ID. + * - If stateless session reuse (using a session ticket) + * is successful, we send back the client's ""session ID"" + * (which doesn't actually identify the session). + * - If it is a new session, we send back the new + * session ID. + * - However, if we want the new session to be single-use, + * we send back a 0-length session ID. + * s->hit is non-zero in either case of session reuse, + * so the following won't overwrite an ID that we're supposed + * to send back. + */ + if (s->session->not_resumable || + (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER) + && !s->hit)) + s->session->session_id_length=0; + + sl=s->session->session_id_length; + if (sl > (int)sizeof(s->session->session_id)) + { + SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + return -1; + } + *(p++)=sl; + memcpy(p,s->session->session_id,sl); + p+=sl; + + /* put the cipher */ + i=ssl3_put_cipher_by_char(s->s3->tmp.new_cipher,p); + p+=i; + + /* put the compression method */ +#ifdef OPENSSL_NO_COMP + *(p++)=0; +#else + if (s->s3->tmp.new_compression == NULL) + *(p++)=0; + else + *(p++)=s->s3->tmp.new_compression->id; +#endif +#ifndef OPENSSL_NO_TLSEXT + if (ssl_prepare_serverhello_tlsext(s) <= 0) + { + SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO,SSL_R_SERVERHELLO_TLSEXT); + return -1; + } + if ((p = ssl_add_serverhello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH, &al)) == NULL) + { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO,ERR_R_INTERNAL_ERROR); + return -1; + } +#endif + /* do the header */ + l=(p-d); + ssl_set_handshake_header(s, SSL3_MT_SERVER_HELLO, l); + s->state=SSL3_ST_SW_SRVR_HELLO_B; + } + + /* SSL3_ST_SW_SRVR_HELLO_B */ + return ssl_do_write(s); + } +","@@ -3056,7 +3056,7 @@ int ssl3_get_cert_verify(SSL *s) + if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY) + { + s->s3->tmp.reuse_message=1; +- if ((peer != NULL) && (type & EVP_PKT_SIGN)) ++ if (peer != NULL) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_MISSING_VERIFY_MESSAGE);",813,1049,2048 +3689,"static int do_last(struct nameidata *nd, struct path *path, + struct file *file, const struct open_flags *op, + int *opened, struct filename *name) +{ + struct dentry *dir = nd->path.dentry; + int open_flag = op->open_flag; + bool will_truncate = (open_flag & O_TRUNC) != 0; + bool got_write = false; + int acc_mode = op->acc_mode; + struct inode *inode; + bool symlink_ok = false; + struct path save_parent = { .dentry = NULL, .mnt = NULL }; + bool retried = false; + int error; + + nd->flags &= ~LOOKUP_PARENT; + nd->flags |= op->intent; + + if (nd->last_type != LAST_NORM) { + error = handle_dots(nd, nd->last_type); + if (error) + return error; + goto finish_open; + } + + if (!(open_flag & O_CREAT)) { + if (nd->last.name[nd->last.len]) + nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; + if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) + symlink_ok = true; + /* we _can_ be in RCU mode here */ + error = lookup_fast(nd, path, &inode); + if (likely(!error)) + goto finish_lookup; + + if (error < 0) + goto out; + + BUG_ON(nd->inode != dir->d_inode); + } else { + /* create side of things */ + /* + * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED + * has been cleared when we got to the last component we are + * about to look up + */ + error = complete_walk(nd); + if (error) + return error; + + audit_inode(name, dir, LOOKUP_PARENT); + error = -EISDIR; + /* trailing slashes? */ + if (nd->last.name[nd->last.len]) + goto out; + } + +retry_lookup: + if (op->open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) { + error = mnt_want_write(nd->path.mnt); + if (!error) + got_write = true; + /* + * do _not_ fail yet - we might not need that or fail with + * a different error; let lookup_open() decide; we'll be + * dropping this one anyway. + */ + } + mutex_lock(&dir->d_inode->i_mutex); + error = lookup_open(nd, path, file, op, got_write, opened); + mutex_unlock(&dir->d_inode->i_mutex); + + if (error <= 0) { + if (error) + goto out; + + if ((*opened & FILE_CREATED) || + !S_ISREG(file_inode(file)->i_mode)) + will_truncate = false; + + audit_inode(name, file->f_path.dentry, 0); + goto opened; + } + + if (*opened & FILE_CREATED) { + /* Don't check for write permission, don't truncate */ + open_flag &= ~O_TRUNC; + will_truncate = false; + acc_mode = MAY_OPEN; + path_to_nameidata(path, nd); + goto finish_open_created; + } + + /* + * create/update audit record if it already exists. + */ + if (d_is_positive(path->dentry)) + audit_inode(name, path->dentry, 0); + + /* + * If atomic_open() acquired write access it is dropped now due to + * possible mount and symlink following (this might be optimized away if + * necessary...) + */ + if (got_write) { + mnt_drop_write(nd->path.mnt); + got_write = false; + } + + error = -EEXIST; + if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) + goto exit_dput; + + error = follow_managed(path, nd->flags); + if (error < 0) + goto exit_dput; + + if (error) + nd->flags |= LOOKUP_JUMPED; + + BUG_ON(nd->flags & LOOKUP_RCU); + inode = path->dentry->d_inode; +finish_lookup: + /* we _can_ be in RCU mode here */ + error = -ENOENT; + if (!inode || d_is_negative(path->dentry)) { + path_to_nameidata(path, nd); + goto out; + } + + if (should_follow_link(path->dentry, !symlink_ok)) { + if (nd->flags & LOOKUP_RCU) { + if (unlikely(unlazy_walk(nd, path->dentry))) { + error = -ECHILD; + goto out; + } + } + BUG_ON(inode != path->dentry->d_inode); + return 1; + } + + if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { + path_to_nameidata(path, nd); + } else { + save_parent.dentry = nd->path.dentry; + save_parent.mnt = mntget(path->mnt); + nd->path.dentry = path->dentry; + + } + nd->inode = inode; + /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ +finish_open: + error = complete_walk(nd); + if (error) { + path_put(&save_parent); + return error; + } + audit_inode(name, nd->path.dentry, 0); + error = -EISDIR; + if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) + goto out; + error = -ENOTDIR; + if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) + goto out; + if (!S_ISREG(nd->inode->i_mode)) + will_truncate = false; + + if (will_truncate) { + error = mnt_want_write(nd->path.mnt); + if (error) + goto out; + got_write = true; + } +finish_open_created: + error = may_open(&nd->path, acc_mode, open_flag); + if (error) + goto out; + file->f_path.mnt = nd->path.mnt; + error = finish_open(file, nd->path.dentry, NULL, opened); + if (error) { + if (error == -EOPENSTALE) + goto stale_open; + goto out; + } +opened: + error = open_check_o_direct(file); + if (error) + goto exit_fput; + error = ima_file_check(file, op->acc_mode); + if (error) + goto exit_fput; + + if (will_truncate) { + error = handle_truncate(file); + if (error) + goto exit_fput; + } +out: + if (got_write) + mnt_drop_write(nd->path.mnt); + path_put(&save_parent); + terminate_walk(nd); + return error; + +exit_dput: + path_put_conditional(path, nd); + goto out; +exit_fput: + fput(file); + goto out; + +stale_open: + /* If no saved parent or already retried then can't retry */ + if (!save_parent.dentry || retried) + goto out; + + BUG_ON(save_parent.dentry != dir); + path_put(&nd->path); + nd->path = save_parent; + nd->inode = dir->d_inode; + save_parent.mnt = NULL; + save_parent.dentry = NULL; + if (got_write) { + mnt_drop_write(nd->path.mnt); + got_write = false; + } + retried = true; + goto retry_lookup; +} +",0,"static int do_last(struct nameidata *nd, struct path *path, + struct file *file, const struct open_flags *op, + int *opened, struct filename *name) +{ + struct dentry *dir = nd->path.dentry; + int open_flag = op->open_flag; + bool will_truncate = (open_flag & O_TRUNC) != 0; + bool got_write = false; + int acc_mode = op->acc_mode; + struct inode *inode; + bool symlink_ok = false; + struct path save_parent = { .dentry = NULL, .mnt = NULL }; + bool retried = false; + int error; + + nd->flags &= ~LOOKUP_PARENT; + nd->flags |= op->intent; + + if (nd->last_type != LAST_NORM) { + error = handle_dots(nd, nd->last_type); + if (error) + return error; + goto finish_open; + } + + if (!(open_flag & O_CREAT)) { + if (nd->last.name[nd->last.len]) + nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; + if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) + symlink_ok = true; + /* we _can_ be in RCU mode here */ + error = lookup_fast(nd, path, &inode); + if (likely(!error)) + goto finish_lookup; + + if (error < 0) + goto out; + + BUG_ON(nd->inode != dir->d_inode); + } else { + /* create side of things */ + /* + * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED + * has been cleared when we got to the last component we are + * about to look up + */ + error = complete_walk(nd); + if (error) + return error; + + audit_inode(name, dir, LOOKUP_PARENT); + error = -EISDIR; + /* trailing slashes? */ + if (nd->last.name[nd->last.len]) + goto out; + } + +retry_lookup: + if (op->open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) { + error = mnt_want_write(nd->path.mnt); + if (!error) + got_write = true; + /* + * do _not_ fail yet - we might not need that or fail with + * a different error; let lookup_open() decide; we'll be + * dropping this one anyway. + */ + } + mutex_lock(&dir->d_inode->i_mutex); + error = lookup_open(nd, path, file, op, got_write, opened); + mutex_unlock(&dir->d_inode->i_mutex); + + if (error <= 0) { + if (error) + goto out; + + if ((*opened & FILE_CREATED) || + !S_ISREG(file_inode(file)->i_mode)) + will_truncate = false; + + audit_inode(name, file->f_path.dentry, 0); + goto opened; + } + + if (*opened & FILE_CREATED) { + /* Don't check for write permission, don't truncate */ + open_flag &= ~O_TRUNC; + will_truncate = false; + acc_mode = MAY_OPEN; + path_to_nameidata(path, nd); + goto finish_open_created; + } + + /* + * create/update audit record if it already exists. + */ + if (d_is_positive(path->dentry)) + audit_inode(name, path->dentry, 0); + + /* + * If atomic_open() acquired write access it is dropped now due to + * possible mount and symlink following (this might be optimized away if + * necessary...) + */ + if (got_write) { + mnt_drop_write(nd->path.mnt); + got_write = false; + } + + error = -EEXIST; + if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) + goto exit_dput; + + error = follow_managed(path, nd->flags); + if (error < 0) + goto exit_dput; + + if (error) + nd->flags |= LOOKUP_JUMPED; + + BUG_ON(nd->flags & LOOKUP_RCU); + inode = path->dentry->d_inode; +finish_lookup: + /* we _can_ be in RCU mode here */ + error = -ENOENT; + if (!inode || d_is_negative(path->dentry)) { + path_to_nameidata(path, nd); + goto out; + } + + if (should_follow_link(path->dentry, !symlink_ok)) { + if (nd->flags & LOOKUP_RCU) { + if (unlikely(unlazy_walk(nd, path->dentry))) { + error = -ECHILD; + goto out; + } + } + BUG_ON(inode != path->dentry->d_inode); + return 1; + } + + if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { + path_to_nameidata(path, nd); + } else { + save_parent.dentry = nd->path.dentry; + save_parent.mnt = mntget(path->mnt); + nd->path.dentry = path->dentry; + + } + nd->inode = inode; + /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ +finish_open: + error = complete_walk(nd); + if (error) { + path_put(&save_parent); + return error; + } + audit_inode(name, nd->path.dentry, 0); + error = -EISDIR; + if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry)) + goto out; + error = -ENOTDIR; + if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) + goto out; + if (!S_ISREG(nd->inode->i_mode)) + will_truncate = false; + + if (will_truncate) { + error = mnt_want_write(nd->path.mnt); + if (error) + goto out; + got_write = true; + } +finish_open_created: + error = may_open(&nd->path, acc_mode, open_flag); + if (error) + goto out; + file->f_path.mnt = nd->path.mnt; + error = finish_open(file, nd->path.dentry, NULL, opened); + if (error) { + if (error == -EOPENSTALE) + goto stale_open; + goto out; + } +opened: + error = open_check_o_direct(file); + if (error) + goto exit_fput; + error = ima_file_check(file, op->acc_mode); + if (error) + goto exit_fput; + + if (will_truncate) { + error = handle_truncate(file); + if (error) + goto exit_fput; + } +out: + if (got_write) + mnt_drop_write(nd->path.mnt); + path_put(&save_parent); + terminate_walk(nd); + return error; + +exit_dput: + path_put_conditional(path, nd); + goto out; +exit_fput: + fput(file); + goto out; + +stale_open: + /* If no saved parent or already retried then can't retry */ + if (!save_parent.dentry || retried) + goto out; + + BUG_ON(save_parent.dentry != dir); + path_put(&nd->path); + nd->path = save_parent; + nd->inode = dir->d_inode; + save_parent.mnt = NULL; + save_parent.dentry = NULL; + if (got_write) { + mnt_drop_write(nd->path.mnt); + got_write = false; + } + retried = true; + goto retry_lookup; +} +","@@ -2256,9 +2256,10 @@ mountpoint_last(struct nameidata *nd, struct path *path) + goto out; + } + path->dentry = dentry; +- path->mnt = mntget(nd->path.mnt); ++ path->mnt = nd->path.mnt; + if (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW)) + return 1; ++ mntget(path->mnt); + follow_mount(path); + error = 0; + out:",1628,1864,2048 +3263,"int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) +{ + struct ifreq ifr; + int ret; + char *colon; + + /* One special case: SIOCGIFCONF takes ifconf argument + and requires shared lock, because it sleeps writing + to user space. + */ + + if (cmd == SIOCGIFCONF) { + rtnl_lock(); + ret = dev_ifconf(net, (char __user *) arg); + rtnl_unlock(); + return ret; + } + if (cmd == SIOCGIFNAME) + return dev_ifname(net, (struct ifreq __user *)arg); + + if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) + return -EFAULT; + + ifr.ifr_name[IFNAMSIZ-1] = 0; + + colon = strchr(ifr.ifr_name, ':'); + if (colon) + *colon = 0; + + /* + * See which interface the caller is talking about. + */ + + switch (cmd) { + /* + * These ioctl calls: + * - can be done by all. + * - atomic and do not require locking. + * - return a value + */ + case SIOCGIFFLAGS: + case SIOCGIFMETRIC: + case SIOCGIFMTU: + case SIOCGIFHWADDR: + case SIOCGIFSLAVE: + case SIOCGIFMAP: + case SIOCGIFINDEX: + case SIOCGIFTXQLEN: + dev_load(net, ifr.ifr_name); + rcu_read_lock(); + ret = dev_ifsioc_locked(net, &ifr, cmd); + rcu_read_unlock(); + if (!ret) { + if (colon) + *colon = ':'; + if (copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + } + return ret; + + case SIOCETHTOOL: + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ethtool(net, &ifr); + rtnl_unlock(); + if (!ret) { + if (colon) + *colon = ':'; + if (copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + } + return ret; + + /* + * These ioctl calls: + * - require superuser power. + * - require strict serialization. + * - return a value + */ + case SIOCGMIIPHY: + case SIOCGMIIREG: + case SIOCSIFNAME: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ifsioc(net, &ifr, cmd); + rtnl_unlock(); + if (!ret) { + if (colon) + *colon = ':'; + if (copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + } + return ret; + + /* + * These ioctl calls: + * - require superuser power. + * - require strict serialization. + * - do not return a value + */ + case SIOCSIFFLAGS: + case SIOCSIFMETRIC: + case SIOCSIFMTU: + case SIOCSIFMAP: + case SIOCSIFHWADDR: + case SIOCSIFSLAVE: + case SIOCADDMULTI: + case SIOCDELMULTI: + case SIOCSIFHWBROADCAST: + case SIOCSIFTXQLEN: + case SIOCSMIIREG: + case SIOCBONDENSLAVE: + case SIOCBONDRELEASE: + case SIOCBONDSETHWADDR: + case SIOCBONDCHANGEACTIVE: + case SIOCBRADDIF: + case SIOCBRDELIF: + case SIOCSHWTSTAMP: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + /* fall through */ + case SIOCBONDSLAVEINFOQUERY: + case SIOCBONDINFOQUERY: + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ifsioc(net, &ifr, cmd); + rtnl_unlock(); + return ret; + + case SIOCGIFMEM: + /* Get the per device memory space. We can add this but + * currently do not support it */ + case SIOCSIFMEM: + /* Set the per device memory buffer space. + * Not applicable in our case */ + case SIOCSIFLINK: + return -EINVAL; + + /* + * Unknown or private ioctl. + */ + default: + if (cmd == SIOCWANDEV || + (cmd >= SIOCDEVPRIVATE && + cmd <= SIOCDEVPRIVATE + 15)) { + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ifsioc(net, &ifr, cmd); + rtnl_unlock(); + if (!ret && copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + return ret; + } + /* Take care of Wireless Extensions */ + if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) + return wext_handle_ioctl(net, &ifr, cmd, arg); + return -EINVAL; + } +} +",0,"int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) +{ + struct ifreq ifr; + int ret; + char *colon; + + /* One special case: SIOCGIFCONF takes ifconf argument + and requires shared lock, because it sleeps writing + to user space. + */ + + if (cmd == SIOCGIFCONF) { + rtnl_lock(); + ret = dev_ifconf(net, (char __user *) arg); + rtnl_unlock(); + return ret; + } + if (cmd == SIOCGIFNAME) + return dev_ifname(net, (struct ifreq __user *)arg); + + if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) + return -EFAULT; + + ifr.ifr_name[IFNAMSIZ-1] = 0; + + colon = strchr(ifr.ifr_name, ':'); + if (colon) + *colon = 0; + + /* + * See which interface the caller is talking about. + */ + + switch (cmd) { + /* + * These ioctl calls: + * - can be done by all. + * - atomic and do not require locking. + * - return a value + */ + case SIOCGIFFLAGS: + case SIOCGIFMETRIC: + case SIOCGIFMTU: + case SIOCGIFHWADDR: + case SIOCGIFSLAVE: + case SIOCGIFMAP: + case SIOCGIFINDEX: + case SIOCGIFTXQLEN: + dev_load(net, ifr.ifr_name); + rcu_read_lock(); + ret = dev_ifsioc_locked(net, &ifr, cmd); + rcu_read_unlock(); + if (!ret) { + if (colon) + *colon = ':'; + if (copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + } + return ret; + + case SIOCETHTOOL: + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ethtool(net, &ifr); + rtnl_unlock(); + if (!ret) { + if (colon) + *colon = ':'; + if (copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + } + return ret; + + /* + * These ioctl calls: + * - require superuser power. + * - require strict serialization. + * - return a value + */ + case SIOCGMIIPHY: + case SIOCGMIIREG: + case SIOCSIFNAME: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ifsioc(net, &ifr, cmd); + rtnl_unlock(); + if (!ret) { + if (colon) + *colon = ':'; + if (copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + } + return ret; + + /* + * These ioctl calls: + * - require superuser power. + * - require strict serialization. + * - do not return a value + */ + case SIOCSIFFLAGS: + case SIOCSIFMETRIC: + case SIOCSIFMTU: + case SIOCSIFMAP: + case SIOCSIFHWADDR: + case SIOCSIFSLAVE: + case SIOCADDMULTI: + case SIOCDELMULTI: + case SIOCSIFHWBROADCAST: + case SIOCSIFTXQLEN: + case SIOCSMIIREG: + case SIOCBONDENSLAVE: + case SIOCBONDRELEASE: + case SIOCBONDSETHWADDR: + case SIOCBONDCHANGEACTIVE: + case SIOCBRADDIF: + case SIOCBRDELIF: + case SIOCSHWTSTAMP: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + /* fall through */ + case SIOCBONDSLAVEINFOQUERY: + case SIOCBONDINFOQUERY: + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ifsioc(net, &ifr, cmd); + rtnl_unlock(); + return ret; + + case SIOCGIFMEM: + /* Get the per device memory space. We can add this but + * currently do not support it */ + case SIOCSIFMEM: + /* Set the per device memory buffer space. + * Not applicable in our case */ + case SIOCSIFLINK: + return -EINVAL; + + /* + * Unknown or private ioctl. + */ + default: + if (cmd == SIOCWANDEV || + (cmd >= SIOCDEVPRIVATE && + cmd <= SIOCDEVPRIVATE + 15)) { + dev_load(net, ifr.ifr_name); + rtnl_lock(); + ret = dev_ifsioc(net, &ifr, cmd); + rtnl_unlock(); + if (!ret && copy_to_user(arg, &ifr, + sizeof(struct ifreq))) + ret = -EFAULT; + return ret; + } + /* Take care of Wireless Extensions */ + if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) + return wext_handle_ioctl(net, &ifr, cmd, arg); + return -EINVAL; + } +} +","@@ -1451,7 +1451,7 @@ static inline void net_timestamp(struct sk_buff *skb) + * + * return values: + * NET_RX_SUCCESS (no congestion) +- * NET_RX_DROP (packet was dropped) ++ * NET_RX_DROP (packet was dropped, but freed) + * + * dev_forward_skb can be used for injecting an skb from the + * start_xmit function of one device into the receive queue +@@ -1465,12 +1465,11 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) + { + skb_orphan(skb); + +- if (!(dev->flags & IFF_UP)) +- return NET_RX_DROP; +- +- if (skb->len > (dev->mtu + dev->hard_header_len)) ++ if (!(dev->flags & IFF_UP) || ++ (skb->len > (dev->mtu + dev->hard_header_len))) { ++ kfree_skb(skb); + return NET_RX_DROP; +- ++ } + skb_set_dev(skb, dev); + skb->tstamp.tv64 = 0; + skb->pkt_type = PACKET_HOST;",1161,1397,2048 +6594,"int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, + void *buf) +{ + struct tmComResBusInfo *bus = &dev->bus; + u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; + u32 new_swp, space_rem; + int ret = SAA_ERR_BAD_PARAMETER; + u16 size; + + if (!msg) { + printk(KERN_ERR ""%s() !msg\n"", __func__); + return SAA_ERR_BAD_PARAMETER; + } + + dprintk(DBGLVL_BUS, ""%s()\n"", __func__); + + saa7164_bus_verify(dev); + + if (msg->size > dev->bus.m_wMaxReqSize) { + printk(KERN_ERR ""%s() Exceeded dev->bus.m_wMaxReqSize\n"", + __func__); + return SAA_ERR_BAD_PARAMETER; + } + + if ((msg->size > 0) && (buf == NULL)) { + printk(KERN_ERR ""%s() Missing message buffer\n"", __func__); + return SAA_ERR_BAD_PARAMETER; + } + + /* Lock the bus from any other access */ + mutex_lock(&bus->lock); + + bytes_to_write = sizeof(*msg) + msg->size; + free_write_space = 0; + timeout = SAA_BUS_TIMEOUT; + curr_srp = saa7164_readl(bus->m_dwSetReadPos); + curr_swp = saa7164_readl(bus->m_dwSetWritePos); + + /* Deal with ring wrapping issues */ + if (curr_srp > curr_swp) + /* Deal with the wrapped ring */ + free_write_space = curr_srp - curr_swp; + else + /* The ring has not wrapped yet */ + free_write_space = (curr_srp + bus->m_dwSizeSetRing) - curr_swp; + + dprintk(DBGLVL_BUS, ""%s() bytes_to_write = %d\n"", __func__, + bytes_to_write); + + dprintk(DBGLVL_BUS, ""%s() free_write_space = %d\n"", __func__, + free_write_space); + + dprintk(DBGLVL_BUS, ""%s() curr_srp = %x\n"", __func__, curr_srp); + dprintk(DBGLVL_BUS, ""%s() curr_swp = %x\n"", __func__, curr_swp); + + /* Process the msg and write the content onto the bus */ + while (bytes_to_write >= free_write_space) { + + if (timeout-- == 0) { + printk(KERN_ERR ""%s() bus timeout\n"", __func__); + ret = SAA_ERR_NO_RESOURCES; + goto out; + } + + /* TODO: Review this delay, efficient? */ + /* Wait, allowing the hardware fetch time */ + mdelay(1); + + /* Check the space usage again */ + curr_srp = saa7164_readl(bus->m_dwSetReadPos); + + /* Deal with ring wrapping issues */ + if (curr_srp > curr_swp) + /* Deal with the wrapped ring */ + free_write_space = curr_srp - curr_swp; + else + /* Read didn't wrap around the buffer */ + free_write_space = (curr_srp + bus->m_dwSizeSetRing) - + curr_swp; + + } + + /* Calculate the new write position */ + new_swp = curr_swp + bytes_to_write; + + dprintk(DBGLVL_BUS, ""%s() new_swp = %x\n"", __func__, new_swp); + dprintk(DBGLVL_BUS, ""%s() bus->m_dwSizeSetRing = %x\n"", __func__, + bus->m_dwSizeSetRing); + + /* + * Make a copy of msg->size before it is converted to le16 since it is + * used in the code below. + */ + size = msg->size; + /* Convert to le16/le32 */ + msg->size = (__force u16)cpu_to_le16(msg->size); + msg->command = (__force u32)cpu_to_le32(msg->command); + msg->controlselector = (__force u16)cpu_to_le16(msg->controlselector); + + /* Mental Note: line 462 tmmhComResBusPCIe.cpp */ + + /* Check if we're going to wrap again */ + if (new_swp > bus->m_dwSizeSetRing) { + + /* Ring wraps */ + new_swp -= bus->m_dwSizeSetRing; + + space_rem = bus->m_dwSizeSetRing - curr_swp; + + dprintk(DBGLVL_BUS, ""%s() space_rem = %x\n"", __func__, + space_rem); + + dprintk(DBGLVL_BUS, ""%s() sizeof(*msg) = %d\n"", __func__, + (u32)sizeof(*msg)); + + if (space_rem < sizeof(*msg)) { + dprintk(DBGLVL_BUS, ""%s() tr4\n"", __func__); + + /* Split the msg into pieces as the ring wraps */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, space_rem); + memcpy_toio(bus->m_pdwSetRing, (u8 *)msg + space_rem, + sizeof(*msg) - space_rem); + + memcpy_toio(bus->m_pdwSetRing + sizeof(*msg) - space_rem, + buf, size); + + } else if (space_rem == sizeof(*msg)) { + dprintk(DBGLVL_BUS, ""%s() tr5\n"", __func__); + + /* Additional data at the beginning of the ring */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); + memcpy_toio(bus->m_pdwSetRing, buf, size); + + } else { + /* Additional data wraps around the ring */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); + if (size > 0) { + memcpy_toio(bus->m_pdwSetRing + curr_swp + + sizeof(*msg), buf, space_rem - + sizeof(*msg)); + memcpy_toio(bus->m_pdwSetRing, (u8 *)buf + + space_rem - sizeof(*msg), + bytes_to_write - space_rem); + } + + } + + } /* (new_swp > bus->m_dwSizeSetRing) */ + else { + dprintk(DBGLVL_BUS, ""%s() tr6\n"", __func__); + + /* The ring buffer doesn't wrap, two simple copies */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); + memcpy_toio(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, + size); + } + + dprintk(DBGLVL_BUS, ""%s() new_swp = %x\n"", __func__, new_swp); + + /* Update the bus write position */ + saa7164_writel(bus->m_dwSetWritePos, new_swp); + + /* Convert back to cpu after writing the msg to the ringbuffer. */ + msg->size = le16_to_cpu((__force __le16)msg->size); + msg->command = le32_to_cpu((__force __le32)msg->command); + msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); + ret = SAA_OK; + +out: + saa7164_bus_dump(dev); + mutex_unlock(&bus->lock); + saa7164_bus_verify(dev); + return ret; +} +",0,"int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, + void *buf) +{ + struct tmComResBusInfo *bus = &dev->bus; + u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; + u32 new_swp, space_rem; + int ret = SAA_ERR_BAD_PARAMETER; + u16 size; + + if (!msg) { + printk(KERN_ERR ""%s() !msg\n"", __func__); + return SAA_ERR_BAD_PARAMETER; + } + + dprintk(DBGLVL_BUS, ""%s()\n"", __func__); + + saa7164_bus_verify(dev); + + if (msg->size > dev->bus.m_wMaxReqSize) { + printk(KERN_ERR ""%s() Exceeded dev->bus.m_wMaxReqSize\n"", + __func__); + return SAA_ERR_BAD_PARAMETER; + } + + if ((msg->size > 0) && (buf == NULL)) { + printk(KERN_ERR ""%s() Missing message buffer\n"", __func__); + return SAA_ERR_BAD_PARAMETER; + } + + /* Lock the bus from any other access */ + mutex_lock(&bus->lock); + + bytes_to_write = sizeof(*msg) + msg->size; + free_write_space = 0; + timeout = SAA_BUS_TIMEOUT; + curr_srp = saa7164_readl(bus->m_dwSetReadPos); + curr_swp = saa7164_readl(bus->m_dwSetWritePos); + + /* Deal with ring wrapping issues */ + if (curr_srp > curr_swp) + /* Deal with the wrapped ring */ + free_write_space = curr_srp - curr_swp; + else + /* The ring has not wrapped yet */ + free_write_space = (curr_srp + bus->m_dwSizeSetRing) - curr_swp; + + dprintk(DBGLVL_BUS, ""%s() bytes_to_write = %d\n"", __func__, + bytes_to_write); + + dprintk(DBGLVL_BUS, ""%s() free_write_space = %d\n"", __func__, + free_write_space); + + dprintk(DBGLVL_BUS, ""%s() curr_srp = %x\n"", __func__, curr_srp); + dprintk(DBGLVL_BUS, ""%s() curr_swp = %x\n"", __func__, curr_swp); + + /* Process the msg and write the content onto the bus */ + while (bytes_to_write >= free_write_space) { + + if (timeout-- == 0) { + printk(KERN_ERR ""%s() bus timeout\n"", __func__); + ret = SAA_ERR_NO_RESOURCES; + goto out; + } + + /* TODO: Review this delay, efficient? */ + /* Wait, allowing the hardware fetch time */ + mdelay(1); + + /* Check the space usage again */ + curr_srp = saa7164_readl(bus->m_dwSetReadPos); + + /* Deal with ring wrapping issues */ + if (curr_srp > curr_swp) + /* Deal with the wrapped ring */ + free_write_space = curr_srp - curr_swp; + else + /* Read didn't wrap around the buffer */ + free_write_space = (curr_srp + bus->m_dwSizeSetRing) - + curr_swp; + + } + + /* Calculate the new write position */ + new_swp = curr_swp + bytes_to_write; + + dprintk(DBGLVL_BUS, ""%s() new_swp = %x\n"", __func__, new_swp); + dprintk(DBGLVL_BUS, ""%s() bus->m_dwSizeSetRing = %x\n"", __func__, + bus->m_dwSizeSetRing); + + /* + * Make a copy of msg->size before it is converted to le16 since it is + * used in the code below. + */ + size = msg->size; + /* Convert to le16/le32 */ + msg->size = (__force u16)cpu_to_le16(msg->size); + msg->command = (__force u32)cpu_to_le32(msg->command); + msg->controlselector = (__force u16)cpu_to_le16(msg->controlselector); + + /* Mental Note: line 462 tmmhComResBusPCIe.cpp */ + + /* Check if we're going to wrap again */ + if (new_swp > bus->m_dwSizeSetRing) { + + /* Ring wraps */ + new_swp -= bus->m_dwSizeSetRing; + + space_rem = bus->m_dwSizeSetRing - curr_swp; + + dprintk(DBGLVL_BUS, ""%s() space_rem = %x\n"", __func__, + space_rem); + + dprintk(DBGLVL_BUS, ""%s() sizeof(*msg) = %d\n"", __func__, + (u32)sizeof(*msg)); + + if (space_rem < sizeof(*msg)) { + dprintk(DBGLVL_BUS, ""%s() tr4\n"", __func__); + + /* Split the msg into pieces as the ring wraps */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, space_rem); + memcpy_toio(bus->m_pdwSetRing, (u8 *)msg + space_rem, + sizeof(*msg) - space_rem); + + memcpy_toio(bus->m_pdwSetRing + sizeof(*msg) - space_rem, + buf, size); + + } else if (space_rem == sizeof(*msg)) { + dprintk(DBGLVL_BUS, ""%s() tr5\n"", __func__); + + /* Additional data at the beginning of the ring */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); + memcpy_toio(bus->m_pdwSetRing, buf, size); + + } else { + /* Additional data wraps around the ring */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); + if (size > 0) { + memcpy_toio(bus->m_pdwSetRing + curr_swp + + sizeof(*msg), buf, space_rem - + sizeof(*msg)); + memcpy_toio(bus->m_pdwSetRing, (u8 *)buf + + space_rem - sizeof(*msg), + bytes_to_write - space_rem); + } + + } + + } /* (new_swp > bus->m_dwSizeSetRing) */ + else { + dprintk(DBGLVL_BUS, ""%s() tr6\n"", __func__); + + /* The ring buffer doesn't wrap, two simple copies */ + memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); + memcpy_toio(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, + size); + } + + dprintk(DBGLVL_BUS, ""%s() new_swp = %x\n"", __func__, new_swp); + + /* Update the bus write position */ + saa7164_writel(bus->m_dwSetWritePos, new_swp); + + /* Convert back to cpu after writing the msg to the ringbuffer. */ + msg->size = le16_to_cpu((__force __le16)msg->size); + msg->command = le32_to_cpu((__force __le32)msg->command); + msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); + ret = SAA_OK; + +out: + saa7164_bus_dump(dev); + mutex_unlock(&bus->lock); + saa7164_bus_verify(dev); + return ret; +} +","@@ -389,11 +389,11 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, + msg_tmp.size = le16_to_cpu((__force __le16)msg_tmp.size); + msg_tmp.command = le32_to_cpu((__force __le32)msg_tmp.command); + msg_tmp.controlselector = le16_to_cpu((__force __le16)msg_tmp.controlselector); ++ memcpy(msg, &msg_tmp, sizeof(*msg)); + + /* No need to update the read positions, because this was a peek */ + /* If the caller specifically want to peek, return */ + if (peekonly) { +- memcpy(msg, &msg_tmp, sizeof(*msg)); + goto peekout; + } + +@@ -438,21 +438,15 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, + space_rem = bus->m_dwSizeGetRing - curr_grp; + + if (space_rem < sizeof(*msg)) { +- /* msg wraps around the ring */ +- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, space_rem); +- memcpy_fromio((u8 *)msg + space_rem, bus->m_pdwGetRing, +- sizeof(*msg) - space_rem); + if (buf) + memcpy_fromio(buf, bus->m_pdwGetRing + sizeof(*msg) - + space_rem, buf_size); + + } else if (space_rem == sizeof(*msg)) { +- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); + if (buf) + memcpy_fromio(buf, bus->m_pdwGetRing, buf_size); + } else { + /* Additional data wraps around the ring */ +- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); + if (buf) { + memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + + sizeof(*msg), space_rem - sizeof(*msg)); +@@ -465,15 +459,10 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, + + } else { + /* No wrapping */ +- memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); + if (buf) + memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), + buf_size); + } +- /* Convert from little endian to CPU */ +- msg->size = le16_to_cpu((__force __le16)msg->size); +- msg->command = le32_to_cpu((__force __le32)msg->command); +- msg->controlselector = le16_to_cpu((__force __le16)msg->controlselector); + + /* Update the read positions, adjusting the ring */ + saa7164_writel(bus->m_dwGetReadPos, new_grp);",1634,1870,2048 +17553,"void LvmEffect_limitLevel(EffectContext *pContext) { + LVM_ControlParams_t ActiveParams; /* Current control Parameters */ + LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ + + /* Get the current settings */ + LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, ""LVM_GetControlParameters"", ""LvmEffect_limitLevel"") + + int gainCorrection = 0; + float energyContribution = 0; + float energyCross = 0; + float energyBassBoost = 0; + float crossCorrection = 0; + + if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0; + float bandCoefficient = LimitLevel_bandEnergyCoefficient[i]; + float bandEnergy = bandFactor * bandCoefficient * bandCoefficient; + if (bandEnergy > 0) + energyContribution += bandEnergy; + } + + float bandFactorSum = 0; + for (int i = 0; i < FIVEBAND_NUMBANDS-1; i++) { + float bandFactor1 = pContext->pBundledContext->bandGaindB[i]/15.0; + float bandFactor2 = pContext->pBundledContext->bandGaindB[i+1]/15.0; + + if (bandFactor1 > 0 && bandFactor2 > 0) { + float crossEnergy = bandFactor1 * bandFactor2 * + LimitLevel_bandEnergyCrossCoefficient[i]; + bandFactorSum += bandFactor1 * bandFactor2; + + if (crossEnergy > 0) + energyCross += crossEnergy; + } + } + bandFactorSum -= 1.0; + if (bandFactorSum > 0) + crossCorrection = bandFactorSum * 0.7; + } + + if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { + float boostFactor = (pContext->pBundledContext->BassStrengthSaved)/1000.0; + float boostCoefficient = LimitLevel_bassBoostEnergyCoefficient; + + energyContribution += boostFactor * boostCoefficient * boostCoefficient; + + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0; + float bandCrossCoefficient = LimitLevel_bassBoostEnergyCrossCoefficient[i]; + float bandEnergy = boostFactor * bandFactor * + bandCrossCoefficient; + if (bandEnergy > 0) + energyBassBoost += bandEnergy; + } + } + + if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { + energyContribution += LimitLevel_virtualizerContribution * + LimitLevel_virtualizerContribution; + } + + double totalEnergyEstimation = sqrt(energyContribution + energyCross + energyBassBoost) - + crossCorrection; + ALOGV("" TOTAL energy estimation: %0.2f"", totalEnergyEstimation); + + int maxLevelRound = (int)(totalEnergyEstimation + 0.99); + if (maxLevelRound + pContext->pBundledContext->volume > 0) { + gainCorrection = maxLevelRound + pContext->pBundledContext->volume; + } + + ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection; + if (ActiveParams.VC_EffectLevel < -96) { + ActiveParams.VC_EffectLevel = -96; + } + ALOGV(""\tVol:%d, GainCorrection: %d, Actual vol: %d"", pContext->pBundledContext->volume, + gainCorrection, ActiveParams.VC_EffectLevel); + + /* Activate the initial settings */ + LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, ""LVM_SetControlParameters"", ""LvmEffect_limitLevel"") + + if (pContext->pBundledContext->firstVolume == LVM_TRUE){ + LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, ""LVM_SetVolumeNoSmoothing"", ""LvmBundle_process"") + ALOGV(""\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks""); + pContext->pBundledContext->firstVolume = LVM_FALSE; + } +} +",0,"void LvmEffect_limitLevel(EffectContext *pContext) { + LVM_ControlParams_t ActiveParams; /* Current control Parameters */ + LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ + + /* Get the current settings */ + LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, ""LVM_GetControlParameters"", ""LvmEffect_limitLevel"") + + int gainCorrection = 0; + float energyContribution = 0; + float energyCross = 0; + float energyBassBoost = 0; + float crossCorrection = 0; + + if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0; + float bandCoefficient = LimitLevel_bandEnergyCoefficient[i]; + float bandEnergy = bandFactor * bandCoefficient * bandCoefficient; + if (bandEnergy > 0) + energyContribution += bandEnergy; + } + + float bandFactorSum = 0; + for (int i = 0; i < FIVEBAND_NUMBANDS-1; i++) { + float bandFactor1 = pContext->pBundledContext->bandGaindB[i]/15.0; + float bandFactor2 = pContext->pBundledContext->bandGaindB[i+1]/15.0; + + if (bandFactor1 > 0 && bandFactor2 > 0) { + float crossEnergy = bandFactor1 * bandFactor2 * + LimitLevel_bandEnergyCrossCoefficient[i]; + bandFactorSum += bandFactor1 * bandFactor2; + + if (crossEnergy > 0) + energyCross += crossEnergy; + } + } + bandFactorSum -= 1.0; + if (bandFactorSum > 0) + crossCorrection = bandFactorSum * 0.7; + } + + if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { + float boostFactor = (pContext->pBundledContext->BassStrengthSaved)/1000.0; + float boostCoefficient = LimitLevel_bassBoostEnergyCoefficient; + + energyContribution += boostFactor * boostCoefficient * boostCoefficient; + + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0; + float bandCrossCoefficient = LimitLevel_bassBoostEnergyCrossCoefficient[i]; + float bandEnergy = boostFactor * bandFactor * + bandCrossCoefficient; + if (bandEnergy > 0) + energyBassBoost += bandEnergy; + } + } + + if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { + energyContribution += LimitLevel_virtualizerContribution * + LimitLevel_virtualizerContribution; + } + + double totalEnergyEstimation = sqrt(energyContribution + energyCross + energyBassBoost) - + crossCorrection; + ALOGV("" TOTAL energy estimation: %0.2f"", totalEnergyEstimation); + + int maxLevelRound = (int)(totalEnergyEstimation + 0.99); + if (maxLevelRound + pContext->pBundledContext->volume > 0) { + gainCorrection = maxLevelRound + pContext->pBundledContext->volume; + } + + ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection; + if (ActiveParams.VC_EffectLevel < -96) { + ActiveParams.VC_EffectLevel = -96; + } + ALOGV(""\tVol:%d, GainCorrection: %d, Actual vol: %d"", pContext->pBundledContext->volume, + gainCorrection, ActiveParams.VC_EffectLevel); + + /* Activate the initial settings */ + LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, ""LVM_SetControlParameters"", ""LvmEffect_limitLevel"") + + if (pContext->pBundledContext->firstVolume == LVM_TRUE){ + LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, ""LVM_SetVolumeNoSmoothing"", ""LvmBundle_process"") + ALOGV(""\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks""); + pContext->pBundledContext->firstVolume = LVM_FALSE; + } +} +","@@ -2357,8 +2357,12 @@ + + + case EQ_PARAM_BAND_LEVEL: + param2 = *pParamTemp; +- if (param2 >= FIVEBAND_NUMBANDS) { ++ if (param2 < 0 || param2 >= FIVEBAND_NUMBANDS) { + status = -EINVAL; ++ if (param2 < 0) { ++ android_errorWriteLog(0x534e4554, ""32438598""); ++ ALOGW(""\tERROR Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d"", param2); ++ } + break; + } + *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2); +@@ -2368,8 +2372,12 @@ + + + case EQ_PARAM_CENTER_FREQ: + param2 = *pParamTemp; +- if (param2 >= FIVEBAND_NUMBANDS) { ++ if (param2 < 0 || param2 >= FIVEBAND_NUMBANDS) { + status = -EINVAL; ++ if (param2 < 0) { ++ android_errorWriteLog(0x534e4554, ""32436341""); ++ ALOGW(""\tERROR Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d"", param2); ++ } + break; + } + *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); +@@ -2379,8 +2387,12 @@ + + + case EQ_PARAM_BAND_FREQ_RANGE: + param2 = *pParamTemp; +- if (param2 >= FIVEBAND_NUMBANDS) { ++ if (param2 < 0 || param2 >= FIVEBAND_NUMBANDS) { + status = -EINVAL; ++ if (param2 < 0) { ++ android_errorWriteLog(0x534e4554, ""32247948""); ++ ALOGW(""\tERROR Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d"", param2); ++ } + break; + } + EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); +",1000,1236,2048 +2315,"void __init sched_init(void) +{ + int i, j; + unsigned long alloc_size = 0, ptr; + +#ifdef CONFIG_FAIR_GROUP_SCHED + alloc_size += 2 * nr_cpu_ids * sizeof(void **); +#endif +#ifdef CONFIG_RT_GROUP_SCHED + alloc_size += 2 * nr_cpu_ids * sizeof(void **); +#endif +#ifdef CONFIG_CPUMASK_OFFSTACK + alloc_size += num_possible_cpus() * cpumask_size(); +#endif + if (alloc_size) { + ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT); + +#ifdef CONFIG_FAIR_GROUP_SCHED + init_task_group.se = (struct sched_entity **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + + init_task_group.cfs_rq = (struct cfs_rq **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + +#endif /* CONFIG_FAIR_GROUP_SCHED */ +#ifdef CONFIG_RT_GROUP_SCHED + init_task_group.rt_se = (struct sched_rt_entity **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + + init_task_group.rt_rq = (struct rt_rq **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + +#endif /* CONFIG_RT_GROUP_SCHED */ +#ifdef CONFIG_CPUMASK_OFFSTACK + for_each_possible_cpu(i) { + per_cpu(load_balance_tmpmask, i) = (void *)ptr; + ptr += cpumask_size(); + } +#endif /* CONFIG_CPUMASK_OFFSTACK */ + } + +#ifdef CONFIG_SMP + init_defrootdomain(); +#endif + + init_rt_bandwidth(&def_rt_bandwidth, + global_rt_period(), global_rt_runtime()); + +#ifdef CONFIG_RT_GROUP_SCHED + init_rt_bandwidth(&init_task_group.rt_bandwidth, + global_rt_period(), global_rt_runtime()); +#endif /* CONFIG_RT_GROUP_SCHED */ + +#ifdef CONFIG_CGROUP_SCHED + list_add(&init_task_group.list, &task_groups); + INIT_LIST_HEAD(&init_task_group.children); + +#endif /* CONFIG_CGROUP_SCHED */ + +#if defined CONFIG_FAIR_GROUP_SCHED && defined CONFIG_SMP + update_shares_data = __alloc_percpu(nr_cpu_ids * sizeof(unsigned long), + __alignof__(unsigned long)); +#endif + for_each_possible_cpu(i) { + struct rq *rq; + + rq = cpu_rq(i); + raw_spin_lock_init(&rq->lock); + rq->nr_running = 0; + rq->calc_load_active = 0; + rq->calc_load_update = jiffies + LOAD_FREQ; + init_cfs_rq(&rq->cfs, rq); + init_rt_rq(&rq->rt, rq); +#ifdef CONFIG_FAIR_GROUP_SCHED + init_task_group.shares = init_task_group_load; + INIT_LIST_HEAD(&rq->leaf_cfs_rq_list); +#ifdef CONFIG_CGROUP_SCHED + /* + * How much cpu bandwidth does init_task_group get? + * + * In case of task-groups formed thr' the cgroup filesystem, it + * gets 100% of the cpu resources in the system. This overall + * system cpu resource is divided among the tasks of + * init_task_group and its child task-groups in a fair manner, + * based on each entity's (task or task-group's) weight + * (se->load.weight). + * + * In other words, if init_task_group has 10 tasks of weight + * 1024) and two child groups A0 and A1 (of weight 1024 each), + * then A0's share of the cpu resource is: + * + * A0's bandwidth = 1024 / (10*1024 + 1024 + 1024) = 8.33% + * + * We achieve this by letting init_task_group's tasks sit + * directly in rq->cfs (i.e init_task_group->se[] = NULL). + */ + init_tg_cfs_entry(&init_task_group, &rq->cfs, NULL, i, 1, NULL); +#endif +#endif /* CONFIG_FAIR_GROUP_SCHED */ + + rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime; +#ifdef CONFIG_RT_GROUP_SCHED + INIT_LIST_HEAD(&rq->leaf_rt_rq_list); +#ifdef CONFIG_CGROUP_SCHED + init_tg_rt_entry(&init_task_group, &rq->rt, NULL, i, 1, NULL); +#endif +#endif + + for (j = 0; j < CPU_LOAD_IDX_MAX; j++) + rq->cpu_load[j] = 0; + + rq->last_load_update_tick = jiffies; + +#ifdef CONFIG_SMP + rq->sd = NULL; + rq->rd = NULL; + rq->cpu_power = SCHED_LOAD_SCALE; + rq->post_schedule = 0; + rq->active_balance = 0; + rq->next_balance = jiffies; + rq->push_cpu = 0; + rq->cpu = i; + rq->online = 0; + rq->idle_stamp = 0; + rq->avg_idle = 2*sysctl_sched_migration_cost; + rq_attach_root(rq, &def_root_domain); +#ifdef CONFIG_NO_HZ + rq->nohz_balance_kick = 0; + init_sched_softirq_csd(&per_cpu(remote_sched_softirq_cb, i)); +#endif +#endif + init_rq_hrtick(rq); + atomic_set(&rq->nr_iowait, 0); + } + + set_load_weight(&init_task); + +#ifdef CONFIG_PREEMPT_NOTIFIERS + INIT_HLIST_HEAD(&init_task.preempt_notifiers); +#endif + +#ifdef CONFIG_SMP + open_softirq(SCHED_SOFTIRQ, run_rebalance_domains); +#endif + +#ifdef CONFIG_RT_MUTEXES + plist_head_init_raw(&init_task.pi_waiters, &init_task.pi_lock); +#endif + + /* + * The boot idle thread does lazy MMU switching as well: + */ + atomic_inc(&init_mm.mm_count); + enter_lazy_tlb(&init_mm, current); + + /* + * Make us the idle thread. Technically, schedule() should not be + * called from this thread, however somewhere below it might be, + * but because we are the idle thread, we just pick up running again + * when this runqueue becomes ""idle"". + */ + init_idle(current, smp_processor_id()); + + calc_load_update = jiffies + LOAD_FREQ; + + /* + * During early bootup we pretend to be a normal task: + */ + current->sched_class = &fair_sched_class; + + /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ + zalloc_cpumask_var(&nohz_cpu_mask, GFP_NOWAIT); +#ifdef CONFIG_SMP +#ifdef CONFIG_NO_HZ + zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT); + alloc_cpumask_var(&nohz.grp_idle_mask, GFP_NOWAIT); + atomic_set(&nohz.load_balancer, nr_cpu_ids); + atomic_set(&nohz.first_pick_cpu, nr_cpu_ids); + atomic_set(&nohz.second_pick_cpu, nr_cpu_ids); +#endif + /* May be allocated at isolcpus cmdline parse time */ + if (cpu_isolated_map == NULL) + zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); +#endif /* SMP */ + + perf_event_init(); + + scheduler_running = 1; +} +",0,"void __init sched_init(void) +{ + int i, j; + unsigned long alloc_size = 0, ptr; + +#ifdef CONFIG_FAIR_GROUP_SCHED + alloc_size += 2 * nr_cpu_ids * sizeof(void **); +#endif +#ifdef CONFIG_RT_GROUP_SCHED + alloc_size += 2 * nr_cpu_ids * sizeof(void **); +#endif +#ifdef CONFIG_CPUMASK_OFFSTACK + alloc_size += num_possible_cpus() * cpumask_size(); +#endif + if (alloc_size) { + ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT); + +#ifdef CONFIG_FAIR_GROUP_SCHED + init_task_group.se = (struct sched_entity **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + + init_task_group.cfs_rq = (struct cfs_rq **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + +#endif /* CONFIG_FAIR_GROUP_SCHED */ +#ifdef CONFIG_RT_GROUP_SCHED + init_task_group.rt_se = (struct sched_rt_entity **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + + init_task_group.rt_rq = (struct rt_rq **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + +#endif /* CONFIG_RT_GROUP_SCHED */ +#ifdef CONFIG_CPUMASK_OFFSTACK + for_each_possible_cpu(i) { + per_cpu(load_balance_tmpmask, i) = (void *)ptr; + ptr += cpumask_size(); + } +#endif /* CONFIG_CPUMASK_OFFSTACK */ + } + +#ifdef CONFIG_SMP + init_defrootdomain(); +#endif + + init_rt_bandwidth(&def_rt_bandwidth, + global_rt_period(), global_rt_runtime()); + +#ifdef CONFIG_RT_GROUP_SCHED + init_rt_bandwidth(&init_task_group.rt_bandwidth, + global_rt_period(), global_rt_runtime()); +#endif /* CONFIG_RT_GROUP_SCHED */ + +#ifdef CONFIG_CGROUP_SCHED + list_add(&init_task_group.list, &task_groups); + INIT_LIST_HEAD(&init_task_group.children); + +#endif /* CONFIG_CGROUP_SCHED */ + +#if defined CONFIG_FAIR_GROUP_SCHED && defined CONFIG_SMP + update_shares_data = __alloc_percpu(nr_cpu_ids * sizeof(unsigned long), + __alignof__(unsigned long)); +#endif + for_each_possible_cpu(i) { + struct rq *rq; + + rq = cpu_rq(i); + raw_spin_lock_init(&rq->lock); + rq->nr_running = 0; + rq->calc_load_active = 0; + rq->calc_load_update = jiffies + LOAD_FREQ; + init_cfs_rq(&rq->cfs, rq); + init_rt_rq(&rq->rt, rq); +#ifdef CONFIG_FAIR_GROUP_SCHED + init_task_group.shares = init_task_group_load; + INIT_LIST_HEAD(&rq->leaf_cfs_rq_list); +#ifdef CONFIG_CGROUP_SCHED + /* + * How much cpu bandwidth does init_task_group get? + * + * In case of task-groups formed thr' the cgroup filesystem, it + * gets 100% of the cpu resources in the system. This overall + * system cpu resource is divided among the tasks of + * init_task_group and its child task-groups in a fair manner, + * based on each entity's (task or task-group's) weight + * (se->load.weight). + * + * In other words, if init_task_group has 10 tasks of weight + * 1024) and two child groups A0 and A1 (of weight 1024 each), + * then A0's share of the cpu resource is: + * + * A0's bandwidth = 1024 / (10*1024 + 1024 + 1024) = 8.33% + * + * We achieve this by letting init_task_group's tasks sit + * directly in rq->cfs (i.e init_task_group->se[] = NULL). + */ + init_tg_cfs_entry(&init_task_group, &rq->cfs, NULL, i, 1, NULL); +#endif +#endif /* CONFIG_FAIR_GROUP_SCHED */ + + rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime; +#ifdef CONFIG_RT_GROUP_SCHED + INIT_LIST_HEAD(&rq->leaf_rt_rq_list); +#ifdef CONFIG_CGROUP_SCHED + init_tg_rt_entry(&init_task_group, &rq->rt, NULL, i, 1, NULL); +#endif +#endif + + for (j = 0; j < CPU_LOAD_IDX_MAX; j++) + rq->cpu_load[j] = 0; + + rq->last_load_update_tick = jiffies; + +#ifdef CONFIG_SMP + rq->sd = NULL; + rq->rd = NULL; + rq->cpu_power = SCHED_LOAD_SCALE; + rq->post_schedule = 0; + rq->active_balance = 0; + rq->next_balance = jiffies; + rq->push_cpu = 0; + rq->cpu = i; + rq->online = 0; + rq->idle_stamp = 0; + rq->avg_idle = 2*sysctl_sched_migration_cost; + rq_attach_root(rq, &def_root_domain); +#ifdef CONFIG_NO_HZ + rq->nohz_balance_kick = 0; + init_sched_softirq_csd(&per_cpu(remote_sched_softirq_cb, i)); +#endif +#endif + init_rq_hrtick(rq); + atomic_set(&rq->nr_iowait, 0); + } + + set_load_weight(&init_task); + +#ifdef CONFIG_PREEMPT_NOTIFIERS + INIT_HLIST_HEAD(&init_task.preempt_notifiers); +#endif + +#ifdef CONFIG_SMP + open_softirq(SCHED_SOFTIRQ, run_rebalance_domains); +#endif + +#ifdef CONFIG_RT_MUTEXES + plist_head_init_raw(&init_task.pi_waiters, &init_task.pi_lock); +#endif + + /* + * The boot idle thread does lazy MMU switching as well: + */ + atomic_inc(&init_mm.mm_count); + enter_lazy_tlb(&init_mm, current); + + /* + * Make us the idle thread. Technically, schedule() should not be + * called from this thread, however somewhere below it might be, + * but because we are the idle thread, we just pick up running again + * when this runqueue becomes ""idle"". + */ + init_idle(current, smp_processor_id()); + + calc_load_update = jiffies + LOAD_FREQ; + + /* + * During early bootup we pretend to be a normal task: + */ + current->sched_class = &fair_sched_class; + + /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ + zalloc_cpumask_var(&nohz_cpu_mask, GFP_NOWAIT); +#ifdef CONFIG_SMP +#ifdef CONFIG_NO_HZ + zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT); + alloc_cpumask_var(&nohz.grp_idle_mask, GFP_NOWAIT); + atomic_set(&nohz.load_balancer, nr_cpu_ids); + atomic_set(&nohz.first_pick_cpu, nr_cpu_ids); + atomic_set(&nohz.second_pick_cpu, nr_cpu_ids); +#endif + /* May be allocated at isolcpus cmdline parse time */ + if (cpu_isolated_map == NULL) + zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); +#endif /* SMP */ + + perf_event_init(); + + scheduler_running = 1; +} +","@@ -641,17 +641,18 @@ static void sched_irq_time_avg_update(struct rq *rq, u64 irq_time); + + inline void update_rq_clock(struct rq *rq) + { +- if (!rq->skip_clock_update) { +- int cpu = cpu_of(rq); +- u64 irq_time; ++ int cpu = cpu_of(rq); ++ u64 irq_time; + +- rq->clock = sched_clock_cpu(cpu); +- irq_time = irq_time_cpu(cpu); +- if (rq->clock - irq_time > rq->clock_task) +- rq->clock_task = rq->clock - irq_time; ++ if (rq->skip_clock_update) ++ return; + +- sched_irq_time_avg_update(rq, irq_time); +- } ++ rq->clock = sched_clock_cpu(cpu); ++ irq_time = irq_time_cpu(cpu); ++ if (rq->clock - irq_time > rq->clock_task) ++ rq->clock_task = rq->clock - irq_time; ++ ++ sched_irq_time_avg_update(rq, irq_time); + } + + /* +@@ -2129,7 +2130,7 @@ static void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags) + * A queue event has occurred, and we're going to schedule. In + * this case, we can save a useless back to back clock update. + */ +- if (test_tsk_need_resched(rq->curr)) ++ if (rq->curr->se.on_rq && test_tsk_need_resched(rq->curr)) + rq->skip_clock_update = 1; + } + +@@ -3973,7 +3974,6 @@ static void put_prev_task(struct rq *rq, struct task_struct *prev) + { + if (prev->se.on_rq) + update_rq_clock(rq); +- rq->skip_clock_update = 0; + prev->sched_class->put_prev_task(rq, prev); + } + +@@ -4031,7 +4031,6 @@ asmlinkage void __sched schedule(void) + hrtick_clear(rq); + + raw_spin_lock_irq(&rq->lock); +- clear_tsk_need_resched(prev); + + switch_count = &prev->nivcsw; + if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { +@@ -4063,6 +4062,8 @@ asmlinkage void __sched schedule(void) + + put_prev_task(rq, prev); + next = pick_next_task(rq); ++ clear_tsk_need_resched(prev); ++ rq->skip_clock_update = 0; + + if (likely(prev != next)) { + sched_info_switch(prev, next); +@@ -4071,6 +4072,7 @@ asmlinkage void __sched schedule(void) + rq->nr_switches++; + rq->curr = next; + ++*switch_count; ++ WARN_ON_ONCE(test_tsk_need_resched(next)); + + context_switch(rq, prev, next); /* unlocks the rq */ + /*",1558,1794,2048 +18017,"static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_filesystem_object *source, int type, zend_class_entry *ce, zval *return_value TSRMLS_DC) /* {{{ */ +{ + spl_filesystem_object *intern; + zend_bool use_include_path = 0; + zval *arg1, *arg2; + zend_error_handling error_handling; + + zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); + + switch (source->type) { + case SPL_FS_INFO: + case SPL_FS_FILE: + break; + case SPL_FS_DIR: + if (!source->u.dir.entry.d_name[0]) { + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, ""Could not open file""); + zend_restore_error_handling(&error_handling TSRMLS_CC); + return NULL; + } + } + + switch (type) { + case SPL_FS_INFO: + ce = ce ? ce : source->info_class; + + zend_update_class_constants(ce TSRMLS_CC); + + return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC); + Z_TYPE_P(return_value) = IS_OBJECT; + + spl_filesystem_object_get_file_name(source TSRMLS_CC); + if (ce->constructor->common.scope != spl_ce_SplFileInfo) { + MAKE_STD_ZVAL(arg1); + ZVAL_STRINGL(arg1, source->file_name, source->file_name_len, 1); + zend_call_method_with_1_params(&return_value, ce, &ce->constructor, ""__construct"", NULL, arg1); + zval_ptr_dtor(&arg1); + } else { + intern->file_name = estrndup(source->file_name, source->file_name_len); + intern->file_name_len = source->file_name_len; + intern->_path = spl_filesystem_object_get_path(source, &intern->_path_len TSRMLS_CC); + intern->_path = estrndup(intern->_path, intern->_path_len); + } + break; + case SPL_FS_FILE: + ce = ce ? ce : source->file_class; + + zend_update_class_constants(ce TSRMLS_CC); + + return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC); + Z_TYPE_P(return_value) = IS_OBJECT; + spl_filesystem_object_get_file_name(source TSRMLS_CC); + + if (ce->constructor->common.scope != spl_ce_SplFileObject) { + MAKE_STD_ZVAL(arg1); + MAKE_STD_ZVAL(arg2); + ZVAL_STRINGL(arg1, source->file_name, source->file_name_len, 1); + ZVAL_STRINGL(arg2, ""r"", 1, 1); + zend_call_method_with_2_params(&return_value, ce, &ce->constructor, ""__construct"", NULL, arg1, arg2); + zval_ptr_dtor(&arg1); + zval_ptr_dtor(&arg2); + } else { + intern->file_name = source->file_name; + intern->file_name_len = source->file_name_len; + intern->_path = spl_filesystem_object_get_path(source, &intern->_path_len TSRMLS_CC); + intern->_path = estrndup(intern->_path, intern->_path_len); + intern->u.file.open_mode = ""r""; + intern->u.file.open_mode_len = 1; + if (ht && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|sbr"", + &intern->u.file.open_mode, &intern->u.file.open_mode_len, + &use_include_path, &intern->u.file.zcontext) == FAILURE) { + zend_restore_error_handling(&error_handling TSRMLS_CC); + intern->u.file.open_mode = NULL; + intern->file_name = NULL; + zval_dtor(return_value); + Z_TYPE_P(return_value) = IS_NULL; + return NULL; + } + if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == FAILURE) { + zend_restore_error_handling(&error_handling TSRMLS_CC); + zval_dtor(return_value); + Z_TYPE_P(return_value) = IS_NULL; + return NULL; + } + } + break; + case SPL_FS_DIR: + zend_restore_error_handling(&error_handling TSRMLS_CC); + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, ""Operation not supported""); + return NULL; + } + zend_restore_error_handling(&error_handling TSRMLS_CC); + return NULL; +} /* }}} */ +",1,"static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_filesystem_object *source, int type, zend_class_entry *ce, zval *return_value TSRMLS_DC) /* {{{ */ +{ + spl_filesystem_object *intern; + zend_bool use_include_path = 0; + zval *arg1, *arg2; + zend_error_handling error_handling; + + zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); + + switch (source->type) { + case SPL_FS_INFO: + case SPL_FS_FILE: + break; + case SPL_FS_DIR: + if (!source->u.dir.entry.d_name[0]) { + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, ""Could not open file""); + zend_restore_error_handling(&error_handling TSRMLS_CC); + return NULL; + } + } + + switch (type) { + case SPL_FS_INFO: + ce = ce ? ce : source->info_class; + + zend_update_class_constants(ce TSRMLS_CC); + + return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC); + Z_TYPE_P(return_value) = IS_OBJECT; + + spl_filesystem_object_get_file_name(source TSRMLS_CC); + if (ce->constructor->common.scope != spl_ce_SplFileInfo) { + MAKE_STD_ZVAL(arg1); + ZVAL_STRINGL(arg1, source->file_name, source->file_name_len, 1); + zend_call_method_with_1_params(&return_value, ce, &ce->constructor, ""__construct"", NULL, arg1); + zval_ptr_dtor(&arg1); + } else { + intern->file_name = estrndup(source->file_name, source->file_name_len); + intern->file_name_len = source->file_name_len; + intern->_path = spl_filesystem_object_get_path(source, &intern->_path_len TSRMLS_CC); + intern->_path = estrndup(intern->_path, intern->_path_len); + } + break; + case SPL_FS_FILE: + ce = ce ? ce : source->file_class; + + zend_update_class_constants(ce TSRMLS_CC); + + return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC); + Z_TYPE_P(return_value) = IS_OBJECT; + + spl_filesystem_object_get_file_name(source TSRMLS_CC); + + if (ce->constructor->common.scope != spl_ce_SplFileObject) { + MAKE_STD_ZVAL(arg1); + MAKE_STD_ZVAL(arg2); + ZVAL_STRINGL(arg1, source->file_name, source->file_name_len, 1); + ZVAL_STRINGL(arg2, ""r"", 1, 1); + zend_call_method_with_2_params(&return_value, ce, &ce->constructor, ""__construct"", NULL, arg1, arg2); + zval_ptr_dtor(&arg1); + zval_ptr_dtor(&arg2); + } else { + intern->file_name = source->file_name; + intern->file_name_len = source->file_name_len; + intern->_path = spl_filesystem_object_get_path(source, &intern->_path_len TSRMLS_CC); + intern->_path = estrndup(intern->_path, intern->_path_len); + + intern->u.file.open_mode = ""r""; + intern->u.file.open_mode_len = 1; + + if (ht && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|sbr"", + &intern->u.file.open_mode, &intern->u.file.open_mode_len, + &use_include_path, &intern->u.file.zcontext) == FAILURE) { + zend_restore_error_handling(&error_handling TSRMLS_CC); + intern->u.file.open_mode = NULL; + intern->file_name = NULL; + zval_dtor(return_value); + Z_TYPE_P(return_value) = IS_NULL; + return NULL; + } + + if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == FAILURE) { + zend_restore_error_handling(&error_handling TSRMLS_CC); + zval_dtor(return_value); + Z_TYPE_P(return_value) = IS_NULL; + return NULL; + } + } + break; + case SPL_FS_DIR: + zend_restore_error_handling(&error_handling TSRMLS_CC); + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, ""Operation not supported""); + return NULL; + } + zend_restore_error_handling(&error_handling TSRMLS_CC); + return NULL; +} /* }}} */ +","@@ -79,9 +79,9 @@ static void spl_filesystem_object_free_storage(void *object TSRMLS_DC) /* {{{ */ + if (intern->oth_handler && intern->oth_handler->dtor) { + intern->oth_handler->dtor(intern TSRMLS_CC); + } +- ++ + zend_object_std_dtor(&intern->std TSRMLS_CC); +- ++ + if (intern->_path) { + efree(intern->_path); + } +@@ -98,7 +98,7 @@ static void spl_filesystem_object_free_storage(void *object TSRMLS_DC) /* {{{ */ + } + if (intern->u.dir.sub_path) { + efree(intern->u.dir.sub_path); +- } ++ } + break; + case SPL_FS_FILE: + if (intern->u.file.stream) { +@@ -134,13 +134,13 @@ static void spl_filesystem_object_free_storage(void *object TSRMLS_DC) /* {{{ */ + } /* }}} */ + + /* {{{ spl_ce_dir_object_new */ +-/* creates the object by +- - allocating memory ++/* creates the object by ++ - allocating memory + - initializing the object members + - storing the object + - setting it's handlers + +- called from ++ called from + - clone + - new + */ +@@ -313,7 +313,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu + /* avoid reference counting in debug mode, thus do it manually */ + ZVAL_RESOURCE(&intern->u.file.zresource, php_stream_get_resource_id(intern->u.file.stream)); + Z_SET_REFCOUNT(intern->u.file.zresource, 1); +- ++ + intern->u.file.delimiter = ','; + intern->u.file.enclosure = '""'; + intern->u.file.escape = '\\'; +@@ -325,7 +325,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu + + /* {{{ spl_filesystem_object_clone */ + /* Local zend_object_value creation (on stack) +- Load the 'other' object ++ Load the 'other' object + Create a new empty object (See spl_filesystem_object_new_ex) + Open the directory + Clone other members (properties) +@@ -370,7 +370,7 @@ static zend_object_value spl_filesystem_object_clone(zval *zobject TSRMLS_DC) + php_error_docref(NULL TSRMLS_CC, E_ERROR, ""An object of class %s cannot be cloned"", old_object->ce->name); + break; + } +- ++ + intern->file_class = source->file_class; + intern->info_class = source->info_class; + intern->oth = source->oth; +@@ -389,7 +389,7 @@ static zend_object_value spl_filesystem_object_clone(zval *zobject TSRMLS_DC) + void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path, int len, int use_copy TSRMLS_DC) /* {{{ */ + { + char *p1, *p2; +- ++ + if (intern->file_name) { + efree(intern->file_name); + } +@@ -413,7 +413,7 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path, + } else { + intern->_path_len = 0; + } +- ++ + if (intern->_path) { + efree(intern->_path); + } +@@ -459,7 +459,7 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_ + } else { + spl_filesystem_info_set_filename(intern, file_path, file_path_len, use_copy TSRMLS_CC); + } +- ++ + zend_restore_error_handling(&error_handling TSRMLS_CC); + return intern; + } /* }}} */ +@@ -514,7 +514,7 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil + + return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC); + Z_TYPE_P(return_value) = IS_OBJECT; +- ++ + spl_filesystem_object_get_file_name(source TSRMLS_CC); + + if (ce->constructor->common.scope != spl_ce_SplFileObject) { +@@ -530,12 +530,12 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil + intern->file_name_len = source->file_name_len; + intern->_path = spl_filesystem_object_get_path(source, &intern->_path_len TSRMLS_CC); + intern->_path = estrndup(intern->_path, intern->_path_len); +- ++ + intern->u.file.open_mode = ""r""; + intern->u.file.open_mode_len = 1; +- +- if (ht && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|sbr"", +- &intern->u.file.open_mode, &intern->u.file.open_mode_len, ++ ++ if (ht && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|sbr"", ++ &intern->u.file.open_mode, &intern->u.file.open_mode_len, + &use_include_path, &intern->u.file.zcontext) == FAILURE) { + zend_restore_error_handling(&error_handling TSRMLS_CC); + intern->u.file.open_mode = NULL; +@@ -544,7 +544,7 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil + Z_TYPE_P(return_value) = IS_NULL; + return NULL; + } +- ++ + if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == FAILURE) { + zend_restore_error_handling(&error_handling TSRMLS_CC); + zval_dtor(return_value); +@@ -553,7 +553,7 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil + } + } + break; +- case SPL_FS_DIR: ++ case SPL_FS_DIR: + zend_restore_error_handling(&error_handling TSRMLS_CC); + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, ""Operation not supported""); + return NULL; +@@ -617,7 +617,7 @@ static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp T + if (intern->file_name) { + pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, ""fileName"", sizeof(""fileName"")-1, &pnlen TSRMLS_CC); + spl_filesystem_object_get_path(intern, &path_len TSRMLS_CC); +- ++ + if (path_len && path_len < intern->file_name_len) { + add_assoc_stringl_ex(&zrv, pnstr, pnlen+1, intern->file_name + path_len + 1, intern->file_name_len - (path_len + 1), 1); + } else { +@@ -665,13 +665,13 @@ static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp T + zend_function *spl_filesystem_object_get_method_check(zval **object_ptr, char *method, int method_len, const struct _zend_literal *key TSRMLS_DC) /* {{{ */ + { + spl_filesystem_object *fsobj = zend_object_store_get_object(*object_ptr TSRMLS_CC); +- ++ + if (fsobj->u.dir.entry.d_name[0] == '\0' && fsobj->orig_path == NULL) { + method = ""_bad_state_ex""; + method_len = sizeof(""_bad_state_ex"") - 1; + key = NULL; + } +- ++ + return zend_get_std_object_handlers()->get_method(object_ptr, method, method_len, key TSRMLS_CC); + } + /* }}} */ +@@ -751,7 +751,7 @@ SPL_METHOD(DirectoryIterator, __construct) + SPL_METHOD(DirectoryIterator, rewind) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -769,7 +769,7 @@ SPL_METHOD(DirectoryIterator, rewind) + SPL_METHOD(DirectoryIterator, key) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -799,7 +799,7 @@ SPL_METHOD(DirectoryIterator, next) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -859,7 +859,7 @@ SPL_METHOD(DirectoryIterator, seek) + SPL_METHOD(DirectoryIterator, valid) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -875,7 +875,7 @@ SPL_METHOD(SplFileInfo, getPath) + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + char *path; + int path_len; +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -891,13 +891,13 @@ SPL_METHOD(SplFileInfo, getFilename) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + int path_len; +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + spl_filesystem_object_get_path(intern, &path_len TSRMLS_CC); +- ++ + if (path_len && path_len < intern->file_name_len) { + RETURN_STRINGL(intern->file_name + path_len + 1, intern->file_name_len - (path_len + 1), 1); + } else { +@@ -911,7 +911,7 @@ SPL_METHOD(SplFileInfo, getFilename) + SPL_METHOD(DirectoryIterator, getFilename) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1019,7 +1019,7 @@ SPL_METHOD(SplFileInfo, getBasename) + + RETURN_STRINGL(fname, flen, 0); + } +-/* }}}*/ ++/* }}}*/ + + /* {{{ proto string DirectoryIterator::getBasename([string $suffix]) U + Returns filename component of current dir entry */ +@@ -1029,7 +1029,7 @@ SPL_METHOD(DirectoryIterator, getBasename) + char *suffix = 0, *fname; + int slen = 0; + size_t flen; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|s"", &suffix, &slen) == FAILURE) { + return; + } +@@ -1065,7 +1065,7 @@ SPL_METHOD(SplFileInfo, getPathname) + SPL_METHOD(FilesystemIterator, key) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1084,7 +1084,7 @@ SPL_METHOD(FilesystemIterator, key) + SPL_METHOD(FilesystemIterator, current) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1107,7 +1107,7 @@ SPL_METHOD(FilesystemIterator, current) + SPL_METHOD(DirectoryIterator, isDot) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1121,8 +1121,8 @@ SPL_METHOD(DirectoryIterator, isDot) + /* zend_replace_error_handling() is used to throw exceptions in case + the constructor fails. Here we use this to ensure the object + has a valid directory resource. +- +- When the constructor gets called the object is already created ++ ++ When the constructor gets called the object is already created + by the engine, so we must only call 'additional' initializations. + */ + SPL_METHOD(SplFileInfo, __construct) +@@ -1140,11 +1140,11 @@ SPL_METHOD(SplFileInfo, __construct) + } + + intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + spl_filesystem_info_set_filename(intern, path, len, 1 TSRMLS_CC); + + zend_restore_error_handling(&error_handling TSRMLS_CC); +- ++ + /* intern->type = SPL_FS_INFO; already set */ + } + /* }}} */ +@@ -1249,7 +1249,7 @@ SPL_METHOD(SplFileInfo, getLinkTarget) + int ret; + char buff[MAXPATHLEN]; + zend_error_handling error_handling; +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1297,7 +1297,7 @@ SPL_METHOD(SplFileInfo, getRealPath) + char buff[MAXPATHLEN]; + char *filename; + zend_error_handling error_handling; +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1307,10 +1307,10 @@ SPL_METHOD(SplFileInfo, getRealPath) + if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) { + spl_filesystem_object_get_file_name(intern TSRMLS_CC); + } +- ++ + if (intern->orig_path) { + filename = intern->orig_path; +- } else { ++ } else { + filename = intern->file_name; + } + +@@ -1348,7 +1348,7 @@ SPL_METHOD(SplFileInfo, setFileClass) + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + zend_class_entry *ce = spl_ce_SplFileObject; + zend_error_handling error_handling; +- ++ + zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|C"", &ce) == SUCCESS) { +@@ -1366,7 +1366,7 @@ SPL_METHOD(SplFileInfo, setInfoClass) + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + zend_class_entry *ce = spl_ce_SplFileInfo; + zend_error_handling error_handling; +- ++ + zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|C"", &ce) == SUCCESS) { +@@ -1384,7 +1384,7 @@ SPL_METHOD(SplFileInfo, getFileInfo) + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + zend_class_entry *ce = intern->info_class; + zend_error_handling error_handling; +- ++ + zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|C"", &ce) == SUCCESS) { +@@ -1402,7 +1402,7 @@ SPL_METHOD(SplFileInfo, getPathInfo) + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + zend_class_entry *ce = intern->info_class; + zend_error_handling error_handling; +- ++ + zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|C"", &ce) == SUCCESS) { +@@ -1463,7 +1463,7 @@ SPL_METHOD(FilesystemIterator, rewind) + SPL_METHOD(FilesystemIterator, getFlags) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1519,11 +1519,11 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren) + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + spl_filesystem_object *subdir; + char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH; +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +- ++ + spl_filesystem_object_get_file_name(intern TSRMLS_CC); + + MAKE_STD_ZVAL(zflags); +@@ -1554,7 +1554,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren) + SPL_METHOD(RecursiveDirectoryIterator, getSubPath) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1575,7 +1575,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPathname) + char *sub_name; + int len; + char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH; +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1611,7 +1611,7 @@ SPL_METHOD(GlobIterator, __construct) + SPL_METHOD(GlobIterator, count) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -1666,7 +1666,7 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval + iterator->current = object; + } + zval_add_ref(&object); +- ++ + return (zend_object_iterator*)iterator; + } + /* }}} */ +@@ -1701,7 +1701,7 @@ static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC) + static void spl_filesystem_dir_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) + { + spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter; +- ++ + *data = &iterator->current; + } + /* }}} */ +@@ -1719,7 +1719,7 @@ static void spl_filesystem_dir_it_current_key(zend_object_iterator *iter, zval * + static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter TSRMLS_DC) + { + spl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter); +- ++ + object->u.dir.index++; + spl_filesystem_dir_read(object TSRMLS_CC); + if (object->file_name) { +@@ -1733,7 +1733,7 @@ static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter TSRMLS + static void spl_filesystem_dir_it_rewind(zend_object_iterator *iter TSRMLS_DC) + { + spl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter); +- ++ + object->u.dir.index = 0; + if (object->u.dir.dirp) { + php_stream_rewinddir(object->u.dir.dirp); +@@ -1803,7 +1803,7 @@ static void spl_filesystem_tree_it_move_forward(zend_object_iterator *iter TSRML + { + spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter; + spl_filesystem_object *object = spl_filesystem_iterator_to_object(iterator); +- ++ + object->u.dir.index++; + do { + spl_filesystem_dir_read(object TSRMLS_CC); +@@ -1824,7 +1824,7 @@ static void spl_filesystem_tree_it_rewind(zend_object_iterator *iter TSRMLS_DC) + { + spl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter; + spl_filesystem_object *object = spl_filesystem_iterator_to_object(iterator); +- ++ + object->u.dir.index = 0; + if (object->u.dir.dirp) { + php_stream_rewinddir(object->u.dir.dirp); +@@ -1868,7 +1868,7 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva + iterator->intern.funcs = &spl_filesystem_tree_it_funcs; + } + zval_add_ref(&object); +- ++ + return (zend_object_iterator*)iterator; + } + /* }}} */ +@@ -1924,7 +1924,7 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS + + /* {{{ declare method parameters */ + /* supply a name and default to call by parameter */ +-ZEND_BEGIN_ARG_INFO(arginfo_info___construct, 0) ++ZEND_BEGIN_ARG_INFO(arginfo_info___construct, 0) + ZEND_ARG_INFO(0, file_name) + ZEND_END_ARG_INFO() + +@@ -1983,11 +1983,11 @@ static const zend_function_entry spl_SplFileInfo_functions[] = { + PHP_FE_END + }; + +-ZEND_BEGIN_ARG_INFO(arginfo_dir___construct, 0) ++ZEND_BEGIN_ARG_INFO(arginfo_dir___construct, 0) + ZEND_ARG_INFO(0, path) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO(arginfo_dir_it_seek, 0) ++ZEND_BEGIN_ARG_INFO(arginfo_dir_it_seek, 0) + ZEND_ARG_INFO(0, position) + ZEND_END_ARG_INFO(); + +@@ -2009,7 +2009,7 @@ static const zend_function_entry spl_DirectoryIterator_functions[] = { + PHP_FE_END + }; + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir___construct, 0, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir___construct, 0, 0, 1) + ZEND_ARG_INFO(0, path) + ZEND_ARG_INFO(0, flags) + ZEND_END_ARG_INFO() +@@ -2058,7 +2058,7 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS + long line_add = (intern->u.file.current_line || intern->u.file.current_zval) ? 1 : 0; + + spl_filesystem_file_free_line(intern TSRMLS_CC); +- ++ + if (php_stream_eof(intern->u.file.stream)) { + if (!silent) { + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, ""Cannot read from file %s"", intern->file_name); +@@ -2086,7 +2086,7 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS + line_len = strcspn(buf, ""\r\n""); + buf[line_len] = '\0'; + } +- ++ + intern->u.file.current_line = buf; + intern->u.file.current_line_len = line_len; + } +@@ -2107,7 +2107,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function + zval ***params = (zval***)safe_emalloc(num_args, sizeof(zval**), 0); + + params[0] = &zresource_ptr; +- ++ + if (arg2) { + params[1] = &arg2; + } +@@ -2133,7 +2133,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function + fcic.object_ptr = NULL; + + result = zend_call_function(&fci, &fcic TSRMLS_CC); +- ++ + if (result == FAILURE) { + RETVAL_FALSE; + } else { +@@ -2159,11 +2159,11 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function + static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, char escape, zval *return_value TSRMLS_DC) /* {{{ */ + { + int ret = SUCCESS; +- ++ + do { + ret = spl_filesystem_file_read(intern, 1 TSRMLS_CC); + } while (ret == SUCCESS && !intern->u.file.current_line_len && SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY)); +- ++ + if (ret == SUCCESS) { + size_t buf_len = intern->u.file.current_line_len; + char *buf = estrndup(intern->u.file.current_line, buf_len); +@@ -2237,7 +2237,7 @@ static int spl_filesystem_file_is_empty_line(spl_filesystem_object *intern TSRML + if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV) + && zend_hash_num_elements(Z_ARRVAL_P(intern->u.file.current_zval)) == 1) { + zval ** first = Z_ARRVAL_P(intern->u.file.current_zval)->pListHead->pData; +- ++ + return Z_TYPE_PP(first) == IS_STRING && Z_STRLEN_PP(first) == 0; + } + return zend_hash_num_elements(Z_ARRVAL_P(intern->u.file.current_zval)) == 0; +@@ -2260,7 +2260,7 @@ static int spl_filesystem_file_read_line(zval * this_ptr, spl_filesystem_object + spl_filesystem_file_free_line(intern TSRMLS_CC); + ret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent TSRMLS_CC); + } +- ++ + return ret; + } + /* }}} */ +@@ -2294,16 +2294,16 @@ SPL_METHOD(SplFileObject, __construct) + intern->u.file.open_mode = NULL; + intern->u.file.open_mode_len = 0; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""p|sbr!"", ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""p|sbr!"", + &intern->file_name, &intern->file_name_len, +- &intern->u.file.open_mode, &intern->u.file.open_mode_len, +- &use_include_path, &intern->u.file.zcontext) == FAILURE) { ++ &intern->u.file.open_mode, &intern->u.file.open_mode_len, ++ &use_include_path, &intern->u.file.zcontext) == FAILURE) { + intern->u.file.open_mode = NULL; + intern->file_name = NULL; + zend_restore_error_handling(&error_handling TSRMLS_CC); + return; + } +- ++ + if (intern->u.file.open_mode == NULL) { + intern->u.file.open_mode = ""r""; + intern->u.file.open_mode_len = 1; +@@ -2368,7 +2368,7 @@ SPL_METHOD(SplTempFileObject, __construct) + intern->u.file.open_mode = ""wb""; + intern->u.file.open_mode_len = 1; + intern->u.file.zcontext = NULL; +- ++ + if (spl_filesystem_file_open(intern, 0, 0 TSRMLS_CC) == SUCCESS) { + intern->_path_len = 0; + intern->_path = estrndup("""", 0); +@@ -2381,7 +2381,7 @@ SPL_METHOD(SplTempFileObject, __construct) + SPL_METHOD(SplFileObject, rewind) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2394,7 +2394,7 @@ SPL_METHOD(SplFileObject, rewind) + SPL_METHOD(SplFileObject, eof) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2407,7 +2407,7 @@ SPL_METHOD(SplFileObject, eof) + SPL_METHOD(SplFileObject, valid) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2424,7 +2424,7 @@ SPL_METHOD(SplFileObject, valid) + SPL_METHOD(SplFileObject, fgets) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2440,7 +2440,7 @@ SPL_METHOD(SplFileObject, fgets) + SPL_METHOD(SplFileObject, current) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2461,7 +2461,7 @@ SPL_METHOD(SplFileObject, current) + SPL_METHOD(SplFileObject, key) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2478,7 +2478,7 @@ SPL_METHOD(SplFileObject, key) + SPL_METHOD(SplFileObject, next) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2530,7 +2530,7 @@ SPL_METHOD(SplFileObject, setMaxLineLen) + zend_throw_exception_ex(spl_ce_DomainException, 0 TSRMLS_CC, ""Maximum line length must be greater than or equal zero""); + return; + } +- ++ + intern->u.file.max_line_len = max_len; + } /* }}} */ + +@@ -2539,7 +2539,7 @@ SPL_METHOD(SplFileObject, setMaxLineLen) + SPL_METHOD(SplFileObject, getMaxLineLen) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2554,7 +2554,7 @@ SPL_METHOD(SplFileObject, hasChildren) + if (zend_parse_parameters_none() == FAILURE) { + return; + } +- ++ + RETURN_FALSE; + } /* }}} */ + +@@ -2585,7 +2585,7 @@ SPL_METHOD(SplFileObject, fgetcsv) + char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape; + char *delim = NULL, *enclo = NULL, *esc = NULL; + int d_len = 0, e_len = 0, esc_len = 0; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|sss"", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) { + switch(ZEND_NUM_ARGS()) + { +@@ -2627,7 +2627,7 @@ SPL_METHOD(SplFileObject, fputcsv) + char *delim = NULL, *enclo = NULL, *esc = NULL; + int d_len = 0, e_len = 0, esc_len = 0, ret; + zval *fields = NULL; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""a|sss"", &fields, &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) { + switch(ZEND_NUM_ARGS()) + { +@@ -2670,7 +2670,7 @@ SPL_METHOD(SplFileObject, setCsvControl) + char delimiter = ',', enclosure = '""', escape='\\'; + char *delim = NULL, *enclo = NULL, *esc = NULL; + int d_len = 0, e_len = 0, esc_len = 0; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""|sss"", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) { + switch(ZEND_NUM_ARGS()) + { +@@ -2713,7 +2713,7 @@ SPL_METHOD(SplFileObject, getCsvControl) + char delimiter[2], enclosure[2]; + + array_init(return_value); +- ++ + delimiter[0] = intern->u.file.delimiter; + delimiter[1] = '\0'; + enclosure[0] = intern->u.file.enclosure; +@@ -2742,7 +2742,7 @@ SPL_METHOD(SplFileObject, fflush) + Return current file position */ + SPL_METHOD(SplFileObject, ftell) + { +- spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + long ret = php_stream_tell(intern->u.file.stream); + + if (ret == -1) { +@@ -2872,6 +2872,10 @@ SPL_METHOD(SplFileObject, fread) + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Length parameter must be greater than 0""); + RETURN_FALSE; + } ++ if (length > INT_MAX) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Length parameter must be no more than %d"", INT_MAX); ++ RETURN_FALSE; ++ } + + Z_STRVAL_P(return_value) = emalloc(length + 1); + Z_STRLEN_P(return_value) = php_stream_read(intern->u.file.stream, Z_STRVAL_P(return_value), length); +@@ -2892,7 +2896,7 @@ SPL_METHOD(SplFileObject, ftruncate) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + long size; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""l"", &size) == FAILURE) { + return; + } +@@ -2901,7 +2905,7 @@ SPL_METHOD(SplFileObject, ftruncate) + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, ""Can't truncate file %s"", intern->file_name); + RETURN_FALSE; + } +- ++ + RETURN_BOOL(0 == php_stream_truncate_set_size(intern->u.file.stream, size)); + } /* }}} */ + +@@ -2911,17 +2915,17 @@ SPL_METHOD(SplFileObject, seek) + { + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + long line_pos; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""l"", &line_pos) == FAILURE) { + return; + } + if (line_pos < 0) { + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, ""Can't seek file %s to negative line %ld"", intern->file_name, line_pos); +- RETURN_FALSE; ++ RETURN_FALSE; + } +- ++ + spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC); +- ++ + while(intern->u.file.current_line_num < line_pos) { + if (spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC) == FAILURE) { + break; +@@ -2958,25 +2962,25 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fputcsv, 0, 0, 1) + ZEND_ARG_INFO(0, escape) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_flock, 0, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_flock, 0, 0, 1) + ZEND_ARG_INFO(0, operation) + ZEND_ARG_INFO(1, wouldblock) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fseek, 0, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fseek, 0, 0, 1) + ZEND_ARG_INFO(0, pos) + ZEND_ARG_INFO(0, whence) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetss, 0, 0, 0) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetss, 0, 0, 0) + ZEND_ARG_INFO(0, allowable_tags) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 1, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 1, 0, 1) + ZEND_ARG_INFO(0, format) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fwrite, 0, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fwrite, 0, 0, 1) + ZEND_ARG_INFO(0, str) + ZEND_ARG_INFO(0, length) + ZEND_END_ARG_INFO() +@@ -2985,11 +2989,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fread, 0, 0, 1) + ZEND_ARG_INFO(0, length) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_ftruncate, 0, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_ftruncate, 0, 0, 1) + ZEND_ARG_INFO(0, size) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_seek, 0, 0, 1) ++ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_seek, 0, 0, 1) + ZEND_ARG_INFO(0, line_pos) + ZEND_END_ARG_INFO() + +@@ -3078,7 +3082,7 @@ PHP_MINIT_FUNCTION(spl_directory) + + REGISTER_SPL_SUB_CLASS_EX(RecursiveDirectoryIterator, FilesystemIterator, spl_filesystem_object_new, spl_RecursiveDirectoryIterator_functions); + REGISTER_SPL_IMPLEMENTS(RecursiveDirectoryIterator, RecursiveIterator); +- ++ + memcpy(&spl_filesystem_object_check_handlers, &spl_filesystem_object_handlers, sizeof(zend_object_handlers)); + spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check; + +@@ -3095,7 +3099,7 @@ PHP_MINIT_FUNCTION(spl_directory) + REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, ""READ_AHEAD"", SPL_FILE_OBJECT_READ_AHEAD); + REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, ""SKIP_EMPTY"", SPL_FILE_OBJECT_SKIP_EMPTY); + REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, ""READ_CSV"", SPL_FILE_OBJECT_READ_CSV); +- ++ + REGISTER_SPL_SUB_CLASS_EX(SplTempFileObject, SplFileObject, spl_filesystem_object_new_check, spl_SplTempFileObject_functions); + return SUCCESS; + }",982,1218,2048 +14079,"Document::Document(const DocumentInit& initializer, + DocumentClassFlags document_classes) + : ContainerNode(nullptr, kCreateDocument), + TreeScope(*this), + ExecutionContext(V8PerIsolateData::MainThreadIsolate()), + evaluate_media_queries_on_style_recalc_(false), + pending_sheet_layout_(kNoLayoutWithPendingSheets), + frame_(initializer.GetFrame()), + dom_window_(frame_ ? frame_->DomWindow() : nullptr), + imports_controller_(initializer.ImportsController()), + context_document_(initializer.ContextDocument()), + context_features_(ContextFeatures::DefaultSwitch()), + well_formed_(false), + printing_(kNotPrinting), + compatibility_mode_(kNoQuirksMode), + compatibility_mode_locked_(false), + has_autofocused_(false), + last_focus_type_(kWebFocusTypeNone), + had_keyboard_event_(false), + clear_focused_element_timer_( + GetTaskRunner(TaskType::kInternalUserInteraction), + this, + &Document::ClearFocusedElementTimerFired), + dom_tree_version_(++global_tree_version_), + style_version_(0), + listener_types_(0), + mutation_observer_types_(0), + visited_link_state_(VisitedLinkState::Create(*this)), + visually_ordered_(false), + ready_state_(kComplete), + parsing_state_(kFinishedParsing), + contains_validity_style_rules_(false), + contains_plugins_(false), + ignore_destructive_write_count_(0), + throw_on_dynamic_markup_insertion_count_(0), + ignore_opens_during_unload_count_(0), + markers_(MakeGarbageCollected(*this)), + update_focus_appearance_timer_( + GetTaskRunner(TaskType::kInternalUserInteraction), + this, + &Document::UpdateFocusAppearanceTimerFired), + css_target_(nullptr), + was_discarded_(false), + load_event_progress_(kLoadEventCompleted), + is_freezing_in_progress_(false), + start_time_(CurrentTime()), + script_runner_(ScriptRunner::Create(this)), + xml_version_(""1.0""), + xml_standalone_(kStandaloneUnspecified), + has_xml_declaration_(0), + design_mode_(false), + is_running_exec_command_(false), + has_annotated_regions_(false), + annotated_regions_dirty_(false), + document_classes_(document_classes), + is_view_source_(false), + saw_elements_in_known_namespaces_(false), + is_srcdoc_document_(initializer.IsSrcdocDocument()), + is_mobile_document_(false), + layout_view_(nullptr), + has_fullscreen_supplement_(false), + load_event_delay_count_(0), + load_event_delay_timer_(GetTaskRunner(TaskType::kNetworking), + this, + &Document::LoadEventDelayTimerFired), + plugin_loading_timer_(GetTaskRunner(TaskType::kInternalLoading), + this, + &Document::PluginLoadingTimerFired), + document_timing_(*this), + write_recursion_is_too_deep_(false), + write_recursion_depth_(0), + registration_context_(initializer.RegistrationContext(this)), + element_data_cache_clear_timer_( + GetTaskRunner(TaskType::kInternalUserInteraction), + this, + &Document::ElementDataCacheClearTimerFired), + timeline_(DocumentTimeline::Create(this)), + pending_animations_(MakeGarbageCollected(*this)), + worklet_animation_controller_( + MakeGarbageCollected(this)), + template_document_host_(nullptr), + did_associate_form_controls_timer_( + GetTaskRunner(TaskType::kInternalLoading), + this, + &Document::DidAssociateFormControlsTimerFired), + timers_(GetTaskRunner(TaskType::kJavascriptTimer)), + has_viewport_units_(false), + parser_sync_policy_(kAllowAsynchronousParsing), + node_count_(0), + logged_field_edit_(false), + secure_context_state_(SecureContextState::kUnknown), + ukm_source_id_(ukm::UkmRecorder::GetNewSourceID()), +#if DCHECK_IS_ON() + slot_assignment_recalc_forbidden_recursion_depth_(0), +#endif + needs_to_record_ukm_outlive_time_(false), + viewport_data_(MakeGarbageCollected(*this)), + agent_cluster_id_(base::UnguessableToken::Create()), + parsed_feature_policies_( + static_cast(mojom::FeaturePolicyFeature::kMaxValue) + 1), + potentially_violated_features_( + static_cast(mojom::FeaturePolicyFeature::kMaxValue) + 1U), + isolated_world_csp_map_( + MakeGarbageCollected< + HeapHashMap>>()) { + if (frame_) { + DCHECK(frame_->GetPage()); + ProvideContextFeaturesToDocumentFrom(*this, *frame_->GetPage()); + fetcher_ = FrameFetchContext::CreateFetcherForCommittedDocument( + *frame_->Loader().GetDocumentLoader(), *this); + CustomElementRegistry* registry = + frame_->DomWindow() ? frame_->DomWindow()->MaybeCustomElements() + : nullptr; + if (registry && registration_context_) + registry->Entangle(registration_context_); + } else if (imports_controller_) { + fetcher_ = FrameFetchContext::CreateFetcherForImportedDocument(this); + } else { + fetcher_ = MakeGarbageCollected(ResourceFetcherInit( + *MakeGarbageCollected(), + &FetchContext::NullInstance(), GetTaskRunner(TaskType::kNetworking))); + } + DCHECK(fetcher_); + + root_scroller_controller_ = RootScrollerController::Create(*this); + + if (initializer.ShouldSetURL()) { + SetURL(initializer.Url()); + } else { + UpdateBaseURL(); + } + + InitSecurityContext(initializer); + if (frame_) + frame_->Client()->DidSetFramePolicyHeaders(GetSandboxFlags(), {}); + + InitDNSPrefetch(); + + InstanceCounters::IncrementCounter(InstanceCounters::kDocumentCounter); + + lifecycle_.AdvanceTo(DocumentLifecycle::kInactive); + + style_engine_ = StyleEngine::Create(*this); + + DCHECK(!ParentDocument() || !ParentDocument()->IsContextPaused()); + +#ifndef NDEBUG + liveDocumentSet().insert(this); +#endif +} +",0,"Document::Document(const DocumentInit& initializer, + DocumentClassFlags document_classes) + : ContainerNode(nullptr, kCreateDocument), + TreeScope(*this), + ExecutionContext(V8PerIsolateData::MainThreadIsolate()), + evaluate_media_queries_on_style_recalc_(false), + pending_sheet_layout_(kNoLayoutWithPendingSheets), + frame_(initializer.GetFrame()), + dom_window_(frame_ ? frame_->DomWindow() : nullptr), + imports_controller_(initializer.ImportsController()), + context_document_(initializer.ContextDocument()), + context_features_(ContextFeatures::DefaultSwitch()), + well_formed_(false), + printing_(kNotPrinting), + compatibility_mode_(kNoQuirksMode), + compatibility_mode_locked_(false), + has_autofocused_(false), + last_focus_type_(kWebFocusTypeNone), + had_keyboard_event_(false), + clear_focused_element_timer_( + GetTaskRunner(TaskType::kInternalUserInteraction), + this, + &Document::ClearFocusedElementTimerFired), + dom_tree_version_(++global_tree_version_), + style_version_(0), + listener_types_(0), + mutation_observer_types_(0), + visited_link_state_(VisitedLinkState::Create(*this)), + visually_ordered_(false), + ready_state_(kComplete), + parsing_state_(kFinishedParsing), + contains_validity_style_rules_(false), + contains_plugins_(false), + ignore_destructive_write_count_(0), + throw_on_dynamic_markup_insertion_count_(0), + ignore_opens_during_unload_count_(0), + markers_(MakeGarbageCollected(*this)), + update_focus_appearance_timer_( + GetTaskRunner(TaskType::kInternalUserInteraction), + this, + &Document::UpdateFocusAppearanceTimerFired), + css_target_(nullptr), + was_discarded_(false), + load_event_progress_(kLoadEventCompleted), + is_freezing_in_progress_(false), + start_time_(CurrentTime()), + script_runner_(ScriptRunner::Create(this)), + xml_version_(""1.0""), + xml_standalone_(kStandaloneUnspecified), + has_xml_declaration_(0), + design_mode_(false), + is_running_exec_command_(false), + has_annotated_regions_(false), + annotated_regions_dirty_(false), + document_classes_(document_classes), + is_view_source_(false), + saw_elements_in_known_namespaces_(false), + is_srcdoc_document_(initializer.IsSrcdocDocument()), + is_mobile_document_(false), + layout_view_(nullptr), + has_fullscreen_supplement_(false), + load_event_delay_count_(0), + load_event_delay_timer_(GetTaskRunner(TaskType::kNetworking), + this, + &Document::LoadEventDelayTimerFired), + plugin_loading_timer_(GetTaskRunner(TaskType::kInternalLoading), + this, + &Document::PluginLoadingTimerFired), + document_timing_(*this), + write_recursion_is_too_deep_(false), + write_recursion_depth_(0), + registration_context_(initializer.RegistrationContext(this)), + element_data_cache_clear_timer_( + GetTaskRunner(TaskType::kInternalUserInteraction), + this, + &Document::ElementDataCacheClearTimerFired), + timeline_(DocumentTimeline::Create(this)), + pending_animations_(MakeGarbageCollected(*this)), + worklet_animation_controller_( + MakeGarbageCollected(this)), + template_document_host_(nullptr), + did_associate_form_controls_timer_( + GetTaskRunner(TaskType::kInternalLoading), + this, + &Document::DidAssociateFormControlsTimerFired), + timers_(GetTaskRunner(TaskType::kJavascriptTimer)), + has_viewport_units_(false), + parser_sync_policy_(kAllowAsynchronousParsing), + node_count_(0), + logged_field_edit_(false), + secure_context_state_(SecureContextState::kUnknown), + ukm_source_id_(ukm::UkmRecorder::GetNewSourceID()), +#if DCHECK_IS_ON() + slot_assignment_recalc_forbidden_recursion_depth_(0), +#endif + needs_to_record_ukm_outlive_time_(false), + viewport_data_(MakeGarbageCollected(*this)), + agent_cluster_id_(base::UnguessableToken::Create()), + parsed_feature_policies_( + static_cast(mojom::FeaturePolicyFeature::kMaxValue) + 1), + potentially_violated_features_( + static_cast(mojom::FeaturePolicyFeature::kMaxValue) + 1U), + isolated_world_csp_map_( + MakeGarbageCollected< + HeapHashMap>>()) { + if (frame_) { + DCHECK(frame_->GetPage()); + ProvideContextFeaturesToDocumentFrom(*this, *frame_->GetPage()); + fetcher_ = FrameFetchContext::CreateFetcherForCommittedDocument( + *frame_->Loader().GetDocumentLoader(), *this); + CustomElementRegistry* registry = + frame_->DomWindow() ? frame_->DomWindow()->MaybeCustomElements() + : nullptr; + if (registry && registration_context_) + registry->Entangle(registration_context_); + } else if (imports_controller_) { + fetcher_ = FrameFetchContext::CreateFetcherForImportedDocument(this); + } else { + fetcher_ = MakeGarbageCollected(ResourceFetcherInit( + *MakeGarbageCollected(), + &FetchContext::NullInstance(), GetTaskRunner(TaskType::kNetworking))); + } + DCHECK(fetcher_); + + root_scroller_controller_ = RootScrollerController::Create(*this); + + if (initializer.ShouldSetURL()) { + SetURL(initializer.Url()); + } else { + UpdateBaseURL(); + } + + InitSecurityContext(initializer); + if (frame_) + frame_->Client()->DidSetFramePolicyHeaders(GetSandboxFlags(), {}); + + InitDNSPrefetch(); + + InstanceCounters::IncrementCounter(InstanceCounters::kDocumentCounter); + + lifecycle_.AdvanceTo(DocumentLifecycle::kInactive); + + style_engine_ = StyleEngine::Create(*this); + + DCHECK(!ParentDocument() || !ParentDocument()->IsContextPaused()); + +#ifndef NDEBUG + liveDocumentSet().insert(this); +#endif +} +","@@ -4657,8 +4657,10 @@ bool Document::SetFocusedElement(Element* new_focused_element, + if (IsRootEditableElement(*new_focused_element) && + !AcceptsEditingFocus(*new_focused_element)) { + // delegate blocks focus change +- focus_change_blocked = true; +- goto SetFocusedElementDone; ++ UpdateStyleAndLayoutTree(); ++ if (LocalFrame* frame = GetFrame()) ++ frame->Selection().DidChangeFocus(); ++ return false; + } + // Set focus on the new node + focused_element_ = new_focused_element; +@@ -4673,18 +4675,13 @@ bool Document::SetFocusedElement(Element* new_focused_element, + + // Element::setFocused for frames can dispatch events. + if (focused_element_ != new_focused_element) { +- focus_change_blocked = true; +- goto SetFocusedElementDone; ++ UpdateStyleAndLayoutTree(); ++ if (LocalFrame* frame = GetFrame()) ++ frame->Selection().DidChangeFocus(); ++ return false; + } + CancelFocusAppearanceUpdate(); + EnsurePaintLocationDataValidForNode(focused_element_); +- // UpdateStyleAndLayout can call SetFocusedElement (through +- // InvokeFragmentAnchor called in Document::LayoutUpdated) and clear +- // focused_element_. +- if (focused_element_ != new_focused_element) { +- focus_change_blocked = true; +- goto SetFocusedElementDone; +- } + focused_element_->UpdateFocusAppearanceWithOptions( + params.selection_behavior, params.options); + +@@ -4698,8 +4695,10 @@ bool Document::SetFocusedElement(Element* new_focused_element, + + if (focused_element_ != new_focused_element) { + // handler shifted focus +- focus_change_blocked = true; +- goto SetFocusedElementDone; ++ UpdateStyleAndLayoutTree(); ++ if (LocalFrame* frame = GetFrame()) ++ frame->Selection().DidChangeFocus(); ++ return false; + } + // DOM level 3 bubbling focus event. + focused_element_->DispatchFocusInEvent(event_type_names::kFocusin, +@@ -4708,8 +4707,10 @@ bool Document::SetFocusedElement(Element* new_focused_element, + + if (focused_element_ != new_focused_element) { + // handler shifted focus +- focus_change_blocked = true; +- goto SetFocusedElementDone; ++ UpdateStyleAndLayoutTree(); ++ if (LocalFrame* frame = GetFrame()) ++ frame->Selection().DidChangeFocus(); ++ return false; + } + + // For DOM level 2 compatibility. +@@ -4721,8 +4722,10 @@ bool Document::SetFocusedElement(Element* new_focused_element, + + if (focused_element_ != new_focused_element) { + // handler shifted focus +- focus_change_blocked = true; +- goto SetFocusedElementDone; ++ UpdateStyleAndLayoutTree(); ++ if (LocalFrame* frame = GetFrame()) ++ frame->Selection().DidChangeFocus(); ++ return false; + } + } + } +@@ -4741,7 +4744,6 @@ bool Document::SetFocusedElement(Element* new_focused_element, + focused_element_.Get()); + } + +-SetFocusedElementDone: + UpdateStyleAndLayoutTree(); + if (LocalFrame* frame = GetFrame()) + frame->Selection().DidChangeFocus();",1309,1545,2048 +11051,"bool WebPage::blockZoom(const Platform::IntPoint& documentTargetPoint) +{ + if (!d->m_mainFrame->view() || !d->isUserScalable()) + return false; + + Node* node = d->bestNodeForZoomUnderPoint(documentTargetPoint); + if (!node) + return false; + + IntRect nodeRect = d->rectForNode(node); + IntRect blockRect; + bool endOfBlockZoomMode = d->compareNodesForBlockZoom(d->m_currentBlockZoomAdjustedNode.get(), node); + const double oldScale = d->m_transformationMatrix->m11(); + double newScale = 0; + const double margin = endOfBlockZoomMode ? 0 : blockZoomMargin * 2 * oldScale; + bool isFirstZoom = false; + + if (endOfBlockZoomMode) { + IntRect rect = d->blockZoomRectForNode(node); + blockRect = IntRect(0, rect.y(), d->transformedContentsSize().width(), d->transformedContentsSize().height() - rect.y()); + d->m_shouldReflowBlock = false; + } else { + Node* tempBlockZoomAdjustedNode = d->m_currentBlockZoomAdjustedNode.get(); + blockRect = d->blockZoomRectForNode(node); + + if (!node->hasTagName(HTMLNames::imgTag)) { + IntRect tRect = d->mapFromTransformed(blockRect); + int blockArea = tRect.width() * tRect.height(); + int pageArea = d->contentsSize().width() * d->contentsSize().height(); + double blockToPageRatio = static_cast(pageArea - blockArea) / pageArea; + if (blockToPageRatio < minimumExpandingRatio) { + d->m_currentBlockZoomAdjustedNode = tempBlockZoomAdjustedNode; + return false; + } + } + + if (blockRect.isEmpty() || !blockRect.width() || !blockRect.height()) + return false; + + if (!d->m_currentBlockZoomNode.get()) + isFirstZoom = true; + + d->m_currentBlockZoomNode = node; + d->m_shouldReflowBlock = true; + } + + newScale = std::min(d->newScaleForBlockZoomRect(blockRect, oldScale, margin), d->maxBlockZoomScale()); + newScale = std::max(newScale, minimumScale()); + +#if ENABLE(VIEWPORT_REFLOW) + if (d->m_currentBlockZoomNode && d->m_shouldReflowBlock && settings()->textReflowMode() != WebSettings::TextReflowDisabled) { + RenderObject* renderer = d->m_currentBlockZoomNode->renderer(); + if (renderer && renderer->isText()) { + double newFontSize = renderer->style()->fontSize() * newScale; + if (newFontSize < d->m_webSettings->defaultFontSize()) { + newScale = std::min(static_cast(d->m_webSettings->defaultFontSize()) / renderer->style()->fontSize(), d->maxBlockZoomScale()); + newScale = std::max(newScale, minimumScale()); + } + blockRect.setWidth(oldScale * static_cast(d->transformedActualVisibleSize().width()) / newScale); + newScale = std::min(d->newScaleForBlockZoomRect(blockRect, oldScale, margin), d->maxBlockZoomScale()); + newScale = std::max(newScale, minimumScale()); // Still, it's not allowed to be smaller than minimum scale. + } + } +#endif + + double newBlockHeight = d->mapFromTransformed(blockRect).height(); + double newBlockWidth = d->mapFromTransformed(blockRect).width(); + double scaledViewportWidth = static_cast(d->actualVisibleSize().width()) * oldScale / newScale; + double scaledViewportHeight = static_cast(d->actualVisibleSize().height()) * oldScale / newScale; + double dx = std::max(0.0, (scaledViewportWidth - newBlockWidth) / 2.0); + double dy = std::max(0.0, (scaledViewportHeight - newBlockHeight) / 2.0); + + RenderObject* renderer = d->m_currentBlockZoomAdjustedNode->renderer(); + FloatPoint anchor; + FloatPoint topLeftPoint(d->mapFromTransformed(blockRect).location()); + if (renderer && renderer->isText()) { + ETextAlign textAlign = renderer->style()->textAlign(); + switch (textAlign) { + case CENTER: + case WEBKIT_CENTER: + anchor = FloatPoint(nodeRect.x() + (nodeRect.width() - scaledViewportWidth) / 2, topLeftPoint.y()); + break; + case LEFT: + case WEBKIT_LEFT: + anchor = topLeftPoint; + break; + case RIGHT: + case WEBKIT_RIGHT: + anchor = FloatPoint(nodeRect.x() + nodeRect.width() - scaledViewportWidth, topLeftPoint.y()); + break; + case TAAUTO: + case JUSTIFY: + default: + if (renderer->style()->isLeftToRightDirection()) + anchor = topLeftPoint; + else + anchor = FloatPoint(nodeRect.x() + nodeRect.width() - scaledViewportWidth, topLeftPoint.y()); + break; + } + } else + anchor = renderer->style()->isLeftToRightDirection() ? topLeftPoint : FloatPoint(nodeRect.x() + nodeRect.width() - scaledViewportWidth, topLeftPoint.y()); + + if (newBlockHeight <= scaledViewportHeight) { + d->m_finalBlockPoint = FloatPoint(anchor.x() - dx, anchor.y() - dy); + } else { + d->m_finalBlockPoint = FloatPoint(anchor.x() - dx, anchor.y() - 3); + } + +#if ENABLE(VIEWPORT_REFLOW) + if (settings()->textReflowMode() != WebSettings::TextReflowDisabled) { + d->m_finalBlockPoint = FloatPoint(anchor.x() - dx, anchor.y() - 3); + d->m_finalBlockPointReflowOffset = FloatPoint(-dx, -3); + } +#endif + + FloatRect br(anchor, FloatSize(scaledViewportWidth, scaledViewportHeight)); + if (!br.contains(IntPoint(documentTargetPoint))) { + d->m_finalBlockPointReflowOffset.move(0, (documentTargetPoint.y() - scaledViewportHeight / 2) - d->m_finalBlockPoint.y()); + d->m_finalBlockPoint = FloatPoint(d->m_finalBlockPoint.x(), documentTargetPoint.y() - scaledViewportHeight / 2); + } + + if (d->m_finalBlockPoint.x() < 0) { + d->m_finalBlockPoint.setX(0); + d->m_finalBlockPointReflowOffset.setX(0); + } else if (d->m_finalBlockPoint.x() + scaledViewportWidth > d->contentsSize().width()) { + d->m_finalBlockPoint.setX(d->contentsSize().width() - scaledViewportWidth); + d->m_finalBlockPointReflowOffset.setX(0); + } + + if (d->m_finalBlockPoint.y() < 0) { + d->m_finalBlockPoint.setY(0); + d->m_finalBlockPointReflowOffset.setY(0); + } else if (d->m_finalBlockPoint.y() + scaledViewportHeight > d->contentsSize().height()) { + d->m_finalBlockPoint.setY(d->contentsSize().height() - scaledViewportHeight); + d->m_finalBlockPointReflowOffset.setY(0); + } + + if (!endOfBlockZoomMode && abs(newScale - oldScale) / oldScale < minimumExpandingRatio) { + const double minimumDisplacement = minimumExpandingRatio * webkitThreadViewportAccessor()->documentViewportSize().width(); + if (oldScale == d->minimumScale() || (distanceBetweenPoints(d->scrollPosition(), roundUntransformedPoint(d->m_finalBlockPoint)) < minimumDisplacement && abs(newScale - oldScale) / oldScale < 0.10)) { + if (isFirstZoom) { + d->resetBlockZoom(); + return false; + } + blockZoom(documentTargetPoint); + return true; + } + } + + d->m_blockZoomFinalScale = newScale; + + d->m_userPerformedManualZoom = true; + d->m_userPerformedManualScroll = true; + d->m_client->animateBlockZoom(d->m_blockZoomFinalScale, d->m_finalBlockPoint); + + return true; +} +",0,"bool WebPage::blockZoom(const Platform::IntPoint& documentTargetPoint) +{ + if (!d->m_mainFrame->view() || !d->isUserScalable()) + return false; + + Node* node = d->bestNodeForZoomUnderPoint(documentTargetPoint); + if (!node) + return false; + + IntRect nodeRect = d->rectForNode(node); + IntRect blockRect; + bool endOfBlockZoomMode = d->compareNodesForBlockZoom(d->m_currentBlockZoomAdjustedNode.get(), node); + const double oldScale = d->m_transformationMatrix->m11(); + double newScale = 0; + const double margin = endOfBlockZoomMode ? 0 : blockZoomMargin * 2 * oldScale; + bool isFirstZoom = false; + + if (endOfBlockZoomMode) { + IntRect rect = d->blockZoomRectForNode(node); + blockRect = IntRect(0, rect.y(), d->transformedContentsSize().width(), d->transformedContentsSize().height() - rect.y()); + d->m_shouldReflowBlock = false; + } else { + Node* tempBlockZoomAdjustedNode = d->m_currentBlockZoomAdjustedNode.get(); + blockRect = d->blockZoomRectForNode(node); + + if (!node->hasTagName(HTMLNames::imgTag)) { + IntRect tRect = d->mapFromTransformed(blockRect); + int blockArea = tRect.width() * tRect.height(); + int pageArea = d->contentsSize().width() * d->contentsSize().height(); + double blockToPageRatio = static_cast(pageArea - blockArea) / pageArea; + if (blockToPageRatio < minimumExpandingRatio) { + d->m_currentBlockZoomAdjustedNode = tempBlockZoomAdjustedNode; + return false; + } + } + + if (blockRect.isEmpty() || !blockRect.width() || !blockRect.height()) + return false; + + if (!d->m_currentBlockZoomNode.get()) + isFirstZoom = true; + + d->m_currentBlockZoomNode = node; + d->m_shouldReflowBlock = true; + } + + newScale = std::min(d->newScaleForBlockZoomRect(blockRect, oldScale, margin), d->maxBlockZoomScale()); + newScale = std::max(newScale, minimumScale()); + +#if ENABLE(VIEWPORT_REFLOW) + if (d->m_currentBlockZoomNode && d->m_shouldReflowBlock && settings()->textReflowMode() != WebSettings::TextReflowDisabled) { + RenderObject* renderer = d->m_currentBlockZoomNode->renderer(); + if (renderer && renderer->isText()) { + double newFontSize = renderer->style()->fontSize() * newScale; + if (newFontSize < d->m_webSettings->defaultFontSize()) { + newScale = std::min(static_cast(d->m_webSettings->defaultFontSize()) / renderer->style()->fontSize(), d->maxBlockZoomScale()); + newScale = std::max(newScale, minimumScale()); + } + blockRect.setWidth(oldScale * static_cast(d->transformedActualVisibleSize().width()) / newScale); + newScale = std::min(d->newScaleForBlockZoomRect(blockRect, oldScale, margin), d->maxBlockZoomScale()); + newScale = std::max(newScale, minimumScale()); // Still, it's not allowed to be smaller than minimum scale. + } + } +#endif + + double newBlockHeight = d->mapFromTransformed(blockRect).height(); + double newBlockWidth = d->mapFromTransformed(blockRect).width(); + double scaledViewportWidth = static_cast(d->actualVisibleSize().width()) * oldScale / newScale; + double scaledViewportHeight = static_cast(d->actualVisibleSize().height()) * oldScale / newScale; + double dx = std::max(0.0, (scaledViewportWidth - newBlockWidth) / 2.0); + double dy = std::max(0.0, (scaledViewportHeight - newBlockHeight) / 2.0); + + RenderObject* renderer = d->m_currentBlockZoomAdjustedNode->renderer(); + FloatPoint anchor; + FloatPoint topLeftPoint(d->mapFromTransformed(blockRect).location()); + if (renderer && renderer->isText()) { + ETextAlign textAlign = renderer->style()->textAlign(); + switch (textAlign) { + case CENTER: + case WEBKIT_CENTER: + anchor = FloatPoint(nodeRect.x() + (nodeRect.width() - scaledViewportWidth) / 2, topLeftPoint.y()); + break; + case LEFT: + case WEBKIT_LEFT: + anchor = topLeftPoint; + break; + case RIGHT: + case WEBKIT_RIGHT: + anchor = FloatPoint(nodeRect.x() + nodeRect.width() - scaledViewportWidth, topLeftPoint.y()); + break; + case TAAUTO: + case JUSTIFY: + default: + if (renderer->style()->isLeftToRightDirection()) + anchor = topLeftPoint; + else + anchor = FloatPoint(nodeRect.x() + nodeRect.width() - scaledViewportWidth, topLeftPoint.y()); + break; + } + } else + anchor = renderer->style()->isLeftToRightDirection() ? topLeftPoint : FloatPoint(nodeRect.x() + nodeRect.width() - scaledViewportWidth, topLeftPoint.y()); + + if (newBlockHeight <= scaledViewportHeight) { + d->m_finalBlockPoint = FloatPoint(anchor.x() - dx, anchor.y() - dy); + } else { + d->m_finalBlockPoint = FloatPoint(anchor.x() - dx, anchor.y() - 3); + } + +#if ENABLE(VIEWPORT_REFLOW) + if (settings()->textReflowMode() != WebSettings::TextReflowDisabled) { + d->m_finalBlockPoint = FloatPoint(anchor.x() - dx, anchor.y() - 3); + d->m_finalBlockPointReflowOffset = FloatPoint(-dx, -3); + } +#endif + + FloatRect br(anchor, FloatSize(scaledViewportWidth, scaledViewportHeight)); + if (!br.contains(IntPoint(documentTargetPoint))) { + d->m_finalBlockPointReflowOffset.move(0, (documentTargetPoint.y() - scaledViewportHeight / 2) - d->m_finalBlockPoint.y()); + d->m_finalBlockPoint = FloatPoint(d->m_finalBlockPoint.x(), documentTargetPoint.y() - scaledViewportHeight / 2); + } + + if (d->m_finalBlockPoint.x() < 0) { + d->m_finalBlockPoint.setX(0); + d->m_finalBlockPointReflowOffset.setX(0); + } else if (d->m_finalBlockPoint.x() + scaledViewportWidth > d->contentsSize().width()) { + d->m_finalBlockPoint.setX(d->contentsSize().width() - scaledViewportWidth); + d->m_finalBlockPointReflowOffset.setX(0); + } + + if (d->m_finalBlockPoint.y() < 0) { + d->m_finalBlockPoint.setY(0); + d->m_finalBlockPointReflowOffset.setY(0); + } else if (d->m_finalBlockPoint.y() + scaledViewportHeight > d->contentsSize().height()) { + d->m_finalBlockPoint.setY(d->contentsSize().height() - scaledViewportHeight); + d->m_finalBlockPointReflowOffset.setY(0); + } + + if (!endOfBlockZoomMode && abs(newScale - oldScale) / oldScale < minimumExpandingRatio) { + const double minimumDisplacement = minimumExpandingRatio * webkitThreadViewportAccessor()->documentViewportSize().width(); + if (oldScale == d->minimumScale() || (distanceBetweenPoints(d->scrollPosition(), roundUntransformedPoint(d->m_finalBlockPoint)) < minimumDisplacement && abs(newScale - oldScale) / oldScale < 0.10)) { + if (isFirstZoom) { + d->resetBlockZoom(); + return false; + } + blockZoom(documentTargetPoint); + return true; + } + } + + d->m_blockZoomFinalScale = newScale; + + d->m_userPerformedManualZoom = true; + d->m_userPerformedManualScroll = true; + d->m_client->animateBlockZoom(d->m_blockZoomFinalScale, d->m_finalBlockPoint); + + return true; +} +","@@ -4058,11 +4058,6 @@ bool WebPage::touchEvent(const Platform::TouchEvent& event) + return d->dispatchTouchEventToFullScreenPlugin(pluginView, event); + + Platform::TouchEvent tEvent = event; +- for (unsigned i = 0; i < event.m_points.size(); i++) { +- tEvent.m_points[i].m_pos = d->mapFromTransformed(tEvent.m_points[i].m_pos); +- tEvent.m_points[i].m_screenPos = tEvent.m_points[i].m_screenPos; +- } +- + if (event.isSingleTap()) + d->m_pluginMayOpenNewTab = true; + else if (tEvent.m_type == Platform::TouchEvent::TouchStart || tEvent.m_type == Platform::TouchEvent::TouchCancel) +@@ -4132,10 +4127,7 @@ void WebPage::touchPointAsMouseEvent(const Platform::TouchPoint& point, unsigned + + d->m_lastUserEventTimestamp = currentTime(); + +- Platform::TouchPoint tPoint = point; +- tPoint.m_pos = d->mapFromTransformed(tPoint.m_pos); +- +- d->m_touchEventHandler->handleTouchPoint(tPoint, modifiers); ++ d->m_touchEventHandler->handleTouchPoint(point, modifiers); + } + + void WebPage::playSoundIfAnchorIsTarget() const +@@ -4165,13 +4157,13 @@ bool WebPagePrivate::dispatchTouchEventToFullScreenPlugin(PluginView* plugin, co + if (npTouchEvent.size) { + npTouchEvent.points = new NPTouchPoint[npTouchEvent.size]; + for (int i = 0; i < npTouchEvent.size; i++) { +- npTouchEvent.points[i].touchId = event.m_points[i].m_id; +- npTouchEvent.points[i].clientX = event.m_points[i].m_screenPos.x(); +- npTouchEvent.points[i].clientY = event.m_points[i].m_screenPos.y(); +- npTouchEvent.points[i].screenX = event.m_points[i].m_screenPos.x(); +- npTouchEvent.points[i].screenY = event.m_points[i].m_screenPos.y(); +- npTouchEvent.points[i].pageX = event.m_points[i].m_pos.x(); +- npTouchEvent.points[i].pageY = event.m_points[i].m_pos.y(); ++ npTouchEvent.points[i].touchId = event.m_points[i].id(); ++ npTouchEvent.points[i].clientX = event.m_points[i].screenPosition().x(); ++ npTouchEvent.points[i].clientY = event.m_points[i].screenPosition().y(); ++ npTouchEvent.points[i].screenX = event.m_points[i].screenPosition().x(); ++ npTouchEvent.points[i].screenY = event.m_points[i].screenPosition().y(); ++ npTouchEvent.points[i].pageX = event.m_points[i].pixelViewportPosition().x(); ++ npTouchEvent.points[i].pageY = event.m_points[i].pixelViewportPosition().y(); + } + } + +@@ -4193,7 +4185,7 @@ bool WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin(PluginView + NPEvent npEvent; + NPMouseEvent mouse; + +- switch (point.m_state) { ++ switch (point.state()) { + case Platform::TouchPoint::TouchPressed: + mouse.type = MOUSE_BUTTON_DOWN; + break; +@@ -4207,8 +4199,8 @@ bool WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin(PluginView + return true; + } + +- mouse.x = point.m_screenPos.x(); +- mouse.y = point.m_screenPos.y(); ++ mouse.x = point.screenPosition().x(); ++ mouse.y = point.screenPosition().y(); + mouse.button = mouse.type != MOUSE_BUTTON_UP; + mouse.flags = 0; + npEvent.type = NP_MouseEvent;",1798,2034,2048 +4475,"struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4) +{ + struct net_device *dev_out = NULL; + __u8 tos = RT_FL_TOS(fl4); + unsigned int flags = 0; + struct fib_result res; + struct rtable *rth; + int orig_oif; + + res.tclassid = 0; + res.fi = NULL; + res.table = NULL; + + orig_oif = fl4->flowi4_oif; + + fl4->flowi4_iif = LOOPBACK_IFINDEX; + fl4->flowi4_tos = tos & IPTOS_RT_MASK; + fl4->flowi4_scope = ((tos & RTO_ONLINK) ? + RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); + + rcu_read_lock(); + if (fl4->saddr) { + rth = ERR_PTR(-EINVAL); + if (ipv4_is_multicast(fl4->saddr) || + ipv4_is_lbcast(fl4->saddr) || + ipv4_is_zeronet(fl4->saddr)) + goto out; + + /* I removed check for oif == dev_out->oif here. + It was wrong for two reasons: + 1. ip_dev_find(net, saddr) can return wrong iface, if saddr + is assigned to multiple interfaces. + 2. Moreover, we are allowed to send packets with saddr + of another iface. --ANK + */ + + if (fl4->flowi4_oif == 0 && + (ipv4_is_multicast(fl4->daddr) || + ipv4_is_lbcast(fl4->daddr))) { + /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ + dev_out = __ip_dev_find(net, fl4->saddr, false); + if (dev_out == NULL) + goto out; + + /* Special hack: user can direct multicasts + and limited broadcast via necessary interface + without fiddling with IP_MULTICAST_IF or IP_PKTINFO. + This hack is not just for fun, it allows + vic,vat and friends to work. + They bind socket to loopback, set ttl to zero + and expect that it will work. + From the viewpoint of routing cache they are broken, + because we are not allowed to build multicast path + with loopback source addr (look, routing cache + cannot know, that ttl is zero, so that packet + will not leave this host and route is valid). + Luckily, this hack is good workaround. + */ + + fl4->flowi4_oif = dev_out->ifindex; + goto make_route; + } + + if (!(fl4->flowi4_flags & FLOWI_FLAG_ANYSRC)) { + /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ + if (!__ip_dev_find(net, fl4->saddr, false)) + goto out; + } + } + + + if (fl4->flowi4_oif) { + dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif); + rth = ERR_PTR(-ENODEV); + if (dev_out == NULL) + goto out; + + /* RACE: Check return value of inet_select_addr instead. */ + if (!(dev_out->flags & IFF_UP) || !__in_dev_get_rcu(dev_out)) { + rth = ERR_PTR(-ENETUNREACH); + goto out; + } + if (ipv4_is_local_multicast(fl4->daddr) || + ipv4_is_lbcast(fl4->daddr)) { + if (!fl4->saddr) + fl4->saddr = inet_select_addr(dev_out, 0, + RT_SCOPE_LINK); + goto make_route; + } + if (!fl4->saddr) { + if (ipv4_is_multicast(fl4->daddr)) + fl4->saddr = inet_select_addr(dev_out, 0, + fl4->flowi4_scope); + else if (!fl4->daddr) + fl4->saddr = inet_select_addr(dev_out, 0, + RT_SCOPE_HOST); + } + } + + if (!fl4->daddr) { + fl4->daddr = fl4->saddr; + if (!fl4->daddr) + fl4->daddr = fl4->saddr = htonl(INADDR_LOOPBACK); + dev_out = net->loopback_dev; + fl4->flowi4_oif = LOOPBACK_IFINDEX; + res.type = RTN_LOCAL; + flags |= RTCF_LOCAL; + goto make_route; + } + + if (fib_lookup(net, fl4, &res)) { + res.fi = NULL; + res.table = NULL; + if (fl4->flowi4_oif) { + /* Apparently, routing tables are wrong. Assume, + that the destination is on link. + + WHY? DW. + Because we are allowed to send to iface + even if it has NO routes and NO assigned + addresses. When oif is specified, routing + tables are looked up with only one purpose: + to catch if destination is gatewayed, rather than + direct. Moreover, if MSG_DONTROUTE is set, + we send packet, ignoring both routing tables + and ifaddr state. --ANK + + + We could make it even if oif is unknown, + likely IPv6, but we do not. + */ + + if (fl4->saddr == 0) + fl4->saddr = inet_select_addr(dev_out, 0, + RT_SCOPE_LINK); + res.type = RTN_UNICAST; + goto make_route; + } + rth = ERR_PTR(-ENETUNREACH); + goto out; + } + + if (res.type == RTN_LOCAL) { + if (!fl4->saddr) { + if (res.fi->fib_prefsrc) + fl4->saddr = res.fi->fib_prefsrc; + else + fl4->saddr = fl4->daddr; + } + dev_out = net->loopback_dev; + fl4->flowi4_oif = dev_out->ifindex; + flags |= RTCF_LOCAL; + goto make_route; + } + +#ifdef CONFIG_IP_ROUTE_MULTIPATH + if (res.fi->fib_nhs > 1 && fl4->flowi4_oif == 0) + fib_select_multipath(&res); + else +#endif + if (!res.prefixlen && + res.table->tb_num_default > 1 && + res.type == RTN_UNICAST && !fl4->flowi4_oif) + fib_select_default(&res); + + if (!fl4->saddr) + fl4->saddr = FIB_RES_PREFSRC(net, res); + + dev_out = FIB_RES_DEV(res); + fl4->flowi4_oif = dev_out->ifindex; + + +make_route: + rth = __mkroute_output(&res, fl4, orig_oif, dev_out, flags); + +out: + rcu_read_unlock(); + return rth; +} +",0,"struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4) +{ + struct net_device *dev_out = NULL; + __u8 tos = RT_FL_TOS(fl4); + unsigned int flags = 0; + struct fib_result res; + struct rtable *rth; + int orig_oif; + + res.tclassid = 0; + res.fi = NULL; + res.table = NULL; + + orig_oif = fl4->flowi4_oif; + + fl4->flowi4_iif = LOOPBACK_IFINDEX; + fl4->flowi4_tos = tos & IPTOS_RT_MASK; + fl4->flowi4_scope = ((tos & RTO_ONLINK) ? + RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); + + rcu_read_lock(); + if (fl4->saddr) { + rth = ERR_PTR(-EINVAL); + if (ipv4_is_multicast(fl4->saddr) || + ipv4_is_lbcast(fl4->saddr) || + ipv4_is_zeronet(fl4->saddr)) + goto out; + + /* I removed check for oif == dev_out->oif here. + It was wrong for two reasons: + 1. ip_dev_find(net, saddr) can return wrong iface, if saddr + is assigned to multiple interfaces. + 2. Moreover, we are allowed to send packets with saddr + of another iface. --ANK + */ + + if (fl4->flowi4_oif == 0 && + (ipv4_is_multicast(fl4->daddr) || + ipv4_is_lbcast(fl4->daddr))) { + /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ + dev_out = __ip_dev_find(net, fl4->saddr, false); + if (dev_out == NULL) + goto out; + + /* Special hack: user can direct multicasts + and limited broadcast via necessary interface + without fiddling with IP_MULTICAST_IF or IP_PKTINFO. + This hack is not just for fun, it allows + vic,vat and friends to work. + They bind socket to loopback, set ttl to zero + and expect that it will work. + From the viewpoint of routing cache they are broken, + because we are not allowed to build multicast path + with loopback source addr (look, routing cache + cannot know, that ttl is zero, so that packet + will not leave this host and route is valid). + Luckily, this hack is good workaround. + */ + + fl4->flowi4_oif = dev_out->ifindex; + goto make_route; + } + + if (!(fl4->flowi4_flags & FLOWI_FLAG_ANYSRC)) { + /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ + if (!__ip_dev_find(net, fl4->saddr, false)) + goto out; + } + } + + + if (fl4->flowi4_oif) { + dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif); + rth = ERR_PTR(-ENODEV); + if (dev_out == NULL) + goto out; + + /* RACE: Check return value of inet_select_addr instead. */ + if (!(dev_out->flags & IFF_UP) || !__in_dev_get_rcu(dev_out)) { + rth = ERR_PTR(-ENETUNREACH); + goto out; + } + if (ipv4_is_local_multicast(fl4->daddr) || + ipv4_is_lbcast(fl4->daddr)) { + if (!fl4->saddr) + fl4->saddr = inet_select_addr(dev_out, 0, + RT_SCOPE_LINK); + goto make_route; + } + if (!fl4->saddr) { + if (ipv4_is_multicast(fl4->daddr)) + fl4->saddr = inet_select_addr(dev_out, 0, + fl4->flowi4_scope); + else if (!fl4->daddr) + fl4->saddr = inet_select_addr(dev_out, 0, + RT_SCOPE_HOST); + } + } + + if (!fl4->daddr) { + fl4->daddr = fl4->saddr; + if (!fl4->daddr) + fl4->daddr = fl4->saddr = htonl(INADDR_LOOPBACK); + dev_out = net->loopback_dev; + fl4->flowi4_oif = LOOPBACK_IFINDEX; + res.type = RTN_LOCAL; + flags |= RTCF_LOCAL; + goto make_route; + } + + if (fib_lookup(net, fl4, &res)) { + res.fi = NULL; + res.table = NULL; + if (fl4->flowi4_oif) { + /* Apparently, routing tables are wrong. Assume, + that the destination is on link. + + WHY? DW. + Because we are allowed to send to iface + even if it has NO routes and NO assigned + addresses. When oif is specified, routing + tables are looked up with only one purpose: + to catch if destination is gatewayed, rather than + direct. Moreover, if MSG_DONTROUTE is set, + we send packet, ignoring both routing tables + and ifaddr state. --ANK + + + We could make it even if oif is unknown, + likely IPv6, but we do not. + */ + + if (fl4->saddr == 0) + fl4->saddr = inet_select_addr(dev_out, 0, + RT_SCOPE_LINK); + res.type = RTN_UNICAST; + goto make_route; + } + rth = ERR_PTR(-ENETUNREACH); + goto out; + } + + if (res.type == RTN_LOCAL) { + if (!fl4->saddr) { + if (res.fi->fib_prefsrc) + fl4->saddr = res.fi->fib_prefsrc; + else + fl4->saddr = fl4->daddr; + } + dev_out = net->loopback_dev; + fl4->flowi4_oif = dev_out->ifindex; + flags |= RTCF_LOCAL; + goto make_route; + } + +#ifdef CONFIG_IP_ROUTE_MULTIPATH + if (res.fi->fib_nhs > 1 && fl4->flowi4_oif == 0) + fib_select_multipath(&res); + else +#endif + if (!res.prefixlen && + res.table->tb_num_default > 1 && + res.type == RTN_UNICAST && !fl4->flowi4_oif) + fib_select_default(&res); + + if (!fl4->saddr) + fl4->saddr = FIB_RES_PREFSRC(net, res); + + dev_out = FIB_RES_DEV(res); + fl4->flowi4_oif = dev_out->ifindex; + + +make_route: + rth = __mkroute_output(&res, fl4, orig_oif, dev_out, flags); + +out: + rcu_read_unlock(); + return rth; +} +","@@ -1554,11 +1554,10 @@ static int __mkroute_input(struct sk_buff *skb, + + do_cache = res->fi && !itag; + if (out_dev == in_dev && err && IN_DEV_TX_REDIRECTS(out_dev) && ++ skb->protocol == htons(ETH_P_IP) && + (IN_DEV_SHARED_MEDIA(out_dev) || +- inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) { +- flags |= RTCF_DOREDIRECT; +- do_cache = false; +- } ++ inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) ++ IPCB(skb)->flags |= IPSKB_DOREDIRECT; + + if (skb->protocol != htons(ETH_P_IP)) { + /* Not IP (i.e. ARP). Do not create route, if it is +@@ -2303,6 +2302,8 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src, + r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; + if (rt->rt_flags & RTCF_NOTIFY) + r->rtm_flags |= RTM_F_NOTIFY; ++ if (IPCB(skb)->flags & IPSKB_DOREDIRECT) ++ r->rtm_flags |= RTCF_DOREDIRECT; + + if (nla_put_be32(skb, RTA_DST, dst)) + goto nla_put_failure;",1538,1774,2048 +7474,"static int server_socket(const char *interface, + int port, + enum network_transport transport, + FILE *portnumber_file) { + int sfd; + struct linger ling = {0, 0}; + struct addrinfo *ai; + struct addrinfo *next; + struct addrinfo hints = { .ai_flags = AI_PASSIVE, + .ai_family = AF_UNSPEC }; + char port_buf[NI_MAXSERV]; + int error; + int success = 0; + int flags =1; + + hints.ai_socktype = IS_UDP(transport) ? SOCK_DGRAM : SOCK_STREAM; + + if (port == -1) { + port = 0; + } + snprintf(port_buf, sizeof(port_buf), ""%d"", port); + error= getaddrinfo(interface, port_buf, &hints, &ai); + if (error != 0) { + if (error != EAI_SYSTEM) + fprintf(stderr, ""getaddrinfo(): %s\n"", gai_strerror(error)); + else + perror(""getaddrinfo()""); + return 1; + } + + for (next= ai; next; next= next->ai_next) { + conn *listen_conn_add; + if ((sfd = new_socket(next)) == -1) { + /* getaddrinfo can return ""junk"" addresses, + * we make sure at least one works before erroring. + */ + if (errno == EMFILE) { + /* ...unless we're out of fds */ + perror(""server_socket""); + exit(EX_OSERR); + } + continue; + } + +#ifdef IPV6_V6ONLY + if (next->ai_family == AF_INET6) { + error = setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags)); + if (error != 0) { + perror(""setsockopt""); + close(sfd); + continue; + } + } +#endif + + setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)); + if (IS_UDP(transport)) { + maximize_sndbuf(sfd); + } else { + error = setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)); + if (error != 0) + perror(""setsockopt""); + + error = setsockopt(sfd, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)); + if (error != 0) + perror(""setsockopt""); + + error = setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)); + if (error != 0) + perror(""setsockopt""); + } + + if (bind(sfd, next->ai_addr, next->ai_addrlen) == -1) { + if (errno != EADDRINUSE) { + perror(""bind()""); + close(sfd); + freeaddrinfo(ai); + return 1; + } + close(sfd); + continue; + } else { + success++; + if (!IS_UDP(transport) && listen(sfd, settings.backlog) == -1) { + perror(""listen()""); + close(sfd); + freeaddrinfo(ai); + return 1; + } + if (portnumber_file != NULL && + (next->ai_addr->sa_family == AF_INET || + next->ai_addr->sa_family == AF_INET6)) { + union { + struct sockaddr_in in; + struct sockaddr_in6 in6; + } my_sockaddr; + socklen_t len = sizeof(my_sockaddr); + if (getsockname(sfd, (struct sockaddr*)&my_sockaddr, &len)==0) { + if (next->ai_addr->sa_family == AF_INET) { + fprintf(portnumber_file, ""%s INET: %u\n"", + IS_UDP(transport) ? ""UDP"" : ""TCP"", + ntohs(my_sockaddr.in.sin_port)); + } else { + fprintf(portnumber_file, ""%s INET6: %u\n"", + IS_UDP(transport) ? ""UDP"" : ""TCP"", + ntohs(my_sockaddr.in6.sin6_port)); + } + } + } + } + + if (IS_UDP(transport)) { + int c; + + for (c = 0; c < settings.num_threads_per_udp; c++) { + /* Allocate one UDP file descriptor per worker thread; + * this allows ""stats conns"" to separately list multiple + * parallel UDP requests in progress. + * + * The dispatch code round-robins new connection requests + * among threads, so this is guaranteed to assign one + * FD to each thread. + */ + int per_thread_fd = c ? dup(sfd) : sfd; + dispatch_conn_new(per_thread_fd, conn_read, + EV_READ | EV_PERSIST, + UDP_READ_BUFFER_SIZE, transport); + } + } else { + if (!(listen_conn_add = conn_new(sfd, conn_listening, + EV_READ | EV_PERSIST, 1, + transport, main_base))) { + fprintf(stderr, ""failed to create listening connection\n""); + exit(EXIT_FAILURE); + } + listen_conn_add->next = listen_conn; + listen_conn = listen_conn_add; + } + } + + freeaddrinfo(ai); + + /* Return zero iff we detected no errors in starting up connections */ + return success == 0; +} +",0,"static int server_socket(const char *interface, + int port, + enum network_transport transport, + FILE *portnumber_file) { + int sfd; + struct linger ling = {0, 0}; + struct addrinfo *ai; + struct addrinfo *next; + struct addrinfo hints = { .ai_flags = AI_PASSIVE, + .ai_family = AF_UNSPEC }; + char port_buf[NI_MAXSERV]; + int error; + int success = 0; + int flags =1; + + hints.ai_socktype = IS_UDP(transport) ? SOCK_DGRAM : SOCK_STREAM; + + if (port == -1) { + port = 0; + } + snprintf(port_buf, sizeof(port_buf), ""%d"", port); + error= getaddrinfo(interface, port_buf, &hints, &ai); + if (error != 0) { + if (error != EAI_SYSTEM) + fprintf(stderr, ""getaddrinfo(): %s\n"", gai_strerror(error)); + else + perror(""getaddrinfo()""); + return 1; + } + + for (next= ai; next; next= next->ai_next) { + conn *listen_conn_add; + if ((sfd = new_socket(next)) == -1) { + /* getaddrinfo can return ""junk"" addresses, + * we make sure at least one works before erroring. + */ + if (errno == EMFILE) { + /* ...unless we're out of fds */ + perror(""server_socket""); + exit(EX_OSERR); + } + continue; + } + +#ifdef IPV6_V6ONLY + if (next->ai_family == AF_INET6) { + error = setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags)); + if (error != 0) { + perror(""setsockopt""); + close(sfd); + continue; + } + } +#endif + + setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)); + if (IS_UDP(transport)) { + maximize_sndbuf(sfd); + } else { + error = setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)); + if (error != 0) + perror(""setsockopt""); + + error = setsockopt(sfd, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)); + if (error != 0) + perror(""setsockopt""); + + error = setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)); + if (error != 0) + perror(""setsockopt""); + } + + if (bind(sfd, next->ai_addr, next->ai_addrlen) == -1) { + if (errno != EADDRINUSE) { + perror(""bind()""); + close(sfd); + freeaddrinfo(ai); + return 1; + } + close(sfd); + continue; + } else { + success++; + if (!IS_UDP(transport) && listen(sfd, settings.backlog) == -1) { + perror(""listen()""); + close(sfd); + freeaddrinfo(ai); + return 1; + } + if (portnumber_file != NULL && + (next->ai_addr->sa_family == AF_INET || + next->ai_addr->sa_family == AF_INET6)) { + union { + struct sockaddr_in in; + struct sockaddr_in6 in6; + } my_sockaddr; + socklen_t len = sizeof(my_sockaddr); + if (getsockname(sfd, (struct sockaddr*)&my_sockaddr, &len)==0) { + if (next->ai_addr->sa_family == AF_INET) { + fprintf(portnumber_file, ""%s INET: %u\n"", + IS_UDP(transport) ? ""UDP"" : ""TCP"", + ntohs(my_sockaddr.in.sin_port)); + } else { + fprintf(portnumber_file, ""%s INET6: %u\n"", + IS_UDP(transport) ? ""UDP"" : ""TCP"", + ntohs(my_sockaddr.in6.sin6_port)); + } + } + } + } + + if (IS_UDP(transport)) { + int c; + + for (c = 0; c < settings.num_threads_per_udp; c++) { + /* Allocate one UDP file descriptor per worker thread; + * this allows ""stats conns"" to separately list multiple + * parallel UDP requests in progress. + * + * The dispatch code round-robins new connection requests + * among threads, so this is guaranteed to assign one + * FD to each thread. + */ + int per_thread_fd = c ? dup(sfd) : sfd; + dispatch_conn_new(per_thread_fd, conn_read, + EV_READ | EV_PERSIST, + UDP_READ_BUFFER_SIZE, transport); + } + } else { + if (!(listen_conn_add = conn_new(sfd, conn_listening, + EV_READ | EV_PERSIST, 1, + transport, main_base))) { + fprintf(stderr, ""failed to create listening connection\n""); + exit(EXIT_FAILURE); + } + listen_conn_add->next = listen_conn; + listen_conn = listen_conn_add; + } + } + + freeaddrinfo(ai); + + /* Return zero iff we detected no errors in starting up connections */ + return success == 0; +} +","@@ -3249,6 +3249,16 @@ static inline int make_ascii_get_suffix(char *suffix, item *it, bool return_cas) + return (p - suffix) + 2; + } + ++#define IT_REFCOUNT_LIMIT 60000 ++static inline item* limited_get(char *key, size_t nkey, conn *c) { ++ item *it = item_get(key, nkey, c, DO_UPDATE); ++ if (it && it->refcount > IT_REFCOUNT_LIMIT) { ++ item_remove(it); ++ it = NULL; ++ } ++ return it; ++} ++ + /* ntokens is overwritten here... shrug.. */ + static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, bool return_cas) { + char *key; +@@ -3273,7 +3283,7 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, + return; + } + +- it = item_get(key, nkey, c, DO_UPDATE); ++ it = limited_get(key, nkey, c); + if (settings.detail_enabled) { + stats_prefix_record_get(key, nkey, NULL != it); + }",1134,1370,2048 +17798,"SplashPath *Splash::makeDashedPath(SplashPath *path) { + SplashPath *dPath; + SplashCoord lineDashTotal; + SplashCoord lineDashStartPhase, lineDashDist, segLen; + SplashCoord x0, y0, x1, y1, xa, ya; + GBool lineDashStartOn, lineDashOn, newPath; + int lineDashStartIdx, lineDashIdx; + int i, j, k; + + lineDashTotal = 0; + for (i = 0; i < state->lineDashLength; ++i) { + lineDashTotal += state->lineDash[i]; + } + if (lineDashTotal == 0) { + return new SplashPath(); + } + lineDashStartPhase = state->lineDashPhase; + i = splashFloor(lineDashStartPhase / lineDashTotal); + lineDashStartPhase -= (SplashCoord)i * lineDashTotal; + lineDashStartOn = gTrue; + lineDashStartIdx = 0; + if (lineDashStartPhase > 0) { + while (lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { + lineDashStartOn = !lineDashStartOn; + lineDashStartPhase -= state->lineDash[lineDashStartIdx]; + ++lineDashStartIdx; + } + } + + dPath = new SplashPath(); + while (i < path->length) { + + for (j = i; + j < path->length - 1 && !(path->flags[j] & splashPathLast); + ++j) ; + + lineDashOn = lineDashStartOn; + lineDashIdx = lineDashStartIdx; + lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase; + + newPath = gTrue; + for (k = i; k < j; ++k) { + + x0 = path->pts[k].x; + y0 = path->pts[k].y; + x1 = path->pts[k+1].x; + y1 = path->pts[k+1].y; + segLen = splashDist(x0, y0, x1, y1); + + while (segLen > 0) { + + if (lineDashDist >= segLen) { + if (lineDashOn) { + if (newPath) { + dPath->moveTo(x0, y0); + newPath = gFalse; + } + dPath->lineTo(x1, y1); + } + lineDashDist -= segLen; + segLen = 0; + + } else { + xa = x0 + (lineDashDist / segLen) * (x1 - x0); + ya = y0 + (lineDashDist / segLen) * (y1 - y0); + if (lineDashOn) { + if (newPath) { + dPath->moveTo(x0, y0); + newPath = gFalse; + } + dPath->lineTo(xa, ya); + } + x0 = xa; + y0 = ya; + segLen -= lineDashDist; + lineDashDist = 0; + } + + if (lineDashDist <= 0) { + lineDashOn = !lineDashOn; + if (++lineDashIdx == state->lineDashLength) { + lineDashIdx = 0; + } + lineDashDist = state->lineDash[lineDashIdx]; + newPath = gTrue; + } + } + } + i = j + 1; + } + + if (dPath->length == 0) { + GBool allSame = gTrue; + for (int i = 0; allSame && i < path->length - 1; ++i) { + allSame = path->pts[i].x == path->pts[i + 1].x && path->pts[i].y == path->pts[i + 1].y; + } + if (allSame) { + x0 = path->pts[0].x; + y0 = path->pts[0].y; + dPath->moveTo(x0, y0); + dPath->lineTo(x0, y0); + } + } + + return dPath; +} +",1,"SplashPath *Splash::makeDashedPath(SplashPath *path) { + SplashPath *dPath; + SplashCoord lineDashTotal; + SplashCoord lineDashStartPhase, lineDashDist, segLen; + SplashCoord x0, y0, x1, y1, xa, ya; + GBool lineDashStartOn, lineDashOn, newPath; + int lineDashStartIdx, lineDashIdx; + int i, j, k; + + lineDashTotal = 0; + for (i = 0; i < state->lineDashLength; ++i) { + lineDashTotal += state->lineDash[i]; + } + if (lineDashTotal == 0) { + return new SplashPath(); + } + lineDashStartPhase = state->lineDashPhase; + i = splashFloor(lineDashStartPhase / lineDashTotal); + lineDashStartPhase -= (SplashCoord)i * lineDashTotal; + lineDashStartOn = gTrue; + lineDashStartIdx = 0; + if (lineDashStartPhase > 0) { + while (lineDashStartIdx < state->lineDashLength && lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { + lineDashStartOn = !lineDashStartOn; + lineDashStartPhase -= state->lineDash[lineDashStartIdx]; + ++lineDashStartIdx; + } + if (unlikely(lineDashStartIdx == state->lineDashLength)) { + return new SplashPath(); + } + } + + dPath = new SplashPath(); + while (i < path->length) { + + for (j = i; + j < path->length - 1 && !(path->flags[j] & splashPathLast); + ++j) ; + + lineDashOn = lineDashStartOn; + lineDashIdx = lineDashStartIdx; + lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase; + + newPath = gTrue; + for (k = i; k < j; ++k) { + + x0 = path->pts[k].x; + y0 = path->pts[k].y; + x1 = path->pts[k+1].x; + y1 = path->pts[k+1].y; + segLen = splashDist(x0, y0, x1, y1); + + while (segLen > 0) { + + if (lineDashDist >= segLen) { + if (lineDashOn) { + if (newPath) { + dPath->moveTo(x0, y0); + newPath = gFalse; + } + dPath->lineTo(x1, y1); + } + lineDashDist -= segLen; + segLen = 0; + + } else { + xa = x0 + (lineDashDist / segLen) * (x1 - x0); + ya = y0 + (lineDashDist / segLen) * (y1 - y0); + if (lineDashOn) { + if (newPath) { + dPath->moveTo(x0, y0); + newPath = gFalse; + } + dPath->lineTo(xa, ya); + } + x0 = xa; + y0 = ya; + segLen -= lineDashDist; + lineDashDist = 0; + } + + if (lineDashDist <= 0) { + lineDashOn = !lineDashOn; + if (++lineDashIdx == state->lineDashLength) { + lineDashIdx = 0; + } + lineDashDist = state->lineDash[lineDashIdx]; + newPath = gTrue; + } + } + } + i = j + 1; + } + + if (dPath->length == 0) { + GBool allSame = gTrue; + for (int i = 0; allSame && i < path->length - 1; ++i) { + allSame = path->pts[i].x == path->pts[i + 1].x && path->pts[i].y == path->pts[i + 1].y; + } + if (allSame) { + x0 = path->pts[0].x; + y0 = path->pts[0].y; + dPath->moveTo(x0, y0); + dPath->lineTo(x0, y0); + } + } + + return dPath; +} +","@@ -2252,11 +2252,14 @@ SplashPath *Splash::makeDashedPath(SplashPath *path) { + lineDashStartOn = gTrue; + lineDashStartIdx = 0; + if (lineDashStartPhase > 0) { +- while (lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { ++ while (lineDashStartIdx < state->lineDashLength && lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { + lineDashStartOn = !lineDashStartOn; + lineDashStartPhase -= state->lineDash[lineDashStartIdx]; + ++lineDashStartIdx; + } ++ if (unlikely(lineDashStartIdx == state->lineDashLength)) { ++ return new SplashPath(); ++ } + } + + dPath = new SplashPath();",903,1139,2048 +9183,"GF_Err video_sample_entry_Size(GF_Box *s) +{ + GF_Err e; + GF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s; + + gf_isom_video_sample_entry_size((GF_VisualSampleEntryBox *)s); + + if (ptr->esd) { + e = gf_isom_box_size((GF_Box *)ptr->esd); + if (e) return e; + ptr->size += ptr->esd->size; + } else if (ptr->cfg_3gpp) { + e = gf_isom_box_size((GF_Box *)ptr->cfg_3gpp); + if (e) return e; + ptr->size += ptr->cfg_3gpp->size; + } else { + switch (ptr->type) { + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_SVC2: + case GF_ISOM_BOX_TYPE_MVC1: + case GF_ISOM_BOX_TYPE_MVC2: + if (!ptr->avc_config && !ptr->svc_config && !ptr->mvc_config) + return GF_ISOM_INVALID_FILE; + break; + case GF_ISOM_BOX_TYPE_VP08: + case GF_ISOM_BOX_TYPE_VP09: + if (!ptr->vp_config) { + return GF_ISOM_INVALID_FILE; + } + break; + case GF_ISOM_BOX_TYPE_AV01: + if (!ptr->av1_config) { + return GF_ISOM_INVALID_FILE; + } + break; + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC2: + case GF_ISOM_BOX_TYPE_HEV2: + case GF_ISOM_BOX_TYPE_LHV1: + case GF_ISOM_BOX_TYPE_LHE1: + if (!ptr->hevc_config && !ptr->lhvc_config) { + return GF_ISOM_INVALID_FILE; + } + break; + default: + break; + } + + if (ptr->hevc_config && ptr->hevc_config->config) { + e = gf_isom_box_size((GF_Box *)ptr->hevc_config); + if (e) return e; + ptr->size += ptr->hevc_config->size; + } + + if (ptr->avc_config && ptr->avc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->avc_config); + if (e) return e; + ptr->size += ptr->avc_config->size; + } + + if (ptr->svc_config && ptr->svc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->svc_config); + if (e) return e; + ptr->size += ptr->svc_config->size; + } + + if (ptr->mvc_config && ptr->mvc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->mvc_config); + if (e) return e; + ptr->size += ptr->mvc_config->size; + } + + if (ptr->lhvc_config && ptr->lhvc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->lhvc_config); + if (e) return e; + ptr->size += ptr->lhvc_config->size; + } + + if (ptr->av1_config && ptr->av1_config->config) { + e = gf_isom_box_size((GF_Box *)ptr->av1_config); + if (e) return e; + ptr->size += ptr->av1_config->size; + } + + if (ptr->vp_config && ptr->vp_config->config) { + e = gf_isom_box_size((GF_Box *)ptr->vp_config); + if (e) return e; + ptr->size += ptr->vp_config->size; + } + + if (ptr->ipod_ext) { + e = gf_isom_box_size((GF_Box *) ptr->ipod_ext); + if (e) return e; + ptr->size += ptr->ipod_ext->size; + } + if (ptr->descr) { + e = gf_isom_box_size((GF_Box *) ptr->descr); + if (e) return e; + ptr->size += ptr->descr->size; + } + } + if (ptr->pasp) { + e = gf_isom_box_size((GF_Box *)ptr->pasp); + if (e) return e; + ptr->size += ptr->pasp->size; + } + if (ptr->clap) { + e = gf_isom_box_size((GF_Box *)ptr->clap); + if (e) return e; + ptr->size += ptr->clap->size; + } + if (ptr->ccst) { + e = gf_isom_box_size((GF_Box *)ptr->ccst); + if (e) return e; + ptr->size += ptr->ccst->size; + } + if (ptr->auxi) { + e = gf_isom_box_size((GF_Box *)ptr->auxi); + if (e) return e; + ptr->size += ptr->auxi->size; + } + if (ptr->rvcc) { + e = gf_isom_box_size((GF_Box *)ptr->rvcc); + if (e) return e; + ptr->size += ptr->rvcc->size; + } + if (ptr->rinf) { + e = gf_isom_box_size((GF_Box *)ptr->rinf); + if (e) return e; + ptr->size += ptr->rinf->size; + } + return gf_isom_box_array_size(s, ptr->protections); +} +",0,"GF_Err video_sample_entry_Size(GF_Box *s) +{ + GF_Err e; + GF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s; + + gf_isom_video_sample_entry_size((GF_VisualSampleEntryBox *)s); + + if (ptr->esd) { + e = gf_isom_box_size((GF_Box *)ptr->esd); + if (e) return e; + ptr->size += ptr->esd->size; + } else if (ptr->cfg_3gpp) { + e = gf_isom_box_size((GF_Box *)ptr->cfg_3gpp); + if (e) return e; + ptr->size += ptr->cfg_3gpp->size; + } else { + switch (ptr->type) { + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_SVC2: + case GF_ISOM_BOX_TYPE_MVC1: + case GF_ISOM_BOX_TYPE_MVC2: + if (!ptr->avc_config && !ptr->svc_config && !ptr->mvc_config) + return GF_ISOM_INVALID_FILE; + break; + case GF_ISOM_BOX_TYPE_VP08: + case GF_ISOM_BOX_TYPE_VP09: + if (!ptr->vp_config) { + return GF_ISOM_INVALID_FILE; + } + break; + case GF_ISOM_BOX_TYPE_AV01: + if (!ptr->av1_config) { + return GF_ISOM_INVALID_FILE; + } + break; + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC2: + case GF_ISOM_BOX_TYPE_HEV2: + case GF_ISOM_BOX_TYPE_LHV1: + case GF_ISOM_BOX_TYPE_LHE1: + if (!ptr->hevc_config && !ptr->lhvc_config) { + return GF_ISOM_INVALID_FILE; + } + break; + default: + break; + } + + if (ptr->hevc_config && ptr->hevc_config->config) { + e = gf_isom_box_size((GF_Box *)ptr->hevc_config); + if (e) return e; + ptr->size += ptr->hevc_config->size; + } + + if (ptr->avc_config && ptr->avc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->avc_config); + if (e) return e; + ptr->size += ptr->avc_config->size; + } + + if (ptr->svc_config && ptr->svc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->svc_config); + if (e) return e; + ptr->size += ptr->svc_config->size; + } + + if (ptr->mvc_config && ptr->mvc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->mvc_config); + if (e) return e; + ptr->size += ptr->mvc_config->size; + } + + if (ptr->lhvc_config && ptr->lhvc_config->config) { + e = gf_isom_box_size((GF_Box *) ptr->lhvc_config); + if (e) return e; + ptr->size += ptr->lhvc_config->size; + } + + if (ptr->av1_config && ptr->av1_config->config) { + e = gf_isom_box_size((GF_Box *)ptr->av1_config); + if (e) return e; + ptr->size += ptr->av1_config->size; + } + + if (ptr->vp_config && ptr->vp_config->config) { + e = gf_isom_box_size((GF_Box *)ptr->vp_config); + if (e) return e; + ptr->size += ptr->vp_config->size; + } + + if (ptr->ipod_ext) { + e = gf_isom_box_size((GF_Box *) ptr->ipod_ext); + if (e) return e; + ptr->size += ptr->ipod_ext->size; + } + if (ptr->descr) { + e = gf_isom_box_size((GF_Box *) ptr->descr); + if (e) return e; + ptr->size += ptr->descr->size; + } + } + if (ptr->pasp) { + e = gf_isom_box_size((GF_Box *)ptr->pasp); + if (e) return e; + ptr->size += ptr->pasp->size; + } + if (ptr->clap) { + e = gf_isom_box_size((GF_Box *)ptr->clap); + if (e) return e; + ptr->size += ptr->clap->size; + } + if (ptr->ccst) { + e = gf_isom_box_size((GF_Box *)ptr->ccst); + if (e) return e; + ptr->size += ptr->ccst->size; + } + if (ptr->auxi) { + e = gf_isom_box_size((GF_Box *)ptr->auxi); + if (e) return e; + ptr->size += ptr->auxi->size; + } + if (ptr->rvcc) { + e = gf_isom_box_size((GF_Box *)ptr->rvcc); + if (e) return e; + ptr->size += ptr->rvcc->size; + } + if (ptr->rinf) { + e = gf_isom_box_size((GF_Box *)ptr->rinf); + if (e) return e; + ptr->size += ptr->rinf->size; + } + return gf_isom_box_array_size(s, ptr->protections); +} +","@@ -931,8 +931,11 @@ GF_Err dinf_Read(GF_Box *s, GF_BitStream *bs) + return e; + } + if (!((GF_DataInformationBox *)s)->dref) { ++ GF_Box* dref; + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (""[iso file] Missing dref box in dinf\n"")); +- ((GF_DataInformationBox *)s)->dref = (GF_DataReferenceBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_DREF); ++ dref = gf_isom_box_new(GF_ISOM_BOX_TYPE_DREF); ++ ((GF_DataInformationBox *)s)->dref = (GF_DataReferenceBox *)dref; ++ gf_isom_box_add_for_dump_mode(s, dref); + } + return GF_OK; + }",1288,1524,2048 +476,"PHP_FUNCTION(openssl_pkey_get_details) +{ + zval *key; + EVP_PKEY *pkey; + BIO *out; + unsigned int pbio_len; + char *pbio; + zend_long ktype; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), ""r"", &key) == FAILURE) { + return; + } + if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), ""OpenSSL key"", le_key)) == NULL) { + RETURN_FALSE; + } + out = BIO_new(BIO_s_mem()); + if (!PEM_write_bio_PUBKEY(out, pkey)) { + BIO_free(out); + php_openssl_store_errors(); + RETURN_FALSE; + } + pbio_len = BIO_get_mem_data(out, &pbio); + + array_init(return_value); + add_assoc_long(return_value, ""bits"", EVP_PKEY_bits(pkey)); + add_assoc_stringl(return_value, ""key"", pbio, pbio_len); + /*TODO: Use the real values once the openssl constants are used + * See the enum at the top of this file + */ + switch (EVP_PKEY_base_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + { + RSA *rsa = EVP_PKEY_get0_RSA(pkey); + ktype = OPENSSL_KEYTYPE_RSA; + + if (rsa != NULL) { + zval z_rsa; + const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; + + RSA_get0_key(rsa, &n, &e, &d); + RSA_get0_factors(rsa, &p, &q); + RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); + + array_init(&z_rsa); + OPENSSL_PKEY_GET_BN(z_rsa, n); + OPENSSL_PKEY_GET_BN(z_rsa, e); + OPENSSL_PKEY_GET_BN(z_rsa, d); + OPENSSL_PKEY_GET_BN(z_rsa, p); + OPENSSL_PKEY_GET_BN(z_rsa, q); + OPENSSL_PKEY_GET_BN(z_rsa, dmp1); + OPENSSL_PKEY_GET_BN(z_rsa, dmq1); + OPENSSL_PKEY_GET_BN(z_rsa, iqmp); + add_assoc_zval(return_value, ""rsa"", &z_rsa); + } + } + break; + case EVP_PKEY_DSA: + case EVP_PKEY_DSA2: + case EVP_PKEY_DSA3: + case EVP_PKEY_DSA4: + { + DSA *dsa = EVP_PKEY_get0_DSA(pkey); + ktype = OPENSSL_KEYTYPE_DSA; + + if (dsa != NULL) { + zval z_dsa; + const BIGNUM *p, *q, *g, *priv_key, *pub_key; + + DSA_get0_pqg(dsa, &p, &q, &g); + DSA_get0_key(dsa, &pub_key, &priv_key); + + array_init(&z_dsa); + OPENSSL_PKEY_GET_BN(z_dsa, p); + OPENSSL_PKEY_GET_BN(z_dsa, q); + OPENSSL_PKEY_GET_BN(z_dsa, g); + OPENSSL_PKEY_GET_BN(z_dsa, priv_key); + OPENSSL_PKEY_GET_BN(z_dsa, pub_key); + add_assoc_zval(return_value, ""dsa"", &z_dsa); + } + } + break; + case EVP_PKEY_DH: + { + DH *dh = EVP_PKEY_get0_DH(pkey); + ktype = OPENSSL_KEYTYPE_DH; + + if (dh != NULL) { + zval z_dh; + const BIGNUM *p, *q, *g, *priv_key, *pub_key; + + DH_get0_pqg(dh, &p, &q, &g); + DH_get0_key(dh, &pub_key, &priv_key); + + array_init(&z_dh); + OPENSSL_PKEY_GET_BN(z_dh, p); + OPENSSL_PKEY_GET_BN(z_dh, g); + OPENSSL_PKEY_GET_BN(z_dh, priv_key); + OPENSSL_PKEY_GET_BN(z_dh, pub_key); + add_assoc_zval(return_value, ""dh"", &z_dh); + } + } + break; +#ifdef HAVE_EVP_PKEY_EC + case EVP_PKEY_EC: + ktype = OPENSSL_KEYTYPE_EC; + if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { + zval ec; + const EC_GROUP *ec_group; + const EC_POINT *pub; + int nid; + char *crv_sn; + ASN1_OBJECT *obj; + char oir_buf[80]; + const EC_KEY *ec_key = EVP_PKEY_get0_EC_KEY(pkey); + BIGNUM *x = BN_new(); + BIGNUM *y = BN_new(); + const BIGNUM *d; + + ec_group = EC_KEY_get0_group(ec_key); + + nid = EC_GROUP_get_curve_name(ec_group); + if (nid == NID_undef) { + break; + } + array_init(&ec); + + crv_sn = (char*) OBJ_nid2sn(nid); + if (crv_sn != NULL) { + add_assoc_string(&ec, ""curve_name"", crv_sn); + } + + obj = OBJ_nid2obj(nid); + if (obj != NULL) { + int oir_len = OBJ_obj2txt(oir_buf, sizeof(oir_buf), obj, 1); + add_assoc_stringl(&ec, ""curve_oid"", (char*) oir_buf, oir_len); + ASN1_OBJECT_free(obj); + } + + pub = EC_KEY_get0_public_key(ec_key); + + if (EC_POINT_get_affine_coordinates_GFp(ec_group, pub, x, y, NULL)) { + OPENSSL_GET_BN(ec, x, x); + OPENSSL_GET_BN(ec, y, y); + } else { + php_openssl_store_errors(); + } + + if ((d = EC_KEY_get0_private_key(EVP_PKEY_get0_EC_KEY(pkey))) != NULL) { + OPENSSL_GET_BN(ec, d, d); + } + + add_assoc_zval(return_value, ""ec"", &ec); + + BN_free(x); + BN_free(y); + } + break; +#endif + default: + ktype = -1; + break; + } + add_assoc_long(return_value, ""type"", ktype); + + BIO_free(out); +} +",0,"PHP_FUNCTION(openssl_pkey_get_details) +{ + zval *key; + EVP_PKEY *pkey; + BIO *out; + unsigned int pbio_len; + char *pbio; + zend_long ktype; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), ""r"", &key) == FAILURE) { + return; + } + if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), ""OpenSSL key"", le_key)) == NULL) { + RETURN_FALSE; + } + out = BIO_new(BIO_s_mem()); + if (!PEM_write_bio_PUBKEY(out, pkey)) { + BIO_free(out); + php_openssl_store_errors(); + RETURN_FALSE; + } + pbio_len = BIO_get_mem_data(out, &pbio); + + array_init(return_value); + add_assoc_long(return_value, ""bits"", EVP_PKEY_bits(pkey)); + add_assoc_stringl(return_value, ""key"", pbio, pbio_len); + /*TODO: Use the real values once the openssl constants are used + * See the enum at the top of this file + */ + switch (EVP_PKEY_base_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + { + RSA *rsa = EVP_PKEY_get0_RSA(pkey); + ktype = OPENSSL_KEYTYPE_RSA; + + if (rsa != NULL) { + zval z_rsa; + const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; + + RSA_get0_key(rsa, &n, &e, &d); + RSA_get0_factors(rsa, &p, &q); + RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); + + array_init(&z_rsa); + OPENSSL_PKEY_GET_BN(z_rsa, n); + OPENSSL_PKEY_GET_BN(z_rsa, e); + OPENSSL_PKEY_GET_BN(z_rsa, d); + OPENSSL_PKEY_GET_BN(z_rsa, p); + OPENSSL_PKEY_GET_BN(z_rsa, q); + OPENSSL_PKEY_GET_BN(z_rsa, dmp1); + OPENSSL_PKEY_GET_BN(z_rsa, dmq1); + OPENSSL_PKEY_GET_BN(z_rsa, iqmp); + add_assoc_zval(return_value, ""rsa"", &z_rsa); + } + } + break; + case EVP_PKEY_DSA: + case EVP_PKEY_DSA2: + case EVP_PKEY_DSA3: + case EVP_PKEY_DSA4: + { + DSA *dsa = EVP_PKEY_get0_DSA(pkey); + ktype = OPENSSL_KEYTYPE_DSA; + + if (dsa != NULL) { + zval z_dsa; + const BIGNUM *p, *q, *g, *priv_key, *pub_key; + + DSA_get0_pqg(dsa, &p, &q, &g); + DSA_get0_key(dsa, &pub_key, &priv_key); + + array_init(&z_dsa); + OPENSSL_PKEY_GET_BN(z_dsa, p); + OPENSSL_PKEY_GET_BN(z_dsa, q); + OPENSSL_PKEY_GET_BN(z_dsa, g); + OPENSSL_PKEY_GET_BN(z_dsa, priv_key); + OPENSSL_PKEY_GET_BN(z_dsa, pub_key); + add_assoc_zval(return_value, ""dsa"", &z_dsa); + } + } + break; + case EVP_PKEY_DH: + { + DH *dh = EVP_PKEY_get0_DH(pkey); + ktype = OPENSSL_KEYTYPE_DH; + + if (dh != NULL) { + zval z_dh; + const BIGNUM *p, *q, *g, *priv_key, *pub_key; + + DH_get0_pqg(dh, &p, &q, &g); + DH_get0_key(dh, &pub_key, &priv_key); + + array_init(&z_dh); + OPENSSL_PKEY_GET_BN(z_dh, p); + OPENSSL_PKEY_GET_BN(z_dh, g); + OPENSSL_PKEY_GET_BN(z_dh, priv_key); + OPENSSL_PKEY_GET_BN(z_dh, pub_key); + add_assoc_zval(return_value, ""dh"", &z_dh); + } + } + break; +#ifdef HAVE_EVP_PKEY_EC + case EVP_PKEY_EC: + ktype = OPENSSL_KEYTYPE_EC; + if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { + zval ec; + const EC_GROUP *ec_group; + const EC_POINT *pub; + int nid; + char *crv_sn; + ASN1_OBJECT *obj; + char oir_buf[80]; + const EC_KEY *ec_key = EVP_PKEY_get0_EC_KEY(pkey); + BIGNUM *x = BN_new(); + BIGNUM *y = BN_new(); + const BIGNUM *d; + + ec_group = EC_KEY_get0_group(ec_key); + + nid = EC_GROUP_get_curve_name(ec_group); + if (nid == NID_undef) { + break; + } + array_init(&ec); + + crv_sn = (char*) OBJ_nid2sn(nid); + if (crv_sn != NULL) { + add_assoc_string(&ec, ""curve_name"", crv_sn); + } + + obj = OBJ_nid2obj(nid); + if (obj != NULL) { + int oir_len = OBJ_obj2txt(oir_buf, sizeof(oir_buf), obj, 1); + add_assoc_stringl(&ec, ""curve_oid"", (char*) oir_buf, oir_len); + ASN1_OBJECT_free(obj); + } + + pub = EC_KEY_get0_public_key(ec_key); + + if (EC_POINT_get_affine_coordinates_GFp(ec_group, pub, x, y, NULL)) { + OPENSSL_GET_BN(ec, x, x); + OPENSSL_GET_BN(ec, y, y); + } else { + php_openssl_store_errors(); + } + + if ((d = EC_KEY_get0_private_key(EVP_PKEY_get0_EC_KEY(pkey))) != NULL) { + OPENSSL_GET_BN(ec, d, d); + } + + add_assoc_zval(return_value, ""ec"", &ec); + + BN_free(x); + BN_free(y); + } + break; +#endif + default: + ktype = -1; + break; + } + add_assoc_long(return_value, ""type"", ktype); + + BIO_free(out); +} +","@@ -5926,7 +5926,7 @@ PHP_FUNCTION(openssl_seal) + buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(ctx)); + EVP_CIPHER_CTX_cleanup(ctx); + +- if (!EVP_SealInit(ctx, cipher, eks, eksl, &iv_buf[0], pkeys, nkeys) || ++ if (EVP_SealInit(ctx, cipher, eks, eksl, &iv_buf[0], pkeys, nkeys) <= 0 || + !EVP_SealUpdate(ctx, buf, &len1, (unsigned char *)data, (int)data_len) || + !EVP_SealFinal(ctx, buf + len1, &len2)) { + efree(buf);",1489,1725,2048 +17634,"xmlHasFeature(xmlFeature feature) +{ + switch (feature) { + case XML_WITH_THREAD: +#ifdef LIBXML_THREAD_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_TREE: +#ifdef LIBXML_TREE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_OUTPUT: +#ifdef LIBXML_OUTPUT_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_PUSH: +#ifdef LIBXML_PUSH_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_READER: +#ifdef LIBXML_READER_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_PATTERN: +#ifdef LIBXML_PATTERN_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_WRITER: +#ifdef LIBXML_WRITER_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SAX1: +#ifdef LIBXML_SAX1_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_FTP: +#ifdef LIBXML_FTP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_HTTP: +#ifdef LIBXML_HTTP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_VALID: +#ifdef LIBXML_VALID_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_HTML: +#ifdef LIBXML_HTML_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_LEGACY: +#ifdef LIBXML_LEGACY_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_C14N: +#ifdef LIBXML_C14N_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_CATALOG: +#ifdef LIBXML_CATALOG_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XPATH: +#ifdef LIBXML_XPATH_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XPTR: +#ifdef LIBXML_XPTR_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XINCLUDE: +#ifdef LIBXML_XINCLUDE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ICONV: +#ifdef LIBXML_ICONV_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ISO8859X: +#ifdef LIBXML_ISO8859X_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_UNICODE: +#ifdef LIBXML_UNICODE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_REGEXP: +#ifdef LIBXML_REGEXP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_AUTOMATA: +#ifdef LIBXML_AUTOMATA_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_EXPR: +#ifdef LIBXML_EXPR_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SCHEMAS: +#ifdef LIBXML_SCHEMAS_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SCHEMATRON: +#ifdef LIBXML_SCHEMATRON_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_MODULES: +#ifdef LIBXML_MODULES_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG: +#ifdef LIBXML_DEBUG_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG_MEM: +#ifdef DEBUG_MEMORY_LOCATION + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG_RUN: +#ifdef LIBXML_DEBUG_RUNTIME + return(1); +#else + return(0); +#endif + case XML_WITH_ZLIB: +#ifdef LIBXML_ZLIB_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_LZMA: +#ifdef LIBXML_LZMA_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ICU: +#ifdef LIBXML_ICU_ENABLED + return(1); +#else + return(0); +#endif + default: + break; + } + return(0); +} +",0,"xmlHasFeature(xmlFeature feature) +{ + switch (feature) { + case XML_WITH_THREAD: +#ifdef LIBXML_THREAD_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_TREE: +#ifdef LIBXML_TREE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_OUTPUT: +#ifdef LIBXML_OUTPUT_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_PUSH: +#ifdef LIBXML_PUSH_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_READER: +#ifdef LIBXML_READER_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_PATTERN: +#ifdef LIBXML_PATTERN_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_WRITER: +#ifdef LIBXML_WRITER_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SAX1: +#ifdef LIBXML_SAX1_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_FTP: +#ifdef LIBXML_FTP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_HTTP: +#ifdef LIBXML_HTTP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_VALID: +#ifdef LIBXML_VALID_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_HTML: +#ifdef LIBXML_HTML_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_LEGACY: +#ifdef LIBXML_LEGACY_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_C14N: +#ifdef LIBXML_C14N_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_CATALOG: +#ifdef LIBXML_CATALOG_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XPATH: +#ifdef LIBXML_XPATH_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XPTR: +#ifdef LIBXML_XPTR_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_XINCLUDE: +#ifdef LIBXML_XINCLUDE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ICONV: +#ifdef LIBXML_ICONV_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ISO8859X: +#ifdef LIBXML_ISO8859X_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_UNICODE: +#ifdef LIBXML_UNICODE_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_REGEXP: +#ifdef LIBXML_REGEXP_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_AUTOMATA: +#ifdef LIBXML_AUTOMATA_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_EXPR: +#ifdef LIBXML_EXPR_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SCHEMAS: +#ifdef LIBXML_SCHEMAS_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_SCHEMATRON: +#ifdef LIBXML_SCHEMATRON_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_MODULES: +#ifdef LIBXML_MODULES_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG: +#ifdef LIBXML_DEBUG_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG_MEM: +#ifdef DEBUG_MEMORY_LOCATION + return(1); +#else + return(0); +#endif + case XML_WITH_DEBUG_RUN: +#ifdef LIBXML_DEBUG_RUNTIME + return(1); +#else + return(0); +#endif + case XML_WITH_ZLIB: +#ifdef LIBXML_ZLIB_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_LZMA: +#ifdef LIBXML_LZMA_ENABLED + return(1); +#else + return(0); +#endif + case XML_WITH_ICU: +#ifdef LIBXML_ICU_ENABLED + return(1); +#else + return(0); +#endif + default: + break; + } + return(0); +} +","@@ -8130,6 +8130,14 @@ + + if (xmlPushInput(ctxt, input) < 0) + return; + } else { ++ if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && ++ ((ctxt->options & XML_PARSE_NOENT) == 0) && ++ ((ctxt->options & XML_PARSE_DTDVALID) == 0) && ++ ((ctxt->options & XML_PARSE_DTDLOAD) == 0) && ++ ((ctxt->options & XML_PARSE_DTDATTR) == 0) && ++ (ctxt->replaceEntities == 0) && ++ (ctxt->validate == 0)) ++ return; + /* + * TODO !!! + * handle the extra spaces added before and after +",845,1081,2048 +23,"char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar TSRMLS_DC) /* {{{ */ +{ + char *path, *fname, *arch, *entry, *ret, *test; + int arch_len, entry_len, fname_len, ret_len; + phar_archive_data *phar; + + if (pphar) { + *pphar = NULL; + } else { + pphar = &phar; + } + + if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) { + return phar_save_resolve_path(filename, filename_len TSRMLS_CC); + } + + fname = (char*)zend_get_executed_filename(TSRMLS_C); + fname_len = strlen(fname); + + if (PHAR_G(last_phar) && !memcmp(fname, ""phar://"", 7) && fname_len - 7 >= PHAR_G(last_phar_name_len) && !memcmp(fname + 7, PHAR_G(last_phar_name), PHAR_G(last_phar_name_len))) { + arch = estrndup(PHAR_G(last_phar_name), PHAR_G(last_phar_name_len)); + arch_len = PHAR_G(last_phar_name_len); + phar = PHAR_G(last_phar); + goto splitted; + } + + if (fname_len < 7 || memcmp(fname, ""phar://"", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { + return phar_save_resolve_path(filename, filename_len TSRMLS_CC); + } + + efree(entry); + + if (*filename == '.') { + int try_len; + + if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) { + efree(arch); + return phar_save_resolve_path(filename, filename_len TSRMLS_CC); + } +splitted: + if (pphar) { + *pphar = phar; + } + + try_len = filename_len; + test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC); + + if (*test == '/') { + if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) { + spprintf(&ret, 0, ""phar://%s%s"", arch, test); + efree(arch); + efree(test); + return ret; + } + } else { + if (zend_hash_exists(&(phar->manifest), test, try_len)) { + spprintf(&ret, 0, ""phar://%s/%s"", arch, test); + efree(arch); + efree(test); + return ret; + } + } + efree(test); + } + + spprintf(&path, MAXPATHLEN, ""phar://%s/%s%c%s"", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path)); + efree(arch); + ret = php_resolve_path(filename, filename_len, path TSRMLS_CC); + efree(path); + + if (ret && strlen(ret) > 8 && !strncmp(ret, ""phar://"", 7)) { + ret_len = strlen(ret); + /* found phar:// */ + + if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { + return ret; + } + + zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar); + + if (!pphar && PHAR_G(manifest_cached)) { + zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar); + } + + efree(arch); + efree(entry); + } + + return ret; +} +/* }}} */ +",0,"char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar TSRMLS_DC) /* {{{ */ +{ + char *path, *fname, *arch, *entry, *ret, *test; + int arch_len, entry_len, fname_len, ret_len; + phar_archive_data *phar; + + if (pphar) { + *pphar = NULL; + } else { + pphar = &phar; + } + + if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) { + return phar_save_resolve_path(filename, filename_len TSRMLS_CC); + } + + fname = (char*)zend_get_executed_filename(TSRMLS_C); + fname_len = strlen(fname); + + if (PHAR_G(last_phar) && !memcmp(fname, ""phar://"", 7) && fname_len - 7 >= PHAR_G(last_phar_name_len) && !memcmp(fname + 7, PHAR_G(last_phar_name), PHAR_G(last_phar_name_len))) { + arch = estrndup(PHAR_G(last_phar_name), PHAR_G(last_phar_name_len)); + arch_len = PHAR_G(last_phar_name_len); + phar = PHAR_G(last_phar); + goto splitted; + } + + if (fname_len < 7 || memcmp(fname, ""phar://"", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { + return phar_save_resolve_path(filename, filename_len TSRMLS_CC); + } + + efree(entry); + + if (*filename == '.') { + int try_len; + + if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) { + efree(arch); + return phar_save_resolve_path(filename, filename_len TSRMLS_CC); + } +splitted: + if (pphar) { + *pphar = phar; + } + + try_len = filename_len; + test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC); + + if (*test == '/') { + if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) { + spprintf(&ret, 0, ""phar://%s%s"", arch, test); + efree(arch); + efree(test); + return ret; + } + } else { + if (zend_hash_exists(&(phar->manifest), test, try_len)) { + spprintf(&ret, 0, ""phar://%s/%s"", arch, test); + efree(arch); + efree(test); + return ret; + } + } + efree(test); + } + + spprintf(&path, MAXPATHLEN, ""phar://%s/%s%c%s"", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path)); + efree(arch); + ret = php_resolve_path(filename, filename_len, path TSRMLS_CC); + efree(path); + + if (ret && strlen(ret) > 8 && !strncmp(ret, ""phar://"", 7)) { + ret_len = strlen(ret); + /* found phar:// */ + + if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { + return ret; + } + + zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar); + + if (!pphar && PHAR_G(manifest_cached)) { + zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar); + } + + efree(arch); + efree(entry); + } + + return ret; +} +/* }}} */ +","@@ -1977,7 +1977,7 @@ void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename + + while ((s = zend_memrchr(filename, '/', filename_len))) { + filename_len = s - filename; +- if (FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) { ++ if (!filename_len || FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) { + break; + } + }",855,1091,2048 +5813,"void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) +{ + struct kvm *kvm = vcpu->kvm; + u64 offset, ns, elapsed; + unsigned long flags; + s64 usdiff; + bool matched; + bool already_matched; + u64 data = msr->data; + + raw_spin_lock_irqsave(&kvm->arch.tsc_write_lock, flags); + offset = kvm_compute_tsc_offset(vcpu, data); + ns = get_kernel_ns(); + elapsed = ns - kvm->arch.last_tsc_nsec; + + if (vcpu->arch.virtual_tsc_khz) { + int faulted = 0; + + /* n.b - signed multiplication and division required */ + usdiff = data - kvm->arch.last_tsc_write; +#ifdef CONFIG_X86_64 + usdiff = (usdiff * 1000) / vcpu->arch.virtual_tsc_khz; +#else + /* do_div() only does unsigned */ + asm(""1: idivl %[divisor]\n"" + ""2: xor %%edx, %%edx\n"" + "" movl $0, %[faulted]\n"" + ""3:\n"" + "".section .fixup,\""ax\""\n"" + ""4: movl $1, %[faulted]\n"" + "" jmp 3b\n"" + "".previous\n"" + + _ASM_EXTABLE(1b, 4b) + + : ""=A""(usdiff), [faulted] ""=r"" (faulted) + : ""A""(usdiff * 1000), [divisor] ""rm""(vcpu->arch.virtual_tsc_khz)); + +#endif + do_div(elapsed, 1000); + usdiff -= elapsed; + if (usdiff < 0) + usdiff = -usdiff; + + /* idivl overflow => difference is larger than USEC_PER_SEC */ + if (faulted) + usdiff = USEC_PER_SEC; + } else + usdiff = USEC_PER_SEC; /* disable TSC match window below */ + + /* + * Special case: TSC write with a small delta (1 second) of virtual + * cycle time against real time is interpreted as an attempt to + * synchronize the CPU. + * + * For a reliable TSC, we can match TSC offsets, and for an unstable + * TSC, we add elapsed time in this computation. We could let the + * compensation code attempt to catch up if we fall behind, but + * it's better to try to match offsets from the beginning. + */ + if (usdiff < USEC_PER_SEC && + vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) { + if (!check_tsc_unstable()) { + offset = kvm->arch.cur_tsc_offset; + pr_debug(""kvm: matched tsc offset for %llu\n"", data); + } else { + u64 delta = nsec_to_cycles(vcpu, elapsed); + data += delta; + offset = kvm_compute_tsc_offset(vcpu, data); + pr_debug(""kvm: adjusted tsc offset by %llu\n"", delta); + } + matched = true; + already_matched = (vcpu->arch.this_tsc_generation == kvm->arch.cur_tsc_generation); + } else { + /* + * We split periods of matched TSC writes into generations. + * For each generation, we track the original measured + * nanosecond time, offset, and write, so if TSCs are in + * sync, we can match exact offset, and if not, we can match + * exact software computation in compute_guest_tsc() + * + * These values are tracked in kvm->arch.cur_xxx variables. + */ + kvm->arch.cur_tsc_generation++; + kvm->arch.cur_tsc_nsec = ns; + kvm->arch.cur_tsc_write = data; + kvm->arch.cur_tsc_offset = offset; + matched = false; + pr_debug(""kvm: new tsc generation %llu, clock %llu\n"", + kvm->arch.cur_tsc_generation, data); + } + + /* + * We also track th most recent recorded KHZ, write and time to + * allow the matching interval to be extended at each write. + */ + kvm->arch.last_tsc_nsec = ns; + kvm->arch.last_tsc_write = data; + kvm->arch.last_tsc_khz = vcpu->arch.virtual_tsc_khz; + + vcpu->arch.last_guest_tsc = data; + + /* Keep track of which generation this VCPU has synchronized to */ + vcpu->arch.this_tsc_generation = kvm->arch.cur_tsc_generation; + vcpu->arch.this_tsc_nsec = kvm->arch.cur_tsc_nsec; + vcpu->arch.this_tsc_write = kvm->arch.cur_tsc_write; + + if (guest_cpuid_has_tsc_adjust(vcpu) && !msr->host_initiated) + update_ia32_tsc_adjust_msr(vcpu, offset); + kvm_x86_ops->write_tsc_offset(vcpu, offset); + raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags); + + spin_lock(&kvm->arch.pvclock_gtod_sync_lock); + if (!matched) { + kvm->arch.nr_vcpus_matched_tsc = 0; + } else if (!already_matched) { + kvm->arch.nr_vcpus_matched_tsc++; + } + + kvm_track_tsc_matching(vcpu); + spin_unlock(&kvm->arch.pvclock_gtod_sync_lock); +} +",0,"void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) +{ + struct kvm *kvm = vcpu->kvm; + u64 offset, ns, elapsed; + unsigned long flags; + s64 usdiff; + bool matched; + bool already_matched; + u64 data = msr->data; + + raw_spin_lock_irqsave(&kvm->arch.tsc_write_lock, flags); + offset = kvm_compute_tsc_offset(vcpu, data); + ns = get_kernel_ns(); + elapsed = ns - kvm->arch.last_tsc_nsec; + + if (vcpu->arch.virtual_tsc_khz) { + int faulted = 0; + + /* n.b - signed multiplication and division required */ + usdiff = data - kvm->arch.last_tsc_write; +#ifdef CONFIG_X86_64 + usdiff = (usdiff * 1000) / vcpu->arch.virtual_tsc_khz; +#else + /* do_div() only does unsigned */ + asm(""1: idivl %[divisor]\n"" + ""2: xor %%edx, %%edx\n"" + "" movl $0, %[faulted]\n"" + ""3:\n"" + "".section .fixup,\""ax\""\n"" + ""4: movl $1, %[faulted]\n"" + "" jmp 3b\n"" + "".previous\n"" + + _ASM_EXTABLE(1b, 4b) + + : ""=A""(usdiff), [faulted] ""=r"" (faulted) + : ""A""(usdiff * 1000), [divisor] ""rm""(vcpu->arch.virtual_tsc_khz)); + +#endif + do_div(elapsed, 1000); + usdiff -= elapsed; + if (usdiff < 0) + usdiff = -usdiff; + + /* idivl overflow => difference is larger than USEC_PER_SEC */ + if (faulted) + usdiff = USEC_PER_SEC; + } else + usdiff = USEC_PER_SEC; /* disable TSC match window below */ + + /* + * Special case: TSC write with a small delta (1 second) of virtual + * cycle time against real time is interpreted as an attempt to + * synchronize the CPU. + * + * For a reliable TSC, we can match TSC offsets, and for an unstable + * TSC, we add elapsed time in this computation. We could let the + * compensation code attempt to catch up if we fall behind, but + * it's better to try to match offsets from the beginning. + */ + if (usdiff < USEC_PER_SEC && + vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) { + if (!check_tsc_unstable()) { + offset = kvm->arch.cur_tsc_offset; + pr_debug(""kvm: matched tsc offset for %llu\n"", data); + } else { + u64 delta = nsec_to_cycles(vcpu, elapsed); + data += delta; + offset = kvm_compute_tsc_offset(vcpu, data); + pr_debug(""kvm: adjusted tsc offset by %llu\n"", delta); + } + matched = true; + already_matched = (vcpu->arch.this_tsc_generation == kvm->arch.cur_tsc_generation); + } else { + /* + * We split periods of matched TSC writes into generations. + * For each generation, we track the original measured + * nanosecond time, offset, and write, so if TSCs are in + * sync, we can match exact offset, and if not, we can match + * exact software computation in compute_guest_tsc() + * + * These values are tracked in kvm->arch.cur_xxx variables. + */ + kvm->arch.cur_tsc_generation++; + kvm->arch.cur_tsc_nsec = ns; + kvm->arch.cur_tsc_write = data; + kvm->arch.cur_tsc_offset = offset; + matched = false; + pr_debug(""kvm: new tsc generation %llu, clock %llu\n"", + kvm->arch.cur_tsc_generation, data); + } + + /* + * We also track th most recent recorded KHZ, write and time to + * allow the matching interval to be extended at each write. + */ + kvm->arch.last_tsc_nsec = ns; + kvm->arch.last_tsc_write = data; + kvm->arch.last_tsc_khz = vcpu->arch.virtual_tsc_khz; + + vcpu->arch.last_guest_tsc = data; + + /* Keep track of which generation this VCPU has synchronized to */ + vcpu->arch.this_tsc_generation = kvm->arch.cur_tsc_generation; + vcpu->arch.this_tsc_nsec = kvm->arch.cur_tsc_nsec; + vcpu->arch.this_tsc_write = kvm->arch.cur_tsc_write; + + if (guest_cpuid_has_tsc_adjust(vcpu) && !msr->host_initiated) + update_ia32_tsc_adjust_msr(vcpu, offset); + kvm_x86_ops->write_tsc_offset(vcpu, offset); + raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags); + + spin_lock(&kvm->arch.pvclock_gtod_sync_lock); + if (!matched) { + kvm->arch.nr_vcpus_matched_tsc = 0; + } else if (!already_matched) { + kvm->arch.nr_vcpus_matched_tsc++; + } + + kvm_track_tsc_matching(vcpu); + spin_unlock(&kvm->arch.pvclock_gtod_sync_lock); +} +","@@ -3572,9 +3572,11 @@ static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps) + + static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) + { ++ int i; + mutex_lock(&kvm->arch.vpit->pit_state.lock); + memcpy(&kvm->arch.vpit->pit_state, ps, sizeof(struct kvm_pit_state)); +- kvm_pit_load_count(kvm, 0, ps->channels[0].count, 0); ++ for (i = 0; i < 3; i++) ++ kvm_pit_load_count(kvm, i, ps->channels[i].count, 0); + mutex_unlock(&kvm->arch.vpit->pit_state.lock); + return 0; + } +@@ -3593,6 +3595,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) + static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) + { + int start = 0; ++ int i; + u32 prev_legacy, cur_legacy; + mutex_lock(&kvm->arch.vpit->pit_state.lock); + prev_legacy = kvm->arch.vpit->pit_state.flags & KVM_PIT_FLAGS_HPET_LEGACY; +@@ -3602,7 +3605,8 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) + memcpy(&kvm->arch.vpit->pit_state.channels, &ps->channels, + sizeof(kvm->arch.vpit->pit_state.channels)); + kvm->arch.vpit->pit_state.flags = ps->flags; +- kvm_pit_load_count(kvm, 0, kvm->arch.vpit->pit_state.channels[0].count, start); ++ for (i = 0; i < 3; i++) ++ kvm_pit_load_count(kvm, i, kvm->arch.vpit->pit_state.channels[i].count, start); + mutex_unlock(&kvm->arch.vpit->pit_state.lock); + return 0; + }",1216,1452,2048 +6584,"static int nsv_parse_NSVs_header(AVFormatContext *s) +{ + NSVContext *nsv = s->priv_data; + AVIOContext *pb = s->pb; + uint32_t vtag, atag; + uint16_t vwidth, vheight; + AVRational framerate; + int i; + AVStream *st; + NSVStream *nst; + + vtag = avio_rl32(pb); + atag = avio_rl32(pb); + vwidth = avio_rl16(pb); + vheight = avio_rl16(pb); + i = avio_r8(pb); + + av_log(s, AV_LOG_TRACE, ""NSV NSVs framerate code %2x\n"", i); + if(i&0x80) { /* odd way of giving native framerates from docs */ + int t=(i & 0x7F)>>2; + if(t<16) framerate = (AVRational){1, t+1}; + else framerate = (AVRational){t-15, 1}; + + if(i&1){ + framerate.num *= 1000; + framerate.den *= 1001; + } + + if((i&3)==3) framerate.num *= 24; + else if((i&3)==2) framerate.num *= 25; + else framerate.num *= 30; + } + else + framerate= (AVRational){i, 1}; + + nsv->avsync = avio_rl16(pb); + nsv->framerate = framerate; + + av_log(s, AV_LOG_TRACE, ""NSV NSVs vsize %""PRIu16""x%""PRIu16""\n"", + vwidth, vheight); + + /* XXX change to ap != NULL ? */ + if (s->nb_streams == 0) { /* streams not yet published, let's do that */ + nsv->vtag = vtag; + nsv->atag = atag; + nsv->vwidth = vwidth; + nsv->vheight = vwidth; + if (vtag != T_NONE) { + int i; + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_VIDEO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_tag = vtag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_video_tags, vtag); + st->codecpar->width = vwidth; + st->codecpar->height = vheight; + st->codecpar->bits_per_coded_sample = 24; /* depth XXX */ + + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); + st->start_time = 0; + st->duration = av_rescale(nsv->duration, framerate.num, 1000*framerate.den); + + for(i=0;iindex_entries;i++) { + if(nsv->nsvs_timestamps) { + av_add_index_entry(st, nsv->nsvs_file_offset[i], nsv->nsvs_timestamps[i], + 0, 0, AVINDEX_KEYFRAME); + } else { + int64_t ts = av_rescale(i*nsv->duration/nsv->index_entries, framerate.num, 1000*framerate.den); + av_add_index_entry(st, nsv->nsvs_file_offset[i], ts, 0, 0, AVINDEX_KEYFRAME); + } + } + } + if (atag != T_NONE) { + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_AUDIO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = atag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag); + + st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */ + + /* set timebase to common denominator of ms and framerate */ + avpriv_set_pts_info(st, 64, 1, framerate.num*1000); + st->start_time = 0; + st->duration = (int64_t)nsv->duration * framerate.num; + } + } else { + if (nsv->vtag != vtag || nsv->atag != atag || nsv->vwidth != vwidth || nsv->vheight != vwidth) { + av_log(s, AV_LOG_TRACE, ""NSV NSVs header values differ from the first one!!!\n""); + } + } + + nsv->state = NSV_HAS_READ_NSVS; + return 0; +fail: + /* XXX */ + nsv->state = NSV_UNSYNC; + return -1; +} +",0,"static int nsv_parse_NSVs_header(AVFormatContext *s) +{ + NSVContext *nsv = s->priv_data; + AVIOContext *pb = s->pb; + uint32_t vtag, atag; + uint16_t vwidth, vheight; + AVRational framerate; + int i; + AVStream *st; + NSVStream *nst; + + vtag = avio_rl32(pb); + atag = avio_rl32(pb); + vwidth = avio_rl16(pb); + vheight = avio_rl16(pb); + i = avio_r8(pb); + + av_log(s, AV_LOG_TRACE, ""NSV NSVs framerate code %2x\n"", i); + if(i&0x80) { /* odd way of giving native framerates from docs */ + int t=(i & 0x7F)>>2; + if(t<16) framerate = (AVRational){1, t+1}; + else framerate = (AVRational){t-15, 1}; + + if(i&1){ + framerate.num *= 1000; + framerate.den *= 1001; + } + + if((i&3)==3) framerate.num *= 24; + else if((i&3)==2) framerate.num *= 25; + else framerate.num *= 30; + } + else + framerate= (AVRational){i, 1}; + + nsv->avsync = avio_rl16(pb); + nsv->framerate = framerate; + + av_log(s, AV_LOG_TRACE, ""NSV NSVs vsize %""PRIu16""x%""PRIu16""\n"", + vwidth, vheight); + + /* XXX change to ap != NULL ? */ + if (s->nb_streams == 0) { /* streams not yet published, let's do that */ + nsv->vtag = vtag; + nsv->atag = atag; + nsv->vwidth = vwidth; + nsv->vheight = vwidth; + if (vtag != T_NONE) { + int i; + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_VIDEO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_tag = vtag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_video_tags, vtag); + st->codecpar->width = vwidth; + st->codecpar->height = vheight; + st->codecpar->bits_per_coded_sample = 24; /* depth XXX */ + + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); + st->start_time = 0; + st->duration = av_rescale(nsv->duration, framerate.num, 1000*framerate.den); + + for(i=0;iindex_entries;i++) { + if(nsv->nsvs_timestamps) { + av_add_index_entry(st, nsv->nsvs_file_offset[i], nsv->nsvs_timestamps[i], + 0, 0, AVINDEX_KEYFRAME); + } else { + int64_t ts = av_rescale(i*nsv->duration/nsv->index_entries, framerate.num, 1000*framerate.den); + av_add_index_entry(st, nsv->nsvs_file_offset[i], ts, 0, 0, AVINDEX_KEYFRAME); + } + } + } + if (atag != T_NONE) { + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_AUDIO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = atag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag); + + st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */ + + /* set timebase to common denominator of ms and framerate */ + avpriv_set_pts_info(st, 64, 1, framerate.num*1000); + st->start_time = 0; + st->duration = (int64_t)nsv->duration * framerate.num; + } + } else { + if (nsv->vtag != vtag || nsv->atag != atag || nsv->vwidth != vwidth || nsv->vheight != vwidth) { + av_log(s, AV_LOG_TRACE, ""NSV NSVs header values differ from the first one!!!\n""); + } + } + + nsv->state = NSV_HAS_READ_NSVS; + return 0; +fail: + /* XXX */ + nsv->state = NSV_UNSYNC; + return -1; +} +","@@ -520,6 +520,7 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header) + uint32_t vsize; + uint16_t asize; + uint16_t auxsize; ++ int ret; + + if (nsv->ahead[0].data || nsv->ahead[1].data) + return 0; //-1; /* hey! eat what you've in your plate first! */ +@@ -571,7 +572,8 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header) + if (vsize && st[NSV_ST_VIDEO]) { + nst = st[NSV_ST_VIDEO]->priv_data; + pkt = &nsv->ahead[NSV_ST_VIDEO]; +- av_get_packet(pb, pkt, vsize); ++ if ((ret = av_get_packet(pb, pkt, vsize)) < 0) ++ return ret; + pkt->stream_index = st[NSV_ST_VIDEO]->index;//NSV_ST_VIDEO; + pkt->dts = nst->frame_offset; + pkt->flags |= nsv->state == NSV_HAS_READ_NSVS ? AV_PKT_FLAG_KEY : 0; /* keyframe only likely on a sync frame */ +@@ -615,7 +617,8 @@ static int nsv_read_chunk(AVFormatContext *s, int fill_header) + bps, channels, samplerate); + } + } +- av_get_packet(pb, pkt, asize); ++ if ((ret = av_get_packet(pb, pkt, asize)) < 0) ++ return ret; + pkt->stream_index = st[NSV_ST_AUDIO]->index;//NSV_ST_AUDIO; + pkt->flags |= nsv->state == NSV_HAS_READ_NSVS ? AV_PKT_FLAG_KEY : 0; /* keyframe only likely on a sync frame */ + if( nsv->state == NSV_HAS_READ_NSVS && st[NSV_ST_VIDEO] ) {",1140,1376,2048 +5689,"void ext4_evict_inode(struct inode *inode) +{ + handle_t *handle; + int err; + + trace_ext4_evict_inode(inode); + + if (inode->i_nlink) { + /* + * When journalling data dirty buffers are tracked only in the + * journal. So although mm thinks everything is clean and + * ready for reaping the inode might still have some pages to + * write in the running transaction or waiting to be + * checkpointed. Thus calling jbd2_journal_invalidatepage() + * (via truncate_inode_pages()) to discard these buffers can + * cause data loss. Also even if we did not discard these + * buffers, we would have no way to find them after the inode + * is reaped and thus user could see stale data if he tries to + * read them before the transaction is checkpointed. So be + * careful and force everything to disk here... We use + * ei->i_datasync_tid to store the newest transaction + * containing inode's data. + * + * Note that directories do not have this problem because they + * don't use page cache. + */ + if (ext4_should_journal_data(inode) && + (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) && + inode->i_ino != EXT4_JOURNAL_INO) { + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; + tid_t commit_tid = EXT4_I(inode)->i_datasync_tid; + + jbd2_complete_transaction(journal, commit_tid); + filemap_write_and_wait(&inode->i_data); + } + truncate_inode_pages_final(&inode->i_data); + + WARN_ON(atomic_read(&EXT4_I(inode)->i_ioend_count)); + goto no_delete; + } + + if (is_bad_inode(inode)) + goto no_delete; + dquot_initialize(inode); + + if (ext4_should_order_data(inode)) + ext4_begin_ordered_truncate(inode, 0); + truncate_inode_pages_final(&inode->i_data); + + WARN_ON(atomic_read(&EXT4_I(inode)->i_ioend_count)); + + /* + * Protect us against freezing - iput() caller didn't have to have any + * protection against it + */ + sb_start_intwrite(inode->i_sb); + handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, + ext4_blocks_for_truncate(inode)+3); + if (IS_ERR(handle)) { + ext4_std_error(inode->i_sb, PTR_ERR(handle)); + /* + * If we're going to skip the normal cleanup, we still need to + * make sure that the in-core orphan linked list is properly + * cleaned up. + */ + ext4_orphan_del(NULL, inode); + sb_end_intwrite(inode->i_sb); + goto no_delete; + } + + if (IS_SYNC(inode)) + ext4_handle_sync(handle); + inode->i_size = 0; + err = ext4_mark_inode_dirty(handle, inode); + if (err) { + ext4_warning(inode->i_sb, + ""couldn't mark inode dirty (err %d)"", err); + goto stop_handle; + } + if (inode->i_blocks) + ext4_truncate(inode); + + /* + * ext4_ext_truncate() doesn't reserve any slop when it + * restarts journal transactions; therefore there may not be + * enough credits left in the handle to remove the inode from + * the orphan list and set the dtime field. + */ + if (!ext4_handle_has_enough_credits(handle, 3)) { + err = ext4_journal_extend(handle, 3); + if (err > 0) + err = ext4_journal_restart(handle, 3); + if (err != 0) { + ext4_warning(inode->i_sb, + ""couldn't extend journal (err %d)"", err); + stop_handle: + ext4_journal_stop(handle); + ext4_orphan_del(NULL, inode); + sb_end_intwrite(inode->i_sb); + goto no_delete; + } + } + + /* + * Kill off the orphan record which ext4_truncate created. + * AKPM: I think this can be inside the above `if'. + * Note that ext4_orphan_del() has to be able to cope with the + * deletion of a non-existent orphan - this is because we don't + * know if ext4_truncate() actually created an orphan record. + * (Well, we could do this if we need to, but heck - it works) + */ + ext4_orphan_del(handle, inode); + EXT4_I(inode)->i_dtime = get_seconds(); + + /* + * One subtle ordering requirement: if anything has gone wrong + * (transaction abort, IO errors, whatever), then we can still + * do these next steps (the fs will already have been marked as + * having errors), but we can't free the inode if the mark_dirty + * fails. + */ + if (ext4_mark_inode_dirty(handle, inode)) + /* If that failed, just do the required in-core inode clear. */ + ext4_clear_inode(inode); + else + ext4_free_inode(handle, inode); + ext4_journal_stop(handle); + sb_end_intwrite(inode->i_sb); + return; +no_delete: + ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ +} +",0,"void ext4_evict_inode(struct inode *inode) +{ + handle_t *handle; + int err; + + trace_ext4_evict_inode(inode); + + if (inode->i_nlink) { + /* + * When journalling data dirty buffers are tracked only in the + * journal. So although mm thinks everything is clean and + * ready for reaping the inode might still have some pages to + * write in the running transaction or waiting to be + * checkpointed. Thus calling jbd2_journal_invalidatepage() + * (via truncate_inode_pages()) to discard these buffers can + * cause data loss. Also even if we did not discard these + * buffers, we would have no way to find them after the inode + * is reaped and thus user could see stale data if he tries to + * read them before the transaction is checkpointed. So be + * careful and force everything to disk here... We use + * ei->i_datasync_tid to store the newest transaction + * containing inode's data. + * + * Note that directories do not have this problem because they + * don't use page cache. + */ + if (ext4_should_journal_data(inode) && + (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) && + inode->i_ino != EXT4_JOURNAL_INO) { + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; + tid_t commit_tid = EXT4_I(inode)->i_datasync_tid; + + jbd2_complete_transaction(journal, commit_tid); + filemap_write_and_wait(&inode->i_data); + } + truncate_inode_pages_final(&inode->i_data); + + WARN_ON(atomic_read(&EXT4_I(inode)->i_ioend_count)); + goto no_delete; + } + + if (is_bad_inode(inode)) + goto no_delete; + dquot_initialize(inode); + + if (ext4_should_order_data(inode)) + ext4_begin_ordered_truncate(inode, 0); + truncate_inode_pages_final(&inode->i_data); + + WARN_ON(atomic_read(&EXT4_I(inode)->i_ioend_count)); + + /* + * Protect us against freezing - iput() caller didn't have to have any + * protection against it + */ + sb_start_intwrite(inode->i_sb); + handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, + ext4_blocks_for_truncate(inode)+3); + if (IS_ERR(handle)) { + ext4_std_error(inode->i_sb, PTR_ERR(handle)); + /* + * If we're going to skip the normal cleanup, we still need to + * make sure that the in-core orphan linked list is properly + * cleaned up. + */ + ext4_orphan_del(NULL, inode); + sb_end_intwrite(inode->i_sb); + goto no_delete; + } + + if (IS_SYNC(inode)) + ext4_handle_sync(handle); + inode->i_size = 0; + err = ext4_mark_inode_dirty(handle, inode); + if (err) { + ext4_warning(inode->i_sb, + ""couldn't mark inode dirty (err %d)"", err); + goto stop_handle; + } + if (inode->i_blocks) + ext4_truncate(inode); + + /* + * ext4_ext_truncate() doesn't reserve any slop when it + * restarts journal transactions; therefore there may not be + * enough credits left in the handle to remove the inode from + * the orphan list and set the dtime field. + */ + if (!ext4_handle_has_enough_credits(handle, 3)) { + err = ext4_journal_extend(handle, 3); + if (err > 0) + err = ext4_journal_restart(handle, 3); + if (err != 0) { + ext4_warning(inode->i_sb, + ""couldn't extend journal (err %d)"", err); + stop_handle: + ext4_journal_stop(handle); + ext4_orphan_del(NULL, inode); + sb_end_intwrite(inode->i_sb); + goto no_delete; + } + } + + /* + * Kill off the orphan record which ext4_truncate created. + * AKPM: I think this can be inside the above `if'. + * Note that ext4_orphan_del() has to be able to cope with the + * deletion of a non-existent orphan - this is because we don't + * know if ext4_truncate() actually created an orphan record. + * (Well, we could do this if we need to, but heck - it works) + */ + ext4_orphan_del(handle, inode); + EXT4_I(inode)->i_dtime = get_seconds(); + + /* + * One subtle ordering requirement: if anything has gone wrong + * (transaction abort, IO errors, whatever), then we can still + * do these next steps (the fs will already have been marked as + * having errors), but we can't free the inode if the mark_dirty + * fails. + */ + if (ext4_mark_inode_dirty(handle, inode)) + /* If that failed, just do the required in-core inode clear. */ + ext4_clear_inode(inode); + else + ext4_free_inode(handle, inode); + ext4_journal_stop(handle); + sb_end_intwrite(inode->i_sb); + return; +no_delete: + ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ +} +","@@ -3623,6 +3623,15 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) + + } + ++ /* Wait all existing dio workers, newcomers will block on i_mutex */ ++ ext4_inode_block_unlocked_dio(inode); ++ inode_dio_wait(inode); ++ ++ /* ++ * Prevent page faults from reinstantiating pages we have released from ++ * page cache. ++ */ ++ down_write(&EXT4_I(inode)->i_mmap_sem); + first_block_offset = round_up(offset, sb->s_blocksize); + last_block_offset = round_down((offset + length), sb->s_blocksize) - 1; + +@@ -3631,10 +3640,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) + truncate_pagecache_range(inode, first_block_offset, + last_block_offset); + +- /* Wait all existing dio workers, newcomers will block on i_mutex */ +- ext4_inode_block_unlocked_dio(inode); +- inode_dio_wait(inode); +- + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) + credits = ext4_writepage_trans_blocks(inode); + else +@@ -3680,16 +3685,12 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) + if (IS_SYNC(inode)) + ext4_handle_sync(handle); + +- /* Now release the pages again to reduce race window */ +- if (last_block_offset > first_block_offset) +- truncate_pagecache_range(inode, first_block_offset, +- last_block_offset); +- + inode->i_mtime = inode->i_ctime = ext4_current_time(inode); + ext4_mark_inode_dirty(handle, inode); + out_stop: + ext4_journal_stop(handle); + out_dio: ++ up_write(&EXT4_I(inode)->i_mmap_sem); + ext4_inode_resume_unlocked_dio(inode); + out_mutex: + mutex_unlock(&inode->i_mutex); +@@ -4823,13 +4824,15 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) + } else + ext4_wait_for_tail_page_commit(inode); + } ++ down_write(&EXT4_I(inode)->i_mmap_sem); + /* + * Truncate pagecache after we've waited for commit + * in data=journal mode to make pages freeable. + */ + truncate_pagecache(inode, inode->i_size); + if (shrink) + ext4_truncate(inode); ++ up_write(&EXT4_I(inode)->i_mmap_sem); + } + + if (!rc) { +@@ -5278,6 +5281,8 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) + + sb_start_pagefault(inode->i_sb); + file_update_time(vma->vm_file); ++ ++ down_read(&EXT4_I(inode)->i_mmap_sem); + /* Delalloc case is easy... */ + if (test_opt(inode->i_sb, DELALLOC) && + !ext4_should_journal_data(inode) && +@@ -5347,6 +5352,19 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) + out_ret: + ret = block_page_mkwrite_return(ret); + out: ++ up_read(&EXT4_I(inode)->i_mmap_sem); + sb_end_pagefault(inode->i_sb); + return ret; + } ++ ++int ext4_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ++{ ++ struct inode *inode = file_inode(vma->vm_file); ++ int err; ++ ++ down_read(&EXT4_I(inode)->i_mmap_sem); ++ err = filemap_fault(vma, vmf); ++ up_read(&EXT4_I(inode)->i_mmap_sem); ++ ++ return err; ++}",1150,1386,2048 +930,"void vrend_renderer_blit_gl(struct vrend_context *ctx, + struct vrend_resource *src_res, + struct vrend_resource *dst_res, + const struct pipe_blit_info *info) +{ + struct vrend_blitter_ctx *blit_ctx = &vrend_blit_ctx; + GLuint prog_id; + GLuint fs_id; + GLint lret; + GLenum filter; + GLuint pos_loc, tc_loc; + GLuint samp_loc; + bool has_depth, has_stencil; + bool blit_stencil, blit_depth; + int dst_z; + const struct util_format_description *src_desc = + util_format_description(src_res->base.format); + const struct util_format_description *dst_desc = + util_format_description(dst_res->base.format); + + has_depth = util_format_has_depth(src_desc) && + util_format_has_depth(dst_desc); + has_stencil = util_format_has_stencil(src_desc) && + util_format_has_stencil(dst_desc); + + blit_depth = has_depth && (info->mask & PIPE_MASK_Z); + blit_stencil = has_stencil && (info->mask & PIPE_MASK_S) & 0; + + filter = convert_mag_filter(info->filter); + vrend_renderer_init_blit_ctx(blit_ctx); + + blitter_set_dst_dim(blit_ctx, + u_minify(dst_res->base.width0, info->dst.level), + u_minify(dst_res->base.height0, info->dst.level)); + + blitter_set_rectangle(blit_ctx, info->dst.box.x, info->dst.box.y, + info->dst.box.x + info->dst.box.width, + info->dst.box.y + info->dst.box.height, 0); + + + prog_id = glCreateProgram(); + glAttachShader(prog_id, blit_ctx->vs); + + if (blit_depth || blit_stencil) + fs_id = blit_get_frag_tex_writedepth(blit_ctx, src_res->base.target, src_res->base.nr_samples); + else if (vrend_format_is_emulated_alpha(info->dst.format)) + fs_id = blit_get_frag_tex_col_emu_alpha(blit_ctx, src_res->base.target, src_res->base.nr_samples); + else + fs_id = blit_get_frag_tex_col(blit_ctx, src_res->base.target, src_res->base.nr_samples); + glAttachShader(prog_id, fs_id); + + glLinkProgram(prog_id); + glGetProgramiv(prog_id, GL_LINK_STATUS, &lret); + if (lret == GL_FALSE) { + char infolog[65536]; + int len; + glGetProgramInfoLog(prog_id, 65536, &len, infolog); + fprintf(stderr,""got error linking\n%s\n"", infolog); + /* dump shaders */ + glDeleteProgram(prog_id); + return; + } + + glUseProgram(prog_id); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id); + vrend_fb_bind_texture(dst_res, 0, info->dst.level, info->dst.box.z); + + glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + + glBindTexture(src_res->target, src_res->id); + + if (vrend_format_is_emulated_alpha(info->src.format)) + glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_R, GL_ALPHA); + + glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(src_res->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + + glTexParameteri(src_res->target, GL_TEXTURE_BASE_LEVEL, info->src.level); + glTexParameteri(src_res->target, GL_TEXTURE_MAX_LEVEL, info->src.level); + glTexParameterf(src_res->target, GL_TEXTURE_MAG_FILTER, filter); + glTexParameterf(src_res->target, GL_TEXTURE_MIN_FILTER, filter); + pos_loc = glGetAttribLocation(prog_id, ""arg0""); + tc_loc = glGetAttribLocation(prog_id, ""arg1""); + samp_loc = glGetUniformLocation(prog_id, ""samp""); + + glUniform1i(samp_loc, 0); + + glVertexAttribPointer(pos_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)0); + glVertexAttribPointer(tc_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(4 * sizeof(float))); + + glEnableVertexAttribArray(pos_loc); + glEnableVertexAttribArray(tc_loc); + + set_dsa_write_depth_keep_stencil(); + + for (dst_z = 0; dst_z < info->dst.box.depth; dst_z++) { + float dst2src_scale = info->src.box.depth / (float)info->dst.box.depth; + float dst_offset = ((info->src.box.depth - 1) - + (info->dst.box.depth - 1) * dst2src_scale) * 0.5; + float src_z = (dst_z + dst_offset) * dst2src_scale; + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id); + vrend_fb_bind_texture(dst_res, 0, info->dst.level, dst_z); + + glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + blitter_set_texcoords(blit_ctx, src_res, info->src.level, + info->src.box.z + src_z, 0, + info->src.box.x, info->src.box.y, + info->src.box.x + info->src.box.width, + info->src.box.y + info->src.box.height); + + glBufferData(GL_ARRAY_BUFFER, sizeof(blit_ctx->vertices), blit_ctx->vertices, GL_STATIC_DRAW); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + } +} +",0,"void vrend_renderer_blit_gl(struct vrend_context *ctx, + struct vrend_resource *src_res, + struct vrend_resource *dst_res, + const struct pipe_blit_info *info) +{ + struct vrend_blitter_ctx *blit_ctx = &vrend_blit_ctx; + GLuint prog_id; + GLuint fs_id; + GLint lret; + GLenum filter; + GLuint pos_loc, tc_loc; + GLuint samp_loc; + bool has_depth, has_stencil; + bool blit_stencil, blit_depth; + int dst_z; + const struct util_format_description *src_desc = + util_format_description(src_res->base.format); + const struct util_format_description *dst_desc = + util_format_description(dst_res->base.format); + + has_depth = util_format_has_depth(src_desc) && + util_format_has_depth(dst_desc); + has_stencil = util_format_has_stencil(src_desc) && + util_format_has_stencil(dst_desc); + + blit_depth = has_depth && (info->mask & PIPE_MASK_Z); + blit_stencil = has_stencil && (info->mask & PIPE_MASK_S) & 0; + + filter = convert_mag_filter(info->filter); + vrend_renderer_init_blit_ctx(blit_ctx); + + blitter_set_dst_dim(blit_ctx, + u_minify(dst_res->base.width0, info->dst.level), + u_minify(dst_res->base.height0, info->dst.level)); + + blitter_set_rectangle(blit_ctx, info->dst.box.x, info->dst.box.y, + info->dst.box.x + info->dst.box.width, + info->dst.box.y + info->dst.box.height, 0); + + + prog_id = glCreateProgram(); + glAttachShader(prog_id, blit_ctx->vs); + + if (blit_depth || blit_stencil) + fs_id = blit_get_frag_tex_writedepth(blit_ctx, src_res->base.target, src_res->base.nr_samples); + else if (vrend_format_is_emulated_alpha(info->dst.format)) + fs_id = blit_get_frag_tex_col_emu_alpha(blit_ctx, src_res->base.target, src_res->base.nr_samples); + else + fs_id = blit_get_frag_tex_col(blit_ctx, src_res->base.target, src_res->base.nr_samples); + glAttachShader(prog_id, fs_id); + + glLinkProgram(prog_id); + glGetProgramiv(prog_id, GL_LINK_STATUS, &lret); + if (lret == GL_FALSE) { + char infolog[65536]; + int len; + glGetProgramInfoLog(prog_id, 65536, &len, infolog); + fprintf(stderr,""got error linking\n%s\n"", infolog); + /* dump shaders */ + glDeleteProgram(prog_id); + return; + } + + glUseProgram(prog_id); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id); + vrend_fb_bind_texture(dst_res, 0, info->dst.level, info->dst.box.z); + + glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + + glBindTexture(src_res->target, src_res->id); + + if (vrend_format_is_emulated_alpha(info->src.format)) + glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_R, GL_ALPHA); + + glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(src_res->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + + glTexParameteri(src_res->target, GL_TEXTURE_BASE_LEVEL, info->src.level); + glTexParameteri(src_res->target, GL_TEXTURE_MAX_LEVEL, info->src.level); + glTexParameterf(src_res->target, GL_TEXTURE_MAG_FILTER, filter); + glTexParameterf(src_res->target, GL_TEXTURE_MIN_FILTER, filter); + pos_loc = glGetAttribLocation(prog_id, ""arg0""); + tc_loc = glGetAttribLocation(prog_id, ""arg1""); + samp_loc = glGetUniformLocation(prog_id, ""samp""); + + glUniform1i(samp_loc, 0); + + glVertexAttribPointer(pos_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)0); + glVertexAttribPointer(tc_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(4 * sizeof(float))); + + glEnableVertexAttribArray(pos_loc); + glEnableVertexAttribArray(tc_loc); + + set_dsa_write_depth_keep_stencil(); + + for (dst_z = 0; dst_z < info->dst.box.depth; dst_z++) { + float dst2src_scale = info->src.box.depth / (float)info->dst.box.depth; + float dst_offset = ((info->src.box.depth - 1) - + (info->dst.box.depth - 1) * dst2src_scale) * 0.5; + float src_z = (dst_z + dst_offset) * dst2src_scale; + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id); + vrend_fb_bind_texture(dst_res, 0, info->dst.level, dst_z); + + glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + blitter_set_texcoords(blit_ctx, src_res, info->src.level, + info->src.box.z + src_z, 0, + info->src.box.x, info->src.box.y, + info->src.box.x + info->src.box.width, + info->src.box.y + info->src.box.height); + + glBufferData(GL_ARRAY_BUFFER, sizeof(blit_ctx->vertices), blit_ctx->vertices, GL_STATIC_DRAW); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + } +} +","@@ -361,6 +361,7 @@ static void vrend_renderer_init_blit_ctx(struct vrend_blitter_ctx *blit_ctx) + return; + } + ++ blit_ctx->initialised = true; + ctx_params.shared = true; + ctx_params.major_ver = VREND_GL_VER_MAJOR; + ctx_params.minor_ver = VREND_GL_VER_MINOR;",1211,1447,2048 +18808,"void impeg2d_dec_hdr(void *pv_dec,impeg2d_video_decode_ip_t *ps_ip, + impeg2d_video_decode_op_t *ps_op) +{ + + UWORD32 u4_bits_read; + dec_state_t *ps_dec; + UWORD32 u4_size = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + + ps_dec = (dec_state_t *)pv_dec; + ps_op->s_ivd_video_decode_op_t.u4_error_code = 0; + if (u4_size > MAX_BITSTREAM_BUFFER_SIZE) + { + u4_size = MAX_BITSTREAM_BUFFER_SIZE; + } + + memcpy(ps_dec->pu1_input_buffer, ps_ip->s_ivd_video_decode_ip_t.pv_stream_buffer, u4_size); + + impeg2d_bit_stream_init(&(ps_dec->s_bit_stream), ps_dec->pu1_input_buffer, + u4_size); + + { + { + IMPEG2D_ERROR_CODES_T e_error; + e_error = impeg2d_process_video_header(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + ps_op->s_ivd_video_decode_op_t.u4_error_code = e_error; + + u4_bits_read = impeg2d_bit_stream_num_bits_read(&ps_dec->s_bit_stream); + + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = u4_bits_read>> 3; + if(ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed > ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes) + { + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + } + if(ps_op->s_ivd_video_decode_op_t.u4_error_code == 0) + ps_op->s_ivd_video_decode_op_t.u4_error_code = e_error; + + if (IMPEG2D_UNSUPPORTED_DIMENSIONS == e_error) + { + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = 0; + ps_dec->u2_header_done = 0; + + ps_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec->u2_reinit_max_height; + ps_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec->u2_reinit_max_width; + } + impeg2d_next_code(ps_dec, SEQUENCE_HEADER_CODE); + return; + } + } + ps_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec->u2_vertical_size; + ps_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec->u2_horizontal_size; + + ps_op->s_ivd_video_decode_op_t.e_pic_type = IV_NA_FRAME; + ps_op->s_ivd_video_decode_op_t.u4_error_code = IV_SUCCESS; + + u4_bits_read = impeg2d_bit_stream_num_bits_read(&ps_dec->s_bit_stream); + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = u4_bits_read>> 3; + if(ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed > ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes) + { + + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + } + ps_op->s_ivd_video_decode_op_t.u4_frame_decoded_flag = 0; + /* MOD */ + ps_dec->u2_header_done = 1; + + } +} +",1,"void impeg2d_dec_hdr(void *pv_dec,impeg2d_video_decode_ip_t *ps_ip, + impeg2d_video_decode_op_t *ps_op) +{ + + UWORD32 u4_bits_read; + dec_state_t *ps_dec; + UWORD32 u4_size = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + + ps_dec = (dec_state_t *)pv_dec; + ps_op->s_ivd_video_decode_op_t.u4_error_code = 0; + if (u4_size > MAX_BITSTREAM_BUFFER_SIZE) + { + u4_size = MAX_BITSTREAM_BUFFER_SIZE; + } + + memcpy(ps_dec->pu1_input_buffer, ps_ip->s_ivd_video_decode_ip_t.pv_stream_buffer, u4_size); + + impeg2d_bit_stream_init(&(ps_dec->s_bit_stream), ps_dec->pu1_input_buffer, + u4_size); + + { + { + IMPEG2D_ERROR_CODES_T e_error; + e_error = impeg2d_process_video_header(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + ps_op->s_ivd_video_decode_op_t.u4_error_code = e_error; + + u4_bits_read = impeg2d_bit_stream_num_bits_read(&ps_dec->s_bit_stream); + + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = u4_bits_read>> 3; + if(ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed > ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes) + { + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + } + if(ps_op->s_ivd_video_decode_op_t.u4_error_code == 0) + ps_op->s_ivd_video_decode_op_t.u4_error_code = e_error; + + if (IMPEG2D_UNSUPPORTED_DIMENSIONS == e_error) + { + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = 0; + ps_dec->u2_header_done = 0; + + ps_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec->u2_reinit_max_height; + ps_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec->u2_reinit_max_width; + } + impeg2d_next_code(ps_dec, SEQUENCE_HEADER_CODE); + return; + } + } + ps_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec->u2_vertical_size; + ps_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec->u2_horizontal_size; + + ps_op->s_ivd_video_decode_op_t.e_pic_type = IV_NA_FRAME; + ps_op->s_ivd_video_decode_op_t.u4_error_code = IV_SUCCESS; + + u4_bits_read = impeg2d_bit_stream_num_bits_read(&ps_dec->s_bit_stream); + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = u4_bits_read>> 3; + if(ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed > ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes) + { + + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + } + ps_op->s_ivd_video_decode_op_t.u4_frame_decoded_flag = 0; + + /* Set the stride */ + if (0 == ps_dec->u4_frm_buf_stride) + { + ps_dec->u4_frm_buf_stride = ps_dec->u2_horizontal_size; + } + /* MOD */ + ps_dec->u2_header_done = 1; + + } +} +","@@ -155,6 +155,12 @@ + + ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; + } + ps_op->s_ivd_video_decode_op_t.u4_frame_decoded_flag = 0; ++ ++ /* Set the stride */ ++ if (0 == ps_dec->u4_frm_buf_stride) ++ { ++ ps_dec->u4_frm_buf_stride = ps_dec->u2_horizontal_size; ++ } + /* MOD */ + ps_dec->u2_header_done = 1; + +",788,1024,2048 +8896,"compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env) +{ + int i, r, mod_tlen; + int infinite = IS_REPEAT_INFINITE(qn->upper); + enum BodyEmpty empty_info = qn->empty_info; + int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg); + + if (tlen < 0) return tlen; + if (tlen == 0) return 0; + + if (is_anychar_infinite_greedy(qn) && + (qn->lower <= 1 || + int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { + r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env); + if (r != 0) return r; + if (IS_NOT_NULL(qn->next_head_exact)) { + r = add_op(reg, + IS_MULTILINE(CTYPE_OPTION(NODE_QUANT_BODY(qn), reg)) ? + OP_ANYCHAR_ML_STAR_PEEK_NEXT : OP_ANYCHAR_STAR_PEEK_NEXT); + if (r != 0) return r; + + COP(reg)->anychar_star_peek_next.c = STR_(qn->next_head_exact)->s[0]; + return 0; + } + else { + r = add_op(reg, + IS_MULTILINE(CTYPE_OPTION(NODE_QUANT_BODY(qn), reg)) ? + OP_ANYCHAR_ML_STAR : OP_ANYCHAR_STAR); + return r; + } + } + + if (empty_info == BODY_IS_NOT_EMPTY) + mod_tlen = tlen; + else + mod_tlen = tlen + (SIZE_OP_EMPTY_CHECK_START + SIZE_OP_EMPTY_CHECK_END); + + if (infinite && + (qn->lower <= 1 || + int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { + int addr; + + if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) { + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + if (qn->greedy) { +#ifdef USE_OP_PUSH_OR_JUMP_EXACT + if (IS_NOT_NULL(qn->head_exact)) + COP(reg)->jump.addr = SIZE_OP_PUSH_OR_JUMP_EXACT1 + SIZE_INC_OP; + else +#endif + if (IS_NOT_NULL(qn->next_head_exact)) + COP(reg)->jump.addr = SIZE_OP_PUSH_IF_PEEK_NEXT + SIZE_INC_OP; + else + COP(reg)->jump.addr = SIZE_OP_PUSH + SIZE_INC_OP; + } + else { + COP(reg)->jump.addr = SIZE_OP_JUMP + SIZE_INC_OP; + } + } + else { + r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env); + if (r != 0) return r; + } + + if (qn->greedy) { +#ifdef USE_OP_PUSH_OR_JUMP_EXACT + if (IS_NOT_NULL(qn->head_exact)) { + r = add_op(reg, OP_PUSH_OR_JUMP_EXACT1); + if (r != 0) return r; + COP(reg)->push_or_jump_exact1.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP; + COP(reg)->push_or_jump_exact1.c = STR_(qn->head_exact)->s[0]; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + addr = -(mod_tlen + (int )SIZE_OP_PUSH_OR_JUMP_EXACT1); + } + else +#endif + if (IS_NOT_NULL(qn->next_head_exact)) { + r = add_op(reg, OP_PUSH_IF_PEEK_NEXT); + if (r != 0) return r; + COP(reg)->push_if_peek_next.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP; + COP(reg)->push_if_peek_next.c = STR_(qn->next_head_exact)->s[0]; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + addr = -(mod_tlen + (int )SIZE_OP_PUSH_IF_PEEK_NEXT); + } + else { + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + addr = -(mod_tlen + (int )SIZE_OP_PUSH); + } + + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = addr; + } + else { + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = mod_tlen + SIZE_INC_OP; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = -mod_tlen; + } + } + else if (qn->upper == 0) { + if (qn->is_refered != 0) { /* /(?..){0}/ */ + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = tlen + SIZE_INC_OP; + + r = compile_tree(NODE_QUANT_BODY(qn), reg, env); + } + else { + /* Nothing output */ + r = 0; + } + } + else if (! infinite && qn->greedy && + (qn->upper == 1 || + int_multiply_cmp(tlen + SIZE_OP_PUSH, qn->upper, + QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { + int n = qn->upper - qn->lower; + + r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env); + if (r != 0) return r; + + for (i = 0; i < n; i++) { + int v = onig_positive_int_multiply(n - i, tlen + SIZE_OP_PUSH); + if (v < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = v; + + r = compile_tree(NODE_QUANT_BODY(qn), reg, env); + if (r != 0) return r; + } + } + else if (! qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */ + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = SIZE_INC_OP + SIZE_OP_JUMP; + + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = tlen + SIZE_INC_OP; + + r = compile_tree(NODE_QUANT_BODY(qn), reg, env); + } + else { + r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg, env); + } + return r; +} +",0,"compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env) +{ + int i, r, mod_tlen; + int infinite = IS_REPEAT_INFINITE(qn->upper); + enum BodyEmpty empty_info = qn->empty_info; + int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg); + + if (tlen < 0) return tlen; + if (tlen == 0) return 0; + + if (is_anychar_infinite_greedy(qn) && + (qn->lower <= 1 || + int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { + r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env); + if (r != 0) return r; + if (IS_NOT_NULL(qn->next_head_exact)) { + r = add_op(reg, + IS_MULTILINE(CTYPE_OPTION(NODE_QUANT_BODY(qn), reg)) ? + OP_ANYCHAR_ML_STAR_PEEK_NEXT : OP_ANYCHAR_STAR_PEEK_NEXT); + if (r != 0) return r; + + COP(reg)->anychar_star_peek_next.c = STR_(qn->next_head_exact)->s[0]; + return 0; + } + else { + r = add_op(reg, + IS_MULTILINE(CTYPE_OPTION(NODE_QUANT_BODY(qn), reg)) ? + OP_ANYCHAR_ML_STAR : OP_ANYCHAR_STAR); + return r; + } + } + + if (empty_info == BODY_IS_NOT_EMPTY) + mod_tlen = tlen; + else + mod_tlen = tlen + (SIZE_OP_EMPTY_CHECK_START + SIZE_OP_EMPTY_CHECK_END); + + if (infinite && + (qn->lower <= 1 || + int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { + int addr; + + if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) { + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + if (qn->greedy) { +#ifdef USE_OP_PUSH_OR_JUMP_EXACT + if (IS_NOT_NULL(qn->head_exact)) + COP(reg)->jump.addr = SIZE_OP_PUSH_OR_JUMP_EXACT1 + SIZE_INC_OP; + else +#endif + if (IS_NOT_NULL(qn->next_head_exact)) + COP(reg)->jump.addr = SIZE_OP_PUSH_IF_PEEK_NEXT + SIZE_INC_OP; + else + COP(reg)->jump.addr = SIZE_OP_PUSH + SIZE_INC_OP; + } + else { + COP(reg)->jump.addr = SIZE_OP_JUMP + SIZE_INC_OP; + } + } + else { + r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env); + if (r != 0) return r; + } + + if (qn->greedy) { +#ifdef USE_OP_PUSH_OR_JUMP_EXACT + if (IS_NOT_NULL(qn->head_exact)) { + r = add_op(reg, OP_PUSH_OR_JUMP_EXACT1); + if (r != 0) return r; + COP(reg)->push_or_jump_exact1.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP; + COP(reg)->push_or_jump_exact1.c = STR_(qn->head_exact)->s[0]; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + addr = -(mod_tlen + (int )SIZE_OP_PUSH_OR_JUMP_EXACT1); + } + else +#endif + if (IS_NOT_NULL(qn->next_head_exact)) { + r = add_op(reg, OP_PUSH_IF_PEEK_NEXT); + if (r != 0) return r; + COP(reg)->push_if_peek_next.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP; + COP(reg)->push_if_peek_next.c = STR_(qn->next_head_exact)->s[0]; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + addr = -(mod_tlen + (int )SIZE_OP_PUSH_IF_PEEK_NEXT); + } + else { + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + addr = -(mod_tlen + (int )SIZE_OP_PUSH); + } + + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = addr; + } + else { + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = mod_tlen + SIZE_INC_OP; + + r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env); + if (r != 0) return r; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = -mod_tlen; + } + } + else if (qn->upper == 0) { + if (qn->is_refered != 0) { /* /(?..){0}/ */ + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = tlen + SIZE_INC_OP; + + r = compile_tree(NODE_QUANT_BODY(qn), reg, env); + } + else { + /* Nothing output */ + r = 0; + } + } + else if (! infinite && qn->greedy && + (qn->upper == 1 || + int_multiply_cmp(tlen + SIZE_OP_PUSH, qn->upper, + QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { + int n = qn->upper - qn->lower; + + r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env); + if (r != 0) return r; + + for (i = 0; i < n; i++) { + int v = onig_positive_int_multiply(n - i, tlen + SIZE_OP_PUSH); + if (v < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = v; + + r = compile_tree(NODE_QUANT_BODY(qn), reg, env); + if (r != 0) return r; + } + } + else if (! qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */ + r = add_op(reg, OP_PUSH); + if (r != 0) return r; + COP(reg)->push.addr = SIZE_INC_OP + SIZE_OP_JUMP; + + r = add_op(reg, OP_JUMP); + if (r != 0) return r; + COP(reg)->jump.addr = tlen + SIZE_INC_OP; + + r = compile_tree(NODE_QUANT_BODY(qn), reg, env); + } + else { + r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg, env); + } + return r; +} +","@@ -1307,8 +1307,9 @@ compile_length_bag_node(BagNode* node, regex_t* reg) + len += tlen; + } + ++ len += SIZE_OP_JUMP + SIZE_OP_ATOMIC_END; ++ + if (IS_NOT_NULL(Else)) { +- len += SIZE_OP_JUMP; + tlen = compile_length_tree(Else, reg); + if (tlen < 0) return tlen; + len += tlen; +@@ -1455,7 +1456,7 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + + case BAG_IF_ELSE: + { +- int cond_len, then_len, jump_len; ++ int cond_len, then_len, else_len, jump_len; + Node* cond = NODE_BAG_BODY(node); + Node* Then = node->te.Then; + Node* Else = node->te.Else; +@@ -1472,8 +1473,7 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + else + then_len = 0; + +- jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END; +- if (IS_NOT_NULL(Else)) jump_len += SIZE_OP_JUMP; ++ jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END + SIZE_OP_JUMP; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; +@@ -1490,11 +1490,20 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + } + + if (IS_NOT_NULL(Else)) { +- int else_len = compile_length_tree(Else, reg); +- r = add_op(reg, OP_JUMP); +- if (r != 0) return r; +- COP(reg)->jump.addr = else_len + SIZE_INC_OP; ++ else_len = compile_length_tree(Else, reg); ++ if (else_len < 0) return else_len; ++ } ++ else ++ else_len = 0; + ++ r = add_op(reg, OP_JUMP); ++ if (r != 0) return r; ++ COP(reg)->jump.addr = SIZE_OP_ATOMIC_END + else_len + SIZE_INC_OP; ++ ++ r = add_op(reg, OP_ATOMIC_END); ++ if (r != 0) return r; ++ ++ if (IS_NOT_NULL(Else)) { + r = compile_tree(Else, reg, env); + } + }",1648,1884,2048 +4226,"int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, + const struct in6_addr *daddr, unsigned int prefs, + struct in6_addr *saddr) +{ + struct ipv6_saddr_score scores[2], + *score = &scores[0], *hiscore = &scores[1]; + struct ipv6_saddr_dst dst; + struct net_device *dev; + int dst_type; + + dst_type = __ipv6_addr_type(daddr); + dst.addr = daddr; + dst.ifindex = dst_dev ? dst_dev->ifindex : 0; + dst.scope = __ipv6_addr_src_scope(dst_type); + dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex); + dst.prefs = prefs; + + hiscore->rule = -1; + hiscore->ifa = NULL; + + rcu_read_lock(); + + for_each_netdev_rcu(net, dev) { + struct inet6_dev *idev; + + /* Candidate Source Address (section 4) + * - multicast and link-local destination address, + * the set of candidate source address MUST only + * include addresses assigned to interfaces + * belonging to the same link as the outgoing + * interface. + * (- For site-local destination addresses, the + * set of candidate source addresses MUST only + * include addresses assigned to interfaces + * belonging to the same site as the outgoing + * interface.) + */ + if (((dst_type & IPV6_ADDR_MULTICAST) || + dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) && + dst.ifindex && dev->ifindex != dst.ifindex) + continue; + + idev = __in6_dev_get(dev); + if (!idev) + continue; + + read_lock_bh(&idev->lock); + list_for_each_entry(score->ifa, &idev->addr_list, if_list) { + int i; + + /* + * - Tentative Address (RFC2462 section 5.4) + * - A tentative address is not considered + * ""assigned to an interface"" in the traditional + * sense, unless it is also flagged as optimistic. + * - Candidate Source Address (section 4) + * - In any case, anycast addresses, multicast + * addresses, and the unspecified address MUST + * NOT be included in a candidate set. + */ + if ((score->ifa->flags & IFA_F_TENTATIVE) && + (!(score->ifa->flags & IFA_F_OPTIMISTIC))) + continue; + + score->addr_type = __ipv6_addr_type(&score->ifa->addr); + + if (unlikely(score->addr_type == IPV6_ADDR_ANY || + score->addr_type & IPV6_ADDR_MULTICAST)) { + net_dbg_ratelimited(""ADDRCONF: unspecified / multicast address assigned as unicast address on %s"", + dev->name); + continue; + } + + score->rule = -1; + bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX); + + for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) { + int minihiscore, miniscore; + + minihiscore = ipv6_get_saddr_eval(net, hiscore, &dst, i); + miniscore = ipv6_get_saddr_eval(net, score, &dst, i); + + if (minihiscore > miniscore) { + if (i == IPV6_SADDR_RULE_SCOPE && + score->scopedist > 0) { + /* + * special case: + * each remaining entry + * has too small (not enough) + * scope, because ifa entries + * are sorted by their scope + * values. + */ + goto try_nextdev; + } + break; + } else if (minihiscore < miniscore) { + if (hiscore->ifa) + in6_ifa_put(hiscore->ifa); + + in6_ifa_hold(score->ifa); + + swap(hiscore, score); + + /* restore our iterator */ + score->ifa = hiscore->ifa; + + break; + } + } + } +try_nextdev: + read_unlock_bh(&idev->lock); + } + rcu_read_unlock(); + + if (!hiscore->ifa) + return -EADDRNOTAVAIL; + + *saddr = hiscore->ifa->addr; + in6_ifa_put(hiscore->ifa); + return 0; +} +",0,"int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, + const struct in6_addr *daddr, unsigned int prefs, + struct in6_addr *saddr) +{ + struct ipv6_saddr_score scores[2], + *score = &scores[0], *hiscore = &scores[1]; + struct ipv6_saddr_dst dst; + struct net_device *dev; + int dst_type; + + dst_type = __ipv6_addr_type(daddr); + dst.addr = daddr; + dst.ifindex = dst_dev ? dst_dev->ifindex : 0; + dst.scope = __ipv6_addr_src_scope(dst_type); + dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex); + dst.prefs = prefs; + + hiscore->rule = -1; + hiscore->ifa = NULL; + + rcu_read_lock(); + + for_each_netdev_rcu(net, dev) { + struct inet6_dev *idev; + + /* Candidate Source Address (section 4) + * - multicast and link-local destination address, + * the set of candidate source address MUST only + * include addresses assigned to interfaces + * belonging to the same link as the outgoing + * interface. + * (- For site-local destination addresses, the + * set of candidate source addresses MUST only + * include addresses assigned to interfaces + * belonging to the same site as the outgoing + * interface.) + */ + if (((dst_type & IPV6_ADDR_MULTICAST) || + dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) && + dst.ifindex && dev->ifindex != dst.ifindex) + continue; + + idev = __in6_dev_get(dev); + if (!idev) + continue; + + read_lock_bh(&idev->lock); + list_for_each_entry(score->ifa, &idev->addr_list, if_list) { + int i; + + /* + * - Tentative Address (RFC2462 section 5.4) + * - A tentative address is not considered + * ""assigned to an interface"" in the traditional + * sense, unless it is also flagged as optimistic. + * - Candidate Source Address (section 4) + * - In any case, anycast addresses, multicast + * addresses, and the unspecified address MUST + * NOT be included in a candidate set. + */ + if ((score->ifa->flags & IFA_F_TENTATIVE) && + (!(score->ifa->flags & IFA_F_OPTIMISTIC))) + continue; + + score->addr_type = __ipv6_addr_type(&score->ifa->addr); + + if (unlikely(score->addr_type == IPV6_ADDR_ANY || + score->addr_type & IPV6_ADDR_MULTICAST)) { + net_dbg_ratelimited(""ADDRCONF: unspecified / multicast address assigned as unicast address on %s"", + dev->name); + continue; + } + + score->rule = -1; + bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX); + + for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) { + int minihiscore, miniscore; + + minihiscore = ipv6_get_saddr_eval(net, hiscore, &dst, i); + miniscore = ipv6_get_saddr_eval(net, score, &dst, i); + + if (minihiscore > miniscore) { + if (i == IPV6_SADDR_RULE_SCOPE && + score->scopedist > 0) { + /* + * special case: + * each remaining entry + * has too small (not enough) + * scope, because ifa entries + * are sorted by their scope + * values. + */ + goto try_nextdev; + } + break; + } else if (minihiscore < miniscore) { + if (hiscore->ifa) + in6_ifa_put(hiscore->ifa); + + in6_ifa_hold(score->ifa); + + swap(hiscore, score); + + /* restore our iterator */ + score->ifa = hiscore->ifa; + + break; + } + } + } +try_nextdev: + read_unlock_bh(&idev->lock); + } + rcu_read_unlock(); + + if (!hiscore->ifa) + return -EADDRNOTAVAIL; + + *saddr = hiscore->ifa->addr; + in6_ifa_put(hiscore->ifa); + return 0; +} +","@@ -4903,6 +4903,21 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write, + return ret; + } + ++static ++int addrconf_sysctl_mtu(struct ctl_table *ctl, int write, ++ void __user *buffer, size_t *lenp, loff_t *ppos) ++{ ++ struct inet6_dev *idev = ctl->extra1; ++ int min_mtu = IPV6_MIN_MTU; ++ struct ctl_table lctl; ++ ++ lctl = *ctl; ++ lctl.extra1 = &min_mtu; ++ lctl.extra2 = idev ? &idev->dev->mtu : NULL; ++ ++ return proc_dointvec_minmax(&lctl, write, buffer, lenp, ppos); ++} ++ + static void dev_disable_change(struct inet6_dev *idev) + { + struct netdev_notifier_info info; +@@ -5054,7 +5069,7 @@ static struct addrconf_sysctl_table + .data = &ipv6_devconf.mtu6, + .maxlen = sizeof(int), + .mode = 0644, +- .proc_handler = proc_dointvec, ++ .proc_handler = addrconf_sysctl_mtu, + }, + { + .procname = ""accept_ra"",",968,1204,2048 +17797,"void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + int srcWidth, int srcHeight, + SplashCoord *mat, GBool glyphMode) { + SplashBitmap *scaledMask; + SplashClipResult clipRes, clipRes2; + SplashPipe pipe; + int scaledWidth, scaledHeight, t0, t1; + SplashCoord r00, r01, r10, r11, det, ir00, ir01, ir10, ir11; + SplashCoord vx[4], vy[4]; + int xMin, yMin, xMax, yMax; + ImageSection section[3]; + int nSections; + int y, xa, xb, x, i, xx, yy; + + vx[0] = mat[4]; vy[0] = mat[5]; + vx[1] = mat[2] + mat[4]; vy[1] = mat[3] + mat[5]; + vx[2] = mat[0] + mat[2] + mat[4]; vy[2] = mat[1] + mat[3] + mat[5]; + vx[3] = mat[0] + mat[4]; vy[3] = mat[1] + mat[5]; + + xMin = imgCoordMungeLowerC(vx[0], glyphMode); + xMax = imgCoordMungeUpperC(vx[0], glyphMode); + yMin = imgCoordMungeLowerC(vy[0], glyphMode); + yMax = imgCoordMungeUpperC(vy[0], glyphMode); + for (i = 1; i < 4; ++i) { + t0 = imgCoordMungeLowerC(vx[i], glyphMode); + if (t0 < xMin) { + xMin = t0; + } + t0 = imgCoordMungeUpperC(vx[i], glyphMode); + if (t0 > xMax) { + xMax = t0; + } + t1 = imgCoordMungeLowerC(vy[i], glyphMode); + if (t1 < yMin) { + yMin = t1; + } + t1 = imgCoordMungeUpperC(vy[i], glyphMode); + if (t1 > yMax) { + yMax = t1; + } + } + clipRes = state->clip->testRect(xMin, yMin, xMax - 1, yMax - 1); + opClipRes = clipRes; + if (clipRes == splashClipAllOutside) { + return; + } + + if (mat[0] >= 0) { + t0 = imgCoordMungeUpperC(mat[0] + mat[4], glyphMode) - + imgCoordMungeLowerC(mat[4], glyphMode); + } else { + t0 = imgCoordMungeUpperC(mat[4], glyphMode) - + imgCoordMungeLowerC(mat[0] + mat[4], glyphMode); + } + if (mat[1] >= 0) { + t1 = imgCoordMungeUpperC(mat[1] + mat[5], glyphMode) - + imgCoordMungeLowerC(mat[5], glyphMode); + } else { + t1 = imgCoordMungeUpperC(mat[5], glyphMode) - + imgCoordMungeLowerC(mat[1] + mat[5], glyphMode); + } + scaledWidth = t0 > t1 ? t0 : t1; + if (mat[2] >= 0) { + t0 = imgCoordMungeUpperC(mat[2] + mat[4], glyphMode) - + imgCoordMungeLowerC(mat[4], glyphMode); + } else { + t0 = imgCoordMungeUpperC(mat[4], glyphMode) - + imgCoordMungeLowerC(mat[2] + mat[4], glyphMode); + } + if (mat[3] >= 0) { + t1 = imgCoordMungeUpperC(mat[3] + mat[5], glyphMode) - + imgCoordMungeLowerC(mat[5], glyphMode); + } else { + t1 = imgCoordMungeUpperC(mat[5], glyphMode) - + imgCoordMungeLowerC(mat[3] + mat[5], glyphMode); + } + scaledHeight = t0 > t1 ? t0 : t1; + if (scaledWidth == 0) { + scaledWidth = 1; + } + if (scaledHeight == 0) { + scaledHeight = 1; + } + + r00 = mat[0] / scaledWidth; + r01 = mat[1] / scaledWidth; + r10 = mat[2] / scaledHeight; + r11 = mat[3] / scaledHeight; + det = r00 * r11 - r01 * r10; + if (splashAbs(det) < 1e-6) { + return; + } + ir00 = r11 / det; + ir01 = -r01 / det; + ir10 = -r10 / det; + ir11 = r00 / det; + + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); + + i = (vy[2] <= vy[3]) ? 2 : 3; + } +",1,"void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + int srcWidth, int srcHeight, + SplashCoord *mat, GBool glyphMode) { + SplashBitmap *scaledMask; + SplashClipResult clipRes, clipRes2; + SplashPipe pipe; + int scaledWidth, scaledHeight, t0, t1; + SplashCoord r00, r01, r10, r11, det, ir00, ir01, ir10, ir11; + SplashCoord vx[4], vy[4]; + int xMin, yMin, xMax, yMax; + ImageSection section[3]; + int nSections; + int y, xa, xb, x, i, xx, yy; + + vx[0] = mat[4]; vy[0] = mat[5]; + vx[1] = mat[2] + mat[4]; vy[1] = mat[3] + mat[5]; + vx[2] = mat[0] + mat[2] + mat[4]; vy[2] = mat[1] + mat[3] + mat[5]; + vx[3] = mat[0] + mat[4]; vy[3] = mat[1] + mat[5]; + + xMin = imgCoordMungeLowerC(vx[0], glyphMode); + xMax = imgCoordMungeUpperC(vx[0], glyphMode); + yMin = imgCoordMungeLowerC(vy[0], glyphMode); + yMax = imgCoordMungeUpperC(vy[0], glyphMode); + for (i = 1; i < 4; ++i) { + t0 = imgCoordMungeLowerC(vx[i], glyphMode); + if (t0 < xMin) { + xMin = t0; + } + t0 = imgCoordMungeUpperC(vx[i], glyphMode); + if (t0 > xMax) { + xMax = t0; + } + t1 = imgCoordMungeLowerC(vy[i], glyphMode); + if (t1 < yMin) { + yMin = t1; + } + t1 = imgCoordMungeUpperC(vy[i], glyphMode); + if (t1 > yMax) { + yMax = t1; + } + } + clipRes = state->clip->testRect(xMin, yMin, xMax - 1, yMax - 1); + opClipRes = clipRes; + if (clipRes == splashClipAllOutside) { + return; + } + + if (mat[0] >= 0) { + t0 = imgCoordMungeUpperC(mat[0] + mat[4], glyphMode) - + imgCoordMungeLowerC(mat[4], glyphMode); + } else { + t0 = imgCoordMungeUpperC(mat[4], glyphMode) - + imgCoordMungeLowerC(mat[0] + mat[4], glyphMode); + } + if (mat[1] >= 0) { + t1 = imgCoordMungeUpperC(mat[1] + mat[5], glyphMode) - + imgCoordMungeLowerC(mat[5], glyphMode); + } else { + t1 = imgCoordMungeUpperC(mat[5], glyphMode) - + imgCoordMungeLowerC(mat[1] + mat[5], glyphMode); + } + scaledWidth = t0 > t1 ? t0 : t1; + if (mat[2] >= 0) { + t0 = imgCoordMungeUpperC(mat[2] + mat[4], glyphMode) - + imgCoordMungeLowerC(mat[4], glyphMode); + } else { + t0 = imgCoordMungeUpperC(mat[4], glyphMode) - + imgCoordMungeLowerC(mat[2] + mat[4], glyphMode); + } + if (mat[3] >= 0) { + t1 = imgCoordMungeUpperC(mat[3] + mat[5], glyphMode) - + imgCoordMungeLowerC(mat[5], glyphMode); + } else { + t1 = imgCoordMungeUpperC(mat[5], glyphMode) - + imgCoordMungeLowerC(mat[3] + mat[5], glyphMode); + } + scaledHeight = t0 > t1 ? t0 : t1; + if (scaledWidth == 0) { + scaledWidth = 1; + } + if (scaledHeight == 0) { + scaledHeight = 1; + } + + r00 = mat[0] / scaledWidth; + r01 = mat[1] / scaledWidth; + r10 = mat[2] / scaledHeight; + r11 = mat[3] / scaledHeight; + det = r00 * r11 - r01 * r10; + if (splashAbs(det) < 1e-6) { + return; + } + ir00 = r11 / det; + ir01 = -r01 / det; + ir10 = -r10 / det; + ir11 = r00 / det; + + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); + if (scaledMask->data == NULL) { + error(errInternal, -1, ""scaledMask->data is NULL in Splash::scaleMaskYuXu""); + delete scaledMask; + return; + } + + i = (vy[2] <= vy[3]) ? 2 : 3; + } +","@@ -2954,6 +2954,11 @@ void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, + // scale the input image + scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, + scaledWidth, scaledHeight); ++ if (scaledMask->data == NULL) { ++ error(errInternal, -1, ""scaledMask->data is NULL in Splash::scaleMaskYuXu""); ++ delete scaledMask; ++ return; ++ } + + // construct the three sections + i = (vy[2] <= vy[3]) ? 2 : 3; +@@ -3381,6 +3386,12 @@ void Splash::scaleMaskYuXu(SplashImageMaskSource src, void *srcData, + int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx; + int i, j; + ++ destPtr0 = dest->data; ++ if (destPtr0 == NULL) { ++ error(errInternal, -1, ""dest->data is NULL in Splash::scaleMaskYuXu""); ++ return; ++ } ++ + // Bresenham parameters for y scale + yp = scaledHeight / srcHeight; + yq = scaledHeight % srcHeight; +@@ -3395,7 +3406,6 @@ void Splash::scaleMaskYuXu(SplashImageMaskSource src, void *srcData, + // init y scale Bresenham + yt = 0; + +- destPtr0 = dest->data; + for (y = 0; y < srcHeight; ++y) { + + // y scale Bresenham",1197,1433,2048 +6234,"ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len, + const u_char *ep _U_, uint32_t phase, uint32_t doi _U_, + uint32_t proto _U_, int depth _U_) +{ +#define USE_IPSECDOI_IN_PHASE1 1 + const struct ikev1_pl_id *p; + struct ikev1_pl_id id; + static const char *idtypestr[] = { + ""IPv4"", ""IPv4net"", ""IPv6"", ""IPv6net"", + }; + static const char *ipsecidtypestr[] = { + NULL, ""IPv4"", ""FQDN"", ""user FQDN"", ""IPv4net"", ""IPv6"", + ""IPv6net"", ""IPv4range"", ""IPv6range"", ""ASN1 DN"", ""ASN1 GN"", + ""keyid"", + }; + int len; + const u_char *data; + + ND_PRINT((ndo,""%s:"", NPSTR(ISAKMP_NPTYPE_ID))); + + p = (const struct ikev1_pl_id *)ext; + ND_TCHECK(*p); + UNALIGNED_MEMCPY(&id, ext, sizeof(id)); + if (sizeof(*p) < item_len) { + data = (const u_char *)(p + 1); + len = item_len - sizeof(*p); + } else { + data = NULL; + len = 0; + } + +#if 0 /*debug*/ + ND_PRINT((ndo,"" [phase=%d doi=%d proto=%d]"", phase, doi, proto)); +#endif + switch (phase) { +#ifndef USE_IPSECDOI_IN_PHASE1 + case 1: +#endif + default: + ND_PRINT((ndo,"" idtype=%s"", STR_OR_ID(id.d.id_type, idtypestr))); + ND_PRINT((ndo,"" doi_data=%u"", + (uint32_t)(ntohl(id.d.doi_data) & 0xffffff))); + break; + +#ifdef USE_IPSECDOI_IN_PHASE1 + case 1: +#endif + case 2: + { + const struct ipsecdoi_id *doi_p; + struct ipsecdoi_id doi_id; + const char *p_name; + + doi_p = (const struct ipsecdoi_id *)ext; + ND_TCHECK(*doi_p); + UNALIGNED_MEMCPY(&doi_id, ext, sizeof(doi_id)); + ND_PRINT((ndo,"" idtype=%s"", STR_OR_ID(doi_id.type, ipsecidtypestr))); + /* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */ + if (!ndo->ndo_nflag && doi_id.proto_id && (p_name = netdb_protoname(doi_id.proto_id)) != NULL) + ND_PRINT((ndo,"" protoid=%s"", p_name)); + else + ND_PRINT((ndo,"" protoid=%u"", doi_id.proto_id)); + ND_PRINT((ndo,"" port=%d"", ntohs(doi_id.port))); + if (!len) + break; + if (data == NULL) + goto trunc; + ND_TCHECK2(*data, len); + switch (doi_id.type) { + case IPSECDOI_ID_IPV4_ADDR: + if (len < 4) + ND_PRINT((ndo,"" len=%d [bad: < 4]"", len)); + else + ND_PRINT((ndo,"" len=%d %s"", len, ipaddr_string(ndo, data))); + len = 0; + break; + case IPSECDOI_ID_FQDN: + case IPSECDOI_ID_USER_FQDN: + { + int i; + ND_PRINT((ndo,"" len=%d "", len)); + for (i = 0; i < len; i++) + safeputchar(ndo, data[i]); + len = 0; + break; + } + case IPSECDOI_ID_IPV4_ADDR_SUBNET: + { + const u_char *mask; + if (len < 8) + ND_PRINT((ndo,"" len=%d [bad: < 8]"", len)); + else { + mask = data + sizeof(struct in_addr); + ND_PRINT((ndo,"" len=%d %s/%u.%u.%u.%u"", len, + ipaddr_string(ndo, data), + mask[0], mask[1], mask[2], mask[3])); + } + len = 0; + break; + } + case IPSECDOI_ID_IPV6_ADDR: + if (len < 16) + ND_PRINT((ndo,"" len=%d [bad: < 16]"", len)); + else + ND_PRINT((ndo,"" len=%d %s"", len, ip6addr_string(ndo, data))); + len = 0; + break; + case IPSECDOI_ID_IPV6_ADDR_SUBNET: + { + const u_char *mask; + if (len < 20) + ND_PRINT((ndo,"" len=%d [bad: < 20]"", len)); + else { + mask = (const u_char *)(data + sizeof(struct in6_addr)); + /*XXX*/ + ND_PRINT((ndo,"" len=%d %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"", len, + ip6addr_string(ndo, data), + mask[0], mask[1], mask[2], mask[3], + mask[4], mask[5], mask[6], mask[7], + mask[8], mask[9], mask[10], mask[11], + mask[12], mask[13], mask[14], mask[15])); + } + len = 0; + break; + } + case IPSECDOI_ID_IPV4_ADDR_RANGE: + if (len < 8) + ND_PRINT((ndo,"" len=%d [bad: < 8]"", len)); + else { + ND_PRINT((ndo,"" len=%d %s-%s"", len, + ipaddr_string(ndo, data), + ipaddr_string(ndo, data + sizeof(struct in_addr)))); + } + len = 0; + break; + case IPSECDOI_ID_IPV6_ADDR_RANGE: + if (len < 32) + ND_PRINT((ndo,"" len=%d [bad: < 32]"", len)); + else { + ND_PRINT((ndo,"" len=%d %s-%s"", len, + ip6addr_string(ndo, data), + ip6addr_string(ndo, data + sizeof(struct in6_addr)))); + } + len = 0; + break; + case IPSECDOI_ID_DER_ASN1_DN: + case IPSECDOI_ID_DER_ASN1_GN: + case IPSECDOI_ID_KEY_ID: + break; + } + break; + } + } + if (data && len) { + ND_PRINT((ndo,"" len=%d"", len)); + if (2 < ndo->ndo_vflag) { + ND_PRINT((ndo,"" "")); + if (!rawprint(ndo, (const uint8_t *)data, len)) + goto trunc; + } + } + return (const u_char *)ext + item_len; +trunc: + ND_PRINT((ndo,"" [|%s]"", NPSTR(ISAKMP_NPTYPE_ID))); + return NULL; +} +",0,"ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len, + const u_char *ep _U_, uint32_t phase, uint32_t doi _U_, + uint32_t proto _U_, int depth _U_) +{ +#define USE_IPSECDOI_IN_PHASE1 1 + const struct ikev1_pl_id *p; + struct ikev1_pl_id id; + static const char *idtypestr[] = { + ""IPv4"", ""IPv4net"", ""IPv6"", ""IPv6net"", + }; + static const char *ipsecidtypestr[] = { + NULL, ""IPv4"", ""FQDN"", ""user FQDN"", ""IPv4net"", ""IPv6"", + ""IPv6net"", ""IPv4range"", ""IPv6range"", ""ASN1 DN"", ""ASN1 GN"", + ""keyid"", + }; + int len; + const u_char *data; + + ND_PRINT((ndo,""%s:"", NPSTR(ISAKMP_NPTYPE_ID))); + + p = (const struct ikev1_pl_id *)ext; + ND_TCHECK(*p); + UNALIGNED_MEMCPY(&id, ext, sizeof(id)); + if (sizeof(*p) < item_len) { + data = (const u_char *)(p + 1); + len = item_len - sizeof(*p); + } else { + data = NULL; + len = 0; + } + +#if 0 /*debug*/ + ND_PRINT((ndo,"" [phase=%d doi=%d proto=%d]"", phase, doi, proto)); +#endif + switch (phase) { +#ifndef USE_IPSECDOI_IN_PHASE1 + case 1: +#endif + default: + ND_PRINT((ndo,"" idtype=%s"", STR_OR_ID(id.d.id_type, idtypestr))); + ND_PRINT((ndo,"" doi_data=%u"", + (uint32_t)(ntohl(id.d.doi_data) & 0xffffff))); + break; + +#ifdef USE_IPSECDOI_IN_PHASE1 + case 1: +#endif + case 2: + { + const struct ipsecdoi_id *doi_p; + struct ipsecdoi_id doi_id; + const char *p_name; + + doi_p = (const struct ipsecdoi_id *)ext; + ND_TCHECK(*doi_p); + UNALIGNED_MEMCPY(&doi_id, ext, sizeof(doi_id)); + ND_PRINT((ndo,"" idtype=%s"", STR_OR_ID(doi_id.type, ipsecidtypestr))); + /* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */ + if (!ndo->ndo_nflag && doi_id.proto_id && (p_name = netdb_protoname(doi_id.proto_id)) != NULL) + ND_PRINT((ndo,"" protoid=%s"", p_name)); + else + ND_PRINT((ndo,"" protoid=%u"", doi_id.proto_id)); + ND_PRINT((ndo,"" port=%d"", ntohs(doi_id.port))); + if (!len) + break; + if (data == NULL) + goto trunc; + ND_TCHECK2(*data, len); + switch (doi_id.type) { + case IPSECDOI_ID_IPV4_ADDR: + if (len < 4) + ND_PRINT((ndo,"" len=%d [bad: < 4]"", len)); + else + ND_PRINT((ndo,"" len=%d %s"", len, ipaddr_string(ndo, data))); + len = 0; + break; + case IPSECDOI_ID_FQDN: + case IPSECDOI_ID_USER_FQDN: + { + int i; + ND_PRINT((ndo,"" len=%d "", len)); + for (i = 0; i < len; i++) + safeputchar(ndo, data[i]); + len = 0; + break; + } + case IPSECDOI_ID_IPV4_ADDR_SUBNET: + { + const u_char *mask; + if (len < 8) + ND_PRINT((ndo,"" len=%d [bad: < 8]"", len)); + else { + mask = data + sizeof(struct in_addr); + ND_PRINT((ndo,"" len=%d %s/%u.%u.%u.%u"", len, + ipaddr_string(ndo, data), + mask[0], mask[1], mask[2], mask[3])); + } + len = 0; + break; + } + case IPSECDOI_ID_IPV6_ADDR: + if (len < 16) + ND_PRINT((ndo,"" len=%d [bad: < 16]"", len)); + else + ND_PRINT((ndo,"" len=%d %s"", len, ip6addr_string(ndo, data))); + len = 0; + break; + case IPSECDOI_ID_IPV6_ADDR_SUBNET: + { + const u_char *mask; + if (len < 20) + ND_PRINT((ndo,"" len=%d [bad: < 20]"", len)); + else { + mask = (const u_char *)(data + sizeof(struct in6_addr)); + /*XXX*/ + ND_PRINT((ndo,"" len=%d %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"", len, + ip6addr_string(ndo, data), + mask[0], mask[1], mask[2], mask[3], + mask[4], mask[5], mask[6], mask[7], + mask[8], mask[9], mask[10], mask[11], + mask[12], mask[13], mask[14], mask[15])); + } + len = 0; + break; + } + case IPSECDOI_ID_IPV4_ADDR_RANGE: + if (len < 8) + ND_PRINT((ndo,"" len=%d [bad: < 8]"", len)); + else { + ND_PRINT((ndo,"" len=%d %s-%s"", len, + ipaddr_string(ndo, data), + ipaddr_string(ndo, data + sizeof(struct in_addr)))); + } + len = 0; + break; + case IPSECDOI_ID_IPV6_ADDR_RANGE: + if (len < 32) + ND_PRINT((ndo,"" len=%d [bad: < 32]"", len)); + else { + ND_PRINT((ndo,"" len=%d %s-%s"", len, + ip6addr_string(ndo, data), + ip6addr_string(ndo, data + sizeof(struct in6_addr)))); + } + len = 0; + break; + case IPSECDOI_ID_DER_ASN1_DN: + case IPSECDOI_ID_DER_ASN1_GN: + case IPSECDOI_ID_KEY_ID: + break; + } + break; + } + } + if (data && len) { + ND_PRINT((ndo,"" len=%d"", len)); + if (2 < ndo->ndo_vflag) { + ND_PRINT((ndo,"" "")); + if (!rawprint(ndo, (const uint8_t *)data, len)) + goto trunc; + } + } + return (const u_char *)ext + item_len; +trunc: + ND_PRINT((ndo,"" [|%s]"", NPSTR(ISAKMP_NPTYPE_ID))); + return NULL; +} +","@@ -912,21 +912,25 @@ struct attrmap { + + static const u_char * + ikev1_attrmap_print(netdissect_options *ndo, +- const u_char *p, const u_char *ep, ++ const u_char *p, const u_char *ep2, + const struct attrmap *map, size_t nmap) + { + int totlen; + uint32_t t, v; + ++ ND_TCHECK(p[0]); + if (p[0] & 0x80) + totlen = 4; +- else ++ else { ++ ND_TCHECK_16BITS(&p[2]); + totlen = 4 + EXTRACT_16BITS(&p[2]); +- if (ep < p + totlen) { ++ } ++ if (ep2 < p + totlen) { + ND_PRINT((ndo,""[|attr]"")); +- return ep + 1; ++ return ep2 + 1; + } + ++ ND_TCHECK_16BITS(&p[0]); + ND_PRINT((ndo,""("")); + t = EXTRACT_16BITS(&p[0]) & 0x7fff; + if (map && t < nmap && map[t].type) +@@ -935,47 +939,71 @@ ikev1_attrmap_print(netdissect_options *ndo, + ND_PRINT((ndo,""type=#%d "", t)); + if (p[0] & 0x80) { + ND_PRINT((ndo,""value="")); ++ ND_TCHECK_16BITS(&p[2]); + v = EXTRACT_16BITS(&p[2]); + if (map && t < nmap && v < map[t].nvalue && map[t].value[v]) + ND_PRINT((ndo,""%s"", map[t].value[v])); +- else +- rawprint(ndo, (const uint8_t *)&p[2], 2); ++ else { ++ if (!rawprint(ndo, (const uint8_t *)&p[2], 2)) { ++ ND_PRINT((ndo,"")"")); ++ goto trunc; ++ } ++ } + } else { +- ND_PRINT((ndo,""len=%d value="", EXTRACT_16BITS(&p[2]))); +- rawprint(ndo, (const uint8_t *)&p[4], EXTRACT_16BITS(&p[2])); ++ ND_PRINT((ndo,""len=%d value="", totlen - 4)); ++ if (!rawprint(ndo, (const uint8_t *)&p[4], totlen - 4)) { ++ ND_PRINT((ndo,"")"")); ++ goto trunc; ++ } + } + ND_PRINT((ndo,"")"")); + return p + totlen; ++ ++trunc: ++ return NULL; + } + + static const u_char * +-ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep) ++ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep2) + { + int totlen; + uint32_t t; + ++ ND_TCHECK(p[0]); + if (p[0] & 0x80) + totlen = 4; +- else ++ else { ++ ND_TCHECK_16BITS(&p[2]); + totlen = 4 + EXTRACT_16BITS(&p[2]); +- if (ep < p + totlen) { ++ } ++ if (ep2 < p + totlen) { + ND_PRINT((ndo,""[|attr]"")); +- return ep + 1; ++ return ep2 + 1; + } + ++ ND_TCHECK_16BITS(&p[0]); + ND_PRINT((ndo,""("")); + t = EXTRACT_16BITS(&p[0]) & 0x7fff; + ND_PRINT((ndo,""type=#%d "", t)); + if (p[0] & 0x80) { + ND_PRINT((ndo,""value="")); + t = p[2]; +- rawprint(ndo, (const uint8_t *)&p[2], 2); ++ if (!rawprint(ndo, (const uint8_t *)&p[2], 2)) { ++ ND_PRINT((ndo,"")"")); ++ goto trunc; ++ } + } else { +- ND_PRINT((ndo,""len=%d value="", EXTRACT_16BITS(&p[2]))); +- rawprint(ndo, (const uint8_t *)&p[4], EXTRACT_16BITS(&p[2])); ++ ND_PRINT((ndo,""len=%d value="", totlen - 4)); ++ if (!rawprint(ndo, (const uint8_t *)&p[4], totlen - 4)) { ++ ND_PRINT((ndo,"")"")); ++ goto trunc; ++ } + } + ND_PRINT((ndo,"")"")); + return p + totlen; ++ ++trunc: ++ return NULL; + } + + static const u_char * +@@ -1256,11 +1284,12 @@ ikev1_t_print(netdissect_options *ndo, u_char tpay _U_, + cp = (const u_char *)(p + 1); + ep2 = (const u_char *)p + item_len; + while (cp < ep && cp < ep2) { +- if (map && nmap) { +- cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2, +- map, nmap); +- } else +- cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2); ++ if (map && nmap) ++ cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); ++ else ++ cp = ikev1_attr_print(ndo, cp, ep2); ++ if (cp == NULL) ++ goto trunc; + } + if (ep < ep2) + ND_PRINT((ndo,""..."")); +@@ -1724,8 +1753,11 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_, + size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); + ND_PRINT((ndo,"" attrs=("")); + while (cp < ep && cp < ep2) { +- cp = ikev1_attrmap_print(ndo, cp, +- (ep < ep2) ? ep : ep2, map, nmap); ++ cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); ++ if (cp == NULL) { ++ ND_PRINT((ndo,"")"")); ++ goto trunc; ++ } + } + ND_PRINT((ndo,"")"")); + break; +@@ -1926,10 +1958,11 @@ ikev2_t_print(netdissect_options *ndo, int tcount, + ep2 = (const u_char *)p + item_len; + while (cp < ep && cp < ep2) { + if (map && nmap) { +- cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2, +- map, nmap); ++ cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); + } else +- cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2); ++ cp = ikev1_attr_print(ndo, cp, ep2); ++ if (cp == NULL) ++ goto trunc; + } + if (ep < ep2) + ND_PRINT((ndo,""...""));",1634,1870,2048 +7747,"test_bson_validate_dbref (void) +{ + size_t offset; + bson_t dbref, child, child2; + + /* should fail, $ref without an $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with non id field */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id at the top */ + { + bson_init (&dbref); + BSON_APPEND_UTF8 (&dbref, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&dbref, ""$id"", ""bar""); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id not first keys */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$db"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, non-string $ref with $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_INT32 (&child, ""$ref"", 1); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, non-string $ref with nothing */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_INT32 (&child, ""$ref"", 1); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id with non-string $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_INT32 (&child, ""$db"", 1); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id with non-string $db with stuff after */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_INT32 (&child, ""$db"", 1); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id with stuff, then $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with nested dbref $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_DOCUMENT_BEGIN (&child, ""$id"", &child2); + BSON_APPEND_UTF8 (&child2, ""$ref"", ""foo2""); + BSON_APPEND_UTF8 (&child2, ""$id"", ""bar2""); + BSON_APPEND_UTF8 (&child2, ""$db"", ""baz2""); + bson_append_document_end (&child, &child2); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with $id and $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with $id and $db and trailing */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } +} +",0,"test_bson_validate_dbref (void) +{ + size_t offset; + bson_t dbref, child, child2; + + /* should fail, $ref without an $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with non id field */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id at the top */ + { + bson_init (&dbref); + BSON_APPEND_UTF8 (&dbref, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&dbref, ""$id"", ""bar""); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id not first keys */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$db"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, non-string $ref with $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_INT32 (&child, ""$ref"", 1); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, non-string $ref with nothing */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_INT32 (&child, ""$ref"", 1); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id with non-string $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_INT32 (&child, ""$db"", 1); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id with non-string $db with stuff after */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_INT32 (&child, ""$db"", 1); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should fail, $ref with $id with stuff, then $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (!bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with nested dbref $id */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_DOCUMENT_BEGIN (&child, ""$id"", &child2); + BSON_APPEND_UTF8 (&child2, ""$ref"", ""foo2""); + BSON_APPEND_UTF8 (&child2, ""$id"", ""bar2""); + BSON_APPEND_UTF8 (&child2, ""$db"", ""baz2""); + bson_append_document_end (&child, &child2); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with $id and $db */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } + + /* should succeed, $ref with $id and $db and trailing */ + { + bson_init (&dbref); + BSON_APPEND_DOCUMENT_BEGIN (&dbref, ""dbref"", &child); + BSON_APPEND_UTF8 (&child, ""$ref"", ""foo""); + BSON_APPEND_UTF8 (&child, ""$id"", ""bar""); + BSON_APPEND_UTF8 (&child, ""$db"", ""baz""); + BSON_APPEND_UTF8 (&child, ""extra"", ""field""); + bson_append_document_end (&dbref, &child); + + BSON_ASSERT (bson_validate (&dbref, BSON_VALIDATE_DOLLAR_KEYS, &offset)); + + bson_destroy (&dbref); + } +} +","@@ -1249,6 +1249,11 @@ test_bson_validate (void) + 12, + BSON_VALIDATE_NONE, + ""corrupt BSON""); ++ VALIDATE_TEST (""test59.bson"", ++ BSON_VALIDATE_NONE, ++ 9, ++ BSON_VALIDATE_NONE, ++ ""corrupt BSON""); + + /* DBRef validation */ + b = BCON_NEW (""my_dbref"",",1689,1925,2048 +9443,"static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +{ + struct sock *sk = sock->sk; + struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct bt_security sec; + struct bt_power pwr; + struct l2cap_conn *conn; + int len, err = 0; + u32 opt; + + BT_DBG(""sk %p"", sk); + + if (level == SOL_L2CAP) + return l2cap_sock_setsockopt_old(sock, optname, optval, optlen); + + if (level != SOL_BLUETOOTH) + return -ENOPROTOOPT; + + lock_sock(sk); + + switch (optname) { + case BT_SECURITY: + if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && + chan->chan_type != L2CAP_CHAN_RAW) { + err = -EINVAL; + break; + } + + sec.level = BT_SECURITY_LOW; + + len = min_t(unsigned int, sizeof(sec), optlen); + if (copy_from_user((char *) &sec, optval, len)) { + err = -EFAULT; + break; + } + + if (sec.level < BT_SECURITY_LOW || + sec.level > BT_SECURITY_HIGH) { + err = -EINVAL; + break; + } + + chan->sec_level = sec.level; + + if (!chan->conn) + break; + + conn = chan->conn; + + /*change security for LE channels */ + if (chan->scid == L2CAP_CID_LE_DATA) { + if (!conn->hcon->out) { + err = -EINVAL; + break; + } + + if (smp_conn_security(conn, sec.level)) + break; + sk->sk_state = BT_CONFIG; + chan->state = BT_CONFIG; + + /* or for ACL link */ + } else if ((sk->sk_state == BT_CONNECT2 && + test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || + sk->sk_state == BT_CONNECTED) { + if (!l2cap_chan_check_security(chan)) + set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); + else + sk->sk_state_change(sk); + } else { + err = -EINVAL; + } + break; + + case BT_DEFER_SETUP: + if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) { + err = -EINVAL; + break; + } + + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt) + set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); + else + clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); + break; + + case BT_FLUSHABLE: + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt > BT_FLUSHABLE_ON) { + err = -EINVAL; + break; + } + + if (opt == BT_FLUSHABLE_OFF) { + struct l2cap_conn *conn = chan->conn; + /* proceed further only when we have l2cap_conn and + No Flush support in the LM */ + if (!conn || !lmp_no_flush_capable(conn->hcon->hdev)) { + err = -EINVAL; + break; + } + } + + if (opt) + set_bit(FLAG_FLUSHABLE, &chan->flags); + else + clear_bit(FLAG_FLUSHABLE, &chan->flags); + break; + + case BT_POWER: + if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && + chan->chan_type != L2CAP_CHAN_RAW) { + err = -EINVAL; + break; + } + + pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; + + len = min_t(unsigned int, sizeof(pwr), optlen); + if (copy_from_user((char *) &pwr, optval, len)) { + err = -EFAULT; + break; + } + + if (pwr.force_active) + set_bit(FLAG_FORCE_ACTIVE, &chan->flags); + else + clear_bit(FLAG_FORCE_ACTIVE, &chan->flags); + break; + + case BT_CHANNEL_POLICY: + if (!enable_hs) { + err = -ENOPROTOOPT; + break; + } + + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt > BT_CHANNEL_POLICY_AMP_PREFERRED) { + err = -EINVAL; + break; + } + + if (chan->mode != L2CAP_MODE_ERTM && + chan->mode != L2CAP_MODE_STREAMING) { + err = -EOPNOTSUPP; + break; + } + + chan->chan_policy = (u8) opt; + break; + + default: + err = -ENOPROTOOPT; + break; + } + + release_sock(sk); + return err; +} +",0,"static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) +{ + struct sock *sk = sock->sk; + struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct bt_security sec; + struct bt_power pwr; + struct l2cap_conn *conn; + int len, err = 0; + u32 opt; + + BT_DBG(""sk %p"", sk); + + if (level == SOL_L2CAP) + return l2cap_sock_setsockopt_old(sock, optname, optval, optlen); + + if (level != SOL_BLUETOOTH) + return -ENOPROTOOPT; + + lock_sock(sk); + + switch (optname) { + case BT_SECURITY: + if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && + chan->chan_type != L2CAP_CHAN_RAW) { + err = -EINVAL; + break; + } + + sec.level = BT_SECURITY_LOW; + + len = min_t(unsigned int, sizeof(sec), optlen); + if (copy_from_user((char *) &sec, optval, len)) { + err = -EFAULT; + break; + } + + if (sec.level < BT_SECURITY_LOW || + sec.level > BT_SECURITY_HIGH) { + err = -EINVAL; + break; + } + + chan->sec_level = sec.level; + + if (!chan->conn) + break; + + conn = chan->conn; + + /*change security for LE channels */ + if (chan->scid == L2CAP_CID_LE_DATA) { + if (!conn->hcon->out) { + err = -EINVAL; + break; + } + + if (smp_conn_security(conn, sec.level)) + break; + sk->sk_state = BT_CONFIG; + chan->state = BT_CONFIG; + + /* or for ACL link */ + } else if ((sk->sk_state == BT_CONNECT2 && + test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || + sk->sk_state == BT_CONNECTED) { + if (!l2cap_chan_check_security(chan)) + set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); + else + sk->sk_state_change(sk); + } else { + err = -EINVAL; + } + break; + + case BT_DEFER_SETUP: + if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) { + err = -EINVAL; + break; + } + + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt) + set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); + else + clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); + break; + + case BT_FLUSHABLE: + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt > BT_FLUSHABLE_ON) { + err = -EINVAL; + break; + } + + if (opt == BT_FLUSHABLE_OFF) { + struct l2cap_conn *conn = chan->conn; + /* proceed further only when we have l2cap_conn and + No Flush support in the LM */ + if (!conn || !lmp_no_flush_capable(conn->hcon->hdev)) { + err = -EINVAL; + break; + } + } + + if (opt) + set_bit(FLAG_FLUSHABLE, &chan->flags); + else + clear_bit(FLAG_FLUSHABLE, &chan->flags); + break; + + case BT_POWER: + if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && + chan->chan_type != L2CAP_CHAN_RAW) { + err = -EINVAL; + break; + } + + pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; + + len = min_t(unsigned int, sizeof(pwr), optlen); + if (copy_from_user((char *) &pwr, optval, len)) { + err = -EFAULT; + break; + } + + if (pwr.force_active) + set_bit(FLAG_FORCE_ACTIVE, &chan->flags); + else + clear_bit(FLAG_FORCE_ACTIVE, &chan->flags); + break; + + case BT_CHANNEL_POLICY: + if (!enable_hs) { + err = -ENOPROTOOPT; + break; + } + + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt > BT_CHANNEL_POLICY_AMP_PREFERRED) { + err = -EINVAL; + break; + } + + if (chan->mode != L2CAP_MODE_ERTM && + chan->mode != L2CAP_MODE_STREAMING) { + err = -EOPNOTSUPP; + break; + } + + chan->chan_policy = (u8) opt; + break; + + default: + err = -ENOPROTOOPT; + break; + } + + release_sock(sk); + return err; +} +","@@ -245,6 +245,7 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l + + BT_DBG(""sock %p, sk %p"", sock, sk); + ++ memset(la, 0, sizeof(struct sockaddr_l2)); + addr->sa_family = AF_BLUETOOTH; + *len = sizeof(struct sockaddr_l2); + ",1111,1347,2048 +2019,"static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, + const struct frag_hdr *fhdr, int nhoff) +{ + struct sk_buff *prev, *next; + int offset, end; + + if (fq->q.last_in & INET_FRAG_COMPLETE) { + pr_debug(""Allready completed\n""); + goto err; + } + + offset = ntohs(fhdr->frag_off) & ~0x7; + end = offset + (ntohs(ipv6_hdr(skb)->payload_len) - + ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1))); + + if ((unsigned int)end > IPV6_MAXPLEN) { + pr_debug(""offset is too large.\n""); + return -1; + } + + if (skb->ip_summed == CHECKSUM_COMPLETE) { + const unsigned char *nh = skb_network_header(skb); + skb->csum = csum_sub(skb->csum, + csum_partial(nh, (u8 *)(fhdr + 1) - nh, + 0)); + } + + /* Is this the final fragment? */ + if (!(fhdr->frag_off & htons(IP6_MF))) { + /* If we already have some bits beyond end + * or have different end, the segment is corrupted. + */ + if (end < fq->q.len || + ((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) { + pr_debug(""already received last fragment\n""); + goto err; + } + fq->q.last_in |= INET_FRAG_LAST_IN; + fq->q.len = end; + } else { + /* Check if the fragment is rounded to 8 bytes. + * Required by the RFC. + */ + if (end & 0x7) { + /* RFC2460 says always send parameter problem in + * this case. -DaveM + */ + pr_debug(""end of fragment not rounded to 8 bytes.\n""); + return -1; + } + if (end > fq->q.len) { + /* Some bits beyond end -> corruption. */ + if (fq->q.last_in & INET_FRAG_LAST_IN) { + pr_debug(""last packet already reached.\n""); + goto err; + } + fq->q.len = end; + } + } + + if (end == offset) + goto err; + + /* Point into the IP datagram 'data' part. */ + if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) { + pr_debug(""queue: message is too short.\n""); + goto err; + } + if (pskb_trim_rcsum(skb, end - offset)) { + pr_debug(""Can't trim\n""); + goto err; + } + + /* Find out which fragments are in front and at the back of us + * in the chain of fragments so far. We must know where to put + * this fragment, right? + */ + prev = NULL; + for (next = fq->q.fragments; next != NULL; next = next->next) { + if (NFCT_FRAG6_CB(next)->offset >= offset) + break; /* bingo! */ + prev = next; + } + + /* We found where to put this one. Check for overlap with + * preceding fragment, and, if needed, align things so that + * any overlaps are eliminated. + */ + if (prev) { + int i = (NFCT_FRAG6_CB(prev)->offset + prev->len) - offset; + + if (i > 0) { + offset += i; + if (end <= offset) { + pr_debug(""overlap\n""); + goto err; + } + if (!pskb_pull(skb, i)) { + pr_debug(""Can't pull\n""); + goto err; + } + if (skb->ip_summed != CHECKSUM_UNNECESSARY) + skb->ip_summed = CHECKSUM_NONE; + } + } + + /* Look for overlap with succeeding segments. + * If we can merge fragments, do it. + */ + while (next && NFCT_FRAG6_CB(next)->offset < end) { + /* overlap is 'i' bytes */ + int i = end - NFCT_FRAG6_CB(next)->offset; + + if (i < next->len) { + /* Eat head of the next overlapped fragment + * and leave the loop. The next ones cannot overlap. + */ + pr_debug(""Eat head of the overlapped parts.: %d"", i); + if (!pskb_pull(next, i)) + goto err; + + /* next fragment */ + NFCT_FRAG6_CB(next)->offset += i; + fq->q.meat -= i; + if (next->ip_summed != CHECKSUM_UNNECESSARY) + next->ip_summed = CHECKSUM_NONE; + break; + } else { + struct sk_buff *free_it = next; + + /* Old fragmnet is completely overridden with + * new one drop it. + */ + next = next->next; + + if (prev) + prev->next = next; + else + fq->q.fragments = next; + + fq->q.meat -= free_it->len; + frag_kfree_skb(free_it, NULL); + } + } + + NFCT_FRAG6_CB(skb)->offset = offset; + + /* Insert this fragment in the chain of fragments. */ + skb->next = next; + if (prev) + prev->next = skb; + else + fq->q.fragments = skb; + + skb->dev = NULL; + fq->q.stamp = skb->tstamp; + fq->q.meat += skb->len; + atomic_add(skb->truesize, &nf_init_frags.mem); + + /* The first fragment. + * nhoffset is obtained from the first fragment, of course. + */ + if (offset == 0) { + fq->nhoffset = nhoff; + fq->q.last_in |= INET_FRAG_FIRST_IN; + } + write_lock(&nf_frags.lock); + list_move_tail(&fq->q.lru_list, &nf_init_frags.lru_list); + write_unlock(&nf_frags.lock); + return 0; + +err: + return -1; +} +",0,"static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, + const struct frag_hdr *fhdr, int nhoff) +{ + struct sk_buff *prev, *next; + int offset, end; + + if (fq->q.last_in & INET_FRAG_COMPLETE) { + pr_debug(""Allready completed\n""); + goto err; + } + + offset = ntohs(fhdr->frag_off) & ~0x7; + end = offset + (ntohs(ipv6_hdr(skb)->payload_len) - + ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1))); + + if ((unsigned int)end > IPV6_MAXPLEN) { + pr_debug(""offset is too large.\n""); + return -1; + } + + if (skb->ip_summed == CHECKSUM_COMPLETE) { + const unsigned char *nh = skb_network_header(skb); + skb->csum = csum_sub(skb->csum, + csum_partial(nh, (u8 *)(fhdr + 1) - nh, + 0)); + } + + /* Is this the final fragment? */ + if (!(fhdr->frag_off & htons(IP6_MF))) { + /* If we already have some bits beyond end + * or have different end, the segment is corrupted. + */ + if (end < fq->q.len || + ((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) { + pr_debug(""already received last fragment\n""); + goto err; + } + fq->q.last_in |= INET_FRAG_LAST_IN; + fq->q.len = end; + } else { + /* Check if the fragment is rounded to 8 bytes. + * Required by the RFC. + */ + if (end & 0x7) { + /* RFC2460 says always send parameter problem in + * this case. -DaveM + */ + pr_debug(""end of fragment not rounded to 8 bytes.\n""); + return -1; + } + if (end > fq->q.len) { + /* Some bits beyond end -> corruption. */ + if (fq->q.last_in & INET_FRAG_LAST_IN) { + pr_debug(""last packet already reached.\n""); + goto err; + } + fq->q.len = end; + } + } + + if (end == offset) + goto err; + + /* Point into the IP datagram 'data' part. */ + if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) { + pr_debug(""queue: message is too short.\n""); + goto err; + } + if (pskb_trim_rcsum(skb, end - offset)) { + pr_debug(""Can't trim\n""); + goto err; + } + + /* Find out which fragments are in front and at the back of us + * in the chain of fragments so far. We must know where to put + * this fragment, right? + */ + prev = NULL; + for (next = fq->q.fragments; next != NULL; next = next->next) { + if (NFCT_FRAG6_CB(next)->offset >= offset) + break; /* bingo! */ + prev = next; + } + + /* We found where to put this one. Check for overlap with + * preceding fragment, and, if needed, align things so that + * any overlaps are eliminated. + */ + if (prev) { + int i = (NFCT_FRAG6_CB(prev)->offset + prev->len) - offset; + + if (i > 0) { + offset += i; + if (end <= offset) { + pr_debug(""overlap\n""); + goto err; + } + if (!pskb_pull(skb, i)) { + pr_debug(""Can't pull\n""); + goto err; + } + if (skb->ip_summed != CHECKSUM_UNNECESSARY) + skb->ip_summed = CHECKSUM_NONE; + } + } + + /* Look for overlap with succeeding segments. + * If we can merge fragments, do it. + */ + while (next && NFCT_FRAG6_CB(next)->offset < end) { + /* overlap is 'i' bytes */ + int i = end - NFCT_FRAG6_CB(next)->offset; + + if (i < next->len) { + /* Eat head of the next overlapped fragment + * and leave the loop. The next ones cannot overlap. + */ + pr_debug(""Eat head of the overlapped parts.: %d"", i); + if (!pskb_pull(next, i)) + goto err; + + /* next fragment */ + NFCT_FRAG6_CB(next)->offset += i; + fq->q.meat -= i; + if (next->ip_summed != CHECKSUM_UNNECESSARY) + next->ip_summed = CHECKSUM_NONE; + break; + } else { + struct sk_buff *free_it = next; + + /* Old fragmnet is completely overridden with + * new one drop it. + */ + next = next->next; + + if (prev) + prev->next = next; + else + fq->q.fragments = next; + + fq->q.meat -= free_it->len; + frag_kfree_skb(free_it, NULL); + } + } + + NFCT_FRAG6_CB(skb)->offset = offset; + + /* Insert this fragment in the chain of fragments. */ + skb->next = next; + if (prev) + prev->next = skb; + else + fq->q.fragments = skb; + + skb->dev = NULL; + fq->q.stamp = skb->tstamp; + fq->q.meat += skb->len; + atomic_add(skb->truesize, &nf_init_frags.mem); + + /* The first fragment. + * nhoffset is obtained from the first fragment, of course. + */ + if (offset == 0) { + fq->nhoffset = nhoff; + fq->q.last_in |= INET_FRAG_FIRST_IN; + } + write_lock(&nf_frags.lock); + list_move_tail(&fq->q.lru_list, &nf_init_frags.lru_list); + write_unlock(&nf_frags.lock); + return 0; + +err: + return -1; +} +","@@ -469,7 +469,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) + + /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */ + fp = skb_shinfo(head)->frag_list; +- if (NFCT_FRAG6_CB(fp)->orig == NULL) ++ if (fp && NFCT_FRAG6_CB(fp)->orig == NULL) + /* at above code, head skb is divided into two skbs. */ + fp = fp->next; + +@@ -595,12 +595,6 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user) + hdr = ipv6_hdr(clone); + fhdr = (struct frag_hdr *)skb_transport_header(clone); + +- if (!(fhdr->frag_off & htons(0xFFF9))) { +- pr_debug(""Invalid fragment offset\n""); +- /* It is not a fragmented frame */ +- goto ret_orig; +- } +- + if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh) + nf_ct_frag6_evictor(); + ",1369,1605,2048 +12083,"void WebURLLoaderImpl::Context::Start( + const WebURLRequest& request, + ResourceLoaderBridge::SyncLoadResponse* sync_load_response, + WebKitPlatformSupportImpl* platform) { + DCHECK(!bridge_.get()); + + request_ = request; // Save the request. + + GURL url = request.url(); + if (url.SchemeIs(""data"") && CanHandleDataURL(url)) { + if (sync_load_response) { + sync_load_response->url = url; + std::string data; + GetInfoFromDataURL(sync_load_response->url, sync_load_response, + &sync_load_response->data, + &sync_load_response->error_code); + } else { + AddRef(); // Balanced in OnCompletedRequest + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&Context::HandleDataURL, this)); + } + return; + } + + GURL referrer_url( + request.httpHeaderField(WebString::fromUTF8(""Referer"")).utf8()); + const std::string& method = request.httpMethod().utf8(); + + int load_flags = net::LOAD_NORMAL; + switch (request.cachePolicy()) { + case WebURLRequest::ReloadIgnoringCacheData: + load_flags |= net::LOAD_VALIDATE_CACHE; + break; + case WebURLRequest::ReturnCacheDataElseLoad: + load_flags |= net::LOAD_PREFERRING_CACHE; + break; + case WebURLRequest::ReturnCacheDataDontLoad: + load_flags |= net::LOAD_ONLY_FROM_CACHE; + break; + case WebURLRequest::UseProtocolCachePolicy: + break; + } + + if (request.reportUploadProgress()) + load_flags |= net::LOAD_ENABLE_UPLOAD_PROGRESS; + if (request.reportLoadTiming()) + load_flags |= net::LOAD_ENABLE_LOAD_TIMING; + if (request.reportRawHeaders()) + load_flags |= net::LOAD_REPORT_RAW_HEADERS; + + if (!request.allowCookies() || !request.allowStoredCredentials()) { + load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; + load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; + } + + if (!request.allowStoredCredentials()) + load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA; + + HeaderFlattener flattener(load_flags); + request.visitHTTPHeaderFields(&flattener); + + + ResourceLoaderBridge::RequestInfo request_info; + request_info.method = method; + request_info.url = url; + request_info.first_party_for_cookies = request.firstPartyForCookies(); + request_info.referrer = referrer_url; + request_info.headers = flattener.GetBuffer(); + request_info.load_flags = load_flags; + request_info.requestor_pid = request.requestorProcessID(); + request_info.request_type = + ResourceType::FromTargetType(request.targetType()); + request_info.priority = + ConvertWebKitPriorityToNetPriority(request.priority()); + request_info.appcache_host_id = request.appCacheHostID(); + request_info.routing_id = request.requestorID(); + request_info.download_to_file = request.downloadToFile(); + request_info.has_user_gesture = request.hasUserGesture(); + request_info.extra_data = request.extraData(); + if (request.extraData()) { + referrer_policy_ = static_cast( + request.extraData())->referrer_policy(); + request_info.referrer_policy = referrer_policy_; + } + bridge_.reset(platform->CreateResourceLoader(request_info)); + + if (!request.httpBody().isNull()) { + DCHECK(method != ""GET"" && method != ""HEAD""); + const WebHTTPBody& httpBody = request.httpBody(); + size_t i = 0; + WebHTTPBody::Element element; + scoped_refptr request_body = new ResourceRequestBody; + while (httpBody.elementAt(i++, element)) { + switch (element.type) { + case WebHTTPBody::Element::TypeData: + if (!element.data.isEmpty()) { + request_body->AppendBytes( + element.data.data(), static_cast(element.data.size())); + } + break; + case WebHTTPBody::Element::TypeFile: + if (element.fileLength == -1) { + request_body->AppendFileRange( + webkit_base::WebStringToFilePath(element.filePath), + 0, kuint64max, base::Time()); + } else { + request_body->AppendFileRange( + webkit_base::WebStringToFilePath(element.filePath), + static_cast(element.fileStart), + static_cast(element.fileLength), + base::Time::FromDoubleT(element.modificationTime)); + } + break; + case WebHTTPBody::Element::TypeURL: { + GURL url = GURL(element.url); + DCHECK(url.SchemeIsFileSystem()); + request_body->AppendFileSystemFileRange( + url, + static_cast(element.fileStart), + static_cast(element.fileLength), + base::Time::FromDoubleT(element.modificationTime)); + break; + } + case WebHTTPBody::Element::TypeBlob: + request_body->AppendBlob(GURL(element.blobURL)); + break; + default: + NOTREACHED(); + } + } + request_body->set_identifier(request.httpBody().identifier()); + bridge_->SetRequestBody(request_body); + } + + if (sync_load_response) { + bridge_->SyncLoad(sync_load_response); + return; + } + + if (bridge_->Start(this)) { + AddRef(); // Balanced in OnCompletedRequest + } else { + bridge_.reset(); + } +} +",0,"void WebURLLoaderImpl::Context::Start( + const WebURLRequest& request, + ResourceLoaderBridge::SyncLoadResponse* sync_load_response, + WebKitPlatformSupportImpl* platform) { + DCHECK(!bridge_.get()); + + request_ = request; // Save the request. + + GURL url = request.url(); + if (url.SchemeIs(""data"") && CanHandleDataURL(url)) { + if (sync_load_response) { + sync_load_response->url = url; + std::string data; + GetInfoFromDataURL(sync_load_response->url, sync_load_response, + &sync_load_response->data, + &sync_load_response->error_code); + } else { + AddRef(); // Balanced in OnCompletedRequest + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&Context::HandleDataURL, this)); + } + return; + } + + GURL referrer_url( + request.httpHeaderField(WebString::fromUTF8(""Referer"")).utf8()); + const std::string& method = request.httpMethod().utf8(); + + int load_flags = net::LOAD_NORMAL; + switch (request.cachePolicy()) { + case WebURLRequest::ReloadIgnoringCacheData: + load_flags |= net::LOAD_VALIDATE_CACHE; + break; + case WebURLRequest::ReturnCacheDataElseLoad: + load_flags |= net::LOAD_PREFERRING_CACHE; + break; + case WebURLRequest::ReturnCacheDataDontLoad: + load_flags |= net::LOAD_ONLY_FROM_CACHE; + break; + case WebURLRequest::UseProtocolCachePolicy: + break; + } + + if (request.reportUploadProgress()) + load_flags |= net::LOAD_ENABLE_UPLOAD_PROGRESS; + if (request.reportLoadTiming()) + load_flags |= net::LOAD_ENABLE_LOAD_TIMING; + if (request.reportRawHeaders()) + load_flags |= net::LOAD_REPORT_RAW_HEADERS; + + if (!request.allowCookies() || !request.allowStoredCredentials()) { + load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; + load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; + } + + if (!request.allowStoredCredentials()) + load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA; + + HeaderFlattener flattener(load_flags); + request.visitHTTPHeaderFields(&flattener); + + + ResourceLoaderBridge::RequestInfo request_info; + request_info.method = method; + request_info.url = url; + request_info.first_party_for_cookies = request.firstPartyForCookies(); + request_info.referrer = referrer_url; + request_info.headers = flattener.GetBuffer(); + request_info.load_flags = load_flags; + request_info.requestor_pid = request.requestorProcessID(); + request_info.request_type = + ResourceType::FromTargetType(request.targetType()); + request_info.priority = + ConvertWebKitPriorityToNetPriority(request.priority()); + request_info.appcache_host_id = request.appCacheHostID(); + request_info.routing_id = request.requestorID(); + request_info.download_to_file = request.downloadToFile(); + request_info.has_user_gesture = request.hasUserGesture(); + request_info.extra_data = request.extraData(); + if (request.extraData()) { + referrer_policy_ = static_cast( + request.extraData())->referrer_policy(); + request_info.referrer_policy = referrer_policy_; + } + bridge_.reset(platform->CreateResourceLoader(request_info)); + + if (!request.httpBody().isNull()) { + DCHECK(method != ""GET"" && method != ""HEAD""); + const WebHTTPBody& httpBody = request.httpBody(); + size_t i = 0; + WebHTTPBody::Element element; + scoped_refptr request_body = new ResourceRequestBody; + while (httpBody.elementAt(i++, element)) { + switch (element.type) { + case WebHTTPBody::Element::TypeData: + if (!element.data.isEmpty()) { + request_body->AppendBytes( + element.data.data(), static_cast(element.data.size())); + } + break; + case WebHTTPBody::Element::TypeFile: + if (element.fileLength == -1) { + request_body->AppendFileRange( + webkit_base::WebStringToFilePath(element.filePath), + 0, kuint64max, base::Time()); + } else { + request_body->AppendFileRange( + webkit_base::WebStringToFilePath(element.filePath), + static_cast(element.fileStart), + static_cast(element.fileLength), + base::Time::FromDoubleT(element.modificationTime)); + } + break; + case WebHTTPBody::Element::TypeURL: { + GURL url = GURL(element.url); + DCHECK(url.SchemeIsFileSystem()); + request_body->AppendFileSystemFileRange( + url, + static_cast(element.fileStart), + static_cast(element.fileLength), + base::Time::FromDoubleT(element.modificationTime)); + break; + } + case WebHTTPBody::Element::TypeBlob: + request_body->AppendBlob(GURL(element.blobURL)); + break; + default: + NOTREACHED(); + } + } + request_body->set_identifier(request.httpBody().identifier()); + bridge_->SetRequestBody(request_body); + } + + if (sync_load_response) { + bridge_->SyncLoad(sync_load_response); + return; + } + + if (bridge_->Start(this)) { + AddRef(); // Balanced in OnCompletedRequest + } else { + bridge_.reset(); + } +} +","@@ -637,6 +637,7 @@ void WebURLLoaderImpl::Context::OnReceivedResponse( + } + } + ++ scoped_refptr protect(this); + client_->didReceiveResponse(loader_, response); + + // We may have been cancelled after didReceiveResponse, which would leave us",1145,1381,2048 +1729,"int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, + int *num, uint64_t *cluster_offset) +{ + BDRVQcowState *s = bs->opaque; + unsigned int l2_index; + uint64_t l1_index, l2_offset, *l2_table; + int l1_bits, c; + unsigned int index_in_cluster, nb_clusters; + uint64_t nb_available, nb_needed; + int ret; + + index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); + nb_needed = *num + index_in_cluster; + + l1_bits = s->l2_bits + s->cluster_bits; + + /* compute how many bytes there are between the offset and + * the end of the l1 entry + */ + + nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1)); + + /* compute the number of available sectors */ + + nb_available = (nb_available >> 9) + index_in_cluster; + + if (nb_needed > nb_available) { + nb_needed = nb_available; + } + + *cluster_offset = 0; + + /* seek the the l2 offset in the l1 table */ + + l1_index = offset >> l1_bits; + if (l1_index >= s->l1_size) { + ret = QCOW2_CLUSTER_UNALLOCATED; + goto out; + } + + l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; + if (!l2_offset) { + ret = QCOW2_CLUSTER_UNALLOCATED; + goto out; + } + + /* load the l2 table in memory */ + + ret = l2_load(bs, l2_offset, &l2_table); + if (ret < 0) { + return ret; + } + + /* find the cluster offset for the given disk offset */ + + l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); + *cluster_offset = be64_to_cpu(l2_table[l2_index]); + nb_clusters = size_to_clusters(s, nb_needed << 9); + + ret = qcow2_get_cluster_type(*cluster_offset); + switch (ret) { + case QCOW2_CLUSTER_COMPRESSED: + /* Compressed clusters can only be processed one by one */ + c = 1; + *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK; + break; + case QCOW2_CLUSTER_ZERO: + if (s->qcow_version < 3) { + return -EIO; + } + c = count_contiguous_clusters(nb_clusters, s->cluster_size, + &l2_table[l2_index], QCOW_OFLAG_ZERO); + *cluster_offset = 0; + break; + case QCOW2_CLUSTER_UNALLOCATED: + /* how many empty clusters ? */ + c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); + *cluster_offset = 0; + break; + case QCOW2_CLUSTER_NORMAL: + /* how many allocated clusters ? */ + c = count_contiguous_clusters(nb_clusters, s->cluster_size, + &l2_table[l2_index], QCOW_OFLAG_ZERO); + *cluster_offset &= L2E_OFFSET_MASK; + break; + default: + abort(); + } + + qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + + nb_available = (c * s->cluster_sectors); + +out: + if (nb_available > nb_needed) + nb_available = nb_needed; + + *num = nb_available - index_in_cluster; + + return ret; +} +",0,"int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, + int *num, uint64_t *cluster_offset) +{ + BDRVQcowState *s = bs->opaque; + unsigned int l2_index; + uint64_t l1_index, l2_offset, *l2_table; + int l1_bits, c; + unsigned int index_in_cluster, nb_clusters; + uint64_t nb_available, nb_needed; + int ret; + + index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); + nb_needed = *num + index_in_cluster; + + l1_bits = s->l2_bits + s->cluster_bits; + + /* compute how many bytes there are between the offset and + * the end of the l1 entry + */ + + nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1)); + + /* compute the number of available sectors */ + + nb_available = (nb_available >> 9) + index_in_cluster; + + if (nb_needed > nb_available) { + nb_needed = nb_available; + } + + *cluster_offset = 0; + + /* seek the the l2 offset in the l1 table */ + + l1_index = offset >> l1_bits; + if (l1_index >= s->l1_size) { + ret = QCOW2_CLUSTER_UNALLOCATED; + goto out; + } + + l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; + if (!l2_offset) { + ret = QCOW2_CLUSTER_UNALLOCATED; + goto out; + } + + /* load the l2 table in memory */ + + ret = l2_load(bs, l2_offset, &l2_table); + if (ret < 0) { + return ret; + } + + /* find the cluster offset for the given disk offset */ + + l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); + *cluster_offset = be64_to_cpu(l2_table[l2_index]); + nb_clusters = size_to_clusters(s, nb_needed << 9); + + ret = qcow2_get_cluster_type(*cluster_offset); + switch (ret) { + case QCOW2_CLUSTER_COMPRESSED: + /* Compressed clusters can only be processed one by one */ + c = 1; + *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK; + break; + case QCOW2_CLUSTER_ZERO: + if (s->qcow_version < 3) { + return -EIO; + } + c = count_contiguous_clusters(nb_clusters, s->cluster_size, + &l2_table[l2_index], QCOW_OFLAG_ZERO); + *cluster_offset = 0; + break; + case QCOW2_CLUSTER_UNALLOCATED: + /* how many empty clusters ? */ + c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); + *cluster_offset = 0; + break; + case QCOW2_CLUSTER_NORMAL: + /* how many allocated clusters ? */ + c = count_contiguous_clusters(nb_clusters, s->cluster_size, + &l2_table[l2_index], QCOW_OFLAG_ZERO); + *cluster_offset &= L2E_OFFSET_MASK; + break; + default: + abort(); + } + + qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + + nb_available = (c * s->cluster_sectors); + +out: + if (nb_available > nb_needed) + nb_available = nb_needed; + + *num = nb_available - index_in_cluster; + + return ret; +} +","@@ -55,7 +55,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, + } + } + +- if (new_l1_size > INT_MAX) { ++ if (new_l1_size > INT_MAX / sizeof(uint64_t)) { + return -EFBIG; + }",790,1026,2048 +12181,"void HTMLSelectElement::menuListDefaultEventHandler(Event* event) +{ + RenderTheme& renderTheme = RenderTheme::theme(); + + if (event->type() == EventTypeNames::keydown) { + if (!renderer() || !event->isKeyboardEvent()) + return; + + if (platformHandleKeydownEvent(toKeyboardEvent(event))) + return; + + if (isSpatialNavigationEnabled(document().frame())) { + if (!m_activeSelectionState) + return; + } + + const String& keyIdentifier = toKeyboardEvent(event)->keyIdentifier(); + bool handled = true; + const Vector& listItems = this->listItems(); + int listIndex = optionToListIndex(selectedIndex()); + + if (keyIdentifier == ""Down"" || keyIdentifier == ""Right"") + listIndex = nextValidIndex(listIndex, SkipForwards, 1); + else if (keyIdentifier == ""Up"" || keyIdentifier == ""Left"") + listIndex = nextValidIndex(listIndex, SkipBackwards, 1); + else if (keyIdentifier == ""PageDown"") + listIndex = nextValidIndex(listIndex, SkipForwards, 3); + else if (keyIdentifier == ""PageUp"") + listIndex = nextValidIndex(listIndex, SkipBackwards, 3); + else if (keyIdentifier == ""Home"") + listIndex = nextValidIndex(-1, SkipForwards, 1); + else if (keyIdentifier == ""End"") + listIndex = nextValidIndex(listItems.size(), SkipBackwards, 1); + else + handled = false; + + if (handled && static_cast(listIndex) < listItems.size()) + selectOption(listToOptionIndex(listIndex), DeselectOtherOptions | DispatchChangeEvent | UserDriven); + + if (handled) + event->setDefaultHandled(); + } + + if (event->type() == EventTypeNames::keypress) { + if (!renderer() || !event->isKeyboardEvent()) + return; + + int keyCode = toKeyboardEvent(event)->keyCode(); + bool handled = false; + + if (keyCode == ' ' && isSpatialNavigationEnabled(document().frame())) { + m_activeSelectionState = !m_activeSelectionState; + event->setDefaultHandled(); + return; + } + + if (renderTheme.popsMenuBySpaceOrReturn()) { + if (keyCode == ' ' || keyCode == '\r') { + focus(); + + if (!renderer() || !renderer()->isMenuList()) + return; + + saveLastSelection(); + if (RenderMenuList* menuList = toRenderMenuList(renderer())) + menuList->showPopup(); + handled = true; + } + } else if (renderTheme.popsMenuByArrowKeys()) { + if (keyCode == ' ') { + focus(); + + if (!renderer() || !renderer()->isMenuList()) + return; + + saveLastSelection(); + if (RenderMenuList* menuList = toRenderMenuList(renderer())) + menuList->showPopup(); + handled = true; + } else if (keyCode == '\r') { + if (form()) + form()->submitImplicitly(event, false); + dispatchChangeEventForMenuList(); + handled = true; + } + } + + if (handled) + event->setDefaultHandled(); + } + + if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) { + focus(); + if (renderer() && renderer()->isMenuList()) { + if (RenderMenuList* menuList = toRenderMenuList(renderer())) { + if (menuList->popupIsVisible()) + menuList->hidePopup(); + else { + saveLastSelection(); + menuList->showPopup(); + } + } + } + event->setDefaultHandled(); + } + + if (event->type() == EventTypeNames::blur) { + if (RenderMenuList* menuList = toRenderMenuList(renderer())) { + if (menuList->popupIsVisible()) + menuList->hidePopup(); + } + } +} +",0,"void HTMLSelectElement::menuListDefaultEventHandler(Event* event) +{ + RenderTheme& renderTheme = RenderTheme::theme(); + + if (event->type() == EventTypeNames::keydown) { + if (!renderer() || !event->isKeyboardEvent()) + return; + + if (platformHandleKeydownEvent(toKeyboardEvent(event))) + return; + + if (isSpatialNavigationEnabled(document().frame())) { + if (!m_activeSelectionState) + return; + } + + const String& keyIdentifier = toKeyboardEvent(event)->keyIdentifier(); + bool handled = true; + const Vector& listItems = this->listItems(); + int listIndex = optionToListIndex(selectedIndex()); + + if (keyIdentifier == ""Down"" || keyIdentifier == ""Right"") + listIndex = nextValidIndex(listIndex, SkipForwards, 1); + else if (keyIdentifier == ""Up"" || keyIdentifier == ""Left"") + listIndex = nextValidIndex(listIndex, SkipBackwards, 1); + else if (keyIdentifier == ""PageDown"") + listIndex = nextValidIndex(listIndex, SkipForwards, 3); + else if (keyIdentifier == ""PageUp"") + listIndex = nextValidIndex(listIndex, SkipBackwards, 3); + else if (keyIdentifier == ""Home"") + listIndex = nextValidIndex(-1, SkipForwards, 1); + else if (keyIdentifier == ""End"") + listIndex = nextValidIndex(listItems.size(), SkipBackwards, 1); + else + handled = false; + + if (handled && static_cast(listIndex) < listItems.size()) + selectOption(listToOptionIndex(listIndex), DeselectOtherOptions | DispatchChangeEvent | UserDriven); + + if (handled) + event->setDefaultHandled(); + } + + if (event->type() == EventTypeNames::keypress) { + if (!renderer() || !event->isKeyboardEvent()) + return; + + int keyCode = toKeyboardEvent(event)->keyCode(); + bool handled = false; + + if (keyCode == ' ' && isSpatialNavigationEnabled(document().frame())) { + m_activeSelectionState = !m_activeSelectionState; + event->setDefaultHandled(); + return; + } + + if (renderTheme.popsMenuBySpaceOrReturn()) { + if (keyCode == ' ' || keyCode == '\r') { + focus(); + + if (!renderer() || !renderer()->isMenuList()) + return; + + saveLastSelection(); + if (RenderMenuList* menuList = toRenderMenuList(renderer())) + menuList->showPopup(); + handled = true; + } + } else if (renderTheme.popsMenuByArrowKeys()) { + if (keyCode == ' ') { + focus(); + + if (!renderer() || !renderer()->isMenuList()) + return; + + saveLastSelection(); + if (RenderMenuList* menuList = toRenderMenuList(renderer())) + menuList->showPopup(); + handled = true; + } else if (keyCode == '\r') { + if (form()) + form()->submitImplicitly(event, false); + dispatchChangeEventForMenuList(); + handled = true; + } + } + + if (handled) + event->setDefaultHandled(); + } + + if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) { + focus(); + if (renderer() && renderer()->isMenuList()) { + if (RenderMenuList* menuList = toRenderMenuList(renderer())) { + if (menuList->popupIsVisible()) + menuList->hidePopup(); + else { + saveLastSelection(); + menuList->showPopup(); + } + } + } + event->setDefaultHandled(); + } + + if (event->type() == EventTypeNames::blur) { + if (RenderMenuList* menuList = toRenderMenuList(renderer())) { + if (menuList->popupIsVisible()) + menuList->hidePopup(); + } + } +} +","@@ -1569,4 +1569,9 @@ bool HTMLSelectElement::isInteractiveContent() const + return true; + } + ++bool HTMLSelectElement::supportsAutofocus() const ++{ ++ return true; ++} ++ + } // namespace",842,1078,2048 +9124,"static MagickBooleanType sixel_encode_impl(unsigned char *pixels, size_t width,size_t height, + unsigned char *palette, size_t ncolors, int keycolor, + sixel_output_t *context) +{ +#define RelinquishNodesAndMap \ + while ((np = context->node_free) != NULL) { \ + context->node_free = np->next; \ + np=(sixel_node_t *) RelinquishMagickMemory(np); \ + } \ + map = (unsigned char *) RelinquishMagickMemory(map) + + int x, y, i, n, c; + int left, right; + int pix; + unsigned char *map; + sixel_node_t *np, *tp, top; + int nwrite; + size_t len; + + context->pos = 0; + + if (ncolors < 1) { + return (MagickFalse); + } + len = ncolors * width; + context->active_palette = (-1); + + if ((map = (unsigned char *)AcquireQuantumMemory(len, sizeof(unsigned char))) == NULL) { + return (MagickFalse); + } + (void) memset(map, 0, len); + + if (context->has_8bit_control) { + nwrite = sprintf((char *)context->buffer, ""\x90"" ""0;0;0"" ""q""); + } else { + nwrite = sprintf((char *)context->buffer, ""\x1bP"" ""0;0;0"" ""q""); + } + if (nwrite <= 0) { + return (MagickFalse); + } + sixel_advance(context, nwrite); + nwrite = sprintf((char *)context->buffer + context->pos, ""\""1;1;%d;%d"", (int) width, (int) height); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + sixel_advance(context, nwrite); + + if (ncolors != 2 || keycolor == -1) { + for (n = 0; n < (ssize_t) ncolors; n++) { + /* DECGCI Graphics Color Introducer # Pc ; Pu; Px; Py; Pz */ + nwrite = sprintf((char *)context->buffer + context->pos, ""#%d;2;%d;%d;%d"", + n, + (palette[n * 3 + 0] * 100 + 127) / 255, + (palette[n * 3 + 1] * 100 + 127) / 255, + (palette[n * 3 + 2] * 100 + 127) / 255); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + sixel_advance(context, nwrite); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + } + } + + for (y = i = 0; y < (ssize_t) height; y++) { + for (x = 0; x < (ssize_t) width; x++) { + pix = pixels[y * width + x]; + if (pix >= 0 && pix < (ssize_t) ncolors && pix != keycolor) { + map[pix * width + x] |= (1 << i); + } + } + + if (++i < 6 && (y + 1) < (ssize_t) height) { + continue; + } + + for (c = 0; c < (ssize_t) ncolors; c++) { + for (left = 0; left < (ssize_t) width; left++) { + if (*(map + c * width + left) == 0) { + continue; + } + + for (right = left + 1; right < (ssize_t) width; right++) { + if (*(map + c * width + right) != 0) { + continue; + } + + for (n = 1; (right + n) < (ssize_t) width; n++) { + if (*(map + c * width + right + n) != 0) { + break; + } + } + + if (n >= 10 || right + n >= (ssize_t) width) { + break; + } + right = right + n - 1; + } + + if ((np = context->node_free) != NULL) { + context->node_free = np->next; + } else if ((np = (sixel_node_t *)AcquireMagickMemory(sizeof(sixel_node_t))) == NULL) { + RelinquishNodesAndMap; + return (MagickFalse); + } + + np->color = c; + np->left = left; + np->right = right; + np->map = map + c * width; + + top.next = context->node_top; + tp = ⊤ + + while (tp->next != NULL) { + if (np->left < tp->next->left) { + break; + } + if (np->left == tp->next->left && np->right > tp->next->right) { + break; + } + tp = tp->next; + } + + np->next = tp->next; + tp->next = np; + context->node_top = top.next; + + left = right - 1; + } + + } + + for (x = 0; (np = context->node_top) != NULL;) { + if (x > np->left) { + /* DECGCR Graphics Carriage Return */ + context->buffer[context->pos] = '$'; + sixel_advance(context, 1); + x = 0; + } + + x = sixel_put_node(context, x, np, (int) ncolors, keycolor); + sixel_node_del(context, np); + np = context->node_top; + + while (np != NULL) { + if (np->left < x) { + np = np->next; + continue; + } + + x = sixel_put_node(context, x, np, (int) ncolors, keycolor); + sixel_node_del(context, np); + np = context->node_top; + } + } + + /* DECGNL Graphics Next Line */ + context->buffer[context->pos] = '-'; + sixel_advance(context, 1); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + + i = 0; + (void) memset(map, 0, len); + } + + if (context->has_8bit_control) { + context->buffer[context->pos] = 0x9c; + sixel_advance(context, 1); + } else { + context->buffer[context->pos] = 0x1b; + context->buffer[context->pos + 1] = '\\'; + sixel_advance(context, 2); + } + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + + /* flush buffer */ + if (context->pos > 0) { + WriteBlob(context->image,context->pos,context->buffer); + } + + RelinquishNodesAndMap; + + return(MagickTrue); +} +",0,"static MagickBooleanType sixel_encode_impl(unsigned char *pixels, size_t width,size_t height, + unsigned char *palette, size_t ncolors, int keycolor, + sixel_output_t *context) +{ +#define RelinquishNodesAndMap \ + while ((np = context->node_free) != NULL) { \ + context->node_free = np->next; \ + np=(sixel_node_t *) RelinquishMagickMemory(np); \ + } \ + map = (unsigned char *) RelinquishMagickMemory(map) + + int x, y, i, n, c; + int left, right; + int pix; + unsigned char *map; + sixel_node_t *np, *tp, top; + int nwrite; + size_t len; + + context->pos = 0; + + if (ncolors < 1) { + return (MagickFalse); + } + len = ncolors * width; + context->active_palette = (-1); + + if ((map = (unsigned char *)AcquireQuantumMemory(len, sizeof(unsigned char))) == NULL) { + return (MagickFalse); + } + (void) memset(map, 0, len); + + if (context->has_8bit_control) { + nwrite = sprintf((char *)context->buffer, ""\x90"" ""0;0;0"" ""q""); + } else { + nwrite = sprintf((char *)context->buffer, ""\x1bP"" ""0;0;0"" ""q""); + } + if (nwrite <= 0) { + return (MagickFalse); + } + sixel_advance(context, nwrite); + nwrite = sprintf((char *)context->buffer + context->pos, ""\""1;1;%d;%d"", (int) width, (int) height); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + sixel_advance(context, nwrite); + + if (ncolors != 2 || keycolor == -1) { + for (n = 0; n < (ssize_t) ncolors; n++) { + /* DECGCI Graphics Color Introducer # Pc ; Pu; Px; Py; Pz */ + nwrite = sprintf((char *)context->buffer + context->pos, ""#%d;2;%d;%d;%d"", + n, + (palette[n * 3 + 0] * 100 + 127) / 255, + (palette[n * 3 + 1] * 100 + 127) / 255, + (palette[n * 3 + 2] * 100 + 127) / 255); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + sixel_advance(context, nwrite); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + } + } + + for (y = i = 0; y < (ssize_t) height; y++) { + for (x = 0; x < (ssize_t) width; x++) { + pix = pixels[y * width + x]; + if (pix >= 0 && pix < (ssize_t) ncolors && pix != keycolor) { + map[pix * width + x] |= (1 << i); + } + } + + if (++i < 6 && (y + 1) < (ssize_t) height) { + continue; + } + + for (c = 0; c < (ssize_t) ncolors; c++) { + for (left = 0; left < (ssize_t) width; left++) { + if (*(map + c * width + left) == 0) { + continue; + } + + for (right = left + 1; right < (ssize_t) width; right++) { + if (*(map + c * width + right) != 0) { + continue; + } + + for (n = 1; (right + n) < (ssize_t) width; n++) { + if (*(map + c * width + right + n) != 0) { + break; + } + } + + if (n >= 10 || right + n >= (ssize_t) width) { + break; + } + right = right + n - 1; + } + + if ((np = context->node_free) != NULL) { + context->node_free = np->next; + } else if ((np = (sixel_node_t *)AcquireMagickMemory(sizeof(sixel_node_t))) == NULL) { + RelinquishNodesAndMap; + return (MagickFalse); + } + + np->color = c; + np->left = left; + np->right = right; + np->map = map + c * width; + + top.next = context->node_top; + tp = ⊤ + + while (tp->next != NULL) { + if (np->left < tp->next->left) { + break; + } + if (np->left == tp->next->left && np->right > tp->next->right) { + break; + } + tp = tp->next; + } + + np->next = tp->next; + tp->next = np; + context->node_top = top.next; + + left = right - 1; + } + + } + + for (x = 0; (np = context->node_top) != NULL;) { + if (x > np->left) { + /* DECGCR Graphics Carriage Return */ + context->buffer[context->pos] = '$'; + sixel_advance(context, 1); + x = 0; + } + + x = sixel_put_node(context, x, np, (int) ncolors, keycolor); + sixel_node_del(context, np); + np = context->node_top; + + while (np != NULL) { + if (np->left < x) { + np = np->next; + continue; + } + + x = sixel_put_node(context, x, np, (int) ncolors, keycolor); + sixel_node_del(context, np); + np = context->node_top; + } + } + + /* DECGNL Graphics Next Line */ + context->buffer[context->pos] = '-'; + sixel_advance(context, 1); + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + + i = 0; + (void) memset(map, 0, len); + } + + if (context->has_8bit_control) { + context->buffer[context->pos] = 0x9c; + sixel_advance(context, 1); + } else { + context->buffer[context->pos] = 0x1b; + context->buffer[context->pos + 1] = '\\'; + sixel_advance(context, 2); + } + if (nwrite <= 0) { + RelinquishNodesAndMap; + return (MagickFalse); + } + + /* flush buffer */ + if (context->pos > 0) { + WriteBlob(context->image,context->pos,context->buffer); + } + + RelinquishNodesAndMap; + + return(MagickTrue); +} +","@@ -1057,6 +1057,7 @@ static Image *ReadSIXELImage(const ImageInfo *image_info,ExceptionInfo *exceptio + if (sixel_decode(image,(unsigned char *) sixel_buffer,&sixel_pixels,&image->columns,&image->rows,&sixel_palette,&image->colors,exception) == MagickFalse) + { + sixel_buffer=(char *) RelinquishMagickMemory(sixel_buffer); ++ sixel_pixels=(unsigned char *) RelinquishMagickMemory(sixel_pixels); + ThrowReaderException(CorruptImageError,""CorruptImage""); + } + sixel_buffer=(char *) RelinquishMagickMemory(sixel_buffer);",1610,1846,2048 +8349,"void AVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *avc, GF_MediaBox *mdia) +{ + GF_AVCConfig *avcc, *svcc, *mvcc; + GF_BitRateBox *btrt = gf_isom_sample_entry_get_bitrate((GF_SampleEntryBox *)avc, GF_FALSE); + + if (avc->emul_esd) gf_odf_desc_del((GF_Descriptor *)avc->emul_esd); + avc->emul_esd = gf_odf_desc_esd_new(2); + avc->emul_esd->decoderConfig->streamType = GF_STREAM_VISUAL; + /*AVC OTI is 0x21, AVC parameter set stream OTI (not supported in gpac) is 0x22, SVC OTI is 0x24*/ + /*if we have only SVC stream, set objectTypeIndication to AVC OTI; else set it to AVC OTI*/ + if (avc->svc_config && !avc->avc_config) + avc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_SVC; + else if (avc->mvc_config && !avc->avc_config) + avc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_MVC; + else + avc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_AVC; + + if (btrt) { + avc->emul_esd->decoderConfig->bufferSizeDB = btrt->bufferSizeDB; + avc->emul_esd->decoderConfig->avgBitrate = btrt->avgBitrate; + avc->emul_esd->decoderConfig->maxBitrate = btrt->maxBitrate; + } + if (avc->descr) { + u32 i=0; + GF_Descriptor *desc,*clone; + i=0; + while ((desc = (GF_Descriptor *)gf_list_enum(avc->descr->descriptors, &i))) { + clone = NULL; + gf_odf_desc_copy(desc, &clone); + if (gf_odf_desc_add_desc((GF_Descriptor *)avc->emul_esd, clone) != GF_OK) + gf_odf_desc_del(clone); + } + } + if (avc->avc_config) { + avcc = avc->avc_config->config ? AVC_DuplicateConfig(avc->avc_config->config) : NULL; + /*merge SVC config*/ + if (avc->svc_config) { + merge_avc_config(avcc, avc->svc_config->config); + } + /*merge MVC config*/ + if (avc->mvc_config) { + merge_avc_config(avcc, avc->mvc_config->config); + } + if (avcc) { + if (mdia) merge_all_config(avcc, NULL, mdia); + + gf_odf_avc_cfg_write(avcc, &avc->emul_esd->decoderConfig->decoderSpecificInfo->data, &avc->emul_esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_odf_avc_cfg_del(avcc); + } + } else if (avc->svc_config) { + svcc = AVC_DuplicateConfig(avc->svc_config->config); + + if (mdia) merge_all_config(svcc, NULL, mdia); + + gf_odf_avc_cfg_write(svcc, &avc->emul_esd->decoderConfig->decoderSpecificInfo->data, &avc->emul_esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_odf_avc_cfg_del(svcc); + } + else if (avc->mvc_config) { + mvcc = AVC_DuplicateConfig(avc->mvc_config->config); + + if (mdia) merge_all_config(mvcc, NULL, mdia); + + gf_odf_avc_cfg_write(mvcc, &avc->emul_esd->decoderConfig->decoderSpecificInfo->data, &avc->emul_esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_odf_avc_cfg_del(mvcc); + } +} +",0,"void AVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *avc, GF_MediaBox *mdia) +{ + GF_AVCConfig *avcc, *svcc, *mvcc; + GF_BitRateBox *btrt = gf_isom_sample_entry_get_bitrate((GF_SampleEntryBox *)avc, GF_FALSE); + + if (avc->emul_esd) gf_odf_desc_del((GF_Descriptor *)avc->emul_esd); + avc->emul_esd = gf_odf_desc_esd_new(2); + avc->emul_esd->decoderConfig->streamType = GF_STREAM_VISUAL; + /*AVC OTI is 0x21, AVC parameter set stream OTI (not supported in gpac) is 0x22, SVC OTI is 0x24*/ + /*if we have only SVC stream, set objectTypeIndication to AVC OTI; else set it to AVC OTI*/ + if (avc->svc_config && !avc->avc_config) + avc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_SVC; + else if (avc->mvc_config && !avc->avc_config) + avc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_MVC; + else + avc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_AVC; + + if (btrt) { + avc->emul_esd->decoderConfig->bufferSizeDB = btrt->bufferSizeDB; + avc->emul_esd->decoderConfig->avgBitrate = btrt->avgBitrate; + avc->emul_esd->decoderConfig->maxBitrate = btrt->maxBitrate; + } + if (avc->descr) { + u32 i=0; + GF_Descriptor *desc,*clone; + i=0; + while ((desc = (GF_Descriptor *)gf_list_enum(avc->descr->descriptors, &i))) { + clone = NULL; + gf_odf_desc_copy(desc, &clone); + if (gf_odf_desc_add_desc((GF_Descriptor *)avc->emul_esd, clone) != GF_OK) + gf_odf_desc_del(clone); + } + } + if (avc->avc_config) { + avcc = avc->avc_config->config ? AVC_DuplicateConfig(avc->avc_config->config) : NULL; + /*merge SVC config*/ + if (avc->svc_config) { + merge_avc_config(avcc, avc->svc_config->config); + } + /*merge MVC config*/ + if (avc->mvc_config) { + merge_avc_config(avcc, avc->mvc_config->config); + } + if (avcc) { + if (mdia) merge_all_config(avcc, NULL, mdia); + + gf_odf_avc_cfg_write(avcc, &avc->emul_esd->decoderConfig->decoderSpecificInfo->data, &avc->emul_esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_odf_avc_cfg_del(avcc); + } + } else if (avc->svc_config) { + svcc = AVC_DuplicateConfig(avc->svc_config->config); + + if (mdia) merge_all_config(svcc, NULL, mdia); + + gf_odf_avc_cfg_write(svcc, &avc->emul_esd->decoderConfig->decoderSpecificInfo->data, &avc->emul_esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_odf_avc_cfg_del(svcc); + } + else if (avc->mvc_config) { + mvcc = AVC_DuplicateConfig(avc->mvc_config->config); + + if (mdia) merge_all_config(mvcc, NULL, mdia); + + gf_odf_avc_cfg_write(mvcc, &avc->emul_esd->decoderConfig->decoderSpecificInfo->data, &avc->emul_esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_odf_avc_cfg_del(mvcc); + } +} +","@@ -2413,6 +2413,8 @@ GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs) + op->output_layer_set_idx = gf_bs_read_u16(bs); + op->max_temporal_id = gf_bs_read_u8(bs); + op->layer_count = gf_bs_read_u8(bs); ++ if (op->layer_count > ARRAY_LENGTH(op->layers_info)) ++ return GF_NON_COMPLIANT_BITSTREAM; + for (j = 0; j < op->layer_count; j++) { + op->layers_info[j].ptl_idx = gf_bs_read_u8(bs); + op->layers_info[j].layer_id = gf_bs_read_int(bs, 6);",948,1184,2048 +18039,"read_SubStreamsInfo(struct archive_read *a, struct _7z_substream_info *ss, + struct _7z_folder *f, size_t numFolders) +{ + const unsigned char *p; + uint64_t *usizes; + size_t unpack_streams; + int type; + unsigned i; + uint32_t numDigests; + + memset(ss, 0, sizeof(*ss)); + + for (i = 0; i < numFolders; i++) + f[i].numUnpackStreams = 1; + + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + + if (type == kNumUnPackStream) { + unpack_streams = 0; + for (i = 0; i < numFolders; i++) { + if (parse_7zip_uint64(a, &(f[i].numUnpackStreams)) < 0) + return (-1); + if (UMAX_ENTRY < f[i].numUnpackStreams) + return (-1); + unpack_streams += (size_t)f[i].numUnpackStreams; + } + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + } else + unpack_streams = numFolders; + + ss->unpack_streams = unpack_streams; + if (unpack_streams) { + ss->unpackSizes = calloc(unpack_streams, + sizeof(*ss->unpackSizes)); + ss->digestsDefined = calloc(unpack_streams, + sizeof(*ss->digestsDefined)); + ss->digests = calloc(unpack_streams, + sizeof(*ss->digests)); + if (ss->unpackSizes == NULL || ss->digestsDefined == NULL || + ss->digests == NULL) + return (-1); + } + + usizes = ss->unpackSizes; + for (i = 0; i < numFolders; i++) { + unsigned pack; + uint64_t sum; + + if (f[i].numUnpackStreams == 0) + continue; + + sum = 0; + if (type == kSize) { + for (pack = 1; pack < f[i].numUnpackStreams; pack++) { + if (parse_7zip_uint64(a, usizes) < 0) + return (-1); + sum += *usizes++; + } + } + *usizes++ = folder_uncompressed_size(&f[i]) - sum; + } + + if (type == kSize) { + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + } + + for (i = 0; i < unpack_streams; i++) { + ss->digestsDefined[i] = 0; + ss->digests[i] = 0; + } + + numDigests = 0; + for (i = 0; i < numFolders; i++) { + if (f[i].numUnpackStreams != 1 || !f[i].digest_defined) + numDigests += (uint32_t)f[i].numUnpackStreams; + } + + if (type == kCRC) { + struct _7z_digests tmpDigests; + unsigned char *digestsDefined = ss->digestsDefined; + uint32_t * digests = ss->digests; + int di = 0; + + memset(&tmpDigests, 0, sizeof(tmpDigests)); + if (read_Digests(a, &(tmpDigests), numDigests) < 0) { + free_Digest(&tmpDigests); + return (-1); + } + for (i = 0; i < numFolders; i++) { + if (f[i].numUnpackStreams == 1 && f[i].digest_defined) { + *digestsDefined++ = 1; + *digests++ = f[i].digest; + } else { + unsigned j; + + for (j = 0; j < f[i].numUnpackStreams; + j++, di++) { + *digestsDefined++ = + tmpDigests.defineds[di]; + *digests++ = + tmpDigests.digests[di]; + } + } + } + free_Digest(&tmpDigests); + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + } + + /* + * Must be kEnd. + */ + if (type != kEnd) + return (-1); + return (0); +} +",1,"read_SubStreamsInfo(struct archive_read *a, struct _7z_substream_info *ss, + struct _7z_folder *f, size_t numFolders) +{ + const unsigned char *p; + uint64_t *usizes; + size_t unpack_streams; + int type; + unsigned i; + uint32_t numDigests; + + memset(ss, 0, sizeof(*ss)); + + for (i = 0; i < numFolders; i++) + f[i].numUnpackStreams = 1; + + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + + if (type == kNumUnPackStream) { + unpack_streams = 0; + for (i = 0; i < numFolders; i++) { + if (parse_7zip_uint64(a, &(f[i].numUnpackStreams)) < 0) + return (-1); + if (UMAX_ENTRY < f[i].numUnpackStreams) + return (-1); + if (unpack_streams > SIZE_MAX - UMAX_ENTRY) { + return (-1); + } + unpack_streams += (size_t)f[i].numUnpackStreams; + } + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + } else + unpack_streams = numFolders; + + ss->unpack_streams = unpack_streams; + if (unpack_streams) { + ss->unpackSizes = calloc(unpack_streams, + sizeof(*ss->unpackSizes)); + ss->digestsDefined = calloc(unpack_streams, + sizeof(*ss->digestsDefined)); + ss->digests = calloc(unpack_streams, + sizeof(*ss->digests)); + if (ss->unpackSizes == NULL || ss->digestsDefined == NULL || + ss->digests == NULL) + return (-1); + } + + usizes = ss->unpackSizes; + for (i = 0; i < numFolders; i++) { + unsigned pack; + uint64_t sum; + + if (f[i].numUnpackStreams == 0) + continue; + + sum = 0; + if (type == kSize) { + for (pack = 1; pack < f[i].numUnpackStreams; pack++) { + if (parse_7zip_uint64(a, usizes) < 0) + return (-1); + sum += *usizes++; + } + } + *usizes++ = folder_uncompressed_size(&f[i]) - sum; + } + + if (type == kSize) { + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + } + + for (i = 0; i < unpack_streams; i++) { + ss->digestsDefined[i] = 0; + ss->digests[i] = 0; + } + + numDigests = 0; + for (i = 0; i < numFolders; i++) { + if (f[i].numUnpackStreams != 1 || !f[i].digest_defined) + numDigests += (uint32_t)f[i].numUnpackStreams; + } + + if (type == kCRC) { + struct _7z_digests tmpDigests; + unsigned char *digestsDefined = ss->digestsDefined; + uint32_t * digests = ss->digests; + int di = 0; + + memset(&tmpDigests, 0, sizeof(tmpDigests)); + if (read_Digests(a, &(tmpDigests), numDigests) < 0) { + free_Digest(&tmpDigests); + return (-1); + } + for (i = 0; i < numFolders; i++) { + if (f[i].numUnpackStreams == 1 && f[i].digest_defined) { + *digestsDefined++ = 1; + *digests++ = f[i].digest; + } else { + unsigned j; + + for (j = 0; j < f[i].numUnpackStreams; + j++, di++) { + *digestsDefined++ = + tmpDigests.defineds[di]; + *digests++ = + tmpDigests.digests[di]; + } + } + } + free_Digest(&tmpDigests); + if ((p = header_bytes(a, 1)) == NULL) + return (-1); + type = *p; + } + + /* + * Must be kEnd. + */ + if (type != kEnd) + return (-1); + return (0); +} +","@@ -2153,6 +2153,9 @@ read_SubStreamsInfo(struct archive_read *a, struct _7z_substream_info *ss, + return (-1); + if (UMAX_ENTRY < f[i].numUnpackStreams) + return (-1); ++ if (unpack_streams > SIZE_MAX - UMAX_ENTRY) { ++ return (-1); ++ } + unpack_streams += (size_t)f[i].numUnpackStreams; + } + if ((p = header_bytes(a, 1)) == NULL)",970,1206,2048 +17656,"xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, + int what, xmlChar end, xmlChar end2, xmlChar end3) { + xmlChar *buffer = NULL; + size_t buffer_size = 0; + size_t nbchars = 0; + + xmlChar *current = NULL; + xmlChar *rep = NULL; + const xmlChar *last; + xmlEntityPtr ent; + int c,l; + + if ((ctxt == NULL) || (str == NULL) || (len < 0)) + return(NULL); + last = str + len; + + if (((ctxt->depth > 40) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) || + (ctxt->depth > 1024)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return(NULL); + } + + /* + * allocate a translation buffer. + */ + buffer_size = XML_PARSER_BIG_BUFFER_SIZE; + buffer = (xmlChar *) xmlMallocAtomic(buffer_size); + if (buffer == NULL) goto mem_error; + + /* + * OK loop until we reach one of the ending char or a size limit. + * we are operating on already parsed values. + */ + if (str < last) + c = CUR_SCHAR(str, l); + else + c = 0; + while ((c != 0) && (c != end) && /* non input consuming loop */ + (c != end2) && (c != end3)) { + + if (c == 0) break; + if ((c == '&') && (str[1] == '#')) { + int val = xmlParseStringCharRef(ctxt, &str); + if (val != 0) { + COPY_BUF(0,buffer,nbchars,val); + } + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) { + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + ""String decoding Entity Reference: %.30s\n"", + str); + ent = xmlParseStringEntityRef(ctxt, &str); + if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) || + (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR)) + goto int_error; + xmlParserEntityCheck(ctxt, 0, ent, 0); + if (ent != NULL) + ctxt->nbentities += ent->checked / 2; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (ent->content != NULL) { + COPY_BUF(0,buffer,nbchars,ent->content[0]); + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else { + xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, + ""predefined entity has no content\n""); + } + } else if ((ent != NULL) && (ent->content != NULL)) { + ctxt->depth++; + rep = xmlStringDecodeEntities(ctxt, ent->content, what, + 0, 0, 0); + ctxt->depth--; + + if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) || + (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR)) + goto int_error; + + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + xmlFree(rep); + rep = NULL; + } + } else if (ent != NULL) { + int i = xmlStrlen(ent->name); + const xmlChar *cur = ent->name; + + buffer[nbchars++] = '&'; + if (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE); + } + for (;i > 0;i--) + buffer[nbchars++] = *cur++; + buffer[nbchars++] = ';'; + } + } else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) { + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + ""String decoding PE Reference: %.30s\n"", str); + ent = xmlParseStringPEReference(ctxt, &str); + if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) + goto int_error; + xmlParserEntityCheck(ctxt, 0, ent, 0); + if (ent != NULL) + ctxt->nbentities += ent->checked / 2; + if (ent != NULL) { + if (ent->content == NULL) { + /* + * Note: external parsed entities will not be loaded, + * it is not required for a non-validating parser to + * complete external PEreferences coming from the + * internal subset + */ + if (((ctxt->options & XML_PARSE_NOENT) != 0) || + ((ctxt->options & XML_PARSE_DTDVALID) != 0) || + (ctxt->validate != 0)) { + xmlLoadEntityContent(ctxt, ent); + } else { + xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING, + ""not validating will not read content for PE entity %s\n"", + ent->name, NULL); + } + } + ctxt->depth++; + rep = xmlStringDecodeEntities(ctxt, ent->content, what, + 0, 0, 0); + ctxt->depth--; + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + xmlFree(rep); + rep = NULL; + } + } + } else { + COPY_BUF(l,buffer,nbchars,c); + str += l; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + if (str < last) + c = CUR_SCHAR(str, l); + else + c = 0; + } + buffer[nbchars] = 0; + return(buffer); + +mem_error: + xmlErrMemory(ctxt, NULL); +int_error: + if (rep != NULL) + xmlFree(rep); + if (buffer != NULL) + xmlFree(buffer); + return(NULL); +} +",0,"xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, + int what, xmlChar end, xmlChar end2, xmlChar end3) { + xmlChar *buffer = NULL; + size_t buffer_size = 0; + size_t nbchars = 0; + + xmlChar *current = NULL; + xmlChar *rep = NULL; + const xmlChar *last; + xmlEntityPtr ent; + int c,l; + + if ((ctxt == NULL) || (str == NULL) || (len < 0)) + return(NULL); + last = str + len; + + if (((ctxt->depth > 40) && + ((ctxt->options & XML_PARSE_HUGE) == 0)) || + (ctxt->depth > 1024)) { + xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); + return(NULL); + } + + /* + * allocate a translation buffer. + */ + buffer_size = XML_PARSER_BIG_BUFFER_SIZE; + buffer = (xmlChar *) xmlMallocAtomic(buffer_size); + if (buffer == NULL) goto mem_error; + + /* + * OK loop until we reach one of the ending char or a size limit. + * we are operating on already parsed values. + */ + if (str < last) + c = CUR_SCHAR(str, l); + else + c = 0; + while ((c != 0) && (c != end) && /* non input consuming loop */ + (c != end2) && (c != end3)) { + + if (c == 0) break; + if ((c == '&') && (str[1] == '#')) { + int val = xmlParseStringCharRef(ctxt, &str); + if (val != 0) { + COPY_BUF(0,buffer,nbchars,val); + } + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) { + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + ""String decoding Entity Reference: %.30s\n"", + str); + ent = xmlParseStringEntityRef(ctxt, &str); + if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) || + (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR)) + goto int_error; + xmlParserEntityCheck(ctxt, 0, ent, 0); + if (ent != NULL) + ctxt->nbentities += ent->checked / 2; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (ent->content != NULL) { + COPY_BUF(0,buffer,nbchars,ent->content[0]); + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } else { + xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, + ""predefined entity has no content\n""); + } + } else if ((ent != NULL) && (ent->content != NULL)) { + ctxt->depth++; + rep = xmlStringDecodeEntities(ctxt, ent->content, what, + 0, 0, 0); + ctxt->depth--; + + if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) || + (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR)) + goto int_error; + + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + xmlFree(rep); + rep = NULL; + } + } else if (ent != NULL) { + int i = xmlStrlen(ent->name); + const xmlChar *cur = ent->name; + + buffer[nbchars++] = '&'; + if (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE); + } + for (;i > 0;i--) + buffer[nbchars++] = *cur++; + buffer[nbchars++] = ';'; + } + } else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) { + if (xmlParserDebugEntities) + xmlGenericError(xmlGenericErrorContext, + ""String decoding PE Reference: %.30s\n"", str); + ent = xmlParseStringPEReference(ctxt, &str); + if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) + goto int_error; + xmlParserEntityCheck(ctxt, 0, ent, 0); + if (ent != NULL) + ctxt->nbentities += ent->checked / 2; + if (ent != NULL) { + if (ent->content == NULL) { + /* + * Note: external parsed entities will not be loaded, + * it is not required for a non-validating parser to + * complete external PEreferences coming from the + * internal subset + */ + if (((ctxt->options & XML_PARSE_NOENT) != 0) || + ((ctxt->options & XML_PARSE_DTDVALID) != 0) || + (ctxt->validate != 0)) { + xmlLoadEntityContent(ctxt, ent); + } else { + xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING, + ""not validating will not read content for PE entity %s\n"", + ent->name, NULL); + } + } + ctxt->depth++; + rep = xmlStringDecodeEntities(ctxt, ent->content, what, + 0, 0, 0); + ctxt->depth--; + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming loop */ + buffer[nbchars++] = *current++; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + if (xmlParserEntityCheck(ctxt, nbchars, ent, 0)) + goto int_error; + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + xmlFree(rep); + rep = NULL; + } + } + } else { + COPY_BUF(l,buffer,nbchars,c); + str += l; + if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) { + growBuffer(buffer, XML_PARSER_BUFFER_SIZE); + } + } + if (str < last) + c = CUR_SCHAR(str, l); + else + c = 0; + } + buffer[nbchars] = 0; + return(buffer); + +mem_error: + xmlErrMemory(ctxt, NULL); +int_error: + if (rep != NULL) + xmlFree(rep); + if (buffer != NULL) + xmlFree(buffer); + return(NULL); +} +","@@ -8130,6 +8130,14 @@ + + if (xmlPushInput(ctxt, input) < 0) + return; + } else { ++ if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && ++ ((ctxt->options & XML_PARSE_NOENT) == 0) && ++ ((ctxt->options & XML_PARSE_DTDVALID) == 0) && ++ ((ctxt->options & XML_PARSE_DTDLOAD) == 0) && ++ ((ctxt->options & XML_PARSE_DTDATTR) == 0) && ++ (ctxt->replaceEntities == 0) && ++ (ctxt->validate == 0)) ++ return; + /* + * TODO !!! + * handle the extra spaces added before and after +",1415,1651,2048 +3602,"print_ccp_config_options(netdissect_options *ndo, + const u_char *p, int length) +{ + int len, opt; + + if (length < 2) + return 0; + ND_TCHECK2(*p, 2); + len = p[1]; + opt = p[0]; + if (length < len) + return 0; + if (len < 2) { + ND_PRINT((ndo, ""\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)"", + tok2str(ccpconfopts_values, ""Unknown"", opt), + opt, + len)); + return 0; + } + + ND_PRINT((ndo, ""\n\t %s Option (0x%02x), length %u"", + tok2str(ccpconfopts_values, ""Unknown"", opt), + opt, + len)); + + switch (opt) { + case CCPOPT_BSDCOMP: + if (len < 3) { + ND_PRINT((ndo, "" (length bogus, should be >= 3)"")); + return len; + } + ND_TCHECK2(*(p + 2), 1); + ND_PRINT((ndo, "": Version: %u, Dictionary Bits: %u"", + p[2] >> 5, p[2] & 0x1f)); + break; + case CCPOPT_MVRCA: + if (len < 4) { + ND_PRINT((ndo, "" (length bogus, should be >= 4)"")); + return len; + } + ND_TCHECK2(*(p + 2), 1); + ND_PRINT((ndo, "": Features: %u, PxP: %s, History: %u, #CTX-ID: %u"", + (p[2] & 0xc0) >> 6, + (p[2] & 0x20) ? ""Enabled"" : ""Disabled"", + p[2] & 0x1f, p[3])); + break; + case CCPOPT_DEFLATE: + if (len < 4) { + ND_PRINT((ndo, "" (length bogus, should be >= 4)"")); + return len; + } + ND_TCHECK2(*(p + 2), 1); + ND_PRINT((ndo, "": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u"", + (p[2] & 0xf0) >> 4, + ((p[2] & 0x0f) == 8) ? ""zlib"" : ""unkown"", + p[2] & 0x0f, (p[3] & 0xfc) >> 2, p[3] & 0x03)); + break; + +/* XXX: to be supported */ +#if 0 + case CCPOPT_OUI: + case CCPOPT_PRED1: + case CCPOPT_PRED2: + case CCPOPT_PJUMP: + case CCPOPT_HPPPC: + case CCPOPT_STACLZS: + case CCPOPT_MPPC: + case CCPOPT_GFZA: + case CCPOPT_V42BIS: + case CCPOPT_LZSDCP: + case CCPOPT_DEC: + case CCPOPT_RESV: + break; +#endif + default: + /* + * Unknown option; dump it as raw bytes now if we're + * not going to do so below. + */ + if (ndo->ndo_vflag < 2) + print_unknown_data(ndo, &p[2], ""\n\t "", len - 2); + break; + } + if (ndo->ndo_vflag > 1) + print_unknown_data(ndo, &p[2], ""\n\t "", len - 2); /* exclude TLV header */ + + return len; + +trunc: + ND_PRINT((ndo, ""[|ccp]"")); + return 0; +} +",0,"print_ccp_config_options(netdissect_options *ndo, + const u_char *p, int length) +{ + int len, opt; + + if (length < 2) + return 0; + ND_TCHECK2(*p, 2); + len = p[1]; + opt = p[0]; + if (length < len) + return 0; + if (len < 2) { + ND_PRINT((ndo, ""\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)"", + tok2str(ccpconfopts_values, ""Unknown"", opt), + opt, + len)); + return 0; + } + + ND_PRINT((ndo, ""\n\t %s Option (0x%02x), length %u"", + tok2str(ccpconfopts_values, ""Unknown"", opt), + opt, + len)); + + switch (opt) { + case CCPOPT_BSDCOMP: + if (len < 3) { + ND_PRINT((ndo, "" (length bogus, should be >= 3)"")); + return len; + } + ND_TCHECK2(*(p + 2), 1); + ND_PRINT((ndo, "": Version: %u, Dictionary Bits: %u"", + p[2] >> 5, p[2] & 0x1f)); + break; + case CCPOPT_MVRCA: + if (len < 4) { + ND_PRINT((ndo, "" (length bogus, should be >= 4)"")); + return len; + } + ND_TCHECK2(*(p + 2), 1); + ND_PRINT((ndo, "": Features: %u, PxP: %s, History: %u, #CTX-ID: %u"", + (p[2] & 0xc0) >> 6, + (p[2] & 0x20) ? ""Enabled"" : ""Disabled"", + p[2] & 0x1f, p[3])); + break; + case CCPOPT_DEFLATE: + if (len < 4) { + ND_PRINT((ndo, "" (length bogus, should be >= 4)"")); + return len; + } + ND_TCHECK2(*(p + 2), 1); + ND_PRINT((ndo, "": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u"", + (p[2] & 0xf0) >> 4, + ((p[2] & 0x0f) == 8) ? ""zlib"" : ""unkown"", + p[2] & 0x0f, (p[3] & 0xfc) >> 2, p[3] & 0x03)); + break; + +/* XXX: to be supported */ +#if 0 + case CCPOPT_OUI: + case CCPOPT_PRED1: + case CCPOPT_PRED2: + case CCPOPT_PJUMP: + case CCPOPT_HPPPC: + case CCPOPT_STACLZS: + case CCPOPT_MPPC: + case CCPOPT_GFZA: + case CCPOPT_V42BIS: + case CCPOPT_LZSDCP: + case CCPOPT_DEC: + case CCPOPT_RESV: + break; +#endif + default: + /* + * Unknown option; dump it as raw bytes now if we're + * not going to do so below. + */ + if (ndo->ndo_vflag < 2) + print_unknown_data(ndo, &p[2], ""\n\t "", len - 2); + break; + } + if (ndo->ndo_vflag > 1) + print_unknown_data(ndo, &p[2], ""\n\t "", len - 2); /* exclude TLV header */ + + return len; + +trunc: + ND_PRINT((ndo, ""[|ccp]"")); + return 0; +} +","@@ -1351,14 +1351,15 @@ static void + ppp_hdlc(netdissect_options *ndo, + const u_char *p, int length) + { +- u_char *b, *s, *t, c; ++ u_char *b, *t, c; ++ const u_char *s; + int i, proto; + const void *se; + + if (length <= 0) + return; + +- b = (uint8_t *)malloc(length); ++ b = (u_char *)malloc(length); + if (b == NULL) + return; + +@@ -1367,14 +1368,13 @@ ppp_hdlc(netdissect_options *ndo, + * Do this so that we dont overwrite the original packet + * contents. + */ +- for (s = (u_char *)p, t = b, i = length; i > 0; i--) { ++ for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) { + c = *s++; + if (c == 0x7d) { +- if (i > 1) { +- i--; +- c = *s++ ^ 0x20; +- } else +- continue; ++ if (i <= 1 || !ND_TTEST(*s)) ++ break; ++ i--; ++ c = *s++ ^ 0x20; + } + *t++ = c; + }",859,1095,2048 +18569,"void RenderProcessHostImpl::CreateMessageFilters() { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + AddFilter(new ResourceSchedulerFilter(GetID())); + MediaInternals* media_internals = MediaInternals::GetInstance(); + scoped_refptr bp_message_filter( + new BrowserPluginMessageFilter(GetID())); + AddFilter(bp_message_filter.get()); + + scoped_refptr request_context( + storage_partition_impl_->GetURLRequestContext()); + scoped_refptr render_message_filter( + new RenderMessageFilter( + GetID(), GetBrowserContext(), request_context.get(), + widget_helper_.get(), media_internals, + storage_partition_impl_->GetDOMStorageContext(), + storage_partition_impl_->GetCacheStorageContext())); + AddFilter(render_message_filter.get()); + + render_frame_message_filter_ = new RenderFrameMessageFilter( + GetID(), +#if BUILDFLAG(ENABLE_PLUGINS) + PluginServiceImpl::GetInstance(), +#else + nullptr, +#endif + GetBrowserContext(), + request_context.get(), + widget_helper_.get()); + AddFilter(render_frame_message_filter_.get()); + + BrowserContext* browser_context = GetBrowserContext(); + ResourceContext* resource_context = browser_context->GetResourceContext(); + + scoped_refptr media_request_context( + GetStoragePartition()->GetMediaURLRequestContext()); + + ResourceMessageFilter::GetContextsCallback get_contexts_callback( + base::Bind(&GetContexts, browser_context->GetResourceContext(), + request_context, media_request_context)); + + scoped_refptr blob_storage_context = + ChromeBlobStorageContext::GetFor(browser_context); + + resource_message_filter_ = new ResourceMessageFilter( + GetID(), storage_partition_impl_->GetAppCacheService(), + blob_storage_context.get(), + storage_partition_impl_->GetFileSystemContext(), + storage_partition_impl_->GetServiceWorkerContext(), + get_contexts_callback); + + AddFilter(resource_message_filter_.get()); + + media::AudioManager* audio_manager = + BrowserMainLoop::GetInstance()->audio_manager(); + MediaStreamManager* media_stream_manager = + BrowserMainLoop::GetInstance()->media_stream_manager(); + audio_input_renderer_host_ = new AudioInputRendererHost( + GetID(), base::GetProcId(GetHandle()), audio_manager, + media_stream_manager, AudioMirroringManager::GetInstance(), + BrowserMainLoop::GetInstance()->user_input_monitor()); + AddFilter(audio_input_renderer_host_.get()); + audio_renderer_host_ = new AudioRendererHost( + GetID(), audio_manager, AudioMirroringManager::GetInstance(), + media_stream_manager, + browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); + AddFilter(audio_renderer_host_.get()); + AddFilter( + new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); + AddFilter(new AppCacheDispatcherHost( + storage_partition_impl_->GetAppCacheService(), GetID())); + AddFilter(new ClipboardMessageFilter(blob_storage_context)); + AddFilter(new DOMStorageMessageFilter( + storage_partition_impl_->GetDOMStorageContext())); + +#if BUILDFLAG(ENABLE_WEBRTC) + peer_connection_tracker_host_ = new PeerConnectionTrackerHost( + GetID(), webrtc_eventlog_host_.GetWeakPtr()); + AddFilter(peer_connection_tracker_host_.get()); + AddFilter(new MediaStreamDispatcherHost( + GetID(), browser_context->GetResourceContext()->GetMediaDeviceIDSalt(), + media_stream_manager)); + AddFilter(new MediaStreamTrackMetricsHost()); +#endif +#if BUILDFLAG(ENABLE_PLUGINS) + AddFilter(new PepperRendererConnection(GetID())); +#endif + AddFilter(new SpeechRecognitionDispatcherHost( + GetID(), storage_partition_impl_->GetURLRequestContext())); + AddFilter(new FileAPIMessageFilter( + GetID(), storage_partition_impl_->GetURLRequestContext(), + storage_partition_impl_->GetFileSystemContext(), + blob_storage_context.get(), StreamContext::GetFor(browser_context))); + AddFilter(new BlobDispatcherHost( + GetID(), blob_storage_context, + make_scoped_refptr(storage_partition_impl_->GetFileSystemContext()))); + AddFilter(new FileUtilitiesMessageFilter(GetID())); + AddFilter( + new DatabaseMessageFilter(storage_partition_impl_->GetDatabaseTracker())); +#if defined(OS_MACOSX) + AddFilter(new TextInputClientMessageFilter()); +#elif defined(OS_WIN) + AddFilter(new DWriteFontProxyMessageFilter()); + + channel_->AddFilter(new FontCacheDispatcher()); +#endif + + message_port_message_filter_ = new MessagePortMessageFilter( + base::Bind(&RenderWidgetHelper::GetNextRoutingID, + base::Unretained(widget_helper_.get()))); + AddFilter(message_port_message_filter_.get()); + + scoped_refptr cache_storage_filter = + new CacheStorageDispatcherHost(); + cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); + AddFilter(cache_storage_filter.get()); + + scoped_refptr service_worker_filter = + new ServiceWorkerDispatcherHost( + GetID(), message_port_message_filter_.get(), resource_context); + service_worker_filter->Init( + storage_partition_impl_->GetServiceWorkerContext()); + AddFilter(service_worker_filter.get()); + + AddFilter(new SharedWorkerMessageFilter( + GetID(), resource_context, + WorkerStoragePartition( + storage_partition_impl_->GetURLRequestContext(), + storage_partition_impl_->GetMediaURLRequestContext(), + storage_partition_impl_->GetAppCacheService(), + storage_partition_impl_->GetQuotaManager(), + storage_partition_impl_->GetFileSystemContext(), + storage_partition_impl_->GetDatabaseTracker(), + storage_partition_impl_->GetIndexedDBContext(), + storage_partition_impl_->GetServiceWorkerContext()), + message_port_message_filter_.get())); + +#if BUILDFLAG(ENABLE_WEBRTC) + p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( + resource_context, request_context.get()); + AddFilter(p2p_socket_dispatcher_host_.get()); +#endif + + AddFilter(new TraceMessageFilter(GetID())); + AddFilter(new ResolveProxyMsgHelper(request_context.get())); + AddFilter(new QuotaDispatcherHost( + GetID(), storage_partition_impl_->GetQuotaManager(), + GetContentClient()->browser()->CreateQuotaPermissionContext())); + + scoped_refptr service_worker_context( + static_cast( + storage_partition_impl_->GetServiceWorkerContext())); + notification_message_filter_ = new NotificationMessageFilter( + GetID(), storage_partition_impl_->GetPlatformNotificationContext(), + resource_context, service_worker_context, browser_context); + AddFilter(notification_message_filter_.get()); + + AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); + AddFilter(new HistogramMessageFilter()); + AddFilter(new MemoryMessageFilter(this)); + AddFilter(new PushMessagingMessageFilter( + GetID(), storage_partition_impl_->GetServiceWorkerContext())); +#if defined(OS_ANDROID) + AddFilter(new ScreenOrientationListenerAndroid()); + synchronous_compositor_filter_ = + new SynchronousCompositorBrowserFilter(GetID()); + AddFilter(synchronous_compositor_filter_.get()); +#endif +} +",1,"void RenderProcessHostImpl::CreateMessageFilters() { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + AddFilter(new ResourceSchedulerFilter(GetID())); + MediaInternals* media_internals = MediaInternals::GetInstance(); + scoped_refptr bp_message_filter( + new BrowserPluginMessageFilter(GetID())); + AddFilter(bp_message_filter.get()); + + scoped_refptr request_context( + storage_partition_impl_->GetURLRequestContext()); + scoped_refptr render_message_filter( + new RenderMessageFilter( + GetID(), GetBrowserContext(), request_context.get(), + widget_helper_.get(), media_internals, + storage_partition_impl_->GetDOMStorageContext(), + storage_partition_impl_->GetCacheStorageContext())); + AddFilter(render_message_filter.get()); + + render_frame_message_filter_ = new RenderFrameMessageFilter( + GetID(), +#if BUILDFLAG(ENABLE_PLUGINS) + PluginServiceImpl::GetInstance(), +#else + nullptr, +#endif + GetBrowserContext(), + request_context.get(), + widget_helper_.get()); + AddFilter(render_frame_message_filter_.get()); + + BrowserContext* browser_context = GetBrowserContext(); + ResourceContext* resource_context = browser_context->GetResourceContext(); + + scoped_refptr media_request_context( + GetStoragePartition()->GetMediaURLRequestContext()); + + ResourceMessageFilter::GetContextsCallback get_contexts_callback( + base::Bind(&GetContexts, browser_context->GetResourceContext(), + request_context, media_request_context)); + + scoped_refptr blob_storage_context = + ChromeBlobStorageContext::GetFor(browser_context); + + resource_message_filter_ = new ResourceMessageFilter( + GetID(), storage_partition_impl_->GetAppCacheService(), + blob_storage_context.get(), + storage_partition_impl_->GetFileSystemContext(), + storage_partition_impl_->GetServiceWorkerContext(), + get_contexts_callback); + + AddFilter(resource_message_filter_.get()); + + media::AudioManager* audio_manager = + BrowserMainLoop::GetInstance()->audio_manager(); + MediaStreamManager* media_stream_manager = + BrowserMainLoop::GetInstance()->media_stream_manager(); + audio_input_renderer_host_ = new AudioInputRendererHost( + GetID(), base::GetProcId(GetHandle()), audio_manager, + media_stream_manager, AudioMirroringManager::GetInstance(), + BrowserMainLoop::GetInstance()->user_input_monitor()); + AddFilter(audio_input_renderer_host_.get()); + audio_renderer_host_ = new AudioRendererHost( + GetID(), audio_manager, BrowserMainLoop::GetInstance()->audio_system(), + AudioMirroringManager::GetInstance(), media_stream_manager, + browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); + AddFilter(audio_renderer_host_.get()); + AddFilter( + new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_service())); + AddFilter(new AppCacheDispatcherHost( + storage_partition_impl_->GetAppCacheService(), GetID())); + AddFilter(new ClipboardMessageFilter(blob_storage_context)); + AddFilter(new DOMStorageMessageFilter( + storage_partition_impl_->GetDOMStorageContext())); + +#if BUILDFLAG(ENABLE_WEBRTC) + peer_connection_tracker_host_ = new PeerConnectionTrackerHost( + GetID(), webrtc_eventlog_host_.GetWeakPtr()); + AddFilter(peer_connection_tracker_host_.get()); + AddFilter(new MediaStreamDispatcherHost( + GetID(), browser_context->GetResourceContext()->GetMediaDeviceIDSalt(), + media_stream_manager)); + AddFilter(new MediaStreamTrackMetricsHost()); +#endif +#if BUILDFLAG(ENABLE_PLUGINS) + AddFilter(new PepperRendererConnection(GetID())); +#endif + AddFilter(new SpeechRecognitionDispatcherHost( + GetID(), storage_partition_impl_->GetURLRequestContext())); + AddFilter(new FileAPIMessageFilter( + GetID(), storage_partition_impl_->GetURLRequestContext(), + storage_partition_impl_->GetFileSystemContext(), + blob_storage_context.get(), StreamContext::GetFor(browser_context))); + AddFilter(new BlobDispatcherHost( + GetID(), blob_storage_context, + make_scoped_refptr(storage_partition_impl_->GetFileSystemContext()))); + AddFilter(new FileUtilitiesMessageFilter(GetID())); + AddFilter( + new DatabaseMessageFilter(storage_partition_impl_->GetDatabaseTracker())); +#if defined(OS_MACOSX) + AddFilter(new TextInputClientMessageFilter()); +#elif defined(OS_WIN) + AddFilter(new DWriteFontProxyMessageFilter()); + + channel_->AddFilter(new FontCacheDispatcher()); +#endif + + message_port_message_filter_ = new MessagePortMessageFilter( + base::Bind(&RenderWidgetHelper::GetNextRoutingID, + base::Unretained(widget_helper_.get()))); + AddFilter(message_port_message_filter_.get()); + + scoped_refptr cache_storage_filter = + new CacheStorageDispatcherHost(); + cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); + AddFilter(cache_storage_filter.get()); + + scoped_refptr service_worker_filter = + new ServiceWorkerDispatcherHost( + GetID(), message_port_message_filter_.get(), resource_context); + service_worker_filter->Init( + storage_partition_impl_->GetServiceWorkerContext()); + AddFilter(service_worker_filter.get()); + + AddFilter(new SharedWorkerMessageFilter( + GetID(), resource_context, + WorkerStoragePartition( + storage_partition_impl_->GetURLRequestContext(), + storage_partition_impl_->GetMediaURLRequestContext(), + storage_partition_impl_->GetAppCacheService(), + storage_partition_impl_->GetQuotaManager(), + storage_partition_impl_->GetFileSystemContext(), + storage_partition_impl_->GetDatabaseTracker(), + storage_partition_impl_->GetIndexedDBContext(), + storage_partition_impl_->GetServiceWorkerContext()), + message_port_message_filter_.get())); + +#if BUILDFLAG(ENABLE_WEBRTC) + p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( + resource_context, request_context.get()); + AddFilter(p2p_socket_dispatcher_host_.get()); +#endif + + AddFilter(new TraceMessageFilter(GetID())); + AddFilter(new ResolveProxyMsgHelper(request_context.get())); + AddFilter(new QuotaDispatcherHost( + GetID(), storage_partition_impl_->GetQuotaManager(), + GetContentClient()->browser()->CreateQuotaPermissionContext())); + + scoped_refptr service_worker_context( + static_cast( + storage_partition_impl_->GetServiceWorkerContext())); + notification_message_filter_ = new NotificationMessageFilter( + GetID(), storage_partition_impl_->GetPlatformNotificationContext(), + resource_context, service_worker_context, browser_context); + AddFilter(notification_message_filter_.get()); + + AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); + AddFilter(new HistogramMessageFilter()); + AddFilter(new MemoryMessageFilter(this)); + AddFilter(new PushMessagingMessageFilter( + GetID(), storage_partition_impl_->GetServiceWorkerContext())); +#if defined(OS_ANDROID) + AddFilter(new ScreenOrientationListenerAndroid()); + synchronous_compositor_filter_ = + new SynchronousCompositorBrowserFilter(GetID()); + AddFilter(synchronous_compositor_filter_.get()); +#endif +} +","@@ -1089,8 +1089,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { + BrowserMainLoop::GetInstance()->user_input_monitor()); + AddFilter(audio_input_renderer_host_.get()); + audio_renderer_host_ = new AudioRendererHost( +- GetID(), audio_manager, AudioMirroringManager::GetInstance(), +- media_stream_manager, ++ GetID(), audio_manager, BrowserMainLoop::GetInstance()->audio_system(), ++ AudioMirroringManager::GetInstance(), media_stream_manager, + browser_context->GetResourceContext()->GetMediaDeviceIDSalt()); + AddFilter(audio_renderer_host_.get()); + AddFilter(",1446,1682,2048 +14882,"bool RenderFrameHostManager::InitRenderFrame( + RenderFrameHostImpl* render_frame_host) { + if (render_frame_host->IsRenderFrameLive()) + return true; + + SiteInstance* site_instance = render_frame_host->GetSiteInstance(); + + int opener_routing_id = MSG_ROUTING_NONE; + if (frame_tree_node_->opener()) + opener_routing_id = GetOpenerRoutingID(site_instance); + + int parent_routing_id = MSG_ROUTING_NONE; + if (frame_tree_node_->parent()) { + parent_routing_id = frame_tree_node_->parent() + ->render_manager() + ->GetRoutingIdForSiteInstance(site_instance); + CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); + } + + int previous_sibling_routing_id = MSG_ROUTING_NONE; + FrameTreeNode* previous_sibling = frame_tree_node_->PreviousSibling(); + if (previous_sibling) { + previous_sibling_routing_id = + previous_sibling->render_manager()->GetRoutingIdForSiteInstance( + site_instance); + CHECK_NE(previous_sibling_routing_id, MSG_ROUTING_NONE); + } + + int proxy_routing_id = MSG_ROUTING_NONE; + RenderFrameProxyHost* existing_proxy = GetRenderFrameProxyHost(site_instance); + if (existing_proxy) { + proxy_routing_id = existing_proxy->GetRoutingID(); + CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); + if (!existing_proxy->is_render_frame_proxy_live()) + existing_proxy->InitRenderFrameProxy(); + } + + if (!existing_proxy && frame_tree_node_->parent()) { + RenderFrameProxyHost* parent_proxy = RenderFrameProxyHost::FromID( + render_frame_host->GetProcess()->GetID(), parent_routing_id); + if (!parent_proxy || !parent_proxy->is_render_frame_proxy_live()) { + base::debug::SetCrashKeyValue(""initrf_parent_proxy_exists"", + parent_proxy ? ""yes"" : ""no""); + + SiteInstance* parent_instance = + frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); + base::debug::SetCrashKeyValue( + ""initrf_parent_is_in_same_site_instance"", + site_instance == parent_instance ? ""yes"" : ""no""); + base::debug::SetCrashKeyValue(""initrf_parent_process_is_live"", + frame_tree_node_->parent() + ->current_frame_host() + ->GetProcess() + ->HasConnection() + ? ""yes"" + : ""no""); + base::debug::SetCrashKeyValue( + ""initrf_render_view_is_live"", + render_frame_host->render_view_host()->IsRenderViewLive() ? ""yes"" + : ""no""); + + FrameTreeNode* root = frame_tree_node_->frame_tree()->root(); + if (root != frame_tree_node_->parent()) { + SiteInstance* root_instance = + root->current_frame_host()->GetSiteInstance(); + base::debug::SetCrashKeyValue( + ""initrf_root_is_in_same_site_instance"", + site_instance == root_instance ? ""yes"" : ""no""); + base::debug::SetCrashKeyValue( + ""initrf_root_is_in_same_site_instance_as_parent"", + parent_instance == root_instance ? ""yes"" : ""no""); + base::debug::SetCrashKeyValue(""initrf_root_process_is_live"", + frame_tree_node_->frame_tree() + ->root() + ->current_frame_host() + ->GetProcess() + ->HasConnection() + ? ""yes"" + : ""no""); + + RenderFrameProxyHost* top_proxy = + root->render_manager()->GetRenderFrameProxyHost(site_instance); + if (top_proxy) { + base::debug::SetCrashKeyValue( + ""initrf_root_proxy_is_live"", + top_proxy->is_render_frame_proxy_live() ? ""yes"" : ""no""); + } + } + + base::debug::DumpWithoutCrashing(); + } + } + + return delegate_->CreateRenderFrameForRenderManager( + render_frame_host, proxy_routing_id, opener_routing_id, parent_routing_id, + previous_sibling_routing_id); +} +",0,"bool RenderFrameHostManager::InitRenderFrame( + RenderFrameHostImpl* render_frame_host) { + if (render_frame_host->IsRenderFrameLive()) + return true; + + SiteInstance* site_instance = render_frame_host->GetSiteInstance(); + + int opener_routing_id = MSG_ROUTING_NONE; + if (frame_tree_node_->opener()) + opener_routing_id = GetOpenerRoutingID(site_instance); + + int parent_routing_id = MSG_ROUTING_NONE; + if (frame_tree_node_->parent()) { + parent_routing_id = frame_tree_node_->parent() + ->render_manager() + ->GetRoutingIdForSiteInstance(site_instance); + CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); + } + + int previous_sibling_routing_id = MSG_ROUTING_NONE; + FrameTreeNode* previous_sibling = frame_tree_node_->PreviousSibling(); + if (previous_sibling) { + previous_sibling_routing_id = + previous_sibling->render_manager()->GetRoutingIdForSiteInstance( + site_instance); + CHECK_NE(previous_sibling_routing_id, MSG_ROUTING_NONE); + } + + int proxy_routing_id = MSG_ROUTING_NONE; + RenderFrameProxyHost* existing_proxy = GetRenderFrameProxyHost(site_instance); + if (existing_proxy) { + proxy_routing_id = existing_proxy->GetRoutingID(); + CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); + if (!existing_proxy->is_render_frame_proxy_live()) + existing_proxy->InitRenderFrameProxy(); + } + + if (!existing_proxy && frame_tree_node_->parent()) { + RenderFrameProxyHost* parent_proxy = RenderFrameProxyHost::FromID( + render_frame_host->GetProcess()->GetID(), parent_routing_id); + if (!parent_proxy || !parent_proxy->is_render_frame_proxy_live()) { + base::debug::SetCrashKeyValue(""initrf_parent_proxy_exists"", + parent_proxy ? ""yes"" : ""no""); + + SiteInstance* parent_instance = + frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); + base::debug::SetCrashKeyValue( + ""initrf_parent_is_in_same_site_instance"", + site_instance == parent_instance ? ""yes"" : ""no""); + base::debug::SetCrashKeyValue(""initrf_parent_process_is_live"", + frame_tree_node_->parent() + ->current_frame_host() + ->GetProcess() + ->HasConnection() + ? ""yes"" + : ""no""); + base::debug::SetCrashKeyValue( + ""initrf_render_view_is_live"", + render_frame_host->render_view_host()->IsRenderViewLive() ? ""yes"" + : ""no""); + + FrameTreeNode* root = frame_tree_node_->frame_tree()->root(); + if (root != frame_tree_node_->parent()) { + SiteInstance* root_instance = + root->current_frame_host()->GetSiteInstance(); + base::debug::SetCrashKeyValue( + ""initrf_root_is_in_same_site_instance"", + site_instance == root_instance ? ""yes"" : ""no""); + base::debug::SetCrashKeyValue( + ""initrf_root_is_in_same_site_instance_as_parent"", + parent_instance == root_instance ? ""yes"" : ""no""); + base::debug::SetCrashKeyValue(""initrf_root_process_is_live"", + frame_tree_node_->frame_tree() + ->root() + ->current_frame_host() + ->GetProcess() + ->HasConnection() + ? ""yes"" + : ""no""); + + RenderFrameProxyHost* top_proxy = + root->render_manager()->GetRenderFrameProxyHost(site_instance); + if (top_proxy) { + base::debug::SetCrashKeyValue( + ""initrf_root_proxy_is_live"", + top_proxy->is_render_frame_proxy_live() ? ""yes"" : ""no""); + } + } + + base::debug::DumpWithoutCrashing(); + } + } + + return delegate_->CreateRenderFrameForRenderManager( + render_frame_host, proxy_routing_id, opener_routing_id, parent_routing_id, + previous_sibling_routing_id); +} +","@@ -61,7 +61,6 @@ RenderFrameHostManager::RenderFrameHostManager( + delegate_(delegate), + render_frame_delegate_(render_frame_delegate), + render_widget_delegate_(render_widget_delegate), +- interstitial_page_(nullptr), + weak_factory_(this) { + DCHECK(frame_tree_node_); + } +@@ -133,8 +132,8 @@ WebUIImpl* RenderFrameHostManager::GetNavigatingWebUI() const { + } + + RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const { +- if (interstitial_page_) +- return interstitial_page_->GetView(); ++ if (delegate_->GetInterstitialForRenderManager()) ++ return delegate_->GetInterstitialForRenderManager()->GetView(); + if (render_frame_host_) + return render_frame_host_->GetView(); + return nullptr; +@@ -1424,7 +1423,7 @@ RenderFrameHostManager::DetermineSiteInstanceForURL( + // SiteInstances if you type in a cross-site URL. This means we have to + // compare the entry's URL to the last committed entry's URL. + NavigationEntry* current_entry = controller.GetLastCommittedEntry(); +- if (interstitial_page_) { ++ if (delegate_->GetInterstitialForRenderManager()) { + // The interstitial is currently the last committed entry, but we want to + // compare against the last non-interstitial entry. + current_entry = controller.GetEntryAtOffset(-1); +@@ -2825,13 +2824,13 @@ bool RenderFrameHostManager::CanSubframeSwapProcess( + } + + void RenderFrameHostManager::EnsureRenderFrameHostVisibilityConsistent() { +- if (render_frame_host_->GetView() && +- render_frame_host_->render_view_host()->GetWidget()->is_hidden() != +- delegate_->IsHidden()) { ++ RenderWidgetHostView* view = GetRenderWidgetHostView(); ++ if (view && static_cast(view->GetRenderWidgetHost()) ++ ->is_hidden() != delegate_->IsHidden()) { + if (delegate_->IsHidden()) { +- render_frame_host_->GetView()->Hide(); ++ view->Hide(); + } else { +- render_frame_host_->GetView()->Show(); ++ view->Show(); + } + } + }",832,1068,2048 +6733,"static int lookup_open(struct nameidata *nd, struct path *path, + struct file *file, + const struct open_flags *op, + bool got_write, int *opened) +{ + struct dentry *dir = nd->path.dentry; + struct inode *dir_inode = dir->d_inode; + int open_flag = op->open_flag; + struct dentry *dentry; + int error, create_error = 0; + umode_t mode = op->mode; + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); + + if (unlikely(IS_DEADDIR(dir_inode))) + return -ENOENT; + + *opened &= ~FILE_CREATED; + dentry = d_lookup(dir, &nd->last); + for (;;) { + if (!dentry) { + dentry = d_alloc_parallel(dir, &nd->last, &wq); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); + } + if (d_in_lookup(dentry)) + break; + + error = d_revalidate(dentry, nd->flags); + if (likely(error > 0)) + break; + if (error) + goto out_dput; + d_invalidate(dentry); + dput(dentry); + dentry = NULL; + } + if (dentry->d_inode) { + /* Cached positive dentry: will open in f_op->open */ + goto out_no_open; + } + + /* + * Checking write permission is tricky, bacuse we don't know if we are + * going to actually need it: O_CREAT opens should work as long as the + * file exists. But checking existence breaks atomicity. The trick is + * to check access and if not granted clear O_CREAT from the flags. + * + * Another problem is returing the ""right"" error value (e.g. for an + * O_EXCL open we want to return EEXIST not EROFS). + */ + if (open_flag & O_CREAT) { + if (!IS_POSIXACL(dir->d_inode)) + mode &= ~current_umask(); + if (unlikely(!got_write)) { + create_error = -EROFS; + open_flag &= ~O_CREAT; + if (open_flag & (O_EXCL | O_TRUNC)) + goto no_open; + /* No side effects, safe to clear O_CREAT */ + } else { + create_error = may_o_create(&nd->path, dentry, mode); + if (create_error) { + open_flag &= ~O_CREAT; + if (open_flag & O_EXCL) + goto no_open; + } + } + } else if ((open_flag & (O_TRUNC|O_WRONLY|O_RDWR)) && + unlikely(!got_write)) { + /* + * No O_CREATE -> atomicity not a requirement -> fall + * back to lookup + open + */ + goto no_open; + } + + if (dir_inode->i_op->atomic_open) { + error = atomic_open(nd, dentry, path, file, op, open_flag, + mode, opened); + if (unlikely(error == -ENOENT) && create_error) + error = create_error; + return error; + } + +no_open: + if (d_in_lookup(dentry)) { + struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry, + nd->flags); + d_lookup_done(dentry); + if (unlikely(res)) { + if (IS_ERR(res)) { + error = PTR_ERR(res); + goto out_dput; + } + dput(dentry); + dentry = res; + } + } + + /* Negative dentry, just create the file */ + if (!dentry->d_inode && (open_flag & O_CREAT)) { + *opened |= FILE_CREATED; + audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE); + if (!dir_inode->i_op->create) { + error = -EACCES; + goto out_dput; + } + error = dir_inode->i_op->create(dir_inode, dentry, mode, + open_flag & O_EXCL); + if (error) + goto out_dput; + fsnotify_create(dir_inode, dentry); + } + if (unlikely(create_error) && !dentry->d_inode) { + error = create_error; + goto out_dput; + } +out_no_open: + path->dentry = dentry; + path->mnt = nd->path.mnt; + return 1; + +out_dput: + dput(dentry); + return error; +} +",0,"static int lookup_open(struct nameidata *nd, struct path *path, + struct file *file, + const struct open_flags *op, + bool got_write, int *opened) +{ + struct dentry *dir = nd->path.dentry; + struct inode *dir_inode = dir->d_inode; + int open_flag = op->open_flag; + struct dentry *dentry; + int error, create_error = 0; + umode_t mode = op->mode; + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); + + if (unlikely(IS_DEADDIR(dir_inode))) + return -ENOENT; + + *opened &= ~FILE_CREATED; + dentry = d_lookup(dir, &nd->last); + for (;;) { + if (!dentry) { + dentry = d_alloc_parallel(dir, &nd->last, &wq); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); + } + if (d_in_lookup(dentry)) + break; + + error = d_revalidate(dentry, nd->flags); + if (likely(error > 0)) + break; + if (error) + goto out_dput; + d_invalidate(dentry); + dput(dentry); + dentry = NULL; + } + if (dentry->d_inode) { + /* Cached positive dentry: will open in f_op->open */ + goto out_no_open; + } + + /* + * Checking write permission is tricky, bacuse we don't know if we are + * going to actually need it: O_CREAT opens should work as long as the + * file exists. But checking existence breaks atomicity. The trick is + * to check access and if not granted clear O_CREAT from the flags. + * + * Another problem is returing the ""right"" error value (e.g. for an + * O_EXCL open we want to return EEXIST not EROFS). + */ + if (open_flag & O_CREAT) { + if (!IS_POSIXACL(dir->d_inode)) + mode &= ~current_umask(); + if (unlikely(!got_write)) { + create_error = -EROFS; + open_flag &= ~O_CREAT; + if (open_flag & (O_EXCL | O_TRUNC)) + goto no_open; + /* No side effects, safe to clear O_CREAT */ + } else { + create_error = may_o_create(&nd->path, dentry, mode); + if (create_error) { + open_flag &= ~O_CREAT; + if (open_flag & O_EXCL) + goto no_open; + } + } + } else if ((open_flag & (O_TRUNC|O_WRONLY|O_RDWR)) && + unlikely(!got_write)) { + /* + * No O_CREATE -> atomicity not a requirement -> fall + * back to lookup + open + */ + goto no_open; + } + + if (dir_inode->i_op->atomic_open) { + error = atomic_open(nd, dentry, path, file, op, open_flag, + mode, opened); + if (unlikely(error == -ENOENT) && create_error) + error = create_error; + return error; + } + +no_open: + if (d_in_lookup(dentry)) { + struct dentry *res = dir_inode->i_op->lookup(dir_inode, dentry, + nd->flags); + d_lookup_done(dentry); + if (unlikely(res)) { + if (IS_ERR(res)) { + error = PTR_ERR(res); + goto out_dput; + } + dput(dentry); + dentry = res; + } + } + + /* Negative dentry, just create the file */ + if (!dentry->d_inode && (open_flag & O_CREAT)) { + *opened |= FILE_CREATED; + audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE); + if (!dir_inode->i_op->create) { + error = -EACCES; + goto out_dput; + } + error = dir_inode->i_op->create(dir_inode, dentry, mode, + open_flag & O_EXCL); + if (error) + goto out_dput; + fsnotify_create(dir_inode, dentry); + } + if (unlikely(create_error) && !dentry->d_inode) { + error = create_error; + goto out_dput; + } +out_no_open: + path->dentry = dentry; + path->mnt = nd->path.mnt; + return 1; + +out_dput: + dput(dentry); + return error; +} +","@@ -4362,11 +4362,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + { + int error; + bool is_dir = d_is_dir(old_dentry); +- const unsigned char *old_name; + struct inode *source = old_dentry->d_inode; + struct inode *target = new_dentry->d_inode; + bool new_is_dir = false; + unsigned max_links = new_dir->i_sb->s_max_links; ++ struct name_snapshot old_name; + + if (source == target) + return 0; +@@ -4413,7 +4413,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + if (error) + return error; + +- old_name = fsnotify_oldname_init(old_dentry->d_name.name); ++ take_dentry_name_snapshot(&old_name, old_dentry); + dget(new_dentry); + if (!is_dir || (flags & RENAME_EXCHANGE)) + lock_two_nondirectories(source, target); +@@ -4468,14 +4468,14 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + inode_unlock(target); + dput(new_dentry); + if (!error) { +- fsnotify_move(old_dir, new_dir, old_name, is_dir, ++ fsnotify_move(old_dir, new_dir, old_name.name, is_dir, + !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry); + if (flags & RENAME_EXCHANGE) { + fsnotify_move(new_dir, old_dir, old_dentry->d_name.name, + new_is_dir, NULL, new_dentry); + } + } +- fsnotify_oldname_free(old_name); ++ release_dentry_name_snapshot(&old_name); + + return error; + }",959,1195,2048 +1453,"do_exec_pty(Session *s, const char *command) +{ + int fdout, ptyfd, ttyfd, ptymaster; + pid_t pid; + + if (s == NULL) + fatal(""do_exec_pty: no session""); + ptyfd = s->ptyfd; + ttyfd = s->ttyfd; + + /* + * Create another descriptor of the pty master side for use as the + * standard input. We could use the original descriptor, but this + * simplifies code in server_loop. The descriptor is bidirectional. + * Do this before forking (and cleanup in the child) so as to + * detect and gracefully fail out-of-fd conditions. + */ + if ((fdout = dup(ptyfd)) < 0) { + error(""%s: dup #1: %s"", __func__, strerror(errno)); + close(ttyfd); + close(ptyfd); + return -1; + } + /* we keep a reference to the pty master */ + if ((ptymaster = dup(ptyfd)) < 0) { + error(""%s: dup #2: %s"", __func__, strerror(errno)); + close(ttyfd); + close(ptyfd); + close(fdout); + return -1; + } + + /* Fork the child. */ + switch ((pid = fork())) { + case -1: + error(""%s: fork: %.100s"", __func__, strerror(errno)); + close(fdout); + close(ptymaster); + close(ttyfd); + close(ptyfd); + return -1; + case 0: + is_child = 1; + + close(fdout); + close(ptymaster); + + /* Child. Reinitialize the log because the pid has changed. */ + log_init(__progname, options.log_level, + options.log_facility, log_stderr); + /* Close the master side of the pseudo tty. */ + close(ptyfd); + + /* Make the pseudo tty our controlling tty. */ + pty_make_controlling_tty(&ttyfd, s->tty); + + /* Redirect stdin/stdout/stderr from the pseudo tty. */ + if (dup2(ttyfd, 0) < 0) + error(""dup2 stdin: %s"", strerror(errno)); + if (dup2(ttyfd, 1) < 0) + error(""dup2 stdout: %s"", strerror(errno)); + if (dup2(ttyfd, 2) < 0) + error(""dup2 stderr: %s"", strerror(errno)); + + /* Close the extra descriptor for the pseudo tty. */ + close(ttyfd); + + /* record login, etc. similar to login(1) */ +#ifndef HAVE_OSF_SIA + if (!(options.use_login && command == NULL)) { +#ifdef _UNICOS + cray_init_job(s->pw); /* set up cray jid and tmpdir */ +#endif /* _UNICOS */ + do_login(s, command); + } +# ifdef LOGIN_NEEDS_UTMPX + else + do_pre_login(s); +# endif +#endif + /* + * Do common processing for the child, such as execing + * the command. + */ + do_child(s, command); + /* NOTREACHED */ + default: + break; + } + +#ifdef _UNICOS + signal(WJSIGNAL, cray_job_termination_handler); +#endif /* _UNICOS */ +#ifdef HAVE_CYGWIN + cygwin_set_impersonation_token(INVALID_HANDLE_VALUE); +#endif + + s->pid = pid; + + /* Parent. Close the slave side of the pseudo tty. */ + close(ttyfd); + + /* Enter interactive session. */ + s->ptymaster = ptymaster; + packet_set_interactive(1, + options.ip_qos_interactive, options.ip_qos_bulk); + if (compat20) { + session_set_fds(s, ptyfd, fdout, -1, 1, 1); + } else { + server_loop(pid, ptyfd, fdout, -1); + /* server_loop _has_ closed ptyfd and fdout. */ + } + return 0; +} +",0,"do_exec_pty(Session *s, const char *command) +{ + int fdout, ptyfd, ttyfd, ptymaster; + pid_t pid; + + if (s == NULL) + fatal(""do_exec_pty: no session""); + ptyfd = s->ptyfd; + ttyfd = s->ttyfd; + + /* + * Create another descriptor of the pty master side for use as the + * standard input. We could use the original descriptor, but this + * simplifies code in server_loop. The descriptor is bidirectional. + * Do this before forking (and cleanup in the child) so as to + * detect and gracefully fail out-of-fd conditions. + */ + if ((fdout = dup(ptyfd)) < 0) { + error(""%s: dup #1: %s"", __func__, strerror(errno)); + close(ttyfd); + close(ptyfd); + return -1; + } + /* we keep a reference to the pty master */ + if ((ptymaster = dup(ptyfd)) < 0) { + error(""%s: dup #2: %s"", __func__, strerror(errno)); + close(ttyfd); + close(ptyfd); + close(fdout); + return -1; + } + + /* Fork the child. */ + switch ((pid = fork())) { + case -1: + error(""%s: fork: %.100s"", __func__, strerror(errno)); + close(fdout); + close(ptymaster); + close(ttyfd); + close(ptyfd); + return -1; + case 0: + is_child = 1; + + close(fdout); + close(ptymaster); + + /* Child. Reinitialize the log because the pid has changed. */ + log_init(__progname, options.log_level, + options.log_facility, log_stderr); + /* Close the master side of the pseudo tty. */ + close(ptyfd); + + /* Make the pseudo tty our controlling tty. */ + pty_make_controlling_tty(&ttyfd, s->tty); + + /* Redirect stdin/stdout/stderr from the pseudo tty. */ + if (dup2(ttyfd, 0) < 0) + error(""dup2 stdin: %s"", strerror(errno)); + if (dup2(ttyfd, 1) < 0) + error(""dup2 stdout: %s"", strerror(errno)); + if (dup2(ttyfd, 2) < 0) + error(""dup2 stderr: %s"", strerror(errno)); + + /* Close the extra descriptor for the pseudo tty. */ + close(ttyfd); + + /* record login, etc. similar to login(1) */ +#ifndef HAVE_OSF_SIA + if (!(options.use_login && command == NULL)) { +#ifdef _UNICOS + cray_init_job(s->pw); /* set up cray jid and tmpdir */ +#endif /* _UNICOS */ + do_login(s, command); + } +# ifdef LOGIN_NEEDS_UTMPX + else + do_pre_login(s); +# endif +#endif + /* + * Do common processing for the child, such as execing + * the command. + */ + do_child(s, command); + /* NOTREACHED */ + default: + break; + } + +#ifdef _UNICOS + signal(WJSIGNAL, cray_job_termination_handler); +#endif /* _UNICOS */ +#ifdef HAVE_CYGWIN + cygwin_set_impersonation_token(INVALID_HANDLE_VALUE); +#endif + + s->pid = pid; + + /* Parent. Close the slave side of the pseudo tty. */ + close(ttyfd); + + /* Enter interactive session. */ + s->ptymaster = ptymaster; + packet_set_interactive(1, + options.ip_qos_interactive, options.ip_qos_bulk); + if (compat20) { + session_set_fds(s, ptyfd, fdout, -1, 1, 1); + } else { + server_loop(pid, ptyfd, fdout, -1); + /* server_loop _has_ closed ptyfd and fdout. */ + } + return 0; +} +","@@ -1322,7 +1322,7 @@ do_setup_env(Session *s, const char *shell) + * Pull in any environment variables that may have + * been set by PAM. + */ +- if (options.use_pam) { ++ if (options.use_pam && !options.use_login) { + char **p; + + p = fetch_pam_child_environment();",887,1123,2048 +5871,"gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int bgColor) +{ + float _angle = (float)((- degrees / 180.0f) * M_PI); + const unsigned int src_w = gdImageSX(src); + const unsigned int src_h = gdImageSY(src); + unsigned int new_width = abs((int)(src_w*cos(_angle))) + abs((int)(src_h*sin(_angle) + 0.5f)); + unsigned int new_height = abs((int)(src_w*sin(_angle))) + abs((int)(src_h*cos(_angle) + 0.5f)); + const gdFixed f_0_5 = gd_ftofx(0.5f); + const gdFixed f_H = gd_itofx(src_h/2); + const gdFixed f_W = gd_itofx(src_w/2); + const gdFixed f_cos = gd_ftofx(cos(-_angle)); + const gdFixed f_sin = gd_ftofx(sin(-_angle)); + const gdFixed f_1 = gd_itofx(1); + unsigned int i; + unsigned int dst_offset_x; + unsigned int dst_offset_y = 0; + unsigned int src_offset_x, src_offset_y; + gdImagePtr dst; + + /* impact perf a bit, but not that much. Implementation for palette + images can be done at a later point. + */ + if (src->trueColor == 0) { + gdImagePaletteToTrueColor(src); + } + + dst = gdImageCreateTrueColor(new_width, new_height); + if (dst == NULL) { + return NULL; + } + dst->saveAlphaFlag = 1; + + for (i = 0; i < new_height; i++) { + unsigned int j; + dst_offset_x = 0; + + for (j=0; j < new_width; j++) { + const gdFixed f_i = gd_itofx((int)i - (int)new_height / 2); + const gdFixed f_j = gd_itofx((int)j - (int)new_width / 2); + const gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H; + const gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W; + const unsigned int m = gd_fxtoi(f_m); + const unsigned int n = gd_fxtoi(f_n); + + if ((m > 0) && (m < src_h - 1) && (n > 0) && (n < src_w - 1)) { + const gdFixed f_f = f_m - gd_itofx(m); + const gdFixed f_g = f_n - gd_itofx(n); + const gdFixed f_w1 = gd_mulfx(f_1-f_f, f_1-f_g); + const gdFixed f_w2 = gd_mulfx(f_1-f_f, f_g); + const gdFixed f_w3 = gd_mulfx(f_f, f_1-f_g); + const gdFixed f_w4 = gd_mulfx(f_f, f_g); + + if (n < src_w - 1) { + src_offset_x = n + 1; + src_offset_y = m; + } + + if (m < src_h - 1) { + src_offset_x = n; + src_offset_y = m + 1; + } + + if (!((n >= src_w - 1) || (m >= src_h - 1))) { + src_offset_x = n + 1; + src_offset_y = m + 1; + } + { + const int pixel1 = src->tpixels[src_offset_y][src_offset_x]; + register int pixel2, pixel3, pixel4; + + if (src_offset_y + 1 >= src_h) { + pixel2 = bgColor; + pixel3 = bgColor; + pixel4 = bgColor; + } else if (src_offset_x + 1 >= src_w) { + pixel2 = bgColor; + pixel3 = bgColor; + pixel4 = bgColor; + } else { + pixel2 = src->tpixels[src_offset_y][src_offset_x + 1]; + pixel3 = src->tpixels[src_offset_y + 1][src_offset_x]; + pixel4 = src->tpixels[src_offset_y + 1][src_offset_x + 1]; + } + { + const gdFixed f_r1 = gd_itofx(gdTrueColorGetRed(pixel1)); + const gdFixed f_r2 = gd_itofx(gdTrueColorGetRed(pixel2)); + const gdFixed f_r3 = gd_itofx(gdTrueColorGetRed(pixel3)); + const gdFixed f_r4 = gd_itofx(gdTrueColorGetRed(pixel4)); + const gdFixed f_g1 = gd_itofx(gdTrueColorGetGreen(pixel1)); + const gdFixed f_g2 = gd_itofx(gdTrueColorGetGreen(pixel2)); + const gdFixed f_g3 = gd_itofx(gdTrueColorGetGreen(pixel3)); + const gdFixed f_g4 = gd_itofx(gdTrueColorGetGreen(pixel4)); + const gdFixed f_b1 = gd_itofx(gdTrueColorGetBlue(pixel1)); + const gdFixed f_b2 = gd_itofx(gdTrueColorGetBlue(pixel2)); + const gdFixed f_b3 = gd_itofx(gdTrueColorGetBlue(pixel3)); + const gdFixed f_b4 = gd_itofx(gdTrueColorGetBlue(pixel4)); + const gdFixed f_a1 = gd_itofx(gdTrueColorGetAlpha(pixel1)); + const gdFixed f_a2 = gd_itofx(gdTrueColorGetAlpha(pixel2)); + const gdFixed f_a3 = gd_itofx(gdTrueColorGetAlpha(pixel3)); + const gdFixed f_a4 = gd_itofx(gdTrueColorGetAlpha(pixel4)); + const gdFixed f_red = gd_mulfx(f_w1, f_r1) + gd_mulfx(f_w2, f_r2) + gd_mulfx(f_w3, f_r3) + gd_mulfx(f_w4, f_r4); + const gdFixed f_green = gd_mulfx(f_w1, f_g1) + gd_mulfx(f_w2, f_g2) + gd_mulfx(f_w3, f_g3) + gd_mulfx(f_w4, f_g4); + const gdFixed f_blue = gd_mulfx(f_w1, f_b1) + gd_mulfx(f_w2, f_b2) + gd_mulfx(f_w3, f_b3) + gd_mulfx(f_w4, f_b4); + const gdFixed f_alpha = gd_mulfx(f_w1, f_a1) + gd_mulfx(f_w2, f_a2) + gd_mulfx(f_w3, f_a3) + gd_mulfx(f_w4, f_a4); + + const unsigned char red = (unsigned char) CLAMP(gd_fxtoi(f_red), 0, 255); + const unsigned char green = (unsigned char) CLAMP(gd_fxtoi(f_green), 0, 255); + const unsigned char blue = (unsigned char) CLAMP(gd_fxtoi(f_blue), 0, 255); + const unsigned char alpha = (unsigned char) CLAMP(gd_fxtoi(f_alpha), 0, 127); + + dst->tpixels[dst_offset_y][dst_offset_x++] = gdTrueColorAlpha(red, green, blue, alpha); + } + } + } else { + dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor; + } + } + dst_offset_y++; + } + return dst; +} +",0,"gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int bgColor) +{ + float _angle = (float)((- degrees / 180.0f) * M_PI); + const unsigned int src_w = gdImageSX(src); + const unsigned int src_h = gdImageSY(src); + unsigned int new_width = abs((int)(src_w*cos(_angle))) + abs((int)(src_h*sin(_angle) + 0.5f)); + unsigned int new_height = abs((int)(src_w*sin(_angle))) + abs((int)(src_h*cos(_angle) + 0.5f)); + const gdFixed f_0_5 = gd_ftofx(0.5f); + const gdFixed f_H = gd_itofx(src_h/2); + const gdFixed f_W = gd_itofx(src_w/2); + const gdFixed f_cos = gd_ftofx(cos(-_angle)); + const gdFixed f_sin = gd_ftofx(sin(-_angle)); + const gdFixed f_1 = gd_itofx(1); + unsigned int i; + unsigned int dst_offset_x; + unsigned int dst_offset_y = 0; + unsigned int src_offset_x, src_offset_y; + gdImagePtr dst; + + /* impact perf a bit, but not that much. Implementation for palette + images can be done at a later point. + */ + if (src->trueColor == 0) { + gdImagePaletteToTrueColor(src); + } + + dst = gdImageCreateTrueColor(new_width, new_height); + if (dst == NULL) { + return NULL; + } + dst->saveAlphaFlag = 1; + + for (i = 0; i < new_height; i++) { + unsigned int j; + dst_offset_x = 0; + + for (j=0; j < new_width; j++) { + const gdFixed f_i = gd_itofx((int)i - (int)new_height / 2); + const gdFixed f_j = gd_itofx((int)j - (int)new_width / 2); + const gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H; + const gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W; + const unsigned int m = gd_fxtoi(f_m); + const unsigned int n = gd_fxtoi(f_n); + + if ((m > 0) && (m < src_h - 1) && (n > 0) && (n < src_w - 1)) { + const gdFixed f_f = f_m - gd_itofx(m); + const gdFixed f_g = f_n - gd_itofx(n); + const gdFixed f_w1 = gd_mulfx(f_1-f_f, f_1-f_g); + const gdFixed f_w2 = gd_mulfx(f_1-f_f, f_g); + const gdFixed f_w3 = gd_mulfx(f_f, f_1-f_g); + const gdFixed f_w4 = gd_mulfx(f_f, f_g); + + if (n < src_w - 1) { + src_offset_x = n + 1; + src_offset_y = m; + } + + if (m < src_h - 1) { + src_offset_x = n; + src_offset_y = m + 1; + } + + if (!((n >= src_w - 1) || (m >= src_h - 1))) { + src_offset_x = n + 1; + src_offset_y = m + 1; + } + { + const int pixel1 = src->tpixels[src_offset_y][src_offset_x]; + register int pixel2, pixel3, pixel4; + + if (src_offset_y + 1 >= src_h) { + pixel2 = bgColor; + pixel3 = bgColor; + pixel4 = bgColor; + } else if (src_offset_x + 1 >= src_w) { + pixel2 = bgColor; + pixel3 = bgColor; + pixel4 = bgColor; + } else { + pixel2 = src->tpixels[src_offset_y][src_offset_x + 1]; + pixel3 = src->tpixels[src_offset_y + 1][src_offset_x]; + pixel4 = src->tpixels[src_offset_y + 1][src_offset_x + 1]; + } + { + const gdFixed f_r1 = gd_itofx(gdTrueColorGetRed(pixel1)); + const gdFixed f_r2 = gd_itofx(gdTrueColorGetRed(pixel2)); + const gdFixed f_r3 = gd_itofx(gdTrueColorGetRed(pixel3)); + const gdFixed f_r4 = gd_itofx(gdTrueColorGetRed(pixel4)); + const gdFixed f_g1 = gd_itofx(gdTrueColorGetGreen(pixel1)); + const gdFixed f_g2 = gd_itofx(gdTrueColorGetGreen(pixel2)); + const gdFixed f_g3 = gd_itofx(gdTrueColorGetGreen(pixel3)); + const gdFixed f_g4 = gd_itofx(gdTrueColorGetGreen(pixel4)); + const gdFixed f_b1 = gd_itofx(gdTrueColorGetBlue(pixel1)); + const gdFixed f_b2 = gd_itofx(gdTrueColorGetBlue(pixel2)); + const gdFixed f_b3 = gd_itofx(gdTrueColorGetBlue(pixel3)); + const gdFixed f_b4 = gd_itofx(gdTrueColorGetBlue(pixel4)); + const gdFixed f_a1 = gd_itofx(gdTrueColorGetAlpha(pixel1)); + const gdFixed f_a2 = gd_itofx(gdTrueColorGetAlpha(pixel2)); + const gdFixed f_a3 = gd_itofx(gdTrueColorGetAlpha(pixel3)); + const gdFixed f_a4 = gd_itofx(gdTrueColorGetAlpha(pixel4)); + const gdFixed f_red = gd_mulfx(f_w1, f_r1) + gd_mulfx(f_w2, f_r2) + gd_mulfx(f_w3, f_r3) + gd_mulfx(f_w4, f_r4); + const gdFixed f_green = gd_mulfx(f_w1, f_g1) + gd_mulfx(f_w2, f_g2) + gd_mulfx(f_w3, f_g3) + gd_mulfx(f_w4, f_g4); + const gdFixed f_blue = gd_mulfx(f_w1, f_b1) + gd_mulfx(f_w2, f_b2) + gd_mulfx(f_w3, f_b3) + gd_mulfx(f_w4, f_b4); + const gdFixed f_alpha = gd_mulfx(f_w1, f_a1) + gd_mulfx(f_w2, f_a2) + gd_mulfx(f_w3, f_a3) + gd_mulfx(f_w4, f_a4); + + const unsigned char red = (unsigned char) CLAMP(gd_fxtoi(f_red), 0, 255); + const unsigned char green = (unsigned char) CLAMP(gd_fxtoi(f_green), 0, 255); + const unsigned char blue = (unsigned char) CLAMP(gd_fxtoi(f_blue), 0, 255); + const unsigned char alpha = (unsigned char) CLAMP(gd_fxtoi(f_alpha), 0, 127); + + dst->tpixels[dst_offset_y][dst_offset_x++] = gdTrueColorAlpha(red, green, blue, alpha); + } + } + } else { + dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor; + } + } + dst_offset_y++; + } + return dst; +} +","@@ -953,9 +953,6 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi + double dTotalWeight = 0.0; + int iSrc; + +- res->ContribRow[u].Left = iLeft; +- res->ContribRow[u].Right = iRight; +- + /* Cut edge points to fit in filter window in case of spill-off */ + if (iRight - iLeft + 1 > windows_size) { + if (iLeft < ((int)src_size - 1 / 2)) { +@@ -965,6 +962,9 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi + } + } + ++ res->ContribRow[u].Left = iLeft; ++ res->ContribRow[u].Right = iRight; ++ + for (iSrc = iLeft; iSrc <= iRight; iSrc++) { + dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc))); + }",1702,1938,2048 +13157,"void RenderFrameImpl::SendDidCommitProvisionalLoad( + blink::WebFrame* frame, + blink::WebHistoryCommitType commit_type, + const blink::WebHistoryItem& item) { + DCHECK(!frame_ || frame_ == frame); + WebDataSource* ds = frame->dataSource(); + DCHECK(ds); + + const WebURLRequest& request = ds->request(); + const WebURLResponse& response = ds->response(); + + DocumentState* document_state = DocumentState::FromDataSource(ds); + NavigationStateImpl* navigation_state = + static_cast(document_state->navigation_state()); + InternalDocumentStateData* internal_data = + InternalDocumentStateData::FromDocumentState(document_state); + + FrameHostMsg_DidCommitProvisionalLoad_Params params; + params.http_status_code = response.httpStatusCode(); + params.url_is_unreachable = ds->hasUnreachableURL(); + params.is_post = false; + params.intended_as_new_entry = + navigation_state->request_params().intended_as_new_entry; + params.did_create_new_entry = commit_type == blink::WebStandardCommit; + params.post_id = -1; + params.page_id = render_view_->page_id_; + params.nav_entry_id = navigation_state->request_params().nav_entry_id; + params.render_view_routing_id = render_view_->routing_id(); + params.socket_address.set_host(response.remoteIPAddress().utf8()); + params.socket_address.set_port(response.remotePort()); + WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); + if (extra_data) + params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); + params.was_within_same_page = navigation_state->WasWithinSamePage(); + params.security_info = response.securityInfo(); + + params.url = GetLoadingUrl(); + DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); + + if (!is_swapped_out_) { + std::string scheme = frame->document().securityOrigin().protocol().utf8(); + if (url::IsStandard(scheme.c_str(), + url::Component(0, static_cast(scheme.length())))) { + params.origin = frame->document().securityOrigin(); + } + } + + if (frame->document().baseURL() != params.url) + params.base_url = frame->document().baseURL(); + + GetRedirectChain(ds, ¶ms.redirects); + params.should_update_history = !ds->hasUnreachableURL() && + !response.isMultipartPayload() && (response.httpStatusCode() != 404); + + params.searchable_form_url = internal_data->searchable_form_url(); + params.searchable_form_encoding = internal_data->searchable_form_encoding(); + + params.gesture = render_view_->navigation_gesture_; + render_view_->navigation_gesture_ = NavigationGestureUnknown; + + HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); + if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { + if (entry) + params.page_state = HistoryEntryToPageState(entry); + else + params.page_state = PageState::CreateFromURL(request.url()); + } else { + params.page_state = SingleHistoryItemToPageState(item); + } + params.item_sequence_number = item.itemSequenceNumber(); + params.document_sequence_number = item.documentSequenceNumber(); + + if (!frame->parent()) { + + render_view_->webview()->zoomLimitsChanged( + ZoomFactorToZoomLevel(kMinimumZoomFactor), + ZoomFactorToZoomLevel(kMaximumZoomFactor)); + + HostZoomLevels::iterator host_zoom = + render_view_->host_zoom_levels_.find(GURL(request.url())); + if (render_view_->webview()->mainFrame()->document().isPluginDocument()) { + render_view_->webview()->setZoomLevel(0); + } else { + if (host_zoom != render_view_->host_zoom_levels_.end()) + render_view_->webview()->setZoomLevel(host_zoom->second); + } + + if (host_zoom != render_view_->host_zoom_levels_.end()) { + render_view_->host_zoom_levels_.erase(host_zoom); + } + + params.contents_mime_type = ds->response().mimeType().utf8(); + + params.transition = navigation_state->GetTransitionType(); + if (!ui::PageTransitionIsMainFrame(params.transition)) { + params.transition = ui::PAGE_TRANSITION_LINK; + } + + if (ds->isClientRedirect()) { + params.referrer = + Referrer(params.redirects[0], ds->request().referrerPolicy()); + params.transition = ui::PageTransitionFromInt( + params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT); + } else { + params.referrer = RenderViewImpl::GetReferrerFromRequest( + frame, ds->request()); + } + + base::string16 method = request.httpMethod(); + if (base::EqualsASCII(method, ""POST"")) { + params.is_post = true; + params.post_id = ExtractPostId(entry); + } + + params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); + + params.original_request_url = GetOriginalRequestURL(ds); + + params.history_list_was_cleared = + navigation_state->request_params().should_clear_history_list; + + params.report_type = static_cast( + frame->dataSource()->request().inputPerfMetricReportPolicy()); + params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( + frame->dataSource()->request().uiStartTime()); + + UMA_HISTOGRAM_COUNTS_10000(""Memory.GlyphPagesPerLoad"", + blink::WebGlyphCache::pageCount()); + + Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); + } else { + if (commit_type == blink::WebStandardCommit) + params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; + else + params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; + + DCHECK(!navigation_state->request_params().should_clear_history_list); + params.history_list_was_cleared = false; + params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; + + if (!is_swapped_out()) + Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); + } + + navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); +} +",0,"void RenderFrameImpl::SendDidCommitProvisionalLoad( + blink::WebFrame* frame, + blink::WebHistoryCommitType commit_type, + const blink::WebHistoryItem& item) { + DCHECK(!frame_ || frame_ == frame); + WebDataSource* ds = frame->dataSource(); + DCHECK(ds); + + const WebURLRequest& request = ds->request(); + const WebURLResponse& response = ds->response(); + + DocumentState* document_state = DocumentState::FromDataSource(ds); + NavigationStateImpl* navigation_state = + static_cast(document_state->navigation_state()); + InternalDocumentStateData* internal_data = + InternalDocumentStateData::FromDocumentState(document_state); + + FrameHostMsg_DidCommitProvisionalLoad_Params params; + params.http_status_code = response.httpStatusCode(); + params.url_is_unreachable = ds->hasUnreachableURL(); + params.is_post = false; + params.intended_as_new_entry = + navigation_state->request_params().intended_as_new_entry; + params.did_create_new_entry = commit_type == blink::WebStandardCommit; + params.post_id = -1; + params.page_id = render_view_->page_id_; + params.nav_entry_id = navigation_state->request_params().nav_entry_id; + params.render_view_routing_id = render_view_->routing_id(); + params.socket_address.set_host(response.remoteIPAddress().utf8()); + params.socket_address.set_port(response.remotePort()); + WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); + if (extra_data) + params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); + params.was_within_same_page = navigation_state->WasWithinSamePage(); + params.security_info = response.securityInfo(); + + params.url = GetLoadingUrl(); + DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); + + if (!is_swapped_out_) { + std::string scheme = frame->document().securityOrigin().protocol().utf8(); + if (url::IsStandard(scheme.c_str(), + url::Component(0, static_cast(scheme.length())))) { + params.origin = frame->document().securityOrigin(); + } + } + + if (frame->document().baseURL() != params.url) + params.base_url = frame->document().baseURL(); + + GetRedirectChain(ds, ¶ms.redirects); + params.should_update_history = !ds->hasUnreachableURL() && + !response.isMultipartPayload() && (response.httpStatusCode() != 404); + + params.searchable_form_url = internal_data->searchable_form_url(); + params.searchable_form_encoding = internal_data->searchable_form_encoding(); + + params.gesture = render_view_->navigation_gesture_; + render_view_->navigation_gesture_ = NavigationGestureUnknown; + + HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); + if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { + if (entry) + params.page_state = HistoryEntryToPageState(entry); + else + params.page_state = PageState::CreateFromURL(request.url()); + } else { + params.page_state = SingleHistoryItemToPageState(item); + } + params.item_sequence_number = item.itemSequenceNumber(); + params.document_sequence_number = item.documentSequenceNumber(); + + if (!frame->parent()) { + + render_view_->webview()->zoomLimitsChanged( + ZoomFactorToZoomLevel(kMinimumZoomFactor), + ZoomFactorToZoomLevel(kMaximumZoomFactor)); + + HostZoomLevels::iterator host_zoom = + render_view_->host_zoom_levels_.find(GURL(request.url())); + if (render_view_->webview()->mainFrame()->document().isPluginDocument()) { + render_view_->webview()->setZoomLevel(0); + } else { + if (host_zoom != render_view_->host_zoom_levels_.end()) + render_view_->webview()->setZoomLevel(host_zoom->second); + } + + if (host_zoom != render_view_->host_zoom_levels_.end()) { + render_view_->host_zoom_levels_.erase(host_zoom); + } + + params.contents_mime_type = ds->response().mimeType().utf8(); + + params.transition = navigation_state->GetTransitionType(); + if (!ui::PageTransitionIsMainFrame(params.transition)) { + params.transition = ui::PAGE_TRANSITION_LINK; + } + + if (ds->isClientRedirect()) { + params.referrer = + Referrer(params.redirects[0], ds->request().referrerPolicy()); + params.transition = ui::PageTransitionFromInt( + params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT); + } else { + params.referrer = RenderViewImpl::GetReferrerFromRequest( + frame, ds->request()); + } + + base::string16 method = request.httpMethod(); + if (base::EqualsASCII(method, ""POST"")) { + params.is_post = true; + params.post_id = ExtractPostId(entry); + } + + params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); + + params.original_request_url = GetOriginalRequestURL(ds); + + params.history_list_was_cleared = + navigation_state->request_params().should_clear_history_list; + + params.report_type = static_cast( + frame->dataSource()->request().inputPerfMetricReportPolicy()); + params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( + frame->dataSource()->request().uiStartTime()); + + UMA_HISTOGRAM_COUNTS_10000(""Memory.GlyphPagesPerLoad"", + blink::WebGlyphCache::pageCount()); + + Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); + } else { + if (commit_type == blink::WebStandardCommit) + params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; + else + params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; + + DCHECK(!navigation_state->request_params().should_clear_history_list); + params.history_list_was_cleared = false; + params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; + + if (!is_swapped_out()) + Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); + } + + navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); +} +","@@ -115,6 +115,7 @@ + #include ""media/blink/webmediaplayer_impl.h"" + #include ""media/blink/webmediaplayer_params.h"" + #include ""media/renderers/gpu_video_accelerator_factories.h"" ++#include ""mojo/common/url_type_converters.h"" + #include ""net/base/data_url.h"" + #include ""net/base/net_errors.h"" + #include ""net/base/registry_controlled_domains/registry_controlled_domain.h"" +@@ -125,6 +126,7 @@ + #include ""third_party/WebKit/public/platform/WebURLError.h"" + #include ""third_party/WebKit/public/platform/WebURLResponse.h"" + #include ""third_party/WebKit/public/platform/WebVector.h"" ++#include ""third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h"" + #include ""third_party/WebKit/public/web/WebColorSuggestion.h"" + #include ""third_party/WebKit/public/web/WebDocument.h"" + #include ""third_party/WebKit/public/web/WebFrameWidget.h"" +@@ -174,6 +176,8 @@ + #include ""content/renderer/media/android/webmediaplayer_android.h"" + #else + #include ""cc/blink/context_provider_web_context.h"" ++#include ""content/renderer/usb/web_usb_client_impl.h"" ++#include ""device/devices_app/public/cpp/constants.h"" + #endif + + #if defined(ENABLE_PEPPER_CDMS) +@@ -705,6 +709,8 @@ RenderFrameImpl::RenderFrameImpl(const CreateParams& params) + #endif + + manifest_manager_ = new ManifestManager(this); ++ ++ GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_)); + } + + RenderFrameImpl::~RenderFrameImpl() { +@@ -3812,6 +3818,17 @@ blink::WebBluetooth* RenderFrameImpl::bluetooth() { + return bluetooth_.get(); + } + ++blink::WebUSBClient* RenderFrameImpl::usbClient() { ++#if !defined(OS_ANDROID) ++ if (!usb_client_) { ++ mojo::ServiceProviderPtr device_services = ++ ConnectToApplication(GURL(device::kDevicesMojoAppUrl)); ++ usb_client_.reset(new WebUSBClientImpl(device_services.Pass())); ++ } ++#endif ++ return usb_client_.get(); ++} ++ + #if defined(ENABLE_WEBVR) + blink::WebVRClient* RenderFrameImpl::webVRClient() { + if (!vr_dispatcher_) +@@ -5003,17 +5020,9 @@ media::MediaPermission* RenderFrameImpl::GetMediaPermission() { + #if defined(ENABLE_MOJO_MEDIA) + media::interfaces::ServiceFactory* RenderFrameImpl::GetMediaServiceFactory() { + if (!media_service_factory_) { +- mojo::InterfacePtr shell_ptr; +- GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&shell_ptr)); +- +- mojo::ServiceProviderPtr service_provider; +- mojo::URLRequestPtr request(mojo::URLRequest::New()); +- request->url = mojo::String::From(""mojo:media""); +- shell_ptr->ConnectToApplication(request.Pass(), GetProxy(&service_provider), +- nullptr, nullptr); +- ++ mojo::ServiceProviderPtr service_provider = ++ ConnectToApplication(GURL(""mojo:media"")); + mojo::ConnectToService(service_provider.get(), &media_service_factory_); +- + media_service_factory_.set_connection_error_handler( + base::Bind(&RenderFrameImpl::OnMediaServiceFactoryConnectionError, + base::Unretained(this))); +@@ -5075,4 +5084,15 @@ void RenderFrameImpl::RegisterMojoServices() { + } + } + ++mojo::ServiceProviderPtr RenderFrameImpl::ConnectToApplication( ++ const GURL& url) { ++ DCHECK(mojo_shell_); ++ mojo::ServiceProviderPtr service_provider; ++ mojo::URLRequestPtr request(mojo::URLRequest::New()); ++ request->url = mojo::String::From(url); ++ mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), ++ nullptr, nullptr); ++ return service_provider.Pass(); ++} ++ + } // namespace content",1332,1568,2048 +5800,"int kvm_arch_hardware_enable(void) +{ + struct kvm *kvm; + struct kvm_vcpu *vcpu; + int i; + int ret; + u64 local_tsc; + u64 max_tsc = 0; + bool stable, backwards_tsc = false; + + kvm_shared_msr_cpu_online(); + ret = kvm_x86_ops->hardware_enable(); + if (ret != 0) + return ret; + + local_tsc = rdtsc(); + stable = !check_tsc_unstable(); + list_for_each_entry(kvm, &vm_list, vm_list) { + kvm_for_each_vcpu(i, vcpu, kvm) { + if (!stable && vcpu->cpu == smp_processor_id()) + kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); + if (stable && vcpu->arch.last_host_tsc > local_tsc) { + backwards_tsc = true; + if (vcpu->arch.last_host_tsc > max_tsc) + max_tsc = vcpu->arch.last_host_tsc; + } + } + } + + /* + * Sometimes, even reliable TSCs go backwards. This happens on + * platforms that reset TSC during suspend or hibernate actions, but + * maintain synchronization. We must compensate. Fortunately, we can + * detect that condition here, which happens early in CPU bringup, + * before any KVM threads can be running. Unfortunately, we can't + * bring the TSCs fully up to date with real time, as we aren't yet far + * enough into CPU bringup that we know how much real time has actually + * elapsed; our helper function, get_kernel_ns() will be using boot + * variables that haven't been updated yet. + * + * So we simply find the maximum observed TSC above, then record the + * adjustment to TSC in each VCPU. When the VCPU later gets loaded, + * the adjustment will be applied. Note that we accumulate + * adjustments, in case multiple suspend cycles happen before some VCPU + * gets a chance to run again. In the event that no KVM threads get a + * chance to run, we will miss the entire elapsed period, as we'll have + * reset last_host_tsc, so VCPUs will not have the TSC adjusted and may + * loose cycle time. This isn't too big a deal, since the loss will be + * uniform across all VCPUs (not to mention the scenario is extremely + * unlikely). It is possible that a second hibernate recovery happens + * much faster than a first, causing the observed TSC here to be + * smaller; this would require additional padding adjustment, which is + * why we set last_host_tsc to the local tsc observed here. + * + * N.B. - this code below runs only on platforms with reliable TSC, + * as that is the only way backwards_tsc is set above. Also note + * that this runs for ALL vcpus, which is not a bug; all VCPUs should + * have the same delta_cyc adjustment applied if backwards_tsc + * is detected. Note further, this adjustment is only done once, + * as we reset last_host_tsc on all VCPUs to stop this from being + * called multiple times (one for each physical CPU bringup). + * + * Platforms with unreliable TSCs don't have to deal with this, they + * will be compensated by the logic in vcpu_load, which sets the TSC to + * catchup mode. This will catchup all VCPUs to real time, but cannot + * guarantee that they stay in perfect synchronization. + */ + if (backwards_tsc) { + u64 delta_cyc = max_tsc - local_tsc; + backwards_tsc_observed = true; + list_for_each_entry(kvm, &vm_list, vm_list) { + kvm_for_each_vcpu(i, vcpu, kvm) { + vcpu->arch.tsc_offset_adjustment += delta_cyc; + vcpu->arch.last_host_tsc = local_tsc; + kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu); + } + + /* + * We have to disable TSC offset matching.. if you were + * booting a VM while issuing an S4 host suspend.... + * you may have some problem. Solving this issue is + * left as an exercise to the reader. + */ + kvm->arch.last_tsc_nsec = 0; + kvm->arch.last_tsc_write = 0; + } + + } + return 0; +} +",0,"int kvm_arch_hardware_enable(void) +{ + struct kvm *kvm; + struct kvm_vcpu *vcpu; + int i; + int ret; + u64 local_tsc; + u64 max_tsc = 0; + bool stable, backwards_tsc = false; + + kvm_shared_msr_cpu_online(); + ret = kvm_x86_ops->hardware_enable(); + if (ret != 0) + return ret; + + local_tsc = rdtsc(); + stable = !check_tsc_unstable(); + list_for_each_entry(kvm, &vm_list, vm_list) { + kvm_for_each_vcpu(i, vcpu, kvm) { + if (!stable && vcpu->cpu == smp_processor_id()) + kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); + if (stable && vcpu->arch.last_host_tsc > local_tsc) { + backwards_tsc = true; + if (vcpu->arch.last_host_tsc > max_tsc) + max_tsc = vcpu->arch.last_host_tsc; + } + } + } + + /* + * Sometimes, even reliable TSCs go backwards. This happens on + * platforms that reset TSC during suspend or hibernate actions, but + * maintain synchronization. We must compensate. Fortunately, we can + * detect that condition here, which happens early in CPU bringup, + * before any KVM threads can be running. Unfortunately, we can't + * bring the TSCs fully up to date with real time, as we aren't yet far + * enough into CPU bringup that we know how much real time has actually + * elapsed; our helper function, get_kernel_ns() will be using boot + * variables that haven't been updated yet. + * + * So we simply find the maximum observed TSC above, then record the + * adjustment to TSC in each VCPU. When the VCPU later gets loaded, + * the adjustment will be applied. Note that we accumulate + * adjustments, in case multiple suspend cycles happen before some VCPU + * gets a chance to run again. In the event that no KVM threads get a + * chance to run, we will miss the entire elapsed period, as we'll have + * reset last_host_tsc, so VCPUs will not have the TSC adjusted and may + * loose cycle time. This isn't too big a deal, since the loss will be + * uniform across all VCPUs (not to mention the scenario is extremely + * unlikely). It is possible that a second hibernate recovery happens + * much faster than a first, causing the observed TSC here to be + * smaller; this would require additional padding adjustment, which is + * why we set last_host_tsc to the local tsc observed here. + * + * N.B. - this code below runs only on platforms with reliable TSC, + * as that is the only way backwards_tsc is set above. Also note + * that this runs for ALL vcpus, which is not a bug; all VCPUs should + * have the same delta_cyc adjustment applied if backwards_tsc + * is detected. Note further, this adjustment is only done once, + * as we reset last_host_tsc on all VCPUs to stop this from being + * called multiple times (one for each physical CPU bringup). + * + * Platforms with unreliable TSCs don't have to deal with this, they + * will be compensated by the logic in vcpu_load, which sets the TSC to + * catchup mode. This will catchup all VCPUs to real time, but cannot + * guarantee that they stay in perfect synchronization. + */ + if (backwards_tsc) { + u64 delta_cyc = max_tsc - local_tsc; + backwards_tsc_observed = true; + list_for_each_entry(kvm, &vm_list, vm_list) { + kvm_for_each_vcpu(i, vcpu, kvm) { + vcpu->arch.tsc_offset_adjustment += delta_cyc; + vcpu->arch.last_host_tsc = local_tsc; + kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu); + } + + /* + * We have to disable TSC offset matching.. if you were + * booting a VM while issuing an S4 host suspend.... + * you may have some problem. Solving this issue is + * left as an exercise to the reader. + */ + kvm->arch.last_tsc_nsec = 0; + kvm->arch.last_tsc_write = 0; + } + + } + return 0; +} +","@@ -3572,9 +3572,11 @@ static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps) + + static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) + { ++ int i; + mutex_lock(&kvm->arch.vpit->pit_state.lock); + memcpy(&kvm->arch.vpit->pit_state, ps, sizeof(struct kvm_pit_state)); +- kvm_pit_load_count(kvm, 0, ps->channels[0].count, 0); ++ for (i = 0; i < 3; i++) ++ kvm_pit_load_count(kvm, i, ps->channels[i].count, 0); + mutex_unlock(&kvm->arch.vpit->pit_state.lock); + return 0; + } +@@ -3593,6 +3595,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) + static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) + { + int start = 0; ++ int i; + u32 prev_legacy, cur_legacy; + mutex_lock(&kvm->arch.vpit->pit_state.lock); + prev_legacy = kvm->arch.vpit->pit_state.flags & KVM_PIT_FLAGS_HPET_LEGACY; +@@ -3602,7 +3605,8 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) + memcpy(&kvm->arch.vpit->pit_state.channels, &ps->channels, + sizeof(kvm->arch.vpit->pit_state.channels)); + kvm->arch.vpit->pit_state.flags = ps->flags; +- kvm_pit_load_count(kvm, 0, kvm->arch.vpit->pit_state.channels[0].count, start); ++ for (i = 0; i < 3; i++) ++ kvm_pit_load_count(kvm, i, kvm->arch.vpit->pit_state.channels[i].count, start); + mutex_unlock(&kvm->arch.vpit->pit_state.lock); + return 0; + }",1018,1254,2048 +4867,"rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0 /*, shift_width = 0 */; + /* int bytes_per_sample, bytes_per_pixel; */ + uint32 row, rowsize, bit_offset; + uint32 src_byte, src_bit; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *next; + tsample_t sample; + + + if ((src == NULL) || (dst == NULL)) + { + TIFFError(""rotateContigSamples24bits"",""Invalid src or destination buffer""); + return (1); + } + + /* bytes_per_sample = (bps + 7) / 8; */ + /* bytes_per_pixel = ((bps * spp) + 7) / 8; */ + /* if (bytes_per_pixel < (bytes_per_sample + 1)) */ + /* shift_width = bytes_per_pixel; */ + /* else */ + /* shift_width = bytes_per_sample + 1; */ + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint64)-1 >> (64 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError(""rotateContigSamples8bits"", ""Invalid rotation %d"", rotation); + return (1); + } + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | next[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | next[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end rotateContigSamples32bits */ +",0,"rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0 /*, shift_width = 0 */; + /* int bytes_per_sample, bytes_per_pixel; */ + uint32 row, rowsize, bit_offset; + uint32 src_byte, src_bit; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *next; + tsample_t sample; + + + if ((src == NULL) || (dst == NULL)) + { + TIFFError(""rotateContigSamples24bits"",""Invalid src or destination buffer""); + return (1); + } + + /* bytes_per_sample = (bps + 7) / 8; */ + /* bytes_per_pixel = ((bps * spp) + 7) / 8; */ + /* if (bytes_per_pixel < (bytes_per_sample + 1)) */ + /* shift_width = bytes_per_pixel; */ + /* else */ + /* shift_width = bytes_per_sample + 1; */ + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint64)-1 >> (64 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError(""rotateContigSamples8bits"", ""Invalid rotation %d"", rotation); + return (1); + } + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | next[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | next[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end rotateContigSamples32bits */ +","@@ -819,9 +819,18 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, + } + } + +- tilebuf = _TIFFmalloc(tile_buffsize); ++ /* Add 3 padding bytes for extractContigSamplesShifted32bits */ ++ if( tile_buffsize > 0xFFFFFFFFU - 3 ) ++ { ++ TIFFError(""readContigTilesIntoBuffer"", ""Integer overflow when calculating buffer size.""); ++ exit(-1); ++ } ++ tilebuf = _TIFFmalloc(tile_buffsize + 3); + if (tilebuf == 0) + return 0; ++ tilebuf[tile_buffsize] = 0; ++ tilebuf[tile_buffsize+1] = 0; ++ tilebuf[tile_buffsize+2] = 0; + + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + for (row = 0; row < imagelength; row += tl)",1040,1276,2048 +15917,"error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size, + const volatile void* cmd_data) { + const char* func_name = ""glTexImage2D""; + const volatile gles2::cmds::TexImage2D& c = + *static_cast(cmd_data); + TRACE_EVENT2(""gpu"", ""GLES2DecoderImpl::HandleTexImage2D"", + ""width"", c.width, ""height"", c.height); + texture_state_.tex_image_failed = true; + GLenum target = static_cast(c.target); + GLint level = static_cast(c.level); + GLint internal_format = static_cast(c.internalformat); + GLsizei width = static_cast(c.width); + GLsizei height = static_cast(c.height); + GLint border = static_cast(c.border); + GLenum format = static_cast(c.format); + GLenum type = static_cast(c.type); + uint32_t pixels_shm_id = static_cast(c.pixels_shm_id); + uint32_t pixels_shm_offset = static_cast(c.pixels_shm_offset); + + if (width < 0 || height < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, ""dimensions < 0""); + return error::kNoError; + } + + PixelStoreParams params; + Buffer* buffer = state_.bound_pixel_unpack_buffer.get(); + if (buffer) { + if (pixels_shm_id) + return error::kInvalidArguments; + if (buffer->GetMappedRange()) { + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, + ""pixel unpack buffer should not be mapped to client memory""); + return error::kNoError; + } + params = state_.GetUnpackParams(ContextState::k2D); + } else { + if (!pixels_shm_id && pixels_shm_offset) + return error::kInvalidArguments; + params.alignment = state_.unpack_alignment; + } + uint32_t pixels_size; + uint32_t skip_size; + uint32_t padding; + if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, + format, type, + params, + &pixels_size, + nullptr, + nullptr, + &skip_size, + &padding)) { + return error::kOutOfBounds; + } + DCHECK_EQ(0u, skip_size); + + const void* pixels; + if (pixels_shm_id) { + pixels = GetSharedMemoryAs( + pixels_shm_id, pixels_shm_offset, pixels_size); + if (!pixels) + return error::kOutOfBounds; + } else { + pixels = reinterpret_cast(pixels_shm_offset); + } + + uint32_t num_pixels; + if (workarounds().simulate_out_of_memory_on_large_textures && + (!SafeMultiplyUint32(width, height, &num_pixels) || + (num_pixels >= 4096 * 4096))) { + LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, ""synthetic out of memory""); + return error::kNoError; + } + + TextureManager::DoTexImageArguments args = { + target, level, internal_format, width, height, 1, border, format, type, + pixels, pixels_size, padding, + TextureManager::DoTexImageArguments::kTexImage2D }; + texture_manager()->ValidateAndDoTexImage( + &texture_state_, &state_, &framebuffer_state_, func_name, args); + + ExitCommandProcessingEarly(); + return error::kNoError; +} +",0,"error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size, + const volatile void* cmd_data) { + const char* func_name = ""glTexImage2D""; + const volatile gles2::cmds::TexImage2D& c = + *static_cast(cmd_data); + TRACE_EVENT2(""gpu"", ""GLES2DecoderImpl::HandleTexImage2D"", + ""width"", c.width, ""height"", c.height); + texture_state_.tex_image_failed = true; + GLenum target = static_cast(c.target); + GLint level = static_cast(c.level); + GLint internal_format = static_cast(c.internalformat); + GLsizei width = static_cast(c.width); + GLsizei height = static_cast(c.height); + GLint border = static_cast(c.border); + GLenum format = static_cast(c.format); + GLenum type = static_cast(c.type); + uint32_t pixels_shm_id = static_cast(c.pixels_shm_id); + uint32_t pixels_shm_offset = static_cast(c.pixels_shm_offset); + + if (width < 0 || height < 0) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, ""dimensions < 0""); + return error::kNoError; + } + + PixelStoreParams params; + Buffer* buffer = state_.bound_pixel_unpack_buffer.get(); + if (buffer) { + if (pixels_shm_id) + return error::kInvalidArguments; + if (buffer->GetMappedRange()) { + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, + ""pixel unpack buffer should not be mapped to client memory""); + return error::kNoError; + } + params = state_.GetUnpackParams(ContextState::k2D); + } else { + if (!pixels_shm_id && pixels_shm_offset) + return error::kInvalidArguments; + params.alignment = state_.unpack_alignment; + } + uint32_t pixels_size; + uint32_t skip_size; + uint32_t padding; + if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, + format, type, + params, + &pixels_size, + nullptr, + nullptr, + &skip_size, + &padding)) { + return error::kOutOfBounds; + } + DCHECK_EQ(0u, skip_size); + + const void* pixels; + if (pixels_shm_id) { + pixels = GetSharedMemoryAs( + pixels_shm_id, pixels_shm_offset, pixels_size); + if (!pixels) + return error::kOutOfBounds; + } else { + pixels = reinterpret_cast(pixels_shm_offset); + } + + uint32_t num_pixels; + if (workarounds().simulate_out_of_memory_on_large_textures && + (!SafeMultiplyUint32(width, height, &num_pixels) || + (num_pixels >= 4096 * 4096))) { + LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, ""synthetic out of memory""); + return error::kNoError; + } + + TextureManager::DoTexImageArguments args = { + target, level, internal_format, width, height, 1, border, format, type, + pixels, pixels_size, padding, + TextureManager::DoTexImageArguments::kTexImage2D }; + texture_manager()->ValidateAndDoTexImage( + &texture_state_, &state_, &framebuffer_state_, func_name, args); + + ExitCommandProcessingEarly(); + return error::kNoError; +} +","@@ -11384,29 +11384,24 @@ void GLES2DecoderImpl::GetTexParameterImpl( + return; + } + break; +- // Get the level information from the texture to avoid a Mac driver +- // bug where they store the levels in int16_t, making values bigger +- // than 2^15-1 overflow in the negative range. + case GL_TEXTURE_BASE_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->base_level()); +- } else { +- iparams[0] = texture->base_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_base_level()); ++ } else { ++ iparams[0] = texture->unclamped_base_level(); + } +- break; ++ return; + case GL_TEXTURE_MAX_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->max_level()); +- } else { +- iparams[0] = texture->max_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_max_level()); ++ } else { ++ iparams[0] = texture->unclamped_max_level(); + } +- break; ++ return; + case GL_TEXTURE_SWIZZLE_R: + if (fparams) { + fparams[0] = static_cast(texture->swizzle_r()); +@@ -17573,25 +17568,6 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + compatibility_internal_format = format_info->decompressed_internal_format; + } + +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); +- +- // TODO(zmo): We might need to emulate TexStorage using TexImage or +- // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying +- // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. +- if (dimension == ContextState::k2D) { +- api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, +- width, height); +- } else { +- api()->glTexStorage3DFn(target, levels, compatibility_internal_format, +- width, height, depth); +- } +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, +- texture->base_level()); +- + { + GLsizei level_width = width; + GLsizei level_height = height; +@@ -17620,6 +17596,29 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + texture->ApplyFormatWorkarounds(feature_info_.get()); + texture->SetImmutable(true); + } ++ ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); ++ ++ // TODO(zmo): We might need to emulate TexStorage using TexImage or ++ // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying ++ // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. ++ if (dimension == ContextState::k2D) { ++ api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, ++ width, height); ++ } else { ++ api()->glTexStorage3DFn(target, levels, compatibility_internal_format, ++ width, height, depth); ++ } ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) { ++ // Note base_level is already clamped due to texture->SetImmutable(true). ++ // This is necessary for certain NVidia Linux drivers; otherwise they ++ // may trigger segmentation fault. See https://crbug.com/877874. ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, ++ texture->base_level()); ++ } + } + + void GLES2DecoderImpl::DoTexStorage2DEXT(GLenum target,",793,1029,2048 +8147,"static int handle_bb_cf_recursive_descent (RAnal *anal, RAnalState *state) { + + RAnalBlock *bb = state->current_bb; + + ut64 addr = 0; + int result = 0; + if (!bb) { + eprintf (""Error: unable to handle basic block @ 0x%08""PFMT64x""\n"", addr); + return R_ANAL_RET_ERROR; + } else if (state->max_depth <= state->current_depth) { + return R_ANAL_RET_ERROR; + } + + state->current_depth++; + addr = bb->addr; + IFDBG eprintf (""Handling a control flow change @ 0x%04""PFMT64x"".\n"", addr); + ut64 control_type = r_anal_ex_map_anal_ex_to_anal_op_type (bb->type2); + + switch (control_type) { + case R_ANAL_OP_TYPE_CALL: + IFDBG eprintf ("" - Handling a call @ 0x%04""PFMT64x"".\n"", addr); + r_anal_xrefs_set (anal, bb->addr, bb->jump, R_ANAL_REF_TYPE_CALL); + result = R_ANAL_RET_ERROR; + break; + case R_ANAL_OP_TYPE_JMP: + { + RList * jmp_list; + IFDBG eprintf ("" - Handling a jmp @ 0x%04""PFMT64x"" to 0x%04""PFMT64x"".\n"", addr, bb->jump); + + if (!r_anal_state_search_bb (state, bb->jump)) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->jump ); + if (jmp_list) + bb->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (bb->jumpbb) + bb->jump = bb->jumpbb->addr; + } else { + bb->jumpbb = r_anal_state_search_bb (state, bb->jump); + if (bb->jumpbb) + bb->jump = bb->jumpbb->addr; + } + + if (state->done == 1) { + IFDBG eprintf ("" Looks like this jmp (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + } + result = R_ANAL_RET_END; + } + break; + case R_ANAL_OP_TYPE_CJMP: + { + RList *jmp_list; + ut8 encountered_stop = 0; + IFDBG eprintf ("" - Handling a cjmp @ 0x%04""PFMT64x"" jmp to 0x%04""PFMT64x"" and fail to 0x%04""PFMT64x"".\n"", addr, bb->jump, bb->fail); + IFDBG eprintf ("" - Handling jmp to 0x%04""PFMT64x"".\n"", bb->jump); + if (!r_anal_state_search_bb (state, bb->jump)) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->jump ); + if (jmp_list) + bb->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (bb->jumpbb) { + bb->jump = bb->jumpbb->addr; + } + } else { + bb->jumpbb = r_anal_state_search_bb (state, bb->jump); + bb->jump = bb->jumpbb->addr; + } + + if (state->done == 1) { + IFDBG eprintf ("" Looks like this jmp (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + state->done = 0; + encountered_stop = 1; + } + + if (!r_anal_state_search_bb (state, bb->fail)) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->fail ); + if (jmp_list) + bb->failbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (bb->failbb) { + bb->fail = bb->failbb->addr; + } + } else { + bb->failbb = r_anal_state_search_bb (state, bb->fail); + if (bb->failbb) { + bb->fail = bb->failbb->addr; + } + } + + IFDBG eprintf ("" - Handling an cjmp @ 0x%04""PFMT64x"" jmp to 0x%04""PFMT64x"" and fail to 0x%04""PFMT64x"".\n"", addr, bb->jump, bb->fail); + IFDBG eprintf ("" - Handling fail to 0x%04""PFMT64x"".\n"", bb->fail); + if (state->done == 1) { + IFDBG eprintf ("" Looks like this fail (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + } + + result = R_ANAL_RET_END; + if (encountered_stop) state->done = 1; + } + break; + + case R_ANAL_OP_TYPE_SWITCH: + { + IFDBG eprintf ("" - Handling an switch @ 0x%04""PFMT64x"".\n"", addr); + if (bb->switch_op) { + RAnalCaseOp *caseop; + RListIter *iter; + RList *jmp_list = NULL; + ut8 encountered_stop = 0; + r_list_foreach (bb->switch_op->cases, iter, caseop) { + if (caseop) { + if (r_anal_state_addr_is_valid (state, caseop->jump) ) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, caseop->jump ); + if (jmp_list) + caseop->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (state->done == 1) { + IFDBG eprintf ("" Looks like this jmp (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + state->done = 0; + encountered_stop = 1; + } + } + } + } + r_list_free (jmp_list); + if (encountered_stop) state->done = 1; + } + + result = R_ANAL_RET_END; + } + break; + case R_ANAL_OP_TYPE_TRAP: + case R_ANAL_OP_TYPE_UJMP: + case R_ANAL_OP_TYPE_IJMP: + case R_ANAL_OP_TYPE_RJMP: + case R_ANAL_OP_TYPE_IRJMP: + case R_ANAL_OP_TYPE_RET: + case R_ANAL_OP_TYPE_ILL: + IFDBG eprintf ("" - Handling an ret @ 0x%04""PFMT64x"".\n"", addr); + state->done = 1; + result = R_ANAL_RET_END; + break; + default: break; + } + + state->current_depth--; + return result; +} +",0,"static int handle_bb_cf_recursive_descent (RAnal *anal, RAnalState *state) { + + RAnalBlock *bb = state->current_bb; + + ut64 addr = 0; + int result = 0; + if (!bb) { + eprintf (""Error: unable to handle basic block @ 0x%08""PFMT64x""\n"", addr); + return R_ANAL_RET_ERROR; + } else if (state->max_depth <= state->current_depth) { + return R_ANAL_RET_ERROR; + } + + state->current_depth++; + addr = bb->addr; + IFDBG eprintf (""Handling a control flow change @ 0x%04""PFMT64x"".\n"", addr); + ut64 control_type = r_anal_ex_map_anal_ex_to_anal_op_type (bb->type2); + + switch (control_type) { + case R_ANAL_OP_TYPE_CALL: + IFDBG eprintf ("" - Handling a call @ 0x%04""PFMT64x"".\n"", addr); + r_anal_xrefs_set (anal, bb->addr, bb->jump, R_ANAL_REF_TYPE_CALL); + result = R_ANAL_RET_ERROR; + break; + case R_ANAL_OP_TYPE_JMP: + { + RList * jmp_list; + IFDBG eprintf ("" - Handling a jmp @ 0x%04""PFMT64x"" to 0x%04""PFMT64x"".\n"", addr, bb->jump); + + if (!r_anal_state_search_bb (state, bb->jump)) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->jump ); + if (jmp_list) + bb->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (bb->jumpbb) + bb->jump = bb->jumpbb->addr; + } else { + bb->jumpbb = r_anal_state_search_bb (state, bb->jump); + if (bb->jumpbb) + bb->jump = bb->jumpbb->addr; + } + + if (state->done == 1) { + IFDBG eprintf ("" Looks like this jmp (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + } + result = R_ANAL_RET_END; + } + break; + case R_ANAL_OP_TYPE_CJMP: + { + RList *jmp_list; + ut8 encountered_stop = 0; + IFDBG eprintf ("" - Handling a cjmp @ 0x%04""PFMT64x"" jmp to 0x%04""PFMT64x"" and fail to 0x%04""PFMT64x"".\n"", addr, bb->jump, bb->fail); + IFDBG eprintf ("" - Handling jmp to 0x%04""PFMT64x"".\n"", bb->jump); + if (!r_anal_state_search_bb (state, bb->jump)) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->jump ); + if (jmp_list) + bb->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (bb->jumpbb) { + bb->jump = bb->jumpbb->addr; + } + } else { + bb->jumpbb = r_anal_state_search_bb (state, bb->jump); + bb->jump = bb->jumpbb->addr; + } + + if (state->done == 1) { + IFDBG eprintf ("" Looks like this jmp (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + state->done = 0; + encountered_stop = 1; + } + + if (!r_anal_state_search_bb (state, bb->fail)) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->fail ); + if (jmp_list) + bb->failbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (bb->failbb) { + bb->fail = bb->failbb->addr; + } + } else { + bb->failbb = r_anal_state_search_bb (state, bb->fail); + if (bb->failbb) { + bb->fail = bb->failbb->addr; + } + } + + IFDBG eprintf ("" - Handling an cjmp @ 0x%04""PFMT64x"" jmp to 0x%04""PFMT64x"" and fail to 0x%04""PFMT64x"".\n"", addr, bb->jump, bb->fail); + IFDBG eprintf ("" - Handling fail to 0x%04""PFMT64x"".\n"", bb->fail); + if (state->done == 1) { + IFDBG eprintf ("" Looks like this fail (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + } + + result = R_ANAL_RET_END; + if (encountered_stop) state->done = 1; + } + break; + + case R_ANAL_OP_TYPE_SWITCH: + { + IFDBG eprintf ("" - Handling an switch @ 0x%04""PFMT64x"".\n"", addr); + if (bb->switch_op) { + RAnalCaseOp *caseop; + RListIter *iter; + RList *jmp_list = NULL; + ut8 encountered_stop = 0; + r_list_foreach (bb->switch_op->cases, iter, caseop) { + if (caseop) { + if (r_anal_state_addr_is_valid (state, caseop->jump) ) { + jmp_list = r_anal_ex_perform_analysis ( anal, state, caseop->jump ); + if (jmp_list) + caseop->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0); + if (state->done == 1) { + IFDBG eprintf ("" Looks like this jmp (bb @ 0x%04""PFMT64x"") found a return.\n"", addr); + state->done = 0; + encountered_stop = 1; + } + } + } + } + r_list_free (jmp_list); + if (encountered_stop) state->done = 1; + } + + result = R_ANAL_RET_END; + } + break; + case R_ANAL_OP_TYPE_TRAP: + case R_ANAL_OP_TYPE_UJMP: + case R_ANAL_OP_TYPE_IJMP: + case R_ANAL_OP_TYPE_RJMP: + case R_ANAL_OP_TYPE_IRJMP: + case R_ANAL_OP_TYPE_RET: + case R_ANAL_OP_TYPE_ILL: + IFDBG eprintf ("" - Handling an ret @ 0x%04""PFMT64x"".\n"", addr); + state->done = 1; + result = R_ANAL_RET_END; + break; + default: break; + } + + state->current_depth--; + return result; +} +","@@ -679,11 +679,11 @@ static int java_switch_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, + + if (op_byte == 0xaa) { + // handle a table switch condition +- if (pos + 8 > len) { ++ if (pos + 8 + 8 > len) { + return op->size; + } +- int min_val = (ut32)(UINT (data, pos + 4)), +- max_val = (ut32)(UINT (data, pos + 8)); ++ const int min_val = (ut32)(UINT (data, pos + 4)); ++ const int max_val = (ut32)(UINT (data, pos + 8)); + + ut32 default_loc = (ut32) (UINT (data, pos)), cur_case = 0; + op->switch_op = r_anal_switch_op_new (addr, min_val, default_loc);",1610,1846,2048 +5516,"static int handle_revision_pseudo_opt(const char *submodule, + struct rev_info *revs, + int argc, const char **argv, int *flags) +{ + const char *arg = argv[0]; + const char *optarg; + int argcount; + + /* + * NOTE! + * + * Commands like ""git shortlog"" will not accept the options below + * unless parse_revision_opt queues them (as opposed to erroring + * out). + * + * When implementing your new pseudo-option, remember to + * register it in the list at the top of handle_revision_opt. + */ + if (!strcmp(arg, ""--all"")) { + handle_refs(submodule, revs, *flags, for_each_ref_submodule); + handle_refs(submodule, revs, *flags, head_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--branches"")) { + handle_refs(submodule, revs, *flags, for_each_branch_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--bisect"")) { + read_bisect_terms(&term_bad, &term_good); + handle_refs(submodule, revs, *flags, for_each_bad_bisect_ref); + handle_refs(submodule, revs, *flags ^ (UNINTERESTING | BOTTOM), for_each_good_bisect_ref); + revs->bisect = 1; + } else if (!strcmp(arg, ""--tags"")) { + handle_refs(submodule, revs, *flags, for_each_tag_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--remotes"")) { + handle_refs(submodule, revs, *flags, for_each_remote_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if ((argcount = parse_long_opt(""glob"", argv, &optarg))) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref(handle_one_ref, optarg, &cb); + clear_ref_exclusion(&revs->ref_excludes); + return argcount; + } else if ((argcount = parse_long_opt(""exclude"", argv, &optarg))) { + add_ref_exclusion(&revs->ref_excludes, optarg); + return argcount; + } else if (starts_with(arg, ""--branches="")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref_in(handle_one_ref, arg + 11, ""refs/heads/"", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else if (starts_with(arg, ""--tags="")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref_in(handle_one_ref, arg + 7, ""refs/tags/"", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else if (starts_with(arg, ""--remotes="")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref_in(handle_one_ref, arg + 10, ""refs/remotes/"", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--reflog"")) { + add_reflogs_to_pending(revs, *flags); + } else if (!strcmp(arg, ""--indexed-objects"")) { + add_index_objects_to_pending(revs, *flags); + } else if (!strcmp(arg, ""--not"")) { + *flags ^= UNINTERESTING | BOTTOM; + } else if (!strcmp(arg, ""--no-walk"")) { + revs->no_walk = REVISION_WALK_NO_WALK_SORTED; + } else if (starts_with(arg, ""--no-walk="")) { + /* + * Detached form (""--no-walk X"" as opposed to ""--no-walk=X"") + * not allowed, since the argument is optional. + */ + if (!strcmp(arg + 10, ""sorted"")) + revs->no_walk = REVISION_WALK_NO_WALK_SORTED; + else if (!strcmp(arg + 10, ""unsorted"")) + revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED; + else + return error(""invalid argument to --no-walk""); + } else if (!strcmp(arg, ""--do-walk"")) { + revs->no_walk = 0; + } else { + return 0; + } + + return 1; +} +",0,"static int handle_revision_pseudo_opt(const char *submodule, + struct rev_info *revs, + int argc, const char **argv, int *flags) +{ + const char *arg = argv[0]; + const char *optarg; + int argcount; + + /* + * NOTE! + * + * Commands like ""git shortlog"" will not accept the options below + * unless parse_revision_opt queues them (as opposed to erroring + * out). + * + * When implementing your new pseudo-option, remember to + * register it in the list at the top of handle_revision_opt. + */ + if (!strcmp(arg, ""--all"")) { + handle_refs(submodule, revs, *flags, for_each_ref_submodule); + handle_refs(submodule, revs, *flags, head_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--branches"")) { + handle_refs(submodule, revs, *flags, for_each_branch_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--bisect"")) { + read_bisect_terms(&term_bad, &term_good); + handle_refs(submodule, revs, *flags, for_each_bad_bisect_ref); + handle_refs(submodule, revs, *flags ^ (UNINTERESTING | BOTTOM), for_each_good_bisect_ref); + revs->bisect = 1; + } else if (!strcmp(arg, ""--tags"")) { + handle_refs(submodule, revs, *flags, for_each_tag_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--remotes"")) { + handle_refs(submodule, revs, *flags, for_each_remote_ref_submodule); + clear_ref_exclusion(&revs->ref_excludes); + } else if ((argcount = parse_long_opt(""glob"", argv, &optarg))) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref(handle_one_ref, optarg, &cb); + clear_ref_exclusion(&revs->ref_excludes); + return argcount; + } else if ((argcount = parse_long_opt(""exclude"", argv, &optarg))) { + add_ref_exclusion(&revs->ref_excludes, optarg); + return argcount; + } else if (starts_with(arg, ""--branches="")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref_in(handle_one_ref, arg + 11, ""refs/heads/"", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else if (starts_with(arg, ""--tags="")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref_in(handle_one_ref, arg + 7, ""refs/tags/"", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else if (starts_with(arg, ""--remotes="")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, *flags); + for_each_glob_ref_in(handle_one_ref, arg + 10, ""refs/remotes/"", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else if (!strcmp(arg, ""--reflog"")) { + add_reflogs_to_pending(revs, *flags); + } else if (!strcmp(arg, ""--indexed-objects"")) { + add_index_objects_to_pending(revs, *flags); + } else if (!strcmp(arg, ""--not"")) { + *flags ^= UNINTERESTING | BOTTOM; + } else if (!strcmp(arg, ""--no-walk"")) { + revs->no_walk = REVISION_WALK_NO_WALK_SORTED; + } else if (starts_with(arg, ""--no-walk="")) { + /* + * Detached form (""--no-walk X"" as opposed to ""--no-walk=X"") + * not allowed, since the argument is optional. + */ + if (!strcmp(arg + 10, ""sorted"")) + revs->no_walk = REVISION_WALK_NO_WALK_SORTED; + else if (!strcmp(arg + 10, ""unsorted"")) + revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED; + else + return error(""invalid argument to --no-walk""); + } else if (!strcmp(arg, ""--do-walk"")) { + revs->no_walk = 0; + } else { + return 0; + } + + return 1; +} +","@@ -25,27 +25,14 @@ volatile show_early_output_fn_t show_early_output; + static const char *term_bad; + static const char *term_good; + +-char *path_name(struct strbuf *path, const char *name) ++void show_object_with_name(FILE *out, struct object *obj, const char *name) + { +- struct strbuf ret = STRBUF_INIT; +- if (path) +- strbuf_addbuf(&ret, path); +- strbuf_addstr(&ret, name); +- return strbuf_detach(&ret, NULL); +-} +- +-void show_object_with_name(FILE *out, struct object *obj, +- struct strbuf *path, const char *component) +-{ +- char *name = path_name(path, component); +- char *p; ++ const char *p; + + fprintf(out, ""%s "", oid_to_hex(&obj->oid)); + for (p = name; *p && *p != '\n'; p++) + fputc(*p, out); + fputc('\n', out); +- +- free(name); + } + + static void mark_blob_uninteresting(struct blob *blob)",1015,1251,2048 +4904,"static apr_status_t h2_session_start(h2_session *session, int *rv) +{ + apr_status_t status = APR_SUCCESS; + nghttp2_settings_entry settings[3]; + size_t slen; + int win_size; + + ap_assert(session); + /* Start the conversation by submitting our SETTINGS frame */ + *rv = 0; + if (session->r) { + const char *s, *cs; + apr_size_t dlen; + h2_stream * stream; + + /* 'h2c' mode: we should have a 'HTTP2-Settings' header with + * base64 encoded client settings. */ + s = apr_table_get(session->r->headers_in, ""HTTP2-Settings""); + if (!s) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EINVAL, session->r, + APLOGNO(02931) + ""HTTP2-Settings header missing in request""); + return APR_EINVAL; + } + cs = NULL; + dlen = h2_util_base64url_decode(&cs, s, session->pool); + + if (APLOGrdebug(session->r)) { + char buffer[128]; + h2_util_hex_dump(buffer, 128, (char*)cs, dlen); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, session->r, APLOGNO(03070) + ""upgrading h2c session with HTTP2-Settings: %s -> %s (%d)"", + s, buffer, (int)dlen); + } + + *rv = nghttp2_session_upgrade(session->ngh2, (uint8_t*)cs, dlen, NULL); + if (*rv != 0) { + status = APR_EINVAL; + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, session->r, + APLOGNO(02932) ""nghttp2_session_upgrade: %s"", + nghttp2_strerror(*rv)); + return status; + } + + /* Now we need to auto-open stream 1 for the request we got. */ + stream = h2_session_open_stream(session, 1, 0, NULL); + if (!stream) { + status = APR_EGENERAL; + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, session->r, + APLOGNO(02933) ""open stream 1: %s"", + nghttp2_strerror(*rv)); + return status; + } + + status = h2_stream_set_request_rec(stream, session->r); + if (status != APR_SUCCESS) { + return status; + } + status = stream_schedule(session, stream, 1); + if (status != APR_SUCCESS) { + return status; + } + } + + slen = 0; + settings[slen].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; + settings[slen].value = (uint32_t)session->max_stream_count; + ++slen; + win_size = h2_config_geti(session->config, H2_CONF_WIN_SIZE); + if (win_size != H2_INITIAL_WINDOW_SIZE) { + settings[slen].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + settings[slen].value = win_size; + ++slen; + } + + ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, APLOGNO(03201) + ""h2_session(%ld): start, INITIAL_WINDOW_SIZE=%ld, "" + ""MAX_CONCURRENT_STREAMS=%d"", + session->id, (long)win_size, (int)session->max_stream_count); + *rv = nghttp2_submit_settings(session->ngh2, NGHTTP2_FLAG_NONE, + settings, slen); + if (*rv != 0) { + status = APR_EGENERAL; + ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c, + APLOGNO(02935) ""nghttp2_submit_settings: %s"", + nghttp2_strerror(*rv)); + } + else { + /* use maximum possible value for connection window size. We are only + * interested in per stream flow control. which have the initial window + * size configured above. + * Therefore, for our use, the connection window can only get in the + * way. Example: if we allow 100 streams with a 32KB window each, we + * buffer up to 3.2 MB of data. Unless we do separate connection window + * interim updates, any smaller connection window will lead to blocking + * in DATA flow. + */ + *rv = nghttp2_submit_window_update(session->ngh2, NGHTTP2_FLAG_NONE, + 0, NGHTTP2_MAX_WINDOW_SIZE - win_size); + if (*rv != 0) { + status = APR_EGENERAL; + ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c, + APLOGNO(02970) ""nghttp2_submit_window_update: %s"", + nghttp2_strerror(*rv)); + } + } + + return status; +} +",0,"static apr_status_t h2_session_start(h2_session *session, int *rv) +{ + apr_status_t status = APR_SUCCESS; + nghttp2_settings_entry settings[3]; + size_t slen; + int win_size; + + ap_assert(session); + /* Start the conversation by submitting our SETTINGS frame */ + *rv = 0; + if (session->r) { + const char *s, *cs; + apr_size_t dlen; + h2_stream * stream; + + /* 'h2c' mode: we should have a 'HTTP2-Settings' header with + * base64 encoded client settings. */ + s = apr_table_get(session->r->headers_in, ""HTTP2-Settings""); + if (!s) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EINVAL, session->r, + APLOGNO(02931) + ""HTTP2-Settings header missing in request""); + return APR_EINVAL; + } + cs = NULL; + dlen = h2_util_base64url_decode(&cs, s, session->pool); + + if (APLOGrdebug(session->r)) { + char buffer[128]; + h2_util_hex_dump(buffer, 128, (char*)cs, dlen); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, session->r, APLOGNO(03070) + ""upgrading h2c session with HTTP2-Settings: %s -> %s (%d)"", + s, buffer, (int)dlen); + } + + *rv = nghttp2_session_upgrade(session->ngh2, (uint8_t*)cs, dlen, NULL); + if (*rv != 0) { + status = APR_EINVAL; + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, session->r, + APLOGNO(02932) ""nghttp2_session_upgrade: %s"", + nghttp2_strerror(*rv)); + return status; + } + + /* Now we need to auto-open stream 1 for the request we got. */ + stream = h2_session_open_stream(session, 1, 0, NULL); + if (!stream) { + status = APR_EGENERAL; + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, session->r, + APLOGNO(02933) ""open stream 1: %s"", + nghttp2_strerror(*rv)); + return status; + } + + status = h2_stream_set_request_rec(stream, session->r); + if (status != APR_SUCCESS) { + return status; + } + status = stream_schedule(session, stream, 1); + if (status != APR_SUCCESS) { + return status; + } + } + + slen = 0; + settings[slen].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; + settings[slen].value = (uint32_t)session->max_stream_count; + ++slen; + win_size = h2_config_geti(session->config, H2_CONF_WIN_SIZE); + if (win_size != H2_INITIAL_WINDOW_SIZE) { + settings[slen].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + settings[slen].value = win_size; + ++slen; + } + + ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, APLOGNO(03201) + ""h2_session(%ld): start, INITIAL_WINDOW_SIZE=%ld, "" + ""MAX_CONCURRENT_STREAMS=%d"", + session->id, (long)win_size, (int)session->max_stream_count); + *rv = nghttp2_submit_settings(session->ngh2, NGHTTP2_FLAG_NONE, + settings, slen); + if (*rv != 0) { + status = APR_EGENERAL; + ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c, + APLOGNO(02935) ""nghttp2_submit_settings: %s"", + nghttp2_strerror(*rv)); + } + else { + /* use maximum possible value for connection window size. We are only + * interested in per stream flow control. which have the initial window + * size configured above. + * Therefore, for our use, the connection window can only get in the + * way. Example: if we allow 100 streams with a 32KB window each, we + * buffer up to 3.2 MB of data. Unless we do separate connection window + * interim updates, any smaller connection window will lead to blocking + * in DATA flow. + */ + *rv = nghttp2_submit_window_update(session->ngh2, NGHTTP2_FLAG_NONE, + 0, NGHTTP2_MAX_WINDOW_SIZE - win_size); + if (*rv != 0) { + status = APR_EGENERAL; + ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c, + APLOGNO(02970) ""nghttp2_submit_window_update: %s"", + nghttp2_strerror(*rv)); + } + } + + return status; +} +","@@ -394,7 +394,7 @@ static int on_header_cb(nghttp2_session *ngh2, const nghttp2_frame *frame, + (void)flags; + stream = get_stream(session, frame->hd.stream_id); + if (!stream) { +- ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c, ++ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, + APLOGNO(02920) + ""h2_session: stream(%ld-%d): on_header unknown stream"", + session->id, (int)frame->hd.stream_id); +@@ -403,7 +403,14 @@ static int on_header_cb(nghttp2_session *ngh2, const nghttp2_frame *frame, + + status = h2_stream_add_header(stream, (const char *)name, namelen, + (const char *)value, valuelen); +- if (status != APR_SUCCESS && !h2_stream_is_ready(stream)) { ++ if (status == APR_ECONNRESET) { ++ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c, ++ ""h2-stream(%ld-%d): on_header, reset stream"", ++ session->id, stream->id); ++ nghttp2_submit_rst_stream(ngh2, NGHTTP2_FLAG_NONE, stream->id, ++ NGHTTP2_INTERNAL_ERROR); ++ } ++ else if (status != APR_SUCCESS && !h2_stream_is_ready(stream)) { + return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; + } + return 0;",1131,1367,2048 +7247,"int jas_image_sampcmpt(jas_image_t *image, int cmptno, int newcmptno, + jas_image_coord_t ho, jas_image_coord_t vo, jas_image_coord_t hs, + jas_image_coord_t vs, int sgnd, int prec) +{ + jas_image_cmpt_t *oldcmpt; + jas_image_cmpt_t *newcmpt; + int width; + int height; + jas_image_coord_t tlx; + jas_image_coord_t tly; + jas_image_coord_t brx; + jas_image_coord_t bry; + int i; + int j; + jas_image_cmptparm_t cmptparm; + jas_image_coord_t ax; + jas_image_coord_t ay; + jas_image_coord_t bx; + jas_image_coord_t by; + jas_image_coord_t d0; + jas_image_coord_t d1; + jas_image_coord_t d2; + jas_image_coord_t d3; + jas_image_coord_t oldx; + jas_image_coord_t oldy; + jas_image_coord_t x; + jas_image_coord_t y; + long v; + jas_image_coord_t cmptbrx; + jas_image_coord_t cmptbry; + + assert(cmptno >= 0 && cmptno < image->numcmpts_); + oldcmpt = image->cmpts_[cmptno]; + assert(oldcmpt->tlx_ == 0 && oldcmpt->tly_ == 0); + jas_image_calcbbox2(image, &tlx, &tly, &brx, &bry); + width = FLOORDIV(brx - ho + hs, hs); + height = FLOORDIV(bry - vo + vs, vs); + cmptparm.tlx = ho; + cmptparm.tly = vo; + cmptparm.hstep = hs; + cmptparm.vstep = vs; + cmptparm.width = width; + cmptparm.height = height; + cmptparm.prec = prec; + cmptparm.sgnd = sgnd; + if (jas_image_addcmpt(image, newcmptno, &cmptparm)) + goto error; +cmptbrx = oldcmpt->tlx_ + (oldcmpt->width_ - 1) * oldcmpt->hstep_; +cmptbry = oldcmpt->tly_ + (oldcmpt->height_ - 1) * oldcmpt->vstep_; + newcmpt = image->cmpts_[newcmptno]; + jas_stream_rewind(newcmpt->stream_); + for (i = 0; i < height; ++i) { + y = newcmpt->tly_ + newcmpt->vstep_ * i; + for (j = 0; j < width; ++j) { + x = newcmpt->tlx_ + newcmpt->hstep_ * j; + ax = downtomult(x - oldcmpt->tlx_, oldcmpt->hstep_) + oldcmpt->tlx_; + ay = downtomult(y - oldcmpt->tly_, oldcmpt->vstep_) + oldcmpt->tly_; + bx = uptomult(x - oldcmpt->tlx_, oldcmpt->hstep_) + oldcmpt->tlx_; + if (bx > cmptbrx) + bx = cmptbrx; + by = uptomult(y - oldcmpt->tly_, oldcmpt->vstep_) + oldcmpt->tly_; + if (by > cmptbry) + by = cmptbry; + d0 = (ax - x) * (ax - x) + (ay - y) * (ay - y); + d1 = (bx - x) * (bx - x) + (ay - y) * (ay - y); + d2 = (bx - x) * (bx - x) + (by - y) * (by - y); + d3 = (ax - x) * (ax - x) + (by - y) * (by - y); + if (d0 <= d1 && d0 <= d2 && d0 <= d3) { + oldx = (ax - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (ay - oldcmpt->tly_) / oldcmpt->vstep_; + } else if (d1 <= d0 && d1 <= d2 && d1 <= d3) { + oldx = (bx - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (ay - oldcmpt->tly_) / oldcmpt->vstep_; + } else if (d2 <= d0 && d2 <= d1 && d1 <= d3) { + oldx = (bx - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (by - oldcmpt->tly_) / oldcmpt->vstep_; + } else { + oldx = (ax - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (by - oldcmpt->tly_) / oldcmpt->vstep_; + } + assert(oldx >= 0 && oldx < oldcmpt->width_ && + oldy >= 0 && oldy < oldcmpt->height_); + if (jas_stream_seek(oldcmpt->stream_, oldcmpt->cps_ * + (oldy * oldcmpt->width_ + oldx), SEEK_SET) < 0) + goto error; + if (getint(oldcmpt->stream_, oldcmpt->sgnd_, + oldcmpt->prec_, &v)) + goto error; + if (newcmpt->prec_ != oldcmpt->prec_ || + newcmpt->sgnd_ != oldcmpt->sgnd_) { + v = convert(v, oldcmpt->sgnd_, oldcmpt->prec_, + newcmpt->sgnd_, newcmpt->prec_); + } + if (putint(newcmpt->stream_, newcmpt->sgnd_, + newcmpt->prec_, v)) + goto error; + } + } + return 0; +error: + return -1; +} +",0,"int jas_image_sampcmpt(jas_image_t *image, int cmptno, int newcmptno, + jas_image_coord_t ho, jas_image_coord_t vo, jas_image_coord_t hs, + jas_image_coord_t vs, int sgnd, int prec) +{ + jas_image_cmpt_t *oldcmpt; + jas_image_cmpt_t *newcmpt; + int width; + int height; + jas_image_coord_t tlx; + jas_image_coord_t tly; + jas_image_coord_t brx; + jas_image_coord_t bry; + int i; + int j; + jas_image_cmptparm_t cmptparm; + jas_image_coord_t ax; + jas_image_coord_t ay; + jas_image_coord_t bx; + jas_image_coord_t by; + jas_image_coord_t d0; + jas_image_coord_t d1; + jas_image_coord_t d2; + jas_image_coord_t d3; + jas_image_coord_t oldx; + jas_image_coord_t oldy; + jas_image_coord_t x; + jas_image_coord_t y; + long v; + jas_image_coord_t cmptbrx; + jas_image_coord_t cmptbry; + + assert(cmptno >= 0 && cmptno < image->numcmpts_); + oldcmpt = image->cmpts_[cmptno]; + assert(oldcmpt->tlx_ == 0 && oldcmpt->tly_ == 0); + jas_image_calcbbox2(image, &tlx, &tly, &brx, &bry); + width = FLOORDIV(brx - ho + hs, hs); + height = FLOORDIV(bry - vo + vs, vs); + cmptparm.tlx = ho; + cmptparm.tly = vo; + cmptparm.hstep = hs; + cmptparm.vstep = vs; + cmptparm.width = width; + cmptparm.height = height; + cmptparm.prec = prec; + cmptparm.sgnd = sgnd; + if (jas_image_addcmpt(image, newcmptno, &cmptparm)) + goto error; +cmptbrx = oldcmpt->tlx_ + (oldcmpt->width_ - 1) * oldcmpt->hstep_; +cmptbry = oldcmpt->tly_ + (oldcmpt->height_ - 1) * oldcmpt->vstep_; + newcmpt = image->cmpts_[newcmptno]; + jas_stream_rewind(newcmpt->stream_); + for (i = 0; i < height; ++i) { + y = newcmpt->tly_ + newcmpt->vstep_ * i; + for (j = 0; j < width; ++j) { + x = newcmpt->tlx_ + newcmpt->hstep_ * j; + ax = downtomult(x - oldcmpt->tlx_, oldcmpt->hstep_) + oldcmpt->tlx_; + ay = downtomult(y - oldcmpt->tly_, oldcmpt->vstep_) + oldcmpt->tly_; + bx = uptomult(x - oldcmpt->tlx_, oldcmpt->hstep_) + oldcmpt->tlx_; + if (bx > cmptbrx) + bx = cmptbrx; + by = uptomult(y - oldcmpt->tly_, oldcmpt->vstep_) + oldcmpt->tly_; + if (by > cmptbry) + by = cmptbry; + d0 = (ax - x) * (ax - x) + (ay - y) * (ay - y); + d1 = (bx - x) * (bx - x) + (ay - y) * (ay - y); + d2 = (bx - x) * (bx - x) + (by - y) * (by - y); + d3 = (ax - x) * (ax - x) + (by - y) * (by - y); + if (d0 <= d1 && d0 <= d2 && d0 <= d3) { + oldx = (ax - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (ay - oldcmpt->tly_) / oldcmpt->vstep_; + } else if (d1 <= d0 && d1 <= d2 && d1 <= d3) { + oldx = (bx - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (ay - oldcmpt->tly_) / oldcmpt->vstep_; + } else if (d2 <= d0 && d2 <= d1 && d1 <= d3) { + oldx = (bx - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (by - oldcmpt->tly_) / oldcmpt->vstep_; + } else { + oldx = (ax - oldcmpt->tlx_) / oldcmpt->hstep_; + oldy = (by - oldcmpt->tly_) / oldcmpt->vstep_; + } + assert(oldx >= 0 && oldx < oldcmpt->width_ && + oldy >= 0 && oldy < oldcmpt->height_); + if (jas_stream_seek(oldcmpt->stream_, oldcmpt->cps_ * + (oldy * oldcmpt->width_ + oldx), SEEK_SET) < 0) + goto error; + if (getint(oldcmpt->stream_, oldcmpt->sgnd_, + oldcmpt->prec_, &v)) + goto error; + if (newcmpt->prec_ != oldcmpt->prec_ || + newcmpt->sgnd_ != oldcmpt->sgnd_) { + v = convert(v, oldcmpt->sgnd_, oldcmpt->prec_, + newcmpt->sgnd_, newcmpt->prec_); + } + if (putint(newcmpt->stream_, newcmpt->sgnd_, + newcmpt->prec_, v)) + goto error; + } + } + return 0; +error: + return -1; +} +","@@ -133,30 +133,35 @@ jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms, + int clrspc) + { + jas_image_t *image; +- uint_fast32_t rawsize; ++ size_t rawsize; + uint_fast32_t inmem; + int cmptno; + jas_image_cmptparm_t *cmptparm; + ++ image = 0; ++ ++ JAS_DBGLOG(100, (""jas_image_create(%d, %p, %d)\n"", numcmpts, cmptparms, ++ clrspc)); ++ + if (!(image = jas_image_create0())) { +- return 0; ++ goto error; + } + + image->clrspc_ = clrspc; + image->maxcmpts_ = numcmpts; +- image->inmem_ = true; ++// image->inmem_ = true; + + /* Allocate memory for the per-component information. */ + if (!(image->cmpts_ = jas_alloc2(image->maxcmpts_, + sizeof(jas_image_cmpt_t *)))) { +- jas_image_destroy(image); +- return 0; ++ goto error; + } + /* Initialize in case of failure. */ + for (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) { + image->cmpts_[cmptno] = 0; + } + ++#if 0 + /* Compute the approximate raw size of the image. */ + rawsize = 0; + for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno, +@@ -167,16 +172,22 @@ jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms, + /* Decide whether to buffer the image data in memory, based on the + raw size of the image. */ + inmem = (rawsize < JAS_IMAGE_INMEMTHRESH); ++#endif + + /* Create the individual image components. */ + for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno, + ++cmptparm) { ++ if (!jas_safe_size_mul3(cmptparm->width, cmptparm->height, ++ (cmptparm->prec + 7), &rawsize)) { ++ goto error; ++ } ++ rawsize /= 8; ++ inmem = (rawsize < JAS_IMAGE_INMEMTHRESH); + if (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx, + cmptparm->tly, cmptparm->hstep, cmptparm->vstep, + cmptparm->width, cmptparm->height, cmptparm->prec, + cmptparm->sgnd, inmem))) { +- jas_image_destroy(image); +- return 0; ++ goto error; + } + ++image->numcmpts_; + } +@@ -186,6 +197,12 @@ jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms, + jas_image_setbbox(image); + + return image; ++ ++error: ++ if (image) { ++ jas_image_destroy(image); ++ } ++ return 0; + } + + jas_image_t *jas_image_create0() +@@ -204,7 +221,7 @@ jas_image_t *jas_image_create0() + image->numcmpts_ = 0; + image->maxcmpts_ = 0; + image->cmpts_ = 0; +- image->inmem_ = true; ++// image->inmem_ = true; + image->cmprof_ = 0; + + return image; +@@ -316,6 +333,19 @@ static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx, + jas_image_cmpt_t *cmpt; + size_t size; + ++ JAS_DBGLOG(100, ( ++ ""jas_image_cmpt_create(%ld, %ld, %ld, %ld, %ld, %ld, %d, %d, %d)\n"", ++ JAS_CAST(long, tlx), ++ JAS_CAST(long, tly), ++ JAS_CAST(long, hstep), ++ JAS_CAST(long, vstep), ++ JAS_CAST(long, width), ++ JAS_CAST(long, height), ++ JAS_CAST(int, depth), ++ sgnd, ++ inmem ++ )); ++ + cmpt = 0; + if (width < 0 || height < 0 || hstep <= 0 || vstep <= 0) { + goto error; +@@ -324,6 +354,9 @@ static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx, + !jas_safe_intfast32_add(tly, height, 0)) { + goto error; + } ++ if (!jas_safe_intfast32_mul3(width, height, depth, 0)) { ++ goto error; ++ } + + if (!(cmpt = jas_malloc(sizeof(jas_image_cmpt_t)))) { + goto error; +@@ -344,8 +377,7 @@ static jas_image_cmpt_t *jas_image_cmpt_create(int_fast32_t tlx, + // Compute the number of samples in the image component, while protecting + // against overflow. + // size = cmpt->width_ * cmpt->height_ * cmpt->cps_; +- if (!jas_safe_size_mul(cmpt->width_, cmpt->height_, &size) || +- !jas_safe_size_mul(size, cmpt->cps_, &size)) { ++ if (!jas_safe_size_mul3(cmpt->width_, cmpt->height_, cmpt->cps_, &size)) { + goto error; + } + cmpt->stream_ = (inmem) ? jas_stream_memopen2(0, size) : +@@ -1279,7 +1311,7 @@ static void jas_image_calcbbox2(jas_image_t *image, jas_image_coord_t *tlx, + *bry = tmpbry; + } + +-static inline long decode_twos_comp(ulong c, int prec) ++static inline long decode_twos_comp(jas_ulong c, int prec) + { + long result; + assert(prec >= 2); +@@ -1289,9 +1321,9 @@ static inline long decode_twos_comp(ulong c, int prec) + return result; + } + +-static inline ulong encode_twos_comp(long n, int prec) ++static inline jas_ulong encode_twos_comp(long n, int prec) + { +- ulong result; ++ jas_ulong result; + assert(prec >= 2); + jas_eprintf(""warning: support for signed data is untested\n""); + // NOTE: Is this correct? +@@ -1332,7 +1364,7 @@ static int putint(jas_stream_t *out, int sgnd, int prec, long val) + int n; + int c; + bool s; +- ulong tmp; ++ jas_ulong tmp; + assert((!sgnd && prec >= 1) || (sgnd && prec >= 2)); + if (sgnd) { + val = encode_twos_comp(val, prec);",1364,1600,2048 +17791,"s_aes_process(stream_state * ss, stream_cursor_read * pr, + stream_cursor_write * pw, bool last) +{ + stream_aes_state *const state = (stream_aes_state *) ss; + const unsigned char *limit; + const long in_size = pr->limit - pr->ptr; + const long out_size = pw->limit - pw->ptr; + unsigned char temp[16]; + int status = 0; + + /* figure out if we're going to run out of space */ + if (in_size > out_size) { + limit = pr->ptr + out_size; + status = 1; /* need more output space */ + } else { + limit = pr->limit; + status = last ? EOFC : 0; /* need more input */ + } + + /* set up state and context */ + if (state->ctx == NULL) { + /* allocate the aes context. this is a public struct but it + contains internal pointers, so we need to store it separately + in immovable memory like any opaque structure. */ + state->ctx = (aes_context *)gs_alloc_bytes_immovable(state->memory, + sizeof(aes_context), ""aes context structure""); + if (state->ctx == NULL) { + gs_throw(gs_error_VMerror, ""could not allocate aes context""); + return ERRC; + } + if (state->keylength < 1 || state->keylength > SAES_MAX_KEYLENGTH) { + gs_throw1(gs_error_rangecheck, ""invalid aes key length (%d bytes)"", + state->keylength); + } + aes_setkey_dec(state->ctx, state->key, state->keylength * 8); + } + if (!state->initialized) { + /* read the initialization vector from the first 16 bytes */ + if (in_size < 16) return 0; /* get more data */ + memcpy(state->iv, pr->ptr + 1, 16); + state->initialized = 1; + pr->ptr += 16; + } + + /* decrypt available blocks */ + while (pr->ptr + 16 <= limit) { + aes_crypt_cbc(state->ctx, AES_DECRYPT, 16, state->iv, + pr->ptr + 1, temp); + pr->ptr += 16; + if (last && pr->ptr == pr->limit) { + /* we're on the last block; unpad if necessary */ + int pad; + + if (state->use_padding) { + /* we are using RFC 1423-style padding, so the last byte of the + plaintext gives the number of bytes to discard */ + pad = temp[15]; + if (pad < 1 || pad > 16) { + /* Bug 692343 - don't error here, just warn. Take padding to be + * zero. This may give us a stream that's too long - preferable + * to the alternatives. */ + gs_warn1(""invalid aes padding byte (0x%02x)"", + (unsigned char)pad); + pad = 0; + } + } else { + /* not using padding */ + pad = 0; + } + + memcpy(pw->ptr + 1, temp, 16 - pad); + pw->ptr += 16 - pad; + return EOFC; + } + memcpy(pw->ptr + 1, temp, 16); + pw->ptr += 16; + } + + /* if we got to the end of the file without triggering the padding + check, the input must not have been a multiple of 16 bytes long. + complain. */ + if (status == EOFC) { + gs_throw(gs_error_rangecheck, ""aes stream isn't a multiple of 16 bytes""); + return 0; + } + + return status; +} +",1,"s_aes_process(stream_state * ss, stream_cursor_read * pr, + stream_cursor_write * pw, bool last) +{ + stream_aes_state *const state = (stream_aes_state *) ss; + const unsigned char *limit; + const long in_size = pr->limit - pr->ptr; + const long out_size = pw->limit - pw->ptr; + unsigned char temp[16]; + int status = 0; + + /* figure out if we're going to run out of space */ + if (in_size > out_size) { + limit = pr->ptr + out_size; + status = 1; /* need more output space */ + } else { + limit = pr->limit; + status = last ? EOFC : 0; /* need more input */ + } + + /* set up state and context */ + if (state->ctx == NULL) { + /* allocate the aes context. this is a public struct but it + contains internal pointers, so we need to store it separately + in immovable memory like any opaque structure. */ + state->ctx = (aes_context *)gs_alloc_bytes_immovable(state->memory, + sizeof(aes_context), ""aes context structure""); + if (state->ctx == NULL) { + gs_throw(gs_error_VMerror, ""could not allocate aes context""); + return ERRC; + } + memset(state->ctx, 0x00, sizeof(aes_context)); + if (state->keylength < 1 || state->keylength > SAES_MAX_KEYLENGTH) { + gs_throw1(gs_error_rangecheck, ""invalid aes key length (%d bytes)"", + state->keylength); + } + aes_setkey_dec(state->ctx, state->key, state->keylength * 8); + } + if (!state->initialized) { + /* read the initialization vector from the first 16 bytes */ + if (in_size < 16) return 0; /* get more data */ + memcpy(state->iv, pr->ptr + 1, 16); + state->initialized = 1; + pr->ptr += 16; + } + + /* decrypt available blocks */ + while (pr->ptr + 16 <= limit) { + aes_crypt_cbc(state->ctx, AES_DECRYPT, 16, state->iv, + pr->ptr + 1, temp); + pr->ptr += 16; + if (last && pr->ptr == pr->limit) { + /* we're on the last block; unpad if necessary */ + int pad; + + if (state->use_padding) { + /* we are using RFC 1423-style padding, so the last byte of the + plaintext gives the number of bytes to discard */ + pad = temp[15]; + if (pad < 1 || pad > 16) { + /* Bug 692343 - don't error here, just warn. Take padding to be + * zero. This may give us a stream that's too long - preferable + * to the alternatives. */ + gs_warn1(""invalid aes padding byte (0x%02x)"", + (unsigned char)pad); + pad = 0; + } + } else { + /* not using padding */ + pad = 0; + } + + memcpy(pw->ptr + 1, temp, 16 - pad); + pw->ptr += 16 - pad; + return EOFC; + } + memcpy(pw->ptr + 1, temp, 16); + pw->ptr += 16; + } + + /* if we got to the end of the file without triggering the padding + check, the input must not have been a multiple of 16 bytes long. + complain. */ + if (status == EOFC) { + gs_throw(gs_error_rangecheck, ""aes stream isn't a multiple of 16 bytes""); + return 0; + } + + return status; +} +","@@ -120,6 +120,7 @@ s_aes_process(stream_state * ss, stream_cursor_read * pr, + gs_throw(gs_error_VMerror, ""could not allocate aes context""); + return ERRC; + } ++ memset(state->ctx, 0x00, sizeof(aes_context)); + if (state->keylength < 1 || state->keylength > SAES_MAX_KEYLENGTH) { + gs_throw1(gs_error_rangecheck, ""invalid aes key length (%d bytes)"", + state->keylength);",830,1066,2048 +4536,"ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, + struct ext4_map_blocks *map, + struct ext4_ext_path **ppath, int flags, + unsigned int allocated, ext4_fsblk_t newblock) +{ + struct ext4_ext_path *path = *ppath; + int ret = 0; + int err = 0; + ext4_io_end_t *io = ext4_inode_aio(inode); + + ext_debug(""ext4_ext_handle_unwritten_extents: inode %lu, logical "" + ""block %llu, max_blocks %u, flags %x, allocated %u\n"", + inode->i_ino, (unsigned long long)map->m_lblk, map->m_len, + flags, allocated); + ext4_ext_show_leaf(inode, path); + + /* + * When writing into unwritten space, we should not fail to + * allocate metadata blocks for the new extent block if needed. + */ + flags |= EXT4_GET_BLOCKS_METADATA_NOFAIL; + + trace_ext4_ext_handle_unwritten_extents(inode, map, flags, + allocated, newblock); + + /* get_block() before submit the IO, split the extent */ + if (flags & EXT4_GET_BLOCKS_PRE_IO) { + ret = ext4_split_convert_extents(handle, inode, map, ppath, + flags | EXT4_GET_BLOCKS_CONVERT); + if (ret <= 0) + goto out; + /* + * Flag the inode(non aio case) or end_io struct (aio case) + * that this IO needs to conversion to written when IO is + * completed + */ + if (io) + ext4_set_io_unwritten_flag(inode, io); + else + ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); + map->m_flags |= EXT4_MAP_UNWRITTEN; + goto out; + } + /* IO end_io complete, convert the filled extent to written */ + if (flags & EXT4_GET_BLOCKS_CONVERT) { + ret = ext4_convert_unwritten_extents_endio(handle, inode, map, + ppath); + if (ret >= 0) { + ext4_update_inode_fsync_trans(handle, inode, 1); + err = check_eofblocks_fl(handle, inode, map->m_lblk, + path, map->m_len); + } else + err = ret; + map->m_flags |= EXT4_MAP_MAPPED; + map->m_pblk = newblock; + if (allocated > map->m_len) + allocated = map->m_len; + map->m_len = allocated; + goto out2; + } + /* buffered IO case */ + /* + * repeat fallocate creation request + * we already have an unwritten extent + */ + if (flags & EXT4_GET_BLOCKS_UNWRIT_EXT) { + map->m_flags |= EXT4_MAP_UNWRITTEN; + goto map_out; + } + + /* buffered READ or buffered write_begin() lookup */ + if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { + /* + * We have blocks reserved already. We + * return allocated blocks so that delalloc + * won't do block reservation for us. But + * the buffer head will be unmapped so that + * a read from the block returns 0s. + */ + map->m_flags |= EXT4_MAP_UNWRITTEN; + goto out1; + } + + /* buffered write, writepage time, convert*/ + ret = ext4_ext_convert_to_initialized(handle, inode, map, ppath, flags); + if (ret >= 0) + ext4_update_inode_fsync_trans(handle, inode, 1); +out: + if (ret <= 0) { + err = ret; + goto out2; + } else + allocated = ret; + map->m_flags |= EXT4_MAP_NEW; + /* + * if we allocated more blocks than requested + * we need to make sure we unmap the extra block + * allocated. The actual needed block will get + * unmapped later when we find the buffer_head marked + * new. + */ + if (allocated > map->m_len) { + unmap_underlying_metadata_blocks(inode->i_sb->s_bdev, + newblock + map->m_len, + allocated - map->m_len); + allocated = map->m_len; + } + map->m_len = allocated; + + /* + * If we have done fallocate with the offset that is already + * delayed allocated, we would have block reservation + * and quota reservation done in the delayed write path. + * But fallocate would have already updated quota and block + * count for this offset. So cancel these reservation + */ + if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) { + unsigned int reserved_clusters; + reserved_clusters = get_reserved_cluster_alloc(inode, + map->m_lblk, map->m_len); + if (reserved_clusters) + ext4_da_update_reserve_space(inode, + reserved_clusters, + 0); + } + +map_out: + map->m_flags |= EXT4_MAP_MAPPED; + if ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0) { + err = check_eofblocks_fl(handle, inode, map->m_lblk, path, + map->m_len); + if (err < 0) + goto out2; + } +out1: + if (allocated > map->m_len) + allocated = map->m_len; + ext4_ext_show_leaf(inode, path); + map->m_pblk = newblock; + map->m_len = allocated; +out2: + return err ? err : allocated; +} +",0,"ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, + struct ext4_map_blocks *map, + struct ext4_ext_path **ppath, int flags, + unsigned int allocated, ext4_fsblk_t newblock) +{ + struct ext4_ext_path *path = *ppath; + int ret = 0; + int err = 0; + ext4_io_end_t *io = ext4_inode_aio(inode); + + ext_debug(""ext4_ext_handle_unwritten_extents: inode %lu, logical "" + ""block %llu, max_blocks %u, flags %x, allocated %u\n"", + inode->i_ino, (unsigned long long)map->m_lblk, map->m_len, + flags, allocated); + ext4_ext_show_leaf(inode, path); + + /* + * When writing into unwritten space, we should not fail to + * allocate metadata blocks for the new extent block if needed. + */ + flags |= EXT4_GET_BLOCKS_METADATA_NOFAIL; + + trace_ext4_ext_handle_unwritten_extents(inode, map, flags, + allocated, newblock); + + /* get_block() before submit the IO, split the extent */ + if (flags & EXT4_GET_BLOCKS_PRE_IO) { + ret = ext4_split_convert_extents(handle, inode, map, ppath, + flags | EXT4_GET_BLOCKS_CONVERT); + if (ret <= 0) + goto out; + /* + * Flag the inode(non aio case) or end_io struct (aio case) + * that this IO needs to conversion to written when IO is + * completed + */ + if (io) + ext4_set_io_unwritten_flag(inode, io); + else + ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); + map->m_flags |= EXT4_MAP_UNWRITTEN; + goto out; + } + /* IO end_io complete, convert the filled extent to written */ + if (flags & EXT4_GET_BLOCKS_CONVERT) { + ret = ext4_convert_unwritten_extents_endio(handle, inode, map, + ppath); + if (ret >= 0) { + ext4_update_inode_fsync_trans(handle, inode, 1); + err = check_eofblocks_fl(handle, inode, map->m_lblk, + path, map->m_len); + } else + err = ret; + map->m_flags |= EXT4_MAP_MAPPED; + map->m_pblk = newblock; + if (allocated > map->m_len) + allocated = map->m_len; + map->m_len = allocated; + goto out2; + } + /* buffered IO case */ + /* + * repeat fallocate creation request + * we already have an unwritten extent + */ + if (flags & EXT4_GET_BLOCKS_UNWRIT_EXT) { + map->m_flags |= EXT4_MAP_UNWRITTEN; + goto map_out; + } + + /* buffered READ or buffered write_begin() lookup */ + if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { + /* + * We have blocks reserved already. We + * return allocated blocks so that delalloc + * won't do block reservation for us. But + * the buffer head will be unmapped so that + * a read from the block returns 0s. + */ + map->m_flags |= EXT4_MAP_UNWRITTEN; + goto out1; + } + + /* buffered write, writepage time, convert*/ + ret = ext4_ext_convert_to_initialized(handle, inode, map, ppath, flags); + if (ret >= 0) + ext4_update_inode_fsync_trans(handle, inode, 1); +out: + if (ret <= 0) { + err = ret; + goto out2; + } else + allocated = ret; + map->m_flags |= EXT4_MAP_NEW; + /* + * if we allocated more blocks than requested + * we need to make sure we unmap the extra block + * allocated. The actual needed block will get + * unmapped later when we find the buffer_head marked + * new. + */ + if (allocated > map->m_len) { + unmap_underlying_metadata_blocks(inode->i_sb->s_bdev, + newblock + map->m_len, + allocated - map->m_len); + allocated = map->m_len; + } + map->m_len = allocated; + + /* + * If we have done fallocate with the offset that is already + * delayed allocated, we would have block reservation + * and quota reservation done in the delayed write path. + * But fallocate would have already updated quota and block + * count for this offset. So cancel these reservation + */ + if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) { + unsigned int reserved_clusters; + reserved_clusters = get_reserved_cluster_alloc(inode, + map->m_lblk, map->m_len); + if (reserved_clusters) + ext4_da_update_reserve_space(inode, + reserved_clusters, + 0); + } + +map_out: + map->m_flags |= EXT4_MAP_MAPPED; + if ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0) { + err = check_eofblocks_fl(handle, inode, map->m_lblk, path, + map->m_len); + if (err < 0) + goto out2; + } +out1: + if (allocated > map->m_len) + allocated = map->m_len; + ext4_ext_show_leaf(inode, path); + map->m_pblk = newblock; + map->m_len = allocated; +out2: + return err ? err : allocated; +} +","@@ -4797,12 +4797,6 @@ static long ext4_zero_range(struct file *file, loff_t offset, + else + max_blocks -= lblk; + +- flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT | +- EXT4_GET_BLOCKS_CONVERT_UNWRITTEN | +- EXT4_EX_NOCACHE; +- if (mode & FALLOC_FL_KEEP_SIZE) +- flags |= EXT4_GET_BLOCKS_KEEP_SIZE; +- + mutex_lock(&inode->i_mutex); + + /* +@@ -4819,15 +4813,28 @@ static long ext4_zero_range(struct file *file, loff_t offset, + ret = inode_newsize_ok(inode, new_size); + if (ret) + goto out_mutex; +- /* +- * If we have a partial block after EOF we have to allocate +- * the entire block. +- */ +- if (partial_end) +- max_blocks += 1; + } + ++ flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT; ++ if (mode & FALLOC_FL_KEEP_SIZE) ++ flags |= EXT4_GET_BLOCKS_KEEP_SIZE; ++ ++ /* Preallocate the range including the unaligned edges */ ++ if (partial_begin || partial_end) { ++ ret = ext4_alloc_file_blocks(file, ++ round_down(offset, 1 << blkbits) >> blkbits, ++ (round_up((offset + len), 1 << blkbits) - ++ round_down(offset, 1 << blkbits)) >> blkbits, ++ new_size, flags, mode); ++ if (ret) ++ goto out_mutex; ++ ++ } ++ ++ /* Zero range excluding the unaligned edges */ + if (max_blocks > 0) { ++ flags |= (EXT4_GET_BLOCKS_CONVERT_UNWRITTEN | ++ EXT4_EX_NOCACHE); + + /* Now release the pages and zero block aligned part of pages*/ + truncate_pagecache_range(inode, start, end - 1);",1202,1438,2048 +4124,"static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32) +{ + struct compat_ethtool_rxnfc __user *compat_rxnfc; + bool convert_in = false, convert_out = false; + size_t buf_size = ALIGN(sizeof(struct ifreq), 8); + struct ethtool_rxnfc __user *rxnfc; + struct ifreq __user *ifr; + u32 rule_cnt = 0, actual_rule_cnt; + u32 ethcmd; + u32 data; + int ret; + + if (get_user(data, &ifr32->ifr_ifru.ifru_data)) + return -EFAULT; + + compat_rxnfc = compat_ptr(data); + + if (get_user(ethcmd, &compat_rxnfc->cmd)) + return -EFAULT; + + /* Most ethtool structures are defined without padding. + * Unfortunately struct ethtool_rxnfc is an exception. + */ + switch (ethcmd) { + default: + break; + case ETHTOOL_GRXCLSRLALL: + /* Buffer size is variable */ + if (get_user(rule_cnt, &compat_rxnfc->rule_cnt)) + return -EFAULT; + if (rule_cnt > KMALLOC_MAX_SIZE / sizeof(u32)) + return -ENOMEM; + buf_size += rule_cnt * sizeof(u32); + /* fall through */ + case ETHTOOL_GRXRINGS: + case ETHTOOL_GRXCLSRLCNT: + case ETHTOOL_GRXCLSRULE: + case ETHTOOL_SRXCLSRLINS: + convert_out = true; + /* fall through */ + case ETHTOOL_SRXCLSRLDEL: + buf_size += sizeof(struct ethtool_rxnfc); + convert_in = true; + break; + } + + ifr = compat_alloc_user_space(buf_size); + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8); + + if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) + return -EFAULT; + + if (put_user(convert_in ? rxnfc : compat_ptr(data), + &ifr->ifr_ifru.ifru_data)) + return -EFAULT; + + if (convert_in) { + /* We expect there to be holes between fs.m_ext and + * fs.ring_cookie and at the end of fs, but nowhere else. + */ + BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.m_ext) + + sizeof(compat_rxnfc->fs.m_ext) != + offsetof(struct ethtool_rxnfc, fs.m_ext) + + sizeof(rxnfc->fs.m_ext)); + BUILD_BUG_ON( + offsetof(struct compat_ethtool_rxnfc, fs.location) - + offsetof(struct compat_ethtool_rxnfc, fs.ring_cookie) != + offsetof(struct ethtool_rxnfc, fs.location) - + offsetof(struct ethtool_rxnfc, fs.ring_cookie)); + + if (copy_in_user(rxnfc, compat_rxnfc, + (void __user *)(&rxnfc->fs.m_ext + 1) - + (void __user *)rxnfc) || + copy_in_user(&rxnfc->fs.ring_cookie, + &compat_rxnfc->fs.ring_cookie, + (void __user *)(&rxnfc->fs.location + 1) - + (void __user *)&rxnfc->fs.ring_cookie) || + copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt, + sizeof(rxnfc->rule_cnt))) + return -EFAULT; + } + + ret = dev_ioctl(net, SIOCETHTOOL, ifr); + if (ret) + return ret; + + if (convert_out) { + if (copy_in_user(compat_rxnfc, rxnfc, + (const void __user *)(&rxnfc->fs.m_ext + 1) - + (const void __user *)rxnfc) || + copy_in_user(&compat_rxnfc->fs.ring_cookie, + &rxnfc->fs.ring_cookie, + (const void __user *)(&rxnfc->fs.location + 1) - + (const void __user *)&rxnfc->fs.ring_cookie) || + copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt, + sizeof(rxnfc->rule_cnt))) + return -EFAULT; + + if (ethcmd == ETHTOOL_GRXCLSRLALL) { + /* As an optimisation, we only copy the actual + * number of rules that the underlying + * function returned. Since Mallory might + * change the rule count in user memory, we + * check that it is less than the rule count + * originally given (as the user buffer size), + * which has been range-checked. + */ + if (get_user(actual_rule_cnt, &rxnfc->rule_cnt)) + return -EFAULT; + if (actual_rule_cnt < rule_cnt) + rule_cnt = actual_rule_cnt; + if (copy_in_user(&compat_rxnfc->rule_locs[0], + &rxnfc->rule_locs[0], + rule_cnt * sizeof(u32))) + return -EFAULT; + } + } + + return 0; +} +",0,"static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32) +{ + struct compat_ethtool_rxnfc __user *compat_rxnfc; + bool convert_in = false, convert_out = false; + size_t buf_size = ALIGN(sizeof(struct ifreq), 8); + struct ethtool_rxnfc __user *rxnfc; + struct ifreq __user *ifr; + u32 rule_cnt = 0, actual_rule_cnt; + u32 ethcmd; + u32 data; + int ret; + + if (get_user(data, &ifr32->ifr_ifru.ifru_data)) + return -EFAULT; + + compat_rxnfc = compat_ptr(data); + + if (get_user(ethcmd, &compat_rxnfc->cmd)) + return -EFAULT; + + /* Most ethtool structures are defined without padding. + * Unfortunately struct ethtool_rxnfc is an exception. + */ + switch (ethcmd) { + default: + break; + case ETHTOOL_GRXCLSRLALL: + /* Buffer size is variable */ + if (get_user(rule_cnt, &compat_rxnfc->rule_cnt)) + return -EFAULT; + if (rule_cnt > KMALLOC_MAX_SIZE / sizeof(u32)) + return -ENOMEM; + buf_size += rule_cnt * sizeof(u32); + /* fall through */ + case ETHTOOL_GRXRINGS: + case ETHTOOL_GRXCLSRLCNT: + case ETHTOOL_GRXCLSRULE: + case ETHTOOL_SRXCLSRLINS: + convert_out = true; + /* fall through */ + case ETHTOOL_SRXCLSRLDEL: + buf_size += sizeof(struct ethtool_rxnfc); + convert_in = true; + break; + } + + ifr = compat_alloc_user_space(buf_size); + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8); + + if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) + return -EFAULT; + + if (put_user(convert_in ? rxnfc : compat_ptr(data), + &ifr->ifr_ifru.ifru_data)) + return -EFAULT; + + if (convert_in) { + /* We expect there to be holes between fs.m_ext and + * fs.ring_cookie and at the end of fs, but nowhere else. + */ + BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.m_ext) + + sizeof(compat_rxnfc->fs.m_ext) != + offsetof(struct ethtool_rxnfc, fs.m_ext) + + sizeof(rxnfc->fs.m_ext)); + BUILD_BUG_ON( + offsetof(struct compat_ethtool_rxnfc, fs.location) - + offsetof(struct compat_ethtool_rxnfc, fs.ring_cookie) != + offsetof(struct ethtool_rxnfc, fs.location) - + offsetof(struct ethtool_rxnfc, fs.ring_cookie)); + + if (copy_in_user(rxnfc, compat_rxnfc, + (void __user *)(&rxnfc->fs.m_ext + 1) - + (void __user *)rxnfc) || + copy_in_user(&rxnfc->fs.ring_cookie, + &compat_rxnfc->fs.ring_cookie, + (void __user *)(&rxnfc->fs.location + 1) - + (void __user *)&rxnfc->fs.ring_cookie) || + copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt, + sizeof(rxnfc->rule_cnt))) + return -EFAULT; + } + + ret = dev_ioctl(net, SIOCETHTOOL, ifr); + if (ret) + return ret; + + if (convert_out) { + if (copy_in_user(compat_rxnfc, rxnfc, + (const void __user *)(&rxnfc->fs.m_ext + 1) - + (const void __user *)rxnfc) || + copy_in_user(&compat_rxnfc->fs.ring_cookie, + &rxnfc->fs.ring_cookie, + (const void __user *)(&rxnfc->fs.location + 1) - + (const void __user *)&rxnfc->fs.ring_cookie) || + copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt, + sizeof(rxnfc->rule_cnt))) + return -EFAULT; + + if (ethcmd == ETHTOOL_GRXCLSRLALL) { + /* As an optimisation, we only copy the actual + * number of rules that the underlying + * function returned. Since Mallory might + * change the rule count in user memory, we + * check that it is less than the rule count + * originally given (as the user buffer size), + * which has been range-checked. + */ + if (get_user(actual_rule_cnt, &rxnfc->rule_cnt)) + return -EFAULT; + if (actual_rule_cnt < rule_cnt) + rule_cnt = actual_rule_cnt; + if (copy_in_user(&compat_rxnfc->rule_locs[0], + &rxnfc->rule_locs[0], + rule_cnt * sizeof(u32))) + return -EFAULT; + } + } + + return 0; +} +","@@ -1840,8 +1840,10 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size, + msg.msg_iov = &iov; + iov.iov_len = size; + iov.iov_base = ubuf; +- msg.msg_name = (struct sockaddr *)&address; +- msg.msg_namelen = sizeof(address); ++ /* Save some cycles and don't copy the address if not needed */ ++ msg.msg_name = addr ? (struct sockaddr *)&address : NULL; ++ /* We assume all kernel code knows the size of sockaddr_storage */ ++ msg.msg_namelen = 0; + if (sock->file->f_flags & O_NONBLOCK) + flags |= MSG_DONTWAIT; + err = sock_recvmsg(sock, &msg, size, flags); +@@ -2221,16 +2223,14 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg, + goto out; + } + +- /* +- * Save the user-mode address (verify_iovec will change the +- * kernel msghdr to use the kernel address space) ++ /* Save the user-mode address (verify_iovec will change the ++ * kernel msghdr to use the kernel address space) + */ +- + uaddr = (__force void __user *)msg_sys->msg_name; + uaddr_len = COMPAT_NAMELEN(msg); +- if (MSG_CMSG_COMPAT & flags) { ++ if (MSG_CMSG_COMPAT & flags) + err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE); +- } else ++ else + err = verify_iovec(msg_sys, iov, &addr, VERIFY_WRITE); + if (err < 0) + goto out_freeiov; +@@ -2239,6 +2239,9 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg, + cmsg_ptr = (unsigned long)msg_sys->msg_control; + msg_sys->msg_flags = flags & (MSG_CMSG_CLOEXEC|MSG_CMSG_COMPAT); + ++ /* We assume all kernel code knows the size of sockaddr_storage */ ++ msg_sys->msg_namelen = 0; ++ + if (sock->file->f_flags & O_NONBLOCK) + flags |= MSG_DONTWAIT; + err = (nosec ? sock_recvmsg_nosec : sock_recvmsg)(sock, msg_sys,",1145,1381,2048 +8887,"MagickExport MagickBooleanType OrderedDitherImage(Image *image, + const char *threshold_map,ExceptionInfo *exception) +{ +#define DitherImageTag ""Dither/Image"" + + CacheView + *image_view; + + char + token[MagickPathExtent]; + + const char + *p; + + double + levels[CompositePixelChannel]; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + register ssize_t + i; + + ssize_t + y; + + ThresholdMap + *map; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + if (threshold_map == (const char *) NULL) + return(MagickTrue); + p=(char *) threshold_map; + while (((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) && + (*p != '\0')) + p++; + threshold_map=p; + while (((isspace((int) ((unsigned char) *p)) == 0) && (*p != ',')) && + (*p != '\0')) + { + if ((p-threshold_map) >= (MagickPathExtent-1)) + break; + token[p-threshold_map]=(*p); + p++; + } + token[p-threshold_map]='\0'; + map=GetThresholdMap(token,exception); + if (map == (ThresholdMap *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""InvalidArgument"",""%s : '%s'"",""ordered-dither"",threshold_map); + return(MagickFalse); + } + for (i=0; i < MaxPixelChannels; i++) + levels[i]=2.0; + p=strchr((char *) threshold_map,','); + if ((p != (char *) NULL) && (isdigit((int) ((unsigned char) *(++p))) != 0)) + { + GetNextToken(p,&p,MagickPathExtent,token); + for (i=0; (i < MaxPixelChannels); i++) + levels[i]=StringToDouble(token,(char **) NULL); + for (i=0; (*p != '\0') && (i < MaxPixelChannels); i++) + { + GetNextToken(p,&p,MagickPathExtent,token); + if (*token == ',') + GetNextToken(p,&p,MagickPathExtent,token); + levels[i]=StringToDouble(token,(char **) NULL); + } + } + for (i=0; i < MaxPixelChannels; i++) + if (fabs(levels[i]) >= 1) + levels[i]-=1.0; + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + status=MagickTrue; + progress=0; + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + register ssize_t + x; + + register Quantum + *magick_restrict q; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + register ssize_t + i; + + ssize_t + n; + + n=0; + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + ssize_t + level, + threshold; + + PixelChannel channel = GetPixelChannelChannel(image,i); + PixelTrait traits = GetPixelChannelTraits(image,channel); + if ((traits & UpdatePixelTrait) == 0) + continue; + if (fabs(levels[n]) < MagickEpsilon) + { + n++; + continue; + } + threshold=(ssize_t) (QuantumScale*q[i]*(levels[n]*(map->divisor-1)+1)); + level=threshold/(map->divisor-1); + threshold-=level*(map->divisor-1); + q[i]=ClampToQuantum((double) (level+(threshold >= + map->levels[(x % map->width)+map->width*(y % map->height)]))* + QuantumRange/levels[n]); + n++; + } + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,DitherImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + map=DestroyThresholdMap(map); + return(MagickTrue); +} +",0,"MagickExport MagickBooleanType OrderedDitherImage(Image *image, + const char *threshold_map,ExceptionInfo *exception) +{ +#define DitherImageTag ""Dither/Image"" + + CacheView + *image_view; + + char + token[MagickPathExtent]; + + const char + *p; + + double + levels[CompositePixelChannel]; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + register ssize_t + i; + + ssize_t + y; + + ThresholdMap + *map; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + if (threshold_map == (const char *) NULL) + return(MagickTrue); + p=(char *) threshold_map; + while (((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) && + (*p != '\0')) + p++; + threshold_map=p; + while (((isspace((int) ((unsigned char) *p)) == 0) && (*p != ',')) && + (*p != '\0')) + { + if ((p-threshold_map) >= (MagickPathExtent-1)) + break; + token[p-threshold_map]=(*p); + p++; + } + token[p-threshold_map]='\0'; + map=GetThresholdMap(token,exception); + if (map == (ThresholdMap *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""InvalidArgument"",""%s : '%s'"",""ordered-dither"",threshold_map); + return(MagickFalse); + } + for (i=0; i < MaxPixelChannels; i++) + levels[i]=2.0; + p=strchr((char *) threshold_map,','); + if ((p != (char *) NULL) && (isdigit((int) ((unsigned char) *(++p))) != 0)) + { + GetNextToken(p,&p,MagickPathExtent,token); + for (i=0; (i < MaxPixelChannels); i++) + levels[i]=StringToDouble(token,(char **) NULL); + for (i=0; (*p != '\0') && (i < MaxPixelChannels); i++) + { + GetNextToken(p,&p,MagickPathExtent,token); + if (*token == ',') + GetNextToken(p,&p,MagickPathExtent,token); + levels[i]=StringToDouble(token,(char **) NULL); + } + } + for (i=0; i < MaxPixelChannels; i++) + if (fabs(levels[i]) >= 1) + levels[i]-=1.0; + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + status=MagickTrue; + progress=0; + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + register ssize_t + x; + + register Quantum + *magick_restrict q; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + register ssize_t + i; + + ssize_t + n; + + n=0; + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + ssize_t + level, + threshold; + + PixelChannel channel = GetPixelChannelChannel(image,i); + PixelTrait traits = GetPixelChannelTraits(image,channel); + if ((traits & UpdatePixelTrait) == 0) + continue; + if (fabs(levels[n]) < MagickEpsilon) + { + n++; + continue; + } + threshold=(ssize_t) (QuantumScale*q[i]*(levels[n]*(map->divisor-1)+1)); + level=threshold/(map->divisor-1); + threshold-=level*(map->divisor-1); + q[i]=ClampToQuantum((double) (level+(threshold >= + map->levels[(x % map->width)+map->width*(y % map->height)]))* + QuantumRange/levels[n]); + n++; + } + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,DitherImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + map=DestroyThresholdMap(map); + return(MagickTrue); +} +","@@ -212,6 +212,8 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image, + threshold_image=CloneImage(image,0,0,MagickTrue,exception); + if (threshold_image == (Image *) NULL) + return((Image *) NULL); ++ if (width == 0) ++ return(threshold_image); + status=SetImageStorageClass(threshold_image,DirectClass,exception); + if (status == MagickFalse) + {",1195,1431,2048 +1326,"int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + ENGINE *impl, const unsigned char *key, + const unsigned char *iv, int enc) +{ + if (enc == -1) + enc = ctx->encrypt; + else { + if (enc) + enc = 1; + ctx->encrypt = enc; + } +#ifndef OPENSSL_NO_ENGINE + /* + * Whether it's nice or not, ""Inits"" can be used on ""Final""'d contexts so + * this context may already have an ENGINE! Try to avoid releasing the + * previous handle, re-querying for an ENGINE, and having a + * reinitialisation, when it may all be unnecessary. + */ + if (ctx->engine && ctx->cipher + && (!cipher || (cipher && (cipher->nid == ctx->cipher->nid)))) + goto skip_to_init; +#endif + if (cipher) { + /* + * Ensure a context left lying around from last time is cleared (the + * previous check attempted to avoid this if the same ENGINE and + * EVP_CIPHER could be used). + */ + if (ctx->cipher) { + unsigned long flags = ctx->flags; + EVP_CIPHER_CTX_reset(ctx); + /* Restore encrypt and flags */ + ctx->encrypt = enc; + ctx->flags = flags; + } +#ifndef OPENSSL_NO_ENGINE + if (impl) { + if (!ENGINE_init(impl)) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); + return 0; + } + } else + /* Ask if an ENGINE is reserved for this job */ + impl = ENGINE_get_cipher_engine(cipher->nid); + if (impl) { + /* There's an ENGINE for this job ... (apparently) */ + const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid); + if (!c) { + /* + * One positive side-effect of US's export control history, + * is that we should at least be able to avoid using US + * misspellings of ""initialisation""? + */ + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); + return 0; + } + /* We'll use the ENGINE's private cipher definition */ + cipher = c; + /* + * Store the ENGINE functional reference so we know 'cipher' came + * from an ENGINE and we need to release it when done. + */ + ctx->engine = impl; + } else + ctx->engine = NULL; +#endif + + ctx->cipher = cipher; + if (ctx->cipher->ctx_size) { + ctx->cipher_data = OPENSSL_zalloc(ctx->cipher->ctx_size); + if (ctx->cipher_data == NULL) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE); + return 0; + } + } else { + ctx->cipher_data = NULL; + } + ctx->key_len = cipher->key_len; + /* Preserve wrap enable flag, zero everything else */ + ctx->flags &= EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; + if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); + return 0; + } + } + } else if (!ctx->cipher) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET); + return 0; + } +#ifndef OPENSSL_NO_ENGINE + skip_to_init: +#endif + /* we assume block size is a power of 2 in *cryptUpdate */ + OPENSSL_assert(ctx->cipher->block_size == 1 + || ctx->cipher->block_size == 8 + || ctx->cipher->block_size == 16); + + if (!(ctx->flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW) + && EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_WRAP_MODE) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_WRAP_MODE_NOT_ALLOWED); + return 0; + } + + if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_CUSTOM_IV)) { + switch (EVP_CIPHER_CTX_mode(ctx)) { + + case EVP_CIPH_STREAM_CIPHER: + case EVP_CIPH_ECB_MODE: + break; + + case EVP_CIPH_CFB_MODE: + case EVP_CIPH_OFB_MODE: + + ctx->num = 0; + /* fall-through */ + + case EVP_CIPH_CBC_MODE: + + OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= + (int)sizeof(ctx->iv)); + if (iv) + memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); + memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); + break; + + case EVP_CIPH_CTR_MODE: + ctx->num = 0; + /* Don't reuse IV for CTR mode */ + if (iv) + memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); + break; + + default: + return 0; + } + } + + if (key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) { + if (!ctx->cipher->init(ctx, key, iv, enc)) + return 0; + } + ctx->buf_len = 0; + ctx->final_used = 0; + ctx->block_mask = ctx->cipher->block_size - 1; + return 1; +} +",0,"int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + ENGINE *impl, const unsigned char *key, + const unsigned char *iv, int enc) +{ + if (enc == -1) + enc = ctx->encrypt; + else { + if (enc) + enc = 1; + ctx->encrypt = enc; + } +#ifndef OPENSSL_NO_ENGINE + /* + * Whether it's nice or not, ""Inits"" can be used on ""Final""'d contexts so + * this context may already have an ENGINE! Try to avoid releasing the + * previous handle, re-querying for an ENGINE, and having a + * reinitialisation, when it may all be unnecessary. + */ + if (ctx->engine && ctx->cipher + && (!cipher || (cipher && (cipher->nid == ctx->cipher->nid)))) + goto skip_to_init; +#endif + if (cipher) { + /* + * Ensure a context left lying around from last time is cleared (the + * previous check attempted to avoid this if the same ENGINE and + * EVP_CIPHER could be used). + */ + if (ctx->cipher) { + unsigned long flags = ctx->flags; + EVP_CIPHER_CTX_reset(ctx); + /* Restore encrypt and flags */ + ctx->encrypt = enc; + ctx->flags = flags; + } +#ifndef OPENSSL_NO_ENGINE + if (impl) { + if (!ENGINE_init(impl)) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); + return 0; + } + } else + /* Ask if an ENGINE is reserved for this job */ + impl = ENGINE_get_cipher_engine(cipher->nid); + if (impl) { + /* There's an ENGINE for this job ... (apparently) */ + const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid); + if (!c) { + /* + * One positive side-effect of US's export control history, + * is that we should at least be able to avoid using US + * misspellings of ""initialisation""? + */ + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); + return 0; + } + /* We'll use the ENGINE's private cipher definition */ + cipher = c; + /* + * Store the ENGINE functional reference so we know 'cipher' came + * from an ENGINE and we need to release it when done. + */ + ctx->engine = impl; + } else + ctx->engine = NULL; +#endif + + ctx->cipher = cipher; + if (ctx->cipher->ctx_size) { + ctx->cipher_data = OPENSSL_zalloc(ctx->cipher->ctx_size); + if (ctx->cipher_data == NULL) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE); + return 0; + } + } else { + ctx->cipher_data = NULL; + } + ctx->key_len = cipher->key_len; + /* Preserve wrap enable flag, zero everything else */ + ctx->flags &= EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; + if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); + return 0; + } + } + } else if (!ctx->cipher) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET); + return 0; + } +#ifndef OPENSSL_NO_ENGINE + skip_to_init: +#endif + /* we assume block size is a power of 2 in *cryptUpdate */ + OPENSSL_assert(ctx->cipher->block_size == 1 + || ctx->cipher->block_size == 8 + || ctx->cipher->block_size == 16); + + if (!(ctx->flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW) + && EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_WRAP_MODE) { + EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_WRAP_MODE_NOT_ALLOWED); + return 0; + } + + if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_CUSTOM_IV)) { + switch (EVP_CIPHER_CTX_mode(ctx)) { + + case EVP_CIPH_STREAM_CIPHER: + case EVP_CIPH_ECB_MODE: + break; + + case EVP_CIPH_CFB_MODE: + case EVP_CIPH_OFB_MODE: + + ctx->num = 0; + /* fall-through */ + + case EVP_CIPH_CBC_MODE: + + OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= + (int)sizeof(ctx->iv)); + if (iv) + memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); + memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); + break; + + case EVP_CIPH_CTR_MODE: + ctx->num = 0; + /* Don't reuse IV for CTR mode */ + if (iv) + memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); + break; + + default: + return 0; + } + } + + if (key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) { + if (!ctx->cipher->init(ctx, key, iv, enc)) + return 0; + } + ctx->buf_len = 0; + ctx->final_used = 0; + ctx->block_mask = ctx->cipher->block_size - 1; + return 1; +} +","@@ -332,7 +332,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, + bl = ctx->cipher->block_size; + OPENSSL_assert(bl <= (int)sizeof(ctx->buf)); + if (i != 0) { +- if (i + inl < bl) { ++ if (bl - i > inl) { + memcpy(&(ctx->buf[i]), in, inl); + ctx->buf_len += inl; + *outl = 0;",1190,1426,2048 +1575,"static void vmxnet3_activate_device(VMXNET3State *s) +{ + int i; + static const uint32_t VMXNET3_DEF_TX_THRESHOLD = 1; + hwaddr qdescr_table_pa; + uint64_t pa; + uint32_t size; + + /* Verify configuration consistency */ + if (!vmxnet3_verify_driver_magic(s->drv_shmem)) { + VMW_ERPRN(""Device configuration received from driver is invalid""); + return; + } + + vmxnet3_adjust_by_guest_type(s); + vmxnet3_update_features(s); + vmxnet3_update_pm_state(s); + vmxnet3_setup_rx_filtering(s); + /* Cache fields from shared memory */ + s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu); + VMW_CFPRN(""MTU is %u"", s->mtu); + + s->max_rx_frags = + VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG); + + if (s->max_rx_frags == 0) { + s->max_rx_frags = 1; + } + + VMW_CFPRN(""Max RX fragments is %u"", s->max_rx_frags); + + s->event_int_idx = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx); + assert(vmxnet3_verify_intx(s, s->event_int_idx)); + VMW_CFPRN(""Events interrupt line is %u"", s->event_int_idx); + + s->auto_int_masking = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask); + VMW_CFPRN(""Automatic interrupt masking is %d"", (int)s->auto_int_masking); + + s->txq_num = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues); + s->rxq_num = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues); + + VMW_CFPRN(""Number of TX/RX queues %u/%u"", s->txq_num, s->rxq_num); + vmxnet3_validate_queues(s); + + qdescr_table_pa = + VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA); + VMW_CFPRN(""TX queues descriptors table is at 0x%"" PRIx64, qdescr_table_pa); + + /* + * Worst-case scenario is a packet that holds all TX rings space so + * we calculate total size of all TX rings for max TX fragments number + */ + s->max_tx_frags = 0; + + /* TX queues */ + for (i = 0; i < s->txq_num; i++) { + hwaddr qdescr_pa = + qdescr_table_pa + i * sizeof(struct Vmxnet3_TxQueueDesc); + + /* Read interrupt number for this TX queue */ + s->txq_descr[i].intr_idx = + VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx); + assert(vmxnet3_verify_intx(s, s->txq_descr[i].intr_idx)); + + VMW_CFPRN(""TX Queue %d interrupt: %d"", i, s->txq_descr[i].intr_idx); + + /* Read rings memory locations for TX queues */ + pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA); + size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize); + + vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size, + sizeof(struct Vmxnet3_TxDesc), false); + VMXNET3_RING_DUMP(VMW_CFPRN, ""TX"", i, &s->txq_descr[i].tx_ring); + + s->max_tx_frags += size; + + /* TXC ring */ + pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA); + size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize); + vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size, + sizeof(struct Vmxnet3_TxCompDesc), true); + VMXNET3_RING_DUMP(VMW_CFPRN, ""TXC"", i, &s->txq_descr[i].comp_ring); + + s->txq_descr[i].tx_stats_pa = + qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats); + + memset(&s->txq_descr[i].txq_stats, 0, + sizeof(s->txq_descr[i].txq_stats)); + + /* Fill device-managed parameters for queues */ + VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa, + ctrl.txThreshold, + VMXNET3_DEF_TX_THRESHOLD); + } + + /* Preallocate TX packet wrapper */ + VMW_CFPRN(""Max TX fragments is %u"", s->max_tx_frags); + vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr); + vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); + + /* Read rings memory locations for RX queues */ + for (i = 0; i < s->rxq_num; i++) { + int j; + hwaddr qd_pa = + qdescr_table_pa + s->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) + + i * sizeof(struct Vmxnet3_RxQueueDesc); + + /* Read interrupt number for this RX queue */ + s->rxq_descr[i].intr_idx = + VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx); + assert(vmxnet3_verify_intx(s, s->rxq_descr[i].intr_idx)); + + VMW_CFPRN(""RX Queue %d interrupt: %d"", i, s->rxq_descr[i].intr_idx); + + /* Read rings memory locations */ + for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) { + /* RX rings */ + pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]); + size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]); + vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size, + sizeof(struct Vmxnet3_RxDesc), false); + VMW_CFPRN(""RX queue %d:%d: Base: %"" PRIx64 "", Size: %d"", + i, j, pa, size); + } + + /* RXC ring */ + pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA); + size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize); + vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size, + sizeof(struct Vmxnet3_RxCompDesc), true); + VMW_CFPRN(""RXC queue %d: Base: %"" PRIx64 "", Size: %d"", i, pa, size); + + s->rxq_descr[i].rx_stats_pa = + qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats); + memset(&s->rxq_descr[i].rxq_stats, 0, + sizeof(s->rxq_descr[i].rxq_stats)); + } + + vmxnet3_validate_interrupts(s); + + /* Make sure everything is in place before device activation */ + smp_wmb(); + + vmxnet3_reset_mac(s); + + s->device_active = true; +} +",0,"static void vmxnet3_activate_device(VMXNET3State *s) +{ + int i; + static const uint32_t VMXNET3_DEF_TX_THRESHOLD = 1; + hwaddr qdescr_table_pa; + uint64_t pa; + uint32_t size; + + /* Verify configuration consistency */ + if (!vmxnet3_verify_driver_magic(s->drv_shmem)) { + VMW_ERPRN(""Device configuration received from driver is invalid""); + return; + } + + vmxnet3_adjust_by_guest_type(s); + vmxnet3_update_features(s); + vmxnet3_update_pm_state(s); + vmxnet3_setup_rx_filtering(s); + /* Cache fields from shared memory */ + s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu); + VMW_CFPRN(""MTU is %u"", s->mtu); + + s->max_rx_frags = + VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG); + + if (s->max_rx_frags == 0) { + s->max_rx_frags = 1; + } + + VMW_CFPRN(""Max RX fragments is %u"", s->max_rx_frags); + + s->event_int_idx = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx); + assert(vmxnet3_verify_intx(s, s->event_int_idx)); + VMW_CFPRN(""Events interrupt line is %u"", s->event_int_idx); + + s->auto_int_masking = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask); + VMW_CFPRN(""Automatic interrupt masking is %d"", (int)s->auto_int_masking); + + s->txq_num = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues); + s->rxq_num = + VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues); + + VMW_CFPRN(""Number of TX/RX queues %u/%u"", s->txq_num, s->rxq_num); + vmxnet3_validate_queues(s); + + qdescr_table_pa = + VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA); + VMW_CFPRN(""TX queues descriptors table is at 0x%"" PRIx64, qdescr_table_pa); + + /* + * Worst-case scenario is a packet that holds all TX rings space so + * we calculate total size of all TX rings for max TX fragments number + */ + s->max_tx_frags = 0; + + /* TX queues */ + for (i = 0; i < s->txq_num; i++) { + hwaddr qdescr_pa = + qdescr_table_pa + i * sizeof(struct Vmxnet3_TxQueueDesc); + + /* Read interrupt number for this TX queue */ + s->txq_descr[i].intr_idx = + VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx); + assert(vmxnet3_verify_intx(s, s->txq_descr[i].intr_idx)); + + VMW_CFPRN(""TX Queue %d interrupt: %d"", i, s->txq_descr[i].intr_idx); + + /* Read rings memory locations for TX queues */ + pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA); + size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize); + + vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size, + sizeof(struct Vmxnet3_TxDesc), false); + VMXNET3_RING_DUMP(VMW_CFPRN, ""TX"", i, &s->txq_descr[i].tx_ring); + + s->max_tx_frags += size; + + /* TXC ring */ + pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA); + size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize); + vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size, + sizeof(struct Vmxnet3_TxCompDesc), true); + VMXNET3_RING_DUMP(VMW_CFPRN, ""TXC"", i, &s->txq_descr[i].comp_ring); + + s->txq_descr[i].tx_stats_pa = + qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats); + + memset(&s->txq_descr[i].txq_stats, 0, + sizeof(s->txq_descr[i].txq_stats)); + + /* Fill device-managed parameters for queues */ + VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa, + ctrl.txThreshold, + VMXNET3_DEF_TX_THRESHOLD); + } + + /* Preallocate TX packet wrapper */ + VMW_CFPRN(""Max TX fragments is %u"", s->max_tx_frags); + vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr); + vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); + + /* Read rings memory locations for RX queues */ + for (i = 0; i < s->rxq_num; i++) { + int j; + hwaddr qd_pa = + qdescr_table_pa + s->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) + + i * sizeof(struct Vmxnet3_RxQueueDesc); + + /* Read interrupt number for this RX queue */ + s->rxq_descr[i].intr_idx = + VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx); + assert(vmxnet3_verify_intx(s, s->rxq_descr[i].intr_idx)); + + VMW_CFPRN(""RX Queue %d interrupt: %d"", i, s->rxq_descr[i].intr_idx); + + /* Read rings memory locations */ + for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) { + /* RX rings */ + pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]); + size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]); + vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size, + sizeof(struct Vmxnet3_RxDesc), false); + VMW_CFPRN(""RX queue %d:%d: Base: %"" PRIx64 "", Size: %d"", + i, j, pa, size); + } + + /* RXC ring */ + pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA); + size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize); + vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size, + sizeof(struct Vmxnet3_RxCompDesc), true); + VMW_CFPRN(""RXC queue %d: Base: %"" PRIx64 "", Size: %d"", i, pa, size); + + s->rxq_descr[i].rx_stats_pa = + qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats); + memset(&s->rxq_descr[i].rxq_stats, 0, + sizeof(s->rxq_descr[i].rxq_stats)); + } + + vmxnet3_validate_interrupts(s); + + /* Make sure everything is in place before device activation */ + smp_wmb(); + + vmxnet3_reset_mac(s); + + s->device_active = true; +} +","@@ -2391,6 +2391,8 @@ static int vmxnet3_post_load(void *opaque, int version_id) + } + } + ++ vmxnet3_validate_interrupts(s); ++ + return 0; + }",1729,1965,2048 +3474,"static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) +{ + struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); + enum ccid3_fback_type do_feedback = CCID3_FBACK_NONE; + const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp; + const bool is_data_packet = dccp_data_packet(skb); + + if (unlikely(hc->rx_state == TFRC_RSTATE_NO_DATA)) { + if (is_data_packet) { + const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; + do_feedback = CCID3_FBACK_INITIAL; + ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); + hc->rx_s = payload; + /* + * Not necessary to update rx_bytes_recv here, + * since X_recv = 0 for the first feedback packet (cf. + * RFC 3448, 6.3) -- gerrit + */ + } + goto update_records; + } + + if (tfrc_rx_hist_duplicate(&hc->rx_hist, skb)) + return; /* done receiving */ + + if (is_data_packet) { + const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; + /* + * Update moving-average of s and the sum of received payload bytes + */ + hc->rx_s = tfrc_ewma(hc->rx_s, payload, 9); + hc->rx_bytes_recv += payload; + } + + /* + * Perform loss detection and handle pending losses + */ + if (tfrc_rx_handle_loss(&hc->rx_hist, &hc->rx_li_hist, + skb, ndp, ccid3_first_li, sk)) { + do_feedback = CCID3_FBACK_PARAM_CHANGE; + goto done_receiving; + } + + if (tfrc_rx_hist_loss_pending(&hc->rx_hist)) + return; /* done receiving */ + + /* + * Handle data packets: RTT sampling and monitoring p + */ + if (unlikely(!is_data_packet)) + goto update_records; + + if (!tfrc_lh_is_initialised(&hc->rx_li_hist)) { + const u32 sample = tfrc_rx_hist_sample_rtt(&hc->rx_hist, skb); + /* + * Empty loss history: no loss so far, hence p stays 0. + * Sample RTT values, since an RTT estimate is required for the + * computation of p when the first loss occurs; RFC 3448, 6.3.1. + */ + if (sample != 0) + hc->rx_rtt = tfrc_ewma(hc->rx_rtt, sample, 9); + + } else if (tfrc_lh_update_i_mean(&hc->rx_li_hist, skb)) { + /* + * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean + * has decreased (resp. p has increased), send feedback now. + */ + do_feedback = CCID3_FBACK_PARAM_CHANGE; + } + + /* + * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3 + */ + if (SUB16(dccp_hdr(skb)->dccph_ccval, hc->rx_last_counter) > 3) + do_feedback = CCID3_FBACK_PERIODIC; + +update_records: + tfrc_rx_hist_add_packet(&hc->rx_hist, skb, ndp); + +done_receiving: + if (do_feedback) + ccid3_hc_rx_send_feedback(sk, skb, do_feedback); +} +",0,"static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) +{ + struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); + enum ccid3_fback_type do_feedback = CCID3_FBACK_NONE; + const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp; + const bool is_data_packet = dccp_data_packet(skb); + + if (unlikely(hc->rx_state == TFRC_RSTATE_NO_DATA)) { + if (is_data_packet) { + const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; + do_feedback = CCID3_FBACK_INITIAL; + ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); + hc->rx_s = payload; + /* + * Not necessary to update rx_bytes_recv here, + * since X_recv = 0 for the first feedback packet (cf. + * RFC 3448, 6.3) -- gerrit + */ + } + goto update_records; + } + + if (tfrc_rx_hist_duplicate(&hc->rx_hist, skb)) + return; /* done receiving */ + + if (is_data_packet) { + const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; + /* + * Update moving-average of s and the sum of received payload bytes + */ + hc->rx_s = tfrc_ewma(hc->rx_s, payload, 9); + hc->rx_bytes_recv += payload; + } + + /* + * Perform loss detection and handle pending losses + */ + if (tfrc_rx_handle_loss(&hc->rx_hist, &hc->rx_li_hist, + skb, ndp, ccid3_first_li, sk)) { + do_feedback = CCID3_FBACK_PARAM_CHANGE; + goto done_receiving; + } + + if (tfrc_rx_hist_loss_pending(&hc->rx_hist)) + return; /* done receiving */ + + /* + * Handle data packets: RTT sampling and monitoring p + */ + if (unlikely(!is_data_packet)) + goto update_records; + + if (!tfrc_lh_is_initialised(&hc->rx_li_hist)) { + const u32 sample = tfrc_rx_hist_sample_rtt(&hc->rx_hist, skb); + /* + * Empty loss history: no loss so far, hence p stays 0. + * Sample RTT values, since an RTT estimate is required for the + * computation of p when the first loss occurs; RFC 3448, 6.3.1. + */ + if (sample != 0) + hc->rx_rtt = tfrc_ewma(hc->rx_rtt, sample, 9); + + } else if (tfrc_lh_update_i_mean(&hc->rx_li_hist, skb)) { + /* + * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean + * has decreased (resp. p has increased), send feedback now. + */ + do_feedback = CCID3_FBACK_PARAM_CHANGE; + } + + /* + * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3 + */ + if (SUB16(dccp_hdr(skb)->dccph_ccval, hc->rx_last_counter) > 3) + do_feedback = CCID3_FBACK_PERIODIC; + +update_records: + tfrc_rx_hist_add_packet(&hc->rx_hist, skb, ndp); + +done_receiving: + if (do_feedback) + ccid3_hc_rx_send_feedback(sk, skb, do_feedback); +} +","@@ -535,6 +535,7 @@ static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len, + case DCCP_SOCKOPT_CCID_TX_INFO: + if (len < sizeof(tfrc)) + return -EINVAL; ++ memset(&tfrc, 0, sizeof(tfrc)); + tfrc.tfrctx_x = hc->tx_x; + tfrc.tfrctx_x_recv = hc->tx_x_recv; + tfrc.tfrctx_x_calc = hc->tx_x_calc;",809,1045,2048 +1877,"static void usage(void) { + printf(PACKAGE "" "" VERSION ""\n""); + printf(""-p TCP port number to listen on (default: 11211)\n"" + ""-U UDP port number to listen on (default: 11211, 0 is off)\n"" + ""-s UNIX socket path to listen on (disables network support)\n"" + ""-a access mask for UNIX socket, in octal (default: 0700)\n"" + ""-l interface to listen on (default: INADDR_ANY, all addresses)\n"" + ""-d run as a daemon\n"" + ""-r maximize core file limit\n"" + ""-u assume identity of (only when run as root)\n"" + ""-m max memory to use for items in megabytes (default: 64 MB)\n"" + ""-M return error on memory exhausted (rather than removing items)\n"" + ""-c max simultaneous connections (default: 1024)\n"" + ""-k lock down all paged memory. Note that there is a\n"" + "" limit on how much memory you may lock. Trying to\n"" + "" allocate more than that would fail, so be sure you\n"" + "" set the limit correctly for the user you started\n"" + "" the daemon with (not for -u user;\n"" + "" under sh this is done with 'ulimit -S -l NUM_KB').\n"" + ""-v verbose (print errors/warnings while in event loop)\n"" + ""-vv very verbose (also print client commands/reponses)\n"" + ""-vvv extremely verbose (also print internal state transitions)\n"" + ""-h print this help and exit\n"" + ""-i print memcached and libevent license\n"" + ""-P save PID in , only used with -d option\n"" + ""-f chunk size growth factor (default: 1.25)\n"" + ""-n minimum space allocated for key+value+flags (default: 48)\n""); + printf(""-L Try to use large memory pages (if available). Increasing\n"" + "" the memory page size could reduce the number of TLB misses\n"" + "" and improve the performance. In order to get large pages\n"" + "" from the OS, memcached will allocate the total item-cache\n"" + "" in one large chunk.\n""); + printf(""-D Use as the delimiter between key prefixes and IDs.\n"" + "" This is used for per-prefix stats reporting. The default is\n"" + "" \"":\"" (colon). If this option is specified, stats collection\n"" + "" is turned on automatically; if not, then it may be turned on\n"" + "" by sending the \""stats detail on\"" command to the server.\n""); + printf(""-t number of threads to use (default: 4)\n""); + printf(""-R Maximum number of requests per event, limits the number of\n"" + "" requests process for a given connection to prevent \n"" + "" starvation (default: 20)\n""); + printf(""-C Disable use of CAS\n""); + printf(""-b Set the backlog queue limit (default: 1024)\n""); + printf(""-B Binding protocol - one of ascii, binary, or auto (default)\n""); + printf(""-I Override the size of each slab page. Adjusts max item size\n"" + "" (default: 1mb, min: 1k, max: 128m)\n""); +#ifdef ENABLE_SASL + printf(""-S Turn on Sasl authentication\n""); +#endif + return; +} +",0,"static void usage(void) { + printf(PACKAGE "" "" VERSION ""\n""); + printf(""-p TCP port number to listen on (default: 11211)\n"" + ""-U UDP port number to listen on (default: 11211, 0 is off)\n"" + ""-s UNIX socket path to listen on (disables network support)\n"" + ""-a access mask for UNIX socket, in octal (default: 0700)\n"" + ""-l interface to listen on (default: INADDR_ANY, all addresses)\n"" + ""-d run as a daemon\n"" + ""-r maximize core file limit\n"" + ""-u assume identity of (only when run as root)\n"" + ""-m max memory to use for items in megabytes (default: 64 MB)\n"" + ""-M return error on memory exhausted (rather than removing items)\n"" + ""-c max simultaneous connections (default: 1024)\n"" + ""-k lock down all paged memory. Note that there is a\n"" + "" limit on how much memory you may lock. Trying to\n"" + "" allocate more than that would fail, so be sure you\n"" + "" set the limit correctly for the user you started\n"" + "" the daemon with (not for -u user;\n"" + "" under sh this is done with 'ulimit -S -l NUM_KB').\n"" + ""-v verbose (print errors/warnings while in event loop)\n"" + ""-vv very verbose (also print client commands/reponses)\n"" + ""-vvv extremely verbose (also print internal state transitions)\n"" + ""-h print this help and exit\n"" + ""-i print memcached and libevent license\n"" + ""-P save PID in , only used with -d option\n"" + ""-f chunk size growth factor (default: 1.25)\n"" + ""-n minimum space allocated for key+value+flags (default: 48)\n""); + printf(""-L Try to use large memory pages (if available). Increasing\n"" + "" the memory page size could reduce the number of TLB misses\n"" + "" and improve the performance. In order to get large pages\n"" + "" from the OS, memcached will allocate the total item-cache\n"" + "" in one large chunk.\n""); + printf(""-D Use as the delimiter between key prefixes and IDs.\n"" + "" This is used for per-prefix stats reporting. The default is\n"" + "" \"":\"" (colon). If this option is specified, stats collection\n"" + "" is turned on automatically; if not, then it may be turned on\n"" + "" by sending the \""stats detail on\"" command to the server.\n""); + printf(""-t number of threads to use (default: 4)\n""); + printf(""-R Maximum number of requests per event, limits the number of\n"" + "" requests process for a given connection to prevent \n"" + "" starvation (default: 20)\n""); + printf(""-C Disable use of CAS\n""); + printf(""-b Set the backlog queue limit (default: 1024)\n""); + printf(""-B Binding protocol - one of ascii, binary, or auto (default)\n""); + printf(""-I Override the size of each slab page. Adjusts max item size\n"" + "" (default: 1mb, min: 1k, max: 128m)\n""); +#ifdef ENABLE_SASL + printf(""-S Turn on Sasl authentication\n""); +#endif + return; +} +","@@ -3148,7 +3148,9 @@ static int try_read_command(conn *c) { + ++ptr; + } + +- if (strcmp(ptr, ""get "") && strcmp(ptr, ""gets "")) { ++ if (ptr - c->rcurr > 100 || ++ (strncmp(ptr, ""get "", 4) && strncmp(ptr, ""gets "", 5))) { ++ + conn_set_state(c, conn_closing); + return 1; + }",861,1097,2048 +13578,"void BlockPainter::PaintObject(const PaintInfo& paint_info, + const LayoutPoint& paint_offset) { + if (layout_block_.IsTruncated()) + return; + + const PaintPhase paint_phase = paint_info.phase; + + if (ShouldPaintSelfBlockBackground(paint_phase)) { + if (layout_block_.Style()->Visibility() == EVisibility::kVisible && + layout_block_.HasBoxDecorationBackground()) + layout_block_.PaintBoxDecorationBackground(paint_info, paint_offset); + if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) + PaintScrollHitTestDisplayItem(paint_info); + if (paint_phase == PaintPhase::kSelfBlockBackgroundOnly) + return; + } + + if (paint_phase == PaintPhase::kMask && + layout_block_.Style()->Visibility() == EVisibility::kVisible) { + layout_block_.PaintMask(paint_info, paint_offset); + return; + } + + if (paint_phase == PaintPhase::kClippingMask && + layout_block_.Style()->Visibility() == EVisibility::kVisible) { + DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV175Enabled()); + BoxPainter(layout_block_).PaintClippingMask(paint_info, paint_offset); + return; + } + + if (paint_phase == PaintPhase::kForeground && paint_info.IsPrinting()) + ObjectPainter(layout_block_) + .AddPDFURLRectIfNeeded(paint_info, paint_offset); + + if (paint_phase != PaintPhase::kSelfOutlineOnly) { + base::Optional scoped_scroll_property; + base::Optional scroll_recorder; + base::Optional scrolled_paint_info; + if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) { + if (const auto* fragment = paint_info.FragmentToPaint(layout_block_)) { + const auto* object_properties = fragment->PaintProperties(); + auto* scroll_translation = object_properties + ? object_properties->ScrollTranslation() + : nullptr; + if (scroll_translation) { + scoped_scroll_property.emplace( + paint_info.context.GetPaintController(), scroll_translation, + layout_block_, DisplayItem::PaintPhaseToScrollType(paint_phase)); + scrolled_paint_info.emplace(paint_info); + if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { + scrolled_paint_info->UpdateCullRectForScrollingContents( + EnclosingIntRect(layout_block_.OverflowClipRect(paint_offset)), + scroll_translation->Matrix().ToAffineTransform()); + } else { + scrolled_paint_info->UpdateCullRect( + scroll_translation->Matrix().ToAffineTransform()); + } + } + } + } else if (layout_block_.HasOverflowClip()) { + IntSize scroll_offset = layout_block_.ScrolledContentOffset(); + if (layout_block_.Layer()->ScrollsOverflow() || !scroll_offset.IsZero()) { + scroll_recorder.emplace(paint_info.context, layout_block_, paint_phase, + scroll_offset); + scrolled_paint_info.emplace(paint_info); + AffineTransform transform; + transform.Translate(-scroll_offset.Width(), -scroll_offset.Height()); + scrolled_paint_info->UpdateCullRect(transform); + } + } + + const PaintInfo& contents_paint_info = + scrolled_paint_info ? *scrolled_paint_info : paint_info; + + if (layout_block_.IsLayoutBlockFlow()) { + BlockFlowPainter block_flow_painter(ToLayoutBlockFlow(layout_block_)); + block_flow_painter.PaintContents(contents_paint_info, paint_offset); + if (paint_phase == PaintPhase::kFloat || + paint_phase == PaintPhase::kSelection || + paint_phase == PaintPhase::kTextClip) + block_flow_painter.PaintFloats(contents_paint_info, paint_offset); + } else { + PaintContents(contents_paint_info, paint_offset); + } + } + + if (ShouldPaintSelfOutline(paint_phase)) + ObjectPainter(layout_block_).PaintOutline(paint_info, paint_offset); + + if (paint_phase == PaintPhase::kForeground && + layout_block_.ShouldPaintCarets()) + PaintCarets(paint_info, paint_offset); +} +",0,"void BlockPainter::PaintObject(const PaintInfo& paint_info, + const LayoutPoint& paint_offset) { + if (layout_block_.IsTruncated()) + return; + + const PaintPhase paint_phase = paint_info.phase; + + if (ShouldPaintSelfBlockBackground(paint_phase)) { + if (layout_block_.Style()->Visibility() == EVisibility::kVisible && + layout_block_.HasBoxDecorationBackground()) + layout_block_.PaintBoxDecorationBackground(paint_info, paint_offset); + if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) + PaintScrollHitTestDisplayItem(paint_info); + if (paint_phase == PaintPhase::kSelfBlockBackgroundOnly) + return; + } + + if (paint_phase == PaintPhase::kMask && + layout_block_.Style()->Visibility() == EVisibility::kVisible) { + layout_block_.PaintMask(paint_info, paint_offset); + return; + } + + if (paint_phase == PaintPhase::kClippingMask && + layout_block_.Style()->Visibility() == EVisibility::kVisible) { + DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV175Enabled()); + BoxPainter(layout_block_).PaintClippingMask(paint_info, paint_offset); + return; + } + + if (paint_phase == PaintPhase::kForeground && paint_info.IsPrinting()) + ObjectPainter(layout_block_) + .AddPDFURLRectIfNeeded(paint_info, paint_offset); + + if (paint_phase != PaintPhase::kSelfOutlineOnly) { + base::Optional scoped_scroll_property; + base::Optional scroll_recorder; + base::Optional scrolled_paint_info; + if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) { + if (const auto* fragment = paint_info.FragmentToPaint(layout_block_)) { + const auto* object_properties = fragment->PaintProperties(); + auto* scroll_translation = object_properties + ? object_properties->ScrollTranslation() + : nullptr; + if (scroll_translation) { + scoped_scroll_property.emplace( + paint_info.context.GetPaintController(), scroll_translation, + layout_block_, DisplayItem::PaintPhaseToScrollType(paint_phase)); + scrolled_paint_info.emplace(paint_info); + if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { + scrolled_paint_info->UpdateCullRectForScrollingContents( + EnclosingIntRect(layout_block_.OverflowClipRect(paint_offset)), + scroll_translation->Matrix().ToAffineTransform()); + } else { + scrolled_paint_info->UpdateCullRect( + scroll_translation->Matrix().ToAffineTransform()); + } + } + } + } else if (layout_block_.HasOverflowClip()) { + IntSize scroll_offset = layout_block_.ScrolledContentOffset(); + if (layout_block_.Layer()->ScrollsOverflow() || !scroll_offset.IsZero()) { + scroll_recorder.emplace(paint_info.context, layout_block_, paint_phase, + scroll_offset); + scrolled_paint_info.emplace(paint_info); + AffineTransform transform; + transform.Translate(-scroll_offset.Width(), -scroll_offset.Height()); + scrolled_paint_info->UpdateCullRect(transform); + } + } + + const PaintInfo& contents_paint_info = + scrolled_paint_info ? *scrolled_paint_info : paint_info; + + if (layout_block_.IsLayoutBlockFlow()) { + BlockFlowPainter block_flow_painter(ToLayoutBlockFlow(layout_block_)); + block_flow_painter.PaintContents(contents_paint_info, paint_offset); + if (paint_phase == PaintPhase::kFloat || + paint_phase == PaintPhase::kSelection || + paint_phase == PaintPhase::kTextClip) + block_flow_painter.PaintFloats(contents_paint_info, paint_offset); + } else { + PaintContents(contents_paint_info, paint_offset); + } + } + + if (ShouldPaintSelfOutline(paint_phase)) + ObjectPainter(layout_block_).PaintOutline(paint_info, paint_offset); + + if (paint_phase == PaintPhase::kForeground && + layout_block_.ShouldPaintCarets()) + PaintCarets(paint_info, paint_offset); +} +","@@ -196,7 +196,7 @@ void BlockPainter::PaintScrollHitTestDisplayItem(const PaintInfo& paint_info) { + DisplayItem::kScrollHitTest); + ScrollHitTestDisplayItem::Record(paint_info.context, layout_block_, + DisplayItem::kScrollHitTest, +- properties->ScrollTranslation()); ++ *properties->ScrollTranslation()); + } + } + ",849,1085,2048 +17813," t42_parse_charstrings( T42_Face face, + T42_Loader loader ) + { + T42_Parser parser = &loader->parser; + PS_Table code_table = &loader->charstrings; + PS_Table name_table = &loader->glyph_names; + PS_Table swap_table = &loader->swap_table; + FT_Memory memory = parser->root.memory; + FT_Error error; + + PSAux_Service psaux = (PSAux_Service)face->psaux; + + FT_Byte* cur; + FT_Byte* limit = parser->root.limit; + FT_UInt n; + FT_UInt notdef_index = 0; + FT_Byte notdef_found = 0; + + + T1_Skip_Spaces( parser ); + + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + if ( ft_isdigit( *parser->root.cursor ) ) + { + loader->num_glyphs = (FT_UInt)T1_ToInt( parser ); + if ( parser->root.error ) + return; + } + else if ( *parser->root.cursor == '<' ) + { + /* We have `<< ... >>'. Count the number of `/' in the dictionary */ + /* to get its size. */ + FT_UInt count = 0; + + + T1_Skip_PS_Token( parser ); + if ( parser->root.error ) + return; + T1_Skip_Spaces( parser ); + cur = parser->root.cursor; + + while ( parser->root.cursor < limit ) + { + if ( *parser->root.cursor == '/' ) + count++; + else if ( *parser->root.cursor == '>' ) + { + loader->num_glyphs = count; + parser->root.cursor = cur; /* rewind */ + break; + } + T1_Skip_PS_Token( parser ); + if ( parser->root.error ) + return; + T1_Skip_Spaces( parser ); + } + } + else + { + FT_ERROR(( ""t42_parse_charstrings: invalid token\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + /* initialize tables */ + + error = psaux->ps_table_funcs->init( code_table, + loader->num_glyphs, + memory ); + if ( error ) + goto Fail; + + error = psaux->ps_table_funcs->init( name_table, + loader->num_glyphs, + memory ); + if ( error ) + goto Fail; + + /* Initialize table for swapping index notdef_index and */ + /* index 0 names and codes (if necessary). */ + + error = psaux->ps_table_funcs->init( swap_table, 4, memory ); + if ( error ) + goto Fail; + + n = 0; + + for (;;) + { + /* The format is simple: */ + /* `/glyphname' + index [+ def] */ + + T1_Skip_Spaces( parser ); + + cur = parser->root.cursor; + if ( cur >= limit ) + break; + + /* We stop when we find an `end' keyword or '>' */ + if ( *cur == 'e' && + cur + 3 < limit && + cur[1] == 'n' && + cur[2] == 'd' && + t42_is_space( cur[3] ) ) + break; + if ( *cur == '>' ) + break; + + T1_Skip_PS_Token( parser ); + if ( parser->root.error ) + return; + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + cur++; /* skip `/' */ + len = parser->root.cursor - cur; + + error = T1_Add_Table( name_table, n, cur, len + 1 ); + if ( error ) + goto Fail; + + /* add a trailing zero to the name table */ + name_table->elements[n][len] = '\0'; + + /* record index of /.notdef */ + if ( *cur == '.' && + ft_strcmp( "".notdef"", + (const char*)(name_table->elements[n]) ) == 0 ) + { + notdef_index = n; + notdef_found = 1; + } + + T1_Skip_Spaces( parser ); + + cur = parser->root.cursor; + + (void)T1_ToInt( parser ); + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + len = parser->root.cursor - cur; + + error = T1_Add_Table( code_table, n, cur, len + 1 ); + if ( error ) + goto Fail; + + code_table->elements[n][len] = '\0'; + + n++; + if ( n >= loader->num_glyphs ) + break; + } + } +",1," t42_parse_charstrings( T42_Face face, + T42_Loader loader ) + { + T42_Parser parser = &loader->parser; + PS_Table code_table = &loader->charstrings; + PS_Table name_table = &loader->glyph_names; + PS_Table swap_table = &loader->swap_table; + FT_Memory memory = parser->root.memory; + FT_Error error; + + PSAux_Service psaux = (PSAux_Service)face->psaux; + + FT_Byte* cur; + FT_Byte* limit = parser->root.limit; + FT_UInt n; + FT_UInt notdef_index = 0; + FT_Byte notdef_found = 0; + + + T1_Skip_Spaces( parser ); + + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + if ( ft_isdigit( *parser->root.cursor ) ) + { + loader->num_glyphs = (FT_UInt)T1_ToInt( parser ); + if ( parser->root.error ) + return; + } + else if ( *parser->root.cursor == '<' ) + { + /* We have `<< ... >>'. Count the number of `/' in the dictionary */ + /* to get its size. */ + FT_UInt count = 0; + + + T1_Skip_PS_Token( parser ); + if ( parser->root.error ) + return; + T1_Skip_Spaces( parser ); + cur = parser->root.cursor; + + while ( parser->root.cursor < limit ) + { + if ( *parser->root.cursor == '/' ) + count++; + else if ( *parser->root.cursor == '>' ) + { + loader->num_glyphs = count; + parser->root.cursor = cur; /* rewind */ + break; + } + T1_Skip_PS_Token( parser ); + if ( parser->root.error ) + return; + T1_Skip_Spaces( parser ); + } + } + else + { + FT_ERROR(( ""t42_parse_charstrings: invalid token\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + /* initialize tables */ + + error = psaux->ps_table_funcs->init( code_table, + loader->num_glyphs, + memory ); + if ( error ) + goto Fail; + + error = psaux->ps_table_funcs->init( name_table, + loader->num_glyphs, + memory ); + if ( error ) + goto Fail; + + /* Initialize table for swapping index notdef_index and */ + /* index 0 names and codes (if necessary). */ + + error = psaux->ps_table_funcs->init( swap_table, 4, memory ); + if ( error ) + goto Fail; + + n = 0; + + for (;;) + { + /* The format is simple: */ + /* `/glyphname' + index [+ def] */ + + T1_Skip_Spaces( parser ); + + cur = parser->root.cursor; + if ( cur >= limit ) + break; + + /* We stop when we find an `end' keyword or '>' */ + if ( *cur == 'e' && + cur + 3 < limit && + cur[1] == 'n' && + cur[2] == 'd' && + t42_is_space( cur[3] ) ) + break; + if ( *cur == '>' ) + break; + + T1_Skip_PS_Token( parser ); + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + if ( parser->root.error ) + return; + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + cur++; /* skip `/' */ + len = parser->root.cursor - cur; + + error = T1_Add_Table( name_table, n, cur, len + 1 ); + if ( error ) + goto Fail; + + /* add a trailing zero to the name table */ + name_table->elements[n][len] = '\0'; + + /* record index of /.notdef */ + if ( *cur == '.' && + ft_strcmp( "".notdef"", + (const char*)(name_table->elements[n]) ) == 0 ) + { + notdef_index = n; + notdef_found = 1; + } + + T1_Skip_Spaces( parser ); + + cur = parser->root.cursor; + + (void)T1_ToInt( parser ); + if ( parser->root.cursor >= limit ) + { + FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + + len = parser->root.cursor - cur; + + error = T1_Add_Table( code_table, n, cur, len + 1 ); + if ( error ) + goto Fail; + + code_table->elements[n][len] = '\0'; + + n++; + if ( n >= loader->num_glyphs ) + break; + } + } +","@@ -849,6 +849,12 @@ + break; + + T1_Skip_PS_Token( parser ); ++ if ( parser->root.cursor >= limit ) ++ { ++ FT_ERROR(( ""t42_parse_charstrings: out of bounds\n"" )); ++ error = FT_THROW( Invalid_File_Format ); ++ goto Fail; ++ } + if ( parser->root.error ) + return;",1176,1412,2048 +18053,"SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) +{ + sapi_header_struct sapi_header; + char *colon_offset; + char *header_line; + uint header_line_len; + int http_response_code; + + if (SG(headers_sent) && !SG(request_info).no_headers) { + const char *output_start_filename = php_output_get_start_filename(TSRMLS_C); + int output_start_lineno = php_output_get_start_lineno(TSRMLS_C); + + if (output_start_filename) { + sapi_module.sapi_error(E_WARNING, ""Cannot modify header information - headers already sent by (output started at %s:%d)"", + output_start_filename, output_start_lineno); + } else { + sapi_module.sapi_error(E_WARNING, ""Cannot modify header information - headers already sent""); + } + return FAILURE; + } + + switch (op) { + case SAPI_HEADER_SET_STATUS: + sapi_update_response_code((int)(zend_intptr_t) arg TSRMLS_CC); + return SUCCESS; + + case SAPI_HEADER_ADD: + case SAPI_HEADER_REPLACE: + case SAPI_HEADER_DELETE: { + sapi_header_line *p = arg; + + if (!p->line || !p->line_len) { + return FAILURE; + } + header_line = p->line; + header_line_len = p->line_len; + http_response_code = p->response_code; + break; + } + + case SAPI_HEADER_DELETE_ALL: + if (sapi_module.header_handler) { + sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC); + } + zend_llist_clean(&SG(sapi_headers).headers); + return SUCCESS; + + default: + return FAILURE; + } + + header_line = estrndup(header_line, header_line_len); + + /* cut off trailing spaces, linefeeds and carriage-returns */ + if (header_line_len && isspace(header_line[header_line_len-1])) { + do { + header_line_len--; + } while(header_line_len && isspace(header_line[header_line_len-1])); + header_line[header_line_len]='\0'; + } + + if (op == SAPI_HEADER_DELETE) { + if (strchr(header_line, ':')) { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header to delete may not contain colon.""); + return FAILURE; + } + if (sapi_module.header_handler) { + sapi_header.header = header_line; + sapi_header.header_len = header_line_len; + sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC); + } + sapi_remove_header(&SG(sapi_headers).headers, header_line, header_line_len); + efree(header_line); + return SUCCESS; + } else { + /* new line/NUL character safety check */ + int i; + for (i = 0; i < header_line_len; i++) { + /* RFC 2616 allows new lines if followed by SP or HT */ + int illegal_break = + (header_line[i+1] != ' ' && header_line[i+1] != '\t') + && ( + header_line[i] == '\n' + || (header_line[i] == '\r' && header_line[i+1] != '\n')); + if (illegal_break) { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header may not contain "" + ""more than a single header, new line detected""); + return FAILURE; + } + if (header_line[i] == '\0') { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header may not contain NUL bytes""); + return FAILURE; + } + } + } + + sapi_header.header = header_line; + sapi_header.header_len = header_line_len; + + /* Check the header for a few cases that we have special support for in SAPI */ + if (header_line_len>=5 + && !strncasecmp(header_line, ""HTTP/"", 5)) { + /* filter out the response code */ + sapi_update_response_code(sapi_extract_response_code(header_line) TSRMLS_CC); + /* sapi_update_response_code doesn't free the status line if the code didn't change */ + if (SG(sapi_headers).http_status_line) { + efree(SG(sapi_headers).http_status_line); + } + SG(sapi_headers).http_status_line = header_line; + return SUCCESS; + } else { + colon_offset = strchr(header_line, ':'); + if (colon_offset) { + *colon_offset = 0; + if (!STRCASECMP(header_line, ""Content-Type"")) { + char *ptr = colon_offset+1, *mimetype = NULL, *newheader; + size_t len = header_line_len - (ptr - header_line), newlen; + while (*ptr == ' ') { + ptr++; + len--; + } + + /* Disable possible output compression for images */ + if (!strncmp(ptr, ""image/"", sizeof(""image/"")-1)) { + zend_alter_ini_entry(""zlib.output_compression"", sizeof(""zlib.output_compression""), ""0"", sizeof(""0"") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + } + + mimetype = estrdup(ptr); + newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC); + if (!SG(sapi_headers).mimetype){ + SG(sapi_headers).mimetype = estrdup(mimetype); + } + + if (newlen != 0) { + newlen += sizeof(""Content-type: ""); + newheader = emalloc(newlen); + PHP_STRLCPY(newheader, ""Content-type: "", newlen, sizeof(""Content-type: "")-1); + strlcat(newheader, mimetype, newlen); + sapi_header.header = newheader; + sapi_header.header_len = newlen - 1; + efree(header_line); + } + efree(mimetype); + SG(sapi_headers).send_default_content_type = 0; + } else if (!STRCASECMP(header_line, ""Content-Length"")) { + /* Script is setting Content-length. The script cannot reasonably + * know the size of the message body after compression, so it's best + * do disable compression altogether. This contributes to making scripts + * portable between setups that have and don't have zlib compression + * enabled globally. See req #44164 */ + zend_alter_ini_entry(""zlib.output_compression"", sizeof(""zlib.output_compression""), + ""0"", sizeof(""0"") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + } else if (!STRCASECMP(header_line, ""Location"")) { + if ((SG(sapi_headers).http_response_code < 300 || + SG(sapi_headers).http_response_code > 399) && + SG(sapi_headers).http_response_code != 201) { + /* Return a Found Redirect if one is not already specified */ + if (http_response_code) { /* user specified redirect code */ + sapi_update_response_code(http_response_code TSRMLS_CC); + } else if (SG(request_info).proto_num > 1000 && + SG(request_info).request_method && + strcmp(SG(request_info).request_method, ""HEAD"") && + strcmp(SG(request_info).request_method, ""GET"")) { + sapi_update_response_code(303 TSRMLS_CC); + } else { + sapi_update_response_code(302 TSRMLS_CC); + } + } + } else if (!STRCASECMP(header_line, ""WWW-Authenticate"")) { /* HTTP Authentication */ + sapi_update_response_code(401 TSRMLS_CC); /* authentication-required */ + } + if (sapi_header.header==header_line) { + *colon_offset = ':'; + } + } + } + if (http_response_code) { + sapi_update_response_code(http_response_code TSRMLS_CC); + } + sapi_header_add_op(op, &sapi_header TSRMLS_CC); + return SUCCESS; +} +",1,"SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) +{ + sapi_header_struct sapi_header; + char *colon_offset; + char *header_line; + uint header_line_len; + int http_response_code; + + if (SG(headers_sent) && !SG(request_info).no_headers) { + const char *output_start_filename = php_output_get_start_filename(TSRMLS_C); + int output_start_lineno = php_output_get_start_lineno(TSRMLS_C); + + if (output_start_filename) { + sapi_module.sapi_error(E_WARNING, ""Cannot modify header information - headers already sent by (output started at %s:%d)"", + output_start_filename, output_start_lineno); + } else { + sapi_module.sapi_error(E_WARNING, ""Cannot modify header information - headers already sent""); + } + return FAILURE; + } + + switch (op) { + case SAPI_HEADER_SET_STATUS: + sapi_update_response_code((int)(zend_intptr_t) arg TSRMLS_CC); + return SUCCESS; + + case SAPI_HEADER_ADD: + case SAPI_HEADER_REPLACE: + case SAPI_HEADER_DELETE: { + sapi_header_line *p = arg; + + if (!p->line || !p->line_len) { + return FAILURE; + } + header_line = p->line; + header_line_len = p->line_len; + http_response_code = p->response_code; + break; + } + + case SAPI_HEADER_DELETE_ALL: + if (sapi_module.header_handler) { + sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC); + } + zend_llist_clean(&SG(sapi_headers).headers); + return SUCCESS; + + default: + return FAILURE; + } + + header_line = estrndup(header_line, header_line_len); + + /* cut off trailing spaces, linefeeds and carriage-returns */ + if (header_line_len && isspace(header_line[header_line_len-1])) { + do { + header_line_len--; + } while(header_line_len && isspace(header_line[header_line_len-1])); + header_line[header_line_len]='\0'; + } + + if (op == SAPI_HEADER_DELETE) { + if (strchr(header_line, ':')) { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header to delete may not contain colon.""); + return FAILURE; + } + if (sapi_module.header_handler) { + sapi_header.header = header_line; + sapi_header.header_len = header_line_len; + sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC); + } + sapi_remove_header(&SG(sapi_headers).headers, header_line, header_line_len); + efree(header_line); + return SUCCESS; + } else { + /* new line/NUL character safety check */ + int i; + for (i = 0; i < header_line_len; i++) { + /* RFC 7230 ch. 3.2.4 deprecates folding support */ + if (header_line[i] == '\n' || header_line[i] == '\r') { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header may not contain "" + ""more than a single header, new line detected""); + return FAILURE; + } + if (header_line[i] == '\0') { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header may not contain NUL bytes""); + return FAILURE; + } + } + } + + sapi_header.header = header_line; + sapi_header.header_len = header_line_len; + + /* Check the header for a few cases that we have special support for in SAPI */ + if (header_line_len>=5 + && !strncasecmp(header_line, ""HTTP/"", 5)) { + /* filter out the response code */ + sapi_update_response_code(sapi_extract_response_code(header_line) TSRMLS_CC); + /* sapi_update_response_code doesn't free the status line if the code didn't change */ + if (SG(sapi_headers).http_status_line) { + efree(SG(sapi_headers).http_status_line); + } + SG(sapi_headers).http_status_line = header_line; + return SUCCESS; + } else { + colon_offset = strchr(header_line, ':'); + if (colon_offset) { + *colon_offset = 0; + if (!STRCASECMP(header_line, ""Content-Type"")) { + char *ptr = colon_offset+1, *mimetype = NULL, *newheader; + size_t len = header_line_len - (ptr - header_line), newlen; + while (*ptr == ' ') { + ptr++; + len--; + } + + /* Disable possible output compression for images */ + if (!strncmp(ptr, ""image/"", sizeof(""image/"")-1)) { + zend_alter_ini_entry(""zlib.output_compression"", sizeof(""zlib.output_compression""), ""0"", sizeof(""0"") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + } + + mimetype = estrdup(ptr); + newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC); + if (!SG(sapi_headers).mimetype){ + SG(sapi_headers).mimetype = estrdup(mimetype); + } + + if (newlen != 0) { + newlen += sizeof(""Content-type: ""); + newheader = emalloc(newlen); + PHP_STRLCPY(newheader, ""Content-type: "", newlen, sizeof(""Content-type: "")-1); + strlcat(newheader, mimetype, newlen); + sapi_header.header = newheader; + sapi_header.header_len = newlen - 1; + efree(header_line); + } + efree(mimetype); + SG(sapi_headers).send_default_content_type = 0; + } else if (!STRCASECMP(header_line, ""Content-Length"")) { + /* Script is setting Content-length. The script cannot reasonably + * know the size of the message body after compression, so it's best + * do disable compression altogether. This contributes to making scripts + * portable between setups that have and don't have zlib compression + * enabled globally. See req #44164 */ + zend_alter_ini_entry(""zlib.output_compression"", sizeof(""zlib.output_compression""), + ""0"", sizeof(""0"") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + } else if (!STRCASECMP(header_line, ""Location"")) { + if ((SG(sapi_headers).http_response_code < 300 || + SG(sapi_headers).http_response_code > 399) && + SG(sapi_headers).http_response_code != 201) { + /* Return a Found Redirect if one is not already specified */ + if (http_response_code) { /* user specified redirect code */ + sapi_update_response_code(http_response_code TSRMLS_CC); + } else if (SG(request_info).proto_num > 1000 && + SG(request_info).request_method && + strcmp(SG(request_info).request_method, ""HEAD"") && + strcmp(SG(request_info).request_method, ""GET"")) { + sapi_update_response_code(303 TSRMLS_CC); + } else { + sapi_update_response_code(302 TSRMLS_CC); + } + } + } else if (!STRCASECMP(header_line, ""WWW-Authenticate"")) { /* HTTP Authentication */ + sapi_update_response_code(401 TSRMLS_CC); /* authentication-required */ + } + if (sapi_header.header==header_line) { + *colon_offset = ':'; + } + } + } + if (http_response_code) { + sapi_update_response_code(http_response_code TSRMLS_CC); + } + sapi_header_add_op(op, &sapi_header TSRMLS_CC); + return SUCCESS; +} +","@@ -743,13 +743,8 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) + /* new line/NUL character safety check */ + int i; + for (i = 0; i < header_line_len; i++) { +- /* RFC 2616 allows new lines if followed by SP or HT */ +- int illegal_break = +- (header_line[i+1] != ' ' && header_line[i+1] != '\t') +- && ( +- header_line[i] == '\n' +- || (header_line[i] == '\r' && header_line[i+1] != '\n')); +- if (illegal_break) { ++ /* RFC 7230 ch. 3.2.4 deprecates folding support */ ++ if (header_line[i] == '\n' || header_line[i] == '\r') { + efree(header_line); + sapi_module.sapi_error(E_WARNING, ""Header may not contain "" + ""more than a single header, new line detected"");",1764,2000,2048 +586,"_gcry_ecc_eddsa_recover_x (gcry_mpi_t x, gcry_mpi_t y, int sign, mpi_ec_t ec) +{ + gpg_err_code_t rc = 0; + gcry_mpi_t u, v, v3, t; + static gcry_mpi_t p58, seven; + + if (ec->dialect != ECC_DIALECT_ED25519) + return GPG_ERR_NOT_IMPLEMENTED; + + if (!p58) + p58 = scanval (""0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"" + ""FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD""); + if (!seven) + seven = mpi_set_ui (NULL, 7); + + u = mpi_new (0); + v = mpi_new (0); + v3 = mpi_new (0); + t = mpi_new (0); + + /* Compute u and v */ + /* u = y^2 */ + mpi_mulm (u, y, y, ec->p); + /* v = b*y^2 */ + mpi_mulm (v, ec->b, u, ec->p); + /* u = y^2-1 */ + mpi_sub_ui (u, u, 1); + /* v = b*y^2+1 */ + mpi_add_ui (v, v, 1); + + /* Compute sqrt(u/v) */ + /* v3 = v^3 */ + mpi_powm (v3, v, mpi_const (MPI_C_THREE), ec->p); + /* t = v3 * v3 * u * v = u * v^7 */ + mpi_powm (t, v, seven, ec->p); + mpi_mulm (t, t, u, ec->p); + /* t = t^((p-5)/8) = (u * v^7)^((p-5)/8) */ + mpi_powm (t, t, p58, ec->p); + /* x = t * u * v^3 = (u * v^3) * (u * v^7)^((p-5)/8) */ + mpi_mulm (t, t, u, ec->p); + mpi_mulm (x, t, v3, ec->p); + + /* Adjust if needed. */ + /* t = v * x^2 */ + mpi_mulm (t, x, x, ec->p); + mpi_mulm (t, t, v, ec->p); + /* -t == u ? x = x * sqrt(-1) */ + mpi_sub (t, ec->p, t); + if (!mpi_cmp (t, u)) + { + static gcry_mpi_t m1; /* Fixme: this is not thread-safe. */ + if (!m1) + m1 = scanval (""2B8324804FC1DF0B2B4D00993DFBD7A7"" + ""2F431806AD2FE478C4EE1B274A0EA0B0""); + mpi_mulm (x, x, m1, ec->p); + /* t = v * x^2 */ + mpi_mulm (t, x, x, ec->p); + mpi_mulm (t, t, v, ec->p); + /* -t == u ? x = x * sqrt(-1) */ + mpi_sub (t, ec->p, t); + if (!mpi_cmp (t, u)) + rc = GPG_ERR_INV_OBJ; + } + + /* Choose the desired square root according to parity */ + if (mpi_test_bit (x, 0) != !!sign) + mpi_sub (x, ec->p, x); + + mpi_free (t); + mpi_free (v3); + mpi_free (v); + mpi_free (u); + + return rc; +} +",0,"_gcry_ecc_eddsa_recover_x (gcry_mpi_t x, gcry_mpi_t y, int sign, mpi_ec_t ec) +{ + gpg_err_code_t rc = 0; + gcry_mpi_t u, v, v3, t; + static gcry_mpi_t p58, seven; + + if (ec->dialect != ECC_DIALECT_ED25519) + return GPG_ERR_NOT_IMPLEMENTED; + + if (!p58) + p58 = scanval (""0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"" + ""FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD""); + if (!seven) + seven = mpi_set_ui (NULL, 7); + + u = mpi_new (0); + v = mpi_new (0); + v3 = mpi_new (0); + t = mpi_new (0); + + /* Compute u and v */ + /* u = y^2 */ + mpi_mulm (u, y, y, ec->p); + /* v = b*y^2 */ + mpi_mulm (v, ec->b, u, ec->p); + /* u = y^2-1 */ + mpi_sub_ui (u, u, 1); + /* v = b*y^2+1 */ + mpi_add_ui (v, v, 1); + + /* Compute sqrt(u/v) */ + /* v3 = v^3 */ + mpi_powm (v3, v, mpi_const (MPI_C_THREE), ec->p); + /* t = v3 * v3 * u * v = u * v^7 */ + mpi_powm (t, v, seven, ec->p); + mpi_mulm (t, t, u, ec->p); + /* t = t^((p-5)/8) = (u * v^7)^((p-5)/8) */ + mpi_powm (t, t, p58, ec->p); + /* x = t * u * v^3 = (u * v^3) * (u * v^7)^((p-5)/8) */ + mpi_mulm (t, t, u, ec->p); + mpi_mulm (x, t, v3, ec->p); + + /* Adjust if needed. */ + /* t = v * x^2 */ + mpi_mulm (t, x, x, ec->p); + mpi_mulm (t, t, v, ec->p); + /* -t == u ? x = x * sqrt(-1) */ + mpi_sub (t, ec->p, t); + if (!mpi_cmp (t, u)) + { + static gcry_mpi_t m1; /* Fixme: this is not thread-safe. */ + if (!m1) + m1 = scanval (""2B8324804FC1DF0B2B4D00993DFBD7A7"" + ""2F431806AD2FE478C4EE1B274A0EA0B0""); + mpi_mulm (x, x, m1, ec->p); + /* t = v * x^2 */ + mpi_mulm (t, x, x, ec->p); + mpi_mulm (t, t, v, ec->p); + /* -t == u ? x = x * sqrt(-1) */ + mpi_sub (t, ec->p, t); + if (!mpi_cmp (t, u)) + rc = GPG_ERR_INV_OBJ; + } + + /* Choose the desired square root according to parity */ + if (mpi_test_bit (x, 0) != !!sign) + mpi_sub (x, ec->p, x); + + mpi_free (t); + mpi_free (v3); + mpi_free (v); + mpi_free (u); + + return rc; +} +","@@ -603,7 +603,7 @@ _gcry_ecc_eddsa_sign (gcry_mpi_t input, ECC_secret_key *skey, + a = mpi_snew (0); + x = mpi_new (0); + y = mpi_new (0); +- r = mpi_new (0); ++ r = mpi_snew (0); + ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0, + skey->E.p, skey->E.a, skey->E.b); + b = (ctx->nbits+7)/8;",845,1081,2048 +17613,"IMPEG2D_ERROR_CODES_T impeg2d_process_video_bit_stream(dec_state_t *ps_dec) +{ + stream_t *ps_stream; + UWORD32 u4_next_bits, u4_start_code_found; + IMPEG2D_ERROR_CODES_T e_error; + + ps_stream = &ps_dec->s_bit_stream; + impeg2d_next_start_code(ps_dec); + /* If the stream is MPEG-2 compliant stream */ + u4_start_code_found = 0; + + if(ps_dec->u2_is_mpeg2) + { + /* MPEG2 decoding starts */ + while((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + u4_next_bits = impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN); + + if(u4_next_bits == SEQUENCE_HEADER_CODE) + { + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + e_error = impeg2d_dec_seq_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + u4_start_code_found = 0; + + } + else + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + + + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + IMPEG2D_ERROR_CODES_T e_error; + e_error = impeg2d_dec_seq_ext(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + u4_start_code_found = 0; + + } + else + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + } + else if((u4_next_bits == USER_DATA_START_CODE) || (u4_next_bits == EXTENSION_START_CODE)) + { + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + impeg2d_dec_seq_ext_data(ps_dec); + u4_start_code_found = 0; + + } + + } + else if((ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + && (u4_next_bits == GOP_START_CODE)) + { + impeg2d_dec_grp_of_pic_hdr(ps_dec); + impeg2d_dec_user_data(ps_dec); + u4_start_code_found = 0; + + } + else if((ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + && (u4_next_bits == PICTURE_START_CODE)) + { + ps_dec->i4_pic_count++; + + e_error = impeg2d_dec_pic_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + e_error = impeg2d_dec_pic_coding_ext(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + e_error = impeg2d_dec_pic_ext_data(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + e_error = impeg2d_pre_pic_dec_proc(ps_dec); + if ((IMPEG2D_ERROR_CODES_T) IVD_ERROR_NONE != e_error) + { + return e_error; + } + impeg2d_dec_pic_data(ps_dec); + impeg2d_post_pic_dec_proc(ps_dec); + u4_start_code_found = 1; + } + else + + { + FLUSH_BITS(ps_dec->s_bit_stream.u4_offset, ps_dec->s_bit_stream.u4_buf, ps_dec->s_bit_stream.u4_buf_nxt, 8, ps_dec->s_bit_stream.pu4_buf_aligned); + + } + if(u4_start_code_found == 0) + { + impeg2d_next_start_code(ps_dec); + /* In case a dec_pic_data call has not been made, the number of + * bytes consumed in the previous header decode has to be + * consumed. Not consuming it will result in zero bytes consumed + * loops in case there are multiple headers and the second + * or a future header has a resolution change/other error where + * the bytes of the last header are not consumed. + */ + ps_dec->i4_bytes_consumed = (ps_dec->s_bit_stream.u4_offset + 7) >> 3; + ps_dec->i4_bytes_consumed -= ((size_t)ps_dec->s_bit_stream.pv_bs_buf & 3); + } + } + if((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset > ps_dec->s_bit_stream.u4_max_offset)) + { + return IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND; + } + + } + /* If the stream is MPEG-1 compliant stream */ + else + { + while((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + u4_next_bits = impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN); + + if(impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN) == SEQUENCE_HEADER_CODE) + { + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + e_error = impeg2d_dec_seq_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + u4_start_code_found = 0; + } + else + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + } + else if((ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) && (u4_next_bits == EXTENSION_START_CODE || u4_next_bits == USER_DATA_START_CODE)) + { + impeg2d_flush_ext_and_user_data(ps_dec); + u4_start_code_found = 0; + } + + + else if ((impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN) == GOP_START_CODE) + && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + impeg2d_dec_grp_of_pic_hdr(ps_dec); + impeg2d_flush_ext_and_user_data(ps_dec); + u4_start_code_found = 0; + } + else if ((impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN) == PICTURE_START_CODE) + && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + ps_dec->i4_pic_count++; + + e_error = impeg2d_dec_pic_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + impeg2d_flush_ext_and_user_data(ps_dec); + impeg2d_pre_pic_dec_proc(ps_dec); + impeg2d_dec_pic_data(ps_dec); + impeg2d_post_pic_dec_proc(ps_dec); + u4_start_code_found = 1; + } + else + { + FLUSH_BITS(ps_dec->s_bit_stream.u4_offset, ps_dec->s_bit_stream.u4_buf, ps_dec->s_bit_stream.u4_buf_nxt, 8, ps_dec->s_bit_stream.pu4_buf_aligned); + } + impeg2d_next_start_code(ps_dec); + if (0 == u4_start_code_found) + { + /* In case a dec_pic_data call has not been made, the number of + * bytes consumed in the previous header decode has to be + * consumed. Not consuming it will result in zero bytes consumed + * loops in case there are multiple headers and the second + * or a future header has a resolution change/other error where + * the bytes of the last header are not consumed. + */ + ps_dec->i4_bytes_consumed = (ps_dec->s_bit_stream.u4_offset + 7) >> 3; + ps_dec->i4_bytes_consumed -= ((size_t)ps_dec->s_bit_stream.pv_bs_buf & 3); + } + } + if((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset > ps_dec->s_bit_stream.u4_max_offset)) + { + return IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND; + } + } + + return (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE; +} +",0,"IMPEG2D_ERROR_CODES_T impeg2d_process_video_bit_stream(dec_state_t *ps_dec) +{ + stream_t *ps_stream; + UWORD32 u4_next_bits, u4_start_code_found; + IMPEG2D_ERROR_CODES_T e_error; + + ps_stream = &ps_dec->s_bit_stream; + impeg2d_next_start_code(ps_dec); + /* If the stream is MPEG-2 compliant stream */ + u4_start_code_found = 0; + + if(ps_dec->u2_is_mpeg2) + { + /* MPEG2 decoding starts */ + while((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + u4_next_bits = impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN); + + if(u4_next_bits == SEQUENCE_HEADER_CODE) + { + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + e_error = impeg2d_dec_seq_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + u4_start_code_found = 0; + + } + else + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + + + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + IMPEG2D_ERROR_CODES_T e_error; + e_error = impeg2d_dec_seq_ext(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + u4_start_code_found = 0; + + } + else + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + } + else if((u4_next_bits == USER_DATA_START_CODE) || (u4_next_bits == EXTENSION_START_CODE)) + { + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + impeg2d_dec_seq_ext_data(ps_dec); + u4_start_code_found = 0; + + } + + } + else if((ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + && (u4_next_bits == GOP_START_CODE)) + { + impeg2d_dec_grp_of_pic_hdr(ps_dec); + impeg2d_dec_user_data(ps_dec); + u4_start_code_found = 0; + + } + else if((ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + && (u4_next_bits == PICTURE_START_CODE)) + { + ps_dec->i4_pic_count++; + + e_error = impeg2d_dec_pic_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + e_error = impeg2d_dec_pic_coding_ext(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + e_error = impeg2d_dec_pic_ext_data(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + e_error = impeg2d_pre_pic_dec_proc(ps_dec); + if ((IMPEG2D_ERROR_CODES_T) IVD_ERROR_NONE != e_error) + { + return e_error; + } + impeg2d_dec_pic_data(ps_dec); + impeg2d_post_pic_dec_proc(ps_dec); + u4_start_code_found = 1; + } + else + + { + FLUSH_BITS(ps_dec->s_bit_stream.u4_offset, ps_dec->s_bit_stream.u4_buf, ps_dec->s_bit_stream.u4_buf_nxt, 8, ps_dec->s_bit_stream.pu4_buf_aligned); + + } + if(u4_start_code_found == 0) + { + impeg2d_next_start_code(ps_dec); + /* In case a dec_pic_data call has not been made, the number of + * bytes consumed in the previous header decode has to be + * consumed. Not consuming it will result in zero bytes consumed + * loops in case there are multiple headers and the second + * or a future header has a resolution change/other error where + * the bytes of the last header are not consumed. + */ + ps_dec->i4_bytes_consumed = (ps_dec->s_bit_stream.u4_offset + 7) >> 3; + ps_dec->i4_bytes_consumed -= ((size_t)ps_dec->s_bit_stream.pv_bs_buf & 3); + } + } + if((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset > ps_dec->s_bit_stream.u4_max_offset)) + { + return IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND; + } + + } + /* If the stream is MPEG-1 compliant stream */ + else + { + while((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + u4_next_bits = impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN); + + if(impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN) == SEQUENCE_HEADER_CODE) + { + if(ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) + { + e_error = impeg2d_dec_seq_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + u4_start_code_found = 0; + } + else + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + } + else if((ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset) && (u4_next_bits == EXTENSION_START_CODE || u4_next_bits == USER_DATA_START_CODE)) + { + impeg2d_flush_ext_and_user_data(ps_dec); + u4_start_code_found = 0; + } + + + else if ((impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN) == GOP_START_CODE) + && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + impeg2d_dec_grp_of_pic_hdr(ps_dec); + impeg2d_flush_ext_and_user_data(ps_dec); + u4_start_code_found = 0; + } + else if ((impeg2d_bit_stream_nxt(ps_stream,START_CODE_LEN) == PICTURE_START_CODE) + && (ps_dec->s_bit_stream.u4_offset < ps_dec->s_bit_stream.u4_max_offset)) + { + ps_dec->i4_pic_count++; + + e_error = impeg2d_dec_pic_hdr(ps_dec); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + impeg2d_flush_ext_and_user_data(ps_dec); + impeg2d_pre_pic_dec_proc(ps_dec); + impeg2d_dec_pic_data(ps_dec); + impeg2d_post_pic_dec_proc(ps_dec); + u4_start_code_found = 1; + } + else + { + FLUSH_BITS(ps_dec->s_bit_stream.u4_offset, ps_dec->s_bit_stream.u4_buf, ps_dec->s_bit_stream.u4_buf_nxt, 8, ps_dec->s_bit_stream.pu4_buf_aligned); + } + impeg2d_next_start_code(ps_dec); + if (0 == u4_start_code_found) + { + /* In case a dec_pic_data call has not been made, the number of + * bytes consumed in the previous header decode has to be + * consumed. Not consuming it will result in zero bytes consumed + * loops in case there are multiple headers and the second + * or a future header has a resolution change/other error where + * the bytes of the last header are not consumed. + */ + ps_dec->i4_bytes_consumed = (ps_dec->s_bit_stream.u4_offset + 7) >> 3; + ps_dec->i4_bytes_consumed -= ((size_t)ps_dec->s_bit_stream.pv_bs_buf & 3); + } + } + if((u4_start_code_found == 0) && (ps_dec->s_bit_stream.u4_offset > ps_dec->s_bit_stream.u4_max_offset)) + { + return IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND; + } + } + + return (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE; +} +","@@ -712,6 +712,11 @@ + + + if(ps_dec->u2_is_mpeg2 == 0) + { ++ if (ps_dec->u2_forw_f_code < 1 || ps_dec->u2_forw_f_code > 7 || ++ ps_dec->u2_back_f_code < 1 || ps_dec->u2_back_f_code > 7) ++ { ++ return IMPEG2D_UNKNOWN_ERROR; ++ } + ps_dec->au2_f_code[0][0] = ps_dec->au2_f_code[0][1] = ps_dec->u2_forw_f_code; + ps_dec->au2_f_code[1][0] = ps_dec->au2_f_code[1][1] = ps_dec->u2_back_f_code; + } +",1803,2039,2048 +6173,"static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset, + size_t size, int flags) +{ + struct tcp_sock *tp = tcp_sk(sk); + int mss_now, size_goal; + int err; + ssize_t copied; + long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); + + /* Wait for a connection to finish. One exception is TCP Fast Open + * (passive side) where data is allowed to be sent before a connection + * is fully established. + */ + if (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) && + !tcp_passive_fastopen(sk)) { + err = sk_stream_wait_connect(sk, &timeo); + if (err != 0) + goto out_err; + } + + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); + + mss_now = tcp_send_mss(sk, &size_goal, flags); + copied = 0; + + err = -EPIPE; + if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) + goto out_err; + + while (size > 0) { + struct sk_buff *skb = tcp_write_queue_tail(sk); + int copy, i; + bool can_coalesce; + + if (!tcp_send_head(sk) || (copy = size_goal - skb->len) <= 0 || + !tcp_skb_can_collapse_to(skb)) { +new_segment: + if (!sk_stream_memory_free(sk)) + goto wait_for_sndbuf; + + skb = sk_stream_alloc_skb(sk, 0, sk->sk_allocation, + skb_queue_empty(&sk->sk_write_queue)); + if (!skb) + goto wait_for_memory; + + skb_entail(sk, skb); + copy = size_goal; + } + + if (copy > size) + copy = size; + + i = skb_shinfo(skb)->nr_frags; + can_coalesce = skb_can_coalesce(skb, i, page, offset); + if (!can_coalesce && i >= sysctl_max_skb_frags) { + tcp_mark_push(tp, skb); + goto new_segment; + } + if (!sk_wmem_schedule(sk, copy)) + goto wait_for_memory; + + if (can_coalesce) { + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); + } else { + get_page(page); + skb_fill_page_desc(skb, i, page, offset, copy); + } + skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; + + skb->len += copy; + skb->data_len += copy; + skb->truesize += copy; + sk->sk_wmem_queued += copy; + sk_mem_charge(sk, copy); + skb->ip_summed = CHECKSUM_PARTIAL; + tp->write_seq += copy; + TCP_SKB_CB(skb)->end_seq += copy; + tcp_skb_pcount_set(skb, 0); + + if (!copied) + TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH; + + copied += copy; + offset += copy; + size -= copy; + if (!size) + goto out; + + if (skb->len < size_goal || (flags & MSG_OOB)) + continue; + + if (forced_push(tp)) { + tcp_mark_push(tp, skb); + __tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH); + } else if (skb == tcp_send_head(sk)) + tcp_push_one(sk, mss_now); + continue; + +wait_for_sndbuf: + set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); +wait_for_memory: + tcp_push(sk, flags & ~MSG_MORE, mss_now, + TCP_NAGLE_PUSH, size_goal); + + err = sk_stream_wait_memory(sk, &timeo); + if (err != 0) + goto do_error; + + mss_now = tcp_send_mss(sk, &size_goal, flags); + } + +out: + if (copied) { + tcp_tx_timestamp(sk, sk->sk_tsflags, tcp_write_queue_tail(sk)); + if (!(flags & MSG_SENDPAGE_NOTLAST)) + tcp_push(sk, flags, mss_now, tp->nonagle, size_goal); + } + return copied; + +do_error: + if (copied) + goto out; +out_err: + /* make sure we wake any epoll edge trigger waiter */ + if (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 && + err == -EAGAIN)) { + sk->sk_write_space(sk); + tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED); + } + return sk_stream_error(sk, flags, err); +} +",0,"static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset, + size_t size, int flags) +{ + struct tcp_sock *tp = tcp_sk(sk); + int mss_now, size_goal; + int err; + ssize_t copied; + long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); + + /* Wait for a connection to finish. One exception is TCP Fast Open + * (passive side) where data is allowed to be sent before a connection + * is fully established. + */ + if (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) && + !tcp_passive_fastopen(sk)) { + err = sk_stream_wait_connect(sk, &timeo); + if (err != 0) + goto out_err; + } + + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); + + mss_now = tcp_send_mss(sk, &size_goal, flags); + copied = 0; + + err = -EPIPE; + if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) + goto out_err; + + while (size > 0) { + struct sk_buff *skb = tcp_write_queue_tail(sk); + int copy, i; + bool can_coalesce; + + if (!tcp_send_head(sk) || (copy = size_goal - skb->len) <= 0 || + !tcp_skb_can_collapse_to(skb)) { +new_segment: + if (!sk_stream_memory_free(sk)) + goto wait_for_sndbuf; + + skb = sk_stream_alloc_skb(sk, 0, sk->sk_allocation, + skb_queue_empty(&sk->sk_write_queue)); + if (!skb) + goto wait_for_memory; + + skb_entail(sk, skb); + copy = size_goal; + } + + if (copy > size) + copy = size; + + i = skb_shinfo(skb)->nr_frags; + can_coalesce = skb_can_coalesce(skb, i, page, offset); + if (!can_coalesce && i >= sysctl_max_skb_frags) { + tcp_mark_push(tp, skb); + goto new_segment; + } + if (!sk_wmem_schedule(sk, copy)) + goto wait_for_memory; + + if (can_coalesce) { + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); + } else { + get_page(page); + skb_fill_page_desc(skb, i, page, offset, copy); + } + skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; + + skb->len += copy; + skb->data_len += copy; + skb->truesize += copy; + sk->sk_wmem_queued += copy; + sk_mem_charge(sk, copy); + skb->ip_summed = CHECKSUM_PARTIAL; + tp->write_seq += copy; + TCP_SKB_CB(skb)->end_seq += copy; + tcp_skb_pcount_set(skb, 0); + + if (!copied) + TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH; + + copied += copy; + offset += copy; + size -= copy; + if (!size) + goto out; + + if (skb->len < size_goal || (flags & MSG_OOB)) + continue; + + if (forced_push(tp)) { + tcp_mark_push(tp, skb); + __tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH); + } else if (skb == tcp_send_head(sk)) + tcp_push_one(sk, mss_now); + continue; + +wait_for_sndbuf: + set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); +wait_for_memory: + tcp_push(sk, flags & ~MSG_MORE, mss_now, + TCP_NAGLE_PUSH, size_goal); + + err = sk_stream_wait_memory(sk, &timeo); + if (err != 0) + goto do_error; + + mss_now = tcp_send_mss(sk, &size_goal, flags); + } + +out: + if (copied) { + tcp_tx_timestamp(sk, sk->sk_tsflags, tcp_write_queue_tail(sk)); + if (!(flags & MSG_SENDPAGE_NOTLAST)) + tcp_push(sk, flags, mss_now, tp->nonagle, size_goal); + } + return copied; + +do_error: + if (copied) + goto out; +out_err: + /* make sure we wake any epoll edge trigger waiter */ + if (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 && + err == -EAGAIN)) { + sk->sk_write_space(sk); + tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED); + } + return sk_stream_error(sk, flags, err); +} +","@@ -2320,6 +2320,10 @@ int tcp_disconnect(struct sock *sk, int flags) + tcp_set_ca_state(sk, TCP_CA_Open); + tcp_clear_retrans(tp); + inet_csk_delack_init(sk); ++ /* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0 ++ * issue in __tcp_select_window() ++ */ ++ icsk->icsk_ack.rcv_mss = TCP_MIN_MSS; + tcp_init_send_head(sk); + memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); + __sk_dst_reset(sk);",1031,1267,2048 +14888,"static int SplitNode( + Rtree *pRtree, + RtreeNode *pNode, + RtreeCell *pCell, + int iHeight +){ + int i; + int newCellIsRight = 0; + + int rc = SQLITE_OK; + int nCell = NCELL(pNode); + RtreeCell *aCell; + int *aiUsed; + + RtreeNode *pLeft = 0; + RtreeNode *pRight = 0; + + RtreeCell leftbbox; + RtreeCell rightbbox; + + /* Allocate an array and populate it with a copy of pCell and + ** all cells from node pLeft. Then zero the original node. + */ + aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1)); + if( !aCell ){ + rc = SQLITE_NOMEM; + goto splitnode_out; + } + aiUsed = (int *)&aCell[nCell+1]; + memset(aiUsed, 0, sizeof(int)*(nCell+1)); + for(i=0; iiNode==1 ){ + pRight = nodeNew(pRtree, pNode); + pLeft = nodeNew(pRtree, pNode); + pRtree->iDepth++; + pNode->isDirty = 1; + writeInt16(pNode->zData, pRtree->iDepth); + }else{ + pLeft = pNode; + pRight = nodeNew(pRtree, pLeft->pParent); + nodeReference(pLeft); + } + + if( !pLeft || !pRight ){ + rc = SQLITE_NOMEM; + goto splitnode_out; + } + + memset(pLeft->zData, 0, pRtree->iNodeSize); + memset(pRight->zData, 0, pRtree->iNodeSize); + + rc = splitNodeStartree(pRtree, aCell, nCell, pLeft, pRight, + &leftbbox, &rightbbox); + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + + /* Ensure both child nodes have node numbers assigned to them by calling + ** nodeWrite(). Node pRight always needs a node number, as it was created + ** by nodeNew() above. But node pLeft sometimes already has a node number. + ** In this case avoid the all to nodeWrite(). + */ + if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight)) + || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft))) + ){ + goto splitnode_out; + } + + rightbbox.iRowid = pRight->iNode; + leftbbox.iRowid = pLeft->iNode; + + if( pNode->iNode==1 ){ + rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1); + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + }else{ + RtreeNode *pParent = pLeft->pParent; + int iCell; + rc = nodeParentIndex(pRtree, pLeft, &iCell); + if( rc==SQLITE_OK ){ + nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); + rc = AdjustTree(pRtree, pParent, &leftbbox); + } + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + } + if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){ + goto splitnode_out; + } + + for(i=0; iiRowid ){ + newCellIsRight = 1; + } + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + } + if( pNode->iNode==1 ){ + for(i=0; iiRowid, pLeft, iHeight); + } + + if( rc==SQLITE_OK ){ + rc = nodeRelease(pRtree, pRight); + pRight = 0; + } + if( rc==SQLITE_OK ){ + rc = nodeRelease(pRtree, pLeft); + pLeft = 0; + } + +splitnode_out: + nodeRelease(pRtree, pRight); + nodeRelease(pRtree, pLeft); + sqlite3_free(aCell); + return rc; +} +",0,"static int SplitNode( + Rtree *pRtree, + RtreeNode *pNode, + RtreeCell *pCell, + int iHeight +){ + int i; + int newCellIsRight = 0; + + int rc = SQLITE_OK; + int nCell = NCELL(pNode); + RtreeCell *aCell; + int *aiUsed; + + RtreeNode *pLeft = 0; + RtreeNode *pRight = 0; + + RtreeCell leftbbox; + RtreeCell rightbbox; + + /* Allocate an array and populate it with a copy of pCell and + ** all cells from node pLeft. Then zero the original node. + */ + aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1)); + if( !aCell ){ + rc = SQLITE_NOMEM; + goto splitnode_out; + } + aiUsed = (int *)&aCell[nCell+1]; + memset(aiUsed, 0, sizeof(int)*(nCell+1)); + for(i=0; iiNode==1 ){ + pRight = nodeNew(pRtree, pNode); + pLeft = nodeNew(pRtree, pNode); + pRtree->iDepth++; + pNode->isDirty = 1; + writeInt16(pNode->zData, pRtree->iDepth); + }else{ + pLeft = pNode; + pRight = nodeNew(pRtree, pLeft->pParent); + nodeReference(pLeft); + } + + if( !pLeft || !pRight ){ + rc = SQLITE_NOMEM; + goto splitnode_out; + } + + memset(pLeft->zData, 0, pRtree->iNodeSize); + memset(pRight->zData, 0, pRtree->iNodeSize); + + rc = splitNodeStartree(pRtree, aCell, nCell, pLeft, pRight, + &leftbbox, &rightbbox); + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + + /* Ensure both child nodes have node numbers assigned to them by calling + ** nodeWrite(). Node pRight always needs a node number, as it was created + ** by nodeNew() above. But node pLeft sometimes already has a node number. + ** In this case avoid the all to nodeWrite(). + */ + if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight)) + || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft))) + ){ + goto splitnode_out; + } + + rightbbox.iRowid = pRight->iNode; + leftbbox.iRowid = pLeft->iNode; + + if( pNode->iNode==1 ){ + rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1); + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + }else{ + RtreeNode *pParent = pLeft->pParent; + int iCell; + rc = nodeParentIndex(pRtree, pLeft, &iCell); + if( rc==SQLITE_OK ){ + nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); + rc = AdjustTree(pRtree, pParent, &leftbbox); + } + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + } + if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){ + goto splitnode_out; + } + + for(i=0; iiRowid ){ + newCellIsRight = 1; + } + if( rc!=SQLITE_OK ){ + goto splitnode_out; + } + } + if( pNode->iNode==1 ){ + for(i=0; iiRowid, pLeft, iHeight); + } + + if( rc==SQLITE_OK ){ + rc = nodeRelease(pRtree, pRight); + pRight = 0; + } + if( rc==SQLITE_OK ){ + rc = nodeRelease(pRtree, pLeft); + pLeft = 0; + } + +splitnode_out: + nodeRelease(pRtree, pRight); + nodeRelease(pRtree, pLeft); + sqlite3_free(aCell); + return rc; +} +","@@ -4065,6 +4065,15 @@ typedef struct sqlite3_context sqlite3_context; + ** [sqlite3_blob_open | incremental BLOB I/O] routines. + ** ^A negative value for the zeroblob results in a zero-length BLOB. + ** ++** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in ++** [prepared statement] S to have an SQL value of NULL, but to also be ++** associated with the pointer P. ++** ^The sqlite3_bind_pointer() routine can be used to pass ++** host-language pointers into [application-defined SQL functions]. ++** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears ++** to be an ordinary SQL NULL value to everything other than ++** [sqlite3_value_pointer()]. ++** + ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer + ** for the [prepared statement] or with a prepared statement for which + ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], +@@ -4098,6 +4107,7 @@ SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*) + SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, + void(*)(void*), unsigned char encoding); + SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); ++SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*); + SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); + SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); + +@@ -4867,6 +4877,11 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 + ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces + ** extract UTF-16 strings as big-endian and little-endian respectively. + ** ++** ^If [sqlite3_value] object V was initialized ++** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then ++** sqlite3_value_pointer(V) will return the pointer P. Otherwise, ++** sqlite3_value_pointer(V) returns a NULL. ++** + ** ^(The sqlite3_value_numeric_type() interface attempts to apply + ** numeric affinity to the value. This means that an attempt is + ** made to convert the value to an integer or floating point. If +@@ -4894,6 +4909,7 @@ SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); + SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); + SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); + SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); ++SQLITE_API void *sqlite3_value_pointer(sqlite3_value*); + SQLITE_API int sqlite3_value_type(sqlite3_value*); + SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); + +@@ -4906,10 +4922,6 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); + ** information can be used to pass a limited amount of context from + ** one SQL function to another. Use the [sqlite3_result_subtype()] + ** routine to set the subtype for the return value of an SQL function. +-** +-** SQLite makes no use of subtype itself. It merely passes the subtype +-** from the result of one [application-defined SQL function] into the +-** input of another. + */ + SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); + +@@ -5187,6 +5199,14 @@ typedef void (*sqlite3_destructor_type)(void*); + ** [unprotected sqlite3_value] object is required, so either + ** kind of [sqlite3_value] object can be used with this interface. + ** ++** ^The sqlite3_result_pointer(C,P) interface sets the result to an ++** SQL NULL value, just like [sqlite3_result_null(C)], except that it ++** also associates the host-language pointer P with that NULL value such ++** that the pointer can be retrieved within an ++** [application-defined SQL function] using [sqlite3_value_pointer()]. ++** This mechanism can be used to pass non-SQL values between ++** application-defined functions. ++** + ** If these routines are called from within the different thread + ** than the one containing the application-defined function that received + ** the [sqlite3_context] pointer, the results are undefined. +@@ -5210,6 +5230,7 @@ SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(* + SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); + SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); + SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); ++SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*); + SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); + SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); + +@@ -18089,6 +18110,7 @@ struct Mem { + double r; /* Real value used when MEM_Real is set in flags */ + i64 i; /* Integer value used when MEM_Int is set in flags */ + int nZero; /* Used when bit MEM_Zero is set in flags */ ++ void *pPtr; /* Pointer when flags=MEM_NULL and eSubtype='p' */ + FuncDef *pDef; /* Used only when flags==MEM_Agg */ + RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ + VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ +@@ -18374,6 +18396,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64); + #else + SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); + #endif ++SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*); + SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); + SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); + SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); +@@ -70280,6 +70303,17 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){ + } + } + ++/* ++** Set the value stored in *pMem should already be a NULL. ++** Also store a pointer to go with it. ++*/ ++SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){ ++ assert( pMem->flags==MEM_Null ); ++ pMem->flags = MEM_Null|MEM_Subtype; ++ pMem->u.pPtr = pPtr; ++ pMem->eSubtype = 'p'; ++} ++ + #ifndef SQLITE_OMIT_FLOATING_POINT + /* + ** Delete any previous value and set the value stored in *pMem to val, +@@ -76159,6 +76193,14 @@ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){ + Mem *pMem = (Mem*)pVal; + return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0); + } ++SQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal){ ++ Mem *p = (Mem*)pVal; ++ if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){ ++ return p->u.pPtr; ++ }else{ ++ return 0; ++ } ++} + SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ + return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8); + } +@@ -76337,6 +76379,12 @@ SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ + assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); + sqlite3VdbeMemSetNull(pCtx->pOut); + } ++SQLITE_API void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){ ++ Mem *pOut = pCtx->pOut; ++ assert( sqlite3_mutex_held(pOut->db->mutex) ); ++ sqlite3VdbeMemSetNull(pOut); ++ sqlite3VdbeMemSetPointer(pOut, pPtr); ++} + SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ + Mem *pOut = pCtx->pOut; + assert( sqlite3_mutex_held(pOut->db->mutex) ); +@@ -77322,6 +77370,16 @@ SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){ + } + return rc; + } ++SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){ ++ int rc; ++ Vdbe *p = (Vdbe*)pStmt; ++ rc = vdbeUnbind(p, i); ++ if( rc==SQLITE_OK ){ ++ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr); ++ sqlite3_mutex_leave(p->db->mutex); ++ } ++ return rc; ++} + SQLITE_API int sqlite3_bind_text( + sqlite3_stmt *pStmt, + int i, +@@ -148237,9 +148295,8 @@ static int fts3ColumnMethod( + sqlite3_result_int64(pCtx, pCsr->iPrevId); + }else if( iCol==p->nColumn ){ + /* The extra column whose name is the same as the table. +- ** Return a blob which is a pointer to the cursor. */ +- sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT); +- sqlite3_result_subtype(pCtx, '3'); ++ ** Return a pointer to the cursor. */ ++ sqlite3_result_pointer(pCtx, pCsr); + }else if( iCol==p->nColumn+2 && pCsr->pExpr ){ + sqlite3_result_int64(pCtx, pCsr->iLangid); + }else{ +@@ -148451,17 +148508,13 @@ static int fts3FunctionArg( + sqlite3_value *pVal, /* argv[0] passed to function */ + Fts3Cursor **ppCsr /* OUT: Store cursor handle here */ + ){ +- Fts3Cursor *pRet; +- if( sqlite3_value_type(pVal)!=SQLITE_BLOB +- || sqlite3_value_subtype(pVal)!='3' +- || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *) +- ){ ++ Fts3Cursor *pRet = (Fts3Cursor*)sqlite3_value_pointer(pVal); ++ if( pRet==0 ){ + char *zErr = sqlite3_mprintf(""illegal first argument to %s"", zFunc); + sqlite3_result_error(pContext, zErr, -1); + sqlite3_free(zErr); + return SQLITE_ERROR; + } +- memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *)); + *ppCsr = pRet; + return SQLITE_OK; + }",1150,1386,2048 +18496,"xmlParsePI(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + int cur, l; + const xmlChar *target; + xmlParserInputState state; + int count = 0; + + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParserInputPtr input = ctxt->input; + state = ctxt->instate; + ctxt->instate = XML_PARSER_PI; + /* + * this is a Processing Instruction. + */ + SKIP(2); + SHRINK; + + /* + * Parse the target name and check for special support like + * namespace. + */ + target = xmlParsePITarget(ctxt); + if (target != NULL) { + if ((RAW == '?') && (NXT(1) == '>')) { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, NULL); + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + return; + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->instate = state; + return; + } + cur = CUR; + if (!IS_BLANK(cur)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED, + ""ParsePI: PI %s space expected\n"", target); + } + SKIP_BLANKS; + cur = CUR_CHAR(l); + while (IS_CHAR(cur) && /* checked */ + ((cur != '?') || (NXT(1) != '>'))) { + if (len + 5 >= size) { + xmlChar *tmp; + + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + ctxt->instate = state; + return; + } + buf = tmp; + } + count++; + if (count > 50) { + GROW; + count = 0; + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); + cur = CUR_CHAR(l); + if (cur == 0) { + SHRINK; + GROW; + cur = CUR_CHAR(l); + } + } + buf[len] = 0; + if (cur != '?') { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""ParsePI: PI %s never end ...\n"", target); + } else { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + +#ifdef LIBXML_CATALOG_ENABLED + if (((state == XML_PARSER_MISC) || + (state == XML_PARSER_START)) && + (xmlStrEqual(target, XML_CATALOG_PI))) { + xmlCatalogAllow allow = xmlCatalogGetDefaults(); + if ((allow == XML_CATA_ALLOW_DOCUMENT) || + (allow == XML_CATA_ALLOW_ALL)) + xmlParseCatalogPI(ctxt, buf); + } +#endif + + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, buf); + } + xmlFree(buf); + } else { + xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); + } + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + } +} +",1,"xmlParsePI(xmlParserCtxtPtr ctxt) { + xmlChar *buf = NULL; + int len = 0; + int size = XML_PARSER_BUFFER_SIZE; + int cur, l; + const xmlChar *target; + xmlParserInputState state; + int count = 0; + + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParserInputPtr input = ctxt->input; + state = ctxt->instate; + ctxt->instate = XML_PARSER_PI; + /* + * this is a Processing Instruction. + */ + SKIP(2); + SHRINK; + + /* + * Parse the target name and check for special support like + * namespace. + */ + target = xmlParsePITarget(ctxt); + if (target != NULL) { + if ((RAW == '?') && (NXT(1) == '>')) { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, NULL); + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + return; + } + buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + if (buf == NULL) { + xmlErrMemory(ctxt, NULL); + ctxt->instate = state; + return; + } + cur = CUR; + if (!IS_BLANK(cur)) { + xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED, + ""ParsePI: PI %s space expected\n"", target); + } + SKIP_BLANKS; + cur = CUR_CHAR(l); + while (IS_CHAR(cur) && /* checked */ + ((cur != '?') || (NXT(1) != '>'))) { + if (len + 5 >= size) { + xmlChar *tmp; + + size *= 2; + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlErrMemory(ctxt, NULL); + xmlFree(buf); + ctxt->instate = state; + return; + } + buf = tmp; + } + count++; + if (count > 50) { + GROW; + if (ctxt->instate == XML_PARSER_EOF) { + xmlFree(buf); + return; + } + count = 0; + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); + cur = CUR_CHAR(l); + if (cur == 0) { + SHRINK; + GROW; + cur = CUR_CHAR(l); + } + } + buf[len] = 0; + if (cur != '?') { + xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED, + ""ParsePI: PI %s never end ...\n"", target); + } else { + if (input != ctxt->input) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + ""PI declaration doesn't start and stop in the same entity\n""); + } + SKIP(2); + +#ifdef LIBXML_CATALOG_ENABLED + if (((state == XML_PARSER_MISC) || + (state == XML_PARSER_START)) && + (xmlStrEqual(target, XML_CATALOG_PI))) { + xmlCatalogAllow allow = xmlCatalogGetDefaults(); + if ((allow == XML_CATA_ALLOW_DOCUMENT) || + (allow == XML_CATA_ALLOW_ALL)) + xmlParseCatalogPI(ctxt, buf); + } +#endif + + + /* + * SAX: PI detected. + */ + if ((ctxt->sax) && (!ctxt->disableSAX) && + (ctxt->sax->processingInstruction != NULL)) + ctxt->sax->processingInstruction(ctxt->userData, + target, buf); + } + xmlFree(buf); + } else { + xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); + } + if (ctxt->instate != XML_PARSER_EOF) + ctxt->instate = state; + } +} +","@@ -2013,6 +2013,8 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) { + ""Pushing input %d : %.30s\n"", ctxt->inputNr+1, input->cur); + } + ret = inputPush(ctxt, input); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + GROW; + return(ret); + } +@@ -2049,6 +2051,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) { + if (count++ > 20) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 16 + (CUR - '0'); +@@ -2080,6 +2084,8 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) { + if (count++ > 20) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(0); + } + if ((RAW >= '0') && (RAW <= '9')) + val = val * 10 + (CUR - '0'); +@@ -2366,6 +2372,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + NEXT; + if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL)) + entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (entity == NULL) { + + /* +@@ -2428,6 +2436,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) { + * the amount of data in the buffer. + */ + GROW ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if ((ctxt->input->end - ctxt->input->cur)>=4) { + start[0] = RAW; + start[1] = NXT(1); +@@ -3046,6 +3056,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + * Handler for more complex cases + */ + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + c = CUR_CHAR(l); + if ((ctxt->options & XML_PARSE_OLD10) == 0) { + /* +@@ -3097,6 +3109,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3121,6 +3135,8 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3214,6 +3230,8 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + } + len += l; + NEXTL(l); +@@ -3294,6 +3312,8 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) { + const xmlChar *ret; + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + + in = ctxt->input->cur; + while (*in != 0 && *in == *cmp) { +@@ -3421,6 +3441,8 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + #endif + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + c = CUR_CHAR(l); + + while (xmlIsNameChar(ctxt, c)) { +@@ -3449,6 +3471,10 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buffer); ++ return(NULL); ++ } + } + if (len + 10 > max) { + xmlChar *tmp; +@@ -3519,6 +3545,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + ctxt->instate = XML_PARSER_ENTITY_VALUE; + input = ctxt->input; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + NEXT; + c = CUR_CHAR(l); + /* +@@ -3530,8 +3560,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + * In practice it means we stop the loop only when back at parsing + * the initial entity and the quote is found + */ +- while ((IS_CHAR(c)) && ((c != stop) || /* checked */ +- (ctxt->input != input))) { ++ while (((IS_CHAR(c)) && ((c != stop) || /* checked */ ++ (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) { + if (len + 5 >= size) { + xmlChar *tmp; + +@@ -3560,6 +3590,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + } + } + buf[len] = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + + /* + * Raise problem w.r.t. '&' and '%' being used in non-entities +@@ -3607,12 +3641,12 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { + */ + ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, + 0, 0, 0); +- if (orig != NULL) ++ if (orig != NULL) + *orig = buf; + else + xmlFree(buf); + } +- ++ + return(ret); + } + +@@ -3663,8 +3697,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + * OK loop until we reach one of the ending char or a size limit. + */ + c = CUR_CHAR(l); +- while ((NXT(0) != limit) && /* checked */ +- (IS_CHAR(c)) && (c != '<')) { ++ while (((NXT(0) != limit) && /* checked */ ++ (IS_CHAR(c)) && (c != '<')) && ++ (ctxt->instate != XML_PARSER_EOF)) { + if (c == 0) break; + if (c == '&') { + in_space = 0; +@@ -3799,6 +3834,9 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + GROW; + c = CUR_CHAR(l); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto error; ++ + if ((in_space) && (normalize)) { + while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } +@@ -3820,6 +3858,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + + mem_error: + xmlErrMemory(ctxt, NULL); ++error: + if (buf != NULL) + xmlFree(buf); + if (rep != NULL) +@@ -3925,6 +3964,10 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + } + COPY_BUF(l,buf,len,cur); + NEXTL(l); +@@ -4002,6 +4045,10 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return(NULL); ++ } + } + NEXT; + cur = CUR; +@@ -4208,6 +4255,8 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) { + } + SHRINK; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + in = ctxt->input->cur; + } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09)); + nbchar = 0; +@@ -4276,6 +4325,8 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + } + NEXTL(l); + cur = CUR_CHAR(l); +@@ -4476,6 +4527,10 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) { + if (count > 50) { + GROW; + count = 0; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + } + NEXTL(l); + cur = CUR_CHAR(l); +@@ -4626,6 +4681,10 @@ xmlParseComment(xmlParserCtxtPtr ctxt) { + } + SHRINK; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + in = ctxt->input->cur; + if (*in == '-') { + if (in[1] == '-') { +@@ -4644,7 +4703,8 @@ xmlParseComment(xmlParserCtxtPtr ctxt) { + } + if (buf != NULL) + xmlFree(buf); +- ctxt->instate = state; ++ if (ctxt->instate != XML_PARSER_EOF) ++ ctxt->instate = state; + return; + } + if (buf != NULL) +@@ -4862,6 +4922,10 @@ xmlParsePI(xmlParserCtxtPtr ctxt) { + count++; + if (count > 50) { + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + count = 0; + } + COPY_BUF(l,buf,len,cur); +@@ -5211,6 +5275,8 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { + } + } + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + SKIP_BLANKS; + if (RAW != '>') { + xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED, +@@ -5602,7 +5668,7 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) { + } + SKIP_BLANKS; + GROW; +- while (RAW != '>') { ++ while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + int type; + int def; +@@ -5751,7 +5817,7 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) { + ret = cur = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA); + if (ret == NULL) return(NULL); + } +- while (RAW == '|') { ++ while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) { + NEXT; + if (elem == NULL) { + ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR); +@@ -5895,7 +5961,7 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, + } + SKIP_BLANKS; + SHRINK; +- while (RAW != ')') { ++ while ((RAW != ')') && (ctxt->instate != XML_PARSER_EOF)) { + /* + * Each loop we parse one separator and one element. + */ +@@ -6174,6 +6240,8 @@ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, + } + NEXT; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + SKIP_BLANKS; + if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) { + tree = xmlParseElementMixedContentDecl(ctxt, inputid); +@@ -6341,8 +6409,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + ""Entering INCLUDE Conditional Section\n""); + } + +- while ((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') || +- (NXT(2) != '>'))) { ++ while (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') || ++ (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -6410,7 +6478,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + if (ctxt->recovery == 0) ctxt->disableSAX = 1; + ctxt->instate = XML_PARSER_IGNORE; + +- while ((depth >= 0) && (RAW != 0)) { ++ while (((depth >= 0) && (RAW != 0)) && ++ (ctxt->instate != XML_PARSER_EOF)) { + if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) { + depth++; + SKIP(3); +@@ -6681,7 +6750,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, + break; + } + } +- ++ + if (RAW != 0) { + xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL); + } +@@ -7127,6 +7196,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { + xmlEntityPtr ent = NULL; + + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + + if (RAW != '&') + return(NULL); +@@ -7172,6 +7243,8 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) { + ent = xmlSAX2GetEntity(ctxt, name); + } + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + /* + * [ WFC: Entity Declared ] + * In a document without any DTD, a document with only an +@@ -7362,6 +7435,10 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) { + ent = xmlSAX2GetEntity(ctxt, name); + } + } ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(name); ++ return(NULL); ++ } + + /* + * [ WFC: Entity Declared ] +@@ -7523,8 +7600,9 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) + */ + if ((ctxt->sax != NULL) && + (ctxt->sax->getParameterEntity != NULL)) +- entity = ctxt->sax->getParameterEntity(ctxt->userData, +- name); ++ entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (entity == NULL) { + /* + * [ WFC: Entity Declared ] +@@ -7657,6 +7735,10 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) { + if (count++ > 100) { + count = 0; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlBufferFree(buf); ++ return(-1); ++ } + } + NEXTL(l); + c = CUR_CHAR(l); +@@ -7748,8 +7830,11 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { + */ + if ((ctxt->sax != NULL) && + (ctxt->sax->getParameterEntity != NULL)) +- entity = ctxt->sax->getParameterEntity(ctxt->userData, +- name); ++ entity = ctxt->sax->getParameterEntity(ctxt->userData, name); ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(name); ++ return(NULL); ++ } + if (entity == NULL) { + /* + * [ WFC: Entity Declared ] +@@ -7851,6 +7936,8 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) { + if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) && + (!ctxt->disableSAX)) + ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + + /* + * Is there any internal subset declarations ? +@@ -7890,7 +7977,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) { + * PEReferences. + * Subsequence (markupdecl | PEReference | S)* + */ +- while (RAW != ']') { ++ while ((RAW != ']') && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *check = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -8076,9 +8163,9 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) { + SKIP_BLANKS; + GROW; + +- while ((RAW != '>') && ++ while (((RAW != '>') && + ((RAW != '/') || (NXT(1) != '>')) && +- (IS_BYTE_CHAR(RAW))) { ++ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *q = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + +@@ -8502,6 +8589,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8516,6 +8605,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8536,6 +8627,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8553,6 +8646,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, + if (in >= end) { + const xmlChar *oldbase = ctxt->input->base; + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(NULL); + if (oldbase != ctxt->input->base) { + long delta = ctxt->input->base - oldbase; + start = start + delta; +@@ -8784,9 +8879,9 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, + GROW; + if (ctxt->input->base != base) goto base_changed; + +- while ((RAW != '>') && ++ while (((RAW != '>') && + ((RAW != '/') || (NXT(1) != '>')) && +- (IS_BYTE_CHAR(RAW))) { ++ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) { + const xmlChar *q = CUR_PTR; + unsigned int cons = ctxt->input->consumed; + int len = -1, alloc = 0; +@@ -8957,6 +9052,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, + failed: + + GROW ++ if (ctxt->instate == XML_PARSER_EOF) ++ break; + if (ctxt->input->base != base) goto base_changed; + if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) + break; +@@ -9194,6 +9291,8 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, + * We should definitely be at the ending ""S? '>'"" part + */ + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + SKIP_BLANKS; + if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) { + xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL); +@@ -9302,6 +9401,10 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { + count++; + if (count > 50) { + GROW; ++ if (ctxt->instate == XML_PARSER_EOF) { ++ xmlFree(buf); ++ return; ++ } + count = 0; + } + NEXTL(l); +@@ -9550,6 +9653,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { + * Parse the content of the element: + */ + xmlParseContent(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return; + if (!IS_BYTE_CHAR(RAW)) { + xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED, + ""Premature end of data in tag %s line %d\n"", +@@ -10065,9 +10170,10 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) { + + void + xmlParseMisc(xmlParserCtxtPtr ctxt) { +- while (((RAW == '<') && (NXT(1) == '?')) || +- (CMP4(CUR_PTR, '<', '!', '-', '-')) || +- IS_BLANK_CH(CUR)) { ++ while ((ctxt->instate != XML_PARSER_EOF) && ++ (((RAW == '<') && (NXT(1) == '?')) || ++ (CMP4(CUR_PTR, '<', '!', '-', '-')) || ++ IS_BLANK_CH(CUR))) { + if ((RAW == '<') && (NXT(1) == '?')) { + xmlParsePI(ctxt); + } else if (IS_BLANK_CH(CUR)) { +@@ -10114,6 +10220,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + */ + if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) + ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) && + ((ctxt->input->end - ctxt->input->cur) >= 4)) { +@@ -10165,6 +10273,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + /* + * The Misc part of the Prolog +@@ -10184,6 +10294,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + xmlParseInternalSubset(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + } + + /* +@@ -10194,6 +10306,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { + (!ctxt->disableSAX)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + ctxt->inSubset = 0; + + xmlCleanSpecialAttr(ctxt); +@@ -10334,6 +10448,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { + } + if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX)) + ctxt->sax->startDocument(ctxt->userData); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + /* + * Doing validity checking on chunk doesn't make sense +@@ -10344,6 +10460,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { + ctxt->depth = 0; + + xmlParseContent(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + + if ((RAW == '<') && (NXT(1) == '/')) { + xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL); +@@ -10651,7 +10769,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + } + xmlParseGetLasts(ctxt, &lastlt, &lastgt); + +- while (1) { ++ while (ctxt->instate != XML_PARSER_EOF) { + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(0); + +@@ -10891,6 +11009,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->endElement(ctxt->userData, name); + #endif /* LIBXML_SAX1_ENABLED */ + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + spacePop(ctxt); + if (ctxt->nameNr == 0) { + ctxt->instate = XML_PARSER_EPILOG; +@@ -11072,6 +11192,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, tmp); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + SKIPL(tmp); + ctxt->checkIndex = 0; + } +@@ -11107,6 +11229,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ctxt->sax->characters(ctxt->userData, + ctxt->input->cur, base); + } ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + SKIPL(base + 3); + ctxt->checkIndex = 0; + ctxt->instate = XML_PARSER_CONTENT; +@@ -11138,6 +11262,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->checkIndex = 0; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && +@@ -11150,6 +11276,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_MISC; + ctxt->checkIndex = 0; + } else if ((cur == '<') && (next == '!') && +@@ -11169,6 +11297,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + #endif + ctxt->inSubset = 1; + xmlParseDocTypeDecl(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + if (RAW == '[') { + ctxt->instate = XML_PARSER_DTD; + #ifdef DEBUG_PUSH +@@ -11225,6 +11355,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) { + if ((!terminate) && +@@ -11235,6 +11367,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_PROLOG; + } else if ((cur == '<') && (next == '!') && + (avail < 4)) { +@@ -11269,6 +11403,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing PI\n""); + #endif + xmlParsePI(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_EPILOG; + } else if ((cur == '<') && (next == '!') && + (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) { +@@ -11280,6 +11416,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + ""PP: Parsing Comment\n""); + #endif + xmlParseComment(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_EPILOG; + } else if ((cur == '<') && (next == '!') && + (avail < 4)) { +@@ -11408,13 +11546,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { + + found_end_int_subset: + xmlParseInternalSubset(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->inSubset = 2; + if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && + (ctxt->sax->externalSubset != NULL)) + ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName, + ctxt->extSubSystem, ctxt->extSubURI); + ctxt->inSubset = 0; + xmlCleanSpecialAttr(ctxt); ++ if (ctxt->instate == XML_PARSER_EOF) ++ goto done; + ctxt->instate = XML_PARSER_PROLOG; + ctxt->checkIndex = 0; + #ifdef DEBUG_PUSH +@@ -11537,6 +11679,8 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, + return(XML_ERR_INTERNAL_ERROR); + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(ctxt->errNo); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(-1); + if (ctxt->instate == XML_PARSER_START) + xmlDetectSAX2(ctxt); + if ((size > 0) && (chunk != NULL) && (!terminate) && +@@ -11623,6 +11767,8 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, + xmlParseTryOrFinish(ctxt, 0); + else + xmlParseTryOrFinish(ctxt, terminate); ++ if (ctxt->instate == XML_PARSER_EOF) ++ return(ctxt->errNo); + if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1)) + return(ctxt->errNo); + +@@ -11816,6 +11962,7 @@ xmlStopParser(xmlParserCtxtPtr ctxt) { + if (ctxt == NULL) + return; + ctxt->instate = XML_PARSER_EOF; ++ ctxt->errNo = XML_ERR_USER_STOP; + ctxt->disableSAX = 1; + if (ctxt->input != NULL) { + ctxt->input->cur = BAD_CAST"""";",910,1146,2048 +1897,"static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx) +{ +#if ENABLE_DEBUG + int i; + + av_log(s, AV_LOG_DEBUG, ""Descriptor Block:\n\n""); + av_log(s, AV_LOG_DEBUG, ""magic = \""%c%c%c%c\""\n"", ape_ctx->magic[0], ape_ctx->magic[1], ape_ctx->magic[2], ape_ctx->magic[3]); + av_log(s, AV_LOG_DEBUG, ""fileversion = %d\n"", ape_ctx->fileversion); + av_log(s, AV_LOG_DEBUG, ""descriptorlength = %d\n"", ape_ctx->descriptorlength); + av_log(s, AV_LOG_DEBUG, ""headerlength = %d\n"", ape_ctx->headerlength); + av_log(s, AV_LOG_DEBUG, ""seektablelength = %d\n"", ape_ctx->seektablelength); + av_log(s, AV_LOG_DEBUG, ""wavheaderlength = %d\n"", ape_ctx->wavheaderlength); + av_log(s, AV_LOG_DEBUG, ""audiodatalength = %d\n"", ape_ctx->audiodatalength); + av_log(s, AV_LOG_DEBUG, ""audiodatalength_high = %d\n"", ape_ctx->audiodatalength_high); + av_log(s, AV_LOG_DEBUG, ""wavtaillength = %d\n"", ape_ctx->wavtaillength); + av_log(s, AV_LOG_DEBUG, ""md5 = ""); + for (i = 0; i < 16; i++) + av_log(s, AV_LOG_DEBUG, ""%02x"", ape_ctx->md5[i]); + av_log(s, AV_LOG_DEBUG, ""\n""); + + av_log(s, AV_LOG_DEBUG, ""\nHeader Block:\n\n""); + + av_log(s, AV_LOG_DEBUG, ""compressiontype = %d\n"", ape_ctx->compressiontype); + av_log(s, AV_LOG_DEBUG, ""formatflags = %d\n"", ape_ctx->formatflags); + av_log(s, AV_LOG_DEBUG, ""blocksperframe = %d\n"", ape_ctx->blocksperframe); + av_log(s, AV_LOG_DEBUG, ""finalframeblocks = %d\n"", ape_ctx->finalframeblocks); + av_log(s, AV_LOG_DEBUG, ""totalframes = %d\n"", ape_ctx->totalframes); + av_log(s, AV_LOG_DEBUG, ""bps = %d\n"", ape_ctx->bps); + av_log(s, AV_LOG_DEBUG, ""channels = %d\n"", ape_ctx->channels); + av_log(s, AV_LOG_DEBUG, ""samplerate = %d\n"", ape_ctx->samplerate); + + av_log(s, AV_LOG_DEBUG, ""\nSeektable\n\n""); + if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) { + av_log(s, AV_LOG_DEBUG, ""No seektable\n""); + } else { + for (i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) { + if (i < ape_ctx->totalframes - 1) { + av_log(s, AV_LOG_DEBUG, ""%8d %d (%d bytes)\n"", i, ape_ctx->seektable[i], ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]); + } else { + av_log(s, AV_LOG_DEBUG, ""%8d %d\n"", i, ape_ctx->seektable[i]); + } + } + } + + av_log(s, AV_LOG_DEBUG, ""\nFrames\n\n""); + for (i = 0; i < ape_ctx->totalframes; i++) + av_log(s, AV_LOG_DEBUG, ""%8d %8lld %8d (%d samples)\n"", i, ape_ctx->frames[i].pos, ape_ctx->frames[i].size, ape_ctx->frames[i].nblocks); + + av_log(s, AV_LOG_DEBUG, ""\nCalculated information:\n\n""); + av_log(s, AV_LOG_DEBUG, ""junklength = %d\n"", ape_ctx->junklength); + av_log(s, AV_LOG_DEBUG, ""firstframe = %d\n"", ape_ctx->firstframe); + av_log(s, AV_LOG_DEBUG, ""totalsamples = %d\n"", ape_ctx->totalsamples); +#endif +} +",0,"static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx) +{ +#if ENABLE_DEBUG + int i; + + av_log(s, AV_LOG_DEBUG, ""Descriptor Block:\n\n""); + av_log(s, AV_LOG_DEBUG, ""magic = \""%c%c%c%c\""\n"", ape_ctx->magic[0], ape_ctx->magic[1], ape_ctx->magic[2], ape_ctx->magic[3]); + av_log(s, AV_LOG_DEBUG, ""fileversion = %d\n"", ape_ctx->fileversion); + av_log(s, AV_LOG_DEBUG, ""descriptorlength = %d\n"", ape_ctx->descriptorlength); + av_log(s, AV_LOG_DEBUG, ""headerlength = %d\n"", ape_ctx->headerlength); + av_log(s, AV_LOG_DEBUG, ""seektablelength = %d\n"", ape_ctx->seektablelength); + av_log(s, AV_LOG_DEBUG, ""wavheaderlength = %d\n"", ape_ctx->wavheaderlength); + av_log(s, AV_LOG_DEBUG, ""audiodatalength = %d\n"", ape_ctx->audiodatalength); + av_log(s, AV_LOG_DEBUG, ""audiodatalength_high = %d\n"", ape_ctx->audiodatalength_high); + av_log(s, AV_LOG_DEBUG, ""wavtaillength = %d\n"", ape_ctx->wavtaillength); + av_log(s, AV_LOG_DEBUG, ""md5 = ""); + for (i = 0; i < 16; i++) + av_log(s, AV_LOG_DEBUG, ""%02x"", ape_ctx->md5[i]); + av_log(s, AV_LOG_DEBUG, ""\n""); + + av_log(s, AV_LOG_DEBUG, ""\nHeader Block:\n\n""); + + av_log(s, AV_LOG_DEBUG, ""compressiontype = %d\n"", ape_ctx->compressiontype); + av_log(s, AV_LOG_DEBUG, ""formatflags = %d\n"", ape_ctx->formatflags); + av_log(s, AV_LOG_DEBUG, ""blocksperframe = %d\n"", ape_ctx->blocksperframe); + av_log(s, AV_LOG_DEBUG, ""finalframeblocks = %d\n"", ape_ctx->finalframeblocks); + av_log(s, AV_LOG_DEBUG, ""totalframes = %d\n"", ape_ctx->totalframes); + av_log(s, AV_LOG_DEBUG, ""bps = %d\n"", ape_ctx->bps); + av_log(s, AV_LOG_DEBUG, ""channels = %d\n"", ape_ctx->channels); + av_log(s, AV_LOG_DEBUG, ""samplerate = %d\n"", ape_ctx->samplerate); + + av_log(s, AV_LOG_DEBUG, ""\nSeektable\n\n""); + if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) { + av_log(s, AV_LOG_DEBUG, ""No seektable\n""); + } else { + for (i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) { + if (i < ape_ctx->totalframes - 1) { + av_log(s, AV_LOG_DEBUG, ""%8d %d (%d bytes)\n"", i, ape_ctx->seektable[i], ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]); + } else { + av_log(s, AV_LOG_DEBUG, ""%8d %d\n"", i, ape_ctx->seektable[i]); + } + } + } + + av_log(s, AV_LOG_DEBUG, ""\nFrames\n\n""); + for (i = 0; i < ape_ctx->totalframes; i++) + av_log(s, AV_LOG_DEBUG, ""%8d %8lld %8d (%d samples)\n"", i, ape_ctx->frames[i].pos, ape_ctx->frames[i].size, ape_ctx->frames[i].nblocks); + + av_log(s, AV_LOG_DEBUG, ""\nCalculated information:\n\n""); + av_log(s, AV_LOG_DEBUG, ""junklength = %d\n"", ape_ctx->junklength); + av_log(s, AV_LOG_DEBUG, ""firstframe = %d\n"", ape_ctx->firstframe); + av_log(s, AV_LOG_DEBUG, ""totalsamples = %d\n"", ape_ctx->totalsamples); +#endif +} +","@@ -242,6 +242,10 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) + avio_seek(pb, ape->wavheaderlength, SEEK_CUR); + } + ++ if(!ape->totalframes){ ++ av_log(s, AV_LOG_ERROR, ""No frames in the file!\n""); ++ return AVERROR(EINVAL); ++ } + if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){ + av_log(s, AV_LOG_ERROR, ""Too many frames: %d\n"", ape->totalframes); + return -1;",941,1177,2048 +5221,"proto_reg_handoff_wbxml(void) +{ + dissector_handle_t wbxml_handle; + + /* Heuristic dissectors would be declared by means of: + * heur_dissector_add(""wsp"", dissect_wbxml_heur, proto_wbxml); + */ + + wbxml_handle = find_dissector(""wbxml""); + + /* Register the WSP content types (defined as protocol port) + * for WBXML dissection. + * + * See http://www.wapforum.org/wina/wsp-content-type.htm + * + * As the media types for WSP and HTTP are the same, the WSP dissector + * uses the same string dissector table as the HTTP protocol. + */ + + /**** Well-known WBXML WSP Content-Type values ****/ + + dissector_add_string(""media_type"", + ""application/vnd.wap.wmlc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.wta-eventc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.sic"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.slc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.coc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.connectivity-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.locc+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.syncml+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.syncml.dm+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.oma.drm.rights+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wv.csp.wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.ms-sync.wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.ms-sync"", wbxml_handle); + + /**** Registered WBXML WSP Content-Type values ****/ + + dissector_add_string(""media_type"", + ""application/vnd.uplanet.cacheop-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.alert-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.list-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.listcmd-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.channel-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.bearer-choice-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.phonecom.mmc-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.nokia.syncset+wbxml"", wbxml_handle); + + /***** Content types that only have a textual representation *****/ + dissector_add_string(""media_type"", + ""application/x-wap-prov.browser-bookmarks"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/x-wap-prov.browser-settings"", wbxml_handle); + /* Same as application/vnd.nokia.syncset+wbxml */ + dissector_add_string(""media_type"", + ""application/x-prov.syncset+wbxml"", wbxml_handle); +} +",0,"proto_reg_handoff_wbxml(void) +{ + dissector_handle_t wbxml_handle; + + /* Heuristic dissectors would be declared by means of: + * heur_dissector_add(""wsp"", dissect_wbxml_heur, proto_wbxml); + */ + + wbxml_handle = find_dissector(""wbxml""); + + /* Register the WSP content types (defined as protocol port) + * for WBXML dissection. + * + * See http://www.wapforum.org/wina/wsp-content-type.htm + * + * As the media types for WSP and HTTP are the same, the WSP dissector + * uses the same string dissector table as the HTTP protocol. + */ + + /**** Well-known WBXML WSP Content-Type values ****/ + + dissector_add_string(""media_type"", + ""application/vnd.wap.wmlc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.wta-eventc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.sic"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.slc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.coc"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.connectivity-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wap.locc+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.syncml+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.syncml.dm+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.oma.drm.rights+wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.wv.csp.wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.ms-sync.wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.ms-sync"", wbxml_handle); + + /**** Registered WBXML WSP Content-Type values ****/ + + dissector_add_string(""media_type"", + ""application/vnd.uplanet.cacheop-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.alert-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.list-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.listcmd-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.channel-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.uplanet.bearer-choice-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.phonecom.mmc-wbxml"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/vnd.nokia.syncset+wbxml"", wbxml_handle); + + /***** Content types that only have a textual representation *****/ + dissector_add_string(""media_type"", + ""application/x-wap-prov.browser-bookmarks"", wbxml_handle); + dissector_add_string(""media_type"", + ""application/x-wap-prov.browser-settings"", wbxml_handle); + /* Same as application/vnd.nokia.syncset+wbxml */ + dissector_add_string(""media_type"", + ""application/x-prov.syncset+wbxml"", wbxml_handle); +} +","@@ -7304,7 +7304,7 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -7323,6 +7323,7 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag_defined (level = %u, offset = %u)\n"", *level, offset)); ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); +@@ -7694,6 +7695,10 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", *level, off - offset)); + return (off - offset); +@@ -7711,7 +7716,7 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + guint8 *codepage_stag, guint8 *codepage_attr) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -7732,6 +7737,7 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag (level = %u, offset = %u)\n"", *level, offset)); ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); +@@ -8091,6 +8097,10 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", + *level, off - offset)); +@@ -8126,7 +8136,7 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -8138,6 +8148,7 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + DebugLog((""parse_wbxml_attr_defined (level = %u, offset = %u)\n"", + level, offset)); + /* Parse attributes */ ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" +@@ -8330,6 +8341,10 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + off++; + } + } ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset)); +@@ -8350,7 +8365,7 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + guint32 offset, guint32 str_tbl, guint8 level, guint8 *codepage_attr) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -8359,6 +8374,7 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + + DebugLog((""parse_wbxml_attr (level = %u, offset = %u)\n"", level, offset)); + /* Parse attributes */ ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" +@@ -8516,6 +8532,10 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + off++; + } + } ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset));",811,1047,2048 +18257,"static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait, + struct uffd_msg *msg) +{ + ssize_t ret; + DECLARE_WAITQUEUE(wait, current); + struct userfaultfd_wait_queue *uwq; + /* + * Handling fork event requires sleeping operations, so + * we drop the event_wqh lock, then do these ops, then + * lock it back and wake up the waiter. While the lock is + * dropped the ewq may go away so we keep track of it + * carefully. + */ + LIST_HEAD(fork_event); + struct userfaultfd_ctx *fork_nctx = NULL; + + /* always take the fd_wqh lock before the fault_pending_wqh lock */ + spin_lock(&ctx->fd_wqh.lock); + __add_wait_queue(&ctx->fd_wqh, &wait); + for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + spin_lock(&ctx->fault_pending_wqh.lock); + uwq = find_userfault(ctx); + if (uwq) { + /* + * Use a seqcount to repeat the lockless check + * in wake_userfault() to avoid missing + * wakeups because during the refile both + * waitqueue could become empty if this is the + * only userfault. + */ + write_seqcount_begin(&ctx->refile_seq); + + /* + * The fault_pending_wqh.lock prevents the uwq + * to disappear from under us. + * + * Refile this userfault from + * fault_pending_wqh to fault_wqh, it's not + * pending anymore after we read it. + * + * Use list_del() by hand (as + * userfaultfd_wake_function also uses + * list_del_init() by hand) to be sure nobody + * changes __remove_wait_queue() to use + * list_del_init() in turn breaking the + * !list_empty_careful() check in + * handle_userfault(). The uwq->wq.head list + * must never be empty at any time during the + * refile, or the waitqueue could disappear + * from under us. The ""wait_queue_head_t"" + * parameter of __remove_wait_queue() is unused + * anyway. + */ + list_del(&uwq->wq.entry); + __add_wait_queue(&ctx->fault_wqh, &uwq->wq); + + write_seqcount_end(&ctx->refile_seq); + + /* careful to always initialize msg if ret == 0 */ + *msg = uwq->msg; + spin_unlock(&ctx->fault_pending_wqh.lock); + ret = 0; + break; + } + spin_unlock(&ctx->fault_pending_wqh.lock); + + spin_lock(&ctx->event_wqh.lock); + uwq = find_userfault_evt(ctx); + if (uwq) { + *msg = uwq->msg; + + if (uwq->msg.event == UFFD_EVENT_FORK) { + fork_nctx = (struct userfaultfd_ctx *) + (unsigned long) + uwq->msg.arg.reserved.reserved1; + list_move(&uwq->wq.entry, &fork_event); + spin_unlock(&ctx->event_wqh.lock); + ret = 0; + break; + } + + userfaultfd_event_complete(ctx, uwq); + spin_unlock(&ctx->event_wqh.lock); + ret = 0; + break; + } + spin_unlock(&ctx->event_wqh.lock); + + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + if (no_wait) { + ret = -EAGAIN; + break; + } + spin_unlock(&ctx->fd_wqh.lock); + schedule(); + spin_lock(&ctx->fd_wqh.lock); + } + __remove_wait_queue(&ctx->fd_wqh, &wait); + __set_current_state(TASK_RUNNING); + spin_unlock(&ctx->fd_wqh.lock); + + if (!ret && msg->event == UFFD_EVENT_FORK) { + ret = resolve_userfault_fork(ctx, fork_nctx, msg); + + if (!ret) { + spin_lock(&ctx->event_wqh.lock); + if (!list_empty(&fork_event)) { + uwq = list_first_entry(&fork_event, + typeof(*uwq), + wq.entry); + list_del(&uwq->wq.entry); + __add_wait_queue(&ctx->event_wqh, &uwq->wq); + userfaultfd_event_complete(ctx, uwq); + } + spin_unlock(&ctx->event_wqh.lock); + } + } + + return ret; +} +",1,"static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait, + struct uffd_msg *msg) +{ + ssize_t ret; + DECLARE_WAITQUEUE(wait, current); + struct userfaultfd_wait_queue *uwq; + /* + * Handling fork event requires sleeping operations, so + * we drop the event_wqh lock, then do these ops, then + * lock it back and wake up the waiter. While the lock is + * dropped the ewq may go away so we keep track of it + * carefully. + */ + LIST_HEAD(fork_event); + struct userfaultfd_ctx *fork_nctx = NULL; + + /* always take the fd_wqh lock before the fault_pending_wqh lock */ + spin_lock(&ctx->fd_wqh.lock); + __add_wait_queue(&ctx->fd_wqh, &wait); + for (;;) { + set_current_state(TASK_INTERRUPTIBLE); + spin_lock(&ctx->fault_pending_wqh.lock); + uwq = find_userfault(ctx); + if (uwq) { + /* + * Use a seqcount to repeat the lockless check + * in wake_userfault() to avoid missing + * wakeups because during the refile both + * waitqueue could become empty if this is the + * only userfault. + */ + write_seqcount_begin(&ctx->refile_seq); + + /* + * The fault_pending_wqh.lock prevents the uwq + * to disappear from under us. + * + * Refile this userfault from + * fault_pending_wqh to fault_wqh, it's not + * pending anymore after we read it. + * + * Use list_del() by hand (as + * userfaultfd_wake_function also uses + * list_del_init() by hand) to be sure nobody + * changes __remove_wait_queue() to use + * list_del_init() in turn breaking the + * !list_empty_careful() check in + * handle_userfault(). The uwq->wq.head list + * must never be empty at any time during the + * refile, or the waitqueue could disappear + * from under us. The ""wait_queue_head_t"" + * parameter of __remove_wait_queue() is unused + * anyway. + */ + list_del(&uwq->wq.entry); + __add_wait_queue(&ctx->fault_wqh, &uwq->wq); + + write_seqcount_end(&ctx->refile_seq); + + /* careful to always initialize msg if ret == 0 */ + *msg = uwq->msg; + spin_unlock(&ctx->fault_pending_wqh.lock); + ret = 0; + break; + } + spin_unlock(&ctx->fault_pending_wqh.lock); + + spin_lock(&ctx->event_wqh.lock); + uwq = find_userfault_evt(ctx); + if (uwq) { + *msg = uwq->msg; + + if (uwq->msg.event == UFFD_EVENT_FORK) { + fork_nctx = (struct userfaultfd_ctx *) + (unsigned long) + uwq->msg.arg.reserved.reserved1; + list_move(&uwq->wq.entry, &fork_event); + /* + * fork_nctx can be freed as soon as + * we drop the lock, unless we take a + * reference on it. + */ + userfaultfd_ctx_get(fork_nctx); + spin_unlock(&ctx->event_wqh.lock); + ret = 0; + break; + } + + userfaultfd_event_complete(ctx, uwq); + spin_unlock(&ctx->event_wqh.lock); + ret = 0; + break; + } + spin_unlock(&ctx->event_wqh.lock); + + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + if (no_wait) { + ret = -EAGAIN; + break; + } + spin_unlock(&ctx->fd_wqh.lock); + schedule(); + spin_lock(&ctx->fd_wqh.lock); + } + __remove_wait_queue(&ctx->fd_wqh, &wait); + __set_current_state(TASK_RUNNING); + spin_unlock(&ctx->fd_wqh.lock); + + if (!ret && msg->event == UFFD_EVENT_FORK) { + ret = resolve_userfault_fork(ctx, fork_nctx, msg); + spin_lock(&ctx->event_wqh.lock); + if (!list_empty(&fork_event)) { + /* + * The fork thread didn't abort, so we can + * drop the temporary refcount. + */ + userfaultfd_ctx_put(fork_nctx); + + uwq = list_first_entry(&fork_event, + typeof(*uwq), + wq.entry); + /* + * If fork_event list wasn't empty and in turn + * the event wasn't already released by fork + * (the event is allocated on fork kernel + * stack), put the event back to its place in + * the event_wq. fork_event head will be freed + * as soon as we return so the event cannot + * stay queued there no matter the current + * ""ret"" value. + */ + list_del(&uwq->wq.entry); + __add_wait_queue(&ctx->event_wqh, &uwq->wq); + + /* + * Leave the event in the waitqueue and report + * error to userland if we failed to resolve + * the userfault fork. + */ + if (likely(!ret)) + userfaultfd_event_complete(ctx, uwq); + } else { + /* + * Here the fork thread aborted and the + * refcount from the fork thread on fork_nctx + * has already been released. We still hold + * the reference we took before releasing the + * lock above. If resolve_userfault_fork + * failed we've to drop it because the + * fork_nctx has to be freed in such case. If + * it succeeded we'll hold it because the new + * uffd references it. + */ + if (ret) + userfaultfd_ctx_put(fork_nctx); + } + spin_unlock(&ctx->event_wqh.lock); + } + + return ret; +} +","@@ -588,6 +588,12 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, + break; + if (ACCESS_ONCE(ctx->released) || + fatal_signal_pending(current)) { ++ /* ++ * &ewq->wq may be queued in fork_event, but ++ * __remove_wait_queue ignores the head ++ * parameter. It would be a problem if it ++ * didn't. ++ */ + __remove_wait_queue(&ctx->event_wqh, &ewq->wq); + if (ewq->msg.event == UFFD_EVENT_FORK) { + struct userfaultfd_ctx *new; +@@ -1061,6 +1067,12 @@ static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait, + (unsigned long) + uwq->msg.arg.reserved.reserved1; + list_move(&uwq->wq.entry, &fork_event); ++ /* ++ * fork_nctx can be freed as soon as ++ * we drop the lock, unless we take a ++ * reference on it. ++ */ ++ userfaultfd_ctx_get(fork_nctx); + spin_unlock(&ctx->event_wqh.lock); + ret = 0; + break; +@@ -1091,19 +1103,53 @@ static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait, + + if (!ret && msg->event == UFFD_EVENT_FORK) { + ret = resolve_userfault_fork(ctx, fork_nctx, msg); ++ spin_lock(&ctx->event_wqh.lock); ++ if (!list_empty(&fork_event)) { ++ /* ++ * The fork thread didn't abort, so we can ++ * drop the temporary refcount. ++ */ ++ userfaultfd_ctx_put(fork_nctx); ++ ++ uwq = list_first_entry(&fork_event, ++ typeof(*uwq), ++ wq.entry); ++ /* ++ * If fork_event list wasn't empty and in turn ++ * the event wasn't already released by fork ++ * (the event is allocated on fork kernel ++ * stack), put the event back to its place in ++ * the event_wq. fork_event head will be freed ++ * as soon as we return so the event cannot ++ * stay queued there no matter the current ++ * ""ret"" value. ++ */ ++ list_del(&uwq->wq.entry); ++ __add_wait_queue(&ctx->event_wqh, &uwq->wq); + +- if (!ret) { +- spin_lock(&ctx->event_wqh.lock); +- if (!list_empty(&fork_event)) { +- uwq = list_first_entry(&fork_event, +- typeof(*uwq), +- wq.entry); +- list_del(&uwq->wq.entry); +- __add_wait_queue(&ctx->event_wqh, &uwq->wq); ++ /* ++ * Leave the event in the waitqueue and report ++ * error to userland if we failed to resolve ++ * the userfault fork. ++ */ ++ if (likely(!ret)) + userfaultfd_event_complete(ctx, uwq); +- } +- spin_unlock(&ctx->event_wqh.lock); ++ } else { ++ /* ++ * Here the fork thread aborted and the ++ * refcount from the fork thread on fork_nctx ++ * has already been released. We still hold ++ * the reference we took before releasing the ++ * lock above. If resolve_userfault_fork ++ * failed we've to drop it because the ++ * fork_nctx has to be freed in such case. If ++ * it succeeded we'll hold it because the new ++ * uffd references it. ++ */ ++ if (ret) ++ userfaultfd_ctx_put(fork_nctx); + } ++ spin_unlock(&ctx->event_wqh.lock); + } + + return ret;",1025,1261,2048 +18784,"void SoftVPXEncoder::onQueueFilled(OMX_U32 /* portIndex */) { + if (mCodecContext == NULL) { + if (OK != initEncoder()) { + ALOGE(""Failed to initialize encoder""); + notify(OMX_EventError, + OMX_ErrorUndefined, + 0, // Extra notification data + NULL); // Notification data pointer + return; + } + } + + vpx_codec_err_t codec_return; + List &inputBufferInfoQueue = getPortQueue(kInputPortIndex); + List &outputBufferInfoQueue = getPortQueue(kOutputPortIndex); + + while (!inputBufferInfoQueue.empty() && !outputBufferInfoQueue.empty()) { + BufferInfo *inputBufferInfo = *inputBufferInfoQueue.begin(); + OMX_BUFFERHEADERTYPE *inputBufferHeader = inputBufferInfo->mHeader; + + BufferInfo *outputBufferInfo = *outputBufferInfoQueue.begin(); + OMX_BUFFERHEADERTYPE *outputBufferHeader = outputBufferInfo->mHeader; + + if ((inputBufferHeader->nFlags & OMX_BUFFERFLAG_EOS) && + inputBufferHeader->nFilledLen == 0) { + inputBufferInfoQueue.erase(inputBufferInfoQueue.begin()); + inputBufferInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inputBufferHeader); + + outputBufferHeader->nFilledLen = 0; + outputBufferHeader->nFlags = OMX_BUFFERFLAG_EOS; + + outputBufferInfoQueue.erase(outputBufferInfoQueue.begin()); + outputBufferInfo->mOwnedByUs = false; + notifyFillBufferDone(outputBufferHeader); + return; + } + + + const uint8_t *source = + inputBufferHeader->pBuffer + inputBufferHeader->nOffset; + + if (mInputDataIsMeta) { + source = extractGraphicBuffer( + mConversionBuffer, mWidth * mHeight * 3 / 2, + source, inputBufferHeader->nFilledLen, + mWidth, mHeight); + if (source == NULL) { + ALOGE(""Unable to extract gralloc buffer in metadata mode""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); + return; + } + } else if (mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { + ConvertYUV420SemiPlanarToYUV420Planar( + source, mConversionBuffer, mWidth, mHeight); + + source = mConversionBuffer; + } + vpx_image_t raw_frame; + vpx_img_wrap(&raw_frame, VPX_IMG_FMT_I420, mWidth, mHeight, + kInputBufferAlignment, (uint8_t *)source); + + vpx_enc_frame_flags_t flags = 0; + if (mTemporalPatternLength > 0) { + flags = getEncodeFlags(); + } + if (mKeyFrameRequested) { + flags |= VPX_EFLAG_FORCE_KF; + mKeyFrameRequested = false; + } + + if (mBitrateUpdated) { + mCodecConfiguration->rc_target_bitrate = mBitrate/1000; + vpx_codec_err_t res = vpx_codec_enc_config_set(mCodecContext, + mCodecConfiguration); + if (res != VPX_CODEC_OK) { + ALOGE(""vp8 encoder failed to update bitrate: %s"", + vpx_codec_err_to_string(res)); + notify(OMX_EventError, + OMX_ErrorUndefined, + 0, // Extra notification data + NULL); // Notification data pointer + } + mBitrateUpdated = false; + } + + uint32_t frameDuration; + if (inputBufferHeader->nTimeStamp > mLastTimestamp) { + frameDuration = (uint32_t)(inputBufferHeader->nTimeStamp - mLastTimestamp); + } else { + frameDuration = (uint32_t)(((uint64_t)1000000 << 16) / mFramerate); + } + mLastTimestamp = inputBufferHeader->nTimeStamp; + codec_return = vpx_codec_encode( + mCodecContext, + &raw_frame, + inputBufferHeader->nTimeStamp, // in timebase units + frameDuration, // frame duration in timebase units + flags, // frame flags + VPX_DL_REALTIME); // encoding deadline + if (codec_return != VPX_CODEC_OK) { + ALOGE(""vpx encoder failed to encode frame""); + notify(OMX_EventError, + OMX_ErrorUndefined, + 0, // Extra notification data + NULL); // Notification data pointer + return; + } + + vpx_codec_iter_t encoded_packet_iterator = NULL; + const vpx_codec_cx_pkt_t* encoded_packet; + + while ((encoded_packet = vpx_codec_get_cx_data( + mCodecContext, &encoded_packet_iterator))) { + if (encoded_packet->kind == VPX_CODEC_CX_FRAME_PKT) { + + outputBufferHeader->nTimeStamp = encoded_packet->data.frame.pts; + outputBufferHeader->nFlags = 0; + if (encoded_packet->data.frame.flags & VPX_FRAME_IS_KEY) + outputBufferHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; + outputBufferHeader->nOffset = 0; + outputBufferHeader->nFilledLen = encoded_packet->data.frame.sz; + memcpy(outputBufferHeader->pBuffer, + encoded_packet->data.frame.buf, + encoded_packet->data.frame.sz); + outputBufferInfo->mOwnedByUs = false; + outputBufferInfoQueue.erase(outputBufferInfoQueue.begin()); + if (inputBufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { + outputBufferHeader->nFlags |= OMX_BUFFERFLAG_EOS; + } + notifyFillBufferDone(outputBufferHeader); + } + } + + inputBufferInfo->mOwnedByUs = false; + inputBufferInfoQueue.erase(inputBufferInfoQueue.begin()); + notifyEmptyBufferDone(inputBufferHeader); + } +} +",1,"void SoftVPXEncoder::onQueueFilled(OMX_U32 /* portIndex */) { + if (mCodecContext == NULL) { + if (OK != initEncoder()) { + ALOGE(""Failed to initialize encoder""); + notify(OMX_EventError, + OMX_ErrorUndefined, + 0, // Extra notification data + NULL); // Notification data pointer + return; + } + } + + vpx_codec_err_t codec_return; + List &inputBufferInfoQueue = getPortQueue(kInputPortIndex); + List &outputBufferInfoQueue = getPortQueue(kOutputPortIndex); + + while (!inputBufferInfoQueue.empty() && !outputBufferInfoQueue.empty()) { + BufferInfo *inputBufferInfo = *inputBufferInfoQueue.begin(); + OMX_BUFFERHEADERTYPE *inputBufferHeader = inputBufferInfo->mHeader; + + BufferInfo *outputBufferInfo = *outputBufferInfoQueue.begin(); + OMX_BUFFERHEADERTYPE *outputBufferHeader = outputBufferInfo->mHeader; + + if ((inputBufferHeader->nFlags & OMX_BUFFERFLAG_EOS) && + inputBufferHeader->nFilledLen == 0) { + inputBufferInfoQueue.erase(inputBufferInfoQueue.begin()); + inputBufferInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inputBufferHeader); + + outputBufferHeader->nFilledLen = 0; + outputBufferHeader->nFlags = OMX_BUFFERFLAG_EOS; + + outputBufferInfoQueue.erase(outputBufferInfoQueue.begin()); + outputBufferInfo->mOwnedByUs = false; + notifyFillBufferDone(outputBufferHeader); + return; + } + + + const uint8_t *source = + inputBufferHeader->pBuffer + inputBufferHeader->nOffset; + + size_t frameSize = mWidth * mHeight * 3 / 2; + if (mInputDataIsMeta) { + source = extractGraphicBuffer( + mConversionBuffer, frameSize, + source, inputBufferHeader->nFilledLen, + mWidth, mHeight); + if (source == NULL) { + ALOGE(""Unable to extract gralloc buffer in metadata mode""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); + return; + } + } else { + if (inputBufferHeader->nFilledLen < frameSize) { + android_errorWriteLog(0x534e4554, ""27569635""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); + return; + } else if (inputBufferHeader->nFilledLen > frameSize) { + ALOGW(""Input buffer contains too many pixels""); + } + + if (mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { + ConvertYUV420SemiPlanarToYUV420Planar( + source, mConversionBuffer, mWidth, mHeight); + + source = mConversionBuffer; + } + } + vpx_image_t raw_frame; + vpx_img_wrap(&raw_frame, VPX_IMG_FMT_I420, mWidth, mHeight, + kInputBufferAlignment, (uint8_t *)source); + + vpx_enc_frame_flags_t flags = 0; + if (mTemporalPatternLength > 0) { + flags = getEncodeFlags(); + } + if (mKeyFrameRequested) { + flags |= VPX_EFLAG_FORCE_KF; + mKeyFrameRequested = false; + } + + if (mBitrateUpdated) { + mCodecConfiguration->rc_target_bitrate = mBitrate/1000; + vpx_codec_err_t res = vpx_codec_enc_config_set(mCodecContext, + mCodecConfiguration); + if (res != VPX_CODEC_OK) { + ALOGE(""vp8 encoder failed to update bitrate: %s"", + vpx_codec_err_to_string(res)); + notify(OMX_EventError, + OMX_ErrorUndefined, + 0, // Extra notification data + NULL); // Notification data pointer + } + mBitrateUpdated = false; + } + + uint32_t frameDuration; + if (inputBufferHeader->nTimeStamp > mLastTimestamp) { + frameDuration = (uint32_t)(inputBufferHeader->nTimeStamp - mLastTimestamp); + } else { + frameDuration = (uint32_t)(((uint64_t)1000000 << 16) / mFramerate); + } + mLastTimestamp = inputBufferHeader->nTimeStamp; + codec_return = vpx_codec_encode( + mCodecContext, + &raw_frame, + inputBufferHeader->nTimeStamp, // in timebase units + frameDuration, // frame duration in timebase units + flags, // frame flags + VPX_DL_REALTIME); // encoding deadline + if (codec_return != VPX_CODEC_OK) { + ALOGE(""vpx encoder failed to encode frame""); + notify(OMX_EventError, + OMX_ErrorUndefined, + 0, // Extra notification data + NULL); // Notification data pointer + return; + } + + vpx_codec_iter_t encoded_packet_iterator = NULL; + const vpx_codec_cx_pkt_t* encoded_packet; + + while ((encoded_packet = vpx_codec_get_cx_data( + mCodecContext, &encoded_packet_iterator))) { + if (encoded_packet->kind == VPX_CODEC_CX_FRAME_PKT) { + + outputBufferHeader->nTimeStamp = encoded_packet->data.frame.pts; + outputBufferHeader->nFlags = 0; + if (encoded_packet->data.frame.flags & VPX_FRAME_IS_KEY) + outputBufferHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; + outputBufferHeader->nOffset = 0; + outputBufferHeader->nFilledLen = encoded_packet->data.frame.sz; + if (outputBufferHeader->nFilledLen > outputBufferHeader->nAllocLen) { + android_errorWriteLog(0x534e4554, ""27569635""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); + return; + } + memcpy(outputBufferHeader->pBuffer, + encoded_packet->data.frame.buf, + encoded_packet->data.frame.sz); + outputBufferInfo->mOwnedByUs = false; + outputBufferInfoQueue.erase(outputBufferInfoQueue.begin()); + if (inputBufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { + outputBufferHeader->nFlags |= OMX_BUFFERFLAG_EOS; + } + notifyFillBufferDone(outputBufferHeader); + } + } + + inputBufferInfo->mOwnedByUs = false; + inputBufferInfoQueue.erase(inputBufferInfoQueue.begin()); + notifyEmptyBufferDone(inputBufferHeader); + } +} +","@@ -688,9 +688,10 @@ + + const uint8_t *source = + inputBufferHeader->pBuffer + inputBufferHeader->nOffset; + ++ size_t frameSize = mWidth * mHeight * 3 / 2; + if (mInputDataIsMeta) { + source = extractGraphicBuffer( +- mConversionBuffer, mWidth * mHeight * 3 / 2, ++ mConversionBuffer, frameSize, + source, inputBufferHeader->nFilledLen, + mWidth, mHeight); + if (source == NULL) { +@@ -698,11 +699,21 @@ + + notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); + return; + } +- } else if (mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { +- ConvertYUV420SemiPlanarToYUV420Planar( +- source, mConversionBuffer, mWidth, mHeight); ++ } else { ++ if (inputBufferHeader->nFilledLen < frameSize) { ++ android_errorWriteLog(0x534e4554, ""27569635""); ++ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); ++ return; ++ } else if (inputBufferHeader->nFilledLen > frameSize) { ++ ALOGW(""Input buffer contains too many pixels""); ++ } + +- source = mConversionBuffer; ++ if (mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { ++ ConvertYUV420SemiPlanarToYUV420Planar( ++ source, mConversionBuffer, mWidth, mHeight); ++ ++ source = mConversionBuffer; ++ } + } + vpx_image_t raw_frame; + vpx_img_wrap(&raw_frame, VPX_IMG_FMT_I420, mWidth, mHeight, +@@ -764,9 +775,14 @@ + + outputBufferHeader->nTimeStamp = encoded_packet->data.frame.pts; + outputBufferHeader->nFlags = 0; + if (encoded_packet->data.frame.flags & VPX_FRAME_IS_KEY) +- outputBufferHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; ++ outputBufferHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; + outputBufferHeader->nOffset = 0; + outputBufferHeader->nFilledLen = encoded_packet->data.frame.sz; ++ if (outputBufferHeader->nFilledLen > outputBufferHeader->nAllocLen) { ++ android_errorWriteLog(0x534e4554, ""27569635""); ++ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0); ++ return; ++ } + memcpy(outputBufferHeader->pBuffer, + encoded_packet->data.frame.buf, + encoded_packet->data.frame.sz); +",1225,1461,2048 +5847,"static int __sched_setscheduler(struct task_struct *p, + const struct sched_attr *attr, + bool user) +{ + int retval, oldprio, oldpolicy = -1, on_rq, running; + int policy = attr->sched_policy; + unsigned long flags; + const struct sched_class *prev_class; + struct rq *rq; + int reset_on_fork; + + /* may grab non-irq protected spin_locks */ + BUG_ON(in_interrupt()); +recheck: + /* double check policy once rq lock held */ + if (policy < 0) { + reset_on_fork = p->sched_reset_on_fork; + policy = oldpolicy = p->policy; + } else { + reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK); + + if (policy != SCHED_DEADLINE && + policy != SCHED_FIFO && policy != SCHED_RR && + policy != SCHED_NORMAL && policy != SCHED_BATCH && + policy != SCHED_IDLE) + return -EINVAL; + } + + if (attr->sched_flags & ~(SCHED_FLAG_RESET_ON_FORK)) + return -EINVAL; + + /* + * Valid priorities for SCHED_FIFO and SCHED_RR are + * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL, + * SCHED_BATCH and SCHED_IDLE is 0. + */ + if ((p->mm && attr->sched_priority > MAX_USER_RT_PRIO-1) || + (!p->mm && attr->sched_priority > MAX_RT_PRIO-1)) + return -EINVAL; + if ((dl_policy(policy) && !__checkparam_dl(attr)) || + (rt_policy(policy) != (attr->sched_priority != 0))) + return -EINVAL; + + /* + * Allow unprivileged RT tasks to decrease priority: + */ + if (user && !capable(CAP_SYS_NICE)) { + if (fair_policy(policy)) { + if (attr->sched_nice < TASK_NICE(p) && + !can_nice(p, attr->sched_nice)) + return -EPERM; + } + + if (rt_policy(policy)) { + unsigned long rlim_rtprio = + task_rlimit(p, RLIMIT_RTPRIO); + + /* can't set/change the rt policy */ + if (policy != p->policy && !rlim_rtprio) + return -EPERM; + + /* can't increase priority */ + if (attr->sched_priority > p->rt_priority && + attr->sched_priority > rlim_rtprio) + return -EPERM; + } + + /* + * Treat SCHED_IDLE as nice 20. Only allow a switch to + * SCHED_NORMAL if the RLIMIT_NICE would normally permit it. + */ + if (p->policy == SCHED_IDLE && policy != SCHED_IDLE) { + if (!can_nice(p, TASK_NICE(p))) + return -EPERM; + } + + /* can't change other user's priorities */ + if (!check_same_owner(p)) + return -EPERM; + + /* Normal users shall not reset the sched_reset_on_fork flag */ + if (p->sched_reset_on_fork && !reset_on_fork) + return -EPERM; + } + + if (user) { + retval = security_task_setscheduler(p); + if (retval) + return retval; + } + + /* + * make sure no PI-waiters arrive (or leave) while we are + * changing the priority of the task: + * + * To be able to change p->policy safely, the appropriate + * runqueue lock must be held. + */ + rq = task_rq_lock(p, &flags); + + /* + * Changing the policy of the stop threads its a very bad idea + */ + if (p == rq->stop) { + task_rq_unlock(rq, p, &flags); + return -EINVAL; + } + + /* + * If not changing anything there's no need to proceed further: + */ + if (unlikely(policy == p->policy)) { + if (fair_policy(policy) && attr->sched_nice != TASK_NICE(p)) + goto change; + if (rt_policy(policy) && attr->sched_priority != p->rt_priority) + goto change; + if (dl_policy(policy)) + goto change; + + task_rq_unlock(rq, p, &flags); + return 0; + } +change: + + if (user) { +#ifdef CONFIG_RT_GROUP_SCHED + /* + * Do not allow realtime tasks into groups that have no runtime + * assigned. + */ + if (rt_bandwidth_enabled() && rt_policy(policy) && + task_group(p)->rt_bandwidth.rt_runtime == 0 && + !task_group_is_autogroup(task_group(p))) { + task_rq_unlock(rq, p, &flags); + return -EPERM; + } +#endif +#ifdef CONFIG_SMP + if (dl_bandwidth_enabled() && dl_policy(policy)) { + cpumask_t *span = rq->rd->span; + + /* + * Don't allow tasks with an affinity mask smaller than + * the entire root_domain to become SCHED_DEADLINE. We + * will also fail if there's no bandwidth available. + */ + if (!cpumask_subset(span, &p->cpus_allowed) || + rq->rd->dl_bw.bw == 0) { + task_rq_unlock(rq, p, &flags); + return -EPERM; + } + } +#endif + } + + /* recheck policy now with rq lock held */ + if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) { + policy = oldpolicy = -1; + task_rq_unlock(rq, p, &flags); + goto recheck; + } + + /* + * If setscheduling to SCHED_DEADLINE (or changing the parameters + * of a SCHED_DEADLINE task) we need to check if enough bandwidth + * is available. + */ + if ((dl_policy(policy) || dl_task(p)) && dl_overflow(p, policy, attr)) { + task_rq_unlock(rq, p, &flags); + return -EBUSY; + } + + on_rq = p->on_rq; + running = task_current(rq, p); + if (on_rq) + dequeue_task(rq, p, 0); + if (running) + p->sched_class->put_prev_task(rq, p); + + p->sched_reset_on_fork = reset_on_fork; + + oldprio = p->prio; + prev_class = p->sched_class; + __setscheduler(rq, p, attr); + + if (running) + p->sched_class->set_curr_task(rq); + if (on_rq) + enqueue_task(rq, p, 0); + + check_class_changed(rq, p, prev_class, oldprio); + task_rq_unlock(rq, p, &flags); + + rt_mutex_adjust_pi(p); + + return 0; +} +",0,"static int __sched_setscheduler(struct task_struct *p, + const struct sched_attr *attr, + bool user) +{ + int retval, oldprio, oldpolicy = -1, on_rq, running; + int policy = attr->sched_policy; + unsigned long flags; + const struct sched_class *prev_class; + struct rq *rq; + int reset_on_fork; + + /* may grab non-irq protected spin_locks */ + BUG_ON(in_interrupt()); +recheck: + /* double check policy once rq lock held */ + if (policy < 0) { + reset_on_fork = p->sched_reset_on_fork; + policy = oldpolicy = p->policy; + } else { + reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK); + + if (policy != SCHED_DEADLINE && + policy != SCHED_FIFO && policy != SCHED_RR && + policy != SCHED_NORMAL && policy != SCHED_BATCH && + policy != SCHED_IDLE) + return -EINVAL; + } + + if (attr->sched_flags & ~(SCHED_FLAG_RESET_ON_FORK)) + return -EINVAL; + + /* + * Valid priorities for SCHED_FIFO and SCHED_RR are + * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL, + * SCHED_BATCH and SCHED_IDLE is 0. + */ + if ((p->mm && attr->sched_priority > MAX_USER_RT_PRIO-1) || + (!p->mm && attr->sched_priority > MAX_RT_PRIO-1)) + return -EINVAL; + if ((dl_policy(policy) && !__checkparam_dl(attr)) || + (rt_policy(policy) != (attr->sched_priority != 0))) + return -EINVAL; + + /* + * Allow unprivileged RT tasks to decrease priority: + */ + if (user && !capable(CAP_SYS_NICE)) { + if (fair_policy(policy)) { + if (attr->sched_nice < TASK_NICE(p) && + !can_nice(p, attr->sched_nice)) + return -EPERM; + } + + if (rt_policy(policy)) { + unsigned long rlim_rtprio = + task_rlimit(p, RLIMIT_RTPRIO); + + /* can't set/change the rt policy */ + if (policy != p->policy && !rlim_rtprio) + return -EPERM; + + /* can't increase priority */ + if (attr->sched_priority > p->rt_priority && + attr->sched_priority > rlim_rtprio) + return -EPERM; + } + + /* + * Treat SCHED_IDLE as nice 20. Only allow a switch to + * SCHED_NORMAL if the RLIMIT_NICE would normally permit it. + */ + if (p->policy == SCHED_IDLE && policy != SCHED_IDLE) { + if (!can_nice(p, TASK_NICE(p))) + return -EPERM; + } + + /* can't change other user's priorities */ + if (!check_same_owner(p)) + return -EPERM; + + /* Normal users shall not reset the sched_reset_on_fork flag */ + if (p->sched_reset_on_fork && !reset_on_fork) + return -EPERM; + } + + if (user) { + retval = security_task_setscheduler(p); + if (retval) + return retval; + } + + /* + * make sure no PI-waiters arrive (or leave) while we are + * changing the priority of the task: + * + * To be able to change p->policy safely, the appropriate + * runqueue lock must be held. + */ + rq = task_rq_lock(p, &flags); + + /* + * Changing the policy of the stop threads its a very bad idea + */ + if (p == rq->stop) { + task_rq_unlock(rq, p, &flags); + return -EINVAL; + } + + /* + * If not changing anything there's no need to proceed further: + */ + if (unlikely(policy == p->policy)) { + if (fair_policy(policy) && attr->sched_nice != TASK_NICE(p)) + goto change; + if (rt_policy(policy) && attr->sched_priority != p->rt_priority) + goto change; + if (dl_policy(policy)) + goto change; + + task_rq_unlock(rq, p, &flags); + return 0; + } +change: + + if (user) { +#ifdef CONFIG_RT_GROUP_SCHED + /* + * Do not allow realtime tasks into groups that have no runtime + * assigned. + */ + if (rt_bandwidth_enabled() && rt_policy(policy) && + task_group(p)->rt_bandwidth.rt_runtime == 0 && + !task_group_is_autogroup(task_group(p))) { + task_rq_unlock(rq, p, &flags); + return -EPERM; + } +#endif +#ifdef CONFIG_SMP + if (dl_bandwidth_enabled() && dl_policy(policy)) { + cpumask_t *span = rq->rd->span; + + /* + * Don't allow tasks with an affinity mask smaller than + * the entire root_domain to become SCHED_DEADLINE. We + * will also fail if there's no bandwidth available. + */ + if (!cpumask_subset(span, &p->cpus_allowed) || + rq->rd->dl_bw.bw == 0) { + task_rq_unlock(rq, p, &flags); + return -EPERM; + } + } +#endif + } + + /* recheck policy now with rq lock held */ + if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) { + policy = oldpolicy = -1; + task_rq_unlock(rq, p, &flags); + goto recheck; + } + + /* + * If setscheduling to SCHED_DEADLINE (or changing the parameters + * of a SCHED_DEADLINE task) we need to check if enough bandwidth + * is available. + */ + if ((dl_policy(policy) || dl_task(p)) && dl_overflow(p, policy, attr)) { + task_rq_unlock(rq, p, &flags); + return -EBUSY; + } + + on_rq = p->on_rq; + running = task_current(rq, p); + if (on_rq) + dequeue_task(rq, p, 0); + if (running) + p->sched_class->put_prev_task(rq, p); + + p->sched_reset_on_fork = reset_on_fork; + + oldprio = p->prio; + prev_class = p->sched_class; + __setscheduler(rq, p, attr); + + if (running) + p->sched_class->set_curr_task(rq); + if (on_rq) + enqueue_task(rq, p, 0); + + check_class_changed(rq, p, prev_class, oldprio); + task_rq_unlock(rq, p, &flags); + + rt_mutex_adjust_pi(p); + + return 0; +} +","@@ -3786,7 +3786,7 @@ static int sched_read_attr(struct sched_attr __user *uattr, + attr->size = usize; + } + +- ret = copy_to_user(uattr, attr, usize); ++ ret = copy_to_user(uattr, attr, attr->size); + if (ret) + return -EFAULT; + ",1480,1716,2048 +14883,"RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( + const GURL& dest_url, + SiteInstance* source_instance, + SiteInstance* dest_instance, + ui::PageTransition transition, + bool dest_is_restore, + bool dest_is_view_source_mode, + const GlobalRequestID& transferred_request_id, + int bindings, + bool is_reload) { + SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); + bool was_server_redirect = transfer_navigation_handle_ && + transfer_navigation_handle_->WasServerRedirect(); + scoped_refptr new_instance = GetSiteInstanceForNavigation( + dest_url, source_instance, dest_instance, nullptr, transition, + dest_is_restore, dest_is_view_source_mode, was_server_redirect); + + bool allowed_to_swap_process = + frame_tree_node_->IsMainFrame() || + CanSubframeSwapProcess(dest_url, source_instance, dest_instance, + was_server_redirect); + + if (transfer_navigation_handle_.get() && + transfer_navigation_handle_->GetGlobalRequestID() == + transferred_request_id) { + RenderFrameHostImpl* transferring_rfh = + transfer_navigation_handle_->GetRenderFrameHost(); + bool transfer_started_from_current_rfh = + transferring_rfh == render_frame_host_.get(); + bool should_transfer = + new_instance.get() != transferring_rfh->GetSiteInstance() && + (!transfer_started_from_current_rfh || allowed_to_swap_process); + if (should_transfer) + transfer_navigation_handle_->Transfer(); + } + + if (pending_render_frame_host_) { + if (pending_render_frame_host_->GetSiteInstance() != new_instance) { + CancelPending(); + } else { + CHECK(pending_render_frame_host_->IsRenderFrameLive()); + } + } + + if (new_instance.get() != current_instance && allowed_to_swap_process) { + TRACE_EVENT_INSTANT2( + ""navigation"", + ""RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance"", + TRACE_EVENT_SCOPE_THREAD, + ""current_instance id"", current_instance->GetId(), + ""new_instance id"", new_instance->GetId()); + + + if (!pending_render_frame_host_) + CreatePendingRenderFrameHost(current_instance, new_instance.get()); + DCHECK(pending_render_frame_host_); + if (!pending_render_frame_host_) + return nullptr; + DCHECK_EQ(new_instance, pending_render_frame_host_->GetSiteInstance()); + + pending_render_frame_host_->UpdatePendingWebUI(dest_url, bindings); + pending_render_frame_host_->CommitPendingWebUI(); + DCHECK_EQ(GetNavigatingWebUI(), pending_render_frame_host_->web_ui()); + + if (pending_render_frame_host_->web_ui()) { + pending_render_frame_host_->web_ui()->RenderFrameCreated( + pending_render_frame_host_.get()); + } + + if (!render_frame_host_->IsRenderFrameLive()) { + if (GetRenderFrameProxyHost(new_instance.get())) { + pending_render_frame_host_->Send( + new FrameMsg_SwapIn(pending_render_frame_host_->GetRoutingID())); + } + CommitPending(); + return render_frame_host_.get(); + } + + bool is_transfer = transferred_request_id != GlobalRequestID(); + if (is_transfer) { + DCHECK(transfer_navigation_handle_ && + transfer_navigation_handle_->GetGlobalRequestID() == + transferred_request_id); + } else if (!pending_render_frame_host_->are_navigations_suspended()) { + render_frame_host_->Send(new FrameMsg_Stop( + render_frame_host_->GetRoutingID())); + pending_render_frame_host_->SetNavigationsSuspended(true, + base::TimeTicks()); + render_frame_host_->DispatchBeforeUnload(true, is_reload); + } + + return pending_render_frame_host_.get(); + } + + + DeleteRenderFrameProxyHost(new_instance.get()); + + UpdatePendingWebUIOnCurrentFrameHost(dest_url, bindings); + + if (dest_is_view_source_mode) { + DCHECK(!render_frame_host_->GetParent()); + render_frame_host_->Send( + new FrameMsg_EnableViewSourceMode(render_frame_host_->GetRoutingID())); + } + + return render_frame_host_.get(); +} +",0,"RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( + const GURL& dest_url, + SiteInstance* source_instance, + SiteInstance* dest_instance, + ui::PageTransition transition, + bool dest_is_restore, + bool dest_is_view_source_mode, + const GlobalRequestID& transferred_request_id, + int bindings, + bool is_reload) { + SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); + bool was_server_redirect = transfer_navigation_handle_ && + transfer_navigation_handle_->WasServerRedirect(); + scoped_refptr new_instance = GetSiteInstanceForNavigation( + dest_url, source_instance, dest_instance, nullptr, transition, + dest_is_restore, dest_is_view_source_mode, was_server_redirect); + + bool allowed_to_swap_process = + frame_tree_node_->IsMainFrame() || + CanSubframeSwapProcess(dest_url, source_instance, dest_instance, + was_server_redirect); + + if (transfer_navigation_handle_.get() && + transfer_navigation_handle_->GetGlobalRequestID() == + transferred_request_id) { + RenderFrameHostImpl* transferring_rfh = + transfer_navigation_handle_->GetRenderFrameHost(); + bool transfer_started_from_current_rfh = + transferring_rfh == render_frame_host_.get(); + bool should_transfer = + new_instance.get() != transferring_rfh->GetSiteInstance() && + (!transfer_started_from_current_rfh || allowed_to_swap_process); + if (should_transfer) + transfer_navigation_handle_->Transfer(); + } + + if (pending_render_frame_host_) { + if (pending_render_frame_host_->GetSiteInstance() != new_instance) { + CancelPending(); + } else { + CHECK(pending_render_frame_host_->IsRenderFrameLive()); + } + } + + if (new_instance.get() != current_instance && allowed_to_swap_process) { + TRACE_EVENT_INSTANT2( + ""navigation"", + ""RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance"", + TRACE_EVENT_SCOPE_THREAD, + ""current_instance id"", current_instance->GetId(), + ""new_instance id"", new_instance->GetId()); + + + if (!pending_render_frame_host_) + CreatePendingRenderFrameHost(current_instance, new_instance.get()); + DCHECK(pending_render_frame_host_); + if (!pending_render_frame_host_) + return nullptr; + DCHECK_EQ(new_instance, pending_render_frame_host_->GetSiteInstance()); + + pending_render_frame_host_->UpdatePendingWebUI(dest_url, bindings); + pending_render_frame_host_->CommitPendingWebUI(); + DCHECK_EQ(GetNavigatingWebUI(), pending_render_frame_host_->web_ui()); + + if (pending_render_frame_host_->web_ui()) { + pending_render_frame_host_->web_ui()->RenderFrameCreated( + pending_render_frame_host_.get()); + } + + if (!render_frame_host_->IsRenderFrameLive()) { + if (GetRenderFrameProxyHost(new_instance.get())) { + pending_render_frame_host_->Send( + new FrameMsg_SwapIn(pending_render_frame_host_->GetRoutingID())); + } + CommitPending(); + return render_frame_host_.get(); + } + + bool is_transfer = transferred_request_id != GlobalRequestID(); + if (is_transfer) { + DCHECK(transfer_navigation_handle_ && + transfer_navigation_handle_->GetGlobalRequestID() == + transferred_request_id); + } else if (!pending_render_frame_host_->are_navigations_suspended()) { + render_frame_host_->Send(new FrameMsg_Stop( + render_frame_host_->GetRoutingID())); + pending_render_frame_host_->SetNavigationsSuspended(true, + base::TimeTicks()); + render_frame_host_->DispatchBeforeUnload(true, is_reload); + } + + return pending_render_frame_host_.get(); + } + + + DeleteRenderFrameProxyHost(new_instance.get()); + + UpdatePendingWebUIOnCurrentFrameHost(dest_url, bindings); + + if (dest_is_view_source_mode) { + DCHECK(!render_frame_host_->GetParent()); + render_frame_host_->Send( + new FrameMsg_EnableViewSourceMode(render_frame_host_->GetRoutingID())); + } + + return render_frame_host_.get(); +} +","@@ -61,7 +61,6 @@ RenderFrameHostManager::RenderFrameHostManager( + delegate_(delegate), + render_frame_delegate_(render_frame_delegate), + render_widget_delegate_(render_widget_delegate), +- interstitial_page_(nullptr), + weak_factory_(this) { + DCHECK(frame_tree_node_); + } +@@ -133,8 +132,8 @@ WebUIImpl* RenderFrameHostManager::GetNavigatingWebUI() const { + } + + RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const { +- if (interstitial_page_) +- return interstitial_page_->GetView(); ++ if (delegate_->GetInterstitialForRenderManager()) ++ return delegate_->GetInterstitialForRenderManager()->GetView(); + if (render_frame_host_) + return render_frame_host_->GetView(); + return nullptr; +@@ -1424,7 +1423,7 @@ RenderFrameHostManager::DetermineSiteInstanceForURL( + // SiteInstances if you type in a cross-site URL. This means we have to + // compare the entry's URL to the last committed entry's URL. + NavigationEntry* current_entry = controller.GetLastCommittedEntry(); +- if (interstitial_page_) { ++ if (delegate_->GetInterstitialForRenderManager()) { + // The interstitial is currently the last committed entry, but we want to + // compare against the last non-interstitial entry. + current_entry = controller.GetEntryAtOffset(-1); +@@ -2825,13 +2824,13 @@ bool RenderFrameHostManager::CanSubframeSwapProcess( + } + + void RenderFrameHostManager::EnsureRenderFrameHostVisibilityConsistent() { +- if (render_frame_host_->GetView() && +- render_frame_host_->render_view_host()->GetWidget()->is_hidden() != +- delegate_->IsHidden()) { ++ RenderWidgetHostView* view = GetRenderWidgetHostView(); ++ if (view && static_cast(view->GetRenderWidgetHost()) ++ ->is_hidden() != delegate_->IsHidden()) { + if (delegate_->IsHidden()) { +- render_frame_host_->GetView()->Hide(); ++ view->Hide(); + } else { +- render_frame_host_->GetView()->Show(); ++ view->Show(); + } + } + }",841,1077,2048 +7188,"_rpc_reattach_tasks(slurm_msg_t *msg) +{ + reattach_tasks_request_msg_t *req = msg->data; + reattach_tasks_response_msg_t *resp = + xmalloc(sizeof(reattach_tasks_response_msg_t)); + slurm_msg_t resp_msg; + int rc = SLURM_SUCCESS; + uint16_t port = 0; + char host[MAXHOSTNAMELEN]; + slurm_addr_t ioaddr; + void *job_cred_sig; + uint32_t len; + int fd; + uid_t req_uid; + slurm_addr_t *cli = &msg->orig_addr; + uint32_t nodeid = (uint32_t)NO_VAL; + uid_t uid = -1; + uint16_t protocol_version; + + slurm_msg_t_copy(&resp_msg, msg); + fd = stepd_connect(conf->spooldir, conf->node_name, + req->job_id, req->job_step_id, &protocol_version); + if (fd == -1) { + debug(""reattach for nonexistent job %u.%u stepd_connect"" + "" failed: %m"", req->job_id, req->job_step_id); + rc = ESLURM_INVALID_JOB_ID; + goto done; + } + + if ((int)(uid = stepd_get_uid(fd, protocol_version)) < 0) { + debug(""_rpc_reattach_tasks couldn't read from the "" + ""step %u.%u: %m"", + req->job_id, req->job_step_id); + rc = ESLURM_INVALID_JOB_ID; + goto done2; + } + + nodeid = stepd_get_nodeid(fd, protocol_version); + + debug2(""_rpc_reattach_tasks: nodeid %d in the job step"", nodeid); + + req_uid = g_slurm_auth_get_uid(msg->auth_cred, conf->auth_info); + if ((req_uid != uid) && (!_slurm_authorized_user(req_uid))) { + error(""uid %ld attempt to attach to job %u.%u owned by %ld"", + (long) req_uid, req->job_id, req->job_step_id, + (long) uid); + rc = EPERM; + goto done2; + } + + memset(resp, 0, sizeof(reattach_tasks_response_msg_t)); + slurm_get_ip_str(cli, &port, host, sizeof(host)); + + /* + * Set response address by resp_port and client address + */ + memcpy(&resp_msg.address, cli, sizeof(slurm_addr_t)); + if (req->num_resp_port > 0) { + port = req->resp_port[nodeid % req->num_resp_port]; + slurm_set_addr(&resp_msg.address, port, NULL); + } + + /* + * Set IO address by io_port and client address + */ + memcpy(&ioaddr, cli, sizeof(slurm_addr_t)); + + if (req->num_io_port > 0) { + port = req->io_port[nodeid % req->num_io_port]; + slurm_set_addr(&ioaddr, port, NULL); + } + + /* + * Get the signature of the job credential. slurmstepd will need + * this to prove its identity when it connects back to srun. + */ + slurm_cred_get_signature(req->cred, (char **)(&job_cred_sig), &len); + if (len != SLURM_IO_KEY_SIZE) { + error(""Incorrect slurm cred signature length""); + goto done2; + } + + resp->gtids = NULL; + resp->local_pids = NULL; + + /* NOTE: We need to use the protocol_version from + * sattach here since responses will be sent back to it. */ + if (msg->protocol_version < protocol_version) + protocol_version = msg->protocol_version; + + /* Following call fills in gtids and local_pids when successful. */ + rc = stepd_attach(fd, protocol_version, &ioaddr, + &resp_msg.address, job_cred_sig, resp); + if (rc != SLURM_SUCCESS) { + debug2(""stepd_attach call failed""); + goto done2; + } + +done2: + close(fd); +done: + debug2(""update step addrs rc = %d"", rc); + resp_msg.data = resp; + resp_msg.msg_type = RESPONSE_REATTACH_TASKS; + resp->node_name = xstrdup(conf->node_name); + resp->return_code = rc; + debug2(""node %s sending rc = %d"", conf->node_name, rc); + + slurm_send_node_msg(msg->conn_fd, &resp_msg); + slurm_free_reattach_tasks_response_msg(resp); +} +",0,"_rpc_reattach_tasks(slurm_msg_t *msg) +{ + reattach_tasks_request_msg_t *req = msg->data; + reattach_tasks_response_msg_t *resp = + xmalloc(sizeof(reattach_tasks_response_msg_t)); + slurm_msg_t resp_msg; + int rc = SLURM_SUCCESS; + uint16_t port = 0; + char host[MAXHOSTNAMELEN]; + slurm_addr_t ioaddr; + void *job_cred_sig; + uint32_t len; + int fd; + uid_t req_uid; + slurm_addr_t *cli = &msg->orig_addr; + uint32_t nodeid = (uint32_t)NO_VAL; + uid_t uid = -1; + uint16_t protocol_version; + + slurm_msg_t_copy(&resp_msg, msg); + fd = stepd_connect(conf->spooldir, conf->node_name, + req->job_id, req->job_step_id, &protocol_version); + if (fd == -1) { + debug(""reattach for nonexistent job %u.%u stepd_connect"" + "" failed: %m"", req->job_id, req->job_step_id); + rc = ESLURM_INVALID_JOB_ID; + goto done; + } + + if ((int)(uid = stepd_get_uid(fd, protocol_version)) < 0) { + debug(""_rpc_reattach_tasks couldn't read from the "" + ""step %u.%u: %m"", + req->job_id, req->job_step_id); + rc = ESLURM_INVALID_JOB_ID; + goto done2; + } + + nodeid = stepd_get_nodeid(fd, protocol_version); + + debug2(""_rpc_reattach_tasks: nodeid %d in the job step"", nodeid); + + req_uid = g_slurm_auth_get_uid(msg->auth_cred, conf->auth_info); + if ((req_uid != uid) && (!_slurm_authorized_user(req_uid))) { + error(""uid %ld attempt to attach to job %u.%u owned by %ld"", + (long) req_uid, req->job_id, req->job_step_id, + (long) uid); + rc = EPERM; + goto done2; + } + + memset(resp, 0, sizeof(reattach_tasks_response_msg_t)); + slurm_get_ip_str(cli, &port, host, sizeof(host)); + + /* + * Set response address by resp_port and client address + */ + memcpy(&resp_msg.address, cli, sizeof(slurm_addr_t)); + if (req->num_resp_port > 0) { + port = req->resp_port[nodeid % req->num_resp_port]; + slurm_set_addr(&resp_msg.address, port, NULL); + } + + /* + * Set IO address by io_port and client address + */ + memcpy(&ioaddr, cli, sizeof(slurm_addr_t)); + + if (req->num_io_port > 0) { + port = req->io_port[nodeid % req->num_io_port]; + slurm_set_addr(&ioaddr, port, NULL); + } + + /* + * Get the signature of the job credential. slurmstepd will need + * this to prove its identity when it connects back to srun. + */ + slurm_cred_get_signature(req->cred, (char **)(&job_cred_sig), &len); + if (len != SLURM_IO_KEY_SIZE) { + error(""Incorrect slurm cred signature length""); + goto done2; + } + + resp->gtids = NULL; + resp->local_pids = NULL; + + /* NOTE: We need to use the protocol_version from + * sattach here since responses will be sent back to it. */ + if (msg->protocol_version < protocol_version) + protocol_version = msg->protocol_version; + + /* Following call fills in gtids and local_pids when successful. */ + rc = stepd_attach(fd, protocol_version, &ioaddr, + &resp_msg.address, job_cred_sig, resp); + if (rc != SLURM_SUCCESS) { + debug2(""stepd_attach call failed""); + goto done2; + } + +done2: + close(fd); +done: + debug2(""update step addrs rc = %d"", rc); + resp_msg.data = resp; + resp_msg.msg_type = RESPONSE_REATTACH_TASKS; + resp->node_name = xstrdup(conf->node_name); + resp->return_code = rc; + debug2(""node %s sending rc = %d"", conf->node_name, rc); + + slurm_send_node_msg(msg->conn_fd, &resp_msg); + slurm_free_reattach_tasks_response_msg(resp); +} +","@@ -168,6 +168,7 @@ static void _note_batch_job_finished(uint32_t job_id); + static int _prolog_is_running (uint32_t jobid); + static int _step_limits_match(void *x, void *key); + static int _terminate_all_steps(uint32_t jobid, bool batch); ++static int _receive_fd(int socket); + static void _rpc_launch_tasks(slurm_msg_t *); + static void _rpc_abort_job(slurm_msg_t *); + static void _rpc_batch_job(slurm_msg_t *msg, bool new_msg); +@@ -214,6 +215,7 @@ static void _sync_messages_kill(kill_job_msg_t *req); + static int _waiter_init (uint32_t jobid); + static int _waiter_complete (uint32_t jobid); + ++static void _send_back_fd(int socket, int fd); + static bool _steps_completed_now(uint32_t jobid); + static int _valid_sbcast_cred(file_bcast_msg_t *req, uid_t req_uid, + uint16_t block_no, uint32_t *job_id); +@@ -1383,6 +1385,111 @@ _rpc_launch_tasks(slurm_msg_t *msg) + send_registration_msg(errnum, false); + } + ++/* ++ * Open file based upon permissions of a different user ++ * IN path_name - name of file to open ++ * IN uid - User ID to use for file access check ++ * IN gid - Group ID to use for file access check ++ * RET -1 on error, file descriptor otherwise ++ */ ++static int _open_as_other(char *path_name, batch_job_launch_msg_t *req) ++{ ++ pid_t child; ++ gids_t *gids; ++ int pipe[2]; ++ int fd = -1, rc = 0; ++ ++ if (!(gids = _gids_cache_lookup(req->user_name, req->gid))) { ++ error(""%s: gids_cache_lookup for %s failed"", ++ __func__, req->user_name); ++ return -1; ++ } ++ ++ if ((rc = container_g_create(req->job_id))) { ++ error(""%s: container_g_create(%u): %m"", __func__, req->job_id); ++ _dealloc_gids(gids); ++ return -1; ++ } ++ ++ /* child process will setuid to the user, register the process ++ * with the container, and open the file for us. */ ++ if (socketpair(AF_UNIX, SOCK_DGRAM, 0, pipe) != 0) { ++ error(""%s: Failed to open pipe: %m"", __func__); ++ _dealloc_gids(gids); ++ return -1; ++ } ++ ++ child = fork(); ++ if (child == -1) { ++ error(""%s: fork failure"", __func__); ++ _dealloc_gids(gids); ++ close(pipe[0]); ++ close(pipe[1]); ++ return -1; ++ } else if (child > 0) { ++ close(pipe[0]); ++ (void) waitpid(child, &rc, 0); ++ _dealloc_gids(gids); ++ if (WIFEXITED(rc) && (WEXITSTATUS(rc) == 0)) ++ fd = _receive_fd(pipe[1]); ++ close(pipe[1]); ++ return fd; ++ } ++ ++ /* child process below here */ ++ ++ close(pipe[1]); ++ ++ /* container_g_add_pid needs to be called in the ++ * forked process part of the fork to avoid a race ++ * condition where if this process makes a file or ++ * detacts itself from a child before we add the pid ++ * to the container in the parent of the fork. */ ++ if (container_g_add_pid(req->job_id, getpid(), req->uid)) { ++ error(""%s container_g_add_pid(%u): %m"", __func__, req->job_id); ++ exit(SLURM_ERROR); ++ } ++ ++ /* The child actually performs the I/O and exits with ++ * a return code, do not return! */ ++ ++ /*********************************************************************\ ++ * NOTE: It would be best to do an exec() immediately after the fork() ++ * in order to help prevent a possible deadlock in the child process ++ * due to locks being set at the time of the fork and being freed by ++ * the parent process, but not freed by the child process. Performing ++ * the work inline is done for simplicity. Note that the logging ++ * performed by error() should be safe due to the use of ++ * atfork_install_handlers() as defined in src/common/log.c. ++ * Change the code below with caution. ++ \*********************************************************************/ ++ ++ if (setgroups(gids->ngids, gids->gids) < 0) { ++ error(""%s: uid: %u setgroups failed: %m"", __func__, req->uid); ++ exit(errno); ++ } ++ _dealloc_gids(gids); ++ ++ if (setgid(req->gid) < 0) { ++ error(""%s: uid:%u setgid(%u): %m"", __func__, req->uid,req->gid); ++ exit(errno); ++ } ++ if (setuid(req->uid) < 0) { ++ error(""%s: getuid(%u): %m"", __func__, req->uid); ++ exit(errno); ++ } ++ ++ fd = open(path_name, (O_CREAT|O_APPEND|O_WRONLY), 0644); ++ if (fd == -1) { ++ error(""%s: uid:%u can't open `%s`: %m"", ++ __func__, req->uid, path_name); ++ exit(errno); ++ } ++ _send_back_fd(pipe[0], fd); ++ close(fd); ++ exit(SLURM_SUCCESS); ++} ++ + static void + _prolog_error(batch_job_launch_msg_t *req, int rc) + { +@@ -1415,10 +1522,8 @@ _prolog_error(batch_job_launch_msg_t *req, int rc) + req->work_dir, err_name_ptr); + else + snprintf(path_name, MAXPATHLEN, ""/%s"", err_name_ptr); +- +- if ((fd = open(path_name, (O_CREAT|O_APPEND|O_WRONLY), 0644)) == -1) { +- error(""Unable to open %s: %s"", path_name, +- slurm_strerror(errno)); ++ if ((fd = _open_as_other(path_name, req)) == -1) { ++ error(""Unable to open %s: Permission denied"", path_name); + return; + } + snprintf(err_name, sizeof(err_name),",979,1215,2048 +17008,"xsltFreeStylePreComp(xsltStylePreCompPtr comp) { + if (comp == NULL) + return; +#ifdef XSLT_REFACTORED + /* + * URGENT TODO: Implement destructors. + */ + switch (comp->type) { + case XSLT_FUNC_LITERAL_RESULT_ELEMENT: + break; + case XSLT_FUNC_COPY: + break; + case XSLT_FUNC_SORT: { + xsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp; + if (item->locale != (xsltLocale)0) + xsltFreeLocale(item->locale); + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_TEXT: + break; + case XSLT_FUNC_ELEMENT: + break; + case XSLT_FUNC_ATTRIBUTE: + break; + case XSLT_FUNC_COMMENT: + break; + case XSLT_FUNC_PI: + break; + case XSLT_FUNC_COPYOF: { + xsltStyleItemCopyOfPtr item = (xsltStyleItemCopyOfPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_VALUEOF: { + xsltStyleItemValueOfPtr item = (xsltStyleItemValueOfPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_NUMBER: { + xsltStyleItemNumberPtr item = (xsltStyleItemNumberPtr) comp; + if (item->numdata.countPat != NULL) + xsltFreeCompMatchList(item->numdata.countPat); + if (item->numdata.fromPat != NULL) + xsltFreeCompMatchList(item->numdata.fromPat); + } + break; + case XSLT_FUNC_APPLYIMPORTS: + break; + case XSLT_FUNC_CALLTEMPLATE: + break; + case XSLT_FUNC_APPLYTEMPLATES: { + xsltStyleItemApplyTemplatesPtr item = + (xsltStyleItemApplyTemplatesPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_CHOOSE: + break; + case XSLT_FUNC_IF: { + xsltStyleItemIfPtr item = (xsltStyleItemIfPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_FOREACH: { + xsltStyleItemForEachPtr item = + (xsltStyleItemForEachPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_DOCUMENT: + break; + case XSLT_FUNC_WITHPARAM: { + xsltStyleItemWithParamPtr item = + (xsltStyleItemWithParamPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_PARAM: { + xsltStyleItemParamPtr item = + (xsltStyleItemParamPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_VARIABLE: { + xsltStyleItemVariablePtr item = + (xsltStyleItemVariablePtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_WHEN: { + xsltStyleItemWhenPtr item = + (xsltStyleItemWhenPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_OTHERWISE: + case XSLT_FUNC_FALLBACK: + case XSLT_FUNC_MESSAGE: + case XSLT_FUNC_INCLUDE: + case XSLT_FUNC_ATTRSET: + + break; + default: + /* TODO: Raise error. */ + break; + } +#else + if (comp->locale != (xsltLocale)0) + xsltFreeLocale(comp->locale); + if (comp->comp != NULL) + xmlXPathFreeCompExpr(comp->comp); + if (comp->numdata.countPat != NULL) + xsltFreeCompMatchList(comp->numdata.countPat); + if (comp->numdata.fromPat != NULL) + xsltFreeCompMatchList(comp->numdata.fromPat); + if (comp->nsList != NULL) + xmlFree(comp->nsList); +#endif + + xmlFree(comp); +} +",0,"xsltFreeStylePreComp(xsltStylePreCompPtr comp) { + if (comp == NULL) + return; +#ifdef XSLT_REFACTORED + /* + * URGENT TODO: Implement destructors. + */ + switch (comp->type) { + case XSLT_FUNC_LITERAL_RESULT_ELEMENT: + break; + case XSLT_FUNC_COPY: + break; + case XSLT_FUNC_SORT: { + xsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp; + if (item->locale != (xsltLocale)0) + xsltFreeLocale(item->locale); + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_TEXT: + break; + case XSLT_FUNC_ELEMENT: + break; + case XSLT_FUNC_ATTRIBUTE: + break; + case XSLT_FUNC_COMMENT: + break; + case XSLT_FUNC_PI: + break; + case XSLT_FUNC_COPYOF: { + xsltStyleItemCopyOfPtr item = (xsltStyleItemCopyOfPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_VALUEOF: { + xsltStyleItemValueOfPtr item = (xsltStyleItemValueOfPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_NUMBER: { + xsltStyleItemNumberPtr item = (xsltStyleItemNumberPtr) comp; + if (item->numdata.countPat != NULL) + xsltFreeCompMatchList(item->numdata.countPat); + if (item->numdata.fromPat != NULL) + xsltFreeCompMatchList(item->numdata.fromPat); + } + break; + case XSLT_FUNC_APPLYIMPORTS: + break; + case XSLT_FUNC_CALLTEMPLATE: + break; + case XSLT_FUNC_APPLYTEMPLATES: { + xsltStyleItemApplyTemplatesPtr item = + (xsltStyleItemApplyTemplatesPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_CHOOSE: + break; + case XSLT_FUNC_IF: { + xsltStyleItemIfPtr item = (xsltStyleItemIfPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_FOREACH: { + xsltStyleItemForEachPtr item = + (xsltStyleItemForEachPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_DOCUMENT: + break; + case XSLT_FUNC_WITHPARAM: { + xsltStyleItemWithParamPtr item = + (xsltStyleItemWithParamPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_PARAM: { + xsltStyleItemParamPtr item = + (xsltStyleItemParamPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_VARIABLE: { + xsltStyleItemVariablePtr item = + (xsltStyleItemVariablePtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_WHEN: { + xsltStyleItemWhenPtr item = + (xsltStyleItemWhenPtr) comp; + if (item->comp != NULL) + xmlXPathFreeCompExpr(item->comp); + } + break; + case XSLT_FUNC_OTHERWISE: + case XSLT_FUNC_FALLBACK: + case XSLT_FUNC_MESSAGE: + case XSLT_FUNC_INCLUDE: + case XSLT_FUNC_ATTRSET: + + break; + default: + /* TODO: Raise error. */ + break; + } +#else + if (comp->locale != (xsltLocale)0) + xsltFreeLocale(comp->locale); + if (comp->comp != NULL) + xmlXPathFreeCompExpr(comp->comp); + if (comp->numdata.countPat != NULL) + xsltFreeCompMatchList(comp->numdata.countPat); + if (comp->numdata.fromPat != NULL) + xsltFreeCompMatchList(comp->numdata.fromPat); + if (comp->nsList != NULL) + xmlFree(comp->nsList); +#endif + + xmlFree(comp); +} +","@@ -949,6 +949,8 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) { + #ifdef XSLT_REFACTORED + comp->nsPrefix = prefix; + comp->name = name; ++#else ++ (void)name; /* Suppress unused variable warning. */ + #endif + } else if (prefix != NULL) { + xsltTransformError(NULL, style, inst, +@@ -1074,6 +1076,8 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) { + #ifdef XSLT_REFACTORED + comp->nsPrefix = prefix; + comp->name = name; ++#else ++ (void)name; /* Suppress unused variable warning. */ + #endif + } else { + xsltTransformError(NULL, style, inst, +@@ -1301,7 +1305,8 @@ xsltGetQNameProperty(xsltStylesheetPtr style, xmlNodePtr inst, + if (prop == NULL) { + style->errors++; + } else { +- *localName = prop; ++ if (localName) ++ *localName = prop; + if (hasProp) + *hasProp = 1; + if (URI != NULL) { +@@ -2245,7 +2250,8 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) { + } else if (IS_XSLT_NAME(inst, ""attribute"")) { + xmlNodePtr parent = inst->parent; + +- if ((parent == NULL) || (parent->ns == NULL) || ++ if ((parent == NULL) || ++ (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) || + ((parent->ns != inst->ns) && + (!xmlStrEqual(parent->ns->href, inst->ns->href))) || + (!xmlStrEqual(parent->name, BAD_CAST ""attribute-set""))) {",1001,1237,2048 +1983,"void rds_recv_incoming(struct rds_connection *conn, __be32 saddr, __be32 daddr, + struct rds_incoming *inc, gfp_t gfp) +{ + struct rds_sock *rs = NULL; + struct sock *sk; + unsigned long flags; + + inc->i_conn = conn; + inc->i_rx_jiffies = jiffies; + + rdsdebug(""conn %p next %llu inc %p seq %llu len %u sport %u dport %u "" + ""flags 0x%x rx_jiffies %lu\n"", conn, + (unsigned long long)conn->c_next_rx_seq, + inc, + (unsigned long long)be64_to_cpu(inc->i_hdr.h_sequence), + be32_to_cpu(inc->i_hdr.h_len), + be16_to_cpu(inc->i_hdr.h_sport), + be16_to_cpu(inc->i_hdr.h_dport), + inc->i_hdr.h_flags, + inc->i_rx_jiffies); + + /* + * Sequence numbers should only increase. Messages get their + * sequence number as they're queued in a sending conn. They + * can be dropped, though, if the sending socket is closed before + * they hit the wire. So sequence numbers can skip forward + * under normal operation. They can also drop back in the conn + * failover case as previously sent messages are resent down the + * new instance of a conn. We drop those, otherwise we have + * to assume that the next valid seq does not come after a + * hole in the fragment stream. + * + * The headers don't give us a way to realize if fragments of + * a message have been dropped. We assume that frags that arrive + * to a flow are part of the current message on the flow that is + * being reassembled. This means that senders can't drop messages + * from the sending conn until all their frags are sent. + * + * XXX we could spend more on the wire to get more robust failure + * detection, arguably worth it to avoid data corruption. + */ + if (be64_to_cpu(inc->i_hdr.h_sequence) < conn->c_next_rx_seq && + (inc->i_hdr.h_flags & RDS_FLAG_RETRANSMITTED)) { + rds_stats_inc(s_recv_drop_old_seq); + goto out; + } + conn->c_next_rx_seq = be64_to_cpu(inc->i_hdr.h_sequence) + 1; + + if (rds_sysctl_ping_enable && inc->i_hdr.h_dport == 0) { + rds_stats_inc(s_recv_ping); + rds_send_pong(conn, inc->i_hdr.h_sport); + goto out; + } + + rs = rds_find_bound(daddr, inc->i_hdr.h_dport); + if (!rs) { + rds_stats_inc(s_recv_drop_no_sock); + goto out; + } + + /* Process extension headers */ + rds_recv_incoming_exthdrs(inc, rs); + + /* We can be racing with rds_release() which marks the socket dead. */ + sk = rds_rs_to_sk(rs); + + /* serialize with rds_release -> sock_orphan */ + write_lock_irqsave(&rs->rs_recv_lock, flags); + if (!sock_flag(sk, SOCK_DEAD)) { + rdsdebug(""adding inc %p to rs %p's recv queue\n"", inc, rs); + rds_stats_inc(s_recv_queued); + rds_recv_rcvbuf_delta(rs, sk, inc->i_conn->c_lcong, + be32_to_cpu(inc->i_hdr.h_len), + inc->i_hdr.h_dport); + rds_inc_addref(inc); + list_add_tail(&inc->i_item, &rs->rs_recv_queue); + __rds_wake_sk_sleep(sk); + } else { + rds_stats_inc(s_recv_drop_dead_sock); + } + write_unlock_irqrestore(&rs->rs_recv_lock, flags); + +out: + if (rs) + rds_sock_put(rs); +} +",0,"void rds_recv_incoming(struct rds_connection *conn, __be32 saddr, __be32 daddr, + struct rds_incoming *inc, gfp_t gfp) +{ + struct rds_sock *rs = NULL; + struct sock *sk; + unsigned long flags; + + inc->i_conn = conn; + inc->i_rx_jiffies = jiffies; + + rdsdebug(""conn %p next %llu inc %p seq %llu len %u sport %u dport %u "" + ""flags 0x%x rx_jiffies %lu\n"", conn, + (unsigned long long)conn->c_next_rx_seq, + inc, + (unsigned long long)be64_to_cpu(inc->i_hdr.h_sequence), + be32_to_cpu(inc->i_hdr.h_len), + be16_to_cpu(inc->i_hdr.h_sport), + be16_to_cpu(inc->i_hdr.h_dport), + inc->i_hdr.h_flags, + inc->i_rx_jiffies); + + /* + * Sequence numbers should only increase. Messages get their + * sequence number as they're queued in a sending conn. They + * can be dropped, though, if the sending socket is closed before + * they hit the wire. So sequence numbers can skip forward + * under normal operation. They can also drop back in the conn + * failover case as previously sent messages are resent down the + * new instance of a conn. We drop those, otherwise we have + * to assume that the next valid seq does not come after a + * hole in the fragment stream. + * + * The headers don't give us a way to realize if fragments of + * a message have been dropped. We assume that frags that arrive + * to a flow are part of the current message on the flow that is + * being reassembled. This means that senders can't drop messages + * from the sending conn until all their frags are sent. + * + * XXX we could spend more on the wire to get more robust failure + * detection, arguably worth it to avoid data corruption. + */ + if (be64_to_cpu(inc->i_hdr.h_sequence) < conn->c_next_rx_seq && + (inc->i_hdr.h_flags & RDS_FLAG_RETRANSMITTED)) { + rds_stats_inc(s_recv_drop_old_seq); + goto out; + } + conn->c_next_rx_seq = be64_to_cpu(inc->i_hdr.h_sequence) + 1; + + if (rds_sysctl_ping_enable && inc->i_hdr.h_dport == 0) { + rds_stats_inc(s_recv_ping); + rds_send_pong(conn, inc->i_hdr.h_sport); + goto out; + } + + rs = rds_find_bound(daddr, inc->i_hdr.h_dport); + if (!rs) { + rds_stats_inc(s_recv_drop_no_sock); + goto out; + } + + /* Process extension headers */ + rds_recv_incoming_exthdrs(inc, rs); + + /* We can be racing with rds_release() which marks the socket dead. */ + sk = rds_rs_to_sk(rs); + + /* serialize with rds_release -> sock_orphan */ + write_lock_irqsave(&rs->rs_recv_lock, flags); + if (!sock_flag(sk, SOCK_DEAD)) { + rdsdebug(""adding inc %p to rs %p's recv queue\n"", inc, rs); + rds_stats_inc(s_recv_queued); + rds_recv_rcvbuf_delta(rs, sk, inc->i_conn->c_lcong, + be32_to_cpu(inc->i_hdr.h_len), + inc->i_hdr.h_dport); + rds_inc_addref(inc); + list_add_tail(&inc->i_item, &rs->rs_recv_queue); + __rds_wake_sk_sleep(sk); + } else { + rds_stats_inc(s_recv_drop_dead_sock); + } + write_unlock_irqrestore(&rs->rs_recv_lock, flags); + +out: + if (rs) + rds_sock_put(rs); +} +","@@ -410,6 +410,8 @@ int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, + + rdsdebug(""size %zu flags 0x%x timeo %ld\n"", size, msg_flags, timeo); + ++ msg->msg_namelen = 0; ++ + if (msg_flags & MSG_OOB) + goto out; + +@@ -485,6 +487,7 @@ int rds_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, + sin->sin_port = inc->i_hdr.h_sport; + sin->sin_addr.s_addr = inc->i_saddr; + memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); ++ msg->msg_namelen = sizeof(*sin); + } + break; + }",878,1114,2048 +1139,"static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoPtr, char **pszEncoding, char *szValuePtr, int ByteCount TSRMLS_DC) +{ + int a; + char *decode; + size_t len;; + + *pszEncoding = NULL; + /* Copy the comment */ + if (ByteCount>=8) { + if (!memcmp(szValuePtr, ""UNICODE\0"", 8)) { + *pszEncoding = estrdup((const char*)szValuePtr); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + /* First try to detect BOM: ZERO WIDTH NOBREAK SPACE (FEFF 16) + * since we have no encoding support for the BOM yet we skip that. + */ + if (!memcmp(szValuePtr, ""\xFE\xFF"", 2)) { + decode = ""UCS-2BE""; + szValuePtr = szValuePtr+2; + ByteCount -= 2; + } else if (!memcmp(szValuePtr, ""\xFF\xFE"", 2)) { + decode = ""UCS-2LE""; + szValuePtr = szValuePtr+2; + ByteCount -= 2; + } else if (ImageInfo->motorola_intel) { + decode = ImageInfo->decode_unicode_be; + } else { + decode = ImageInfo->decode_unicode_le; + } + /* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */ + if (zend_multibyte_encoding_converter( + (unsigned char**)pszInfoPtr, + &len, + (unsigned char*)szValuePtr, + ByteCount, + zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC), + zend_multibyte_fetch_encoding(decode TSRMLS_CC) + TSRMLS_CC) == (size_t)-1) { + len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount); + } + return len; + } else if (!memcmp(szValuePtr, ""ASCII\0\0\0"", 8)) { + *pszEncoding = estrdup((const char*)szValuePtr); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + } else if (!memcmp(szValuePtr, ""JIS\0\0\0\0\0"", 8)) { + /* JIS should be tanslated to MB or we leave it to the user - leave it to the user */ + *pszEncoding = estrdup((const char*)szValuePtr); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + /* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */ + if (zend_multibyte_encoding_converter( + (unsigned char**)pszInfoPtr, + &len, + (unsigned char*)szValuePtr, + ByteCount, + zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC), + zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageInfo->decode_jis_le TSRMLS_CC) + TSRMLS_CC) == (size_t)-1) { + len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount); + } + return len; + } else if (!memcmp(szValuePtr, ""\0\0\0\0\0\0\0\0"", 8)) { + /* 8 NULL means undefined and should be ASCII... */ + *pszEncoding = estrdup(""UNDEFINED""); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + } + } + + /* Olympus has this padded with trailing spaces. Remove these first. */ + if (ByteCount>0) { + for (a=ByteCount-1;a && szValuePtr[a]==' ';a--) { + (szValuePtr)[a] = '\0'; + } + } + + /* normal text without encoding */ + exif_process_string(pszInfoPtr, szValuePtr, ByteCount TSRMLS_CC); + return strlen(*pszInfoPtr); +} +",0,"static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoPtr, char **pszEncoding, char *szValuePtr, int ByteCount TSRMLS_DC) +{ + int a; + char *decode; + size_t len;; + + *pszEncoding = NULL; + /* Copy the comment */ + if (ByteCount>=8) { + if (!memcmp(szValuePtr, ""UNICODE\0"", 8)) { + *pszEncoding = estrdup((const char*)szValuePtr); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + /* First try to detect BOM: ZERO WIDTH NOBREAK SPACE (FEFF 16) + * since we have no encoding support for the BOM yet we skip that. + */ + if (!memcmp(szValuePtr, ""\xFE\xFF"", 2)) { + decode = ""UCS-2BE""; + szValuePtr = szValuePtr+2; + ByteCount -= 2; + } else if (!memcmp(szValuePtr, ""\xFF\xFE"", 2)) { + decode = ""UCS-2LE""; + szValuePtr = szValuePtr+2; + ByteCount -= 2; + } else if (ImageInfo->motorola_intel) { + decode = ImageInfo->decode_unicode_be; + } else { + decode = ImageInfo->decode_unicode_le; + } + /* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */ + if (zend_multibyte_encoding_converter( + (unsigned char**)pszInfoPtr, + &len, + (unsigned char*)szValuePtr, + ByteCount, + zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC), + zend_multibyte_fetch_encoding(decode TSRMLS_CC) + TSRMLS_CC) == (size_t)-1) { + len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount); + } + return len; + } else if (!memcmp(szValuePtr, ""ASCII\0\0\0"", 8)) { + *pszEncoding = estrdup((const char*)szValuePtr); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + } else if (!memcmp(szValuePtr, ""JIS\0\0\0\0\0"", 8)) { + /* JIS should be tanslated to MB or we leave it to the user - leave it to the user */ + *pszEncoding = estrdup((const char*)szValuePtr); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + /* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */ + if (zend_multibyte_encoding_converter( + (unsigned char**)pszInfoPtr, + &len, + (unsigned char*)szValuePtr, + ByteCount, + zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC), + zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageInfo->decode_jis_le TSRMLS_CC) + TSRMLS_CC) == (size_t)-1) { + len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount); + } + return len; + } else if (!memcmp(szValuePtr, ""\0\0\0\0\0\0\0\0"", 8)) { + /* 8 NULL means undefined and should be ASCII... */ + *pszEncoding = estrdup(""UNDEFINED""); + szValuePtr = szValuePtr+8; + ByteCount -= 8; + } + } + + /* Olympus has this padded with trailing spaces. Remove these first. */ + if (ByteCount>0) { + for (a=ByteCount-1;a && szValuePtr[a]==' ';a--) { + (szValuePtr)[a] = '\0'; + } + } + + /* normal text without encoding */ + exif_process_string(pszInfoPtr, szValuePtr, ByteCount TSRMLS_CC); + return strlen(*pszInfoPtr); +} +","@@ -2965,7 +2965,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha + /* When there are any characters after the first NUL */ + ImageInfo->CopyrightPhotographer = estrdup(value_ptr); + ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1); +- spprintf(&ImageInfo->Copyright, 0, ""%s, %s"", value_ptr, value_ptr+length+1); ++ spprintf(&ImageInfo->Copyright, 0, ""%s, %s"", ImageInfo->CopyrightPhotographer, ImageInfo->CopyrightEditor); + /* format = TAG_FMT_UNDEFINED; this musn't be ASCII */ + /* but we are not supposed to change this */ + /* keep in mind that image_info does not store editor value */ +@@ -3134,6 +3134,11 @@ static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, + + ImageInfo->sections_found |= FOUND_IFD0; + ++ if ((dir_start + 2) >= (offset_base+IFDlength)) { ++ exif_error_docref(""exif_read_data#error_ifd"" EXIFERR_CC, ImageInfo, E_WARNING, ""Illegal IFD size""); ++ return FALSE; ++ } ++ + NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); + + if ((dir_start+2+NumDirEntries*12) > (offset_base+IFDlength)) { +@@ -3157,6 +3162,10 @@ static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, + * Hack to make it process IDF1 I hope + * There are 2 IDFs, the second one holds the keys (0x0201 and 0x0202) to the thumbnail + */ ++ if ((dir_start+2+12*de + 4) >= (offset_base+IFDlength)) { ++ exif_error_docref(""exif_read_data#error_ifd"" EXIFERR_CC, ImageInfo, E_WARNING, ""Illegal IFD size""); ++ return FALSE; ++ } + NextDirOffset = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel); + if (NextDirOffset) { + /* the next line seems false but here IFDlength means length of all IFDs */ +@@ -3206,9 +3215,13 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, + } + + /* Check the next two values for correctness. */ ++ if (length < 8) { ++ exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, ""Invalid TIFF start (1)""); ++ return; ++ } + exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel); + offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel); +- if ( exif_value_2a != 0x2a || offset_of_ifd < 0x08) { ++ if (exif_value_2a != 0x2a || offset_of_ifd < 0x08) { + exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, ""Invalid TIFF start (1)""); + return; + }",921,1157,2048 +16905,"ExtensionFunction::ResponseAction TabsQueryFunction::Run() { + std::unique_ptr params( + tabs::Query::Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params.get()); + + bool loading_status_set = params->query_info.status != tabs::TAB_STATUS_NONE; + bool loading = params->query_info.status == tabs::TAB_STATUS_LOADING; + + URLPatternSet url_patterns; + if (params->query_info.url.get()) { + std::vector url_pattern_strings; + if (params->query_info.url->as_string) + url_pattern_strings.push_back(*params->query_info.url->as_string); + else if (params->query_info.url->as_strings) + url_pattern_strings.swap(*params->query_info.url->as_strings); + std::string error; + if (!url_patterns.Populate(url_pattern_strings, URLPattern::SCHEME_ALL, + true, &error)) { + return RespondNow(Error(error)); + } + } + + std::string title; + if (params->query_info.title.get()) + title = *params->query_info.title; + + int window_id = extension_misc::kUnknownWindowId; + if (params->query_info.window_id.get()) + window_id = *params->query_info.window_id; + + int index = -1; + if (params->query_info.index.get()) + index = *params->query_info.index; + + std::string window_type; + if (params->query_info.window_type != tabs::WINDOW_TYPE_NONE) + window_type = tabs::ToString(params->query_info.window_type); + + std::unique_ptr result(new base::ListValue()); + Profile* profile = Profile::FromBrowserContext(browser_context()); + Browser* last_active_browser = + chrome::FindAnyBrowser(profile, include_incognito()); + Browser* current_browser = + ChromeExtensionFunctionDetails(this).GetCurrentBrowser(); + for (auto* browser : *BrowserList::GetInstance()) { + if (!profile->IsSameProfile(browser->profile())) + continue; + + if (!browser->window()) + continue; + + if (!include_incognito() && profile != browser->profile()) + continue; + + if (!browser->extension_window_controller()->IsVisibleToTabsAPIForExtension( + extension(), false /*allow_dev_tools_windows*/)) { + continue; + } + + if (window_id >= 0 && window_id != ExtensionTabUtil::GetWindowId(browser)) + continue; + + if (window_id == extension_misc::kCurrentWindowId && + browser != current_browser) { + continue; + } + + if (!MatchesBool(params->query_info.current_window.get(), + browser == current_browser)) { + continue; + } + + if (!MatchesBool(params->query_info.last_focused_window.get(), + browser == last_active_browser)) { + continue; + } + + if (!window_type.empty() && + window_type != + browser->extension_window_controller()->GetWindowTypeText()) { + continue; + } + + TabStripModel* tab_strip = browser->tab_strip_model(); + for (int i = 0; i < tab_strip->count(); ++i) { + WebContents* web_contents = tab_strip->GetWebContentsAt(i); + + if (index > -1 && i != index) + continue; + + if (!web_contents) { + continue; + } + + if (!MatchesBool(params->query_info.highlighted.get(), + tab_strip->IsTabSelected(i))) { + continue; + } + + if (!MatchesBool(params->query_info.active.get(), + i == tab_strip->active_index())) { + continue; + } + + if (!MatchesBool(params->query_info.pinned.get(), + tab_strip->IsTabPinned(i))) { + continue; + } + + if (!MatchesBool(params->query_info.audible.get(), + web_contents->WasRecentlyAudible())) { + continue; + } + + auto* tab_lifecycle_unit_external = + resource_coordinator::TabLifecycleUnitExternal::FromWebContents( + web_contents); + + if (!MatchesBool(params->query_info.discarded.get(), + tab_lifecycle_unit_external->IsDiscarded())) { + continue; + } + + if (!MatchesBool(params->query_info.auto_discardable.get(), + tab_lifecycle_unit_external->IsAutoDiscardable())) { + continue; + } + + if (!MatchesBool(params->query_info.muted.get(), + web_contents->IsAudioMuted())) { + continue; + } + + if (!title.empty() || !url_patterns.is_empty()) { + if (!extension_->permissions_data()->HasAPIPermissionForTab( + ExtensionTabUtil::GetTabId(web_contents), + APIPermission::kTab) && + !extension_->permissions_data()->HasHostPermission( + web_contents->GetURL())) { + continue; + } + + if (!title.empty() && + !base::MatchPattern(web_contents->GetTitle(), + base::UTF8ToUTF16(title))) { + continue; + } + + if (!url_patterns.is_empty() && + !url_patterns.MatchesURL(web_contents->GetURL())) { + continue; + } + } + + if (loading_status_set && loading != web_contents->IsLoading()) + continue; + + result->Append(ExtensionTabUtil::CreateTabObject( + web_contents, ExtensionTabUtil::kScrubTab, extension(), + tab_strip, i) + ->ToValue()); + } + } + + return RespondNow(OneArgument(std::move(result))); +} +",0,"ExtensionFunction::ResponseAction TabsQueryFunction::Run() { + std::unique_ptr params( + tabs::Query::Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params.get()); + + bool loading_status_set = params->query_info.status != tabs::TAB_STATUS_NONE; + bool loading = params->query_info.status == tabs::TAB_STATUS_LOADING; + + URLPatternSet url_patterns; + if (params->query_info.url.get()) { + std::vector url_pattern_strings; + if (params->query_info.url->as_string) + url_pattern_strings.push_back(*params->query_info.url->as_string); + else if (params->query_info.url->as_strings) + url_pattern_strings.swap(*params->query_info.url->as_strings); + std::string error; + if (!url_patterns.Populate(url_pattern_strings, URLPattern::SCHEME_ALL, + true, &error)) { + return RespondNow(Error(error)); + } + } + + std::string title; + if (params->query_info.title.get()) + title = *params->query_info.title; + + int window_id = extension_misc::kUnknownWindowId; + if (params->query_info.window_id.get()) + window_id = *params->query_info.window_id; + + int index = -1; + if (params->query_info.index.get()) + index = *params->query_info.index; + + std::string window_type; + if (params->query_info.window_type != tabs::WINDOW_TYPE_NONE) + window_type = tabs::ToString(params->query_info.window_type); + + std::unique_ptr result(new base::ListValue()); + Profile* profile = Profile::FromBrowserContext(browser_context()); + Browser* last_active_browser = + chrome::FindAnyBrowser(profile, include_incognito()); + Browser* current_browser = + ChromeExtensionFunctionDetails(this).GetCurrentBrowser(); + for (auto* browser : *BrowserList::GetInstance()) { + if (!profile->IsSameProfile(browser->profile())) + continue; + + if (!browser->window()) + continue; + + if (!include_incognito() && profile != browser->profile()) + continue; + + if (!browser->extension_window_controller()->IsVisibleToTabsAPIForExtension( + extension(), false /*allow_dev_tools_windows*/)) { + continue; + } + + if (window_id >= 0 && window_id != ExtensionTabUtil::GetWindowId(browser)) + continue; + + if (window_id == extension_misc::kCurrentWindowId && + browser != current_browser) { + continue; + } + + if (!MatchesBool(params->query_info.current_window.get(), + browser == current_browser)) { + continue; + } + + if (!MatchesBool(params->query_info.last_focused_window.get(), + browser == last_active_browser)) { + continue; + } + + if (!window_type.empty() && + window_type != + browser->extension_window_controller()->GetWindowTypeText()) { + continue; + } + + TabStripModel* tab_strip = browser->tab_strip_model(); + for (int i = 0; i < tab_strip->count(); ++i) { + WebContents* web_contents = tab_strip->GetWebContentsAt(i); + + if (index > -1 && i != index) + continue; + + if (!web_contents) { + continue; + } + + if (!MatchesBool(params->query_info.highlighted.get(), + tab_strip->IsTabSelected(i))) { + continue; + } + + if (!MatchesBool(params->query_info.active.get(), + i == tab_strip->active_index())) { + continue; + } + + if (!MatchesBool(params->query_info.pinned.get(), + tab_strip->IsTabPinned(i))) { + continue; + } + + if (!MatchesBool(params->query_info.audible.get(), + web_contents->WasRecentlyAudible())) { + continue; + } + + auto* tab_lifecycle_unit_external = + resource_coordinator::TabLifecycleUnitExternal::FromWebContents( + web_contents); + + if (!MatchesBool(params->query_info.discarded.get(), + tab_lifecycle_unit_external->IsDiscarded())) { + continue; + } + + if (!MatchesBool(params->query_info.auto_discardable.get(), + tab_lifecycle_unit_external->IsAutoDiscardable())) { + continue; + } + + if (!MatchesBool(params->query_info.muted.get(), + web_contents->IsAudioMuted())) { + continue; + } + + if (!title.empty() || !url_patterns.is_empty()) { + if (!extension_->permissions_data()->HasAPIPermissionForTab( + ExtensionTabUtil::GetTabId(web_contents), + APIPermission::kTab) && + !extension_->permissions_data()->HasHostPermission( + web_contents->GetURL())) { + continue; + } + + if (!title.empty() && + !base::MatchPattern(web_contents->GetTitle(), + base::UTF8ToUTF16(title))) { + continue; + } + + if (!url_patterns.is_empty() && + !url_patterns.MatchesURL(web_contents->GetURL())) { + continue; + } + } + + if (loading_status_set && loading != web_contents->IsLoading()) + continue; + + result->Append(ExtensionTabUtil::CreateTabObject( + web_contents, ExtensionTabUtil::kScrubTab, extension(), + tab_strip, i) + ->ToValue()); + } + } + + return RespondNow(OneArgument(std::move(result))); +} +","@@ -1739,6 +1739,7 @@ WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID( + } + + if (!extension()->permissions_data()->CanCaptureVisiblePage( ++ contents->GetLastCommittedURL(), extension(), + SessionTabHelper::IdForTab(contents).id(), error)) { + return nullptr; + } +@@ -1762,9 +1763,8 @@ ExtensionFunction::ResponseAction TabsCaptureVisibleTabFunction::Run() { + + std::string error; + WebContents* contents = GetWebContentsForID(context_id, &error); +- // TODO(wjmaclean): If |error| was populated, shouldn't we send error +- // response? Currently doing that will fail +- // ExtensionApiCaptureTest.CaptureNullWindow test. ++ if (!contents) ++ return RespondNow(Error(error)); + + const CaptureResult capture_result = CaptureAsync( + contents, image_details.get(),",1142,1378,2048 +18248,"int build_ntlmssp_auth_blob(unsigned char **pbuffer, + u16 *buflen, + struct cifs_ses *ses, + const struct nls_table *nls_cp) +{ + int rc; + AUTHENTICATE_MESSAGE *sec_blob; + __u32 flags; + unsigned char *tmp; + + rc = setup_ntlmv2_rsp(ses, nls_cp); + if (rc) { + cifs_dbg(VFS, ""Error %d during NTLMSSP authentication\n"", rc); + *buflen = 0; + goto setup_ntlmv2_ret; + } + *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL); + sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer; + + memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); + sec_blob->MessageType = NtLmAuthenticate; + + flags = NTLMSSP_NEGOTIATE_56 | + NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | + NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | + NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; + if (ses->server->sign) { + flags |= NTLMSSP_NEGOTIATE_SIGN; + if (!ses->server->session_estab || + ses->ntlmssp->sesskey_per_smbsess) + flags |= NTLMSSP_NEGOTIATE_KEY_XCH; + } + + tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE); + sec_blob->NegotiateFlags = cpu_to_le32(flags); + + sec_blob->LmChallengeResponse.BufferOffset = + cpu_to_le32(sizeof(AUTHENTICATE_MESSAGE)); + sec_blob->LmChallengeResponse.Length = 0; + sec_blob->LmChallengeResponse.MaximumLength = 0; + + sec_blob->NtChallengeResponse.BufferOffset = + cpu_to_le32(tmp - *pbuffer); + if (ses->user_name != NULL) { + memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, + ses->auth_key.len - CIFS_SESS_KEY_SIZE); + tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; + + sec_blob->NtChallengeResponse.Length = + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); + sec_blob->NtChallengeResponse.MaximumLength = + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); + } else { + /* + * don't send an NT Response for anonymous access + */ + sec_blob->NtChallengeResponse.Length = 0; + sec_blob->NtChallengeResponse.MaximumLength = 0; + } + + if (ses->domainName == NULL) { + sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->DomainName.Length = 0; + sec_blob->DomainName.MaximumLength = 0; + tmp += 2; + } else { + int len; + len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, + CIFS_MAX_DOMAINNAME_LEN, nls_cp); + len *= 2; /* unicode is 2 bytes each */ + sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->DomainName.Length = cpu_to_le16(len); + sec_blob->DomainName.MaximumLength = cpu_to_le16(len); + tmp += len; + } + + if (ses->user_name == NULL) { + sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->UserName.Length = 0; + sec_blob->UserName.MaximumLength = 0; + tmp += 2; + } else { + int len; + len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, + CIFS_MAX_USERNAME_LEN, nls_cp); + len *= 2; /* unicode is 2 bytes each */ + sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->UserName.Length = cpu_to_le16(len); + sec_blob->UserName.MaximumLength = cpu_to_le16(len); + tmp += len; + } + + sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->WorkstationName.Length = 0; + sec_blob->WorkstationName.MaximumLength = 0; + tmp += 2; + + if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || + (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) + && !calc_seckey(ses)) { + memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); + sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE); + sec_blob->SessionKey.MaximumLength = + cpu_to_le16(CIFS_CPHTXT_SIZE); + tmp += CIFS_CPHTXT_SIZE; + } else { + sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->SessionKey.Length = 0; + sec_blob->SessionKey.MaximumLength = 0; + } + + *buflen = tmp - *pbuffer; +setup_ntlmv2_ret: + return rc; +} +",1,"int build_ntlmssp_auth_blob(unsigned char **pbuffer, + u16 *buflen, + struct cifs_ses *ses, + const struct nls_table *nls_cp) +{ + int rc; + AUTHENTICATE_MESSAGE *sec_blob; + __u32 flags; + unsigned char *tmp; + + rc = setup_ntlmv2_rsp(ses, nls_cp); + if (rc) { + cifs_dbg(VFS, ""Error %d during NTLMSSP authentication\n"", rc); + *buflen = 0; + goto setup_ntlmv2_ret; + } + *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL); + sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer; + + memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); + sec_blob->MessageType = NtLmAuthenticate; + + flags = NTLMSSP_NEGOTIATE_56 | + NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | + NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | + NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | + NTLMSSP_NEGOTIATE_SEAL; + if (ses->server->sign) + flags |= NTLMSSP_NEGOTIATE_SIGN; + if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) + flags |= NTLMSSP_NEGOTIATE_KEY_XCH; + + tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE); + sec_blob->NegotiateFlags = cpu_to_le32(flags); + + sec_blob->LmChallengeResponse.BufferOffset = + cpu_to_le32(sizeof(AUTHENTICATE_MESSAGE)); + sec_blob->LmChallengeResponse.Length = 0; + sec_blob->LmChallengeResponse.MaximumLength = 0; + + sec_blob->NtChallengeResponse.BufferOffset = + cpu_to_le32(tmp - *pbuffer); + if (ses->user_name != NULL) { + memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, + ses->auth_key.len - CIFS_SESS_KEY_SIZE); + tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; + + sec_blob->NtChallengeResponse.Length = + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); + sec_blob->NtChallengeResponse.MaximumLength = + cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); + } else { + /* + * don't send an NT Response for anonymous access + */ + sec_blob->NtChallengeResponse.Length = 0; + sec_blob->NtChallengeResponse.MaximumLength = 0; + } + + if (ses->domainName == NULL) { + sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->DomainName.Length = 0; + sec_blob->DomainName.MaximumLength = 0; + tmp += 2; + } else { + int len; + len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, + CIFS_MAX_DOMAINNAME_LEN, nls_cp); + len *= 2; /* unicode is 2 bytes each */ + sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->DomainName.Length = cpu_to_le16(len); + sec_blob->DomainName.MaximumLength = cpu_to_le16(len); + tmp += len; + } + + if (ses->user_name == NULL) { + sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->UserName.Length = 0; + sec_blob->UserName.MaximumLength = 0; + tmp += 2; + } else { + int len; + len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, + CIFS_MAX_USERNAME_LEN, nls_cp); + len *= 2; /* unicode is 2 bytes each */ + sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->UserName.Length = cpu_to_le16(len); + sec_blob->UserName.MaximumLength = cpu_to_le16(len); + tmp += len; + } + + sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->WorkstationName.Length = 0; + sec_blob->WorkstationName.MaximumLength = 0; + tmp += 2; + + if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || + (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) + && !calc_seckey(ses)) { + memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); + sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE); + sec_blob->SessionKey.MaximumLength = + cpu_to_le16(CIFS_CPHTXT_SIZE); + tmp += CIFS_CPHTXT_SIZE; + } else { + sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); + sec_blob->SessionKey.Length = 0; + sec_blob->SessionKey.MaximumLength = 0; + } + + *buflen = tmp - *pbuffer; +setup_ntlmv2_ret: + return rc; +} +","@@ -344,13 +344,12 @@ void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, + /* BB is NTLMV2 session security format easier to use here? */ + flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | + NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | +- NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; +- if (ses->server->sign) { ++ NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | ++ NTLMSSP_NEGOTIATE_SEAL; ++ if (ses->server->sign) + flags |= NTLMSSP_NEGOTIATE_SIGN; +- if (!ses->server->session_estab || +- ses->ntlmssp->sesskey_per_smbsess) +- flags |= NTLMSSP_NEGOTIATE_KEY_XCH; +- } ++ if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) ++ flags |= NTLMSSP_NEGOTIATE_KEY_XCH; + + sec_blob->NegotiateFlags = cpu_to_le32(flags); + +@@ -407,13 +406,12 @@ int build_ntlmssp_auth_blob(unsigned char **pbuffer, + flags = NTLMSSP_NEGOTIATE_56 | + NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | + NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | +- NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; +- if (ses->server->sign) { ++ NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | ++ NTLMSSP_NEGOTIATE_SEAL; ++ if (ses->server->sign) + flags |= NTLMSSP_NEGOTIATE_SIGN; +- if (!ses->server->session_estab || +- ses->ntlmssp->sesskey_per_smbsess) +- flags |= NTLMSSP_NEGOTIATE_KEY_XCH; +- } ++ if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) ++ flags |= NTLMSSP_NEGOTIATE_KEY_XCH; + + tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE); + sec_blob->NegotiateFlags = cpu_to_le32(flags);",1244,1480,2048 +11089,"void WebPagePrivate::zoomBlock() +{ + if (!m_mainFrame) + return; + + IntPoint anchor(roundUntransformedPoint(m_finalBlockPoint)); + bool willUseTextReflow = false; + +#if ENABLE(VIEWPORT_REFLOW) + willUseTextReflow = m_webPage->settings()->textReflowMode() != WebSettings::TextReflowDisabled; + toggleTextReflowIfEnabledForBlockZoomOnly(m_shouldReflowBlock); + setNeedsLayout(); +#endif + + TransformationMatrix zoom; + zoom.scale(m_blockZoomFinalScale); + *m_transformationMatrix = zoom; + m_backingStore->d->suspendBackingStoreUpdates(); + m_backingStore->d->suspendScreenUpdates(); + updateViewportSize(); + + FrameView* mainFrameView = m_mainFrame->view(); + bool constrainsScrollingToContentEdge = true; + if (mainFrameView) { + constrainsScrollingToContentEdge = mainFrameView->constrainsScrollingToContentEdge(); + mainFrameView->setConstrainsScrollingToContentEdge(m_shouldConstrainScrollingToContentEdge); + } + +#if ENABLE(VIEWPORT_REFLOW) + requestLayoutIfNeeded(); + if (willUseTextReflow && m_shouldReflowBlock) { + IntRect reflowedRect = rectForNode(m_currentBlockZoomAdjustedNode.get()); + reflowedRect = adjustRectOffsetForFrameOffset(reflowedRect, m_currentBlockZoomAdjustedNode.get()); + reflowedRect.move(roundTransformedPoint(m_finalBlockPointReflowOffset).x(), roundTransformedPoint(m_finalBlockPointReflowOffset).y()); + RenderObject* renderer = m_currentBlockZoomAdjustedNode->renderer(); + IntPoint topLeftPoint(reflowedRect.location()); + if (renderer && renderer->isText()) { + ETextAlign textAlign = renderer->style()->textAlign(); + IntPoint textAnchor; + switch (textAlign) { + case CENTER: + case WEBKIT_CENTER: + textAnchor = IntPoint(reflowedRect.x() + (reflowedRect.width() - actualVisibleSize().width()) / 2, topLeftPoint.y()); + break; + case LEFT: + case WEBKIT_LEFT: + textAnchor = topLeftPoint; + break; + case RIGHT: + case WEBKIT_RIGHT: + textAnchor = IntPoint(reflowedRect.x() + reflowedRect.width() - actualVisibleSize().width(), topLeftPoint.y()); + break; + case TAAUTO: + case JUSTIFY: + default: + if (renderer->style()->isLeftToRightDirection()) + textAnchor = topLeftPoint; + else + textAnchor = IntPoint(reflowedRect.x() + reflowedRect.width() - actualVisibleSize().width(), topLeftPoint.y()); + break; + } + setScrollPosition(textAnchor); + } else { + renderer->style()->isLeftToRightDirection() + ? setScrollPosition(topLeftPoint) + : setScrollPosition(IntPoint(reflowedRect.x() + reflowedRect.width() - actualVisibleSize().width(), topLeftPoint.y())); + } + } else if (willUseTextReflow) { + IntRect finalRect = rectForNode(m_currentBlockZoomAdjustedNode.get()); + finalRect = adjustRectOffsetForFrameOffset(finalRect, m_currentBlockZoomAdjustedNode.get()); + setScrollPosition(IntPoint(0, finalRect.y() + m_finalBlockPointReflowOffset.y())); + resetBlockZoom(); + } +#endif + if (!willUseTextReflow) { + setScrollPosition(anchor); + if (!m_shouldReflowBlock) + resetBlockZoom(); + } + + notifyTransformChanged(); + m_client->scaleChanged(); + + if (mainFrameView) + mainFrameView->setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdge); + + m_backingStore->d->resumeBackingStoreUpdates(); + m_backingStore->d->resumeScreenUpdates(BackingStore::RenderAndBlit); +} +",0,"void WebPagePrivate::zoomBlock() +{ + if (!m_mainFrame) + return; + + IntPoint anchor(roundUntransformedPoint(m_finalBlockPoint)); + bool willUseTextReflow = false; + +#if ENABLE(VIEWPORT_REFLOW) + willUseTextReflow = m_webPage->settings()->textReflowMode() != WebSettings::TextReflowDisabled; + toggleTextReflowIfEnabledForBlockZoomOnly(m_shouldReflowBlock); + setNeedsLayout(); +#endif + + TransformationMatrix zoom; + zoom.scale(m_blockZoomFinalScale); + *m_transformationMatrix = zoom; + m_backingStore->d->suspendBackingStoreUpdates(); + m_backingStore->d->suspendScreenUpdates(); + updateViewportSize(); + + FrameView* mainFrameView = m_mainFrame->view(); + bool constrainsScrollingToContentEdge = true; + if (mainFrameView) { + constrainsScrollingToContentEdge = mainFrameView->constrainsScrollingToContentEdge(); + mainFrameView->setConstrainsScrollingToContentEdge(m_shouldConstrainScrollingToContentEdge); + } + +#if ENABLE(VIEWPORT_REFLOW) + requestLayoutIfNeeded(); + if (willUseTextReflow && m_shouldReflowBlock) { + IntRect reflowedRect = rectForNode(m_currentBlockZoomAdjustedNode.get()); + reflowedRect = adjustRectOffsetForFrameOffset(reflowedRect, m_currentBlockZoomAdjustedNode.get()); + reflowedRect.move(roundTransformedPoint(m_finalBlockPointReflowOffset).x(), roundTransformedPoint(m_finalBlockPointReflowOffset).y()); + RenderObject* renderer = m_currentBlockZoomAdjustedNode->renderer(); + IntPoint topLeftPoint(reflowedRect.location()); + if (renderer && renderer->isText()) { + ETextAlign textAlign = renderer->style()->textAlign(); + IntPoint textAnchor; + switch (textAlign) { + case CENTER: + case WEBKIT_CENTER: + textAnchor = IntPoint(reflowedRect.x() + (reflowedRect.width() - actualVisibleSize().width()) / 2, topLeftPoint.y()); + break; + case LEFT: + case WEBKIT_LEFT: + textAnchor = topLeftPoint; + break; + case RIGHT: + case WEBKIT_RIGHT: + textAnchor = IntPoint(reflowedRect.x() + reflowedRect.width() - actualVisibleSize().width(), topLeftPoint.y()); + break; + case TAAUTO: + case JUSTIFY: + default: + if (renderer->style()->isLeftToRightDirection()) + textAnchor = topLeftPoint; + else + textAnchor = IntPoint(reflowedRect.x() + reflowedRect.width() - actualVisibleSize().width(), topLeftPoint.y()); + break; + } + setScrollPosition(textAnchor); + } else { + renderer->style()->isLeftToRightDirection() + ? setScrollPosition(topLeftPoint) + : setScrollPosition(IntPoint(reflowedRect.x() + reflowedRect.width() - actualVisibleSize().width(), topLeftPoint.y())); + } + } else if (willUseTextReflow) { + IntRect finalRect = rectForNode(m_currentBlockZoomAdjustedNode.get()); + finalRect = adjustRectOffsetForFrameOffset(finalRect, m_currentBlockZoomAdjustedNode.get()); + setScrollPosition(IntPoint(0, finalRect.y() + m_finalBlockPointReflowOffset.y())); + resetBlockZoom(); + } +#endif + if (!willUseTextReflow) { + setScrollPosition(anchor); + if (!m_shouldReflowBlock) + resetBlockZoom(); + } + + notifyTransformChanged(); + m_client->scaleChanged(); + + if (mainFrameView) + mainFrameView->setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdge); + + m_backingStore->d->resumeBackingStoreUpdates(); + m_backingStore->d->resumeScreenUpdates(BackingStore::RenderAndBlit); +} +","@@ -4058,11 +4058,6 @@ bool WebPage::touchEvent(const Platform::TouchEvent& event) + return d->dispatchTouchEventToFullScreenPlugin(pluginView, event); + + Platform::TouchEvent tEvent = event; +- for (unsigned i = 0; i < event.m_points.size(); i++) { +- tEvent.m_points[i].m_pos = d->mapFromTransformed(tEvent.m_points[i].m_pos); +- tEvent.m_points[i].m_screenPos = tEvent.m_points[i].m_screenPos; +- } +- + if (event.isSingleTap()) + d->m_pluginMayOpenNewTab = true; + else if (tEvent.m_type == Platform::TouchEvent::TouchStart || tEvent.m_type == Platform::TouchEvent::TouchCancel) +@@ -4132,10 +4127,7 @@ void WebPage::touchPointAsMouseEvent(const Platform::TouchPoint& point, unsigned + + d->m_lastUserEventTimestamp = currentTime(); + +- Platform::TouchPoint tPoint = point; +- tPoint.m_pos = d->mapFromTransformed(tPoint.m_pos); +- +- d->m_touchEventHandler->handleTouchPoint(tPoint, modifiers); ++ d->m_touchEventHandler->handleTouchPoint(point, modifiers); + } + + void WebPage::playSoundIfAnchorIsTarget() const +@@ -4165,13 +4157,13 @@ bool WebPagePrivate::dispatchTouchEventToFullScreenPlugin(PluginView* plugin, co + if (npTouchEvent.size) { + npTouchEvent.points = new NPTouchPoint[npTouchEvent.size]; + for (int i = 0; i < npTouchEvent.size; i++) { +- npTouchEvent.points[i].touchId = event.m_points[i].m_id; +- npTouchEvent.points[i].clientX = event.m_points[i].m_screenPos.x(); +- npTouchEvent.points[i].clientY = event.m_points[i].m_screenPos.y(); +- npTouchEvent.points[i].screenX = event.m_points[i].m_screenPos.x(); +- npTouchEvent.points[i].screenY = event.m_points[i].m_screenPos.y(); +- npTouchEvent.points[i].pageX = event.m_points[i].m_pos.x(); +- npTouchEvent.points[i].pageY = event.m_points[i].m_pos.y(); ++ npTouchEvent.points[i].touchId = event.m_points[i].id(); ++ npTouchEvent.points[i].clientX = event.m_points[i].screenPosition().x(); ++ npTouchEvent.points[i].clientY = event.m_points[i].screenPosition().y(); ++ npTouchEvent.points[i].screenX = event.m_points[i].screenPosition().x(); ++ npTouchEvent.points[i].screenY = event.m_points[i].screenPosition().y(); ++ npTouchEvent.points[i].pageX = event.m_points[i].pixelViewportPosition().x(); ++ npTouchEvent.points[i].pageY = event.m_points[i].pixelViewportPosition().y(); + } + } + +@@ -4193,7 +4185,7 @@ bool WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin(PluginView + NPEvent npEvent; + NPMouseEvent mouse; + +- switch (point.m_state) { ++ switch (point.state()) { + case Platform::TouchPoint::TouchPressed: + mouse.type = MOUSE_BUTTON_DOWN; + break; +@@ -4207,8 +4199,8 @@ bool WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin(PluginView + return true; + } + +- mouse.x = point.m_screenPos.x(); +- mouse.y = point.m_screenPos.y(); ++ mouse.x = point.screenPosition().x(); ++ mouse.y = point.screenPosition().y(); + mouse.button = mouse.type != MOUSE_BUTTON_UP; + mouse.flags = 0; + npEvent.type = NP_MouseEvent;",842,1078,2048 +11681,"png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, + png_bytep prev_row, int filter) +{ + png_debug(1, ""in png_read_filter_row""); + png_debug2(2, ""row = %lu, filter = %d"", png_ptr->row_number, filter); + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + case PNG_FILTER_VALUE_SUB: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_UP: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_AVG: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *lp++) / 2 ) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_PAETH: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* Use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + break; + } + default: + png_warning(png_ptr, ""Ignoring bad adaptive filter type""); + *row = 0; + break; + } +} +",0,"png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, + png_bytep prev_row, int filter) +{ + png_debug(1, ""in png_read_filter_row""); + png_debug2(2, ""row = %lu, filter = %d"", png_ptr->row_number, filter); + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + case PNG_FILTER_VALUE_SUB: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_UP: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_AVG: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *lp++) / 2 ) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_PAETH: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* Use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + break; + } + default: + png_warning(png_ptr, ""Ignoring bad adaptive filter type""); + *row = 0; + break; + } +} +","@@ -247,8 +247,8 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size, + { + if (output != 0 && output_size > count) + { +- int copy = output_size - count; +- if (avail < copy) copy = avail; ++ png_size_t copy = output_size - count; ++ if ((png_size_t) avail < copy) copy = (png_size_t) avail; + png_memcpy(output + count, png_ptr->zbuf, copy); + } + count += avail;",911,1147,2048 +17999,"static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + int closing, int tx_ring) +{ + struct pgv *pg_vec = NULL; + struct packet_sock *po = pkt_sk(sk); + int was_running, order = 0; + struct packet_ring_buffer *rb; + struct sk_buff_head *rb_queue; + __be16 num; + int err = -EINVAL; + /* Added to avoid minimal code churn */ + struct tpacket_req *req = &req_u->req; + + /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ + if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { + net_warn_ratelimited(""Tx-ring is not supported.\n""); + goto out; + } + + rb = tx_ring ? &po->tx_ring : &po->rx_ring; + rb_queue = tx_ring ? &sk->sk_write_queue : &sk->sk_receive_queue; + + err = -EBUSY; + if (!closing) { + if (atomic_read(&po->mapped)) + goto out; + if (packet_read_pending(rb)) + goto out; + } + + if (req->tp_block_nr) { + /* Sanity tests and some calculations */ + err = -EBUSY; + if (unlikely(rb->pg_vec)) + goto out; + + switch (po->tp_version) { + case TPACKET_V1: + po->tp_hdrlen = TPACKET_HDRLEN; + break; + case TPACKET_V2: + po->tp_hdrlen = TPACKET2_HDRLEN; + break; + case TPACKET_V3: + po->tp_hdrlen = TPACKET3_HDRLEN; + break; + } + + err = -EINVAL; + if (unlikely((int)req->tp_block_size <= 0)) + goto out; + if (unlikely(!PAGE_ALIGNED(req->tp_block_size))) + goto out; + if (po->tp_version >= TPACKET_V3 && + (int)(req->tp_block_size - + BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0) + goto out; + if (unlikely(req->tp_frame_size < po->tp_hdrlen + + po->tp_reserve)) + goto out; + if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1))) + goto out; + + rb->frames_per_block = req->tp_block_size / req->tp_frame_size; + if (unlikely(rb->frames_per_block == 0)) + goto out; + if (unlikely((rb->frames_per_block * req->tp_block_nr) != + req->tp_frame_nr)) + goto out; + + err = -ENOMEM; + order = get_order(req->tp_block_size); + pg_vec = alloc_pg_vec(req, order); + if (unlikely(!pg_vec)) + goto out; + switch (po->tp_version) { + case TPACKET_V3: + /* Transmit path is not supported. We checked + * it above but just being paranoid + */ + if (!tx_ring) + init_prb_bdqc(po, rb, pg_vec, req_u); + break; + default: + break; + } + } + /* Done */ + else { + err = -EINVAL; + if (unlikely(req->tp_frame_nr)) + goto out; + } + + lock_sock(sk); + + /* Detach socket from network */ + spin_lock(&po->bind_lock); + was_running = po->running; + num = po->num; + if (was_running) { + po->num = 0; + __unregister_prot_hook(sk, false); + } + spin_unlock(&po->bind_lock); + + synchronize_net(); + + err = -EBUSY; + mutex_lock(&po->pg_vec_lock); + if (closing || atomic_read(&po->mapped) == 0) { + err = 0; + spin_lock_bh(&rb_queue->lock); + swap(rb->pg_vec, pg_vec); + rb->frame_max = (req->tp_frame_nr - 1); + rb->head = 0; + rb->frame_size = req->tp_frame_size; + spin_unlock_bh(&rb_queue->lock); + + swap(rb->pg_vec_order, order); + swap(rb->pg_vec_len, req->tp_block_nr); + + rb->pg_vec_pages = req->tp_block_size/PAGE_SIZE; + po->prot_hook.func = (po->rx_ring.pg_vec) ? + tpacket_rcv : packet_rcv; + skb_queue_purge(rb_queue); + if (atomic_read(&po->mapped)) + pr_err(""packet_mmap: vma is busy: %d\n"", + atomic_read(&po->mapped)); + } + mutex_unlock(&po->pg_vec_lock); + + spin_lock(&po->bind_lock); + if (was_running) { + po->num = num; + register_prot_hook(sk); + } + spin_unlock(&po->bind_lock); + if (closing && (po->tp_version > TPACKET_V2)) { + /* Because we don't support block-based V3 on tx-ring */ + if (!tx_ring) + prb_shutdown_retire_blk_timer(po, rb_queue); + } + release_sock(sk); + + if (pg_vec) + free_pg_vec(pg_vec, order, req->tp_block_nr); + out: + return err; + } +",1,"static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + int closing, int tx_ring) +{ + struct pgv *pg_vec = NULL; + struct packet_sock *po = pkt_sk(sk); + int was_running, order = 0; + struct packet_ring_buffer *rb; + struct sk_buff_head *rb_queue; + __be16 num; + int err = -EINVAL; + /* Added to avoid minimal code churn */ + struct tpacket_req *req = &req_u->req; + + lock_sock(sk); + /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ + if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { + net_warn_ratelimited(""Tx-ring is not supported.\n""); + goto out; + } + + rb = tx_ring ? &po->tx_ring : &po->rx_ring; + rb_queue = tx_ring ? &sk->sk_write_queue : &sk->sk_receive_queue; + + err = -EBUSY; + if (!closing) { + if (atomic_read(&po->mapped)) + goto out; + if (packet_read_pending(rb)) + goto out; + } + + if (req->tp_block_nr) { + /* Sanity tests and some calculations */ + err = -EBUSY; + if (unlikely(rb->pg_vec)) + goto out; + + switch (po->tp_version) { + case TPACKET_V1: + po->tp_hdrlen = TPACKET_HDRLEN; + break; + case TPACKET_V2: + po->tp_hdrlen = TPACKET2_HDRLEN; + break; + case TPACKET_V3: + po->tp_hdrlen = TPACKET3_HDRLEN; + break; + } + + err = -EINVAL; + if (unlikely((int)req->tp_block_size <= 0)) + goto out; + if (unlikely(!PAGE_ALIGNED(req->tp_block_size))) + goto out; + if (po->tp_version >= TPACKET_V3 && + (int)(req->tp_block_size - + BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0) + goto out; + if (unlikely(req->tp_frame_size < po->tp_hdrlen + + po->tp_reserve)) + goto out; + if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1))) + goto out; + + rb->frames_per_block = req->tp_block_size / req->tp_frame_size; + if (unlikely(rb->frames_per_block == 0)) + goto out; + if (unlikely((rb->frames_per_block * req->tp_block_nr) != + req->tp_frame_nr)) + goto out; + + err = -ENOMEM; + order = get_order(req->tp_block_size); + pg_vec = alloc_pg_vec(req, order); + if (unlikely(!pg_vec)) + goto out; + switch (po->tp_version) { + case TPACKET_V3: + /* Transmit path is not supported. We checked + * it above but just being paranoid + */ + if (!tx_ring) + init_prb_bdqc(po, rb, pg_vec, req_u); + break; + default: + break; + } + } + /* Done */ + else { + err = -EINVAL; + if (unlikely(req->tp_frame_nr)) + goto out; + } + + + /* Detach socket from network */ + spin_lock(&po->bind_lock); + was_running = po->running; + num = po->num; + if (was_running) { + po->num = 0; + __unregister_prot_hook(sk, false); + } + spin_unlock(&po->bind_lock); + + synchronize_net(); + + err = -EBUSY; + mutex_lock(&po->pg_vec_lock); + if (closing || atomic_read(&po->mapped) == 0) { + err = 0; + spin_lock_bh(&rb_queue->lock); + swap(rb->pg_vec, pg_vec); + rb->frame_max = (req->tp_frame_nr - 1); + rb->head = 0; + rb->frame_size = req->tp_frame_size; + spin_unlock_bh(&rb_queue->lock); + + swap(rb->pg_vec_order, order); + swap(rb->pg_vec_len, req->tp_block_nr); + + rb->pg_vec_pages = req->tp_block_size/PAGE_SIZE; + po->prot_hook.func = (po->rx_ring.pg_vec) ? + tpacket_rcv : packet_rcv; + skb_queue_purge(rb_queue); + if (atomic_read(&po->mapped)) + pr_err(""packet_mmap: vma is busy: %d\n"", + atomic_read(&po->mapped)); + } + mutex_unlock(&po->pg_vec_lock); + + spin_lock(&po->bind_lock); + if (was_running) { + po->num = num; + register_prot_hook(sk); + } + spin_unlock(&po->bind_lock); + if (closing && (po->tp_version > TPACKET_V2)) { + /* Because we don't support block-based V3 on tx-ring */ + if (!tx_ring) + prb_shutdown_retire_blk_timer(po, rb_queue); + } + + if (pg_vec) + free_pg_vec(pg_vec, order, req->tp_block_nr); + out: + release_sock(sk); + return err; + } +","@@ -3648,19 +3648,25 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv + + if (optlen != sizeof(val)) + return -EINVAL; +- if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) +- return -EBUSY; + if (copy_from_user(&val, optval, sizeof(val))) + return -EFAULT; + switch (val) { + case TPACKET_V1: + case TPACKET_V2: + case TPACKET_V3: +- po->tp_version = val; +- return 0; ++ break; + default: + return -EINVAL; + } ++ lock_sock(sk); ++ if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { ++ ret = -EBUSY; ++ } else { ++ po->tp_version = val; ++ ret = 0; ++ } ++ release_sock(sk); ++ return ret; + } + case PACKET_RESERVE: + { +@@ -4164,6 +4170,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + /* Added to avoid minimal code churn */ + struct tpacket_req *req = &req_u->req; + ++ lock_sock(sk); + /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ + if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { + net_warn_ratelimited(""Tx-ring is not supported.\n""); +@@ -4245,7 +4252,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + goto out; + } + +- lock_sock(sk); + + /* Detach socket from network */ + spin_lock(&po->bind_lock); +@@ -4294,11 +4300,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + if (!tx_ring) + prb_shutdown_retire_blk_timer(po, rb_queue); + } +- release_sock(sk); + + if (pg_vec) + free_pg_vec(pg_vec, order, req->tp_block_nr); + out: ++ release_sock(sk); + return err; + } + ",1155,1391,2048 +18786,"FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, unsigned length) +{ + FLAC__uint32 i; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + /* read vendor string */ + if (length >= 8) { + length -= 8; /* vendor string length + num comments entries alone take 8 bytes */ + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + if (obj->vendor_string.length > 0) { + if (length < obj->vendor_string.length) { + obj->vendor_string.length = 0; + obj->vendor_string.entry = 0; + goto skip; + } + else + length -= obj->vendor_string.length; + if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + obj->vendor_string.entry[obj->vendor_string.length] = '\0'; + } + else + obj->vendor_string.entry = 0; + + /* read num comments */ + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN == 32); + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) + return false; /* read_callback_ sets the state for us */ + + /* read comments */ + if (obj->num_comments > 100000) { + /* Possibly malicious file. */ + obj->num_comments = 0; + return false; + } + + if (obj->num_comments > 0) { + if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + for (i = 0; i < obj->num_comments; i++) { + /* Initialize here just to make sure. */ + obj->comments[i].length = 0; + obj->comments[i].entry = 0; + + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); + if (length < 4) { + obj->num_comments = i; + goto skip; + } + else + length -= 4; + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)) + return false; /* read_callback_ sets the state for us */ + if (obj->comments[i].length > 0) { + if (length < obj->comments[i].length) { + obj->num_comments = i; + goto skip; + } + else + length -= obj->comments[i].length; + if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + memset (obj->comments[i].entry, 0, obj->comments[i].length) ; + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) { + obj->num_comments = i; + goto skip; + } + obj->comments[i].entry[obj->comments[i].length] = '\0'; + } + else + obj->comments[i].entry = 0; + } + } + else + obj->comments = 0; + } + + skip: + if (length > 0) { + /* This will only happen on files with invalid data in comments */ + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) + return false; /* read_callback_ sets the state for us */ + } + + return true; +} +",1,"FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, unsigned length) +{ + FLAC__uint32 i; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + /* read vendor string */ + if (length >= 8) { + length -= 8; /* vendor string length + num comments entries alone take 8 bytes */ + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + if (obj->vendor_string.length > 0) { + if (length < obj->vendor_string.length) { + obj->vendor_string.length = 0; + obj->vendor_string.entry = 0; + goto skip; + } + else + length -= obj->vendor_string.length; + if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + obj->vendor_string.entry[obj->vendor_string.length] = '\0'; + } + else + obj->vendor_string.entry = 0; + + /* read num comments */ + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN == 32); + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) + return false; /* read_callback_ sets the state for us */ + + /* read comments */ + if (obj->num_comments > 100000) { + /* Possibly malicious file. */ + obj->num_comments = 0; + return false; + } + + if (obj->num_comments > 0) { + if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + obj->num_comments = 0; + return false; + } + for (i = 0; i < obj->num_comments; i++) { + /* Initialize here just to make sure. */ + obj->comments[i].length = 0; + obj->comments[i].entry = 0; + + FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); + if (length < 4) { + obj->num_comments = i; + goto skip; + } + else + length -= 4; + if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)) + return false; /* read_callback_ sets the state for us */ + if (obj->comments[i].length > 0) { + if (length < obj->comments[i].length) { + obj->num_comments = i; + goto skip; + } + else + length -= obj->comments[i].length; + if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + memset (obj->comments[i].entry, 0, obj->comments[i].length) ; + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) { + obj->num_comments = i; + goto skip; + } + obj->comments[i].entry[obj->comments[i].length] = '\0'; + } + else + obj->comments[i].entry = 0; + } + } + else + obj->comments = 0; + } + + skip: + if (length > 0) { + /* This will only happen on files with invalid data in comments */ + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) + return false; /* read_callback_ sets the state for us */ + } + + return true; +} +","@@ -1739,6 +1739,7 @@ + + if (obj->num_comments > 0) { + if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; ++ obj->num_comments = 0; + return false; + } + for (i = 0; i < obj->num_comments; i++) { +",959,1195,2048 +8917,"static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) +{ + char *bootm_argv[] = { ""bootm"", NULL, NULL, NULL, NULL }; + char initrd_str[28]; + char mac_str[29] = """"; + char ip_str[68] = """"; + char *fit_addr = NULL; + int bootm_argc = 2; + int len = 0; + ulong kernel_addr; + void *buf; + + label_print(label); + + label->attempted = 1; + + if (label->localboot) { + if (label->localboot_val >= 0) + label_localboot(label); + return 0; + } + + if (!label->kernel) { + printf(""No kernel given, skipping %s\n"", + label->name); + return 1; + } + + if (label->initrd) { + if (get_relfile_envaddr(cmdtp, label->initrd, ""ramdisk_addr_r"") < 0) { + printf(""Skipping %s for failure retrieving initrd\n"", + label->name); + return 1; + } + + bootm_argv[2] = initrd_str; + strncpy(bootm_argv[2], env_get(""ramdisk_addr_r""), 18); + strcat(bootm_argv[2], "":""); + strncat(bootm_argv[2], env_get(""filesize""), 9); + bootm_argc = 3; + } + + if (get_relfile_envaddr(cmdtp, label->kernel, ""kernel_addr_r"") < 0) { + printf(""Skipping %s for failure retrieving kernel\n"", + label->name); + return 1; + } + + if (label->ipappend & 0x1) { + sprintf(ip_str, "" ip=%s:%s:%s:%s"", + env_get(""ipaddr""), env_get(""serverip""), + env_get(""gatewayip""), env_get(""netmask"")); + } + +#ifdef CONFIG_CMD_NET + if (label->ipappend & 0x2) { + int err; + + strcpy(mac_str, "" BOOTIF=""); + err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); + if (err < 0) + mac_str[0] = '\0'; + } +#endif + + if ((label->ipappend & 0x3) || label->append) { + char bootargs[CONFIG_SYS_CBSIZE] = """"; + char finalbootargs[CONFIG_SYS_CBSIZE]; + + if (strlen(label->append ?: """") + + strlen(ip_str) + strlen(mac_str) + 1 > sizeof(bootargs)) { + printf(""bootarg overflow %zd+%zd+%zd+1 > %zd\n"", + strlen(label->append ?: """"), + strlen(ip_str), strlen(mac_str), + sizeof(bootargs)); + return 1; + } + + if (label->append) + strncpy(bootargs, label->append, sizeof(bootargs)); + + strcat(bootargs, ip_str); + strcat(bootargs, mac_str); + + cli_simple_process_macros(bootargs, finalbootargs); + env_set(""bootargs"", finalbootargs); + printf(""append: %s\n"", finalbootargs); + } + + bootm_argv[1] = env_get(""kernel_addr_r""); + /* for FIT, append the configuration identifier */ + if (label->config) { + int len = strlen(bootm_argv[1]) + strlen(label->config) + 1; + + fit_addr = malloc(len); + if (!fit_addr) { + printf(""malloc fail (FIT address)\n""); + return 1; + } + snprintf(fit_addr, len, ""%s%s"", bootm_argv[1], label->config); + bootm_argv[1] = fit_addr; + } + + /* + * fdt usage is optional: + * It handles the following scenarios. All scenarios are exclusive + * + * Scenario 1: If fdt_addr_r specified and ""fdt"" label is defined in + * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm, + * and adjust argc appropriately. + * + * Scenario 2: If there is an fdt_addr specified, pass it along to + * bootm, and adjust argc appropriately. + * + * Scenario 3: fdt blob is not available. + */ + bootm_argv[3] = env_get(""fdt_addr_r""); + + /* if fdt label is defined then get fdt from server */ + if (bootm_argv[3]) { + char *fdtfile = NULL; + char *fdtfilefree = NULL; + + if (label->fdt) { + fdtfile = label->fdt; + } else if (label->fdtdir) { + char *f1, *f2, *f3, *f4, *slash; + + f1 = env_get(""fdtfile""); + if (f1) { + f2 = """"; + f3 = """"; + f4 = """"; + } else { + /* + * For complex cases where this code doesn't + * generate the correct filename, the board + * code should set $fdtfile during early boot, + * or the boot scripts should set $fdtfile + * before invoking ""pxe"" or ""sysboot"". + */ + f1 = env_get(""soc""); + f2 = ""-""; + f3 = env_get(""board""); + f4 = "".dtb""; + } + + len = strlen(label->fdtdir); + if (!len) + slash = ""./""; + else if (label->fdtdir[len - 1] != '/') + slash = ""/""; + else + slash = """"; + + len = strlen(label->fdtdir) + strlen(slash) + + strlen(f1) + strlen(f2) + strlen(f3) + + strlen(f4) + 1; + fdtfilefree = malloc(len); + if (!fdtfilefree) { + printf(""malloc fail (FDT filename)\n""); + goto cleanup; + } + + snprintf(fdtfilefree, len, ""%s%s%s%s%s%s"", + label->fdtdir, slash, f1, f2, f3, f4); + fdtfile = fdtfilefree; + } + + if (fdtfile) { + int err = get_relfile_envaddr(cmdtp, fdtfile, + ""fdt_addr_r""); + + free(fdtfilefree); + if (err < 0) { + printf(""Skipping %s for failure retrieving fdt\n"", + label->name); + goto cleanup; + } + } else { + bootm_argv[3] = NULL; + } + } + + if (!bootm_argv[3]) + bootm_argv[3] = env_get(""fdt_addr""); + + if (bootm_argv[3]) { + if (!bootm_argv[2]) + bootm_argv[2] = ""-""; + bootm_argc = 4; + } + + kernel_addr = genimg_get_kernel_addr(bootm_argv[1]); + buf = map_sysmem(kernel_addr, 0); + /* Try bootm for legacy and FIT format image */ + if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID) + do_bootm(cmdtp, 0, bootm_argc, bootm_argv); +#ifdef CONFIG_CMD_BOOTI + /* Try booting an AArch64 Linux kernel image */ + else + do_booti(cmdtp, 0, bootm_argc, bootm_argv); +#elif defined(CONFIG_CMD_BOOTZ) + /* Try booting a Image */ + else + do_bootz(cmdtp, 0, bootm_argc, bootm_argv); +#endif + unmap_sysmem(buf); + +cleanup: + if (fit_addr) + free(fit_addr); + return 1; +} +",0,"static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) +{ + char *bootm_argv[] = { ""bootm"", NULL, NULL, NULL, NULL }; + char initrd_str[28]; + char mac_str[29] = """"; + char ip_str[68] = """"; + char *fit_addr = NULL; + int bootm_argc = 2; + int len = 0; + ulong kernel_addr; + void *buf; + + label_print(label); + + label->attempted = 1; + + if (label->localboot) { + if (label->localboot_val >= 0) + label_localboot(label); + return 0; + } + + if (!label->kernel) { + printf(""No kernel given, skipping %s\n"", + label->name); + return 1; + } + + if (label->initrd) { + if (get_relfile_envaddr(cmdtp, label->initrd, ""ramdisk_addr_r"") < 0) { + printf(""Skipping %s for failure retrieving initrd\n"", + label->name); + return 1; + } + + bootm_argv[2] = initrd_str; + strncpy(bootm_argv[2], env_get(""ramdisk_addr_r""), 18); + strcat(bootm_argv[2], "":""); + strncat(bootm_argv[2], env_get(""filesize""), 9); + bootm_argc = 3; + } + + if (get_relfile_envaddr(cmdtp, label->kernel, ""kernel_addr_r"") < 0) { + printf(""Skipping %s for failure retrieving kernel\n"", + label->name); + return 1; + } + + if (label->ipappend & 0x1) { + sprintf(ip_str, "" ip=%s:%s:%s:%s"", + env_get(""ipaddr""), env_get(""serverip""), + env_get(""gatewayip""), env_get(""netmask"")); + } + +#ifdef CONFIG_CMD_NET + if (label->ipappend & 0x2) { + int err; + + strcpy(mac_str, "" BOOTIF=""); + err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); + if (err < 0) + mac_str[0] = '\0'; + } +#endif + + if ((label->ipappend & 0x3) || label->append) { + char bootargs[CONFIG_SYS_CBSIZE] = """"; + char finalbootargs[CONFIG_SYS_CBSIZE]; + + if (strlen(label->append ?: """") + + strlen(ip_str) + strlen(mac_str) + 1 > sizeof(bootargs)) { + printf(""bootarg overflow %zd+%zd+%zd+1 > %zd\n"", + strlen(label->append ?: """"), + strlen(ip_str), strlen(mac_str), + sizeof(bootargs)); + return 1; + } + + if (label->append) + strncpy(bootargs, label->append, sizeof(bootargs)); + + strcat(bootargs, ip_str); + strcat(bootargs, mac_str); + + cli_simple_process_macros(bootargs, finalbootargs); + env_set(""bootargs"", finalbootargs); + printf(""append: %s\n"", finalbootargs); + } + + bootm_argv[1] = env_get(""kernel_addr_r""); + /* for FIT, append the configuration identifier */ + if (label->config) { + int len = strlen(bootm_argv[1]) + strlen(label->config) + 1; + + fit_addr = malloc(len); + if (!fit_addr) { + printf(""malloc fail (FIT address)\n""); + return 1; + } + snprintf(fit_addr, len, ""%s%s"", bootm_argv[1], label->config); + bootm_argv[1] = fit_addr; + } + + /* + * fdt usage is optional: + * It handles the following scenarios. All scenarios are exclusive + * + * Scenario 1: If fdt_addr_r specified and ""fdt"" label is defined in + * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm, + * and adjust argc appropriately. + * + * Scenario 2: If there is an fdt_addr specified, pass it along to + * bootm, and adjust argc appropriately. + * + * Scenario 3: fdt blob is not available. + */ + bootm_argv[3] = env_get(""fdt_addr_r""); + + /* if fdt label is defined then get fdt from server */ + if (bootm_argv[3]) { + char *fdtfile = NULL; + char *fdtfilefree = NULL; + + if (label->fdt) { + fdtfile = label->fdt; + } else if (label->fdtdir) { + char *f1, *f2, *f3, *f4, *slash; + + f1 = env_get(""fdtfile""); + if (f1) { + f2 = """"; + f3 = """"; + f4 = """"; + } else { + /* + * For complex cases where this code doesn't + * generate the correct filename, the board + * code should set $fdtfile during early boot, + * or the boot scripts should set $fdtfile + * before invoking ""pxe"" or ""sysboot"". + */ + f1 = env_get(""soc""); + f2 = ""-""; + f3 = env_get(""board""); + f4 = "".dtb""; + } + + len = strlen(label->fdtdir); + if (!len) + slash = ""./""; + else if (label->fdtdir[len - 1] != '/') + slash = ""/""; + else + slash = """"; + + len = strlen(label->fdtdir) + strlen(slash) + + strlen(f1) + strlen(f2) + strlen(f3) + + strlen(f4) + 1; + fdtfilefree = malloc(len); + if (!fdtfilefree) { + printf(""malloc fail (FDT filename)\n""); + goto cleanup; + } + + snprintf(fdtfilefree, len, ""%s%s%s%s%s%s"", + label->fdtdir, slash, f1, f2, f3, f4); + fdtfile = fdtfilefree; + } + + if (fdtfile) { + int err = get_relfile_envaddr(cmdtp, fdtfile, + ""fdt_addr_r""); + + free(fdtfilefree); + if (err < 0) { + printf(""Skipping %s for failure retrieving fdt\n"", + label->name); + goto cleanup; + } + } else { + bootm_argv[3] = NULL; + } + } + + if (!bootm_argv[3]) + bootm_argv[3] = env_get(""fdt_addr""); + + if (bootm_argv[3]) { + if (!bootm_argv[2]) + bootm_argv[2] = ""-""; + bootm_argc = 4; + } + + kernel_addr = genimg_get_kernel_addr(bootm_argv[1]); + buf = map_sysmem(kernel_addr, 0); + /* Try bootm for legacy and FIT format image */ + if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID) + do_bootm(cmdtp, 0, bootm_argc, bootm_argv); +#ifdef CONFIG_CMD_BOOTI + /* Try booting an AArch64 Linux kernel image */ + else + do_booti(cmdtp, 0, bootm_argc, bootm_argv); +#elif defined(CONFIG_CMD_BOOTZ) + /* Try booting a Image */ + else + do_bootz(cmdtp, 0, bootm_argc, bootm_argv); +#endif + unmap_sysmem(buf); + +cleanup: + if (fit_addr) + free(fit_addr); + return 1; +} +","@@ -1312,7 +1312,8 @@ void handle_pxe_menu(cmd_tbl_t *cmdtp, struct pxe_menu *cfg) + /* display BMP if available */ + if (cfg->bmp) { + if (get_relfile(cmdtp, cfg->bmp, image_load_addr)) { +- run_command(""cls"", 0); ++ if (CONFIG_IS_ENABLED(CMD_CLS)) ++ run_command(""cls"", 0); + bmp_display(image_load_addr, + BMP_ALIGN_CENTER, BMP_ALIGN_CENTER); + } else {",1701,1937,2048 +7326,"static int UnpackWPG2Raster(Image *image,int bpp) +{ + int XorMe = 0; + + int + RunCount; + + size_t + x, + y; + + ssize_t + i, + ldblk; + + unsigned int + SampleSize=1; + + unsigned char + bbuf, + *BImgBuff, + SampleBuffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + x=0; + y=0; + ldblk=(ssize_t) ((bpp*image->columns+7)/8); + BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, + sizeof(*BImgBuff)); + if(BImgBuff==NULL) + return(-2); + + while( y< image->rows) + { + bbuf=ReadBlobByte(image); + + switch(bbuf) + { + case 0x7D: + SampleSize=ReadBlobByte(image); /* DSZ */ + if(SampleSize>8) + return(-2); + if(SampleSize<1) + return(-2); + break; + case 0x7E: + (void) FormatLocaleFile(stderr, + ""\nUnsupported WPG token XOR, please report!""); + XorMe=!XorMe; + break; + case 0x7F: + RunCount=ReadBlobByte(image); /* BLK */ + if (RunCount < 0) + break; + for(i=0; i < SampleSize*(RunCount+1); i++) + { + InsertByte6(0); + } + break; + case 0xFD: + RunCount=ReadBlobByte(image); /* EXT */ + if (RunCount < 0) + break; + for(i=0; i<= RunCount;i++) + for(bbuf=0; bbuf < SampleSize; bbuf++) + InsertByte6(SampleBuffer[bbuf]); + break; + case 0xFE: + RunCount=ReadBlobByte(image); /* RST */ + if (RunCount < 0) + break; + if(x!=0) + { + (void) FormatLocaleFile(stderr, + ""\nUnsupported WPG2 unaligned token RST x=%.20g, please report!\n"" + ,(double) x); + return(-3); + } + { + /* duplicate the previous row RunCount x */ + for(i=0;i<=RunCount;i++) + { + InsertRow(BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1), + image,bpp); + y++; + } + } + break; + case 0xFF: + RunCount=ReadBlobByte(image); /* WHT */ + if (RunCount < 0) + break; + for (i=0; i < SampleSize*(RunCount+1); i++) + { + InsertByte6(0xFF); + } + break; + default: + RunCount=bbuf & 0x7F; + + if(bbuf & 0x80) /* REP */ + { + for(i=0; i < SampleSize; i++) + SampleBuffer[i]=ReadBlobByte(image); + for(i=0;i<=RunCount;i++) + for(bbuf=0;bbufcolumns+7)/8); + BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, + sizeof(*BImgBuff)); + if(BImgBuff==NULL) + return(-2); + + while( y< image->rows) + { + bbuf=ReadBlobByte(image); + + switch(bbuf) + { + case 0x7D: + SampleSize=ReadBlobByte(image); /* DSZ */ + if(SampleSize>8) + return(-2); + if(SampleSize<1) + return(-2); + break; + case 0x7E: + (void) FormatLocaleFile(stderr, + ""\nUnsupported WPG token XOR, please report!""); + XorMe=!XorMe; + break; + case 0x7F: + RunCount=ReadBlobByte(image); /* BLK */ + if (RunCount < 0) + break; + for(i=0; i < SampleSize*(RunCount+1); i++) + { + InsertByte6(0); + } + break; + case 0xFD: + RunCount=ReadBlobByte(image); /* EXT */ + if (RunCount < 0) + break; + for(i=0; i<= RunCount;i++) + for(bbuf=0; bbuf < SampleSize; bbuf++) + InsertByte6(SampleBuffer[bbuf]); + break; + case 0xFE: + RunCount=ReadBlobByte(image); /* RST */ + if (RunCount < 0) + break; + if(x!=0) + { + (void) FormatLocaleFile(stderr, + ""\nUnsupported WPG2 unaligned token RST x=%.20g, please report!\n"" + ,(double) x); + return(-3); + } + { + /* duplicate the previous row RunCount x */ + for(i=0;i<=RunCount;i++) + { + InsertRow(BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1), + image,bpp); + y++; + } + } + break; + case 0xFF: + RunCount=ReadBlobByte(image); /* WHT */ + if (RunCount < 0) + break; + for (i=0; i < SampleSize*(RunCount+1); i++) + { + InsertByte6(0xFF); + } + break; + default: + RunCount=bbuf & 0x7F; + + if(bbuf & 0x80) /* REP */ + { + for(i=0; i < SampleSize; i++) + SampleBuffer[i]=ReadBlobByte(image); + for(i=0;i<=RunCount;i++) + for(bbuf=0;bbufseverity != UndefinedException) goto FINISH_UNL; + if(magic_info->name == (char *) NULL) goto FINISH_UNL; + +- (void) CopyMagickMemory(clone_info->magick,magic_info->name,MaxTextExtent); ++ (void) strncpy(clone_info->magick,magic_info->name,MaxTextExtent); + + /* Read nested image */ + /*FormatString(clone_info->filename,""%s:%s"",magic_info->name,postscript_file);*/",817,1053,2048 +6149,"static int nsv_parse_NSVs_header(AVFormatContext *s) +{ + NSVContext *nsv = s->priv_data; + AVIOContext *pb = s->pb; + uint32_t vtag, atag; + uint16_t vwidth, vheight; + AVRational framerate; + int i; + AVStream *st; + NSVStream *nst; + + vtag = avio_rl32(pb); + atag = avio_rl32(pb); + vwidth = avio_rl16(pb); + vheight = avio_rl16(pb); + i = avio_r8(pb); + + av_log(s, AV_LOG_TRACE, ""NSV NSVs framerate code %2x\n"", i); + if(i&0x80) { /* odd way of giving native framerates from docs */ + int t=(i & 0x7F)>>2; + if(t<16) framerate = (AVRational){1, t+1}; + else framerate = (AVRational){t-15, 1}; + + if(i&1){ + framerate.num *= 1000; + framerate.den *= 1001; + } + + if((i&3)==3) framerate.num *= 24; + else if((i&3)==2) framerate.num *= 25; + else framerate.num *= 30; + } + else + framerate= (AVRational){i, 1}; + + nsv->avsync = avio_rl16(pb); + nsv->framerate = framerate; + + av_log(s, AV_LOG_TRACE, ""NSV NSVs vsize %dx%d\n"", vwidth, vheight); + + /* XXX change to ap != NULL ? */ + if (s->nb_streams == 0) { /* streams not yet published, let's do that */ + nsv->vtag = vtag; + nsv->atag = atag; + nsv->vwidth = vwidth; + nsv->vheight = vwidth; + if (vtag != T_NONE) { + int i; + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_VIDEO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_tag = vtag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_video_tags, vtag); + st->codecpar->width = vwidth; + st->codecpar->height = vheight; + st->codecpar->bits_per_coded_sample = 24; /* depth XXX */ + + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); + st->start_time = 0; + st->duration = av_rescale(nsv->duration, framerate.num, 1000*framerate.den); + + for(i=0;iindex_entries;i++) { + if(nsv->nsvs_timestamps) { + av_add_index_entry(st, nsv->nsvs_file_offset[i], nsv->nsvs_timestamps[i], + 0, 0, AVINDEX_KEYFRAME); + } else { + int64_t ts = av_rescale(i*nsv->duration/nsv->index_entries, framerate.num, 1000*framerate.den); + av_add_index_entry(st, nsv->nsvs_file_offset[i], ts, 0, 0, AVINDEX_KEYFRAME); + } + } + } + if (atag != T_NONE) { + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_AUDIO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = atag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag); + + st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */ + + /* set timebase to common denominator of ms and framerate */ + avpriv_set_pts_info(st, 64, 1, framerate.num*1000); + st->start_time = 0; + st->duration = (int64_t)nsv->duration * framerate.num; + } + } else { + if (nsv->vtag != vtag || nsv->atag != atag || nsv->vwidth != vwidth || nsv->vheight != vwidth) { + av_log(s, AV_LOG_TRACE, ""NSV NSVs header values differ from the first one!!!\n""); + } + } + + nsv->state = NSV_HAS_READ_NSVS; + return 0; +fail: + /* XXX */ + nsv->state = NSV_UNSYNC; + return -1; +} +",0,"static int nsv_parse_NSVs_header(AVFormatContext *s) +{ + NSVContext *nsv = s->priv_data; + AVIOContext *pb = s->pb; + uint32_t vtag, atag; + uint16_t vwidth, vheight; + AVRational framerate; + int i; + AVStream *st; + NSVStream *nst; + + vtag = avio_rl32(pb); + atag = avio_rl32(pb); + vwidth = avio_rl16(pb); + vheight = avio_rl16(pb); + i = avio_r8(pb); + + av_log(s, AV_LOG_TRACE, ""NSV NSVs framerate code %2x\n"", i); + if(i&0x80) { /* odd way of giving native framerates from docs */ + int t=(i & 0x7F)>>2; + if(t<16) framerate = (AVRational){1, t+1}; + else framerate = (AVRational){t-15, 1}; + + if(i&1){ + framerate.num *= 1000; + framerate.den *= 1001; + } + + if((i&3)==3) framerate.num *= 24; + else if((i&3)==2) framerate.num *= 25; + else framerate.num *= 30; + } + else + framerate= (AVRational){i, 1}; + + nsv->avsync = avio_rl16(pb); + nsv->framerate = framerate; + + av_log(s, AV_LOG_TRACE, ""NSV NSVs vsize %dx%d\n"", vwidth, vheight); + + /* XXX change to ap != NULL ? */ + if (s->nb_streams == 0) { /* streams not yet published, let's do that */ + nsv->vtag = vtag; + nsv->atag = atag; + nsv->vwidth = vwidth; + nsv->vheight = vwidth; + if (vtag != T_NONE) { + int i; + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_VIDEO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_tag = vtag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_video_tags, vtag); + st->codecpar->width = vwidth; + st->codecpar->height = vheight; + st->codecpar->bits_per_coded_sample = 24; /* depth XXX */ + + avpriv_set_pts_info(st, 64, framerate.den, framerate.num); + st->start_time = 0; + st->duration = av_rescale(nsv->duration, framerate.num, 1000*framerate.den); + + for(i=0;iindex_entries;i++) { + if(nsv->nsvs_timestamps) { + av_add_index_entry(st, nsv->nsvs_file_offset[i], nsv->nsvs_timestamps[i], + 0, 0, AVINDEX_KEYFRAME); + } else { + int64_t ts = av_rescale(i*nsv->duration/nsv->index_entries, framerate.num, 1000*framerate.den); + av_add_index_entry(st, nsv->nsvs_file_offset[i], ts, 0, 0, AVINDEX_KEYFRAME); + } + } + } + if (atag != T_NONE) { + st = avformat_new_stream(s, NULL); + if (!st) + goto fail; + + st->id = NSV_ST_AUDIO; + nst = av_mallocz(sizeof(NSVStream)); + if (!nst) + goto fail; + st->priv_data = nst; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_tag = atag; + st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag); + + st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */ + + /* set timebase to common denominator of ms and framerate */ + avpriv_set_pts_info(st, 64, 1, framerate.num*1000); + st->start_time = 0; + st->duration = (int64_t)nsv->duration * framerate.num; + } + } else { + if (nsv->vtag != vtag || nsv->atag != atag || nsv->vwidth != vwidth || nsv->vheight != vwidth) { + av_log(s, AV_LOG_TRACE, ""NSV NSVs header values differ from the first one!!!\n""); + } + } + + nsv->state = NSV_HAS_READ_NSVS; + return 0; +fail: + /* XXX */ + nsv->state = NSV_UNSYNC; + return -1; +} +","@@ -335,8 +335,11 @@ static int nsv_parse_NSVf_header(AVFormatContext *s) + if (!nsv->nsvs_file_offset) + return AVERROR(ENOMEM); + +- for(i=0;insvs_file_offset[i] = avio_rl32(pb) + size; ++ } + + if(table_entries > table_entries_used && + avio_rl32(pb) == MKTAG('T','O','C','2')) {",1130,1366,2048 +18419,"void Browser::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + switch (type.value) { + case NotificationType::TAB_CONTENTS_DISCONNECTED: + if (is_attempting_to_close_browser_) { + MessageLoop::current()->PostTask( + FROM_HERE, + method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, + Source(source).ptr())); + } + break; + + case NotificationType::SSL_VISIBLE_STATE_CHANGED: + if (GetSelectedTabContents() && + &GetSelectedTabContents()->controller() == + Source(source).ptr()) + UpdateToolbar(false); + break; + + case NotificationType::EXTENSION_UPDATE_DISABLED: { + Profile* profile = Source(source).ptr(); + if (profile_->IsSameProfile(profile)) { + ExtensionService* service = profile->GetExtensionService(); + DCHECK(service); + const Extension* extension = Details(details).ptr(); + if (service->extension_prefs()->DidExtensionEscalatePermissions( + extension->id())) + ShowExtensionDisabledUI(service, profile_, extension); + } + break; + } + + case NotificationType::EXTENSION_UNLOADED: { + window()->GetLocationBar()->UpdatePageActions(); + + const Extension* extension = + Details(details)->extension; + TabStripModel* model = tab_handler_->GetTabStripModel(); + for (int i = model->count() - 1; i >= 0; --i) { + TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); + if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && + tc->GetURL().host() == extension->id()) { + CloseTabContents(tc); + } + } + + break; + } + + case NotificationType::EXTENSION_PROCESS_TERMINATED: { + window()->GetLocationBar()->InvalidatePageActions(); + + TabContents* tab_contents = GetSelectedTabContents(); + if (!tab_contents) + break; + ExtensionService* extensions_service = + Source(source).ptr()->GetExtensionService(); + ExtensionHost* extension_host = Details(details).ptr(); + tab_contents->AddInfoBar(new CrashedExtensionInfoBarDelegate( + tab_contents, extensions_service, extension_host->extension())); + break; + } + + case NotificationType::EXTENSION_LOADED: { + window()->GetLocationBar()->UpdatePageActions(); + + const Extension* extension = Details(details).ptr(); + CrashedExtensionInfoBarDelegate* delegate = NULL; + TabStripModel* model = tab_handler_->GetTabStripModel(); + for (int m = 0; m < model->count(); ++m) { + TabContents* tab_contents = model->GetTabContentsAt(m)->tab_contents(); + for (int i = 0; i < tab_contents->infobar_delegate_count();) { + delegate = tab_contents->GetInfoBarDelegateAt(i)-> + AsCrashedExtensionInfoBarDelegate(); + if (delegate && delegate->extension_id() == extension->id()) { + tab_contents->RemoveInfoBar(delegate); + continue; + } + ++i; + } + } + break; + } + + case NotificationType::BROWSER_THEME_CHANGED: + window()->UserChangedTheme(); + break; + + case NotificationType::EXTENSION_READY_FOR_INSTALL: { + if (BrowserList::FindBrowserWithType(profile(), + Browser::TYPE_NORMAL, + true) != this) + break; + + GURL download_url = *(Details(details).ptr()); + if (ExtensionService::IsDownloadFromMiniGallery(download_url)) + window()->ShowThemeInstallBubble(); + break; + } + + case NotificationType::PROFILE_ERROR: { + if (BrowserList::GetLastActive() != this) + break; + int* message_id = Details(details).ptr(); + window()->ShowProfileErrorDialog(*message_id); + break; + } + + case NotificationType::PREF_CHANGED: { + const std::string& pref_name = *Details(details).ptr(); + if (pref_name == prefs::kUseVerticalTabs) { + UseVerticalTabsChanged(); + } else if (pref_name == prefs::kPrintingEnabled) { + UpdatePrintingState(0); + } else if (pref_name == prefs::kInstantEnabled) { + if (!InstantController::IsEnabled(profile())) { + if (instant()) { + instant()->DestroyPreviewContents(); + instant_.reset(); + instant_unload_handler_.reset(); + } + } else { + CreateInstantIfNecessary(); + } + } else if (pref_name == prefs::kDevToolsDisabled) { + UpdateCommandsForDevTools(); + if (dev_tools_disabled_.GetValue()) + g_browser_process->devtools_manager()->CloseAllClientHosts(); + } else { + NOTREACHED(); + } + break; + } + + default: + NOTREACHED() << ""Got a notification we didn't register for.""; + } +} +",1,"void Browser::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + switch (type.value) { + case NotificationType::TAB_CONTENTS_DISCONNECTED: + if (is_attempting_to_close_browser_) { + // Pass in false so that we delay processing. We need to delay the + // processing as it may close the tab, which is currently on the call + // stack above us. + ClearUnloadState(Source(source).ptr(), false); + } + break; + + case NotificationType::SSL_VISIBLE_STATE_CHANGED: + if (GetSelectedTabContents() && + &GetSelectedTabContents()->controller() == + Source(source).ptr()) + UpdateToolbar(false); + break; + + case NotificationType::EXTENSION_UPDATE_DISABLED: { + Profile* profile = Source(source).ptr(); + if (profile_->IsSameProfile(profile)) { + ExtensionService* service = profile->GetExtensionService(); + DCHECK(service); + const Extension* extension = Details(details).ptr(); + if (service->extension_prefs()->DidExtensionEscalatePermissions( + extension->id())) + ShowExtensionDisabledUI(service, profile_, extension); + } + break; + } + + case NotificationType::EXTENSION_UNLOADED: { + window()->GetLocationBar()->UpdatePageActions(); + + const Extension* extension = + Details(details)->extension; + TabStripModel* model = tab_handler_->GetTabStripModel(); + for (int i = model->count() - 1; i >= 0; --i) { + TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); + if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && + tc->GetURL().host() == extension->id()) { + CloseTabContents(tc); + } + } + + break; + } + + case NotificationType::EXTENSION_PROCESS_TERMINATED: { + window()->GetLocationBar()->InvalidatePageActions(); + + TabContents* tab_contents = GetSelectedTabContents(); + if (!tab_contents) + break; + ExtensionService* extensions_service = + Source(source).ptr()->GetExtensionService(); + ExtensionHost* extension_host = Details(details).ptr(); + tab_contents->AddInfoBar(new CrashedExtensionInfoBarDelegate( + tab_contents, extensions_service, extension_host->extension())); + break; + } + + case NotificationType::EXTENSION_LOADED: { + window()->GetLocationBar()->UpdatePageActions(); + + const Extension* extension = Details(details).ptr(); + CrashedExtensionInfoBarDelegate* delegate = NULL; + TabStripModel* model = tab_handler_->GetTabStripModel(); + for (int m = 0; m < model->count(); ++m) { + TabContents* tab_contents = model->GetTabContentsAt(m)->tab_contents(); + for (int i = 0; i < tab_contents->infobar_delegate_count();) { + delegate = tab_contents->GetInfoBarDelegateAt(i)-> + AsCrashedExtensionInfoBarDelegate(); + if (delegate && delegate->extension_id() == extension->id()) { + tab_contents->RemoveInfoBar(delegate); + continue; + } + ++i; + } + } + break; + } + + case NotificationType::BROWSER_THEME_CHANGED: + window()->UserChangedTheme(); + break; + + case NotificationType::EXTENSION_READY_FOR_INSTALL: { + if (BrowserList::FindBrowserWithType(profile(), + Browser::TYPE_NORMAL, + true) != this) + break; + + GURL download_url = *(Details(details).ptr()); + if (ExtensionService::IsDownloadFromMiniGallery(download_url)) + window()->ShowThemeInstallBubble(); + break; + } + + case NotificationType::PROFILE_ERROR: { + if (BrowserList::GetLastActive() != this) + break; + int* message_id = Details(details).ptr(); + window()->ShowProfileErrorDialog(*message_id); + break; + } + + case NotificationType::PREF_CHANGED: { + const std::string& pref_name = *Details(details).ptr(); + if (pref_name == prefs::kUseVerticalTabs) { + UseVerticalTabsChanged(); + } else if (pref_name == prefs::kPrintingEnabled) { + UpdatePrintingState(0); + } else if (pref_name == prefs::kInstantEnabled) { + if (!InstantController::IsEnabled(profile())) { + if (instant()) { + instant()->DestroyPreviewContents(); + instant_.reset(); + instant_unload_handler_.reset(); + } + } else { + CreateInstantIfNecessary(); + } + } else if (pref_name == prefs::kDevToolsDisabled) { + UpdateCommandsForDevTools(); + if (dev_tools_disabled_.GetValue()) + g_browser_process->devtools_manager()->CloseAllClientHosts(); + } else { + NOTREACHED(); + } + break; + } + + default: + NOTREACHED() << ""Got a notification we didn't register for.""; + } +} +","@@ -2847,7 +2847,7 @@ void Browser::CloseContents(TabContents* source) { + // waiting for unload to fire. Don't actually try to close the tab as it + // will go down the slow shutdown path instead of the fast path of killing + // all the renderer processes. +- ClearUnloadState(source); ++ ClearUnloadState(source, true); + return; + } + +@@ -3208,12 +3208,10 @@ void Browser::Observe(NotificationType type, + switch (type.value) { + case NotificationType::TAB_CONTENTS_DISCONNECTED: + if (is_attempting_to_close_browser_) { +- // Need to do this asynchronously as it will close the tab, which is +- // currently on the call stack above us. +- MessageLoop::current()->PostTask( +- FROM_HERE, +- method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, +- Source(source).ptr())); ++ // Pass in false so that we delay processing. We need to delay the ++ // processing as it may close the tab, which is currently on the call ++ // stack above us. ++ ClearUnloadState(Source(source).ptr(), false); + } + break; + +@@ -3852,7 +3850,12 @@ void Browser::SyncHistoryWithTabs(int index) { + // Browser, OnBeforeUnload handling (private): + + void Browser::ProcessPendingTabs() { +- DCHECK(is_attempting_to_close_browser_); ++ if (!is_attempting_to_close_browser_) { ++ // Because we might invoke this after a delay it's possible for the value of ++ // is_attempting_to_close_browser_ to have changed since we scheduled the ++ // task. ++ return; ++ } + + if (HasCompletedUnloadProcessing()) { + // We've finished all the unload events and can proceed to close the +@@ -3870,7 +3873,7 @@ void Browser::ProcessPendingTabs() { + if (tab->render_view_host()) { + tab->render_view_host()->FirePageBeforeUnload(false); + } else { +- ClearUnloadState(tab); ++ ClearUnloadState(tab, true); + } + } else if (!tabs_needing_unload_fired_.empty()) { + // We've finished firing all beforeunload events and can proceed with unload +@@ -3887,7 +3890,7 @@ void Browser::ProcessPendingTabs() { + if (tab->render_view_host()) { + tab->render_view_host()->ClosePage(false, -1, -1); + } else { +- ClearUnloadState(tab); ++ ClearUnloadState(tab, true); + } + } else { + NOTREACHED(); +@@ -3927,18 +3930,23 @@ bool Browser::RemoveFromSet(UnloadListenerSet* set, TabContents* tab) { + return false; + } + +-void Browser::ClearUnloadState(TabContents* tab) { ++void Browser::ClearUnloadState(TabContents* tab, bool process_now) { + // Closing of browser could be canceled (via IsClosingPermitted) between the + // time when request was initiated and when this method is called, so check + // for is_attempting_to_close_browser_ flag before proceeding. + if (is_attempting_to_close_browser_) { + RemoveFromSet(&tabs_needing_before_unload_fired_, tab); + RemoveFromSet(&tabs_needing_unload_fired_, tab); +- ProcessPendingTabs(); ++ if (process_now) { ++ ProcessPendingTabs(); ++ } else { ++ MessageLoop::current()->PostTask( ++ FROM_HERE, ++ method_factory_.NewRunnableMethod(&Browser::ProcessPendingTabs)); ++ } + } + } + +- + /////////////////////////////////////////////////////////////////////////////// + // Browser, In-progress download termination handling (private): + +@@ -4097,6 +4105,14 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index, + find_bar_controller_->ChangeTabContents(NULL); + } + ++ if (is_attempting_to_close_browser_) { ++ // If this is the last tab with unload handlers, then ProcessPendingTabs ++ // would call back into the TabStripModel (which is invoking this method on ++ // us). Avoid that by passing in false so that the call to ++ // ProcessPendingTabs is delayed. ++ ClearUnloadState(contents->tab_contents(), false); ++ } ++ + registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED, + Source(contents)); + }",1063,1299,2048 +3241,"static int dispatch_rw_block_io(struct xen_blkif *blkif, + struct blkif_request *req, + struct pending_req *pending_req) +{ + struct phys_req preq; + struct seg_buf *seg = pending_req->seg; + unsigned int nseg; + struct bio *bio = NULL; + struct bio **biolist = pending_req->biolist; + int i, nbio = 0; + int operation; + struct blk_plug plug; + bool drain = false; + struct grant_page **pages = pending_req->segments; + unsigned short req_operation; + + req_operation = req->operation == BLKIF_OP_INDIRECT ? + req->u.indirect.indirect_op : req->operation; + if ((req->operation == BLKIF_OP_INDIRECT) && + (req_operation != BLKIF_OP_READ) && + (req_operation != BLKIF_OP_WRITE)) { + pr_debug(DRV_PFX ""Invalid indirect operation (%u)\n"", + req_operation); + goto fail_response; + } + + switch (req_operation) { + case BLKIF_OP_READ: + blkif->st_rd_req++; + operation = READ; + break; + case BLKIF_OP_WRITE: + blkif->st_wr_req++; + operation = WRITE_ODIRECT; + break; + case BLKIF_OP_WRITE_BARRIER: + drain = true; + case BLKIF_OP_FLUSH_DISKCACHE: + blkif->st_f_req++; + operation = WRITE_FLUSH; + break; + default: + operation = 0; /* make gcc happy */ + goto fail_response; + break; + } + + /* Check that the number of segments is sane. */ + nseg = req->operation == BLKIF_OP_INDIRECT ? + req->u.indirect.nr_segments : req->u.rw.nr_segments; + + if (unlikely(nseg == 0 && operation != WRITE_FLUSH) || + unlikely((req->operation != BLKIF_OP_INDIRECT) && + (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) || + unlikely((req->operation == BLKIF_OP_INDIRECT) && + (nseg > MAX_INDIRECT_SEGMENTS))) { + pr_debug(DRV_PFX ""Bad number of segments in request (%d)\n"", + nseg); + /* Haven't submitted any bio's yet. */ + goto fail_response; + } + + preq.nr_sects = 0; + + pending_req->blkif = blkif; + pending_req->id = req->u.rw.id; + pending_req->operation = req_operation; + pending_req->status = BLKIF_RSP_OKAY; + pending_req->nr_pages = nseg; + + if (req->operation != BLKIF_OP_INDIRECT) { + preq.dev = req->u.rw.handle; + preq.sector_number = req->u.rw.sector_number; + for (i = 0; i < nseg; i++) { + pages[i]->gref = req->u.rw.seg[i].gref; + seg[i].nsec = req->u.rw.seg[i].last_sect - + req->u.rw.seg[i].first_sect + 1; + seg[i].offset = (req->u.rw.seg[i].first_sect << 9); + if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) || + (req->u.rw.seg[i].last_sect < + req->u.rw.seg[i].first_sect)) + goto fail_response; + preq.nr_sects += seg[i].nsec; + } + } else { + preq.dev = req->u.indirect.handle; + preq.sector_number = req->u.indirect.sector_number; + if (xen_blkbk_parse_indirect(req, pending_req, seg, &preq)) + goto fail_response; + } + + if (xen_vbd_translate(&preq, blkif, operation) != 0) { + pr_debug(DRV_PFX ""access denied: %s of [%llu,%llu] on dev=%04x\n"", + operation == READ ? ""read"" : ""write"", + preq.sector_number, + preq.sector_number + preq.nr_sects, + blkif->vbd.pdevice); + goto fail_response; + } + + /* + * This check _MUST_ be done after xen_vbd_translate as the preq.bdev + * is set there. + */ + for (i = 0; i < nseg; i++) { + if (((int)preq.sector_number|(int)seg[i].nsec) & + ((bdev_logical_block_size(preq.bdev) >> 9) - 1)) { + pr_debug(DRV_PFX ""Misaligned I/O request from domain %d"", + blkif->domid); + goto fail_response; + } + } + + /* Wait on all outstanding I/O's and once that has been completed + * issue the WRITE_FLUSH. + */ + if (drain) + xen_blk_drain_io(pending_req->blkif); + + /* + * If we have failed at this point, we need to undo the M2P override, + * set gnttab_set_unmap_op on all of the grant references and perform + * the hypercall to unmap the grants - that is all done in + * xen_blkbk_unmap. + */ + if (xen_blkbk_map_seg(pending_req)) + goto fail_flush; + + /* + * This corresponding xen_blkif_put is done in __end_block_io_op, or + * below (in ""!bio"") if we are handling a BLKIF_OP_DISCARD. + */ + xen_blkif_get(blkif); + + for (i = 0; i < nseg; i++) { + while ((bio == NULL) || + (bio_add_page(bio, + pages[i]->page, + seg[i].nsec << 9, + seg[i].offset) == 0)) { + + bio = bio_alloc(GFP_KERNEL, nseg-i); + if (unlikely(bio == NULL)) + goto fail_put_bio; + + biolist[nbio++] = bio; + bio->bi_bdev = preq.bdev; + bio->bi_private = pending_req; + bio->bi_end_io = end_block_io_op; + bio->bi_sector = preq.sector_number; + } + + preq.sector_number += seg[i].nsec; + } + + /* This will be hit if the operation was a flush or discard. */ + if (!bio) { + BUG_ON(operation != WRITE_FLUSH); + + bio = bio_alloc(GFP_KERNEL, 0); + if (unlikely(bio == NULL)) + goto fail_put_bio; + + biolist[nbio++] = bio; + bio->bi_bdev = preq.bdev; + bio->bi_private = pending_req; + bio->bi_end_io = end_block_io_op; + } + + atomic_set(&pending_req->pendcnt, nbio); + blk_start_plug(&plug); + + for (i = 0; i < nbio; i++) + submit_bio(operation, biolist[i]); + + /* Let the I/Os go.. */ + blk_finish_plug(&plug); + + if (operation == READ) + blkif->st_rd_sect += preq.nr_sects; + else if (operation & WRITE) + blkif->st_wr_sect += preq.nr_sects; + + return 0; + + fail_flush: + xen_blkbk_unmap(blkif, pending_req->segments, + pending_req->nr_pages); + fail_response: + /* Haven't submitted any bio's yet. */ + make_response(blkif, req->u.rw.id, req_operation, BLKIF_RSP_ERROR); + free_req(blkif, pending_req); + msleep(1); /* back off a bit */ + return -EIO; + + fail_put_bio: + for (i = 0; i < nbio; i++) + bio_put(biolist[i]); + atomic_set(&pending_req->pendcnt, 1); + __end_block_io_op(pending_req, -EINVAL); + msleep(1); /* back off a bit */ + return -EIO; +} +",0,"static int dispatch_rw_block_io(struct xen_blkif *blkif, + struct blkif_request *req, + struct pending_req *pending_req) +{ + struct phys_req preq; + struct seg_buf *seg = pending_req->seg; + unsigned int nseg; + struct bio *bio = NULL; + struct bio **biolist = pending_req->biolist; + int i, nbio = 0; + int operation; + struct blk_plug plug; + bool drain = false; + struct grant_page **pages = pending_req->segments; + unsigned short req_operation; + + req_operation = req->operation == BLKIF_OP_INDIRECT ? + req->u.indirect.indirect_op : req->operation; + if ((req->operation == BLKIF_OP_INDIRECT) && + (req_operation != BLKIF_OP_READ) && + (req_operation != BLKIF_OP_WRITE)) { + pr_debug(DRV_PFX ""Invalid indirect operation (%u)\n"", + req_operation); + goto fail_response; + } + + switch (req_operation) { + case BLKIF_OP_READ: + blkif->st_rd_req++; + operation = READ; + break; + case BLKIF_OP_WRITE: + blkif->st_wr_req++; + operation = WRITE_ODIRECT; + break; + case BLKIF_OP_WRITE_BARRIER: + drain = true; + case BLKIF_OP_FLUSH_DISKCACHE: + blkif->st_f_req++; + operation = WRITE_FLUSH; + break; + default: + operation = 0; /* make gcc happy */ + goto fail_response; + break; + } + + /* Check that the number of segments is sane. */ + nseg = req->operation == BLKIF_OP_INDIRECT ? + req->u.indirect.nr_segments : req->u.rw.nr_segments; + + if (unlikely(nseg == 0 && operation != WRITE_FLUSH) || + unlikely((req->operation != BLKIF_OP_INDIRECT) && + (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) || + unlikely((req->operation == BLKIF_OP_INDIRECT) && + (nseg > MAX_INDIRECT_SEGMENTS))) { + pr_debug(DRV_PFX ""Bad number of segments in request (%d)\n"", + nseg); + /* Haven't submitted any bio's yet. */ + goto fail_response; + } + + preq.nr_sects = 0; + + pending_req->blkif = blkif; + pending_req->id = req->u.rw.id; + pending_req->operation = req_operation; + pending_req->status = BLKIF_RSP_OKAY; + pending_req->nr_pages = nseg; + + if (req->operation != BLKIF_OP_INDIRECT) { + preq.dev = req->u.rw.handle; + preq.sector_number = req->u.rw.sector_number; + for (i = 0; i < nseg; i++) { + pages[i]->gref = req->u.rw.seg[i].gref; + seg[i].nsec = req->u.rw.seg[i].last_sect - + req->u.rw.seg[i].first_sect + 1; + seg[i].offset = (req->u.rw.seg[i].first_sect << 9); + if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) || + (req->u.rw.seg[i].last_sect < + req->u.rw.seg[i].first_sect)) + goto fail_response; + preq.nr_sects += seg[i].nsec; + } + } else { + preq.dev = req->u.indirect.handle; + preq.sector_number = req->u.indirect.sector_number; + if (xen_blkbk_parse_indirect(req, pending_req, seg, &preq)) + goto fail_response; + } + + if (xen_vbd_translate(&preq, blkif, operation) != 0) { + pr_debug(DRV_PFX ""access denied: %s of [%llu,%llu] on dev=%04x\n"", + operation == READ ? ""read"" : ""write"", + preq.sector_number, + preq.sector_number + preq.nr_sects, + blkif->vbd.pdevice); + goto fail_response; + } + + /* + * This check _MUST_ be done after xen_vbd_translate as the preq.bdev + * is set there. + */ + for (i = 0; i < nseg; i++) { + if (((int)preq.sector_number|(int)seg[i].nsec) & + ((bdev_logical_block_size(preq.bdev) >> 9) - 1)) { + pr_debug(DRV_PFX ""Misaligned I/O request from domain %d"", + blkif->domid); + goto fail_response; + } + } + + /* Wait on all outstanding I/O's and once that has been completed + * issue the WRITE_FLUSH. + */ + if (drain) + xen_blk_drain_io(pending_req->blkif); + + /* + * If we have failed at this point, we need to undo the M2P override, + * set gnttab_set_unmap_op on all of the grant references and perform + * the hypercall to unmap the grants - that is all done in + * xen_blkbk_unmap. + */ + if (xen_blkbk_map_seg(pending_req)) + goto fail_flush; + + /* + * This corresponding xen_blkif_put is done in __end_block_io_op, or + * below (in ""!bio"") if we are handling a BLKIF_OP_DISCARD. + */ + xen_blkif_get(blkif); + + for (i = 0; i < nseg; i++) { + while ((bio == NULL) || + (bio_add_page(bio, + pages[i]->page, + seg[i].nsec << 9, + seg[i].offset) == 0)) { + + bio = bio_alloc(GFP_KERNEL, nseg-i); + if (unlikely(bio == NULL)) + goto fail_put_bio; + + biolist[nbio++] = bio; + bio->bi_bdev = preq.bdev; + bio->bi_private = pending_req; + bio->bi_end_io = end_block_io_op; + bio->bi_sector = preq.sector_number; + } + + preq.sector_number += seg[i].nsec; + } + + /* This will be hit if the operation was a flush or discard. */ + if (!bio) { + BUG_ON(operation != WRITE_FLUSH); + + bio = bio_alloc(GFP_KERNEL, 0); + if (unlikely(bio == NULL)) + goto fail_put_bio; + + biolist[nbio++] = bio; + bio->bi_bdev = preq.bdev; + bio->bi_private = pending_req; + bio->bi_end_io = end_block_io_op; + } + + atomic_set(&pending_req->pendcnt, nbio); + blk_start_plug(&plug); + + for (i = 0; i < nbio; i++) + submit_bio(operation, biolist[i]); + + /* Let the I/Os go.. */ + blk_finish_plug(&plug); + + if (operation == READ) + blkif->st_rd_sect += preq.nr_sects; + else if (operation & WRITE) + blkif->st_wr_sect += preq.nr_sects; + + return 0; + + fail_flush: + xen_blkbk_unmap(blkif, pending_req->segments, + pending_req->nr_pages); + fail_response: + /* Haven't submitted any bio's yet. */ + make_response(blkif, req->u.rw.id, req_operation, BLKIF_RSP_ERROR); + free_req(blkif, pending_req); + msleep(1); /* back off a bit */ + return -EIO; + + fail_put_bio: + for (i = 0; i < nbio; i++) + bio_put(biolist[i]); + atomic_set(&pending_req->pendcnt, 1); + __end_block_io_op(pending_req, -EINVAL); + msleep(1); /* back off a bit */ + return -EIO; +} +","@@ -876,7 +876,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif, + int status = BLKIF_RSP_OKAY; + struct block_device *bdev = blkif->vbd.bdev; + unsigned long secure; ++ struct phys_req preq; ++ ++ preq.sector_number = req->u.discard.sector_number; ++ preq.nr_sects = req->u.discard.nr_sectors; + ++ err = xen_vbd_translate(&preq, blkif, WRITE); ++ if (err) { ++ pr_warn(DRV_PFX ""access denied: DISCARD [%llu->%llu] on dev=%04x\n"", ++ preq.sector_number, ++ preq.sector_number + preq.nr_sects, blkif->vbd.pdevice); ++ goto fail_response; ++ } + blkif->st_ds_req++; + + xen_blkif_get(blkif); +@@ -887,7 +898,7 @@ static int dispatch_discard_io(struct xen_blkif *blkif, + err = blkdev_issue_discard(bdev, req->u.discard.sector_number, + req->u.discard.nr_sectors, + GFP_KERNEL, secure); +- ++fail_response: + if (err == -EOPNOTSUPP) { + pr_debug(DRV_PFX ""discard op failed, not supported\n""); + status = BLKIF_RSP_EOPNOTSUPP;",1778,2014,2048 +1118,"int ssl3_check_cert_and_algorithm(SSL *s) + { + int i,idx; + long alg_k,alg_a; + EVP_PKEY *pkey=NULL; + SESS_CERT *sc; +#ifndef OPENSSL_NO_RSA + RSA *rsa; +#endif +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + + alg_k=s->s3->tmp.new_cipher->algorithm_mkey; + alg_a=s->s3->tmp.new_cipher->algorithm_auth; + + /* we don't have a certificate */ + if ((alg_a & (SSL_aDH|SSL_aNULL|SSL_aKRB5)) || (alg_k & SSL_kPSK)) + return(1); + + sc=s->session->sess_cert; + if (sc == NULL) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR); + goto err; + } + +#ifndef OPENSSL_NO_RSA + rsa=s->session->sess_cert->peer_rsa_tmp; +#endif +#ifndef OPENSSL_NO_DH + dh=s->session->sess_cert->peer_dh_tmp; +#endif + + /* This is the passed certificate */ + + idx=sc->peer_cert_type; +#ifndef OPENSSL_NO_ECDH + if (idx == SSL_PKEY_ECC) + { + if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, + s) == 0) + { /* check failed */ + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_BAD_ECC_CERT); + goto f_err; + } + else + { + return 1; + } + } +#endif + pkey=X509_get_pubkey(sc->peer_pkeys[idx].x509); + i=X509_certificate_type(sc->peer_pkeys[idx].x509,pkey); + EVP_PKEY_free(pkey); + + + /* Check that we have a certificate if we require one */ + if ((alg_a & SSL_aRSA) && !has_bits(i,EVP_PK_RSA|EVP_PKT_SIGN)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_a & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_RSA + if ((alg_k & SSL_kRSA) && + !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_DH + if ((alg_k & SSL_kEDH) && + !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_KEY); + goto f_err; + } + else if ((alg_k & SSL_kDHr) && !has_bits(i,EVP_PK_DH|EVP_PKS_RSA)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_k & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); + goto f_err; + } +#endif +#endif + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) + { +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) + { + if (rsa == NULL + || RSA_size(rsa)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } + } + else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) + { + if (dh == NULL + || DH_size(dh)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } + } + else +#endif + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + } + return(1); +f_err: + ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); +err: + return(0); + } +",0,"int ssl3_check_cert_and_algorithm(SSL *s) + { + int i,idx; + long alg_k,alg_a; + EVP_PKEY *pkey=NULL; + SESS_CERT *sc; +#ifndef OPENSSL_NO_RSA + RSA *rsa; +#endif +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + + alg_k=s->s3->tmp.new_cipher->algorithm_mkey; + alg_a=s->s3->tmp.new_cipher->algorithm_auth; + + /* we don't have a certificate */ + if ((alg_a & (SSL_aDH|SSL_aNULL|SSL_aKRB5)) || (alg_k & SSL_kPSK)) + return(1); + + sc=s->session->sess_cert; + if (sc == NULL) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR); + goto err; + } + +#ifndef OPENSSL_NO_RSA + rsa=s->session->sess_cert->peer_rsa_tmp; +#endif +#ifndef OPENSSL_NO_DH + dh=s->session->sess_cert->peer_dh_tmp; +#endif + + /* This is the passed certificate */ + + idx=sc->peer_cert_type; +#ifndef OPENSSL_NO_ECDH + if (idx == SSL_PKEY_ECC) + { + if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, + s) == 0) + { /* check failed */ + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_BAD_ECC_CERT); + goto f_err; + } + else + { + return 1; + } + } +#endif + pkey=X509_get_pubkey(sc->peer_pkeys[idx].x509); + i=X509_certificate_type(sc->peer_pkeys[idx].x509,pkey); + EVP_PKEY_free(pkey); + + + /* Check that we have a certificate if we require one */ + if ((alg_a & SSL_aRSA) && !has_bits(i,EVP_PK_RSA|EVP_PKT_SIGN)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_a & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_RSA + if ((alg_k & SSL_kRSA) && + !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_ENCRYPTING_CERT); + goto f_err; + } +#endif +#ifndef OPENSSL_NO_DH + if ((alg_k & SSL_kEDH) && + !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_KEY); + goto f_err; + } + else if ((alg_k & SSL_kDHr) && !has_bits(i,EVP_PK_DH|EVP_PKS_RSA)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); + goto f_err; + } +#ifndef OPENSSL_NO_DSA + else if ((alg_k & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); + goto f_err; + } +#endif +#endif + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) + { +#ifndef OPENSSL_NO_RSA + if (alg_k & SSL_kRSA) + { + if (rsa == NULL + || RSA_size(rsa)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY); + goto f_err; + } + } + else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) + { + if (dh == NULL + || DH_size(dh)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY); + goto f_err; + } + } + else +#endif + { + SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + } + return(1); +f_err: + ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); +err: + return(0); + } +","@@ -954,6 +954,15 @@ int ssl3_get_server_hello(SSL *s) + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED); + goto f_err; + } ++#ifndef OPENSSL_NO_SRP ++ if (((c->algorithm_mkey & SSL_kSRP) || (c->algorithm_auth & SSL_aSRP)) && ++ !(s->srp_ctx.srp_Mask & SSL_kSRP)) ++ { ++ al=SSL_AD_ILLEGAL_PARAMETER; ++ SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED); ++ goto f_err; ++ } ++#endif /* OPENSSL_NO_SRP */ + p+=ssl_put_cipher_by_char(s,NULL,NULL); + + sk=ssl_get_ciphers_by_id(s);",1122,1358,2048 +18295,"static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) + { + uint8_t optlen, i; + + ND_TCHECK(*option); + + if (*option >= 32) { + ND_TCHECK(*(option+1)); + optlen = *(option +1); + if (optlen < 2) { + if (*option >= 128) + ND_PRINT((ndo, ""CCID option %u optlen too short"", *option)); + else + ND_PRINT((ndo, ""%s optlen too short"", + tok2str(dccp_option_values, ""Option %u"", *option))); + return 0; + } + } else + optlen = 1; + + if (hlen < optlen) { + if (*option >= 128) + ND_PRINT((ndo, ""CCID option %u optlen goes past header length"", + *option)); + else + ND_PRINT((ndo, ""%s optlen goes past header length"", + tok2str(dccp_option_values, ""Option %u"", *option))); + return 0; + } + ND_TCHECK2(*option, optlen); + + if (*option >= 128) { + ND_PRINT((ndo, ""CCID option %d"", *option)); + switch (optlen) { + case 4: + ND_PRINT((ndo, "" %u"", EXTRACT_16BITS(option + 2))); + break; + case 6: + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + break; + default: + break; + } + } else { + ND_PRINT((ndo, ""%s"", tok2str(dccp_option_values, ""Option %u"", *option))); + switch (*option) { + case 32: + case 33: + case 34: + case 35: + if (optlen < 3) { + ND_PRINT((ndo, "" optlen too short"")); + return optlen; + } + if (*(option + 2) < 10){ + ND_PRINT((ndo, "" %s"", dccp_feature_nums[*(option + 2)])); + for (i = 0; i < optlen - 3; i++) + ND_PRINT((ndo, "" %d"", *(option + 3 + i))); + } + break; + case 36: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 37: + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, "" %d"", *(option + 2 + i))); + break; + case 38: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 39: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 40: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 41: + if (optlen == 4) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else + ND_PRINT((ndo, "" optlen != 4"")); + break; + case 42: + if (optlen == 4) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else + ND_PRINT((ndo, "" optlen != 4"")); + break; + case 43: + if (optlen == 6) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else if (optlen == 4) + ND_PRINT((ndo, "" %u"", EXTRACT_16BITS(option + 2))); + else + ND_PRINT((ndo, "" optlen != 4 or 6"")); + break; + case 44: + if (optlen > 2) { + ND_PRINT((ndo, "" "")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + } + } + + return optlen; +trunc: + ND_PRINT((ndo, ""%s"", tstr)); + return 0; +} +",1,"static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) +static int +dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) + { + uint8_t optlen, i; + + ND_TCHECK(*option); + + if (*option >= 32) { + ND_TCHECK(*(option+1)); + optlen = *(option +1); + if (optlen < 2) { + if (*option >= 128) + ND_PRINT((ndo, ""CCID option %u optlen too short"", *option)); + else + ND_PRINT((ndo, ""%s optlen too short"", + tok2str(dccp_option_values, ""Option %u"", *option))); + return 0; + } + } else + optlen = 1; + + if (hlen < optlen) { + if (*option >= 128) + ND_PRINT((ndo, ""CCID option %u optlen goes past header length"", + *option)); + else + ND_PRINT((ndo, ""%s optlen goes past header length"", + tok2str(dccp_option_values, ""Option %u"", *option))); + return 0; + } + ND_TCHECK2(*option, optlen); + + if (*option >= 128) { + ND_PRINT((ndo, ""CCID option %d"", *option)); + switch (optlen) { + case 4: + ND_PRINT((ndo, "" %u"", EXTRACT_16BITS(option + 2))); + break; + case 6: + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + break; + default: + break; + } + } else { + ND_PRINT((ndo, ""%s"", tok2str(dccp_option_values, ""Option %u"", *option))); + switch (*option) { + case 32: + case 33: + case 34: + case 35: + if (optlen < 3) { + ND_PRINT((ndo, "" optlen too short"")); + return optlen; + } + if (*(option + 2) < 10){ + ND_PRINT((ndo, "" %s"", dccp_feature_nums[*(option + 2)])); + for (i = 0; i < optlen - 3; i++) + ND_PRINT((ndo, "" %d"", *(option + 3 + i))); + } + break; + case 36: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 37: + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, "" %d"", *(option + 2 + i))); + break; + case 38: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 39: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 40: + if (optlen > 2) { + ND_PRINT((ndo, "" 0x"")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + case 41: + /* + * 13.1. Timestamp Option + * + * +--------+--------+--------+--------+--------+--------+ + * |00101001|00000110| Timestamp Value | + * +--------+--------+--------+--------+--------+--------+ + * Type=41 Length=6 + */ + if (optlen == 6) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else + ND_PRINT((ndo, "" [optlen != 6]"")); + break; + case 42: + /* + * 13.3. Timestamp Echo Option + * + * +--------+--------+--------+--------+--------+--------+ + * |00101010|00000110| Timestamp Echo | + * +--------+--------+--------+--------+--------+--------+ + * Type=42 Len=6 + * + * +--------+--------+------- ... -------+--------+--------+ + * |00101010|00001000| Timestamp Echo | Elapsed Time | + * +--------+--------+------- ... -------+--------+--------+ + * Type=42 Len=8 (4 bytes) + * + * +--------+--------+------- ... -------+------- ... -------+ + * |00101010|00001010| Timestamp Echo | Elapsed Time | + * +--------+--------+------- ... -------+------- ... -------+ + * Type=42 Len=10 (4 bytes) (4 bytes) + */ + switch (optlen) { + case 6: + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + break; + case 8: + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + ND_PRINT((ndo, "" (elapsed time %u)"", EXTRACT_16BITS(option + 6))); + break; + case 10: + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + ND_PRINT((ndo, "" (elapsed time %u)"", EXTRACT_32BITS(option + 6))); + break; + default: + ND_PRINT((ndo, "" [optlen != 6 or 8 or 10]"")); + break; + } + break; + case 43: + if (optlen == 6) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else if (optlen == 4) + ND_PRINT((ndo, "" %u"", EXTRACT_16BITS(option + 2))); + else + ND_PRINT((ndo, "" [optlen != 4 or 6]"")); + break; + case 44: + if (optlen > 2) { + ND_PRINT((ndo, "" "")); + for (i = 0; i < optlen - 2; i++) + ND_PRINT((ndo, ""%02x"", *(option + 2 + i))); + } + break; + } + } + + return optlen; +trunc: + ND_PRINT((ndo, ""%s"", tstr)); + return 0; +} +","@@ -530,7 +530,8 @@ static const struct tok dccp_option_values[] = { + { 0, NULL } + }; + +-static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) ++static int ++dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) + { + uint8_t optlen, i; + +@@ -623,24 +624,62 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in + } + break; + case 41: +- if (optlen == 4) ++ /* ++ * 13.1. Timestamp Option ++ * ++ * +--------+--------+--------+--------+--------+--------+ ++ * |00101001|00000110| Timestamp Value | ++ * +--------+--------+--------+--------+--------+--------+ ++ * Type=41 Length=6 ++ */ ++ if (optlen == 6) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else +- ND_PRINT((ndo, "" optlen != 4"")); ++ ND_PRINT((ndo, "" [optlen != 6]"")); + break; + case 42: +- if (optlen == 4) ++ /* ++ * 13.3. Timestamp Echo Option ++ * ++ * +--------+--------+--------+--------+--------+--------+ ++ * |00101010|00000110| Timestamp Echo | ++ * +--------+--------+--------+--------+--------+--------+ ++ * Type=42 Len=6 ++ * ++ * +--------+--------+------- ... -------+--------+--------+ ++ * |00101010|00001000| Timestamp Echo | Elapsed Time | ++ * +--------+--------+------- ... -------+--------+--------+ ++ * Type=42 Len=8 (4 bytes) ++ * ++ * +--------+--------+------- ... -------+------- ... -------+ ++ * |00101010|00001010| Timestamp Echo | Elapsed Time | ++ * +--------+--------+------- ... -------+------- ... -------+ ++ * Type=42 Len=10 (4 bytes) (4 bytes) ++ */ ++ switch (optlen) { ++ case 6: + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); +- else +- ND_PRINT((ndo, "" optlen != 4"")); ++ break; ++ case 8: ++ ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); ++ ND_PRINT((ndo, "" (elapsed time %u)"", EXTRACT_16BITS(option + 6))); ++ break; ++ case 10: ++ ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); ++ ND_PRINT((ndo, "" (elapsed time %u)"", EXTRACT_32BITS(option + 6))); ++ break; ++ default: ++ ND_PRINT((ndo, "" [optlen != 6 or 8 or 10]"")); ++ break; ++ } + break; + case 43: + if (optlen == 6) + ND_PRINT((ndo, "" %u"", EXTRACT_32BITS(option + 2))); + else if (optlen == 4) + ND_PRINT((ndo, "" %u"", EXTRACT_16BITS(option + 2))); + else +- ND_PRINT((ndo, "" optlen != 4 or 6"")); ++ ND_PRINT((ndo, "" [optlen != 4 or 6]"")); + break; + case 44: + if (optlen > 2) {",1174,1410,2048 +18424,"xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + xmlChar limit = 0; + xmlChar *buf = NULL; + xmlChar *rep = NULL; + int len = 0; + int buf_size = 0; + int c, l, in_space = 0; + xmlChar *current = NULL; + xmlEntityPtr ent; + + if (NXT(0) == '""') { + ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE; + limit = '""'; + NEXT; + } else if (NXT(0) == '\'') { + limit = '\''; + ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE; + NEXT; + } else { + xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL); + return(NULL); + } + + /* + * allocate a translation buffer. + */ + buf_size = XML_PARSER_BUFFER_SIZE; + buf = (xmlChar *) xmlMallocAtomic(buf_size * sizeof(xmlChar)); + if (buf == NULL) goto mem_error; + + /* + * OK loop until we reach one of the ending char or a size limit. + */ + c = CUR_CHAR(l); + while ((NXT(0) != limit) && /* checked */ + (IS_CHAR(c)) && (c != '<')) { + if (c == 0) break; + if (c == '&') { + in_space = 0; + if (NXT(1) == '#') { + int val = xmlParseCharRef(ctxt); + + if (val == '&') { + if (ctxt->replaceEntities) { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + buf[len++] = '&'; + } else { + /* + * The reparsing will be done in xmlStringGetNodeList() + * called by the attribute() function in SAX.c + */ + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + buf[len++] = '&'; + buf[len++] = '#'; + buf[len++] = '3'; + buf[len++] = '8'; + buf[len++] = ';'; + } + } else if (val != 0) { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + len += xmlCopyChar(0, &buf[len], val); + } + } else { + ent = xmlParseEntityRef(ctxt); + ctxt->nbentities++; + if (ent != NULL) + ctxt->nbentities += ent->owner; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + if ((ctxt->replaceEntities == 0) && + (ent->content[0] == '&')) { + buf[len++] = '&'; + buf[len++] = '#'; + buf[len++] = '3'; + buf[len++] = '8'; + buf[len++] = ';'; + } else { + buf[len++] = ent->content[0]; + } + } else if ((ent != NULL) && + (ctxt->replaceEntities != 0)) { + if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) { + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, + 0, 0, 0); + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming */ + if ((*current == 0xD) || (*current == 0xA) || + (*current == 0x9)) { + buf[len++] = 0x20; + current++; + } else + buf[len++] = *current++; + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + } + xmlFree(rep); + rep = NULL; + } + } else { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + if (ent->content != NULL) + buf[len++] = ent->content[0]; + } + } else if (ent != NULL) { + int i = xmlStrlen(ent->name); + const xmlChar *cur = ent->name; + + /* + * This may look absurd but is needed to detect + * entities problems + */ + if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && + (ent->content != NULL)) { + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, 0, 0, 0); + if (rep != NULL) { + xmlFree(rep); + rep = NULL; + } + } + + /* + * Just output the reference + */ + buf[len++] = '&'; + while (len > buf_size - i - 10) { + growBuffer(buf, i + 10); + } + for (;i > 0;i--) + buf[len++] = *cur++; + buf[len++] = ';'; + } + } + } else { + if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) { + if ((len != 0) || (!normalize)) { + if ((!normalize) || (!in_space)) { + COPY_BUF(l,buf,len,0x20); + while (len > buf_size - 10) { + growBuffer(buf, 10); + } + } + in_space = 1; + } + } else { + in_space = 0; + COPY_BUF(l,buf,len,c); + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + } + NEXTL(l); + } + GROW; + c = CUR_CHAR(l); + } + if ((in_space) && (normalize)) { + while (buf[len - 1] == 0x20) len--; + } + buf[len] = 0; + if (RAW == '<') { + xmlFatalErr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, NULL); + } else if (RAW != limit) { + if ((c != 0) && (!IS_CHAR(c))) { + xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR, + ""invalid character in attribute value\n""); + } else { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + ""AttValue: ' expected\n""); + } + } else + NEXT; + if (attlen != NULL) *attlen = len; + return(buf); + +mem_error: + xmlErrMemory(ctxt, NULL); + if (buf != NULL) + xmlFree(buf); + if (rep != NULL) + xmlFree(rep); + return(NULL); +} +",1,"xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + xmlChar limit = 0; + xmlChar *buf = NULL; + xmlChar *rep = NULL; + int len = 0; + int buf_size = 0; + int c, l, in_space = 0; + xmlChar *current = NULL; + xmlEntityPtr ent; + + if (NXT(0) == '""') { + ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE; + limit = '""'; + NEXT; + } else if (NXT(0) == '\'') { + limit = '\''; + ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE; + NEXT; + } else { + xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL); + return(NULL); + } + + /* + * allocate a translation buffer. + */ + buf_size = XML_PARSER_BUFFER_SIZE; + buf = (xmlChar *) xmlMallocAtomic(buf_size * sizeof(xmlChar)); + if (buf == NULL) goto mem_error; + + /* + * OK loop until we reach one of the ending char or a size limit. + */ + c = CUR_CHAR(l); + while ((NXT(0) != limit) && /* checked */ + (IS_CHAR(c)) && (c != '<')) { + if (c == 0) break; + if (c == '&') { + in_space = 0; + if (NXT(1) == '#') { + int val = xmlParseCharRef(ctxt); + + if (val == '&') { + if (ctxt->replaceEntities) { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + buf[len++] = '&'; + } else { + /* + * The reparsing will be done in xmlStringGetNodeList() + * called by the attribute() function in SAX.c + */ + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + buf[len++] = '&'; + buf[len++] = '#'; + buf[len++] = '3'; + buf[len++] = '8'; + buf[len++] = ';'; + } + } else if (val != 0) { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + len += xmlCopyChar(0, &buf[len], val); + } + } else { + ent = xmlParseEntityRef(ctxt); + ctxt->nbentities++; + if (ent != NULL) + ctxt->nbentities += ent->owner; + if ((ent != NULL) && + (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + if ((ctxt->replaceEntities == 0) && + (ent->content[0] == '&')) { + buf[len++] = '&'; + buf[len++] = '#'; + buf[len++] = '3'; + buf[len++] = '8'; + buf[len++] = ';'; + } else { + buf[len++] = ent->content[0]; + } + } else if ((ent != NULL) && + (ctxt->replaceEntities != 0)) { + if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) { + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, + 0, 0, 0); + if (rep != NULL) { + current = rep; + while (*current != 0) { /* non input consuming */ + if ((*current == 0xD) || (*current == 0xA) || + (*current == 0x9)) { + buf[len++] = 0x20; + current++; + } else + buf[len++] = *current++; + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + } + xmlFree(rep); + rep = NULL; + } + } else { + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + if (ent->content != NULL) + buf[len++] = ent->content[0]; + } + } else if (ent != NULL) { + int i = xmlStrlen(ent->name); + const xmlChar *cur = ent->name; + + /* + * This may look absurd but is needed to detect + * entities problems + */ + if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && + (ent->content != NULL)) { + rep = xmlStringDecodeEntities(ctxt, ent->content, + XML_SUBSTITUTE_REF, 0, 0, 0); + if (rep != NULL) { + xmlFree(rep); + rep = NULL; + } + } + + /* + * Just output the reference + */ + buf[len++] = '&'; + while (len > buf_size - i - 10) { + growBuffer(buf, i + 10); + } + for (;i > 0;i--) + buf[len++] = *cur++; + buf[len++] = ';'; + } + } + } else { + if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) { + if ((len != 0) || (!normalize)) { + if ((!normalize) || (!in_space)) { + COPY_BUF(l,buf,len,0x20); + while (len > buf_size - 10) { + growBuffer(buf, 10); + } + } + in_space = 1; + } + } else { + in_space = 0; + COPY_BUF(l,buf,len,c); + if (len > buf_size - 10) { + growBuffer(buf, 10); + } + } + NEXTL(l); + } + GROW; + c = CUR_CHAR(l); + } + if ((in_space) && (normalize)) { + while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } + buf[len] = 0; + if (RAW == '<') { + xmlFatalErr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, NULL); + } else if (RAW != limit) { + if ((c != 0) && (!IS_CHAR(c))) { + xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR, + ""invalid character in attribute value\n""); + } else { + xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, + ""AttValue: ' expected\n""); + } + } else + NEXT; + if (attlen != NULL) *attlen = len; + return(buf); + +mem_error: + xmlErrMemory(ctxt, NULL); + if (buf != NULL) + xmlFree(buf); + if (rep != NULL) + xmlFree(rep); + return(NULL); +} +","@@ -3800,7 +3800,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { + c = CUR_CHAR(l); + } + if ((in_space) && (normalize)) { +- while (buf[len - 1] == 0x20) len--; ++ while ((len > 0) && (buf[len - 1] == 0x20)) len--; + } + buf[len] = 0; + if (RAW == '<') {",1517,1753,2048 +3222,"static sctp_disposition_t sctp_sf_do_dupcook_a(struct net *net, + const struct sctp_endpoint *ep, + const struct sctp_association *asoc, + struct sctp_chunk *chunk, + sctp_cmd_seq_t *commands, + struct sctp_association *new_asoc) +{ + sctp_init_chunk_t *peer_init; + struct sctp_ulpevent *ev; + struct sctp_chunk *repl; + struct sctp_chunk *err; + sctp_disposition_t disposition; + + /* new_asoc is a brand-new association, so these are not yet + * side effects--it is safe to run them here. + */ + peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; + + if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, + GFP_ATOMIC)) + goto nomem; + + /* Make sure no new addresses are being added during the + * restart. Though this is a pretty complicated attack + * since you'd have to get inside the cookie. + */ + if (!sctp_sf_check_restart_addrs(new_asoc, asoc, chunk, commands)) { + return SCTP_DISPOSITION_CONSUME; + } + + /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes + * the peer has restarted (Action A), it MUST NOT setup a new + * association but instead resend the SHUTDOWN ACK and send an ERROR + * chunk with a ""Cookie Received while Shutting Down"" error cause to + * its peer. + */ + if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) { + disposition = sctp_sf_do_9_2_reshutack(net, ep, asoc, + SCTP_ST_CHUNK(chunk->chunk_hdr->type), + chunk, commands); + if (SCTP_DISPOSITION_NOMEM == disposition) + goto nomem; + + err = sctp_make_op_error(asoc, chunk, + SCTP_ERROR_COOKIE_IN_SHUTDOWN, + NULL, 0, 0); + if (err) + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, + SCTP_CHUNK(err)); + + return SCTP_DISPOSITION_CONSUME; + } + + /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked + * data. Consider the optional choice of resending of this data. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_T3_RTX_TIMERS_STOP, SCTP_NULL()); + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, + SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); + sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_OUTQUEUE, SCTP_NULL()); + + /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue + * and ASCONF-ACK cache. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, + SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); + sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_ASCONF_QUEUE, SCTP_NULL()); + + repl = sctp_make_cookie_ack(new_asoc, chunk); + if (!repl) + goto nomem; + + /* Report association restart to upper layer. */ + ev = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_RESTART, 0, + new_asoc->c.sinit_num_ostreams, + new_asoc->c.sinit_max_instreams, + NULL, GFP_ATOMIC); + if (!ev) + goto nomem_ev; + + /* Update the content of current association. */ + sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, + SCTP_STATE(SCTP_STATE_ESTABLISHED)); + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); + return SCTP_DISPOSITION_CONSUME; + +nomem_ev: + sctp_chunk_free(repl); +nomem: + return SCTP_DISPOSITION_NOMEM; +} +",0,"static sctp_disposition_t sctp_sf_do_dupcook_a(struct net *net, + const struct sctp_endpoint *ep, + const struct sctp_association *asoc, + struct sctp_chunk *chunk, + sctp_cmd_seq_t *commands, + struct sctp_association *new_asoc) +{ + sctp_init_chunk_t *peer_init; + struct sctp_ulpevent *ev; + struct sctp_chunk *repl; + struct sctp_chunk *err; + sctp_disposition_t disposition; + + /* new_asoc is a brand-new association, so these are not yet + * side effects--it is safe to run them here. + */ + peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; + + if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, + GFP_ATOMIC)) + goto nomem; + + /* Make sure no new addresses are being added during the + * restart. Though this is a pretty complicated attack + * since you'd have to get inside the cookie. + */ + if (!sctp_sf_check_restart_addrs(new_asoc, asoc, chunk, commands)) { + return SCTP_DISPOSITION_CONSUME; + } + + /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes + * the peer has restarted (Action A), it MUST NOT setup a new + * association but instead resend the SHUTDOWN ACK and send an ERROR + * chunk with a ""Cookie Received while Shutting Down"" error cause to + * its peer. + */ + if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) { + disposition = sctp_sf_do_9_2_reshutack(net, ep, asoc, + SCTP_ST_CHUNK(chunk->chunk_hdr->type), + chunk, commands); + if (SCTP_DISPOSITION_NOMEM == disposition) + goto nomem; + + err = sctp_make_op_error(asoc, chunk, + SCTP_ERROR_COOKIE_IN_SHUTDOWN, + NULL, 0, 0); + if (err) + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, + SCTP_CHUNK(err)); + + return SCTP_DISPOSITION_CONSUME; + } + + /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked + * data. Consider the optional choice of resending of this data. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_T3_RTX_TIMERS_STOP, SCTP_NULL()); + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, + SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); + sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_OUTQUEUE, SCTP_NULL()); + + /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue + * and ASCONF-ACK cache. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, + SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); + sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_ASCONF_QUEUE, SCTP_NULL()); + + repl = sctp_make_cookie_ack(new_asoc, chunk); + if (!repl) + goto nomem; + + /* Report association restart to upper layer. */ + ev = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_RESTART, 0, + new_asoc->c.sinit_num_ostreams, + new_asoc->c.sinit_max_instreams, + NULL, GFP_ATOMIC); + if (!ev) + goto nomem_ev; + + /* Update the content of current association. */ + sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, + SCTP_STATE(SCTP_STATE_ESTABLISHED)); + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); + return SCTP_DISPOSITION_CONSUME; + +nomem_ev: + sctp_chunk_free(repl); +nomem: + return SCTP_DISPOSITION_NOMEM; +} +","@@ -2082,7 +2082,7 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(struct net *net, + } + + /* Delete the tempory new association. */ +- sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); ++ sctp_add_cmd_sf(commands, SCTP_CMD_SET_ASOC, SCTP_ASOC(new_asoc)); + sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); + + /* Restore association pointer to provide SCTP command interpeter",894,1130,2048 +1796,"dmxProcRenderCompositeGlyphs(ClientPtr client) +{ + int ret; + + REQUEST(xRenderCompositeGlyphsReq); + + ret = dmxSaveRenderVector[stuff->renderReqType] (client); + + /* For the following to work with PanoramiX, it assumes that Render + * wraps the ProcRenderVector after dmxRenderInit has been called. + */ + if (ret == Success) { + PicturePtr pSrc; + dmxPictPrivPtr pSrcPriv; + PicturePtr pDst; + dmxPictPrivPtr pDstPriv; + PictFormatPtr pFmt; + XRenderPictFormat *pFormat; + int size; + + int scrnNum; + DMXScreenInfo *dmxScreen; + + CARD8 *buffer; + CARD8 *end; + int space; + + int nglyph; + char *glyphs; + char *curGlyph; + + xGlyphElt *elt; + int nelt; + XGlyphElt8 *elts; + XGlyphElt8 *curElt; + + GlyphSetPtr glyphSet; + dmxGlyphPrivPtr glyphPriv; + + dixLookupResourceByType((void **) &pSrc, + stuff->src, PictureType, client, DixReadAccess); + + pSrcPriv = DMX_GET_PICT_PRIV(pSrc); + if (!pSrcPriv->pict) + return ret; + + dixLookupResourceByType((void **) &pDst, + stuff->dst, PictureType, + client, DixWriteAccess); + + pDstPriv = DMX_GET_PICT_PRIV(pDst); + if (!pDstPriv->pict) + return ret; + + scrnNum = pDst->pDrawable->pScreen->myNum; + dmxScreen = &dmxScreens[scrnNum]; + + /* Note: If the back-end display has been detached, then it + * should not be possible to reach here since the pSrcPriv->pict + * and pDstPriv->pict will have already been set to 0. + */ + if (!dmxScreen->beDisplay) + return ret; + + if (stuff->maskFormat) + dixLookupResourceByType((void **) &pFmt, + stuff->maskFormat, PictFormatType, + client, DixReadAccess); + else + pFmt = NULL; + + pFormat = dmxFindFormat(dmxScreen, pFmt); + + switch (stuff->renderReqType) { + case X_RenderCompositeGlyphs8: + size = sizeof(CARD8); + break; + case X_RenderCompositeGlyphs16: + size = sizeof(CARD16); + break; + case X_RenderCompositeGlyphs32: + size = sizeof(CARD32); + break; + default: + return BadPictOp; /* Can't happen */ + } + + buffer = (CARD8 *) (stuff + 1); + end = (CARD8 *) stuff + (stuff->length << 2); + nelt = 0; + nglyph = 0; + while (buffer + sizeof(xGlyphElt) < end) { + elt = (xGlyphElt *) buffer; + buffer += sizeof(xGlyphElt); + + if (elt->len == 0xff) { + buffer += 4; + } + else { + nelt++; + nglyph += elt->len; + space = size * elt->len; + if (space & 3) + space += 4 - (space & 3); + buffer += space; + } + } + + /* The following only works for Render version > 0.2 */ + + /* All of the XGlyphElt* structure sizes are identical */ + elts = xallocarray(nelt, sizeof(XGlyphElt8)); + if (!elts) + return BadAlloc; + + glyphs = xallocarray(nglyph, size); + if (!glyphs) { + free(elts); + return BadAlloc; + } + + buffer = (CARD8 *) (stuff + 1); + end = (CARD8 *) stuff + (stuff->length << 2); + curGlyph = glyphs; + curElt = elts; + + dixLookupResourceByType((void **) &glyphSet, + stuff->glyphset, GlyphSetType, + client, DixReadAccess); + glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); + + while (buffer + sizeof(xGlyphElt) < end) { + elt = (xGlyphElt *) buffer; + buffer += sizeof(xGlyphElt); + + if (elt->len == 0xff) { + dixLookupResourceByType((void **) &glyphSet, + *((CARD32 *) buffer), + GlyphSetType, client, DixReadAccess); + glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); + buffer += 4; + } + else { + curElt->glyphset = glyphPriv->glyphSets[scrnNum]; + curElt->xOff = elt->deltax; + curElt->yOff = elt->deltay; + curElt->nchars = elt->len; + curElt->chars = curGlyph; + + memcpy(curGlyph, buffer, size * elt->len); + curGlyph += size * elt->len; + + curElt++; + + space = size * elt->len; + if (space & 3) + space += 4 - (space & 3); + buffer += space; + } + } + + switch (stuff->renderReqType) { + case X_RenderCompositeGlyphs8: + XRenderCompositeText8(dmxScreen->beDisplay, stuff->op, + pSrcPriv->pict, pDstPriv->pict, + pFormat, + stuff->xSrc, stuff->ySrc, 0, 0, elts, nelt); + break; + case X_RenderCompositeGlyphs16: + XRenderCompositeText16(dmxScreen->beDisplay, stuff->op, + pSrcPriv->pict, pDstPriv->pict, + pFormat, + stuff->xSrc, stuff->ySrc, + 0, 0, (XGlyphElt16 *) elts, nelt); + break; + case X_RenderCompositeGlyphs32: + XRenderCompositeText32(dmxScreen->beDisplay, stuff->op, + pSrcPriv->pict, pDstPriv->pict, + pFormat, + stuff->xSrc, stuff->ySrc, + 0, 0, (XGlyphElt32 *) elts, nelt); + break; + } + + dmxSync(dmxScreen, FALSE); + + free(elts); + free(glyphs); + } + + return ret; +} +",0,"dmxProcRenderCompositeGlyphs(ClientPtr client) +{ + int ret; + + REQUEST(xRenderCompositeGlyphsReq); + + ret = dmxSaveRenderVector[stuff->renderReqType] (client); + + /* For the following to work with PanoramiX, it assumes that Render + * wraps the ProcRenderVector after dmxRenderInit has been called. + */ + if (ret == Success) { + PicturePtr pSrc; + dmxPictPrivPtr pSrcPriv; + PicturePtr pDst; + dmxPictPrivPtr pDstPriv; + PictFormatPtr pFmt; + XRenderPictFormat *pFormat; + int size; + + int scrnNum; + DMXScreenInfo *dmxScreen; + + CARD8 *buffer; + CARD8 *end; + int space; + + int nglyph; + char *glyphs; + char *curGlyph; + + xGlyphElt *elt; + int nelt; + XGlyphElt8 *elts; + XGlyphElt8 *curElt; + + GlyphSetPtr glyphSet; + dmxGlyphPrivPtr glyphPriv; + + dixLookupResourceByType((void **) &pSrc, + stuff->src, PictureType, client, DixReadAccess); + + pSrcPriv = DMX_GET_PICT_PRIV(pSrc); + if (!pSrcPriv->pict) + return ret; + + dixLookupResourceByType((void **) &pDst, + stuff->dst, PictureType, + client, DixWriteAccess); + + pDstPriv = DMX_GET_PICT_PRIV(pDst); + if (!pDstPriv->pict) + return ret; + + scrnNum = pDst->pDrawable->pScreen->myNum; + dmxScreen = &dmxScreens[scrnNum]; + + /* Note: If the back-end display has been detached, then it + * should not be possible to reach here since the pSrcPriv->pict + * and pDstPriv->pict will have already been set to 0. + */ + if (!dmxScreen->beDisplay) + return ret; + + if (stuff->maskFormat) + dixLookupResourceByType((void **) &pFmt, + stuff->maskFormat, PictFormatType, + client, DixReadAccess); + else + pFmt = NULL; + + pFormat = dmxFindFormat(dmxScreen, pFmt); + + switch (stuff->renderReqType) { + case X_RenderCompositeGlyphs8: + size = sizeof(CARD8); + break; + case X_RenderCompositeGlyphs16: + size = sizeof(CARD16); + break; + case X_RenderCompositeGlyphs32: + size = sizeof(CARD32); + break; + default: + return BadPictOp; /* Can't happen */ + } + + buffer = (CARD8 *) (stuff + 1); + end = (CARD8 *) stuff + (stuff->length << 2); + nelt = 0; + nglyph = 0; + while (buffer + sizeof(xGlyphElt) < end) { + elt = (xGlyphElt *) buffer; + buffer += sizeof(xGlyphElt); + + if (elt->len == 0xff) { + buffer += 4; + } + else { + nelt++; + nglyph += elt->len; + space = size * elt->len; + if (space & 3) + space += 4 - (space & 3); + buffer += space; + } + } + + /* The following only works for Render version > 0.2 */ + + /* All of the XGlyphElt* structure sizes are identical */ + elts = xallocarray(nelt, sizeof(XGlyphElt8)); + if (!elts) + return BadAlloc; + + glyphs = xallocarray(nglyph, size); + if (!glyphs) { + free(elts); + return BadAlloc; + } + + buffer = (CARD8 *) (stuff + 1); + end = (CARD8 *) stuff + (stuff->length << 2); + curGlyph = glyphs; + curElt = elts; + + dixLookupResourceByType((void **) &glyphSet, + stuff->glyphset, GlyphSetType, + client, DixReadAccess); + glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); + + while (buffer + sizeof(xGlyphElt) < end) { + elt = (xGlyphElt *) buffer; + buffer += sizeof(xGlyphElt); + + if (elt->len == 0xff) { + dixLookupResourceByType((void **) &glyphSet, + *((CARD32 *) buffer), + GlyphSetType, client, DixReadAccess); + glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); + buffer += 4; + } + else { + curElt->glyphset = glyphPriv->glyphSets[scrnNum]; + curElt->xOff = elt->deltax; + curElt->yOff = elt->deltay; + curElt->nchars = elt->len; + curElt->chars = curGlyph; + + memcpy(curGlyph, buffer, size * elt->len); + curGlyph += size * elt->len; + + curElt++; + + space = size * elt->len; + if (space & 3) + space += 4 - (space & 3); + buffer += space; + } + } + + switch (stuff->renderReqType) { + case X_RenderCompositeGlyphs8: + XRenderCompositeText8(dmxScreen->beDisplay, stuff->op, + pSrcPriv->pict, pDstPriv->pict, + pFormat, + stuff->xSrc, stuff->ySrc, 0, 0, elts, nelt); + break; + case X_RenderCompositeGlyphs16: + XRenderCompositeText16(dmxScreen->beDisplay, stuff->op, + pSrcPriv->pict, pDstPriv->pict, + pFormat, + stuff->xSrc, stuff->ySrc, + 0, 0, (XGlyphElt16 *) elts, nelt); + break; + case X_RenderCompositeGlyphs32: + XRenderCompositeText32(dmxScreen->beDisplay, stuff->op, + pSrcPriv->pict, pDstPriv->pict, + pFormat, + stuff->xSrc, stuff->ySrc, + 0, 0, (XGlyphElt32 *) elts, nelt); + break; + } + + dmxSync(dmxScreen, FALSE); + + free(elts); + free(glyphs); + } + + return ret; +} +","@@ -716,6 +716,8 @@ dmxProcRenderSetPictureFilter(ClientPtr client) + filter = (char *) (stuff + 1); + params = (XFixed *) (filter + ((stuff->nbytes + 3) & ~3)); + nparams = ((XFixed *) stuff + client->req_len) - params; ++ if (nparams < 0) ++ return BadLength; + + XRenderSetPictureFilter(dmxScreen->beDisplay, + pPictPriv->pict, filter, params, nparams);",1454,1690,2048 +85,"void ArthurOutputDev::updateFont(GfxState *state) +{ + GfxFont *gfxFont; + GfxFontType fontType; + SplashOutFontFileID *id; + SplashFontFile *fontFile; + SplashFontSrc *fontsrc; + FoFiTrueType *ff; + Ref embRef; + Object refObj, strObj; + GooString *fileName; + char *tmpBuf; + int tmpBufLen; + Gushort *codeToGID; + DisplayFontParam *dfp; + double *textMat; + double m11, m12, m21, m22, fontSize; + SplashCoord mat[4]; + int substIdx, n; + int faceIndex = 0; + SplashCoord matrix[6]; + + m_needFontUpdate = false; + m_font = NULL; + fileName = NULL; + tmpBuf = NULL; + substIdx = -1; + + if (!(gfxFont = state->getFont())) { + goto err1; + } + fontType = gfxFont->getType(); + if (fontType == fontType3) { + goto err1; + } + + id = new SplashOutFontFileID(gfxFont->getID()); + if ((fontFile = m_fontEngine->getFontFile(id))) { + delete id; + + } else { + + if (gfxFont->getEmbeddedFontID(&embRef)) { + tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); + if (! tmpBuf) + goto err2; + } else if (!(fileName = gfxFont->getExtFontFile())) { + + dfp = NULL; + if (gfxFont->getName()) { + dfp = globalParams->getDisplayFont(gfxFont); + } + if (!dfp) { + error(-1, ""Couldn't find a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + switch (dfp->kind) { + case displayFontT1: + fileName = dfp->t1.fileName; + fontType = gfxFont->isCIDFont() ? fontCIDType0 : fontType1; + break; + case displayFontTT: + fileName = dfp->tt.fileName; + fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType; + faceIndex = dfp->tt.faceIndex; + break; + } + } + + fontsrc = new SplashFontSrc; + if (fileName) + fontsrc->setFile(fileName, gFalse); + else + fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse); + + switch (fontType) { + case fontType1: + if (!(fontFile = m_fontEngine->loadType1Font( + id, + fontsrc, + ((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontType1C: + if (!(fontFile = m_fontEngine->loadType1CFont( + id, + fontsrc, + ((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontType1COT: + if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont( + id, + fontsrc, + ((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontTrueType: + case fontTrueTypeOT: + if (fileName) + ff = FoFiTrueType::load(fileName->getCString()); + else + ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + if (ff) { + codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); + n = 256; + delete ff; + } else { + codeToGID = NULL; + n = 0; + } + if (!(fontFile = m_fontEngine->loadTrueTypeFont( + id, + fontsrc, + codeToGID, n))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontCIDType0: + case fontCIDType0C: + if (!(fontFile = m_fontEngine->loadCIDFont( + id, + fontsrc))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontCIDType0COT: + if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont( + id, + fontsrc))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontCIDType2: + case fontCIDType2OT: + codeToGID = NULL; + n = 0; + if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { + n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); + if (n) { + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); + memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), + n * sizeof(Gushort)); + } + } else { + if (fileName) + ff = FoFiTrueType::load(fileName->getCString()); + else + ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + if (! ff) + goto err2; + codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); + delete ff; + } + if (!(fontFile = m_fontEngine->loadTrueTypeFont( + id, + fontsrc, + codeToGID, n, faceIndex))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + default: + goto err2; + } + } + + textMat = state->getTextMat(); + fontSize = state->getFontSize(); + m11 = textMat[0] * fontSize * state->getHorizScaling(); + m12 = textMat[1] * fontSize * state->getHorizScaling(); + m21 = textMat[2] * fontSize; + m22 = textMat[3] * fontSize; + + { + QMatrix painterMatrix = m_painter->worldMatrix(); + matrix[0] = painterMatrix.m11(); + matrix[1] = painterMatrix.m12(); + matrix[2] = painterMatrix.m21(); + matrix[3] = painterMatrix.m22(); + matrix[4] = painterMatrix.dx(); + matrix[5] = painterMatrix.dy(); + } + + mat[0] = m11; mat[1] = -m12; + mat[2] = m21; mat[3] = -m22; + m_font = m_fontEngine->getFont(fontFile, mat, matrix); + + return; + + err2: + delete id; + err1: + return; +} +",0,"void ArthurOutputDev::updateFont(GfxState *state) +{ + GfxFont *gfxFont; + GfxFontType fontType; + SplashOutFontFileID *id; + SplashFontFile *fontFile; + SplashFontSrc *fontsrc; + FoFiTrueType *ff; + Ref embRef; + Object refObj, strObj; + GooString *fileName; + char *tmpBuf; + int tmpBufLen; + Gushort *codeToGID; + DisplayFontParam *dfp; + double *textMat; + double m11, m12, m21, m22, fontSize; + SplashCoord mat[4]; + int substIdx, n; + int faceIndex = 0; + SplashCoord matrix[6]; + + m_needFontUpdate = false; + m_font = NULL; + fileName = NULL; + tmpBuf = NULL; + substIdx = -1; + + if (!(gfxFont = state->getFont())) { + goto err1; + } + fontType = gfxFont->getType(); + if (fontType == fontType3) { + goto err1; + } + + id = new SplashOutFontFileID(gfxFont->getID()); + if ((fontFile = m_fontEngine->getFontFile(id))) { + delete id; + + } else { + + if (gfxFont->getEmbeddedFontID(&embRef)) { + tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); + if (! tmpBuf) + goto err2; + } else if (!(fileName = gfxFont->getExtFontFile())) { + + dfp = NULL; + if (gfxFont->getName()) { + dfp = globalParams->getDisplayFont(gfxFont); + } + if (!dfp) { + error(-1, ""Couldn't find a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + switch (dfp->kind) { + case displayFontT1: + fileName = dfp->t1.fileName; + fontType = gfxFont->isCIDFont() ? fontCIDType0 : fontType1; + break; + case displayFontTT: + fileName = dfp->tt.fileName; + fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType; + faceIndex = dfp->tt.faceIndex; + break; + } + } + + fontsrc = new SplashFontSrc; + if (fileName) + fontsrc->setFile(fileName, gFalse); + else + fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse); + + switch (fontType) { + case fontType1: + if (!(fontFile = m_fontEngine->loadType1Font( + id, + fontsrc, + ((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontType1C: + if (!(fontFile = m_fontEngine->loadType1CFont( + id, + fontsrc, + ((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontType1COT: + if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont( + id, + fontsrc, + ((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontTrueType: + case fontTrueTypeOT: + if (fileName) + ff = FoFiTrueType::load(fileName->getCString()); + else + ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + if (ff) { + codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); + n = 256; + delete ff; + } else { + codeToGID = NULL; + n = 0; + } + if (!(fontFile = m_fontEngine->loadTrueTypeFont( + id, + fontsrc, + codeToGID, n))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontCIDType0: + case fontCIDType0C: + if (!(fontFile = m_fontEngine->loadCIDFont( + id, + fontsrc))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontCIDType0COT: + if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont( + id, + fontsrc))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + case fontCIDType2: + case fontCIDType2OT: + codeToGID = NULL; + n = 0; + if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { + n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); + if (n) { + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); + memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), + n * sizeof(Gushort)); + } + } else { + if (fileName) + ff = FoFiTrueType::load(fileName->getCString()); + else + ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + if (! ff) + goto err2; + codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); + delete ff; + } + if (!(fontFile = m_fontEngine->loadTrueTypeFont( + id, + fontsrc, + codeToGID, n, faceIndex))) { + error(-1, ""Couldn't create a font for '%s'"", + gfxFont->getName() ? gfxFont->getName()->getCString() + : ""(unnamed)""); + goto err2; + } + break; + default: + goto err2; + } + } + + textMat = state->getTextMat(); + fontSize = state->getFontSize(); + m11 = textMat[0] * fontSize * state->getHorizScaling(); + m12 = textMat[1] * fontSize * state->getHorizScaling(); + m21 = textMat[2] * fontSize; + m22 = textMat[3] * fontSize; + + { + QMatrix painterMatrix = m_painter->worldMatrix(); + matrix[0] = painterMatrix.m11(); + matrix[1] = painterMatrix.m12(); + matrix[2] = painterMatrix.m21(); + matrix[3] = painterMatrix.m22(); + matrix[4] = painterMatrix.dx(); + matrix[5] = painterMatrix.dy(); + } + + mat[0] = m11; mat[1] = -m12; + mat[2] = m21; mat[3] = -m22; + m_font = m_fontEngine->getFont(fontFile, mat, matrix); + + return; + + err2: + delete id; + err1: + return; +} +","@@ -14,7 +14,7 @@ + // under GPL version 2 or later + // + // Copyright (C) 2005 Brad Hards +-// Copyright (C) 2005-2008 Albert Astals Cid ++// Copyright (C) 2005-2009 Albert Astals Cid + // Copyright (C) 2008 Pino Toscano + // + // To see a description of the changes please see the Changelog file that +@@ -751,7 +751,7 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, + QMatrix matrix; + int is_identity_transform; + +- buffer = (unsigned char *)gmalloc (width * height * 4); ++ buffer = (unsigned char *)gmallocn3(width, height, 4); + + /* TODO: Do we want to cache these? */ + imgStr = new ImageStream(str, width,",1719,1955,2048 +1711,"pdf_obj_read(fz_context *ctx, pdf_document *doc, int64_t *offset, int *nump, pdf_obj **page) +{ + pdf_lexbuf *buf = &doc->lexbuf.base; + int num, gen, tok; + int64_t numofs, genofs, stmofs, tmpofs, newtmpofs; + int xref_len; + pdf_xref_entry *entry; + + numofs = *offset; + fz_seek(ctx, doc->file, numofs, SEEK_SET); + + /* We expect to read 'num' here */ + tok = pdf_lex(ctx, doc->file, buf); + genofs = fz_tell(ctx, doc->file); + if (tok != PDF_TOK_INT) + { + /* Failed! */ + DEBUGMESS((ctx, ""skipping unexpected data (tok=%d) at %d"", tok, *offset)); + *offset = genofs; + return tok == PDF_TOK_EOF; + } + *nump = num = buf->i; + + /* We expect to read 'gen' here */ + tok = pdf_lex(ctx, doc->file, buf); + tmpofs = fz_tell(ctx, doc->file); + if (tok != PDF_TOK_INT) + { + /* Failed! */ + DEBUGMESS((ctx, ""skipping unexpected data after \""%d\"" (tok=%d) at %d"", num, tok, *offset)); + *offset = tmpofs; + return tok == PDF_TOK_EOF; + } + gen = buf->i; + + /* We expect to read 'obj' here */ + do + { + tmpofs = fz_tell(ctx, doc->file); + tok = pdf_lex(ctx, doc->file, buf); + if (tok == PDF_TOK_OBJ) + break; + if (tok != PDF_TOK_INT) + { + DEBUGMESS((ctx, ""skipping unexpected data (tok=%d) at %d"", tok, tmpofs)); + *offset = fz_tell(ctx, doc->file); + return tok == PDF_TOK_EOF; + } + DEBUGMESS((ctx, ""skipping unexpected int %d at %d"", num, numofs)); + *nump = num = gen; + numofs = genofs; + gen = buf->i; + genofs = tmpofs; + } + while (1); + + /* Now we read the actual object */ + xref_len = pdf_xref_len(ctx, doc); + + /* When we are reading a progressive file, we typically see: + * File Header + * obj m (Linearization params) + * xref #1 (refers to objects m-n) + * obj m+1 + * ... + * obj n + * obj 1 + * ... + * obj n-1 + * xref #2 + * + * The linearisation params are read elsewhere, hence + * whenever we read an object it should just go into the + * previous xref. + */ + tok = pdf_repair_obj(ctx, doc, buf, &stmofs, NULL, NULL, NULL, page, &newtmpofs, NULL); + + do /* So we can break out of it */ + { + if (num <= 0 || num >= xref_len) + { + fz_warn(ctx, ""Not a valid object number (%d %d obj)"", num, gen); + break; + } + if (gen != 0) + { + fz_warn(ctx, ""Unexpected non zero generation number in linearized file""); + } + entry = pdf_get_populating_xref_entry(ctx, doc, num); + if (entry->type != 0) + { + DEBUGMESS((ctx, ""Duplicate object found (%d %d obj)"", num, gen)); + break; + } + if (page && *page) + { + DEBUGMESS((ctx, ""Successfully read object %d @ %d - and found page %d!"", num, numofs, doc->linear_page_num)); + if (!entry->obj) + entry->obj = pdf_keep_obj(ctx, *page); + + if (doc->linear_page_refs[doc->linear_page_num] == NULL) + doc->linear_page_refs[doc->linear_page_num] = pdf_new_indirect(ctx, doc, num, gen); + } + else + { + DEBUGMESS((ctx, ""Successfully read object %d @ %d"", num, numofs)); + } + entry->type = 'n'; + entry->gen = gen; // XXX: was 0 + entry->num = num; + entry->ofs = numofs; + entry->stm_ofs = stmofs; + } + while (0); + if (page && *page) + doc->linear_page_num++; + + if (tok == PDF_TOK_ENDOBJ) + { + *offset = fz_tell(ctx, doc->file); + } + else + { + *offset = newtmpofs; + } + return 0; +} +",0,"pdf_obj_read(fz_context *ctx, pdf_document *doc, int64_t *offset, int *nump, pdf_obj **page) +{ + pdf_lexbuf *buf = &doc->lexbuf.base; + int num, gen, tok; + int64_t numofs, genofs, stmofs, tmpofs, newtmpofs; + int xref_len; + pdf_xref_entry *entry; + + numofs = *offset; + fz_seek(ctx, doc->file, numofs, SEEK_SET); + + /* We expect to read 'num' here */ + tok = pdf_lex(ctx, doc->file, buf); + genofs = fz_tell(ctx, doc->file); + if (tok != PDF_TOK_INT) + { + /* Failed! */ + DEBUGMESS((ctx, ""skipping unexpected data (tok=%d) at %d"", tok, *offset)); + *offset = genofs; + return tok == PDF_TOK_EOF; + } + *nump = num = buf->i; + + /* We expect to read 'gen' here */ + tok = pdf_lex(ctx, doc->file, buf); + tmpofs = fz_tell(ctx, doc->file); + if (tok != PDF_TOK_INT) + { + /* Failed! */ + DEBUGMESS((ctx, ""skipping unexpected data after \""%d\"" (tok=%d) at %d"", num, tok, *offset)); + *offset = tmpofs; + return tok == PDF_TOK_EOF; + } + gen = buf->i; + + /* We expect to read 'obj' here */ + do + { + tmpofs = fz_tell(ctx, doc->file); + tok = pdf_lex(ctx, doc->file, buf); + if (tok == PDF_TOK_OBJ) + break; + if (tok != PDF_TOK_INT) + { + DEBUGMESS((ctx, ""skipping unexpected data (tok=%d) at %d"", tok, tmpofs)); + *offset = fz_tell(ctx, doc->file); + return tok == PDF_TOK_EOF; + } + DEBUGMESS((ctx, ""skipping unexpected int %d at %d"", num, numofs)); + *nump = num = gen; + numofs = genofs; + gen = buf->i; + genofs = tmpofs; + } + while (1); + + /* Now we read the actual object */ + xref_len = pdf_xref_len(ctx, doc); + + /* When we are reading a progressive file, we typically see: + * File Header + * obj m (Linearization params) + * xref #1 (refers to objects m-n) + * obj m+1 + * ... + * obj n + * obj 1 + * ... + * obj n-1 + * xref #2 + * + * The linearisation params are read elsewhere, hence + * whenever we read an object it should just go into the + * previous xref. + */ + tok = pdf_repair_obj(ctx, doc, buf, &stmofs, NULL, NULL, NULL, page, &newtmpofs, NULL); + + do /* So we can break out of it */ + { + if (num <= 0 || num >= xref_len) + { + fz_warn(ctx, ""Not a valid object number (%d %d obj)"", num, gen); + break; + } + if (gen != 0) + { + fz_warn(ctx, ""Unexpected non zero generation number in linearized file""); + } + entry = pdf_get_populating_xref_entry(ctx, doc, num); + if (entry->type != 0) + { + DEBUGMESS((ctx, ""Duplicate object found (%d %d obj)"", num, gen)); + break; + } + if (page && *page) + { + DEBUGMESS((ctx, ""Successfully read object %d @ %d - and found page %d!"", num, numofs, doc->linear_page_num)); + if (!entry->obj) + entry->obj = pdf_keep_obj(ctx, *page); + + if (doc->linear_page_refs[doc->linear_page_num] == NULL) + doc->linear_page_refs[doc->linear_page_num] = pdf_new_indirect(ctx, doc, num, gen); + } + else + { + DEBUGMESS((ctx, ""Successfully read object %d @ %d"", num, numofs)); + } + entry->type = 'n'; + entry->gen = gen; // XXX: was 0 + entry->num = num; + entry->ofs = numofs; + entry->stm_ofs = stmofs; + } + while (0); + if (page && *page) + doc->linear_page_num++; + + if (tok == PDF_TOK_ENDOBJ) + { + *offset = fz_tell(ctx, doc->file); + } + else + { + *offset = newtmpofs; + } + return 0; +} +","@@ -868,11 +868,12 @@ pdf_read_old_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf) + fz_seek(ctx, file, -(2 + (int)strlen(s)), SEEK_CUR); + } + +- if (ofs < 0) +- fz_throw(ctx, FZ_ERROR_GENERIC, ""out of range object num in xref: %d"", (int)ofs); +- if (ofs > INT64_MAX - len) +- fz_throw(ctx, FZ_ERROR_GENERIC, ""xref section object numbers too big""); +- ++ if (ofs < 0 || ofs > PDF_MAX_OBJECT_NUMBER ++ || len < 0 || len > PDF_MAX_OBJECT_NUMBER ++ || ofs + len - 1 > PDF_MAX_OBJECT_NUMBER) ++ { ++ fz_throw(ctx, FZ_ERROR_GENERIC, ""xref subsection object numbers are out of range""); ++ } + /* broken pdfs where size in trailer undershoots entries in xref sections */ + if (ofs + len > xref_len) + { +@@ -933,10 +934,8 @@ pdf_read_new_xref_section(fz_context *ctx, pdf_document *doc, fz_stream *stm, in + pdf_xref_entry *table; + int i, n; + +- if (i0 < 0 || i1 < 0 || i0 > INT_MAX - i1) +- fz_throw(ctx, FZ_ERROR_GENERIC, ""negative xref stream entry index""); +- //if (i0 + i1 > pdf_xref_len(ctx, doc)) +- // fz_throw(ctx, FZ_ERROR_GENERIC, ""xref stream has too many entries""); ++ if (i0 < 0 || i0 > PDF_MAX_OBJECT_NUMBER || i1 < 0 || i1 > PDF_MAX_OBJECT_NUMBER || i0 + i1 - 1 > PDF_MAX_OBJECT_NUMBER) ++ fz_throw(ctx, FZ_ERROR_GENERIC, ""xref subsection object numbers are out of range""); + + table = pdf_xref_find_subsection(ctx, doc, i0, i1); + for (i = i0; i < i0 + i1; i++) +@@ -2086,6 +2085,10 @@ pdf_create_object(fz_context *ctx, pdf_document *doc) + /* TODO: reuse free object slots by properly linking free object chains in the ofs field */ + pdf_xref_entry *entry; + int num = pdf_xref_len(ctx, doc); ++ ++ if (num > PDF_MAX_OBJECT_NUMBER) ++ fz_throw(ctx, FZ_ERROR_GENERIC, ""too many objects stored in pdf""); ++ + entry = pdf_get_incremental_xref_entry(ctx, doc, num); + entry->type = 'f'; + entry->ofs = -1;",1078,1314,2048 +18165,"static Image *ReadMAPImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image + *image; + + IndexPacket + index; + + MagickBooleanType + status; + + register IndexPacket + *indexes; + + register ssize_t + x; + + register PixelPacket + *q; + + register ssize_t + i; + + register unsigned char + *p; + + size_t + depth, + packet_size, + quantum; + + ssize_t + count, + y; + + unsigned char + *colormap, + *pixels; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + if ((image->columns == 0) || (image->rows == 0)) + ThrowReaderException(OptionError,""MustSpecifyImageSize""); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Initialize image structure. + */ + image->storage_class=PseudoClass; + status=AcquireImageColormap(image,(size_t) + (image->offset != 0 ? image->offset : 256)); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + depth=GetImageQuantumDepth(image,MagickTrue); + packet_size=(size_t) (depth/8); + pixels=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size* + sizeof(*pixels)); + packet_size=(size_t) (image->colors > 256 ? 6UL : 3UL); + colormap=(unsigned char *) AcquireQuantumMemory(image->colors,packet_size* + sizeof(*colormap)); + if ((pixels == (unsigned char *) NULL) || + (colormap == (unsigned char *) NULL)) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + /* + Read image colormap. + */ + count=ReadBlob(image,packet_size*image->colors,colormap); + if (count != (ssize_t) (packet_size*image->colors)) + ThrowReaderException(CorruptImageError,""InsufficientImageDataInFile""); + p=colormap; + if (image->depth <= 8) + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } + else + for (i=0; i < (ssize_t) image->colors; i++) + { + quantum=(*p++ << 8); + quantum|=(*p++); + image->colormap[i].red=(Quantum) quantum; + quantum=(*p++ << 8); + quantum|=(*p++); + image->colormap[i].green=(Quantum) quantum; + quantum=(*p++ << 8); + quantum|=(*p++); + image->colormap[i].blue=(Quantum) quantum; + } + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + /* + Read image pixels. + */ + packet_size=(size_t) (depth/8); + for (y=0; y < (ssize_t) image->rows; y++) + { + p=pixels; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + count=ReadBlob(image,(size_t) packet_size*image->columns,pixels); + if (count != (ssize_t) (packet_size*image->columns)) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + index=ConstrainColormapIndex(image,*p); + p++; + if (image->colors > 256) + { + index=ConstrainColormapIndex(image,((size_t) index << 8)+(*p)); + p++; + } + SetPixelIndex(indexes+x,index); + SetPixelRGBO(q,image->colormap+(ssize_t) index); + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + if (y < (ssize_t) image->rows) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadMAPImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image + *image; + + IndexPacket + index; + + MagickBooleanType + status; + + register IndexPacket + *indexes; + + register ssize_t + x; + + register PixelPacket + *q; + + register ssize_t + i; + + register unsigned char + *p; + + size_t + depth, + packet_size, + quantum; + + ssize_t + count, + y; + + unsigned char + *colormap, + *pixels; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + if ((image->columns == 0) || (image->rows == 0)) + ThrowReaderException(OptionError,""MustSpecifyImageSize""); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Initialize image structure. + */ + image->storage_class=PseudoClass; + status=AcquireImageColormap(image,(size_t) + (image->offset != 0 ? image->offset : 256)); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + depth=GetImageQuantumDepth(image,MagickTrue); + packet_size=(size_t) (depth/8); + pixels=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size* + sizeof(*pixels)); + packet_size=(size_t) (image->colors > 256 ? 6UL : 3UL); + colormap=(unsigned char *) AcquireQuantumMemory(image->colors,packet_size* + sizeof(*colormap)); + if ((pixels == (unsigned char *) NULL) || + (colormap == (unsigned char *) NULL)) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + /* + Read image colormap. + */ + count=ReadBlob(image,packet_size*image->colors,colormap); + if (count != (ssize_t) (packet_size*image->colors)) + ThrowReaderException(CorruptImageError,""InsufficientImageDataInFile""); + p=colormap; + if (image->depth <= 8) + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } + else + for (i=0; i < (ssize_t) image->colors; i++) + { + quantum=(*p++ << 8); + quantum|=(*p++); + image->colormap[i].red=(Quantum) quantum; + quantum=(*p++ << 8); + quantum|=(*p++); + image->colormap[i].green=(Quantum) quantum; + quantum=(*p++ << 8); + quantum|=(*p++); + image->colormap[i].blue=(Quantum) quantum; + } + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + /* + Read image pixels. + */ + packet_size=(size_t) (depth/8); + for (y=0; y < (ssize_t) image->rows; y++) + { + p=pixels; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + count=ReadBlob(image,(size_t) packet_size*image->columns,pixels); + if (count != (ssize_t) (packet_size*image->columns)) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + index=ConstrainColormapIndex(image,*p); + p++; + if (image->colors > 256) + { + index=ConstrainColormapIndex(image,((size_t) index << 8)+(*p)); + p++; + } + SetPixelIndex(indexes+x,index); + SetPixelRGBO(q,image->colormap+(ssize_t) index); + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + if (y < (ssize_t) image->rows) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -206,6 +206,12 @@ static Image *ReadMAPImage(const ImageInfo *image_info,ExceptionInfo *exception) + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + /* + Read image pixels. + */",1123,1359,2048 +17936," int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + unsigned char *out, size_t *out_len) +{ + unsigned char *op; + const unsigned char *ip; + size_t t, next; + size_t state = 0; + const unsigned char *m_pos; + const unsigned char * const ip_end = in + in_len; + unsigned char * const op_end = out + *out_len; + + op = out; + ip = in; + + if (unlikely(in_len < 3)) + goto input_overrun; + if (*ip > 17) { + t = *ip++ - 17; + if (t < 4) { + next = t; + goto match_next; + } + goto copy_literal_run; + } + + for (;;) { + t = *ip++; + if (t < 16) { + if (likely(state == 0)) { + if (unlikely(t == 0)) { + while (unlikely(*ip == 0)) { + t += 255; + ip++; + NEED_IP(1); + } + t += 15 + *ip++; + } + t += 3; + copy_literal_run: + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (likely(HAVE_IP(t + 15) && HAVE_OP(t + 15))) { + const unsigned char *ie = ip + t; + unsigned char *oe = op + t; + do { + COPY8(op, ip); + op += 8; + ip += 8; + COPY8(op, ip); + op += 8; + ip += 8; + } while (ip < ie); + ip = ie; + op = oe; + } else + #endif + { + NEED_OP(t); + NEED_IP(t + 3); + do { + *op++ = *ip++; + } while (--t > 0); + } + state = 4; + continue; + } else if (state != 4) { + next = t & 3; + m_pos = op - 1; + m_pos -= t >> 2; + m_pos -= *ip++ << 2; + TEST_LB(m_pos); + NEED_OP(2); + op[0] = m_pos[0]; + op[1] = m_pos[1]; + op += 2; + goto match_next; + } else { + next = t & 3; + m_pos = op - (1 + M2_MAX_OFFSET); + m_pos -= t >> 2; + m_pos -= *ip++ << 2; + t = 3; + } + } else if (t >= 64) { + next = t & 3; + m_pos = op - 1; + m_pos -= (t >> 2) & 7; + m_pos -= *ip++ << 3; + t = (t >> 5) - 1 + (3 - 1); + } else if (t >= 32) { + t = (t & 31) + (3 - 1); + if (unlikely(t == 2)) { + while (unlikely(*ip == 0)) { + t += 255; + ip++; + NEED_IP(1); + } + t += 31 + *ip++; + NEED_IP(2); + } + m_pos = op - 1; + next = get_unaligned_le16(ip); + ip += 2; + m_pos -= next >> 2; + next &= 3; + } else { + m_pos = op; + m_pos -= (t & 8) << 11; + t = (t & 7) + (3 - 1); + if (unlikely(t == 2)) { + while (unlikely(*ip == 0)) { + t += 255; + ip++; + NEED_IP(1); + } + t += 7 + *ip++; + NEED_IP(2); + } + next = get_unaligned_le16(ip); + ip += 2; + m_pos -= next >> 2; + next &= 3; + if (m_pos == op) + goto eof_found; + m_pos -= 0x4000; + } + TEST_LB(m_pos); + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (op - m_pos >= 8) { + unsigned char *oe = op + t; + if (likely(HAVE_OP(t + 15))) { + do { + COPY8(op, m_pos); + op += 8; + m_pos += 8; + COPY8(op, m_pos); + op += 8; + m_pos += 8; + } while (op < oe); + op = oe; + if (HAVE_IP(6)) { + state = next; + COPY4(op, ip); + op += next; + ip += next; + continue; + } + } else { + NEED_OP(t); + do { + *op++ = *m_pos++; + } while (op < oe); + } + } else + #endif + { + unsigned char *oe = op + t; + NEED_OP(t); + op[0] = m_pos[0]; + op[1] = m_pos[1]; + op += 2; + m_pos += 2; + do { + *op++ = *m_pos++; + } while (op < oe); + } +match_next: + state = next; + t = next; + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (likely(HAVE_IP(6) && HAVE_OP(4))) { + COPY4(op, ip); + op += t; + ip += t; + } else + #endif + { + NEED_IP(t + 3); + NEED_OP(t); + while (t > 0) { + *op++ = *ip++; + t--; + } + } + } + +eof_found: + *out_len = op - out; + return (t != 3 ? LZO_E_ERROR : + ip == ip_end ? LZO_E_OK : + ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN); + +input_overrun: + *out_len = op - out; + return LZO_E_INPUT_OVERRUN; + +output_overrun: + *out_len = op - out; + return LZO_E_OUTPUT_OVERRUN; + +lookbehind_overrun: + *out_len = op - out; + return LZO_E_LOOKBEHIND_OVERRUN; +} +",1," int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + unsigned char *out, size_t *out_len) +{ + unsigned char *op; + const unsigned char *ip; + size_t t, next; + size_t state = 0; + const unsigned char *m_pos; + const unsigned char * const ip_end = in + in_len; + unsigned char * const op_end = out + *out_len; + + op = out; + ip = in; + + if (unlikely(in_len < 3)) + goto input_overrun; + if (*ip > 17) { + t = *ip++ - 17; + if (t < 4) { + next = t; + goto match_next; + } + goto copy_literal_run; + } + + for (;;) { + t = *ip++; + if (t < 16) { + if (likely(state == 0)) { + if (unlikely(t == 0)) { + while (unlikely(*ip == 0)) { + t += 255; + ip++; + NEED_IP(1, 0); + } + t += 15 + *ip++; + } + t += 3; + copy_literal_run: + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) { + const unsigned char *ie = ip + t; + unsigned char *oe = op + t; + do { + COPY8(op, ip); + op += 8; + ip += 8; + COPY8(op, ip); + op += 8; + ip += 8; + } while (ip < ie); + ip = ie; + op = oe; + } else + #endif + { + NEED_OP(t, 0); + NEED_IP(t, 3); + do { + *op++ = *ip++; + } while (--t > 0); + } + state = 4; + continue; + } else if (state != 4) { + next = t & 3; + m_pos = op - 1; + m_pos -= t >> 2; + m_pos -= *ip++ << 2; + TEST_LB(m_pos); + NEED_OP(2, 0); + op[0] = m_pos[0]; + op[1] = m_pos[1]; + op += 2; + goto match_next; + } else { + next = t & 3; + m_pos = op - (1 + M2_MAX_OFFSET); + m_pos -= t >> 2; + m_pos -= *ip++ << 2; + t = 3; + } + } else if (t >= 64) { + next = t & 3; + m_pos = op - 1; + m_pos -= (t >> 2) & 7; + m_pos -= *ip++ << 3; + t = (t >> 5) - 1 + (3 - 1); + } else if (t >= 32) { + t = (t & 31) + (3 - 1); + if (unlikely(t == 2)) { + while (unlikely(*ip == 0)) { + t += 255; + ip++; + NEED_IP(1, 0); + } + t += 31 + *ip++; + NEED_IP(2, 0); + } + m_pos = op - 1; + next = get_unaligned_le16(ip); + ip += 2; + m_pos -= next >> 2; + next &= 3; + } else { + m_pos = op; + m_pos -= (t & 8) << 11; + t = (t & 7) + (3 - 1); + if (unlikely(t == 2)) { + while (unlikely(*ip == 0)) { + t += 255; + ip++; + NEED_IP(1, 0); + } + t += 7 + *ip++; + NEED_IP(2, 0); + } + next = get_unaligned_le16(ip); + ip += 2; + m_pos -= next >> 2; + next &= 3; + if (m_pos == op) + goto eof_found; + m_pos -= 0x4000; + } + TEST_LB(m_pos); + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (op - m_pos >= 8) { + unsigned char *oe = op + t; + if (likely(HAVE_OP(t, 15))) { + do { + COPY8(op, m_pos); + op += 8; + m_pos += 8; + COPY8(op, m_pos); + op += 8; + m_pos += 8; + } while (op < oe); + op = oe; + if (HAVE_IP(6, 0)) { + state = next; + COPY4(op, ip); + op += next; + ip += next; + continue; + } + } else { + NEED_OP(t, 0); + do { + *op++ = *m_pos++; + } while (op < oe); + } + } else + #endif + { + unsigned char *oe = op + t; + NEED_OP(t, 0); + op[0] = m_pos[0]; + op[1] = m_pos[1]; + op += 2; + m_pos += 2; + do { + *op++ = *m_pos++; + } while (op < oe); + } +match_next: + state = next; + t = next; + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) { + COPY4(op, ip); + op += t; + ip += t; + } else + #endif + { + NEED_IP(t, 3); + NEED_OP(t, 0); + while (t > 0) { + *op++ = *ip++; + t--; + } + } + } + +eof_found: + *out_len = op - out; + return (t != 3 ? LZO_E_ERROR : + ip == ip_end ? LZO_E_OK : + ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN); + +input_overrun: + *out_len = op - out; + return LZO_E_INPUT_OVERRUN; + +output_overrun: + *out_len = op - out; + return LZO_E_OUTPUT_OVERRUN; + +lookbehind_overrun: + *out_len = op - out; + return LZO_E_LOOKBEHIND_OVERRUN; +} +","@@ -19,11 +19,31 @@ + #include + #include ""lzodefs.h"" + +-#define HAVE_IP(x) ((size_t)(ip_end - ip) >= (size_t)(x)) +-#define HAVE_OP(x) ((size_t)(op_end - op) >= (size_t)(x)) +-#define NEED_IP(x) if (!HAVE_IP(x)) goto input_overrun +-#define NEED_OP(x) if (!HAVE_OP(x)) goto output_overrun +-#define TEST_LB(m_pos) if ((m_pos) < out) goto lookbehind_overrun ++#define HAVE_IP(t, x) \ ++ (((size_t)(ip_end - ip) >= (size_t)(t + x)) && \ ++ (((t + x) >= t) && ((t + x) >= x))) ++ ++#define HAVE_OP(t, x) \ ++ (((size_t)(op_end - op) >= (size_t)(t + x)) && \ ++ (((t + x) >= t) && ((t + x) >= x))) ++ ++#define NEED_IP(t, x) \ ++ do { \ ++ if (!HAVE_IP(t, x)) \ ++ goto input_overrun; \ ++ } while (0) ++ ++#define NEED_OP(t, x) \ ++ do { \ ++ if (!HAVE_OP(t, x)) \ ++ goto output_overrun; \ ++ } while (0) ++ ++#define TEST_LB(m_pos) \ ++ do { \ ++ if ((m_pos) < out) \ ++ goto lookbehind_overrun; \ ++ } while (0) + + int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + unsigned char *out, size_t *out_len) +@@ -58,14 +78,14 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + while (unlikely(*ip == 0)) { + t += 255; + ip++; +- NEED_IP(1); ++ NEED_IP(1, 0); + } + t += 15 + *ip++; + } + t += 3; + copy_literal_run: + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) +- if (likely(HAVE_IP(t + 15) && HAVE_OP(t + 15))) { ++ if (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) { + const unsigned char *ie = ip + t; + unsigned char *oe = op + t; + do { +@@ -81,8 +101,8 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + } else + #endif + { +- NEED_OP(t); +- NEED_IP(t + 3); ++ NEED_OP(t, 0); ++ NEED_IP(t, 3); + do { + *op++ = *ip++; + } while (--t > 0); +@@ -95,7 +115,7 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + m_pos -= t >> 2; + m_pos -= *ip++ << 2; + TEST_LB(m_pos); +- NEED_OP(2); ++ NEED_OP(2, 0); + op[0] = m_pos[0]; + op[1] = m_pos[1]; + op += 2; +@@ -119,10 +139,10 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + while (unlikely(*ip == 0)) { + t += 255; + ip++; +- NEED_IP(1); ++ NEED_IP(1, 0); + } + t += 31 + *ip++; +- NEED_IP(2); ++ NEED_IP(2, 0); + } + m_pos = op - 1; + next = get_unaligned_le16(ip); +@@ -137,10 +157,10 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + while (unlikely(*ip == 0)) { + t += 255; + ip++; +- NEED_IP(1); ++ NEED_IP(1, 0); + } + t += 7 + *ip++; +- NEED_IP(2); ++ NEED_IP(2, 0); + } + next = get_unaligned_le16(ip); + ip += 2; +@@ -154,7 +174,7 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + if (op - m_pos >= 8) { + unsigned char *oe = op + t; +- if (likely(HAVE_OP(t + 15))) { ++ if (likely(HAVE_OP(t, 15))) { + do { + COPY8(op, m_pos); + op += 8; +@@ -164,15 +184,15 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + m_pos += 8; + } while (op < oe); + op = oe; +- if (HAVE_IP(6)) { ++ if (HAVE_IP(6, 0)) { + state = next; + COPY4(op, ip); + op += next; + ip += next; + continue; + } + } else { +- NEED_OP(t); ++ NEED_OP(t, 0); + do { + *op++ = *m_pos++; + } while (op < oe); +@@ -181,7 +201,7 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + #endif + { + unsigned char *oe = op + t; +- NEED_OP(t); ++ NEED_OP(t, 0); + op[0] = m_pos[0]; + op[1] = m_pos[1]; + op += 2; +@@ -194,15 +214,15 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + state = next; + t = next; + #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) +- if (likely(HAVE_IP(6) && HAVE_OP(4))) { ++ if (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) { + COPY4(op, ip); + op += t; + ip += t; + } else + #endif + { +- NEED_IP(t + 3); +- NEED_OP(t); ++ NEED_IP(t, 3); ++ NEED_OP(t, 0); + while (t > 0) { + *op++ = *ip++; + t--;",1492,1728,2048 +6480,"static int check_call(struct bpf_verifier_env *env, int func_id, int insn_idx) +{ + struct bpf_verifier_state *state = &env->cur_state; + const struct bpf_func_proto *fn = NULL; + struct bpf_reg_state *regs = state->regs; + struct bpf_reg_state *reg; + struct bpf_call_arg_meta meta; + bool changes_data; + int i, err; + + /* find function prototype */ + if (func_id < 0 || func_id >= __BPF_FUNC_MAX_ID) { + verbose(""invalid func %s#%d\n"", func_id_name(func_id), func_id); + return -EINVAL; + } + + if (env->prog->aux->ops->get_func_proto) + fn = env->prog->aux->ops->get_func_proto(func_id); + + if (!fn) { + verbose(""unknown func %s#%d\n"", func_id_name(func_id), func_id); + return -EINVAL; + } + + /* eBPF programs must be GPL compatible to use GPL-ed functions */ + if (!env->prog->gpl_compatible && fn->gpl_only) { + verbose(""cannot call GPL only function from proprietary program\n""); + return -EINVAL; + } + + changes_data = bpf_helper_changes_pkt_data(fn->func); + + memset(&meta, 0, sizeof(meta)); + meta.pkt_access = fn->pkt_access; + + /* We only support one arg being in raw mode at the moment, which + * is sufficient for the helper functions we have right now. + */ + err = check_raw_mode(fn); + if (err) { + verbose(""kernel subsystem misconfigured func %s#%d\n"", + func_id_name(func_id), func_id); + return err; + } + + /* check args */ + err = check_func_arg(env, BPF_REG_1, fn->arg1_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_2, fn->arg2_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_3, fn->arg3_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_4, fn->arg4_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_5, fn->arg5_type, &meta); + if (err) + return err; + + /* Mark slots with STACK_MISC in case of raw mode, stack offset + * is inferred from register state. + */ + for (i = 0; i < meta.access_size; i++) { + err = check_mem_access(env, meta.regno, i, BPF_B, BPF_WRITE, -1); + if (err) + return err; + } + + /* reset caller saved regs */ + for (i = 0; i < CALLER_SAVED_REGS; i++) { + reg = regs + caller_saved[i]; + reg->type = NOT_INIT; + reg->imm = 0; + } + + /* update return register */ + if (fn->ret_type == RET_INTEGER) { + regs[BPF_REG_0].type = UNKNOWN_VALUE; + } else if (fn->ret_type == RET_VOID) { + regs[BPF_REG_0].type = NOT_INIT; + } else if (fn->ret_type == RET_PTR_TO_MAP_VALUE_OR_NULL) { + struct bpf_insn_aux_data *insn_aux; + + regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL; + regs[BPF_REG_0].max_value = regs[BPF_REG_0].min_value = 0; + /* remember map_ptr, so that check_map_access() + * can check 'value_size' boundary of memory access + * to map element returned from bpf_map_lookup_elem() + */ + if (meta.map_ptr == NULL) { + verbose(""kernel subsystem misconfigured verifier\n""); + return -EINVAL; + } + regs[BPF_REG_0].map_ptr = meta.map_ptr; + regs[BPF_REG_0].id = ++env->id_gen; + insn_aux = &env->insn_aux_data[insn_idx]; + if (!insn_aux->map_ptr) + insn_aux->map_ptr = meta.map_ptr; + else if (insn_aux->map_ptr != meta.map_ptr) + insn_aux->map_ptr = BPF_MAP_PTR_POISON; + } else { + verbose(""unknown return type %d of func %s#%d\n"", + fn->ret_type, func_id_name(func_id), func_id); + return -EINVAL; + } + + err = check_map_func_compatibility(meta.map_ptr, func_id); + if (err) + return err; + + if (changes_data) + clear_all_pkt_pointers(env); + return 0; +} +",0,"static int check_call(struct bpf_verifier_env *env, int func_id, int insn_idx) +{ + struct bpf_verifier_state *state = &env->cur_state; + const struct bpf_func_proto *fn = NULL; + struct bpf_reg_state *regs = state->regs; + struct bpf_reg_state *reg; + struct bpf_call_arg_meta meta; + bool changes_data; + int i, err; + + /* find function prototype */ + if (func_id < 0 || func_id >= __BPF_FUNC_MAX_ID) { + verbose(""invalid func %s#%d\n"", func_id_name(func_id), func_id); + return -EINVAL; + } + + if (env->prog->aux->ops->get_func_proto) + fn = env->prog->aux->ops->get_func_proto(func_id); + + if (!fn) { + verbose(""unknown func %s#%d\n"", func_id_name(func_id), func_id); + return -EINVAL; + } + + /* eBPF programs must be GPL compatible to use GPL-ed functions */ + if (!env->prog->gpl_compatible && fn->gpl_only) { + verbose(""cannot call GPL only function from proprietary program\n""); + return -EINVAL; + } + + changes_data = bpf_helper_changes_pkt_data(fn->func); + + memset(&meta, 0, sizeof(meta)); + meta.pkt_access = fn->pkt_access; + + /* We only support one arg being in raw mode at the moment, which + * is sufficient for the helper functions we have right now. + */ + err = check_raw_mode(fn); + if (err) { + verbose(""kernel subsystem misconfigured func %s#%d\n"", + func_id_name(func_id), func_id); + return err; + } + + /* check args */ + err = check_func_arg(env, BPF_REG_1, fn->arg1_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_2, fn->arg2_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_3, fn->arg3_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_4, fn->arg4_type, &meta); + if (err) + return err; + err = check_func_arg(env, BPF_REG_5, fn->arg5_type, &meta); + if (err) + return err; + + /* Mark slots with STACK_MISC in case of raw mode, stack offset + * is inferred from register state. + */ + for (i = 0; i < meta.access_size; i++) { + err = check_mem_access(env, meta.regno, i, BPF_B, BPF_WRITE, -1); + if (err) + return err; + } + + /* reset caller saved regs */ + for (i = 0; i < CALLER_SAVED_REGS; i++) { + reg = regs + caller_saved[i]; + reg->type = NOT_INIT; + reg->imm = 0; + } + + /* update return register */ + if (fn->ret_type == RET_INTEGER) { + regs[BPF_REG_0].type = UNKNOWN_VALUE; + } else if (fn->ret_type == RET_VOID) { + regs[BPF_REG_0].type = NOT_INIT; + } else if (fn->ret_type == RET_PTR_TO_MAP_VALUE_OR_NULL) { + struct bpf_insn_aux_data *insn_aux; + + regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL; + regs[BPF_REG_0].max_value = regs[BPF_REG_0].min_value = 0; + /* remember map_ptr, so that check_map_access() + * can check 'value_size' boundary of memory access + * to map element returned from bpf_map_lookup_elem() + */ + if (meta.map_ptr == NULL) { + verbose(""kernel subsystem misconfigured verifier\n""); + return -EINVAL; + } + regs[BPF_REG_0].map_ptr = meta.map_ptr; + regs[BPF_REG_0].id = ++env->id_gen; + insn_aux = &env->insn_aux_data[insn_idx]; + if (!insn_aux->map_ptr) + insn_aux->map_ptr = meta.map_ptr; + else if (insn_aux->map_ptr != meta.map_ptr) + insn_aux->map_ptr = BPF_MAP_PTR_POISON; + } else { + verbose(""unknown return type %d of func %s#%d\n"", + fn->ret_type, func_id_name(func_id), func_id); + return -EINVAL; + } + + err = check_map_func_compatibility(meta.map_ptr, func_id); + if (err) + return err; + + if (changes_data) + clear_all_pkt_pointers(env); + return 0; +} +","@@ -298,7 +298,8 @@ static const char *const bpf_jmp_string[16] = { + [BPF_EXIT >> 4] = ""exit"", + }; + +-static void print_bpf_insn(struct bpf_insn *insn) ++static void print_bpf_insn(const struct bpf_verifier_env *env, ++ const struct bpf_insn *insn) + { + u8 class = BPF_CLASS(insn->code); + +@@ -362,9 +363,19 @@ static void print_bpf_insn(struct bpf_insn *insn) + insn->code, + bpf_ldst_string[BPF_SIZE(insn->code) >> 3], + insn->src_reg, insn->imm); +- } else if (BPF_MODE(insn->code) == BPF_IMM) { +- verbose(""(%02x) r%d = 0x%x\n"", +- insn->code, insn->dst_reg, insn->imm); ++ } else if (BPF_MODE(insn->code) == BPF_IMM && ++ BPF_SIZE(insn->code) == BPF_DW) { ++ /* At this point, we already made sure that the second ++ * part of the ldimm64 insn is accessible. ++ */ ++ u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm; ++ bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD; ++ ++ if (map_ptr && !env->allow_ptr_leaks) ++ imm = 0; ++ ++ verbose(""(%02x) r%d = 0x%llx\n"", insn->code, ++ insn->dst_reg, (unsigned long long)imm); + } else { + verbose(""BUG_ld_%02x\n"", insn->code); + return; +@@ -2853,7 +2864,7 @@ static int do_check(struct bpf_verifier_env *env) + + if (log_level) { + verbose(""%d: "", insn_idx); +- print_bpf_insn(insn); ++ print_bpf_insn(env, insn); + } + + err = ext_analyzer_insn_hook(env, insn_idx, prev_insn_idx);",1038,1274,2048 +18229,"av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) +{ + const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; + + if (avctx->lowres==1) { + c->idct_put = ff_jref_idct4_put; + c->idct_add = ff_jref_idct4_add; + c->idct = ff_j_rev_dct4; + c->perm_type = FF_IDCT_PERM_NONE; + } else if (avctx->lowres==2) { + c->idct_put = ff_jref_idct2_put; + c->idct_add = ff_jref_idct2_add; + c->idct = ff_j_rev_dct2; + c->perm_type = FF_IDCT_PERM_NONE; + } else if (avctx->lowres==3) { + c->idct_put = ff_jref_idct1_put; + c->idct_add = ff_jref_idct1_add; + c->idct = ff_j_rev_dct1; + c->perm_type = FF_IDCT_PERM_NONE; + } else { + if (avctx->bits_per_raw_sample == 10 || avctx->bits_per_raw_sample == 9) { + /* 10-bit MPEG-4 Simple Studio Profile requires a higher precision IDCT + However, it only uses idct_put */ + if (avctx->codec_id == AV_CODEC_ID_MPEG4 && avctx->profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO) + c->idct_put = ff_simple_idct_put_int32_10bit; + else { + c->idct_put = ff_simple_idct_put_int16_10bit; + c->idct_add = ff_simple_idct_add_int16_10bit; + c->idct = ff_simple_idct_int16_10bit; + } + c->perm_type = FF_IDCT_PERM_NONE; + } else if (avctx->bits_per_raw_sample == 12) { + c->idct_put = ff_simple_idct_put_int16_12bit; + c->idct_add = ff_simple_idct_add_int16_12bit; + c->idct = ff_simple_idct_int16_12bit; + c->perm_type = FF_IDCT_PERM_NONE; + } else { + if (avctx->idct_algo == FF_IDCT_INT) { + c->idct_put = ff_jref_idct_put; + c->idct_add = ff_jref_idct_add; + c->idct = ff_j_rev_dct; + c->perm_type = FF_IDCT_PERM_LIBMPEG2; +#if CONFIG_FAANIDCT + } else if (avctx->idct_algo == FF_IDCT_FAAN) { + c->idct_put = ff_faanidct_put; + c->idct_add = ff_faanidct_add; + c->idct = ff_faanidct; + c->perm_type = FF_IDCT_PERM_NONE; +#endif /* CONFIG_FAANIDCT */ + } else { // accurate/default + /* Be sure FF_IDCT_NONE will select this one, since it uses FF_IDCT_PERM_NONE */ + c->idct_put = ff_simple_idct_put_int16_8bit; + c->idct_add = ff_simple_idct_add_int16_8bit; + c->idct = ff_simple_idct_int16_8bit; + c->perm_type = FF_IDCT_PERM_NONE; + } + } + } + + c->put_pixels_clamped = ff_put_pixels_clamped_c; + c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; + c->add_pixels_clamped = ff_add_pixels_clamped_c; + + if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID) + ff_xvid_idct_init(c, avctx); + + if (ARCH_AARCH64) + ff_idctdsp_init_aarch64(c, avctx, high_bit_depth); + if (ARCH_ALPHA) + ff_idctdsp_init_alpha(c, avctx, high_bit_depth); + if (ARCH_ARM) + ff_idctdsp_init_arm(c, avctx, high_bit_depth); + if (ARCH_PPC) + ff_idctdsp_init_ppc(c, avctx, high_bit_depth); + if (ARCH_X86) + ff_idctdsp_init_x86(c, avctx, high_bit_depth); + if (ARCH_MIPS) + ff_idctdsp_init_mips(c, avctx, high_bit_depth); + + ff_init_scantable_permutation(c->idct_permutation, + c->perm_type); +} +",1,"av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) +{ + const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; + + if (avctx->lowres==1) { + c->idct_put = ff_jref_idct4_put; + c->idct_add = ff_jref_idct4_add; + c->idct = ff_j_rev_dct4; + c->perm_type = FF_IDCT_PERM_NONE; + } else if (avctx->lowres==2) { + c->idct_put = ff_jref_idct2_put; + c->idct_add = ff_jref_idct2_add; + c->idct = ff_j_rev_dct2; + c->perm_type = FF_IDCT_PERM_NONE; + } else if (avctx->lowres==3) { + c->idct_put = ff_jref_idct1_put; + c->idct_add = ff_jref_idct1_add; + c->idct = ff_j_rev_dct1; + c->perm_type = FF_IDCT_PERM_NONE; + } else { + if (avctx->bits_per_raw_sample == 10 || avctx->bits_per_raw_sample == 9) { + /* 10-bit MPEG-4 Simple Studio Profile requires a higher precision IDCT + However, it only uses idct_put */ + if (c->mpeg4_studio_profile) + c->idct_put = ff_simple_idct_put_int32_10bit; + else { + c->idct_put = ff_simple_idct_put_int16_10bit; + c->idct_add = ff_simple_idct_add_int16_10bit; + c->idct = ff_simple_idct_int16_10bit; + } + c->perm_type = FF_IDCT_PERM_NONE; + } else if (avctx->bits_per_raw_sample == 12) { + c->idct_put = ff_simple_idct_put_int16_12bit; + c->idct_add = ff_simple_idct_add_int16_12bit; + c->idct = ff_simple_idct_int16_12bit; + c->perm_type = FF_IDCT_PERM_NONE; + } else { + if (avctx->idct_algo == FF_IDCT_INT) { + c->idct_put = ff_jref_idct_put; + c->idct_add = ff_jref_idct_add; + c->idct = ff_j_rev_dct; + c->perm_type = FF_IDCT_PERM_LIBMPEG2; +#if CONFIG_FAANIDCT + } else if (avctx->idct_algo == FF_IDCT_FAAN) { + c->idct_put = ff_faanidct_put; + c->idct_add = ff_faanidct_add; + c->idct = ff_faanidct; + c->perm_type = FF_IDCT_PERM_NONE; +#endif /* CONFIG_FAANIDCT */ + } else { // accurate/default + /* Be sure FF_IDCT_NONE will select this one, since it uses FF_IDCT_PERM_NONE */ + c->idct_put = ff_simple_idct_put_int16_8bit; + c->idct_add = ff_simple_idct_add_int16_8bit; + c->idct = ff_simple_idct_int16_8bit; + c->perm_type = FF_IDCT_PERM_NONE; + } + } + } + + c->put_pixels_clamped = ff_put_pixels_clamped_c; + c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; + c->add_pixels_clamped = ff_add_pixels_clamped_c; + + if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID) + ff_xvid_idct_init(c, avctx); + + if (ARCH_AARCH64) + ff_idctdsp_init_aarch64(c, avctx, high_bit_depth); + if (ARCH_ALPHA) + ff_idctdsp_init_alpha(c, avctx, high_bit_depth); + if (ARCH_ARM) + ff_idctdsp_init_arm(c, avctx, high_bit_depth); + if (ARCH_PPC) + ff_idctdsp_init_ppc(c, avctx, high_bit_depth); + if (ARCH_X86) + ff_idctdsp_init_x86(c, avctx, high_bit_depth); + if (ARCH_MIPS) + ff_idctdsp_init_mips(c, avctx, high_bit_depth); + + ff_init_scantable_permutation(c->idct_permutation, + c->perm_type); +} +","@@ -258,7 +258,7 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) + if (avctx->bits_per_raw_sample == 10 || avctx->bits_per_raw_sample == 9) { + /* 10-bit MPEG-4 Simple Studio Profile requires a higher precision IDCT + However, it only uses idct_put */ +- if (avctx->codec_id == AV_CODEC_ID_MPEG4 && avctx->profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO) ++ if (c->mpeg4_studio_profile) + c->idct_put = ff_simple_idct_put_int32_10bit; + else { + c->idct_put = ff_simple_idct_put_int16_10bit;",1072,1308,2048 +7268,"static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, + jpc_enc_tcmpt_t *tcmpt, jpc_tsfb_band_t *bandinfos) +{ + uint_fast16_t rlvlno; + uint_fast32_t tlprctlx; + uint_fast32_t tlprctly; + uint_fast32_t brprcbrx; + uint_fast32_t brprcbry; + uint_fast16_t bandno; + jpc_enc_band_t *band; + + /* Deduce the resolution level. */ + rlvlno = rlvl - tcmpt->rlvls; + + /* Initialize members required for error recovery. */ + rlvl->bands = 0; + rlvl->tcmpt = tcmpt; + + /* Compute the coordinates of the top-left and bottom-right + corners of the tile-component at this resolution. */ + rlvl->tlx = JPC_CEILDIVPOW2(jas_seq2d_xstart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->tly = JPC_CEILDIVPOW2(jas_seq2d_ystart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->brx = JPC_CEILDIVPOW2(jas_seq2d_xend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->bry = JPC_CEILDIVPOW2(jas_seq2d_yend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + + if (rlvl->tlx >= rlvl->brx || rlvl->tly >= rlvl->bry) { + rlvl->numhprcs = 0; + rlvl->numvprcs = 0; + rlvl->numprcs = 0; + return rlvl; + } + + rlvl->numbands = (!rlvlno) ? 1 : 3; + rlvl->prcwidthexpn = cp->tccp.prcwidthexpns[rlvlno]; + rlvl->prcheightexpn = cp->tccp.prcheightexpns[rlvlno]; + if (!rlvlno) { + rlvl->cbgwidthexpn = rlvl->prcwidthexpn; + rlvl->cbgheightexpn = rlvl->prcheightexpn; + } else { + rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; + rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; + } + rlvl->cblkwidthexpn = JAS_MIN(cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn); + rlvl->cblkheightexpn = JAS_MIN(cp->tccp.cblkheightexpn, rlvl->cbgheightexpn); + + /* Compute the number of precincts. */ + tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); + tlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn); + brprcbrx = JPC_CEILTOMULTPOW2(rlvl->brx, rlvl->prcwidthexpn); + brprcbry = JPC_CEILTOMULTPOW2(rlvl->bry, rlvl->prcheightexpn); + rlvl->numhprcs = JPC_FLOORDIVPOW2(brprcbrx - tlprctlx, rlvl->prcwidthexpn); + rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn); + rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs; + + if (!(rlvl->bands = jas_alloc2(rlvl->numbands, sizeof(jpc_enc_band_t)))) { + goto error; + } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + band->prcs = 0; + band->data = 0; + band->rlvl = rlvl; + } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + if (!band_create(band, cp, rlvl, bandinfos)) { + goto error; + } + } + + return rlvl; +error: + + rlvl_destroy(rlvl); + return 0; +} +",0,"static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, + jpc_enc_tcmpt_t *tcmpt, jpc_tsfb_band_t *bandinfos) +{ + uint_fast16_t rlvlno; + uint_fast32_t tlprctlx; + uint_fast32_t tlprctly; + uint_fast32_t brprcbrx; + uint_fast32_t brprcbry; + uint_fast16_t bandno; + jpc_enc_band_t *band; + + /* Deduce the resolution level. */ + rlvlno = rlvl - tcmpt->rlvls; + + /* Initialize members required for error recovery. */ + rlvl->bands = 0; + rlvl->tcmpt = tcmpt; + + /* Compute the coordinates of the top-left and bottom-right + corners of the tile-component at this resolution. */ + rlvl->tlx = JPC_CEILDIVPOW2(jas_seq2d_xstart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->tly = JPC_CEILDIVPOW2(jas_seq2d_ystart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->brx = JPC_CEILDIVPOW2(jas_seq2d_xend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->bry = JPC_CEILDIVPOW2(jas_seq2d_yend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + + if (rlvl->tlx >= rlvl->brx || rlvl->tly >= rlvl->bry) { + rlvl->numhprcs = 0; + rlvl->numvprcs = 0; + rlvl->numprcs = 0; + return rlvl; + } + + rlvl->numbands = (!rlvlno) ? 1 : 3; + rlvl->prcwidthexpn = cp->tccp.prcwidthexpns[rlvlno]; + rlvl->prcheightexpn = cp->tccp.prcheightexpns[rlvlno]; + if (!rlvlno) { + rlvl->cbgwidthexpn = rlvl->prcwidthexpn; + rlvl->cbgheightexpn = rlvl->prcheightexpn; + } else { + rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; + rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; + } + rlvl->cblkwidthexpn = JAS_MIN(cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn); + rlvl->cblkheightexpn = JAS_MIN(cp->tccp.cblkheightexpn, rlvl->cbgheightexpn); + + /* Compute the number of precincts. */ + tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); + tlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn); + brprcbrx = JPC_CEILTOMULTPOW2(rlvl->brx, rlvl->prcwidthexpn); + brprcbry = JPC_CEILTOMULTPOW2(rlvl->bry, rlvl->prcheightexpn); + rlvl->numhprcs = JPC_FLOORDIVPOW2(brprcbrx - tlprctlx, rlvl->prcwidthexpn); + rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn); + rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs; + + if (!(rlvl->bands = jas_alloc2(rlvl->numbands, sizeof(jpc_enc_band_t)))) { + goto error; + } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + band->prcs = 0; + band->data = 0; + band->rlvl = rlvl; + } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + if (!band_create(band, cp, rlvl, bandinfos)) { + goto error; + } + } + + return rlvl; +error: + + rlvl_destroy(rlvl); + return 0; +} +","@@ -961,7 +961,7 @@ startoff = jas_stream_getrwcount(enc->out); + com = &enc->mrk->parms.com; + com->len = JAS_CAST(uint_fast16_t, strlen(buf)); + com->regid = JPC_COM_LATIN; +- if (!(com->data = JAS_CAST(uchar *, jas_strdup(buf)))) { ++ if (!(com->data = JAS_CAST(jas_uchar *, jas_strdup(buf)))) { + abort(); + } + if (jpc_putms(enc->out, enc->cstate, enc->mrk)) {",1094,1330,2048 +18010,"static MagickBooleanType Get8BIMProperty(const Image *image,const char *key, + ExceptionInfo *exception) +{ + char + *attribute, + format[MagickPathExtent], + name[MagickPathExtent], + *resource; + + const StringInfo + *profile; + + const unsigned char + *info; + + long + start, + stop; + + MagickBooleanType + status; + + register ssize_t + i; + + size_t + length; + + ssize_t + count, + id, + sub_number; + + /* + There are no newlines in path names, so it's safe as terminator. + */ + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + return(MagickFalse); + count=(ssize_t) sscanf(key,""8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]"",&start,&stop, + name,format); + if ((count != 2) && (count != 3) && (count != 4)) + return(MagickFalse); + if (count < 4) + (void) CopyMagickString(format,""SVG"",MagickPathExtent); + if (count < 3) + *name='\0'; + sub_number=1; + if (*name == '#') + sub_number=(ssize_t) StringToLong(&name[1]); + sub_number=MagickMax(sub_number,1L); + resource=(char *) NULL; + status=MagickFalse; + length=GetStringInfoLength(profile); + info=GetStringInfoDatum(profile); + while ((length > 0) && (status == MagickFalse)) + { + if (ReadPropertyByte(&info,&length) != (unsigned char) '8') + continue; + if (ReadPropertyByte(&info,&length) != (unsigned char) 'B') + continue; + if (ReadPropertyByte(&info,&length) != (unsigned char) 'I') + continue; + if (ReadPropertyByte(&info,&length) != (unsigned char) 'M') + continue; + id=(ssize_t) ReadPropertyMSBShort(&info,&length); + if (id < (ssize_t) start) + continue; + if (id > (ssize_t) stop) + continue; + if (resource != (char *) NULL) + resource=DestroyString(resource); + count=(ssize_t) ReadPropertyByte(&info,&length); + if ((count != 0) && ((size_t) count <= length)) + { + resource=(char *) NULL; + if (~((size_t) count) >= (MagickPathExtent-1)) + resource=(char *) AcquireQuantumMemory((size_t) count+ + MagickPathExtent,sizeof(*resource)); + if (resource != (char *) NULL) + { + for (i=0; i < (ssize_t) count; i++) + resource[i]=(char) ReadPropertyByte(&info,&length); + resource[count]='\0'; + } + } + if ((count & 0x01) == 0) + (void) ReadPropertyByte(&info,&length); + count=(ssize_t) ReadPropertyMSBLong(&info,&length); + if ((*name != '\0') && (*name != '#')) + if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0)) + { + /* + No name match, scroll forward and try next. + */ + info+=count; + length-=MagickMin(count,(ssize_t) length); + continue; + } + if ((*name == '#') && (sub_number != 1)) + { + /* + No numbered match, scroll forward and try next. + */ + sub_number--; + info+=count; + length-=MagickMin(count,(ssize_t) length); + continue; + } + /* + We have the resource of interest. + */ + attribute=(char *) NULL; + if (~((size_t) count) >= (MagickPathExtent-1)) + attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent, + sizeof(*attribute)); + if (attribute != (char *) NULL) + { + (void) CopyMagickMemory(attribute,(char *) info,(size_t) count); + attribute[count]='\0'; + info+=count; + length-=MagickMin(count,(ssize_t) length); + if ((id <= 1999) || (id >= 2999)) + (void) SetImageProperty((Image *) image,key,(const char *) + attribute,exception); + else + { + char + *path; + + if (LocaleCompare(format,""svg"") == 0) + path=TraceSVGClippath((unsigned char *) attribute,(size_t) count, + image->columns,image->rows); + else + path=TracePSClippath((unsigned char *) attribute,(size_t) count); + (void) SetImageProperty((Image *) image,key,(const char *) path, + exception); + path=DestroyString(path); + } + attribute=DestroyString(attribute); + status=MagickTrue; + } + } + if (resource != (char *) NULL) + resource=DestroyString(resource); + return(status); +} +",1,"static MagickBooleanType Get8BIMProperty(const Image *image,const char *key, + ExceptionInfo *exception) +{ + char + *attribute, + format[MagickPathExtent], + name[MagickPathExtent], + *resource; + + const StringInfo + *profile; + + const unsigned char + *info; + + long + start, + stop; + + MagickBooleanType + status; + + register ssize_t + i; + + size_t + length; + + ssize_t + count, + id, + sub_number; + + /* + There are no newlines in path names, so it's safe as terminator. + */ + profile=GetImageProfile(image,""8bim""); + if (profile == (StringInfo *) NULL) + return(MagickFalse); + count=(ssize_t) sscanf(key,""8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]"",&start,&stop, + name,format); + if ((count != 2) && (count != 3) && (count != 4)) + return(MagickFalse); + if (count < 4) + (void) CopyMagickString(format,""SVG"",MagickPathExtent); + if (count < 3) + *name='\0'; + sub_number=1; + if (*name == '#') + sub_number=(ssize_t) StringToLong(&name[1]); + sub_number=MagickMax(sub_number,1L); + resource=(char *) NULL; + status=MagickFalse; + length=GetStringInfoLength(profile); + info=GetStringInfoDatum(profile); + while ((length > 0) && (status == MagickFalse)) + { + if (ReadPropertyByte(&info,&length) != (unsigned char) '8') + continue; + if (ReadPropertyByte(&info,&length) != (unsigned char) 'B') + continue; + if (ReadPropertyByte(&info,&length) != (unsigned char) 'I') + continue; + if (ReadPropertyByte(&info,&length) != (unsigned char) 'M') + continue; + id=(ssize_t) ReadPropertyMSBShort(&info,&length); + if (id < (ssize_t) start) + continue; + if (id > (ssize_t) stop) + continue; + if (resource != (char *) NULL) + resource=DestroyString(resource); + count=(ssize_t) ReadPropertyByte(&info,&length); + if ((count != 0) && ((size_t) count <= length)) + { + resource=(char *) NULL; + if (~((size_t) count) >= (MagickPathExtent-1)) + resource=(char *) AcquireQuantumMemory((size_t) count+ + MagickPathExtent,sizeof(*resource)); + if (resource != (char *) NULL) + { + for (i=0; i < (ssize_t) count; i++) + resource[i]=(char) ReadPropertyByte(&info,&length); + resource[count]='\0'; + } + } + if ((count & 0x01) == 0) + (void) ReadPropertyByte(&info,&length); + count=(ssize_t) ReadPropertyMSBLong(&info,&length); + if ((count < 0) || ((size_t) count > length)) + { + length=0; + continue; + } + if ((*name != '\0') && (*name != '#')) + if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0)) + { + /* + No name match, scroll forward and try next. + */ + info+=count; + length-=MagickMin(count,(ssize_t) length); + continue; + } + if ((*name == '#') && (sub_number != 1)) + { + /* + No numbered match, scroll forward and try next. + */ + sub_number--; + info+=count; + length-=MagickMin(count,(ssize_t) length); + continue; + } + /* + We have the resource of interest. + */ + attribute=(char *) NULL; + if (~((size_t) count) >= (MagickPathExtent-1)) + attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent, + sizeof(*attribute)); + if (attribute != (char *) NULL) + { + (void) CopyMagickMemory(attribute,(char *) info,(size_t) count); + attribute[count]='\0'; + info+=count; + length-=MagickMin(count,(ssize_t) length); + if ((id <= 1999) || (id >= 2999)) + (void) SetImageProperty((Image *) image,key,(const char *) + attribute,exception); + else + { + char + *path; + + if (LocaleCompare(format,""svg"") == 0) + path=TraceSVGClippath((unsigned char *) attribute,(size_t) count, + image->columns,image->rows); + else + path=TracePSClippath((unsigned char *) attribute,(size_t) count); + (void) SetImageProperty((Image *) image,key,(const char *) path, + exception); + path=DestroyString(path); + } + attribute=DestroyString(attribute); + status=MagickTrue; + } + } + if (resource != (char *) NULL) + resource=DestroyString(resource); + return(status); +} +","@@ -665,6 +665,11 @@ static MagickBooleanType Get8BIMProperty(const Image *image,const char *key, + if ((count & 0x01) == 0) + (void) ReadPropertyByte(&info,&length); + count=(ssize_t) ReadPropertyMSBLong(&info,&length); ++ if ((count < 0) || ((size_t) count > length)) ++ { ++ length=0; ++ continue; ++ } + if ((*name != '\0') && (*name != '#')) + if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0)) + {",1133,1369,2048 +5250,"dissect_DEVMODE(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, dcerpc_info *di, guint8 *drep) +{ + proto_item *item; + proto_tree *subtree; + guint16 driver_extra; + gint16 print_quality; + guint32 fields; + int struct_start = offset; + + if (di->conformant_run) + return offset; + + subtree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_DEVMODE, &item, ""Devicemode""); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, hf_devmode_size, + NULL); + + /* The device name is stored in a 32-wchar buffer */ + + dissect_spoolss_uint16uni(tvb, offset, pinfo, subtree, drep, NULL, hf_devmode_devicename); + offset += 64; + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_spec_version, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_driver_version, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_size2, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_driver_extra_len, &driver_extra); + + offset = dissect_DEVMODE_fields( + tvb, offset, pinfo, subtree, di, drep, &fields); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_orientation, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_paper_size, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_paper_length, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_paper_width, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_scale, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_copies, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_default_source, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, NULL, di, drep, + hf_devmode_print_quality, &print_quality); + + if (print_quality < 0) + proto_tree_add_item( + subtree, hf_devmode_print_quality, tvb, + offset - 2, 2, DREP_ENC_INTEGER(drep)); + else + proto_tree_add_uint_format_value( + subtree, hf_devmode_print_quality, tvb, offset - 4, 4, + print_quality, ""%d dpi"", print_quality); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_color, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_duplex, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_y_resolution, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_tt_option, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_collate, NULL); + + dissect_spoolss_uint16uni(tvb, offset, pinfo, subtree, drep, NULL, hf_devmode_form_name); + offset += 64; + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_log_pixels, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_bits_per_pel, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_pels_width, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_pels_height, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_display_flags, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_display_freq, NULL); + + /* TODO: Some of the remaining fields are optional. See + rpc_parse/parse_spoolss.c in the Samba source for details. */ + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_icm_method, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_icm_intent, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_media_type, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_dither_type, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_reserved1, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_reserved2, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_panning_width, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_panning_height, NULL); + + if (driver_extra) + offset = dissect_ndr_uint8s( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_driver_extra, driver_extra, NULL); + + proto_item_set_len(item, offset - struct_start); + + return offset; +} +",0,"dissect_DEVMODE(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, dcerpc_info *di, guint8 *drep) +{ + proto_item *item; + proto_tree *subtree; + guint16 driver_extra; + gint16 print_quality; + guint32 fields; + int struct_start = offset; + + if (di->conformant_run) + return offset; + + subtree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_DEVMODE, &item, ""Devicemode""); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, hf_devmode_size, + NULL); + + /* The device name is stored in a 32-wchar buffer */ + + dissect_spoolss_uint16uni(tvb, offset, pinfo, subtree, drep, NULL, hf_devmode_devicename); + offset += 64; + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_spec_version, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_driver_version, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_size2, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_driver_extra_len, &driver_extra); + + offset = dissect_DEVMODE_fields( + tvb, offset, pinfo, subtree, di, drep, &fields); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_orientation, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_paper_size, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_paper_length, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_paper_width, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_scale, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_copies, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_default_source, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, NULL, di, drep, + hf_devmode_print_quality, &print_quality); + + if (print_quality < 0) + proto_tree_add_item( + subtree, hf_devmode_print_quality, tvb, + offset - 2, 2, DREP_ENC_INTEGER(drep)); + else + proto_tree_add_uint_format_value( + subtree, hf_devmode_print_quality, tvb, offset - 4, 4, + print_quality, ""%d dpi"", print_quality); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_color, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_duplex, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_y_resolution, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_tt_option, NULL); + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_collate, NULL); + + dissect_spoolss_uint16uni(tvb, offset, pinfo, subtree, drep, NULL, hf_devmode_form_name); + offset += 64; + + offset = dissect_ndr_uint16( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_log_pixels, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_bits_per_pel, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_pels_width, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_pels_height, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_display_flags, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_display_freq, NULL); + + /* TODO: Some of the remaining fields are optional. See + rpc_parse/parse_spoolss.c in the Samba source for details. */ + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_icm_method, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_icm_intent, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_media_type, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_dither_type, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_reserved1, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_reserved2, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_panning_width, NULL); + + offset = dissect_ndr_uint32( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_panning_height, NULL); + + if (driver_extra) + offset = dissect_ndr_uint8s( + tvb, offset, pinfo, subtree, di, drep, + hf_devmode_driver_extra, driver_extra, NULL); + + proto_item_set_len(item, offset - struct_start); + + return offset; +} +","@@ -1090,7 +1090,7 @@ dissect_spoolss_uint16uni(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, + + /* Get remaining data in buffer as a string */ + +- remaining = tvb_captured_length_remaining(tvb, offset); ++ remaining = tvb_reported_length_remaining(tvb, offset); + if (remaining <= 0) { + if (data) + *data = g_strdup(""""); +@@ -6198,9 +6198,10 @@ dissect_spoolss_keybuffer(tvbuff_t *tvb, int offset, packet_info *pinfo, + end_offset = tvb_reported_length_remaining(tvb, offset) + 1; + } + +- while (offset < end_offset) ++ while (offset > 0 && offset < end_offset) { + offset = dissect_spoolss_uint16uni( + tvb, offset, pinfo, tree, drep, NULL, hf_keybuffer); ++ } + + return offset; + }",1582,1818,2048 +7472,"enum delta_result_type do_add_delta(conn *c, const char *key, const size_t nkey, + const bool incr, const int64_t delta, + char *buf, uint64_t *cas, + const uint32_t hv) { + char *ptr; + uint64_t value; + int res; + item *it; + + it = do_item_get(key, nkey, hv, c, DONT_UPDATE); + if (!it) { + return DELTA_ITEM_NOT_FOUND; + } + + /* Can't delta zero byte values. 2-byte are the ""\r\n"" */ + /* Also can't delta for chunked items. Too large to be a number */ + if (it->nbytes <= 2 || (it->it_flags & ITEM_CHUNKED) != 0) { + return NON_NUMERIC; + } + + if (cas != NULL && *cas != 0 && ITEM_get_cas(it) != *cas) { + do_item_remove(it); + return DELTA_ITEM_CAS_MISMATCH; + } + + ptr = ITEM_data(it); + + if (!safe_strtoull(ptr, &value)) { + do_item_remove(it); + return NON_NUMERIC; + } + + if (incr) { + value += delta; + MEMCACHED_COMMAND_INCR(c->sfd, ITEM_key(it), it->nkey, value); + } else { + if(delta > value) { + value = 0; + } else { + value -= delta; + } + MEMCACHED_COMMAND_DECR(c->sfd, ITEM_key(it), it->nkey, value); + } + + pthread_mutex_lock(&c->thread->stats.mutex); + if (incr) { + c->thread->stats.slab_stats[ITEM_clsid(it)].incr_hits++; + } else { + c->thread->stats.slab_stats[ITEM_clsid(it)].decr_hits++; + } + pthread_mutex_unlock(&c->thread->stats.mutex); + + snprintf(buf, INCR_MAX_STORAGE_LEN, ""%llu"", (unsigned long long)value); + res = strlen(buf); + /* refcount == 2 means we are the only ones holding the item, and it is + * linked. We hold the item's lock in this function, so refcount cannot + * increase. */ + if (res + 2 <= it->nbytes && it->refcount == 2) { /* replace in-place */ + /* When changing the value without replacing the item, we + need to update the CAS on the existing item. */ + /* We also need to fiddle it in the sizes tracker in case the tracking + * was enabled at runtime, since it relies on the CAS value to know + * whether to remove an item or not. */ + item_stats_sizes_remove(it); + ITEM_set_cas(it, (settings.use_cas) ? get_cas_id() : 0); + item_stats_sizes_add(it); + memcpy(ITEM_data(it), buf, res); + memset(ITEM_data(it) + res, ' ', it->nbytes - res - 2); + do_item_update(it); + } else if (it->refcount > 1) { + item *new_it; + uint32_t flags; + if (settings.inline_ascii_response) { + flags = (uint32_t) strtoul(ITEM_suffix(it)+1, (char **) NULL, 10); + } else { + flags = *((uint32_t *)ITEM_suffix(it)); + } + new_it = do_item_alloc(ITEM_key(it), it->nkey, flags, it->exptime, res + 2); + if (new_it == 0) { + do_item_remove(it); + return EOM; + } + memcpy(ITEM_data(new_it), buf, res); + memcpy(ITEM_data(new_it) + res, ""\r\n"", 2); + item_replace(it, new_it, hv); + ITEM_set_cas(it, (settings.use_cas) ? ITEM_get_cas(new_it) : 0); + do_item_remove(new_it); /* release our reference */ + } else { + /* Should never get here. This means we somehow fetched an unlinked + * item. TODO: Add a counter? */ + if (settings.verbose) { + fprintf(stderr, ""Tried to do incr/decr on invalid item\n""); + } + if (it->refcount == 1) + do_item_remove(it); + return DELTA_ITEM_NOT_FOUND; + } + + if (cas) { + *cas = ITEM_get_cas(it); /* swap the incoming CAS value */ + } + do_item_remove(it); /* release our reference */ + return OK; +} +",0,"enum delta_result_type do_add_delta(conn *c, const char *key, const size_t nkey, + const bool incr, const int64_t delta, + char *buf, uint64_t *cas, + const uint32_t hv) { + char *ptr; + uint64_t value; + int res; + item *it; + + it = do_item_get(key, nkey, hv, c, DONT_UPDATE); + if (!it) { + return DELTA_ITEM_NOT_FOUND; + } + + /* Can't delta zero byte values. 2-byte are the ""\r\n"" */ + /* Also can't delta for chunked items. Too large to be a number */ + if (it->nbytes <= 2 || (it->it_flags & ITEM_CHUNKED) != 0) { + return NON_NUMERIC; + } + + if (cas != NULL && *cas != 0 && ITEM_get_cas(it) != *cas) { + do_item_remove(it); + return DELTA_ITEM_CAS_MISMATCH; + } + + ptr = ITEM_data(it); + + if (!safe_strtoull(ptr, &value)) { + do_item_remove(it); + return NON_NUMERIC; + } + + if (incr) { + value += delta; + MEMCACHED_COMMAND_INCR(c->sfd, ITEM_key(it), it->nkey, value); + } else { + if(delta > value) { + value = 0; + } else { + value -= delta; + } + MEMCACHED_COMMAND_DECR(c->sfd, ITEM_key(it), it->nkey, value); + } + + pthread_mutex_lock(&c->thread->stats.mutex); + if (incr) { + c->thread->stats.slab_stats[ITEM_clsid(it)].incr_hits++; + } else { + c->thread->stats.slab_stats[ITEM_clsid(it)].decr_hits++; + } + pthread_mutex_unlock(&c->thread->stats.mutex); + + snprintf(buf, INCR_MAX_STORAGE_LEN, ""%llu"", (unsigned long long)value); + res = strlen(buf); + /* refcount == 2 means we are the only ones holding the item, and it is + * linked. We hold the item's lock in this function, so refcount cannot + * increase. */ + if (res + 2 <= it->nbytes && it->refcount == 2) { /* replace in-place */ + /* When changing the value without replacing the item, we + need to update the CAS on the existing item. */ + /* We also need to fiddle it in the sizes tracker in case the tracking + * was enabled at runtime, since it relies on the CAS value to know + * whether to remove an item or not. */ + item_stats_sizes_remove(it); + ITEM_set_cas(it, (settings.use_cas) ? get_cas_id() : 0); + item_stats_sizes_add(it); + memcpy(ITEM_data(it), buf, res); + memset(ITEM_data(it) + res, ' ', it->nbytes - res - 2); + do_item_update(it); + } else if (it->refcount > 1) { + item *new_it; + uint32_t flags; + if (settings.inline_ascii_response) { + flags = (uint32_t) strtoul(ITEM_suffix(it)+1, (char **) NULL, 10); + } else { + flags = *((uint32_t *)ITEM_suffix(it)); + } + new_it = do_item_alloc(ITEM_key(it), it->nkey, flags, it->exptime, res + 2); + if (new_it == 0) { + do_item_remove(it); + return EOM; + } + memcpy(ITEM_data(new_it), buf, res); + memcpy(ITEM_data(new_it) + res, ""\r\n"", 2); + item_replace(it, new_it, hv); + ITEM_set_cas(it, (settings.use_cas) ? ITEM_get_cas(new_it) : 0); + do_item_remove(new_it); /* release our reference */ + } else { + /* Should never get here. This means we somehow fetched an unlinked + * item. TODO: Add a counter? */ + if (settings.verbose) { + fprintf(stderr, ""Tried to do incr/decr on invalid item\n""); + } + if (it->refcount == 1) + do_item_remove(it); + return DELTA_ITEM_NOT_FOUND; + } + + if (cas) { + *cas = ITEM_get_cas(it); /* swap the incoming CAS value */ + } + do_item_remove(it); /* release our reference */ + return OK; +} +","@@ -3249,6 +3249,16 @@ static inline int make_ascii_get_suffix(char *suffix, item *it, bool return_cas) + return (p - suffix) + 2; + } + ++#define IT_REFCOUNT_LIMIT 60000 ++static inline item* limited_get(char *key, size_t nkey, conn *c) { ++ item *it = item_get(key, nkey, c, DO_UPDATE); ++ if (it && it->refcount > IT_REFCOUNT_LIMIT) { ++ item_remove(it); ++ it = NULL; ++ } ++ return it; ++} ++ + /* ntokens is overwritten here... shrug.. */ + static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, bool return_cas) { + char *key; +@@ -3273,7 +3283,7 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, + return; + } + +- it = item_get(key, nkey, c, DO_UPDATE); ++ it = limited_get(key, nkey, c); + if (settings.detail_enabled) { + stats_prefix_record_get(key, nkey, NULL != it); + }",1000,1236,2048 +1726,"int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, + int *num, uint64_t *host_offset, QCowL2Meta **m) +{ + BDRVQcowState *s = bs->opaque; + uint64_t start, remaining; + uint64_t cluster_offset; + uint64_t cur_bytes; + int ret; + + trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset, *num); + + assert((offset & ~BDRV_SECTOR_MASK) == 0); + +again: + start = offset; + remaining = *num << BDRV_SECTOR_BITS; + cluster_offset = 0; + *host_offset = 0; + cur_bytes = 0; + *m = NULL; + + while (true) { + + if (!*host_offset) { + *host_offset = start_of_cluster(s, cluster_offset); + } + + assert(remaining >= cur_bytes); + + start += cur_bytes; + remaining -= cur_bytes; + cluster_offset += cur_bytes; + + if (remaining == 0) { + break; + } + + cur_bytes = remaining; + + /* + * Now start gathering as many contiguous clusters as possible: + * + * 1. Check for overlaps with in-flight allocations + * + * a) Overlap not in the first cluster -> shorten this request and + * let the caller handle the rest in its next loop iteration. + * + * b) Real overlaps of two requests. Yield and restart the search + * for contiguous clusters (the situation could have changed + * while we were sleeping) + * + * c) TODO: Request starts in the same cluster as the in-flight + * allocation ends. Shorten the COW of the in-fight allocation, + * set cluster_offset to write to the same cluster and set up + * the right synchronisation between the in-flight request and + * the new one. + */ + ret = handle_dependencies(bs, start, &cur_bytes, m); + if (ret == -EAGAIN) { + /* Currently handle_dependencies() doesn't yield if we already had + * an allocation. If it did, we would have to clean up the L2Meta + * structs before starting over. */ + assert(*m == NULL); + goto again; + } else if (ret < 0) { + return ret; + } else if (cur_bytes == 0) { + break; + } else { + /* handle_dependencies() may have decreased cur_bytes (shortened + * the allocations below) so that the next dependency is processed + * correctly during the next loop iteration. */ + } + + /* + * 2. Count contiguous COPIED clusters. + */ + ret = handle_copied(bs, start, &cluster_offset, &cur_bytes, m); + if (ret < 0) { + return ret; + } else if (ret) { + continue; + } else if (cur_bytes == 0) { + break; + } + + /* + * 3. If the request still hasn't completed, allocate new clusters, + * considering any cluster_offset of steps 1c or 2. + */ + ret = handle_alloc(bs, start, &cluster_offset, &cur_bytes, m); + if (ret < 0) { + return ret; + } else if (ret) { + continue; + } else { + assert(cur_bytes == 0); + break; + } + } + + *num -= remaining >> BDRV_SECTOR_BITS; + assert(*num > 0); + assert(*host_offset != 0); + + return 0; +} +",0,"int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, + int *num, uint64_t *host_offset, QCowL2Meta **m) +{ + BDRVQcowState *s = bs->opaque; + uint64_t start, remaining; + uint64_t cluster_offset; + uint64_t cur_bytes; + int ret; + + trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset, *num); + + assert((offset & ~BDRV_SECTOR_MASK) == 0); + +again: + start = offset; + remaining = *num << BDRV_SECTOR_BITS; + cluster_offset = 0; + *host_offset = 0; + cur_bytes = 0; + *m = NULL; + + while (true) { + + if (!*host_offset) { + *host_offset = start_of_cluster(s, cluster_offset); + } + + assert(remaining >= cur_bytes); + + start += cur_bytes; + remaining -= cur_bytes; + cluster_offset += cur_bytes; + + if (remaining == 0) { + break; + } + + cur_bytes = remaining; + + /* + * Now start gathering as many contiguous clusters as possible: + * + * 1. Check for overlaps with in-flight allocations + * + * a) Overlap not in the first cluster -> shorten this request and + * let the caller handle the rest in its next loop iteration. + * + * b) Real overlaps of two requests. Yield and restart the search + * for contiguous clusters (the situation could have changed + * while we were sleeping) + * + * c) TODO: Request starts in the same cluster as the in-flight + * allocation ends. Shorten the COW of the in-fight allocation, + * set cluster_offset to write to the same cluster and set up + * the right synchronisation between the in-flight request and + * the new one. + */ + ret = handle_dependencies(bs, start, &cur_bytes, m); + if (ret == -EAGAIN) { + /* Currently handle_dependencies() doesn't yield if we already had + * an allocation. If it did, we would have to clean up the L2Meta + * structs before starting over. */ + assert(*m == NULL); + goto again; + } else if (ret < 0) { + return ret; + } else if (cur_bytes == 0) { + break; + } else { + /* handle_dependencies() may have decreased cur_bytes (shortened + * the allocations below) so that the next dependency is processed + * correctly during the next loop iteration. */ + } + + /* + * 2. Count contiguous COPIED clusters. + */ + ret = handle_copied(bs, start, &cluster_offset, &cur_bytes, m); + if (ret < 0) { + return ret; + } else if (ret) { + continue; + } else if (cur_bytes == 0) { + break; + } + + /* + * 3. If the request still hasn't completed, allocate new clusters, + * considering any cluster_offset of steps 1c or 2. + */ + ret = handle_alloc(bs, start, &cluster_offset, &cur_bytes, m); + if (ret < 0) { + return ret; + } else if (ret) { + continue; + } else { + assert(cur_bytes == 0); + break; + } + } + + *num -= remaining >> BDRV_SECTOR_BITS; + assert(*num > 0); + assert(*host_offset != 0); + + return 0; +} +","@@ -55,7 +55,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, + } + } + +- if (new_l1_size > INT_MAX) { ++ if (new_l1_size > INT_MAX / sizeof(uint64_t)) { + return -EFBIG; + }",789,1025,2048 +18785,"status_t IPCThreadState::executeCommand(int32_t cmd) +{ + BBinder* obj; + RefBase::weakref_type* refs; + status_t result = NO_ERROR; + + switch ((uint32_t)cmd) { + case BR_ERROR: + result = mIn.readInt32(); + break; + + case BR_OK: + break; + + case BR_ACQUIRE: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + ALOG_ASSERT(refs->refBase() == obj, + ""BR_ACQUIRE: object %p does not match cookie %p (expected %p)"", + refs, obj, refs->refBase()); + obj->incStrong(mProcess.get()); + IF_LOG_REMOTEREFS() { + LOG_REMOTEREFS(""BR_ACQUIRE from driver on %p"", obj); + obj->printRefs(); + } + mOut.writeInt32(BC_ACQUIRE_DONE); + mOut.writePointer((uintptr_t)refs); + mOut.writePointer((uintptr_t)obj); + break; + + case BR_RELEASE: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + ALOG_ASSERT(refs->refBase() == obj, + ""BR_RELEASE: object %p does not match cookie %p (expected %p)"", + refs, obj, refs->refBase()); + IF_LOG_REMOTEREFS() { + LOG_REMOTEREFS(""BR_RELEASE from driver on %p"", obj); + obj->printRefs(); + } + mPendingStrongDerefs.push(obj); + break; + + case BR_INCREFS: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + refs->incWeak(mProcess.get()); + mOut.writeInt32(BC_INCREFS_DONE); + mOut.writePointer((uintptr_t)refs); + mOut.writePointer((uintptr_t)obj); + break; + + case BR_DECREFS: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + mPendingWeakDerefs.push(refs); + break; + + case BR_ATTEMPT_ACQUIRE: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + + { + const bool success = refs->attemptIncStrong(mProcess.get()); + ALOG_ASSERT(success && refs->refBase() == obj, + ""BR_ATTEMPT_ACQUIRE: object %p does not match cookie %p (expected %p)"", + refs, obj, refs->refBase()); + + mOut.writeInt32(BC_ACQUIRE_RESULT); + mOut.writeInt32((int32_t)success); + } + break; + + case BR_TRANSACTION: + { + binder_transaction_data tr; + result = mIn.read(&tr, sizeof(tr)); + ALOG_ASSERT(result == NO_ERROR, + ""Not enough command data for brTRANSACTION""); + if (result != NO_ERROR) break; + + Parcel buffer; + buffer.ipcSetDataReference( + reinterpret_cast(tr.data.ptr.buffer), + tr.data_size, + reinterpret_cast(tr.data.ptr.offsets), + tr.offsets_size/sizeof(binder_size_t), freeBuffer, this); + + const pid_t origPid = mCallingPid; + const uid_t origUid = mCallingUid; + const int32_t origStrictModePolicy = mStrictModePolicy; + const int32_t origTransactionBinderFlags = mLastTransactionBinderFlags; + + mCallingPid = tr.sender_pid; + mCallingUid = tr.sender_euid; + mLastTransactionBinderFlags = tr.flags; + + int curPrio = getpriority(PRIO_PROCESS, mMyThreadId); + if (gDisableBackgroundScheduling) { + if (curPrio > ANDROID_PRIORITY_NORMAL) { + setpriority(PRIO_PROCESS, mMyThreadId, ANDROID_PRIORITY_NORMAL); + } + } else { + if (curPrio >= ANDROID_PRIORITY_BACKGROUND) { + set_sched_policy(mMyThreadId, SP_BACKGROUND); + } + } + + + Parcel reply; + status_t error; + IF_LOG_TRANSACTIONS() { + TextOutput::Bundle _b(alog); + alog << ""BR_TRANSACTION thr "" << (void*)pthread_self() + << "" / obj "" << tr.target.ptr << "" / code "" + << TypeCode(tr.code) << "": "" << indent << buffer + << dedent << endl + << ""Data addr = "" + << reinterpret_cast(tr.data.ptr.buffer) + << "", offsets addr="" + + << reinterpret_cast(tr.data.ptr.offsets) << endl; + } + if (tr.target.ptr) { + sp b((BBinder*)tr.cookie); + error = b->transact(tr.code, buffer, &reply, tr.flags); + + } else { + error = the_context_object->transact(tr.code, buffer, &reply, tr.flags); + } + + + if ((tr.flags & TF_ONE_WAY) == 0) { + LOG_ONEWAY(""Sending reply to %d!"", mCallingPid); + if (error < NO_ERROR) reply.setError(error); + sendReply(reply, 0); + } else { + LOG_ONEWAY(""NOT sending reply to %d!"", mCallingPid); + } + + mCallingPid = origPid; + mCallingUid = origUid; + mStrictModePolicy = origStrictModePolicy; + mLastTransactionBinderFlags = origTransactionBinderFlags; + + IF_LOG_TRANSACTIONS() { + TextOutput::Bundle _b(alog); + alog << ""BC_REPLY thr "" << (void*)pthread_self() << "" / obj "" + << tr.target.ptr << "": "" << indent << reply << dedent << endl; + } + + } + break; + + case BR_DEAD_BINDER: + { + BpBinder *proxy = (BpBinder*)mIn.readPointer(); + proxy->sendObituary(); + mOut.writeInt32(BC_DEAD_BINDER_DONE); + mOut.writePointer((uintptr_t)proxy); + } break; + + case BR_CLEAR_DEATH_NOTIFICATION_DONE: + { + BpBinder *proxy = (BpBinder*)mIn.readPointer(); + proxy->getWeakRefs()->decWeak(proxy); + } break; + + case BR_FINISHED: + result = TIMED_OUT; + break; + + case BR_NOOP: + break; + + case BR_SPAWN_LOOPER: + mProcess->spawnPooledThread(false); + break; + + default: + printf(""*** BAD COMMAND %d received from Binder driver\n"", cmd); + result = UNKNOWN_ERROR; + break; + } + + if (result != NO_ERROR) { + mLastError = result; + } + + return result; +} +",1,"status_t IPCThreadState::executeCommand(int32_t cmd) +{ + BBinder* obj; + RefBase::weakref_type* refs; + status_t result = NO_ERROR; + + switch ((uint32_t)cmd) { + case BR_ERROR: + result = mIn.readInt32(); + break; + + case BR_OK: + break; + + case BR_ACQUIRE: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + ALOG_ASSERT(refs->refBase() == obj, + ""BR_ACQUIRE: object %p does not match cookie %p (expected %p)"", + refs, obj, refs->refBase()); + obj->incStrong(mProcess.get()); + IF_LOG_REMOTEREFS() { + LOG_REMOTEREFS(""BR_ACQUIRE from driver on %p"", obj); + obj->printRefs(); + } + mOut.writeInt32(BC_ACQUIRE_DONE); + mOut.writePointer((uintptr_t)refs); + mOut.writePointer((uintptr_t)obj); + break; + + case BR_RELEASE: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + ALOG_ASSERT(refs->refBase() == obj, + ""BR_RELEASE: object %p does not match cookie %p (expected %p)"", + refs, obj, refs->refBase()); + IF_LOG_REMOTEREFS() { + LOG_REMOTEREFS(""BR_RELEASE from driver on %p"", obj); + obj->printRefs(); + } + mPendingStrongDerefs.push(obj); + break; + + case BR_INCREFS: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + refs->incWeak(mProcess.get()); + mOut.writeInt32(BC_INCREFS_DONE); + mOut.writePointer((uintptr_t)refs); + mOut.writePointer((uintptr_t)obj); + break; + + case BR_DECREFS: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + mPendingWeakDerefs.push(refs); + break; + + case BR_ATTEMPT_ACQUIRE: + refs = (RefBase::weakref_type*)mIn.readPointer(); + obj = (BBinder*)mIn.readPointer(); + + { + const bool success = refs->attemptIncStrong(mProcess.get()); + ALOG_ASSERT(success && refs->refBase() == obj, + ""BR_ATTEMPT_ACQUIRE: object %p does not match cookie %p (expected %p)"", + refs, obj, refs->refBase()); + + mOut.writeInt32(BC_ACQUIRE_RESULT); + mOut.writeInt32((int32_t)success); + } + break; + + case BR_TRANSACTION: + { + binder_transaction_data tr; + result = mIn.read(&tr, sizeof(tr)); + ALOG_ASSERT(result == NO_ERROR, + ""Not enough command data for brTRANSACTION""); + if (result != NO_ERROR) break; + + Parcel buffer; + buffer.ipcSetDataReference( + reinterpret_cast(tr.data.ptr.buffer), + tr.data_size, + reinterpret_cast(tr.data.ptr.offsets), + tr.offsets_size/sizeof(binder_size_t), freeBuffer, this); + + const pid_t origPid = mCallingPid; + const uid_t origUid = mCallingUid; + const int32_t origStrictModePolicy = mStrictModePolicy; + const int32_t origTransactionBinderFlags = mLastTransactionBinderFlags; + + mCallingPid = tr.sender_pid; + mCallingUid = tr.sender_euid; + mLastTransactionBinderFlags = tr.flags; + + int curPrio = getpriority(PRIO_PROCESS, mMyThreadId); + if (gDisableBackgroundScheduling) { + if (curPrio > ANDROID_PRIORITY_NORMAL) { + setpriority(PRIO_PROCESS, mMyThreadId, ANDROID_PRIORITY_NORMAL); + } + } else { + if (curPrio >= ANDROID_PRIORITY_BACKGROUND) { + set_sched_policy(mMyThreadId, SP_BACKGROUND); + } + } + + + Parcel reply; + status_t error; + IF_LOG_TRANSACTIONS() { + TextOutput::Bundle _b(alog); + alog << ""BR_TRANSACTION thr "" << (void*)pthread_self() + << "" / obj "" << tr.target.ptr << "" / code "" + << TypeCode(tr.code) << "": "" << indent << buffer + << dedent << endl + << ""Data addr = "" + << reinterpret_cast(tr.data.ptr.buffer) + << "", offsets addr="" + + << reinterpret_cast(tr.data.ptr.offsets) << endl; + } + if (tr.target.ptr) { + // We only have a weak reference on the target object, so we must first try to + // safely acquire a strong reference before doing anything else with it. + if (reinterpret_cast( + tr.target.ptr)->attemptIncStrong(this)) { + error = reinterpret_cast(tr.cookie)->transact(tr.code, buffer, + &reply, tr.flags); + reinterpret_cast(tr.cookie)->decStrong(this); + } else { + error = UNKNOWN_TRANSACTION; + } + + } else { + error = the_context_object->transact(tr.code, buffer, &reply, tr.flags); + } + + + if ((tr.flags & TF_ONE_WAY) == 0) { + LOG_ONEWAY(""Sending reply to %d!"", mCallingPid); + if (error < NO_ERROR) reply.setError(error); + sendReply(reply, 0); + } else { + LOG_ONEWAY(""NOT sending reply to %d!"", mCallingPid); + } + + mCallingPid = origPid; + mCallingUid = origUid; + mStrictModePolicy = origStrictModePolicy; + mLastTransactionBinderFlags = origTransactionBinderFlags; + + IF_LOG_TRANSACTIONS() { + TextOutput::Bundle _b(alog); + alog << ""BC_REPLY thr "" << (void*)pthread_self() << "" / obj "" + << tr.target.ptr << "": "" << indent << reply << dedent << endl; + } + + } + break; + + case BR_DEAD_BINDER: + { + BpBinder *proxy = (BpBinder*)mIn.readPointer(); + proxy->sendObituary(); + mOut.writeInt32(BC_DEAD_BINDER_DONE); + mOut.writePointer((uintptr_t)proxy); + } break; + + case BR_CLEAR_DEATH_NOTIFICATION_DONE: + { + BpBinder *proxy = (BpBinder*)mIn.readPointer(); + proxy->getWeakRefs()->decWeak(proxy); + } break; + + case BR_FINISHED: + result = TIMED_OUT; + break; + + case BR_NOOP: + break; + + case BR_SPAWN_LOOPER: + mProcess->spawnPooledThread(false); + break; + + default: + printf(""*** BAD COMMAND %d received from Binder driver\n"", cmd); + result = UNKNOWN_ERROR; + break; + } + + if (result != NO_ERROR) { + mLastError = result; + } + + return result; +} +","@@ -1083,8 +1083,16 @@ + + << reinterpret_cast(tr.data.ptr.offsets) << endl; + } + if (tr.target.ptr) { +- sp b((BBinder*)tr.cookie); +- error = b->transact(tr.code, buffer, &reply, tr.flags); ++ // We only have a weak reference on the target object, so we must first try to ++ // safely acquire a strong reference before doing anything else with it. ++ if (reinterpret_cast( ++ tr.target.ptr)->attemptIncStrong(this)) { ++ error = reinterpret_cast(tr.cookie)->transact(tr.code, buffer, ++ &reply, tr.flags); ++ reinterpret_cast(tr.cookie)->decStrong(this); ++ } else { ++ error = UNKNOWN_TRANSACTION; ++ } + + } else { + error = the_context_object->transact(tr.code, buffer, &reply, tr.flags); +",1412,1648,2048 +18136,"int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + struct inode **delegated_inode, unsigned int flags) + { + int error; + bool is_dir = d_is_dir(old_dentry); + const unsigned char *old_name; + struct inode *source = old_dentry->d_inode; + struct inode *target = new_dentry->d_inode; + bool new_is_dir = false; + unsigned max_links = new_dir->i_sb->s_max_links; + + if (source == target) + return 0; + + error = may_delete(old_dir, old_dentry, is_dir); + if (error) + return error; + + if (!target) { + error = may_create(new_dir, new_dentry); + } else { + new_is_dir = d_is_dir(new_dentry); + + if (!(flags & RENAME_EXCHANGE)) + error = may_delete(new_dir, new_dentry, is_dir); + else + error = may_delete(new_dir, new_dentry, new_is_dir); + } + if (error) + return error; + + if (!old_dir->i_op->rename) + return -EPERM; + + /* + * If we are going to change the parent - check write permissions, + * we'll need to flip '..'. + */ + if (new_dir != old_dir) { + if (is_dir) { + error = inode_permission(source, MAY_WRITE); + if (error) + return error; + } + if ((flags & RENAME_EXCHANGE) && new_is_dir) { + error = inode_permission(target, MAY_WRITE); + if (error) + return error; + } + } + + error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry, + flags); + if (error) + return error; + + old_name = fsnotify_oldname_init(old_dentry->d_name.name); + dget(new_dentry); + if (!is_dir || (flags & RENAME_EXCHANGE)) + lock_two_nondirectories(source, target); + else if (target) + inode_lock(target); + + error = -EBUSY; + if (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry)) + goto out; + + if (max_links && new_dir != old_dir) { + error = -EMLINK; + if (is_dir && !new_is_dir && new_dir->i_nlink >= max_links) + goto out; + if ((flags & RENAME_EXCHANGE) && !is_dir && new_is_dir && + old_dir->i_nlink >= max_links) + goto out; + } + if (is_dir && !(flags & RENAME_EXCHANGE) && target) + shrink_dcache_parent(new_dentry); + if (!is_dir) { + error = try_break_deleg(source, delegated_inode); + if (error) + goto out; + } + if (target && !new_is_dir) { + error = try_break_deleg(target, delegated_inode); + if (error) + goto out; + } + error = old_dir->i_op->rename(old_dir, old_dentry, + new_dir, new_dentry, flags); + if (error) + goto out; + + if (!(flags & RENAME_EXCHANGE) && target) { + if (is_dir) + target->i_flags |= S_DEAD; + dont_mount(new_dentry); + detach_mounts(new_dentry); + } + if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) { + if (!(flags & RENAME_EXCHANGE)) + d_move(old_dentry, new_dentry); + else + d_exchange(old_dentry, new_dentry); + } +out: + if (!is_dir || (flags & RENAME_EXCHANGE)) + unlock_two_nondirectories(source, target); + else if (target) + inode_unlock(target); + dput(new_dentry); + if (!error) { + fsnotify_move(old_dir, new_dir, old_name, is_dir, + !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry); + if (flags & RENAME_EXCHANGE) { + fsnotify_move(new_dir, old_dir, old_dentry->d_name.name, + new_is_dir, NULL, new_dentry); + } + } + fsnotify_oldname_free(old_name); + + return error; + } +",1,"int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + struct inode **delegated_inode, unsigned int flags) + { + int error; + bool is_dir = d_is_dir(old_dentry); + struct inode *source = old_dentry->d_inode; + struct inode *target = new_dentry->d_inode; + bool new_is_dir = false; + unsigned max_links = new_dir->i_sb->s_max_links; + struct name_snapshot old_name; + + if (source == target) + return 0; + + error = may_delete(old_dir, old_dentry, is_dir); + if (error) + return error; + + if (!target) { + error = may_create(new_dir, new_dentry); + } else { + new_is_dir = d_is_dir(new_dentry); + + if (!(flags & RENAME_EXCHANGE)) + error = may_delete(new_dir, new_dentry, is_dir); + else + error = may_delete(new_dir, new_dentry, new_is_dir); + } + if (error) + return error; + + if (!old_dir->i_op->rename) + return -EPERM; + + /* + * If we are going to change the parent - check write permissions, + * we'll need to flip '..'. + */ + if (new_dir != old_dir) { + if (is_dir) { + error = inode_permission(source, MAY_WRITE); + if (error) + return error; + } + if ((flags & RENAME_EXCHANGE) && new_is_dir) { + error = inode_permission(target, MAY_WRITE); + if (error) + return error; + } + } + + error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry, + flags); + if (error) + return error; + + take_dentry_name_snapshot(&old_name, old_dentry); + dget(new_dentry); + if (!is_dir || (flags & RENAME_EXCHANGE)) + lock_two_nondirectories(source, target); + else if (target) + inode_lock(target); + + error = -EBUSY; + if (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry)) + goto out; + + if (max_links && new_dir != old_dir) { + error = -EMLINK; + if (is_dir && !new_is_dir && new_dir->i_nlink >= max_links) + goto out; + if ((flags & RENAME_EXCHANGE) && !is_dir && new_is_dir && + old_dir->i_nlink >= max_links) + goto out; + } + if (is_dir && !(flags & RENAME_EXCHANGE) && target) + shrink_dcache_parent(new_dentry); + if (!is_dir) { + error = try_break_deleg(source, delegated_inode); + if (error) + goto out; + } + if (target && !new_is_dir) { + error = try_break_deleg(target, delegated_inode); + if (error) + goto out; + } + error = old_dir->i_op->rename(old_dir, old_dentry, + new_dir, new_dentry, flags); + if (error) + goto out; + + if (!(flags & RENAME_EXCHANGE) && target) { + if (is_dir) + target->i_flags |= S_DEAD; + dont_mount(new_dentry); + detach_mounts(new_dentry); + } + if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) { + if (!(flags & RENAME_EXCHANGE)) + d_move(old_dentry, new_dentry); + else + d_exchange(old_dentry, new_dentry); + } +out: + if (!is_dir || (flags & RENAME_EXCHANGE)) + unlock_two_nondirectories(source, target); + else if (target) + inode_unlock(target); + dput(new_dentry); + if (!error) { + fsnotify_move(old_dir, new_dir, old_name.name, is_dir, + !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry); + if (flags & RENAME_EXCHANGE) { + fsnotify_move(new_dir, old_dir, old_dentry->d_name.name, + new_is_dir, NULL, new_dentry); + } + } + release_dentry_name_snapshot(&old_name); + + return error; + } +","@@ -4362,11 +4362,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + { + int error; + bool is_dir = d_is_dir(old_dentry); +- const unsigned char *old_name; + struct inode *source = old_dentry->d_inode; + struct inode *target = new_dentry->d_inode; + bool new_is_dir = false; + unsigned max_links = new_dir->i_sb->s_max_links; ++ struct name_snapshot old_name; + + if (source == target) + return 0; +@@ -4413,7 +4413,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + if (error) + return error; + +- old_name = fsnotify_oldname_init(old_dentry->d_name.name); ++ take_dentry_name_snapshot(&old_name, old_dentry); + dget(new_dentry); + if (!is_dir || (flags & RENAME_EXCHANGE)) + lock_two_nondirectories(source, target); +@@ -4468,14 +4468,14 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + inode_unlock(target); + dput(new_dentry); + if (!error) { +- fsnotify_move(old_dir, new_dir, old_name, is_dir, ++ fsnotify_move(old_dir, new_dir, old_name.name, is_dir, + !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry); + if (flags & RENAME_EXCHANGE) { + fsnotify_move(new_dir, old_dir, old_dentry->d_name.name, + new_is_dir, NULL, new_dentry); + } + } +- fsnotify_oldname_free(old_name); ++ release_dentry_name_snapshot(&old_name); + + return error; + }",941,1177,2048 +2191,"static unsigned long zap_pte_range(struct mmu_gather *tlb, + struct vm_area_struct *vma, pmd_t *pmd, + unsigned long addr, unsigned long end, + struct zap_details *details) +{ + struct mm_struct *mm = tlb->mm; + int force_flush = 0; + int rss[NR_MM_COUNTERS]; + spinlock_t *ptl; + pte_t *start_pte; + pte_t *pte; + +again: + init_rss_vec(rss); + start_pte = pte_offset_map_lock(mm, pmd, addr, &ptl); + pte = start_pte; + arch_enter_lazy_mmu_mode(); + do { + pte_t ptent = *pte; + if (pte_none(ptent)) { + continue; + } + + if (pte_present(ptent)) { + struct page *page; + + page = vm_normal_page(vma, addr, ptent); + if (unlikely(details) && page) { + /* + * unmap_shared_mapping_pages() wants to + * invalidate cache without truncating: + * unmap shared but keep private pages. + */ + if (details->check_mapping && + details->check_mapping != page->mapping) + continue; + /* + * Each page->index must be checked when + * invalidating or truncating nonlinear. + */ + if (details->nonlinear_vma && + (page->index < details->first_index || + page->index > details->last_index)) + continue; + } + ptent = ptep_get_and_clear_full(mm, addr, pte, + tlb->fullmm); + tlb_remove_tlb_entry(tlb, pte, addr); + if (unlikely(!page)) + continue; + if (unlikely(details) && details->nonlinear_vma + && linear_page_index(details->nonlinear_vma, + addr) != page->index) + set_pte_at(mm, addr, pte, + pgoff_to_pte(page->index)); + if (PageAnon(page)) + rss[MM_ANONPAGES]--; + else { + if (pte_dirty(ptent)) + set_page_dirty(page); + if (pte_young(ptent) && + likely(!VM_SequentialReadHint(vma))) + mark_page_accessed(page); + rss[MM_FILEPAGES]--; + } + page_remove_rmap(page); + if (unlikely(page_mapcount(page) < 0)) + print_bad_pte(vma, addr, ptent, page); + force_flush = !__tlb_remove_page(tlb, page); + if (force_flush) + break; + continue; + } + /* + * If details->check_mapping, we leave swap entries; + * if details->nonlinear_vma, we leave file entries. + */ + if (unlikely(details)) + continue; + if (pte_file(ptent)) { + if (unlikely(!(vma->vm_flags & VM_NONLINEAR))) + print_bad_pte(vma, addr, ptent, NULL); + } else { + swp_entry_t entry = pte_to_swp_entry(ptent); + + if (!non_swap_entry(entry)) + rss[MM_SWAPENTS]--; + else if (is_migration_entry(entry)) { + struct page *page; + + page = migration_entry_to_page(entry); + + if (PageAnon(page)) + rss[MM_ANONPAGES]--; + else + rss[MM_FILEPAGES]--; + } + if (unlikely(!free_swap_and_cache(entry))) + print_bad_pte(vma, addr, ptent, NULL); + } + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); + } while (pte++, addr += PAGE_SIZE, addr != end); + + add_mm_rss_vec(mm, rss); + arch_leave_lazy_mmu_mode(); + pte_unmap_unlock(start_pte, ptl); + + /* + * mmu_gather ran out of room to batch pages, we break out of + * the PTE lock to avoid doing the potential expensive TLB invalidate + * and page-free while holding it. + */ + if (force_flush) { + force_flush = 0; + tlb_flush_mmu(tlb); + if (addr != end) + goto again; + } + + return addr; +} +",0,"static unsigned long zap_pte_range(struct mmu_gather *tlb, + struct vm_area_struct *vma, pmd_t *pmd, + unsigned long addr, unsigned long end, + struct zap_details *details) +{ + struct mm_struct *mm = tlb->mm; + int force_flush = 0; + int rss[NR_MM_COUNTERS]; + spinlock_t *ptl; + pte_t *start_pte; + pte_t *pte; + +again: + init_rss_vec(rss); + start_pte = pte_offset_map_lock(mm, pmd, addr, &ptl); + pte = start_pte; + arch_enter_lazy_mmu_mode(); + do { + pte_t ptent = *pte; + if (pte_none(ptent)) { + continue; + } + + if (pte_present(ptent)) { + struct page *page; + + page = vm_normal_page(vma, addr, ptent); + if (unlikely(details) && page) { + /* + * unmap_shared_mapping_pages() wants to + * invalidate cache without truncating: + * unmap shared but keep private pages. + */ + if (details->check_mapping && + details->check_mapping != page->mapping) + continue; + /* + * Each page->index must be checked when + * invalidating or truncating nonlinear. + */ + if (details->nonlinear_vma && + (page->index < details->first_index || + page->index > details->last_index)) + continue; + } + ptent = ptep_get_and_clear_full(mm, addr, pte, + tlb->fullmm); + tlb_remove_tlb_entry(tlb, pte, addr); + if (unlikely(!page)) + continue; + if (unlikely(details) && details->nonlinear_vma + && linear_page_index(details->nonlinear_vma, + addr) != page->index) + set_pte_at(mm, addr, pte, + pgoff_to_pte(page->index)); + if (PageAnon(page)) + rss[MM_ANONPAGES]--; + else { + if (pte_dirty(ptent)) + set_page_dirty(page); + if (pte_young(ptent) && + likely(!VM_SequentialReadHint(vma))) + mark_page_accessed(page); + rss[MM_FILEPAGES]--; + } + page_remove_rmap(page); + if (unlikely(page_mapcount(page) < 0)) + print_bad_pte(vma, addr, ptent, page); + force_flush = !__tlb_remove_page(tlb, page); + if (force_flush) + break; + continue; + } + /* + * If details->check_mapping, we leave swap entries; + * if details->nonlinear_vma, we leave file entries. + */ + if (unlikely(details)) + continue; + if (pte_file(ptent)) { + if (unlikely(!(vma->vm_flags & VM_NONLINEAR))) + print_bad_pte(vma, addr, ptent, NULL); + } else { + swp_entry_t entry = pte_to_swp_entry(ptent); + + if (!non_swap_entry(entry)) + rss[MM_SWAPENTS]--; + else if (is_migration_entry(entry)) { + struct page *page; + + page = migration_entry_to_page(entry); + + if (PageAnon(page)) + rss[MM_ANONPAGES]--; + else + rss[MM_FILEPAGES]--; + } + if (unlikely(!free_swap_and_cache(entry))) + print_bad_pte(vma, addr, ptent, NULL); + } + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); + } while (pte++, addr += PAGE_SIZE, addr != end); + + add_mm_rss_vec(mm, rss); + arch_leave_lazy_mmu_mode(); + pte_unmap_unlock(start_pte, ptl); + + /* + * mmu_gather ran out of room to batch pages, we break out of + * the PTE lock to avoid doing the potential expensive TLB invalidate + * and page-free while holding it. + */ + if (force_flush) { + force_flush = 0; + tlb_flush_mmu(tlb); + if (addr != end) + goto again; + } + + return addr; +} +","@@ -1247,16 +1247,24 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb, + do { + next = pmd_addr_end(addr, end); + if (pmd_trans_huge(*pmd)) { +- if (next-addr != HPAGE_PMD_SIZE) { ++ if (next - addr != HPAGE_PMD_SIZE) { + VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem)); + split_huge_page_pmd(vma->vm_mm, pmd); + } else if (zap_huge_pmd(tlb, vma, pmd, addr)) +- continue; ++ goto next; + /* fall through */ + } +- if (pmd_none_or_clear_bad(pmd)) +- continue; ++ /* ++ * Here there can be other concurrent MADV_DONTNEED or ++ * trans huge page faults running, and if the pmd is ++ * none or trans huge it can change under us. This is ++ * because MADV_DONTNEED holds the mmap_sem in read ++ * mode. ++ */ ++ if (pmd_none_or_trans_huge_or_clear_bad(pmd)) ++ goto next; + next = zap_pte_range(tlb, vma, pmd, addr, next, details); ++next: + cond_resched(); + } while (pmd++, addr = next, addr != end); + ",928,1164,2048 +17845,"vmnc_handle_wmvi_rectangle (GstVMncDec * dec, struct RfbRectangle *rect, + const guint8 * data, int len, gboolean decode) +{ + GstVideoFormat format; + gint bpp, tc; + guint32 redmask, greenmask, bluemask; + guint32 endianness, dataendianness; + GstVideoCodecState *state; + + /* A WMVi rectangle has a 16byte payload */ + if (len < 16) { + GST_DEBUG_OBJECT (dec, ""Bad WMVi rect: too short""); + return ERROR_INSUFFICIENT_DATA; + } + + /* We only compare 13 bytes; ignoring the 3 padding bytes at the end */ + if (dec->have_format && memcmp (data, dec->format.descriptor, 13) == 0) { + /* Nothing changed, so just exit */ + return 16; + } + + /* Store the whole block for simple comparison later */ + memcpy (dec->format.descriptor, data, 16); + + if (rect->x != 0 || rect->y != 0) { + GST_WARNING_OBJECT (dec, ""Bad WMVi rect: wrong coordinates""); + return ERROR_INVALID; + } + + bpp = data[0]; + dec->format.depth = data[1]; + dec->format.big_endian = data[2]; + dataendianness = data[2] ? G_BIG_ENDIAN : G_LITTLE_ENDIAN; + tc = data[3]; + + if (bpp != 8 && bpp != 16 && bpp != 32) { + GST_WARNING_OBJECT (dec, ""Bad bpp value: %d"", bpp); + return ERROR_INVALID; + } + + if (!tc) { + GST_WARNING_OBJECT (dec, ""Paletted video not supported""); + return ERROR_INVALID; + } + + dec->format.bytes_per_pixel = bpp / 8; + dec->format.width = rect->width; + dec->format.height = rect->height; + + redmask = (guint32) (RFB_GET_UINT16 (data + 4)) << data[10]; + greenmask = (guint32) (RFB_GET_UINT16 (data + 6)) << data[11]; + bluemask = (guint32) (RFB_GET_UINT16 (data + 8)) << data[12]; + + GST_DEBUG_OBJECT (dec, ""Red: mask %d, shift %d"", + RFB_GET_UINT16 (data + 4), data[10]); + GST_DEBUG_OBJECT (dec, ""Green: mask %d, shift %d"", + RFB_GET_UINT16 (data + 6), data[11]); + GST_DEBUG_OBJECT (dec, ""Blue: mask %d, shift %d"", + RFB_GET_UINT16 (data + 8), data[12]); + GST_DEBUG_OBJECT (dec, ""BPP: %d. endianness: %s"", bpp, + data[2] ? ""big"" : ""little""); + + /* GStreamer's RGB caps are a bit weird. */ + if (bpp == 8) { + endianness = G_BYTE_ORDER; /* Doesn't matter */ + } else if (bpp == 16) { + /* We require host-endian. */ + endianness = G_BYTE_ORDER; + } else { /* bpp == 32 */ + /* We require big endian */ + endianness = G_BIG_ENDIAN; + if (endianness != dataendianness) { + redmask = GUINT32_SWAP_LE_BE (redmask); + greenmask = GUINT32_SWAP_LE_BE (greenmask); + bluemask = GUINT32_SWAP_LE_BE (bluemask); + } + } + + format = gst_video_format_from_masks (dec->format.depth, bpp, endianness, + redmask, greenmask, bluemask, 0); + + GST_DEBUG_OBJECT (dec, ""From depth: %d bpp: %u endianess: %s redmask: %X "" + ""greenmask: %X bluemask: %X got format %s"", + dec->format.depth, bpp, endianness == G_BIG_ENDIAN ? ""BE"" : ""LE"", + GUINT32_FROM_BE (redmask), GUINT32_FROM_BE (greenmask), + GUINT32_FROM_BE (bluemask), + format == GST_VIDEO_FORMAT_UNKNOWN ? ""UNKOWN"" : + gst_video_format_to_string (format)); + + if (format == GST_VIDEO_FORMAT_UNKNOWN) { + GST_WARNING_OBJECT (dec, ""Video format unknown to GStreamer""); + return ERROR_INVALID; + } + + dec->have_format = TRUE; + if (!decode) { + GST_LOG_OBJECT (dec, ""Parsing, not setting caps""); + return 16; + } + + + state = gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), format, + rect->width, rect->height, dec->input_state); + gst_video_codec_state_unref (state); + + g_free (dec->imagedata); + dec->imagedata = g_malloc (dec->format.width * dec->format.height * + dec->format.bytes_per_pixel); + GST_DEBUG_OBJECT (dec, ""Allocated image data at %p"", dec->imagedata); + + dec->format.stride = dec->format.width * dec->format.bytes_per_pixel; + + return 16; +} +",1,"vmnc_handle_wmvi_rectangle (GstVMncDec * dec, struct RfbRectangle *rect, + const guint8 * data, int len, gboolean decode) +{ + GstVideoFormat format; + gint bpp, tc; + guint32 redmask, greenmask, bluemask; + guint32 endianness, dataendianness; + GstVideoCodecState *state; + + /* A WMVi rectangle has a 16byte payload */ + if (len < 16) { + GST_DEBUG_OBJECT (dec, ""Bad WMVi rect: too short""); + return ERROR_INSUFFICIENT_DATA; + } + + /* We only compare 13 bytes; ignoring the 3 padding bytes at the end */ + if (dec->have_format && memcmp (data, dec->format.descriptor, 13) == 0) { + /* Nothing changed, so just exit */ + return 16; + } + + /* Store the whole block for simple comparison later */ + memcpy (dec->format.descriptor, data, 16); + + if (rect->x != 0 || rect->y != 0) { + GST_WARNING_OBJECT (dec, ""Bad WMVi rect: wrong coordinates""); + return ERROR_INVALID; + } + + bpp = data[0]; + dec->format.depth = data[1]; + dec->format.big_endian = data[2]; + dataendianness = data[2] ? G_BIG_ENDIAN : G_LITTLE_ENDIAN; + tc = data[3]; + + if (bpp != 8 && bpp != 16 && bpp != 32) { + GST_WARNING_OBJECT (dec, ""Bad bpp value: %d"", bpp); + return ERROR_INVALID; + } + + if (!tc) { + GST_WARNING_OBJECT (dec, ""Paletted video not supported""); + return ERROR_INVALID; + } + + dec->format.bytes_per_pixel = bpp / 8; + dec->format.width = rect->width; + dec->format.height = rect->height; + + redmask = (guint32) (RFB_GET_UINT16 (data + 4)) << data[10]; + greenmask = (guint32) (RFB_GET_UINT16 (data + 6)) << data[11]; + bluemask = (guint32) (RFB_GET_UINT16 (data + 8)) << data[12]; + + GST_DEBUG_OBJECT (dec, ""Red: mask %d, shift %d"", + RFB_GET_UINT16 (data + 4), data[10]); + GST_DEBUG_OBJECT (dec, ""Green: mask %d, shift %d"", + RFB_GET_UINT16 (data + 6), data[11]); + GST_DEBUG_OBJECT (dec, ""Blue: mask %d, shift %d"", + RFB_GET_UINT16 (data + 8), data[12]); + GST_DEBUG_OBJECT (dec, ""BPP: %d. endianness: %s"", bpp, + data[2] ? ""big"" : ""little""); + + /* GStreamer's RGB caps are a bit weird. */ + if (bpp == 8) { + endianness = G_BYTE_ORDER; /* Doesn't matter */ + } else if (bpp == 16) { + /* We require host-endian. */ + endianness = G_BYTE_ORDER; + } else { /* bpp == 32 */ + /* We require big endian */ + endianness = G_BIG_ENDIAN; + if (endianness != dataendianness) { + redmask = GUINT32_SWAP_LE_BE (redmask); + greenmask = GUINT32_SWAP_LE_BE (greenmask); + bluemask = GUINT32_SWAP_LE_BE (bluemask); + } + } + + format = gst_video_format_from_masks (dec->format.depth, bpp, endianness, + redmask, greenmask, bluemask, 0); + + GST_DEBUG_OBJECT (dec, ""From depth: %d bpp: %u endianess: %s redmask: %X "" + ""greenmask: %X bluemask: %X got format %s"", + dec->format.depth, bpp, endianness == G_BIG_ENDIAN ? ""BE"" : ""LE"", + GUINT32_FROM_BE (redmask), GUINT32_FROM_BE (greenmask), + GUINT32_FROM_BE (bluemask), + format == GST_VIDEO_FORMAT_UNKNOWN ? ""UNKOWN"" : + gst_video_format_to_string (format)); + + if (format == GST_VIDEO_FORMAT_UNKNOWN) { + GST_WARNING_OBJECT (dec, ""Video format unknown to GStreamer""); + return ERROR_INVALID; + } + + dec->have_format = TRUE; + if (!decode) { + GST_LOG_OBJECT (dec, ""Parsing, not setting caps""); + return 16; + } + + + state = gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), format, + rect->width, rect->height, dec->input_state); + gst_video_codec_state_unref (state); + + g_free (dec->imagedata); + dec->imagedata = g_malloc0 (dec->format.width * dec->format.height * + dec->format.bytes_per_pixel); + GST_DEBUG_OBJECT (dec, ""Allocated image data at %p"", dec->imagedata); + + dec->format.stride = dec->format.width * dec->format.bytes_per_pixel; + + return 16; +} +","@@ -260,7 +260,7 @@ vmnc_handle_wmvi_rectangle (GstVMncDec * dec, struct RfbRectangle *rect, + gst_video_codec_state_unref (state); + + g_free (dec->imagedata); +- dec->imagedata = g_malloc (dec->format.width * dec->format.height * ++ dec->imagedata = g_malloc0 (dec->format.width * dec->format.height * + dec->format.bytes_per_pixel); + GST_DEBUG_OBJECT (dec, ""Allocated image data at %p"", dec->imagedata); + +@@ -790,6 +790,10 @@ vmnc_handle_packet (GstVMncDec * dec, const guint8 * data, int len, + GST_WARNING_OBJECT (dec, ""Rectangle out of range, type %d"", r.type); + return ERROR_INVALID; + } ++ } else if (r.width > 16384 || r.height > 16384) { ++ GST_WARNING_OBJECT (dec, ""Width or height too high: %ux%u"", r.width, ++ r.height); ++ return ERROR_INVALID; + } + + switch (r.type) {",1168,1404,2048 +9129,"static int check_cond_jmp_op(struct bpf_verifier_env *env, + struct bpf_insn *insn, int *insn_idx) +{ + struct bpf_verifier_state *this_branch = env->cur_state; + struct bpf_verifier_state *other_branch; + struct bpf_reg_state *regs = this_branch->frame[this_branch->curframe]->regs; + struct bpf_reg_state *dst_reg, *other_branch_regs; + u8 opcode = BPF_OP(insn->code); + int err; + + if (opcode > BPF_JSLE) { + verbose(env, ""invalid BPF_JMP opcode %x\n"", opcode); + return -EINVAL; + } + + if (BPF_SRC(insn->code) == BPF_X) { + if (insn->imm != 0) { + verbose(env, ""BPF_JMP uses reserved fields\n""); + return -EINVAL; + } + + /* check src1 operand */ + err = check_reg_arg(env, insn->src_reg, SRC_OP); + if (err) + return err; + + if (is_pointer_value(env, insn->src_reg)) { + verbose(env, ""R%d pointer comparison prohibited\n"", + insn->src_reg); + return -EACCES; + } + } else { + if (insn->src_reg != BPF_REG_0) { + verbose(env, ""BPF_JMP uses reserved fields\n""); + return -EINVAL; + } + } + + /* check src2 operand */ + err = check_reg_arg(env, insn->dst_reg, SRC_OP); + if (err) + return err; + + dst_reg = ®s[insn->dst_reg]; + + if (BPF_SRC(insn->code) == BPF_K) { + int pred = is_branch_taken(dst_reg, insn->imm, opcode); + + if (pred == 1) { + /* only follow the goto, ignore fall-through */ + *insn_idx += insn->off; + return 0; + } else if (pred == 0) { + /* only follow fall-through branch, since + * that's where the program will go + */ + return 0; + } + } + + other_branch = push_stack(env, *insn_idx + insn->off + 1, *insn_idx, + false); + if (!other_branch) + return -EFAULT; + other_branch_regs = other_branch->frame[other_branch->curframe]->regs; + + /* detect if we are comparing against a constant value so we can adjust + * our min/max values for our dst register. + * this is only legit if both are scalars (or pointers to the same + * object, I suppose, but we don't support that right now), because + * otherwise the different base pointers mean the offsets aren't + * comparable. + */ + if (BPF_SRC(insn->code) == BPF_X) { + if (dst_reg->type == SCALAR_VALUE && + regs[insn->src_reg].type == SCALAR_VALUE) { + if (tnum_is_const(regs[insn->src_reg].var_off)) + reg_set_min_max(&other_branch_regs[insn->dst_reg], + dst_reg, regs[insn->src_reg].var_off.value, + opcode); + else if (tnum_is_const(dst_reg->var_off)) + reg_set_min_max_inv(&other_branch_regs[insn->src_reg], + ®s[insn->src_reg], + dst_reg->var_off.value, opcode); + else if (opcode == BPF_JEQ || opcode == BPF_JNE) + /* Comparing for equality, we can combine knowledge */ + reg_combine_min_max(&other_branch_regs[insn->src_reg], + &other_branch_regs[insn->dst_reg], + ®s[insn->src_reg], + ®s[insn->dst_reg], opcode); + } + } else if (dst_reg->type == SCALAR_VALUE) { + reg_set_min_max(&other_branch_regs[insn->dst_reg], + dst_reg, insn->imm, opcode); + } + + /* detect if R == 0 where R is returned from bpf_map_lookup_elem() */ + if (BPF_SRC(insn->code) == BPF_K && + insn->imm == 0 && (opcode == BPF_JEQ || opcode == BPF_JNE) && + reg_type_may_be_null(dst_reg->type)) { + /* Mark all identical registers in each branch as either + * safe or unknown depending R == 0 or R != 0 conditional. + */ + mark_ptr_or_null_regs(this_branch, insn->dst_reg, + opcode == BPF_JNE); + mark_ptr_or_null_regs(other_branch, insn->dst_reg, + opcode == BPF_JEQ); + } else if (!try_match_pkt_pointers(insn, dst_reg, ®s[insn->src_reg], + this_branch, other_branch) && + is_pointer_value(env, insn->dst_reg)) { + verbose(env, ""R%d pointer comparison prohibited\n"", + insn->dst_reg); + return -EACCES; + } + if (env->log.level) + print_verifier_state(env, this_branch->frame[this_branch->curframe]); + return 0; +} +",0,"static int check_cond_jmp_op(struct bpf_verifier_env *env, + struct bpf_insn *insn, int *insn_idx) +{ + struct bpf_verifier_state *this_branch = env->cur_state; + struct bpf_verifier_state *other_branch; + struct bpf_reg_state *regs = this_branch->frame[this_branch->curframe]->regs; + struct bpf_reg_state *dst_reg, *other_branch_regs; + u8 opcode = BPF_OP(insn->code); + int err; + + if (opcode > BPF_JSLE) { + verbose(env, ""invalid BPF_JMP opcode %x\n"", opcode); + return -EINVAL; + } + + if (BPF_SRC(insn->code) == BPF_X) { + if (insn->imm != 0) { + verbose(env, ""BPF_JMP uses reserved fields\n""); + return -EINVAL; + } + + /* check src1 operand */ + err = check_reg_arg(env, insn->src_reg, SRC_OP); + if (err) + return err; + + if (is_pointer_value(env, insn->src_reg)) { + verbose(env, ""R%d pointer comparison prohibited\n"", + insn->src_reg); + return -EACCES; + } + } else { + if (insn->src_reg != BPF_REG_0) { + verbose(env, ""BPF_JMP uses reserved fields\n""); + return -EINVAL; + } + } + + /* check src2 operand */ + err = check_reg_arg(env, insn->dst_reg, SRC_OP); + if (err) + return err; + + dst_reg = ®s[insn->dst_reg]; + + if (BPF_SRC(insn->code) == BPF_K) { + int pred = is_branch_taken(dst_reg, insn->imm, opcode); + + if (pred == 1) { + /* only follow the goto, ignore fall-through */ + *insn_idx += insn->off; + return 0; + } else if (pred == 0) { + /* only follow fall-through branch, since + * that's where the program will go + */ + return 0; + } + } + + other_branch = push_stack(env, *insn_idx + insn->off + 1, *insn_idx, + false); + if (!other_branch) + return -EFAULT; + other_branch_regs = other_branch->frame[other_branch->curframe]->regs; + + /* detect if we are comparing against a constant value so we can adjust + * our min/max values for our dst register. + * this is only legit if both are scalars (or pointers to the same + * object, I suppose, but we don't support that right now), because + * otherwise the different base pointers mean the offsets aren't + * comparable. + */ + if (BPF_SRC(insn->code) == BPF_X) { + if (dst_reg->type == SCALAR_VALUE && + regs[insn->src_reg].type == SCALAR_VALUE) { + if (tnum_is_const(regs[insn->src_reg].var_off)) + reg_set_min_max(&other_branch_regs[insn->dst_reg], + dst_reg, regs[insn->src_reg].var_off.value, + opcode); + else if (tnum_is_const(dst_reg->var_off)) + reg_set_min_max_inv(&other_branch_regs[insn->src_reg], + ®s[insn->src_reg], + dst_reg->var_off.value, opcode); + else if (opcode == BPF_JEQ || opcode == BPF_JNE) + /* Comparing for equality, we can combine knowledge */ + reg_combine_min_max(&other_branch_regs[insn->src_reg], + &other_branch_regs[insn->dst_reg], + ®s[insn->src_reg], + ®s[insn->dst_reg], opcode); + } + } else if (dst_reg->type == SCALAR_VALUE) { + reg_set_min_max(&other_branch_regs[insn->dst_reg], + dst_reg, insn->imm, opcode); + } + + /* detect if R == 0 where R is returned from bpf_map_lookup_elem() */ + if (BPF_SRC(insn->code) == BPF_K && + insn->imm == 0 && (opcode == BPF_JEQ || opcode == BPF_JNE) && + reg_type_may_be_null(dst_reg->type)) { + /* Mark all identical registers in each branch as either + * safe or unknown depending R == 0 or R != 0 conditional. + */ + mark_ptr_or_null_regs(this_branch, insn->dst_reg, + opcode == BPF_JNE); + mark_ptr_or_null_regs(other_branch, insn->dst_reg, + opcode == BPF_JEQ); + } else if (!try_match_pkt_pointers(insn, dst_reg, ®s[insn->src_reg], + this_branch, other_branch) && + is_pointer_value(env, insn->dst_reg)) { + verbose(env, ""R%d pointer comparison prohibited\n"", + insn->dst_reg); + return -EACCES; + } + if (env->log.level) + print_verifier_state(env, this_branch->frame[this_branch->curframe]); + return 0; +} +","@@ -3103,6 +3103,40 @@ static int retrieve_ptr_limit(const struct bpf_reg_state *ptr_reg, + } + } + ++static bool can_skip_alu_sanitation(const struct bpf_verifier_env *env, ++ const struct bpf_insn *insn) ++{ ++ return env->allow_ptr_leaks || BPF_SRC(insn->code) == BPF_K; ++} ++ ++static int update_alu_sanitation_state(struct bpf_insn_aux_data *aux, ++ u32 alu_state, u32 alu_limit) ++{ ++ /* If we arrived here from different branches with different ++ * state or limits to sanitize, then this won't work. ++ */ ++ if (aux->alu_state && ++ (aux->alu_state != alu_state || ++ aux->alu_limit != alu_limit)) ++ return -EACCES; ++ ++ /* Corresponding fixup done in fixup_bpf_calls(). */ ++ aux->alu_state = alu_state; ++ aux->alu_limit = alu_limit; ++ return 0; ++} ++ ++static int sanitize_val_alu(struct bpf_verifier_env *env, ++ struct bpf_insn *insn) ++{ ++ struct bpf_insn_aux_data *aux = cur_aux(env); ++ ++ if (can_skip_alu_sanitation(env, insn)) ++ return 0; ++ ++ return update_alu_sanitation_state(aux, BPF_ALU_NON_POINTER, 0); ++} ++ + static int sanitize_ptr_alu(struct bpf_verifier_env *env, + struct bpf_insn *insn, + const struct bpf_reg_state *ptr_reg, +@@ -3117,7 +3151,7 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, + struct bpf_reg_state tmp; + bool ret; + +- if (env->allow_ptr_leaks || BPF_SRC(insn->code) == BPF_K) ++ if (can_skip_alu_sanitation(env, insn)) + return 0; + + /* We already marked aux for masking from non-speculative +@@ -3133,19 +3167,8 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, + + if (retrieve_ptr_limit(ptr_reg, &alu_limit, opcode, off_is_neg)) + return 0; +- +- /* If we arrived here from different branches with different +- * limits to sanitize, then this won't work. +- */ +- if (aux->alu_state && +- (aux->alu_state != alu_state || +- aux->alu_limit != alu_limit)) ++ if (update_alu_sanitation_state(aux, alu_state, alu_limit)) + return -EACCES; +- +- /* Corresponding fixup done in fixup_bpf_calls(). */ +- aux->alu_state = alu_state; +- aux->alu_limit = alu_limit; +- + do_sim: + /* Simulate and find potential out-of-bounds access under + * speculative execution from truncation as a result of +@@ -3418,6 +3441,8 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + s64 smin_val, smax_val; + u64 umin_val, umax_val; + u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; ++ u32 dst = insn->dst_reg; ++ int ret; + + if (insn_bitness == 32) { + /* Relevant for 32-bit RSH: Information can propagate towards +@@ -3452,6 +3477,11 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + + switch (opcode) { + case BPF_ADD: ++ ret = sanitize_val_alu(env, insn); ++ if (ret < 0) { ++ verbose(env, ""R%d tried to add from different pointers or scalars\n"", dst); ++ return ret; ++ } + if (signed_add_overflows(dst_reg->smin_value, smin_val) || + signed_add_overflows(dst_reg->smax_value, smax_val)) { + dst_reg->smin_value = S64_MIN; +@@ -3471,6 +3501,11 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + dst_reg->var_off = tnum_add(dst_reg->var_off, src_reg.var_off); + break; + case BPF_SUB: ++ ret = sanitize_val_alu(env, insn); ++ if (ret < 0) { ++ verbose(env, ""R%d tried to sub from different pointers or scalars\n"", dst); ++ return ret; ++ } + if (signed_sub_overflows(dst_reg->smin_value, smax_val) || + signed_sub_overflows(dst_reg->smax_value, smin_val)) { + /* Overflow possible, we know nothing */",1117,1353,2048 +3328,"static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) +{ + int err = -EIO; + u32 eee_cap; + u32 jmb_pkt_sz = 9000; + + if (tp->dma_limit) + jmb_pkt_sz = tp->dma_limit - ETH_HLEN; + + eee_cap = tp->phy_flags & TG3_PHYFLG_EEE_CAP; + tp->phy_flags &= ~TG3_PHYFLG_EEE_CAP; + + if (!netif_running(tp->dev)) { + data[TG3_MAC_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + data[TG3_PHY_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + if (do_extlpbk) + data[TG3_EXT_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + goto done; + } + + err = tg3_reset_hw(tp, 1); + if (err) { + data[TG3_MAC_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + data[TG3_PHY_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + if (do_extlpbk) + data[TG3_EXT_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + goto done; + } + + if (tg3_flag(tp, ENABLE_RSS)) { + int i; + + /* Reroute all rx packets to the 1st queue */ + for (i = MAC_RSS_INDIR_TBL_0; + i < MAC_RSS_INDIR_TBL_0 + TG3_RSS_INDIR_TBL_SIZE; i += 4) + tw32(i, 0x0); + } + + /* HW errata - mac loopback fails in some cases on 5780. + * Normal traffic and PHY loopback are not affected by + * errata. Also, the MAC loopback test is deprecated for + * all newer ASIC revisions. + */ + if (tg3_asic_rev(tp) != ASIC_REV_5780 && + !tg3_flag(tp, CPMU_PRESENT)) { + tg3_mac_loopback(tp, true); + + if (tg3_run_loopback(tp, ETH_FRAME_LEN, false)) + data[TG3_MAC_LOOPB_TEST] |= TG3_STD_LOOPBACK_FAILED; + + if (tg3_flag(tp, JUMBO_RING_ENABLE) && + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) + data[TG3_MAC_LOOPB_TEST] |= TG3_JMB_LOOPBACK_FAILED; + + tg3_mac_loopback(tp, false); + } + + if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && + !tg3_flag(tp, USE_PHYLIB)) { + int i; + + tg3_phy_lpbk_set(tp, 0, false); + + /* Wait for link */ + for (i = 0; i < 100; i++) { + if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP) + break; + mdelay(1); + } + + if (tg3_run_loopback(tp, ETH_FRAME_LEN, false)) + data[TG3_PHY_LOOPB_TEST] |= TG3_STD_LOOPBACK_FAILED; + if (tg3_flag(tp, TSO_CAPABLE) && + tg3_run_loopback(tp, ETH_FRAME_LEN, true)) + data[TG3_PHY_LOOPB_TEST] |= TG3_TSO_LOOPBACK_FAILED; + if (tg3_flag(tp, JUMBO_RING_ENABLE) && + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) + data[TG3_PHY_LOOPB_TEST] |= TG3_JMB_LOOPBACK_FAILED; + + if (do_extlpbk) { + tg3_phy_lpbk_set(tp, 0, true); + + /* All link indications report up, but the hardware + * isn't really ready for about 20 msec. Double it + * to be sure. + */ + mdelay(40); + + if (tg3_run_loopback(tp, ETH_FRAME_LEN, false)) + data[TG3_EXT_LOOPB_TEST] |= + TG3_STD_LOOPBACK_FAILED; + if (tg3_flag(tp, TSO_CAPABLE) && + tg3_run_loopback(tp, ETH_FRAME_LEN, true)) + data[TG3_EXT_LOOPB_TEST] |= + TG3_TSO_LOOPBACK_FAILED; + if (tg3_flag(tp, JUMBO_RING_ENABLE) && + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) + data[TG3_EXT_LOOPB_TEST] |= + TG3_JMB_LOOPBACK_FAILED; + } + + /* Re-enable gphy autopowerdown. */ + if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD) + tg3_phy_toggle_apd(tp, true); + } + + err = (data[TG3_MAC_LOOPB_TEST] | data[TG3_PHY_LOOPB_TEST] | + data[TG3_EXT_LOOPB_TEST]) ? -EIO : 0; + +done: + tp->phy_flags |= eee_cap; + + return err; +} +",0,"static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) +{ + int err = -EIO; + u32 eee_cap; + u32 jmb_pkt_sz = 9000; + + if (tp->dma_limit) + jmb_pkt_sz = tp->dma_limit - ETH_HLEN; + + eee_cap = tp->phy_flags & TG3_PHYFLG_EEE_CAP; + tp->phy_flags &= ~TG3_PHYFLG_EEE_CAP; + + if (!netif_running(tp->dev)) { + data[TG3_MAC_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + data[TG3_PHY_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + if (do_extlpbk) + data[TG3_EXT_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + goto done; + } + + err = tg3_reset_hw(tp, 1); + if (err) { + data[TG3_MAC_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + data[TG3_PHY_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + if (do_extlpbk) + data[TG3_EXT_LOOPB_TEST] = TG3_LOOPBACK_FAILED; + goto done; + } + + if (tg3_flag(tp, ENABLE_RSS)) { + int i; + + /* Reroute all rx packets to the 1st queue */ + for (i = MAC_RSS_INDIR_TBL_0; + i < MAC_RSS_INDIR_TBL_0 + TG3_RSS_INDIR_TBL_SIZE; i += 4) + tw32(i, 0x0); + } + + /* HW errata - mac loopback fails in some cases on 5780. + * Normal traffic and PHY loopback are not affected by + * errata. Also, the MAC loopback test is deprecated for + * all newer ASIC revisions. + */ + if (tg3_asic_rev(tp) != ASIC_REV_5780 && + !tg3_flag(tp, CPMU_PRESENT)) { + tg3_mac_loopback(tp, true); + + if (tg3_run_loopback(tp, ETH_FRAME_LEN, false)) + data[TG3_MAC_LOOPB_TEST] |= TG3_STD_LOOPBACK_FAILED; + + if (tg3_flag(tp, JUMBO_RING_ENABLE) && + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) + data[TG3_MAC_LOOPB_TEST] |= TG3_JMB_LOOPBACK_FAILED; + + tg3_mac_loopback(tp, false); + } + + if (!(tp->phy_flags & TG3_PHYFLG_PHY_SERDES) && + !tg3_flag(tp, USE_PHYLIB)) { + int i; + + tg3_phy_lpbk_set(tp, 0, false); + + /* Wait for link */ + for (i = 0; i < 100; i++) { + if (tr32(MAC_TX_STATUS) & TX_STATUS_LINK_UP) + break; + mdelay(1); + } + + if (tg3_run_loopback(tp, ETH_FRAME_LEN, false)) + data[TG3_PHY_LOOPB_TEST] |= TG3_STD_LOOPBACK_FAILED; + if (tg3_flag(tp, TSO_CAPABLE) && + tg3_run_loopback(tp, ETH_FRAME_LEN, true)) + data[TG3_PHY_LOOPB_TEST] |= TG3_TSO_LOOPBACK_FAILED; + if (tg3_flag(tp, JUMBO_RING_ENABLE) && + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) + data[TG3_PHY_LOOPB_TEST] |= TG3_JMB_LOOPBACK_FAILED; + + if (do_extlpbk) { + tg3_phy_lpbk_set(tp, 0, true); + + /* All link indications report up, but the hardware + * isn't really ready for about 20 msec. Double it + * to be sure. + */ + mdelay(40); + + if (tg3_run_loopback(tp, ETH_FRAME_LEN, false)) + data[TG3_EXT_LOOPB_TEST] |= + TG3_STD_LOOPBACK_FAILED; + if (tg3_flag(tp, TSO_CAPABLE) && + tg3_run_loopback(tp, ETH_FRAME_LEN, true)) + data[TG3_EXT_LOOPB_TEST] |= + TG3_TSO_LOOPBACK_FAILED; + if (tg3_flag(tp, JUMBO_RING_ENABLE) && + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) + data[TG3_EXT_LOOPB_TEST] |= + TG3_JMB_LOOPBACK_FAILED; + } + + /* Re-enable gphy autopowerdown. */ + if (tp->phy_flags & TG3_PHYFLG_ENABLE_APD) + tg3_phy_toggle_apd(tp, true); + } + + err = (data[TG3_MAC_LOOPB_TEST] | data[TG3_PHY_LOOPB_TEST] | + data[TG3_EXT_LOOPB_TEST]) ? -EIO : 0; + +done: + tp->phy_flags |= eee_cap; + + return err; +} +","@@ -14604,8 +14604,11 @@ static void tg3_read_vpd(struct tg3 *tp) + if (j + len > block_end) + goto partno; + +- memcpy(tp->fw_ver, &vpd_data[j], len); +- strncat(tp->fw_ver, "" bc "", vpdlen - len - 1); ++ if (len >= sizeof(tp->fw_ver)) ++ len = sizeof(tp->fw_ver) - 1; ++ memset(tp->fw_ver, 0, sizeof(tp->fw_ver)); ++ snprintf(tp->fw_ver, sizeof(tp->fw_ver), ""%.*s bc "", len, ++ &vpd_data[j]); + } + + partno:",1104,1340,2048 +8140,"static int cliSendCommand(int argc, char **argv, long repeat) { + char *command = argv[0]; + size_t *argvlen; + int j, output_raw; + + if (!config.eval_ldb && /* In debugging mode, let's pass ""help"" to Redis. */ + (!strcasecmp(command,""help"") || !strcasecmp(command,""?""))) { + cliOutputHelp(--argc, ++argv); + return REDIS_OK; + } + + if (context == NULL) return REDIS_ERR; + + output_raw = 0; + if (!strcasecmp(command,""info"") || + (argc >= 2 && !strcasecmp(command,""debug"") && + !strcasecmp(argv[1],""htstats"")) || + (argc >= 2 && !strcasecmp(command,""memory"") && + (!strcasecmp(argv[1],""malloc-stats"") || + !strcasecmp(argv[1],""doctor""))) || + (argc == 2 && !strcasecmp(command,""cluster"") && + (!strcasecmp(argv[1],""nodes"") || + !strcasecmp(argv[1],""info""))) || + (argc == 2 && !strcasecmp(command,""client"") && + !strcasecmp(argv[1],""list"")) || + (argc == 3 && !strcasecmp(command,""latency"") && + !strcasecmp(argv[1],""graph"")) || + (argc == 2 && !strcasecmp(command,""latency"") && + !strcasecmp(argv[1],""doctor""))) + { + output_raw = 1; + } + + if (!strcasecmp(command,""shutdown"")) config.shutdown = 1; + if (!strcasecmp(command,""monitor"")) config.monitor_mode = 1; + if (!strcasecmp(command,""subscribe"") || + !strcasecmp(command,""psubscribe"")) config.pubsub_mode = 1; + if (!strcasecmp(command,""sync"") || + !strcasecmp(command,""psync"")) config.slave_mode = 1; + + /* When the user manually calls SCRIPT DEBUG, setup the activation of + * debugging mode on the next eval if needed. */ + if (argc == 3 && !strcasecmp(argv[0],""script"") && + !strcasecmp(argv[1],""debug"")) + { + if (!strcasecmp(argv[2],""yes"") || !strcasecmp(argv[2],""sync"")) { + config.enable_ldb_on_eval = 1; + } else { + config.enable_ldb_on_eval = 0; + } + } + + /* Actually activate LDB on EVAL if needed. */ + if (!strcasecmp(command,""eval"") && config.enable_ldb_on_eval) { + config.eval_ldb = 1; + config.output = OUTPUT_RAW; + } + + /* Setup argument length */ + argvlen = zmalloc(argc*sizeof(size_t)); + for (j = 0; j < argc; j++) + argvlen[j] = sdslen(argv[j]); + + while(repeat-- > 0) { + redisAppendCommandArgv(context,argc,(const char**)argv,argvlen); + while (config.monitor_mode) { + if (cliReadReply(output_raw) != REDIS_OK) exit(1); + fflush(stdout); + } + + if (config.pubsub_mode) { + if (config.output != OUTPUT_RAW) + printf(""Reading messages... (press Ctrl-C to quit)\n""); + while (1) { + if (cliReadReply(output_raw) != REDIS_OK) exit(1); + } + } + + if (config.slave_mode) { + printf(""Entering slave output mode... (press Ctrl-C to quit)\n""); + slaveMode(); + config.slave_mode = 0; + zfree(argvlen); + return REDIS_ERR; /* Error = slaveMode lost connection to master */ + } + + if (cliReadReply(output_raw) != REDIS_OK) { + zfree(argvlen); + return REDIS_ERR; + } else { + /* Store database number when SELECT was successfully executed. */ + if (!strcasecmp(command,""select"") && argc == 2 && config.last_cmd_type != REDIS_REPLY_ERROR) { + config.dbnum = atoi(argv[1]); + cliRefreshPrompt(); + } else if (!strcasecmp(command,""auth"") && argc == 2) { + cliSelect(); + } + } + if (config.interval) usleep(config.interval); + fflush(stdout); /* Make it grep friendly */ + } + + zfree(argvlen); + return REDIS_OK; +} +",0,"static int cliSendCommand(int argc, char **argv, long repeat) { + char *command = argv[0]; + size_t *argvlen; + int j, output_raw; + + if (!config.eval_ldb && /* In debugging mode, let's pass ""help"" to Redis. */ + (!strcasecmp(command,""help"") || !strcasecmp(command,""?""))) { + cliOutputHelp(--argc, ++argv); + return REDIS_OK; + } + + if (context == NULL) return REDIS_ERR; + + output_raw = 0; + if (!strcasecmp(command,""info"") || + (argc >= 2 && !strcasecmp(command,""debug"") && + !strcasecmp(argv[1],""htstats"")) || + (argc >= 2 && !strcasecmp(command,""memory"") && + (!strcasecmp(argv[1],""malloc-stats"") || + !strcasecmp(argv[1],""doctor""))) || + (argc == 2 && !strcasecmp(command,""cluster"") && + (!strcasecmp(argv[1],""nodes"") || + !strcasecmp(argv[1],""info""))) || + (argc == 2 && !strcasecmp(command,""client"") && + !strcasecmp(argv[1],""list"")) || + (argc == 3 && !strcasecmp(command,""latency"") && + !strcasecmp(argv[1],""graph"")) || + (argc == 2 && !strcasecmp(command,""latency"") && + !strcasecmp(argv[1],""doctor""))) + { + output_raw = 1; + } + + if (!strcasecmp(command,""shutdown"")) config.shutdown = 1; + if (!strcasecmp(command,""monitor"")) config.monitor_mode = 1; + if (!strcasecmp(command,""subscribe"") || + !strcasecmp(command,""psubscribe"")) config.pubsub_mode = 1; + if (!strcasecmp(command,""sync"") || + !strcasecmp(command,""psync"")) config.slave_mode = 1; + + /* When the user manually calls SCRIPT DEBUG, setup the activation of + * debugging mode on the next eval if needed. */ + if (argc == 3 && !strcasecmp(argv[0],""script"") && + !strcasecmp(argv[1],""debug"")) + { + if (!strcasecmp(argv[2],""yes"") || !strcasecmp(argv[2],""sync"")) { + config.enable_ldb_on_eval = 1; + } else { + config.enable_ldb_on_eval = 0; + } + } + + /* Actually activate LDB on EVAL if needed. */ + if (!strcasecmp(command,""eval"") && config.enable_ldb_on_eval) { + config.eval_ldb = 1; + config.output = OUTPUT_RAW; + } + + /* Setup argument length */ + argvlen = zmalloc(argc*sizeof(size_t)); + for (j = 0; j < argc; j++) + argvlen[j] = sdslen(argv[j]); + + while(repeat-- > 0) { + redisAppendCommandArgv(context,argc,(const char**)argv,argvlen); + while (config.monitor_mode) { + if (cliReadReply(output_raw) != REDIS_OK) exit(1); + fflush(stdout); + } + + if (config.pubsub_mode) { + if (config.output != OUTPUT_RAW) + printf(""Reading messages... (press Ctrl-C to quit)\n""); + while (1) { + if (cliReadReply(output_raw) != REDIS_OK) exit(1); + } + } + + if (config.slave_mode) { + printf(""Entering slave output mode... (press Ctrl-C to quit)\n""); + slaveMode(); + config.slave_mode = 0; + zfree(argvlen); + return REDIS_ERR; /* Error = slaveMode lost connection to master */ + } + + if (cliReadReply(output_raw) != REDIS_OK) { + zfree(argvlen); + return REDIS_ERR; + } else { + /* Store database number when SELECT was successfully executed. */ + if (!strcasecmp(command,""select"") && argc == 2 && config.last_cmd_type != REDIS_REPLY_ERROR) { + config.dbnum = atoi(argv[1]); + cliRefreshPrompt(); + } else if (!strcasecmp(command,""auth"") && argc == 2) { + cliSelect(); + } + } + if (config.interval) usleep(config.interval); + fflush(stdout); /* Make it grep friendly */ + } + + zfree(argvlen); + return REDIS_OK; +} +","@@ -152,20 +152,25 @@ static long long mstime(void) { + } + + static void cliRefreshPrompt(void) { +- int len; +- + if (config.eval_ldb) return; +- if (config.hostsocket != NULL) +- len = snprintf(config.prompt,sizeof(config.prompt),""redis %s"", +- config.hostsocket); +- else +- len = anetFormatAddr(config.prompt, sizeof(config.prompt), +- config.hostip, config.hostport); ++ ++ sds prompt = sdsempty(); ++ if (config.hostsocket != NULL) { ++ prompt = sdscatfmt(prompt,""redis %s"",config.hostsocket); ++ } else { ++ char addr[256]; ++ anetFormatAddr(addr, sizeof(addr), config.hostip, config.hostport); ++ prompt = sdscatlen(prompt,addr,strlen(addr)); ++ } ++ + /* Add [dbnum] if needed */ + if (config.dbnum != 0) +- len += snprintf(config.prompt+len,sizeof(config.prompt)-len,""[%d]"", +- config.dbnum); +- snprintf(config.prompt+len,sizeof(config.prompt)-len,""> ""); ++ prompt = sdscatfmt(prompt,""[%i]"",config.dbnum); ++ ++ /* Copy the prompt in the static buffer. */ ++ prompt = sdscatlen(prompt,""> "",2); ++ snprintf(config.prompt,sizeof(config.prompt),""%s"",prompt); ++ sdsfree(prompt); + } + + /* Return the name of the dotfile for the specified 'dotfilename'.",905,1141,2048 +18179,"static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, + ExceptionInfo *exception) +{ + char + buffer[MagickPathExtent], + colorspace[MagickPathExtent], + tuple[MagickPathExtent]; + + MagickBooleanType + status; + + MagickOffsetType + scene; + + PixelInfo + pixel; + + register const Quantum + *p; + + register ssize_t + x; + + ssize_t + y; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBlobMode,exception); + if (status == MagickFalse) + return(status); + scene=0; + do + { + ComplianceType + compliance; + + const char + *value; + + (void) CopyMagickString(colorspace,CommandOptionToMnemonic( + MagickColorspaceOptions,(ssize_t) image->colorspace),MagickPathExtent); + LocaleLower(colorspace); + image->depth=GetImageQuantumDepth(image,MagickTrue); + if (image->alpha_trait != UndefinedPixelTrait) + (void) ConcatenateMagickString(colorspace,""a"",MagickPathExtent); + compliance=NoCompliance; + value=GetImageOption(image_info,""txt:compliance""); + if (value != (char *) NULL) + compliance=(ComplianceType) ParseCommandOption(MagickComplianceOptions, + MagickFalse,value); + if (LocaleCompare(image_info->magick,""SPARSE-COLOR"") != 0) + { + size_t + depth; + + depth=compliance == SVGCompliance ? image->depth : + MAGICKCORE_QUANTUM_DEPTH; + (void) FormatLocaleString(buffer,MagickPathExtent, + ""# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n"",(double) + image->columns,(double) image->rows,(double) ((MagickOffsetType) + GetQuantumRange(depth)),colorspace); + (void) WriteBlobString(image,buffer); + } + GetPixelInfo(image,&pixel); + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetPixelInfoPixel(image,p,&pixel); + if (pixel.colorspace == LabColorspace) + { + pixel.green-=(QuantumRange+1)/2.0; + pixel.blue-=(QuantumRange+1)/2.0; + } + if (LocaleCompare(image_info->magick,""SPARSE-COLOR"") == 0) + { + /* + Sparse-color format. + */ + if (GetPixelAlpha(image,p) == (Quantum) OpaqueAlpha) + { + GetColorTuple(&pixel,MagickFalse,tuple); + (void) FormatLocaleString(buffer,MagickPathExtent, + ""%.20g,%.20g,"",(double) x,(double) y); + (void) WriteBlobString(image,buffer); + (void) WriteBlobString(image,tuple); + (void) WriteBlobString(image,"" ""); + } + p+=GetPixelChannels(image); + continue; + } + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g,%.20g: "", + (double) x,(double) y); + (void) WriteBlobString(image,buffer); + (void) CopyMagickString(tuple,""("",MagickPathExtent); + if (pixel.colorspace == GRAYColorspace) + ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance, + tuple); + else + { + ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple); + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,GreenPixelChannel,compliance, + tuple); + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,BluePixelChannel,compliance,tuple); + } + if (pixel.colorspace == CMYKColorspace) + { + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,BlackPixelChannel,compliance, + tuple); + } + if (pixel.alpha_trait != UndefinedPixelTrait) + { + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,AlphaPixelChannel,compliance, + tuple); + } + (void) ConcatenateMagickString(tuple,"")"",MagickPathExtent); + (void) WriteBlobString(image,tuple); + (void) WriteBlobString(image,"" ""); + GetColorTuple(&pixel,MagickTrue,tuple); + (void) FormatLocaleString(buffer,MagickPathExtent,""%s"",tuple); + (void) WriteBlobString(image,buffer); + (void) WriteBlobString(image,"" ""); + (void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception); + (void) WriteBlobString(image,tuple); + (void) WriteBlobString(image,""\n""); + p+=GetPixelChannels(image); + } + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + if (GetNextImageInList(image) == (Image *) NULL) + break; + image=SyncNextImageInList(image); + status=SetImageProgress(image,SaveImagesTag,scene++, + GetImageListLength(image)); + if (status == MagickFalse) + break; + } while (image_info->adjoin != MagickFalse); + (void) CloseBlob(image); + return(MagickTrue); +} +",1,"static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, + ExceptionInfo *exception) +{ + char + buffer[MagickPathExtent], + colorspace[MagickPathExtent], + tuple[MagickPathExtent]; + + MagickBooleanType + status; + + MagickOffsetType + scene; + + PixelInfo + pixel; + + register const Quantum + *p; + + register ssize_t + x; + + ssize_t + y; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBlobMode,exception); + if (status == MagickFalse) + return(status); + scene=0; + do + { + ComplianceType + compliance; + + const char + *value; + + (void) CopyMagickString(colorspace,CommandOptionToMnemonic( + MagickColorspaceOptions,(ssize_t) image->colorspace),MagickPathExtent); + LocaleLower(colorspace); + image->depth=GetImageQuantumDepth(image,MagickTrue); + if (image->alpha_trait != UndefinedPixelTrait) + (void) ConcatenateMagickString(colorspace,""a"",MagickPathExtent); + compliance=NoCompliance; + value=GetImageOption(image_info,""txt:compliance""); + if (value != (char *) NULL) + compliance=(ComplianceType) ParseCommandOption(MagickComplianceOptions, + MagickFalse,value); + if (LocaleCompare(image_info->magick,""SPARSE-COLOR"") != 0) + { + size_t + depth; + + depth=compliance == SVGCompliance ? image->depth : + MAGICKCORE_QUANTUM_DEPTH; + (void) FormatLocaleString(buffer,MagickPathExtent, + ""# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n"",(double) + image->columns,(double) image->rows,(double) ((MagickOffsetType) + GetQuantumRange(depth)),colorspace); + (void) WriteBlobString(image,buffer); + } + GetPixelInfo(image,&pixel); + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetPixelInfoPixel(image,p,&pixel); + if (pixel.colorspace == LabColorspace) + { + pixel.green-=(QuantumRange+1)/2.0; + pixel.blue-=(QuantumRange+1)/2.0; + } + if (LocaleCompare(image_info->magick,""SPARSE-COLOR"") == 0) + { + /* + Sparse-color format. + */ + if (GetPixelAlpha(image,p) == (Quantum) OpaqueAlpha) + { + GetColorTuple(&pixel,MagickFalse,tuple); + (void) FormatLocaleString(buffer,MagickPathExtent, + ""%.20g,%.20g,"",(double) x,(double) y); + (void) WriteBlobString(image,buffer); + (void) WriteBlobString(image,tuple); + (void) WriteBlobString(image,"" ""); + } + p+=GetPixelChannels(image); + continue; + } + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g,%.20g: "", + (double) x,(double) y); + (void) WriteBlobString(image,buffer); + (void) CopyMagickString(tuple,""("",MagickPathExtent); + if (pixel.colorspace == GRAYColorspace) + ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,tuple); + else + { + ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple); + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,GreenPixelChannel,compliance, + tuple); + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,BluePixelChannel,compliance,tuple); + } + if (pixel.colorspace == CMYKColorspace) + { + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,BlackPixelChannel,compliance, + tuple); + } + if (pixel.alpha_trait != UndefinedPixelTrait) + { + (void) ConcatenateMagickString(tuple,"","",MagickPathExtent); + ConcatenateColorComponent(&pixel,AlphaPixelChannel,compliance, + tuple); + } + (void) ConcatenateMagickString(tuple,"")"",MagickPathExtent); + (void) WriteBlobString(image,tuple); + (void) WriteBlobString(image,"" ""); + GetColorTuple(&pixel,MagickTrue,tuple); + (void) FormatLocaleString(buffer,MagickPathExtent,""%s"",tuple); + (void) WriteBlobString(image,buffer); + (void) WriteBlobString(image,"" ""); + (void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception); + (void) WriteBlobString(image,tuple); + (void) WriteBlobString(image,""\n""); + p+=GetPixelChannels(image); + } + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + if (GetNextImageInList(image) == (Image *) NULL) + break; + image=SyncNextImageInList(image); + status=SetImageProgress(image,SaveImagesTag,scene++, + GetImageListLength(image)); + if (status == MagickFalse) + break; + } while (image_info->adjoin != MagickFalse); + (void) CloseBlob(image); + return(MagickTrue); +} +","@@ -793,8 +793,7 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, + (void) WriteBlobString(image,buffer); + (void) CopyMagickString(tuple,""("",MagickPathExtent); + if (pixel.colorspace == GRAYColorspace) +- ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance, +- tuple); ++ ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,tuple); + else + { + ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple);",1356,1592,2048 +657,"process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) +{ + uint32_t txd_lower = le32_to_cpu(dp->lower.data); + uint32_t dtype = txd_lower & (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D); + unsigned int split_size = txd_lower & 0xffff, bytes, sz, op; + unsigned int msh = 0xfffff, hdr = 0; + uint64_t addr; + struct e1000_context_desc *xp = (struct e1000_context_desc *)dp; + struct e1000_tx *tp = &s->tx; + + if (dtype == E1000_TXD_CMD_DEXT) { // context descriptor + op = le32_to_cpu(xp->cmd_and_length); + tp->ipcss = xp->lower_setup.ip_fields.ipcss; + tp->ipcso = xp->lower_setup.ip_fields.ipcso; + tp->ipcse = le16_to_cpu(xp->lower_setup.ip_fields.ipcse); + tp->tucss = xp->upper_setup.tcp_fields.tucss; + tp->tucso = xp->upper_setup.tcp_fields.tucso; + tp->tucse = le16_to_cpu(xp->upper_setup.tcp_fields.tucse); + tp->paylen = op & 0xfffff; + tp->hdr_len = xp->tcp_seg_setup.fields.hdr_len; + tp->mss = le16_to_cpu(xp->tcp_seg_setup.fields.mss); + tp->ip = (op & E1000_TXD_CMD_IP) ? 1 : 0; + tp->tcp = (op & E1000_TXD_CMD_TCP) ? 1 : 0; + tp->tse = (op & E1000_TXD_CMD_TSE) ? 1 : 0; + tp->tso_frames = 0; + if (tp->tucso == 0) { // this is probably wrong + DBGOUT(TXSUM, ""TCP/UDP: cso 0!\n""); + tp->tucso = tp->tucss + (tp->tcp ? 16 : 6); + } + return; + } else if (dtype == (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D)) { + if (tp->size == 0) { + tp->sum_needed = le32_to_cpu(dp->upper.data) >> 8; + } + tp->cptse = ( txd_lower & E1000_TXD_CMD_TSE ) ? 1 : 0; + } else { + tp->cptse = 0; + } + + if (vlan_enabled(s) && is_vlan_txd(txd_lower) && + (tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) { + tp->vlan_needed = 1; + cpu_to_be16wu((uint16_t *)(tp->vlan_header), + le16_to_cpup((uint16_t *)(s->mac_reg + VET))); + cpu_to_be16wu((uint16_t *)(tp->vlan_header + 2), + le16_to_cpu(dp->upper.fields.special)); + } + + addr = le64_to_cpu(dp->buffer_addr); + if (tp->tse && tp->cptse) { + hdr = tp->hdr_len; + msh = hdr + tp->mss; + do { + bytes = split_size; + if (tp->size + bytes > msh) + bytes = msh - tp->size; + + bytes = MIN(sizeof(tp->data) - tp->size, bytes); + pci_dma_read(&s->dev, addr, tp->data + tp->size, bytes); + if ((sz = tp->size + bytes) >= hdr && tp->size < hdr) + memmove(tp->header, tp->data, hdr); + tp->size = sz; + addr += bytes; + if (sz == msh) { + xmit_seg(s); + memmove(tp->data, tp->header, hdr); + tp->size = hdr; + } + } while (split_size -= bytes); + } else if (!tp->tse && tp->cptse) { + DBGOUT(TXERR, ""TCP segmentation error\n""); + } else { + split_size = MIN(sizeof(tp->data) - tp->size, split_size); + pci_dma_read(&s->dev, addr, tp->data + tp->size, split_size); + tp->size += split_size; + } + + if (!(txd_lower & E1000_TXD_CMD_EOP)) + return; + if (!(tp->tse && tp->cptse && tp->size < hdr)) + xmit_seg(s); + tp->tso_frames = 0; + tp->sum_needed = 0; + tp->vlan_needed = 0; + tp->size = 0; + tp->cptse = 0; +} +",0,"process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) +{ + uint32_t txd_lower = le32_to_cpu(dp->lower.data); + uint32_t dtype = txd_lower & (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D); + unsigned int split_size = txd_lower & 0xffff, bytes, sz, op; + unsigned int msh = 0xfffff, hdr = 0; + uint64_t addr; + struct e1000_context_desc *xp = (struct e1000_context_desc *)dp; + struct e1000_tx *tp = &s->tx; + + if (dtype == E1000_TXD_CMD_DEXT) { // context descriptor + op = le32_to_cpu(xp->cmd_and_length); + tp->ipcss = xp->lower_setup.ip_fields.ipcss; + tp->ipcso = xp->lower_setup.ip_fields.ipcso; + tp->ipcse = le16_to_cpu(xp->lower_setup.ip_fields.ipcse); + tp->tucss = xp->upper_setup.tcp_fields.tucss; + tp->tucso = xp->upper_setup.tcp_fields.tucso; + tp->tucse = le16_to_cpu(xp->upper_setup.tcp_fields.tucse); + tp->paylen = op & 0xfffff; + tp->hdr_len = xp->tcp_seg_setup.fields.hdr_len; + tp->mss = le16_to_cpu(xp->tcp_seg_setup.fields.mss); + tp->ip = (op & E1000_TXD_CMD_IP) ? 1 : 0; + tp->tcp = (op & E1000_TXD_CMD_TCP) ? 1 : 0; + tp->tse = (op & E1000_TXD_CMD_TSE) ? 1 : 0; + tp->tso_frames = 0; + if (tp->tucso == 0) { // this is probably wrong + DBGOUT(TXSUM, ""TCP/UDP: cso 0!\n""); + tp->tucso = tp->tucss + (tp->tcp ? 16 : 6); + } + return; + } else if (dtype == (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D)) { + if (tp->size == 0) { + tp->sum_needed = le32_to_cpu(dp->upper.data) >> 8; + } + tp->cptse = ( txd_lower & E1000_TXD_CMD_TSE ) ? 1 : 0; + } else { + tp->cptse = 0; + } + + if (vlan_enabled(s) && is_vlan_txd(txd_lower) && + (tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) { + tp->vlan_needed = 1; + cpu_to_be16wu((uint16_t *)(tp->vlan_header), + le16_to_cpup((uint16_t *)(s->mac_reg + VET))); + cpu_to_be16wu((uint16_t *)(tp->vlan_header + 2), + le16_to_cpu(dp->upper.fields.special)); + } + + addr = le64_to_cpu(dp->buffer_addr); + if (tp->tse && tp->cptse) { + hdr = tp->hdr_len; + msh = hdr + tp->mss; + do { + bytes = split_size; + if (tp->size + bytes > msh) + bytes = msh - tp->size; + + bytes = MIN(sizeof(tp->data) - tp->size, bytes); + pci_dma_read(&s->dev, addr, tp->data + tp->size, bytes); + if ((sz = tp->size + bytes) >= hdr && tp->size < hdr) + memmove(tp->header, tp->data, hdr); + tp->size = sz; + addr += bytes; + if (sz == msh) { + xmit_seg(s); + memmove(tp->data, tp->header, hdr); + tp->size = hdr; + } + } while (split_size -= bytes); + } else if (!tp->tse && tp->cptse) { + DBGOUT(TXERR, ""TCP segmentation error\n""); + } else { + split_size = MIN(sizeof(tp->data) - tp->size, split_size); + pci_dma_read(&s->dev, addr, tp->data + tp->size, split_size); + tp->size += split_size; + } + + if (!(txd_lower & E1000_TXD_CMD_EOP)) + return; + if (!(tp->tse && tp->cptse && tp->size < hdr)) + xmit_seg(s); + tp->tso_frames = 0; + tp->sum_needed = 0; + tp->vlan_needed = 0; + tp->size = 0; + tp->cptse = 0; +} +","@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); + #define PNPMMIO_SIZE 0x20000 + #define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */ + ++/* this is the size past which hardware will drop packets when setting LPE=0 */ ++#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 ++ + /* + * HW models: + * E1000_DEV_ID_82540EM works with Windows and Linux +@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) + size = sizeof(min_buf); + } + ++ /* Discard oversized packets if !LPE and !SBP. */ ++ if (size > MAXIMUM_ETHERNET_VLAN_SIZE ++ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE) ++ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) { ++ return size; ++ } ++ + if (!receive_filter(s, buf, size)) + return size;",1125,1361,2048 +18773,"OMX_ERRORTYPE omx_vdec::get_config(OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_INDEXTYPE configIndex, + OMX_INOUT OMX_PTR configData) +{ + (void) hComp; + OMX_ERRORTYPE eRet = OMX_ErrorNone; + + if (m_state == OMX_StateInvalid) { + DEBUG_PRINT_ERROR(""Get Config in Invalid State""); + return OMX_ErrorInvalidState; + } + + + switch ((unsigned long)configIndex) { + case OMX_QcomIndexConfigInterlaced: { + OMX_QCOM_CONFIG_INTERLACETYPE *configFmt = + (OMX_QCOM_CONFIG_INTERLACETYPE *) configData; + if (configFmt->nPortIndex == 1) { + if (configFmt->nIndex == 0) { + configFmt->eInterlaceType = OMX_QCOM_InterlaceFrameProgressive; + } else if (configFmt->nIndex == 1) { + configFmt->eInterlaceType = + OMX_QCOM_InterlaceInterleaveFrameTopFieldFirst; + } else if (configFmt->nIndex == 2) { + configFmt->eInterlaceType = + OMX_QCOM_InterlaceInterleaveFrameBottomFieldFirst; + } else { + DEBUG_PRINT_ERROR(""get_config: OMX_QcomIndexConfigInterlaced:"" + "" NoMore Interlaced formats""); + eRet = OMX_ErrorNoMore; + } + + } else { + DEBUG_PRINT_ERROR(""get_config: Bad port index %d queried on only o/p port"", + (int)configFmt->nPortIndex); + eRet = OMX_ErrorBadPortIndex; + } + + break; + } + case OMX_QcomIndexQueryNumberOfVideoDecInstance: { + QOMX_VIDEO_QUERY_DECODER_INSTANCES *decoderinstances = + (QOMX_VIDEO_QUERY_DECODER_INSTANCES*)configData; + decoderinstances->nNumOfInstances = 16; + /*TODO: How to handle this case */ + break; + + } + case OMX_QcomIndexConfigVideoFramePackingArrangement: { + if (drv_ctx.decoder_format == VDEC_CODECTYPE_H264) { + OMX_QCOM_FRAME_PACK_ARRANGEMENT *configFmt = + (OMX_QCOM_FRAME_PACK_ARRANGEMENT *) configData; + memcpy(configFmt, &m_frame_pack_arrangement, + sizeof(OMX_QCOM_FRAME_PACK_ARRANGEMENT)); + } else { + DEBUG_PRINT_ERROR(""get_config: Framepack data not supported for non H264 codecs""); + } + + break; + } + case OMX_IndexConfigCommonOutputCrop: { + OMX_CONFIG_RECTTYPE *rect = (OMX_CONFIG_RECTTYPE *) configData; + memcpy(rect, &rectangle, sizeof(OMX_CONFIG_RECTTYPE)); + DEBUG_PRINT_HIGH(""get_config: crop info: L: %u, T: %u, R: %u, B: %u"", + rectangle.nLeft, rectangle.nTop, + rectangle.nWidth, rectangle.nHeight); + + break; + } + case OMX_QcomIndexConfigPerfLevel: { + struct v4l2_control control; + OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL *perf = + (OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL *)configData; + + control.id = V4L2_CID_MPEG_VIDC_SET_PERF_LEVEL; + if (ioctl(drv_ctx.video_driver_fd, VIDIOC_G_CTRL, &control) < 0) { + DEBUG_PRINT_ERROR(""Failed getting performance level: %d"", errno); + eRet = OMX_ErrorHardware; + } + + if (eRet == OMX_ErrorNone) { + switch (control.value) { + case V4L2_CID_MPEG_VIDC_PERF_LEVEL_TURBO: + perf->ePerfLevel = OMX_QCOM_PerfLevelTurbo; + break; + default: + DEBUG_PRINT_HIGH(""Unknown perf level %d, reporting Nominal instead"", control.value); + /* Fall through */ + case V4L2_CID_MPEG_VIDC_PERF_LEVEL_NOMINAL: + perf->ePerfLevel = OMX_QCOM_PerfLevelNominal; + break; + } + + } + + break; + } + default: { + DEBUG_PRINT_ERROR(""get_config: unknown param %d"",configIndex); + eRet = OMX_ErrorBadParameter; + } + + } + + return eRet; +} +",1,"OMX_ERRORTYPE omx_vdec::get_config(OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_INDEXTYPE configIndex, + OMX_INOUT OMX_PTR configData) +{ + (void) hComp; + OMX_ERRORTYPE eRet = OMX_ErrorNone; + + if (m_state == OMX_StateInvalid) { + DEBUG_PRINT_ERROR(""Get Config in Invalid State""); + return OMX_ErrorInvalidState; + } + + + switch ((unsigned long)configIndex) { + case OMX_QcomIndexConfigInterlaced: { + VALIDATE_OMX_PARAM_DATA(configData, OMX_QCOM_CONFIG_INTERLACETYPE); + OMX_QCOM_CONFIG_INTERLACETYPE *configFmt = + (OMX_QCOM_CONFIG_INTERLACETYPE *) configData; + if (configFmt->nPortIndex == 1) { + if (configFmt->nIndex == 0) { + configFmt->eInterlaceType = OMX_QCOM_InterlaceFrameProgressive; + } else if (configFmt->nIndex == 1) { + configFmt->eInterlaceType = + OMX_QCOM_InterlaceInterleaveFrameTopFieldFirst; + } else if (configFmt->nIndex == 2) { + configFmt->eInterlaceType = + OMX_QCOM_InterlaceInterleaveFrameBottomFieldFirst; + } else { + DEBUG_PRINT_ERROR(""get_config: OMX_QcomIndexConfigInterlaced:"" + "" NoMore Interlaced formats""); + eRet = OMX_ErrorNoMore; + } + + } else { + DEBUG_PRINT_ERROR(""get_config: Bad port index %d queried on only o/p port"", + (int)configFmt->nPortIndex); + eRet = OMX_ErrorBadPortIndex; + } + + break; + } + case OMX_QcomIndexQueryNumberOfVideoDecInstance: { + VALIDATE_OMX_PARAM_DATA(configData, QOMX_VIDEO_QUERY_DECODER_INSTANCES); + QOMX_VIDEO_QUERY_DECODER_INSTANCES *decoderinstances = + (QOMX_VIDEO_QUERY_DECODER_INSTANCES*)configData; + decoderinstances->nNumOfInstances = 16; + /*TODO: How to handle this case */ + break; + + } + case OMX_QcomIndexConfigVideoFramePackingArrangement: { + if (drv_ctx.decoder_format == VDEC_CODECTYPE_H264) { + VALIDATE_OMX_PARAM_DATA(configData, OMX_QCOM_FRAME_PACK_ARRANGEMENT); + OMX_QCOM_FRAME_PACK_ARRANGEMENT *configFmt = + (OMX_QCOM_FRAME_PACK_ARRANGEMENT *) configData; + memcpy(configFmt, &m_frame_pack_arrangement, + sizeof(OMX_QCOM_FRAME_PACK_ARRANGEMENT)); + } else { + DEBUG_PRINT_ERROR(""get_config: Framepack data not supported for non H264 codecs""); + } + + break; + } + case OMX_IndexConfigCommonOutputCrop: { + VALIDATE_OMX_PARAM_DATA(configData, OMX_CONFIG_RECTTYPE); + OMX_CONFIG_RECTTYPE *rect = (OMX_CONFIG_RECTTYPE *) configData; + memcpy(rect, &rectangle, sizeof(OMX_CONFIG_RECTTYPE)); + DEBUG_PRINT_HIGH(""get_config: crop info: L: %u, T: %u, R: %u, B: %u"", + rectangle.nLeft, rectangle.nTop, + rectangle.nWidth, rectangle.nHeight); + + break; + } + case OMX_QcomIndexConfigPerfLevel: { + VALIDATE_OMX_PARAM_DATA(configData, OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL); + struct v4l2_control control; + OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL *perf = + (OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL *)configData; + + control.id = V4L2_CID_MPEG_VIDC_SET_PERF_LEVEL; + if (ioctl(drv_ctx.video_driver_fd, VIDIOC_G_CTRL, &control) < 0) { + DEBUG_PRINT_ERROR(""Failed getting performance level: %d"", errno); + eRet = OMX_ErrorHardware; + } + + if (eRet == OMX_ErrorNone) { + switch (control.value) { + case V4L2_CID_MPEG_VIDC_PERF_LEVEL_TURBO: + perf->ePerfLevel = OMX_QCOM_PerfLevelTurbo; + break; + default: + DEBUG_PRINT_HIGH(""Unknown perf level %d, reporting Nominal instead"", control.value); + /* Fall through */ + case V4L2_CID_MPEG_VIDC_PERF_LEVEL_NOMINAL: + perf->ePerfLevel = OMX_QCOM_PerfLevelNominal; + break; + } + + } + + break; + } + default: { + DEBUG_PRINT_ERROR(""get_config: unknown param %d"",configIndex); + eRet = OMX_ErrorBadParameter; + } + + } + + return eRet; +} +","@@ -2979,6 +2979,7 @@ + + } + switch ((unsigned long)paramIndex) { + case OMX_IndexParamPortDefinition: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_PORTDEFINITIONTYPE); + OMX_PARAM_PORTDEFINITIONTYPE *portDefn = + (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamPortDefinition""); +@@ -2988,23 +2989,25 @@ + + break; + } + case OMX_IndexParamVideoInit: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PORT_PARAM_TYPE); + OMX_PORT_PARAM_TYPE *portParamType = + (OMX_PORT_PARAM_TYPE *) paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoInit""); + + portParamType->nVersion.nVersion = OMX_SPEC_VERSION; +- portParamType->nSize = sizeof(portParamType); ++ portParamType->nSize = sizeof(OMX_PORT_PARAM_TYPE); + portParamType->nPorts = 2; + portParamType->nStartPortNumber = 0; + break; + } + case OMX_IndexParamVideoPortFormat: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_PORTFORMATTYPE); + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFmt = + (OMX_VIDEO_PARAM_PORTFORMATTYPE *)paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoPortFormat""); + + portFmt->nVersion.nVersion = OMX_SPEC_VERSION; +- portFmt->nSize = sizeof(portFmt); ++ portFmt->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); + + if (0 == portFmt->nPortIndex) { + if (0 == portFmt->nIndex) { +@@ -3046,22 +3049,24 @@ + + } + /*Component should support this port definition*/ + case OMX_IndexParamAudioInit: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PORT_PARAM_TYPE); + OMX_PORT_PARAM_TYPE *audioPortParamType = + (OMX_PORT_PARAM_TYPE *) paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamAudioInit""); + audioPortParamType->nVersion.nVersion = OMX_SPEC_VERSION; +- audioPortParamType->nSize = sizeof(audioPortParamType); ++ audioPortParamType->nSize = sizeof(OMX_PORT_PARAM_TYPE); + audioPortParamType->nPorts = 0; + audioPortParamType->nStartPortNumber = 0; + break; + } + /*Component should support this port definition*/ + case OMX_IndexParamImageInit: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PORT_PARAM_TYPE); + OMX_PORT_PARAM_TYPE *imagePortParamType = + (OMX_PORT_PARAM_TYPE *) paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamImageInit""); + imagePortParamType->nVersion.nVersion = OMX_SPEC_VERSION; +- imagePortParamType->nSize = sizeof(imagePortParamType); ++ imagePortParamType->nSize = sizeof(OMX_PORT_PARAM_TYPE); + imagePortParamType->nPorts = 0; + imagePortParamType->nStartPortNumber = 0; + break; +@@ -3075,6 +3080,7 @@ + + break; + } + case OMX_IndexParamStandardComponentRole: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_COMPONENTROLETYPE); + OMX_PARAM_COMPONENTROLETYPE *comp_role; + comp_role = (OMX_PARAM_COMPONENTROLETYPE *) paramData; + comp_role->nVersion.nVersion = OMX_SPEC_VERSION; +@@ -3088,22 +3094,23 @@ + + } + /* Added for parameter test */ + case OMX_IndexParamPriorityMgmt: { +- ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PRIORITYMGMTTYPE); + OMX_PRIORITYMGMTTYPE *priorityMgmType = + (OMX_PRIORITYMGMTTYPE *) paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamPriorityMgmt""); + priorityMgmType->nVersion.nVersion = OMX_SPEC_VERSION; +- priorityMgmType->nSize = sizeof(priorityMgmType); ++ priorityMgmType->nSize = sizeof(OMX_PRIORITYMGMTTYPE); + + break; + } + /* Added for parameter test */ + case OMX_IndexParamCompBufferSupplier: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_BUFFERSUPPLIERTYPE); + OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplierType = + (OMX_PARAM_BUFFERSUPPLIERTYPE*) paramData; + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamCompBufferSupplier""); + +- bufferSupplierType->nSize = sizeof(bufferSupplierType); ++ bufferSupplierType->nSize = sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE); + bufferSupplierType->nVersion.nVersion = OMX_SPEC_VERSION; + if (0 == bufferSupplierType->nPortIndex) + bufferSupplierType->nPortIndex = OMX_BufferSupplyUnspecified; +@@ -3141,6 +3148,7 @@ + + break; + } + case OMX_IndexParamVideoProfileLevelQuerySupported: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_PROFILELEVELTYPE); + DEBUG_PRINT_LOW(""get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported %08x"", paramIndex); + OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)paramData; +@@ -3149,6 +3157,7 @@ + + } + #if defined (_ANDROID_HONEYCOMB_) || defined (_ANDROID_ICS_) + case OMX_GoogleAndroidIndexGetAndroidNativeBufferUsage: { ++ VALIDATE_OMX_PARAM_DATA(paramData, GetAndroidNativeBufferUsageParams); + DEBUG_PRINT_LOW(""get_parameter: OMX_GoogleAndroidIndexGetAndroidNativeBufferUsage""); + GetAndroidNativeBufferUsageParams* nativeBuffersUsage = (GetAndroidNativeBufferUsageParams *) paramData; + if (nativeBuffersUsage->nPortIndex == OMX_CORE_OUTPUT_PORT_INDEX) { +@@ -3172,6 +3181,7 @@ + + #ifdef FLEXYUV_SUPPORTED + case OMX_QcomIndexFlexibleYUVDescription: { + DEBUG_PRINT_LOW(""get_parameter: describeColorFormat""); ++ VALIDATE_OMX_PARAM_DATA(paramData, DescribeColorFormatParams); + eRet = describeColorFormat(paramData); + break; + } +@@ -3282,6 +3292,7 @@ + + } + switch ((unsigned long)paramIndex) { + case OMX_IndexParamPortDefinition: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_PORTDEFINITIONTYPE); + OMX_PARAM_PORTDEFINITIONTYPE *portDefn; + portDefn = (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; + //TODO: Check if any allocate buffer/use buffer/useNativeBuffer has +@@ -3525,6 +3536,7 @@ + + } + break; + case OMX_IndexParamVideoPortFormat: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_PORTFORMATTYPE); + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFmt = + (OMX_VIDEO_PARAM_PORTFORMATTYPE *)paramData; + int ret=0; +@@ -3571,6 +3583,7 @@ + + break; + + case OMX_QcomIndexPortDefn: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_QCOM_PARAM_PORTDEFINITIONTYPE); + OMX_QCOM_PARAM_PORTDEFINITIONTYPE *portFmt = + (OMX_QCOM_PARAM_PORTDEFINITIONTYPE *) paramData; + DEBUG_PRINT_LOW(""set_parameter: OMX_IndexQcomParamPortDefinitionType %u"", +@@ -3617,6 +3630,7 @@ + + break; + + case OMX_IndexParamStandardComponentRole: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_COMPONENTROLETYPE); + OMX_PARAM_COMPONENTROLETYPE *comp_role; + comp_role = (OMX_PARAM_COMPONENTROLETYPE *) paramData; + DEBUG_PRINT_LOW(""set_parameter: OMX_IndexParamStandardComponentRole %s"", +@@ -3707,6 +3721,7 @@ + + } + + case OMX_IndexParamPriorityMgmt: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PRIORITYMGMTTYPE); + if (m_state != OMX_StateLoaded) { + DEBUG_PRINT_ERROR(""Set Parameter called in Invalid State""); + return OMX_ErrorIncorrectStateOperation; +@@ -3725,6 +3740,7 @@ + + } + + case OMX_IndexParamCompBufferSupplier: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_BUFFERSUPPLIERTYPE); + OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplierType = (OMX_PARAM_BUFFERSUPPLIERTYPE*) paramData; + DEBUG_PRINT_LOW(""set_parameter: OMX_IndexParamCompBufferSupplier %d"", + bufferSupplierType->eBufferSupplier); +@@ -3764,6 +3780,7 @@ + + break; + } + case OMX_QcomIndexParamVideoDecoderPictureOrder: { ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_VIDEO_DECODER_PICTURE_ORDER); + QOMX_VIDEO_DECODER_PICTURE_ORDER *pictureOrder = + (QOMX_VIDEO_DECODER_PICTURE_ORDER *)paramData; + struct v4l2_control control; +@@ -3789,42 +3806,52 @@ + + break; + } + case OMX_QcomIndexParamConcealMBMapExtraData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(VDEC_EXTRADATA_MB_ERROR_MAP, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamFrameInfoExtraData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_FRAMEINFO_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_ExtraDataFrameDimension: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_FRAMEDIMENSION_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamInterlaceExtraData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_INTERLACE_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamH264TimeInfo: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_TIMEINFO_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamVideoFramePackingExtradata: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_FRAMEPACK_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamVideoQPExtraData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_QP_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamVideoInputBitsInfoExtraData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_BITSINFO_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexEnableExtnUserData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_EXTNUSER_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; + case OMX_QcomIndexParamMpeg2SeqDispExtraData: ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); + eRet = enable_extradata(OMX_MPEG2SEQDISP_EXTRADATA, false, + ((QOMX_ENABLETYPE *)paramData)->bEnable); + break; +@@ -3833,6 +3860,7 @@ + + } + break; + case OMX_QcomIndexPlatformPvt: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_QCOM_PLATFORMPRIVATE_EXTN); + DEBUG_PRINT_HIGH(""set_parameter: OMX_QcomIndexPlatformPvt OP Port""); + OMX_QCOM_PLATFORMPRIVATE_EXTN* entryType = (OMX_QCOM_PLATFORMPRIVATE_EXTN *) paramData; + if (entryType->type != OMX_QCOM_PLATFORM_PRIVATE_PMEM) { +@@ -3883,6 +3911,7 @@ + + break; + + case OMX_QcomIndexParamIndexExtraDataType: { ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_INDEXEXTRADATATYPE); + QOMX_INDEXEXTRADATATYPE *extradataIndexType = (QOMX_INDEXEXTRADATATYPE *) paramData; + if ((extradataIndexType->nIndex == OMX_IndexParamPortDefinition) && + (extradataIndexType->bEnabled == OMX_TRUE) && +@@ -3906,6 +3935,7 @@ + + * state. This is ANDROID architecture which is not in sync + * with openmax standard. */ + case OMX_GoogleAndroidIndexEnableAndroidNativeBuffers: { ++ VALIDATE_OMX_PARAM_DATA(paramData, EnableAndroidNativeBuffersParams); + EnableAndroidNativeBuffersParams* enableNativeBuffers = (EnableAndroidNativeBuffersParams *) paramData; + if (enableNativeBuffers) { + m_enable_android_native_buffers = enableNativeBuffers->enable; +@@ -3922,11 +3952,13 @@ + + } + break; + case OMX_GoogleAndroidIndexUseAndroidNativeBuffer: { ++ VALIDATE_OMX_PARAM_DATA(paramData, UseAndroidNativeBufferParams); + eRet = use_android_native_buffer(hComp, paramData); + } + break; + #endif + case OMX_QcomIndexParamEnableTimeStampReorder: { ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_INDEXTIMESTAMPREORDER); + QOMX_INDEXTIMESTAMPREORDER *reorder = (QOMX_INDEXTIMESTAMPREORDER *)paramData; + if (drv_ctx.picture_order == (vdec_output_order)QOMX_VIDEO_DISPLAY_ORDER) { + if (reorder->bEnable == OMX_TRUE) { +@@ -3943,6 +3975,7 @@ + + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: { ++ VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_PROFILELEVELTYPE); + OMX_VIDEO_PARAM_PROFILELEVELTYPE* pParam = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)paramData; + if (pParam) { +@@ -3954,6 +3987,7 @@ + + } + case OMX_QcomIndexParamVideoMetaBufferMode: + { ++ VALIDATE_OMX_PARAM_DATA(paramData, StoreMetaDataInBuffersParams); + StoreMetaDataInBuffersParams *metabuffer = + (StoreMetaDataInBuffersParams *)paramData; + if (!metabuffer) { +@@ -3996,6 +4030,7 @@ + + } + case OMX_QcomIndexParamVideoDownScalar: + { ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_INDEXDOWNSCALAR); + QOMX_INDEXDOWNSCALAR* pParam = (QOMX_INDEXDOWNSCALAR*)paramData; + struct v4l2_control control; + int rc; +@@ -4024,6 +4059,7 @@ + + #ifdef ADAPTIVE_PLAYBACK_SUPPORTED + case OMX_QcomIndexParamVideoAdaptivePlaybackMode: + { ++ VALIDATE_OMX_PARAM_DATA(paramData, PrepareForAdaptivePlaybackParams); + DEBUG_PRINT_LOW(""set_parameter: OMX_GoogleAndroidIndexPrepareForAdaptivePlayback""); + PrepareForAdaptivePlaybackParams* pParams = + (PrepareForAdaptivePlaybackParams *) paramData; +@@ -4052,6 +4088,7 @@ + + #endif + case OMX_QcomIndexParamVideoCustomBufferSize: + { ++ VALIDATE_OMX_PARAM_DATA(paramData, QOMX_VIDEO_CUSTOM_BUFFERSIZE); + DEBUG_PRINT_LOW(""set_parameter: OMX_QcomIndexParamVideoCustomBufferSize""); + QOMX_VIDEO_CUSTOM_BUFFERSIZE* pParam = (QOMX_VIDEO_CUSTOM_BUFFERSIZE*)paramData; + if (pParam->nPortIndex == OMX_CORE_INPUT_PORT_INDEX) { +@@ -4115,6 +4152,7 @@ + + + switch ((unsigned long)configIndex) { + case OMX_QcomIndexConfigInterlaced: { ++ VALIDATE_OMX_PARAM_DATA(configData, OMX_QCOM_CONFIG_INTERLACETYPE); + OMX_QCOM_CONFIG_INTERLACETYPE *configFmt = + (OMX_QCOM_CONFIG_INTERLACETYPE *) configData; + if (configFmt->nPortIndex == 1) { +@@ -4140,6 +4178,7 @@ + + break; + } + case OMX_QcomIndexQueryNumberOfVideoDecInstance: { ++ VALIDATE_OMX_PARAM_DATA(configData, QOMX_VIDEO_QUERY_DECODER_INSTANCES); + QOMX_VIDEO_QUERY_DECODER_INSTANCES *decoderinstances = + (QOMX_VIDEO_QUERY_DECODER_INSTANCES*)configData; + decoderinstances->nNumOfInstances = 16; +@@ -4148,6 +4187,7 @@ + + } + case OMX_QcomIndexConfigVideoFramePackingArrangement: { + if (drv_ctx.decoder_format == VDEC_CODECTYPE_H264) { ++ VALIDATE_OMX_PARAM_DATA(configData, OMX_QCOM_FRAME_PACK_ARRANGEMENT); + OMX_QCOM_FRAME_PACK_ARRANGEMENT *configFmt = + (OMX_QCOM_FRAME_PACK_ARRANGEMENT *) configData; + memcpy(configFmt, &m_frame_pack_arrangement, +@@ -4158,6 +4198,7 @@ + + break; + } + case OMX_IndexConfigCommonOutputCrop: { ++ VALIDATE_OMX_PARAM_DATA(configData, OMX_CONFIG_RECTTYPE); + OMX_CONFIG_RECTTYPE *rect = (OMX_CONFIG_RECTTYPE *) configData; + memcpy(rect, &rectangle, sizeof(OMX_CONFIG_RECTTYPE)); + DEBUG_PRINT_HIGH(""get_config: crop info: L: %u, T: %u, R: %u, B: %u"", +@@ -4166,6 +4207,7 @@ + + break; + } + case OMX_QcomIndexConfigPerfLevel: { ++ VALIDATE_OMX_PARAM_DATA(configData, OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL); + struct v4l2_control control; + OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL *perf = + (OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL *)configData; +@@ -4191,7 +4233,7 @@ + + } + + break; +- } ++ } + default: { + DEBUG_PRINT_ERROR(""get_config: unknown param %d"",configIndex); + eRet = OMX_ErrorBadParameter; +@@ -4337,6 +4379,7 @@ + + struct v4l2_control temp; + temp.id = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_FORMAT; + ++ VALIDATE_OMX_PARAM_DATA(configData, OMX_VIDEO_CONFIG_NALSIZE); + pNal = reinterpret_cast < OMX_VIDEO_CONFIG_NALSIZE * >(configData); + switch (pNal->nNaluBytes) { + case 0: +@@ -8752,7 +8795,7 @@ + + } + DEBUG_PRINT_LOW(""omx_vdec::update_portdef""); + portDefn->nVersion.nVersion = OMX_SPEC_VERSION; +- portDefn->nSize = sizeof(portDefn); ++ portDefn->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); + portDefn->eDomain = OMX_PortDomainVideo; + if (drv_ctx.frame_rate.fps_denominator > 0) + portDefn->format.video.xFramerate = (drv_ctx.frame_rate.fps_numerator / +",902,1138,2048 +18261,"static int jpc_pi_nextrpcl(register jpc_pi_t *pi) +{ + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + int compno; + jpc_picomp_t *picomp; + int xstep; + int ystep; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + uint_fast32_t trx0; + uint_fast32_t try0; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->xstep = 0; + pi->ystep = 0; + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn + + picomp->numrlvls - rlvlno - 1)); + ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn + + picomp->numrlvls - rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; + } + + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend && + pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) { + for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += + pi->ystep - (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += + pi->xstep - (pi->x % pi->xstep)) { + for (pi->compno = pchg->compnostart, + pi->picomp = &pi->picomps[pi->compno]; + pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < + pi->numcomps; ++pi->compno, ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) + || !(pi->x % (1 << rpx))) && + ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) + || !(pi->y % (1 << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp + << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, + pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp + << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, + pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < + pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } +skip: + ; + } + } + } + } + } + } + return 1; +} +",1,"static int jpc_pi_nextrpcl(register jpc_pi_t *pi) +{ + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + int compno; + jpc_picomp_t *picomp; + int xstep; + int ystep; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + uint_fast32_t trx0; + uint_fast32_t try0; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->xstep = 0; + pi->ystep = 0; + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + // Check for the potential for overflow problems. + if (pirlvl->prcwidthexpn + pi->picomp->numrlvls > + JAS_UINTFAST32_NUMBITS - 2 || + pirlvl->prcheightexpn + pi->picomp->numrlvls > + JAS_UINTFAST32_NUMBITS - 2) { + return -1; + } + xstep = picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) << + (pirlvl->prcwidthexpn + picomp->numrlvls - rlvlno - 1)); + ystep = picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) << + (pirlvl->prcheightexpn + picomp->numrlvls - rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; + } + + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend && + pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) { + for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += + pi->ystep - (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += + pi->xstep - (pi->x % pi->xstep)) { + for (pi->compno = pchg->compnostart, + pi->picomp = &pi->picomps[pi->compno]; + pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < + pi->numcomps; ++pi->compno, ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + if (((pi->x == pi->xstart && + ((trx0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpx))) + || !(pi->x % (JAS_CAST(uint_fast32_t, 1) << rpx))) && + ((pi->y == pi->ystart && + ((try0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpy))) + || !(pi->y % (JAS_CAST(uint_fast32_t, 1) << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, + pi->picomp->hsamp << r), pi->pirlvl->prcwidthexpn) - + JPC_FLOORDIVPOW2(trx0, pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, + pi->picomp->vsamp << r), pi->pirlvl->prcheightexpn) - + JPC_FLOORDIVPOW2(try0, pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < + pi->numlyrs && pi->lyrno < JAS_CAST(int, + pchg->lyrnoend); ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } +skip: + ; + } + } + } + } + } + } + return 1; +} +","@@ -198,7 +198,8 @@ static int jpc_pi_nextrlcp(register jpc_pi_t *pi) + JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { + for (pi->compno = pchg->compnostart, pi->picomp = + &pi->picomps[pi->compno]; pi->compno < pi->numcomps && +- pi->compno < JAS_CAST(int, pchg->compnoend); ++pi->compno, ++pi->picomp) { ++ pi->compno < JAS_CAST(int, pchg->compnoend); ++pi->compno, ++ ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } +@@ -247,10 +248,17 @@ static int jpc_pi_nextrpcl(register jpc_pi_t *pi) + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { +- xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn + +- picomp->numrlvls - rlvlno - 1)); +- ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn + +- picomp->numrlvls - rlvlno - 1)); ++ // Check for the potential for overflow problems. ++ if (pirlvl->prcwidthexpn + pi->picomp->numrlvls > ++ JAS_UINTFAST32_NUMBITS - 2 || ++ pirlvl->prcheightexpn + pi->picomp->numrlvls > ++ JAS_UINTFAST32_NUMBITS - 2) { ++ return -1; ++ } ++ xstep = picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) << ++ (pirlvl->prcwidthexpn + picomp->numrlvls - rlvlno - 1)); ++ ystep = picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) << ++ (pirlvl->prcheightexpn + picomp->numrlvls - rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } +@@ -280,21 +288,24 @@ static int jpc_pi_nextrpcl(register jpc_pi_t *pi) + rpy = r + pi->pirlvl->prcheightexpn; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); +- if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) +- || !(pi->x % (1 << rpx))) && +- ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) +- || !(pi->y % (1 << rpy)))) { +- prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp +- << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, +- pi->pirlvl->prcwidthexpn); +- prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp +- << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, +- pi->pirlvl->prcheightexpn); ++ if (((pi->x == pi->xstart && ++ ((trx0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpx))) ++ || !(pi->x % (JAS_CAST(uint_fast32_t, 1) << rpx))) && ++ ((pi->y == pi->ystart && ++ ((try0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpy))) ++ || !(pi->y % (JAS_CAST(uint_fast32_t, 1) << rpy)))) { ++ prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, ++ pi->picomp->hsamp << r), pi->pirlvl->prcwidthexpn) - ++ JPC_FLOORDIVPOW2(trx0, pi->pirlvl->prcwidthexpn); ++ prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, ++ pi->picomp->vsamp << r), pi->pirlvl->prcheightexpn) - ++ JPC_FLOORDIVPOW2(try0, pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < +- pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { ++ pi->numlyrs && pi->lyrno < JAS_CAST(int, ++ pchg->lyrnoend); ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); +@@ -339,16 +350,19 @@ static int jpc_pi_nextpcrl(register jpc_pi_t *pi) + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { +- xstep = picomp->hsamp * (1 << +- (pirlvl->prcwidthexpn + picomp->numrlvls - +- rlvlno - 1)); +- ystep = picomp->vsamp * (1 << +- (pirlvl->prcheightexpn + picomp->numrlvls - +- rlvlno - 1)); +- pi->xstep = (!pi->xstep) ? xstep : +- JAS_MIN(pi->xstep, xstep); +- pi->ystep = (!pi->ystep) ? ystep : +- JAS_MIN(pi->ystep, ystep); ++ // Check for the potential for overflow problems. ++ if (pirlvl->prcwidthexpn + pi->picomp->numrlvls > ++ JAS_UINTFAST32_NUMBITS - 2 || ++ pirlvl->prcheightexpn + pi->picomp->numrlvls > ++ JAS_UINTFAST32_NUMBITS - 2) { ++ return -1; ++ } ++ xstep = picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) << ++ (pirlvl->prcwidthexpn + picomp->numrlvls - rlvlno - 1)); ++ ystep = picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) << ++ (pirlvl->prcheightexpn + picomp->numrlvls - rlvlno - 1)); ++ pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); ++ pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; +@@ -375,20 +389,23 @@ static int jpc_pi_nextpcrl(register jpc_pi_t *pi) + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; +- if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) || ++ if (((pi->x == pi->xstart && ++ ((trx0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpx))) || + !(pi->x % (pi->picomp->hsamp << rpx))) && +- ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) || ++ ((pi->y == pi->ystart && ++ ((try0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpy))) || + !(pi->y % (pi->picomp->vsamp << rpy)))) { +- prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp +- << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, +- pi->pirlvl->prcwidthexpn); +- prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp +- << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, +- pi->pirlvl->prcheightexpn); ++ prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, ++ pi->picomp->hsamp << r), pi->pirlvl->prcwidthexpn) - ++ JPC_FLOORDIVPOW2(trx0, pi->pirlvl->prcwidthexpn); ++ prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, ++ pi->picomp->vsamp << r), pi->pirlvl->prcheightexpn) - ++ JPC_FLOORDIVPOW2(try0, pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && +- pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { ++ pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++ ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); +@@ -426,10 +443,17 @@ static int jpc_pi_nextcprl(register jpc_pi_t *pi) + pi->prgvolfirst = 0; + } + +- for (pi->compno = pchg->compnostart, pi->picomp = +- &pi->picomps[pi->compno]; pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++pi->compno, +- ++pi->picomp) { ++ for (pi->compno = pchg->compnostart, pi->picomp = &pi->picomps[pi->compno]; ++ pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++ ++pi->compno, ++pi->picomp) { + pirlvl = pi->picomp->pirlvls; ++ // Check for the potential for overflow problems. ++ if (pirlvl->prcwidthexpn + pi->picomp->numrlvls > ++ JAS_UINTFAST32_NUMBITS - 2 || ++ pirlvl->prcheightexpn + pi->picomp->numrlvls > ++ JAS_UINTFAST32_NUMBITS - 2) { ++ return -1; ++ } + pi->xstep = pi->picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) << + (pirlvl->prcwidthexpn + pi->picomp->numrlvls - 1)); + pi->ystep = pi->picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) << +@@ -459,23 +483,23 @@ static int jpc_pi_nextcprl(register jpc_pi_t *pi) + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; +- if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) || ++ if (((pi->x == pi->xstart && ++ ((trx0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpx))) || + !(pi->x % (pi->picomp->hsamp << rpx))) && +- ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) || ++ ((pi->y == pi->ystart && ++ ((try0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpy))) || + !(pi->y % (pi->picomp->vsamp << rpy)))) { +- prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp +- << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, +- pi->pirlvl->prcwidthexpn); +- prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp +- << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, +- pi->pirlvl->prcheightexpn); +- pi->prcno = prcvind * +- pi->pirlvl->numhprcs + +- prchind; +- assert(pi->prcno < +- pi->pirlvl->numprcs); +- for (pi->lyrno = 0; pi->lyrno < +- pi->numlyrs && pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) { ++ prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, ++ pi->picomp->hsamp << r), pi->pirlvl->prcwidthexpn) - ++ JPC_FLOORDIVPOW2(trx0, pi->pirlvl->prcwidthexpn); ++ prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, ++ pi->picomp->vsamp << r), pi->pirlvl->prcheightexpn) - ++ JPC_FLOORDIVPOW2(try0, pi->pirlvl->prcheightexpn); ++ pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; ++ assert(pi->prcno < pi->pirlvl->numprcs); ++ for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && ++ pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++ ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno);",1210,1446,2048 +1452,"do_exec_no_pty(Session *s, const char *command) +{ + pid_t pid; + +#ifdef USE_PIPES + int pin[2], pout[2], perr[2]; + + if (s == NULL) + fatal(""do_exec_no_pty: no session""); + + /* Allocate pipes for communicating with the program. */ + if (pipe(pin) < 0) { + error(""%s: pipe in: %.100s"", __func__, strerror(errno)); + return -1; + } + if (pipe(pout) < 0) { + error(""%s: pipe out: %.100s"", __func__, strerror(errno)); + close(pin[0]); + close(pin[1]); + return -1; + } + if (pipe(perr) < 0) { + error(""%s: pipe err: %.100s"", __func__, + strerror(errno)); + close(pin[0]); + close(pin[1]); + close(pout[0]); + close(pout[1]); + return -1; + } +#else + int inout[2], err[2]; + + if (s == NULL) + fatal(""do_exec_no_pty: no session""); + + /* Uses socket pairs to communicate with the program. */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) < 0) { + error(""%s: socketpair #1: %.100s"", __func__, strerror(errno)); + return -1; + } + if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) { + error(""%s: socketpair #2: %.100s"", __func__, + strerror(errno)); + close(inout[0]); + close(inout[1]); + return -1; + } +#endif + + session_proctitle(s); + + /* Fork the child. */ + switch ((pid = fork())) { + case -1: + error(""%s: fork: %.100s"", __func__, strerror(errno)); +#ifdef USE_PIPES + close(pin[0]); + close(pin[1]); + close(pout[0]); + close(pout[1]); + close(perr[0]); + close(perr[1]); +#else + close(inout[0]); + close(inout[1]); + close(err[0]); + close(err[1]); +#endif + return -1; + case 0: + is_child = 1; + + /* Child. Reinitialize the log since the pid has changed. */ + log_init(__progname, options.log_level, + options.log_facility, log_stderr); + + /* + * Create a new session and process group since the 4.4BSD + * setlogin() affects the entire process group. + */ + if (setsid() < 0) + error(""setsid failed: %.100s"", strerror(errno)); + +#ifdef USE_PIPES + /* + * Redirect stdin. We close the parent side of the socket + * pair, and make the child side the standard input. + */ + close(pin[1]); + if (dup2(pin[0], 0) < 0) + perror(""dup2 stdin""); + close(pin[0]); + + /* Redirect stdout. */ + close(pout[0]); + if (dup2(pout[1], 1) < 0) + perror(""dup2 stdout""); + close(pout[1]); + + /* Redirect stderr. */ + close(perr[0]); + if (dup2(perr[1], 2) < 0) + perror(""dup2 stderr""); + close(perr[1]); +#else + /* + * Redirect stdin, stdout, and stderr. Stdin and stdout will + * use the same socket, as some programs (particularly rdist) + * seem to depend on it. + */ + close(inout[1]); + close(err[1]); + if (dup2(inout[0], 0) < 0) /* stdin */ + perror(""dup2 stdin""); + if (dup2(inout[0], 1) < 0) /* stdout (same as stdin) */ + perror(""dup2 stdout""); + close(inout[0]); + if (dup2(err[0], 2) < 0) /* stderr */ + perror(""dup2 stderr""); + close(err[0]); +#endif + + +#ifdef _UNICOS + cray_init_job(s->pw); /* set up cray jid and tmpdir */ +#endif + + /* Do processing for the child (exec command etc). */ + do_child(s, command); + /* NOTREACHED */ + default: + break; + } + +#ifdef _UNICOS + signal(WJSIGNAL, cray_job_termination_handler); +#endif /* _UNICOS */ +#ifdef HAVE_CYGWIN + cygwin_set_impersonation_token(INVALID_HANDLE_VALUE); +#endif + + s->pid = pid; + /* Set interactive/non-interactive mode. */ + packet_set_interactive(s->display != NULL, + options.ip_qos_interactive, options.ip_qos_bulk); + + /* + * Clear loginmsg, since it's the child's responsibility to display + * it to the user, otherwise multiple sessions may accumulate + * multiple copies of the login messages. + */ + buffer_clear(&loginmsg); + +#ifdef USE_PIPES + /* We are the parent. Close the child sides of the pipes. */ + close(pin[0]); + close(pout[1]); + close(perr[1]); + + if (compat20) { + session_set_fds(s, pin[1], pout[0], perr[0], + s->is_subsystem, 0); + } else { + /* Enter the interactive session. */ + server_loop(pid, pin[1], pout[0], perr[0]); + /* server_loop has closed pin[1], pout[0], and perr[0]. */ + } +#else + /* We are the parent. Close the child sides of the socket pairs. */ + close(inout[0]); + close(err[0]); + + /* + * Enter the interactive session. Note: server_loop must be able to + * handle the case that fdin and fdout are the same. + */ + if (compat20) { + session_set_fds(s, inout[1], inout[1], err[1], + s->is_subsystem, 0); + } else { + server_loop(pid, inout[1], inout[1], err[1]); + /* server_loop has closed inout[1] and err[1]. */ + } +#endif + return 0; +} +",0,"do_exec_no_pty(Session *s, const char *command) +{ + pid_t pid; + +#ifdef USE_PIPES + int pin[2], pout[2], perr[2]; + + if (s == NULL) + fatal(""do_exec_no_pty: no session""); + + /* Allocate pipes for communicating with the program. */ + if (pipe(pin) < 0) { + error(""%s: pipe in: %.100s"", __func__, strerror(errno)); + return -1; + } + if (pipe(pout) < 0) { + error(""%s: pipe out: %.100s"", __func__, strerror(errno)); + close(pin[0]); + close(pin[1]); + return -1; + } + if (pipe(perr) < 0) { + error(""%s: pipe err: %.100s"", __func__, + strerror(errno)); + close(pin[0]); + close(pin[1]); + close(pout[0]); + close(pout[1]); + return -1; + } +#else + int inout[2], err[2]; + + if (s == NULL) + fatal(""do_exec_no_pty: no session""); + + /* Uses socket pairs to communicate with the program. */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) < 0) { + error(""%s: socketpair #1: %.100s"", __func__, strerror(errno)); + return -1; + } + if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) { + error(""%s: socketpair #2: %.100s"", __func__, + strerror(errno)); + close(inout[0]); + close(inout[1]); + return -1; + } +#endif + + session_proctitle(s); + + /* Fork the child. */ + switch ((pid = fork())) { + case -1: + error(""%s: fork: %.100s"", __func__, strerror(errno)); +#ifdef USE_PIPES + close(pin[0]); + close(pin[1]); + close(pout[0]); + close(pout[1]); + close(perr[0]); + close(perr[1]); +#else + close(inout[0]); + close(inout[1]); + close(err[0]); + close(err[1]); +#endif + return -1; + case 0: + is_child = 1; + + /* Child. Reinitialize the log since the pid has changed. */ + log_init(__progname, options.log_level, + options.log_facility, log_stderr); + + /* + * Create a new session and process group since the 4.4BSD + * setlogin() affects the entire process group. + */ + if (setsid() < 0) + error(""setsid failed: %.100s"", strerror(errno)); + +#ifdef USE_PIPES + /* + * Redirect stdin. We close the parent side of the socket + * pair, and make the child side the standard input. + */ + close(pin[1]); + if (dup2(pin[0], 0) < 0) + perror(""dup2 stdin""); + close(pin[0]); + + /* Redirect stdout. */ + close(pout[0]); + if (dup2(pout[1], 1) < 0) + perror(""dup2 stdout""); + close(pout[1]); + + /* Redirect stderr. */ + close(perr[0]); + if (dup2(perr[1], 2) < 0) + perror(""dup2 stderr""); + close(perr[1]); +#else + /* + * Redirect stdin, stdout, and stderr. Stdin and stdout will + * use the same socket, as some programs (particularly rdist) + * seem to depend on it. + */ + close(inout[1]); + close(err[1]); + if (dup2(inout[0], 0) < 0) /* stdin */ + perror(""dup2 stdin""); + if (dup2(inout[0], 1) < 0) /* stdout (same as stdin) */ + perror(""dup2 stdout""); + close(inout[0]); + if (dup2(err[0], 2) < 0) /* stderr */ + perror(""dup2 stderr""); + close(err[0]); +#endif + + +#ifdef _UNICOS + cray_init_job(s->pw); /* set up cray jid and tmpdir */ +#endif + + /* Do processing for the child (exec command etc). */ + do_child(s, command); + /* NOTREACHED */ + default: + break; + } + +#ifdef _UNICOS + signal(WJSIGNAL, cray_job_termination_handler); +#endif /* _UNICOS */ +#ifdef HAVE_CYGWIN + cygwin_set_impersonation_token(INVALID_HANDLE_VALUE); +#endif + + s->pid = pid; + /* Set interactive/non-interactive mode. */ + packet_set_interactive(s->display != NULL, + options.ip_qos_interactive, options.ip_qos_bulk); + + /* + * Clear loginmsg, since it's the child's responsibility to display + * it to the user, otherwise multiple sessions may accumulate + * multiple copies of the login messages. + */ + buffer_clear(&loginmsg); + +#ifdef USE_PIPES + /* We are the parent. Close the child sides of the pipes. */ + close(pin[0]); + close(pout[1]); + close(perr[1]); + + if (compat20) { + session_set_fds(s, pin[1], pout[0], perr[0], + s->is_subsystem, 0); + } else { + /* Enter the interactive session. */ + server_loop(pid, pin[1], pout[0], perr[0]); + /* server_loop has closed pin[1], pout[0], and perr[0]. */ + } +#else + /* We are the parent. Close the child sides of the socket pairs. */ + close(inout[0]); + close(err[0]); + + /* + * Enter the interactive session. Note: server_loop must be able to + * handle the case that fdin and fdout are the same. + */ + if (compat20) { + session_set_fds(s, inout[1], inout[1], err[1], + s->is_subsystem, 0); + } else { + server_loop(pid, inout[1], inout[1], err[1]); + /* server_loop has closed inout[1] and err[1]. */ + } +#endif + return 0; +} +","@@ -1322,7 +1322,7 @@ do_setup_env(Session *s, const char *shell) + * Pull in any environment variables that may have + * been set by PAM. + */ +- if (options.use_pam) { ++ if (options.use_pam && !options.use_login) { + char **p; + + p = fetch_pam_child_environment();",1413,1649,2048 +9123,"do_note_freebsd_version(struct magic_set *ms, int swap, void *v) +{ + uint32_t desc; + + memcpy(&desc, v, sizeof(desc)); + desc = elf_getu32(swap, desc); + if (file_printf(ms, "", for FreeBSD"") == -1) + return; + + /* + * Contents is __FreeBSD_version, whose relation to OS + * versions is defined by a huge table in the Porter's + * Handbook. This is the general scheme: + * + * Releases: + * Mmp000 (before 4.10) + * Mmi0p0 (before 5.0) + * Mmm0p0 + * + * Development branches: + * Mmpxxx (before 4.6) + * Mmp1xx (before 4.10) + * Mmi1xx (before 5.0) + * M000xx (pre-M.0) + * Mmm1xx + * + * M = major version + * m = minor version + * i = minor version increment (491000 -> 4.10) + * p = patchlevel + * x = revision + * + * The first release of FreeBSD to use ELF by default + * was version 3.0. + */ + if (desc == 460002) { + if (file_printf(ms, "" 4.6.2"") == -1) + return; + } else if (desc < 460100) { + if (file_printf(ms, "" %d.%d"", desc / 100000, + desc / 10000 % 10) == -1) + return; + if (desc / 1000 % 10 > 0) + if (file_printf(ms, "".%d"", desc / 1000 % 10) == -1) + return; + if ((desc % 1000 > 0) || (desc % 100000 == 0)) + if (file_printf(ms, "" (%d)"", desc) == -1) + return; + } else if (desc < 500000) { + if (file_printf(ms, "" %d.%d"", desc / 100000, + desc / 10000 % 10 + desc / 1000 % 10) == -1) + return; + if (desc / 100 % 10 > 0) { + if (file_printf(ms, "" (%d)"", desc) == -1) + return; + } else if (desc / 10 % 10 > 0) { + if (file_printf(ms, "".%d"", desc / 10 % 10) == -1) + return; + } + } else { + if (file_printf(ms, "" %d.%d"", desc / 100000, + desc / 1000 % 100) == -1) + return; + if ((desc / 100 % 10 > 0) || + (desc % 100000 / 100 == 0)) { + if (file_printf(ms, "" (%d)"", desc) == -1) + return; + } else if (desc / 10 % 10 > 0) { + if (file_printf(ms, "".%d"", desc / 10 % 10) == -1) + return; + } + } +} +",0,"do_note_freebsd_version(struct magic_set *ms, int swap, void *v) +{ + uint32_t desc; + + memcpy(&desc, v, sizeof(desc)); + desc = elf_getu32(swap, desc); + if (file_printf(ms, "", for FreeBSD"") == -1) + return; + + /* + * Contents is __FreeBSD_version, whose relation to OS + * versions is defined by a huge table in the Porter's + * Handbook. This is the general scheme: + * + * Releases: + * Mmp000 (before 4.10) + * Mmi0p0 (before 5.0) + * Mmm0p0 + * + * Development branches: + * Mmpxxx (before 4.6) + * Mmp1xx (before 4.10) + * Mmi1xx (before 5.0) + * M000xx (pre-M.0) + * Mmm1xx + * + * M = major version + * m = minor version + * i = minor version increment (491000 -> 4.10) + * p = patchlevel + * x = revision + * + * The first release of FreeBSD to use ELF by default + * was version 3.0. + */ + if (desc == 460002) { + if (file_printf(ms, "" 4.6.2"") == -1) + return; + } else if (desc < 460100) { + if (file_printf(ms, "" %d.%d"", desc / 100000, + desc / 10000 % 10) == -1) + return; + if (desc / 1000 % 10 > 0) + if (file_printf(ms, "".%d"", desc / 1000 % 10) == -1) + return; + if ((desc % 1000 > 0) || (desc % 100000 == 0)) + if (file_printf(ms, "" (%d)"", desc) == -1) + return; + } else if (desc < 500000) { + if (file_printf(ms, "" %d.%d"", desc / 100000, + desc / 10000 % 10 + desc / 1000 % 10) == -1) + return; + if (desc / 100 % 10 > 0) { + if (file_printf(ms, "" (%d)"", desc) == -1) + return; + } else if (desc / 10 % 10 > 0) { + if (file_printf(ms, "".%d"", desc / 10 % 10) == -1) + return; + } + } else { + if (file_printf(ms, "" %d.%d"", desc / 100000, + desc / 1000 % 100) == -1) + return; + if ((desc / 100 % 10 > 0) || + (desc % 100000 / 100 == 0)) { + if (file_printf(ms, "" (%d)"", desc) == -1) + return; + } else if (desc / 10 % 10 > 0) { + if (file_printf(ms, "".%d"", desc / 10 % 10) == -1) + return; + } + } +} +","@@ -27,7 +27,7 @@ + #include ""file.h"" + + #ifndef lint +-FILE_RCSID(""@(#)$File: readelf.c,v 1.156 2018/10/19 00:33:04 christos Exp $"") ++FILE_RCSID(""@(#)$File: readelf.c,v 1.157 2019/01/02 19:44:14 christos Exp $"") + #endif + + #ifdef BUILTIN_ELF +@@ -752,7 +752,7 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, + char sbuf[512]; + struct NetBSD_elfcore_procinfo pi; + memset(&pi, 0, sizeof(pi)); +- memcpy(&pi, nbuf + doff, descsz); ++ memcpy(&pi, nbuf + doff, MIN(descsz, sizeof(pi))); + + if (file_printf(ms, "", from '%.31s', pid=%u, uid=%u, "" + ""gid=%u, nlwps=%u, lwp=%u (signal %u/code %u)"",",811,1047,2048 +4850,"static int get_vmx_mem_address(struct kvm_vcpu *vcpu, + unsigned long exit_qualification, + u32 vmx_instruction_info, bool wr, gva_t *ret) +{ + gva_t off; + bool exn; + struct kvm_segment s; + + /* + * According to Vol. 3B, ""Information for VM Exits Due to Instruction + * Execution"", on an exit, vmx_instruction_info holds most of the + * addressing components of the operand. Only the displacement part + * is put in exit_qualification (see 3B, ""Basic VM-Exit Information""). + * For how an actual address is calculated from all these components, + * refer to Vol. 1, ""Operand Addressing"". + */ + int scaling = vmx_instruction_info & 3; + int addr_size = (vmx_instruction_info >> 7) & 7; + bool is_reg = vmx_instruction_info & (1u << 10); + int seg_reg = (vmx_instruction_info >> 15) & 7; + int index_reg = (vmx_instruction_info >> 18) & 0xf; + bool index_is_valid = !(vmx_instruction_info & (1u << 22)); + int base_reg = (vmx_instruction_info >> 23) & 0xf; + bool base_is_valid = !(vmx_instruction_info & (1u << 27)); + + if (is_reg) { + kvm_queue_exception(vcpu, UD_VECTOR); + return 1; + } + + /* Addr = segment_base + offset */ + /* offset = base + [index * scale] + displacement */ + off = exit_qualification; /* holds the displacement */ + if (base_is_valid) + off += kvm_register_read(vcpu, base_reg); + if (index_is_valid) + off += kvm_register_read(vcpu, index_reg)< s.limit); + } + if (exn) { + kvm_queue_exception_e(vcpu, + seg_reg == VCPU_SREG_SS ? + SS_VECTOR : GP_VECTOR, + 0); + return 1; + } + + return 0; +} +",0,"static int get_vmx_mem_address(struct kvm_vcpu *vcpu, + unsigned long exit_qualification, + u32 vmx_instruction_info, bool wr, gva_t *ret) +{ + gva_t off; + bool exn; + struct kvm_segment s; + + /* + * According to Vol. 3B, ""Information for VM Exits Due to Instruction + * Execution"", on an exit, vmx_instruction_info holds most of the + * addressing components of the operand. Only the displacement part + * is put in exit_qualification (see 3B, ""Basic VM-Exit Information""). + * For how an actual address is calculated from all these components, + * refer to Vol. 1, ""Operand Addressing"". + */ + int scaling = vmx_instruction_info & 3; + int addr_size = (vmx_instruction_info >> 7) & 7; + bool is_reg = vmx_instruction_info & (1u << 10); + int seg_reg = (vmx_instruction_info >> 15) & 7; + int index_reg = (vmx_instruction_info >> 18) & 0xf; + bool index_is_valid = !(vmx_instruction_info & (1u << 22)); + int base_reg = (vmx_instruction_info >> 23) & 0xf; + bool base_is_valid = !(vmx_instruction_info & (1u << 27)); + + if (is_reg) { + kvm_queue_exception(vcpu, UD_VECTOR); + return 1; + } + + /* Addr = segment_base + offset */ + /* offset = base + [index * scale] + displacement */ + off = exit_qualification; /* holds the displacement */ + if (base_is_valid) + off += kvm_register_read(vcpu, base_reg); + if (index_is_valid) + off += kvm_register_read(vcpu, index_reg)< s.limit); + } + if (exn) { + kvm_queue_exception_e(vcpu, + seg_reg == VCPU_SREG_SS ? + SS_VECTOR : GP_VECTOR, + 0); + return 1; + } + + return 0; +} +","@@ -1389,10 +1389,10 @@ static inline bool nested_cpu_has_posted_intr(struct vmcs12 *vmcs12) + return vmcs12->pin_based_vm_exec_control & PIN_BASED_POSTED_INTR; + } + +-static inline bool is_exception(u32 intr_info) ++static inline bool is_nmi(u32 intr_info) + { + return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VALID_MASK)) +- == (INTR_TYPE_HARD_EXCEPTION | INTR_INFO_VALID_MASK); ++ == (INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK); + } + + static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, +@@ -5728,7 +5728,7 @@ static int handle_exception(struct kvm_vcpu *vcpu) + if (is_machine_check(intr_info)) + return handle_machine_check(vcpu); + +- if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR) ++ if (is_nmi(intr_info)) + return 1; /* already handled by vmx_vcpu_run() */ + + if (is_no_device(intr_info)) { +@@ -8170,7 +8170,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) + + switch (exit_reason) { + case EXIT_REASON_EXCEPTION_NMI: +- if (!is_exception(intr_info)) ++ if (is_nmi(intr_info)) + return false; + else if (is_page_fault(intr_info)) + return enable_ept; +@@ -8765,8 +8765,7 @@ static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx) + kvm_machine_check(); + + /* We need to handle NMIs before interrupts are enabled */ +- if ((exit_intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR && +- (exit_intr_info & INTR_INFO_VALID_MASK)) { ++ if (is_nmi(exit_intr_info)) { + kvm_before_handle_nmi(&vmx->vcpu); + asm(""int $2""); + kvm_after_handle_nmi(&vmx->vcpu);",882,1118,2048 +18042,"static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) +{ + struct ipv6_txoptions opt_space; + DECLARE_SOCKADDR(struct sockaddr_l2tpip6 *, lsa, msg->msg_name); + struct in6_addr *daddr, *final_p, final; + struct ipv6_pinfo *np = inet6_sk(sk); + struct ipv6_txoptions *opt = NULL; + struct ip6_flowlabel *flowlabel = NULL; + struct dst_entry *dst = NULL; + struct flowi6 fl6; + int addr_len = msg->msg_namelen; + int hlimit = -1; + int tclass = -1; + int dontfrag = -1; + int transhdrlen = 4; /* zero session-id */ + int ulen = len + transhdrlen; + int err; + + /* Rough check on arithmetic overflow, + better check is made in ip6_append_data(). + */ + if (len > INT_MAX) + return -EMSGSIZE; + + /* Mirror BSD error message compatibility */ + if (msg->msg_flags & MSG_OOB) + return -EOPNOTSUPP; + + /* + * Get and verify the address. + */ + memset(&fl6, 0, sizeof(fl6)); + + fl6.flowi6_mark = sk->sk_mark; + + if (lsa) { + if (addr_len < SIN6_LEN_RFC2133) + return -EINVAL; + + if (lsa->l2tp_family && lsa->l2tp_family != AF_INET6) + return -EAFNOSUPPORT; + + daddr = &lsa->l2tp_addr; + if (np->sndflow) { + fl6.flowlabel = lsa->l2tp_flowinfo & IPV6_FLOWINFO_MASK; + if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + } + } + + /* + * Otherwise it will be difficult to maintain + * sk->sk_dst_cache. + */ + if (sk->sk_state == TCP_ESTABLISHED && + ipv6_addr_equal(daddr, &sk->sk_v6_daddr)) + daddr = &sk->sk_v6_daddr; + + if (addr_len >= sizeof(struct sockaddr_in6) && + lsa->l2tp_scope_id && + ipv6_addr_type(daddr) & IPV6_ADDR_LINKLOCAL) + fl6.flowi6_oif = lsa->l2tp_scope_id; + } else { + if (sk->sk_state != TCP_ESTABLISHED) + return -EDESTADDRREQ; + + daddr = &sk->sk_v6_daddr; + fl6.flowlabel = np->flow_label; + } + + if (fl6.flowi6_oif == 0) + fl6.flowi6_oif = sk->sk_bound_dev_if; + + if (msg->msg_controllen) { + opt = &opt_space; + memset(opt, 0, sizeof(struct ipv6_txoptions)); + opt->tot_len = sizeof(struct ipv6_txoptions); + + err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt, + &hlimit, &tclass, &dontfrag); + if (err < 0) { + fl6_sock_release(flowlabel); + return err; + } + if ((fl6.flowlabel & IPV6_FLOWLABEL_MASK) && !flowlabel) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + } + if (!(opt->opt_nflen|opt->opt_flen)) + opt = NULL; + } + + if (opt == NULL) + opt = np->opt; + if (flowlabel) + opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = ipv6_fixup_options(&opt_space, opt); + + fl6.flowi6_proto = sk->sk_protocol; + if (!ipv6_addr_any(daddr)) + fl6.daddr = *daddr; + else + fl6.daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */ + if (ipv6_addr_any(&fl6.saddr) && !ipv6_addr_any(&np->saddr)) + fl6.saddr = np->saddr; + + final_p = fl6_update_dst(&fl6, opt, &final); + + if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) + fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; + + security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); + + dst = ip6_dst_lookup_flow(sk, &fl6, final_p); + if (IS_ERR(dst)) { + err = PTR_ERR(dst); + goto out; + } + + if (hlimit < 0) + hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst); + + if (tclass < 0) + tclass = np->tclass; + + if (dontfrag < 0) + dontfrag = np->dontfrag; + + if (msg->msg_flags & MSG_CONFIRM) + goto do_confirm; + +back_from_confirm: + lock_sock(sk); + err = ip6_append_data(sk, ip_generic_getfrag, msg, + ulen, transhdrlen, hlimit, tclass, opt, + &fl6, (struct rt6_info *)dst, + msg->msg_flags, dontfrag); + if (err) + ip6_flush_pending_frames(sk); + else if (!(msg->msg_flags & MSG_MORE)) + err = l2tp_ip6_push_pending_frames(sk); + release_sock(sk); +done: + dst_release(dst); + out: + fl6_sock_release(flowlabel); + + return err < 0 ? err : len; + +do_confirm: + dst_confirm(dst); + if (!(msg->msg_flags & MSG_PROBE) || len) + goto back_from_confirm; + err = 0; + goto done; +} +",1,"static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) +{ + struct ipv6_txoptions opt_space; + DECLARE_SOCKADDR(struct sockaddr_l2tpip6 *, lsa, msg->msg_name); + struct in6_addr *daddr, *final_p, final; + struct ipv6_pinfo *np = inet6_sk(sk); + struct ipv6_txoptions *opt_to_free = NULL; + struct ipv6_txoptions *opt = NULL; + struct ip6_flowlabel *flowlabel = NULL; + struct dst_entry *dst = NULL; + struct flowi6 fl6; + int addr_len = msg->msg_namelen; + int hlimit = -1; + int tclass = -1; + int dontfrag = -1; + int transhdrlen = 4; /* zero session-id */ + int ulen = len + transhdrlen; + int err; + + /* Rough check on arithmetic overflow, + better check is made in ip6_append_data(). + */ + if (len > INT_MAX) + return -EMSGSIZE; + + /* Mirror BSD error message compatibility */ + if (msg->msg_flags & MSG_OOB) + return -EOPNOTSUPP; + + /* + * Get and verify the address. + */ + memset(&fl6, 0, sizeof(fl6)); + + fl6.flowi6_mark = sk->sk_mark; + + if (lsa) { + if (addr_len < SIN6_LEN_RFC2133) + return -EINVAL; + + if (lsa->l2tp_family && lsa->l2tp_family != AF_INET6) + return -EAFNOSUPPORT; + + daddr = &lsa->l2tp_addr; + if (np->sndflow) { + fl6.flowlabel = lsa->l2tp_flowinfo & IPV6_FLOWINFO_MASK; + if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + } + } + + /* + * Otherwise it will be difficult to maintain + * sk->sk_dst_cache. + */ + if (sk->sk_state == TCP_ESTABLISHED && + ipv6_addr_equal(daddr, &sk->sk_v6_daddr)) + daddr = &sk->sk_v6_daddr; + + if (addr_len >= sizeof(struct sockaddr_in6) && + lsa->l2tp_scope_id && + ipv6_addr_type(daddr) & IPV6_ADDR_LINKLOCAL) + fl6.flowi6_oif = lsa->l2tp_scope_id; + } else { + if (sk->sk_state != TCP_ESTABLISHED) + return -EDESTADDRREQ; + + daddr = &sk->sk_v6_daddr; + fl6.flowlabel = np->flow_label; + } + + if (fl6.flowi6_oif == 0) + fl6.flowi6_oif = sk->sk_bound_dev_if; + + if (msg->msg_controllen) { + opt = &opt_space; + memset(opt, 0, sizeof(struct ipv6_txoptions)); + opt->tot_len = sizeof(struct ipv6_txoptions); + + err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt, + &hlimit, &tclass, &dontfrag); + if (err < 0) { + fl6_sock_release(flowlabel); + return err; + } + if ((fl6.flowlabel & IPV6_FLOWLABEL_MASK) && !flowlabel) { + flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); + if (flowlabel == NULL) + return -EINVAL; + } + if (!(opt->opt_nflen|opt->opt_flen)) + opt = NULL; + } + + if (!opt) { + opt = txopt_get(np); + opt_to_free = opt; + } + if (flowlabel) + opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = ipv6_fixup_options(&opt_space, opt); + + fl6.flowi6_proto = sk->sk_protocol; + if (!ipv6_addr_any(daddr)) + fl6.daddr = *daddr; + else + fl6.daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */ + if (ipv6_addr_any(&fl6.saddr) && !ipv6_addr_any(&np->saddr)) + fl6.saddr = np->saddr; + + final_p = fl6_update_dst(&fl6, opt, &final); + + if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) + fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; + + security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); + + dst = ip6_dst_lookup_flow(sk, &fl6, final_p); + if (IS_ERR(dst)) { + err = PTR_ERR(dst); + goto out; + } + + if (hlimit < 0) + hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst); + + if (tclass < 0) + tclass = np->tclass; + + if (dontfrag < 0) + dontfrag = np->dontfrag; + + if (msg->msg_flags & MSG_CONFIRM) + goto do_confirm; + +back_from_confirm: + lock_sock(sk); + err = ip6_append_data(sk, ip_generic_getfrag, msg, + ulen, transhdrlen, hlimit, tclass, opt, + &fl6, (struct rt6_info *)dst, + msg->msg_flags, dontfrag); + if (err) + ip6_flush_pending_frames(sk); + else if (!(msg->msg_flags & MSG_MORE)) + err = l2tp_ip6_push_pending_frames(sk); + release_sock(sk); +done: + dst_release(dst); + out: + fl6_sock_release(flowlabel); + txopt_put(opt_to_free); + + return err < 0 ? err : len; + +do_confirm: + dst_confirm(dst); + if (!(msg->msg_flags & MSG_PROBE) || len) + goto back_from_confirm; + err = 0; + goto done; +} +","@@ -486,6 +486,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) + DECLARE_SOCKADDR(struct sockaddr_l2tpip6 *, lsa, msg->msg_name); + struct in6_addr *daddr, *final_p, final; + struct ipv6_pinfo *np = inet6_sk(sk); ++ struct ipv6_txoptions *opt_to_free = NULL; + struct ipv6_txoptions *opt = NULL; + struct ip6_flowlabel *flowlabel = NULL; + struct dst_entry *dst = NULL; +@@ -575,8 +576,10 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) + opt = NULL; + } + +- if (opt == NULL) +- opt = np->opt; ++ if (!opt) { ++ opt = txopt_get(np); ++ opt_to_free = opt; ++ } + if (flowlabel) + opt = fl6_merge_options(&opt_space, flowlabel, opt); + opt = ipv6_fixup_options(&opt_space, opt); +@@ -631,6 +634,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) + dst_release(dst); + out: + fl6_sock_release(flowlabel); ++ txopt_put(opt_to_free); + + return err < 0 ? err : len; + ",1350,1586,2048 +17931,"static int isofs_read_inode(struct inode *inode) + { + struct super_block *sb = inode->i_sb; + struct isofs_sb_info *sbi = ISOFS_SB(sb); + unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); + unsigned long block; + int high_sierra = sbi->s_high_sierra; + struct buffer_head *bh = NULL; + struct iso_directory_record *de; + struct iso_directory_record *tmpde = NULL; + unsigned int de_len; + unsigned long offset; + struct iso_inode_info *ei = ISOFS_I(inode); + int ret = -EIO; + + block = ei->i_iget5_block; + bh = sb_bread(inode->i_sb, block); + if (!bh) + goto out_badread; + + offset = ei->i_iget5_offset; + + de = (struct iso_directory_record *) (bh->b_data + offset); + de_len = *(unsigned char *) de; + + if (offset + de_len > bufsize) { + int frag1 = bufsize - offset; + + tmpde = kmalloc(de_len, GFP_KERNEL); + if (tmpde == NULL) { + printk(KERN_INFO ""%s: out of memory\n"", __func__); + ret = -ENOMEM; + goto fail; + } + memcpy(tmpde, bh->b_data + offset, frag1); + brelse(bh); + bh = sb_bread(inode->i_sb, ++block); + if (!bh) + goto out_badread; + memcpy((char *)tmpde+frag1, bh->b_data, de_len - frag1); + de = tmpde; + } + + inode->i_ino = isofs_get_ino(ei->i_iget5_block, + ei->i_iget5_offset, + ISOFS_BUFFER_BITS(inode)); + + /* Assume it is a normal-format file unless told otherwise */ + ei->i_file_format = isofs_file_normal; + + if (de->flags[-high_sierra] & 2) { + if (sbi->s_dmode != ISOFS_INVALID_MODE) + inode->i_mode = S_IFDIR | sbi->s_dmode; + else + inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; + set_nlink(inode, 1); /* + * Set to 1. We know there are 2, but + * the find utility tries to optimize + * if it is 2, and it screws up. It is + * easier to give 1 which tells find to + * do it the hard way. + */ + } else { + if (sbi->s_fmode != ISOFS_INVALID_MODE) { + inode->i_mode = S_IFREG | sbi->s_fmode; + } else { + /* + * Set default permissions: r-x for all. The disc + * could be shared with DOS machines so virtually + * anything could be a valid executable. + */ + inode->i_mode = S_IFREG | S_IRUGO | S_IXUGO; + } + set_nlink(inode, 1); + } + inode->i_uid = sbi->s_uid; + inode->i_gid = sbi->s_gid; + inode->i_blocks = 0; + + ei->i_format_parm[0] = 0; + ei->i_format_parm[1] = 0; + ei->i_format_parm[2] = 0; + + ei->i_section_size = isonum_733(de->size); + if (de->flags[-high_sierra] & 0x80) { + ret = isofs_read_level3_size(inode); + if (ret < 0) + goto fail; + ret = -EIO; + } else { + ei->i_next_section_block = 0; + ei->i_next_section_offset = 0; + inode->i_size = isonum_733(de->size); + } + + /* + * Some dipshit decided to store some other bit of information + * in the high byte of the file length. Truncate size in case + * this CDROM was mounted with the cruft option. + */ + + if (sbi->s_cruft) + inode->i_size &= 0x00ffffff; + + if (de->interleave[0]) { + printk(KERN_DEBUG ""ISOFS: Interleaved files not (yet) supported.\n""); + inode->i_size = 0; + } + + /* I have no idea what file_unit_size is used for, so + we will flag it for now */ + if (de->file_unit_size[0] != 0) { + printk(KERN_DEBUG ""ISOFS: File unit size != 0 for ISO file (%ld).\n"", + inode->i_ino); + } + + /* I have no idea what other flag bits are used for, so + we will flag it for now */ +#ifdef DEBUG + if((de->flags[-high_sierra] & ~2)!= 0){ + printk(KERN_DEBUG ""ISOFS: Unusual flag settings for ISO file "" + ""(%ld %x).\n"", + inode->i_ino, de->flags[-high_sierra]); + } +#endif + + inode->i_mtime.tv_sec = + inode->i_atime.tv_sec = + inode->i_ctime.tv_sec = iso_date(de->date, high_sierra); + inode->i_mtime.tv_nsec = + inode->i_atime.tv_nsec = + inode->i_ctime.tv_nsec = 0; + + ei->i_first_extent = (isonum_733(de->extent) + + isonum_711(de->ext_attr_length)); + + /* Set the number of blocks for stat() - should be done before RR */ + inode->i_blocks = (inode->i_size + 511) >> 9; + + /* + * Now test for possible Rock Ridge extensions which will override + * some of these numbers in the inode structure. + */ + + if (!high_sierra) { + parse_rock_ridge_inode(de, inode); + /* if we want uid/gid set, override the rock ridge setting */ + if (sbi->s_uid_set) + inode->i_uid = sbi->s_uid; + if (sbi->s_gid_set) + inode->i_gid = sbi->s_gid; + } + /* Now set final access rights if overriding rock ridge setting */ + if (S_ISDIR(inode->i_mode) && sbi->s_overriderockperm && + sbi->s_dmode != ISOFS_INVALID_MODE) + inode->i_mode = S_IFDIR | sbi->s_dmode; + if (S_ISREG(inode->i_mode) && sbi->s_overriderockperm && + sbi->s_fmode != ISOFS_INVALID_MODE) + inode->i_mode = S_IFREG | sbi->s_fmode; + + /* Install the inode operations vector */ + if (S_ISREG(inode->i_mode)) { + inode->i_fop = &generic_ro_fops; + switch (ei->i_file_format) { +#ifdef CONFIG_ZISOFS + case isofs_file_compressed: + inode->i_data.a_ops = &zisofs_aops; + break; +#endif + default: + inode->i_data.a_ops = &isofs_aops; + break; + } + } else if (S_ISDIR(inode->i_mode)) { + inode->i_op = &isofs_dir_inode_operations; + inode->i_fop = &isofs_dir_operations; + } else if (S_ISLNK(inode->i_mode)) { + inode->i_op = &page_symlink_inode_operations; + inode->i_data.a_ops = &isofs_symlink_aops; + } else + /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ + init_special_inode(inode, inode->i_mode, inode->i_rdev); + + ret = 0; +out: + kfree(tmpde); + if (bh) + brelse(bh); + return ret; + +out_badread: + printk(KERN_WARNING ""ISOFS: unable to read i-node block\n""); +fail: + goto out; +} +",1,"static int isofs_read_inode(struct inode *inode) +static int isofs_read_inode(struct inode *inode, int relocated) + { + struct super_block *sb = inode->i_sb; + struct isofs_sb_info *sbi = ISOFS_SB(sb); + unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); + unsigned long block; + int high_sierra = sbi->s_high_sierra; + struct buffer_head *bh = NULL; + struct iso_directory_record *de; + struct iso_directory_record *tmpde = NULL; + unsigned int de_len; + unsigned long offset; + struct iso_inode_info *ei = ISOFS_I(inode); + int ret = -EIO; + + block = ei->i_iget5_block; + bh = sb_bread(inode->i_sb, block); + if (!bh) + goto out_badread; + + offset = ei->i_iget5_offset; + + de = (struct iso_directory_record *) (bh->b_data + offset); + de_len = *(unsigned char *) de; + + if (offset + de_len > bufsize) { + int frag1 = bufsize - offset; + + tmpde = kmalloc(de_len, GFP_KERNEL); + if (tmpde == NULL) { + printk(KERN_INFO ""%s: out of memory\n"", __func__); + ret = -ENOMEM; + goto fail; + } + memcpy(tmpde, bh->b_data + offset, frag1); + brelse(bh); + bh = sb_bread(inode->i_sb, ++block); + if (!bh) + goto out_badread; + memcpy((char *)tmpde+frag1, bh->b_data, de_len - frag1); + de = tmpde; + } + + inode->i_ino = isofs_get_ino(ei->i_iget5_block, + ei->i_iget5_offset, + ISOFS_BUFFER_BITS(inode)); + + /* Assume it is a normal-format file unless told otherwise */ + ei->i_file_format = isofs_file_normal; + + if (de->flags[-high_sierra] & 2) { + if (sbi->s_dmode != ISOFS_INVALID_MODE) + inode->i_mode = S_IFDIR | sbi->s_dmode; + else + inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; + set_nlink(inode, 1); /* + * Set to 1. We know there are 2, but + * the find utility tries to optimize + * if it is 2, and it screws up. It is + * easier to give 1 which tells find to + * do it the hard way. + */ + } else { + if (sbi->s_fmode != ISOFS_INVALID_MODE) { + inode->i_mode = S_IFREG | sbi->s_fmode; + } else { + /* + * Set default permissions: r-x for all. The disc + * could be shared with DOS machines so virtually + * anything could be a valid executable. + */ + inode->i_mode = S_IFREG | S_IRUGO | S_IXUGO; + } + set_nlink(inode, 1); + } + inode->i_uid = sbi->s_uid; + inode->i_gid = sbi->s_gid; + inode->i_blocks = 0; + + ei->i_format_parm[0] = 0; + ei->i_format_parm[1] = 0; + ei->i_format_parm[2] = 0; + + ei->i_section_size = isonum_733(de->size); + if (de->flags[-high_sierra] & 0x80) { + ret = isofs_read_level3_size(inode); + if (ret < 0) + goto fail; + ret = -EIO; + } else { + ei->i_next_section_block = 0; + ei->i_next_section_offset = 0; + inode->i_size = isonum_733(de->size); + } + + /* + * Some dipshit decided to store some other bit of information + * in the high byte of the file length. Truncate size in case + * this CDROM was mounted with the cruft option. + */ + + if (sbi->s_cruft) + inode->i_size &= 0x00ffffff; + + if (de->interleave[0]) { + printk(KERN_DEBUG ""ISOFS: Interleaved files not (yet) supported.\n""); + inode->i_size = 0; + } + + /* I have no idea what file_unit_size is used for, so + we will flag it for now */ + if (de->file_unit_size[0] != 0) { + printk(KERN_DEBUG ""ISOFS: File unit size != 0 for ISO file (%ld).\n"", + inode->i_ino); + } + + /* I have no idea what other flag bits are used for, so + we will flag it for now */ +#ifdef DEBUG + if((de->flags[-high_sierra] & ~2)!= 0){ + printk(KERN_DEBUG ""ISOFS: Unusual flag settings for ISO file "" + ""(%ld %x).\n"", + inode->i_ino, de->flags[-high_sierra]); + } +#endif + + inode->i_mtime.tv_sec = + inode->i_atime.tv_sec = + inode->i_ctime.tv_sec = iso_date(de->date, high_sierra); + inode->i_mtime.tv_nsec = + inode->i_atime.tv_nsec = + inode->i_ctime.tv_nsec = 0; + + ei->i_first_extent = (isonum_733(de->extent) + + isonum_711(de->ext_attr_length)); + + /* Set the number of blocks for stat() - should be done before RR */ + inode->i_blocks = (inode->i_size + 511) >> 9; + + /* + * Now test for possible Rock Ridge extensions which will override + * some of these numbers in the inode structure. + */ + + if (!high_sierra) { + parse_rock_ridge_inode(de, inode, relocated); + /* if we want uid/gid set, override the rock ridge setting */ + if (sbi->s_uid_set) + inode->i_uid = sbi->s_uid; + if (sbi->s_gid_set) + inode->i_gid = sbi->s_gid; + } + /* Now set final access rights if overriding rock ridge setting */ + if (S_ISDIR(inode->i_mode) && sbi->s_overriderockperm && + sbi->s_dmode != ISOFS_INVALID_MODE) + inode->i_mode = S_IFDIR | sbi->s_dmode; + if (S_ISREG(inode->i_mode) && sbi->s_overriderockperm && + sbi->s_fmode != ISOFS_INVALID_MODE) + inode->i_mode = S_IFREG | sbi->s_fmode; + + /* Install the inode operations vector */ + if (S_ISREG(inode->i_mode)) { + inode->i_fop = &generic_ro_fops; + switch (ei->i_file_format) { +#ifdef CONFIG_ZISOFS + case isofs_file_compressed: + inode->i_data.a_ops = &zisofs_aops; + break; +#endif + default: + inode->i_data.a_ops = &isofs_aops; + break; + } + } else if (S_ISDIR(inode->i_mode)) { + inode->i_op = &isofs_dir_inode_operations; + inode->i_fop = &isofs_dir_operations; + } else if (S_ISLNK(inode->i_mode)) { + inode->i_op = &page_symlink_inode_operations; + inode->i_data.a_ops = &isofs_symlink_aops; + } else + /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ + init_special_inode(inode, inode->i_mode, inode->i_rdev); + + ret = 0; +out: + kfree(tmpde); + if (bh) + brelse(bh); + return ret; + +out_badread: + printk(KERN_WARNING ""ISOFS: unable to read i-node block\n""); +fail: + goto out; +} +","@@ -61,7 +61,7 @@ static void isofs_put_super(struct super_block *sb) + return; + } + +-static int isofs_read_inode(struct inode *); ++static int isofs_read_inode(struct inode *, int relocated); + static int isofs_statfs (struct dentry *, struct kstatfs *); + + static struct kmem_cache *isofs_inode_cachep; +@@ -1259,7 +1259,7 @@ static int isofs_read_level3_size(struct inode *inode) + goto out; + } + +-static int isofs_read_inode(struct inode *inode) ++static int isofs_read_inode(struct inode *inode, int relocated) + { + struct super_block *sb = inode->i_sb; + struct isofs_sb_info *sbi = ISOFS_SB(sb); +@@ -1404,7 +1404,7 @@ static int isofs_read_inode(struct inode *inode) + */ + + if (!high_sierra) { +- parse_rock_ridge_inode(de, inode); ++ parse_rock_ridge_inode(de, inode, relocated); + /* if we want uid/gid set, override the rock ridge setting */ + if (sbi->s_uid_set) + inode->i_uid = sbi->s_uid; +@@ -1483,9 +1483,10 @@ static int isofs_iget5_set(struct inode *ino, void *data) + * offset that point to the underlying meta-data for the inode. The + * code below is otherwise similar to the iget() code in + * include/linux/fs.h */ +-struct inode *isofs_iget(struct super_block *sb, +- unsigned long block, +- unsigned long offset) ++struct inode *__isofs_iget(struct super_block *sb, ++ unsigned long block, ++ unsigned long offset, ++ int relocated) + { + unsigned long hashval; + struct inode *inode; +@@ -1507,7 +1508,7 @@ struct inode *isofs_iget(struct super_block *sb, + return ERR_PTR(-ENOMEM); + + if (inode->i_state & I_NEW) { +- ret = isofs_read_inode(inode); ++ ret = isofs_read_inode(inode, relocated); + if (ret < 0) { + iget_failed(inode); + inode = ERR_PTR(ret);",1778,2014,2048 +7931,"png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_const_charp errmsg = NULL; + png_bytep buffer; + png_uint_32 prefix_length; + + png_debug(1, ""in png_handle_iTXt""); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, ""no space in chunk cache""); + return; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, ""missing IHDR""); + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + + buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); + + if (buffer == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, ""out of memory""); + return; + } + + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* First the keyword. */ + for (prefix_length=0; + prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* Perform a basic check on the keyword length here. */ + if (prefix_length > 79 || prefix_length < 1) + errmsg = ""bad keyword""; + + /* Expect keyword, compression flag, compression type, language, translated + * keyword (both may be empty but are 0 terminated) then the text, which may + * be empty. + */ + else if (prefix_length + 5 > length) + errmsg = ""truncated""; + + else if (buffer[prefix_length+1] == 0 || + (buffer[prefix_length+1] == 1 && + buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE)) + { + int compressed = buffer[prefix_length+1] != 0; + png_uint_32 language_offset, translated_keyword_offset; + png_alloc_size_t uncompressed_length = 0; + + /* Now the language tag */ + prefix_length += 3; + language_offset = prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* WARNING: the length may be invalid here, this is checked below. */ + translated_keyword_offset = ++prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* prefix_length should now be at the trailing '\0' of the translated + * keyword, but it may already be over the end. None of this arithmetic + * can overflow because chunks are at most 2^31 bytes long, but on 16-bit + * systems the available allocation may overflow. + */ + ++prefix_length; + + if (compressed == 0 && prefix_length <= length) + uncompressed_length = length - prefix_length; + + else if (compressed != 0 && prefix_length < length) + { + uncompressed_length = PNG_SIZE_MAX; + + /* TODO: at present png_decompress_chunk imposes a single application + * level memory limit, this should be split to different values for + * iCCP and text chunks. + */ + if (png_decompress_chunk(png_ptr, length, prefix_length, + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + buffer = png_ptr->read_buffer; + + else + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = ""truncated""; + + if (errmsg == NULL) + { + png_text text; + + buffer[uncompressed_length+prefix_length] = 0; + + if (compressed == 0) + text.compression = PNG_ITXT_COMPRESSION_NONE; + + else + text.compression = PNG_ITXT_COMPRESSION_zTXt; + + text.key = (png_charp)buffer; + text.lang = (png_charp)buffer + language_offset; + text.lang_key = (png_charp)buffer + translated_keyword_offset; + text.text = (png_charp)buffer + prefix_length; + text.text_length = 0; + text.itxt_length = uncompressed_length; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) + errmsg = ""insufficient memory""; + } + } + + else + errmsg = ""bad compression info""; + + if (errmsg != NULL) + png_chunk_benign_error(png_ptr, errmsg); +} +",0,"png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_const_charp errmsg = NULL; + png_bytep buffer; + png_uint_32 prefix_length; + + png_debug(1, ""in png_handle_iTXt""); + +#ifdef PNG_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + + if (--png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, ""no space in chunk cache""); + return; + } + } +#endif + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, ""missing IHDR""); + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + + buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); + + if (buffer == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, ""out of memory""); + return; + } + + png_crc_read(png_ptr, buffer, length); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* First the keyword. */ + for (prefix_length=0; + prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* Perform a basic check on the keyword length here. */ + if (prefix_length > 79 || prefix_length < 1) + errmsg = ""bad keyword""; + + /* Expect keyword, compression flag, compression type, language, translated + * keyword (both may be empty but are 0 terminated) then the text, which may + * be empty. + */ + else if (prefix_length + 5 > length) + errmsg = ""truncated""; + + else if (buffer[prefix_length+1] == 0 || + (buffer[prefix_length+1] == 1 && + buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE)) + { + int compressed = buffer[prefix_length+1] != 0; + png_uint_32 language_offset, translated_keyword_offset; + png_alloc_size_t uncompressed_length = 0; + + /* Now the language tag */ + prefix_length += 3; + language_offset = prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* WARNING: the length may be invalid here, this is checked below. */ + translated_keyword_offset = ++prefix_length; + + for (; prefix_length < length && buffer[prefix_length] != 0; + ++prefix_length) + /* Empty loop */ ; + + /* prefix_length should now be at the trailing '\0' of the translated + * keyword, but it may already be over the end. None of this arithmetic + * can overflow because chunks are at most 2^31 bytes long, but on 16-bit + * systems the available allocation may overflow. + */ + ++prefix_length; + + if (compressed == 0 && prefix_length <= length) + uncompressed_length = length - prefix_length; + + else if (compressed != 0 && prefix_length < length) + { + uncompressed_length = PNG_SIZE_MAX; + + /* TODO: at present png_decompress_chunk imposes a single application + * level memory limit, this should be split to different values for + * iCCP and text chunks. + */ + if (png_decompress_chunk(png_ptr, length, prefix_length, + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + buffer = png_ptr->read_buffer; + + else + errmsg = png_ptr->zstream.msg; + } + + else + errmsg = ""truncated""; + + if (errmsg == NULL) + { + png_text text; + + buffer[uncompressed_length+prefix_length] = 0; + + if (compressed == 0) + text.compression = PNG_ITXT_COMPRESSION_NONE; + + else + text.compression = PNG_ITXT_COMPRESSION_zTXt; + + text.key = (png_charp)buffer; + text.lang = (png_charp)buffer + language_offset; + text.lang_key = (png_charp)buffer + translated_keyword_offset; + text.text = (png_charp)buffer + prefix_length; + text.text_length = 0; + text.itxt_length = uncompressed_length; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) + errmsg = ""insufficient memory""; + } + } + + else + errmsg = ""bad compression info""; + + if (errmsg != NULL) + png_chunk_benign_error(png_ptr, errmsg); +} +","@@ -3167,10 +3167,13 @@ png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) + { + png_alloc_size_t idat_limit = PNG_UINT_31_MAX; + size_t row_factor = +- (png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) +- + 1 + (png_ptr->interlaced? 6: 0)); ++ (size_t)png_ptr->width ++ * (size_t)png_ptr->channels ++ * (png_ptr->bit_depth > 8? 2: 1) ++ + 1 ++ + (png_ptr->interlaced? 6: 0); + if (png_ptr->height > PNG_UINT_32_MAX/row_factor) +- idat_limit=PNG_UINT_31_MAX; ++ idat_limit = PNG_UINT_31_MAX; + else + idat_limit = png_ptr->height * row_factor; + row_factor = row_factor > 32566? 32566 : row_factor;",1070,1306,2048 +3651,"xfs_da3_blk_link( + struct xfs_da_state *state, + struct xfs_da_state_blk *old_blk, + struct xfs_da_state_blk *new_blk) +{ + struct xfs_da_blkinfo *old_info; + struct xfs_da_blkinfo *new_info; + struct xfs_da_blkinfo *tmp_info; + struct xfs_da_args *args; + struct xfs_buf *bp; + int before = 0; + int error; + struct xfs_inode *dp = state->args->dp; + + /* + * Set up environment. + */ + args = state->args; + ASSERT(args != NULL); + old_info = old_blk->bp->b_addr; + new_info = new_blk->bp->b_addr; + ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || + old_blk->magic == XFS_DIR2_LEAFN_MAGIC || + old_blk->magic == XFS_ATTR_LEAF_MAGIC); + + switch (old_blk->magic) { + case XFS_ATTR_LEAF_MAGIC: + before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); + break; + case XFS_DIR2_LEAFN_MAGIC: + before = xfs_dir2_leafn_order(dp, old_blk->bp, new_blk->bp); + break; + case XFS_DA_NODE_MAGIC: + before = xfs_da3_node_order(dp, old_blk->bp, new_blk->bp); + break; + } + + /* + * Link blocks in appropriate order. + */ + if (before) { + /* + * Link new block in before existing block. + */ + trace_xfs_da_link_before(args); + new_info->forw = cpu_to_be32(old_blk->blkno); + new_info->back = old_info->back; + if (old_info->back) { + error = xfs_da3_node_read(args->trans, dp, + be32_to_cpu(old_info->back), + -1, &bp, args->whichfork); + if (error) + return(error); + ASSERT(bp != NULL); + tmp_info = bp->b_addr; + ASSERT(tmp_info->magic == old_info->magic); + ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno); + tmp_info->forw = cpu_to_be32(new_blk->blkno); + xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); + } + old_info->back = cpu_to_be32(new_blk->blkno); + } else { + /* + * Link new block in after existing block. + */ + trace_xfs_da_link_after(args); + new_info->forw = old_info->forw; + new_info->back = cpu_to_be32(old_blk->blkno); + if (old_info->forw) { + error = xfs_da3_node_read(args->trans, dp, + be32_to_cpu(old_info->forw), + -1, &bp, args->whichfork); + if (error) + return(error); + ASSERT(bp != NULL); + tmp_info = bp->b_addr; + ASSERT(tmp_info->magic == old_info->magic); + ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno); + tmp_info->back = cpu_to_be32(new_blk->blkno); + xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); + } + old_info->forw = cpu_to_be32(new_blk->blkno); + } + + xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); + xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1); + return(0); +} +",0,"xfs_da3_blk_link( + struct xfs_da_state *state, + struct xfs_da_state_blk *old_blk, + struct xfs_da_state_blk *new_blk) +{ + struct xfs_da_blkinfo *old_info; + struct xfs_da_blkinfo *new_info; + struct xfs_da_blkinfo *tmp_info; + struct xfs_da_args *args; + struct xfs_buf *bp; + int before = 0; + int error; + struct xfs_inode *dp = state->args->dp; + + /* + * Set up environment. + */ + args = state->args; + ASSERT(args != NULL); + old_info = old_blk->bp->b_addr; + new_info = new_blk->bp->b_addr; + ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || + old_blk->magic == XFS_DIR2_LEAFN_MAGIC || + old_blk->magic == XFS_ATTR_LEAF_MAGIC); + + switch (old_blk->magic) { + case XFS_ATTR_LEAF_MAGIC: + before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); + break; + case XFS_DIR2_LEAFN_MAGIC: + before = xfs_dir2_leafn_order(dp, old_blk->bp, new_blk->bp); + break; + case XFS_DA_NODE_MAGIC: + before = xfs_da3_node_order(dp, old_blk->bp, new_blk->bp); + break; + } + + /* + * Link blocks in appropriate order. + */ + if (before) { + /* + * Link new block in before existing block. + */ + trace_xfs_da_link_before(args); + new_info->forw = cpu_to_be32(old_blk->blkno); + new_info->back = old_info->back; + if (old_info->back) { + error = xfs_da3_node_read(args->trans, dp, + be32_to_cpu(old_info->back), + -1, &bp, args->whichfork); + if (error) + return(error); + ASSERT(bp != NULL); + tmp_info = bp->b_addr; + ASSERT(tmp_info->magic == old_info->magic); + ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno); + tmp_info->forw = cpu_to_be32(new_blk->blkno); + xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); + } + old_info->back = cpu_to_be32(new_blk->blkno); + } else { + /* + * Link new block in after existing block. + */ + trace_xfs_da_link_after(args); + new_info->forw = old_info->forw; + new_info->back = cpu_to_be32(old_blk->blkno); + if (old_info->forw) { + error = xfs_da3_node_read(args->trans, dp, + be32_to_cpu(old_info->forw), + -1, &bp, args->whichfork); + if (error) + return(error); + ASSERT(bp != NULL); + tmp_info = bp->b_addr; + ASSERT(tmp_info->magic == old_info->magic); + ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno); + tmp_info->back = cpu_to_be32(new_blk->blkno); + xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); + } + old_info->forw = cpu_to_be32(new_blk->blkno); + } + + xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); + xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1); + return(0); +} +","@@ -1295,7 +1295,7 @@ xfs_da3_fixhashpath( + node = blk->bp->b_addr; + dp->d_ops->node_hdr_from_disk(&nodehdr, node); + btree = dp->d_ops->node_tree_p(node); +- if (be32_to_cpu(btree->hashval) == lasthash) ++ if (be32_to_cpu(btree[blk->index].hashval) == lasthash) + break; + blk->hashval = lasthash; + btree[blk->index].hashval = cpu_to_be32(lasthash);",819,1055,2048 +6750,"MODRET auth_user(cmd_rec *cmd) { + int nopass = FALSE; + config_rec *c; + const char *denymsg = NULL, *user, *origuser; + int failnopwprompt = 0, aclp, i; + unsigned char *anon_require_passwd = NULL, *login_passwd_prompt = NULL; + + if (cmd->argc < 2) { + return PR_ERROR_MSG(cmd, R_500, _(""USER: command requires a parameter"")); + } + + if (logged_in) { + /* If the client has already authenticated, BUT the given USER command + * here is for the exact same user name, then allow the command to + * succeed (Bug#4217). + */ + origuser = pr_table_get(session.notes, ""mod_auth.orig-user"", NULL); + if (origuser != NULL && + strcmp(origuser, cmd->arg) == 0) { + pr_response_add(R_230, _(""User %s logged in""), origuser); + return PR_HANDLED(cmd); + } + + pr_response_add_err(R_501, ""%s"", _(""Reauthentication not supported"")); + return PR_ERROR(cmd); + } + + user = cmd->arg; + + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + if (pr_table_add_dup(session.notes, ""mod_auth.orig-user"", user, 0) < 0) { + pr_log_debug(DEBUG3, ""error stashing 'mod_auth.orig-user' in "" + ""session.notes: %s"", strerror(errno)); + } + + origuser = user; + c = pr_auth_get_anon_config(cmd->tmp_pool, &user, NULL, NULL); + + /* Check for AccessDenyMsg */ + denymsg = get_param_ptr((c ? c->subset : cmd->server->conf), ""AccessDenyMsg"", + FALSE); + if (denymsg != NULL) { + if (strstr(denymsg, ""%u"") != NULL) { + denymsg = sreplace(cmd->tmp_pool, denymsg, ""%u"", user, NULL); + } + } + + login_passwd_prompt = get_param_ptr( + (c && c->config_type == CONF_ANON) ? c->subset : main_server->conf, + ""LoginPasswordPrompt"", FALSE); + + if (login_passwd_prompt && + *login_passwd_prompt == FALSE) { + failnopwprompt = TRUE; + + } else { + failnopwprompt = FALSE; + } + + if (failnopwprompt) { + if (!user) { + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + pr_log_pri(PR_LOG_NOTICE, ""USER %s (Login failed): Not a UserAlias"", + origuser); + + if (denymsg) { + pr_response_send(R_530, ""%s"", denymsg); + + } else { + pr_response_send(R_530, _(""Login incorrect."")); + } + + pr_session_end(0); + } + + aclp = login_check_limits(main_server->conf, FALSE, TRUE, &i); + + if (c && c->config_type != CONF_ANON) { + c = (config_rec *) pcalloc(session.pool, sizeof(config_rec)); + c->config_type = CONF_ANON; + c->name = """"; /* don't really need this yet */ + c->subset = main_server->conf; + } + + if (c) { + if (!login_check_limits(c->subset, FALSE, TRUE, &i) || + (!aclp && !i) ) { + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + pr_log_auth(PR_LOG_NOTICE, ""ANON %s: Limit access denies login"", + origuser); + + if (denymsg) { + pr_response_send(R_530, ""%s"", denymsg); + + } else { + pr_response_send(R_530, _(""Login incorrect."")); + } + + pr_session_disconnect(&auth_module, PR_SESS_DISCONNECT_CONFIG_ACL, + ""Denied by ""); + } + } + + if (c == NULL && + aclp == 0) { + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + pr_log_auth(PR_LOG_NOTICE, + ""USER %s: Limit access denies login"", origuser); + + if (denymsg) { + pr_response_send(R_530, ""%s"", denymsg); + + } else { + pr_response_send(R_530, ""%s"", _(""Login incorrect."")); + } + + pr_session_disconnect(&auth_module, PR_SESS_DISCONNECT_CONFIG_ACL, + ""Denied by ""); + } + } + + if (c) + anon_require_passwd = get_param_ptr(c->subset, ""AnonRequirePassword"", + FALSE); + + if (c && user && (!anon_require_passwd || *anon_require_passwd == FALSE)) + nopass = TRUE; + + session.gids = NULL; + session.groups = NULL; + session.user = NULL; + session.group = NULL; + + if (nopass) { + pr_response_add(R_331, _(""Anonymous login ok, send your complete email "" + ""address as your password"")); + + } else if (pr_auth_requires_pass(cmd->tmp_pool, user) == FALSE) { + /* Check to see if a password from the client is required. In the + * vast majority of cases, a password will be required. + */ + + /* Act as if we received a PASS command from the client. */ + cmd_rec *fakecmd = pr_cmd_alloc(cmd->pool, 2, NULL); + + /* We use pstrdup() here, rather than assigning C_PASS directly, since + * code elsewhere will attempt to modify this buffer, and C_PASS is + * a string literal. + */ + fakecmd->argv[0] = pstrdup(fakecmd->pool, C_PASS); + fakecmd->argv[1] = NULL; + fakecmd->arg = NULL; + + c = add_config_param_set(&cmd->server->conf, ""authenticated"", 1, NULL); + c->argv[0] = pcalloc(c->pool, sizeof(unsigned char)); + *((unsigned char *) c->argv[0]) = TRUE; + + authenticated_without_pass = TRUE; + pr_log_auth(PR_LOG_NOTICE, ""USER %s: Authenticated without password"", user); + + pr_cmd_dispatch(fakecmd); + + } else { + pr_response_add(R_331, _(""Password required for %s""), + (char *) cmd->argv[1]); + } + + return PR_HANDLED(cmd); +} +",0,"MODRET auth_user(cmd_rec *cmd) { + int nopass = FALSE; + config_rec *c; + const char *denymsg = NULL, *user, *origuser; + int failnopwprompt = 0, aclp, i; + unsigned char *anon_require_passwd = NULL, *login_passwd_prompt = NULL; + + if (cmd->argc < 2) { + return PR_ERROR_MSG(cmd, R_500, _(""USER: command requires a parameter"")); + } + + if (logged_in) { + /* If the client has already authenticated, BUT the given USER command + * here is for the exact same user name, then allow the command to + * succeed (Bug#4217). + */ + origuser = pr_table_get(session.notes, ""mod_auth.orig-user"", NULL); + if (origuser != NULL && + strcmp(origuser, cmd->arg) == 0) { + pr_response_add(R_230, _(""User %s logged in""), origuser); + return PR_HANDLED(cmd); + } + + pr_response_add_err(R_501, ""%s"", _(""Reauthentication not supported"")); + return PR_ERROR(cmd); + } + + user = cmd->arg; + + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + if (pr_table_add_dup(session.notes, ""mod_auth.orig-user"", user, 0) < 0) { + pr_log_debug(DEBUG3, ""error stashing 'mod_auth.orig-user' in "" + ""session.notes: %s"", strerror(errno)); + } + + origuser = user; + c = pr_auth_get_anon_config(cmd->tmp_pool, &user, NULL, NULL); + + /* Check for AccessDenyMsg */ + denymsg = get_param_ptr((c ? c->subset : cmd->server->conf), ""AccessDenyMsg"", + FALSE); + if (denymsg != NULL) { + if (strstr(denymsg, ""%u"") != NULL) { + denymsg = sreplace(cmd->tmp_pool, denymsg, ""%u"", user, NULL); + } + } + + login_passwd_prompt = get_param_ptr( + (c && c->config_type == CONF_ANON) ? c->subset : main_server->conf, + ""LoginPasswordPrompt"", FALSE); + + if (login_passwd_prompt && + *login_passwd_prompt == FALSE) { + failnopwprompt = TRUE; + + } else { + failnopwprompt = FALSE; + } + + if (failnopwprompt) { + if (!user) { + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + pr_log_pri(PR_LOG_NOTICE, ""USER %s (Login failed): Not a UserAlias"", + origuser); + + if (denymsg) { + pr_response_send(R_530, ""%s"", denymsg); + + } else { + pr_response_send(R_530, _(""Login incorrect."")); + } + + pr_session_end(0); + } + + aclp = login_check_limits(main_server->conf, FALSE, TRUE, &i); + + if (c && c->config_type != CONF_ANON) { + c = (config_rec *) pcalloc(session.pool, sizeof(config_rec)); + c->config_type = CONF_ANON; + c->name = """"; /* don't really need this yet */ + c->subset = main_server->conf; + } + + if (c) { + if (!login_check_limits(c->subset, FALSE, TRUE, &i) || + (!aclp && !i) ) { + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + pr_log_auth(PR_LOG_NOTICE, ""ANON %s: Limit access denies login"", + origuser); + + if (denymsg) { + pr_response_send(R_530, ""%s"", denymsg); + + } else { + pr_response_send(R_530, _(""Login incorrect."")); + } + + pr_session_disconnect(&auth_module, PR_SESS_DISCONNECT_CONFIG_ACL, + ""Denied by ""); + } + } + + if (c == NULL && + aclp == 0) { + (void) pr_table_remove(session.notes, ""mod_auth.orig-user"", NULL); + (void) pr_table_remove(session.notes, ""mod_auth.anon-passwd"", NULL); + + pr_log_auth(PR_LOG_NOTICE, + ""USER %s: Limit access denies login"", origuser); + + if (denymsg) { + pr_response_send(R_530, ""%s"", denymsg); + + } else { + pr_response_send(R_530, ""%s"", _(""Login incorrect."")); + } + + pr_session_disconnect(&auth_module, PR_SESS_DISCONNECT_CONFIG_ACL, + ""Denied by ""); + } + } + + if (c) + anon_require_passwd = get_param_ptr(c->subset, ""AnonRequirePassword"", + FALSE); + + if (c && user && (!anon_require_passwd || *anon_require_passwd == FALSE)) + nopass = TRUE; + + session.gids = NULL; + session.groups = NULL; + session.user = NULL; + session.group = NULL; + + if (nopass) { + pr_response_add(R_331, _(""Anonymous login ok, send your complete email "" + ""address as your password"")); + + } else if (pr_auth_requires_pass(cmd->tmp_pool, user) == FALSE) { + /* Check to see if a password from the client is required. In the + * vast majority of cases, a password will be required. + */ + + /* Act as if we received a PASS command from the client. */ + cmd_rec *fakecmd = pr_cmd_alloc(cmd->pool, 2, NULL); + + /* We use pstrdup() here, rather than assigning C_PASS directly, since + * code elsewhere will attempt to modify this buffer, and C_PASS is + * a string literal. + */ + fakecmd->argv[0] = pstrdup(fakecmd->pool, C_PASS); + fakecmd->argv[1] = NULL; + fakecmd->arg = NULL; + + c = add_config_param_set(&cmd->server->conf, ""authenticated"", 1, NULL); + c->argv[0] = pcalloc(c->pool, sizeof(unsigned char)); + *((unsigned char *) c->argv[0]) = TRUE; + + authenticated_without_pass = TRUE; + pr_log_auth(PR_LOG_NOTICE, ""USER %s: Authenticated without password"", user); + + pr_cmd_dispatch(fakecmd); + + } else { + pr_response_add(R_331, _(""Password required for %s""), + (char *) cmd->argv[1]); + } + + return PR_HANDLED(cmd); +} +","@@ -804,6 +804,59 @@ static const char *get_default_chdir(pool *p, xaset_t *conf) { + return dir; + } + ++static int is_symlink_path(pool *p, const char *path, size_t pathlen) { ++ int res, xerrno = 0; ++ struct stat st; ++ char *ptr; ++ ++ if (pathlen == 0) { ++ return 0; ++ } ++ ++ pr_fs_clear_cache2(path); ++ res = pr_fsio_lstat(path, &st); ++ if (res < 0) { ++ xerrno = errno; ++ ++ pr_log_pri(PR_LOG_WARNING, ""error: unable to check %s: %s"", path, ++ strerror(xerrno)); ++ ++ errno = xerrno; ++ return -1; ++ } ++ ++ if (S_ISLNK(st.st_mode)) { ++ errno = EPERM; ++ return -1; ++ } ++ ++ /* To handle the case where a component further up the path might be a ++ * symlink (which lstat(2) will NOT handle), we walk the path backwards, ++ * calling ourselves recursively. ++ */ ++ ++ ptr = strrchr(path, '/'); ++ if (ptr != NULL) { ++ char *new_path; ++ size_t new_pathlen; ++ ++ pr_signals_handle(); ++ ++ new_pathlen = ptr - path; ++ new_path = pstrndup(p, path, new_pathlen); ++ ++ pr_log_debug(DEBUG10, ++ ""AllowChrootSymlink: path '%s' not a symlink, checking '%s'"", path, ++ new_path); ++ res = is_symlink_path(p, new_path, new_pathlen); ++ if (res < 0) { ++ return -1; ++ } ++ } ++ ++ return 0; ++} ++ + /* Determine if the user (non-anon) needs a default root dir other than /. */ + static int get_default_root(pool *p, int allow_symlinks, const char **root) { + config_rec *c = NULL; +@@ -847,7 +900,6 @@ static int get_default_root(pool *p, int allow_symlinks, const char **root) { + + if (allow_symlinks == FALSE) { + char *path, target_path[PR_TUNABLE_PATH_MAX + 1]; +- struct stat st; + size_t pathlen; + + /* First, deal with any possible interpolation. dir_realpath() will +@@ -878,22 +930,13 @@ static int get_default_root(pool *p, int allow_symlinks, const char **root) { + path[pathlen-1] = '\0'; + } + +- pr_fs_clear_cache2(path); +- res = pr_fsio_lstat(path, &st); ++ res = is_symlink_path(p, path, pathlen); + if (res < 0) { +- xerrno = errno; +- +- pr_log_pri(PR_LOG_WARNING, ""error: unable to check %s: %s"", path, +- strerror(xerrno)); +- +- errno = xerrno; +- return -1; +- } ++ if (errno == EPERM) { ++ pr_log_pri(PR_LOG_WARNING, ""error: DefaultRoot %s is a symlink "" ++ ""(denied by AllowChrootSymlinks config)"", path); ++ } + +- if (S_ISLNK(st.st_mode)) { +- pr_log_pri(PR_LOG_WARNING, +- ""error: DefaultRoot %s is a symlink (denied by AllowChrootSymlinks "" +- ""config)"", path); + errno = EPERM; + return -1; + }",1487,1723,2048 +8183,"JsVar *jsvMakeIntoVariableName(JsVar *var, JsVar *valueOrZero) { + if (!var) return 0; + assert(jsvGetRefs(var)==0); // make sure it's unused + assert(jsvIsSimpleInt(var) || jsvIsString(var)); + JsVarFlags varType = (var->flags & JSV_VARTYPEMASK); + if (varType==JSV_INTEGER) { + int t = JSV_NAME_INT; + if ((jsvIsInt(valueOrZero) || jsvIsBoolean(valueOrZero)) && !jsvIsPin(valueOrZero)) { + JsVarInt v = valueOrZero->varData.integer; + if (v>=JSVARREF_MIN && v<=JSVARREF_MAX) { + t = jsvIsInt(valueOrZero) ? JSV_NAME_INT_INT : JSV_NAME_INT_BOOL; + jsvSetFirstChild(var, (JsVarRef)v); + valueOrZero = 0; + } + } + var->flags = (JsVarFlags)(var->flags & ~JSV_VARTYPEMASK) | t; + } else if (varType>=_JSV_STRING_START && varType<=_JSV_STRING_END) { + if (jsvGetCharactersInVar(var) > JSVAR_DATA_STRING_NAME_LEN) { + /* Argh. String is too large to fit in a JSV_NAME! We must chomp make + * new STRINGEXTs to put the data in + */ + JsvStringIterator it; + jsvStringIteratorNew(&it, var, JSVAR_DATA_STRING_NAME_LEN); + JsVar *startExt = jsvNewWithFlags(JSV_STRING_EXT_0); + JsVar *ext = jsvLockAgainSafe(startExt); + size_t nChars = 0; + while (ext && jsvStringIteratorHasChar(&it)) { + if (nChars >= JSVAR_DATA_STRING_MAX_LEN) { + jsvSetCharactersInVar(ext, nChars); + JsVar *ext2 = jsvNewWithFlags(JSV_STRING_EXT_0); + if (ext2) { + jsvSetLastChild(ext, jsvGetRef(ext2)); + } + jsvUnLock(ext); + ext = ext2; + nChars = 0; + } + ext->varData.str[nChars++] = jsvStringIteratorGetChar(&it); + jsvStringIteratorNext(&it); + } + jsvStringIteratorFree(&it); + if (ext) { + jsvSetCharactersInVar(ext, nChars); + jsvUnLock(ext); + } + jsvSetCharactersInVar(var, JSVAR_DATA_STRING_NAME_LEN); + JsVarRef oldRef = jsvGetLastChild(var); + while (oldRef) { + JsVar *v = jsvGetAddressOf(oldRef); + oldRef = jsvGetLastChild(v); + jsvFreePtrInternal(v); + } + jsvSetLastChild(var, jsvGetRef(startExt)); + jsvSetNextSibling(var, 0); + jsvSetPrevSibling(var, 0); + jsvSetFirstChild(var, 0); + jsvUnLock(startExt); + } + + size_t t = JSV_NAME_STRING_0; + if (jsvIsInt(valueOrZero) && !jsvIsPin(valueOrZero)) { + JsVarInt v = valueOrZero->varData.integer; + if (v>=JSVARREF_MIN && v<=JSVARREF_MAX) { + t = JSV_NAME_STRING_INT_0; + jsvSetFirstChild(var, (JsVarRef)v); + valueOrZero = 0; + } + } else + jsvSetFirstChild(var, 0); + var->flags = (var->flags & (JsVarFlags)~JSV_VARTYPEMASK) | (t+jsvGetCharactersInVar(var)); + } else assert(0); + + if (valueOrZero) + jsvSetFirstChild(var, jsvGetRef(jsvRef(valueOrZero))); + return var; +} +",0,"JsVar *jsvMakeIntoVariableName(JsVar *var, JsVar *valueOrZero) { + if (!var) return 0; + assert(jsvGetRefs(var)==0); // make sure it's unused + assert(jsvIsSimpleInt(var) || jsvIsString(var)); + JsVarFlags varType = (var->flags & JSV_VARTYPEMASK); + if (varType==JSV_INTEGER) { + int t = JSV_NAME_INT; + if ((jsvIsInt(valueOrZero) || jsvIsBoolean(valueOrZero)) && !jsvIsPin(valueOrZero)) { + JsVarInt v = valueOrZero->varData.integer; + if (v>=JSVARREF_MIN && v<=JSVARREF_MAX) { + t = jsvIsInt(valueOrZero) ? JSV_NAME_INT_INT : JSV_NAME_INT_BOOL; + jsvSetFirstChild(var, (JsVarRef)v); + valueOrZero = 0; + } + } + var->flags = (JsVarFlags)(var->flags & ~JSV_VARTYPEMASK) | t; + } else if (varType>=_JSV_STRING_START && varType<=_JSV_STRING_END) { + if (jsvGetCharactersInVar(var) > JSVAR_DATA_STRING_NAME_LEN) { + /* Argh. String is too large to fit in a JSV_NAME! We must chomp make + * new STRINGEXTs to put the data in + */ + JsvStringIterator it; + jsvStringIteratorNew(&it, var, JSVAR_DATA_STRING_NAME_LEN); + JsVar *startExt = jsvNewWithFlags(JSV_STRING_EXT_0); + JsVar *ext = jsvLockAgainSafe(startExt); + size_t nChars = 0; + while (ext && jsvStringIteratorHasChar(&it)) { + if (nChars >= JSVAR_DATA_STRING_MAX_LEN) { + jsvSetCharactersInVar(ext, nChars); + JsVar *ext2 = jsvNewWithFlags(JSV_STRING_EXT_0); + if (ext2) { + jsvSetLastChild(ext, jsvGetRef(ext2)); + } + jsvUnLock(ext); + ext = ext2; + nChars = 0; + } + ext->varData.str[nChars++] = jsvStringIteratorGetChar(&it); + jsvStringIteratorNext(&it); + } + jsvStringIteratorFree(&it); + if (ext) { + jsvSetCharactersInVar(ext, nChars); + jsvUnLock(ext); + } + jsvSetCharactersInVar(var, JSVAR_DATA_STRING_NAME_LEN); + JsVarRef oldRef = jsvGetLastChild(var); + while (oldRef) { + JsVar *v = jsvGetAddressOf(oldRef); + oldRef = jsvGetLastChild(v); + jsvFreePtrInternal(v); + } + jsvSetLastChild(var, jsvGetRef(startExt)); + jsvSetNextSibling(var, 0); + jsvSetPrevSibling(var, 0); + jsvSetFirstChild(var, 0); + jsvUnLock(startExt); + } + + size_t t = JSV_NAME_STRING_0; + if (jsvIsInt(valueOrZero) && !jsvIsPin(valueOrZero)) { + JsVarInt v = valueOrZero->varData.integer; + if (v>=JSVARREF_MIN && v<=JSVARREF_MAX) { + t = JSV_NAME_STRING_INT_0; + jsvSetFirstChild(var, (JsVarRef)v); + valueOrZero = 0; + } + } else + jsvSetFirstChild(var, 0); + var->flags = (var->flags & (JsVarFlags)~JSV_VARTYPEMASK) | (t+jsvGetCharactersInVar(var)); + } else assert(0); + + if (valueOrZero) + jsvSetFirstChild(var, jsvGetRef(jsvRef(valueOrZero))); + return var; +} +","@@ -1190,7 +1190,7 @@ size_t jsvGetString(const JsVar *v, char *str, size_t len) { + * want to pad the entire buffer with zeros */ + len--; + int l = 0; +- while (*s && l &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + if (mSignalledError || mOutputPortSettingsChange != NONE) { + return; + } + + while (!inQueue.empty() && !outQueue.empty()) { + + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + notifyEmptyBufferDone(inHeader); + continue; + } + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + + outHeader->nFilledLen = 0; + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + + outQueue.erase(outQueue.begin()); + outInfo->mOwnedByUs = false; + notifyFillBufferDone(outHeader); + + return; + } + + if (inHeader->nOffset == 0) { + mAnchorTimeUs = inHeader->nTimeStamp; + mNumSamplesOutput = 0; + } + + const uint8_t *inputPtr = inHeader->pBuffer + inHeader->nOffset; + int32_t numBytesRead; + + if (mMode == MODE_NARROW) { + if (outHeader->nAllocLen < kNumSamplesPerFrameNB * sizeof(int16_t)) { + ALOGE(""b/27662364: NB expected output buffer %zu bytes vs %u"", + kNumSamplesPerFrameNB * sizeof(int16_t), outHeader->nAllocLen); + android_errorWriteLog(0x534e4554, ""27662364""); + notify(OMX_EventError, OMX_ErrorOverflow, 0, NULL); + mSignalledError = true; + return; + } + + int16 mode = ((inputPtr[0] >> 3) & 0x0f); + size_t frameSize = WmfDecBytesPerFrame[mode] + 1; + + if (inHeader->nFilledLen < frameSize) { + ALOGE(""b/27662364: expected %zu bytes vs %u"", frameSize, inHeader->nFilledLen); + notify(OMX_EventError, OMX_ErrorStreamCorrupt, 0, NULL); + mSignalledError = true; + return; + } + + numBytesRead = + AMRDecode(mState, + (Frame_Type_3GPP)((inputPtr[0] >> 3) & 0x0f), + (UWord8 *)&inputPtr[1], + reinterpret_cast(outHeader->pBuffer), + MIME_IETF); + + if (numBytesRead == -1) { + ALOGE(""PV AMR decoder AMRDecode() call failed""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + + return; + } + + ++numBytesRead; // Include the frame type header byte. + + if (static_cast(numBytesRead) > inHeader->nFilledLen) { + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + + return; + } + } else { + if (outHeader->nAllocLen < kNumSamplesPerFrameWB * sizeof(int16_t)) { + ALOGE(""b/27662364: WB expected output buffer %zu bytes vs %u"", + kNumSamplesPerFrameWB * sizeof(int16_t), outHeader->nAllocLen); + android_errorWriteLog(0x534e4554, ""27662364""); + notify(OMX_EventError, OMX_ErrorOverflow, 0, NULL); + mSignalledError = true; + return; + } + + int16 mode = ((inputPtr[0] >> 3) & 0x0f); + + if (mode >= 10 && mode <= 13) { + ALOGE(""encountered illegal frame type %d in AMR WB content."", + mode); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + + return; + } + + size_t frameSize = getFrameSize(mode); + if (inHeader->nFilledLen < frameSize) { + ALOGE(""b/27662364: expected %zu bytes vs %u"", frameSize, inHeader->nFilledLen); + notify(OMX_EventError, OMX_ErrorStreamCorrupt, 0, NULL); + mSignalledError = true; + return; + } + + int16_t *outPtr = (int16_t *)outHeader->pBuffer; + + if (mode >= 9) { + memset(outPtr, 0, kNumSamplesPerFrameWB * sizeof(int16_t)); + } else if (mode < 9) { + int16 frameType; + RX_State_wb rx_state; + mime_unsorting( + const_cast(&inputPtr[1]), + mInputSampleBuffer, + &frameType, &mode, 1, &rx_state); + + int16_t numSamplesOutput; + pvDecoder_AmrWb( + mode, mInputSampleBuffer, + outPtr, + &numSamplesOutput, + mDecoderBuf, frameType, mDecoderCookie); + + CHECK_EQ((int)numSamplesOutput, (int)kNumSamplesPerFrameWB); + + for (int i = 0; i < kNumSamplesPerFrameWB; ++i) { + /* Delete the 2 LSBs (14-bit output) */ + outPtr[i] &= 0xfffC; + } + } + + numBytesRead = frameSize; + } + + inHeader->nOffset += numBytesRead; + inHeader->nFilledLen -= numBytesRead; + + outHeader->nFlags = 0; + outHeader->nOffset = 0; + + if (mMode == MODE_NARROW) { + outHeader->nFilledLen = kNumSamplesPerFrameNB * sizeof(int16_t); + + outHeader->nTimeStamp = + mAnchorTimeUs + + (mNumSamplesOutput * 1000000ll) / kSampleRateNB; + + mNumSamplesOutput += kNumSamplesPerFrameNB; + } else { + outHeader->nFilledLen = kNumSamplesPerFrameWB * sizeof(int16_t); + + outHeader->nTimeStamp = + mAnchorTimeUs + + (mNumSamplesOutput * 1000000ll) / kSampleRateWB; + + mNumSamplesOutput += kNumSamplesPerFrameWB; + } + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + + ++mInputBufferCount; + } +} +",1,"void SoftAMR::onQueueFilled(OMX_U32 /* portIndex */) { + List &inQueue = getPortQueue(0); + List &outQueue = getPortQueue(1); + + if (mSignalledError || mOutputPortSettingsChange != NONE) { + return; + } + + while (!inQueue.empty() && !outQueue.empty()) { + + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + + if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + + outHeader->nFilledLen = 0; + outHeader->nFlags = OMX_BUFFERFLAG_EOS; + + outQueue.erase(outQueue.begin()); + outInfo->mOwnedByUs = false; + notifyFillBufferDone(outHeader); + + return; + } + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + notifyEmptyBufferDone(inHeader); + continue; + } + + if (inHeader->nOffset == 0) { + mAnchorTimeUs = inHeader->nTimeStamp; + mNumSamplesOutput = 0; + } + + const uint8_t *inputPtr = inHeader->pBuffer + inHeader->nOffset; + int32_t numBytesRead; + + if (mMode == MODE_NARROW) { + if (outHeader->nAllocLen < kNumSamplesPerFrameNB * sizeof(int16_t)) { + ALOGE(""b/27662364: NB expected output buffer %zu bytes vs %u"", + kNumSamplesPerFrameNB * sizeof(int16_t), outHeader->nAllocLen); + android_errorWriteLog(0x534e4554, ""27662364""); + notify(OMX_EventError, OMX_ErrorOverflow, 0, NULL); + mSignalledError = true; + return; + } + + int16 mode = ((inputPtr[0] >> 3) & 0x0f); + size_t frameSize = WmfDecBytesPerFrame[mode] + 1; + + if (inHeader->nFilledLen < frameSize) { + ALOGE(""b/27662364: expected %zu bytes vs %u"", frameSize, inHeader->nFilledLen); + notify(OMX_EventError, OMX_ErrorStreamCorrupt, 0, NULL); + mSignalledError = true; + return; + } + + numBytesRead = + AMRDecode(mState, + (Frame_Type_3GPP)((inputPtr[0] >> 3) & 0x0f), + (UWord8 *)&inputPtr[1], + reinterpret_cast(outHeader->pBuffer), + MIME_IETF); + + if (numBytesRead == -1) { + ALOGE(""PV AMR decoder AMRDecode() call failed""); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + + return; + } + + ++numBytesRead; // Include the frame type header byte. + + if (static_cast(numBytesRead) > inHeader->nFilledLen) { + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + + return; + } + } else { + if (outHeader->nAllocLen < kNumSamplesPerFrameWB * sizeof(int16_t)) { + ALOGE(""b/27662364: WB expected output buffer %zu bytes vs %u"", + kNumSamplesPerFrameWB * sizeof(int16_t), outHeader->nAllocLen); + android_errorWriteLog(0x534e4554, ""27662364""); + notify(OMX_EventError, OMX_ErrorOverflow, 0, NULL); + mSignalledError = true; + return; + } + + int16 mode = ((inputPtr[0] >> 3) & 0x0f); + + if (mode >= 10 && mode <= 13) { + ALOGE(""encountered illegal frame type %d in AMR WB content."", + mode); + + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; + + return; + } + + size_t frameSize = getFrameSize(mode); + if (inHeader->nFilledLen < frameSize) { + ALOGE(""b/27662364: expected %zu bytes vs %u"", frameSize, inHeader->nFilledLen); + notify(OMX_EventError, OMX_ErrorStreamCorrupt, 0, NULL); + mSignalledError = true; + return; + } + + int16_t *outPtr = (int16_t *)outHeader->pBuffer; + + if (mode >= 9) { + memset(outPtr, 0, kNumSamplesPerFrameWB * sizeof(int16_t)); + } else if (mode < 9) { + int16 frameType; + RX_State_wb rx_state; + mime_unsorting( + const_cast(&inputPtr[1]), + mInputSampleBuffer, + &frameType, &mode, 1, &rx_state); + + int16_t numSamplesOutput; + pvDecoder_AmrWb( + mode, mInputSampleBuffer, + outPtr, + &numSamplesOutput, + mDecoderBuf, frameType, mDecoderCookie); + + CHECK_EQ((int)numSamplesOutput, (int)kNumSamplesPerFrameWB); + + for (int i = 0; i < kNumSamplesPerFrameWB; ++i) { + /* Delete the 2 LSBs (14-bit output) */ + outPtr[i] &= 0xfffC; + } + } + + numBytesRead = frameSize; + } + + inHeader->nOffset += numBytesRead; + inHeader->nFilledLen -= numBytesRead; + + outHeader->nFlags = 0; + outHeader->nOffset = 0; + + if (mMode == MODE_NARROW) { + outHeader->nFilledLen = kNumSamplesPerFrameNB * sizeof(int16_t); + + outHeader->nTimeStamp = + mAnchorTimeUs + + (mNumSamplesOutput * 1000000ll) / kSampleRateNB; + + mNumSamplesOutput += kNumSamplesPerFrameNB; + } else { + outHeader->nFilledLen = kNumSamplesPerFrameWB * sizeof(int16_t); + + outHeader->nTimeStamp = + mAnchorTimeUs + + (mNumSamplesOutput * 1000000ll) / kSampleRateWB; + + mNumSamplesOutput += kNumSamplesPerFrameWB; + } + + if (inHeader->nFilledLen == 0) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + + ++mInputBufferCount; + } +} +","@@ -286,13 +286,6 @@ + + BufferInfo *inInfo = *inQueue.begin(); + OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; + +- if (inHeader->nFilledLen == 0) { +- inInfo->mOwnedByUs = false; +- inQueue.erase(inQueue.begin()); +- notifyEmptyBufferDone(inHeader); +- continue; +- } +- + BufferInfo *outInfo = *outQueue.begin(); + OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; + +@@ -310,6 +303,13 @@ + + return; + } + ++ if (inHeader->nFilledLen == 0) { ++ inInfo->mOwnedByUs = false; ++ inQueue.erase(inQueue.begin()); ++ notifyEmptyBufferDone(inHeader); ++ continue; ++ } ++ + if (inHeader->nOffset == 0) { + mAnchorTimeUs = inHeader->nTimeStamp; + mNumSamplesOutput = 0; +",1606,1842,2048 +17419,"FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length) +{ + FLAC__uint32 x; + unsigned bits, used_bits = 0; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; + decoder->private_->stream_info.is_last = is_last; + decoder->private_->stream_info.length = length; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.min_blocksize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.max_blocksize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.min_framesize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.max_framesize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.sample_rate = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.channels = x+1; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) + return false; /* read_callback_ sets the state for us */ + used_bits += bits; + + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->stream_info.data.stream_info.md5sum, 16)) + return false; /* read_callback_ sets the state for us */ + used_bits += 16*8; + + /* skip the rest of the block */ + FLAC__ASSERT(used_bits % 8 == 0); + length -= (used_bits / 8); + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) + return false; /* read_callback_ sets the state for us */ + + return true; +} +",0,"FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length) +{ + FLAC__uint32 x; + unsigned bits, used_bits = 0; + + FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); + + decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; + decoder->private_->stream_info.is_last = is_last; + decoder->private_->stream_info.length = length; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.min_blocksize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.max_blocksize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.min_framesize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.max_framesize = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.sample_rate = x; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.channels = x+1; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; + if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)) + return false; /* read_callback_ sets the state for us */ + decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; + used_bits += bits; + + bits = FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; + if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) + return false; /* read_callback_ sets the state for us */ + used_bits += bits; + + if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->stream_info.data.stream_info.md5sum, 16)) + return false; /* read_callback_ sets the state for us */ + used_bits += 16*8; + + /* skip the rest of the block */ + FLAC__ASSERT(used_bits % 8 == 0); + length -= (used_bits / 8); + if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) + return false; /* read_callback_ sets the state for us */ + + return true; +} +","@@ -1739,6 +1739,7 @@ + + if (obj->num_comments > 0) { + if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; ++ obj->num_comments = 0; + return false; + } + for (i = 0; i < obj->num_comments; i++) { +",874,1110,2048 +17811," FT_Bitmap_Convert( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target, + FT_Int alignment ) + { + FT_Error error = FT_Err_Ok; + FT_Memory memory; + + FT_Int source_pitch, target_pitch; + + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + memory = library->memory; + + switch ( source->pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + case FT_PIXEL_MODE_GRAY: + case FT_PIXEL_MODE_GRAY2: + case FT_PIXEL_MODE_GRAY4: + case FT_PIXEL_MODE_LCD: + case FT_PIXEL_MODE_LCD_V: + case FT_PIXEL_MODE_LCD_V: + case FT_PIXEL_MODE_BGRA: + { + FT_Int pad, old_target_pitch; + FT_Long old_size; + + + old_target_pitch = target->pitch; + old_target_pitch = -old_target_pitch; + + old_size = target->rows * old_target_pitch; + + target->pixel_mode = FT_PIXEL_MODE_GRAY; + target->rows = source->rows; + target->width = source->width; + + pad = 0; + if ( alignment > 0 ) + { + pad = source->width % alignment; + if ( pad != 0 ) + pad = alignment - pad; + } + + target_pitch = source->width + pad; + + if ( target_pitch > 0 && + (FT_ULong)target->rows > FT_ULONG_MAX / target_pitch ) + return FT_THROW( Invalid_Argument ); + + if ( target->rows * target_pitch > old_size && + FT_QREALLOC( target->buffer, + old_size, target->rows * target_pitch ) ) + return error; + + target->pitch = target->pitch < 0 ? -target_pitch : target_pitch; + } + break; + + default: + error = FT_THROW( Invalid_Argument ); + } + + source_pitch = source->pitch; + if ( source_pitch < 0 ) + source_pitch = -source_pitch; + + switch ( source->pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 2; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + /* get the full bytes */ + for ( j = source->width >> 3; j > 0; j-- ) + { + FT_Int val = ss[0]; /* avoid a byte->int cast on each line */ + + + tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7 ); + tt[1] = (FT_Byte)( ( val & 0x40 ) >> 6 ); + tt[2] = (FT_Byte)( ( val & 0x20 ) >> 5 ); + tt[3] = (FT_Byte)( ( val & 0x10 ) >> 4 ); + tt[4] = (FT_Byte)( ( val & 0x08 ) >> 3 ); + tt[5] = (FT_Byte)( ( val & 0x04 ) >> 2 ); + tt[6] = (FT_Byte)( ( val & 0x02 ) >> 1 ); + tt[7] = (FT_Byte)( val & 0x01 ); + + tt += 8; + ss += 1; + } + + /* get remaining pixels (if any) */ + j = source->width & 7; + if ( j > 0 ) + { + FT_Int val = *ss; + + + for ( ; j > 0; j-- ) + { + tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7); + val <<= 1; + tt += 1; + } + } + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_GRAY: + case FT_PIXEL_MODE_LCD: + case FT_PIXEL_MODE_LCD_V: + { + FT_Int width = source->width; + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 256; + + for ( i = source->rows; i > 0; i-- ) + { + FT_ARRAY_COPY( t, s, width ); + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_GRAY2: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 4; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + /* get the full bytes */ + for ( j = source->width >> 2; j > 0; j-- ) + { + FT_Int val = ss[0]; + + + tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 ); + tt[1] = (FT_Byte)( ( val & 0x30 ) >> 4 ); + tt[2] = (FT_Byte)( ( val & 0x0C ) >> 2 ); + tt[3] = (FT_Byte)( ( val & 0x03 ) ); + + ss += 1; + tt += 4; + } + + j = source->width & 3; + if ( j > 0 ) + { + FT_Int val = ss[0]; + + + for ( ; j > 0; j-- ) + { + tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 ); + val <<= 2; + tt += 1; + } + } + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_GRAY4: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 16; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + /* get the full bytes */ + for ( j = source->width >> 1; j > 0; j-- ) + { + FT_Int val = ss[0]; + + + tt[0] = (FT_Byte)( ( val & 0xF0 ) >> 4 ); + tt[1] = (FT_Byte)( ( val & 0x0F ) ); + + ss += 1; + tt += 2; + } + + if ( source->width & 1 ) + tt[0] = (FT_Byte)( ( ss[0] & 0xF0 ) >> 4 ); + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_BGRA: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 256; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + for ( j = source->width; j > 0; j-- ) + { + tt[0] = ft_gray_for_premultiplied_srgb_bgra( ss ); + + ss += 4; + tt += 1; + } + + s += source_pitch; + t += target_pitch; + } + } + break; + + default: + ; + } + + return error; + } +",1," FT_Bitmap_Convert( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target, + FT_Int alignment ) + { + FT_Error error = FT_Err_Ok; + FT_Memory memory; + + FT_Int source_pitch, target_pitch; + + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + memory = library->memory; + + switch ( source->pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + case FT_PIXEL_MODE_GRAY: + case FT_PIXEL_MODE_GRAY2: + case FT_PIXEL_MODE_GRAY4: + case FT_PIXEL_MODE_LCD: + case FT_PIXEL_MODE_LCD_V: + case FT_PIXEL_MODE_LCD_V: + case FT_PIXEL_MODE_BGRA: + { + FT_Int pad, old_target_pitch; + FT_ULong old_size; + + + old_target_pitch = target->pitch; + old_target_pitch = -old_target_pitch; + + old_size = target->rows * old_target_pitch; + + target->pixel_mode = FT_PIXEL_MODE_GRAY; + target->rows = source->rows; + target->width = source->width; + + pad = 0; + if ( alignment > 0 ) + { + pad = source->width % alignment; + if ( pad != 0 ) + pad = alignment - pad; + } + + target_pitch = source->width + pad; + + if ( target_pitch > 0 && + (FT_ULong)target->rows > FT_ULONG_MAX / target_pitch ) + return FT_THROW( Invalid_Argument ); + + if ( target->rows * target_pitch > old_size && + FT_QREALLOC( target->buffer, + old_size, target->rows * target_pitch ) ) + return error; + + target->pitch = target->pitch < 0 ? -target_pitch : target_pitch; + } + break; + + default: + error = FT_THROW( Invalid_Argument ); + } + + source_pitch = source->pitch; + if ( source_pitch < 0 ) + source_pitch = -source_pitch; + + switch ( source->pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 2; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + /* get the full bytes */ + for ( j = source->width >> 3; j > 0; j-- ) + { + FT_Int val = ss[0]; /* avoid a byte->int cast on each line */ + + + tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7 ); + tt[1] = (FT_Byte)( ( val & 0x40 ) >> 6 ); + tt[2] = (FT_Byte)( ( val & 0x20 ) >> 5 ); + tt[3] = (FT_Byte)( ( val & 0x10 ) >> 4 ); + tt[4] = (FT_Byte)( ( val & 0x08 ) >> 3 ); + tt[5] = (FT_Byte)( ( val & 0x04 ) >> 2 ); + tt[6] = (FT_Byte)( ( val & 0x02 ) >> 1 ); + tt[7] = (FT_Byte)( val & 0x01 ); + + tt += 8; + ss += 1; + } + + /* get remaining pixels (if any) */ + j = source->width & 7; + if ( j > 0 ) + { + FT_Int val = *ss; + + + for ( ; j > 0; j-- ) + { + tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7); + val <<= 1; + tt += 1; + } + } + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_GRAY: + case FT_PIXEL_MODE_LCD: + case FT_PIXEL_MODE_LCD_V: + { + FT_Int width = source->width; + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 256; + + for ( i = source->rows; i > 0; i-- ) + { + FT_ARRAY_COPY( t, s, width ); + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_GRAY2: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 4; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + /* get the full bytes */ + for ( j = source->width >> 2; j > 0; j-- ) + { + FT_Int val = ss[0]; + + + tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 ); + tt[1] = (FT_Byte)( ( val & 0x30 ) >> 4 ); + tt[2] = (FT_Byte)( ( val & 0x0C ) >> 2 ); + tt[3] = (FT_Byte)( ( val & 0x03 ) ); + + ss += 1; + tt += 4; + } + + j = source->width & 3; + if ( j > 0 ) + { + FT_Int val = ss[0]; + + + for ( ; j > 0; j-- ) + { + tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 ); + val <<= 2; + tt += 1; + } + } + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_GRAY4: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 16; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + /* get the full bytes */ + for ( j = source->width >> 1; j > 0; j-- ) + { + FT_Int val = ss[0]; + + + tt[0] = (FT_Byte)( ( val & 0xF0 ) >> 4 ); + tt[1] = (FT_Byte)( ( val & 0x0F ) ); + + ss += 1; + tt += 2; + } + + if ( source->width & 1 ) + tt[0] = (FT_Byte)( ( ss[0] & 0xF0 ) >> 4 ); + + s += source_pitch; + t += target_pitch; + } + } + break; + + + case FT_PIXEL_MODE_BGRA: + { + FT_Byte* s = source->buffer; + FT_Byte* t = target->buffer; + FT_Int i; + + + target->num_grays = 256; + + for ( i = source->rows; i > 0; i-- ) + { + FT_Byte* ss = s; + FT_Byte* tt = t; + FT_Int j; + + + for ( j = source->width; j > 0; j-- ) + { + tt[0] = ft_gray_for_premultiplied_srgb_bgra( ss ); + + ss += 4; + tt += 1; + } + + s += source_pitch; + t += target_pitch; + } + } + break; + + default: + ; + } + + return error; + } +","@@ -62,7 +62,7 @@ + + if ( pitch < 0 ) + pitch = -pitch; +- size = (FT_ULong)( pitch * source->rows ); ++ size = (FT_ULong)pitch * source->rows; + + if ( target->buffer ) + { +@@ -72,7 +72,7 @@ + + if ( target_pitch < 0 ) + target_pitch = -target_pitch; +- target_size = (FT_ULong)( target_pitch * target->rows ); ++ target_size = (FT_ULong)target_pitch * target->rows; + + if ( target_size != size ) + (void)FT_QREALLOC( target->buffer, target_size, size ); +@@ -109,7 +109,7 @@ + int pitch; + int new_pitch; + FT_UInt bpp; +- FT_Int i, width, height; ++ FT_UInt i, width, height; + unsigned char* buffer = NULL; + + +@@ -147,17 +147,17 @@ + if ( ypixels == 0 && new_pitch <= pitch ) + { + /* zero the padding */ +- FT_Int bit_width = pitch * 8; +- FT_Int bit_last = ( width + xpixels ) * bpp; ++ FT_UInt bit_width = pitch * 8; ++ FT_UInt bit_last = ( width + xpixels ) * bpp; + + + if ( bit_last < bit_width ) + { + FT_Byte* line = bitmap->buffer + ( bit_last >> 3 ); + FT_Byte* end = bitmap->buffer + pitch; +- FT_Int shift = bit_last & 7; ++ FT_UInt shift = bit_last & 7; + FT_UInt mask = 0xFF00U >> shift; +- FT_Int count = height; ++ FT_UInt count = height; + + + for ( ; count > 0; count--, line += pitch, end += pitch ) +@@ -186,7 +186,7 @@ + /* thus take care of the flow direction */ + if ( bitmap->pitch > 0 ) + { +- FT_Int len = ( width * bpp + 7 ) >> 3; ++ FT_UInt len = ( width * bpp + 7 ) >> 3; + + + for ( i = 0; i < bitmap->rows; i++ ) +@@ -195,7 +195,7 @@ + } + else + { +- FT_Int len = ( width * bpp + 7 ) >> 3; ++ FT_UInt len = ( width * bpp + 7 ) >> 3; + + + for ( i = 0; i < bitmap->rows; i++ ) +@@ -226,7 +226,8 @@ + { + FT_Error error; + unsigned char* p; +- FT_Int i, x, y, pitch; ++ FT_Int i, x, pitch; ++ FT_UInt y; + FT_Int xstr, ystr; + + +@@ -451,8 +452,8 @@ + case FT_PIXEL_MODE_LCD_V: + case FT_PIXEL_MODE_BGRA: + { +- FT_Int pad, old_target_pitch; +- FT_Long old_size; ++ FT_Int pad, old_target_pitch; ++ FT_ULong old_size; + + + old_target_pitch = target->pitch;",1808,2044,2048 +1195,"fbCombineConjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine) +{ + int i; + + for (i = 0; i < width; ++i) { + CARD32 s, d; + CARD32 m,n,o,p; + CARD32 Fa, Fb; + CARD16 t, u, v; + CARD32 sa; + CARD8 da; + + s = READ(src + i); + m = READ(mask + i); + d = READ(dest + i); + da = d >> 24; + + fbCombineMaskC (&s, &m); + + sa = m; + + switch (combine & CombineA) { + default: + Fa = 0; + break; + case CombineAOut: + m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da); + n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8; + o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16; + p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24; + Fa = m|n|o|p; + break; + case CombineAIn: + m = fbCombineConjointInPart ((CARD8) (sa >> 0), da); + n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8; + o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16; + p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24; + Fa = m|n|o|p; + break; + case CombineA: + Fa = 0xffffffff; + break; + } + + switch (combine & CombineB) { + default: + Fb = 0; + break; + case CombineBOut: + m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0)); + n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; + break; + case CombineBIn: + m = fbCombineConjointInPart (da, (CARD8) (sa >> 0)); + n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; + break; + case CombineB: + Fb = 0xffffffff; + break; + } + m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v); + n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v); + o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v); + p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v); + s = m|n|o|p; + WRITE(dest + i, s); + } +} +",0,"fbCombineConjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine) +{ + int i; + + for (i = 0; i < width; ++i) { + CARD32 s, d; + CARD32 m,n,o,p; + CARD32 Fa, Fb; + CARD16 t, u, v; + CARD32 sa; + CARD8 da; + + s = READ(src + i); + m = READ(mask + i); + d = READ(dest + i); + da = d >> 24; + + fbCombineMaskC (&s, &m); + + sa = m; + + switch (combine & CombineA) { + default: + Fa = 0; + break; + case CombineAOut: + m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da); + n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8; + o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16; + p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24; + Fa = m|n|o|p; + break; + case CombineAIn: + m = fbCombineConjointInPart ((CARD8) (sa >> 0), da); + n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8; + o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16; + p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24; + Fa = m|n|o|p; + break; + case CombineA: + Fa = 0xffffffff; + break; + } + + switch (combine & CombineB) { + default: + Fb = 0; + break; + case CombineBOut: + m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0)); + n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; + break; + case CombineBIn: + m = fbCombineConjointInPart (da, (CARD8) (sa >> 0)); + n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; + break; + case CombineB: + Fb = 0xffffffff; + break; + } + m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v); + n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v); + o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v); + p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v); + s = m|n|o|p; + WRITE(dest + i, s); + } +} +","@@ -4308,107 +4308,9 @@ fbCompositeGeneral (CARD8 op, + CARD16 width, + CARD16 height) + { +- RegionRec region; +- int n; +- BoxPtr pbox; +- Bool srcRepeat = FALSE; +- Bool maskRepeat = FALSE; +- int w, h; +- CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH*3]; +- CARD32 *scanline_buffer = _scanline_buffer; +- FbComposeData compose_data; +- +- if (pSrc->pDrawable) +- srcRepeat = pSrc->repeatType == RepeatNormal && !pSrc->transform +- && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1); +- +- if (pMask && pMask->pDrawable) +- maskRepeat = pMask->repeatType == RepeatNormal && !pMask->transform +- && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1); +- +- if (op == PictOpOver && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap) +- op = PictOpSrc; +- +- if (!miComputeCompositeRegion (®ion, +- pSrc, +- pMask, +- pDst, +- xSrc, +- ySrc, +- xMask, +- yMask, +- xDst, +- yDst, +- width, +- height)) +- return; +- +- compose_data.op = op; +- compose_data.src = pSrc; +- compose_data.mask = pMask; +- compose_data.dest = pDst; +- if (width > SCANLINE_BUFFER_LENGTH) +- scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32)); +- +- n = REGION_NUM_RECTS (®ion); +- pbox = REGION_RECTS (®ion); +- while (n--) +- { +- h = pbox->y2 - pbox->y1; +- compose_data.ySrc = pbox->y1 - yDst + ySrc; +- compose_data.yMask = pbox->y1 - yDst + yMask; +- compose_data.yDest = pbox->y1; +- while (h) +- { +- compose_data.height = h; +- w = pbox->x2 - pbox->x1; +- compose_data.xSrc = pbox->x1 - xDst + xSrc; +- compose_data.xMask = pbox->x1 - xDst + xMask; +- compose_data.xDest = pbox->x1; +- if (maskRepeat) +- { +- compose_data.yMask = mod (compose_data.yMask, pMask->pDrawable->height); +- if (compose_data.height > pMask->pDrawable->height - compose_data.yMask) +- compose_data.height = pMask->pDrawable->height - compose_data.yMask; +- } +- if (srcRepeat) +- { +- compose_data.ySrc = mod (compose_data.ySrc, pSrc->pDrawable->height); +- if (compose_data.height > pSrc->pDrawable->height - compose_data.ySrc) +- compose_data.height = pSrc->pDrawable->height - compose_data.ySrc; +- } +- while (w) +- { +- compose_data.width = w; +- if (maskRepeat) +- { +- compose_data.xMask = mod (compose_data.xMask, pMask->pDrawable->width); +- if (compose_data.width > pMask->pDrawable->width - compose_data.xMask) +- compose_data.width = pMask->pDrawable->width - compose_data.xMask; +- } +- if (srcRepeat) +- { +- compose_data.xSrc = mod (compose_data.xSrc, pSrc->pDrawable->width); +- if (compose_data.width > pSrc->pDrawable->width - compose_data.xSrc) +- compose_data.width = pSrc->pDrawable->width - compose_data.xSrc; +- } +- fbCompositeRect(&compose_data, scanline_buffer); +- w -= compose_data.width; +- compose_data.xSrc += compose_data.width; +- compose_data.xMask += compose_data.width; +- compose_data.xDest += compose_data.width; +- } +- h -= compose_data.height; +- compose_data.ySrc += compose_data.height; +- compose_data.yMask += compose_data.height; +- compose_data.yDest += compose_data.height; +- } +- pbox++; +- } +- REGION_UNINIT (pDst->pDrawable->pScreen, ®ion); +- +- if (scanline_buffer != _scanline_buffer) +- free(scanline_buffer); ++ return fbComposite (op, pSrc, pMask, pDst, ++ xSrc, ySrc, xMask, yMask, xDst, yDst, ++ width, height); + } + + #endif",891,1127,2048 +18459,"xsltCompilePatternInternal(const xmlChar *pattern, xmlDocPtr doc, + xmlNodePtr node, xsltStylesheetPtr style, + xsltTransformContextPtr runtime, int novar) { + xsltParserContextPtr ctxt = NULL; + xsltCompMatchPtr element, first = NULL, previous = NULL; + int current, start, end, level, j; + + if (pattern == NULL) { + xsltTransformError(NULL, NULL, node, + ""xsltCompilePattern : NULL pattern\n""); + return(NULL); + } + + ctxt = xsltNewParserContext(style, runtime); + if (ctxt == NULL) + return(NULL); + ctxt->doc = doc; + ctxt->elem = node; + current = end = 0; + while (pattern[current] != 0) { + start = current; + while (IS_BLANK_CH(pattern[current])) + current++; + end = current; + level = 0; + while ((pattern[end] != 0) && ((pattern[end] != '|') || (level != 0))) { + if (pattern[end] == '[') + level++; + else if (pattern[end] == ']') + level--; + else if (pattern[end] == '\'') { + end++; + while ((pattern[end] != 0) && (pattern[end] != '\'')) + end++; + } else if (pattern[end] == '""') { + end++; + while ((pattern[end] != 0) && (pattern[end] != '""')) + end++; + } + end++; + } + if (current == end) { + xsltTransformError(NULL, NULL, node, + ""xsltCompilePattern : NULL pattern\n""); + goto error; + } + element = xsltNewCompMatch(); + if (element == NULL) { + goto error; + } + if (first == NULL) + first = element; + else if (previous != NULL) + previous->next = element; + previous = element; + + ctxt->comp = element; + ctxt->base = xmlStrndup(&pattern[start], end - start); + if (ctxt->base == NULL) + goto error; + ctxt->cur = &(ctxt->base)[current - start]; + element->pattern = ctxt->base; + element->nsList = xmlGetNsList(doc, node); + j = 0; + if (element->nsList != NULL) { + while (element->nsList[j] != NULL) + j++; + } + element->nsNr = j; + + +#ifdef WITH_XSLT_DEBUG_PATTERN + xsltGenericDebug(xsltGenericDebugContext, + ""xsltCompilePattern : parsing '%s'\n"", + element->pattern); +#endif + /* + Preset default priority to be zero. + This may be changed by xsltCompileLocationPathPattern. + */ + element->priority = 0; + xsltCompileLocationPathPattern(ctxt, novar); + if (ctxt->error) { + xsltTransformError(NULL, style, node, + ""xsltCompilePattern : failed to compile '%s'\n"", + element->pattern); + if (style != NULL) style->errors++; + goto error; + } + + /* + * Reverse for faster interpretation. + */ + xsltReverseCompMatch(ctxt, element); + + /* + * Set-up the priority + */ + if (element->priority == 0) { /* if not yet determined */ + if (((element->steps[0].op == XSLT_OP_ELEM) || + (element->steps[0].op == XSLT_OP_ATTR) || + (element->steps[0].op == XSLT_OP_PI)) && + (element->steps[0].value != NULL) && + (element->steps[1].op == XSLT_OP_END)) { + ; /* previously preset */ + } else if ((element->steps[0].op == XSLT_OP_ATTR) && + (element->steps[0].value2 != NULL) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.25; + } else if ((element->steps[0].op == XSLT_OP_NS) && + (element->steps[0].value != NULL) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.25; + } else if ((element->steps[0].op == XSLT_OP_ATTR) && + (element->steps[0].value == NULL) && + (element->steps[0].value2 == NULL) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.5; + } else if (((element->steps[0].op == XSLT_OP_PI) || + (element->steps[0].op == XSLT_OP_TEXT) || + (element->steps[0].op == XSLT_OP_ALL) || + (element->steps[0].op == XSLT_OP_NODE) || + (element->steps[0].op == XSLT_OP_COMMENT)) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.5; + } else { + element->priority = 0.5; + } + } +#ifdef WITH_XSLT_DEBUG_PATTERN + xsltGenericDebug(xsltGenericDebugContext, + ""xsltCompilePattern : parsed %s, default priority %f\n"", + element->pattern, element->priority); +#endif + if (pattern[end] == '|') + end++; + current = end; + } + if (end == 0) { + xsltTransformError(NULL, style, node, + ""xsltCompilePattern : NULL pattern\n""); + if (style != NULL) style->errors++; + goto error; + } + + xsltFreeParserContext(ctxt); + return(first); + +error: + if (ctxt != NULL) + xsltFreeParserContext(ctxt); + if (first != NULL) + xsltFreeCompMatchList(first); + return(NULL); +} +",1,"xsltCompilePatternInternal(const xmlChar *pattern, xmlDocPtr doc, + xmlNodePtr node, xsltStylesheetPtr style, + xsltTransformContextPtr runtime, int novar) { + xsltParserContextPtr ctxt = NULL; + xsltCompMatchPtr element, first = NULL, previous = NULL; + int current, start, end, level, j; + + if (pattern == NULL) { + xsltTransformError(NULL, NULL, node, + ""xsltCompilePattern : NULL pattern\n""); + return(NULL); + } + + ctxt = xsltNewParserContext(style, runtime); + if (ctxt == NULL) + return(NULL); + ctxt->doc = doc; + ctxt->elem = node; + current = end = 0; + while (pattern[current] != 0) { + start = current; + while (IS_BLANK_CH(pattern[current])) + current++; + end = current; + level = 0; + while ((pattern[end] != 0) && ((pattern[end] != '|') || (level != 0))) { + if (pattern[end] == '[') + level++; + else if (pattern[end] == ']') + level--; + else if (pattern[end] == '\'') { + end++; + while ((pattern[end] != 0) && (pattern[end] != '\'')) + end++; + } else if (pattern[end] == '""') { + end++; + while ((pattern[end] != 0) && (pattern[end] != '""')) + end++; + } + if (pattern[end] == 0) + break; + end++; + } + if (current == end) { + xsltTransformError(NULL, NULL, node, + ""xsltCompilePattern : NULL pattern\n""); + goto error; + } + element = xsltNewCompMatch(); + if (element == NULL) { + goto error; + } + if (first == NULL) + first = element; + else if (previous != NULL) + previous->next = element; + previous = element; + + ctxt->comp = element; + ctxt->base = xmlStrndup(&pattern[start], end - start); + if (ctxt->base == NULL) + goto error; + ctxt->cur = &(ctxt->base)[current - start]; + element->pattern = ctxt->base; + element->nsList = xmlGetNsList(doc, node); + j = 0; + if (element->nsList != NULL) { + while (element->nsList[j] != NULL) + j++; + } + element->nsNr = j; + + +#ifdef WITH_XSLT_DEBUG_PATTERN + xsltGenericDebug(xsltGenericDebugContext, + ""xsltCompilePattern : parsing '%s'\n"", + element->pattern); +#endif + /* + Preset default priority to be zero. + This may be changed by xsltCompileLocationPathPattern. + */ + element->priority = 0; + xsltCompileLocationPathPattern(ctxt, novar); + if (ctxt->error) { + xsltTransformError(NULL, style, node, + ""xsltCompilePattern : failed to compile '%s'\n"", + element->pattern); + if (style != NULL) style->errors++; + goto error; + } + + /* + * Reverse for faster interpretation. + */ + xsltReverseCompMatch(ctxt, element); + + /* + * Set-up the priority + */ + if (element->priority == 0) { /* if not yet determined */ + if (((element->steps[0].op == XSLT_OP_ELEM) || + (element->steps[0].op == XSLT_OP_ATTR) || + (element->steps[0].op == XSLT_OP_PI)) && + (element->steps[0].value != NULL) && + (element->steps[1].op == XSLT_OP_END)) { + ; /* previously preset */ + } else if ((element->steps[0].op == XSLT_OP_ATTR) && + (element->steps[0].value2 != NULL) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.25; + } else if ((element->steps[0].op == XSLT_OP_NS) && + (element->steps[0].value != NULL) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.25; + } else if ((element->steps[0].op == XSLT_OP_ATTR) && + (element->steps[0].value == NULL) && + (element->steps[0].value2 == NULL) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.5; + } else if (((element->steps[0].op == XSLT_OP_PI) || + (element->steps[0].op == XSLT_OP_TEXT) || + (element->steps[0].op == XSLT_OP_ALL) || + (element->steps[0].op == XSLT_OP_NODE) || + (element->steps[0].op == XSLT_OP_COMMENT)) && + (element->steps[1].op == XSLT_OP_END)) { + element->priority = -0.5; + } else { + element->priority = 0.5; + } + } +#ifdef WITH_XSLT_DEBUG_PATTERN + xsltGenericDebug(xsltGenericDebugContext, + ""xsltCompilePattern : parsed %s, default priority %f\n"", + element->pattern, element->priority); +#endif + if (pattern[end] == '|') + end++; + current = end; + } + if (end == 0) { + xsltTransformError(NULL, style, node, + ""xsltCompilePattern : NULL pattern\n""); + if (style != NULL) style->errors++; + goto error; + } + + xsltFreeParserContext(ctxt); + return(first); + +error: + if (ctxt != NULL) + xsltFreeParserContext(ctxt); + if (first != NULL) + xsltFreeCompMatchList(first); + return(NULL); +} +","@@ -1864,6 +1864,8 @@ xsltCompilePatternInternal(const xmlChar *pattern, xmlDocPtr doc, + while ((pattern[end] != 0) && (pattern[end] != '""')) + end++; + } ++ if (pattern[end] == 0) ++ break; + end++; + } + if (current == end) {",1285,1521,2048 +17346,"void NuPlayer::GenericSource::onMessageReceived(const sp &msg) { + switch (msg->what()) { + case kWhatPrepareAsync: + { + onPrepareAsync(); + break; + } + case kWhatFetchSubtitleData: + { + fetchTextData(kWhatSendSubtitleData, MEDIA_TRACK_TYPE_SUBTITLE, + mFetchSubtitleDataGeneration, mSubtitleTrack.mPackets, msg); + break; + } + + case kWhatFetchTimedTextData: + { + fetchTextData(kWhatSendTimedTextData, MEDIA_TRACK_TYPE_TIMEDTEXT, + mFetchTimedTextDataGeneration, mTimedTextTrack.mPackets, msg); + break; + } + + case kWhatSendSubtitleData: + { + sendTextData(kWhatSubtitleData, MEDIA_TRACK_TYPE_SUBTITLE, + mFetchSubtitleDataGeneration, mSubtitleTrack.mPackets, msg); + break; + } + + case kWhatSendTimedTextData: + { + sendTextData(kWhatTimedTextData, MEDIA_TRACK_TYPE_TIMEDTEXT, + mFetchTimedTextDataGeneration, mTimedTextTrack.mPackets, msg); + break; + } + + case kWhatChangeAVSource: + { + int32_t trackIndex; + CHECK(msg->findInt32(""trackIndex"", &trackIndex)); + const sp source = mSources.itemAt(trackIndex); + + Track* track; + const char *mime; + media_track_type trackType, counterpartType; + sp meta = source->getFormat(); + meta->findCString(kKeyMIMEType, &mime); + if (!strncasecmp(mime, ""audio/"", 6)) { + track = &mAudioTrack; + trackType = MEDIA_TRACK_TYPE_AUDIO; + counterpartType = MEDIA_TRACK_TYPE_VIDEO;; + } else { + CHECK(!strncasecmp(mime, ""video/"", 6)); + track = &mVideoTrack; + trackType = MEDIA_TRACK_TYPE_VIDEO; + counterpartType = MEDIA_TRACK_TYPE_AUDIO;; + } + + + if (track->mSource != NULL) { + track->mSource->stop(); + } + track->mSource = source; + track->mSource->start(); + track->mIndex = trackIndex; + + int64_t timeUs, actualTimeUs; + const bool formatChange = true; + if (trackType == MEDIA_TRACK_TYPE_AUDIO) { + timeUs = mAudioLastDequeueTimeUs; + } else { + timeUs = mVideoLastDequeueTimeUs; + } + readBuffer(trackType, timeUs, &actualTimeUs, formatChange); + readBuffer(counterpartType, -1, NULL, formatChange); + ALOGV(""timeUs %lld actualTimeUs %lld"", (long long)timeUs, (long long)actualTimeUs); + + break; + } + + case kWhatStart: + case kWhatResume: + { + restartPollBuffering(); + break; + } + + case kWhatPollBuffering: + { + int32_t generation; + CHECK(msg->findInt32(""generation"", &generation)); + if (generation == mPollBufferingGeneration) { + onPollBuffering(); + } + break; + } + + case kWhatGetFormat: + { + onGetFormatMeta(msg); + break; + } + + case kWhatGetSelectedTrack: + { + onGetSelectedTrack(msg); + break; + } + + case kWhatSelectTrack: + { + onSelectTrack(msg); + break; + } + + case kWhatSeek: + { + onSeek(msg); + break; + } + + case kWhatReadBuffer: + { + onReadBuffer(msg); + break; + } + + case kWhatSecureDecodersInstantiated: + { + int32_t err; + CHECK(msg->findInt32(""err"", &err)); + onSecureDecodersInstantiated(err); + break; + } + + case kWhatStopWidevine: + { + mStopRead = true; + if (mVideoTrack.mSource != NULL) { + mVideoTrack.mPackets->clear(); + } + sp response = new AMessage; + sp replyID; + CHECK(msg->senderAwaitsResponse(&replyID)); + response->postReply(replyID); + break; + } + default: + Source::onMessageReceived(msg); + break; + } +} +",0,"void NuPlayer::GenericSource::onMessageReceived(const sp &msg) { + switch (msg->what()) { + case kWhatPrepareAsync: + { + onPrepareAsync(); + break; + } + case kWhatFetchSubtitleData: + { + fetchTextData(kWhatSendSubtitleData, MEDIA_TRACK_TYPE_SUBTITLE, + mFetchSubtitleDataGeneration, mSubtitleTrack.mPackets, msg); + break; + } + + case kWhatFetchTimedTextData: + { + fetchTextData(kWhatSendTimedTextData, MEDIA_TRACK_TYPE_TIMEDTEXT, + mFetchTimedTextDataGeneration, mTimedTextTrack.mPackets, msg); + break; + } + + case kWhatSendSubtitleData: + { + sendTextData(kWhatSubtitleData, MEDIA_TRACK_TYPE_SUBTITLE, + mFetchSubtitleDataGeneration, mSubtitleTrack.mPackets, msg); + break; + } + + case kWhatSendTimedTextData: + { + sendTextData(kWhatTimedTextData, MEDIA_TRACK_TYPE_TIMEDTEXT, + mFetchTimedTextDataGeneration, mTimedTextTrack.mPackets, msg); + break; + } + + case kWhatChangeAVSource: + { + int32_t trackIndex; + CHECK(msg->findInt32(""trackIndex"", &trackIndex)); + const sp source = mSources.itemAt(trackIndex); + + Track* track; + const char *mime; + media_track_type trackType, counterpartType; + sp meta = source->getFormat(); + meta->findCString(kKeyMIMEType, &mime); + if (!strncasecmp(mime, ""audio/"", 6)) { + track = &mAudioTrack; + trackType = MEDIA_TRACK_TYPE_AUDIO; + counterpartType = MEDIA_TRACK_TYPE_VIDEO;; + } else { + CHECK(!strncasecmp(mime, ""video/"", 6)); + track = &mVideoTrack; + trackType = MEDIA_TRACK_TYPE_VIDEO; + counterpartType = MEDIA_TRACK_TYPE_AUDIO;; + } + + + if (track->mSource != NULL) { + track->mSource->stop(); + } + track->mSource = source; + track->mSource->start(); + track->mIndex = trackIndex; + + int64_t timeUs, actualTimeUs; + const bool formatChange = true; + if (trackType == MEDIA_TRACK_TYPE_AUDIO) { + timeUs = mAudioLastDequeueTimeUs; + } else { + timeUs = mVideoLastDequeueTimeUs; + } + readBuffer(trackType, timeUs, &actualTimeUs, formatChange); + readBuffer(counterpartType, -1, NULL, formatChange); + ALOGV(""timeUs %lld actualTimeUs %lld"", (long long)timeUs, (long long)actualTimeUs); + + break; + } + + case kWhatStart: + case kWhatResume: + { + restartPollBuffering(); + break; + } + + case kWhatPollBuffering: + { + int32_t generation; + CHECK(msg->findInt32(""generation"", &generation)); + if (generation == mPollBufferingGeneration) { + onPollBuffering(); + } + break; + } + + case kWhatGetFormat: + { + onGetFormatMeta(msg); + break; + } + + case kWhatGetSelectedTrack: + { + onGetSelectedTrack(msg); + break; + } + + case kWhatSelectTrack: + { + onSelectTrack(msg); + break; + } + + case kWhatSeek: + { + onSeek(msg); + break; + } + + case kWhatReadBuffer: + { + onReadBuffer(msg); + break; + } + + case kWhatSecureDecodersInstantiated: + { + int32_t err; + CHECK(msg->findInt32(""err"", &err)); + onSecureDecodersInstantiated(err); + break; + } + + case kWhatStopWidevine: + { + mStopRead = true; + if (mVideoTrack.mSource != NULL) { + mVideoTrack.mPackets->clear(); + } + sp response = new AMessage; + sp replyID; + CHECK(msg->senderAwaitsResponse(&replyID)); + response->postReply(replyID); + break; + } + default: + Source::onMessageReceived(msg); + break; + } +} +","@@ -211,6 +211,9 @@ + + + for (size_t i = 0; i < numtracks; ++i) { + sp track = extractor->getTrack(i); ++ if (track == NULL) { ++ continue; ++ } + + sp meta = extractor->getTrackMetaData(i); + +@@ -253,22 +256,25 @@ + + } + } + +- if (track != NULL) { +- mSources.push(track); +- int64_t durationUs; +- if (meta->findInt64(kKeyDuration, &durationUs)) { +- if (durationUs > mDurationUs) { +- mDurationUs = durationUs; +- } +- } +- +- int32_t bitrate; +- if (totalBitrate >= 0 && meta->findInt32(kKeyBitRate, &bitrate)) { +- totalBitrate += bitrate; +- } else { +- totalBitrate = -1; ++ mSources.push(track); ++ int64_t durationUs; ++ if (meta->findInt64(kKeyDuration, &durationUs)) { ++ if (durationUs > mDurationUs) { ++ mDurationUs = durationUs; + } + } ++ ++ int32_t bitrate; ++ if (totalBitrate >= 0 && meta->findInt32(kKeyBitRate, &bitrate)) { ++ totalBitrate += bitrate; ++ } else { ++ totalBitrate = -1; ++ } ++ } ++ ++ if (mSources.size() == 0) { ++ ALOGE(""b/23705695""); ++ return UNKNOWN_ERROR; + } + + mBitrate = totalBitrate; +@@ -318,7 +324,7 @@ + + + status_t NuPlayer::GenericSource::setBuffers( + bool audio, Vector &buffers) { +- if (mIsSecure && !audio) { ++ if (mIsWidevine && !audio && mVideoTrack.mSource != NULL) { + return mVideoTrack.mSource->setBuffers(buffers); + } + return INVALID_OPERATION; +",858,1094,2048 +13210,"void ChromotingInstance::HandleConnect(const base::DictionaryValue& data) { + std::string local_jid; + std::string host_jid; + std::string host_public_key; + std::string auth_methods_str; + std::string authentication_tag; + std::vector auth_methods; + if (!data.GetString(""hostJid"", &host_jid) || + !data.GetString(""hostPublicKey"", &host_public_key) || + !data.GetString(""localJid"", &local_jid) || + !data.GetString(""authenticationMethods"", &auth_methods_str) || + !ParseAuthMethods(auth_methods_str, &auth_methods) || + !data.GetString(""authenticationTag"", &authentication_tag)) { + LOG(ERROR) << ""Invalid connect() data.""; + return; + } + + std::string client_pairing_id; + data.GetString(""clientPairingId"", &client_pairing_id); + std::string client_paired_secret; + data.GetString(""clientPairedSecret"", &client_paired_secret); + + protocol::FetchSecretCallback fetch_secret_callback; + if (use_async_pin_dialog_) { + fetch_secret_callback = base::Bind( + &ChromotingInstance::FetchSecretFromDialog, weak_factory_.GetWeakPtr()); + } else { + std::string shared_secret; + if (!data.GetString(""sharedSecret"", &shared_secret)) { + LOG(ERROR) << ""sharedSecret not specified in connect().""; + return; + } + fetch_secret_callback = + base::Bind(&ChromotingInstance::FetchSecretFromString, shared_secret); + } + + std::string capabilities; + if (data.HasKey(""capabilities"")) { + if (!data.GetString(""capabilities"", &capabilities)) { + LOG(ERROR) << ""Invalid connect() data.""; + return; + } + } + + VLOG(0) << ""Connecting to "" << host_jid + << "". Local jid: "" << local_jid << "".""; + +#if defined(OS_NACL) + std::string key_filter; + if (!data.GetString(""keyFilter"", &key_filter)) { + NOTREACHED(); + normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); + } else if (key_filter == ""mac"") { + normalizing_input_filter_.reset( + new NormalizingInputFilterMac(&key_mapper_)); + } else if (key_filter == ""cros"") { + normalizing_input_filter_.reset( + new NormalizingInputFilterCros(&key_mapper_)); + } else { + DCHECK(key_filter.empty()); + normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); + } +#elif defined(OS_MACOSX) + normalizing_input_filter_.reset(new NormalizingInputFilterMac(&key_mapper_)); +#elif defined(OS_CHROMEOS) + normalizing_input_filter_.reset(new NormalizingInputFilterCros(&key_mapper_)); +#else + normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); +#endif + input_handler_.set_input_stub(normalizing_input_filter_.get()); + + bool enable_video_decode_renderer = false; + if (data.GetBoolean(""enableVideoDecodeRenderer"", + &enable_video_decode_renderer) && + enable_video_decode_renderer) { + LogToWebapp(""Initializing 3D renderer.""); + video_renderer_.reset(new PepperVideoRenderer3D()); + if (!video_renderer_->Initialize(this, context_, this)) + video_renderer_.reset(); + } + + if (!video_renderer_) { + LogToWebapp(""Initializing 2D renderer.""); + video_renderer_.reset(new PepperVideoRenderer2D()); + if (!video_renderer_->Initialize(this, context_, this)) + video_renderer_.reset(); + } + + CHECK(video_renderer_); + + if (!plugin_view_.is_null()) + video_renderer_->OnViewChanged(plugin_view_); + + scoped_ptr audio_player(new PepperAudioPlayer(this)); + client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), + audio_player.Pass())); + + mouse_input_filter_.set_input_stub(client_->input_stub()); + if (!plugin_view_.is_null()) { + mouse_input_filter_.set_input_size(webrtc::DesktopSize( + plugin_view_.GetRect().width(), plugin_view_.GetRect().height())); + } + + signal_strategy_.reset(new DelegatingSignalStrategy( + local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, + weak_factory_.GetWeakPtr()))); + + scoped_ptr transport_factory( + new protocol::LibjingleTransportFactory( + signal_strategy_.get(), + PepperPortAllocator::Create(this).Pass(), + protocol::NetworkSettings( + protocol::NetworkSettings::NAT_TRAVERSAL_FULL))); + + scoped_ptr + token_fetcher(new TokenFetcherProxy( + base::Bind(&ChromotingInstance::FetchThirdPartyToken, + weak_factory_.GetWeakPtr()), + host_public_key)); + scoped_ptr authenticator( + new protocol::NegotiatingClientAuthenticator( + client_pairing_id, client_paired_secret, authentication_tag, + fetch_secret_callback, token_fetcher.Pass(), auth_methods)); + + client_->Start(signal_strategy_.get(), authenticator.Pass(), + transport_factory.Pass(), host_jid, capabilities); + + plugin_task_runner_->PostDelayedTask( + FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, + weak_factory_.GetWeakPtr()), + base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); +} +",0,"void ChromotingInstance::HandleConnect(const base::DictionaryValue& data) { + std::string local_jid; + std::string host_jid; + std::string host_public_key; + std::string auth_methods_str; + std::string authentication_tag; + std::vector auth_methods; + if (!data.GetString(""hostJid"", &host_jid) || + !data.GetString(""hostPublicKey"", &host_public_key) || + !data.GetString(""localJid"", &local_jid) || + !data.GetString(""authenticationMethods"", &auth_methods_str) || + !ParseAuthMethods(auth_methods_str, &auth_methods) || + !data.GetString(""authenticationTag"", &authentication_tag)) { + LOG(ERROR) << ""Invalid connect() data.""; + return; + } + + std::string client_pairing_id; + data.GetString(""clientPairingId"", &client_pairing_id); + std::string client_paired_secret; + data.GetString(""clientPairedSecret"", &client_paired_secret); + + protocol::FetchSecretCallback fetch_secret_callback; + if (use_async_pin_dialog_) { + fetch_secret_callback = base::Bind( + &ChromotingInstance::FetchSecretFromDialog, weak_factory_.GetWeakPtr()); + } else { + std::string shared_secret; + if (!data.GetString(""sharedSecret"", &shared_secret)) { + LOG(ERROR) << ""sharedSecret not specified in connect().""; + return; + } + fetch_secret_callback = + base::Bind(&ChromotingInstance::FetchSecretFromString, shared_secret); + } + + std::string capabilities; + if (data.HasKey(""capabilities"")) { + if (!data.GetString(""capabilities"", &capabilities)) { + LOG(ERROR) << ""Invalid connect() data.""; + return; + } + } + + VLOG(0) << ""Connecting to "" << host_jid + << "". Local jid: "" << local_jid << "".""; + +#if defined(OS_NACL) + std::string key_filter; + if (!data.GetString(""keyFilter"", &key_filter)) { + NOTREACHED(); + normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); + } else if (key_filter == ""mac"") { + normalizing_input_filter_.reset( + new NormalizingInputFilterMac(&key_mapper_)); + } else if (key_filter == ""cros"") { + normalizing_input_filter_.reset( + new NormalizingInputFilterCros(&key_mapper_)); + } else { + DCHECK(key_filter.empty()); + normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); + } +#elif defined(OS_MACOSX) + normalizing_input_filter_.reset(new NormalizingInputFilterMac(&key_mapper_)); +#elif defined(OS_CHROMEOS) + normalizing_input_filter_.reset(new NormalizingInputFilterCros(&key_mapper_)); +#else + normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); +#endif + input_handler_.set_input_stub(normalizing_input_filter_.get()); + + bool enable_video_decode_renderer = false; + if (data.GetBoolean(""enableVideoDecodeRenderer"", + &enable_video_decode_renderer) && + enable_video_decode_renderer) { + LogToWebapp(""Initializing 3D renderer.""); + video_renderer_.reset(new PepperVideoRenderer3D()); + if (!video_renderer_->Initialize(this, context_, this)) + video_renderer_.reset(); + } + + if (!video_renderer_) { + LogToWebapp(""Initializing 2D renderer.""); + video_renderer_.reset(new PepperVideoRenderer2D()); + if (!video_renderer_->Initialize(this, context_, this)) + video_renderer_.reset(); + } + + CHECK(video_renderer_); + + if (!plugin_view_.is_null()) + video_renderer_->OnViewChanged(plugin_view_); + + scoped_ptr audio_player(new PepperAudioPlayer(this)); + client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), + audio_player.Pass())); + + mouse_input_filter_.set_input_stub(client_->input_stub()); + if (!plugin_view_.is_null()) { + mouse_input_filter_.set_input_size(webrtc::DesktopSize( + plugin_view_.GetRect().width(), plugin_view_.GetRect().height())); + } + + signal_strategy_.reset(new DelegatingSignalStrategy( + local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, + weak_factory_.GetWeakPtr()))); + + scoped_ptr transport_factory( + new protocol::LibjingleTransportFactory( + signal_strategy_.get(), + PepperPortAllocator::Create(this).Pass(), + protocol::NetworkSettings( + protocol::NetworkSettings::NAT_TRAVERSAL_FULL))); + + scoped_ptr + token_fetcher(new TokenFetcherProxy( + base::Bind(&ChromotingInstance::FetchThirdPartyToken, + weak_factory_.GetWeakPtr()), + host_public_key)); + scoped_ptr authenticator( + new protocol::NegotiatingClientAuthenticator( + client_pairing_id, client_paired_secret, authentication_tag, + fetch_secret_callback, token_fetcher.Pass(), auth_methods)); + + client_->Start(signal_strategy_.get(), authenticator.Pass(), + transport_factory.Pass(), host_jid, capabilities); + + plugin_task_runner_->PostDelayedTask( + FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, + weak_factory_.GetWeakPtr()), + base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); +} +","@@ -350,6 +350,8 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) { + HandleSendMouseInputWhenUnfocused(); + } else if (method == ""delegateLargeCursors"") { + HandleDelegateLargeCursors(); ++ } else if (method == ""enableDebugRegion"") { ++ HandleEnableDebugRegion(*data); + } + } + +@@ -436,6 +438,25 @@ void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion& shape) { + PostLegacyJsonMessage(""onDesktopShape"", data.Pass()); + } + ++void ChromotingInstance::OnVideoFrameDirtyRegion( ++ const webrtc::DesktopRegion& dirty_region) { ++ scoped_ptr rects_value(new base::ListValue()); ++ for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); ++ i.Advance()) { ++ const webrtc::DesktopRect& rect = i.rect(); ++ scoped_ptr rect_value(new base::ListValue()); ++ rect_value->AppendInteger(rect.left()); ++ rect_value->AppendInteger(rect.top()); ++ rect_value->AppendInteger(rect.width()); ++ rect_value->AppendInteger(rect.height()); ++ rects_value->Append(rect_value.release()); ++ } ++ ++ scoped_ptr data(new base::DictionaryValue()); ++ data->Set(""rects"", rects_value.release()); ++ PostLegacyJsonMessage(""onDebugRegion"", data.Pass()); ++} ++ + void ChromotingInstance::OnConnectionState( + protocol::ConnectionToHost::State state, + protocol::ErrorCode error) { +@@ -947,6 +968,17 @@ void ChromotingInstance::HandleDelegateLargeCursors() { + cursor_setter_.set_delegate_stub(this); + } + ++void ChromotingInstance::HandleEnableDebugRegion( ++ const base::DictionaryValue& data) { ++ bool enable = false; ++ if (!data.GetBoolean(""enable"", &enable)) { ++ LOG(ERROR) << ""Invalid enableDebugRegion.""; ++ return; ++ } ++ ++ video_renderer_->EnableDebugDirtyRegion(enable); ++} ++ + void ChromotingInstance::Disconnect() { + DCHECK(plugin_task_runner_->BelongsToCurrentThread()); + ",1158,1394,2048 +9646,"MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images, + size_t *length,ExceptionInfo *exception) +{ + const MagickInfo + *magick_info; + + ImageInfo + *clone_info; + + MagickBooleanType + status; + + void + *blob; + + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(images != (Image *) NULL); + assert(images->signature == MagickCoreSignature); + assert(exception != (ExceptionInfo *) NULL); + *length=0; + blob=(unsigned char *) NULL; + clone_info=CloneImageInfo(image_info); + (void) SetImageInfo(clone_info,(unsigned int) GetImageListLength(images), + exception); + if (*clone_info->magick != '\0') + (void) CopyMagickString(images->magick,clone_info->magick,MagickPathExtent); + magick_info=GetMagickInfo(images->magick,exception); + if (magick_info == (const MagickInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + MissingDelegateError,""NoDecodeDelegateForThisImageFormat"",""`%s'"", + images->magick); + clone_info=DestroyImageInfo(clone_info); + return(blob); + } + if (GetMagickAdjoin(magick_info) == MagickFalse) + { + clone_info=DestroyImageInfo(clone_info); + return(ImageToBlob(image_info,images,length,exception)); + } + (void) CopyMagickString(clone_info->magick,images->magick,MagickPathExtent); + if (GetMagickBlobSupport(magick_info) != MagickFalse) + { + /* + Native blob support for this images format. + */ + clone_info->length=0; + clone_info->blob=(void *) AcquireQuantumMemory(MagickMaxBlobExtent, + sizeof(unsigned char)); + if (clone_info->blob == (void *) NULL) + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",images->filename); + else + { + (void) CloseBlob(images); + images->blob->exempt=MagickTrue; + *images->filename='\0'; + status=WriteImages(clone_info,images,images->filename,exception); + *length=images->blob->length; + blob=DetachBlob(images->blob); + if (blob == (void *) NULL) + clone_info->blob=RelinquishMagickMemory(clone_info->blob); + else if (status == MagickFalse) + blob=RelinquishMagickMemory(blob); + else + blob=ResizeQuantumMemory(blob,*length+1,sizeof(unsigned char)); + } + } + else + { + char + filename[MagickPathExtent], + unique[MagickPathExtent]; + + int + file; + + /* + Write file to disk in blob images format. + */ + file=AcquireUniqueFileResource(unique); + if (file == -1) + { + ThrowFileException(exception,FileOpenError,""UnableToWriteBlob"", + image_info->filename); + } + else + { + clone_info->file=fdopen(file,""wb""); + if (clone_info->file != (FILE *) NULL) + { + (void) FormatLocaleString(filename,MagickPathExtent,""%s:%s"", + images->magick,unique); + status=WriteImages(clone_info,images,filename,exception); + (void) CloseBlob(images); + (void) fclose(clone_info->file); + if (status != MagickFalse) + blob=FileToBlob(unique,~0UL,length,exception); + } + (void) RelinquishUniqueFileResource(unique); + } + } + clone_info=DestroyImageInfo(clone_info); + return(blob); +} +",0,"MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images, + size_t *length,ExceptionInfo *exception) +{ + const MagickInfo + *magick_info; + + ImageInfo + *clone_info; + + MagickBooleanType + status; + + void + *blob; + + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(images != (Image *) NULL); + assert(images->signature == MagickCoreSignature); + assert(exception != (ExceptionInfo *) NULL); + *length=0; + blob=(unsigned char *) NULL; + clone_info=CloneImageInfo(image_info); + (void) SetImageInfo(clone_info,(unsigned int) GetImageListLength(images), + exception); + if (*clone_info->magick != '\0') + (void) CopyMagickString(images->magick,clone_info->magick,MagickPathExtent); + magick_info=GetMagickInfo(images->magick,exception); + if (magick_info == (const MagickInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + MissingDelegateError,""NoDecodeDelegateForThisImageFormat"",""`%s'"", + images->magick); + clone_info=DestroyImageInfo(clone_info); + return(blob); + } + if (GetMagickAdjoin(magick_info) == MagickFalse) + { + clone_info=DestroyImageInfo(clone_info); + return(ImageToBlob(image_info,images,length,exception)); + } + (void) CopyMagickString(clone_info->magick,images->magick,MagickPathExtent); + if (GetMagickBlobSupport(magick_info) != MagickFalse) + { + /* + Native blob support for this images format. + */ + clone_info->length=0; + clone_info->blob=(void *) AcquireQuantumMemory(MagickMaxBlobExtent, + sizeof(unsigned char)); + if (clone_info->blob == (void *) NULL) + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",images->filename); + else + { + (void) CloseBlob(images); + images->blob->exempt=MagickTrue; + *images->filename='\0'; + status=WriteImages(clone_info,images,images->filename,exception); + *length=images->blob->length; + blob=DetachBlob(images->blob); + if (blob == (void *) NULL) + clone_info->blob=RelinquishMagickMemory(clone_info->blob); + else if (status == MagickFalse) + blob=RelinquishMagickMemory(blob); + else + blob=ResizeQuantumMemory(blob,*length+1,sizeof(unsigned char)); + } + } + else + { + char + filename[MagickPathExtent], + unique[MagickPathExtent]; + + int + file; + + /* + Write file to disk in blob images format. + */ + file=AcquireUniqueFileResource(unique); + if (file == -1) + { + ThrowFileException(exception,FileOpenError,""UnableToWriteBlob"", + image_info->filename); + } + else + { + clone_info->file=fdopen(file,""wb""); + if (clone_info->file != (FILE *) NULL) + { + (void) FormatLocaleString(filename,MagickPathExtent,""%s:%s"", + images->magick,unique); + status=WriteImages(clone_info,images,filename,exception); + (void) CloseBlob(images); + (void) fclose(clone_info->file); + if (status != MagickFalse) + blob=FileToBlob(unique,~0UL,length,exception); + } + (void) RelinquishUniqueFileResource(unique); + } + } + clone_info=DestroyImageInfo(clone_info); + return(blob); +} +","@@ -996,6 +996,7 @@ MagickExport void *DetachBlob(BlobInfo *blob_info) + if (blob_info->mapped != MagickFalse) + { + (void) UnmapBlob(blob_info->data,blob_info->length); ++ blob_info->data=NULL; + RelinquishMagickResource(MapResource,blob_info->length); + } + blob_info->mapped=MagickFalse;",871,1107,2048 +4328,"static void start_event_run(const char *event_name) +{ + /* Start event asynchronously on the dump dir + * (synchronous run would freeze GUI until completion) + */ + + /* https://bugzilla.redhat.com/show_bug.cgi?id=1044653 */ + correct_bz_private_goup_name(event_name); + + struct run_event_state *state = new_run_event_state(); + state->logging_callback = run_event_gtk_logging; + state->error_callback = run_event_gtk_error; + state->alert_callback = run_event_gtk_alert; + state->ask_callback = run_event_gtk_ask; + state->ask_yes_no_callback = run_event_gtk_ask_yes_no; + state->ask_yes_no_yesforever_callback = run_event_gtk_ask_yes_no_yesforever; + state->ask_yes_no_save_result_callback = run_event_gtk_ask_yes_no_save_result; + state->ask_password_callback = run_event_gtk_ask_password; + + if (prepare_commands(state, g_dump_dir_name, event_name) == 0) + { + no_cmds: + /* No commands needed?! (This is untypical) */ + free_run_event_state(state); + char *msg = xasprintf(_(""No processing for event '%s' is defined""), event_name); + append_to_textview(g_tv_event_log, msg); + free(msg); + cancel_processing(g_lbl_event_log, _(""Processing failed.""), TERMINATE_NOFLAGS); + return; + } + + struct dump_dir *dd = wizard_open_directory_for_writing(g_dump_dir_name); + dd_close(dd); + if (!dd) + { + free_run_event_state(state); + if (!g_expert_mode) + { + cancel_processing(g_lbl_event_log, _(""Processing interrupted: can't continue without writable directory.""), TERMINATE_NOFLAGS); + } + return; /* user refused to steal, or write error, etc... */ + } + + set_excluded_envvar(); + GList *env_list = export_event_config(event_name); + + if (spawn_next_command(state, g_dump_dir_name, event_name, EXECFLG_SETPGID) < 0) + { + unexport_event_config(env_list); + goto no_cmds; + } + g_event_child_pid = state->command_pid; + + /* At least one command is needed, and we started first one. + * Hook its output fd to the main loop. + */ + struct analyze_event_data *evd = xzalloc(sizeof(*evd)); + evd->run_state = state; + evd->event_name = xstrdup(event_name); + evd->env_list = env_list; + evd->event_log = strbuf_new(); + evd->fd = state->command_out_fd; + + state->logging_param = evd; + state->error_param = evd; + state->interaction_param = evd; + + ndelay_on(evd->fd); + evd->channel = g_io_channel_unix_new(evd->fd); + g_event_source_id = g_io_add_watch(evd->channel, + G_IO_IN | G_IO_ERR | G_IO_HUP, /* need HUP to detect EOF w/o any data */ + consume_cmd_output, + evd + ); + + gtk_label_set_text(g_lbl_event_log, _(""Processing..."")); + log_notice(""running event '%s' on '%s'"", event_name, g_dump_dir_name); + char *msg = xasprintf(""--- Running %s ---\n"", event_name); + append_to_textview(g_tv_event_log, msg); + free(msg); + + /* don't bother testing if they are visible, this is faster */ + gtk_widget_hide(GTK_WIDGET(g_img_process_fail)); + + gtk_widget_show(GTK_WIDGET(g_spinner_event_log)); + gtk_widget_show(g_btn_stop); + /* Disable (gray out) navigation buttons */ + gtk_widget_set_sensitive(g_btn_close, false); + gtk_widget_set_sensitive(g_btn_next, false); +} +",0,"static void start_event_run(const char *event_name) +{ + /* Start event asynchronously on the dump dir + * (synchronous run would freeze GUI until completion) + */ + + /* https://bugzilla.redhat.com/show_bug.cgi?id=1044653 */ + correct_bz_private_goup_name(event_name); + + struct run_event_state *state = new_run_event_state(); + state->logging_callback = run_event_gtk_logging; + state->error_callback = run_event_gtk_error; + state->alert_callback = run_event_gtk_alert; + state->ask_callback = run_event_gtk_ask; + state->ask_yes_no_callback = run_event_gtk_ask_yes_no; + state->ask_yes_no_yesforever_callback = run_event_gtk_ask_yes_no_yesforever; + state->ask_yes_no_save_result_callback = run_event_gtk_ask_yes_no_save_result; + state->ask_password_callback = run_event_gtk_ask_password; + + if (prepare_commands(state, g_dump_dir_name, event_name) == 0) + { + no_cmds: + /* No commands needed?! (This is untypical) */ + free_run_event_state(state); + char *msg = xasprintf(_(""No processing for event '%s' is defined""), event_name); + append_to_textview(g_tv_event_log, msg); + free(msg); + cancel_processing(g_lbl_event_log, _(""Processing failed.""), TERMINATE_NOFLAGS); + return; + } + + struct dump_dir *dd = wizard_open_directory_for_writing(g_dump_dir_name); + dd_close(dd); + if (!dd) + { + free_run_event_state(state); + if (!g_expert_mode) + { + cancel_processing(g_lbl_event_log, _(""Processing interrupted: can't continue without writable directory.""), TERMINATE_NOFLAGS); + } + return; /* user refused to steal, or write error, etc... */ + } + + set_excluded_envvar(); + GList *env_list = export_event_config(event_name); + + if (spawn_next_command(state, g_dump_dir_name, event_name, EXECFLG_SETPGID) < 0) + { + unexport_event_config(env_list); + goto no_cmds; + } + g_event_child_pid = state->command_pid; + + /* At least one command is needed, and we started first one. + * Hook its output fd to the main loop. + */ + struct analyze_event_data *evd = xzalloc(sizeof(*evd)); + evd->run_state = state; + evd->event_name = xstrdup(event_name); + evd->env_list = env_list; + evd->event_log = strbuf_new(); + evd->fd = state->command_out_fd; + + state->logging_param = evd; + state->error_param = evd; + state->interaction_param = evd; + + ndelay_on(evd->fd); + evd->channel = g_io_channel_unix_new(evd->fd); + g_event_source_id = g_io_add_watch(evd->channel, + G_IO_IN | G_IO_ERR | G_IO_HUP, /* need HUP to detect EOF w/o any data */ + consume_cmd_output, + evd + ); + + gtk_label_set_text(g_lbl_event_log, _(""Processing..."")); + log_notice(""running event '%s' on '%s'"", event_name, g_dump_dir_name); + char *msg = xasprintf(""--- Running %s ---\n"", event_name); + append_to_textview(g_tv_event_log, msg); + free(msg); + + /* don't bother testing if they are visible, this is faster */ + gtk_widget_hide(GTK_WIDGET(g_img_process_fail)); + + gtk_widget_show(GTK_WIDGET(g_spinner_event_log)); + gtk_widget_show(g_btn_stop); + /* Disable (gray out) navigation buttons */ + gtk_widget_set_sensitive(g_btn_close, false); + gtk_widget_set_sensitive(g_btn_next, false); +} +","@@ -433,8 +433,6 @@ static void save_text_if_changed(const char *name, const char *new_value) + + //FIXME: else: what to do with still-unsaved data in the widget?? + dd_close(dd); +- problem_data_reload_from_dump_dir(); +- update_gui_state_from_problem_data(/* don't update selected event */ 0); + } + } + +@@ -777,7 +775,11 @@ static void tv_details_row_activated( + load_text_to_text_view(GTK_TEXT_VIEW(textview), item_name); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) ++ { + save_text_from_text_view(GTK_TEXT_VIEW(textview), item_name); ++ problem_data_reload_from_dump_dir(); ++ update_gui_state_from_problem_data(/* don't update selected event */ 0); ++ } + + gtk_widget_destroy(textview); + gtk_widget_destroy(scrolled); +@@ -2709,7 +2711,8 @@ static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer us + * these tabs will be lost */ + save_items_from_notepad(); + save_text_from_text_view(g_tv_comment, FILENAME_COMMENT); +- ++ problem_data_reload_from_dump_dir(); ++ update_gui_state_from_problem_data(/* don't update selected event */ 0); + + if (pages[PAGENO_SUMMARY].page_widget == page) + {",826,1062,2048 +15441,"bool GLES2DecoderImpl::SimulateFixedAttribs( + const char* function_name, + GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { + DCHECK(simulated); + *simulated = false; + if (gl_version_info().SupportsFixedType()) + return true; + + if (!state_.vertex_attrib_manager->HaveFixedAttribs()) { + return true; + } + + LOCAL_PERFORMANCE_WARNING( + ""GL_FIXED attributes have a significant performance penalty""); + + + base::CheckedNumeric elements_needed = 0; + const VertexAttribManager::VertexAttribList& enabled_attribs = + state_.vertex_attrib_manager->GetEnabledVertexAttribs(); + for (VertexAttribManager::VertexAttribList::const_iterator it = + enabled_attribs.begin(); it != enabled_attribs.end(); ++it) { + const VertexAttrib* attrib = *it; + const Program::VertexAttrib* attrib_info = + state_.current_program->GetAttribInfoByLocation(attrib->index()); + GLuint max_accessed = attrib->MaxVertexAccessed(primcount, + max_vertex_accessed); + GLuint num_vertices = max_accessed + 1; + if (num_vertices == 0) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""Simulating attrib 0""); + return false; + } + if (attrib_info && + attrib->CanAccess(max_accessed) && + attrib->type() == GL_FIXED) { + elements_needed += base::CheckMul(num_vertices, attrib->size()); + } + } + + const uint32_t kSizeOfFloat = sizeof(float); // NOLINT + uint32_t size_needed = 0; + if (!base::CheckMul(elements_needed, kSizeOfFloat) + .AssignIfValid(&size_needed) || + size_needed > 0x7FFFFFFFU) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""simulating GL_FIXED attribs""); + return false; + } + + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); + + api()->glBindBufferFn(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_); + if (static_cast(size_needed) > fixed_attrib_buffer_size_) { + api()->glBufferDataFn(GL_ARRAY_BUFFER, size_needed, nullptr, + GL_DYNAMIC_DRAW); + GLenum error = api()->glGetErrorFn(); + if (error != GL_NO_ERROR) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""simulating GL_FIXED attribs""); + return false; + } + } + + GLintptr offset = 0; + for (VertexAttribManager::VertexAttribList::const_iterator it = + enabled_attribs.begin(); it != enabled_attribs.end(); ++it) { + const VertexAttrib* attrib = *it; + const Program::VertexAttrib* attrib_info = + state_.current_program->GetAttribInfoByLocation(attrib->index()); + GLuint max_accessed = attrib->MaxVertexAccessed(primcount, + max_vertex_accessed); + GLuint num_vertices = max_accessed + 1; + if (num_vertices == 0) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""Simulating attrib 0""); + return false; + } + if (attrib_info && + attrib->CanAccess(max_accessed) && + attrib->type() == GL_FIXED) { + int num_elements = attrib->size() * num_vertices; + const int src_size = num_elements * sizeof(int32_t); + const int dst_size = num_elements * sizeof(float); + std::unique_ptr data(new float[num_elements]); + const int32_t* src = reinterpret_cast( + attrib->buffer()->GetRange(attrib->offset(), src_size)); + const int32_t* end = src + num_elements; + float* dst = data.get(); + while (src != end) { + *dst++ = static_cast(*src++) / 65536.0f; + } + api()->glBufferSubDataFn(GL_ARRAY_BUFFER, offset, dst_size, data.get()); + api()->glVertexAttribPointerFn(attrib->index(), attrib->size(), GL_FLOAT, + false, 0, + reinterpret_cast(offset)); + offset += dst_size; + } + } + *simulated = true; + return true; +} +",0,"bool GLES2DecoderImpl::SimulateFixedAttribs( + const char* function_name, + GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { + DCHECK(simulated); + *simulated = false; + if (gl_version_info().SupportsFixedType()) + return true; + + if (!state_.vertex_attrib_manager->HaveFixedAttribs()) { + return true; + } + + LOCAL_PERFORMANCE_WARNING( + ""GL_FIXED attributes have a significant performance penalty""); + + + base::CheckedNumeric elements_needed = 0; + const VertexAttribManager::VertexAttribList& enabled_attribs = + state_.vertex_attrib_manager->GetEnabledVertexAttribs(); + for (VertexAttribManager::VertexAttribList::const_iterator it = + enabled_attribs.begin(); it != enabled_attribs.end(); ++it) { + const VertexAttrib* attrib = *it; + const Program::VertexAttrib* attrib_info = + state_.current_program->GetAttribInfoByLocation(attrib->index()); + GLuint max_accessed = attrib->MaxVertexAccessed(primcount, + max_vertex_accessed); + GLuint num_vertices = max_accessed + 1; + if (num_vertices == 0) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""Simulating attrib 0""); + return false; + } + if (attrib_info && + attrib->CanAccess(max_accessed) && + attrib->type() == GL_FIXED) { + elements_needed += base::CheckMul(num_vertices, attrib->size()); + } + } + + const uint32_t kSizeOfFloat = sizeof(float); // NOLINT + uint32_t size_needed = 0; + if (!base::CheckMul(elements_needed, kSizeOfFloat) + .AssignIfValid(&size_needed) || + size_needed > 0x7FFFFFFFU) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""simulating GL_FIXED attribs""); + return false; + } + + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); + + api()->glBindBufferFn(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_); + if (static_cast(size_needed) > fixed_attrib_buffer_size_) { + api()->glBufferDataFn(GL_ARRAY_BUFFER, size_needed, nullptr, + GL_DYNAMIC_DRAW); + GLenum error = api()->glGetErrorFn(); + if (error != GL_NO_ERROR) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""simulating GL_FIXED attribs""); + return false; + } + } + + GLintptr offset = 0; + for (VertexAttribManager::VertexAttribList::const_iterator it = + enabled_attribs.begin(); it != enabled_attribs.end(); ++it) { + const VertexAttrib* attrib = *it; + const Program::VertexAttrib* attrib_info = + state_.current_program->GetAttribInfoByLocation(attrib->index()); + GLuint max_accessed = attrib->MaxVertexAccessed(primcount, + max_vertex_accessed); + GLuint num_vertices = max_accessed + 1; + if (num_vertices == 0) { + LOCAL_SET_GL_ERROR( + GL_OUT_OF_MEMORY, function_name, ""Simulating attrib 0""); + return false; + } + if (attrib_info && + attrib->CanAccess(max_accessed) && + attrib->type() == GL_FIXED) { + int num_elements = attrib->size() * num_vertices; + const int src_size = num_elements * sizeof(int32_t); + const int dst_size = num_elements * sizeof(float); + std::unique_ptr data(new float[num_elements]); + const int32_t* src = reinterpret_cast( + attrib->buffer()->GetRange(attrib->offset(), src_size)); + const int32_t* end = src + num_elements; + float* dst = data.get(); + while (src != end) { + *dst++ = static_cast(*src++) / 65536.0f; + } + api()->glBufferSubDataFn(GL_ARRAY_BUFFER, offset, dst_size, data.get()); + api()->glVertexAttribPointerFn(attrib->index(), attrib->size(), GL_FLOAT, + false, 0, + reinterpret_cast(offset)); + offset += dst_size; + } + } + *simulated = true; + return true; +} +","@@ -17209,6 +17209,13 @@ error::Error GLES2DecoderImpl::HandleBeginQueryEXT( + return error::kNoError; + } + break; ++ case GL_PROGRAM_COMPLETION_QUERY_CHROMIUM: ++ if (!features().chromium_completion_query) { ++ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, ""glBeginQueryEXT"", ++ ""not enabled for program completion queries""); ++ return error::kNoError; ++ } ++ break; + case GL_SAMPLES_PASSED_ARB: + if (!features().occlusion_query) { + LOCAL_SET_GL_ERROR(",926,1162,2048 +3653,"xfs_da3_node_toosmall( + struct xfs_da_state *state, + int *action) +{ + struct xfs_da_intnode *node; + struct xfs_da_state_blk *blk; + struct xfs_da_blkinfo *info; + xfs_dablk_t blkno; + struct xfs_buf *bp; + struct xfs_da3_icnode_hdr nodehdr; + int count; + int forward; + int error; + int retval; + int i; + struct xfs_inode *dp = state->args->dp; + + trace_xfs_da_node_toosmall(state->args); + + /* + * Check for the degenerate case of the block being over 50% full. + * If so, it's not worth even looking to see if we might be able + * to coalesce with a sibling. + */ + blk = &state->path.blk[ state->path.active-1 ]; + info = blk->bp->b_addr; + node = (xfs_da_intnode_t *)info; + dp->d_ops->node_hdr_from_disk(&nodehdr, node); + if (nodehdr.count > (state->node_ents >> 1)) { + *action = 0; /* blk over 50%, don't try to join */ + return(0); /* blk over 50%, don't try to join */ + } + + /* + * Check for the degenerate case of the block being empty. + * If the block is empty, we'll simply delete it, no need to + * coalesce it with a sibling block. We choose (arbitrarily) + * to merge with the forward block unless it is NULL. + */ + if (nodehdr.count == 0) { + /* + * Make altpath point to the block we want to keep and + * path point to the block we want to drop (this one). + */ + forward = (info->forw != 0); + memcpy(&state->altpath, &state->path, sizeof(state->path)); + error = xfs_da3_path_shift(state, &state->altpath, forward, + 0, &retval); + if (error) + return(error); + if (retval) { + *action = 0; + } else { + *action = 2; + } + return(0); + } + + /* + * Examine each sibling block to see if we can coalesce with + * at least 25% free space to spare. We need to figure out + * whether to merge with the forward or the backward block. + * We prefer coalescing with the lower numbered sibling so as + * to shrink a directory over time. + */ + count = state->node_ents; + count -= state->node_ents >> 2; + count -= nodehdr.count; + + /* start with smaller blk num */ + forward = nodehdr.forw < nodehdr.back; + for (i = 0; i < 2; forward = !forward, i++) { + struct xfs_da3_icnode_hdr thdr; + if (forward) + blkno = nodehdr.forw; + else + blkno = nodehdr.back; + if (blkno == 0) + continue; + error = xfs_da3_node_read(state->args->trans, dp, + blkno, -1, &bp, state->args->whichfork); + if (error) + return(error); + + node = bp->b_addr; + dp->d_ops->node_hdr_from_disk(&thdr, node); + xfs_trans_brelse(state->args->trans, bp); + + if (count - thdr.count >= 0) + break; /* fits with at least 25% to spare */ + } + if (i >= 2) { + *action = 0; + return 0; + } + + /* + * Make altpath point to the block we want to keep (the lower + * numbered block) and path point to the block we want to drop. + */ + memcpy(&state->altpath, &state->path, sizeof(state->path)); + if (blkno < blk->blkno) { + error = xfs_da3_path_shift(state, &state->altpath, forward, + 0, &retval); + } else { + error = xfs_da3_path_shift(state, &state->path, forward, + 0, &retval); + } + if (error) + return error; + if (retval) { + *action = 0; + return 0; + } + *action = 1; + return 0; +} +",0,"xfs_da3_node_toosmall( + struct xfs_da_state *state, + int *action) +{ + struct xfs_da_intnode *node; + struct xfs_da_state_blk *blk; + struct xfs_da_blkinfo *info; + xfs_dablk_t blkno; + struct xfs_buf *bp; + struct xfs_da3_icnode_hdr nodehdr; + int count; + int forward; + int error; + int retval; + int i; + struct xfs_inode *dp = state->args->dp; + + trace_xfs_da_node_toosmall(state->args); + + /* + * Check for the degenerate case of the block being over 50% full. + * If so, it's not worth even looking to see if we might be able + * to coalesce with a sibling. + */ + blk = &state->path.blk[ state->path.active-1 ]; + info = blk->bp->b_addr; + node = (xfs_da_intnode_t *)info; + dp->d_ops->node_hdr_from_disk(&nodehdr, node); + if (nodehdr.count > (state->node_ents >> 1)) { + *action = 0; /* blk over 50%, don't try to join */ + return(0); /* blk over 50%, don't try to join */ + } + + /* + * Check for the degenerate case of the block being empty. + * If the block is empty, we'll simply delete it, no need to + * coalesce it with a sibling block. We choose (arbitrarily) + * to merge with the forward block unless it is NULL. + */ + if (nodehdr.count == 0) { + /* + * Make altpath point to the block we want to keep and + * path point to the block we want to drop (this one). + */ + forward = (info->forw != 0); + memcpy(&state->altpath, &state->path, sizeof(state->path)); + error = xfs_da3_path_shift(state, &state->altpath, forward, + 0, &retval); + if (error) + return(error); + if (retval) { + *action = 0; + } else { + *action = 2; + } + return(0); + } + + /* + * Examine each sibling block to see if we can coalesce with + * at least 25% free space to spare. We need to figure out + * whether to merge with the forward or the backward block. + * We prefer coalescing with the lower numbered sibling so as + * to shrink a directory over time. + */ + count = state->node_ents; + count -= state->node_ents >> 2; + count -= nodehdr.count; + + /* start with smaller blk num */ + forward = nodehdr.forw < nodehdr.back; + for (i = 0; i < 2; forward = !forward, i++) { + struct xfs_da3_icnode_hdr thdr; + if (forward) + blkno = nodehdr.forw; + else + blkno = nodehdr.back; + if (blkno == 0) + continue; + error = xfs_da3_node_read(state->args->trans, dp, + blkno, -1, &bp, state->args->whichfork); + if (error) + return(error); + + node = bp->b_addr; + dp->d_ops->node_hdr_from_disk(&thdr, node); + xfs_trans_brelse(state->args->trans, bp); + + if (count - thdr.count >= 0) + break; /* fits with at least 25% to spare */ + } + if (i >= 2) { + *action = 0; + return 0; + } + + /* + * Make altpath point to the block we want to keep (the lower + * numbered block) and path point to the block we want to drop. + */ + memcpy(&state->altpath, &state->path, sizeof(state->path)); + if (blkno < blk->blkno) { + error = xfs_da3_path_shift(state, &state->altpath, forward, + 0, &retval); + } else { + error = xfs_da3_path_shift(state, &state->path, forward, + 0, &retval); + } + if (error) + return error; + if (retval) { + *action = 0; + return 0; + } + *action = 1; + return 0; +} +","@@ -1295,7 +1295,7 @@ xfs_da3_fixhashpath( + node = blk->bp->b_addr; + dp->d_ops->node_hdr_from_disk(&nodehdr, node); + btree = dp->d_ops->node_tree_p(node); +- if (be32_to_cpu(btree->hashval) == lasthash) ++ if (be32_to_cpu(btree[blk->index].hashval) == lasthash) + break; + blk->hashval = lasthash; + btree[blk->index].hashval = cpu_to_be32(lasthash);",1011,1247,2048 +4001,"static int __init do_floppy_init(void) +{ + int i, unit, drive, err; + + set_debugt(); + interruptjiffies = resultjiffies = jiffies; + +#if defined(CONFIG_PPC) + if (check_legacy_ioport(FDC1)) + return -ENODEV; +#endif + + raw_cmd = NULL; + + floppy_wq = alloc_ordered_workqueue(""floppy"", 0); + if (!floppy_wq) + return -ENOMEM; + + for (drive = 0; drive < N_DRIVE; drive++) { + disks[drive] = alloc_disk(1); + if (!disks[drive]) { + err = -ENOMEM; + goto out_put_disk; + } + + disks[drive]->queue = blk_init_queue(do_fd_request, &floppy_lock); + if (!disks[drive]->queue) { + err = -ENOMEM; + goto out_put_disk; + } + + blk_queue_max_hw_sectors(disks[drive]->queue, 64); + disks[drive]->major = FLOPPY_MAJOR; + disks[drive]->first_minor = TOMINOR(drive); + disks[drive]->fops = &floppy_fops; + sprintf(disks[drive]->disk_name, ""fd%d"", drive); + + init_timer(&motor_off_timer[drive]); + motor_off_timer[drive].data = drive; + motor_off_timer[drive].function = motor_off_callback; + } + + err = register_blkdev(FLOPPY_MAJOR, ""fd""); + if (err) + goto out_put_disk; + + err = platform_driver_register(&floppy_driver); + if (err) + goto out_unreg_blkdev; + + blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, + floppy_find, NULL, NULL); + + for (i = 0; i < 256; i++) + if (ITYPE(i)) + floppy_sizes[i] = floppy_type[ITYPE(i)].size; + else + floppy_sizes[i] = MAX_DISK_SIZE << 1; + + reschedule_timeout(MAXTIMEOUT, ""floppy init""); + config_types(); + + for (i = 0; i < N_FDC; i++) { + fdc = i; + memset(FDCS, 0, sizeof(*FDCS)); + FDCS->dtr = -1; + FDCS->dor = 0x4; +#if defined(__sparc__) || defined(__mc68000__) + /*sparcs/sun3x don't have a DOR reset which we can fall back on to */ +#ifdef __mc68000__ + if (MACH_IS_SUN3X) +#endif + FDCS->version = FDC_82072A; +#endif + } + + use_virtual_dma = can_use_virtual_dma & 1; + fdc_state[0].address = FDC1; + if (fdc_state[0].address == -1) { + cancel_delayed_work(&fd_timeout); + err = -ENODEV; + goto out_unreg_region; + } +#if N_FDC > 1 + fdc_state[1].address = FDC2; +#endif + + fdc = 0; /* reset fdc in case of unexpected interrupt */ + err = floppy_grab_irq_and_dma(); + if (err) { + cancel_delayed_work(&fd_timeout); + err = -EBUSY; + goto out_unreg_region; + } + + /* initialise drive state */ + for (drive = 0; drive < N_DRIVE; drive++) { + memset(UDRS, 0, sizeof(*UDRS)); + memset(UDRWE, 0, sizeof(*UDRWE)); + set_bit(FD_DISK_NEWCHANGE_BIT, &UDRS->flags); + set_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); + set_bit(FD_VERIFY_BIT, &UDRS->flags); + UDRS->fd_device = -1; + floppy_track_buffer = NULL; + max_buffer_sectors = 0; + } + /* + * Small 10 msec delay to let through any interrupt that + * initialization might have triggered, to not + * confuse detection: + */ + msleep(10); + + for (i = 0; i < N_FDC; i++) { + fdc = i; + FDCS->driver_version = FD_DRIVER_VERSION; + for (unit = 0; unit < 4; unit++) + FDCS->track[unit] = 0; + if (FDCS->address == -1) + continue; + FDCS->rawcmd = 2; + if (user_reset_fdc(-1, FD_RESET_ALWAYS, false)) { + /* free ioports reserved by floppy_grab_irq_and_dma() */ + floppy_release_regions(fdc); + FDCS->address = -1; + FDCS->version = FDC_NONE; + continue; + } + /* Try to determine the floppy controller type */ + FDCS->version = get_fdc_version(); + if (FDCS->version == FDC_NONE) { + /* free ioports reserved by floppy_grab_irq_and_dma() */ + floppy_release_regions(fdc); + FDCS->address = -1; + continue; + } + if (can_use_virtual_dma == 2 && FDCS->version < FDC_82072A) + can_use_virtual_dma = 0; + + have_no_fdc = 0; + /* Not all FDCs seem to be able to handle the version command + * properly, so force a reset for the standard FDC clones, + * to avoid interrupt garbage. + */ + user_reset_fdc(-1, FD_RESET_ALWAYS, false); + } + fdc = 0; + cancel_delayed_work(&fd_timeout); + current_drive = 0; + initialized = true; + if (have_no_fdc) { + DPRINT(""no floppy controllers found\n""); + err = have_no_fdc; + goto out_release_dma; + } + + for (drive = 0; drive < N_DRIVE; drive++) { + if (!floppy_available(drive)) + continue; + + floppy_device[drive].name = floppy_device_name; + floppy_device[drive].id = drive; + floppy_device[drive].dev.release = floppy_device_release; + + err = platform_device_register(&floppy_device[drive]); + if (err) + goto out_remove_drives; + + err = device_create_file(&floppy_device[drive].dev, + &dev_attr_cmos); + if (err) + goto out_unreg_platform_dev; + + /* to be cleaned up... */ + disks[drive]->private_data = (void *)(long)drive; + disks[drive]->flags |= GENHD_FL_REMOVABLE; + disks[drive]->driverfs_dev = &floppy_device[drive].dev; + add_disk(disks[drive]); + } + + return 0; + +out_unreg_platform_dev: + platform_device_unregister(&floppy_device[drive]); +out_remove_drives: + while (drive--) { + if (floppy_available(drive)) { + del_gendisk(disks[drive]); + device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); + platform_device_unregister(&floppy_device[drive]); + } + } +out_release_dma: + if (atomic_read(&usage_count)) + floppy_release_irq_and_dma(); +out_unreg_region: + blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); + platform_driver_unregister(&floppy_driver); +out_unreg_blkdev: + unregister_blkdev(FLOPPY_MAJOR, ""fd""); +out_put_disk: + destroy_workqueue(floppy_wq); + for (drive = 0; drive < N_DRIVE; drive++) { + if (!disks[drive]) + break; + if (disks[drive]->queue) { + del_timer_sync(&motor_off_timer[drive]); + blk_cleanup_queue(disks[drive]->queue); + disks[drive]->queue = NULL; + } + put_disk(disks[drive]); + } + return err; +} +",0,"static int __init do_floppy_init(void) +{ + int i, unit, drive, err; + + set_debugt(); + interruptjiffies = resultjiffies = jiffies; + +#if defined(CONFIG_PPC) + if (check_legacy_ioport(FDC1)) + return -ENODEV; +#endif + + raw_cmd = NULL; + + floppy_wq = alloc_ordered_workqueue(""floppy"", 0); + if (!floppy_wq) + return -ENOMEM; + + for (drive = 0; drive < N_DRIVE; drive++) { + disks[drive] = alloc_disk(1); + if (!disks[drive]) { + err = -ENOMEM; + goto out_put_disk; + } + + disks[drive]->queue = blk_init_queue(do_fd_request, &floppy_lock); + if (!disks[drive]->queue) { + err = -ENOMEM; + goto out_put_disk; + } + + blk_queue_max_hw_sectors(disks[drive]->queue, 64); + disks[drive]->major = FLOPPY_MAJOR; + disks[drive]->first_minor = TOMINOR(drive); + disks[drive]->fops = &floppy_fops; + sprintf(disks[drive]->disk_name, ""fd%d"", drive); + + init_timer(&motor_off_timer[drive]); + motor_off_timer[drive].data = drive; + motor_off_timer[drive].function = motor_off_callback; + } + + err = register_blkdev(FLOPPY_MAJOR, ""fd""); + if (err) + goto out_put_disk; + + err = platform_driver_register(&floppy_driver); + if (err) + goto out_unreg_blkdev; + + blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, + floppy_find, NULL, NULL); + + for (i = 0; i < 256; i++) + if (ITYPE(i)) + floppy_sizes[i] = floppy_type[ITYPE(i)].size; + else + floppy_sizes[i] = MAX_DISK_SIZE << 1; + + reschedule_timeout(MAXTIMEOUT, ""floppy init""); + config_types(); + + for (i = 0; i < N_FDC; i++) { + fdc = i; + memset(FDCS, 0, sizeof(*FDCS)); + FDCS->dtr = -1; + FDCS->dor = 0x4; +#if defined(__sparc__) || defined(__mc68000__) + /*sparcs/sun3x don't have a DOR reset which we can fall back on to */ +#ifdef __mc68000__ + if (MACH_IS_SUN3X) +#endif + FDCS->version = FDC_82072A; +#endif + } + + use_virtual_dma = can_use_virtual_dma & 1; + fdc_state[0].address = FDC1; + if (fdc_state[0].address == -1) { + cancel_delayed_work(&fd_timeout); + err = -ENODEV; + goto out_unreg_region; + } +#if N_FDC > 1 + fdc_state[1].address = FDC2; +#endif + + fdc = 0; /* reset fdc in case of unexpected interrupt */ + err = floppy_grab_irq_and_dma(); + if (err) { + cancel_delayed_work(&fd_timeout); + err = -EBUSY; + goto out_unreg_region; + } + + /* initialise drive state */ + for (drive = 0; drive < N_DRIVE; drive++) { + memset(UDRS, 0, sizeof(*UDRS)); + memset(UDRWE, 0, sizeof(*UDRWE)); + set_bit(FD_DISK_NEWCHANGE_BIT, &UDRS->flags); + set_bit(FD_DISK_CHANGED_BIT, &UDRS->flags); + set_bit(FD_VERIFY_BIT, &UDRS->flags); + UDRS->fd_device = -1; + floppy_track_buffer = NULL; + max_buffer_sectors = 0; + } + /* + * Small 10 msec delay to let through any interrupt that + * initialization might have triggered, to not + * confuse detection: + */ + msleep(10); + + for (i = 0; i < N_FDC; i++) { + fdc = i; + FDCS->driver_version = FD_DRIVER_VERSION; + for (unit = 0; unit < 4; unit++) + FDCS->track[unit] = 0; + if (FDCS->address == -1) + continue; + FDCS->rawcmd = 2; + if (user_reset_fdc(-1, FD_RESET_ALWAYS, false)) { + /* free ioports reserved by floppy_grab_irq_and_dma() */ + floppy_release_regions(fdc); + FDCS->address = -1; + FDCS->version = FDC_NONE; + continue; + } + /* Try to determine the floppy controller type */ + FDCS->version = get_fdc_version(); + if (FDCS->version == FDC_NONE) { + /* free ioports reserved by floppy_grab_irq_and_dma() */ + floppy_release_regions(fdc); + FDCS->address = -1; + continue; + } + if (can_use_virtual_dma == 2 && FDCS->version < FDC_82072A) + can_use_virtual_dma = 0; + + have_no_fdc = 0; + /* Not all FDCs seem to be able to handle the version command + * properly, so force a reset for the standard FDC clones, + * to avoid interrupt garbage. + */ + user_reset_fdc(-1, FD_RESET_ALWAYS, false); + } + fdc = 0; + cancel_delayed_work(&fd_timeout); + current_drive = 0; + initialized = true; + if (have_no_fdc) { + DPRINT(""no floppy controllers found\n""); + err = have_no_fdc; + goto out_release_dma; + } + + for (drive = 0; drive < N_DRIVE; drive++) { + if (!floppy_available(drive)) + continue; + + floppy_device[drive].name = floppy_device_name; + floppy_device[drive].id = drive; + floppy_device[drive].dev.release = floppy_device_release; + + err = platform_device_register(&floppy_device[drive]); + if (err) + goto out_remove_drives; + + err = device_create_file(&floppy_device[drive].dev, + &dev_attr_cmos); + if (err) + goto out_unreg_platform_dev; + + /* to be cleaned up... */ + disks[drive]->private_data = (void *)(long)drive; + disks[drive]->flags |= GENHD_FL_REMOVABLE; + disks[drive]->driverfs_dev = &floppy_device[drive].dev; + add_disk(disks[drive]); + } + + return 0; + +out_unreg_platform_dev: + platform_device_unregister(&floppy_device[drive]); +out_remove_drives: + while (drive--) { + if (floppy_available(drive)) { + del_gendisk(disks[drive]); + device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); + platform_device_unregister(&floppy_device[drive]); + } + } +out_release_dma: + if (atomic_read(&usage_count)) + floppy_release_irq_and_dma(); +out_unreg_region: + blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); + platform_driver_unregister(&floppy_driver); +out_unreg_blkdev: + unregister_blkdev(FLOPPY_MAJOR, ""fd""); +out_put_disk: + destroy_workqueue(floppy_wq); + for (drive = 0; drive < N_DRIVE; drive++) { + if (!disks[drive]) + break; + if (disks[drive]->queue) { + del_timer_sync(&motor_off_timer[drive]); + blk_cleanup_queue(disks[drive]->queue); + disks[drive]->queue = NULL; + } + put_disk(disks[drive]); + } + return err; +} +","@@ -3067,7 +3067,10 @@ static int raw_cmd_copyout(int cmd, void __user *param, + int ret; + + while (ptr) { +- ret = copy_to_user(param, ptr, sizeof(*ptr)); ++ struct floppy_raw_cmd cmd = *ptr; ++ cmd.next = NULL; ++ cmd.kernel_data = NULL; ++ ret = copy_to_user(param, &cmd, sizeof(cmd)); + if (ret) + return -EFAULT; + param += sizeof(struct floppy_raw_cmd);",1767,2003,2048 +15946,"PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) + : client_(client), + current_zoom_(1.0), + current_rotation_(0), + doc_(nullptr), + form_(nullptr), + defer_page_unload_(false), + selecting_(false), + mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA, + PDFiumPage::LinkTarget()), + in_form_text_area_(false), + editable_form_text_area_(false), + mouse_left_button_down_(false), + permissions_(0), + permissions_handler_revision_(-1), + fpdf_availability_(nullptr), + last_page_mouse_down_(-1), + most_visible_page_(-1), + called_do_document_action_(false), + render_grayscale_(false), + render_annots_(true) { + find_factory_.Initialize(this); + password_factory_.Initialize(this); + + file_access_.m_FileLen = 0; + file_access_.m_GetBlock = &GetBlock; + file_access_.m_Param = this; + + file_availability_.version = 1; + file_availability_.IsDataAvail = &IsDataAvail; + file_availability_.engine = this; + + download_hints_.version = 1; + download_hints_.AddSegment = &AddSegment; + download_hints_.engine = this; + + FPDF_FORMFILLINFO::version = 1; + FPDF_FORMFILLINFO::m_pJsPlatform = this; + FPDF_FORMFILLINFO::Release = nullptr; + FPDF_FORMFILLINFO::FFI_Invalidate = Form_Invalidate; + FPDF_FORMFILLINFO::FFI_OutputSelectedRect = Form_OutputSelectedRect; + FPDF_FORMFILLINFO::FFI_SetCursor = Form_SetCursor; + FPDF_FORMFILLINFO::FFI_SetTimer = Form_SetTimer; + FPDF_FORMFILLINFO::FFI_KillTimer = Form_KillTimer; + FPDF_FORMFILLINFO::FFI_GetLocalTime = Form_GetLocalTime; + FPDF_FORMFILLINFO::FFI_OnChange = Form_OnChange; + FPDF_FORMFILLINFO::FFI_GetPage = Form_GetPage; + FPDF_FORMFILLINFO::FFI_GetCurrentPage = Form_GetCurrentPage; + FPDF_FORMFILLINFO::FFI_GetRotation = Form_GetRotation; + FPDF_FORMFILLINFO::FFI_ExecuteNamedAction = Form_ExecuteNamedAction; + FPDF_FORMFILLINFO::FFI_SetTextFieldFocus = Form_SetTextFieldFocus; + FPDF_FORMFILLINFO::FFI_DoURIAction = Form_DoURIAction; + FPDF_FORMFILLINFO::FFI_DoGoToAction = Form_DoGoToAction; +#if defined(PDF_ENABLE_XFA) + FPDF_FORMFILLINFO::version = 2; + FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo; + FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret; + FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage; + FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex; + FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect; + FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; + FPDF_FORMFILLINFO::FFI_PageEvent = nullptr; + FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; + FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; + FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; + FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo; + FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL; + FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile; + FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL; + FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage; +#endif // defined(PDF_ENABLE_XFA) + IPDF_JSPLATFORM::version = 3; + IPDF_JSPLATFORM::app_alert = Form_Alert; + IPDF_JSPLATFORM::app_beep = Form_Beep; + IPDF_JSPLATFORM::app_response = Form_Response; + IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; + IPDF_JSPLATFORM::Doc_mail = Form_Mail; + IPDF_JSPLATFORM::Doc_print = Form_Print; + IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; + IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; + IPDF_JSPLATFORM::Field_browse = nullptr; + + IFSDK_PAUSE::version = 1; + IFSDK_PAUSE::user = nullptr; + IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; + +#if defined(OS_LINUX) + pp::Instance* instance = client_->GetPluginInstance(); + if (instance) + g_last_instance_id = instance->pp_instance(); +#endif +} +",0,"PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) + : client_(client), + current_zoom_(1.0), + current_rotation_(0), + doc_(nullptr), + form_(nullptr), + defer_page_unload_(false), + selecting_(false), + mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA, + PDFiumPage::LinkTarget()), + in_form_text_area_(false), + editable_form_text_area_(false), + mouse_left_button_down_(false), + permissions_(0), + permissions_handler_revision_(-1), + fpdf_availability_(nullptr), + last_page_mouse_down_(-1), + most_visible_page_(-1), + called_do_document_action_(false), + render_grayscale_(false), + render_annots_(true) { + find_factory_.Initialize(this); + password_factory_.Initialize(this); + + file_access_.m_FileLen = 0; + file_access_.m_GetBlock = &GetBlock; + file_access_.m_Param = this; + + file_availability_.version = 1; + file_availability_.IsDataAvail = &IsDataAvail; + file_availability_.engine = this; + + download_hints_.version = 1; + download_hints_.AddSegment = &AddSegment; + download_hints_.engine = this; + + FPDF_FORMFILLINFO::version = 1; + FPDF_FORMFILLINFO::m_pJsPlatform = this; + FPDF_FORMFILLINFO::Release = nullptr; + FPDF_FORMFILLINFO::FFI_Invalidate = Form_Invalidate; + FPDF_FORMFILLINFO::FFI_OutputSelectedRect = Form_OutputSelectedRect; + FPDF_FORMFILLINFO::FFI_SetCursor = Form_SetCursor; + FPDF_FORMFILLINFO::FFI_SetTimer = Form_SetTimer; + FPDF_FORMFILLINFO::FFI_KillTimer = Form_KillTimer; + FPDF_FORMFILLINFO::FFI_GetLocalTime = Form_GetLocalTime; + FPDF_FORMFILLINFO::FFI_OnChange = Form_OnChange; + FPDF_FORMFILLINFO::FFI_GetPage = Form_GetPage; + FPDF_FORMFILLINFO::FFI_GetCurrentPage = Form_GetCurrentPage; + FPDF_FORMFILLINFO::FFI_GetRotation = Form_GetRotation; + FPDF_FORMFILLINFO::FFI_ExecuteNamedAction = Form_ExecuteNamedAction; + FPDF_FORMFILLINFO::FFI_SetTextFieldFocus = Form_SetTextFieldFocus; + FPDF_FORMFILLINFO::FFI_DoURIAction = Form_DoURIAction; + FPDF_FORMFILLINFO::FFI_DoGoToAction = Form_DoGoToAction; +#if defined(PDF_ENABLE_XFA) + FPDF_FORMFILLINFO::version = 2; + FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo; + FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret; + FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage; + FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex; + FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect; + FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; + FPDF_FORMFILLINFO::FFI_PageEvent = nullptr; + FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; + FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; + FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; + FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo; + FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL; + FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile; + FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL; + FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage; +#endif // defined(PDF_ENABLE_XFA) + IPDF_JSPLATFORM::version = 3; + IPDF_JSPLATFORM::app_alert = Form_Alert; + IPDF_JSPLATFORM::app_beep = Form_Beep; + IPDF_JSPLATFORM::app_response = Form_Response; + IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; + IPDF_JSPLATFORM::Doc_mail = Form_Mail; + IPDF_JSPLATFORM::Doc_print = Form_Print; + IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; + IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; + IPDF_JSPLATFORM::Field_browse = nullptr; + + IFSDK_PAUSE::version = 1; + IFSDK_PAUSE::user = nullptr; + IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; + +#if defined(OS_LINUX) + pp::Instance* instance = client_->GetPluginInstance(); + if (instance) + g_last_instance_id = instance->pp_instance(); +#endif +} +","@@ -1405,9 +1405,15 @@ bool PDFiumEngine::HandleEvent(const pp::InputEvent& event) { + + DCHECK(defer_page_unload_); + defer_page_unload_ = false; +- for (int page_index : deferred_page_unloads_) ++ ++ // Store the pages to unload away because the act of unloading pages can cause ++ // there to be more pages to unload. We leave those extra pages to be unloaded ++ // on the next go around. ++ std::vector pages_to_unload; ++ std::swap(pages_to_unload, deferred_page_unloads_); ++ for (int page_index : pages_to_unload) + pages_[page_index]->Unload(); +- deferred_page_unloads_.clear(); ++ + return rv; + } + ",1088,1324,2048 +960,"int ssl3_client_hello(SSL *s) +{ + unsigned char *buf; + unsigned char *p, *d; + int i; + unsigned long l; +#ifndef OPENSSL_NO_COMP + int j; + SSL_COMP *comp; +#endif + + buf = (unsigned char *)s->init_buf->data; + if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { + SSL_SESSION *sess = s->session; + if ((sess == NULL) || (sess->ssl_version != s->version) || +#ifdef OPENSSL_NO_TLSEXT + !sess->session_id_length || +#else + /* + * In the case of EAP-FAST, we can have a pre-shared + * ""ticket"" without a session ID. + */ + (!sess->session_id_length && !sess->tlsext_tick) || +#endif + (sess->not_resumable)) { + if (!ssl_get_new_session(s, 0)) + goto err; + } + /* else use the pre-loaded session */ + + p = s->s3->client_random; + + if (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0) + goto err; + + /* Do the message type and length last */ + d = p = &(buf[4]); + + /*- + * version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ +#if 0 + *(p++) = s->version >> 8; + *(p++) = s->version & 0xff; + s->client_version = s->version; +#else + *(p++) = s->client_version >> 8; + *(p++) = s->client_version & 0xff; +#endif + + /* Random stuff */ + memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); + p += SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i = 0; + else + i = s->session->session_id_length; + *(p++) = i; + if (i != 0) { + if (i > (int)sizeof(s->session->session_id)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + memcpy(p, s->session->session_id, i); + p += i; + } + + /* Ciphers supported */ + i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0); + if (i == 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } +#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH + /* + * Some servers hang if client hello > 256 bytes as hack workaround + * chop number of supported ciphers to keep it well below this if we + * use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; +#endif + s2n(i, p); + p += i; + + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + *(p++) = 1; +#else + + if ((s->options & SSL_OP_NO_COMPRESSION) + || !s->ctx->comp_methods) + j = 0; + else + j = sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++) = 1 + j; + for (i = 0; i < j; i++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); + *(p++) = comp->id; + } +#endif + *(p++) = 0; /* Add the NULL method */ + +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions */ + if (ssl_prepare_clienthello_tlsext(s) <= 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = + ssl_add_clienthello_tlsext(s, p, + buf + SSL3_RT_MAX_PLAIN_LENGTH)) == + NULL) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } +#endif + + l = (p - d); + d = buf; + *(d++) = SSL3_MT_CLIENT_HELLO; + l2n3(l, d); + + s->state = SSL3_ST_CW_CLNT_HELLO_B; + /* number of bytes to write */ + s->init_num = p - buf; + s->init_off = 0; + } + + /* SSL3_ST_CW_CLNT_HELLO_B */ + return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); + err: + s->state = SSL_ST_ERR; + return (-1); +} +",0,"int ssl3_client_hello(SSL *s) +{ + unsigned char *buf; + unsigned char *p, *d; + int i; + unsigned long l; +#ifndef OPENSSL_NO_COMP + int j; + SSL_COMP *comp; +#endif + + buf = (unsigned char *)s->init_buf->data; + if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { + SSL_SESSION *sess = s->session; + if ((sess == NULL) || (sess->ssl_version != s->version) || +#ifdef OPENSSL_NO_TLSEXT + !sess->session_id_length || +#else + /* + * In the case of EAP-FAST, we can have a pre-shared + * ""ticket"" without a session ID. + */ + (!sess->session_id_length && !sess->tlsext_tick) || +#endif + (sess->not_resumable)) { + if (!ssl_get_new_session(s, 0)) + goto err; + } + /* else use the pre-loaded session */ + + p = s->s3->client_random; + + if (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0) + goto err; + + /* Do the message type and length last */ + d = p = &(buf[4]); + + /*- + * version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ +#if 0 + *(p++) = s->version >> 8; + *(p++) = s->version & 0xff; + s->client_version = s->version; +#else + *(p++) = s->client_version >> 8; + *(p++) = s->client_version & 0xff; +#endif + + /* Random stuff */ + memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); + p += SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i = 0; + else + i = s->session->session_id_length; + *(p++) = i; + if (i != 0) { + if (i > (int)sizeof(s->session->session_id)) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + memcpy(p, s->session->session_id, i); + p += i; + } + + /* Ciphers supported */ + i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0); + if (i == 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } +#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH + /* + * Some servers hang if client hello > 256 bytes as hack workaround + * chop number of supported ciphers to keep it well below this if we + * use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; +#endif + s2n(i, p); + p += i; + + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + *(p++) = 1; +#else + + if ((s->options & SSL_OP_NO_COMPRESSION) + || !s->ctx->comp_methods) + j = 0; + else + j = sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++) = 1 + j; + for (i = 0; i < j; i++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); + *(p++) = comp->id; + } +#endif + *(p++) = 0; /* Add the NULL method */ + +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions */ + if (ssl_prepare_clienthello_tlsext(s) <= 0) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = + ssl_add_clienthello_tlsext(s, p, + buf + SSL3_RT_MAX_PLAIN_LENGTH)) == + NULL) { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } +#endif + + l = (p - d); + d = buf; + *(d++) = SSL3_MT_CLIENT_HELLO; + l2n3(l, d); + + s->state = SSL3_ST_CW_CLNT_HELLO_B; + /* number of bytes to write */ + s->init_num = p - buf; + s->init_off = 0; + } + + /* SSL3_ST_CW_CLNT_HELLO_B */ + return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); + err: + s->state = SSL_ST_ERR; + return (-1); +} +","@@ -1143,6 +1143,12 @@ int ssl3_get_server_certificate(SSL *s) + goto f_err; + } + for (nc = 0; nc < llen;) { ++ if (nc + 3 > llen) { ++ al = SSL_AD_DECODE_ERROR; ++ SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ++ SSL_R_CERT_LENGTH_MISMATCH); ++ goto f_err; ++ } + n2l3(p, l); + if ((l + nc + 3) > llen) { + al = SSL_AD_DECODE_ERROR; +@@ -2072,6 +2078,11 @@ int ssl3_get_certificate_request(SSL *s) + } + + for (nc = 0; nc < llen;) { ++ if (nc + 2 > llen) { ++ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); ++ SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_CA_DN_TOO_LONG); ++ goto err; ++ } + n2s(p, l); + if ((l + nc + 2) > llen) { + if ((s->options & SSL_OP_NETSCAPE_CA_DN_BUG))",1421,1657,2048 +18111,"static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image) +{ + MagickBooleanType + status; + + register const IndexPacket + *indexes; + + register const PixelPacket + *p; + + register ssize_t + i, + x; + + register unsigned char + *q; + + size_t + depth, + packet_size; + + ssize_t + y; + + unsigned char + *colormap, + *pixels; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + (void) TransformImageColorspace(image,sRGBColorspace); + /* + Allocate colormap. + */ + if (IsPaletteImage(image,&image->exception) == MagickFalse) + (void) SetImageType(image,PaletteType); + depth=GetImageQuantumDepth(image,MagickTrue); + packet_size=(size_t) (depth/8); + pixels=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size* + sizeof(*pixels)); + packet_size=(size_t) (image->colors > 256 ? 6UL : 3UL); + colormap=(unsigned char *) AcquireQuantumMemory(image->colors,packet_size* + sizeof(*colormap)); + if ((pixels == (unsigned char *) NULL) || + (colormap == (unsigned char *) NULL)) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + /* + Write colormap to file. + */ + q=colormap; + q=colormap; + if (image->colors <= 256) + for (i=0; i < (ssize_t) image->colors; i++) + { + *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].red); + *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].green); + *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].blue); + } + else + for (i=0; i < (ssize_t) image->colors; i++) + { + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) & 0xff); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) & 0xff);; + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) & 0xff); + } + (void) WriteBlob(image,packet_size*image->colors,colormap); + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + /* + Write image pixels to file. + */ + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(image); + q=pixels; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->colors > 256) + *q++=(unsigned char) ((size_t) GetPixelIndex(indexes+x) >> 8); + *q++=(unsigned char) GetPixelIndex(indexes+x); + } + (void) WriteBlob(image,(size_t) (q-pixels),pixels); + } + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + (void) CloseBlob(image); + return(status); +} +",1,"static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image) +{ + MagickBooleanType + status; + + register const IndexPacket + *indexes; + + register const PixelPacket + *p; + + register ssize_t + i, + x; + + register unsigned char + *q; + + size_t + depth, + packet_size; + + ssize_t + y; + + unsigned char + *colormap, + *pixels; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + (void) TransformImageColorspace(image,sRGBColorspace); + /* + Allocate colormap. + */ + if (IsPaletteImage(image,&image->exception) == MagickFalse) + (void) SetImageType(image,PaletteType); + depth=GetImageQuantumDepth(image,MagickTrue); + packet_size=(size_t) (depth/8); + pixels=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size* + sizeof(*pixels)); + packet_size=(size_t) (image->colors > 256 ? 6UL : 3UL); + colormap=(unsigned char *) AcquireQuantumMemory(image->colors,packet_size* + sizeof(*colormap)); + if ((pixels == (unsigned char *) NULL) || + (colormap == (unsigned char *) NULL)) + { + if (colormap != (unsigned char *) NULL) + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + if (pixels != (unsigned char *) NULL) + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + } + /* + Write colormap to file. + */ + q=colormap; + if (image->colors <= 256) + for (i=0; i < (ssize_t) image->colors; i++) + { + *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].red); + *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].green); + *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].blue); + } + else + for (i=0; i < (ssize_t) image->colors; i++) + { + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) & 0xff); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) & + 0xff); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) & + 0xff); + } + (void) WriteBlob(image,packet_size*image->colors,colormap); + colormap=(unsigned char *) RelinquishMagickMemory(colormap); + /* + Write image pixels to file. + */ + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(image); + q=pixels; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->colors > 256) + *q++=(unsigned char) ((size_t) GetPixelIndex(indexes+x) >> 8); + *q++=(unsigned char) GetPixelIndex(indexes+x); + } + (void) WriteBlob(image,(size_t) (q-pixels),pixels); + } + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + (void) CloseBlob(image); + return(status); +} +","@@ -396,12 +396,17 @@ static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image) + sizeof(*colormap)); + if ((pixels == (unsigned char *) NULL) || + (colormap == (unsigned char *) NULL)) +- ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); ++ { ++ if (colormap != (unsigned char *) NULL) ++ colormap=(unsigned char *) RelinquishMagickMemory(colormap); ++ if (pixels != (unsigned char *) NULL) ++ pixels=(unsigned char *) RelinquishMagickMemory(pixels); ++ ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); ++ } + /* + Write colormap to file. + */ + q=colormap; +- q=colormap; + if (image->colors <= 256) + for (i=0; i < (ssize_t) image->colors; i++) + { +@@ -415,9 +420,11 @@ static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image) + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) >> 8); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) & 0xff); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) >> 8); +- *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) & 0xff);; ++ *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) & ++ 0xff); + *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) >> 8); +- *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) & 0xff); ++ *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) & ++ 0xff); + } + (void) WriteBlob(image,packet_size*image->colors,colormap); + colormap=(unsigned char *) RelinquishMagickMemory(colormap);",934,1170,2048 +1119,"int ssl3_client_hello(SSL *s) + { + unsigned char *buf; + unsigned char *p,*d; + int i; + unsigned long l; +#ifndef OPENSSL_NO_COMP + int j; + SSL_COMP *comp; +#endif + + buf=(unsigned char *)s->init_buf->data; + if (s->state == SSL3_ST_CW_CLNT_HELLO_A) + { + SSL_SESSION *sess = s->session; + if ((sess == NULL) || + (sess->ssl_version != s->version) || +#ifdef OPENSSL_NO_TLSEXT + !sess->session_id_length || +#else + (!sess->session_id_length && !sess->tlsext_tick) || +#endif + (sess->not_resumable)) + { + if (!ssl_get_new_session(s,0)) + goto err; + } + /* else use the pre-loaded session */ + + p=s->s3->client_random; + + if (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0) + goto err; + + /* Do the message type and length last */ + d=p= &(buf[4]); + + /* version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ +#if 0 + *(p++)=s->version>>8; + *(p++)=s->version&0xff; + s->client_version=s->version; +#else + *(p++)=s->client_version>>8; + *(p++)=s->client_version&0xff; +#endif + + /* Random stuff */ + memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE); + p+=SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i=0; + else + i=s->session->session_id_length; + *(p++)=i; + if (i != 0) + { + if (i > (int)sizeof(s->session->session_id)) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + memcpy(p,s->session->session_id,i); + p+=i; + } + + /* Ciphers supported */ + i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),&(p[2]),0); + if (i == 0) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } +#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH + /* Some servers hang if client hello > 256 bytes + * as hack workaround chop number of supported ciphers + * to keep it well below this if we use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; +#endif + s2n(i,p); + p+=i; + + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + *(p++)=1; +#else + + if ((s->options & SSL_OP_NO_COMPRESSION) + || !s->ctx->comp_methods) + j=0; + else + j=sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++)=1+j; + for (i=0; ictx->comp_methods,i); + *(p++)=comp->id; + } +#endif + *(p++)=0; /* Add the NULL method */ + +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions*/ + if (ssl_prepare_clienthello_tlsext(s) <= 0) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = ssl_add_clienthello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO,ERR_R_INTERNAL_ERROR); + goto err; + } +#endif + + l=(p-d); + d=buf; + *(d++)=SSL3_MT_CLIENT_HELLO; + l2n3(l,d); + + s->state=SSL3_ST_CW_CLNT_HELLO_B; + /* number of bytes to write */ + s->init_num=p-buf; + s->init_off=0; + } + + /* SSL3_ST_CW_CLNT_HELLO_B */ + return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); +err: + return(-1); + } +",0,"int ssl3_client_hello(SSL *s) + { + unsigned char *buf; + unsigned char *p,*d; + int i; + unsigned long l; +#ifndef OPENSSL_NO_COMP + int j; + SSL_COMP *comp; +#endif + + buf=(unsigned char *)s->init_buf->data; + if (s->state == SSL3_ST_CW_CLNT_HELLO_A) + { + SSL_SESSION *sess = s->session; + if ((sess == NULL) || + (sess->ssl_version != s->version) || +#ifdef OPENSSL_NO_TLSEXT + !sess->session_id_length || +#else + (!sess->session_id_length && !sess->tlsext_tick) || +#endif + (sess->not_resumable)) + { + if (!ssl_get_new_session(s,0)) + goto err; + } + /* else use the pre-loaded session */ + + p=s->s3->client_random; + + if (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0) + goto err; + + /* Do the message type and length last */ + d=p= &(buf[4]); + + /* version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ +#if 0 + *(p++)=s->version>>8; + *(p++)=s->version&0xff; + s->client_version=s->version; +#else + *(p++)=s->client_version>>8; + *(p++)=s->client_version&0xff; +#endif + + /* Random stuff */ + memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE); + p+=SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i=0; + else + i=s->session->session_id_length; + *(p++)=i; + if (i != 0) + { + if (i > (int)sizeof(s->session->session_id)) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + memcpy(p,s->session->session_id,i); + p+=i; + } + + /* Ciphers supported */ + i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),&(p[2]),0); + if (i == 0) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } +#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH + /* Some servers hang if client hello > 256 bytes + * as hack workaround chop number of supported ciphers + * to keep it well below this if we use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; +#endif + s2n(i,p); + p+=i; + + /* COMPRESSION */ +#ifdef OPENSSL_NO_COMP + *(p++)=1; +#else + + if ((s->options & SSL_OP_NO_COMPRESSION) + || !s->ctx->comp_methods) + j=0; + else + j=sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++)=1+j; + for (i=0; ictx->comp_methods,i); + *(p++)=comp->id; + } +#endif + *(p++)=0; /* Add the NULL method */ + +#ifndef OPENSSL_NO_TLSEXT + /* TLS extensions*/ + if (ssl_prepare_clienthello_tlsext(s) <= 0) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = ssl_add_clienthello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) + { + SSLerr(SSL_F_SSL3_CLIENT_HELLO,ERR_R_INTERNAL_ERROR); + goto err; + } +#endif + + l=(p-d); + d=buf; + *(d++)=SSL3_MT_CLIENT_HELLO; + l2n3(l,d); + + s->state=SSL3_ST_CW_CLNT_HELLO_B; + /* number of bytes to write */ + s->init_num=p-buf; + s->init_off=0; + } + + /* SSL3_ST_CW_CLNT_HELLO_B */ + return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); +err: + return(-1); + } +","@@ -954,6 +954,15 @@ int ssl3_get_server_hello(SSL *s) + SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED); + goto f_err; + } ++#ifndef OPENSSL_NO_SRP ++ if (((c->algorithm_mkey & SSL_kSRP) || (c->algorithm_auth & SSL_aSRP)) && ++ !(s->srp_ctx.srp_Mask & SSL_kSRP)) ++ { ++ al=SSL_AD_ILLEGAL_PARAMETER; ++ SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED); ++ goto f_err; ++ } ++#endif /* OPENSSL_NO_SRP */ + p+=ssl_put_cipher_by_char(s,NULL,NULL); + + sk=ssl_get_ciphers_by_id(s);",1386,1622,2048 +17926,"__switch_to(struct task_struct *prev_p, struct task_struct *next_p) +{ + struct thread_struct *prev = &prev_p->thread; + struct thread_struct *next = &next_p->thread; + int cpu = smp_processor_id(); + struct tss_struct *tss = &per_cpu(init_tss, cpu); + unsigned fsindex, gsindex; + fpu_switch_t fpu; + + fpu = switch_fpu_prepare(prev_p, next_p, cpu); + + /* + * Reload esp0, LDT and the page table pointer: + */ + load_sp0(tss, next); + + /* + * Switch DS and ES. + * This won't pick up thread selector changes, but I guess that is ok. + */ + savesegment(es, prev->es); + if (unlikely(next->es | prev->es)) + loadsegment(es, next->es); + savesegment(ds, prev->ds); + if (unlikely(next->ds | prev->ds)) + loadsegment(ds, next->ds); + /* We must save %fs and %gs before load_TLS() because + * %fs and %gs may be cleared by load_TLS(). + * + * (e.g. xen_load_tls()) + */ + savesegment(fs, fsindex); + savesegment(gs, gsindex); + + load_TLS(next, cpu); + + /* + * Leave lazy mode, flushing any hypercalls made here. + * This must be done before restoring TLS segments so + * the GDT and LDT are properly updated, and must be + * done before math_state_restore, so the TS bit is up + * to date. + */ + arch_end_context_switch(next_p); + + /* + * Switch FS and GS. + * + * Segment register != 0 always requires a reload. Also + * reload when it has changed. When prev process used 64bit + * base always reload to avoid an information leak. + */ + if (unlikely(fsindex | next->fsindex | prev->fs)) { + loadsegment(fs, next->fsindex); + /* + * Check if the user used a selector != 0; if yes + * clear 64bit base, since overloaded base is always + * mapped to the Null selector + */ + if (fsindex) + prev->fs = 0; + } + /* when next process has a 64bit base use it */ + if (next->fs) + wrmsrl(MSR_FS_BASE, next->fs); + prev->fsindex = fsindex; + + if (unlikely(gsindex | next->gsindex | prev->gs)) { + load_gs_index(next->gsindex); + if (gsindex) + prev->gs = 0; + } + if (next->gs) + wrmsrl(MSR_KERNEL_GS_BASE, next->gs); + prev->gsindex = gsindex; + + switch_fpu_finish(next_p, fpu); + + /* + * Switch the PDA and FPU contexts. + */ + prev->usersp = this_cpu_read(old_rsp); + this_cpu_write(old_rsp, next->usersp); + this_cpu_write(current_task, next_p); + + /* + * If it were not for PREEMPT_ACTIVE we could guarantee that the + * preempt_count of all tasks was equal here and this would not be + * needed. + */ + task_thread_info(prev_p)->saved_preempt_count = this_cpu_read(__preempt_count); + this_cpu_write(__preempt_count, task_thread_info(next_p)->saved_preempt_count); + + this_cpu_write(kernel_stack, + (unsigned long)task_stack_page(next_p) + + THREAD_SIZE - KERNEL_STACK_OFFSET); + + /* + * Now maybe reload the debug registers and handle I/O bitmaps + */ + if (unlikely(task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT || + task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV)) + __switch_to_xtra(prev_p, next_p, tss); + + return prev_p; +} +",1,"__switch_to(struct task_struct *prev_p, struct task_struct *next_p) +{ + struct thread_struct *prev = &prev_p->thread; + struct thread_struct *next = &next_p->thread; + int cpu = smp_processor_id(); + struct tss_struct *tss = &per_cpu(init_tss, cpu); + unsigned fsindex, gsindex; + fpu_switch_t fpu; + + fpu = switch_fpu_prepare(prev_p, next_p, cpu); + + /* Reload esp0 and ss1. */ + load_sp0(tss, next); + + /* We must save %fs and %gs before load_TLS() because + * %fs and %gs may be cleared by load_TLS(). + * + * (e.g. xen_load_tls()) + */ + savesegment(fs, fsindex); + savesegment(gs, gsindex); + + /* + * Load TLS before restoring any segments so that segment loads + * reference the correct GDT entries. + */ + load_TLS(next, cpu); + + /* + * Leave lazy mode, flushing any hypercalls made here. This + * must be done after loading TLS entries in the GDT but before + * loading segments that might reference them, and and it must + * be done before math_state_restore, so the TS bit is up to + * date. + */ + arch_end_context_switch(next_p); + + /* Switch DS and ES. + * + * Reading them only returns the selectors, but writing them (if + * nonzero) loads the full descriptor from the GDT or LDT. The + * LDT for next is loaded in switch_mm, and the GDT is loaded + * above. + * + * We therefore need to write new values to the segment + * registers on every context switch unless both the new and old + * values are zero. + * + * Note that we don't need to do anything for CS and SS, as + * those are saved and restored as part of pt_regs. + */ + savesegment(es, prev->es); + if (unlikely(next->es | prev->es)) + loadsegment(es, next->es); + + savesegment(ds, prev->ds); + if (unlikely(next->ds | prev->ds)) + loadsegment(ds, next->ds); + + /* + * Switch FS and GS. + * + * These are even more complicated than FS and GS: they have + * 64-bit bases are that controlled by arch_prctl. Those bases + * only differ from the values in the GDT or LDT if the selector + * is 0. + * + * Loading the segment register resets the hidden base part of + * the register to 0 or the value from the GDT / LDT. If the + * next base address zero, writing 0 to the segment register is + * much faster than using wrmsr to explicitly zero the base. + * + * The thread_struct.fs and thread_struct.gs values are 0 + * if the fs and gs bases respectively are not overridden + * from the values implied by fsindex and gsindex. They + * are nonzero, and store the nonzero base addresses, if + * the bases are overridden. + * + * (fs != 0 && fsindex != 0) || (gs != 0 && gsindex != 0) should + * be impossible. + * + * Therefore we need to reload the segment registers if either + * the old or new selector is nonzero, and we need to override + * the base address if next thread expects it to be overridden. + * + * This code is unnecessarily slow in the case where the old and + * new indexes are zero and the new base is nonzero -- it will + * unnecessarily write 0 to the selector before writing the new + * base address. + * + * Note: This all depends on arch_prctl being the only way that + * user code can override the segment base. Once wrfsbase and + * wrgsbase are enabled, most of this code will need to change. + */ + if (unlikely(fsindex | next->fsindex | prev->fs)) { + loadsegment(fs, next->fsindex); + + /* + * If user code wrote a nonzero value to FS, then it also + * cleared the overridden base address. + * + * XXX: if user code wrote 0 to FS and cleared the base + * address itself, we won't notice and we'll incorrectly + * restore the prior base address next time we reschdule + * the process. + */ + if (fsindex) + prev->fs = 0; + } + if (next->fs) + wrmsrl(MSR_FS_BASE, next->fs); + prev->fsindex = fsindex; + + if (unlikely(gsindex | next->gsindex | prev->gs)) { + load_gs_index(next->gsindex); + + /* This works (and fails) the same way as fsindex above. */ + if (gsindex) + prev->gs = 0; + } + if (next->gs) + wrmsrl(MSR_KERNEL_GS_BASE, next->gs); + prev->gsindex = gsindex; + + switch_fpu_finish(next_p, fpu); + + /* + * Switch the PDA and FPU contexts. + */ + prev->usersp = this_cpu_read(old_rsp); + this_cpu_write(old_rsp, next->usersp); + this_cpu_write(current_task, next_p); + + /* + * If it were not for PREEMPT_ACTIVE we could guarantee that the + * preempt_count of all tasks was equal here and this would not be + * needed. + */ + task_thread_info(prev_p)->saved_preempt_count = this_cpu_read(__preempt_count); + this_cpu_write(__preempt_count, task_thread_info(next_p)->saved_preempt_count); + + this_cpu_write(kernel_stack, + (unsigned long)task_stack_page(next_p) + + THREAD_SIZE - KERNEL_STACK_OFFSET); + + /* + * Now maybe reload the debug registers and handle I/O bitmaps + */ + if (unlikely(task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT || + task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV)) + __switch_to_xtra(prev_p, next_p, tss); + + return prev_p; +} +","@@ -283,24 +283,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) + + fpu = switch_fpu_prepare(prev_p, next_p, cpu); + +- /* +- * Reload esp0, LDT and the page table pointer: +- */ ++ /* Reload esp0 and ss1. */ + load_sp0(tss, next); + +- /* +- * Switch DS and ES. +- * This won't pick up thread selector changes, but I guess that is ok. +- */ +- savesegment(es, prev->es); +- if (unlikely(next->es | prev->es)) +- loadsegment(es, next->es); +- +- savesegment(ds, prev->ds); +- if (unlikely(next->ds | prev->ds)) +- loadsegment(ds, next->ds); +- +- + /* We must save %fs and %gs before load_TLS() because + * %fs and %gs may be cleared by load_TLS(). + * +@@ -309,41 +294,101 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) + savesegment(fs, fsindex); + savesegment(gs, gsindex); + ++ /* ++ * Load TLS before restoring any segments so that segment loads ++ * reference the correct GDT entries. ++ */ + load_TLS(next, cpu); + + /* +- * Leave lazy mode, flushing any hypercalls made here. +- * This must be done before restoring TLS segments so +- * the GDT and LDT are properly updated, and must be +- * done before math_state_restore, so the TS bit is up +- * to date. ++ * Leave lazy mode, flushing any hypercalls made here. This ++ * must be done after loading TLS entries in the GDT but before ++ * loading segments that might reference them, and and it must ++ * be done before math_state_restore, so the TS bit is up to ++ * date. + */ + arch_end_context_switch(next_p); + ++ /* Switch DS and ES. ++ * ++ * Reading them only returns the selectors, but writing them (if ++ * nonzero) loads the full descriptor from the GDT or LDT. The ++ * LDT for next is loaded in switch_mm, and the GDT is loaded ++ * above. ++ * ++ * We therefore need to write new values to the segment ++ * registers on every context switch unless both the new and old ++ * values are zero. ++ * ++ * Note that we don't need to do anything for CS and SS, as ++ * those are saved and restored as part of pt_regs. ++ */ ++ savesegment(es, prev->es); ++ if (unlikely(next->es | prev->es)) ++ loadsegment(es, next->es); ++ ++ savesegment(ds, prev->ds); ++ if (unlikely(next->ds | prev->ds)) ++ loadsegment(ds, next->ds); ++ + /* + * Switch FS and GS. + * +- * Segment register != 0 always requires a reload. Also +- * reload when it has changed. When prev process used 64bit +- * base always reload to avoid an information leak. ++ * These are even more complicated than FS and GS: they have ++ * 64-bit bases are that controlled by arch_prctl. Those bases ++ * only differ from the values in the GDT or LDT if the selector ++ * is 0. ++ * ++ * Loading the segment register resets the hidden base part of ++ * the register to 0 or the value from the GDT / LDT. If the ++ * next base address zero, writing 0 to the segment register is ++ * much faster than using wrmsr to explicitly zero the base. ++ * ++ * The thread_struct.fs and thread_struct.gs values are 0 ++ * if the fs and gs bases respectively are not overridden ++ * from the values implied by fsindex and gsindex. They ++ * are nonzero, and store the nonzero base addresses, if ++ * the bases are overridden. ++ * ++ * (fs != 0 && fsindex != 0) || (gs != 0 && gsindex != 0) should ++ * be impossible. ++ * ++ * Therefore we need to reload the segment registers if either ++ * the old or new selector is nonzero, and we need to override ++ * the base address if next thread expects it to be overridden. ++ * ++ * This code is unnecessarily slow in the case where the old and ++ * new indexes are zero and the new base is nonzero -- it will ++ * unnecessarily write 0 to the selector before writing the new ++ * base address. ++ * ++ * Note: This all depends on arch_prctl being the only way that ++ * user code can override the segment base. Once wrfsbase and ++ * wrgsbase are enabled, most of this code will need to change. + */ + if (unlikely(fsindex | next->fsindex | prev->fs)) { + loadsegment(fs, next->fsindex); ++ + /* +- * Check if the user used a selector != 0; if yes +- * clear 64bit base, since overloaded base is always +- * mapped to the Null selector ++ * If user code wrote a nonzero value to FS, then it also ++ * cleared the overridden base address. ++ * ++ * XXX: if user code wrote 0 to FS and cleared the base ++ * address itself, we won't notice and we'll incorrectly ++ * restore the prior base address next time we reschdule ++ * the process. + */ + if (fsindex) + prev->fs = 0; + } +- /* when next process has a 64bit base use it */ + if (next->fs) + wrmsrl(MSR_FS_BASE, next->fs); + prev->fsindex = fsindex; + + if (unlikely(gsindex | next->gsindex | prev->gs)) { + load_gs_index(next->gsindex); ++ ++ /* This works (and fails) the same way as fsindex above. */ + if (gsindex) + prev->gs = 0; + }",865,1101,2048 +18254,"static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_write_ctxt *wc; + struct ocfs2_write_cluster_desc *desc = NULL; + struct ocfs2_dio_write_ctxt *dwc = NULL; + struct buffer_head *di_bh = NULL; + u64 p_blkno; + loff_t pos = iblock << inode->i_sb->s_blocksize_bits; + unsigned len, total_len = bh_result->b_size; + int ret = 0, first_get_block = 0; + + len = osb->s_clustersize - (pos & (osb->s_clustersize - 1)); + len = min(total_len, len); + + mlog(0, ""get block of %lu at %llu:%u req %u\n"", + inode->i_ino, pos, len, total_len); + + /* + * Because we need to change file size in ocfs2_dio_end_io_write(), or + * we may need to add it to orphan dir. So can not fall to fast path + * while file size will be changed. + */ + if (pos + total_len <= i_size_read(inode)) { + down_read(&oi->ip_alloc_sem); + /* This is the fast path for re-write. */ + ret = ocfs2_get_block(inode, iblock, bh_result, create); + up_read(&oi->ip_alloc_sem); + + if (buffer_mapped(bh_result) && + !buffer_new(bh_result) && + ret == 0) + goto out; + + /* Clear state set by ocfs2_get_block. */ + bh_result->b_state = 0; + } + + dwc = ocfs2_dio_alloc_write_ctx(bh_result, &first_get_block); + if (unlikely(dwc == NULL)) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + + if (ocfs2_clusters_for_bytes(inode->i_sb, pos + total_len) > + ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode)) && + !dwc->dw_orphaned) { + /* + * when we are going to alloc extents beyond file size, add the + * inode to orphan dir, so we can recall those spaces when + * system crashed during write. + */ + ret = ocfs2_add_inode_to_orphan(osb, inode); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + dwc->dw_orphaned = 1; + } + + ret = ocfs2_inode_lock(inode, &di_bh, 1); + if (ret) { + mlog_errno(ret); + goto out; + } + + down_write(&oi->ip_alloc_sem); + + if (first_get_block) { + if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) + ret = ocfs2_zero_tail(inode, di_bh, pos); + else + ret = ocfs2_expand_nonsparse_inode(inode, di_bh, pos, + total_len, NULL); + if (ret < 0) { + mlog_errno(ret); + goto unlock; + } + } + + ret = ocfs2_write_begin_nolock(inode->i_mapping, pos, len, + OCFS2_WRITE_DIRECT, NULL, + (void **)&wc, di_bh, NULL); + if (ret) { + mlog_errno(ret); + goto unlock; + } + + desc = &wc->w_desc[0]; + + p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, desc->c_phys); + BUG_ON(p_blkno == 0); + p_blkno += iblock & (u64)(ocfs2_clusters_to_blocks(inode->i_sb, 1) - 1); + + map_bh(bh_result, inode->i_sb, p_blkno); + bh_result->b_size = len; + if (desc->c_needs_zero) + set_buffer_new(bh_result); + + /* May sleep in end_io. It should not happen in a irq context. So defer + * it to dio work queue. */ + set_buffer_defer_completion(bh_result); + + if (!list_empty(&wc->w_unwritten_list)) { + struct ocfs2_unwritten_extent *ue = NULL; + + ue = list_first_entry(&wc->w_unwritten_list, + struct ocfs2_unwritten_extent, + ue_node); + BUG_ON(ue->ue_cpos != desc->c_cpos); + /* The physical address may be 0, fill it. */ + ue->ue_phys = desc->c_phys; + + list_splice_tail_init(&wc->w_unwritten_list, &dwc->dw_zero_list); + dwc->dw_zero_count++; + } + + ret = ocfs2_write_end_nolock(inode->i_mapping, pos, len, len, wc); + BUG_ON(ret != len); + ret = 0; +unlock: + up_write(&oi->ip_alloc_sem); + ocfs2_inode_unlock(inode, 1); + brelse(di_bh); +out: + if (ret < 0) + ret = -EIO; + return ret; +} +",1,"static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, +static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_write_ctxt *wc; + struct ocfs2_write_cluster_desc *desc = NULL; + struct ocfs2_dio_write_ctxt *dwc = NULL; + struct buffer_head *di_bh = NULL; + u64 p_blkno; + loff_t pos = iblock << inode->i_sb->s_blocksize_bits; + unsigned len, total_len = bh_result->b_size; + int ret = 0, first_get_block = 0; + + len = osb->s_clustersize - (pos & (osb->s_clustersize - 1)); + len = min(total_len, len); + + mlog(0, ""get block of %lu at %llu:%u req %u\n"", + inode->i_ino, pos, len, total_len); + + /* + * Because we need to change file size in ocfs2_dio_end_io_write(), or + * we may need to add it to orphan dir. So can not fall to fast path + * while file size will be changed. + */ + if (pos + total_len <= i_size_read(inode)) { + + /* This is the fast path for re-write. */ + ret = ocfs2_lock_get_block(inode, iblock, bh_result, create); + if (buffer_mapped(bh_result) && + !buffer_new(bh_result) && + ret == 0) + goto out; + + /* Clear state set by ocfs2_get_block. */ + bh_result->b_state = 0; + } + + dwc = ocfs2_dio_alloc_write_ctx(bh_result, &first_get_block); + if (unlikely(dwc == NULL)) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + + if (ocfs2_clusters_for_bytes(inode->i_sb, pos + total_len) > + ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode)) && + !dwc->dw_orphaned) { + /* + * when we are going to alloc extents beyond file size, add the + * inode to orphan dir, so we can recall those spaces when + * system crashed during write. + */ + ret = ocfs2_add_inode_to_orphan(osb, inode); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + dwc->dw_orphaned = 1; + } + + ret = ocfs2_inode_lock(inode, &di_bh, 1); + if (ret) { + mlog_errno(ret); + goto out; + } + + down_write(&oi->ip_alloc_sem); + + if (first_get_block) { + if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) + ret = ocfs2_zero_tail(inode, di_bh, pos); + else + ret = ocfs2_expand_nonsparse_inode(inode, di_bh, pos, + total_len, NULL); + if (ret < 0) { + mlog_errno(ret); + goto unlock; + } + } + + ret = ocfs2_write_begin_nolock(inode->i_mapping, pos, len, + OCFS2_WRITE_DIRECT, NULL, + (void **)&wc, di_bh, NULL); + if (ret) { + mlog_errno(ret); + goto unlock; + } + + desc = &wc->w_desc[0]; + + p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, desc->c_phys); + BUG_ON(p_blkno == 0); + p_blkno += iblock & (u64)(ocfs2_clusters_to_blocks(inode->i_sb, 1) - 1); + + map_bh(bh_result, inode->i_sb, p_blkno); + bh_result->b_size = len; + if (desc->c_needs_zero) + set_buffer_new(bh_result); + + /* May sleep in end_io. It should not happen in a irq context. So defer + * it to dio work queue. */ + set_buffer_defer_completion(bh_result); + + if (!list_empty(&wc->w_unwritten_list)) { + struct ocfs2_unwritten_extent *ue = NULL; + + ue = list_first_entry(&wc->w_unwritten_list, + struct ocfs2_unwritten_extent, + ue_node); + BUG_ON(ue->ue_cpos != desc->c_cpos); + /* The physical address may be 0, fill it. */ + ue->ue_phys = desc->c_phys; + + list_splice_tail_init(&wc->w_unwritten_list, &dwc->dw_zero_list); + dwc->dw_zero_count++; + } + + ret = ocfs2_write_end_nolock(inode->i_mapping, pos, len, len, wc); + BUG_ON(ret != len); + ret = 0; +unlock: + up_write(&oi->ip_alloc_sem); + ocfs2_inode_unlock(inode, 1); + brelse(di_bh); +out: + if (ret < 0) + ret = -EIO; + return ret; +} +","@@ -134,6 +134,19 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, + return err; + } + ++static int ocfs2_lock_get_block(struct inode *inode, sector_t iblock, ++ struct buffer_head *bh_result, int create) ++{ ++ int ret = 0; ++ struct ocfs2_inode_info *oi = OCFS2_I(inode); ++ ++ down_read(&oi->ip_alloc_sem); ++ ret = ocfs2_get_block(inode, iblock, bh_result, create); ++ up_read(&oi->ip_alloc_sem); ++ ++ return ret; ++} ++ + int ocfs2_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { +@@ -2128,7 +2141,7 @@ static void ocfs2_dio_free_write_ctx(struct inode *inode, + * called like this: dio->get_blocks(dio->inode, fs_startblk, + * fs_count, map_bh, dio->rw == WRITE); + */ +-static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, ++static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) + { + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); +@@ -2154,12 +2167,9 @@ static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, + * while file size will be changed. + */ + if (pos + total_len <= i_size_read(inode)) { +- down_read(&oi->ip_alloc_sem); +- /* This is the fast path for re-write. */ +- ret = ocfs2_get_block(inode, iblock, bh_result, create); +- +- up_read(&oi->ip_alloc_sem); + ++ /* This is the fast path for re-write. */ ++ ret = ocfs2_lock_get_block(inode, iblock, bh_result, create); + if (buffer_mapped(bh_result) && + !buffer_new(bh_result) && + ret == 0) +@@ -2424,9 +2434,9 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) + return 0; + + if (iov_iter_rw(iter) == READ) +- get_block = ocfs2_get_block; ++ get_block = ocfs2_lock_get_block; + else +- get_block = ocfs2_dio_get_block; ++ get_block = ocfs2_dio_wr_get_block; + + return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, + iter, get_block,",1148,1384,2048 +2913,"static av_always_inline void mc_dir_part(H264Context *h, Picture *pic, + int n, int square, int height, + int delta, int list, + uint8_t *dest_y, uint8_t *dest_cb, + uint8_t *dest_cr, + int src_x_offset, int src_y_offset, + qpel_mc_func *qpix_op, + h264_chroma_mc_func chroma_op, + int pixel_shift, int chroma_idc) +{ + const int mx = h->mv_cache[list][scan8[n]][0] + src_x_offset * 8; + int my = h->mv_cache[list][scan8[n]][1] + src_y_offset * 8; + const int luma_xy = (mx & 3) + ((my & 3) << 2); + ptrdiff_t offset = ((mx >> 2) << pixel_shift) + (my >> 2) * h->mb_linesize; + uint8_t *src_y = pic->f.data[0] + offset; + uint8_t *src_cb, *src_cr; + int extra_width = 0; + int extra_height = 0; + int emu = 0; + const int full_mx = mx >> 2; + const int full_my = my >> 2; + const int pic_width = 16 * h->mb_width; + const int pic_height = 16 * h->mb_height >> MB_FIELD(h); + int ysh; + + if (mx & 7) + extra_width -= 3; + if (my & 7) + extra_height -= 3; + + if (full_mx < 0 - extra_width || + full_my < 0 - extra_height || + full_mx + 16 /*FIXME*/ > pic_width + extra_width || + full_my + 16 /*FIXME*/ > pic_height + extra_height) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_linesize, + src_y - (2 << pixel_shift) - 2 * h->mb_linesize, + h->mb_linesize, + 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2, + full_my - 2, pic_width, pic_height); + src_y = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + emu = 1; + } + + qpix_op[luma_xy](dest_y, src_y, h->mb_linesize); // FIXME try variable height perhaps? + if (!square) + qpix_op[luma_xy](dest_y + delta, src_y + delta, h->mb_linesize); + + if (CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY) + return; + + if (chroma_idc == 3 /* yuv444 */) { + src_cb = pic->f.data[1] + offset; + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_linesize, + src_cb - (2 << pixel_shift) - 2 * h->mb_linesize, + h->mb_linesize, + 16 + 5, 16 + 5 /*FIXME*/, + full_mx - 2, full_my - 2, + pic_width, pic_height); + src_cb = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + } + qpix_op[luma_xy](dest_cb, src_cb, h->mb_linesize); // FIXME try variable height perhaps? + if (!square) + qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize); + + src_cr = pic->f.data[2] + offset; + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_linesize, + src_cr - (2 << pixel_shift) - 2 * h->mb_linesize, + h->mb_linesize, + 16 + 5, 16 + 5 /*FIXME*/, + full_mx - 2, full_my - 2, + pic_width, pic_height); + src_cr = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + } + qpix_op[luma_xy](dest_cr, src_cr, h->mb_linesize); // FIXME try variable height perhaps? + if (!square) + qpix_op[luma_xy](dest_cr + delta, src_cr + delta, h->mb_linesize); + return; + } + + ysh = 3 - (chroma_idc == 2 /* yuv422 */); + if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(h)) { + my += 2 * ((h->mb_y & 1) - (pic->reference - 1)); + emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1); + } + + src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) + + (my >> ysh) * h->mb_uvlinesize; + src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) + + (my >> ysh) * h->mb_uvlinesize; + + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_uvlinesize, src_cb, h->mb_uvlinesize, + 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), + pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); + src_cb = h->edge_emu_buffer; + } + chroma_op(dest_cb, src_cb, h->mb_uvlinesize, + height >> (chroma_idc == 1 /* yuv420 */), + mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7); + + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_uvlinesize, src_cr, h->mb_uvlinesize, + 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), + pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); + src_cr = h->edge_emu_buffer; + } + chroma_op(dest_cr, src_cr, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), + mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7); +} +",0,"static av_always_inline void mc_dir_part(H264Context *h, Picture *pic, + int n, int square, int height, + int delta, int list, + uint8_t *dest_y, uint8_t *dest_cb, + uint8_t *dest_cr, + int src_x_offset, int src_y_offset, + qpel_mc_func *qpix_op, + h264_chroma_mc_func chroma_op, + int pixel_shift, int chroma_idc) +{ + const int mx = h->mv_cache[list][scan8[n]][0] + src_x_offset * 8; + int my = h->mv_cache[list][scan8[n]][1] + src_y_offset * 8; + const int luma_xy = (mx & 3) + ((my & 3) << 2); + ptrdiff_t offset = ((mx >> 2) << pixel_shift) + (my >> 2) * h->mb_linesize; + uint8_t *src_y = pic->f.data[0] + offset; + uint8_t *src_cb, *src_cr; + int extra_width = 0; + int extra_height = 0; + int emu = 0; + const int full_mx = mx >> 2; + const int full_my = my >> 2; + const int pic_width = 16 * h->mb_width; + const int pic_height = 16 * h->mb_height >> MB_FIELD(h); + int ysh; + + if (mx & 7) + extra_width -= 3; + if (my & 7) + extra_height -= 3; + + if (full_mx < 0 - extra_width || + full_my < 0 - extra_height || + full_mx + 16 /*FIXME*/ > pic_width + extra_width || + full_my + 16 /*FIXME*/ > pic_height + extra_height) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_linesize, + src_y - (2 << pixel_shift) - 2 * h->mb_linesize, + h->mb_linesize, + 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2, + full_my - 2, pic_width, pic_height); + src_y = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + emu = 1; + } + + qpix_op[luma_xy](dest_y, src_y, h->mb_linesize); // FIXME try variable height perhaps? + if (!square) + qpix_op[luma_xy](dest_y + delta, src_y + delta, h->mb_linesize); + + if (CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY) + return; + + if (chroma_idc == 3 /* yuv444 */) { + src_cb = pic->f.data[1] + offset; + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_linesize, + src_cb - (2 << pixel_shift) - 2 * h->mb_linesize, + h->mb_linesize, + 16 + 5, 16 + 5 /*FIXME*/, + full_mx - 2, full_my - 2, + pic_width, pic_height); + src_cb = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + } + qpix_op[luma_xy](dest_cb, src_cb, h->mb_linesize); // FIXME try variable height perhaps? + if (!square) + qpix_op[luma_xy](dest_cb + delta, src_cb + delta, h->mb_linesize); + + src_cr = pic->f.data[2] + offset; + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_linesize, + src_cr - (2 << pixel_shift) - 2 * h->mb_linesize, + h->mb_linesize, + 16 + 5, 16 + 5 /*FIXME*/, + full_mx - 2, full_my - 2, + pic_width, pic_height); + src_cr = h->edge_emu_buffer + (2 << pixel_shift) + 2 * h->mb_linesize; + } + qpix_op[luma_xy](dest_cr, src_cr, h->mb_linesize); // FIXME try variable height perhaps? + if (!square) + qpix_op[luma_xy](dest_cr + delta, src_cr + delta, h->mb_linesize); + return; + } + + ysh = 3 - (chroma_idc == 2 /* yuv422 */); + if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(h)) { + my += 2 * ((h->mb_y & 1) - (pic->reference - 1)); + emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1); + } + + src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) + + (my >> ysh) * h->mb_uvlinesize; + src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) + + (my >> ysh) * h->mb_uvlinesize; + + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_uvlinesize, src_cb, h->mb_uvlinesize, + 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), + pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); + src_cb = h->edge_emu_buffer; + } + chroma_op(dest_cb, src_cb, h->mb_uvlinesize, + height >> (chroma_idc == 1 /* yuv420 */), + mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7); + + if (emu) { + h->vdsp.emulated_edge_mc(h->edge_emu_buffer, h->mb_uvlinesize, src_cr, h->mb_uvlinesize, + 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), + pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); + src_cr = h->edge_emu_buffer; + } + chroma_op(dest_cr, src_cr, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), + mx & 7, (my << (chroma_idc == 2 /* yuv422 */)) & 7); +} +","@@ -3621,7 +3621,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) + assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF); + + /* Mark old field/frame as completed */ +- if (!last_pic_droppable && h0->cur_pic_ptr->tf.owner == h0->avctx) { ++ if (h0->cur_pic_ptr->tf.owner == h0->avctx) { + ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX, + last_pic_structure == PICT_BOTTOM_FIELD); + } +@@ -3630,7 +3630,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) + if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) { + /* Previous field is unmatched. Don't display it, but let it + * remain for reference if marked as such. */ +- if (!last_pic_droppable && last_pic_structure != PICT_FRAME) { ++ if (last_pic_structure != PICT_FRAME) { + ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX, + last_pic_structure == PICT_TOP_FIELD); + } +@@ -3640,7 +3640,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) + * different frame_nums. Consider this field first in + * pair. Throw away previous field except for reference + * purposes. */ +- if (!last_pic_droppable && last_pic_structure != PICT_FRAME) { ++ if (last_pic_structure != PICT_FRAME) { + ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX, + last_pic_structure == PICT_TOP_FIELD); + }",1548,1784,2048 +3572,"CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, + const char *tree, struct cifsTconInfo *tcon, + const struct nls_table *nls_codepage) +{ + struct smb_hdr *smb_buffer; + struct smb_hdr *smb_buffer_response; + TCONX_REQ *pSMB; + TCONX_RSP *pSMBr; + unsigned char *bcc_ptr; + int rc = 0; + int length, bytes_left; + __u16 count; + + if (ses == NULL) + return -EIO; + + smb_buffer = cifs_buf_get(); + if (smb_buffer == NULL) + return -ENOMEM; + + smb_buffer_response = smb_buffer; + + header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX, + NULL /*no tid */ , 4 /*wct */ ); + + smb_buffer->Mid = GetNextMid(ses->server); + smb_buffer->Uid = ses->Suid; + pSMB = (TCONX_REQ *) smb_buffer; + pSMBr = (TCONX_RSP *) smb_buffer_response; + + pSMB->AndXCommand = 0xFF; + pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); + bcc_ptr = &pSMB->Password[0]; + if ((ses->server->secMode) & SECMODE_USER) { + pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ + *bcc_ptr = 0; /* password is null byte */ + bcc_ptr++; /* skip password */ + /* already aligned so no need to do it below */ + } else { + pSMB->PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); + /* BB FIXME add code to fail this if NTLMv2 or Kerberos + specified as required (when that support is added to + the vfs in the future) as only NTLM or the much + weaker LANMAN (which we do not send by default) is accepted + by Samba (not sure whether other servers allow + NTLMv2 password here) */ +#ifdef CONFIG_CIFS_WEAK_PW_HASH + if ((global_secflags & CIFSSEC_MAY_LANMAN) && + (ses->server->secType == LANMAN)) + calc_lanman_hash(tcon->password, ses->server->cryptKey, + ses->server->secMode & + SECMODE_PW_ENCRYPT ? true : false, + bcc_ptr); + else +#endif /* CIFS_WEAK_PW_HASH */ + SMBNTencrypt(tcon->password, ses->server->cryptKey, + bcc_ptr); + + bcc_ptr += CIFS_SESS_KEY_SIZE; + if (ses->capabilities & CAP_UNICODE) { + /* must align unicode strings */ + *bcc_ptr = 0; /* null byte password */ + bcc_ptr++; + } + } + + if (ses->server->secMode & + (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) + smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; + + if (ses->capabilities & CAP_STATUS32) { + smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; + } + if (ses->capabilities & CAP_DFS) { + smb_buffer->Flags2 |= SMBFLG2_DFS; + } + if (ses->capabilities & CAP_UNICODE) { + smb_buffer->Flags2 |= SMBFLG2_UNICODE; + length = + cifs_strtoUCS((__le16 *) bcc_ptr, tree, + 6 /* max utf8 char length in bytes */ * + (/* server len*/ + 256 /* share len */), nls_codepage); + bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ + bcc_ptr += 2; /* skip trailing null */ + } else { /* ASCII */ + strcpy(bcc_ptr, tree); + bcc_ptr += strlen(tree) + 1; + } + strcpy(bcc_ptr, ""?????""); + bcc_ptr += strlen(""?????""); + bcc_ptr += 1; + count = bcc_ptr - &pSMB->Password[0]; + pSMB->hdr.smb_buf_length += count; + pSMB->ByteCount = cpu_to_le16(count); + + rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, + CIFS_STD_OP); + + /* above now done in SendReceive */ + if ((rc == 0) && (tcon != NULL)) { + bool is_unicode; + + tcon->tidStatus = CifsGood; + tcon->need_reconnect = false; + tcon->tid = smb_buffer_response->Tid; + bcc_ptr = pByteArea(smb_buffer_response); + bytes_left = BCC(smb_buffer_response); + length = strnlen(bcc_ptr, bytes_left - 2); + if (smb_buffer->Flags2 & SMBFLG2_UNICODE) + is_unicode = true; + else + is_unicode = false; + + + /* skip service field (NB: this field is always ASCII) */ + if (length == 3) { + if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') && + (bcc_ptr[2] == 'C')) { + cFYI(1, ""IPC connection""); + tcon->ipc = 1; + } + } else if (length == 2) { + if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) { + /* the most common case */ + cFYI(1, ""disk share connection""); + } + } + bcc_ptr += length + 1; + bytes_left -= (length + 1); + strncpy(tcon->treeName, tree, MAX_TREE_SIZE); + + /* mostly informational -- no need to fail on error here */ + kfree(tcon->nativeFileSystem); + tcon->nativeFileSystem = cifs_strndup_from_ucs(bcc_ptr, + bytes_left, is_unicode, + nls_codepage); + + cFYI(1, ""nativeFileSystem=%s"", tcon->nativeFileSystem); + + if ((smb_buffer_response->WordCount == 3) || + (smb_buffer_response->WordCount == 7)) + /* field is in same location */ + tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); + else + tcon->Flags = 0; + cFYI(1, ""Tcon flags: 0x%x "", tcon->Flags); + } else if ((rc == 0) && tcon == NULL) { + /* all we need to save for IPC$ connection */ + ses->ipc_tid = smb_buffer_response->Tid; + } + + cifs_buf_release(smb_buffer); + return rc; +} +",0,"CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, + const char *tree, struct cifsTconInfo *tcon, + const struct nls_table *nls_codepage) +{ + struct smb_hdr *smb_buffer; + struct smb_hdr *smb_buffer_response; + TCONX_REQ *pSMB; + TCONX_RSP *pSMBr; + unsigned char *bcc_ptr; + int rc = 0; + int length, bytes_left; + __u16 count; + + if (ses == NULL) + return -EIO; + + smb_buffer = cifs_buf_get(); + if (smb_buffer == NULL) + return -ENOMEM; + + smb_buffer_response = smb_buffer; + + header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX, + NULL /*no tid */ , 4 /*wct */ ); + + smb_buffer->Mid = GetNextMid(ses->server); + smb_buffer->Uid = ses->Suid; + pSMB = (TCONX_REQ *) smb_buffer; + pSMBr = (TCONX_RSP *) smb_buffer_response; + + pSMB->AndXCommand = 0xFF; + pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); + bcc_ptr = &pSMB->Password[0]; + if ((ses->server->secMode) & SECMODE_USER) { + pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ + *bcc_ptr = 0; /* password is null byte */ + bcc_ptr++; /* skip password */ + /* already aligned so no need to do it below */ + } else { + pSMB->PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); + /* BB FIXME add code to fail this if NTLMv2 or Kerberos + specified as required (when that support is added to + the vfs in the future) as only NTLM or the much + weaker LANMAN (which we do not send by default) is accepted + by Samba (not sure whether other servers allow + NTLMv2 password here) */ +#ifdef CONFIG_CIFS_WEAK_PW_HASH + if ((global_secflags & CIFSSEC_MAY_LANMAN) && + (ses->server->secType == LANMAN)) + calc_lanman_hash(tcon->password, ses->server->cryptKey, + ses->server->secMode & + SECMODE_PW_ENCRYPT ? true : false, + bcc_ptr); + else +#endif /* CIFS_WEAK_PW_HASH */ + SMBNTencrypt(tcon->password, ses->server->cryptKey, + bcc_ptr); + + bcc_ptr += CIFS_SESS_KEY_SIZE; + if (ses->capabilities & CAP_UNICODE) { + /* must align unicode strings */ + *bcc_ptr = 0; /* null byte password */ + bcc_ptr++; + } + } + + if (ses->server->secMode & + (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) + smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; + + if (ses->capabilities & CAP_STATUS32) { + smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; + } + if (ses->capabilities & CAP_DFS) { + smb_buffer->Flags2 |= SMBFLG2_DFS; + } + if (ses->capabilities & CAP_UNICODE) { + smb_buffer->Flags2 |= SMBFLG2_UNICODE; + length = + cifs_strtoUCS((__le16 *) bcc_ptr, tree, + 6 /* max utf8 char length in bytes */ * + (/* server len*/ + 256 /* share len */), nls_codepage); + bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */ + bcc_ptr += 2; /* skip trailing null */ + } else { /* ASCII */ + strcpy(bcc_ptr, tree); + bcc_ptr += strlen(tree) + 1; + } + strcpy(bcc_ptr, ""?????""); + bcc_ptr += strlen(""?????""); + bcc_ptr += 1; + count = bcc_ptr - &pSMB->Password[0]; + pSMB->hdr.smb_buf_length += count; + pSMB->ByteCount = cpu_to_le16(count); + + rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, + CIFS_STD_OP); + + /* above now done in SendReceive */ + if ((rc == 0) && (tcon != NULL)) { + bool is_unicode; + + tcon->tidStatus = CifsGood; + tcon->need_reconnect = false; + tcon->tid = smb_buffer_response->Tid; + bcc_ptr = pByteArea(smb_buffer_response); + bytes_left = BCC(smb_buffer_response); + length = strnlen(bcc_ptr, bytes_left - 2); + if (smb_buffer->Flags2 & SMBFLG2_UNICODE) + is_unicode = true; + else + is_unicode = false; + + + /* skip service field (NB: this field is always ASCII) */ + if (length == 3) { + if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') && + (bcc_ptr[2] == 'C')) { + cFYI(1, ""IPC connection""); + tcon->ipc = 1; + } + } else if (length == 2) { + if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) { + /* the most common case */ + cFYI(1, ""disk share connection""); + } + } + bcc_ptr += length + 1; + bytes_left -= (length + 1); + strncpy(tcon->treeName, tree, MAX_TREE_SIZE); + + /* mostly informational -- no need to fail on error here */ + kfree(tcon->nativeFileSystem); + tcon->nativeFileSystem = cifs_strndup_from_ucs(bcc_ptr, + bytes_left, is_unicode, + nls_codepage); + + cFYI(1, ""nativeFileSystem=%s"", tcon->nativeFileSystem); + + if ((smb_buffer_response->WordCount == 3) || + (smb_buffer_response->WordCount == 7)) + /* field is in same location */ + tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); + else + tcon->Flags = 0; + cFYI(1, ""Tcon flags: 0x%x "", tcon->Flags); + } else if ((rc == 0) && tcon == NULL) { + /* all we need to save for IPC$ connection */ + ses->ipc_tid = smb_buffer_response->Tid; + } + + cifs_buf_release(smb_buffer); + return rc; +} +","@@ -1644,17 +1644,27 @@ cifs_get_tcp_session(struct smb_vol *volume_info) + } + + static struct cifsSesInfo * +-cifs_find_smb_ses(struct TCP_Server_Info *server, char *username) ++cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol) + { +- struct list_head *tmp; + struct cifsSesInfo *ses; + + write_lock(&cifs_tcp_ses_lock); +- list_for_each(tmp, &server->smb_ses_list) { +- ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); +- if (strncmp(ses->userName, username, MAX_USERNAME_SIZE)) +- continue; +- ++ list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { ++ switch (server->secType) { ++ case Kerberos: ++ if (vol->linux_uid != ses->linux_uid) ++ continue; ++ break; ++ default: ++ /* anything else takes username/password */ ++ if (strncmp(ses->userName, vol->username, ++ MAX_USERNAME_SIZE)) ++ continue; ++ if (strlen(vol->username) != 0 && ++ strncmp(ses->password, vol->password, ++ MAX_PASSWORD_SIZE)) ++ continue; ++ } + ++ses->ses_count; + write_unlock(&cifs_tcp_ses_lock); + return ses; +@@ -1696,7 +1706,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) + + xid = GetXid(); + +- ses = cifs_find_smb_ses(server, volume_info->username); ++ ses = cifs_find_smb_ses(server, volume_info); + if (ses) { + cFYI(1, ""Existing smb sess found (status=%d)"", ses->status); + ",1487,1723,2048 +7042,"static int jpc_dec_tilefini(jpc_dec_t *dec, jpc_dec_tile_t *tile) +{ + jpc_dec_tcomp_t *tcomp; + int compno; + int bandno; + int rlvlno; + jpc_dec_band_t *band; + jpc_dec_rlvl_t *rlvl; + int prcno; + jpc_dec_prc_t *prc; + jpc_dec_seg_t *seg; + jpc_dec_cblk_t *cblk; + int cblkno; + + if (tile->tcomps) { + + for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps; + ++compno, ++tcomp) { + for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls; + ++rlvlno, ++rlvl) { + if (!rlvl->bands) { + continue; + } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + if (band->prcs) { + for (prcno = 0, prc = band->prcs; prcno < + rlvl->numprcs; ++prcno, ++prc) { + if (!prc->cblks) { + continue; + } + for (cblkno = 0, cblk = prc->cblks; cblkno < + prc->numcblks; ++cblkno, ++cblk) { + + while (cblk->segs.head) { + seg = cblk->segs.head; + jpc_seglist_remove(&cblk->segs, seg); + jpc_seg_destroy(seg); + } + jas_matrix_destroy(cblk->data); + if (cblk->mqdec) { + jpc_mqdec_destroy(cblk->mqdec); + } + if (cblk->nulldec) { + jpc_bitstream_close(cblk->nulldec); + } + if (cblk->flags) { + jas_matrix_destroy(cblk->flags); + } + } + if (prc->incltagtree) { + jpc_tagtree_destroy(prc->incltagtree); + } + if (prc->numimsbstagtree) { + jpc_tagtree_destroy(prc->numimsbstagtree); + } + if (prc->cblks) { + jas_free(prc->cblks); + } + } + } + if (band->data) { + jas_matrix_destroy(band->data); + } + if (band->prcs) { + jas_free(band->prcs); + } + } + if (rlvl->bands) { + jas_free(rlvl->bands); + } + } + if (tcomp->rlvls) { + jas_free(tcomp->rlvls); + } + if (tcomp->data) { + jas_matrix_destroy(tcomp->data); + } + if (tcomp->tsfb) { + jpc_tsfb_destroy(tcomp->tsfb); + } + } + } + + if (tile->cp) { + jpc_dec_cp_destroy(tile->cp); + } + if (tile->tcomps) { + jas_free(tile->tcomps); + } + if (tile->pi) { + jpc_pi_destroy(tile->pi); + } + if (tile->pkthdrstream) { + jas_stream_close(tile->pkthdrstream); + } + if (tile->pptstab) { + jpc_ppxstab_destroy(tile->pptstab); + } + + tile->state = JPC_TILE_DONE; + + return 0; +} +",0,"static int jpc_dec_tilefini(jpc_dec_t *dec, jpc_dec_tile_t *tile) +{ + jpc_dec_tcomp_t *tcomp; + int compno; + int bandno; + int rlvlno; + jpc_dec_band_t *band; + jpc_dec_rlvl_t *rlvl; + int prcno; + jpc_dec_prc_t *prc; + jpc_dec_seg_t *seg; + jpc_dec_cblk_t *cblk; + int cblkno; + + if (tile->tcomps) { + + for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps; + ++compno, ++tcomp) { + for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls; + ++rlvlno, ++rlvl) { + if (!rlvl->bands) { + continue; + } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + if (band->prcs) { + for (prcno = 0, prc = band->prcs; prcno < + rlvl->numprcs; ++prcno, ++prc) { + if (!prc->cblks) { + continue; + } + for (cblkno = 0, cblk = prc->cblks; cblkno < + prc->numcblks; ++cblkno, ++cblk) { + + while (cblk->segs.head) { + seg = cblk->segs.head; + jpc_seglist_remove(&cblk->segs, seg); + jpc_seg_destroy(seg); + } + jas_matrix_destroy(cblk->data); + if (cblk->mqdec) { + jpc_mqdec_destroy(cblk->mqdec); + } + if (cblk->nulldec) { + jpc_bitstream_close(cblk->nulldec); + } + if (cblk->flags) { + jas_matrix_destroy(cblk->flags); + } + } + if (prc->incltagtree) { + jpc_tagtree_destroy(prc->incltagtree); + } + if (prc->numimsbstagtree) { + jpc_tagtree_destroy(prc->numimsbstagtree); + } + if (prc->cblks) { + jas_free(prc->cblks); + } + } + } + if (band->data) { + jas_matrix_destroy(band->data); + } + if (band->prcs) { + jas_free(band->prcs); + } + } + if (rlvl->bands) { + jas_free(rlvl->bands); + } + } + if (tcomp->rlvls) { + jas_free(tcomp->rlvls); + } + if (tcomp->data) { + jas_matrix_destroy(tcomp->data); + } + if (tcomp->tsfb) { + jpc_tsfb_destroy(tcomp->tsfb); + } + } + } + + if (tile->cp) { + jpc_dec_cp_destroy(tile->cp); + } + if (tile->tcomps) { + jas_free(tile->tcomps); + } + if (tile->pi) { + jpc_pi_destroy(tile->pi); + } + if (tile->pkthdrstream) { + jas_stream_close(tile->pkthdrstream); + } + if (tile->pptstab) { + jpc_ppxstab_destroy(tile->pptstab); + } + + tile->state = JPC_TILE_DONE; + + return 0; +} +","@@ -1838,6 +1838,13 @@ static void jpc_undo_roi(jas_matrix_t *x, int roishift, int bgshift, int numbps) + bool warn; + uint_fast32_t mask; + ++ if (roishift < 0) { ++ /* We could instead return an error here. */ ++ /* I do not think it matters much. */ ++ jas_eprintf(""warning: forcing negative ROI shift to zero "" ++ ""(bitstream is probably corrupt)\n""); ++ roishift = 0; ++ } + if (roishift == 0 && bgshift == 0) { + return; + } +@@ -1856,7 +1863,7 @@ static void jpc_undo_roi(jas_matrix_t *x, int roishift, int bgshift, int numbps) + } else { + /* We are dealing with non-ROI (i.e., background) data. */ + mag <<= bgshift; +- mask = (1 << numbps) - 1; ++ mask = (JAS_CAST(uint_fast32_t, 1) << numbps) - 1; + /* Perform a basic sanity check on the sample value. */ + /* Some implementations write garbage in the unused + most-significant bit planes introduced by ROI shifting.",838,1074,2048 +6668,"static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], + int num) +{ + struct dvb_usb_device *d = i2c_get_adapdata(adap); + struct usb_device *udev; + int len, i, j, ret; + + if (!d) + return -ENODEV; + udev = d->udev; + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) + return -EAGAIN; + + for (j = 0; j < num; j++) { + switch (msg[j].addr) { + case (DW2102_RC_QUERY): { + u8 ibuf[5]; + dw210x_op_rw(d->udev, 0xb8, 0, 0, + ibuf, 5, DW210X_READ_MSG); + memcpy(msg[j].buf, ibuf + 3, 2); + break; + } + case (DW2102_VOLTAGE_CTRL): { + u8 obuf[2]; + + obuf[0] = 1; + obuf[1] = msg[j].buf[1];/* off-on */ + dw210x_op_rw(d->udev, 0x8a, 0, 0, + obuf, 2, DW210X_WRITE_MSG); + obuf[0] = 3; + obuf[1] = msg[j].buf[0];/* 13v-18v */ + dw210x_op_rw(d->udev, 0x8a, 0, 0, + obuf, 2, DW210X_WRITE_MSG); + break; + } + case (DW2102_LED_CTRL): { + u8 obuf[2]; + + obuf[0] = 5; + obuf[1] = msg[j].buf[0]; + dw210x_op_rw(d->udev, 0x8a, 0, 0, + obuf, 2, DW210X_WRITE_MSG); + break; + } + /*case 0x55: cx24116 + case 0x6a: stv0903 + case 0x68: ds3000, stv0903, rs2000 + case 0x60: ts2020, stv6110, stb6100 + case 0xa0: eeprom */ + default: { + if (msg[j].flags == I2C_M_RD) { + /* read registers */ + u8 ibuf[MAX_XFER_SIZE]; + + if (msg[j].len > sizeof(ibuf)) { + warn(""i2c rd: len=%d is too big!\n"", + msg[j].len); + ret = -EOPNOTSUPP; + goto unlock; + } + + dw210x_op_rw(d->udev, 0x91, 0, 0, + ibuf, msg[j].len, + DW210X_READ_MSG); + memcpy(msg[j].buf, ibuf, msg[j].len); + break; + } else if ((msg[j].buf[0] == 0xb0) && + (msg[j].addr == 0x68)) { + /* write firmware */ + u8 obuf[19]; + obuf[0] = (msg[j].len > 16 ? + 18 : msg[j].len + 1); + obuf[1] = msg[j].addr << 1; + obuf[2] = msg[j].buf[0]; + len = msg[j].len - 1; + i = 1; + do { + memcpy(obuf + 3, msg[j].buf + i, + (len > 16 ? 16 : len)); + dw210x_op_rw(d->udev, 0x80, 0, 0, + obuf, (len > 16 ? 16 : len) + 3, + DW210X_WRITE_MSG); + i += 16; + len -= 16; + } while (len > 0); + } else if (j < (num - 1)) { + /* write register addr before read */ + u8 obuf[MAX_XFER_SIZE]; + + if (2 + msg[j].len > sizeof(obuf)) { + warn(""i2c wr: len=%d is too big!\n"", + msg[j].len); + ret = -EOPNOTSUPP; + goto unlock; + } + + obuf[0] = msg[j + 1].len; + obuf[1] = (msg[j].addr << 1); + memcpy(obuf + 2, msg[j].buf, msg[j].len); + dw210x_op_rw(d->udev, + le16_to_cpu(udev->descriptor.idProduct) == + 0x7500 ? 0x92 : 0x90, 0, 0, + obuf, msg[j].len + 2, + DW210X_WRITE_MSG); + break; + } else { + /* write registers */ + u8 obuf[MAX_XFER_SIZE]; + + if (2 + msg[j].len > sizeof(obuf)) { + warn(""i2c wr: len=%d is too big!\n"", + msg[j].len); + ret = -EOPNOTSUPP; + goto unlock; + } + obuf[0] = msg[j].len + 1; + obuf[1] = (msg[j].addr << 1); + memcpy(obuf + 2, msg[j].buf, msg[j].len); + dw210x_op_rw(d->udev, 0x80, 0, 0, + obuf, msg[j].len + 2, + DW210X_WRITE_MSG); + break; + } + break; + } + } + } + ret = num; + +unlock: + mutex_unlock(&d->i2c_mutex); + return ret; +} +",0,"static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], + int num) +{ + struct dvb_usb_device *d = i2c_get_adapdata(adap); + struct usb_device *udev; + int len, i, j, ret; + + if (!d) + return -ENODEV; + udev = d->udev; + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) + return -EAGAIN; + + for (j = 0; j < num; j++) { + switch (msg[j].addr) { + case (DW2102_RC_QUERY): { + u8 ibuf[5]; + dw210x_op_rw(d->udev, 0xb8, 0, 0, + ibuf, 5, DW210X_READ_MSG); + memcpy(msg[j].buf, ibuf + 3, 2); + break; + } + case (DW2102_VOLTAGE_CTRL): { + u8 obuf[2]; + + obuf[0] = 1; + obuf[1] = msg[j].buf[1];/* off-on */ + dw210x_op_rw(d->udev, 0x8a, 0, 0, + obuf, 2, DW210X_WRITE_MSG); + obuf[0] = 3; + obuf[1] = msg[j].buf[0];/* 13v-18v */ + dw210x_op_rw(d->udev, 0x8a, 0, 0, + obuf, 2, DW210X_WRITE_MSG); + break; + } + case (DW2102_LED_CTRL): { + u8 obuf[2]; + + obuf[0] = 5; + obuf[1] = msg[j].buf[0]; + dw210x_op_rw(d->udev, 0x8a, 0, 0, + obuf, 2, DW210X_WRITE_MSG); + break; + } + /*case 0x55: cx24116 + case 0x6a: stv0903 + case 0x68: ds3000, stv0903, rs2000 + case 0x60: ts2020, stv6110, stb6100 + case 0xa0: eeprom */ + default: { + if (msg[j].flags == I2C_M_RD) { + /* read registers */ + u8 ibuf[MAX_XFER_SIZE]; + + if (msg[j].len > sizeof(ibuf)) { + warn(""i2c rd: len=%d is too big!\n"", + msg[j].len); + ret = -EOPNOTSUPP; + goto unlock; + } + + dw210x_op_rw(d->udev, 0x91, 0, 0, + ibuf, msg[j].len, + DW210X_READ_MSG); + memcpy(msg[j].buf, ibuf, msg[j].len); + break; + } else if ((msg[j].buf[0] == 0xb0) && + (msg[j].addr == 0x68)) { + /* write firmware */ + u8 obuf[19]; + obuf[0] = (msg[j].len > 16 ? + 18 : msg[j].len + 1); + obuf[1] = msg[j].addr << 1; + obuf[2] = msg[j].buf[0]; + len = msg[j].len - 1; + i = 1; + do { + memcpy(obuf + 3, msg[j].buf + i, + (len > 16 ? 16 : len)); + dw210x_op_rw(d->udev, 0x80, 0, 0, + obuf, (len > 16 ? 16 : len) + 3, + DW210X_WRITE_MSG); + i += 16; + len -= 16; + } while (len > 0); + } else if (j < (num - 1)) { + /* write register addr before read */ + u8 obuf[MAX_XFER_SIZE]; + + if (2 + msg[j].len > sizeof(obuf)) { + warn(""i2c wr: len=%d is too big!\n"", + msg[j].len); + ret = -EOPNOTSUPP; + goto unlock; + } + + obuf[0] = msg[j + 1].len; + obuf[1] = (msg[j].addr << 1); + memcpy(obuf + 2, msg[j].buf, msg[j].len); + dw210x_op_rw(d->udev, + le16_to_cpu(udev->descriptor.idProduct) == + 0x7500 ? 0x92 : 0x90, 0, 0, + obuf, msg[j].len + 2, + DW210X_WRITE_MSG); + break; + } else { + /* write registers */ + u8 obuf[MAX_XFER_SIZE]; + + if (2 + msg[j].len > sizeof(obuf)) { + warn(""i2c wr: len=%d is too big!\n"", + msg[j].len); + ret = -EOPNOTSUPP; + goto unlock; + } + obuf[0] = msg[j].len + 1; + obuf[1] = (msg[j].addr << 1); + memcpy(obuf + 2, msg[j].buf, msg[j].len); + dw210x_op_rw(d->udev, 0x80, 0, 0, + obuf, msg[j].len + 2, + DW210X_WRITE_MSG); + break; + } + break; + } + } + } + ret = num; + +unlock: + mutex_unlock(&d->i2c_mutex); + return ret; +} +","@@ -68,6 +68,7 @@ + struct dw2102_state { + u8 initialized; + u8 last_lock; ++ u8 data[MAX_XFER_SIZE + 4]; + struct i2c_client *i2c_client_demod; + struct i2c_client *i2c_client_tuner; + +@@ -661,62 +662,72 @@ static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], + int num) + { + struct dvb_usb_device *d = i2c_get_adapdata(adap); +- u8 obuf[0x40], ibuf[0x40]; ++ struct dw2102_state *state; + + if (!d) + return -ENODEV; ++ ++ state = d->priv; ++ + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) + return -EAGAIN; ++ if (mutex_lock_interruptible(&d->data_mutex) < 0) { ++ mutex_unlock(&d->i2c_mutex); ++ return -EAGAIN; ++ } + + switch (num) { + case 1: + switch (msg[0].addr) { + case SU3000_STREAM_CTRL: +- obuf[0] = msg[0].buf[0] + 0x36; +- obuf[1] = 3; +- obuf[2] = 0; +- if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0) ++ state->data[0] = msg[0].buf[0] + 0x36; ++ state->data[1] = 3; ++ state->data[2] = 0; ++ if (dvb_usb_generic_rw(d, state->data, 3, ++ state->data, 0, 0) < 0) + err(""i2c transfer failed.""); + break; + case DW2102_RC_QUERY: +- obuf[0] = 0x10; +- if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0) ++ state->data[0] = 0x10; ++ if (dvb_usb_generic_rw(d, state->data, 1, ++ state->data, 2, 0) < 0) + err(""i2c transfer failed.""); +- msg[0].buf[1] = ibuf[0]; +- msg[0].buf[0] = ibuf[1]; ++ msg[0].buf[1] = state->data[0]; ++ msg[0].buf[0] = state->data[1]; + break; + default: + /* always i2c write*/ +- obuf[0] = 0x08; +- obuf[1] = msg[0].addr; +- obuf[2] = msg[0].len; ++ state->data[0] = 0x08; ++ state->data[1] = msg[0].addr; ++ state->data[2] = msg[0].len; + +- memcpy(&obuf[3], msg[0].buf, msg[0].len); ++ memcpy(&state->data[3], msg[0].buf, msg[0].len); + +- if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3, +- ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, msg[0].len + 3, ++ state->data, 1, 0) < 0) + err(""i2c transfer failed.""); + + } + break; + case 2: + /* always i2c read */ +- obuf[0] = 0x09; +- obuf[1] = msg[0].len; +- obuf[2] = msg[1].len; +- obuf[3] = msg[0].addr; +- memcpy(&obuf[4], msg[0].buf, msg[0].len); +- +- if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4, +- ibuf, msg[1].len + 1, 0) < 0) ++ state->data[0] = 0x09; ++ state->data[1] = msg[0].len; ++ state->data[2] = msg[1].len; ++ state->data[3] = msg[0].addr; ++ memcpy(&state->data[4], msg[0].buf, msg[0].len); ++ ++ if (dvb_usb_generic_rw(d, state->data, msg[0].len + 4, ++ state->data, msg[1].len + 1, 0) < 0) + err(""i2c transfer failed.""); + +- memcpy(msg[1].buf, &ibuf[1], msg[1].len); ++ memcpy(msg[1].buf, &state->data[1], msg[1].len); + break; + default: + warn(""more than 2 i2c messages at a time is not handled yet.""); + break; + } ++ mutex_unlock(&d->data_mutex); + mutex_unlock(&d->i2c_mutex); + return num; + } +@@ -844,17 +855,23 @@ static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) + static int su3000_power_ctrl(struct dvb_usb_device *d, int i) + { + struct dw2102_state *state = (struct dw2102_state *)d->priv; +- u8 obuf[] = {0xde, 0}; ++ int ret = 0; + + info(""%s: %d, initialized %d"", __func__, i, state->initialized); + + if (i && !state->initialized) { ++ mutex_lock(&d->data_mutex); ++ ++ state->data[0] = 0xde; ++ state->data[1] = 0; ++ + state->initialized = 1; + /* reset board */ +- return dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0); ++ ret = dvb_usb_generic_rw(d, state->data, 2, NULL, 0, 0); ++ mutex_unlock(&d->data_mutex); + } + +- return 0; ++ return ret; + } + + static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) +@@ -1309,49 +1326,57 @@ static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) + return 0; + } + +-static int su3000_frontend_attach(struct dvb_usb_adapter *d) ++static int su3000_frontend_attach(struct dvb_usb_adapter *adap) + { +- u8 obuf[3] = { 0xe, 0x80, 0 }; +- u8 ibuf[] = { 0 }; ++ struct dvb_usb_device *d = adap->dev; ++ struct dw2102_state *state = d->priv; ++ ++ mutex_lock(&d->data_mutex); ++ ++ state->data[0] = 0xe; ++ state->data[1] = 0x80; ++ state->data[2] = 0; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0xe; +- obuf[1] = 0x02; +- obuf[2] = 1; ++ state->data[0] = 0xe; ++ state->data[1] = 0x02; ++ state->data[2] = 1; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + msleep(300); + +- obuf[0] = 0xe; +- obuf[1] = 0x83; +- obuf[2] = 0; ++ state->data[0] = 0xe; ++ state->data[1] = 0x83; ++ state->data[2] = 0; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0xe; +- obuf[1] = 0x83; +- obuf[2] = 1; ++ state->data[0] = 0xe; ++ state->data[1] = 0x83; ++ state->data[2] = 1; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0x51; ++ state->data[0] = 0x51; + +- if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) + err(""command 0x51 transfer failed.""); + +- d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, +- &d->dev->i2c_adap); +- if (d->fe_adap[0].fe == NULL) ++ mutex_unlock(&d->data_mutex); ++ ++ adap->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, ++ &d->i2c_adap); ++ if (adap->fe_adap[0].fe == NULL) + return -EIO; + +- if (dvb_attach(ts2020_attach, d->fe_adap[0].fe, ++ if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, + &dw2104_ts2020_config, +- &d->dev->i2c_adap)) { ++ &d->i2c_adap)) { + info(""Attached DS3000/TS2020!""); + return 0; + } +@@ -1360,47 +1385,55 @@ static int su3000_frontend_attach(struct dvb_usb_adapter *d) + return -EIO; + } + +-static int t220_frontend_attach(struct dvb_usb_adapter *d) ++static int t220_frontend_attach(struct dvb_usb_adapter *adap) + { +- u8 obuf[3] = { 0xe, 0x87, 0 }; +- u8 ibuf[] = { 0 }; ++ struct dvb_usb_device *d = adap->dev; ++ struct dw2102_state *state = d->priv; ++ ++ mutex_lock(&d->data_mutex); + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ state->data[0] = 0xe; ++ state->data[1] = 0x87; ++ state->data[2] = 0x0; ++ ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0xe; +- obuf[1] = 0x86; +- obuf[2] = 1; ++ state->data[0] = 0xe; ++ state->data[1] = 0x86; ++ state->data[2] = 1; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0xe; +- obuf[1] = 0x80; +- obuf[2] = 0; ++ state->data[0] = 0xe; ++ state->data[1] = 0x80; ++ state->data[2] = 0; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + + msleep(50); + +- obuf[0] = 0xe; +- obuf[1] = 0x80; +- obuf[2] = 1; ++ state->data[0] = 0xe; ++ state->data[1] = 0x80; ++ state->data[2] = 1; + +- if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0x51; ++ state->data[0] = 0x51; + +- if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) + err(""command 0x51 transfer failed.""); + +- d->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, +- &d->dev->i2c_adap, NULL); +- if (d->fe_adap[0].fe != NULL) { +- if (dvb_attach(tda18271_attach, d->fe_adap[0].fe, 0x60, +- &d->dev->i2c_adap, &tda18271_config)) { ++ mutex_unlock(&d->data_mutex); ++ ++ adap->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, ++ &d->i2c_adap, NULL); ++ if (adap->fe_adap[0].fe != NULL) { ++ if (dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0x60, ++ &d->i2c_adap, &tda18271_config)) { + info(""Attached TDA18271HD/CXD2820R!""); + return 0; + } +@@ -1410,23 +1443,30 @@ static int t220_frontend_attach(struct dvb_usb_adapter *d) + return -EIO; + } + +-static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d) ++static int m88rs2000_frontend_attach(struct dvb_usb_adapter *adap) + { +- u8 obuf[] = { 0x51 }; +- u8 ibuf[] = { 0 }; ++ struct dvb_usb_device *d = adap->dev; ++ struct dw2102_state *state = d->priv; ++ ++ mutex_lock(&d->data_mutex); + +- if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) ++ state->data[0] = 0x51; ++ ++ if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) + err(""command 0x51 transfer failed.""); + +- d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config, +- &d->dev->i2c_adap); ++ mutex_unlock(&d->data_mutex); + +- if (d->fe_adap[0].fe == NULL) ++ adap->fe_adap[0].fe = dvb_attach(m88rs2000_attach, ++ &s421_m88rs2000_config, ++ &d->i2c_adap); ++ ++ if (adap->fe_adap[0].fe == NULL) + return -EIO; + +- if (dvb_attach(ts2020_attach, d->fe_adap[0].fe, ++ if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, + &dw2104_ts2020_config, +- &d->dev->i2c_adap)) { ++ &d->i2c_adap)) { + info(""Attached RS2000/TS2020!""); + return 0; + } +@@ -1439,44 +1479,50 @@ static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap) + { + struct dvb_usb_device *d = adap->dev; + struct dw2102_state *state = d->priv; +- u8 obuf[3] = { 0xe, 0x80, 0 }; +- u8 ibuf[] = { 0 }; + struct i2c_adapter *i2c_adapter; + struct i2c_client *client; + struct i2c_board_info board_info; + struct m88ds3103_platform_data m88ds3103_pdata = {}; + struct ts2020_config ts2020_config = {}; + +- if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 1, 0) < 0) ++ mutex_lock(&d->data_mutex); ++ ++ state->data[0] = 0xe; ++ state->data[1] = 0x80; ++ state->data[2] = 0x0; ++ ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0xe; +- obuf[1] = 0x02; +- obuf[2] = 1; ++ state->data[0] = 0xe; ++ state->data[1] = 0x02; ++ state->data[2] = 1; + +- if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + msleep(300); + +- obuf[0] = 0xe; +- obuf[1] = 0x83; +- obuf[2] = 0; ++ state->data[0] = 0xe; ++ state->data[1] = 0x83; ++ state->data[2] = 0; + +- if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0xe; +- obuf[1] = 0x83; +- obuf[2] = 1; ++ state->data[0] = 0xe; ++ state->data[1] = 0x83; ++ state->data[2] = 1; + +- if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) + err(""command 0x0e transfer failed.""); + +- obuf[0] = 0x51; ++ state->data[0] = 0x51; + +- if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 1, 0) < 0) ++ if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) + err(""command 0x51 transfer failed.""); + ++ mutex_unlock(&d->data_mutex); ++ + /* attach demod */ + m88ds3103_pdata.clk = 27000000; + m88ds3103_pdata.i2c_wr_max = 33;",1384,1620,2048 +3502,"static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, + struct sk_buff *skb) +{ + struct nci_rf_intf_activated_ntf ntf; + __u8 *data = skb->data; + int err = NCI_STATUS_OK; + + ntf.rf_discovery_id = *data++; + ntf.rf_interface = *data++; + ntf.rf_protocol = *data++; + ntf.activation_rf_tech_and_mode = *data++; + ntf.max_data_pkt_payload_size = *data++; + ntf.initial_num_credits = *data++; + ntf.rf_tech_specific_params_len = *data++; + + pr_debug(""rf_discovery_id %d\n"", ntf.rf_discovery_id); + pr_debug(""rf_interface 0x%x\n"", ntf.rf_interface); + pr_debug(""rf_protocol 0x%x\n"", ntf.rf_protocol); + pr_debug(""activation_rf_tech_and_mode 0x%x\n"", + ntf.activation_rf_tech_and_mode); + pr_debug(""max_data_pkt_payload_size 0x%x\n"", + ntf.max_data_pkt_payload_size); + pr_debug(""initial_num_credits 0x%x\n"", + ntf.initial_num_credits); + pr_debug(""rf_tech_specific_params_len %d\n"", + ntf.rf_tech_specific_params_len); + + if (ntf.rf_tech_specific_params_len > 0) { + switch (ntf.activation_rf_tech_and_mode) { + case NCI_NFC_A_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfca_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfca_poll), data); + break; + + case NCI_NFC_B_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcb_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfcb_poll), data); + break; + + case NCI_NFC_F_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcf_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfcf_poll), data); + break; + + default: + pr_err(""unsupported activation_rf_tech_and_mode 0x%x\n"", + ntf.activation_rf_tech_and_mode); + err = NCI_STATUS_RF_PROTOCOL_ERROR; + goto exit; + } + } + + ntf.data_exch_rf_tech_and_mode = *data++; + ntf.data_exch_tx_bit_rate = *data++; + ntf.data_exch_rx_bit_rate = *data++; + ntf.activation_params_len = *data++; + + pr_debug(""data_exch_rf_tech_and_mode 0x%x\n"", + ntf.data_exch_rf_tech_and_mode); + pr_debug(""data_exch_tx_bit_rate 0x%x\n"", ntf.data_exch_tx_bit_rate); + pr_debug(""data_exch_rx_bit_rate 0x%x\n"", ntf.data_exch_rx_bit_rate); + pr_debug(""activation_params_len %d\n"", ntf.activation_params_len); + + if (ntf.activation_params_len > 0) { + switch (ntf.rf_interface) { + case NCI_RF_INTERFACE_ISO_DEP: + err = nci_extract_activation_params_iso_dep(ndev, + &ntf, data); + break; + + case NCI_RF_INTERFACE_FRAME: + /* no activation params */ + break; + + default: + pr_err(""unsupported rf_interface 0x%x\n"", + ntf.rf_interface); + err = NCI_STATUS_RF_PROTOCOL_ERROR; + break; + } + } + +exit: + if (err == NCI_STATUS_OK) { + ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size; + ndev->initial_num_credits = ntf.initial_num_credits; + + /* set the available credits to initial value */ + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); + } + + if (atomic_read(&ndev->state) == NCI_DISCOVERY) { + /* A single target was found and activated automatically */ + atomic_set(&ndev->state, NCI_POLL_ACTIVE); + if (err == NCI_STATUS_OK) + nci_target_auto_activated(ndev, &ntf); + } else { /* ndev->state == NCI_W4_HOST_SELECT */ + /* A selected target was activated, so complete the request */ + atomic_set(&ndev->state, NCI_POLL_ACTIVE); + nci_req_complete(ndev, err); + } +} +",0,"static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, + struct sk_buff *skb) +{ + struct nci_rf_intf_activated_ntf ntf; + __u8 *data = skb->data; + int err = NCI_STATUS_OK; + + ntf.rf_discovery_id = *data++; + ntf.rf_interface = *data++; + ntf.rf_protocol = *data++; + ntf.activation_rf_tech_and_mode = *data++; + ntf.max_data_pkt_payload_size = *data++; + ntf.initial_num_credits = *data++; + ntf.rf_tech_specific_params_len = *data++; + + pr_debug(""rf_discovery_id %d\n"", ntf.rf_discovery_id); + pr_debug(""rf_interface 0x%x\n"", ntf.rf_interface); + pr_debug(""rf_protocol 0x%x\n"", ntf.rf_protocol); + pr_debug(""activation_rf_tech_and_mode 0x%x\n"", + ntf.activation_rf_tech_and_mode); + pr_debug(""max_data_pkt_payload_size 0x%x\n"", + ntf.max_data_pkt_payload_size); + pr_debug(""initial_num_credits 0x%x\n"", + ntf.initial_num_credits); + pr_debug(""rf_tech_specific_params_len %d\n"", + ntf.rf_tech_specific_params_len); + + if (ntf.rf_tech_specific_params_len > 0) { + switch (ntf.activation_rf_tech_and_mode) { + case NCI_NFC_A_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfca_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfca_poll), data); + break; + + case NCI_NFC_B_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcb_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfcb_poll), data); + break; + + case NCI_NFC_F_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcf_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfcf_poll), data); + break; + + default: + pr_err(""unsupported activation_rf_tech_and_mode 0x%x\n"", + ntf.activation_rf_tech_and_mode); + err = NCI_STATUS_RF_PROTOCOL_ERROR; + goto exit; + } + } + + ntf.data_exch_rf_tech_and_mode = *data++; + ntf.data_exch_tx_bit_rate = *data++; + ntf.data_exch_rx_bit_rate = *data++; + ntf.activation_params_len = *data++; + + pr_debug(""data_exch_rf_tech_and_mode 0x%x\n"", + ntf.data_exch_rf_tech_and_mode); + pr_debug(""data_exch_tx_bit_rate 0x%x\n"", ntf.data_exch_tx_bit_rate); + pr_debug(""data_exch_rx_bit_rate 0x%x\n"", ntf.data_exch_rx_bit_rate); + pr_debug(""activation_params_len %d\n"", ntf.activation_params_len); + + if (ntf.activation_params_len > 0) { + switch (ntf.rf_interface) { + case NCI_RF_INTERFACE_ISO_DEP: + err = nci_extract_activation_params_iso_dep(ndev, + &ntf, data); + break; + + case NCI_RF_INTERFACE_FRAME: + /* no activation params */ + break; + + default: + pr_err(""unsupported rf_interface 0x%x\n"", + ntf.rf_interface); + err = NCI_STATUS_RF_PROTOCOL_ERROR; + break; + } + } + +exit: + if (err == NCI_STATUS_OK) { + ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size; + ndev->initial_num_credits = ntf.initial_num_credits; + + /* set the available credits to initial value */ + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); + } + + if (atomic_read(&ndev->state) == NCI_DISCOVERY) { + /* A single target was found and activated automatically */ + atomic_set(&ndev->state, NCI_POLL_ACTIVE); + if (err == NCI_STATUS_OK) + nci_target_auto_activated(ndev, &ntf); + } else { /* ndev->state == NCI_W4_HOST_SELECT */ + /* A selected target was activated, so complete the request */ + atomic_set(&ndev->state, NCI_POLL_ACTIVE); + nci_req_complete(ndev, err); + } +} +","@@ -106,7 +106,7 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, + nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); + data += 2; + +- nfca_poll->nfcid1_len = *data++; ++ nfca_poll->nfcid1_len = min_t(__u8, *data++, NFC_NFCID1_MAXSIZE); + + pr_debug(""sens_res 0x%x, nfcid1_len %d\n"", + nfca_poll->sens_res, nfca_poll->nfcid1_len); +@@ -130,7 +130,7 @@ static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, + struct rf_tech_specific_params_nfcb_poll *nfcb_poll, + __u8 *data) + { +- nfcb_poll->sensb_res_len = *data++; ++ nfcb_poll->sensb_res_len = min_t(__u8, *data++, NFC_SENSB_RES_MAXSIZE); + + pr_debug(""sensb_res_len %d\n"", nfcb_poll->sensb_res_len); + +@@ -145,7 +145,7 @@ static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, + __u8 *data) + { + nfcf_poll->bit_rate = *data++; +- nfcf_poll->sensf_res_len = *data++; ++ nfcf_poll->sensf_res_len = min_t(__u8, *data++, NFC_SENSF_RES_MAXSIZE); + + pr_debug(""bit_rate %d, sensf_res_len %d\n"", + nfcf_poll->bit_rate, nfcf_poll->sensf_res_len); +@@ -331,7 +331,7 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, + switch (ntf->activation_rf_tech_and_mode) { + case NCI_NFC_A_PASSIVE_POLL_MODE: + nfca_poll = &ntf->activation_params.nfca_poll_iso_dep; +- nfca_poll->rats_res_len = *data++; ++ nfca_poll->rats_res_len = min_t(__u8, *data++, 20); + pr_debug(""rats_res_len %d\n"", nfca_poll->rats_res_len); + if (nfca_poll->rats_res_len > 0) { + memcpy(nfca_poll->rats_res, +@@ -341,7 +341,7 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, + + case NCI_NFC_B_PASSIVE_POLL_MODE: + nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep; +- nfcb_poll->attrib_res_len = *data++; ++ nfcb_poll->attrib_res_len = min_t(__u8, *data++, 50); + pr_debug(""attrib_res_len %d\n"", nfcb_poll->attrib_res_len); + if (nfcb_poll->attrib_res_len > 0) { + memcpy(nfcb_poll->attrib_res,",964,1200,2048 +17827,"static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) +{ + PCIDevice *pci_dev = PCI_DEVICE(s); + PCIDeviceClass *pci_class = PCI_DEVICE_GET_CLASS(pci_dev); + MegasasBaseClass *base_class = MEGASAS_DEVICE_GET_CLASS(s); + struct mfi_ctrl_info info; + size_t dcmd_size = sizeof(info); + BusChild *kid; + int num_pd_disks = 0; + + memset(&info, 0x0, dcmd_size); + if (cmd->iov_size < dcmd_size) { + trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size, + dcmd_size); + return MFI_STAT_INVALID_PARAMETER; + } + + info.pci.vendor = cpu_to_le16(pci_class->vendor_id); + info.pci.device = cpu_to_le16(pci_class->device_id); + info.pci.subvendor = cpu_to_le16(pci_class->subsystem_vendor_id); + info.pci.subdevice = cpu_to_le16(pci_class->subsystem_id); + + /* + * For some reason the firmware supports + * only up to 8 device ports. + * Despite supporting a far larger number + * of devices for the physical devices. + * So just display the first 8 devices + * in the device port list, independent + * of how many logical devices are actually + * present. + */ + info.host.type = MFI_INFO_HOST_PCIE; + info.device.type = MFI_INFO_DEV_SAS3G; + info.device.port_count = 8; + QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { + SCSIDevice *sdev = SCSI_DEVICE(kid->child); + uint16_t pd_id; + + if (num_pd_disks < 8) { + pd_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF); + info.device.port_addr[num_pd_disks] = + cpu_to_le64(megasas_get_sata_addr(pd_id)); + } + num_pd_disks++; + } + + memcpy(info.product_name, base_class->product_name, 24); + snprintf(info.serial_number, 32, ""%s"", s->hba_serial); + snprintf(info.package_version, 0x60, ""%s-QEMU"", qemu_hw_version()); + memcpy(info.image_component[0].name, ""APP"", 3); + snprintf(info.image_component[0].version, 10, ""%s-QEMU"", + base_class->product_version); + memcpy(info.image_component[0].build_date, ""Apr 1 2014"", 11); + memcpy(info.image_component[0].build_time, ""12:34:56"", 8); + info.image_component_count = 1; + if (pci_dev->has_rom) { + uint8_t biosver[32]; + uint8_t *ptr; + + ptr = memory_region_get_ram_ptr(&pci_dev->rom); + memcpy(biosver, ptr + 0x41, 31); + memcpy(info.image_component[1].name, ""BIOS"", 4); + memcpy(info.image_component[1].version, biosver, + strlen((const char *)biosver)); + } + info.current_fw_time = cpu_to_le32(megasas_fw_time()); + info.max_arms = 32; + info.max_spans = 8; + info.max_arrays = MEGASAS_MAX_ARRAYS; + info.max_lds = MFI_MAX_LD; + info.max_cmds = cpu_to_le16(s->fw_cmds); + info.max_sg_elements = cpu_to_le16(s->fw_sge); + info.max_request_size = cpu_to_le32(MEGASAS_MAX_SECTORS); + if (!megasas_is_jbod(s)) + info.lds_present = cpu_to_le16(num_pd_disks); + info.pd_present = cpu_to_le16(num_pd_disks); + info.pd_disks_present = cpu_to_le16(num_pd_disks); + info.hw_present = cpu_to_le32(MFI_INFO_HW_NVRAM | + MFI_INFO_HW_MEM | + MFI_INFO_HW_FLASH); + info.memory_size = cpu_to_le16(512); + info.nvram_size = cpu_to_le16(32); + info.flash_size = cpu_to_le16(16); + info.raid_levels = cpu_to_le32(MFI_INFO_RAID_0); + info.adapter_ops = cpu_to_le32(MFI_INFO_AOPS_RBLD_RATE | + MFI_INFO_AOPS_SELF_DIAGNOSTIC | + MFI_INFO_AOPS_MIXED_ARRAY); + info.ld_ops = cpu_to_le32(MFI_INFO_LDOPS_DISK_CACHE_POLICY | + MFI_INFO_LDOPS_ACCESS_POLICY | + MFI_INFO_LDOPS_IO_POLICY | + MFI_INFO_LDOPS_WRITE_POLICY | + MFI_INFO_LDOPS_READ_POLICY); + info.max_strips_per_io = cpu_to_le16(s->fw_sge); + info.stripe_sz_ops.min = 3; + info.stripe_sz_ops.max = ctz32(MEGASAS_MAX_SECTORS + 1); + info.properties.pred_fail_poll_interval = cpu_to_le16(300); + info.properties.intr_throttle_cnt = cpu_to_le16(16); + info.properties.intr_throttle_timeout = cpu_to_le16(50); + info.properties.rebuild_rate = 30; + info.properties.patrol_read_rate = 30; + info.properties.bgi_rate = 30; + info.properties.cc_rate = 30; + info.properties.recon_rate = 30; + info.properties.cache_flush_interval = 4; + info.properties.spinup_drv_cnt = 2; + info.properties.spinup_delay = 6; + info.properties.ecc_bucket_size = 15; + info.properties.ecc_bucket_leak_rate = cpu_to_le16(1440); + info.properties.expose_encl_devices = 1; + info.properties.OnOffProperties = cpu_to_le32(MFI_CTRL_PROP_EnableJBOD); + info.pd_ops = cpu_to_le32(MFI_INFO_PDOPS_FORCE_ONLINE | + MFI_INFO_PDOPS_FORCE_OFFLINE); + info.pd_mix_support = cpu_to_le32(MFI_INFO_PDMIX_SAS | + MFI_INFO_PDMIX_SATA | + MFI_INFO_PDMIX_LD); + + cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + return MFI_STAT_OK; +} +",1,"static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) +{ + PCIDevice *pci_dev = PCI_DEVICE(s); + PCIDeviceClass *pci_class = PCI_DEVICE_GET_CLASS(pci_dev); + MegasasBaseClass *base_class = MEGASAS_DEVICE_GET_CLASS(s); + struct mfi_ctrl_info info; + size_t dcmd_size = sizeof(info); + BusChild *kid; + int num_pd_disks = 0; + + memset(&info, 0x0, dcmd_size); + if (cmd->iov_size < dcmd_size) { + trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size, + dcmd_size); + return MFI_STAT_INVALID_PARAMETER; + } + + info.pci.vendor = cpu_to_le16(pci_class->vendor_id); + info.pci.device = cpu_to_le16(pci_class->device_id); + info.pci.subvendor = cpu_to_le16(pci_class->subsystem_vendor_id); + info.pci.subdevice = cpu_to_le16(pci_class->subsystem_id); + + /* + * For some reason the firmware supports + * only up to 8 device ports. + * Despite supporting a far larger number + * of devices for the physical devices. + * So just display the first 8 devices + * in the device port list, independent + * of how many logical devices are actually + * present. + */ + info.host.type = MFI_INFO_HOST_PCIE; + info.device.type = MFI_INFO_DEV_SAS3G; + info.device.port_count = 8; + QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { + SCSIDevice *sdev = SCSI_DEVICE(kid->child); + uint16_t pd_id; + + if (num_pd_disks < 8) { + pd_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF); + info.device.port_addr[num_pd_disks] = + cpu_to_le64(megasas_get_sata_addr(pd_id)); + } + num_pd_disks++; + } + + memcpy(info.product_name, base_class->product_name, 24); + snprintf(info.serial_number, 32, ""%s"", s->hba_serial); + snprintf(info.package_version, 0x60, ""%s-QEMU"", qemu_hw_version()); + memcpy(info.image_component[0].name, ""APP"", 3); + snprintf(info.image_component[0].version, 10, ""%s-QEMU"", + base_class->product_version); + memcpy(info.image_component[0].build_date, ""Apr 1 2014"", 11); + memcpy(info.image_component[0].build_time, ""12:34:56"", 8); + info.image_component_count = 1; + if (pci_dev->has_rom) { + uint8_t biosver[32]; + uint8_t *ptr; + + ptr = memory_region_get_ram_ptr(&pci_dev->rom); + memcpy(biosver, ptr + 0x41, 31); + biosver[31] = 0; + memcpy(info.image_component[1].name, ""BIOS"", 4); + memcpy(info.image_component[1].version, biosver, + strlen((const char *)biosver)); + } + info.current_fw_time = cpu_to_le32(megasas_fw_time()); + info.max_arms = 32; + info.max_spans = 8; + info.max_arrays = MEGASAS_MAX_ARRAYS; + info.max_lds = MFI_MAX_LD; + info.max_cmds = cpu_to_le16(s->fw_cmds); + info.max_sg_elements = cpu_to_le16(s->fw_sge); + info.max_request_size = cpu_to_le32(MEGASAS_MAX_SECTORS); + if (!megasas_is_jbod(s)) + info.lds_present = cpu_to_le16(num_pd_disks); + info.pd_present = cpu_to_le16(num_pd_disks); + info.pd_disks_present = cpu_to_le16(num_pd_disks); + info.hw_present = cpu_to_le32(MFI_INFO_HW_NVRAM | + MFI_INFO_HW_MEM | + MFI_INFO_HW_FLASH); + info.memory_size = cpu_to_le16(512); + info.nvram_size = cpu_to_le16(32); + info.flash_size = cpu_to_le16(16); + info.raid_levels = cpu_to_le32(MFI_INFO_RAID_0); + info.adapter_ops = cpu_to_le32(MFI_INFO_AOPS_RBLD_RATE | + MFI_INFO_AOPS_SELF_DIAGNOSTIC | + MFI_INFO_AOPS_MIXED_ARRAY); + info.ld_ops = cpu_to_le32(MFI_INFO_LDOPS_DISK_CACHE_POLICY | + MFI_INFO_LDOPS_ACCESS_POLICY | + MFI_INFO_LDOPS_IO_POLICY | + MFI_INFO_LDOPS_WRITE_POLICY | + MFI_INFO_LDOPS_READ_POLICY); + info.max_strips_per_io = cpu_to_le16(s->fw_sge); + info.stripe_sz_ops.min = 3; + info.stripe_sz_ops.max = ctz32(MEGASAS_MAX_SECTORS + 1); + info.properties.pred_fail_poll_interval = cpu_to_le16(300); + info.properties.intr_throttle_cnt = cpu_to_le16(16); + info.properties.intr_throttle_timeout = cpu_to_le16(50); + info.properties.rebuild_rate = 30; + info.properties.patrol_read_rate = 30; + info.properties.bgi_rate = 30; + info.properties.cc_rate = 30; + info.properties.recon_rate = 30; + info.properties.cache_flush_interval = 4; + info.properties.spinup_drv_cnt = 2; + info.properties.spinup_delay = 6; + info.properties.ecc_bucket_size = 15; + info.properties.ecc_bucket_leak_rate = cpu_to_le16(1440); + info.properties.expose_encl_devices = 1; + info.properties.OnOffProperties = cpu_to_le32(MFI_CTRL_PROP_EnableJBOD); + info.pd_ops = cpu_to_le32(MFI_INFO_PDOPS_FORCE_ONLINE | + MFI_INFO_PDOPS_FORCE_OFFLINE); + info.pd_mix_support = cpu_to_le32(MFI_INFO_PDMIX_SAS | + MFI_INFO_PDMIX_SATA | + MFI_INFO_PDMIX_LD); + + cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + return MFI_STAT_OK; +} +","@@ -773,6 +773,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) + + ptr = memory_region_get_ram_ptr(&pci_dev->rom); + memcpy(biosver, ptr + 0x41, 31); ++ biosver[31] = 0; + memcpy(info.image_component[1].name, ""BIOS"", 4); + memcpy(info.image_component[1].version, biosver, + strlen((const char *)biosver));",1464,1700,2048 +7764,"static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info, + const char *timestamp,ExceptionInfo *exception) +{ + int + ret; + + int + day, + hour, + minute, + month, + second, + year; + + int + addhours=0, + addminutes=0; + + png_time + ptime; + + assert(timestamp != (const char *) NULL); + LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing tIME chunk: timestamp property is %30s\n"",timestamp); + ret=sscanf(timestamp,""%d-%d-%dT%d:%d:%d"",&year,&month,&day,&hour, + &minute, &second); + addhours=0; + addminutes=0; + ret=sscanf(timestamp,""%d-%d-%dT%d:%d:%d%d:%d"",&year,&month,&day,&hour, + &minute, &second, &addhours, &addminutes); + LogMagickEvent(CoderEvent,GetMagickModule(), + "" Date format specified for png:tIME=%s"" ,timestamp); + LogMagickEvent(CoderEvent,GetMagickModule(), + "" ret=%d,y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, as=%d"", + ret,year,month,day,hour,minute,second,addhours,addminutes); + if (ret < 6) + { + LogMagickEvent(CoderEvent,GetMagickModule(), + "" Invalid date, ret=%d"",ret); + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + ""Invalid date format specified for png:tIME"",""`%s' (ret=%d)"", + image->filename,ret); + return; + } + if (addhours < 0) + { + addhours+=24; + addminutes=-addminutes; + day--; + } + hour+=addhours; + minute+=addminutes; + if (day == 0) + { + month--; + day=31; + if(month == 2) + day=28; + else + { + if(month == 4 || month == 6 || month == 9 || month == 11) + day=30; + else + day=31; + } + } + if (month == 0) + { + month++; + year--; + } + if (minute > 59) + { + hour++; + minute-=60; + } + if (hour > 23) + { + day ++; + hour -=24; + } + if (hour < 0) + { + day --; + hour +=24; + } + /* To do: fix this for leap years */ + if (day > 31 || (month == 2 && day > 28) || ((month == 4 || month == 6 || + month == 9 || month == 11) && day > 30)) + { + month++; + day = 1; + } + if (month > 12) + { + year++; + month=1; + } + + ptime.year = year; + ptime.month = month; + ptime.day = day; + ptime.hour = hour; + ptime.minute = minute; + ptime.second = second; + + LogMagickEvent(CoderEvent,GetMagickModule(), + "" png_set_tIME: y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, am=%d"", + ptime.year, ptime.month, ptime.day, ptime.hour, ptime.minute, + ptime.second, addhours, addminutes); + png_set_tIME(ping,info,&ptime); +} +",0,"static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info, + const char *timestamp,ExceptionInfo *exception) +{ + int + ret; + + int + day, + hour, + minute, + month, + second, + year; + + int + addhours=0, + addminutes=0; + + png_time + ptime; + + assert(timestamp != (const char *) NULL); + LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing tIME chunk: timestamp property is %30s\n"",timestamp); + ret=sscanf(timestamp,""%d-%d-%dT%d:%d:%d"",&year,&month,&day,&hour, + &minute, &second); + addhours=0; + addminutes=0; + ret=sscanf(timestamp,""%d-%d-%dT%d:%d:%d%d:%d"",&year,&month,&day,&hour, + &minute, &second, &addhours, &addminutes); + LogMagickEvent(CoderEvent,GetMagickModule(), + "" Date format specified for png:tIME=%s"" ,timestamp); + LogMagickEvent(CoderEvent,GetMagickModule(), + "" ret=%d,y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, as=%d"", + ret,year,month,day,hour,minute,second,addhours,addminutes); + if (ret < 6) + { + LogMagickEvent(CoderEvent,GetMagickModule(), + "" Invalid date, ret=%d"",ret); + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + ""Invalid date format specified for png:tIME"",""`%s' (ret=%d)"", + image->filename,ret); + return; + } + if (addhours < 0) + { + addhours+=24; + addminutes=-addminutes; + day--; + } + hour+=addhours; + minute+=addminutes; + if (day == 0) + { + month--; + day=31; + if(month == 2) + day=28; + else + { + if(month == 4 || month == 6 || month == 9 || month == 11) + day=30; + else + day=31; + } + } + if (month == 0) + { + month++; + year--; + } + if (minute > 59) + { + hour++; + minute-=60; + } + if (hour > 23) + { + day ++; + hour -=24; + } + if (hour < 0) + { + day --; + hour +=24; + } + /* To do: fix this for leap years */ + if (day > 31 || (month == 2 && day > 28) || ((month == 4 || month == 6 || + month == 9 || month == 11) && day > 30)) + { + month++; + day = 1; + } + if (month > 12) + { + year++; + month=1; + } + + ptime.year = year; + ptime.month = month; + ptime.day = day; + ptime.hour = hour; + ptime.minute = minute; + ptime.second = second; + + LogMagickEvent(CoderEvent,GetMagickModule(), + "" png_set_tIME: y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, am=%d"", + ptime.year, ptime.month, ptime.day, ptime.hour, ptime.minute, + ptime.second, addhours, addminutes); + png_set_tIME(ping,info,&ptime); +} +","@@ -4560,7 +4560,11 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); + + if (chunk == (unsigned char *) NULL) +- ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ { ++ DestroyJNG(NULL,&color_image,&color_image_info, ++ &alpha_image,&alpha_image_info); ++ ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ } + + for (i=0; i < (ssize_t) length; i++) + { +@@ -4587,13 +4591,12 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + jng_width=(png_uint_32)mng_get_long(p); + jng_height=(png_uint_32)mng_get_long(&p[4]); + if ((jng_width == 0) || (jng_height == 0)) +- { +- DestroyJNG(chunk,&color_image,&color_image_info, +- &alpha_image,&alpha_image_info); +- +- ThrowReaderException(CorruptImageError, +- ""NegativeOrZeroImageSize""); +- } ++ { ++ DestroyJNG(chunk,&color_image,&color_image_info, ++ &alpha_image,&alpha_image_info); ++ ThrowReaderException(CorruptImageError, ++ ""NegativeOrZeroImageSize""); ++ } + jng_color_type=p[8]; + jng_image_sample_depth=p[9]; + jng_image_compression_method=p[10];",846,1082,2048 +18118,"grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) +{ + struct grub_ext2_data *data = node->data; + struct grub_ext2_inode *inode = &node->inode; + int blknr = -1; + unsigned int blksz = EXT2_BLOCK_SIZE (data); + int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data); + + if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG) + { +#ifndef _MSC_VER + char buf[EXT2_BLOCK_SIZE (data)]; +#else + char * buf = grub_malloc (EXT2_BLOCK_SIZE(data)); +#endif + struct grub_ext4_extent_header *leaf; + struct grub_ext4_extent *ext; + int i; + + leaf = grub_ext4_find_leaf (data, buf, + (struct grub_ext4_extent_header *) inode->blocks.dir_blocks, + fileblock); + if (! leaf) + { + grub_error (GRUB_ERR_BAD_FS, ""invalid extent""); + return -1; + } + + ext = (struct grub_ext4_extent *) (leaf + 1); + for (i = 0; i < grub_le_to_cpu16 (leaf->entries); i++) + { + if (fileblock < grub_le_to_cpu32 (ext[i].block)) + break; + } + + if (--i >= 0) + { + fileblock -= grub_le_to_cpu32 (ext[i].block); + if (fileblock >= grub_le_to_cpu16 (ext[i].len)) + return 0; + else + { + grub_disk_addr_t start; + + start = grub_le_to_cpu16 (ext[i].start_hi); + start = (start << 32) + grub_le_to_cpu32 (ext[i].start); + + return fileblock + start; + } + } + else + { + grub_error (GRUB_ERR_BAD_FS, ""something wrong with extent""); + return -1; + } + } + /* Direct blocks. */ + if (fileblock < INDIRECT_BLOCKS) { + blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]); + /* Indirect. */ + } else if (fileblock < INDIRECT_BLOCKS + blksz / 4) + { + grub_uint32_t *indir; + + indir = grub_malloc (blksz); + if (! indir) + return grub_errno; + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (inode->blocks.indir_block)) + << log2_blksz, + 0, blksz, indir)) + return grub_errno; + + blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]); + grub_free (indir); + } + /* Double indirect. */ + else if (fileblock < (grub_disk_addr_t)(INDIRECT_BLOCKS + blksz / 4) \ + * (grub_disk_addr_t)(blksz / 4 + 1)) + { + unsigned int perblock = blksz / 4; + unsigned int rblock = fileblock - (INDIRECT_BLOCKS + + blksz / 4); + grub_uint32_t *indir; + + indir = grub_malloc (blksz); + if (! indir) + return grub_errno; + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (inode->blocks.double_indir_block)) + << log2_blksz, + 0, blksz, indir)) + return grub_errno; + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (indir[rblock / perblock])) + << log2_blksz, + 0, blksz, indir)) + return grub_errno; + + blknr = grub_le_to_cpu32 (indir[rblock % perblock]); + grub_free (indir); + } + /* triple indirect. */ + else + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + ""ext2fs doesn't support triple indirect blocks""); + } + + return blknr; +} +",1,"grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) +{ + struct grub_ext2_data *data = node->data; + struct grub_ext2_inode *inode = &node->inode; + int blknr = -1; + unsigned int blksz = EXT2_BLOCK_SIZE (data); + int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data); + + if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG) + { + char * buf = grub_malloc (EXT2_BLOCK_SIZE (data)); + if (!buf) { + return -1; + } + struct grub_ext4_extent_header *leaf; + struct grub_ext4_extent *ext; + int i; + + leaf = grub_ext4_find_leaf (data, buf, + (struct grub_ext4_extent_header *) inode->blocks.dir_blocks, + fileblock); + if (! leaf) + { + grub_error (GRUB_ERR_BAD_FS, ""invalid extent""); + free (buf); + return -1; + } + + ext = (struct grub_ext4_extent *) (leaf + 1); + for (i = 0; i < grub_le_to_cpu16 (leaf->entries); i++) + { + if (fileblock < grub_le_to_cpu32 (ext[i].block)) + break; + } + + if (--i >= 0) + { + fileblock -= grub_le_to_cpu32 (ext[i].block); + if (fileblock >= grub_le_to_cpu16 (ext[i].len)) { + free (buf); + return 0; + } else + { + grub_disk_addr_t start; + + start = grub_le_to_cpu16 (ext[i].start_hi); + start = (start << 32) + grub_le_to_cpu32 (ext[i].start); + free (buf); + + return fileblock + start; + } + } + else + { + grub_error (GRUB_ERR_BAD_FS, ""something wrong with extent""); + free (buf); + return -1; + } +free (buf); + } + /* Direct blocks. */ + if (fileblock < INDIRECT_BLOCKS) { + blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]); + /* Indirect. */ + } else if (fileblock < INDIRECT_BLOCKS + blksz / 4) + { + grub_uint32_t *indir; + + indir = grub_malloc (blksz); + if (! indir) { + return grub_errno; +} + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (inode->blocks.indir_block)) + << log2_blksz, + 0, blksz, indir)) { + return grub_errno; +} + + blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]); + grub_free (indir); + } + /* Double indirect. */ + else if (fileblock < (grub_disk_addr_t)(INDIRECT_BLOCKS + blksz / 4) \ + * (grub_disk_addr_t)(blksz / 4 + 1)) + { + unsigned int perblock = blksz / 4; + unsigned int rblock = fileblock - (INDIRECT_BLOCKS + + blksz / 4); + grub_uint32_t *indir; + + indir = grub_malloc (blksz); + if (! indir) { + return grub_errno; +} + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (inode->blocks.double_indir_block)) + << log2_blksz, + 0, blksz, indir)) { + return grub_errno; +} + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (indir[rblock / perblock])) + << log2_blksz, + 0, blksz, indir)) { + return grub_errno; +} + + blknr = grub_le_to_cpu32 (indir[rblock % perblock]); + grub_free (indir); + } + /* triple indirect. */ + else + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + ""ext2fs doesn't support triple indirect blocks""); + } + + return blknr; +} +","@@ -42,6 +42,7 @@ + #define FILETYPE_INO_DIRECTORY 0040000 + #define FILETYPE_INO_SYMLINK 0120000 + ++#include + #include + #include + #include +@@ -367,8 +368,9 @@ grub_ext4_find_leaf (struct grub_ext2_data *data, char *buf, + block = (block << 32) + grub_le_to_cpu32 (index[i].leaf); + if (grub_disk_read (data->disk, + block << LOG2_EXT2_BLOCK_SIZE (data), +- 0, EXT2_BLOCK_SIZE(data), buf)) ++ 0, EXT2_BLOCK_SIZE(data), buf)) { + return 0; ++ } + + ext_block = (struct grub_ext4_extent_header *) buf; + } +@@ -385,11 +387,10 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + + if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG) + { +-#ifndef _MSC_VER +- char buf[EXT2_BLOCK_SIZE (data)]; +-#else +- char * buf = grub_malloc (EXT2_BLOCK_SIZE(data)); +-#endif ++ char * buf = grub_malloc (EXT2_BLOCK_SIZE (data)); ++ if (!buf) { ++ return -1; ++ } + struct grub_ext4_extent_header *leaf; + struct grub_ext4_extent *ext; + int i; +@@ -400,6 +401,7 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + if (! leaf) + { + grub_error (GRUB_ERR_BAD_FS, ""invalid extent""); ++ free (buf); + return -1; + } + +@@ -413,23 +415,27 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + if (--i >= 0) + { + fileblock -= grub_le_to_cpu32 (ext[i].block); +- if (fileblock >= grub_le_to_cpu16 (ext[i].len)) ++ if (fileblock >= grub_le_to_cpu16 (ext[i].len)) { ++ free (buf); + return 0; +- else ++ } else + { + grub_disk_addr_t start; + + start = grub_le_to_cpu16 (ext[i].start_hi); + start = (start << 32) + grub_le_to_cpu32 (ext[i].start); ++ free (buf); + + return fileblock + start; + } + } + else + { + grub_error (GRUB_ERR_BAD_FS, ""something wrong with extent""); ++ free (buf); + return -1; + } ++free (buf); + } + /* Direct blocks. */ + if (fileblock < INDIRECT_BLOCKS) { +@@ -440,15 +446,17 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + grub_uint32_t *indir; + + indir = grub_malloc (blksz); +- if (! indir) ++ if (! indir) { + return grub_errno; ++} + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (inode->blocks.indir_block)) + << log2_blksz, +- 0, blksz, indir)) ++ 0, blksz, indir)) { + return grub_errno; ++} + + blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]); + grub_free (indir); +@@ -463,22 +471,25 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + grub_uint32_t *indir; + + indir = grub_malloc (blksz); +- if (! indir) ++ if (! indir) { + return grub_errno; ++} + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (inode->blocks.double_indir_block)) + << log2_blksz, +- 0, blksz, indir)) ++ 0, blksz, indir)) { + return grub_errno; ++} + + if (grub_disk_read (data->disk, + ((grub_disk_addr_t) + grub_le_to_cpu32 (indir[rblock / perblock])) + << log2_blksz, +- 0, blksz, indir)) ++ 0, blksz, indir)) { + return grub_errno; ++} + + blknr = grub_le_to_cpu32 (indir[rblock % perblock]); + grub_free (indir);",942,1178,2048 +9286,"inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *w, char *url) { + static uint32_t hash_action = 0, hash_access = 0, hash_hello = 0, hash_delete = 0, hash_search = 0, + hash_switch = 0, hash_machine = 0, hash_url = 0, hash_name = 0, hash_delete_url = 0, hash_for = 0, + hash_to = 0 /*, hash_redirects = 0 */; + + if(unlikely(!hash_action)) { + hash_action = simple_hash(""action""); + hash_access = simple_hash(""access""); + hash_hello = simple_hash(""hello""); + hash_delete = simple_hash(""delete""); + hash_search = simple_hash(""search""); + hash_switch = simple_hash(""switch""); + hash_machine = simple_hash(""machine""); + hash_url = simple_hash(""url""); + hash_name = simple_hash(""name""); + hash_delete_url = simple_hash(""delete_url""); + hash_for = simple_hash(""for""); + hash_to = simple_hash(""to""); +/* + hash_redirects = simple_hash(""redirects""); +*/ + } + + char person_guid[GUID_LEN + 1] = """"; + + debug(D_WEB_CLIENT, ""%llu: API v1 registry with URL '%s'"", w->id, url); + + + char *cookie = strstr(w->response.data->buffer, NETDATA_REGISTRY_COOKIE_NAME ""=""); + if(cookie) + strncpyz(person_guid, &cookie[sizeof(NETDATA_REGISTRY_COOKIE_NAME)], 36); + + char action = '\0'; + char *machine_guid = NULL, + *machine_url = NULL, + *url_name = NULL, + *search_machine_guid = NULL, + *delete_url = NULL, + *to_person_guid = NULL; +/* + int redirects = 0; +*/ + + while(url) { + char *value = mystrsep(&url, ""?&""); + if (!value || !*value) continue; + + char *name = mystrsep(&value, ""=""); + if (!name || !*name) continue; + if (!value || !*value) continue; + + debug(D_WEB_CLIENT, ""%llu: API v1 registry query param '%s' with value '%s'"", w->id, name, value); + + uint32_t hash = simple_hash(name); + + if(hash == hash_action && !strcmp(name, ""action"")) { + uint32_t vhash = simple_hash(value); + + if(vhash == hash_access && !strcmp(value, ""access"")) action = 'A'; + else if(vhash == hash_hello && !strcmp(value, ""hello"")) action = 'H'; + else if(vhash == hash_delete && !strcmp(value, ""delete"")) action = 'D'; + else if(vhash == hash_search && !strcmp(value, ""search"")) action = 'S'; + else if(vhash == hash_switch && !strcmp(value, ""switch"")) action = 'W'; +#ifdef NETDATA_INTERNAL_CHECKS + else error(""unknown registry action '%s'"", value); +#endif /* NETDATA_INTERNAL_CHECKS */ + } +/* + else if(hash == hash_redirects && !strcmp(name, ""redirects"")) + redirects = atoi(value); +*/ + else if(hash == hash_machine && !strcmp(name, ""machine"")) + machine_guid = value; + + else if(hash == hash_url && !strcmp(name, ""url"")) + machine_url = value; + + else if(action == 'A') { + if(hash == hash_name && !strcmp(name, ""name"")) + url_name = value; + } + else if(action == 'D') { + if(hash == hash_delete_url && !strcmp(name, ""delete_url"")) + delete_url = value; + } + else if(action == 'S') { + if(hash == hash_for && !strcmp(name, ""for"")) + search_machine_guid = value; + } + else if(action == 'W') { + if(hash == hash_to && !strcmp(name, ""to"")) + to_person_guid = value; + } +#ifdef NETDATA_INTERNAL_CHECKS + else error(""unused registry URL parameter '%s' with value '%s'"", name, value); +#endif /* NETDATA_INTERNAL_CHECKS */ + } + + if(unlikely(respect_web_browser_do_not_track_policy && web_client_has_donottrack(w))) { + buffer_flush(w->response.data); + buffer_sprintf(w->response.data, ""Your web browser is sending 'DNT: 1' (Do Not Track). The registry requires persistent cookies on your browser to work.""); + return 400; + } + + if(unlikely(action == 'H')) { + if(unlikely(!web_client_can_access_dashboard(w))) + return web_client_permission_denied(w); + } + else { + if(unlikely(!web_client_can_access_registry(w))) + return web_client_permission_denied(w); + } + + switch(action) { + case 'A': + if(unlikely(!machine_guid || !machine_url || !url_name)) { + error(""Invalid registry request - access requires these parameters: machine ('%s'), url ('%s'), name ('%s')"", machine_guid ? machine_guid : ""UNSET"", machine_url ? machine_url : ""UNSET"", url_name ? url_name : ""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Access request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_access_json(host, w, person_guid, machine_guid, machine_url, url_name, now_realtime_sec()); + + case 'D': + if(unlikely(!machine_guid || !machine_url || !delete_url)) { + error(""Invalid registry request - delete requires these parameters: machine ('%s'), url ('%s'), delete_url ('%s')"", machine_guid?machine_guid:""UNSET"", machine_url?machine_url:""UNSET"", delete_url?delete_url:""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Delete request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_delete_json(host, w, person_guid, machine_guid, machine_url, delete_url, now_realtime_sec()); + + case 'S': + if(unlikely(!machine_guid || !machine_url || !search_machine_guid)) { + error(""Invalid registry request - search requires these parameters: machine ('%s'), url ('%s'), for ('%s')"", machine_guid?machine_guid:""UNSET"", machine_url?machine_url:""UNSET"", search_machine_guid?search_machine_guid:""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Search request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_search_json(host, w, person_guid, machine_guid, machine_url, search_machine_guid, now_realtime_sec()); + + case 'W': + if(unlikely(!machine_guid || !machine_url || !to_person_guid)) { + error(""Invalid registry request - switching identity requires these parameters: machine ('%s'), url ('%s'), to ('%s')"", machine_guid?machine_guid:""UNSET"", machine_url?machine_url:""UNSET"", to_person_guid?to_person_guid:""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Switch request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_switch_json(host, w, person_guid, machine_guid, machine_url, to_person_guid, now_realtime_sec()); + + case 'H': + return registry_request_hello_json(host, w); + + default: + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry request - you need to set an action: hello, access, delete, search""); + return 400; + } +} +",0,"inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *w, char *url) { + static uint32_t hash_action = 0, hash_access = 0, hash_hello = 0, hash_delete = 0, hash_search = 0, + hash_switch = 0, hash_machine = 0, hash_url = 0, hash_name = 0, hash_delete_url = 0, hash_for = 0, + hash_to = 0 /*, hash_redirects = 0 */; + + if(unlikely(!hash_action)) { + hash_action = simple_hash(""action""); + hash_access = simple_hash(""access""); + hash_hello = simple_hash(""hello""); + hash_delete = simple_hash(""delete""); + hash_search = simple_hash(""search""); + hash_switch = simple_hash(""switch""); + hash_machine = simple_hash(""machine""); + hash_url = simple_hash(""url""); + hash_name = simple_hash(""name""); + hash_delete_url = simple_hash(""delete_url""); + hash_for = simple_hash(""for""); + hash_to = simple_hash(""to""); +/* + hash_redirects = simple_hash(""redirects""); +*/ + } + + char person_guid[GUID_LEN + 1] = """"; + + debug(D_WEB_CLIENT, ""%llu: API v1 registry with URL '%s'"", w->id, url); + + + char *cookie = strstr(w->response.data->buffer, NETDATA_REGISTRY_COOKIE_NAME ""=""); + if(cookie) + strncpyz(person_guid, &cookie[sizeof(NETDATA_REGISTRY_COOKIE_NAME)], 36); + + char action = '\0'; + char *machine_guid = NULL, + *machine_url = NULL, + *url_name = NULL, + *search_machine_guid = NULL, + *delete_url = NULL, + *to_person_guid = NULL; +/* + int redirects = 0; +*/ + + while(url) { + char *value = mystrsep(&url, ""?&""); + if (!value || !*value) continue; + + char *name = mystrsep(&value, ""=""); + if (!name || !*name) continue; + if (!value || !*value) continue; + + debug(D_WEB_CLIENT, ""%llu: API v1 registry query param '%s' with value '%s'"", w->id, name, value); + + uint32_t hash = simple_hash(name); + + if(hash == hash_action && !strcmp(name, ""action"")) { + uint32_t vhash = simple_hash(value); + + if(vhash == hash_access && !strcmp(value, ""access"")) action = 'A'; + else if(vhash == hash_hello && !strcmp(value, ""hello"")) action = 'H'; + else if(vhash == hash_delete && !strcmp(value, ""delete"")) action = 'D'; + else if(vhash == hash_search && !strcmp(value, ""search"")) action = 'S'; + else if(vhash == hash_switch && !strcmp(value, ""switch"")) action = 'W'; +#ifdef NETDATA_INTERNAL_CHECKS + else error(""unknown registry action '%s'"", value); +#endif /* NETDATA_INTERNAL_CHECKS */ + } +/* + else if(hash == hash_redirects && !strcmp(name, ""redirects"")) + redirects = atoi(value); +*/ + else if(hash == hash_machine && !strcmp(name, ""machine"")) + machine_guid = value; + + else if(hash == hash_url && !strcmp(name, ""url"")) + machine_url = value; + + else if(action == 'A') { + if(hash == hash_name && !strcmp(name, ""name"")) + url_name = value; + } + else if(action == 'D') { + if(hash == hash_delete_url && !strcmp(name, ""delete_url"")) + delete_url = value; + } + else if(action == 'S') { + if(hash == hash_for && !strcmp(name, ""for"")) + search_machine_guid = value; + } + else if(action == 'W') { + if(hash == hash_to && !strcmp(name, ""to"")) + to_person_guid = value; + } +#ifdef NETDATA_INTERNAL_CHECKS + else error(""unused registry URL parameter '%s' with value '%s'"", name, value); +#endif /* NETDATA_INTERNAL_CHECKS */ + } + + if(unlikely(respect_web_browser_do_not_track_policy && web_client_has_donottrack(w))) { + buffer_flush(w->response.data); + buffer_sprintf(w->response.data, ""Your web browser is sending 'DNT: 1' (Do Not Track). The registry requires persistent cookies on your browser to work.""); + return 400; + } + + if(unlikely(action == 'H')) { + if(unlikely(!web_client_can_access_dashboard(w))) + return web_client_permission_denied(w); + } + else { + if(unlikely(!web_client_can_access_registry(w))) + return web_client_permission_denied(w); + } + + switch(action) { + case 'A': + if(unlikely(!machine_guid || !machine_url || !url_name)) { + error(""Invalid registry request - access requires these parameters: machine ('%s'), url ('%s'), name ('%s')"", machine_guid ? machine_guid : ""UNSET"", machine_url ? machine_url : ""UNSET"", url_name ? url_name : ""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Access request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_access_json(host, w, person_guid, machine_guid, machine_url, url_name, now_realtime_sec()); + + case 'D': + if(unlikely(!machine_guid || !machine_url || !delete_url)) { + error(""Invalid registry request - delete requires these parameters: machine ('%s'), url ('%s'), delete_url ('%s')"", machine_guid?machine_guid:""UNSET"", machine_url?machine_url:""UNSET"", delete_url?delete_url:""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Delete request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_delete_json(host, w, person_guid, machine_guid, machine_url, delete_url, now_realtime_sec()); + + case 'S': + if(unlikely(!machine_guid || !machine_url || !search_machine_guid)) { + error(""Invalid registry request - search requires these parameters: machine ('%s'), url ('%s'), for ('%s')"", machine_guid?machine_guid:""UNSET"", machine_url?machine_url:""UNSET"", search_machine_guid?search_machine_guid:""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Search request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_search_json(host, w, person_guid, machine_guid, machine_url, search_machine_guid, now_realtime_sec()); + + case 'W': + if(unlikely(!machine_guid || !machine_url || !to_person_guid)) { + error(""Invalid registry request - switching identity requires these parameters: machine ('%s'), url ('%s'), to ('%s')"", machine_guid?machine_guid:""UNSET"", machine_url?machine_url:""UNSET"", to_person_guid?to_person_guid:""UNSET""); + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry Switch request.""); + return 400; + } + + web_client_enable_tracking_required(w); + return registry_request_switch_json(host, w, person_guid, machine_guid, machine_url, to_person_guid, now_realtime_sec()); + + case 'H': + return registry_request_hello_json(host, w); + + default: + buffer_flush(w->response.data); + buffer_strcat(w->response.data, ""Invalid registry request - you need to set an action: hello, access, delete, search""); + return 400; + } +} +","@@ -233,6 +233,15 @@ inline int web_client_api_request_v1_chart(RRDHOST *host, struct web_client *w, + return web_client_api_request_single_chart(host, w, url, rrd_stats_api_v1_chart); + } + ++void fix_google_param(char *s) { ++ if(unlikely(!s)) return; ++ ++ for( ; *s ;s++) { ++ if(!isalnum(*s) && *s != '.' && *s != '_' && *s != '-') ++ *s = '_'; ++ } ++} ++ + // returns the HTTP code + inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, char *url) { + debug(D_WEB_CLIENT, ""%llu: API v1 data with URL '%s'"", w->id, url); +@@ -332,6 +341,14 @@ inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, c + } + } + ++ // validate the google parameters given ++ fix_google_param(google_out); ++ fix_google_param(google_sig); ++ fix_google_param(google_reqId); ++ fix_google_param(google_version); ++ fix_google_param(responseHandler); ++ fix_google_param(outFileName); ++ + if(!chart || !*chart) { + buffer_sprintf(w->response.data, ""No chart id is given at the request.""); + goto cleanup;",1686,1922,2048 +8621,"void jpc_ft_fwdlift_colgrp(jpc_fix_t *a, int numrows, int stride, int parity) +{ + + jpc_fix_t *lptr; + jpc_fix_t *hptr; + register jpc_fix_t *lptr2; + register jpc_fix_t *hptr2; + register int n; + register int i; + int llen; + + llen = (numrows + 1 - parity) >> 1; + + if (numrows > 1) { + + /* Apply the first lifting step. */ + lptr = &a[0]; + hptr = &a[llen * stride]; + if (parity) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + hptr2[0] -= lptr2[0]; + ++hptr2; + ++lptr2; + } + hptr += stride; + } + n = numrows - llen - parity - (parity == (numrows & 1)); + while (n-- > 0) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + hptr2[0] -= jpc_fix_asr(lptr2[0] + lptr2[stride], 1); + ++lptr2; + ++hptr2; + } + hptr += stride; + lptr += stride; + } + if (parity == (numrows & 1)) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + hptr2[0] -= lptr2[0]; + ++lptr2; + ++hptr2; + } + } + + /* Apply the second lifting step. */ + lptr = &a[0]; + hptr = &a[llen * stride]; + if (!parity) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] += jpc_fix_asr(hptr2[0] + 1, 1); + ++lptr2; + ++hptr2; + } + lptr += stride; + } + n = llen - (!parity) - (parity != (numrows & 1)); + while (n-- > 0) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] += jpc_fix_asr(hptr2[0] + hptr2[stride] + 2, 2); + ++lptr2; + ++hptr2; + } + lptr += stride; + hptr += stride; + } + if (parity != (numrows & 1)) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] += jpc_fix_asr(hptr2[0] + 1, 1); + ++lptr2; + ++hptr2; + } + } + + } else { + + if (parity) { + lptr2 = &a[0]; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] = jpc_fix_asl(lptr2[0], 1); + ++lptr2; + } + } + + } + +} +",0,"void jpc_ft_fwdlift_colgrp(jpc_fix_t *a, int numrows, int stride, int parity) +{ + + jpc_fix_t *lptr; + jpc_fix_t *hptr; + register jpc_fix_t *lptr2; + register jpc_fix_t *hptr2; + register int n; + register int i; + int llen; + + llen = (numrows + 1 - parity) >> 1; + + if (numrows > 1) { + + /* Apply the first lifting step. */ + lptr = &a[0]; + hptr = &a[llen * stride]; + if (parity) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + hptr2[0] -= lptr2[0]; + ++hptr2; + ++lptr2; + } + hptr += stride; + } + n = numrows - llen - parity - (parity == (numrows & 1)); + while (n-- > 0) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + hptr2[0] -= jpc_fix_asr(lptr2[0] + lptr2[stride], 1); + ++lptr2; + ++hptr2; + } + hptr += stride; + lptr += stride; + } + if (parity == (numrows & 1)) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + hptr2[0] -= lptr2[0]; + ++lptr2; + ++hptr2; + } + } + + /* Apply the second lifting step. */ + lptr = &a[0]; + hptr = &a[llen * stride]; + if (!parity) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] += jpc_fix_asr(hptr2[0] + 1, 1); + ++lptr2; + ++hptr2; + } + lptr += stride; + } + n = llen - (!parity) - (parity != (numrows & 1)); + while (n-- > 0) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] += jpc_fix_asr(hptr2[0] + hptr2[stride] + 2, 2); + ++lptr2; + ++hptr2; + } + lptr += stride; + hptr += stride; + } + if (parity != (numrows & 1)) { + lptr2 = lptr; + hptr2 = hptr; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] += jpc_fix_asr(hptr2[0] + 1, 1); + ++lptr2; + ++hptr2; + } + } + + } else { + + if (parity) { + lptr2 = &a[0]; + for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) { + lptr2[0] = jpc_fix_asl(lptr2[0], 1); + ++lptr2; + } + } + + } + +} +","@@ -374,7 +374,7 @@ void jpc_qmfb_split_col(jpc_fix_t *a, int numrows, int stride, + register jpc_fix_t *dstptr; + register int n; + register int m; +- int hstartcol; ++ int hstartrow; + + /* Get a buffer. */ + if (bufsize > QMFB_SPLITBUFSIZE) { +@@ -385,9 +385,9 @@ void jpc_qmfb_split_col(jpc_fix_t *a, int numrows, int stride, + } + + if (numrows >= 2) { +- hstartcol = (numrows + 1 - parity) >> 1; +- // ORIGINAL (WRONG): m = (parity) ? hstartcol : (numrows - hstartcol); +- m = numrows - hstartcol; ++ hstartrow = (numrows + 1 - parity) >> 1; ++ // ORIGINAL (WRONG): m = (parity) ? hstartrow : (numrows - hstartrow); ++ m = numrows - hstartrow; + + /* Save the samples destined for the highpass channel. */ + n = m; +@@ -408,7 +408,7 @@ void jpc_qmfb_split_col(jpc_fix_t *a, int numrows, int stride, + srcptr += stride << 1; + } + /* Copy the saved samples into the highpass channel. */ +- dstptr = &a[hstartcol * stride]; ++ dstptr = &a[hstartrow * stride]; + srcptr = buf; + n = m; + while (n-- > 0) { +@@ -439,20 +439,21 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a, int numrows, int stride, + register int n; + register int i; + int m; +- int hstartcol; ++ int hstartrow; + + /* Get a buffer. */ + if (bufsize > QMFB_SPLITBUFSIZE) { +- if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) { ++ if (!(buf = jas_alloc3(bufsize, JPC_QMFB_COLGRPSIZE, ++ sizeof(jpc_fix_t)))) { + /* We have no choice but to commit suicide in this case. */ + abort(); + } + } + + if (numrows >= 2) { +- hstartcol = (numrows + 1 - parity) >> 1; +- // ORIGINAL (WRONG): m = (parity) ? hstartcol : (numrows - hstartcol); +- m = numrows - hstartcol; ++ hstartrow = (numrows + 1 - parity) >> 1; ++ // ORIGINAL (WRONG): m = (parity) ? hstartrow : (numrows - hstartrow); ++ m = numrows - hstartrow; + + /* Save the samples destined for the highpass channel. */ + n = m; +@@ -485,7 +486,7 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a, int numrows, int stride, + srcptr += stride << 1; + } + /* Copy the saved samples into the highpass channel. */ +- dstptr = &a[hstartcol * stride]; ++ dstptr = &a[hstartrow * stride]; + srcptr = buf; + n = m; + while (n-- > 0) { +@@ -526,7 +527,7 @@ void jpc_qmfb_split_colres(jpc_fix_t *a, int numrows, int numcols, + + /* Get a buffer. */ + if (bufsize > QMFB_SPLITBUFSIZE) { +- if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) { ++ if (!(buf = jas_alloc3(bufsize, numcols, sizeof(jpc_fix_t)))) { + /* We have no choice but to commit suicide in this case. */ + abort(); + } +@@ -721,7 +722,8 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a, int numrows, int stride, + + /* Allocate memory for the join buffer from the heap. */ + if (bufsize > QMFB_JOINBUFSIZE) { +- if (!(buf = jas_alloc3(bufsize, JPC_QMFB_COLGRPSIZE, sizeof(jpc_fix_t)))) { ++ if (!(buf = jas_alloc3(bufsize, JPC_QMFB_COLGRPSIZE, ++ sizeof(jpc_fix_t)))) { + /* We have no choice but to commit suicide. */ + abort(); + }",875,1111,2048 +8873,"MagickExport MagickBooleanType EvaluateImageChannel(Image *image, + const ChannelType channel,const MagickEvaluateOperator op,const double value, + ExceptionInfo *exception) +{ + CacheView + *image_view; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + RandomInfo + **magick_restrict random_info; + + ssize_t + y; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + unsigned long + key; +#endif + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + if (SetImageStorageClass(image,DirectClass) == MagickFalse) + { + InheritException(exception,&image->exception); + return(MagickFalse); + } + status=MagickTrue; + progress=0; + random_info=AcquireRandomInfoThreadSet(); + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + key=GetRandomSecretKey(random_info[0]); + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,key == ~0UL) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + const int + id = GetOpenMPThreadId(); + + register IndexPacket + *magick_restrict indexes; + + register PixelPacket + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + { + status=MagickFalse; + continue; + } + indexes=GetCacheViewAuthenticIndexQueue(image_view); + for (x=0; x < (ssize_t) image->columns; x++) + { + MagickRealType + result; + + if ((channel & RedChannel) != 0) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelRed(q),op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelRed(q,ClampToQuantum(result)); + } + if ((channel & GreenChannel) != 0) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelGreen(q),op, + value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelGreen(q,ClampToQuantum(result)); + } + if ((channel & BlueChannel) != 0) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelBlue(q),op, + value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelBlue(q,ClampToQuantum(result)); + } + if ((channel & OpacityChannel) != 0) + { + if (image->matte == MagickFalse) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelOpacity(q), + op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelOpacity(q,ClampToQuantum(result)); + } + else + { + result=ApplyEvaluateOperator(random_info[id],GetPixelAlpha(q), + op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelAlpha(q,ClampToQuantum(result)); + } + } + if (((channel & IndexChannel) != 0) && (indexes != (IndexPacket *) NULL)) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelIndex(indexes+x), + op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelIndex(indexes+x,ClampToQuantum(result)); + } + q++; + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + + proceed=SetImageProgress(image,EvaluateImageTag,progress++,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + random_info=DestroyRandomInfoThreadSet(random_info); + return(status); +} +",0,"MagickExport MagickBooleanType EvaluateImageChannel(Image *image, + const ChannelType channel,const MagickEvaluateOperator op,const double value, + ExceptionInfo *exception) +{ + CacheView + *image_view; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + RandomInfo + **magick_restrict random_info; + + ssize_t + y; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + unsigned long + key; +#endif + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + if (SetImageStorageClass(image,DirectClass) == MagickFalse) + { + InheritException(exception,&image->exception); + return(MagickFalse); + } + status=MagickTrue; + progress=0; + random_info=AcquireRandomInfoThreadSet(); + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + key=GetRandomSecretKey(random_info[0]); + #pragma omp parallel for schedule(static) shared(progress,status) \ + magick_number_threads(image,image,image->rows,key == ~0UL) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + const int + id = GetOpenMPThreadId(); + + register IndexPacket + *magick_restrict indexes; + + register PixelPacket + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + { + status=MagickFalse; + continue; + } + indexes=GetCacheViewAuthenticIndexQueue(image_view); + for (x=0; x < (ssize_t) image->columns; x++) + { + MagickRealType + result; + + if ((channel & RedChannel) != 0) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelRed(q),op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelRed(q,ClampToQuantum(result)); + } + if ((channel & GreenChannel) != 0) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelGreen(q),op, + value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelGreen(q,ClampToQuantum(result)); + } + if ((channel & BlueChannel) != 0) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelBlue(q),op, + value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelBlue(q,ClampToQuantum(result)); + } + if ((channel & OpacityChannel) != 0) + { + if (image->matte == MagickFalse) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelOpacity(q), + op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelOpacity(q,ClampToQuantum(result)); + } + else + { + result=ApplyEvaluateOperator(random_info[id],GetPixelAlpha(q), + op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelAlpha(q,ClampToQuantum(result)); + } + } + if (((channel & IndexChannel) != 0) && (indexes != (IndexPacket *) NULL)) + { + result=ApplyEvaluateOperator(random_info[id],GetPixelIndex(indexes+x), + op,value); + if (op == MeanEvaluateOperator) + result/=2.0; + SetPixelIndex(indexes+x,ClampToQuantum(result)); + } + q++; + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + + proceed=SetImageProgress(image,EvaluateImageTag,progress++,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + random_info=DestroyRandomInfoThreadSet(random_info); + return(status); +} +","@@ -163,18 +163,17 @@ static MagickPixelPacket **AcquirePixelThreadSet(const Image *images) + + size_t + columns, +- number_threads; ++ rows; + +- number_threads=(size_t) GetMagickResourceLimit(ThreadResource); +- pixels=(MagickPixelPacket **) AcquireQuantumMemory(number_threads, +- sizeof(*pixels)); ++ rows=MagickMax(GetImageListLength(images), ++ (size_t) GetMagickResourceLimit(ThreadResource)); ++ pixels=(MagickPixelPacket **) AcquireQuantumMemory(rows,sizeof(*pixels)); + if (pixels == (MagickPixelPacket **) NULL) + return((MagickPixelPacket **) NULL); +- (void) memset(pixels,0,number_threads*sizeof(*pixels)); + columns=images->columns; + for (next=images; next != (Image *) NULL; next=next->next) + columns=MagickMax(next->columns,columns); +- for (i=0; i < (ssize_t) number_threads; i++) ++ for (i=0; i < (ssize_t) rows; i++) + { + pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(columns, + sizeof(**pixels));",990,1226,2048 +18008,"int read_image_tga( gdIOCtx *ctx, oTga *tga ) +{ + int pixel_block_size = (tga->bits / 8); + int image_block_size = (tga->width * tga->height) * pixel_block_size; + uint8_t* decompression_buffer = NULL; + unsigned char* conversion_buffer = NULL; + int buffer_caret = 0; + int bitmap_caret = 0; + int i = 0; + int j = 0; + uint8_t encoded_pixels; + + if(overflow2(tga->width, tga->height)) { + return -1; + } + + if(overflow2(tga->width * tga->height, pixel_block_size)) { + return -1; + } + + if(overflow2(image_block_size, sizeof(int))) { + return -1; + } + + /*! \todo Add more image type support. + */ + if (tga->imagetype != TGA_TYPE_RGB && tga->imagetype != TGA_TYPE_RGB_RLE) + return -1; + + /*! \brief Allocate memmory for image block + * Allocate a chunk of memory for the image block to be passed into. + */ + tga->bitmap = (int *) gdMalloc(image_block_size * sizeof(int)); + if (tga->bitmap == NULL) + return -1; + + switch (tga->imagetype) { + case TGA_TYPE_RGB: + /*! \brief Read in uncompressed RGB TGA + * Chunk load the pixel data from an uncompressed RGB type TGA. + */ + conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); + if (conversion_buffer == NULL) { + return -1; + } + + if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + gd_error(""gd-tga: premature end of image data\n""); + gdFree(conversion_buffer); + return -1; + } + + while (buffer_caret < image_block_size) { + tga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret]; + buffer_caret++; + } + + gdFree(conversion_buffer); + break; + + case TGA_TYPE_RGB_RLE: + /*! \brief Read in RLE compressed RGB TGA + * Chunk load the pixel data from an RLE compressed RGB type TGA. + */ + decompression_buffer = (uint8_t*) gdMalloc(image_block_size * sizeof(uint8_t)); + if (decompression_buffer == NULL) { + return -1; + } + conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); + if (conversion_buffer == NULL) { + gd_error(""gd-tga: premature end of image data\n""); + gdFree( decompression_buffer ); + return -1; + } + + if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + gdFree(conversion_buffer); + gdFree(decompression_buffer); + return -1; + } + + buffer_caret = 0; + + while( buffer_caret < image_block_size) { + decompression_buffer[buffer_caret] = (int)conversion_buffer[buffer_caret]; + buffer_caret++; + } + + buffer_caret = 0; + + while( bitmap_caret < image_block_size ) { + + if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { + encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & 127 ) + 1 ); + buffer_caret++; + + if (encoded_pixels != 0) { + if (!((buffer_caret + (encoded_pixels * pixel_block_size)) < image_block_size)) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; + } + for (i = 0; i < encoded_pixels; i++) { + for (j = 0; j < pixel_block_size; j++, bitmap_caret++) { + tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ]; + } + } + } + buffer_caret += pixel_block_size; + } else { + encoded_pixels = decompression_buffer[ buffer_caret ] + 1; + buffer_caret++; + + if (encoded_pixels != 0) { + if (!((buffer_caret + (encoded_pixels * pixel_block_size)) < image_block_size)) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; + } + for (i = 0; i < encoded_pixels; i++) { + for( j = 0; j < pixel_block_size; j++, bitmap_caret++ ) { + tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ]; + } + buffer_caret += pixel_block_size; + } + } + } + } + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + break; + } + + return 1; +} +",1,"int read_image_tga( gdIOCtx *ctx, oTga *tga ) +{ + int pixel_block_size = (tga->bits / 8); + int image_block_size = (tga->width * tga->height) * pixel_block_size; + uint8_t* decompression_buffer = NULL; + unsigned char* conversion_buffer = NULL; + int buffer_caret = 0; + int bitmap_caret = 0; + int i = 0; + uint8_t encoded_pixels; + + if(overflow2(tga->width, tga->height)) { + return -1; + } + + if(overflow2(tga->width * tga->height, pixel_block_size)) { + return -1; + } + + if(overflow2(image_block_size, sizeof(int))) { + return -1; + } + + /*! \todo Add more image type support. + */ + if (tga->imagetype != TGA_TYPE_RGB && tga->imagetype != TGA_TYPE_RGB_RLE) + return -1; + + /*! \brief Allocate memmory for image block + * Allocate a chunk of memory for the image block to be passed into. + */ + tga->bitmap = (int *) gdMalloc(image_block_size * sizeof(int)); + if (tga->bitmap == NULL) + return -1; + + switch (tga->imagetype) { + case TGA_TYPE_RGB: + /*! \brief Read in uncompressed RGB TGA + * Chunk load the pixel data from an uncompressed RGB type TGA. + */ + conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); + if (conversion_buffer == NULL) { + return -1; + } + + if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + gd_error(""gd-tga: premature end of image data\n""); + gdFree(conversion_buffer); + return -1; + } + + while (buffer_caret < image_block_size) { + tga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret]; + buffer_caret++; + } + + gdFree(conversion_buffer); + break; + + case TGA_TYPE_RGB_RLE: + /*! \brief Read in RLE compressed RGB TGA + * Chunk load the pixel data from an RLE compressed RGB type TGA. + */ + decompression_buffer = (uint8_t*) gdMalloc(image_block_size * sizeof(uint8_t)); + if (decompression_buffer == NULL) { + return -1; + } + conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); + if (conversion_buffer == NULL) { + gd_error(""gd-tga: premature end of image data\n""); + gdFree( decompression_buffer ); + return -1; + } + + if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + gdFree(conversion_buffer); + gdFree(decompression_buffer); + return -1; + } + + buffer_caret = 0; + + while( buffer_caret < image_block_size) { + decompression_buffer[buffer_caret] = (int)conversion_buffer[buffer_caret]; + buffer_caret++; + } + + buffer_caret = 0; + + while( bitmap_caret < image_block_size ) { + + if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { + encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & !TGA_RLE_FLAG ) + 1 ); + buffer_caret++; + + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; + } + + for (i = 0; i < encoded_pixels; i++) { + memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size); + bitmap_caret += pixel_block_size; + } + buffer_caret += pixel_block_size; + + } else { + encoded_pixels = decompression_buffer[ buffer_caret ] + 1; + buffer_caret++; + + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; + } + + memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size); + bitmap_caret += (encoded_pixels * pixel_block_size); + buffer_caret += (encoded_pixels * pixel_block_size); + } + } + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + break; + } + + return 1; +} +","@@ -196,7 +196,6 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga ) + int buffer_caret = 0; + int bitmap_caret = 0; + int i = 0; +- int j = 0; + uint8_t encoded_pixels; + + if(overflow2(tga->width, tga->height)) { +@@ -280,43 +279,34 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga ) + while( bitmap_caret < image_block_size ) { + + if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { +- encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & 127 ) + 1 ); ++ encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & !TGA_RLE_FLAG ) + 1 ); + buffer_caret++; + +- if (encoded_pixels != 0) { +- +- if (!((buffer_caret + (encoded_pixels * pixel_block_size)) < image_block_size)) { +- gdFree( decompression_buffer ); +- gdFree( conversion_buffer ); +- return -1; +- } +- +- for (i = 0; i < encoded_pixels; i++) { +- for (j = 0; j < pixel_block_size; j++, bitmap_caret++) { +- tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ]; +- } +- } ++ if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { ++ gdFree( decompression_buffer ); ++ gdFree( conversion_buffer ); ++ return -1; ++ } ++ ++ for (i = 0; i < encoded_pixels; i++) { ++ memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size); ++ bitmap_caret += pixel_block_size; + } + buffer_caret += pixel_block_size; ++ + } else { + encoded_pixels = decompression_buffer[ buffer_caret ] + 1; + buffer_caret++; + +- if (encoded_pixels != 0) { +- +- if (!((buffer_caret + (encoded_pixels * pixel_block_size)) < image_block_size)) { +- gdFree( decompression_buffer ); +- gdFree( conversion_buffer ); +- return -1; +- } +- +- for (i = 0; i < encoded_pixels; i++) { +- for( j = 0; j < pixel_block_size; j++, bitmap_caret++ ) { +- tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ]; +- } +- buffer_caret += pixel_block_size; +- } ++ if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { ++ gdFree( decompression_buffer ); ++ gdFree( conversion_buffer ); ++ return -1; + } ++ ++ memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size); ++ bitmap_caret += (encoded_pixels * pixel_block_size); ++ buffer_caret += (encoded_pixels * pixel_block_size); + } + } + gdFree( decompression_buffer );",1113,1349,2048 +4483,"static int cg_getattr(const char *path, struct stat *sb) +{ + struct timespec now; + struct fuse_context *fc = fuse_get_context(); + char * cgdir = NULL; + char *fpath = NULL, *path1, *path2; + struct cgfs_files *k = NULL; + const char *cgroup; + const char *controller = NULL; + int ret = -ENOENT; + + + if (!fc) + return -EIO; + + memset(sb, 0, sizeof(struct stat)); + + if (clock_gettime(CLOCK_REALTIME, &now) < 0) + return -EINVAL; + + sb->st_uid = sb->st_gid = 0; + sb->st_atim = sb->st_mtim = sb->st_ctim = now; + sb->st_size = 0; + + if (strcmp(path, ""/cgroup"") == 0) { + sb->st_mode = S_IFDIR | 00755; + sb->st_nlink = 2; + return 0; + } + + controller = pick_controller_from_path(fc, path); + if (!controller) + return -EIO; + cgroup = find_cgroup_in_path(path); + if (!cgroup) { + /* this is just /cgroup/controller, return it as a dir */ + sb->st_mode = S_IFDIR | 00755; + sb->st_nlink = 2; + return 0; + } + + get_cgdir_and_path(cgroup, &cgdir, &fpath); + + if (!fpath) { + path1 = ""/""; + path2 = cgdir; + } else { + path1 = cgdir; + path2 = fpath; + } + + /* check that cgcopy is either a child cgroup of cgdir, or listed in its keys. + * Then check that caller's cgroup is under path if fpath is a child + * cgroup, or cgdir if fpath is a file */ + + if (is_child_cgroup(controller, path1, path2)) { + if (!caller_may_see_dir(fc->pid, controller, cgroup)) { + ret = -ENOENT; + goto out; + } + if (!caller_is_in_ancestor(fc->pid, controller, cgroup, NULL)) { + /* this is just /cgroup/controller, return it as a dir */ + sb->st_mode = S_IFDIR | 00555; + sb->st_nlink = 2; + ret = 0; + goto out; + } + if (!fc_may_access(fc, controller, cgroup, NULL, O_RDONLY)) { + ret = -EACCES; + goto out; + } + + sb->st_mode = S_IFDIR | 00755; + k = cgfs_get_key(controller, cgroup, ""tasks""); + if (!k) { + sb->st_uid = sb->st_gid = 0; + } else { + sb->st_uid = k->uid; + sb->st_gid = k->gid; + } + free_key(k); + sb->st_nlink = 2; + ret = 0; + goto out; + } + + if ((k = cgfs_get_key(controller, path1, path2)) != NULL) { + sb->st_mode = S_IFREG | k->mode; + sb->st_nlink = 1; + sb->st_uid = k->uid; + sb->st_gid = k->gid; + sb->st_size = 0; + free_key(k); + if (!caller_is_in_ancestor(fc->pid, controller, path1, NULL)) { + ret = -ENOENT; + goto out; + } + if (!fc_may_access(fc, controller, path1, path2, O_RDONLY)) { + ret = -EACCES; + goto out; + } + + ret = 0; + } + +out: + free(cgdir); + return ret; +} +",0,"static int cg_getattr(const char *path, struct stat *sb) +{ + struct timespec now; + struct fuse_context *fc = fuse_get_context(); + char * cgdir = NULL; + char *fpath = NULL, *path1, *path2; + struct cgfs_files *k = NULL; + const char *cgroup; + const char *controller = NULL; + int ret = -ENOENT; + + + if (!fc) + return -EIO; + + memset(sb, 0, sizeof(struct stat)); + + if (clock_gettime(CLOCK_REALTIME, &now) < 0) + return -EINVAL; + + sb->st_uid = sb->st_gid = 0; + sb->st_atim = sb->st_mtim = sb->st_ctim = now; + sb->st_size = 0; + + if (strcmp(path, ""/cgroup"") == 0) { + sb->st_mode = S_IFDIR | 00755; + sb->st_nlink = 2; + return 0; + } + + controller = pick_controller_from_path(fc, path); + if (!controller) + return -EIO; + cgroup = find_cgroup_in_path(path); + if (!cgroup) { + /* this is just /cgroup/controller, return it as a dir */ + sb->st_mode = S_IFDIR | 00755; + sb->st_nlink = 2; + return 0; + } + + get_cgdir_and_path(cgroup, &cgdir, &fpath); + + if (!fpath) { + path1 = ""/""; + path2 = cgdir; + } else { + path1 = cgdir; + path2 = fpath; + } + + /* check that cgcopy is either a child cgroup of cgdir, or listed in its keys. + * Then check that caller's cgroup is under path if fpath is a child + * cgroup, or cgdir if fpath is a file */ + + if (is_child_cgroup(controller, path1, path2)) { + if (!caller_may_see_dir(fc->pid, controller, cgroup)) { + ret = -ENOENT; + goto out; + } + if (!caller_is_in_ancestor(fc->pid, controller, cgroup, NULL)) { + /* this is just /cgroup/controller, return it as a dir */ + sb->st_mode = S_IFDIR | 00555; + sb->st_nlink = 2; + ret = 0; + goto out; + } + if (!fc_may_access(fc, controller, cgroup, NULL, O_RDONLY)) { + ret = -EACCES; + goto out; + } + + sb->st_mode = S_IFDIR | 00755; + k = cgfs_get_key(controller, cgroup, ""tasks""); + if (!k) { + sb->st_uid = sb->st_gid = 0; + } else { + sb->st_uid = k->uid; + sb->st_gid = k->gid; + } + free_key(k); + sb->st_nlink = 2; + ret = 0; + goto out; + } + + if ((k = cgfs_get_key(controller, path1, path2)) != NULL) { + sb->st_mode = S_IFREG | k->mode; + sb->st_nlink = 1; + sb->st_uid = k->uid; + sb->st_gid = k->gid; + sb->st_size = 0; + free_key(k); + if (!caller_is_in_ancestor(fc->pid, controller, path1, NULL)) { + ret = -ENOENT; + goto out; + } + if (!fc_may_access(fc, controller, path1, path2, O_RDONLY)) { + ret = -EACCES; + goto out; + } + + ret = 0; + } + +out: + free(cgdir); + return ret; +} +","@@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid) + goto loop; + } + +-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf) ++/* ++ * Given host @uid, return the uid to which it maps in ++ * @pid's user namespace, or -1 if none. ++ */ ++bool hostuid_to_ns(uid_t uid, pid_t pid, uid_t *answer) ++{ ++ FILE *f; ++ char line[400]; ++ ++ sprintf(line, ""/proc/%d/uid_map"", pid); ++ if ((f = fopen(line, ""r"")) == NULL) { ++ return false; ++ } ++ ++ *answer = convert_id_to_ns(f, uid); ++ fclose(f); ++ ++ if (*answer == -1) ++ return false; ++ return true; ++} ++ ++/* ++ * get_pid_creds: get the real uid and gid of @pid from ++ * /proc/$$/status ++ * (XXX should we use euid here?) ++ */ ++void get_pid_creds(pid_t pid, uid_t *uid, gid_t *gid) ++{ ++ char line[400]; ++ uid_t u; ++ gid_t g; ++ FILE *f; ++ ++ *uid = -1; ++ *gid = -1; ++ sprintf(line, ""/proc/%d/status"", pid); ++ if ((f = fopen(line, ""r"")) == NULL) { ++ fprintf(stderr, ""Error opening %s: %s\n"", line, strerror(errno)); ++ return; ++ } ++ while (fgets(line, 400, f)) { ++ if (strncmp(line, ""Uid:"", 4) == 0) { ++ if (sscanf(line+4, ""%u"", &u) != 1) { ++ fprintf(stderr, ""bad uid line for pid %u\n"", pid); ++ fclose(f); ++ return; ++ } ++ *uid = u; ++ } else if (strncmp(line, ""Gid:"", 4) == 0) { ++ if (sscanf(line+4, ""%u"", &g) != 1) { ++ fprintf(stderr, ""bad gid line for pid %u\n"", pid); ++ fclose(f); ++ return; ++ } ++ *gid = g; ++ } ++ } ++ fclose(f); ++} ++ ++/* ++ * May the requestor @r move victim @v to a new cgroup? ++ * This is allowed if ++ * . they are the same task ++ * . they are ownedy by the same uid ++ * . @r is root on the host, or ++ * . @v's uid is mapped into @r's where @r is root. ++ */ ++bool may_move_pid(pid_t r, uid_t r_uid, pid_t v) ++{ ++ uid_t v_uid, tmpuid; ++ gid_t v_gid; ++ ++ if (r == v) ++ return true; ++ if (r_uid == 0) ++ return true; ++ get_pid_creds(v, &v_uid, &v_gid); ++ if (r_uid == v_uid) ++ return true; ++ if (hostuid_to_ns(r_uid, r, &tmpuid) && tmpuid == 0 ++ && hostuid_to_ns(v_uid, r, &tmpuid)) ++ return true; ++ return false; ++} ++ ++static bool do_write_pids(pid_t tpid, uid_t tuid, const char *contrl, const char *cg, ++ const char *file, const char *buf) + { + int sock[2] = {-1, -1}; + pid_t qpid, cpid = -1; +@@ -1378,6 +1466,10 @@ static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const + + if (recv_creds(sock[0], &cred, &v)) { + if (v == '0') { ++ if (!may_move_pid(tpid, tuid, cred.pid)) { ++ fail = true; ++ break; ++ } + if (fprintf(pids_file, ""%d"", (int) cred.pid) < 0) + fail = true; + } +@@ -1450,7 +1542,7 @@ int cg_write(const char *path, const char *buf, size_t size, off_t offset, + strcmp(f->file, ""/cgroup.procs"") == 0 || + strcmp(f->file, ""cgroup.procs"") == 0) + // special case - we have to translate the pids +- r = do_write_pids(fc->pid, f->controller, f->cgroup, f->file, localbuf); ++ r = do_write_pids(fc->pid, fc->uid, f->controller, f->cgroup, f->file, localbuf); + else + r = cgfs_set_value(f->controller, f->cgroup, f->file, localbuf); + ",842,1078,2048 +2922,"void ping_err(struct sk_buff *skb, int offset, u32 info) +{ + int family; + struct icmphdr *icmph; + struct inet_sock *inet_sock; + int type; + int code; + struct net *net = dev_net(skb->dev); + struct sock *sk; + int harderr; + int err; + + if (skb->protocol == htons(ETH_P_IP)) { + family = AF_INET; + type = icmp_hdr(skb)->type; + code = icmp_hdr(skb)->code; + icmph = (struct icmphdr *)(skb->data + offset); + } else if (skb->protocol == htons(ETH_P_IPV6)) { + family = AF_INET6; + type = icmp6_hdr(skb)->icmp6_type; + code = icmp6_hdr(skb)->icmp6_code; + icmph = (struct icmphdr *) (skb->data + offset); + } else { + BUG(); + } + + /* We assume the packet has already been checked by icmp_unreach */ + + if (!ping_supported(family, icmph->type, icmph->code)) + return; + + pr_debug(""ping_err(proto=0x%x,type=%d,code=%d,id=%04x,seq=%04x)\n"", + skb->protocol, type, code, ntohs(icmph->un.echo.id), + ntohs(icmph->un.echo.sequence)); + + sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); + if (sk == NULL) { + pr_debug(""no socket, dropping\n""); + return; /* No socket for error */ + } + pr_debug(""err on socket %p\n"", sk); + + err = 0; + harderr = 0; + inet_sock = inet_sk(sk); + + if (skb->protocol == htons(ETH_P_IP)) { + switch (type) { + default: + case ICMP_TIME_EXCEEDED: + err = EHOSTUNREACH; + break; + case ICMP_SOURCE_QUENCH: + /* This is not a real error but ping wants to see it. + * Report it with some fake errno. + */ + err = EREMOTEIO; + break; + case ICMP_PARAMETERPROB: + err = EPROTO; + harderr = 1; + break; + case ICMP_DEST_UNREACH: + if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */ + ipv4_sk_update_pmtu(skb, sk, info); + if (inet_sock->pmtudisc != IP_PMTUDISC_DONT) { + err = EMSGSIZE; + harderr = 1; + break; + } + goto out; + } + err = EHOSTUNREACH; + if (code <= NR_ICMP_UNREACH) { + harderr = icmp_err_convert[code].fatal; + err = icmp_err_convert[code].errno; + } + break; + case ICMP_REDIRECT: + /* See ICMP_SOURCE_QUENCH */ + ipv4_sk_redirect(skb, sk); + err = EREMOTEIO; + break; + } +#if IS_ENABLED(CONFIG_IPV6) + } else if (skb->protocol == htons(ETH_P_IPV6)) { + harderr = pingv6_ops.icmpv6_err_convert(type, code, &err); +#endif + } + + /* + * RFC1122: OK. Passes ICMP errors back to application, as per + * 4.1.3.3. + */ + if ((family == AF_INET && !inet_sock->recverr) || + (family == AF_INET6 && !inet6_sk(sk)->recverr)) { + if (!harderr || sk->sk_state != TCP_ESTABLISHED) + goto out; + } else { + if (family == AF_INET) { + ip_icmp_error(sk, skb, err, 0 /* no remote port */, + info, (u8 *)icmph); +#if IS_ENABLED(CONFIG_IPV6) + } else if (family == AF_INET6) { + pingv6_ops.ipv6_icmp_error(sk, skb, err, 0, + info, (u8 *)icmph); +#endif + } + } + sk->sk_err = err; + sk->sk_error_report(sk); +out: + sock_put(sk); +} +",0,"void ping_err(struct sk_buff *skb, int offset, u32 info) +{ + int family; + struct icmphdr *icmph; + struct inet_sock *inet_sock; + int type; + int code; + struct net *net = dev_net(skb->dev); + struct sock *sk; + int harderr; + int err; + + if (skb->protocol == htons(ETH_P_IP)) { + family = AF_INET; + type = icmp_hdr(skb)->type; + code = icmp_hdr(skb)->code; + icmph = (struct icmphdr *)(skb->data + offset); + } else if (skb->protocol == htons(ETH_P_IPV6)) { + family = AF_INET6; + type = icmp6_hdr(skb)->icmp6_type; + code = icmp6_hdr(skb)->icmp6_code; + icmph = (struct icmphdr *) (skb->data + offset); + } else { + BUG(); + } + + /* We assume the packet has already been checked by icmp_unreach */ + + if (!ping_supported(family, icmph->type, icmph->code)) + return; + + pr_debug(""ping_err(proto=0x%x,type=%d,code=%d,id=%04x,seq=%04x)\n"", + skb->protocol, type, code, ntohs(icmph->un.echo.id), + ntohs(icmph->un.echo.sequence)); + + sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); + if (sk == NULL) { + pr_debug(""no socket, dropping\n""); + return; /* No socket for error */ + } + pr_debug(""err on socket %p\n"", sk); + + err = 0; + harderr = 0; + inet_sock = inet_sk(sk); + + if (skb->protocol == htons(ETH_P_IP)) { + switch (type) { + default: + case ICMP_TIME_EXCEEDED: + err = EHOSTUNREACH; + break; + case ICMP_SOURCE_QUENCH: + /* This is not a real error but ping wants to see it. + * Report it with some fake errno. + */ + err = EREMOTEIO; + break; + case ICMP_PARAMETERPROB: + err = EPROTO; + harderr = 1; + break; + case ICMP_DEST_UNREACH: + if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */ + ipv4_sk_update_pmtu(skb, sk, info); + if (inet_sock->pmtudisc != IP_PMTUDISC_DONT) { + err = EMSGSIZE; + harderr = 1; + break; + } + goto out; + } + err = EHOSTUNREACH; + if (code <= NR_ICMP_UNREACH) { + harderr = icmp_err_convert[code].fatal; + err = icmp_err_convert[code].errno; + } + break; + case ICMP_REDIRECT: + /* See ICMP_SOURCE_QUENCH */ + ipv4_sk_redirect(skb, sk); + err = EREMOTEIO; + break; + } +#if IS_ENABLED(CONFIG_IPV6) + } else if (skb->protocol == htons(ETH_P_IPV6)) { + harderr = pingv6_ops.icmpv6_err_convert(type, code, &err); +#endif + } + + /* + * RFC1122: OK. Passes ICMP errors back to application, as per + * 4.1.3.3. + */ + if ((family == AF_INET && !inet_sock->recverr) || + (family == AF_INET6 && !inet6_sk(sk)->recverr)) { + if (!harderr || sk->sk_state != TCP_ESTABLISHED) + goto out; + } else { + if (family == AF_INET) { + ip_icmp_error(sk, skb, err, 0 /* no remote port */, + info, (u8 *)icmph); +#if IS_ENABLED(CONFIG_IPV6) + } else if (family == AF_INET6) { + pingv6_ops.ipv6_icmp_error(sk, skb, err, 0, + info, (u8 *)icmph); +#endif + } + } + sk->sk_err = err; + sk->sk_error_report(sk); +out: + sock_put(sk); +} +","@@ -870,11 +870,13 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, + if (family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; + +- sin->sin_family = AF_INET; +- sin->sin_port = 0 /* skb->h.uh->source */; +- sin->sin_addr.s_addr = ip_hdr(skb)->saddr; +- memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); +- *addr_len = sizeof(*sin); ++ if (sin) { ++ sin->sin_family = AF_INET; ++ sin->sin_port = 0 /* skb->h.uh->source */; ++ sin->sin_addr.s_addr = ip_hdr(skb)->saddr; ++ memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); ++ *addr_len = sizeof(*sin); ++ } + + if (isk->cmsg_flags) + ip_cmsg_recv(msg, skb); +@@ -886,16 +888,18 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, + struct sockaddr_in6 *sin6 = + (struct sockaddr_in6 *)msg->msg_name; + +- sin6->sin6_family = AF_INET6; +- sin6->sin6_port = 0; +- sin6->sin6_addr = ip6->saddr; +- sin6->sin6_flowinfo = 0; +- if (np->sndflow) +- sin6->sin6_flowinfo = ip6_flowinfo(ip6); +- +- sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, +- IP6CB(skb)->iif); +- *addr_len = sizeof(*sin6); ++ if (sin6) { ++ sin6->sin6_family = AF_INET6; ++ sin6->sin6_port = 0; ++ sin6->sin6_addr = ip6->saddr; ++ sin6->sin6_flowinfo = 0; ++ if (np->sndflow) ++ sin6->sin6_flowinfo = ip6_flowinfo(ip6); ++ sin6->sin6_scope_id = ++ ipv6_iface_scope_id(&sin6->sin6_addr, ++ IP6CB(skb)->iif); ++ *addr_len = sizeof(*sin6); ++ } + + if (inet6_sk(sk)->rxopt.all) + pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);",916,1152,2048 +3118,"static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, + struct msghdr *msg, size_t len) +{ + struct sock *sk = sock->sk; + struct rose_sock *rose = rose_sk(sk); + struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name; + int err; + struct full_sockaddr_rose srose; + struct sk_buff *skb; + unsigned char *asmptr; + int n, size, qbit = 0; + + if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_CMSG_COMPAT)) + return -EINVAL; + + if (sock_flag(sk, SOCK_ZAPPED)) + return -EADDRNOTAVAIL; + + if (sk->sk_shutdown & SEND_SHUTDOWN) { + send_sig(SIGPIPE, current, 0); + return -EPIPE; + } + + if (rose->neighbour == NULL || rose->device == NULL) + return -ENETUNREACH; + + if (usrose != NULL) { + if (msg->msg_namelen != sizeof(struct sockaddr_rose) && msg->msg_namelen != sizeof(struct full_sockaddr_rose)) + return -EINVAL; + memset(&srose, 0, sizeof(struct full_sockaddr_rose)); + memcpy(&srose, usrose, msg->msg_namelen); + if (rosecmp(&rose->dest_addr, &srose.srose_addr) != 0 || + ax25cmp(&rose->dest_call, &srose.srose_call) != 0) + return -EISCONN; + if (srose.srose_ndigis != rose->dest_ndigis) + return -EISCONN; + if (srose.srose_ndigis == rose->dest_ndigis) { + for (n = 0 ; n < srose.srose_ndigis ; n++) + if (ax25cmp(&rose->dest_digis[n], + &srose.srose_digis[n])) + return -EISCONN; + } + if (srose.srose_family != AF_ROSE) + return -EINVAL; + } else { + if (sk->sk_state != TCP_ESTABLISHED) + return -ENOTCONN; + + srose.srose_family = AF_ROSE; + srose.srose_addr = rose->dest_addr; + srose.srose_call = rose->dest_call; + srose.srose_ndigis = rose->dest_ndigis; + for (n = 0 ; n < rose->dest_ndigis ; n++) + srose.srose_digis[n] = rose->dest_digis[n]; + } + + /* Build a packet */ + /* Sanity check the packet size */ + if (len > 65535) + return -EMSGSIZE; + + size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN; + + if ((skb = sock_alloc_send_skb(sk, size, msg->msg_flags & MSG_DONTWAIT, &err)) == NULL) + return err; + + skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN); + + /* + * Put the data on the end + */ + + skb_reset_transport_header(skb); + skb_put(skb, len); + + err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); + if (err) { + kfree_skb(skb); + return err; + } + + /* + * If the Q BIT Include socket option is in force, the first + * byte of the user data is the logical value of the Q Bit. + */ + if (rose->qbitincl) { + qbit = skb->data[0]; + skb_pull(skb, 1); + } + + /* + * Push down the ROSE header + */ + asmptr = skb_push(skb, ROSE_MIN_LEN); + + /* Build a ROSE Network header */ + asmptr[0] = ((rose->lci >> 8) & 0x0F) | ROSE_GFI; + asmptr[1] = (rose->lci >> 0) & 0xFF; + asmptr[2] = ROSE_DATA; + + if (qbit) + asmptr[0] |= ROSE_Q_BIT; + + if (sk->sk_state != TCP_ESTABLISHED) { + kfree_skb(skb); + return -ENOTCONN; + } + +#ifdef M_BIT +#define ROSE_PACLEN (256-ROSE_MIN_LEN) + if (skb->len - ROSE_MIN_LEN > ROSE_PACLEN) { + unsigned char header[ROSE_MIN_LEN]; + struct sk_buff *skbn; + int frontlen; + int lg; + + /* Save a copy of the Header */ + skb_copy_from_linear_data(skb, header, ROSE_MIN_LEN); + skb_pull(skb, ROSE_MIN_LEN); + + frontlen = skb_headroom(skb); + + while (skb->len > 0) { + if ((skbn = sock_alloc_send_skb(sk, frontlen + ROSE_PACLEN, 0, &err)) == NULL) { + kfree_skb(skb); + return err; + } + + skbn->sk = sk; + skbn->free = 1; + skbn->arp = 1; + + skb_reserve(skbn, frontlen); + + lg = (ROSE_PACLEN > skb->len) ? skb->len : ROSE_PACLEN; + + /* Copy the user data */ + skb_copy_from_linear_data(skb, skb_put(skbn, lg), lg); + skb_pull(skb, lg); + + /* Duplicate the Header */ + skb_push(skbn, ROSE_MIN_LEN); + skb_copy_to_linear_data(skbn, header, ROSE_MIN_LEN); + + if (skb->len > 0) + skbn->data[2] |= M_BIT; + + skb_queue_tail(&sk->sk_write_queue, skbn); /* Throw it on the queue */ + } + + skb->free = 1; + kfree_skb(skb); + } else { + skb_queue_tail(&sk->sk_write_queue, skb); /* Throw it on the queue */ + } +#else + skb_queue_tail(&sk->sk_write_queue, skb); /* Shove it onto the queue */ +#endif + + rose_kick(sk); + + return len; +} +",0,"static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, + struct msghdr *msg, size_t len) +{ + struct sock *sk = sock->sk; + struct rose_sock *rose = rose_sk(sk); + struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name; + int err; + struct full_sockaddr_rose srose; + struct sk_buff *skb; + unsigned char *asmptr; + int n, size, qbit = 0; + + if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_CMSG_COMPAT)) + return -EINVAL; + + if (sock_flag(sk, SOCK_ZAPPED)) + return -EADDRNOTAVAIL; + + if (sk->sk_shutdown & SEND_SHUTDOWN) { + send_sig(SIGPIPE, current, 0); + return -EPIPE; + } + + if (rose->neighbour == NULL || rose->device == NULL) + return -ENETUNREACH; + + if (usrose != NULL) { + if (msg->msg_namelen != sizeof(struct sockaddr_rose) && msg->msg_namelen != sizeof(struct full_sockaddr_rose)) + return -EINVAL; + memset(&srose, 0, sizeof(struct full_sockaddr_rose)); + memcpy(&srose, usrose, msg->msg_namelen); + if (rosecmp(&rose->dest_addr, &srose.srose_addr) != 0 || + ax25cmp(&rose->dest_call, &srose.srose_call) != 0) + return -EISCONN; + if (srose.srose_ndigis != rose->dest_ndigis) + return -EISCONN; + if (srose.srose_ndigis == rose->dest_ndigis) { + for (n = 0 ; n < srose.srose_ndigis ; n++) + if (ax25cmp(&rose->dest_digis[n], + &srose.srose_digis[n])) + return -EISCONN; + } + if (srose.srose_family != AF_ROSE) + return -EINVAL; + } else { + if (sk->sk_state != TCP_ESTABLISHED) + return -ENOTCONN; + + srose.srose_family = AF_ROSE; + srose.srose_addr = rose->dest_addr; + srose.srose_call = rose->dest_call; + srose.srose_ndigis = rose->dest_ndigis; + for (n = 0 ; n < rose->dest_ndigis ; n++) + srose.srose_digis[n] = rose->dest_digis[n]; + } + + /* Build a packet */ + /* Sanity check the packet size */ + if (len > 65535) + return -EMSGSIZE; + + size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN; + + if ((skb = sock_alloc_send_skb(sk, size, msg->msg_flags & MSG_DONTWAIT, &err)) == NULL) + return err; + + skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN); + + /* + * Put the data on the end + */ + + skb_reset_transport_header(skb); + skb_put(skb, len); + + err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); + if (err) { + kfree_skb(skb); + return err; + } + + /* + * If the Q BIT Include socket option is in force, the first + * byte of the user data is the logical value of the Q Bit. + */ + if (rose->qbitincl) { + qbit = skb->data[0]; + skb_pull(skb, 1); + } + + /* + * Push down the ROSE header + */ + asmptr = skb_push(skb, ROSE_MIN_LEN); + + /* Build a ROSE Network header */ + asmptr[0] = ((rose->lci >> 8) & 0x0F) | ROSE_GFI; + asmptr[1] = (rose->lci >> 0) & 0xFF; + asmptr[2] = ROSE_DATA; + + if (qbit) + asmptr[0] |= ROSE_Q_BIT; + + if (sk->sk_state != TCP_ESTABLISHED) { + kfree_skb(skb); + return -ENOTCONN; + } + +#ifdef M_BIT +#define ROSE_PACLEN (256-ROSE_MIN_LEN) + if (skb->len - ROSE_MIN_LEN > ROSE_PACLEN) { + unsigned char header[ROSE_MIN_LEN]; + struct sk_buff *skbn; + int frontlen; + int lg; + + /* Save a copy of the Header */ + skb_copy_from_linear_data(skb, header, ROSE_MIN_LEN); + skb_pull(skb, ROSE_MIN_LEN); + + frontlen = skb_headroom(skb); + + while (skb->len > 0) { + if ((skbn = sock_alloc_send_skb(sk, frontlen + ROSE_PACLEN, 0, &err)) == NULL) { + kfree_skb(skb); + return err; + } + + skbn->sk = sk; + skbn->free = 1; + skbn->arp = 1; + + skb_reserve(skbn, frontlen); + + lg = (ROSE_PACLEN > skb->len) ? skb->len : ROSE_PACLEN; + + /* Copy the user data */ + skb_copy_from_linear_data(skb, skb_put(skbn, lg), lg); + skb_pull(skb, lg); + + /* Duplicate the Header */ + skb_push(skbn, ROSE_MIN_LEN); + skb_copy_to_linear_data(skbn, header, ROSE_MIN_LEN); + + if (skb->len > 0) + skbn->data[2] |= M_BIT; + + skb_queue_tail(&sk->sk_write_queue, skbn); /* Throw it on the queue */ + } + + skb->free = 1; + kfree_skb(skb); + } else { + skb_queue_tail(&sk->sk_write_queue, skb); /* Throw it on the queue */ + } +#else + skb_queue_tail(&sk->sk_write_queue, skb); /* Shove it onto the queue */ +#endif + + rose_kick(sk); + + return len; +} +","@@ -1253,6 +1253,7 @@ static int rose_recvmsg(struct kiocb *iocb, struct socket *sock, + skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); + + if (srose != NULL) { ++ memset(srose, 0, msg->msg_namelen); + srose->srose_family = AF_ROSE; + srose->srose_addr = rose->dest_addr; + srose->srose_call = rose->dest_call;",1386,1622,2048 +473,"static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr) /* {{{ */ +{ +/* + This is how the time string is formatted: + + snprintf(p, sizeof(p), ""%02d%02d%02d%02d%02d%02dZ"",ts->tm_year%100, + ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); +*/ + + time_t ret; + struct tm thetime; + char * strbuf; + char * thestr; + long gmadjust = 0; + size_t timestr_len; + + if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME && ASN1_STRING_type(timestr) != V_ASN1_GENERALIZEDTIME) { + php_error_docref(NULL, E_WARNING, ""illegal ASN1 data type for timestamp""); + return (time_t)-1; + } + + timestr_len = (size_t)ASN1_STRING_length(timestr); + + if (timestr_len != strlen((const char *)ASN1_STRING_get0_data(timestr))) { + php_error_docref(NULL, E_WARNING, ""illegal length in timestamp""); + return (time_t)-1; + } + + if (timestr_len < 13 && timestr_len != 11) { + php_error_docref(NULL, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + if (ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME && timestr_len < 15) { + php_error_docref(NULL, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + strbuf = estrdup((const char *)ASN1_STRING_get0_data(timestr)); + + memset(&thetime, 0, sizeof(thetime)); + + /* we work backwards so that we can use atoi more easily */ + + thestr = strbuf + timestr_len - 3; + + if (timestr_len == 11) { + thetime.tm_sec = 0; + } else { + thetime.tm_sec = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + } + thetime.tm_min = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_hour = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mday = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mon = atoi(thestr)-1; + + *thestr = '\0'; + if( ASN1_STRING_type(timestr) == V_ASN1_UTCTIME ) { + thestr -= 2; + thetime.tm_year = atoi(thestr); + + if (thetime.tm_year < 68) { + thetime.tm_year += 100; + } + } else if( ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME ) { + thestr -= 4; + thetime.tm_year = atoi(thestr) - 1900; + } + + + thetime.tm_isdst = -1; + ret = mktime(&thetime); + +#if HAVE_TM_GMTOFF + gmadjust = thetime.tm_gmtoff; +#else + /* + ** If correcting for daylight savings time, we set the adjustment to + ** the value of timezone - 3600 seconds. Otherwise, we need to overcorrect and + ** set the adjustment to the main timezone + 3600 seconds. + */ + gmadjust = -(thetime.tm_isdst ? (long)timezone - 3600 : (long)timezone); +#endif + ret += gmadjust; + + efree(strbuf); + + return ret; +} +/* }}} */ +",0,"static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr) /* {{{ */ +{ +/* + This is how the time string is formatted: + + snprintf(p, sizeof(p), ""%02d%02d%02d%02d%02d%02dZ"",ts->tm_year%100, + ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); +*/ + + time_t ret; + struct tm thetime; + char * strbuf; + char * thestr; + long gmadjust = 0; + size_t timestr_len; + + if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME && ASN1_STRING_type(timestr) != V_ASN1_GENERALIZEDTIME) { + php_error_docref(NULL, E_WARNING, ""illegal ASN1 data type for timestamp""); + return (time_t)-1; + } + + timestr_len = (size_t)ASN1_STRING_length(timestr); + + if (timestr_len != strlen((const char *)ASN1_STRING_get0_data(timestr))) { + php_error_docref(NULL, E_WARNING, ""illegal length in timestamp""); + return (time_t)-1; + } + + if (timestr_len < 13 && timestr_len != 11) { + php_error_docref(NULL, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + if (ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME && timestr_len < 15) { + php_error_docref(NULL, E_WARNING, ""unable to parse time string %s correctly"", timestr->data); + return (time_t)-1; + } + + strbuf = estrdup((const char *)ASN1_STRING_get0_data(timestr)); + + memset(&thetime, 0, sizeof(thetime)); + + /* we work backwards so that we can use atoi more easily */ + + thestr = strbuf + timestr_len - 3; + + if (timestr_len == 11) { + thetime.tm_sec = 0; + } else { + thetime.tm_sec = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + } + thetime.tm_min = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_hour = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mday = atoi(thestr); + *thestr = '\0'; + thestr -= 2; + thetime.tm_mon = atoi(thestr)-1; + + *thestr = '\0'; + if( ASN1_STRING_type(timestr) == V_ASN1_UTCTIME ) { + thestr -= 2; + thetime.tm_year = atoi(thestr); + + if (thetime.tm_year < 68) { + thetime.tm_year += 100; + } + } else if( ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME ) { + thestr -= 4; + thetime.tm_year = atoi(thestr) - 1900; + } + + + thetime.tm_isdst = -1; + ret = mktime(&thetime); + +#if HAVE_TM_GMTOFF + gmadjust = thetime.tm_gmtoff; +#else + /* + ** If correcting for daylight savings time, we set the adjustment to + ** the value of timezone - 3600 seconds. Otherwise, we need to overcorrect and + ** set the adjustment to the main timezone + 3600 seconds. + */ + gmadjust = -(thetime.tm_isdst ? (long)timezone - 3600 : (long)timezone); +#endif + ret += gmadjust; + + efree(strbuf); + + return ret; +} +/* }}} */ +","@@ -5421,7 +5421,7 @@ PHP_FUNCTION(openssl_seal) + buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(ctx)); + EVP_CIPHER_CTX_cleanup(ctx); + +- if (!EVP_SealInit(ctx, cipher, eks, eksl, &iv_buf[0], pkeys, nkeys) || ++ if (EVP_SealInit(ctx, cipher, eks, eksl, &iv_buf[0], pkeys, nkeys) <= 0 || + !EVP_SealUpdate(ctx, buf, &len1, (unsigned char *)data, (int)data_len) || + !EVP_SealFinal(ctx, buf + len1, &len2)) { + RETVAL_FALSE;",857,1093,2048 +18005,"static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type ) +{ + char *f_org, *f_dest; + int f_org_len, f_dest_len; + long height, width, threshold; + gdImagePtr im_org, im_dest, im_tmp; + char *fn_org = NULL; + char *fn_dest = NULL; + FILE *org, *dest; + int dest_height = -1; + int dest_width = -1; + int org_height, org_width; + int white, black; + int color, color_org, median; + int int_threshold; + int x, y; + float x_ratio, y_ratio; + long ignore_warning; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""pplll"", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) { + return; + } + + fn_org = f_org; + fn_dest = f_dest; + dest_height = height; + dest_width = width; + int_threshold = threshold; + + /* Check threshold value */ + if (int_threshold < 0 || int_threshold > 8) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Invalid threshold value '%d'"", int_threshold); + RETURN_FALSE; + } + + /* Check origin file */ + PHP_GD_CHECK_OPEN_BASEDIR(fn_org, ""Invalid origin filename""); + + /* Check destination file */ + PHP_GD_CHECK_OPEN_BASEDIR(fn_dest, ""Invalid destination filename""); + + /* Open origin file */ + org = VCWD_FOPEN(fn_org, ""rb""); + if (!org) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' for reading"", fn_org); + RETURN_FALSE; + } + + /* Open destination file */ + dest = VCWD_FOPEN(fn_dest, ""wb""); + if (!dest) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' for writing"", fn_dest); + RETURN_FALSE; + } + + switch (image_type) { + case PHP_GDIMG_TYPE_GIF: + im_org = gdImageCreateFromGif(org); + if (im_org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' Not a valid GIF file"", fn_dest); + RETURN_FALSE; + } + break; + +#ifdef HAVE_GD_JPG + case PHP_GDIMG_TYPE_JPG: + ignore_warning = INI_INT(""gd.jpeg_ignore_warning""); + im_org = gdImageCreateFromJpegEx(org, ignore_warning); + if (im_org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' Not a valid JPEG file"", fn_dest); + RETURN_FALSE; + } + break; +#endif /* HAVE_GD_JPG */ + +#ifdef HAVE_GD_PNG + case PHP_GDIMG_TYPE_PNG: + im_org = gdImageCreateFromPng(org); + if (im_org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' Not a valid PNG file"", fn_dest); + RETURN_FALSE; + } + break; +#endif /* HAVE_GD_PNG */ + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Format not supported""); + RETURN_FALSE; + break; + } + + org_width = gdImageSX (im_org); + org_height = gdImageSY (im_org); + + x_ratio = (float) org_width / (float) dest_width; + y_ratio = (float) org_height / (float) dest_height; + + if (x_ratio > 1 && y_ratio > 1) { + if (y_ratio > x_ratio) { + x_ratio = y_ratio; + } else { + y_ratio = x_ratio; + } + dest_width = (int) (org_width / x_ratio); + dest_height = (int) (org_height / y_ratio); + } else { + x_ratio = (float) dest_width / (float) org_width; + y_ratio = (float) dest_height / (float) org_height; + + if (y_ratio < x_ratio) { + x_ratio = y_ratio; + } else { + y_ratio = x_ratio; + } + dest_width = (int) (org_width * x_ratio); + dest_height = (int) (org_height * y_ratio); + } + + im_tmp = gdImageCreate (dest_width, dest_height); + if (im_tmp == NULL ) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate temporary buffer""); + RETURN_FALSE; + } + + gdImageCopyResized (im_tmp, im_org, 0, 0, 0, 0, dest_width, dest_height, org_width, org_height); + + gdImageDestroy(im_org); + + fclose(org); + + im_dest = gdImageCreate(dest_width, dest_height); + if (im_dest == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate destination buffer""); + RETURN_FALSE; + } + + white = gdImageColorAllocate(im_dest, 255, 255, 255); + if (white == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate the colors for the destination buffer""); + RETURN_FALSE; + } + + black = gdImageColorAllocate(im_dest, 0, 0, 0); + if (black == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate the colors for the destination buffer""); + RETURN_FALSE; + } + + int_threshold = int_threshold * 32; + + for (y = 0; y < dest_height; y++) { + for (x = 0; x < dest_width; x++) { + color_org = gdImageGetPixel (im_tmp, x, y); + median = (im_tmp->red[color_org] + im_tmp->green[color_org] + im_tmp->blue[color_org]) / 3; + if (median < int_threshold) { + color = black; + } else { + color = white; + } + gdImageSetPixel (im_dest, x, y, color); + } + } + + gdImageDestroy (im_tmp ); + + gdImageWBMP(im_dest, black , dest); + + fflush(dest); + fclose(dest); + + gdImageDestroy(im_dest); + + RETURN_TRUE; +} +",1,"static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type ) +{ + char *f_org, *f_dest; + int f_org_len, f_dest_len; + long height, width, threshold; + gdImagePtr im_org, im_dest, im_tmp; + char *fn_org = NULL; + char *fn_dest = NULL; + FILE *org, *dest; + int dest_height = -1; + int dest_width = -1; + int org_height, org_width; + int white, black; + int color, color_org, median; + int int_threshold; + int x, y; + float x_ratio, y_ratio; + long ignore_warning; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""pplll"", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) { + return; + } + + fn_org = f_org; + fn_dest = f_dest; + dest_height = height; + dest_width = width; + int_threshold = threshold; + + /* Check threshold value */ + if (int_threshold < 0 || int_threshold > 8) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Invalid threshold value '%d'"", int_threshold); + RETURN_FALSE; + } + + /* Check origin file */ + PHP_GD_CHECK_OPEN_BASEDIR(fn_org, ""Invalid origin filename""); + + /* Check destination file */ + PHP_GD_CHECK_OPEN_BASEDIR(fn_dest, ""Invalid destination filename""); + + /* Open origin file */ + org = VCWD_FOPEN(fn_org, ""rb""); + if (!org) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' for reading"", fn_org); + RETURN_FALSE; + } + + /* Open destination file */ + dest = VCWD_FOPEN(fn_dest, ""wb""); + if (!dest) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' for writing"", fn_dest); + RETURN_FALSE; + } + + switch (image_type) { + case PHP_GDIMG_TYPE_GIF: + im_org = gdImageCreateFromGif(org); + if (im_org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' Not a valid GIF file"", fn_dest); + RETURN_FALSE; + } + break; + +#ifdef HAVE_GD_JPG + case PHP_GDIMG_TYPE_JPG: + ignore_warning = INI_INT(""gd.jpeg_ignore_warning""); + im_org = gdImageCreateFromJpegEx(org, ignore_warning); + if (im_org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' Not a valid JPEG file"", fn_dest); + RETURN_FALSE; + } + break; +#endif /* HAVE_GD_JPG */ + +#ifdef HAVE_GD_PNG + case PHP_GDIMG_TYPE_PNG: + im_org = gdImageCreateFromPng(org); + if (im_org == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to open '%s' Not a valid PNG file"", fn_dest); + RETURN_FALSE; + } + break; +#endif /* HAVE_GD_PNG */ + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Format not supported""); + RETURN_FALSE; + break; + } + + org_width = gdImageSX (im_org); + org_height = gdImageSY (im_org); + + x_ratio = (float) org_width / (float) dest_width; + y_ratio = (float) org_height / (float) dest_height; + + if (x_ratio > 1 && y_ratio > 1) { + if (y_ratio > x_ratio) { + x_ratio = y_ratio; + } else { + y_ratio = x_ratio; + } + dest_width = (int) (org_width / x_ratio); + dest_height = (int) (org_height / y_ratio); + } else { + x_ratio = (float) dest_width / (float) org_width; + y_ratio = (float) dest_height / (float) org_height; + + if (y_ratio < x_ratio) { + x_ratio = y_ratio; + } else { + y_ratio = x_ratio; + } + dest_width = (int) (org_width * x_ratio); + dest_height = (int) (org_height * y_ratio); + } + + im_tmp = gdImageCreate (dest_width, dest_height); + if (im_tmp == NULL ) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate temporary buffer""); + RETURN_FALSE; + } + + gdImageCopyResized (im_tmp, im_org, 0, 0, 0, 0, dest_width, dest_height, org_width, org_height); + + gdImageDestroy(im_org); + + fclose(org); + + im_dest = gdImageCreate(dest_width, dest_height); + if (im_dest == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate destination buffer""); + RETURN_FALSE; + } + + white = gdImageColorAllocate(im_dest, 255, 255, 255); + if (white == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate the colors for the destination buffer""); + RETURN_FALSE; + } + + black = gdImageColorAllocate(im_dest, 0, 0, 0); + if (black == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Unable to allocate the colors for the destination buffer""); + RETURN_FALSE; + } + + int_threshold = int_threshold * 32; + + for (y = 0; y < dest_height; y++) { + for (x = 0; x < dest_width; x++) { + color_org = gdImageGetPixel (im_tmp, x, y); + median = (im_tmp->red[color_org] + im_tmp->green[color_org] + im_tmp->blue[color_org]) / 3; + if (median < int_threshold) { + color = black; + } else { + color = white; + } + gdImageSetPixel (im_dest, x, y, color); + } + } + + gdImageDestroy (im_tmp ); + + gdImageWBMP(im_dest, black , dest); + + fflush(dest); + fclose(dest); + + gdImageDestroy(im_dest); + + RETURN_TRUE; +} +","@@ -99,7 +99,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int, int); + + #include ""gd_ctx.c"" + +-/* as it is not really public, duplicate declaration here to avoid ++/* as it is not really public, duplicate declaration here to avoid + pointless warnings */ + int overflow2(int a, int b); + +@@ -1197,7 +1197,7 @@ PHP_MINIT_FUNCTION(gd) + REGISTER_LONG_CONSTANT(""IMG_CROP_SIDES"", GD_CROP_SIDES, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(""IMG_CROP_THRESHOLD"", GD_CROP_THRESHOLD, CONST_CS | CONST_PERSISTENT); + +- ++ + REGISTER_LONG_CONSTANT(""IMG_BELL"", GD_BELL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(""IMG_BESSEL"", GD_BESSEL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(""IMG_BILINEAR_FIXED"", GD_BILINEAR_FIXED, CONST_CS | CONST_PERSISTENT); +@@ -1651,11 +1651,11 @@ PHP_FUNCTION(imagetruecolortopalette) + + ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, ""Image"", le_gd); + +- if (ncolors <= 0) { +- php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Number of colors has to be greater than zero""); ++ if (ncolors <= 0 || ncolors > INT_MAX) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Number of colors has to be greater than zero and no more than %d"", INT_MAX); + RETURN_FALSE; + } +- gdImageTrueColorToPalette(im, dither, ncolors); ++ gdImageTrueColorToPalette(im, dither, (int)ncolors); + + RETURN_TRUE; + } +@@ -3906,7 +3906,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int + #endif /* VIRTUAL_DIR */ + + PHP_GD_CHECK_OPEN_BASEDIR(fontname, ""Invalid font filename""); +- ++ + #ifdef HAVE_GD_FREETYPE + if (extended) { + error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex); +@@ -4484,7 +4484,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type ) + int x, y; + float x_ratio, y_ratio; + long ignore_warning; +- ++ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ""pplll"", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) { + return; + } +@@ -5367,7 +5367,7 @@ PHP_FUNCTION(imageaffinematrixget) + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Missing y position""); + RETURN_FALSE; + } +- ++ + if (type == GD_AFFINE_TRANSLATE) { + res = gdAffineTranslate(affine, x, y); + } else {",1372,1608,2048 +9657,"_gcry_aes_ocb_crypt (gcry_cipher_hd_t c, void *outbuf_arg, + const void *inbuf_arg, size_t nblocks, int encrypt) +{ + RIJNDAEL_context *ctx = (void *)&c->context.c; + unsigned char *outbuf = outbuf_arg; + const unsigned char *inbuf = inbuf_arg; + unsigned int burn_depth = 0; + + if (0) + ; +#ifdef USE_AESNI + else if (ctx->use_aesni) + { + return _gcry_aes_aesni_ocb_crypt (c, outbuf, inbuf, nblocks, encrypt); + } +#endif /*USE_AESNI*/ +#ifdef USE_SSSE3 + else if (ctx->use_ssse3) + { + return _gcry_aes_ssse3_ocb_crypt (c, outbuf, inbuf, nblocks, encrypt); + } +#endif /*USE_SSSE3*/ +#ifdef USE_ARM_CE + else if (ctx->use_arm_ce) + { + return _gcry_aes_armv8_ce_ocb_crypt (c, outbuf, inbuf, nblocks, encrypt); + } +#endif /*USE_ARM_CE*/ + else if (encrypt) + { + union { unsigned char x1[16] ATTR_ALIGNED_16; u32 x32[4]; } l_tmp; + rijndael_cryptfn_t encrypt_fn = ctx->encrypt_fn; + + if (ctx->prefetch_enc_fn) + ctx->prefetch_enc_fn(); + + for ( ;nblocks; nblocks-- ) + { + u64 i = ++c->u_mode.ocb.data_nblocks; + const unsigned char *l = ocb_get_l(c, i); + + /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */ + cipher_block_xor_1 (c->u_iv.iv, l, BLOCKSIZE); + cipher_block_cpy (l_tmp.x1, inbuf, BLOCKSIZE); + /* Checksum_i = Checksum_{i-1} xor P_i */ + cipher_block_xor_1 (c->u_ctr.ctr, l_tmp.x1, BLOCKSIZE); + /* C_i = Offset_i xor ENCIPHER(K, P_i xor Offset_i) */ + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + burn_depth = encrypt_fn (ctx, l_tmp.x1, l_tmp.x1); + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + cipher_block_cpy (outbuf, l_tmp.x1, BLOCKSIZE); + + inbuf += BLOCKSIZE; + outbuf += BLOCKSIZE; + } + } + else + { + union { unsigned char x1[16] ATTR_ALIGNED_16; u32 x32[4]; } l_tmp; + rijndael_cryptfn_t decrypt_fn = ctx->decrypt_fn; + + check_decryption_preparation (ctx); + + if (ctx->prefetch_dec_fn) + ctx->prefetch_dec_fn(); + + for ( ;nblocks; nblocks-- ) + { + u64 i = ++c->u_mode.ocb.data_nblocks; + const unsigned char *l = ocb_get_l(c, i); + + /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */ + cipher_block_xor_1 (c->u_iv.iv, l, BLOCKSIZE); + cipher_block_cpy (l_tmp.x1, inbuf, BLOCKSIZE); + /* C_i = Offset_i xor ENCIPHER(K, P_i xor Offset_i) */ + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + burn_depth = decrypt_fn (ctx, l_tmp.x1, l_tmp.x1); + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + /* Checksum_i = Checksum_{i-1} xor P_i */ + cipher_block_xor_1 (c->u_ctr.ctr, l_tmp.x1, BLOCKSIZE); + cipher_block_cpy (outbuf, l_tmp.x1, BLOCKSIZE); + + inbuf += BLOCKSIZE; + outbuf += BLOCKSIZE; + } + } + + if (burn_depth) + _gcry_burn_stack (burn_depth + 4 * sizeof(void *)); + + return 0; +} +",0,"_gcry_aes_ocb_crypt (gcry_cipher_hd_t c, void *outbuf_arg, + const void *inbuf_arg, size_t nblocks, int encrypt) +{ + RIJNDAEL_context *ctx = (void *)&c->context.c; + unsigned char *outbuf = outbuf_arg; + const unsigned char *inbuf = inbuf_arg; + unsigned int burn_depth = 0; + + if (0) + ; +#ifdef USE_AESNI + else if (ctx->use_aesni) + { + return _gcry_aes_aesni_ocb_crypt (c, outbuf, inbuf, nblocks, encrypt); + } +#endif /*USE_AESNI*/ +#ifdef USE_SSSE3 + else if (ctx->use_ssse3) + { + return _gcry_aes_ssse3_ocb_crypt (c, outbuf, inbuf, nblocks, encrypt); + } +#endif /*USE_SSSE3*/ +#ifdef USE_ARM_CE + else if (ctx->use_arm_ce) + { + return _gcry_aes_armv8_ce_ocb_crypt (c, outbuf, inbuf, nblocks, encrypt); + } +#endif /*USE_ARM_CE*/ + else if (encrypt) + { + union { unsigned char x1[16] ATTR_ALIGNED_16; u32 x32[4]; } l_tmp; + rijndael_cryptfn_t encrypt_fn = ctx->encrypt_fn; + + if (ctx->prefetch_enc_fn) + ctx->prefetch_enc_fn(); + + for ( ;nblocks; nblocks-- ) + { + u64 i = ++c->u_mode.ocb.data_nblocks; + const unsigned char *l = ocb_get_l(c, i); + + /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */ + cipher_block_xor_1 (c->u_iv.iv, l, BLOCKSIZE); + cipher_block_cpy (l_tmp.x1, inbuf, BLOCKSIZE); + /* Checksum_i = Checksum_{i-1} xor P_i */ + cipher_block_xor_1 (c->u_ctr.ctr, l_tmp.x1, BLOCKSIZE); + /* C_i = Offset_i xor ENCIPHER(K, P_i xor Offset_i) */ + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + burn_depth = encrypt_fn (ctx, l_tmp.x1, l_tmp.x1); + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + cipher_block_cpy (outbuf, l_tmp.x1, BLOCKSIZE); + + inbuf += BLOCKSIZE; + outbuf += BLOCKSIZE; + } + } + else + { + union { unsigned char x1[16] ATTR_ALIGNED_16; u32 x32[4]; } l_tmp; + rijndael_cryptfn_t decrypt_fn = ctx->decrypt_fn; + + check_decryption_preparation (ctx); + + if (ctx->prefetch_dec_fn) + ctx->prefetch_dec_fn(); + + for ( ;nblocks; nblocks-- ) + { + u64 i = ++c->u_mode.ocb.data_nblocks; + const unsigned char *l = ocb_get_l(c, i); + + /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */ + cipher_block_xor_1 (c->u_iv.iv, l, BLOCKSIZE); + cipher_block_cpy (l_tmp.x1, inbuf, BLOCKSIZE); + /* C_i = Offset_i xor ENCIPHER(K, P_i xor Offset_i) */ + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + burn_depth = decrypt_fn (ctx, l_tmp.x1, l_tmp.x1); + cipher_block_xor_1 (l_tmp.x1, c->u_iv.iv, BLOCKSIZE); + /* Checksum_i = Checksum_{i-1} xor P_i */ + cipher_block_xor_1 (c->u_ctr.ctr, l_tmp.x1, BLOCKSIZE); + cipher_block_cpy (outbuf, l_tmp.x1, BLOCKSIZE); + + inbuf += BLOCKSIZE; + outbuf += BLOCKSIZE; + } + } + + if (burn_depth) + _gcry_burn_stack (burn_depth + 4 * sizeof(void *)); + + return 0; +} +","@@ -218,11 +218,11 @@ static const char *selftest(void); + + + /* Prefetching for encryption/decryption tables. */ +-static void prefetch_table(const volatile byte *tab, size_t len) ++static inline void prefetch_table(const volatile byte *tab, size_t len) + { + size_t i; + +- for (i = 0; i < len; i += 8 * 32) ++ for (i = 0; len - i >= 8 * 32; i += 8 * 32) + { + (void)tab[i + 0 * 32]; + (void)tab[i + 1 * 32]; +@@ -233,17 +233,37 @@ static void prefetch_table(const volatile byte *tab, size_t len) + (void)tab[i + 6 * 32]; + (void)tab[i + 7 * 32]; + } ++ for (; i < len; i += 32) ++ { ++ (void)tab[i]; ++ } + + (void)tab[len - 1]; + } + + static void prefetch_enc(void) + { +- prefetch_table((const void *)encT, sizeof(encT)); ++ /* Modify counters to trigger copy-on-write and unsharing if physical pages ++ * of look-up table are shared between processes. Modifying counters also ++ * causes checksums for pages to change and hint same-page merging algorithm ++ * that these pages are frequently changing. */ ++ enc_tables.counter_head++; ++ enc_tables.counter_tail++; ++ ++ /* Prefetch look-up tables to cache. */ ++ prefetch_table((const void *)&enc_tables, sizeof(enc_tables)); + } + + static void prefetch_dec(void) + { ++ /* Modify counters to trigger copy-on-write and unsharing if physical pages ++ * of look-up table are shared between processes. Modifying counters also ++ * causes checksums for pages to change and hint same-page merging algorithm ++ * that these pages are frequently changing. */ ++ dec_tables.counter_head++; ++ dec_tables.counter_tail++; ++ ++ /* Prefetch look-up tables to cache. */ + prefetch_table((const void *)&dec_tables, sizeof(dec_tables)); + } + +@@ -765,9 +785,10 @@ do_encrypt (const RIJNDAEL_context *ctx, + { + #ifdef USE_AMD64_ASM + return _gcry_aes_amd64_encrypt_block(ctx->keyschenc, bx, ax, ctx->rounds, +- encT); ++ enc_tables.T); + #elif defined(USE_ARM_ASM) +- return _gcry_aes_arm_encrypt_block(ctx->keyschenc, bx, ax, ctx->rounds, encT); ++ return _gcry_aes_arm_encrypt_block(ctx->keyschenc, bx, ax, ctx->rounds, ++ enc_tables.T); + #else + return do_encrypt_fn (ctx, bx, ax); + #endif /* !USE_ARM_ASM && !USE_AMD64_ASM*/ +@@ -1123,10 +1144,10 @@ do_decrypt (const RIJNDAEL_context *ctx, unsigned char *bx, + { + #ifdef USE_AMD64_ASM + return _gcry_aes_amd64_decrypt_block(ctx->keyschdec, bx, ax, ctx->rounds, +- &dec_tables); ++ dec_tables.T); + #elif defined(USE_ARM_ASM) + return _gcry_aes_arm_decrypt_block(ctx->keyschdec, bx, ax, ctx->rounds, +- &dec_tables); ++ dec_tables.T); + #else + return do_decrypt_fn (ctx, bx, ax); + #endif /*!USE_ARM_ASM && !USE_AMD64_ASM*/",946,1182,2048 +2830,"static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + struct ip_tunnel *tunnel = netdev_priv(dev); + struct net_device_stats *stats = &dev->stats; + struct netdev_queue *txq = netdev_get_tx_queue(dev, 0); + struct iphdr *tiph = &tunnel->parms.iph; + struct ipv6hdr *iph6 = ipv6_hdr(skb); + u8 tos = tunnel->parms.iph.tos; + __be16 df = tiph->frag_off; + struct rtable *rt; /* Route to the other host */ + struct net_device *tdev; /* Device to other host */ + struct iphdr *iph; /* Our new IP header */ + unsigned int max_headroom; /* The extra header space needed */ + __be32 dst = tiph->daddr; + int mtu; + struct in6_addr *addr6; + int addr_type; + + if (skb->protocol != htons(ETH_P_IPV6)) + goto tx_error; + + /* ISATAP (RFC4214) - must come before 6to4 */ + if (dev->priv_flags & IFF_ISATAP) { + struct neighbour *neigh = NULL; + + if (skb_dst(skb)) + neigh = skb_dst(skb)->neighbour; + + if (neigh == NULL) { + if (net_ratelimit()) + printk(KERN_DEBUG ""sit: nexthop == NULL\n""); + goto tx_error; + } + + addr6 = (struct in6_addr*)&neigh->primary_key; + addr_type = ipv6_addr_type(addr6); + + if ((addr_type & IPV6_ADDR_UNICAST) && + ipv6_addr_is_isatap(addr6)) + dst = addr6->s6_addr32[3]; + else + goto tx_error; + } + + if (!dst) + dst = try_6rd(&iph6->daddr, tunnel); + + if (!dst) { + struct neighbour *neigh = NULL; + + if (skb_dst(skb)) + neigh = skb_dst(skb)->neighbour; + + if (neigh == NULL) { + if (net_ratelimit()) + printk(KERN_DEBUG ""sit: nexthop == NULL\n""); + goto tx_error; + } + + addr6 = (struct in6_addr*)&neigh->primary_key; + addr_type = ipv6_addr_type(addr6); + + if (addr_type == IPV6_ADDR_ANY) { + addr6 = &ipv6_hdr(skb)->daddr; + addr_type = ipv6_addr_type(addr6); + } + + if ((addr_type & IPV6_ADDR_COMPATv4) == 0) + goto tx_error_icmp; + + dst = addr6->s6_addr32[3]; + } + + { + struct flowi fl = { .nl_u = { .ip4_u = + { .daddr = dst, + .saddr = tiph->saddr, + .tos = RT_TOS(tos) } }, + .oif = tunnel->parms.link, + .proto = IPPROTO_IPV6 }; + if (ip_route_output_key(dev_net(dev), &rt, &fl)) { + stats->tx_carrier_errors++; + goto tx_error_icmp; + } + } + if (rt->rt_type != RTN_UNICAST) { + ip_rt_put(rt); + stats->tx_carrier_errors++; + goto tx_error_icmp; + } + tdev = rt->u.dst.dev; + + if (tdev == dev) { + ip_rt_put(rt); + stats->collisions++; + goto tx_error; + } + + if (df) { + mtu = dst_mtu(&rt->u.dst) - sizeof(struct iphdr); + + if (mtu < 68) { + stats->collisions++; + ip_rt_put(rt); + goto tx_error; + } + + if (mtu < IPV6_MIN_MTU) { + mtu = IPV6_MIN_MTU; + df = 0; + } + + if (tunnel->parms.iph.daddr && skb_dst(skb)) + skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu); + + if (skb->len > mtu) { + icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev); + ip_rt_put(rt); + goto tx_error; + } + } + + if (tunnel->err_count > 0) { + if (time_before(jiffies, + tunnel->err_time + IPTUNNEL_ERR_TIMEO)) { + tunnel->err_count--; + dst_link_failure(skb); + } else + tunnel->err_count = 0; + } + + /* + * Okay, now see if we can stuff it in the buffer as-is. + */ + max_headroom = LL_RESERVED_SPACE(tdev)+sizeof(struct iphdr); + + if (skb_headroom(skb) < max_headroom || skb_shared(skb) || + (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { + struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); + if (!new_skb) { + ip_rt_put(rt); + txq->tx_dropped++; + dev_kfree_skb(skb); + return NETDEV_TX_OK; + } + if (skb->sk) + skb_set_owner_w(new_skb, skb->sk); + dev_kfree_skb(skb); + skb = new_skb; + iph6 = ipv6_hdr(skb); + } + + skb->transport_header = skb->network_header; + skb_push(skb, sizeof(struct iphdr)); + skb_reset_network_header(skb); + memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); + IPCB(skb)->flags = 0; + skb_dst_drop(skb); + skb_dst_set(skb, &rt->u.dst); + + /* + * Push down and install the IPIP header. + */ + + iph = ip_hdr(skb); + iph->version = 4; + iph->ihl = sizeof(struct iphdr)>>2; + iph->frag_off = df; + iph->protocol = IPPROTO_IPV6; + iph->tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6)); + iph->daddr = rt->rt_dst; + iph->saddr = rt->rt_src; + + if ((iph->ttl = tiph->ttl) == 0) + iph->ttl = iph6->hop_limit; + + nf_reset(skb); + + IPTUNNEL_XMIT(); + return NETDEV_TX_OK; + +tx_error_icmp: + dst_link_failure(skb); +tx_error: + stats->tx_errors++; + dev_kfree_skb(skb); + return NETDEV_TX_OK; +} +",0,"static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + struct ip_tunnel *tunnel = netdev_priv(dev); + struct net_device_stats *stats = &dev->stats; + struct netdev_queue *txq = netdev_get_tx_queue(dev, 0); + struct iphdr *tiph = &tunnel->parms.iph; + struct ipv6hdr *iph6 = ipv6_hdr(skb); + u8 tos = tunnel->parms.iph.tos; + __be16 df = tiph->frag_off; + struct rtable *rt; /* Route to the other host */ + struct net_device *tdev; /* Device to other host */ + struct iphdr *iph; /* Our new IP header */ + unsigned int max_headroom; /* The extra header space needed */ + __be32 dst = tiph->daddr; + int mtu; + struct in6_addr *addr6; + int addr_type; + + if (skb->protocol != htons(ETH_P_IPV6)) + goto tx_error; + + /* ISATAP (RFC4214) - must come before 6to4 */ + if (dev->priv_flags & IFF_ISATAP) { + struct neighbour *neigh = NULL; + + if (skb_dst(skb)) + neigh = skb_dst(skb)->neighbour; + + if (neigh == NULL) { + if (net_ratelimit()) + printk(KERN_DEBUG ""sit: nexthop == NULL\n""); + goto tx_error; + } + + addr6 = (struct in6_addr*)&neigh->primary_key; + addr_type = ipv6_addr_type(addr6); + + if ((addr_type & IPV6_ADDR_UNICAST) && + ipv6_addr_is_isatap(addr6)) + dst = addr6->s6_addr32[3]; + else + goto tx_error; + } + + if (!dst) + dst = try_6rd(&iph6->daddr, tunnel); + + if (!dst) { + struct neighbour *neigh = NULL; + + if (skb_dst(skb)) + neigh = skb_dst(skb)->neighbour; + + if (neigh == NULL) { + if (net_ratelimit()) + printk(KERN_DEBUG ""sit: nexthop == NULL\n""); + goto tx_error; + } + + addr6 = (struct in6_addr*)&neigh->primary_key; + addr_type = ipv6_addr_type(addr6); + + if (addr_type == IPV6_ADDR_ANY) { + addr6 = &ipv6_hdr(skb)->daddr; + addr_type = ipv6_addr_type(addr6); + } + + if ((addr_type & IPV6_ADDR_COMPATv4) == 0) + goto tx_error_icmp; + + dst = addr6->s6_addr32[3]; + } + + { + struct flowi fl = { .nl_u = { .ip4_u = + { .daddr = dst, + .saddr = tiph->saddr, + .tos = RT_TOS(tos) } }, + .oif = tunnel->parms.link, + .proto = IPPROTO_IPV6 }; + if (ip_route_output_key(dev_net(dev), &rt, &fl)) { + stats->tx_carrier_errors++; + goto tx_error_icmp; + } + } + if (rt->rt_type != RTN_UNICAST) { + ip_rt_put(rt); + stats->tx_carrier_errors++; + goto tx_error_icmp; + } + tdev = rt->u.dst.dev; + + if (tdev == dev) { + ip_rt_put(rt); + stats->collisions++; + goto tx_error; + } + + if (df) { + mtu = dst_mtu(&rt->u.dst) - sizeof(struct iphdr); + + if (mtu < 68) { + stats->collisions++; + ip_rt_put(rt); + goto tx_error; + } + + if (mtu < IPV6_MIN_MTU) { + mtu = IPV6_MIN_MTU; + df = 0; + } + + if (tunnel->parms.iph.daddr && skb_dst(skb)) + skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu); + + if (skb->len > mtu) { + icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev); + ip_rt_put(rt); + goto tx_error; + } + } + + if (tunnel->err_count > 0) { + if (time_before(jiffies, + tunnel->err_time + IPTUNNEL_ERR_TIMEO)) { + tunnel->err_count--; + dst_link_failure(skb); + } else + tunnel->err_count = 0; + } + + /* + * Okay, now see if we can stuff it in the buffer as-is. + */ + max_headroom = LL_RESERVED_SPACE(tdev)+sizeof(struct iphdr); + + if (skb_headroom(skb) < max_headroom || skb_shared(skb) || + (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { + struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); + if (!new_skb) { + ip_rt_put(rt); + txq->tx_dropped++; + dev_kfree_skb(skb); + return NETDEV_TX_OK; + } + if (skb->sk) + skb_set_owner_w(new_skb, skb->sk); + dev_kfree_skb(skb); + skb = new_skb; + iph6 = ipv6_hdr(skb); + } + + skb->transport_header = skb->network_header; + skb_push(skb, sizeof(struct iphdr)); + skb_reset_network_header(skb); + memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); + IPCB(skb)->flags = 0; + skb_dst_drop(skb); + skb_dst_set(skb, &rt->u.dst); + + /* + * Push down and install the IPIP header. + */ + + iph = ip_hdr(skb); + iph->version = 4; + iph->ihl = sizeof(struct iphdr)>>2; + iph->frag_off = df; + iph->protocol = IPPROTO_IPV6; + iph->tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6)); + iph->daddr = rt->rt_dst; + iph->saddr = rt->rt_src; + + if ((iph->ttl = tiph->ttl) == 0) + iph->ttl = iph6->hop_limit; + + nf_reset(skb); + + IPTUNNEL_XMIT(); + return NETDEV_TX_OK; + +tx_error_icmp: + dst_link_failure(skb); +tx_error: + stats->tx_errors++; + dev_kfree_skb(skb); + return NETDEV_TX_OK; +} +","@@ -1227,15 +1227,14 @@ static int __init sit_init(void) + + printk(KERN_INFO ""IPv6 over IPv4 tunneling driver\n""); + +- if (xfrm4_tunnel_register(&sit_handler, AF_INET6) < 0) { +- printk(KERN_INFO ""sit init: Can't add protocol\n""); +- return -EAGAIN; +- } +- + err = register_pernet_device(&sit_net_ops); + if (err < 0) +- xfrm4_tunnel_deregister(&sit_handler, AF_INET6); +- ++ return err; ++ err = xfrm4_tunnel_register(&sit_handler, AF_INET6); ++ if (err < 0) { ++ unregister_pernet_device(&sit_net_ops); ++ printk(KERN_INFO ""sit init: Can't add protocol\n""); ++ } + return err; + } + ",1476,1712,2048 +6306,"static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, + u32 exit_intr_info, + unsigned long exit_qualification) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); + u32 vm_inst_error = 0; + + /* trying to cancel vmlaunch/vmresume is a bug */ + WARN_ON_ONCE(vmx->nested.nested_run_pending); + + leave_guest_mode(vcpu); + prepare_vmcs12(vcpu, vmcs12, exit_reason, exit_intr_info, + exit_qualification); + + if (nested_vmx_store_msr(vcpu, vmcs12->vm_exit_msr_store_addr, + vmcs12->vm_exit_msr_store_count)) + nested_vmx_abort(vcpu, VMX_ABORT_SAVE_GUEST_MSR_FAIL); + + if (unlikely(vmx->fail)) + vm_inst_error = vmcs_read32(VM_INSTRUCTION_ERROR); + + vmx_switch_vmcs(vcpu, &vmx->vmcs01); + + /* + * TODO: SDM says that with acknowledge interrupt on exit, bit 31 of + * the VM-exit interrupt information (valid interrupt) is always set to + * 1 on EXIT_REASON_EXTERNAL_INTERRUPT, so we shouldn't need + * kvm_cpu_has_interrupt(). See the commit message for details. + */ + if (nested_exit_intr_ack_set(vcpu) && + exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT && + kvm_cpu_has_interrupt(vcpu)) { + int irq = kvm_cpu_get_interrupt(vcpu); + WARN_ON(irq < 0); + vmcs12->vm_exit_intr_info = irq | + INTR_INFO_VALID_MASK | INTR_TYPE_EXT_INTR; + } + + trace_kvm_nested_vmexit_inject(vmcs12->vm_exit_reason, + vmcs12->exit_qualification, + vmcs12->idt_vectoring_info_field, + vmcs12->vm_exit_intr_info, + vmcs12->vm_exit_intr_error_code, + KVM_ISA_VMX); + + vm_entry_controls_reset_shadow(vmx); + vm_exit_controls_reset_shadow(vmx); + vmx_segment_cache_clear(vmx); + + /* if no vmcs02 cache requested, remove the one we used */ + if (VMCS02_POOL_SIZE == 0) + nested_free_vmcs02(vmx, vmx->nested.current_vmptr); + + load_vmcs12_host_state(vcpu, vmcs12); + + /* Update any VMCS fields that might have changed while L2 ran */ + vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, vmx->msr_autoload.nr); + vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, vmx->msr_autoload.nr); + vmcs_write64(TSC_OFFSET, vcpu->arch.tsc_offset); + if (vmx->hv_deadline_tsc == -1) + vmcs_clear_bits(PIN_BASED_VM_EXEC_CONTROL, + PIN_BASED_VMX_PREEMPTION_TIMER); + else + vmcs_set_bits(PIN_BASED_VM_EXEC_CONTROL, + PIN_BASED_VMX_PREEMPTION_TIMER); + if (kvm_has_tsc_control) + decache_tsc_multiplier(vmx); + + if (vmx->nested.change_vmcs01_virtual_x2apic_mode) { + vmx->nested.change_vmcs01_virtual_x2apic_mode = false; + vmx_set_virtual_x2apic_mode(vcpu, + vcpu->arch.apic_base & X2APIC_ENABLE); + } else if (!nested_cpu_has_ept(vmcs12) && + nested_cpu_has2(vmcs12, + SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) { + vmx_flush_tlb_ept_only(vcpu); + } + + /* This is needed for same reason as it was needed in prepare_vmcs02 */ + vmx->host_rsp = 0; + + /* Unpin physical memory we referred to in vmcs02 */ + if (vmx->nested.apic_access_page) { + kvm_release_page_dirty(vmx->nested.apic_access_page); + vmx->nested.apic_access_page = NULL; + } + if (vmx->nested.virtual_apic_page) { + kvm_release_page_dirty(vmx->nested.virtual_apic_page); + vmx->nested.virtual_apic_page = NULL; + } + if (vmx->nested.pi_desc_page) { + kunmap(vmx->nested.pi_desc_page); + kvm_release_page_dirty(vmx->nested.pi_desc_page); + vmx->nested.pi_desc_page = NULL; + vmx->nested.pi_desc = NULL; + } + + /* + * We are now running in L2, mmu_notifier will force to reload the + * page's hpa for L2 vmcs. Need to reload it for L1 before entering L1. + */ + kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu); + + /* + * Exiting from L2 to L1, we're now back to L1 which thinks it just + * finished a VMLAUNCH or VMRESUME instruction, so we need to set the + * success or failure flag accordingly. + */ + if (unlikely(vmx->fail)) { + vmx->fail = 0; + nested_vmx_failValid(vcpu, vm_inst_error); + } else + nested_vmx_succeed(vcpu); + if (enable_shadow_vmcs) + vmx->nested.sync_shadow_vmcs = true; + + /* in case we halted in L2 */ + vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; +} +",0,"static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, + u32 exit_intr_info, + unsigned long exit_qualification) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); + u32 vm_inst_error = 0; + + /* trying to cancel vmlaunch/vmresume is a bug */ + WARN_ON_ONCE(vmx->nested.nested_run_pending); + + leave_guest_mode(vcpu); + prepare_vmcs12(vcpu, vmcs12, exit_reason, exit_intr_info, + exit_qualification); + + if (nested_vmx_store_msr(vcpu, vmcs12->vm_exit_msr_store_addr, + vmcs12->vm_exit_msr_store_count)) + nested_vmx_abort(vcpu, VMX_ABORT_SAVE_GUEST_MSR_FAIL); + + if (unlikely(vmx->fail)) + vm_inst_error = vmcs_read32(VM_INSTRUCTION_ERROR); + + vmx_switch_vmcs(vcpu, &vmx->vmcs01); + + /* + * TODO: SDM says that with acknowledge interrupt on exit, bit 31 of + * the VM-exit interrupt information (valid interrupt) is always set to + * 1 on EXIT_REASON_EXTERNAL_INTERRUPT, so we shouldn't need + * kvm_cpu_has_interrupt(). See the commit message for details. + */ + if (nested_exit_intr_ack_set(vcpu) && + exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT && + kvm_cpu_has_interrupt(vcpu)) { + int irq = kvm_cpu_get_interrupt(vcpu); + WARN_ON(irq < 0); + vmcs12->vm_exit_intr_info = irq | + INTR_INFO_VALID_MASK | INTR_TYPE_EXT_INTR; + } + + trace_kvm_nested_vmexit_inject(vmcs12->vm_exit_reason, + vmcs12->exit_qualification, + vmcs12->idt_vectoring_info_field, + vmcs12->vm_exit_intr_info, + vmcs12->vm_exit_intr_error_code, + KVM_ISA_VMX); + + vm_entry_controls_reset_shadow(vmx); + vm_exit_controls_reset_shadow(vmx); + vmx_segment_cache_clear(vmx); + + /* if no vmcs02 cache requested, remove the one we used */ + if (VMCS02_POOL_SIZE == 0) + nested_free_vmcs02(vmx, vmx->nested.current_vmptr); + + load_vmcs12_host_state(vcpu, vmcs12); + + /* Update any VMCS fields that might have changed while L2 ran */ + vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, vmx->msr_autoload.nr); + vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, vmx->msr_autoload.nr); + vmcs_write64(TSC_OFFSET, vcpu->arch.tsc_offset); + if (vmx->hv_deadline_tsc == -1) + vmcs_clear_bits(PIN_BASED_VM_EXEC_CONTROL, + PIN_BASED_VMX_PREEMPTION_TIMER); + else + vmcs_set_bits(PIN_BASED_VM_EXEC_CONTROL, + PIN_BASED_VMX_PREEMPTION_TIMER); + if (kvm_has_tsc_control) + decache_tsc_multiplier(vmx); + + if (vmx->nested.change_vmcs01_virtual_x2apic_mode) { + vmx->nested.change_vmcs01_virtual_x2apic_mode = false; + vmx_set_virtual_x2apic_mode(vcpu, + vcpu->arch.apic_base & X2APIC_ENABLE); + } else if (!nested_cpu_has_ept(vmcs12) && + nested_cpu_has2(vmcs12, + SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) { + vmx_flush_tlb_ept_only(vcpu); + } + + /* This is needed for same reason as it was needed in prepare_vmcs02 */ + vmx->host_rsp = 0; + + /* Unpin physical memory we referred to in vmcs02 */ + if (vmx->nested.apic_access_page) { + kvm_release_page_dirty(vmx->nested.apic_access_page); + vmx->nested.apic_access_page = NULL; + } + if (vmx->nested.virtual_apic_page) { + kvm_release_page_dirty(vmx->nested.virtual_apic_page); + vmx->nested.virtual_apic_page = NULL; + } + if (vmx->nested.pi_desc_page) { + kunmap(vmx->nested.pi_desc_page); + kvm_release_page_dirty(vmx->nested.pi_desc_page); + vmx->nested.pi_desc_page = NULL; + vmx->nested.pi_desc = NULL; + } + + /* + * We are now running in L2, mmu_notifier will force to reload the + * page's hpa for L2 vmcs. Need to reload it for L1 before entering L1. + */ + kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu); + + /* + * Exiting from L2 to L1, we're now back to L1 which thinks it just + * finished a VMLAUNCH or VMRESUME instruction, so we need to set the + * success or failure flag accordingly. + */ + if (unlikely(vmx->fail)) { + vmx->fail = 0; + nested_vmx_failValid(vcpu, vm_inst_error); + } else + nested_vmx_succeed(vcpu); + if (enable_shadow_vmcs) + vmx->nested.sync_shadow_vmcs = true; + + /* in case we halted in L2 */ + vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; +} +","@@ -10525,6 +10525,11 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, + if (exec_control & CPU_BASED_TPR_SHADOW) { + vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, -1ull); + vmcs_write32(TPR_THRESHOLD, vmcs12->tpr_threshold); ++ } else { ++#ifdef CONFIG_X86_64 ++ exec_control |= CPU_BASED_CR8_LOAD_EXITING | ++ CPU_BASED_CR8_STORE_EXITING; ++#endif + } + + /*",1221,1457,2048 +3280,"static int ext4_symlink(struct inode *dir, + struct dentry *dentry, const char *symname) +{ + handle_t *handle; + struct inode *inode; + int l, err, retries = 0; + int credits; + + l = strlen(symname)+1; + if (l > dir->i_sb->s_blocksize) + return -ENAMETOOLONG; + + dquot_initialize(dir); + + if (l > EXT4_N_BLOCKS * 4) { + /* + * For non-fast symlinks, we just allocate inode and put it on + * orphan list in the first transaction => we need bitmap, + * group descriptor, sb, inode block, quota blocks, and + * possibly selinux xattr blocks. + */ + credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) + + EXT4_XATTR_TRANS_BLOCKS; + } else { + /* + * Fast symlink. We have to add entry to directory + * (EXT4_DATA_TRANS_BLOCKS + EXT4_INDEX_EXTRA_TRANS_BLOCKS), + * allocate new inode (bitmap, group descriptor, inode block, + * quota blocks, sb is already counted in previous macros). + */ + credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb); + } +retry: + handle = ext4_journal_start(dir, credits); + if (IS_ERR(handle)) + return PTR_ERR(handle); + + if (IS_DIRSYNC(dir)) + ext4_handle_sync(handle); + + inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO, + &dentry->d_name, 0, NULL); + err = PTR_ERR(inode); + if (IS_ERR(inode)) + goto out_stop; + + if (l > EXT4_N_BLOCKS * 4) { + inode->i_op = &ext4_symlink_inode_operations; + ext4_set_aops(inode); + /* + * We cannot call page_symlink() with transaction started + * because it calls into ext4_write_begin() which can wait + * for transaction commit if we are running out of space + * and thus we deadlock. So we have to stop transaction now + * and restart it when symlink contents is written. + * + * To keep fs consistent in case of crash, we have to put inode + * to orphan list in the mean time. + */ + drop_nlink(inode); + err = ext4_orphan_add(handle, inode); + ext4_journal_stop(handle); + if (err) + goto err_drop_inode; + err = __page_symlink(inode, symname, l, 1); + if (err) + goto err_drop_inode; + /* + * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS + * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified + */ + handle = ext4_journal_start(dir, + EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1); + if (IS_ERR(handle)) { + err = PTR_ERR(handle); + goto err_drop_inode; + } + set_nlink(inode, 1); + err = ext4_orphan_del(handle, inode); + if (err) { + ext4_journal_stop(handle); + clear_nlink(inode); + goto err_drop_inode; + } + } else { + /* clear the extent format for fast symlink */ + ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS); + inode->i_op = &ext4_fast_symlink_inode_operations; + memcpy((char *)&EXT4_I(inode)->i_data, symname, l); + inode->i_size = l-1; + } + EXT4_I(inode)->i_disksize = inode->i_size; + err = ext4_add_nondir(handle, dentry, inode); +out_stop: + ext4_journal_stop(handle); + if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) + goto retry; + return err; +err_drop_inode: + unlock_new_inode(inode); + iput(inode); + return err; +} +",0,"static int ext4_symlink(struct inode *dir, + struct dentry *dentry, const char *symname) +{ + handle_t *handle; + struct inode *inode; + int l, err, retries = 0; + int credits; + + l = strlen(symname)+1; + if (l > dir->i_sb->s_blocksize) + return -ENAMETOOLONG; + + dquot_initialize(dir); + + if (l > EXT4_N_BLOCKS * 4) { + /* + * For non-fast symlinks, we just allocate inode and put it on + * orphan list in the first transaction => we need bitmap, + * group descriptor, sb, inode block, quota blocks, and + * possibly selinux xattr blocks. + */ + credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) + + EXT4_XATTR_TRANS_BLOCKS; + } else { + /* + * Fast symlink. We have to add entry to directory + * (EXT4_DATA_TRANS_BLOCKS + EXT4_INDEX_EXTRA_TRANS_BLOCKS), + * allocate new inode (bitmap, group descriptor, inode block, + * quota blocks, sb is already counted in previous macros). + */ + credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb); + } +retry: + handle = ext4_journal_start(dir, credits); + if (IS_ERR(handle)) + return PTR_ERR(handle); + + if (IS_DIRSYNC(dir)) + ext4_handle_sync(handle); + + inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO, + &dentry->d_name, 0, NULL); + err = PTR_ERR(inode); + if (IS_ERR(inode)) + goto out_stop; + + if (l > EXT4_N_BLOCKS * 4) { + inode->i_op = &ext4_symlink_inode_operations; + ext4_set_aops(inode); + /* + * We cannot call page_symlink() with transaction started + * because it calls into ext4_write_begin() which can wait + * for transaction commit if we are running out of space + * and thus we deadlock. So we have to stop transaction now + * and restart it when symlink contents is written. + * + * To keep fs consistent in case of crash, we have to put inode + * to orphan list in the mean time. + */ + drop_nlink(inode); + err = ext4_orphan_add(handle, inode); + ext4_journal_stop(handle); + if (err) + goto err_drop_inode; + err = __page_symlink(inode, symname, l, 1); + if (err) + goto err_drop_inode; + /* + * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS + * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified + */ + handle = ext4_journal_start(dir, + EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1); + if (IS_ERR(handle)) { + err = PTR_ERR(handle); + goto err_drop_inode; + } + set_nlink(inode, 1); + err = ext4_orphan_del(handle, inode); + if (err) { + ext4_journal_stop(handle); + clear_nlink(inode); + goto err_drop_inode; + } + } else { + /* clear the extent format for fast symlink */ + ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS); + inode->i_op = &ext4_fast_symlink_inode_operations; + memcpy((char *)&EXT4_I(inode)->i_data, symname, l); + inode->i_size = l-1; + } + EXT4_I(inode)->i_disksize = inode->i_size; + err = ext4_add_nondir(handle, dentry, inode); +out_stop: + ext4_journal_stop(handle); + if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) + goto retry; + return err; +err_drop_inode: + unlock_new_inode(inode); + iput(inode); + return err; +} +","@@ -2648,7 +2648,8 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) + struct ext4_iloc iloc; + int err = 0; + +- if (!EXT4_SB(inode->i_sb)->s_journal) ++ if ((!EXT4_SB(inode->i_sb)->s_journal) && ++ !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) + return 0; + + mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock);",893,1129,2048 +1934,"int ip_options_compile(struct net *net, + struct ip_options * opt, struct sk_buff * skb) +{ + int l; + unsigned char * iph; + unsigned char * optptr; + int optlen; + unsigned char * pp_ptr = NULL; + struct rtable *rt = NULL; + + if (skb != NULL) { + rt = skb_rtable(skb); + optptr = (unsigned char *)&(ip_hdr(skb)[1]); + } else + optptr = opt->__data; + iph = optptr - sizeof(struct iphdr); + + for (l = opt->optlen; l > 0; ) { + switch (*optptr) { + case IPOPT_END: + for (optptr++, l--; l>0; optptr++, l--) { + if (*optptr != IPOPT_END) { + *optptr = IPOPT_END; + opt->is_changed = 1; + } + } + goto eol; + case IPOPT_NOOP: + l--; + optptr++; + continue; + } + optlen = optptr[1]; + if (optlen<2 || optlen>l) { + pp_ptr = optptr; + goto error; + } + switch (*optptr) { + case IPOPT_SSRR: + case IPOPT_LSRR: + if (optlen < 3) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] < 4) { + pp_ptr = optptr + 2; + goto error; + } + /* NB: cf RFC-1812 5.2.4.1 */ + if (opt->srr) { + pp_ptr = optptr; + goto error; + } + if (!skb) { + if (optptr[2] != 4 || optlen < 7 || ((optlen-3) & 3)) { + pp_ptr = optptr + 1; + goto error; + } + memcpy(&opt->faddr, &optptr[3], 4); + if (optlen > 7) + memmove(&optptr[3], &optptr[7], optlen-7); + } + opt->is_strictroute = (optptr[0] == IPOPT_SSRR); + opt->srr = optptr - iph; + break; + case IPOPT_RR: + if (opt->rr) { + pp_ptr = optptr; + goto error; + } + if (optlen < 3) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] < 4) { + pp_ptr = optptr + 2; + goto error; + } + if (optptr[2] <= optlen) { + if (optptr[2]+3 > optlen) { + pp_ptr = optptr + 2; + goto error; + } + if (rt) { + memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); + opt->is_changed = 1; + } + optptr[2] += 4; + opt->rr_needaddr = 1; + } + opt->rr = optptr - iph; + break; + case IPOPT_TIMESTAMP: + if (opt->ts) { + pp_ptr = optptr; + goto error; + } + if (optlen < 4) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] < 5) { + pp_ptr = optptr + 2; + goto error; + } + if (optptr[2] <= optlen) { + __be32 *timeptr = NULL; + if (optptr[2]+3 > optptr[1]) { + pp_ptr = optptr + 2; + goto error; + } + switch (optptr[3]&0xF) { + case IPOPT_TS_TSONLY: + opt->ts = optptr - iph; + if (skb) + timeptr = (__be32*)&optptr[optptr[2]-1]; + opt->ts_needtime = 1; + optptr[2] += 4; + break; + case IPOPT_TS_TSANDADDR: + if (optptr[2]+7 > optptr[1]) { + pp_ptr = optptr + 2; + goto error; + } + opt->ts = optptr - iph; + if (rt) { + memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); + timeptr = (__be32*)&optptr[optptr[2]+3]; + } + opt->ts_needaddr = 1; + opt->ts_needtime = 1; + optptr[2] += 8; + break; + case IPOPT_TS_PRESPEC: + if (optptr[2]+7 > optptr[1]) { + pp_ptr = optptr + 2; + goto error; + } + opt->ts = optptr - iph; + { + __be32 addr; + memcpy(&addr, &optptr[optptr[2]-1], 4); + if (inet_addr_type(net, addr) == RTN_UNICAST) + break; + if (skb) + timeptr = (__be32*)&optptr[optptr[2]+3]; + } + opt->ts_needtime = 1; + optptr[2] += 8; + break; + default: + if (!skb && !capable(CAP_NET_RAW)) { + pp_ptr = optptr + 3; + goto error; + } + break; + } + if (timeptr) { + struct timespec tv; + __be32 midtime; + getnstimeofday(&tv); + midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC); + memcpy(timeptr, &midtime, sizeof(__be32)); + opt->is_changed = 1; + } + } else { + unsigned overflow = optptr[3]>>4; + if (overflow == 15) { + pp_ptr = optptr + 3; + goto error; + } + opt->ts = optptr - iph; + if (skb) { + optptr[3] = (optptr[3]&0xF)|((overflow+1)<<4); + opt->is_changed = 1; + } + } + break; + case IPOPT_RA: + if (optlen < 4) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] == 0 && optptr[3] == 0) + opt->router_alert = optptr - iph; + break; + case IPOPT_CIPSO: + if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) { + pp_ptr = optptr; + goto error; + } + opt->cipso = optptr - iph; + if (cipso_v4_validate(skb, &optptr)) { + pp_ptr = optptr; + goto error; + } + break; + case IPOPT_SEC: + case IPOPT_SID: + default: + if (!skb && !capable(CAP_NET_RAW)) { + pp_ptr = optptr; + goto error; + } + break; + } + l -= optlen; + optptr += optlen; + } + +eol: + if (!pp_ptr) + return 0; + +error: + if (skb) { + icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((pp_ptr-iph)<<24)); + } + return -EINVAL; +} +",0,"int ip_options_compile(struct net *net, + struct ip_options * opt, struct sk_buff * skb) +{ + int l; + unsigned char * iph; + unsigned char * optptr; + int optlen; + unsigned char * pp_ptr = NULL; + struct rtable *rt = NULL; + + if (skb != NULL) { + rt = skb_rtable(skb); + optptr = (unsigned char *)&(ip_hdr(skb)[1]); + } else + optptr = opt->__data; + iph = optptr - sizeof(struct iphdr); + + for (l = opt->optlen; l > 0; ) { + switch (*optptr) { + case IPOPT_END: + for (optptr++, l--; l>0; optptr++, l--) { + if (*optptr != IPOPT_END) { + *optptr = IPOPT_END; + opt->is_changed = 1; + } + } + goto eol; + case IPOPT_NOOP: + l--; + optptr++; + continue; + } + optlen = optptr[1]; + if (optlen<2 || optlen>l) { + pp_ptr = optptr; + goto error; + } + switch (*optptr) { + case IPOPT_SSRR: + case IPOPT_LSRR: + if (optlen < 3) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] < 4) { + pp_ptr = optptr + 2; + goto error; + } + /* NB: cf RFC-1812 5.2.4.1 */ + if (opt->srr) { + pp_ptr = optptr; + goto error; + } + if (!skb) { + if (optptr[2] != 4 || optlen < 7 || ((optlen-3) & 3)) { + pp_ptr = optptr + 1; + goto error; + } + memcpy(&opt->faddr, &optptr[3], 4); + if (optlen > 7) + memmove(&optptr[3], &optptr[7], optlen-7); + } + opt->is_strictroute = (optptr[0] == IPOPT_SSRR); + opt->srr = optptr - iph; + break; + case IPOPT_RR: + if (opt->rr) { + pp_ptr = optptr; + goto error; + } + if (optlen < 3) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] < 4) { + pp_ptr = optptr + 2; + goto error; + } + if (optptr[2] <= optlen) { + if (optptr[2]+3 > optlen) { + pp_ptr = optptr + 2; + goto error; + } + if (rt) { + memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); + opt->is_changed = 1; + } + optptr[2] += 4; + opt->rr_needaddr = 1; + } + opt->rr = optptr - iph; + break; + case IPOPT_TIMESTAMP: + if (opt->ts) { + pp_ptr = optptr; + goto error; + } + if (optlen < 4) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] < 5) { + pp_ptr = optptr + 2; + goto error; + } + if (optptr[2] <= optlen) { + __be32 *timeptr = NULL; + if (optptr[2]+3 > optptr[1]) { + pp_ptr = optptr + 2; + goto error; + } + switch (optptr[3]&0xF) { + case IPOPT_TS_TSONLY: + opt->ts = optptr - iph; + if (skb) + timeptr = (__be32*)&optptr[optptr[2]-1]; + opt->ts_needtime = 1; + optptr[2] += 4; + break; + case IPOPT_TS_TSANDADDR: + if (optptr[2]+7 > optptr[1]) { + pp_ptr = optptr + 2; + goto error; + } + opt->ts = optptr - iph; + if (rt) { + memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); + timeptr = (__be32*)&optptr[optptr[2]+3]; + } + opt->ts_needaddr = 1; + opt->ts_needtime = 1; + optptr[2] += 8; + break; + case IPOPT_TS_PRESPEC: + if (optptr[2]+7 > optptr[1]) { + pp_ptr = optptr + 2; + goto error; + } + opt->ts = optptr - iph; + { + __be32 addr; + memcpy(&addr, &optptr[optptr[2]-1], 4); + if (inet_addr_type(net, addr) == RTN_UNICAST) + break; + if (skb) + timeptr = (__be32*)&optptr[optptr[2]+3]; + } + opt->ts_needtime = 1; + optptr[2] += 8; + break; + default: + if (!skb && !capable(CAP_NET_RAW)) { + pp_ptr = optptr + 3; + goto error; + } + break; + } + if (timeptr) { + struct timespec tv; + __be32 midtime; + getnstimeofday(&tv); + midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC); + memcpy(timeptr, &midtime, sizeof(__be32)); + opt->is_changed = 1; + } + } else { + unsigned overflow = optptr[3]>>4; + if (overflow == 15) { + pp_ptr = optptr + 3; + goto error; + } + opt->ts = optptr - iph; + if (skb) { + optptr[3] = (optptr[3]&0xF)|((overflow+1)<<4); + opt->is_changed = 1; + } + } + break; + case IPOPT_RA: + if (optlen < 4) { + pp_ptr = optptr + 1; + goto error; + } + if (optptr[2] == 0 && optptr[3] == 0) + opt->router_alert = optptr - iph; + break; + case IPOPT_CIPSO: + if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) { + pp_ptr = optptr; + goto error; + } + opt->cipso = optptr - iph; + if (cipso_v4_validate(skb, &optptr)) { + pp_ptr = optptr; + goto error; + } + break; + case IPOPT_SEC: + case IPOPT_SID: + default: + if (!skb && !capable(CAP_NET_RAW)) { + pp_ptr = optptr; + goto error; + } + break; + } + l -= optlen; + optptr += optlen; + } + +eol: + if (!pp_ptr) + return 0; + +error: + if (skb) { + icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((pp_ptr-iph)<<24)); + } + return -EINVAL; +} +","@@ -36,7 +36,7 @@ + * saddr is address of outgoing interface. + */ + +-void ip_options_build(struct sk_buff * skb, struct ip_options * opt, ++void ip_options_build(struct sk_buff *skb, struct ip_options *opt, + __be32 daddr, struct rtable *rt, int is_frag) + { + unsigned char *iph = skb_network_header(skb); +@@ -83,9 +83,9 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt, + * NOTE: dopt cannot point to skb. + */ + +-int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) ++int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb) + { +- struct ip_options *sopt; ++ const struct ip_options *sopt; + unsigned char *sptr, *dptr; + int soffset, doffset; + int optlen; +@@ -95,10 +95,8 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) + + sopt = &(IPCB(skb)->opt); + +- if (sopt->optlen == 0) { +- dopt->optlen = 0; ++ if (sopt->optlen == 0) + return 0; +- } + + sptr = skb_network_header(skb); + dptr = dopt->__data; +@@ -157,7 +155,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) + dopt->optlen += optlen; + } + if (sopt->srr) { +- unsigned char * start = sptr+sopt->srr; ++ unsigned char *start = sptr+sopt->srr; + __be32 faddr; + + optlen = start[1]; +@@ -499,19 +497,19 @@ void ip_options_undo(struct ip_options * opt) + } + } + +-static struct ip_options *ip_options_get_alloc(const int optlen) ++static struct ip_options_rcu *ip_options_get_alloc(const int optlen) + { +- return kzalloc(sizeof(struct ip_options) + ((optlen + 3) & ~3), ++ return kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3), + GFP_KERNEL); + } + +-static int ip_options_get_finish(struct net *net, struct ip_options **optp, +- struct ip_options *opt, int optlen) ++static int ip_options_get_finish(struct net *net, struct ip_options_rcu **optp, ++ struct ip_options_rcu *opt, int optlen) + { + while (optlen & 3) +- opt->__data[optlen++] = IPOPT_END; +- opt->optlen = optlen; +- if (optlen && ip_options_compile(net, opt, NULL)) { ++ opt->opt.__data[optlen++] = IPOPT_END; ++ opt->opt.optlen = optlen; ++ if (optlen && ip_options_compile(net, &opt->opt, NULL)) { + kfree(opt); + return -EINVAL; + } +@@ -520,29 +518,29 @@ static int ip_options_get_finish(struct net *net, struct ip_options **optp, + return 0; + } + +-int ip_options_get_from_user(struct net *net, struct ip_options **optp, ++int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, + unsigned char __user *data, int optlen) + { +- struct ip_options *opt = ip_options_get_alloc(optlen); ++ struct ip_options_rcu *opt = ip_options_get_alloc(optlen); + + if (!opt) + return -ENOMEM; +- if (optlen && copy_from_user(opt->__data, data, optlen)) { ++ if (optlen && copy_from_user(opt->opt.__data, data, optlen)) { + kfree(opt); + return -EFAULT; + } + return ip_options_get_finish(net, optp, opt, optlen); + } + +-int ip_options_get(struct net *net, struct ip_options **optp, ++int ip_options_get(struct net *net, struct ip_options_rcu **optp, + unsigned char *data, int optlen) + { +- struct ip_options *opt = ip_options_get_alloc(optlen); ++ struct ip_options_rcu *opt = ip_options_get_alloc(optlen); + + if (!opt) + return -ENOMEM; + if (optlen) +- memcpy(opt->__data, data, optlen); ++ memcpy(opt->opt.__data, data, optlen); + return ip_options_get_finish(net, optp, opt, optlen); + } + ",1732,1968,2048 +16452,"ExtensionFunction::ResponseAction WindowsCreateFunction::Run() { + std::unique_ptr params( + windows::Create::Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + std::vector urls; + TabStripModel* source_tab_strip = NULL; + int tab_index = -1; + + windows::Create::Params::CreateData* create_data = params->create_data.get(); + + if (create_data && create_data->url) { + std::vector url_strings; + if (create_data->url->as_string) + url_strings.push_back(*create_data->url->as_string); + else if (create_data->url->as_strings) + url_strings.swap(*create_data->url->as_strings); + + for (auto i = url_strings.begin(); i != url_strings.end(); ++i) { + GURL url = ExtensionTabUtil::ResolvePossiblyRelativeURL(*i, extension()); + if (!url.is_valid()) + return RespondNow(Error(tabs_constants::kInvalidUrlError, *i)); + if (ExtensionTabUtil::IsKillURL(url)) + return RespondNow(Error(tabs_constants::kNoCrashBrowserError)); + urls.push_back(url); + } + } + + std::string error; + bool open_incognito_window = + ShouldOpenIncognitoWindow(create_data, &urls, &error); + if (!error.empty()) + return RespondNow(Error(error)); + + Profile* calling_profile = Profile::FromBrowserContext(browser_context()); + Profile* window_profile = open_incognito_window + ? calling_profile->GetOffTheRecordProfile() + : calling_profile; + + if (create_data && create_data->tab_id) { + Browser* source_browser = nullptr; + if (!GetTabById(*create_data->tab_id, calling_profile, + include_incognito_information(), &source_browser, + &source_tab_strip, nullptr, &tab_index, &error)) { + return RespondNow(Error(error)); + } + + if (!source_browser->window()->IsTabStripEditable()) + return RespondNow(Error(tabs_constants::kTabStripNotEditableError)); + + if (source_browser->profile() != window_profile) + return RespondNow( + Error(tabs_constants::kCanOnlyMoveTabsWithinSameProfileError)); + } + + if (!IsValidStateForWindowsCreateFunction(create_data)) + return RespondNow(Error(tabs_constants::kInvalidWindowStateError)); + + Browser::Type window_type = Browser::TYPE_TABBED; + + gfx::Rect window_bounds; + bool focused = true; + std::string extension_id; + + if (create_data) { + ReportRequestedWindowState(create_data->state); + + switch (create_data->type) { + case windows::CREATE_TYPE_PANEL: + case windows::CREATE_TYPE_POPUP: + window_type = Browser::TYPE_POPUP; + extension_id = extension()->id(); + break; + case windows::CREATE_TYPE_NONE: + case windows::CREATE_TYPE_NORMAL: + break; + default: + return RespondNow(Error(tabs_constants::kInvalidWindowTypeError)); + } + + if (window_type == Browser::TYPE_TABBED || + window_type == Browser::TYPE_POPUP) { + ui::WindowShowState ignored_show_state = ui::SHOW_STATE_DEFAULT; + WindowSizer::GetBrowserWindowBoundsAndShowState( + std::string(), gfx::Rect(), nullptr, &window_bounds, + &ignored_show_state); + } + + if (create_data->left) + window_bounds.set_x(*create_data->left); + + if (create_data->top) + window_bounds.set_y(*create_data->top); + + if (create_data->width) + window_bounds.set_width(*create_data->width); + + if (create_data->height) + window_bounds.set_height(*create_data->height); + + if (create_data->focused) + focused = *create_data->focused; + } + + Browser::CreateParams create_params(window_type, window_profile, + user_gesture()); + if (extension_id.empty()) { + create_params.initial_bounds = window_bounds; + } else { + create_params = Browser::CreateParams::CreateForApp( + web_app::GenerateApplicationNameFromAppId(extension_id), + false /* trusted_source */, window_bounds, window_profile, + user_gesture()); + } + create_params.initial_show_state = ui::SHOW_STATE_NORMAL; + if (create_data && create_data->state) { + if (create_data->state == windows::WINDOW_STATE_LOCKED_FULLSCREEN && + !ExtensionHasLockedFullscreenPermission(extension())) { + return RespondNow( + Error(tabs_constants::kMissingLockWindowFullscreenPrivatePermission)); + } + create_params.initial_show_state = + ConvertToWindowShowState(create_data->state); + } + + Browser* new_window = new Browser(create_params); + + for (const GURL& url : urls) { + NavigateParams navigate_params(new_window, url, ui::PAGE_TRANSITION_LINK); + navigate_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; + + bool set_self_as_opener = create_data->set_self_as_opener && // present? + *create_data->set_self_as_opener; // set to true? + navigate_params.opener = set_self_as_opener ? render_frame_host() : nullptr; + navigate_params.source_site_instance = + render_frame_host()->GetSiteInstance(); + + Navigate(&navigate_params); + } + + WebContents* contents = NULL; + if ((window_type == Browser::TYPE_POPUP && urls.empty()) || + window_type == Browser::TYPE_TABBED) { + if (source_tab_strip) { + std::unique_ptr detached_tab = + source_tab_strip->DetachWebContentsAt(tab_index); + contents = detached_tab.get(); + TabStripModel* target_tab_strip = new_window->tab_strip_model(); + target_tab_strip->InsertWebContentsAt( + urls.size(), std::move(detached_tab), TabStripModel::ADD_NONE); + } + } + if (!contents && urls.empty() && window_type != Browser::TYPE_POPUP) { + chrome::NewTab(new_window); + } + chrome::SelectNumberedTab(new_window, 0); + + if (focused) + new_window->window()->Show(); + else + new_window->window()->ShowInactive(); + +#if defined(OS_CHROMEOS) + if (create_data && + create_data->state == windows::WINDOW_STATE_LOCKED_FULLSCREEN) { + SetLockedFullscreenState(new_window, true); + } +#endif + + std::unique_ptr result; + if (new_window->profile()->IsOffTheRecord() && + !browser_context()->IsOffTheRecord() && + !include_incognito_information()) { + result = std::make_unique(); + } else { + result = ExtensionTabUtil::CreateWindowValueForExtension( + *new_window, extension(), ExtensionTabUtil::kPopulateTabs); + } + + return RespondNow(OneArgument(std::move(result))); +} +",0,"ExtensionFunction::ResponseAction WindowsCreateFunction::Run() { + std::unique_ptr params( + windows::Create::Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params); + std::vector urls; + TabStripModel* source_tab_strip = NULL; + int tab_index = -1; + + windows::Create::Params::CreateData* create_data = params->create_data.get(); + + if (create_data && create_data->url) { + std::vector url_strings; + if (create_data->url->as_string) + url_strings.push_back(*create_data->url->as_string); + else if (create_data->url->as_strings) + url_strings.swap(*create_data->url->as_strings); + + for (auto i = url_strings.begin(); i != url_strings.end(); ++i) { + GURL url = ExtensionTabUtil::ResolvePossiblyRelativeURL(*i, extension()); + if (!url.is_valid()) + return RespondNow(Error(tabs_constants::kInvalidUrlError, *i)); + if (ExtensionTabUtil::IsKillURL(url)) + return RespondNow(Error(tabs_constants::kNoCrashBrowserError)); + urls.push_back(url); + } + } + + std::string error; + bool open_incognito_window = + ShouldOpenIncognitoWindow(create_data, &urls, &error); + if (!error.empty()) + return RespondNow(Error(error)); + + Profile* calling_profile = Profile::FromBrowserContext(browser_context()); + Profile* window_profile = open_incognito_window + ? calling_profile->GetOffTheRecordProfile() + : calling_profile; + + if (create_data && create_data->tab_id) { + Browser* source_browser = nullptr; + if (!GetTabById(*create_data->tab_id, calling_profile, + include_incognito_information(), &source_browser, + &source_tab_strip, nullptr, &tab_index, &error)) { + return RespondNow(Error(error)); + } + + if (!source_browser->window()->IsTabStripEditable()) + return RespondNow(Error(tabs_constants::kTabStripNotEditableError)); + + if (source_browser->profile() != window_profile) + return RespondNow( + Error(tabs_constants::kCanOnlyMoveTabsWithinSameProfileError)); + } + + if (!IsValidStateForWindowsCreateFunction(create_data)) + return RespondNow(Error(tabs_constants::kInvalidWindowStateError)); + + Browser::Type window_type = Browser::TYPE_TABBED; + + gfx::Rect window_bounds; + bool focused = true; + std::string extension_id; + + if (create_data) { + ReportRequestedWindowState(create_data->state); + + switch (create_data->type) { + case windows::CREATE_TYPE_PANEL: + case windows::CREATE_TYPE_POPUP: + window_type = Browser::TYPE_POPUP; + extension_id = extension()->id(); + break; + case windows::CREATE_TYPE_NONE: + case windows::CREATE_TYPE_NORMAL: + break; + default: + return RespondNow(Error(tabs_constants::kInvalidWindowTypeError)); + } + + if (window_type == Browser::TYPE_TABBED || + window_type == Browser::TYPE_POPUP) { + ui::WindowShowState ignored_show_state = ui::SHOW_STATE_DEFAULT; + WindowSizer::GetBrowserWindowBoundsAndShowState( + std::string(), gfx::Rect(), nullptr, &window_bounds, + &ignored_show_state); + } + + if (create_data->left) + window_bounds.set_x(*create_data->left); + + if (create_data->top) + window_bounds.set_y(*create_data->top); + + if (create_data->width) + window_bounds.set_width(*create_data->width); + + if (create_data->height) + window_bounds.set_height(*create_data->height); + + if (create_data->focused) + focused = *create_data->focused; + } + + Browser::CreateParams create_params(window_type, window_profile, + user_gesture()); + if (extension_id.empty()) { + create_params.initial_bounds = window_bounds; + } else { + create_params = Browser::CreateParams::CreateForApp( + web_app::GenerateApplicationNameFromAppId(extension_id), + false /* trusted_source */, window_bounds, window_profile, + user_gesture()); + } + create_params.initial_show_state = ui::SHOW_STATE_NORMAL; + if (create_data && create_data->state) { + if (create_data->state == windows::WINDOW_STATE_LOCKED_FULLSCREEN && + !ExtensionHasLockedFullscreenPermission(extension())) { + return RespondNow( + Error(tabs_constants::kMissingLockWindowFullscreenPrivatePermission)); + } + create_params.initial_show_state = + ConvertToWindowShowState(create_data->state); + } + + Browser* new_window = new Browser(create_params); + + for (const GURL& url : urls) { + NavigateParams navigate_params(new_window, url, ui::PAGE_TRANSITION_LINK); + navigate_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; + + bool set_self_as_opener = create_data->set_self_as_opener && // present? + *create_data->set_self_as_opener; // set to true? + navigate_params.opener = set_self_as_opener ? render_frame_host() : nullptr; + navigate_params.source_site_instance = + render_frame_host()->GetSiteInstance(); + + Navigate(&navigate_params); + } + + WebContents* contents = NULL; + if ((window_type == Browser::TYPE_POPUP && urls.empty()) || + window_type == Browser::TYPE_TABBED) { + if (source_tab_strip) { + std::unique_ptr detached_tab = + source_tab_strip->DetachWebContentsAt(tab_index); + contents = detached_tab.get(); + TabStripModel* target_tab_strip = new_window->tab_strip_model(); + target_tab_strip->InsertWebContentsAt( + urls.size(), std::move(detached_tab), TabStripModel::ADD_NONE); + } + } + if (!contents && urls.empty() && window_type != Browser::TYPE_POPUP) { + chrome::NewTab(new_window); + } + chrome::SelectNumberedTab(new_window, 0); + + if (focused) + new_window->window()->Show(); + else + new_window->window()->ShowInactive(); + +#if defined(OS_CHROMEOS) + if (create_data && + create_data->state == windows::WINDOW_STATE_LOCKED_FULLSCREEN) { + SetLockedFullscreenState(new_window, true); + } +#endif + + std::unique_ptr result; + if (new_window->profile()->IsOffTheRecord() && + !browser_context()->IsOffTheRecord() && + !include_incognito_information()) { + result = std::make_unique(); + } else { + result = ExtensionTabUtil::CreateWindowValueForExtension( + *new_window, extension(), ExtensionTabUtil::kPopulateTabs); + } + + return RespondNow(OneArgument(std::move(result))); +} +","@@ -1712,7 +1712,8 @@ WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID( + + if (!extension()->permissions_data()->CanCaptureVisiblePage( + contents->GetLastCommittedURL(), +- SessionTabHelper::IdForTab(contents).id(), error)) { ++ SessionTabHelper::IdForTab(contents).id(), error, ++ extensions::CaptureRequirement::kActiveTabOrAllUrls)) { + return nullptr; + } + return contents;",1460,1696,2048 +18022,"static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, int *fmt, int *ncx, int *ncy, t_chunk_info ** chunkIdx) +{ + int i; + int ch; + char id[5]; + t_chunk_info *cidx; + int sidx; + int nc; + + GD2_DBG(php_gd_error(""Reading gd2 header info"")); + + for (i = 0; i < 4; i++) { + ch = gdGetC(in); + if (ch == EOF) { + goto fail1; + } + id[i] = ch; + } + id[4] = 0; + + GD2_DBG(php_gd_error(""Got file code: %s"", id)); + + /* Equiv. of 'magick'. */ + if (strcmp(id, GD2_ID) != 0) { + GD2_DBG(php_gd_error(""Not a valid gd2 file"")); + goto fail1; + } + + /* Version */ + if (gdGetWord(vers, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""Version: %d"", *vers)); + + if ((*vers != 1) && (*vers != 2)) { + GD2_DBG(php_gd_error(""Bad version: %d"", *vers)); + goto fail1; + } + + /* Image Size */ + if (!gdGetWord(sx, in)) { + GD2_DBG(php_gd_error(""Could not get x-size"")); + goto fail1; + } + if (!gdGetWord(sy, in)) { + GD2_DBG(php_gd_error(""Could not get y-size"")); + goto fail1; + } + GD2_DBG(php_gd_error(""Image is %dx%d"", *sx, *sy)); + + /* Chunk Size (pixels, not bytes!) */ + if (gdGetWord(cs, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""ChunkSize: %d"", *cs)); + + if ((*cs < GD2_CHUNKSIZE_MIN) || (*cs > GD2_CHUNKSIZE_MAX)) { + GD2_DBG(php_gd_error(""Bad chunk size: %d"", *cs)); + goto fail1; + } + + /* Data Format */ + if (gdGetWord(fmt, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""Format: %d"", *fmt)); + + if ((*fmt != GD2_FMT_RAW) && (*fmt != GD2_FMT_COMPRESSED) && (*fmt != GD2_FMT_TRUECOLOR_RAW) && (*fmt != GD2_FMT_TRUECOLOR_COMPRESSED)) { + GD2_DBG(php_gd_error(""Bad data format: %d"", *fmt)); + goto fail1; + } + + /* # of chunks wide */ + if (gdGetWord(ncx, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""%d Chunks Wide"", *ncx)); + + /* # of chunks high */ + if (gdGetWord(ncy, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""%d Chunks vertically"", *ncy)); + + if (gd2_compressed(*fmt)) { + nc = (*ncx) * (*ncy); + GD2_DBG(php_gd_error(""Reading %d chunk index entries"", nc)); + sidx = sizeof(t_chunk_info) * nc; + if (sidx <= 0) { + goto fail1; + } + cidx = gdCalloc(sidx, 1); + for (i = 0; i < nc; i++) { + if (gdGetInt(&cidx[i].offset, in) != 1) { + gdFree(cidx); + goto fail1; + } + if (gdGetInt(&cidx[i].size, in) != 1) { + gdFree(cidx); + goto fail1; + } + if (cidx[i].offset < 0 || cidx[i].size < 0) { + gdFree(cidx); + goto fail1; + } + } + *chunkIdx = cidx; + } + + GD2_DBG(php_gd_error(""gd2 header complete"")); + + return 1; + +fail1: + return 0; +} +",1,"static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, int *fmt, int *ncx, int *ncy, t_chunk_info ** chunkIdx) +{ + int i; + int ch; + char id[5]; + t_chunk_info *cidx; + int sidx; + int nc; + + GD2_DBG(php_gd_error(""Reading gd2 header info"")); + + for (i = 0; i < 4; i++) { + ch = gdGetC(in); + if (ch == EOF) { + goto fail1; + } + id[i] = ch; + } + id[4] = 0; + + GD2_DBG(php_gd_error(""Got file code: %s"", id)); + + /* Equiv. of 'magick'. */ + if (strcmp(id, GD2_ID) != 0) { + GD2_DBG(php_gd_error(""Not a valid gd2 file"")); + goto fail1; + } + + /* Version */ + if (gdGetWord(vers, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""Version: %d"", *vers)); + + if ((*vers != 1) && (*vers != 2)) { + GD2_DBG(php_gd_error(""Bad version: %d"", *vers)); + goto fail1; + } + + /* Image Size */ + if (!gdGetWord(sx, in)) { + GD2_DBG(php_gd_error(""Could not get x-size"")); + goto fail1; + } + if (!gdGetWord(sy, in)) { + GD2_DBG(php_gd_error(""Could not get y-size"")); + goto fail1; + } + GD2_DBG(php_gd_error(""Image is %dx%d"", *sx, *sy)); + + /* Chunk Size (pixels, not bytes!) */ + if (gdGetWord(cs, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""ChunkSize: %d"", *cs)); + + if ((*cs < GD2_CHUNKSIZE_MIN) || (*cs > GD2_CHUNKSIZE_MAX)) { + GD2_DBG(php_gd_error(""Bad chunk size: %d"", *cs)); + goto fail1; + } + + /* Data Format */ + if (gdGetWord(fmt, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""Format: %d"", *fmt)); + + if ((*fmt != GD2_FMT_RAW) && (*fmt != GD2_FMT_COMPRESSED) && (*fmt != GD2_FMT_TRUECOLOR_RAW) && (*fmt != GD2_FMT_TRUECOLOR_COMPRESSED)) { + GD2_DBG(php_gd_error(""Bad data format: %d"", *fmt)); + goto fail1; + } + + /* # of chunks wide */ + if (gdGetWord(ncx, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""%d Chunks Wide"", *ncx)); + + /* # of chunks high */ + if (gdGetWord(ncy, in) != 1) { + goto fail1; + } + GD2_DBG(php_gd_error(""%d Chunks vertically"", *ncy)); + + if (gd2_compressed(*fmt)) { + nc = (*ncx) * (*ncy); + GD2_DBG(php_gd_error(""Reading %d chunk index entries"", nc)); + if (overflow2(sidx, nc)) { + goto fail1; + } + sidx = sizeof(t_chunk_info) * nc; + if (sidx <= 0) { + goto fail1; + } + cidx = gdCalloc(sidx, 1); + if (cidx == NULL) { + goto fail1; + } + + for (i = 0; i < nc; i++) { + if (gdGetInt(&cidx[i].offset, in) != 1) { + gdFree(cidx); + goto fail1; + } + if (gdGetInt(&cidx[i].size, in) != 1) { + gdFree(cidx); + goto fail1; + } + if (cidx[i].offset < 0 || cidx[i].size < 0) { + gdFree(cidx); + goto fail1; + } + } + *chunkIdx = cidx; + } + + GD2_DBG(php_gd_error(""gd2 header complete"")); + + return 1; + +fail1: + return 0; +} +","@@ -138,11 +138,18 @@ static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, in + if (gd2_compressed(*fmt)) { + nc = (*ncx) * (*ncy); + GD2_DBG(php_gd_error(""Reading %d chunk index entries"", nc)); ++ if (overflow2(sidx, nc)) { ++ goto fail1; ++ } + sidx = sizeof(t_chunk_info) * nc; + if (sidx <= 0) { + goto fail1; + } + cidx = gdCalloc(sidx, 1); ++ if (cidx == NULL) { ++ goto fail1; ++ } ++ + for (i = 0; i < nc; i++) { + if (gdGetInt(&cidx[i].offset, in) != 1) { + gdFree(cidx);",958,1194,2048 +2889,"static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s) +{ + Jpeg2000CodingStyle *codsty = s->codsty; + Jpeg2000QuantStyle *qntsty = s->qntsty; + uint8_t *properties = s->properties; + + for (;;) { + int len, ret = 0; + uint16_t marker; + int oldpos; + + if (bytestream2_get_bytes_left(&s->g) < 2) { + av_log(s->avctx, AV_LOG_ERROR, ""Missing EOC\n""); + break; + } + + marker = bytestream2_get_be16u(&s->g); + oldpos = bytestream2_tell(&s->g); + + if (marker == JPEG2000_SOD) { + Jpeg2000Tile *tile; + Jpeg2000TilePart *tp; + + if (s->curtileno < 0) { + av_log(s->avctx, AV_LOG_ERROR, ""Missing SOT\n""); + return AVERROR_INVALIDDATA; + } + + tile = s->tile + s->curtileno; + tp = tile->tile_part + tile->tp_idx; + if (tp->tp_end < s->g.buffer) { + av_log(s->avctx, AV_LOG_ERROR, ""Invalid tpend\n""); + return AVERROR_INVALIDDATA; + } + bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_end - s->g.buffer); + bytestream2_skip(&s->g, tp->tp_end - s->g.buffer); + + continue; + } + if (marker == JPEG2000_EOC) + break; + + len = bytestream2_get_be16(&s->g); + if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) + return AVERROR_INVALIDDATA; + + switch (marker) { + case JPEG2000_SIZ: + ret = get_siz(s); + if (!s->tile) + s->numXtiles = s->numYtiles = 0; + break; + case JPEG2000_COC: + ret = get_coc(s, codsty, properties); + break; + case JPEG2000_COD: + ret = get_cod(s, codsty, properties); + break; + case JPEG2000_QCC: + ret = get_qcc(s, len, qntsty, properties); + break; + case JPEG2000_QCD: + ret = get_qcd(s, len, qntsty, properties); + break; + case JPEG2000_SOT: + if (!(ret = get_sot(s, len))) { + av_assert1(s->curtileno >= 0); + codsty = s->tile[s->curtileno].codsty; + qntsty = s->tile[s->curtileno].qntsty; + properties = s->tile[s->curtileno].properties; + } + break; + case JPEG2000_COM: + bytestream2_skip(&s->g, len - 2); + break; + case JPEG2000_TLM: + ret = get_tlm(s, len); + break; + default: + av_log(s->avctx, AV_LOG_ERROR, + ""unsupported marker 0x%.4X at pos 0x%X\n"", + marker, bytestream2_tell(&s->g) - 4); + bytestream2_skip(&s->g, len - 2); + break; + } + if (bytestream2_tell(&s->g) - oldpos != len || ret) { + av_log(s->avctx, AV_LOG_ERROR, + ""error during processing marker segment %.4x\n"", marker); + return ret ? ret : -1; + } + } + return 0; +} +",0,"static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s) +{ + Jpeg2000CodingStyle *codsty = s->codsty; + Jpeg2000QuantStyle *qntsty = s->qntsty; + uint8_t *properties = s->properties; + + for (;;) { + int len, ret = 0; + uint16_t marker; + int oldpos; + + if (bytestream2_get_bytes_left(&s->g) < 2) { + av_log(s->avctx, AV_LOG_ERROR, ""Missing EOC\n""); + break; + } + + marker = bytestream2_get_be16u(&s->g); + oldpos = bytestream2_tell(&s->g); + + if (marker == JPEG2000_SOD) { + Jpeg2000Tile *tile; + Jpeg2000TilePart *tp; + + if (s->curtileno < 0) { + av_log(s->avctx, AV_LOG_ERROR, ""Missing SOT\n""); + return AVERROR_INVALIDDATA; + } + + tile = s->tile + s->curtileno; + tp = tile->tile_part + tile->tp_idx; + if (tp->tp_end < s->g.buffer) { + av_log(s->avctx, AV_LOG_ERROR, ""Invalid tpend\n""); + return AVERROR_INVALIDDATA; + } + bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_end - s->g.buffer); + bytestream2_skip(&s->g, tp->tp_end - s->g.buffer); + + continue; + } + if (marker == JPEG2000_EOC) + break; + + len = bytestream2_get_be16(&s->g); + if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) + return AVERROR_INVALIDDATA; + + switch (marker) { + case JPEG2000_SIZ: + ret = get_siz(s); + if (!s->tile) + s->numXtiles = s->numYtiles = 0; + break; + case JPEG2000_COC: + ret = get_coc(s, codsty, properties); + break; + case JPEG2000_COD: + ret = get_cod(s, codsty, properties); + break; + case JPEG2000_QCC: + ret = get_qcc(s, len, qntsty, properties); + break; + case JPEG2000_QCD: + ret = get_qcd(s, len, qntsty, properties); + break; + case JPEG2000_SOT: + if (!(ret = get_sot(s, len))) { + av_assert1(s->curtileno >= 0); + codsty = s->tile[s->curtileno].codsty; + qntsty = s->tile[s->curtileno].qntsty; + properties = s->tile[s->curtileno].properties; + } + break; + case JPEG2000_COM: + bytestream2_skip(&s->g, len - 2); + break; + case JPEG2000_TLM: + ret = get_tlm(s, len); + break; + default: + av_log(s->avctx, AV_LOG_ERROR, + ""unsupported marker 0x%.4X at pos 0x%X\n"", + marker, bytestream2_tell(&s->g) - 4); + bytestream2_skip(&s->g, len - 2); + break; + } + if (bytestream2_tell(&s->g) - oldpos != len || ret) { + av_log(s->avctx, AV_LOG_ERROR, + ""error during processing marker segment %.4x\n"", marker); + return ret ? ret : -1; + } + } + return 0; +} +","@@ -384,6 +384,11 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) + return AVERROR_INVALIDDATA; + } + ++ if (c->log2_cblk_width > 6 || c->log2_cblk_height > 6) { ++ avpriv_request_sample(s->avctx, ""cblk size > 64""); ++ return AVERROR_PATCHWELCOME; ++ } ++ + c->cblk_style = bytestream2_get_byteu(&s->g); + if (c->cblk_style != 0) { // cblk style + av_log(s->avctx, AV_LOG_WARNING, ""extra cblk styles %X\n"", c->cblk_style); +@@ -1025,6 +1030,9 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, + int bpass_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_BYPASS; + int vert_causal_ctx_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_VSC; + ++ av_assert0(width <= JPEG2000_MAX_CBLKW); ++ av_assert0(height <= JPEG2000_MAX_CBLKH); ++ + for (y = 0; y < height; y++) + memset(t1->data[y], 0, width * sizeof(**t1->data)); + ",873,1109,2048 +18157,"static int http_connect(URLContext *h, const char *path, const char *local_path, + const char *hoststr, const char *auth, + const char *proxyauth, int *new_location) +{ + HTTPContext *s = h->priv_data; + int post, err; + char headers[HTTP_HEADERS_SIZE] = """"; + char *authstr = NULL, *proxyauthstr = NULL; + int64_t off = s->off; + int len = 0; + const char *method; + int send_expect_100 = 0; + + /* send http header */ + post = h->flags & AVIO_FLAG_WRITE; + + if (s->post_data) { + /* force POST method and disable chunked encoding when + * custom HTTP post data is set */ + post = 1; + s->chunked_post = 0; + } + + if (s->method) + method = s->method; + else + method = post ? ""POST"" : ""GET""; + + authstr = ff_http_auth_create_response(&s->auth_state, auth, + local_path, method); + proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, + local_path, method); + if (post && !s->post_data) { + send_expect_100 = s->send_expect_100; + /* The user has supplied authentication but we don't know the auth type, + * send Expect: 100-continue to get the 401 response including the + * WWW-Authenticate header, or an 100 continue if no auth actually + * is needed. */ + if (auth && *auth && + s->auth_state.auth_type == HTTP_AUTH_NONE && + s->http_code != 401) + send_expect_100 = 1; + } + +#if FF_API_HTTP_USER_AGENT + if (strcmp(s->user_agent_deprecated, DEFAULT_USER_AGENT)) { + av_log(s, AV_LOG_WARNING, ""the user-agent option is deprecated, please use user_agent option\n""); + s->user_agent = av_strdup(s->user_agent_deprecated); + } +#endif + /* set default headers if needed */ + if (!has_header(s->headers, ""\r\nUser-Agent: "")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""User-Agent: %s\r\n"", s->user_agent); + if (!has_header(s->headers, ""\r\nAccept: "")) + len += av_strlcpy(headers + len, ""Accept: */*\r\n"", + sizeof(headers) - len); + if (!has_header(s->headers, ""\r\nRange: "") && !post && (s->off > 0 || s->end_off || s->seekable == -1)) { + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Range: bytes=%""PRId64""-"", s->off); + if (s->end_off) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""%""PRId64, s->end_off - 1); + len += av_strlcpy(headers + len, ""\r\n"", + sizeof(headers) - len); + } + if (send_expect_100 && !has_header(s->headers, ""\r\nExpect: "")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Expect: 100-continue\r\n""); + + if (!has_header(s->headers, ""\r\nConnection: "")) { + if (s->multiple_requests) + len += av_strlcpy(headers + len, ""Connection: keep-alive\r\n"", + sizeof(headers) - len); + else + len += av_strlcpy(headers + len, ""Connection: close\r\n"", + sizeof(headers) - len); + } + + if (!has_header(s->headers, ""\r\nHost: "")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Host: %s\r\n"", hoststr); + if (!has_header(s->headers, ""\r\nContent-Length: "") && s->post_data) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Content-Length: %d\r\n"", s->post_datalen); + + if (!has_header(s->headers, ""\r\nContent-Type: "") && s->content_type) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Content-Type: %s\r\n"", s->content_type); + if (!has_header(s->headers, ""\r\nCookie: "") && s->cookies) { + char *cookies = NULL; + if (!get_cookies(s, &cookies, path, hoststr) && cookies) { + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Cookie: %s\r\n"", cookies); + av_free(cookies); + } + } + if (!has_header(s->headers, ""\r\nIcy-MetaData: "") && s->icy) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Icy-MetaData: %d\r\n"", 1); + + /* now add in custom headers */ + if (s->headers) + av_strlcpy(headers + len, s->headers, sizeof(headers) - len); + + snprintf(s->buffer, sizeof(s->buffer), + ""%s %s HTTP/1.1\r\n"" + ""%s"" + ""%s"" + ""%s"" + ""%s%s"" + ""\r\n"", + method, + path, + post && s->chunked_post ? ""Transfer-Encoding: chunked\r\n"" : """", + headers, + authstr ? authstr : """", + proxyauthstr ? ""Proxy-"" : """", proxyauthstr ? proxyauthstr : """"); + + av_log(h, AV_LOG_DEBUG, ""request: %s\n"", s->buffer); + + if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) + goto done; + + if (s->post_data) + if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) + goto done; + + /* init input buffer */ + s->buf_ptr = s->buffer; + s->buf_end = s->buffer; + s->line_count = 0; + s->off = 0; + s->icy_data_read = 0; + s->filesize = -1; + s->willclose = 0; + s->end_chunked_post = 0; + s->end_header = 0; + if (post && !s->post_data && !send_expect_100) { + /* Pretend that it did work. We didn't read any header yet, since + * we've still to send the POST data, but the code calling this + * function will check http_code after we return. */ + s->http_code = 200; + err = 0; + goto done; + } + + /* wait for header */ + err = http_read_header(h, new_location); + if (err < 0) + goto done; + + if (*new_location) + s->off = off; + + err = (off == s->off) ? 0 : -1; +done: + av_freep(&authstr); + av_freep(&proxyauthstr); + return err; +} +",1,"static int http_connect(URLContext *h, const char *path, const char *local_path, + const char *hoststr, const char *auth, + const char *proxyauth, int *new_location) +{ + HTTPContext *s = h->priv_data; + int post, err; + char headers[HTTP_HEADERS_SIZE] = """"; + char *authstr = NULL, *proxyauthstr = NULL; + uint64_t off = s->off; + int len = 0; + const char *method; + int send_expect_100 = 0; + + /* send http header */ + post = h->flags & AVIO_FLAG_WRITE; + + if (s->post_data) { + /* force POST method and disable chunked encoding when + * custom HTTP post data is set */ + post = 1; + s->chunked_post = 0; + } + + if (s->method) + method = s->method; + else + method = post ? ""POST"" : ""GET""; + + authstr = ff_http_auth_create_response(&s->auth_state, auth, + local_path, method); + proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, + local_path, method); + if (post && !s->post_data) { + send_expect_100 = s->send_expect_100; + /* The user has supplied authentication but we don't know the auth type, + * send Expect: 100-continue to get the 401 response including the + * WWW-Authenticate header, or an 100 continue if no auth actually + * is needed. */ + if (auth && *auth && + s->auth_state.auth_type == HTTP_AUTH_NONE && + s->http_code != 401) + send_expect_100 = 1; + } + +#if FF_API_HTTP_USER_AGENT + if (strcmp(s->user_agent_deprecated, DEFAULT_USER_AGENT)) { + av_log(s, AV_LOG_WARNING, ""the user-agent option is deprecated, please use user_agent option\n""); + s->user_agent = av_strdup(s->user_agent_deprecated); + } +#endif + /* set default headers if needed */ + if (!has_header(s->headers, ""\r\nUser-Agent: "")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""User-Agent: %s\r\n"", s->user_agent); + if (!has_header(s->headers, ""\r\nAccept: "")) + len += av_strlcpy(headers + len, ""Accept: */*\r\n"", + sizeof(headers) - len); + if (!has_header(s->headers, ""\r\nRange: "") && !post && (s->off > 0 || s->end_off || s->seekable == -1)) { + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Range: bytes=%""PRIu64""-"", s->off); + if (s->end_off) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""%""PRId64, s->end_off - 1); + len += av_strlcpy(headers + len, ""\r\n"", + sizeof(headers) - len); + } + if (send_expect_100 && !has_header(s->headers, ""\r\nExpect: "")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Expect: 100-continue\r\n""); + + if (!has_header(s->headers, ""\r\nConnection: "")) { + if (s->multiple_requests) + len += av_strlcpy(headers + len, ""Connection: keep-alive\r\n"", + sizeof(headers) - len); + else + len += av_strlcpy(headers + len, ""Connection: close\r\n"", + sizeof(headers) - len); + } + + if (!has_header(s->headers, ""\r\nHost: "")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Host: %s\r\n"", hoststr); + if (!has_header(s->headers, ""\r\nContent-Length: "") && s->post_data) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Content-Length: %d\r\n"", s->post_datalen); + + if (!has_header(s->headers, ""\r\nContent-Type: "") && s->content_type) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Content-Type: %s\r\n"", s->content_type); + if (!has_header(s->headers, ""\r\nCookie: "") && s->cookies) { + char *cookies = NULL; + if (!get_cookies(s, &cookies, path, hoststr) && cookies) { + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Cookie: %s\r\n"", cookies); + av_free(cookies); + } + } + if (!has_header(s->headers, ""\r\nIcy-MetaData: "") && s->icy) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""Icy-MetaData: %d\r\n"", 1); + + /* now add in custom headers */ + if (s->headers) + av_strlcpy(headers + len, s->headers, sizeof(headers) - len); + + snprintf(s->buffer, sizeof(s->buffer), + ""%s %s HTTP/1.1\r\n"" + ""%s"" + ""%s"" + ""%s"" + ""%s%s"" + ""\r\n"", + method, + path, + post && s->chunked_post ? ""Transfer-Encoding: chunked\r\n"" : """", + headers, + authstr ? authstr : """", + proxyauthstr ? ""Proxy-"" : """", proxyauthstr ? proxyauthstr : """"); + + av_log(h, AV_LOG_DEBUG, ""request: %s\n"", s->buffer); + + if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) + goto done; + + if (s->post_data) + if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) + goto done; + + /* init input buffer */ + s->buf_ptr = s->buffer; + s->buf_end = s->buffer; + s->line_count = 0; + s->off = 0; + s->icy_data_read = 0; + s->filesize = UINT64_MAX; + s->willclose = 0; + s->end_chunked_post = 0; + s->end_header = 0; + if (post && !s->post_data && !send_expect_100) { + /* Pretend that it did work. We didn't read any header yet, since + * we've still to send the POST data, but the code calling this + * function will check http_code after we return. */ + s->http_code = 200; + err = 0; + goto done; + } + + /* wait for header */ + err = http_read_header(h, new_location); + if (err < 0) + goto done; + + if (*new_location) + s->off = off; + + err = (off == s->off) ? 0 : -1; +done: + av_freep(&authstr); + av_freep(&proxyauthstr); + return err; +} +","@@ -62,8 +62,8 @@ typedef struct HTTPContext { + int line_count; + int http_code; + /* Used if ""Transfer-Encoding: chunked"" otherwise -1. */ +- int64_t chunksize; +- int64_t off, end_off, filesize; ++ uint64_t chunksize; ++ uint64_t off, end_off, filesize; + char *location; + HTTPAuthState auth_state; + HTTPAuthState proxy_auth_state; +@@ -95,9 +95,9 @@ typedef struct HTTPContext { + AVDictionary *cookie_dict; + int icy; + /* how much data was read since the last ICY metadata packet */ +- int icy_data_read; ++ uint64_t icy_data_read; + /* after how many bytes of read data a new metadata packet will be found */ +- int icy_metaint; ++ uint64_t icy_metaint; + char *icy_metadata_headers; + char *icy_metadata_packet; + AVDictionary *metadata; +@@ -489,7 +489,7 @@ static int http_open(URLContext *h, const char *uri, int flags, + else + h->is_streamed = 1; + +- s->filesize = -1; ++ s->filesize = UINT64_MAX; + s->location = av_strdup(uri); + if (!s->location) + return AVERROR(ENOMEM); +@@ -616,9 +616,9 @@ static void parse_content_range(URLContext *h, const char *p) + + if (!strncmp(p, ""bytes "", 6)) { + p += 6; +- s->off = strtoll(p, NULL, 10); ++ s->off = strtoull(p, NULL, 10); + if ((slash = strchr(p, '/')) && strlen(slash) > 0) +- s->filesize = strtoll(slash + 1, NULL, 10); ++ s->filesize = strtoull(slash + 1, NULL, 10); + } + if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647)) + h->is_streamed = 0; /* we _can_ in fact seek */ +@@ -808,8 +808,9 @@ static int process_line(URLContext *h, char *line, int line_count, + if ((ret = parse_location(s, p)) < 0) + return ret; + *new_location = 1; +- } else if (!av_strcasecmp(tag, ""Content-Length"") && s->filesize == -1) { +- s->filesize = strtoll(p, NULL, 10); ++ } else if (!av_strcasecmp(tag, ""Content-Length"") && ++ s->filesize == UINT64_MAX) { ++ s->filesize = strtoull(p, NULL, 10); + } else if (!av_strcasecmp(tag, ""Content-Range"")) { + parse_content_range(h, p); + } else if (!av_strcasecmp(tag, ""Accept-Ranges"") && +@@ -818,7 +819,7 @@ static int process_line(URLContext *h, char *line, int line_count, + h->is_streamed = 0; + } else if (!av_strcasecmp(tag, ""Transfer-Encoding"") && + !av_strncasecmp(p, ""chunked"", 7)) { +- s->filesize = -1; ++ s->filesize = UINT64_MAX; + s->chunksize = 0; + } else if (!av_strcasecmp(tag, ""WWW-Authenticate"")) { + ff_http_auth_handle_header(&s->auth_state, tag, p); +@@ -842,7 +843,7 @@ static int process_line(URLContext *h, char *line, int line_count, + if (parse_cookie(s, p, &s->cookie_dict)) + av_log(h, AV_LOG_WARNING, ""Unable to parse '%s'\n"", p); + } else if (!av_strcasecmp(tag, ""Icy-MetaInt"")) { +- s->icy_metaint = strtoll(p, NULL, 10); ++ s->icy_metaint = strtoull(p, NULL, 10); + } else if (!av_strncasecmp(tag, ""Icy-"", 4)) { + if ((ret = parse_icy(s, tag, p)) < 0) + return ret; +@@ -972,7 +973,7 @@ static int http_read_header(URLContext *h, int *new_location) + char line[MAX_URL_SIZE]; + int err = 0; + +- s->chunksize = -1; ++ s->chunksize = UINT64_MAX; + + for (;;) { + if ((err = http_get_line(s, line, sizeof(line))) < 0) +@@ -1006,7 +1007,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, + int post, err; + char headers[HTTP_HEADERS_SIZE] = """"; + char *authstr = NULL, *proxyauthstr = NULL; +- int64_t off = s->off; ++ uint64_t off = s->off; + int len = 0; + const char *method; + int send_expect_100 = 0; +@@ -1060,7 +1061,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, + // server supports seeking by analysing the reply headers. + if (!has_header(s->headers, ""\r\nRange: "") && !post && (s->off > 0 || s->end_off || s->seekable == -1)) { + len += av_strlcatf(headers + len, sizeof(headers) - len, +- ""Range: bytes=%""PRId64""-"", s->off); ++ ""Range: bytes=%""PRIu64""-"", s->off); + if (s->end_off) + len += av_strlcatf(headers + len, sizeof(headers) - len, + ""%""PRId64, s->end_off - 1); +@@ -1135,7 +1136,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, + s->line_count = 0; + s->off = 0; + s->icy_data_read = 0; +- s->filesize = -1; ++ s->filesize = UINT64_MAX; + s->willclose = 0; + s->end_chunked_post = 0; + s->end_header = 0; +@@ -1175,15 +1176,13 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size) + memcpy(buf, s->buf_ptr, len); + s->buf_ptr += len; + } else { +- int64_t target_end = s->end_off ? s->end_off : s->filesize; +- if ((!s->willclose || s->chunksize < 0) && +- target_end >= 0 && s->off >= target_end) ++ uint64_t target_end = s->end_off ? s->end_off : s->filesize; ++ if ((!s->willclose || s->chunksize == UINT64_MAX) && s->off >= target_end) + return AVERROR_EOF; + len = ffurl_read(s->hd, buf, size); +- if (!len && (!s->willclose || s->chunksize < 0) && +- target_end >= 0 && s->off < target_end) { ++ if (!len && (!s->willclose || s->chunksize == UINT64_MAX) && s->off < target_end) { + av_log(h, AV_LOG_ERROR, +- ""Stream ends prematurely at %""PRId64"", should be %""PRId64""\n"", ++ ""Stream ends prematurely at %""PRIu64"", should be %""PRIu64""\n"", + s->off, target_end + ); + return AVERROR(EIO); +@@ -1247,7 +1246,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) + return err; + } + +- if (s->chunksize >= 0) { ++ if (s->chunksize != UINT64_MAX) { + if (!s->chunksize) { + char line[32]; + +@@ -1256,13 +1255,19 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) + return err; + } while (!*line); /* skip CR LF from last chunk */ + +- s->chunksize = strtoll(line, NULL, 16); ++ s->chunksize = strtoull(line, NULL, 16); + +- av_log(NULL, AV_LOG_TRACE, ""Chunked encoding data size: %""PRId64""'\n"", ++ av_log(h, AV_LOG_TRACE, ++ ""Chunked encoding data size: %""PRIu64""'\n"", + s->chunksize); + + if (!s->chunksize) + return 0; ++ else if (s->chunksize == UINT64_MAX) { ++ av_log(h, AV_LOG_ERROR, ""Invalid chunk size %""PRIu64""\n"", ++ s->chunksize); ++ return AVERROR(EINVAL); ++ } + } + size = FFMIN(size, s->chunksize); + } +@@ -1273,17 +1278,17 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) + read_ret = http_buf_read(h, buf, size); + if ( (read_ret < 0 && s->reconnect && (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize) + || (read_ret == 0 && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) { +- int64_t target = h->is_streamed ? 0 : s->off; ++ uint64_t target = h->is_streamed ? 0 : s->off; + + if (s->reconnect_delay > s->reconnect_delay_max) + return AVERROR(EIO); + +- av_log(h, AV_LOG_INFO, ""Will reconnect at %""PRId64"" error=%s.\n"", s->off, av_err2str(read_ret)); ++ av_log(h, AV_LOG_INFO, ""Will reconnect at %""PRIu64"" error=%s.\n"", s->off, av_err2str(read_ret)); + av_usleep(1000U*1000*s->reconnect_delay); + s->reconnect_delay = 1 + 2*s->reconnect_delay; + seek_ret = http_seek_internal(h, target, SEEK_SET, 1); + if (seek_ret != target) { +- av_log(h, AV_LOG_ERROR, ""Failed to reconnect at %""PRId64"".\n"", target); ++ av_log(h, AV_LOG_ERROR, ""Failed to reconnect at %""PRIu64"".\n"", target); + return read_ret; + } + +@@ -1338,10 +1343,11 @@ static int store_icy(URLContext *h, int size) + { + HTTPContext *s = h->priv_data; + /* until next metadata packet */ +- int remaining = s->icy_metaint - s->icy_data_read; ++ uint64_t remaining; + +- if (remaining < 0) ++ if (s->icy_metaint < s->icy_data_read) + return AVERROR_INVALIDDATA; ++ remaining = s->icy_metaint - s->icy_data_read; + + if (!remaining) { + /* The metadata packet is variable sized. It has a 1 byte header +@@ -1455,7 +1461,7 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo + { + HTTPContext *s = h->priv_data; + URLContext *old_hd = s->hd; +- int64_t old_off = s->off; ++ uint64_t old_off = s->off; + uint8_t old_buf[BUFFER_SIZE]; + int old_buf_size, ret; + AVDictionary *options = NULL; +@@ -1466,7 +1472,7 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo + ((whence == SEEK_CUR && off == 0) || + (whence == SEEK_SET && off == s->off))) + return s->off; +- else if ((s->filesize == -1 && whence == SEEK_END)) ++ else if ((s->filesize == UINT64_MAX && whence == SEEK_END)) + return AVERROR(ENOSYS); + + if (whence == SEEK_CUR) +@@ -1621,7 +1627,7 @@ static int http_proxy_open(URLContext *h, const char *uri, int flags) + s->buf_ptr = s->buffer; + s->buf_end = s->buffer; + s->line_count = 0; +- s->filesize = -1; ++ s->filesize = UINT64_MAX; + cur_auth_type = s->proxy_auth_state.auth_type; + + /* Note: This uses buffering, potentially reading more than the",1643,1879,2048 +8974,"AddPinhole(struct upnphttp * h, const char * action, const char * ns) +{ + int r; + static const char resp[] = + """" + ""%d"" + """"; + char body[512]; + int bodylen; + struct NameValueParserData data; + char * rem_host, * rem_port, * int_ip, * int_port, * protocol, * leaseTime; + int uid = 0; + unsigned short iport, rport; + int ltime; + long proto; + char rem_ip[INET6_ADDRSTRLEN]; + + if(CheckStatus(h)==0) + return; + + ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data); + rem_host = GetValueFromNameValueList(&data, ""RemoteHost""); + rem_port = GetValueFromNameValueList(&data, ""RemotePort""); + int_ip = GetValueFromNameValueList(&data, ""InternalClient""); + int_port = GetValueFromNameValueList(&data, ""InternalPort""); + protocol = GetValueFromNameValueList(&data, ""Protocol""); + leaseTime = GetValueFromNameValueList(&data, ""LeaseTime""); + + rport = (unsigned short)(rem_port ? atoi(rem_port) : 0); + iport = (unsigned short)(int_port ? atoi(int_port) : 0); + ltime = leaseTime ? atoi(leaseTime) : -1; + errno = 0; + proto = protocol ? strtol(protocol, NULL, 0) : -1; + if(errno != 0 || proto > 65535 || proto < 0) + { + SoapError(h, 402, ""Invalid Args""); + goto clear_and_exit; + } + if(iport == 0) + { + SoapError(h, 706, ""InternalPortWilcardingNotAllowed""); + goto clear_and_exit; + } + + /* In particular, [IGD2] RECOMMENDS that unauthenticated and + * unauthorized control points are only allowed to invoke + * this action with: + * - InternalPort value greater than or equal to 1024, + * - InternalClient value equals to the control point's IP address. + * It is REQUIRED that InternalClient cannot be one of IPv6 + * addresses used by the gateway. */ + if(!int_ip || int_ip[0] == '\0' || 0 == strcmp(int_ip, ""*"")) + { + SoapError(h, 708, ""WildCardNotPermittedInSrcIP""); + goto clear_and_exit; + } + /* I guess it is useless to convert int_ip to literal ipv6 address */ + if(rem_host) + { + /* trim */ + while(isspace(rem_host[0])) + rem_host++; + } + /* rem_host should be converted to literal ipv6 : */ + if(rem_host && (rem_host[0] != '\0') && (rem_host[0] != '*')) + { + struct addrinfo *ai, *p; + struct addrinfo hints; + int err; + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_INET6; + /*hints.ai_flags = */ + /* hints.ai_protocol = proto; */ + err = getaddrinfo(rem_host, rem_port, &hints, &ai); + if(err == 0) + { + /* take the 1st IPv6 address */ + for(p = ai; p; p = p->ai_next) + { + if(p->ai_family == AF_INET6) + { + inet_ntop(AF_INET6, + &(((struct sockaddr_in6 *)p->ai_addr)->sin6_addr), + rem_ip, sizeof(rem_ip)); + syslog(LOG_INFO, ""resolved '%s' to '%s'"", rem_host, rem_ip); + rem_host = rem_ip; + break; + } + } + freeaddrinfo(ai); + } + else + { + syslog(LOG_WARNING, ""AddPinhole : getaddrinfo(%s) : %s"", + rem_host, gai_strerror(err)); +#if 0 + SoapError(h, 402, ""Invalid Args""); + goto clear_and_exit; +#endif + } + } + + if(proto == 65535) + { + SoapError(h, 707, ""ProtocolWilcardingNotAllowed""); + goto clear_and_exit; + } + if(proto != IPPROTO_UDP && proto != IPPROTO_TCP +#ifdef IPPROTO_UDPITE + && atoi(protocol) != IPPROTO_UDPLITE +#endif + ) + { + SoapError(h, 705, ""ProtocolNotSupported""); + goto clear_and_exit; + } + if(ltime < 1 || ltime > 86400) + { + syslog(LOG_WARNING, ""%s: LeaseTime=%d not supported, (ip=%s)"", + action, ltime, int_ip); + SoapError(h, 402, ""Invalid Args""); + goto clear_and_exit; + } + + if(PinholeVerification(h, int_ip, iport) <= 0) + goto clear_and_exit; + + syslog(LOG_INFO, ""%s: (inbound) from [%s]:%hu to [%s]:%hu with proto %ld during %d sec"", + action, rem_host?rem_host:""any"", + rport, int_ip, iport, + proto, ltime); + + /* In cases where the RemoteHost, RemotePort, InternalPort, + * InternalClient and Protocol are the same than an existing pinhole, + * but LeaseTime is different, the device MUST extend the existing + * pinhole's lease time and return the UniqueID of the existing pinhole. */ + r = upnp_add_inboundpinhole(rem_host, rport, int_ip, iport, proto, ""IGD2 pinhole"", ltime, &uid); + + switch(r) + { + case 1: /* success */ + bodylen = snprintf(body, sizeof(body), + resp, action, + ns/*""urn:schemas-upnp-org:service:WANIPv6FirewallControl:1""*/, + uid, action); + BuildSendAndCloseSoapResp(h, body, bodylen); + break; + case -1: /* not permitted */ + SoapError(h, 701, ""PinholeSpaceExhausted""); + break; + default: + SoapError(h, 501, ""ActionFailed""); + break; + } + /* 606 Action not authorized + * 701 PinholeSpaceExhausted + * 702 FirewallDisabled + * 703 InboundPinholeNotAllowed + * 705 ProtocolNotSupported + * 706 InternalPortWildcardingNotAllowed + * 707 ProtocolWildcardingNotAllowed + * 708 WildCardNotPermittedInSrcIP */ +clear_and_exit: + ClearNameValueList(&data); +} +",0,"AddPinhole(struct upnphttp * h, const char * action, const char * ns) +{ + int r; + static const char resp[] = + """" + ""%d"" + """"; + char body[512]; + int bodylen; + struct NameValueParserData data; + char * rem_host, * rem_port, * int_ip, * int_port, * protocol, * leaseTime; + int uid = 0; + unsigned short iport, rport; + int ltime; + long proto; + char rem_ip[INET6_ADDRSTRLEN]; + + if(CheckStatus(h)==0) + return; + + ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data); + rem_host = GetValueFromNameValueList(&data, ""RemoteHost""); + rem_port = GetValueFromNameValueList(&data, ""RemotePort""); + int_ip = GetValueFromNameValueList(&data, ""InternalClient""); + int_port = GetValueFromNameValueList(&data, ""InternalPort""); + protocol = GetValueFromNameValueList(&data, ""Protocol""); + leaseTime = GetValueFromNameValueList(&data, ""LeaseTime""); + + rport = (unsigned short)(rem_port ? atoi(rem_port) : 0); + iport = (unsigned short)(int_port ? atoi(int_port) : 0); + ltime = leaseTime ? atoi(leaseTime) : -1; + errno = 0; + proto = protocol ? strtol(protocol, NULL, 0) : -1; + if(errno != 0 || proto > 65535 || proto < 0) + { + SoapError(h, 402, ""Invalid Args""); + goto clear_and_exit; + } + if(iport == 0) + { + SoapError(h, 706, ""InternalPortWilcardingNotAllowed""); + goto clear_and_exit; + } + + /* In particular, [IGD2] RECOMMENDS that unauthenticated and + * unauthorized control points are only allowed to invoke + * this action with: + * - InternalPort value greater than or equal to 1024, + * - InternalClient value equals to the control point's IP address. + * It is REQUIRED that InternalClient cannot be one of IPv6 + * addresses used by the gateway. */ + if(!int_ip || int_ip[0] == '\0' || 0 == strcmp(int_ip, ""*"")) + { + SoapError(h, 708, ""WildCardNotPermittedInSrcIP""); + goto clear_and_exit; + } + /* I guess it is useless to convert int_ip to literal ipv6 address */ + if(rem_host) + { + /* trim */ + while(isspace(rem_host[0])) + rem_host++; + } + /* rem_host should be converted to literal ipv6 : */ + if(rem_host && (rem_host[0] != '\0') && (rem_host[0] != '*')) + { + struct addrinfo *ai, *p; + struct addrinfo hints; + int err; + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_INET6; + /*hints.ai_flags = */ + /* hints.ai_protocol = proto; */ + err = getaddrinfo(rem_host, rem_port, &hints, &ai); + if(err == 0) + { + /* take the 1st IPv6 address */ + for(p = ai; p; p = p->ai_next) + { + if(p->ai_family == AF_INET6) + { + inet_ntop(AF_INET6, + &(((struct sockaddr_in6 *)p->ai_addr)->sin6_addr), + rem_ip, sizeof(rem_ip)); + syslog(LOG_INFO, ""resolved '%s' to '%s'"", rem_host, rem_ip); + rem_host = rem_ip; + break; + } + } + freeaddrinfo(ai); + } + else + { + syslog(LOG_WARNING, ""AddPinhole : getaddrinfo(%s) : %s"", + rem_host, gai_strerror(err)); +#if 0 + SoapError(h, 402, ""Invalid Args""); + goto clear_and_exit; +#endif + } + } + + if(proto == 65535) + { + SoapError(h, 707, ""ProtocolWilcardingNotAllowed""); + goto clear_and_exit; + } + if(proto != IPPROTO_UDP && proto != IPPROTO_TCP +#ifdef IPPROTO_UDPITE + && atoi(protocol) != IPPROTO_UDPLITE +#endif + ) + { + SoapError(h, 705, ""ProtocolNotSupported""); + goto clear_and_exit; + } + if(ltime < 1 || ltime > 86400) + { + syslog(LOG_WARNING, ""%s: LeaseTime=%d not supported, (ip=%s)"", + action, ltime, int_ip); + SoapError(h, 402, ""Invalid Args""); + goto clear_and_exit; + } + + if(PinholeVerification(h, int_ip, iport) <= 0) + goto clear_and_exit; + + syslog(LOG_INFO, ""%s: (inbound) from [%s]:%hu to [%s]:%hu with proto %ld during %d sec"", + action, rem_host?rem_host:""any"", + rport, int_ip, iport, + proto, ltime); + + /* In cases where the RemoteHost, RemotePort, InternalPort, + * InternalClient and Protocol are the same than an existing pinhole, + * but LeaseTime is different, the device MUST extend the existing + * pinhole's lease time and return the UniqueID of the existing pinhole. */ + r = upnp_add_inboundpinhole(rem_host, rport, int_ip, iport, proto, ""IGD2 pinhole"", ltime, &uid); + + switch(r) + { + case 1: /* success */ + bodylen = snprintf(body, sizeof(body), + resp, action, + ns/*""urn:schemas-upnp-org:service:WANIPv6FirewallControl:1""*/, + uid, action); + BuildSendAndCloseSoapResp(h, body, bodylen); + break; + case -1: /* not permitted */ + SoapError(h, 701, ""PinholeSpaceExhausted""); + break; + default: + SoapError(h, 501, ""ActionFailed""); + break; + } + /* 606 Action not authorized + * 701 PinholeSpaceExhausted + * 702 FirewallDisabled + * 703 InboundPinholeNotAllowed + * 705 ProtocolNotSupported + * 706 InternalPortWildcardingNotAllowed + * 707 ProtocolWildcardingNotAllowed + * 708 WildCardNotPermittedInSrcIP */ +clear_and_exit: + ClearNameValueList(&data); +} +","@@ -1850,6 +1850,13 @@ GetOutboundPinholeTimeout(struct upnphttp * h, const char * action, const char * + rem_port = GetValueFromNameValueList(&data, ""RemotePort""); + protocol = GetValueFromNameValueList(&data, ""Protocol""); + ++ if (!int_port || !ext_port || !protocol) ++ { ++ ClearNameValueList(&data); ++ SoapError(h, 402, ""Invalid Args""); ++ return; ++ } ++ + rport = (unsigned short)atoi(rem_port); + iport = (unsigned short)atoi(int_port); + /*proto = atoi(protocol);*/",1534,1770,2048 +5194,"gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h) +{ + int scx, scy, ecx, ecy, fsx, fsy; + int nc, ncx, ncy, cs, cx, cy; + int x, y, ylo, yhi, xlo, xhi; + int dstart, dpos; + int i; + /* 2.0.12: unsigned is correct; fixes problems with color munging. Thanks to Steven Brown. */ + unsigned int ch; + int vers, fmt; + t_chunk_info *chunkIdx = NULL; + unsigned char *chunkBuf = NULL; + int chunkNum; + int chunkMax = 0; + uLongf chunkLen; + int chunkPos = 0; + int compMax; + char *compBuf = NULL; + + gdImagePtr im; + + if (w<1 || h <1) { + return 0; + } + + /* The next few lines are basically copied from gd2CreateFromFile + * we change the file size, so don't want to use the code directly. + * but we do need to know the file size. + */ + if (_gd2GetHeader(in, &fsx, &fsy, &cs, &vers, &fmt, &ncx, &ncy, &chunkIdx) != 1) { + goto fail1; + } + + GD2_DBG(php_gd_error(""File size is %dx%d"", fsx, fsy)); + + /* This is the difference - make a file based on size of chunks. */ + if (gd2_truecolor(fmt)) { + im = gdImageCreateTrueColor(w, h); + } else { + im = gdImageCreate(w, h); + } + if (im == NULL) { + goto fail1; + } + + if (!_gdGetColors(in, im, vers == 2)) { + goto fail2; + } + GD2_DBG(php_gd_error(""Image palette completed: %d colours"", im->colorsTotal)); + + /* Process the header info */ + nc = ncx * ncy; + + if (gd2_compressed(fmt)) { + /* Find the maximum compressed chunk size. */ + compMax = 0; + for (i = 0; (i < nc); i++) { + if (chunkIdx[i].size > compMax) { + compMax = chunkIdx[i].size; + } + } + compMax++; + + if (im->trueColor) { + chunkMax = cs * cs * 4; + } else { + chunkMax = cs * cs; + } + if (chunkMax <= 0) { + goto fail2; + } + + chunkBuf = gdCalloc(chunkMax, 1); + compBuf = gdCalloc(compMax, 1); + } + + /* Work out start/end chunks */ + scx = srcx / cs; + scy = srcy / cs; + if (scx < 0) { + scx = 0; + } + if (scy < 0) { + scy = 0; + } + + ecx = (srcx + w) / cs; + ecy = (srcy + h) / cs; + if (ecx >= ncx) { + ecx = ncx - 1; + } + if (ecy >= ncy) { + ecy = ncy - 1; + } + + /* Remember file position of image data. */ + dstart = gdTell(in); + GD2_DBG(php_gd_error(""Data starts at %d"", dstart)); + + /* Loop through the chunks. */ + for (cy = scy; (cy <= ecy); cy++) { + ylo = cy * cs; + yhi = ylo + cs; + if (yhi > fsy) { + yhi = fsy; + } + + for (cx = scx; cx <= ecx; cx++) { + + xlo = cx * cs; + xhi = xlo + cs; + if (xhi > fsx) { + xhi = fsx; + } + + GD2_DBG(php_gd_error(""Processing Chunk (%d, %d), from %d to %d"", cx, cy, ylo, yhi)); + + if (!gd2_compressed(fmt)) { + GD2_DBG(php_gd_error(""Using raw format data"")); + if (im->trueColor) { + dpos = (cy * (cs * fsx) * 4 + cx * cs * (yhi - ylo) * 4) + dstart; + } else { + dpos = cy * (cs * fsx) + cx * cs * (yhi - ylo) + dstart; + } + + /* gd 2.0.11: gdSeek returns TRUE on success, not 0. Longstanding bug. 01/16/03 */ + if (!gdSeek(in, dpos)) { + php_gd_error_ex(E_WARNING, ""Error from seek: %d"", errno); + goto fail2; + } + GD2_DBG(php_gd_error(""Reading (%d, %d) from position %d"", cx, cy, dpos - dstart)); + } else { + chunkNum = cx + cy * ncx; + + chunkLen = chunkMax; + if (!_gd2ReadChunk (chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, (char *)chunkBuf, &chunkLen, in)) { + php_gd_error(""Error reading comproessed chunk""); + goto fail2; + } + chunkPos = 0; + GD2_DBG(php_gd_error(""Reading (%d, %d) from chunk %d"", cx, cy, chunkNum)); + } + + GD2_DBG(php_gd_error("" into (%d, %d) - (%d, %d)"", xlo, ylo, xhi, yhi)); + + for (y = ylo; (y < yhi); y++) { + for (x = xlo; x < xhi; x++) { + if (!gd2_compressed(fmt)) { + if (im->trueColor) { + if (!gdGetInt((int *)&ch, in)) { + ch = 0; + } + } else { + ch = gdGetC(in); + if ((int)ch == EOF) { + ch = 0; + } + } + } else { + if (im->trueColor) { + ch = chunkBuf[chunkPos++]; + ch = (ch << 8) + chunkBuf[chunkPos++]; + ch = (ch << 8) + chunkBuf[chunkPos++]; + ch = (ch << 8) + chunkBuf[chunkPos++]; + } else { + ch = chunkBuf[chunkPos++]; + } + } + + /* Only use a point that is in the image. */ + if ((x >= srcx) && (x < (srcx + w)) && (x < fsx) && (x >= 0) && (y >= srcy) && (y < (srcy + h)) && (y < fsy) && (y >= 0)) { + if (im->trueColor) { + im->tpixels[y - srcy][x - srcx] = ch; + } else { + im->pixels[y - srcy][x - srcx] = ch; + } + } + } + } + } + } + + if (chunkBuf) { + gdFree(chunkBuf); + } + if (compBuf) { + gdFree(compBuf); + } + if (chunkIdx) { + gdFree(chunkIdx); + } + + return im; + +fail2: + gdImageDestroy(im); +fail1: + if (chunkBuf) { + gdFree(chunkBuf); + } + if (compBuf) { + gdFree(compBuf); + } + if (chunkIdx) { + gdFree(chunkIdx); + } + + return 0; +} +",0,"gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h) +{ + int scx, scy, ecx, ecy, fsx, fsy; + int nc, ncx, ncy, cs, cx, cy; + int x, y, ylo, yhi, xlo, xhi; + int dstart, dpos; + int i; + /* 2.0.12: unsigned is correct; fixes problems with color munging. Thanks to Steven Brown. */ + unsigned int ch; + int vers, fmt; + t_chunk_info *chunkIdx = NULL; + unsigned char *chunkBuf = NULL; + int chunkNum; + int chunkMax = 0; + uLongf chunkLen; + int chunkPos = 0; + int compMax; + char *compBuf = NULL; + + gdImagePtr im; + + if (w<1 || h <1) { + return 0; + } + + /* The next few lines are basically copied from gd2CreateFromFile + * we change the file size, so don't want to use the code directly. + * but we do need to know the file size. + */ + if (_gd2GetHeader(in, &fsx, &fsy, &cs, &vers, &fmt, &ncx, &ncy, &chunkIdx) != 1) { + goto fail1; + } + + GD2_DBG(php_gd_error(""File size is %dx%d"", fsx, fsy)); + + /* This is the difference - make a file based on size of chunks. */ + if (gd2_truecolor(fmt)) { + im = gdImageCreateTrueColor(w, h); + } else { + im = gdImageCreate(w, h); + } + if (im == NULL) { + goto fail1; + } + + if (!_gdGetColors(in, im, vers == 2)) { + goto fail2; + } + GD2_DBG(php_gd_error(""Image palette completed: %d colours"", im->colorsTotal)); + + /* Process the header info */ + nc = ncx * ncy; + + if (gd2_compressed(fmt)) { + /* Find the maximum compressed chunk size. */ + compMax = 0; + for (i = 0; (i < nc); i++) { + if (chunkIdx[i].size > compMax) { + compMax = chunkIdx[i].size; + } + } + compMax++; + + if (im->trueColor) { + chunkMax = cs * cs * 4; + } else { + chunkMax = cs * cs; + } + if (chunkMax <= 0) { + goto fail2; + } + + chunkBuf = gdCalloc(chunkMax, 1); + compBuf = gdCalloc(compMax, 1); + } + + /* Work out start/end chunks */ + scx = srcx / cs; + scy = srcy / cs; + if (scx < 0) { + scx = 0; + } + if (scy < 0) { + scy = 0; + } + + ecx = (srcx + w) / cs; + ecy = (srcy + h) / cs; + if (ecx >= ncx) { + ecx = ncx - 1; + } + if (ecy >= ncy) { + ecy = ncy - 1; + } + + /* Remember file position of image data. */ + dstart = gdTell(in); + GD2_DBG(php_gd_error(""Data starts at %d"", dstart)); + + /* Loop through the chunks. */ + for (cy = scy; (cy <= ecy); cy++) { + ylo = cy * cs; + yhi = ylo + cs; + if (yhi > fsy) { + yhi = fsy; + } + + for (cx = scx; cx <= ecx; cx++) { + + xlo = cx * cs; + xhi = xlo + cs; + if (xhi > fsx) { + xhi = fsx; + } + + GD2_DBG(php_gd_error(""Processing Chunk (%d, %d), from %d to %d"", cx, cy, ylo, yhi)); + + if (!gd2_compressed(fmt)) { + GD2_DBG(php_gd_error(""Using raw format data"")); + if (im->trueColor) { + dpos = (cy * (cs * fsx) * 4 + cx * cs * (yhi - ylo) * 4) + dstart; + } else { + dpos = cy * (cs * fsx) + cx * cs * (yhi - ylo) + dstart; + } + + /* gd 2.0.11: gdSeek returns TRUE on success, not 0. Longstanding bug. 01/16/03 */ + if (!gdSeek(in, dpos)) { + php_gd_error_ex(E_WARNING, ""Error from seek: %d"", errno); + goto fail2; + } + GD2_DBG(php_gd_error(""Reading (%d, %d) from position %d"", cx, cy, dpos - dstart)); + } else { + chunkNum = cx + cy * ncx; + + chunkLen = chunkMax; + if (!_gd2ReadChunk (chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, (char *)chunkBuf, &chunkLen, in)) { + php_gd_error(""Error reading comproessed chunk""); + goto fail2; + } + chunkPos = 0; + GD2_DBG(php_gd_error(""Reading (%d, %d) from chunk %d"", cx, cy, chunkNum)); + } + + GD2_DBG(php_gd_error("" into (%d, %d) - (%d, %d)"", xlo, ylo, xhi, yhi)); + + for (y = ylo; (y < yhi); y++) { + for (x = xlo; x < xhi; x++) { + if (!gd2_compressed(fmt)) { + if (im->trueColor) { + if (!gdGetInt((int *)&ch, in)) { + ch = 0; + } + } else { + ch = gdGetC(in); + if ((int)ch == EOF) { + ch = 0; + } + } + } else { + if (im->trueColor) { + ch = chunkBuf[chunkPos++]; + ch = (ch << 8) + chunkBuf[chunkPos++]; + ch = (ch << 8) + chunkBuf[chunkPos++]; + ch = (ch << 8) + chunkBuf[chunkPos++]; + } else { + ch = chunkBuf[chunkPos++]; + } + } + + /* Only use a point that is in the image. */ + if ((x >= srcx) && (x < (srcx + w)) && (x < fsx) && (x >= 0) && (y >= srcy) && (y < (srcy + h)) && (y < fsy) && (y >= 0)) { + if (im->trueColor) { + im->tpixels[y - srcy][x - srcx] = ch; + } else { + im->pixels[y - srcy][x - srcx] = ch; + } + } + } + } + } + } + + if (chunkBuf) { + gdFree(chunkBuf); + } + if (compBuf) { + gdFree(compBuf); + } + if (chunkIdx) { + gdFree(chunkIdx); + } + + return im; + +fail2: + gdImageDestroy(im); +fail1: + if (chunkBuf) { + gdFree(chunkBuf); + } + if (compBuf) { + gdFree(compBuf); + } + if (chunkIdx) { + gdFree(chunkIdx); + } + + return 0; +} +","@@ -138,11 +138,18 @@ static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, in + if (gd2_compressed(*fmt)) { + nc = (*ncx) * (*ncy); + GD2_DBG(php_gd_error(""Reading %d chunk index entries"", nc)); ++ if (overflow2(sidx, nc)) { ++ goto fail1; ++ } + sidx = sizeof(t_chunk_info) * nc; + if (sidx <= 0) { + goto fail1; + } + cidx = gdCalloc(sidx, 1); ++ if (cidx == NULL) { ++ goto fail1; ++ } ++ + for (i = 0; i < nc; i++) { + if (gdGetInt(&cidx[i].offset, in) != 1) { + gdFree(cidx);",1767,2003,2048 +6962,"rend_service_intro_has_opened(origin_circuit_t *circuit) +{ + rend_service_t *service; + char buf[RELAY_PAYLOAD_SIZE]; + char serviceid[REND_SERVICE_ID_LEN_BASE32+1]; + unsigned int expiring_nodes_len, num_ip_circuits, valid_ip_circuits = 0; + int reason = END_CIRC_REASON_TORPROTOCOL; + const char *rend_pk_digest; + + tor_assert(circuit->base_.purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO); + assert_circ_anonymity_ok(circuit, get_options()); + tor_assert(circuit->cpath); + tor_assert(circuit->rend_data); + /* XXX: This is version 2 specific (only on supported). */ + rend_pk_digest = (char *) rend_data_get_pk_digest(circuit->rend_data, NULL); + + base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1, + rend_pk_digest, REND_SERVICE_ID_LEN); + + service = rend_service_get_by_pk_digest(rend_pk_digest); + if (!service) { + log_warn(LD_REND, ""Unrecognized service ID %s on introduction circuit %u."", + safe_str_client(serviceid), (unsigned)circuit->base_.n_circ_id); + reason = END_CIRC_REASON_NOSUCHSERVICE; + goto err; + } + + /* Take the current amount of expiring nodes and the current amount of IP + * circuits and compute how many valid IP circuits we have. */ + expiring_nodes_len = (unsigned int) smartlist_len(service->expiring_nodes); + num_ip_circuits = count_intro_point_circuits(service); + /* Let's avoid an underflow. The valid_ip_circuits is initialized to 0 in + * case this condition turns out false because it means that all circuits + * are expiring so we need to keep this circuit. */ + if (num_ip_circuits > expiring_nodes_len) { + valid_ip_circuits = num_ip_circuits - expiring_nodes_len; + } + + /* If we already have enough introduction circuits for this service, + * redefine this one as a general circuit or close it, depending. + * Substract the amount of expiring nodes here because the circuits are + * still opened. */ + if (valid_ip_circuits > service->n_intro_points_wanted) { + const or_options_t *options = get_options(); + /* Remove the intro point associated with this circuit, it's being + * repurposed or closed thus cleanup memory. */ + rend_intro_point_t *intro = find_intro_point(circuit); + if (intro != NULL) { + smartlist_remove(service->intro_nodes, intro); + rend_intro_point_free(intro); + } + + if (options->ExcludeNodes) { + /* XXXX in some future version, we can test whether the transition is + allowed or not given the actual nodes in the circuit. But for now, + this case, we might as well close the thing. */ + log_info(LD_CIRC|LD_REND, ""We have just finished an introduction "" + ""circuit, but we already have enough. Closing it.""); + reason = END_CIRC_REASON_NONE; + goto err; + } else { + tor_assert(circuit->build_state->is_internal); + log_info(LD_CIRC|LD_REND, ""We have just finished an introduction "" + ""circuit, but we already have enough. Redefining purpose to "" + ""general; leaving as internal.""); + + circuit_change_purpose(TO_CIRCUIT(circuit), CIRCUIT_PURPOSE_C_GENERAL); + + { + rend_data_free(circuit->rend_data); + circuit->rend_data = NULL; + } + { + crypto_pk_t *intro_key = circuit->intro_key; + circuit->intro_key = NULL; + crypto_pk_free(intro_key); + } + + circuit_has_opened(circuit); + goto done; + } + } + + log_info(LD_REND, + ""Established circuit %u as introduction point for service %s"", + (unsigned)circuit->base_.n_circ_id, serviceid); + circuit_log_path(LOG_INFO, LD_REND, circuit); + + /* Send the ESTABLISH_INTRO cell */ + { + ssize_t len; + len = encode_establish_intro_cell_legacy(buf, sizeof(buf), + circuit->intro_key, + circuit->cpath->prev->rend_circ_nonce); + if (len < 0) { + reason = END_CIRC_REASON_INTERNAL; + goto err; + } + + if (relay_send_command_from_edge(0, TO_CIRCUIT(circuit), + RELAY_COMMAND_ESTABLISH_INTRO, + buf, len, circuit->cpath->prev)<0) { + log_info(LD_GENERAL, + ""Couldn't send introduction request for service %s on circuit %u"", + serviceid, (unsigned)circuit->base_.n_circ_id); + goto done; + } + } + + /* We've attempted to use this circuit */ + pathbias_count_use_attempt(circuit); + + goto done; + + err: + circuit_mark_for_close(TO_CIRCUIT(circuit), reason); + done: + memwipe(buf, 0, sizeof(buf)); + memwipe(serviceid, 0, sizeof(serviceid)); + + return; +} +",0,"rend_service_intro_has_opened(origin_circuit_t *circuit) +{ + rend_service_t *service; + char buf[RELAY_PAYLOAD_SIZE]; + char serviceid[REND_SERVICE_ID_LEN_BASE32+1]; + unsigned int expiring_nodes_len, num_ip_circuits, valid_ip_circuits = 0; + int reason = END_CIRC_REASON_TORPROTOCOL; + const char *rend_pk_digest; + + tor_assert(circuit->base_.purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO); + assert_circ_anonymity_ok(circuit, get_options()); + tor_assert(circuit->cpath); + tor_assert(circuit->rend_data); + /* XXX: This is version 2 specific (only on supported). */ + rend_pk_digest = (char *) rend_data_get_pk_digest(circuit->rend_data, NULL); + + base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1, + rend_pk_digest, REND_SERVICE_ID_LEN); + + service = rend_service_get_by_pk_digest(rend_pk_digest); + if (!service) { + log_warn(LD_REND, ""Unrecognized service ID %s on introduction circuit %u."", + safe_str_client(serviceid), (unsigned)circuit->base_.n_circ_id); + reason = END_CIRC_REASON_NOSUCHSERVICE; + goto err; + } + + /* Take the current amount of expiring nodes and the current amount of IP + * circuits and compute how many valid IP circuits we have. */ + expiring_nodes_len = (unsigned int) smartlist_len(service->expiring_nodes); + num_ip_circuits = count_intro_point_circuits(service); + /* Let's avoid an underflow. The valid_ip_circuits is initialized to 0 in + * case this condition turns out false because it means that all circuits + * are expiring so we need to keep this circuit. */ + if (num_ip_circuits > expiring_nodes_len) { + valid_ip_circuits = num_ip_circuits - expiring_nodes_len; + } + + /* If we already have enough introduction circuits for this service, + * redefine this one as a general circuit or close it, depending. + * Substract the amount of expiring nodes here because the circuits are + * still opened. */ + if (valid_ip_circuits > service->n_intro_points_wanted) { + const or_options_t *options = get_options(); + /* Remove the intro point associated with this circuit, it's being + * repurposed or closed thus cleanup memory. */ + rend_intro_point_t *intro = find_intro_point(circuit); + if (intro != NULL) { + smartlist_remove(service->intro_nodes, intro); + rend_intro_point_free(intro); + } + + if (options->ExcludeNodes) { + /* XXXX in some future version, we can test whether the transition is + allowed or not given the actual nodes in the circuit. But for now, + this case, we might as well close the thing. */ + log_info(LD_CIRC|LD_REND, ""We have just finished an introduction "" + ""circuit, but we already have enough. Closing it.""); + reason = END_CIRC_REASON_NONE; + goto err; + } else { + tor_assert(circuit->build_state->is_internal); + log_info(LD_CIRC|LD_REND, ""We have just finished an introduction "" + ""circuit, but we already have enough. Redefining purpose to "" + ""general; leaving as internal.""); + + circuit_change_purpose(TO_CIRCUIT(circuit), CIRCUIT_PURPOSE_C_GENERAL); + + { + rend_data_free(circuit->rend_data); + circuit->rend_data = NULL; + } + { + crypto_pk_t *intro_key = circuit->intro_key; + circuit->intro_key = NULL; + crypto_pk_free(intro_key); + } + + circuit_has_opened(circuit); + goto done; + } + } + + log_info(LD_REND, + ""Established circuit %u as introduction point for service %s"", + (unsigned)circuit->base_.n_circ_id, serviceid); + circuit_log_path(LOG_INFO, LD_REND, circuit); + + /* Send the ESTABLISH_INTRO cell */ + { + ssize_t len; + len = encode_establish_intro_cell_legacy(buf, sizeof(buf), + circuit->intro_key, + circuit->cpath->prev->rend_circ_nonce); + if (len < 0) { + reason = END_CIRC_REASON_INTERNAL; + goto err; + } + + if (relay_send_command_from_edge(0, TO_CIRCUIT(circuit), + RELAY_COMMAND_ESTABLISH_INTRO, + buf, len, circuit->cpath->prev)<0) { + log_info(LD_GENERAL, + ""Couldn't send introduction request for service %s on circuit %u"", + serviceid, (unsigned)circuit->base_.n_circ_id); + goto done; + } + } + + /* We've attempted to use this circuit */ + pathbias_count_use_attempt(circuit); + + goto done; + + err: + circuit_mark_for_close(TO_CIRCUIT(circuit), reason); + done: + memwipe(buf, 0, sizeof(buf)); + memwipe(serviceid, 0, sizeof(serviceid)); + + return; +} +","@@ -3372,6 +3372,8 @@ rend_service_intro_established(origin_circuit_t *circuit, + (unsigned)circuit->base_.n_circ_id); + goto err; + } ++ base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32 + 1, ++ rend_pk_digest, REND_SERVICE_ID_LEN); + /* We've just successfully established a intro circuit to one of our + * introduction point, account for it. */ + intro = find_intro_point(circuit); +@@ -3388,8 +3390,6 @@ rend_service_intro_established(origin_circuit_t *circuit, + service->desc_is_dirty = time(NULL); + circuit_change_purpose(TO_CIRCUIT(circuit), CIRCUIT_PURPOSE_S_INTRO); + +- base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32 + 1, +- rend_pk_digest, REND_SERVICE_ID_LEN); + log_info(LD_REND, + ""Received INTRO_ESTABLISHED cell on circuit %u for service %s"", + (unsigned)circuit->base_.n_circ_id, serviceid);",1139,1375,2048 +9397,"bool radeon_atom_get_clock_info(struct drm_device *dev) +{ + struct radeon_device *rdev = dev->dev_private; + struct radeon_mode_info *mode_info = &rdev->mode_info; + int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); + union firmware_info *firmware_info; + uint8_t frev, crev; + struct radeon_pll *p1pll = &rdev->clock.p1pll; + struct radeon_pll *p2pll = &rdev->clock.p2pll; + struct radeon_pll *dcpll = &rdev->clock.dcpll; + struct radeon_pll *spll = &rdev->clock.spll; + struct radeon_pll *mpll = &rdev->clock.mpll; + uint16_t data_offset; + + if (atom_parse_data_header(mode_info->atom_context, index, NULL, + &frev, &crev, &data_offset)) { + firmware_info = + (union firmware_info *)(mode_info->atom_context->bios + + data_offset); + /* pixel clocks */ + p1pll->reference_freq = + le16_to_cpu(firmware_info->info.usReferenceClock); + p1pll->reference_div = 0; + + if (crev < 2) + p1pll->pll_out_min = + le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); + else + p1pll->pll_out_min = + le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); + p1pll->pll_out_max = + le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); + + if (crev >= 4) { + p1pll->lcd_pll_out_min = + le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; + if (p1pll->lcd_pll_out_min == 0) + p1pll->lcd_pll_out_min = p1pll->pll_out_min; + p1pll->lcd_pll_out_max = + le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100; + if (p1pll->lcd_pll_out_max == 0) + p1pll->lcd_pll_out_max = p1pll->pll_out_max; + } else { + p1pll->lcd_pll_out_min = p1pll->pll_out_min; + p1pll->lcd_pll_out_max = p1pll->pll_out_max; + } + + if (p1pll->pll_out_min == 0) { + if (ASIC_IS_AVIVO(rdev)) + p1pll->pll_out_min = 64800; + else + p1pll->pll_out_min = 20000; + } else if (p1pll->pll_out_min > 64800) { + /* Limiting the pll output range is a good thing generally as + * it limits the number of possible pll combinations for a given + * frequency presumably to the ones that work best on each card. + * However, certain duallink DVI monitors seem to like + * pll combinations that would be limited by this at least on + * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per + * family. + */ + if (!radeon_new_pll) + p1pll->pll_out_min = 64800; + } + + p1pll->pll_in_min = + le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input); + p1pll->pll_in_max = + le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input); + + *p2pll = *p1pll; + + /* system clock */ + spll->reference_freq = + le16_to_cpu(firmware_info->info.usReferenceClock); + spll->reference_div = 0; + + spll->pll_out_min = + le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output); + spll->pll_out_max = + le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output); + + /* ??? */ + if (spll->pll_out_min == 0) { + if (ASIC_IS_AVIVO(rdev)) + spll->pll_out_min = 64800; + else + spll->pll_out_min = 20000; + } + + spll->pll_in_min = + le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input); + spll->pll_in_max = + le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input); + + /* memory clock */ + mpll->reference_freq = + le16_to_cpu(firmware_info->info.usReferenceClock); + mpll->reference_div = 0; + + mpll->pll_out_min = + le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output); + mpll->pll_out_max = + le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output); + + /* ??? */ + if (mpll->pll_out_min == 0) { + if (ASIC_IS_AVIVO(rdev)) + mpll->pll_out_min = 64800; + else + mpll->pll_out_min = 20000; + } + + mpll->pll_in_min = + le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input); + mpll->pll_in_max = + le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input); + + rdev->clock.default_sclk = + le32_to_cpu(firmware_info->info.ulDefaultEngineClock); + rdev->clock.default_mclk = + le32_to_cpu(firmware_info->info.ulDefaultMemoryClock); + + if (ASIC_IS_DCE4(rdev)) { + rdev->clock.default_dispclk = + le32_to_cpu(firmware_info->info_21.ulDefaultDispEngineClkFreq); + if (rdev->clock.default_dispclk == 0) + rdev->clock.default_dispclk = 60000; /* 600 Mhz */ + rdev->clock.dp_extclk = + le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq); + } + *dcpll = *p1pll; + + return true; + } + + return false; +} +",0,"bool radeon_atom_get_clock_info(struct drm_device *dev) +{ + struct radeon_device *rdev = dev->dev_private; + struct radeon_mode_info *mode_info = &rdev->mode_info; + int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); + union firmware_info *firmware_info; + uint8_t frev, crev; + struct radeon_pll *p1pll = &rdev->clock.p1pll; + struct radeon_pll *p2pll = &rdev->clock.p2pll; + struct radeon_pll *dcpll = &rdev->clock.dcpll; + struct radeon_pll *spll = &rdev->clock.spll; + struct radeon_pll *mpll = &rdev->clock.mpll; + uint16_t data_offset; + + if (atom_parse_data_header(mode_info->atom_context, index, NULL, + &frev, &crev, &data_offset)) { + firmware_info = + (union firmware_info *)(mode_info->atom_context->bios + + data_offset); + /* pixel clocks */ + p1pll->reference_freq = + le16_to_cpu(firmware_info->info.usReferenceClock); + p1pll->reference_div = 0; + + if (crev < 2) + p1pll->pll_out_min = + le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); + else + p1pll->pll_out_min = + le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); + p1pll->pll_out_max = + le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); + + if (crev >= 4) { + p1pll->lcd_pll_out_min = + le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; + if (p1pll->lcd_pll_out_min == 0) + p1pll->lcd_pll_out_min = p1pll->pll_out_min; + p1pll->lcd_pll_out_max = + le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100; + if (p1pll->lcd_pll_out_max == 0) + p1pll->lcd_pll_out_max = p1pll->pll_out_max; + } else { + p1pll->lcd_pll_out_min = p1pll->pll_out_min; + p1pll->lcd_pll_out_max = p1pll->pll_out_max; + } + + if (p1pll->pll_out_min == 0) { + if (ASIC_IS_AVIVO(rdev)) + p1pll->pll_out_min = 64800; + else + p1pll->pll_out_min = 20000; + } else if (p1pll->pll_out_min > 64800) { + /* Limiting the pll output range is a good thing generally as + * it limits the number of possible pll combinations for a given + * frequency presumably to the ones that work best on each card. + * However, certain duallink DVI monitors seem to like + * pll combinations that would be limited by this at least on + * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per + * family. + */ + if (!radeon_new_pll) + p1pll->pll_out_min = 64800; + } + + p1pll->pll_in_min = + le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input); + p1pll->pll_in_max = + le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input); + + *p2pll = *p1pll; + + /* system clock */ + spll->reference_freq = + le16_to_cpu(firmware_info->info.usReferenceClock); + spll->reference_div = 0; + + spll->pll_out_min = + le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output); + spll->pll_out_max = + le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output); + + /* ??? */ + if (spll->pll_out_min == 0) { + if (ASIC_IS_AVIVO(rdev)) + spll->pll_out_min = 64800; + else + spll->pll_out_min = 20000; + } + + spll->pll_in_min = + le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input); + spll->pll_in_max = + le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input); + + /* memory clock */ + mpll->reference_freq = + le16_to_cpu(firmware_info->info.usReferenceClock); + mpll->reference_div = 0; + + mpll->pll_out_min = + le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output); + mpll->pll_out_max = + le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output); + + /* ??? */ + if (mpll->pll_out_min == 0) { + if (ASIC_IS_AVIVO(rdev)) + mpll->pll_out_min = 64800; + else + mpll->pll_out_min = 20000; + } + + mpll->pll_in_min = + le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input); + mpll->pll_in_max = + le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input); + + rdev->clock.default_sclk = + le32_to_cpu(firmware_info->info.ulDefaultEngineClock); + rdev->clock.default_mclk = + le32_to_cpu(firmware_info->info.ulDefaultMemoryClock); + + if (ASIC_IS_DCE4(rdev)) { + rdev->clock.default_dispclk = + le32_to_cpu(firmware_info->info_21.ulDefaultDispEngineClkFreq); + if (rdev->clock.default_dispclk == 0) + rdev->clock.default_dispclk = 60000; /* 600 Mhz */ + rdev->clock.dp_extclk = + le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq); + } + *dcpll = *p1pll; + + return true; + } + + return false; +} +","@@ -1264,7 +1264,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, + switch (crev) { + case 1: + tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); +- if (index > MAX_SUPPORTED_TV_TIMING) ++ if (index >= MAX_SUPPORTED_TV_TIMING) + return false; + + mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); +@@ -1302,7 +1302,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, + break; + case 2: + tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); +- if (index > MAX_SUPPORTED_TV_TIMING_V1_2) ++ if (index >= MAX_SUPPORTED_TV_TIMING_V1_2) + return false; + + dtd_timings = &tv_info_v1_2->aModeTimings[index];",1436,1672,2048 +9420,"static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) +{ + struct vm_area_struct *mpnt, *tmp, **pprev; + struct rb_node **rb_link, *rb_parent; + int retval; + unsigned long charge; + struct mempolicy *pol; + + down_write(&oldmm->mmap_sem); + flush_cache_dup_mm(oldmm); + /* + * Not linked in yet - no deadlock potential: + */ + down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING); + + mm->locked_vm = 0; + mm->mmap = NULL; + mm->mmap_cache = NULL; + mm->free_area_cache = oldmm->mmap_base; + mm->cached_hole_size = ~0UL; + mm->map_count = 0; + cpumask_clear(mm_cpumask(mm)); + mm->mm_rb = RB_ROOT; + rb_link = &mm->mm_rb.rb_node; + rb_parent = NULL; + pprev = &mm->mmap; + retval = ksm_fork(mm, oldmm); + if (retval) + goto out; + + for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) { + struct file *file; + + if (mpnt->vm_flags & VM_DONTCOPY) { + long pages = vma_pages(mpnt); + mm->total_vm -= pages; + vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file, + -pages); + continue; + } + charge = 0; + if (mpnt->vm_flags & VM_ACCOUNT) { + unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; + if (security_vm_enough_memory(len)) + goto fail_nomem; + charge = len; + } + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); + if (!tmp) + goto fail_nomem; + *tmp = *mpnt; + pol = mpol_dup(vma_policy(mpnt)); + retval = PTR_ERR(pol); + if (IS_ERR(pol)) + goto fail_nomem_policy; + vma_set_policy(tmp, pol); + tmp->vm_flags &= ~VM_LOCKED; + tmp->vm_mm = mm; + tmp->vm_next = NULL; + anon_vma_link(tmp); + file = tmp->vm_file; + if (file) { + struct inode *inode = file->f_path.dentry->d_inode; + struct address_space *mapping = file->f_mapping; + + get_file(file); + if (tmp->vm_flags & VM_DENYWRITE) + atomic_dec(&inode->i_writecount); + spin_lock(&mapping->i_mmap_lock); + if (tmp->vm_flags & VM_SHARED) + mapping->i_mmap_writable++; + tmp->vm_truncate_count = mpnt->vm_truncate_count; + flush_dcache_mmap_lock(mapping); + /* insert tmp into the share list, just after mpnt */ + vma_prio_tree_add(tmp, mpnt); + flush_dcache_mmap_unlock(mapping); + spin_unlock(&mapping->i_mmap_lock); + } + + /* + * Clear hugetlb-related page reserves for children. This only + * affects MAP_PRIVATE mappings. Faults generated by the child + * are not guaranteed to succeed, even if read-only + */ + if (is_vm_hugetlb_page(tmp)) + reset_vma_resv_huge_pages(tmp); + + /* + * Link in the new vma and copy the page table entries. + */ + *pprev = tmp; + pprev = &tmp->vm_next; + + __vma_link_rb(mm, tmp, rb_link, rb_parent); + rb_link = &tmp->vm_rb.rb_right; + rb_parent = &tmp->vm_rb; + + mm->map_count++; + retval = copy_page_range(mm, oldmm, mpnt); + + if (tmp->vm_ops && tmp->vm_ops->open) + tmp->vm_ops->open(tmp); + + if (retval) + goto out; + } + /* a new mm has just been created */ + arch_dup_mmap(oldmm, mm); + retval = 0; +out: + up_write(&mm->mmap_sem); + flush_tlb_mm(oldmm); + up_write(&oldmm->mmap_sem); + return retval; +fail_nomem_policy: + kmem_cache_free(vm_area_cachep, tmp); +fail_nomem: + retval = -ENOMEM; + vm_unacct_memory(charge); + goto out; +} +",0,"static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) +{ + struct vm_area_struct *mpnt, *tmp, **pprev; + struct rb_node **rb_link, *rb_parent; + int retval; + unsigned long charge; + struct mempolicy *pol; + + down_write(&oldmm->mmap_sem); + flush_cache_dup_mm(oldmm); + /* + * Not linked in yet - no deadlock potential: + */ + down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING); + + mm->locked_vm = 0; + mm->mmap = NULL; + mm->mmap_cache = NULL; + mm->free_area_cache = oldmm->mmap_base; + mm->cached_hole_size = ~0UL; + mm->map_count = 0; + cpumask_clear(mm_cpumask(mm)); + mm->mm_rb = RB_ROOT; + rb_link = &mm->mm_rb.rb_node; + rb_parent = NULL; + pprev = &mm->mmap; + retval = ksm_fork(mm, oldmm); + if (retval) + goto out; + + for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) { + struct file *file; + + if (mpnt->vm_flags & VM_DONTCOPY) { + long pages = vma_pages(mpnt); + mm->total_vm -= pages; + vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file, + -pages); + continue; + } + charge = 0; + if (mpnt->vm_flags & VM_ACCOUNT) { + unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; + if (security_vm_enough_memory(len)) + goto fail_nomem; + charge = len; + } + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); + if (!tmp) + goto fail_nomem; + *tmp = *mpnt; + pol = mpol_dup(vma_policy(mpnt)); + retval = PTR_ERR(pol); + if (IS_ERR(pol)) + goto fail_nomem_policy; + vma_set_policy(tmp, pol); + tmp->vm_flags &= ~VM_LOCKED; + tmp->vm_mm = mm; + tmp->vm_next = NULL; + anon_vma_link(tmp); + file = tmp->vm_file; + if (file) { + struct inode *inode = file->f_path.dentry->d_inode; + struct address_space *mapping = file->f_mapping; + + get_file(file); + if (tmp->vm_flags & VM_DENYWRITE) + atomic_dec(&inode->i_writecount); + spin_lock(&mapping->i_mmap_lock); + if (tmp->vm_flags & VM_SHARED) + mapping->i_mmap_writable++; + tmp->vm_truncate_count = mpnt->vm_truncate_count; + flush_dcache_mmap_lock(mapping); + /* insert tmp into the share list, just after mpnt */ + vma_prio_tree_add(tmp, mpnt); + flush_dcache_mmap_unlock(mapping); + spin_unlock(&mapping->i_mmap_lock); + } + + /* + * Clear hugetlb-related page reserves for children. This only + * affects MAP_PRIVATE mappings. Faults generated by the child + * are not guaranteed to succeed, even if read-only + */ + if (is_vm_hugetlb_page(tmp)) + reset_vma_resv_huge_pages(tmp); + + /* + * Link in the new vma and copy the page table entries. + */ + *pprev = tmp; + pprev = &tmp->vm_next; + + __vma_link_rb(mm, tmp, rb_link, rb_parent); + rb_link = &tmp->vm_rb.rb_right; + rb_parent = &tmp->vm_rb; + + mm->map_count++; + retval = copy_page_range(mm, oldmm, mpnt); + + if (tmp->vm_ops && tmp->vm_ops->open) + tmp->vm_ops->open(tmp); + + if (retval) + goto out; + } + /* a new mm has just been created */ + arch_dup_mmap(oldmm, mm); + retval = 0; +out: + up_write(&mm->mmap_sem); + flush_tlb_mm(oldmm); + up_write(&oldmm->mmap_sem); + return retval; +fail_nomem_policy: + kmem_cache_free(vm_area_cachep, tmp); +fail_nomem: + retval = -ENOMEM; + vm_unacct_memory(charge); + goto out; +} +","@@ -1310,7 +1310,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, + if (pid != &init_struct_pid) + free_pid(pid); + bad_fork_cleanup_io: +- put_io_context(p->io_context); ++ if (p->io_context) ++ exit_io_context(p); + bad_fork_cleanup_namespaces: + exit_task_namespaces(p); + bad_fork_cleanup_mm:",983,1219,2048 +9645,"MagickExport void *FileToBlob(const char *filename,const size_t extent, + size_t *length,ExceptionInfo *exception) +{ + int + file; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + register size_t + i; + + ssize_t + count; + + struct stat + attributes; + + unsigned char + *blob; + + void + *map; + + assert(filename != (const char *) NULL); + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",filename); + assert(exception != (ExceptionInfo *) NULL); + *length=0; + status=IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,filename); + if (status == MagickFalse) + { + errno=EPERM; + (void) ThrowMagickException(exception,GetMagickModule(),PolicyError, + ""NotAuthorized"",""`%s'"",filename); + return(NULL); + } + file=fileno(stdin); + if (LocaleCompare(filename,""-"") != 0) + { + status=GetPathAttributes(filename,&attributes); + if ((status == MagickFalse) || (S_ISDIR(attributes.st_mode) != 0)) + { + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + return(NULL); + } + file=open_utf8(filename,O_RDONLY | O_BINARY,0); + } + if (file == -1) + { + ThrowFileException(exception,BlobError,""UnableToOpenFile"",filename); + return(NULL); + } + offset=(MagickOffsetType) lseek(file,0,SEEK_END); + count=0; + if ((file == fileno(stdin)) || (offset < 0) || + (offset != (MagickOffsetType) ((ssize_t) offset))) + { + size_t + quantum; + + struct stat + file_stats; + + /* + Stream is not seekable. + */ + offset=(MagickOffsetType) lseek(file,0,SEEK_SET); + quantum=(size_t) MagickMaxBufferExtent; + if ((fstat(file,&file_stats) == 0) && (file_stats.st_size > 0)) + quantum=(size_t) MagickMin(file_stats.st_size,MagickMaxBufferExtent); + blob=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*blob)); + for (i=0; blob != (unsigned char *) NULL; i+=count) + { + count=read(file,blob+i,quantum); + if (count <= 0) + { + count=0; + if (errno != EINTR) + break; + } + if (~((size_t) i) < (quantum+1)) + { + blob=(unsigned char *) RelinquishMagickMemory(blob); + break; + } + blob=(unsigned char *) ResizeQuantumMemory(blob,i+quantum+1, + sizeof(*blob)); + if ((size_t) (i+count) >= extent) + break; + } + if (LocaleCompare(filename,""-"") != 0) + file=close(file); + if (blob == (unsigned char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",filename); + return(NULL); + } + if (file == -1) + { + blob=(unsigned char *) RelinquishMagickMemory(blob); + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + return(NULL); + } + *length=(size_t) MagickMin(i+count,extent); + blob[*length]='\0'; + return(blob); + } + *length=(size_t) MagickMin(offset,(MagickOffsetType) + MagickMin(extent,(size_t) SSIZE_MAX)); + blob=(unsigned char *) NULL; + if (~(*length) >= (MagickPathExtent-1)) + blob=(unsigned char *) AcquireQuantumMemory(*length+MagickPathExtent, + sizeof(*blob)); + if (blob == (unsigned char *) NULL) + { + file=close(file); + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",filename); + return(NULL); + } + map=MapBlob(file,ReadMode,0,*length); + if (map != (unsigned char *) NULL) + { + (void) memcpy(blob,map,*length); + (void) UnmapBlob(map,*length); + } + else + { + (void) lseek(file,0,SEEK_SET); + for (i=0; i < *length; i+=count) + { + count=read(file,blob+i,(size_t) MagickMin(*length-i,(size_t) + SSIZE_MAX)); + if (count <= 0) + { + count=0; + if (errno != EINTR) + break; + } + } + if (i < *length) + { + file=close(file)-1; + blob=(unsigned char *) RelinquishMagickMemory(blob); + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + return(NULL); + } + } + blob[*length]='\0'; + if (LocaleCompare(filename,""-"") != 0) + file=close(file); + if (file == -1) + { + blob=(unsigned char *) RelinquishMagickMemory(blob); + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + } + return(blob); +} +",0,"MagickExport void *FileToBlob(const char *filename,const size_t extent, + size_t *length,ExceptionInfo *exception) +{ + int + file; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + register size_t + i; + + ssize_t + count; + + struct stat + attributes; + + unsigned char + *blob; + + void + *map; + + assert(filename != (const char *) NULL); + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",filename); + assert(exception != (ExceptionInfo *) NULL); + *length=0; + status=IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,filename); + if (status == MagickFalse) + { + errno=EPERM; + (void) ThrowMagickException(exception,GetMagickModule(),PolicyError, + ""NotAuthorized"",""`%s'"",filename); + return(NULL); + } + file=fileno(stdin); + if (LocaleCompare(filename,""-"") != 0) + { + status=GetPathAttributes(filename,&attributes); + if ((status == MagickFalse) || (S_ISDIR(attributes.st_mode) != 0)) + { + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + return(NULL); + } + file=open_utf8(filename,O_RDONLY | O_BINARY,0); + } + if (file == -1) + { + ThrowFileException(exception,BlobError,""UnableToOpenFile"",filename); + return(NULL); + } + offset=(MagickOffsetType) lseek(file,0,SEEK_END); + count=0; + if ((file == fileno(stdin)) || (offset < 0) || + (offset != (MagickOffsetType) ((ssize_t) offset))) + { + size_t + quantum; + + struct stat + file_stats; + + /* + Stream is not seekable. + */ + offset=(MagickOffsetType) lseek(file,0,SEEK_SET); + quantum=(size_t) MagickMaxBufferExtent; + if ((fstat(file,&file_stats) == 0) && (file_stats.st_size > 0)) + quantum=(size_t) MagickMin(file_stats.st_size,MagickMaxBufferExtent); + blob=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*blob)); + for (i=0; blob != (unsigned char *) NULL; i+=count) + { + count=read(file,blob+i,quantum); + if (count <= 0) + { + count=0; + if (errno != EINTR) + break; + } + if (~((size_t) i) < (quantum+1)) + { + blob=(unsigned char *) RelinquishMagickMemory(blob); + break; + } + blob=(unsigned char *) ResizeQuantumMemory(blob,i+quantum+1, + sizeof(*blob)); + if ((size_t) (i+count) >= extent) + break; + } + if (LocaleCompare(filename,""-"") != 0) + file=close(file); + if (blob == (unsigned char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",filename); + return(NULL); + } + if (file == -1) + { + blob=(unsigned char *) RelinquishMagickMemory(blob); + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + return(NULL); + } + *length=(size_t) MagickMin(i+count,extent); + blob[*length]='\0'; + return(blob); + } + *length=(size_t) MagickMin(offset,(MagickOffsetType) + MagickMin(extent,(size_t) SSIZE_MAX)); + blob=(unsigned char *) NULL; + if (~(*length) >= (MagickPathExtent-1)) + blob=(unsigned char *) AcquireQuantumMemory(*length+MagickPathExtent, + sizeof(*blob)); + if (blob == (unsigned char *) NULL) + { + file=close(file); + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",filename); + return(NULL); + } + map=MapBlob(file,ReadMode,0,*length); + if (map != (unsigned char *) NULL) + { + (void) memcpy(blob,map,*length); + (void) UnmapBlob(map,*length); + } + else + { + (void) lseek(file,0,SEEK_SET); + for (i=0; i < *length; i+=count) + { + count=read(file,blob+i,(size_t) MagickMin(*length-i,(size_t) + SSIZE_MAX)); + if (count <= 0) + { + count=0; + if (errno != EINTR) + break; + } + } + if (i < *length) + { + file=close(file)-1; + blob=(unsigned char *) RelinquishMagickMemory(blob); + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + return(NULL); + } + } + blob[*length]='\0'; + if (LocaleCompare(filename,""-"") != 0) + file=close(file); + if (file == -1) + { + blob=(unsigned char *) RelinquishMagickMemory(blob); + ThrowFileException(exception,BlobError,""UnableToReadBlob"",filename); + } + return(blob); +} +","@@ -996,6 +996,7 @@ MagickExport void *DetachBlob(BlobInfo *blob_info) + if (blob_info->mapped != MagickFalse) + { + (void) UnmapBlob(blob_info->data,blob_info->length); ++ blob_info->data=NULL; + RelinquishMagickResource(MapResource,blob_info->length); + } + blob_info->mapped=MagickFalse;",1184,1420,2048 +6166,"OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *p_tcd, + OPJ_BYTE *p_src, + OPJ_UINT32 p_max_length, + OPJ_UINT32 p_tile_no, + opj_codestream_index_t *p_cstr_index, + opj_event_mgr_t *p_manager + ) +{ + OPJ_UINT32 l_data_read; + p_tcd->tcd_tileno = p_tile_no; + p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]); + +#ifdef TODO_MSD /* FIXME */ + /* INDEX >> */ + if (p_cstr_info) { + OPJ_UINT32 resno, compno, numprec = 0; + for (compno = 0; compno < (OPJ_UINT32) p_cstr_info->numcomps; compno++) { + opj_tcp_t *tcp = &p_tcd->cp->tcps[0]; + opj_tccp_t *tccp = &tcp->tccps[compno]; + opj_tcd_tilecomp_t *tilec_idx = &p_tcd->tcd_image->tiles->comps[compno]; + for (resno = 0; resno < tilec_idx->numresolutions; resno++) { + opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno]; + p_cstr_info->tile[p_tile_no].pw[resno] = res_idx->pw; + p_cstr_info->tile[p_tile_no].ph[resno] = res_idx->ph; + numprec += res_idx->pw * res_idx->ph; + p_cstr_info->tile[p_tile_no].pdx[resno] = tccp->prcw[resno]; + p_cstr_info->tile[p_tile_no].pdy[resno] = tccp->prch[resno]; + } + } + p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_malloc( + p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t)); + p_cstr_info->packno = 0; + } + /* << INDEX */ +#endif + + /*--------------TIER2------------------*/ + /* FIXME _ProfStart(PGROUP_T2); */ + l_data_read = 0; + if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index, + p_manager)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_T2); */ + + /*------------------TIER1-----------------*/ + + /* FIXME _ProfStart(PGROUP_T1); */ + if (! opj_tcd_t1_decode(p_tcd, p_manager)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_T1); */ + + /*----------------DWT---------------------*/ + + /* FIXME _ProfStart(PGROUP_DWT); */ + if + (! opj_tcd_dwt_decode(p_tcd)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_DWT); */ + + /*----------------MCT-------------------*/ + /* FIXME _ProfStart(PGROUP_MCT); */ + if + (! opj_tcd_mct_decode(p_tcd, p_manager)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_MCT); */ + + /* FIXME _ProfStart(PGROUP_DC_SHIFT); */ + if + (! opj_tcd_dc_level_shift_decode(p_tcd)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_DC_SHIFT); */ + + + /*---------------TILE-------------------*/ + return OPJ_TRUE; +} +",0,"OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *p_tcd, + OPJ_BYTE *p_src, + OPJ_UINT32 p_max_length, + OPJ_UINT32 p_tile_no, + opj_codestream_index_t *p_cstr_index, + opj_event_mgr_t *p_manager + ) +{ + OPJ_UINT32 l_data_read; + p_tcd->tcd_tileno = p_tile_no; + p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]); + +#ifdef TODO_MSD /* FIXME */ + /* INDEX >> */ + if (p_cstr_info) { + OPJ_UINT32 resno, compno, numprec = 0; + for (compno = 0; compno < (OPJ_UINT32) p_cstr_info->numcomps; compno++) { + opj_tcp_t *tcp = &p_tcd->cp->tcps[0]; + opj_tccp_t *tccp = &tcp->tccps[compno]; + opj_tcd_tilecomp_t *tilec_idx = &p_tcd->tcd_image->tiles->comps[compno]; + for (resno = 0; resno < tilec_idx->numresolutions; resno++) { + opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno]; + p_cstr_info->tile[p_tile_no].pw[resno] = res_idx->pw; + p_cstr_info->tile[p_tile_no].ph[resno] = res_idx->ph; + numprec += res_idx->pw * res_idx->ph; + p_cstr_info->tile[p_tile_no].pdx[resno] = tccp->prcw[resno]; + p_cstr_info->tile[p_tile_no].pdy[resno] = tccp->prch[resno]; + } + } + p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_malloc( + p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t)); + p_cstr_info->packno = 0; + } + /* << INDEX */ +#endif + + /*--------------TIER2------------------*/ + /* FIXME _ProfStart(PGROUP_T2); */ + l_data_read = 0; + if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index, + p_manager)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_T2); */ + + /*------------------TIER1-----------------*/ + + /* FIXME _ProfStart(PGROUP_T1); */ + if (! opj_tcd_t1_decode(p_tcd, p_manager)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_T1); */ + + /*----------------DWT---------------------*/ + + /* FIXME _ProfStart(PGROUP_DWT); */ + if + (! opj_tcd_dwt_decode(p_tcd)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_DWT); */ + + /*----------------MCT-------------------*/ + /* FIXME _ProfStart(PGROUP_MCT); */ + if + (! opj_tcd_mct_decode(p_tcd, p_manager)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_MCT); */ + + /* FIXME _ProfStart(PGROUP_DC_SHIFT); */ + if + (! opj_tcd_dc_level_shift_decode(p_tcd)) { + return OPJ_FALSE; + } + /* FIXME _ProfStop(PGROUP_DC_SHIFT); */ + + + /*---------------TILE-------------------*/ + return OPJ_TRUE; +} +","@@ -1187,8 +1187,11 @@ static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t * + { + OPJ_UINT32 l_data_size; + +- /* The +1 is needed for https://github.com/uclouvain/openjpeg/issues/835 */ +- l_data_size = 1 + (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) * ++ /* +1 is needed for https://github.com/uclouvain/openjpeg/issues/835 */ ++ /* and actually +2 required for https://github.com/uclouvain/openjpeg/issues/982 */ ++ /* TODO: is there a theoretical upper-bound for the compressed code */ ++ /* block size ? */ ++ l_data_size = 2 + (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) * + (p_code_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32)); + + if (l_data_size > p_code_block->data_size) {",813,1049,2048 +4506,"int lxc_setup(struct lxc_handler *handler) +{ + const char *name = handler->name; + struct lxc_conf *lxc_conf = handler->conf; + const char *lxcpath = handler->lxcpath; + + if (do_rootfs_setup(lxc_conf, name, lxcpath) < 0) { + ERROR(""Error setting up rootfs mount after spawn""); + return -1; + } + + if (lxc_conf->inherit_ns_fd[LXC_NS_UTS] == -1) { + if (setup_utsname(lxc_conf->utsname)) { + ERROR(""failed to setup the utsname for '%s'"", name); + return -1; + } + } + + if (setup_network(&lxc_conf->network)) { + ERROR(""failed to setup the network for '%s'"", name); + return -1; + } + + if (lxc_conf->autodev > 0) { + if (mount_autodev(name, &lxc_conf->rootfs, lxcpath)) { + ERROR(""failed to mount /dev in the container""); + return -1; + } + } + + /* do automatic mounts (mainly /proc and /sys), but exclude + * those that need to wait until other stuff has finished + */ + if (lxc_mount_auto_mounts(lxc_conf, lxc_conf->auto_mounts & ~LXC_AUTO_CGROUP_MASK, handler) < 0) { + ERROR(""failed to setup the automatic mounts for '%s'"", name); + return -1; + } + + if (setup_mount(&lxc_conf->rootfs, lxc_conf->fstab, name)) { + ERROR(""failed to setup the mounts for '%s'"", name); + return -1; + } + + if (!lxc_list_empty(&lxc_conf->mount_list) && setup_mount_entries(&lxc_conf->rootfs, &lxc_conf->mount_list, name)) { + ERROR(""failed to setup the mount entries for '%s'"", name); + return -1; + } + + /* Make sure any start hooks are in the container */ + if (!verify_start_hooks(lxc_conf)) + return -1; + + if (lxc_conf->is_execute) + lxc_execute_bind_init(lxc_conf); + + /* now mount only cgroup, if wanted; + * before, /sys could not have been mounted + * (is either mounted automatically or via fstab entries) + */ + if (lxc_mount_auto_mounts(lxc_conf, lxc_conf->auto_mounts & LXC_AUTO_CGROUP_MASK, handler) < 0) { + ERROR(""failed to setup the automatic mounts for '%s'"", name); + return -1; + } + + if (run_lxc_hooks(name, ""mount"", lxc_conf, lxcpath, NULL)) { + ERROR(""failed to run mount hooks for container '%s'."", name); + return -1; + } + + if (lxc_conf->autodev > 0) { + if (run_lxc_hooks(name, ""autodev"", lxc_conf, lxcpath, NULL)) { + ERROR(""failed to run autodev hooks for container '%s'."", name); + return -1; + } + if (fill_autodev(&lxc_conf->rootfs)) { + ERROR(""failed to populate /dev in the container""); + return -1; + } + } + + if (!lxc_conf->is_execute && setup_console(&lxc_conf->rootfs, &lxc_conf->console, lxc_conf->ttydir)) { + ERROR(""failed to setup the console for '%s'"", name); + return -1; + } + + if (lxc_conf->kmsg) { + if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console)) // don't fail + ERROR(""failed to setup kmsg for '%s'"", name); + } + + if (!lxc_conf->is_execute && setup_dev_symlinks(&lxc_conf->rootfs)) { + ERROR(""failed to setup /dev symlinks for '%s'"", name); + return -1; + } + + /* mount /proc if it's not already there */ + if (tmp_proc_mount(lxc_conf) < 0) { + ERROR(""failed to LSM mount proc for '%s'"", name); + return -1; + } + + if (setup_pivot_root(&lxc_conf->rootfs)) { + ERROR(""failed to set rootfs for '%s'"", name); + return -1; + } + + if (setup_pts(lxc_conf->pts)) { + ERROR(""failed to setup the new pts instance""); + return -1; + } + + if (lxc_create_tty(name, lxc_conf)) { + ERROR(""failed to create the ttys""); + return -1; + } + + if (send_ttys_to_parent(handler) < 0) { + ERROR(""failure sending console info to parent""); + return -1; + } + + + if (!lxc_conf->is_execute && setup_tty(lxc_conf)) { + ERROR(""failed to setup the ttys for '%s'"", name); + return -1; + } + + if (lxc_conf->pty_names && setenv(""container_ttys"", lxc_conf->pty_names, 1)) + SYSERROR(""failed to set environment variable for container ptys""); + + + if (setup_personality(lxc_conf->personality)) { + ERROR(""failed to setup personality""); + return -1; + } + + if (!lxc_list_empty(&lxc_conf->keepcaps)) { + if (!lxc_list_empty(&lxc_conf->caps)) { + ERROR(""Simultaneously requested dropping and keeping caps""); + return -1; + } + if (dropcaps_except(&lxc_conf->keepcaps)) { + ERROR(""failed to keep requested caps""); + return -1; + } + } else if (setup_caps(&lxc_conf->caps)) { + ERROR(""failed to drop capabilities""); + return -1; + } + + NOTICE(""'%s' is setup."", name); + + return 0; +} +",0,"int lxc_setup(struct lxc_handler *handler) +{ + const char *name = handler->name; + struct lxc_conf *lxc_conf = handler->conf; + const char *lxcpath = handler->lxcpath; + + if (do_rootfs_setup(lxc_conf, name, lxcpath) < 0) { + ERROR(""Error setting up rootfs mount after spawn""); + return -1; + } + + if (lxc_conf->inherit_ns_fd[LXC_NS_UTS] == -1) { + if (setup_utsname(lxc_conf->utsname)) { + ERROR(""failed to setup the utsname for '%s'"", name); + return -1; + } + } + + if (setup_network(&lxc_conf->network)) { + ERROR(""failed to setup the network for '%s'"", name); + return -1; + } + + if (lxc_conf->autodev > 0) { + if (mount_autodev(name, &lxc_conf->rootfs, lxcpath)) { + ERROR(""failed to mount /dev in the container""); + return -1; + } + } + + /* do automatic mounts (mainly /proc and /sys), but exclude + * those that need to wait until other stuff has finished + */ + if (lxc_mount_auto_mounts(lxc_conf, lxc_conf->auto_mounts & ~LXC_AUTO_CGROUP_MASK, handler) < 0) { + ERROR(""failed to setup the automatic mounts for '%s'"", name); + return -1; + } + + if (setup_mount(&lxc_conf->rootfs, lxc_conf->fstab, name)) { + ERROR(""failed to setup the mounts for '%s'"", name); + return -1; + } + + if (!lxc_list_empty(&lxc_conf->mount_list) && setup_mount_entries(&lxc_conf->rootfs, &lxc_conf->mount_list, name)) { + ERROR(""failed to setup the mount entries for '%s'"", name); + return -1; + } + + /* Make sure any start hooks are in the container */ + if (!verify_start_hooks(lxc_conf)) + return -1; + + if (lxc_conf->is_execute) + lxc_execute_bind_init(lxc_conf); + + /* now mount only cgroup, if wanted; + * before, /sys could not have been mounted + * (is either mounted automatically or via fstab entries) + */ + if (lxc_mount_auto_mounts(lxc_conf, lxc_conf->auto_mounts & LXC_AUTO_CGROUP_MASK, handler) < 0) { + ERROR(""failed to setup the automatic mounts for '%s'"", name); + return -1; + } + + if (run_lxc_hooks(name, ""mount"", lxc_conf, lxcpath, NULL)) { + ERROR(""failed to run mount hooks for container '%s'."", name); + return -1; + } + + if (lxc_conf->autodev > 0) { + if (run_lxc_hooks(name, ""autodev"", lxc_conf, lxcpath, NULL)) { + ERROR(""failed to run autodev hooks for container '%s'."", name); + return -1; + } + if (fill_autodev(&lxc_conf->rootfs)) { + ERROR(""failed to populate /dev in the container""); + return -1; + } + } + + if (!lxc_conf->is_execute && setup_console(&lxc_conf->rootfs, &lxc_conf->console, lxc_conf->ttydir)) { + ERROR(""failed to setup the console for '%s'"", name); + return -1; + } + + if (lxc_conf->kmsg) { + if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console)) // don't fail + ERROR(""failed to setup kmsg for '%s'"", name); + } + + if (!lxc_conf->is_execute && setup_dev_symlinks(&lxc_conf->rootfs)) { + ERROR(""failed to setup /dev symlinks for '%s'"", name); + return -1; + } + + /* mount /proc if it's not already there */ + if (tmp_proc_mount(lxc_conf) < 0) { + ERROR(""failed to LSM mount proc for '%s'"", name); + return -1; + } + + if (setup_pivot_root(&lxc_conf->rootfs)) { + ERROR(""failed to set rootfs for '%s'"", name); + return -1; + } + + if (setup_pts(lxc_conf->pts)) { + ERROR(""failed to setup the new pts instance""); + return -1; + } + + if (lxc_create_tty(name, lxc_conf)) { + ERROR(""failed to create the ttys""); + return -1; + } + + if (send_ttys_to_parent(handler) < 0) { + ERROR(""failure sending console info to parent""); + return -1; + } + + + if (!lxc_conf->is_execute && setup_tty(lxc_conf)) { + ERROR(""failed to setup the ttys for '%s'"", name); + return -1; + } + + if (lxc_conf->pty_names && setenv(""container_ttys"", lxc_conf->pty_names, 1)) + SYSERROR(""failed to set environment variable for container ptys""); + + + if (setup_personality(lxc_conf->personality)) { + ERROR(""failed to setup personality""); + return -1; + } + + if (!lxc_list_empty(&lxc_conf->keepcaps)) { + if (!lxc_list_empty(&lxc_conf->caps)) { + ERROR(""Simultaneously requested dropping and keeping caps""); + return -1; + } + if (dropcaps_except(&lxc_conf->keepcaps)) { + ERROR(""failed to keep requested caps""); + return -1; + } + } else if (setup_caps(&lxc_conf->caps)) { + ERROR(""failed to drop capabilities""); + return -1; + } + + NOTICE(""'%s' is setup."", name); + + return 0; +} +","@@ -769,10 +769,11 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha + * 2.6.32... + */ + { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""proc"", ""%r/proc"", ""proc"", MS_NODEV|MS_NOEXEC|MS_NOSUID, NULL }, +- { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""%r/proc/sys/net"", ""%r/proc/net"", NULL, MS_BIND, NULL }, ++ /* proc/tty is used as a temporary placeholder for proc/sys/net which we'll move back in a few steps */ ++ { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""%r/proc/sys/net"", ""%r/proc/tty"", NULL, MS_BIND, NULL }, + { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""%r/proc/sys"", ""%r/proc/sys"", NULL, MS_BIND, NULL }, + { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, NULL, ""%r/proc/sys"", NULL, MS_REMOUNT|MS_BIND|MS_RDONLY, NULL }, +- { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""%r/proc/net"", ""%r/proc/sys/net"", NULL, MS_MOVE, NULL }, ++ { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""%r/proc/tty"", ""%r/proc/sys/net"", NULL, MS_MOVE, NULL }, + { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, ""%r/proc/sysrq-trigger"", ""%r/proc/sysrq-trigger"", NULL, MS_BIND, NULL }, + { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_MIXED, NULL, ""%r/proc/sysrq-trigger"", NULL, MS_REMOUNT|MS_BIND|MS_RDONLY, NULL }, + { LXC_AUTO_PROC_MASK, LXC_AUTO_PROC_RW, ""proc"", ""%r/proc"", ""proc"", MS_NODEV|MS_NOEXEC|MS_NOSUID, NULL }, +@@ -815,7 +816,7 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha + } + mflags = add_required_remount_flags(source, destination, + default_mounts[i].flags); +- r = mount(source, destination, default_mounts[i].fstype, mflags, default_mounts[i].options); ++ r = safe_mount(source, destination, default_mounts[i].fstype, mflags, default_mounts[i].options, conf->rootfs.path ? conf->rootfs.mount : NULL); + saved_errno = errno; + if (r < 0 && errno == ENOENT) { + INFO(""Mount source or target for %s on %s doesn't exist. Skipping."", source, destination); +@@ -1167,7 +1168,8 @@ static int mount_autodev(const char *name, const struct lxc_rootfs *rootfs, cons + return 0; + } + +- if (mount(""none"", path, ""tmpfs"", 0, ""size=100000,mode=755"")) { ++ if (safe_mount(""none"", path, ""tmpfs"", 0, ""size=100000,mode=755"", ++ rootfs->path ? rootfs->mount : NULL)) { + SYSERROR(""Failed mounting tmpfs onto %s\n"", path); + return false; + } +@@ -1252,7 +1254,8 @@ static int fill_autodev(const struct lxc_rootfs *rootfs) + return -1; + } + fclose(pathfile); +- if (mount(hostpath, path, 0, MS_BIND, NULL) != 0) { ++ if (safe_mount(hostpath, path, 0, MS_BIND, NULL, ++ rootfs->path ? rootfs->mount : NULL) != 0) { + SYSERROR(""Failed bind mounting device %s from host into container"", + d->name); + return -1; +@@ -1505,7 +1508,7 @@ static int setup_dev_console(const struct lxc_rootfs *rootfs, + return -1; + } + +- if (mount(console->name, path, ""none"", MS_BIND, 0)) { ++ if (safe_mount(console->name, path, ""none"", MS_BIND, 0, rootfs->mount)) { + ERROR(""failed to mount '%s' on '%s'"", console->name, path); + return -1; + } +@@ -1560,7 +1563,7 @@ static int setup_ttydir_console(const struct lxc_rootfs *rootfs, + return 0; + } + +- if (mount(console->name, lxcpath, ""none"", MS_BIND, 0)) { ++ if (safe_mount(console->name, lxcpath, ""none"", MS_BIND, 0, rootfs->mount)) { + ERROR(""failed to mount '%s' on '%s'"", console->name, lxcpath); + return -1; + } +@@ -1710,13 +1713,13 @@ static char *get_field(char *src, int nfields) + + static int mount_entry(const char *fsname, const char *target, + const char *fstype, unsigned long mountflags, +- const char *data, int optional) ++ const char *data, int optional, const char *rootfs) + { + #ifdef HAVE_STATVFS + struct statvfs sb; + #endif + +- if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data)) { ++ if (safe_mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data, rootfs)) { + if (optional) { + INFO(""failed to mount '%s' on '%s' (optional): %s"", fsname, + target, strerror(errno)); +@@ -1763,7 +1766,7 @@ static int mount_entry(const char *fsname, const char *target, + #endif + + if (mount(fsname, target, fstype, +- mountflags | MS_REMOUNT, data)) { ++ mountflags | MS_REMOUNT, data) < 0) { + if (optional) { + INFO(""failed to mount '%s' on '%s' (optional): %s"", + fsname, target, strerror(errno)); +@@ -1843,7 +1846,7 @@ static int mount_entry_create_dir_file(const struct mntent *mntent, + } + + static inline int mount_entry_on_generic(struct mntent *mntent, +- const char* path) ++ const char* path, const char *rootfs) + { + unsigned long mntflags; + char *mntdata; +@@ -1863,7 +1866,7 @@ static inline int mount_entry_on_generic(struct mntent *mntent, + } + + ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type, +- mntflags, mntdata, optional); ++ mntflags, mntdata, optional, rootfs); + + free(mntdata); + +@@ -1872,7 +1875,7 @@ static inline int mount_entry_on_generic(struct mntent *mntent, + + static inline int mount_entry_on_systemfs(struct mntent *mntent) + { +- return mount_entry_on_generic(mntent, mntent->mnt_dir); ++ return mount_entry_on_generic(mntent, mntent->mnt_dir, NULL); + } + + static int mount_entry_on_absolute_rootfs(struct mntent *mntent, +@@ -1919,7 +1922,7 @@ static int mount_entry_on_absolute_rootfs(struct mntent *mntent, + return -1; + } + +- return mount_entry_on_generic(mntent, path); ++ return mount_entry_on_generic(mntent, path, rootfs->mount); + } + + static int mount_entry_on_relative_rootfs(struct mntent *mntent, +@@ -1935,7 +1938,7 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent, + return -1; + } + +- return mount_entry_on_generic(mntent, path); ++ return mount_entry_on_generic(mntent, path, rootfs); + } + + static int mount_file_entries(const struct lxc_rootfs *rootfs, FILE *file, +@@ -3602,7 +3605,7 @@ void lxc_execute_bind_init(struct lxc_conf *conf) + fclose(pathfile); + } + +- ret = mount(path, destpath, ""none"", MS_BIND, NULL); ++ ret = safe_mount(path, destpath, ""none"", MS_BIND, NULL, conf->rootfs.mount); + if (ret < 0) + SYSERROR(""Failed to bind lxc.init.static into container""); + INFO(""lxc.init.static bound into container at %s"", path);",1283,1519,2048 +18168,"static Image *ReadOTBImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define GetBit(a,i) (((a) >> (i)) & 1L) + + Image + *image; + + int + byte; + + MagickBooleanType + status; + + register IndexPacket + *indexes; + + register ssize_t + x; + + register PixelPacket + *q; + + ssize_t + y; + + unsigned char + bit, + info, + depth; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Initialize image structure. + */ + info=(unsigned char) ReadBlobByte(image); + if (GetBit(info,4) == 0) + { + image->columns=(size_t) ReadBlobByte(image); + image->rows=(size_t) ReadBlobByte(image); + } + else + { + image->columns=(size_t) ReadBlobMSBShort(image); + image->rows=(size_t) ReadBlobMSBShort(image); + } + if ((image->columns == 0) || (image->rows == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + depth=(unsigned char) ReadBlobByte(image); + if (depth != 1) + ThrowReaderException(CoderError,""OnlyLevelZerofilesSupported""); + if (AcquireImageColormap(image,2) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + /* + Convert bi-level image to pixel packets. + */ + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + bit=0; + byte=0; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (bit == 0) + { + byte=ReadBlobByte(image); + if (byte == EOF) + ThrowReaderException(CorruptImageError,""CorruptImage""); + } + SetPixelIndex(indexes+x,(byte & (0x01 << (7-bit))) ? + 0x00 : 0x01); + bit++; + if (bit == 8) + bit=0; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + (void) SyncImage(image); + if (EOFBlob(image) != MagickFalse) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadOTBImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define GetBit(a,i) (((a) >> (i)) & 1L) + + Image + *image; + + int + byte; + + MagickBooleanType + status; + + register IndexPacket + *indexes; + + register ssize_t + x; + + register PixelPacket + *q; + + ssize_t + y; + + unsigned char + bit, + info, + depth; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Initialize image structure. + */ + info=(unsigned char) ReadBlobByte(image); + if (GetBit(info,4) == 0) + { + image->columns=(size_t) ReadBlobByte(image); + image->rows=(size_t) ReadBlobByte(image); + } + else + { + image->columns=(size_t) ReadBlobMSBShort(image); + image->rows=(size_t) ReadBlobMSBShort(image); + } + if ((image->columns == 0) || (image->rows == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + depth=(unsigned char) ReadBlobByte(image); + if (depth != 1) + ThrowReaderException(CoderError,""OnlyLevelZerofilesSupported""); + if (AcquireImageColormap(image,2) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + /* + Convert bi-level image to pixel packets. + */ + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + bit=0; + byte=0; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (bit == 0) + { + byte=ReadBlobByte(image); + if (byte == EOF) + ThrowReaderException(CorruptImageError,""CorruptImage""); + } + SetPixelIndex(indexes+x,(byte & (0x01 << (7-bit))) ? + 0x00 : 0x01); + bit++; + if (bit == 8) + bit=0; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + (void) SyncImage(image); + if (EOFBlob(image) != MagickFalse) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -168,6 +168,12 @@ static Image *ReadOTBImage(const ImageInfo *image_info,ExceptionInfo *exception) + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + /* + Convert bi-level image to pixel packets. + */",803,1039,2048 +5349,"static int proc_control(struct usb_dev_state *ps, void __user *arg) +{ + struct usb_device *dev = ps->dev; + struct usbdevfs_ctrltransfer ctrl; + unsigned int tmo; + unsigned char *tbuf; + unsigned wLength; + int i, pipe, ret; + + if (copy_from_user(&ctrl, arg, sizeof(ctrl))) + return -EFAULT; + ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.bRequest, + ctrl.wIndex); + if (ret) + return ret; + wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ + if (wLength > PAGE_SIZE) + return -EINVAL; + ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct urb) + + sizeof(struct usb_ctrlrequest)); + if (ret) + return ret; + tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); + if (!tbuf) { + ret = -ENOMEM; + goto done; + } + tmo = ctrl.timeout; + snoop(&dev->dev, ""control urb: bRequestType=%02x "" + ""bRequest=%02x wValue=%04x "" + ""wIndex=%04x wLength=%04x\n"", + ctrl.bRequestType, ctrl.bRequest, ctrl.wValue, + ctrl.wIndex, ctrl.wLength); + if (ctrl.bRequestType & 0x80) { + if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, + ctrl.wLength)) { + ret = -EINVAL; + goto done; + } + pipe = usb_rcvctrlpipe(dev, 0); + snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); + + usb_unlock_device(dev); + i = usb_control_msg(dev, pipe, ctrl.bRequest, + ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, + tbuf, ctrl.wLength, tmo); + usb_lock_device(dev); + snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, + tbuf, max(i, 0)); + if ((i > 0) && ctrl.wLength) { + if (copy_to_user(ctrl.data, tbuf, i)) { + ret = -EFAULT; + goto done; + } + } + } else { + if (ctrl.wLength) { + if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { + ret = -EFAULT; + goto done; + } + } + pipe = usb_sndctrlpipe(dev, 0); + snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, + tbuf, ctrl.wLength); + + usb_unlock_device(dev); + i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, + ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, + tbuf, ctrl.wLength, tmo); + usb_lock_device(dev); + snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); + } + if (i < 0 && i != -EPIPE) { + dev_printk(KERN_DEBUG, &dev->dev, ""usbfs: USBDEVFS_CONTROL "" + ""failed cmd %s rqt %u rq %u len %u ret %d\n"", + current->comm, ctrl.bRequestType, ctrl.bRequest, + ctrl.wLength, i); + } + ret = i; + done: + free_page((unsigned long) tbuf); + usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) + + sizeof(struct usb_ctrlrequest)); + return ret; +} +",0,"static int proc_control(struct usb_dev_state *ps, void __user *arg) +{ + struct usb_device *dev = ps->dev; + struct usbdevfs_ctrltransfer ctrl; + unsigned int tmo; + unsigned char *tbuf; + unsigned wLength; + int i, pipe, ret; + + if (copy_from_user(&ctrl, arg, sizeof(ctrl))) + return -EFAULT; + ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.bRequest, + ctrl.wIndex); + if (ret) + return ret; + wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ + if (wLength > PAGE_SIZE) + return -EINVAL; + ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct urb) + + sizeof(struct usb_ctrlrequest)); + if (ret) + return ret; + tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); + if (!tbuf) { + ret = -ENOMEM; + goto done; + } + tmo = ctrl.timeout; + snoop(&dev->dev, ""control urb: bRequestType=%02x "" + ""bRequest=%02x wValue=%04x "" + ""wIndex=%04x wLength=%04x\n"", + ctrl.bRequestType, ctrl.bRequest, ctrl.wValue, + ctrl.wIndex, ctrl.wLength); + if (ctrl.bRequestType & 0x80) { + if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, + ctrl.wLength)) { + ret = -EINVAL; + goto done; + } + pipe = usb_rcvctrlpipe(dev, 0); + snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); + + usb_unlock_device(dev); + i = usb_control_msg(dev, pipe, ctrl.bRequest, + ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, + tbuf, ctrl.wLength, tmo); + usb_lock_device(dev); + snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, + tbuf, max(i, 0)); + if ((i > 0) && ctrl.wLength) { + if (copy_to_user(ctrl.data, tbuf, i)) { + ret = -EFAULT; + goto done; + } + } + } else { + if (ctrl.wLength) { + if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { + ret = -EFAULT; + goto done; + } + } + pipe = usb_sndctrlpipe(dev, 0); + snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, + tbuf, ctrl.wLength); + + usb_unlock_device(dev); + i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, + ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, + tbuf, ctrl.wLength, tmo); + usb_lock_device(dev); + snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); + } + if (i < 0 && i != -EPIPE) { + dev_printk(KERN_DEBUG, &dev->dev, ""usbfs: USBDEVFS_CONTROL "" + ""failed cmd %s rqt %u rq %u len %u ret %d\n"", + current->comm, ctrl.bRequestType, ctrl.bRequest, + ctrl.wLength, i); + } + ret = i; + done: + free_page((unsigned long) tbuf); + usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) + + sizeof(struct usb_ctrlrequest)); + return ret; +} +","@@ -1316,10 +1316,11 @@ static int proc_getdriver(struct usb_dev_state *ps, void __user *arg) + + static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) + { +- struct usbdevfs_connectinfo ci = { +- .devnum = ps->dev->devnum, +- .slow = ps->dev->speed == USB_SPEED_LOW +- }; ++ struct usbdevfs_connectinfo ci; ++ ++ memset(&ci, 0, sizeof(ci)); ++ ci.devnum = ps->dev->devnum; ++ ci.slow = ps->dev->speed == USB_SPEED_LOW; + + if (copy_to_user(arg, &ci, sizeof(ci))) + return -EFAULT;",805,1041,2048 +18190,"main(int argc, char * * argv) +{ + const char command0[] = { 0x00, 0x00 }; + char command1[] = ""\x01\x00urn:schemas-upnp-org:device:InternetGatewayDevice""; + char command2[] = ""\x02\x00uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::upnp:rootdevice""; + const char command3[] = { 0x03, 0x00 }; + /* old versions of minissdpd would reject a command with + * a zero length string argument */ + char command3compat[] = ""\x03\x00ssdp:all""; + char command4[] = ""\x04\x00test:test:test""; + const char bad_command[] = { 0xff, 0xff }; + const char overflow[] = { 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + const char command5[] = { 0x05, 0x00 }; + int s; + int i; + void * tmp; + unsigned char * resp = NULL; + size_t respsize = 0; + unsigned char buf[4096]; + ssize_t n; + int total = 0; + const char * sockpath = ""/var/run/minissdpd.sock""; + + for(i=0; i 0) { + printversion(buf, n); + } else { + printf(""Command 0 (get version) not supported\n""); + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command1, sizeof(command1) - 1); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command2, sizeof(command2) - 1); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + buf[0] = 0; /* Slight hack for printing num devices when 0 */ + n = SENDCOMMAND(command3, sizeof(command3)); + n = read(s, buf, sizeof(buf)); + if(n == 0) { + printf(""command3 failed, testing compatible one\n""); + close(s); + s = connect_unix_socket(sockpath); + n = SENDCOMMAND(command3compat, sizeof(command3compat) - 1); + n = read(s, buf, sizeof(buf)); + } + printf(""Response received %d bytes\n"", (int)n); + printf(""Number of devices %d\n"", (int)buf[0]); + while(n > 0) { + tmp = realloc(resp, respsize + n); + if(tmp == NULL) { + fprintf(stderr, ""memory allocation error\n""); + break; + } + resp = tmp; + respsize += n; + if (n > 0) { + memcpy(resp + total, buf, n); + total += n; + } + if (n < (ssize_t)sizeof(buf)) { + break; + } + + n = read(s, buf, sizeof(buf)); + printf(""response received %d bytes\n"", (int)n); + } + if(resp != NULL) { + printresponse(resp, total); + free(resp); + resp = NULL; + } + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command4, sizeof(command4)); + /* no response for request type 4 */ + + n = SENDCOMMAND(bad_command, sizeof(bad_command)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(overflow, sizeof(overflow)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command5, sizeof(command5)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + + close(s); + return 0; +} +",1,"main(int argc, char * * argv) +{ + const char command0[] = { 0x00, 0x00 }; + char command1[] = ""\x01\x00urn:schemas-upnp-org:device:InternetGatewayDevice""; + char command2[] = ""\x02\x00uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::upnp:rootdevice""; + const char command3[] = { 0x03, 0x00 }; + /* old versions of minissdpd would reject a command with + * a zero length string argument */ + char command3compat[] = ""\x03\x00ssdp:all""; + char command4[] = ""\x04\x00test:test:test""; + const char bad_command[] = { 0xff, 0xff }; + const char overflow[] = { 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + const char command5[] = { 0x05, 0x00 }; + const char bad_command4[] = { 0x04, 0x01, 0x60, 0x8f, 0xff, 0xff, 0xff, 0x7f}; + int s; + int i; + void * tmp; + unsigned char * resp = NULL; + size_t respsize = 0; + unsigned char buf[4096]; + ssize_t n; + int total = 0; + const char * sockpath = ""/var/run/minissdpd.sock""; + + for(i=0; i 0) { + printversion(buf, n); + } else { + printf(""Command 0 (get version) not supported\n""); + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command1, sizeof(command1) - 1); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command2, sizeof(command2) - 1); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + buf[0] = 0; /* Slight hack for printing num devices when 0 */ + n = SENDCOMMAND(command3, sizeof(command3)); + n = read(s, buf, sizeof(buf)); + if(n == 0) { + printf(""command3 failed, testing compatible one\n""); + close(s); + s = connect_unix_socket(sockpath); + n = SENDCOMMAND(command3compat, sizeof(command3compat) - 1); + n = read(s, buf, sizeof(buf)); + } + printf(""Response received %d bytes\n"", (int)n); + printf(""Number of devices %d\n"", (int)buf[0]); + while(n > 0) { + tmp = realloc(resp, respsize + n); + if(tmp == NULL) { + fprintf(stderr, ""memory allocation error\n""); + break; + } + resp = tmp; + respsize += n; + if (n > 0) { + memcpy(resp + total, buf, n); + total += n; + } + if (n < (ssize_t)sizeof(buf)) { + break; + } + + n = read(s, buf, sizeof(buf)); + printf(""response received %d bytes\n"", (int)n); + } + if(resp != NULL) { + printresponse(resp, total); + free(resp); + resp = NULL; + } + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command4, sizeof(command4)); + /* no response for request type 4 */ + + n = SENDCOMMAND(bad_command, sizeof(bad_command)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(overflow, sizeof(overflow)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(command5, sizeof(command5)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + if(n == 0) { + close(s); + s = connect_unix_socket(sockpath); + } + + n = SENDCOMMAND(bad_command4, sizeof(bad_command4)); + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); + + close(s); + return 0; +} +","@@ -1,4 +1,4 @@ +-/* $Id: testminissdpd.c,v 1.12 2015/08/06 13:16:59 nanard Exp $ */ ++/* $Id: testminissdpd.c,v 1.14 2016/03/01 17:49:51 nanard Exp $ */ + /* Project : miniupnp + * website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ + * Author : Thomas BERNARD +@@ -65,6 +65,7 @@ main(int argc, char * * argv) + const char bad_command[] = { 0xff, 0xff }; + const char overflow[] = { 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + const char command5[] = { 0x05, 0x00 }; ++ const char bad_command4[] = { 0x04, 0x01, 0x60, 0x8f, 0xff, 0xff, 0xff, 0x7f}; + int s; + int i; + void * tmp; +@@ -180,6 +181,15 @@ main(int argc, char * * argv) + n = read(s, buf, sizeof(buf)); + printf(""Response received %d bytes\n"", (int)n); + printresponse(buf, n); ++ if(n == 0) { ++ close(s); ++ s = connect_unix_socket(sockpath); ++ } ++ ++ n = SENDCOMMAND(bad_command4, sizeof(bad_command4)); ++ n = read(s, buf, sizeof(buf)); ++ printf(""Response received %d bytes\n"", (int)n); ++ printresponse(buf, n); + + close(s); + return 0;",1145,1381,2048 +18624,"static PassRefPtr cropImage( + Image* image, + const ParsedOptions& parsedOptions, + AlphaDisposition imageFormat = PremultiplyAlpha, + ImageDecoder::ColorSpaceOption colorSpaceOp = + ImageDecoder::ColorSpaceApplied) { + ASSERT(image); + IntRect imgRect(IntPoint(), IntSize(image->width(), image->height())); + const IntRect srcRect = intersection(imgRect, parsedOptions.cropRect); + + if (srcRect.isEmpty() && !parsedOptions.premultiplyAlpha) { + SkImageInfo info = + SkImageInfo::Make(parsedOptions.resizeWidth, parsedOptions.resizeHeight, + kN32_SkColorType, kUnpremul_SkAlphaType); + RefPtr dstBuffer = ArrayBuffer::createOrNull( + static_cast(info.width()) * info.height(), + info.bytesPerPixel()); + if (!dstBuffer) + return nullptr; + RefPtr dstPixels = + Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength()); + return StaticBitmapImage::create(newSkImageFromRaster( + info, std::move(dstPixels), + static_cast(info.width()) * info.bytesPerPixel())); + } + + sk_sp skiaImage = image->imageForCurrentFrame(); + if ((((!parsedOptions.premultiplyAlpha && !skiaImage->isOpaque()) || + !skiaImage) && + image->data() && imageFormat == PremultiplyAlpha) || + colorSpaceOp == ImageDecoder::ColorSpaceIgnored) { + std::unique_ptr decoder(ImageDecoder::create( + image->data(), true, + parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied + : ImageDecoder::AlphaNotPremultiplied, + colorSpaceOp)); + if (!decoder) + return nullptr; + skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); + if (!skiaImage) + return nullptr; + } + + if (parsedOptions.cropRect == srcRect && !parsedOptions.shouldScaleInput) { + sk_sp croppedSkImage = skiaImage->makeSubset(srcRect); + if (parsedOptions.flipY) + return StaticBitmapImage::create(flipSkImageVertically( + croppedSkImage.get(), parsedOptions.premultiplyAlpha + ? PremultiplyAlpha + : DontPremultiplyAlpha)); + if (parsedOptions.premultiplyAlpha && imageFormat == DontPremultiplyAlpha) + return StaticBitmapImage::create( + unPremulSkImageToPremul(croppedSkImage.get())); + croppedSkImage->preroll(); + return StaticBitmapImage::create(std::move(croppedSkImage)); + } + + sk_sp surface = SkSurface::MakeRasterN32Premul( + parsedOptions.resizeWidth, parsedOptions.resizeHeight); + if (!surface) + return nullptr; + if (srcRect.isEmpty()) + return StaticBitmapImage::create(surface->makeImageSnapshot()); + + SkScalar dstLeft = std::min(0, -parsedOptions.cropRect.x()); + SkScalar dstTop = std::min(0, -parsedOptions.cropRect.y()); + if (parsedOptions.cropRect.x() < 0) + dstLeft = -parsedOptions.cropRect.x(); + if (parsedOptions.cropRect.y() < 0) + dstTop = -parsedOptions.cropRect.y(); + if (parsedOptions.flipY) { + surface->getCanvas()->translate(0, surface->height()); + surface->getCanvas()->scale(1, -1); + } + if (parsedOptions.shouldScaleInput) { + SkRect drawSrcRect = SkRect::MakeXYWH( + parsedOptions.cropRect.x(), parsedOptions.cropRect.y(), + parsedOptions.cropRect.width(), parsedOptions.cropRect.height()); + SkRect drawDstRect = SkRect::MakeXYWH(0, 0, parsedOptions.resizeWidth, + parsedOptions.resizeHeight); + SkPaint paint; + paint.setFilterQuality(parsedOptions.resizeQuality); + surface->getCanvas()->drawImageRect(skiaImage, drawSrcRect, drawDstRect, + &paint); + } else { + surface->getCanvas()->drawImage(skiaImage, dstLeft, dstTop); + } + skiaImage = surface->makeImageSnapshot(); + + if (parsedOptions.premultiplyAlpha) { + if (imageFormat == DontPremultiplyAlpha) + return StaticBitmapImage::create( + unPremulSkImageToPremul(skiaImage.get())); + return StaticBitmapImage::create(std::move(skiaImage)); + } + return StaticBitmapImage::create(premulSkImageToUnPremul(skiaImage.get())); +} +",1,"static PassRefPtr cropImage( + Image* image, + const ParsedOptions& parsedOptions, + AlphaDisposition imageFormat = PremultiplyAlpha, + ImageDecoder::ColorSpaceOption colorSpaceOp = + ImageDecoder::ColorSpaceApplied) { + ASSERT(image); + IntRect imgRect(IntPoint(), IntSize(image->width(), image->height())); + const IntRect srcRect = intersection(imgRect, parsedOptions.cropRect); + + if (srcRect.isEmpty() && !parsedOptions.premultiplyAlpha) { + SkImageInfo info = + SkImageInfo::Make(parsedOptions.resizeWidth, parsedOptions.resizeHeight, + kN32_SkColorType, kUnpremul_SkAlphaType); + RefPtr dstBuffer = ArrayBuffer::createOrNull( + static_cast(info.width()) * info.height(), + info.bytesPerPixel()); + if (!dstBuffer) + return nullptr; + RefPtr dstPixels = + Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength()); + return StaticBitmapImage::create(newSkImageFromRaster( + info, std::move(dstPixels), + static_cast(info.width()) * info.bytesPerPixel())); + } + + sk_sp skiaImage = image->imageForCurrentFrame(); + if ((((!parsedOptions.premultiplyAlpha && !skiaImage->isOpaque()) || + !skiaImage) && + image->data() && imageFormat == PremultiplyAlpha) || + colorSpaceOp == ImageDecoder::ColorSpaceIgnored) { + std::unique_ptr decoder(ImageDecoder::create( + image->data(), true, + parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied + : ImageDecoder::AlphaNotPremultiplied, + colorSpaceOp)); + if (!decoder) + return nullptr; + skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); + if (!skiaImage) + return nullptr; + } + + if (parsedOptions.cropRect == srcRect && !parsedOptions.shouldScaleInput) { + sk_sp croppedSkImage = skiaImage->makeSubset(srcRect); + if (parsedOptions.flipY) + return StaticBitmapImage::create(flipSkImageVertically( + croppedSkImage.get(), parsedOptions.premultiplyAlpha + ? PremultiplyAlpha + : DontPremultiplyAlpha)); + if (parsedOptions.premultiplyAlpha && imageFormat == DontPremultiplyAlpha) + return StaticBitmapImage::create( + unPremulSkImageToPremul(croppedSkImage.get())); + croppedSkImage->preroll(); + return StaticBitmapImage::create(std::move(croppedSkImage)); + } + + sk_sp surface = SkSurface::MakeRasterN32Premul( + parsedOptions.resizeWidth, parsedOptions.resizeHeight); + if (!surface) + return nullptr; + if (srcRect.isEmpty()) + return StaticBitmapImage::create(surface->makeImageSnapshot()); + + SkScalar dstLeft = std::min(0, -parsedOptions.cropRect.x()); + SkScalar dstTop = std::min(0, -parsedOptions.cropRect.y()); + if (parsedOptions.cropRect.x() < 0) + dstLeft = -parsedOptions.cropRect.x(); + if (parsedOptions.cropRect.y() < 0) + dstTop = -parsedOptions.cropRect.y(); + if (parsedOptions.flipY) { + surface->getCanvas()->translate(0, surface->height()); + surface->getCanvas()->scale(1, -1); + } + if (parsedOptions.shouldScaleInput) { + SkRect drawSrcRect = SkRect::MakeXYWH( + parsedOptions.cropRect.x(), parsedOptions.cropRect.y(), + parsedOptions.cropRect.width(), parsedOptions.cropRect.height()); + SkRect drawDstRect = SkRect::MakeXYWH(0, 0, parsedOptions.resizeWidth, + parsedOptions.resizeHeight); + SkPaint paint; + paint.setFilterQuality(parsedOptions.resizeQuality); + surface->getCanvas()->drawImageRect(skiaImage, drawSrcRect, drawDstRect, + &paint); + } else { + surface->getCanvas()->drawImage(skiaImage, dstLeft, dstTop); + } + skiaImage = surface->makeImageSnapshot(); + + if (parsedOptions.premultiplyAlpha) { + if (imageFormat == DontPremultiplyAlpha) + return StaticBitmapImage::create( + unPremulSkImageToPremul(skiaImage.get())); + return StaticBitmapImage::create(std::move(skiaImage)); + } + return StaticBitmapImage::create(premulSkImageToUnPremul(skiaImage.get())); +} +","@@ -108,7 +108,7 @@ ParsedOptions parseOptions(const ImageBitmapOptions& options, + } + + bool dstBufferSizeHasOverflow(ParsedOptions options) { +- CheckedNumeric totalBytes = options.cropRect.width(); ++ CheckedNumeric totalBytes = options.cropRect.width(); + totalBytes *= options.cropRect.height(); + totalBytes *= options.bytesPerPixel; + if (!totalBytes.IsValid()) +@@ -131,8 +131,8 @@ static PassRefPtr copySkImageData(SkImage* input, + const SkImageInfo& info) { + // The function dstBufferSizeHasOverflow() is being called at the beginning of + // each ImageBitmap() constructor, which makes sure that doing +- // width * height * bytesPerPixel will never overflow size_t. +- size_t width = static_cast(input->width()); ++ // width * height * bytesPerPixel will never overflow unsigned. ++ unsigned width = static_cast(input->width()); + RefPtr dstBuffer = + ArrayBuffer::createOrNull(width * input->height(), info.bytesPerPixel()); + if (!dstBuffer) +@@ -146,7 +146,7 @@ static PassRefPtr copySkImageData(SkImage* input, + + static sk_sp newSkImageFromRaster(const SkImageInfo& info, + PassRefPtr imagePixels, +- size_t imageRowBytes) { ++ unsigned imageRowBytes) { + SkPixmap pixmap(info, imagePixels->data(), imageRowBytes); + return SkImage::MakeFromRaster(pixmap, + [](const void*, void* pixels) { +@@ -156,15 +156,15 @@ static sk_sp newSkImageFromRaster(const SkImageInfo& info, + } + + static void swizzleImageData(unsigned char* srcAddr, +- size_t height, +- size_t bytesPerRow, ++ unsigned height, ++ unsigned bytesPerRow, + bool flipY) { + if (flipY) { +- for (size_t i = 0; i < height / 2; i++) { +- size_t topRowStartPosition = i * bytesPerRow; +- size_t bottomRowStartPosition = (height - 1 - i) * bytesPerRow; ++ for (unsigned i = 0; i < height / 2; i++) { ++ unsigned topRowStartPosition = i * bytesPerRow; ++ unsigned bottomRowStartPosition = (height - 1 - i) * bytesPerRow; + if (kN32_SkColorType == kBGRA_8888_SkColorType) { // needs to swizzle +- for (size_t j = 0; j < bytesPerRow; j += 4) { ++ for (unsigned j = 0; j < bytesPerRow; j += 4) { + std::swap(srcAddr[topRowStartPosition + j], + srcAddr[bottomRowStartPosition + j + 2]); + std::swap(srcAddr[topRowStartPosition + j + 1], +@@ -182,27 +182,27 @@ static void swizzleImageData(unsigned char* srcAddr, + } + } else { + if (kN32_SkColorType == kBGRA_8888_SkColorType) // needs to swizzle +- for (size_t i = 0; i < height * bytesPerRow; i += 4) ++ for (unsigned i = 0; i < height * bytesPerRow; i += 4) + std::swap(srcAddr[i], srcAddr[i + 2]); + } + } + + static sk_sp flipSkImageVertically(SkImage* input, + AlphaDisposition alphaOp) { +- size_t width = static_cast(input->width()); +- size_t height = static_cast(input->height()); ++ unsigned width = static_cast(input->width()); ++ unsigned height = static_cast(input->height()); + SkImageInfo info = SkImageInfo::MakeN32(input->width(), input->height(), + (alphaOp == PremultiplyAlpha) + ? kPremul_SkAlphaType + : kUnpremul_SkAlphaType); +- size_t imageRowBytes = width * info.bytesPerPixel(); ++ unsigned imageRowBytes = width * info.bytesPerPixel(); + RefPtr imagePixels = copySkImageData(input, info); + if (!imagePixels) + return nullptr; +- for (size_t i = 0; i < height / 2; i++) { +- size_t topFirstElement = i * imageRowBytes; +- size_t topLastElement = (i + 1) * imageRowBytes; +- size_t bottomFirstElement = (height - 1 - i) * imageRowBytes; ++ for (unsigned i = 0; i < height / 2; i++) { ++ unsigned topFirstElement = i * imageRowBytes; ++ unsigned topLastElement = (i + 1) * imageRowBytes; ++ unsigned bottomFirstElement = (height - 1 - i) * imageRowBytes; + std::swap_ranges(imagePixels->data() + topFirstElement, + imagePixels->data() + topLastElement, + imagePixels->data() + bottomFirstElement); +@@ -218,7 +218,7 @@ static sk_sp premulSkImageToUnPremul(SkImage* input) { + return nullptr; + return newSkImageFromRaster( + info, std::move(dstPixels), +- static_cast(input->width()) * info.bytesPerPixel()); ++ static_cast(input->width()) * info.bytesPerPixel()); + } + + static sk_sp unPremulSkImageToPremul(SkImage* input) { +@@ -229,7 +229,7 @@ static sk_sp unPremulSkImageToPremul(SkImage* input) { + return nullptr; + return newSkImageFromRaster( + info, std::move(dstPixels), +- static_cast(input->width()) * info.bytesPerPixel()); ++ static_cast(input->width()) * info.bytesPerPixel()); + } + + sk_sp ImageBitmap::getSkImageFromDecoder( +@@ -290,15 +290,15 @@ static PassRefPtr cropImage( + SkImageInfo::Make(parsedOptions.resizeWidth, parsedOptions.resizeHeight, + kN32_SkColorType, kUnpremul_SkAlphaType); + RefPtr dstBuffer = ArrayBuffer::createOrNull( +- static_cast(info.width()) * info.height(), ++ static_cast(info.width()) * info.height(), + info.bytesPerPixel()); + if (!dstBuffer) + return nullptr; + RefPtr dstPixels = + Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength()); + return StaticBitmapImage::create(newSkImageFromRaster( + info, std::move(dstPixels), +- static_cast(info.width()) * info.bytesPerPixel())); ++ static_cast(info.width()) * info.bytesPerPixel())); + } + + sk_sp skiaImage = image->imageForCurrentFrame(); +@@ -524,7 +524,7 @@ static sk_sp scaleSkImage(sk_sp skImage, + Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength()); + SkPixmap pixmap( + resizedInfo, resizedPixels->data(), +- static_cast(resizeWidth) * resizedInfo.bytesPerPixel()); ++ static_cast(resizeWidth) * resizedInfo.bytesPerPixel()); + skImage->scalePixels(pixmap, resizeQuality); + return SkImage::MakeFromRaster(pixmap, + [](const void*, void* pixels) { +@@ -553,9 +553,10 @@ ImageBitmap::ImageBitmap(ImageData* data, + SkImageInfo info = SkImageInfo::Make( + parsedOptions.cropRect.width(), parsedOptions.cropRect.height(), + kN32_SkColorType, kUnpremul_SkAlphaType); +- size_t bytesPerPixel = static_cast(info.bytesPerPixel()); +- size_t srcPixelBytesPerRow = bytesPerPixel * data->size().width(); +- size_t dstPixelBytesPerRow = bytesPerPixel * parsedOptions.cropRect.width(); ++ unsigned bytesPerPixel = static_cast(info.bytesPerPixel()); ++ unsigned srcPixelBytesPerRow = bytesPerPixel * data->size().width(); ++ unsigned dstPixelBytesPerRow = ++ bytesPerPixel * parsedOptions.cropRect.width(); + sk_sp skImage; + if (parsedOptions.cropRect == IntRect(IntPoint(), data->size())) { + swizzleImageData(srcAddr, data->size().height(), srcPixelBytesPerRow, +@@ -567,7 +568,7 @@ ImageBitmap::ImageBitmap(ImageData* data, + parsedOptions.flipY); + } else { + RefPtr dstBuffer = ArrayBuffer::createOrNull( +- static_cast(parsedOptions.cropRect.height()) * ++ static_cast(parsedOptions.cropRect.height()) * + parsedOptions.cropRect.width(), + bytesPerPixel); + if (!dstBuffer) +@@ -589,12 +590,12 @@ ImageBitmap::ImageBitmap(ImageData* data, + if (parsedOptions.cropRect.width() < copyWidth) + copyWidth = parsedOptions.cropRect.width(); + for (int i = 0; i < copyHeight; i++) { +- size_t srcStartCopyPosition = ++ unsigned srcStartCopyPosition = + (i + srcPoint.y()) * srcPixelBytesPerRow + + srcPoint.x() * bytesPerPixel; +- size_t srcEndCopyPosition = ++ unsigned srcEndCopyPosition = + srcStartCopyPosition + copyWidth * bytesPerPixel; +- size_t dstStartCopyPosition; ++ unsigned dstStartCopyPosition; + if (parsedOptions.flipY) + dstStartCopyPosition = + (parsedOptions.cropRect.height() - 1 - dstPoint.y() - i) * +@@ -603,7 +604,7 @@ ImageBitmap::ImageBitmap(ImageData* data, + else + dstStartCopyPosition = (dstPoint.y() + i) * dstPixelBytesPerRow + + dstPoint.x() * bytesPerPixel; +- for (size_t j = 0; j < srcEndCopyPosition - srcStartCopyPosition; ++ for (unsigned j = 0; j < srcEndCopyPosition - srcStartCopyPosition; + j++) { + // swizzle when necessary + if (kN32_SkColorType == kBGRA_8888_SkColorType) {",1003,1239,2048 +18285,"static int userfaultfd_register(struct userfaultfd_ctx *ctx, + unsigned long arg) +{ + struct mm_struct *mm = ctx->mm; + struct vm_area_struct *vma, *prev, *cur; + int ret; + struct uffdio_register uffdio_register; + struct uffdio_register __user *user_uffdio_register; + unsigned long vm_flags, new_flags; + bool found; + bool basic_ioctls; + unsigned long start, end, vma_end; + + user_uffdio_register = (struct uffdio_register __user *) arg; + + ret = -EFAULT; + if (copy_from_user(&uffdio_register, user_uffdio_register, + sizeof(uffdio_register)-sizeof(__u64))) + goto out; + + ret = -EINVAL; + if (!uffdio_register.mode) + goto out; + if (uffdio_register.mode & ~(UFFDIO_REGISTER_MODE_MISSING| + UFFDIO_REGISTER_MODE_WP)) + goto out; + vm_flags = 0; + if (uffdio_register.mode & UFFDIO_REGISTER_MODE_MISSING) + vm_flags |= VM_UFFD_MISSING; + if (uffdio_register.mode & UFFDIO_REGISTER_MODE_WP) { + vm_flags |= VM_UFFD_WP; + /* + * FIXME: remove the below error constraint by + * implementing the wprotect tracking mode. + */ + ret = -EINVAL; + goto out; + } + + ret = validate_range(mm, uffdio_register.range.start, + uffdio_register.range.len); + if (ret) + goto out; + + start = uffdio_register.range.start; + end = start + uffdio_register.range.len; + + ret = -ENOMEM; + if (!mmget_not_zero(mm)) + goto out; + + down_write(&mm->mmap_sem); + vma = find_vma_prev(mm, start, &prev); + if (!vma) + goto out_unlock; + + /* check that there's at least one vma in the range */ + ret = -EINVAL; + if (vma->vm_start >= end) + goto out_unlock; + + /* + * If the first vma contains huge pages, make sure start address + * is aligned to huge page size. + */ + if (is_vm_hugetlb_page(vma)) { + unsigned long vma_hpagesize = vma_kernel_pagesize(vma); + + if (start & (vma_hpagesize - 1)) + goto out_unlock; + } + + /* + * Search for not compatible vmas. + */ + found = false; + basic_ioctls = false; + for (cur = vma; cur && cur->vm_start < end; cur = cur->vm_next) { + cond_resched(); + + BUG_ON(!!cur->vm_userfaultfd_ctx.ctx ^ + !!(cur->vm_flags & (VM_UFFD_MISSING | VM_UFFD_WP))); + + /* check not compatible vmas */ + ret = -EINVAL; + if (!vma_can_userfault(cur)) + goto out_unlock; + + /* + * UFFDIO_COPY will fill file holes even without + * PROT_WRITE. This check enforces that if this is a + * MAP_SHARED, the process has write permission to the backing + * file. If VM_MAYWRITE is set it also enforces that on a + * MAP_SHARED vma: there is no F_WRITE_SEAL and no further + * F_WRITE_SEAL can be taken until the vma is destroyed. + */ + ret = -EPERM; + if (unlikely(!(cur->vm_flags & VM_MAYWRITE))) + goto out_unlock; + + /* + * If this vma contains ending address, and huge pages + * check alignment. + */ + if (is_vm_hugetlb_page(cur) && end <= cur->vm_end && + end > cur->vm_start) { + unsigned long vma_hpagesize = vma_kernel_pagesize(cur); + + ret = -EINVAL; + + if (end & (vma_hpagesize - 1)) + goto out_unlock; + } + + /* + * Check that this vma isn't already owned by a + * different userfaultfd. We can't allow more than one + * userfaultfd to own a single vma simultaneously or we + * wouldn't know which one to deliver the userfaults to. + */ + ret = -EBUSY; + if (cur->vm_userfaultfd_ctx.ctx && + cur->vm_userfaultfd_ctx.ctx != ctx) + goto out_unlock; + + /* + * Note vmas containing huge pages + */ + if (is_vm_hugetlb_page(cur)) + basic_ioctls = true; + + found = true; + } + BUG_ON(!found); + + if (vma->vm_start < start) + prev = vma; + + ret = 0; + do { + cond_resched(); + + BUG_ON(!vma_can_userfault(vma)); + BUG_ON(vma->vm_userfaultfd_ctx.ctx && + vma->vm_userfaultfd_ctx.ctx != ctx); + WARN_ON(!(vma->vm_flags & VM_MAYWRITE)); + + /* + * Nothing to do: this vma is already registered into this + * userfaultfd and with the right tracking mode too. + */ + if (vma->vm_userfaultfd_ctx.ctx == ctx && + (vma->vm_flags & vm_flags) == vm_flags) + goto skip; + + if (vma->vm_start > start) + start = vma->vm_start; + vma_end = min(end, vma->vm_end); + + new_flags = (vma->vm_flags & ~vm_flags) | vm_flags; + prev = vma_merge(mm, prev, start, vma_end, new_flags, + vma->anon_vma, vma->vm_file, vma->vm_pgoff, + vma_policy(vma), + ((struct vm_userfaultfd_ctx){ ctx })); + if (prev) { + vma = prev; + goto next; + } + if (vma->vm_start < start) { + ret = split_vma(mm, vma, start, 1); + if (ret) + break; + } + if (vma->vm_end > end) { + ret = split_vma(mm, vma, end, 0); + if (ret) + break; + } + next: + /* + * In the vma_merge() successful mprotect-like case 8: + * the next vma was merged into the current one and + * the current one has not been updated yet. + */ + vma->vm_flags = new_flags; + vma->vm_userfaultfd_ctx.ctx = ctx; + + skip: + prev = vma; + start = vma->vm_end; + vma = vma->vm_next; + } while (vma && vma->vm_start < end); +out_unlock: + up_write(&mm->mmap_sem); + mmput(mm); + if (!ret) { + /* + * Now that we scanned all vmas we can already tell + * userland which ioctls methods are guaranteed to + * succeed on this range. + */ + if (put_user(basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC : + UFFD_API_RANGE_IOCTLS, + &user_uffdio_register->ioctls)) + ret = -EFAULT; + } +out: + return ret; +} +",1,"static int userfaultfd_register(struct userfaultfd_ctx *ctx, + unsigned long arg) +{ + struct mm_struct *mm = ctx->mm; + struct vm_area_struct *vma, *prev, *cur; + int ret; + struct uffdio_register uffdio_register; + struct uffdio_register __user *user_uffdio_register; + unsigned long vm_flags, new_flags; + bool found; + bool basic_ioctls; + unsigned long start, end, vma_end; + + user_uffdio_register = (struct uffdio_register __user *) arg; + + ret = -EFAULT; + if (copy_from_user(&uffdio_register, user_uffdio_register, + sizeof(uffdio_register)-sizeof(__u64))) + goto out; + + ret = -EINVAL; + if (!uffdio_register.mode) + goto out; + if (uffdio_register.mode & ~(UFFDIO_REGISTER_MODE_MISSING| + UFFDIO_REGISTER_MODE_WP)) + goto out; + vm_flags = 0; + if (uffdio_register.mode & UFFDIO_REGISTER_MODE_MISSING) + vm_flags |= VM_UFFD_MISSING; + if (uffdio_register.mode & UFFDIO_REGISTER_MODE_WP) { + vm_flags |= VM_UFFD_WP; + /* + * FIXME: remove the below error constraint by + * implementing the wprotect tracking mode. + */ + ret = -EINVAL; + goto out; + } + + ret = validate_range(mm, uffdio_register.range.start, + uffdio_register.range.len); + if (ret) + goto out; + + start = uffdio_register.range.start; + end = start + uffdio_register.range.len; + + ret = -ENOMEM; + if (!mmget_not_zero(mm)) + goto out; + + down_write(&mm->mmap_sem); + if (!mmget_still_valid(mm)) + goto out_unlock; + vma = find_vma_prev(mm, start, &prev); + if (!vma) + goto out_unlock; + + /* check that there's at least one vma in the range */ + ret = -EINVAL; + if (vma->vm_start >= end) + goto out_unlock; + + /* + * If the first vma contains huge pages, make sure start address + * is aligned to huge page size. + */ + if (is_vm_hugetlb_page(vma)) { + unsigned long vma_hpagesize = vma_kernel_pagesize(vma); + + if (start & (vma_hpagesize - 1)) + goto out_unlock; + } + + /* + * Search for not compatible vmas. + */ + found = false; + basic_ioctls = false; + for (cur = vma; cur && cur->vm_start < end; cur = cur->vm_next) { + cond_resched(); + + BUG_ON(!!cur->vm_userfaultfd_ctx.ctx ^ + !!(cur->vm_flags & (VM_UFFD_MISSING | VM_UFFD_WP))); + + /* check not compatible vmas */ + ret = -EINVAL; + if (!vma_can_userfault(cur)) + goto out_unlock; + + /* + * UFFDIO_COPY will fill file holes even without + * PROT_WRITE. This check enforces that if this is a + * MAP_SHARED, the process has write permission to the backing + * file. If VM_MAYWRITE is set it also enforces that on a + * MAP_SHARED vma: there is no F_WRITE_SEAL and no further + * F_WRITE_SEAL can be taken until the vma is destroyed. + */ + ret = -EPERM; + if (unlikely(!(cur->vm_flags & VM_MAYWRITE))) + goto out_unlock; + + /* + * If this vma contains ending address, and huge pages + * check alignment. + */ + if (is_vm_hugetlb_page(cur) && end <= cur->vm_end && + end > cur->vm_start) { + unsigned long vma_hpagesize = vma_kernel_pagesize(cur); + + ret = -EINVAL; + + if (end & (vma_hpagesize - 1)) + goto out_unlock; + } + + /* + * Check that this vma isn't already owned by a + * different userfaultfd. We can't allow more than one + * userfaultfd to own a single vma simultaneously or we + * wouldn't know which one to deliver the userfaults to. + */ + ret = -EBUSY; + if (cur->vm_userfaultfd_ctx.ctx && + cur->vm_userfaultfd_ctx.ctx != ctx) + goto out_unlock; + + /* + * Note vmas containing huge pages + */ + if (is_vm_hugetlb_page(cur)) + basic_ioctls = true; + + found = true; + } + BUG_ON(!found); + + if (vma->vm_start < start) + prev = vma; + + ret = 0; + do { + cond_resched(); + + BUG_ON(!vma_can_userfault(vma)); + BUG_ON(vma->vm_userfaultfd_ctx.ctx && + vma->vm_userfaultfd_ctx.ctx != ctx); + WARN_ON(!(vma->vm_flags & VM_MAYWRITE)); + + /* + * Nothing to do: this vma is already registered into this + * userfaultfd and with the right tracking mode too. + */ + if (vma->vm_userfaultfd_ctx.ctx == ctx && + (vma->vm_flags & vm_flags) == vm_flags) + goto skip; + + if (vma->vm_start > start) + start = vma->vm_start; + vma_end = min(end, vma->vm_end); + + new_flags = (vma->vm_flags & ~vm_flags) | vm_flags; + prev = vma_merge(mm, prev, start, vma_end, new_flags, + vma->anon_vma, vma->vm_file, vma->vm_pgoff, + vma_policy(vma), + ((struct vm_userfaultfd_ctx){ ctx })); + if (prev) { + vma = prev; + goto next; + } + if (vma->vm_start < start) { + ret = split_vma(mm, vma, start, 1); + if (ret) + break; + } + if (vma->vm_end > end) { + ret = split_vma(mm, vma, end, 0); + if (ret) + break; + } + next: + /* + * In the vma_merge() successful mprotect-like case 8: + * the next vma was merged into the current one and + * the current one has not been updated yet. + */ + vma->vm_flags = new_flags; + vma->vm_userfaultfd_ctx.ctx = ctx; + + skip: + prev = vma; + start = vma->vm_end; + vma = vma->vm_next; + } while (vma && vma->vm_start < end); +out_unlock: + up_write(&mm->mmap_sem); + mmput(mm); + if (!ret) { + /* + * Now that we scanned all vmas we can already tell + * userland which ioctls methods are guaranteed to + * succeed on this range. + */ + if (put_user(basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC : + UFFD_API_RANGE_IOCTLS, + &user_uffdio_register->ioctls)) + ret = -EFAULT; + } +out: + return ret; +} +","@@ -629,6 +629,8 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, + + /* the various vma->vm_userfaultfd_ctx still points to it */ + down_write(&mm->mmap_sem); ++ /* no task can run (and in turn coredump) yet */ ++ VM_WARN_ON(!mmget_still_valid(mm)); + for (vma = mm->mmap; vma; vma = vma->vm_next) + if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx) { + vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX; +@@ -883,6 +885,8 @@ static int userfaultfd_release(struct inode *inode, struct file *file) + * taking the mmap_sem for writing. + */ + down_write(&mm->mmap_sem); ++ if (!mmget_still_valid(mm)) ++ goto skip_mm; + prev = NULL; + for (vma = mm->mmap; vma; vma = vma->vm_next) { + cond_resched(); +@@ -905,6 +909,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file) + vma->vm_flags = new_flags; + vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX; + } ++skip_mm: + up_write(&mm->mmap_sem); + mmput(mm); + wakeup: +@@ -1333,6 +1338,8 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, + goto out; + + down_write(&mm->mmap_sem); ++ if (!mmget_still_valid(mm)) ++ goto out_unlock; + vma = find_vma_prev(mm, start, &prev); + if (!vma) + goto out_unlock; +@@ -1520,6 +1527,8 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, + goto out; + + down_write(&mm->mmap_sem); ++ if (!mmget_still_valid(mm)) ++ goto out_unlock; + vma = find_vma_prev(mm, start, &prev); + if (!vma) + goto out_unlock;",1592,1828,2048 +372,"int main(int argc, char *argv[]) +{ + BN_CTX *ctx; + BIO *out; + char *outfile = NULL; + + results = 0; + + RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */ + + argc--; + argv++; + while (argc >= 1) { + if (strcmp(*argv, ""-results"") == 0) + results = 1; + else if (strcmp(*argv, ""-out"") == 0) { + if (--argc < 1) + break; + outfile = *(++argv); + } + argc--; + argv++; + } + + ctx = BN_CTX_new(); + if (ctx == NULL) + EXIT(1); + + out = BIO_new(BIO_s_file()); + if (out == NULL) + EXIT(1); + if (outfile == NULL) { + BIO_set_fp(out, stdout, BIO_NOCLOSE); + } else { + if (!BIO_write_filename(out, outfile)) { + perror(outfile); + EXIT(1); + } + } + + if (!results) + BIO_puts(out, ""obase=16\nibase=16\n""); + + message(out, ""BN_add""); + if (!test_add(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_sub""); + if (!test_sub(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_lshift1""); + if (!test_lshift1(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_lshift (fixed)""); + if (!test_lshift(out, ctx, BN_bin2bn(lst, sizeof(lst) - 1, NULL))) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_lshift""); + if (!test_lshift(out, ctx, NULL)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_rshift1""); + if (!test_rshift1(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_rshift""); + if (!test_rshift(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_sqr""); + if (!test_sqr(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mul""); + if (!test_mul(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_div""); + if (!test_div(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_div_word""); + if (!test_div_word(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_div_recp""); + if (!test_div_recp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod""); + if (!test_mod(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_mul""); + if (!test_mod_mul(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mont""); + if (!test_mont(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_exp""); + if (!test_mod_exp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_exp_mont_consttime""); + if (!test_mod_exp_mont_consttime(out, ctx)) + goto err; + if (!test_mod_exp_mont5(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_exp""); + if (!test_exp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_kronecker""); + if (!test_kron(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_sqrt""); + if (!test_sqrt(out, ctx)) + goto err; + (void)BIO_flush(out); +#ifndef OPENSSL_NO_EC2M + message(out, ""BN_GF2m_add""); + if (!test_gf2m_add(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod""); + if (!test_gf2m_mod(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_mul""); + if (!test_gf2m_mod_mul(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_sqr""); + if (!test_gf2m_mod_sqr(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_inv""); + if (!test_gf2m_mod_inv(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_div""); + if (!test_gf2m_mod_div(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_exp""); + if (!test_gf2m_mod_exp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_sqrt""); + if (!test_gf2m_mod_sqrt(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_solve_quad""); + if (!test_gf2m_mod_solve_quad(out, ctx)) + goto err; + (void)BIO_flush(out); +#endif + BN_CTX_free(ctx); + BIO_free(out); + + EXIT(0); + err: + BIO_puts(out, ""1\n""); /* make sure the Perl script fed by bc + * notices the failure, see test_bn in + * test/Makefile.ssl */ + (void)BIO_flush(out); + ERR_load_crypto_strings(); + ERR_print_errors_fp(stderr); + EXIT(1); + return (1); +} +",0,"int main(int argc, char *argv[]) +{ + BN_CTX *ctx; + BIO *out; + char *outfile = NULL; + + results = 0; + + RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */ + + argc--; + argv++; + while (argc >= 1) { + if (strcmp(*argv, ""-results"") == 0) + results = 1; + else if (strcmp(*argv, ""-out"") == 0) { + if (--argc < 1) + break; + outfile = *(++argv); + } + argc--; + argv++; + } + + ctx = BN_CTX_new(); + if (ctx == NULL) + EXIT(1); + + out = BIO_new(BIO_s_file()); + if (out == NULL) + EXIT(1); + if (outfile == NULL) { + BIO_set_fp(out, stdout, BIO_NOCLOSE); + } else { + if (!BIO_write_filename(out, outfile)) { + perror(outfile); + EXIT(1); + } + } + + if (!results) + BIO_puts(out, ""obase=16\nibase=16\n""); + + message(out, ""BN_add""); + if (!test_add(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_sub""); + if (!test_sub(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_lshift1""); + if (!test_lshift1(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_lshift (fixed)""); + if (!test_lshift(out, ctx, BN_bin2bn(lst, sizeof(lst) - 1, NULL))) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_lshift""); + if (!test_lshift(out, ctx, NULL)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_rshift1""); + if (!test_rshift1(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_rshift""); + if (!test_rshift(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_sqr""); + if (!test_sqr(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mul""); + if (!test_mul(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_div""); + if (!test_div(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_div_word""); + if (!test_div_word(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_div_recp""); + if (!test_div_recp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod""); + if (!test_mod(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_mul""); + if (!test_mod_mul(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mont""); + if (!test_mont(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_exp""); + if (!test_mod_exp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_exp_mont_consttime""); + if (!test_mod_exp_mont_consttime(out, ctx)) + goto err; + if (!test_mod_exp_mont5(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_exp""); + if (!test_exp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_kronecker""); + if (!test_kron(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_mod_sqrt""); + if (!test_sqrt(out, ctx)) + goto err; + (void)BIO_flush(out); +#ifndef OPENSSL_NO_EC2M + message(out, ""BN_GF2m_add""); + if (!test_gf2m_add(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod""); + if (!test_gf2m_mod(out)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_mul""); + if (!test_gf2m_mod_mul(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_sqr""); + if (!test_gf2m_mod_sqr(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_inv""); + if (!test_gf2m_mod_inv(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_div""); + if (!test_gf2m_mod_div(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_exp""); + if (!test_gf2m_mod_exp(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_sqrt""); + if (!test_gf2m_mod_sqrt(out, ctx)) + goto err; + (void)BIO_flush(out); + + message(out, ""BN_GF2m_mod_solve_quad""); + if (!test_gf2m_mod_solve_quad(out, ctx)) + goto err; + (void)BIO_flush(out); +#endif + BN_CTX_free(ctx); + BIO_free(out); + + EXIT(0); + err: + BIO_puts(out, ""1\n""); /* make sure the Perl script fed by bc + * notices the failure, see test_bn in + * test/Makefile.ssl */ + (void)BIO_flush(out); + ERR_load_crypto_strings(); + ERR_print_errors_fp(stderr); + EXIT(1); + return (1); +} +","@@ -1016,6 +1016,24 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx) + return 0; + } + } ++ ++ /* Regression test for carry propagation bug in sqr8x_reduction */ ++ BN_hex2bn(&a, ""050505050505""); ++ BN_hex2bn(&b, ""02""); ++ BN_hex2bn(&c, ++ ""4141414141414141414141274141414141414141414141414141414141414141"" ++ ""4141414141414141414141414141414141414141414141414141414141414141"" ++ ""4141414141414141414141800000000000000000000000000000000000000000"" ++ ""0000000000000000000000000000000000000000000000000000000000000000"" ++ ""0000000000000000000000000000000000000000000000000000000000000000"" ++ ""0000000000000000000000000000000000000000000000000000000001""); ++ BN_mod_exp(d, a, b, c, ctx); ++ BN_mul(e, a, a, ctx); ++ if (BN_cmp(d, e)) { ++ fprintf(stderr, ""BN_mod_exp and BN_mul produce different results!\n""); ++ return 0; ++ } ++ + BN_free(a); + BN_free(b); + BN_free(c);",1359,1595,2048 +841,"void Gfx::doFunctionShFill1(GfxFunctionShading *shading, + double x0, double y0, + double x1, double y1, + GfxColor *colors, int depth) { + GfxColor fillColor; + GfxColor color0M, color1M, colorM0, colorM1, colorMM; + GfxColor colors2[4]; + double *matrix; + double xM, yM; + int nComps, i, j; + + nComps = shading->getColorSpace()->getNComps(); + matrix = shading->getMatrix(); + + for (i = 0; i < 4; ++i) { + for (j = 0; j < nComps; ++j) { + if (abs(colors[i].c[j] - colors[(i+1)&3].c[j]) > functionColorDelta) { + break; + } + } + if (j < nComps) { + break; + } + } + + xM = 0.5 * (x0 + x1); + yM = 0.5 * (y0 + y1); + + if ((i == 4 && depth > 0) || depth == functionMaxDepth) { + + shading->getColor(xM, yM, &fillColor); + state->setFillColor(&fillColor); + out->updateFillColor(state); + + state->moveTo(x0 * matrix[0] + y0 * matrix[2] + matrix[4], + x0 * matrix[1] + y0 * matrix[3] + matrix[5]); + state->lineTo(x1 * matrix[0] + y0 * matrix[2] + matrix[4], + x1 * matrix[1] + y0 * matrix[3] + matrix[5]); + state->lineTo(x1 * matrix[0] + y1 * matrix[2] + matrix[4], + x1 * matrix[1] + y1 * matrix[3] + matrix[5]); + state->lineTo(x0 * matrix[0] + y1 * matrix[2] + matrix[4], + x0 * matrix[1] + y1 * matrix[3] + matrix[5]); + state->closePath(); + if (!contentIsHidden()) + out->fill(state); + state->clearPath(); + + } else { + + + shading->getColor(x0, yM, &color0M); + shading->getColor(x1, yM, &color1M); + shading->getColor(xM, y0, &colorM0); + shading->getColor(xM, y1, &colorM1); + shading->getColor(xM, yM, &colorMM); + + colors2[0] = colors[0]; + colors2[1] = color0M; + colors2[2] = colorM0; + colors2[3] = colorMM; + doFunctionShFill1(shading, x0, y0, xM, yM, colors2, depth + 1); + + colors2[0] = color0M; + colors2[1] = colors[1]; + colors2[2] = colorMM; + colors2[3] = colorM1; + doFunctionShFill1(shading, x0, yM, xM, y1, colors2, depth + 1); + + colors2[0] = colorM0; + colors2[1] = colorMM; + colors2[2] = colors[2]; + colors2[3] = color1M; + doFunctionShFill1(shading, xM, y0, x1, yM, colors2, depth + 1); + + colors2[0] = colorMM; + colors2[1] = colorM1; + colors2[2] = color1M; + colors2[3] = colors[3]; + doFunctionShFill1(shading, xM, yM, x1, y1, colors2, depth + 1); + } +} +",0,"void Gfx::doFunctionShFill1(GfxFunctionShading *shading, + double x0, double y0, + double x1, double y1, + GfxColor *colors, int depth) { + GfxColor fillColor; + GfxColor color0M, color1M, colorM0, colorM1, colorMM; + GfxColor colors2[4]; + double *matrix; + double xM, yM; + int nComps, i, j; + + nComps = shading->getColorSpace()->getNComps(); + matrix = shading->getMatrix(); + + for (i = 0; i < 4; ++i) { + for (j = 0; j < nComps; ++j) { + if (abs(colors[i].c[j] - colors[(i+1)&3].c[j]) > functionColorDelta) { + break; + } + } + if (j < nComps) { + break; + } + } + + xM = 0.5 * (x0 + x1); + yM = 0.5 * (y0 + y1); + + if ((i == 4 && depth > 0) || depth == functionMaxDepth) { + + shading->getColor(xM, yM, &fillColor); + state->setFillColor(&fillColor); + out->updateFillColor(state); + + state->moveTo(x0 * matrix[0] + y0 * matrix[2] + matrix[4], + x0 * matrix[1] + y0 * matrix[3] + matrix[5]); + state->lineTo(x1 * matrix[0] + y0 * matrix[2] + matrix[4], + x1 * matrix[1] + y0 * matrix[3] + matrix[5]); + state->lineTo(x1 * matrix[0] + y1 * matrix[2] + matrix[4], + x1 * matrix[1] + y1 * matrix[3] + matrix[5]); + state->lineTo(x0 * matrix[0] + y1 * matrix[2] + matrix[4], + x0 * matrix[1] + y1 * matrix[3] + matrix[5]); + state->closePath(); + if (!contentIsHidden()) + out->fill(state); + state->clearPath(); + + } else { + + + shading->getColor(x0, yM, &color0M); + shading->getColor(x1, yM, &color1M); + shading->getColor(xM, y0, &colorM0); + shading->getColor(xM, y1, &colorM1); + shading->getColor(xM, yM, &colorMM); + + colors2[0] = colors[0]; + colors2[1] = color0M; + colors2[2] = colorM0; + colors2[3] = colorMM; + doFunctionShFill1(shading, x0, y0, xM, yM, colors2, depth + 1); + + colors2[0] = color0M; + colors2[1] = colors[1]; + colors2[2] = colorMM; + colors2[3] = colorM1; + doFunctionShFill1(shading, x0, yM, xM, y1, colors2, depth + 1); + + colors2[0] = colorM0; + colors2[1] = colorMM; + colors2[2] = colors[2]; + colors2[3] = color1M; + doFunctionShFill1(shading, xM, y0, x1, yM, colors2, depth + 1); + + colors2[0] = colorMM; + colors2[1] = colorM1; + colors2[2] = color1M; + colors2[3] = colors[3]; + doFunctionShFill1(shading, xM, yM, x1, y1, colors2, depth + 1); + } +} +","@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata + drawText = gFalse; + maskHaveCSPattern = gFalse; + mcStack = NULL; ++ parser = NULL; + + // start the resource stack + res = new GfxResources(xref, resDict, NULL); +@@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, + drawText = gFalse; + maskHaveCSPattern = gFalse; + mcStack = NULL; ++ parser = NULL; + + // start the resource stack + res = new GfxResources(xref, resDict, NULL);",880,1116,2048 +5601,"init_WinZip_AES_decryption(struct archive_read *a) +{ + struct zip *zip = (struct zip *)(a->format->data); + const void *p; + const uint8_t *pv; + size_t key_len, salt_len; + uint8_t derived_key[MAX_DERIVED_KEY_BUF_SIZE]; + int retry; + int r; + + if (zip->cctx_valid || zip->hctx_valid) + return (ARCHIVE_OK); + + switch (zip->entry->aes_extra.strength) { + case 1: salt_len = 8; key_len = 16; break; + case 2: salt_len = 12; key_len = 24; break; + case 3: salt_len = 16; key_len = 32; break; + default: goto corrupted; + } + p = __archive_read_ahead(a, salt_len + 2, NULL); + if (p == NULL) + goto truncated; + + for (retry = 0;; retry++) { + const char *passphrase; + + passphrase = __archive_read_next_passphrase(a); + if (passphrase == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + (retry > 0)? + ""Incorrect passphrase"": + ""Passphrase required for this entry""); + return (ARCHIVE_FAILED); + } + memset(derived_key, 0, sizeof(derived_key)); + r = archive_pbkdf2_sha1(passphrase, strlen(passphrase), + p, salt_len, 1000, derived_key, key_len * 2 + 2); + if (r != 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Decryption is unsupported due to lack of "" + ""crypto library""); + return (ARCHIVE_FAILED); + } + + /* Check password verification value. */ + pv = ((const uint8_t *)p) + salt_len; + if (derived_key[key_len * 2] == pv[0] && + derived_key[key_len * 2 + 1] == pv[1]) + break;/* The passphrase is OK. */ + if (retry > 10000) { + /* Avoid infinity loop. */ + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Too many incorrect passphrases""); + return (ARCHIVE_FAILED); + } + } + + r = archive_decrypto_aes_ctr_init(&zip->cctx, derived_key, key_len); + if (r != 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Decryption is unsupported due to lack of crypto library""); + return (ARCHIVE_FAILED); + } + r = archive_hmac_sha1_init(&zip->hctx, derived_key + key_len, key_len); + if (r != 0) { + archive_decrypto_aes_ctr_release(&zip->cctx); + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Failed to initialize HMAC-SHA1""); + return (ARCHIVE_FAILED); + } + zip->cctx_valid = zip->hctx_valid = 1; + __archive_read_consume(a, salt_len + 2); + zip->entry_bytes_remaining -= salt_len + 2 + AUTH_CODE_SIZE; + if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END) + && zip->entry_bytes_remaining < 0) + goto corrupted; + zip->entry_compressed_bytes_read += salt_len + 2 + AUTH_CODE_SIZE; + zip->decrypted_bytes_remaining = 0; + + zip->entry->compression = zip->entry->aes_extra.compression; + return (zip_alloc_decryption_buffer(a)); + +truncated: + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Truncated ZIP file data""); + return (ARCHIVE_FATAL); +corrupted: + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Corrupted ZIP file data""); + return (ARCHIVE_FATAL); +} +",0,"init_WinZip_AES_decryption(struct archive_read *a) +{ + struct zip *zip = (struct zip *)(a->format->data); + const void *p; + const uint8_t *pv; + size_t key_len, salt_len; + uint8_t derived_key[MAX_DERIVED_KEY_BUF_SIZE]; + int retry; + int r; + + if (zip->cctx_valid || zip->hctx_valid) + return (ARCHIVE_OK); + + switch (zip->entry->aes_extra.strength) { + case 1: salt_len = 8; key_len = 16; break; + case 2: salt_len = 12; key_len = 24; break; + case 3: salt_len = 16; key_len = 32; break; + default: goto corrupted; + } + p = __archive_read_ahead(a, salt_len + 2, NULL); + if (p == NULL) + goto truncated; + + for (retry = 0;; retry++) { + const char *passphrase; + + passphrase = __archive_read_next_passphrase(a); + if (passphrase == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + (retry > 0)? + ""Incorrect passphrase"": + ""Passphrase required for this entry""); + return (ARCHIVE_FAILED); + } + memset(derived_key, 0, sizeof(derived_key)); + r = archive_pbkdf2_sha1(passphrase, strlen(passphrase), + p, salt_len, 1000, derived_key, key_len * 2 + 2); + if (r != 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Decryption is unsupported due to lack of "" + ""crypto library""); + return (ARCHIVE_FAILED); + } + + /* Check password verification value. */ + pv = ((const uint8_t *)p) + salt_len; + if (derived_key[key_len * 2] == pv[0] && + derived_key[key_len * 2 + 1] == pv[1]) + break;/* The passphrase is OK. */ + if (retry > 10000) { + /* Avoid infinity loop. */ + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Too many incorrect passphrases""); + return (ARCHIVE_FAILED); + } + } + + r = archive_decrypto_aes_ctr_init(&zip->cctx, derived_key, key_len); + if (r != 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Decryption is unsupported due to lack of crypto library""); + return (ARCHIVE_FAILED); + } + r = archive_hmac_sha1_init(&zip->hctx, derived_key + key_len, key_len); + if (r != 0) { + archive_decrypto_aes_ctr_release(&zip->cctx); + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Failed to initialize HMAC-SHA1""); + return (ARCHIVE_FAILED); + } + zip->cctx_valid = zip->hctx_valid = 1; + __archive_read_consume(a, salt_len + 2); + zip->entry_bytes_remaining -= salt_len + 2 + AUTH_CODE_SIZE; + if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END) + && zip->entry_bytes_remaining < 0) + goto corrupted; + zip->entry_compressed_bytes_read += salt_len + 2 + AUTH_CODE_SIZE; + zip->decrypted_bytes_remaining = 0; + + zip->entry->compression = zip->entry->aes_extra.compression; + return (zip_alloc_decryption_buffer(a)); + +truncated: + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Truncated ZIP file data""); + return (ARCHIVE_FATAL); +corrupted: + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Corrupted ZIP file data""); + return (ARCHIVE_FATAL); +} +","@@ -2778,6 +2778,11 @@ zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry, + + switch(rsrc->compression) { + case 0: /* No compression. */ ++ if (rsrc->uncompressed_size != rsrc->compressed_size) { ++ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, ++ ""Malformed OS X metadata entry: inconsistent size""); ++ return (ARCHIVE_FATAL); ++ } + #ifdef HAVE_ZLIB_H + case 8: /* Deflate compression. */ + #endif +@@ -2798,6 +2803,12 @@ zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry, + (intmax_t)rsrc->uncompressed_size); + return (ARCHIVE_WARN); + } ++ if (rsrc->compressed_size > (4 * 1024 * 1024)) { ++ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, ++ ""Mac metadata is too large: %jd > 4M bytes"", ++ (intmax_t)rsrc->compressed_size); ++ return (ARCHIVE_WARN); ++ } + + metadata = malloc((size_t)rsrc->uncompressed_size); + if (metadata == NULL) { +@@ -2836,6 +2847,8 @@ zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry, + bytes_avail = remaining_bytes; + switch(rsrc->compression) { + case 0: /* No compression. */ ++ if ((size_t)bytes_avail > metadata_bytes) ++ bytes_avail = metadata_bytes; + memcpy(mp, p, bytes_avail); + bytes_used = (size_t)bytes_avail; + metadata_bytes -= bytes_used;",860,1096,2048 +7932,"png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) +{ + if (png_ptr->zowner != 0) + { + char msg[64]; + + PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner); + /* So the message that results is "" using zstream""; this is an + * internal error, but is very useful for debugging. i18n requirements + * are minimal. + */ + (void)png_safecat(msg, (sizeof msg), 4, "" using zstream""); +#if PNG_RELEASE_BUILD + png_chunk_warning(png_ptr, msg); + png_ptr->zowner = 0; +#else + png_chunk_error(png_ptr, msg); +#endif + } + + /* Implementation note: unlike 'png_deflate_claim' this internal function + * does not take the size of the data as an argument. Some efficiency could + * be gained by using this when it is known *if* the zlib stream itself does + * not record the number; however, this is an illusion: the original writer + * of the PNG may have selected a lower window size, and we really must + * follow that because, for systems with with limited capabilities, we + * would otherwise reject the application's attempts to use a smaller window + * size (zlib doesn't have an interface to say ""this or lower""!). + * + * inflateReset2 was added to zlib 1.2.4; before this the window could not be + * reset, therefore it is necessary to always allocate the maximum window + * size with earlier zlibs just in case later compressed chunks need it. + */ + { + int ret; /* zlib return code */ +#if ZLIB_VERNUM >= 0x1240 + int window_bits = 0; + +# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) + if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) == + PNG_OPTION_ON) + { + window_bits = 15; + png_ptr->zstream_start = 0; /* fixed window size */ + } + + else + { + png_ptr->zstream_start = 1; + } +# endif + +#endif /* ZLIB_VERNUM >= 0x1240 */ + + /* Set this for safety, just in case the previous owner left pointers to + * memory allocations. + */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->zstream.avail_out = 0; + + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) + { +#if ZLIB_VERNUM >= 0x1240 + ret = inflateReset2(&png_ptr->zstream, window_bits); +#else + ret = inflateReset(&png_ptr->zstream); +#endif + } + + else + { +#if ZLIB_VERNUM >= 0x1240 + ret = inflateInit2(&png_ptr->zstream, window_bits); +#else + ret = inflateInit(&png_ptr->zstream); +#endif + + if (ret == Z_OK) + png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; + } + +#if ZLIB_VERNUM >= 0x1290 && \ + defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32) + if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON) + /* Turn off validation of the ADLER32 checksum in IDAT chunks */ + ret = inflateValidate(&png_ptr->zstream, 0); +#endif + + if (ret == Z_OK) + png_ptr->zowner = owner; + + else + png_zstream_error(png_ptr, ret); + + return ret; + } + +#ifdef window_bits +# undef window_bits +#endif +} +",0,"png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) +{ + if (png_ptr->zowner != 0) + { + char msg[64]; + + PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner); + /* So the message that results is "" using zstream""; this is an + * internal error, but is very useful for debugging. i18n requirements + * are minimal. + */ + (void)png_safecat(msg, (sizeof msg), 4, "" using zstream""); +#if PNG_RELEASE_BUILD + png_chunk_warning(png_ptr, msg); + png_ptr->zowner = 0; +#else + png_chunk_error(png_ptr, msg); +#endif + } + + /* Implementation note: unlike 'png_deflate_claim' this internal function + * does not take the size of the data as an argument. Some efficiency could + * be gained by using this when it is known *if* the zlib stream itself does + * not record the number; however, this is an illusion: the original writer + * of the PNG may have selected a lower window size, and we really must + * follow that because, for systems with with limited capabilities, we + * would otherwise reject the application's attempts to use a smaller window + * size (zlib doesn't have an interface to say ""this or lower""!). + * + * inflateReset2 was added to zlib 1.2.4; before this the window could not be + * reset, therefore it is necessary to always allocate the maximum window + * size with earlier zlibs just in case later compressed chunks need it. + */ + { + int ret; /* zlib return code */ +#if ZLIB_VERNUM >= 0x1240 + int window_bits = 0; + +# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) + if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) == + PNG_OPTION_ON) + { + window_bits = 15; + png_ptr->zstream_start = 0; /* fixed window size */ + } + + else + { + png_ptr->zstream_start = 1; + } +# endif + +#endif /* ZLIB_VERNUM >= 0x1240 */ + + /* Set this for safety, just in case the previous owner left pointers to + * memory allocations. + */ + png_ptr->zstream.next_in = NULL; + png_ptr->zstream.avail_in = 0; + png_ptr->zstream.next_out = NULL; + png_ptr->zstream.avail_out = 0; + + if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) + { +#if ZLIB_VERNUM >= 0x1240 + ret = inflateReset2(&png_ptr->zstream, window_bits); +#else + ret = inflateReset(&png_ptr->zstream); +#endif + } + + else + { +#if ZLIB_VERNUM >= 0x1240 + ret = inflateInit2(&png_ptr->zstream, window_bits); +#else + ret = inflateInit(&png_ptr->zstream); +#endif + + if (ret == Z_OK) + png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; + } + +#if ZLIB_VERNUM >= 0x1290 && \ + defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32) + if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON) + /* Turn off validation of the ADLER32 checksum in IDAT chunks */ + ret = inflateValidate(&png_ptr->zstream, 0); +#endif + + if (ret == Z_OK) + png_ptr->zowner = owner; + + else + png_zstream_error(png_ptr, ret); + + return ret; + } + +#ifdef window_bits +# undef window_bits +#endif +} +","@@ -3167,10 +3167,13 @@ png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) + { + png_alloc_size_t idat_limit = PNG_UINT_31_MAX; + size_t row_factor = +- (png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) +- + 1 + (png_ptr->interlaced? 6: 0)); ++ (size_t)png_ptr->width ++ * (size_t)png_ptr->channels ++ * (png_ptr->bit_depth > 8? 2: 1) ++ + 1 ++ + (png_ptr->interlaced? 6: 0); + if (png_ptr->height > PNG_UINT_32_MAX/row_factor) +- idat_limit=PNG_UINT_31_MAX; ++ idat_limit = PNG_UINT_31_MAX; + else + idat_limit = png_ptr->height * row_factor; + row_factor = row_factor > 32566? 32566 : row_factor;",861,1097,2048 +5436,"static void cypress_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) +{ + struct cypress_private *priv = usb_get_serial_port_data(port); + struct device *dev = &port->dev; + int data_bits, stop_bits, parity_type, parity_enable; + unsigned cflag, iflag; + unsigned long flags; + __u8 oldlines; + int linechange = 0; + + spin_lock_irqsave(&priv->lock, flags); + /* We can't clean this one up as we don't know the device type + early enough */ + if (!priv->termios_initialized) { + if (priv->chiptype == CT_EARTHMATE) { + tty->termios = tty_std_termios; + tty->termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | + CLOCAL; + tty->termios.c_ispeed = 4800; + tty->termios.c_ospeed = 4800; + } else if (priv->chiptype == CT_CYPHIDCOM) { + tty->termios = tty_std_termios; + tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | + CLOCAL; + tty->termios.c_ispeed = 9600; + tty->termios.c_ospeed = 9600; + } else if (priv->chiptype == CT_CA42V2) { + tty->termios = tty_std_termios; + tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | + CLOCAL; + tty->termios.c_ispeed = 9600; + tty->termios.c_ospeed = 9600; + } + priv->termios_initialized = 1; + } + spin_unlock_irqrestore(&priv->lock, flags); + + /* Unsupported features need clearing */ + tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS); + + cflag = tty->termios.c_cflag; + iflag = tty->termios.c_iflag; + + /* check if there are new settings */ + if (old_termios) { + spin_lock_irqsave(&priv->lock, flags); + priv->tmp_termios = tty->termios; + spin_unlock_irqrestore(&priv->lock, flags); + } + + /* set number of data bits, parity, stop bits */ + /* when parity is disabled the parity type bit is ignored */ + + /* 1 means 2 stop bits, 0 means 1 stop bit */ + stop_bits = cflag & CSTOPB ? 1 : 0; + + if (cflag & PARENB) { + parity_enable = 1; + /* 1 means odd parity, 0 means even parity */ + parity_type = cflag & PARODD ? 1 : 0; + } else + parity_enable = parity_type = 0; + + switch (cflag & CSIZE) { + case CS5: + data_bits = 0; + break; + case CS6: + data_bits = 1; + break; + case CS7: + data_bits = 2; + break; + case CS8: + data_bits = 3; + break; + default: + dev_err(dev, ""%s - CSIZE was set, but not CS5-CS8\n"", __func__); + data_bits = 3; + } + spin_lock_irqsave(&priv->lock, flags); + oldlines = priv->line_control; + if ((cflag & CBAUD) == B0) { + /* drop dtr and rts */ + dev_dbg(dev, ""%s - dropping the lines, baud rate 0bps\n"", __func__); + priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); + } else + priv->line_control = (CONTROL_DTR | CONTROL_RTS); + spin_unlock_irqrestore(&priv->lock, flags); + + dev_dbg(dev, ""%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)\n"", + __func__, stop_bits, parity_enable, parity_type, data_bits); + + cypress_serial_control(tty, port, tty_get_baud_rate(tty), + data_bits, stop_bits, + parity_enable, parity_type, + 0, CYPRESS_SET_CONFIG); + + /* we perform a CYPRESS_GET_CONFIG so that the current settings are + * filled into the private structure this should confirm that all is + * working if it returns what we just set */ + cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); + + /* Here we can define custom tty settings for devices; the main tty + * termios flag base comes from empeg.c */ + + spin_lock_irqsave(&priv->lock, flags); + if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) { + dev_dbg(dev, ""Using custom termios settings for a baud rate of 4800bps.\n""); + /* define custom termios settings for NMEA protocol */ + + tty->termios.c_iflag /* input modes - */ + &= ~(IGNBRK /* disable ignore break */ + | BRKINT /* disable break causes interrupt */ + | PARMRK /* disable mark parity errors */ + | ISTRIP /* disable clear high bit of input char */ + | INLCR /* disable translate NL to CR */ + | IGNCR /* disable ignore CR */ + | ICRNL /* disable translate CR to NL */ + | IXON); /* disable enable XON/XOFF flow control */ + + tty->termios.c_oflag /* output modes */ + &= ~OPOST; /* disable postprocess output char */ + + tty->termios.c_lflag /* line discipline modes */ + &= ~(ECHO /* disable echo input characters */ + | ECHONL /* disable echo new line */ + | ICANON /* disable erase, kill, werase, and rprnt + special characters */ + | ISIG /* disable interrupt, quit, and suspend + special characters */ + | IEXTEN); /* disable non-POSIX special characters */ + } /* CT_CYPHIDCOM: Application should handle this for device */ + + linechange = (priv->line_control != oldlines); + spin_unlock_irqrestore(&priv->lock, flags); + + /* if necessary, set lines */ + if (linechange) { + priv->cmd_ctrl = 1; + cypress_write(tty, port, NULL, 0); + } +} /* cypress_set_termios */ +",0,"static void cypress_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) +{ + struct cypress_private *priv = usb_get_serial_port_data(port); + struct device *dev = &port->dev; + int data_bits, stop_bits, parity_type, parity_enable; + unsigned cflag, iflag; + unsigned long flags; + __u8 oldlines; + int linechange = 0; + + spin_lock_irqsave(&priv->lock, flags); + /* We can't clean this one up as we don't know the device type + early enough */ + if (!priv->termios_initialized) { + if (priv->chiptype == CT_EARTHMATE) { + tty->termios = tty_std_termios; + tty->termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | + CLOCAL; + tty->termios.c_ispeed = 4800; + tty->termios.c_ospeed = 4800; + } else if (priv->chiptype == CT_CYPHIDCOM) { + tty->termios = tty_std_termios; + tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | + CLOCAL; + tty->termios.c_ispeed = 9600; + tty->termios.c_ospeed = 9600; + } else if (priv->chiptype == CT_CA42V2) { + tty->termios = tty_std_termios; + tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | + CLOCAL; + tty->termios.c_ispeed = 9600; + tty->termios.c_ospeed = 9600; + } + priv->termios_initialized = 1; + } + spin_unlock_irqrestore(&priv->lock, flags); + + /* Unsupported features need clearing */ + tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS); + + cflag = tty->termios.c_cflag; + iflag = tty->termios.c_iflag; + + /* check if there are new settings */ + if (old_termios) { + spin_lock_irqsave(&priv->lock, flags); + priv->tmp_termios = tty->termios; + spin_unlock_irqrestore(&priv->lock, flags); + } + + /* set number of data bits, parity, stop bits */ + /* when parity is disabled the parity type bit is ignored */ + + /* 1 means 2 stop bits, 0 means 1 stop bit */ + stop_bits = cflag & CSTOPB ? 1 : 0; + + if (cflag & PARENB) { + parity_enable = 1; + /* 1 means odd parity, 0 means even parity */ + parity_type = cflag & PARODD ? 1 : 0; + } else + parity_enable = parity_type = 0; + + switch (cflag & CSIZE) { + case CS5: + data_bits = 0; + break; + case CS6: + data_bits = 1; + break; + case CS7: + data_bits = 2; + break; + case CS8: + data_bits = 3; + break; + default: + dev_err(dev, ""%s - CSIZE was set, but not CS5-CS8\n"", __func__); + data_bits = 3; + } + spin_lock_irqsave(&priv->lock, flags); + oldlines = priv->line_control; + if ((cflag & CBAUD) == B0) { + /* drop dtr and rts */ + dev_dbg(dev, ""%s - dropping the lines, baud rate 0bps\n"", __func__); + priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); + } else + priv->line_control = (CONTROL_DTR | CONTROL_RTS); + spin_unlock_irqrestore(&priv->lock, flags); + + dev_dbg(dev, ""%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)\n"", + __func__, stop_bits, parity_enable, parity_type, data_bits); + + cypress_serial_control(tty, port, tty_get_baud_rate(tty), + data_bits, stop_bits, + parity_enable, parity_type, + 0, CYPRESS_SET_CONFIG); + + /* we perform a CYPRESS_GET_CONFIG so that the current settings are + * filled into the private structure this should confirm that all is + * working if it returns what we just set */ + cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); + + /* Here we can define custom tty settings for devices; the main tty + * termios flag base comes from empeg.c */ + + spin_lock_irqsave(&priv->lock, flags); + if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) { + dev_dbg(dev, ""Using custom termios settings for a baud rate of 4800bps.\n""); + /* define custom termios settings for NMEA protocol */ + + tty->termios.c_iflag /* input modes - */ + &= ~(IGNBRK /* disable ignore break */ + | BRKINT /* disable break causes interrupt */ + | PARMRK /* disable mark parity errors */ + | ISTRIP /* disable clear high bit of input char */ + | INLCR /* disable translate NL to CR */ + | IGNCR /* disable ignore CR */ + | ICRNL /* disable translate CR to NL */ + | IXON); /* disable enable XON/XOFF flow control */ + + tty->termios.c_oflag /* output modes */ + &= ~OPOST; /* disable postprocess output char */ + + tty->termios.c_lflag /* line discipline modes */ + &= ~(ECHO /* disable echo input characters */ + | ECHONL /* disable echo new line */ + | ICANON /* disable erase, kill, werase, and rprnt + special characters */ + | ISIG /* disable interrupt, quit, and suspend + special characters */ + | IEXTEN); /* disable non-POSIX special characters */ + } /* CT_CYPHIDCOM: Application should handle this for device */ + + linechange = (priv->line_control != oldlines); + spin_unlock_irqrestore(&priv->lock, flags); + + /* if necessary, set lines */ + if (linechange) { + priv->cmd_ctrl = 1; + cypress_write(tty, port, NULL, 0); + } +} /* cypress_set_termios */ +","@@ -447,6 +447,11 @@ static int cypress_generic_port_probe(struct usb_serial_port *port) + struct usb_serial *serial = port->serial; + struct cypress_private *priv; + ++ if (!port->interrupt_out_urb || !port->interrupt_in_urb) { ++ dev_err(&port->dev, ""required endpoint is missing\n""); ++ return -ENODEV; ++ } ++ + priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL); + if (!priv) + return -ENOMEM; +@@ -606,12 +611,6 @@ static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port) + cypress_set_termios(tty, port, &priv->tmp_termios); + + /* setup the port and start reading from the device */ +- if (!port->interrupt_in_urb) { +- dev_err(&port->dev, ""%s - interrupt_in_urb is empty!\n"", +- __func__); +- return -1; +- } +- + usb_fill_int_urb(port->interrupt_in_urb, serial->dev, + usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), + port->interrupt_in_urb->transfer_buffer,",1490,1726,2048 +8908,"tree_min_len(Node* node, ScanEnv* env) +{ + OnigLen len; + OnigLen tmin; + + len = 0; + switch (NODE_TYPE(node)) { + case NODE_BACKREF: + if (! NODE_IS_CHECKER(node)) { + int i; + int* backs; + MemEnv* mem_env = SCANENV_MEMENV(env); + BackRefNode* br = BACKREF_(node); + if (NODE_IS_RECURSION(node)) break; + + backs = BACKREFS_P(br); + len = tree_min_len(mem_env[backs[0]].node, env); + for (i = 1; i < br->back_num; i++) { + tmin = tree_min_len(mem_env[backs[i]].node, env); + if (len > tmin) len = tmin; + } + } + break; + +#ifdef USE_CALL + case NODE_CALL: + { + Node* t = NODE_BODY(node); + if (NODE_IS_RECURSION(node)) { + if (NODE_IS_MIN_FIXED(t)) + len = BAG_(t)->min_len; + } + else + len = tree_min_len(t, env); + } + break; +#endif + + case NODE_LIST: + do { + tmin = tree_min_len(NODE_CAR(node), env); + len = distance_add(len, tmin); + } while (IS_NOT_NULL(node = NODE_CDR(node))); + break; + + case NODE_ALT: + { + Node *x, *y; + y = node; + do { + x = NODE_CAR(y); + tmin = tree_min_len(x, env); + if (y == node) len = tmin; + else if (len > tmin) len = tmin; + } while (IS_NOT_NULL(y = NODE_CDR(y))); + } + break; + + case NODE_STRING: + { + StrNode* sn = STR_(node); + len = (int )(sn->end - sn->s); + } + break; + + case NODE_CTYPE: + case NODE_CCLASS: + len = ONIGENC_MBC_MINLEN(env->enc); + break; + + case NODE_QUANT: + { + QuantNode* qn = QUANT_(node); + + if (qn->lower > 0) { + len = tree_min_len(NODE_BODY(node), env); + len = distance_multiply(len, qn->lower); + } + } + break; + + case NODE_BAG: + { + BagNode* en = BAG_(node); + switch (en->type) { + case BAG_MEMORY: + if (NODE_IS_MIN_FIXED(node)) + len = en->min_len; + else { + if (NODE_IS_MARK1(node)) + len = 0; /* recursive */ + else { + NODE_STATUS_ADD(node, MARK1); + len = tree_min_len(NODE_BODY(node), env); + NODE_STATUS_REMOVE(node, MARK1); + + en->min_len = len; + NODE_STATUS_ADD(node, MIN_FIXED); + } + } + break; + + case BAG_OPTION: + case BAG_STOP_BACKTRACK: + len = tree_min_len(NODE_BODY(node), env); + break; + case BAG_IF_ELSE: + { + OnigLen elen; + + len = tree_min_len(NODE_BODY(node), env); + if (IS_NOT_NULL(en->te.Then)) + len += tree_min_len(en->te.Then, env); + if (IS_NOT_NULL(en->te.Else)) + elen = tree_min_len(en->te.Else, env); + else elen = 0; + + if (elen < len) len = elen; + } + break; + } + } + break; + + case NODE_GIMMICK: + { + GimmickNode* g = GIMMICK_(node); + if (g->type == GIMMICK_FAIL) { + len = INFINITE_LEN; + break; + } + } + /* fall */ + case NODE_ANCHOR: + default: + break; + } + + return len; +} +",0,"tree_min_len(Node* node, ScanEnv* env) +{ + OnigLen len; + OnigLen tmin; + + len = 0; + switch (NODE_TYPE(node)) { + case NODE_BACKREF: + if (! NODE_IS_CHECKER(node)) { + int i; + int* backs; + MemEnv* mem_env = SCANENV_MEMENV(env); + BackRefNode* br = BACKREF_(node); + if (NODE_IS_RECURSION(node)) break; + + backs = BACKREFS_P(br); + len = tree_min_len(mem_env[backs[0]].node, env); + for (i = 1; i < br->back_num; i++) { + tmin = tree_min_len(mem_env[backs[i]].node, env); + if (len > tmin) len = tmin; + } + } + break; + +#ifdef USE_CALL + case NODE_CALL: + { + Node* t = NODE_BODY(node); + if (NODE_IS_RECURSION(node)) { + if (NODE_IS_MIN_FIXED(t)) + len = BAG_(t)->min_len; + } + else + len = tree_min_len(t, env); + } + break; +#endif + + case NODE_LIST: + do { + tmin = tree_min_len(NODE_CAR(node), env); + len = distance_add(len, tmin); + } while (IS_NOT_NULL(node = NODE_CDR(node))); + break; + + case NODE_ALT: + { + Node *x, *y; + y = node; + do { + x = NODE_CAR(y); + tmin = tree_min_len(x, env); + if (y == node) len = tmin; + else if (len > tmin) len = tmin; + } while (IS_NOT_NULL(y = NODE_CDR(y))); + } + break; + + case NODE_STRING: + { + StrNode* sn = STR_(node); + len = (int )(sn->end - sn->s); + } + break; + + case NODE_CTYPE: + case NODE_CCLASS: + len = ONIGENC_MBC_MINLEN(env->enc); + break; + + case NODE_QUANT: + { + QuantNode* qn = QUANT_(node); + + if (qn->lower > 0) { + len = tree_min_len(NODE_BODY(node), env); + len = distance_multiply(len, qn->lower); + } + } + break; + + case NODE_BAG: + { + BagNode* en = BAG_(node); + switch (en->type) { + case BAG_MEMORY: + if (NODE_IS_MIN_FIXED(node)) + len = en->min_len; + else { + if (NODE_IS_MARK1(node)) + len = 0; /* recursive */ + else { + NODE_STATUS_ADD(node, MARK1); + len = tree_min_len(NODE_BODY(node), env); + NODE_STATUS_REMOVE(node, MARK1); + + en->min_len = len; + NODE_STATUS_ADD(node, MIN_FIXED); + } + } + break; + + case BAG_OPTION: + case BAG_STOP_BACKTRACK: + len = tree_min_len(NODE_BODY(node), env); + break; + case BAG_IF_ELSE: + { + OnigLen elen; + + len = tree_min_len(NODE_BODY(node), env); + if (IS_NOT_NULL(en->te.Then)) + len += tree_min_len(en->te.Then, env); + if (IS_NOT_NULL(en->te.Else)) + elen = tree_min_len(en->te.Else, env); + else elen = 0; + + if (elen < len) len = elen; + } + break; + } + } + break; + + case NODE_GIMMICK: + { + GimmickNode* g = GIMMICK_(node); + if (g->type == GIMMICK_FAIL) { + len = INFINITE_LEN; + break; + } + } + /* fall */ + case NODE_ANCHOR: + default: + break; + } + + return len; +} +","@@ -1307,8 +1307,9 @@ compile_length_bag_node(BagNode* node, regex_t* reg) + len += tlen; + } + ++ len += SIZE_OP_JUMP + SIZE_OP_ATOMIC_END; ++ + if (IS_NOT_NULL(Else)) { +- len += SIZE_OP_JUMP; + tlen = compile_length_tree(Else, reg); + if (tlen < 0) return tlen; + len += tlen; +@@ -1455,7 +1456,7 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + + case BAG_IF_ELSE: + { +- int cond_len, then_len, jump_len; ++ int cond_len, then_len, else_len, jump_len; + Node* cond = NODE_BAG_BODY(node); + Node* Then = node->te.Then; + Node* Else = node->te.Else; +@@ -1472,8 +1473,7 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + else + then_len = 0; + +- jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END; +- if (IS_NOT_NULL(Else)) jump_len += SIZE_OP_JUMP; ++ jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END + SIZE_OP_JUMP; + + r = add_op(reg, OP_PUSH); + if (r != 0) return r; +@@ -1490,11 +1490,20 @@ compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env) + } + + if (IS_NOT_NULL(Else)) { +- int else_len = compile_length_tree(Else, reg); +- r = add_op(reg, OP_JUMP); +- if (r != 0) return r; +- COP(reg)->jump.addr = else_len + SIZE_INC_OP; ++ else_len = compile_length_tree(Else, reg); ++ if (else_len < 0) return else_len; ++ } ++ else ++ else_len = 0; + ++ r = add_op(reg, OP_JUMP); ++ if (r != 0) return r; ++ COP(reg)->jump.addr = SIZE_OP_ATOMIC_END + else_len + SIZE_INC_OP; ++ ++ r = add_op(reg, OP_ATOMIC_END); ++ if (r != 0) return r; ++ ++ if (IS_NOT_NULL(Else)) { + r = compile_tree(Else, reg, env); + } + }",869,1105,2048 +63,"pdf_show_pattern(fz_context *ctx, pdf_run_processor *pr, pdf_pattern *pat, pdf_gstate *pat_gstate, const fz_rect *area, int what) +{ + pdf_gstate *gstate; + int gparent_save; + fz_matrix ptm, invptm, gparent_save_ctm; + int x0, y0, x1, y1; + float fx0, fy0, fx1, fy1; + fz_rect local_area; + int id; + + pdf_gsave(ctx, pr); + gstate = pr->gstate + pr->gtop; + + /* Patterns are run with the gstate of the parent */ + pdf_copy_pattern_gstate(ctx, gstate, pat_gstate); + + if (pat->ismask) + { + pdf_unset_pattern(ctx, pr, PDF_FILL); + pdf_unset_pattern(ctx, pr, PDF_STROKE); + if (what == PDF_FILL) + { + pdf_drop_material(ctx, &gstate->stroke); + pdf_keep_material(ctx, &gstate->fill); + gstate->stroke = gstate->fill; + } + if (what == PDF_STROKE) + { + pdf_drop_material(ctx, &gstate->fill); + pdf_keep_material(ctx, &gstate->stroke); + gstate->fill = gstate->stroke; + } + id = 0; /* don't cache uncolored patterns, since we colorize them when drawing */ + } + else + { + pdf_unset_pattern(ctx, pr, what); + id = pat->id; + } + + /* don't apply soft masks to objects in the pattern as well */ + if (gstate->softmask) + { + pdf_drop_xobject(ctx, gstate->softmask); + gstate->softmask = NULL; + } + + fz_concat(&ptm, &pat->matrix, &pat_gstate->ctm); + fz_invert_matrix(&invptm, &ptm); + + /* The parent_ctm is amended with our pattern matrix */ + gparent_save = pr->gparent; + pr->gparent = pr->gtop-1; + gparent_save_ctm = pr->gstate[pr->gparent].ctm; + pr->gstate[pr->gparent].ctm = ptm; + + fz_try(ctx) + { + /* patterns are painted using the parent_ctm. area = bbox of + * shape to be filled in device space. Map it back to pattern + * space. */ + local_area = *area; + fz_transform_rect(&local_area, &invptm); + + fx0 = (local_area.x0 - pat->bbox.x0) / pat->xstep; + fy0 = (local_area.y0 - pat->bbox.y0) / pat->ystep; + fx1 = (local_area.x1 - pat->bbox.x0) / pat->xstep; + fy1 = (local_area.y1 - pat->bbox.y0) / pat->ystep; + if (fx0 > fx1) + { + float t = fx0; fx0 = fx1; fx1 = t; + } + if (fy0 > fy1) + { + float t = fy0; fy0 = fy1; fy1 = t; + } + +#ifdef TILE + /* We have tried various formulations in the past, but this one is + * best we've found; only use it as a tile if a whole repeat is + * required in at least one direction. Note, that this allows for + * 'sections' of 4 tiles to be show, but all non-overlapping. */ + if (fx1-fx0 > 1 || fy1-fy0 > 1) +#else + if (0) +#endif + { + int cached = fz_begin_tile_id(ctx, pr->dev, &local_area, &pat->bbox, pat->xstep, pat->ystep, &ptm, id); + if (cached) + { + fz_end_tile(ctx, pr->dev); + } + else + { + gstate->ctm = ptm; + pdf_gsave(ctx, pr); + fz_try(ctx) + pdf_process_contents(ctx, (pdf_processor*)pr, pat->document, pat->resources, pat->contents, NULL); + fz_always(ctx) + { + pdf_grestore(ctx, pr); + fz_end_tile(ctx, pr->dev); + } + fz_catch(ctx) + fz_rethrow(ctx); + } + } + else + { + int x, y; + + /* When calculating the number of tiles required, we adjust by + * a small amount to allow for rounding errors. By choosing + * this amount to be smaller than 1/256, we guarantee we won't + * cause problems that will be visible even under our most + * extreme antialiasing. */ + x0 = floorf(fx0 + 0.001f); + y0 = floorf(fy0 + 0.001f); + x1 = ceilf(fx1 - 0.001f); + y1 = ceilf(fy1 - 0.001f); + /* The above adjustments cause problems for sufficiently + * large values for xstep/ystep which may be used if the + * pattern is expected to be rendered exactly once. */ + if (fx1 > fx0 && x1 == x0) + x1 = x0 + 1; + if (fy1 > fy0 && y1 == y0) + y1 = y0 + 1; + + for (y = y0; y < y1; y++) + { + for (x = x0; x < x1; x++) + { + gstate->ctm = ptm; + fz_pre_translate(&gstate->ctm, x * pat->xstep, y * pat->ystep); + pdf_gsave(ctx, pr); + fz_try(ctx) + pdf_process_contents(ctx, (pdf_processor*)pr, pat->document, pat->resources, pat->contents, NULL); + fz_always(ctx) + pdf_grestore(ctx, pr); + fz_catch(ctx) + fz_rethrow(ctx); + } + } + } + } + fz_always(ctx) + { + pr->gstate[pr->gparent].ctm = gparent_save_ctm; + pr->gparent = gparent_save; + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } + + pdf_grestore(ctx, pr); +} +",0,"pdf_show_pattern(fz_context *ctx, pdf_run_processor *pr, pdf_pattern *pat, pdf_gstate *pat_gstate, const fz_rect *area, int what) +{ + pdf_gstate *gstate; + int gparent_save; + fz_matrix ptm, invptm, gparent_save_ctm; + int x0, y0, x1, y1; + float fx0, fy0, fx1, fy1; + fz_rect local_area; + int id; + + pdf_gsave(ctx, pr); + gstate = pr->gstate + pr->gtop; + + /* Patterns are run with the gstate of the parent */ + pdf_copy_pattern_gstate(ctx, gstate, pat_gstate); + + if (pat->ismask) + { + pdf_unset_pattern(ctx, pr, PDF_FILL); + pdf_unset_pattern(ctx, pr, PDF_STROKE); + if (what == PDF_FILL) + { + pdf_drop_material(ctx, &gstate->stroke); + pdf_keep_material(ctx, &gstate->fill); + gstate->stroke = gstate->fill; + } + if (what == PDF_STROKE) + { + pdf_drop_material(ctx, &gstate->fill); + pdf_keep_material(ctx, &gstate->stroke); + gstate->fill = gstate->stroke; + } + id = 0; /* don't cache uncolored patterns, since we colorize them when drawing */ + } + else + { + pdf_unset_pattern(ctx, pr, what); + id = pat->id; + } + + /* don't apply soft masks to objects in the pattern as well */ + if (gstate->softmask) + { + pdf_drop_xobject(ctx, gstate->softmask); + gstate->softmask = NULL; + } + + fz_concat(&ptm, &pat->matrix, &pat_gstate->ctm); + fz_invert_matrix(&invptm, &ptm); + + /* The parent_ctm is amended with our pattern matrix */ + gparent_save = pr->gparent; + pr->gparent = pr->gtop-1; + gparent_save_ctm = pr->gstate[pr->gparent].ctm; + pr->gstate[pr->gparent].ctm = ptm; + + fz_try(ctx) + { + /* patterns are painted using the parent_ctm. area = bbox of + * shape to be filled in device space. Map it back to pattern + * space. */ + local_area = *area; + fz_transform_rect(&local_area, &invptm); + + fx0 = (local_area.x0 - pat->bbox.x0) / pat->xstep; + fy0 = (local_area.y0 - pat->bbox.y0) / pat->ystep; + fx1 = (local_area.x1 - pat->bbox.x0) / pat->xstep; + fy1 = (local_area.y1 - pat->bbox.y0) / pat->ystep; + if (fx0 > fx1) + { + float t = fx0; fx0 = fx1; fx1 = t; + } + if (fy0 > fy1) + { + float t = fy0; fy0 = fy1; fy1 = t; + } + +#ifdef TILE + /* We have tried various formulations in the past, but this one is + * best we've found; only use it as a tile if a whole repeat is + * required in at least one direction. Note, that this allows for + * 'sections' of 4 tiles to be show, but all non-overlapping. */ + if (fx1-fx0 > 1 || fy1-fy0 > 1) +#else + if (0) +#endif + { + int cached = fz_begin_tile_id(ctx, pr->dev, &local_area, &pat->bbox, pat->xstep, pat->ystep, &ptm, id); + if (cached) + { + fz_end_tile(ctx, pr->dev); + } + else + { + gstate->ctm = ptm; + pdf_gsave(ctx, pr); + fz_try(ctx) + pdf_process_contents(ctx, (pdf_processor*)pr, pat->document, pat->resources, pat->contents, NULL); + fz_always(ctx) + { + pdf_grestore(ctx, pr); + fz_end_tile(ctx, pr->dev); + } + fz_catch(ctx) + fz_rethrow(ctx); + } + } + else + { + int x, y; + + /* When calculating the number of tiles required, we adjust by + * a small amount to allow for rounding errors. By choosing + * this amount to be smaller than 1/256, we guarantee we won't + * cause problems that will be visible even under our most + * extreme antialiasing. */ + x0 = floorf(fx0 + 0.001f); + y0 = floorf(fy0 + 0.001f); + x1 = ceilf(fx1 - 0.001f); + y1 = ceilf(fy1 - 0.001f); + /* The above adjustments cause problems for sufficiently + * large values for xstep/ystep which may be used if the + * pattern is expected to be rendered exactly once. */ + if (fx1 > fx0 && x1 == x0) + x1 = x0 + 1; + if (fy1 > fy0 && y1 == y0) + y1 = y0 + 1; + + for (y = y0; y < y1; y++) + { + for (x = x0; x < x1; x++) + { + gstate->ctm = ptm; + fz_pre_translate(&gstate->ctm, x * pat->xstep, y * pat->ystep); + pdf_gsave(ctx, pr); + fz_try(ctx) + pdf_process_contents(ctx, (pdf_processor*)pr, pat->document, pat->resources, pat->contents, NULL); + fz_always(ctx) + pdf_grestore(ctx, pr); + fz_catch(ctx) + fz_rethrow(ctx); + } + } + } + } + fz_always(ctx) + { + pr->gstate[pr->gparent].ctm = gparent_save_ctm; + pr->gparent = gparent_save; + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } + + pdf_grestore(ctx, pr); +} +","@@ -135,7 +135,7 @@ begin_softmask(fz_context *ctx, pdf_run_processor *pr, softmask_save *save) + mask_colorspace = pdf_xobject_colorspace(ctx, softmask); + + if (gstate->luminosity && !mask_colorspace) +- mask_colorspace = fz_device_gray(ctx); ++ mask_colorspace = fz_keep_colorspace(ctx, fz_device_gray(ctx)); + + fz_try(ctx) + {",1460,1696,2048 +18342,"static int read_entry( + git_index_entry **out, + size_t *out_size, + git_index *index, + const void *buffer, + size_t buffer_size, + const char *last) +{ + size_t path_length, entry_size; + const char *path_ptr; + struct entry_short source; + git_index_entry entry = {{0}}; + bool compressed = index->version >= INDEX_VERSION_NUMBER_COMP; + char *tmp_path = NULL; + + if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size) + return -1; + + /* buffer is not guaranteed to be aligned */ + memcpy(&source, buffer, sizeof(struct entry_short)); + + entry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds); + entry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds); + entry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds); + entry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds); + entry.dev = ntohl(source.dev); + entry.ino = ntohl(source.ino); + entry.mode = ntohl(source.mode); + entry.uid = ntohl(source.uid); + entry.gid = ntohl(source.gid); + entry.file_size = ntohl(source.file_size); + git_oid_cpy(&entry.id, &source.oid); + entry.flags = ntohs(source.flags); + + if (entry.flags & GIT_IDXENTRY_EXTENDED) { + uint16_t flags_raw; + size_t flags_offset; + + flags_offset = offsetof(struct entry_long, flags_extended); + memcpy(&flags_raw, (const char *) buffer + flags_offset, + sizeof(flags_raw)); + flags_raw = ntohs(flags_raw); + + memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw)); + path_ptr = (const char *) buffer + offsetof(struct entry_long, path); + } else + path_ptr = (const char *) buffer + offsetof(struct entry_short, path); + + if (!compressed) { + path_length = entry.flags & GIT_IDXENTRY_NAMEMASK; + + /* if this is a very long string, we must find its + * real length without overflowing */ + if (path_length == 0xFFF) { + const char *path_end; + + path_end = memchr(path_ptr, '\0', buffer_size); + if (path_end == NULL) + return -1; + + path_length = path_end - path_ptr; + } + + entry_size = index_entry_size(path_length, 0, entry.flags); + entry.path = (char *)path_ptr; + } else { + size_t varint_len, last_len, prefix_len, suffix_len, path_len; + uintmax_t strip_len; + + strip_len = git_decode_varint((const unsigned char *)path_ptr, &varint_len); + last_len = strlen(last); + + if (varint_len == 0 || last_len < strip_len) + return index_error_invalid(""incorrect prefix length""); + + prefix_len = last_len - strip_len; + suffix_len = strlen(path_ptr + varint_len); + + GITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len); + GITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1); + tmp_path = git__malloc(path_len); + GITERR_CHECK_ALLOC(tmp_path); + + memcpy(tmp_path, last, prefix_len); + memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1); + entry_size = index_entry_size(suffix_len, varint_len, entry.flags); + entry.path = tmp_path; + } + + if (entry_size == 0) + return -1; + + if (INDEX_FOOTER_SIZE + entry_size > buffer_size) + return -1; + + if (index_entry_dup(out, index, &entry) < 0) { + git__free(tmp_path); + return -1; + } + + git__free(tmp_path); + *out_size = entry_size; + return 0; +} +",1,"static int read_entry( + git_index_entry **out, + size_t *out_size, + git_index *index, + const void *buffer, + size_t buffer_size, + const char *last) +{ + size_t path_length, entry_size; + const char *path_ptr; + struct entry_short source; + git_index_entry entry = {{0}}; + bool compressed = index->version >= INDEX_VERSION_NUMBER_COMP; + char *tmp_path = NULL; + + if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size) + return -1; + + /* buffer is not guaranteed to be aligned */ + memcpy(&source, buffer, sizeof(struct entry_short)); + + entry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds); + entry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds); + entry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds); + entry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds); + entry.dev = ntohl(source.dev); + entry.ino = ntohl(source.ino); + entry.mode = ntohl(source.mode); + entry.uid = ntohl(source.uid); + entry.gid = ntohl(source.gid); + entry.file_size = ntohl(source.file_size); + git_oid_cpy(&entry.id, &source.oid); + entry.flags = ntohs(source.flags); + + if (entry.flags & GIT_IDXENTRY_EXTENDED) { + uint16_t flags_raw; + size_t flags_offset; + + flags_offset = offsetof(struct entry_long, flags_extended); + memcpy(&flags_raw, (const char *) buffer + flags_offset, + sizeof(flags_raw)); + flags_raw = ntohs(flags_raw); + + memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw)); + path_ptr = (const char *) buffer + offsetof(struct entry_long, path); + } else + path_ptr = (const char *) buffer + offsetof(struct entry_short, path); + + if (!compressed) { + path_length = entry.flags & GIT_IDXENTRY_NAMEMASK; + + /* if this is a very long string, we must find its + * real length without overflowing */ + if (path_length == 0xFFF) { + const char *path_end; + + path_end = memchr(path_ptr, '\0', buffer_size); + if (path_end == NULL) + return -1; + + path_length = path_end - path_ptr; + } + + entry_size = index_entry_size(path_length, 0, entry.flags); + entry.path = (char *)path_ptr; + } else { + size_t varint_len, last_len, prefix_len, suffix_len, path_len; + uintmax_t strip_len; + + strip_len = git_decode_varint((const unsigned char *)path_ptr, &varint_len); + last_len = strlen(last); + + if (varint_len == 0 || last_len < strip_len) + return index_error_invalid(""incorrect prefix length""); + + prefix_len = last_len - strip_len; + suffix_len = strlen(path_ptr + varint_len); + + GITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len); + GITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1); + + if (path_len > GIT_PATH_MAX) + return index_error_invalid(""unreasonable path length""); + + tmp_path = git__malloc(path_len); + GITERR_CHECK_ALLOC(tmp_path); + + memcpy(tmp_path, last, prefix_len); + memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1); + entry_size = index_entry_size(suffix_len, varint_len, entry.flags); + entry.path = tmp_path; + } + + if (entry_size == 0) + return -1; + + if (INDEX_FOOTER_SIZE + entry_size > buffer_size) + return -1; + + if (index_entry_dup(out, index, &entry) < 0) { + git__free(tmp_path); + return -1; + } + + git__free(tmp_path); + *out_size = entry_size; + return 0; +} +","@@ -2379,6 +2379,10 @@ static int read_entry( + + GITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len); + GITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1); ++ ++ if (path_len > GIT_PATH_MAX) ++ return index_error_invalid(""unreasonable path length""); ++ + tmp_path = git__malloc(path_len); + GITERR_CHECK_ALLOC(tmp_path); + ",809,1045,2048 +6395,"static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) +{ + VP56RangeCoder *c = &s->c; + int header_size, hscale, vscale, ret; + int width = s->avctx->width; + int height = s->avctx->height; + + if (buf_size < 3) { + av_log(s->avctx, AV_LOG_ERROR, ""Insufficent data (%d) for header\n"", buf_size); + return AVERROR_INVALIDDATA; + } + + s->keyframe = !(buf[0] & 1); + s->profile = (buf[0]>>1) & 7; + s->invisible = !(buf[0] & 0x10); + header_size = AV_RL24(buf) >> 5; + buf += 3; + buf_size -= 3; + + if (s->profile > 3) + av_log(s->avctx, AV_LOG_WARNING, ""Unknown profile %d\n"", s->profile); + + if (!s->profile) + memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, + sizeof(s->put_pixels_tab)); + else // profile 1-3 use bilinear, 4+ aren't defined so whatever + memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab, + sizeof(s->put_pixels_tab)); + + if (header_size > buf_size - 7 * s->keyframe) { + av_log(s->avctx, AV_LOG_ERROR, ""Header size larger than data provided\n""); + return AVERROR_INVALIDDATA; + } + + if (s->keyframe) { + if (AV_RL24(buf) != 0x2a019d) { + av_log(s->avctx, AV_LOG_ERROR, + ""Invalid start code 0x%x\n"", AV_RL24(buf)); + return AVERROR_INVALIDDATA; + } + width = AV_RL16(buf + 3) & 0x3fff; + height = AV_RL16(buf + 5) & 0x3fff; + hscale = buf[4] >> 6; + vscale = buf[6] >> 6; + buf += 7; + buf_size -= 7; + + if (hscale || vscale) + avpriv_request_sample(s->avctx, ""Upscaling""); + + s->update_golden = s->update_altref = VP56_FRAME_CURRENT; + vp78_reset_probability_tables(s); + memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, + sizeof(s->prob->pred16x16)); + memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter, + sizeof(s->prob->pred8x8c)); + memcpy(s->prob->mvc, vp8_mv_default_prob, + sizeof(s->prob->mvc)); + memset(&s->segmentation, 0, sizeof(s->segmentation)); + memset(&s->lf_delta, 0, sizeof(s->lf_delta)); + } + + ret = ff_vp56_init_range_decoder(c, buf, header_size); + if (ret < 0) + return ret; + buf += header_size; + buf_size -= header_size; + + if (s->keyframe) { + s->colorspace = vp8_rac_get(c); + if (s->colorspace) + av_log(s->avctx, AV_LOG_WARNING, ""Unspecified colorspace\n""); + s->fullrange = vp8_rac_get(c); + } + + if ((s->segmentation.enabled = vp8_rac_get(c))) + parse_segment_info(s); + else + s->segmentation.update_map = 0; // FIXME: move this to some init function? + + s->filter.simple = vp8_rac_get(c); + s->filter.level = vp8_rac_get_uint(c, 6); + s->filter.sharpness = vp8_rac_get_uint(c, 3); + + if ((s->lf_delta.enabled = vp8_rac_get(c))) + if (vp8_rac_get(c)) + update_lf_deltas(s); + + if (setup_partitions(s, buf, buf_size)) { + av_log(s->avctx, AV_LOG_ERROR, ""Invalid partitions\n""); + return AVERROR_INVALIDDATA; + } + + if (!s->macroblocks_base || /* first frame */ + width != s->avctx->width || height != s->avctx->height || + (width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) + if ((ret = vp8_update_dimensions(s, width, height)) < 0) + return ret; + + vp8_get_quants(s); + + if (!s->keyframe) { + update_refs(s); + s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c); + s->sign_bias[VP56_FRAME_GOLDEN2 /* altref */] = vp8_rac_get(c); + } + + if (!(s->update_probabilities = vp8_rac_get(c))) + s->prob[1] = s->prob[0]; + + s->update_last = s->keyframe || vp8_rac_get(c); + + vp78_update_probability_tables(s); + + if ((s->mbskip_enabled = vp8_rac_get(c))) + s->prob->mbskip = vp8_rac_get_uint(c, 8); + + if (!s->keyframe) { + s->prob->intra = vp8_rac_get_uint(c, 8); + s->prob->last = vp8_rac_get_uint(c, 8); + s->prob->golden = vp8_rac_get_uint(c, 8); + vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE); + } + + return 0; +} +",0,"static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) +{ + VP56RangeCoder *c = &s->c; + int header_size, hscale, vscale, ret; + int width = s->avctx->width; + int height = s->avctx->height; + + if (buf_size < 3) { + av_log(s->avctx, AV_LOG_ERROR, ""Insufficent data (%d) for header\n"", buf_size); + return AVERROR_INVALIDDATA; + } + + s->keyframe = !(buf[0] & 1); + s->profile = (buf[0]>>1) & 7; + s->invisible = !(buf[0] & 0x10); + header_size = AV_RL24(buf) >> 5; + buf += 3; + buf_size -= 3; + + if (s->profile > 3) + av_log(s->avctx, AV_LOG_WARNING, ""Unknown profile %d\n"", s->profile); + + if (!s->profile) + memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, + sizeof(s->put_pixels_tab)); + else // profile 1-3 use bilinear, 4+ aren't defined so whatever + memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab, + sizeof(s->put_pixels_tab)); + + if (header_size > buf_size - 7 * s->keyframe) { + av_log(s->avctx, AV_LOG_ERROR, ""Header size larger than data provided\n""); + return AVERROR_INVALIDDATA; + } + + if (s->keyframe) { + if (AV_RL24(buf) != 0x2a019d) { + av_log(s->avctx, AV_LOG_ERROR, + ""Invalid start code 0x%x\n"", AV_RL24(buf)); + return AVERROR_INVALIDDATA; + } + width = AV_RL16(buf + 3) & 0x3fff; + height = AV_RL16(buf + 5) & 0x3fff; + hscale = buf[4] >> 6; + vscale = buf[6] >> 6; + buf += 7; + buf_size -= 7; + + if (hscale || vscale) + avpriv_request_sample(s->avctx, ""Upscaling""); + + s->update_golden = s->update_altref = VP56_FRAME_CURRENT; + vp78_reset_probability_tables(s); + memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, + sizeof(s->prob->pred16x16)); + memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter, + sizeof(s->prob->pred8x8c)); + memcpy(s->prob->mvc, vp8_mv_default_prob, + sizeof(s->prob->mvc)); + memset(&s->segmentation, 0, sizeof(s->segmentation)); + memset(&s->lf_delta, 0, sizeof(s->lf_delta)); + } + + ret = ff_vp56_init_range_decoder(c, buf, header_size); + if (ret < 0) + return ret; + buf += header_size; + buf_size -= header_size; + + if (s->keyframe) { + s->colorspace = vp8_rac_get(c); + if (s->colorspace) + av_log(s->avctx, AV_LOG_WARNING, ""Unspecified colorspace\n""); + s->fullrange = vp8_rac_get(c); + } + + if ((s->segmentation.enabled = vp8_rac_get(c))) + parse_segment_info(s); + else + s->segmentation.update_map = 0; // FIXME: move this to some init function? + + s->filter.simple = vp8_rac_get(c); + s->filter.level = vp8_rac_get_uint(c, 6); + s->filter.sharpness = vp8_rac_get_uint(c, 3); + + if ((s->lf_delta.enabled = vp8_rac_get(c))) + if (vp8_rac_get(c)) + update_lf_deltas(s); + + if (setup_partitions(s, buf, buf_size)) { + av_log(s->avctx, AV_LOG_ERROR, ""Invalid partitions\n""); + return AVERROR_INVALIDDATA; + } + + if (!s->macroblocks_base || /* first frame */ + width != s->avctx->width || height != s->avctx->height || + (width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) + if ((ret = vp8_update_dimensions(s, width, height)) < 0) + return ret; + + vp8_get_quants(s); + + if (!s->keyframe) { + update_refs(s); + s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c); + s->sign_bias[VP56_FRAME_GOLDEN2 /* altref */] = vp8_rac_get(c); + } + + if (!(s->update_probabilities = vp8_rac_get(c))) + s->prob[1] = s->prob[0]; + + s->update_last = s->keyframe || vp8_rac_get(c); + + vp78_update_probability_tables(s); + + if ((s->mbskip_enabled = vp8_rac_get(c))) + s->prob->mbskip = vp8_rac_get_uint(c, 8); + + if (!s->keyframe) { + s->prob->intra = vp8_rac_get_uint(c, 8); + s->prob->last = vp8_rac_get_uint(c, 8); + s->prob->golden = vp8_rac_get_uint(c, 8); + vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE); + } + + return 0; +} +","@@ -2550,6 +2550,8 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, + enum AVDiscard skip_thresh; + VP8Frame *av_uninit(curframe), *prev_frame; + ++ av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVA420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P); ++ + if (is_vp7) + ret = vp7_decode_frame_header(s, avpkt->data, avpkt->size); + else",1335,1571,2048 +2185,"static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, pte_t *page_table, pmd_t *pmd, + unsigned int flags, pte_t orig_pte) +{ + spinlock_t *ptl; + struct page *page, *swapcache = NULL; + swp_entry_t entry; + pte_t pte; + int locked; + struct mem_cgroup *ptr; + int exclusive = 0; + int ret = 0; + + if (!pte_unmap_same(mm, pmd, page_table, orig_pte)) + goto out; + + entry = pte_to_swp_entry(orig_pte); + if (unlikely(non_swap_entry(entry))) { + if (is_migration_entry(entry)) { + migration_entry_wait(mm, pmd, address); + } else if (is_hwpoison_entry(entry)) { + ret = VM_FAULT_HWPOISON; + } else { + print_bad_pte(vma, address, orig_pte, NULL); + ret = VM_FAULT_SIGBUS; + } + goto out; + } + delayacct_set_flag(DELAYACCT_PF_SWAPIN); + page = lookup_swap_cache(entry); + if (!page) { + grab_swap_token(mm); /* Contend for token _before_ read-in */ + page = swapin_readahead(entry, + GFP_HIGHUSER_MOVABLE, vma, address); + if (!page) { + /* + * Back out if somebody else faulted in this pte + * while we released the pte lock. + */ + page_table = pte_offset_map_lock(mm, pmd, address, &ptl); + if (likely(pte_same(*page_table, orig_pte))) + ret = VM_FAULT_OOM; + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); + goto unlock; + } + + /* Had to read the page from swap area: Major fault */ + ret = VM_FAULT_MAJOR; + count_vm_event(PGMAJFAULT); + mem_cgroup_count_vm_event(mm, PGMAJFAULT); + } else if (PageHWPoison(page)) { + /* + * hwpoisoned dirty swapcache pages are kept for killing + * owner processes (which may be unknown at hwpoison time) + */ + ret = VM_FAULT_HWPOISON; + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); + goto out_release; + } + + locked = lock_page_or_retry(page, mm, flags); + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); + if (!locked) { + ret |= VM_FAULT_RETRY; + goto out_release; + } + + /* + * Make sure try_to_free_swap or reuse_swap_page or swapoff did not + * release the swapcache from under us. The page pin, and pte_same + * test below, are not enough to exclude that. Even if it is still + * swapcache, we need to check that the page's swap has not changed. + */ + if (unlikely(!PageSwapCache(page) || page_private(page) != entry.val)) + goto out_page; + + if (ksm_might_need_to_copy(page, vma, address)) { + swapcache = page; + page = ksm_does_need_to_copy(page, vma, address); + + if (unlikely(!page)) { + ret = VM_FAULT_OOM; + page = swapcache; + swapcache = NULL; + goto out_page; + } + } + + if (mem_cgroup_try_charge_swapin(mm, page, GFP_KERNEL, &ptr)) { + ret = VM_FAULT_OOM; + goto out_page; + } + + /* + * Back out if somebody else already faulted in this pte. + */ + page_table = pte_offset_map_lock(mm, pmd, address, &ptl); + if (unlikely(!pte_same(*page_table, orig_pte))) + goto out_nomap; + + if (unlikely(!PageUptodate(page))) { + ret = VM_FAULT_SIGBUS; + goto out_nomap; + } + + /* + * The page isn't present yet, go ahead with the fault. + * + * Be careful about the sequence of operations here. + * To get its accounting right, reuse_swap_page() must be called + * while the page is counted on swap but not yet in mapcount i.e. + * before page_add_anon_rmap() and swap_free(); try_to_free_swap() + * must be called after the swap_free(), or it will never succeed. + * Because delete_from_swap_page() may be called by reuse_swap_page(), + * mem_cgroup_commit_charge_swapin() may not be able to find swp_entry + * in page->private. In this case, a record in swap_cgroup is silently + * discarded at swap_free(). + */ + + inc_mm_counter_fast(mm, MM_ANONPAGES); + dec_mm_counter_fast(mm, MM_SWAPENTS); + pte = mk_pte(page, vma->vm_page_prot); + if ((flags & FAULT_FLAG_WRITE) && reuse_swap_page(page)) { + pte = maybe_mkwrite(pte_mkdirty(pte), vma); + flags &= ~FAULT_FLAG_WRITE; + ret |= VM_FAULT_WRITE; + exclusive = 1; + } + flush_icache_page(vma, page); + set_pte_at(mm, address, page_table, pte); + do_page_add_anon_rmap(page, vma, address, exclusive); + /* It's better to call commit-charge after rmap is established */ + mem_cgroup_commit_charge_swapin(page, ptr); + + swap_free(entry); + if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page)) + try_to_free_swap(page); + unlock_page(page); + if (swapcache) { + /* + * Hold the lock to avoid the swap entry to be reused + * until we take the PT lock for the pte_same() check + * (to avoid false positives from pte_same). For + * further safety release the lock after the swap_free + * so that the swap count won't change under a + * parallel locked swapcache. + */ + unlock_page(swapcache); + page_cache_release(swapcache); + } + + if (flags & FAULT_FLAG_WRITE) { + ret |= do_wp_page(mm, vma, address, page_table, pmd, ptl, pte); + if (ret & VM_FAULT_ERROR) + ret &= VM_FAULT_ERROR; + goto out; + } + + /* No need to invalidate - it was non-present before */ + update_mmu_cache(vma, address, page_table); +unlock: + pte_unmap_unlock(page_table, ptl); +out: + return ret; +out_nomap: + mem_cgroup_cancel_charge_swapin(ptr); + pte_unmap_unlock(page_table, ptl); +out_page: + unlock_page(page); +out_release: + page_cache_release(page); + if (swapcache) { + unlock_page(swapcache); + page_cache_release(swapcache); + } + return ret; +} +",0,"static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, pte_t *page_table, pmd_t *pmd, + unsigned int flags, pte_t orig_pte) +{ + spinlock_t *ptl; + struct page *page, *swapcache = NULL; + swp_entry_t entry; + pte_t pte; + int locked; + struct mem_cgroup *ptr; + int exclusive = 0; + int ret = 0; + + if (!pte_unmap_same(mm, pmd, page_table, orig_pte)) + goto out; + + entry = pte_to_swp_entry(orig_pte); + if (unlikely(non_swap_entry(entry))) { + if (is_migration_entry(entry)) { + migration_entry_wait(mm, pmd, address); + } else if (is_hwpoison_entry(entry)) { + ret = VM_FAULT_HWPOISON; + } else { + print_bad_pte(vma, address, orig_pte, NULL); + ret = VM_FAULT_SIGBUS; + } + goto out; + } + delayacct_set_flag(DELAYACCT_PF_SWAPIN); + page = lookup_swap_cache(entry); + if (!page) { + grab_swap_token(mm); /* Contend for token _before_ read-in */ + page = swapin_readahead(entry, + GFP_HIGHUSER_MOVABLE, vma, address); + if (!page) { + /* + * Back out if somebody else faulted in this pte + * while we released the pte lock. + */ + page_table = pte_offset_map_lock(mm, pmd, address, &ptl); + if (likely(pte_same(*page_table, orig_pte))) + ret = VM_FAULT_OOM; + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); + goto unlock; + } + + /* Had to read the page from swap area: Major fault */ + ret = VM_FAULT_MAJOR; + count_vm_event(PGMAJFAULT); + mem_cgroup_count_vm_event(mm, PGMAJFAULT); + } else if (PageHWPoison(page)) { + /* + * hwpoisoned dirty swapcache pages are kept for killing + * owner processes (which may be unknown at hwpoison time) + */ + ret = VM_FAULT_HWPOISON; + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); + goto out_release; + } + + locked = lock_page_or_retry(page, mm, flags); + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); + if (!locked) { + ret |= VM_FAULT_RETRY; + goto out_release; + } + + /* + * Make sure try_to_free_swap or reuse_swap_page or swapoff did not + * release the swapcache from under us. The page pin, and pte_same + * test below, are not enough to exclude that. Even if it is still + * swapcache, we need to check that the page's swap has not changed. + */ + if (unlikely(!PageSwapCache(page) || page_private(page) != entry.val)) + goto out_page; + + if (ksm_might_need_to_copy(page, vma, address)) { + swapcache = page; + page = ksm_does_need_to_copy(page, vma, address); + + if (unlikely(!page)) { + ret = VM_FAULT_OOM; + page = swapcache; + swapcache = NULL; + goto out_page; + } + } + + if (mem_cgroup_try_charge_swapin(mm, page, GFP_KERNEL, &ptr)) { + ret = VM_FAULT_OOM; + goto out_page; + } + + /* + * Back out if somebody else already faulted in this pte. + */ + page_table = pte_offset_map_lock(mm, pmd, address, &ptl); + if (unlikely(!pte_same(*page_table, orig_pte))) + goto out_nomap; + + if (unlikely(!PageUptodate(page))) { + ret = VM_FAULT_SIGBUS; + goto out_nomap; + } + + /* + * The page isn't present yet, go ahead with the fault. + * + * Be careful about the sequence of operations here. + * To get its accounting right, reuse_swap_page() must be called + * while the page is counted on swap but not yet in mapcount i.e. + * before page_add_anon_rmap() and swap_free(); try_to_free_swap() + * must be called after the swap_free(), or it will never succeed. + * Because delete_from_swap_page() may be called by reuse_swap_page(), + * mem_cgroup_commit_charge_swapin() may not be able to find swp_entry + * in page->private. In this case, a record in swap_cgroup is silently + * discarded at swap_free(). + */ + + inc_mm_counter_fast(mm, MM_ANONPAGES); + dec_mm_counter_fast(mm, MM_SWAPENTS); + pte = mk_pte(page, vma->vm_page_prot); + if ((flags & FAULT_FLAG_WRITE) && reuse_swap_page(page)) { + pte = maybe_mkwrite(pte_mkdirty(pte), vma); + flags &= ~FAULT_FLAG_WRITE; + ret |= VM_FAULT_WRITE; + exclusive = 1; + } + flush_icache_page(vma, page); + set_pte_at(mm, address, page_table, pte); + do_page_add_anon_rmap(page, vma, address, exclusive); + /* It's better to call commit-charge after rmap is established */ + mem_cgroup_commit_charge_swapin(page, ptr); + + swap_free(entry); + if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page)) + try_to_free_swap(page); + unlock_page(page); + if (swapcache) { + /* + * Hold the lock to avoid the swap entry to be reused + * until we take the PT lock for the pte_same() check + * (to avoid false positives from pte_same). For + * further safety release the lock after the swap_free + * so that the swap count won't change under a + * parallel locked swapcache. + */ + unlock_page(swapcache); + page_cache_release(swapcache); + } + + if (flags & FAULT_FLAG_WRITE) { + ret |= do_wp_page(mm, vma, address, page_table, pmd, ptl, pte); + if (ret & VM_FAULT_ERROR) + ret &= VM_FAULT_ERROR; + goto out; + } + + /* No need to invalidate - it was non-present before */ + update_mmu_cache(vma, address, page_table); +unlock: + pte_unmap_unlock(page_table, ptl); +out: + return ret; +out_nomap: + mem_cgroup_cancel_charge_swapin(ptr); + pte_unmap_unlock(page_table, ptl); +out_page: + unlock_page(page); +out_release: + page_cache_release(page); + if (swapcache) { + unlock_page(swapcache); + page_cache_release(swapcache); + } + return ret; +} +","@@ -1247,16 +1247,24 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb, + do { + next = pmd_addr_end(addr, end); + if (pmd_trans_huge(*pmd)) { +- if (next-addr != HPAGE_PMD_SIZE) { ++ if (next - addr != HPAGE_PMD_SIZE) { + VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem)); + split_huge_page_pmd(vma->vm_mm, pmd); + } else if (zap_huge_pmd(tlb, vma, pmd, addr)) +- continue; ++ goto next; + /* fall through */ + } +- if (pmd_none_or_clear_bad(pmd)) +- continue; ++ /* ++ * Here there can be other concurrent MADV_DONTNEED or ++ * trans huge page faults running, and if the pmd is ++ * none or trans huge it can change under us. This is ++ * because MADV_DONTNEED holds the mmap_sem in read ++ * mode. ++ */ ++ if (pmd_none_or_trans_huge_or_clear_bad(pmd)) ++ goto next; + next = zap_pte_range(tlb, vma, pmd, addr, next, details); ++next: + cond_resched(); + } while (pmd++, addr = next, addr != end); + ",1498,1734,2048 +18818,"void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) { + UNUSED(portIndex); + + if (mOutputPortSettingsChange != NONE) { + return; + } + + List &inQueue = getPortQueue(kInputPortIndex); + List &outQueue = getPortQueue(kOutputPortIndex); + + /* If input EOS is seen and decoder is not in flush mode, + * set the decoder in flush mode. + * There can be a case where EOS is sent along with last picture data + * In that case, only after decoding that input data, decoder has to be + * put in flush. This case is handled here */ + + if (mReceivedEOS && !mIsInFlush) { + setFlushMode(); + } + + while (!outQueue.empty()) { + BufferInfo *inInfo; + OMX_BUFFERHEADERTYPE *inHeader; + + BufferInfo *outInfo; + OMX_BUFFERHEADERTYPE *outHeader; + size_t timeStampIx; + + inInfo = NULL; + inHeader = NULL; + + if (!mIsInFlush) { + if (!inQueue.empty()) { + inInfo = *inQueue.begin(); + inHeader = inInfo->mHeader; + } else { + break; + } + } + + outInfo = *outQueue.begin(); + outHeader = outInfo->mHeader; + outHeader->nFlags = 0; + outHeader->nTimeStamp = 0; + outHeader->nOffset = 0; + + if (inHeader != NULL && (inHeader->nFlags & OMX_BUFFERFLAG_EOS)) { + mReceivedEOS = true; + if (inHeader->nFilledLen == 0) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + setFlushMode(); + } + } + + if (mInitNeeded && !mIsInFlush) { + bool portWillReset = false; + handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight); + + CHECK_EQ(reInitDecoder(), (status_t)OK); + return; + } + + /* Get a free slot in timestamp array to hold input timestamp */ + { + size_t i; + timeStampIx = 0; + for (i = 0; i < MAX_TIME_STAMPS; i++) { + if (!mTimeStampsValid[i]) { + timeStampIx = i; + break; + } + } + if (inHeader != NULL) { + mTimeStampsValid[timeStampIx] = true; + mTimeStamps[timeStampIx] = inHeader->nTimeStamp; + } + } + + { + ivd_video_decode_ip_t s_dec_ip; + ivd_video_decode_op_t s_dec_op; + + WORD32 timeDelay, timeTaken; + size_t sizeY, sizeUV; + + setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); + DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes); + + if (s_dec_ip.u4_num_Bytes > 0) { + char *ptr = (char *)s_dec_ip.pv_stream_buffer; + } + + GETTIME(&mTimeStart, NULL); + /* Compute time elapsed between end of previous decode() + * to start of current decode() */ + TIME_DIFF(mTimeEnd, mTimeStart, timeDelay); + + IV_API_CALL_STATUS_T status; + status = ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); + + bool unsupportedDimensions = (IMPEG2D_UNSUPPORTED_DIMENSIONS == s_dec_op.u4_error_code); + bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF)); + + GETTIME(&mTimeEnd, NULL); + /* Compute time taken for decode() */ + TIME_DIFF(mTimeStart, mTimeEnd, timeTaken); + + ALOGV(""timeTaken=%6d delay=%6d numBytes=%6d"", timeTaken, timeDelay, + s_dec_op.u4_num_bytes_consumed); + if (s_dec_op.u4_frame_decoded_flag && !mFlushNeeded) { + mFlushNeeded = true; + } + + if ((inHeader != NULL) && (1 != s_dec_op.u4_frame_decoded_flag)) { + /* If the input did not contain picture data, then ignore + * the associated timestamp */ + mTimeStampsValid[timeStampIx] = false; + } + + if (unsupportedDimensions && !mFlushNeeded) { + bool portWillReset = false; + handlePortSettingsChange(&portWillReset, s_dec_op.u4_pic_wd, s_dec_op.u4_pic_ht); + + + CHECK_EQ(reInitDecoder(), (status_t)OK); + + setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); + ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); + return; + } + + if (mChangingResolution && !s_dec_op.u4_output_present) { + mChangingResolution = false; + resetDecoder(); + resetPlugin(); + continue; + } + + if (unsupportedDimensions || resChanged) { + mChangingResolution = true; + if (mFlushNeeded) { + setFlushMode(); + } + + if (unsupportedDimensions) { + mNewWidth = s_dec_op.u4_pic_wd; + mNewHeight = s_dec_op.u4_pic_ht; + mInitNeeded = true; + } + continue; + } + + if ((0 < s_dec_op.u4_pic_wd) && (0 < s_dec_op.u4_pic_ht)) { + uint32_t width = s_dec_op.u4_pic_wd; + uint32_t height = s_dec_op.u4_pic_ht; + bool portWillReset = false; + handlePortSettingsChange(&portWillReset, width, height); + + if (portWillReset) { + resetDecoder(); + return; + } + } + + if (s_dec_op.u4_output_present) { + size_t timeStampIdx; + outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; + + timeStampIdx = getMinTimestampIdx(mTimeStamps, mTimeStampsValid); + outHeader->nTimeStamp = mTimeStamps[timeStampIdx]; + mTimeStampsValid[timeStampIdx] = false; + + /* mWaitForI waits for the first I picture. Once made FALSE, it + has to remain false till explicitly set to TRUE. */ + mWaitForI = mWaitForI && !(IV_I_FRAME == s_dec_op.e_pic_type); + + if (mWaitForI) { + s_dec_op.u4_output_present = false; + } else { + ALOGV(""Output timestamp: %lld, res: %ux%u"", + (long long)outHeader->nTimeStamp, mWidth, mHeight); + DUMP_TO_FILE(mOutFile, outHeader->pBuffer, outHeader->nFilledLen); + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + } + } else { + /* If in flush mode and no output is returned by the codec, + * then come out of flush mode */ + mIsInFlush = false; + + /* If EOS was recieved on input port and there is no output + * from the codec, then signal EOS on output port */ + if (mReceivedEOS) { + outHeader->nFilledLen = 0; + outHeader->nFlags |= OMX_BUFFERFLAG_EOS; + + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + resetPlugin(); + } + } + } + + if (inHeader != NULL) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + } +} +",1,"void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) { + UNUSED(portIndex); + + if (mOutputPortSettingsChange != NONE) { + return; + } + + List &inQueue = getPortQueue(kInputPortIndex); + List &outQueue = getPortQueue(kOutputPortIndex); + + /* If input EOS is seen and decoder is not in flush mode, + * set the decoder in flush mode. + * There can be a case where EOS is sent along with last picture data + * In that case, only after decoding that input data, decoder has to be + * put in flush. This case is handled here */ + + if (mReceivedEOS && !mIsInFlush) { + setFlushMode(); + } + + while (!outQueue.empty()) { + BufferInfo *inInfo; + OMX_BUFFERHEADERTYPE *inHeader; + + BufferInfo *outInfo; + OMX_BUFFERHEADERTYPE *outHeader; + size_t timeStampIx; + + inInfo = NULL; + inHeader = NULL; + + if (!mIsInFlush) { + if (!inQueue.empty()) { + inInfo = *inQueue.begin(); + inHeader = inInfo->mHeader; + } else { + break; + } + } + + outInfo = *outQueue.begin(); + outHeader = outInfo->mHeader; + outHeader->nFlags = 0; + outHeader->nTimeStamp = 0; + outHeader->nOffset = 0; + + if (inHeader != NULL && (inHeader->nFlags & OMX_BUFFERFLAG_EOS)) { + mReceivedEOS = true; + if (inHeader->nFilledLen == 0) { + inQueue.erase(inQueue.begin()); + inInfo->mOwnedByUs = false; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + setFlushMode(); + } + } + + if (mInitNeeded && !mIsInFlush) { + bool portWillReset = false; + handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight); + + CHECK_EQ(reInitDecoder(), (status_t)OK); + return; + } + + /* Get a free slot in timestamp array to hold input timestamp */ + { + size_t i; + timeStampIx = 0; + for (i = 0; i < MAX_TIME_STAMPS; i++) { + if (!mTimeStampsValid[i]) { + timeStampIx = i; + break; + } + } + if (inHeader != NULL) { + mTimeStampsValid[timeStampIx] = true; + mTimeStamps[timeStampIx] = inHeader->nTimeStamp; + } + } + + { + ivd_video_decode_ip_t s_dec_ip; + ivd_video_decode_op_t s_dec_op; + + WORD32 timeDelay, timeTaken; + size_t sizeY, sizeUV; + + if (!setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx)) { + ALOGE(""Decoder arg setup failed""); + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + return; + } + DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes); + + if (s_dec_ip.u4_num_Bytes > 0) { + char *ptr = (char *)s_dec_ip.pv_stream_buffer; + } + + GETTIME(&mTimeStart, NULL); + /* Compute time elapsed between end of previous decode() + * to start of current decode() */ + TIME_DIFF(mTimeEnd, mTimeStart, timeDelay); + + IV_API_CALL_STATUS_T status; + status = ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); + + bool unsupportedDimensions = (IMPEG2D_UNSUPPORTED_DIMENSIONS == s_dec_op.u4_error_code); + bool resChanged = (IVD_RES_CHANGED == (s_dec_op.u4_error_code & 0xFF)); + + GETTIME(&mTimeEnd, NULL); + /* Compute time taken for decode() */ + TIME_DIFF(mTimeStart, mTimeEnd, timeTaken); + + ALOGV(""timeTaken=%6d delay=%6d numBytes=%6d"", timeTaken, timeDelay, + s_dec_op.u4_num_bytes_consumed); + if (s_dec_op.u4_frame_decoded_flag && !mFlushNeeded) { + mFlushNeeded = true; + } + + if ((inHeader != NULL) && (1 != s_dec_op.u4_frame_decoded_flag)) { + /* If the input did not contain picture data, then ignore + * the associated timestamp */ + mTimeStampsValid[timeStampIx] = false; + } + + if (unsupportedDimensions && !mFlushNeeded) { + bool portWillReset = false; + handlePortSettingsChange(&portWillReset, s_dec_op.u4_pic_wd, s_dec_op.u4_pic_ht); + + + CHECK_EQ(reInitDecoder(), (status_t)OK); + + if (setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx)) { + ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); + } + return; + } + + if (mChangingResolution && !s_dec_op.u4_output_present) { + mChangingResolution = false; + resetDecoder(); + resetPlugin(); + continue; + } + + if (unsupportedDimensions || resChanged) { + mChangingResolution = true; + if (mFlushNeeded) { + setFlushMode(); + } + + if (unsupportedDimensions) { + mNewWidth = s_dec_op.u4_pic_wd; + mNewHeight = s_dec_op.u4_pic_ht; + mInitNeeded = true; + } + continue; + } + + if ((0 < s_dec_op.u4_pic_wd) && (0 < s_dec_op.u4_pic_ht)) { + uint32_t width = s_dec_op.u4_pic_wd; + uint32_t height = s_dec_op.u4_pic_ht; + bool portWillReset = false; + handlePortSettingsChange(&portWillReset, width, height); + + if (portWillReset) { + resetDecoder(); + return; + } + } + + if (s_dec_op.u4_output_present) { + size_t timeStampIdx; + outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; + + timeStampIdx = getMinTimestampIdx(mTimeStamps, mTimeStampsValid); + outHeader->nTimeStamp = mTimeStamps[timeStampIdx]; + mTimeStampsValid[timeStampIdx] = false; + + /* mWaitForI waits for the first I picture. Once made FALSE, it + has to remain false till explicitly set to TRUE. */ + mWaitForI = mWaitForI && !(IV_I_FRAME == s_dec_op.e_pic_type); + + if (mWaitForI) { + s_dec_op.u4_output_present = false; + } else { + ALOGV(""Output timestamp: %lld, res: %ux%u"", + (long long)outHeader->nTimeStamp, mWidth, mHeight); + DUMP_TO_FILE(mOutFile, outHeader->pBuffer, outHeader->nFilledLen); + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + } + } else { + /* If in flush mode and no output is returned by the codec, + * then come out of flush mode */ + mIsInFlush = false; + + /* If EOS was recieved on input port and there is no output + * from the codec, then signal EOS on output port */ + if (mReceivedEOS) { + outHeader->nFilledLen = 0; + outHeader->nFlags |= OMX_BUFFERFLAG_EOS; + + outInfo->mOwnedByUs = false; + outQueue.erase(outQueue.begin()); + outInfo = NULL; + notifyFillBufferDone(outHeader); + outHeader = NULL; + resetPlugin(); + } + } + } + + if (inHeader != NULL) { + inInfo->mOwnedByUs = false; + inQueue.erase(inQueue.begin()); + inInfo = NULL; + notifyEmptyBufferDone(inHeader); + inHeader = NULL; + } + } +} +","@@ -466,7 +466,7 @@ + + return ret; + } + +-void SoftMPEG2::setDecodeArgs( ++bool SoftMPEG2::setDecodeArgs( + ivd_video_decode_ip_t *ps_dec_ip, + ivd_video_decode_op_t *ps_dec_op, + OMX_BUFFERHEADERTYPE *inHeader, +@@ -474,7 +474,6 @@ + + size_t timeStampIx) { + size_t sizeY = outputBufferWidth() * outputBufferHeight(); + size_t sizeUV; +- uint8_t *pBuf; + + ps_dec_ip->u4_size = sizeof(ivd_video_decode_ip_t); + ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); +@@ -494,22 +493,28 @@ + + ps_dec_ip->u4_num_Bytes = 0; + } + +- if (outHeader) { +- pBuf = outHeader->pBuffer; +- } else { +- pBuf = mFlushOutBuffer; +- } +- + sizeUV = sizeY / 4; + ps_dec_ip->s_out_buffer.u4_min_out_buf_size[0] = sizeY; + ps_dec_ip->s_out_buffer.u4_min_out_buf_size[1] = sizeUV; + ps_dec_ip->s_out_buffer.u4_min_out_buf_size[2] = sizeUV; + ++ uint8_t *pBuf; ++ if (outHeader) { ++ if (outHeader->nAllocLen < sizeY + (sizeUV * 2)) { ++ android_errorWriteLog(0x534e4554, ""27569635""); ++ return false; ++ } ++ pBuf = outHeader->pBuffer; ++ } else { ++ // mFlushOutBuffer always has the right size. ++ pBuf = mFlushOutBuffer; ++ } ++ + ps_dec_ip->s_out_buffer.pu1_bufs[0] = pBuf; + ps_dec_ip->s_out_buffer.pu1_bufs[1] = pBuf + sizeY; + ps_dec_ip->s_out_buffer.pu1_bufs[2] = pBuf + sizeY + sizeUV; + ps_dec_ip->s_out_buffer.u4_num_bufs = 3; +- return; ++ return true; + } + void SoftMPEG2::onPortFlushCompleted(OMX_U32 portIndex) { + /* Once the output buffers are flushed, ignore any buffers that are held in decoder */ +@@ -622,7 +627,11 @@ + + WORD32 timeDelay, timeTaken; + size_t sizeY, sizeUV; + +- setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); ++ if (!setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx)) { ++ ALOGE(""Decoder arg setup failed""); ++ notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); ++ return; ++ } + // If input dump is enabled, then write to file + DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes); + +@@ -665,9 +674,9 @@ + + + CHECK_EQ(reInitDecoder(), (status_t)OK); + +- setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx); +- +- ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); ++ if (setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx)) { ++ ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op); ++ } + return; + } + +",1694,1930,2048 +17006,"xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, + xsltStylesheetPtr style) +{ + xsltStylesheetPtr curstyle; + xsltTemplatePtr ret = NULL; + const xmlChar *name = NULL; + xsltCompMatchPtr list = NULL; + float priority; + int keyed = 0; + + if ((ctxt == NULL) || (node == NULL)) + return(NULL); + + if (style == NULL) { + curstyle = ctxt->style; + } else { + curstyle = xsltNextImport(style); + } + + while ((curstyle != NULL) && (curstyle != style)) { + priority = XSLT_PAT_NO_PRIORITY; + /* TODO : handle IDs/keys here ! */ + if (curstyle->templatesHash != NULL) { + /* + * Use the top name as selector + */ + switch (node->type) { + case XML_ELEMENT_NODE: + if (node->name[0] == ' ') + break; + case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: + name = node->name; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + default: + return(NULL); + + } + } + if (name != NULL) { + /* + * find the list of applicable expressions based on the name + */ + list = (xsltCompMatchPtr) xmlHashLookup3(curstyle->templatesHash, + name, ctxt->mode, ctxt->modeURI); + } else + list = NULL; + while (list != NULL) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + list = NULL; + + /* + * find alternate generic matches + */ + switch (node->type) { + case XML_ELEMENT_NODE: + if (node->name[0] == ' ') + list = curstyle->rootMatch; + else + list = curstyle->elemMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_ATTRIBUTE_NODE: { + xmlAttrPtr attr; + + list = curstyle->attrMatch; + attr = (xmlAttrPtr) node; + if (attr->psvi != NULL) keyed = 1; + break; + } + case XML_PI_NODE: + list = curstyle->piMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: { + xmlDocPtr doc; + + list = curstyle->rootMatch; + doc = (xmlDocPtr) node; + if (doc->psvi != NULL) keyed = 1; + break; + } + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + list = curstyle->textMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_COMMENT_NODE: + list = curstyle->commentMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + default: + break; + } + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + /* + * Some of the tests for elements can also apply to documents + */ + if ((node->type == XML_DOCUMENT_NODE) || + (node->type == XML_HTML_DOCUMENT_NODE) || + (node->type == XML_TEXT_NODE)) { + list = curstyle->elemMatch; + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + } else if ((node->type == XML_PI_NODE) || + (node->type == XML_COMMENT_NODE)) { + list = curstyle->elemMatch; + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + } + +keyed_match: + if (keyed) { + list = curstyle->keyMatch; + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + } + else if (ctxt->hasTemplKeyPatterns && + ((ctxt->document == NULL) || + (ctxt->document->nbKeysComputed < ctxt->nbKeys))) + { + /* + * Compute all remaining keys for this document. + * + * REVISIT TODO: I think this could be further optimized. + */ + if (xsltComputeAllKeys(ctxt, node) == -1) + goto error; + + switch (node->type) { + case XML_ELEMENT_NODE: + if (node->psvi != NULL) keyed = 1; + break; + case XML_ATTRIBUTE_NODE: + if (((xmlAttrPtr) node)->psvi != NULL) keyed = 1; + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_PI_NODE: + if (node->psvi != NULL) keyed = 1; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: + if (((xmlDocPtr) node)->psvi != NULL) keyed = 1; + break; + default: + break; + } + if (keyed) + goto keyed_match; + } + if (ret != NULL) + return(ret); + + /* + * Cycle on next curstylesheet import. + */ + curstyle = xsltNextImport(curstyle); + } + +error: + return(NULL); +} +",0,"xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, + xsltStylesheetPtr style) +{ + xsltStylesheetPtr curstyle; + xsltTemplatePtr ret = NULL; + const xmlChar *name = NULL; + xsltCompMatchPtr list = NULL; + float priority; + int keyed = 0; + + if ((ctxt == NULL) || (node == NULL)) + return(NULL); + + if (style == NULL) { + curstyle = ctxt->style; + } else { + curstyle = xsltNextImport(style); + } + + while ((curstyle != NULL) && (curstyle != style)) { + priority = XSLT_PAT_NO_PRIORITY; + /* TODO : handle IDs/keys here ! */ + if (curstyle->templatesHash != NULL) { + /* + * Use the top name as selector + */ + switch (node->type) { + case XML_ELEMENT_NODE: + if (node->name[0] == ' ') + break; + case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: + name = node->name; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + default: + return(NULL); + + } + } + if (name != NULL) { + /* + * find the list of applicable expressions based on the name + */ + list = (xsltCompMatchPtr) xmlHashLookup3(curstyle->templatesHash, + name, ctxt->mode, ctxt->modeURI); + } else + list = NULL; + while (list != NULL) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + list = NULL; + + /* + * find alternate generic matches + */ + switch (node->type) { + case XML_ELEMENT_NODE: + if (node->name[0] == ' ') + list = curstyle->rootMatch; + else + list = curstyle->elemMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_ATTRIBUTE_NODE: { + xmlAttrPtr attr; + + list = curstyle->attrMatch; + attr = (xmlAttrPtr) node; + if (attr->psvi != NULL) keyed = 1; + break; + } + case XML_PI_NODE: + list = curstyle->piMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: { + xmlDocPtr doc; + + list = curstyle->rootMatch; + doc = (xmlDocPtr) node; + if (doc->psvi != NULL) keyed = 1; + break; + } + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + list = curstyle->textMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_COMMENT_NODE: + list = curstyle->commentMatch; + if (node->psvi != NULL) keyed = 1; + break; + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_DTD_NODE: + case XML_ELEMENT_DECL: + case XML_ATTRIBUTE_DECL: + case XML_ENTITY_DECL: + case XML_NAMESPACE_DECL: + case XML_XINCLUDE_START: + case XML_XINCLUDE_END: + break; + default: + break; + } + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + /* + * Some of the tests for elements can also apply to documents + */ + if ((node->type == XML_DOCUMENT_NODE) || + (node->type == XML_HTML_DOCUMENT_NODE) || + (node->type == XML_TEXT_NODE)) { + list = curstyle->elemMatch; + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + } else if ((node->type == XML_PI_NODE) || + (node->type == XML_COMMENT_NODE)) { + list = curstyle->elemMatch; + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + } + +keyed_match: + if (keyed) { + list = curstyle->keyMatch; + while ((list != NULL) && + ((ret == NULL) || (list->priority > priority))) { + if (xsltTestCompMatch(ctxt, list, node, + ctxt->mode, ctxt->modeURI)) { + ret = list->template; + priority = list->priority; + break; + } + list = list->next; + } + } + else if (ctxt->hasTemplKeyPatterns && + ((ctxt->document == NULL) || + (ctxt->document->nbKeysComputed < ctxt->nbKeys))) + { + /* + * Compute all remaining keys for this document. + * + * REVISIT TODO: I think this could be further optimized. + */ + if (xsltComputeAllKeys(ctxt, node) == -1) + goto error; + + switch (node->type) { + case XML_ELEMENT_NODE: + if (node->psvi != NULL) keyed = 1; + break; + case XML_ATTRIBUTE_NODE: + if (((xmlAttrPtr) node)->psvi != NULL) keyed = 1; + break; + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_PI_NODE: + if (node->psvi != NULL) keyed = 1; + break; + case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: + if (((xmlDocPtr) node)->psvi != NULL) keyed = 1; + break; + default: + break; + } + if (keyed) + goto keyed_match; + } + if (ret != NULL) + return(ret); + + /* + * Cycle on next curstylesheet import. + */ + curstyle = xsltNextImport(curstyle); + } + +error: + return(NULL); +} +","@@ -451,11 +451,14 @@ xsltReverseCompMatch(xsltParserContextPtr ctxt, xsltCompMatchPtr comp) { + xsltCompMatchAdd(ctxt, comp, XSLT_OP_END, NULL, NULL, 0); + + /* +- * detect consecutive XSLT_OP_PREDICATE indicating a direct +- * matching should be done. ++ * Detect consecutive XSLT_OP_PREDICATE and predicates on ops which ++ * haven't been optimized yet indicating a direct matching should be done. + */ + for (i = 0;i < comp->nbStep - 1;i++) { +- if ((comp->steps[i].op == XSLT_OP_PREDICATE) && ++ xsltOp op = comp->steps[i].op; ++ ++ if ((op != XSLT_OP_ELEM) && ++ (op != XSLT_OP_ALL) && + (comp->steps[i + 1].op == XSLT_OP_PREDICATE)) { + + comp->direct = 1; +@@ -620,6 +623,280 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + return(0); + } + ++/** ++ * xsltTestPredicateMatch: ++ * @ctxt: a XSLT process context ++ * @comp: the precompiled pattern ++ * @node: a node ++ * @step: the predicate step ++ * @sel: the previous step ++ * ++ * Test whether the node matches the predicate ++ * ++ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure ++ */ ++static int ++xsltTestPredicateMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, ++ xmlNodePtr node, xsltStepOpPtr step, ++ xsltStepOpPtr sel) { ++ xmlNodePtr oldNode; ++ xmlDocPtr doc; ++ int oldCS, oldCP; ++ int pos = 0, len = 0; ++ int isRVT; ++ int match; ++ ++ if (step->value == NULL) ++ return(0); ++ if (step->comp == NULL) ++ return(0); ++ ++ doc = node->doc; ++ if (XSLT_IS_RES_TREE_FRAG(doc)) ++ isRVT = 1; ++ else ++ isRVT = 0; ++ ++ /* ++ * Recompute contextSize and proximityPosition. ++ * ++ * TODO: Make this work for additional ops. Currently, only XSLT_OP_ELEM ++ * and XSLT_OP_ALL are supported. ++ */ ++ oldCS = ctxt->xpathCtxt->contextSize; ++ oldCP = ctxt->xpathCtxt->proximityPosition; ++ if ((sel != NULL) && ++ (sel->op == XSLT_OP_ELEM) && ++ (sel->value != NULL) && ++ (node->type == XML_ELEMENT_NODE) && ++ (node->parent != NULL)) { ++ xmlNodePtr previous; ++ int nocache = 0; ++ ++ previous = (xmlNodePtr) ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); ++ if ((previous != NULL) && ++ (previous->parent == node->parent)) { ++ /* ++ * just walk back to adjust the index ++ */ ++ int indx = 0; ++ xmlNodePtr sibling = node; ++ ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if ((sibling->type == XML_ELEMENT_NODE) && ++ (previous->name != NULL) && ++ (sibling->name != NULL) && ++ (previous->name[0] == sibling->name[0]) && ++ (xmlStrEqual(previous->name, sibling->name))) ++ { ++ if ((sel->value2 == NULL) || ++ ((sibling->ns != NULL) && ++ (xmlStrEqual(sel->value2, sibling->ns->href)))) ++ indx++; ++ } ++ sibling = sibling->prev; ++ } ++ if (sibling == NULL) { ++ /* hum going backward in document order ... */ ++ indx = 0; ++ sibling = node; ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if ((sibling->type == XML_ELEMENT_NODE) && ++ (previous->name != NULL) && ++ (sibling->name != NULL) && ++ (previous->name[0] == sibling->name[0]) && ++ (xmlStrEqual(previous->name, sibling->name))) ++ { ++ if ((sel->value2 == NULL) || ++ ((sibling->ns != NULL) && ++ (xmlStrEqual(sel->value2, ++ sibling->ns->href)))) ++ { ++ indx--; ++ } ++ } ++ sibling = sibling->next; ++ } ++ } ++ if (sibling != NULL) { ++ pos = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) + indx; ++ /* ++ * If the node is in a Value Tree we need to ++ * save len, but cannot cache the node! ++ * (bugs 153137 and 158840) ++ */ ++ if (node->doc != NULL) { ++ len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival); ++ if (!isRVT) { ++ XSLT_RUNTIME_EXTRA(ctxt, ++ sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ } ++ } ++ } else ++ pos = 0; ++ } else { ++ /* ++ * recompute the index ++ */ ++ xmlNodePtr parent = node->parent; ++ xmlNodePtr siblings = NULL; ++ ++ if (parent) siblings = parent->children; ++ ++ while (siblings != NULL) { ++ if (siblings->type == XML_ELEMENT_NODE) { ++ if (siblings == node) { ++ len++; ++ pos = len; ++ } else if ((node->name != NULL) && ++ (siblings->name != NULL) && ++ (node->name[0] == siblings->name[0]) && ++ (xmlStrEqual(node->name, siblings->name))) { ++ if ((sel->value2 == NULL) || ++ ((siblings->ns != NULL) && ++ (xmlStrEqual(sel->value2, siblings->ns->href)))) ++ len++; ++ } ++ } ++ siblings = siblings->next; ++ } ++ if ((parent == NULL) || (node->doc == NULL)) ++ nocache = 1; ++ else { ++ while (parent->parent != NULL) ++ parent = parent->parent; ++ if (((parent->type != XML_DOCUMENT_NODE) && ++ (parent->type != XML_HTML_DOCUMENT_NODE)) || ++ (parent != (xmlNodePtr) node->doc)) ++ nocache = 1; ++ } ++ } ++ if (pos != 0) { ++ ctxt->xpathCtxt->contextSize = len; ++ ctxt->xpathCtxt->proximityPosition = pos; ++ /* ++ * If the node is in a Value Tree we cannot ++ * cache it ! ++ */ ++ if ((!isRVT) && (node->doc != NULL) && ++ (nocache == 0)) { ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len; ++ } ++ } ++ } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) && ++ (node->type == XML_ELEMENT_NODE)) { ++ xmlNodePtr previous; ++ int nocache = 0; ++ ++ previous = (xmlNodePtr) ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); ++ if ((previous != NULL) && ++ (previous->parent == node->parent)) { ++ /* ++ * just walk back to adjust the index ++ */ ++ int indx = 0; ++ xmlNodePtr sibling = node; ++ ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if (sibling->type == XML_ELEMENT_NODE) ++ indx++; ++ sibling = sibling->prev; ++ } ++ if (sibling == NULL) { ++ /* hum going backward in document order ... */ ++ indx = 0; ++ sibling = node; ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if (sibling->type == XML_ELEMENT_NODE) ++ indx--; ++ sibling = sibling->next; ++ } ++ } ++ if (sibling != NULL) { ++ pos = XSLT_RUNTIME_EXTRA(ctxt, ++ sel->indexExtra, ival) + indx; ++ /* ++ * If the node is in a Value Tree we cannot ++ * cache it ! ++ */ ++ if ((node->doc != NULL) && !isRVT) { ++ len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival); ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ } ++ } else ++ pos = 0; ++ } else { ++ /* ++ * recompute the index ++ */ ++ xmlNodePtr parent = node->parent; ++ xmlNodePtr siblings = NULL; ++ ++ if (parent) siblings = parent->children; ++ ++ while (siblings != NULL) { ++ if (siblings->type == XML_ELEMENT_NODE) { ++ len++; ++ if (siblings == node) { ++ pos = len; ++ } ++ } ++ siblings = siblings->next; ++ } ++ if ((parent == NULL) || (node->doc == NULL)) ++ nocache = 1; ++ else { ++ while (parent->parent != NULL) ++ parent = parent->parent; ++ if (((parent->type != XML_DOCUMENT_NODE) && ++ (parent->type != XML_HTML_DOCUMENT_NODE)) || ++ (parent != (xmlNodePtr) node->doc)) ++ nocache = 1; ++ } ++ } ++ if (pos != 0) { ++ ctxt->xpathCtxt->contextSize = len; ++ ctxt->xpathCtxt->proximityPosition = pos; ++ /* ++ * If the node is in a Value Tree we cannot ++ * cache it ! ++ */ ++ if ((node->doc != NULL) && (nocache == 0) && !isRVT) { ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len; ++ } ++ } ++ } ++ ++ oldNode = ctxt->node; ++ ctxt->node = node; ++ ++ match = xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList, comp->nsNr); ++ ++ if (pos != 0) { ++ ctxt->xpathCtxt->contextSize = oldCS; ++ ctxt->xpathCtxt->proximityPosition = oldCP; ++ } ++ ctxt->node = oldNode; ++ ++ return match; ++} ++ + /** + * xsltTestCompMatch: + * @ctxt: a XSLT process context +@@ -634,9 +911,10 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + */ + static int + xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, +- xmlNodePtr node, const xmlChar *mode, ++ xmlNodePtr matchNode, const xmlChar *mode, + const xmlChar *modeURI) { + int i; ++ xmlNodePtr node = matchNode; + xsltStepOpPtr step, sel = NULL; + xsltStepStates states = {0, 0, NULL}; /* // may require backtrack */ + +@@ -854,14 +1132,9 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + goto rollback; + break; + case XSLT_OP_PREDICATE: { +- xmlNodePtr oldNode; +- xmlDocPtr doc; +- int oldCS, oldCP; +- int pos = 0, len = 0; +- int isRVT; +- + /* +- * when there is cascading XSLT_OP_PREDICATE, then use a ++ * When there is cascading XSLT_OP_PREDICATE or a predicate ++ * after an op which hasn't been optimized yet, then use a + * direct computation approach. It's not done directly + * at the beginning of the routine to filter out as much + * as possible this costly computation. +@@ -871,278 +1144,14 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + /* Free the rollback states */ + xmlFree(states.states); + } +- return(xsltTestCompMatchDirect(ctxt, comp, node, ++ return(xsltTestCompMatchDirect(ctxt, comp, matchNode, + comp->nsList, comp->nsNr)); + } + +- doc = node->doc; +- if (XSLT_IS_RES_TREE_FRAG(doc)) +- isRVT = 1; +- else +- isRVT = 0; +- +- /* +- * Depending on the last selection, one may need to +- * recompute contextSize and proximityPosition. +- */ +- oldCS = ctxt->xpathCtxt->contextSize; +- oldCP = ctxt->xpathCtxt->proximityPosition; +- if ((sel != NULL) && +- (sel->op == XSLT_OP_ELEM) && +- (sel->value != NULL) && +- (node->type == XML_ELEMENT_NODE) && +- (node->parent != NULL)) { +- xmlNodePtr previous; +- int nocache = 0; +- +- previous = (xmlNodePtr) +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); +- if ((previous != NULL) && +- (previous->parent == node->parent)) { +- /* +- * just walk back to adjust the index +- */ +- int indx = 0; +- xmlNodePtr sibling = node; +- +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if ((sibling->type == XML_ELEMENT_NODE) && +- (previous->name != NULL) && +- (sibling->name != NULL) && +- (previous->name[0] == sibling->name[0]) && +- (xmlStrEqual(previous->name, sibling->name))) +- { +- if ((sel->value2 == NULL) || +- ((sibling->ns != NULL) && +- (xmlStrEqual(sel->value2, +- sibling->ns->href)))) +- indx++; +- } +- sibling = sibling->prev; +- } +- if (sibling == NULL) { +- /* hum going backward in document order ... */ +- indx = 0; +- sibling = node; +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if ((sibling->type == XML_ELEMENT_NODE) && +- (previous->name != NULL) && +- (sibling->name != NULL) && +- (previous->name[0] == sibling->name[0]) && +- (xmlStrEqual(previous->name, sibling->name))) +- { +- if ((sel->value2 == NULL) || +- ((sibling->ns != NULL) && +- (xmlStrEqual(sel->value2, +- sibling->ns->href)))) +- { +- indx--; +- } +- } +- sibling = sibling->next; +- } +- } +- if (sibling != NULL) { +- pos = XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) + indx; +- /* +- * If the node is in a Value Tree we need to +- * save len, but cannot cache the node! +- * (bugs 153137 and 158840) +- */ +- if (node->doc != NULL) { +- len = XSLT_RUNTIME_EXTRA(ctxt, +- sel->lenExtra, ival); +- if (!isRVT) { +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->previousExtra, ptr) = node; +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) = pos; +- } +- } +- } else +- pos = 0; +- } else { +- /* +- * recompute the index +- */ +- xmlNodePtr parent = node->parent; +- xmlNodePtr siblings = NULL; +- +- if (parent) siblings = parent->children; +- +- while (siblings != NULL) { +- if (siblings->type == XML_ELEMENT_NODE) { +- if (siblings == node) { +- len++; +- pos = len; +- } else if ((node->name != NULL) && +- (siblings->name != NULL) && +- (node->name[0] == siblings->name[0]) && +- (xmlStrEqual(node->name, siblings->name))) { +- if ((sel->value2 == NULL) || +- ((siblings->ns != NULL) && +- (xmlStrEqual(sel->value2, +- siblings->ns->href)))) +- len++; +- } +- } +- siblings = siblings->next; +- } +- if ((parent == NULL) || (node->doc == NULL)) +- nocache = 1; +- else { +- while (parent->parent != NULL) +- parent = parent->parent; +- if (((parent->type != XML_DOCUMENT_NODE) && +- (parent->type != XML_HTML_DOCUMENT_NODE)) || +- (parent != (xmlNodePtr) node->doc)) +- nocache = 1; +- } +- } +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = len; +- ctxt->xpathCtxt->proximityPosition = pos; +- /* +- * If the node is in a Value Tree we cannot +- * cache it ! +- */ +- if ((!isRVT) && (node->doc != NULL) && +- (nocache == 0)) { +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = +- node; +- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = +- pos; +- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = +- len; +- } +- } +- } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) && +- (node->type == XML_ELEMENT_NODE)) { +- xmlNodePtr previous; +- int nocache = 0; +- +- previous = (xmlNodePtr) +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); +- if ((previous != NULL) && +- (previous->parent == node->parent)) { +- /* +- * just walk back to adjust the index +- */ +- int indx = 0; +- xmlNodePtr sibling = node; +- +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if (sibling->type == XML_ELEMENT_NODE) +- indx++; +- sibling = sibling->prev; +- } +- if (sibling == NULL) { +- /* hum going backward in document order ... */ +- indx = 0; +- sibling = node; +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if (sibling->type == XML_ELEMENT_NODE) +- indx--; +- sibling = sibling->next; +- } +- } +- if (sibling != NULL) { +- pos = XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) + indx; +- /* +- * If the node is in a Value Tree we cannot +- * cache it ! +- */ +- if ((node->doc != NULL) && !isRVT) { +- len = XSLT_RUNTIME_EXTRA(ctxt, +- sel->lenExtra, ival); +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->previousExtra, ptr) = node; +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) = pos; +- } +- } else +- pos = 0; +- } else { +- /* +- * recompute the index +- */ +- xmlNodePtr parent = node->parent; +- xmlNodePtr siblings = NULL; +- +- if (parent) siblings = parent->children; +- +- while (siblings != NULL) { +- if (siblings->type == XML_ELEMENT_NODE) { +- len++; +- if (siblings == node) { +- pos = len; +- } +- } +- siblings = siblings->next; +- } +- if ((parent == NULL) || (node->doc == NULL)) +- nocache = 1; +- else { +- while (parent->parent != NULL) +- parent = parent->parent; +- if (((parent->type != XML_DOCUMENT_NODE) && +- (parent->type != XML_HTML_DOCUMENT_NODE)) || +- (parent != (xmlNodePtr) node->doc)) +- nocache = 1; +- } +- } +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = len; +- ctxt->xpathCtxt->proximityPosition = pos; +- /* +- * If the node is in a Value Tree we cannot +- * cache it ! +- */ +- if ((node->doc != NULL) && (nocache == 0) && !isRVT) { +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = +- node; +- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = +- pos; +- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = +- len; +- } +- } +- } +- oldNode = ctxt->node; +- ctxt->node = node; +- +- if (step->value == NULL) +- goto wrong_index; +- if (step->comp == NULL) +- goto wrong_index; +- +- if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList, +- comp->nsNr)) +- goto wrong_index; ++ if (!xsltTestPredicateMatch(ctxt, comp, node, step, sel)) ++ goto rollback; + +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = oldCS; +- ctxt->xpathCtxt->proximityPosition = oldCP; +- } +- ctxt->node = oldNode; + break; +-wrong_index: +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = oldCS; +- ctxt->xpathCtxt->proximityPosition = oldCP; +- } +- ctxt->node = oldNode; +- goto rollback; + } + case XSLT_OP_PI: + if (node->type != XML_PI_NODE) +@@ -1424,6 +1433,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, + if (CUR != ',') { + xsltTransformError(NULL, NULL, NULL, + ""xsltCompileIdKeyPattern : , expected\n""); ++ xmlFree(lit); + ctxt->error = 1; + return; + } +@@ -2080,9 +2090,34 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, + const xmlChar *name = NULL; + float priority; /* the priority */ + +- if ((style == NULL) || (cur == NULL) || (cur->match == NULL)) ++ if ((style == NULL) || (cur == NULL)) + return(-1); + ++ /* Register named template */ ++ if (cur->name != NULL) { ++ if (style->namedTemplates == NULL) { ++ style->namedTemplates = xmlHashCreate(10); ++ if (style->namedTemplates == NULL) ++ return(-1); ++ } ++ else { ++ void *dup = xmlHashLookup2(style->namedTemplates, cur->name, ++ cur->nameURI); ++ if (dup != NULL) { ++ xsltTransformError(NULL, style, NULL, ++ ""xsl:template: error duplicate name '%s'\n"", ++ cur->name); ++ style->errors++; ++ return(-1); ++ } ++ } ++ ++ xmlHashAddEntry2(style->namedTemplates, cur->name, cur->nameURI, cur); ++ } ++ ++ if (cur->match == NULL) ++ return(0); ++ + priority = cur->priority; + pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem, + style, NULL, 1); +@@ -2552,5 +2587,7 @@ xsltFreeTemplateHashes(xsltStylesheetPtr style) { + xsltFreeCompMatchList(style->piMatch); + if (style->commentMatch != NULL) + xsltFreeCompMatchList(style->commentMatch); ++ if (style->namedTemplates != NULL) ++ xmlHashFree(style->namedTemplates, NULL); + } + ",1599,1835,2048 +7947,"static void vc1_put_blocks_clamped(VC1Context *v, int put_signed) +{ + MpegEncContext *s = &v->s; + uint8_t *dest; + int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; + int fieldtx = 0; + int i; + + /* The put pixels loop is one MB row and one MB column behind the decoding + * loop because we can only put pixels when overlap filtering is done. For + * interlaced frame pictures, however, the put pixels loop is only one + * column behind the decoding loop as interlaced frame pictures only need + * horizontal overlap filtering. */ + if (!s->first_slice_line && v->fcm != ILACE_FRAME) { + if (s->mb_x) { + for (i = 0; i < block_count; i++) { + if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i] - 1] : + v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i] - 2]) { + dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + ((i & 1) - 2) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize); + else + s->idsp.put_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize); + } + } + } + if (s->mb_x == v->end_mb_x - 1) { + for (i = 0; i < block_count; i++) { + if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i]] : + v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i]]) { + dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + (i & 1) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, + i > 3 ? s->uvlinesize : s->linesize); + else + s->idsp.put_pixels_clamped(v->block[v->top_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, + i > 3 ? s->uvlinesize : s->linesize); + } + } + } + } + if (s->mb_y == s->end_mb_y - 1 || v->fcm == ILACE_FRAME) { + if (s->mb_x) { + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x - 1]; + for (i = 0; i < block_count; i++) { + if (i > 3 ? v->mb_type[0][s->block_index[i] - 1] : + v->mb_type[0][s->block_index[i] - 2]) { + if (fieldtx) + dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + ((i & 1) - 2) * 8; + else + dest = s->dest[0] + (i & 2) * 4 * s->linesize + ((i & 1) - 2) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->left_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + else + s->idsp.put_pixels_clamped(v->block[v->left_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + } + } + } + if (s->mb_x == v->end_mb_x - 1) { + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x]; + for (i = 0; i < block_count; i++) { + if (v->mb_type[0][s->block_index[i]]) { + if (fieldtx) + dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + (i & 1) * 8; + else + dest = s->dest[0] + (i & 2) * 4 * s->linesize + (i & 1) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + else + s->idsp.put_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + } + } + } + } +} +",0,"static void vc1_put_blocks_clamped(VC1Context *v, int put_signed) +{ + MpegEncContext *s = &v->s; + uint8_t *dest; + int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6; + int fieldtx = 0; + int i; + + /* The put pixels loop is one MB row and one MB column behind the decoding + * loop because we can only put pixels when overlap filtering is done. For + * interlaced frame pictures, however, the put pixels loop is only one + * column behind the decoding loop as interlaced frame pictures only need + * horizontal overlap filtering. */ + if (!s->first_slice_line && v->fcm != ILACE_FRAME) { + if (s->mb_x) { + for (i = 0; i < block_count; i++) { + if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i] - 1] : + v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i] - 2]) { + dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + ((i & 1) - 2) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize); + else + s->idsp.put_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize); + } + } + } + if (s->mb_x == v->end_mb_x - 1) { + for (i = 0; i < block_count; i++) { + if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i]] : + v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i]]) { + dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + (i & 1) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, + i > 3 ? s->uvlinesize : s->linesize); + else + s->idsp.put_pixels_clamped(v->block[v->top_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest, + i > 3 ? s->uvlinesize : s->linesize); + } + } + } + } + if (s->mb_y == s->end_mb_y - 1 || v->fcm == ILACE_FRAME) { + if (s->mb_x) { + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x - 1]; + for (i = 0; i < block_count; i++) { + if (i > 3 ? v->mb_type[0][s->block_index[i] - 1] : + v->mb_type[0][s->block_index[i] - 2]) { + if (fieldtx) + dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + ((i & 1) - 2) * 8; + else + dest = s->dest[0] + (i & 2) * 4 * s->linesize + ((i & 1) - 2) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->left_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + else + s->idsp.put_pixels_clamped(v->block[v->left_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] - 8 : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + } + } + } + if (s->mb_x == v->end_mb_x - 1) { + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x]; + for (i = 0; i < block_count; i++) { + if (v->mb_type[0][s->block_index[i]]) { + if (fieldtx) + dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + (i & 1) * 8; + else + dest = s->dest[0] + (i & 2) * 4 * s->linesize + (i & 1) * 8; + if (put_signed) + s->idsp.put_signed_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + else + s->idsp.put_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]], + i > 3 ? s->dest[i - 3] : dest, + i > 3 ? s->uvlinesize : s->linesize << fieldtx); + } + } + } + } +} +","@@ -207,7 +207,7 @@ static void vc1_put_blocks_clamped(VC1Context *v, int put_signed) + if ((edges&8) && \ + s->mb_y == ((s->mb_height >> v->field_mode) - 1)) \ + mquant = -v->altpq; \ +- if (!mquant || mquant > 31) { \ ++ if (!mquant || mquant > 31 || mquant < -31) { \ + av_log(v->s.avctx, AV_LOG_ERROR, \ + ""Overriding invalid mquant %d\n"", mquant); \ + mquant = 1; \",1402,1638,2048 +16361,"void RenderThreadImpl::InitializeWebKit( + const scoped_refptr& resource_task_queue, + blink::InterfaceRegistry* interface_registry) { + DCHECK(!blink_platform_impl_); + + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + +#ifdef ENABLE_VTUNE_JIT_INTERFACE + if (command_line.HasSwitch(switches::kEnableVtune)) + gin::Debug::SetJitCodeEventHandler(vTune::GetVtuneCodeEventHandler()); +#endif + + blink_platform_impl_.reset( + new RendererBlinkPlatformImpl(renderer_scheduler_.get())); + SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); + GetContentClient() + ->renderer() + ->SetRuntimeFeaturesDefaultsBeforeBlinkInitialization(); + blink::Initialize(blink_platform_impl_.get(), interface_registry); + + v8::Isolate* isolate = blink::MainThreadIsolate(); + isolate->SetCreateHistogramFunction(CreateHistogram); + isolate->SetAddHistogramSampleFunction(AddHistogramSample); + renderer_scheduler_->SetRAILModeObserver(this); + + main_thread_compositor_task_runner_ = + renderer_scheduler_->CompositorTaskRunner(); + + main_input_callback_.Reset( + base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), + base::Unretained(this))); + + scoped_refptr resource_task_queue2; + if (resource_task_queue) { + resource_task_queue2 = resource_task_queue; + } else { + resource_task_queue2 = renderer_scheduler_->LoadingTaskRunner(); + } + scoped_refptr filter( + new ResourceSchedulingFilter( + resource_task_queue2, resource_dispatcher_.get())); + channel()->AddFilter(filter.get()); + resource_dispatcher_->SetResourceSchedulingFilter(filter); + + resource_message_filter_->SetMainThreadTaskRunner( + resource_task_queue2); + resource_dispatcher_->SetThreadTaskRunner(resource_task_queue2); + + if (!command_line.HasSwitch(switches::kDisableThreadedCompositing)) + InitializeCompositorThread(); + + if (!input_event_filter_.get()) { + input_event_filter_ = new MainThreadInputEventFilter( + main_input_callback_.callback(), main_thread_compositor_task_runner_); + } + AddFilter(input_event_filter_.get()); + + scoped_refptr compositor_impl_side_task_runner; + if (compositor_task_runner_) + compositor_impl_side_task_runner = compositor_task_runner_; + else + compositor_impl_side_task_runner = base::ThreadTaskRunnerHandle::Get(); + + compositor_message_filter_ = new CompositorForwardingMessageFilter( + compositor_impl_side_task_runner.get()); + AddFilter(compositor_message_filter_.get()); + + RenderThreadImpl::RegisterSchemes(); + + RenderMediaClient::Initialize(); + + devtools_agent_message_filter_ = new DevToolsAgentFilter(); + AddFilter(devtools_agent_message_filter_.get()); + + if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { + ScheduleIdleHandler(kLongIdleHandlerDelayMs); + } else { + isolate->IsolateInBackgroundNotification(); + } + + service_worker_message_filter_ = + new ServiceWorkerMessageFilter(thread_safe_sender()); + AddFilter(service_worker_message_filter_->GetFilter()); + + renderer_scheduler_->SetStoppingWhenBackgroundedEnabled( + GetContentClient()->renderer()->AllowStoppingWhenProcessBackgrounded()); + + SkGraphics::SetResourceCacheSingleAllocationByteLimit( + kImageCacheSingleAllocationByteLimit); + + SkGraphics::SetImageGeneratorFromEncodedDataFactory( + blink::WebImageGenerator::CreateAsSkImageGenerator); + + if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) { + std::string allowed_ports = + command_line.GetSwitchValueASCII(switches::kExplicitlyAllowedPorts); + net::SetExplicitlyAllowedPorts(allowed_ports); + } +} +",0,"void RenderThreadImpl::InitializeWebKit( + const scoped_refptr& resource_task_queue, + blink::InterfaceRegistry* interface_registry) { + DCHECK(!blink_platform_impl_); + + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + +#ifdef ENABLE_VTUNE_JIT_INTERFACE + if (command_line.HasSwitch(switches::kEnableVtune)) + gin::Debug::SetJitCodeEventHandler(vTune::GetVtuneCodeEventHandler()); +#endif + + blink_platform_impl_.reset( + new RendererBlinkPlatformImpl(renderer_scheduler_.get())); + SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); + GetContentClient() + ->renderer() + ->SetRuntimeFeaturesDefaultsBeforeBlinkInitialization(); + blink::Initialize(blink_platform_impl_.get(), interface_registry); + + v8::Isolate* isolate = blink::MainThreadIsolate(); + isolate->SetCreateHistogramFunction(CreateHistogram); + isolate->SetAddHistogramSampleFunction(AddHistogramSample); + renderer_scheduler_->SetRAILModeObserver(this); + + main_thread_compositor_task_runner_ = + renderer_scheduler_->CompositorTaskRunner(); + + main_input_callback_.Reset( + base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), + base::Unretained(this))); + + scoped_refptr resource_task_queue2; + if (resource_task_queue) { + resource_task_queue2 = resource_task_queue; + } else { + resource_task_queue2 = renderer_scheduler_->LoadingTaskRunner(); + } + scoped_refptr filter( + new ResourceSchedulingFilter( + resource_task_queue2, resource_dispatcher_.get())); + channel()->AddFilter(filter.get()); + resource_dispatcher_->SetResourceSchedulingFilter(filter); + + resource_message_filter_->SetMainThreadTaskRunner( + resource_task_queue2); + resource_dispatcher_->SetThreadTaskRunner(resource_task_queue2); + + if (!command_line.HasSwitch(switches::kDisableThreadedCompositing)) + InitializeCompositorThread(); + + if (!input_event_filter_.get()) { + input_event_filter_ = new MainThreadInputEventFilter( + main_input_callback_.callback(), main_thread_compositor_task_runner_); + } + AddFilter(input_event_filter_.get()); + + scoped_refptr compositor_impl_side_task_runner; + if (compositor_task_runner_) + compositor_impl_side_task_runner = compositor_task_runner_; + else + compositor_impl_side_task_runner = base::ThreadTaskRunnerHandle::Get(); + + compositor_message_filter_ = new CompositorForwardingMessageFilter( + compositor_impl_side_task_runner.get()); + AddFilter(compositor_message_filter_.get()); + + RenderThreadImpl::RegisterSchemes(); + + RenderMediaClient::Initialize(); + + devtools_agent_message_filter_ = new DevToolsAgentFilter(); + AddFilter(devtools_agent_message_filter_.get()); + + if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { + ScheduleIdleHandler(kLongIdleHandlerDelayMs); + } else { + isolate->IsolateInBackgroundNotification(); + } + + service_worker_message_filter_ = + new ServiceWorkerMessageFilter(thread_safe_sender()); + AddFilter(service_worker_message_filter_->GetFilter()); + + renderer_scheduler_->SetStoppingWhenBackgroundedEnabled( + GetContentClient()->renderer()->AllowStoppingWhenProcessBackgrounded()); + + SkGraphics::SetResourceCacheSingleAllocationByteLimit( + kImageCacheSingleAllocationByteLimit); + + SkGraphics::SetImageGeneratorFromEncodedDataFactory( + blink::WebImageGenerator::CreateAsSkImageGenerator); + + if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) { + std::string allowed_ports = + command_line.GetSwitchValueASCII(switches::kExplicitlyAllowedPorts); + net::SetExplicitlyAllowedPorts(allowed_ports); + } +} +","@@ -994,9 +994,6 @@ void RenderThreadImpl::Init( + if (!command_line.HasSwitch(switches::kSingleProcess)) + base::SequencedWorkerPool::EnableForProcess(); + +- EVP_set_buggy_rsa_parser( +- base::FeatureList::IsEnabled(features::kBuggyRSAParser)); +- + GetConnector()->BindInterface(mojom::kBrowserServiceName, + mojo::MakeRequest(&frame_sink_provider_)); + ",806,1042,2048 +5333,"static double GetFillAlpha(PolygonInfo *polygon_info,const double mid, + const MagickBooleanType fill,const FillRule fill_rule,const ssize_t x, + const ssize_t y,double *stroke_alpha) +{ + double + alpha, + beta, + distance, + subpath_alpha; + + PointInfo + delta; + + register const PointInfo + *q; + + register EdgeInfo + *p; + + register ssize_t + i; + + ssize_t + j, + winding_number; + + /* + Compute fill & stroke opacity for this (x,y) point. + */ + *stroke_alpha=0.0; + subpath_alpha=0.0; + p=polygon_info->edges; + for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++) + { + if ((double) y <= (p->bounds.y1-mid-0.5)) + break; + if ((double) y > (p->bounds.y2+mid+0.5)) + { + (void) DestroyEdge(polygon_info,(size_t) j); + continue; + } + if (((double) x <= (p->bounds.x1-mid-0.5)) || + ((double) x > (p->bounds.x2+mid+0.5))) + continue; + i=(ssize_t) MagickMax((double) p->highwater,1.0); + for ( ; i < (ssize_t) p->number_points; i++) + { + if ((double) y <= (p->points[i-1].y-mid-0.5)) + break; + if ((double) y > (p->points[i].y+mid+0.5)) + continue; + if (p->scanline != (double) y) + { + p->scanline=(double) y; + p->highwater=(size_t) i; + } + /* + Compute distance between a point and an edge. + */ + q=p->points+i-1; + delta.x=(q+1)->x-q->x; + delta.y=(q+1)->y-q->y; + beta=delta.x*(x-q->x)+delta.y*(y-q->y); + if (beta < 0.0) + { + delta.x=(double) x-q->x; + delta.y=(double) y-q->y; + distance=delta.x*delta.x+delta.y*delta.y; + } + else + { + alpha=delta.x*delta.x+delta.y*delta.y; + if (beta > alpha) + { + delta.x=(double) x-(q+1)->x; + delta.y=(double) y-(q+1)->y; + distance=delta.x*delta.x+delta.y*delta.y; + } + else + { + alpha=1.0/alpha; + beta=delta.x*(y-q->y)-delta.y*(x-q->x); + distance=alpha*beta*beta; + } + } + /* + Compute stroke & subpath opacity. + */ + beta=0.0; + if (p->ghostline == MagickFalse) + { + alpha=mid+0.5; + if ((*stroke_alpha < 1.0) && + (distance <= ((alpha+0.25)*(alpha+0.25)))) + { + alpha=mid-0.5; + if (distance <= ((alpha+0.25)*(alpha+0.25))) + *stroke_alpha=1.0; + else + { + beta=1.0; + if (distance != 1.0) + beta=sqrt((double) distance); + alpha=beta-mid-0.5; + if (*stroke_alpha < ((alpha-0.25)*(alpha-0.25))) + *stroke_alpha=(alpha-0.25)*(alpha-0.25); + } + } + } + if ((fill == MagickFalse) || (distance > 1.0) || (subpath_alpha >= 1.0)) + continue; + if (distance <= 0.0) + { + subpath_alpha=1.0; + continue; + } + if (distance > 1.0) + continue; + if (beta == 0.0) + { + beta=1.0; + if (distance != 1.0) + beta=sqrt(distance); + } + alpha=beta-1.0; + if (subpath_alpha < (alpha*alpha)) + subpath_alpha=alpha*alpha; + } + } + /* + Compute fill opacity. + */ + if (fill == MagickFalse) + return(0.0); + if (subpath_alpha >= 1.0) + return(1.0); + /* + Determine winding number. + */ + winding_number=0; + p=polygon_info->edges; + for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++) + { + if ((double) y <= p->bounds.y1) + break; + if (((double) y > p->bounds.y2) || ((double) x <= p->bounds.x1)) + continue; + if ((double) x > p->bounds.x2) + { + winding_number+=p->direction ? 1 : -1; + continue; + } + i=(ssize_t) MagickMax((double) p->highwater,1.0); + for ( ; i < (ssize_t) p->number_points; i++) + if ((double) y <= p->points[i].y) + break; + q=p->points+i-1; + if ((((q+1)->x-q->x)*(y-q->y)) <= (((q+1)->y-q->y)*(x-q->x))) + winding_number+=p->direction ? 1 : -1; + } + if (fill_rule != NonZeroRule) + { + if ((MagickAbsoluteValue(winding_number) & 0x01) != 0) + return(1.0); + } + else + if (MagickAbsoluteValue(winding_number) != 0) + return(1.0); + return(subpath_alpha); +} +",0,"static double GetFillAlpha(PolygonInfo *polygon_info,const double mid, + const MagickBooleanType fill,const FillRule fill_rule,const ssize_t x, + const ssize_t y,double *stroke_alpha) +{ + double + alpha, + beta, + distance, + subpath_alpha; + + PointInfo + delta; + + register const PointInfo + *q; + + register EdgeInfo + *p; + + register ssize_t + i; + + ssize_t + j, + winding_number; + + /* + Compute fill & stroke opacity for this (x,y) point. + */ + *stroke_alpha=0.0; + subpath_alpha=0.0; + p=polygon_info->edges; + for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++) + { + if ((double) y <= (p->bounds.y1-mid-0.5)) + break; + if ((double) y > (p->bounds.y2+mid+0.5)) + { + (void) DestroyEdge(polygon_info,(size_t) j); + continue; + } + if (((double) x <= (p->bounds.x1-mid-0.5)) || + ((double) x > (p->bounds.x2+mid+0.5))) + continue; + i=(ssize_t) MagickMax((double) p->highwater,1.0); + for ( ; i < (ssize_t) p->number_points; i++) + { + if ((double) y <= (p->points[i-1].y-mid-0.5)) + break; + if ((double) y > (p->points[i].y+mid+0.5)) + continue; + if (p->scanline != (double) y) + { + p->scanline=(double) y; + p->highwater=(size_t) i; + } + /* + Compute distance between a point and an edge. + */ + q=p->points+i-1; + delta.x=(q+1)->x-q->x; + delta.y=(q+1)->y-q->y; + beta=delta.x*(x-q->x)+delta.y*(y-q->y); + if (beta < 0.0) + { + delta.x=(double) x-q->x; + delta.y=(double) y-q->y; + distance=delta.x*delta.x+delta.y*delta.y; + } + else + { + alpha=delta.x*delta.x+delta.y*delta.y; + if (beta > alpha) + { + delta.x=(double) x-(q+1)->x; + delta.y=(double) y-(q+1)->y; + distance=delta.x*delta.x+delta.y*delta.y; + } + else + { + alpha=1.0/alpha; + beta=delta.x*(y-q->y)-delta.y*(x-q->x); + distance=alpha*beta*beta; + } + } + /* + Compute stroke & subpath opacity. + */ + beta=0.0; + if (p->ghostline == MagickFalse) + { + alpha=mid+0.5; + if ((*stroke_alpha < 1.0) && + (distance <= ((alpha+0.25)*(alpha+0.25)))) + { + alpha=mid-0.5; + if (distance <= ((alpha+0.25)*(alpha+0.25))) + *stroke_alpha=1.0; + else + { + beta=1.0; + if (distance != 1.0) + beta=sqrt((double) distance); + alpha=beta-mid-0.5; + if (*stroke_alpha < ((alpha-0.25)*(alpha-0.25))) + *stroke_alpha=(alpha-0.25)*(alpha-0.25); + } + } + } + if ((fill == MagickFalse) || (distance > 1.0) || (subpath_alpha >= 1.0)) + continue; + if (distance <= 0.0) + { + subpath_alpha=1.0; + continue; + } + if (distance > 1.0) + continue; + if (beta == 0.0) + { + beta=1.0; + if (distance != 1.0) + beta=sqrt(distance); + } + alpha=beta-1.0; + if (subpath_alpha < (alpha*alpha)) + subpath_alpha=alpha*alpha; + } + } + /* + Compute fill opacity. + */ + if (fill == MagickFalse) + return(0.0); + if (subpath_alpha >= 1.0) + return(1.0); + /* + Determine winding number. + */ + winding_number=0; + p=polygon_info->edges; + for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++) + { + if ((double) y <= p->bounds.y1) + break; + if (((double) y > p->bounds.y2) || ((double) x <= p->bounds.x1)) + continue; + if ((double) x > p->bounds.x2) + { + winding_number+=p->direction ? 1 : -1; + continue; + } + i=(ssize_t) MagickMax((double) p->highwater,1.0); + for ( ; i < (ssize_t) p->number_points; i++) + if ((double) y <= p->points[i].y) + break; + q=p->points+i-1; + if ((((q+1)->x-q->x)*(y-q->y)) <= (((q+1)->y-q->y)*(x-q->x))) + winding_number+=p->direction ? 1 : -1; + } + if (fill_rule != NonZeroRule) + { + if ((MagickAbsoluteValue(winding_number) & 0x01) != 0) + return(1.0); + } + else + if (MagickAbsoluteValue(winding_number) != 0) + return(1.0); + return(subpath_alpha); +} +","@@ -1417,7 +1417,7 @@ MagickExport MagickBooleanType DrawClipPath(Image *image, + return(MagickFalse); + (void) QueryColorCompliance(""#0000"",AllCompliance, + &clip_mask->background_color,exception); +- clip_mask->background_color.alpha=(Quantum) TransparentAlpha; ++ clip_mask->background_color.alpha=(MagickRealType) TransparentAlpha; + (void) SetImageBackgroundColor(clip_mask,exception); + if (image->debug != MagickFalse) + (void) LogMagickEvent(DrawEvent,GetMagickModule(),""\nbegin clip-path %s"", +@@ -1541,7 +1541,7 @@ static MagickBooleanType DrawDashPolygon(const DrawInfo *draw_info, + status=MagickTrue; + maximum_length=0.0; + total_length=0.0; +- for (i=1; (i < number_vertices) && (length >= 0.0); i++) ++ for (i=1; (i < (ssize_t) number_vertices) && (length >= 0.0); i++) + { + dx=primitive_info[i].point.x-primitive_info[i-1].point.x; + dy=primitive_info[i].point.y-primitive_info[i-1].point.y; +@@ -1794,7 +1794,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, + /* + Interpret graphic primitive. + */ +- GetNextToken(q,&q,extent,keyword); ++ GetNextToken(q,&q,MagickPathExtent,keyword); + if (*keyword == '\0') + break; + if (*keyword == '#') +@@ -2104,7 +2104,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, + GetNextToken(q,&q,extent,token); + weight=ParseCommandOption(MagickWeightOptions,MagickFalse,token); + if (weight == -1) +- weight=StringToUnsignedLong(token); ++ weight=(ssize_t) StringToUnsignedLong(token); + graphic_context[n]->weight=(size_t) weight; + break; + } +@@ -2353,7 +2353,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, + (void) SetImageArtifact(image,key,token); + (void) FormatLocaleString(key,MagickPathExtent,""%s-type"",name); + (void) SetImageArtifact(image,key,type); +- (void) FormatLocaleString(key,MagickPathExtent,""%s-geometry"",name); ++ (void) FormatLocaleString(key,MagickPathExtent,""%s-geometry"", ++ name); + (void) FormatLocaleString(geometry,MagickPathExtent, + ""%gx%g%+.15g%+.15g"", + MagickMax(fabs(bounds.x2-bounds.x1+1.0),1.0), +@@ -4608,7 +4609,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, + */ + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; +- clone_info->stroke.alpha=(Quantum) TransparentAlpha; ++ clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); +@@ -4643,7 +4644,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, + } + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; +- clone_info->stroke.alpha=(Quantum) TransparentAlpha; ++ clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); +@@ -4743,7 +4744,7 @@ static MagickBooleanType DrawStrokePolygon(Image *image, + if (clone_info->stroke_pattern != (Image *) NULL) + clone_info->fill_pattern=CloneImage(clone_info->stroke_pattern,0,0, + MagickTrue,exception); +- clone_info->stroke.alpha=(Quantum) TransparentAlpha; ++ clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + clone_info->stroke_width=0.0; + clone_info->fill_rule=NonZeroRule; + status=MagickTrue; +@@ -4858,7 +4859,7 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info) + draw_info->miterlimit=10; + draw_info->decorate=NoDecoration; + draw_info->pointsize=12.0; +- draw_info->undercolor.alpha=(Quantum) TransparentAlpha; ++ draw_info->undercolor.alpha=(MagickRealType) TransparentAlpha; + draw_info->compose=OverCompositeOp; + draw_info->render=MagickTrue; + draw_info->debug=IsEventLogging(); +@@ -4925,7 +4926,7 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info) + + weight=ParseCommandOption(MagickWeightOptions,MagickFalse,option); + if (weight == -1) +- weight=StringToUnsignedLong(option); ++ weight=(ssize_t) StringToUnsignedLong(option); + draw_info->weight=(size_t) weight; + } + exception=DestroyExceptionInfo(exception); +@@ -6021,17 +6022,29 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info, + } + if (q >= (ssize_t) (max_strokes-6*BezierQuantum-360)) + { +- max_strokes+=6*BezierQuantum+360; +- path_p=(PointInfo *) ResizeQuantumMemory(path_p,(size_t) max_strokes, +- sizeof(*path_p)); +- path_q=(PointInfo *) ResizeQuantumMemory(path_q,(size_t) max_strokes, +- sizeof(*path_q)); +- if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL)) +- { +- polygon_primitive=(PrimitiveInfo *) +- RelinquishMagickMemory(polygon_primitive); +- return((PrimitiveInfo *) NULL); +- } ++ if (~max_strokes < (6*BezierQuantum+360)) ++ { ++ path_p=(PointInfo *) RelinquishMagickMemory(path_p); ++ path_q=(PointInfo *) RelinquishMagickMemory(path_q); ++ } ++ else ++ { ++ max_strokes+=6*BezierQuantum+360; ++ path_p=(PointInfo *) ResizeQuantumMemory(path_p,max_strokes, ++ sizeof(*path_p)); ++ path_q=(PointInfo *) ResizeQuantumMemory(path_q,max_strokes, ++ sizeof(*path_q)); ++ } ++ if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL)) ++ { ++ if (path_p != (PointInfo *) NULL) ++ path_p=(PointInfo *) RelinquishMagickMemory(path_p); ++ if (path_q != (PointInfo *) NULL) ++ path_q=(PointInfo *) RelinquishMagickMemory(path_q); ++ polygon_primitive=(PrimitiveInfo *) ++ RelinquishMagickMemory(polygon_primitive); ++ return((PrimitiveInfo *) NULL); ++ } + } + dot_product=dx.q*dy.p-dx.p*dy.q; + if (dot_product <= 0.0)",1344,1580,2048 +15510,"void WebGLRenderingContextBase::TexImageHelperImageData( + TexImageFunctionID function_id, + GLenum target, + GLint level, + GLint internalformat, + GLint border, + GLenum format, + GLenum type, + GLsizei depth, + GLint xoffset, + GLint yoffset, + GLint zoffset, + ImageData* pixels, + const IntRect& source_image_rect, + GLint unpack_image_height) { + const char* func_name = GetTexImageFunctionName(function_id); + if (isContextLost()) + return; + DCHECK(pixels); + if (pixels->data()->BufferBase()->IsNeutered()) { + SynthesizeGLError(GL_INVALID_VALUE, func_name, + ""The source data has been neutered.""); + return; + } + if (!ValidateTexImageBinding(func_name, function_id, target)) + return; + TexImageFunctionType function_type; + if (function_id == kTexImage2D || function_id == kTexImage3D) + function_type = kTexImage; + else + function_type = kTexSubImage; + if (!ValidateTexFunc(func_name, function_type, kSourceImageData, target, + level, internalformat, pixels->width(), pixels->height(), + depth, border, format, type, xoffset, yoffset, zoffset)) + return; + + bool selecting_sub_rectangle = false; + if (!ValidateTexImageSubRectangle( + func_name, function_id, pixels, source_image_rect, depth, + unpack_image_height, &selecting_sub_rectangle)) { + return; + } + IntRect adjusted_source_image_rect = source_image_rect; + if (unpack_flip_y_) { + adjusted_source_image_rect.SetY(pixels->height() - + adjusted_source_image_rect.MaxY()); + } + + Vector data; + bool need_conversion = true; + if (!unpack_flip_y_ && !unpack_premultiply_alpha_ && format == GL_RGBA && + type == GL_UNSIGNED_BYTE && !selecting_sub_rectangle && depth == 1) { + need_conversion = false; + } else { + if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { + type = GL_FLOAT; + } + if (!WebGLImageConversion::ExtractImageData( + pixels->data()->Data(), + WebGLImageConversion::DataFormat::kDataFormatRGBA8, pixels->Size(), + adjusted_source_image_rect, depth, unpack_image_height, format, + type, unpack_flip_y_, unpack_premultiply_alpha_, data)) { + SynthesizeGLError(GL_INVALID_VALUE, func_name, ""bad image data""); + return; + } + } + ScopedUnpackParametersResetRestore temporary_reset_unpack(this); + const uint8_t* bytes = need_conversion ? data.data() : pixels->data()->Data(); + if (function_id == kTexImage2D) { + DCHECK_EQ(unpack_image_height, 0); + TexImage2DBase( + target, level, internalformat, adjusted_source_image_rect.Width(), + adjusted_source_image_rect.Height(), border, format, type, bytes); + } else if (function_id == kTexSubImage2D) { + DCHECK_EQ(unpack_image_height, 0); + ContextGL()->TexSubImage2D( + target, level, xoffset, yoffset, adjusted_source_image_rect.Width(), + adjusted_source_image_rect.Height(), format, type, bytes); + } else { + GLint upload_height = adjusted_source_image_rect.Height(); + if (function_id == kTexImage3D) { + ContextGL()->TexImage3D(target, level, internalformat, + adjusted_source_image_rect.Width(), upload_height, + depth, border, format, type, bytes); + } else { + DCHECK_EQ(function_id, kTexSubImage3D); + ContextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, + adjusted_source_image_rect.Width(), + upload_height, depth, format, type, bytes); + } + } +} +",0,"void WebGLRenderingContextBase::TexImageHelperImageData( + TexImageFunctionID function_id, + GLenum target, + GLint level, + GLint internalformat, + GLint border, + GLenum format, + GLenum type, + GLsizei depth, + GLint xoffset, + GLint yoffset, + GLint zoffset, + ImageData* pixels, + const IntRect& source_image_rect, + GLint unpack_image_height) { + const char* func_name = GetTexImageFunctionName(function_id); + if (isContextLost()) + return; + DCHECK(pixels); + if (pixels->data()->BufferBase()->IsNeutered()) { + SynthesizeGLError(GL_INVALID_VALUE, func_name, + ""The source data has been neutered.""); + return; + } + if (!ValidateTexImageBinding(func_name, function_id, target)) + return; + TexImageFunctionType function_type; + if (function_id == kTexImage2D || function_id == kTexImage3D) + function_type = kTexImage; + else + function_type = kTexSubImage; + if (!ValidateTexFunc(func_name, function_type, kSourceImageData, target, + level, internalformat, pixels->width(), pixels->height(), + depth, border, format, type, xoffset, yoffset, zoffset)) + return; + + bool selecting_sub_rectangle = false; + if (!ValidateTexImageSubRectangle( + func_name, function_id, pixels, source_image_rect, depth, + unpack_image_height, &selecting_sub_rectangle)) { + return; + } + IntRect adjusted_source_image_rect = source_image_rect; + if (unpack_flip_y_) { + adjusted_source_image_rect.SetY(pixels->height() - + adjusted_source_image_rect.MaxY()); + } + + Vector data; + bool need_conversion = true; + if (!unpack_flip_y_ && !unpack_premultiply_alpha_ && format == GL_RGBA && + type == GL_UNSIGNED_BYTE && !selecting_sub_rectangle && depth == 1) { + need_conversion = false; + } else { + if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { + type = GL_FLOAT; + } + if (!WebGLImageConversion::ExtractImageData( + pixels->data()->Data(), + WebGLImageConversion::DataFormat::kDataFormatRGBA8, pixels->Size(), + adjusted_source_image_rect, depth, unpack_image_height, format, + type, unpack_flip_y_, unpack_premultiply_alpha_, data)) { + SynthesizeGLError(GL_INVALID_VALUE, func_name, ""bad image data""); + return; + } + } + ScopedUnpackParametersResetRestore temporary_reset_unpack(this); + const uint8_t* bytes = need_conversion ? data.data() : pixels->data()->Data(); + if (function_id == kTexImage2D) { + DCHECK_EQ(unpack_image_height, 0); + TexImage2DBase( + target, level, internalformat, adjusted_source_image_rect.Width(), + adjusted_source_image_rect.Height(), border, format, type, bytes); + } else if (function_id == kTexSubImage2D) { + DCHECK_EQ(unpack_image_height, 0); + ContextGL()->TexSubImage2D( + target, level, xoffset, yoffset, adjusted_source_image_rect.Width(), + adjusted_source_image_rect.Height(), format, type, bytes); + } else { + GLint upload_height = adjusted_source_image_rect.Height(); + if (function_id == kTexImage3D) { + ContextGL()->TexImage3D(target, level, internalformat, + adjusted_source_image_rect.Width(), upload_height, + depth, border, format, type, bytes); + } else { + DCHECK_EQ(function_id, kTexSubImage3D); + ContextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, + adjusted_source_image_rect.Width(), + upload_height, depth, format, type, bytes); + } + } +} +","@@ -30,6 +30,7 @@ + #include ""base/numerics/checked_math.h"" + #include ""base/stl_util.h"" + #include ""build/build_config.h"" ++#include ""gpu/GLES2/gl2extchromium.h"" + #include ""gpu/command_buffer/client/gles2_interface.h"" + #include ""gpu/command_buffer/common/capabilities.h"" + #include ""gpu/config/gpu_feature_info.h"" +@@ -1015,7 +1016,9 @@ WebGLRenderingContextBase::WebGLRenderingContextBase( + &WebGLRenderingContextBase::MaybeRestoreContext), + task_runner_(task_runner), + num_gl_errors_to_console_allowed_(kMaxGLErrorsAllowedToConsole), +- context_type_(context_type) { ++ context_type_(context_type), ++ program_completion_queries_( ++ base::MRUCache::NO_AUTO_EVICT) { + DCHECK(context_provider); + + // TODO(http://crbug.com/876140) Make sure this is being created on a +@@ -1304,6 +1307,8 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase() { + // context state. + destruction_in_progress_ = true; + ++ clearProgramCompletionQueries(); ++ + // Now that the context and context group no longer hold on to the + // objects they create, and now that the objects are eagerly finalized + // rather than the context, there is very little useful work that this +@@ -3455,7 +3460,10 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter( + ""invalid parameter name""); + return ScriptValue::CreateNull(script_state); + } +- ++ bool completed; ++ if (checkProgramCompletionQueryAvailable(program, &completed)) { ++ return WebGLAny(script_state, completed); ++ } + return WebGLAny(script_state, program->CompletionStatus(this)); + case GL_ACTIVE_UNIFORM_BLOCKS: + case GL_TRANSFORM_FEEDBACK_VARYINGS: +@@ -4190,7 +4198,17 @@ void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) { + return; + } + ++ GLuint query = 0u; ++ if (ExtensionEnabled(kKHRParallelShaderCompileName)) { ++ ContextGL()->GenQueriesEXT(1, &query); ++ ContextGL()->BeginQueryEXT(GL_PROGRAM_COMPLETION_QUERY_CHROMIUM, query); ++ } + ContextGL()->LinkProgram(ObjectOrZero(program)); ++ if (ExtensionEnabled(kKHRParallelShaderCompileName)) { ++ ContextGL()->EndQueryEXT(GL_PROGRAM_COMPLETION_QUERY_CHROMIUM); ++ addProgramCompletionQuery(program, query); ++ } ++ + program->IncreaseLinkCount(); + } + +@@ -8151,4 +8169,40 @@ void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( + } + } + ++void WebGLRenderingContextBase::addProgramCompletionQuery(WebGLProgram* program, ++ GLuint query) { ++ auto old_query = program_completion_queries_.Get(program); ++ if (old_query != program_completion_queries_.end()) { ++ ContextGL()->DeleteQueriesEXT(1, &old_query->second); ++ } ++ program_completion_queries_.Put(program, query); ++ if (program_completion_queries_.size() > kMaxProgramCompletionQueries) { ++ auto oldest = program_completion_queries_.rbegin(); ++ ContextGL()->DeleteQueriesEXT(1, &oldest->second); ++ program_completion_queries_.Erase(oldest); ++ } ++} ++ ++void WebGLRenderingContextBase::clearProgramCompletionQueries() { ++ for (auto query : program_completion_queries_) { ++ ContextGL()->DeleteQueriesEXT(1, &query.second); ++ } ++ program_completion_queries_.Clear(); ++} ++ ++bool WebGLRenderingContextBase::checkProgramCompletionQueryAvailable( ++ WebGLProgram* program, ++ bool* completed) { ++ GLuint id = 0; ++ auto found = program_completion_queries_.Get(program); ++ if (found != program_completion_queries_.end()) { ++ id = found->second; ++ GLuint available; ++ ContextGL()->GetQueryObjectuivEXT(id, GL_QUERY_RESULT_AVAILABLE, ++ &available); ++ *completed = (available == GL_TRUE); ++ return true; ++ } ++ return false; ++} + } // namespace blink",832,1068,2048 +5228,"proto_register_usb_ms(void) +{ + static hf_register_info hf[] = { + { &hf_usb_ms_dCBWSignature, + { ""Signature"", ""usbms.dCBWSignature"", FT_UINT32, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWTag, + { ""Tag"", ""usbms.dCBWTag"", FT_UINT32, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWDataTransferLength, + { ""DataTransferLength"", ""usbms.dCBWDataTransferLength"", FT_UINT32, BASE_DEC, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWFlags, + { ""Flags"", ""usbms.dCBWFlags"", FT_UINT8, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWTarget, + { ""Target"", ""usbms.dCBWTarget"", FT_UINT8, BASE_HEX_DEC, + NULL, 0x70, ""Target Number when enabling multi-target mode"", HFILL }}, + + { &hf_usb_ms_dCBWLUN, + { ""LUN"", ""usbms.dCBWLUN"", FT_UINT8, BASE_HEX, + NULL, 0x0f, NULL, HFILL }}, + + { &hf_usb_ms_dCBWCBLength, + { ""CDB Length"", ""usbms.dCBWCBLength"", FT_UINT8, BASE_HEX, + NULL, 0x1f, NULL, HFILL }}, + + { &hf_usb_ms_dCSWSignature, + { ""Signature"", ""usbms.dCSWSignature"", FT_UINT32, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCSWDataResidue, + { ""DataResidue"", ""usbms.dCSWDataResidue"", FT_UINT32, BASE_DEC, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCSWStatus, + { ""Status"", ""usbms.dCSWStatus"", FT_UINT8, BASE_HEX, + VALS(status_vals), 0x0, NULL, HFILL }}, + + { &hf_usb_ms_request, + { ""bRequest"", ""usbms.setup.bRequest"", FT_UINT8, BASE_HEX, VALS(setup_request_names_vals), 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_value, + { ""wValue"", ""usbms.setup.wValue"", FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_index, + { ""wIndex"", ""usbms.setup.wIndex"", FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_length, + { ""wLength"", ""usbms.setup.wLength"", FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_maxlun, + { ""Max LUN"", ""usbms.setup.maxlun"", FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + }; + + static gint *usb_ms_subtrees[] = { + &ett_usb_ms, + }; + + + proto_usb_ms = proto_register_protocol(""USB Mass Storage"", ""USBMS"", ""usbms""); + proto_register_field_array(proto_usb_ms, hf, array_length(hf)); + proto_register_subtree_array(usb_ms_subtrees, array_length(usb_ms_subtrees)); + + register_dissector(""usbms"", dissect_usb_ms_bulk, proto_usb_ms); +} +",0,"proto_register_usb_ms(void) +{ + static hf_register_info hf[] = { + { &hf_usb_ms_dCBWSignature, + { ""Signature"", ""usbms.dCBWSignature"", FT_UINT32, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWTag, + { ""Tag"", ""usbms.dCBWTag"", FT_UINT32, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWDataTransferLength, + { ""DataTransferLength"", ""usbms.dCBWDataTransferLength"", FT_UINT32, BASE_DEC, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWFlags, + { ""Flags"", ""usbms.dCBWFlags"", FT_UINT8, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCBWTarget, + { ""Target"", ""usbms.dCBWTarget"", FT_UINT8, BASE_HEX_DEC, + NULL, 0x70, ""Target Number when enabling multi-target mode"", HFILL }}, + + { &hf_usb_ms_dCBWLUN, + { ""LUN"", ""usbms.dCBWLUN"", FT_UINT8, BASE_HEX, + NULL, 0x0f, NULL, HFILL }}, + + { &hf_usb_ms_dCBWCBLength, + { ""CDB Length"", ""usbms.dCBWCBLength"", FT_UINT8, BASE_HEX, + NULL, 0x1f, NULL, HFILL }}, + + { &hf_usb_ms_dCSWSignature, + { ""Signature"", ""usbms.dCSWSignature"", FT_UINT32, BASE_HEX, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCSWDataResidue, + { ""DataResidue"", ""usbms.dCSWDataResidue"", FT_UINT32, BASE_DEC, + NULL, 0x0, NULL, HFILL }}, + + { &hf_usb_ms_dCSWStatus, + { ""Status"", ""usbms.dCSWStatus"", FT_UINT8, BASE_HEX, + VALS(status_vals), 0x0, NULL, HFILL }}, + + { &hf_usb_ms_request, + { ""bRequest"", ""usbms.setup.bRequest"", FT_UINT8, BASE_HEX, VALS(setup_request_names_vals), 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_value, + { ""wValue"", ""usbms.setup.wValue"", FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_index, + { ""wIndex"", ""usbms.setup.wIndex"", FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_length, + { ""wLength"", ""usbms.setup.wLength"", FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_usb_ms_maxlun, + { ""Max LUN"", ""usbms.setup.maxlun"", FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + }; + + static gint *usb_ms_subtrees[] = { + &ett_usb_ms, + }; + + + proto_usb_ms = proto_register_protocol(""USB Mass Storage"", ""USBMS"", ""usbms""); + proto_register_field_array(proto_usb_ms, hf, array_length(hf)); + proto_register_subtree_array(usb_ms_subtrees, array_length(usb_ms_subtrees)); + + register_dissector(""usbms"", dissect_usb_ms_bulk, proto_usb_ms); +} +","@@ -199,9 +199,12 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, + usb_ms_conv_info->itl=wmem_tree_new(wmem_file_scope()); + usb_ms_conv_info->itlq=wmem_tree_new(wmem_file_scope()); + usb_conv_info->class_data=usb_ms_conv_info; ++ usb_conv_info->class_data_type = USB_CONV_MASS_STORAGE; ++ } else if (usb_conv_info->class_data_type != USB_CONV_MASS_STORAGE) { ++ /* Don't dissect if another USB type is in the conversation */ ++ return 0; + } + +- + is_request=(pinfo->srcport==NO_ENDPOINT); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, ""USBMS"");",821,1057,2048 +903,"int vrend_create_shader(struct vrend_context *ctx, + uint32_t handle, + const struct pipe_stream_output_info *so_info, + const char *shd_text, uint32_t offlen, uint32_t num_tokens, + uint32_t type, uint32_t pkt_length) +{ + struct vrend_shader_selector *sel = NULL; + int ret_handle; + bool new_shader = true, long_shader = false; + bool finished = false; + int ret; + + if (type > PIPE_SHADER_GEOMETRY) + return EINVAL; + + if (offlen & VIRGL_OBJ_SHADER_OFFSET_CONT) + new_shader = false; + else if (((offlen + 3) / 4) > pkt_length) + long_shader = true; + + /* if we have an in progress one - don't allow a new shader + of that type or a different handle. */ + if (ctx->sub->long_shader_in_progress_handle[type]) { + if (new_shader == true) + return EINVAL; + if (handle != ctx->sub->long_shader_in_progress_handle[type]) + return EINVAL; + } + + if (new_shader) { + sel = vrend_create_shader_state(ctx, so_info, type); + if (sel == NULL) + return ENOMEM; + + if (long_shader) { + sel->buf_len = ((offlen + 3) / 4) * 4; /* round up buffer size */ + sel->tmp_buf = malloc(sel->buf_len); + if (!sel->tmp_buf) { + ret = ENOMEM; + goto error; + } + memcpy(sel->tmp_buf, shd_text, pkt_length * 4); + sel->buf_offset = pkt_length * 4; + ctx->sub->long_shader_in_progress_handle[type] = handle; + } else + finished = true; + } else { + sel = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_SHADER); + if (!sel) { + fprintf(stderr, ""got continuation without original shader %d\n"", handle); + ret = EINVAL; + goto error; + } + + offlen &= ~VIRGL_OBJ_SHADER_OFFSET_CONT; + if (offlen != sel->buf_offset) { + fprintf(stderr, ""Got mismatched shader continuation %d vs %d\n"", + offlen, sel->buf_offset); + ret = EINVAL; + goto error; + } + + /*make sure no overflow */ + if (pkt_length * 4 < pkt_length || + pkt_length * 4 + sel->buf_offset < pkt_length * 4 || + pkt_length * 4 + sel->buf_offset < sel->buf_offset) { + ret = EINVAL; + goto error; + } + + if ((pkt_length * 4 + sel->buf_offset) > sel->buf_len) { + fprintf(stderr, ""Got too large shader continuation %d vs %d\n"", + pkt_length * 4 + sel->buf_offset, sel->buf_len); + ret = EINVAL; + goto error; + } + + memcpy(sel->tmp_buf + sel->buf_offset, shd_text, pkt_length * 4); + + sel->buf_offset += pkt_length * 4; + if (sel->buf_offset >= sel->buf_len) { + finished = true; + shd_text = sel->tmp_buf; + } + } + + if (finished) { + struct tgsi_token *tokens; + + tokens = calloc(num_tokens + 10, sizeof(struct tgsi_token)); + if (!tokens) { + ret = ENOMEM; + goto error; + } + + if (vrend_dump_shaders) + fprintf(stderr,""shader\n%s\n"", shd_text); + if (!tgsi_text_translate((const char *)shd_text, tokens, num_tokens + 10)) { + free(tokens); + ret = EINVAL; + goto error; + } + + if (vrend_finish_shader(ctx, sel, tokens)) { + free(tokens); + ret = EINVAL; + goto error; + } else { + free(sel->tmp_buf); + sel->tmp_buf = NULL; + } + free(tokens); + ctx->sub->long_shader_in_progress_handle[type] = 0; + } + + if (new_shader) { + ret_handle = vrend_renderer_object_insert(ctx, sel, sizeof(*sel), handle, VIRGL_OBJECT_SHADER); + if (ret_handle == 0) { + ret = ENOMEM; + goto error; + } + } + + return 0; + +error: + if (new_shader) + vrend_destroy_shader_selector(sel); + else + vrend_renderer_object_destroy(ctx, handle); + + return ret; +} +",0,"int vrend_create_shader(struct vrend_context *ctx, + uint32_t handle, + const struct pipe_stream_output_info *so_info, + const char *shd_text, uint32_t offlen, uint32_t num_tokens, + uint32_t type, uint32_t pkt_length) +{ + struct vrend_shader_selector *sel = NULL; + int ret_handle; + bool new_shader = true, long_shader = false; + bool finished = false; + int ret; + + if (type > PIPE_SHADER_GEOMETRY) + return EINVAL; + + if (offlen & VIRGL_OBJ_SHADER_OFFSET_CONT) + new_shader = false; + else if (((offlen + 3) / 4) > pkt_length) + long_shader = true; + + /* if we have an in progress one - don't allow a new shader + of that type or a different handle. */ + if (ctx->sub->long_shader_in_progress_handle[type]) { + if (new_shader == true) + return EINVAL; + if (handle != ctx->sub->long_shader_in_progress_handle[type]) + return EINVAL; + } + + if (new_shader) { + sel = vrend_create_shader_state(ctx, so_info, type); + if (sel == NULL) + return ENOMEM; + + if (long_shader) { + sel->buf_len = ((offlen + 3) / 4) * 4; /* round up buffer size */ + sel->tmp_buf = malloc(sel->buf_len); + if (!sel->tmp_buf) { + ret = ENOMEM; + goto error; + } + memcpy(sel->tmp_buf, shd_text, pkt_length * 4); + sel->buf_offset = pkt_length * 4; + ctx->sub->long_shader_in_progress_handle[type] = handle; + } else + finished = true; + } else { + sel = vrend_object_lookup(ctx->sub->object_hash, handle, VIRGL_OBJECT_SHADER); + if (!sel) { + fprintf(stderr, ""got continuation without original shader %d\n"", handle); + ret = EINVAL; + goto error; + } + + offlen &= ~VIRGL_OBJ_SHADER_OFFSET_CONT; + if (offlen != sel->buf_offset) { + fprintf(stderr, ""Got mismatched shader continuation %d vs %d\n"", + offlen, sel->buf_offset); + ret = EINVAL; + goto error; + } + + /*make sure no overflow */ + if (pkt_length * 4 < pkt_length || + pkt_length * 4 + sel->buf_offset < pkt_length * 4 || + pkt_length * 4 + sel->buf_offset < sel->buf_offset) { + ret = EINVAL; + goto error; + } + + if ((pkt_length * 4 + sel->buf_offset) > sel->buf_len) { + fprintf(stderr, ""Got too large shader continuation %d vs %d\n"", + pkt_length * 4 + sel->buf_offset, sel->buf_len); + ret = EINVAL; + goto error; + } + + memcpy(sel->tmp_buf + sel->buf_offset, shd_text, pkt_length * 4); + + sel->buf_offset += pkt_length * 4; + if (sel->buf_offset >= sel->buf_len) { + finished = true; + shd_text = sel->tmp_buf; + } + } + + if (finished) { + struct tgsi_token *tokens; + + tokens = calloc(num_tokens + 10, sizeof(struct tgsi_token)); + if (!tokens) { + ret = ENOMEM; + goto error; + } + + if (vrend_dump_shaders) + fprintf(stderr,""shader\n%s\n"", shd_text); + if (!tgsi_text_translate((const char *)shd_text, tokens, num_tokens + 10)) { + free(tokens); + ret = EINVAL; + goto error; + } + + if (vrend_finish_shader(ctx, sel, tokens)) { + free(tokens); + ret = EINVAL; + goto error; + } else { + free(sel->tmp_buf); + sel->tmp_buf = NULL; + } + free(tokens); + ctx->sub->long_shader_in_progress_handle[type] = 0; + } + + if (new_shader) { + ret_handle = vrend_renderer_object_insert(ctx, sel, sizeof(*sel), handle, VIRGL_OBJECT_SHADER); + if (ret_handle == 0) { + ret = ENOMEM; + goto error; + } + } + + return 0; + +error: + if (new_shader) + vrend_destroy_shader_selector(sel); + else + vrend_renderer_object_destroy(ctx, handle); + + return ret; +} +","@@ -1648,18 +1648,19 @@ int vrend_create_vertex_elements_state(struct vrend_context *ctx, + unsigned num_elements, + const struct pipe_vertex_element *elements) + { +- struct vrend_vertex_element_array *v = CALLOC_STRUCT(vrend_vertex_element_array); ++ struct vrend_vertex_element_array *v; + const struct util_format_description *desc; + GLenum type; + int i; + uint32_t ret_handle; + +- if (!v) +- return ENOMEM; +- + if (num_elements > PIPE_MAX_ATTRIBS) + return EINVAL; + ++ v = CALLOC_STRUCT(vrend_vertex_element_array); ++ if (!v) ++ return ENOMEM; ++ + v->count = num_elements; + for (i = 0; i < num_elements; i++) { + memcpy(&v->elements[i].base, &elements[i], sizeof(struct pipe_vertex_element));",989,1225,2048 +18636," std::unique_ptr HandleFileRequest( + const base::FilePath& server_root, + const HttpRequest& request) { + base::ScopedAllowBlockingForTesting allow_blocking; + + GURL request_url = request.GetURL(); + std::string relative_path(request_url.path()); + + std::string post_prefix(""/post/""); + if (base::StartsWith(relative_path, post_prefix, + base::CompareCase::SENSITIVE)) { + if (request.method != METHOD_POST) + return nullptr; + relative_path = relative_path.substr(post_prefix.size() - 1); + } + + RequestQuery query = ParseQuery(request_url); + + std::unique_ptr failed_response(new BasicHttpResponse); + failed_response->set_code(HTTP_NOT_FOUND); + + if (query.find(""expected_body"") != query.end()) { + if (request.content.find(query[""expected_body""].front()) == + std::string::npos) { + return std::move(failed_response); + } + } + + if (query.find(""expected_headers"") != query.end()) { + for (const auto& header : query[""expected_headers""]) { + if (header.find("":"") == std::string::npos) + return std::move(failed_response); + std::string key = header.substr(0, header.find("":"")); + std::string value = header.substr(header.find("":"") + 1); + if (request.headers.find(key) == request.headers.end() || + request.headers.at(key) != value) { + return std::move(failed_response); + } + } + } + + DCHECK(base::StartsWith(relative_path, ""/"", base::CompareCase::SENSITIVE)); + std::string request_path = relative_path.substr(1); + base::FilePath file_path(server_root.AppendASCII(request_path)); + std::string file_contents; + if (!base::ReadFileToString(file_path, &file_contents)) { + file_path = file_path.AppendASCII(""index.html""); + if (!base::ReadFileToString(file_path, &file_contents)) + return nullptr; + } + + if (request.method == METHOD_HEAD) + file_contents = """"; + + if (query.find(""replace_text"") != query.end()) { + for (const auto& replacement : query[""replace_text""]) { + if (replacement.find("":"") == std::string::npos) + return std::move(failed_response); + std::string find; + std::string with; + base::Base64Decode(replacement.substr(0, replacement.find("":"")), &find); + base::Base64Decode(replacement.substr(replacement.find("":"") + 1), &with); + base::ReplaceSubstringsAfterOffset(&file_contents, 0, find, with); + } + } + + base::FilePath::StringPieceType mock_headers_extension; + #if defined(OS_WIN) + base::string16 temp = base::ASCIIToUTF16(kMockHttpHeadersExtension); + mock_headers_extension = temp; +#else + mock_headers_extension = kMockHttpHeadersExtension; +#endif + + base::FilePath headers_path(file_path.AddExtension(mock_headers_extension)); + + if (base::PathExists(headers_path)) { + std::string headers_contents; + + if (!base::ReadFileToString(headers_path, &headers_contents)) + return nullptr; + + return std::make_unique(headers_contents, file_contents); + } + + std::unique_ptr http_response(new BasicHttpResponse); + http_response->set_code(HTTP_OK); + + if (request.headers.find(""Range"") != request.headers.end()) { + std::vector ranges; + + if (HttpUtil::ParseRangeHeader(request.headers.at(""Range""), &ranges) && + ranges.size() == 1) { + ranges[0].ComputeBounds(file_contents.size()); + size_t start = ranges[0].first_byte_position(); + size_t end = ranges[0].last_byte_position(); + + http_response->set_code(HTTP_PARTIAL_CONTENT); + http_response->AddCustomHeader( + ""Content-Range"", + base::StringPrintf(""bytes %"" PRIuS ""-%"" PRIuS ""/%"" PRIuS, start, end, + file_contents.size())); + + file_contents = file_contents.substr(start, end - start + 1); + } + } + + http_response->set_content_type(GetContentType(file_path)); + http_response->AddCustomHeader(""Accept-Ranges"", ""bytes""); + http_response->AddCustomHeader(""ETag"", ""'"" + file_path.MaybeAsASCII() + ""'""); + http_response->set_content(file_contents); + return std::move(http_response); +} +",1," std::unique_ptr HandleFileRequest( + const base::FilePath& server_root, + const HttpRequest& request) { + base::ScopedAllowBlockingForTesting allow_blocking; + + GURL request_url = request.GetURL(); + std::string relative_path(request_url.path()); + + std::string post_prefix(""/post/""); + if (base::StartsWith(relative_path, post_prefix, + base::CompareCase::SENSITIVE)) { + if (request.method != METHOD_POST) + return nullptr; + relative_path = relative_path.substr(post_prefix.size() - 1); + } + + RequestQuery query = ParseQuery(request_url); + + std::unique_ptr failed_response(new BasicHttpResponse); + failed_response->set_code(HTTP_NOT_FOUND); + + if (query.find(""expected_body"") != query.end()) { + if (request.content.find(query[""expected_body""].front()) == + std::string::npos) { + return std::move(failed_response); + } + } + + if (query.find(""expected_headers"") != query.end()) { + for (const auto& header : query[""expected_headers""]) { + if (header.find("":"") == std::string::npos) + return std::move(failed_response); + std::string key = header.substr(0, header.find("":"")); + std::string value = header.substr(header.find("":"") + 1); + if (request.headers.find(key) == request.headers.end() || + request.headers.at(key) != value) { + return std::move(failed_response); + } + } + } + + DCHECK(base::StartsWith(relative_path, ""/"", base::CompareCase::SENSITIVE)); + std::string request_path = relative_path.substr(1); + base::FilePath file_path(server_root.AppendASCII(request_path)); + std::string file_contents; + if (!base::ReadFileToString(file_path, &file_contents)) { + file_path = file_path.AppendASCII(""index.html""); + if (!base::ReadFileToString(file_path, &file_contents)) + return nullptr; + } + + if (request.method == METHOD_HEAD) + file_contents = """"; + + if (!UpdateReplacedText(query, &file_contents)) + return std::move(failed_response); + + base::FilePath::StringPieceType mock_headers_extension; + #if defined(OS_WIN) + base::string16 temp = base::ASCIIToUTF16(kMockHttpHeadersExtension); + mock_headers_extension = temp; +#else + mock_headers_extension = kMockHttpHeadersExtension; +#endif + + base::FilePath headers_path(file_path.AddExtension(mock_headers_extension)); + + if (base::PathExists(headers_path)) { + std::string headers_contents; + + if (!base::ReadFileToString(headers_path, &headers_contents) || + !UpdateReplacedText(query, &headers_contents)) { + return nullptr; + } + + return std::make_unique(headers_contents, file_contents); + } + + std::unique_ptr http_response(new BasicHttpResponse); + http_response->set_code(HTTP_OK); + + if (request.headers.find(""Range"") != request.headers.end()) { + std::vector ranges; + + if (HttpUtil::ParseRangeHeader(request.headers.at(""Range""), &ranges) && + ranges.size() == 1) { + ranges[0].ComputeBounds(file_contents.size()); + size_t start = ranges[0].first_byte_position(); + size_t end = ranges[0].last_byte_position(); + + http_response->set_code(HTTP_PARTIAL_CONTENT); + http_response->AddCustomHeader( + ""Content-Range"", + base::StringPrintf(""bytes %"" PRIuS ""-%"" PRIuS ""/%"" PRIuS, start, end, + file_contents.size())); + + file_contents = file_contents.substr(start, end - start + 1); + } + } + + http_response->set_content_type(GetContentType(file_path)); + http_response->AddCustomHeader(""Accept-Ranges"", ""bytes""); + http_response->AddCustomHeader(""ETag"", ""'"" + file_path.MaybeAsASCII() + ""'""); + http_response->set_content(file_contents); + return std::move(http_response); +} +","@@ -120,6 +120,25 @@ void GetFilePathWithReplacements(const std::string& original_file_path, + *replacement_path = new_file_path; + } + ++// Returns false if there were errors, otherwise true. ++bool UpdateReplacedText(const RequestQuery& query, std::string* data) { ++ auto replace_text = query.find(""replace_text""); ++ if (replace_text == query.end()) ++ return true; ++ ++ for (const auto& replacement : replace_text->second) { ++ if (replacement.find("":"") == std::string::npos) ++ return false; ++ std::string find; ++ std::string with; ++ base::Base64Decode(replacement.substr(0, replacement.find("":"")), &find); ++ base::Base64Decode(replacement.substr(replacement.find("":"") + 1), &with); ++ base::ReplaceSubstringsAfterOffset(data, 0, find, with); ++ } ++ ++ return true; ++} ++ + // Handles |request| by serving a file from under |server_root|. + std::unique_ptr HandleFileRequest( + const base::FilePath& server_root, +@@ -180,17 +199,8 @@ std::unique_ptr HandleFileRequest( + if (request.method == METHOD_HEAD) + file_contents = """"; + +- if (query.find(""replace_text"") != query.end()) { +- for (const auto& replacement : query[""replace_text""]) { +- if (replacement.find("":"") == std::string::npos) +- return std::move(failed_response); +- std::string find; +- std::string with; +- base::Base64Decode(replacement.substr(0, replacement.find("":"")), &find); +- base::Base64Decode(replacement.substr(replacement.find("":"") + 1), &with); +- base::ReplaceSubstringsAfterOffset(&file_contents, 0, find, with); +- } +- } ++ if (!UpdateReplacedText(query, &file_contents)) ++ return std::move(failed_response); + + base::FilePath::StringPieceType mock_headers_extension; + #if defined(OS_WIN) +@@ -205,8 +215,10 @@ std::unique_ptr HandleFileRequest( + if (base::PathExists(headers_path)) { + std::string headers_contents; + +- if (!base::ReadFileToString(headers_path, &headers_contents)) ++ if (!base::ReadFileToString(headers_path, &headers_contents) || ++ !UpdateReplacedText(query, &headers_contents)) { + return nullptr; ++ } + + return std::make_unique(headers_contents, file_contents); + }",959,1195,2048 +17934,"void sctp_assoc_update(struct sctp_association *asoc, + struct sctp_association *new) +{ + struct sctp_transport *trans; + struct list_head *pos, *temp; + + /* Copy in new parameters of peer. */ + asoc->c = new->c; + asoc->peer.rwnd = new->peer.rwnd; + asoc->peer.sack_needed = new->peer.sack_needed; + asoc->peer.i = new->peer.i; + sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, + asoc->peer.i.initial_tsn, GFP_ATOMIC); + + /* Remove any peer addresses not present in the new association. */ + list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { + trans = list_entry(pos, struct sctp_transport, transports); + if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr)) { + sctp_assoc_rm_peer(asoc, trans); + continue; + } + + if (asoc->state >= SCTP_STATE_ESTABLISHED) + sctp_transport_reset(trans); + } + + /* If the case is A (association restart), use + * initial_tsn as next_tsn. If the case is B, use + * current next_tsn in case data sent to peer + * has been discarded and needs retransmission. + */ + if (asoc->state >= SCTP_STATE_ESTABLISHED) { + asoc->next_tsn = new->next_tsn; + asoc->ctsn_ack_point = new->ctsn_ack_point; + asoc->adv_peer_ack_point = new->adv_peer_ack_point; + + /* Reinitialize SSN for both local streams + * and peer's streams. + */ + sctp_ssnmap_clear(asoc->ssnmap); + + /* Flush the ULP reassembly and ordered queue. + * Any data there will now be stale and will + * cause problems. + */ + sctp_ulpq_flush(&asoc->ulpq); + + /* reset the overall association error count so + * that the restarted association doesn't get torn + * down on the next retransmission timer. + */ + asoc->overall_error_count = 0; + + } else { + /* Add any peer addresses from the new association. */ + list_for_each_entry(trans, &new->peer.transport_addr_list, + transports) { + if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) + sctp_assoc_add_peer(asoc, &trans->ipaddr, + GFP_ATOMIC, trans->state); + } + + asoc->ctsn_ack_point = asoc->next_tsn - 1; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + if (!asoc->ssnmap) { + /* Move the ssnmap. */ + asoc->ssnmap = new->ssnmap; + new->ssnmap = NULL; + } + + if (!asoc->assoc_id) { + /* get a new association id since we don't have one + * yet. + */ + sctp_assoc_set_id(asoc, GFP_ATOMIC); + } + } + + /* SCTP-AUTH: Save the peer parameters from the new associations + * and also move the association shared keys over + */ + kfree(asoc->peer.peer_random); + asoc->peer.peer_random = new->peer.peer_random; + new->peer.peer_random = NULL; + + kfree(asoc->peer.peer_chunks); + asoc->peer.peer_chunks = new->peer.peer_chunks; + new->peer.peer_chunks = NULL; + + kfree(asoc->peer.peer_hmacs); + asoc->peer.peer_hmacs = new->peer.peer_hmacs; + new->peer.peer_hmacs = NULL; + + sctp_auth_key_put(asoc->asoc_shared_key); + sctp_auth_asoc_init_active_key(asoc, GFP_ATOMIC); +} +",1,"void sctp_assoc_update(struct sctp_association *asoc, + struct sctp_association *new) +{ + struct sctp_transport *trans; + struct list_head *pos, *temp; + + /* Copy in new parameters of peer. */ + asoc->c = new->c; + asoc->peer.rwnd = new->peer.rwnd; + asoc->peer.sack_needed = new->peer.sack_needed; + asoc->peer.auth_capable = new->peer.auth_capable; + asoc->peer.i = new->peer.i; + sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, + asoc->peer.i.initial_tsn, GFP_ATOMIC); + + /* Remove any peer addresses not present in the new association. */ + list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { + trans = list_entry(pos, struct sctp_transport, transports); + if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr)) { + sctp_assoc_rm_peer(asoc, trans); + continue; + } + + if (asoc->state >= SCTP_STATE_ESTABLISHED) + sctp_transport_reset(trans); + } + + /* If the case is A (association restart), use + * initial_tsn as next_tsn. If the case is B, use + * current next_tsn in case data sent to peer + * has been discarded and needs retransmission. + */ + if (asoc->state >= SCTP_STATE_ESTABLISHED) { + asoc->next_tsn = new->next_tsn; + asoc->ctsn_ack_point = new->ctsn_ack_point; + asoc->adv_peer_ack_point = new->adv_peer_ack_point; + + /* Reinitialize SSN for both local streams + * and peer's streams. + */ + sctp_ssnmap_clear(asoc->ssnmap); + + /* Flush the ULP reassembly and ordered queue. + * Any data there will now be stale and will + * cause problems. + */ + sctp_ulpq_flush(&asoc->ulpq); + + /* reset the overall association error count so + * that the restarted association doesn't get torn + * down on the next retransmission timer. + */ + asoc->overall_error_count = 0; + + } else { + /* Add any peer addresses from the new association. */ + list_for_each_entry(trans, &new->peer.transport_addr_list, + transports) { + if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) + sctp_assoc_add_peer(asoc, &trans->ipaddr, + GFP_ATOMIC, trans->state); + } + + asoc->ctsn_ack_point = asoc->next_tsn - 1; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + if (!asoc->ssnmap) { + /* Move the ssnmap. */ + asoc->ssnmap = new->ssnmap; + new->ssnmap = NULL; + } + + if (!asoc->assoc_id) { + /* get a new association id since we don't have one + * yet. + */ + sctp_assoc_set_id(asoc, GFP_ATOMIC); + } + } + + /* SCTP-AUTH: Save the peer parameters from the new associations + * and also move the association shared keys over + */ + kfree(asoc->peer.peer_random); + asoc->peer.peer_random = new->peer.peer_random; + new->peer.peer_random = NULL; + + kfree(asoc->peer.peer_chunks); + asoc->peer.peer_chunks = new->peer.peer_chunks; + new->peer.peer_chunks = NULL; + + kfree(asoc->peer.peer_hmacs); + asoc->peer.peer_hmacs = new->peer.peer_hmacs; + new->peer.peer_hmacs = NULL; + + sctp_auth_key_put(asoc->asoc_shared_key); + sctp_auth_asoc_init_active_key(asoc, GFP_ATOMIC); +} +","@@ -1097,6 +1097,7 @@ void sctp_assoc_update(struct sctp_association *asoc, + asoc->c = new->c; + asoc->peer.rwnd = new->peer.rwnd; + asoc->peer.sack_needed = new->peer.sack_needed; ++ asoc->peer.auth_capable = new->peer.auth_capable; + asoc->peer.i = new->peer.i; + sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, + asoc->peer.i.initial_tsn, GFP_ATOMIC);",852,1088,2048 +605,"static void xhci_process_commands(XHCIState *xhci) +{ + XHCITRB trb; + TRBType type; + XHCIEvent event = {ER_COMMAND_COMPLETE, CC_SUCCESS}; + dma_addr_t addr; + unsigned int i, slotid = 0; + + DPRINTF(""xhci_process_commands()\n""); + if (!xhci_running(xhci)) { + DPRINTF(""xhci_process_commands() called while xHC stopped or paused\n""); + return; + } + + xhci->crcr_low |= CRCR_CRR; + + while ((type = xhci_ring_fetch(xhci, &xhci->cmd_ring, &trb, &addr))) { + event.ptr = addr; + switch (type) { + case CR_ENABLE_SLOT: + for (i = 0; i < xhci->numslots; i++) { + if (!xhci->slots[i].enabled) { + break; + } + } + if (i >= xhci->numslots) { + DPRINTF(""xhci: no device slots available\n""); + event.ccode = CC_NO_SLOTS_ERROR; + } else { + slotid = i+1; + event.ccode = xhci_enable_slot(xhci, slotid); + } + break; + case CR_DISABLE_SLOT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_disable_slot(xhci, slotid); + } + break; + case CR_ADDRESS_DEVICE: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_address_slot(xhci, slotid, trb.parameter, + trb.control & TRB_CR_BSR); + } + break; + case CR_CONFIGURE_ENDPOINT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_configure_slot(xhci, slotid, trb.parameter, + trb.control & TRB_CR_DC); + } + break; + case CR_EVALUATE_CONTEXT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_evaluate_slot(xhci, slotid, trb.parameter); + } + break; + case CR_STOP_ENDPOINT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) + & TRB_CR_EPID_MASK; + event.ccode = xhci_stop_ep(xhci, slotid, epid); + } + break; + case CR_RESET_ENDPOINT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) + & TRB_CR_EPID_MASK; + event.ccode = xhci_reset_ep(xhci, slotid, epid); + } + break; + case CR_SET_TR_DEQUEUE: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) + & TRB_CR_EPID_MASK; + unsigned int streamid = (trb.status >> 16) & 0xffff; + event.ccode = xhci_set_ep_dequeue(xhci, slotid, + epid, streamid, + trb.parameter); + } + break; + case CR_RESET_DEVICE: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_reset_slot(xhci, slotid); + } + break; + case CR_GET_PORT_BANDWIDTH: + event.ccode = xhci_get_port_bandwidth(xhci, trb.parameter); + break; + case CR_VENDOR_VIA_CHALLENGE_RESPONSE: + xhci_via_challenge(xhci, trb.parameter); + break; + case CR_VENDOR_NEC_FIRMWARE_REVISION: + event.type = 48; /* NEC reply */ + event.length = 0x3025; + break; + case CR_VENDOR_NEC_CHALLENGE_RESPONSE: + { + uint32_t chi = trb.parameter >> 32; + uint32_t clo = trb.parameter; + uint32_t val = xhci_nec_challenge(chi, clo); + event.length = val & 0xFFFF; + event.epid = val >> 16; + slotid = val >> 24; + event.type = 48; /* NEC reply */ + } + break; + default: + trace_usb_xhci_unimplemented(""command"", type); + event.ccode = CC_TRB_ERROR; + break; + } + event.slotid = slotid; + xhci_event(xhci, &event, 0); + } +} +",0,"static void xhci_process_commands(XHCIState *xhci) +{ + XHCITRB trb; + TRBType type; + XHCIEvent event = {ER_COMMAND_COMPLETE, CC_SUCCESS}; + dma_addr_t addr; + unsigned int i, slotid = 0; + + DPRINTF(""xhci_process_commands()\n""); + if (!xhci_running(xhci)) { + DPRINTF(""xhci_process_commands() called while xHC stopped or paused\n""); + return; + } + + xhci->crcr_low |= CRCR_CRR; + + while ((type = xhci_ring_fetch(xhci, &xhci->cmd_ring, &trb, &addr))) { + event.ptr = addr; + switch (type) { + case CR_ENABLE_SLOT: + for (i = 0; i < xhci->numslots; i++) { + if (!xhci->slots[i].enabled) { + break; + } + } + if (i >= xhci->numslots) { + DPRINTF(""xhci: no device slots available\n""); + event.ccode = CC_NO_SLOTS_ERROR; + } else { + slotid = i+1; + event.ccode = xhci_enable_slot(xhci, slotid); + } + break; + case CR_DISABLE_SLOT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_disable_slot(xhci, slotid); + } + break; + case CR_ADDRESS_DEVICE: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_address_slot(xhci, slotid, trb.parameter, + trb.control & TRB_CR_BSR); + } + break; + case CR_CONFIGURE_ENDPOINT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_configure_slot(xhci, slotid, trb.parameter, + trb.control & TRB_CR_DC); + } + break; + case CR_EVALUATE_CONTEXT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_evaluate_slot(xhci, slotid, trb.parameter); + } + break; + case CR_STOP_ENDPOINT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) + & TRB_CR_EPID_MASK; + event.ccode = xhci_stop_ep(xhci, slotid, epid); + } + break; + case CR_RESET_ENDPOINT: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) + & TRB_CR_EPID_MASK; + event.ccode = xhci_reset_ep(xhci, slotid, epid); + } + break; + case CR_SET_TR_DEQUEUE: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) + & TRB_CR_EPID_MASK; + unsigned int streamid = (trb.status >> 16) & 0xffff; + event.ccode = xhci_set_ep_dequeue(xhci, slotid, + epid, streamid, + trb.parameter); + } + break; + case CR_RESET_DEVICE: + slotid = xhci_get_slot(xhci, &event, &trb); + if (slotid) { + event.ccode = xhci_reset_slot(xhci, slotid); + } + break; + case CR_GET_PORT_BANDWIDTH: + event.ccode = xhci_get_port_bandwidth(xhci, trb.parameter); + break; + case CR_VENDOR_VIA_CHALLENGE_RESPONSE: + xhci_via_challenge(xhci, trb.parameter); + break; + case CR_VENDOR_NEC_FIRMWARE_REVISION: + event.type = 48; /* NEC reply */ + event.length = 0x3025; + break; + case CR_VENDOR_NEC_CHALLENGE_RESPONSE: + { + uint32_t chi = trb.parameter >> 32; + uint32_t clo = trb.parameter; + uint32_t val = xhci_nec_challenge(chi, clo); + event.length = val & 0xFFFF; + event.epid = val >> 16; + slotid = val >> 24; + event.type = 48; /* NEC reply */ + } + break; + default: + trace_usb_xhci_unimplemented(""command"", type); + event.ccode = CC_TRB_ERROR; + break; + } + event.slotid = slotid; + xhci_event(xhci, &event, 0); + } +} +","@@ -390,6 +390,7 @@ struct XHCIEPContext { + dma_addr_t pctx; + unsigned int max_psize; + uint32_t state; ++ uint32_t kick_active; + + /* streams */ + unsigned int max_pstreams; +@@ -2131,6 +2132,9 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid, + return; + } + ++ if (epctx->kick_active) { ++ return; ++ } + xhci_kick_epctx(epctx, streamid); + } + +@@ -2146,6 +2150,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid) + int i; + + trace_usb_xhci_ep_kick(epctx->slotid, epctx->epid, streamid); ++ assert(!epctx->kick_active); + + /* If the device has been detached, but the guest has not noticed this + yet the 2 above checks will succeed, but we must NOT continue */ +@@ -2217,6 +2222,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid) + } + assert(ring->dequeue != 0); + ++ epctx->kick_active++; + while (1) { + length = xhci_ring_chain_length(xhci, ring); + if (length <= 0) { +@@ -2253,6 +2259,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid) + break; + } + } ++ epctx->kick_active--; + + ep = xhci_epid_to_usbep(epctx); + if (ep) {",1080,1316,2048 +18794,"status_t BnGraphicBufferConsumer::onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) +{ + switch(code) { + case ACQUIRE_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + BufferItem item; + int64_t presentWhen = data.readInt64(); + status_t result = acquireBuffer(&item, presentWhen); + status_t err = reply->write(item); + if (err) return err; + reply->writeInt32(result); + return NO_ERROR; + } break; + case DETACH_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + int slot = data.readInt32(); + int result = detachBuffer(slot); + reply->writeInt32(result); + return NO_ERROR; + } break; + case ATTACH_BUFFER: { + + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + sp buffer = new GraphicBuffer(); + data.read(*buffer.get()); + int slot; + int result = attachBuffer(&slot, buffer); + reply->writeInt32(slot); + reply->writeInt32(result); + return NO_ERROR; + } break; + case RELEASE_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + int buf = data.readInt32(); + uint64_t frameNumber = data.readInt64(); + sp releaseFence = new Fence(); + status_t err = data.read(*releaseFence); + if (err) return err; + status_t result = releaseBuffer(buf, frameNumber, + EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); + reply->writeInt32(result); + return NO_ERROR; + } break; + case CONSUMER_CONNECT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + sp consumer = IConsumerListener::asInterface( data.readStrongBinder() ); + bool controlledByApp = data.readInt32(); + status_t result = consumerConnect(consumer, controlledByApp); + reply->writeInt32(result); + return NO_ERROR; + } break; + case CONSUMER_DISCONNECT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + status_t result = consumerDisconnect(); + reply->writeInt32(result); + return NO_ERROR; + } break; + case GET_RELEASED_BUFFERS: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint64_t slotMask; + status_t result = getReleasedBuffers(&slotMask); + reply->writeInt64(slotMask); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_DEFAULT_BUFFER_SIZE: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t w = data.readInt32(); + uint32_t h = data.readInt32(); + status_t result = setDefaultBufferSize(w, h); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_DEFAULT_MAX_BUFFER_COUNT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t bufferCount = data.readInt32(); + status_t result = setDefaultMaxBufferCount(bufferCount); + reply->writeInt32(result); + return NO_ERROR; + } break; + case DISABLE_ASYNC_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + status_t result = disableAsyncBuffer(); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_MAX_ACQUIRED_BUFFER_COUNT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t maxAcquiredBuffers = data.readInt32(); + status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_CONSUMER_NAME: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + setConsumerName( data.readString8() ); + return NO_ERROR; + } break; + case SET_DEFAULT_BUFFER_FORMAT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t defaultFormat = data.readInt32(); + status_t result = setDefaultBufferFormat(defaultFormat); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_CONSUMER_USAGE_BITS: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t usage = data.readInt32(); + status_t result = setConsumerUsageBits(usage); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_TRANSFORM_HINT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t hint = data.readInt32(); + status_t result = setTransformHint(hint); + reply->writeInt32(result); + return NO_ERROR; + } break; + case DUMP: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + String8 result = data.readString8(); + String8 prefix = data.readString8(); + static_cast(this)->dump(result, prefix); + reply->writeString8(result); + return NO_ERROR; + } + } + return BBinder::onTransact(code, data, reply, flags); +} +",1,"status_t BnGraphicBufferConsumer::onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) +{ + switch(code) { + case ACQUIRE_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + BufferItem item; + int64_t presentWhen = data.readInt64(); + status_t result = acquireBuffer(&item, presentWhen); + status_t err = reply->write(item); + if (err) return err; + reply->writeInt32(result); + return NO_ERROR; + } break; + case DETACH_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + int slot = data.readInt32(); + int result = detachBuffer(slot); + reply->writeInt32(result); + return NO_ERROR; + } break; + case ATTACH_BUFFER: { + + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + sp buffer = new GraphicBuffer(); + data.read(*buffer.get()); + int slot = -1; + int result = attachBuffer(&slot, buffer); + reply->writeInt32(slot); + reply->writeInt32(result); + return NO_ERROR; + } break; + case RELEASE_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + int buf = data.readInt32(); + uint64_t frameNumber = data.readInt64(); + sp releaseFence = new Fence(); + status_t err = data.read(*releaseFence); + if (err) return err; + status_t result = releaseBuffer(buf, frameNumber, + EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); + reply->writeInt32(result); + return NO_ERROR; + } break; + case CONSUMER_CONNECT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + sp consumer = IConsumerListener::asInterface( data.readStrongBinder() ); + bool controlledByApp = data.readInt32(); + status_t result = consumerConnect(consumer, controlledByApp); + reply->writeInt32(result); + return NO_ERROR; + } break; + case CONSUMER_DISCONNECT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + status_t result = consumerDisconnect(); + reply->writeInt32(result); + return NO_ERROR; + } break; + case GET_RELEASED_BUFFERS: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint64_t slotMask; + status_t result = getReleasedBuffers(&slotMask); + reply->writeInt64(slotMask); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_DEFAULT_BUFFER_SIZE: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t w = data.readInt32(); + uint32_t h = data.readInt32(); + status_t result = setDefaultBufferSize(w, h); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_DEFAULT_MAX_BUFFER_COUNT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t bufferCount = data.readInt32(); + status_t result = setDefaultMaxBufferCount(bufferCount); + reply->writeInt32(result); + return NO_ERROR; + } break; + case DISABLE_ASYNC_BUFFER: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + status_t result = disableAsyncBuffer(); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_MAX_ACQUIRED_BUFFER_COUNT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t maxAcquiredBuffers = data.readInt32(); + status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_CONSUMER_NAME: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + setConsumerName( data.readString8() ); + return NO_ERROR; + } break; + case SET_DEFAULT_BUFFER_FORMAT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t defaultFormat = data.readInt32(); + status_t result = setDefaultBufferFormat(defaultFormat); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_CONSUMER_USAGE_BITS: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t usage = data.readInt32(); + status_t result = setConsumerUsageBits(usage); + reply->writeInt32(result); + return NO_ERROR; + } break; + case SET_TRANSFORM_HINT: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + uint32_t hint = data.readInt32(); + status_t result = setTransformHint(hint); + reply->writeInt32(result); + return NO_ERROR; + } break; + case DUMP: { + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + String8 result = data.readString8(); + String8 prefix = data.readString8(); + static_cast(this)->dump(result, prefix); + reply->writeString8(result); + return NO_ERROR; + } + } + return BBinder::onTransact(code, data, reply, flags); +} +","@@ -444,7 +444,7 @@ + + CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); + sp buffer = new GraphicBuffer(); + data.read(*buffer.get()); +- int slot; ++ int slot = -1; + int result = attachBuffer(&slot, buffer); + reply->writeInt32(slot); + reply->writeInt32(result); +",1070,1306,2048 +9319,"int netif_set_xps_queue(struct net_device *dev, const struct cpumask *mask, + u16 index) +{ + struct xps_dev_maps *dev_maps, *new_dev_maps = NULL; + int i, cpu, tci, numa_node_id = -2; + int maps_sz, num_tc = 1, tc = 0; + struct xps_map *map, *new_map; + bool active = false; + + if (dev->num_tc) { + num_tc = dev->num_tc; + tc = netdev_txq_to_tc(dev, index); + if (tc < 0) + return -EINVAL; + } + + maps_sz = XPS_DEV_MAPS_SIZE(num_tc); + if (maps_sz < L1_CACHE_BYTES) + maps_sz = L1_CACHE_BYTES; + + mutex_lock(&xps_map_mutex); + + dev_maps = xmap_dereference(dev->xps_maps); + + /* allocate memory for queue storage */ + for_each_cpu_and(cpu, cpu_online_mask, mask) { + if (!new_dev_maps) + new_dev_maps = kzalloc(maps_sz, GFP_KERNEL); + if (!new_dev_maps) { + mutex_unlock(&xps_map_mutex); + return -ENOMEM; + } + + tci = cpu * num_tc + tc; + map = dev_maps ? xmap_dereference(dev_maps->cpu_map[tci]) : + NULL; + + map = expand_xps_map(map, cpu, index); + if (!map) + goto error; + + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + + if (!new_dev_maps) + goto out_no_new_maps; + + for_each_possible_cpu(cpu) { + /* copy maps belonging to foreign traffic classes */ + for (i = tc, tci = cpu * num_tc; dev_maps && i--; tci++) { + /* fill in the new device map from the old device map */ + map = xmap_dereference(dev_maps->cpu_map[tci]); + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + + /* We need to explicitly update tci as prevous loop + * could break out early if dev_maps is NULL. + */ + tci = cpu * num_tc + tc; + + if (cpumask_test_cpu(cpu, mask) && cpu_online(cpu)) { + /* add queue to CPU maps */ + int pos = 0; + + map = xmap_dereference(new_dev_maps->cpu_map[tci]); + while ((pos < map->len) && (map->queues[pos] != index)) + pos++; + + if (pos == map->len) + map->queues[map->len++] = index; +#ifdef CONFIG_NUMA + if (numa_node_id == -2) + numa_node_id = cpu_to_node(cpu); + else if (numa_node_id != cpu_to_node(cpu)) + numa_node_id = -1; +#endif + } else if (dev_maps) { + /* fill in the new device map from the old device map */ + map = xmap_dereference(dev_maps->cpu_map[tci]); + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + + /* copy maps belonging to foreign traffic classes */ + for (i = num_tc - tc, tci++; dev_maps && --i; tci++) { + /* fill in the new device map from the old device map */ + map = xmap_dereference(dev_maps->cpu_map[tci]); + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + } + + rcu_assign_pointer(dev->xps_maps, new_dev_maps); + + /* Cleanup old maps */ + if (!dev_maps) + goto out_no_old_maps; + + for_each_possible_cpu(cpu) { + for (i = num_tc, tci = cpu * num_tc; i--; tci++) { + new_map = xmap_dereference(new_dev_maps->cpu_map[tci]); + map = xmap_dereference(dev_maps->cpu_map[tci]); + if (map && map != new_map) + kfree_rcu(map, rcu); + } + } + + kfree_rcu(dev_maps, rcu); + +out_no_old_maps: + dev_maps = new_dev_maps; + active = true; + +out_no_new_maps: + /* update Tx queue numa node */ + netdev_queue_numa_node_write(netdev_get_tx_queue(dev, index), + (numa_node_id >= 0) ? numa_node_id : + NUMA_NO_NODE); + + if (!dev_maps) + goto out_no_maps; + + /* removes queue from unused CPUs */ + for_each_possible_cpu(cpu) { + for (i = tc, tci = cpu * num_tc; i--; tci++) + active |= remove_xps_queue(dev_maps, tci, index); + if (!cpumask_test_cpu(cpu, mask) || !cpu_online(cpu)) + active |= remove_xps_queue(dev_maps, tci, index); + for (i = num_tc - tc, tci++; --i; tci++) + active |= remove_xps_queue(dev_maps, tci, index); + } + + /* free map if not active */ + if (!active) { + RCU_INIT_POINTER(dev->xps_maps, NULL); + kfree_rcu(dev_maps, rcu); + } + +out_no_maps: + mutex_unlock(&xps_map_mutex); + + return 0; +error: + /* remove any maps that we added */ + for_each_possible_cpu(cpu) { + for (i = num_tc, tci = cpu * num_tc; i--; tci++) { + new_map = xmap_dereference(new_dev_maps->cpu_map[tci]); + map = dev_maps ? + xmap_dereference(dev_maps->cpu_map[tci]) : + NULL; + if (new_map && new_map != map) + kfree(new_map); + } + } + + mutex_unlock(&xps_map_mutex); + + kfree(new_dev_maps); + return -ENOMEM; +} +",0,"int netif_set_xps_queue(struct net_device *dev, const struct cpumask *mask, + u16 index) +{ + struct xps_dev_maps *dev_maps, *new_dev_maps = NULL; + int i, cpu, tci, numa_node_id = -2; + int maps_sz, num_tc = 1, tc = 0; + struct xps_map *map, *new_map; + bool active = false; + + if (dev->num_tc) { + num_tc = dev->num_tc; + tc = netdev_txq_to_tc(dev, index); + if (tc < 0) + return -EINVAL; + } + + maps_sz = XPS_DEV_MAPS_SIZE(num_tc); + if (maps_sz < L1_CACHE_BYTES) + maps_sz = L1_CACHE_BYTES; + + mutex_lock(&xps_map_mutex); + + dev_maps = xmap_dereference(dev->xps_maps); + + /* allocate memory for queue storage */ + for_each_cpu_and(cpu, cpu_online_mask, mask) { + if (!new_dev_maps) + new_dev_maps = kzalloc(maps_sz, GFP_KERNEL); + if (!new_dev_maps) { + mutex_unlock(&xps_map_mutex); + return -ENOMEM; + } + + tci = cpu * num_tc + tc; + map = dev_maps ? xmap_dereference(dev_maps->cpu_map[tci]) : + NULL; + + map = expand_xps_map(map, cpu, index); + if (!map) + goto error; + + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + + if (!new_dev_maps) + goto out_no_new_maps; + + for_each_possible_cpu(cpu) { + /* copy maps belonging to foreign traffic classes */ + for (i = tc, tci = cpu * num_tc; dev_maps && i--; tci++) { + /* fill in the new device map from the old device map */ + map = xmap_dereference(dev_maps->cpu_map[tci]); + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + + /* We need to explicitly update tci as prevous loop + * could break out early if dev_maps is NULL. + */ + tci = cpu * num_tc + tc; + + if (cpumask_test_cpu(cpu, mask) && cpu_online(cpu)) { + /* add queue to CPU maps */ + int pos = 0; + + map = xmap_dereference(new_dev_maps->cpu_map[tci]); + while ((pos < map->len) && (map->queues[pos] != index)) + pos++; + + if (pos == map->len) + map->queues[map->len++] = index; +#ifdef CONFIG_NUMA + if (numa_node_id == -2) + numa_node_id = cpu_to_node(cpu); + else if (numa_node_id != cpu_to_node(cpu)) + numa_node_id = -1; +#endif + } else if (dev_maps) { + /* fill in the new device map from the old device map */ + map = xmap_dereference(dev_maps->cpu_map[tci]); + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + + /* copy maps belonging to foreign traffic classes */ + for (i = num_tc - tc, tci++; dev_maps && --i; tci++) { + /* fill in the new device map from the old device map */ + map = xmap_dereference(dev_maps->cpu_map[tci]); + RCU_INIT_POINTER(new_dev_maps->cpu_map[tci], map); + } + } + + rcu_assign_pointer(dev->xps_maps, new_dev_maps); + + /* Cleanup old maps */ + if (!dev_maps) + goto out_no_old_maps; + + for_each_possible_cpu(cpu) { + for (i = num_tc, tci = cpu * num_tc; i--; tci++) { + new_map = xmap_dereference(new_dev_maps->cpu_map[tci]); + map = xmap_dereference(dev_maps->cpu_map[tci]); + if (map && map != new_map) + kfree_rcu(map, rcu); + } + } + + kfree_rcu(dev_maps, rcu); + +out_no_old_maps: + dev_maps = new_dev_maps; + active = true; + +out_no_new_maps: + /* update Tx queue numa node */ + netdev_queue_numa_node_write(netdev_get_tx_queue(dev, index), + (numa_node_id >= 0) ? numa_node_id : + NUMA_NO_NODE); + + if (!dev_maps) + goto out_no_maps; + + /* removes queue from unused CPUs */ + for_each_possible_cpu(cpu) { + for (i = tc, tci = cpu * num_tc; i--; tci++) + active |= remove_xps_queue(dev_maps, tci, index); + if (!cpumask_test_cpu(cpu, mask) || !cpu_online(cpu)) + active |= remove_xps_queue(dev_maps, tci, index); + for (i = num_tc - tc, tci++; --i; tci++) + active |= remove_xps_queue(dev_maps, tci, index); + } + + /* free map if not active */ + if (!active) { + RCU_INIT_POINTER(dev->xps_maps, NULL); + kfree_rcu(dev_maps, rcu); + } + +out_no_maps: + mutex_unlock(&xps_map_mutex); + + return 0; +error: + /* remove any maps that we added */ + for_each_possible_cpu(cpu) { + for (i = num_tc, tci = cpu * num_tc; i--; tci++) { + new_map = xmap_dereference(new_dev_maps->cpu_map[tci]); + map = dev_maps ? + xmap_dereference(dev_maps->cpu_map[tci]) : + NULL; + if (new_map && new_map != map) + kfree(new_map); + } + } + + mutex_unlock(&xps_map_mutex); + + kfree(new_dev_maps); + return -ENOMEM; +} +","@@ -1147,9 +1147,8 @@ static int dev_alloc_name_ns(struct net *net, + return ret; + } + +-static int dev_get_valid_name(struct net *net, +- struct net_device *dev, +- const char *name) ++int dev_get_valid_name(struct net *net, struct net_device *dev, ++ const char *name) + { + BUG_ON(!net); + +@@ -1165,6 +1164,7 @@ static int dev_get_valid_name(struct net *net, + + return 0; + } ++EXPORT_SYMBOL(dev_get_valid_name); + + /** + * dev_change_name - change name of a device",1272,1508,2048 +135,"void Splash::strokeNarrow(SplashPath *path) { + SplashPipe pipe; + SplashXPath *xPath; + SplashXPathSeg *seg; + int x0, x1, x2, x3, y0, y1, x, y, t; + SplashCoord dx, dy, dxdy; + SplashClipResult clipRes; + int nClipRes[3]; + int i; + + nClipRes[0] = nClipRes[1] = nClipRes[2] = 0; + + xPath = new SplashXPath(path, state->matrix, state->flatness, gFalse); + + pipeInit(&pipe, 0, 0, state->strokePattern, NULL, state->strokeAlpha, + gFalse, gFalse); + + for (i = 0, seg = xPath->segs; i < xPath->length; ++i, ++seg) { + + x0 = splashFloor(seg->x0); + x1 = splashFloor(seg->x1); + y0 = splashFloor(seg->y0); + y1 = splashFloor(seg->y1); + + if (y0 == y1) { + if (x0 > x1) { + t = x0; x0 = x1; x1 = t; + } + if ((clipRes = state->clip->testSpan(x0, x1, y0)) + != splashClipAllOutside) { + drawSpan(&pipe, x0, x1, y0, clipRes == splashClipAllInside); + } + + } else if (splashAbs(seg->dxdy) > 1) { + dx = seg->x1 - seg->x0; + dy = seg->y1 - seg->y0; + dxdy = seg->dxdy; + if (y0 > y1) { + t = y0; y0 = y1; y1 = t; + t = x0; x0 = x1; x1 = t; + dx = -dx; + dy = -dy; + } + if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0, + x0 <= x1 ? x1 : x0, y1)) + != splashClipAllOutside) { + if (dx > 0) { + x2 = x0; + x3 = splashFloor(seg->x0 + ((SplashCoord)y0 + 1 - seg->y0) * dxdy); + drawSpan(&pipe, x2, (x2 <= x3 - 1) ? x3 - 1 : x2, y0, + clipRes == splashClipAllInside); + x2 = x3; + for (y = y0 + 1; y <= y1 - 1; ++y) { + x3 = splashFloor(seg->x0 + ((SplashCoord)y + 1 - seg->y0) * dxdy); + drawSpan(&pipe, x2, x3 - 1, y, clipRes == splashClipAllInside); + x2 = x3; + } + drawSpan(&pipe, x2, x2 <= x1 ? x1 : x2, y1, + clipRes == splashClipAllInside); + } else { + x2 = x0; + x3 = splashFloor(seg->x0 + ((SplashCoord)y0 + 1 - seg->y0) * dxdy); + drawSpan(&pipe, (x3 + 1 <= x2) ? x3 + 1 : x2, x2, y0, + clipRes == splashClipAllInside); + x2 = x3; + for (y = y0 + 1; y <= y1 - 1; ++y) { + x3 = splashFloor(seg->x0 + ((SplashCoord)y + 1 - seg->y0) * dxdy); + drawSpan(&pipe, x3 + 1, x2, y, clipRes == splashClipAllInside); + x2 = x3; + } + drawSpan(&pipe, x1, (x1 <= x2) ? x2 : x1, y1, + clipRes == splashClipAllInside); + } + } + + } else { + dxdy = seg->dxdy; + if (y0 > y1) { + t = x0; x0 = x1; x1 = t; + t = y0; y0 = y1; y1 = t; + } + if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0, + x0 <= x1 ? x1 : x0, y1)) + != splashClipAllOutside) { + drawPixel(&pipe, x0, y0, clipRes == splashClipAllInside); + for (y = y0 + 1; y <= y1 - 1; ++y) { + x = splashFloor(seg->x0 + ((SplashCoord)y - seg->y0) * dxdy); + drawPixel(&pipe, x, y, clipRes == splashClipAllInside); + } + drawPixel(&pipe, x1, y1, clipRes == splashClipAllInside); + } + } + ++nClipRes[clipRes]; + } + if (nClipRes[splashClipPartial] || + (nClipRes[splashClipAllInside] && nClipRes[splashClipAllOutside])) { + opClipRes = splashClipPartial; + } else if (nClipRes[splashClipAllInside]) { + opClipRes = splashClipAllInside; + } else { + opClipRes = splashClipAllOutside; + } + + delete xPath; +} +",0,"void Splash::strokeNarrow(SplashPath *path) { + SplashPipe pipe; + SplashXPath *xPath; + SplashXPathSeg *seg; + int x0, x1, x2, x3, y0, y1, x, y, t; + SplashCoord dx, dy, dxdy; + SplashClipResult clipRes; + int nClipRes[3]; + int i; + + nClipRes[0] = nClipRes[1] = nClipRes[2] = 0; + + xPath = new SplashXPath(path, state->matrix, state->flatness, gFalse); + + pipeInit(&pipe, 0, 0, state->strokePattern, NULL, state->strokeAlpha, + gFalse, gFalse); + + for (i = 0, seg = xPath->segs; i < xPath->length; ++i, ++seg) { + + x0 = splashFloor(seg->x0); + x1 = splashFloor(seg->x1); + y0 = splashFloor(seg->y0); + y1 = splashFloor(seg->y1); + + if (y0 == y1) { + if (x0 > x1) { + t = x0; x0 = x1; x1 = t; + } + if ((clipRes = state->clip->testSpan(x0, x1, y0)) + != splashClipAllOutside) { + drawSpan(&pipe, x0, x1, y0, clipRes == splashClipAllInside); + } + + } else if (splashAbs(seg->dxdy) > 1) { + dx = seg->x1 - seg->x0; + dy = seg->y1 - seg->y0; + dxdy = seg->dxdy; + if (y0 > y1) { + t = y0; y0 = y1; y1 = t; + t = x0; x0 = x1; x1 = t; + dx = -dx; + dy = -dy; + } + if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0, + x0 <= x1 ? x1 : x0, y1)) + != splashClipAllOutside) { + if (dx > 0) { + x2 = x0; + x3 = splashFloor(seg->x0 + ((SplashCoord)y0 + 1 - seg->y0) * dxdy); + drawSpan(&pipe, x2, (x2 <= x3 - 1) ? x3 - 1 : x2, y0, + clipRes == splashClipAllInside); + x2 = x3; + for (y = y0 + 1; y <= y1 - 1; ++y) { + x3 = splashFloor(seg->x0 + ((SplashCoord)y + 1 - seg->y0) * dxdy); + drawSpan(&pipe, x2, x3 - 1, y, clipRes == splashClipAllInside); + x2 = x3; + } + drawSpan(&pipe, x2, x2 <= x1 ? x1 : x2, y1, + clipRes == splashClipAllInside); + } else { + x2 = x0; + x3 = splashFloor(seg->x0 + ((SplashCoord)y0 + 1 - seg->y0) * dxdy); + drawSpan(&pipe, (x3 + 1 <= x2) ? x3 + 1 : x2, x2, y0, + clipRes == splashClipAllInside); + x2 = x3; + for (y = y0 + 1; y <= y1 - 1; ++y) { + x3 = splashFloor(seg->x0 + ((SplashCoord)y + 1 - seg->y0) * dxdy); + drawSpan(&pipe, x3 + 1, x2, y, clipRes == splashClipAllInside); + x2 = x3; + } + drawSpan(&pipe, x1, (x1 <= x2) ? x2 : x1, y1, + clipRes == splashClipAllInside); + } + } + + } else { + dxdy = seg->dxdy; + if (y0 > y1) { + t = x0; x0 = x1; x1 = t; + t = y0; y0 = y1; y1 = t; + } + if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0, + x0 <= x1 ? x1 : x0, y1)) + != splashClipAllOutside) { + drawPixel(&pipe, x0, y0, clipRes == splashClipAllInside); + for (y = y0 + 1; y <= y1 - 1; ++y) { + x = splashFloor(seg->x0 + ((SplashCoord)y - seg->y0) * dxdy); + drawPixel(&pipe, x, y, clipRes == splashClipAllInside); + } + drawPixel(&pipe, x1, y1, clipRes == splashClipAllInside); + } + } + ++nClipRes[clipRes]; + } + if (nClipRes[splashClipPartial] || + (nClipRes[splashClipAllInside] && nClipRes[splashClipAllOutside])) { + opClipRes = splashClipPartial; + } else if (nClipRes[splashClipAllInside]) { + opClipRes = splashClipAllInside; + } else { + opClipRes = splashClipAllOutside; + } + + delete xPath; +} +","@@ -11,7 +11,7 @@ + // All changes made under the Poppler project to this file are licensed + // under GPL version 2 or later + // +-// Copyright (C) 2005-2008 Albert Astals Cid ++// Copyright (C) 2005-2009 Albert Astals Cid + // Copyright (C) 2005 Marco Pesenti Gritti + // + // To see a description of the changes please see the Changelog file that +@@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, + xq = w % scaledWidth; + + // allocate pixel buffer +- pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); ++ pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); + + // initialize the pixel pipe + pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, +@@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, + xq = w % scaledWidth; + + // allocate pixel buffers +- colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); ++ colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); + if (srcAlpha) { +- alphaBuf = (Guchar *)gmalloc((yp + 1) * w); ++ alphaBuf = (Guchar *)gmallocn((yp + 1), w); + } else { + alphaBuf = NULL; + }",1237,1473,2048 +1959,"static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win, + u32 ts, struct tcp_md5sig_key *key, int rst) +{ + struct tcphdr *th = tcp_hdr(skb), *t1; + struct sk_buff *buff; + struct flowi6 fl6; + struct net *net = dev_net(skb_dst(skb)->dev); + struct sock *ctl_sk = net->ipv6.tcp_sk; + unsigned int tot_len = sizeof(struct tcphdr); + struct dst_entry *dst; + __be32 *topt; + + if (ts) + tot_len += TCPOLEN_TSTAMP_ALIGNED; +#ifdef CONFIG_TCP_MD5SIG + if (key) + tot_len += TCPOLEN_MD5SIG_ALIGNED; +#endif + + buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len, + GFP_ATOMIC); + if (buff == NULL) + return; + + skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len); + + t1 = (struct tcphdr *) skb_push(buff, tot_len); + skb_reset_transport_header(buff); + + /* Swap the send and the receive. */ + memset(t1, 0, sizeof(*t1)); + t1->dest = th->source; + t1->source = th->dest; + t1->doff = tot_len / 4; + t1->seq = htonl(seq); + t1->ack_seq = htonl(ack); + t1->ack = !rst || !th->ack; + t1->rst = rst; + t1->window = htons(win); + + topt = (__be32 *)(t1 + 1); + + if (ts) { + *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); + *topt++ = htonl(tcp_time_stamp); + *topt++ = htonl(ts); + } + +#ifdef CONFIG_TCP_MD5SIG + if (key) { + *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); + tcp_v6_md5_hash_hdr((__u8 *)topt, key, + &ipv6_hdr(skb)->saddr, + &ipv6_hdr(skb)->daddr, t1); + } +#endif + + memset(&fl6, 0, sizeof(fl6)); + ipv6_addr_copy(&fl6.daddr, &ipv6_hdr(skb)->saddr); + ipv6_addr_copy(&fl6.saddr, &ipv6_hdr(skb)->daddr); + + buff->ip_summed = CHECKSUM_PARTIAL; + buff->csum = 0; + + __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr); + + fl6.flowi6_proto = IPPROTO_TCP; + fl6.flowi6_oif = inet6_iif(skb); + fl6.fl6_dport = t1->dest; + fl6.fl6_sport = t1->source; + security_skb_classify_flow(skb, flowi6_to_flowi(&fl6)); + + /* Pass a socket to ip6_dst_lookup either it is for RST + * Underlying function will use this to retrieve the network + * namespace + */ + dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false); + if (!IS_ERR(dst)) { + skb_dst_set(buff, dst); + ip6_xmit(ctl_sk, buff, &fl6, NULL); + TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); + if (rst) + TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); + return; + } + + kfree_skb(buff); +} +",0,"static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win, + u32 ts, struct tcp_md5sig_key *key, int rst) +{ + struct tcphdr *th = tcp_hdr(skb), *t1; + struct sk_buff *buff; + struct flowi6 fl6; + struct net *net = dev_net(skb_dst(skb)->dev); + struct sock *ctl_sk = net->ipv6.tcp_sk; + unsigned int tot_len = sizeof(struct tcphdr); + struct dst_entry *dst; + __be32 *topt; + + if (ts) + tot_len += TCPOLEN_TSTAMP_ALIGNED; +#ifdef CONFIG_TCP_MD5SIG + if (key) + tot_len += TCPOLEN_MD5SIG_ALIGNED; +#endif + + buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len, + GFP_ATOMIC); + if (buff == NULL) + return; + + skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len); + + t1 = (struct tcphdr *) skb_push(buff, tot_len); + skb_reset_transport_header(buff); + + /* Swap the send and the receive. */ + memset(t1, 0, sizeof(*t1)); + t1->dest = th->source; + t1->source = th->dest; + t1->doff = tot_len / 4; + t1->seq = htonl(seq); + t1->ack_seq = htonl(ack); + t1->ack = !rst || !th->ack; + t1->rst = rst; + t1->window = htons(win); + + topt = (__be32 *)(t1 + 1); + + if (ts) { + *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); + *topt++ = htonl(tcp_time_stamp); + *topt++ = htonl(ts); + } + +#ifdef CONFIG_TCP_MD5SIG + if (key) { + *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); + tcp_v6_md5_hash_hdr((__u8 *)topt, key, + &ipv6_hdr(skb)->saddr, + &ipv6_hdr(skb)->daddr, t1); + } +#endif + + memset(&fl6, 0, sizeof(fl6)); + ipv6_addr_copy(&fl6.daddr, &ipv6_hdr(skb)->saddr); + ipv6_addr_copy(&fl6.saddr, &ipv6_hdr(skb)->daddr); + + buff->ip_summed = CHECKSUM_PARTIAL; + buff->csum = 0; + + __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr); + + fl6.flowi6_proto = IPPROTO_TCP; + fl6.flowi6_oif = inet6_iif(skb); + fl6.fl6_dport = t1->dest; + fl6.fl6_sport = t1->source; + security_skb_classify_flow(skb, flowi6_to_flowi(&fl6)); + + /* Pass a socket to ip6_dst_lookup either it is for RST + * Underlying function will use this to retrieve the network + * namespace + */ + dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false); + if (!IS_ERR(dst)) { + skb_dst_set(buff, dst); + ip6_xmit(ctl_sk, buff, &fl6, NULL); + TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); + if (rst) + TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); + return; + } + + kfree_skb(buff); +} +","@@ -1469,7 +1469,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, + + First: no IPv4 options. + */ +- newinet->opt = NULL; ++ newinet->inet_opt = NULL; + newnp->ipv6_fl_list = NULL; + + /* Clone RX bits */",836,1072,2048 +7907,"static int nntp_msg_open(struct Context *ctx, struct Message *msg, int msgno) +{ + struct NntpData *nntp_data = ctx->data; + struct Header *hdr = ctx->hdrs[msgno]; + char article[16]; + + /* try to get article from cache */ + struct NntpAcache *acache = &nntp_data->acache[hdr->index % NNTP_ACACHE_LEN]; + if (acache->path) + { + if (acache->index == hdr->index) + { + msg->fp = mutt_file_fopen(acache->path, ""r""); + if (msg->fp) + return 0; + } + /* clear previous entry */ + else + { + unlink(acache->path); + FREE(&acache->path); + } + } + snprintf(article, sizeof(article), ""%d"", NHDR(hdr)->article_num); + msg->fp = mutt_bcache_get(nntp_data->bcache, article); + if (msg->fp) + { + if (NHDR(hdr)->parsed) + return 0; + } + else + { + char buf[PATH_MAX]; + /* don't try to fetch article from removed newsgroup */ + if (nntp_data->deleted) + return -1; + + /* create new cache file */ + const char *fetch_msg = _(""Fetching message...""); + mutt_message(fetch_msg); + msg->fp = mutt_bcache_put(nntp_data->bcache, article); + if (!msg->fp) + { + mutt_mktemp(buf, sizeof(buf)); + acache->path = mutt_str_strdup(buf); + acache->index = hdr->index; + msg->fp = mutt_file_fopen(acache->path, ""w+""); + if (!msg->fp) + { + mutt_perror(acache->path); + unlink(acache->path); + FREE(&acache->path); + return -1; + } + } + + /* fetch message to cache file */ + snprintf(buf, sizeof(buf), ""ARTICLE %s\r\n"", + NHDR(hdr)->article_num ? article : hdr->env->message_id); + const int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), fetch_msg, + fetch_tempfile, msg->fp); + if (rc) + { + mutt_file_fclose(&msg->fp); + if (acache->path) + { + unlink(acache->path); + FREE(&acache->path); + } + if (rc > 0) + { + if (mutt_str_strncmp(NHDR(hdr)->article_num ? ""423"" : ""430"", buf, 3) == 0) + { + mutt_error(_(""Article %d not found on the server.""), + NHDR(hdr)->article_num ? article : hdr->env->message_id); + } + else + mutt_error(""ARTICLE: %s"", buf); + } + return -1; + } + + if (!acache->path) + mutt_bcache_commit(nntp_data->bcache, article); + } + + /* replace envelope with new one + * hash elements must be updated because pointers will be changed */ + if (ctx->id_hash && hdr->env->message_id) + mutt_hash_delete(ctx->id_hash, hdr->env->message_id, hdr); + if (ctx->subj_hash && hdr->env->real_subj) + mutt_hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr); + + mutt_env_free(&hdr->env); + hdr->env = mutt_rfc822_read_header(msg->fp, hdr, 0, 0); + + if (ctx->id_hash && hdr->env->message_id) + mutt_hash_insert(ctx->id_hash, hdr->env->message_id, hdr); + if (ctx->subj_hash && hdr->env->real_subj) + mutt_hash_insert(ctx->subj_hash, hdr->env->real_subj, hdr); + + /* fix content length */ + fseek(msg->fp, 0, SEEK_END); + hdr->content->length = ftell(msg->fp) - hdr->content->offset; + + /* this is called in neomutt before the open which fetches the message, + * which is probably wrong, but we just call it again here to handle + * the problem instead of fixing it */ + NHDR(hdr)->parsed = true; + mutt_parse_mime_message(ctx, hdr); + + /* these would normally be updated in mx_update_context(), but the + * full headers aren't parsed with overview, so the information wasn't + * available then */ + if (WithCrypto) + hdr->security = crypt_query(hdr->content); + + rewind(msg->fp); + mutt_clear_error(); + return 0; +} +",0,"static int nntp_msg_open(struct Context *ctx, struct Message *msg, int msgno) +{ + struct NntpData *nntp_data = ctx->data; + struct Header *hdr = ctx->hdrs[msgno]; + char article[16]; + + /* try to get article from cache */ + struct NntpAcache *acache = &nntp_data->acache[hdr->index % NNTP_ACACHE_LEN]; + if (acache->path) + { + if (acache->index == hdr->index) + { + msg->fp = mutt_file_fopen(acache->path, ""r""); + if (msg->fp) + return 0; + } + /* clear previous entry */ + else + { + unlink(acache->path); + FREE(&acache->path); + } + } + snprintf(article, sizeof(article), ""%d"", NHDR(hdr)->article_num); + msg->fp = mutt_bcache_get(nntp_data->bcache, article); + if (msg->fp) + { + if (NHDR(hdr)->parsed) + return 0; + } + else + { + char buf[PATH_MAX]; + /* don't try to fetch article from removed newsgroup */ + if (nntp_data->deleted) + return -1; + + /* create new cache file */ + const char *fetch_msg = _(""Fetching message...""); + mutt_message(fetch_msg); + msg->fp = mutt_bcache_put(nntp_data->bcache, article); + if (!msg->fp) + { + mutt_mktemp(buf, sizeof(buf)); + acache->path = mutt_str_strdup(buf); + acache->index = hdr->index; + msg->fp = mutt_file_fopen(acache->path, ""w+""); + if (!msg->fp) + { + mutt_perror(acache->path); + unlink(acache->path); + FREE(&acache->path); + return -1; + } + } + + /* fetch message to cache file */ + snprintf(buf, sizeof(buf), ""ARTICLE %s\r\n"", + NHDR(hdr)->article_num ? article : hdr->env->message_id); + const int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), fetch_msg, + fetch_tempfile, msg->fp); + if (rc) + { + mutt_file_fclose(&msg->fp); + if (acache->path) + { + unlink(acache->path); + FREE(&acache->path); + } + if (rc > 0) + { + if (mutt_str_strncmp(NHDR(hdr)->article_num ? ""423"" : ""430"", buf, 3) == 0) + { + mutt_error(_(""Article %d not found on the server.""), + NHDR(hdr)->article_num ? article : hdr->env->message_id); + } + else + mutt_error(""ARTICLE: %s"", buf); + } + return -1; + } + + if (!acache->path) + mutt_bcache_commit(nntp_data->bcache, article); + } + + /* replace envelope with new one + * hash elements must be updated because pointers will be changed */ + if (ctx->id_hash && hdr->env->message_id) + mutt_hash_delete(ctx->id_hash, hdr->env->message_id, hdr); + if (ctx->subj_hash && hdr->env->real_subj) + mutt_hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr); + + mutt_env_free(&hdr->env); + hdr->env = mutt_rfc822_read_header(msg->fp, hdr, 0, 0); + + if (ctx->id_hash && hdr->env->message_id) + mutt_hash_insert(ctx->id_hash, hdr->env->message_id, hdr); + if (ctx->subj_hash && hdr->env->real_subj) + mutt_hash_insert(ctx->subj_hash, hdr->env->real_subj, hdr); + + /* fix content length */ + fseek(msg->fp, 0, SEEK_END); + hdr->content->length = ftell(msg->fp) - hdr->content->offset; + + /* this is called in neomutt before the open which fetches the message, + * which is probably wrong, but we just call it again here to handle + * the problem instead of fixing it */ + NHDR(hdr)->parsed = true; + mutt_parse_mime_message(ctx, hdr); + + /* these would normally be updated in mx_update_context(), but the + * full headers aren't parsed with overview, so the information wasn't + * available then */ + if (WithCrypto) + hdr->security = crypt_query(hdr->content); + + rewind(msg->fp); + mutt_clear_error(); + return 0; +} +","@@ -1288,6 +1288,8 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, + fc.last = last; + fc.restore = restore; + fc.messages = mutt_mem_calloc(last - first + 1, sizeof(unsigned char)); ++ if (fc.messages == NULL) ++ return -1; + #ifdef USE_HCACHE + fc.hc = hc; + #endif",1039,1275,2048 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.pkl new file mode 100644 index 0000000000000000000000000000000000000000..b5b045295ecf4327932e06eb0c3df1a73c852051 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8146cbc2bb420ab8fdac26cc70b95b79672aa7272154d348fe9dfade400fce69 +size 5024973 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.csv new file mode 100644 index 0000000000000000000000000000000000000000..674876acf6fb959234eacc7a55f7488b2da2c252 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.csv @@ -0,0 +1,5547 @@ +idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting +7306,"static MagickBooleanType SetsRGBImageProfile(Image *image, + ExceptionInfo *exception) +{ + static unsigned char + sRGBProfile[] = + { + 0x00, 0x00, 0x0c, 0x8c, 0x61, 0x72, 0x67, 0x6c, 0x02, 0x20, 0x00, 0x00, + 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, + 0x07, 0xde, 0x00, 0x01, 0x00, 0x06, 0x00, 0x16, 0x00, 0x0f, 0x00, 0x3a, + 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x72, 0x67, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x99, + 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0xec, 0x00, 0x00, 0x00, 0x67, + 0x64, 0x6d, 0x6e, 0x64, 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00, 0x70, + 0x64, 0x6d, 0x64, 0x64, 0x00, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x00, 0x88, + 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x0c, + 0x76, 0x75, 0x65, 0x64, 0x00, 0x00, 0x03, 0x58, 0x00, 0x00, 0x00, 0x67, + 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x24, + 0x6c, 0x75, 0x6d, 0x69, 0x00, 0x00, 0x03, 0xe4, 0x00, 0x00, 0x00, 0x14, + 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x24, + 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x04, 0x1c, 0x00, 0x00, 0x00, 0x14, + 0x62, 0x6b, 0x70, 0x74, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x00, 0x14, + 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x14, + 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x58, 0x00, 0x00, 0x00, 0x14, + 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x6c, 0x00, 0x00, 0x00, 0x14, + 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c, + 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c, + 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, + 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75, 0x69, 0x76, + 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, 0x77, 0x77, + 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x31, 0x39, + 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3f, 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, + 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75, + 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, + 0x77, 0x77, 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20, + 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x47, 0x72, 0x61, 0x65, 0x6d, + 0x65, 0x20, 0x57, 0x2e, 0x20, 0x47, 0x69, 0x6c, 0x6c, 0x2e, 0x20, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x20, 0x4e, 0x6f, 0x20, 0x57, + 0x61, 0x72, 0x72, 0x61, 0x6e, 0x74, 0x79, 0x2c, 0x20, 0x55, 0x73, 0x65, + 0x20, 0x61, 0x74, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, + 0x20, 0x72, 0x69, 0x73, 0x6b, 0x2e, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, + 0x65, 0x63, 0x2e, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, 0x68, 0x74, 0x74, + 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x65, 0x63, 0x2e, + 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, + 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, + 0x31, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, + 0x42, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x20, 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43, + 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x44, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x63, + 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, + 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x43, 0x52, 0x54, 0x20, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, + 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, + 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xa4, 0x7c, + 0x00, 0x14, 0x5f, 0x30, 0x00, 0x10, 0xce, 0x02, 0x00, 0x03, 0xed, 0xb2, + 0x00, 0x04, 0x13, 0x0a, 0x00, 0x03, 0x5c, 0x67, 0x00, 0x00, 0x00, 0x01, + 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x0a, 0x3d, + 0x00, 0x50, 0x00, 0x00, 0x00, 0x57, 0x1e, 0xb8, 0x6d, 0x65, 0x61, 0x73, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x8f, 0x00, 0x00, 0x00, 0x02, 0x58, 0x59, 0x5a, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa0, + 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x58, 0x59, 0x5a, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x97, 0x00, 0x00, 0xb7, 0x87, + 0x00, 0x00, 0x18, 0xd9, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x24, 0x9f, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xc4, + 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19, + 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37, + 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54, + 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72, + 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90, + 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae, + 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb, + 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb, + 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d, + 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32, + 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59, + 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83, + 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1, + 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1, + 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14, + 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b, + 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84, + 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1, + 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00, + 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43, + 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a, + 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3, + 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20, + 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71, + 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4, + 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c, + 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77, + 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5, + 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37, + 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d, + 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07, + 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74, + 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5, + 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a, + 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2, + 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f, + 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf, + 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54, + 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc, + 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69, + 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9, + 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e, + 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26, + 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3, + 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64, + 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09, + 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3, + 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61, + 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13, + 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9, + 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84, + 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43, + 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06, + 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce, + 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b, + 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c, + 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41, + 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b, + 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa, + 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd, + 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5, + 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2, + 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3, + 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99, + 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94, + 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94, + 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98, + 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1, + 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf, + 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2, + 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda, + 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7, + 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18, + 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f, + 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b, + 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b, + 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1, + 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c, + 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c, + 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91, + 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb, + 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a, + 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f, + 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8, + 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37, + 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c, + 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05, + 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74, + 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8, + 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61, + 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0, + 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64, + 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee, + 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d, + 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12, + 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab, + 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b, + 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0, + 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a, + 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a, + 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00, + 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb, + 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c, + 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42, + 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f, + 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0, + 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8, + 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95, + 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78, + 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61, + 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f, + 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43, + 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d, + 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d, + 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43, + 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f, + 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60, + 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78, + 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95, + 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8, + 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1, + 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11, + 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46, + 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81, + 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2, + 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a, + 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57, + 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab, + 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04, + 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64, + 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca, + 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36, + 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8, + 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20, + 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f, + 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24, + 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf, + 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40, + 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8, + 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76, + 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a, + 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4, + 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75, + 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d, + 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea, + 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae, + 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79, + 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a, + 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21, + 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff, + 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3, + 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce, + 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf, + 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7, + 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5, + 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba, + 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6, + 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8, + 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1, + 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10, + 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36, + 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63, + 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96, + 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0, + 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11, + 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58, + 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7, + 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb, + 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57, + 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba, + 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff + }; + + StringInfo + *profile; + + MagickBooleanType + status; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (GetImageProfile(image,""icc"") != (const StringInfo *) NULL) + return(MagickFalse); + profile=AcquireStringInfo(sizeof(sRGBProfile)); + SetStringInfoDatum(profile,sRGBProfile); + status=SetImageProfile(image,""icc"",profile,exception); + profile=DestroyStringInfo(profile); + return(status); +} +",0,"static MagickBooleanType SetsRGBImageProfile(Image *image, + ExceptionInfo *exception) +{ + static unsigned char + sRGBProfile[] = + { + 0x00, 0x00, 0x0c, 0x8c, 0x61, 0x72, 0x67, 0x6c, 0x02, 0x20, 0x00, 0x00, + 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, + 0x07, 0xde, 0x00, 0x01, 0x00, 0x06, 0x00, 0x16, 0x00, 0x0f, 0x00, 0x3a, + 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x72, 0x67, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x99, + 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0xec, 0x00, 0x00, 0x00, 0x67, + 0x64, 0x6d, 0x6e, 0x64, 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00, 0x70, + 0x64, 0x6d, 0x64, 0x64, 0x00, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x00, 0x88, + 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x0c, + 0x76, 0x75, 0x65, 0x64, 0x00, 0x00, 0x03, 0x58, 0x00, 0x00, 0x00, 0x67, + 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x24, + 0x6c, 0x75, 0x6d, 0x69, 0x00, 0x00, 0x03, 0xe4, 0x00, 0x00, 0x00, 0x14, + 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x24, + 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x04, 0x1c, 0x00, 0x00, 0x00, 0x14, + 0x62, 0x6b, 0x70, 0x74, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x00, 0x14, + 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x14, + 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x58, 0x00, 0x00, 0x00, 0x14, + 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x6c, 0x00, 0x00, 0x00, 0x14, + 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c, + 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c, + 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, + 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75, 0x69, 0x76, + 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, 0x77, 0x77, + 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x31, 0x39, + 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3f, 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, + 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75, + 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, + 0x77, 0x77, 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20, + 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x47, 0x72, 0x61, 0x65, 0x6d, + 0x65, 0x20, 0x57, 0x2e, 0x20, 0x47, 0x69, 0x6c, 0x6c, 0x2e, 0x20, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x20, 0x4e, 0x6f, 0x20, 0x57, + 0x61, 0x72, 0x72, 0x61, 0x6e, 0x74, 0x79, 0x2c, 0x20, 0x55, 0x73, 0x65, + 0x20, 0x61, 0x74, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, + 0x20, 0x72, 0x69, 0x73, 0x6b, 0x2e, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, + 0x65, 0x63, 0x2e, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, 0x68, 0x74, 0x74, + 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x65, 0x63, 0x2e, + 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, + 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, + 0x31, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, + 0x42, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x20, 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43, + 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x44, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x63, + 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, + 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x43, 0x52, 0x54, 0x20, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, + 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36, + 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xa4, 0x7c, + 0x00, 0x14, 0x5f, 0x30, 0x00, 0x10, 0xce, 0x02, 0x00, 0x03, 0xed, 0xb2, + 0x00, 0x04, 0x13, 0x0a, 0x00, 0x03, 0x5c, 0x67, 0x00, 0x00, 0x00, 0x01, + 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x0a, 0x3d, + 0x00, 0x50, 0x00, 0x00, 0x00, 0x57, 0x1e, 0xb8, 0x6d, 0x65, 0x61, 0x73, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x8f, 0x00, 0x00, 0x00, 0x02, 0x58, 0x59, 0x5a, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa0, + 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x58, 0x59, 0x5a, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x97, 0x00, 0x00, 0xb7, 0x87, + 0x00, 0x00, 0x18, 0xd9, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x24, 0x9f, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xc4, + 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19, + 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37, + 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54, + 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72, + 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90, + 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae, + 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb, + 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb, + 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d, + 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32, + 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59, + 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83, + 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1, + 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1, + 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14, + 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b, + 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84, + 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1, + 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00, + 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43, + 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a, + 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3, + 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20, + 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71, + 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4, + 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c, + 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77, + 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5, + 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37, + 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d, + 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07, + 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74, + 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5, + 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a, + 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2, + 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f, + 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf, + 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54, + 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc, + 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69, + 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9, + 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e, + 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26, + 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3, + 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64, + 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09, + 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3, + 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61, + 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13, + 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9, + 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84, + 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43, + 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06, + 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce, + 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b, + 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c, + 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41, + 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b, + 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa, + 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd, + 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5, + 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2, + 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3, + 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99, + 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94, + 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94, + 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98, + 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1, + 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf, + 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2, + 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda, + 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7, + 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18, + 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f, + 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b, + 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b, + 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1, + 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c, + 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c, + 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91, + 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb, + 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a, + 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f, + 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8, + 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37, + 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c, + 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05, + 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74, + 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8, + 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61, + 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0, + 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64, + 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee, + 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d, + 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12, + 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab, + 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b, + 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0, + 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a, + 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a, + 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00, + 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb, + 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c, + 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42, + 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f, + 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0, + 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8, + 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95, + 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78, + 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61, + 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f, + 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43, + 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d, + 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d, + 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43, + 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f, + 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60, + 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78, + 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95, + 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8, + 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1, + 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11, + 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46, + 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81, + 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2, + 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a, + 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57, + 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab, + 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04, + 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64, + 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca, + 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36, + 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8, + 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20, + 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f, + 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24, + 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf, + 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40, + 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8, + 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76, + 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a, + 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4, + 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75, + 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d, + 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea, + 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae, + 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79, + 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a, + 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21, + 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff, + 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3, + 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce, + 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf, + 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7, + 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5, + 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba, + 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6, + 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8, + 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1, + 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10, + 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36, + 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63, + 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96, + 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0, + 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11, + 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58, + 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7, + 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb, + 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57, + 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba, + 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff + }; + + StringInfo + *profile; + + MagickBooleanType + status; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (GetImageProfile(image,""icc"") != (const StringInfo *) NULL) + return(MagickFalse); + profile=AcquireStringInfo(sizeof(sRGBProfile)); + SetStringInfoDatum(profile,sRGBProfile); + status=SetImageProfile(image,""icc"",profile,exception); + profile=DestroyStringInfo(profile); + return(status); +} +","@@ -2032,7 +2032,7 @@ MagickBooleanType SyncExifProfile(Image *image,StringInfo *profile) + break; /* corrupt EXIF */ + tag_value=(ssize_t) ReadProfileShort(endian,q); + format=(ssize_t) ReadProfileShort(endian,q+2); +- if ((format-1) >= EXIF_NUM_FORMATS) ++ if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS)) + break; + components=(ssize_t) ReadProfileLong(endian,q+4); + if (components < 0)",18883,19119,28000 +18302,"rsvp_obj_print(netdissect_options *ndo, + const u_char *pptr, u_int plen, const u_char *tptr, + const char *ident, u_int tlen, + const struct rsvp_common_header *rsvp_com_header) +{ + const struct rsvp_object_header *rsvp_obj_header; + const u_char *obj_tptr; + union { + const struct rsvp_obj_integrity_t *rsvp_obj_integrity; + const struct rsvp_obj_frr_t *rsvp_obj_frr; + } obj_ptr; + + u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen; + int hexdump,processed,padbytes,error_code,error_value,i,sigcheck; + union { + float f; + uint32_t i; + } bw; + uint8_t namelen; + + u_int action, subchannel; + + while(tlen>=sizeof(struct rsvp_object_header)) { + /* did we capture enough for fully decoding the object header ? */ + ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header)); + + rsvp_obj_header = (const struct rsvp_object_header *)tptr; + rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length); + rsvp_obj_ctype=rsvp_obj_header->ctype; + + if(rsvp_obj_len % 4) { + ND_PRINT((ndo, ""%sERROR: object header size %u not a multiple of 4"", ident, rsvp_obj_len)); + return -1; + } + if(rsvp_obj_len < sizeof(struct rsvp_object_header)) { + ND_PRINT((ndo, ""%sERROR: object header too short %u < %lu"", ident, rsvp_obj_len, + (unsigned long)sizeof(const struct rsvp_object_header))); + return -1; + } + + ND_PRINT((ndo, ""%s%s Object (%u) Flags: [%s"", + ident, + tok2str(rsvp_obj_values, + ""Unknown"", + rsvp_obj_header->class_num), + rsvp_obj_header->class_num, + ((rsvp_obj_header->class_num) & 0x80) ? ""ignore"" : ""reject"")); + + if (rsvp_obj_header->class_num > 128) + ND_PRINT((ndo, "" %s"", + ((rsvp_obj_header->class_num) & 0x40) ? ""and forward"" : ""silently"")); + + ND_PRINT((ndo, "" if unknown], Class-Type: %s (%u), length: %u"", + tok2str(rsvp_ctype_values, + ""Unknown"", + ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype), + rsvp_obj_ctype, + rsvp_obj_len)); + + if(tlen < rsvp_obj_len) { + ND_PRINT((ndo, ""%sERROR: object goes past end of objects TLV"", ident)); + return -1; + } + + obj_tptr=tptr+sizeof(struct rsvp_object_header); + obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header); + + /* did we capture enough for fully decoding the object ? */ + if (!ND_TTEST2(*tptr, rsvp_obj_len)) + return -1; + hexdump=FALSE; + + switch(rsvp_obj_header->class_num) { + case RSVP_OBJ_SESSION: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return -1; + ND_PRINT((ndo, ""%s IPv4 DestAddress: %s, Protocol ID: 0x%02x"", + ident, + ipaddr_string(ndo, obj_tptr), + *(obj_tptr + sizeof(struct in_addr)))); + ND_PRINT((ndo, ""%s Flags: [0x%02x], DestPort %u"", + ident, + *(obj_tptr+5), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return -1; + ND_PRINT((ndo, ""%s IPv6 DestAddress: %s, Protocol ID: 0x%02x"", + ident, + ip6addr_string(ndo, obj_tptr), + *(obj_tptr + sizeof(struct in6_addr)))); + ND_PRINT((ndo, ""%s Flags: [0x%02x], DestPort %u"", + ident, + *(obj_tptr+sizeof(struct in6_addr)+1), + EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2))); + obj_tlen-=20; + obj_tptr+=20; + break; + + case RSVP_CTYPE_TUNNEL_IPV6: + if (obj_tlen < 36) + return -1; + ND_PRINT((ndo, ""%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ip6addr_string(ndo, obj_tptr + 20))); + obj_tlen-=36; + obj_tptr+=36; + break; + + case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */ + if (obj_tlen < 26) + return -1; + ND_PRINT((ndo, ""%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ip6addr_string(ndo, obj_tptr + 8))); + obj_tlen-=26; + obj_tptr+=26; + break; + case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */ + if (obj_tlen < 12) + return -1; + ND_PRINT((ndo, ""%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ipaddr_string(ndo, obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_TUNNEL_IPV4: + case RSVP_CTYPE_UNI_IPV4: + if (obj_tlen < 12) + return -1; + ND_PRINT((ndo, ""%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ipaddr_string(ndo, obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_CONFIRM: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < sizeof(struct in_addr)) + return -1; + ND_PRINT((ndo, ""%s IPv4 Receiver Address: %s"", + ident, + ipaddr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in_addr); + obj_tptr+=sizeof(struct in_addr); + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < sizeof(struct in6_addr)) + return -1; + ND_PRINT((ndo, ""%s IPv6 Receiver Address: %s"", + ident, + ip6addr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in6_addr); + obj_tptr+=sizeof(struct in6_addr); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_NOTIFY_REQ: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < sizeof(struct in_addr)) + return -1; + ND_PRINT((ndo, ""%s IPv4 Notify Node Address: %s"", + ident, + ipaddr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in_addr); + obj_tptr+=sizeof(struct in_addr); + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < sizeof(struct in6_addr)) + return-1; + ND_PRINT((ndo, ""%s IPv6 Notify Node Address: %s"", + ident, + ip6addr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in6_addr); + obj_tptr+=sizeof(struct in6_addr); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */ + case RSVP_OBJ_UPSTREAM_LABEL: /* fall through */ + case RSVP_OBJ_RECOVERY_LABEL: /* fall through */ + case RSVP_OBJ_LABEL: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + while(obj_tlen >= 4 ) { + ND_PRINT((ndo, ""%s Label: %u"", ident, EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + case RSVP_CTYPE_2: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Generalized Label: %u"", + ident, + EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 12) + return-1; + ND_PRINT((ndo, ""%s Waveband ID: %u%s Start Label: %u, Stop Label: %u"", + ident, + EXTRACT_32BITS(obj_tptr), + ident, + EXTRACT_32BITS(obj_tptr+4), + EXTRACT_32BITS(obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_STYLE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Reservation Style: %s, Flags: [0x%02x]"", + ident, + tok2str(rsvp_resstyle_values, + ""Unknown"", + EXTRACT_24BITS(obj_tptr+1)), + *(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SENDER_TEMPLATE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 18))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */ + if (obj_tlen < 40) + return-1; + ND_PRINT((ndo, ""%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ident, + ip6addr_string(ndo, obj_tptr+20), + EXTRACT_16BITS(obj_tptr + 38))); + obj_tlen-=40; + obj_tptr+=40; + break; + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */ + if (obj_tlen < 16) + return-1; + ND_PRINT((ndo, ""%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ident, + ipaddr_string(ndo, obj_tptr+8), + EXTRACT_16BITS(obj_tptr + 12))); + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_LABEL_REQ: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + while(obj_tlen >= 4 ) { + ND_PRINT((ndo, ""%s L3 Protocol ID: %s"", + ident, + tok2str(ethertype_values, + ""Unknown Protocol (0x%04x)"", + EXTRACT_16BITS(obj_tptr + 2)))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + case RSVP_CTYPE_2: + if (obj_tlen < 12) + return-1; + ND_PRINT((ndo, ""%s L3 Protocol ID: %s"", + ident, + tok2str(ethertype_values, + ""Unknown Protocol (0x%04x)"", + EXTRACT_16BITS(obj_tptr + 2)))); + ND_PRINT((ndo, "",%s merge capability"",((*(obj_tptr + 4)) & 0x80) ? ""no"" : """" )); + ND_PRINT((ndo, ""%s Minimum VPI/VCI: %u/%u"", + ident, + (EXTRACT_16BITS(obj_tptr+4))&0xfff, + (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff)); + ND_PRINT((ndo, ""%s Maximum VPI/VCI: %u/%u"", + ident, + (EXTRACT_16BITS(obj_tptr+8))&0xfff, + (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff)); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 12) + return-1; + ND_PRINT((ndo, ""%s L3 Protocol ID: %s"", + ident, + tok2str(ethertype_values, + ""Unknown Protocol (0x%04x)"", + EXTRACT_16BITS(obj_tptr + 2)))); + ND_PRINT((ndo, ""%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI"", + ident, + (EXTRACT_32BITS(obj_tptr+4))&0x7fffff, + (EXTRACT_32BITS(obj_tptr+8))&0x7fffff, + (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? ""10"" : """", + (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? ""23"" : """")); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_4: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s LSP Encoding Type: %s (%u)"", + ident, + tok2str(gmpls_encoding_values, + ""Unknown"", + *obj_tptr), + *obj_tptr)); + ND_PRINT((ndo, ""%s Switching Type: %s (%u), Payload ID: %s (0x%04x)"", + ident, + tok2str(gmpls_switch_cap_values, + ""Unknown"", + *(obj_tptr+1)), + *(obj_tptr+1), + tok2str(gmpls_payload_values, + ""Unknown"", + EXTRACT_16BITS(obj_tptr+2)), + EXTRACT_16BITS(obj_tptr + 2))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RRO: + case RSVP_OBJ_ERO: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + while(obj_tlen >= 4 ) { + u_char length; + + ND_TCHECK2(*obj_tptr, 4); + length = *(obj_tptr + 1); + ND_PRINT((ndo, ""%s Subobject Type: %s, length %u"", + ident, + tok2str(rsvp_obj_xro_values, + ""Unknown %u"", + RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)), + length)); + + if (length == 0) { /* prevent infinite loops */ + ND_PRINT((ndo, ""%s ERROR: zero length ERO subtype"", ident)); + break; + } + + switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) { + u_char prefix_length; + + case RSVP_OBJ_XRO_IPV4: + if (length != 8) { + ND_PRINT((ndo, "" ERROR: length != 8"")); + goto invalid; + } + ND_TCHECK2(*obj_tptr, 8); + prefix_length = *(obj_tptr+6); + if (prefix_length != 32) { + ND_PRINT((ndo, "" ERROR: Prefix length %u != 32"", + prefix_length)); + goto invalid; + } + ND_PRINT((ndo, "", %s, %s/%u, Flags: [%s]"", + RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? ""Loose"" : ""Strict"", + ipaddr_string(ndo, obj_tptr+2), + *(obj_tptr+6), + bittok2str(rsvp_obj_rro_flag_values, + ""none"", + *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */ + break; + case RSVP_OBJ_XRO_LABEL: + if (length != 8) { + ND_PRINT((ndo, "" ERROR: length != 8"")); + goto invalid; + } + ND_TCHECK2(*obj_tptr, 8); + ND_PRINT((ndo, "", Flags: [%s] (%#x), Class-Type: %s (%u), %u"", + bittok2str(rsvp_obj_rro_label_flag_values, + ""none"", + *(obj_tptr+2)), + *(obj_tptr+2), + tok2str(rsvp_ctype_values, + ""Unknown"", + *(obj_tptr+3) + 256*RSVP_OBJ_RRO), + *(obj_tptr+3), + EXTRACT_32BITS(obj_tptr + 4))); + } + obj_tlen-=*(obj_tptr+1); + obj_tptr+=*(obj_tptr+1); + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_HELLO: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + case RSVP_CTYPE_2: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Instance: 0x%08x, Destination Instance: 0x%08x"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RESTART_CAPABILITY: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Restart Time: %ums, Recovery Time: %ums"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SESSION_ATTRIBUTE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 4) + return-1; + namelen = *(obj_tptr+3); + if (obj_tlen < 4+namelen) + return-1; + ND_PRINT((ndo, ""%s Session Name: "", ident)); + for (i = 0; i < namelen; i++) + safeputchar(ndo, *(obj_tptr + 4 + i)); + ND_PRINT((ndo, ""%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)"", + ident, + (int)*obj_tptr, + (int)*(obj_tptr+1), + bittok2str(rsvp_session_attribute_flag_values, + ""none"", + *(obj_tptr+2)), + *(obj_tptr + 2))); + obj_tlen-=4+*(obj_tptr+3); + obj_tptr+=4+*(obj_tptr+3); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_GENERALIZED_UNI: + switch(rsvp_obj_ctype) { + int subobj_type,af,subobj_len,total_subobj_len; + + case RSVP_CTYPE_1: + + if (obj_tlen < 4) + return-1; + + /* read variable length subobjects */ + total_subobj_len = obj_tlen; + while(total_subobj_len > 0) { + /* If RFC 3476 Section 3.1 defined that a sub-object of the + * GENERALIZED_UNI RSVP object must have the Length field as + * a multiple of 4, instead of the check below it would be + * better to test total_subobj_len only once before the loop. + * So long as it does not define it and this while loop does + * not implement such a requirement, let's accept that within + * each iteration subobj_len may happen to be a multiple of 1 + * and test it and total_subobj_len respectively. + */ + if (total_subobj_len < 4) + goto invalid; + subobj_len = EXTRACT_16BITS(obj_tptr); + subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8; + af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF; + + ND_PRINT((ndo, ""%s Subobject Type: %s (%u), AF: %s (%u), length: %u"", + ident, + tok2str(rsvp_obj_generalized_uni_values, ""Unknown"", subobj_type), + subobj_type, + tok2str(af_values, ""Unknown"", af), af, + subobj_len)); + + /* In addition to what is explained above, the same spec does not + * explicitly say that the same Length field includes the 4-octet + * sub-object header, but as long as this while loop implements it + * as it does include, let's keep the check below consistent with + * the rest of the code. + */ + if(subobj_len < 4 || subobj_len > total_subobj_len) + goto invalid; + + switch(subobj_type) { + case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS: + case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS: + + switch(af) { + case AFNUM_INET: + if (subobj_len < 8) + return -1; + ND_PRINT((ndo, ""%s UNI IPv4 TNA address: %s"", + ident, ipaddr_string(ndo, obj_tptr + 4))); + break; + case AFNUM_INET6: + if (subobj_len < 20) + return -1; + ND_PRINT((ndo, ""%s UNI IPv6 TNA address: %s"", + ident, ip6addr_string(ndo, obj_tptr + 4))); + break; + case AFNUM_NSAP: + if (subobj_len) { + /* unless we have a TLV parser lets just hexdump */ + hexdump=TRUE; + } + break; + } + break; + + case RSVP_GEN_UNI_SUBOBJ_DIVERSITY: + if (subobj_len) { + /* unless we have a TLV parser lets just hexdump */ + hexdump=TRUE; + } + break; + + case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL: + if (subobj_len < 16) { + return -1; + } + + ND_PRINT((ndo, ""%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u"", + ident, + ((EXTRACT_32BITS(obj_tptr+4))>>31), + ((EXTRACT_32BITS(obj_tptr+4))&0xFF), + EXTRACT_32BITS(obj_tptr+8), + EXTRACT_32BITS(obj_tptr + 12))); + break; + + case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL: + if (subobj_len < 8) { + return -1; + } + + ND_PRINT((ndo, ""%s Service level: %u"", + ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24)); + break; + + default: + hexdump=TRUE; + break; + } + total_subobj_len-=subobj_len; + obj_tptr+=subobj_len; + obj_tlen+=subobj_len; + } + + if (total_subobj_len) { + /* unless we have a TLV parser lets just hexdump */ + hexdump=TRUE; + } + break; + + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RSVP_HOP: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_32BITS(obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + if (obj_tlen) + hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ + break; + case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_32BITS(obj_tptr + 16))); + obj_tlen-=20; + obj_tptr+=20; + hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_TIME_VALUES: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Refresh Period: %ums"", + ident, + EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + /* those three objects do share the same semantics */ + case RSVP_OBJ_SENDER_TSPEC: + case RSVP_OBJ_ADSPEC: + case RSVP_OBJ_FLOWSPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_2: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Msg-Version: %u, length: %u"", + ident, + (*obj_tptr & 0xf0) >> 4, + EXTRACT_16BITS(obj_tptr + 2) << 2)); + obj_tptr+=4; /* get to the start of the service header */ + obj_tlen-=4; + + while (obj_tlen >= 4) { + intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2; + ND_PRINT((ndo, ""%s Service Type: %s (%u), break bit %s set, Service length: %u"", + ident, + tok2str(rsvp_intserv_service_type_values,""unknown"",*(obj_tptr)), + *(obj_tptr), + (*(obj_tptr+1)&0x80) ? """" : ""not"", + intserv_serv_tlen)); + + obj_tptr+=4; /* get to the start of the parameter list */ + obj_tlen-=4; + + while (intserv_serv_tlen>=4) { + processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen); + if (processed == 0) + break; + obj_tlen-=processed; + intserv_serv_tlen-=processed; + obj_tptr+=processed; + } + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_FILTERSPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 18))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Flow Label: %u"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_24BITS(obj_tptr + 17))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_TUNNEL_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, LSP-ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 18))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */ + if (obj_tlen < 40) + return-1; + ND_PRINT((ndo, ""%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ident, + ip6addr_string(ndo, obj_tptr+20), + EXTRACT_16BITS(obj_tptr + 38))); + obj_tlen-=40; + obj_tptr+=40; + break; + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, LSP-ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */ + if (obj_tlen < 16) + return-1; + ND_PRINT((ndo, ""%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ident, + ipaddr_string(ndo, obj_tptr+8), + EXTRACT_16BITS(obj_tptr + 12))); + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_FASTREROUTE: + /* the differences between c-type 1 and 7 are minor */ + obj_ptr.rsvp_obj_frr = (const struct rsvp_obj_frr_t *)obj_tptr; + + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: /* new style */ + if (obj_tlen < sizeof(struct rsvp_obj_frr_t)) + return-1; + bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth); + ND_PRINT((ndo, ""%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps"", + ident, + (int)obj_ptr.rsvp_obj_frr->setup_prio, + (int)obj_ptr.rsvp_obj_frr->hold_prio, + (int)obj_ptr.rsvp_obj_frr->hop_limit, + bw.f * 8 / 1000000)); + ND_PRINT((ndo, ""%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x"", + ident, + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any), + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any), + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all))); + obj_tlen-=sizeof(struct rsvp_obj_frr_t); + obj_tptr+=sizeof(struct rsvp_obj_frr_t); + break; + + case RSVP_CTYPE_TUNNEL_IPV4: /* old style */ + if (obj_tlen < 16) + return-1; + bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth); + ND_PRINT((ndo, ""%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps"", + ident, + (int)obj_ptr.rsvp_obj_frr->setup_prio, + (int)obj_ptr.rsvp_obj_frr->hold_prio, + (int)obj_ptr.rsvp_obj_frr->hop_limit, + bw.f * 8 / 1000000)); + ND_PRINT((ndo, ""%s Include Colors: 0x%08x, Exclude Colors: 0x%08x"", + ident, + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any), + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any))); + obj_tlen-=16; + obj_tptr+=16; + break; + + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_DETOUR: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + while(obj_tlen >= 8) { + ND_PRINT((ndo, ""%s PLR-ID: %s, Avoid-Node-ID: %s"", + ident, + ipaddr_string(ndo, obj_tptr), + ipaddr_string(ndo, obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_CLASSTYPE: + case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */ + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + ND_PRINT((ndo, ""%s CT: %u"", + ident, + EXTRACT_32BITS(obj_tptr) & 0x7)); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_ERROR_SPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + error_code=*(obj_tptr+5); + error_value=EXTRACT_16BITS(obj_tptr+6); + ND_PRINT((ndo, ""%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)"", + ident, + ipaddr_string(ndo, obj_tptr), + *(obj_tptr+4), + ident, + tok2str(rsvp_obj_error_code_values,""unknown"",error_code), + error_code)); + switch (error_code) { + case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: + ND_PRINT((ndo, "", Error Value: %s (%u)"", + tok2str(rsvp_obj_error_code_routing_values,""unknown"",error_value), + error_value)); + break; + case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */ + case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD: + ND_PRINT((ndo, "", Error Value: %s (%u)"", + tok2str(rsvp_obj_error_code_diffserv_te_values,""unknown"",error_value), + error_value)); + break; + default: + ND_PRINT((ndo, "", Unknown Error Value (%u)"", error_value)); + break; + } + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + error_code=*(obj_tptr+17); + error_value=EXTRACT_16BITS(obj_tptr+18); + ND_PRINT((ndo, ""%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)"", + ident, + ip6addr_string(ndo, obj_tptr), + *(obj_tptr+16), + ident, + tok2str(rsvp_obj_error_code_values,""unknown"",error_code), + error_code)); + + switch (error_code) { + case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: + ND_PRINT((ndo, "", Error Value: %s (%u)"", + tok2str(rsvp_obj_error_code_routing_values,""unknown"",error_value), + error_value)); + break; + default: + break; + } + obj_tlen-=20; + obj_tptr+=20; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_PROPERTIES: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + padbytes = EXTRACT_16BITS(obj_tptr+2); + ND_PRINT((ndo, ""%s TLV count: %u, padding bytes: %u"", + ident, + EXTRACT_16BITS(obj_tptr), + padbytes)); + obj_tlen-=4; + obj_tptr+=4; + /* loop through as long there is anything longer than the TLV header (2) */ + while(obj_tlen >= 2 + padbytes) { + ND_PRINT((ndo, ""%s %s TLV (0x%02x), length: %u"", /* length includes header */ + ident, + tok2str(rsvp_obj_prop_tlv_values,""unknown"",*obj_tptr), + *obj_tptr, + *(obj_tptr + 1))); + if (obj_tlen < *(obj_tptr+1)) + return-1; + if (*(obj_tptr+1) < 2) + return -1; + print_unknown_data(ndo, obj_tptr + 2, ""\n\t\t"", *(obj_tptr + 1) - 2); + obj_tlen-=*(obj_tptr+1); + obj_tptr+=*(obj_tptr+1); + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_MESSAGE_ID: /* fall through */ + case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */ + case RSVP_OBJ_MESSAGE_ID_LIST: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + case RSVP_CTYPE_2: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Flags [0x%02x], epoch: %u"", + ident, + *obj_tptr, + EXTRACT_24BITS(obj_tptr + 1))); + obj_tlen-=4; + obj_tptr+=4; + /* loop through as long there are no messages left */ + while(obj_tlen >= 4) { + ND_PRINT((ndo, ""%s Message-ID 0x%08x (%u)"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_INTEGRITY: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < sizeof(struct rsvp_obj_integrity_t)) + return-1; + obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr; + ND_PRINT((ndo, ""%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]"", + ident, + EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4), + bittok2str(rsvp_obj_integrity_flag_values, + ""none"", + obj_ptr.rsvp_obj_integrity->flags))); + ND_PRINT((ndo, ""%s MD5-sum 0x%08x%08x%08x%08x "", + ident, + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12))); + + sigcheck = signature_verify(ndo, pptr, plen, + obj_ptr.rsvp_obj_integrity->digest, + rsvp_clear_checksum, + rsvp_com_header); + ND_PRINT((ndo, "" (%s)"", tok2str(signature_check_values, ""Unknown"", sigcheck))); + + obj_tlen+=sizeof(struct rsvp_obj_integrity_t); + obj_tptr+=sizeof(struct rsvp_obj_integrity_t); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_ADMIN_STATUS: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Flags [%s]"", ident, + bittok2str(rsvp_obj_admin_status_flag_values, ""none"", + EXTRACT_32BITS(obj_tptr)))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_LABEL_SET: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + action = (EXTRACT_16BITS(obj_tptr)>>8); + + ND_PRINT((ndo, ""%s Action: %s (%u), Label type: %u"", ident, + tok2str(rsvp_obj_label_set_action_values, ""Unknown"", action), + action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)))); + + switch (action) { + case LABEL_SET_INCLUSIVE_RANGE: + case LABEL_SET_EXCLUSIVE_RANGE: /* fall through */ + + /* only a couple of subchannels are expected */ + if (obj_tlen < 12) + return -1; + ND_PRINT((ndo, ""%s Start range: %u, End range: %u"", ident, + EXTRACT_32BITS(obj_tptr+4), + EXTRACT_32BITS(obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + + default: + obj_tlen-=4; + obj_tptr+=4; + subchannel = 1; + while(obj_tlen >= 4 ) { + ND_PRINT((ndo, ""%s Subchannel #%u: %u"", ident, subchannel, + EXTRACT_32BITS(obj_tptr))); + obj_tptr+=4; + obj_tlen-=4; + subchannel++; + } + break; + } + break; + default: + hexdump=TRUE; + } + + case RSVP_OBJ_S2L: + switch (rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Sub-LSP destination address: %s"", + ident, ipaddr_string(ndo, obj_tptr))); + + obj_tlen-=4; + obj_tptr+=4; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 16) + return-1; + ND_PRINT((ndo, ""%s Sub-LSP destination address: %s"", + ident, ip6addr_string(ndo, obj_tptr))); + + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + + /* + * FIXME those are the defined objects that lack a decoder + * you are welcome to contribute code ;-) + */ + + case RSVP_OBJ_SCOPE: + case RSVP_OBJ_POLICY_DATA: + case RSVP_OBJ_ACCEPT_LABEL_SET: + case RSVP_OBJ_PROTECTION: + default: + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, obj_tptr, ""\n\t "", obj_tlen); /* FIXME indentation */ + break; + } + /* do we also want to see a hex dump ? */ + if (ndo->ndo_vflag > 1 || hexdump == TRUE) + print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), ""\n\t "", /* FIXME indentation */ + rsvp_obj_len - sizeof(struct rsvp_object_header)); + + tptr+=rsvp_obj_len; + tlen-=rsvp_obj_len; + } + return 0; +invalid: + ND_PRINT((ndo, ""%s"", istr)); + return -1; +trunc: + ND_PRINT((ndo, ""\n\t\t"")); + ND_PRINT((ndo, ""%s"", tstr)); + return -1; +} +",1,"rsvp_obj_print(netdissect_options *ndo, + const u_char *pptr, u_int plen, const u_char *tptr, + const char *ident, u_int tlen, + const struct rsvp_common_header *rsvp_com_header) +{ + const struct rsvp_object_header *rsvp_obj_header; + const u_char *obj_tptr; + union { + const struct rsvp_obj_integrity_t *rsvp_obj_integrity; + const struct rsvp_obj_frr_t *rsvp_obj_frr; + } obj_ptr; + + u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen; + int hexdump,processed,padbytes,error_code,error_value,i,sigcheck; + union { + float f; + uint32_t i; + } bw; + uint8_t namelen; + + u_int action, subchannel; + + while(tlen>=sizeof(struct rsvp_object_header)) { + /* did we capture enough for fully decoding the object header ? */ + ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header)); + + rsvp_obj_header = (const struct rsvp_object_header *)tptr; + rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length); + rsvp_obj_ctype=rsvp_obj_header->ctype; + + if(rsvp_obj_len % 4) { + ND_PRINT((ndo, ""%sERROR: object header size %u not a multiple of 4"", ident, rsvp_obj_len)); + return -1; + } + if(rsvp_obj_len < sizeof(struct rsvp_object_header)) { + ND_PRINT((ndo, ""%sERROR: object header too short %u < %lu"", ident, rsvp_obj_len, + (unsigned long)sizeof(const struct rsvp_object_header))); + return -1; + } + + ND_PRINT((ndo, ""%s%s Object (%u) Flags: [%s"", + ident, + tok2str(rsvp_obj_values, + ""Unknown"", + rsvp_obj_header->class_num), + rsvp_obj_header->class_num, + ((rsvp_obj_header->class_num) & 0x80) ? ""ignore"" : ""reject"")); + + if (rsvp_obj_header->class_num > 128) + ND_PRINT((ndo, "" %s"", + ((rsvp_obj_header->class_num) & 0x40) ? ""and forward"" : ""silently"")); + + ND_PRINT((ndo, "" if unknown], Class-Type: %s (%u), length: %u"", + tok2str(rsvp_ctype_values, + ""Unknown"", + ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype), + rsvp_obj_ctype, + rsvp_obj_len)); + + if(tlen < rsvp_obj_len) { + ND_PRINT((ndo, ""%sERROR: object goes past end of objects TLV"", ident)); + return -1; + } + + obj_tptr=tptr+sizeof(struct rsvp_object_header); + obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header); + + /* did we capture enough for fully decoding the object ? */ + if (!ND_TTEST2(*tptr, rsvp_obj_len)) + return -1; + hexdump=FALSE; + + switch(rsvp_obj_header->class_num) { + case RSVP_OBJ_SESSION: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return -1; + ND_PRINT((ndo, ""%s IPv4 DestAddress: %s, Protocol ID: 0x%02x"", + ident, + ipaddr_string(ndo, obj_tptr), + *(obj_tptr + sizeof(struct in_addr)))); + ND_PRINT((ndo, ""%s Flags: [0x%02x], DestPort %u"", + ident, + *(obj_tptr+5), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return -1; + ND_PRINT((ndo, ""%s IPv6 DestAddress: %s, Protocol ID: 0x%02x"", + ident, + ip6addr_string(ndo, obj_tptr), + *(obj_tptr + sizeof(struct in6_addr)))); + ND_PRINT((ndo, ""%s Flags: [0x%02x], DestPort %u"", + ident, + *(obj_tptr+sizeof(struct in6_addr)+1), + EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2))); + obj_tlen-=20; + obj_tptr+=20; + break; + + case RSVP_CTYPE_TUNNEL_IPV6: + if (obj_tlen < 36) + return -1; + ND_PRINT((ndo, ""%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ip6addr_string(ndo, obj_tptr + 20))); + obj_tlen-=36; + obj_tptr+=36; + break; + + case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */ + if (obj_tlen < 26) + return -1; + ND_PRINT((ndo, ""%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ip6addr_string(ndo, obj_tptr + 8))); + obj_tlen-=26; + obj_tptr+=26; + break; + case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */ + if (obj_tlen < 12) + return -1; + ND_PRINT((ndo, ""%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ipaddr_string(ndo, obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_TUNNEL_IPV4: + case RSVP_CTYPE_UNI_IPV4: + if (obj_tlen < 12) + return -1; + ND_PRINT((ndo, ""%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ipaddr_string(ndo, obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_CONFIRM: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < sizeof(struct in_addr)) + return -1; + ND_PRINT((ndo, ""%s IPv4 Receiver Address: %s"", + ident, + ipaddr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in_addr); + obj_tptr+=sizeof(struct in_addr); + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < sizeof(struct in6_addr)) + return -1; + ND_PRINT((ndo, ""%s IPv6 Receiver Address: %s"", + ident, + ip6addr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in6_addr); + obj_tptr+=sizeof(struct in6_addr); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_NOTIFY_REQ: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < sizeof(struct in_addr)) + return -1; + ND_PRINT((ndo, ""%s IPv4 Notify Node Address: %s"", + ident, + ipaddr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in_addr); + obj_tptr+=sizeof(struct in_addr); + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < sizeof(struct in6_addr)) + return-1; + ND_PRINT((ndo, ""%s IPv6 Notify Node Address: %s"", + ident, + ip6addr_string(ndo, obj_tptr))); + obj_tlen-=sizeof(struct in6_addr); + obj_tptr+=sizeof(struct in6_addr); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */ + case RSVP_OBJ_UPSTREAM_LABEL: /* fall through */ + case RSVP_OBJ_RECOVERY_LABEL: /* fall through */ + case RSVP_OBJ_LABEL: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + while(obj_tlen >= 4 ) { + ND_PRINT((ndo, ""%s Label: %u"", ident, EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + case RSVP_CTYPE_2: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Generalized Label: %u"", + ident, + EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 12) + return-1; + ND_PRINT((ndo, ""%s Waveband ID: %u%s Start Label: %u, Stop Label: %u"", + ident, + EXTRACT_32BITS(obj_tptr), + ident, + EXTRACT_32BITS(obj_tptr+4), + EXTRACT_32BITS(obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_STYLE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Reservation Style: %s, Flags: [0x%02x]"", + ident, + tok2str(rsvp_resstyle_values, + ""Unknown"", + EXTRACT_24BITS(obj_tptr+1)), + *(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SENDER_TEMPLATE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 18))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */ + if (obj_tlen < 40) + return-1; + ND_PRINT((ndo, ""%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ident, + ip6addr_string(ndo, obj_tptr+20), + EXTRACT_16BITS(obj_tptr + 38))); + obj_tlen-=40; + obj_tptr+=40; + break; + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */ + if (obj_tlen < 16) + return-1; + ND_PRINT((ndo, ""%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ident, + ipaddr_string(ndo, obj_tptr+8), + EXTRACT_16BITS(obj_tptr + 12))); + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_LABEL_REQ: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + while(obj_tlen >= 4 ) { + ND_PRINT((ndo, ""%s L3 Protocol ID: %s"", + ident, + tok2str(ethertype_values, + ""Unknown Protocol (0x%04x)"", + EXTRACT_16BITS(obj_tptr + 2)))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + case RSVP_CTYPE_2: + if (obj_tlen < 12) + return-1; + ND_PRINT((ndo, ""%s L3 Protocol ID: %s"", + ident, + tok2str(ethertype_values, + ""Unknown Protocol (0x%04x)"", + EXTRACT_16BITS(obj_tptr + 2)))); + ND_PRINT((ndo, "",%s merge capability"",((*(obj_tptr + 4)) & 0x80) ? ""no"" : """" )); + ND_PRINT((ndo, ""%s Minimum VPI/VCI: %u/%u"", + ident, + (EXTRACT_16BITS(obj_tptr+4))&0xfff, + (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff)); + ND_PRINT((ndo, ""%s Maximum VPI/VCI: %u/%u"", + ident, + (EXTRACT_16BITS(obj_tptr+8))&0xfff, + (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff)); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 12) + return-1; + ND_PRINT((ndo, ""%s L3 Protocol ID: %s"", + ident, + tok2str(ethertype_values, + ""Unknown Protocol (0x%04x)"", + EXTRACT_16BITS(obj_tptr + 2)))); + ND_PRINT((ndo, ""%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI"", + ident, + (EXTRACT_32BITS(obj_tptr+4))&0x7fffff, + (EXTRACT_32BITS(obj_tptr+8))&0x7fffff, + (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? ""10"" : """", + (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? ""23"" : """")); + obj_tlen-=12; + obj_tptr+=12; + break; + case RSVP_CTYPE_4: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s LSP Encoding Type: %s (%u)"", + ident, + tok2str(gmpls_encoding_values, + ""Unknown"", + *obj_tptr), + *obj_tptr)); + ND_PRINT((ndo, ""%s Switching Type: %s (%u), Payload ID: %s (0x%04x)"", + ident, + tok2str(gmpls_switch_cap_values, + ""Unknown"", + *(obj_tptr+1)), + *(obj_tptr+1), + tok2str(gmpls_payload_values, + ""Unknown"", + EXTRACT_16BITS(obj_tptr+2)), + EXTRACT_16BITS(obj_tptr + 2))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RRO: + case RSVP_OBJ_ERO: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + while(obj_tlen >= 4 ) { + u_char length; + + ND_TCHECK2(*obj_tptr, 4); + length = *(obj_tptr + 1); + ND_PRINT((ndo, ""%s Subobject Type: %s, length %u"", + ident, + tok2str(rsvp_obj_xro_values, + ""Unknown %u"", + RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)), + length)); + + if (length == 0) { /* prevent infinite loops */ + ND_PRINT((ndo, ""%s ERROR: zero length ERO subtype"", ident)); + break; + } + + switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) { + u_char prefix_length; + + case RSVP_OBJ_XRO_IPV4: + if (length != 8) { + ND_PRINT((ndo, "" ERROR: length != 8"")); + goto invalid; + } + ND_TCHECK2(*obj_tptr, 8); + prefix_length = *(obj_tptr+6); + if (prefix_length != 32) { + ND_PRINT((ndo, "" ERROR: Prefix length %u != 32"", + prefix_length)); + goto invalid; + } + ND_PRINT((ndo, "", %s, %s/%u, Flags: [%s]"", + RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? ""Loose"" : ""Strict"", + ipaddr_string(ndo, obj_tptr+2), + *(obj_tptr+6), + bittok2str(rsvp_obj_rro_flag_values, + ""none"", + *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */ + break; + case RSVP_OBJ_XRO_LABEL: + if (length != 8) { + ND_PRINT((ndo, "" ERROR: length != 8"")); + goto invalid; + } + ND_TCHECK2(*obj_tptr, 8); + ND_PRINT((ndo, "", Flags: [%s] (%#x), Class-Type: %s (%u), %u"", + bittok2str(rsvp_obj_rro_label_flag_values, + ""none"", + *(obj_tptr+2)), + *(obj_tptr+2), + tok2str(rsvp_ctype_values, + ""Unknown"", + *(obj_tptr+3) + 256*RSVP_OBJ_RRO), + *(obj_tptr+3), + EXTRACT_32BITS(obj_tptr + 4))); + } + obj_tlen-=*(obj_tptr+1); + obj_tptr+=*(obj_tptr+1); + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_HELLO: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + case RSVP_CTYPE_2: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Instance: 0x%08x, Destination Instance: 0x%08x"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RESTART_CAPABILITY: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Restart Time: %ums, Recovery Time: %ums"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_SESSION_ATTRIBUTE: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 4) + return-1; + namelen = *(obj_tptr+3); + if (obj_tlen < 4+namelen) + return-1; + ND_PRINT((ndo, ""%s Session Name: "", ident)); + for (i = 0; i < namelen; i++) + safeputchar(ndo, *(obj_tptr + 4 + i)); + ND_PRINT((ndo, ""%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)"", + ident, + (int)*obj_tptr, + (int)*(obj_tptr+1), + bittok2str(rsvp_session_attribute_flag_values, + ""none"", + *(obj_tptr+2)), + *(obj_tptr + 2))); + obj_tlen-=4+*(obj_tptr+3); + obj_tptr+=4+*(obj_tptr+3); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_GENERALIZED_UNI: + switch(rsvp_obj_ctype) { + int subobj_type,af,subobj_len,total_subobj_len; + + case RSVP_CTYPE_1: + + if (obj_tlen < 4) + return-1; + + /* read variable length subobjects */ + total_subobj_len = obj_tlen; + while(total_subobj_len > 0) { + /* If RFC 3476 Section 3.1 defined that a sub-object of the + * GENERALIZED_UNI RSVP object must have the Length field as + * a multiple of 4, instead of the check below it would be + * better to test total_subobj_len only once before the loop. + * So long as it does not define it and this while loop does + * not implement such a requirement, let's accept that within + * each iteration subobj_len may happen to be a multiple of 1 + * and test it and total_subobj_len respectively. + */ + if (total_subobj_len < 4) + goto invalid; + subobj_len = EXTRACT_16BITS(obj_tptr); + subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8; + af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF; + + ND_PRINT((ndo, ""%s Subobject Type: %s (%u), AF: %s (%u), length: %u"", + ident, + tok2str(rsvp_obj_generalized_uni_values, ""Unknown"", subobj_type), + subobj_type, + tok2str(af_values, ""Unknown"", af), af, + subobj_len)); + + /* In addition to what is explained above, the same spec does not + * explicitly say that the same Length field includes the 4-octet + * sub-object header, but as long as this while loop implements it + * as it does include, let's keep the check below consistent with + * the rest of the code. + */ + if(subobj_len < 4 || subobj_len > total_subobj_len) + goto invalid; + + switch(subobj_type) { + case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS: + case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS: + + switch(af) { + case AFNUM_INET: + if (subobj_len < 8) + return -1; + ND_PRINT((ndo, ""%s UNI IPv4 TNA address: %s"", + ident, ipaddr_string(ndo, obj_tptr + 4))); + break; + case AFNUM_INET6: + if (subobj_len < 20) + return -1; + ND_PRINT((ndo, ""%s UNI IPv6 TNA address: %s"", + ident, ip6addr_string(ndo, obj_tptr + 4))); + break; + case AFNUM_NSAP: + if (subobj_len) { + /* unless we have a TLV parser lets just hexdump */ + hexdump=TRUE; + } + break; + } + break; + + case RSVP_GEN_UNI_SUBOBJ_DIVERSITY: + if (subobj_len) { + /* unless we have a TLV parser lets just hexdump */ + hexdump=TRUE; + } + break; + + case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL: + if (subobj_len < 16) { + return -1; + } + + ND_PRINT((ndo, ""%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u"", + ident, + ((EXTRACT_32BITS(obj_tptr+4))>>31), + ((EXTRACT_32BITS(obj_tptr+4))&0xFF), + EXTRACT_32BITS(obj_tptr+8), + EXTRACT_32BITS(obj_tptr + 12))); + break; + + case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL: + if (subobj_len < 8) { + return -1; + } + + ND_PRINT((ndo, ""%s Service level: %u"", + ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24)); + break; + + default: + hexdump=TRUE; + break; + } + total_subobj_len-=subobj_len; + obj_tptr+=subobj_len; + obj_tlen+=subobj_len; + } + + if (total_subobj_len) { + /* unless we have a TLV parser lets just hexdump */ + hexdump=TRUE; + } + break; + + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_RSVP_HOP: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_32BITS(obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + if (obj_tlen) + hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ + break; + case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_32BITS(obj_tptr + 16))); + obj_tlen-=20; + obj_tptr+=20; + hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_TIME_VALUES: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Refresh Period: %ums"", + ident, + EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + /* those three objects do share the same semantics */ + case RSVP_OBJ_SENDER_TSPEC: + case RSVP_OBJ_ADSPEC: + case RSVP_OBJ_FLOWSPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_2: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Msg-Version: %u, length: %u"", + ident, + (*obj_tptr & 0xf0) >> 4, + EXTRACT_16BITS(obj_tptr + 2) << 2)); + obj_tptr+=4; /* get to the start of the service header */ + obj_tlen-=4; + + while (obj_tlen >= 4) { + intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2; + ND_PRINT((ndo, ""%s Service Type: %s (%u), break bit %s set, Service length: %u"", + ident, + tok2str(rsvp_intserv_service_type_values,""unknown"",*(obj_tptr)), + *(obj_tptr), + (*(obj_tptr+1)&0x80) ? """" : ""not"", + intserv_serv_tlen)); + + obj_tptr+=4; /* get to the start of the parameter list */ + obj_tlen-=4; + + while (intserv_serv_tlen>=4) { + processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen); + if (processed == 0) + break; + obj_tlen-=processed; + intserv_serv_tlen-=processed; + obj_tptr+=processed; + } + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_FILTERSPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Source Port: %u"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 18))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_3: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, Flow Label: %u"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_24BITS(obj_tptr + 17))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_TUNNEL_IPV6: + if (obj_tlen < 20) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, LSP-ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 18))); + obj_tlen-=20; + obj_tptr+=20; + break; + case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */ + if (obj_tlen < 40) + return-1; + ND_PRINT((ndo, ""%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ip6addr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+18), + ident, + ip6addr_string(ndo, obj_tptr+20), + EXTRACT_16BITS(obj_tptr + 38))); + obj_tlen-=40; + obj_tptr+=40; + break; + case RSVP_CTYPE_TUNNEL_IPV4: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Source Address: %s, LSP-ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr + 6))); + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */ + if (obj_tlen < 16) + return-1; + ND_PRINT((ndo, ""%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"" + ""%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x"", + ident, + ipaddr_string(ndo, obj_tptr), + EXTRACT_16BITS(obj_tptr+6), + ident, + ipaddr_string(ndo, obj_tptr+8), + EXTRACT_16BITS(obj_tptr + 12))); + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_FASTREROUTE: + /* the differences between c-type 1 and 7 are minor */ + obj_ptr.rsvp_obj_frr = (const struct rsvp_obj_frr_t *)obj_tptr; + + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: /* new style */ + if (obj_tlen < sizeof(struct rsvp_obj_frr_t)) + return-1; + bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth); + ND_PRINT((ndo, ""%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps"", + ident, + (int)obj_ptr.rsvp_obj_frr->setup_prio, + (int)obj_ptr.rsvp_obj_frr->hold_prio, + (int)obj_ptr.rsvp_obj_frr->hop_limit, + bw.f * 8 / 1000000)); + ND_PRINT((ndo, ""%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x"", + ident, + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any), + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any), + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all))); + obj_tlen-=sizeof(struct rsvp_obj_frr_t); + obj_tptr+=sizeof(struct rsvp_obj_frr_t); + break; + + case RSVP_CTYPE_TUNNEL_IPV4: /* old style */ + if (obj_tlen < 16) + return-1; + bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth); + ND_PRINT((ndo, ""%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps"", + ident, + (int)obj_ptr.rsvp_obj_frr->setup_prio, + (int)obj_ptr.rsvp_obj_frr->hold_prio, + (int)obj_ptr.rsvp_obj_frr->hop_limit, + bw.f * 8 / 1000000)); + ND_PRINT((ndo, ""%s Include Colors: 0x%08x, Exclude Colors: 0x%08x"", + ident, + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any), + EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any))); + obj_tlen-=16; + obj_tptr+=16; + break; + + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_DETOUR: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_TUNNEL_IPV4: + while(obj_tlen >= 8) { + ND_PRINT((ndo, ""%s PLR-ID: %s, Avoid-Node-ID: %s"", + ident, + ipaddr_string(ndo, obj_tptr), + ipaddr_string(ndo, obj_tptr + 4))); + obj_tlen-=8; + obj_tptr+=8; + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_CLASSTYPE: + case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */ + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + ND_TCHECK_32BITS(obj_tptr); + ND_PRINT((ndo, ""%s CT: %u"", + ident, + EXTRACT_32BITS(obj_tptr) & 0x7)); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_ERROR_SPEC: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV4: + if (obj_tlen < 8) + return-1; + error_code=*(obj_tptr+5); + error_value=EXTRACT_16BITS(obj_tptr+6); + ND_PRINT((ndo, ""%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)"", + ident, + ipaddr_string(ndo, obj_tptr), + *(obj_tptr+4), + ident, + tok2str(rsvp_obj_error_code_values,""unknown"",error_code), + error_code)); + switch (error_code) { + case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: + ND_PRINT((ndo, "", Error Value: %s (%u)"", + tok2str(rsvp_obj_error_code_routing_values,""unknown"",error_value), + error_value)); + break; + case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */ + case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD: + ND_PRINT((ndo, "", Error Value: %s (%u)"", + tok2str(rsvp_obj_error_code_diffserv_te_values,""unknown"",error_value), + error_value)); + break; + default: + ND_PRINT((ndo, "", Unknown Error Value (%u)"", error_value)); + break; + } + obj_tlen-=8; + obj_tptr+=8; + break; + case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ + case RSVP_CTYPE_IPV6: + if (obj_tlen < 20) + return-1; + error_code=*(obj_tptr+17); + error_value=EXTRACT_16BITS(obj_tptr+18); + ND_PRINT((ndo, ""%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)"", + ident, + ip6addr_string(ndo, obj_tptr), + *(obj_tptr+16), + ident, + tok2str(rsvp_obj_error_code_values,""unknown"",error_code), + error_code)); + + switch (error_code) { + case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: + ND_PRINT((ndo, "", Error Value: %s (%u)"", + tok2str(rsvp_obj_error_code_routing_values,""unknown"",error_value), + error_value)); + break; + default: + break; + } + obj_tlen-=20; + obj_tptr+=20; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_PROPERTIES: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + padbytes = EXTRACT_16BITS(obj_tptr+2); + ND_PRINT((ndo, ""%s TLV count: %u, padding bytes: %u"", + ident, + EXTRACT_16BITS(obj_tptr), + padbytes)); + obj_tlen-=4; + obj_tptr+=4; + /* loop through as long there is anything longer than the TLV header (2) */ + while(obj_tlen >= 2 + padbytes) { + ND_PRINT((ndo, ""%s %s TLV (0x%02x), length: %u"", /* length includes header */ + ident, + tok2str(rsvp_obj_prop_tlv_values,""unknown"",*obj_tptr), + *obj_tptr, + *(obj_tptr + 1))); + if (obj_tlen < *(obj_tptr+1)) + return-1; + if (*(obj_tptr+1) < 2) + return -1; + print_unknown_data(ndo, obj_tptr + 2, ""\n\t\t"", *(obj_tptr + 1) - 2); + obj_tlen-=*(obj_tptr+1); + obj_tptr+=*(obj_tptr+1); + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_MESSAGE_ID: /* fall through */ + case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */ + case RSVP_OBJ_MESSAGE_ID_LIST: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + case RSVP_CTYPE_2: + if (obj_tlen < 8) + return-1; + ND_PRINT((ndo, ""%s Flags [0x%02x], epoch: %u"", + ident, + *obj_tptr, + EXTRACT_24BITS(obj_tptr + 1))); + obj_tlen-=4; + obj_tptr+=4; + /* loop through as long there are no messages left */ + while(obj_tlen >= 4) { + ND_PRINT((ndo, ""%s Message-ID 0x%08x (%u)"", + ident, + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr))); + obj_tlen-=4; + obj_tptr+=4; + } + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_INTEGRITY: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < sizeof(struct rsvp_obj_integrity_t)) + return-1; + obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr; + ND_PRINT((ndo, ""%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]"", + ident, + EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4), + bittok2str(rsvp_obj_integrity_flag_values, + ""none"", + obj_ptr.rsvp_obj_integrity->flags))); + ND_PRINT((ndo, ""%s MD5-sum 0x%08x%08x%08x%08x "", + ident, + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8), + EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12))); + + sigcheck = signature_verify(ndo, pptr, plen, + obj_ptr.rsvp_obj_integrity->digest, + rsvp_clear_checksum, + rsvp_com_header); + ND_PRINT((ndo, "" (%s)"", tok2str(signature_check_values, ""Unknown"", sigcheck))); + + obj_tlen+=sizeof(struct rsvp_obj_integrity_t); + obj_tptr+=sizeof(struct rsvp_obj_integrity_t); + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_ADMIN_STATUS: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Flags [%s]"", ident, + bittok2str(rsvp_obj_admin_status_flag_values, ""none"", + EXTRACT_32BITS(obj_tptr)))); + obj_tlen-=4; + obj_tptr+=4; + break; + default: + hexdump=TRUE; + } + break; + + case RSVP_OBJ_LABEL_SET: + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: + if (obj_tlen < 4) + return-1; + action = (EXTRACT_16BITS(obj_tptr)>>8); + + ND_PRINT((ndo, ""%s Action: %s (%u), Label type: %u"", ident, + tok2str(rsvp_obj_label_set_action_values, ""Unknown"", action), + action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)))); + + switch (action) { + case LABEL_SET_INCLUSIVE_RANGE: + case LABEL_SET_EXCLUSIVE_RANGE: /* fall through */ + + /* only a couple of subchannels are expected */ + if (obj_tlen < 12) + return -1; + ND_PRINT((ndo, ""%s Start range: %u, End range: %u"", ident, + EXTRACT_32BITS(obj_tptr+4), + EXTRACT_32BITS(obj_tptr + 8))); + obj_tlen-=12; + obj_tptr+=12; + break; + + default: + obj_tlen-=4; + obj_tptr+=4; + subchannel = 1; + while(obj_tlen >= 4 ) { + ND_PRINT((ndo, ""%s Subchannel #%u: %u"", ident, subchannel, + EXTRACT_32BITS(obj_tptr))); + obj_tptr+=4; + obj_tlen-=4; + subchannel++; + } + break; + } + break; + default: + hexdump=TRUE; + } + + case RSVP_OBJ_S2L: + switch (rsvp_obj_ctype) { + case RSVP_CTYPE_IPV4: + if (obj_tlen < 4) + return-1; + ND_PRINT((ndo, ""%s Sub-LSP destination address: %s"", + ident, ipaddr_string(ndo, obj_tptr))); + + obj_tlen-=4; + obj_tptr+=4; + break; + case RSVP_CTYPE_IPV6: + if (obj_tlen < 16) + return-1; + ND_PRINT((ndo, ""%s Sub-LSP destination address: %s"", + ident, ip6addr_string(ndo, obj_tptr))); + + obj_tlen-=16; + obj_tptr+=16; + break; + default: + hexdump=TRUE; + } + + /* + * FIXME those are the defined objects that lack a decoder + * you are welcome to contribute code ;-) + */ + + case RSVP_OBJ_SCOPE: + case RSVP_OBJ_POLICY_DATA: + case RSVP_OBJ_ACCEPT_LABEL_SET: + case RSVP_OBJ_PROTECTION: + default: + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, obj_tptr, ""\n\t "", obj_tlen); /* FIXME indentation */ + break; + } + /* do we also want to see a hex dump ? */ + if (ndo->ndo_vflag > 1 || hexdump == TRUE) + print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), ""\n\t "", /* FIXME indentation */ + rsvp_obj_len - sizeof(struct rsvp_object_header)); + + tptr+=rsvp_obj_len; + tlen-=rsvp_obj_len; + } + return 0; +invalid: + ND_PRINT((ndo, ""%s"", istr)); + return -1; +trunc: + ND_PRINT((ndo, ""\n\t\t"")); + ND_PRINT((ndo, ""%s"", tstr)); + return -1; +} +","@@ -1555,6 +1555,7 @@ rsvp_obj_print(netdissect_options *ndo, + case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */ + switch(rsvp_obj_ctype) { + case RSVP_CTYPE_1: ++ ND_TCHECK_32BITS(obj_tptr); + ND_PRINT((ndo, ""%s CT: %u"", + ident, + EXTRACT_32BITS(obj_tptr) & 0x7));",10904,11140,28000 +18325,"static void cmdloop(void) +{ + int c; + int usinguid, havepartition, havenamespace, recursive; + static struct buf tag, cmd, arg1, arg2, arg3; + char *p, shut[MAX_MAILBOX_PATH+1], cmdname[100]; + const char *err; + const char * commandmintimer; + double commandmintimerd = 0.0; + struct sync_reserve_list *reserve_list = + sync_reserve_list_create(SYNC_MESSAGE_LIST_HASH_SIZE); + struct applepushserviceargs applepushserviceargs; + + prot_printf(imapd_out, ""* OK [CAPABILITY ""); + capa_response(CAPA_PREAUTH); + prot_printf(imapd_out, ""]""); + if (config_serverinfo) prot_printf(imapd_out, "" %s"", config_servername); + if (config_serverinfo == IMAP_ENUM_SERVERINFO_ON) { + prot_printf(imapd_out, "" Cyrus IMAP %s"", cyrus_version()); + } + prot_printf(imapd_out, "" server ready\r\n""); + + /* clear cancelled flag if present before the next command */ + cmd_cancelled(); + + motd_file(); + + /* Get command timer logging paramater. This string + * is a time in seconds. Any command that takes >= + * this time to execute is logged */ + commandmintimer = config_getstring(IMAPOPT_COMMANDMINTIMER); + cmdtime_settimer(commandmintimer ? 1 : 0); + if (commandmintimer) { + commandmintimerd = atof(commandmintimer); + } + + for (;;) { + /* Release any held index */ + index_release(imapd_index); + + /* Flush any buffered output */ + prot_flush(imapd_out); + if (backend_current) prot_flush(backend_current->out); + + /* command no longer running */ + proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), NULL); + + /* Check for shutdown file */ + if ( !imapd_userisadmin && imapd_userid && + (shutdown_file(shut, sizeof(shut)) || + userdeny(imapd_userid, config_ident, shut, sizeof(shut)))) { + for (p = shut; *p == '['; p++); /* can't have [ be first char */ + prot_printf(imapd_out, ""* BYE [ALERT] %s\r\n"", p); + telemetry_rusage(imapd_userid); + shut_down(0); + } + + signals_poll(); + + if (!proxy_check_input(protin, imapd_in, imapd_out, + backend_current ? backend_current->in : NULL, + NULL, 0)) { + /* No input from client */ + continue; + } + + /* Parse tag */ + c = getword(imapd_in, &tag); + if (c == EOF) { + if ((err = prot_error(imapd_in))!=NULL + && strcmp(err, PROT_EOF_STRING)) { + syslog(LOG_WARNING, ""%s, closing connection"", err); + prot_printf(imapd_out, ""* BYE %s\r\n"", err); + } + goto done; + } + if (c != ' ' || !imparse_isatom(tag.s) || (tag.s[0] == '*' && !tag.s[1])) { + prot_printf(imapd_out, ""* BAD Invalid tag\r\n""); + eatline(imapd_in, c); + continue; + } + + /* Parse command name */ + c = getword(imapd_in, &cmd); + if (!cmd.s[0]) { + prot_printf(imapd_out, ""%s BAD Null command\r\n"", tag.s); + eatline(imapd_in, c); + continue; + } + lcase(cmd.s); + xstrncpy(cmdname, cmd.s, 99); + cmd.s[0] = toupper((unsigned char) cmd.s[0]); + + if (config_getswitch(IMAPOPT_CHATTY)) + syslog(LOG_NOTICE, ""command: %s %s"", tag.s, cmd.s); + + proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), cmd.s); + + /* if we need to force a kick, do so */ + if (referral_kick) { + kick_mupdate(); + referral_kick = 0; + } + + if (plaintextloginalert) { + prot_printf(imapd_out, ""* OK [ALERT] %s\r\n"", + plaintextloginalert); + plaintextloginalert = NULL; + } + + /* Only Authenticate/Enable/Login/Logout/Noop/Capability/Id/Starttls + allowed when not logged in */ + if (!imapd_userid && !strchr(""AELNCIS"", cmd.s[0])) goto nologin; + + /* Start command timer */ + cmdtime_starttimer(); + + /* note that about half the commands (the common ones that don't + hit the mailboxes file) now close the mailboxes file just in + case it was open. */ + switch (cmd.s[0]) { + case 'A': + if (!strcmp(cmd.s, ""Authenticate"")) { + int haveinitresp = 0; + + if (c != ' ') goto missingargs; + c = getword(imapd_in, &arg1); + if (!imparse_isatom(arg1.s)) { + prot_printf(imapd_out, ""%s BAD Invalid authenticate mechanism\r\n"", tag.s); + eatline(imapd_in, c); + continue; + } + if (c == ' ') { + haveinitresp = 1; + c = getword(imapd_in, &arg2); + if (c == EOF) goto missingargs; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + if (imapd_userid) { + prot_printf(imapd_out, ""%s BAD Already authenticated\r\n"", tag.s); + continue; + } + cmd_authenticate(tag.s, arg1.s, haveinitresp ? arg2.s : NULL); + + snmp_increment(AUTHENTICATE_COUNT, 1); + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Append"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_append(tag.s, arg1.s, NULL); + + snmp_increment(APPEND_COUNT, 1); + } + else goto badcmd; + break; + + case 'C': + if (!strcmp(cmd.s, ""Capability"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_capability(tag.s); + + snmp_increment(CAPABILITY_COUNT, 1); + } + else if (!imapd_userid) goto nologin; +#ifdef HAVE_ZLIB + else if (!strcmp(cmd.s, ""Compress"")) { + if (c != ' ') goto missingargs; + c = getword(imapd_in, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_compress(tag.s, arg1.s); + + snmp_increment(COMPRESS_COUNT, 1); + } +#endif /* HAVE_ZLIB */ + else if (!strcmp(cmd.s, ""Check"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_noop(tag.s, cmd.s); + + snmp_increment(CHECK_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Copy"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + copy: + c = getword(imapd_in, &arg1); + if (c == '\r') goto missingargs; + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/0); + + snmp_increment(COPY_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Create"")) { + struct dlist *extargs = NULL; + + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == ' ') { + c = parsecreateargs(&extargs); + if (c == EOF) goto badpartition; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_create(tag.s, arg1.s, extargs, 0); + dlist_free(&extargs); + + snmp_increment(CREATE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Close"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_close(tag.s, cmd.s); + + snmp_increment(CLOSE_COUNT, 1); + } + else goto badcmd; + break; + + case 'D': + if (!strcmp(cmd.s, ""Delete"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_delete(tag.s, arg1.s, 0, 0); + + snmp_increment(DELETE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Deleteacl"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_setacl(tag.s, arg1.s, arg2.s, NULL); + + snmp_increment(DELETEACL_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Dump"")) { + int uid_start = 0; + + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c == ' ') { + c = getastring(imapd_in, imapd_out, &arg2); + if(!imparse_isnumber(arg2.s)) goto extraargs; + uid_start = atoi(arg2.s); + } + + if(c == '\r') c = prot_getc(imapd_in); + if(c != '\n') goto extraargs; + + cmd_dump(tag.s, arg1.s, uid_start); + /* snmp_increment(DUMP_COUNT, 1);*/ + } + else goto badcmd; + break; + + case 'E': + if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Enable"")) { + if (c != ' ') goto missingargs; + + cmd_enable(tag.s); + } + else if (!strcmp(cmd.s, ""Expunge"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_expunge(tag.s, 0); + + snmp_increment(EXPUNGE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Examine"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + prot_ungetc(c, imapd_in); + + cmd_select(tag.s, cmd.s, arg1.s); + + snmp_increment(EXAMINE_COUNT, 1); + } + else goto badcmd; + break; + + case 'F': + if (!strcmp(cmd.s, ""Fetch"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + fetch: + c = getword(imapd_in, &arg1); + if (c == '\r') goto missingargs; + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + + cmd_fetch(tag.s, arg1.s, usinguid); + + snmp_increment(FETCH_COUNT, 1); + } + else goto badcmd; + break; + + case 'G': + if (!strcmp(cmd.s, ""Getacl"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_getacl(tag.s, arg1.s); + + snmp_increment(GETACL_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getannotation"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_getannotation(tag.s, arg1.s); + + snmp_increment(GETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getmetadata"")) { + if (c != ' ') goto missingargs; + + cmd_getmetadata(tag.s); + + snmp_increment(GETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getquota"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_getquota(tag.s, arg1.s); + + snmp_increment(GETQUOTA_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getquotaroot"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_getquotaroot(tag.s, arg1.s); + + snmp_increment(GETQUOTAROOT_COUNT, 1); + } +#ifdef HAVE_SSL + else if (!strcmp(cmd.s, ""Genurlauth"")) { + if (c != ' ') goto missingargs; + + cmd_genurlauth(tag.s); + /* snmp_increment(GENURLAUTH_COUNT, 1);*/ + } +#endif + else goto badcmd; + break; + + case 'I': + if (!strcmp(cmd.s, ""Id"")) { + if (c != ' ') goto missingargs; + cmd_id(tag.s); + + snmp_increment(ID_COUNT, 1); + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Idle"") && idle_enabled()) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_idle(tag.s); + + snmp_increment(IDLE_COUNT, 1); + } + else goto badcmd; + break; + + case 'L': + if (!strcmp(cmd.s, ""Login"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c != ' ') goto missingargs; + + cmd_login(tag.s, arg1.s); + + snmp_increment(LOGIN_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Logout"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + snmp_increment(LOGOUT_COUNT, 1); + + /* force any responses from our selected backend */ + if (backend_current) imapd_check(NULL, 0); + + prot_printf(imapd_out, ""* BYE %s\r\n"", + error_message(IMAP_BYE_LOGOUT)); + prot_printf(imapd_out, ""%s OK %s\r\n"", tag.s, + error_message(IMAP_OK_COMPLETED)); + + if (imapd_userid && *imapd_userid) { + telemetry_rusage(imapd_userid); + } + + goto done; + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""List"")) { + struct listargs listargs; + + if (c != ' ') goto missingargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.ret = LIST_RET_CHILDREN; + getlistargs(tag.s, &listargs); + if (listargs.pat.count) cmd_list(tag.s, &listargs); + + snmp_increment(LIST_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Lsub"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.cmd = LIST_CMD_LSUB; + listargs.sel = LIST_SEL_SUBSCRIBED; + if (!strcasecmpsafe(imapd_magicplus, ""+dav"")) + listargs.sel |= LIST_SEL_DAV; + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + + cmd_list(tag.s, &listargs); + + snmp_increment(LSUB_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Listrights"")) { + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_listrights(tag.s, arg1.s, arg2.s); + + snmp_increment(LISTRIGHTS_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Localappend"")) { + /* create a local-only mailbox */ + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c != ' ') goto missingargs; + + cmd_append(tag.s, arg1.s, *arg2.s ? arg2.s : NULL); + + snmp_increment(APPEND_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Localcreate"")) { + /* create a local-only mailbox */ + struct dlist *extargs = NULL; + + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == ' ') { + c = parsecreateargs(&extargs); + if (c == EOF) goto badpartition; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_create(tag.s, arg1.s, extargs, 1); + dlist_free(&extargs); + + /* xxxx snmp_increment(CREATE_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Localdelete"")) { + /* delete a mailbox locally only */ + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_delete(tag.s, arg1.s, 1, 1); + + /* xxxx snmp_increment(DELETE_COUNT, 1); */ + } + else goto badcmd; + break; + + case 'M': + if (!strcmp(cmd.s, ""Myrights"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_myrights(tag.s, arg1.s); + + /* xxxx snmp_increment(MYRIGHTS_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Mupdatepush"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c == EOF) goto missingargs; + if(c == '\r') c = prot_getc(imapd_in); + if(c != '\n') goto extraargs; + cmd_mupdatepush(tag.s, arg1.s); + + /* xxxx snmp_increment(MUPDATEPUSH_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Move"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + move: + c = getword(imapd_in, &arg1); + if (c == '\r') goto missingargs; + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/1); + + snmp_increment(COPY_COUNT, 1); + } else goto badcmd; + break; + + case 'N': + if (!strcmp(cmd.s, ""Noop"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_noop(tag.s, cmd.s); + + /* xxxx snmp_increment(NOOP_COUNT, 1); */ + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Namespace"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_namespace(tag.s); + + /* xxxx snmp_increment(NAMESPACE_COUNT, 1); */ + } + else goto badcmd; + break; + + case 'R': + if (!strcmp(cmd.s, ""Rename"")) { + havepartition = 0; + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == ' ') { + havepartition = 1; + c = getword(imapd_in, &arg3); + if (!imparse_isatom(arg3.s)) goto badpartition; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_rename(tag.s, arg1.s, arg2.s, havepartition ? arg3.s : 0); + + /* xxxx snmp_increment(RENAME_COUNT, 1); */ + } else if(!strcmp(cmd.s, ""Reconstruct"")) { + recursive = 0; + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c == ' ') { + /* Optional RECURSEIVE argument */ + c = getword(imapd_in, &arg2); + if(!imparse_isatom(arg2.s)) + goto extraargs; + else if(!strcasecmp(arg2.s, ""RECURSIVE"")) + recursive = 1; + else + goto extraargs; + } + if(c == '\r') c = prot_getc(imapd_in); + if(c != '\n') goto extraargs; + cmd_reconstruct(tag.s, arg1.s, recursive); + + /* snmp_increment(RECONSTRUCT_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Rlist"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.sel = LIST_SEL_REMOTE; + listargs.ret = LIST_RET_CHILDREN; + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + + cmd_list(tag.s, &listargs); + +/* snmp_increment(LIST_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Rlsub"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.cmd = LIST_CMD_LSUB; + listargs.sel = LIST_SEL_REMOTE | LIST_SEL_SUBSCRIBED; + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + + cmd_list(tag.s, &listargs); + +/* snmp_increment(LSUB_COUNT, 1); */ + } +#ifdef HAVE_SSL + else if (!strcmp(cmd.s, ""Resetkey"")) { + int have_mbox = 0, have_mech = 0; + + if (c == ' ') { + have_mbox = 1; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == ' ') { + have_mech = 1; + c = getword(imapd_in, &arg2); + } + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_resetkey(tag.s, have_mbox ? arg1.s : 0, + have_mech ? arg2.s : 0); + /* snmp_increment(RESETKEY_COUNT, 1);*/ + } +#endif + else goto badcmd; + break; + + case 'S': + if (!strcmp(cmd.s, ""Starttls"")) { + if (!tls_enabled()) { + /* we don't support starttls */ + goto badcmd; + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + /* XXX discard any input pipelined after STARTTLS */ + prot_flush(imapd_in); + + /* if we've already done SASL fail */ + if (imapd_userid != NULL) { + prot_printf(imapd_out, + ""%s BAD Can't Starttls after authentication\r\n"", tag.s); + continue; + } + + /* if we've already done COMPRESS fail */ + if (imapd_compress_done == 1) { + prot_printf(imapd_out, + ""%s BAD Can't Starttls after Compress\r\n"", tag.s); + continue; + } + + /* check if already did a successful tls */ + if (imapd_starttls_done == 1) { + prot_printf(imapd_out, + ""%s BAD Already did a successful Starttls\r\n"", + tag.s); + continue; + } + cmd_starttls(tag.s, 0); + + snmp_increment(STARTTLS_COUNT, 1); + continue; + } + if (!imapd_userid) { + goto nologin; + } else if (!strcmp(cmd.s, ""Store"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + store: + c = getword(imapd_in, &arg1); + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + + cmd_store(tag.s, arg1.s, usinguid); + + snmp_increment(STORE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Select"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + prot_ungetc(c, imapd_in); + + cmd_select(tag.s, cmd.s, arg1.s); + + snmp_increment(SELECT_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Search"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + search: + + cmd_search(tag.s, usinguid); + + snmp_increment(SEARCH_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Subscribe"")) { + if (c != ' ') goto missingargs; + havenamespace = 0; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == ' ') { + havenamespace = 1; + c = getastring(imapd_in, imapd_out, &arg2); + } + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + if (havenamespace) { + cmd_changesub(tag.s, arg1.s, arg2.s, 1); + } + else { + cmd_changesub(tag.s, (char *)0, arg1.s, 1); + } + snmp_increment(SUBSCRIBE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setacl"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg3); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_setacl(tag.s, arg1.s, arg2.s, arg3.s); + + snmp_increment(SETACL_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setannotation"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_setannotation(tag.s, arg1.s); + + snmp_increment(SETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setmetadata"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_setmetadata(tag.s, arg1.s); + + snmp_increment(SETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setquota"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + cmd_setquota(tag.s, arg1.s); + + snmp_increment(SETQUOTA_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Sort"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + sort: + cmd_sort(tag.s, usinguid); + + snmp_increment(SORT_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Status"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + cmd_status(tag.s, arg1.s); + + snmp_increment(STATUS_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Scan"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg3); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + listargs.scan = arg3.s; + + cmd_list(tag.s, &listargs); + + snmp_increment(SCAN_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Syncapply"")) { + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { + cmd_syncapply(tag.s, kl, reserve_list); + dlist_free(&kl); + } + else goto extraargs; + } + else if (!strcmp(cmd.s, ""Syncget"")) { + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { + cmd_syncget(tag.s, kl); + dlist_free(&kl); + } + else goto extraargs; + } + else if (!strcmp(cmd.s, ""Syncrestart"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + /* just clear the GUID cache */ + cmd_syncrestart(tag.s, &reserve_list, 1); + } + else if (!strcmp(cmd.s, ""Syncrestore"")) { + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { + cmd_syncrestore(tag.s, kl, reserve_list); + dlist_free(&kl); + } + else goto extraargs; + } + else goto badcmd; + break; + + case 'T': + if (!strcmp(cmd.s, ""Thread"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + thread: + cmd_thread(tag.s, usinguid); + + snmp_increment(THREAD_COUNT, 1); + } + else goto badcmd; + break; + + case 'U': + if (!strcmp(cmd.s, ""Uid"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 1; + if (c != ' ') goto missingargs; + c = getword(imapd_in, &arg1); + if (c != ' ') goto missingargs; + lcase(arg1.s); + xstrncpy(cmdname, arg1.s, 99); + if (!strcmp(arg1.s, ""fetch"")) { + goto fetch; + } + else if (!strcmp(arg1.s, ""store"")) { + goto store; + } + else if (!strcmp(arg1.s, ""search"")) { + goto search; + } + else if (!strcmp(arg1.s, ""sort"")) { + goto sort; + } + else if (!strcmp(arg1.s, ""thread"")) { + goto thread; + } + else if (!strcmp(arg1.s, ""copy"")) { + goto copy; + } + else if (!strcmp(arg1.s, ""move"")) { + goto move; + } + else if (!strcmp(arg1.s, ""xmove"")) { + goto move; + } + else if (!strcmp(arg1.s, ""expunge"")) { + c = getword(imapd_in, &arg1); + if (!imparse_issequence(arg1.s)) goto badsequence; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_expunge(tag.s, arg1.s); + + snmp_increment(EXPUNGE_COUNT, 1); + } + else if (!strcmp(arg1.s, ""xrunannotator"")) { + goto xrunannotator; + } + else { + prot_printf(imapd_out, ""%s BAD Unrecognized UID subcommand\r\n"", tag.s); + eatline(imapd_in, c); + } + } + else if (!strcmp(cmd.s, ""Unsubscribe"")) { + if (c != ' ') goto missingargs; + havenamespace = 0; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == ' ') { + havenamespace = 1; + c = getastring(imapd_in, imapd_out, &arg2); + } + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + if (havenamespace) { + cmd_changesub(tag.s, arg1.s, arg2.s, 0); + } + else { + cmd_changesub(tag.s, (char *)0, arg1.s, 0); + } + + snmp_increment(UNSUBSCRIBE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Unselect"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_close(tag.s, cmd.s); + + snmp_increment(UNSELECT_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Undump"")) { + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + + /* we want to get a list at this point */ + if(c != ' ') goto missingargs; + + cmd_undump(tag.s, arg1.s); + /* snmp_increment(UNDUMP_COUNT, 1);*/ + } +#ifdef HAVE_SSL + else if (!strcmp(cmd.s, ""Urlfetch"")) { + if (c != ' ') goto missingargs; + + cmd_urlfetch(tag.s); + /* snmp_increment(URLFETCH_COUNT, 1);*/ + } +#endif + else goto badcmd; + break; + + case 'X': + if (!strcmp(cmd.s, ""Xbackup"")) { + int havechannel = 0; + + if (!config_getswitch(IMAPOPT_XBACKUP_ENABLED)) + goto badcmd; + + /* user */ + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + + /* channel */ + if (c == ' ') { + havechannel = 1; + c = getword(imapd_in, &arg2); + if (c == EOF) goto missingargs; + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_xbackup(tag.s, arg1.s, havechannel ? arg2.s : NULL); + + } + else if (!strcmp(cmd.s, ""Xconvfetch"")) { + cmd_xconvfetch(tag.s); + + } + else if (!strcmp(cmd.s, ""Xconvmultisort"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xconvmultisort(tag.s); + + } + else if (!strcmp(cmd.s, ""Xconvsort"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xconvsort(tag.s, 0); + + } + else if (!strcmp(cmd.s, ""Xconvupdates"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xconvsort(tag.s, 1); + + } + else if (!strcmp(cmd.s, ""Xfer"")) { + int havepartition = 0; + + /* Mailbox */ + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + + /* Dest Server */ + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + + if(c == ' ') { + /* Dest Partition */ + c = getastring(imapd_in, imapd_out, &arg3); + if (!imparse_isatom(arg3.s)) goto badpartition; + havepartition = 1; + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_xfer(tag.s, arg1.s, arg2.s, + (havepartition ? arg3.s : NULL)); + /* snmp_increment(XFER_COUNT, 1);*/ + } + else if (!strcmp(cmd.s, ""Xconvmeta"")) { + cmd_xconvmeta(tag.s); + } + else if (!strcmp(cmd.s, ""Xlist"")) { + struct listargs listargs; + + if (c != ' ') goto missingargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.cmd = LIST_CMD_XLIST; + listargs.ret = LIST_RET_CHILDREN | LIST_RET_SPECIALUSE; + getlistargs(tag.s, &listargs); + if (listargs.pat.count) cmd_list(tag.s, &listargs); + + snmp_increment(LIST_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Xmove"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + goto move; + } + else if (!strcmp(cmd.s, ""Xrunannotator"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + xrunannotator: + c = getword(imapd_in, &arg1); + if (!arg1.len || !imparse_issequence(arg1.s)) goto badsequence; + cmd_xrunannotator(tag.s, arg1.s, usinguid); + } + else if (!strcmp(cmd.s, ""Xsnippets"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xsnippets(tag.s); + + } + else if (!strcmp(cmd.s, ""Xstats"")) { + cmd_xstats(tag.s, c); + } + else if (!strcmp(cmd.s, ""Xwarmup"")) { + /* XWARMUP doesn't need a mailbox to be selected */ + if (c != ' ') goto missingargs; + cmd_xwarmup(tag.s); + } + else if (!strcmp(cmd.s, ""Xkillmy"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_xkillmy(tag.s, arg1.s); + } + else if (!strcmp(cmd.s, ""Xforever"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_xforever(tag.s); + } + else if (!strcmp(cmd.s, ""Xmeid"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_xmeid(tag.s, arg1.s); + } + + else if (apns_enabled && !strcmp(cmd.s, ""Xapplepushservice"")) { + if (c != ' ') goto missingargs; + + memset(&applepushserviceargs, 0, sizeof(struct applepushserviceargs)); + + do { + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto aps_missingargs; + + if (!strcmp(arg1.s, ""mailboxes"")) { + c = prot_getc(imapd_in); + if (c != '(') + goto aps_missingargs; + + c = prot_getc(imapd_in); + if (c != ')') { + prot_ungetc(c, imapd_in); + do { + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) break; + strarray_push(&applepushserviceargs.mailboxes, arg2.s); + } while (c == ' '); + } + + if (c != ')') + goto aps_missingargs; + c = prot_getc(imapd_in); + } + + else { + c = getastring(imapd_in, imapd_out, &arg2); + + if (!strcmp(arg1.s, ""aps-version"")) { + if (!imparse_isnumber(arg2.s)) goto aps_extraargs; + applepushserviceargs.aps_version = atoi(arg2.s); + } + else if (!strcmp(arg1.s, ""aps-account-id"")) + buf_copy(&applepushserviceargs.aps_account_id, &arg2); + else if (!strcmp(arg1.s, ""aps-device-token"")) + buf_copy(&applepushserviceargs.aps_device_token, &arg2); + else if (!strcmp(arg1.s, ""aps-subtopic"")) + buf_copy(&applepushserviceargs.aps_subtopic, &arg2); + else + goto aps_extraargs; + } + } while (c == ' '); + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto aps_extraargs; + + cmd_xapplepushservice(tag.s, &applepushserviceargs); + } + + else goto badcmd; + break; + + default: + badcmd: + prot_printf(imapd_out, ""%s BAD Unrecognized command\r\n"", tag.s); + eatline(imapd_in, c); + } + + /* End command timer - don't log ""idle"" commands */ + if (commandmintimer && strcmp(""idle"", cmdname)) { + double cmdtime, nettime; + const char *mboxname = index_mboxname(imapd_index); + if (!mboxname) mboxname = """"; + cmdtime_endtimer(&cmdtime, &nettime); + if (cmdtime >= commandmintimerd) { + syslog(LOG_NOTICE, ""cmdtimer: '%s' '%s' '%s' '%f' '%f' '%f'"", + imapd_userid ? imapd_userid : """", cmdname, mboxname, + cmdtime, nettime, cmdtime + nettime); + } + } + continue; + + nologin: + prot_printf(imapd_out, ""%s BAD Please login first\r\n"", tag.s); + eatline(imapd_in, c); + continue; + + nomailbox: + prot_printf(imapd_out, + ""%s BAD Please select a mailbox first\r\n"", tag.s); + eatline(imapd_in, c); + continue; + + aps_missingargs: + buf_free(&applepushserviceargs.aps_account_id); + buf_free(&applepushserviceargs.aps_device_token); + buf_free(&applepushserviceargs.aps_subtopic); + strarray_fini(&applepushserviceargs.mailboxes); + + missingargs: + prot_printf(imapd_out, + ""%s BAD Missing required argument to %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + + aps_extraargs: + buf_free(&applepushserviceargs.aps_account_id); + buf_free(&applepushserviceargs.aps_device_token); + buf_free(&applepushserviceargs.aps_subtopic); + strarray_fini(&applepushserviceargs.mailboxes); + + extraargs: + prot_printf(imapd_out, + ""%s BAD Unexpected extra arguments to %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + + badsequence: + prot_printf(imapd_out, + ""%s BAD Invalid sequence in %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + + badpartition: + prot_printf(imapd_out, + ""%s BAD Invalid partition name in %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + } + +done: + cmd_syncrestart(NULL, &reserve_list, 0); +} +",1,"static void cmdloop(void) +{ + int c; + int usinguid, havepartition, havenamespace, recursive; + static struct buf tag, cmd, arg1, arg2, arg3; + char *p, shut[MAX_MAILBOX_PATH+1], cmdname[100]; + const char *err; + const char * commandmintimer; + double commandmintimerd = 0.0; + struct sync_reserve_list *reserve_list = + sync_reserve_list_create(SYNC_MESSAGE_LIST_HASH_SIZE); + struct applepushserviceargs applepushserviceargs; + + prot_printf(imapd_out, ""* OK [CAPABILITY ""); + capa_response(CAPA_PREAUTH); + prot_printf(imapd_out, ""]""); + if (config_serverinfo) prot_printf(imapd_out, "" %s"", config_servername); + if (config_serverinfo == IMAP_ENUM_SERVERINFO_ON) { + prot_printf(imapd_out, "" Cyrus IMAP %s"", cyrus_version()); + } + prot_printf(imapd_out, "" server ready\r\n""); + + /* clear cancelled flag if present before the next command */ + cmd_cancelled(); + + motd_file(); + + /* Get command timer logging paramater. This string + * is a time in seconds. Any command that takes >= + * this time to execute is logged */ + commandmintimer = config_getstring(IMAPOPT_COMMANDMINTIMER); + cmdtime_settimer(commandmintimer ? 1 : 0); + if (commandmintimer) { + commandmintimerd = atof(commandmintimer); + } + + for (;;) { + /* Release any held index */ + index_release(imapd_index); + + /* Flush any buffered output */ + prot_flush(imapd_out); + if (backend_current) prot_flush(backend_current->out); + + /* command no longer running */ + proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), NULL); + + /* Check for shutdown file */ + if ( !imapd_userisadmin && imapd_userid && + (shutdown_file(shut, sizeof(shut)) || + userdeny(imapd_userid, config_ident, shut, sizeof(shut)))) { + for (p = shut; *p == '['; p++); /* can't have [ be first char */ + prot_printf(imapd_out, ""* BYE [ALERT] %s\r\n"", p); + telemetry_rusage(imapd_userid); + shut_down(0); + } + + signals_poll(); + + if (!proxy_check_input(protin, imapd_in, imapd_out, + backend_current ? backend_current->in : NULL, + NULL, 0)) { + /* No input from client */ + continue; + } + + /* Parse tag */ + c = getword(imapd_in, &tag); + if (c == EOF) { + if ((err = prot_error(imapd_in))!=NULL + && strcmp(err, PROT_EOF_STRING)) { + syslog(LOG_WARNING, ""%s, closing connection"", err); + prot_printf(imapd_out, ""* BYE %s\r\n"", err); + } + goto done; + } + if (c != ' ' || !imparse_isatom(tag.s) || (tag.s[0] == '*' && !tag.s[1])) { + prot_printf(imapd_out, ""* BAD Invalid tag\r\n""); + eatline(imapd_in, c); + continue; + } + + /* Parse command name */ + c = getword(imapd_in, &cmd); + if (!cmd.s[0]) { + prot_printf(imapd_out, ""%s BAD Null command\r\n"", tag.s); + eatline(imapd_in, c); + continue; + } + lcase(cmd.s); + xstrncpy(cmdname, cmd.s, 99); + cmd.s[0] = toupper((unsigned char) cmd.s[0]); + + if (config_getswitch(IMAPOPT_CHATTY)) + syslog(LOG_NOTICE, ""command: %s %s"", tag.s, cmd.s); + + proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), cmd.s); + + /* if we need to force a kick, do so */ + if (referral_kick) { + kick_mupdate(); + referral_kick = 0; + } + + if (plaintextloginalert) { + prot_printf(imapd_out, ""* OK [ALERT] %s\r\n"", + plaintextloginalert); + plaintextloginalert = NULL; + } + + /* Only Authenticate/Enable/Login/Logout/Noop/Capability/Id/Starttls + allowed when not logged in */ + if (!imapd_userid && !strchr(""AELNCIS"", cmd.s[0])) goto nologin; + + /* Start command timer */ + cmdtime_starttimer(); + + /* note that about half the commands (the common ones that don't + hit the mailboxes file) now close the mailboxes file just in + case it was open. */ + switch (cmd.s[0]) { + case 'A': + if (!strcmp(cmd.s, ""Authenticate"")) { + int haveinitresp = 0; + + if (c != ' ') goto missingargs; + c = getword(imapd_in, &arg1); + if (!imparse_isatom(arg1.s)) { + prot_printf(imapd_out, ""%s BAD Invalid authenticate mechanism\r\n"", tag.s); + eatline(imapd_in, c); + continue; + } + if (c == ' ') { + haveinitresp = 1; + c = getword(imapd_in, &arg2); + if (c == EOF) goto missingargs; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + if (imapd_userid) { + prot_printf(imapd_out, ""%s BAD Already authenticated\r\n"", tag.s); + continue; + } + cmd_authenticate(tag.s, arg1.s, haveinitresp ? arg2.s : NULL); + + snmp_increment(AUTHENTICATE_COUNT, 1); + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Append"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_append(tag.s, arg1.s, NULL); + + snmp_increment(APPEND_COUNT, 1); + } + else goto badcmd; + break; + + case 'C': + if (!strcmp(cmd.s, ""Capability"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_capability(tag.s); + + snmp_increment(CAPABILITY_COUNT, 1); + } + else if (!imapd_userid) goto nologin; +#ifdef HAVE_ZLIB + else if (!strcmp(cmd.s, ""Compress"")) { + if (c != ' ') goto missingargs; + c = getword(imapd_in, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_compress(tag.s, arg1.s); + + snmp_increment(COMPRESS_COUNT, 1); + } +#endif /* HAVE_ZLIB */ + else if (!strcmp(cmd.s, ""Check"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_noop(tag.s, cmd.s); + + snmp_increment(CHECK_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Copy"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + copy: + c = getword(imapd_in, &arg1); + if (c == '\r') goto missingargs; + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/0); + + snmp_increment(COPY_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Create"")) { + struct dlist *extargs = NULL; + + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == ' ') { + c = parsecreateargs(&extargs); + if (c == EOF) goto badpartition; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_create(tag.s, arg1.s, extargs, 0); + dlist_free(&extargs); + + snmp_increment(CREATE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Close"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_close(tag.s, cmd.s); + + snmp_increment(CLOSE_COUNT, 1); + } + else goto badcmd; + break; + + case 'D': + if (!strcmp(cmd.s, ""Delete"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_delete(tag.s, arg1.s, 0, 0); + + snmp_increment(DELETE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Deleteacl"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_setacl(tag.s, arg1.s, arg2.s, NULL); + + snmp_increment(DELETEACL_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Dump"")) { + int uid_start = 0; + + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c == ' ') { + c = getastring(imapd_in, imapd_out, &arg2); + if(!imparse_isnumber(arg2.s)) goto extraargs; + uid_start = atoi(arg2.s); + } + + if(c == '\r') c = prot_getc(imapd_in); + if(c != '\n') goto extraargs; + + cmd_dump(tag.s, arg1.s, uid_start); + /* snmp_increment(DUMP_COUNT, 1);*/ + } + else goto badcmd; + break; + + case 'E': + if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Enable"")) { + if (c != ' ') goto missingargs; + + cmd_enable(tag.s); + } + else if (!strcmp(cmd.s, ""Expunge"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_expunge(tag.s, 0); + + snmp_increment(EXPUNGE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Examine"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + prot_ungetc(c, imapd_in); + + cmd_select(tag.s, cmd.s, arg1.s); + + snmp_increment(EXAMINE_COUNT, 1); + } + else goto badcmd; + break; + + case 'F': + if (!strcmp(cmd.s, ""Fetch"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + fetch: + c = getword(imapd_in, &arg1); + if (c == '\r') goto missingargs; + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + + cmd_fetch(tag.s, arg1.s, usinguid); + + snmp_increment(FETCH_COUNT, 1); + } + else goto badcmd; + break; + + case 'G': + if (!strcmp(cmd.s, ""Getacl"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_getacl(tag.s, arg1.s); + + snmp_increment(GETACL_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getannotation"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_getannotation(tag.s, arg1.s); + + snmp_increment(GETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getmetadata"")) { + if (c != ' ') goto missingargs; + + cmd_getmetadata(tag.s); + + snmp_increment(GETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getquota"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_getquota(tag.s, arg1.s); + + snmp_increment(GETQUOTA_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Getquotaroot"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_getquotaroot(tag.s, arg1.s); + + snmp_increment(GETQUOTAROOT_COUNT, 1); + } +#ifdef HAVE_SSL + else if (!strcmp(cmd.s, ""Genurlauth"")) { + if (c != ' ') goto missingargs; + + cmd_genurlauth(tag.s); + /* snmp_increment(GENURLAUTH_COUNT, 1);*/ + } +#endif + else goto badcmd; + break; + + case 'I': + if (!strcmp(cmd.s, ""Id"")) { + if (c != ' ') goto missingargs; + cmd_id(tag.s); + + snmp_increment(ID_COUNT, 1); + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Idle"") && idle_enabled()) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_idle(tag.s); + + snmp_increment(IDLE_COUNT, 1); + } + else goto badcmd; + break; + + case 'L': + if (!strcmp(cmd.s, ""Login"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c != ' ') goto missingargs; + + cmd_login(tag.s, arg1.s); + + snmp_increment(LOGIN_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Logout"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + snmp_increment(LOGOUT_COUNT, 1); + + /* force any responses from our selected backend */ + if (backend_current) imapd_check(NULL, 0); + + prot_printf(imapd_out, ""* BYE %s\r\n"", + error_message(IMAP_BYE_LOGOUT)); + prot_printf(imapd_out, ""%s OK %s\r\n"", tag.s, + error_message(IMAP_OK_COMPLETED)); + + if (imapd_userid && *imapd_userid) { + telemetry_rusage(imapd_userid); + } + + goto done; + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""List"")) { + struct listargs listargs; + + if (c != ' ') goto missingargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.ret = LIST_RET_CHILDREN; + getlistargs(tag.s, &listargs); + if (listargs.pat.count) cmd_list(tag.s, &listargs); + + snmp_increment(LIST_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Lsub"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.cmd = LIST_CMD_LSUB; + listargs.sel = LIST_SEL_SUBSCRIBED; + if (!strcasecmpsafe(imapd_magicplus, ""+dav"")) + listargs.sel |= LIST_SEL_DAV; + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + + cmd_list(tag.s, &listargs); + + snmp_increment(LSUB_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Listrights"")) { + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_listrights(tag.s, arg1.s, arg2.s); + + snmp_increment(LISTRIGHTS_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Localappend"")) { + /* create a local-only mailbox */ + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c != ' ') goto missingargs; + + cmd_append(tag.s, arg1.s, *arg2.s ? arg2.s : NULL); + + snmp_increment(APPEND_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Localcreate"")) { + /* create a local-only mailbox */ + struct dlist *extargs = NULL; + + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == ' ') { + c = parsecreateargs(&extargs); + if (c == EOF) goto badpartition; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_create(tag.s, arg1.s, extargs, 1); + dlist_free(&extargs); + + /* xxxx snmp_increment(CREATE_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Localdelete"")) { + /* delete a mailbox locally only */ + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_delete(tag.s, arg1.s, 1, 1); + + /* xxxx snmp_increment(DELETE_COUNT, 1); */ + } + else goto badcmd; + break; + + case 'M': + if (!strcmp(cmd.s, ""Myrights"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_myrights(tag.s, arg1.s); + + /* xxxx snmp_increment(MYRIGHTS_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Mupdatepush"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c == EOF) goto missingargs; + if(c == '\r') c = prot_getc(imapd_in); + if(c != '\n') goto extraargs; + cmd_mupdatepush(tag.s, arg1.s); + + /* xxxx snmp_increment(MUPDATEPUSH_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Move"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + move: + c = getword(imapd_in, &arg1); + if (c == '\r') goto missingargs; + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/1); + + snmp_increment(COPY_COUNT, 1); + } else goto badcmd; + break; + + case 'N': + if (!strcmp(cmd.s, ""Noop"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_noop(tag.s, cmd.s); + + /* xxxx snmp_increment(NOOP_COUNT, 1); */ + } + else if (!imapd_userid) goto nologin; + else if (!strcmp(cmd.s, ""Namespace"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_namespace(tag.s); + + /* xxxx snmp_increment(NAMESPACE_COUNT, 1); */ + } + else goto badcmd; + break; + + case 'R': + if (!strcmp(cmd.s, ""Rename"")) { + havepartition = 0; + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) goto missingargs; + if (c == ' ') { + havepartition = 1; + c = getword(imapd_in, &arg3); + if (!imparse_isatom(arg3.s)) goto badpartition; + } + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_rename(tag.s, arg1.s, arg2.s, havepartition ? arg3.s : 0); + + /* xxxx snmp_increment(RENAME_COUNT, 1); */ + } else if(!strcmp(cmd.s, ""Reconstruct"")) { + recursive = 0; + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if(c == ' ') { + /* Optional RECURSEIVE argument */ + c = getword(imapd_in, &arg2); + if(!imparse_isatom(arg2.s)) + goto extraargs; + else if(!strcasecmp(arg2.s, ""RECURSIVE"")) + recursive = 1; + else + goto extraargs; + } + if(c == '\r') c = prot_getc(imapd_in); + if(c != '\n') goto extraargs; + cmd_reconstruct(tag.s, arg1.s, recursive); + + /* snmp_increment(RECONSTRUCT_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Rlist"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.sel = LIST_SEL_REMOTE; + listargs.ret = LIST_RET_CHILDREN; + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + + cmd_list(tag.s, &listargs); + +/* snmp_increment(LIST_COUNT, 1); */ + } + else if (!strcmp(cmd.s, ""Rlsub"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.cmd = LIST_CMD_LSUB; + listargs.sel = LIST_SEL_REMOTE | LIST_SEL_SUBSCRIBED; + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + + cmd_list(tag.s, &listargs); + +/* snmp_increment(LSUB_COUNT, 1); */ + } +#ifdef HAVE_SSL + else if (!strcmp(cmd.s, ""Resetkey"")) { + int have_mbox = 0, have_mech = 0; + + if (c == ' ') { + have_mbox = 1; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == ' ') { + have_mech = 1; + c = getword(imapd_in, &arg2); + } + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_resetkey(tag.s, have_mbox ? arg1.s : 0, + have_mech ? arg2.s : 0); + /* snmp_increment(RESETKEY_COUNT, 1);*/ + } +#endif + else goto badcmd; + break; + + case 'S': + if (!strcmp(cmd.s, ""Starttls"")) { + if (!tls_enabled()) { + /* we don't support starttls */ + goto badcmd; + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + /* XXX discard any input pipelined after STARTTLS */ + prot_flush(imapd_in); + + /* if we've already done SASL fail */ + if (imapd_userid != NULL) { + prot_printf(imapd_out, + ""%s BAD Can't Starttls after authentication\r\n"", tag.s); + continue; + } + + /* if we've already done COMPRESS fail */ + if (imapd_compress_done == 1) { + prot_printf(imapd_out, + ""%s BAD Can't Starttls after Compress\r\n"", tag.s); + continue; + } + + /* check if already did a successful tls */ + if (imapd_starttls_done == 1) { + prot_printf(imapd_out, + ""%s BAD Already did a successful Starttls\r\n"", + tag.s); + continue; + } + cmd_starttls(tag.s, 0); + + snmp_increment(STARTTLS_COUNT, 1); + continue; + } + if (!imapd_userid) { + goto nologin; + } else if (!strcmp(cmd.s, ""Store"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + store: + c = getword(imapd_in, &arg1); + if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; + + cmd_store(tag.s, arg1.s, usinguid); + + snmp_increment(STORE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Select"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + prot_ungetc(c, imapd_in); + + cmd_select(tag.s, cmd.s, arg1.s); + + snmp_increment(SELECT_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Search"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + search: + + cmd_search(tag.s, usinguid); + + snmp_increment(SEARCH_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Subscribe"")) { + if (c != ' ') goto missingargs; + havenamespace = 0; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == ' ') { + havenamespace = 1; + c = getastring(imapd_in, imapd_out, &arg2); + } + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + if (havenamespace) { + cmd_changesub(tag.s, arg1.s, arg2.s, 1); + } + else { + cmd_changesub(tag.s, (char *)0, arg1.s, 1); + } + snmp_increment(SUBSCRIBE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setacl"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg3); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_setacl(tag.s, arg1.s, arg2.s, arg3.s); + + snmp_increment(SETACL_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setannotation"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_setannotation(tag.s, arg1.s); + + snmp_increment(SETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setmetadata"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + + cmd_setmetadata(tag.s, arg1.s); + + snmp_increment(SETANNOTATION_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Setquota"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + cmd_setquota(tag.s, arg1.s); + + snmp_increment(SETQUOTA_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Sort"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + sort: + cmd_sort(tag.s, usinguid); + + snmp_increment(SORT_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Status"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + cmd_status(tag.s, arg1.s); + + snmp_increment(STATUS_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Scan"")) { + struct listargs listargs; + + c = getastring(imapd_in, imapd_out, &arg1); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg3); + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.ref = arg1.s; + strarray_append(&listargs.pat, arg2.s); + listargs.scan = arg3.s; + + cmd_list(tag.s, &listargs); + + snmp_increment(SCAN_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Syncapply"")) { + if (!imapd_userisadmin) goto badcmd; + + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { + cmd_syncapply(tag.s, kl, reserve_list); + dlist_free(&kl); + } + else goto extraargs; + } + else if (!strcmp(cmd.s, ""Syncget"")) { + if (!imapd_userisadmin) goto badcmd; + + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { + cmd_syncget(tag.s, kl); + dlist_free(&kl); + } + else goto extraargs; + } + else if (!strcmp(cmd.s, ""Syncrestart"")) { + if (!imapd_userisadmin) goto badcmd; + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + /* just clear the GUID cache */ + cmd_syncrestart(tag.s, &reserve_list, 1); + } + else if (!strcmp(cmd.s, ""Syncrestore"")) { + if (!imapd_userisadmin) goto badcmd; + + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { + cmd_syncrestore(tag.s, kl, reserve_list); + dlist_free(&kl); + } + else goto extraargs; + } + else goto badcmd; + break; + + case 'T': + if (!strcmp(cmd.s, ""Thread"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + thread: + cmd_thread(tag.s, usinguid); + + snmp_increment(THREAD_COUNT, 1); + } + else goto badcmd; + break; + + case 'U': + if (!strcmp(cmd.s, ""Uid"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 1; + if (c != ' ') goto missingargs; + c = getword(imapd_in, &arg1); + if (c != ' ') goto missingargs; + lcase(arg1.s); + xstrncpy(cmdname, arg1.s, 99); + if (!strcmp(arg1.s, ""fetch"")) { + goto fetch; + } + else if (!strcmp(arg1.s, ""store"")) { + goto store; + } + else if (!strcmp(arg1.s, ""search"")) { + goto search; + } + else if (!strcmp(arg1.s, ""sort"")) { + goto sort; + } + else if (!strcmp(arg1.s, ""thread"")) { + goto thread; + } + else if (!strcmp(arg1.s, ""copy"")) { + goto copy; + } + else if (!strcmp(arg1.s, ""move"")) { + goto move; + } + else if (!strcmp(arg1.s, ""xmove"")) { + goto move; + } + else if (!strcmp(arg1.s, ""expunge"")) { + c = getword(imapd_in, &arg1); + if (!imparse_issequence(arg1.s)) goto badsequence; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_expunge(tag.s, arg1.s); + + snmp_increment(EXPUNGE_COUNT, 1); + } + else if (!strcmp(arg1.s, ""xrunannotator"")) { + goto xrunannotator; + } + else { + prot_printf(imapd_out, ""%s BAD Unrecognized UID subcommand\r\n"", tag.s); + eatline(imapd_in, c); + } + } + else if (!strcmp(cmd.s, ""Unsubscribe"")) { + if (c != ' ') goto missingargs; + havenamespace = 0; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == ' ') { + havenamespace = 1; + c = getastring(imapd_in, imapd_out, &arg2); + } + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + if (havenamespace) { + cmd_changesub(tag.s, arg1.s, arg2.s, 0); + } + else { + cmd_changesub(tag.s, (char *)0, arg1.s, 0); + } + + snmp_increment(UNSUBSCRIBE_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Unselect"")) { + if (!imapd_index && !backend_current) goto nomailbox; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_close(tag.s, cmd.s); + + snmp_increment(UNSELECT_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Undump"")) { + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + + /* we want to get a list at this point */ + if(c != ' ') goto missingargs; + + cmd_undump(tag.s, arg1.s); + /* snmp_increment(UNDUMP_COUNT, 1);*/ + } +#ifdef HAVE_SSL + else if (!strcmp(cmd.s, ""Urlfetch"")) { + if (c != ' ') goto missingargs; + + cmd_urlfetch(tag.s); + /* snmp_increment(URLFETCH_COUNT, 1);*/ + } +#endif + else goto badcmd; + break; + + case 'X': + if (!strcmp(cmd.s, ""Xbackup"")) { + int havechannel = 0; + + if (!config_getswitch(IMAPOPT_XBACKUP_ENABLED)) + goto badcmd; + + /* user */ + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + + /* channel */ + if (c == ' ') { + havechannel = 1; + c = getword(imapd_in, &arg2); + if (c == EOF) goto missingargs; + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_xbackup(tag.s, arg1.s, havechannel ? arg2.s : NULL); + + } + else if (!strcmp(cmd.s, ""Xconvfetch"")) { + cmd_xconvfetch(tag.s); + + } + else if (!strcmp(cmd.s, ""Xconvmultisort"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xconvmultisort(tag.s); + + } + else if (!strcmp(cmd.s, ""Xconvsort"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xconvsort(tag.s, 0); + + } + else if (!strcmp(cmd.s, ""Xconvupdates"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xconvsort(tag.s, 1); + + } + else if (!strcmp(cmd.s, ""Xfer"")) { + int havepartition = 0; + + /* Mailbox */ + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + + /* Dest Server */ + if(c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg2); + + if(c == ' ') { + /* Dest Partition */ + c = getastring(imapd_in, imapd_out, &arg3); + if (!imparse_isatom(arg3.s)) goto badpartition; + havepartition = 1; + } + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + cmd_xfer(tag.s, arg1.s, arg2.s, + (havepartition ? arg3.s : NULL)); + /* snmp_increment(XFER_COUNT, 1);*/ + } + else if (!strcmp(cmd.s, ""Xconvmeta"")) { + cmd_xconvmeta(tag.s); + } + else if (!strcmp(cmd.s, ""Xlist"")) { + struct listargs listargs; + + if (c != ' ') goto missingargs; + + memset(&listargs, 0, sizeof(struct listargs)); + listargs.cmd = LIST_CMD_XLIST; + listargs.ret = LIST_RET_CHILDREN | LIST_RET_SPECIALUSE; + getlistargs(tag.s, &listargs); + if (listargs.pat.count) cmd_list(tag.s, &listargs); + + snmp_increment(LIST_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Xmove"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + goto move; + } + else if (!strcmp(cmd.s, ""Xrunannotator"")) { + if (!imapd_index && !backend_current) goto nomailbox; + usinguid = 0; + if (c != ' ') goto missingargs; + xrunannotator: + c = getword(imapd_in, &arg1); + if (!arg1.len || !imparse_issequence(arg1.s)) goto badsequence; + cmd_xrunannotator(tag.s, arg1.s, usinguid); + } + else if (!strcmp(cmd.s, ""Xsnippets"")) { + if (c != ' ') goto missingargs; + if (!imapd_index && !backend_current) goto nomailbox; + cmd_xsnippets(tag.s); + + } + else if (!strcmp(cmd.s, ""Xstats"")) { + cmd_xstats(tag.s, c); + } + else if (!strcmp(cmd.s, ""Xwarmup"")) { + /* XWARMUP doesn't need a mailbox to be selected */ + if (c != ' ') goto missingargs; + cmd_xwarmup(tag.s); + } + else if (!strcmp(cmd.s, ""Xkillmy"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_xkillmy(tag.s, arg1.s); + } + else if (!strcmp(cmd.s, ""Xforever"")) { + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_xforever(tag.s); + } + else if (!strcmp(cmd.s, ""Xmeid"")) { + if (c != ' ') goto missingargs; + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto missingargs; + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + cmd_xmeid(tag.s, arg1.s); + } + + else if (apns_enabled && !strcmp(cmd.s, ""Xapplepushservice"")) { + if (c != ' ') goto missingargs; + + memset(&applepushserviceargs, 0, sizeof(struct applepushserviceargs)); + + do { + c = getastring(imapd_in, imapd_out, &arg1); + if (c == EOF) goto aps_missingargs; + + if (!strcmp(arg1.s, ""mailboxes"")) { + c = prot_getc(imapd_in); + if (c != '(') + goto aps_missingargs; + + c = prot_getc(imapd_in); + if (c != ')') { + prot_ungetc(c, imapd_in); + do { + c = getastring(imapd_in, imapd_out, &arg2); + if (c == EOF) break; + strarray_push(&applepushserviceargs.mailboxes, arg2.s); + } while (c == ' '); + } + + if (c != ')') + goto aps_missingargs; + c = prot_getc(imapd_in); + } + + else { + c = getastring(imapd_in, imapd_out, &arg2); + + if (!strcmp(arg1.s, ""aps-version"")) { + if (!imparse_isnumber(arg2.s)) goto aps_extraargs; + applepushserviceargs.aps_version = atoi(arg2.s); + } + else if (!strcmp(arg1.s, ""aps-account-id"")) + buf_copy(&applepushserviceargs.aps_account_id, &arg2); + else if (!strcmp(arg1.s, ""aps-device-token"")) + buf_copy(&applepushserviceargs.aps_device_token, &arg2); + else if (!strcmp(arg1.s, ""aps-subtopic"")) + buf_copy(&applepushserviceargs.aps_subtopic, &arg2); + else + goto aps_extraargs; + } + } while (c == ' '); + + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto aps_extraargs; + + cmd_xapplepushservice(tag.s, &applepushserviceargs); + } + + else goto badcmd; + break; + + default: + badcmd: + prot_printf(imapd_out, ""%s BAD Unrecognized command\r\n"", tag.s); + eatline(imapd_in, c); + } + + /* End command timer - don't log ""idle"" commands */ + if (commandmintimer && strcmp(""idle"", cmdname)) { + double cmdtime, nettime; + const char *mboxname = index_mboxname(imapd_index); + if (!mboxname) mboxname = """"; + cmdtime_endtimer(&cmdtime, &nettime); + if (cmdtime >= commandmintimerd) { + syslog(LOG_NOTICE, ""cmdtimer: '%s' '%s' '%s' '%f' '%f' '%f'"", + imapd_userid ? imapd_userid : """", cmdname, mboxname, + cmdtime, nettime, cmdtime + nettime); + } + } + continue; + + nologin: + prot_printf(imapd_out, ""%s BAD Please login first\r\n"", tag.s); + eatline(imapd_in, c); + continue; + + nomailbox: + prot_printf(imapd_out, + ""%s BAD Please select a mailbox first\r\n"", tag.s); + eatline(imapd_in, c); + continue; + + aps_missingargs: + buf_free(&applepushserviceargs.aps_account_id); + buf_free(&applepushserviceargs.aps_device_token); + buf_free(&applepushserviceargs.aps_subtopic); + strarray_fini(&applepushserviceargs.mailboxes); + + missingargs: + prot_printf(imapd_out, + ""%s BAD Missing required argument to %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + + aps_extraargs: + buf_free(&applepushserviceargs.aps_account_id); + buf_free(&applepushserviceargs.aps_device_token); + buf_free(&applepushserviceargs.aps_subtopic); + strarray_fini(&applepushserviceargs.mailboxes); + + extraargs: + prot_printf(imapd_out, + ""%s BAD Unexpected extra arguments to %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + + badsequence: + prot_printf(imapd_out, + ""%s BAD Invalid sequence in %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + + badpartition: + prot_printf(imapd_out, + ""%s BAD Invalid partition name in %s\r\n"", tag.s, cmd.s); + eatline(imapd_in, c); + continue; + } + +done: + cmd_syncrestart(NULL, &reserve_list, 0); +} +","@@ -2062,6 +2062,8 @@ static void cmdloop(void) + snmp_increment(SCAN_COUNT, 1); + } + else if (!strcmp(cmd.s, ""Syncapply"")) { ++ if (!imapd_userisadmin) goto badcmd; ++ + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { +@@ -2071,6 +2073,8 @@ static void cmdloop(void) + else goto extraargs; + } + else if (!strcmp(cmd.s, ""Syncget"")) { ++ if (!imapd_userisadmin) goto badcmd; ++ + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) { +@@ -2080,13 +2084,17 @@ static void cmdloop(void) + else goto extraargs; + } + else if (!strcmp(cmd.s, ""Syncrestart"")) { ++ if (!imapd_userisadmin) goto badcmd; ++ + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') goto extraargs; + + /* just clear the GUID cache */ + cmd_syncrestart(tag.s, &reserve_list, 1); + } + else if (!strcmp(cmd.s, ""Syncrestore"")) { ++ if (!imapd_userisadmin) goto badcmd; ++ + struct dlist *kl = sync_parseline(imapd_in); + + if (kl) {",11261,11497,28000 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.pkl new file mode 100644 index 0000000000000000000000000000000000000000..6c981e01ed9f3190f3bdf61e1a557d64a74794aa --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6785456ec8deb5783b77c1d2b3f768d19a768d2659de3d1faeaec9239ac9dde +size 234947 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.csv new file mode 100644 index 0000000000000000000000000000000000000000..2c00044a030aa1f15ac05e413587acbe302d5447 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.csv @@ -0,0 +1,83658 @@ +idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting +1011,"void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx) +{ + enum ht_state state; /* updated only when leaving the FSM */ + register char *ptr, *end; /* request pointers, to avoid dereferences */ + struct buffer *buf; + + state = msg->msg_state; + buf = msg->chn->buf; + ptr = buf->p + msg->next; + end = buf->p + buf->i; + + if (unlikely(ptr >= end)) + goto http_msg_ood; + + switch (state) { + /* + * First, states that are specific to the response only. + * We check them first so that request and headers are + * closer to each other (accessed more often). + */ + case HTTP_MSG_RPBEFORE: + http_msg_rpbefore: + if (likely(HTTP_IS_TOKEN(*ptr))) { + /* we have a start of message, but we have to check + * first if we need to remove some CRLF. We can only + * do this when o=0. + */ + if (unlikely(ptr != buf->p)) { + if (buf->o) + goto http_msg_ood; + /* Remove empty leading lines, as recommended by RFC2616. */ + bi_fast_delete(buf, ptr - buf->p); + } + msg->sol = 0; + msg->sl.st.l = 0; /* used in debug mode */ + hdr_idx_init(idx); + state = HTTP_MSG_RPVER; + goto http_msg_rpver; + } + + if (unlikely(!HTTP_IS_CRLF(*ptr))) + goto http_msg_invalid; + + if (unlikely(*ptr == '\n')) + EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore, HTTP_MSG_RPBEFORE); + EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore_cr, HTTP_MSG_RPBEFORE_CR); + /* stop here */ + + case HTTP_MSG_RPBEFORE_CR: + http_msg_rpbefore_cr: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore, HTTP_MSG_RPBEFORE); + /* stop here */ + + case HTTP_MSG_RPVER: + http_msg_rpver: + case HTTP_MSG_RPVER_SP: + case HTTP_MSG_RPCODE: + case HTTP_MSG_RPCODE_SP: + case HTTP_MSG_RPREASON: + ptr = (char *)http_parse_stsline(msg, + state, ptr, end, + &msg->next, &msg->msg_state); + if (unlikely(!ptr)) + return; + + /* we have a full response and we know that we have either a CR + * or an LF at . + */ + hdr_idx_set_start(idx, msg->sl.st.l, *ptr == '\r'); + + msg->sol = ptr - buf->p; + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_rpline_end, HTTP_MSG_RPLINE_END); + goto http_msg_rpline_end; + + case HTTP_MSG_RPLINE_END: + http_msg_rpline_end: + /* msg->sol must point to the first of CR or LF. */ + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_first, HTTP_MSG_HDR_FIRST); + /* stop here */ + + /* + * Second, states that are specific to the request only + */ + case HTTP_MSG_RQBEFORE: + http_msg_rqbefore: + if (likely(HTTP_IS_TOKEN(*ptr))) { + /* we have a start of message, but we have to check + * first if we need to remove some CRLF. We can only + * do this when o=0. + */ + if (likely(ptr != buf->p)) { + if (buf->o) + goto http_msg_ood; + /* Remove empty leading lines, as recommended by RFC2616. */ + bi_fast_delete(buf, ptr - buf->p); + } + msg->sol = 0; + msg->sl.rq.l = 0; /* used in debug mode */ + state = HTTP_MSG_RQMETH; + goto http_msg_rqmeth; + } + + if (unlikely(!HTTP_IS_CRLF(*ptr))) + goto http_msg_invalid; + + if (unlikely(*ptr == '\n')) + EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore, HTTP_MSG_RQBEFORE); + EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore_cr, HTTP_MSG_RQBEFORE_CR); + /* stop here */ + + case HTTP_MSG_RQBEFORE_CR: + http_msg_rqbefore_cr: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore, HTTP_MSG_RQBEFORE); + /* stop here */ + + case HTTP_MSG_RQMETH: + http_msg_rqmeth: + case HTTP_MSG_RQMETH_SP: + case HTTP_MSG_RQURI: + case HTTP_MSG_RQURI_SP: + case HTTP_MSG_RQVER: + ptr = (char *)http_parse_reqline(msg, + state, ptr, end, + &msg->next, &msg->msg_state); + if (unlikely(!ptr)) + return; + + /* we have a full request and we know that we have either a CR + * or an LF at . + */ + hdr_idx_set_start(idx, msg->sl.rq.l, *ptr == '\r'); + + msg->sol = ptr - buf->p; + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_rqline_end, HTTP_MSG_RQLINE_END); + goto http_msg_rqline_end; + + case HTTP_MSG_RQLINE_END: + http_msg_rqline_end: + /* check for HTTP/0.9 request : no version information available. + * msg->sol must point to the first of CR or LF. + */ + if (unlikely(msg->sl.rq.v_l == 0)) + goto http_msg_last_lf; + + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_first, HTTP_MSG_HDR_FIRST); + /* stop here */ + + /* + * Common states below + */ + case HTTP_MSG_HDR_FIRST: + http_msg_hdr_first: + msg->sol = ptr - buf->p; + if (likely(!HTTP_IS_CRLF(*ptr))) { + goto http_msg_hdr_name; + } + + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_last_lf, HTTP_MSG_LAST_LF); + goto http_msg_last_lf; + + case HTTP_MSG_HDR_NAME: + http_msg_hdr_name: + /* assumes msg->sol points to the first char */ + if (likely(HTTP_IS_TOKEN(*ptr))) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_name, HTTP_MSG_HDR_NAME); + + if (likely(*ptr == ':')) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_sp, HTTP_MSG_HDR_L1_SP); + + if (likely(msg->err_pos < -1) || *ptr == '\n') + goto http_msg_invalid; + + if (msg->err_pos == -1) /* capture error pointer */ + msg->err_pos = ptr - buf->p; /* >= 0 now */ + + /* and we still accept this non-token character */ + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_name, HTTP_MSG_HDR_NAME); + + case HTTP_MSG_HDR_L1_SP: + http_msg_hdr_l1_sp: + /* assumes msg->sol points to the first char */ + if (likely(HTTP_IS_SPHT(*ptr))) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_sp, HTTP_MSG_HDR_L1_SP); + + /* header value can be basically anything except CR/LF */ + msg->sov = ptr - buf->p; + + if (likely(!HTTP_IS_CRLF(*ptr))) { + goto http_msg_hdr_val; + } + + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_lf, HTTP_MSG_HDR_L1_LF); + goto http_msg_hdr_l1_lf; + + case HTTP_MSG_HDR_L1_LF: + http_msg_hdr_l1_lf: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_lws, HTTP_MSG_HDR_L1_LWS); + + case HTTP_MSG_HDR_L1_LWS: + http_msg_hdr_l1_lws: + if (likely(HTTP_IS_SPHT(*ptr))) { + /* replace HT,CR,LF with spaces */ + for (; buf->p + msg->sov < ptr; msg->sov++) + buf->p[msg->sov] = ' '; + goto http_msg_hdr_l1_sp; + } + /* we had a header consisting only in spaces ! */ + msg->eol = msg->sov; + goto http_msg_complete_header; + + case HTTP_MSG_HDR_VAL: + http_msg_hdr_val: + /* assumes msg->sol points to the first char, and msg->sov + * points to the first character of the value. + */ + if (likely(!HTTP_IS_CRLF(*ptr))) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_val, HTTP_MSG_HDR_VAL); + + msg->eol = ptr - buf->p; + /* Note: we could also copy eol into ->eoh so that we have the + * real header end in case it ends with lots of LWS, but is this + * really needed ? + */ + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l2_lf, HTTP_MSG_HDR_L2_LF); + goto http_msg_hdr_l2_lf; + + case HTTP_MSG_HDR_L2_LF: + http_msg_hdr_l2_lf: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l2_lws, HTTP_MSG_HDR_L2_LWS); + + case HTTP_MSG_HDR_L2_LWS: + http_msg_hdr_l2_lws: + if (unlikely(HTTP_IS_SPHT(*ptr))) { + /* LWS: replace HT,CR,LF with spaces */ + for (; buf->p + msg->eol < ptr; msg->eol++) + buf->p[msg->eol] = ' '; + goto http_msg_hdr_val; + } + http_msg_complete_header: + /* + * It was a new header, so the last one is finished. + * Assumes msg->sol points to the first char, msg->sov points + * to the first character of the value and msg->eol to the + * first CR or LF so we know how the line ends. We insert last + * header into the index. + */ + if (unlikely(hdr_idx_add(msg->eol - msg->sol, buf->p[msg->eol] == '\r', + idx, idx->tail) < 0)) + goto http_msg_invalid; + + msg->sol = ptr - buf->p; + if (likely(!HTTP_IS_CRLF(*ptr))) { + goto http_msg_hdr_name; + } + + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_last_lf, HTTP_MSG_LAST_LF); + goto http_msg_last_lf; + + case HTTP_MSG_LAST_LF: + http_msg_last_lf: + /* Assumes msg->sol points to the first of either CR or LF. + * Sets ->sov and ->next to the total header length, ->eoh to + * the last CRLF, and ->eol to the last CRLF length (1 or 2). + */ + EXPECT_LF_HERE(ptr, http_msg_invalid); + ptr++; + msg->sov = msg->next = ptr - buf->p; + msg->eoh = msg->sol; + msg->sol = 0; + msg->eol = msg->sov - msg->eoh; + msg->msg_state = HTTP_MSG_BODY; + return; + + case HTTP_MSG_ERROR: + /* this may only happen if we call http_msg_analyser() twice with an error */ + break; + + default: +#ifdef DEBUG_FULL + fprintf(stderr, ""FIXME !!!! impossible state at %s:%d = %d\n"", __FILE__, __LINE__, state); + exit(1); +#endif + ; + } + http_msg_ood: + /* out of data */ + msg->msg_state = state; + msg->next = ptr - buf->p; + return; + + http_msg_invalid: + /* invalid message */ + msg->msg_state = HTTP_MSG_ERROR; + msg->next = ptr - buf->p; + return; +} +",0,"void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx) +{ + enum ht_state state; /* updated only when leaving the FSM */ + register char *ptr, *end; /* request pointers, to avoid dereferences */ + struct buffer *buf; + + state = msg->msg_state; + buf = msg->chn->buf; + ptr = buf->p + msg->next; + end = buf->p + buf->i; + + if (unlikely(ptr >= end)) + goto http_msg_ood; + + switch (state) { + /* + * First, states that are specific to the response only. + * We check them first so that request and headers are + * closer to each other (accessed more often). + */ + case HTTP_MSG_RPBEFORE: + http_msg_rpbefore: + if (likely(HTTP_IS_TOKEN(*ptr))) { + /* we have a start of message, but we have to check + * first if we need to remove some CRLF. We can only + * do this when o=0. + */ + if (unlikely(ptr != buf->p)) { + if (buf->o) + goto http_msg_ood; + /* Remove empty leading lines, as recommended by RFC2616. */ + bi_fast_delete(buf, ptr - buf->p); + } + msg->sol = 0; + msg->sl.st.l = 0; /* used in debug mode */ + hdr_idx_init(idx); + state = HTTP_MSG_RPVER; + goto http_msg_rpver; + } + + if (unlikely(!HTTP_IS_CRLF(*ptr))) + goto http_msg_invalid; + + if (unlikely(*ptr == '\n')) + EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore, HTTP_MSG_RPBEFORE); + EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore_cr, HTTP_MSG_RPBEFORE_CR); + /* stop here */ + + case HTTP_MSG_RPBEFORE_CR: + http_msg_rpbefore_cr: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore, HTTP_MSG_RPBEFORE); + /* stop here */ + + case HTTP_MSG_RPVER: + http_msg_rpver: + case HTTP_MSG_RPVER_SP: + case HTTP_MSG_RPCODE: + case HTTP_MSG_RPCODE_SP: + case HTTP_MSG_RPREASON: + ptr = (char *)http_parse_stsline(msg, + state, ptr, end, + &msg->next, &msg->msg_state); + if (unlikely(!ptr)) + return; + + /* we have a full response and we know that we have either a CR + * or an LF at . + */ + hdr_idx_set_start(idx, msg->sl.st.l, *ptr == '\r'); + + msg->sol = ptr - buf->p; + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_rpline_end, HTTP_MSG_RPLINE_END); + goto http_msg_rpline_end; + + case HTTP_MSG_RPLINE_END: + http_msg_rpline_end: + /* msg->sol must point to the first of CR or LF. */ + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_first, HTTP_MSG_HDR_FIRST); + /* stop here */ + + /* + * Second, states that are specific to the request only + */ + case HTTP_MSG_RQBEFORE: + http_msg_rqbefore: + if (likely(HTTP_IS_TOKEN(*ptr))) { + /* we have a start of message, but we have to check + * first if we need to remove some CRLF. We can only + * do this when o=0. + */ + if (likely(ptr != buf->p)) { + if (buf->o) + goto http_msg_ood; + /* Remove empty leading lines, as recommended by RFC2616. */ + bi_fast_delete(buf, ptr - buf->p); + } + msg->sol = 0; + msg->sl.rq.l = 0; /* used in debug mode */ + state = HTTP_MSG_RQMETH; + goto http_msg_rqmeth; + } + + if (unlikely(!HTTP_IS_CRLF(*ptr))) + goto http_msg_invalid; + + if (unlikely(*ptr == '\n')) + EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore, HTTP_MSG_RQBEFORE); + EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore_cr, HTTP_MSG_RQBEFORE_CR); + /* stop here */ + + case HTTP_MSG_RQBEFORE_CR: + http_msg_rqbefore_cr: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore, HTTP_MSG_RQBEFORE); + /* stop here */ + + case HTTP_MSG_RQMETH: + http_msg_rqmeth: + case HTTP_MSG_RQMETH_SP: + case HTTP_MSG_RQURI: + case HTTP_MSG_RQURI_SP: + case HTTP_MSG_RQVER: + ptr = (char *)http_parse_reqline(msg, + state, ptr, end, + &msg->next, &msg->msg_state); + if (unlikely(!ptr)) + return; + + /* we have a full request and we know that we have either a CR + * or an LF at . + */ + hdr_idx_set_start(idx, msg->sl.rq.l, *ptr == '\r'); + + msg->sol = ptr - buf->p; + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_rqline_end, HTTP_MSG_RQLINE_END); + goto http_msg_rqline_end; + + case HTTP_MSG_RQLINE_END: + http_msg_rqline_end: + /* check for HTTP/0.9 request : no version information available. + * msg->sol must point to the first of CR or LF. + */ + if (unlikely(msg->sl.rq.v_l == 0)) + goto http_msg_last_lf; + + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_first, HTTP_MSG_HDR_FIRST); + /* stop here */ + + /* + * Common states below + */ + case HTTP_MSG_HDR_FIRST: + http_msg_hdr_first: + msg->sol = ptr - buf->p; + if (likely(!HTTP_IS_CRLF(*ptr))) { + goto http_msg_hdr_name; + } + + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_last_lf, HTTP_MSG_LAST_LF); + goto http_msg_last_lf; + + case HTTP_MSG_HDR_NAME: + http_msg_hdr_name: + /* assumes msg->sol points to the first char */ + if (likely(HTTP_IS_TOKEN(*ptr))) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_name, HTTP_MSG_HDR_NAME); + + if (likely(*ptr == ':')) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_sp, HTTP_MSG_HDR_L1_SP); + + if (likely(msg->err_pos < -1) || *ptr == '\n') + goto http_msg_invalid; + + if (msg->err_pos == -1) /* capture error pointer */ + msg->err_pos = ptr - buf->p; /* >= 0 now */ + + /* and we still accept this non-token character */ + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_name, HTTP_MSG_HDR_NAME); + + case HTTP_MSG_HDR_L1_SP: + http_msg_hdr_l1_sp: + /* assumes msg->sol points to the first char */ + if (likely(HTTP_IS_SPHT(*ptr))) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_sp, HTTP_MSG_HDR_L1_SP); + + /* header value can be basically anything except CR/LF */ + msg->sov = ptr - buf->p; + + if (likely(!HTTP_IS_CRLF(*ptr))) { + goto http_msg_hdr_val; + } + + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_lf, HTTP_MSG_HDR_L1_LF); + goto http_msg_hdr_l1_lf; + + case HTTP_MSG_HDR_L1_LF: + http_msg_hdr_l1_lf: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_lws, HTTP_MSG_HDR_L1_LWS); + + case HTTP_MSG_HDR_L1_LWS: + http_msg_hdr_l1_lws: + if (likely(HTTP_IS_SPHT(*ptr))) { + /* replace HT,CR,LF with spaces */ + for (; buf->p + msg->sov < ptr; msg->sov++) + buf->p[msg->sov] = ' '; + goto http_msg_hdr_l1_sp; + } + /* we had a header consisting only in spaces ! */ + msg->eol = msg->sov; + goto http_msg_complete_header; + + case HTTP_MSG_HDR_VAL: + http_msg_hdr_val: + /* assumes msg->sol points to the first char, and msg->sov + * points to the first character of the value. + */ + if (likely(!HTTP_IS_CRLF(*ptr))) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_val, HTTP_MSG_HDR_VAL); + + msg->eol = ptr - buf->p; + /* Note: we could also copy eol into ->eoh so that we have the + * real header end in case it ends with lots of LWS, but is this + * really needed ? + */ + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l2_lf, HTTP_MSG_HDR_L2_LF); + goto http_msg_hdr_l2_lf; + + case HTTP_MSG_HDR_L2_LF: + http_msg_hdr_l2_lf: + EXPECT_LF_HERE(ptr, http_msg_invalid); + EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l2_lws, HTTP_MSG_HDR_L2_LWS); + + case HTTP_MSG_HDR_L2_LWS: + http_msg_hdr_l2_lws: + if (unlikely(HTTP_IS_SPHT(*ptr))) { + /* LWS: replace HT,CR,LF with spaces */ + for (; buf->p + msg->eol < ptr; msg->eol++) + buf->p[msg->eol] = ' '; + goto http_msg_hdr_val; + } + http_msg_complete_header: + /* + * It was a new header, so the last one is finished. + * Assumes msg->sol points to the first char, msg->sov points + * to the first character of the value and msg->eol to the + * first CR or LF so we know how the line ends. We insert last + * header into the index. + */ + if (unlikely(hdr_idx_add(msg->eol - msg->sol, buf->p[msg->eol] == '\r', + idx, idx->tail) < 0)) + goto http_msg_invalid; + + msg->sol = ptr - buf->p; + if (likely(!HTTP_IS_CRLF(*ptr))) { + goto http_msg_hdr_name; + } + + if (likely(*ptr == '\r')) + EAT_AND_JUMP_OR_RETURN(http_msg_last_lf, HTTP_MSG_LAST_LF); + goto http_msg_last_lf; + + case HTTP_MSG_LAST_LF: + http_msg_last_lf: + /* Assumes msg->sol points to the first of either CR or LF. + * Sets ->sov and ->next to the total header length, ->eoh to + * the last CRLF, and ->eol to the last CRLF length (1 or 2). + */ + EXPECT_LF_HERE(ptr, http_msg_invalid); + ptr++; + msg->sov = msg->next = ptr - buf->p; + msg->eoh = msg->sol; + msg->sol = 0; + msg->eol = msg->sov - msg->eoh; + msg->msg_state = HTTP_MSG_BODY; + return; + + case HTTP_MSG_ERROR: + /* this may only happen if we call http_msg_analyser() twice with an error */ + break; + + default: +#ifdef DEBUG_FULL + fprintf(stderr, ""FIXME !!!! impossible state at %s:%d = %d\n"", __FILE__, __LINE__, state); + exit(1); +#endif + ; + } + http_msg_ood: + /* out of data */ + msg->msg_state = state; + msg->next = ptr - buf->p; + return; + + http_msg_invalid: + /* invalid message */ + msg->msg_state = HTTP_MSG_ERROR; + msg->next = ptr - buf->p; + return; +} +","@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) + s->req->cons->conn_retries = 0; /* used for logging too */ + s->req->cons->exp = TICK_ETERNITY; + s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ +- s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); +- s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); ++ s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); ++ s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); + s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); + s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); + +@@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit + * such as last chunk of data or trailers. + */ + b_adv(req->buf, msg->next); +- if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) ++ if (unlikely(!(s->req->flags & CF_WROTE_DATA))) + msg->sov -= msg->next; + msg->next = 0; + +@@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit + missing_data: + /* we may have some pending data starting at req->buf->p */ + b_adv(req->buf, msg->next); +- if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) ++ if (unlikely(!(s->req->flags & CF_WROTE_DATA))) + msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); + + msg->next = 0;",2668,2904,4096 +18032,"MagickExport MagickBooleanType DrawPrimitive(Image *image, + const DrawInfo *draw_info,const PrimitiveInfo *primitive_info, + ExceptionInfo *exception) +{ + CacheView + *image_view; + + MagickStatusType + status; + + register ssize_t + i, + x; + + ssize_t + y; + + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(DrawEvent,GetMagickModule(), + "" begin draw-primitive""); + (void) LogMagickEvent(DrawEvent,GetMagickModule(), + "" affine: %g %g %g %g %g %g"",draw_info->affine.sx, + draw_info->affine.rx,draw_info->affine.ry,draw_info->affine.sy, + draw_info->affine.tx,draw_info->affine.ty); + } + if ((IsGrayColorspace(image->colorspace) != MagickFalse) && + ((IsPixelInfoGray(&draw_info->fill) == MagickFalse) || + (IsPixelInfoGray(&draw_info->stroke) == MagickFalse))) + (void) SetImageColorspace(image,sRGBColorspace,exception); + status=MagickTrue; + x=(ssize_t) ceil(primitive_info->point.x-0.5); + y=(ssize_t) ceil(primitive_info->point.y-0.5); + image_view=AcquireAuthenticCacheView(image,exception); + switch (primitive_info->primitive) + { + case AlphaPrimitive: + { + if (image->alpha_trait == UndefinedPixelTrait) + (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); + switch (primitive_info->method) + { + case PointMethod: + default: + { + PixelInfo + pixel; + + register Quantum + *q; + + q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); + if (q == (Quantum *) NULL) + break; + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + (void) SyncCacheViewAuthenticPixels(image_view,exception); + break; + } + case ReplaceMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel, + target; + + (void) GetOneCacheViewVirtualPixelInfo(image_view,x,y,&target, + exception); + GetPixelInfo(image,&pixel); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetPixelInfoPixel(image,q,&pixel); + if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse) + { + q+=GetPixelChannels(image); + continue; + } + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + case FloodfillMethod: + case FillToBorderMethod: + { + ChannelType + channel_mask; + + PixelInfo + target; + + (void) GetOneVirtualPixelInfo(image,TileVirtualPixelMethod,x,y, + &target,exception); + if (primitive_info->method == FillToBorderMethod) + { + target.red=(double) draw_info->border_color.red; + target.green=(double) draw_info->border_color.green; + target.blue=(double) draw_info->border_color.blue; + } + channel_mask=SetImageChannelMask(image,AlphaChannel); + status&=FloodfillPaintImage(image,draw_info,&target,x,y, + primitive_info->method == FloodfillMethod ? MagickFalse : + MagickTrue,exception); + (void) SetImageChannelMask(image,channel_mask); + break; + } + case ResetMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel; + + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + } + break; + } + case ColorPrimitive: + { + switch (primitive_info->method) + { + case PointMethod: + default: + { + PixelInfo + pixel; + + register Quantum + *q; + + q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); + if (q == (Quantum *) NULL) + break; + GetPixelInfo(image,&pixel); + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelViaPixelInfo(image,&pixel,q); + (void) SyncCacheViewAuthenticPixels(image_view,exception); + break; + } + case ReplaceMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel, + target; + + (void) GetOneCacheViewVirtualPixelInfo(image_view,x,y,&target, + exception); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetPixelInfoPixel(image,q,&pixel); + if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse) + { + q+=GetPixelChannels(image); + continue; + } + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelViaPixelInfo(image,&pixel,q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + case FloodfillMethod: + case FillToBorderMethod: + { + PixelInfo + target; + + (void) GetOneVirtualPixelInfo(image,TileVirtualPixelMethod,x,y, + &target,exception); + if (primitive_info->method == FillToBorderMethod) + { + target.red=(double) draw_info->border_color.red; + target.green=(double) draw_info->border_color.green; + target.blue=(double) draw_info->border_color.blue; + } + status&=FloodfillPaintImage(image,draw_info,&target,x,y, + primitive_info->method == FloodfillMethod ? MagickFalse : + MagickTrue,exception); + break; + } + case ResetMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel; + + GetPixelInfo(image,&pixel); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelViaPixelInfo(image,&pixel,q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + } + break; + } + case ImagePrimitive: + { + AffineMatrix + affine; + + char + composite_geometry[MagickPathExtent]; + + Image + *composite_image; + + ImageInfo + *clone_info; + + RectangleInfo + geometry; + + ssize_t + x1, + y1; + + if (primitive_info->text == (char *) NULL) + break; + clone_info=AcquireImageInfo(); + if (LocaleNCompare(primitive_info->text,""data:"",5) == 0) + composite_image=ReadInlineImage(clone_info,primitive_info->text, + exception); + else + { + (void) CopyMagickString(clone_info->filename,primitive_info->text, + MagickPathExtent); + composite_image=ReadImage(clone_info,exception); + } + clone_info=DestroyImageInfo(clone_info); + if (composite_image == (Image *) NULL) + break; + (void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor) + NULL,(void *) NULL); + x1=(ssize_t) ceil(primitive_info[1].point.x-0.5); + y1=(ssize_t) ceil(primitive_info[1].point.y-0.5); + if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) || + ((y1 != 0L) && (y1 != (ssize_t) composite_image->rows))) + { + /* + Resize image. + */ + (void) FormatLocaleString(composite_geometry,MagickPathExtent, + ""%gx%g!"",primitive_info[1].point.x,primitive_info[1].point.y); + composite_image->filter=image->filter; + (void) TransformImage(&composite_image,(char *) NULL, + composite_geometry,exception); + } + if (composite_image->alpha_trait == UndefinedPixelTrait) + (void) SetImageAlphaChannel(composite_image,OpaqueAlphaChannel, + exception); + if (draw_info->alpha != OpaqueAlpha) + (void) SetImageAlpha(composite_image,draw_info->alpha,exception); + SetGeometry(image,&geometry); + image->gravity=draw_info->gravity; + geometry.x=x; + geometry.y=y; + (void) FormatLocaleString(composite_geometry,MagickPathExtent, + ""%.20gx%.20g%+.20g%+.20g"",(double) composite_image->columns,(double) + composite_image->rows,(double) geometry.x,(double) geometry.y); + (void) ParseGravityGeometry(image,composite_geometry,&geometry,exception); + affine=draw_info->affine; + affine.tx=(double) geometry.x; + affine.ty=(double) geometry.y; + composite_image->interpolate=image->interpolate; + if (draw_info->compose == OverCompositeOp) + (void) DrawAffineImage(image,composite_image,&affine,exception); + else + (void) CompositeImage(image,composite_image,draw_info->compose, + MagickTrue,geometry.x,geometry.y,exception); + composite_image=DestroyImage(composite_image); + break; + } + case PointPrimitive: + { + PixelInfo + fill_color; + + register Quantum + *q; + + if ((y < 0) || (y >= (ssize_t) image->rows)) + break; + if ((x < 0) || (x >= (ssize_t) image->columns)) + break; + q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); + if (q == (Quantum *) NULL) + break; + GetFillColor(draw_info,x,y,&fill_color,exception); + CompositePixelOver(image,&fill_color,(double) fill_color.alpha,q, + (double) GetPixelAlpha(image,q),q); + (void) SyncCacheViewAuthenticPixels(image_view,exception); + break; + } + case TextPrimitive: + { + char + geometry[MagickPathExtent]; + + DrawInfo + *clone_info; + + if (primitive_info->text == (char *) NULL) + break; + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + (void) CloneString(&clone_info->text,primitive_info->text); + (void) FormatLocaleString(geometry,MagickPathExtent,""%+f%+f"", + primitive_info->point.x,primitive_info->point.y); + (void) CloneString(&clone_info->geometry,geometry); + status&=AnnotateImage(image,clone_info,exception); + clone_info=DestroyDrawInfo(clone_info); + break; + } + default: + { + double + mid, + scale; + + DrawInfo + *clone_info; + + if (IsEventLogging() != MagickFalse) + LogPrimitiveInfo(primitive_info); + scale=ExpandAffine(&draw_info->affine); + if ((draw_info->dash_pattern != (double *) NULL) && + (draw_info->dash_pattern[0] != 0.0) && + ((scale*draw_info->stroke_width) >= MagickEpsilon) && + (draw_info->stroke.alpha != (Quantum) TransparentAlpha)) + { + /* + Draw dash polygon. + */ + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; + clone_info->stroke.alpha=(Quantum) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); + (void) DrawDashPolygon(draw_info,primitive_info,image,exception); + break; + } + mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0; + if ((mid > 1.0) && + ((draw_info->stroke.alpha != (Quantum) TransparentAlpha) || + (draw_info->stroke_pattern != (Image *) NULL))) + { + MagickBooleanType + closed_path; + + /* + Draw strokes while respecting line cap/join attributes. + */ + for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++) ; + closed_path= + (primitive_info[i-1].point.x == primitive_info[0].point.x) && + (primitive_info[i-1].point.y == primitive_info[0].point.y) ? + MagickTrue : MagickFalse; + i=(ssize_t) primitive_info[0].coordinates; + if ((((draw_info->linecap == RoundCap) || + (closed_path != MagickFalse)) && + (draw_info->linejoin == RoundJoin)) || + (primitive_info[i].primitive != UndefinedPrimitive)) + { + (void) DrawPolygonPrimitive(image,draw_info,primitive_info, + exception); + break; + } + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; + clone_info->stroke.alpha=(Quantum) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); + status&=DrawStrokePolygon(image,draw_info,primitive_info,exception); + break; + } + status&=DrawPolygonPrimitive(image,draw_info,primitive_info,exception); + break; + } + } + image_view=DestroyCacheView(image_view); + if (image->debug != MagickFalse) + (void) LogMagickEvent(DrawEvent,GetMagickModule(),"" end draw-primitive""); + return(status != 0 ? MagickTrue : MagickFalse); +} +",1,"MagickExport MagickBooleanType DrawPrimitive(Image *image, + const DrawInfo *draw_info,const PrimitiveInfo *primitive_info, + ExceptionInfo *exception) +{ + CacheView + *image_view; + + MagickStatusType + status; + + register ssize_t + i, + x; + + ssize_t + y; + + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(DrawEvent,GetMagickModule(), + "" begin draw-primitive""); + (void) LogMagickEvent(DrawEvent,GetMagickModule(), + "" affine: %g %g %g %g %g %g"",draw_info->affine.sx, + draw_info->affine.rx,draw_info->affine.ry,draw_info->affine.sy, + draw_info->affine.tx,draw_info->affine.ty); + } + if ((IsGrayColorspace(image->colorspace) != MagickFalse) && + ((IsPixelInfoGray(&draw_info->fill) == MagickFalse) || + (IsPixelInfoGray(&draw_info->stroke) == MagickFalse))) + (void) SetImageColorspace(image,sRGBColorspace,exception); + status=MagickTrue; + x=(ssize_t) ceil(primitive_info->point.x-0.5); + y=(ssize_t) ceil(primitive_info->point.y-0.5); + image_view=AcquireAuthenticCacheView(image,exception); + switch (primitive_info->primitive) + { + case AlphaPrimitive: + { + if (image->alpha_trait == UndefinedPixelTrait) + (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); + switch (primitive_info->method) + { + case PointMethod: + default: + { + PixelInfo + pixel; + + register Quantum + *q; + + q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); + if (q == (Quantum *) NULL) + break; + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + (void) SyncCacheViewAuthenticPixels(image_view,exception); + break; + } + case ReplaceMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel, + target; + + (void) GetOneCacheViewVirtualPixelInfo(image_view,x,y,&target, + exception); + GetPixelInfo(image,&pixel); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetPixelInfoPixel(image,q,&pixel); + if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse) + { + q+=GetPixelChannels(image); + continue; + } + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + case FloodfillMethod: + case FillToBorderMethod: + { + ChannelType + channel_mask; + + PixelInfo + target; + + (void) GetOneVirtualPixelInfo(image,TileVirtualPixelMethod,x,y, + &target,exception); + if (primitive_info->method == FillToBorderMethod) + { + target.red=(double) draw_info->border_color.red; + target.green=(double) draw_info->border_color.green; + target.blue=(double) draw_info->border_color.blue; + } + channel_mask=SetImageChannelMask(image,AlphaChannel); + status&=FloodfillPaintImage(image,draw_info,&target,x,y, + primitive_info->method == FloodfillMethod ? MagickFalse : + MagickTrue,exception); + (void) SetImageChannelMask(image,channel_mask); + break; + } + case ResetMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel; + + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + } + break; + } + case ColorPrimitive: + { + switch (primitive_info->method) + { + case PointMethod: + default: + { + PixelInfo + pixel; + + register Quantum + *q; + + q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); + if (q == (Quantum *) NULL) + break; + GetPixelInfo(image,&pixel); + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelViaPixelInfo(image,&pixel,q); + (void) SyncCacheViewAuthenticPixels(image_view,exception); + break; + } + case ReplaceMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel, + target; + + (void) GetOneCacheViewVirtualPixelInfo(image_view,x,y,&target, + exception); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetPixelInfoPixel(image,q,&pixel); + if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse) + { + q+=GetPixelChannels(image); + continue; + } + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelViaPixelInfo(image,&pixel,q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + case FloodfillMethod: + case FillToBorderMethod: + { + PixelInfo + target; + + (void) GetOneVirtualPixelInfo(image,TileVirtualPixelMethod,x,y, + &target,exception); + if (primitive_info->method == FillToBorderMethod) + { + target.red=(double) draw_info->border_color.red; + target.green=(double) draw_info->border_color.green; + target.blue=(double) draw_info->border_color.blue; + } + status&=FloodfillPaintImage(image,draw_info,&target,x,y, + primitive_info->method == FloodfillMethod ? MagickFalse : + MagickTrue,exception); + break; + } + case ResetMethod: + { + MagickBooleanType + sync; + + PixelInfo + pixel; + + GetPixelInfo(image,&pixel); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + GetFillColor(draw_info,x,y,&pixel,exception); + SetPixelViaPixelInfo(image,&pixel,q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + break; + } + break; + } + } + break; + } + case ImagePrimitive: + { + AffineMatrix + affine; + + char + composite_geometry[MagickPathExtent]; + + Image + *composite_image; + + ImageInfo + *clone_info; + + RectangleInfo + geometry; + + ssize_t + x1, + y1; + + if (primitive_info->text == (char *) NULL) + break; + clone_info=AcquireImageInfo(); + if (LocaleNCompare(primitive_info->text,""data:"",5) == 0) + composite_image=ReadInlineImage(clone_info,primitive_info->text, + exception); + else + { + (void) CopyMagickString(clone_info->filename,primitive_info->text, + MagickPathExtent); + composite_image=ReadImage(clone_info,exception); + } + clone_info=DestroyImageInfo(clone_info); + if (composite_image == (Image *) NULL) + break; + (void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor) + NULL,(void *) NULL); + x1=(ssize_t) ceil(primitive_info[1].point.x-0.5); + y1=(ssize_t) ceil(primitive_info[1].point.y-0.5); + if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) || + ((y1 != 0L) && (y1 != (ssize_t) composite_image->rows))) + { + /* + Resize image. + */ + (void) FormatLocaleString(composite_geometry,MagickPathExtent, + ""%gx%g!"",primitive_info[1].point.x,primitive_info[1].point.y); + composite_image->filter=image->filter; + (void) TransformImage(&composite_image,(char *) NULL, + composite_geometry,exception); + } + if (composite_image->alpha_trait == UndefinedPixelTrait) + (void) SetImageAlphaChannel(composite_image,OpaqueAlphaChannel, + exception); + if (draw_info->alpha != OpaqueAlpha) + (void) SetImageAlpha(composite_image,draw_info->alpha,exception); + SetGeometry(image,&geometry); + image->gravity=draw_info->gravity; + geometry.x=x; + geometry.y=y; + (void) FormatLocaleString(composite_geometry,MagickPathExtent, + ""%.20gx%.20g%+.20g%+.20g"",(double) composite_image->columns,(double) + composite_image->rows,(double) geometry.x,(double) geometry.y); + (void) ParseGravityGeometry(image,composite_geometry,&geometry,exception); + affine=draw_info->affine; + affine.tx=(double) geometry.x; + affine.ty=(double) geometry.y; + composite_image->interpolate=image->interpolate; + if (draw_info->compose == OverCompositeOp) + (void) DrawAffineImage(image,composite_image,&affine,exception); + else + (void) CompositeImage(image,composite_image,draw_info->compose, + MagickTrue,geometry.x,geometry.y,exception); + composite_image=DestroyImage(composite_image); + break; + } + case PointPrimitive: + { + PixelInfo + fill_color; + + register Quantum + *q; + + if ((y < 0) || (y >= (ssize_t) image->rows)) + break; + if ((x < 0) || (x >= (ssize_t) image->columns)) + break; + q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); + if (q == (Quantum *) NULL) + break; + GetFillColor(draw_info,x,y,&fill_color,exception); + CompositePixelOver(image,&fill_color,(double) fill_color.alpha,q, + (double) GetPixelAlpha(image,q),q); + (void) SyncCacheViewAuthenticPixels(image_view,exception); + break; + } + case TextPrimitive: + { + char + geometry[MagickPathExtent]; + + DrawInfo + *clone_info; + + if (primitive_info->text == (char *) NULL) + break; + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + (void) CloneString(&clone_info->text,primitive_info->text); + (void) FormatLocaleString(geometry,MagickPathExtent,""%+f%+f"", + primitive_info->point.x,primitive_info->point.y); + (void) CloneString(&clone_info->geometry,geometry); + status&=AnnotateImage(image,clone_info,exception); + clone_info=DestroyDrawInfo(clone_info); + break; + } + default: + { + double + mid, + scale; + + DrawInfo + *clone_info; + + if (IsEventLogging() != MagickFalse) + LogPrimitiveInfo(primitive_info); + scale=ExpandAffine(&draw_info->affine); + if ((draw_info->dash_pattern != (double *) NULL) && + (draw_info->dash_pattern[0] != 0.0) && + ((scale*draw_info->stroke_width) >= MagickEpsilon) && + (draw_info->stroke.alpha != (Quantum) TransparentAlpha)) + { + /* + Draw dash polygon. + */ + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; + clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); + (void) DrawDashPolygon(draw_info,primitive_info,image,exception); + break; + } + mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0; + if ((mid > 1.0) && + ((draw_info->stroke.alpha != (Quantum) TransparentAlpha) || + (draw_info->stroke_pattern != (Image *) NULL))) + { + MagickBooleanType + closed_path; + + /* + Draw strokes while respecting line cap/join attributes. + */ + for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++) ; + closed_path= + (primitive_info[i-1].point.x == primitive_info[0].point.x) && + (primitive_info[i-1].point.y == primitive_info[0].point.y) ? + MagickTrue : MagickFalse; + i=(ssize_t) primitive_info[0].coordinates; + if ((((draw_info->linecap == RoundCap) || + (closed_path != MagickFalse)) && + (draw_info->linejoin == RoundJoin)) || + (primitive_info[i].primitive != UndefinedPrimitive)) + { + (void) DrawPolygonPrimitive(image,draw_info,primitive_info, + exception); + break; + } + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; + clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); + status&=DrawStrokePolygon(image,draw_info,primitive_info,exception); + break; + } + status&=DrawPolygonPrimitive(image,draw_info,primitive_info,exception); + break; + } + } + image_view=DestroyCacheView(image_view); + if (image->debug != MagickFalse) + (void) LogMagickEvent(DrawEvent,GetMagickModule(),"" end draw-primitive""); + return(status != 0 ? MagickTrue : MagickFalse); +} +","@@ -1417,7 +1417,7 @@ MagickExport MagickBooleanType DrawClipPath(Image *image, + return(MagickFalse); + (void) QueryColorCompliance(""#0000"",AllCompliance, + &clip_mask->background_color,exception); +- clip_mask->background_color.alpha=(Quantum) TransparentAlpha; ++ clip_mask->background_color.alpha=(MagickRealType) TransparentAlpha; + (void) SetImageBackgroundColor(clip_mask,exception); + if (image->debug != MagickFalse) + (void) LogMagickEvent(DrawEvent,GetMagickModule(),""\nbegin clip-path %s"", +@@ -1541,7 +1541,7 @@ static MagickBooleanType DrawDashPolygon(const DrawInfo *draw_info, + status=MagickTrue; + maximum_length=0.0; + total_length=0.0; +- for (i=1; (i < number_vertices) && (length >= 0.0); i++) ++ for (i=1; (i < (ssize_t) number_vertices) && (length >= 0.0); i++) + { + dx=primitive_info[i].point.x-primitive_info[i-1].point.x; + dy=primitive_info[i].point.y-primitive_info[i-1].point.y; +@@ -1794,7 +1794,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, + /* + Interpret graphic primitive. + */ +- GetNextToken(q,&q,extent,keyword); ++ GetNextToken(q,&q,MagickPathExtent,keyword); + if (*keyword == '\0') + break; + if (*keyword == '#') +@@ -2104,7 +2104,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, + GetNextToken(q,&q,extent,token); + weight=ParseCommandOption(MagickWeightOptions,MagickFalse,token); + if (weight == -1) +- weight=StringToUnsignedLong(token); ++ weight=(ssize_t) StringToUnsignedLong(token); + graphic_context[n]->weight=(size_t) weight; + break; + } +@@ -2353,7 +2353,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, + (void) SetImageArtifact(image,key,token); + (void) FormatLocaleString(key,MagickPathExtent,""%s-type"",name); + (void) SetImageArtifact(image,key,type); +- (void) FormatLocaleString(key,MagickPathExtent,""%s-geometry"",name); ++ (void) FormatLocaleString(key,MagickPathExtent,""%s-geometry"", ++ name); + (void) FormatLocaleString(geometry,MagickPathExtent, + ""%gx%g%+.15g%+.15g"", + MagickMax(fabs(bounds.x2-bounds.x1+1.0),1.0), +@@ -4608,7 +4609,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, + */ + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; +- clone_info->stroke.alpha=(Quantum) TransparentAlpha; ++ clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); +@@ -4643,7 +4644,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, + } + clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + clone_info->stroke_width=0.0; +- clone_info->stroke.alpha=(Quantum) TransparentAlpha; ++ clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + status&=DrawPolygonPrimitive(image,clone_info,primitive_info, + exception); + clone_info=DestroyDrawInfo(clone_info); +@@ -4743,7 +4744,7 @@ static MagickBooleanType DrawStrokePolygon(Image *image, + if (clone_info->stroke_pattern != (Image *) NULL) + clone_info->fill_pattern=CloneImage(clone_info->stroke_pattern,0,0, + MagickTrue,exception); +- clone_info->stroke.alpha=(Quantum) TransparentAlpha; ++ clone_info->stroke.alpha=(MagickRealType) TransparentAlpha; + clone_info->stroke_width=0.0; + clone_info->fill_rule=NonZeroRule; + status=MagickTrue; +@@ -4858,7 +4859,7 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info) + draw_info->miterlimit=10; + draw_info->decorate=NoDecoration; + draw_info->pointsize=12.0; +- draw_info->undercolor.alpha=(Quantum) TransparentAlpha; ++ draw_info->undercolor.alpha=(MagickRealType) TransparentAlpha; + draw_info->compose=OverCompositeOp; + draw_info->render=MagickTrue; + draw_info->debug=IsEventLogging(); +@@ -4925,7 +4926,7 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info) + + weight=ParseCommandOption(MagickWeightOptions,MagickFalse,option); + if (weight == -1) +- weight=StringToUnsignedLong(option); ++ weight=(ssize_t) StringToUnsignedLong(option); + draw_info->weight=(size_t) weight; + } + exception=DestroyExceptionInfo(exception); +@@ -6021,17 +6022,29 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info, + } + if (q >= (ssize_t) (max_strokes-6*BezierQuantum-360)) + { +- max_strokes+=6*BezierQuantum+360; +- path_p=(PointInfo *) ResizeQuantumMemory(path_p,(size_t) max_strokes, +- sizeof(*path_p)); +- path_q=(PointInfo *) ResizeQuantumMemory(path_q,(size_t) max_strokes, +- sizeof(*path_q)); +- if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL)) +- { +- polygon_primitive=(PrimitiveInfo *) +- RelinquishMagickMemory(polygon_primitive); +- return((PrimitiveInfo *) NULL); +- } ++ if (~max_strokes < (6*BezierQuantum+360)) ++ { ++ path_p=(PointInfo *) RelinquishMagickMemory(path_p); ++ path_q=(PointInfo *) RelinquishMagickMemory(path_q); ++ } ++ else ++ { ++ max_strokes+=6*BezierQuantum+360; ++ path_p=(PointInfo *) ResizeQuantumMemory(path_p,max_strokes, ++ sizeof(*path_p)); ++ path_q=(PointInfo *) ResizeQuantumMemory(path_q,max_strokes, ++ sizeof(*path_q)); ++ } ++ if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL)) ++ { ++ if (path_p != (PointInfo *) NULL) ++ path_p=(PointInfo *) RelinquishMagickMemory(path_p); ++ if (path_q != (PointInfo *) NULL) ++ path_q=(PointInfo *) RelinquishMagickMemory(path_q); ++ polygon_primitive=(PrimitiveInfo *) ++ RelinquishMagickMemory(polygon_primitive); ++ return((PrimitiveInfo *) NULL); ++ } + } + dot_product=dx.q*dy.p-dx.p*dy.q; + if (dot_product <= 0.0)",3420,3656,4096 +15382,"bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { + + switch (pname) { + case GL_ACTIVE_TEXTURE: + *params = active_texture_unit_ + GL_TEXTURE0; + return true; + case GL_ARRAY_BUFFER_BINDING: + *params = bound_array_buffer_; + return true; + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + *params = vertex_array_object_manager_->bound_element_array_buffer(); + return true; + case GL_FRAMEBUFFER_BINDING: + *params = bound_framebuffer_; + return true; + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + *params = capabilities_.max_combined_texture_image_units; + return true; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + *params = capabilities_.max_cube_map_texture_size; + return true; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + *params = capabilities_.max_fragment_uniform_vectors; + return true; + case GL_MAX_RENDERBUFFER_SIZE: + *params = capabilities_.max_renderbuffer_size; + return true; + case GL_MAX_TEXTURE_IMAGE_UNITS: + *params = capabilities_.max_texture_image_units; + return true; + case GL_MAX_TEXTURE_SIZE: + *params = capabilities_.max_texture_size; + return true; + case GL_MAX_VARYING_VECTORS: + *params = capabilities_.max_varying_vectors; + return true; + case GL_MAX_VERTEX_ATTRIBS: + *params = capabilities_.max_vertex_attribs; + return true; + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + *params = capabilities_.max_vertex_texture_image_units; + return true; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + *params = capabilities_.max_vertex_uniform_vectors; + return true; + case GL_MAX_VIEWPORT_DIMS: + if (capabilities_.max_viewport_width > 0 && + capabilities_.max_viewport_height > 0) { + params[0] = capabilities_.max_viewport_width; + params[1] = capabilities_.max_viewport_height; + return true; + } + return false; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + *params = capabilities_.num_compressed_texture_formats; + return true; + case GL_NUM_SHADER_BINARY_FORMATS: + *params = capabilities_.num_shader_binary_formats; + return true; + case GL_RENDERBUFFER_BINDING: + *params = bound_renderbuffer_; + return true; + case GL_TEXTURE_BINDING_2D: + *params = texture_units_[active_texture_unit_].bound_texture_2d; + return true; + case GL_TEXTURE_BINDING_CUBE_MAP: + *params = texture_units_[active_texture_unit_].bound_texture_cube_map; + return true; + + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *params = texture_units_[active_texture_unit_].bound_texture_external_oes; + return true; + case GL_TEXTURE_BINDING_RECTANGLE_ARB: + *params = + texture_units_[active_texture_unit_].bound_texture_rectangle_arb; + return true; + case GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM: + *params = bound_pixel_pack_transfer_buffer_id_; + return true; + case GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM: + *params = bound_pixel_unpack_transfer_buffer_id_; + return true; + case GL_READ_FRAMEBUFFER_BINDING: + if (capabilities_.major_version >= 3 || + IsChromiumFramebufferMultisampleAvailable()) { + *params = bound_read_framebuffer_; + return true; + } + break; + case GL_TIMESTAMP_EXT: + *params = base::saturated_cast( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() * + base::Time::kNanosecondsPerMicrosecond); + return true; + case GL_GPU_DISJOINT_EXT: + *params = static_cast(query_tracker_->CheckAndResetDisjoint()); + return true; + + case GL_VIEWPORT: + if (state_.viewport_width > 0 && state_.viewport_height > 0 && + capabilities_.max_viewport_width > 0 && + capabilities_.max_viewport_height > 0) { + params[0] = state_.viewport_x; + params[1] = state_.viewport_y; + params[2] = + std::min(state_.viewport_width, capabilities_.max_viewport_width); + params[3] = + std::min(state_.viewport_height, capabilities_.max_viewport_height); + return true; + } + return false; + + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_ALPHA_BITS: + case GL_BLEND: + case GL_BLEND_COLOR: + case GL_BLEND_DST_ALPHA: + case GL_BLEND_DST_RGB: + case GL_BLEND_EQUATION_ALPHA: + case GL_BLEND_EQUATION_RGB: + case GL_BLEND_SRC_ALPHA: + case GL_BLEND_SRC_RGB: + case GL_BLUE_BITS: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_COMPRESSED_TEXTURE_FORMATS: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_CURRENT_PROGRAM: + case GL_DEPTH_BITS: + case GL_DEPTH_CLEAR_VALUE: + case GL_DEPTH_FUNC: + case GL_DEPTH_RANGE: + case GL_DEPTH_TEST: + case GL_DEPTH_WRITEMASK: + case GL_DITHER: + case GL_FRONT_FACE: + case GL_GENERATE_MIPMAP_HINT: + case GL_GREEN_BITS: + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + case GL_LINE_WIDTH: + case GL_PACK_ALIGNMENT: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_SCISSOR_BOX: + case GL_SCISSOR_TEST: + case GL_SHADER_BINARY_FORMATS: + case GL_SHADER_COMPILER: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_WRITEMASK: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_FUNC: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_WRITEMASK: + case GL_SUBPIXEL_BITS: + case GL_UNPACK_ALIGNMENT: + return false; + default: + break; + } + + if (capabilities_.major_version < 3) { + return false; + } + + switch (pname) { + case GL_COPY_READ_BUFFER_BINDING: + *params = bound_copy_read_buffer_; + return true; + case GL_COPY_WRITE_BUFFER_BINDING: + *params = bound_copy_write_buffer_; + return true; + case GL_MAJOR_VERSION: + *params = capabilities_.major_version; + return true; + case GL_MAX_3D_TEXTURE_SIZE: + *params = capabilities_.max_3d_texture_size; + return true; + case GL_MAX_ARRAY_TEXTURE_LAYERS: + *params = capabilities_.max_array_texture_layers; + return true; + case GL_MAX_COLOR_ATTACHMENTS: + *params = capabilities_.max_color_attachments; + return true; + case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: + *params = static_cast( + capabilities_.max_combined_fragment_uniform_components); + return true; + case GL_MAX_COMBINED_UNIFORM_BLOCKS: + *params = capabilities_.max_combined_uniform_blocks; + return true; + case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: + *params = static_cast( + capabilities_.max_combined_vertex_uniform_components); + return true; + case GL_MAX_DRAW_BUFFERS: + *params = capabilities_.max_draw_buffers; + return true; + case GL_MAX_ELEMENT_INDEX: + *params = static_cast(capabilities_.max_element_index); + return true; + case GL_MAX_ELEMENTS_INDICES: + *params = capabilities_.max_elements_indices; + return true; + case GL_MAX_ELEMENTS_VERTICES: + *params = capabilities_.max_elements_vertices; + return true; + case GL_MAX_FRAGMENT_INPUT_COMPONENTS: + *params = capabilities_.max_fragment_input_components; + return true; + case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: + *params = capabilities_.max_fragment_uniform_blocks; + return true; + case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: + *params = capabilities_.max_fragment_uniform_components; + return true; + case GL_MAX_PROGRAM_TEXEL_OFFSET: + *params = capabilities_.max_program_texel_offset; + return true; + case GL_MAX_SAMPLES: + *params = capabilities_.max_samples; + return true; + case GL_MAX_SERVER_WAIT_TIMEOUT: + *params = static_cast(capabilities_.max_server_wait_timeout); + return true; + case GL_MAX_TEXTURE_LOD_BIAS: + *params = static_cast(capabilities_.max_texture_lod_bias); + return true; + case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: + *params = capabilities_.max_transform_feedback_interleaved_components; + return true; + case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: + *params = capabilities_.max_transform_feedback_separate_attribs; + return true; + case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: + *params = capabilities_.max_transform_feedback_separate_components; + return true; + case GL_MAX_UNIFORM_BLOCK_SIZE: + *params = static_cast(capabilities_.max_uniform_block_size); + return true; + case GL_MAX_UNIFORM_BUFFER_BINDINGS: + *params = capabilities_.max_uniform_buffer_bindings; + return true; + case GL_MAX_VARYING_COMPONENTS: + *params = capabilities_.max_varying_components; + return true; + case GL_MAX_VERTEX_OUTPUT_COMPONENTS: + *params = capabilities_.max_vertex_output_components; + return true; + case GL_MAX_VERTEX_UNIFORM_BLOCKS: + *params = capabilities_.max_vertex_uniform_blocks; + return true; + case GL_MAX_VERTEX_UNIFORM_COMPONENTS: + *params = capabilities_.max_vertex_uniform_components; + return true; + case GL_MIN_PROGRAM_TEXEL_OFFSET: + *params = capabilities_.min_program_texel_offset; + return true; + case GL_MINOR_VERSION: + *params = capabilities_.minor_version; + return true; + case GL_NUM_EXTENSIONS: + UpdateCachedExtensionsIfNeeded(); + *params = cached_extensions_.size(); + return true; + case GL_NUM_PROGRAM_BINARY_FORMATS: + *params = capabilities_.num_program_binary_formats; + return true; + case GL_PACK_SKIP_PIXELS: + *params = pack_skip_pixels_; + return true; + case GL_PACK_SKIP_ROWS: + *params = pack_skip_rows_; + return true; + case GL_PIXEL_PACK_BUFFER_BINDING: + *params = bound_pixel_pack_buffer_; + return true; + case GL_PIXEL_UNPACK_BUFFER_BINDING: + *params = bound_pixel_unpack_buffer_; + return true; + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + *params = bound_transform_feedback_buffer_; + return true; + case GL_UNIFORM_BUFFER_BINDING: + *params = bound_uniform_buffer_; + return true; + case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: + *params = capabilities_.uniform_buffer_offset_alignment; + return true; + case GL_UNPACK_SKIP_IMAGES: + *params = unpack_skip_images_; + return true; + case GL_UNPACK_SKIP_PIXELS: + *params = unpack_skip_pixels_; + return true; + case GL_UNPACK_SKIP_ROWS: + *params = unpack_skip_rows_; + return true; + + case GL_DRAW_BUFFER0: + case GL_DRAW_BUFFER1: + case GL_DRAW_BUFFER2: + case GL_DRAW_BUFFER3: + case GL_DRAW_BUFFER4: + case GL_DRAW_BUFFER5: + case GL_DRAW_BUFFER6: + case GL_DRAW_BUFFER7: + case GL_DRAW_BUFFER8: + case GL_DRAW_BUFFER9: + case GL_DRAW_BUFFER10: + case GL_DRAW_BUFFER11: + case GL_DRAW_BUFFER12: + case GL_DRAW_BUFFER13: + case GL_DRAW_BUFFER14: + case GL_DRAW_BUFFER15: + case GL_DRAW_FRAMEBUFFER_BINDING: + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: + case GL_PACK_ROW_LENGTH: + case GL_PRIMITIVE_RESTART_FIXED_INDEX: + case GL_PROGRAM_BINARY_FORMATS: + case GL_RASTERIZER_DISCARD: + case GL_READ_BUFFER: + case GL_READ_FRAMEBUFFER_BINDING: + case GL_SAMPLER_BINDING: + case GL_TEXTURE_BINDING_2D_ARRAY: + case GL_TEXTURE_BINDING_3D: + case GL_TRANSFORM_FEEDBACK_BINDING: + case GL_TRANSFORM_FEEDBACK_ACTIVE: + case GL_TRANSFORM_FEEDBACK_PAUSED: + case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: + case GL_TRANSFORM_FEEDBACK_BUFFER_START: + case GL_UNIFORM_BUFFER_SIZE: + case GL_UNIFORM_BUFFER_START: + case GL_UNPACK_IMAGE_HEIGHT: + case GL_UNPACK_ROW_LENGTH: + case GL_VERTEX_ARRAY_BINDING: + return false; + default: + break; + } + + if (capabilities_.minor_version < 1) { + return false; + } + + switch (pname) { + case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: + *params = capabilities_.max_atomic_counter_buffer_bindings; + return true; + case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: + *params = capabilities_.max_shader_storage_buffer_bindings; + return true; + case GL_ATOMIC_COUNTER_BUFFER_BINDING: + *params = bound_atomic_counter_buffer_; + return true; + case GL_SHADER_STORAGE_BUFFER_BINDING: + *params = bound_shader_storage_buffer_; + return true; + case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: + *params = capabilities_.shader_storage_buffer_offset_alignment; + return true; + + case GL_ATOMIC_COUNTER_BUFFER_SIZE: + case GL_ATOMIC_COUNTER_BUFFER_START: + case GL_SHADER_STORAGE_BUFFER_SIZE: + case GL_SHADER_STORAGE_BUFFER_START: + return false; + default: + return false; + } +} +",0,"bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { + + switch (pname) { + case GL_ACTIVE_TEXTURE: + *params = active_texture_unit_ + GL_TEXTURE0; + return true; + case GL_ARRAY_BUFFER_BINDING: + *params = bound_array_buffer_; + return true; + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + *params = vertex_array_object_manager_->bound_element_array_buffer(); + return true; + case GL_FRAMEBUFFER_BINDING: + *params = bound_framebuffer_; + return true; + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + *params = capabilities_.max_combined_texture_image_units; + return true; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + *params = capabilities_.max_cube_map_texture_size; + return true; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + *params = capabilities_.max_fragment_uniform_vectors; + return true; + case GL_MAX_RENDERBUFFER_SIZE: + *params = capabilities_.max_renderbuffer_size; + return true; + case GL_MAX_TEXTURE_IMAGE_UNITS: + *params = capabilities_.max_texture_image_units; + return true; + case GL_MAX_TEXTURE_SIZE: + *params = capabilities_.max_texture_size; + return true; + case GL_MAX_VARYING_VECTORS: + *params = capabilities_.max_varying_vectors; + return true; + case GL_MAX_VERTEX_ATTRIBS: + *params = capabilities_.max_vertex_attribs; + return true; + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + *params = capabilities_.max_vertex_texture_image_units; + return true; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + *params = capabilities_.max_vertex_uniform_vectors; + return true; + case GL_MAX_VIEWPORT_DIMS: + if (capabilities_.max_viewport_width > 0 && + capabilities_.max_viewport_height > 0) { + params[0] = capabilities_.max_viewport_width; + params[1] = capabilities_.max_viewport_height; + return true; + } + return false; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + *params = capabilities_.num_compressed_texture_formats; + return true; + case GL_NUM_SHADER_BINARY_FORMATS: + *params = capabilities_.num_shader_binary_formats; + return true; + case GL_RENDERBUFFER_BINDING: + *params = bound_renderbuffer_; + return true; + case GL_TEXTURE_BINDING_2D: + *params = texture_units_[active_texture_unit_].bound_texture_2d; + return true; + case GL_TEXTURE_BINDING_CUBE_MAP: + *params = texture_units_[active_texture_unit_].bound_texture_cube_map; + return true; + + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *params = texture_units_[active_texture_unit_].bound_texture_external_oes; + return true; + case GL_TEXTURE_BINDING_RECTANGLE_ARB: + *params = + texture_units_[active_texture_unit_].bound_texture_rectangle_arb; + return true; + case GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM: + *params = bound_pixel_pack_transfer_buffer_id_; + return true; + case GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM: + *params = bound_pixel_unpack_transfer_buffer_id_; + return true; + case GL_READ_FRAMEBUFFER_BINDING: + if (capabilities_.major_version >= 3 || + IsChromiumFramebufferMultisampleAvailable()) { + *params = bound_read_framebuffer_; + return true; + } + break; + case GL_TIMESTAMP_EXT: + *params = base::saturated_cast( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() * + base::Time::kNanosecondsPerMicrosecond); + return true; + case GL_GPU_DISJOINT_EXT: + *params = static_cast(query_tracker_->CheckAndResetDisjoint()); + return true; + + case GL_VIEWPORT: + if (state_.viewport_width > 0 && state_.viewport_height > 0 && + capabilities_.max_viewport_width > 0 && + capabilities_.max_viewport_height > 0) { + params[0] = state_.viewport_x; + params[1] = state_.viewport_y; + params[2] = + std::min(state_.viewport_width, capabilities_.max_viewport_width); + params[3] = + std::min(state_.viewport_height, capabilities_.max_viewport_height); + return true; + } + return false; + + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_ALPHA_BITS: + case GL_BLEND: + case GL_BLEND_COLOR: + case GL_BLEND_DST_ALPHA: + case GL_BLEND_DST_RGB: + case GL_BLEND_EQUATION_ALPHA: + case GL_BLEND_EQUATION_RGB: + case GL_BLEND_SRC_ALPHA: + case GL_BLEND_SRC_RGB: + case GL_BLUE_BITS: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_COMPRESSED_TEXTURE_FORMATS: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_CURRENT_PROGRAM: + case GL_DEPTH_BITS: + case GL_DEPTH_CLEAR_VALUE: + case GL_DEPTH_FUNC: + case GL_DEPTH_RANGE: + case GL_DEPTH_TEST: + case GL_DEPTH_WRITEMASK: + case GL_DITHER: + case GL_FRONT_FACE: + case GL_GENERATE_MIPMAP_HINT: + case GL_GREEN_BITS: + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + case GL_LINE_WIDTH: + case GL_PACK_ALIGNMENT: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_SCISSOR_BOX: + case GL_SCISSOR_TEST: + case GL_SHADER_BINARY_FORMATS: + case GL_SHADER_COMPILER: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_WRITEMASK: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_FUNC: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_WRITEMASK: + case GL_SUBPIXEL_BITS: + case GL_UNPACK_ALIGNMENT: + return false; + default: + break; + } + + if (capabilities_.major_version < 3) { + return false; + } + + switch (pname) { + case GL_COPY_READ_BUFFER_BINDING: + *params = bound_copy_read_buffer_; + return true; + case GL_COPY_WRITE_BUFFER_BINDING: + *params = bound_copy_write_buffer_; + return true; + case GL_MAJOR_VERSION: + *params = capabilities_.major_version; + return true; + case GL_MAX_3D_TEXTURE_SIZE: + *params = capabilities_.max_3d_texture_size; + return true; + case GL_MAX_ARRAY_TEXTURE_LAYERS: + *params = capabilities_.max_array_texture_layers; + return true; + case GL_MAX_COLOR_ATTACHMENTS: + *params = capabilities_.max_color_attachments; + return true; + case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: + *params = static_cast( + capabilities_.max_combined_fragment_uniform_components); + return true; + case GL_MAX_COMBINED_UNIFORM_BLOCKS: + *params = capabilities_.max_combined_uniform_blocks; + return true; + case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: + *params = static_cast( + capabilities_.max_combined_vertex_uniform_components); + return true; + case GL_MAX_DRAW_BUFFERS: + *params = capabilities_.max_draw_buffers; + return true; + case GL_MAX_ELEMENT_INDEX: + *params = static_cast(capabilities_.max_element_index); + return true; + case GL_MAX_ELEMENTS_INDICES: + *params = capabilities_.max_elements_indices; + return true; + case GL_MAX_ELEMENTS_VERTICES: + *params = capabilities_.max_elements_vertices; + return true; + case GL_MAX_FRAGMENT_INPUT_COMPONENTS: + *params = capabilities_.max_fragment_input_components; + return true; + case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: + *params = capabilities_.max_fragment_uniform_blocks; + return true; + case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: + *params = capabilities_.max_fragment_uniform_components; + return true; + case GL_MAX_PROGRAM_TEXEL_OFFSET: + *params = capabilities_.max_program_texel_offset; + return true; + case GL_MAX_SAMPLES: + *params = capabilities_.max_samples; + return true; + case GL_MAX_SERVER_WAIT_TIMEOUT: + *params = static_cast(capabilities_.max_server_wait_timeout); + return true; + case GL_MAX_TEXTURE_LOD_BIAS: + *params = static_cast(capabilities_.max_texture_lod_bias); + return true; + case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: + *params = capabilities_.max_transform_feedback_interleaved_components; + return true; + case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: + *params = capabilities_.max_transform_feedback_separate_attribs; + return true; + case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: + *params = capabilities_.max_transform_feedback_separate_components; + return true; + case GL_MAX_UNIFORM_BLOCK_SIZE: + *params = static_cast(capabilities_.max_uniform_block_size); + return true; + case GL_MAX_UNIFORM_BUFFER_BINDINGS: + *params = capabilities_.max_uniform_buffer_bindings; + return true; + case GL_MAX_VARYING_COMPONENTS: + *params = capabilities_.max_varying_components; + return true; + case GL_MAX_VERTEX_OUTPUT_COMPONENTS: + *params = capabilities_.max_vertex_output_components; + return true; + case GL_MAX_VERTEX_UNIFORM_BLOCKS: + *params = capabilities_.max_vertex_uniform_blocks; + return true; + case GL_MAX_VERTEX_UNIFORM_COMPONENTS: + *params = capabilities_.max_vertex_uniform_components; + return true; + case GL_MIN_PROGRAM_TEXEL_OFFSET: + *params = capabilities_.min_program_texel_offset; + return true; + case GL_MINOR_VERSION: + *params = capabilities_.minor_version; + return true; + case GL_NUM_EXTENSIONS: + UpdateCachedExtensionsIfNeeded(); + *params = cached_extensions_.size(); + return true; + case GL_NUM_PROGRAM_BINARY_FORMATS: + *params = capabilities_.num_program_binary_formats; + return true; + case GL_PACK_SKIP_PIXELS: + *params = pack_skip_pixels_; + return true; + case GL_PACK_SKIP_ROWS: + *params = pack_skip_rows_; + return true; + case GL_PIXEL_PACK_BUFFER_BINDING: + *params = bound_pixel_pack_buffer_; + return true; + case GL_PIXEL_UNPACK_BUFFER_BINDING: + *params = bound_pixel_unpack_buffer_; + return true; + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + *params = bound_transform_feedback_buffer_; + return true; + case GL_UNIFORM_BUFFER_BINDING: + *params = bound_uniform_buffer_; + return true; + case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: + *params = capabilities_.uniform_buffer_offset_alignment; + return true; + case GL_UNPACK_SKIP_IMAGES: + *params = unpack_skip_images_; + return true; + case GL_UNPACK_SKIP_PIXELS: + *params = unpack_skip_pixels_; + return true; + case GL_UNPACK_SKIP_ROWS: + *params = unpack_skip_rows_; + return true; + + case GL_DRAW_BUFFER0: + case GL_DRAW_BUFFER1: + case GL_DRAW_BUFFER2: + case GL_DRAW_BUFFER3: + case GL_DRAW_BUFFER4: + case GL_DRAW_BUFFER5: + case GL_DRAW_BUFFER6: + case GL_DRAW_BUFFER7: + case GL_DRAW_BUFFER8: + case GL_DRAW_BUFFER9: + case GL_DRAW_BUFFER10: + case GL_DRAW_BUFFER11: + case GL_DRAW_BUFFER12: + case GL_DRAW_BUFFER13: + case GL_DRAW_BUFFER14: + case GL_DRAW_BUFFER15: + case GL_DRAW_FRAMEBUFFER_BINDING: + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: + case GL_PACK_ROW_LENGTH: + case GL_PRIMITIVE_RESTART_FIXED_INDEX: + case GL_PROGRAM_BINARY_FORMATS: + case GL_RASTERIZER_DISCARD: + case GL_READ_BUFFER: + case GL_READ_FRAMEBUFFER_BINDING: + case GL_SAMPLER_BINDING: + case GL_TEXTURE_BINDING_2D_ARRAY: + case GL_TEXTURE_BINDING_3D: + case GL_TRANSFORM_FEEDBACK_BINDING: + case GL_TRANSFORM_FEEDBACK_ACTIVE: + case GL_TRANSFORM_FEEDBACK_PAUSED: + case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: + case GL_TRANSFORM_FEEDBACK_BUFFER_START: + case GL_UNIFORM_BUFFER_SIZE: + case GL_UNIFORM_BUFFER_START: + case GL_UNPACK_IMAGE_HEIGHT: + case GL_UNPACK_ROW_LENGTH: + case GL_VERTEX_ARRAY_BINDING: + return false; + default: + break; + } + + if (capabilities_.minor_version < 1) { + return false; + } + + switch (pname) { + case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: + *params = capabilities_.max_atomic_counter_buffer_bindings; + return true; + case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: + *params = capabilities_.max_shader_storage_buffer_bindings; + return true; + case GL_ATOMIC_COUNTER_BUFFER_BINDING: + *params = bound_atomic_counter_buffer_; + return true; + case GL_SHADER_STORAGE_BUFFER_BINDING: + *params = bound_shader_storage_buffer_; + return true; + case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: + *params = capabilities_.shader_storage_buffer_offset_alignment; + return true; + + case GL_ATOMIC_COUNTER_BUFFER_SIZE: + case GL_ATOMIC_COUNTER_BUFFER_START: + case GL_SHADER_STORAGE_BUFFER_SIZE: + case GL_SHADER_STORAGE_BUFFER_START: + return false; + default: + return false; + } +} +","@@ -6078,6 +6078,7 @@ void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) { + case GL_LATENCY_QUERY_CHROMIUM: + case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: + case GL_GET_ERROR_QUERY_CHROMIUM: ++ case GL_PROGRAM_COMPLETION_QUERY_CHROMIUM: + break; + case GL_READBACK_SHADOW_COPIES_UPDATED_CHROMIUM: + case GL_COMMANDS_COMPLETED_CHROMIUM:",2976,3212,4096 +16465,"static int accessPayload( + BtCursor *pCur, /* Cursor pointing to entry to read from */ + u32 offset, /* Begin reading this far into payload */ + u32 amt, /* Read this many bytes */ + unsigned char *pBuf, /* Write the bytes into this buffer */ + int eOp /* zero to read. non-zero to write. */ +){ + unsigned char *aPayload; + int rc = SQLITE_OK; + int iIdx = 0; + MemPage *pPage = pCur->pPage; /* Btree page of current entry */ + BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */ +#ifdef SQLITE_DIRECT_OVERFLOW_READ + unsigned char * const pBufStart = pBuf; /* Start of original out buffer */ +#endif + + assert( pPage ); + assert( eOp==0 || eOp==1 ); + assert( pCur->eState==CURSOR_VALID ); + assert( pCur->ixnCell ); + assert( cursorHoldsMutex(pCur) ); + + getCellInfo(pCur); + aPayload = pCur->info.pPayload; + assert( offset+amt <= pCur->info.nPayload ); + + assert( aPayload > pPage->aData ); + if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){ + /* Trying to read or write past the end of the data is an error. The + ** conditional above is really: + ** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize] + ** but is recast into its current form to avoid integer overflow problems + */ + return SQLITE_CORRUPT_PAGE(pPage); + } + + /* Check if data must be read/written to/from the btree page itself. */ + if( offsetinfo.nLocal ){ + int a = amt; + if( a+offset>pCur->info.nLocal ){ + a = pCur->info.nLocal - offset; + } + rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage); + offset = 0; + pBuf += a; + amt -= a; + }else{ + offset -= pCur->info.nLocal; + } + + + if( rc==SQLITE_OK && amt>0 ){ + const u32 ovflSize = pBt->usableSize - 4; /* Bytes content per ovfl page */ + Pgno nextPage; + + nextPage = get4byte(&aPayload[pCur->info.nLocal]); + + /* If the BtCursor.aOverflow[] has not been allocated, allocate it now. + ** + ** The aOverflow[] array is sized at one entry for each overflow page + ** in the overflow chain. The page number of the first overflow page is + ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array + ** means ""not yet known"" (the cache is lazily populated). + */ + if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){ + int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize; + if( pCur->aOverflow==0 + || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow) + ){ + Pgno *aNew = (Pgno*)sqlite3Realloc( + pCur->aOverflow, nOvfl*2*sizeof(Pgno) + ); + if( aNew==0 ){ + return SQLITE_NOMEM_BKPT; + }else{ + pCur->aOverflow = aNew; + } + } + memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); + pCur->curFlags |= BTCF_ValidOvfl; + }else{ + /* If the overflow page-list cache has been allocated and the + ** entry for the first required overflow page is valid, skip + ** directly to it. + */ + if( pCur->aOverflow[offset/ovflSize] ){ + iIdx = (offset/ovflSize); + nextPage = pCur->aOverflow[iIdx]; + offset = (offset%ovflSize); + } + } + + assert( rc==SQLITE_OK && amt>0 ); + while( nextPage ){ + /* If required, populate the overflow page-list cache. */ + assert( pCur->aOverflow[iIdx]==0 + || pCur->aOverflow[iIdx]==nextPage + || CORRUPT_DB ); + pCur->aOverflow[iIdx] = nextPage; + + if( offset>=ovflSize ){ + /* The only reason to read this page is to obtain the page + ** number for the next page in the overflow chain. The page + ** data is not required. So first try to lookup the overflow + ** page-list cache, if any, then fall back to the getOverflowPage() + ** function. + */ + assert( pCur->curFlags & BTCF_ValidOvfl ); + assert( pCur->pBtree->db==pBt->db ); + if( pCur->aOverflow[iIdx+1] ){ + nextPage = pCur->aOverflow[iIdx+1]; + }else{ + rc = getOverflowPage(pBt, nextPage, 0, &nextPage); + } + offset -= ovflSize; + }else{ + /* Need to read this page properly. It contains some of the + ** range of data that is being read (eOp==0) or written (eOp!=0). + */ + int a = amt; + if( a + offset > ovflSize ){ + a = ovflSize - offset; + } + +#ifdef SQLITE_DIRECT_OVERFLOW_READ + /* If all the following are true: + ** + ** 1) this is a read operation, and + ** 2) data is required from the start of this overflow page, and + ** 3) there are no dirty pages in the page-cache + ** 4) the database is file-backed, and + ** 5) the page is not in the WAL file + ** 6) at least 4 bytes have already been read into the output buffer + ** + ** then data can be read directly from the database file into the + ** output buffer, bypassing the page-cache altogether. This speeds + ** up loading large records that span many overflow pages. + */ + if( eOp==0 /* (1) */ + && offset==0 /* (2) */ + && sqlite3PagerDirectReadOk(pBt->pPager, nextPage) /* (3,4,5) */ + && &pBuf[-4]>=pBufStart /* (6) */ + ){ + sqlite3_file *fd = sqlite3PagerFile(pBt->pPager); + u8 aSave[4]; + u8 *aWrite = &pBuf[-4]; + assert( aWrite>=pBufStart ); /* due to (6) */ + memcpy(aSave, aWrite, 4); + rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1)); + nextPage = get4byte(aWrite); + memcpy(aWrite, aSave, 4); + }else +#endif + + { + DbPage *pDbPage; + rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage, + (eOp==0 ? PAGER_GET_READONLY : 0) + ); + if( rc==SQLITE_OK ){ + aPayload = sqlite3PagerGetData(pDbPage); + nextPage = get4byte(aPayload); + rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage); + sqlite3PagerUnref(pDbPage); + offset = 0; + } + } + amt -= a; + if( amt==0 ) return rc; + pBuf += a; + } + if( rc ) break; + iIdx++; + } + } + + if( rc==SQLITE_OK && amt>0 ){ + /* Overflow chain ends prematurely */ + return SQLITE_CORRUPT_PAGE(pPage); + } + return rc; +} +",0,"static int accessPayload( + BtCursor *pCur, /* Cursor pointing to entry to read from */ + u32 offset, /* Begin reading this far into payload */ + u32 amt, /* Read this many bytes */ + unsigned char *pBuf, /* Write the bytes into this buffer */ + int eOp /* zero to read. non-zero to write. */ +){ + unsigned char *aPayload; + int rc = SQLITE_OK; + int iIdx = 0; + MemPage *pPage = pCur->pPage; /* Btree page of current entry */ + BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */ +#ifdef SQLITE_DIRECT_OVERFLOW_READ + unsigned char * const pBufStart = pBuf; /* Start of original out buffer */ +#endif + + assert( pPage ); + assert( eOp==0 || eOp==1 ); + assert( pCur->eState==CURSOR_VALID ); + assert( pCur->ixnCell ); + assert( cursorHoldsMutex(pCur) ); + + getCellInfo(pCur); + aPayload = pCur->info.pPayload; + assert( offset+amt <= pCur->info.nPayload ); + + assert( aPayload > pPage->aData ); + if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){ + /* Trying to read or write past the end of the data is an error. The + ** conditional above is really: + ** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize] + ** but is recast into its current form to avoid integer overflow problems + */ + return SQLITE_CORRUPT_PAGE(pPage); + } + + /* Check if data must be read/written to/from the btree page itself. */ + if( offsetinfo.nLocal ){ + int a = amt; + if( a+offset>pCur->info.nLocal ){ + a = pCur->info.nLocal - offset; + } + rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage); + offset = 0; + pBuf += a; + amt -= a; + }else{ + offset -= pCur->info.nLocal; + } + + + if( rc==SQLITE_OK && amt>0 ){ + const u32 ovflSize = pBt->usableSize - 4; /* Bytes content per ovfl page */ + Pgno nextPage; + + nextPage = get4byte(&aPayload[pCur->info.nLocal]); + + /* If the BtCursor.aOverflow[] has not been allocated, allocate it now. + ** + ** The aOverflow[] array is sized at one entry for each overflow page + ** in the overflow chain. The page number of the first overflow page is + ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array + ** means ""not yet known"" (the cache is lazily populated). + */ + if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){ + int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize; + if( pCur->aOverflow==0 + || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow) + ){ + Pgno *aNew = (Pgno*)sqlite3Realloc( + pCur->aOverflow, nOvfl*2*sizeof(Pgno) + ); + if( aNew==0 ){ + return SQLITE_NOMEM_BKPT; + }else{ + pCur->aOverflow = aNew; + } + } + memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); + pCur->curFlags |= BTCF_ValidOvfl; + }else{ + /* If the overflow page-list cache has been allocated and the + ** entry for the first required overflow page is valid, skip + ** directly to it. + */ + if( pCur->aOverflow[offset/ovflSize] ){ + iIdx = (offset/ovflSize); + nextPage = pCur->aOverflow[iIdx]; + offset = (offset%ovflSize); + } + } + + assert( rc==SQLITE_OK && amt>0 ); + while( nextPage ){ + /* If required, populate the overflow page-list cache. */ + assert( pCur->aOverflow[iIdx]==0 + || pCur->aOverflow[iIdx]==nextPage + || CORRUPT_DB ); + pCur->aOverflow[iIdx] = nextPage; + + if( offset>=ovflSize ){ + /* The only reason to read this page is to obtain the page + ** number for the next page in the overflow chain. The page + ** data is not required. So first try to lookup the overflow + ** page-list cache, if any, then fall back to the getOverflowPage() + ** function. + */ + assert( pCur->curFlags & BTCF_ValidOvfl ); + assert( pCur->pBtree->db==pBt->db ); + if( pCur->aOverflow[iIdx+1] ){ + nextPage = pCur->aOverflow[iIdx+1]; + }else{ + rc = getOverflowPage(pBt, nextPage, 0, &nextPage); + } + offset -= ovflSize; + }else{ + /* Need to read this page properly. It contains some of the + ** range of data that is being read (eOp==0) or written (eOp!=0). + */ + int a = amt; + if( a + offset > ovflSize ){ + a = ovflSize - offset; + } + +#ifdef SQLITE_DIRECT_OVERFLOW_READ + /* If all the following are true: + ** + ** 1) this is a read operation, and + ** 2) data is required from the start of this overflow page, and + ** 3) there are no dirty pages in the page-cache + ** 4) the database is file-backed, and + ** 5) the page is not in the WAL file + ** 6) at least 4 bytes have already been read into the output buffer + ** + ** then data can be read directly from the database file into the + ** output buffer, bypassing the page-cache altogether. This speeds + ** up loading large records that span many overflow pages. + */ + if( eOp==0 /* (1) */ + && offset==0 /* (2) */ + && sqlite3PagerDirectReadOk(pBt->pPager, nextPage) /* (3,4,5) */ + && &pBuf[-4]>=pBufStart /* (6) */ + ){ + sqlite3_file *fd = sqlite3PagerFile(pBt->pPager); + u8 aSave[4]; + u8 *aWrite = &pBuf[-4]; + assert( aWrite>=pBufStart ); /* due to (6) */ + memcpy(aSave, aWrite, 4); + rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1)); + nextPage = get4byte(aWrite); + memcpy(aWrite, aSave, 4); + }else +#endif + + { + DbPage *pDbPage; + rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage, + (eOp==0 ? PAGER_GET_READONLY : 0) + ); + if( rc==SQLITE_OK ){ + aPayload = sqlite3PagerGetData(pDbPage); + nextPage = get4byte(aPayload); + rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage); + sqlite3PagerUnref(pDbPage); + offset = 0; + } + } + amt -= a; + if( amt==0 ) return rc; + pBuf += a; + } + if( rc ) break; + iIdx++; + } + } + + if( rc==SQLITE_OK && amt>0 ){ + /* Overflow chain ends prematurely */ + return SQLITE_CORRUPT_PAGE(pPage); + } + return rc; +} +","@@ -31668,7 +31668,7 @@ SQLITE_PRIVATE VList *sqlite3VListAdd( + assert( pIn==0 || pIn[0]>=3 ); /* Verify ok to add new elements */ + if( pIn==0 || pIn[1]+nInt > pIn[0] ){ + /* Enlarge the allocation */ +- int nAlloc = (pIn ? pIn[0]*2 : 10) + nInt; ++ sqlite3_int64 nAlloc = (pIn ? 2*(sqlite3_int64)pIn[0] : 10) + nInt; + VList *pOut = sqlite3DbRealloc(db, pIn, nAlloc*sizeof(int)); + if( pOut==0 ) return pIn; + if( pIn==0 ) pOut[1] = 2; +@@ -76266,9 +76266,11 @@ static int growOpArray(Vdbe *v, int nOp){ + ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current + ** size of the op array or add 1KB of space, whichever is smaller. */ + #ifdef SQLITE_TEST_REALLOC_STRESS +- int nNew = (v->nOpAlloc>=512 ? v->nOpAlloc*2 : v->nOpAlloc+nOp); ++ sqlite3_int64 nNew = (v->nOpAlloc>=512 ? 2*(sqlite3_int64)v->nOpAlloc ++ : (sqlite3_int64)v->nOpAlloc+nOp); + #else +- int nNew = (v->nOpAlloc ? v->nOpAlloc*2 : (int)(1024/sizeof(Op))); ++ sqlite3_int64 nNew = (v->nOpAlloc ? 2*(sqlite3_int64)v->nOpAlloc ++ : (sqlite3_int64)1024/sizeof(Op)); + UNUSED_PARAMETER(nOp); + #endif + +@@ -77055,7 +77057,7 @@ SQLITE_PRIVATE void sqlite3VdbeScanStatus( + LogEst nEst, /* Estimated number of output rows */ + const char *zName /* Name of table or index being scanned */ + ){ +- int nByte = (p->nScan+1) * sizeof(ScanStatus); ++ sqlite3_int64 nByte = (p->nScan+1) * sizeof(ScanStatus); + ScanStatus *aNew; + aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte); + if( aNew ){ +@@ -92025,7 +92027,7 @@ static int vdbePmaReadBlob( + /* Extend the p->aAlloc[] allocation if required. */ + if( p->nAllocnAlloc*2); ++ sqlite3_int64 nNew = MAX(128, 2*(sqlite3_int64)p->nAlloc); + while( nByte>nNew ) nNew = nNew*2; + aNew = sqlite3Realloc(p->aAlloc, nNew); + if( !aNew ) return SQLITE_NOMEM_BKPT; +@@ -93317,7 +93319,7 @@ SQLITE_PRIVATE int sqlite3VdbeSorterWrite( + if( nMin>pSorter->nMemory ){ + u8 *aNew; + int iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory; +- int nNew = pSorter->nMemory * 2; ++ sqlite3_int64 nNew = 2 * (sqlite3_int64)pSorter->nMemory; + while( nNew < nMin ) nNew = nNew*2; + if( nNew > pSorter->mxPmaSize ) nNew = pSorter->mxPmaSize; + if( nNew < nMin ) nNew = nMin; +@@ -98229,7 +98231,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListAppend( + }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ + ExprList *pNew; + pNew = sqlite3DbRealloc(db, pList, +- sizeof(*pList)+(2*pList->nExpr - 1)*sizeof(pList->a[0])); ++ sizeof(*pList)+(2*(sqlite3_int64)pList->nExpr-1)*sizeof(pList->a[0])); + if( pNew==0 ){ + goto no_mem; + } +@@ -110336,9 +110338,9 @@ SQLITE_PRIVATE void *sqlite3ArrayAllocate( + int *pIdx /* Write the index of a new slot here */ + ){ + char *z; +- int n = *pnEntry; ++ sqlite3_int64 n = *pnEntry; + if( (n & (n-1))==0 ){ +- int sz = (n==0) ? 1 : 2*n; ++ sqlite3_int64 sz = (n==0) ? 1 : 2*n; + void *pNew = sqlite3DbRealloc(db, pArray, sz*szEntry); + if( pNew==0 ){ + *pIdx = -1; +@@ -110459,7 +110461,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge( + /* Allocate additional space if needed */ + if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){ + SrcList *pNew; +- int nAlloc = pSrc->nSrc*2+nExtra; ++ sqlite3_int64 nAlloc = 2*(sqlite3_int64)pSrc->nSrc+nExtra; + sqlite3 *db = pParse->db; + + if( pSrc->nSrc+nExtra>=SQLITE_MAX_SRCLIST ){ +@@ -111215,7 +111217,7 @@ SQLITE_PRIVATE With *sqlite3WithAdd( + } + + if( pWith ){ +- int nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte); ++ sqlite3_int64 nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte); + pNew = sqlite3DbRealloc(db, pWith, nByte); + }else{ + pNew = sqlite3DbMallocZero(db, sizeof(*pWith)); +@@ -134301,9 +134303,13 @@ SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){ + ** string will be freed automatically when the table is + ** deleted. + */ +-static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){ +- int nBytes = sizeof(char *)*(2+pTable->nModuleArg); ++static void addModuleArgument(Parse *pParse, Table *pTable, char *zArg){ ++ sqlite3_int64 nBytes = sizeof(char *)*(2+pTable->nModuleArg); + char **azModuleArg; ++ sqlite3 *db = pParse->db; ++ if( pTable->nModuleArg+3>=db->aLimit[SQLITE_LIMIT_COLUMN] ){ ++ sqlite3ErrorMsg(pParse, ""too many columns on %s"", pTable->zName); ++ } + azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes); + if( azModuleArg==0 ){ + sqlite3DbFree(db, zArg); +@@ -134338,9 +134344,9 @@ SQLITE_PRIVATE void sqlite3VtabBeginParse( + db = pParse->db; + + assert( pTable->nModuleArg==0 ); +- addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName)); +- addModuleArgument(db, pTable, 0); +- addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName)); ++ addModuleArgument(pParse, pTable, sqlite3NameFromToken(db, pModuleName)); ++ addModuleArgument(pParse, pTable, 0); ++ addModuleArgument(pParse, pTable, sqlite3DbStrDup(db, pTable->zName)); + assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0) + || (pParse->sNameToken.z==pName1->z && pName2->z==0) + ); +@@ -134373,7 +134379,7 @@ static void addArgumentToVtab(Parse *pParse){ + const char *z = (const char*)pParse->sArg.z; + int n = pParse->sArg.n; + sqlite3 *db = pParse->db; +- addModuleArgument(db, pParse->pNewTable, sqlite3DbStrNDup(db, z, n)); ++ addModuleArgument(pParse, pParse->pNewTable, sqlite3DbStrNDup(db, z, n)); + } + } + +@@ -134662,7 +134668,8 @@ static int growVTrans(sqlite3 *db){ + /* Grow the sqlite3.aVTrans array if required */ + if( (db->nVTrans%ARRAY_INCR)==0 ){ + VTable **aVTrans; +- int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR); ++ sqlite3_int64 nBytes = sizeof(sqlite3_vtab*)* ++ ((sqlite3_int64)db->nVTrans + ARRAY_INCR); + aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes); + if( !aVTrans ){ + return SQLITE_NOMEM_BKPT; +@@ -135158,9 +135165,9 @@ SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ + pTab->pSchema = db->aDb[0].pSchema; + assert( pTab->nModuleArg==0 ); + pTab->iPKey = -1; +- addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName)); +- addModuleArgument(db, pTab, 0); +- addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName)); ++ addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); ++ addModuleArgument(pParse, pTab, 0); ++ addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); + rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr); + if( rc ){ + sqlite3ErrorMsg(pParse, ""%s"", zErr); +@@ -153996,7 +154003,7 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ + pStart = 0; + }else if( pBuf==0 ){ + sqlite3BeginBenignMalloc(); +- pStart = sqlite3Malloc( sz*cnt ); /* IMP: R-61949-35727 */ ++ pStart = sqlite3Malloc( sz*(sqlite3_int64)cnt ); /* IMP: R-61949-35727 */ + sqlite3EndBenignMalloc(); + if( pStart ) cnt = sqlite3MallocSize(pStart)/sz; + }else{ +@@ -168038,8 +168045,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitTokenizer( + int iArg = 0; + z = &z[n+1]; + while( zzInput = sqlite3_malloc(nByte+1); ++ pCsr->zInput = sqlite3_malloc64(nByte+1); + if( pCsr->zInput==0 ){ + rc = SQLITE_NOMEM; + }else{ +@@ -170808,8 +170815,9 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderPending( + } + + if( nElem>0 ){ +- int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *); +- pReader = (Fts3SegReader *)sqlite3_malloc(nByte); ++ sqlite3_int64 nByte; ++ nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *); ++ pReader = (Fts3SegReader *)sqlite3_malloc64(nByte); + if( !pReader ){ + rc = SQLITE_NOMEM; + }else{ +@@ -172421,7 +172429,7 @@ static void fts3InsertDocsize( + int rc; /* Result code from subfunctions */ + + if( *pRC ) return; +- pBlob = sqlite3_malloc( 10*p->nColumn ); ++ pBlob = sqlite3_malloc64( 10*(sqlite3_int64)p->nColumn ); + if( pBlob==0 ){ + *pRC = SQLITE_NOMEM; + return; +@@ -172471,7 +172479,7 @@ static void fts3UpdateDocTotals( + const int nStat = p->nColumn+2; + + if( *pRC ) return; +- a = sqlite3_malloc( (sizeof(u32)+10)*nStat ); ++ a = sqlite3_malloc64( (sizeof(u32)+10)*(sqlite3_int64)nStat ); + if( a==0 ){ + *pRC = SQLITE_NOMEM; + return; +@@ -172592,8 +172600,8 @@ static int fts3DoRebuild(Fts3Table *p){ + } + + if( rc==SQLITE_OK ){ +- int nByte = sizeof(u32) * (p->nColumn+1)*3; +- aSz = (u32 *)sqlite3_malloc(nByte); ++ sqlite3_int64 nByte = sizeof(u32) * ((sqlite3_int64)p->nColumn+1)*3; ++ aSz = (u32 *)sqlite3_malloc64(nByte); + if( aSz==0 ){ + rc = SQLITE_NOMEM; + }else{ +@@ -172659,12 +172667,12 @@ static int fts3IncrmergeCsr( + ){ + int rc; /* Return Code */ + sqlite3_stmt *pStmt = 0; /* Statement used to read %_segdir entry */ +- int nByte; /* Bytes allocated at pCsr->apSegment[] */ ++ sqlite3_int64 nByte; /* Bytes allocated at pCsr->apSegment[] */ + + /* Allocate space for the Fts3MultiSegReader.aCsr[] array */ + memset(pCsr, 0, sizeof(*pCsr)); + nByte = sizeof(Fts3SegReader *) * nSeg; +- pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte); ++ pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc64(nByte); + + if( pCsr->apSegment==0 ){ + rc = SQLITE_NOMEM; +@@ -174644,7 +174652,7 @@ SQLITE_PRIVATE int sqlite3Fts3UpdateMethod( + } + + /* Allocate space to hold the change in document sizes */ +- aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 ); ++ aSzDel = sqlite3_malloc64(sizeof(aSzDel[0])*((sqlite3_int64)p->nColumn+1)*2); + if( aSzDel==0 ){ + rc = SQLITE_NOMEM; + goto update_out; +@@ -174900,10 +174908,11 @@ struct StrBuffer { + */ + static MatchinfoBuffer *fts3MIBufferNew(int nElem, const char *zMatchinfo){ + MatchinfoBuffer *pRet; +- int nByte = sizeof(u32) * (2*nElem + 1) + sizeof(MatchinfoBuffer); +- int nStr = (int)strlen(zMatchinfo); ++ sqlite3_int64 nByte = sizeof(u32) * (2*(sqlite3_int64)nElem + 1) ++ + sizeof(MatchinfoBuffer); ++ sqlite3_int64 nStr = strlen(zMatchinfo); + +- pRet = sqlite3_malloc(nByte + nStr+1); ++ pRet = sqlite3_malloc64(nByte + nStr+1); + if( pRet ){ + memset(pRet, 0, nByte); + pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet; +@@ -184388,7 +184397,7 @@ static GeoPoly *geopolyParseJson(const unsigned char *z, int *pRc){ + GeoPoly *pOut; + int x = 1; + s.nVertex--; /* Remove the redundant vertex at the end */ +- pOut = sqlite3_malloc64( GEOPOLY_SZ(s.nVertex) ); ++ pOut = sqlite3_malloc64( GEOPOLY_SZ((sqlite3_int64)s.nVertex) ); + x = 1; + if( pOut==0 ) goto parse_json_err; + pOut->nVertex = s.nVertex; +@@ -184774,7 +184783,7 @@ static GeoPoly *geopolyBBox( + if( pRc ) *pRc = SQLITE_OK; + if( aCoord==0 ){ + geopolyBboxFill: +- pOut = sqlite3_realloc(p, GEOPOLY_SZ(4)); ++ pOut = sqlite3_realloc64(p, GEOPOLY_SZ(4)); + if( pOut==0 ){ + sqlite3_free(p); + if( context ) sqlite3_result_error_nomem(context); +@@ -185170,9 +185179,9 @@ static GeoSegment *geopolySortSegmentsByYAndC(GeoSegment *pList){ + ** Determine the overlap between two polygons + */ + static int geopolyOverlap(GeoPoly *p1, GeoPoly *p2){ +- int nVertex = p1->nVertex + p2->nVertex + 2; ++ sqlite3_int64 nVertex = p1->nVertex + p2->nVertex + 2; + GeoOverlap *p; +- int nByte; ++ sqlite3_int64 nByte; + GeoEvent *pThisEvent; + double rX; + int rc = 0; +@@ -185184,7 +185193,7 @@ static int geopolyOverlap(GeoPoly *p1, GeoPoly *p2){ + nByte = sizeof(GeoEvent)*nVertex*2 + + sizeof(GeoSegment)*nVertex + + sizeof(GeoOverlap); +- p = sqlite3_malloc( nByte ); ++ p = sqlite3_malloc64( nByte ); + if( p==0 ) return -1; + p->aEvent = (GeoEvent*)&p[1]; + p->aSegment = (GeoSegment*)&p->aEvent[nVertex*2]; +@@ -185343,18 +185352,18 @@ static int geopolyInit( + ){ + int rc = SQLITE_OK; + Rtree *pRtree; +- int nDb; /* Length of string argv[1] */ +- int nName; /* Length of string argv[2] */ ++ sqlite3_int64 nDb; /* Length of string argv[1] */ ++ sqlite3_int64 nName; /* Length of string argv[2] */ + sqlite3_str *pSql; + char *zSql; + int ii; + + sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); + + /* Allocate the sqlite3_vtab structure */ +- nDb = (int)strlen(argv[1]); +- nName = (int)strlen(argv[2]); +- pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2); ++ nDb = strlen(argv[1]); ++ nName = strlen(argv[2]); ++ pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); + if( !pRtree ){ + return SQLITE_NOMEM; + } +@@ -218315,7 +218324,7 @@ static int fts5UnicodeCreate( + + p->eRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE; + p->nFold = 64; +- p->aFold = sqlite3_malloc(p->nFold * sizeof(char)); ++ p->aFold = sqlite3_malloc64(p->nFold * sizeof(char)); + if( p->aFold==0 ){ + rc = SQLITE_NOMEM; + } +@@ -221434,7 +221443,7 @@ SQLITE_API int sqlite3_stmt_init( + #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ + + /************** End of stmt.c ************************************************/ +-#if __LINE__!=221437 ++#if __LINE__!=221446 + #undef SQLITE_SOURCE_ID + #define SQLITE_SOURCE_ID ""2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0alt2"" + #endif",1828,2064,4096 +17787,"static bool ldb_dn_explode(struct ldb_dn *dn) +{ + char *p, *ex_name = NULL, *ex_value = NULL, *data, *d, *dt, *t; + bool trim = true; + bool in_extended = true; + bool in_ex_name = false; + bool in_ex_value = false; + bool in_attr = false; + bool in_value = false; + bool in_quote = false; + bool is_oid = false; + bool escape = false; + unsigned int x; + size_t l = 0; + int ret; + char *parse_dn; + bool is_index; + + if ( ! dn || dn->invalid) return false; + + if (dn->components) { + return true; + } + + if (dn->ext_linearized) { + parse_dn = dn->ext_linearized; + } else { + parse_dn = dn->linearized; + } + + if ( ! parse_dn ) { + return false; + } + + is_index = (strncmp(parse_dn, ""DN=@INDEX:"", 10) == 0); + + /* Empty DNs */ + if (parse_dn[0] == '\0') { + return true; + } + + /* Special DNs case */ + if (dn->special) { + return true; + } + + /* make sure we free this if allocated previously before replacing */ + LDB_FREE(dn->components); + dn->comp_num = 0; + + LDB_FREE(dn->ext_components); + dn->ext_comp_num = 0; + + /* in the common case we have 3 or more components */ + /* make sure all components are zeroed, other functions depend on it */ + dn->components = talloc_zero_array(dn, struct ldb_dn_component, 3); + if ( ! dn->components) { + return false; + } + + /* Components data space is allocated here once */ + data = talloc_array(dn->components, char, strlen(parse_dn) + 1); + if (!data) { + return false; + } + + p = parse_dn; + t = NULL; + d = dt = data; + + while (*p) { + if (in_extended) { + + if (!in_ex_name && !in_ex_value) { + + if (p[0] == '<') { + p++; + ex_name = d; + in_ex_name = true; + continue; + } else if (p[0] == '\0') { + p++; + continue; + } else { + in_extended = false; + in_attr = true; + dt = d; + + continue; + } + } + + if (in_ex_name && *p == '=') { + *d++ = '\0'; + p++; + ex_value = d; + in_ex_name = false; + in_ex_value = true; + continue; + } + + if (in_ex_value && *p == '>') { + const struct ldb_dn_extended_syntax *ext_syntax; + struct ldb_val ex_val = { + .data = (uint8_t *)ex_value, + .length = d - ex_value + }; + + *d++ = '\0'; + p++; + in_ex_value = false; + + /* Process name and ex_value */ + + dn->ext_components = talloc_realloc(dn, + dn->ext_components, + struct ldb_dn_ext_component, + dn->ext_comp_num + 1); + if ( ! dn->ext_components) { + /* ouch ! */ + goto failed; + } + + ext_syntax = ldb_dn_extended_syntax_by_name(dn->ldb, ex_name); + if (!ext_syntax) { + /* We don't know about this type of extended DN */ + goto failed; + } + + dn->ext_components[dn->ext_comp_num].name = talloc_strdup(dn->ext_components, ex_name); + if (!dn->ext_components[dn->ext_comp_num].name) { + /* ouch */ + goto failed; + } + ret = ext_syntax->read_fn(dn->ldb, dn->ext_components, + &ex_val, &dn->ext_components[dn->ext_comp_num].value); + if (ret != LDB_SUCCESS) { + ldb_dn_mark_invalid(dn); + goto failed; + } + + dn->ext_comp_num++; + + if (*p == '\0') { + /* We have reached the end (extended component only)! */ + talloc_free(data); + return true; + + } else if (*p == ';') { + p++; + continue; + } else { + ldb_dn_mark_invalid(dn); + goto failed; + } + } + + *d++ = *p++; + continue; + } + if (in_attr) { + if (trim) { + if (*p == ' ') { + p++; + continue; + } + + /* first char */ + trim = false; + + if (!isascii(*p)) { + /* attr names must be ascii only */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + if (isdigit(*p)) { + is_oid = true; + } else + if ( ! isalpha(*p)) { + /* not a digit nor an alpha, + * invalid attribute name */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + /* Copy this character across from parse_dn, + * now we have trimmed out spaces */ + *d++ = *p++; + continue; + } + + if (*p == ' ') { + p++; + /* valid only if we are at the end */ + trim = true; + continue; + } + + if (trim && (*p != '=')) { + /* spaces/tabs are not allowed */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + if (*p == '=') { + /* attribute terminated */ + in_attr = false; + in_value = true; + trim = true; + l = 0; + + /* Terminate this string in d + * (which is a copy of parse_dn + * with spaces trimmed) */ + *d++ = '\0'; + dn->components[dn->comp_num].name = talloc_strdup(dn->components, dt); + if ( ! dn->components[dn->comp_num].name) { + /* ouch */ + goto failed; + } + + dt = d; + + p++; + continue; + } + + if (!isascii(*p)) { + /* attr names must be ascii only */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + if (is_oid && ( ! (isdigit(*p) || (*p == '.')))) { + /* not a digit nor a dot, + * invalid attribute oid */ + ldb_dn_mark_invalid(dn); + goto failed; + } else + if ( ! (isalpha(*p) || isdigit(*p) || (*p == '-'))) { + /* not ALPHA, DIGIT or HYPHEN */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + *d++ = *p++; + continue; + } + + if (in_value) { + if (in_quote) { + if (*p == '\""') { + if (p[-1] != '\\') { + p++; + in_quote = false; + continue; + } + } + *d++ = *p++; + l++; + continue; + } + + if (trim) { + if (*p == ' ') { + p++; + continue; + } + + /* first char */ + trim = false; + + if (*p == '\""') { + in_quote = true; + p++; + continue; + } + } + + switch (*p) { + + /* TODO: support ber encoded values + case '#': + */ + + case ',': + if (escape) { + *d++ = *p++; + l++; + escape = false; + continue; + } + /* ok found value terminator */ + + if ( t ) { + /* trim back */ + d -= (p - t); + l -= (p - t); + } + + in_attr = true; + in_value = false; + trim = true; + + p++; + *d++ = '\0'; + dn->components[dn->comp_num].value.data = (uint8_t *)talloc_strdup(dn->components, dt); + dn->components[dn->comp_num].value.length = l; + if ( ! dn->components[dn->comp_num].value.data) { + /* ouch ! */ + goto failed; + } + + dt = d; + + dn->components, + struct ldb_dn_component, + dn->comp_num + 1); + if ( ! dn->components) { + /* ouch ! */ + goto failed; + } + /* make sure all components are zeroed, other functions depend on this */ + memset(&dn->components[dn->comp_num], '\0', sizeof(struct ldb_dn_component)); + } + + continue; + + case '+': + case '=': + /* to main compatibility with earlier + versions of ldb indexing, we have to + accept the base64 encoded binary index + values, which contain a '+' or '=' + which should normally be escaped */ + if (is_index) { + if ( t ) t = NULL; + *d++ = *p++; + l++; + break; + } + /* fall through */ + case '\""': + case '<': + case '>': + case ';': + /* a string with not escaped specials is invalid (tested) */ + if ( ! escape) { + ldb_dn_mark_invalid(dn); + goto failed; + } + escape = false; + + *d++ = *p++; + l++; + + if ( t ) t = NULL; + break; + + case '\\': + if ( ! escape) { + escape = true; + p++; + continue; + } + escape = false; + + *d++ = *p++; + l++; + + if ( t ) t = NULL; + break; + + default: + if (escape) { + if (isxdigit(p[0]) && isxdigit(p[1])) { + if (sscanf(p, ""%02x"", &x) != 1) { + /* invalid escaping sequence */ + ldb_dn_mark_invalid(dn); + goto failed; + } + p += 2; + *d++ = (unsigned char)x; + } else { + *d++ = *p++; + } + + escape = false; + l++; + if ( t ) t = NULL; + break; + } + + if (*p == ' ') { + if ( ! t) t = p; + } else { + if ( t ) t = NULL; + } + + *d++ = *p++; + l++; + + break; + } + + } + } +",1,"static bool ldb_dn_explode(struct ldb_dn *dn) +{ + char *p, *ex_name = NULL, *ex_value = NULL, *data, *d, *dt, *t; + bool trim = true; + bool in_extended = true; + bool in_ex_name = false; + bool in_ex_value = false; + bool in_attr = false; + bool in_value = false; + bool in_quote = false; + bool is_oid = false; + bool escape = false; + unsigned int x; + size_t l = 0; + int ret; + char *parse_dn; + bool is_index; + + if ( ! dn || dn->invalid) return false; + + if (dn->components) { + return true; + } + + if (dn->ext_linearized) { + parse_dn = dn->ext_linearized; + } else { + parse_dn = dn->linearized; + } + + if ( ! parse_dn ) { + return false; + } + + is_index = (strncmp(parse_dn, ""DN=@INDEX:"", 10) == 0); + + /* Empty DNs */ + if (parse_dn[0] == '\0') { + return true; + } + + /* Special DNs case */ + if (dn->special) { + return true; + } + + /* make sure we free this if allocated previously before replacing */ + LDB_FREE(dn->components); + dn->comp_num = 0; + + LDB_FREE(dn->ext_components); + dn->ext_comp_num = 0; + + /* in the common case we have 3 or more components */ + /* make sure all components are zeroed, other functions depend on it */ + dn->components = talloc_zero_array(dn, struct ldb_dn_component, 3); + if ( ! dn->components) { + return false; + } + + /* Components data space is allocated here once */ + data = talloc_array(dn->components, char, strlen(parse_dn) + 1); + if (!data) { + return false; + } + + p = parse_dn; + t = NULL; + d = dt = data; + + while (*p) { + if (in_extended) { + + if (!in_ex_name && !in_ex_value) { + + if (p[0] == '<') { + p++; + ex_name = d; + in_ex_name = true; + continue; + } else if (p[0] == '\0') { + p++; + continue; + } else { + in_extended = false; + in_attr = true; + dt = d; + + continue; + } + } + + if (in_ex_name && *p == '=') { + *d++ = '\0'; + p++; + ex_value = d; + in_ex_name = false; + in_ex_value = true; + continue; + } + + if (in_ex_value && *p == '>') { + const struct ldb_dn_extended_syntax *ext_syntax; + struct ldb_val ex_val = { + .data = (uint8_t *)ex_value, + .length = d - ex_value + }; + + *d++ = '\0'; + p++; + in_ex_value = false; + + /* Process name and ex_value */ + + dn->ext_components = talloc_realloc(dn, + dn->ext_components, + struct ldb_dn_ext_component, + dn->ext_comp_num + 1); + if ( ! dn->ext_components) { + /* ouch ! */ + goto failed; + } + + ext_syntax = ldb_dn_extended_syntax_by_name(dn->ldb, ex_name); + if (!ext_syntax) { + /* We don't know about this type of extended DN */ + goto failed; + } + + dn->ext_components[dn->ext_comp_num].name = talloc_strdup(dn->ext_components, ex_name); + if (!dn->ext_components[dn->ext_comp_num].name) { + /* ouch */ + goto failed; + } + ret = ext_syntax->read_fn(dn->ldb, dn->ext_components, + &ex_val, &dn->ext_components[dn->ext_comp_num].value); + if (ret != LDB_SUCCESS) { + ldb_dn_mark_invalid(dn); + goto failed; + } + + dn->ext_comp_num++; + + if (*p == '\0') { + /* We have reached the end (extended component only)! */ + talloc_free(data); + return true; + + } else if (*p == ';') { + p++; + continue; + } else { + ldb_dn_mark_invalid(dn); + goto failed; + } + } + + *d++ = *p++; + continue; + } + if (in_attr) { + if (trim) { + if (*p == ' ') { + p++; + continue; + } + + /* first char */ + trim = false; + + if (!isascii(*p)) { + /* attr names must be ascii only */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + if (isdigit(*p)) { + is_oid = true; + } else + if ( ! isalpha(*p)) { + /* not a digit nor an alpha, + * invalid attribute name */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + /* Copy this character across from parse_dn, + * now we have trimmed out spaces */ + *d++ = *p++; + continue; + } + + if (*p == ' ') { + p++; + /* valid only if we are at the end */ + trim = true; + continue; + } + + if (trim && (*p != '=')) { + /* spaces/tabs are not allowed */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + if (*p == '=') { + /* attribute terminated */ + in_attr = false; + in_value = true; + trim = true; + l = 0; + + /* Terminate this string in d + * (which is a copy of parse_dn + * with spaces trimmed) */ + *d++ = '\0'; + dn->components[dn->comp_num].name = talloc_strdup(dn->components, dt); + if ( ! dn->components[dn->comp_num].name) { + /* ouch */ + goto failed; + } + + dt = d; + + p++; + continue; + } + + if (!isascii(*p)) { + /* attr names must be ascii only */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + if (is_oid && ( ! (isdigit(*p) || (*p == '.')))) { + /* not a digit nor a dot, + * invalid attribute oid */ + ldb_dn_mark_invalid(dn); + goto failed; + } else + if ( ! (isalpha(*p) || isdigit(*p) || (*p == '-'))) { + /* not ALPHA, DIGIT or HYPHEN */ + ldb_dn_mark_invalid(dn); + goto failed; + } + + *d++ = *p++; + continue; + } + + if (in_value) { + if (in_quote) { + if (*p == '\""') { + if (p[-1] != '\\') { + p++; + in_quote = false; + continue; + } + } + *d++ = *p++; + l++; + continue; + } + + if (trim) { + if (*p == ' ') { + p++; + continue; + } + + /* first char */ + trim = false; + + if (*p == '\""') { + in_quote = true; + p++; + continue; + } + } + + switch (*p) { + + /* TODO: support ber encoded values + case '#': + */ + + case ',': + if (escape) { + *d++ = *p++; + l++; + escape = false; + continue; + } + /* ok found value terminator */ + + if ( t ) { + /* trim back */ + d -= (p - t); + l -= (p - t); + } + + in_attr = true; + in_value = false; + trim = true; + + p++; + *d++ = '\0'; + dn->components[dn->comp_num].value.data = \ + (uint8_t *)talloc_memdup(dn->components, dt, l + 1); + dn->components[dn->comp_num].value.length = l; + if ( ! dn->components[dn->comp_num].value.data) { + /* ouch ! */ + goto failed; + } + talloc_set_name_const(dn->components[dn->comp_num].value.data, + (const char *)dn->components[dn->comp_num].value.data); + + dt = d; + + dn->components, + struct ldb_dn_component, + dn->comp_num + 1); + if ( ! dn->components) { + /* ouch ! */ + goto failed; + } + /* make sure all components are zeroed, other functions depend on this */ + memset(&dn->components[dn->comp_num], '\0', sizeof(struct ldb_dn_component)); + } + + continue; + + case '+': + case '=': + /* to main compatibility with earlier + versions of ldb indexing, we have to + accept the base64 encoded binary index + values, which contain a '+' or '=' + which should normally be escaped */ + if (is_index) { + if ( t ) t = NULL; + *d++ = *p++; + l++; + break; + } + /* fall through */ + case '\""': + case '<': + case '>': + case ';': + /* a string with not escaped specials is invalid (tested) */ + if ( ! escape) { + ldb_dn_mark_invalid(dn); + goto failed; + } + escape = false; + + *d++ = *p++; + l++; + + if ( t ) t = NULL; + break; + + case '\\': + if ( ! escape) { + escape = true; + p++; + continue; + } + escape = false; + + *d++ = *p++; + l++; + + if ( t ) t = NULL; + break; + + default: + if (escape) { + if (isxdigit(p[0]) && isxdigit(p[1])) { + if (sscanf(p, ""%02x"", &x) != 1) { + /* invalid escaping sequence */ + ldb_dn_mark_invalid(dn); + goto failed; + } + p += 2; + *d++ = (unsigned char)x; + } else { + *d++ = *p++; + } + + escape = false; + l++; + if ( t ) t = NULL; + break; + } + + if (*p == ' ') { + if ( ! t) t = p; + } else { + if ( t ) t = NULL; + } + + *d++ = *p++; + l++; + + break; + } + + } + } +","@@ -586,12 +586,15 @@ static bool ldb_dn_explode(struct ldb_dn *dn) + + p++; + *d++ = '\0'; +- dn->components[dn->comp_num].value.data = (uint8_t *)talloc_strdup(dn->components, dt); ++ dn->components[dn->comp_num].value.data = \ ++ (uint8_t *)talloc_memdup(dn->components, dt, l + 1); + dn->components[dn->comp_num].value.length = l; + if ( ! dn->components[dn->comp_num].value.data) { + /* ouch ! */ + goto failed; + } ++ talloc_set_name_const(dn->components[dn->comp_num].value.data, ++ (const char *)dn->components[dn->comp_num].value.data); + + dt = d; + +@@ -707,11 +710,13 @@ static bool ldb_dn_explode(struct ldb_dn *dn) + *d++ = '\0'; + dn->components[dn->comp_num].value.length = l; + dn->components[dn->comp_num].value.data = +- (uint8_t *)talloc_strdup(dn->components, dt); ++ (uint8_t *)talloc_memdup(dn->components, dt, l + 1); + if ( ! dn->components[dn->comp_num].value.data) { + /* ouch */ + goto failed; + } ++ talloc_set_name_const(dn->components[dn->comp_num].value.data, ++ (const char *)dn->components[dn->comp_num].value.data); + + dn->comp_num++;",2370,2606,4096 +18106,"lldp_private_8021_print(netdissect_options *ndo, + const u_char *tptr, u_int tlv_len) +{ + int subtype, hexdump = FALSE; + u_int sublen; + u_int tval; + uint8_t i; + + if (tlv_len < 4) { + return hexdump; + } + subtype = *(tptr+3); + + ND_PRINT((ndo, ""\n\t %s Subtype (%u)"", + tok2str(lldp_8021_subtype_values, ""unknown"", subtype), + subtype)); + + switch (subtype) { + case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID: + if (tlv_len < 6) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t port vlan id (PVID): %u"", + EXTRACT_16BITS(tptr + 4))); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID: + if (tlv_len < 7) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)"", + EXTRACT_16BITS(tptr+5), + bittok2str(lldp_8021_port_protocol_id_values, ""none"", *(tptr+4)), + *(tptr + 4))); + break; + case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME: + if (tlv_len < 6) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t vlan id (VID): %u"", EXTRACT_16BITS(tptr + 4))); + if (tlv_len < 7) { + return hexdump; + } + sublen = *(tptr+6); + if (tlv_len < 7+sublen) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t vlan name: "")); + safeputs(ndo, tptr + 7, sublen); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: + if (tlv_len < 5) { + return hexdump; + } + sublen = *(tptr+4); + if (tlv_len < 5+sublen) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t protocol identity: "")); + safeputs(ndo, tptr + 5, sublen); + break; + case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION: + if(tlv_len> i) & 0x01)); + tval=*(tptr+5); + ND_PRINT((ndo, ""\n\t Pre-Priority Ready Indicator"")); + ND_PRINT((ndo, ""\n\t Priority : 0 1 2 3 4 5 6 7"")); + ND_PRINT((ndo, ""\n\t Value : "")); + for(i=0;i> i) & 0x01)); + break; + + case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION: + if(tlv_len> 7, (tval >> 6) & 0x02, (tval >> 3) & 0x07, tval & 0x07)); + + /*Print Priority Assignment Table*/ + print_ets_priority_assignment_table(ndo, tptr + 5); + + /*Print TC Bandwidth Table*/ + print_tc_bandwidth_table(ndo, tptr + 9); + + /* Print TSA Assignment Table */ + print_tsa_assignment_table(ndo, tptr + 17); + + break; + + case LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION: + if(tlv_len> 7, (tval >> 6) & 0x01, (tval >> 4) & 0x03, (tval & 0x0f))); + ND_PRINT((ndo, ""\n\t PFC Enable"")); + tval=*(tptr+5); + ND_PRINT((ndo, ""\n\t Priority : 0 1 2 3 4 5 6 7"")); + ND_PRINT((ndo, ""\n\t Value : "")); + for(i=0;i> i) & 0x01)); + break; + + case LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY: + if(tlv_len> 5, (tval >> 3) & 0x03, (tval & 0x07))); + ND_PRINT((ndo, ""Protocol ID: %d"", EXTRACT_16BITS(tptr + i + 5))); + i=i+3; + } + break; + case LLDP_PRIVATE_8021_SUBTYPE_EVB: + if(tlv_len> 3, (tval >> 2) & 0x01, (tval >> 1) & 0x01, tval & 0x01)); + ND_PRINT((ndo, ""\n\t EVB Station Status"")); + tval=*(tptr+5); + ND_PRINT((ndo, ""\n\t RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d"", + tval >> 4, (tval >> 3) & 0x01, (tval >> 2) & 0x01, tval & 0x03)); + tval=*(tptr+6); + ND_PRINT((ndo, ""\n\t R: %d, RTE: %d, "",tval >> 5, tval & 0x1f)); + tval=*(tptr+7); + ND_PRINT((ndo, ""EVB Mode: %s [%d]"", + tok2str(lldp_evb_mode_values, ""unknown"", tval >> 6), tval >> 6)); + ND_PRINT((ndo, ""\n\t ROL: %d, RWD: %d, "", (tval >> 5) & 0x01, tval & 0x1f)); + tval=*(tptr+8); + ND_PRINT((ndo, ""RES: %d, ROL: %d, RKA: %d"", tval >> 6, (tval >> 5) & 0x01, tval & 0x1f)); + break; + + case LLDP_PRIVATE_8021_SUBTYPE_CDCP: + if(tlv_len> 7, (tval >> 4) & 0x07, (tval >> 3) & 0x01)); + ND_PRINT((ndo, ""ChnCap: %d"", EXTRACT_16BITS(tptr + 6) & 0x0fff)); + sublen=tlv_len-8; + if(sublen%3!=0) { + return hexdump; + } + i=0; + while(i> 12, tval & 0x000fff)); + i=i+3; + } + break; + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} +",1,"lldp_private_8021_print(netdissect_options *ndo, + const u_char *tptr, u_int tlv_len) +{ + int subtype, hexdump = FALSE; + u_int sublen; + u_int tval; + u_int i; + + if (tlv_len < 4) { + return hexdump; + } + subtype = *(tptr+3); + + ND_PRINT((ndo, ""\n\t %s Subtype (%u)"", + tok2str(lldp_8021_subtype_values, ""unknown"", subtype), + subtype)); + + switch (subtype) { + case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID: + if (tlv_len < 6) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t port vlan id (PVID): %u"", + EXTRACT_16BITS(tptr + 4))); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID: + if (tlv_len < 7) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)"", + EXTRACT_16BITS(tptr+5), + bittok2str(lldp_8021_port_protocol_id_values, ""none"", *(tptr+4)), + *(tptr + 4))); + break; + case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME: + if (tlv_len < 6) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t vlan id (VID): %u"", EXTRACT_16BITS(tptr + 4))); + if (tlv_len < 7) { + return hexdump; + } + sublen = *(tptr+6); + if (tlv_len < 7+sublen) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t vlan name: "")); + safeputs(ndo, tptr + 7, sublen); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: + if (tlv_len < 5) { + return hexdump; + } + sublen = *(tptr+4); + if (tlv_len < 5+sublen) { + return hexdump; + } + ND_PRINT((ndo, ""\n\t protocol identity: "")); + safeputs(ndo, tptr + 5, sublen); + break; + case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION: + if(tlv_len> i) & 0x01)); + tval=*(tptr+5); + ND_PRINT((ndo, ""\n\t Pre-Priority Ready Indicator"")); + ND_PRINT((ndo, ""\n\t Priority : 0 1 2 3 4 5 6 7"")); + ND_PRINT((ndo, ""\n\t Value : "")); + for(i=0;i> i) & 0x01)); + break; + + case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION: + if(tlv_len> 7, (tval >> 6) & 0x02, (tval >> 3) & 0x07, tval & 0x07)); + + /*Print Priority Assignment Table*/ + print_ets_priority_assignment_table(ndo, tptr + 5); + + /*Print TC Bandwidth Table*/ + print_tc_bandwidth_table(ndo, tptr + 9); + + /* Print TSA Assignment Table */ + print_tsa_assignment_table(ndo, tptr + 17); + + break; + + case LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION: + if(tlv_len> 7, (tval >> 6) & 0x01, (tval >> 4) & 0x03, (tval & 0x0f))); + ND_PRINT((ndo, ""\n\t PFC Enable"")); + tval=*(tptr+5); + ND_PRINT((ndo, ""\n\t Priority : 0 1 2 3 4 5 6 7"")); + ND_PRINT((ndo, ""\n\t Value : "")); + for(i=0;i> i) & 0x01)); + break; + + case LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY: + if(tlv_len> 5, (tval >> 3) & 0x03, (tval & 0x07), + EXTRACT_16BITS(tptr + i + 5))); + i=i+3; + } + break; + case LLDP_PRIVATE_8021_SUBTYPE_EVB: + if(tlv_len> 3, (tval >> 2) & 0x01, (tval >> 1) & 0x01, tval & 0x01)); + ND_PRINT((ndo, ""\n\t EVB Station Status"")); + tval=*(tptr+5); + ND_PRINT((ndo, ""\n\t RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d"", + tval >> 4, (tval >> 3) & 0x01, (tval >> 2) & 0x01, tval & 0x03)); + tval=*(tptr+6); + ND_PRINT((ndo, ""\n\t R: %d, RTE: %d, "",tval >> 5, tval & 0x1f)); + tval=*(tptr+7); + ND_PRINT((ndo, ""EVB Mode: %s [%d]"", + tok2str(lldp_evb_mode_values, ""unknown"", tval >> 6), tval >> 6)); + ND_PRINT((ndo, ""\n\t ROL: %d, RWD: %d, "", (tval >> 5) & 0x01, tval & 0x1f)); + tval=*(tptr+8); + ND_PRINT((ndo, ""RES: %d, ROL: %d, RKA: %d"", tval >> 6, (tval >> 5) & 0x01, tval & 0x1f)); + break; + + case LLDP_PRIVATE_8021_SUBTYPE_CDCP: + if(tlv_len> 7, (tval >> 4) & 0x07, (tval >> 3) & 0x01)); + ND_PRINT((ndo, ""ChnCap: %d"", EXTRACT_16BITS(tptr + 6) & 0x0fff)); + sublen=tlv_len-8; + if(sublen%3!=0) { + return hexdump; + } + i=0; + while(i> 12, tval & 0x000fff)); + i=i+3; + } + break; + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} +","@@ -651,7 +651,7 @@ lldp_private_8021_print(netdissect_options *ndo, + int subtype, hexdump = FALSE; + u_int sublen; + u_int tval; +- uint8_t i; ++ u_int i; + + if (tlv_len < 4) { + return hexdump; +@@ -787,9 +787,9 @@ lldp_private_8021_print(netdissect_options *ndo, + ND_PRINT((ndo, ""\n\t Application Priority Table"")); + while(i> 5, (tval >> 3) & 0x03, (tval & 0x07))); +- ND_PRINT((ndo, ""Protocol ID: %d"", EXTRACT_16BITS(tptr + i + 5))); ++ ND_PRINT((ndo, ""\n\t Priority: %u, RES: %u, Sel: %u, Protocol ID: %u"", ++ tval >> 5, (tval >> 3) & 0x03, (tval & 0x07), ++ EXTRACT_16BITS(tptr + i + 5))); + i=i+3; + } + break;",2427,2663,4096 +4169,"tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb, + u32 prior_snd_una) +{ + const struct inet_connection_sock *icsk = inet_csk(sk); + struct tcp_sock *tp = tcp_sk(sk); + const unsigned char *ptr = (skb_transport_header(ack_skb) + + TCP_SKB_CB(ack_skb)->sacked); + struct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2); + struct tcp_sack_block sp[TCP_NUM_SACKS]; + struct tcp_sack_block *cache; + struct tcp_sacktag_state state; + struct sk_buff *skb; + int num_sacks = min(TCP_NUM_SACKS, (ptr[1] - TCPOLEN_SACK_BASE) >> 3); + int used_sacks; + int found_dup_sack = 0; + int i, j; + int first_sack_index; + + state.flag = 0; + state.reord = tp->packets_out; + + if (!tp->sacked_out) { + if (WARN_ON(tp->fackets_out)) + tp->fackets_out = 0; + tcp_highest_sack_reset(sk); + } + + found_dup_sack = tcp_check_dsack(sk, ack_skb, sp_wire, + num_sacks, prior_snd_una); + if (found_dup_sack) + state.flag |= FLAG_DSACKING_ACK; + + /* Eliminate too old ACKs, but take into + * account more or less fresh ones, they can + * contain valid SACK info. + */ + if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window)) + return 0; + + if (!tp->packets_out) + goto out; + + used_sacks = 0; + first_sack_index = 0; + for (i = 0; i < num_sacks; i++) { + int dup_sack = !i && found_dup_sack; + + sp[used_sacks].start_seq = get_unaligned_be32(&sp_wire[i].start_seq); + sp[used_sacks].end_seq = get_unaligned_be32(&sp_wire[i].end_seq); + + if (!tcp_is_sackblock_valid(tp, dup_sack, + sp[used_sacks].start_seq, + sp[used_sacks].end_seq)) { + int mib_idx; + + if (dup_sack) { + if (!tp->undo_marker) + mib_idx = LINUX_MIB_TCPDSACKIGNOREDNOUNDO; + else + mib_idx = LINUX_MIB_TCPDSACKIGNOREDOLD; + } else { + /* Don't count olds caused by ACK reordering */ + if ((TCP_SKB_CB(ack_skb)->ack_seq != tp->snd_una) && + !after(sp[used_sacks].end_seq, tp->snd_una)) + continue; + mib_idx = LINUX_MIB_TCPSACKDISCARD; + } + + NET_INC_STATS_BH(sock_net(sk), mib_idx); + if (i == 0) + first_sack_index = -1; + continue; + } + + /* Ignore very old stuff early */ + if (!after(sp[used_sacks].end_seq, prior_snd_una)) + continue; + + used_sacks++; + } + + /* order SACK blocks to allow in order walk of the retrans queue */ + for (i = used_sacks - 1; i > 0; i--) { + for (j = 0; j < i; j++) { + if (after(sp[j].start_seq, sp[j + 1].start_seq)) { + swap(sp[j], sp[j + 1]); + + /* Track where the first SACK block goes to */ + if (j == first_sack_index) + first_sack_index = j + 1; + } + } + } + + skb = tcp_write_queue_head(sk); + state.fack_count = 0; + i = 0; + + if (!tp->sacked_out) { + /* It's already past, so skip checking against it */ + cache = tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache); + } else { + cache = tp->recv_sack_cache; + /* Skip empty blocks in at head of the cache */ + while (tcp_sack_cache_ok(tp, cache) && !cache->start_seq && + !cache->end_seq) + cache++; + } + + while (i < used_sacks) { + u32 start_seq = sp[i].start_seq; + u32 end_seq = sp[i].end_seq; + int dup_sack = (found_dup_sack && (i == first_sack_index)); + struct tcp_sack_block *next_dup = NULL; + + if (found_dup_sack && ((i + 1) == first_sack_index)) + next_dup = &sp[i + 1]; + + /* Event ""B"" in the comment above. */ + if (after(end_seq, tp->high_seq)) + state.flag |= FLAG_DATA_LOST; + + /* Skip too early cached blocks */ + while (tcp_sack_cache_ok(tp, cache) && + !before(start_seq, cache->end_seq)) + cache++; + + /* Can skip some work by looking recv_sack_cache? */ + if (tcp_sack_cache_ok(tp, cache) && !dup_sack && + after(end_seq, cache->start_seq)) { + + /* Head todo? */ + if (before(start_seq, cache->start_seq)) { + skb = tcp_sacktag_skip(skb, sk, &state, + start_seq); + skb = tcp_sacktag_walk(skb, sk, next_dup, + &state, + start_seq, + cache->start_seq, + dup_sack); + } + + /* Rest of the block already fully processed? */ + if (!after(end_seq, cache->end_seq)) + goto advance_sp; + + skb = tcp_maybe_skipping_dsack(skb, sk, next_dup, + &state, + cache->end_seq); + + /* ...tail remains todo... */ + if (tcp_highest_sack_seq(tp) == cache->end_seq) { + /* ...but better entrypoint exists! */ + skb = tcp_highest_sack(sk); + if (skb == NULL) + break; + state.fack_count = tp->fackets_out; + cache++; + goto walk; + } + + skb = tcp_sacktag_skip(skb, sk, &state, cache->end_seq); + /* Check overlap against next cached too (past this one already) */ + cache++; + continue; + } + + if (!before(start_seq, tcp_highest_sack_seq(tp))) { + skb = tcp_highest_sack(sk); + if (skb == NULL) + break; + state.fack_count = tp->fackets_out; + } + skb = tcp_sacktag_skip(skb, sk, &state, start_seq); + +walk: + skb = tcp_sacktag_walk(skb, sk, next_dup, &state, + start_seq, end_seq, dup_sack); + +advance_sp: + /* SACK enhanced FRTO (RFC4138, Appendix B): Clearing correct + * due to in-order walk + */ + if (after(end_seq, tp->frto_highmark)) + state.flag &= ~FLAG_ONLY_ORIG_SACKED; + + i++; + } + + /* Clear the head of the cache sack blocks so we can skip it next time */ + for (i = 0; i < ARRAY_SIZE(tp->recv_sack_cache) - used_sacks; i++) { + tp->recv_sack_cache[i].start_seq = 0; + tp->recv_sack_cache[i].end_seq = 0; + } + for (j = 0; j < used_sacks; j++) + tp->recv_sack_cache[i++] = sp[j]; + + tcp_mark_lost_retrans(sk); + + tcp_verify_left_out(tp); + + if ((state.reord < tp->fackets_out) && + ((icsk->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker) && + (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark))) + tcp_update_reordering(sk, tp->fackets_out - state.reord, 0); + +out: + +#if FASTRETRANS_DEBUG > 0 + WARN_ON((int)tp->sacked_out < 0); + WARN_ON((int)tp->lost_out < 0); + WARN_ON((int)tp->retrans_out < 0); + WARN_ON((int)tcp_packets_in_flight(tp) < 0); +#endif + return state.flag; +} +",0,"tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb, + u32 prior_snd_una) +{ + const struct inet_connection_sock *icsk = inet_csk(sk); + struct tcp_sock *tp = tcp_sk(sk); + const unsigned char *ptr = (skb_transport_header(ack_skb) + + TCP_SKB_CB(ack_skb)->sacked); + struct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2); + struct tcp_sack_block sp[TCP_NUM_SACKS]; + struct tcp_sack_block *cache; + struct tcp_sacktag_state state; + struct sk_buff *skb; + int num_sacks = min(TCP_NUM_SACKS, (ptr[1] - TCPOLEN_SACK_BASE) >> 3); + int used_sacks; + int found_dup_sack = 0; + int i, j; + int first_sack_index; + + state.flag = 0; + state.reord = tp->packets_out; + + if (!tp->sacked_out) { + if (WARN_ON(tp->fackets_out)) + tp->fackets_out = 0; + tcp_highest_sack_reset(sk); + } + + found_dup_sack = tcp_check_dsack(sk, ack_skb, sp_wire, + num_sacks, prior_snd_una); + if (found_dup_sack) + state.flag |= FLAG_DSACKING_ACK; + + /* Eliminate too old ACKs, but take into + * account more or less fresh ones, they can + * contain valid SACK info. + */ + if (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window)) + return 0; + + if (!tp->packets_out) + goto out; + + used_sacks = 0; + first_sack_index = 0; + for (i = 0; i < num_sacks; i++) { + int dup_sack = !i && found_dup_sack; + + sp[used_sacks].start_seq = get_unaligned_be32(&sp_wire[i].start_seq); + sp[used_sacks].end_seq = get_unaligned_be32(&sp_wire[i].end_seq); + + if (!tcp_is_sackblock_valid(tp, dup_sack, + sp[used_sacks].start_seq, + sp[used_sacks].end_seq)) { + int mib_idx; + + if (dup_sack) { + if (!tp->undo_marker) + mib_idx = LINUX_MIB_TCPDSACKIGNOREDNOUNDO; + else + mib_idx = LINUX_MIB_TCPDSACKIGNOREDOLD; + } else { + /* Don't count olds caused by ACK reordering */ + if ((TCP_SKB_CB(ack_skb)->ack_seq != tp->snd_una) && + !after(sp[used_sacks].end_seq, tp->snd_una)) + continue; + mib_idx = LINUX_MIB_TCPSACKDISCARD; + } + + NET_INC_STATS_BH(sock_net(sk), mib_idx); + if (i == 0) + first_sack_index = -1; + continue; + } + + /* Ignore very old stuff early */ + if (!after(sp[used_sacks].end_seq, prior_snd_una)) + continue; + + used_sacks++; + } + + /* order SACK blocks to allow in order walk of the retrans queue */ + for (i = used_sacks - 1; i > 0; i--) { + for (j = 0; j < i; j++) { + if (after(sp[j].start_seq, sp[j + 1].start_seq)) { + swap(sp[j], sp[j + 1]); + + /* Track where the first SACK block goes to */ + if (j == first_sack_index) + first_sack_index = j + 1; + } + } + } + + skb = tcp_write_queue_head(sk); + state.fack_count = 0; + i = 0; + + if (!tp->sacked_out) { + /* It's already past, so skip checking against it */ + cache = tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache); + } else { + cache = tp->recv_sack_cache; + /* Skip empty blocks in at head of the cache */ + while (tcp_sack_cache_ok(tp, cache) && !cache->start_seq && + !cache->end_seq) + cache++; + } + + while (i < used_sacks) { + u32 start_seq = sp[i].start_seq; + u32 end_seq = sp[i].end_seq; + int dup_sack = (found_dup_sack && (i == first_sack_index)); + struct tcp_sack_block *next_dup = NULL; + + if (found_dup_sack && ((i + 1) == first_sack_index)) + next_dup = &sp[i + 1]; + + /* Event ""B"" in the comment above. */ + if (after(end_seq, tp->high_seq)) + state.flag |= FLAG_DATA_LOST; + + /* Skip too early cached blocks */ + while (tcp_sack_cache_ok(tp, cache) && + !before(start_seq, cache->end_seq)) + cache++; + + /* Can skip some work by looking recv_sack_cache? */ + if (tcp_sack_cache_ok(tp, cache) && !dup_sack && + after(end_seq, cache->start_seq)) { + + /* Head todo? */ + if (before(start_seq, cache->start_seq)) { + skb = tcp_sacktag_skip(skb, sk, &state, + start_seq); + skb = tcp_sacktag_walk(skb, sk, next_dup, + &state, + start_seq, + cache->start_seq, + dup_sack); + } + + /* Rest of the block already fully processed? */ + if (!after(end_seq, cache->end_seq)) + goto advance_sp; + + skb = tcp_maybe_skipping_dsack(skb, sk, next_dup, + &state, + cache->end_seq); + + /* ...tail remains todo... */ + if (tcp_highest_sack_seq(tp) == cache->end_seq) { + /* ...but better entrypoint exists! */ + skb = tcp_highest_sack(sk); + if (skb == NULL) + break; + state.fack_count = tp->fackets_out; + cache++; + goto walk; + } + + skb = tcp_sacktag_skip(skb, sk, &state, cache->end_seq); + /* Check overlap against next cached too (past this one already) */ + cache++; + continue; + } + + if (!before(start_seq, tcp_highest_sack_seq(tp))) { + skb = tcp_highest_sack(sk); + if (skb == NULL) + break; + state.fack_count = tp->fackets_out; + } + skb = tcp_sacktag_skip(skb, sk, &state, start_seq); + +walk: + skb = tcp_sacktag_walk(skb, sk, next_dup, &state, + start_seq, end_seq, dup_sack); + +advance_sp: + /* SACK enhanced FRTO (RFC4138, Appendix B): Clearing correct + * due to in-order walk + */ + if (after(end_seq, tp->frto_highmark)) + state.flag &= ~FLAG_ONLY_ORIG_SACKED; + + i++; + } + + /* Clear the head of the cache sack blocks so we can skip it next time */ + for (i = 0; i < ARRAY_SIZE(tp->recv_sack_cache) - used_sacks; i++) { + tp->recv_sack_cache[i].start_seq = 0; + tp->recv_sack_cache[i].end_seq = 0; + } + for (j = 0; j < used_sacks; j++) + tp->recv_sack_cache[i++] = sp[j]; + + tcp_mark_lost_retrans(sk); + + tcp_verify_left_out(tp); + + if ((state.reord < tp->fackets_out) && + ((icsk->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker) && + (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark))) + tcp_update_reordering(sk, tp->fackets_out - state.reord, 0); + +out: + +#if FASTRETRANS_DEBUG > 0 + WARN_ON((int)tp->sacked_out < 0); + WARN_ON((int)tp->lost_out < 0); + WARN_ON((int)tp->retrans_out < 0); + WARN_ON((int)tcp_packets_in_flight(tp) < 0); +#endif + return state.flag; +} +","@@ -5811,6 +5811,8 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, + goto discard; + + if (th->syn) { ++ if (th->fin) ++ goto discard; + if (icsk->icsk_af_ops->conn_request(sk, skb) < 0) + return 1; + ",1883,2119,4096 +18103,"vtp_print (netdissect_options *ndo, + const u_char *pptr, u_int length) +{ + int type, len, tlv_len, tlv_value, mgmtd_len; + const u_char *tptr; + const struct vtp_vlan_ *vtp_vlan; + + if (length < VTP_HEADER_LEN) + goto trunc; + + tptr = pptr; + + ND_TCHECK2(*tptr, VTP_HEADER_LEN); + + type = *(tptr+1); + ND_PRINT((ndo, ""VTPv%u, Message %s (0x%02x), length %u"", + *tptr, + tok2str(vtp_message_type_values,""Unknown message type"", type), + type, + length)); + + /* In non-verbose mode, just print version and message type */ + if (ndo->ndo_vflag < 1) { + return; + } + + /* verbose mode print all fields */ + ND_PRINT((ndo, ""\n\tDomain name: "")); + mgmtd_len = *(tptr + 3); + if (mgmtd_len < 1 || mgmtd_len > 32) { + ND_PRINT((ndo, "" [invalid MgmtD Len %d]"", mgmtd_len)); + return; + } + fn_printzp(ndo, tptr + 4, mgmtd_len, NULL); + ND_PRINT((ndo, "", %s: %u"", + tok2str(vtp_header_values, ""Unknown"", type), + *(tptr+2))); + + tptr += VTP_HEADER_LEN; + + switch (type) { + + case VTP_SUMMARY_ADV: + + /* + * SUMMARY ADVERTISEMENT + * + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Code | Followers | MgmtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name (zero-padded to 32 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Configuration revision number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Updater Identity IP address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Update Timestamp (12 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | MD5 digest (16 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + ND_TCHECK2(*tptr, 8); + ND_PRINT((ndo, ""\n\t Config Rev %x, Updater %s"", + EXTRACT_32BITS(tptr), + ipaddr_string(ndo, tptr+4))); + tptr += 8; + ND_TCHECK2(*tptr, VTP_UPDATE_TIMESTAMP_LEN); + ND_PRINT((ndo, "", Timestamp 0x%08x 0x%08x 0x%08x"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8))); + tptr += VTP_UPDATE_TIMESTAMP_LEN; + ND_TCHECK2(*tptr, VTP_MD5_DIGEST_LEN); + ND_PRINT((ndo, "", MD5 digest: %08x%08x%08x%08x"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + EXTRACT_32BITS(tptr + 12))); + tptr += VTP_MD5_DIGEST_LEN; + break; + + case VTP_SUBSET_ADV: + + /* + * SUBSET ADVERTISEMENT + * + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Code | Seq number | MgmtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name (zero-padded to 32 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Configuration revision number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN info field 1 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ................ | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN info field N | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + ND_PRINT((ndo, "", Config Rev %x"", EXTRACT_32BITS(tptr))); + + /* + * VLAN INFORMATION + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | V info len | Status | VLAN type | VLAN name len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ISL vlan id | MTU size | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 802.10 index (SAID) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN name | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + tptr += 4; + while (tptr < (pptr+length)) { + + len = *tptr; + if (len == 0) + break; + + ND_TCHECK2(*tptr, len); + + vtp_vlan = (const struct vtp_vlan_*)tptr; + ND_TCHECK(*vtp_vlan); + ND_PRINT((ndo, ""\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name "", + tok2str(vtp_vlan_status,""Unknown"",vtp_vlan->status), + tok2str(vtp_vlan_type_values,""Unknown"",vtp_vlan->type), + EXTRACT_16BITS(&vtp_vlan->vlanid), + EXTRACT_16BITS(&vtp_vlan->mtu), + EXTRACT_32BITS(&vtp_vlan->index))); + fn_printzp(ndo, tptr + VTP_VLAN_INFO_OFFSET, vtp_vlan->name_len, NULL); + + /* + * Vlan names are aligned to 32-bit boundaries. + */ + len -= VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); + tptr += VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); + + /* TLV information follows */ + + while (len > 0) { + + /* + * Cisco specs says 2 bytes for type + 2 bytes for length, take only 1 + * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm + */ + type = *tptr; + tlv_len = *(tptr+1); + + ND_PRINT((ndo, ""\n\t\t%s (0x%04x) TLV"", + tok2str(vtp_vlan_tlv_values, ""Unknown"", type), + type)); + + /* + * infinite loop check + */ + if (type == 0 || tlv_len == 0) { + return; + } + + ND_TCHECK2(*tptr, tlv_len * 2 +2); + + tlv_value = EXTRACT_16BITS(tptr+2); + + switch (type) { + case VTP_VLAN_STE_HOP_COUNT: + ND_PRINT((ndo, "", %u"", tlv_value)); + break; + + case VTP_VLAN_PRUNING: + ND_PRINT((ndo, "", %s (%u)"", + tlv_value == 1 ? ""Enabled"" : ""Disabled"", + tlv_value)); + break; + + case VTP_VLAN_STP_TYPE: + ND_PRINT((ndo, "", %s (%u)"", + tok2str(vtp_stp_type_values, ""Unknown"", tlv_value), + tlv_value)); + break; + + case VTP_VLAN_BRIDGE_TYPE: + ND_PRINT((ndo, "", %s (%u)"", + tlv_value == 1 ? ""SRB"" : ""SRT"", + tlv_value)); + break; + + case VTP_VLAN_BACKUP_CRF_MODE: + ND_PRINT((ndo, "", %s (%u)"", + tlv_value == 1 ? ""Backup"" : ""Not backup"", + tlv_value)); + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER: + case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER: + case VTP_VLAN_PARENT_VLAN: + case VTP_VLAN_TRANS_BRIDGED_VLAN: + case VTP_VLAN_ARP_HOP_COUNT: + default: + print_unknown_data(ndo, tptr, ""\n\t\t "", 2 + tlv_len*2); + break; + } + len -= 2 + tlv_len*2; + tptr += 2 + tlv_len*2; + } + } + break; + + case VTP_ADV_REQUEST: + + /* + * ADVERTISEMENT REQUEST + * + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Code | Reserved | MgmtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name (zero-padded to 32 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Start value | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + ND_TCHECK2(*tptr, 4); + ND_PRINT((ndo, ""\n\tStart value: %u"", EXTRACT_32BITS(tptr))); + break; + + case VTP_JOIN_MESSAGE: + + /* FIXME - Could not find message format */ + break; + + default: + break; + } + + return; + + trunc: + ND_PRINT((ndo, ""[|vtp]"")); +} +",1,"vtp_print (netdissect_options *ndo, + const u_char *pptr, u_int length) +{ + int type, len, tlv_len, tlv_value, mgmtd_len; + const u_char *tptr; + const struct vtp_vlan_ *vtp_vlan; + + if (length < VTP_HEADER_LEN) + goto trunc; + + tptr = pptr; + + ND_TCHECK2(*tptr, VTP_HEADER_LEN); + + type = *(tptr+1); + ND_PRINT((ndo, ""VTPv%u, Message %s (0x%02x), length %u"", + *tptr, + tok2str(vtp_message_type_values,""Unknown message type"", type), + type, + length)); + + /* In non-verbose mode, just print version and message type */ + if (ndo->ndo_vflag < 1) { + return; + } + + /* verbose mode print all fields */ + ND_PRINT((ndo, ""\n\tDomain name: "")); + mgmtd_len = *(tptr + 3); + if (mgmtd_len < 1 || mgmtd_len > 32) { + ND_PRINT((ndo, "" [invalid MgmtD Len %d]"", mgmtd_len)); + return; + } + fn_printzp(ndo, tptr + 4, mgmtd_len, NULL); + ND_PRINT((ndo, "", %s: %u"", + tok2str(vtp_header_values, ""Unknown"", type), + *(tptr+2))); + + tptr += VTP_HEADER_LEN; + + switch (type) { + + case VTP_SUMMARY_ADV: + + /* + * SUMMARY ADVERTISEMENT + * + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Code | Followers | MgmtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name (zero-padded to 32 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Configuration revision number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Updater Identity IP address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Update Timestamp (12 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | MD5 digest (16 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + ND_TCHECK2(*tptr, 8); + ND_PRINT((ndo, ""\n\t Config Rev %x, Updater %s"", + EXTRACT_32BITS(tptr), + ipaddr_string(ndo, tptr+4))); + tptr += 8; + ND_TCHECK2(*tptr, VTP_UPDATE_TIMESTAMP_LEN); + ND_PRINT((ndo, "", Timestamp 0x%08x 0x%08x 0x%08x"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8))); + tptr += VTP_UPDATE_TIMESTAMP_LEN; + ND_TCHECK2(*tptr, VTP_MD5_DIGEST_LEN); + ND_PRINT((ndo, "", MD5 digest: %08x%08x%08x%08x"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + EXTRACT_32BITS(tptr + 12))); + tptr += VTP_MD5_DIGEST_LEN; + break; + + case VTP_SUBSET_ADV: + + /* + * SUBSET ADVERTISEMENT + * + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Code | Seq number | MgmtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name (zero-padded to 32 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Configuration revision number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN info field 1 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ................ | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN info field N | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + ND_TCHECK_32BITS(tptr); + ND_PRINT((ndo, "", Config Rev %x"", EXTRACT_32BITS(tptr))); + + /* + * VLAN INFORMATION + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | V info len | Status | VLAN type | VLAN name len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ISL vlan id | MTU size | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 802.10 index (SAID) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN name | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + tptr += 4; + while (tptr < (pptr+length)) { + + ND_TCHECK_8BITS(tptr); + len = *tptr; + if (len == 0) + break; + + ND_TCHECK2(*tptr, len); + + vtp_vlan = (const struct vtp_vlan_*)tptr; + ND_TCHECK(*vtp_vlan); + ND_PRINT((ndo, ""\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name "", + tok2str(vtp_vlan_status,""Unknown"",vtp_vlan->status), + tok2str(vtp_vlan_type_values,""Unknown"",vtp_vlan->type), + EXTRACT_16BITS(&vtp_vlan->vlanid), + EXTRACT_16BITS(&vtp_vlan->mtu), + EXTRACT_32BITS(&vtp_vlan->index))); + fn_printzp(ndo, tptr + VTP_VLAN_INFO_OFFSET, vtp_vlan->name_len, NULL); + + /* + * Vlan names are aligned to 32-bit boundaries. + */ + len -= VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); + tptr += VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); + + /* TLV information follows */ + + while (len > 0) { + + /* + * Cisco specs says 2 bytes for type + 2 bytes for length, take only 1 + * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm + */ + type = *tptr; + tlv_len = *(tptr+1); + + ND_PRINT((ndo, ""\n\t\t%s (0x%04x) TLV"", + tok2str(vtp_vlan_tlv_values, ""Unknown"", type), + type)); + + /* + * infinite loop check + */ + if (type == 0 || tlv_len == 0) { + return; + } + + ND_TCHECK2(*tptr, tlv_len * 2 +2); + + tlv_value = EXTRACT_16BITS(tptr+2); + + switch (type) { + case VTP_VLAN_STE_HOP_COUNT: + ND_PRINT((ndo, "", %u"", tlv_value)); + break; + + case VTP_VLAN_PRUNING: + ND_PRINT((ndo, "", %s (%u)"", + tlv_value == 1 ? ""Enabled"" : ""Disabled"", + tlv_value)); + break; + + case VTP_VLAN_STP_TYPE: + ND_PRINT((ndo, "", %s (%u)"", + tok2str(vtp_stp_type_values, ""Unknown"", tlv_value), + tlv_value)); + break; + + case VTP_VLAN_BRIDGE_TYPE: + ND_PRINT((ndo, "", %s (%u)"", + tlv_value == 1 ? ""SRB"" : ""SRT"", + tlv_value)); + break; + + case VTP_VLAN_BACKUP_CRF_MODE: + ND_PRINT((ndo, "", %s (%u)"", + tlv_value == 1 ? ""Backup"" : ""Not backup"", + tlv_value)); + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER: + case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER: + case VTP_VLAN_PARENT_VLAN: + case VTP_VLAN_TRANS_BRIDGED_VLAN: + case VTP_VLAN_ARP_HOP_COUNT: + default: + print_unknown_data(ndo, tptr, ""\n\t\t "", 2 + tlv_len*2); + break; + } + len -= 2 + tlv_len*2; + tptr += 2 + tlv_len*2; + } + } + break; + + case VTP_ADV_REQUEST: + + /* + * ADVERTISEMENT REQUEST + * + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Code | Reserved | MgmtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name (zero-padded to 32 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Start value | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + ND_TCHECK2(*tptr, 4); + ND_PRINT((ndo, ""\n\tStart value: %u"", EXTRACT_32BITS(tptr))); + break; + + case VTP_JOIN_MESSAGE: + + /* FIXME - Could not find message format */ + break; + + default: + break; + } + + return; + + trunc: + ND_PRINT((ndo, ""[|vtp]"")); +} +","@@ -223,6 +223,7 @@ vtp_print (netdissect_options *ndo, + * + */ + ++ ND_TCHECK_32BITS(tptr); + ND_PRINT((ndo, "", Config Rev %x"", EXTRACT_32BITS(tptr))); + + /* +@@ -243,6 +244,7 @@ vtp_print (netdissect_options *ndo, + tptr += 4; + while (tptr < (pptr+length)) { + ++ ND_TCHECK_8BITS(tptr); + len = *tptr; + if (len == 0) + break;",2460,2696,4096 +18108,"icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2, + int fragmented) +{ + char *cp; + const struct icmp *dp; + const struct icmp_ext_t *ext_dp; + const struct ip *ip; + const char *str, *fmt; + const struct ip *oip; + const struct udphdr *ouh; + const uint8_t *obj_tptr; + uint32_t raw_label; + const u_char *snapend_save; + const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header; + u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype; + char buf[MAXHOSTNAMELEN + 100]; + struct cksum_vec vec[1]; + + dp = (const struct icmp *)bp; + ext_dp = (const struct icmp_ext_t *)bp; + ip = (const struct ip *)bp2; + str = buf; + + ND_TCHECK(dp->icmp_code); + switch (dp->icmp_type) { + + case ICMP_ECHO: + case ICMP_ECHOREPLY: + ND_TCHECK(dp->icmp_seq); + (void)snprintf(buf, sizeof(buf), ""echo %s, id %u, seq %u"", + dp->icmp_type == ICMP_ECHO ? + ""request"" : ""reply"", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq)); + break; + + case ICMP_UNREACH: + ND_TCHECK(dp->icmp_ip.ip_dst); + switch (dp->icmp_code) { + + case ICMP_UNREACH_PROTOCOL: + ND_TCHECK(dp->icmp_ip.ip_p); + (void)snprintf(buf, sizeof(buf), + ""%s protocol %d unreachable"", + ipaddr_string(ndo, &dp->icmp_ip.ip_dst), + dp->icmp_ip.ip_p); + break; + + case ICMP_UNREACH_PORT: + ND_TCHECK(dp->icmp_ip.ip_p); + oip = &dp->icmp_ip; + hlen = IP_HL(oip) * 4; + ouh = (const struct udphdr *)(((const u_char *)oip) + hlen); + ND_TCHECK(ouh->uh_dport); + dport = EXTRACT_16BITS(&ouh->uh_dport); + switch (oip->ip_p) { + + case IPPROTO_TCP: + (void)snprintf(buf, sizeof(buf), + ""%s tcp port %s unreachable"", + ipaddr_string(ndo, &oip->ip_dst), + tcpport_string(ndo, dport)); + break; + + case IPPROTO_UDP: + (void)snprintf(buf, sizeof(buf), + ""%s udp port %s unreachable"", + ipaddr_string(ndo, &oip->ip_dst), + udpport_string(ndo, dport)); + break; + + default: + (void)snprintf(buf, sizeof(buf), + ""%s protocol %d port %d unreachable"", + ipaddr_string(ndo, &oip->ip_dst), + oip->ip_p, dport); + break; + } + break; + + case ICMP_UNREACH_NEEDFRAG: + { + register const struct mtu_discovery *mp; + mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void; + mtu = EXTRACT_16BITS(&mp->nexthopmtu); + if (mtu) { + (void)snprintf(buf, sizeof(buf), + ""%s unreachable - need to frag (mtu %d)"", + ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu); + } else { + (void)snprintf(buf, sizeof(buf), + ""%s unreachable - need to frag"", + ipaddr_string(ndo, &dp->icmp_ip.ip_dst)); + } + } + break; + + default: + fmt = tok2str(unreach2str, ""#%d %%s unreachable"", + dp->icmp_code); + (void)snprintf(buf, sizeof(buf), fmt, + ipaddr_string(ndo, &dp->icmp_ip.ip_dst)); + break; + } + break; + + case ICMP_REDIRECT: + ND_TCHECK(dp->icmp_ip.ip_dst); + fmt = tok2str(type2str, ""redirect-#%d %%s to net %%s"", + dp->icmp_code); + (void)snprintf(buf, sizeof(buf), fmt, + ipaddr_string(ndo, &dp->icmp_ip.ip_dst), + ipaddr_string(ndo, &dp->icmp_gwaddr)); + break; + + case ICMP_ROUTERADVERT: + { + register const struct ih_rdiscovery *ihp; + register const struct id_rdiscovery *idp; + u_int lifetime, num, size; + + (void)snprintf(buf, sizeof(buf), ""router advertisement""); + cp = buf + strlen(buf); + + ihp = (const struct ih_rdiscovery *)&dp->icmp_void; + ND_TCHECK(*ihp); + (void)strncpy(cp, "" lifetime "", sizeof(buf) - (cp - buf)); + cp = buf + strlen(buf); + lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); + if (lifetime < 60) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), ""%u"", + lifetime); + } else if (lifetime < 60 * 60) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), ""%u:%02u"", + lifetime / 60, lifetime % 60); + } else { + (void)snprintf(cp, sizeof(buf) - (cp - buf), + ""%u:%02u:%02u"", + lifetime / 3600, + (lifetime % 3600) / 60, + lifetime % 60); + } + cp = buf + strlen(buf); + + num = ihp->ird_addrnum; + (void)snprintf(cp, sizeof(buf) - (cp - buf), "" %d:"", num); + cp = buf + strlen(buf); + + size = ihp->ird_addrsiz; + if (size != 2) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), + "" [size %d]"", size); + break; + } + idp = (const struct id_rdiscovery *)&dp->icmp_data; + while (num-- > 0) { + ND_TCHECK(*idp); + (void)snprintf(cp, sizeof(buf) - (cp - buf), "" {%s %u}"", + ipaddr_string(ndo, &idp->ird_addr), + EXTRACT_32BITS(&idp->ird_pref)); + cp = buf + strlen(buf); + ++idp; + } + } + break; + + case ICMP_TIMXCEED: + ND_TCHECK(dp->icmp_ip.ip_dst); + switch (dp->icmp_code) { + + case ICMP_TIMXCEED_INTRANS: + str = ""time exceeded in-transit""; + break; + + case ICMP_TIMXCEED_REASS: + str = ""ip reassembly time exceeded""; + break; + + default: + (void)snprintf(buf, sizeof(buf), ""time exceeded-#%d"", + dp->icmp_code); + break; + } + break; + + case ICMP_PARAMPROB: + if (dp->icmp_code) + (void)snprintf(buf, sizeof(buf), + ""parameter problem - code %d"", dp->icmp_code); + else { + ND_TCHECK(dp->icmp_pptr); + (void)snprintf(buf, sizeof(buf), + ""parameter problem - octet %d"", dp->icmp_pptr); + } + break; + + case ICMP_MASKREPLY: + ND_TCHECK(dp->icmp_mask); + (void)snprintf(buf, sizeof(buf), ""address mask is 0x%08x"", + EXTRACT_32BITS(&dp->icmp_mask)); + break; + + case ICMP_TSTAMP: + ND_TCHECK(dp->icmp_seq); + (void)snprintf(buf, sizeof(buf), + ""time stamp query id %u seq %u"", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq)); + break; + + case ICMP_TSTAMPREPLY: + ND_TCHECK(dp->icmp_ttime); + (void)snprintf(buf, sizeof(buf), + ""time stamp reply id %u seq %u: org %s"", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq), + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_otime))); + + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"", recv %s"", + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_rtime))); + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"", xmit %s"", + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_ttime))); + break; + + default: + str = tok2str(icmp2str, ""type-#%d"", dp->icmp_type); + break; + } + ND_PRINT((ndo, ""ICMP %s, length %u"", str, plen)); + if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */ + uint16_t sum, icmp_sum; + + if (ND_TTEST2(*bp, plen)) { + vec[0].ptr = (const uint8_t *)(const void *)dp; + vec[0].len = plen; + sum = in_cksum(vec, 1); + if (sum != 0) { + icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum); + ND_PRINT((ndo, "" (wrong icmp cksum %x (->%x)!)"", + icmp_sum, + in_cksum_shouldbe(icmp_sum, sum))); + } + } + } + + /* + * print the remnants of the IP packet. + * save the snaplength as this may get overidden in the IP printer. + */ + if (ndo->ndo_vflag >= 1 && ICMP_ERRTYPE(dp->icmp_type)) { + bp += 8; + ND_PRINT((ndo, ""\n\t"")); + ip = (const struct ip *)bp; + snapend_save = ndo->ndo_snapend; + ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len)); + ndo->ndo_snapend = snapend_save; + } + + /* + * Attempt to decode the MPLS extensions only for some ICMP types. + */ + if (ndo->ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) { + + ND_TCHECK(*ext_dp); + + /* + * Check first if the mpls extension header shows a non-zero length. + * If the length field is not set then silently verify the checksum + * to check if an extension header is present. This is expedient, + * however not all implementations set the length field proper. + */ + if (!ext_dp->icmp_length) { + vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; + vec[0].len = plen - ICMP_EXTD_MINLEN; + if (in_cksum(vec, 1)) { + return; + } + } + + ND_PRINT((ndo, ""\n\tMPLS extension v%u"", + ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)))); + + /* + * Sanity checking of the header. + */ + if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) != + ICMP_MPLS_EXT_VERSION) { + ND_PRINT((ndo, "" packet not supported"")); + return; + } + + hlen = plen - ICMP_EXTD_MINLEN; + vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; + vec[0].len = hlen; + ND_PRINT((ndo, "", checksum 0x%04x (%scorrect), length %u"", + EXTRACT_16BITS(ext_dp->icmp_ext_checksum), + in_cksum(vec, 1) ? ""in"" : """", + hlen)); + + hlen -= 4; /* subtract common header size */ + obj_tptr = (const uint8_t *)ext_dp->icmp_ext_data; + + while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) { + + icmp_mpls_ext_object_header = (const struct icmp_mpls_ext_object_header_t *)obj_tptr; + ND_TCHECK(*icmp_mpls_ext_object_header); + obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length); + obj_class_num = icmp_mpls_ext_object_header->class_num; + obj_ctype = icmp_mpls_ext_object_header->ctype; + obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t); + + ND_PRINT((ndo, ""\n\t %s Object (%u), Class-Type: %u, length %u"", + tok2str(icmp_mpls_ext_obj_values,""unknown"",obj_class_num), + obj_class_num, + obj_ctype, + obj_tlen)); + + hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */ + + /* infinite loop protection */ + if ((obj_class_num == 0) || + (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) { + return; + } + obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t); + + switch (obj_class_num) { + case 1: + switch(obj_ctype) { + case 1: + ND_TCHECK2(*obj_tptr, 4); + raw_label = EXTRACT_32BITS(obj_tptr); + ND_PRINT((ndo, ""\n\t label %u, exp %u"", MPLS_LABEL(raw_label), MPLS_EXP(raw_label))); + if (MPLS_STACK(raw_label)) + ND_PRINT((ndo, "", [S]"")); + ND_PRINT((ndo, "", ttl %u"", MPLS_TTL(raw_label))); + break; + default: + print_unknown_data(ndo, obj_tptr, ""\n\t "", obj_tlen); + } + break; + + /* + * FIXME those are the defined objects that lack a decoder + * you are welcome to contribute code ;-) + */ + case 2: + default: + print_unknown_data(ndo, obj_tptr, ""\n\t "", obj_tlen); + break; + } + if (hlen < obj_tlen) + break; + hlen -= obj_tlen; + obj_tptr += obj_tlen; + } + } + + return; +trunc: + ND_PRINT((ndo, ""[|icmp]"")); +} +",1,"icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2, + int fragmented) +{ + char *cp; + const struct icmp *dp; + const struct icmp_ext_t *ext_dp; + const struct ip *ip; + const char *str, *fmt; + const struct ip *oip; + const struct udphdr *ouh; + const uint8_t *obj_tptr; + uint32_t raw_label; + const u_char *snapend_save; + const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header; + u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype; + char buf[MAXHOSTNAMELEN + 100]; + struct cksum_vec vec[1]; + + dp = (const struct icmp *)bp; + ext_dp = (const struct icmp_ext_t *)bp; + ip = (const struct ip *)bp2; + str = buf; + + ND_TCHECK(dp->icmp_code); + switch (dp->icmp_type) { + + case ICMP_ECHO: + case ICMP_ECHOREPLY: + ND_TCHECK(dp->icmp_seq); + (void)snprintf(buf, sizeof(buf), ""echo %s, id %u, seq %u"", + dp->icmp_type == ICMP_ECHO ? + ""request"" : ""reply"", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq)); + break; + + case ICMP_UNREACH: + ND_TCHECK(dp->icmp_ip.ip_dst); + switch (dp->icmp_code) { + + case ICMP_UNREACH_PROTOCOL: + ND_TCHECK(dp->icmp_ip.ip_p); + (void)snprintf(buf, sizeof(buf), + ""%s protocol %d unreachable"", + ipaddr_string(ndo, &dp->icmp_ip.ip_dst), + dp->icmp_ip.ip_p); + break; + + case ICMP_UNREACH_PORT: + ND_TCHECK(dp->icmp_ip.ip_p); + oip = &dp->icmp_ip; + hlen = IP_HL(oip) * 4; + ouh = (const struct udphdr *)(((const u_char *)oip) + hlen); + ND_TCHECK(ouh->uh_dport); + dport = EXTRACT_16BITS(&ouh->uh_dport); + switch (oip->ip_p) { + + case IPPROTO_TCP: + (void)snprintf(buf, sizeof(buf), + ""%s tcp port %s unreachable"", + ipaddr_string(ndo, &oip->ip_dst), + tcpport_string(ndo, dport)); + break; + + case IPPROTO_UDP: + (void)snprintf(buf, sizeof(buf), + ""%s udp port %s unreachable"", + ipaddr_string(ndo, &oip->ip_dst), + udpport_string(ndo, dport)); + break; + + default: + (void)snprintf(buf, sizeof(buf), + ""%s protocol %d port %d unreachable"", + ipaddr_string(ndo, &oip->ip_dst), + oip->ip_p, dport); + break; + } + break; + + case ICMP_UNREACH_NEEDFRAG: + { + register const struct mtu_discovery *mp; + mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void; + mtu = EXTRACT_16BITS(&mp->nexthopmtu); + if (mtu) { + (void)snprintf(buf, sizeof(buf), + ""%s unreachable - need to frag (mtu %d)"", + ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu); + } else { + (void)snprintf(buf, sizeof(buf), + ""%s unreachable - need to frag"", + ipaddr_string(ndo, &dp->icmp_ip.ip_dst)); + } + } + break; + + default: + fmt = tok2str(unreach2str, ""#%d %%s unreachable"", + dp->icmp_code); + (void)snprintf(buf, sizeof(buf), fmt, + ipaddr_string(ndo, &dp->icmp_ip.ip_dst)); + break; + } + break; + + case ICMP_REDIRECT: + ND_TCHECK(dp->icmp_ip.ip_dst); + fmt = tok2str(type2str, ""redirect-#%d %%s to net %%s"", + dp->icmp_code); + (void)snprintf(buf, sizeof(buf), fmt, + ipaddr_string(ndo, &dp->icmp_ip.ip_dst), + ipaddr_string(ndo, &dp->icmp_gwaddr)); + break; + + case ICMP_ROUTERADVERT: + { + register const struct ih_rdiscovery *ihp; + register const struct id_rdiscovery *idp; + u_int lifetime, num, size; + + (void)snprintf(buf, sizeof(buf), ""router advertisement""); + cp = buf + strlen(buf); + + ihp = (const struct ih_rdiscovery *)&dp->icmp_void; + ND_TCHECK(*ihp); + (void)strncpy(cp, "" lifetime "", sizeof(buf) - (cp - buf)); + cp = buf + strlen(buf); + lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); + if (lifetime < 60) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), ""%u"", + lifetime); + } else if (lifetime < 60 * 60) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), ""%u:%02u"", + lifetime / 60, lifetime % 60); + } else { + (void)snprintf(cp, sizeof(buf) - (cp - buf), + ""%u:%02u:%02u"", + lifetime / 3600, + (lifetime % 3600) / 60, + lifetime % 60); + } + cp = buf + strlen(buf); + + num = ihp->ird_addrnum; + (void)snprintf(cp, sizeof(buf) - (cp - buf), "" %d:"", num); + cp = buf + strlen(buf); + + size = ihp->ird_addrsiz; + if (size != 2) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), + "" [size %d]"", size); + break; + } + idp = (const struct id_rdiscovery *)&dp->icmp_data; + while (num-- > 0) { + ND_TCHECK(*idp); + (void)snprintf(cp, sizeof(buf) - (cp - buf), "" {%s %u}"", + ipaddr_string(ndo, &idp->ird_addr), + EXTRACT_32BITS(&idp->ird_pref)); + cp = buf + strlen(buf); + ++idp; + } + } + break; + + case ICMP_TIMXCEED: + ND_TCHECK(dp->icmp_ip.ip_dst); + switch (dp->icmp_code) { + + case ICMP_TIMXCEED_INTRANS: + str = ""time exceeded in-transit""; + break; + + case ICMP_TIMXCEED_REASS: + str = ""ip reassembly time exceeded""; + break; + + default: + (void)snprintf(buf, sizeof(buf), ""time exceeded-#%d"", + dp->icmp_code); + break; + } + break; + + case ICMP_PARAMPROB: + if (dp->icmp_code) + (void)snprintf(buf, sizeof(buf), + ""parameter problem - code %d"", dp->icmp_code); + else { + ND_TCHECK(dp->icmp_pptr); + (void)snprintf(buf, sizeof(buf), + ""parameter problem - octet %d"", dp->icmp_pptr); + } + break; + + case ICMP_MASKREPLY: + ND_TCHECK(dp->icmp_mask); + (void)snprintf(buf, sizeof(buf), ""address mask is 0x%08x"", + EXTRACT_32BITS(&dp->icmp_mask)); + break; + + case ICMP_TSTAMP: + ND_TCHECK(dp->icmp_seq); + (void)snprintf(buf, sizeof(buf), + ""time stamp query id %u seq %u"", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq)); + break; + + case ICMP_TSTAMPREPLY: + ND_TCHECK(dp->icmp_ttime); + (void)snprintf(buf, sizeof(buf), + ""time stamp reply id %u seq %u: org %s"", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq), + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_otime))); + + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"", recv %s"", + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_rtime))); + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"", xmit %s"", + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_ttime))); + break; + + default: + str = tok2str(icmp2str, ""type-#%d"", dp->icmp_type); + break; + } + ND_PRINT((ndo, ""ICMP %s, length %u"", str, plen)); + if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */ + uint16_t sum, icmp_sum; + + if (ND_TTEST2(*bp, plen)) { + vec[0].ptr = (const uint8_t *)(const void *)dp; + vec[0].len = plen; + sum = in_cksum(vec, 1); + if (sum != 0) { + icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum); + ND_PRINT((ndo, "" (wrong icmp cksum %x (->%x)!)"", + icmp_sum, + in_cksum_shouldbe(icmp_sum, sum))); + } + } + } + + /* + * print the remnants of the IP packet. + * save the snaplength as this may get overidden in the IP printer. + */ + if (ndo->ndo_vflag >= 1 && ICMP_ERRTYPE(dp->icmp_type)) { + bp += 8; + ND_PRINT((ndo, ""\n\t"")); + ip = (const struct ip *)bp; + snapend_save = ndo->ndo_snapend; + ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len)); + ndo->ndo_snapend = snapend_save; + } + + /* + * Attempt to decode the MPLS extensions only for some ICMP types. + */ + if (ndo->ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) { + + ND_TCHECK(*ext_dp); + + /* + * Check first if the mpls extension header shows a non-zero length. + * If the length field is not set then silently verify the checksum + * to check if an extension header is present. This is expedient, + * however not all implementations set the length field proper. + */ + if (!ext_dp->icmp_length && + ND_TTEST2(ext_dp->icmp_ext_version_res, plen - ICMP_EXTD_MINLEN)) { + vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; + vec[0].len = plen - ICMP_EXTD_MINLEN; + if (in_cksum(vec, 1)) { + return; + } + } + + ND_PRINT((ndo, ""\n\tMPLS extension v%u"", + ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)))); + + /* + * Sanity checking of the header. + */ + if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) != + ICMP_MPLS_EXT_VERSION) { + ND_PRINT((ndo, "" packet not supported"")); + return; + } + + hlen = plen - ICMP_EXTD_MINLEN; + if (ND_TTEST2(ext_dp->icmp_ext_version_res, hlen)) { + vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; + vec[0].len = hlen; + ND_PRINT((ndo, "", checksum 0x%04x (%scorrect), length %u"", + EXTRACT_16BITS(ext_dp->icmp_ext_checksum), + in_cksum(vec, 1) ? ""in"" : """", + hlen)); + } + + hlen -= 4; /* subtract common header size */ + obj_tptr = (const uint8_t *)ext_dp->icmp_ext_data; + + while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) { + + icmp_mpls_ext_object_header = (const struct icmp_mpls_ext_object_header_t *)obj_tptr; + ND_TCHECK(*icmp_mpls_ext_object_header); + obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length); + obj_class_num = icmp_mpls_ext_object_header->class_num; + obj_ctype = icmp_mpls_ext_object_header->ctype; + obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t); + + ND_PRINT((ndo, ""\n\t %s Object (%u), Class-Type: %u, length %u"", + tok2str(icmp_mpls_ext_obj_values,""unknown"",obj_class_num), + obj_class_num, + obj_ctype, + obj_tlen)); + + hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */ + + /* infinite loop protection */ + if ((obj_class_num == 0) || + (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) { + return; + } + obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t); + + switch (obj_class_num) { + case 1: + switch(obj_ctype) { + case 1: + ND_TCHECK2(*obj_tptr, 4); + raw_label = EXTRACT_32BITS(obj_tptr); + ND_PRINT((ndo, ""\n\t label %u, exp %u"", MPLS_LABEL(raw_label), MPLS_EXP(raw_label))); + if (MPLS_STACK(raw_label)) + ND_PRINT((ndo, "", [S]"")); + ND_PRINT((ndo, "", ttl %u"", MPLS_TTL(raw_label))); + break; + default: + print_unknown_data(ndo, obj_tptr, ""\n\t "", obj_tlen); + } + break; + + /* + * FIXME those are the defined objects that lack a decoder + * you are welcome to contribute code ;-) + */ + case 2: + default: + print_unknown_data(ndo, obj_tptr, ""\n\t "", obj_tlen); + break; + } + if (hlen < obj_tlen) + break; + hlen -= obj_tlen; + obj_tptr += obj_tlen; + } + } + + return; +trunc: + ND_PRINT((ndo, ""[|icmp]"")); +} +","@@ -598,7 +598,8 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * + * to check if an extension header is present. This is expedient, + * however not all implementations set the length field proper. + */ +- if (!ext_dp->icmp_length) { ++ if (!ext_dp->icmp_length && ++ ND_TTEST2(ext_dp->icmp_ext_version_res, plen - ICMP_EXTD_MINLEN)) { + vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; + vec[0].len = plen - ICMP_EXTD_MINLEN; + if (in_cksum(vec, 1)) { +@@ -619,12 +620,14 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * + } + + hlen = plen - ICMP_EXTD_MINLEN; +- vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; +- vec[0].len = hlen; +- ND_PRINT((ndo, "", checksum 0x%04x (%scorrect), length %u"", +- EXTRACT_16BITS(ext_dp->icmp_ext_checksum), +- in_cksum(vec, 1) ? ""in"" : """", +- hlen)); ++ if (ND_TTEST2(ext_dp->icmp_ext_version_res, hlen)) { ++ vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; ++ vec[0].len = hlen; ++ ND_PRINT((ndo, "", checksum 0x%04x (%scorrect), length %u"", ++ EXTRACT_16BITS(ext_dp->icmp_ext_checksum), ++ in_cksum(vec, 1) ? ""in"" : """", ++ hlen)); ++ } + + hlen -= 4; /* subtract common header size */ + obj_tptr = (const uint8_t *)ext_dp->icmp_ext_data;",3265,3501,4096 +18154,"ModuleExport MagickBooleanType ReadPSDLayers(Image *image, + const ImageInfo *image_info,const PSDInfo *psd_info, + const MagickBooleanType skip_layers,ExceptionInfo *exception) +{ + char + type[4]; + + LayerInfo + *layer_info; + + MagickSizeType + size; + + MagickBooleanType + status; + + register ssize_t + i; + + ssize_t + count, + j, + number_layers; + + size=GetPSDSize(psd_info,image); + if (size == 0) + { + /* + Skip layers & masks. + */ + (void) ReadBlobLong(image); + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + status=MagickFalse; + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + return(MagickTrue); + else + { + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count != 0) && (LocaleNCompare(type,""Lr16"",4) == 0)) + size=GetPSDSize(psd_info,image); + else + return(MagickTrue); + } + } + status=MagickTrue; + if (size != 0) + { + layer_info=(LayerInfo *) NULL; + number_layers=(short) ReadBlobShort(image); + + if (number_layers < 0) + { + /* + The first alpha channel in the merged result contains the + transparency data for the merged result. + */ + number_layers=MagickAbsoluteValue(number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" negative layer count corrected for""); + image->alpha_trait=BlendPixelTrait; + } + + /* + We only need to know if the image has an alpha channel + */ + if (skip_layers != MagickFalse) + return(MagickTrue); + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" image contains %.20g layers"",(double) number_layers); + + if (number_layers == 0) + ThrowBinaryException(CorruptImageError,""InvalidNumberOfLayers"", + image->filename); + + layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers, + sizeof(*layer_info)); + if (layer_info == (LayerInfo *) NULL) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of LayerInfo failed""); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + (void) ResetMagickMemory(layer_info,0,(size_t) number_layers* + sizeof(*layer_info)); + + for (i=0; i < number_layers; i++) + { + ssize_t + x, + y; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading layer #%.20g"",(double) i+1); + layer_info[i].page.y=ReadBlobSignedLong(image); + layer_info[i].page.x=ReadBlobSignedLong(image); + y=ReadBlobSignedLong(image); + x=ReadBlobSignedLong(image); + layer_info[i].page.width=(size_t) (x-layer_info[i].page.x); + layer_info[i].page.height=(size_t) (y-layer_info[i].page.y); + layer_info[i].channels=ReadBlobShort(image); + if (layer_info[i].channels > MaxPSDChannels) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""MaximumChannelsExceeded"", + image->filename); + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g"", + (double) layer_info[i].page.x,(double) layer_info[i].page.y, + (double) layer_info[i].page.height,(double) + layer_info[i].page.width,(double) layer_info[i].channels); + for (j=0; j < (ssize_t) layer_info[i].channels; j++) + { + layer_info[i].channel_info[j].type=(short) ReadBlobShort(image); + layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info, + image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" channel[%.20g]: type=%.20g, size=%.20g"",(double) j, + (double) layer_info[i].channel_info[j].type, + (double) layer_info[i].channel_info[j].size); + } + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer type was %.4s instead of 8BIM"", type); + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""ImproperImageHeader"", + image->filename); + } + count=ReadBlob(image,4,(unsigned char *) layer_info[i].blendkey); + ReversePSDString(image,layer_info[i].blendkey,4); + layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + layer_info[i].clipping=(unsigned char) ReadBlobByte(image); + layer_info[i].flags=(unsigned char) ReadBlobByte(image); + layer_info[i].visible=!(layer_info[i].flags & 0x02); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s"", + layer_info[i].blendkey,(double) layer_info[i].opacity, + layer_info[i].clipping ? ""true"" : ""false"",layer_info[i].flags, + layer_info[i].visible ? ""true"" : ""false""); + (void) ReadBlobByte(image); /* filler */ + + size=ReadBlobLong(image); + if (size != 0) + { + MagickSizeType + combined_length, + length; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer contains additional info""); + length=ReadBlobLong(image); + combined_length=length+4; + if (length != 0) + { + /* + Layer mask info. + */ + layer_info[i].mask.page.y=ReadBlobSignedLong(image); + layer_info[i].mask.page.x=ReadBlobSignedLong(image); + layer_info[i].mask.page.height=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.y); + layer_info[i].mask.page.width=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.x); + layer_info[i].mask.background=(unsigned char) ReadBlobByte( + image); + layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image); + if (!(layer_info[i].mask.flags & 0x01)) + { + layer_info[i].mask.page.y=layer_info[i].mask.page.y- + layer_info[i].page.y; + layer_info[i].mask.page.x=layer_info[i].mask.page.x- + layer_info[i].page.x; + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g"", + (double) layer_info[i].mask.page.x,(double) + layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width, + (double) layer_info[i].mask.page.height,(double) + ((MagickOffsetType) length)-18); + /* + Skip over the rest of the layer mask information. + */ + if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + } + } + length=ReadBlobLong(image); + combined_length+=length+4; + if (length != 0) + { + /* + Layer blending ranges info. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer blending ranges: length=%.20g"",(double) + ((MagickOffsetType) length)); + /* + We read it, but don't use it... + */ + for (j=0; j < (ssize_t) length; j+=8) + { + size_t blend_source=ReadBlobLong(image); + size_t blend_dest=ReadBlobLong(image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" source(%x), dest(%x)"",(unsigned int) + blend_source,(unsigned int) blend_dest); + } + } + /* + Layer name. + */ + length=(MagickSizeType) ReadBlobByte(image); + combined_length+=length+1; + if (length > 0) + (void) ReadBlob(image,(size_t) length++,layer_info[i].name); + layer_info[i].name[length]='\0'; + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer name: %s"",layer_info[i].name); + if ((length % 4) != 0) + { + length=4-(length % 4); + combined_length+=length; + /* Skip over the padding of the layer name */ + if (DiscardBlobBytes(image,length) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + length=(MagickSizeType) size-combined_length; + if (length > 0) + { + unsigned char + *info; + + layer_info[i].info=AcquireStringInfo((const size_t) length); + info=GetStringInfoDatum(layer_info[i].info); + (void) ReadBlob(image,(const size_t) length,info); + } + } + } + + for (i=0; i < number_layers; i++) + { + if ((layer_info[i].page.width == 0) || + (layer_info[i].page.height == 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer data is empty""); + if (layer_info[i].info != (StringInfo *) NULL) + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + continue; + } + + /* + Allocate layered image. + */ + layer_info[i].image=CloneImage(image,layer_info[i].page.width, + layer_info[i].page.height,MagickFalse,exception); + if (layer_info[i].image == (Image *) NULL) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of image for layer %.20g failed"",(double) i); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + + if (layer_info[i].info != (StringInfo *) NULL) + { + (void) SetImageProfile(layer_info[i].image,""psd:additional-info"", + layer_info[i].info,exception); + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + } + } + + if (image_info->ping == MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=0; j < layer_info[i].channels; j++) + { + if (DiscardBlobBytes(image,(MagickSizeType) + layer_info[i].channel_info[j].size) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + continue; + } + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading data for layer %.20g"",(double) i); + + status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i], + exception); + if (status == MagickFalse) + break; + + status=SetImageProgress(image,LoadImagesTag,i,(MagickSizeType) + number_layers); + if (status == MagickFalse) + break; + } + } + + if (status != MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=i; j < number_layers - 1; j++) + layer_info[j] = layer_info[j+1]; + number_layers--; + i--; + } + } + + if (number_layers > 0) + { + for (i=0; i < number_layers; i++) + { + if (i > 0) + layer_info[i].image->previous=layer_info[i-1].image; + if (i < (number_layers-1)) + layer_info[i].image->next=layer_info[i+1].image; + layer_info[i].image->page=layer_info[i].page; + } + image->next=layer_info[0].image; + layer_info[0].image->previous=image; + } + layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info); + } + else + layer_info=DestroyLayerInfo(layer_info,number_layers); + } + + return(status); +} +",1,"ModuleExport MagickBooleanType ReadPSDLayers(Image *image, + const ImageInfo *image_info,const PSDInfo *psd_info, + const MagickBooleanType skip_layers,ExceptionInfo *exception) +{ + char + type[4]; + + LayerInfo + *layer_info; + + MagickSizeType + size; + + MagickBooleanType + status; + + register ssize_t + i; + + ssize_t + count, + j, + number_layers; + + size=GetPSDSize(psd_info,image); + if (size == 0) + { + /* + Skip layers & masks. + */ + (void) ReadBlobLong(image); + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + status=MagickFalse; + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + return(MagickTrue); + else + { + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count != 0) && (LocaleNCompare(type,""Lr16"",4) == 0)) + size=GetPSDSize(psd_info,image); + else + return(MagickTrue); + } + } + status=MagickTrue; + if (size != 0) + { + layer_info=(LayerInfo *) NULL; + number_layers=(short) ReadBlobShort(image); + + if (number_layers < 0) + { + /* + The first alpha channel in the merged result contains the + transparency data for the merged result. + */ + number_layers=MagickAbsoluteValue(number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" negative layer count corrected for""); + image->alpha_trait=BlendPixelTrait; + } + + /* + We only need to know if the image has an alpha channel + */ + if (skip_layers != MagickFalse) + return(MagickTrue); + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" image contains %.20g layers"",(double) number_layers); + + if (number_layers == 0) + ThrowBinaryException(CorruptImageError,""InvalidNumberOfLayers"", + image->filename); + + layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers, + sizeof(*layer_info)); + if (layer_info == (LayerInfo *) NULL) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of LayerInfo failed""); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + (void) ResetMagickMemory(layer_info,0,(size_t) number_layers* + sizeof(*layer_info)); + + for (i=0; i < number_layers; i++) + { + ssize_t + x, + y; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading layer #%.20g"",(double) i+1); + layer_info[i].page.y=ReadBlobSignedLong(image); + layer_info[i].page.x=ReadBlobSignedLong(image); + y=ReadBlobSignedLong(image); + x=ReadBlobSignedLong(image); + layer_info[i].page.width=(size_t) (x-layer_info[i].page.x); + layer_info[i].page.height=(size_t) (y-layer_info[i].page.y); + layer_info[i].channels=ReadBlobShort(image); + if (layer_info[i].channels > MaxPSDChannels) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""MaximumChannelsExceeded"", + image->filename); + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g"", + (double) layer_info[i].page.x,(double) layer_info[i].page.y, + (double) layer_info[i].page.height,(double) + layer_info[i].page.width,(double) layer_info[i].channels); + for (j=0; j < (ssize_t) layer_info[i].channels; j++) + { + layer_info[i].channel_info[j].type=(short) ReadBlobShort(image); + layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info, + image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" channel[%.20g]: type=%.20g, size=%.20g"",(double) j, + (double) layer_info[i].channel_info[j].type, + (double) layer_info[i].channel_info[j].size); + } + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer type was %.4s instead of 8BIM"", type); + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""ImproperImageHeader"", + image->filename); + } + count=ReadBlob(image,4,(unsigned char *) layer_info[i].blendkey); + ReversePSDString(image,layer_info[i].blendkey,4); + layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + layer_info[i].clipping=(unsigned char) ReadBlobByte(image); + layer_info[i].flags=(unsigned char) ReadBlobByte(image); + layer_info[i].visible=!(layer_info[i].flags & 0x02); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s"", + layer_info[i].blendkey,(double) layer_info[i].opacity, + layer_info[i].clipping ? ""true"" : ""false"",layer_info[i].flags, + layer_info[i].visible ? ""true"" : ""false""); + (void) ReadBlobByte(image); /* filler */ + + size=ReadBlobLong(image); + if (size != 0) + { + MagickSizeType + combined_length, + length; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer contains additional info""); + length=ReadBlobLong(image); + combined_length=length+4; + if (length != 0) + { + /* + Layer mask info. + */ + layer_info[i].mask.page.y=ReadBlobSignedLong(image); + layer_info[i].mask.page.x=ReadBlobSignedLong(image); + layer_info[i].mask.page.height=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.y); + layer_info[i].mask.page.width=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.x); + layer_info[i].mask.background=(unsigned char) ReadBlobByte( + image); + layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image); + if (!(layer_info[i].mask.flags & 0x01)) + { + layer_info[i].mask.page.y=layer_info[i].mask.page.y- + layer_info[i].page.y; + layer_info[i].mask.page.x=layer_info[i].mask.page.x- + layer_info[i].page.x; + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g"", + (double) layer_info[i].mask.page.x,(double) + layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width, + (double) layer_info[i].mask.page.height,(double) + ((MagickOffsetType) length)-18); + /* + Skip over the rest of the layer mask information. + */ + if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + } + } + length=ReadBlobLong(image); + combined_length+=length+4; + if (length != 0) + { + /* + Layer blending ranges info. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer blending ranges: length=%.20g"",(double) + ((MagickOffsetType) length)); + /* + We read it, but don't use it... + */ + for (j=0; j < (ssize_t) length; j+=8) + { + size_t blend_source=ReadBlobLong(image); + size_t blend_dest=ReadBlobLong(image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" source(%x), dest(%x)"",(unsigned int) + blend_source,(unsigned int) blend_dest); + } + } + /* + Layer name. + */ + length=(MagickSizeType) (unsigned char) ReadBlobByte(image); + combined_length+=length+1; + if (length > 0) + (void) ReadBlob(image,(size_t) length++,layer_info[i].name); + layer_info[i].name[length]='\0'; + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer name: %s"",layer_info[i].name); + if ((length % 4) != 0) + { + length=4-(length % 4); + combined_length+=length; + /* Skip over the padding of the layer name */ + if (DiscardBlobBytes(image,length) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + length=(MagickSizeType) size-combined_length; + if (length > 0) + { + unsigned char + *info; + + layer_info[i].info=AcquireStringInfo((const size_t) length); + info=GetStringInfoDatum(layer_info[i].info); + (void) ReadBlob(image,(const size_t) length,info); + } + } + } + + for (i=0; i < number_layers; i++) + { + if ((layer_info[i].page.width == 0) || + (layer_info[i].page.height == 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer data is empty""); + if (layer_info[i].info != (StringInfo *) NULL) + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + continue; + } + + /* + Allocate layered image. + */ + layer_info[i].image=CloneImage(image,layer_info[i].page.width, + layer_info[i].page.height,MagickFalse,exception); + if (layer_info[i].image == (Image *) NULL) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of image for layer %.20g failed"",(double) i); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + + if (layer_info[i].info != (StringInfo *) NULL) + { + (void) SetImageProfile(layer_info[i].image,""psd:additional-info"", + layer_info[i].info,exception); + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + } + } + + if (image_info->ping == MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=0; j < layer_info[i].channels; j++) + { + if (DiscardBlobBytes(image,(MagickSizeType) + layer_info[i].channel_info[j].size) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + continue; + } + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading data for layer %.20g"",(double) i); + + status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i], + exception); + if (status == MagickFalse) + break; + + status=SetImageProgress(image,LoadImagesTag,i,(MagickSizeType) + number_layers); + if (status == MagickFalse) + break; + } + } + + if (status != MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=i; j < number_layers - 1; j++) + layer_info[j] = layer_info[j+1]; + number_layers--; + i--; + } + } + + if (number_layers > 0) + { + for (i=0; i < number_layers; i++) + { + if (i > 0) + layer_info[i].image->previous=layer_info[i-1].image; + if (i < (number_layers-1)) + layer_info[i].image->next=layer_info[i+1].image; + layer_info[i].image->page=layer_info[i].page; + } + image->next=layer_info[0].image; + layer_info[0].image->previous=image; + } + layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info); + } + else + layer_info=DestroyLayerInfo(layer_info,number_layers); + } + + return(status); +} +","@@ -1691,7 +1691,7 @@ ModuleExport MagickBooleanType ReadPSDLayers(Image *image, + /* + Layer name. + */ +- length=(MagickSizeType) ReadBlobByte(image); ++ length=(MagickSizeType) (unsigned char) ReadBlobByte(image); + combined_length+=length+1; + if (length > 0) + (void) ReadBlob(image,(size_t) length++,layer_info[i].name);",3250,3486,4096 +18336,"static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define RMT_EQUAL_RGB 1 +#define RMT_NONE 0 +#define RMT_RAW 2 +#define RT_STANDARD 1 +#define RT_ENCODED 2 +#define RT_FORMAT_RGB 3 + + typedef struct _SUNInfo + { + unsigned int + magic, + width, + height, + depth, + length, + type, + maptype, + maplength; + } SUNInfo; + + Image + *image; + + int + bit; + + MagickBooleanType + status; + + MagickSizeType + number_pixels; + + register Quantum + *q; + + register ssize_t + i, + x; + + register unsigned char + *p; + + size_t + bytes_per_line, + extent, + height, + length; + + ssize_t + count, + y; + + SUNInfo + sun_info; + + unsigned char + *sun_data, + *sun_pixels; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read SUN raster header. + */ + (void) ResetMagickMemory(&sun_info,0,sizeof(sun_info)); + sun_info.magic=ReadBlobMSBLong(image); + do + { + /* + Verify SUN identifier. + */ + if (sun_info.magic != 0x59a66a95) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + sun_info.width=ReadBlobMSBLong(image); + sun_info.height=ReadBlobMSBLong(image); + sun_info.depth=ReadBlobMSBLong(image); + sun_info.length=ReadBlobMSBLong(image); + sun_info.type=ReadBlobMSBLong(image); + sun_info.maptype=ReadBlobMSBLong(image); + sun_info.maplength=ReadBlobMSBLong(image); + extent=sun_info.height*sun_info.width; + if ((sun_info.height != 0) && (sun_info.width != extent/sun_info.height)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) && + (sun_info.type != RT_FORMAT_RGB)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.maptype == RMT_NONE) && (sun_info.maplength != 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.depth == 0) || (sun_info.depth > 32)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.maptype != RMT_NONE) && (sun_info.maptype != RMT_EQUAL_RGB) && + (sun_info.maptype != RMT_RAW)) + ThrowReaderException(CoderError,""ColormapTypeNotSupported""); + image->columns=sun_info.width; + image->rows=sun_info.height; + image->depth=sun_info.depth <= 8 ? sun_info.depth : + MAGICKCORE_QUANTUM_DEPTH; + if (sun_info.depth < 24) + { + size_t + one; + + image->colors=sun_info.maplength; + one=1; + if (sun_info.maptype == RMT_NONE) + image->colors=one << sun_info.depth; + if (sun_info.maptype == RMT_EQUAL_RGB) + image->colors=sun_info.maplength/3; + if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + switch (sun_info.maptype) + { + case RMT_NONE: + break; + case RMT_EQUAL_RGB: + { + unsigned char + *sun_colormap; + + /* + Read SUN raster colormap. + */ + sun_colormap=(unsigned char *) AcquireQuantumMemory(image->colors, + sizeof(*sun_colormap)); + if (sun_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,image->colors,sun_colormap); + if (count != (ssize_t) image->colors) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].red=(MagickRealType) ScaleCharToQuantum( + sun_colormap[i]); + count=ReadBlob(image,image->colors,sun_colormap); + if (count != (ssize_t) image->colors) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].green=(MagickRealType) ScaleCharToQuantum( + sun_colormap[i]); + count=ReadBlob(image,image->colors,sun_colormap); + if (count != (ssize_t) image->colors) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum( + sun_colormap[i]); + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + break; + } + case RMT_RAW: + { + unsigned char + *sun_colormap; + + /* + Read SUN raster colormap. + */ + sun_colormap=(unsigned char *) AcquireQuantumMemory(sun_info.maplength, + sizeof(*sun_colormap)); + if (sun_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,sun_info.maplength,sun_colormap); + if (count != (ssize_t) sun_info.maplength) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + break; + } + default: + ThrowReaderException(CoderError,""ColormapTypeNotSupported""); + } + image->alpha_trait=sun_info.depth == 32 ? BlendPixelTrait : + UndefinedPixelTrait; + image->columns=sun_info.width; + image->rows=sun_info.height; + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + if ((sun_info.length*sizeof(*sun_data))/sizeof(*sun_data) != + sun_info.length || !sun_info.length) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + number_pixels=(MagickSizeType) image->columns*image->rows; + if ((sun_info.type != RT_ENCODED) && + ((number_pixels*sun_info.depth) > (8*sun_info.length))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + bytes_per_line=sun_info.width*sun_info.depth; + sun_data=(unsigned char *) AcquireQuantumMemory((size_t) MagickMax( + sun_info.length,bytes_per_line*sun_info.width),sizeof(*sun_data)); + if (sun_data == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=(ssize_t) ReadBlob(image,sun_info.length,sun_data); + if (count != (ssize_t) sun_info.length) + ThrowReaderException(CorruptImageError,""UnableToReadImageData""); + height=sun_info.height; + if ((height == 0) || (sun_info.width == 0) || (sun_info.depth == 0) || + ((bytes_per_line/sun_info.depth) != sun_info.width)) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + bytes_per_line+=15; + bytes_per_line<<=1; + if ((bytes_per_line >> 1) != (sun_info.width*sun_info.depth+15)) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + bytes_per_line>>=4; + sun_pixels=(unsigned char *) AcquireQuantumMemory(height, + bytes_per_line*sizeof(*sun_pixels)); + if (sun_pixels == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if (sun_info.type == RT_ENCODED) + (void) DecodeImage(sun_data,sun_info.length,sun_pixels,bytes_per_line* + height); + sun_data=(unsigned char *) RelinquishMagickMemory(sun_data); + /* + Convert SUN raster image to pixel packets. + */ + p=sun_pixels; + if (sun_info.depth == 1) + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + for (bit=7; bit >= 0; bit--) + { + SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 : 0x01), + q); + q+=GetPixelChannels(image); + } + p++; + } + if ((image->columns % 8) != 0) + { + for (bit=7; bit >= (int) (8-(image->columns % 8)); bit--) + { + SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 : + 0x01),q); + q+=GetPixelChannels(image); + } + p++; + } + if ((((image->columns/8)+(image->columns % 8 ? 1 : 0)) % 2) != 0) + p++; + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image->storage_class == PseudoClass) + { + if (bytes_per_line == 0) + bytes_per_line=image->columns; + length=image->rows*(image->columns+image->columns % 2); + if (((sun_info.type == RT_ENCODED) && + (length > (bytes_per_line*image->rows))) || + ((sun_info.type != RT_ENCODED) && (length > sun_info.length))) + ThrowReaderException(CorruptImageError,""UnableToReadImageData""); + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelIndex(image,*p++,q); + q+=GetPixelChannels(image); + } + if ((image->columns % 2) != 0) + p++; + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + else + { + size_t + bytes_per_pixel; + + bytes_per_pixel=3; + if (image->alpha_trait != UndefinedPixelTrait) + bytes_per_pixel++; + if (bytes_per_line == 0) + bytes_per_line=bytes_per_pixel*image->columns; + length=image->rows*(bytes_per_line+bytes_per_line % 2); + if (((sun_info.type == RT_ENCODED) && + (length > (bytes_per_line*image->rows))) || + ((sun_info.type != RT_ENCODED) && (length > sun_info.length))) + ThrowReaderException(CorruptImageError,""UnableToReadImageData""); + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->alpha_trait != UndefinedPixelTrait) + SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); + if (sun_info.type == RT_STANDARD) + { + SetPixelBlue(image,ScaleCharToQuantum(*p++),q); + SetPixelGreen(image,ScaleCharToQuantum(*p++),q); + SetPixelRed(image,ScaleCharToQuantum(*p++),q); + } + else + { + SetPixelRed(image,ScaleCharToQuantum(*p++),q); + SetPixelGreen(image,ScaleCharToQuantum(*p++),q); + SetPixelBlue(image,ScaleCharToQuantum(*p++),q); + } + if (image->colors != 0) + { + SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t) + GetPixelRed(image,q)].red),q); + SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t) + GetPixelGreen(image,q)].green),q); + SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t) + GetPixelBlue(image,q)].blue),q); + } + q+=GetPixelChannels(image); + } + if (((bytes_per_pixel*image->columns) % 2) != 0) + p++; + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if (image->storage_class == PseudoClass) + (void) SyncImage(image,exception); + sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels); + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + break; + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + sun_info.magic=ReadBlobMSBLong(image); + if (sun_info.magic == 0x59a66a95) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image,exception); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } while (sun_info.magic == 0x59a66a95); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define RMT_EQUAL_RGB 1 +#define RMT_NONE 0 +#define RMT_RAW 2 +#define RT_STANDARD 1 +#define RT_ENCODED 2 +#define RT_FORMAT_RGB 3 + + typedef struct _SUNInfo + { + unsigned int + magic, + width, + height, + depth, + length, + type, + maptype, + maplength; + } SUNInfo; + + Image + *image; + + int + bit; + + MagickBooleanType + status; + + MagickSizeType + number_pixels; + + register Quantum + *q; + + register ssize_t + i, + x; + + register unsigned char + *p; + + size_t + bytes_per_line, + extent, + height, + length; + + ssize_t + count, + y; + + SUNInfo + sun_info; + + unsigned char + *sun_data, + *sun_pixels; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read SUN raster header. + */ + (void) ResetMagickMemory(&sun_info,0,sizeof(sun_info)); + sun_info.magic=ReadBlobMSBLong(image); + do + { + /* + Verify SUN identifier. + */ + if (sun_info.magic != 0x59a66a95) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + sun_info.width=ReadBlobMSBLong(image); + sun_info.height=ReadBlobMSBLong(image); + sun_info.depth=ReadBlobMSBLong(image); + sun_info.length=ReadBlobMSBLong(image); + sun_info.type=ReadBlobMSBLong(image); + sun_info.maptype=ReadBlobMSBLong(image); + sun_info.maplength=ReadBlobMSBLong(image); + extent=sun_info.height*sun_info.width; + if ((sun_info.height != 0) && (sun_info.width != extent/sun_info.height)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) && + (sun_info.type != RT_FORMAT_RGB)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.maptype == RMT_NONE) && (sun_info.maplength != 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.depth == 0) || (sun_info.depth > 32)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if ((sun_info.maptype != RMT_NONE) && (sun_info.maptype != RMT_EQUAL_RGB) && + (sun_info.maptype != RMT_RAW)) + ThrowReaderException(CoderError,""ColormapTypeNotSupported""); + image->columns=sun_info.width; + image->rows=sun_info.height; + image->depth=sun_info.depth <= 8 ? sun_info.depth : + MAGICKCORE_QUANTUM_DEPTH; + if (sun_info.depth < 24) + { + size_t + one; + + image->colors=sun_info.maplength; + one=1; + if (sun_info.maptype == RMT_NONE) + image->colors=one << sun_info.depth; + if (sun_info.maptype == RMT_EQUAL_RGB) + image->colors=sun_info.maplength/3; + if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + switch (sun_info.maptype) + { + case RMT_NONE: + break; + case RMT_EQUAL_RGB: + { + unsigned char + *sun_colormap; + + /* + Read SUN raster colormap. + */ + sun_colormap=(unsigned char *) AcquireQuantumMemory(image->colors, + sizeof(*sun_colormap)); + if (sun_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,image->colors,sun_colormap); + if (count != (ssize_t) image->colors) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].red=(MagickRealType) ScaleCharToQuantum( + sun_colormap[i]); + count=ReadBlob(image,image->colors,sun_colormap); + if (count != (ssize_t) image->colors) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].green=(MagickRealType) ScaleCharToQuantum( + sun_colormap[i]); + count=ReadBlob(image,image->colors,sun_colormap); + if (count != (ssize_t) image->colors) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum( + sun_colormap[i]); + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + break; + } + case RMT_RAW: + { + unsigned char + *sun_colormap; + + /* + Read SUN raster colormap. + */ + sun_colormap=(unsigned char *) AcquireQuantumMemory(sun_info.maplength, + sizeof(*sun_colormap)); + if (sun_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,sun_info.maplength,sun_colormap); + if (count != (ssize_t) sun_info.maplength) + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap); + break; + } + default: + ThrowReaderException(CoderError,""ColormapTypeNotSupported""); + } + image->alpha_trait=sun_info.depth == 32 ? BlendPixelTrait : + UndefinedPixelTrait; + image->columns=sun_info.width; + image->rows=sun_info.height; + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + if ((sun_info.length*sizeof(*sun_data))/sizeof(*sun_data) != + sun_info.length || !sun_info.length) + ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + number_pixels=(MagickSizeType) image->columns*image->rows; + if ((sun_info.type != RT_ENCODED) && + ((number_pixels*sun_info.depth) > (8*sun_info.length))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + bytes_per_line=sun_info.width*sun_info.depth; + sun_data=(unsigned char *) AcquireQuantumMemory((size_t) MagickMax( + sun_info.length,bytes_per_line*sun_info.width),sizeof(*sun_data)); + if (sun_data == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=(ssize_t) ReadBlob(image,sun_info.length,sun_data); + if (count != (ssize_t) sun_info.length) + ThrowReaderException(CorruptImageError,""UnableToReadImageData""); + height=sun_info.height; + if ((height == 0) || (sun_info.width == 0) || (sun_info.depth == 0) || + ((bytes_per_line/sun_info.depth) != sun_info.width)) + ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + bytes_per_line+=15; + bytes_per_line<<=1; + if ((bytes_per_line >> 1) != (sun_info.width*sun_info.depth+15)) + ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + bytes_per_line>>=4; + sun_pixels=(unsigned char *) AcquireQuantumMemory(height, + bytes_per_line*sizeof(*sun_pixels)); + if (sun_pixels == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if (sun_info.type == RT_ENCODED) + (void) DecodeImage(sun_data,sun_info.length,sun_pixels,bytes_per_line* + height); + else + { + if (sun_info.length > (height*bytes_per_line)) + ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length); + } + sun_data=(unsigned char *) RelinquishMagickMemory(sun_data); + /* + Convert SUN raster image to pixel packets. + */ + p=sun_pixels; + if (sun_info.depth == 1) + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + for (bit=7; bit >= 0; bit--) + { + SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 : 0x01), + q); + q+=GetPixelChannels(image); + } + p++; + } + if ((image->columns % 8) != 0) + { + for (bit=7; bit >= (int) (8-(image->columns % 8)); bit--) + { + SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 : + 0x01),q); + q+=GetPixelChannels(image); + } + p++; + } + if ((((image->columns/8)+(image->columns % 8 ? 1 : 0)) % 2) != 0) + p++; + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image->storage_class == PseudoClass) + { + if (bytes_per_line == 0) + bytes_per_line=image->columns; + length=image->rows*(image->columns+image->columns % 2); + if (((sun_info.type == RT_ENCODED) && + (length > (bytes_per_line*image->rows))) || + ((sun_info.type != RT_ENCODED) && (length > sun_info.length))) + ThrowReaderException(CorruptImageError,""UnableToReadImageData""); + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelIndex(image,*p++,q); + q+=GetPixelChannels(image); + } + if ((image->columns % 2) != 0) + p++; + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + else + { + size_t + bytes_per_pixel; + + bytes_per_pixel=3; + if (image->alpha_trait != UndefinedPixelTrait) + bytes_per_pixel++; + if (bytes_per_line == 0) + bytes_per_line=bytes_per_pixel*image->columns; + length=image->rows*(bytes_per_line+bytes_per_line % 2); + if (((sun_info.type == RT_ENCODED) && + (length > (bytes_per_line*image->rows))) || + ((sun_info.type != RT_ENCODED) && (length > sun_info.length))) + ThrowReaderException(CorruptImageError,""UnableToReadImageData""); + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->alpha_trait != UndefinedPixelTrait) + SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); + if (sun_info.type == RT_STANDARD) + { + SetPixelBlue(image,ScaleCharToQuantum(*p++),q); + SetPixelGreen(image,ScaleCharToQuantum(*p++),q); + SetPixelRed(image,ScaleCharToQuantum(*p++),q); + } + else + { + SetPixelRed(image,ScaleCharToQuantum(*p++),q); + SetPixelGreen(image,ScaleCharToQuantum(*p++),q); + SetPixelBlue(image,ScaleCharToQuantum(*p++),q); + } + if (image->colors != 0) + { + SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t) + GetPixelRed(image,q)].red),q); + SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t) + GetPixelGreen(image,q)].green),q); + SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t) + GetPixelBlue(image,q)].blue),q); + } + q+=GetPixelChannels(image); + } + if (((bytes_per_pixel*image->columns) % 2) != 0) + p++; + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if (image->storage_class == PseudoClass) + (void) SyncImage(image,exception); + sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels); + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + break; + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + sun_info.magic=ReadBlobMSBLong(image); + if (sun_info.magic == 0x59a66a95) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image,exception); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } while (sun_info.magic == 0x59a66a95); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -408,7 +408,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) + return(DestroyImageList(image)); + if ((sun_info.length*sizeof(*sun_data))/sizeof(*sun_data) != + sun_info.length || !sun_info.length) +- ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + number_pixels=(MagickSizeType) image->columns*image->rows; + if ((sun_info.type != RT_ENCODED) && + ((number_pixels*sun_info.depth) > (8*sun_info.length))) +@@ -424,11 +424,11 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) + height=sun_info.height; + if ((height == 0) || (sun_info.width == 0) || (sun_info.depth == 0) || + ((bytes_per_line/sun_info.depth) != sun_info.width)) +- ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + bytes_per_line+=15; + bytes_per_line<<=1; + if ((bytes_per_line >> 1) != (sun_info.width*sun_info.depth+15)) +- ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); + bytes_per_line>>=4; + sun_pixels=(unsigned char *) AcquireQuantumMemory(height, + bytes_per_line*sizeof(*sun_pixels)); +@@ -437,6 +437,12 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) + if (sun_info.type == RT_ENCODED) + (void) DecodeImage(sun_data,sun_info.length,sun_pixels,bytes_per_line* + height); ++ else ++ { ++ if (sun_info.length > (height*bytes_per_line)) ++ ThrowReaderException(ResourceLimitError,""ImproperImageHeader""); ++ (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length); ++ } + sun_data=(unsigned char *) RelinquishMagickMemory(sun_data); + /* + Convert SUN raster image to pixel packets.",3541,3777,4096 +8568,"cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ +{ + int bytes, /* Number of bytes written */ + field_col; /* Current column */ + char *bufptr, /* Pointer into buffer */ + *bufend; /* Pointer to end of buffer */ + ipp_state_t ipp_state; /* IPP state value */ + + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""con->http=%p"", con->http); + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""cupsdWriteClient "" + ""error=%d, "" + ""used=%d, "" + ""state=%s, "" + ""data_encoding=HTTP_ENCODING_%s, "" + ""data_remaining="" CUPS_LLFMT "", "" + ""response=%p(%s), "" + ""pipe_pid=%d, "" + ""file=%d"", + httpError(con->http), (int)httpGetReady(con->http), + httpStateString(httpGetState(con->http)), + httpIsChunked(con->http) ? ""CHUNKED"" : ""LENGTH"", + CUPS_LLCAST httpGetLength2(con->http), + con->response, + con->response ? ippStateString(ippGetState(con->request)) : """", + con->pipe_pid, con->file); + + if (httpGetState(con->http) != HTTP_STATE_GET_SEND && + httpGetState(con->http) != HTTP_STATE_POST_SEND) + { + /* + * If we get called in the wrong state, then something went wrong with the + * connection and we need to shut it down... + */ + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Closing on unexpected HTTP write state %s."", + httpStateString(httpGetState(con->http))); + cupsdCloseClient(con); + return; + } + + if (con->pipe_pid) + { + /* + * Make sure we select on the CGI output... + */ + + cupsdAddSelect(con->file, (cupsd_selfunc_t)write_pipe, NULL, con); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Waiting for CGI data.""); + + if (!con->file_ready) + { + /* + * Try again later when there is CGI output available... + */ + + cupsdRemoveSelect(httpGetFd(con->http)); + return; + } + + con->file_ready = 0; + } + + bytes = (ssize_t)(sizeof(con->header) - (size_t)con->header_used); + + if (!con->pipe_pid && bytes > (ssize_t)httpGetRemaining(con->http)) + { + /* + * Limit GET bytes to original size of file (STR #3265)... + */ + + bytes = (ssize_t)httpGetRemaining(con->http); + } + + if (con->response && con->response->state != IPP_STATE_DATA) + { + size_t wused = httpGetPending(con->http); /* Previous write buffer use */ + + do + { + /* + * Write a single attribute or the IPP message header... + */ + + ipp_state = ippWrite(con->http, con->response); + + /* + * If the write buffer has been flushed, stop buffering up attributes... + */ + + if (httpGetPending(con->http) <= wused) + break; + } + while (ipp_state != IPP_STATE_DATA && ipp_state != IPP_STATE_ERROR); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""Writing IPP response, ipp_state=%s, old "" + ""wused="" CUPS_LLFMT "", new wused="" CUPS_LLFMT, + ippStateString(ipp_state), + CUPS_LLCAST wused, CUPS_LLCAST httpGetPending(con->http)); + + if (httpGetPending(con->http) > 0) + httpFlushWrite(con->http); + + bytes = ipp_state != IPP_STATE_ERROR && + (con->file >= 0 || ipp_state != IPP_STATE_DATA); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""bytes=%d, http_state=%d, data_remaining="" CUPS_LLFMT, + (int)bytes, httpGetState(con->http), + CUPS_LLCAST httpGetLength2(con->http)); + } + else if ((bytes = read(con->file, con->header + con->header_used, (size_t)bytes)) > 0) + { + con->header_used += bytes; + + if (con->pipe_pid && !con->got_fields) + { + /* + * Inspect the data for Content-Type and other fields. + */ + + for (bufptr = con->header, bufend = con->header + con->header_used, + field_col = 0; + !con->got_fields && bufptr < bufend; + bufptr ++) + { + if (*bufptr == '\n') + { + /* + * Send line to client... + */ + + if (bufptr > con->header && bufptr[-1] == '\r') + bufptr[-1] = '\0'; + *bufptr++ = '\0'; + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Script header: %s"", con->header); + + if (!con->sent_header) + { + /* + * Handle redirection and CGI status codes... + */ + + http_field_t field; /* HTTP field */ + char *value = strchr(con->header, ':'); + /* Value of field */ + + if (value) + { + *value++ = '\0'; + while (isspace(*value & 255)) + value ++; + } + + field = httpFieldValue(con->header); + + if (field != HTTP_FIELD_UNKNOWN && value) + { + httpSetField(con->http, field, value); + + if (field == HTTP_FIELD_LOCATION) + { + con->pipe_status = HTTP_STATUS_SEE_OTHER; + con->sent_header = 2; + } + else + con->sent_header = 1; + } + else if (!_cups_strcasecmp(con->header, ""Status"") && value) + { + con->pipe_status = (http_status_t)atoi(value); + con->sent_header = 2; + } + else if (!_cups_strcasecmp(con->header, ""Set-Cookie"") && value) + { + httpSetCookie(con->http, value); + con->sent_header = 1; + } + } + + /* + * Update buffer... + */ + + con->header_used -= bufptr - con->header; + + if (con->header_used > 0) + memmove(con->header, bufptr, (size_t)con->header_used); + + bufptr = con->header - 1; + + /* + * See if the line was empty... + */ + + if (field_col == 0) + { + con->got_fields = 1; + + if (httpGetVersion(con->http) == HTTP_VERSION_1_1 && + !httpGetField(con->http, HTTP_FIELD_CONTENT_LENGTH)[0]) + httpSetLength(con->http, 0); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Sending status %d for CGI."", con->pipe_status); + + if (con->pipe_status == HTTP_STATUS_OK) + { + if (!cupsdSendHeader(con, con->pipe_status, NULL, CUPSD_AUTH_NONE)) + { + cupsdCloseClient(con); + return; + } + } + else + { + if (!cupsdSendError(con, con->pipe_status, CUPSD_AUTH_NONE)) + { + cupsdCloseClient(con); + return; + } + } + } + else + field_col = 0; + } + else if (*bufptr != '\r') + field_col ++; + } + + if (!con->got_fields) + return; + } + + if (con->header_used > 0) + { + if (httpWrite2(con->http, con->header, (size_t)con->header_used) < 0) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Closing for error %d (%s)"", + httpError(con->http), strerror(httpError(con->http))); + cupsdCloseClient(con); + return; + } + + if (httpIsChunked(con->http)) + httpFlushWrite(con->http); + + con->bytes += con->header_used; + + if (httpGetState(con->http) == HTTP_STATE_WAITING) + bytes = 0; + else + bytes = con->header_used; + + con->header_used = 0; + } + } + + if (bytes <= 0 || + (httpGetState(con->http) != HTTP_STATE_GET_SEND && + httpGetState(con->http) != HTTP_STATE_POST_SEND)) + { + if (!con->sent_header && con->pipe_pid) + cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE); + else + { + cupsdLogRequest(con, HTTP_STATUS_OK); + + if (httpIsChunked(con->http) && (!con->pipe_pid || con->sent_header > 0)) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Sending 0-length chunk.""); + + if (httpWrite2(con->http, """", 0) < 0) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Closing for error %d (%s)"", + httpError(con->http), strerror(httpError(con->http))); + cupsdCloseClient(con); + return; + } + } + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Flushing write buffer.""); + httpFlushWrite(con->http); + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""New state is %s"", httpStateString(httpGetState(con->http))); + } + + cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient, NULL, con); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Waiting for request.""); + + if (con->file >= 0) + { + cupsdRemoveSelect(con->file); + + if (con->pipe_pid) + cupsdEndProcess(con->pipe_pid, 0); + + close(con->file); + con->file = -1; + con->pipe_pid = 0; + } + + if (con->filename) + { + unlink(con->filename); + cupsdClearString(&con->filename); + } + + if (con->request) + { + ippDelete(con->request); + con->request = NULL; + } + + if (con->response) + { + ippDelete(con->response); + con->response = NULL; + } + + cupsdClearString(&con->command); + cupsdClearString(&con->options); + cupsdClearString(&con->query_string); + + if (!httpGetKeepAlive(con->http)) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""Closing because Keep-Alive is disabled.""); + cupsdCloseClient(con); + return; + } + else + { + cupsArrayRemove(ActiveClients, con); + cupsdSetBusyState(); + } + } +} +",0,"cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ +{ + int bytes, /* Number of bytes written */ + field_col; /* Current column */ + char *bufptr, /* Pointer into buffer */ + *bufend; /* Pointer to end of buffer */ + ipp_state_t ipp_state; /* IPP state value */ + + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""con->http=%p"", con->http); + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""cupsdWriteClient "" + ""error=%d, "" + ""used=%d, "" + ""state=%s, "" + ""data_encoding=HTTP_ENCODING_%s, "" + ""data_remaining="" CUPS_LLFMT "", "" + ""response=%p(%s), "" + ""pipe_pid=%d, "" + ""file=%d"", + httpError(con->http), (int)httpGetReady(con->http), + httpStateString(httpGetState(con->http)), + httpIsChunked(con->http) ? ""CHUNKED"" : ""LENGTH"", + CUPS_LLCAST httpGetLength2(con->http), + con->response, + con->response ? ippStateString(ippGetState(con->request)) : """", + con->pipe_pid, con->file); + + if (httpGetState(con->http) != HTTP_STATE_GET_SEND && + httpGetState(con->http) != HTTP_STATE_POST_SEND) + { + /* + * If we get called in the wrong state, then something went wrong with the + * connection and we need to shut it down... + */ + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Closing on unexpected HTTP write state %s."", + httpStateString(httpGetState(con->http))); + cupsdCloseClient(con); + return; + } + + if (con->pipe_pid) + { + /* + * Make sure we select on the CGI output... + */ + + cupsdAddSelect(con->file, (cupsd_selfunc_t)write_pipe, NULL, con); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Waiting for CGI data.""); + + if (!con->file_ready) + { + /* + * Try again later when there is CGI output available... + */ + + cupsdRemoveSelect(httpGetFd(con->http)); + return; + } + + con->file_ready = 0; + } + + bytes = (ssize_t)(sizeof(con->header) - (size_t)con->header_used); + + if (!con->pipe_pid && bytes > (ssize_t)httpGetRemaining(con->http)) + { + /* + * Limit GET bytes to original size of file (STR #3265)... + */ + + bytes = (ssize_t)httpGetRemaining(con->http); + } + + if (con->response && con->response->state != IPP_STATE_DATA) + { + size_t wused = httpGetPending(con->http); /* Previous write buffer use */ + + do + { + /* + * Write a single attribute or the IPP message header... + */ + + ipp_state = ippWrite(con->http, con->response); + + /* + * If the write buffer has been flushed, stop buffering up attributes... + */ + + if (httpGetPending(con->http) <= wused) + break; + } + while (ipp_state != IPP_STATE_DATA && ipp_state != IPP_STATE_ERROR); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""Writing IPP response, ipp_state=%s, old "" + ""wused="" CUPS_LLFMT "", new wused="" CUPS_LLFMT, + ippStateString(ipp_state), + CUPS_LLCAST wused, CUPS_LLCAST httpGetPending(con->http)); + + if (httpGetPending(con->http) > 0) + httpFlushWrite(con->http); + + bytes = ipp_state != IPP_STATE_ERROR && + (con->file >= 0 || ipp_state != IPP_STATE_DATA); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""bytes=%d, http_state=%d, data_remaining="" CUPS_LLFMT, + (int)bytes, httpGetState(con->http), + CUPS_LLCAST httpGetLength2(con->http)); + } + else if ((bytes = read(con->file, con->header + con->header_used, (size_t)bytes)) > 0) + { + con->header_used += bytes; + + if (con->pipe_pid && !con->got_fields) + { + /* + * Inspect the data for Content-Type and other fields. + */ + + for (bufptr = con->header, bufend = con->header + con->header_used, + field_col = 0; + !con->got_fields && bufptr < bufend; + bufptr ++) + { + if (*bufptr == '\n') + { + /* + * Send line to client... + */ + + if (bufptr > con->header && bufptr[-1] == '\r') + bufptr[-1] = '\0'; + *bufptr++ = '\0'; + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Script header: %s"", con->header); + + if (!con->sent_header) + { + /* + * Handle redirection and CGI status codes... + */ + + http_field_t field; /* HTTP field */ + char *value = strchr(con->header, ':'); + /* Value of field */ + + if (value) + { + *value++ = '\0'; + while (isspace(*value & 255)) + value ++; + } + + field = httpFieldValue(con->header); + + if (field != HTTP_FIELD_UNKNOWN && value) + { + httpSetField(con->http, field, value); + + if (field == HTTP_FIELD_LOCATION) + { + con->pipe_status = HTTP_STATUS_SEE_OTHER; + con->sent_header = 2; + } + else + con->sent_header = 1; + } + else if (!_cups_strcasecmp(con->header, ""Status"") && value) + { + con->pipe_status = (http_status_t)atoi(value); + con->sent_header = 2; + } + else if (!_cups_strcasecmp(con->header, ""Set-Cookie"") && value) + { + httpSetCookie(con->http, value); + con->sent_header = 1; + } + } + + /* + * Update buffer... + */ + + con->header_used -= bufptr - con->header; + + if (con->header_used > 0) + memmove(con->header, bufptr, (size_t)con->header_used); + + bufptr = con->header - 1; + + /* + * See if the line was empty... + */ + + if (field_col == 0) + { + con->got_fields = 1; + + if (httpGetVersion(con->http) == HTTP_VERSION_1_1 && + !httpGetField(con->http, HTTP_FIELD_CONTENT_LENGTH)[0]) + httpSetLength(con->http, 0); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Sending status %d for CGI."", con->pipe_status); + + if (con->pipe_status == HTTP_STATUS_OK) + { + if (!cupsdSendHeader(con, con->pipe_status, NULL, CUPSD_AUTH_NONE)) + { + cupsdCloseClient(con); + return; + } + } + else + { + if (!cupsdSendError(con, con->pipe_status, CUPSD_AUTH_NONE)) + { + cupsdCloseClient(con); + return; + } + } + } + else + field_col = 0; + } + else if (*bufptr != '\r') + field_col ++; + } + + if (!con->got_fields) + return; + } + + if (con->header_used > 0) + { + if (httpWrite2(con->http, con->header, (size_t)con->header_used) < 0) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Closing for error %d (%s)"", + httpError(con->http), strerror(httpError(con->http))); + cupsdCloseClient(con); + return; + } + + if (httpIsChunked(con->http)) + httpFlushWrite(con->http); + + con->bytes += con->header_used; + + if (httpGetState(con->http) == HTTP_STATE_WAITING) + bytes = 0; + else + bytes = con->header_used; + + con->header_used = 0; + } + } + + if (bytes <= 0 || + (httpGetState(con->http) != HTTP_STATE_GET_SEND && + httpGetState(con->http) != HTTP_STATE_POST_SEND)) + { + if (!con->sent_header && con->pipe_pid) + cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE); + else + { + cupsdLogRequest(con, HTTP_STATUS_OK); + + if (httpIsChunked(con->http) && (!con->pipe_pid || con->sent_header > 0)) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Sending 0-length chunk.""); + + if (httpWrite2(con->http, """", 0) < 0) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Closing for error %d (%s)"", + httpError(con->http), strerror(httpError(con->http))); + cupsdCloseClient(con); + return; + } + } + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Flushing write buffer.""); + httpFlushWrite(con->http); + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""New state is %s"", httpStateString(httpGetState(con->http))); + } + + cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient, NULL, con); + + cupsdLogClient(con, CUPSD_LOG_DEBUG, ""Waiting for request.""); + + if (con->file >= 0) + { + cupsdRemoveSelect(con->file); + + if (con->pipe_pid) + cupsdEndProcess(con->pipe_pid, 0); + + close(con->file); + con->file = -1; + con->pipe_pid = 0; + } + + if (con->filename) + { + unlink(con->filename); + cupsdClearString(&con->filename); + } + + if (con->request) + { + ippDelete(con->request); + con->request = NULL; + } + + if (con->response) + { + ippDelete(con->response); + con->response = NULL; + } + + cupsdClearString(&con->command); + cupsdClearString(&con->options); + cupsdClearString(&con->query_string); + + if (!httpGetKeepAlive(con->http)) + { + cupsdLogClient(con, CUPSD_LOG_DEBUG, + ""Closing because Keep-Alive is disabled.""); + cupsdCloseClient(con); + return; + } + else + { + cupsArrayRemove(ActiveClients, con); + cupsdSetBusyState(); + } + } +} +","@@ -3890,9 +3890,6 @@ valid_host(cupsd_client_t *con) /* I - Client connection */ + + return (!_cups_strcasecmp(con->clientname, ""localhost"") || + !_cups_strcasecmp(con->clientname, ""localhost."") || +-#ifdef __linux +- !_cups_strcasecmp(con->clientname, ""localhost.localdomain"") || +-#endif /* __linux */ + !strcmp(con->clientname, ""127.0.0.1"") || + !strcmp(con->clientname, ""[::1]"")); + }",2429,2665,4096 +18220,"static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + AVIOContext *pb = s->pb; + AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar; + FLVContext *flv = s->priv_data; + FLVStreamContext *sc = s->streams[pkt->stream_index]->priv_data; + unsigned ts; + int size = pkt->size; + uint8_t *data = NULL; + int flags = -1, flags_size, ret; + int64_t cur_offset = avio_tell(pb); + + if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || + par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) + flags_size = 2; + else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) + flags_size = 5; + else + flags_size = 1; + + if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 + || par->codec_id == AV_CODEC_ID_MPEG4) { + int side_size = 0; + uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); + if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) { + av_free(par->extradata); + par->extradata = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!par->extradata) { + par->extradata_size = 0; + return AVERROR(ENOMEM); + } + memcpy(par->extradata, side, side_size); + par->extradata_size = side_size; + flv_write_codec_header(s, par, pkt->dts); + } + } + + if (flv->delay == AV_NOPTS_VALUE) + flv->delay = -pkt->dts; + + if (pkt->dts < -flv->delay) { + av_log(s, AV_LOG_WARNING, + ""Packets are not in the proper order with respect to DTS\n""); + return AVERROR(EINVAL); + } + + ts = pkt->dts; + + if (s->event_flags & AVSTREAM_EVENT_FLAG_METADATA_UPDATED) { + write_metadata(s, ts); + s->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED; + } + + avio_write_marker(pb, av_rescale(ts, AV_TIME_BASE, 1000), + pkt->flags & AV_PKT_FLAG_KEY && (flv->video_par ? par->codec_type == AVMEDIA_TYPE_VIDEO : 1) ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT); + + switch (par->codec_type) { + case AVMEDIA_TYPE_VIDEO: + avio_w8(pb, FLV_TAG_TYPE_VIDEO); + + flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id); + + flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER; + break; + case AVMEDIA_TYPE_AUDIO: + flags = get_audio_flags(s, par); + + av_assert0(size); + + avio_w8(pb, FLV_TAG_TYPE_AUDIO); + break; + case AVMEDIA_TYPE_SUBTITLE: + case AVMEDIA_TYPE_DATA: + avio_w8(pb, FLV_TAG_TYPE_META); + break; + default: + return AVERROR(EINVAL); + } + + if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) { + /* check if extradata looks like mp4 formatted */ + if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1) + if ((ret = ff_avc_parse_nal_units_buf(pkt->data, &data, &size)) < 0) + return ret; + } else if (par->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && + (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { + if (!s->streams[pkt->stream_index]->nb_frames) { + av_log(s, AV_LOG_ERROR, ""Malformed AAC bitstream detected: "" + ""use the audio bitstream filter 'aac_adtstoasc' to fix it "" + ""('-bsf:a aac_adtstoasc' option with ffmpeg)\n""); + return AVERROR_INVALIDDATA; + } + av_log(s, AV_LOG_WARNING, ""aac bitstream error\n""); + } + + /* check Speex packet duration */ + if (par->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160) + av_log(s, AV_LOG_WARNING, ""Warning: Speex stream has more than "" + ""8 frames per packet. Adobe Flash "" + ""Player cannot handle this!\n""); + + if (sc->last_ts < ts) + sc->last_ts = ts; + + if (size + flags_size >= 1<<24) { + av_log(s, AV_LOG_ERROR, ""Too large packet with size %u >= %u\n"", + size + flags_size, 1<<24); + return AVERROR(EINVAL); + } + + avio_wb24(pb, size + flags_size); + put_timestamp(pb, ts); + avio_wb24(pb, flv->reserved); + + if (par->codec_type == AVMEDIA_TYPE_DATA || + par->codec_type == AVMEDIA_TYPE_SUBTITLE ) { + int data_size; + int64_t metadata_size_pos = avio_tell(pb); + if (par->codec_id == AV_CODEC_ID_TEXT) { + avio_w8(pb, AMF_DATA_TYPE_STRING); + put_amf_string(pb, ""onTextData""); + avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY); + avio_wb32(pb, 2); + put_amf_string(pb, ""type""); + avio_w8(pb, AMF_DATA_TYPE_STRING); + put_amf_string(pb, ""Text""); + put_amf_string(pb, ""text""); + avio_w8(pb, AMF_DATA_TYPE_STRING); + put_amf_string(pb, pkt->data); + put_amf_string(pb, """"); + avio_w8(pb, AMF_END_OF_OBJECT); + } else { + avio_write(pb, data ? data : pkt->data, size); + } + /* write total size of tag */ + data_size = avio_tell(pb) - metadata_size_pos; + avio_seek(pb, metadata_size_pos - 10, SEEK_SET); + avio_wb24(pb, data_size); + avio_seek(pb, data_size + 10 - 3, SEEK_CUR); + avio_wb32(pb, data_size + 11); + } else { + av_assert1(flags>=0); + avio_w8(pb,flags); + if (par->codec_id == AV_CODEC_ID_VP6) + avio_w8(pb,0); + if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A) { + if (par->extradata_size) + avio_w8(pb, par->extradata[0]); + else + avio_w8(pb, ((FFALIGN(par->width, 16) - par->width) << 4) | + (FFALIGN(par->height, 16) - par->height)); + } else if (par->codec_id == AV_CODEC_ID_AAC) + avio_w8(pb, 1); // AAC raw + else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) { + avio_w8(pb, 1); // AVC NALU + avio_wb24(pb, pkt->pts - pkt->dts); + } + + avio_write(pb, data ? data : pkt->data, size); + + avio_wb32(pb, size + flags_size + 11); // previous tag size + flv->duration = FFMAX(flv->duration, + pkt->pts + flv->delay + pkt->duration); + } + + if (flv->flags & FLV_ADD_KEYFRAME_INDEX) { + switch (par->codec_type) { + case AVMEDIA_TYPE_VIDEO: + flv->videosize += (avio_tell(pb) - cur_offset); + flv->lasttimestamp = flv->acurframeindex / flv->framerate; + if (pkt->flags & AV_PKT_FLAG_KEY) { + double ts = flv->acurframeindex / flv->framerate; + int64_t pos = cur_offset; + + flv->lastkeyframetimestamp = flv->acurframeindex / flv->framerate; + flv->lastkeyframelocation = pos; + flv_append_keyframe_info(s, flv, ts, pos); + } + flv->acurframeindex++; + break; + + case AVMEDIA_TYPE_AUDIO: + flv->audiosize += (avio_tell(pb) - cur_offset); + break; + + default: + av_log(s, AV_LOG_WARNING, ""par->codec_type is type = [%d]\n"", par->codec_type); + break; + } + } + + av_free(data); + + return pb->error; +} +",1,"static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + AVIOContext *pb = s->pb; + AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar; + FLVContext *flv = s->priv_data; + FLVStreamContext *sc = s->streams[pkt->stream_index]->priv_data; + unsigned ts; + int size = pkt->size; + uint8_t *data = NULL; + int flags = -1, flags_size, ret; + int64_t cur_offset = avio_tell(pb); + + if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) { + av_log(s, AV_LOG_WARNING, ""Empty audio Packet\n""); + return AVERROR(EINVAL); + } + + if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || + par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) + flags_size = 2; + else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) + flags_size = 5; + else + flags_size = 1; + + if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 + || par->codec_id == AV_CODEC_ID_MPEG4) { + int side_size = 0; + uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); + if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) { + av_free(par->extradata); + par->extradata = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!par->extradata) { + par->extradata_size = 0; + return AVERROR(ENOMEM); + } + memcpy(par->extradata, side, side_size); + par->extradata_size = side_size; + flv_write_codec_header(s, par, pkt->dts); + } + } + + if (flv->delay == AV_NOPTS_VALUE) + flv->delay = -pkt->dts; + + if (pkt->dts < -flv->delay) { + av_log(s, AV_LOG_WARNING, + ""Packets are not in the proper order with respect to DTS\n""); + return AVERROR(EINVAL); + } + + ts = pkt->dts; + + if (s->event_flags & AVSTREAM_EVENT_FLAG_METADATA_UPDATED) { + write_metadata(s, ts); + s->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED; + } + + avio_write_marker(pb, av_rescale(ts, AV_TIME_BASE, 1000), + pkt->flags & AV_PKT_FLAG_KEY && (flv->video_par ? par->codec_type == AVMEDIA_TYPE_VIDEO : 1) ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT); + + switch (par->codec_type) { + case AVMEDIA_TYPE_VIDEO: + avio_w8(pb, FLV_TAG_TYPE_VIDEO); + + flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id); + + flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER; + break; + case AVMEDIA_TYPE_AUDIO: + flags = get_audio_flags(s, par); + + av_assert0(size); + + avio_w8(pb, FLV_TAG_TYPE_AUDIO); + break; + case AVMEDIA_TYPE_SUBTITLE: + case AVMEDIA_TYPE_DATA: + avio_w8(pb, FLV_TAG_TYPE_META); + break; + default: + return AVERROR(EINVAL); + } + + if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) { + /* check if extradata looks like mp4 formatted */ + if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1) + if ((ret = ff_avc_parse_nal_units_buf(pkt->data, &data, &size)) < 0) + return ret; + } else if (par->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && + (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { + if (!s->streams[pkt->stream_index]->nb_frames) { + av_log(s, AV_LOG_ERROR, ""Malformed AAC bitstream detected: "" + ""use the audio bitstream filter 'aac_adtstoasc' to fix it "" + ""('-bsf:a aac_adtstoasc' option with ffmpeg)\n""); + return AVERROR_INVALIDDATA; + } + av_log(s, AV_LOG_WARNING, ""aac bitstream error\n""); + } + + /* check Speex packet duration */ + if (par->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160) + av_log(s, AV_LOG_WARNING, ""Warning: Speex stream has more than "" + ""8 frames per packet. Adobe Flash "" + ""Player cannot handle this!\n""); + + if (sc->last_ts < ts) + sc->last_ts = ts; + + if (size + flags_size >= 1<<24) { + av_log(s, AV_LOG_ERROR, ""Too large packet with size %u >= %u\n"", + size + flags_size, 1<<24); + return AVERROR(EINVAL); + } + + avio_wb24(pb, size + flags_size); + put_timestamp(pb, ts); + avio_wb24(pb, flv->reserved); + + if (par->codec_type == AVMEDIA_TYPE_DATA || + par->codec_type == AVMEDIA_TYPE_SUBTITLE ) { + int data_size; + int64_t metadata_size_pos = avio_tell(pb); + if (par->codec_id == AV_CODEC_ID_TEXT) { + avio_w8(pb, AMF_DATA_TYPE_STRING); + put_amf_string(pb, ""onTextData""); + avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY); + avio_wb32(pb, 2); + put_amf_string(pb, ""type""); + avio_w8(pb, AMF_DATA_TYPE_STRING); + put_amf_string(pb, ""Text""); + put_amf_string(pb, ""text""); + avio_w8(pb, AMF_DATA_TYPE_STRING); + put_amf_string(pb, pkt->data); + put_amf_string(pb, """"); + avio_w8(pb, AMF_END_OF_OBJECT); + } else { + avio_write(pb, data ? data : pkt->data, size); + } + /* write total size of tag */ + data_size = avio_tell(pb) - metadata_size_pos; + avio_seek(pb, metadata_size_pos - 10, SEEK_SET); + avio_wb24(pb, data_size); + avio_seek(pb, data_size + 10 - 3, SEEK_CUR); + avio_wb32(pb, data_size + 11); + } else { + av_assert1(flags>=0); + avio_w8(pb,flags); + if (par->codec_id == AV_CODEC_ID_VP6) + avio_w8(pb,0); + if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A) { + if (par->extradata_size) + avio_w8(pb, par->extradata[0]); + else + avio_w8(pb, ((FFALIGN(par->width, 16) - par->width) << 4) | + (FFALIGN(par->height, 16) - par->height)); + } else if (par->codec_id == AV_CODEC_ID_AAC) + avio_w8(pb, 1); // AAC raw + else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) { + avio_w8(pb, 1); // AVC NALU + avio_wb24(pb, pkt->pts - pkt->dts); + } + + avio_write(pb, data ? data : pkt->data, size); + + avio_wb32(pb, size + flags_size + 11); // previous tag size + flv->duration = FFMAX(flv->duration, + pkt->pts + flv->delay + pkt->duration); + } + + if (flv->flags & FLV_ADD_KEYFRAME_INDEX) { + switch (par->codec_type) { + case AVMEDIA_TYPE_VIDEO: + flv->videosize += (avio_tell(pb) - cur_offset); + flv->lasttimestamp = flv->acurframeindex / flv->framerate; + if (pkt->flags & AV_PKT_FLAG_KEY) { + double ts = flv->acurframeindex / flv->framerate; + int64_t pos = cur_offset; + + flv->lastkeyframetimestamp = flv->acurframeindex / flv->framerate; + flv->lastkeyframelocation = pos; + flv_append_keyframe_info(s, flv, ts, pos); + } + flv->acurframeindex++; + break; + + case AVMEDIA_TYPE_AUDIO: + flv->audiosize += (avio_tell(pb) - cur_offset); + break; + + default: + av_log(s, AV_LOG_WARNING, ""par->codec_type is type = [%d]\n"", par->codec_type); + break; + } + } + + av_free(data); + + return pb->error; +} +","@@ -883,6 +883,11 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) + int flags = -1, flags_size, ret; + int64_t cur_offset = avio_tell(pb); + ++ if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) { ++ av_log(s, AV_LOG_WARNING, ""Empty audio Packet\n""); ++ return AVERROR(EINVAL); ++ } ++ + if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || + par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) + flags_size = 2;",2097,2333,4096 +8344,"vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, + VipsSaveable saveable, VipsBandFormat *format, VipsCoding *coding, + VipsArrayDouble *background ) +{ + /* in holds a reference to the output of our chain as we build it. + */ + g_object_ref( in ); + + /* For coded images, can this class save the coding we are in now? + * Nothing to do. + */ + if( in->Coding != VIPS_CODING_NONE && + coding[in->Coding] ) { + *ready = in; + return( 0 ); + } + + /* For uncoded images, if this saver supports ANY bands and this + * format we have nothing to do. + */ + if( in->Coding == VIPS_CODING_NONE && + saveable == VIPS_SAVEABLE_ANY && + format[in->BandFmt] == in->BandFmt ) { + *ready = in; + return( 0 ); + } + + /* Otherwise ... we need to decode and then (possibly) recode at the + * end. + */ + + /* If this is an VIPS_CODING_LABQ, we can go straight to RGB. + */ + if( in->Coding == VIPS_CODING_LABQ ) { + VipsImage *out; + + if( vips_LabQ2sRGB( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* If this is an VIPS_CODING_RAD, we unpack to float. This could be + * scRGB or XYZ. + */ + if( in->Coding == VIPS_CODING_RAD ) { + VipsImage *out; + + if( vips_rad2float( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* If the saver supports RAD, we need to go to scRGB or XYZ. + */ + if( coding[VIPS_CODING_RAD] ) { + if( in->Type != VIPS_INTERPRETATION_scRGB && + in->Type != VIPS_INTERPRETATION_XYZ ) { + VipsImage *out; + + if( vips_colourspace( in, &out, + VIPS_INTERPRETATION_scRGB, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + } + + /* If this image is CMYK and the saver is RGB-only, use lcms to try to + * import to XYZ. This will only work if the image has an embedded + * profile. + */ + if( in->Type == VIPS_INTERPRETATION_CMYK && + in->Bands >= 4 && + (saveable == VIPS_SAVEABLE_RGB || + saveable == VIPS_SAVEABLE_RGBA || + saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { + VipsImage *out; + + if( vips_icc_import( in, &out, + ""pcs"", VIPS_PCS_XYZ, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + + /* We've imported to PCS, we must remove the embedded profile, + * since it no longer matches the image. + * + * For example, when converting CMYK JPG to RGB PNG, we need + * to remove the CMYK profile on import, or the png writer will + * try to attach it when we write the image as RGB. + */ + vips_image_remove( in, VIPS_META_ICC_NAME ); + } + + /* If this is something other than CMYK or RAD, eg. maybe a LAB image, + * we need to transform to RGB. + */ + if( !coding[VIPS_CODING_RAD] && + in->Bands >= 3 && + in->Type != VIPS_INTERPRETATION_CMYK && + vips_colourspace_issupported( in ) && + (saveable == VIPS_SAVEABLE_RGB || + saveable == VIPS_SAVEABLE_RGBA || + saveable == VIPS_SAVEABLE_RGBA_ONLY || + saveable == VIPS_SAVEABLE_RGB_CMYK) ) { + VipsImage *out; + VipsInterpretation interpretation; + + /* Do we make RGB or RGB16? We don't want to squash a 16-bit + * RGB down to 8 bits if the saver supports 16. + */ + if( vips_band_format_is8bit( format[in->BandFmt] ) ) + interpretation = VIPS_INTERPRETATION_sRGB; + else + interpretation = VIPS_INTERPRETATION_RGB16; + + if( vips_colourspace( in, &out, interpretation, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* VIPS_SAVEABLE_RGBA_ONLY does not support 1 or 2 bands ... convert + * to sRGB. + */ + if( !coding[VIPS_CODING_RAD] && + in->Bands < 3 && + vips_colourspace_issupported( in ) && + saveable == VIPS_SAVEABLE_RGBA_ONLY ) { + VipsImage *out; + VipsInterpretation interpretation; + + /* Do we make RGB or RGB16? We don't want to squash a 16-bit + * RGB down to 8 bits if the saver supports 16. + */ + if( vips_band_format_is8bit( format[in->BandFmt] ) ) + interpretation = VIPS_INTERPRETATION_sRGB; + else + interpretation = VIPS_INTERPRETATION_RGB16; + + if( vips_colourspace( in, &out, interpretation, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Get the bands right. We must do this after all colourspace + * transforms, since they can change the number of bands. + */ + if( in->Coding == VIPS_CODING_NONE ) { + /* Do we need to flatten out an alpha channel? There needs to + * be an alpha there now, and this writer needs to not support + * alpha. + */ + if( (in->Bands == 2 || + (in->Bands == 4 && + in->Type != VIPS_INTERPRETATION_CMYK)) && + (saveable == VIPS_SAVEABLE_MONO || + saveable == VIPS_SAVEABLE_RGB || + saveable == VIPS_SAVEABLE_RGB_CMYK) ) { + VipsImage *out; + + if( vips_flatten( in, &out, + ""background"", background, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Other alpha removal strategies ... just drop the extra + * bands. + */ + + else if( in->Bands > 3 && + (saveable == VIPS_SAVEABLE_RGB || + (saveable == VIPS_SAVEABLE_RGB_CMYK && + in->Type != VIPS_INTERPRETATION_CMYK)) ) { + VipsImage *out; + + /* Don't let 4 bands though unless the image really is + * a CMYK. + * + * Consider a RGBA png being saved as JPG. We can + * write CMYK jpg, but we mustn't do that for RGBA + * images. + */ + if( vips_extract_band( in, &out, 0, + ""n"", 3, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else if( in->Bands > 4 && + ((saveable == VIPS_SAVEABLE_RGB_CMYK && + in->Type == VIPS_INTERPRETATION_CMYK) || + saveable == VIPS_SAVEABLE_RGBA || + saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { + VipsImage *out; + + if( vips_extract_band( in, &out, 0, + ""n"", 4, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else if( in->Bands > 1 && + saveable == VIPS_SAVEABLE_MONO ) { + VipsImage *out; + + if( vips_extract_band( in, &out, 0, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Else we have VIPS_SAVEABLE_ANY and we don't chop bands down. + */ + } + + /* Handle the ushort interpretations. + * + * RGB16 and GREY16 use 0-65535 for black-white. If we have an image + * tagged like this, and it has more than 8 bits (we leave crazy uchar + * images tagged as RGB16 alone), we'll need to get it ready for the + * saver. + */ + if( (in->Type == VIPS_INTERPRETATION_RGB16 || + in->Type == VIPS_INTERPRETATION_GREY16) && + !vips_band_format_is8bit( in->BandFmt ) ) { + /* If the saver supports ushort, cast to ushort. It may be + * float at the moment, for example. + * + * If the saver does not support ushort, automatically shift + * it down. This is the behaviour we want for saving an RGB16 + * image as JPG, for example. + */ + if( format[VIPS_FORMAT_USHORT] == VIPS_FORMAT_USHORT ) { + VipsImage *out; + + if( vips_cast( in, &out, VIPS_FORMAT_USHORT, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else { + VipsImage *out; + + if( vips_rshift_const1( in, &out, 8, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + + /* That could have produced an int image ... make sure + * we are now uchar. + */ + if( vips_cast( in, &out, VIPS_FORMAT_UCHAR, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + } + + /* Cast to the output format. + */ + { + VipsImage *out; + + if( vips_cast( in, &out, format[in->BandFmt], NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Does this class want a coded image? Search the coding table for the + * first one. + */ + if( coding[VIPS_CODING_NONE] ) { + /* Already NONE, nothing to do. + */ + } + else if( coding[VIPS_CODING_LABQ] ) { + VipsImage *out; + + if( vips_Lab2LabQ( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else if( coding[VIPS_CODING_RAD] ) { + VipsImage *out; + + if( vips_float2rad( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + *ready = in; + + return( 0 ); +} +",0,"vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready, + VipsSaveable saveable, VipsBandFormat *format, VipsCoding *coding, + VipsArrayDouble *background ) +{ + /* in holds a reference to the output of our chain as we build it. + */ + g_object_ref( in ); + + /* For coded images, can this class save the coding we are in now? + * Nothing to do. + */ + if( in->Coding != VIPS_CODING_NONE && + coding[in->Coding] ) { + *ready = in; + return( 0 ); + } + + /* For uncoded images, if this saver supports ANY bands and this + * format we have nothing to do. + */ + if( in->Coding == VIPS_CODING_NONE && + saveable == VIPS_SAVEABLE_ANY && + format[in->BandFmt] == in->BandFmt ) { + *ready = in; + return( 0 ); + } + + /* Otherwise ... we need to decode and then (possibly) recode at the + * end. + */ + + /* If this is an VIPS_CODING_LABQ, we can go straight to RGB. + */ + if( in->Coding == VIPS_CODING_LABQ ) { + VipsImage *out; + + if( vips_LabQ2sRGB( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* If this is an VIPS_CODING_RAD, we unpack to float. This could be + * scRGB or XYZ. + */ + if( in->Coding == VIPS_CODING_RAD ) { + VipsImage *out; + + if( vips_rad2float( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* If the saver supports RAD, we need to go to scRGB or XYZ. + */ + if( coding[VIPS_CODING_RAD] ) { + if( in->Type != VIPS_INTERPRETATION_scRGB && + in->Type != VIPS_INTERPRETATION_XYZ ) { + VipsImage *out; + + if( vips_colourspace( in, &out, + VIPS_INTERPRETATION_scRGB, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + } + + /* If this image is CMYK and the saver is RGB-only, use lcms to try to + * import to XYZ. This will only work if the image has an embedded + * profile. + */ + if( in->Type == VIPS_INTERPRETATION_CMYK && + in->Bands >= 4 && + (saveable == VIPS_SAVEABLE_RGB || + saveable == VIPS_SAVEABLE_RGBA || + saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { + VipsImage *out; + + if( vips_icc_import( in, &out, + ""pcs"", VIPS_PCS_XYZ, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + + /* We've imported to PCS, we must remove the embedded profile, + * since it no longer matches the image. + * + * For example, when converting CMYK JPG to RGB PNG, we need + * to remove the CMYK profile on import, or the png writer will + * try to attach it when we write the image as RGB. + */ + vips_image_remove( in, VIPS_META_ICC_NAME ); + } + + /* If this is something other than CMYK or RAD, eg. maybe a LAB image, + * we need to transform to RGB. + */ + if( !coding[VIPS_CODING_RAD] && + in->Bands >= 3 && + in->Type != VIPS_INTERPRETATION_CMYK && + vips_colourspace_issupported( in ) && + (saveable == VIPS_SAVEABLE_RGB || + saveable == VIPS_SAVEABLE_RGBA || + saveable == VIPS_SAVEABLE_RGBA_ONLY || + saveable == VIPS_SAVEABLE_RGB_CMYK) ) { + VipsImage *out; + VipsInterpretation interpretation; + + /* Do we make RGB or RGB16? We don't want to squash a 16-bit + * RGB down to 8 bits if the saver supports 16. + */ + if( vips_band_format_is8bit( format[in->BandFmt] ) ) + interpretation = VIPS_INTERPRETATION_sRGB; + else + interpretation = VIPS_INTERPRETATION_RGB16; + + if( vips_colourspace( in, &out, interpretation, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* VIPS_SAVEABLE_RGBA_ONLY does not support 1 or 2 bands ... convert + * to sRGB. + */ + if( !coding[VIPS_CODING_RAD] && + in->Bands < 3 && + vips_colourspace_issupported( in ) && + saveable == VIPS_SAVEABLE_RGBA_ONLY ) { + VipsImage *out; + VipsInterpretation interpretation; + + /* Do we make RGB or RGB16? We don't want to squash a 16-bit + * RGB down to 8 bits if the saver supports 16. + */ + if( vips_band_format_is8bit( format[in->BandFmt] ) ) + interpretation = VIPS_INTERPRETATION_sRGB; + else + interpretation = VIPS_INTERPRETATION_RGB16; + + if( vips_colourspace( in, &out, interpretation, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Get the bands right. We must do this after all colourspace + * transforms, since they can change the number of bands. + */ + if( in->Coding == VIPS_CODING_NONE ) { + /* Do we need to flatten out an alpha channel? There needs to + * be an alpha there now, and this writer needs to not support + * alpha. + */ + if( (in->Bands == 2 || + (in->Bands == 4 && + in->Type != VIPS_INTERPRETATION_CMYK)) && + (saveable == VIPS_SAVEABLE_MONO || + saveable == VIPS_SAVEABLE_RGB || + saveable == VIPS_SAVEABLE_RGB_CMYK) ) { + VipsImage *out; + + if( vips_flatten( in, &out, + ""background"", background, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Other alpha removal strategies ... just drop the extra + * bands. + */ + + else if( in->Bands > 3 && + (saveable == VIPS_SAVEABLE_RGB || + (saveable == VIPS_SAVEABLE_RGB_CMYK && + in->Type != VIPS_INTERPRETATION_CMYK)) ) { + VipsImage *out; + + /* Don't let 4 bands though unless the image really is + * a CMYK. + * + * Consider a RGBA png being saved as JPG. We can + * write CMYK jpg, but we mustn't do that for RGBA + * images. + */ + if( vips_extract_band( in, &out, 0, + ""n"", 3, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else if( in->Bands > 4 && + ((saveable == VIPS_SAVEABLE_RGB_CMYK && + in->Type == VIPS_INTERPRETATION_CMYK) || + saveable == VIPS_SAVEABLE_RGBA || + saveable == VIPS_SAVEABLE_RGBA_ONLY) ) { + VipsImage *out; + + if( vips_extract_band( in, &out, 0, + ""n"", 4, + NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else if( in->Bands > 1 && + saveable == VIPS_SAVEABLE_MONO ) { + VipsImage *out; + + if( vips_extract_band( in, &out, 0, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Else we have VIPS_SAVEABLE_ANY and we don't chop bands down. + */ + } + + /* Handle the ushort interpretations. + * + * RGB16 and GREY16 use 0-65535 for black-white. If we have an image + * tagged like this, and it has more than 8 bits (we leave crazy uchar + * images tagged as RGB16 alone), we'll need to get it ready for the + * saver. + */ + if( (in->Type == VIPS_INTERPRETATION_RGB16 || + in->Type == VIPS_INTERPRETATION_GREY16) && + !vips_band_format_is8bit( in->BandFmt ) ) { + /* If the saver supports ushort, cast to ushort. It may be + * float at the moment, for example. + * + * If the saver does not support ushort, automatically shift + * it down. This is the behaviour we want for saving an RGB16 + * image as JPG, for example. + */ + if( format[VIPS_FORMAT_USHORT] == VIPS_FORMAT_USHORT ) { + VipsImage *out; + + if( vips_cast( in, &out, VIPS_FORMAT_USHORT, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else { + VipsImage *out; + + if( vips_rshift_const1( in, &out, 8, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + + /* That could have produced an int image ... make sure + * we are now uchar. + */ + if( vips_cast( in, &out, VIPS_FORMAT_UCHAR, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + } + + /* Cast to the output format. + */ + { + VipsImage *out; + + if( vips_cast( in, &out, format[in->BandFmt], NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + /* Does this class want a coded image? Search the coding table for the + * first one. + */ + if( coding[VIPS_CODING_NONE] ) { + /* Already NONE, nothing to do. + */ + } + else if( coding[VIPS_CODING_LABQ] ) { + VipsImage *out; + + if( vips_Lab2LabQ( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + else if( coding[VIPS_CODING_RAD] ) { + VipsImage *out; + + if( vips_float2rad( in, &out, NULL ) ) { + g_object_unref( in ); + return( -1 ); + } + g_object_unref( in ); + + in = out; + } + + *ready = in; + + return( 0 ); +} +","@@ -18,6 +18,8 @@ + * - transform cmyk->rgb if there's an embedded profile + * 16/6/17 + * - add page_height ++ * 5/3/18 ++ * - block _start if one start fails, see #893 + */ + + /* +@@ -796,6 +798,11 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) + VipsForeignLoad *load = VIPS_FOREIGN_LOAD( b ); + VipsForeignLoadClass *class = VIPS_FOREIGN_LOAD_GET_CLASS( load ); + ++ /* If this start has failed before in another thread, we can fail now. ++ */ ++ if( load->error ) ++ return( NULL ); ++ + if( !load->real ) { + if( !(load->real = vips_foreign_load_temp( load )) ) + return( NULL ); +@@ -819,19 +826,25 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) + g_object_set_qdata( G_OBJECT( load->real ), + vips__foreign_load_operation, load ); + +- if( class->load( load ) || +- vips_image_pio_input( load->real ) ) +- return( NULL ); +- +- /* ->header() read the header into @out, load has read the ++ /* Load the image and check the result. ++ * ++ * ->header() read the header into @out, load has read the + * image into @real. They must match exactly in size, bands, + * format and coding for the copy to work. + * + * Some versions of ImageMagick give different results between + * Ping and Load for some formats, for example. ++ * ++ * If the load fails, we need to stop + */ +- if( !vips_foreign_load_iscompat( load->real, out ) ) ++ if( class->load( load ) || ++ vips_image_pio_input( load->real ) || ++ vips_foreign_load_iscompat( load->real, out ) ) { ++ vips_operation_invalidate( VIPS_OPERATION( load ) ); ++ load->error = TRUE; ++ + return( NULL ); ++ } + + /* We have to tell vips that out depends on real. We've set + * the demand hint below, but not given an input there.",2721,2957,4096 +18247,"kadm5_create_principal_3(void *server_handle, + kadm5_principal_ent_t entry, long mask, + int n_ks_tuple, krb5_key_salt_tuple *ks_tuple, + char *password) +{ + krb5_db_entry *kdb; + osa_princ_ent_rec adb; + kadm5_policy_ent_rec polent; + krb5_boolean have_polent = FALSE; + krb5_timestamp now; + krb5_tl_data *tl_data_tail; + unsigned int ret; + kadm5_server_handle_t handle = server_handle; + krb5_keyblock *act_mkey; + krb5_kvno act_kvno; + int new_n_ks_tuple = 0; + krb5_key_salt_tuple *new_ks_tuple = NULL; + + CHECK_HANDLE(server_handle); + + krb5_clear_error_message(handle->context); + + check_1_6_dummy(entry, mask, n_ks_tuple, ks_tuple, &password); + + /* + * Argument sanity checking, and opening up the DB + */ + if (entry == NULL) + return EINVAL; + if(!(mask & KADM5_PRINCIPAL) || (mask & KADM5_MOD_NAME) || + (mask & KADM5_MOD_TIME) || (mask & KADM5_LAST_PWD_CHANGE) || + (mask & KADM5_MKVNO) || (mask & KADM5_AUX_ATTRIBUTES) || + (mask & KADM5_LAST_SUCCESS) || (mask & KADM5_LAST_FAILED) || + (mask & KADM5_FAIL_AUTH_COUNT)) + return KADM5_BAD_MASK; + if ((mask & KADM5_KEY_DATA) && entry->n_key_data != 0) + return KADM5_BAD_MASK; + if((mask & KADM5_POLICY) && entry->policy == NULL) + return KADM5_BAD_MASK; + if((mask & KADM5_POLICY) && (mask & KADM5_POLICY_CLR)) + return KADM5_BAD_MASK; + if((mask & ~ALL_PRINC_MASK)) + return KADM5_BAD_MASK; + + /* + * Check to see if the principal exists + */ + ret = kdb_get_entry(handle, entry->principal, &kdb, &adb); + + switch(ret) { + case KADM5_UNK_PRINC: + break; + case 0: + kdb_free_entry(handle, kdb, &adb); + return KADM5_DUP; + default: + return ret; + } + + kdb = calloc(1, sizeof(*kdb)); + if (kdb == NULL) + return ENOMEM; + memset(&adb, 0, sizeof(osa_princ_ent_rec)); + + /* + * If a policy was specified, load it. + * If we can not find the one specified return an error + */ + if ((mask & KADM5_POLICY)) { + ret = get_policy(handle, entry->policy, &polent, &have_polent); + if (ret) + goto cleanup; + } + if (password) { + ret = passwd_check(handle, password, have_polent ? &polent : NULL, + entry->principal); + if (ret) + goto cleanup; + } + /* + * Start populating the various DB fields, using the + * ""defaults"" for fields that were not specified by the + * mask. + */ + if ((ret = krb5_timeofday(handle->context, &now))) + goto cleanup; + + kdb->magic = KRB5_KDB_MAGIC_NUMBER; + kdb->len = KRB5_KDB_V1_BASE_LENGTH; /* gag me with a chainsaw */ + + if ((mask & KADM5_ATTRIBUTES)) + kdb->attributes = entry->attributes; + else + kdb->attributes = handle->params.flags; + + if ((mask & KADM5_MAX_LIFE)) + kdb->max_life = entry->max_life; + else + kdb->max_life = handle->params.max_life; + + if (mask & KADM5_MAX_RLIFE) + kdb->max_renewable_life = entry->max_renewable_life; + else + kdb->max_renewable_life = handle->params.max_rlife; + + if ((mask & KADM5_PRINC_EXPIRE_TIME)) + kdb->expiration = entry->princ_expire_time; + else + kdb->expiration = handle->params.expiration; + + kdb->pw_expiration = 0; + if (have_polent) { + if(polent.pw_max_life) + kdb->pw_expiration = ts_incr(now, polent.pw_max_life); + else + kdb->pw_expiration = 0; + } + if ((mask & KADM5_PW_EXPIRATION)) + kdb->pw_expiration = entry->pw_expiration; + + kdb->last_success = 0; + kdb->last_failed = 0; + kdb->fail_auth_count = 0; + + /* this is kind of gross, but in order to free the tl data, I need + to free the entire kdb entry, and that will try to free the + principal. */ + + ret = krb5_copy_principal(handle->context, entry->principal, &kdb->princ); + if (ret) + goto cleanup; + + if ((ret = krb5_dbe_update_last_pwd_change(handle->context, kdb, now))) + goto cleanup; + + if (mask & KADM5_TL_DATA) { + /* splice entry->tl_data onto the front of kdb->tl_data */ + for (tl_data_tail = entry->tl_data; tl_data_tail; + tl_data_tail = tl_data_tail->tl_data_next) + { + ret = krb5_dbe_update_tl_data(handle->context, kdb, tl_data_tail); + if( ret ) + goto cleanup; + } + } + + /* + * We need to have setup the TL data, so we have strings, so we can + * check enctype policy, which is why we check/initialize ks_tuple + * this late. + */ + ret = apply_keysalt_policy(handle, entry->policy, n_ks_tuple, ks_tuple, + &new_n_ks_tuple, &new_ks_tuple); + if (ret) + goto cleanup; + + /* initialize the keys */ + + ret = kdb_get_active_mkey(handle, &act_kvno, &act_mkey); + if (ret) + goto cleanup; + + if (mask & KADM5_KEY_DATA) { + /* The client requested no keys for this principal. */ + assert(entry->n_key_data == 0); + } else if (password) { + ret = krb5_dbe_cpw(handle->context, act_mkey, new_ks_tuple, + new_n_ks_tuple, password, + (mask & KADM5_KVNO)?entry->kvno:1, + FALSE, kdb); + } else { + /* Null password means create with random key (new in 1.8). */ + ret = krb5_dbe_crk(handle->context, &master_keyblock, + new_ks_tuple, new_n_ks_tuple, FALSE, kdb); + } + if (ret) + goto cleanup; + + /* Record the master key VNO used to encrypt this entry's keys */ + ret = krb5_dbe_update_mkvno(handle->context, kdb, act_kvno); + if (ret) + goto cleanup; + + ret = k5_kadm5_hook_create(handle->context, handle->hook_handles, + KADM5_HOOK_STAGE_PRECOMMIT, entry, mask, + new_n_ks_tuple, new_ks_tuple, password); + if (ret) + goto cleanup; + + /* populate the admin-server-specific fields. In the OV server, + this used to be in a separate database. Since there's already + marshalling code for the admin fields, to keep things simple, + I'm going to keep it, and make all the admin stuff occupy a + single tl_data record, */ + + adb.admin_history_kvno = INITIAL_HIST_KVNO; + if (mask & KADM5_POLICY) { + adb.aux_attributes = KADM5_POLICY; + + /* this does *not* need to be strdup'ed, because adb is xdr */ + /* encoded in osa_adb_create_princ, and not ever freed */ + + adb.policy = entry->policy; + } + + /* In all cases key and the principal data is set, let the database provider know */ + kdb->mask = mask | KADM5_KEY_DATA | KADM5_PRINCIPAL ; + + /* store the new db entry */ + ret = kdb_put_entry(handle, kdb, &adb); + + (void) k5_kadm5_hook_create(handle->context, handle->hook_handles, + KADM5_HOOK_STAGE_POSTCOMMIT, entry, mask, + new_n_ks_tuple, new_ks_tuple, password); + +cleanup: + free(new_ks_tuple); + krb5_db_free_principal(handle->context, kdb); + if (have_polent) + (void) kadm5_free_policy_ent(handle->lhandle, &polent); + return ret; +} +",1,"kadm5_create_principal_3(void *server_handle, + kadm5_principal_ent_t entry, long mask, + int n_ks_tuple, krb5_key_salt_tuple *ks_tuple, + char *password) +{ + krb5_db_entry *kdb; + osa_princ_ent_rec adb; + kadm5_policy_ent_rec polent; + krb5_boolean have_polent = FALSE; + krb5_timestamp now; + krb5_tl_data *tl_data_tail; + unsigned int ret; + kadm5_server_handle_t handle = server_handle; + krb5_keyblock *act_mkey; + krb5_kvno act_kvno; + int new_n_ks_tuple = 0; + krb5_key_salt_tuple *new_ks_tuple = NULL; + + CHECK_HANDLE(server_handle); + + krb5_clear_error_message(handle->context); + + check_1_6_dummy(entry, mask, n_ks_tuple, ks_tuple, &password); + + /* + * Argument sanity checking, and opening up the DB + */ + if (entry == NULL) + return EINVAL; + if(!(mask & KADM5_PRINCIPAL) || (mask & KADM5_MOD_NAME) || + (mask & KADM5_MOD_TIME) || (mask & KADM5_LAST_PWD_CHANGE) || + (mask & KADM5_MKVNO) || (mask & KADM5_AUX_ATTRIBUTES) || + (mask & KADM5_LAST_SUCCESS) || (mask & KADM5_LAST_FAILED) || + (mask & KADM5_FAIL_AUTH_COUNT)) + return KADM5_BAD_MASK; + if ((mask & KADM5_KEY_DATA) && entry->n_key_data != 0) + return KADM5_BAD_MASK; + if((mask & KADM5_POLICY) && entry->policy == NULL) + return KADM5_BAD_MASK; + if((mask & KADM5_POLICY) && (mask & KADM5_POLICY_CLR)) + return KADM5_BAD_MASK; + if((mask & ~ALL_PRINC_MASK)) + return KADM5_BAD_MASK; + if (mask & KADM5_TL_DATA) { + for (tl_data_tail = entry->tl_data; tl_data_tail != NULL; + tl_data_tail = tl_data_tail->tl_data_next) { + if (tl_data_tail->tl_data_type < 256) + return KADM5_BAD_TL_TYPE; + } + } + + /* + * Check to see if the principal exists + */ + ret = kdb_get_entry(handle, entry->principal, &kdb, &adb); + + switch(ret) { + case KADM5_UNK_PRINC: + break; + case 0: + kdb_free_entry(handle, kdb, &adb); + return KADM5_DUP; + default: + return ret; + } + + kdb = calloc(1, sizeof(*kdb)); + if (kdb == NULL) + return ENOMEM; + memset(&adb, 0, sizeof(osa_princ_ent_rec)); + + /* + * If a policy was specified, load it. + * If we can not find the one specified return an error + */ + if ((mask & KADM5_POLICY)) { + ret = get_policy(handle, entry->policy, &polent, &have_polent); + if (ret) + goto cleanup; + } + if (password) { + ret = passwd_check(handle, password, have_polent ? &polent : NULL, + entry->principal); + if (ret) + goto cleanup; + } + /* + * Start populating the various DB fields, using the + * ""defaults"" for fields that were not specified by the + * mask. + */ + if ((ret = krb5_timeofday(handle->context, &now))) + goto cleanup; + + kdb->magic = KRB5_KDB_MAGIC_NUMBER; + kdb->len = KRB5_KDB_V1_BASE_LENGTH; /* gag me with a chainsaw */ + + if ((mask & KADM5_ATTRIBUTES)) + kdb->attributes = entry->attributes; + else + kdb->attributes = handle->params.flags; + + if ((mask & KADM5_MAX_LIFE)) + kdb->max_life = entry->max_life; + else + kdb->max_life = handle->params.max_life; + + if (mask & KADM5_MAX_RLIFE) + kdb->max_renewable_life = entry->max_renewable_life; + else + kdb->max_renewable_life = handle->params.max_rlife; + + if ((mask & KADM5_PRINC_EXPIRE_TIME)) + kdb->expiration = entry->princ_expire_time; + else + kdb->expiration = handle->params.expiration; + + kdb->pw_expiration = 0; + if (have_polent) { + if(polent.pw_max_life) + kdb->pw_expiration = ts_incr(now, polent.pw_max_life); + else + kdb->pw_expiration = 0; + } + if ((mask & KADM5_PW_EXPIRATION)) + kdb->pw_expiration = entry->pw_expiration; + + kdb->last_success = 0; + kdb->last_failed = 0; + kdb->fail_auth_count = 0; + + /* this is kind of gross, but in order to free the tl data, I need + to free the entire kdb entry, and that will try to free the + principal. */ + + ret = krb5_copy_principal(handle->context, entry->principal, &kdb->princ); + if (ret) + goto cleanup; + + if ((ret = krb5_dbe_update_last_pwd_change(handle->context, kdb, now))) + goto cleanup; + + if (mask & KADM5_TL_DATA) { + /* splice entry->tl_data onto the front of kdb->tl_data */ + for (tl_data_tail = entry->tl_data; tl_data_tail; + tl_data_tail = tl_data_tail->tl_data_next) + { + ret = krb5_dbe_update_tl_data(handle->context, kdb, tl_data_tail); + if( ret ) + goto cleanup; + } + } + + /* + * We need to have setup the TL data, so we have strings, so we can + * check enctype policy, which is why we check/initialize ks_tuple + * this late. + */ + ret = apply_keysalt_policy(handle, entry->policy, n_ks_tuple, ks_tuple, + &new_n_ks_tuple, &new_ks_tuple); + if (ret) + goto cleanup; + + /* initialize the keys */ + + ret = kdb_get_active_mkey(handle, &act_kvno, &act_mkey); + if (ret) + goto cleanup; + + if (mask & KADM5_KEY_DATA) { + /* The client requested no keys for this principal. */ + assert(entry->n_key_data == 0); + } else if (password) { + ret = krb5_dbe_cpw(handle->context, act_mkey, new_ks_tuple, + new_n_ks_tuple, password, + (mask & KADM5_KVNO)?entry->kvno:1, + FALSE, kdb); + } else { + /* Null password means create with random key (new in 1.8). */ + ret = krb5_dbe_crk(handle->context, &master_keyblock, + new_ks_tuple, new_n_ks_tuple, FALSE, kdb); + } + if (ret) + goto cleanup; + + /* Record the master key VNO used to encrypt this entry's keys */ + ret = krb5_dbe_update_mkvno(handle->context, kdb, act_kvno); + if (ret) + goto cleanup; + + ret = k5_kadm5_hook_create(handle->context, handle->hook_handles, + KADM5_HOOK_STAGE_PRECOMMIT, entry, mask, + new_n_ks_tuple, new_ks_tuple, password); + if (ret) + goto cleanup; + + /* populate the admin-server-specific fields. In the OV server, + this used to be in a separate database. Since there's already + marshalling code for the admin fields, to keep things simple, + I'm going to keep it, and make all the admin stuff occupy a + single tl_data record, */ + + adb.admin_history_kvno = INITIAL_HIST_KVNO; + if (mask & KADM5_POLICY) { + adb.aux_attributes = KADM5_POLICY; + + /* this does *not* need to be strdup'ed, because adb is xdr */ + /* encoded in osa_adb_create_princ, and not ever freed */ + + adb.policy = entry->policy; + } + + /* In all cases key and the principal data is set, let the database provider know */ + kdb->mask = mask | KADM5_KEY_DATA | KADM5_PRINCIPAL ; + + /* store the new db entry */ + ret = kdb_put_entry(handle, kdb, &adb); + + (void) k5_kadm5_hook_create(handle->context, handle->hook_handles, + KADM5_HOOK_STAGE_POSTCOMMIT, entry, mask, + new_n_ks_tuple, new_ks_tuple, password); + +cleanup: + free(new_ks_tuple); + krb5_db_free_principal(handle->context, kdb); + if (have_polent) + (void) kadm5_free_policy_ent(handle->lhandle, &polent); + return ret; +} +","@@ -330,6 +330,13 @@ kadm5_create_principal_3(void *server_handle, + return KADM5_BAD_MASK; + if((mask & ~ALL_PRINC_MASK)) + return KADM5_BAD_MASK; ++ if (mask & KADM5_TL_DATA) { ++ for (tl_data_tail = entry->tl_data; tl_data_tail != NULL; ++ tl_data_tail = tl_data_tail->tl_data_next) { ++ if (tl_data_tail->tl_data_type < 256) ++ return KADM5_BAD_TL_TYPE; ++ } ++ } + + /* + * Check to see if the principal exists",1974,2210,4096 +5031,"static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ */ +{ + phar_zip_file_header local; + phar_zip_unix3 perms; + phar_zip_central_dir_file central; + struct _phar_zip_pass *p; + php_uint32 newcrc32; + zend_off_t offset; + int not_really_modified = 0; + p = (struct _phar_zip_pass*) arg; + + if (entry->is_mounted) { + return ZEND_HASH_APPLY_KEEP; + } + + if (entry->is_deleted) { + if (entry->fp_refcount <= 0) { + return ZEND_HASH_APPLY_REMOVE; + } else { + /* we can't delete this in-memory until it is closed */ + return ZEND_HASH_APPLY_KEEP; + } + } + + phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len); + memset(&local, 0, sizeof(local)); + memset(¢ral, 0, sizeof(central)); + memset(&perms, 0, sizeof(perms)); + strncpy(local.signature, ""PK\3\4"", 4); + strncpy(central.signature, ""PK\1\2"", 4); + PHAR_SET_16(central.extra_len, sizeof(perms)); + PHAR_SET_16(local.extra_len, sizeof(perms)); + perms.tag[0] = 'n'; + perms.tag[1] = 'u'; + PHAR_SET_16(perms.size, sizeof(perms) - 4); + PHAR_SET_16(perms.perms, entry->flags & PHAR_ENT_PERM_MASK); + { + php_uint32 crc = (php_uint32) ~0; + CRC32(crc, perms.perms[0]); + CRC32(crc, perms.perms[1]); + PHAR_SET_32(perms.crc32, ~crc); + } + + if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { + PHAR_SET_16(central.compressed, PHAR_ZIP_COMP_DEFLATE); + PHAR_SET_16(local.compressed, PHAR_ZIP_COMP_DEFLATE); + } + + if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) { + PHAR_SET_16(central.compressed, PHAR_ZIP_COMP_BZIP2); + PHAR_SET_16(local.compressed, PHAR_ZIP_COMP_BZIP2); + } + + /* do not use PHAR_GET_16 on either field of the next line */ + phar_zip_u2d_time(entry->timestamp, local.timestamp, local.datestamp); + memcpy(central.timestamp, local.timestamp, sizeof(local.timestamp)); + memcpy(central.datestamp, local.datestamp, sizeof(local.datestamp)); + PHAR_SET_16(central.filename_len, entry->filename_len + (entry->is_dir ? 1 : 0)); + PHAR_SET_16(local.filename_len, entry->filename_len + (entry->is_dir ? 1 : 0)); + PHAR_SET_32(central.offset, php_stream_tell(p->filefp)); + + /* do extra field for perms later */ + if (entry->is_modified) { + php_uint32 loc; + php_stream_filter *filter; + php_stream *efp; + + if (entry->is_dir) { + entry->is_modified = 0; + if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { + php_stream_close(entry->fp); + entry->fp = NULL; + entry->fp_type = PHAR_FP; + } + goto continue_dir; + } + + if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) { + spprintf(p->error, 0, ""unable to open file contents of file \""%s\"" in zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + /* we can be modified and already be compressed, such as when chmod() is executed */ + if (entry->flags & PHAR_ENT_COMPRESSION_MASK && (entry->old_flags == entry->flags || !entry->old_flags)) { + not_really_modified = 1; + goto is_compressed; + } + + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + spprintf(p->error, 0, ""unable to seek to start of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + efp = phar_get_efp(entry, 0); + newcrc32 = ~0; + + for (loc = 0;loc < entry->uncompressed_filesize; ++loc) { + CRC32(newcrc32, php_stream_getc(efp)); + } + + entry->crc32 = ~newcrc32; + PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize); + PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize); + + if (!(entry->flags & PHAR_ENT_COMPRESSION_MASK)) { + /* not compressed */ + entry->compressed_filesize = entry->uncompressed_filesize; + PHAR_SET_32(central.compsize, entry->uncompressed_filesize); + PHAR_SET_32(local.compsize, entry->uncompressed_filesize); + goto not_compressed; + } + + filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0); + + if (!filter) { + if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { + spprintf(p->error, 0, ""unable to gzip compress file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + } else { + spprintf(p->error, 0, ""unable to bzip2 compress file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + } + return ZEND_HASH_APPLY_STOP; + } + + /* create new file that holds the compressed version */ + /* work around inability to specify freedom in write and strictness + in read count */ + entry->cfp = php_stream_fopen_tmpfile(); + + if (!entry->cfp) { + spprintf(p->error, 0, ""unable to create temporary file for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_flush(efp); + + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + spprintf(p->error, 0, ""unable to seek to start of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_filter_append((&entry->cfp->writefilters), filter); + + if (SUCCESS != php_stream_copy_to_stream_ex(efp, entry->cfp, entry->uncompressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to copy compressed file contents of file \""%s\"" while creating new phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_filter_flush(filter, 1); + php_stream_flush(entry->cfp); + php_stream_filter_remove(filter, 1); + php_stream_seek(entry->cfp, 0, SEEK_END); + entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp); + PHAR_SET_32(central.compsize, entry->compressed_filesize); + PHAR_SET_32(local.compsize, entry->compressed_filesize); + /* generate crc on compressed file */ + php_stream_rewind(entry->cfp); + entry->old_flags = entry->flags; + entry->is_modified = 1; + } else { +is_compressed: + PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize); + PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize); + PHAR_SET_32(central.compsize, entry->compressed_filesize); + PHAR_SET_32(local.compsize, entry->compressed_filesize); + if (p->old) { + if (-1 == php_stream_seek(p->old, entry->offset_abs, SEEK_SET)) { + spprintf(p->error, 0, ""unable to seek to start of file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + } +not_compressed: + PHAR_SET_32(central.crc32, entry->crc32); + PHAR_SET_32(local.crc32, entry->crc32); +continue_dir: + /* set file metadata */ + if (Z_TYPE(entry->metadata) != IS_UNDEF) { + php_serialize_data_t metadata_hash; + + if (entry->metadata_str.s) { + smart_str_free(&entry->metadata_str); + } + entry->metadata_str.s = NULL; + PHP_VAR_SERIALIZE_INIT(metadata_hash); + php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash); + PHP_VAR_SERIALIZE_DESTROY(metadata_hash); + PHAR_SET_16(central.comment_len, ZSTR_LEN(entry->metadata_str.s)); + } + + entry->header_offset = php_stream_tell(p->filefp); + offset = entry->header_offset + sizeof(local) + entry->filename_len + (entry->is_dir ? 1 : 0) + sizeof(perms); + + if (sizeof(local) != php_stream_write(p->filefp, (char *)&local, sizeof(local))) { + spprintf(p->error, 0, ""unable to write local file header of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (sizeof(central) != php_stream_write(p->centralfp, (char *)¢ral, sizeof(central))) { + spprintf(p->error, 0, ""unable to write central directory entry for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (entry->is_dir) { + if (entry->filename_len != php_stream_write(p->filefp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to local directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (1 != php_stream_write(p->filefp, ""/"", 1)) { + spprintf(p->error, 0, ""unable to write filename to local directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (entry->filename_len != php_stream_write(p->centralfp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to central directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (1 != php_stream_write(p->centralfp, ""/"", 1)) { + spprintf(p->error, 0, ""unable to write filename to central directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } else { + if (entry->filename_len != php_stream_write(p->filefp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to local directory entry for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (entry->filename_len != php_stream_write(p->centralfp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to central directory entry for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + + if (sizeof(perms) != php_stream_write(p->filefp, (char *)&perms, sizeof(perms))) { + spprintf(p->error, 0, ""unable to write local extra permissions file header of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (sizeof(perms) != php_stream_write(p->centralfp, (char *)&perms, sizeof(perms))) { + spprintf(p->error, 0, ""unable to write central extra permissions file header of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (!not_really_modified && entry->is_modified) { + if (entry->cfp) { + if (SUCCESS != php_stream_copy_to_stream_ex(entry->cfp, p->filefp, entry->compressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to write compressed contents of file \""%s\"" in zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_close(entry->cfp); + entry->cfp = NULL; + } else { + if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) { + return ZEND_HASH_APPLY_STOP; + } + + phar_seek_efp(entry, 0, SEEK_SET, 0, 0); + + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), p->filefp, entry->uncompressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to write contents of file \""%s\"" in zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + + if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp && entry->fp_refcount == 0) { + php_stream_close(entry->fp); + } + + entry->is_modified = 0; + } else { + entry->is_modified = 0; + if (entry->fp_refcount) { + /* open file pointers refer to this fp, do not free the stream */ + switch (entry->fp_type) { + case PHAR_FP: + p->free_fp = 0; + break; + case PHAR_UFP: + p->free_ufp = 0; + default: + break; + } + } + + if (!entry->is_dir && entry->compressed_filesize && SUCCESS != php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to copy contents of file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + + entry->fp = NULL; + entry->offset = entry->offset_abs = offset; + entry->fp_type = PHAR_FP; + + if (entry->metadata_str.s) { + if (ZSTR_LEN(entry->metadata_str.s) != php_stream_write(p->centralfp, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s))) { + spprintf(p->error, 0, ""unable to write metadata as file comment for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + smart_str_free(&entry->metadata_str); + return ZEND_HASH_APPLY_STOP; + } + + smart_str_free(&entry->metadata_str); + } + + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ +",0,"static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ */ +{ + phar_zip_file_header local; + phar_zip_unix3 perms; + phar_zip_central_dir_file central; + struct _phar_zip_pass *p; + php_uint32 newcrc32; + zend_off_t offset; + int not_really_modified = 0; + p = (struct _phar_zip_pass*) arg; + + if (entry->is_mounted) { + return ZEND_HASH_APPLY_KEEP; + } + + if (entry->is_deleted) { + if (entry->fp_refcount <= 0) { + return ZEND_HASH_APPLY_REMOVE; + } else { + /* we can't delete this in-memory until it is closed */ + return ZEND_HASH_APPLY_KEEP; + } + } + + phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len); + memset(&local, 0, sizeof(local)); + memset(¢ral, 0, sizeof(central)); + memset(&perms, 0, sizeof(perms)); + strncpy(local.signature, ""PK\3\4"", 4); + strncpy(central.signature, ""PK\1\2"", 4); + PHAR_SET_16(central.extra_len, sizeof(perms)); + PHAR_SET_16(local.extra_len, sizeof(perms)); + perms.tag[0] = 'n'; + perms.tag[1] = 'u'; + PHAR_SET_16(perms.size, sizeof(perms) - 4); + PHAR_SET_16(perms.perms, entry->flags & PHAR_ENT_PERM_MASK); + { + php_uint32 crc = (php_uint32) ~0; + CRC32(crc, perms.perms[0]); + CRC32(crc, perms.perms[1]); + PHAR_SET_32(perms.crc32, ~crc); + } + + if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { + PHAR_SET_16(central.compressed, PHAR_ZIP_COMP_DEFLATE); + PHAR_SET_16(local.compressed, PHAR_ZIP_COMP_DEFLATE); + } + + if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) { + PHAR_SET_16(central.compressed, PHAR_ZIP_COMP_BZIP2); + PHAR_SET_16(local.compressed, PHAR_ZIP_COMP_BZIP2); + } + + /* do not use PHAR_GET_16 on either field of the next line */ + phar_zip_u2d_time(entry->timestamp, local.timestamp, local.datestamp); + memcpy(central.timestamp, local.timestamp, sizeof(local.timestamp)); + memcpy(central.datestamp, local.datestamp, sizeof(local.datestamp)); + PHAR_SET_16(central.filename_len, entry->filename_len + (entry->is_dir ? 1 : 0)); + PHAR_SET_16(local.filename_len, entry->filename_len + (entry->is_dir ? 1 : 0)); + PHAR_SET_32(central.offset, php_stream_tell(p->filefp)); + + /* do extra field for perms later */ + if (entry->is_modified) { + php_uint32 loc; + php_stream_filter *filter; + php_stream *efp; + + if (entry->is_dir) { + entry->is_modified = 0; + if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { + php_stream_close(entry->fp); + entry->fp = NULL; + entry->fp_type = PHAR_FP; + } + goto continue_dir; + } + + if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) { + spprintf(p->error, 0, ""unable to open file contents of file \""%s\"" in zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + /* we can be modified and already be compressed, such as when chmod() is executed */ + if (entry->flags & PHAR_ENT_COMPRESSION_MASK && (entry->old_flags == entry->flags || !entry->old_flags)) { + not_really_modified = 1; + goto is_compressed; + } + + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + spprintf(p->error, 0, ""unable to seek to start of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + efp = phar_get_efp(entry, 0); + newcrc32 = ~0; + + for (loc = 0;loc < entry->uncompressed_filesize; ++loc) { + CRC32(newcrc32, php_stream_getc(efp)); + } + + entry->crc32 = ~newcrc32; + PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize); + PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize); + + if (!(entry->flags & PHAR_ENT_COMPRESSION_MASK)) { + /* not compressed */ + entry->compressed_filesize = entry->uncompressed_filesize; + PHAR_SET_32(central.compsize, entry->uncompressed_filesize); + PHAR_SET_32(local.compsize, entry->uncompressed_filesize); + goto not_compressed; + } + + filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0); + + if (!filter) { + if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { + spprintf(p->error, 0, ""unable to gzip compress file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + } else { + spprintf(p->error, 0, ""unable to bzip2 compress file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + } + return ZEND_HASH_APPLY_STOP; + } + + /* create new file that holds the compressed version */ + /* work around inability to specify freedom in write and strictness + in read count */ + entry->cfp = php_stream_fopen_tmpfile(); + + if (!entry->cfp) { + spprintf(p->error, 0, ""unable to create temporary file for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_flush(efp); + + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + spprintf(p->error, 0, ""unable to seek to start of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_filter_append((&entry->cfp->writefilters), filter); + + if (SUCCESS != php_stream_copy_to_stream_ex(efp, entry->cfp, entry->uncompressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to copy compressed file contents of file \""%s\"" while creating new phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_filter_flush(filter, 1); + php_stream_flush(entry->cfp); + php_stream_filter_remove(filter, 1); + php_stream_seek(entry->cfp, 0, SEEK_END); + entry->compressed_filesize = (php_uint32) php_stream_tell(entry->cfp); + PHAR_SET_32(central.compsize, entry->compressed_filesize); + PHAR_SET_32(local.compsize, entry->compressed_filesize); + /* generate crc on compressed file */ + php_stream_rewind(entry->cfp); + entry->old_flags = entry->flags; + entry->is_modified = 1; + } else { +is_compressed: + PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize); + PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize); + PHAR_SET_32(central.compsize, entry->compressed_filesize); + PHAR_SET_32(local.compsize, entry->compressed_filesize); + if (p->old) { + if (-1 == php_stream_seek(p->old, entry->offset_abs, SEEK_SET)) { + spprintf(p->error, 0, ""unable to seek to start of file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + } +not_compressed: + PHAR_SET_32(central.crc32, entry->crc32); + PHAR_SET_32(local.crc32, entry->crc32); +continue_dir: + /* set file metadata */ + if (Z_TYPE(entry->metadata) != IS_UNDEF) { + php_serialize_data_t metadata_hash; + + if (entry->metadata_str.s) { + smart_str_free(&entry->metadata_str); + } + entry->metadata_str.s = NULL; + PHP_VAR_SERIALIZE_INIT(metadata_hash); + php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash); + PHP_VAR_SERIALIZE_DESTROY(metadata_hash); + PHAR_SET_16(central.comment_len, ZSTR_LEN(entry->metadata_str.s)); + } + + entry->header_offset = php_stream_tell(p->filefp); + offset = entry->header_offset + sizeof(local) + entry->filename_len + (entry->is_dir ? 1 : 0) + sizeof(perms); + + if (sizeof(local) != php_stream_write(p->filefp, (char *)&local, sizeof(local))) { + spprintf(p->error, 0, ""unable to write local file header of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (sizeof(central) != php_stream_write(p->centralfp, (char *)¢ral, sizeof(central))) { + spprintf(p->error, 0, ""unable to write central directory entry for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (entry->is_dir) { + if (entry->filename_len != php_stream_write(p->filefp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to local directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (1 != php_stream_write(p->filefp, ""/"", 1)) { + spprintf(p->error, 0, ""unable to write filename to local directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (entry->filename_len != php_stream_write(p->centralfp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to central directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (1 != php_stream_write(p->centralfp, ""/"", 1)) { + spprintf(p->error, 0, ""unable to write filename to central directory entry for directory \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } else { + if (entry->filename_len != php_stream_write(p->filefp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to local directory entry for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (entry->filename_len != php_stream_write(p->centralfp, entry->filename, entry->filename_len)) { + spprintf(p->error, 0, ""unable to write filename to central directory entry for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + + if (sizeof(perms) != php_stream_write(p->filefp, (char *)&perms, sizeof(perms))) { + spprintf(p->error, 0, ""unable to write local extra permissions file header of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (sizeof(perms) != php_stream_write(p->centralfp, (char *)&perms, sizeof(perms))) { + spprintf(p->error, 0, ""unable to write central extra permissions file header of file \""%s\"" to zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + if (!not_really_modified && entry->is_modified) { + if (entry->cfp) { + if (SUCCESS != php_stream_copy_to_stream_ex(entry->cfp, p->filefp, entry->compressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to write compressed contents of file \""%s\"" in zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + + php_stream_close(entry->cfp); + entry->cfp = NULL; + } else { + if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) { + return ZEND_HASH_APPLY_STOP; + } + + phar_seek_efp(entry, 0, SEEK_SET, 0, 0); + + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), p->filefp, entry->uncompressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to write contents of file \""%s\"" in zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + + if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp && entry->fp_refcount == 0) { + php_stream_close(entry->fp); + } + + entry->is_modified = 0; + } else { + entry->is_modified = 0; + if (entry->fp_refcount) { + /* open file pointers refer to this fp, do not free the stream */ + switch (entry->fp_type) { + case PHAR_FP: + p->free_fp = 0; + break; + case PHAR_UFP: + p->free_ufp = 0; + default: + break; + } + } + + if (!entry->is_dir && entry->compressed_filesize && SUCCESS != php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize, NULL)) { + spprintf(p->error, 0, ""unable to copy contents of file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + return ZEND_HASH_APPLY_STOP; + } + } + + entry->fp = NULL; + entry->offset = entry->offset_abs = offset; + entry->fp_type = PHAR_FP; + + if (entry->metadata_str.s) { + if (ZSTR_LEN(entry->metadata_str.s) != php_stream_write(p->centralfp, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s))) { + spprintf(p->error, 0, ""unable to write metadata as file comment for file \""%s\"" while creating zip-based phar \""%s\"""", entry->filename, entry->phar->fname); + smart_str_free(&entry->metadata_str); + return ZEND_HASH_APPLY_STOP; + } + + smart_str_free(&entry->metadata_str); + } + + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ +","@@ -418,7 +418,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, + php_stream_seek(fp, sizeof(phar_zip_file_header) + entry.header_offset + entry.filename_len + PHAR_GET_16(zipentry.extra_len), SEEK_SET); + sig = (char *) emalloc(entry.uncompressed_filesize); + read = php_stream_read(fp, sig, entry.uncompressed_filesize); +- if (read != entry.uncompressed_filesize) { ++ if (read != entry.uncompressed_filesize || read <= 8) { + php_stream_close(sigfile); + efree(sig); + PHAR_ZIP_FAIL(""signature cannot be read"");",3741,3977,4096 +6181,"static int hls_read_header(AVFormatContext *s) +{ + void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb; + HLSContext *c = s->priv_data; + int ret = 0, i; + int highest_cur_seq_no = 0; + + c->ctx = s; + c->interrupt_callback = &s->interrupt_callback; + c->strict_std_compliance = s->strict_std_compliance; + + c->first_packet = 1; + c->first_timestamp = AV_NOPTS_VALUE; + c->cur_timestamp = AV_NOPTS_VALUE; + + if (u) { + update_options(&c->user_agent, ""user_agent"", u); + + update_options(&c->cookies, ""cookies"", u); + + update_options(&c->headers, ""headers"", u); + + update_options(&c->http_proxy, ""http_proxy"", u); + } + + if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0) + goto fail; + + if ((ret = save_avio_options(s)) < 0) + goto fail; + + /* Some HLS servers don't like being sent the range header */ + av_dict_set(&c->avio_opts, ""seekable"", ""0"", 0); + + if (c->n_variants == 0) { + av_log(NULL, AV_LOG_WARNING, ""Empty playlist\n""); + ret = AVERROR_EOF; + goto fail; + } + /* If the playlist only contained playlists (Master Playlist), + * parse each individual playlist. */ + if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) { + for (i = 0; i < c->n_playlists; i++) { + struct playlist *pls = c->playlists[i]; + if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0) + goto fail; + } + } + + if (c->variants[0]->playlists[0]->n_segments == 0) { + av_log(NULL, AV_LOG_WARNING, ""Empty playlist\n""); + ret = AVERROR_EOF; + goto fail; + } + + /* If this isn't a live stream, calculate the total duration of the + * stream. */ + if (c->variants[0]->playlists[0]->finished) { + int64_t duration = 0; + for (i = 0; i < c->variants[0]->playlists[0]->n_segments; i++) + duration += c->variants[0]->playlists[0]->segments[i]->duration; + s->duration = duration; + } + + /* Associate renditions with variants */ + for (i = 0; i < c->n_variants; i++) { + struct variant *var = c->variants[i]; + + if (var->audio_group[0]) + add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO, var->audio_group); + if (var->video_group[0]) + add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO, var->video_group); + if (var->subtitles_group[0]) + add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE, var->subtitles_group); + } + + /* Create a program for each variant */ + for (i = 0; i < c->n_variants; i++) { + struct variant *v = c->variants[i]; + AVProgram *program; + + program = av_new_program(s, i); + if (!program) + goto fail; + av_dict_set_int(&program->metadata, ""variant_bitrate"", v->bandwidth, 0); + } + + /* Select the starting segments */ + for (i = 0; i < c->n_playlists; i++) { + struct playlist *pls = c->playlists[i]; + + if (pls->n_segments == 0) + continue; + + pls->cur_seq_no = select_cur_seq_no(c, pls); + highest_cur_seq_no = FFMAX(highest_cur_seq_no, pls->cur_seq_no); + } + + /* Open the demuxer for each playlist */ + for (i = 0; i < c->n_playlists; i++) { + struct playlist *pls = c->playlists[i]; + AVInputFormat *in_fmt = NULL; + + if (!(pls->ctx = avformat_alloc_context())) { + ret = AVERROR(ENOMEM); + goto fail; + } + + if (pls->n_segments == 0) + continue; + + pls->index = i; + pls->needed = 1; + pls->parent = s; + + /* + * If this is a live stream and this playlist looks like it is one segment + * behind, try to sync it up so that every substream starts at the same + * time position (so e.g. avformat_find_stream_info() will see packets from + * all active streams within the first few seconds). This is not very generic, + * though, as the sequence numbers are technically independent. + */ + if (!pls->finished && pls->cur_seq_no == highest_cur_seq_no - 1 && + highest_cur_seq_no < pls->start_seq_no + pls->n_segments) { + pls->cur_seq_no = highest_cur_seq_no; + } + + pls->read_buffer = av_malloc(INITIAL_BUFFER_SIZE); + if (!pls->read_buffer){ + ret = AVERROR(ENOMEM); + avformat_free_context(pls->ctx); + pls->ctx = NULL; + goto fail; + } + ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls, + read_data, NULL, NULL); + pls->pb.seekable = 0; + ret = av_probe_input_buffer(&pls->pb, &in_fmt, pls->segments[0]->url, + NULL, 0, 0); + if (ret < 0) { + /* Free the ctx - it isn't initialized properly at this point, + * so avformat_close_input shouldn't be called. If + * avformat_open_input fails below, it frees and zeros the + * context, so it doesn't need any special treatment like this. */ + av_log(s, AV_LOG_ERROR, ""Error when loading first segment '%s'\n"", pls->segments[0]->url); + avformat_free_context(pls->ctx); + pls->ctx = NULL; + goto fail; + } + pls->ctx->pb = &pls->pb; + pls->ctx->io_open = nested_io_open; + pls->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO; + + if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0) + goto fail; + + ret = avformat_open_input(&pls->ctx, pls->segments[0]->url, in_fmt, NULL); + if (ret < 0) + goto fail; + + if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) { + ff_id3v2_parse_apic(pls->ctx, &pls->id3_deferred_extra); + avformat_queue_attached_pictures(pls->ctx); + ff_id3v2_free_extra_meta(&pls->id3_deferred_extra); + pls->id3_deferred_extra = NULL; + } + + if (pls->is_id3_timestamped == -1) + av_log(s, AV_LOG_WARNING, ""No expected HTTP requests have been made\n""); + + /* + * For ID3 timestamped raw audio streams we need to detect the packet + * durations to calculate timestamps in fill_timing_for_id3_timestamped_stream(), + * but for other streams we can rely on our user calling avformat_find_stream_info() + * on us if they want to. + */ + if (pls->is_id3_timestamped) { + ret = avformat_find_stream_info(pls->ctx, NULL); + if (ret < 0) + goto fail; + } + + pls->has_noheader_flag = !!(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER); + + /* Create new AVStreams for each stream in this playlist */ + ret = update_streams_from_subdemuxer(s, pls); + if (ret < 0) + goto fail; + + add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_AUDIO); + add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_VIDEO); + add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_SUBTITLE); + } + + update_noheader_flag(s); + + return 0; +fail: + hls_close(s); + return ret; +} +",0,"static int hls_read_header(AVFormatContext *s) +{ + void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb; + HLSContext *c = s->priv_data; + int ret = 0, i; + int highest_cur_seq_no = 0; + + c->ctx = s; + c->interrupt_callback = &s->interrupt_callback; + c->strict_std_compliance = s->strict_std_compliance; + + c->first_packet = 1; + c->first_timestamp = AV_NOPTS_VALUE; + c->cur_timestamp = AV_NOPTS_VALUE; + + if (u) { + update_options(&c->user_agent, ""user_agent"", u); + + update_options(&c->cookies, ""cookies"", u); + + update_options(&c->headers, ""headers"", u); + + update_options(&c->http_proxy, ""http_proxy"", u); + } + + if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0) + goto fail; + + if ((ret = save_avio_options(s)) < 0) + goto fail; + + /* Some HLS servers don't like being sent the range header */ + av_dict_set(&c->avio_opts, ""seekable"", ""0"", 0); + + if (c->n_variants == 0) { + av_log(NULL, AV_LOG_WARNING, ""Empty playlist\n""); + ret = AVERROR_EOF; + goto fail; + } + /* If the playlist only contained playlists (Master Playlist), + * parse each individual playlist. */ + if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) { + for (i = 0; i < c->n_playlists; i++) { + struct playlist *pls = c->playlists[i]; + if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0) + goto fail; + } + } + + if (c->variants[0]->playlists[0]->n_segments == 0) { + av_log(NULL, AV_LOG_WARNING, ""Empty playlist\n""); + ret = AVERROR_EOF; + goto fail; + } + + /* If this isn't a live stream, calculate the total duration of the + * stream. */ + if (c->variants[0]->playlists[0]->finished) { + int64_t duration = 0; + for (i = 0; i < c->variants[0]->playlists[0]->n_segments; i++) + duration += c->variants[0]->playlists[0]->segments[i]->duration; + s->duration = duration; + } + + /* Associate renditions with variants */ + for (i = 0; i < c->n_variants; i++) { + struct variant *var = c->variants[i]; + + if (var->audio_group[0]) + add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO, var->audio_group); + if (var->video_group[0]) + add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO, var->video_group); + if (var->subtitles_group[0]) + add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE, var->subtitles_group); + } + + /* Create a program for each variant */ + for (i = 0; i < c->n_variants; i++) { + struct variant *v = c->variants[i]; + AVProgram *program; + + program = av_new_program(s, i); + if (!program) + goto fail; + av_dict_set_int(&program->metadata, ""variant_bitrate"", v->bandwidth, 0); + } + + /* Select the starting segments */ + for (i = 0; i < c->n_playlists; i++) { + struct playlist *pls = c->playlists[i]; + + if (pls->n_segments == 0) + continue; + + pls->cur_seq_no = select_cur_seq_no(c, pls); + highest_cur_seq_no = FFMAX(highest_cur_seq_no, pls->cur_seq_no); + } + + /* Open the demuxer for each playlist */ + for (i = 0; i < c->n_playlists; i++) { + struct playlist *pls = c->playlists[i]; + AVInputFormat *in_fmt = NULL; + + if (!(pls->ctx = avformat_alloc_context())) { + ret = AVERROR(ENOMEM); + goto fail; + } + + if (pls->n_segments == 0) + continue; + + pls->index = i; + pls->needed = 1; + pls->parent = s; + + /* + * If this is a live stream and this playlist looks like it is one segment + * behind, try to sync it up so that every substream starts at the same + * time position (so e.g. avformat_find_stream_info() will see packets from + * all active streams within the first few seconds). This is not very generic, + * though, as the sequence numbers are technically independent. + */ + if (!pls->finished && pls->cur_seq_no == highest_cur_seq_no - 1 && + highest_cur_seq_no < pls->start_seq_no + pls->n_segments) { + pls->cur_seq_no = highest_cur_seq_no; + } + + pls->read_buffer = av_malloc(INITIAL_BUFFER_SIZE); + if (!pls->read_buffer){ + ret = AVERROR(ENOMEM); + avformat_free_context(pls->ctx); + pls->ctx = NULL; + goto fail; + } + ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls, + read_data, NULL, NULL); + pls->pb.seekable = 0; + ret = av_probe_input_buffer(&pls->pb, &in_fmt, pls->segments[0]->url, + NULL, 0, 0); + if (ret < 0) { + /* Free the ctx - it isn't initialized properly at this point, + * so avformat_close_input shouldn't be called. If + * avformat_open_input fails below, it frees and zeros the + * context, so it doesn't need any special treatment like this. */ + av_log(s, AV_LOG_ERROR, ""Error when loading first segment '%s'\n"", pls->segments[0]->url); + avformat_free_context(pls->ctx); + pls->ctx = NULL; + goto fail; + } + pls->ctx->pb = &pls->pb; + pls->ctx->io_open = nested_io_open; + pls->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO; + + if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0) + goto fail; + + ret = avformat_open_input(&pls->ctx, pls->segments[0]->url, in_fmt, NULL); + if (ret < 0) + goto fail; + + if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) { + ff_id3v2_parse_apic(pls->ctx, &pls->id3_deferred_extra); + avformat_queue_attached_pictures(pls->ctx); + ff_id3v2_free_extra_meta(&pls->id3_deferred_extra); + pls->id3_deferred_extra = NULL; + } + + if (pls->is_id3_timestamped == -1) + av_log(s, AV_LOG_WARNING, ""No expected HTTP requests have been made\n""); + + /* + * For ID3 timestamped raw audio streams we need to detect the packet + * durations to calculate timestamps in fill_timing_for_id3_timestamped_stream(), + * but for other streams we can rely on our user calling avformat_find_stream_info() + * on us if they want to. + */ + if (pls->is_id3_timestamped) { + ret = avformat_find_stream_info(pls->ctx, NULL); + if (ret < 0) + goto fail; + } + + pls->has_noheader_flag = !!(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER); + + /* Create new AVStreams for each stream in this playlist */ + ret = update_streams_from_subdemuxer(s, pls); + if (ret < 0) + goto fail; + + add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_AUDIO); + add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_VIDEO); + add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_SUBTITLE); + } + + update_noheader_flag(s); + + return 0; +fail: + hls_close(s); + return ret; +} +","@@ -205,6 +205,7 @@ typedef struct HLSContext { + AVDictionary *avio_opts; + int strict_std_compliance; + char *allowed_extensions; ++ int max_reload; + } HLSContext; + + static int read_chomp_line(AVIOContext *s, char *buf, int maxlen) +@@ -1263,6 +1264,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size) + HLSContext *c = v->parent->priv_data; + int ret, i; + int just_opened = 0; ++ int reload_count = 0; + + restart: + if (!v->needed) +@@ -1294,6 +1296,9 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size) + reload_interval = default_reload_interval(v); + + reload: ++ reload_count++; ++ if (reload_count > c->max_reload) ++ return AVERROR_EOF; + if (!v->finished && + av_gettime_relative() - v->last_load_time >= reload_interval) { + if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) { +@@ -2150,6 +2155,8 @@ static const AVOption hls_options[] = { + OFFSET(allowed_extensions), AV_OPT_TYPE_STRING, + {.str = ""3gp,aac,avi,flac,mkv,m3u8,m4a,m4s,m4v,mpg,mov,mp2,mp3,mp4,mpeg,mpegts,ogg,ogv,oga,ts,vob,wav""}, + INT_MIN, INT_MAX, FLAGS}, ++ {""max_reload"", ""Maximum number of times a insufficient list is attempted to be reloaded"", ++ OFFSET(max_reload), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, FLAGS}, + {NULL} + }; + ",1881,2117,4096 +5304,"static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct ppp_file *pf; + struct ppp *ppp; + int err = -EFAULT, val, val2, i; + struct ppp_idle idle; + struct npioctl npi; + int unit, cflags; + struct slcompress *vj; + void __user *argp = (void __user *)arg; + int __user *p = argp; + + mutex_lock(&ppp_mutex); + + pf = file->private_data; + if (!pf) { + err = ppp_unattached_ioctl(current->nsproxy->net_ns, + pf, file, cmd, arg); + goto out; + } + + if (cmd == PPPIOCDETACH) { + /* + * We have to be careful here... if the file descriptor + * has been dup'd, we could have another process in the + * middle of a poll using the same file *, so we had + * better not free the interface data structures - + * instead we fail the ioctl. Even in this case, we + * shut down the interface if we are the owner of it. + * Actually, we should get rid of PPPIOCDETACH, userland + * (i.e. pppd) could achieve the same effect by closing + * this fd and reopening /dev/ppp. + */ + err = -EINVAL; + if (pf->kind == INTERFACE) { + ppp = PF_TO_PPP(pf); + rtnl_lock(); + if (file == ppp->owner) + unregister_netdevice(ppp->dev); + rtnl_unlock(); + } + if (atomic_long_read(&file->f_count) < 2) { + ppp_release(NULL, file); + err = 0; + } else + pr_warn(""PPPIOCDETACH file->f_count=%ld\n"", + atomic_long_read(&file->f_count)); + goto out; + } + + if (pf->kind == CHANNEL) { + struct channel *pch; + struct ppp_channel *chan; + + pch = PF_TO_CHANNEL(pf); + + switch (cmd) { + case PPPIOCCONNECT: + if (get_user(unit, p)) + break; + err = ppp_connect_channel(pch, unit); + break; + + case PPPIOCDISCONN: + err = ppp_disconnect_channel(pch); + break; + + default: + down_read(&pch->chan_sem); + chan = pch->chan; + err = -ENOTTY; + if (chan && chan->ops->ioctl) + err = chan->ops->ioctl(chan, cmd, arg); + up_read(&pch->chan_sem); + } + goto out; + } + + if (pf->kind != INTERFACE) { + /* can't happen */ + pr_err(""PPP: not interface or channel??\n""); + err = -EINVAL; + goto out; + } + + ppp = PF_TO_PPP(pf); + switch (cmd) { + case PPPIOCSMRU: + if (get_user(val, p)) + break; + ppp->mru = val; + err = 0; + break; + + case PPPIOCSFLAGS: + if (get_user(val, p)) + break; + ppp_lock(ppp); + cflags = ppp->flags & ~val; +#ifdef CONFIG_PPP_MULTILINK + if (!(ppp->flags & SC_MULTILINK) && (val & SC_MULTILINK)) + ppp->nextseq = 0; +#endif + ppp->flags = val & SC_FLAG_BITS; + ppp_unlock(ppp); + if (cflags & SC_CCP_OPEN) + ppp_ccp_closed(ppp); + err = 0; + break; + + case PPPIOCGFLAGS: + val = ppp->flags | ppp->xstate | ppp->rstate; + if (put_user(val, p)) + break; + err = 0; + break; + + case PPPIOCSCOMPRESS: + err = ppp_set_compress(ppp, arg); + break; + + case PPPIOCGUNIT: + if (put_user(ppp->file.index, p)) + break; + err = 0; + break; + + case PPPIOCSDEBUG: + if (get_user(val, p)) + break; + ppp->debug = val; + err = 0; + break; + + case PPPIOCGDEBUG: + if (put_user(ppp->debug, p)) + break; + err = 0; + break; + + case PPPIOCGIDLE: + idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ; + idle.recv_idle = (jiffies - ppp->last_recv) / HZ; + if (copy_to_user(argp, &idle, sizeof(idle))) + break; + err = 0; + break; + + case PPPIOCSMAXCID: + if (get_user(val, p)) + break; + val2 = 15; + if ((val >> 16) != 0) { + val2 = val >> 16; + val &= 0xffff; + } + vj = slhc_init(val2+1, val+1); + if (IS_ERR(vj)) { + err = PTR_ERR(vj); + break; + } + ppp_lock(ppp); + if (ppp->vj) + slhc_free(ppp->vj); + ppp->vj = vj; + ppp_unlock(ppp); + err = 0; + break; + + case PPPIOCGNPMODE: + case PPPIOCSNPMODE: + if (copy_from_user(&npi, argp, sizeof(npi))) + break; + err = proto_to_npindex(npi.protocol); + if (err < 0) + break; + i = err; + if (cmd == PPPIOCGNPMODE) { + err = -EFAULT; + npi.mode = ppp->npmode[i]; + if (copy_to_user(argp, &npi, sizeof(npi))) + break; + } else { + ppp->npmode[i] = npi.mode; + /* we may be able to transmit more packets now (??) */ + netif_wake_queue(ppp->dev); + } + err = 0; + break; + +#ifdef CONFIG_PPP_FILTER + case PPPIOCSPASS: + { + struct sock_filter *code; + + err = get_filter(argp, &code); + if (err >= 0) { + struct bpf_prog *pass_filter = NULL; + struct sock_fprog_kern fprog = { + .len = err, + .filter = code, + }; + + err = 0; + if (fprog.filter) + err = bpf_prog_create(&pass_filter, &fprog); + if (!err) { + ppp_lock(ppp); + if (ppp->pass_filter) + bpf_prog_destroy(ppp->pass_filter); + ppp->pass_filter = pass_filter; + ppp_unlock(ppp); + } + kfree(code); + } + break; + } + case PPPIOCSACTIVE: + { + struct sock_filter *code; + + err = get_filter(argp, &code); + if (err >= 0) { + struct bpf_prog *active_filter = NULL; + struct sock_fprog_kern fprog = { + .len = err, + .filter = code, + }; + + err = 0; + if (fprog.filter) + err = bpf_prog_create(&active_filter, &fprog); + if (!err) { + ppp_lock(ppp); + if (ppp->active_filter) + bpf_prog_destroy(ppp->active_filter); + ppp->active_filter = active_filter; + ppp_unlock(ppp); + } + kfree(code); + } + break; + } +#endif /* CONFIG_PPP_FILTER */ + +#ifdef CONFIG_PPP_MULTILINK + case PPPIOCSMRRU: + if (get_user(val, p)) + break; + ppp_recv_lock(ppp); + ppp->mrru = val; + ppp_recv_unlock(ppp); + err = 0; + break; +#endif /* CONFIG_PPP_MULTILINK */ + + default: + err = -ENOTTY; + } + +out: + mutex_unlock(&ppp_mutex); + + return err; +} +",0,"static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct ppp_file *pf; + struct ppp *ppp; + int err = -EFAULT, val, val2, i; + struct ppp_idle idle; + struct npioctl npi; + int unit, cflags; + struct slcompress *vj; + void __user *argp = (void __user *)arg; + int __user *p = argp; + + mutex_lock(&ppp_mutex); + + pf = file->private_data; + if (!pf) { + err = ppp_unattached_ioctl(current->nsproxy->net_ns, + pf, file, cmd, arg); + goto out; + } + + if (cmd == PPPIOCDETACH) { + /* + * We have to be careful here... if the file descriptor + * has been dup'd, we could have another process in the + * middle of a poll using the same file *, so we had + * better not free the interface data structures - + * instead we fail the ioctl. Even in this case, we + * shut down the interface if we are the owner of it. + * Actually, we should get rid of PPPIOCDETACH, userland + * (i.e. pppd) could achieve the same effect by closing + * this fd and reopening /dev/ppp. + */ + err = -EINVAL; + if (pf->kind == INTERFACE) { + ppp = PF_TO_PPP(pf); + rtnl_lock(); + if (file == ppp->owner) + unregister_netdevice(ppp->dev); + rtnl_unlock(); + } + if (atomic_long_read(&file->f_count) < 2) { + ppp_release(NULL, file); + err = 0; + } else + pr_warn(""PPPIOCDETACH file->f_count=%ld\n"", + atomic_long_read(&file->f_count)); + goto out; + } + + if (pf->kind == CHANNEL) { + struct channel *pch; + struct ppp_channel *chan; + + pch = PF_TO_CHANNEL(pf); + + switch (cmd) { + case PPPIOCCONNECT: + if (get_user(unit, p)) + break; + err = ppp_connect_channel(pch, unit); + break; + + case PPPIOCDISCONN: + err = ppp_disconnect_channel(pch); + break; + + default: + down_read(&pch->chan_sem); + chan = pch->chan; + err = -ENOTTY; + if (chan && chan->ops->ioctl) + err = chan->ops->ioctl(chan, cmd, arg); + up_read(&pch->chan_sem); + } + goto out; + } + + if (pf->kind != INTERFACE) { + /* can't happen */ + pr_err(""PPP: not interface or channel??\n""); + err = -EINVAL; + goto out; + } + + ppp = PF_TO_PPP(pf); + switch (cmd) { + case PPPIOCSMRU: + if (get_user(val, p)) + break; + ppp->mru = val; + err = 0; + break; + + case PPPIOCSFLAGS: + if (get_user(val, p)) + break; + ppp_lock(ppp); + cflags = ppp->flags & ~val; +#ifdef CONFIG_PPP_MULTILINK + if (!(ppp->flags & SC_MULTILINK) && (val & SC_MULTILINK)) + ppp->nextseq = 0; +#endif + ppp->flags = val & SC_FLAG_BITS; + ppp_unlock(ppp); + if (cflags & SC_CCP_OPEN) + ppp_ccp_closed(ppp); + err = 0; + break; + + case PPPIOCGFLAGS: + val = ppp->flags | ppp->xstate | ppp->rstate; + if (put_user(val, p)) + break; + err = 0; + break; + + case PPPIOCSCOMPRESS: + err = ppp_set_compress(ppp, arg); + break; + + case PPPIOCGUNIT: + if (put_user(ppp->file.index, p)) + break; + err = 0; + break; + + case PPPIOCSDEBUG: + if (get_user(val, p)) + break; + ppp->debug = val; + err = 0; + break; + + case PPPIOCGDEBUG: + if (put_user(ppp->debug, p)) + break; + err = 0; + break; + + case PPPIOCGIDLE: + idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ; + idle.recv_idle = (jiffies - ppp->last_recv) / HZ; + if (copy_to_user(argp, &idle, sizeof(idle))) + break; + err = 0; + break; + + case PPPIOCSMAXCID: + if (get_user(val, p)) + break; + val2 = 15; + if ((val >> 16) != 0) { + val2 = val >> 16; + val &= 0xffff; + } + vj = slhc_init(val2+1, val+1); + if (IS_ERR(vj)) { + err = PTR_ERR(vj); + break; + } + ppp_lock(ppp); + if (ppp->vj) + slhc_free(ppp->vj); + ppp->vj = vj; + ppp_unlock(ppp); + err = 0; + break; + + case PPPIOCGNPMODE: + case PPPIOCSNPMODE: + if (copy_from_user(&npi, argp, sizeof(npi))) + break; + err = proto_to_npindex(npi.protocol); + if (err < 0) + break; + i = err; + if (cmd == PPPIOCGNPMODE) { + err = -EFAULT; + npi.mode = ppp->npmode[i]; + if (copy_to_user(argp, &npi, sizeof(npi))) + break; + } else { + ppp->npmode[i] = npi.mode; + /* we may be able to transmit more packets now (??) */ + netif_wake_queue(ppp->dev); + } + err = 0; + break; + +#ifdef CONFIG_PPP_FILTER + case PPPIOCSPASS: + { + struct sock_filter *code; + + err = get_filter(argp, &code); + if (err >= 0) { + struct bpf_prog *pass_filter = NULL; + struct sock_fprog_kern fprog = { + .len = err, + .filter = code, + }; + + err = 0; + if (fprog.filter) + err = bpf_prog_create(&pass_filter, &fprog); + if (!err) { + ppp_lock(ppp); + if (ppp->pass_filter) + bpf_prog_destroy(ppp->pass_filter); + ppp->pass_filter = pass_filter; + ppp_unlock(ppp); + } + kfree(code); + } + break; + } + case PPPIOCSACTIVE: + { + struct sock_filter *code; + + err = get_filter(argp, &code); + if (err >= 0) { + struct bpf_prog *active_filter = NULL; + struct sock_fprog_kern fprog = { + .len = err, + .filter = code, + }; + + err = 0; + if (fprog.filter) + err = bpf_prog_create(&active_filter, &fprog); + if (!err) { + ppp_lock(ppp); + if (ppp->active_filter) + bpf_prog_destroy(ppp->active_filter); + ppp->active_filter = active_filter; + ppp_unlock(ppp); + } + kfree(code); + } + break; + } +#endif /* CONFIG_PPP_FILTER */ + +#ifdef CONFIG_PPP_MULTILINK + case PPPIOCSMRRU: + if (get_user(val, p)) + break; + ppp_recv_lock(ppp); + ppp->mrru = val; + ppp_recv_unlock(ppp); + err = 0; + break; +#endif /* CONFIG_PPP_MULTILINK */ + + default: + err = -ENOTTY; + } + +out: + mutex_unlock(&ppp_mutex); + + return err; +} +","@@ -2307,7 +2307,7 @@ int ppp_register_net_channel(struct net *net, struct ppp_channel *chan) + + pch->ppp = NULL; + pch->chan = chan; +- pch->chan_net = net; ++ pch->chan_net = get_net(net); + chan->ppp = pch; + init_ppp_file(&pch->file, CHANNEL); + pch->file.hdrlen = chan->hdrlen; +@@ -2404,6 +2404,8 @@ ppp_unregister_channel(struct ppp_channel *chan) + spin_lock_bh(&pn->all_channels_lock); + list_del(&pch->list); + spin_unlock_bh(&pn->all_channels_lock); ++ put_net(pch->chan_net); ++ pch->chan_net = NULL; + + pch->file.dead = 1; + wake_up_interruptible(&pch->file.rwait);",1812,2048,4096 +18819,"status_t BnOMX::onTransact( + uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { + switch (code) { + case LIVES_LOCALLY: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + node_id node = (node_id)data.readInt32(); + pid_t pid = (pid_t)data.readInt32(); + reply->writeInt32(livesLocally(node, pid)); + + return OK; + } + + case LIST_NODES: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + List list; + listNodes(&list); + + reply->writeInt32(list.size()); + for (List::iterator it = list.begin(); + it != list.end(); ++it) { + ComponentInfo &cur = *it; + + reply->writeString8(cur.mName); + reply->writeInt32(cur.mRoles.size()); + for (List::iterator role_it = cur.mRoles.begin(); + role_it != cur.mRoles.end(); ++role_it) { + reply->writeString8(*role_it); + } + } + + return NO_ERROR; + } + + case ALLOCATE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + const char *name = data.readCString(); + + sp observer = + interface_cast(data.readStrongBinder()); + + node_id node; + + status_t err = allocateNode(name, observer, &node); + reply->writeInt32(err); + if (err == OK) { + reply->writeInt32((int32_t)node); + } + + return NO_ERROR; + } + + case FREE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + reply->writeInt32(freeNode(node)); + + return NO_ERROR; + } + + case SEND_COMMAND: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + OMX_COMMANDTYPE cmd = + static_cast(data.readInt32()); + + OMX_S32 param = data.readInt32(); + reply->writeInt32(sendCommand(node, cmd, param)); + + return NO_ERROR; + } + + case GET_PARAMETER: + case SET_PARAMETER: + case GET_CONFIG: + case SET_CONFIG: + case SET_INTERNAL_OPTION: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_INDEXTYPE index = static_cast(data.readInt32()); + + + size_t size = data.readInt64(); + + status_t err = NO_MEMORY; + void *params = calloc(size, 1); + if (params) { + err = data.read(params, size); + if (err != OK) { + android_errorWriteLog(0x534e4554, ""26914474""); + } else { + switch (code) { + case GET_PARAMETER: + err = getParameter(node, index, params, size); + break; + case SET_PARAMETER: + err = setParameter(node, index, params, size); + break; + case GET_CONFIG: + err = getConfig(node, index, params, size); + break; + case SET_CONFIG: + err = setConfig(node, index, params, size); + break; + case SET_INTERNAL_OPTION: + { + InternalOptionType type = + (InternalOptionType)data.readInt32(); + + err = setInternalOption(node, index, type, params, size); + break; + } + default: + TRESPASS(); + } + } + } + + reply->writeInt32(err); + + if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { + + reply->write(params, size); + } + + free(params); + params = NULL; + + return NO_ERROR; + } + + case GET_STATE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_STATETYPE state = OMX_StateInvalid; + + status_t err = getState(node, &state); + reply->writeInt32(state); + reply->writeInt32(err); + + return NO_ERROR; + } + + case ENABLE_GRAPHIC_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + status_t err = enableGraphicBuffers(node, port_index, enable); + reply->writeInt32(err); + + return NO_ERROR; + } + + case GET_GRAPHIC_BUFFER_USAGE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + OMX_U32 usage = 0; + status_t err = getGraphicBufferUsage(node, port_index, &usage); + reply->writeInt32(err); + reply->writeInt32(usage); + + return NO_ERROR; + } + + case USE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + OMX_U32 allottedSize = data.readInt32(); + + buffer_id buffer; + status_t err = useBuffer(node, port_index, params, &buffer, allottedSize); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case USE_GRAPHIC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + + buffer_id buffer; + status_t err = useGraphicBuffer( + node, port_index, graphicBuffer, &buffer); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case UPDATE_GRAPHIC_BUFFER_IN_META: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + buffer_id buffer = (buffer_id)data.readInt32(); + + status_t err = updateGraphicBufferInMeta( + node, port_index, graphicBuffer, buffer); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CREATE_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + sp bufferProducer; + MetadataBufferType type = kMetadataBufferTypeInvalid; + status_t err = createInputSurface(node, port_index, &bufferProducer, &type); + + if ((err != OK) && (type == kMetadataBufferTypeInvalid)) { + android_errorWriteLog(0x534e4554, ""26324358""); + } + + reply->writeInt32(type); + reply->writeInt32(err); + + if (err == OK) { + reply->writeStrongBinder(IInterface::asBinder(bufferProducer)); + } + + return NO_ERROR; + } + + case CREATE_PERSISTENT_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + sp bufferProducer; + sp bufferConsumer; + status_t err = createPersistentInputSurface( + &bufferProducer, &bufferConsumer); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeStrongBinder(IInterface::asBinder(bufferProducer)); + reply->writeStrongBinder(IInterface::asBinder(bufferConsumer)); + } + + return NO_ERROR; + } + + case SET_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + sp bufferConsumer = + interface_cast(data.readStrongBinder()); + + MetadataBufferType type = kMetadataBufferTypeInvalid; + status_t err = setInputSurface(node, port_index, bufferConsumer, &type); + + if ((err != OK) && (type == kMetadataBufferTypeInvalid)) { + android_errorWriteLog(0x534e4554, ""26324358""); + } + + reply->writeInt32(type); + reply->writeInt32(err); + return NO_ERROR; + } + + case SIGNAL_END_OF_INPUT_STREAM: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + status_t err = signalEndOfInputStream(node); + reply->writeInt32(err); + + return NO_ERROR; + } + + case STORE_META_DATA_IN_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + MetadataBufferType type = kMetadataBufferTypeInvalid; + status_t err = storeMetaDataInBuffers(node, port_index, enable, &type); + + reply->writeInt32(type); + reply->writeInt32(err); + + return NO_ERROR; + } + + case PREPARE_FOR_ADAPTIVE_PLAYBACK: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + OMX_U32 max_width = data.readInt32(); + OMX_U32 max_height = data.readInt32(); + + status_t err = prepareForAdaptivePlayback( + node, port_index, enable, max_width, max_height); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CONFIGURE_VIDEO_TUNNEL_MODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL tunneled = (OMX_BOOL)data.readInt32(); + OMX_U32 audio_hw_sync = data.readInt32(); + + native_handle_t *sideband_handle = NULL; + status_t err = configureVideoTunnelMode( + node, port_index, tunneled, audio_hw_sync, &sideband_handle); + reply->writeInt32(err); + if(err == OK){ + reply->writeNativeHandle(sideband_handle); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + if (!isSecure(node) || port_index != 0 /* kPortIndexInput */) { + ALOGE(""b/24310423""); + reply->writeInt32(INVALID_OPERATION); + return NO_ERROR; + } + + size_t size = data.readInt64(); + + buffer_id buffer; + void *buffer_data; + status_t err = allocateBuffer( + node, port_index, size, &buffer, &buffer_data); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + reply->writeInt64((uintptr_t)buffer_data); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER_WITH_BACKUP: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + OMX_U32 allottedSize = data.readInt32(); + + buffer_id buffer; + status_t err = allocateBufferWithBackup( + node, port_index, params, &buffer, allottedSize); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case FREE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + reply->writeInt32(freeBuffer(node, port_index, buffer)); + + return NO_ERROR; + } + + case FILL_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + bool haveFence = data.readInt32(); + int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; + reply->writeInt32(fillBuffer(node, buffer, fenceFd)); + + return NO_ERROR; + } + + case EMPTY_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + OMX_U32 range_offset = data.readInt32(); + OMX_U32 range_length = data.readInt32(); + OMX_U32 flags = data.readInt32(); + OMX_TICKS timestamp = data.readInt64(); + bool haveFence = data.readInt32(); + int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; + reply->writeInt32(emptyBuffer( + node, buffer, range_offset, range_length, flags, timestamp, fenceFd)); + + return NO_ERROR; + } + + case GET_EXTENSION_INDEX: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + const char *parameter_name = data.readCString(); + + OMX_INDEXTYPE index; + status_t err = getExtensionIndex(node, parameter_name, &index); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32(index); + } + + return OK; + } + + default: + return BBinder::onTransact(code, data, reply, flags); + } +} +",1,"status_t BnOMX::onTransact( + uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { + switch (code) { + case LIVES_LOCALLY: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + node_id node = (node_id)data.readInt32(); + pid_t pid = (pid_t)data.readInt32(); + reply->writeInt32(livesLocally(node, pid)); + + return OK; + } + + case LIST_NODES: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + List list; + listNodes(&list); + + reply->writeInt32(list.size()); + for (List::iterator it = list.begin(); + it != list.end(); ++it) { + ComponentInfo &cur = *it; + + reply->writeString8(cur.mName); + reply->writeInt32(cur.mRoles.size()); + for (List::iterator role_it = cur.mRoles.begin(); + role_it != cur.mRoles.end(); ++role_it) { + reply->writeString8(*role_it); + } + } + + return NO_ERROR; + } + + case ALLOCATE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + const char *name = data.readCString(); + + sp observer = + interface_cast(data.readStrongBinder()); + + node_id node; + + status_t err = allocateNode(name, observer, &node); + reply->writeInt32(err); + if (err == OK) { + reply->writeInt32((int32_t)node); + } + + return NO_ERROR; + } + + case FREE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + reply->writeInt32(freeNode(node)); + + return NO_ERROR; + } + + case SEND_COMMAND: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + OMX_COMMANDTYPE cmd = + static_cast(data.readInt32()); + + OMX_S32 param = data.readInt32(); + reply->writeInt32(sendCommand(node, cmd, param)); + + return NO_ERROR; + } + + case GET_PARAMETER: + case SET_PARAMETER: + case GET_CONFIG: + case SET_CONFIG: + case SET_INTERNAL_OPTION: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_INDEXTYPE index = static_cast(data.readInt32()); + + + size_t size = data.readInt64(); + + status_t err = NOT_ENOUGH_DATA; + void *params = NULL; + size_t pageSize = 0; + size_t allocSize = 0; + if (code != SET_INTERNAL_OPTION && size < 8) { + // we expect the structure to contain at least the size and + // version, 8 bytes total + ALOGE(""b/27207275 (%zu)"", size); + android_errorWriteLog(0x534e4554, ""27207275""); + } else { + err = NO_MEMORY; + pageSize = (size_t) sysconf(_SC_PAGE_SIZE); + if (size > SIZE_MAX - (pageSize * 2)) { + ALOGE(""requested param size too big""); + } else { + allocSize = (size + pageSize * 2) & ~(pageSize - 1); + params = mmap(NULL, allocSize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1 /* fd */, 0 /* offset */); + } + if (params != MAP_FAILED) { + err = data.read(params, size); + if (err != OK) { + android_errorWriteLog(0x534e4554, ""26914474""); + } else { + err = NOT_ENOUGH_DATA; + OMX_U32 declaredSize = *(OMX_U32*)params; + if (code != SET_INTERNAL_OPTION && declaredSize > size) { + // the buffer says it's bigger than it actually is + ALOGE(""b/27207275 (%u/%zu)"", declaredSize, size); + android_errorWriteLog(0x534e4554, ""27207275""); + } else { + // mark the last page as inaccessible, to avoid exploitation + // of codecs that access past the end of the allocation because + // they didn't check the size + mprotect((char*)params + allocSize - pageSize, pageSize, PROT_NONE); + switch (code) { + case GET_PARAMETER: + err = getParameter(node, index, params, size); + break; + case SET_PARAMETER: + err = setParameter(node, index, params, size); + break; + case GET_CONFIG: + err = getConfig(node, index, params, size); + break; + case SET_CONFIG: + err = setConfig(node, index, params, size); + break; + case SET_INTERNAL_OPTION: + { + InternalOptionType type = + (InternalOptionType)data.readInt32(); + + err = setInternalOption(node, index, type, params, size); + break; + } + + default: + TRESPASS(); + } + } + } + } else { + ALOGE(""couldn't map: %s"", strerror(errno)); + } + } + + reply->writeInt32(err); + + if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { + + reply->write(params, size); + } + + if (params) { + munmap(params, allocSize); + } + params = NULL; + + return NO_ERROR; + } + + case GET_STATE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_STATETYPE state = OMX_StateInvalid; + + status_t err = getState(node, &state); + reply->writeInt32(state); + reply->writeInt32(err); + + return NO_ERROR; + } + + case ENABLE_GRAPHIC_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + status_t err = enableGraphicBuffers(node, port_index, enable); + reply->writeInt32(err); + + return NO_ERROR; + } + + case GET_GRAPHIC_BUFFER_USAGE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + OMX_U32 usage = 0; + status_t err = getGraphicBufferUsage(node, port_index, &usage); + reply->writeInt32(err); + reply->writeInt32(usage); + + return NO_ERROR; + } + + case USE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + OMX_U32 allottedSize = data.readInt32(); + + buffer_id buffer; + status_t err = useBuffer(node, port_index, params, &buffer, allottedSize); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case USE_GRAPHIC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + + buffer_id buffer; + status_t err = useGraphicBuffer( + node, port_index, graphicBuffer, &buffer); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case UPDATE_GRAPHIC_BUFFER_IN_META: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + buffer_id buffer = (buffer_id)data.readInt32(); + + status_t err = updateGraphicBufferInMeta( + node, port_index, graphicBuffer, buffer); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CREATE_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + sp bufferProducer; + MetadataBufferType type = kMetadataBufferTypeInvalid; + status_t err = createInputSurface(node, port_index, &bufferProducer, &type); + + if ((err != OK) && (type == kMetadataBufferTypeInvalid)) { + android_errorWriteLog(0x534e4554, ""26324358""); + } + + reply->writeInt32(type); + reply->writeInt32(err); + + if (err == OK) { + reply->writeStrongBinder(IInterface::asBinder(bufferProducer)); + } + + return NO_ERROR; + } + + case CREATE_PERSISTENT_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + sp bufferProducer; + sp bufferConsumer; + status_t err = createPersistentInputSurface( + &bufferProducer, &bufferConsumer); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeStrongBinder(IInterface::asBinder(bufferProducer)); + reply->writeStrongBinder(IInterface::asBinder(bufferConsumer)); + } + + return NO_ERROR; + } + + case SET_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + sp bufferConsumer = + interface_cast(data.readStrongBinder()); + + MetadataBufferType type = kMetadataBufferTypeInvalid; + status_t err = setInputSurface(node, port_index, bufferConsumer, &type); + + if ((err != OK) && (type == kMetadataBufferTypeInvalid)) { + android_errorWriteLog(0x534e4554, ""26324358""); + } + + reply->writeInt32(type); + reply->writeInt32(err); + return NO_ERROR; + } + + case SIGNAL_END_OF_INPUT_STREAM: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + status_t err = signalEndOfInputStream(node); + reply->writeInt32(err); + + return NO_ERROR; + } + + case STORE_META_DATA_IN_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + MetadataBufferType type = kMetadataBufferTypeInvalid; + status_t err = storeMetaDataInBuffers(node, port_index, enable, &type); + + reply->writeInt32(type); + reply->writeInt32(err); + + return NO_ERROR; + } + + case PREPARE_FOR_ADAPTIVE_PLAYBACK: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + OMX_U32 max_width = data.readInt32(); + OMX_U32 max_height = data.readInt32(); + + status_t err = prepareForAdaptivePlayback( + node, port_index, enable, max_width, max_height); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CONFIGURE_VIDEO_TUNNEL_MODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL tunneled = (OMX_BOOL)data.readInt32(); + OMX_U32 audio_hw_sync = data.readInt32(); + + native_handle_t *sideband_handle = NULL; + status_t err = configureVideoTunnelMode( + node, port_index, tunneled, audio_hw_sync, &sideband_handle); + reply->writeInt32(err); + if(err == OK){ + reply->writeNativeHandle(sideband_handle); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + if (!isSecure(node) || port_index != 0 /* kPortIndexInput */) { + ALOGE(""b/24310423""); + reply->writeInt32(INVALID_OPERATION); + return NO_ERROR; + } + + size_t size = data.readInt64(); + + buffer_id buffer; + void *buffer_data; + status_t err = allocateBuffer( + node, port_index, size, &buffer, &buffer_data); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + reply->writeInt64((uintptr_t)buffer_data); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER_WITH_BACKUP: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + OMX_U32 allottedSize = data.readInt32(); + + buffer_id buffer; + status_t err = allocateBufferWithBackup( + node, port_index, params, &buffer, allottedSize); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case FREE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + reply->writeInt32(freeBuffer(node, port_index, buffer)); + + return NO_ERROR; + } + + case FILL_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + bool haveFence = data.readInt32(); + int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; + reply->writeInt32(fillBuffer(node, buffer, fenceFd)); + + return NO_ERROR; + } + + case EMPTY_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + OMX_U32 range_offset = data.readInt32(); + OMX_U32 range_length = data.readInt32(); + OMX_U32 flags = data.readInt32(); + OMX_TICKS timestamp = data.readInt64(); + bool haveFence = data.readInt32(); + int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; + reply->writeInt32(emptyBuffer( + node, buffer, range_offset, range_length, flags, timestamp, fenceFd)); + + return NO_ERROR; + } + + case GET_EXTENSION_INDEX: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + const char *parameter_name = data.readCString(); + + OMX_INDEXTYPE index; + status_t err = getExtensionIndex(node, parameter_name, &index); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32(index); + } + + return OK; + } + + default: + return BBinder::onTransact(code, data, reply, flags); + } +} +","@@ -18,6 +18,8 @@ + + #define LOG_TAG ""IOMX"" + #include + ++#include ++ + #include + #include + #include +@@ -692,38 +694,70 @@ + + + size_t size = data.readInt64(); + +- status_t err = NO_MEMORY; +- void *params = calloc(size, 1); +- if (params) { +- err = data.read(params, size); +- if (err != OK) { +- android_errorWriteLog(0x534e4554, ""26914474""); ++ status_t err = NOT_ENOUGH_DATA; ++ void *params = NULL; ++ size_t pageSize = 0; ++ size_t allocSize = 0; ++ if (code != SET_INTERNAL_OPTION && size < 8) { ++ // we expect the structure to contain at least the size and ++ // version, 8 bytes total ++ ALOGE(""b/27207275 (%zu)"", size); ++ android_errorWriteLog(0x534e4554, ""27207275""); ++ } else { ++ err = NO_MEMORY; ++ pageSize = (size_t) sysconf(_SC_PAGE_SIZE); ++ if (size > SIZE_MAX - (pageSize * 2)) { ++ ALOGE(""requested param size too big""); + } else { +- switch (code) { +- case GET_PARAMETER: +- err = getParameter(node, index, params, size); +- break; +- case SET_PARAMETER: +- err = setParameter(node, index, params, size); +- break; +- case GET_CONFIG: +- err = getConfig(node, index, params, size); +- break; +- case SET_CONFIG: +- err = setConfig(node, index, params, size); +- break; +- case SET_INTERNAL_OPTION: +- { +- InternalOptionType type = +- (InternalOptionType)data.readInt32(); ++ allocSize = (size + pageSize * 2) & ~(pageSize - 1); ++ params = mmap(NULL, allocSize, PROT_READ | PROT_WRITE, ++ MAP_PRIVATE | MAP_ANONYMOUS, -1 /* fd */, 0 /* offset */); ++ } ++ if (params != MAP_FAILED) { ++ err = data.read(params, size); ++ if (err != OK) { ++ android_errorWriteLog(0x534e4554, ""26914474""); ++ } else { ++ err = NOT_ENOUGH_DATA; ++ OMX_U32 declaredSize = *(OMX_U32*)params; ++ if (code != SET_INTERNAL_OPTION && declaredSize > size) { ++ // the buffer says it's bigger than it actually is ++ ALOGE(""b/27207275 (%u/%zu)"", declaredSize, size); ++ android_errorWriteLog(0x534e4554, ""27207275""); ++ } else { ++ // mark the last page as inaccessible, to avoid exploitation ++ // of codecs that access past the end of the allocation because ++ // they didn't check the size ++ mprotect((char*)params + allocSize - pageSize, pageSize, PROT_NONE); ++ switch (code) { ++ case GET_PARAMETER: ++ err = getParameter(node, index, params, size); ++ break; ++ case SET_PARAMETER: ++ err = setParameter(node, index, params, size); ++ break; ++ case GET_CONFIG: ++ err = getConfig(node, index, params, size); ++ break; ++ case SET_CONFIG: ++ err = setConfig(node, index, params, size); ++ break; ++ case SET_INTERNAL_OPTION: ++ { ++ InternalOptionType type = ++ (InternalOptionType)data.readInt32(); + +- err = setInternalOption(node, index, type, params, size); +- break; ++ err = setInternalOption(node, index, type, params, size); ++ break; ++ } ++ ++ default: ++ TRESPASS(); ++ } + } +- +- default: +- TRESPASS(); + } ++ } else { ++ ALOGE(""couldn't map: %s"", strerror(errno)); + } + } + +@@ -733,7 +767,9 @@ + + reply->write(params, size); + } + +- free(params); ++ if (params) { ++ munmap(params, allocSize); ++ } + params = NULL; + + return NO_ERROR; +",3148,3384,4096 +4865,"extractCompositeRegions(struct image_data *image, struct crop_mask *crop, + unsigned char *read_buff, unsigned char *crop_buff) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 i, trailing_bits, prev_trailing_bits; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_rowsize, dst_rowsize, src_offset, dst_offset; + uint32 crop_width, crop_length, img_width /*, img_length */; + uint32 prev_length, prev_width, composite_width; + uint16 bps, spp; + uint8 *src, *dst; + tsample_t count, sample = 0; /* Update to extract one or more samples */ + + img_width = image->width; + /* img_length = image->length; */ + bps = image->bps; + spp = image->spp; + count = spp; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + src = read_buff; + dst = crop_buff; + + /* These are setup for adding additional sections */ + prev_width = prev_length = 0; + prev_trailing_bits = trailing_bits = 0; + composite_width = crop->combined_width; + crop->combined_width = 0; + crop->combined_length = 0; + + for (i = 0; i < crop->selections; i++) + { + /* rows, columns, width, length are expressed in pixels */ + first_row = crop->regionlist[i].y1; + last_row = crop->regionlist[i].y2; + first_col = crop->regionlist[i].x1; + last_col = crop->regionlist[i].x2; + + crop_width = last_col - first_col + 1; + crop_length = last_row - first_row + 1; + + /* These should not be needed for composite images */ + crop->regionlist[i].width = crop_width; + crop->regionlist[i].length = crop_length; + crop->regionlist[i].buffptr = crop_buff; + + src_rowsize = ((img_width * bps * spp) + 7) / 8; + dst_rowsize = (((crop_width * bps * count) + 7) / 8); + + switch (crop->edge_ref) + { + default: + case EDGE_TOP: + case EDGE_BOTTOM: + if ((i > 0) && (crop_width != crop->regionlist[i - 1].width)) + { + TIFFError (""extractCompositeRegions"", + ""Only equal width regions can be combined for -E top or bottom""); + return (1); + } + + crop->combined_width = crop_width; + crop->combined_length += crop_length; + + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + (prev_length * dst_rowsize); + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, sample, + spp, bps, count, first_col, + last_col + 1)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + default: TIFFError(""extractCompositeRegions"", ""Unsupported bit depth %d"", bps); + return (1); + } + } + prev_length += crop_length; + break; + case EDGE_LEFT: /* splice the pieces of each row together, side by side */ + case EDGE_RIGHT: + if ((i > 0) && (crop_length != crop->regionlist[i - 1].length)) + { + TIFFError (""extractCompositeRegions"", + ""Only equal length regions can be combined for -E left or right""); + return (1); + } + crop->combined_width += crop_width; + crop->combined_length = crop_length; + dst_rowsize = (((composite_width * bps * count) + 7) / 8); + trailing_bits = (crop_width * bps * count) % 8; + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + prev_width; + + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + default: TIFFError(""extractCompositeRegions"", ""Unsupported bit depth %d"", bps); + return (1); + } + } + prev_width += (crop_width * bps * count) / 8; + prev_trailing_bits += trailing_bits; + if (prev_trailing_bits > 7) + prev_trailing_bits-= 8; + break; + } + } + if (crop->combined_width != composite_width) + TIFFError(""combineSeparateRegions"",""Combined width does not match composite width""); + + return (0); + } /* end extractCompositeRegions */ +",0,"extractCompositeRegions(struct image_data *image, struct crop_mask *crop, + unsigned char *read_buff, unsigned char *crop_buff) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 i, trailing_bits, prev_trailing_bits; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_rowsize, dst_rowsize, src_offset, dst_offset; + uint32 crop_width, crop_length, img_width /*, img_length */; + uint32 prev_length, prev_width, composite_width; + uint16 bps, spp; + uint8 *src, *dst; + tsample_t count, sample = 0; /* Update to extract one or more samples */ + + img_width = image->width; + /* img_length = image->length; */ + bps = image->bps; + spp = image->spp; + count = spp; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + src = read_buff; + dst = crop_buff; + + /* These are setup for adding additional sections */ + prev_width = prev_length = 0; + prev_trailing_bits = trailing_bits = 0; + composite_width = crop->combined_width; + crop->combined_width = 0; + crop->combined_length = 0; + + for (i = 0; i < crop->selections; i++) + { + /* rows, columns, width, length are expressed in pixels */ + first_row = crop->regionlist[i].y1; + last_row = crop->regionlist[i].y2; + first_col = crop->regionlist[i].x1; + last_col = crop->regionlist[i].x2; + + crop_width = last_col - first_col + 1; + crop_length = last_row - first_row + 1; + + /* These should not be needed for composite images */ + crop->regionlist[i].width = crop_width; + crop->regionlist[i].length = crop_length; + crop->regionlist[i].buffptr = crop_buff; + + src_rowsize = ((img_width * bps * spp) + 7) / 8; + dst_rowsize = (((crop_width * bps * count) + 7) / 8); + + switch (crop->edge_ref) + { + default: + case EDGE_TOP: + case EDGE_BOTTOM: + if ((i > 0) && (crop_width != crop->regionlist[i - 1].width)) + { + TIFFError (""extractCompositeRegions"", + ""Only equal width regions can be combined for -E top or bottom""); + return (1); + } + + crop->combined_width = crop_width; + crop->combined_length += crop_length; + + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + (prev_length * dst_rowsize); + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, sample, + spp, bps, count, first_col, + last_col + 1)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + default: TIFFError(""extractCompositeRegions"", ""Unsupported bit depth %d"", bps); + return (1); + } + } + prev_length += crop_length; + break; + case EDGE_LEFT: /* splice the pieces of each row together, side by side */ + case EDGE_RIGHT: + if ((i > 0) && (crop_length != crop->regionlist[i - 1].length)) + { + TIFFError (""extractCompositeRegions"", + ""Only equal length regions can be combined for -E left or right""); + return (1); + } + crop->combined_width += crop_width; + crop->combined_length = crop_length; + dst_rowsize = (((composite_width * bps * count) + 7) / 8); + trailing_bits = (crop_width * bps * count) % 8; + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + prev_width; + + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError(""extractCompositeRegions"", + ""Unable to extract row %d"", row); + return (1); + } + break; + default: TIFFError(""extractCompositeRegions"", ""Unsupported bit depth %d"", bps); + return (1); + } + } + prev_width += (crop_width * bps * count) / 8; + prev_trailing_bits += trailing_bits; + if (prev_trailing_bits > 7) + prev_trailing_bits-= 8; + break; + } + } + if (crop->combined_width != composite_width) + TIFFError(""combineSeparateRegions"",""Combined width does not match composite width""); + + return (0); + } /* end extractCompositeRegions */ +","@@ -819,9 +819,18 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, + } + } + +- tilebuf = _TIFFmalloc(tile_buffsize); ++ /* Add 3 padding bytes for extractContigSamplesShifted32bits */ ++ if( tile_buffsize > 0xFFFFFFFFU - 3 ) ++ { ++ TIFFError(""readContigTilesIntoBuffer"", ""Integer overflow when calculating buffer size.""); ++ exit(-1); ++ } ++ tilebuf = _TIFFmalloc(tile_buffsize + 3); + if (tilebuf == 0) + return 0; ++ tilebuf[tile_buffsize] = 0; ++ tilebuf[tile_buffsize+1] = 0; ++ tilebuf[tile_buffsize+2] = 0; + + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + for (row = 0; row < imagelength; row += tl)",1990,2226,4096 +962,"int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d, + int n, int *al) +{ + unsigned short length; + unsigned short type; + unsigned short size; + unsigned char *data = *p; + int tlsext_servername = 0; + int renegotiate_seen = 0; + +# ifndef OPENSSL_NO_NEXTPROTONEG + s->s3->next_proto_neg_seen = 0; +# endif + s->tlsext_ticket_expected = 0; + +# ifndef OPENSSL_NO_HEARTBEATS + s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED | + SSL_TLSEXT_HB_DONT_SEND_REQUESTS); +# endif + + if ((d + n) - data <= 2) + goto ri_check; + + n2s(data, length); + if ((d + n) - data != length) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + while ((d + n) - data >= 4) { + n2s(data, type); + n2s(data, size); + + if ((d + n) - data < size) + goto ri_check; + + if (s->tlsext_debug_cb) + s->tlsext_debug_cb(s, 1, type, data, size, s->tlsext_debug_arg); + + if (type == TLSEXT_TYPE_server_name) { + if (s->tlsext_hostname == NULL || size > 0) { + *al = TLS1_AD_UNRECOGNIZED_NAME; + return 0; + } + tlsext_servername = 1; + } +# ifndef OPENSSL_NO_EC + else if (type == TLSEXT_TYPE_ec_point_formats) { + unsigned char *sdata = data; + int ecpointformatlist_length = *(sdata++); + + if (ecpointformatlist_length != size - 1 || + ecpointformatlist_length < 1) { + *al = TLS1_AD_DECODE_ERROR; + return 0; + } + if (!s->hit) { + s->session->tlsext_ecpointformatlist_length = 0; + if (s->session->tlsext_ecpointformatlist != NULL) + OPENSSL_free(s->session->tlsext_ecpointformatlist); + if ((s->session->tlsext_ecpointformatlist = + OPENSSL_malloc(ecpointformatlist_length)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->session->tlsext_ecpointformatlist_length = + ecpointformatlist_length; + memcpy(s->session->tlsext_ecpointformatlist, sdata, + ecpointformatlist_length); + } +# if 0 + fprintf(stderr, + ""ssl_parse_serverhello_tlsext s->session->tlsext_ecpointformatlist ""); + sdata = s->session->tlsext_ecpointformatlist; + for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) + fprintf(stderr, ""%i "", *(sdata++)); + fprintf(stderr, ""\n""); +# endif + } +# endif /* OPENSSL_NO_EC */ + + else if (type == TLSEXT_TYPE_session_ticket) { + if (s->tls_session_ticket_ext_cb && + !s->tls_session_ticket_ext_cb(s, data, size, + s->tls_session_ticket_ext_cb_arg)) + { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + if ((SSL_get_options(s) & SSL_OP_NO_TICKET) + || (size > 0)) { + *al = TLS1_AD_UNSUPPORTED_EXTENSION; + return 0; + } + s->tlsext_ticket_expected = 1; + } +# ifdef TLSEXT_TYPE_opaque_prf_input + else if (type == TLSEXT_TYPE_opaque_prf_input && + s->version != DTLS1_VERSION) { + unsigned char *sdata = data; + + if (size < 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + n2s(sdata, s->s3->server_opaque_prf_input_len); + if (s->s3->server_opaque_prf_input_len != size - 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + if (s->s3->server_opaque_prf_input != NULL) { + /* shouldn't really happen */ + OPENSSL_free(s->s3->server_opaque_prf_input); + } + if (s->s3->server_opaque_prf_input_len == 0) { + /* dummy byte just to get non-NULL */ + s->s3->server_opaque_prf_input = OPENSSL_malloc(1); + } else { + s->s3->server_opaque_prf_input = + BUF_memdup(sdata, s->s3->server_opaque_prf_input_len); + } + + if (s->s3->server_opaque_prf_input == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + } +# endif + else if (type == TLSEXT_TYPE_status_request && + s->version != DTLS1_VERSION) { + /* + * MUST be empty and only sent if we've requested a status + * request message. + */ + if ((s->tlsext_status_type == -1) || (size > 0)) { + *al = TLS1_AD_UNSUPPORTED_EXTENSION; + return 0; + } + /* Set flag to expect CertificateStatus message */ + s->tlsext_status_expected = 1; + } +# ifndef OPENSSL_NO_NEXTPROTONEG + else if (type == TLSEXT_TYPE_next_proto_neg && + s->s3->tmp.finish_md_len == 0) { + unsigned char *selected; + unsigned char selected_len; + + /* We must have requested it. */ + if (s->ctx->next_proto_select_cb == NULL) { + *al = TLS1_AD_UNSUPPORTED_EXTENSION; + return 0; + } + /* The data must be valid */ + if (!ssl_next_proto_validate(data, size)) { + *al = TLS1_AD_DECODE_ERROR; + return 0; + } + if (s-> + ctx->next_proto_select_cb(s, &selected, &selected_len, data, + size, + s->ctx->next_proto_select_cb_arg) != + SSL_TLSEXT_ERR_OK) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->next_proto_negotiated = OPENSSL_malloc(selected_len); + if (!s->next_proto_negotiated) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + memcpy(s->next_proto_negotiated, selected, selected_len); + s->next_proto_negotiated_len = selected_len; + s->s3->next_proto_neg_seen = 1; + } +# endif + else if (type == TLSEXT_TYPE_renegotiate) { + if (!ssl_parse_serverhello_renegotiate_ext(s, data, size, al)) + return 0; + renegotiate_seen = 1; + } +# ifndef OPENSSL_NO_HEARTBEATS + else if (type == TLSEXT_TYPE_heartbeat) { + switch (data[0]) { + case 0x01: /* Server allows us to send HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + break; + case 0x02: /* Server doesn't accept HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_SEND_REQUESTS; + break; + default: + *al = SSL_AD_ILLEGAL_PARAMETER; + return 0; + } + } +# endif +# ifndef OPENSSL_NO_SRTP + else if (SSL_IS_DTLS(s) && type == TLSEXT_TYPE_use_srtp) { + if (ssl_parse_serverhello_use_srtp_ext(s, data, size, al)) + return 0; + } +# endif + + data += size; + } + + if (data != d + n) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + if (!s->hit && tlsext_servername == 1) { + if (s->tlsext_hostname) { + if (s->session->tlsext_hostname == NULL) { + s->session->tlsext_hostname = BUF_strdup(s->tlsext_hostname); + if (!s->session->tlsext_hostname) { + *al = SSL_AD_UNRECOGNIZED_NAME; + return 0; + } + } else { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + } + } + + *p = data; + + ri_check: + + /* + * Determine if we need to see RI. Strictly speaking if we want to avoid + * an attack we should *always* see RI even on initial server hello + * because the client doesn't see any renegotiation during an attack. + * However this would mean we could not connect to any server which + * doesn't support RI so for the immediate future tolerate RI absence on + * initial connect only. + */ + if (!renegotiate_seen && !(s->options & SSL_OP_LEGACY_SERVER_CONNECT) + && !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + *al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + return 0; + } + + return 1; +} +",0,"int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d, + int n, int *al) +{ + unsigned short length; + unsigned short type; + unsigned short size; + unsigned char *data = *p; + int tlsext_servername = 0; + int renegotiate_seen = 0; + +# ifndef OPENSSL_NO_NEXTPROTONEG + s->s3->next_proto_neg_seen = 0; +# endif + s->tlsext_ticket_expected = 0; + +# ifndef OPENSSL_NO_HEARTBEATS + s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED | + SSL_TLSEXT_HB_DONT_SEND_REQUESTS); +# endif + + if ((d + n) - data <= 2) + goto ri_check; + + n2s(data, length); + if ((d + n) - data != length) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + while ((d + n) - data >= 4) { + n2s(data, type); + n2s(data, size); + + if ((d + n) - data < size) + goto ri_check; + + if (s->tlsext_debug_cb) + s->tlsext_debug_cb(s, 1, type, data, size, s->tlsext_debug_arg); + + if (type == TLSEXT_TYPE_server_name) { + if (s->tlsext_hostname == NULL || size > 0) { + *al = TLS1_AD_UNRECOGNIZED_NAME; + return 0; + } + tlsext_servername = 1; + } +# ifndef OPENSSL_NO_EC + else if (type == TLSEXT_TYPE_ec_point_formats) { + unsigned char *sdata = data; + int ecpointformatlist_length = *(sdata++); + + if (ecpointformatlist_length != size - 1 || + ecpointformatlist_length < 1) { + *al = TLS1_AD_DECODE_ERROR; + return 0; + } + if (!s->hit) { + s->session->tlsext_ecpointformatlist_length = 0; + if (s->session->tlsext_ecpointformatlist != NULL) + OPENSSL_free(s->session->tlsext_ecpointformatlist); + if ((s->session->tlsext_ecpointformatlist = + OPENSSL_malloc(ecpointformatlist_length)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->session->tlsext_ecpointformatlist_length = + ecpointformatlist_length; + memcpy(s->session->tlsext_ecpointformatlist, sdata, + ecpointformatlist_length); + } +# if 0 + fprintf(stderr, + ""ssl_parse_serverhello_tlsext s->session->tlsext_ecpointformatlist ""); + sdata = s->session->tlsext_ecpointformatlist; + for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) + fprintf(stderr, ""%i "", *(sdata++)); + fprintf(stderr, ""\n""); +# endif + } +# endif /* OPENSSL_NO_EC */ + + else if (type == TLSEXT_TYPE_session_ticket) { + if (s->tls_session_ticket_ext_cb && + !s->tls_session_ticket_ext_cb(s, data, size, + s->tls_session_ticket_ext_cb_arg)) + { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + if ((SSL_get_options(s) & SSL_OP_NO_TICKET) + || (size > 0)) { + *al = TLS1_AD_UNSUPPORTED_EXTENSION; + return 0; + } + s->tlsext_ticket_expected = 1; + } +# ifdef TLSEXT_TYPE_opaque_prf_input + else if (type == TLSEXT_TYPE_opaque_prf_input && + s->version != DTLS1_VERSION) { + unsigned char *sdata = data; + + if (size < 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + n2s(sdata, s->s3->server_opaque_prf_input_len); + if (s->s3->server_opaque_prf_input_len != size - 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + if (s->s3->server_opaque_prf_input != NULL) { + /* shouldn't really happen */ + OPENSSL_free(s->s3->server_opaque_prf_input); + } + if (s->s3->server_opaque_prf_input_len == 0) { + /* dummy byte just to get non-NULL */ + s->s3->server_opaque_prf_input = OPENSSL_malloc(1); + } else { + s->s3->server_opaque_prf_input = + BUF_memdup(sdata, s->s3->server_opaque_prf_input_len); + } + + if (s->s3->server_opaque_prf_input == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + } +# endif + else if (type == TLSEXT_TYPE_status_request && + s->version != DTLS1_VERSION) { + /* + * MUST be empty and only sent if we've requested a status + * request message. + */ + if ((s->tlsext_status_type == -1) || (size > 0)) { + *al = TLS1_AD_UNSUPPORTED_EXTENSION; + return 0; + } + /* Set flag to expect CertificateStatus message */ + s->tlsext_status_expected = 1; + } +# ifndef OPENSSL_NO_NEXTPROTONEG + else if (type == TLSEXT_TYPE_next_proto_neg && + s->s3->tmp.finish_md_len == 0) { + unsigned char *selected; + unsigned char selected_len; + + /* We must have requested it. */ + if (s->ctx->next_proto_select_cb == NULL) { + *al = TLS1_AD_UNSUPPORTED_EXTENSION; + return 0; + } + /* The data must be valid */ + if (!ssl_next_proto_validate(data, size)) { + *al = TLS1_AD_DECODE_ERROR; + return 0; + } + if (s-> + ctx->next_proto_select_cb(s, &selected, &selected_len, data, + size, + s->ctx->next_proto_select_cb_arg) != + SSL_TLSEXT_ERR_OK) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->next_proto_negotiated = OPENSSL_malloc(selected_len); + if (!s->next_proto_negotiated) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + memcpy(s->next_proto_negotiated, selected, selected_len); + s->next_proto_negotiated_len = selected_len; + s->s3->next_proto_neg_seen = 1; + } +# endif + else if (type == TLSEXT_TYPE_renegotiate) { + if (!ssl_parse_serverhello_renegotiate_ext(s, data, size, al)) + return 0; + renegotiate_seen = 1; + } +# ifndef OPENSSL_NO_HEARTBEATS + else if (type == TLSEXT_TYPE_heartbeat) { + switch (data[0]) { + case 0x01: /* Server allows us to send HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + break; + case 0x02: /* Server doesn't accept HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_SEND_REQUESTS; + break; + default: + *al = SSL_AD_ILLEGAL_PARAMETER; + return 0; + } + } +# endif +# ifndef OPENSSL_NO_SRTP + else if (SSL_IS_DTLS(s) && type == TLSEXT_TYPE_use_srtp) { + if (ssl_parse_serverhello_use_srtp_ext(s, data, size, al)) + return 0; + } +# endif + + data += size; + } + + if (data != d + n) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + if (!s->hit && tlsext_servername == 1) { + if (s->tlsext_hostname) { + if (s->session->tlsext_hostname == NULL) { + s->session->tlsext_hostname = BUF_strdup(s->tlsext_hostname); + if (!s->session->tlsext_hostname) { + *al = SSL_AD_UNRECOGNIZED_NAME; + return 0; + } + } else { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + } + } + + *p = data; + + ri_check: + + /* + * Determine if we need to see RI. Strictly speaking if we want to avoid + * an attack we should *always* see RI even on initial server hello + * because the client doesn't see any renegotiation during an attack. + * However this would mean we could not connect to any server which + * doesn't support RI so for the immediate future tolerate RI absence on + * initial connect only. + */ + if (!renegotiate_seen && !(s->options & SSL_OP_LEGACY_SERVER_CONNECT) + && !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + *al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + return 0; + } + + return 1; +} +","@@ -1284,6 +1284,23 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + size -= 2; + if (dsize > size) + goto err; ++ ++ /* ++ * We remove any OCSP_RESPIDs from a previous handshake ++ * to prevent unbounded memory growth - CVE-2016-6304 ++ */ ++ sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, ++ OCSP_RESPID_free); ++ if (dsize > 0) { ++ s->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null(); ++ if (s->tlsext_ocsp_ids == NULL) { ++ *al = SSL_AD_INTERNAL_ERROR; ++ return 0; ++ } ++ } else { ++ s->tlsext_ocsp_ids = NULL; ++ } ++ + while (dsize > 0) { + OCSP_RESPID *id; + int idsize; +@@ -1303,13 +1320,6 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + OCSP_RESPID_free(id); + goto err; + } +- if (!s->tlsext_ocsp_ids +- && !(s->tlsext_ocsp_ids = +- sk_OCSP_RESPID_new_null())) { +- OCSP_RESPID_free(id); +- *al = SSL_AD_INTERNAL_ERROR; +- return 0; +- } + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR;",2156,2392,4096 +18282,"int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, + const char **argv) { + + struct passwd *pw = NULL, pw_s; + const char *user = NULL; + + cfg_t cfg_st; + cfg_t *cfg = &cfg_st; + char buffer[BUFSIZE]; + char *buf = NULL; + char *authfile_dir; + size_t authfile_dir_len; + int pgu_ret, gpn_ret; + int retval = PAM_IGNORE; + device_t *devices = NULL; + unsigned n_devices = 0; + int openasuser; + int should_free_origin = 0; + int should_free_appid = 0; + int should_free_auth_file = 0; + int should_free_authpending_file = 0; + + parse_cfg(flags, argc, argv, cfg); + + if (!cfg->origin) { + strcpy(buffer, DEFAULT_ORIGIN_PREFIX); + + if (gethostname(buffer + strlen(DEFAULT_ORIGIN_PREFIX), + BUFSIZE - strlen(DEFAULT_ORIGIN_PREFIX)) == -1) { + DBG(""Unable to get host name""); + goto done; + } + DBG(""Origin not specified, using \""%s\"""", buffer); + cfg->origin = strdup(buffer); + if (!cfg->origin) { + DBG(""Unable to allocate memory""); + goto done; + } else { + should_free_origin = 1; + } + } + + if (!cfg->appid) { + DBG(""Appid not specified, using the same value of origin (%s)"", + cfg->origin); + cfg->appid = strdup(cfg->origin); + if (!cfg->appid) { + DBG(""Unable to allocate memory"") + goto done; + } else { + should_free_appid = 1; + } + } + + if (cfg->max_devs == 0) { + DBG(""Maximum devices number not set. Using default (%d)"", MAX_DEVS); + cfg->max_devs = MAX_DEVS; + } + + devices = malloc(sizeof(device_t) * cfg->max_devs); + if (!devices) { + DBG(""Unable to allocate memory""); + retval = PAM_IGNORE; + goto done; + } + + pgu_ret = pam_get_user(pamh, &user, NULL); + if (pgu_ret != PAM_SUCCESS || user == NULL) { + DBG(""Unable to access user %s"", user); + retval = PAM_CONV_ERR; + goto done; + } + + DBG(""Requesting authentication for user %s"", user); + + gpn_ret = getpwnam_r(user, &pw_s, buffer, sizeof(buffer), &pw); + if (gpn_ret != 0 || pw == NULL || pw->pw_dir == NULL || + pw->pw_dir[0] != '/') { + DBG(""Unable to retrieve credentials for user %s, (%s)"", user, + strerror(errno)); + retval = PAM_USER_UNKNOWN; + goto done; + } + + DBG(""Found user %s"", user); + DBG(""Home directory for %s is %s"", user, pw->pw_dir); + + if (!cfg->auth_file) { + buf = NULL; + authfile_dir = secure_getenv(DEFAULT_AUTHFILE_DIR_VAR); + if (!authfile_dir) { + DBG(""Variable %s is not set. Using default value ($HOME/.config/)"", + DEFAULT_AUTHFILE_DIR_VAR); + authfile_dir_len = + strlen(pw->pw_dir) + strlen(""/.config"") + strlen(DEFAULT_AUTHFILE) + 1; + buf = malloc(sizeof(char) * (authfile_dir_len)); + + if (!buf) { + DBG(""Unable to allocate memory""); + retval = PAM_IGNORE; + goto done; + } + + snprintf(buf, authfile_dir_len, + ""%s/.config%s"", pw->pw_dir, DEFAULT_AUTHFILE); + } else { + DBG(""Variable %s set to %s"", DEFAULT_AUTHFILE_DIR_VAR, authfile_dir); + authfile_dir_len = strlen(authfile_dir) + strlen(DEFAULT_AUTHFILE) + 1; + buf = malloc(sizeof(char) * (authfile_dir_len)); + + if (!buf) { + DBG(""Unable to allocate memory""); + retval = PAM_IGNORE; + goto done; + } + + snprintf(buf, authfile_dir_len, + ""%s%s"", authfile_dir, DEFAULT_AUTHFILE); + } + + DBG(""Using default authentication file %s"", buf); + + cfg->auth_file = buf; /* cfg takes ownership */ + should_free_auth_file = 1; + buf = NULL; + } else { + DBG(""Using authentication file %s"", cfg->auth_file); + } + + openasuser = geteuid() == 0 && cfg->openasuser; + if (openasuser) { + if (seteuid(pw_s.pw_uid)) { + DBG(""Unable to switch user to uid %i"", pw_s.pw_uid); + retval = PAM_IGNORE; + goto done; + } + DBG(""Switched to uid %i"", pw_s.pw_uid); + } + retval = get_devices_from_authfile(cfg->auth_file, user, cfg->max_devs, + cfg->debug, cfg->debug_file, + devices, &n_devices); + if (openasuser) { + if (seteuid(0)) { + DBG(""Unable to switch back to uid 0""); + retval = PAM_IGNORE; + goto done; + } + DBG(""Switched back to uid 0""); + } + + if (retval != 1) { + n_devices = 0; + } + + if (n_devices == 0) { + if (cfg->nouserok) { + DBG(""Found no devices but nouserok specified. Skipping authentication""); + retval = PAM_SUCCESS; + goto done; + } else if (retval != 1) { + DBG(""Unable to get devices from file %s"", cfg->auth_file); + retval = PAM_AUTHINFO_UNAVAIL; + goto done; + } else { + DBG(""Found no devices. Aborting.""); + retval = PAM_AUTHINFO_UNAVAIL; + goto done; + } + } + + if (!cfg->authpending_file) { + int actual_size = snprintf(buffer, BUFSIZE, DEFAULT_AUTHPENDING_FILE_PATH, getuid()); + if (actual_size >= 0 && actual_size < BUFSIZE) { + cfg->authpending_file = strdup(buffer); + } + if (!cfg->authpending_file) { + DBG(""Unable to allocate memory for the authpending_file, touch request notifications will not be emitted""); + } else { + should_free_authpending_file = 1; + } + } else { + if (strlen(cfg->authpending_file) == 0) { + DBG(""authpending_file is set to an empty value, touch request notifications will be disabled""); + cfg->authpending_file = NULL; + } + } + + int authpending_file_descriptor = -1; + if (cfg->authpending_file) { + DBG(""Using file '%s' for emitting touch request notifications"", cfg->authpending_file); + + authpending_file_descriptor = open(cfg->authpending_file, O_RDONLY | O_CREAT, 0664); + if (authpending_file_descriptor < 0) { + DBG(""Unable to emit 'authentication started' notification by opening the file '%s', (%s)"", + cfg->authpending_file, strerror(errno)); + } + } + + if (cfg->manual == 0) { + if (cfg->interactive) { + converse(pamh, PAM_PROMPT_ECHO_ON, + cfg->prompt != NULL ? cfg->prompt : DEFAULT_PROMPT); + } + + retval = do_authentication(cfg, devices, n_devices, pamh); + } else { + retval = do_manual_authentication(cfg, devices, n_devices, pamh); + } + + if (authpending_file_descriptor >= 0) { + if (close(authpending_file_descriptor) < 0) { + DBG(""Unable to emit 'authentication stopped' notification by closing the file '%s', (%s)"", + cfg->authpending_file, strerror(errno)); + } + } + + if (retval != 1) { + DBG(""do_authentication returned %d"", retval); + retval = PAM_AUTH_ERR; + goto done; + } + + retval = PAM_SUCCESS; + +done: + free_devices(devices, n_devices); + + if (buf) { + free(buf); + buf = NULL; + } + + if (should_free_origin) { + free((char *) cfg->origin); + cfg->origin = NULL; + } + + if (should_free_appid) { + free((char *) cfg->appid); + cfg->appid = NULL; + } + + if (should_free_auth_file) { + free((char *) cfg->auth_file); + cfg->auth_file = NULL; + } + + if (should_free_authpending_file) { + free((char *) cfg->authpending_file); + cfg->authpending_file = NULL; + } + + if (cfg->alwaysok && retval != PAM_SUCCESS) { + DBG(""alwaysok needed (otherwise return with %d)"", retval); + retval = PAM_SUCCESS; + } + DBG(""done. [%s]"", pam_strerror(pamh, retval)); + + return retval; + } +",1,"int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, + const char **argv) { + + struct passwd *pw = NULL, pw_s; + const char *user = NULL; + + cfg_t cfg_st; + cfg_t *cfg = &cfg_st; + char buffer[BUFSIZE]; + char *buf = NULL; + char *authfile_dir; + size_t authfile_dir_len; + int pgu_ret, gpn_ret; + int retval = PAM_IGNORE; + device_t *devices = NULL; + unsigned n_devices = 0; + int openasuser; + int should_free_origin = 0; + int should_free_appid = 0; + int should_free_auth_file = 0; + int should_free_authpending_file = 0; + + parse_cfg(flags, argc, argv, cfg); + + if (!cfg->origin) { + strcpy(buffer, DEFAULT_ORIGIN_PREFIX); + + if (gethostname(buffer + strlen(DEFAULT_ORIGIN_PREFIX), + BUFSIZE - strlen(DEFAULT_ORIGIN_PREFIX)) == -1) { + DBG(""Unable to get host name""); + goto done; + } + DBG(""Origin not specified, using \""%s\"""", buffer); + cfg->origin = strdup(buffer); + if (!cfg->origin) { + DBG(""Unable to allocate memory""); + goto done; + } else { + should_free_origin = 1; + } + } + + if (!cfg->appid) { + DBG(""Appid not specified, using the same value of origin (%s)"", + cfg->origin); + cfg->appid = strdup(cfg->origin); + if (!cfg->appid) { + DBG(""Unable to allocate memory"") + goto done; + } else { + should_free_appid = 1; + } + } + + if (cfg->max_devs == 0) { + DBG(""Maximum devices number not set. Using default (%d)"", MAX_DEVS); + cfg->max_devs = MAX_DEVS; + } + + devices = malloc(sizeof(device_t) * cfg->max_devs); + if (!devices) { + DBG(""Unable to allocate memory""); + retval = PAM_IGNORE; + goto done; + } + + pgu_ret = pam_get_user(pamh, &user, NULL); + if (pgu_ret != PAM_SUCCESS || user == NULL) { + DBG(""Unable to access user %s"", user); + retval = PAM_CONV_ERR; + goto done; + } + + DBG(""Requesting authentication for user %s"", user); + + gpn_ret = getpwnam_r(user, &pw_s, buffer, sizeof(buffer), &pw); + if (gpn_ret != 0 || pw == NULL || pw->pw_dir == NULL || + pw->pw_dir[0] != '/') { + DBG(""Unable to retrieve credentials for user %s, (%s)"", user, + strerror(errno)); + retval = PAM_USER_UNKNOWN; + goto done; + } + + DBG(""Found user %s"", user); + DBG(""Home directory for %s is %s"", user, pw->pw_dir); + + if (!cfg->auth_file) { + buf = NULL; + authfile_dir = secure_getenv(DEFAULT_AUTHFILE_DIR_VAR); + if (!authfile_dir) { + DBG(""Variable %s is not set. Using default value ($HOME/.config/)"", + DEFAULT_AUTHFILE_DIR_VAR); + authfile_dir_len = + strlen(pw->pw_dir) + strlen(""/.config"") + strlen(DEFAULT_AUTHFILE) + 1; + buf = malloc(sizeof(char) * (authfile_dir_len)); + + if (!buf) { + DBG(""Unable to allocate memory""); + retval = PAM_IGNORE; + goto done; + } + + snprintf(buf, authfile_dir_len, + ""%s/.config%s"", pw->pw_dir, DEFAULT_AUTHFILE); + } else { + DBG(""Variable %s set to %s"", DEFAULT_AUTHFILE_DIR_VAR, authfile_dir); + authfile_dir_len = strlen(authfile_dir) + strlen(DEFAULT_AUTHFILE) + 1; + buf = malloc(sizeof(char) * (authfile_dir_len)); + + if (!buf) { + DBG(""Unable to allocate memory""); + retval = PAM_IGNORE; + goto done; + } + + snprintf(buf, authfile_dir_len, + ""%s%s"", authfile_dir, DEFAULT_AUTHFILE); + } + + DBG(""Using default authentication file %s"", buf); + + cfg->auth_file = buf; /* cfg takes ownership */ + should_free_auth_file = 1; + buf = NULL; + } else { + DBG(""Using authentication file %s"", cfg->auth_file); + } + + openasuser = geteuid() == 0 && cfg->openasuser; + if (openasuser) { + if (seteuid(pw_s.pw_uid)) { + DBG(""Unable to switch user to uid %i"", pw_s.pw_uid); + retval = PAM_IGNORE; + goto done; + } + DBG(""Switched to uid %i"", pw_s.pw_uid); + } + retval = get_devices_from_authfile(cfg->auth_file, user, cfg->max_devs, + cfg->debug, cfg->debug_file, + devices, &n_devices); + if (openasuser) { + if (seteuid(0)) { + DBG(""Unable to switch back to uid 0""); + retval = PAM_IGNORE; + goto done; + } + DBG(""Switched back to uid 0""); + } + + if (retval != 1) { + n_devices = 0; + } + + if (n_devices == 0) { + if (cfg->nouserok) { + DBG(""Found no devices but nouserok specified. Skipping authentication""); + retval = PAM_SUCCESS; + goto done; + } else if (retval != 1) { + DBG(""Unable to get devices from file %s"", cfg->auth_file); + retval = PAM_AUTHINFO_UNAVAIL; + goto done; + } else { + DBG(""Found no devices. Aborting.""); + retval = PAM_AUTHINFO_UNAVAIL; + goto done; + } + } + + if (!cfg->authpending_file) { + int actual_size = snprintf(buffer, BUFSIZE, DEFAULT_AUTHPENDING_FILE_PATH, getuid()); + if (actual_size >= 0 && actual_size < BUFSIZE) { + cfg->authpending_file = strdup(buffer); + } + if (!cfg->authpending_file) { + DBG(""Unable to allocate memory for the authpending_file, touch request notifications will not be emitted""); + } else { + should_free_authpending_file = 1; + } + } else { + if (strlen(cfg->authpending_file) == 0) { + DBG(""authpending_file is set to an empty value, touch request notifications will be disabled""); + cfg->authpending_file = NULL; + } + } + + int authpending_file_descriptor = -1; + if (cfg->authpending_file) { + DBG(""Using file '%s' for emitting touch request notifications"", cfg->authpending_file); + + authpending_file_descriptor = + open(cfg->authpending_file, O_RDONLY | O_CREAT | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY, 0664); + if (authpending_file_descriptor < 0) { + DBG(""Unable to emit 'authentication started' notification by opening the file '%s', (%s)"", + cfg->authpending_file, strerror(errno)); + } + } + + if (cfg->manual == 0) { + if (cfg->interactive) { + converse(pamh, PAM_PROMPT_ECHO_ON, + cfg->prompt != NULL ? cfg->prompt : DEFAULT_PROMPT); + } + + retval = do_authentication(cfg, devices, n_devices, pamh); + } else { + retval = do_manual_authentication(cfg, devices, n_devices, pamh); + } + + if (authpending_file_descriptor >= 0) { + if (close(authpending_file_descriptor) < 0) { + DBG(""Unable to emit 'authentication stopped' notification by closing the file '%s', (%s)"", + cfg->authpending_file, strerror(errno)); + } + } + + if (retval != 1) { + DBG(""do_authentication returned %d"", retval); + retval = PAM_AUTH_ERR; + goto done; + } + + retval = PAM_SUCCESS; + +done: + free_devices(devices, n_devices); + + if (buf) { + free(buf); + buf = NULL; + } + + if (should_free_origin) { + free((char *) cfg->origin); + cfg->origin = NULL; + } + + if (should_free_appid) { + free((char *) cfg->appid); + cfg->appid = NULL; + } + + if (should_free_auth_file) { + free((char *) cfg->auth_file); + cfg->auth_file = NULL; + } + + if (should_free_authpending_file) { + free((char *) cfg->authpending_file); + cfg->authpending_file = NULL; + } + + if (cfg->alwaysok && retval != PAM_SUCCESS) { + DBG(""alwaysok needed (otherwise return with %d)"", retval); + retval = PAM_SUCCESS; + } + DBG(""done. [%s]"", pam_strerror(pamh, retval)); + + if (cfg->is_custom_debug_file) { + fclose(cfg->debug_file); + } + + return retval; + } +","@@ -1,5 +1,5 @@ + /* +- * Copyright (C) 2014-2018 Yubico AB - See COPYING ++ * Copyright (C) 2014-2019 Yubico AB - See COPYING + */ + + /* Define which PAM interfaces we provide */ +@@ -31,7 +31,11 @@ char *secure_getenv(const char *name) { + #endif + + static void parse_cfg(int flags, int argc, const char **argv, cfg_t *cfg) { ++ struct stat st; ++ FILE *file = NULL; ++ int fd = -1; + int i; ++ + memset(cfg, 0, sizeof(cfg_t)); + cfg->debug_file = stderr; + +@@ -76,14 +80,14 @@ static void parse_cfg(int flags, int argc, const char **argv, cfg_t *cfg) { + cfg->debug_file = (FILE *)-1; + } + else { +- struct stat st; +- FILE *file; +- if(lstat(filename, &st) == 0) { +- if(S_ISREG(st.st_mode)) { +- file = fopen(filename, ""a""); +- if(file != NULL) { +- cfg->debug_file = file; +- } ++ fd = open(filename, O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY); ++ if (fd >= 0 && (fstat(fd, &st) == 0) && S_ISREG(st.st_mode)) { ++ file = fdopen(fd, ""a""); ++ if(file != NULL) { ++ cfg->debug_file = file; ++ cfg->is_custom_debug_file = 1; ++ file = NULL; ++ fd = -1; + } + } + } +@@ -111,6 +115,12 @@ static void parse_cfg(int flags, int argc, const char **argv, cfg_t *cfg) { + D(cfg->debug_file, ""appid=%s"", cfg->appid ? cfg->appid : ""(null)""); + D(cfg->debug_file, ""prompt=%s"", cfg->prompt ? cfg->prompt : ""(null)""); + } ++ ++ if (fd != -1) ++ close(fd); ++ ++ if (file != NULL) ++ fclose(file); + } + + #ifdef DBG +@@ -317,7 +327,8 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, + DBG(""Using file '%s' for emitting touch request notifications"", cfg->authpending_file); + + // Open (or create) the authpending_file to indicate that we start waiting for a touch +- authpending_file_descriptor = open(cfg->authpending_file, O_RDONLY | O_CREAT, 0664); ++ authpending_file_descriptor = ++ open(cfg->authpending_file, O_RDONLY | O_CREAT | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY, 0664); + if (authpending_file_descriptor < 0) { + DBG(""Unable to emit 'authentication started' notification by opening the file '%s', (%s)"", + cfg->authpending_file, strerror(errno)); +@@ -385,6 +396,10 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, + } + DBG(""done. [%s]"", pam_strerror(pamh, retval)); + ++ if (cfg->is_custom_debug_file) { ++ fclose(cfg->debug_file); ++ } ++ + return retval; + } + ",1966,2202,4096 +7319,"static MagickBooleanType WritePSDImage(const ImageInfo *image_info, + Image *image) +{ + const char + *property; + + const StringInfo + *icc_profile; + + Image + *base_image, + *next_image; + + MagickBooleanType + status; + + PSDInfo + psd_info; + + register ssize_t + i; + + size_t + channel_size, + channelLength, + layer_count, + layer_info_size, + length, + num_channels, + packet_size, + rounded_layer_info_size; + + StringInfo + *bim_profile; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + packet_size=(size_t) (image->depth > 8 ? 6 : 3); + if (image->matte != MagickFalse) + packet_size+=image->depth > 8 ? 2 : 1; + psd_info.version=1; + if ((LocaleCompare(image_info->magick,""PSB"") == 0) || + (image->columns > 30000) || (image->rows > 30000)) + psd_info.version=2; + (void) WriteBlob(image,4,(const unsigned char *) ""8BPS""); + (void) WriteBlobMSBShort(image,psd_info.version); /* version */ + for (i=1; i <= 6; i++) + (void) WriteBlobByte(image, 0); /* 6 bytes of reserved */ + if (SetImageGray(image,&image->exception) != MagickFalse) + num_channels=(image->matte != MagickFalse ? 2UL : 1UL); + else + if ((image_info->type != TrueColorType) && (image_info->type != + TrueColorMatteType) && (image->storage_class == PseudoClass)) + num_channels=(image->matte != MagickFalse ? 2UL : 1UL); + else + { + if (image->storage_class == PseudoClass) + (void) SetImageStorageClass(image,DirectClass); + if (image->colorspace != CMYKColorspace) + num_channels=(image->matte != MagickFalse ? 4UL : 3UL); + else + num_channels=(image->matte != MagickFalse ? 5UL : 4UL); + } + (void) WriteBlobMSBShort(image,(unsigned short) num_channels); + (void) WriteBlobMSBLong(image,(unsigned int) image->rows); + (void) WriteBlobMSBLong(image,(unsigned int) image->columns); + if (IsGrayImage(image,&image->exception) != MagickFalse) + { + MagickBooleanType + monochrome; + + /* + Write depth & mode. + */ + monochrome=IsMonochromeImage(image,&image->exception) && + (image->depth == 1) ? MagickTrue : MagickFalse; + (void) WriteBlobMSBShort(image,(unsigned short) + (monochrome != MagickFalse ? 1 : image->depth > 8 ? 16 : 8)); + (void) WriteBlobMSBShort(image,(unsigned short) + (monochrome != MagickFalse ? BitmapMode : GrayscaleMode)); + } + else + { + (void) WriteBlobMSBShort(image,(unsigned short) (image->storage_class == + PseudoClass ? 8 : image->depth > 8 ? 16 : 8)); + if (((image_info->colorspace != UndefinedColorspace) || + (image->colorspace != CMYKColorspace)) && + (image_info->colorspace != CMYKColorspace)) + { + (void) TransformImageColorspace(image,sRGBColorspace); + (void) WriteBlobMSBShort(image,(unsigned short) + (image->storage_class == PseudoClass ? IndexedMode : RGBMode)); + } + else + { + if (image->colorspace != CMYKColorspace) + (void) TransformImageColorspace(image,CMYKColorspace); + (void) WriteBlobMSBShort(image,CMYKMode); + } + } + if ((IsGrayImage(image,&image->exception) != MagickFalse) || + (image->storage_class == DirectClass) || (image->colors > 256)) + (void) WriteBlobMSBLong(image,0); + else + { + /* + Write PSD raster colormap. + */ + (void) WriteBlobMSBLong(image,768); + for (i=0; i < (ssize_t) image->colors; i++) + (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].red)); + for ( ; i < 256; i++) + (void) WriteBlobByte(image,0); + for (i=0; i < (ssize_t) image->colors; i++) + (void) WriteBlobByte(image,ScaleQuantumToChar( + image->colormap[i].green)); + for ( ; i < 256; i++) + (void) WriteBlobByte(image,0); + for (i=0; i < (ssize_t) image->colors; i++) + (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].blue)); + for ( ; i < 256; i++) + (void) WriteBlobByte(image,0); + } + /* + Image resource block. + */ + length=28; /* 0x03EB */ + bim_profile=(StringInfo *) GetImageProfile(image,""8bim""); + icc_profile=GetImageProfile(image,""icc""); + if (bim_profile != (StringInfo *) NULL) + { + bim_profile=CloneStringInfo(bim_profile); + if (icc_profile != (StringInfo *) NULL) + RemoveICCProfileFromResourceBlock(bim_profile); + RemoveResolutionFromResourceBlock(bim_profile); + length+=PSDQuantum(GetStringInfoLength(bim_profile)); + } + if (icc_profile != (const StringInfo *) NULL) + length+=PSDQuantum(GetStringInfoLength(icc_profile))+12; + (void) WriteBlobMSBLong(image,(unsigned int) length); + WriteResolutionResourceBlock(image); + if (bim_profile != (StringInfo *) NULL) + { + (void) WriteBlob(image,GetStringInfoLength(bim_profile), + GetStringInfoDatum(bim_profile)); + bim_profile=DestroyStringInfo(bim_profile); + } + if (icc_profile != (StringInfo *) NULL) + { + (void) WriteBlob(image,4,(const unsigned char *) ""8BIM""); + (void) WriteBlobMSBShort(image,0x0000040F); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBLong(image,(unsigned int) GetStringInfoLength( + icc_profile)); + (void) WriteBlob(image,GetStringInfoLength(icc_profile), + GetStringInfoDatum(icc_profile)); + if ((MagickOffsetType) GetStringInfoLength(icc_profile) != + PSDQuantum(GetStringInfoLength(icc_profile))) + (void) WriteBlobByte(image,0); + } + layer_count=0; + layer_info_size=2; + base_image=GetNextImageInList(image); + if (base_image == (Image *) NULL) + base_image=image; + next_image=base_image; + while (next_image != (Image *) NULL) + { + packet_size=next_image->depth > 8 ? 2UL : 1UL; + if (IsGrayImage(next_image,&image->exception) != MagickFalse) + num_channels=next_image->matte != MagickFalse ? 2UL : 1UL; + else + if (next_image->storage_class == PseudoClass) + num_channels=next_image->matte != MagickFalse ? 2UL : 1UL; + else + if (next_image->colorspace != CMYKColorspace) + num_channels=next_image->matte != MagickFalse ? 4UL : 3UL; + else + num_channels=next_image->matte != MagickFalse ? 5UL : 4UL; + channelLength=(size_t) (next_image->columns*next_image->rows*packet_size+2); + layer_info_size+=(size_t) (4*4+2+num_channels*6+(psd_info.version == 1 ? 8 : + 16)+4*1+4+num_channels*channelLength); + property=(const char *) GetImageProperty(next_image,""label""); + if (property == (const char *) NULL) + layer_info_size+=16; + else + { + size_t + length; + + length=strlen(property); + layer_info_size+=8+length+(4-(length % 4)); + } + layer_count++; + next_image=GetNextImageInList(next_image); + } + if (layer_count == 0) + (void) SetPSDSize(&psd_info,image,0); + else + { + CompressionType + compression; + + (void) SetPSDSize(&psd_info,image,layer_info_size+ + (psd_info.version == 1 ? 8 : 16)); + if ((layer_info_size/2) != ((layer_info_size+1)/2)) + rounded_layer_info_size=layer_info_size+1; + else + rounded_layer_info_size=layer_info_size; + (void) SetPSDSize(&psd_info,image,rounded_layer_info_size); + if (image->matte != MagickFalse) + (void) WriteBlobMSBShort(image,-(unsigned short) layer_count); + else + (void) WriteBlobMSBShort(image,(unsigned short) layer_count); + layer_count=1; + compression=base_image->compression; + for (next_image=base_image; next_image != NULL; ) + { + next_image->compression=NoCompression; + (void) WriteBlobMSBLong(image,(unsigned int) next_image->page.y); + (void) WriteBlobMSBLong(image,(unsigned int) next_image->page.x); + (void) WriteBlobMSBLong(image,(unsigned int) (next_image->page.y+ + next_image->rows)); + (void) WriteBlobMSBLong(image,(unsigned int) (next_image->page.x+ + next_image->columns)); + packet_size=next_image->depth > 8 ? 2UL : 1UL; + channel_size=(unsigned int) ((packet_size*next_image->rows* + next_image->columns)+2); + if ((IsGrayImage(next_image,&image->exception) != MagickFalse) || + (next_image->storage_class == PseudoClass)) + { + (void) WriteBlobMSBShort(image,(unsigned short) + (next_image->matte != MagickFalse ? 2 : 1)); + (void) WriteBlobMSBShort(image,0); + (void) SetPSDSize(&psd_info,image,channel_size); + if (next_image->matte != MagickFalse) + { + (void) WriteBlobMSBShort(image,(unsigned short) -1); + (void) SetPSDSize(&psd_info,image,channel_size); + } + } + else + if (next_image->colorspace != CMYKColorspace) + { + (void) WriteBlobMSBShort(image,(unsigned short) + (next_image->matte != MagickFalse ? 4 : 3)); + (void) WriteBlobMSBShort(image,0); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,1); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,2); + (void) SetPSDSize(&psd_info,image,channel_size); + if (next_image->matte!= MagickFalse ) + { + (void) WriteBlobMSBShort(image,(unsigned short) -1); + (void) SetPSDSize(&psd_info,image,channel_size); + } + } + else + { + (void) WriteBlobMSBShort(image,(unsigned short) + (next_image->matte ? 5 : 4)); + (void) WriteBlobMSBShort(image,0); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,1); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,2); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,3); + (void) SetPSDSize(&psd_info,image,channel_size); + if (next_image->matte) + { + (void) WriteBlobMSBShort(image,(unsigned short) -1); + (void) SetPSDSize(&psd_info,image,channel_size); + } + } + (void) WriteBlob(image,4,(const unsigned char *) ""8BIM""); + (void) WriteBlob(image,4,(const unsigned char *) + CompositeOperatorToPSDBlendMode(next_image->compose)); + (void) WriteBlobByte(image,255); /* layer opacity */ + (void) WriteBlobByte(image,0); + (void) WriteBlobByte(image,next_image->compose==NoCompositeOp ? + 1 << 0x02 : 1); /* layer properties - visible, etc. */ + (void) WriteBlobByte(image,0); + property=(const char *) GetImageProperty(next_image,""label""); + if (property == (const char *) NULL) + { + char + layer_name[MaxTextExtent]; + + (void) WriteBlobMSBLong(image,16); + (void) WriteBlobMSBLong(image,0); + (void) WriteBlobMSBLong(image,0); + (void) FormatLocaleString(layer_name,MaxTextExtent,""L%04ld"",(long) + layer_count++); + WritePascalString(image,layer_name,4); + } + else + { + size_t + length; + + length=strlen(property); + (void) WriteBlobMSBLong(image,(unsigned int) (length+(4- + (length % 4))+8)); + (void) WriteBlobMSBLong(image,0); + (void) WriteBlobMSBLong(image,0); + WritePascalString(image,property,4); + } + next_image=GetNextImageInList(next_image); + } + /* + Now the image data! + */ + next_image=base_image; + while (next_image != NULL) + { + status=WriteImageChannels(&psd_info,image_info,image,next_image, + MagickTrue); + next_image=GetNextImageInList(next_image); + } + (void) WriteBlobMSBLong(image,0); /* user mask data */ + base_image->compression=compression; + } + /* + Write composite image. + */ + if (status != MagickFalse) + status=WriteImageChannels(&psd_info,image_info,image,image,MagickFalse); + (void) CloseBlob(image); + return(status); +} +",0,"static MagickBooleanType WritePSDImage(const ImageInfo *image_info, + Image *image) +{ + const char + *property; + + const StringInfo + *icc_profile; + + Image + *base_image, + *next_image; + + MagickBooleanType + status; + + PSDInfo + psd_info; + + register ssize_t + i; + + size_t + channel_size, + channelLength, + layer_count, + layer_info_size, + length, + num_channels, + packet_size, + rounded_layer_info_size; + + StringInfo + *bim_profile; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + packet_size=(size_t) (image->depth > 8 ? 6 : 3); + if (image->matte != MagickFalse) + packet_size+=image->depth > 8 ? 2 : 1; + psd_info.version=1; + if ((LocaleCompare(image_info->magick,""PSB"") == 0) || + (image->columns > 30000) || (image->rows > 30000)) + psd_info.version=2; + (void) WriteBlob(image,4,(const unsigned char *) ""8BPS""); + (void) WriteBlobMSBShort(image,psd_info.version); /* version */ + for (i=1; i <= 6; i++) + (void) WriteBlobByte(image, 0); /* 6 bytes of reserved */ + if (SetImageGray(image,&image->exception) != MagickFalse) + num_channels=(image->matte != MagickFalse ? 2UL : 1UL); + else + if ((image_info->type != TrueColorType) && (image_info->type != + TrueColorMatteType) && (image->storage_class == PseudoClass)) + num_channels=(image->matte != MagickFalse ? 2UL : 1UL); + else + { + if (image->storage_class == PseudoClass) + (void) SetImageStorageClass(image,DirectClass); + if (image->colorspace != CMYKColorspace) + num_channels=(image->matte != MagickFalse ? 4UL : 3UL); + else + num_channels=(image->matte != MagickFalse ? 5UL : 4UL); + } + (void) WriteBlobMSBShort(image,(unsigned short) num_channels); + (void) WriteBlobMSBLong(image,(unsigned int) image->rows); + (void) WriteBlobMSBLong(image,(unsigned int) image->columns); + if (IsGrayImage(image,&image->exception) != MagickFalse) + { + MagickBooleanType + monochrome; + + /* + Write depth & mode. + */ + monochrome=IsMonochromeImage(image,&image->exception) && + (image->depth == 1) ? MagickTrue : MagickFalse; + (void) WriteBlobMSBShort(image,(unsigned short) + (monochrome != MagickFalse ? 1 : image->depth > 8 ? 16 : 8)); + (void) WriteBlobMSBShort(image,(unsigned short) + (monochrome != MagickFalse ? BitmapMode : GrayscaleMode)); + } + else + { + (void) WriteBlobMSBShort(image,(unsigned short) (image->storage_class == + PseudoClass ? 8 : image->depth > 8 ? 16 : 8)); + if (((image_info->colorspace != UndefinedColorspace) || + (image->colorspace != CMYKColorspace)) && + (image_info->colorspace != CMYKColorspace)) + { + (void) TransformImageColorspace(image,sRGBColorspace); + (void) WriteBlobMSBShort(image,(unsigned short) + (image->storage_class == PseudoClass ? IndexedMode : RGBMode)); + } + else + { + if (image->colorspace != CMYKColorspace) + (void) TransformImageColorspace(image,CMYKColorspace); + (void) WriteBlobMSBShort(image,CMYKMode); + } + } + if ((IsGrayImage(image,&image->exception) != MagickFalse) || + (image->storage_class == DirectClass) || (image->colors > 256)) + (void) WriteBlobMSBLong(image,0); + else + { + /* + Write PSD raster colormap. + */ + (void) WriteBlobMSBLong(image,768); + for (i=0; i < (ssize_t) image->colors; i++) + (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].red)); + for ( ; i < 256; i++) + (void) WriteBlobByte(image,0); + for (i=0; i < (ssize_t) image->colors; i++) + (void) WriteBlobByte(image,ScaleQuantumToChar( + image->colormap[i].green)); + for ( ; i < 256; i++) + (void) WriteBlobByte(image,0); + for (i=0; i < (ssize_t) image->colors; i++) + (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].blue)); + for ( ; i < 256; i++) + (void) WriteBlobByte(image,0); + } + /* + Image resource block. + */ + length=28; /* 0x03EB */ + bim_profile=(StringInfo *) GetImageProfile(image,""8bim""); + icc_profile=GetImageProfile(image,""icc""); + if (bim_profile != (StringInfo *) NULL) + { + bim_profile=CloneStringInfo(bim_profile); + if (icc_profile != (StringInfo *) NULL) + RemoveICCProfileFromResourceBlock(bim_profile); + RemoveResolutionFromResourceBlock(bim_profile); + length+=PSDQuantum(GetStringInfoLength(bim_profile)); + } + if (icc_profile != (const StringInfo *) NULL) + length+=PSDQuantum(GetStringInfoLength(icc_profile))+12; + (void) WriteBlobMSBLong(image,(unsigned int) length); + WriteResolutionResourceBlock(image); + if (bim_profile != (StringInfo *) NULL) + { + (void) WriteBlob(image,GetStringInfoLength(bim_profile), + GetStringInfoDatum(bim_profile)); + bim_profile=DestroyStringInfo(bim_profile); + } + if (icc_profile != (StringInfo *) NULL) + { + (void) WriteBlob(image,4,(const unsigned char *) ""8BIM""); + (void) WriteBlobMSBShort(image,0x0000040F); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBLong(image,(unsigned int) GetStringInfoLength( + icc_profile)); + (void) WriteBlob(image,GetStringInfoLength(icc_profile), + GetStringInfoDatum(icc_profile)); + if ((MagickOffsetType) GetStringInfoLength(icc_profile) != + PSDQuantum(GetStringInfoLength(icc_profile))) + (void) WriteBlobByte(image,0); + } + layer_count=0; + layer_info_size=2; + base_image=GetNextImageInList(image); + if (base_image == (Image *) NULL) + base_image=image; + next_image=base_image; + while (next_image != (Image *) NULL) + { + packet_size=next_image->depth > 8 ? 2UL : 1UL; + if (IsGrayImage(next_image,&image->exception) != MagickFalse) + num_channels=next_image->matte != MagickFalse ? 2UL : 1UL; + else + if (next_image->storage_class == PseudoClass) + num_channels=next_image->matte != MagickFalse ? 2UL : 1UL; + else + if (next_image->colorspace != CMYKColorspace) + num_channels=next_image->matte != MagickFalse ? 4UL : 3UL; + else + num_channels=next_image->matte != MagickFalse ? 5UL : 4UL; + channelLength=(size_t) (next_image->columns*next_image->rows*packet_size+2); + layer_info_size+=(size_t) (4*4+2+num_channels*6+(psd_info.version == 1 ? 8 : + 16)+4*1+4+num_channels*channelLength); + property=(const char *) GetImageProperty(next_image,""label""); + if (property == (const char *) NULL) + layer_info_size+=16; + else + { + size_t + length; + + length=strlen(property); + layer_info_size+=8+length+(4-(length % 4)); + } + layer_count++; + next_image=GetNextImageInList(next_image); + } + if (layer_count == 0) + (void) SetPSDSize(&psd_info,image,0); + else + { + CompressionType + compression; + + (void) SetPSDSize(&psd_info,image,layer_info_size+ + (psd_info.version == 1 ? 8 : 16)); + if ((layer_info_size/2) != ((layer_info_size+1)/2)) + rounded_layer_info_size=layer_info_size+1; + else + rounded_layer_info_size=layer_info_size; + (void) SetPSDSize(&psd_info,image,rounded_layer_info_size); + if (image->matte != MagickFalse) + (void) WriteBlobMSBShort(image,-(unsigned short) layer_count); + else + (void) WriteBlobMSBShort(image,(unsigned short) layer_count); + layer_count=1; + compression=base_image->compression; + for (next_image=base_image; next_image != NULL; ) + { + next_image->compression=NoCompression; + (void) WriteBlobMSBLong(image,(unsigned int) next_image->page.y); + (void) WriteBlobMSBLong(image,(unsigned int) next_image->page.x); + (void) WriteBlobMSBLong(image,(unsigned int) (next_image->page.y+ + next_image->rows)); + (void) WriteBlobMSBLong(image,(unsigned int) (next_image->page.x+ + next_image->columns)); + packet_size=next_image->depth > 8 ? 2UL : 1UL; + channel_size=(unsigned int) ((packet_size*next_image->rows* + next_image->columns)+2); + if ((IsGrayImage(next_image,&image->exception) != MagickFalse) || + (next_image->storage_class == PseudoClass)) + { + (void) WriteBlobMSBShort(image,(unsigned short) + (next_image->matte != MagickFalse ? 2 : 1)); + (void) WriteBlobMSBShort(image,0); + (void) SetPSDSize(&psd_info,image,channel_size); + if (next_image->matte != MagickFalse) + { + (void) WriteBlobMSBShort(image,(unsigned short) -1); + (void) SetPSDSize(&psd_info,image,channel_size); + } + } + else + if (next_image->colorspace != CMYKColorspace) + { + (void) WriteBlobMSBShort(image,(unsigned short) + (next_image->matte != MagickFalse ? 4 : 3)); + (void) WriteBlobMSBShort(image,0); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,1); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,2); + (void) SetPSDSize(&psd_info,image,channel_size); + if (next_image->matte!= MagickFalse ) + { + (void) WriteBlobMSBShort(image,(unsigned short) -1); + (void) SetPSDSize(&psd_info,image,channel_size); + } + } + else + { + (void) WriteBlobMSBShort(image,(unsigned short) + (next_image->matte ? 5 : 4)); + (void) WriteBlobMSBShort(image,0); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,1); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,2); + (void) SetPSDSize(&psd_info,image,channel_size); + (void) WriteBlobMSBShort(image,3); + (void) SetPSDSize(&psd_info,image,channel_size); + if (next_image->matte) + { + (void) WriteBlobMSBShort(image,(unsigned short) -1); + (void) SetPSDSize(&psd_info,image,channel_size); + } + } + (void) WriteBlob(image,4,(const unsigned char *) ""8BIM""); + (void) WriteBlob(image,4,(const unsigned char *) + CompositeOperatorToPSDBlendMode(next_image->compose)); + (void) WriteBlobByte(image,255); /* layer opacity */ + (void) WriteBlobByte(image,0); + (void) WriteBlobByte(image,next_image->compose==NoCompositeOp ? + 1 << 0x02 : 1); /* layer properties - visible, etc. */ + (void) WriteBlobByte(image,0); + property=(const char *) GetImageProperty(next_image,""label""); + if (property == (const char *) NULL) + { + char + layer_name[MaxTextExtent]; + + (void) WriteBlobMSBLong(image,16); + (void) WriteBlobMSBLong(image,0); + (void) WriteBlobMSBLong(image,0); + (void) FormatLocaleString(layer_name,MaxTextExtent,""L%04ld"",(long) + layer_count++); + WritePascalString(image,layer_name,4); + } + else + { + size_t + length; + + length=strlen(property); + (void) WriteBlobMSBLong(image,(unsigned int) (length+(4- + (length % 4))+8)); + (void) WriteBlobMSBLong(image,0); + (void) WriteBlobMSBLong(image,0); + WritePascalString(image,property,4); + } + next_image=GetNextImageInList(next_image); + } + /* + Now the image data! + */ + next_image=base_image; + while (next_image != NULL) + { + status=WriteImageChannels(&psd_info,image_info,image,next_image, + MagickTrue); + next_image=GetNextImageInList(next_image); + } + (void) WriteBlobMSBLong(image,0); /* user mask data */ + base_image->compression=compression; + } + /* + Write composite image. + */ + if (status != MagickFalse) + status=WriteImageChannels(&psd_info,image_info,image,image,MagickFalse); + (void) CloseBlob(image); + return(status); +} +","@@ -2542,9 +2542,12 @@ static void RemoveICCProfileFromResourceBlock(StringInfo *bim_profile) + p=PushLongPixel(MSBEndian,p,&count); + if (id == 0x0000040f) + { +- (void) CopyMagickMemory(q,q+PSDQuantum(count)+12,length- +- (PSDQuantum(count)+12)-(q-datum)); +- SetStringInfoLength(bim_profile,length-(PSDQuantum(count)+12)); ++ if ((q+PSDQuantum(count)+12) < (datum+length-16)) ++ { ++ (void) CopyMagickMemory(q,q+PSDQuantum(count)+12,length- ++ (PSDQuantum(count)+12)-(q-datum)); ++ SetStringInfoLength(bim_profile,length-(PSDQuantum(count)+12)); ++ } + break; + } + p+=count;",3419,3655,4096 +18107,"juniper_parse_header(netdissect_options *ndo, + const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) +{ + const struct juniper_cookie_table_t *lp = juniper_cookie_table; + u_int idx, jnx_ext_len, jnx_header_len = 0; + uint8_t tlv_type,tlv_len; + uint32_t control_word; + int tlv_value; + const u_char *tptr; + + + l2info->header_len = 0; + l2info->cookie_len = 0; + l2info->proto = 0; + + + l2info->length = h->len; + l2info->caplen = h->caplen; + ND_TCHECK2(p[0], 4); + l2info->flags = p[3]; + l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; + + if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ + ND_PRINT((ndo, ""no magic-number found!"")); + return 0; + } + + if (ndo->ndo_eflag) /* print direction */ + ND_PRINT((ndo, ""%3s "", tok2str(juniper_direction_values, ""---"", l2info->direction))); + + /* magic number + flags */ + jnx_header_len = 4; + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n\tJuniper PCAP Flags [%s]"", + bittok2str(jnx_flag_values, ""none"", l2info->flags))); + + /* extensions present ? - calculate how much bytes to skip */ + if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { + + tptr = p+jnx_header_len; + + /* ok to read extension length ? */ + ND_TCHECK2(tptr[0], 2); + jnx_ext_len = EXTRACT_16BITS(tptr); + jnx_header_len += 2; + tptr +=2; + + /* nail up the total length - + * just in case something goes wrong + * with TLV parsing */ + jnx_header_len += jnx_ext_len; + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, "", PCAP Extension(s) total length %u"", jnx_ext_len)); + + ND_TCHECK2(tptr[0], jnx_ext_len); + while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) { + tlv_type = *(tptr++); + tlv_len = *(tptr++); + tlv_value = 0; + + /* sanity checks */ + if (tlv_type == 0 || tlv_len == 0) + break; + if (tlv_len+JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len) + goto trunc; + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n\t %s Extension TLV #%u, length %u, value "", + tok2str(jnx_ext_tlv_values,""Unknown"",tlv_type), + tlv_type, + tlv_len)); + + tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len); + switch (tlv_type) { + case JUNIPER_EXT_TLV_IFD_NAME: + /* FIXME */ + break; + case JUNIPER_EXT_TLV_IFD_MEDIATYPE: + case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE: + if (tlv_value != -1) { + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""%s (%u)"", + tok2str(juniper_ifmt_values, ""Unknown"", tlv_value), + tlv_value)); + } + break; + case JUNIPER_EXT_TLV_IFL_ENCAPS: + case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS: + if (tlv_value != -1) { + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""%s (%u)"", + tok2str(juniper_ifle_values, ""Unknown"", tlv_value), + tlv_value)); + } + break; + case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */ + case JUNIPER_EXT_TLV_IFL_UNIT: + case JUNIPER_EXT_TLV_IFD_IDX: + default: + if (tlv_value != -1) { + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""%u"", tlv_value)); + } + break; + } + + tptr+=tlv_len; + jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD; + } + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n\t-----original packet-----\n\t"")); + } + + if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""no-L2-hdr, "")); + + /* there is no link-layer present - + * perform the v4/v6 heuristics + * to figure out what it is + */ + ND_TCHECK2(p[jnx_header_len + 4], 1); + if (ip_heuristic_guess(ndo, p + jnx_header_len + 4, + l2info->length - (jnx_header_len + 4)) == 0) + ND_PRINT((ndo, ""no IP-hdr found!"")); + + l2info->header_len=jnx_header_len+4; + return 0; /* stop parsing the output further */ + + } + l2info->header_len = jnx_header_len; + p+=l2info->header_len; + l2info->length -= l2info->header_len; + l2info->caplen -= l2info->header_len; + + /* search through the cookie table and copy values matching for our PIC type */ + while (lp->s != NULL) { + if (lp->pictype == l2info->pictype) { + + l2info->cookie_len += lp->cookie_len; + + switch (p[0]) { + case LS_COOKIE_ID: + l2info->cookie_type = LS_COOKIE_ID; + l2info->cookie_len += 2; + break; + case AS_COOKIE_ID: + l2info->cookie_type = AS_COOKIE_ID; + l2info->cookie_len = 8; + break; + + default: + l2info->bundle = l2info->cookie[0]; + break; + } + + +#ifdef DLT_JUNIPER_MFR + /* MFR child links don't carry cookies */ + if (l2info->pictype == DLT_JUNIPER_MFR && + (p[0] & MFR_BE_MASK) == MFR_BE_MASK) { + l2info->cookie_len = 0; + } +#endif + + l2info->header_len += l2info->cookie_len; + l2info->length -= l2info->cookie_len; + l2info->caplen -= l2info->cookie_len; + + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%s-PIC, cookie-len %u"", + lp->s, + l2info->cookie_len)); + + if (l2info->cookie_len > 0) { + ND_TCHECK2(p[0], l2info->cookie_len); + if (ndo->ndo_eflag) + ND_PRINT((ndo, "", cookie 0x"")); + for (idx = 0; idx < l2info->cookie_len; idx++) { + l2info->cookie[idx] = p[idx]; /* copy cookie data */ + if (ndo->ndo_eflag) ND_PRINT((ndo, ""%02x"", p[idx])); + } + } + + if (ndo->ndo_eflag) ND_PRINT((ndo, "": "")); /* print demarc b/w L2/L3*/ + + + l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); + break; + } + ++lp; + } + p+=l2info->cookie_len; + + /* DLT_ specific parsing */ + switch(l2info->pictype) { +#ifdef DLT_JUNIPER_MLPPP + case DLT_JUNIPER_MLPPP: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_MLFR + case DLT_JUNIPER_MLFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_MFR + case DLT_JUNIPER_MFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_ATM2 + case DLT_JUNIPER_ATM2: + ND_TCHECK2(p[0], 4); + /* ATM cell relay control word present ? */ + if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { + control_word = EXTRACT_32BITS(p); + /* some control word heuristics */ + switch(control_word) { + case 0: /* zero control word */ + case 0x08000000: /* < JUNOS 7.4 control-word */ + case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ + l2info->header_len += 4; + break; + default: + break; + } + + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""control-word 0x%08x "", control_word)); + } + break; +#endif +#ifdef DLT_JUNIPER_GGSN + case DLT_JUNIPER_GGSN: + break; +#endif +#ifdef DLT_JUNIPER_ATM1 + case DLT_JUNIPER_ATM1: + break; +#endif +#ifdef DLT_JUNIPER_PPP + case DLT_JUNIPER_PPP: + break; +#endif +#ifdef DLT_JUNIPER_CHDLC + case DLT_JUNIPER_CHDLC: + break; +#endif +#ifdef DLT_JUNIPER_ETHER + case DLT_JUNIPER_ETHER: + break; +#endif +#ifdef DLT_JUNIPER_FRELAY + case DLT_JUNIPER_FRELAY: + break; +#endif + + default: + ND_PRINT((ndo, ""Unknown Juniper DLT_ type %u: "", l2info->pictype)); + break; + } + + if (ndo->ndo_eflag > 1) + ND_PRINT((ndo, ""hlen %u, proto 0x%04x, "", l2info->header_len, l2info->proto)); + + return 1; /* everything went ok so far. continue parsing */ + trunc: + ND_PRINT((ndo, ""[|juniper_hdr], length %u"", h->len)); + return 0; +} +",1,"juniper_parse_header(netdissect_options *ndo, + const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) +{ + const struct juniper_cookie_table_t *lp = juniper_cookie_table; + u_int idx, jnx_ext_len, jnx_header_len = 0; + uint8_t tlv_type,tlv_len; + uint32_t control_word; + int tlv_value; + const u_char *tptr; + + + l2info->header_len = 0; + l2info->cookie_len = 0; + l2info->proto = 0; + + + l2info->length = h->len; + l2info->caplen = h->caplen; + ND_TCHECK2(p[0], 4); + l2info->flags = p[3]; + l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; + + if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ + ND_PRINT((ndo, ""no magic-number found!"")); + return 0; + } + + if (ndo->ndo_eflag) /* print direction */ + ND_PRINT((ndo, ""%3s "", tok2str(juniper_direction_values, ""---"", l2info->direction))); + + /* magic number + flags */ + jnx_header_len = 4; + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n\tJuniper PCAP Flags [%s]"", + bittok2str(jnx_flag_values, ""none"", l2info->flags))); + + /* extensions present ? - calculate how much bytes to skip */ + if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { + + tptr = p+jnx_header_len; + + /* ok to read extension length ? */ + ND_TCHECK2(tptr[0], 2); + jnx_ext_len = EXTRACT_16BITS(tptr); + jnx_header_len += 2; + tptr +=2; + + /* nail up the total length - + * just in case something goes wrong + * with TLV parsing */ + jnx_header_len += jnx_ext_len; + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, "", PCAP Extension(s) total length %u"", jnx_ext_len)); + + ND_TCHECK2(tptr[0], jnx_ext_len); + while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) { + tlv_type = *(tptr++); + tlv_len = *(tptr++); + tlv_value = 0; + + /* sanity checks */ + if (tlv_type == 0 || tlv_len == 0) + break; + if (tlv_len+JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len) + goto trunc; + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n\t %s Extension TLV #%u, length %u, value "", + tok2str(jnx_ext_tlv_values,""Unknown"",tlv_type), + tlv_type, + tlv_len)); + + tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len); + switch (tlv_type) { + case JUNIPER_EXT_TLV_IFD_NAME: + /* FIXME */ + break; + case JUNIPER_EXT_TLV_IFD_MEDIATYPE: + case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE: + if (tlv_value != -1) { + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""%s (%u)"", + tok2str(juniper_ifmt_values, ""Unknown"", tlv_value), + tlv_value)); + } + break; + case JUNIPER_EXT_TLV_IFL_ENCAPS: + case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS: + if (tlv_value != -1) { + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""%s (%u)"", + tok2str(juniper_ifle_values, ""Unknown"", tlv_value), + tlv_value)); + } + break; + case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */ + case JUNIPER_EXT_TLV_IFL_UNIT: + case JUNIPER_EXT_TLV_IFD_IDX: + default: + if (tlv_value != -1) { + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""%u"", tlv_value)); + } + break; + } + + tptr+=tlv_len; + jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD; + } + + if (ndo->ndo_vflag > 1) + ND_PRINT((ndo, ""\n\t-----original packet-----\n\t"")); + } + + if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""no-L2-hdr, "")); + + /* there is no link-layer present - + * perform the v4/v6 heuristics + * to figure out what it is + */ + ND_TCHECK2(p[jnx_header_len + 4], 1); + if (ip_heuristic_guess(ndo, p + jnx_header_len + 4, + l2info->length - (jnx_header_len + 4)) == 0) + ND_PRINT((ndo, ""no IP-hdr found!"")); + + l2info->header_len=jnx_header_len+4; + return 0; /* stop parsing the output further */ + + } + l2info->header_len = jnx_header_len; + p+=l2info->header_len; + l2info->length -= l2info->header_len; + l2info->caplen -= l2info->header_len; + + /* search through the cookie table and copy values matching for our PIC type */ + ND_TCHECK(p[0]); + while (lp->s != NULL) { + if (lp->pictype == l2info->pictype) { + + l2info->cookie_len += lp->cookie_len; + + switch (p[0]) { + case LS_COOKIE_ID: + l2info->cookie_type = LS_COOKIE_ID; + l2info->cookie_len += 2; + break; + case AS_COOKIE_ID: + l2info->cookie_type = AS_COOKIE_ID; + l2info->cookie_len = 8; + break; + + default: + l2info->bundle = l2info->cookie[0]; + break; + } + + +#ifdef DLT_JUNIPER_MFR + /* MFR child links don't carry cookies */ + if (l2info->pictype == DLT_JUNIPER_MFR && + (p[0] & MFR_BE_MASK) == MFR_BE_MASK) { + l2info->cookie_len = 0; + } +#endif + + l2info->header_len += l2info->cookie_len; + l2info->length -= l2info->cookie_len; + l2info->caplen -= l2info->cookie_len; + + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""%s-PIC, cookie-len %u"", + lp->s, + l2info->cookie_len)); + + if (l2info->cookie_len > 0) { + ND_TCHECK2(p[0], l2info->cookie_len); + if (ndo->ndo_eflag) + ND_PRINT((ndo, "", cookie 0x"")); + for (idx = 0; idx < l2info->cookie_len; idx++) { + l2info->cookie[idx] = p[idx]; /* copy cookie data */ + if (ndo->ndo_eflag) ND_PRINT((ndo, ""%02x"", p[idx])); + } + } + + if (ndo->ndo_eflag) ND_PRINT((ndo, "": "")); /* print demarc b/w L2/L3*/ + + + l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); + break; + } + ++lp; + } + p+=l2info->cookie_len; + + /* DLT_ specific parsing */ + switch(l2info->pictype) { +#ifdef DLT_JUNIPER_MLPPP + case DLT_JUNIPER_MLPPP: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_MLFR + case DLT_JUNIPER_MLFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + ND_TCHECK2(p[0], 2); + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_MFR + case DLT_JUNIPER_MFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + ND_TCHECK2(p[0], 2); + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_ATM2 + case DLT_JUNIPER_ATM2: + ND_TCHECK2(p[0], 4); + /* ATM cell relay control word present ? */ + if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { + control_word = EXTRACT_32BITS(p); + /* some control word heuristics */ + switch(control_word) { + case 0: /* zero control word */ + case 0x08000000: /* < JUNOS 7.4 control-word */ + case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ + l2info->header_len += 4; + break; + default: + break; + } + + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""control-word 0x%08x "", control_word)); + } + break; +#endif +#ifdef DLT_JUNIPER_GGSN + case DLT_JUNIPER_GGSN: + break; +#endif +#ifdef DLT_JUNIPER_ATM1 + case DLT_JUNIPER_ATM1: + break; +#endif +#ifdef DLT_JUNIPER_PPP + case DLT_JUNIPER_PPP: + break; +#endif +#ifdef DLT_JUNIPER_CHDLC + case DLT_JUNIPER_CHDLC: + break; +#endif +#ifdef DLT_JUNIPER_ETHER + case DLT_JUNIPER_ETHER: + break; +#endif +#ifdef DLT_JUNIPER_FRELAY + case DLT_JUNIPER_FRELAY: + break; +#endif + + default: + ND_PRINT((ndo, ""Unknown Juniper DLT_ type %u: "", l2info->pictype)); + break; + } + + if (ndo->ndo_eflag > 1) + ND_PRINT((ndo, ""hlen %u, proto 0x%04x, "", l2info->header_len, l2info->proto)); + + return 1; /* everything went ok so far. continue parsing */ + trunc: + ND_PRINT((ndo, ""[|juniper_hdr], length %u"", h->len)); + return 0; +} +","@@ -472,6 +472,7 @@ juniper_ggsn_print(netdissect_options *ndo, + p+=l2info.header_len; + gh = (struct juniper_ggsn_header *)&l2info.cookie; + ++ ND_TCHECK(*gh); + if (ndo->ndo_eflag) { + ND_PRINT((ndo, ""proto %s (%u), vlan %u: "", + tok2str(juniper_protocol_values,""Unknown"",gh->proto), +@@ -492,6 +493,10 @@ juniper_ggsn_print(netdissect_options *ndo, + } + + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_services]"")); ++ return l2info.header_len; + } + #endif + +@@ -519,6 +524,7 @@ juniper_es_print(netdissect_options *ndo, + p+=l2info.header_len; + ih = (const struct juniper_ipsec_header *)p; + ++ ND_TCHECK(*ih); + switch (ih->type) { + case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE: + case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE: +@@ -564,6 +570,10 @@ juniper_es_print(netdissect_options *ndo, + + ip_print(ndo, p, l2info.length); + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_services]"")); ++ return l2info.header_len; + } + #endif + +@@ -588,6 +598,7 @@ juniper_monitor_print(netdissect_options *ndo, + p+=l2info.header_len; + mh = (const struct juniper_monitor_header *)p; + ++ ND_TCHECK(*mh); + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""service-id %u, iif %u, pkt-type %u: "", + EXTRACT_32BITS(&mh->service_id), +@@ -598,6 +609,10 @@ juniper_monitor_print(netdissect_options *ndo, + ip_heuristic_guess (ndo, p, l2info.length); + + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_services]"")); ++ return l2info.header_len; + } + #endif + +@@ -622,6 +637,7 @@ juniper_services_print(netdissect_options *ndo, + p+=l2info.header_len; + sh = (const struct juniper_services_header *)p; + ++ ND_TCHECK(*sh); + if (ndo->ndo_eflag) + ND_PRINT((ndo, ""service-id %u flags 0x%02x service-set-id 0x%04x iif %u: "", + sh->svc_id, +@@ -633,6 +649,10 @@ juniper_services_print(netdissect_options *ndo, + ip_heuristic_guess (ndo, p, l2info.length); + + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_services]"")); ++ return l2info.header_len; + } + #endif + +@@ -740,6 +760,7 @@ juniper_pppoe_atm_print(netdissect_options *ndo, + + p+=l2info.header_len; + ++ ND_TCHECK2(p[0], 2); + extracted_ethertype = EXTRACT_16BITS(p); + /* this DLT contains nothing but raw PPPoE frames, + * prepended with a type field*/ +@@ -752,6 +773,10 @@ juniper_pppoe_atm_print(netdissect_options *ndo, + ND_PRINT((ndo, ""unknown ethertype 0x%04x"", extracted_ethertype)); + + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_pppoe_atm]"")); ++ return l2info.header_len; + } + #endif + +@@ -940,6 +965,7 @@ juniper_atm1_print(netdissect_options *ndo, + return l2info.header_len; + } + ++ ND_TCHECK2(p[0], 3); + if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ + EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ + +@@ -958,6 +984,10 @@ juniper_atm1_print(netdissect_options *ndo, + return l2info.header_len; + + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_atm1]"")); ++ return l2info.header_len; + } + #endif + +@@ -989,6 +1019,7 @@ juniper_atm2_print(netdissect_options *ndo, + return l2info.header_len; + } + ++ ND_TCHECK2(p[0], 3); + if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ + EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ + +@@ -1016,6 +1047,10 @@ juniper_atm2_print(netdissect_options *ndo, + return l2info.header_len; + + return l2info.header_len; ++ ++trunc: ++ ND_PRINT((ndo, ""[|juniper_atm2]"")); ++ return l2info.header_len; + } + #endif + +@@ -1280,6 +1315,7 @@ juniper_parse_header(netdissect_options *ndo, + l2info->caplen -= l2info->header_len; + + /* search through the cookie table and copy values matching for our PIC type */ ++ ND_TCHECK(p[0]); + while (lp->s != NULL) { + if (lp->pictype == l2info->pictype) { + +@@ -1360,6 +1396,7 @@ juniper_parse_header(netdissect_options *ndo, + case DLT_JUNIPER_MLFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: ++ ND_TCHECK2(p[0], 2); + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; +@@ -1383,6 +1420,7 @@ juniper_parse_header(netdissect_options *ndo, + case DLT_JUNIPER_MFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: ++ ND_TCHECK2(p[0], 2); + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2;",2931,3167,4096 +6141,"static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + char tmp_key[5]; + char key2[32], language[4] = {0}; + char *str = NULL; + const char *key = NULL; + uint16_t langcode = 0; + uint32_t data_type = 0, str_size, str_size_alloc; + int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL; + int raw = 0; + int num = 0; + + switch (atom.type) { + case MKTAG( '@','P','R','M'): key = ""premiere_version""; raw = 1; break; + case MKTAG( '@','P','R','Q'): key = ""quicktime_version""; raw = 1; break; + case MKTAG( 'X','M','P','_'): + if (c->export_xmp) { key = ""xmp""; raw = 1; } break; + case MKTAG( 'a','A','R','T'): key = ""album_artist""; break; + case MKTAG( 'a','k','I','D'): key = ""account_type""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'a','p','I','D'): key = ""account_id""; break; + case MKTAG( 'c','a','t','g'): key = ""category""; break; + case MKTAG( 'c','p','i','l'): key = ""compilation""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'c','p','r','t'): key = ""copyright""; break; + case MKTAG( 'd','e','s','c'): key = ""description""; break; + case MKTAG( 'd','i','s','k'): key = ""disc""; + parse = mov_metadata_track_or_disc_number; break; + case MKTAG( 'e','g','i','d'): key = ""episode_uid""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'F','I','R','M'): key = ""firmware""; raw = 1; break; + case MKTAG( 'g','n','r','e'): key = ""genre""; + parse = mov_metadata_gnre; break; + case MKTAG( 'h','d','v','d'): key = ""hd_video""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'H','M','M','T'): + return mov_metadata_hmmt(c, pb, atom.size); + case MKTAG( 'k','e','y','w'): key = ""keywords""; break; + case MKTAG( 'l','d','e','s'): key = ""synopsis""; break; + case MKTAG( 'l','o','c','i'): + return mov_metadata_loci(c, pb, atom.size); + case MKTAG( 'p','c','s','t'): key = ""podcast""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'p','g','a','p'): key = ""gapless_playback""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'p','u','r','d'): key = ""purchase_date""; break; + case MKTAG( 'r','t','n','g'): key = ""rating""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 's','o','a','a'): key = ""sort_album_artist""; break; + case MKTAG( 's','o','a','l'): key = ""sort_album""; break; + case MKTAG( 's','o','a','r'): key = ""sort_artist""; break; + case MKTAG( 's','o','c','o'): key = ""sort_composer""; break; + case MKTAG( 's','o','n','m'): key = ""sort_name""; break; + case MKTAG( 's','o','s','n'): key = ""sort_show""; break; + case MKTAG( 's','t','i','k'): key = ""media_type""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 't','r','k','n'): key = ""track""; + parse = mov_metadata_track_or_disc_number; break; + case MKTAG( 't','v','e','n'): key = ""episode_id""; break; + case MKTAG( 't','v','e','s'): key = ""episode_sort""; + parse = mov_metadata_int8_bypass_padding; break; + case MKTAG( 't','v','n','n'): key = ""network""; break; + case MKTAG( 't','v','s','h'): key = ""show""; break; + case MKTAG( 't','v','s','n'): key = ""season_number""; + parse = mov_metadata_int8_bypass_padding; break; + case MKTAG(0xa9,'A','R','T'): key = ""artist""; break; + case MKTAG(0xa9,'P','R','D'): key = ""producer""; break; + case MKTAG(0xa9,'a','l','b'): key = ""album""; break; + case MKTAG(0xa9,'a','u','t'): key = ""artist""; break; + case MKTAG(0xa9,'c','h','p'): key = ""chapter""; break; + case MKTAG(0xa9,'c','m','t'): key = ""comment""; break; + case MKTAG(0xa9,'c','o','m'): key = ""composer""; break; + case MKTAG(0xa9,'c','p','y'): key = ""copyright""; break; + case MKTAG(0xa9,'d','a','y'): key = ""date""; break; + case MKTAG(0xa9,'d','i','r'): key = ""director""; break; + case MKTAG(0xa9,'d','i','s'): key = ""disclaimer""; break; + case MKTAG(0xa9,'e','d','1'): key = ""edit_date""; break; + case MKTAG(0xa9,'e','n','c'): key = ""encoder""; break; + case MKTAG(0xa9,'f','m','t'): key = ""original_format""; break; + case MKTAG(0xa9,'g','e','n'): key = ""genre""; break; + case MKTAG(0xa9,'g','r','p'): key = ""grouping""; break; + case MKTAG(0xa9,'h','s','t'): key = ""host_computer""; break; + case MKTAG(0xa9,'i','n','f'): key = ""comment""; break; + case MKTAG(0xa9,'l','y','r'): key = ""lyrics""; break; + case MKTAG(0xa9,'m','a','k'): key = ""make""; break; + case MKTAG(0xa9,'m','o','d'): key = ""model""; break; + case MKTAG(0xa9,'n','a','m'): key = ""title""; break; + case MKTAG(0xa9,'o','p','e'): key = ""original_artist""; break; + case MKTAG(0xa9,'p','r','d'): key = ""producer""; break; + case MKTAG(0xa9,'p','r','f'): key = ""performers""; break; + case MKTAG(0xa9,'r','e','q'): key = ""playback_requirements""; break; + case MKTAG(0xa9,'s','r','c'): key = ""original_source""; break; + case MKTAG(0xa9,'s','t','3'): key = ""subtitle""; break; + case MKTAG(0xa9,'s','w','r'): key = ""encoder""; break; + case MKTAG(0xa9,'t','o','o'): key = ""encoder""; break; + case MKTAG(0xa9,'t','r','k'): key = ""track""; break; + case MKTAG(0xa9,'u','r','l'): key = ""URL""; break; + case MKTAG(0xa9,'w','r','n'): key = ""warning""; break; + case MKTAG(0xa9,'w','r','t'): key = ""composer""; break; + case MKTAG(0xa9,'x','y','z'): key = ""location""; break; + } +retry: + if (c->itunes_metadata && atom.size > 8) { + int data_size = avio_rb32(pb); + int tag = avio_rl32(pb); + if (tag == MKTAG('d','a','t','a') && data_size <= atom.size) { + data_type = avio_rb32(pb); // type + avio_rb32(pb); // unknown + str_size = data_size - 16; + atom.size -= 16; + + if (atom.type == MKTAG('c', 'o', 'v', 'r')) { + int ret = mov_read_covr(c, pb, data_type, str_size); + if (ret < 0) { + av_log(c->fc, AV_LOG_ERROR, ""Error parsing cover art.\n""); + } + return ret; + } else if (!key && c->found_hdlr_mdta && c->meta_keys) { + uint32_t index = AV_RB32(&atom.type); + if (index < c->meta_keys_count && index > 0) { + key = c->meta_keys[index]; + } else { + av_log(c->fc, AV_LOG_WARNING, + ""The index of 'data' is out of range: %""PRId32"" < 1 or >= %d.\n"", + index, c->meta_keys_count); + } + } + } else return 0; + } else if (atom.size > 4 && key && !c->itunes_metadata && !raw) { + str_size = avio_rb16(pb); // string length + if (str_size > atom.size) { + raw = 1; + avio_seek(pb, -2, SEEK_CUR); + av_log(c->fc, AV_LOG_WARNING, ""UDTA parsing failed retrying raw\n""); + goto retry; + } + langcode = avio_rb16(pb); + ff_mov_lang_to_iso639(langcode, language); + atom.size -= 4; + } else + str_size = atom.size; + + if (c->export_all && !key) { + snprintf(tmp_key, 5, ""%.4s"", (char*)&atom.type); + key = tmp_key; + } + + if (!key) + return 0; + if (atom.size < 0 || str_size >= INT_MAX/2) + return AVERROR_INVALIDDATA; + + num = (data_type >= 21 && data_type <= 23); + str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1; + str = av_mallocz(str_size_alloc); + if (!str) + return AVERROR(ENOMEM); + + if (parse) + parse(c, pb, str_size, key); + else { + if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) { // MAC Encoded + mov_read_mac_string(c, pb, str_size, str, str_size_alloc); + } else if (data_type == 21) { // BE signed integer, variable size + int val = 0; + if (str_size == 1) + val = (int8_t)avio_r8(pb); + else if (str_size == 2) + val = (int16_t)avio_rb16(pb); + else if (str_size == 3) + val = ((int32_t)(avio_rb24(pb)<<8))>>8; + else if (str_size == 4) + val = (int32_t)avio_rb32(pb); + if (snprintf(str, str_size_alloc, ""%d"", val) >= str_size_alloc) { + av_log(c->fc, AV_LOG_ERROR, + ""Failed to store the number (%d) in string.\n"", val); + av_free(str); + return AVERROR_INVALIDDATA; + } + } else if (data_type == 22) { // BE unsigned integer, variable size + unsigned int val = 0; + if (str_size == 1) + val = avio_r8(pb); + else if (str_size == 2) + val = avio_rb16(pb); + else if (str_size == 3) + val = avio_rb24(pb); + else if (str_size == 4) + val = avio_rb32(pb); + if (snprintf(str, str_size_alloc, ""%u"", val) >= str_size_alloc) { + av_log(c->fc, AV_LOG_ERROR, + ""Failed to store the number (%u) in string.\n"", val); + av_free(str); + return AVERROR_INVALIDDATA; + } + } else if (data_type == 23 && str_size >= 4) { // BE float32 + float val = av_int2float(avio_rb32(pb)); + if (snprintf(str, str_size_alloc, ""%f"", val) >= str_size_alloc) { + av_log(c->fc, AV_LOG_ERROR, + ""Failed to store the float32 number (%f) in string.\n"", val); + av_free(str); + return AVERROR_INVALIDDATA; + } + } else { + int ret = ffio_read_size(pb, str, str_size); + if (ret < 0) { + av_free(str); + return ret; + } + str[str_size] = 0; + } + c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; + av_dict_set(&c->fc->metadata, key, str, 0); + if (*language && strcmp(language, ""und"")) { + snprintf(key2, sizeof(key2), ""%s-%s"", key, language); + av_dict_set(&c->fc->metadata, key2, str, 0); + } + if (!strcmp(key, ""encoder"")) { + int major, minor, micro; + if (sscanf(str, ""HandBrake %d.%d.%d"", &major, &minor, µ) == 3) { + c->handbrake_version = 1000000*major + 1000*minor + micro; + } + } + } + + av_freep(&str); + return 0; +} +",0,"static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + char tmp_key[5]; + char key2[32], language[4] = {0}; + char *str = NULL; + const char *key = NULL; + uint16_t langcode = 0; + uint32_t data_type = 0, str_size, str_size_alloc; + int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL; + int raw = 0; + int num = 0; + + switch (atom.type) { + case MKTAG( '@','P','R','M'): key = ""premiere_version""; raw = 1; break; + case MKTAG( '@','P','R','Q'): key = ""quicktime_version""; raw = 1; break; + case MKTAG( 'X','M','P','_'): + if (c->export_xmp) { key = ""xmp""; raw = 1; } break; + case MKTAG( 'a','A','R','T'): key = ""album_artist""; break; + case MKTAG( 'a','k','I','D'): key = ""account_type""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'a','p','I','D'): key = ""account_id""; break; + case MKTAG( 'c','a','t','g'): key = ""category""; break; + case MKTAG( 'c','p','i','l'): key = ""compilation""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'c','p','r','t'): key = ""copyright""; break; + case MKTAG( 'd','e','s','c'): key = ""description""; break; + case MKTAG( 'd','i','s','k'): key = ""disc""; + parse = mov_metadata_track_or_disc_number; break; + case MKTAG( 'e','g','i','d'): key = ""episode_uid""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'F','I','R','M'): key = ""firmware""; raw = 1; break; + case MKTAG( 'g','n','r','e'): key = ""genre""; + parse = mov_metadata_gnre; break; + case MKTAG( 'h','d','v','d'): key = ""hd_video""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'H','M','M','T'): + return mov_metadata_hmmt(c, pb, atom.size); + case MKTAG( 'k','e','y','w'): key = ""keywords""; break; + case MKTAG( 'l','d','e','s'): key = ""synopsis""; break; + case MKTAG( 'l','o','c','i'): + return mov_metadata_loci(c, pb, atom.size); + case MKTAG( 'p','c','s','t'): key = ""podcast""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'p','g','a','p'): key = ""gapless_playback""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'p','u','r','d'): key = ""purchase_date""; break; + case MKTAG( 'r','t','n','g'): key = ""rating""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 's','o','a','a'): key = ""sort_album_artist""; break; + case MKTAG( 's','o','a','l'): key = ""sort_album""; break; + case MKTAG( 's','o','a','r'): key = ""sort_artist""; break; + case MKTAG( 's','o','c','o'): key = ""sort_composer""; break; + case MKTAG( 's','o','n','m'): key = ""sort_name""; break; + case MKTAG( 's','o','s','n'): key = ""sort_show""; break; + case MKTAG( 's','t','i','k'): key = ""media_type""; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 't','r','k','n'): key = ""track""; + parse = mov_metadata_track_or_disc_number; break; + case MKTAG( 't','v','e','n'): key = ""episode_id""; break; + case MKTAG( 't','v','e','s'): key = ""episode_sort""; + parse = mov_metadata_int8_bypass_padding; break; + case MKTAG( 't','v','n','n'): key = ""network""; break; + case MKTAG( 't','v','s','h'): key = ""show""; break; + case MKTAG( 't','v','s','n'): key = ""season_number""; + parse = mov_metadata_int8_bypass_padding; break; + case MKTAG(0xa9,'A','R','T'): key = ""artist""; break; + case MKTAG(0xa9,'P','R','D'): key = ""producer""; break; + case MKTAG(0xa9,'a','l','b'): key = ""album""; break; + case MKTAG(0xa9,'a','u','t'): key = ""artist""; break; + case MKTAG(0xa9,'c','h','p'): key = ""chapter""; break; + case MKTAG(0xa9,'c','m','t'): key = ""comment""; break; + case MKTAG(0xa9,'c','o','m'): key = ""composer""; break; + case MKTAG(0xa9,'c','p','y'): key = ""copyright""; break; + case MKTAG(0xa9,'d','a','y'): key = ""date""; break; + case MKTAG(0xa9,'d','i','r'): key = ""director""; break; + case MKTAG(0xa9,'d','i','s'): key = ""disclaimer""; break; + case MKTAG(0xa9,'e','d','1'): key = ""edit_date""; break; + case MKTAG(0xa9,'e','n','c'): key = ""encoder""; break; + case MKTAG(0xa9,'f','m','t'): key = ""original_format""; break; + case MKTAG(0xa9,'g','e','n'): key = ""genre""; break; + case MKTAG(0xa9,'g','r','p'): key = ""grouping""; break; + case MKTAG(0xa9,'h','s','t'): key = ""host_computer""; break; + case MKTAG(0xa9,'i','n','f'): key = ""comment""; break; + case MKTAG(0xa9,'l','y','r'): key = ""lyrics""; break; + case MKTAG(0xa9,'m','a','k'): key = ""make""; break; + case MKTAG(0xa9,'m','o','d'): key = ""model""; break; + case MKTAG(0xa9,'n','a','m'): key = ""title""; break; + case MKTAG(0xa9,'o','p','e'): key = ""original_artist""; break; + case MKTAG(0xa9,'p','r','d'): key = ""producer""; break; + case MKTAG(0xa9,'p','r','f'): key = ""performers""; break; + case MKTAG(0xa9,'r','e','q'): key = ""playback_requirements""; break; + case MKTAG(0xa9,'s','r','c'): key = ""original_source""; break; + case MKTAG(0xa9,'s','t','3'): key = ""subtitle""; break; + case MKTAG(0xa9,'s','w','r'): key = ""encoder""; break; + case MKTAG(0xa9,'t','o','o'): key = ""encoder""; break; + case MKTAG(0xa9,'t','r','k'): key = ""track""; break; + case MKTAG(0xa9,'u','r','l'): key = ""URL""; break; + case MKTAG(0xa9,'w','r','n'): key = ""warning""; break; + case MKTAG(0xa9,'w','r','t'): key = ""composer""; break; + case MKTAG(0xa9,'x','y','z'): key = ""location""; break; + } +retry: + if (c->itunes_metadata && atom.size > 8) { + int data_size = avio_rb32(pb); + int tag = avio_rl32(pb); + if (tag == MKTAG('d','a','t','a') && data_size <= atom.size) { + data_type = avio_rb32(pb); // type + avio_rb32(pb); // unknown + str_size = data_size - 16; + atom.size -= 16; + + if (atom.type == MKTAG('c', 'o', 'v', 'r')) { + int ret = mov_read_covr(c, pb, data_type, str_size); + if (ret < 0) { + av_log(c->fc, AV_LOG_ERROR, ""Error parsing cover art.\n""); + } + return ret; + } else if (!key && c->found_hdlr_mdta && c->meta_keys) { + uint32_t index = AV_RB32(&atom.type); + if (index < c->meta_keys_count && index > 0) { + key = c->meta_keys[index]; + } else { + av_log(c->fc, AV_LOG_WARNING, + ""The index of 'data' is out of range: %""PRId32"" < 1 or >= %d.\n"", + index, c->meta_keys_count); + } + } + } else return 0; + } else if (atom.size > 4 && key && !c->itunes_metadata && !raw) { + str_size = avio_rb16(pb); // string length + if (str_size > atom.size) { + raw = 1; + avio_seek(pb, -2, SEEK_CUR); + av_log(c->fc, AV_LOG_WARNING, ""UDTA parsing failed retrying raw\n""); + goto retry; + } + langcode = avio_rb16(pb); + ff_mov_lang_to_iso639(langcode, language); + atom.size -= 4; + } else + str_size = atom.size; + + if (c->export_all && !key) { + snprintf(tmp_key, 5, ""%.4s"", (char*)&atom.type); + key = tmp_key; + } + + if (!key) + return 0; + if (atom.size < 0 || str_size >= INT_MAX/2) + return AVERROR_INVALIDDATA; + + num = (data_type >= 21 && data_type <= 23); + str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1; + str = av_mallocz(str_size_alloc); + if (!str) + return AVERROR(ENOMEM); + + if (parse) + parse(c, pb, str_size, key); + else { + if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) { // MAC Encoded + mov_read_mac_string(c, pb, str_size, str, str_size_alloc); + } else if (data_type == 21) { // BE signed integer, variable size + int val = 0; + if (str_size == 1) + val = (int8_t)avio_r8(pb); + else if (str_size == 2) + val = (int16_t)avio_rb16(pb); + else if (str_size == 3) + val = ((int32_t)(avio_rb24(pb)<<8))>>8; + else if (str_size == 4) + val = (int32_t)avio_rb32(pb); + if (snprintf(str, str_size_alloc, ""%d"", val) >= str_size_alloc) { + av_log(c->fc, AV_LOG_ERROR, + ""Failed to store the number (%d) in string.\n"", val); + av_free(str); + return AVERROR_INVALIDDATA; + } + } else if (data_type == 22) { // BE unsigned integer, variable size + unsigned int val = 0; + if (str_size == 1) + val = avio_r8(pb); + else if (str_size == 2) + val = avio_rb16(pb); + else if (str_size == 3) + val = avio_rb24(pb); + else if (str_size == 4) + val = avio_rb32(pb); + if (snprintf(str, str_size_alloc, ""%u"", val) >= str_size_alloc) { + av_log(c->fc, AV_LOG_ERROR, + ""Failed to store the number (%u) in string.\n"", val); + av_free(str); + return AVERROR_INVALIDDATA; + } + } else if (data_type == 23 && str_size >= 4) { // BE float32 + float val = av_int2float(avio_rb32(pb)); + if (snprintf(str, str_size_alloc, ""%f"", val) >= str_size_alloc) { + av_log(c->fc, AV_LOG_ERROR, + ""Failed to store the float32 number (%f) in string.\n"", val); + av_free(str); + return AVERROR_INVALIDDATA; + } + } else { + int ret = ffio_read_size(pb, str, str_size); + if (ret < 0) { + av_free(str); + return ret; + } + str[str_size] = 0; + } + c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; + av_dict_set(&c->fc->metadata, key, str, 0); + if (*language && strcmp(language, ""und"")) { + snprintf(key2, sizeof(key2), ""%s-%s"", key, language); + av_dict_set(&c->fc->metadata, key2, str, 0); + } + if (!strcmp(key, ""encoder"")) { + int major, minor, micro; + if (sscanf(str, ""HandBrake %d.%d.%d"", &major, &minor, µ) == 3) { + c->handbrake_version = 1000000*major + 1000*minor + micro; + } + } + } + + av_freep(&str); + return 0; +} +","@@ -6094,6 +6094,13 @@ static int read_tfra(MOVContext *mov, AVIOContext *f) + } + for (i = 0; i < index->item_count; i++) { + int64_t time, offset; ++ ++ if (avio_feof(f)) { ++ index->item_count = 0; ++ av_freep(&index->items); ++ return AVERROR_INVALIDDATA; ++ } ++ + if (version == 1) { + time = avio_rb64(f); + offset = avio_rb64(f);",3287,3523,4096 +9051,"process_extra(struct archive_read *a, const char *p, size_t extra_length, struct zip_entry* zip_entry) +{ + unsigned offset = 0; + + if (extra_length == 0) { + return ARCHIVE_OK; + } + + if (extra_length < 4) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Too-small extra data: Need at least 4 bytes, but only found %d bytes"", (int)extra_length); + return ARCHIVE_FAILED; + } + while (offset <= extra_length - 4) { + unsigned short headerid = archive_le16dec(p + offset); + unsigned short datasize = archive_le16dec(p + offset + 2); + + offset += 4; + if (offset + datasize > extra_length) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Extra data overflow: Need %d bytes but only found %d bytes"", + (int)datasize, (int)(extra_length - offset)); + return ARCHIVE_FAILED; + } +#ifdef DEBUG + fprintf(stderr, ""Header id 0x%04x, length %d\n"", + headerid, datasize); +#endif + switch (headerid) { + case 0x0001: + /* Zip64 extended information extra field. */ + zip_entry->flags |= LA_USED_ZIP64; + if (zip_entry->uncompressed_size == 0xffffffff) { + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed 64-bit uncompressed size""); + return ARCHIVE_FAILED; + } + zip_entry->uncompressed_size = t; + offset += 8; + datasize -= 8; + } + if (zip_entry->compressed_size == 0xffffffff) { + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed 64-bit compressed size""); + return ARCHIVE_FAILED; + } + zip_entry->compressed_size = t; + offset += 8; + datasize -= 8; + } + if (zip_entry->local_header_offset == 0xffffffff) { + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed 64-bit local header offset""); + return ARCHIVE_FAILED; + } + zip_entry->local_header_offset = t; + offset += 8; + datasize -= 8; + } + /* archive_le32dec(p + offset) gives disk + * on which file starts, but we don't handle + * multi-volume Zip files. */ + break; +#ifdef DEBUG + case 0x0017: + { + /* Strong encryption field. */ + if (archive_le16dec(p + offset) == 2) { + unsigned algId = + archive_le16dec(p + offset + 2); + unsigned bitLen = + archive_le16dec(p + offset + 4); + int flags = + archive_le16dec(p + offset + 6); + fprintf(stderr, ""algId=0x%04x, bitLen=%u, "" + ""flgas=%d\n"", algId, bitLen,flags); + } + break; + } +#endif + case 0x5455: + { + /* Extended time field ""UT"". */ + int flags; + if (datasize == 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Incomplete extended time field""); + return ARCHIVE_FAILED; + } + flags = p[offset]; + offset++; + datasize--; + /* Flag bits indicate which dates are present. */ + if (flags & 0x01) + { +#ifdef DEBUG + fprintf(stderr, ""mtime: %lld -> %d\n"", + (long long)zip_entry->mtime, + archive_le32dec(p + offset)); +#endif + if (datasize < 4) + break; + zip_entry->mtime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + if (flags & 0x02) + { + if (datasize < 4) + break; + zip_entry->atime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + if (flags & 0x04) + { + if (datasize < 4) + break; + zip_entry->ctime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + break; + } + case 0x5855: + { + /* Info-ZIP Unix Extra Field (old version) ""UX"". */ + if (datasize >= 8) { + zip_entry->atime = archive_le32dec(p + offset); + zip_entry->mtime = + archive_le32dec(p + offset + 4); + } + if (datasize >= 12) { + zip_entry->uid = + archive_le16dec(p + offset + 8); + zip_entry->gid = + archive_le16dec(p + offset + 10); + } + break; + } + case 0x6c78: + { + /* Experimental 'xl' field */ + /* + * Introduced Dec 2013 to provide a way to + * include external file attributes (and other + * fields that ordinarily appear only in + * central directory) in local file header. + * This provides file type and permission + * information necessary to support full + * streaming extraction. Currently being + * discussed with other Zip developers + * ... subject to change. + * + * Format: + * The field starts with a bitmap that specifies + * which additional fields are included. The + * bitmap is variable length and can be extended in + * the future. + * + * n bytes - feature bitmap: first byte has low-order + * 7 bits. If high-order bit is set, a subsequent + * byte holds the next 7 bits, etc. + * + * if bitmap & 1, 2 byte ""version made by"" + * if bitmap & 2, 2 byte ""internal file attributes"" + * if bitmap & 4, 4 byte ""external file attributes"" + * if bitmap & 8, 2 byte comment length + n byte comment + */ + int bitmap, bitmap_last; + + if (datasize < 1) + break; + bitmap_last = bitmap = 0xff & p[offset]; + offset += 1; + datasize -= 1; + + /* We only support first 7 bits of bitmap; skip rest. */ + while ((bitmap_last & 0x80) != 0 + && datasize >= 1) { + bitmap_last = p[offset]; + offset += 1; + datasize -= 1; + } + + if (bitmap & 1) { + /* 2 byte ""version made by"" */ + if (datasize < 2) + break; + zip_entry->system + = archive_le16dec(p + offset) >> 8; + offset += 2; + datasize -= 2; + } + if (bitmap & 2) { + /* 2 byte ""internal file attributes"" */ + uint32_t internal_attributes; + if (datasize < 2) + break; + internal_attributes + = archive_le16dec(p + offset); + /* Not used by libarchive at present. */ + (void)internal_attributes; /* UNUSED */ + offset += 2; + datasize -= 2; + } + if (bitmap & 4) { + /* 4 byte ""external file attributes"" */ + uint32_t external_attributes; + if (datasize < 4) + break; + external_attributes + = archive_le32dec(p + offset); + if (zip_entry->system == 3) { + zip_entry->mode + = external_attributes >> 16; + } else if (zip_entry->system == 0) { + if (0x10 == (external_attributes & 0x10)) { + zip_entry->mode = AE_IFDIR | 0775; + } else { + zip_entry->mode = AE_IFREG | 0664; + } + if (0x01 == (external_attributes & 0x01)) { + zip_entry->mode &= 0555; + } + } else { + zip_entry->mode = 0; + } + offset += 4; + datasize -= 4; + } + if (bitmap & 8) { + /* 2 byte comment length + comment */ + uint32_t comment_length; + if (datasize < 2) + break; + comment_length + = archive_le16dec(p + offset); + offset += 2; + datasize -= 2; + + if (datasize < comment_length) + break; + /* Comment is not supported by libarchive */ + offset += comment_length; + datasize -= comment_length; + } + break; + } + case 0x7855: + /* Info-ZIP Unix Extra Field (type 2) ""Ux"". */ +#ifdef DEBUG + fprintf(stderr, ""uid %d gid %d\n"", + archive_le16dec(p + offset), + archive_le16dec(p + offset + 2)); +#endif + if (datasize >= 2) + zip_entry->uid = archive_le16dec(p + offset); + if (datasize >= 4) + zip_entry->gid = + archive_le16dec(p + offset + 2); + break; + case 0x7875: + { + /* Info-Zip Unix Extra Field (type 3) ""ux"". */ + int uidsize = 0, gidsize = 0; + + /* TODO: support arbitrary uidsize/gidsize. */ + if (datasize >= 1 && p[offset] == 1) {/* version=1 */ + if (datasize >= 4) { + /* get a uid size. */ + uidsize = 0xff & (int)p[offset+1]; + if (uidsize == 2) + zip_entry->uid = + archive_le16dec( + p + offset + 2); + else if (uidsize == 4 && datasize >= 6) + zip_entry->uid = + archive_le32dec( + p + offset + 2); + } + if (datasize >= (2 + uidsize + 3)) { + /* get a gid size. */ + gidsize = 0xff & (int)p[offset+2+uidsize]; + if (gidsize == 2) + zip_entry->gid = + archive_le16dec( + p+offset+2+uidsize+1); + else if (gidsize == 4 && + datasize >= (2 + uidsize + 5)) + zip_entry->gid = + archive_le32dec( + p+offset+2+uidsize+1); + } + } + break; + } + case 0x9901: + /* WinZip AES extra data field. */ + if (datasize < 6) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Incomplete AES field""); + return ARCHIVE_FAILED; + } + if (p[offset + 2] == 'A' && p[offset + 3] == 'E') { + /* Vendor version. */ + zip_entry->aes_extra.vendor = + archive_le16dec(p + offset); + /* AES encryption strength. */ + zip_entry->aes_extra.strength = p[offset + 4]; + /* Actual compression method. */ + zip_entry->aes_extra.compression = + p[offset + 5]; + } + break; + default: + break; + } + offset += datasize; + } + if (offset != extra_length) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed extra data: Consumed %d bytes of %d bytes"", + (int)offset, (int)extra_length); + return ARCHIVE_FAILED; + } + return ARCHIVE_OK; +} +",0,"process_extra(struct archive_read *a, const char *p, size_t extra_length, struct zip_entry* zip_entry) +{ + unsigned offset = 0; + + if (extra_length == 0) { + return ARCHIVE_OK; + } + + if (extra_length < 4) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Too-small extra data: Need at least 4 bytes, but only found %d bytes"", (int)extra_length); + return ARCHIVE_FAILED; + } + while (offset <= extra_length - 4) { + unsigned short headerid = archive_le16dec(p + offset); + unsigned short datasize = archive_le16dec(p + offset + 2); + + offset += 4; + if (offset + datasize > extra_length) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Extra data overflow: Need %d bytes but only found %d bytes"", + (int)datasize, (int)(extra_length - offset)); + return ARCHIVE_FAILED; + } +#ifdef DEBUG + fprintf(stderr, ""Header id 0x%04x, length %d\n"", + headerid, datasize); +#endif + switch (headerid) { + case 0x0001: + /* Zip64 extended information extra field. */ + zip_entry->flags |= LA_USED_ZIP64; + if (zip_entry->uncompressed_size == 0xffffffff) { + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed 64-bit uncompressed size""); + return ARCHIVE_FAILED; + } + zip_entry->uncompressed_size = t; + offset += 8; + datasize -= 8; + } + if (zip_entry->compressed_size == 0xffffffff) { + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed 64-bit compressed size""); + return ARCHIVE_FAILED; + } + zip_entry->compressed_size = t; + offset += 8; + datasize -= 8; + } + if (zip_entry->local_header_offset == 0xffffffff) { + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed 64-bit local header offset""); + return ARCHIVE_FAILED; + } + zip_entry->local_header_offset = t; + offset += 8; + datasize -= 8; + } + /* archive_le32dec(p + offset) gives disk + * on which file starts, but we don't handle + * multi-volume Zip files. */ + break; +#ifdef DEBUG + case 0x0017: + { + /* Strong encryption field. */ + if (archive_le16dec(p + offset) == 2) { + unsigned algId = + archive_le16dec(p + offset + 2); + unsigned bitLen = + archive_le16dec(p + offset + 4); + int flags = + archive_le16dec(p + offset + 6); + fprintf(stderr, ""algId=0x%04x, bitLen=%u, "" + ""flgas=%d\n"", algId, bitLen,flags); + } + break; + } +#endif + case 0x5455: + { + /* Extended time field ""UT"". */ + int flags; + if (datasize == 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Incomplete extended time field""); + return ARCHIVE_FAILED; + } + flags = p[offset]; + offset++; + datasize--; + /* Flag bits indicate which dates are present. */ + if (flags & 0x01) + { +#ifdef DEBUG + fprintf(stderr, ""mtime: %lld -> %d\n"", + (long long)zip_entry->mtime, + archive_le32dec(p + offset)); +#endif + if (datasize < 4) + break; + zip_entry->mtime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + if (flags & 0x02) + { + if (datasize < 4) + break; + zip_entry->atime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + if (flags & 0x04) + { + if (datasize < 4) + break; + zip_entry->ctime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + break; + } + case 0x5855: + { + /* Info-ZIP Unix Extra Field (old version) ""UX"". */ + if (datasize >= 8) { + zip_entry->atime = archive_le32dec(p + offset); + zip_entry->mtime = + archive_le32dec(p + offset + 4); + } + if (datasize >= 12) { + zip_entry->uid = + archive_le16dec(p + offset + 8); + zip_entry->gid = + archive_le16dec(p + offset + 10); + } + break; + } + case 0x6c78: + { + /* Experimental 'xl' field */ + /* + * Introduced Dec 2013 to provide a way to + * include external file attributes (and other + * fields that ordinarily appear only in + * central directory) in local file header. + * This provides file type and permission + * information necessary to support full + * streaming extraction. Currently being + * discussed with other Zip developers + * ... subject to change. + * + * Format: + * The field starts with a bitmap that specifies + * which additional fields are included. The + * bitmap is variable length and can be extended in + * the future. + * + * n bytes - feature bitmap: first byte has low-order + * 7 bits. If high-order bit is set, a subsequent + * byte holds the next 7 bits, etc. + * + * if bitmap & 1, 2 byte ""version made by"" + * if bitmap & 2, 2 byte ""internal file attributes"" + * if bitmap & 4, 4 byte ""external file attributes"" + * if bitmap & 8, 2 byte comment length + n byte comment + */ + int bitmap, bitmap_last; + + if (datasize < 1) + break; + bitmap_last = bitmap = 0xff & p[offset]; + offset += 1; + datasize -= 1; + + /* We only support first 7 bits of bitmap; skip rest. */ + while ((bitmap_last & 0x80) != 0 + && datasize >= 1) { + bitmap_last = p[offset]; + offset += 1; + datasize -= 1; + } + + if (bitmap & 1) { + /* 2 byte ""version made by"" */ + if (datasize < 2) + break; + zip_entry->system + = archive_le16dec(p + offset) >> 8; + offset += 2; + datasize -= 2; + } + if (bitmap & 2) { + /* 2 byte ""internal file attributes"" */ + uint32_t internal_attributes; + if (datasize < 2) + break; + internal_attributes + = archive_le16dec(p + offset); + /* Not used by libarchive at present. */ + (void)internal_attributes; /* UNUSED */ + offset += 2; + datasize -= 2; + } + if (bitmap & 4) { + /* 4 byte ""external file attributes"" */ + uint32_t external_attributes; + if (datasize < 4) + break; + external_attributes + = archive_le32dec(p + offset); + if (zip_entry->system == 3) { + zip_entry->mode + = external_attributes >> 16; + } else if (zip_entry->system == 0) { + if (0x10 == (external_attributes & 0x10)) { + zip_entry->mode = AE_IFDIR | 0775; + } else { + zip_entry->mode = AE_IFREG | 0664; + } + if (0x01 == (external_attributes & 0x01)) { + zip_entry->mode &= 0555; + } + } else { + zip_entry->mode = 0; + } + offset += 4; + datasize -= 4; + } + if (bitmap & 8) { + /* 2 byte comment length + comment */ + uint32_t comment_length; + if (datasize < 2) + break; + comment_length + = archive_le16dec(p + offset); + offset += 2; + datasize -= 2; + + if (datasize < comment_length) + break; + /* Comment is not supported by libarchive */ + offset += comment_length; + datasize -= comment_length; + } + break; + } + case 0x7855: + /* Info-ZIP Unix Extra Field (type 2) ""Ux"". */ +#ifdef DEBUG + fprintf(stderr, ""uid %d gid %d\n"", + archive_le16dec(p + offset), + archive_le16dec(p + offset + 2)); +#endif + if (datasize >= 2) + zip_entry->uid = archive_le16dec(p + offset); + if (datasize >= 4) + zip_entry->gid = + archive_le16dec(p + offset + 2); + break; + case 0x7875: + { + /* Info-Zip Unix Extra Field (type 3) ""ux"". */ + int uidsize = 0, gidsize = 0; + + /* TODO: support arbitrary uidsize/gidsize. */ + if (datasize >= 1 && p[offset] == 1) {/* version=1 */ + if (datasize >= 4) { + /* get a uid size. */ + uidsize = 0xff & (int)p[offset+1]; + if (uidsize == 2) + zip_entry->uid = + archive_le16dec( + p + offset + 2); + else if (uidsize == 4 && datasize >= 6) + zip_entry->uid = + archive_le32dec( + p + offset + 2); + } + if (datasize >= (2 + uidsize + 3)) { + /* get a gid size. */ + gidsize = 0xff & (int)p[offset+2+uidsize]; + if (gidsize == 2) + zip_entry->gid = + archive_le16dec( + p+offset+2+uidsize+1); + else if (gidsize == 4 && + datasize >= (2 + uidsize + 5)) + zip_entry->gid = + archive_le32dec( + p+offset+2+uidsize+1); + } + } + break; + } + case 0x9901: + /* WinZip AES extra data field. */ + if (datasize < 6) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Incomplete AES field""); + return ARCHIVE_FAILED; + } + if (p[offset + 2] == 'A' && p[offset + 3] == 'E') { + /* Vendor version. */ + zip_entry->aes_extra.vendor = + archive_le16dec(p + offset); + /* AES encryption strength. */ + zip_entry->aes_extra.strength = p[offset + 4]; + /* Actual compression method. */ + zip_entry->aes_extra.compression = + p[offset + 5]; + } + break; + default: + break; + } + offset += datasize; + } + if (offset != extra_length) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Malformed extra data: Consumed %d bytes of %d bytes"", + (int)offset, (int)extra_length); + return ARCHIVE_FAILED; + } + return ARCHIVE_OK; +} +","@@ -2751,7 +2751,7 @@ archive_read_format_zip_cleanup(struct archive_read *a) + inflateEnd(&zip->stream); + #endif + +-#if HAVA_LZMA_H && HAVE_LIBLZMA ++#if HAVE_LZMA_H && HAVE_LIBLZMA + if (zip->zipx_lzma_valid) { + lzma_end(&zip->zipx_lzma_stream); + }",2927,3163,4096 +18173,"ModuleExport MagickBooleanType ReadPSDLayers(Image *image, + const ImageInfo *image_info,const PSDInfo *psd_info, + const MagickBooleanType skip_layers,ExceptionInfo *exception) +{ + char + type[4]; + + LayerInfo + *layer_info; + + MagickSizeType + size; + + MagickBooleanType + status; + + register ssize_t + i; + + ssize_t + count, + j, + number_layers; + + size=GetPSDSize(psd_info,image); + if (size == 0) + { + /* + Skip layers & masks. + */ + (void) ReadBlobLong(image); + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + status=MagickFalse; + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + return(MagickTrue); + else + { + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count != 0) && (LocaleNCompare(type,""Lr16"",4) == 0)) + size=GetPSDSize(psd_info,image); + else + return(MagickTrue); + } + } + status=MagickTrue; + if (size != 0) + { + layer_info=(LayerInfo *) NULL; + number_layers=(short) ReadBlobShort(image); + + if (number_layers < 0) + { + /* + The first alpha channel in the merged result contains the + transparency data for the merged result. + */ + number_layers=MagickAbsoluteValue(number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" negative layer count corrected for""); + image->matte=MagickTrue; + } + + /* + We only need to know if the image has an alpha channel + */ + if (skip_layers != MagickFalse) + return(MagickTrue); + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" image contains %.20g layers"",(double) number_layers); + + if (number_layers == 0) + ThrowBinaryException(CorruptImageError,""InvalidNumberOfLayers"", + image->filename); + + layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers, + sizeof(*layer_info)); + if (layer_info == (LayerInfo *) NULL) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of LayerInfo failed""); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + (void) ResetMagickMemory(layer_info,0,(size_t) number_layers* + sizeof(*layer_info)); + + for (i=0; i < number_layers; i++) + { + ssize_t + x, + y; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading layer #%.20g"",(double) i+1); + layer_info[i].page.y=ReadBlobSignedLong(image); + layer_info[i].page.x=ReadBlobSignedLong(image); + y=ReadBlobSignedLong(image); + x=ReadBlobSignedLong(image); + layer_info[i].page.width=(size_t) (x-layer_info[i].page.x); + layer_info[i].page.height=(size_t) (y-layer_info[i].page.y); + layer_info[i].channels=ReadBlobShort(image); + if (layer_info[i].channels > MaxPSDChannels) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""MaximumChannelsExceeded"", + image->filename); + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g"", + (double) layer_info[i].page.x,(double) layer_info[i].page.y, + (double) layer_info[i].page.height,(double) + layer_info[i].page.width,(double) layer_info[i].channels); + for (j=0; j < (ssize_t) layer_info[i].channels; j++) + { + layer_info[i].channel_info[j].type=(short) ReadBlobShort(image); + layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info, + image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" channel[%.20g]: type=%.20g, size=%.20g"",(double) j, + (double) layer_info[i].channel_info[j].type, + (double) layer_info[i].channel_info[j].size); + } + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer type was %.4s instead of 8BIM"", type); + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""ImproperImageHeader"", + image->filename); + } + (void) ReadBlob(image,4,(unsigned char *) layer_info[i].blendkey); + ReversePSDString(image,layer_info[i].blendkey,4); + layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + layer_info[i].clipping=(unsigned char) ReadBlobByte(image); + layer_info[i].flags=(unsigned char) ReadBlobByte(image); + layer_info[i].visible=!(layer_info[i].flags & 0x02); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s"", + layer_info[i].blendkey,(double) layer_info[i].opacity, + layer_info[i].clipping ? ""true"" : ""false"",layer_info[i].flags, + layer_info[i].visible ? ""true"" : ""false""); + (void) ReadBlobByte(image); /* filler */ + + size=ReadBlobLong(image); + if (size != 0) + { + MagickSizeType + combined_length, + length; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer contains additional info""); + length=ReadBlobLong(image); + combined_length=length+4; + if (length != 0) + { + /* + Layer mask info. + */ + layer_info[i].mask.page.y=ReadBlobSignedLong(image); + layer_info[i].mask.page.x=ReadBlobSignedLong(image); + layer_info[i].mask.page.height=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.y); + layer_info[i].mask.page.width=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.x); + layer_info[i].mask.background=(unsigned char) ReadBlobByte( + image); + layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image); + if (!(layer_info[i].mask.flags & 0x01)) + { + layer_info[i].mask.page.y=layer_info[i].mask.page.y- + layer_info[i].page.y; + layer_info[i].mask.page.x=layer_info[i].mask.page.x- + layer_info[i].page.x; + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g"", + (double) layer_info[i].mask.page.x,(double) + layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width, + (double) layer_info[i].mask.page.height,(double) + ((MagickOffsetType) length)-18); + /* + Skip over the rest of the layer mask information. + */ + if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + } + } + length=ReadBlobLong(image); + combined_length+=length+4; + if (length != 0) + { + /* + Layer blending ranges info. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer blending ranges: length=%.20g"",(double) + ((MagickOffsetType) length)); + /* + We read it, but don't use it... + */ + for (j=0; j < (ssize_t) length; j+=8) + { + size_t blend_source=ReadBlobLong(image); + size_t blend_dest=ReadBlobLong(image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" source(%x), dest(%x)"",(unsigned int) + blend_source,(unsigned int) blend_dest); + } + } + /* + Layer name. + */ + length=(MagickSizeType) ReadBlobByte(image); + combined_length+=length+1; + if (length > 0) + (void) ReadBlob(image,(size_t) length++,layer_info[i].name); + layer_info[i].name[length]='\0'; + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer name: %s"",layer_info[i].name); + if ((length % 4) != 0) + { + length=4-(length % 4); + combined_length+=length; + /* Skip over the padding of the layer name */ + if (DiscardBlobBytes(image,length) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + length=(MagickSizeType) size-combined_length; + if (length > 0) + { + unsigned char + *info; + + layer_info[i].info=AcquireStringInfo((const size_t) length); + info=GetStringInfoDatum(layer_info[i].info); + (void) ReadBlob(image,(const size_t) length,info); + } + } + } + + for (i=0; i < number_layers; i++) + { + if ((layer_info[i].page.width == 0) || + (layer_info[i].page.height == 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer data is empty""); + continue; + } + + /* + Allocate layered image. + */ + layer_info[i].image=CloneImage(image,layer_info[i].page.width, + layer_info[i].page.height,MagickFalse,exception); + if (layer_info[i].image == (Image *) NULL) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of image for layer %.20g failed"",(double) i); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + + if (layer_info[i].info != (StringInfo *) NULL) + { + (void) SetImageProfile(layer_info[i].image,""psd:additional-info"", + layer_info[i].info); + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + } + } + + if (image_info->ping == MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=0; j < layer_info[i].channels; j++) + { + if (DiscardBlobBytes(image,(MagickSizeType) + layer_info[i].channel_info[j].size) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + continue; + } + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading data for layer %.20g"",(double) i); + status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i], + exception); + if (status == MagickFalse) + break; + + status=SetImageProgress(image,LoadImagesTag,i,(MagickSizeType) + number_layers); + if (status == MagickFalse) + break; + } + } + + if (status != MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=i; j < number_layers - 1; j++) + layer_info[j] = layer_info[j+1]; + number_layers--; + i--; + } + } + + if (number_layers > 0) + { + for (i=0; i < number_layers; i++) + { + if (i > 0) + layer_info[i].image->previous=layer_info[i-1].image; + if (i < (number_layers-1)) + layer_info[i].image->next=layer_info[i+1].image; + layer_info[i].image->page=layer_info[i].page; + } + image->next=layer_info[0].image; + layer_info[0].image->previous=image; + } + layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info); + } + else + layer_info=DestroyLayerInfo(layer_info,number_layers); + } + + return(status); +} +",1,"ModuleExport MagickBooleanType ReadPSDLayers(Image *image, + const ImageInfo *image_info,const PSDInfo *psd_info, + const MagickBooleanType skip_layers,ExceptionInfo *exception) +{ + char + type[4]; + + LayerInfo + *layer_info; + + MagickSizeType + size; + + MagickBooleanType + status; + + register ssize_t + i; + + ssize_t + count, + j, + number_layers; + + size=GetPSDSize(psd_info,image); + if (size == 0) + { + /* + Skip layers & masks. + */ + (void) ReadBlobLong(image); + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + status=MagickFalse; + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + return(MagickTrue); + else + { + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count != 0) && (LocaleNCompare(type,""Lr16"",4) == 0)) + size=GetPSDSize(psd_info,image); + else + return(MagickTrue); + } + } + status=MagickTrue; + if (size != 0) + { + layer_info=(LayerInfo *) NULL; + number_layers=(short) ReadBlobShort(image); + + if (number_layers < 0) + { + /* + The first alpha channel in the merged result contains the + transparency data for the merged result. + */ + number_layers=MagickAbsoluteValue(number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" negative layer count corrected for""); + image->matte=MagickTrue; + } + + /* + We only need to know if the image has an alpha channel + */ + if (skip_layers != MagickFalse) + return(MagickTrue); + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" image contains %.20g layers"",(double) number_layers); + + if (number_layers == 0) + ThrowBinaryException(CorruptImageError,""InvalidNumberOfLayers"", + image->filename); + + layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers, + sizeof(*layer_info)); + if (layer_info == (LayerInfo *) NULL) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of LayerInfo failed""); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + (void) ResetMagickMemory(layer_info,0,(size_t) number_layers* + sizeof(*layer_info)); + + for (i=0; i < number_layers; i++) + { + ssize_t + x, + y; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading layer #%.20g"",(double) i+1); + layer_info[i].page.y=ReadBlobSignedLong(image); + layer_info[i].page.x=ReadBlobSignedLong(image); + y=ReadBlobSignedLong(image); + x=ReadBlobSignedLong(image); + layer_info[i].page.width=(size_t) (x-layer_info[i].page.x); + layer_info[i].page.height=(size_t) (y-layer_info[i].page.y); + layer_info[i].channels=ReadBlobShort(image); + if (layer_info[i].channels > MaxPSDChannels) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""MaximumChannelsExceeded"", + image->filename); + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g"", + (double) layer_info[i].page.x,(double) layer_info[i].page.y, + (double) layer_info[i].page.height,(double) + layer_info[i].page.width,(double) layer_info[i].channels); + for (j=0; j < (ssize_t) layer_info[i].channels; j++) + { + layer_info[i].channel_info[j].type=(short) ReadBlobShort(image); + layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info, + image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" channel[%.20g]: type=%.20g, size=%.20g"",(double) j, + (double) layer_info[i].channel_info[j].type, + (double) layer_info[i].channel_info[j].size); + } + count=ReadBlob(image,4,(unsigned char *) type); + ReversePSDString(image,type,4); + if ((count == 0) || (LocaleNCompare(type,""8BIM"",4) != 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer type was %.4s instead of 8BIM"", type); + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""ImproperImageHeader"", + image->filename); + } + (void) ReadBlob(image,4,(unsigned char *) layer_info[i].blendkey); + ReversePSDString(image,layer_info[i].blendkey,4); + layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + layer_info[i].clipping=(unsigned char) ReadBlobByte(image); + layer_info[i].flags=(unsigned char) ReadBlobByte(image); + layer_info[i].visible=!(layer_info[i].flags & 0x02); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s"", + layer_info[i].blendkey,(double) layer_info[i].opacity, + layer_info[i].clipping ? ""true"" : ""false"",layer_info[i].flags, + layer_info[i].visible ? ""true"" : ""false""); + (void) ReadBlobByte(image); /* filler */ + + size=ReadBlobLong(image); + if (size != 0) + { + MagickSizeType + combined_length, + length; + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer contains additional info""); + length=ReadBlobLong(image); + combined_length=length+4; + if (length != 0) + { + /* + Layer mask info. + */ + layer_info[i].mask.page.y=ReadBlobSignedLong(image); + layer_info[i].mask.page.x=ReadBlobSignedLong(image); + layer_info[i].mask.page.height=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.y); + layer_info[i].mask.page.width=(size_t) (ReadBlobLong(image)- + layer_info[i].mask.page.x); + layer_info[i].mask.background=(unsigned char) ReadBlobByte( + image); + layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image); + if (!(layer_info[i].mask.flags & 0x01)) + { + layer_info[i].mask.page.y=layer_info[i].mask.page.y- + layer_info[i].page.y; + layer_info[i].mask.page.x=layer_info[i].mask.page.x- + layer_info[i].page.x; + } + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g"", + (double) layer_info[i].mask.page.x,(double) + layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width, + (double) layer_info[i].mask.page.height,(double) + ((MagickOffsetType) length)-18); + /* + Skip over the rest of the layer mask information. + */ + if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + } + } + length=ReadBlobLong(image); + combined_length+=length+4; + if (length != 0) + { + /* + Layer blending ranges info. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer blending ranges: length=%.20g"",(double) + ((MagickOffsetType) length)); + /* + We read it, but don't use it... + */ + for (j=0; j < (ssize_t) length; j+=8) + { + size_t blend_source=ReadBlobLong(image); + size_t blend_dest=ReadBlobLong(image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" source(%x), dest(%x)"",(unsigned int) + blend_source,(unsigned int) blend_dest); + } + } + /* + Layer name. + */ + length=(MagickSizeType) ReadBlobByte(image); + combined_length+=length+1; + if (length > 0) + (void) ReadBlob(image,(size_t) length++,layer_info[i].name); + layer_info[i].name[length]='\0'; + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer name: %s"",layer_info[i].name); + if ((length % 4) != 0) + { + length=4-(length % 4); + combined_length+=length; + /* Skip over the padding of the layer name */ + if (DiscardBlobBytes(image,length) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + length=(MagickSizeType) size-combined_length; + if (length > 0) + { + unsigned char + *info; + + layer_info[i].info=AcquireStringInfo((const size_t) length); + info=GetStringInfoDatum(layer_info[i].info); + (void) ReadBlob(image,(const size_t) length,info); + } + } + } + + for (i=0; i < number_layers; i++) + { + if ((layer_info[i].page.width == 0) || + (layer_info[i].page.height == 0)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer data is empty""); + if (layer_info[i].info != (StringInfo *) NULL) + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + continue; + } + + /* + Allocate layered image. + */ + layer_info[i].image=CloneImage(image,layer_info[i].page.width, + layer_info[i].page.height,MagickFalse,exception); + if (layer_info[i].image == (Image *) NULL) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" allocation of image for layer %.20g failed"",(double) i); + ThrowBinaryException(ResourceLimitError,""MemoryAllocationFailed"", + image->filename); + } + + if (layer_info[i].info != (StringInfo *) NULL) + { + (void) SetImageProfile(layer_info[i].image,""psd:additional-info"", + layer_info[i].info); + layer_info[i].info=DestroyStringInfo(layer_info[i].info); + } + } + + if (image_info->ping == MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=0; j < layer_info[i].channels; j++) + { + if (DiscardBlobBytes(image,(MagickSizeType) + layer_info[i].channel_info[j].size) == MagickFalse) + { + layer_info=DestroyLayerInfo(layer_info,number_layers); + ThrowBinaryException(CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + } + } + continue; + } + + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading data for layer %.20g"",(double) i); + status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i], + exception); + if (status == MagickFalse) + break; + + status=SetImageProgress(image,LoadImagesTag,i,(MagickSizeType) + number_layers); + if (status == MagickFalse) + break; + } + } + + if (status != MagickFalse) + { + for (i=0; i < number_layers; i++) + { + if (layer_info[i].image == (Image *) NULL) + { + for (j=i; j < number_layers - 1; j++) + layer_info[j] = layer_info[j+1]; + number_layers--; + i--; + } + } + + if (number_layers > 0) + { + for (i=0; i < number_layers; i++) + { + if (i > 0) + layer_info[i].image->previous=layer_info[i-1].image; + if (i < (number_layers-1)) + layer_info[i].image->next=layer_info[i+1].image; + layer_info[i].image->page=layer_info[i].page; + } + image->next=layer_info[0].image; + layer_info[0].image->previous=image; + } + layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info); + } + else + layer_info=DestroyLayerInfo(layer_info,number_layers); + } + + return(status); +} +","@@ -1719,6 +1719,8 @@ ModuleExport MagickBooleanType ReadPSDLayers(Image *image, + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" layer data is empty""); ++ if (layer_info[i].info != (StringInfo *) NULL) ++ layer_info[i].info=DestroyStringInfo(layer_info[i].info); + continue; + } + ",3218,3454,4096 +11461,"void TestingAutomationProvider::SendJSONRequest(int handle, + const std::string& json_request, + IPC::Message* reply_message) { + scoped_ptr values; + base::JSONReader reader; + std::string error; + values.reset(reader.ReadAndReturnError(json_request, true, NULL, &error)); + if (!error.empty()) { + AutomationJSONReply(this, reply_message).SendError(error); + return; + } + + std::string command; + DictionaryValue* dict_value = NULL; + if (values->GetType() != Value::TYPE_DICTIONARY) { + AutomationJSONReply(this, reply_message).SendError(""not a dict""); + return; + } + dict_value = static_cast(values.get()); + if (!dict_value->GetStringASCII(std::string(""command""), &command)) { + AutomationJSONReply(this, reply_message) + .SendError(""no command key in dict or not a string command""); + return; + } + + std::map handler_map; + handler_map[""WaitForAllTabsToStopLoading""] = + &TestingAutomationProvider::WaitForAllViewsToStopLoading; + handler_map[""GetIndicesFromTab""] = + &TestingAutomationProvider::GetIndicesFromTab; + handler_map[""NavigateToURL""] = + &TestingAutomationProvider::NavigateToURL; + handler_map[""GetLocalStatePrefsInfo""] = + &TestingAutomationProvider::GetLocalStatePrefsInfo; + handler_map[""SetLocalStatePrefs""] = + &TestingAutomationProvider::SetLocalStatePrefs; + handler_map[""GetPrefsInfo""] = &TestingAutomationProvider::GetPrefsInfo; + handler_map[""SetPrefs""] = &TestingAutomationProvider::SetPrefs; + handler_map[""ExecuteJavascript""] = + &TestingAutomationProvider::ExecuteJavascriptJSON; + handler_map[""ExecuteJavascriptInRenderView""] = + &TestingAutomationProvider::ExecuteJavascriptInRenderView; + handler_map[""GoForward""] = + &TestingAutomationProvider::GoForward; + handler_map[""GoBack""] = + &TestingAutomationProvider::GoBack; + handler_map[""Reload""] = + &TestingAutomationProvider::ReloadJSON; + handler_map[""CaptureEntirePage""] = + &TestingAutomationProvider::CaptureEntirePageJSON; + handler_map[""GetCookies""] = + &TestingAutomationProvider::GetCookiesJSON; + handler_map[""DeleteCookie""] = + &TestingAutomationProvider::DeleteCookieJSON; + handler_map[""SetCookie""] = + &TestingAutomationProvider::SetCookieJSON; + handler_map[""GetTabIds""] = + &TestingAutomationProvider::GetTabIds; + handler_map[""GetViews""] = + &TestingAutomationProvider::GetViews; + handler_map[""IsTabIdValid""] = + &TestingAutomationProvider::IsTabIdValid; + handler_map[""DoesAutomationObjectExist""] = + &TestingAutomationProvider::DoesAutomationObjectExist; + handler_map[""CloseTab""] = + &TestingAutomationProvider::CloseTabJSON; + handler_map[""WebkitMouseMove""] = + &TestingAutomationProvider::WebkitMouseMove; + handler_map[""WebkitMouseClick""] = + &TestingAutomationProvider::WebkitMouseClick; + handler_map[""WebkitMouseDrag""] = + &TestingAutomationProvider::WebkitMouseDrag; + handler_map[""WebkitMouseButtonUp""] = + &TestingAutomationProvider::WebkitMouseButtonUp; + handler_map[""WebkitMouseButtonDown""] = + &TestingAutomationProvider::WebkitMouseButtonDown; + handler_map[""WebkitMouseDoubleClick""] = + &TestingAutomationProvider::WebkitMouseDoubleClick; + handler_map[""DragAndDropFilePaths""] = + &TestingAutomationProvider::DragAndDropFilePaths; + handler_map[""SendWebkitKeyEvent""] = + &TestingAutomationProvider::SendWebkitKeyEvent; + handler_map[""SendOSLevelKeyEventToTab""] = + &TestingAutomationProvider::SendOSLevelKeyEventToTab; + handler_map[""ProcessWebMouseEvent""] = + &TestingAutomationProvider::ProcessWebMouseEvent; + handler_map[""ActivateTab""] = + &TestingAutomationProvider::ActivateTabJSON; + handler_map[""GetAppModalDialogMessage""] = + &TestingAutomationProvider::GetAppModalDialogMessage; + handler_map[""AcceptOrDismissAppModalDialog""] = + &TestingAutomationProvider::AcceptOrDismissAppModalDialog; + handler_map[""GetChromeDriverAutomationVersion""] = + &TestingAutomationProvider::GetChromeDriverAutomationVersion; + handler_map[""UpdateExtensionsNow""] = + &TestingAutomationProvider::UpdateExtensionsNow; + handler_map[""IsPageActionVisible""] = + &TestingAutomationProvider::IsPageActionVisible; + handler_map[""CreateNewAutomationProvider""] = + &TestingAutomationProvider::CreateNewAutomationProvider; + handler_map[""GetBrowserInfo""] = + &TestingAutomationProvider::GetBrowserInfo; + handler_map[""OpenNewBrowserWindowWithNewProfile""] = + &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; + handler_map[""GetMultiProfileInfo""] = + &TestingAutomationProvider::GetMultiProfileInfo; + handler_map[""GetProcessInfo""] = + &TestingAutomationProvider::GetProcessInfo; + handler_map[""SetPolicies""] = + &TestingAutomationProvider::SetPolicies; + handler_map[""GetPolicyDefinitionList""] = + &TestingAutomationProvider::GetPolicyDefinitionList; + handler_map[""InstallExtension""] = + &TestingAutomationProvider::InstallExtension; + handler_map[""GetExtensionsInfo""] = + &TestingAutomationProvider::GetExtensionsInfo; + handler_map[""UninstallExtensionById""] = + &TestingAutomationProvider::UninstallExtensionById; + handler_map[""SetExtensionStateById""] = + &TestingAutomationProvider::SetExtensionStateById; + handler_map[""RefreshPolicies""] = + &TestingAutomationProvider::RefreshPolicies; + handler_map[""TriggerPageActionById""] = + &TestingAutomationProvider::TriggerPageActionById; + handler_map[""TriggerBrowserActionById""] = + &TestingAutomationProvider::TriggerBrowserActionById; +#if defined(OS_CHROMEOS) + handler_map[""GetLoginInfo""] = &TestingAutomationProvider::GetLoginInfo; + handler_map[""ShowCreateAccountUI""] = + &TestingAutomationProvider::ShowCreateAccountUI; + handler_map[""LoginAsGuest""] = &TestingAutomationProvider::LoginAsGuest; + handler_map[""Login""] = &TestingAutomationProvider::Login; + + handler_map[""LockScreen""] = &TestingAutomationProvider::LockScreen; + handler_map[""UnlockScreen""] = &TestingAutomationProvider::UnlockScreen; + handler_map[""SignoutInScreenLocker""] = + &TestingAutomationProvider::SignoutInScreenLocker; + + handler_map[""GetBatteryInfo""] = &TestingAutomationProvider::GetBatteryInfo; + + handler_map[""GetNetworkInfo""] = &TestingAutomationProvider::GetNetworkInfo; + handler_map[""NetworkScan""] = &TestingAutomationProvider::NetworkScan; + handler_map[""ToggleNetworkDevice""] = + &TestingAutomationProvider::ToggleNetworkDevice; + handler_map[""ConnectToCellularNetwork""] = + &TestingAutomationProvider::ConnectToCellularNetwork; + handler_map[""DisconnectFromCellularNetwork""] = + &TestingAutomationProvider::DisconnectFromCellularNetwork; + handler_map[""ConnectToWifiNetwork""] = + &TestingAutomationProvider::ConnectToWifiNetwork; + handler_map[""ConnectToHiddenWifiNetwork""] = + &TestingAutomationProvider::ConnectToHiddenWifiNetwork; + handler_map[""DisconnectFromWifiNetwork""] = + &TestingAutomationProvider::DisconnectFromWifiNetwork; + handler_map[""ForgetWifiNetwork""] = + &TestingAutomationProvider::ForgetWifiNetwork; + + handler_map[""AddPrivateNetwork""] = + &TestingAutomationProvider::AddPrivateNetwork; + handler_map[""GetPrivateNetworkInfo""] = + &TestingAutomationProvider::GetPrivateNetworkInfo; + handler_map[""ConnectToPrivateNetwork""] = + &TestingAutomationProvider::ConnectToPrivateNetwork; + handler_map[""DisconnectFromPrivateNetwork""] = + &TestingAutomationProvider::DisconnectFromPrivateNetwork; + + handler_map[""IsEnterpriseDevice""] = + &TestingAutomationProvider::IsEnterpriseDevice; + handler_map[""GetEnterprisePolicyInfo""] = + &TestingAutomationProvider::GetEnterprisePolicyInfo; + handler_map[""EnrollEnterpriseDevice""] = + &TestingAutomationProvider::EnrollEnterpriseDevice; + + handler_map[""GetTimeInfo""] = &TestingAutomationProvider::GetTimeInfo; + handler_map[""SetTimezone""] = &TestingAutomationProvider::SetTimezone; + + handler_map[""GetUpdateInfo""] = &TestingAutomationProvider::GetUpdateInfo; + handler_map[""UpdateCheck""] = &TestingAutomationProvider::UpdateCheck; + handler_map[""SetReleaseTrack""] = &TestingAutomationProvider::SetReleaseTrack; + + handler_map[""GetVolumeInfo""] = &TestingAutomationProvider::GetVolumeInfo; + handler_map[""SetVolume""] = &TestingAutomationProvider::SetVolume; + handler_map[""SetMute""] = &TestingAutomationProvider::SetMute; + +#endif // defined(OS_CHROMEOS) + + std::map browser_handler_map; + browser_handler_map[""DisablePlugin""] = + &TestingAutomationProvider::DisablePlugin; + browser_handler_map[""EnablePlugin""] = + &TestingAutomationProvider::EnablePlugin; + browser_handler_map[""GetPluginsInfo""] = + &TestingAutomationProvider::GetPluginsInfo; + + browser_handler_map[""GetNavigationInfo""] = + &TestingAutomationProvider::GetNavigationInfo; + + browser_handler_map[""PerformActionOnInfobar""] = + &TestingAutomationProvider::PerformActionOnInfobar; + + browser_handler_map[""GetHistoryInfo""] = + &TestingAutomationProvider::GetHistoryInfo; + browser_handler_map[""AddHistoryItem""] = + &TestingAutomationProvider::AddHistoryItem; + + browser_handler_map[""GetOmniboxInfo""] = + &TestingAutomationProvider::GetOmniboxInfo; + browser_handler_map[""SetOmniboxText""] = + &TestingAutomationProvider::SetOmniboxText; + browser_handler_map[""OmniboxAcceptInput""] = + &TestingAutomationProvider::OmniboxAcceptInput; + browser_handler_map[""OmniboxMovePopupSelection""] = + &TestingAutomationProvider::OmniboxMovePopupSelection; + + browser_handler_map[""GetInstantInfo""] = + &TestingAutomationProvider::GetInstantInfo; + + browser_handler_map[""LoadSearchEngineInfo""] = + &TestingAutomationProvider::LoadSearchEngineInfo; + browser_handler_map[""GetSearchEngineInfo""] = + &TestingAutomationProvider::GetSearchEngineInfo; + browser_handler_map[""AddOrEditSearchEngine""] = + &TestingAutomationProvider::AddOrEditSearchEngine; + browser_handler_map[""PerformActionOnSearchEngine""] = + &TestingAutomationProvider::PerformActionOnSearchEngine; + + browser_handler_map[""SetWindowDimensions""] = + &TestingAutomationProvider::SetWindowDimensions; + + browser_handler_map[""GetDownloadsInfo""] = + &TestingAutomationProvider::GetDownloadsInfo; + browser_handler_map[""WaitForAllDownloadsToComplete""] = + &TestingAutomationProvider::WaitForAllDownloadsToComplete; + browser_handler_map[""PerformActionOnDownload""] = + &TestingAutomationProvider::PerformActionOnDownload; + + browser_handler_map[""GetInitialLoadTimes""] = + &TestingAutomationProvider::GetInitialLoadTimes; + + browser_handler_map[""SaveTabContents""] = + &TestingAutomationProvider::SaveTabContents; + + browser_handler_map[""ImportSettings""] = + &TestingAutomationProvider::ImportSettings; + + browser_handler_map[""AddSavedPassword""] = + &TestingAutomationProvider::AddSavedPassword; + browser_handler_map[""RemoveSavedPassword""] = + &TestingAutomationProvider::RemoveSavedPassword; + browser_handler_map[""GetSavedPasswords""] = + &TestingAutomationProvider::GetSavedPasswords; + + browser_handler_map[""ClearBrowsingData""] = + &TestingAutomationProvider::ClearBrowsingData; + + browser_handler_map[""GetBlockedPopupsInfo""] = + &TestingAutomationProvider::GetBlockedPopupsInfo; + browser_handler_map[""UnblockAndLaunchBlockedPopup""] = + &TestingAutomationProvider::UnblockAndLaunchBlockedPopup; + + browser_handler_map[""GetThemeInfo""] = + &TestingAutomationProvider::GetThemeInfo; + + browser_handler_map[""FindInPage""] = &TestingAutomationProvider::FindInPage; + + browser_handler_map[""SelectTranslateOption""] = + &TestingAutomationProvider::SelectTranslateOption; + browser_handler_map[""GetTranslateInfo""] = + &TestingAutomationProvider::GetTranslateInfo; + + browser_handler_map[""GetAutofillProfile""] = + &TestingAutomationProvider::GetAutofillProfile; + browser_handler_map[""FillAutofillProfile""] = + &TestingAutomationProvider::FillAutofillProfile; + browser_handler_map[""SubmitAutofillForm""] = + &TestingAutomationProvider::SubmitAutofillForm; + browser_handler_map[""AutofillTriggerSuggestions""] = + &TestingAutomationProvider::AutofillTriggerSuggestions; + browser_handler_map[""AutofillHighlightSuggestion""] = + &TestingAutomationProvider::AutofillHighlightSuggestion; + browser_handler_map[""AutofillAcceptSelection""] = + &TestingAutomationProvider::AutofillAcceptSelection; + + browser_handler_map[""GetAllNotifications""] = + &TestingAutomationProvider::GetAllNotifications; + browser_handler_map[""CloseNotification""] = + &TestingAutomationProvider::CloseNotification; + browser_handler_map[""WaitForNotificationCount""] = + &TestingAutomationProvider::WaitForNotificationCount; + + browser_handler_map[""SignInToSync""] = + &TestingAutomationProvider::SignInToSync; + browser_handler_map[""GetSyncInfo""] = &TestingAutomationProvider::GetSyncInfo; + browser_handler_map[""AwaitFullSyncCompletion""] = + &TestingAutomationProvider::AwaitFullSyncCompletion; + browser_handler_map[""AwaitSyncRestart""] = + &TestingAutomationProvider::AwaitSyncRestart; + browser_handler_map[""EnableSyncForDatatypes""] = + &TestingAutomationProvider::EnableSyncForDatatypes; + browser_handler_map[""DisableSyncForDatatypes""] = + &TestingAutomationProvider::DisableSyncForDatatypes; + + browser_handler_map[""GetNTPInfo""] = + &TestingAutomationProvider::GetNTPInfo; + browser_handler_map[""MoveNTPMostVisitedThumbnail""] = + &TestingAutomationProvider::MoveNTPMostVisitedThumbnail; + browser_handler_map[""RemoveNTPMostVisitedThumbnail""] = + &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail; + browser_handler_map[""UnpinNTPMostVisitedThumbnail""] = + &TestingAutomationProvider::UnpinNTPMostVisitedThumbnail; + browser_handler_map[""RestoreAllNTPMostVisitedThumbnails""] = + &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails; + + browser_handler_map[""KillRendererProcess""] = + &TestingAutomationProvider::KillRendererProcess; + + browser_handler_map[""LaunchApp""] = &TestingAutomationProvider::LaunchApp; + browser_handler_map[""SetAppLaunchType""] = + &TestingAutomationProvider::SetAppLaunchType; +#if defined(OS_CHROMEOS) + browser_handler_map[""CaptureProfilePhoto""] = + &TestingAutomationProvider::CaptureProfilePhoto; + browser_handler_map[""GetTimeInfo""] = &TestingAutomationProvider::GetTimeInfo; + browser_handler_map[""GetProxySettings""] = + &TestingAutomationProvider::GetProxySettings; + browser_handler_map[""SetProxySettings""] = + &TestingAutomationProvider::SetProxySettings; +#endif // defined(OS_CHROMEOS) + + if (browser_handler_map.find(std::string(command)) != + browser_handler_map.end()) { + Browser* browser = NULL; + if (!browser_tracker_->ContainsHandle(handle) || + !(browser = browser_tracker_->GetResource(handle))) { + if (handler_map.find(std::string(command)) != handler_map.end()) + (this->*handler_map[command])(dict_value, reply_message); + else + AutomationJSONReply(this, reply_message).SendError( + ""No browser object.""); + } else { + (this->*browser_handler_map[command])(browser, dict_value, reply_message); + } + } else if (handler_map.find(std::string(command)) != handler_map.end()) { + (this->*handler_map[command])(dict_value, reply_message); + } else { + std::string error_string = ""Unknown command. Options: ""; + for (std::map::const_iterator it = + handler_map.begin(); it != handler_map.end(); ++it) { + error_string += it->first + "", ""; + } + for (std::map::const_iterator it = + browser_handler_map.begin(); it != browser_handler_map.end(); ++it) { + error_string += it->first + "", ""; + } + AutomationJSONReply(this, reply_message).SendError(error_string); + } +} +",0,"void TestingAutomationProvider::SendJSONRequest(int handle, + const std::string& json_request, + IPC::Message* reply_message) { + scoped_ptr values; + base::JSONReader reader; + std::string error; + values.reset(reader.ReadAndReturnError(json_request, true, NULL, &error)); + if (!error.empty()) { + AutomationJSONReply(this, reply_message).SendError(error); + return; + } + + std::string command; + DictionaryValue* dict_value = NULL; + if (values->GetType() != Value::TYPE_DICTIONARY) { + AutomationJSONReply(this, reply_message).SendError(""not a dict""); + return; + } + dict_value = static_cast(values.get()); + if (!dict_value->GetStringASCII(std::string(""command""), &command)) { + AutomationJSONReply(this, reply_message) + .SendError(""no command key in dict or not a string command""); + return; + } + + std::map handler_map; + handler_map[""WaitForAllTabsToStopLoading""] = + &TestingAutomationProvider::WaitForAllViewsToStopLoading; + handler_map[""GetIndicesFromTab""] = + &TestingAutomationProvider::GetIndicesFromTab; + handler_map[""NavigateToURL""] = + &TestingAutomationProvider::NavigateToURL; + handler_map[""GetLocalStatePrefsInfo""] = + &TestingAutomationProvider::GetLocalStatePrefsInfo; + handler_map[""SetLocalStatePrefs""] = + &TestingAutomationProvider::SetLocalStatePrefs; + handler_map[""GetPrefsInfo""] = &TestingAutomationProvider::GetPrefsInfo; + handler_map[""SetPrefs""] = &TestingAutomationProvider::SetPrefs; + handler_map[""ExecuteJavascript""] = + &TestingAutomationProvider::ExecuteJavascriptJSON; + handler_map[""ExecuteJavascriptInRenderView""] = + &TestingAutomationProvider::ExecuteJavascriptInRenderView; + handler_map[""GoForward""] = + &TestingAutomationProvider::GoForward; + handler_map[""GoBack""] = + &TestingAutomationProvider::GoBack; + handler_map[""Reload""] = + &TestingAutomationProvider::ReloadJSON; + handler_map[""CaptureEntirePage""] = + &TestingAutomationProvider::CaptureEntirePageJSON; + handler_map[""GetCookies""] = + &TestingAutomationProvider::GetCookiesJSON; + handler_map[""DeleteCookie""] = + &TestingAutomationProvider::DeleteCookieJSON; + handler_map[""SetCookie""] = + &TestingAutomationProvider::SetCookieJSON; + handler_map[""GetTabIds""] = + &TestingAutomationProvider::GetTabIds; + handler_map[""GetViews""] = + &TestingAutomationProvider::GetViews; + handler_map[""IsTabIdValid""] = + &TestingAutomationProvider::IsTabIdValid; + handler_map[""DoesAutomationObjectExist""] = + &TestingAutomationProvider::DoesAutomationObjectExist; + handler_map[""CloseTab""] = + &TestingAutomationProvider::CloseTabJSON; + handler_map[""WebkitMouseMove""] = + &TestingAutomationProvider::WebkitMouseMove; + handler_map[""WebkitMouseClick""] = + &TestingAutomationProvider::WebkitMouseClick; + handler_map[""WebkitMouseDrag""] = + &TestingAutomationProvider::WebkitMouseDrag; + handler_map[""WebkitMouseButtonUp""] = + &TestingAutomationProvider::WebkitMouseButtonUp; + handler_map[""WebkitMouseButtonDown""] = + &TestingAutomationProvider::WebkitMouseButtonDown; + handler_map[""WebkitMouseDoubleClick""] = + &TestingAutomationProvider::WebkitMouseDoubleClick; + handler_map[""DragAndDropFilePaths""] = + &TestingAutomationProvider::DragAndDropFilePaths; + handler_map[""SendWebkitKeyEvent""] = + &TestingAutomationProvider::SendWebkitKeyEvent; + handler_map[""SendOSLevelKeyEventToTab""] = + &TestingAutomationProvider::SendOSLevelKeyEventToTab; + handler_map[""ProcessWebMouseEvent""] = + &TestingAutomationProvider::ProcessWebMouseEvent; + handler_map[""ActivateTab""] = + &TestingAutomationProvider::ActivateTabJSON; + handler_map[""GetAppModalDialogMessage""] = + &TestingAutomationProvider::GetAppModalDialogMessage; + handler_map[""AcceptOrDismissAppModalDialog""] = + &TestingAutomationProvider::AcceptOrDismissAppModalDialog; + handler_map[""GetChromeDriverAutomationVersion""] = + &TestingAutomationProvider::GetChromeDriverAutomationVersion; + handler_map[""UpdateExtensionsNow""] = + &TestingAutomationProvider::UpdateExtensionsNow; + handler_map[""IsPageActionVisible""] = + &TestingAutomationProvider::IsPageActionVisible; + handler_map[""CreateNewAutomationProvider""] = + &TestingAutomationProvider::CreateNewAutomationProvider; + handler_map[""GetBrowserInfo""] = + &TestingAutomationProvider::GetBrowserInfo; + handler_map[""OpenNewBrowserWindowWithNewProfile""] = + &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; + handler_map[""GetMultiProfileInfo""] = + &TestingAutomationProvider::GetMultiProfileInfo; + handler_map[""GetProcessInfo""] = + &TestingAutomationProvider::GetProcessInfo; + handler_map[""SetPolicies""] = + &TestingAutomationProvider::SetPolicies; + handler_map[""GetPolicyDefinitionList""] = + &TestingAutomationProvider::GetPolicyDefinitionList; + handler_map[""InstallExtension""] = + &TestingAutomationProvider::InstallExtension; + handler_map[""GetExtensionsInfo""] = + &TestingAutomationProvider::GetExtensionsInfo; + handler_map[""UninstallExtensionById""] = + &TestingAutomationProvider::UninstallExtensionById; + handler_map[""SetExtensionStateById""] = + &TestingAutomationProvider::SetExtensionStateById; + handler_map[""RefreshPolicies""] = + &TestingAutomationProvider::RefreshPolicies; + handler_map[""TriggerPageActionById""] = + &TestingAutomationProvider::TriggerPageActionById; + handler_map[""TriggerBrowserActionById""] = + &TestingAutomationProvider::TriggerBrowserActionById; +#if defined(OS_CHROMEOS) + handler_map[""GetLoginInfo""] = &TestingAutomationProvider::GetLoginInfo; + handler_map[""ShowCreateAccountUI""] = + &TestingAutomationProvider::ShowCreateAccountUI; + handler_map[""LoginAsGuest""] = &TestingAutomationProvider::LoginAsGuest; + handler_map[""Login""] = &TestingAutomationProvider::Login; + + handler_map[""LockScreen""] = &TestingAutomationProvider::LockScreen; + handler_map[""UnlockScreen""] = &TestingAutomationProvider::UnlockScreen; + handler_map[""SignoutInScreenLocker""] = + &TestingAutomationProvider::SignoutInScreenLocker; + + handler_map[""GetBatteryInfo""] = &TestingAutomationProvider::GetBatteryInfo; + + handler_map[""GetNetworkInfo""] = &TestingAutomationProvider::GetNetworkInfo; + handler_map[""NetworkScan""] = &TestingAutomationProvider::NetworkScan; + handler_map[""ToggleNetworkDevice""] = + &TestingAutomationProvider::ToggleNetworkDevice; + handler_map[""ConnectToCellularNetwork""] = + &TestingAutomationProvider::ConnectToCellularNetwork; + handler_map[""DisconnectFromCellularNetwork""] = + &TestingAutomationProvider::DisconnectFromCellularNetwork; + handler_map[""ConnectToWifiNetwork""] = + &TestingAutomationProvider::ConnectToWifiNetwork; + handler_map[""ConnectToHiddenWifiNetwork""] = + &TestingAutomationProvider::ConnectToHiddenWifiNetwork; + handler_map[""DisconnectFromWifiNetwork""] = + &TestingAutomationProvider::DisconnectFromWifiNetwork; + handler_map[""ForgetWifiNetwork""] = + &TestingAutomationProvider::ForgetWifiNetwork; + + handler_map[""AddPrivateNetwork""] = + &TestingAutomationProvider::AddPrivateNetwork; + handler_map[""GetPrivateNetworkInfo""] = + &TestingAutomationProvider::GetPrivateNetworkInfo; + handler_map[""ConnectToPrivateNetwork""] = + &TestingAutomationProvider::ConnectToPrivateNetwork; + handler_map[""DisconnectFromPrivateNetwork""] = + &TestingAutomationProvider::DisconnectFromPrivateNetwork; + + handler_map[""IsEnterpriseDevice""] = + &TestingAutomationProvider::IsEnterpriseDevice; + handler_map[""GetEnterprisePolicyInfo""] = + &TestingAutomationProvider::GetEnterprisePolicyInfo; + handler_map[""EnrollEnterpriseDevice""] = + &TestingAutomationProvider::EnrollEnterpriseDevice; + + handler_map[""GetTimeInfo""] = &TestingAutomationProvider::GetTimeInfo; + handler_map[""SetTimezone""] = &TestingAutomationProvider::SetTimezone; + + handler_map[""GetUpdateInfo""] = &TestingAutomationProvider::GetUpdateInfo; + handler_map[""UpdateCheck""] = &TestingAutomationProvider::UpdateCheck; + handler_map[""SetReleaseTrack""] = &TestingAutomationProvider::SetReleaseTrack; + + handler_map[""GetVolumeInfo""] = &TestingAutomationProvider::GetVolumeInfo; + handler_map[""SetVolume""] = &TestingAutomationProvider::SetVolume; + handler_map[""SetMute""] = &TestingAutomationProvider::SetMute; + +#endif // defined(OS_CHROMEOS) + + std::map browser_handler_map; + browser_handler_map[""DisablePlugin""] = + &TestingAutomationProvider::DisablePlugin; + browser_handler_map[""EnablePlugin""] = + &TestingAutomationProvider::EnablePlugin; + browser_handler_map[""GetPluginsInfo""] = + &TestingAutomationProvider::GetPluginsInfo; + + browser_handler_map[""GetNavigationInfo""] = + &TestingAutomationProvider::GetNavigationInfo; + + browser_handler_map[""PerformActionOnInfobar""] = + &TestingAutomationProvider::PerformActionOnInfobar; + + browser_handler_map[""GetHistoryInfo""] = + &TestingAutomationProvider::GetHistoryInfo; + browser_handler_map[""AddHistoryItem""] = + &TestingAutomationProvider::AddHistoryItem; + + browser_handler_map[""GetOmniboxInfo""] = + &TestingAutomationProvider::GetOmniboxInfo; + browser_handler_map[""SetOmniboxText""] = + &TestingAutomationProvider::SetOmniboxText; + browser_handler_map[""OmniboxAcceptInput""] = + &TestingAutomationProvider::OmniboxAcceptInput; + browser_handler_map[""OmniboxMovePopupSelection""] = + &TestingAutomationProvider::OmniboxMovePopupSelection; + + browser_handler_map[""GetInstantInfo""] = + &TestingAutomationProvider::GetInstantInfo; + + browser_handler_map[""LoadSearchEngineInfo""] = + &TestingAutomationProvider::LoadSearchEngineInfo; + browser_handler_map[""GetSearchEngineInfo""] = + &TestingAutomationProvider::GetSearchEngineInfo; + browser_handler_map[""AddOrEditSearchEngine""] = + &TestingAutomationProvider::AddOrEditSearchEngine; + browser_handler_map[""PerformActionOnSearchEngine""] = + &TestingAutomationProvider::PerformActionOnSearchEngine; + + browser_handler_map[""SetWindowDimensions""] = + &TestingAutomationProvider::SetWindowDimensions; + + browser_handler_map[""GetDownloadsInfo""] = + &TestingAutomationProvider::GetDownloadsInfo; + browser_handler_map[""WaitForAllDownloadsToComplete""] = + &TestingAutomationProvider::WaitForAllDownloadsToComplete; + browser_handler_map[""PerformActionOnDownload""] = + &TestingAutomationProvider::PerformActionOnDownload; + + browser_handler_map[""GetInitialLoadTimes""] = + &TestingAutomationProvider::GetInitialLoadTimes; + + browser_handler_map[""SaveTabContents""] = + &TestingAutomationProvider::SaveTabContents; + + browser_handler_map[""ImportSettings""] = + &TestingAutomationProvider::ImportSettings; + + browser_handler_map[""AddSavedPassword""] = + &TestingAutomationProvider::AddSavedPassword; + browser_handler_map[""RemoveSavedPassword""] = + &TestingAutomationProvider::RemoveSavedPassword; + browser_handler_map[""GetSavedPasswords""] = + &TestingAutomationProvider::GetSavedPasswords; + + browser_handler_map[""ClearBrowsingData""] = + &TestingAutomationProvider::ClearBrowsingData; + + browser_handler_map[""GetBlockedPopupsInfo""] = + &TestingAutomationProvider::GetBlockedPopupsInfo; + browser_handler_map[""UnblockAndLaunchBlockedPopup""] = + &TestingAutomationProvider::UnblockAndLaunchBlockedPopup; + + browser_handler_map[""GetThemeInfo""] = + &TestingAutomationProvider::GetThemeInfo; + + browser_handler_map[""FindInPage""] = &TestingAutomationProvider::FindInPage; + + browser_handler_map[""SelectTranslateOption""] = + &TestingAutomationProvider::SelectTranslateOption; + browser_handler_map[""GetTranslateInfo""] = + &TestingAutomationProvider::GetTranslateInfo; + + browser_handler_map[""GetAutofillProfile""] = + &TestingAutomationProvider::GetAutofillProfile; + browser_handler_map[""FillAutofillProfile""] = + &TestingAutomationProvider::FillAutofillProfile; + browser_handler_map[""SubmitAutofillForm""] = + &TestingAutomationProvider::SubmitAutofillForm; + browser_handler_map[""AutofillTriggerSuggestions""] = + &TestingAutomationProvider::AutofillTriggerSuggestions; + browser_handler_map[""AutofillHighlightSuggestion""] = + &TestingAutomationProvider::AutofillHighlightSuggestion; + browser_handler_map[""AutofillAcceptSelection""] = + &TestingAutomationProvider::AutofillAcceptSelection; + + browser_handler_map[""GetAllNotifications""] = + &TestingAutomationProvider::GetAllNotifications; + browser_handler_map[""CloseNotification""] = + &TestingAutomationProvider::CloseNotification; + browser_handler_map[""WaitForNotificationCount""] = + &TestingAutomationProvider::WaitForNotificationCount; + + browser_handler_map[""SignInToSync""] = + &TestingAutomationProvider::SignInToSync; + browser_handler_map[""GetSyncInfo""] = &TestingAutomationProvider::GetSyncInfo; + browser_handler_map[""AwaitFullSyncCompletion""] = + &TestingAutomationProvider::AwaitFullSyncCompletion; + browser_handler_map[""AwaitSyncRestart""] = + &TestingAutomationProvider::AwaitSyncRestart; + browser_handler_map[""EnableSyncForDatatypes""] = + &TestingAutomationProvider::EnableSyncForDatatypes; + browser_handler_map[""DisableSyncForDatatypes""] = + &TestingAutomationProvider::DisableSyncForDatatypes; + + browser_handler_map[""GetNTPInfo""] = + &TestingAutomationProvider::GetNTPInfo; + browser_handler_map[""MoveNTPMostVisitedThumbnail""] = + &TestingAutomationProvider::MoveNTPMostVisitedThumbnail; + browser_handler_map[""RemoveNTPMostVisitedThumbnail""] = + &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail; + browser_handler_map[""UnpinNTPMostVisitedThumbnail""] = + &TestingAutomationProvider::UnpinNTPMostVisitedThumbnail; + browser_handler_map[""RestoreAllNTPMostVisitedThumbnails""] = + &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails; + + browser_handler_map[""KillRendererProcess""] = + &TestingAutomationProvider::KillRendererProcess; + + browser_handler_map[""LaunchApp""] = &TestingAutomationProvider::LaunchApp; + browser_handler_map[""SetAppLaunchType""] = + &TestingAutomationProvider::SetAppLaunchType; +#if defined(OS_CHROMEOS) + browser_handler_map[""CaptureProfilePhoto""] = + &TestingAutomationProvider::CaptureProfilePhoto; + browser_handler_map[""GetTimeInfo""] = &TestingAutomationProvider::GetTimeInfo; + browser_handler_map[""GetProxySettings""] = + &TestingAutomationProvider::GetProxySettings; + browser_handler_map[""SetProxySettings""] = + &TestingAutomationProvider::SetProxySettings; +#endif // defined(OS_CHROMEOS) + + if (browser_handler_map.find(std::string(command)) != + browser_handler_map.end()) { + Browser* browser = NULL; + if (!browser_tracker_->ContainsHandle(handle) || + !(browser = browser_tracker_->GetResource(handle))) { + if (handler_map.find(std::string(command)) != handler_map.end()) + (this->*handler_map[command])(dict_value, reply_message); + else + AutomationJSONReply(this, reply_message).SendError( + ""No browser object.""); + } else { + (this->*browser_handler_map[command])(browser, dict_value, reply_message); + } + } else if (handler_map.find(std::string(command)) != handler_map.end()) { + (this->*handler_map[command])(dict_value, reply_message); + } else { + std::string error_string = ""Unknown command. Options: ""; + for (std::map::const_iterator it = + handler_map.begin(); it != handler_map.end(); ++it) { + error_string += it->first + "", ""; + } + for (std::map::const_iterator it = + browser_handler_map.begin(); it != browser_handler_map.end(); ++it) { + error_string += it->first + "", ""; + } + AutomationJSONReply(this, reply_message).SendError(error_string); + } +} +","@@ -4473,7 +4473,7 @@ void TestingAutomationProvider::GetExtensionsInfo( + extension_value->SetString(""public_key"", extension->public_key()); + extension_value->SetString(""description"", extension->description()); + extension_value->SetString(""background_url"", +- extension->background_url().spec()); ++ extension->GetBackgroundURL().spec()); + extension_value->SetString(""options_url"", + extension->options_url().spec()); + extension_value->Set(""host_permissions"",",3515,3751,4096 +7174,"static MagickBooleanType ParseInternalDoctype(XMLTreeRoot *root,char *xml, + size_t length,ExceptionInfo *exception) +{ + char + *c, + **entities, + *n, + **predefined_entitites, + q, + *t, + *v; + + register ssize_t + i; + + ssize_t + j; + + n=(char *) NULL; + predefined_entitites=(char **) AcquireMagickMemory(sizeof(sentinel)); + if (predefined_entitites == (char **) NULL) + ThrowFatalException(ResourceLimitError,""MemoryAllocationFailed""); + (void) CopyMagickMemory(predefined_entitites,sentinel,sizeof(sentinel)); + for (xml[length]='\0'; xml != (char *) NULL; ) + { + while ((*xml != '\0') && (*xml != '<') && (*xml != '%')) + xml++; + if (*xml == '\0') + break; + if (strncmp(xml,""'); + continue; + } + entities=(*c == '%') ? predefined_entitites : root->entities; + for (i=0; entities[i] != (char *) NULL; i++) ; + entities=(char **) ResizeQuantumMemory(entities,(size_t) (i+3), + sizeof(*entities)); + if (entities == (char **) NULL) + ThrowFatalException(ResourceLimitFatalError,""MemoryAllocationFailed""); + if (*c == '%') + predefined_entitites=entities; + else + root->entities=entities; + xml++; + *xml='\0'; + xml=strchr(v,q); + if (xml != (char *) NULL) + { + *xml='\0'; + xml++; + } + entities[i+1]=ParseEntities(v,predefined_entitites,'%'); + entities[i+2]=(char *) NULL; + if (ValidateEntities(n,entities[i+1],entities) != MagickFalse) + entities[i]=n; + else + { + if (entities[i+1] != v) + entities[i+1]=DestroyString(entities[i+1]); + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""circular entity declaration &%s"",n); + predefined_entitites=(char **) RelinquishMagickMemory( + predefined_entitites); + return(MagickFalse); + } + } + else + if (strncmp(xml,""""); + if (*xml == '>') + continue; + *xml='\0'; + i=0; + while ((root->attributes[i] != (char **) NULL) && + (n != (char *) NULL) && + (strcmp(n,root->attributes[i][0]) != 0)) + i++; + while ((*(n=xml+strspn(xml+1,XMLWhitespace)+1) != '\0') && + (*n != '>')) + { + xml=n+strcspn(n,XMLWhitespace); + if (*xml != '\0') + *xml='\0'; + else + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""malformed "")-1; + if (*c == ' ') + continue; + v=(char *) NULL; + } + else + if (((*xml == '""') || (*xml == '\'')) && + ((xml=strchr(v=xml+1,*xml)) != (char *) NULL)) + *xml='\0'; + else + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""malformed attributes[i] == (char **) NULL) + { + /* + New attribute tag. + */ + if (i == 0) + root->attributes=(char ***) AcquireQuantumMemory(2, + sizeof(*root->attributes)); + else + root->attributes=(char ***) ResizeQuantumMemory( + root->attributes,(size_t) (i+2), + sizeof(*root->attributes)); + if (root->attributes == (char ***) NULL) + ThrowFatalException(ResourceLimitFatalError, + ""MemoryAllocationFailed""); + root->attributes[i]=(char **) AcquireQuantumMemory(2, + sizeof(**root->attributes)); + if (root->attributes[i] == (char **) NULL) + ThrowFatalException(ResourceLimitFatalError, + ""MemoryAllocationFailed""); + root->attributes[i][0]=ConstantString(t); + root->attributes[i][1]=(char *) NULL; + root->attributes[i+1]=(char **) NULL; + } + for (j=1; root->attributes[i][j] != (char *) NULL; j+=3) ; + root->attributes[i]=(char **) ResizeQuantumMemory( + root->attributes[i],(size_t) (j+4),sizeof(**root->attributes)); + if (root->attributes[i] == (char **) NULL) + ThrowFatalException(ResourceLimitFatalError, + ""MemoryAllocationFailed""); + root->attributes[i][j+3]=(char *) NULL; + root->attributes[i][j+2]=ConstantString(c); + root->attributes[i][j+1]=(char *) NULL; + if (v != (char *) NULL) + root->attributes[i][j+1]=ParseEntities(v,root->entities,*c); + root->attributes[i][j]=ConstantString(n); + } + } + else + if (strncmp(xml, """"); + else + if (strncmp(xml,""""); + if (xml != (char *) NULL) + { + ParseProcessingInstructions(root,c,(size_t) (xml-c)); + xml++; + } + } + else + if (*xml == '<') + xml=strchr(xml,'>'); + else + if ((*(xml++) == '%') && (root->standalone == MagickFalse)) + break; + } + predefined_entitites=(char **) RelinquishMagickMemory(predefined_entitites); + return(MagickTrue); +} +",0,"static MagickBooleanType ParseInternalDoctype(XMLTreeRoot *root,char *xml, + size_t length,ExceptionInfo *exception) +{ + char + *c, + **entities, + *n, + **predefined_entitites, + q, + *t, + *v; + + register ssize_t + i; + + ssize_t + j; + + n=(char *) NULL; + predefined_entitites=(char **) AcquireMagickMemory(sizeof(sentinel)); + if (predefined_entitites == (char **) NULL) + ThrowFatalException(ResourceLimitError,""MemoryAllocationFailed""); + (void) CopyMagickMemory(predefined_entitites,sentinel,sizeof(sentinel)); + for (xml[length]='\0'; xml != (char *) NULL; ) + { + while ((*xml != '\0') && (*xml != '<') && (*xml != '%')) + xml++; + if (*xml == '\0') + break; + if (strncmp(xml,""'); + continue; + } + entities=(*c == '%') ? predefined_entitites : root->entities; + for (i=0; entities[i] != (char *) NULL; i++) ; + entities=(char **) ResizeQuantumMemory(entities,(size_t) (i+3), + sizeof(*entities)); + if (entities == (char **) NULL) + ThrowFatalException(ResourceLimitFatalError,""MemoryAllocationFailed""); + if (*c == '%') + predefined_entitites=entities; + else + root->entities=entities; + xml++; + *xml='\0'; + xml=strchr(v,q); + if (xml != (char *) NULL) + { + *xml='\0'; + xml++; + } + entities[i+1]=ParseEntities(v,predefined_entitites,'%'); + entities[i+2]=(char *) NULL; + if (ValidateEntities(n,entities[i+1],entities) != MagickFalse) + entities[i]=n; + else + { + if (entities[i+1] != v) + entities[i+1]=DestroyString(entities[i+1]); + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""circular entity declaration &%s"",n); + predefined_entitites=(char **) RelinquishMagickMemory( + predefined_entitites); + return(MagickFalse); + } + } + else + if (strncmp(xml,""""); + if (*xml == '>') + continue; + *xml='\0'; + i=0; + while ((root->attributes[i] != (char **) NULL) && + (n != (char *) NULL) && + (strcmp(n,root->attributes[i][0]) != 0)) + i++; + while ((*(n=xml+strspn(xml+1,XMLWhitespace)+1) != '\0') && + (*n != '>')) + { + xml=n+strcspn(n,XMLWhitespace); + if (*xml != '\0') + *xml='\0'; + else + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""malformed "")-1; + if (*c == ' ') + continue; + v=(char *) NULL; + } + else + if (((*xml == '""') || (*xml == '\'')) && + ((xml=strchr(v=xml+1,*xml)) != (char *) NULL)) + *xml='\0'; + else + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""malformed attributes[i] == (char **) NULL) + { + /* + New attribute tag. + */ + if (i == 0) + root->attributes=(char ***) AcquireQuantumMemory(2, + sizeof(*root->attributes)); + else + root->attributes=(char ***) ResizeQuantumMemory( + root->attributes,(size_t) (i+2), + sizeof(*root->attributes)); + if (root->attributes == (char ***) NULL) + ThrowFatalException(ResourceLimitFatalError, + ""MemoryAllocationFailed""); + root->attributes[i]=(char **) AcquireQuantumMemory(2, + sizeof(**root->attributes)); + if (root->attributes[i] == (char **) NULL) + ThrowFatalException(ResourceLimitFatalError, + ""MemoryAllocationFailed""); + root->attributes[i][0]=ConstantString(t); + root->attributes[i][1]=(char *) NULL; + root->attributes[i+1]=(char **) NULL; + } + for (j=1; root->attributes[i][j] != (char *) NULL; j+=3) ; + root->attributes[i]=(char **) ResizeQuantumMemory( + root->attributes[i],(size_t) (j+4),sizeof(**root->attributes)); + if (root->attributes[i] == (char **) NULL) + ThrowFatalException(ResourceLimitFatalError, + ""MemoryAllocationFailed""); + root->attributes[i][j+3]=(char *) NULL; + root->attributes[i][j+2]=ConstantString(c); + root->attributes[i][j+1]=(char *) NULL; + if (v != (char *) NULL) + root->attributes[i][j+1]=ParseEntities(v,root->entities,*c); + root->attributes[i][j]=ConstantString(n); + } + } + else + if (strncmp(xml, """"); + else + if (strncmp(xml,""""); + if (xml != (char *) NULL) + { + ParseProcessingInstructions(root,c,(size_t) (xml-c)); + xml++; + } + } + else + if (*xml == '<') + xml=strchr(xml,'>'); + else + if ((*(xml++) == '%') && (root->standalone == MagickFalse)) + break; + } + predefined_entitites=(char **) RelinquishMagickMemory(predefined_entitites); + return(MagickTrue); +} +","@@ -2140,7 +2140,10 @@ MagickExport XMLTreeInfo *NewXMLTree(const char *xml,ExceptionInfo *exception) + if ((ignore_depth == 0) && (IsSkipTag(tag) == MagickFalse)) + ParseOpenTag(root,tag,attributes); + else +- ignore_depth++; ++ { ++ ignore_depth++; ++ (void) DestroyXMLTreeAttributes(attributes); ++ } + *p=c; + } + else",1864,2100,4096 +6800,"static const ut8 *parse_dex_class_method(RBinFile *binfile, RBinDexObj *bin, + RBinDexClass *c, RBinClass *cls, + const ut8 *p, const ut8 *p_end, + int *sym_count, ut64 DM, int *methods, + bool is_direct) { + struct r_bin_t *rbin = binfile->rbin; + ut8 ff2[16] = {0}; + ut8 ff3[8] = {0}; + int i; + ut64 omi = 0; + bool catchAll; + ut16 regsz, ins_size, outs_size, tries_size; + ut16 handler_off, start_addr, insn_count; + ut32 debug_info_off, insns_size; + const ut8 *encoded_method_addr; + for (i = 0; i < DM; i++) { + encoded_method_addr = p; + char *method_name, *flag_name; + ut64 MI, MA, MC; + p = r_uleb128 (p, p_end - p, &MI); + MI += omi; + omi = MI; + p = r_uleb128 (p, p_end - p, &MA); + p = r_uleb128 (p, p_end - p, &MC); + if (MI < bin->header.method_size) { + if (methods) { + methods[MI] = 1; + } + } + method_name = dex_method_name (bin, MI); + char *signature = dex_method_signature (bin, MI); + if (!method_name) { + method_name = strdup (""unknown""); + } + flag_name = r_str_newf (""%s.method.%s%s"", cls->name, + method_name, signature); + if (!flag_name) { + R_FREE (method_name); + R_FREE (signature); + continue; + } + ut64 v2, handler_type, handler_addr; + int t; + if (MC > 0) { + if (MC + 16 >= bin->size || MC + 16 < MC) { + R_FREE (method_name); + R_FREE (flag_name); + R_FREE (signature); + continue; + } + if (r_buf_read_at (binfile->buf, + binfile->buf->base + MC, ff2, + 16) < 1) { + R_FREE (method_name); + R_FREE (flag_name); + R_FREE (signature); + continue; + } + regsz = r_read_le16 (ff2); + ins_size = r_read_le16 (ff2 + 2); + outs_size = r_read_le16 (ff2 + 4); + tries_size = r_read_le16 (ff2 + 6); + debug_info_off = r_read_le32 (ff2 + 8); + insns_size = r_read_le32 (ff2 + 12); + int padd = 0; + if (tries_size > 0 && insns_size % 2) { + padd = 2; + } + t = 16 + 2 * insns_size + padd; + } + if (dexdump) { + const char* accessStr = createAccessFlagStr (MA, kAccessForMethod); + rbin->cb_printf ("" #%d : (in %s;)\n"", i, cls->name); + rbin->cb_printf ("" name : '%s'\n"", method_name); + rbin->cb_printf ("" type : '%s'\n"", signature); + rbin->cb_printf ("" access : 0x%04x (%s)\n"", + (unsigned int)MA, accessStr); + } + + if (MC > 0) { + if (dexdump) { + rbin->cb_printf ("" code -\n""); + rbin->cb_printf ("" registers : %d\n"", regsz); + rbin->cb_printf ("" ins : %d\n"", ins_size); + rbin->cb_printf ("" outs : %d\n"", outs_size); + rbin->cb_printf ( + "" insns size : %d 16-bit code "" + ""units\n"", + insns_size); + } + if (tries_size > 0) { + if (dexdump) { + rbin->cb_printf ("" catches : %d\n"", tries_size); + } + int j, m = 0; + for (j = 0; j < tries_size; ++j) { + ut64 offset = MC + t + j * 8; + if (offset >= bin->size || offset < MC) { + R_FREE (signature); + break; + } + if (r_buf_read_at ( + binfile->buf, + binfile->buf->base + offset, + ff3, 8) < 1) { + R_FREE (signature); + break; + } + start_addr = r_read_le32 (ff3); + insn_count = r_read_le16 (ff3 + 4); + handler_off = r_read_le16 (ff3 + 6); + char* s = NULL; + if (dexdump) { + rbin->cb_printf ( + "" 0x%04x - "" + ""0x%04x\n"", + start_addr, + (start_addr + + insn_count)); + } + + const ut8 *p3, *p3_end; + int off = MC + t + tries_size * 8 + handler_off; + if (off >= bin->size || off < tries_size) { + R_FREE (signature); + break; + } + p3 = r_buf_get_at (binfile->buf, off, NULL); + p3_end = p3 + binfile->buf->length - off; + st64 size = r_sleb128 (&p3, p3_end); + + if (size <= 0) { + catchAll = true; + size = -size; + } else { + catchAll = false; + } + + for (m = 0; m < size; m++) { + p3 = r_uleb128 (p3, p3_end - p3, &handler_type); + p3 = r_uleb128 (p3, p3_end - p3, &handler_addr); + + if (handler_type > 0 && + handler_type < + bin->header.types_size) { + s = getstr (bin, bin->types[handler_type].descriptor_id); + if (dexdump) { + rbin->cb_printf ( + "" %s "" + ""-> 0x%04llx\n"", + s, + handler_addr); + } + } else { + if (dexdump) { + rbin->cb_printf ( + "" "" + ""(error) -> "" + ""0x%04llx\n"", + handler_addr); + } + } + } + if (catchAll) { + p3 = r_uleb128 (p3, p3_end - p3, &v2); + if (dexdump) { + rbin->cb_printf ( + "" "" + "" -> "" + ""0x%04llx\n"", + v2); + } + } + } + } else { + if (dexdump) { + rbin->cb_printf ( + "" catches : "" + ""(none)\n""); + } + } + } else { + if (dexdump) { + rbin->cb_printf ( + "" code : (none)\n""); + } + } + if (*flag_name) { + RBinSymbol *sym = R_NEW0 (RBinSymbol); + sym->name = flag_name; + if (MC > 0) { + sym->type = r_str_const (""FUNC""); + sym->paddr = MC;// + 0x10; + sym->vaddr = MC;// + 0x10; + } else { + sym->type = r_str_const (""METH""); + sym->paddr = encoded_method_addr - binfile->buf->buf; + sym->vaddr = encoded_method_addr - binfile->buf->buf; + } + if ((MA & 0x1) == 0x1) { + sym->bind = r_str_const (""GLOBAL""); + } else { + sym->bind = r_str_const (""LOCAL""); + } + sym->ordinal = (*sym_count)++; + if (MC > 0) { + if (r_buf_read_at (binfile->buf, binfile->buf->base + MC, ff2, 16) < 1) { + R_FREE (sym); + R_FREE (signature); + continue; + } + ut16 tries_size = r_read_le16 (ff2 + 6); + ut32 insns_size = r_read_le32 (ff2 + 12); + ut64 prolog_size = 2 + 2 + 2 + 2 + 4 + 4; + if (tries_size > 0) { + } + sym->paddr = MC + prolog_size;// + 0x10; + sym->vaddr = MC + prolog_size;// + 0x10; + sym->size = insns_size * 2; + r_list_append (bin->methods_list, sym); + r_list_append (cls->methods, sym); + + if (bin->code_from > sym->paddr) { + bin->code_from = sym->paddr; + } + if (bin->code_to < sym->paddr) { + bin->code_to = sym->paddr; + } + + if (!mdb) { + mdb = sdb_new0 (); + } + sdb_num_set (mdb, sdb_fmt (0, ""method.%d"", MI), sym->paddr, 0); + if (0) { + if (MA & 0x10000) { //ACC_CONSTRUCTOR + if (!cdb) { + cdb = sdb_new0 (); + } + sdb_num_set (cdb, sdb_fmt (0, ""%d"", c->class_id), sym->paddr, 0); + } + } + } else { + sym->size = 0; + r_list_append (bin->methods_list, sym); + r_list_append (cls->methods, sym); + } + if (MC > 0 && debug_info_off > 0 && bin->header.data_offset < debug_info_off && + debug_info_off < bin->header.data_offset + bin->header.data_size) { + dex_parse_debug_item (binfile, bin, c, MI, MA, sym->paddr, ins_size, + insns_size, cls->name, regsz, debug_info_off); + } else if (MC > 0) { + if (dexdump) { + rbin->cb_printf ("" positions :\n""); + rbin->cb_printf ("" locals :\n""); + } + } + } else { + R_FREE (flag_name); + } + R_FREE (signature); + R_FREE (method_name); + } + return p; +} +",0,"static const ut8 *parse_dex_class_method(RBinFile *binfile, RBinDexObj *bin, + RBinDexClass *c, RBinClass *cls, + const ut8 *p, const ut8 *p_end, + int *sym_count, ut64 DM, int *methods, + bool is_direct) { + struct r_bin_t *rbin = binfile->rbin; + ut8 ff2[16] = {0}; + ut8 ff3[8] = {0}; + int i; + ut64 omi = 0; + bool catchAll; + ut16 regsz, ins_size, outs_size, tries_size; + ut16 handler_off, start_addr, insn_count; + ut32 debug_info_off, insns_size; + const ut8 *encoded_method_addr; + for (i = 0; i < DM; i++) { + encoded_method_addr = p; + char *method_name, *flag_name; + ut64 MI, MA, MC; + p = r_uleb128 (p, p_end - p, &MI); + MI += omi; + omi = MI; + p = r_uleb128 (p, p_end - p, &MA); + p = r_uleb128 (p, p_end - p, &MC); + if (MI < bin->header.method_size) { + if (methods) { + methods[MI] = 1; + } + } + method_name = dex_method_name (bin, MI); + char *signature = dex_method_signature (bin, MI); + if (!method_name) { + method_name = strdup (""unknown""); + } + flag_name = r_str_newf (""%s.method.%s%s"", cls->name, + method_name, signature); + if (!flag_name) { + R_FREE (method_name); + R_FREE (signature); + continue; + } + ut64 v2, handler_type, handler_addr; + int t; + if (MC > 0) { + if (MC + 16 >= bin->size || MC + 16 < MC) { + R_FREE (method_name); + R_FREE (flag_name); + R_FREE (signature); + continue; + } + if (r_buf_read_at (binfile->buf, + binfile->buf->base + MC, ff2, + 16) < 1) { + R_FREE (method_name); + R_FREE (flag_name); + R_FREE (signature); + continue; + } + regsz = r_read_le16 (ff2); + ins_size = r_read_le16 (ff2 + 2); + outs_size = r_read_le16 (ff2 + 4); + tries_size = r_read_le16 (ff2 + 6); + debug_info_off = r_read_le32 (ff2 + 8); + insns_size = r_read_le32 (ff2 + 12); + int padd = 0; + if (tries_size > 0 && insns_size % 2) { + padd = 2; + } + t = 16 + 2 * insns_size + padd; + } + if (dexdump) { + const char* accessStr = createAccessFlagStr (MA, kAccessForMethod); + rbin->cb_printf ("" #%d : (in %s;)\n"", i, cls->name); + rbin->cb_printf ("" name : '%s'\n"", method_name); + rbin->cb_printf ("" type : '%s'\n"", signature); + rbin->cb_printf ("" access : 0x%04x (%s)\n"", + (unsigned int)MA, accessStr); + } + + if (MC > 0) { + if (dexdump) { + rbin->cb_printf ("" code -\n""); + rbin->cb_printf ("" registers : %d\n"", regsz); + rbin->cb_printf ("" ins : %d\n"", ins_size); + rbin->cb_printf ("" outs : %d\n"", outs_size); + rbin->cb_printf ( + "" insns size : %d 16-bit code "" + ""units\n"", + insns_size); + } + if (tries_size > 0) { + if (dexdump) { + rbin->cb_printf ("" catches : %d\n"", tries_size); + } + int j, m = 0; + for (j = 0; j < tries_size; ++j) { + ut64 offset = MC + t + j * 8; + if (offset >= bin->size || offset < MC) { + R_FREE (signature); + break; + } + if (r_buf_read_at ( + binfile->buf, + binfile->buf->base + offset, + ff3, 8) < 1) { + R_FREE (signature); + break; + } + start_addr = r_read_le32 (ff3); + insn_count = r_read_le16 (ff3 + 4); + handler_off = r_read_le16 (ff3 + 6); + char* s = NULL; + if (dexdump) { + rbin->cb_printf ( + "" 0x%04x - "" + ""0x%04x\n"", + start_addr, + (start_addr + + insn_count)); + } + + const ut8 *p3, *p3_end; + int off = MC + t + tries_size * 8 + handler_off; + if (off >= bin->size || off < tries_size) { + R_FREE (signature); + break; + } + p3 = r_buf_get_at (binfile->buf, off, NULL); + p3_end = p3 + binfile->buf->length - off; + st64 size = r_sleb128 (&p3, p3_end); + + if (size <= 0) { + catchAll = true; + size = -size; + } else { + catchAll = false; + } + + for (m = 0; m < size; m++) { + p3 = r_uleb128 (p3, p3_end - p3, &handler_type); + p3 = r_uleb128 (p3, p3_end - p3, &handler_addr); + + if (handler_type > 0 && + handler_type < + bin->header.types_size) { + s = getstr (bin, bin->types[handler_type].descriptor_id); + if (dexdump) { + rbin->cb_printf ( + "" %s "" + ""-> 0x%04llx\n"", + s, + handler_addr); + } + } else { + if (dexdump) { + rbin->cb_printf ( + "" "" + ""(error) -> "" + ""0x%04llx\n"", + handler_addr); + } + } + } + if (catchAll) { + p3 = r_uleb128 (p3, p3_end - p3, &v2); + if (dexdump) { + rbin->cb_printf ( + "" "" + "" -> "" + ""0x%04llx\n"", + v2); + } + } + } + } else { + if (dexdump) { + rbin->cb_printf ( + "" catches : "" + ""(none)\n""); + } + } + } else { + if (dexdump) { + rbin->cb_printf ( + "" code : (none)\n""); + } + } + if (*flag_name) { + RBinSymbol *sym = R_NEW0 (RBinSymbol); + sym->name = flag_name; + if (MC > 0) { + sym->type = r_str_const (""FUNC""); + sym->paddr = MC;// + 0x10; + sym->vaddr = MC;// + 0x10; + } else { + sym->type = r_str_const (""METH""); + sym->paddr = encoded_method_addr - binfile->buf->buf; + sym->vaddr = encoded_method_addr - binfile->buf->buf; + } + if ((MA & 0x1) == 0x1) { + sym->bind = r_str_const (""GLOBAL""); + } else { + sym->bind = r_str_const (""LOCAL""); + } + sym->ordinal = (*sym_count)++; + if (MC > 0) { + if (r_buf_read_at (binfile->buf, binfile->buf->base + MC, ff2, 16) < 1) { + R_FREE (sym); + R_FREE (signature); + continue; + } + ut16 tries_size = r_read_le16 (ff2 + 6); + ut32 insns_size = r_read_le32 (ff2 + 12); + ut64 prolog_size = 2 + 2 + 2 + 2 + 4 + 4; + if (tries_size > 0) { + } + sym->paddr = MC + prolog_size;// + 0x10; + sym->vaddr = MC + prolog_size;// + 0x10; + sym->size = insns_size * 2; + r_list_append (bin->methods_list, sym); + r_list_append (cls->methods, sym); + + if (bin->code_from > sym->paddr) { + bin->code_from = sym->paddr; + } + if (bin->code_to < sym->paddr) { + bin->code_to = sym->paddr; + } + + if (!mdb) { + mdb = sdb_new0 (); + } + sdb_num_set (mdb, sdb_fmt (0, ""method.%d"", MI), sym->paddr, 0); + if (0) { + if (MA & 0x10000) { //ACC_CONSTRUCTOR + if (!cdb) { + cdb = sdb_new0 (); + } + sdb_num_set (cdb, sdb_fmt (0, ""%d"", c->class_id), sym->paddr, 0); + } + } + } else { + sym->size = 0; + r_list_append (bin->methods_list, sym); + r_list_append (cls->methods, sym); + } + if (MC > 0 && debug_info_off > 0 && bin->header.data_offset < debug_info_off && + debug_info_off < bin->header.data_offset + bin->header.data_size) { + dex_parse_debug_item (binfile, bin, c, MI, MA, sym->paddr, ins_size, + insns_size, cls->name, regsz, debug_info_off); + } else if (MC > 0) { + if (dexdump) { + rbin->cb_printf ("" positions :\n""); + rbin->cb_printf ("" locals :\n""); + } + } + } else { + R_FREE (flag_name); + } + R_FREE (signature); + R_FREE (method_name); + } + return p; +} +","@@ -377,6 +377,9 @@ static void dex_parse_debug_item(RBinFile *binfile, RBinDexObj *bin, + --parameters_size; + } + ++ if (p4 <= 0) { ++ return; ++ } + ut8 opcode = *(p4++) & 0xff; + while (keep) { + switch (opcode) {",2559,2795,4096 +7320,"MagickExport MagickBooleanType ProfileImage(Image *image,const char *name, + const void *datum,const size_t length, + const MagickBooleanType magick_unused(clone)) +{ +#define ProfileImageTag ""Profile/Image"" +#define ThrowProfileException(severity,tag,context) \ +{ \ + if (source_profile != (cmsHPROFILE) NULL) \ + (void) cmsCloseProfile(source_profile); \ + if (target_profile != (cmsHPROFILE) NULL) \ + (void) cmsCloseProfile(target_profile); \ + ThrowBinaryException(severity,tag,context); \ +} + + MagickBooleanType + status; + + StringInfo + *profile; + + magick_unreferenced(clone); + + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(name != (const char *) NULL); + if ((datum == (const void *) NULL) || (length == 0)) + { + char + *next; + + /* + Delete image profile(s). + */ + ResetImageProfileIterator(image); + for (next=GetNextImageProfile(image); next != (const char *) NULL; ) + { + if (IsOptionMember(next,name) != MagickFalse) + { + (void) DeleteImageProfile(image,next); + ResetImageProfileIterator(image); + } + next=GetNextImageProfile(image); + } + return(MagickTrue); + } + /* + Add a ICC, IPTC, or generic profile to the image. + */ + status=MagickTrue; + profile=AcquireStringInfo((size_t) length); + SetStringInfoDatum(profile,(unsigned char *) datum); + if ((LocaleCompare(name,""icc"") != 0) && (LocaleCompare(name,""icm"") != 0)) + status=SetImageProfile(image,name,profile); + else + { + const StringInfo + *icc_profile; + + icc_profile=GetImageProfile(image,""icc""); + if ((icc_profile != (const StringInfo *) NULL) && + (CompareStringInfo(icc_profile,profile) == 0)) + { + const char + *value; + + value=GetImageProperty(image,""exif:ColorSpace""); + (void) value; + if (LocaleCompare(value,""1"") != 0) + (void) SetsRGBImageProfile(image); + value=GetImageProperty(image,""exif:InteroperabilityIndex""); + if (LocaleCompare(value,""R98."") != 0) + (void) SetsRGBImageProfile(image); + /* Future. + value=GetImageProperty(image,""exif:InteroperabilityIndex""); + if (LocaleCompare(value,""R03."") != 0) + (void) SetAdobeRGB1998ImageProfile(image); + */ + icc_profile=GetImageProfile(image,""icc""); + } + if ((icc_profile != (const StringInfo *) NULL) && + (CompareStringInfo(icc_profile,profile) == 0)) + { + profile=DestroyStringInfo(profile); + return(MagickTrue); + } +#if !defined(MAGICKCORE_LCMS_DELEGATE) + (void) ThrowMagickException(&image->exception,GetMagickModule(), + MissingDelegateWarning,""DelegateLibrarySupportNotBuiltIn"",""`%s' (LCMS)"", + image->filename); +#else + { + cmsHPROFILE + source_profile; + + /* + Transform pixel colors as defined by the color profiles. + */ + cmsSetLogErrorHandler(LCMSExceptionHandler); + source_profile=cmsOpenProfileFromMemTHR((cmsContext) image, + GetStringInfoDatum(profile),(cmsUInt32Number) + GetStringInfoLength(profile)); + if (source_profile == (cmsHPROFILE) NULL) + ThrowBinaryException(ResourceLimitError, + ""ColorspaceColorProfileMismatch"",name); + if ((cmsGetDeviceClass(source_profile) != cmsSigLinkClass) && + (icc_profile == (StringInfo *) NULL)) + status=SetImageProfile(image,name,profile); + else + { + CacheView + *image_view; + + ColorspaceType + source_colorspace, + target_colorspace; + + cmsColorSpaceSignature + signature; + + cmsHPROFILE + target_profile; + + cmsHTRANSFORM + *magick_restrict transform; + + cmsUInt32Number + flags, + source_type, + target_type; + + ExceptionInfo + *exception; + + int + intent; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + size_t + source_channels, + target_channels; + + ssize_t + y; + + unsigned short + **magick_restrict source_pixels, + **magick_restrict target_pixels; + + exception=(&image->exception); + target_profile=(cmsHPROFILE) NULL; + if (icc_profile != (StringInfo *) NULL) + { + target_profile=source_profile; + source_profile=cmsOpenProfileFromMemTHR((cmsContext) image, + GetStringInfoDatum(icc_profile),(cmsUInt32Number) + GetStringInfoLength(icc_profile)); + if (source_profile == (cmsHPROFILE) NULL) + ThrowProfileException(ResourceLimitError, + ""ColorspaceColorProfileMismatch"",name); + } + switch (cmsGetColorSpace(source_profile)) + { + case cmsSigCmykData: + { + source_colorspace=CMYKColorspace; + source_type=(cmsUInt32Number) TYPE_CMYK_16; + source_channels=4; + break; + } + case cmsSigGrayData: + { + source_colorspace=GRAYColorspace; + source_type=(cmsUInt32Number) TYPE_GRAY_16; + source_channels=1; + break; + } + case cmsSigLabData: + { + source_colorspace=LabColorspace; + source_type=(cmsUInt32Number) TYPE_Lab_16; + source_channels=3; + break; + } + case cmsSigLuvData: + { + source_colorspace=YUVColorspace; + source_type=(cmsUInt32Number) TYPE_YUV_16; + source_channels=3; + break; + } + case cmsSigRgbData: + { + source_colorspace=sRGBColorspace; + source_type=(cmsUInt32Number) TYPE_RGB_16; + source_channels=3; + break; + } + case cmsSigXYZData: + { + source_colorspace=XYZColorspace; + source_type=(cmsUInt32Number) TYPE_XYZ_16; + source_channels=3; + break; + } + case cmsSigYCbCrData: + { + source_colorspace=YCbCrColorspace; + source_type=(cmsUInt32Number) TYPE_YCbCr_16; + source_channels=3; + break; + } + default: + { + source_colorspace=UndefinedColorspace; + source_type=(cmsUInt32Number) TYPE_RGB_16; + source_channels=3; + break; + } + } + signature=cmsGetPCS(source_profile); + if (target_profile != (cmsHPROFILE) NULL) + signature=cmsGetColorSpace(target_profile); + switch (signature) + { + case cmsSigCmykData: + { + target_colorspace=CMYKColorspace; + target_type=(cmsUInt32Number) TYPE_CMYK_16; + target_channels=4; + break; + } + case cmsSigLabData: + { + target_colorspace=LabColorspace; + target_type=(cmsUInt32Number) TYPE_Lab_16; + target_channels=3; + break; + } + case cmsSigGrayData: + { + target_colorspace=GRAYColorspace; + target_type=(cmsUInt32Number) TYPE_GRAY_16; + target_channels=1; + break; + } + case cmsSigLuvData: + { + target_colorspace=YUVColorspace; + target_type=(cmsUInt32Number) TYPE_YUV_16; + target_channels=3; + break; + } + case cmsSigRgbData: + { + target_colorspace=sRGBColorspace; + target_type=(cmsUInt32Number) TYPE_RGB_16; + target_channels=3; + break; + } + case cmsSigXYZData: + { + target_colorspace=XYZColorspace; + target_type=(cmsUInt32Number) TYPE_XYZ_16; + target_channels=3; + break; + } + case cmsSigYCbCrData: + { + target_colorspace=YCbCrColorspace; + target_type=(cmsUInt32Number) TYPE_YCbCr_16; + target_channels=3; + break; + } + default: + { + target_colorspace=UndefinedColorspace; + target_type=(cmsUInt32Number) TYPE_RGB_16; + target_channels=3; + break; + } + } + if ((source_colorspace == UndefinedColorspace) || + (target_colorspace == UndefinedColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == GRAYColorspace) && + (SetImageGray(image,exception) == MagickFalse)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == CMYKColorspace) && + (image->colorspace != CMYKColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == XYZColorspace) && + (image->colorspace != XYZColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == YCbCrColorspace) && + (image->colorspace != YCbCrColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace != CMYKColorspace) && + (source_colorspace != GRAYColorspace) && + (source_colorspace != LabColorspace) && + (source_colorspace != XYZColorspace) && + (source_colorspace != YCbCrColorspace) && + (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + switch (image->rendering_intent) + { + case AbsoluteIntent: intent=INTENT_ABSOLUTE_COLORIMETRIC; break; + case PerceptualIntent: intent=INTENT_PERCEPTUAL; break; + case RelativeIntent: intent=INTENT_RELATIVE_COLORIMETRIC; break; + case SaturationIntent: intent=INTENT_SATURATION; break; + default: intent=INTENT_PERCEPTUAL; break; + } + flags=cmsFLAGS_HIGHRESPRECALC; +#if defined(cmsFLAGS_BLACKPOINTCOMPENSATION) + if (image->black_point_compensation != MagickFalse) + flags|=cmsFLAGS_BLACKPOINTCOMPENSATION; +#endif + transform=AcquireTransformThreadSet(image,source_profile, + source_type,target_profile,target_type,intent,flags); + if (transform == (cmsHTRANSFORM *) NULL) + ThrowProfileException(ImageError,""UnableToCreateColorTransform"", + name); + /* + Transform image as dictated by the source & target image profiles. + */ + source_pixels=AcquirePixelThreadSet(image->columns,source_channels); + target_pixels=AcquirePixelThreadSet(image->columns,target_channels); + if ((source_pixels == (unsigned short **) NULL) || + (target_pixels == (unsigned short **) NULL)) + { + transform=DestroyTransformThreadSet(transform); + ThrowProfileException(ResourceLimitError, + ""MemoryAllocationFailed"",image->filename); + } + if (SetImageStorageClass(image,DirectClass) == MagickFalse) + { + target_pixels=DestroyPixelThreadSet(target_pixels); + source_pixels=DestroyPixelThreadSet(source_pixels); + transform=DestroyTransformThreadSet(transform); + if (source_profile != (cmsHPROFILE) NULL) + (void) cmsCloseProfile(source_profile); + if (target_profile != (cmsHPROFILE) NULL) + (void) cmsCloseProfile(target_profile); + return(MagickFalse); + } + if (target_colorspace == CMYKColorspace) + (void) SetImageColorspace(image,target_colorspace); + status=MagickTrue; + progress=0; + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static,4) shared(status) \ + magick_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + const int + id = GetOpenMPThreadId(); + + MagickBooleanType + sync; + + register IndexPacket + *magick_restrict indexes; + + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + register unsigned short + *p; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (PixelPacket *) NULL) + { + status=MagickFalse; + continue; + } + indexes=GetCacheViewAuthenticIndexQueue(image_view); + p=source_pixels[id]; + for (x=0; x < (ssize_t) image->columns; x++) + { + *p++=ScaleQuantumToShort(GetPixelRed(q)); + if (source_channels > 1) + { + *p++=ScaleQuantumToShort(GetPixelGreen(q)); + *p++=ScaleQuantumToShort(GetPixelBlue(q)); + } + if (source_channels > 3) + *p++=ScaleQuantumToShort(GetPixelIndex(indexes+x)); + q++; + } + cmsDoTransform(transform[id],source_pixels[id],target_pixels[id], + (unsigned int) image->columns); + p=target_pixels[id]; + q-=image->columns; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(q,ScaleShortToQuantum(*p)); + SetPixelGreen(q,GetPixelRed(q)); + SetPixelBlue(q,GetPixelRed(q)); + p++; + if (target_channels > 1) + { + SetPixelGreen(q,ScaleShortToQuantum(*p)); + p++; + SetPixelBlue(q,ScaleShortToQuantum(*p)); + p++; + } + if (target_channels > 3) + { + SetPixelIndex(indexes+x,ScaleShortToQuantum(*p)); + p++; + } + q++; + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp critical (MagickCore_ProfileImage) +#endif + proceed=SetImageProgress(image,ProfileImageTag,progress++, + image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + (void) SetImageColorspace(image,target_colorspace); + switch (signature) + { + case cmsSigRgbData: + { + image->type=image->matte == MagickFalse ? TrueColorType : + TrueColorMatteType; + break; + } + case cmsSigCmykData: + { + image->type=image->matte == MagickFalse ? ColorSeparationType : + ColorSeparationMatteType; + break; + } + case cmsSigGrayData: + { + image->type=image->matte == MagickFalse ? GrayscaleType : + GrayscaleMatteType; + break; + } + default: + break; + } + target_pixels=DestroyPixelThreadSet(target_pixels); + source_pixels=DestroyPixelThreadSet(source_pixels); + transform=DestroyTransformThreadSet(transform); + if (cmsGetDeviceClass(source_profile) != cmsSigLinkClass) + status=SetImageProfile(image,name,profile); + if (target_profile != (cmsHPROFILE) NULL) + (void) cmsCloseProfile(target_profile); + } + (void) cmsCloseProfile(source_profile); + } +#endif + } + profile=DestroyStringInfo(profile); + return(status); +} +",0,"MagickExport MagickBooleanType ProfileImage(Image *image,const char *name, + const void *datum,const size_t length, + const MagickBooleanType magick_unused(clone)) +{ +#define ProfileImageTag ""Profile/Image"" +#define ThrowProfileException(severity,tag,context) \ +{ \ + if (source_profile != (cmsHPROFILE) NULL) \ + (void) cmsCloseProfile(source_profile); \ + if (target_profile != (cmsHPROFILE) NULL) \ + (void) cmsCloseProfile(target_profile); \ + ThrowBinaryException(severity,tag,context); \ +} + + MagickBooleanType + status; + + StringInfo + *profile; + + magick_unreferenced(clone); + + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(name != (const char *) NULL); + if ((datum == (const void *) NULL) || (length == 0)) + { + char + *next; + + /* + Delete image profile(s). + */ + ResetImageProfileIterator(image); + for (next=GetNextImageProfile(image); next != (const char *) NULL; ) + { + if (IsOptionMember(next,name) != MagickFalse) + { + (void) DeleteImageProfile(image,next); + ResetImageProfileIterator(image); + } + next=GetNextImageProfile(image); + } + return(MagickTrue); + } + /* + Add a ICC, IPTC, or generic profile to the image. + */ + status=MagickTrue; + profile=AcquireStringInfo((size_t) length); + SetStringInfoDatum(profile,(unsigned char *) datum); + if ((LocaleCompare(name,""icc"") != 0) && (LocaleCompare(name,""icm"") != 0)) + status=SetImageProfile(image,name,profile); + else + { + const StringInfo + *icc_profile; + + icc_profile=GetImageProfile(image,""icc""); + if ((icc_profile != (const StringInfo *) NULL) && + (CompareStringInfo(icc_profile,profile) == 0)) + { + const char + *value; + + value=GetImageProperty(image,""exif:ColorSpace""); + (void) value; + if (LocaleCompare(value,""1"") != 0) + (void) SetsRGBImageProfile(image); + value=GetImageProperty(image,""exif:InteroperabilityIndex""); + if (LocaleCompare(value,""R98."") != 0) + (void) SetsRGBImageProfile(image); + /* Future. + value=GetImageProperty(image,""exif:InteroperabilityIndex""); + if (LocaleCompare(value,""R03."") != 0) + (void) SetAdobeRGB1998ImageProfile(image); + */ + icc_profile=GetImageProfile(image,""icc""); + } + if ((icc_profile != (const StringInfo *) NULL) && + (CompareStringInfo(icc_profile,profile) == 0)) + { + profile=DestroyStringInfo(profile); + return(MagickTrue); + } +#if !defined(MAGICKCORE_LCMS_DELEGATE) + (void) ThrowMagickException(&image->exception,GetMagickModule(), + MissingDelegateWarning,""DelegateLibrarySupportNotBuiltIn"",""`%s' (LCMS)"", + image->filename); +#else + { + cmsHPROFILE + source_profile; + + /* + Transform pixel colors as defined by the color profiles. + */ + cmsSetLogErrorHandler(LCMSExceptionHandler); + source_profile=cmsOpenProfileFromMemTHR((cmsContext) image, + GetStringInfoDatum(profile),(cmsUInt32Number) + GetStringInfoLength(profile)); + if (source_profile == (cmsHPROFILE) NULL) + ThrowBinaryException(ResourceLimitError, + ""ColorspaceColorProfileMismatch"",name); + if ((cmsGetDeviceClass(source_profile) != cmsSigLinkClass) && + (icc_profile == (StringInfo *) NULL)) + status=SetImageProfile(image,name,profile); + else + { + CacheView + *image_view; + + ColorspaceType + source_colorspace, + target_colorspace; + + cmsColorSpaceSignature + signature; + + cmsHPROFILE + target_profile; + + cmsHTRANSFORM + *magick_restrict transform; + + cmsUInt32Number + flags, + source_type, + target_type; + + ExceptionInfo + *exception; + + int + intent; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + size_t + source_channels, + target_channels; + + ssize_t + y; + + unsigned short + **magick_restrict source_pixels, + **magick_restrict target_pixels; + + exception=(&image->exception); + target_profile=(cmsHPROFILE) NULL; + if (icc_profile != (StringInfo *) NULL) + { + target_profile=source_profile; + source_profile=cmsOpenProfileFromMemTHR((cmsContext) image, + GetStringInfoDatum(icc_profile),(cmsUInt32Number) + GetStringInfoLength(icc_profile)); + if (source_profile == (cmsHPROFILE) NULL) + ThrowProfileException(ResourceLimitError, + ""ColorspaceColorProfileMismatch"",name); + } + switch (cmsGetColorSpace(source_profile)) + { + case cmsSigCmykData: + { + source_colorspace=CMYKColorspace; + source_type=(cmsUInt32Number) TYPE_CMYK_16; + source_channels=4; + break; + } + case cmsSigGrayData: + { + source_colorspace=GRAYColorspace; + source_type=(cmsUInt32Number) TYPE_GRAY_16; + source_channels=1; + break; + } + case cmsSigLabData: + { + source_colorspace=LabColorspace; + source_type=(cmsUInt32Number) TYPE_Lab_16; + source_channels=3; + break; + } + case cmsSigLuvData: + { + source_colorspace=YUVColorspace; + source_type=(cmsUInt32Number) TYPE_YUV_16; + source_channels=3; + break; + } + case cmsSigRgbData: + { + source_colorspace=sRGBColorspace; + source_type=(cmsUInt32Number) TYPE_RGB_16; + source_channels=3; + break; + } + case cmsSigXYZData: + { + source_colorspace=XYZColorspace; + source_type=(cmsUInt32Number) TYPE_XYZ_16; + source_channels=3; + break; + } + case cmsSigYCbCrData: + { + source_colorspace=YCbCrColorspace; + source_type=(cmsUInt32Number) TYPE_YCbCr_16; + source_channels=3; + break; + } + default: + { + source_colorspace=UndefinedColorspace; + source_type=(cmsUInt32Number) TYPE_RGB_16; + source_channels=3; + break; + } + } + signature=cmsGetPCS(source_profile); + if (target_profile != (cmsHPROFILE) NULL) + signature=cmsGetColorSpace(target_profile); + switch (signature) + { + case cmsSigCmykData: + { + target_colorspace=CMYKColorspace; + target_type=(cmsUInt32Number) TYPE_CMYK_16; + target_channels=4; + break; + } + case cmsSigLabData: + { + target_colorspace=LabColorspace; + target_type=(cmsUInt32Number) TYPE_Lab_16; + target_channels=3; + break; + } + case cmsSigGrayData: + { + target_colorspace=GRAYColorspace; + target_type=(cmsUInt32Number) TYPE_GRAY_16; + target_channels=1; + break; + } + case cmsSigLuvData: + { + target_colorspace=YUVColorspace; + target_type=(cmsUInt32Number) TYPE_YUV_16; + target_channels=3; + break; + } + case cmsSigRgbData: + { + target_colorspace=sRGBColorspace; + target_type=(cmsUInt32Number) TYPE_RGB_16; + target_channels=3; + break; + } + case cmsSigXYZData: + { + target_colorspace=XYZColorspace; + target_type=(cmsUInt32Number) TYPE_XYZ_16; + target_channels=3; + break; + } + case cmsSigYCbCrData: + { + target_colorspace=YCbCrColorspace; + target_type=(cmsUInt32Number) TYPE_YCbCr_16; + target_channels=3; + break; + } + default: + { + target_colorspace=UndefinedColorspace; + target_type=(cmsUInt32Number) TYPE_RGB_16; + target_channels=3; + break; + } + } + if ((source_colorspace == UndefinedColorspace) || + (target_colorspace == UndefinedColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == GRAYColorspace) && + (SetImageGray(image,exception) == MagickFalse)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == CMYKColorspace) && + (image->colorspace != CMYKColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == XYZColorspace) && + (image->colorspace != XYZColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace == YCbCrColorspace) && + (image->colorspace != YCbCrColorspace)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + if ((source_colorspace != CMYKColorspace) && + (source_colorspace != GRAYColorspace) && + (source_colorspace != LabColorspace) && + (source_colorspace != XYZColorspace) && + (source_colorspace != YCbCrColorspace) && + (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)) + ThrowProfileException(ImageError,""ColorspaceColorProfileMismatch"", + name); + switch (image->rendering_intent) + { + case AbsoluteIntent: intent=INTENT_ABSOLUTE_COLORIMETRIC; break; + case PerceptualIntent: intent=INTENT_PERCEPTUAL; break; + case RelativeIntent: intent=INTENT_RELATIVE_COLORIMETRIC; break; + case SaturationIntent: intent=INTENT_SATURATION; break; + default: intent=INTENT_PERCEPTUAL; break; + } + flags=cmsFLAGS_HIGHRESPRECALC; +#if defined(cmsFLAGS_BLACKPOINTCOMPENSATION) + if (image->black_point_compensation != MagickFalse) + flags|=cmsFLAGS_BLACKPOINTCOMPENSATION; +#endif + transform=AcquireTransformThreadSet(image,source_profile, + source_type,target_profile,target_type,intent,flags); + if (transform == (cmsHTRANSFORM *) NULL) + ThrowProfileException(ImageError,""UnableToCreateColorTransform"", + name); + /* + Transform image as dictated by the source & target image profiles. + */ + source_pixels=AcquirePixelThreadSet(image->columns,source_channels); + target_pixels=AcquirePixelThreadSet(image->columns,target_channels); + if ((source_pixels == (unsigned short **) NULL) || + (target_pixels == (unsigned short **) NULL)) + { + transform=DestroyTransformThreadSet(transform); + ThrowProfileException(ResourceLimitError, + ""MemoryAllocationFailed"",image->filename); + } + if (SetImageStorageClass(image,DirectClass) == MagickFalse) + { + target_pixels=DestroyPixelThreadSet(target_pixels); + source_pixels=DestroyPixelThreadSet(source_pixels); + transform=DestroyTransformThreadSet(transform); + if (source_profile != (cmsHPROFILE) NULL) + (void) cmsCloseProfile(source_profile); + if (target_profile != (cmsHPROFILE) NULL) + (void) cmsCloseProfile(target_profile); + return(MagickFalse); + } + if (target_colorspace == CMYKColorspace) + (void) SetImageColorspace(image,target_colorspace); + status=MagickTrue; + progress=0; + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static,4) shared(status) \ + magick_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + const int + id = GetOpenMPThreadId(); + + MagickBooleanType + sync; + + register IndexPacket + *magick_restrict indexes; + + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + register unsigned short + *p; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (PixelPacket *) NULL) + { + status=MagickFalse; + continue; + } + indexes=GetCacheViewAuthenticIndexQueue(image_view); + p=source_pixels[id]; + for (x=0; x < (ssize_t) image->columns; x++) + { + *p++=ScaleQuantumToShort(GetPixelRed(q)); + if (source_channels > 1) + { + *p++=ScaleQuantumToShort(GetPixelGreen(q)); + *p++=ScaleQuantumToShort(GetPixelBlue(q)); + } + if (source_channels > 3) + *p++=ScaleQuantumToShort(GetPixelIndex(indexes+x)); + q++; + } + cmsDoTransform(transform[id],source_pixels[id],target_pixels[id], + (unsigned int) image->columns); + p=target_pixels[id]; + q-=image->columns; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(q,ScaleShortToQuantum(*p)); + SetPixelGreen(q,GetPixelRed(q)); + SetPixelBlue(q,GetPixelRed(q)); + p++; + if (target_channels > 1) + { + SetPixelGreen(q,ScaleShortToQuantum(*p)); + p++; + SetPixelBlue(q,ScaleShortToQuantum(*p)); + p++; + } + if (target_channels > 3) + { + SetPixelIndex(indexes+x,ScaleShortToQuantum(*p)); + p++; + } + q++; + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + status=MagickFalse; + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp critical (MagickCore_ProfileImage) +#endif + proceed=SetImageProgress(image,ProfileImageTag,progress++, + image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + (void) SetImageColorspace(image,target_colorspace); + switch (signature) + { + case cmsSigRgbData: + { + image->type=image->matte == MagickFalse ? TrueColorType : + TrueColorMatteType; + break; + } + case cmsSigCmykData: + { + image->type=image->matte == MagickFalse ? ColorSeparationType : + ColorSeparationMatteType; + break; + } + case cmsSigGrayData: + { + image->type=image->matte == MagickFalse ? GrayscaleType : + GrayscaleMatteType; + break; + } + default: + break; + } + target_pixels=DestroyPixelThreadSet(target_pixels); + source_pixels=DestroyPixelThreadSet(source_pixels); + transform=DestroyTransformThreadSet(transform); + if (cmsGetDeviceClass(source_profile) != cmsSigLinkClass) + status=SetImageProfile(image,name,profile); + if (target_profile != (cmsHPROFILE) NULL) + (void) cmsCloseProfile(target_profile); + } + (void) cmsCloseProfile(source_profile); + } +#endif + } + profile=DestroyStringInfo(profile); + return(status); +} +","@@ -1444,7 +1444,8 @@ static void WriteTo8BimProfile(Image *image,const char *name, + count=(ssize_t) value; + if ((count & 0x01) != 0) + count++; +- if ((p > (datum+length-count)) || (count > (ssize_t) length)) ++ if ((count < 0) || (p > (datum+length-count)) || ++ (count > (ssize_t) length)) + break; + if (id != profile_id) + p+=count;",3570,3806,4096 +3205,"static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net, + const struct sadb_msg *hdr, + void * const *ext_hdrs) +{ + struct xfrm_state *x; + const struct sadb_lifetime *lifetime; + const struct sadb_sa *sa; + const struct sadb_key *key; + const struct sadb_x_sec_ctx *sec_ctx; + uint16_t proto; + int err; + + + sa = ext_hdrs[SADB_EXT_SA - 1]; + if (!sa || + !present_and_same_family(ext_hdrs[SADB_EXT_ADDRESS_SRC-1], + ext_hdrs[SADB_EXT_ADDRESS_DST-1])) + return ERR_PTR(-EINVAL); + if (hdr->sadb_msg_satype == SADB_SATYPE_ESP && + !ext_hdrs[SADB_EXT_KEY_ENCRYPT-1]) + return ERR_PTR(-EINVAL); + if (hdr->sadb_msg_satype == SADB_SATYPE_AH && + !ext_hdrs[SADB_EXT_KEY_AUTH-1]) + return ERR_PTR(-EINVAL); + if (!!ext_hdrs[SADB_EXT_LIFETIME_HARD-1] != + !!ext_hdrs[SADB_EXT_LIFETIME_SOFT-1]) + return ERR_PTR(-EINVAL); + + proto = pfkey_satype2proto(hdr->sadb_msg_satype); + if (proto == 0) + return ERR_PTR(-EINVAL); + + /* default error is no buffer space */ + err = -ENOBUFS; + + /* RFC2367: + + Only SADB_SASTATE_MATURE SAs may be submitted in an SADB_ADD message. + SADB_SASTATE_LARVAL SAs are created by SADB_GETSPI and it is not + sensible to add a new SA in the DYING or SADB_SASTATE_DEAD state. + Therefore, the sadb_sa_state field of all submitted SAs MUST be + SADB_SASTATE_MATURE and the kernel MUST return an error if this is + not true. + + However, KAME setkey always uses SADB_SASTATE_LARVAL. + Hence, we have to _ignore_ sadb_sa_state, which is also reasonable. + */ + if (sa->sadb_sa_auth > SADB_AALG_MAX || + (hdr->sadb_msg_satype == SADB_X_SATYPE_IPCOMP && + sa->sadb_sa_encrypt > SADB_X_CALG_MAX) || + sa->sadb_sa_encrypt > SADB_EALG_MAX) + return ERR_PTR(-EINVAL); + key = ext_hdrs[SADB_EXT_KEY_AUTH - 1]; + if (key != NULL && + sa->sadb_sa_auth != SADB_X_AALG_NULL && + ((key->sadb_key_bits+7) / 8 == 0 || + (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t))) + return ERR_PTR(-EINVAL); + key = ext_hdrs[SADB_EXT_KEY_ENCRYPT-1]; + if (key != NULL && + sa->sadb_sa_encrypt != SADB_EALG_NULL && + ((key->sadb_key_bits+7) / 8 == 0 || + (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t))) + return ERR_PTR(-EINVAL); + + x = xfrm_state_alloc(net); + if (x == NULL) + return ERR_PTR(-ENOBUFS); + + x->id.proto = proto; + x->id.spi = sa->sadb_sa_spi; + x->props.replay_window = sa->sadb_sa_replay; + if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN) + x->props.flags |= XFRM_STATE_NOECN; + if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP) + x->props.flags |= XFRM_STATE_DECAP_DSCP; + if (sa->sadb_sa_flags & SADB_SAFLAGS_NOPMTUDISC) + x->props.flags |= XFRM_STATE_NOPMTUDISC; + + lifetime = ext_hdrs[SADB_EXT_LIFETIME_HARD - 1]; + if (lifetime != NULL) { + x->lft.hard_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); + x->lft.hard_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); + x->lft.hard_add_expires_seconds = lifetime->sadb_lifetime_addtime; + x->lft.hard_use_expires_seconds = lifetime->sadb_lifetime_usetime; + } + lifetime = ext_hdrs[SADB_EXT_LIFETIME_SOFT - 1]; + if (lifetime != NULL) { + x->lft.soft_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); + x->lft.soft_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); + x->lft.soft_add_expires_seconds = lifetime->sadb_lifetime_addtime; + x->lft.soft_use_expires_seconds = lifetime->sadb_lifetime_usetime; + } + + sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1]; + if (sec_ctx != NULL) { + struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); + + if (!uctx) + goto out; + + err = security_xfrm_state_alloc(x, uctx); + kfree(uctx); + + if (err) + goto out; + } + + key = ext_hdrs[SADB_EXT_KEY_AUTH - 1]; + if (sa->sadb_sa_auth) { + int keysize = 0; + struct xfrm_algo_desc *a = xfrm_aalg_get_byid(sa->sadb_sa_auth); + if (!a || !a->pfkey_supported) { + err = -ENOSYS; + goto out; + } + if (key) + keysize = (key->sadb_key_bits + 7) / 8; + x->aalg = kmalloc(sizeof(*x->aalg) + keysize, GFP_KERNEL); + if (!x->aalg) + goto out; + strcpy(x->aalg->alg_name, a->name); + x->aalg->alg_key_len = 0; + if (key) { + x->aalg->alg_key_len = key->sadb_key_bits; + memcpy(x->aalg->alg_key, key+1, keysize); + } + x->aalg->alg_trunc_len = a->uinfo.auth.icv_truncbits; + x->props.aalgo = sa->sadb_sa_auth; + /* x->algo.flags = sa->sadb_sa_flags; */ + } + if (sa->sadb_sa_encrypt) { + if (hdr->sadb_msg_satype == SADB_X_SATYPE_IPCOMP) { + struct xfrm_algo_desc *a = xfrm_calg_get_byid(sa->sadb_sa_encrypt); + if (!a || !a->pfkey_supported) { + err = -ENOSYS; + goto out; + } + x->calg = kmalloc(sizeof(*x->calg), GFP_KERNEL); + if (!x->calg) + goto out; + strcpy(x->calg->alg_name, a->name); + x->props.calgo = sa->sadb_sa_encrypt; + } else { + int keysize = 0; + struct xfrm_algo_desc *a = xfrm_ealg_get_byid(sa->sadb_sa_encrypt); + if (!a || !a->pfkey_supported) { + err = -ENOSYS; + goto out; + } + key = (struct sadb_key*) ext_hdrs[SADB_EXT_KEY_ENCRYPT-1]; + if (key) + keysize = (key->sadb_key_bits + 7) / 8; + x->ealg = kmalloc(sizeof(*x->ealg) + keysize, GFP_KERNEL); + if (!x->ealg) + goto out; + strcpy(x->ealg->alg_name, a->name); + x->ealg->alg_key_len = 0; + if (key) { + x->ealg->alg_key_len = key->sadb_key_bits; + memcpy(x->ealg->alg_key, key+1, keysize); + } + x->props.ealgo = sa->sadb_sa_encrypt; + } + } + /* x->algo.flags = sa->sadb_sa_flags; */ + + x->props.family = pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_SRC-1], + &x->props.saddr); + if (!x->props.family) { + err = -EAFNOSUPPORT; + goto out; + } + pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_DST-1], + &x->id.daddr); + + if (ext_hdrs[SADB_X_EXT_SA2-1]) { + const struct sadb_x_sa2 *sa2 = ext_hdrs[SADB_X_EXT_SA2-1]; + int mode = pfkey_mode_to_xfrm(sa2->sadb_x_sa2_mode); + if (mode < 0) { + err = -EINVAL; + goto out; + } + x->props.mode = mode; + x->props.reqid = sa2->sadb_x_sa2_reqid; + } + + if (ext_hdrs[SADB_EXT_ADDRESS_PROXY-1]) { + const struct sadb_address *addr = ext_hdrs[SADB_EXT_ADDRESS_PROXY-1]; + + /* Nobody uses this, but we try. */ + x->sel.family = pfkey_sadb_addr2xfrm_addr(addr, &x->sel.saddr); + x->sel.prefixlen_s = addr->sadb_address_prefixlen; + } + + if (!x->sel.family) + x->sel.family = x->props.family; + + if (ext_hdrs[SADB_X_EXT_NAT_T_TYPE-1]) { + const struct sadb_x_nat_t_type* n_type; + struct xfrm_encap_tmpl *natt; + + x->encap = kmalloc(sizeof(*x->encap), GFP_KERNEL); + if (!x->encap) + goto out; + + natt = x->encap; + n_type = ext_hdrs[SADB_X_EXT_NAT_T_TYPE-1]; + natt->encap_type = n_type->sadb_x_nat_t_type_type; + + if (ext_hdrs[SADB_X_EXT_NAT_T_SPORT-1]) { + const struct sadb_x_nat_t_port *n_port = + ext_hdrs[SADB_X_EXT_NAT_T_SPORT-1]; + natt->encap_sport = n_port->sadb_x_nat_t_port_port; + } + if (ext_hdrs[SADB_X_EXT_NAT_T_DPORT-1]) { + const struct sadb_x_nat_t_port *n_port = + ext_hdrs[SADB_X_EXT_NAT_T_DPORT-1]; + natt->encap_dport = n_port->sadb_x_nat_t_port_port; + } + memset(&natt->encap_oa, 0, sizeof(natt->encap_oa)); + } + + err = xfrm_init_state(x); + if (err) + goto out; + + x->km.seq = hdr->sadb_msg_seq; + return x; + +out: + x->km.state = XFRM_STATE_DEAD; + xfrm_state_put(x); + return ERR_PTR(err); +} +",0,"static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net, + const struct sadb_msg *hdr, + void * const *ext_hdrs) +{ + struct xfrm_state *x; + const struct sadb_lifetime *lifetime; + const struct sadb_sa *sa; + const struct sadb_key *key; + const struct sadb_x_sec_ctx *sec_ctx; + uint16_t proto; + int err; + + + sa = ext_hdrs[SADB_EXT_SA - 1]; + if (!sa || + !present_and_same_family(ext_hdrs[SADB_EXT_ADDRESS_SRC-1], + ext_hdrs[SADB_EXT_ADDRESS_DST-1])) + return ERR_PTR(-EINVAL); + if (hdr->sadb_msg_satype == SADB_SATYPE_ESP && + !ext_hdrs[SADB_EXT_KEY_ENCRYPT-1]) + return ERR_PTR(-EINVAL); + if (hdr->sadb_msg_satype == SADB_SATYPE_AH && + !ext_hdrs[SADB_EXT_KEY_AUTH-1]) + return ERR_PTR(-EINVAL); + if (!!ext_hdrs[SADB_EXT_LIFETIME_HARD-1] != + !!ext_hdrs[SADB_EXT_LIFETIME_SOFT-1]) + return ERR_PTR(-EINVAL); + + proto = pfkey_satype2proto(hdr->sadb_msg_satype); + if (proto == 0) + return ERR_PTR(-EINVAL); + + /* default error is no buffer space */ + err = -ENOBUFS; + + /* RFC2367: + + Only SADB_SASTATE_MATURE SAs may be submitted in an SADB_ADD message. + SADB_SASTATE_LARVAL SAs are created by SADB_GETSPI and it is not + sensible to add a new SA in the DYING or SADB_SASTATE_DEAD state. + Therefore, the sadb_sa_state field of all submitted SAs MUST be + SADB_SASTATE_MATURE and the kernel MUST return an error if this is + not true. + + However, KAME setkey always uses SADB_SASTATE_LARVAL. + Hence, we have to _ignore_ sadb_sa_state, which is also reasonable. + */ + if (sa->sadb_sa_auth > SADB_AALG_MAX || + (hdr->sadb_msg_satype == SADB_X_SATYPE_IPCOMP && + sa->sadb_sa_encrypt > SADB_X_CALG_MAX) || + sa->sadb_sa_encrypt > SADB_EALG_MAX) + return ERR_PTR(-EINVAL); + key = ext_hdrs[SADB_EXT_KEY_AUTH - 1]; + if (key != NULL && + sa->sadb_sa_auth != SADB_X_AALG_NULL && + ((key->sadb_key_bits+7) / 8 == 0 || + (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t))) + return ERR_PTR(-EINVAL); + key = ext_hdrs[SADB_EXT_KEY_ENCRYPT-1]; + if (key != NULL && + sa->sadb_sa_encrypt != SADB_EALG_NULL && + ((key->sadb_key_bits+7) / 8 == 0 || + (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t))) + return ERR_PTR(-EINVAL); + + x = xfrm_state_alloc(net); + if (x == NULL) + return ERR_PTR(-ENOBUFS); + + x->id.proto = proto; + x->id.spi = sa->sadb_sa_spi; + x->props.replay_window = sa->sadb_sa_replay; + if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN) + x->props.flags |= XFRM_STATE_NOECN; + if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP) + x->props.flags |= XFRM_STATE_DECAP_DSCP; + if (sa->sadb_sa_flags & SADB_SAFLAGS_NOPMTUDISC) + x->props.flags |= XFRM_STATE_NOPMTUDISC; + + lifetime = ext_hdrs[SADB_EXT_LIFETIME_HARD - 1]; + if (lifetime != NULL) { + x->lft.hard_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); + x->lft.hard_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); + x->lft.hard_add_expires_seconds = lifetime->sadb_lifetime_addtime; + x->lft.hard_use_expires_seconds = lifetime->sadb_lifetime_usetime; + } + lifetime = ext_hdrs[SADB_EXT_LIFETIME_SOFT - 1]; + if (lifetime != NULL) { + x->lft.soft_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); + x->lft.soft_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); + x->lft.soft_add_expires_seconds = lifetime->sadb_lifetime_addtime; + x->lft.soft_use_expires_seconds = lifetime->sadb_lifetime_usetime; + } + + sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1]; + if (sec_ctx != NULL) { + struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); + + if (!uctx) + goto out; + + err = security_xfrm_state_alloc(x, uctx); + kfree(uctx); + + if (err) + goto out; + } + + key = ext_hdrs[SADB_EXT_KEY_AUTH - 1]; + if (sa->sadb_sa_auth) { + int keysize = 0; + struct xfrm_algo_desc *a = xfrm_aalg_get_byid(sa->sadb_sa_auth); + if (!a || !a->pfkey_supported) { + err = -ENOSYS; + goto out; + } + if (key) + keysize = (key->sadb_key_bits + 7) / 8; + x->aalg = kmalloc(sizeof(*x->aalg) + keysize, GFP_KERNEL); + if (!x->aalg) + goto out; + strcpy(x->aalg->alg_name, a->name); + x->aalg->alg_key_len = 0; + if (key) { + x->aalg->alg_key_len = key->sadb_key_bits; + memcpy(x->aalg->alg_key, key+1, keysize); + } + x->aalg->alg_trunc_len = a->uinfo.auth.icv_truncbits; + x->props.aalgo = sa->sadb_sa_auth; + /* x->algo.flags = sa->sadb_sa_flags; */ + } + if (sa->sadb_sa_encrypt) { + if (hdr->sadb_msg_satype == SADB_X_SATYPE_IPCOMP) { + struct xfrm_algo_desc *a = xfrm_calg_get_byid(sa->sadb_sa_encrypt); + if (!a || !a->pfkey_supported) { + err = -ENOSYS; + goto out; + } + x->calg = kmalloc(sizeof(*x->calg), GFP_KERNEL); + if (!x->calg) + goto out; + strcpy(x->calg->alg_name, a->name); + x->props.calgo = sa->sadb_sa_encrypt; + } else { + int keysize = 0; + struct xfrm_algo_desc *a = xfrm_ealg_get_byid(sa->sadb_sa_encrypt); + if (!a || !a->pfkey_supported) { + err = -ENOSYS; + goto out; + } + key = (struct sadb_key*) ext_hdrs[SADB_EXT_KEY_ENCRYPT-1]; + if (key) + keysize = (key->sadb_key_bits + 7) / 8; + x->ealg = kmalloc(sizeof(*x->ealg) + keysize, GFP_KERNEL); + if (!x->ealg) + goto out; + strcpy(x->ealg->alg_name, a->name); + x->ealg->alg_key_len = 0; + if (key) { + x->ealg->alg_key_len = key->sadb_key_bits; + memcpy(x->ealg->alg_key, key+1, keysize); + } + x->props.ealgo = sa->sadb_sa_encrypt; + } + } + /* x->algo.flags = sa->sadb_sa_flags; */ + + x->props.family = pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_SRC-1], + &x->props.saddr); + if (!x->props.family) { + err = -EAFNOSUPPORT; + goto out; + } + pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_DST-1], + &x->id.daddr); + + if (ext_hdrs[SADB_X_EXT_SA2-1]) { + const struct sadb_x_sa2 *sa2 = ext_hdrs[SADB_X_EXT_SA2-1]; + int mode = pfkey_mode_to_xfrm(sa2->sadb_x_sa2_mode); + if (mode < 0) { + err = -EINVAL; + goto out; + } + x->props.mode = mode; + x->props.reqid = sa2->sadb_x_sa2_reqid; + } + + if (ext_hdrs[SADB_EXT_ADDRESS_PROXY-1]) { + const struct sadb_address *addr = ext_hdrs[SADB_EXT_ADDRESS_PROXY-1]; + + /* Nobody uses this, but we try. */ + x->sel.family = pfkey_sadb_addr2xfrm_addr(addr, &x->sel.saddr); + x->sel.prefixlen_s = addr->sadb_address_prefixlen; + } + + if (!x->sel.family) + x->sel.family = x->props.family; + + if (ext_hdrs[SADB_X_EXT_NAT_T_TYPE-1]) { + const struct sadb_x_nat_t_type* n_type; + struct xfrm_encap_tmpl *natt; + + x->encap = kmalloc(sizeof(*x->encap), GFP_KERNEL); + if (!x->encap) + goto out; + + natt = x->encap; + n_type = ext_hdrs[SADB_X_EXT_NAT_T_TYPE-1]; + natt->encap_type = n_type->sadb_x_nat_t_type_type; + + if (ext_hdrs[SADB_X_EXT_NAT_T_SPORT-1]) { + const struct sadb_x_nat_t_port *n_port = + ext_hdrs[SADB_X_EXT_NAT_T_SPORT-1]; + natt->encap_sport = n_port->sadb_x_nat_t_port_port; + } + if (ext_hdrs[SADB_X_EXT_NAT_T_DPORT-1]) { + const struct sadb_x_nat_t_port *n_port = + ext_hdrs[SADB_X_EXT_NAT_T_DPORT-1]; + natt->encap_dport = n_port->sadb_x_nat_t_port_port; + } + memset(&natt->encap_oa, 0, sizeof(natt->encap_oa)); + } + + err = xfrm_init_state(x); + if (err) + goto out; + + x->km.seq = hdr->sadb_msg_seq; + return x; + +out: + x->km.state = XFRM_STATE_DEAD; + xfrm_state_put(x); + return ERR_PTR(err); +} +","@@ -2694,6 +2694,7 @@ static int key_notify_policy_flush(const struct km_event *c) + hdr->sadb_msg_pid = c->portid; + hdr->sadb_msg_version = PF_KEY_V2; + hdr->sadb_msg_errno = (uint8_t) 0; ++ hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC; + hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); + pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net); + return 0;",2468,2704,4096 +18092,"static int mboxlist_do_find(struct find_rock *rock, const strarray_t *patterns) +{ + const char *userid = rock->userid; + int isadmin = rock->isadmin; + + int crossdomains = config_getswitch(IMAPOPT_CROSSDOMAINS); + char inbox[MAX_MAILBOX_BUFFER]; + size_t inboxlen = 0; + size_t prefixlen, len; + size_t domainlen = 0; + size_t userlen = userid ? strlen(userid) : 0; + char domainpat[MAX_MAILBOX_BUFFER]; /* do intra-domain fetches only */ + char commonpat[MAX_MAILBOX_BUFFER]; + int r = 0; + int i; + const char *p; + + if (patterns->count < 1) return 0; /* nothing to do */ + + for (i = 0; i < patterns->count; i++) { + glob *g = glob_init(strarray_nth(patterns, i), rock->namespace->hier_sep); + ptrarray_append(&rock->globs, g); + } + + if (config_virtdomains && userid && (p = strchr(userid, '@'))) { + userlen = p - userid; + domainlen = strlen(p); /* includes separator */ + snprintf(domainpat, sizeof(domainpat), ""%s!"", p+1); + } + else + domainpat[0] = '\0'; + + /* calculate the inbox (with trailing .INBOX. for later use) */ + if (userid && (!(p = strchr(userid, rock->namespace->hier_sep)) || + ((p - userid) > (int)userlen)) && + strlen(userid)+7 < MAX_MAILBOX_BUFFER) { + char *t, *tmpuser = NULL; + const char *inboxuser; + + if (domainlen) + snprintf(inbox, sizeof(inbox), ""%s!"", userid+userlen+1); + if (rock->namespace->hier_sep == '/' && (p = strchr(userid, '.'))) { + tmpuser = xmalloc(userlen); + memcpy(tmpuser, userid, userlen); + t = tmpuser + (p - userid); + while(t < (tmpuser + userlen)) { + if (*t == '.') + *t = '^'; + t++; + } + inboxuser = tmpuser; + } else + inboxuser = userid; + snprintf(inbox+domainlen, sizeof(inbox)-domainlen, + ""user.%.*s.INBOX."", (int)userlen, inboxuser); + free(tmpuser); + inboxlen = strlen(inbox) - 7; + } + else { + userid = 0; + } + + /* Find the common search prefix of all patterns */ + const char *firstpat = strarray_nth(patterns, 0); + for (prefixlen = 0; firstpat[prefixlen]; prefixlen++) { + if (prefixlen >= MAX_MAILBOX_NAME) { + r = IMAP_MAILBOX_BADNAME; + goto done; + } + char c = firstpat[prefixlen]; + for (i = 1; i < patterns->count; i++) { + const char *pat = strarray_nth(patterns, i); + if (pat[prefixlen] != c) break; + } + if (i < patterns->count) break; + if (c == '*' || c == '%' || c == '?') break; + commonpat[prefixlen] = c; + } + commonpat[prefixlen] = '\0'; + + if (patterns->count == 1) { + /* Skip pattern which matches shared namespace prefix */ + if (!strcmp(firstpat+prefixlen, ""%"")) + rock->singlepercent = 2; + /* output prefix regardless */ + if (!strcmp(firstpat+prefixlen, ""*%"")) + rock->singlepercent = 1; + } + + /* + * Personal (INBOX) namespace (only if not admin) + */ + if (userid && !isadmin) { + /* first the INBOX */ + rock->mb_category = MBNAME_INBOX; + r = cyrusdb_forone(rock->db, inbox, inboxlen, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + + if (rock->namespace->isalt) { + /* do exact INBOX subs before resetting the namebuffer */ + rock->mb_category = MBNAME_INBOXSUB; + r = cyrusdb_foreach(rock->db, inbox, inboxlen+7, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + } + + /* iterate through all the mailboxes under the user's inbox */ + rock->mb_category = MBNAME_OWNER; + r = cyrusdb_foreach(rock->db, inbox, inboxlen+1, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + + /* ""Alt Prefix"" folders */ + if (rock->namespace->isalt) { + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + + rock->mb_category = MBNAME_ALTINBOX; + + /* special case user.foo.INBOX. If we're singlepercent == 2, this could + return DONE, in which case we don't need to foreach the rest of the + altprefix space */ + r = cyrusdb_forone(rock->db, inbox, inboxlen+6, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) goto skipalt; + if (r) goto done; + + /* special case any other altprefix stuff */ + rock->mb_category = MBNAME_ALTPREFIX; + r = cyrusdb_foreach(rock->db, inbox, inboxlen+1, &find_p, &find_cb, rock, NULL); + skipalt: /* we got a done, so skip out of the foreach early */ + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + } + } + + /* + * Other Users namespace + * + * If ""Other Users*"" can match pattern, search for those mailboxes next + */ + if (isadmin || rock->namespace->accessible[NAMESPACE_USER]) { + len = strlen(rock->namespace->prefix[NAMESPACE_USER]); + if (len) len--; // trailing separator + + if (!strncmp(rock->namespace->prefix[NAMESPACE_USER], commonpat, MIN(len, prefixlen))) { + if (prefixlen < len) { + /* we match all users */ + strlcpy(domainpat+domainlen, ""user."", sizeof(domainpat)-domainlen); + } + else { + /* just those in this prefix */ + strlcpy(domainpat+domainlen, ""user."", sizeof(domainpat)-domainlen); + strlcpy(domainpat+domainlen+5, commonpat+len+1, sizeof(domainpat)-domainlen-5); + } + + rock->mb_category = MBNAME_OTHERUSER; + + /* because of how domains work, with crossdomains or admin you can't prefix at all :( */ + size_t thislen = (isadmin || crossdomains) ? 0 : strlen(domainpat); + + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + + r = mboxlist_find_category(rock, domainpat, thislen); + if (r) goto done; + } + } + + /* + * Shared namespace + * + * search for all remaining mailboxes. + * just bother looking at the ones that have the same pattern prefix. + */ + if (isadmin || rock->namespace->accessible[NAMESPACE_SHARED]) { + len = strlen(rock->namespace->prefix[NAMESPACE_SHARED]); + if (len) len--; // trailing separator + + if (!strncmp(rock->namespace->prefix[NAMESPACE_SHARED], commonpat, MIN(len, prefixlen))) { + rock->mb_category = MBNAME_SHARED; + + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + + /* iterate through all the non-user folders on the server */ + r = mboxlist_find_category(rock, domainpat, domainlen); + if (r) goto done; + } + } + + /* finish with a reset call always */ + r = (*rock->proc)(NULL, rock->procrock); + + done: + for (i = 0; i < rock->globs.count; i++) { + glob *g = ptrarray_nth(&rock->globs, i); + glob_free(&g); + } + ptrarray_fini(&rock->globs); + + return r; +} +",1,"static int mboxlist_do_find(struct find_rock *rock, const strarray_t *patterns) +{ + const char *userid = rock->userid; + int isadmin = rock->isadmin; + + int crossdomains = config_getswitch(IMAPOPT_CROSSDOMAINS); + char inbox[MAX_MAILBOX_BUFFER]; + size_t inboxlen = 0; + size_t prefixlen, len; + size_t domainlen = 0; + size_t userlen = userid ? strlen(userid) : 0; + char domainpat[MAX_MAILBOX_BUFFER]; /* do intra-domain fetches only */ + char commonpat[MAX_MAILBOX_BUFFER]; + int r = 0; + int i; + const char *p; + + if (patterns->count < 1) return 0; /* nothing to do */ + + for (i = 0; i < patterns->count; i++) { + glob *g = glob_init(strarray_nth(patterns, i), rock->namespace->hier_sep); + ptrarray_append(&rock->globs, g); + } + + if (config_virtdomains && userid && (p = strchr(userid, '@'))) { + userlen = p - userid; + domainlen = strlen(p); /* includes separator */ + snprintf(domainpat, sizeof(domainpat), ""%s!"", p+1); + } + else + domainpat[0] = '\0'; + + /* calculate the inbox (with trailing .INBOX. for later use) */ + if (userid && (!(p = strchr(userid, rock->namespace->hier_sep)) || + ((p - userid) > (int)userlen)) && + strlen(userid)+7 < MAX_MAILBOX_BUFFER) { + char *t, *tmpuser = NULL; + const char *inboxuser; + + if (domainlen) + snprintf(inbox, sizeof(inbox), ""%s!"", userid+userlen+1); + if (rock->namespace->hier_sep == '/' && (p = strchr(userid, '.'))) { + tmpuser = xmalloc(userlen); + memcpy(tmpuser, userid, userlen); + t = tmpuser + (p - userid); + while(t < (tmpuser + userlen)) { + if (*t == '.') + *t = '^'; + t++; + } + inboxuser = tmpuser; + } else + inboxuser = userid; + snprintf(inbox+domainlen, sizeof(inbox)-domainlen, + ""user.%.*s.INBOX."", (int)userlen, inboxuser); + free(tmpuser); + inboxlen = strlen(inbox) - 7; + } + else { + userid = 0; + } + + /* Find the common search prefix of all patterns */ + const char *firstpat = strarray_nth(patterns, 0); + for (prefixlen = 0; firstpat[prefixlen]; prefixlen++) { + if (prefixlen >= MAX_MAILBOX_NAME) { + r = IMAP_MAILBOX_BADNAME; + goto done; + } + char c = firstpat[prefixlen]; + for (i = 1; i < patterns->count; i++) { + const char *pat = strarray_nth(patterns, i); + if (pat[prefixlen] != c) break; + } + if (i < patterns->count) break; + if (c == '*' || c == '%' || c == '?') break; + commonpat[prefixlen] = c; + } + commonpat[prefixlen] = '\0'; + + if (patterns->count == 1) { + /* Skip pattern which matches shared namespace prefix */ + if (!strcmp(firstpat+prefixlen, ""%"")) + rock->singlepercent = 2; + /* output prefix regardless */ + if (!strcmp(firstpat+prefixlen, ""*%"")) + rock->singlepercent = 1; + } + + /* + * Personal (INBOX) namespace (only if not admin) + */ + if (userid && !isadmin) { + /* first the INBOX */ + rock->mb_category = MBNAME_INBOX; + r = cyrusdb_forone(rock->db, inbox, inboxlen, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + + if (rock->namespace->isalt) { + /* do exact INBOX subs before resetting the namebuffer */ + rock->mb_category = MBNAME_INBOXSUB; + r = cyrusdb_foreach(rock->db, inbox, inboxlen+7, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + } + + /* iterate through all the mailboxes under the user's inbox */ + rock->mb_category = MBNAME_OWNER; + r = cyrusdb_foreach(rock->db, inbox, inboxlen+1, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + + /* ""Alt Prefix"" folders */ + if (rock->namespace->isalt) { + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + + rock->mb_category = MBNAME_ALTINBOX; + + /* special case user.foo.INBOX. If we're singlepercent == 2, this could + return DONE, in which case we don't need to foreach the rest of the + altprefix space */ + r = cyrusdb_forone(rock->db, inbox, inboxlen+6, &find_p, &find_cb, rock, NULL); + if (r == CYRUSDB_DONE) goto skipalt; + if (r) goto done; + + /* special case any other altprefix stuff */ + rock->mb_category = MBNAME_ALTPREFIX; + r = cyrusdb_foreach(rock->db, inbox, inboxlen+1, &find_p, &find_cb, rock, NULL); + skipalt: /* we got a done, so skip out of the foreach early */ + if (r == CYRUSDB_DONE) r = 0; + if (r) goto done; + } + } + + /* + * Other Users namespace + * + * If ""Other Users*"" can match pattern, search for those mailboxes next + */ + if (isadmin || rock->namespace->accessible[NAMESPACE_USER]) { + len = strlen(rock->namespace->prefix[NAMESPACE_USER]); + if (len) len--; // trailing separator + + if (!strncmp(rock->namespace->prefix[NAMESPACE_USER], commonpat, MIN(len, prefixlen))) { + if (prefixlen <= len) { + /* we match all users */ + strlcpy(domainpat+domainlen, ""user."", sizeof(domainpat)-domainlen); + } + else { + /* just those in this prefix */ + strlcpy(domainpat+domainlen, ""user."", sizeof(domainpat)-domainlen); + strlcpy(domainpat+domainlen+5, commonpat+len+1, sizeof(domainpat)-domainlen-5); + } + + rock->mb_category = MBNAME_OTHERUSER; + + /* because of how domains work, with crossdomains or admin you can't prefix at all :( */ + size_t thislen = (isadmin || crossdomains) ? 0 : strlen(domainpat); + + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + + r = mboxlist_find_category(rock, domainpat, thislen); + if (r) goto done; + } + } + + /* + * Shared namespace + * + * search for all remaining mailboxes. + * just bother looking at the ones that have the same pattern prefix. + */ + if (isadmin || rock->namespace->accessible[NAMESPACE_SHARED]) { + len = strlen(rock->namespace->prefix[NAMESPACE_SHARED]); + if (len) len--; // trailing separator + + if (!strncmp(rock->namespace->prefix[NAMESPACE_SHARED], commonpat, MIN(len, prefixlen))) { + rock->mb_category = MBNAME_SHARED; + + /* reset the the namebuffer */ + r = (*rock->proc)(NULL, rock->procrock); + if (r) goto done; + + /* iterate through all the non-user folders on the server */ + r = mboxlist_find_category(rock, domainpat, domainlen); + if (r) goto done; + } + } + + /* finish with a reset call always */ + r = (*rock->proc)(NULL, rock->procrock); + + done: + for (i = 0; i < rock->globs.count; i++) { + glob *g = ptrarray_nth(&rock->globs, i); + glob_free(&g); + } + ptrarray_fini(&rock->globs); + + return r; +} +","@@ -2851,7 +2851,7 @@ static int mboxlist_do_find(struct find_rock *rock, const strarray_t *patterns) + if (len) len--; // trailing separator + + if (!strncmp(rock->namespace->prefix[NAMESPACE_USER], commonpat, MIN(len, prefixlen))) { +- if (prefixlen < len) { ++ if (prefixlen <= len) { + /* we match all users */ + strlcpy(domainpat+domainlen, ""user."", sizeof(domainpat)-domainlen); + }",1955,2191,4096 +8250,"doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, + size_t size, off_t fsize, int mach, int strtab, int *flags, + uint16_t *notecount) +{ + Elf32_Shdr sh32; + Elf64_Shdr sh64; + int stripped = 1, has_debug_info = 0; + size_t nbadcap = 0; + void *nbuf; + off_t noff, coff, name_off; + uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilities */ + uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilities */ + char name[50]; + ssize_t namesize; + + if (size != xsh_sizeof) { + if (file_printf(ms, "", corrupted section header size"") == -1) + return -1; + return 0; + } + + /* Read offset of name section to be able to read section names later */ + if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab))) + < CAST(ssize_t, xsh_sizeof)) { + if (file_printf(ms, "", missing section headers"") == -1) + return -1; + return 0; + } + name_off = xsh_offset; + + for ( ; num; num--) { + /* Read the name of this section. */ + if ((namesize = pread(fd, name, sizeof(name) - 1, + name_off + xsh_name)) == -1) { + file_badread(ms); + return -1; + } + name[namesize] = '\0'; + if (strcmp(name, "".debug_info"") == 0) { + has_debug_info = 1; + stripped = 0; + } + + if (pread(fd, xsh_addr, xsh_sizeof, off) < + CAST(ssize_t, xsh_sizeof)) { + file_badread(ms); + return -1; + } + off += size; + + /* Things we can determine before we seek */ + switch (xsh_type) { + case SHT_SYMTAB: +#if 0 + case SHT_DYNSYM: +#endif + stripped = 0; + break; + default: + if (fsize != SIZE_UNKNOWN && xsh_offset > fsize) { + /* Perhaps warn here */ + continue; + } + break; + } + + + /* Things we can determine when we seek */ + switch (xsh_type) { + case SHT_NOTE: + if (CAST(uintmax_t, (xsh_size + xsh_offset)) > + CAST(uintmax_t, fsize)) { + if (file_printf(ms, + "", note offset/size %#"" INTMAX_T_FORMAT + ""x+%#"" INTMAX_T_FORMAT ""x exceeds"" + "" file size %#"" INTMAX_T_FORMAT ""x"", + CAST(uintmax_t, xsh_offset), + CAST(uintmax_t, xsh_size), + CAST(uintmax_t, fsize)) == -1) + return -1; + return 0; + } + if ((nbuf = malloc(xsh_size)) == NULL) { + file_error(ms, errno, ""Cannot allocate memory"" + "" for note""); + return -1; + } + if (pread(fd, nbuf, xsh_size, xsh_offset) < + CAST(ssize_t, xsh_size)) { + file_badread(ms); + free(nbuf); + return -1; + } + + noff = 0; + for (;;) { + if (noff >= CAST(off_t, xsh_size)) + break; + noff = donote(ms, nbuf, CAST(size_t, noff), + xsh_size, clazz, swap, 4, flags, notecount, + fd, 0, 0, 0); + if (noff == 0) + break; + } + free(nbuf); + break; + case SHT_SUNW_cap: + switch (mach) { + case EM_SPARC: + case EM_SPARCV9: + case EM_IA_64: + case EM_386: + case EM_AMD64: + break; + default: + goto skip; + } + + if (nbadcap > 5) + break; + if (lseek(fd, xsh_offset, SEEK_SET) + == CAST(off_t, -1)) { + file_badseek(ms); + return -1; + } + coff = 0; + for (;;) { + Elf32_Cap cap32; + Elf64_Cap cap64; + char cbuf[/*CONSTCOND*/ + MAX(sizeof(cap32), sizeof(cap64))]; + if ((coff += xcap_sizeof) > + CAST(off_t, xsh_size)) + break; + if (read(fd, cbuf, CAST(size_t, xcap_sizeof)) != + CAST(ssize_t, xcap_sizeof)) { + file_badread(ms); + return -1; + } + if (cbuf[0] == 'A') { +#ifdef notyet + char *p = cbuf + 1; + uint32_t len, tag; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (memcmp(""gnu"", p, 3) != 0) { + if (file_printf(ms, + "", unknown capability %.3s"", p) + == -1) + return -1; + break; + } + p += strlen(p) + 1; + tag = *p++; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (tag != 1) { + if (file_printf(ms, "", unknown gnu"" + "" capability tag %d"", tag) + == -1) + return -1; + break; + } +#endif + break; + } + memcpy(xcap_addr, cbuf, xcap_sizeof); + switch (xcap_tag) { + case CA_SUNW_NULL: + break; + case CA_SUNW_HW_1: + cap_hw1 |= xcap_val; + break; + case CA_SUNW_SF_1: + cap_sf1 |= xcap_val; + break; + default: + if (file_printf(ms, + "", with unknown capability "" + ""%#"" INT64_T_FORMAT ""x = %#"" + INT64_T_FORMAT ""x"", + CAST(unsigned long long, xcap_tag), + CAST(unsigned long long, xcap_val)) + == -1) + return -1; + if (nbadcap++ > 2) + coff = xsh_size; + break; + } + } + /*FALLTHROUGH*/ + skip: + default: + break; + } + } + + if (has_debug_info) { + if (file_printf(ms, "", with debug_info"") == -1) + return -1; + } + if (file_printf(ms, "", %sstripped"", stripped ? """" : ""not "") == -1) + return -1; + if (cap_hw1) { + const cap_desc_t *cdp; + switch (mach) { + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + cdp = cap_desc_sparc; + break; + case EM_386: + case EM_IA_64: + case EM_AMD64: + cdp = cap_desc_386; + break; + default: + cdp = NULL; + break; + } + if (file_printf(ms, "", uses"") == -1) + return -1; + if (cdp) { + while (cdp->cd_name) { + if (cap_hw1 & cdp->cd_mask) { + if (file_printf(ms, + "" %s"", cdp->cd_name) == -1) + return -1; + cap_hw1 &= ~cdp->cd_mask; + } + ++cdp; + } + if (cap_hw1) + if (file_printf(ms, + "" unknown hardware capability %#"" + INT64_T_FORMAT ""x"", + CAST(unsigned long long, cap_hw1)) == -1) + return -1; + } else { + if (file_printf(ms, + "" hardware capability %#"" INT64_T_FORMAT ""x"", + CAST(unsigned long long, cap_hw1)) == -1) + return -1; + } + } + if (cap_sf1) { + if (cap_sf1 & SF1_SUNW_FPUSED) { + if (file_printf(ms, + (cap_sf1 & SF1_SUNW_FPKNWN) + ? "", uses frame pointer"" + : "", not known to use frame pointer"") == -1) + return -1; + } + cap_sf1 &= ~SF1_SUNW_MASK; + if (cap_sf1) + if (file_printf(ms, + "", with unknown software capability %#"" + INT64_T_FORMAT ""x"", + CAST(unsigned long long, cap_sf1)) == -1) + return -1; + } + return 0; +} +",0,"doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, + size_t size, off_t fsize, int mach, int strtab, int *flags, + uint16_t *notecount) +{ + Elf32_Shdr sh32; + Elf64_Shdr sh64; + int stripped = 1, has_debug_info = 0; + size_t nbadcap = 0; + void *nbuf; + off_t noff, coff, name_off; + uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilities */ + uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilities */ + char name[50]; + ssize_t namesize; + + if (size != xsh_sizeof) { + if (file_printf(ms, "", corrupted section header size"") == -1) + return -1; + return 0; + } + + /* Read offset of name section to be able to read section names later */ + if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab))) + < CAST(ssize_t, xsh_sizeof)) { + if (file_printf(ms, "", missing section headers"") == -1) + return -1; + return 0; + } + name_off = xsh_offset; + + for ( ; num; num--) { + /* Read the name of this section. */ + if ((namesize = pread(fd, name, sizeof(name) - 1, + name_off + xsh_name)) == -1) { + file_badread(ms); + return -1; + } + name[namesize] = '\0'; + if (strcmp(name, "".debug_info"") == 0) { + has_debug_info = 1; + stripped = 0; + } + + if (pread(fd, xsh_addr, xsh_sizeof, off) < + CAST(ssize_t, xsh_sizeof)) { + file_badread(ms); + return -1; + } + off += size; + + /* Things we can determine before we seek */ + switch (xsh_type) { + case SHT_SYMTAB: +#if 0 + case SHT_DYNSYM: +#endif + stripped = 0; + break; + default: + if (fsize != SIZE_UNKNOWN && xsh_offset > fsize) { + /* Perhaps warn here */ + continue; + } + break; + } + + + /* Things we can determine when we seek */ + switch (xsh_type) { + case SHT_NOTE: + if (CAST(uintmax_t, (xsh_size + xsh_offset)) > + CAST(uintmax_t, fsize)) { + if (file_printf(ms, + "", note offset/size %#"" INTMAX_T_FORMAT + ""x+%#"" INTMAX_T_FORMAT ""x exceeds"" + "" file size %#"" INTMAX_T_FORMAT ""x"", + CAST(uintmax_t, xsh_offset), + CAST(uintmax_t, xsh_size), + CAST(uintmax_t, fsize)) == -1) + return -1; + return 0; + } + if ((nbuf = malloc(xsh_size)) == NULL) { + file_error(ms, errno, ""Cannot allocate memory"" + "" for note""); + return -1; + } + if (pread(fd, nbuf, xsh_size, xsh_offset) < + CAST(ssize_t, xsh_size)) { + file_badread(ms); + free(nbuf); + return -1; + } + + noff = 0; + for (;;) { + if (noff >= CAST(off_t, xsh_size)) + break; + noff = donote(ms, nbuf, CAST(size_t, noff), + xsh_size, clazz, swap, 4, flags, notecount, + fd, 0, 0, 0); + if (noff == 0) + break; + } + free(nbuf); + break; + case SHT_SUNW_cap: + switch (mach) { + case EM_SPARC: + case EM_SPARCV9: + case EM_IA_64: + case EM_386: + case EM_AMD64: + break; + default: + goto skip; + } + + if (nbadcap > 5) + break; + if (lseek(fd, xsh_offset, SEEK_SET) + == CAST(off_t, -1)) { + file_badseek(ms); + return -1; + } + coff = 0; + for (;;) { + Elf32_Cap cap32; + Elf64_Cap cap64; + char cbuf[/*CONSTCOND*/ + MAX(sizeof(cap32), sizeof(cap64))]; + if ((coff += xcap_sizeof) > + CAST(off_t, xsh_size)) + break; + if (read(fd, cbuf, CAST(size_t, xcap_sizeof)) != + CAST(ssize_t, xcap_sizeof)) { + file_badread(ms); + return -1; + } + if (cbuf[0] == 'A') { +#ifdef notyet + char *p = cbuf + 1; + uint32_t len, tag; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (memcmp(""gnu"", p, 3) != 0) { + if (file_printf(ms, + "", unknown capability %.3s"", p) + == -1) + return -1; + break; + } + p += strlen(p) + 1; + tag = *p++; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (tag != 1) { + if (file_printf(ms, "", unknown gnu"" + "" capability tag %d"", tag) + == -1) + return -1; + break; + } +#endif + break; + } + memcpy(xcap_addr, cbuf, xcap_sizeof); + switch (xcap_tag) { + case CA_SUNW_NULL: + break; + case CA_SUNW_HW_1: + cap_hw1 |= xcap_val; + break; + case CA_SUNW_SF_1: + cap_sf1 |= xcap_val; + break; + default: + if (file_printf(ms, + "", with unknown capability "" + ""%#"" INT64_T_FORMAT ""x = %#"" + INT64_T_FORMAT ""x"", + CAST(unsigned long long, xcap_tag), + CAST(unsigned long long, xcap_val)) + == -1) + return -1; + if (nbadcap++ > 2) + coff = xsh_size; + break; + } + } + /*FALLTHROUGH*/ + skip: + default: + break; + } + } + + if (has_debug_info) { + if (file_printf(ms, "", with debug_info"") == -1) + return -1; + } + if (file_printf(ms, "", %sstripped"", stripped ? """" : ""not "") == -1) + return -1; + if (cap_hw1) { + const cap_desc_t *cdp; + switch (mach) { + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + cdp = cap_desc_sparc; + break; + case EM_386: + case EM_IA_64: + case EM_AMD64: + cdp = cap_desc_386; + break; + default: + cdp = NULL; + break; + } + if (file_printf(ms, "", uses"") == -1) + return -1; + if (cdp) { + while (cdp->cd_name) { + if (cap_hw1 & cdp->cd_mask) { + if (file_printf(ms, + "" %s"", cdp->cd_name) == -1) + return -1; + cap_hw1 &= ~cdp->cd_mask; + } + ++cdp; + } + if (cap_hw1) + if (file_printf(ms, + "" unknown hardware capability %#"" + INT64_T_FORMAT ""x"", + CAST(unsigned long long, cap_hw1)) == -1) + return -1; + } else { + if (file_printf(ms, + "" hardware capability %#"" INT64_T_FORMAT ""x"", + CAST(unsigned long long, cap_hw1)) == -1) + return -1; + } + } + if (cap_sf1) { + if (cap_sf1 & SF1_SUNW_FPUSED) { + if (file_printf(ms, + (cap_sf1 & SF1_SUNW_FPKNWN) + ? "", uses frame pointer"" + : "", not known to use frame pointer"") == -1) + return -1; + } + cap_sf1 &= ~SF1_SUNW_MASK; + if (cap_sf1) + if (file_printf(ms, + "", with unknown software capability %#"" + INT64_T_FORMAT ""x"", + CAST(unsigned long long, cap_sf1)) == -1) + return -1; + } + return 0; +} +","@@ -27,7 +27,7 @@ + #include ""file.h"" + + #ifndef lint +-FILE_RCSID(""@(#)$File: readelf.c,v 1.142 2018/05/24 18:08:01 christos Exp $"") ++FILE_RCSID(""@(#)$File: readelf.c,v 1.143 2018/06/09 16:00:06 christos Exp $"") + #endif + + #ifdef BUILTIN_ELF +@@ -842,7 +842,8 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, + + cname = (unsigned char *) + &nbuf[doff + prpsoffsets(i)]; +- for (cp = cname; *cp && isprint(*cp); cp++) ++ for (cp = cname; cp < nbuf + size && *cp ++ && isprint(*cp); cp++) + continue; + /* + * Linux apparently appends a space at the end",2056,2292,4096 +7515,"hfs_ext_find_extent_record_attr(HFS_INFO * hfs, uint32_t cnid, + TSK_FS_ATTR * a_attr, unsigned char dataForkQ) +{ + TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); + uint16_t nodesize; /* size of nodes (all, regardless of the name) */ + uint32_t cur_node; /* node id of the current node */ + char *node = NULL; + uint8_t is_done; + uint8_t desiredType; + + tsk_error_reset(); + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record_attr: Looking for extents for file %"" + PRIu32 "" %s\n"", cnid, + dataForkQ ? ""data fork"" : ""resource fork""); + + if (!hfs->has_extents_file) { + return 0; + } + + desiredType = + dataForkQ ? HFS_EXT_KEY_TYPE_DATA : HFS_EXT_KEY_TYPE_RSRC; + + if (hfs->extents_file == NULL) { + ssize_t cnt; + + if ((hfs->extents_file = + tsk_fs_file_open_meta(fs, NULL, + HFS_EXTENTS_FILE_ID)) == NULL) { + return 1; + } + + /* cache the data attribute */ + hfs->extents_attr = + tsk_fs_attrlist_get(hfs->extents_file->meta->attr, + TSK_FS_ATTR_TYPE_DEFAULT); + if (!hfs->extents_attr) { + tsk_error_errstr2_concat + ("" - Default Attribute not found in Extents File""); + return 1; + } + + cnt = tsk_fs_attr_read(hfs->extents_attr, 14, + (char *) &(hfs->extents_header), + sizeof(hfs_btree_header_record), 0); + if (cnt != sizeof(hfs_btree_header_record)) { + if (cnt >= 0) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_FS_READ); + } + tsk_error_set_errstr2 + (""hfs_ext_find_extent_record_attr: Error reading header""); + return 1; + } + } + + nodesize = tsk_getu16(fs->endian, hfs->extents_header.nodesize); + if ((node = (char *) tsk_malloc(nodesize)) == NULL) { + return 1; + } + + /* start at root node */ + cur_node = tsk_getu32(fs->endian, hfs->extents_header.rootNode); + + /* if the root node is zero, then the extents btree is empty */ + /* if no files have overflow extents, the Extents B-tree still + exists on disk, but is an empty B-tree containing only + the header node */ + if (cur_node == 0) { + if (tsk_verbose) + tsk_fprintf(stderr, ""hfs_ext_find_extent_record: "" + ""empty extents btree\n""); + free(node); + return 0; + } + + if (tsk_verbose) + tsk_fprintf(stderr, ""hfs_ext_find_extent_record: starting at "" + ""root node %"" PRIu32 ""; nodesize = %"" + PRIu16 ""\n"", cur_node, nodesize); + + /* Recurse down to the needed leaf nodes and then go forward */ + is_done = 0; + while (is_done == 0) { + TSK_OFF_T cur_off; /* start address of cur_node */ + uint16_t num_rec; /* number of records in this node */ + ssize_t cnt; + hfs_btree_node *node_desc; + + if (cur_node > tsk_getu32(fs->endian, + hfs->extents_header.totalNodes)) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: Node %d too large for file"", + cur_node); + free(node); + return 1; + } + + cur_off = (TSK_OFF_T)cur_node * nodesize; + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: reading node %"" PRIu32 + "" at offset %"" PRIuOFF ""\n"", cur_node, cur_off); + + cnt = tsk_fs_attr_read(hfs->extents_attr, cur_off, + node, nodesize, 0); + if (cnt != nodesize) { + if (cnt >= 0) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_FS_READ); + } + tsk_error_set_errstr2 + (""hfs_ext_find_extent_record_attr: Error reading node %d at offset %"" + PRIuOFF, cur_node, cur_off); + free(node); + return 1; + } + + if (nodesize < sizeof(hfs_btree_node)) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: Node size %d is too small to be valid"", nodesize); + free(node); + return 1; + } + node_desc = (hfs_btree_node *) node; + num_rec = tsk_getu16(fs->endian, node_desc->num_rec); + + if (num_rec == 0) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record: zero records in node %"" + PRIu32, cur_node); + free(node); + return 1; + } + + + /* With an index node, find the record with the largest key that is smaller + * to or equal to cnid */ + if (node_desc->type == HFS_BT_NODE_TYPE_IDX) { + uint32_t next_node = 0; + int rec; + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: Index node %"" PRIu32 + "" @ %"" PRIu64 "" has %"" PRIu16 "" records\n"", cur_node, + cur_off, num_rec); + + for (rec = 0; rec < num_rec; ++rec) { + int cmp; + size_t rec_off; + hfs_btree_key_ext *key; + + rec_off = + tsk_getu16(fs->endian, + &node[nodesize - (rec + 1) * 2]); + if (rec_off + sizeof(hfs_btree_key_ext) > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset of record %d in index node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, (int) rec_off, + nodesize); + free(node); + return 1; + } + key = (hfs_btree_key_ext *) & node[rec_off]; + + cmp = hfs_ext_compare_keys(hfs, cnid, key); + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: record %"" PRIu16 + "" ; keylen %"" PRIu16 "" (FileId: %"" PRIu32 + "", ForkType: %"" PRIu8 "", StartBlk: %"" PRIu32 + ""); compare: %d\n"", rec, tsk_getu16(fs->endian, + key->key_len), tsk_getu32(fs->endian, + key->file_id), key->fork_type, + tsk_getu32(fs->endian, key->start_block), cmp); + + /* save the info from this record unless it is bigger than cnid */ + if ((cmp <= 0) || (next_node == 0)) { + hfs_btree_index_record *idx_rec; + int keylen = + 2 + hfs_get_idxkeylen(hfs, tsk_getu16(fs->endian, + key->key_len), &(hfs->extents_header)); + if (rec_off + keylen > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset and keylenth of record %d in index node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, + (int) rec_off + keylen, nodesize); + free(node); + return 1; + } + idx_rec = + (hfs_btree_index_record *) & node[rec_off + + keylen]; + next_node = tsk_getu32(fs->endian, idx_rec->childNode); + } + + if (cmp > 0) { + break; + } + } + + if (next_node == 0) { + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record_attr: did not find any keys for %d in index node %d"", + cnid, cur_node); + is_done = 1; + break; + } + cur_node = next_node; + } + + /* with a leaf, we process until we are past cnid. We move right too if we can */ + else if (node_desc->type == HFS_BT_NODE_TYPE_LEAF) { + int rec; + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: Leaf node %"" PRIu32 "" @ %"" + PRIu64 "" has %"" PRIu16 "" records\n"", cur_node, cur_off, + num_rec); + + for (rec = 0; rec < num_rec; ++rec) { + size_t rec_off; + hfs_btree_key_ext *key; + uint32_t rec_cnid; + hfs_extents *extents; + TSK_OFF_T ext_off = 0; + int keylen; + TSK_FS_ATTR_RUN *attr_run; + + rec_off = + tsk_getu16(fs->endian, + &node[nodesize - (rec + 1) * 2]); + if (rec_off > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset of record %d in leaf node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, (int) rec_off, + nodesize); + free(node); + return 1; + } + key = (hfs_btree_key_ext *) & node[rec_off]; + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: record %"" PRIu16 + ""; keylen %"" PRIu16 "" (%"" PRIu32 + "", %"" PRIu8 "", %"" PRIu32 "")\n"", rec, + tsk_getu16(fs->endian, key->key_len), + tsk_getu32(fs->endian, key->file_id), + key->fork_type, tsk_getu32(fs->endian, + key->start_block)); + + rec_cnid = tsk_getu32(fs->endian, key->file_id); + + + if (rec_cnid < cnid) { + continue; + } + if (rec_cnid > cnid) { + is_done = 1; + break; + } + + + if (key->fork_type != desiredType) { + if (dataForkQ) { + is_done = 1; + break; + } + else + continue; + } + + keylen = 2 + tsk_getu16(fs->endian, key->key_len); + if (rec_off + keylen + sizeof(hfs_extents) > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset and keylenth of record %d in leaf node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, (int) rec_off + keylen, + nodesize); + free(node); + return 1; + } + + ext_off = tsk_getu32(fs->endian, key->start_block); + + extents = (hfs_extents *) & node[rec_off + keylen]; + + attr_run = + hfs_extents_to_attr(fs, extents->extents, ext_off); + if ((attr_run == NULL) && (tsk_error_get_errno() != 0)) { + tsk_error_errstr2_concat + ("" - hfs_ext_find_extent_record_attr""); + free(node); + return 1; + } + + if (tsk_fs_attr_add_run(fs, a_attr, attr_run)) { + tsk_error_errstr2_concat + ("" - hfs_ext_find_extent_record_attr""); + free(node); + return 1; + } + } + cur_node = tsk_getu32(fs->endian, node_desc->flink); + if (cur_node == 0) { + is_done = 1; + break; + } + } + else { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr(""hfs_ext_find_extent_record: btree node %"" + PRIu32 "" (%"" PRIuOFF "") is neither index nor leaf (%"" PRIu8 + "")"", cur_node, cur_off, node_desc->type); + free(node); + return 1; + } + } + free(node); + return 0; +} +",0,"hfs_ext_find_extent_record_attr(HFS_INFO * hfs, uint32_t cnid, + TSK_FS_ATTR * a_attr, unsigned char dataForkQ) +{ + TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info); + uint16_t nodesize; /* size of nodes (all, regardless of the name) */ + uint32_t cur_node; /* node id of the current node */ + char *node = NULL; + uint8_t is_done; + uint8_t desiredType; + + tsk_error_reset(); + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record_attr: Looking for extents for file %"" + PRIu32 "" %s\n"", cnid, + dataForkQ ? ""data fork"" : ""resource fork""); + + if (!hfs->has_extents_file) { + return 0; + } + + desiredType = + dataForkQ ? HFS_EXT_KEY_TYPE_DATA : HFS_EXT_KEY_TYPE_RSRC; + + if (hfs->extents_file == NULL) { + ssize_t cnt; + + if ((hfs->extents_file = + tsk_fs_file_open_meta(fs, NULL, + HFS_EXTENTS_FILE_ID)) == NULL) { + return 1; + } + + /* cache the data attribute */ + hfs->extents_attr = + tsk_fs_attrlist_get(hfs->extents_file->meta->attr, + TSK_FS_ATTR_TYPE_DEFAULT); + if (!hfs->extents_attr) { + tsk_error_errstr2_concat + ("" - Default Attribute not found in Extents File""); + return 1; + } + + cnt = tsk_fs_attr_read(hfs->extents_attr, 14, + (char *) &(hfs->extents_header), + sizeof(hfs_btree_header_record), 0); + if (cnt != sizeof(hfs_btree_header_record)) { + if (cnt >= 0) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_FS_READ); + } + tsk_error_set_errstr2 + (""hfs_ext_find_extent_record_attr: Error reading header""); + return 1; + } + } + + nodesize = tsk_getu16(fs->endian, hfs->extents_header.nodesize); + if ((node = (char *) tsk_malloc(nodesize)) == NULL) { + return 1; + } + + /* start at root node */ + cur_node = tsk_getu32(fs->endian, hfs->extents_header.rootNode); + + /* if the root node is zero, then the extents btree is empty */ + /* if no files have overflow extents, the Extents B-tree still + exists on disk, but is an empty B-tree containing only + the header node */ + if (cur_node == 0) { + if (tsk_verbose) + tsk_fprintf(stderr, ""hfs_ext_find_extent_record: "" + ""empty extents btree\n""); + free(node); + return 0; + } + + if (tsk_verbose) + tsk_fprintf(stderr, ""hfs_ext_find_extent_record: starting at "" + ""root node %"" PRIu32 ""; nodesize = %"" + PRIu16 ""\n"", cur_node, nodesize); + + /* Recurse down to the needed leaf nodes and then go forward */ + is_done = 0; + while (is_done == 0) { + TSK_OFF_T cur_off; /* start address of cur_node */ + uint16_t num_rec; /* number of records in this node */ + ssize_t cnt; + hfs_btree_node *node_desc; + + if (cur_node > tsk_getu32(fs->endian, + hfs->extents_header.totalNodes)) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: Node %d too large for file"", + cur_node); + free(node); + return 1; + } + + cur_off = (TSK_OFF_T)cur_node * nodesize; + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: reading node %"" PRIu32 + "" at offset %"" PRIuOFF ""\n"", cur_node, cur_off); + + cnt = tsk_fs_attr_read(hfs->extents_attr, cur_off, + node, nodesize, 0); + if (cnt != nodesize) { + if (cnt >= 0) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_FS_READ); + } + tsk_error_set_errstr2 + (""hfs_ext_find_extent_record_attr: Error reading node %d at offset %"" + PRIuOFF, cur_node, cur_off); + free(node); + return 1; + } + + if (nodesize < sizeof(hfs_btree_node)) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: Node size %d is too small to be valid"", nodesize); + free(node); + return 1; + } + node_desc = (hfs_btree_node *) node; + num_rec = tsk_getu16(fs->endian, node_desc->num_rec); + + if (num_rec == 0) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record: zero records in node %"" + PRIu32, cur_node); + free(node); + return 1; + } + + + /* With an index node, find the record with the largest key that is smaller + * to or equal to cnid */ + if (node_desc->type == HFS_BT_NODE_TYPE_IDX) { + uint32_t next_node = 0; + int rec; + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: Index node %"" PRIu32 + "" @ %"" PRIu64 "" has %"" PRIu16 "" records\n"", cur_node, + cur_off, num_rec); + + for (rec = 0; rec < num_rec; ++rec) { + int cmp; + size_t rec_off; + hfs_btree_key_ext *key; + + rec_off = + tsk_getu16(fs->endian, + &node[nodesize - (rec + 1) * 2]); + if (rec_off + sizeof(hfs_btree_key_ext) > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset of record %d in index node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, (int) rec_off, + nodesize); + free(node); + return 1; + } + key = (hfs_btree_key_ext *) & node[rec_off]; + + cmp = hfs_ext_compare_keys(hfs, cnid, key); + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: record %"" PRIu16 + "" ; keylen %"" PRIu16 "" (FileId: %"" PRIu32 + "", ForkType: %"" PRIu8 "", StartBlk: %"" PRIu32 + ""); compare: %d\n"", rec, tsk_getu16(fs->endian, + key->key_len), tsk_getu32(fs->endian, + key->file_id), key->fork_type, + tsk_getu32(fs->endian, key->start_block), cmp); + + /* save the info from this record unless it is bigger than cnid */ + if ((cmp <= 0) || (next_node == 0)) { + hfs_btree_index_record *idx_rec; + int keylen = + 2 + hfs_get_idxkeylen(hfs, tsk_getu16(fs->endian, + key->key_len), &(hfs->extents_header)); + if (rec_off + keylen > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset and keylenth of record %d in index node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, + (int) rec_off + keylen, nodesize); + free(node); + return 1; + } + idx_rec = + (hfs_btree_index_record *) & node[rec_off + + keylen]; + next_node = tsk_getu32(fs->endian, idx_rec->childNode); + } + + if (cmp > 0) { + break; + } + } + + if (next_node == 0) { + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record_attr: did not find any keys for %d in index node %d"", + cnid, cur_node); + is_done = 1; + break; + } + cur_node = next_node; + } + + /* with a leaf, we process until we are past cnid. We move right too if we can */ + else if (node_desc->type == HFS_BT_NODE_TYPE_LEAF) { + int rec; + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: Leaf node %"" PRIu32 "" @ %"" + PRIu64 "" has %"" PRIu16 "" records\n"", cur_node, cur_off, + num_rec); + + for (rec = 0; rec < num_rec; ++rec) { + size_t rec_off; + hfs_btree_key_ext *key; + uint32_t rec_cnid; + hfs_extents *extents; + TSK_OFF_T ext_off = 0; + int keylen; + TSK_FS_ATTR_RUN *attr_run; + + rec_off = + tsk_getu16(fs->endian, + &node[nodesize - (rec + 1) * 2]); + if (rec_off > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset of record %d in leaf node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, (int) rec_off, + nodesize); + free(node); + return 1; + } + key = (hfs_btree_key_ext *) & node[rec_off]; + + if (tsk_verbose) + tsk_fprintf(stderr, + ""hfs_ext_find_extent_record: record %"" PRIu16 + ""; keylen %"" PRIu16 "" (%"" PRIu32 + "", %"" PRIu8 "", %"" PRIu32 "")\n"", rec, + tsk_getu16(fs->endian, key->key_len), + tsk_getu32(fs->endian, key->file_id), + key->fork_type, tsk_getu32(fs->endian, + key->start_block)); + + rec_cnid = tsk_getu32(fs->endian, key->file_id); + + + if (rec_cnid < cnid) { + continue; + } + if (rec_cnid > cnid) { + is_done = 1; + break; + } + + + if (key->fork_type != desiredType) { + if (dataForkQ) { + is_done = 1; + break; + } + else + continue; + } + + keylen = 2 + tsk_getu16(fs->endian, key->key_len); + if (rec_off + keylen + sizeof(hfs_extents) > nodesize) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_ext_find_extent_record_attr: offset and keylenth of record %d in leaf node %d too large (%d vs %"" + PRIu16 "")"", rec, cur_node, (int) rec_off + keylen, + nodesize); + free(node); + return 1; + } + + ext_off = tsk_getu32(fs->endian, key->start_block); + + extents = (hfs_extents *) & node[rec_off + keylen]; + + attr_run = + hfs_extents_to_attr(fs, extents->extents, ext_off); + if ((attr_run == NULL) && (tsk_error_get_errno() != 0)) { + tsk_error_errstr2_concat + ("" - hfs_ext_find_extent_record_attr""); + free(node); + return 1; + } + + if (tsk_fs_attr_add_run(fs, a_attr, attr_run)) { + tsk_error_errstr2_concat + ("" - hfs_ext_find_extent_record_attr""); + free(node); + return 1; + } + } + cur_node = tsk_getu32(fs->endian, node_desc->flink); + if (cur_node == 0) { + is_done = 1; + break; + } + } + else { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr(""hfs_ext_find_extent_record: btree node %"" + PRIu32 "" (%"" PRIuOFF "") is neither index nor leaf (%"" PRIu8 + "")"", cur_node, cur_off, node_desc->type); + free(node); + return 1; + } + } + free(node); + return 0; +} +","@@ -956,11 +956,12 @@ hfs_cat_traverse(HFS_INFO * hfs, + key = (hfs_btree_key_cat *) & node[rec_off]; + + keylen = 2 + tsk_getu16(hfs->fs_info.endian, key->key_len); +- if ((keylen) > nodesize) { ++ ++ if (keylen >= nodesize - rec_off) { + tsk_error_set_errno(TSK_ERR_FS_GENFS); + tsk_error_set_errstr + (""hfs_cat_traverse: length of key %d in index node %d too large (%d vs %"" +- PRIu16 "")"", rec, cur_node, keylen, nodesize); ++ PRIu16 "")"", rec, cur_node, keylen, (nodesize - rec_off)); + free(node); + return 1; + }",3001,3237,4096 +7900,"static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) +{ + int64_t pos = avio_tell(pb); + char compressor_name[32] = { 0 }; + int avid = 0; + + int uncompressed_ycbcr = ((track->par->codec_id == AV_CODEC_ID_RAWVIDEO && track->par->format == AV_PIX_FMT_UYVY422) + || (track->par->codec_id == AV_CODEC_ID_RAWVIDEO && track->par->format == AV_PIX_FMT_YUYV422) + || track->par->codec_id == AV_CODEC_ID_V308 + || track->par->codec_id == AV_CODEC_ID_V408 + || track->par->codec_id == AV_CODEC_ID_V410 + || track->par->codec_id == AV_CODEC_ID_V210); + + avio_wb32(pb, 0); /* size */ + if (mov->encryption_scheme != MOV_ENC_NONE) { + ffio_wfourcc(pb, ""encv""); + } else { + avio_wl32(pb, track->tag); // store it byteswapped + } + avio_wb32(pb, 0); /* Reserved */ + avio_wb16(pb, 0); /* Reserved */ + avio_wb16(pb, 1); /* Data-reference index */ + + if (uncompressed_ycbcr) { + avio_wb16(pb, 2); /* Codec stream version */ + } else { + avio_wb16(pb, 0); /* Codec stream version */ + } + avio_wb16(pb, 0); /* Codec stream revision (=0) */ + if (track->mode == MODE_MOV) { + ffio_wfourcc(pb, ""FFMP""); /* Vendor */ + if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO || uncompressed_ycbcr) { + avio_wb32(pb, 0); /* Temporal Quality */ + avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/ + } else { + avio_wb32(pb, 0x200); /* Temporal Quality = normal */ + avio_wb32(pb, 0x200); /* Spatial Quality = normal */ + } + } else { + avio_wb32(pb, 0); /* Reserved */ + avio_wb32(pb, 0); /* Reserved */ + avio_wb32(pb, 0); /* Reserved */ + } + avio_wb16(pb, track->par->width); /* Video width */ + avio_wb16(pb, track->height); /* Video height */ + avio_wb32(pb, 0x00480000); /* Horizontal resolution 72dpi */ + avio_wb32(pb, 0x00480000); /* Vertical resolution 72dpi */ + avio_wb32(pb, 0); /* Data size (= 0) */ + avio_wb16(pb, 1); /* Frame count (= 1) */ + + /* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */ + find_compressor(compressor_name, 32, track); + avio_w8(pb, strlen(compressor_name)); + avio_write(pb, compressor_name, 31); + + if (track->mode == MODE_MOV && + (track->par->codec_id == AV_CODEC_ID_V410 || track->par->codec_id == AV_CODEC_ID_V210)) + avio_wb16(pb, 0x18); + else if (track->mode == MODE_MOV && track->par->bits_per_coded_sample) + avio_wb16(pb, track->par->bits_per_coded_sample | + (track->par->format == AV_PIX_FMT_GRAY8 ? 0x20 : 0)); + else + avio_wb16(pb, 0x18); /* Reserved */ + + if (track->mode == MODE_MOV && track->par->format == AV_PIX_FMT_PAL8) { + int pal_size = 1 << track->par->bits_per_coded_sample; + int i; + avio_wb16(pb, 0); /* Color table ID */ + avio_wb32(pb, 0); /* Color table seed */ + avio_wb16(pb, 0x8000); /* Color table flags */ + avio_wb16(pb, pal_size - 1); /* Color table size (zero-relative) */ + for (i = 0; i < pal_size; i++) { + uint32_t rgb = track->palette[i]; + uint16_t r = (rgb >> 16) & 0xff; + uint16_t g = (rgb >> 8) & 0xff; + uint16_t b = rgb & 0xff; + avio_wb16(pb, 0); + avio_wb16(pb, (r << 8) | r); + avio_wb16(pb, (g << 8) | g); + avio_wb16(pb, (b << 8) | b); + } + } else + avio_wb16(pb, 0xffff); /* Reserved */ + + if (track->tag == MKTAG('m','p','4','v')) + mov_write_esds_tag(pb, track); + else if (track->par->codec_id == AV_CODEC_ID_H263) + mov_write_d263_tag(pb); + else if (track->par->codec_id == AV_CODEC_ID_AVUI || + track->par->codec_id == AV_CODEC_ID_SVQ3) { + mov_write_extradata_tag(pb, track); + avio_wb32(pb, 0); + } else if (track->par->codec_id == AV_CODEC_ID_DNXHD) { + mov_write_avid_tag(pb, track); + avid = 1; + } else if (track->par->codec_id == AV_CODEC_ID_HEVC) + mov_write_hvcc_tag(pb, track); + else if (track->par->codec_id == AV_CODEC_ID_H264 && !TAG_IS_AVCI(track->tag)) { + mov_write_avcc_tag(pb, track); + if (track->mode == MODE_IPOD) + mov_write_uuid_tag_ipod(pb); + } else if (track->par->codec_id == AV_CODEC_ID_VP9) { + mov_write_vpcc_tag(mov->fc, pb, track); + } else if (track->par->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0) + mov_write_dvc1_tag(pb, track); + else if (track->par->codec_id == AV_CODEC_ID_VP6F || + track->par->codec_id == AV_CODEC_ID_VP6A) { + /* Don't write any potential extradata here - the cropping + * is signalled via the normal width/height fields. */ + } else if (track->par->codec_id == AV_CODEC_ID_R10K) { + if (track->par->codec_tag == MKTAG('R','1','0','k')) + mov_write_dpxe_tag(pb, track); + } else if (track->vos_len > 0) + mov_write_glbl_tag(pb, track); + + if (track->par->codec_id != AV_CODEC_ID_H264 && + track->par->codec_id != AV_CODEC_ID_MPEG4 && + track->par->codec_id != AV_CODEC_ID_DNXHD) { + int field_order = track->par->field_order; + +#if FF_API_LAVF_AVCTX + FF_DISABLE_DEPRECATION_WARNINGS + if (field_order != track->st->codec->field_order && track->st->codec->field_order != AV_FIELD_UNKNOWN) + field_order = track->st->codec->field_order; + FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (field_order != AV_FIELD_UNKNOWN) + mov_write_fiel_tag(pb, track, field_order); + } + + if (mov->flags & FF_MOV_FLAG_WRITE_GAMA) { + if (track->mode == MODE_MOV) + mov_write_gama_tag(pb, track, mov->gamma); + else + av_log(mov->fc, AV_LOG_WARNING, ""Not writing 'gama' atom. Format is not MOV.\n""); + } + if (mov->flags & FF_MOV_FLAG_WRITE_COLR) { + if (track->mode == MODE_MOV || track->mode == MODE_MP4) + mov_write_colr_tag(pb, track); + else + av_log(mov->fc, AV_LOG_WARNING, ""Not writing 'colr' atom. Format is not MOV or MP4.\n""); + } + + if (track->mode == MODE_MP4 && mov->fc->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { + AVStereo3D* stereo_3d = (AVStereo3D*) av_stream_get_side_data(track->st, AV_PKT_DATA_STEREO3D, NULL); + AVSphericalMapping* spherical_mapping = (AVSphericalMapping*)av_stream_get_side_data(track->st, AV_PKT_DATA_SPHERICAL, NULL); + + if (stereo_3d) + mov_write_st3d_tag(pb, stereo_3d); + if (spherical_mapping) + mov_write_sv3d_tag(mov->fc, pb, spherical_mapping); + } + + if (track->par->sample_aspect_ratio.den && track->par->sample_aspect_ratio.num) { + mov_write_pasp_tag(pb, track); + } + + if (uncompressed_ycbcr){ + mov_write_clap_tag(pb, track); + } + + if (mov->encryption_scheme != MOV_ENC_NONE) { + ff_mov_cenc_write_sinf_tag(track, pb, mov->encryption_kid); + } + + /* extra padding for avid stsd */ + /* https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-61112 */ + if (avid) + avio_wb32(pb, 0); + + return update_size(pb, pos); +} +",0,"static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) +{ + int64_t pos = avio_tell(pb); + char compressor_name[32] = { 0 }; + int avid = 0; + + int uncompressed_ycbcr = ((track->par->codec_id == AV_CODEC_ID_RAWVIDEO && track->par->format == AV_PIX_FMT_UYVY422) + || (track->par->codec_id == AV_CODEC_ID_RAWVIDEO && track->par->format == AV_PIX_FMT_YUYV422) + || track->par->codec_id == AV_CODEC_ID_V308 + || track->par->codec_id == AV_CODEC_ID_V408 + || track->par->codec_id == AV_CODEC_ID_V410 + || track->par->codec_id == AV_CODEC_ID_V210); + + avio_wb32(pb, 0); /* size */ + if (mov->encryption_scheme != MOV_ENC_NONE) { + ffio_wfourcc(pb, ""encv""); + } else { + avio_wl32(pb, track->tag); // store it byteswapped + } + avio_wb32(pb, 0); /* Reserved */ + avio_wb16(pb, 0); /* Reserved */ + avio_wb16(pb, 1); /* Data-reference index */ + + if (uncompressed_ycbcr) { + avio_wb16(pb, 2); /* Codec stream version */ + } else { + avio_wb16(pb, 0); /* Codec stream version */ + } + avio_wb16(pb, 0); /* Codec stream revision (=0) */ + if (track->mode == MODE_MOV) { + ffio_wfourcc(pb, ""FFMP""); /* Vendor */ + if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO || uncompressed_ycbcr) { + avio_wb32(pb, 0); /* Temporal Quality */ + avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/ + } else { + avio_wb32(pb, 0x200); /* Temporal Quality = normal */ + avio_wb32(pb, 0x200); /* Spatial Quality = normal */ + } + } else { + avio_wb32(pb, 0); /* Reserved */ + avio_wb32(pb, 0); /* Reserved */ + avio_wb32(pb, 0); /* Reserved */ + } + avio_wb16(pb, track->par->width); /* Video width */ + avio_wb16(pb, track->height); /* Video height */ + avio_wb32(pb, 0x00480000); /* Horizontal resolution 72dpi */ + avio_wb32(pb, 0x00480000); /* Vertical resolution 72dpi */ + avio_wb32(pb, 0); /* Data size (= 0) */ + avio_wb16(pb, 1); /* Frame count (= 1) */ + + /* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */ + find_compressor(compressor_name, 32, track); + avio_w8(pb, strlen(compressor_name)); + avio_write(pb, compressor_name, 31); + + if (track->mode == MODE_MOV && + (track->par->codec_id == AV_CODEC_ID_V410 || track->par->codec_id == AV_CODEC_ID_V210)) + avio_wb16(pb, 0x18); + else if (track->mode == MODE_MOV && track->par->bits_per_coded_sample) + avio_wb16(pb, track->par->bits_per_coded_sample | + (track->par->format == AV_PIX_FMT_GRAY8 ? 0x20 : 0)); + else + avio_wb16(pb, 0x18); /* Reserved */ + + if (track->mode == MODE_MOV && track->par->format == AV_PIX_FMT_PAL8) { + int pal_size = 1 << track->par->bits_per_coded_sample; + int i; + avio_wb16(pb, 0); /* Color table ID */ + avio_wb32(pb, 0); /* Color table seed */ + avio_wb16(pb, 0x8000); /* Color table flags */ + avio_wb16(pb, pal_size - 1); /* Color table size (zero-relative) */ + for (i = 0; i < pal_size; i++) { + uint32_t rgb = track->palette[i]; + uint16_t r = (rgb >> 16) & 0xff; + uint16_t g = (rgb >> 8) & 0xff; + uint16_t b = rgb & 0xff; + avio_wb16(pb, 0); + avio_wb16(pb, (r << 8) | r); + avio_wb16(pb, (g << 8) | g); + avio_wb16(pb, (b << 8) | b); + } + } else + avio_wb16(pb, 0xffff); /* Reserved */ + + if (track->tag == MKTAG('m','p','4','v')) + mov_write_esds_tag(pb, track); + else if (track->par->codec_id == AV_CODEC_ID_H263) + mov_write_d263_tag(pb); + else if (track->par->codec_id == AV_CODEC_ID_AVUI || + track->par->codec_id == AV_CODEC_ID_SVQ3) { + mov_write_extradata_tag(pb, track); + avio_wb32(pb, 0); + } else if (track->par->codec_id == AV_CODEC_ID_DNXHD) { + mov_write_avid_tag(pb, track); + avid = 1; + } else if (track->par->codec_id == AV_CODEC_ID_HEVC) + mov_write_hvcc_tag(pb, track); + else if (track->par->codec_id == AV_CODEC_ID_H264 && !TAG_IS_AVCI(track->tag)) { + mov_write_avcc_tag(pb, track); + if (track->mode == MODE_IPOD) + mov_write_uuid_tag_ipod(pb); + } else if (track->par->codec_id == AV_CODEC_ID_VP9) { + mov_write_vpcc_tag(mov->fc, pb, track); + } else if (track->par->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0) + mov_write_dvc1_tag(pb, track); + else if (track->par->codec_id == AV_CODEC_ID_VP6F || + track->par->codec_id == AV_CODEC_ID_VP6A) { + /* Don't write any potential extradata here - the cropping + * is signalled via the normal width/height fields. */ + } else if (track->par->codec_id == AV_CODEC_ID_R10K) { + if (track->par->codec_tag == MKTAG('R','1','0','k')) + mov_write_dpxe_tag(pb, track); + } else if (track->vos_len > 0) + mov_write_glbl_tag(pb, track); + + if (track->par->codec_id != AV_CODEC_ID_H264 && + track->par->codec_id != AV_CODEC_ID_MPEG4 && + track->par->codec_id != AV_CODEC_ID_DNXHD) { + int field_order = track->par->field_order; + +#if FF_API_LAVF_AVCTX + FF_DISABLE_DEPRECATION_WARNINGS + if (field_order != track->st->codec->field_order && track->st->codec->field_order != AV_FIELD_UNKNOWN) + field_order = track->st->codec->field_order; + FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (field_order != AV_FIELD_UNKNOWN) + mov_write_fiel_tag(pb, track, field_order); + } + + if (mov->flags & FF_MOV_FLAG_WRITE_GAMA) { + if (track->mode == MODE_MOV) + mov_write_gama_tag(pb, track, mov->gamma); + else + av_log(mov->fc, AV_LOG_WARNING, ""Not writing 'gama' atom. Format is not MOV.\n""); + } + if (mov->flags & FF_MOV_FLAG_WRITE_COLR) { + if (track->mode == MODE_MOV || track->mode == MODE_MP4) + mov_write_colr_tag(pb, track); + else + av_log(mov->fc, AV_LOG_WARNING, ""Not writing 'colr' atom. Format is not MOV or MP4.\n""); + } + + if (track->mode == MODE_MP4 && mov->fc->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { + AVStereo3D* stereo_3d = (AVStereo3D*) av_stream_get_side_data(track->st, AV_PKT_DATA_STEREO3D, NULL); + AVSphericalMapping* spherical_mapping = (AVSphericalMapping*)av_stream_get_side_data(track->st, AV_PKT_DATA_SPHERICAL, NULL); + + if (stereo_3d) + mov_write_st3d_tag(pb, stereo_3d); + if (spherical_mapping) + mov_write_sv3d_tag(mov->fc, pb, spherical_mapping); + } + + if (track->par->sample_aspect_ratio.den && track->par->sample_aspect_ratio.num) { + mov_write_pasp_tag(pb, track); + } + + if (uncompressed_ycbcr){ + mov_write_clap_tag(pb, track); + } + + if (mov->encryption_scheme != MOV_ENC_NONE) { + ff_mov_cenc_write_sinf_tag(track, pb, mov->encryption_kid); + } + + /* extra padding for avid stsd */ + /* https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-61112 */ + if (avid) + avio_wb32(pb, 0); + + return update_size(pb, pos); +} +","@@ -1022,7 +1022,7 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex + uint32_t tag = track->tag; + + if (track->mode == MODE_MOV) { +- if (track->timescale > UINT16_MAX) { ++ if (track->timescale > UINT16_MAX || !track->par->channels) { + if (mov_get_lpcm_flags(track->par->codec_id)) + tag = AV_RL32(""lpcm""); + version = 2;",2300,2536,4096 +11457,"bool TestingAutomationProvider::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + bool deserialize_success = true; + IPC_BEGIN_MESSAGE_MAP_EX(TestingAutomationProvider, + message, + deserialize_success) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser) + IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync, + CloseBrowserAsync) + IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendBackgroundTab, + AppendBackgroundTab) + IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) + IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) + IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) + IPC_MESSAGE_HANDLER(AutomationMsg_DeleteCookie, DeleteCookie) + IPC_MESSAGE_HANDLER(AutomationMsg_ShowCollectedCookiesDialog, + ShowCollectedCookiesDialog) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, + NavigateToURLBlockUntilNavigationsComplete) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsyncWithDisposition, + NavigationAsyncWithDisposition) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, CancelAuth) + IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuth, NeedsAuth) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RedirectsFrom, + GetRedirectsFrom) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) + IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, + GetNormalBrowserWindowCount) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_GetBrowserLocale, GetBrowserLocale) + IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, + GetLastActiveBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_FindTabbedBrowserWindow, + FindTabbedBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) + IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowMaximized, IsWindowMaximized) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, + ExecuteBrowserCommandAsync) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, + ExecuteBrowserCommand) + IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_GetWindowBounds, GetWindowBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) + IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) + IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) + IPC_MESSAGE_HANDLER(AutomationMsg_IsBrowserInApplicationMode, + IsBrowserInApplicationMode) + IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) + IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) + IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) + IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) + IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreen, IsFullscreen) + IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreenBubbleVisible, + GetFullscreenBubbleVisibility) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, + ExecuteJavascript) + IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCount, + GetConstrainedWindowCount) +#if defined(TOOLKIT_VIEWS) + IPC_MESSAGE_HANDLER(AutomationMsg_GetFocusedViewID, GetFocusedViewID) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForFocusedViewIDToChange, + WaitForFocusedViewIDToChange) + IPC_MESSAGE_HANDLER(AutomationMsg_StartTrackingPopupMenus, + StartTrackingPopupMenus) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForPopupMenuToOpen, + WaitForPopupMenuToOpen) +#endif // defined(TOOLKIT_VIEWS) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, + HandleInspectElementRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, + OpenNewBrowserWindowOfType) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ShowInterstitialPage, + ShowInterstitialPage) + IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, + HideInterstitialPage) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, + WaitForTabToBeRestored) + IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) + IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) + IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, + GetMetricEventDuration) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, + ActionOnSSLBlockingPage) + IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) + IPC_MESSAGE_HANDLER(AutomationMsg_IsMenuCommandEnabled, + IsMenuCommandEnabled) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_PrintNow, PrintNow) + IPC_MESSAGE_HANDLER(AutomationMsg_SavePage, SavePage) + IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, + HandleOpenFindInPageRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, + GetFindWindowVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowLocation, + HandleFindWindowLocationRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, + GetBookmarkBarVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON, + GetBookmarksAsJSON) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad, + WaitForBookmarkModelToLoad) + IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, + AddBookmarkGroup) + IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkURL, + AddBookmarkURL) + IPC_MESSAGE_HANDLER(AutomationMsg_ReparentBookmark, + ReparentBookmark) + IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkTitle, + SetBookmarkTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkURL, + SetBookmarkURL) + IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBookmark, + RemoveBookmark) + IPC_MESSAGE_HANDLER(AutomationMsg_GetInfoBarCount, GetInfoBarCount) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ClickInfoBarAccept, + ClickInfoBarAccept) + IPC_MESSAGE_HANDLER(AutomationMsg_GetLastNavigationTime, + GetLastNavigationTime) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForNavigation, + WaitForNavigation) + IPC_MESSAGE_HANDLER(AutomationMsg_SetIntPreference, SetIntPreference) + IPC_MESSAGE_HANDLER(AutomationMsg_ShowingAppModalDialog, + GetShowingAppModalDialog) + IPC_MESSAGE_HANDLER(AutomationMsg_ClickAppModalDialogButton, + ClickAppModalDialogButton) + IPC_MESSAGE_HANDLER(AutomationMsg_SetStringPreference, SetStringPreference) + IPC_MESSAGE_HANDLER(AutomationMsg_GetBooleanPreference, + GetBooleanPreference) + IPC_MESSAGE_HANDLER(AutomationMsg_SetBooleanPreference, + SetBooleanPreference) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_WaitForBrowserWindowCountToBecome, + WaitForBrowserWindowCountToBecome) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_WaitForAppModalDialogToBeShown, + WaitForAppModalDialogToBeShown) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_GoBackBlockUntilNavigationsComplete, + GoBackBlockUntilNavigationsComplete) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_GoForwardBlockUntilNavigationsComplete, + GoForwardBlockUntilNavigationsComplete) + IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, + SavePackageShouldPromptUser) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, + SendJSONRequest) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, + WaitForTabCountToBecome) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, + WaitForInfoBarCount) + IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, + GetPageCurrentEncoding) + IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService, + ShutdownSessionService) + IPC_MESSAGE_HANDLER(AutomationMsg_SetContentSetting, SetContentSetting) + IPC_MESSAGE_HANDLER(AutomationMsg_LoadBlockedPlugins, LoadBlockedPlugins) + IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_WaitForProcessLauncherThreadToGoIdle, + WaitForProcessLauncherThreadToGoIdle) + IPC_MESSAGE_HANDLER(AutomationMsg_GetParentBrowserOfTab, + GetParentBrowserOfTab) + + IPC_MESSAGE_UNHANDLED( + handled = AutomationProvider::OnMessageReceived(message)) + IPC_END_MESSAGE_MAP_EX() + if (!deserialize_success) + OnMessageDeserializationFailure(); + return handled; +} +",0,"bool TestingAutomationProvider::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + bool deserialize_success = true; + IPC_BEGIN_MESSAGE_MAP_EX(TestingAutomationProvider, + message, + deserialize_success) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser) + IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync, + CloseBrowserAsync) + IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendBackgroundTab, + AppendBackgroundTab) + IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) + IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) + IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) + IPC_MESSAGE_HANDLER(AutomationMsg_DeleteCookie, DeleteCookie) + IPC_MESSAGE_HANDLER(AutomationMsg_ShowCollectedCookiesDialog, + ShowCollectedCookiesDialog) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, + NavigateToURLBlockUntilNavigationsComplete) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) + IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsyncWithDisposition, + NavigationAsyncWithDisposition) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, CancelAuth) + IPC_MESSAGE_HANDLER(AutomationMsg_NeedsAuth, NeedsAuth) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RedirectsFrom, + GetRedirectsFrom) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) + IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, + GetNormalBrowserWindowCount) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_GetBrowserLocale, GetBrowserLocale) + IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, + GetLastActiveBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_FindTabbedBrowserWindow, + FindTabbedBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) + IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowMaximized, IsWindowMaximized) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, + ExecuteBrowserCommandAsync) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, + ExecuteBrowserCommand) + IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_GetWindowBounds, GetWindowBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) + IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) + IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) + IPC_MESSAGE_HANDLER(AutomationMsg_IsBrowserInApplicationMode, + IsBrowserInApplicationMode) + IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) + IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) + IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) + IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) + IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreen, IsFullscreen) + IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreenBubbleVisible, + GetFullscreenBubbleVisibility) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, + ExecuteJavascript) + IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCount, + GetConstrainedWindowCount) +#if defined(TOOLKIT_VIEWS) + IPC_MESSAGE_HANDLER(AutomationMsg_GetFocusedViewID, GetFocusedViewID) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForFocusedViewIDToChange, + WaitForFocusedViewIDToChange) + IPC_MESSAGE_HANDLER(AutomationMsg_StartTrackingPopupMenus, + StartTrackingPopupMenus) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForPopupMenuToOpen, + WaitForPopupMenuToOpen) +#endif // defined(TOOLKIT_VIEWS) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, + HandleInspectElementRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, + OpenNewBrowserWindowOfType) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ShowInterstitialPage, + ShowInterstitialPage) + IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, + HideInterstitialPage) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, + WaitForTabToBeRestored) + IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) + IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) + IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, + GetMetricEventDuration) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, + ActionOnSSLBlockingPage) + IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) + IPC_MESSAGE_HANDLER(AutomationMsg_IsMenuCommandEnabled, + IsMenuCommandEnabled) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_PrintNow, PrintNow) + IPC_MESSAGE_HANDLER(AutomationMsg_SavePage, SavePage) + IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, + HandleOpenFindInPageRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, + GetFindWindowVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowLocation, + HandleFindWindowLocationRequest) + IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, + GetBookmarkBarVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON, + GetBookmarksAsJSON) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad, + WaitForBookmarkModelToLoad) + IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, + AddBookmarkGroup) + IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkURL, + AddBookmarkURL) + IPC_MESSAGE_HANDLER(AutomationMsg_ReparentBookmark, + ReparentBookmark) + IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkTitle, + SetBookmarkTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkURL, + SetBookmarkURL) + IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBookmark, + RemoveBookmark) + IPC_MESSAGE_HANDLER(AutomationMsg_GetInfoBarCount, GetInfoBarCount) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ClickInfoBarAccept, + ClickInfoBarAccept) + IPC_MESSAGE_HANDLER(AutomationMsg_GetLastNavigationTime, + GetLastNavigationTime) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForNavigation, + WaitForNavigation) + IPC_MESSAGE_HANDLER(AutomationMsg_SetIntPreference, SetIntPreference) + IPC_MESSAGE_HANDLER(AutomationMsg_ShowingAppModalDialog, + GetShowingAppModalDialog) + IPC_MESSAGE_HANDLER(AutomationMsg_ClickAppModalDialogButton, + ClickAppModalDialogButton) + IPC_MESSAGE_HANDLER(AutomationMsg_SetStringPreference, SetStringPreference) + IPC_MESSAGE_HANDLER(AutomationMsg_GetBooleanPreference, + GetBooleanPreference) + IPC_MESSAGE_HANDLER(AutomationMsg_SetBooleanPreference, + SetBooleanPreference) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_WaitForBrowserWindowCountToBecome, + WaitForBrowserWindowCountToBecome) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_WaitForAppModalDialogToBeShown, + WaitForAppModalDialogToBeShown) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_GoBackBlockUntilNavigationsComplete, + GoBackBlockUntilNavigationsComplete) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_GoForwardBlockUntilNavigationsComplete, + GoForwardBlockUntilNavigationsComplete) + IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, + SavePackageShouldPromptUser) + IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) + IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) + IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, + SendJSONRequest) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, + WaitForTabCountToBecome) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, + WaitForInfoBarCount) + IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, + GetPageCurrentEncoding) + IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService, + ShutdownSessionService) + IPC_MESSAGE_HANDLER(AutomationMsg_SetContentSetting, SetContentSetting) + IPC_MESSAGE_HANDLER(AutomationMsg_LoadBlockedPlugins, LoadBlockedPlugins) + IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_WaitForProcessLauncherThreadToGoIdle, + WaitForProcessLauncherThreadToGoIdle) + IPC_MESSAGE_HANDLER(AutomationMsg_GetParentBrowserOfTab, + GetParentBrowserOfTab) + + IPC_MESSAGE_UNHANDLED( + handled = AutomationProvider::OnMessageReceived(message)) + IPC_END_MESSAGE_MAP_EX() + if (!deserialize_success) + OnMessageDeserializationFailure(); + return handled; +} +","@@ -4473,7 +4473,7 @@ void TestingAutomationProvider::GetExtensionsInfo( + extension_value->SetString(""public_key"", extension->public_key()); + extension_value->SetString(""description"", extension->description()); + extension_value->SetString(""background_url"", +- extension->background_url().spec()); ++ extension->GetBackgroundURL().spec()); + extension_value->SetString(""options_url"", + extension->options_url().spec()); + extension_value->Set(""host_permissions"",",2070,2306,4096 +3795,"sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, + const struct sctp_endpoint *ep, + const struct sctp_association *asoc, + const sctp_subtype_t type, void *arg, + sctp_cmd_seq_t *commands) +{ + struct sctp_chunk *chunk = arg; + struct sctp_association *new_asoc; + sctp_init_chunk_t *peer_init; + struct sctp_chunk *repl; + struct sctp_ulpevent *ev, *ai_ev = NULL; + int error = 0; + struct sctp_chunk *err_chk_p; + struct sock *sk; + + /* If the packet is an OOTB packet which is temporarily on the + * control endpoint, respond with an ABORT. + */ + if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { + SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + } + + /* Make sure that the COOKIE_ECHO chunk has a valid length. + * In this case, we check that we have enough for at least a + * chunk header. More detailed verification is done + * in sctp_unpack_cookie(). + */ + if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + /* If the endpoint is not listening or if the number of associations + * on the TCP-style socket exceed the max backlog, respond with an + * ABORT. + */ + sk = ep->base.sk; + if (!sctp_sstate(sk, LISTENING) || + (sctp_style(sk, TCP) && sk_acceptq_is_full(sk))) + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + + /* ""Decode"" the chunk. We have no optional parameters so we + * are in good shape. + */ + chunk->subh.cookie_hdr = + (struct sctp_signed_cookie *)chunk->skb->data; + if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - + sizeof(sctp_chunkhdr_t))) + goto nomem; + + /* 5.1 D) Upon reception of the COOKIE ECHO chunk, Endpoint + * ""Z"" will reply with a COOKIE ACK chunk after building a TCB + * and moving to the ESTABLISHED state. + */ + new_asoc = sctp_unpack_cookie(ep, asoc, chunk, GFP_ATOMIC, &error, + &err_chk_p); + + /* FIXME: + * If the re-build failed, what is the proper error path + * from here? + * + * [We should abort the association. --piggy] + */ + if (!new_asoc) { + /* FIXME: Several errors are possible. A bad cookie should + * be silently discarded, but think about logging it too. + */ + switch (error) { + case -SCTP_IERROR_NOMEM: + goto nomem; + + case -SCTP_IERROR_STALE_COOKIE: + sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, + err_chk_p); + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + case -SCTP_IERROR_BAD_SIG: + default: + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + } + } + + + /* Delay state machine commands until later. + * + * Re-build the bind address for the association is done in + * the sctp_unpack_cookie() already. + */ + /* This is a brand-new association, so these are not yet side + * effects--it is safe to run them here. + */ + peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; + + if (!sctp_process_init(new_asoc, chunk, + &chunk->subh.cookie_hdr->c.peer_addr, + peer_init, GFP_ATOMIC)) + goto nomem_init; + + /* SCTP-AUTH: Now that we've populate required fields in + * sctp_process_init, set up the assocaition shared keys as + * necessary so that we can potentially authenticate the ACK + */ + error = sctp_auth_asoc_init_active_key(new_asoc, GFP_ATOMIC); + if (error) + goto nomem_init; + + /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo + * is supposed to be authenticated and we have to do delayed + * authentication. We've just recreated the association using + * the information in the cookie and now it's much easier to + * do the authentication. + */ + if (chunk->auth_chunk) { + struct sctp_chunk auth; + sctp_ierror_t ret; + + /* Make sure that we and the peer are AUTH capable */ + if (!net->sctp.auth_enable || !new_asoc->peer.auth_capable) { + sctp_association_free(new_asoc); + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + } + + /* set-up our fake chunk so that we can process it */ + auth.skb = chunk->auth_chunk; + auth.asoc = chunk->asoc; + auth.sctp_hdr = chunk->sctp_hdr; + auth.chunk_hdr = (sctp_chunkhdr_t *)skb_push(chunk->auth_chunk, + sizeof(sctp_chunkhdr_t)); + skb_pull(chunk->auth_chunk, sizeof(sctp_chunkhdr_t)); + auth.transport = chunk->transport; + + ret = sctp_sf_authenticate(net, ep, new_asoc, type, &auth); + if (ret != SCTP_IERROR_NO_ERROR) { + sctp_association_free(new_asoc); + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + } + } + + repl = sctp_make_cookie_ack(new_asoc, chunk); + if (!repl) + goto nomem_init; + + /* RFC 2960 5.1 Normal Establishment of an Association + * + * D) IMPLEMENTATION NOTE: An implementation may choose to + * send the Communication Up notification to the SCTP user + * upon reception of a valid COOKIE ECHO chunk. + */ + ev = sctp_ulpevent_make_assoc_change(new_asoc, 0, SCTP_COMM_UP, 0, + new_asoc->c.sinit_num_ostreams, + new_asoc->c.sinit_max_instreams, + NULL, GFP_ATOMIC); + if (!ev) + goto nomem_ev; + + /* Sockets API Draft Section 5.3.1.6 + * When a peer sends a Adaptation Layer Indication parameter , SCTP + * delivers this notification to inform the application that of the + * peers requested adaptation layer. + */ + if (new_asoc->peer.adaptation_ind) { + ai_ev = sctp_ulpevent_make_adaptation_indication(new_asoc, + GFP_ATOMIC); + if (!ai_ev) + goto nomem_aiev; + } + + /* Add all the state machine commands now since we've created + * everything. This way we don't introduce memory corruptions + * during side-effect processing and correclty count established + * associations. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, + SCTP_STATE(SCTP_STATE_ESTABLISHED)); + SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); + SCTP_INC_STATS(net, SCTP_MIB_PASSIVEESTABS); + sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); + + if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, + SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); + + /* This will send the COOKIE ACK */ + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); + + /* Queue the ASSOC_CHANGE event */ + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); + + /* Send up the Adaptation Layer Indication event */ + if (ai_ev) + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, + SCTP_ULPEVENT(ai_ev)); + + return SCTP_DISPOSITION_CONSUME; + +nomem_aiev: + sctp_ulpevent_free(ev); +nomem_ev: + sctp_chunk_free(repl); +nomem_init: + sctp_association_free(new_asoc); +nomem: + return SCTP_DISPOSITION_NOMEM; +} +",0,"sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, + const struct sctp_endpoint *ep, + const struct sctp_association *asoc, + const sctp_subtype_t type, void *arg, + sctp_cmd_seq_t *commands) +{ + struct sctp_chunk *chunk = arg; + struct sctp_association *new_asoc; + sctp_init_chunk_t *peer_init; + struct sctp_chunk *repl; + struct sctp_ulpevent *ev, *ai_ev = NULL; + int error = 0; + struct sctp_chunk *err_chk_p; + struct sock *sk; + + /* If the packet is an OOTB packet which is temporarily on the + * control endpoint, respond with an ABORT. + */ + if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { + SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + } + + /* Make sure that the COOKIE_ECHO chunk has a valid length. + * In this case, we check that we have enough for at least a + * chunk header. More detailed verification is done + * in sctp_unpack_cookie(). + */ + if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + /* If the endpoint is not listening or if the number of associations + * on the TCP-style socket exceed the max backlog, respond with an + * ABORT. + */ + sk = ep->base.sk; + if (!sctp_sstate(sk, LISTENING) || + (sctp_style(sk, TCP) && sk_acceptq_is_full(sk))) + return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); + + /* ""Decode"" the chunk. We have no optional parameters so we + * are in good shape. + */ + chunk->subh.cookie_hdr = + (struct sctp_signed_cookie *)chunk->skb->data; + if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - + sizeof(sctp_chunkhdr_t))) + goto nomem; + + /* 5.1 D) Upon reception of the COOKIE ECHO chunk, Endpoint + * ""Z"" will reply with a COOKIE ACK chunk after building a TCB + * and moving to the ESTABLISHED state. + */ + new_asoc = sctp_unpack_cookie(ep, asoc, chunk, GFP_ATOMIC, &error, + &err_chk_p); + + /* FIXME: + * If the re-build failed, what is the proper error path + * from here? + * + * [We should abort the association. --piggy] + */ + if (!new_asoc) { + /* FIXME: Several errors are possible. A bad cookie should + * be silently discarded, but think about logging it too. + */ + switch (error) { + case -SCTP_IERROR_NOMEM: + goto nomem; + + case -SCTP_IERROR_STALE_COOKIE: + sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, + err_chk_p); + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + + case -SCTP_IERROR_BAD_SIG: + default: + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + } + } + + + /* Delay state machine commands until later. + * + * Re-build the bind address for the association is done in + * the sctp_unpack_cookie() already. + */ + /* This is a brand-new association, so these are not yet side + * effects--it is safe to run them here. + */ + peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; + + if (!sctp_process_init(new_asoc, chunk, + &chunk->subh.cookie_hdr->c.peer_addr, + peer_init, GFP_ATOMIC)) + goto nomem_init; + + /* SCTP-AUTH: Now that we've populate required fields in + * sctp_process_init, set up the assocaition shared keys as + * necessary so that we can potentially authenticate the ACK + */ + error = sctp_auth_asoc_init_active_key(new_asoc, GFP_ATOMIC); + if (error) + goto nomem_init; + + /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo + * is supposed to be authenticated and we have to do delayed + * authentication. We've just recreated the association using + * the information in the cookie and now it's much easier to + * do the authentication. + */ + if (chunk->auth_chunk) { + struct sctp_chunk auth; + sctp_ierror_t ret; + + /* Make sure that we and the peer are AUTH capable */ + if (!net->sctp.auth_enable || !new_asoc->peer.auth_capable) { + sctp_association_free(new_asoc); + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + } + + /* set-up our fake chunk so that we can process it */ + auth.skb = chunk->auth_chunk; + auth.asoc = chunk->asoc; + auth.sctp_hdr = chunk->sctp_hdr; + auth.chunk_hdr = (sctp_chunkhdr_t *)skb_push(chunk->auth_chunk, + sizeof(sctp_chunkhdr_t)); + skb_pull(chunk->auth_chunk, sizeof(sctp_chunkhdr_t)); + auth.transport = chunk->transport; + + ret = sctp_sf_authenticate(net, ep, new_asoc, type, &auth); + if (ret != SCTP_IERROR_NO_ERROR) { + sctp_association_free(new_asoc); + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); + } + } + + repl = sctp_make_cookie_ack(new_asoc, chunk); + if (!repl) + goto nomem_init; + + /* RFC 2960 5.1 Normal Establishment of an Association + * + * D) IMPLEMENTATION NOTE: An implementation may choose to + * send the Communication Up notification to the SCTP user + * upon reception of a valid COOKIE ECHO chunk. + */ + ev = sctp_ulpevent_make_assoc_change(new_asoc, 0, SCTP_COMM_UP, 0, + new_asoc->c.sinit_num_ostreams, + new_asoc->c.sinit_max_instreams, + NULL, GFP_ATOMIC); + if (!ev) + goto nomem_ev; + + /* Sockets API Draft Section 5.3.1.6 + * When a peer sends a Adaptation Layer Indication parameter , SCTP + * delivers this notification to inform the application that of the + * peers requested adaptation layer. + */ + if (new_asoc->peer.adaptation_ind) { + ai_ev = sctp_ulpevent_make_adaptation_indication(new_asoc, + GFP_ATOMIC); + if (!ai_ev) + goto nomem_aiev; + } + + /* Add all the state machine commands now since we've created + * everything. This way we don't introduce memory corruptions + * during side-effect processing and correclty count established + * associations. + */ + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); + sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, + SCTP_STATE(SCTP_STATE_ESTABLISHED)); + SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); + SCTP_INC_STATS(net, SCTP_MIB_PASSIVEESTABS); + sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); + + if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, + SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); + + /* This will send the COOKIE ACK */ + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); + + /* Queue the ASSOC_CHANGE event */ + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); + + /* Send up the Adaptation Layer Indication event */ + if (ai_ev) + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, + SCTP_ULPEVENT(ai_ev)); + + return SCTP_DISPOSITION_CONSUME; + +nomem_aiev: + sctp_ulpevent_free(ev); +nomem_ev: + sctp_chunk_free(repl); +nomem_init: + sctp_association_free(new_asoc); +nomem: + return SCTP_DISPOSITION_NOMEM; +} +","@@ -170,6 +170,9 @@ sctp_chunk_length_valid(struct sctp_chunk *chunk, + { + __u16 chunk_length = ntohs(chunk->chunk_hdr->length); + ++ /* Previously already marked? */ ++ if (unlikely(chunk->pdiscard)) ++ return 0; + if (unlikely(chunk_length < required_length)) + return 0; + ",1905,2141,4096 +18176,"void ZLIB_INTERNAL inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + z_const unsigned char FAR *in; /* local strm->next_in */ + z_const unsigned char FAR *last; /* have enough input while in < last */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ +#ifdef INFLATE_STRICT + unsigned dmax; /* maximum distance from zlib header */ +#endif + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code here; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in - OFF; + last = in + (strm->avail_in - 5); + out = strm->next_out - OFF; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); + #ifdef INFLATE_STRICT + dmax = state->dmax; +#endif + wsize = state->wsize; + whave = state->whave; + wnext = state->wnext; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op == 0) { /* literal */ + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + ""inflate: literal '%c'\n"" : + ""inflate: literal 0x%02x\n"", here.val)); + PUP(out) = (unsigned char)(here.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, ""inflate: length %u\n"", len)); + if (bits < 15) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); +#ifdef INFLATE_STRICT + if (dist > dmax) { + strm->msg = (char *)""invalid distance too far back""; + state->mode = BAD; + break; + } +#endif + hold >>= op; + bits -= op; + Tracevv((stderr, ""inflate: distance %u\n"", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + if (state->sane) { + strm->msg = + (char *)""invalid distance too far back""; + state->mode = BAD; + break; + } + #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (len <= op - whave) { + do { + PUP(out) = 0; + } while (--len); + continue; + } + len -= op - whave; + do { + PUP(out) = 0; + } while (--op > whave); + if (op == 0) { + from = out - dist; + do { + PUP(out) = PUP(from); + } while (--len); + continue; + } + #endif + } + from = window - OFF; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = window - OFF; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + PUP(out) = PUP(from); + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } while (len > 2); + if (len) { + PUP(out) = PUP(from); + if (len > 1) + PUP(out) = PUP(from); + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + here = dcode[here.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)""invalid distance code""; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + here = lcode[here.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, ""inflate: end of block\n"")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)""invalid literal/length code""; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in + OFF; + strm->next_out = out + OFF; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} +",1,"void ZLIB_INTERNAL inflate_fast(strm, start) +z_streamp strm; +unsigned start; /* inflate()'s starting value for strm->avail_out */ +{ + struct inflate_state FAR *state; + z_const unsigned char FAR *in; /* local strm->next_in */ + z_const unsigned char FAR *last; /* have enough input while in < last */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ +#ifdef INFLATE_STRICT + unsigned dmax; /* maximum distance from zlib header */ +#endif + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code here; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char FAR *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + in = strm->next_in; + last = in + (strm->avail_in - 5); + out = strm->next_out; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); + #ifdef INFLATE_STRICT + dmax = state->dmax; +#endif + wsize = state->wsize; + whave = state->whave; + wnext = state->wnext; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op == 0) { /* literal */ + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + ""inflate: literal '%c'\n"" : + ""inflate: literal 0x%02x\n"", here.val)); + *out++ = (unsigned char)(here.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + Tracevv((stderr, ""inflate: length %u\n"", len)); + if (bits < 15) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + op = (unsigned)(here.bits); + hold >>= op; + bits -= op; + op = (unsigned)(here.op); + if (op & 16) { /* distance base */ + dist = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + if (bits < op) { + hold += (unsigned long)(*in++) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); +#ifdef INFLATE_STRICT + if (dist > dmax) { + strm->msg = (char *)""invalid distance too far back""; + state->mode = BAD; + break; + } +#endif + hold >>= op; + bits -= op; + Tracevv((stderr, ""inflate: distance %u\n"", dist)); + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + if (state->sane) { + strm->msg = + (char *)""invalid distance too far back""; + state->mode = BAD; + break; + } + #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (len <= op - whave) { + do { + *out++ = 0; + } while (--len); + continue; + } + len -= op - whave; + do { + *out++ = 0; + } while (--op > whave); + if (op == 0) { + from = out - dist; + do { + *out++ = *from++; + } while (--len); + continue; + } + #endif + } + from = window; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = window; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + } + else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; + len -= 3; + } + if (len) { + *out++ = *from++; + if (len > 1) + *out++ = *from++; + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; + len -= 3; + } while (len > 2); + if (len) { + *out++ = *from++; + if (len > 1) + *out++ = *from++; + } + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ + here = dcode[here.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else { + strm->msg = (char *)""invalid distance code""; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) { /* 2nd level length code */ + here = lcode[here.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) { /* end-of-block */ + Tracevv((stderr, ""inflate: end of block\n"")); + state->mode = TYPE; + break; + } + else { + strm->msg = (char *)""invalid literal/length code""; + state->mode = BAD; + break; + } + } while (in < last && out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + /* update state and return */ + strm->next_in = in; + strm->next_out = out; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; +} +","@@ -10,25 +10,6 @@ + + #ifndef ASMINF + +-/* Allow machine dependent optimization for post-increment or pre-increment. +- Based on testing to date, +- Pre-increment preferred for: +- - PowerPC G3 (Adler) +- - MIPS R5000 (Randers-Pehrson) +- Post-increment preferred for: +- - none +- No measurable difference: +- - Pentium III (Anderson) +- - M68060 (Nikl) +- */ +-#ifdef POSTINC +-# define OFF 0 +-# define PUP(a) *(a)++ +-#else +-# define OFF 1 +-# define PUP(a) *++(a) +-#endif +- + /* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is +@@ -96,9 +77,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; +- in = strm->next_in - OFF; ++ in = strm->next_in; + last = in + (strm->avail_in - 5); +- out = strm->next_out - OFF; ++ out = strm->next_out; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); + #ifdef INFLATE_STRICT +@@ -119,9 +100,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + input data or output space */ + do { + if (bits < 15) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + here = lcode[hold & lmask]; +@@ -134,14 +115,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + ""inflate: literal '%c'\n"" : + ""inflate: literal 0x%02x\n"", here.val)); +- PUP(out) = (unsigned char)(here.val); ++ *out++ = (unsigned char)(here.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); +@@ -150,9 +131,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + } + Tracevv((stderr, ""inflate: length %u\n"", len)); + if (bits < 15) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + here = dcode[hold & dmask]; +@@ -165,10 +146,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + dist = (unsigned)(here.val); + op &= 15; /* number of extra bits */ + if (bits < op) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + if (bits < op) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + } +@@ -196,30 +177,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + if (len <= op - whave) { + do { +- PUP(out) = 0; ++ *out++ = 0; + } while (--len); + continue; + } + len -= op - whave; + do { +- PUP(out) = 0; ++ *out++ = 0; + } while (--op > whave); + if (op == 0) { + from = out - dist; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--len); + continue; + } + #endif + } +- from = window - OFF; ++ from = window; + if (wnext == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } +@@ -230,14 +211,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + if (op < len) { /* some from end of window */ + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); +- from = window - OFF; ++ from = window; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } +@@ -248,35 +229,35 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + if (op < len) { /* some from window */ + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { +- PUP(out) = PUP(from); +- PUP(out) = PUP(from); +- PUP(out) = PUP(from); ++ *out++ = *from++; ++ *out++ = *from++; ++ *out++ = *from++; + len -= 3; + } + if (len) { +- PUP(out) = PUP(from); ++ *out++ = *from++; + if (len > 1) +- PUP(out) = PUP(from); ++ *out++ = *from++; + } + } + else { + from = out - dist; /* copy direct from output */ + do { /* minimum length is three */ +- PUP(out) = PUP(from); +- PUP(out) = PUP(from); +- PUP(out) = PUP(from); ++ *out++ = *from++; ++ *out++ = *from++; ++ *out++ = *from++; + len -= 3; + } while (len > 2); + if (len) { +- PUP(out) = PUP(from); ++ *out++ = *from++; + if (len > 1) +- PUP(out) = PUP(from); ++ *out++ = *from++; + } + } + } +@@ -313,8 +294,8 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ + hold &= (1U << bits) - 1; + + /* update state and return */ +- strm->next_in = in + OFF; +- strm->next_out = out + OFF; ++ strm->next_in = in; ++ strm->next_out = out; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end));",2287,2523,4096 +6109,"activate_files (ActivateParameters *parameters) +{ + NautilusFile *file; + NautilusWindow *window; + NautilusWindowOpenFlags flags; + g_autoptr (GList) open_in_app_parameters = NULL; + g_autoptr (GList) unhandled_open_in_app_uris = NULL; + ApplicationLaunchParameters *one_parameters; + int count; + g_autofree char *old_working_dir = NULL; + GdkScreen *screen; + gint num_apps; + gint num_unhandled; + gint num_files; + gboolean open_files; + gboolean closed_window; + g_autoptr (GQueue) launch_desktop_files = NULL; + g_autoptr (GQueue) launch_files = NULL; + g_autoptr (GQueue) launch_in_terminal_files = NULL; + g_autoptr (GQueue) open_in_app_uris = NULL; + g_autoptr (GQueue) open_in_view_files = NULL; + GList *l; + ActivationAction action; + LaunchLocation *location; + + launch_desktop_files = g_queue_new (); + launch_files = g_queue_new (); + launch_in_terminal_files = g_queue_new (); + open_in_view_files = g_queue_new (); + open_in_app_uris = g_queue_new (); + + for (l = parameters->locations; l != NULL; l = l->next) + { + location = l->data; + file = location->file; + + if (file_was_cancelled (file)) + { + continue; + } + + action = get_activation_action (file); + if (action == ACTIVATION_ACTION_ASK) + { + /* Special case for executable text files, since it might be + * dangerous & unexpected to launch these. + */ + pause_activation_timed_cancel (parameters); + action = get_executable_text_file_action (parameters->parent_window, file); + unpause_activation_timed_cancel (parameters); + } + + switch (action) + { + case ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE: + { + g_queue_push_tail (launch_desktop_files, file); + } + break; + + case ACTIVATION_ACTION_LAUNCH: + { + g_queue_push_tail (launch_files, file); + } + break; + + case ACTIVATION_ACTION_LAUNCH_IN_TERMINAL: + { + g_queue_push_tail (launch_in_terminal_files, file); + } + break; + + case ACTIVATION_ACTION_OPEN_IN_VIEW: + { + g_queue_push_tail (open_in_view_files, file); + } + break; + + case ACTIVATION_ACTION_OPEN_IN_APPLICATION: + { + g_queue_push_tail (open_in_app_uris, location->uri); + } + break; + + case ACTIVATION_ACTION_DO_NOTHING: + { + } + break; + + case ACTIVATION_ACTION_EXTRACT: + { + /* Extraction of files should be handled in the view */ + g_assert_not_reached (); + } + break; + + case ACTIVATION_ACTION_ASK: + { + g_assert_not_reached (); + } + break; + } + } + + for (l = g_queue_peek_head_link (launch_desktop_files); l != NULL; l = l->next) + { + file = NAUTILUS_FILE (l->data); + + activate_desktop_file (parameters, file); + } + + if (parameters->activation_directory && + (!g_queue_is_empty (launch_files) || + !g_queue_is_empty (launch_in_terminal_files))) + { + old_working_dir = g_get_current_dir (); + g_chdir (parameters->activation_directory); + } + + screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window)); + for (l = g_queue_peek_head_link (launch_files); l != NULL; l = l->next) + { + g_autofree char *uri = NULL; + g_autofree char *executable_path = NULL; + g_autofree char *quoted_path = NULL; + + file = NAUTILUS_FILE (l->data); + + uri = nautilus_file_get_activation_uri (file); + executable_path = g_filename_from_uri (uri, NULL, NULL); + quoted_path = g_shell_quote (executable_path); + + DEBUG (""Launching file path %s"", quoted_path); + + nautilus_launch_application_from_command (screen, quoted_path, FALSE, NULL); + } + + for (l = g_queue_peek_head_link (launch_in_terminal_files); l != NULL; l = l->next) + { + g_autofree char *uri = NULL; + g_autofree char *executable_path = NULL; + g_autofree char *quoted_path = NULL; + + file = NAUTILUS_FILE (l->data); + + uri = nautilus_file_get_activation_uri (file); + executable_path = g_filename_from_uri (uri, NULL, NULL); + quoted_path = g_shell_quote (executable_path); + + DEBUG (""Launching in terminal file quoted path %s"", quoted_path); + + nautilus_launch_application_from_command (screen, quoted_path, TRUE, NULL); + } + + if (old_working_dir != NULL) + { + g_chdir (old_working_dir); + } + + count = g_queue_get_length (open_in_view_files); + + flags = parameters->flags; + if (count > 1) + { + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) + { + /* if CLOSE_BEHIND is set and we have a directory to be activated, we + * will first have to open a new window and after that we can open the + * rest of files in tabs */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + else + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; + } + } + else + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + } + else + { + /* if we want to close the window and activate a single directory, then we will need + * the NEW_WINDOW flag set */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + } + + if (parameters->slot != NULL && + (!parameters->user_confirmation || + confirm_multiple_windows (parameters->parent_window, count, + (flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0))) + { + if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0 && + g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_NEW_TAB_POSITION) == + NAUTILUS_NEW_TAB_POSITION_AFTER_CURRENT_TAB) + { + /* When inserting N tabs after the current one, + * we first open tab N, then tab N-1, ..., then tab 0. + * Each of them is appended to the current tab, i.e. + * prepended to the list of tabs to open. + */ + g_queue_reverse (open_in_view_files); + } + + closed_window = FALSE; + + for (l = g_queue_peek_head_link (open_in_view_files); l != NULL; l = l->next) + { + g_autofree char *uri = NULL; + g_autoptr (GFile) location = NULL; + g_autoptr (GFile) location_with_permissions = NULL; + /* The ui should ask for navigation or object windows + * depending on what the current one is */ + file = NAUTILUS_FILE (l->data); + uri = nautilus_file_get_activation_uri (file); + location = g_file_new_for_uri (uri); + if (g_file_is_native (location) && + (nautilus_file_is_in_admin (file) || + !nautilus_file_can_read (file) || + !nautilus_file_can_execute (file))) + { + g_autofree gchar *file_path = NULL; + + g_free (uri); + + file_path = g_file_get_path (location); + uri = g_strconcat (""admin://"", file_path, NULL); + } + + location_with_permissions = g_file_new_for_uri (uri); + /* FIXME: we need to pass the parent_window, but we only use it for the current active window, + * which nautilus-application should take care of. However is not working and creating regressions + * in some cases. Until we figure out what's going on, continue to use the parameters->slot + * to make splicit the window we want to use for activating the files */ + nautilus_application_open_location_full (NAUTILUS_APPLICATION (g_application_get_default ()), + location_with_permissions, flags, NULL, NULL, parameters->slot); + + /* close only the window from which the action was launched and then open + * tabs/windows (depending on parameters->flags) */ + if (!closed_window && (flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags &= (~NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND); + + /* if NEW_WINDOW is set, we want all files in new windows, not in tabs */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) + { + flags &= (~NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW); + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; + } + + closed_window = TRUE; + } + } + } + + if (open_in_app_uris != NULL) + { + open_in_app_parameters = make_activation_parameters (g_queue_peek_head_link (open_in_app_uris), + &unhandled_open_in_app_uris); + } + + num_apps = g_list_length (open_in_app_parameters); + num_unhandled = g_list_length (unhandled_open_in_app_uris); + num_files = g_queue_get_length (open_in_app_uris); + open_files = TRUE; + + if (g_queue_is_empty (open_in_app_uris) && + (!parameters->user_confirmation || + num_files + num_unhandled > SILENT_OPEN_LIMIT) && + num_apps > 1) + { + GtkDialog *dialog; + char *prompt; + g_autofree char *detail = NULL; + int response; + + pause_activation_timed_cancel (parameters); + + prompt = _(""Are you sure you want to open all files?""); + detail = g_strdup_printf (ngettext (""This will open %d separate application."", + ""This will open %d separate applications."", num_apps), num_apps); + dialog = eel_show_yes_no_dialog (prompt, detail, + _(""_OK""), _(""_Cancel""), + parameters->parent_window); + response = gtk_dialog_run (dialog); + gtk_widget_destroy (GTK_WIDGET (dialog)); + + unpause_activation_timed_cancel (parameters); + + if (response != GTK_RESPONSE_YES) + { + open_files = FALSE; + } + } + + if (open_files) + { + for (l = open_in_app_parameters; l != NULL; l = l->next) + { + one_parameters = l->data; + + nautilus_launch_application_by_uri (one_parameters->application, + one_parameters->uris, + parameters->parent_window); + application_launch_parameters_free (one_parameters); + } + + for (l = unhandled_open_in_app_uris; l != NULL; l = l->next) + { + char *uri = l->data; + + /* this does not block */ + application_unhandled_uri (parameters, uri); + } + } + + window = NULL; + if (parameters->slot != NULL) + { + window = nautilus_window_slot_get_window (parameters->slot); + } + + if (open_in_app_parameters != NULL || + unhandled_open_in_app_uris != NULL) + { + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0 && + window != NULL) + { + nautilus_window_close (window); + } + } + + activation_parameters_free (parameters); +} +",0,"activate_files (ActivateParameters *parameters) +{ + NautilusFile *file; + NautilusWindow *window; + NautilusWindowOpenFlags flags; + g_autoptr (GList) open_in_app_parameters = NULL; + g_autoptr (GList) unhandled_open_in_app_uris = NULL; + ApplicationLaunchParameters *one_parameters; + int count; + g_autofree char *old_working_dir = NULL; + GdkScreen *screen; + gint num_apps; + gint num_unhandled; + gint num_files; + gboolean open_files; + gboolean closed_window; + g_autoptr (GQueue) launch_desktop_files = NULL; + g_autoptr (GQueue) launch_files = NULL; + g_autoptr (GQueue) launch_in_terminal_files = NULL; + g_autoptr (GQueue) open_in_app_uris = NULL; + g_autoptr (GQueue) open_in_view_files = NULL; + GList *l; + ActivationAction action; + LaunchLocation *location; + + launch_desktop_files = g_queue_new (); + launch_files = g_queue_new (); + launch_in_terminal_files = g_queue_new (); + open_in_view_files = g_queue_new (); + open_in_app_uris = g_queue_new (); + + for (l = parameters->locations; l != NULL; l = l->next) + { + location = l->data; + file = location->file; + + if (file_was_cancelled (file)) + { + continue; + } + + action = get_activation_action (file); + if (action == ACTIVATION_ACTION_ASK) + { + /* Special case for executable text files, since it might be + * dangerous & unexpected to launch these. + */ + pause_activation_timed_cancel (parameters); + action = get_executable_text_file_action (parameters->parent_window, file); + unpause_activation_timed_cancel (parameters); + } + + switch (action) + { + case ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE: + { + g_queue_push_tail (launch_desktop_files, file); + } + break; + + case ACTIVATION_ACTION_LAUNCH: + { + g_queue_push_tail (launch_files, file); + } + break; + + case ACTIVATION_ACTION_LAUNCH_IN_TERMINAL: + { + g_queue_push_tail (launch_in_terminal_files, file); + } + break; + + case ACTIVATION_ACTION_OPEN_IN_VIEW: + { + g_queue_push_tail (open_in_view_files, file); + } + break; + + case ACTIVATION_ACTION_OPEN_IN_APPLICATION: + { + g_queue_push_tail (open_in_app_uris, location->uri); + } + break; + + case ACTIVATION_ACTION_DO_NOTHING: + { + } + break; + + case ACTIVATION_ACTION_EXTRACT: + { + /* Extraction of files should be handled in the view */ + g_assert_not_reached (); + } + break; + + case ACTIVATION_ACTION_ASK: + { + g_assert_not_reached (); + } + break; + } + } + + for (l = g_queue_peek_head_link (launch_desktop_files); l != NULL; l = l->next) + { + file = NAUTILUS_FILE (l->data); + + activate_desktop_file (parameters, file); + } + + if (parameters->activation_directory && + (!g_queue_is_empty (launch_files) || + !g_queue_is_empty (launch_in_terminal_files))) + { + old_working_dir = g_get_current_dir (); + g_chdir (parameters->activation_directory); + } + + screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window)); + for (l = g_queue_peek_head_link (launch_files); l != NULL; l = l->next) + { + g_autofree char *uri = NULL; + g_autofree char *executable_path = NULL; + g_autofree char *quoted_path = NULL; + + file = NAUTILUS_FILE (l->data); + + uri = nautilus_file_get_activation_uri (file); + executable_path = g_filename_from_uri (uri, NULL, NULL); + quoted_path = g_shell_quote (executable_path); + + DEBUG (""Launching file path %s"", quoted_path); + + nautilus_launch_application_from_command (screen, quoted_path, FALSE, NULL); + } + + for (l = g_queue_peek_head_link (launch_in_terminal_files); l != NULL; l = l->next) + { + g_autofree char *uri = NULL; + g_autofree char *executable_path = NULL; + g_autofree char *quoted_path = NULL; + + file = NAUTILUS_FILE (l->data); + + uri = nautilus_file_get_activation_uri (file); + executable_path = g_filename_from_uri (uri, NULL, NULL); + quoted_path = g_shell_quote (executable_path); + + DEBUG (""Launching in terminal file quoted path %s"", quoted_path); + + nautilus_launch_application_from_command (screen, quoted_path, TRUE, NULL); + } + + if (old_working_dir != NULL) + { + g_chdir (old_working_dir); + } + + count = g_queue_get_length (open_in_view_files); + + flags = parameters->flags; + if (count > 1) + { + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) + { + /* if CLOSE_BEHIND is set and we have a directory to be activated, we + * will first have to open a new window and after that we can open the + * rest of files in tabs */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + else + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; + } + } + else + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + } + else + { + /* if we want to close the window and activate a single directory, then we will need + * the NEW_WINDOW flag set */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + } + + if (parameters->slot != NULL && + (!parameters->user_confirmation || + confirm_multiple_windows (parameters->parent_window, count, + (flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0))) + { + if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0 && + g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_NEW_TAB_POSITION) == + NAUTILUS_NEW_TAB_POSITION_AFTER_CURRENT_TAB) + { + /* When inserting N tabs after the current one, + * we first open tab N, then tab N-1, ..., then tab 0. + * Each of them is appended to the current tab, i.e. + * prepended to the list of tabs to open. + */ + g_queue_reverse (open_in_view_files); + } + + closed_window = FALSE; + + for (l = g_queue_peek_head_link (open_in_view_files); l != NULL; l = l->next) + { + g_autofree char *uri = NULL; + g_autoptr (GFile) location = NULL; + g_autoptr (GFile) location_with_permissions = NULL; + /* The ui should ask for navigation or object windows + * depending on what the current one is */ + file = NAUTILUS_FILE (l->data); + uri = nautilus_file_get_activation_uri (file); + location = g_file_new_for_uri (uri); + if (g_file_is_native (location) && + (nautilus_file_is_in_admin (file) || + !nautilus_file_can_read (file) || + !nautilus_file_can_execute (file))) + { + g_autofree gchar *file_path = NULL; + + g_free (uri); + + file_path = g_file_get_path (location); + uri = g_strconcat (""admin://"", file_path, NULL); + } + + location_with_permissions = g_file_new_for_uri (uri); + /* FIXME: we need to pass the parent_window, but we only use it for the current active window, + * which nautilus-application should take care of. However is not working and creating regressions + * in some cases. Until we figure out what's going on, continue to use the parameters->slot + * to make splicit the window we want to use for activating the files */ + nautilus_application_open_location_full (NAUTILUS_APPLICATION (g_application_get_default ()), + location_with_permissions, flags, NULL, NULL, parameters->slot); + + /* close only the window from which the action was launched and then open + * tabs/windows (depending on parameters->flags) */ + if (!closed_window && (flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) + { + flags &= (~NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND); + + /* if NEW_WINDOW is set, we want all files in new windows, not in tabs */ + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) + { + flags &= (~NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW); + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; + } + + closed_window = TRUE; + } + } + } + + if (open_in_app_uris != NULL) + { + open_in_app_parameters = make_activation_parameters (g_queue_peek_head_link (open_in_app_uris), + &unhandled_open_in_app_uris); + } + + num_apps = g_list_length (open_in_app_parameters); + num_unhandled = g_list_length (unhandled_open_in_app_uris); + num_files = g_queue_get_length (open_in_app_uris); + open_files = TRUE; + + if (g_queue_is_empty (open_in_app_uris) && + (!parameters->user_confirmation || + num_files + num_unhandled > SILENT_OPEN_LIMIT) && + num_apps > 1) + { + GtkDialog *dialog; + char *prompt; + g_autofree char *detail = NULL; + int response; + + pause_activation_timed_cancel (parameters); + + prompt = _(""Are you sure you want to open all files?""); + detail = g_strdup_printf (ngettext (""This will open %d separate application."", + ""This will open %d separate applications."", num_apps), num_apps); + dialog = eel_show_yes_no_dialog (prompt, detail, + _(""_OK""), _(""_Cancel""), + parameters->parent_window); + response = gtk_dialog_run (dialog); + gtk_widget_destroy (GTK_WIDGET (dialog)); + + unpause_activation_timed_cancel (parameters); + + if (response != GTK_RESPONSE_YES) + { + open_files = FALSE; + } + } + + if (open_files) + { + for (l = open_in_app_parameters; l != NULL; l = l->next) + { + one_parameters = l->data; + + nautilus_launch_application_by_uri (one_parameters->application, + one_parameters->uris, + parameters->parent_window); + application_launch_parameters_free (one_parameters); + } + + for (l = unhandled_open_in_app_uris; l != NULL; l = l->next) + { + char *uri = l->data; + + /* this does not block */ + application_unhandled_uri (parameters, uri); + } + } + + window = NULL; + if (parameters->slot != NULL) + { + window = nautilus_window_slot_get_window (parameters->slot); + } + + if (open_in_app_parameters != NULL || + unhandled_open_in_app_uris != NULL) + { + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0 && + window != NULL) + { + nautilus_window_close (window); + } + } + + activation_parameters_free (parameters); +} +","@@ -42,6 +42,7 @@ + #include ""nautilus-program-choosing.h"" + #include ""nautilus-global-preferences.h"" + #include ""nautilus-signaller.h"" ++#include ""nautilus-metadata.h"" + + #define DEBUG_FLAG NAUTILUS_DEBUG_MIME + #include ""nautilus-debug.h"" +@@ -221,7 +222,6 @@ struct + #define RESPONSE_RUN 1000 + #define RESPONSE_DISPLAY 1001 + #define RESPONSE_RUN_IN_TERMINAL 1002 +-#define RESPONSE_MARK_TRUSTED 1003 + + #define SILENT_WINDOW_OPEN_LIMIT 5 + #define SILENT_OPEN_LIMIT 5 +@@ -1517,24 +1517,35 @@ untrusted_launcher_response_callback (GtkDialog *dialog, + + switch (response_id) + { +- case RESPONSE_RUN: ++ case GTK_RESPONSE_OK: + { ++ file = nautilus_file_get_location (parameters->file); ++ ++ /* We need to do this in order to prevent malicious desktop files ++ * with the executable bit already set. ++ * See https://bugzilla.gnome.org/show_bug.cgi?id=777991 ++ */ ++ nautilus_file_set_metadata (parameters->file, NAUTILUS_METADATA_KEY_DESKTOP_FILE_TRUSTED, ++ NULL, ++ ""yes""); ++ ++ nautilus_file_mark_desktop_file_executable (file, ++ parameters->parent_window, ++ TRUE, ++ NULL, NULL); ++ ++ /* Need to force a reload of the attributes so is_trusted is marked ++ * correctly. Not sure why the general monitor doesn't fire in this ++ * case when setting the metadata ++ */ ++ nautilus_file_invalidate_all_attributes (parameters->file); ++ + screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window)); + uri = nautilus_file_get_uri (parameters->file); + DEBUG (""Launching untrusted launcher %s"", uri); + nautilus_launch_desktop_file (screen, uri, NULL, + parameters->parent_window); + g_free (uri); +- } +- break; +- +- case RESPONSE_MARK_TRUSTED: +- { +- file = nautilus_file_get_location (parameters->file); +- nautilus_file_mark_desktop_file_trusted (file, +- parameters->parent_window, +- TRUE, +- NULL, NULL); + g_object_unref (file); + } + break; +@@ -1590,17 +1601,16 @@ activate_desktop_file (ActivateParameters *parameters, + ""text"", primary, + ""secondary-text"", secondary, + NULL); ++ + gtk_dialog_add_button (GTK_DIALOG (dialog), +- _(""_Launch Anyway""), RESPONSE_RUN); ++ _(""_Cancel""), GTK_RESPONSE_CANCEL); ++ ++ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); + if (nautilus_file_can_set_permissions (file)) + { + gtk_dialog_add_button (GTK_DIALOG (dialog), +- _(""Mark as _Trusted""), RESPONSE_MARK_TRUSTED); ++ _(""Trust and _Launch""), GTK_RESPONSE_OK); + } +- gtk_dialog_add_button (GTK_DIALOG (dialog), +- _(""_Cancel""), GTK_RESPONSE_CANCEL); +- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); +- + g_signal_connect (dialog, ""response"", + G_CALLBACK (untrusted_launcher_response_callback), + parameters_desktop);",2548,2784,4096 +18030,"static ssize_t hfi1_file_write(struct file *fp, const char __user *data, + size_t count, loff_t *offset) +{ + const struct hfi1_cmd __user *ucmd; + struct hfi1_filedata *fd = fp->private_data; + struct hfi1_ctxtdata *uctxt = fd->uctxt; + struct hfi1_cmd cmd; + struct hfi1_user_info uinfo; + struct hfi1_tid_info tinfo; + unsigned long addr; + ssize_t consumed = 0, copy = 0, ret = 0; + void *dest = NULL; + __u64 user_val = 0; + int uctxt_required = 1; + int must_be_root = 0; + + if (count < sizeof(cmd)) { + ret = -EINVAL; + goto bail; + } + + ucmd = (const struct hfi1_cmd __user *)data; + if (copy_from_user(&cmd, ucmd, sizeof(cmd))) { + ret = -EFAULT; + goto bail; + } + + consumed = sizeof(cmd); + + switch (cmd.type) { + case HFI1_CMD_ASSIGN_CTXT: + uctxt_required = 0; /* assigned user context not required */ + copy = sizeof(uinfo); + dest = &uinfo; + break; + case HFI1_CMD_SDMA_STATUS_UPD: + case HFI1_CMD_CREDIT_UPD: + copy = 0; + break; + case HFI1_CMD_TID_UPDATE: + case HFI1_CMD_TID_FREE: + case HFI1_CMD_TID_INVAL_READ: + copy = sizeof(tinfo); + dest = &tinfo; + break; + case HFI1_CMD_USER_INFO: + case HFI1_CMD_RECV_CTRL: + case HFI1_CMD_POLL_TYPE: + case HFI1_CMD_ACK_EVENT: + case HFI1_CMD_CTXT_INFO: + case HFI1_CMD_SET_PKEY: + case HFI1_CMD_CTXT_RESET: + copy = 0; + user_val = cmd.addr; + break; + case HFI1_CMD_EP_INFO: + case HFI1_CMD_EP_ERASE_CHIP: + case HFI1_CMD_EP_ERASE_RANGE: + case HFI1_CMD_EP_READ_RANGE: + case HFI1_CMD_EP_WRITE_RANGE: + uctxt_required = 0; /* assigned user context not required */ + must_be_root = 1; /* validate user */ + copy = 0; + break; + default: + ret = -EINVAL; + goto bail; + } + + /* If the command comes with user data, copy it. */ + if (copy) { + if (copy_from_user(dest, (void __user *)cmd.addr, copy)) { + ret = -EFAULT; + goto bail; + } + consumed += copy; + } + + /* + * Make sure there is a uctxt when needed. + */ + if (uctxt_required && !uctxt) { + ret = -EINVAL; + goto bail; + } + + /* only root can do these operations */ + if (must_be_root && !capable(CAP_SYS_ADMIN)) { + ret = -EPERM; + goto bail; + } + + switch (cmd.type) { + case HFI1_CMD_ASSIGN_CTXT: + ret = assign_ctxt(fp, &uinfo); + if (ret < 0) + goto bail; + ret = setup_ctxt(fp); + if (ret) + goto bail; + ret = user_init(fp); + break; + case HFI1_CMD_CTXT_INFO: + ret = get_ctxt_info(fp, (void __user *)(unsigned long) + user_val, cmd.len); + break; + case HFI1_CMD_USER_INFO: + ret = get_base_info(fp, (void __user *)(unsigned long) + user_val, cmd.len); + break; + case HFI1_CMD_SDMA_STATUS_UPD: + break; + case HFI1_CMD_CREDIT_UPD: + if (uctxt && uctxt->sc) + sc_return_credits(uctxt->sc); + break; + case HFI1_CMD_TID_UPDATE: + ret = hfi1_user_exp_rcv_setup(fp, &tinfo); + if (!ret) { + /* + * Copy the number of tidlist entries we used + * and the length of the buffer we registered. + * These fields are adjacent in the structure so + * we can copy them at the same time. + */ + addr = (unsigned long)cmd.addr + + offsetof(struct hfi1_tid_info, tidcnt); + if (copy_to_user((void __user *)addr, &tinfo.tidcnt, + sizeof(tinfo.tidcnt) + + sizeof(tinfo.length))) + ret = -EFAULT; + } + break; + case HFI1_CMD_TID_INVAL_READ: + ret = hfi1_user_exp_rcv_invalid(fp, &tinfo); + if (ret) + break; + addr = (unsigned long)cmd.addr + + offsetof(struct hfi1_tid_info, tidcnt); + if (copy_to_user((void __user *)addr, &tinfo.tidcnt, + sizeof(tinfo.tidcnt))) + ret = -EFAULT; + break; + case HFI1_CMD_TID_FREE: + ret = hfi1_user_exp_rcv_clear(fp, &tinfo); + if (ret) + break; + addr = (unsigned long)cmd.addr + + offsetof(struct hfi1_tid_info, tidcnt); + if (copy_to_user((void __user *)addr, &tinfo.tidcnt, + sizeof(tinfo.tidcnt))) + ret = -EFAULT; + break; + case HFI1_CMD_RECV_CTRL: + ret = manage_rcvq(uctxt, fd->subctxt, (int)user_val); + break; + case HFI1_CMD_POLL_TYPE: + uctxt->poll_type = (typeof(uctxt->poll_type))user_val; + break; + case HFI1_CMD_ACK_EVENT: + ret = user_event_ack(uctxt, fd->subctxt, user_val); + break; + case HFI1_CMD_SET_PKEY: + if (HFI1_CAP_IS_USET(PKEY_CHECK)) + ret = set_ctxt_pkey(uctxt, fd->subctxt, user_val); + else + ret = -EPERM; + break; + case HFI1_CMD_CTXT_RESET: { + struct send_context *sc; + struct hfi1_devdata *dd; + + if (!uctxt || !uctxt->dd || !uctxt->sc) { + ret = -EINVAL; + break; + } + /* + * There is no protection here. User level has to + * guarantee that no one will be writing to the send + * context while it is being re-initialized. + * If user level breaks that guarantee, it will break + * it's own context and no one else's. + */ + dd = uctxt->dd; + sc = uctxt->sc; + /* + * Wait until the interrupt handler has marked the + * context as halted or frozen. Report error if we time + * out. + */ + wait_event_interruptible_timeout( + sc->halt_wait, (sc->flags & SCF_HALTED), + msecs_to_jiffies(SEND_CTXT_HALT_TIMEOUT)); + if (!(sc->flags & SCF_HALTED)) { + ret = -ENOLCK; + break; + } + /* + * If the send context was halted due to a Freeze, + * wait until the device has been ""unfrozen"" before + * resetting the context. + */ + if (sc->flags & SCF_FROZEN) { + wait_event_interruptible_timeout( + dd->event_queue, + !(ACCESS_ONCE(dd->flags) & HFI1_FROZEN), + msecs_to_jiffies(SEND_CTXT_HALT_TIMEOUT)); + if (dd->flags & HFI1_FROZEN) { + ret = -ENOLCK; + break; + } + if (dd->flags & HFI1_FORCED_FREEZE) { + /* + * Don't allow context reset if we are into + * forced freeze + */ + ret = -ENODEV; + break; + } + sc_disable(sc); + ret = sc_enable(sc); + hfi1_rcvctrl(dd, HFI1_RCVCTRL_CTXT_ENB, + uctxt->ctxt); + } else { + ret = sc_restart(sc); + } + if (!ret) + sc_return_credits(sc); + break; + } + case HFI1_CMD_EP_INFO: + case HFI1_CMD_EP_ERASE_CHIP: + case HFI1_CMD_EP_ERASE_RANGE: + case HFI1_CMD_EP_READ_RANGE: + case HFI1_CMD_EP_WRITE_RANGE: + ret = handle_eprom_command(fp, &cmd); + break; + } + + if (ret >= 0) + ret = consumed; +bail: + return ret; +} +",1,"static ssize_t hfi1_file_write(struct file *fp, const char __user *data, + size_t count, loff_t *offset) +{ + const struct hfi1_cmd __user *ucmd; + struct hfi1_filedata *fd = fp->private_data; + struct hfi1_ctxtdata *uctxt = fd->uctxt; + struct hfi1_cmd cmd; + struct hfi1_user_info uinfo; + struct hfi1_tid_info tinfo; + unsigned long addr; + ssize_t consumed = 0, copy = 0, ret = 0; + void *dest = NULL; + __u64 user_val = 0; + int uctxt_required = 1; + int must_be_root = 0; + + /* FIXME: This interface cannot continue out of staging */ + if (WARN_ON_ONCE(!ib_safe_file_access(fp))) + return -EACCES; + + if (count < sizeof(cmd)) { + ret = -EINVAL; + goto bail; + } + + ucmd = (const struct hfi1_cmd __user *)data; + if (copy_from_user(&cmd, ucmd, sizeof(cmd))) { + ret = -EFAULT; + goto bail; + } + + consumed = sizeof(cmd); + + switch (cmd.type) { + case HFI1_CMD_ASSIGN_CTXT: + uctxt_required = 0; /* assigned user context not required */ + copy = sizeof(uinfo); + dest = &uinfo; + break; + case HFI1_CMD_SDMA_STATUS_UPD: + case HFI1_CMD_CREDIT_UPD: + copy = 0; + break; + case HFI1_CMD_TID_UPDATE: + case HFI1_CMD_TID_FREE: + case HFI1_CMD_TID_INVAL_READ: + copy = sizeof(tinfo); + dest = &tinfo; + break; + case HFI1_CMD_USER_INFO: + case HFI1_CMD_RECV_CTRL: + case HFI1_CMD_POLL_TYPE: + case HFI1_CMD_ACK_EVENT: + case HFI1_CMD_CTXT_INFO: + case HFI1_CMD_SET_PKEY: + case HFI1_CMD_CTXT_RESET: + copy = 0; + user_val = cmd.addr; + break; + case HFI1_CMD_EP_INFO: + case HFI1_CMD_EP_ERASE_CHIP: + case HFI1_CMD_EP_ERASE_RANGE: + case HFI1_CMD_EP_READ_RANGE: + case HFI1_CMD_EP_WRITE_RANGE: + uctxt_required = 0; /* assigned user context not required */ + must_be_root = 1; /* validate user */ + copy = 0; + break; + default: + ret = -EINVAL; + goto bail; + } + + /* If the command comes with user data, copy it. */ + if (copy) { + if (copy_from_user(dest, (void __user *)cmd.addr, copy)) { + ret = -EFAULT; + goto bail; + } + consumed += copy; + } + + /* + * Make sure there is a uctxt when needed. + */ + if (uctxt_required && !uctxt) { + ret = -EINVAL; + goto bail; + } + + /* only root can do these operations */ + if (must_be_root && !capable(CAP_SYS_ADMIN)) { + ret = -EPERM; + goto bail; + } + + switch (cmd.type) { + case HFI1_CMD_ASSIGN_CTXT: + ret = assign_ctxt(fp, &uinfo); + if (ret < 0) + goto bail; + ret = setup_ctxt(fp); + if (ret) + goto bail; + ret = user_init(fp); + break; + case HFI1_CMD_CTXT_INFO: + ret = get_ctxt_info(fp, (void __user *)(unsigned long) + user_val, cmd.len); + break; + case HFI1_CMD_USER_INFO: + ret = get_base_info(fp, (void __user *)(unsigned long) + user_val, cmd.len); + break; + case HFI1_CMD_SDMA_STATUS_UPD: + break; + case HFI1_CMD_CREDIT_UPD: + if (uctxt && uctxt->sc) + sc_return_credits(uctxt->sc); + break; + case HFI1_CMD_TID_UPDATE: + ret = hfi1_user_exp_rcv_setup(fp, &tinfo); + if (!ret) { + /* + * Copy the number of tidlist entries we used + * and the length of the buffer we registered. + * These fields are adjacent in the structure so + * we can copy them at the same time. + */ + addr = (unsigned long)cmd.addr + + offsetof(struct hfi1_tid_info, tidcnt); + if (copy_to_user((void __user *)addr, &tinfo.tidcnt, + sizeof(tinfo.tidcnt) + + sizeof(tinfo.length))) + ret = -EFAULT; + } + break; + case HFI1_CMD_TID_INVAL_READ: + ret = hfi1_user_exp_rcv_invalid(fp, &tinfo); + if (ret) + break; + addr = (unsigned long)cmd.addr + + offsetof(struct hfi1_tid_info, tidcnt); + if (copy_to_user((void __user *)addr, &tinfo.tidcnt, + sizeof(tinfo.tidcnt))) + ret = -EFAULT; + break; + case HFI1_CMD_TID_FREE: + ret = hfi1_user_exp_rcv_clear(fp, &tinfo); + if (ret) + break; + addr = (unsigned long)cmd.addr + + offsetof(struct hfi1_tid_info, tidcnt); + if (copy_to_user((void __user *)addr, &tinfo.tidcnt, + sizeof(tinfo.tidcnt))) + ret = -EFAULT; + break; + case HFI1_CMD_RECV_CTRL: + ret = manage_rcvq(uctxt, fd->subctxt, (int)user_val); + break; + case HFI1_CMD_POLL_TYPE: + uctxt->poll_type = (typeof(uctxt->poll_type))user_val; + break; + case HFI1_CMD_ACK_EVENT: + ret = user_event_ack(uctxt, fd->subctxt, user_val); + break; + case HFI1_CMD_SET_PKEY: + if (HFI1_CAP_IS_USET(PKEY_CHECK)) + ret = set_ctxt_pkey(uctxt, fd->subctxt, user_val); + else + ret = -EPERM; + break; + case HFI1_CMD_CTXT_RESET: { + struct send_context *sc; + struct hfi1_devdata *dd; + + if (!uctxt || !uctxt->dd || !uctxt->sc) { + ret = -EINVAL; + break; + } + /* + * There is no protection here. User level has to + * guarantee that no one will be writing to the send + * context while it is being re-initialized. + * If user level breaks that guarantee, it will break + * it's own context and no one else's. + */ + dd = uctxt->dd; + sc = uctxt->sc; + /* + * Wait until the interrupt handler has marked the + * context as halted or frozen. Report error if we time + * out. + */ + wait_event_interruptible_timeout( + sc->halt_wait, (sc->flags & SCF_HALTED), + msecs_to_jiffies(SEND_CTXT_HALT_TIMEOUT)); + if (!(sc->flags & SCF_HALTED)) { + ret = -ENOLCK; + break; + } + /* + * If the send context was halted due to a Freeze, + * wait until the device has been ""unfrozen"" before + * resetting the context. + */ + if (sc->flags & SCF_FROZEN) { + wait_event_interruptible_timeout( + dd->event_queue, + !(ACCESS_ONCE(dd->flags) & HFI1_FROZEN), + msecs_to_jiffies(SEND_CTXT_HALT_TIMEOUT)); + if (dd->flags & HFI1_FROZEN) { + ret = -ENOLCK; + break; + } + if (dd->flags & HFI1_FORCED_FREEZE) { + /* + * Don't allow context reset if we are into + * forced freeze + */ + ret = -ENODEV; + break; + } + sc_disable(sc); + ret = sc_enable(sc); + hfi1_rcvctrl(dd, HFI1_RCVCTRL_CTXT_ENB, + uctxt->ctxt); + } else { + ret = sc_restart(sc); + } + if (!ret) + sc_return_credits(sc); + break; + } + case HFI1_CMD_EP_INFO: + case HFI1_CMD_EP_ERASE_CHIP: + case HFI1_CMD_EP_ERASE_RANGE: + case HFI1_CMD_EP_READ_RANGE: + case HFI1_CMD_EP_WRITE_RANGE: + ret = handle_eprom_command(fp, &cmd); + break; + } + + if (ret >= 0) + ret = consumed; +bail: + return ret; +} +","@@ -49,6 +49,8 @@ + #include + #include + ++#include ++ + #include ""hfi.h"" + #include ""pio.h"" + #include ""device.h"" +@@ -190,6 +192,10 @@ static ssize_t hfi1_file_write(struct file *fp, const char __user *data, + int uctxt_required = 1; + int must_be_root = 0; + ++ /* FIXME: This interface cannot continue out of staging */ ++ if (WARN_ON_ONCE(!ib_safe_file_access(fp))) ++ return -EACCES; ++ + if (count < sizeof(cmd)) { + ret = -EINVAL; + goto bail;",1905,2141,4096 +18276,"MagickExport MagickBooleanType AnnotateImage(Image *image, + const DrawInfo *draw_info) +{ + char + *p, + primitive[MaxTextExtent], + *text, + **textlist; + + DrawInfo + *annotate, + *annotate_info; + + GeometryInfo + geometry_info; + + MagickBooleanType + status; + + PointInfo + offset; + + RectangleInfo + geometry; + + register ssize_t + i; + + TypeMetric + metrics; + + size_t + height, + number_lines; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(draw_info != (DrawInfo *) NULL); + assert(draw_info->signature == MagickCoreSignature); + if (draw_info->text == (char *) NULL) + return(MagickFalse); + if (*draw_info->text == '\0') + return(MagickTrue); + annotate=CloneDrawInfo((ImageInfo *) NULL,draw_info); + text=annotate->text; + annotate->text=(char *) NULL; + annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + number_lines=1; + for (p=text; *p != '\0'; p++) + if (*p == '\n') + number_lines++; + textlist=AcquireQuantumMemory(number_lines+1,sizeof(*textlist)); + if (textlist == (char **) NULL) + { + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + return(MagickFalse); + } + p=text; + for (i=0; i < number_lines; i++) + { + char + *q; + + textlist[i]=p; + for (q=p; *q != '\0'; q++) + if ((*q == '\r') || (*q == '\n')) + break; + if (*q == '\r') + { + *q='\0'; + q++; + } + *q='\0'; + p=q+1; + } + textlist[i]=(char *) NULL; + SetGeometry(image,&geometry); + SetGeometryInfo(&geometry_info); + if (annotate_info->geometry != (char *) NULL) + { + (void) ParsePageGeometry(image,annotate_info->geometry,&geometry, + &image->exception); + (void) ParseGeometry(annotate_info->geometry,&geometry_info); + } + if (SetImageStorageClass(image,DirectClass) == MagickFalse) + { + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + textlist=(char **) RelinquishMagickMemory(textlist); + return(MagickFalse); + } + if (IsGrayColorspace(image->colorspace) != MagickFalse) + (void) SetImageColorspace(image,sRGBColorspace); + status=MagickTrue; + (void) memset(&metrics,0,sizeof(metrics)); + for (i=0; textlist[i] != (char *) NULL; i++) + { + if (*textlist[i] == '\0') + continue; + /* + Position text relative to image. + */ + annotate_info->affine.tx=geometry_info.xi-image->page.x; + annotate_info->affine.ty=geometry_info.psi-image->page.y; + (void) CloneString(&annotate->text,textlist[i]); + if ((metrics.width == 0) || (annotate->gravity != NorthWestGravity)) + (void) GetTypeMetrics(image,annotate,&metrics); + height=(ssize_t) (metrics.ascent-metrics.descent+ + draw_info->interline_spacing+0.5); + switch (annotate->gravity) + { + case UndefinedGravity: + default: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height; + break; + } + case NorthWestGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* + annotate_info->affine.ry*height+annotate_info->affine.ry* + (metrics.ascent+metrics.descent); + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* + annotate_info->affine.sy*height+annotate_info->affine.sy* + metrics.ascent; + break; + } + case NorthGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ + geometry.width/2.0+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0+annotate_info->affine.ry* + (metrics.ascent+metrics.descent); + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* + annotate_info->affine.sy*height+annotate_info->affine.sy* + metrics.ascent-annotate_info->affine.rx*metrics.width/2.0; + break; + } + case NorthEastGravity: + { + offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ + geometry.width+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width+annotate_info->affine.ry* + (metrics.ascent+metrics.descent)-1.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* + annotate_info->affine.sy*height+annotate_info->affine.sy* + metrics.ascent-annotate_info->affine.rx*metrics.width; + break; + } + case WestGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* + annotate_info->affine.ry*height+annotate_info->affine.ry* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ + geometry.height/2.0+i*annotate_info->affine.sy*height+ + annotate_info->affine.sy*(metrics.ascent+metrics.descent- + (number_lines-1.0)*height)/2.0; + break; + } + case StaticGravity: + case CenterGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ + geometry.width/2.0+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0+annotate_info->affine.ry* + (metrics.ascent+metrics.descent-(number_lines-1)*height)/2.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ + geometry.height/2.0+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width/2.0+annotate_info->affine.sy* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; + break; + } + case EastGravity: + { + offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ + geometry.width+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width+annotate_info->affine.ry* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0-1.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ + geometry.height/2.0+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width+annotate_info->affine.sy* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; + break; + } + case SouthWestGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* + annotate_info->affine.ry*height-annotate_info->affine.ry* + (number_lines-1.0)*height; + offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ + geometry.height+i*annotate_info->affine.sy*height- + annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent; + break; + } + case SouthGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ + geometry.width/2.0+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0-annotate_info->affine.ry* + (number_lines-1.0)*height/2.0; + offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ + geometry.height+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width/2.0-annotate_info->affine.sy* + (number_lines-1.0)*height+metrics.descent; + break; + } + case SouthEastGravity: + { + offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ + geometry.width+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width-annotate_info->affine.ry* + (number_lines-1.0)*height-1.0; + offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ + geometry.height+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width-annotate_info->affine.sy* + (number_lines-1.0)*height+metrics.descent; + break; + } + } + switch (annotate->align) + { + case LeftAlign: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height; + break; + } + case CenterAlign: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width/2.0; + break; + } + case RightAlign: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width; + break; + } + default: + break; + } + if (draw_info->undercolor.opacity != TransparentOpacity) + { + DrawInfo + *undercolor_info; + + /* + Text box. + */ + undercolor_info=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL); + undercolor_info->fill=draw_info->undercolor; + undercolor_info->affine=draw_info->affine; + undercolor_info->affine.tx=offset.x-draw_info->affine.ry*metrics.ascent; + undercolor_info->affine.ty=offset.y-draw_info->affine.sy*metrics.ascent; + (void) FormatLocaleString(primitive,MaxTextExtent, + ""rectangle 0.0,0.0 %g,%g"",metrics.origin.x,(double) height); + (void) CloneString(&undercolor_info->primitive,primitive); + (void) DrawImage(image,undercolor_info); + (void) DestroyDrawInfo(undercolor_info); + } + annotate_info->affine.tx=offset.x; + annotate_info->affine.ty=offset.y; + (void) FormatLocaleString(primitive,MaxTextExtent,""stroke-width %g "" + ""line 0,0 %g,0"",metrics.underline_thickness,metrics.width); + if (annotate->decorate == OverlineDecoration) + { + annotate_info->affine.ty-=(draw_info->affine.sy*(metrics.ascent+ + metrics.descent-metrics.underline_position)); + (void) CloneString(&annotate_info->primitive,primitive); + (void) DrawImage(image,annotate_info); + } + else + if (annotate->decorate == UnderlineDecoration) + { + annotate_info->affine.ty-=(draw_info->affine.sy* + metrics.underline_position); + (void) CloneString(&annotate_info->primitive,primitive); + (void) DrawImage(image,annotate_info); + } + /* + Annotate image with text. + */ + status=RenderType(image,annotate,&offset,&metrics); + if (status == MagickFalse) + break; + if (annotate->decorate == LineThroughDecoration) + { + annotate_info->affine.ty-=(draw_info->affine.sy*(height+ + metrics.underline_position+metrics.descent)/2.0); + (void) CloneString(&annotate_info->primitive,primitive); + (void) DrawImage(image,annotate_info); + } + } + /* + Relinquish resources. + */ + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + textlist=(char **) RelinquishMagickMemory(textlist); + return(status); + } +",1,"MagickExport MagickBooleanType AnnotateImage(Image *image, + const DrawInfo *draw_info) +{ + char + *p, + primitive[MaxTextExtent], + *text, + **textlist; + + DrawInfo + *annotate, + *annotate_info; + + GeometryInfo + geometry_info; + + MagickBooleanType + status; + + PointInfo + offset; + + RectangleInfo + geometry; + + register ssize_t + i; + + TypeMetric + metrics; + + size_t + height, + number_lines; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(draw_info != (DrawInfo *) NULL); + assert(draw_info->signature == MagickCoreSignature); + if (draw_info->text == (char *) NULL) + return(MagickFalse); + if (*draw_info->text == '\0') + return(MagickTrue); + annotate=CloneDrawInfo((ImageInfo *) NULL,draw_info); + text=annotate->text; + annotate->text=(char *) NULL; + annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); + number_lines=1; + for (p=text; *p != '\0'; p++) + if (*p == '\n') + number_lines++; + textlist=AcquireQuantumMemory(number_lines+1,sizeof(*textlist)); + if (textlist == (char **) NULL) + { + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + text=DestroyString(text); + return(MagickFalse); + } + p=text; + for (i=0; i < number_lines; i++) + { + char + *q; + + textlist[i]=p; + for (q=p; *q != '\0'; q++) + if ((*q == '\r') || (*q == '\n')) + break; + if (*q == '\r') + { + *q='\0'; + q++; + } + *q='\0'; + p=q+1; + } + textlist[i]=(char *) NULL; + SetGeometry(image,&geometry); + SetGeometryInfo(&geometry_info); + if (annotate_info->geometry != (char *) NULL) + { + (void) ParsePageGeometry(image,annotate_info->geometry,&geometry, + &image->exception); + (void) ParseGeometry(annotate_info->geometry,&geometry_info); + } + if (SetImageStorageClass(image,DirectClass) == MagickFalse) + { + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + textlist=(char **) RelinquishMagickMemory(textlist); + text=DestroyString(text); + return(MagickFalse); + } + if (IsGrayColorspace(image->colorspace) != MagickFalse) + (void) SetImageColorspace(image,sRGBColorspace); + status=MagickTrue; + (void) memset(&metrics,0,sizeof(metrics)); + for (i=0; textlist[i] != (char *) NULL; i++) + { + if (*textlist[i] == '\0') + continue; + /* + Position text relative to image. + */ + annotate_info->affine.tx=geometry_info.xi-image->page.x; + annotate_info->affine.ty=geometry_info.psi-image->page.y; + (void) CloneString(&annotate->text,textlist[i]); + if ((metrics.width == 0) || (annotate->gravity != NorthWestGravity)) + (void) GetTypeMetrics(image,annotate,&metrics); + height=(ssize_t) (metrics.ascent-metrics.descent+ + draw_info->interline_spacing+0.5); + switch (annotate->gravity) + { + case UndefinedGravity: + default: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height; + break; + } + case NorthWestGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* + annotate_info->affine.ry*height+annotate_info->affine.ry* + (metrics.ascent+metrics.descent); + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* + annotate_info->affine.sy*height+annotate_info->affine.sy* + metrics.ascent; + break; + } + case NorthGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ + geometry.width/2.0+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0+annotate_info->affine.ry* + (metrics.ascent+metrics.descent); + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* + annotate_info->affine.sy*height+annotate_info->affine.sy* + metrics.ascent-annotate_info->affine.rx*metrics.width/2.0; + break; + } + case NorthEastGravity: + { + offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ + geometry.width+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width+annotate_info->affine.ry* + (metrics.ascent+metrics.descent)-1.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* + annotate_info->affine.sy*height+annotate_info->affine.sy* + metrics.ascent-annotate_info->affine.rx*metrics.width; + break; + } + case WestGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* + annotate_info->affine.ry*height+annotate_info->affine.ry* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ + geometry.height/2.0+i*annotate_info->affine.sy*height+ + annotate_info->affine.sy*(metrics.ascent+metrics.descent- + (number_lines-1.0)*height)/2.0; + break; + } + case StaticGravity: + case CenterGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ + geometry.width/2.0+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0+annotate_info->affine.ry* + (metrics.ascent+metrics.descent-(number_lines-1)*height)/2.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ + geometry.height/2.0+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width/2.0+annotate_info->affine.sy* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; + break; + } + case EastGravity: + { + offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ + geometry.width+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width+annotate_info->affine.ry* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0-1.0; + offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ + geometry.height/2.0+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width+annotate_info->affine.sy* + (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; + break; + } + case SouthWestGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* + annotate_info->affine.ry*height-annotate_info->affine.ry* + (number_lines-1.0)*height; + offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ + geometry.height+i*annotate_info->affine.sy*height- + annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent; + break; + } + case SouthGravity: + { + offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ + geometry.width/2.0+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0-annotate_info->affine.ry* + (number_lines-1.0)*height/2.0; + offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ + geometry.height+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width/2.0-annotate_info->affine.sy* + (number_lines-1.0)*height+metrics.descent; + break; + } + case SouthEastGravity: + { + offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ + geometry.width+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width-annotate_info->affine.ry* + (number_lines-1.0)*height-1.0; + offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ + geometry.height+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width-annotate_info->affine.sy* + (number_lines-1.0)*height+metrics.descent; + break; + } + } + switch (annotate->align) + { + case LeftAlign: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height; + break; + } + case CenterAlign: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width/2.0; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width/2.0; + break; + } + case RightAlign: + { + offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height- + annotate_info->affine.sx*metrics.width; + offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height- + annotate_info->affine.rx*metrics.width; + break; + } + default: + break; + } + if (draw_info->undercolor.opacity != TransparentOpacity) + { + DrawInfo + *undercolor_info; + + /* + Text box. + */ + undercolor_info=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL); + undercolor_info->fill=draw_info->undercolor; + undercolor_info->affine=draw_info->affine; + undercolor_info->affine.tx=offset.x-draw_info->affine.ry*metrics.ascent; + undercolor_info->affine.ty=offset.y-draw_info->affine.sy*metrics.ascent; + (void) FormatLocaleString(primitive,MaxTextExtent, + ""rectangle 0.0,0.0 %g,%g"",metrics.origin.x,(double) height); + (void) CloneString(&undercolor_info->primitive,primitive); + (void) DrawImage(image,undercolor_info); + (void) DestroyDrawInfo(undercolor_info); + } + annotate_info->affine.tx=offset.x; + annotate_info->affine.ty=offset.y; + (void) FormatLocaleString(primitive,MaxTextExtent,""stroke-width %g "" + ""line 0,0 %g,0"",metrics.underline_thickness,metrics.width); + if (annotate->decorate == OverlineDecoration) + { + annotate_info->affine.ty-=(draw_info->affine.sy*(metrics.ascent+ + metrics.descent-metrics.underline_position)); + (void) CloneString(&annotate_info->primitive,primitive); + (void) DrawImage(image,annotate_info); + } + else + if (annotate->decorate == UnderlineDecoration) + { + annotate_info->affine.ty-=(draw_info->affine.sy* + metrics.underline_position); + (void) CloneString(&annotate_info->primitive,primitive); + (void) DrawImage(image,annotate_info); + } + /* + Annotate image with text. + */ + status=RenderType(image,annotate,&offset,&metrics); + if (status == MagickFalse) + break; + if (annotate->decorate == LineThroughDecoration) + { + annotate_info->affine.ty-=(draw_info->affine.sy*(height+ + metrics.underline_position+metrics.descent)/2.0); + (void) CloneString(&annotate_info->primitive,primitive); + (void) DrawImage(image,annotate_info); + } + } + /* + Relinquish resources. + */ + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + textlist=(char **) RelinquishMagickMemory(textlist); + text=DestroyString(text); + return(status); + } +","@@ -266,6 +266,7 @@ MagickExport MagickBooleanType AnnotateImage(Image *image, + { + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); ++ text=DestroyString(text); + return(MagickFalse); + } + p=text; +@@ -300,6 +301,7 @@ MagickExport MagickBooleanType AnnotateImage(Image *image, + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + textlist=(char **) RelinquishMagickMemory(textlist); ++ text=DestroyString(text); + return(MagickFalse); + } + if (IsGrayColorspace(image->colorspace) != MagickFalse) +@@ -517,6 +519,7 @@ MagickExport MagickBooleanType AnnotateImage(Image *image, + annotate_info=DestroyDrawInfo(annotate_info); + annotate=DestroyDrawInfo(annotate); + textlist=(char **) RelinquishMagickMemory(textlist); ++ text=DestroyString(text); + return(status); + } + ",3133,3369,4096 +17821,"int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + unsigned char *limit, int *al) +{ + unsigned short type; + unsigned short size; + unsigned short len; + unsigned char *data = *p; + int renegotiate_seen = 0; + int sigalg_seen = 0; + + s->servername_done = 0; + s->tlsext_status_type = -1; +# ifndef OPENSSL_NO_NEXTPROTONEG + s->s3->next_proto_neg_seen = 0; +# endif + +# ifndef OPENSSL_NO_HEARTBEATS + s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED | + SSL_TLSEXT_HB_DONT_SEND_REQUESTS); +# endif + +# ifndef OPENSSL_NO_EC + if (s->options & SSL_OP_SAFARI_ECDHE_ECDSA_BUG) + ssl_check_for_safari(s, data, limit); +# endif /* !OPENSSL_NO_EC */ + +# ifndef OPENSSL_NO_SRP + if (s->srp_ctx.login != NULL) { + OPENSSL_free(s->srp_ctx.login); + s->srp_ctx.login = NULL; + } +# endif + + s->srtp_profile = NULL; + + if (data == limit) + goto ri_check; + + if (limit - data < 2) + goto err; + + n2s(data, len); + + if (limit - data != len) + goto err; + + while (limit - data >= 4) { + n2s(data, type); + n2s(data, size); + + if (limit - data < size) + goto err; +# if 0 + fprintf(stderr, ""Received extension type %d size %d\n"", type, size); +# endif + if (s->tlsext_debug_cb) + s->tlsext_debug_cb(s, 0, type, data, size, s->tlsext_debug_arg); +/*- + * The servername extension is treated as follows: + * + * - Only the hostname type is supported with a maximum length of 255. + * - The servername is rejected if too long or if it contains zeros, + * in which case an fatal alert is generated. + * - The servername field is maintained together with the session cache. + * - When a session is resumed, the servername call back invoked in order + * to allow the application to position itself to the right context. + * - The servername is acknowledged if it is new for a session or when + * it is identical to a previously used for the same session. + * Applications can control the behaviour. They can at any time + * set a 'desirable' servername for a new SSL object. This can be the + * case for example with HTTPS when a Host: header field is received and + * a renegotiation is requested. In this case, a possible servername + * presented in the new client hello is only acknowledged if it matches + * the value of the Host: field. + * - Applications must use SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION + * if they provide for changing an explicit servername context for the + * session, i.e. when the session has been established with a servername + * extension. + * - On session reconnect, the servername extension may be absent. + * + */ + + if (type == TLSEXT_TYPE_server_name) { + unsigned char *sdata; + int servname_type; + int dsize; + + if (size < 2) + goto err; + n2s(data, dsize); + size -= 2; + if (dsize > size) + goto err; + + sdata = data; + while (dsize > 3) { + servname_type = *(sdata++); + n2s(sdata, len); + dsize -= 3; + + if (len > dsize) + goto err; + + if (s->servername_done == 0) + switch (servname_type) { + case TLSEXT_NAMETYPE_host_name: + if (!s->hit) { + if (s->session->tlsext_hostname) + goto err; + + if (len > TLSEXT_MAXLEN_host_name) { + *al = TLS1_AD_UNRECOGNIZED_NAME; + return 0; + } + if ((s->session->tlsext_hostname = + OPENSSL_malloc(len + 1)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + memcpy(s->session->tlsext_hostname, sdata, len); + s->session->tlsext_hostname[len] = '\0'; + if (strlen(s->session->tlsext_hostname) != len) { + OPENSSL_free(s->session->tlsext_hostname); + s->session->tlsext_hostname = NULL; + *al = TLS1_AD_UNRECOGNIZED_NAME; + return 0; + } + s->servername_done = 1; + + } else + s->servername_done = s->session->tlsext_hostname + && strlen(s->session->tlsext_hostname) == len + && strncmp(s->session->tlsext_hostname, + (char *)sdata, len) == 0; + + break; + + default: + break; + } + + dsize -= len; + } + if (dsize != 0) + goto err; + + } +# ifndef OPENSSL_NO_SRP + else if (type == TLSEXT_TYPE_srp) { + if (size == 0 || ((len = data[0])) != (size - 1)) + goto err; + if (s->srp_ctx.login != NULL) + goto err; + if ((s->srp_ctx.login = OPENSSL_malloc(len + 1)) == NULL) + return -1; + memcpy(s->srp_ctx.login, &data[1], len); + s->srp_ctx.login[len] = '\0'; + + if (strlen(s->srp_ctx.login) != len) + goto err; + } +# endif + +# ifndef OPENSSL_NO_EC + else if (type == TLSEXT_TYPE_ec_point_formats) { + unsigned char *sdata = data; + int ecpointformatlist_length = *(sdata++); + + if (ecpointformatlist_length != size - 1) + goto err; + if (!s->hit) { + if (s->session->tlsext_ecpointformatlist) { + OPENSSL_free(s->session->tlsext_ecpointformatlist); + s->session->tlsext_ecpointformatlist = NULL; + } + s->session->tlsext_ecpointformatlist_length = 0; + if ((s->session->tlsext_ecpointformatlist = + OPENSSL_malloc(ecpointformatlist_length)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->session->tlsext_ecpointformatlist_length = + ecpointformatlist_length; + memcpy(s->session->tlsext_ecpointformatlist, sdata, + ecpointformatlist_length); + } +# if 0 + fprintf(stderr, + ""ssl_parse_clienthello_tlsext s->session->tlsext_ecpointformatlist (length=%i) "", + s->session->tlsext_ecpointformatlist_length); + sdata = s->session->tlsext_ecpointformatlist; + for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) + fprintf(stderr, ""%i "", *(sdata++)); + fprintf(stderr, ""\n""); +# endif + } else if (type == TLSEXT_TYPE_elliptic_curves) { + unsigned char *sdata = data; + int ellipticcurvelist_length = (*(sdata++) << 8); + ellipticcurvelist_length += (*(sdata++)); + + if (ellipticcurvelist_length != size - 2 || + ellipticcurvelist_length < 1 || + /* Each NamedCurve is 2 bytes. */ + ellipticcurvelist_length & 1) + goto err; + + if (!s->hit) { + if (s->session->tlsext_ellipticcurvelist) + goto err; + + s->session->tlsext_ellipticcurvelist_length = 0; + if ((s->session->tlsext_ellipticcurvelist = + OPENSSL_malloc(ellipticcurvelist_length)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->session->tlsext_ellipticcurvelist_length = + ellipticcurvelist_length; + memcpy(s->session->tlsext_ellipticcurvelist, sdata, + ellipticcurvelist_length); + } +# if 0 + fprintf(stderr, + ""ssl_parse_clienthello_tlsext s->session->tlsext_ellipticcurvelist (length=%i) "", + s->session->tlsext_ellipticcurvelist_length); + sdata = s->session->tlsext_ellipticcurvelist; + for (i = 0; i < s->session->tlsext_ellipticcurvelist_length; i++) + fprintf(stderr, ""%i "", *(sdata++)); + fprintf(stderr, ""\n""); +# endif + } +# endif /* OPENSSL_NO_EC */ +# ifdef TLSEXT_TYPE_opaque_prf_input + else if (type == TLSEXT_TYPE_opaque_prf_input && + s->version != DTLS1_VERSION) { + unsigned char *sdata = data; + + if (size < 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + n2s(sdata, s->s3->client_opaque_prf_input_len); + if (s->s3->client_opaque_prf_input_len != size - 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + if (s->s3->client_opaque_prf_input != NULL) { + /* shouldn't really happen */ + OPENSSL_free(s->s3->client_opaque_prf_input); + } + + /* dummy byte just to get non-NULL */ + if (s->s3->client_opaque_prf_input_len == 0) + s->s3->client_opaque_prf_input = OPENSSL_malloc(1); + else + s->s3->client_opaque_prf_input = + BUF_memdup(sdata, s->s3->client_opaque_prf_input_len); + if (s->s3->client_opaque_prf_input == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + } +# endif + else if (type == TLSEXT_TYPE_session_ticket) { + if (s->tls_session_ticket_ext_cb && + !s->tls_session_ticket_ext_cb(s, data, size, + s->tls_session_ticket_ext_cb_arg)) + { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + } else if (type == TLSEXT_TYPE_renegotiate) { + if (!ssl_parse_clienthello_renegotiate_ext(s, data, size, al)) + return 0; + renegotiate_seen = 1; + } else if (type == TLSEXT_TYPE_signature_algorithms) { + int dsize; + if (sigalg_seen || size < 2) + goto err; + sigalg_seen = 1; + n2s(data, dsize); + size -= 2; + if (dsize != size || dsize & 1) + goto err; + if (!tls1_process_sigalgs(s, data, dsize)) + goto err; + } else if (type == TLSEXT_TYPE_status_request && + s->version != DTLS1_VERSION) { + + if (size < 5) + goto err; + + s->tlsext_status_type = *data++; + size--; + if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { + const unsigned char *sdata; + int dsize; + /* Read in responder_id_list */ + n2s(data, dsize); + size -= 2; + if (dsize > size) + goto err; + while (dsize > 0) { + OCSP_RESPID *id; + int idsize; + && !(s->tlsext_ocsp_ids = + sk_OCSP_RESPID_new_null())) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } + } + + OCSP_RESPID_free(id); + goto err; + } + if (!s->tlsext_ocsp_ids + && !(s->tlsext_ocsp_ids = + sk_OCSP_RESPID_new_null())) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + goto err; + sdata = data; + if (dsize > 0) { + if (s->tlsext_ocsp_exts) { + sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, + X509_EXTENSION_free); + } + + s->tlsext_ocsp_exts = + d2i_X509_EXTENSIONS(NULL, &sdata, dsize); + if (!s->tlsext_ocsp_exts || (data + dsize != sdata)) + goto err; + } + } + /* + * We don't know what to do with any other type * so ignore it. + */ + else + s->tlsext_status_type = -1; + } +# ifndef OPENSSL_NO_HEARTBEATS + else if (type == TLSEXT_TYPE_heartbeat) { + switch (data[0]) { + case 0x01: /* Client allows us to send HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + break; + case 0x02: /* Client doesn't accept HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_SEND_REQUESTS; + break; + default: + *al = SSL_AD_ILLEGAL_PARAMETER; + return 0; + } + } +# endif +# ifndef OPENSSL_NO_NEXTPROTONEG + else if (type == TLSEXT_TYPE_next_proto_neg && + s->s3->tmp.finish_md_len == 0) { + /*- + * We shouldn't accept this extension on a + * renegotiation. + * + * s->new_session will be set on renegotiation, but we + * probably shouldn't rely that it couldn't be set on + * the initial renegotation too in certain cases (when + * there's some other reason to disallow resuming an + * earlier session -- the current code won't be doing + * anything like that, but this might change). + * + * A valid sign that there's been a previous handshake + * in this connection is if s->s3->tmp.finish_md_len > + * 0. (We are talking about a check that will happen + * in the Hello protocol round, well before a new + * Finished message could have been computed.) + */ + s->s3->next_proto_neg_seen = 1; + } +# endif + + /* session ticket processed earlier */ +# ifndef OPENSSL_NO_SRTP + else if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s) + && type == TLSEXT_TYPE_use_srtp) { + if (ssl_parse_clienthello_use_srtp_ext(s, data, size, al)) + return 0; + } +# endif + + data += size; + } + + /* Spurious data on the end */ + if (data != limit) + goto err; + + *p = data; + + ri_check: + + /* Need RI if renegotiating */ + + if (!renegotiate_seen && s->renegotiate && + !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + *al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + return 0; + } + + return 1; +err: + *al = SSL_AD_DECODE_ERROR; + return 0; +} +",1,"int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + unsigned char *limit, int *al) +{ + unsigned short type; + unsigned short size; + unsigned short len; + unsigned char *data = *p; + int renegotiate_seen = 0; + int sigalg_seen = 0; + + s->servername_done = 0; + s->tlsext_status_type = -1; +# ifndef OPENSSL_NO_NEXTPROTONEG + s->s3->next_proto_neg_seen = 0; +# endif + +# ifndef OPENSSL_NO_HEARTBEATS + s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED | + SSL_TLSEXT_HB_DONT_SEND_REQUESTS); +# endif + +# ifndef OPENSSL_NO_EC + if (s->options & SSL_OP_SAFARI_ECDHE_ECDSA_BUG) + ssl_check_for_safari(s, data, limit); +# endif /* !OPENSSL_NO_EC */ + +# ifndef OPENSSL_NO_SRP + if (s->srp_ctx.login != NULL) { + OPENSSL_free(s->srp_ctx.login); + s->srp_ctx.login = NULL; + } +# endif + + s->srtp_profile = NULL; + + if (data == limit) + goto ri_check; + + if (limit - data < 2) + goto err; + + n2s(data, len); + + if (limit - data != len) + goto err; + + while (limit - data >= 4) { + n2s(data, type); + n2s(data, size); + + if (limit - data < size) + goto err; +# if 0 + fprintf(stderr, ""Received extension type %d size %d\n"", type, size); +# endif + if (s->tlsext_debug_cb) + s->tlsext_debug_cb(s, 0, type, data, size, s->tlsext_debug_arg); +/*- + * The servername extension is treated as follows: + * + * - Only the hostname type is supported with a maximum length of 255. + * - The servername is rejected if too long or if it contains zeros, + * in which case an fatal alert is generated. + * - The servername field is maintained together with the session cache. + * - When a session is resumed, the servername call back invoked in order + * to allow the application to position itself to the right context. + * - The servername is acknowledged if it is new for a session or when + * it is identical to a previously used for the same session. + * Applications can control the behaviour. They can at any time + * set a 'desirable' servername for a new SSL object. This can be the + * case for example with HTTPS when a Host: header field is received and + * a renegotiation is requested. In this case, a possible servername + * presented in the new client hello is only acknowledged if it matches + * the value of the Host: field. + * - Applications must use SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION + * if they provide for changing an explicit servername context for the + * session, i.e. when the session has been established with a servername + * extension. + * - On session reconnect, the servername extension may be absent. + * + */ + + if (type == TLSEXT_TYPE_server_name) { + unsigned char *sdata; + int servname_type; + int dsize; + + if (size < 2) + goto err; + n2s(data, dsize); + size -= 2; + if (dsize > size) + goto err; + + sdata = data; + while (dsize > 3) { + servname_type = *(sdata++); + n2s(sdata, len); + dsize -= 3; + + if (len > dsize) + goto err; + + if (s->servername_done == 0) + switch (servname_type) { + case TLSEXT_NAMETYPE_host_name: + if (!s->hit) { + if (s->session->tlsext_hostname) + goto err; + + if (len > TLSEXT_MAXLEN_host_name) { + *al = TLS1_AD_UNRECOGNIZED_NAME; + return 0; + } + if ((s->session->tlsext_hostname = + OPENSSL_malloc(len + 1)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + memcpy(s->session->tlsext_hostname, sdata, len); + s->session->tlsext_hostname[len] = '\0'; + if (strlen(s->session->tlsext_hostname) != len) { + OPENSSL_free(s->session->tlsext_hostname); + s->session->tlsext_hostname = NULL; + *al = TLS1_AD_UNRECOGNIZED_NAME; + return 0; + } + s->servername_done = 1; + + } else + s->servername_done = s->session->tlsext_hostname + && strlen(s->session->tlsext_hostname) == len + && strncmp(s->session->tlsext_hostname, + (char *)sdata, len) == 0; + + break; + + default: + break; + } + + dsize -= len; + } + if (dsize != 0) + goto err; + + } +# ifndef OPENSSL_NO_SRP + else if (type == TLSEXT_TYPE_srp) { + if (size == 0 || ((len = data[0])) != (size - 1)) + goto err; + if (s->srp_ctx.login != NULL) + goto err; + if ((s->srp_ctx.login = OPENSSL_malloc(len + 1)) == NULL) + return -1; + memcpy(s->srp_ctx.login, &data[1], len); + s->srp_ctx.login[len] = '\0'; + + if (strlen(s->srp_ctx.login) != len) + goto err; + } +# endif + +# ifndef OPENSSL_NO_EC + else if (type == TLSEXT_TYPE_ec_point_formats) { + unsigned char *sdata = data; + int ecpointformatlist_length = *(sdata++); + + if (ecpointformatlist_length != size - 1) + goto err; + if (!s->hit) { + if (s->session->tlsext_ecpointformatlist) { + OPENSSL_free(s->session->tlsext_ecpointformatlist); + s->session->tlsext_ecpointformatlist = NULL; + } + s->session->tlsext_ecpointformatlist_length = 0; + if ((s->session->tlsext_ecpointformatlist = + OPENSSL_malloc(ecpointformatlist_length)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->session->tlsext_ecpointformatlist_length = + ecpointformatlist_length; + memcpy(s->session->tlsext_ecpointformatlist, sdata, + ecpointformatlist_length); + } +# if 0 + fprintf(stderr, + ""ssl_parse_clienthello_tlsext s->session->tlsext_ecpointformatlist (length=%i) "", + s->session->tlsext_ecpointformatlist_length); + sdata = s->session->tlsext_ecpointformatlist; + for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) + fprintf(stderr, ""%i "", *(sdata++)); + fprintf(stderr, ""\n""); +# endif + } else if (type == TLSEXT_TYPE_elliptic_curves) { + unsigned char *sdata = data; + int ellipticcurvelist_length = (*(sdata++) << 8); + ellipticcurvelist_length += (*(sdata++)); + + if (ellipticcurvelist_length != size - 2 || + ellipticcurvelist_length < 1 || + /* Each NamedCurve is 2 bytes. */ + ellipticcurvelist_length & 1) + goto err; + + if (!s->hit) { + if (s->session->tlsext_ellipticcurvelist) + goto err; + + s->session->tlsext_ellipticcurvelist_length = 0; + if ((s->session->tlsext_ellipticcurvelist = + OPENSSL_malloc(ellipticcurvelist_length)) == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + s->session->tlsext_ellipticcurvelist_length = + ellipticcurvelist_length; + memcpy(s->session->tlsext_ellipticcurvelist, sdata, + ellipticcurvelist_length); + } +# if 0 + fprintf(stderr, + ""ssl_parse_clienthello_tlsext s->session->tlsext_ellipticcurvelist (length=%i) "", + s->session->tlsext_ellipticcurvelist_length); + sdata = s->session->tlsext_ellipticcurvelist; + for (i = 0; i < s->session->tlsext_ellipticcurvelist_length; i++) + fprintf(stderr, ""%i "", *(sdata++)); + fprintf(stderr, ""\n""); +# endif + } +# endif /* OPENSSL_NO_EC */ +# ifdef TLSEXT_TYPE_opaque_prf_input + else if (type == TLSEXT_TYPE_opaque_prf_input && + s->version != DTLS1_VERSION) { + unsigned char *sdata = data; + + if (size < 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + n2s(sdata, s->s3->client_opaque_prf_input_len); + if (s->s3->client_opaque_prf_input_len != size - 2) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + + if (s->s3->client_opaque_prf_input != NULL) { + /* shouldn't really happen */ + OPENSSL_free(s->s3->client_opaque_prf_input); + } + + /* dummy byte just to get non-NULL */ + if (s->s3->client_opaque_prf_input_len == 0) + s->s3->client_opaque_prf_input = OPENSSL_malloc(1); + else + s->s3->client_opaque_prf_input = + BUF_memdup(sdata, s->s3->client_opaque_prf_input_len); + if (s->s3->client_opaque_prf_input == NULL) { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + } +# endif + else if (type == TLSEXT_TYPE_session_ticket) { + if (s->tls_session_ticket_ext_cb && + !s->tls_session_ticket_ext_cb(s, data, size, + s->tls_session_ticket_ext_cb_arg)) + { + *al = TLS1_AD_INTERNAL_ERROR; + return 0; + } + } else if (type == TLSEXT_TYPE_renegotiate) { + if (!ssl_parse_clienthello_renegotiate_ext(s, data, size, al)) + return 0; + renegotiate_seen = 1; + } else if (type == TLSEXT_TYPE_signature_algorithms) { + int dsize; + if (sigalg_seen || size < 2) + goto err; + sigalg_seen = 1; + n2s(data, dsize); + size -= 2; + if (dsize != size || dsize & 1) + goto err; + if (!tls1_process_sigalgs(s, data, dsize)) + goto err; + } else if (type == TLSEXT_TYPE_status_request && + s->version != DTLS1_VERSION) { + + if (size < 5) + goto err; + + s->tlsext_status_type = *data++; + size--; + if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { + const unsigned char *sdata; + int dsize; + /* Read in responder_id_list */ + n2s(data, dsize); + size -= 2; + if (dsize > size) + goto err; + + /* + * We remove any OCSP_RESPIDs from a previous handshake + * to prevent unbounded memory growth - CVE-2016-6304 + */ + sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, + OCSP_RESPID_free); + if (dsize > 0) { + s->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null(); + if (s->tlsext_ocsp_ids == NULL) { + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } + } else { + s->tlsext_ocsp_ids = NULL; + } + + while (dsize > 0) { + OCSP_RESPID *id; + int idsize; + && !(s->tlsext_ocsp_ids = + sk_OCSP_RESPID_new_null())) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } + } + + OCSP_RESPID_free(id); + goto err; + } + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR; + goto err; + sdata = data; + if (dsize > 0) { + if (s->tlsext_ocsp_exts) { + sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, + X509_EXTENSION_free); + } + + s->tlsext_ocsp_exts = + d2i_X509_EXTENSIONS(NULL, &sdata, dsize); + if (!s->tlsext_ocsp_exts || (data + dsize != sdata)) + goto err; + } + } + /* + * We don't know what to do with any other type * so ignore it. + */ + else + s->tlsext_status_type = -1; + } +# ifndef OPENSSL_NO_HEARTBEATS + else if (type == TLSEXT_TYPE_heartbeat) { + switch (data[0]) { + case 0x01: /* Client allows us to send HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + break; + case 0x02: /* Client doesn't accept HB requests */ + s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; + s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_SEND_REQUESTS; + break; + default: + *al = SSL_AD_ILLEGAL_PARAMETER; + return 0; + } + } +# endif +# ifndef OPENSSL_NO_NEXTPROTONEG + else if (type == TLSEXT_TYPE_next_proto_neg && + s->s3->tmp.finish_md_len == 0) { + /*- + * We shouldn't accept this extension on a + * renegotiation. + * + * s->new_session will be set on renegotiation, but we + * probably shouldn't rely that it couldn't be set on + * the initial renegotation too in certain cases (when + * there's some other reason to disallow resuming an + * earlier session -- the current code won't be doing + * anything like that, but this might change). + * + * A valid sign that there's been a previous handshake + * in this connection is if s->s3->tmp.finish_md_len > + * 0. (We are talking about a check that will happen + * in the Hello protocol round, well before a new + * Finished message could have been computed.) + */ + s->s3->next_proto_neg_seen = 1; + } +# endif + + /* session ticket processed earlier */ +# ifndef OPENSSL_NO_SRTP + else if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s) + && type == TLSEXT_TYPE_use_srtp) { + if (ssl_parse_clienthello_use_srtp_ext(s, data, size, al)) + return 0; + } +# endif + + data += size; + } + + /* Spurious data on the end */ + if (data != limit) + goto err; + + *p = data; + + ri_check: + + /* Need RI if renegotiating */ + + if (!renegotiate_seen && s->renegotiate && + !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + *al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + return 0; + } + + return 1; +err: + *al = SSL_AD_DECODE_ERROR; + return 0; +} +","@@ -1284,6 +1284,23 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + size -= 2; + if (dsize > size) + goto err; ++ ++ /* ++ * We remove any OCSP_RESPIDs from a previous handshake ++ * to prevent unbounded memory growth - CVE-2016-6304 ++ */ ++ sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, ++ OCSP_RESPID_free); ++ if (dsize > 0) { ++ s->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null(); ++ if (s->tlsext_ocsp_ids == NULL) { ++ *al = SSL_AD_INTERNAL_ERROR; ++ return 0; ++ } ++ } else { ++ s->tlsext_ocsp_ids = NULL; ++ } ++ + while (dsize > 0) { + OCSP_RESPID *id; + int idsize; +@@ -1303,13 +1320,6 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + OCSP_RESPID_free(id); + goto err; + } +- if (!s->tlsext_ocsp_ids +- && !(s->tlsext_ocsp_ids = +- sk_OCSP_RESPID_new_null())) { +- OCSP_RESPID_free(id); +- *al = SSL_AD_INTERNAL_ERROR; +- return 0; +- } + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { + OCSP_RESPID_free(id); + *al = SSL_AD_INTERNAL_ERROR;",3708,3944,4096 +1616,"PhotoDataUtils::Import2WayExif ( const TIFF_Manager & exif, SXMPMeta * xmp, int iptcDigestState ) +{ + const bool nativeEndian = exif.IsNativeEndian(); + + bool found, foundFromXMP; + TIFF_Manager::TagInfo tagInfo; + XMP_OptionBits flags; + + ImportTIFF_StandardMappings ( kTIFF_PrimaryIFD, exif, xmp ); + ImportTIFF_StandardMappings ( kTIFF_ExifIFD, exif, xmp ); + ImportTIFF_StandardMappings ( kTIFF_GPSInfoIFD, exif, xmp ); + + + #if SupportOldExifProperties + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_CameraOwnerName, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ASCIIType) && (tagInfo.count > 0) ) { + ImportSingleTIFF ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF_Aux, ""OwnerName"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_BodySerialNumber, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ASCIIType) && (tagInfo.count > 0) ) { + ImportSingleTIFF ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF_Aux, ""SerialNumber"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_LensModel, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ASCIIType) && (tagInfo.count > 0) ) { + ImportSingleTIFF ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF_Aux, ""Lens"" ); + } + + found = xmp->GetProperty ( kXMP_NS_ExifEX, ""LensSpecification"", 0, &flags ); + if ( found && XMP_PropIsArray(flags) ) { + std::string fullStr, oneItem; + size_t count = (size_t) xmp->CountArrayItems ( kXMP_NS_ExifEX, ""LensSpecification"" ); + if ( count > 0 ) { + (void) xmp->GetArrayItem ( kXMP_NS_ExifEX, ""LensSpecification"", 1, &fullStr, 0 ); + for ( size_t i = 2; i <= count; ++i ) { + fullStr += ' '; + (void) xmp->GetArrayItem ( kXMP_NS_ExifEX, ""LensSpecification"", i, &oneItem, 0 ); + fullStr += oneItem; + } + } + xmp->SetProperty ( kXMP_NS_EXIF_Aux, ""LensInfo"", fullStr.c_str(), kXMP_DeleteExisting ); + } + + #endif + + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSAltitude, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_RationalType) && (tagInfo.count == 1) ) { + + XMP_Uns32 num = exif.GetUns32 ( tagInfo.dataPtr ); + XMP_Uns32 denom = exif.GetUns32 ( (XMP_Uns8*)tagInfo.dataPtr + 4 ); + + bool fixXMP = false; + bool numNeg = num >> 31; + bool denomNeg = denom >> 31; + + if ( denomNeg ) { // The denominator looks negative, shift the sign to the numerator. + denom = -denom; + num = -num; + numNeg = num >> 31; + fixXMP = true; + } + + if ( numNeg ) { // The numerator looks negative, fix the XMP. + xmp->SetProperty ( kXMP_NS_EXIF, ""GPSAltitudeRef"", ""1"" ); + num = -num; + fixXMP = true; + } + + if ( fixXMP ) { + char buffer [32]; + snprintf ( buffer, sizeof(buffer), ""%lu/%lu"", (unsigned long) num, (unsigned long) denom ); // AUDIT: Using sizeof(buffer) is safe. + xmp->SetProperty ( kXMP_NS_EXIF, ""GPSAltitude"", buffer ); + } + + } + + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_DateTimeOriginal, &tagInfo ); + foundFromXMP = xmp->DoesPropertyExist ( kXMP_NS_EXIF, ""DateTimeOriginal"" ); + + if ( found && (! foundFromXMP) && (tagInfo.type == kTIFF_ASCIIType) ) { + ImportTIFF_Date ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""DateTimeOriginal"" ); + } + + found = exif.GetTag ( kTIFF_PrimaryIFD, kTIFF_DateTime, &tagInfo ); + foundFromXMP = xmp->DoesPropertyExist ( kXMP_NS_XMP, ""ModifyDate"" ); + + if ( found && (! foundFromXMP) && (tagInfo.type == kTIFF_ASCIIType) ) { + ImportTIFF_Date ( exif, tagInfo, xmp, kXMP_NS_XMP, ""ModifyDate"" ); + } + + + ImportTIFF_PhotographicSensitivity ( exif, xmp ); + + found = exif.GetTag ( kTIFF_PrimaryIFD, kTIFF_Artist, &tagInfo ); + foundFromXMP = xmp->DoesPropertyExist ( kXMP_NS_DC, ""creator"" ); + if ( (! found) && (! foundFromXMP) ) { + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_CameraOwnerName, &tagInfo ); + if ( found ) { + std::string xmpValue ( (char*)tagInfo.dataPtr, tagInfo.dataLen ); + xmp->AppendArrayItem ( kXMP_NS_DC, ""creator"", kXMP_PropArrayIsOrdered, xmpValue.c_str() ); + } + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_ExifVersion, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + char str[5]; + + *((XMP_Uns32*)str) = GetUns32AsIs ( tagInfo.dataPtr ); + str[4] = 0; + xmp->SetProperty ( kXMP_NS_EXIF, ""ExifVersion"", str ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_FlashpixVersion, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + char str[5]; + + *((XMP_Uns32*)str) = GetUns32AsIs ( tagInfo.dataPtr ); + str[4] = 0; + xmp->SetProperty ( kXMP_NS_EXIF, ""FlashpixVersion"", str ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_ComponentsConfiguration, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + ImportArrayTIFF_Byte ( tagInfo, xmp, kXMP_NS_EXIF, ""ComponentsConfiguration"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_UserComment, &tagInfo ); + if ( found ) { + ImportTIFF_EncodedString ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""UserComment"", true /* isLangAlt */ ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_OECF, &tagInfo ); + if ( found ) { + ImportConversionTable ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""OECF"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_Flash, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ShortType) && (tagInfo.count == 1) ) { + ImportTIFF_Flash ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""Flash"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_SpatialFrequencyResponse, &tagInfo ); + if ( found ) { + ImportConversionTable ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""SpatialFrequencyResponse"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_FileSource, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 1) ) { + ImportSingleTIFF_Byte ( tagInfo, xmp, kXMP_NS_EXIF, ""FileSource"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_SceneType, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 1) ) { + ImportSingleTIFF_Byte ( tagInfo, xmp, kXMP_NS_EXIF, ""SceneType"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_CFAPattern, &tagInfo ); + if ( found ) { + ImportTIFF_CFATable ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""CFAPattern"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_DeviceSettingDescription, &tagInfo ); + if ( found ) { + ImportTIFF_DSDTable ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""DeviceSettingDescription"" ); + } + + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSVersionID, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ByteType) && (tagInfo.count == 4) ) { + const XMP_Uns8 * binValue = (const XMP_Uns8 *) tagInfo.dataPtr; + char strOut[20];// ! Value could be up to 16 bytes: ""255.255.255.255"" plus nul. + snprintf ( strOut, sizeof(strOut), ""%u.%u.%u.%u"", // AUDIT: Use of sizeof(strOut) is safe. + binValue[0], binValue[1], binValue[2], binValue[3] ); + xmp->SetProperty ( kXMP_NS_EXIF, ""GPSVersionID"", strOut ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSLatitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSLatitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSLongitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSLongitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSTimeStamp, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_RationalType) && (tagInfo.count == 3) ) { + ImportTIFF_GPSTimeStamp ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSTimeStamp"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSDestLatitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSDestLatitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSDestLongitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSDestLongitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSProcessingMethod, &tagInfo ); + if ( found ) { + ImportTIFF_EncodedString ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSProcessingMethod"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSAreaInformation, &tagInfo ); + if ( found ) { + ImportTIFF_EncodedString ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSAreaInformation"" ); + } + +} // PhotoDataUtils::Import2WayExif +",0,"PhotoDataUtils::Import2WayExif ( const TIFF_Manager & exif, SXMPMeta * xmp, int iptcDigestState ) +{ + const bool nativeEndian = exif.IsNativeEndian(); + + bool found, foundFromXMP; + TIFF_Manager::TagInfo tagInfo; + XMP_OptionBits flags; + + ImportTIFF_StandardMappings ( kTIFF_PrimaryIFD, exif, xmp ); + ImportTIFF_StandardMappings ( kTIFF_ExifIFD, exif, xmp ); + ImportTIFF_StandardMappings ( kTIFF_GPSInfoIFD, exif, xmp ); + + + #if SupportOldExifProperties + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_CameraOwnerName, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ASCIIType) && (tagInfo.count > 0) ) { + ImportSingleTIFF ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF_Aux, ""OwnerName"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_BodySerialNumber, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ASCIIType) && (tagInfo.count > 0) ) { + ImportSingleTIFF ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF_Aux, ""SerialNumber"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_LensModel, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ASCIIType) && (tagInfo.count > 0) ) { + ImportSingleTIFF ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF_Aux, ""Lens"" ); + } + + found = xmp->GetProperty ( kXMP_NS_ExifEX, ""LensSpecification"", 0, &flags ); + if ( found && XMP_PropIsArray(flags) ) { + std::string fullStr, oneItem; + size_t count = (size_t) xmp->CountArrayItems ( kXMP_NS_ExifEX, ""LensSpecification"" ); + if ( count > 0 ) { + (void) xmp->GetArrayItem ( kXMP_NS_ExifEX, ""LensSpecification"", 1, &fullStr, 0 ); + for ( size_t i = 2; i <= count; ++i ) { + fullStr += ' '; + (void) xmp->GetArrayItem ( kXMP_NS_ExifEX, ""LensSpecification"", i, &oneItem, 0 ); + fullStr += oneItem; + } + } + xmp->SetProperty ( kXMP_NS_EXIF_Aux, ""LensInfo"", fullStr.c_str(), kXMP_DeleteExisting ); + } + + #endif + + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSAltitude, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_RationalType) && (tagInfo.count == 1) ) { + + XMP_Uns32 num = exif.GetUns32 ( tagInfo.dataPtr ); + XMP_Uns32 denom = exif.GetUns32 ( (XMP_Uns8*)tagInfo.dataPtr + 4 ); + + bool fixXMP = false; + bool numNeg = num >> 31; + bool denomNeg = denom >> 31; + + if ( denomNeg ) { // The denominator looks negative, shift the sign to the numerator. + denom = -denom; + num = -num; + numNeg = num >> 31; + fixXMP = true; + } + + if ( numNeg ) { // The numerator looks negative, fix the XMP. + xmp->SetProperty ( kXMP_NS_EXIF, ""GPSAltitudeRef"", ""1"" ); + num = -num; + fixXMP = true; + } + + if ( fixXMP ) { + char buffer [32]; + snprintf ( buffer, sizeof(buffer), ""%lu/%lu"", (unsigned long) num, (unsigned long) denom ); // AUDIT: Using sizeof(buffer) is safe. + xmp->SetProperty ( kXMP_NS_EXIF, ""GPSAltitude"", buffer ); + } + + } + + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_DateTimeOriginal, &tagInfo ); + foundFromXMP = xmp->DoesPropertyExist ( kXMP_NS_EXIF, ""DateTimeOriginal"" ); + + if ( found && (! foundFromXMP) && (tagInfo.type == kTIFF_ASCIIType) ) { + ImportTIFF_Date ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""DateTimeOriginal"" ); + } + + found = exif.GetTag ( kTIFF_PrimaryIFD, kTIFF_DateTime, &tagInfo ); + foundFromXMP = xmp->DoesPropertyExist ( kXMP_NS_XMP, ""ModifyDate"" ); + + if ( found && (! foundFromXMP) && (tagInfo.type == kTIFF_ASCIIType) ) { + ImportTIFF_Date ( exif, tagInfo, xmp, kXMP_NS_XMP, ""ModifyDate"" ); + } + + + ImportTIFF_PhotographicSensitivity ( exif, xmp ); + + found = exif.GetTag ( kTIFF_PrimaryIFD, kTIFF_Artist, &tagInfo ); + foundFromXMP = xmp->DoesPropertyExist ( kXMP_NS_DC, ""creator"" ); + if ( (! found) && (! foundFromXMP) ) { + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_CameraOwnerName, &tagInfo ); + if ( found ) { + std::string xmpValue ( (char*)tagInfo.dataPtr, tagInfo.dataLen ); + xmp->AppendArrayItem ( kXMP_NS_DC, ""creator"", kXMP_PropArrayIsOrdered, xmpValue.c_str() ); + } + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_ExifVersion, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + char str[5]; + + *((XMP_Uns32*)str) = GetUns32AsIs ( tagInfo.dataPtr ); + str[4] = 0; + xmp->SetProperty ( kXMP_NS_EXIF, ""ExifVersion"", str ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_FlashpixVersion, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + char str[5]; + + *((XMP_Uns32*)str) = GetUns32AsIs ( tagInfo.dataPtr ); + str[4] = 0; + xmp->SetProperty ( kXMP_NS_EXIF, ""FlashpixVersion"", str ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_ComponentsConfiguration, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + ImportArrayTIFF_Byte ( tagInfo, xmp, kXMP_NS_EXIF, ""ComponentsConfiguration"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_UserComment, &tagInfo ); + if ( found ) { + ImportTIFF_EncodedString ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""UserComment"", true /* isLangAlt */ ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_OECF, &tagInfo ); + if ( found ) { + ImportConversionTable ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""OECF"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_Flash, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ShortType) && (tagInfo.count == 1) ) { + ImportTIFF_Flash ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""Flash"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_SpatialFrequencyResponse, &tagInfo ); + if ( found ) { + ImportConversionTable ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""SpatialFrequencyResponse"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_FileSource, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 1) ) { + ImportSingleTIFF_Byte ( tagInfo, xmp, kXMP_NS_EXIF, ""FileSource"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_SceneType, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 1) ) { + ImportSingleTIFF_Byte ( tagInfo, xmp, kXMP_NS_EXIF, ""SceneType"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_CFAPattern, &tagInfo ); + if ( found ) { + ImportTIFF_CFATable ( tagInfo, nativeEndian, xmp, kXMP_NS_EXIF, ""CFAPattern"" ); + } + + found = exif.GetTag ( kTIFF_ExifIFD, kTIFF_DeviceSettingDescription, &tagInfo ); + if ( found ) { + ImportTIFF_DSDTable ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""DeviceSettingDescription"" ); + } + + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSVersionID, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_ByteType) && (tagInfo.count == 4) ) { + const XMP_Uns8 * binValue = (const XMP_Uns8 *) tagInfo.dataPtr; + char strOut[20];// ! Value could be up to 16 bytes: ""255.255.255.255"" plus nul. + snprintf ( strOut, sizeof(strOut), ""%u.%u.%u.%u"", // AUDIT: Use of sizeof(strOut) is safe. + binValue[0], binValue[1], binValue[2], binValue[3] ); + xmp->SetProperty ( kXMP_NS_EXIF, ""GPSVersionID"", strOut ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSLatitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSLatitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSLongitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSLongitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSTimeStamp, &tagInfo ); + if ( found && (tagInfo.type == kTIFF_RationalType) && (tagInfo.count == 3) ) { + ImportTIFF_GPSTimeStamp ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSTimeStamp"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSDestLatitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSDestLatitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSDestLongitude, &tagInfo ); + if ( found ) { + ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSDestLongitude"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSProcessingMethod, &tagInfo ); + if ( found ) { + ImportTIFF_EncodedString ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSProcessingMethod"" ); + } + + found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSAreaInformation, &tagInfo ); + if ( found ) { + ImportTIFF_EncodedString ( exif, tagInfo, xmp, kXMP_NS_EXIF, ""GPSAreaInformation"" ); + } + +} // PhotoDataUtils::Import2WayExif +","@@ -233,7 +233,7 @@ static XMP_Uns32 GatherInt ( const char * strPtr, size_t count ) + + static size_t TrimTrailingSpaces ( char * firstChar, size_t origLen ) + { +- if ( origLen == 0 ) return 0; ++ if ( !firstChar || origLen == 0 ) return 0; + + char * lastChar = firstChar + origLen - 1; + if ( (*lastChar != ' ') && (*lastChar != 0) ) return origLen; // Nothing to do.",2919,3155,4096 +18174,"MagickExport XMLTreeInfo *NewXMLTree(const char *xml,ExceptionInfo *exception) +{ + char + **attribute, + **attributes, + *tag, + *utf8; + + int + c, + terminal; + + MagickBooleanType + status; + + register char + *p; + + register ssize_t + i; + + size_t + ignore_depth, + length; + + ssize_t + j, + l; + + XMLTreeRoot + *root; + + /* + Convert xml-string to UTF8. + */ + if ((xml == (const char *) NULL) || (strlen(xml) == 0)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, + ""ParseError"",""root tag missing""); + return((XMLTreeInfo *) NULL); + } + root=(XMLTreeRoot *) NewXMLTreeTag((char *) NULL); + length=strlen(xml); + utf8=ConvertUTF16ToUTF8(xml,&length); + if (utf8 == (char *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, + ""ParseError"",""UTF16 to UTF8 failed""); + return((XMLTreeInfo *) NULL); + } + terminal=utf8[length-1]; + utf8[length-1]='\0'; + p=utf8; + while ((*p != '\0') && (*p != '<')) + p++; + if (*p == '\0') + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, + ""ParseError"",""root tag missing""); + utf8=DestroyString(utf8); + return((XMLTreeInfo *) NULL); + } + attribute=(char **) NULL; + l=0; + ignore_depth=0; + for (p++; ; p++) + { + attributes=(char **) sentinel; + tag=p; + c=(*p); + if ((isalpha((int) ((unsigned char) *p)) !=0) || (*p == '_') || + (*p == ':') || (c < '\0')) + { + /* + Tag. + */ + if (root->node == (XMLTreeInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""root tag missing""); + utf8=DestroyString(utf8); + return(&root->root); + } + p+=strcspn(p,XMLWhitespace ""/>""); + while (isspace((int) ((unsigned char) *p)) != 0) + *p++='\0'; + if (ignore_depth == 0) + { + if ((*p != '\0') && (*p != '/') && (*p != '>')) + { + /* + Find tag in default attributes list. + */ + i=0; + while ((root->attributes[i] != (char **) NULL) && + (strcmp(root->attributes[i][0],tag) != 0)) + i++; + attribute=root->attributes[i]; + } + for (l=0; (*p != '\0') && (*p != '/') && (*p != '>'); l+=2) + { + /* + Attribute. + */ + if (l == 0) + attributes=(char **) AcquireQuantumMemory(4, + sizeof(*attributes)); + else + attributes=(char **) ResizeQuantumMemory(attributes, + (size_t) (l+4),sizeof(*attributes)); + if (attributes == (char **) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,""MemoryAllocationFailed"",""`%s'"",""""); + utf8=DestroyString(utf8); + return(&root->root); + } + attributes[l+2]=(char *) NULL; + attributes[l+1]=(char *) NULL; + attributes[l]=p; + p+=strcspn(p,XMLWhitespace ""=/>""); + if ((*p != '=') && (isspace((int) ((unsigned char) *p)) == 0)) + attributes[l]=ConstantString(""""); + else + { + *p++='\0'; + p+=strspn(p,XMLWhitespace ""=""); + c=(*p); + if ((c == '""') || (c == '\'')) + { + /* + Attributes value. + */ + p++; + attributes[l+1]=p; + while ((*p != '\0') && (*p != c)) + p++; + if (*p != '\0') + *p++='\0'; + else + { + attributes[l]=ConstantString(""""); + attributes[l+1]=ConstantString(""""); + (void) DestroyXMLTreeAttributes(attributes); + (void) ThrowMagickException(exception, + GetMagickModule(),OptionWarning,""ParseError"", + ""missing %c"",c); + utf8=DestroyString(utf8); + return(&root->root); + } + j=1; + while ((attribute != (char **) NULL) && + (attribute[j] != (char *) NULL) && + (strcmp(attribute[j],attributes[l]) != 0)) + j+=3; + attributes[l+1]=ParseEntities(attributes[l+1], + root->entities,(attribute != (char **) NULL) && + (attribute[j] != (char *) NULL) ? *attribute[j+2] : + ' '); + } + attributes[l]=ConstantString(attributes[l]); + } + while (isspace((int) ((unsigned char) *p)) != 0) + p++; + } + } + else + { + while((*p != '\0') && (*p != '/') && (*p != '>')) + p++; + } + if (*p == '/') + { + /* + Self closing tag. + */ + *p++='\0'; + if (((*p != '\0') && (*p != '>')) || + ((*p == '\0') && (terminal != '>'))) + { + if (l != 0) + (void) DestroyXMLTreeAttributes(attributes); + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""missing >""); + utf8=DestroyString(utf8); + return(&root->root); + } + if ((ignore_depth == 0) && (IsSkipTag(tag) == MagickFalse)) + { + ParseOpenTag(root,tag,attributes); + (void) ParseCloseTag(root,tag,exception); + } + } + else + { + c=(*p); + if ((*p == '>') || ((*p == '\0') && (terminal == '>'))) + { + *p='\0'; + if ((ignore_depth == 0) && (IsSkipTag(tag) == MagickFalse)) + ParseOpenTag(root,tag,attributes); + else + ignore_depth++; + *p=c; + } + else + { + if (l != 0) + (void) DestroyXMLTreeAttributes(attributes); + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""missing >""); + utf8=DestroyString(utf8); + return(&root->root); + } + } + } + else + if (*p == '/') + { + /* + Close tag. + */ + tag=p+1; + p+=strcspn(tag,XMLWhitespace "">"")+1; + c=(*p); + if ((c == '\0') && (terminal != '>')) + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""missing >""); + utf8=DestroyString(utf8); + return(&root->root); + } + *p='\0'; + if (ignore_depth == 0 && ParseCloseTag(root,tag,exception) != + (XMLTreeInfo *) NULL) + { + utf8=DestroyString(utf8); + return(&root->root); + } + if (ignore_depth > 0) + ignore_depth--; + *p=c; + if (isspace((int) ((unsigned char) *p)) != 0) + p+=strspn(p,XMLWhitespace); + } + else + if (strncmp(p,""!--"",3) == 0) + { + /* + Comment. + */ + p=strstr(p+3,""--""); + if ((p == (char *) NULL) || ((*(p+=2) != '>') && (*p != '\0')) || + ((*p == '\0') && (terminal != '>'))) + { + (void) ThrowMagickException(exception,GetMagickModule(), + OptionWarning,""ParseError"",""unclosed %3d "" + ""| SWITCH_PAGE (Attr code page) |"", + *codepage_attr); + off += 2; + break; + case 0x01: /* END */ + /* BEWARE + * The Attribute END token means either "">"" or ""/>"" + * and as a consequence both must be treated separately. + * This is done in the TAG state parser. + */ + off++; + DebugLog((""ATTR: level = %u, Return: len = %u\n"", + level, off - offset)); + return (off - offset); + case 0x02: /* ENTITY */ + ent = tvb_get_guintvar (tvb, off+1, &len); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| ENTITY "" + ""| %s'&#%u;'"", + level, *codepage_attr, Indent (level), ent); + off += 1+len; + break; + case 0x03: /* STR_I */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| STR_I (Inline string) "" + ""| %s\'%s\'"", + level, *codepage_attr, Indent (level), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + case 0x04: /* LITERAL */ + /* ALWAYS means the start of a new attribute, + * and may only contain the NAME of the attribute. + */ + idx = tvb_get_guintvar (tvb, off+1, &len); + str_len = tvb_strsize (tvb, str_tbl+idx); + attr_save_known = 0; + attr_save_literal = tvb_format_text (tvb, + str_tbl+idx, str_len-1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| LITERAL (Literal Attribute) "" + ""| %s<%s />"", + level, *codepage_attr, Indent (level), + attr_save_literal); + off += 1+len; + break; + case 0x40: /* EXT_I_0 */ + case 0x41: /* EXT_I_1 */ + case 0x42: /* EXT_I_2 */ + /* Extension tokens */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| EXT_I_%1x (Extension Token) "" + ""| %s(%s: \'%s\')"", + level, *codepage_attr, peek & 0x0f, Indent (level), + map_token (map->global, 0, peek), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + /* 0x43 impossible in ATTR state */ + /* 0x44 impossible in ATTR state */ + case 0x80: /* EXT_T_0 */ + case 0x81: /* EXT_T_1 */ + case 0x82: /* EXT_T_2 */ + /* Extension tokens */ + idx = tvb_get_guintvar (tvb, off+1, &len); + { char *s; + + if (map->ext_t[peek & 0x03]) + s = (map->ext_t[peek & 0x03])(tvb, idx, str_tbl); + else + s = wmem_strdup_printf(wmem_packet_scope(), ""EXT_T_%1x (%s)"", peek & 0x03, + map_token (map->global, 0, peek)); + + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| EXT_T_%1x (Extension Token) "" + ""| %s%s)"", + level, *codepage_attr, peek & 0x0f, Indent (level), + s); + } + off += 1+len; + break; + case 0x83: /* STR_T */ + idx = tvb_get_guintvar (tvb, off+1, &len); + str_len = tvb_strsize (tvb, str_tbl+idx); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| STR_T (Tableref string) "" + ""| %s\'%s\'"", + level, *codepage_attr, Indent (level), + tvb_format_text (tvb, str_tbl+idx, str_len-1)); + off += 1+len; + break; + /* 0x84 impossible in ATTR state */ + case 0xC0: /* EXT_0 */ + case 0xC1: /* EXT_1 */ + case 0xC2: /* EXT_2 */ + /* Extension tokens */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| EXT_%1x (Extension Token) "" + ""| %s(%s)"", + level, *codepage_attr, peek & 0x0f, Indent (level), + map_token (map->global, 0, peek)); + off++; + break; + case 0xC3: /* OPAQUE - WBXML 1.1 and newer */ + if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */ + char *str; + if (attr_save_known) { /* Knwon attribute */ + if (map->opaque_binary_attr) { + str = map->opaque_binary_attr(tvb, off + 1, + attr_save_known, *codepage_attr, &len); + } else { + str = default_opaque_binary_attr(tvb, off + 1, + attr_save_known, *codepage_attr, &len); + } + } else { /* lITERAL attribute */ + if (map->opaque_literal_tag) { + str = map->opaque_literal_attr(tvb, off + 1, + attr_save_literal, *codepage_attr, &len); + } else { + str = default_opaque_literal_attr(tvb, off + 1, + attr_save_literal, *codepage_attr, &len); + } + } + proto_tree_add_text (tree, tvb, off, 1 + len, + "" %3d | Attr | A %3d "" + ""| OPAQUE (Opaque data) "" + ""| %s%s"", + level, *codepage_attr, Indent (level), str); + off += 1 + len; + } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| RESERVED_2 (Invalid Token!) "" + ""| WBXML 1.0 parsing stops here."", + level, *codepage_attr); + /* Stop processing as it is impossible to parse now */ + off = tvb_len; + DebugLog((""ATTR: level = %u, Return: len = %u\n"", + level, off - offset)); + return (off - offset); + } + break; + /* 0xC4 impossible in ATTR state */ + default: + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| %-10s (Invalid Token!) "" + ""| WBXML parsing stops here."", + level, *codepage_attr, + val_to_str_ext (peek, &vals_wbxml1x_global_tokens_ext, ""(unknown 0x%x)"")); + /* Move to end of buffer */ + off = tvb_len; + break; + } else { /* Known atribute token */ + if (peek & 0x80) { /* attrValue */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| Known attrValue 0x%02X "" + ""| %s%s"", + level, *codepage_attr, peek & 0x7f, Indent (level), + map_token (map->attrValue, *codepage_attr, peek)); + off++; + } else { /* attrStart */ + attr_save_known = peek & 0x7f; + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| Known attrStart 0x%02X "" + ""| %s%s"", + level, *codepage_attr, attr_save_known, Indent (level), + map_token (map->attrStart, *codepage_attr, peek)); + off++; + } + } + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset)); + return (off - offset); +} +",1,"parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + guint32 offset, guint32 str_tbl, guint8 level, guint8 *codepage_attr, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); + guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; + guint32 idx; + guint8 peek; + guint8 attr_save_known = 0; /* Will contain peek & 0x3F (attr identity) */ + const char *attr_save_literal = NULL; /* Will contain the LITERAL attr identity */ + + DebugLog((""parse_wbxml_attr_defined (level = %u, offset = %u)\n"", + level, offset)); + /* Parse attributes */ + last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" + ""off = %u, tvb_len = %u\n"", level, peek, off, tvb_len)); + if ((peek & 0x3F) < 5) switch (peek) { /* Global tokens + in state = ATTR */ + case 0x00: /* SWITCH_PAGE */ + *codepage_attr = tvb_get_guint8 (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 2, + "" | Attr | A -->%3d "" + ""| SWITCH_PAGE (Attr code page) |"", + *codepage_attr); + off += 2; + break; + case 0x01: /* END */ + /* BEWARE + * The Attribute END token means either "">"" or ""/>"" + * and as a consequence both must be treated separately. + * This is done in the TAG state parser. + */ + off++; + DebugLog((""ATTR: level = %u, Return: len = %u\n"", + level, off - offset)); + return (off - offset); + case 0x02: /* ENTITY */ + ent = tvb_get_guintvar (tvb, off+1, &len); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| ENTITY "" + ""| %s'&#%u;'"", + level, *codepage_attr, Indent (level), ent); + off += 1+len; + break; + case 0x03: /* STR_I */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| STR_I (Inline string) "" + ""| %s\'%s\'"", + level, *codepage_attr, Indent (level), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + case 0x04: /* LITERAL */ + /* ALWAYS means the start of a new attribute, + * and may only contain the NAME of the attribute. + */ + idx = tvb_get_guintvar (tvb, off+1, &len); + str_len = tvb_strsize (tvb, str_tbl+idx); + attr_save_known = 0; + attr_save_literal = tvb_format_text (tvb, + str_tbl+idx, str_len-1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| LITERAL (Literal Attribute) "" + ""| %s<%s />"", + level, *codepage_attr, Indent (level), + attr_save_literal); + off += 1+len; + break; + case 0x40: /* EXT_I_0 */ + case 0x41: /* EXT_I_1 */ + case 0x42: /* EXT_I_2 */ + /* Extension tokens */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| EXT_I_%1x (Extension Token) "" + ""| %s(%s: \'%s\')"", + level, *codepage_attr, peek & 0x0f, Indent (level), + map_token (map->global, 0, peek), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + /* 0x43 impossible in ATTR state */ + /* 0x44 impossible in ATTR state */ + case 0x80: /* EXT_T_0 */ + case 0x81: /* EXT_T_1 */ + case 0x82: /* EXT_T_2 */ + /* Extension tokens */ + idx = tvb_get_guintvar (tvb, off+1, &len); + { char *s; + + if (map->ext_t[peek & 0x03]) + s = (map->ext_t[peek & 0x03])(tvb, idx, str_tbl); + else + s = wmem_strdup_printf(wmem_packet_scope(), ""EXT_T_%1x (%s)"", peek & 0x03, + map_token (map->global, 0, peek)); + + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| EXT_T_%1x (Extension Token) "" + ""| %s%s)"", + level, *codepage_attr, peek & 0x0f, Indent (level), + s); + } + off += 1+len; + break; + case 0x83: /* STR_T */ + idx = tvb_get_guintvar (tvb, off+1, &len); + str_len = tvb_strsize (tvb, str_tbl+idx); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Attr | A %3d "" + ""| STR_T (Tableref string) "" + ""| %s\'%s\'"", + level, *codepage_attr, Indent (level), + tvb_format_text (tvb, str_tbl+idx, str_len-1)); + off += 1+len; + break; + /* 0x84 impossible in ATTR state */ + case 0xC0: /* EXT_0 */ + case 0xC1: /* EXT_1 */ + case 0xC2: /* EXT_2 */ + /* Extension tokens */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| EXT_%1x (Extension Token) "" + ""| %s(%s)"", + level, *codepage_attr, peek & 0x0f, Indent (level), + map_token (map->global, 0, peek)); + off++; + break; + case 0xC3: /* OPAQUE - WBXML 1.1 and newer */ + if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */ + char *str; + if (attr_save_known) { /* Knwon attribute */ + if (map->opaque_binary_attr) { + str = map->opaque_binary_attr(tvb, off + 1, + attr_save_known, *codepage_attr, &len); + } else { + str = default_opaque_binary_attr(tvb, off + 1, + attr_save_known, *codepage_attr, &len); + } + } else { /* lITERAL attribute */ + if (map->opaque_literal_tag) { + str = map->opaque_literal_attr(tvb, off + 1, + attr_save_literal, *codepage_attr, &len); + } else { + str = default_opaque_literal_attr(tvb, off + 1, + attr_save_literal, *codepage_attr, &len); + } + } + proto_tree_add_text (tree, tvb, off, 1 + len, + "" %3d | Attr | A %3d "" + ""| OPAQUE (Opaque data) "" + ""| %s%s"", + level, *codepage_attr, Indent (level), str); + off += 1 + len; + } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| RESERVED_2 (Invalid Token!) "" + ""| WBXML 1.0 parsing stops here."", + level, *codepage_attr); + /* Stop processing as it is impossible to parse now */ + off = tvb_len; + DebugLog((""ATTR: level = %u, Return: len = %u\n"", + level, off - offset)); + return (off - offset); + } + break; + /* 0xC4 impossible in ATTR state */ + default: + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| %-10s (Invalid Token!) "" + ""| WBXML parsing stops here."", + level, *codepage_attr, + val_to_str_ext (peek, &vals_wbxml1x_global_tokens_ext, ""(unknown 0x%x)"")); + /* Move to end of buffer */ + off = tvb_len; + break; + } else { /* Known atribute token */ + if (peek & 0x80) { /* attrValue */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| Known attrValue 0x%02X "" + ""| %s%s"", + level, *codepage_attr, peek & 0x7f, Indent (level), + map_token (map->attrValue, *codepage_attr, peek)); + off++; + } else { /* attrStart */ + attr_save_known = peek & 0x7f; + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Attr | A %3d "" + ""| Known attrStart 0x%02X "" + ""| %s%s"", + level, *codepage_attr, attr_save_known, Indent (level), + map_token (map->attrStart, *codepage_attr, peek)); + off++; + } + } + if (off < last_off) { + THROW(ReportedBoundsError); + } + last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset)); + return (off - offset); +} +","@@ -7304,7 +7304,7 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -7323,6 +7323,7 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag_defined (level = %u, offset = %u)\n"", *level, offset)); ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); +@@ -7694,6 +7695,10 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", *level, off - offset)); + return (off - offset); +@@ -7711,7 +7716,7 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + guint8 *codepage_stag, guint8 *codepage_attr) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -7732,6 +7737,7 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag (level = %u, offset = %u)\n"", *level, offset)); ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); +@@ -8091,6 +8097,10 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", + *level, off - offset)); +@@ -8126,7 +8136,7 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -8138,6 +8148,7 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + DebugLog((""parse_wbxml_attr_defined (level = %u, offset = %u)\n"", + level, offset)); + /* Parse attributes */ ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" +@@ -8330,6 +8341,10 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + off++; + } + } ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset)); +@@ -8350,7 +8365,7 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + guint32 offset, guint32 str_tbl, guint8 level, guint8 *codepage_attr) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -8359,6 +8374,7 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + + DebugLog((""parse_wbxml_attr (level = %u, offset = %u)\n"", level, offset)); + /* Parse attributes */ ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" +@@ -8516,6 +8532,10 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + off++; + } + } ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset));",2515,2751,4096 +980,"select_and_cluster(void) +{ + peer_t *p; + llist_t *item; + int i, j; + int size = 3 * G.peer_cnt; + /* for selection algorithm */ + point_t point[size]; + unsigned num_points, num_candidates; + double low, high; + unsigned num_falsetickers; + /* for cluster algorithm */ + survivor_t survivor[size]; + unsigned num_survivors; + + /* Selection */ + + num_points = 0; + item = G.ntp_peers; + while (item != NULL) { + double rd, offset; + + p = (peer_t *) item->data; + rd = root_distance(p); + offset = p->filter_offset; + if (!fit(p, rd)) { + item = item->link; + continue; + } + + VERB5 bb_error_msg(""interval: [%f %f %f] %s"", + offset - rd, + offset, + offset + rd, + p->p_dotted + ); + point[num_points].p = p; + point[num_points].type = -1; + point[num_points].edge = offset - rd; + point[num_points].opt_rd = rd; + num_points++; + point[num_points].p = p; + point[num_points].type = 0; + point[num_points].edge = offset; + point[num_points].opt_rd = rd; + num_points++; + point[num_points].p = p; + point[num_points].type = 1; + point[num_points].edge = offset + rd; + point[num_points].opt_rd = rd; + num_points++; + item = item->link; + } + num_candidates = num_points / 3; + if (num_candidates == 0) { + VERB3 bb_error_msg(""no valid datapoints%s"", "", no peer selected""); + return NULL; + } + qsort(point, num_points, sizeof(point[0]), compare_point_edge); + + /* Start with the assumption that there are no falsetickers. + * Attempt to find a nonempty intersection interval containing + * the midpoints of all truechimers. + * If a nonempty interval cannot be found, increase the number + * of assumed falsetickers by one and try again. + * If a nonempty interval is found and the number of falsetickers + * is less than the number of truechimers, a majority has been found + * and the midpoint of each truechimer represents + * the candidates available to the cluster algorithm. + */ + num_falsetickers = 0; + while (1) { + int c; + unsigned num_midpoints = 0; + + low = 1 << 9; + high = - (1 << 9); + c = 0; + for (i = 0; i < num_points; i++) { + /* We want to do: + * if (point[i].type == -1) c++; + * if (point[i].type == 1) c--; + * and it's simpler to do it this way: + */ + c -= point[i].type; + if (c >= num_candidates - num_falsetickers) { + /* If it was c++ and it got big enough... */ + low = point[i].edge; + break; + } + if (point[i].type == 0) + num_midpoints++; + } + c = 0; + for (i = num_points-1; i >= 0; i--) { + c += point[i].type; + if (c >= num_candidates - num_falsetickers) { + high = point[i].edge; + break; + } + if (point[i].type == 0) + num_midpoints++; + } + /* If the number of midpoints is greater than the number + * of allowed falsetickers, the intersection contains at + * least one truechimer with no midpoint - bad. + * Also, interval should be nonempty. + */ + if (num_midpoints <= num_falsetickers && low < high) + break; + num_falsetickers++; + if (num_falsetickers * 2 >= num_candidates) { + VERB3 bb_error_msg(""falsetickers:%d, candidates:%d%s"", + num_falsetickers, num_candidates, + "", no peer selected""); + return NULL; + } + } + VERB4 bb_error_msg(""selected interval: [%f, %f]; candidates:%d falsetickers:%d"", + low, high, num_candidates, num_falsetickers); + + /* Clustering */ + + /* Construct a list of survivors (p, metric) + * from the chime list, where metric is dominated + * first by stratum and then by root distance. + * All other things being equal, this is the order of preference. + */ + num_survivors = 0; + for (i = 0; i < num_points; i++) { + if (point[i].edge < low || point[i].edge > high) + continue; + p = point[i].p; + survivor[num_survivors].p = p; + /* x.opt_rd == root_distance(p); */ + survivor[num_survivors].metric = MAXDIST * p->lastpkt_stratum + point[i].opt_rd; + VERB5 bb_error_msg(""survivor[%d] metric:%f peer:%s"", + num_survivors, survivor[num_survivors].metric, p->p_dotted); + num_survivors++; + } + /* There must be at least MIN_SELECTED survivors to satisfy the + * correctness assertions. Ordinarily, the Byzantine criteria + * require four survivors, but for the demonstration here, one + * is acceptable. + */ + if (num_survivors < MIN_SELECTED) { + VERB3 bb_error_msg(""survivors:%d%s"", + num_survivors, + "", no peer selected""); + return NULL; + } + + qsort(survivor, num_survivors, sizeof(survivor[0]), compare_survivor_metric); + + /* For each association p in turn, calculate the selection + * jitter p->sjitter as the square root of the sum of squares + * (p->offset - q->offset) over all q associations. The idea is + * to repeatedly discard the survivor with maximum selection + * jitter until a termination condition is met. + */ + while (1) { + unsigned max_idx = max_idx; + double max_selection_jitter = max_selection_jitter; + double min_jitter = min_jitter; + + if (num_survivors <= MIN_CLUSTERED) { + VERB4 bb_error_msg(""num_survivors %d <= %d, not discarding more"", + num_survivors, MIN_CLUSTERED); + break; + } + + /* To make sure a few survivors are left + * for the clustering algorithm to chew on, + * we stop if the number of survivors + * is less than or equal to MIN_CLUSTERED (3). + */ + for (i = 0; i < num_survivors; i++) { + double selection_jitter_sq; + + p = survivor[i].p; + if (i == 0 || p->filter_jitter < min_jitter) + min_jitter = p->filter_jitter; + + selection_jitter_sq = 0; + for (j = 0; j < num_survivors; j++) { + peer_t *q = survivor[j].p; + selection_jitter_sq += SQUARE(p->filter_offset - q->filter_offset); + } + if (i == 0 || selection_jitter_sq > max_selection_jitter) { + max_selection_jitter = selection_jitter_sq; + max_idx = i; + } + VERB6 bb_error_msg(""survivor %d selection_jitter^2:%f"", + i, selection_jitter_sq); + } + max_selection_jitter = SQRT(max_selection_jitter / num_survivors); + VERB5 bb_error_msg(""max_selection_jitter (at %d):%f min_jitter:%f"", + max_idx, max_selection_jitter, min_jitter); + + /* If the maximum selection jitter is less than the + * minimum peer jitter, then tossing out more survivors + * will not lower the minimum peer jitter, so we might + * as well stop. + */ + if (max_selection_jitter < min_jitter) { + VERB4 bb_error_msg(""max_selection_jitter:%f < min_jitter:%f, num_survivors:%d, not discarding more"", + max_selection_jitter, min_jitter, num_survivors); + break; + } + + /* Delete survivor[max_idx] from the list + * and go around again. + */ + VERB6 bb_error_msg(""dropping survivor %d"", max_idx); + num_survivors--; + while (max_idx < num_survivors) { + survivor[max_idx] = survivor[max_idx + 1]; + max_idx++; + } + } + + if (0) { + /* Combine the offsets of the clustering algorithm survivors + * using a weighted average with weight determined by the root + * distance. Compute the selection jitter as the weighted RMS + * difference between the first survivor and the remaining + * survivors. In some cases the inherent clock jitter can be + * reduced by not using this algorithm, especially when frequent + * clockhopping is involved. bbox: thus we don't do it. + */ + double x, y, z, w; + y = z = w = 0; + for (i = 0; i < num_survivors; i++) { + p = survivor[i].p; + x = root_distance(p); + y += 1 / x; + z += p->filter_offset / x; + w += SQUARE(p->filter_offset - survivor[0].p->filter_offset) / x; + } + } + + /* Pick the best clock. If the old system peer is on the list + * and at the same stratum as the first survivor on the list, + * then don't do a clock hop. Otherwise, select the first + * survivor on the list as the new system peer. + */ + p = survivor[0].p; + if (G.last_update_peer + && G.last_update_peer->lastpkt_stratum <= p->lastpkt_stratum + ) { + /* Starting from 1 is ok here */ + for (i = 1; i < num_survivors; i++) { + if (G.last_update_peer == survivor[i].p) { + VERB5 bb_error_msg(""keeping old synced peer""); + p = G.last_update_peer; + goto keep_old; + } + } + } + G.last_update_peer = p; + keep_old: + VERB4 bb_error_msg(""selected peer %s filter_offset:%+f age:%f"", + p->p_dotted, + p->filter_offset, + G.cur_time - p->lastpkt_recv_time + ); + return p; +} +",0,"select_and_cluster(void) +{ + peer_t *p; + llist_t *item; + int i, j; + int size = 3 * G.peer_cnt; + /* for selection algorithm */ + point_t point[size]; + unsigned num_points, num_candidates; + double low, high; + unsigned num_falsetickers; + /* for cluster algorithm */ + survivor_t survivor[size]; + unsigned num_survivors; + + /* Selection */ + + num_points = 0; + item = G.ntp_peers; + while (item != NULL) { + double rd, offset; + + p = (peer_t *) item->data; + rd = root_distance(p); + offset = p->filter_offset; + if (!fit(p, rd)) { + item = item->link; + continue; + } + + VERB5 bb_error_msg(""interval: [%f %f %f] %s"", + offset - rd, + offset, + offset + rd, + p->p_dotted + ); + point[num_points].p = p; + point[num_points].type = -1; + point[num_points].edge = offset - rd; + point[num_points].opt_rd = rd; + num_points++; + point[num_points].p = p; + point[num_points].type = 0; + point[num_points].edge = offset; + point[num_points].opt_rd = rd; + num_points++; + point[num_points].p = p; + point[num_points].type = 1; + point[num_points].edge = offset + rd; + point[num_points].opt_rd = rd; + num_points++; + item = item->link; + } + num_candidates = num_points / 3; + if (num_candidates == 0) { + VERB3 bb_error_msg(""no valid datapoints%s"", "", no peer selected""); + return NULL; + } + qsort(point, num_points, sizeof(point[0]), compare_point_edge); + + /* Start with the assumption that there are no falsetickers. + * Attempt to find a nonempty intersection interval containing + * the midpoints of all truechimers. + * If a nonempty interval cannot be found, increase the number + * of assumed falsetickers by one and try again. + * If a nonempty interval is found and the number of falsetickers + * is less than the number of truechimers, a majority has been found + * and the midpoint of each truechimer represents + * the candidates available to the cluster algorithm. + */ + num_falsetickers = 0; + while (1) { + int c; + unsigned num_midpoints = 0; + + low = 1 << 9; + high = - (1 << 9); + c = 0; + for (i = 0; i < num_points; i++) { + /* We want to do: + * if (point[i].type == -1) c++; + * if (point[i].type == 1) c--; + * and it's simpler to do it this way: + */ + c -= point[i].type; + if (c >= num_candidates - num_falsetickers) { + /* If it was c++ and it got big enough... */ + low = point[i].edge; + break; + } + if (point[i].type == 0) + num_midpoints++; + } + c = 0; + for (i = num_points-1; i >= 0; i--) { + c += point[i].type; + if (c >= num_candidates - num_falsetickers) { + high = point[i].edge; + break; + } + if (point[i].type == 0) + num_midpoints++; + } + /* If the number of midpoints is greater than the number + * of allowed falsetickers, the intersection contains at + * least one truechimer with no midpoint - bad. + * Also, interval should be nonempty. + */ + if (num_midpoints <= num_falsetickers && low < high) + break; + num_falsetickers++; + if (num_falsetickers * 2 >= num_candidates) { + VERB3 bb_error_msg(""falsetickers:%d, candidates:%d%s"", + num_falsetickers, num_candidates, + "", no peer selected""); + return NULL; + } + } + VERB4 bb_error_msg(""selected interval: [%f, %f]; candidates:%d falsetickers:%d"", + low, high, num_candidates, num_falsetickers); + + /* Clustering */ + + /* Construct a list of survivors (p, metric) + * from the chime list, where metric is dominated + * first by stratum and then by root distance. + * All other things being equal, this is the order of preference. + */ + num_survivors = 0; + for (i = 0; i < num_points; i++) { + if (point[i].edge < low || point[i].edge > high) + continue; + p = point[i].p; + survivor[num_survivors].p = p; + /* x.opt_rd == root_distance(p); */ + survivor[num_survivors].metric = MAXDIST * p->lastpkt_stratum + point[i].opt_rd; + VERB5 bb_error_msg(""survivor[%d] metric:%f peer:%s"", + num_survivors, survivor[num_survivors].metric, p->p_dotted); + num_survivors++; + } + /* There must be at least MIN_SELECTED survivors to satisfy the + * correctness assertions. Ordinarily, the Byzantine criteria + * require four survivors, but for the demonstration here, one + * is acceptable. + */ + if (num_survivors < MIN_SELECTED) { + VERB3 bb_error_msg(""survivors:%d%s"", + num_survivors, + "", no peer selected""); + return NULL; + } + + qsort(survivor, num_survivors, sizeof(survivor[0]), compare_survivor_metric); + + /* For each association p in turn, calculate the selection + * jitter p->sjitter as the square root of the sum of squares + * (p->offset - q->offset) over all q associations. The idea is + * to repeatedly discard the survivor with maximum selection + * jitter until a termination condition is met. + */ + while (1) { + unsigned max_idx = max_idx; + double max_selection_jitter = max_selection_jitter; + double min_jitter = min_jitter; + + if (num_survivors <= MIN_CLUSTERED) { + VERB4 bb_error_msg(""num_survivors %d <= %d, not discarding more"", + num_survivors, MIN_CLUSTERED); + break; + } + + /* To make sure a few survivors are left + * for the clustering algorithm to chew on, + * we stop if the number of survivors + * is less than or equal to MIN_CLUSTERED (3). + */ + for (i = 0; i < num_survivors; i++) { + double selection_jitter_sq; + + p = survivor[i].p; + if (i == 0 || p->filter_jitter < min_jitter) + min_jitter = p->filter_jitter; + + selection_jitter_sq = 0; + for (j = 0; j < num_survivors; j++) { + peer_t *q = survivor[j].p; + selection_jitter_sq += SQUARE(p->filter_offset - q->filter_offset); + } + if (i == 0 || selection_jitter_sq > max_selection_jitter) { + max_selection_jitter = selection_jitter_sq; + max_idx = i; + } + VERB6 bb_error_msg(""survivor %d selection_jitter^2:%f"", + i, selection_jitter_sq); + } + max_selection_jitter = SQRT(max_selection_jitter / num_survivors); + VERB5 bb_error_msg(""max_selection_jitter (at %d):%f min_jitter:%f"", + max_idx, max_selection_jitter, min_jitter); + + /* If the maximum selection jitter is less than the + * minimum peer jitter, then tossing out more survivors + * will not lower the minimum peer jitter, so we might + * as well stop. + */ + if (max_selection_jitter < min_jitter) { + VERB4 bb_error_msg(""max_selection_jitter:%f < min_jitter:%f, num_survivors:%d, not discarding more"", + max_selection_jitter, min_jitter, num_survivors); + break; + } + + /* Delete survivor[max_idx] from the list + * and go around again. + */ + VERB6 bb_error_msg(""dropping survivor %d"", max_idx); + num_survivors--; + while (max_idx < num_survivors) { + survivor[max_idx] = survivor[max_idx + 1]; + max_idx++; + } + } + + if (0) { + /* Combine the offsets of the clustering algorithm survivors + * using a weighted average with weight determined by the root + * distance. Compute the selection jitter as the weighted RMS + * difference between the first survivor and the remaining + * survivors. In some cases the inherent clock jitter can be + * reduced by not using this algorithm, especially when frequent + * clockhopping is involved. bbox: thus we don't do it. + */ + double x, y, z, w; + y = z = w = 0; + for (i = 0; i < num_survivors; i++) { + p = survivor[i].p; + x = root_distance(p); + y += 1 / x; + z += p->filter_offset / x; + w += SQUARE(p->filter_offset - survivor[0].p->filter_offset) / x; + } + } + + /* Pick the best clock. If the old system peer is on the list + * and at the same stratum as the first survivor on the list, + * then don't do a clock hop. Otherwise, select the first + * survivor on the list as the new system peer. + */ + p = survivor[0].p; + if (G.last_update_peer + && G.last_update_peer->lastpkt_stratum <= p->lastpkt_stratum + ) { + /* Starting from 1 is ok here */ + for (i = 1; i < num_survivors; i++) { + if (G.last_update_peer == survivor[i].p) { + VERB5 bb_error_msg(""keeping old synced peer""); + p = G.last_update_peer; + goto keep_old; + } + } + } + G.last_update_peer = p; + keep_old: + VERB4 bb_error_msg(""selected peer %s filter_offset:%+f age:%f"", + p->p_dotted, + p->filter_offset, + G.cur_time - p->lastpkt_recv_time + ); + return p; +} +","@@ -2051,6 +2051,13 @@ recv_and_process_client_pkt(void /*int fd*/) + goto bail; + } + ++ /* Respond only to client and symmetric active packets */ ++ if ((msg.m_status & MODE_MASK) != MODE_CLIENT ++ && (msg.m_status & MODE_MASK) != MODE_SYM_ACT ++ ) { ++ goto bail; ++ } ++ + query_status = msg.m_status; + query_xmttime = msg.m_xmttime;",2418,2654,4096 +17909,"int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, + int offset, int len, int odd, struct sk_buff *skb), + void *from, int length, int transhdrlen, + int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6, + struct rt6_info *rt, unsigned int flags, int dontfrag) +{ + struct inet_sock *inet = inet_sk(sk); + struct ipv6_pinfo *np = inet6_sk(sk); + struct inet_cork *cork; + struct sk_buff *skb, *skb_prev = NULL; + unsigned int maxfraglen, fragheaderlen; + int exthdrlen; + int dst_exthdrlen; + int hh_len; + int mtu; + int copy; + int err; + int offset = 0; + __u8 tx_flags = 0; + + if (flags&MSG_PROBE) + return 0; + cork = &inet->cork.base; + if (skb_queue_empty(&sk->sk_write_queue)) { + /* + * setup for corking + */ + if (opt) { + if (WARN_ON(np->cork.opt)) + return -EINVAL; + + np->cork.opt = kzalloc(opt->tot_len, sk->sk_allocation); + if (unlikely(np->cork.opt == NULL)) + return -ENOBUFS; + + np->cork.opt->tot_len = opt->tot_len; + np->cork.opt->opt_flen = opt->opt_flen; + np->cork.opt->opt_nflen = opt->opt_nflen; + + np->cork.opt->dst0opt = ip6_opt_dup(opt->dst0opt, + sk->sk_allocation); + if (opt->dst0opt && !np->cork.opt->dst0opt) + return -ENOBUFS; + + np->cork.opt->dst1opt = ip6_opt_dup(opt->dst1opt, + sk->sk_allocation); + if (opt->dst1opt && !np->cork.opt->dst1opt) + return -ENOBUFS; + + np->cork.opt->hopopt = ip6_opt_dup(opt->hopopt, + sk->sk_allocation); + if (opt->hopopt && !np->cork.opt->hopopt) + return -ENOBUFS; + + np->cork.opt->srcrt = ip6_rthdr_dup(opt->srcrt, + sk->sk_allocation); + if (opt->srcrt && !np->cork.opt->srcrt) + return -ENOBUFS; + + /* need source address above miyazawa*/ + } + dst_hold(&rt->dst); + cork->dst = &rt->dst; + inet->cork.fl.u.ip6 = *fl6; + np->cork.hop_limit = hlimit; + np->cork.tclass = tclass; + if (rt->dst.flags & DST_XFRM_TUNNEL) + mtu = np->pmtudisc == IPV6_PMTUDISC_PROBE ? + rt->dst.dev->mtu : dst_mtu(&rt->dst); + else + mtu = np->pmtudisc == IPV6_PMTUDISC_PROBE ? + rt->dst.dev->mtu : dst_mtu(rt->dst.path); + if (np->frag_size < mtu) { + if (np->frag_size) + mtu = np->frag_size; + } + cork->fragsize = mtu; + if (dst_allfrag(rt->dst.path)) + cork->flags |= IPCORK_ALLFRAG; + cork->length = 0; + exthdrlen = (opt ? opt->opt_flen : 0); + length += exthdrlen; + transhdrlen += exthdrlen; + dst_exthdrlen = rt->dst.header_len - rt->rt6i_nfheader_len; + } else { + rt = (struct rt6_info *)cork->dst; + fl6 = &inet->cork.fl.u.ip6; + opt = np->cork.opt; + transhdrlen = 0; + exthdrlen = 0; + dst_exthdrlen = 0; + mtu = cork->fragsize; + } + + hh_len = LL_RESERVED_SPACE(rt->dst.dev); + + fragheaderlen = sizeof(struct ipv6hdr) + rt->rt6i_nfheader_len + + (opt ? opt->opt_nflen : 0); + maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr); + + if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) { + if (cork->length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) { + ipv6_local_error(sk, EMSGSIZE, fl6, mtu-exthdrlen); + return -EMSGSIZE; + } + } + + /* For UDP, check if TX timestamp is enabled */ + if (sk->sk_type == SOCK_DGRAM) + sock_tx_timestamp(sk, &tx_flags); + + /* + * Let's try using as much space as possible. + * Use MTU if total length of the message fits into the MTU. + * Otherwise, we need to reserve fragment header and + * fragment alignment (= 8-15 octects, in total). + * + * Note that we may need to ""move"" the data from the tail of + * of the buffer to the new fragment when we split + * the message. + * + * FIXME: It may be fragmented into multiple chunks + * at once if non-fragmentable extension headers + * are too large. + * --yoshfuji + */ + + cork->length += length; + if (length > mtu) { + int proto = sk->sk_protocol; + if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){ + ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen); + return -EMSGSIZE; + } + + if (proto == IPPROTO_UDP && + (rt->dst.dev->features & NETIF_F_UFO)) { + + err = ip6_ufo_append_data(sk, getfrag, from, length, + hh_len, fragheaderlen, + transhdrlen, mtu, flags, rt); + if (err) + goto error; + return 0; + } + } + + if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) + goto alloc_new_skb; + + while (length > 0) { + /* Check if the remaining data fits into current packet. */ + copy = (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - skb->len; + if (copy < length) + copy = maxfraglen - skb->len; + + if (copy <= 0) { + char *data; + unsigned int datalen; + unsigned int fraglen; + unsigned int fraggap; + unsigned int alloclen; +alloc_new_skb: + /* There's no room in the current skb */ + if (skb) + fraggap = skb->len - maxfraglen; + else + fraggap = 0; + /* update mtu and maxfraglen if necessary */ + if (skb == NULL || skb_prev == NULL) + ip6_append_data_mtu(&mtu, &maxfraglen, + fragheaderlen, skb, rt); + + skb_prev = skb; + + /* + * If remaining data exceeds the mtu, + * we know we need more fragment(s). + */ + datalen = length + fraggap; + + if (datalen > (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - fragheaderlen) + datalen = maxfraglen - fragheaderlen - rt->dst.trailer_len; + if ((flags & MSG_MORE) && + !(rt->dst.dev->features&NETIF_F_SG)) + alloclen = mtu; + else + alloclen = datalen + fragheaderlen; + + alloclen += dst_exthdrlen; + + if (datalen != length + fraggap) { + /* + * this is not the last fragment, the trailer + * space is regarded as data space. + */ + datalen += rt->dst.trailer_len; + } + + alloclen += rt->dst.trailer_len; + fraglen = datalen + fragheaderlen; + + /* + * We just reserve space for fragment header. + * Note: this may be overallocation if the message + * (without MSG_MORE) fits into the MTU. + */ + alloclen += sizeof(struct frag_hdr); + + if (transhdrlen) { + skb = sock_alloc_send_skb(sk, + alloclen + hh_len, + (flags & MSG_DONTWAIT), &err); + } else { + skb = NULL; + if (atomic_read(&sk->sk_wmem_alloc) <= + 2 * sk->sk_sndbuf) + skb = sock_wmalloc(sk, + alloclen + hh_len, 1, + sk->sk_allocation); + if (unlikely(skb == NULL)) + err = -ENOBUFS; + else { + /* Only the initial fragment + * is time stamped. + */ + tx_flags = 0; + } + } + if (skb == NULL) + goto error; + /* + * Fill in the control structures + */ + skb->ip_summed = CHECKSUM_NONE; + skb->csum = 0; + /* reserve for fragmentation and ipsec header */ + skb_reserve(skb, hh_len + sizeof(struct frag_hdr) + + dst_exthdrlen); + + if (sk->sk_type == SOCK_DGRAM) + skb_shinfo(skb)->tx_flags = tx_flags; + + /* + * Find where to start putting bytes + */ + data = skb_put(skb, fraglen); + skb_set_network_header(skb, exthdrlen); + data += fragheaderlen; + skb->transport_header = (skb->network_header + + fragheaderlen); + if (fraggap) { + skb->csum = skb_copy_and_csum_bits( + skb_prev, maxfraglen, + data + transhdrlen, fraggap, 0); + skb_prev->csum = csum_sub(skb_prev->csum, + skb->csum); + data += fraggap; + pskb_trim_unique(skb_prev, maxfraglen); + } + copy = datalen - transhdrlen - fraggap; + + if (copy < 0) { + err = -EINVAL; + kfree_skb(skb); + goto error; + } else if (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, fraggap, skb) < 0) { + err = -EFAULT; + kfree_skb(skb); + goto error; + } + + offset += copy; + length -= datalen - fraggap; + transhdrlen = 0; + exthdrlen = 0; + dst_exthdrlen = 0; + + /* + * Put the packet on the pending queue + */ + __skb_queue_tail(&sk->sk_write_queue, skb); + continue; + } + + if (copy > length) + copy = length; + + if (!(rt->dst.dev->features&NETIF_F_SG)) { + unsigned int off; + + off = skb->len; + if (getfrag(from, skb_put(skb, copy), + offset, copy, off, skb) < 0) { + __skb_trim(skb, off); + err = -EFAULT; + goto error; + } + } else { + int i = skb_shinfo(skb)->nr_frags; + struct page_frag *pfrag = sk_page_frag(sk); + + err = -ENOMEM; + if (!sk_page_frag_refill(sk, pfrag)) + goto error; + + if (!skb_can_coalesce(skb, i, pfrag->page, + pfrag->offset)) { + err = -EMSGSIZE; + if (i == MAX_SKB_FRAGS) + goto error; + + __skb_fill_page_desc(skb, i, pfrag->page, + pfrag->offset, 0); + skb_shinfo(skb)->nr_frags = ++i; + get_page(pfrag->page); + } + copy = min_t(int, copy, pfrag->size - pfrag->offset); + if (getfrag(from, + page_address(pfrag->page) + pfrag->offset, + offset, copy, skb->len, skb) < 0) + goto error_efault; + + pfrag->offset += copy; + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); + skb->len += copy; + skb->data_len += copy; + skb->truesize += copy; + atomic_add(copy, &sk->sk_wmem_alloc); + } + offset += copy; + length -= copy; + } + + return 0; + +error_efault: + err = -EFAULT; +error: + cork->length -= length; + IP6_INC_STATS(sock_net(sk), rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS); + return err; +} +",1,"int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, + int offset, int len, int odd, struct sk_buff *skb), + void *from, int length, int transhdrlen, + int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6, + struct rt6_info *rt, unsigned int flags, int dontfrag) +{ + struct inet_sock *inet = inet_sk(sk); + struct ipv6_pinfo *np = inet6_sk(sk); + struct inet_cork *cork; + struct sk_buff *skb, *skb_prev = NULL; + unsigned int maxfraglen, fragheaderlen, mtu; + int exthdrlen; + int dst_exthdrlen; + int hh_len; + int copy; + int err; + int offset = 0; + __u8 tx_flags = 0; + + if (flags&MSG_PROBE) + return 0; + cork = &inet->cork.base; + if (skb_queue_empty(&sk->sk_write_queue)) { + /* + * setup for corking + */ + if (opt) { + if (WARN_ON(np->cork.opt)) + return -EINVAL; + + np->cork.opt = kzalloc(opt->tot_len, sk->sk_allocation); + if (unlikely(np->cork.opt == NULL)) + return -ENOBUFS; + + np->cork.opt->tot_len = opt->tot_len; + np->cork.opt->opt_flen = opt->opt_flen; + np->cork.opt->opt_nflen = opt->opt_nflen; + + np->cork.opt->dst0opt = ip6_opt_dup(opt->dst0opt, + sk->sk_allocation); + if (opt->dst0opt && !np->cork.opt->dst0opt) + return -ENOBUFS; + + np->cork.opt->dst1opt = ip6_opt_dup(opt->dst1opt, + sk->sk_allocation); + if (opt->dst1opt && !np->cork.opt->dst1opt) + return -ENOBUFS; + + np->cork.opt->hopopt = ip6_opt_dup(opt->hopopt, + sk->sk_allocation); + if (opt->hopopt && !np->cork.opt->hopopt) + return -ENOBUFS; + + np->cork.opt->srcrt = ip6_rthdr_dup(opt->srcrt, + sk->sk_allocation); + if (opt->srcrt && !np->cork.opt->srcrt) + return -ENOBUFS; + + /* need source address above miyazawa*/ + } + dst_hold(&rt->dst); + cork->dst = &rt->dst; + inet->cork.fl.u.ip6 = *fl6; + np->cork.hop_limit = hlimit; + np->cork.tclass = tclass; + if (rt->dst.flags & DST_XFRM_TUNNEL) + mtu = np->pmtudisc == IPV6_PMTUDISC_PROBE ? + rt->dst.dev->mtu : dst_mtu(&rt->dst); + else + mtu = np->pmtudisc == IPV6_PMTUDISC_PROBE ? + rt->dst.dev->mtu : dst_mtu(rt->dst.path); + if (np->frag_size < mtu) { + if (np->frag_size) + mtu = np->frag_size; + } + cork->fragsize = mtu; + if (dst_allfrag(rt->dst.path)) + cork->flags |= IPCORK_ALLFRAG; + cork->length = 0; + exthdrlen = (opt ? opt->opt_flen : 0); + length += exthdrlen; + transhdrlen += exthdrlen; + dst_exthdrlen = rt->dst.header_len - rt->rt6i_nfheader_len; + } else { + rt = (struct rt6_info *)cork->dst; + fl6 = &inet->cork.fl.u.ip6; + opt = np->cork.opt; + transhdrlen = 0; + exthdrlen = 0; + dst_exthdrlen = 0; + mtu = cork->fragsize; + } + + hh_len = LL_RESERVED_SPACE(rt->dst.dev); + + fragheaderlen = sizeof(struct ipv6hdr) + rt->rt6i_nfheader_len + + (opt ? opt->opt_nflen : 0); + maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr); + + if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) { + if (cork->length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) { + ipv6_local_error(sk, EMSGSIZE, fl6, mtu-exthdrlen); + return -EMSGSIZE; + } + } + + /* For UDP, check if TX timestamp is enabled */ + if (sk->sk_type == SOCK_DGRAM) + sock_tx_timestamp(sk, &tx_flags); + + /* + * Let's try using as much space as possible. + * Use MTU if total length of the message fits into the MTU. + * Otherwise, we need to reserve fragment header and + * fragment alignment (= 8-15 octects, in total). + * + * Note that we may need to ""move"" the data from the tail of + * of the buffer to the new fragment when we split + * the message. + * + * FIXME: It may be fragmented into multiple chunks + * at once if non-fragmentable extension headers + * are too large. + * --yoshfuji + */ + + cork->length += length; + if (length > mtu) { + int proto = sk->sk_protocol; + if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){ + ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen); + return -EMSGSIZE; + } + + if (proto == IPPROTO_UDP && + (rt->dst.dev->features & NETIF_F_UFO)) { + + err = ip6_ufo_append_data(sk, getfrag, from, length, + hh_len, fragheaderlen, + transhdrlen, mtu, flags, rt); + if (err) + goto error; + return 0; + } + } + + if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) + goto alloc_new_skb; + + while (length > 0) { + /* Check if the remaining data fits into current packet. */ + copy = (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - skb->len; + if (copy < length) + copy = maxfraglen - skb->len; + + if (copy <= 0) { + char *data; + unsigned int datalen; + unsigned int fraglen; + unsigned int fraggap; + unsigned int alloclen; +alloc_new_skb: + /* There's no room in the current skb */ + if (skb) + fraggap = skb->len - maxfraglen; + else + fraggap = 0; + /* update mtu and maxfraglen if necessary */ + if (skb == NULL || skb_prev == NULL) + ip6_append_data_mtu(&mtu, &maxfraglen, + fragheaderlen, skb, rt, + np->pmtudisc == + IPV6_PMTUDISC_PROBE); + + skb_prev = skb; + + /* + * If remaining data exceeds the mtu, + * we know we need more fragment(s). + */ + datalen = length + fraggap; + + if (datalen > (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - fragheaderlen) + datalen = maxfraglen - fragheaderlen - rt->dst.trailer_len; + if ((flags & MSG_MORE) && + !(rt->dst.dev->features&NETIF_F_SG)) + alloclen = mtu; + else + alloclen = datalen + fragheaderlen; + + alloclen += dst_exthdrlen; + + if (datalen != length + fraggap) { + /* + * this is not the last fragment, the trailer + * space is regarded as data space. + */ + datalen += rt->dst.trailer_len; + } + + alloclen += rt->dst.trailer_len; + fraglen = datalen + fragheaderlen; + + /* + * We just reserve space for fragment header. + * Note: this may be overallocation if the message + * (without MSG_MORE) fits into the MTU. + */ + alloclen += sizeof(struct frag_hdr); + + if (transhdrlen) { + skb = sock_alloc_send_skb(sk, + alloclen + hh_len, + (flags & MSG_DONTWAIT), &err); + } else { + skb = NULL; + if (atomic_read(&sk->sk_wmem_alloc) <= + 2 * sk->sk_sndbuf) + skb = sock_wmalloc(sk, + alloclen + hh_len, 1, + sk->sk_allocation); + if (unlikely(skb == NULL)) + err = -ENOBUFS; + else { + /* Only the initial fragment + * is time stamped. + */ + tx_flags = 0; + } + } + if (skb == NULL) + goto error; + /* + * Fill in the control structures + */ + skb->ip_summed = CHECKSUM_NONE; + skb->csum = 0; + /* reserve for fragmentation and ipsec header */ + skb_reserve(skb, hh_len + sizeof(struct frag_hdr) + + dst_exthdrlen); + + if (sk->sk_type == SOCK_DGRAM) + skb_shinfo(skb)->tx_flags = tx_flags; + + /* + * Find where to start putting bytes + */ + data = skb_put(skb, fraglen); + skb_set_network_header(skb, exthdrlen); + data += fragheaderlen; + skb->transport_header = (skb->network_header + + fragheaderlen); + if (fraggap) { + skb->csum = skb_copy_and_csum_bits( + skb_prev, maxfraglen, + data + transhdrlen, fraggap, 0); + skb_prev->csum = csum_sub(skb_prev->csum, + skb->csum); + data += fraggap; + pskb_trim_unique(skb_prev, maxfraglen); + } + copy = datalen - transhdrlen - fraggap; + + if (copy < 0) { + err = -EINVAL; + kfree_skb(skb); + goto error; + } else if (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, fraggap, skb) < 0) { + err = -EFAULT; + kfree_skb(skb); + goto error; + } + + offset += copy; + length -= datalen - fraggap; + transhdrlen = 0; + exthdrlen = 0; + dst_exthdrlen = 0; + + /* + * Put the packet on the pending queue + */ + __skb_queue_tail(&sk->sk_write_queue, skb); + continue; + } + + if (copy > length) + copy = length; + + if (!(rt->dst.dev->features&NETIF_F_SG)) { + unsigned int off; + + off = skb->len; + if (getfrag(from, skb_put(skb, copy), + offset, copy, off, skb) < 0) { + __skb_trim(skb, off); + err = -EFAULT; + goto error; + } + } else { + int i = skb_shinfo(skb)->nr_frags; + struct page_frag *pfrag = sk_page_frag(sk); + + err = -ENOMEM; + if (!sk_page_frag_refill(sk, pfrag)) + goto error; + + if (!skb_can_coalesce(skb, i, pfrag->page, + pfrag->offset)) { + err = -EMSGSIZE; + if (i == MAX_SKB_FRAGS) + goto error; + + __skb_fill_page_desc(skb, i, pfrag->page, + pfrag->offset, 0); + skb_shinfo(skb)->nr_frags = ++i; + get_page(pfrag->page); + } + copy = min_t(int, copy, pfrag->size - pfrag->offset); + if (getfrag(from, + page_address(pfrag->page) + pfrag->offset, + offset, copy, skb->len, skb) < 0) + goto error_efault; + + pfrag->offset += copy; + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); + skb->len += copy; + skb->data_len += copy; + skb->truesize += copy; + atomic_add(copy, &sk->sk_wmem_alloc); + } + offset += copy; + length -= copy; + } + + return 0; + +error_efault: + err = -EFAULT; +error: + cork->length -= length; + IP6_INC_STATS(sock_net(sk), rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS); + return err; +} +","@@ -1093,11 +1093,12 @@ static inline struct ipv6_rt_hdr *ip6_rthdr_dup(struct ipv6_rt_hdr *src, + return src ? kmemdup(src, (src->hdrlen + 1) * 8, gfp) : NULL; + } + +-static void ip6_append_data_mtu(int *mtu, ++static void ip6_append_data_mtu(unsigned int *mtu, + int *maxfraglen, + unsigned int fragheaderlen, + struct sk_buff *skb, +- struct rt6_info *rt) ++ struct rt6_info *rt, ++ bool pmtuprobe) + { + if (!(rt->dst.flags & DST_XFRM_TUNNEL)) { + if (skb == NULL) { +@@ -1109,7 +1110,9 @@ static void ip6_append_data_mtu(int *mtu, + * this fragment is not first, the headers + * space is regarded as data space. + */ +- *mtu = dst_mtu(rt->dst.path); ++ *mtu = min(*mtu, pmtuprobe ? ++ rt->dst.dev->mtu : ++ dst_mtu(rt->dst.path)); + } + *maxfraglen = ((*mtu - fragheaderlen) & ~7) + + fragheaderlen - sizeof(struct frag_hdr); +@@ -1126,11 +1129,10 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, + struct ipv6_pinfo *np = inet6_sk(sk); + struct inet_cork *cork; + struct sk_buff *skb, *skb_prev = NULL; +- unsigned int maxfraglen, fragheaderlen; ++ unsigned int maxfraglen, fragheaderlen, mtu; + int exthdrlen; + int dst_exthdrlen; + int hh_len; +- int mtu; + int copy; + int err; + int offset = 0; +@@ -1287,7 +1289,9 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, + /* update mtu and maxfraglen if necessary */ + if (skb == NULL || skb_prev == NULL) + ip6_append_data_mtu(&mtu, &maxfraglen, +- fragheaderlen, skb, rt); ++ fragheaderlen, skb, rt, ++ np->pmtudisc == ++ IPV6_PMTUDISC_PROBE); + + skb_prev = skb; + ",2970,3206,4096 +17835,"int ssl23_get_client_hello(SSL *s) + { + char buf_space[11]; /* Request this many bytes in initial read. + * We can detect SSL 3.0/TLS 1.0 Client Hellos + * ('type == 3') correctly only when the following + * is in a single record, which is not guaranteed by + * the protocol specification: + * Byte Content + * 0 type \ + * 1/2 version > record header + * 3/4 length / + * 5 msg_type \ + * 6-8 length > Client Hello message + * 9/10 client_version / + */ + char *buf= &(buf_space[0]); + unsigned char *p,*d,*d_len,*dd; + unsigned int i; + unsigned int csl,sil,cl; + int n=0,j; + int type=0; + int v[2]; + + if (s->state == SSL23_ST_SR_CLNT_HELLO_A) + { + /* read the initial header */ + v[0]=v[1]=0; + + if (!ssl3_setup_buffers(s)) goto err; + + n=ssl23_read_bytes(s, sizeof buf_space); + if (n != sizeof buf_space) return(n); /* n == -1 || n == 0 */ + + p=s->packet; + + memcpy(buf,p,n); + + if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) + { + /* + * SSLv2 header + */ + if ((p[3] == 0x00) && (p[4] == 0x02)) + { + v[0]=p[3]; v[1]=p[4]; + /* SSLv2 */ + if (!(s->options & SSL_OP_NO_SSLv2)) + type=1; + } + else if (p[3] == SSL3_VERSION_MAJOR) + { + v[0]=p[3]; v[1]=p[4]; + /* SSLv3/TLSv1 */ + if (p[4] >= TLS1_VERSION_MINOR) + { + if (!(s->options & SSL_OP_NO_TLSv1)) + { + s->version=TLS1_VERSION; + /* type=2; */ /* done later to survive restarts */ + s->state=SSL23_ST_SR_CLNT_HELLO_B; + } + else if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + /* type=2; */ + s->state=SSL23_ST_SR_CLNT_HELLO_B; + } + else if (!(s->options & SSL_OP_NO_SSLv2)) + { + type=1; + } + } + else if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + /* type=2; */ + s->state=SSL23_ST_SR_CLNT_HELLO_B; + } + else if (!(s->options & SSL_OP_NO_SSLv2)) + type=1; + + } + } + else if ((p[0] == SSL3_RT_HANDSHAKE) && + (p[1] == SSL3_VERSION_MAJOR) && + (p[5] == SSL3_MT_CLIENT_HELLO) && + ((p[3] == 0 && p[4] < 5 /* silly record length? */) + || (p[9] >= p[1]))) + { + /* + * SSLv3 or tls1 header + */ + + v[0]=p[1]; /* major version (= SSL3_VERSION_MAJOR) */ + /* We must look at client_version inside the Client Hello message + * to get the correct minor version. + * However if we have only a pathologically small fragment of the + * Client Hello message, this would be difficult, and we'd have + * to read more records to find out. + * No known SSL 3.0 client fragments ClientHello like this, + * so we simply reject such connections to avoid + * protocol version downgrade attacks. */ + if (p[3] == 0 && p[4] < 6) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL); + goto err; + } + /* if major version number > 3 set minor to a value + * which will use the highest version 3 we support. + * If TLS 2.0 ever appears we will need to revise + * this.... + */ + if (p[9] > SSL3_VERSION_MAJOR) + v[1]=0xff; + else + v[1]=p[10]; /* minor version according to client_version */ + if (v[1] >= TLS1_VERSION_MINOR) + { + if (!(s->options & SSL_OP_NO_TLSv1)) + { + s->version=TLS1_VERSION; + type=3; + } + else if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + type=3; + } + } + else + { + /* client requests SSL 3.0 */ + if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + type=3; + } + else if (!(s->options & SSL_OP_NO_TLSv1)) + { + /* we won't be able to use TLS of course, + * but this will send an appropriate alert */ + s->version=TLS1_VERSION; + type=3; + } + } + } + else if ((strncmp(""GET "", (char *)p,4) == 0) || + (strncmp(""POST "",(char *)p,5) == 0) || + (strncmp(""HEAD "",(char *)p,5) == 0) || + (strncmp(""PUT "", (char *)p,4) == 0)) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTP_REQUEST); + goto err; + } + else if (strncmp(""CONNECT"",(char *)p,7) == 0) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTPS_PROXY_REQUEST); + goto err; + } + } + +#ifdef OPENSSL_FIPS + if (FIPS_mode() && (s->version < TLS1_VERSION)) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, + SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE); + goto err; + } +#endif + + /* ensure that TLS_MAX_VERSION is up-to-date */ + OPENSSL_assert(s->version <= TLS_MAX_VERSION); + + if (s->state == SSL23_ST_SR_CLNT_HELLO_B) + { + /* we have SSLv3/TLSv1 in an SSLv2 header + * (other cases skip this state) */ + + type=2; + p=s->packet; + v[0] = p[3]; /* == SSL3_VERSION_MAJOR */ + v[1] = p[4]; + + /* An SSLv3/TLSv1 backwards-compatible CLIENT-HELLO in an SSLv2 + * header is sent directly on the wire, not wrapped as a TLS + * record. It's format is: + * Byte Content + * 0-1 msg_length + * 2 msg_type + * 3-4 version + * 5-6 cipher_spec_length + * 7-8 session_id_length + * 9-10 challenge_length + * ... ... + */ + n=((p[0]&0x7f)<<8)|p[1]; + if (n > (1024*4)) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_LARGE); + goto err; + } + if (n < 9) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_LENGTH_MISMATCH); + goto err; + } + + j=ssl23_read_bytes(s,n+2); + /* We previously read 11 bytes, so if j > 0, we must have + * j == n+2 == s->packet_length. We have at least 11 valid + * packet bytes. */ + if (j <= 0) return(j); + + ssl3_finish_mac(s, s->packet+2, s->packet_length-2); + if (s->msg_callback) + s->msg_callback(0, SSL2_VERSION, 0, s->packet+2, s->packet_length-2, s, s->msg_callback_arg); /* CLIENT-HELLO */ + + p=s->packet; + p+=5; + n2s(p,csl); + n2s(p,sil); + n2s(p,cl); + d=(unsigned char *)s->init_buf->data; + if ((csl+sil+cl+11) != s->packet_length) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_LENGTH_MISMATCH); + goto err; + } + + /* record header: msg_type ... */ + *(d++) = SSL3_MT_CLIENT_HELLO; + /* ... and length (actual value will be written later) */ + d_len = d; + d += 3; + + /* client_version */ + *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */ + *(d++) = v[1]; + + /* lets populate the random area */ + /* get the challenge_length */ + i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl; + memset(d,0,SSL3_RANDOM_SIZE); + memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i); + d+=SSL3_RANDOM_SIZE; + + /* no session-id reuse */ + *(d++)=0; + + /* ciphers */ + j=0; + dd=d; + d+=2; + for (i=0; iinit_buf->data) - 4; + l2n3((long)i, d_len); + + /* get the data reused from the init_buf */ + s->s3->tmp.reuse_message=1; + s->s3->tmp.message_type=SSL3_MT_CLIENT_HELLO; + s->s3->tmp.message_size=i; + } + + /* imaginary new state (for program structure): */ + /* s->state = SSL23_SR_CLNT_HELLO_C */ + + if (type == 1) + { +#ifdef OPENSSL_NO_SSL2 + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); + goto err; +#else + /* we are talking sslv2 */ + /* we need to clean up the SSLv3/TLSv1 setup and put in the + * sslv2 stuff. */ + + if (s->s2 == NULL) + { + if (!ssl2_new(s)) + goto err; + } + else + ssl2_clear(s); + + if (s->s3 != NULL) ssl3_free(s); + + if (!BUF_MEM_grow_clean(s->init_buf, + SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) + { + goto err; + } + + s->state=SSL2_ST_GET_CLIENT_HELLO_A; + if (s->options & SSL_OP_NO_TLSv1 && s->options & SSL_OP_NO_SSLv3) + s->s2->ssl2_rollback=0; + else + /* reject SSL 2.0 session if client supports SSL 3.0 or TLS 1.0 + * (SSL 3.0 draft/RFC 2246, App. E.2) */ + s->s2->ssl2_rollback=1; + + /* setup the n bytes we have read so we get them from + * the sslv2 buffer */ + s->rstate=SSL_ST_READ_HEADER; + s->packet_length=n; + s->packet= &(s->s2->rbuf[0]); + memcpy(s->packet,buf,n); + s->s2->rbuf_left=n; + s->s2->rbuf_offs=0; + + s->method=SSLv2_server_method(); + s->handshake_func=s->method->ssl_accept; +#endif + } + + if ((type == 2) || (type == 3)) + { + /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */ + s->method = ssl23_get_server_method(s->version); + if (s->method == NULL) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); + goto err; + } + + if (!ssl_init_wbio_buffer(s,1)) goto err; + + if (type == 3) + { + /* put the 'n' bytes we have read into the input buffer + * for SSLv3 */ + s->rstate=SSL_ST_READ_HEADER; + s->packet_length=n; + s->packet= &(s->s3->rbuf.buf[0]); + memcpy(s->packet,buf,n); + s->s3->rbuf.left=n; + s->s3->rbuf.offset=0; + } + else + { + s->packet_length=0; + s->s3->rbuf.left=0; + s->s3->rbuf.offset=0; + } +#if 0 /* ssl3_get_client_hello does this */ + s->client_version=(v[0]<<8)|v[1]; +#endif + s->handshake_func=s->method->ssl_accept; + } + + if ((type < 1) || (type > 3)) + { + /* bad, very bad */ + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNKNOWN_PROTOCOL); + goto err; + } + s->init_num=0; + + if (buf != buf_space) OPENSSL_free(buf); + return(SSL_accept(s)); +err: + if (buf != buf_space) OPENSSL_free(buf); + return(-1); + } +",1,"int ssl23_get_client_hello(SSL *s) + { + char buf_space[11]; /* Request this many bytes in initial read. + * We can detect SSL 3.0/TLS 1.0 Client Hellos + * ('type == 3') correctly only when the following + * is in a single record, which is not guaranteed by + * the protocol specification: + * Byte Content + * 0 type \ + * 1/2 version > record header + * 3/4 length / + * 5 msg_type \ + * 6-8 length > Client Hello message + * 9/10 client_version / + */ + char *buf= &(buf_space[0]); + unsigned char *p,*d,*d_len,*dd; + unsigned int i; + unsigned int csl,sil,cl; + int n=0,j; + int type=0; + int v[2]; + + if (s->state == SSL23_ST_SR_CLNT_HELLO_A) + { + /* read the initial header */ + v[0]=v[1]=0; + + if (!ssl3_setup_buffers(s)) goto err; + + n=ssl23_read_bytes(s, sizeof buf_space); + if (n != sizeof buf_space) return(n); /* n == -1 || n == 0 */ + + p=s->packet; + + memcpy(buf,p,n); + + if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) + { + /* + * SSLv2 header + */ + if ((p[3] == 0x00) && (p[4] == 0x02)) + { + v[0]=p[3]; v[1]=p[4]; + /* SSLv2 */ + if (!(s->options & SSL_OP_NO_SSLv2)) + type=1; + } + else if (p[3] == SSL3_VERSION_MAJOR) + { + v[0]=p[3]; v[1]=p[4]; + /* SSLv3/TLSv1 */ + if (p[4] >= TLS1_VERSION_MINOR) + { + if (!(s->options & SSL_OP_NO_TLSv1)) + { + s->version=TLS1_VERSION; + /* type=2; */ /* done later to survive restarts */ + s->state=SSL23_ST_SR_CLNT_HELLO_B; + } + else if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + /* type=2; */ + s->state=SSL23_ST_SR_CLNT_HELLO_B; + } + else if (!(s->options & SSL_OP_NO_SSLv2)) + { + type=1; + } + } + else if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + /* type=2; */ + s->state=SSL23_ST_SR_CLNT_HELLO_B; + } + else if (!(s->options & SSL_OP_NO_SSLv2)) + type=1; + + } + } + else if ((p[0] == SSL3_RT_HANDSHAKE) && + (p[1] == SSL3_VERSION_MAJOR) && + (p[5] == SSL3_MT_CLIENT_HELLO) && + ((p[3] == 0 && p[4] < 5 /* silly record length? */) + || (p[9] >= p[1]))) + { + /* + * SSLv3 or tls1 header + */ + + v[0]=p[1]; /* major version (= SSL3_VERSION_MAJOR) */ + /* We must look at client_version inside the Client Hello message + * to get the correct minor version. + * However if we have only a pathologically small fragment of the + * Client Hello message, this would be difficult, and we'd have + * to read more records to find out. + * No known SSL 3.0 client fragments ClientHello like this, + * so we simply reject such connections to avoid + * protocol version downgrade attacks. */ + if (p[3] == 0 && p[4] < 6) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL); + goto err; + } + /* if major version number > 3 set minor to a value + * which will use the highest version 3 we support. + * If TLS 2.0 ever appears we will need to revise + * this.... + */ + if (p[9] > SSL3_VERSION_MAJOR) + v[1]=0xff; + else + v[1]=p[10]; /* minor version according to client_version */ + if (v[1] >= TLS1_VERSION_MINOR) + { + if (!(s->options & SSL_OP_NO_TLSv1)) + { + s->version=TLS1_VERSION; + type=3; + } + else if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + type=3; + } + } + else + { + /* client requests SSL 3.0 */ + if (!(s->options & SSL_OP_NO_SSLv3)) + { + s->version=SSL3_VERSION; + type=3; + } + else if (!(s->options & SSL_OP_NO_TLSv1)) + { + /* we won't be able to use TLS of course, + * but this will send an appropriate alert */ + s->version=TLS1_VERSION; + type=3; + } + } + } + else if ((strncmp(""GET "", (char *)p,4) == 0) || + (strncmp(""POST "",(char *)p,5) == 0) || + (strncmp(""HEAD "",(char *)p,5) == 0) || + (strncmp(""PUT "", (char *)p,4) == 0)) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTP_REQUEST); + goto err; + } + else if (strncmp(""CONNECT"",(char *)p,7) == 0) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTPS_PROXY_REQUEST); + goto err; + } + } + +#ifdef OPENSSL_FIPS + if (FIPS_mode() && (s->version < TLS1_VERSION)) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, + SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE); + goto err; + } +#endif + + /* ensure that TLS_MAX_VERSION is up-to-date */ + OPENSSL_assert(s->version <= TLS_MAX_VERSION); + + if (s->state == SSL23_ST_SR_CLNT_HELLO_B) + { + /* we have SSLv3/TLSv1 in an SSLv2 header + * (other cases skip this state) */ + + type=2; + p=s->packet; + v[0] = p[3]; /* == SSL3_VERSION_MAJOR */ + v[1] = p[4]; + + /* An SSLv3/TLSv1 backwards-compatible CLIENT-HELLO in an SSLv2 + * header is sent directly on the wire, not wrapped as a TLS + * record. It's format is: + * Byte Content + * 0-1 msg_length + * 2 msg_type + * 3-4 version + * 5-6 cipher_spec_length + * 7-8 session_id_length + * 9-10 challenge_length + * ... ... + */ + n=((p[0]&0x7f)<<8)|p[1]; + if (n > (1024*4)) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_LARGE); + goto err; + } + if (n < 9) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_LENGTH_MISMATCH); + goto err; + } + + j=ssl23_read_bytes(s,n+2); + /* We previously read 11 bytes, so if j > 0, we must have + * j == n+2 == s->packet_length. We have at least 11 valid + * packet bytes. */ + if (j <= 0) return(j); + + ssl3_finish_mac(s, s->packet+2, s->packet_length-2); + if (s->msg_callback) + s->msg_callback(0, SSL2_VERSION, 0, s->packet+2, s->packet_length-2, s, s->msg_callback_arg); /* CLIENT-HELLO */ + + p=s->packet; + p+=5; + n2s(p,csl); + n2s(p,sil); + n2s(p,cl); + d=(unsigned char *)s->init_buf->data; + if ((csl+sil+cl+11) != s->packet_length) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_LENGTH_MISMATCH); + goto err; + } + + /* record header: msg_type ... */ + *(d++) = SSL3_MT_CLIENT_HELLO; + /* ... and length (actual value will be written later) */ + d_len = d; + d += 3; + + /* client_version */ + *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */ + *(d++) = v[1]; + + /* lets populate the random area */ + /* get the challenge_length */ + i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl; + memset(d,0,SSL3_RANDOM_SIZE); + memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i); + d+=SSL3_RANDOM_SIZE; + + /* no session-id reuse */ + *(d++)=0; + + /* ciphers */ + j=0; + dd=d; + d+=2; + for (i=0; iinit_buf->data) - 4; + l2n3((long)i, d_len); + + /* get the data reused from the init_buf */ + s->s3->tmp.reuse_message=1; + s->s3->tmp.message_type=SSL3_MT_CLIENT_HELLO; + s->s3->tmp.message_size=i; + } + + /* imaginary new state (for program structure): */ + /* s->state = SSL23_SR_CLNT_HELLO_C */ + + if (type == 1) + { +#ifdef OPENSSL_NO_SSL2 + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); + goto err; +#else + /* we are talking sslv2 */ + /* we need to clean up the SSLv3/TLSv1 setup and put in the + * sslv2 stuff. */ + + if (s->s2 == NULL) + { + if (!ssl2_new(s)) + goto err; + } + else + ssl2_clear(s); + + if (s->s3 != NULL) ssl3_free(s); + + if (!BUF_MEM_grow_clean(s->init_buf, + SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) + { + goto err; + } + + s->state=SSL2_ST_GET_CLIENT_HELLO_A; + if (s->options & SSL_OP_NO_TLSv1 && s->options & SSL_OP_NO_SSLv3) + s->s2->ssl2_rollback=0; + else + /* reject SSL 2.0 session if client supports SSL 3.0 or TLS 1.0 + * (SSL 3.0 draft/RFC 2246, App. E.2) */ + s->s2->ssl2_rollback=1; + + /* setup the n bytes we have read so we get them from + * the sslv2 buffer */ + s->rstate=SSL_ST_READ_HEADER; + s->packet_length=n; + s->packet= &(s->s2->rbuf[0]); + memcpy(s->packet,buf,n); + s->s2->rbuf_left=n; + s->s2->rbuf_offs=0; + + s->method=SSLv2_server_method(); + s->handshake_func=s->method->ssl_accept; +#endif + } + + if ((type == 2) || (type == 3)) + { + /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */ + const SSL_METHOD *new_method; + new_method = ssl23_get_server_method(s->version); + if (new_method == NULL) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); + goto err; + } + s->method = new_method; + + if (!ssl_init_wbio_buffer(s,1)) goto err; + + if (type == 3) + { + /* put the 'n' bytes we have read into the input buffer + * for SSLv3 */ + s->rstate=SSL_ST_READ_HEADER; + s->packet_length=n; + s->packet= &(s->s3->rbuf.buf[0]); + memcpy(s->packet,buf,n); + s->s3->rbuf.left=n; + s->s3->rbuf.offset=0; + } + else + { + s->packet_length=0; + s->s3->rbuf.left=0; + s->s3->rbuf.offset=0; + } +#if 0 /* ssl3_get_client_hello does this */ + s->client_version=(v[0]<<8)|v[1]; +#endif + s->handshake_func=s->method->ssl_accept; + } + + if ((type < 1) || (type > 3)) + { + /* bad, very bad */ + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNKNOWN_PROTOCOL); + goto err; + } + s->init_num=0; + + if (buf != buf_space) OPENSSL_free(buf); + return(SSL_accept(s)); +err: + if (buf != buf_space) OPENSSL_free(buf); + return(-1); + } +","@@ -559,12 +559,14 @@ int ssl23_get_client_hello(SSL *s) + if ((type == 2) || (type == 3)) + { + /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */ +- s->method = ssl23_get_server_method(s->version); +- if (s->method == NULL) ++ const SSL_METHOD *new_method; ++ new_method = ssl23_get_server_method(s->version); ++ if (new_method == NULL) + { + SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); + goto err; + } ++ s->method = new_method; + + if (!ssl_init_wbio_buffer(s,1)) goto err;",3304,3540,4096 +17440,"void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT8 status) +{ + tBTM_SEC_DEV_REC *p_dev_rec; + int i; + DEV_CLASS dev_class; + UINT8 old_sec_state; + + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete""); + if (((p_bd_addr == NULL) && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda)) + || ((p_bd_addr != NULL) && !BTM_ACL_IS_CONNECTED(p_bd_addr))) + { + btm_acl_resubmit_page(); + } + + /* If remote name request failed, p_bd_addr is null and we need to search */ + /* based on state assuming that we are doing 1 at a time */ + if (p_bd_addr) + p_dev_rec = btm_find_dev (p_bd_addr); + else + { + p_dev_rec = &btm_cb.sec_dev_rec[0]; + + for (i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i++, p_dev_rec++) + { + if ((p_dev_rec->sec_flags & BTM_SEC_IN_USE) + && (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME)) + { + p_bd_addr = p_dev_rec->bd_addr; + break; + } + } + + if (i == BTM_SEC_MAX_DEVICE_RECORDS) + p_dev_rec = NULL; + } + + + /* Commenting out trace due to obf/compilation problems. + */ +#if (BT_USE_TRACES == TRUE) + if (!p_bd_name) + p_bd_name = (UINT8 *)""""; + + if (p_dev_rec) + { + BTM_TRACE_EVENT (""Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d State:%d p_dev_rec: 0x%08x "", + btm_pair_state_descr (btm_cb.pairing_state), p_bd_name, + status, p_dev_rec->sec_state, p_dev_rec); + } + else + { + BTM_TRACE_EVENT (""Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d"", + btm_pair_state_descr (btm_cb.pairing_state), p_bd_name, + status); + } +#endif + + if (p_dev_rec) + { + old_sec_state = p_dev_rec->sec_state; + if (status == HCI_SUCCESS) + { + BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN); + p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; + BTM_TRACE_EVENT (""setting BTM_SEC_NAME_KNOWN sec_flags:0x%x"", p_dev_rec->sec_flags); + } + else + { + /* Notify all clients waiting for name to be resolved even if it failed so clients can continue */ + p_dev_rec->sec_bd_name[0] = 0; + } + + if (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME) + p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; + + /* Notify all clients waiting for name to be resolved */ + for (i = 0;i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) + { + if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) + (*btm_cb.p_rmt_name_callback[i])(p_bd_addr, p_dev_rec->dev_class, + p_dev_rec->sec_bd_name); + } + } + else + { + dev_class[0] = 0; + dev_class[1] = 0; + dev_class[2] = 0; + + /* Notify all clients waiting for name to be resolved even if not found so clients can continue */ + for (i = 0;i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) + { + if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) + (*btm_cb.p_rmt_name_callback[i])(p_bd_addr, dev_class, (UINT8 *)""""); + } + + return; + } + + /* If we were delaying asking UI for a PIN because name was not resolved, ask now */ + if ( (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) && p_bd_addr + && (memcmp (btm_cb.pairing_bda, p_bd_addr, BD_ADDR_LEN) == 0) ) + { + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete() delayed pin now being requested flags:0x%x, (p_pin_callback=0x%p)"", btm_cb.pairing_flags, btm_cb.api.p_pin_callback); + + if (((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) == 0) && + ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0) && + btm_cb.api.p_pin_callback) + { + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete() calling pin_callback""); + btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; + (*btm_cb.api.p_pin_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, p_bd_name); + } + + /* Set the same state again to force the timer to be restarted */ + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); + return; + } + + /* Check if we were delaying bonding because name was not resolved */ + if ( btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) + { + if (p_bd_addr && memcmp (btm_cb.pairing_bda, p_bd_addr, BD_ADDR_LEN) == 0) + { + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete() continue bonding sm4: 0x%04x, status:0x%x"", p_dev_rec->sm4, status); + if(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_CANCEL_DD) + { + btm_sec_bond_cancel_complete(); + return; + } + + if (status != HCI_SUCCESS) + { + btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); + + if (btm_cb.api.p_auth_complete_callback) + (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, + p_dev_rec->sec_bd_name, status); + return; + } + + /* if peer is very old legacy devices, HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT is not reported */ + if (BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)) + { + /* set the KNOWN flag only if BTM_PAIR_FLAGS_REJECTED_CONNECT is not set.*/ + /* If it is set, there may be a race condition */ + BTM_TRACE_DEBUG (""btm_sec_rmt_name_request_complete IS_SM4_UNKNOWN Flags:0x%04x"", + btm_cb.pairing_flags); + if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) == 0) + { + p_dev_rec->sm4 |= BTM_SM4_KNOWN; + } + } + + BTM_TRACE_DEBUG(""%s, SM4 Value: %x, Legacy:%d,IS SM4:%d, Unknown:%d"",__FUNCTION__, + p_dev_rec->sm4, BTM_SEC_IS_SM4_LEGACY(p_dev_rec->sm4), + BTM_SEC_IS_SM4(p_dev_rec->sm4),BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)); + + /* BT 2.1 or carkit, bring up the connection to force the peer to request PIN. + ** Else prefetch (btm_sec_check_prefetch_pin will do the prefetching if needed) + */ + if ((p_dev_rec->sm4 != BTM_SM4_KNOWN) || !btm_sec_check_prefetch_pin(p_dev_rec)) + { + /* if we rejected incoming connection request, we have to wait HCI_Connection_Complete event */ + /* before originating */ + if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete: waiting HCI_Connection_Complete after rejecting connection""); + } + /* Both we and the peer are 2.1 - continue to create connection */ + else if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED) + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete: failed to start connection""); + + btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); + + if (btm_cb.api.p_auth_complete_callback) + (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, + p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL); + } + } + return; + } + else + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete: wrong BDA, retry with pairing BDA""); + + BTM_ReadRemoteDeviceName (btm_cb.pairing_bda, NULL, BT_TRANSPORT_BR_EDR); + return; + } + } + + /* check if we were delaying link_key_callback because name was not resolved */ + if (p_dev_rec->link_key_not_sent) + { + /* If HCI connection complete has not arrived, wait for it */ + if (p_dev_rec->hci_handle == BTM_SEC_INVALID_HANDLE) + return; + + p_dev_rec->link_key_not_sent = FALSE; + btm_send_link_key_notif(p_dev_rec); + + /* If its not us who perform authentication, we should tell stackserver */ + /* that some authentication has been completed */ + /* This is required when different entities receive link notification and auth complete */ + if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) + { + if (btm_cb.api.p_auth_complete_callback) + (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, + p_dev_rec->dev_class, + p_dev_rec->sec_bd_name, HCI_SUCCESS); + + } + } + + /* If this is a bonding procedure can disconnect the link now */ + if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) + && (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)) + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete (none/ce)""); + p_dev_rec->security_required &= ~(BTM_SEC_OUT_AUTHENTICATE); + l2cu_start_post_bond_timer(p_dev_rec->hci_handle); + return; + } + + if (old_sec_state != BTM_SEC_STATE_GETTING_NAME) + return; + + /* If get name failed, notify the waiting layer */ + if (status != HCI_SUCCESS) + { + btm_sec_dev_rec_cback_event (p_dev_rec, BTM_ERR_PROCESSING, FALSE); + return; + } + + if (p_dev_rec->sm4 & BTM_SM4_REQ_PEND) + { + BTM_TRACE_EVENT (""waiting for remote features!!""); + return; + } + + /* Remote Name succeeded, execute the next security procedure, if any */ + status = (UINT8)btm_sec_execute_procedure (p_dev_rec); + + /* If result is pending reply from the user or from the device is pending */ + if (status == BTM_CMD_STARTED) + return; + + /* There is no next procedure or start of procedure failed, notify the waiting layer */ + btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); +} +",0,"void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT8 status) +{ + tBTM_SEC_DEV_REC *p_dev_rec; + int i; + DEV_CLASS dev_class; + UINT8 old_sec_state; + + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete""); + if (((p_bd_addr == NULL) && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda)) + || ((p_bd_addr != NULL) && !BTM_ACL_IS_CONNECTED(p_bd_addr))) + { + btm_acl_resubmit_page(); + } + + /* If remote name request failed, p_bd_addr is null and we need to search */ + /* based on state assuming that we are doing 1 at a time */ + if (p_bd_addr) + p_dev_rec = btm_find_dev (p_bd_addr); + else + { + p_dev_rec = &btm_cb.sec_dev_rec[0]; + + for (i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i++, p_dev_rec++) + { + if ((p_dev_rec->sec_flags & BTM_SEC_IN_USE) + && (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME)) + { + p_bd_addr = p_dev_rec->bd_addr; + break; + } + } + + if (i == BTM_SEC_MAX_DEVICE_RECORDS) + p_dev_rec = NULL; + } + + + /* Commenting out trace due to obf/compilation problems. + */ +#if (BT_USE_TRACES == TRUE) + if (!p_bd_name) + p_bd_name = (UINT8 *)""""; + + if (p_dev_rec) + { + BTM_TRACE_EVENT (""Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d State:%d p_dev_rec: 0x%08x "", + btm_pair_state_descr (btm_cb.pairing_state), p_bd_name, + status, p_dev_rec->sec_state, p_dev_rec); + } + else + { + BTM_TRACE_EVENT (""Security Manager: rmt_name_complete PairState: %s RemName: %s status: %d"", + btm_pair_state_descr (btm_cb.pairing_state), p_bd_name, + status); + } +#endif + + if (p_dev_rec) + { + old_sec_state = p_dev_rec->sec_state; + if (status == HCI_SUCCESS) + { + BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN); + p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; + BTM_TRACE_EVENT (""setting BTM_SEC_NAME_KNOWN sec_flags:0x%x"", p_dev_rec->sec_flags); + } + else + { + /* Notify all clients waiting for name to be resolved even if it failed so clients can continue */ + p_dev_rec->sec_bd_name[0] = 0; + } + + if (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME) + p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; + + /* Notify all clients waiting for name to be resolved */ + for (i = 0;i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) + { + if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) + (*btm_cb.p_rmt_name_callback[i])(p_bd_addr, p_dev_rec->dev_class, + p_dev_rec->sec_bd_name); + } + } + else + { + dev_class[0] = 0; + dev_class[1] = 0; + dev_class[2] = 0; + + /* Notify all clients waiting for name to be resolved even if not found so clients can continue */ + for (i = 0;i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) + { + if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) + (*btm_cb.p_rmt_name_callback[i])(p_bd_addr, dev_class, (UINT8 *)""""); + } + + return; + } + + /* If we were delaying asking UI for a PIN because name was not resolved, ask now */ + if ( (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) && p_bd_addr + && (memcmp (btm_cb.pairing_bda, p_bd_addr, BD_ADDR_LEN) == 0) ) + { + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete() delayed pin now being requested flags:0x%x, (p_pin_callback=0x%p)"", btm_cb.pairing_flags, btm_cb.api.p_pin_callback); + + if (((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) == 0) && + ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0) && + btm_cb.api.p_pin_callback) + { + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete() calling pin_callback""); + btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; + (*btm_cb.api.p_pin_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, p_bd_name); + } + + /* Set the same state again to force the timer to be restarted */ + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); + return; + } + + /* Check if we were delaying bonding because name was not resolved */ + if ( btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) + { + if (p_bd_addr && memcmp (btm_cb.pairing_bda, p_bd_addr, BD_ADDR_LEN) == 0) + { + BTM_TRACE_EVENT (""btm_sec_rmt_name_request_complete() continue bonding sm4: 0x%04x, status:0x%x"", p_dev_rec->sm4, status); + if(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_CANCEL_DD) + { + btm_sec_bond_cancel_complete(); + return; + } + + if (status != HCI_SUCCESS) + { + btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); + + if (btm_cb.api.p_auth_complete_callback) + (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, + p_dev_rec->sec_bd_name, status); + return; + } + + /* if peer is very old legacy devices, HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT is not reported */ + if (BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)) + { + /* set the KNOWN flag only if BTM_PAIR_FLAGS_REJECTED_CONNECT is not set.*/ + /* If it is set, there may be a race condition */ + BTM_TRACE_DEBUG (""btm_sec_rmt_name_request_complete IS_SM4_UNKNOWN Flags:0x%04x"", + btm_cb.pairing_flags); + if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) == 0) + { + p_dev_rec->sm4 |= BTM_SM4_KNOWN; + } + } + + BTM_TRACE_DEBUG(""%s, SM4 Value: %x, Legacy:%d,IS SM4:%d, Unknown:%d"",__FUNCTION__, + p_dev_rec->sm4, BTM_SEC_IS_SM4_LEGACY(p_dev_rec->sm4), + BTM_SEC_IS_SM4(p_dev_rec->sm4),BTM_SEC_IS_SM4_UNKNOWN(p_dev_rec->sm4)); + + /* BT 2.1 or carkit, bring up the connection to force the peer to request PIN. + ** Else prefetch (btm_sec_check_prefetch_pin will do the prefetching if needed) + */ + if ((p_dev_rec->sm4 != BTM_SM4_KNOWN) || !btm_sec_check_prefetch_pin(p_dev_rec)) + { + /* if we rejected incoming connection request, we have to wait HCI_Connection_Complete event */ + /* before originating */ + if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete: waiting HCI_Connection_Complete after rejecting connection""); + } + /* Both we and the peer are 2.1 - continue to create connection */ + else if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED) + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete: failed to start connection""); + + btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); + + if (btm_cb.api.p_auth_complete_callback) + (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, + p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL); + } + } + return; + } + else + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete: wrong BDA, retry with pairing BDA""); + + BTM_ReadRemoteDeviceName (btm_cb.pairing_bda, NULL, BT_TRANSPORT_BR_EDR); + return; + } + } + + /* check if we were delaying link_key_callback because name was not resolved */ + if (p_dev_rec->link_key_not_sent) + { + /* If HCI connection complete has not arrived, wait for it */ + if (p_dev_rec->hci_handle == BTM_SEC_INVALID_HANDLE) + return; + + p_dev_rec->link_key_not_sent = FALSE; + btm_send_link_key_notif(p_dev_rec); + + /* If its not us who perform authentication, we should tell stackserver */ + /* that some authentication has been completed */ + /* This is required when different entities receive link notification and auth complete */ + if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) + { + if (btm_cb.api.p_auth_complete_callback) + (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, + p_dev_rec->dev_class, + p_dev_rec->sec_bd_name, HCI_SUCCESS); + + } + } + + /* If this is a bonding procedure can disconnect the link now */ + if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) + && (p_dev_rec->sec_flags & BTM_SEC_AUTHENTICATED)) + { + BTM_TRACE_WARNING (""btm_sec_rmt_name_request_complete (none/ce)""); + p_dev_rec->security_required &= ~(BTM_SEC_OUT_AUTHENTICATE); + l2cu_start_post_bond_timer(p_dev_rec->hci_handle); + return; + } + + if (old_sec_state != BTM_SEC_STATE_GETTING_NAME) + return; + + /* If get name failed, notify the waiting layer */ + if (status != HCI_SUCCESS) + { + btm_sec_dev_rec_cback_event (p_dev_rec, BTM_ERR_PROCESSING, FALSE); + return; + } + + if (p_dev_rec->sm4 & BTM_SM4_REQ_PEND) + { + BTM_TRACE_EVENT (""waiting for remote features!!""); + return; + } + + /* Remote Name succeeded, execute the next security procedure, if any */ + status = (UINT8)btm_sec_execute_procedure (p_dev_rec); + + /* If result is pending reply from the user or from the device is pending */ + if (status == BTM_CMD_STARTED) + return; + + /* There is no next procedure or start of procedure failed, notify the waiting layer */ + btm_sec_dev_rec_cback_event (p_dev_rec, status, FALSE); +} +","@@ -1074,13 +1074,6 @@ + + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); + btm_cb.acl_disc_reason = HCI_SUCCESS; + +-#ifdef PORCHE_PAIRING_CONFLICT +- BTM_TRACE_EVENT(""BTM_PINCodeReply(): Saving pin_len: %d btm_cb.pin_code_len: %d"", pin_len, btm_cb.pin_code_len); +- /* if this was not pre-fetched, save the PIN */ +- if (btm_cb.pin_code_len == 0) +- memcpy (btm_cb.pin_code, p_pin, pin_len); +- btm_cb.pin_code_len_saved = pin_len; +-#endif + btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin); + } + +@@ -5057,10 +5050,6 @@ + + tBTM_SEC_DEV_REC *p_dev_rec; + tBTM_CB *p_cb = &btm_cb; + +-#ifdef PORCHE_PAIRING_CONFLICT +- UINT8 default_pin_code_len = 4; +- PIN_CODE default_pin_code = {0x30, 0x30, 0x30, 0x30}; +-#endif + BTM_TRACE_EVENT (""btm_sec_pin_code_request() State: %s, BDA:%04x%08x"", + btm_pair_state_descr(btm_cb.pairing_state), + (p_bda[0]<<8)+p_bda[1], (p_bda[2]<<24)+(p_bda[3]<<16)+(p_bda[4]<<8)+p_bda[5] ); +@@ -5070,18 +5059,8 @@ + + if ( (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) && + (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) ) + { +- /* fake this out - porshe carkit issue - */ +-// btm_cb.pairing_state = BTM_PAIR_STATE_IDLE; +- if(! btm_cb.pin_code_len_saved) +- { +- btsnd_hcic_pin_code_neg_reply (p_bda); +- return; +- } +- else +- { +- btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code); +- return; +- } ++ btsnd_hcic_pin_code_neg_reply (p_bda); ++ return; + } + else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) + || memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) +@@ -5089,22 +5068,7 @@ + + BTM_TRACE_WARNING (""btm_sec_pin_code_request() rejected - state: %s"", + btm_pair_state_descr(btm_cb.pairing_state)); + +-#ifdef PORCHE_PAIRING_CONFLICT +- /* reply pin code again due to counter in_rand when local initiates pairing */ +- BTM_TRACE_EVENT (""btm_sec_pin_code_request from remote dev. for local initiated pairing""); +- if(! btm_cb.pin_code_len_saved) +- { +- btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); +- btsnd_hcic_pin_code_req_reply (p_bda, default_pin_code_len, default_pin_code); +- } +- else +- { +- btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_AUTH_COMPLETE); +- btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len_saved, p_cb->pin_code); +- } +-#else + btsnd_hcic_pin_code_neg_reply (p_bda); +-#endif + return; + } + } +@@ -5141,10 +5105,6 @@ + + BTM_TRACE_EVENT (""btm_sec_pin_code_request bonding sending reply""); + btsnd_hcic_pin_code_req_reply (p_bda, btm_cb.pin_code_len, p_cb->pin_code); + +-#ifdef PORCHE_PAIRING_CONFLICT +- btm_cb.pin_code_len_saved = btm_cb.pin_code_len; +-#endif +- + /* Mark that we forwarded received from the user PIN code */ + btm_cb.pin_code_len = 0; + +@@ -5175,7 +5135,6 @@ + + /* Notify upper layer of PIN request and start expiration timer */ + else + { +- btm_cb.pin_code_len_saved = 0; + btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); + /* Pin code request can not come at the same time as connection request */ + memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN); +",2373,2609,4096 +18787,"status_t BnDrm::onTransact( + uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { + switch (code) { + case INIT_CHECK: + { + CHECK_INTERFACE(IDrm, data, reply); + reply->writeInt32(initCheck()); + return OK; + } + + case IS_CRYPTO_SUPPORTED: + { + CHECK_INTERFACE(IDrm, data, reply); + uint8_t uuid[16]; + data.read(uuid, sizeof(uuid)); + String8 mimeType = data.readString8(); + reply->writeInt32(isCryptoSchemeSupported(uuid, mimeType)); + + return OK; + } + + case CREATE_PLUGIN: + { + CHECK_INTERFACE(IDrm, data, reply); + uint8_t uuid[16]; + data.read(uuid, sizeof(uuid)); + reply->writeInt32(createPlugin(uuid)); + return OK; + } + + case DESTROY_PLUGIN: + { + CHECK_INTERFACE(IDrm, data, reply); + reply->writeInt32(destroyPlugin()); + return OK; + } + + case OPEN_SESSION: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + status_t result = openSession(sessionId); + writeVector(reply, sessionId); + reply->writeInt32(result); + return OK; + } + + case CLOSE_SESSION: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + reply->writeInt32(closeSession(sessionId)); + return OK; + } + + case GET_KEY_REQUEST: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, initData; + + readVector(data, sessionId); + readVector(data, initData); + String8 mimeType = data.readString8(); + DrmPlugin::KeyType keyType = (DrmPlugin::KeyType)data.readInt32(); + + KeyedVector optionalParameters; + uint32_t count = data.readInt32(); + for (size_t i = 0; i < count; ++i) { + String8 key, value; + key = data.readString8(); + value = data.readString8(); + optionalParameters.add(key, value); + } + + + Vector request; + String8 defaultUrl; + DrmPlugin::KeyRequestType keyRequestType; + + status_t result = getKeyRequest(sessionId, initData, mimeType, + keyType, optionalParameters, request, defaultUrl, + &keyRequestType); + + writeVector(reply, request); + reply->writeString8(defaultUrl); + reply->writeInt32(static_cast(keyRequestType)); + reply->writeInt32(result); + return OK; + } + + case PROVIDE_KEY_RESPONSE: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, response, keySetId; + readVector(data, sessionId); + readVector(data, response); + uint32_t result = provideKeyResponse(sessionId, response, keySetId); + writeVector(reply, keySetId); + reply->writeInt32(result); + return OK; + } + + case REMOVE_KEYS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector keySetId; + readVector(data, keySetId); + reply->writeInt32(removeKeys(keySetId)); + return OK; + } + + case RESTORE_KEYS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keySetId; + readVector(data, sessionId); + readVector(data, keySetId); + reply->writeInt32(restoreKeys(sessionId, keySetId)); + return OK; + } + + case QUERY_KEY_STATUS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + KeyedVector infoMap; + status_t result = queryKeyStatus(sessionId, infoMap); + size_t count = infoMap.size(); + reply->writeInt32(count); + for (size_t i = 0; i < count; ++i) { + reply->writeString8(infoMap.keyAt(i)); + reply->writeString8(infoMap.valueAt(i)); + } + reply->writeInt32(result); + return OK; + } + + case GET_PROVISION_REQUEST: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 certType = data.readString8(); + String8 certAuthority = data.readString8(); + + Vector request; + String8 defaultUrl; + status_t result = getProvisionRequest(certType, certAuthority, + request, defaultUrl); + writeVector(reply, request); + reply->writeString8(defaultUrl); + reply->writeInt32(result); + return OK; + } + + case PROVIDE_PROVISION_RESPONSE: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector response; + Vector certificate; + Vector wrappedKey; + readVector(data, response); + status_t result = provideProvisionResponse(response, certificate, wrappedKey); + writeVector(reply, certificate); + writeVector(reply, wrappedKey); + reply->writeInt32(result); + return OK; + } + + case UNPROVISION_DEVICE: + { + CHECK_INTERFACE(IDrm, data, reply); + status_t result = unprovisionDevice(); + reply->writeInt32(result); + return OK; + } + + case GET_SECURE_STOPS: + { + CHECK_INTERFACE(IDrm, data, reply); + List > secureStops; + status_t result = getSecureStops(secureStops); + size_t count = secureStops.size(); + reply->writeInt32(count); + List >::iterator iter = secureStops.begin(); + while(iter != secureStops.end()) { + size_t size = iter->size(); + reply->writeInt32(size); + reply->write(iter->array(), iter->size()); + iter++; + } + reply->writeInt32(result); + return OK; + } + + case GET_SECURE_STOP: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector ssid, secureStop; + readVector(data, ssid); + status_t result = getSecureStop(ssid, secureStop); + writeVector(reply, secureStop); + reply->writeInt32(result); + return OK; + } + + case RELEASE_SECURE_STOPS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector ssRelease; + readVector(data, ssRelease); + reply->writeInt32(releaseSecureStops(ssRelease)); + return OK; + } + + case RELEASE_ALL_SECURE_STOPS: + { + CHECK_INTERFACE(IDrm, data, reply); + reply->writeInt32(releaseAllSecureStops()); + return OK; + } + + case GET_PROPERTY_STRING: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + String8 value; + status_t result = getPropertyString(name, value); + reply->writeString8(value); + reply->writeInt32(result); + return OK; + } + + case GET_PROPERTY_BYTE_ARRAY: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + Vector value; + status_t result = getPropertyByteArray(name, value); + writeVector(reply, value); + reply->writeInt32(result); + return OK; + } + + case SET_PROPERTY_STRING: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + String8 value = data.readString8(); + reply->writeInt32(setPropertyString(name, value)); + return OK; + } + + case SET_PROPERTY_BYTE_ARRAY: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + Vector value; + readVector(data, value); + reply->writeInt32(setPropertyByteArray(name, value)); + return OK; + } + + case SET_CIPHER_ALGORITHM: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + String8 algorithm = data.readString8(); + reply->writeInt32(setCipherAlgorithm(sessionId, algorithm)); + return OK; + } + + case SET_MAC_ALGORITHM: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + String8 algorithm = data.readString8(); + reply->writeInt32(setMacAlgorithm(sessionId, algorithm)); + return OK; + } + + case ENCRYPT: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, input, iv, output; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, input); + readVector(data, iv); + uint32_t result = encrypt(sessionId, keyId, input, iv, output); + writeVector(reply, output); + reply->writeInt32(result); + return OK; + } + + case DECRYPT: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, input, iv, output; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, input); + readVector(data, iv); + uint32_t result = decrypt(sessionId, keyId, input, iv, output); + writeVector(reply, output); + reply->writeInt32(result); + return OK; + } + + case SIGN: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, message, signature; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, message); + uint32_t result = sign(sessionId, keyId, message, signature); + writeVector(reply, signature); + reply->writeInt32(result); + return OK; + } + + case VERIFY: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, message, signature; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, message); + readVector(data, signature); + bool match; + uint32_t result = verify(sessionId, keyId, message, signature, match); + reply->writeInt32(match); + reply->writeInt32(result); + return OK; + } + + case SIGN_RSA: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, message, wrappedKey, signature; + readVector(data, sessionId); + String8 algorithm = data.readString8(); + readVector(data, message); + readVector(data, wrappedKey); + uint32_t result = signRSA(sessionId, algorithm, message, wrappedKey, signature); + writeVector(reply, signature); + reply->writeInt32(result); + return OK; + } + + case SET_LISTENER: { + CHECK_INTERFACE(IDrm, data, reply); + sp listener = + interface_cast(data.readStrongBinder()); + reply->writeInt32(setListener(listener)); + return NO_ERROR; + } break; + + default: + return BBinder::onTransact(code, data, reply, flags); + } +} +",1,"status_t BnDrm::onTransact( + uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { + switch (code) { + case INIT_CHECK: + { + CHECK_INTERFACE(IDrm, data, reply); + reply->writeInt32(initCheck()); + return OK; + } + + case IS_CRYPTO_SUPPORTED: + { + CHECK_INTERFACE(IDrm, data, reply); + uint8_t uuid[16]; + data.read(uuid, sizeof(uuid)); + String8 mimeType = data.readString8(); + reply->writeInt32(isCryptoSchemeSupported(uuid, mimeType)); + + return OK; + } + + case CREATE_PLUGIN: + { + CHECK_INTERFACE(IDrm, data, reply); + uint8_t uuid[16]; + data.read(uuid, sizeof(uuid)); + reply->writeInt32(createPlugin(uuid)); + return OK; + } + + case DESTROY_PLUGIN: + { + CHECK_INTERFACE(IDrm, data, reply); + reply->writeInt32(destroyPlugin()); + return OK; + } + + case OPEN_SESSION: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + status_t result = openSession(sessionId); + writeVector(reply, sessionId); + reply->writeInt32(result); + return OK; + } + + case CLOSE_SESSION: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + reply->writeInt32(closeSession(sessionId)); + return OK; + } + + case GET_KEY_REQUEST: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, initData; + + readVector(data, sessionId); + readVector(data, initData); + String8 mimeType = data.readString8(); + DrmPlugin::KeyType keyType = (DrmPlugin::KeyType)data.readInt32(); + + KeyedVector optionalParameters; + uint32_t count = data.readInt32(); + for (size_t i = 0; i < count; ++i) { + String8 key, value; + key = data.readString8(); + value = data.readString8(); + optionalParameters.add(key, value); + } + + + Vector request; + String8 defaultUrl; + DrmPlugin::KeyRequestType keyRequestType = DrmPlugin::kKeyRequestType_Unknown; + + status_t result = getKeyRequest(sessionId, initData, mimeType, + keyType, optionalParameters, request, defaultUrl, + &keyRequestType); + + writeVector(reply, request); + reply->writeString8(defaultUrl); + reply->writeInt32(static_cast(keyRequestType)); + reply->writeInt32(result); + return OK; + } + + case PROVIDE_KEY_RESPONSE: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, response, keySetId; + readVector(data, sessionId); + readVector(data, response); + uint32_t result = provideKeyResponse(sessionId, response, keySetId); + writeVector(reply, keySetId); + reply->writeInt32(result); + return OK; + } + + case REMOVE_KEYS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector keySetId; + readVector(data, keySetId); + reply->writeInt32(removeKeys(keySetId)); + return OK; + } + + case RESTORE_KEYS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keySetId; + readVector(data, sessionId); + readVector(data, keySetId); + reply->writeInt32(restoreKeys(sessionId, keySetId)); + return OK; + } + + case QUERY_KEY_STATUS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + KeyedVector infoMap; + status_t result = queryKeyStatus(sessionId, infoMap); + size_t count = infoMap.size(); + reply->writeInt32(count); + for (size_t i = 0; i < count; ++i) { + reply->writeString8(infoMap.keyAt(i)); + reply->writeString8(infoMap.valueAt(i)); + } + reply->writeInt32(result); + return OK; + } + + case GET_PROVISION_REQUEST: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 certType = data.readString8(); + String8 certAuthority = data.readString8(); + + Vector request; + String8 defaultUrl; + status_t result = getProvisionRequest(certType, certAuthority, + request, defaultUrl); + writeVector(reply, request); + reply->writeString8(defaultUrl); + reply->writeInt32(result); + return OK; + } + + case PROVIDE_PROVISION_RESPONSE: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector response; + Vector certificate; + Vector wrappedKey; + readVector(data, response); + status_t result = provideProvisionResponse(response, certificate, wrappedKey); + writeVector(reply, certificate); + writeVector(reply, wrappedKey); + reply->writeInt32(result); + return OK; + } + + case UNPROVISION_DEVICE: + { + CHECK_INTERFACE(IDrm, data, reply); + status_t result = unprovisionDevice(); + reply->writeInt32(result); + return OK; + } + + case GET_SECURE_STOPS: + { + CHECK_INTERFACE(IDrm, data, reply); + List > secureStops; + status_t result = getSecureStops(secureStops); + size_t count = secureStops.size(); + reply->writeInt32(count); + List >::iterator iter = secureStops.begin(); + while(iter != secureStops.end()) { + size_t size = iter->size(); + reply->writeInt32(size); + reply->write(iter->array(), iter->size()); + iter++; + } + reply->writeInt32(result); + return OK; + } + + case GET_SECURE_STOP: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector ssid, secureStop; + readVector(data, ssid); + status_t result = getSecureStop(ssid, secureStop); + writeVector(reply, secureStop); + reply->writeInt32(result); + return OK; + } + + case RELEASE_SECURE_STOPS: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector ssRelease; + readVector(data, ssRelease); + reply->writeInt32(releaseSecureStops(ssRelease)); + return OK; + } + + case RELEASE_ALL_SECURE_STOPS: + { + CHECK_INTERFACE(IDrm, data, reply); + reply->writeInt32(releaseAllSecureStops()); + return OK; + } + + case GET_PROPERTY_STRING: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + String8 value; + status_t result = getPropertyString(name, value); + reply->writeString8(value); + reply->writeInt32(result); + return OK; + } + + case GET_PROPERTY_BYTE_ARRAY: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + Vector value; + status_t result = getPropertyByteArray(name, value); + writeVector(reply, value); + reply->writeInt32(result); + return OK; + } + + case SET_PROPERTY_STRING: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + String8 value = data.readString8(); + reply->writeInt32(setPropertyString(name, value)); + return OK; + } + + case SET_PROPERTY_BYTE_ARRAY: + { + CHECK_INTERFACE(IDrm, data, reply); + String8 name = data.readString8(); + Vector value; + readVector(data, value); + reply->writeInt32(setPropertyByteArray(name, value)); + return OK; + } + + case SET_CIPHER_ALGORITHM: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + String8 algorithm = data.readString8(); + reply->writeInt32(setCipherAlgorithm(sessionId, algorithm)); + return OK; + } + + case SET_MAC_ALGORITHM: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId; + readVector(data, sessionId); + String8 algorithm = data.readString8(); + reply->writeInt32(setMacAlgorithm(sessionId, algorithm)); + return OK; + } + + case ENCRYPT: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, input, iv, output; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, input); + readVector(data, iv); + uint32_t result = encrypt(sessionId, keyId, input, iv, output); + writeVector(reply, output); + reply->writeInt32(result); + return OK; + } + + case DECRYPT: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, input, iv, output; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, input); + readVector(data, iv); + uint32_t result = decrypt(sessionId, keyId, input, iv, output); + writeVector(reply, output); + reply->writeInt32(result); + return OK; + } + + case SIGN: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, message, signature; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, message); + uint32_t result = sign(sessionId, keyId, message, signature); + writeVector(reply, signature); + reply->writeInt32(result); + return OK; + } + + case VERIFY: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, keyId, message, signature; + readVector(data, sessionId); + readVector(data, keyId); + readVector(data, message); + readVector(data, signature); + bool match; + uint32_t result = verify(sessionId, keyId, message, signature, match); + reply->writeInt32(match); + reply->writeInt32(result); + return OK; + } + + case SIGN_RSA: + { + CHECK_INTERFACE(IDrm, data, reply); + Vector sessionId, message, wrappedKey, signature; + readVector(data, sessionId); + String8 algorithm = data.readString8(); + readVector(data, message); + readVector(data, wrappedKey); + uint32_t result = signRSA(sessionId, algorithm, message, wrappedKey, signature); + writeVector(reply, signature); + reply->writeInt32(result); + return OK; + } + + case SET_LISTENER: { + CHECK_INTERFACE(IDrm, data, reply); + sp listener = + interface_cast(data.readStrongBinder()); + reply->writeInt32(setListener(listener)); + return NO_ERROR; + } break; + + default: + return BBinder::onTransact(code, data, reply, flags); + } +} +","@@ -658,7 +658,7 @@ + + + Vector request; + String8 defaultUrl; +- DrmPlugin::KeyRequestType keyRequestType; ++ DrmPlugin::KeyRequestType keyRequestType = DrmPlugin::kKeyRequestType_Unknown; + + status_t result = getKeyRequest(sessionId, initData, mimeType, + keyType, optionalParameters, request, defaultUrl, +",2276,2512,4096 +18289,"static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + struct bpf_insn *insn, + struct bpf_reg_state *dst_reg, + struct bpf_reg_state src_reg) +{ + struct bpf_reg_state *regs = cur_regs(env); + u8 opcode = BPF_OP(insn->code); + bool src_known, dst_known; + s64 smin_val, smax_val; + u64 umin_val, umax_val; + u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; + + if (insn_bitness == 32) { + /* Relevant for 32-bit RSH: Information can propagate towards + * LSB, so it isn't sufficient to only truncate the output to + * 32 bits. + */ + coerce_reg_to_size(dst_reg, 4); + coerce_reg_to_size(&src_reg, 4); + } + + smin_val = src_reg.smin_value; + smax_val = src_reg.smax_value; + umin_val = src_reg.umin_value; + umax_val = src_reg.umax_value; + src_known = tnum_is_const(src_reg.var_off); + dst_known = tnum_is_const(dst_reg->var_off); + + if ((src_known && (smin_val != smax_val || umin_val != umax_val)) || + smin_val > smax_val || umin_val > umax_val) { + /* Taint dst register if offset had invalid bounds derived from + * e.g. dead branches. + */ + __mark_reg_unknown(dst_reg); + return 0; + } + + if (!src_known && + opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND) { + __mark_reg_unknown(dst_reg); + return 0; + } + + switch (opcode) { + case BPF_ADD: + if (signed_add_overflows(dst_reg->smin_value, smin_val) || + signed_add_overflows(dst_reg->smax_value, smax_val)) { + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value += smin_val; + dst_reg->smax_value += smax_val; + } + if (dst_reg->umin_value + umin_val < umin_val || + dst_reg->umax_value + umax_val < umax_val) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value += umin_val; + dst_reg->umax_value += umax_val; + } + dst_reg->var_off = tnum_add(dst_reg->var_off, src_reg.var_off); + break; + case BPF_SUB: + if (signed_sub_overflows(dst_reg->smin_value, smax_val) || + signed_sub_overflows(dst_reg->smax_value, smin_val)) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value -= smax_val; + dst_reg->smax_value -= smin_val; + } + if (dst_reg->umin_value < umax_val) { + /* Overflow possible, we know nothing */ + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + /* Cannot overflow (as long as bounds are consistent) */ + dst_reg->umin_value -= umax_val; + dst_reg->umax_value -= umin_val; + } + dst_reg->var_off = tnum_sub(dst_reg->var_off, src_reg.var_off); + break; + case BPF_MUL: + dst_reg->var_off = tnum_mul(dst_reg->var_off, src_reg.var_off); + if (smin_val < 0 || dst_reg->smin_value < 0) { + /* Ain't nobody got time to multiply that sign */ + __mark_reg_unbounded(dst_reg); + __update_reg_bounds(dst_reg); + break; + } + /* Both values are positive, so we can work with unsigned and + * copy the result to signed (unless it exceeds S64_MAX). + */ + if (umax_val > U32_MAX || dst_reg->umax_value > U32_MAX) { + /* Potential overflow, we know nothing */ + __mark_reg_unbounded(dst_reg); + /* (except what we can learn from the var_off) */ + __update_reg_bounds(dst_reg); + break; + } + dst_reg->umin_value *= umin_val; + dst_reg->umax_value *= umax_val; + if (dst_reg->umax_value > S64_MAX) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + break; + case BPF_AND: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value & + src_reg.var_off.value); + break; + } + /* We get our minimum from the var_off, since that's inherently + * bitwise. Our maximum is the minimum of the operands' maxima. + */ + dst_reg->var_off = tnum_and(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = dst_reg->var_off.value; + dst_reg->umax_value = min(dst_reg->umax_value, umax_val); + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ANDing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ANDing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_OR: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value | + src_reg.var_off.value); + break; + } + /* We get our maximum from the var_off, and our minimum is the + * maximum of the operands' minima + */ + dst_reg->var_off = tnum_or(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = max(dst_reg->umin_value, umin_val); + dst_reg->umax_value = dst_reg->var_off.value | + dst_reg->var_off.mask; + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ORing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ORing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_LSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* We lose all sign bit information (except what we can pick + * up from var_off) + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + /* If we might shift our top bit out, then we know nothing */ + if (dst_reg->umax_value > 1ULL << (63 - umax_val)) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value <<= umin_val; + dst_reg->umax_value <<= umax_val; + } + dst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val); + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_RSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* BPF_RSH is an unsigned shift. If the value in dst_reg might + * be negative, then either: + * 1) src_reg might be zero, so the sign bit of the result is + * unknown, so we lose our signed bounds + * 2) it's known negative, thus the unsigned bounds capture the + * signed bounds + * 3) the signed bounds cross zero, so they tell us nothing + * about the result + * If the value in dst_reg is known nonnegative, then again the + * unsigned bounts capture the signed bounds. + * Thus, in all cases it suffices to blow away our signed bounds + * and rely on inferring new ones from the unsigned bounds and + * var_off of the result. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + dst_reg->var_off = tnum_rshift(dst_reg->var_off, umin_val); + dst_reg->umin_value >>= umax_val; + dst_reg->umax_value >>= umin_val; + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_ARSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + + /* Upon reaching here, src_known is true and + * umax_val is equal to umin_val. + */ + dst_reg->smin_value >>= umin_val; + dst_reg->smax_value >>= umin_val; + dst_reg->var_off = tnum_arshift(dst_reg->var_off, umin_val); + + /* blow away the dst_reg umin_value/umax_value and rely on + * dst_reg var_off to refine the result. + */ + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + __update_reg_bounds(dst_reg); + break; + default: + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + + if (BPF_CLASS(insn->code) != BPF_ALU64) { + /* 32-bit ALU ops are (32,32)->32 */ + coerce_reg_to_size(dst_reg, 4); + } + + __reg_deduce_bounds(dst_reg); + __reg_bound_offset(dst_reg); + return 0; +} +",1,"static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + struct bpf_insn *insn, + struct bpf_reg_state *dst_reg, + struct bpf_reg_state src_reg) +{ + struct bpf_reg_state *regs = cur_regs(env); + u8 opcode = BPF_OP(insn->code); + bool src_known, dst_known; + s64 smin_val, smax_val; + u64 umin_val, umax_val; + u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; + u32 dst = insn->dst_reg; + int ret; + + if (insn_bitness == 32) { + /* Relevant for 32-bit RSH: Information can propagate towards + * LSB, so it isn't sufficient to only truncate the output to + * 32 bits. + */ + coerce_reg_to_size(dst_reg, 4); + coerce_reg_to_size(&src_reg, 4); + } + + smin_val = src_reg.smin_value; + smax_val = src_reg.smax_value; + umin_val = src_reg.umin_value; + umax_val = src_reg.umax_value; + src_known = tnum_is_const(src_reg.var_off); + dst_known = tnum_is_const(dst_reg->var_off); + + if ((src_known && (smin_val != smax_val || umin_val != umax_val)) || + smin_val > smax_val || umin_val > umax_val) { + /* Taint dst register if offset had invalid bounds derived from + * e.g. dead branches. + */ + __mark_reg_unknown(dst_reg); + return 0; + } + + if (!src_known && + opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND) { + __mark_reg_unknown(dst_reg); + return 0; + } + + switch (opcode) { + case BPF_ADD: + ret = sanitize_val_alu(env, insn); + if (ret < 0) { + verbose(env, ""R%d tried to add from different pointers or scalars\n"", dst); + return ret; + } + if (signed_add_overflows(dst_reg->smin_value, smin_val) || + signed_add_overflows(dst_reg->smax_value, smax_val)) { + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value += smin_val; + dst_reg->smax_value += smax_val; + } + if (dst_reg->umin_value + umin_val < umin_val || + dst_reg->umax_value + umax_val < umax_val) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value += umin_val; + dst_reg->umax_value += umax_val; + } + dst_reg->var_off = tnum_add(dst_reg->var_off, src_reg.var_off); + break; + case BPF_SUB: + ret = sanitize_val_alu(env, insn); + if (ret < 0) { + verbose(env, ""R%d tried to sub from different pointers or scalars\n"", dst); + return ret; + } + if (signed_sub_overflows(dst_reg->smin_value, smax_val) || + signed_sub_overflows(dst_reg->smax_value, smin_val)) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value -= smax_val; + dst_reg->smax_value -= smin_val; + } + if (dst_reg->umin_value < umax_val) { + /* Overflow possible, we know nothing */ + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + /* Cannot overflow (as long as bounds are consistent) */ + dst_reg->umin_value -= umax_val; + dst_reg->umax_value -= umin_val; + } + dst_reg->var_off = tnum_sub(dst_reg->var_off, src_reg.var_off); + break; + case BPF_MUL: + dst_reg->var_off = tnum_mul(dst_reg->var_off, src_reg.var_off); + if (smin_val < 0 || dst_reg->smin_value < 0) { + /* Ain't nobody got time to multiply that sign */ + __mark_reg_unbounded(dst_reg); + __update_reg_bounds(dst_reg); + break; + } + /* Both values are positive, so we can work with unsigned and + * copy the result to signed (unless it exceeds S64_MAX). + */ + if (umax_val > U32_MAX || dst_reg->umax_value > U32_MAX) { + /* Potential overflow, we know nothing */ + __mark_reg_unbounded(dst_reg); + /* (except what we can learn from the var_off) */ + __update_reg_bounds(dst_reg); + break; + } + dst_reg->umin_value *= umin_val; + dst_reg->umax_value *= umax_val; + if (dst_reg->umax_value > S64_MAX) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + break; + case BPF_AND: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value & + src_reg.var_off.value); + break; + } + /* We get our minimum from the var_off, since that's inherently + * bitwise. Our maximum is the minimum of the operands' maxima. + */ + dst_reg->var_off = tnum_and(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = dst_reg->var_off.value; + dst_reg->umax_value = min(dst_reg->umax_value, umax_val); + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ANDing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ANDing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_OR: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value | + src_reg.var_off.value); + break; + } + /* We get our maximum from the var_off, and our minimum is the + * maximum of the operands' minima + */ + dst_reg->var_off = tnum_or(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = max(dst_reg->umin_value, umin_val); + dst_reg->umax_value = dst_reg->var_off.value | + dst_reg->var_off.mask; + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ORing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ORing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_LSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* We lose all sign bit information (except what we can pick + * up from var_off) + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + /* If we might shift our top bit out, then we know nothing */ + if (dst_reg->umax_value > 1ULL << (63 - umax_val)) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value <<= umin_val; + dst_reg->umax_value <<= umax_val; + } + dst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val); + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_RSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* BPF_RSH is an unsigned shift. If the value in dst_reg might + * be negative, then either: + * 1) src_reg might be zero, so the sign bit of the result is + * unknown, so we lose our signed bounds + * 2) it's known negative, thus the unsigned bounds capture the + * signed bounds + * 3) the signed bounds cross zero, so they tell us nothing + * about the result + * If the value in dst_reg is known nonnegative, then again the + * unsigned bounts capture the signed bounds. + * Thus, in all cases it suffices to blow away our signed bounds + * and rely on inferring new ones from the unsigned bounds and + * var_off of the result. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + dst_reg->var_off = tnum_rshift(dst_reg->var_off, umin_val); + dst_reg->umin_value >>= umax_val; + dst_reg->umax_value >>= umin_val; + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_ARSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + + /* Upon reaching here, src_known is true and + * umax_val is equal to umin_val. + */ + dst_reg->smin_value >>= umin_val; + dst_reg->smax_value >>= umin_val; + dst_reg->var_off = tnum_arshift(dst_reg->var_off, umin_val); + + /* blow away the dst_reg umin_value/umax_value and rely on + * dst_reg var_off to refine the result. + */ + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + __update_reg_bounds(dst_reg); + break; + default: + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + + if (BPF_CLASS(insn->code) != BPF_ALU64) { + /* 32-bit ALU ops are (32,32)->32 */ + coerce_reg_to_size(dst_reg, 4); + } + + __reg_deduce_bounds(dst_reg); + __reg_bound_offset(dst_reg); + return 0; +} +","@@ -3103,6 +3103,40 @@ static int retrieve_ptr_limit(const struct bpf_reg_state *ptr_reg, + } + } + ++static bool can_skip_alu_sanitation(const struct bpf_verifier_env *env, ++ const struct bpf_insn *insn) ++{ ++ return env->allow_ptr_leaks || BPF_SRC(insn->code) == BPF_K; ++} ++ ++static int update_alu_sanitation_state(struct bpf_insn_aux_data *aux, ++ u32 alu_state, u32 alu_limit) ++{ ++ /* If we arrived here from different branches with different ++ * state or limits to sanitize, then this won't work. ++ */ ++ if (aux->alu_state && ++ (aux->alu_state != alu_state || ++ aux->alu_limit != alu_limit)) ++ return -EACCES; ++ ++ /* Corresponding fixup done in fixup_bpf_calls(). */ ++ aux->alu_state = alu_state; ++ aux->alu_limit = alu_limit; ++ return 0; ++} ++ ++static int sanitize_val_alu(struct bpf_verifier_env *env, ++ struct bpf_insn *insn) ++{ ++ struct bpf_insn_aux_data *aux = cur_aux(env); ++ ++ if (can_skip_alu_sanitation(env, insn)) ++ return 0; ++ ++ return update_alu_sanitation_state(aux, BPF_ALU_NON_POINTER, 0); ++} ++ + static int sanitize_ptr_alu(struct bpf_verifier_env *env, + struct bpf_insn *insn, + const struct bpf_reg_state *ptr_reg, +@@ -3117,7 +3151,7 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, + struct bpf_reg_state tmp; + bool ret; + +- if (env->allow_ptr_leaks || BPF_SRC(insn->code) == BPF_K) ++ if (can_skip_alu_sanitation(env, insn)) + return 0; + + /* We already marked aux for masking from non-speculative +@@ -3133,19 +3167,8 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, + + if (retrieve_ptr_limit(ptr_reg, &alu_limit, opcode, off_is_neg)) + return 0; +- +- /* If we arrived here from different branches with different +- * limits to sanitize, then this won't work. +- */ +- if (aux->alu_state && +- (aux->alu_state != alu_state || +- aux->alu_limit != alu_limit)) ++ if (update_alu_sanitation_state(aux, alu_state, alu_limit)) + return -EACCES; +- +- /* Corresponding fixup done in fixup_bpf_calls(). */ +- aux->alu_state = alu_state; +- aux->alu_limit = alu_limit; +- + do_sim: + /* Simulate and find potential out-of-bounds access under + * speculative execution from truncation as a result of +@@ -3418,6 +3441,8 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + s64 smin_val, smax_val; + u64 umin_val, umax_val; + u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; ++ u32 dst = insn->dst_reg; ++ int ret; + + if (insn_bitness == 32) { + /* Relevant for 32-bit RSH: Information can propagate towards +@@ -3452,6 +3477,11 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + + switch (opcode) { + case BPF_ADD: ++ ret = sanitize_val_alu(env, insn); ++ if (ret < 0) { ++ verbose(env, ""R%d tried to add from different pointers or scalars\n"", dst); ++ return ret; ++ } + if (signed_add_overflows(dst_reg->smin_value, smin_val) || + signed_add_overflows(dst_reg->smax_value, smax_val)) { + dst_reg->smin_value = S64_MIN; +@@ -3471,6 +3501,11 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + dst_reg->var_off = tnum_add(dst_reg->var_off, src_reg.var_off); + break; + case BPF_SUB: ++ ret = sanitize_val_alu(env, insn); ++ if (ret < 0) { ++ verbose(env, ""R%d tried to sub from different pointers or scalars\n"", dst); ++ return ret; ++ } + if (signed_sub_overflows(dst_reg->smin_value, smax_val) || + signed_sub_overflows(dst_reg->smax_value, smin_val)) { + /* Overflow possible, we know nothing */",2654,2890,4096 +17939,"static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray) + { + u_short type, class, dlen; + u_long ttl; + long n, i; + u_short s; + u_char *tp, *p; + char name[MAXHOSTNAMELEN]; + int have_v6_break = 0, in_v6_break = 0; + + *subarray = NULL; + + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, sizeof(name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + + GETSHORT(type, cp); + GETSHORT(class, cp); + GETLONG(ttl, cp); + GETSHORT(dlen, cp); + if (type_to_fetch != T_ANY && type != type_to_fetch) { + cp += dlen; + return cp; + } + + if (!store) { + cp += dlen; + return cp; + } + + ALLOC_INIT_ZVAL(*subarray); + array_init(*subarray); + + add_assoc_string(*subarray, ""host"", name, 1); + add_assoc_string(*subarray, ""class"", ""IN"", 1); + add_assoc_long(*subarray, ""ttl"", ttl); + + if (raw) { + add_assoc_long(*subarray, ""type"", type); + add_assoc_stringl(*subarray, ""data"", (char*) cp, (uint) dlen, 1); + cp += dlen; + return cp; + } + + switch (type) { + case DNS_T_A: + add_assoc_string(*subarray, ""type"", ""A"", 1); + snprintf(name, sizeof(name), ""%d.%d.%d.%d"", cp[0], cp[1], cp[2], cp[3]); + add_assoc_string(*subarray, ""ip"", name, 1); + cp += dlen; + break; + case DNS_T_MX: + add_assoc_string(*subarray, ""type"", ""MX"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pri"", n); + /* no break; */ + case DNS_T_CNAME: + if (type == DNS_T_CNAME) { + add_assoc_string(*subarray, ""type"", ""CNAME"", 1); + } + /* no break; */ + case DNS_T_NS: + if (type == DNS_T_NS) { + add_assoc_string(*subarray, ""type"", ""NS"", 1); + } + /* no break; */ + case DNS_T_PTR: + if (type == DNS_T_PTR) { + add_assoc_string(*subarray, ""type"", ""PTR"", 1); + } + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""target"", name, 1); + break; + case DNS_T_HINFO: + /* See RFC 1010 for values */ + add_assoc_string(*subarray, ""type"", ""HINFO"", 1); + n = *cp & 0xFF; + cp++; + add_assoc_stringl(*subarray, ""cpu"", (char*)cp, n, 1); + cp += n; + n = *cp & 0xFF; + cp++; + add_assoc_stringl(*subarray, ""os"", (char*)cp, n, 1); + cp += n; + break; + case DNS_T_TXT: + { + int ll = 0; + zval *entries = NULL; + + add_assoc_string(*subarray, ""type"", ""TXT"", 1); + tp = emalloc(dlen + 1); + + MAKE_STD_ZVAL(entries); + array_init(entries); + + while (ll < dlen) { + n = cp[ll]; + if ((ll + n) >= dlen) { + n = dlen - (ll + 1); + } + memcpy(tp + ll , cp + ll + 1, n); + add_next_index_stringl(entries, cp + ll + 1, n, 1); + ll = ll + n + 1; + } + tp[dlen] = '\0'; + cp += dlen; + + add_assoc_stringl(*subarray, ""txt"", tp, (dlen>0)?dlen - 1:0, 0); + add_assoc_zval(*subarray, ""entries"", entries); + } + break; + case DNS_T_SOA: + add_assoc_string(*subarray, ""type"", ""SOA"", 1); + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""mname"", name, 1); + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""rname"", name, 1); + GETLONG(n, cp); + add_assoc_long(*subarray, ""serial"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""refresh"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""retry"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""expire"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""minimum-ttl"", n); + break; + case DNS_T_AAAA: + tp = (u_char*)name; + for(i=0; i < 8; i++) { + GETSHORT(s, cp); + if (s != 0) { + if (tp > (u_char *)name) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + tp += sprintf((char*)tp,""%x"",s); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + } + if (have_v6_break && in_v6_break) { + tp[0] = ':'; + tp++; + } + tp[0] = '\0'; + add_assoc_string(*subarray, ""type"", ""AAAA"", 1); + add_assoc_string(*subarray, ""ipv6"", name, 1); + break; + case DNS_T_A6: + p = cp; + add_assoc_string(*subarray, ""type"", ""A6"", 1); + n = ((int)cp[0]) & 0xFF; + cp++; + add_assoc_long(*subarray, ""masklen"", n); + tp = (u_char*)name; + if (n > 15) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } + if (n % 16 > 8) { + /* Partial short */ + if (cp[0] != 0) { + if (tp > (u_char *)name) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + sprintf((char*)tp, ""%x"", cp[0] & 0xFF); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + cp++; + } + for (i = (n + 8) / 16; i < 8; i++) { + GETSHORT(s, cp); + if (s != 0) { + if (tp > (u_char *)name) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + tp += sprintf((char*)tp,""%x"",s); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + } + if (have_v6_break && in_v6_break) { + tp[0] = ':'; + tp++; + } + tp[0] = '\0'; + add_assoc_string(*subarray, ""ipv6"", name, 1); + if (cp < p + dlen) { + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""chain"", name, 1); + } + break; + case DNS_T_SRV: + add_assoc_string(*subarray, ""type"", ""SRV"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pri"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""weight"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""port"", n); + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""target"", name, 1); + break; + case DNS_T_NAPTR: + add_assoc_string(*subarray, ""type"", ""NAPTR"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""order"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pref"", n); + n = (cp[0] & 0xFF); + add_assoc_stringl(*subarray, ""flags"", (char*)++cp, n, 1); + cp += n; + n = (cp[0] & 0xFF); + add_assoc_stringl(*subarray, ""services"", (char*)++cp, n, 1); + cp += n; + n = (cp[0] & 0xFF); + add_assoc_stringl(*subarray, ""regex"", (char*)++cp, n, 1); + cp += n; + n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""replacement"", name, 1); + break; + default: + zval_ptr_dtor(subarray); + *subarray = NULL; + cp += dlen; + break; + } + + return cp; +} +",1,"static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray) +static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray) + { + u_short type, class, dlen; + u_long ttl; + long n, i; + u_short s; + u_char *tp, *p; + char name[MAXHOSTNAMELEN]; + int have_v6_break = 0, in_v6_break = 0; + + *subarray = NULL; + + n = dn_expand(answer->qb2, end, cp, name, sizeof(name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + + CHECKCP(10); + GETSHORT(type, cp); + GETSHORT(class, cp); + GETLONG(ttl, cp); + GETSHORT(dlen, cp); + CHECKCP(dlen); + if (type_to_fetch != T_ANY && type != type_to_fetch) { + cp += dlen; + return cp; + } + + if (!store) { + cp += dlen; + return cp; + } + + ALLOC_INIT_ZVAL(*subarray); + array_init(*subarray); + + add_assoc_string(*subarray, ""host"", name, 1); + add_assoc_string(*subarray, ""class"", ""IN"", 1); + add_assoc_long(*subarray, ""ttl"", ttl); + + if (raw) { + add_assoc_long(*subarray, ""type"", type); + add_assoc_stringl(*subarray, ""data"", (char*) cp, (uint) dlen, 1); + cp += dlen; + return cp; + } + + switch (type) { + case DNS_T_A: + CHECKCP(4); + add_assoc_string(*subarray, ""type"", ""A"", 1); + snprintf(name, sizeof(name), ""%d.%d.%d.%d"", cp[0], cp[1], cp[2], cp[3]); + add_assoc_string(*subarray, ""ip"", name, 1); + cp += dlen; + break; + case DNS_T_MX: + CHECKCP(2); + add_assoc_string(*subarray, ""type"", ""MX"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pri"", n); + /* no break; */ + case DNS_T_CNAME: + if (type == DNS_T_CNAME) { + add_assoc_string(*subarray, ""type"", ""CNAME"", 1); + } + /* no break; */ + case DNS_T_NS: + if (type == DNS_T_NS) { + add_assoc_string(*subarray, ""type"", ""NS"", 1); + } + /* no break; */ + case DNS_T_PTR: + if (type == DNS_T_PTR) { + add_assoc_string(*subarray, ""type"", ""PTR"", 1); + } + n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""target"", name, 1); + break; + case DNS_T_HINFO: + /* See RFC 1010 for values */ + add_assoc_string(*subarray, ""type"", ""HINFO"", 1); + CHECKCP(1); + n = *cp & 0xFF; + cp++; + CHECKCP(n); + add_assoc_stringl(*subarray, ""cpu"", (char*)cp, n, 1); + cp += n; + CHECKCP(1); + n = *cp & 0xFF; + cp++; + CHECKCP(n); + add_assoc_stringl(*subarray, ""os"", (char*)cp, n, 1); + cp += n; + break; + case DNS_T_TXT: + { + int l1 = 0, l2 = 0; + zval *entries = NULL; + + add_assoc_string(*subarray, ""type"", ""TXT"", 1); + tp = emalloc(dlen + 1); + + MAKE_STD_ZVAL(entries); + array_init(entries); + + while (l1 < dlen) { + n = cp[l1]; + if ((l1 + n) >= dlen) { + n = dlen - (l1 + 1); + } + if (n) { + memcpy(tp + l2 , cp + l1 + 1, n); + add_next_index_stringl(entries, cp + l1 + 1, n, 1); + } + l1 = l1 + n + 1; + l2 = l2 + n; + } + tp[l2] = '\0'; + cp += dlen; + + add_assoc_stringl(*subarray, ""txt"", tp, l2, 0); + add_assoc_zval(*subarray, ""entries"", entries); + } + break; + case DNS_T_SOA: + add_assoc_string(*subarray, ""type"", ""SOA"", 1); + n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""mname"", name, 1); + n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""rname"", name, 1); + CHECKCP(5*4); + GETLONG(n, cp); + add_assoc_long(*subarray, ""serial"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""refresh"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""retry"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""expire"", n); + GETLONG(n, cp); + add_assoc_long(*subarray, ""minimum-ttl"", n); + break; + case DNS_T_AAAA: + tp = (u_char*)name; + CHECKCP(8*2); + for(i=0; i < 8; i++) { + GETSHORT(s, cp); + if (s != 0) { + if (tp > (u_char *)name) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + tp += sprintf((char*)tp,""%x"",s); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + } + if (have_v6_break && in_v6_break) { + tp[0] = ':'; + tp++; + } + tp[0] = '\0'; + add_assoc_string(*subarray, ""type"", ""AAAA"", 1); + add_assoc_string(*subarray, ""ipv6"", name, 1); + break; + case DNS_T_A6: + p = cp; + add_assoc_string(*subarray, ""type"", ""A6"", 1); + CHECKCP(1); + n = ((int)cp[0]) & 0xFF; + cp++; + add_assoc_long(*subarray, ""masklen"", n); + tp = (u_char*)name; + if (n > 15) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } + if (n % 16 > 8) { + /* Partial short */ + if (cp[0] != 0) { + if (tp > (u_char *)name) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + sprintf((char*)tp, ""%x"", cp[0] & 0xFF); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + cp++; + } + for (i = (n + 8) / 16; i < 8; i++) { + CHECKCP(2); + GETSHORT(s, cp); + if (s != 0) { + if (tp > (u_char *)name) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + tp += sprintf((char*)tp,""%x"",s); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + } + if (have_v6_break && in_v6_break) { + tp[0] = ':'; + tp++; + } + tp[0] = '\0'; + add_assoc_string(*subarray, ""ipv6"", name, 1); + if (cp < p + dlen) { + n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""chain"", name, 1); + } + break; + case DNS_T_SRV: + CHECKCP(3*2); + add_assoc_string(*subarray, ""type"", ""SRV"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pri"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""weight"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""port"", n); + n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""target"", name, 1); + break; + case DNS_T_NAPTR: + CHECKCP(2*2); + add_assoc_string(*subarray, ""type"", ""NAPTR"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""order"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pref"", n); + + CHECKCP(1); + n = (cp[0] & 0xFF); + cp++; + CHECKCP(n); + add_assoc_stringl(*subarray, ""flags"", (char*)cp, n, 1); + cp += n; + + CHECKCP(1); + n = (cp[0] & 0xFF); + cp++; + CHECKCP(n); + add_assoc_stringl(*subarray, ""services"", (char*)cp, n, 1); + cp += n; + + CHECKCP(1); + n = (cp[0] & 0xFF); + cp++; + CHECKCP(n); + add_assoc_stringl(*subarray, ""regex"", (char*)cp, n, 1); + cp += n; + + n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""replacement"", name, 1); + break; + default: + zval_ptr_dtor(subarray); + *subarray = NULL; + cp += dlen; + break; + } + + return cp; +} +","@@ -412,8 +412,14 @@ PHP_FUNCTION(dns_check_record) + + #if HAVE_FULL_DNS_FUNCS + ++#define CHECKCP(n) do { \ ++ if (cp + n > end) { \ ++ return NULL; \ ++ } \ ++} while (0) ++ + /* {{{ php_parserr */ +-static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray) ++static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray) + { + u_short type, class, dlen; + u_long ttl; +@@ -425,16 +431,18 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + + *subarray = NULL; + +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, sizeof(name) - 2); ++ n = dn_expand(answer->qb2, end, cp, name, sizeof(name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + ++ CHECKCP(10); + GETSHORT(type, cp); + GETSHORT(class, cp); + GETLONG(ttl, cp); + GETSHORT(dlen, cp); ++ CHECKCP(dlen); + if (type_to_fetch != T_ANY && type != type_to_fetch) { + cp += dlen; + return cp; +@@ -461,12 +469,14 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + + switch (type) { + case DNS_T_A: ++ CHECKCP(4); + add_assoc_string(*subarray, ""type"", ""A"", 1); + snprintf(name, sizeof(name), ""%d.%d.%d.%d"", cp[0], cp[1], cp[2], cp[3]); + add_assoc_string(*subarray, ""ip"", name, 1); + cp += dlen; + break; + case DNS_T_MX: ++ CHECKCP(2); + add_assoc_string(*subarray, ""type"", ""MX"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pri"", n); +@@ -485,7 +495,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + if (type == DNS_T_PTR) { + add_assoc_string(*subarray, ""type"", ""PTR"", 1); + } +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); ++ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } +@@ -495,18 +505,22 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + case DNS_T_HINFO: + /* See RFC 1010 for values */ + add_assoc_string(*subarray, ""type"", ""HINFO"", 1); ++ CHECKCP(1); + n = *cp & 0xFF; + cp++; ++ CHECKCP(n); + add_assoc_stringl(*subarray, ""cpu"", (char*)cp, n, 1); + cp += n; ++ CHECKCP(1); + n = *cp & 0xFF; + cp++; ++ CHECKCP(n); + add_assoc_stringl(*subarray, ""os"", (char*)cp, n, 1); + cp += n; + break; + case DNS_T_TXT: + { +- int ll = 0; ++ int l1 = 0, l2 = 0; + zval *entries = NULL; + + add_assoc_string(*subarray, ""type"", ""TXT"", 1); +@@ -515,37 +529,41 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + MAKE_STD_ZVAL(entries); + array_init(entries); + +- while (ll < dlen) { +- n = cp[ll]; +- if ((ll + n) >= dlen) { ++ while (l1 < dlen) { ++ n = cp[l1]; ++ if ((l1 + n) >= dlen) { + // Invalid chunk length, truncate +- n = dlen - (ll + 1); ++ n = dlen - (l1 + 1); ++ } ++ if (n) { ++ memcpy(tp + l2 , cp + l1 + 1, n); ++ add_next_index_stringl(entries, cp + l1 + 1, n, 1); + } +- memcpy(tp + ll , cp + ll + 1, n); +- add_next_index_stringl(entries, cp + ll + 1, n, 1); +- ll = ll + n + 1; ++ l1 = l1 + n + 1; ++ l2 = l2 + n; + } +- tp[dlen] = '\0'; ++ tp[l2] = '\0'; + cp += dlen; + +- add_assoc_stringl(*subarray, ""txt"", tp, (dlen>0)?dlen - 1:0, 0); ++ add_assoc_stringl(*subarray, ""txt"", tp, l2, 0); + add_assoc_zval(*subarray, ""entries"", entries); + } + break; + case DNS_T_SOA: + add_assoc_string(*subarray, ""type"", ""SOA"", 1); +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2); ++ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""mname"", name, 1); +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2); ++ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""rname"", name, 1); ++ CHECKCP(5*4); + GETLONG(n, cp); + add_assoc_long(*subarray, ""serial"", n); + GETLONG(n, cp); +@@ -559,6 +577,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + break; + case DNS_T_AAAA: + tp = (u_char*)name; ++ CHECKCP(8*2); + for(i=0; i < 8; i++) { + GETSHORT(s, cp); + if (s != 0) { +@@ -593,6 +612,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + case DNS_T_A6: + p = cp; + add_assoc_string(*subarray, ""type"", ""A6"", 1); ++ CHECKCP(1); + n = ((int)cp[0]) & 0xFF; + cp++; + add_assoc_long(*subarray, ""masklen"", n); +@@ -628,6 +648,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + cp++; + } + for (i = (n + 8) / 16; i < 8; i++) { ++ CHECKCP(2); + GETSHORT(s, cp); + if (s != 0) { + if (tp > (u_char *)name) { +@@ -657,7 +678,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + tp[0] = '\0'; + add_assoc_string(*subarray, ""ipv6"", name, 1); + if (cp < p + dlen) { +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); ++ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } +@@ -666,36 +687,51 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int + } + break; + case DNS_T_SRV: ++ CHECKCP(3*2); + add_assoc_string(*subarray, ""type"", ""SRV"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pri"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""weight"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""port"", n); +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); ++ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } + cp += n; + add_assoc_string(*subarray, ""target"", name, 1); + break; + case DNS_T_NAPTR: ++ CHECKCP(2*2); + add_assoc_string(*subarray, ""type"", ""NAPTR"", 1); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""order"", n); + GETSHORT(n, cp); + add_assoc_long(*subarray, ""pref"", n); ++ ++ CHECKCP(1); + n = (cp[0] & 0xFF); +- add_assoc_stringl(*subarray, ""flags"", (char*)++cp, n, 1); ++ cp++; ++ CHECKCP(n); ++ add_assoc_stringl(*subarray, ""flags"", (char*)cp, n, 1); + cp += n; ++ ++ CHECKCP(1); + n = (cp[0] & 0xFF); +- add_assoc_stringl(*subarray, ""services"", (char*)++cp, n, 1); ++ cp++; ++ CHECKCP(n); ++ add_assoc_stringl(*subarray, ""services"", (char*)cp, n, 1); + cp += n; ++ ++ CHECKCP(1); + n = (cp[0] & 0xFF); +- add_assoc_stringl(*subarray, ""regex"", (char*)++cp, n, 1); ++ cp++; ++ CHECKCP(n); ++ add_assoc_stringl(*subarray, ""regex"", (char*)cp, n, 1); + cp += n; +- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2); ++ ++ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2); + if (n < 0) { + return NULL; + } +@@ -888,7 +924,7 @@ PHP_FUNCTION(dns_get_record) + while (an-- && cp && cp < end) { + zval *retval; + +- cp = php_parserr(cp, &answer, type_to_fetch, store_results, raw, &retval); ++ cp = php_parserr(cp, end, &answer, type_to_fetch, store_results, raw, &retval); + if (retval != NULL && store_results) { + add_next_index_zval(return_value, retval); + } +@@ -901,7 +937,7 @@ PHP_FUNCTION(dns_get_record) + while (ns-- > 0 && cp && cp < end) { + zval *retval = NULL; + +- cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, raw, &retval); ++ cp = php_parserr(cp, end, &answer, DNS_T_ANY, authns != NULL, raw, &retval); + if (retval != NULL) { + add_next_index_zval(authns, retval); + } +@@ -913,7 +949,7 @@ PHP_FUNCTION(dns_get_record) + while (ar-- > 0 && cp && cp < end) { + zval *retval = NULL; + +- cp = php_parserr(cp, &answer, DNS_T_ANY, 1, raw, &retval); ++ cp = php_parserr(cp, end, &answer, DNS_T_ANY, 1, raw, &retval); + if (retval != NULL) { + add_next_index_zval(addtl, retval); + }",2633,2869,4096 +18026,"static inline unsigned int get_next_char( + enum entity_charset charset, + const unsigned char *str, + size_t str_len, + size_t *cursor, + int *status) +{ + size_t pos = *cursor; + unsigned int this_char = 0; + + *status = SUCCESS; + assert(pos <= str_len); + + if (!CHECK_LEN(pos, 1)) + MB_FAILURE(pos, 1); + + switch (charset) { + case cs_utf_8: + { + /* We'll follow strategy 2. from section 3.6.1 of UTR #36: + * ""In a reported illegal byte sequence, do not include any + * non-initial byte that encodes a valid character or is a leading + * byte for a valid sequence."" */ + unsigned char c; + c = str[pos]; + if (c < 0x80) { + this_char = c; + pos++; + } else if (c < 0xc2) { + MB_FAILURE(pos, 1); + } else if (c < 0xe0) { + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + if (!utf8_trail(str[pos + 1])) { + MB_FAILURE(pos, utf8_lead(str[pos + 1]) ? 1 : 2); + } + this_char = ((c & 0x1f) << 6) | (str[pos + 1] & 0x3f); + if (this_char < 0x80) { /* non-shortest form */ + MB_FAILURE(pos, 2); + } + pos += 2; + } else if (c < 0xf0) { + size_t avail = str_len - pos; + + if (avail < 3 || + !utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2])) { + if (avail < 2 || utf8_lead(str[pos + 1])) + MB_FAILURE(pos, 1); + else if (avail < 3 || utf8_lead(str[pos + 2])) + MB_FAILURE(pos, 2); + else + MB_FAILURE(pos, 3); + } + + this_char = ((c & 0x0f) << 12) | ((str[pos + 1] & 0x3f) << 6) | (str[pos + 2] & 0x3f); + if (this_char < 0x800) { /* non-shortest form */ + MB_FAILURE(pos, 3); + } else if (this_char >= 0xd800 && this_char <= 0xdfff) { /* surrogate */ + MB_FAILURE(pos, 3); + } + pos += 3; + } else if (c < 0xf5) { + size_t avail = str_len - pos; + + if (avail < 4 || + !utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2]) || + !utf8_trail(str[pos + 3])) { + if (avail < 2 || utf8_lead(str[pos + 1])) + MB_FAILURE(pos, 1); + else if (avail < 3 || utf8_lead(str[pos + 2])) + MB_FAILURE(pos, 2); + else if (avail < 4 || utf8_lead(str[pos + 3])) + MB_FAILURE(pos, 3); + else + MB_FAILURE(pos, 4); + } + this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f); + if (this_char < 0x10000 || this_char > 0x10FFFF) { /* non-shortest form or outside range */ + MB_FAILURE(pos, 4); + } + pos += 4; + } else { + MB_FAILURE(pos, 1); + } + } + break; + + case cs_big5: + /* reference http://demo.icu-project.org/icu-bin/convexp?conv=big5 */ + { + unsigned char c = str[pos]; + if (c >= 0x81 && c <= 0xFE) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if ((next >= 0x40 && next <= 0x7E) || + (next >= 0xA1 && next <= 0xFE)) { + this_char = (c << 8) | next; + } else { + MB_FAILURE(pos, 1); + } + pos += 2; + } else { + this_char = c; + pos += 1; + } + } + break; + + case cs_big5hkscs: + { + unsigned char c = str[pos]; + if (c >= 0x81 && c <= 0xFE) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if ((next >= 0x40 && next <= 0x7E) || + (next >= 0xA1 && next <= 0xFE)) { + this_char = (c << 8) | next; + } else if (next != 0x80 && next != 0xFF) { + MB_FAILURE(pos, 1); + } else { + MB_FAILURE(pos, 2); + } + pos += 2; + } else { + this_char = c; + pos += 1; + } + } + break; + + case cs_gb2312: /* EUC-CN */ + { + unsigned char c = str[pos]; + if (c >= 0xA1 && c <= 0xFE) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if (gb2312_trail(next)) { + this_char = (c << 8) | next; + } else if (gb2312_lead(next)) { + MB_FAILURE(pos, 1); + } else { + MB_FAILURE(pos, 2); + } + pos += 2; + } else if (gb2312_lead(c)) { + this_char = c; + pos += 1; + } else { + MB_FAILURE(pos, 1); + } + } + break; + + case cs_sjis: + { + unsigned char c = str[pos]; + if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC)) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if (sjis_trail(next)) { + this_char = (c << 8) | next; + } else if (sjis_lead(next)) { + MB_FAILURE(pos, 1); + } else { + MB_FAILURE(pos, 2); + } + pos += 2; + } else if (c < 0x80 || (c >= 0xA1 && c <= 0xDF)) { + this_char = c; + pos += 1; + } else { + MB_FAILURE(pos, 1); + } + } + break; + + case cs_eucjp: + { + unsigned char c = str[pos]; + + if (c >= 0xA1 && c <= 0xFE) { + unsigned next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + next = str[pos + 1]; + + if (next >= 0xA1 && next <= 0xFE) { + /* this a jis kanji char */ + this_char = (c << 8) | next; + } else { + MB_FAILURE(pos, (next != 0xA0 && next != 0xFF) ? 1 : 2); + } + pos += 2; + } else if (c == 0x8E) { + unsigned next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + if (next >= 0xA1 && next <= 0xDF) { + /* JIS X 0201 kana */ + this_char = (c << 8) | next; + } else { + MB_FAILURE(pos, (next != 0xA0 && next != 0xFF) ? 1 : 2); + } + pos += 2; + } else if (c == 0x8F) { + size_t avail = str_len - pos; + + if (avail < 3 || !(str[pos + 1] >= 0xA1 && str[pos + 1] <= 0xFE) || + !(str[pos + 2] >= 0xA1 && str[pos + 2] <= 0xFE)) { + if (avail < 2 || (str[pos + 1] != 0xA0 && str[pos + 1] != 0xFF)) + MB_FAILURE(pos, 1); + else if (avail < 3 || (str[pos + 2] != 0xA0 && str[pos + 2] != 0xFF)) + MB_FAILURE(pos, 2); + else + MB_FAILURE(pos, 3); + } else { + /* JIS X 0212 hojo-kanji */ + this_char = (c << 16) | (str[pos + 1] << 8) | str[pos + 2]; + } + pos += 3; + } else if (c != 0xA0 && c != 0xFF) { + /* character encoded in 1 code unit */ + this_char = c; + pos += 1; + } else { + MB_FAILURE(pos, 1); + } + } + break; + default: + /* single-byte charsets */ + this_char = str[pos++]; + break; + } + + *cursor = pos; + return this_char; +} +",1,"static inline unsigned int get_next_char( + enum entity_charset charset, + const unsigned char *str, + size_t str_len, + size_t *cursor, + int *status) +{ + size_t pos = *cursor; + unsigned int this_char = 0; + + *status = SUCCESS; + assert(pos <= str_len); + + if (!CHECK_LEN(pos, 1)) + MB_FAILURE(pos, 1); + + switch (charset) { + case cs_utf_8: + { + /* We'll follow strategy 2. from section 3.6.1 of UTR #36: + * ""In a reported illegal byte sequence, do not include any + * non-initial byte that encodes a valid character or is a leading + * byte for a valid sequence."" */ + unsigned char c; + c = str[pos]; + if (c < 0x80) { + this_char = c; + pos++; + } else if (c < 0xc2) { + MB_FAILURE(pos, 1); + } else if (c < 0xe0) { + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + if (!utf8_trail(str[pos + 1])) { + MB_FAILURE(pos, utf8_lead(str[pos + 1]) ? 1 : 2); + } + this_char = ((c & 0x1f) << 6) | (str[pos + 1] & 0x3f); + if (this_char < 0x80) { /* non-shortest form */ + MB_FAILURE(pos, 2); + } + pos += 2; + } else if (c < 0xf0) { + size_t avail = str_len - pos; + + if (avail < 3 || + !utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2])) { + if (avail < 2 || utf8_lead(str[pos + 1])) + MB_FAILURE(pos, 1); + else if (avail < 3 || utf8_lead(str[pos + 2])) + MB_FAILURE(pos, 2); + else + MB_FAILURE(pos, 3); + } + + this_char = ((c & 0x0f) << 12) | ((str[pos + 1] & 0x3f) << 6) | (str[pos + 2] & 0x3f); + if (this_char < 0x800) { /* non-shortest form */ + MB_FAILURE(pos, 3); + } else if (this_char >= 0xd800 && this_char <= 0xdfff) { /* surrogate */ + MB_FAILURE(pos, 3); + } + pos += 3; + } else if (c < 0xf5) { + size_t avail = str_len - pos; + + if (avail < 4 || + !utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2]) || + !utf8_trail(str[pos + 3])) { + if (avail < 2 || utf8_lead(str[pos + 1])) + MB_FAILURE(pos, 1); + else if (avail < 3 || utf8_lead(str[pos + 2])) + MB_FAILURE(pos, 2); + else if (avail < 4 || utf8_lead(str[pos + 3])) + MB_FAILURE(pos, 3); + else + MB_FAILURE(pos, 4); + } + + this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f); + if (this_char < 0x10000 || this_char > 0x10FFFF) { /* non-shortest form or outside range */ + MB_FAILURE(pos, 4); + } + pos += 4; + } else { + MB_FAILURE(pos, 1); + } + } + break; + + case cs_big5: + /* reference http://demo.icu-project.org/icu-bin/convexp?conv=big5 */ + { + unsigned char c = str[pos]; + if (c >= 0x81 && c <= 0xFE) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if ((next >= 0x40 && next <= 0x7E) || + (next >= 0xA1 && next <= 0xFE)) { + this_char = (c << 8) | next; + } else { + MB_FAILURE(pos, 1); + } + pos += 2; + } else { + this_char = c; + pos += 1; + } + } + break; + + case cs_big5hkscs: + { + unsigned char c = str[pos]; + if (c >= 0x81 && c <= 0xFE) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if ((next >= 0x40 && next <= 0x7E) || + (next >= 0xA1 && next <= 0xFE)) { + this_char = (c << 8) | next; + } else if (next != 0x80 && next != 0xFF) { + MB_FAILURE(pos, 1); + } else { + MB_FAILURE(pos, 2); + } + pos += 2; + } else { + this_char = c; + pos += 1; + } + } + break; + + case cs_gb2312: /* EUC-CN */ + { + unsigned char c = str[pos]; + if (c >= 0xA1 && c <= 0xFE) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if (gb2312_trail(next)) { + this_char = (c << 8) | next; + } else if (gb2312_lead(next)) { + MB_FAILURE(pos, 1); + } else { + MB_FAILURE(pos, 2); + } + pos += 2; + } else if (gb2312_lead(c)) { + this_char = c; + pos += 1; + } else { + MB_FAILURE(pos, 1); + } + } + break; + + case cs_sjis: + { + unsigned char c = str[pos]; + if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC)) { + unsigned char next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + + if (sjis_trail(next)) { + this_char = (c << 8) | next; + } else if (sjis_lead(next)) { + MB_FAILURE(pos, 1); + } else { + MB_FAILURE(pos, 2); + } + pos += 2; + } else if (c < 0x80 || (c >= 0xA1 && c <= 0xDF)) { + this_char = c; + pos += 1; + } else { + MB_FAILURE(pos, 1); + } + } + break; + + case cs_eucjp: + { + unsigned char c = str[pos]; + + if (c >= 0xA1 && c <= 0xFE) { + unsigned next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + next = str[pos + 1]; + + if (next >= 0xA1 && next <= 0xFE) { + /* this a jis kanji char */ + this_char = (c << 8) | next; + } else { + MB_FAILURE(pos, (next != 0xA0 && next != 0xFF) ? 1 : 2); + } + pos += 2; + } else if (c == 0x8E) { + unsigned next; + if (!CHECK_LEN(pos, 2)) + MB_FAILURE(pos, 1); + + next = str[pos + 1]; + if (next >= 0xA1 && next <= 0xDF) { + /* JIS X 0201 kana */ + this_char = (c << 8) | next; + } else { + MB_FAILURE(pos, (next != 0xA0 && next != 0xFF) ? 1 : 2); + } + pos += 2; + } else if (c == 0x8F) { + size_t avail = str_len - pos; + + if (avail < 3 || !(str[pos + 1] >= 0xA1 && str[pos + 1] <= 0xFE) || + !(str[pos + 2] >= 0xA1 && str[pos + 2] <= 0xFE)) { + if (avail < 2 || (str[pos + 1] != 0xA0 && str[pos + 1] != 0xFF)) + MB_FAILURE(pos, 1); + else if (avail < 3 || (str[pos + 2] != 0xA0 && str[pos + 2] != 0xFF)) + MB_FAILURE(pos, 2); + else + MB_FAILURE(pos, 3); + } else { + /* JIS X 0212 hojo-kanji */ + this_char = (c << 16) | (str[pos + 1] << 8) | str[pos + 2]; + } + pos += 3; + } else if (c != 0xA0 && c != 0xFF) { + /* character encoded in 1 code unit */ + this_char = c; + pos += 1; + } else { + MB_FAILURE(pos, 1); + } + } + break; + default: + /* single-byte charsets */ + this_char = str[pos++]; + break; + } + + *cursor = pos; + return this_char; +} +","@@ -163,7 +163,7 @@ static inline unsigned int get_next_char( + else + MB_FAILURE(pos, 4); + } +- ++ + this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f); + if (this_char < 0x10000 || this_char > 0x10FFFF) { /* non-shortest form or outside range */ + MB_FAILURE(pos, 4); +@@ -437,7 +437,7 @@ static enum entity_charset determine_charset(char *charset_hint TSRMLS_DC) + + if (charset_hint) { + int found = 0; +- ++ + /* now walk the charset map and look for the codeset */ + for (i = 0; charset_map[i].codeset; i++) { + if (len == strlen(charset_map[i].codeset) && strncasecmp(charset_hint, charset_map[i].codeset, len) == 0) { +@@ -545,7 +545,7 @@ static inline unsigned char unimap_bsearch(const uni_to_enc *table, unsigned cod + return 0; + + code_key = (unsigned short) code_key_a; +- ++ + while (l <= h) { + m = l + (h - l) / 2; + if (code_key < m->un_code_point) +@@ -571,7 +571,7 @@ static inline int map_from_unicode(unsigned code, enum entity_charset charset, u + /* identity mapping of code points to unicode */ + if (code > 0xFF) { + return FAILURE; +- } ++ } + *res = code; + break; + +@@ -590,7 +590,7 @@ static inline int map_from_unicode(unsigned code, enum entity_charset charset, u + return FAILURE; + } + break; +- ++ + case cs_8859_15: + if (code < 0xA4 || (code > 0xBE && code <= 0xFF)) { + *res = code; +@@ -634,7 +634,7 @@ static inline int map_from_unicode(unsigned code, enum entity_charset charset, u + case cs_cp866: + table = unimap_cp866; + table_size = sizeof(unimap_cp866) / sizeof(*unimap_cp866); +- ++ + table_over_7F: + if (code <= 0x7F) { + *res = code; +@@ -710,7 +710,7 @@ static inline int unicode_cp_is_allowed(unsigned uni_cp, int document_type) + * Not sure this is the relevant part for HTML 5, though. I opted to + * disallow the characters that would result in a parse error when + * preprocessing of the input stream. See also section 8.1.3. +- * ++ * + * It's unclear if XHTML 1.0 allows C1 characters. I'll opt to apply to + * XHTML 1.0 the same rules as for XML 1.0. + * See . +@@ -774,7 +774,7 @@ static inline int numeric_entity_is_allowed(unsigned uni_cp, int document_type) + /* {{{ process_numeric_entity + * Auxiliary function to traverse_for_entities. + * On input, *buf should point to the first character after # and on output, it's the last +- * byte read, no matter if there was success or insuccess. ++ * byte read, no matter if there was success or insuccess. + */ + static inline int process_numeric_entity(const char **buf, unsigned *code_point) + { +@@ -784,7 +784,7 @@ static inline int process_numeric_entity(const char **buf, unsigned *code_point) + + if (hexadecimal && (**buf != '\0')) + (*buf)++; +- ++ + /* strtol allows whitespace and other stuff in the beginning + * we're not interested */ + if ((hexadecimal && !isxdigit(**buf)) || +@@ -969,7 +969,7 @@ static void traverse_for_entities( + goto invalid_code; + + /* are we allowed to decode this entity in this document type? +- * HTML 5 is the only that has a character that cannot be used in ++ * HTML 5 is the only that has a character that cannot be used in + * a numeric entity but is allowed literally (U+000D). The + * unoptimized version would be ... || !numeric_entity_is_allowed(code) */ + if (!unicode_cp_is_allowed(code, doctype) || +@@ -996,9 +996,9 @@ static void traverse_for_entities( + } + } + } +- ++ + assert(*next == ';'); +- ++ + if (((code == '\'' && !(flags & ENT_HTML_QUOTE_SINGLE)) || + (code == '""' && !(flags & ENT_HTML_QUOTE_DOUBLE))) + /* && code2 == '\0' always true for current maps */) +@@ -1026,7 +1026,7 @@ static void traverse_for_entities( + *(q++) = *p; + } + } +- ++ + *q = '\0'; + *retlen = (size_t)(q - ret); + } +@@ -1066,7 +1066,7 @@ static entity_table_opt determine_entity_table(int all, int doctype) + entity_table_opt retval = {NULL}; + + assert(!(doctype == ENT_HTML_DOC_XML1 && all)); +- ++ + if (all) { + retval.ms_table = (doctype == ENT_HTML_DOC_HTML5) ? + entity_ms_table_html5 : entity_ms_table_html4; +@@ -1111,13 +1111,13 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_ + if (retlen == 0) { + goto empty_source; + } +- ++ + inverse_map = unescape_inverse_map(all, flags); +- ++ + /* replace numeric entities */ + traverse_for_entities(old, oldlen, ret, &retlen, all, flags, inverse_map, charset); + +-empty_source: ++empty_source: + *newlen = retlen; + return ret; + } +@@ -1141,7 +1141,7 @@ static inline void find_entity_for_char( + { + unsigned stage1_idx = ENT_STAGE1_INDEX(k); + const entity_stage3_row *c; +- ++ + if (stage1_idx > 0x1D) { + *entity = NULL; + *entity_len = 0; +@@ -1162,7 +1162,7 @@ static inline void find_entity_for_char( + if (!(*cursor < oldlen)) + goto no_suitable_2nd; + +- next_char = get_next_char(charset, old, oldlen, cursor, &status); ++ next_char = get_next_char(charset, old, oldlen, cursor, &status); + + if (status == FAILURE) + goto no_suitable_2nd; +@@ -1187,7 +1187,7 @@ static inline void find_entity_for_char( + *entity = (const unsigned char *) + c->data.multicodepoint_table[0].leading_entry.default_entity; + *entity_len = c->data.multicodepoint_table[0].leading_entry.default_entity_len; +- } ++ } + } + /* }}} */ + +@@ -1255,7 +1255,7 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size + + /* initial estimate */ + if (oldlen < 64) { +- maxlen = 128; ++ maxlen = 128; + } else { + maxlen = 2 * oldlen; + if (maxlen < oldlen) { +@@ -1444,6 +1444,10 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all) + } + + replaced = php_escape_html_entities_ex(str, str_len, &new_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC); ++ if (new_len > INT_MAX) { ++ efree(replaced); ++ RETURN_FALSE; ++ } + RETVAL_STRINGL(replaced, (int)new_len, 0); + } + /* }}} */ +@@ -1577,7 +1581,7 @@ static inline void write_s3row_data( + } else { + spe_cp = uni_cp; + } +- ++ + written_k2 = write_octet_sequence(&key[written_k1], charset, spe_cp); + memcpy(&entity[1], mcpr[i].normal_entry.entity, l); + entity[l + 1] = ';'; +@@ -1615,7 +1619,7 @@ PHP_FUNCTION(get_html_translation_table) + LIMIT_ALL(all, doctype, charset); + + array_init(return_value); +- ++ + entity_table = determine_entity_table(all, doctype); + if (all && !CHARSET_UNICODE_COMPAT(charset)) { + to_uni_table = enc_to_uni_index[charset];",2348,2584,4096 +9058,"static void cexp(JF, js_Ast *exp) +{ + int then, end; + int n; + + switch (exp->type) { + case EXP_STRING: + emitline(J, F, exp); + emitstring(J, F, OP_STRING, exp->string); + break; + case EXP_NUMBER: + emitline(J, F, exp); + emitnumber(J, F, exp->number); + break; + case EXP_UNDEF: + emitline(J, F, exp); + emit(J, F, OP_UNDEF); + break; + case EXP_NULL: + emitline(J, F, exp); + emit(J, F, OP_NULL); + break; + case EXP_TRUE: + emitline(J, F, exp); + emit(J, F, OP_TRUE); + break; + case EXP_FALSE: + emitline(J, F, exp); + emit(J, F, OP_FALSE); + break; + case EXP_THIS: + emitline(J, F, exp); + emit(J, F, OP_THIS); + break; + + case EXP_REGEXP: + emitline(J, F, exp); + emit(J, F, OP_NEWREGEXP); + emitarg(J, F, addstring(J, F, exp->string)); + emitarg(J, F, exp->number); + break; + + case EXP_OBJECT: + emitline(J, F, exp); + emit(J, F, OP_NEWOBJECT); + cobject(J, F, exp->a); + break; + + case EXP_ARRAY: + emitline(J, F, exp); + emit(J, F, OP_NEWARRAY); + carray(J, F, exp->a); + break; + + case EXP_FUN: + emitline(J, F, exp); + emitfunction(J, F, newfun(J, exp->line, exp->a, exp->b, exp->c, 0, F->strict)); + break; + + case EXP_IDENTIFIER: + emitline(J, F, exp); + emitlocal(J, F, OP_GETLOCAL, OP_GETVAR, exp); + break; + + case EXP_INDEX: + cexp(J, F, exp->a); + cexp(J, F, exp->b); + emitline(J, F, exp); + emit(J, F, OP_GETPROP); + break; + + case EXP_MEMBER: + cexp(J, F, exp->a); + emitline(J, F, exp); + emitstring(J, F, OP_GETPROP_S, exp->b->string); + break; + + case EXP_CALL: + ccall(J, F, exp->a, exp->b); + break; + + case EXP_NEW: + cexp(J, F, exp->a); + n = cargs(J, F, exp->b); + emitline(J, F, exp); + emit(J, F, OP_NEW); + emitarg(J, F, n); + break; + + case EXP_DELETE: + cdelete(J, F, exp); + break; + + case EXP_PREINC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_INC); + cassignop2(J, F, exp->a, 0); + break; + + case EXP_PREDEC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_DEC); + cassignop2(J, F, exp->a, 0); + break; + + case EXP_POSTINC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POSTINC); + cassignop2(J, F, exp->a, 1); + emit(J, F, OP_POP); + break; + + case EXP_POSTDEC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POSTDEC); + cassignop2(J, F, exp->a, 1); + emit(J, F, OP_POP); + break; + + case EXP_VOID: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POP); + emit(J, F, OP_UNDEF); + break; + + case EXP_TYPEOF: ctypeof(J, F, exp); break; + case EXP_POS: cunary(J, F, exp, OP_POS); break; + case EXP_NEG: cunary(J, F, exp, OP_NEG); break; + case EXP_BITNOT: cunary(J, F, exp, OP_BITNOT); break; + case EXP_LOGNOT: cunary(J, F, exp, OP_LOGNOT); break; + + case EXP_BITOR: cbinary(J, F, exp, OP_BITOR); break; + case EXP_BITXOR: cbinary(J, F, exp, OP_BITXOR); break; + case EXP_BITAND: cbinary(J, F, exp, OP_BITAND); break; + case EXP_EQ: cbinary(J, F, exp, OP_EQ); break; + case EXP_NE: cbinary(J, F, exp, OP_NE); break; + case EXP_STRICTEQ: cbinary(J, F, exp, OP_STRICTEQ); break; + case EXP_STRICTNE: cbinary(J, F, exp, OP_STRICTNE); break; + case EXP_LT: cbinary(J, F, exp, OP_LT); break; + case EXP_GT: cbinary(J, F, exp, OP_GT); break; + case EXP_LE: cbinary(J, F, exp, OP_LE); break; + case EXP_GE: cbinary(J, F, exp, OP_GE); break; + case EXP_INSTANCEOF: cbinary(J, F, exp, OP_INSTANCEOF); break; + case EXP_IN: cbinary(J, F, exp, OP_IN); break; + case EXP_SHL: cbinary(J, F, exp, OP_SHL); break; + case EXP_SHR: cbinary(J, F, exp, OP_SHR); break; + case EXP_USHR: cbinary(J, F, exp, OP_USHR); break; + case EXP_ADD: cbinary(J, F, exp, OP_ADD); break; + case EXP_SUB: cbinary(J, F, exp, OP_SUB); break; + case EXP_MUL: cbinary(J, F, exp, OP_MUL); break; + case EXP_DIV: cbinary(J, F, exp, OP_DIV); break; + case EXP_MOD: cbinary(J, F, exp, OP_MOD); break; + + case EXP_ASS: cassign(J, F, exp); break; + case EXP_ASS_MUL: cassignop(J, F, exp, OP_MUL); break; + case EXP_ASS_DIV: cassignop(J, F, exp, OP_DIV); break; + case EXP_ASS_MOD: cassignop(J, F, exp, OP_MOD); break; + case EXP_ASS_ADD: cassignop(J, F, exp, OP_ADD); break; + case EXP_ASS_SUB: cassignop(J, F, exp, OP_SUB); break; + case EXP_ASS_SHL: cassignop(J, F, exp, OP_SHL); break; + case EXP_ASS_SHR: cassignop(J, F, exp, OP_SHR); break; + case EXP_ASS_USHR: cassignop(J, F, exp, OP_USHR); break; + case EXP_ASS_BITAND: cassignop(J, F, exp, OP_BITAND); break; + case EXP_ASS_BITXOR: cassignop(J, F, exp, OP_BITXOR); break; + case EXP_ASS_BITOR: cassignop(J, F, exp, OP_BITOR); break; + + case EXP_COMMA: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POP); + cexp(J, F, exp->b); + break; + + case EXP_LOGOR: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_DUP); + end = emitjump(J, F, OP_JTRUE); + emit(J, F, OP_POP); + cexp(J, F, exp->b); + label(J, F, end); + break; + + case EXP_LOGAND: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_DUP); + end = emitjump(J, F, OP_JFALSE); + emit(J, F, OP_POP); + cexp(J, F, exp->b); + label(J, F, end); + break; + + case EXP_COND: + cexp(J, F, exp->a); + emitline(J, F, exp); + then = emitjump(J, F, OP_JTRUE); + cexp(J, F, exp->c); + end = emitjump(J, F, OP_JUMP); + label(J, F, then); + cexp(J, F, exp->b); + label(J, F, end); + break; + + default: + jsC_error(J, exp, ""unknown expression: (%s)"", jsP_aststring(exp->type)); + } +} +",0,"static void cexp(JF, js_Ast *exp) +{ + int then, end; + int n; + + switch (exp->type) { + case EXP_STRING: + emitline(J, F, exp); + emitstring(J, F, OP_STRING, exp->string); + break; + case EXP_NUMBER: + emitline(J, F, exp); + emitnumber(J, F, exp->number); + break; + case EXP_UNDEF: + emitline(J, F, exp); + emit(J, F, OP_UNDEF); + break; + case EXP_NULL: + emitline(J, F, exp); + emit(J, F, OP_NULL); + break; + case EXP_TRUE: + emitline(J, F, exp); + emit(J, F, OP_TRUE); + break; + case EXP_FALSE: + emitline(J, F, exp); + emit(J, F, OP_FALSE); + break; + case EXP_THIS: + emitline(J, F, exp); + emit(J, F, OP_THIS); + break; + + case EXP_REGEXP: + emitline(J, F, exp); + emit(J, F, OP_NEWREGEXP); + emitarg(J, F, addstring(J, F, exp->string)); + emitarg(J, F, exp->number); + break; + + case EXP_OBJECT: + emitline(J, F, exp); + emit(J, F, OP_NEWOBJECT); + cobject(J, F, exp->a); + break; + + case EXP_ARRAY: + emitline(J, F, exp); + emit(J, F, OP_NEWARRAY); + carray(J, F, exp->a); + break; + + case EXP_FUN: + emitline(J, F, exp); + emitfunction(J, F, newfun(J, exp->line, exp->a, exp->b, exp->c, 0, F->strict)); + break; + + case EXP_IDENTIFIER: + emitline(J, F, exp); + emitlocal(J, F, OP_GETLOCAL, OP_GETVAR, exp); + break; + + case EXP_INDEX: + cexp(J, F, exp->a); + cexp(J, F, exp->b); + emitline(J, F, exp); + emit(J, F, OP_GETPROP); + break; + + case EXP_MEMBER: + cexp(J, F, exp->a); + emitline(J, F, exp); + emitstring(J, F, OP_GETPROP_S, exp->b->string); + break; + + case EXP_CALL: + ccall(J, F, exp->a, exp->b); + break; + + case EXP_NEW: + cexp(J, F, exp->a); + n = cargs(J, F, exp->b); + emitline(J, F, exp); + emit(J, F, OP_NEW); + emitarg(J, F, n); + break; + + case EXP_DELETE: + cdelete(J, F, exp); + break; + + case EXP_PREINC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_INC); + cassignop2(J, F, exp->a, 0); + break; + + case EXP_PREDEC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_DEC); + cassignop2(J, F, exp->a, 0); + break; + + case EXP_POSTINC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POSTINC); + cassignop2(J, F, exp->a, 1); + emit(J, F, OP_POP); + break; + + case EXP_POSTDEC: + cassignop1(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POSTDEC); + cassignop2(J, F, exp->a, 1); + emit(J, F, OP_POP); + break; + + case EXP_VOID: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POP); + emit(J, F, OP_UNDEF); + break; + + case EXP_TYPEOF: ctypeof(J, F, exp); break; + case EXP_POS: cunary(J, F, exp, OP_POS); break; + case EXP_NEG: cunary(J, F, exp, OP_NEG); break; + case EXP_BITNOT: cunary(J, F, exp, OP_BITNOT); break; + case EXP_LOGNOT: cunary(J, F, exp, OP_LOGNOT); break; + + case EXP_BITOR: cbinary(J, F, exp, OP_BITOR); break; + case EXP_BITXOR: cbinary(J, F, exp, OP_BITXOR); break; + case EXP_BITAND: cbinary(J, F, exp, OP_BITAND); break; + case EXP_EQ: cbinary(J, F, exp, OP_EQ); break; + case EXP_NE: cbinary(J, F, exp, OP_NE); break; + case EXP_STRICTEQ: cbinary(J, F, exp, OP_STRICTEQ); break; + case EXP_STRICTNE: cbinary(J, F, exp, OP_STRICTNE); break; + case EXP_LT: cbinary(J, F, exp, OP_LT); break; + case EXP_GT: cbinary(J, F, exp, OP_GT); break; + case EXP_LE: cbinary(J, F, exp, OP_LE); break; + case EXP_GE: cbinary(J, F, exp, OP_GE); break; + case EXP_INSTANCEOF: cbinary(J, F, exp, OP_INSTANCEOF); break; + case EXP_IN: cbinary(J, F, exp, OP_IN); break; + case EXP_SHL: cbinary(J, F, exp, OP_SHL); break; + case EXP_SHR: cbinary(J, F, exp, OP_SHR); break; + case EXP_USHR: cbinary(J, F, exp, OP_USHR); break; + case EXP_ADD: cbinary(J, F, exp, OP_ADD); break; + case EXP_SUB: cbinary(J, F, exp, OP_SUB); break; + case EXP_MUL: cbinary(J, F, exp, OP_MUL); break; + case EXP_DIV: cbinary(J, F, exp, OP_DIV); break; + case EXP_MOD: cbinary(J, F, exp, OP_MOD); break; + + case EXP_ASS: cassign(J, F, exp); break; + case EXP_ASS_MUL: cassignop(J, F, exp, OP_MUL); break; + case EXP_ASS_DIV: cassignop(J, F, exp, OP_DIV); break; + case EXP_ASS_MOD: cassignop(J, F, exp, OP_MOD); break; + case EXP_ASS_ADD: cassignop(J, F, exp, OP_ADD); break; + case EXP_ASS_SUB: cassignop(J, F, exp, OP_SUB); break; + case EXP_ASS_SHL: cassignop(J, F, exp, OP_SHL); break; + case EXP_ASS_SHR: cassignop(J, F, exp, OP_SHR); break; + case EXP_ASS_USHR: cassignop(J, F, exp, OP_USHR); break; + case EXP_ASS_BITAND: cassignop(J, F, exp, OP_BITAND); break; + case EXP_ASS_BITXOR: cassignop(J, F, exp, OP_BITXOR); break; + case EXP_ASS_BITOR: cassignop(J, F, exp, OP_BITOR); break; + + case EXP_COMMA: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_POP); + cexp(J, F, exp->b); + break; + + case EXP_LOGOR: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_DUP); + end = emitjump(J, F, OP_JTRUE); + emit(J, F, OP_POP); + cexp(J, F, exp->b); + label(J, F, end); + break; + + case EXP_LOGAND: + cexp(J, F, exp->a); + emitline(J, F, exp); + emit(J, F, OP_DUP); + end = emitjump(J, F, OP_JFALSE); + emit(J, F, OP_POP); + cexp(J, F, exp->b); + label(J, F, end); + break; + + case EXP_COND: + cexp(J, F, exp->a); + emitline(J, F, exp); + then = emitjump(J, F, OP_JTRUE); + cexp(J, F, exp->c); + end = emitjump(J, F, OP_JUMP); + label(J, F, then); + cexp(J, F, exp->b); + label(J, F, end); + break; + + default: + jsC_error(J, exp, ""unknown expression: (%s)"", jsP_aststring(exp->type)); + } +} +","@@ -1023,6 +1023,7 @@ static void ctrycatchfinally(JF, js_Ast *trystm, js_Ast *catchvar, js_Ast *catch + emitstring(J, F, OP_CATCH, catchvar->string); + cstm(J, F, catchstm); + emit(J, F, OP_ENDCATCH); ++ emit(J, F, OP_ENDTRY); + L3 = emitjump(J, F, OP_JUMP); /* skip past the try block to the finally block */ + } + label(J, F, L1);",1931,2167,4096 +9504,"doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, + size_t size, off_t fsize, int mach, int strtab, int *flags, + uint16_t *notecount) +{ + Elf32_Shdr sh32; + Elf64_Shdr sh64; + int stripped = 1; + size_t nbadcap = 0; + void *nbuf; + off_t noff, coff, name_off; + uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */ + uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */ + char name[50]; + ssize_t namesize; + + if (size != xsh_sizeof) { + if (file_printf(ms, "", corrupted section header size"") == -1) + return -1; + return 0; + } + + /* Read offset of name section to be able to read section names later */ + if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab))) + < (ssize_t)xsh_sizeof) { + file_badread(ms); + return -1; + } + name_off = xsh_offset; + + for ( ; num; num--) { + /* Read the name of this section. */ + if ((namesize = pread(fd, name, sizeof(name) - 1, name_off + xsh_name)) == -1) { + file_badread(ms); + return -1; + } + name[namesize] = '\0'; + if (strcmp(name, "".debug_info"") == 0) + stripped = 0; + + if (pread(fd, xsh_addr, xsh_sizeof, off) < (ssize_t)xsh_sizeof) { + file_badread(ms); + return -1; + } + off += size; + + /* Things we can determine before we seek */ + switch (xsh_type) { + case SHT_SYMTAB: +#if 0 + case SHT_DYNSYM: +#endif + stripped = 0; + break; + default: + if (fsize != SIZE_UNKNOWN && xsh_offset > fsize) { + /* Perhaps warn here */ + continue; + } + break; + } + + + /* Things we can determine when we seek */ + switch (xsh_type) { + case SHT_NOTE: + if ((uintmax_t)(xsh_size + xsh_offset) > + (uintmax_t)fsize) { + if (file_printf(ms, + "", note offset/size 0x%"" INTMAX_T_FORMAT + ""x+0x%"" INTMAX_T_FORMAT ""x exceeds"" + "" file size 0x%"" INTMAX_T_FORMAT ""x"", + (uintmax_t)xsh_offset, (uintmax_t)xsh_size, + (uintmax_t)fsize) == -1) + return -1; + return 0; + } + if ((nbuf = malloc(xsh_size)) == NULL) { + file_error(ms, errno, ""Cannot allocate memory"" + "" for note""); + return -1; + } + if (pread(fd, nbuf, xsh_size, xsh_offset) < + (ssize_t)xsh_size) { + file_badread(ms); + free(nbuf); + return -1; + } + + noff = 0; + for (;;) { + if (noff >= (off_t)xsh_size) + break; + noff = donote(ms, nbuf, (size_t)noff, + xsh_size, clazz, swap, 4, flags, notecount, + fd, 0, 0, 0); + if (noff == 0) + break; + } + free(nbuf); + break; + case SHT_SUNW_cap: + switch (mach) { + case EM_SPARC: + case EM_SPARCV9: + case EM_IA_64: + case EM_386: + case EM_AMD64: + break; + default: + goto skip; + } + + if (nbadcap > 5) + break; + if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) { + file_badseek(ms); + return -1; + } + coff = 0; + for (;;) { + Elf32_Cap cap32; + Elf64_Cap cap64; + char cbuf[/*CONSTCOND*/ + MAX(sizeof cap32, sizeof cap64)]; + if ((coff += xcap_sizeof) > (off_t)xsh_size) + break; + if (read(fd, cbuf, (size_t)xcap_sizeof) != + (ssize_t)xcap_sizeof) { + file_badread(ms); + return -1; + } + if (cbuf[0] == 'A') { +#ifdef notyet + char *p = cbuf + 1; + uint32_t len, tag; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (memcmp(""gnu"", p, 3) != 0) { + if (file_printf(ms, + "", unknown capability %.3s"", p) + == -1) + return -1; + break; + } + p += strlen(p) + 1; + tag = *p++; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (tag != 1) { + if (file_printf(ms, "", unknown gnu"" + "" capability tag %d"", tag) + == -1) + return -1; + break; + } +#endif + break; + } + (void)memcpy(xcap_addr, cbuf, xcap_sizeof); + switch (xcap_tag) { + case CA_SUNW_NULL: + break; + case CA_SUNW_HW_1: + cap_hw1 |= xcap_val; + break; + case CA_SUNW_SF_1: + cap_sf1 |= xcap_val; + break; + default: + if (file_printf(ms, + "", with unknown capability "" + ""0x%"" INT64_T_FORMAT ""x = 0x%"" + INT64_T_FORMAT ""x"", + (unsigned long long)xcap_tag, + (unsigned long long)xcap_val) == -1) + return -1; + if (nbadcap++ > 2) + coff = xsh_size; + break; + } + } + /*FALLTHROUGH*/ + skip: + default: + break; + } + } + + if (file_printf(ms, "", %sstripped"", stripped ? """" : ""not "") == -1) + return -1; + if (cap_hw1) { + const cap_desc_t *cdp; + switch (mach) { + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + cdp = cap_desc_sparc; + break; + case EM_386: + case EM_IA_64: + case EM_AMD64: + cdp = cap_desc_386; + break; + default: + cdp = NULL; + break; + } + if (file_printf(ms, "", uses"") == -1) + return -1; + if (cdp) { + while (cdp->cd_name) { + if (cap_hw1 & cdp->cd_mask) { + if (file_printf(ms, + "" %s"", cdp->cd_name) == -1) + return -1; + cap_hw1 &= ~cdp->cd_mask; + } + ++cdp; + } + if (cap_hw1) + if (file_printf(ms, + "" unknown hardware capability 0x%"" + INT64_T_FORMAT ""x"", + (unsigned long long)cap_hw1) == -1) + return -1; + } else { + if (file_printf(ms, + "" hardware capability 0x%"" INT64_T_FORMAT ""x"", + (unsigned long long)cap_hw1) == -1) + return -1; + } + } + if (cap_sf1) { + if (cap_sf1 & SF1_SUNW_FPUSED) { + if (file_printf(ms, + (cap_sf1 & SF1_SUNW_FPKNWN) + ? "", uses frame pointer"" + : "", not known to use frame pointer"") == -1) + return -1; + } + cap_sf1 &= ~SF1_SUNW_MASK; + if (cap_sf1) + if (file_printf(ms, + "", with unknown software capability 0x%"" + INT64_T_FORMAT ""x"", + (unsigned long long)cap_sf1) == -1) + return -1; + } + return 0; +} +",0,"doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, + size_t size, off_t fsize, int mach, int strtab, int *flags, + uint16_t *notecount) +{ + Elf32_Shdr sh32; + Elf64_Shdr sh64; + int stripped = 1; + size_t nbadcap = 0; + void *nbuf; + off_t noff, coff, name_off; + uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */ + uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */ + char name[50]; + ssize_t namesize; + + if (size != xsh_sizeof) { + if (file_printf(ms, "", corrupted section header size"") == -1) + return -1; + return 0; + } + + /* Read offset of name section to be able to read section names later */ + if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab))) + < (ssize_t)xsh_sizeof) { + file_badread(ms); + return -1; + } + name_off = xsh_offset; + + for ( ; num; num--) { + /* Read the name of this section. */ + if ((namesize = pread(fd, name, sizeof(name) - 1, name_off + xsh_name)) == -1) { + file_badread(ms); + return -1; + } + name[namesize] = '\0'; + if (strcmp(name, "".debug_info"") == 0) + stripped = 0; + + if (pread(fd, xsh_addr, xsh_sizeof, off) < (ssize_t)xsh_sizeof) { + file_badread(ms); + return -1; + } + off += size; + + /* Things we can determine before we seek */ + switch (xsh_type) { + case SHT_SYMTAB: +#if 0 + case SHT_DYNSYM: +#endif + stripped = 0; + break; + default: + if (fsize != SIZE_UNKNOWN && xsh_offset > fsize) { + /* Perhaps warn here */ + continue; + } + break; + } + + + /* Things we can determine when we seek */ + switch (xsh_type) { + case SHT_NOTE: + if ((uintmax_t)(xsh_size + xsh_offset) > + (uintmax_t)fsize) { + if (file_printf(ms, + "", note offset/size 0x%"" INTMAX_T_FORMAT + ""x+0x%"" INTMAX_T_FORMAT ""x exceeds"" + "" file size 0x%"" INTMAX_T_FORMAT ""x"", + (uintmax_t)xsh_offset, (uintmax_t)xsh_size, + (uintmax_t)fsize) == -1) + return -1; + return 0; + } + if ((nbuf = malloc(xsh_size)) == NULL) { + file_error(ms, errno, ""Cannot allocate memory"" + "" for note""); + return -1; + } + if (pread(fd, nbuf, xsh_size, xsh_offset) < + (ssize_t)xsh_size) { + file_badread(ms); + free(nbuf); + return -1; + } + + noff = 0; + for (;;) { + if (noff >= (off_t)xsh_size) + break; + noff = donote(ms, nbuf, (size_t)noff, + xsh_size, clazz, swap, 4, flags, notecount, + fd, 0, 0, 0); + if (noff == 0) + break; + } + free(nbuf); + break; + case SHT_SUNW_cap: + switch (mach) { + case EM_SPARC: + case EM_SPARCV9: + case EM_IA_64: + case EM_386: + case EM_AMD64: + break; + default: + goto skip; + } + + if (nbadcap > 5) + break; + if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) { + file_badseek(ms); + return -1; + } + coff = 0; + for (;;) { + Elf32_Cap cap32; + Elf64_Cap cap64; + char cbuf[/*CONSTCOND*/ + MAX(sizeof cap32, sizeof cap64)]; + if ((coff += xcap_sizeof) > (off_t)xsh_size) + break; + if (read(fd, cbuf, (size_t)xcap_sizeof) != + (ssize_t)xcap_sizeof) { + file_badread(ms); + return -1; + } + if (cbuf[0] == 'A') { +#ifdef notyet + char *p = cbuf + 1; + uint32_t len, tag; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (memcmp(""gnu"", p, 3) != 0) { + if (file_printf(ms, + "", unknown capability %.3s"", p) + == -1) + return -1; + break; + } + p += strlen(p) + 1; + tag = *p++; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (tag != 1) { + if (file_printf(ms, "", unknown gnu"" + "" capability tag %d"", tag) + == -1) + return -1; + break; + } +#endif + break; + } + (void)memcpy(xcap_addr, cbuf, xcap_sizeof); + switch (xcap_tag) { + case CA_SUNW_NULL: + break; + case CA_SUNW_HW_1: + cap_hw1 |= xcap_val; + break; + case CA_SUNW_SF_1: + cap_sf1 |= xcap_val; + break; + default: + if (file_printf(ms, + "", with unknown capability "" + ""0x%"" INT64_T_FORMAT ""x = 0x%"" + INT64_T_FORMAT ""x"", + (unsigned long long)xcap_tag, + (unsigned long long)xcap_val) == -1) + return -1; + if (nbadcap++ > 2) + coff = xsh_size; + break; + } + } + /*FALLTHROUGH*/ + skip: + default: + break; + } + } + + if (file_printf(ms, "", %sstripped"", stripped ? """" : ""not "") == -1) + return -1; + if (cap_hw1) { + const cap_desc_t *cdp; + switch (mach) { + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + cdp = cap_desc_sparc; + break; + case EM_386: + case EM_IA_64: + case EM_AMD64: + cdp = cap_desc_386; + break; + default: + cdp = NULL; + break; + } + if (file_printf(ms, "", uses"") == -1) + return -1; + if (cdp) { + while (cdp->cd_name) { + if (cap_hw1 & cdp->cd_mask) { + if (file_printf(ms, + "" %s"", cdp->cd_name) == -1) + return -1; + cap_hw1 &= ~cdp->cd_mask; + } + ++cdp; + } + if (cap_hw1) + if (file_printf(ms, + "" unknown hardware capability 0x%"" + INT64_T_FORMAT ""x"", + (unsigned long long)cap_hw1) == -1) + return -1; + } else { + if (file_printf(ms, + "" hardware capability 0x%"" INT64_T_FORMAT ""x"", + (unsigned long long)cap_hw1) == -1) + return -1; + } + } + if (cap_sf1) { + if (cap_sf1 & SF1_SUNW_FPUSED) { + if (file_printf(ms, + (cap_sf1 & SF1_SUNW_FPKNWN) + ? "", uses frame pointer"" + : "", not known to use frame pointer"") == -1) + return -1; + } + cap_sf1 &= ~SF1_SUNW_MASK; + if (cap_sf1) + if (file_printf(ms, + "", with unknown software capability 0x%"" + INT64_T_FORMAT ""x"", + (unsigned long long)cap_sf1) == -1) + return -1; + } + return 0; +} +","@@ -27,7 +27,7 @@ + #include ""file.h"" + + #ifndef lint +-FILE_RCSID(""@(#)$File: readelf.c,v 1.126 2015/11/16 16:03:45 christos Exp $"") ++FILE_RCSID(""@(#)$File: readelf.c,v 1.127 2015/11/18 12:29:29 christos Exp $"") + #endif + + #ifdef BUILTIN_ELF +@@ -509,12 +509,26 @@ do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, + size_t noff, size_t doff, int *flags) + { + if (namesz == 4 && strcmp((char *)&nbuf[noff], ""GNU"") == 0 && +- type == NT_GNU_BUILD_ID && (descsz == 16 || descsz == 20)) { ++ type == NT_GNU_BUILD_ID && (descsz >= 4 || descsz <= 20)) { + uint8_t desc[20]; ++ const char *btype; + uint32_t i; + *flags |= FLAGS_DID_BUILD_ID; +- if (file_printf(ms, "", BuildID[%s]="", descsz == 16 ? ""md5/uuid"" : +- ""sha1"") == -1) ++ switch (descsz) { ++ case 8: ++ btype = ""xxHash""; ++ break; ++ case 16: ++ btype = ""md5/uuid""; ++ break; ++ case 20: ++ btype = ""sha1""; ++ break; ++ default: ++ btype = ""unknown""; ++ break; ++ } ++ if (file_printf(ms, "", BuildID[%s]="", btype) == -1) + return 1; + (void)memcpy(desc, &nbuf[doff], descsz); + for (i = 0; i < descsz; i++)",1992,2228,4096 +15911,"void GLES2DecoderImpl::DoCopyTexImage2D( + GLenum target, + GLint level, + GLenum internal_format, + GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLint border) { + const char* func_name = ""glCopyTexImage2D""; + DCHECK(!ShouldDeferReads()); + TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( + &state_, target); + if (!texture_ref) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, func_name, ""unknown texture for target""); + return; + } + Texture* texture = texture_ref->texture(); + if (texture->IsImmutable()) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, func_name, ""texture is immutable""); + return; + } + if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || + border != 0) { + LOCAL_SET_GL_ERROR( + GL_INVALID_VALUE, func_name, ""dimensions out of range""); + return; + } + + if (!CheckBoundReadFramebufferValid(func_name, + GL_INVALID_FRAMEBUFFER_OPERATION)) { + return; + } + + GLenum read_format = GetBoundReadFramebufferInternalFormat(); + GLenum read_type = GetBoundReadFramebufferTextureType(); + if (!ValidateCopyTexFormat(func_name, internal_format, + read_format, read_type)) { + return; + } + + uint32_t pixels_size = 0; + GLenum format = + TextureManager::ExtractFormatFromStorageFormat(internal_format); + GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); + bool internal_format_unsized = internal_format == format; + if (internal_format_unsized && feature_info_->IsWebGL2OrES3Context()) { + DCHECK(type == GL_UNSIGNED_BYTE); + switch (internal_format) { + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE: + case GL_ALPHA: + case GL_BGRA_EXT: + break; + default: + format = GL_NONE; + break; + } + } + if (!format || !type) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + func_name, ""Invalid unsized internal format.""); + return; + } + + DCHECK(texture_manager()->ValidateTextureParameters( + GetErrorState(), func_name, true, format, type, internal_format, level)); + + if (!GLES2Util::ComputeImageDataSizes(width, height, 1, format, type, + state_.unpack_alignment, &pixels_size, + nullptr, nullptr)) { + LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, ""dimensions too large""); + return; + } + + if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + func_name, ""source and destination textures are the same""); + return; + } + + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); + ScopedResolvedFramebufferBinder binder(this, false, true); + gfx::Size size = GetBoundReadFramebufferSize(); + + if (texture->IsAttachedToFramebuffer()) { + framebuffer_state_.clear_state_dirty = true; + } + + bool requires_luma_blit = + CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), + format); + if (requires_luma_blit && + !InitializeCopyTexImageBlitter(func_name)) { + return; + } + + bool reset_source_texture_base_level_max_level = false; + GLint attached_texture_level = -1; + Framebuffer* framebuffer = GetBoundReadFramebuffer(); + if (framebuffer) { + const Framebuffer::Attachment* attachment = + framebuffer->GetReadBufferAttachment(); + if (attachment->IsTexture(texture_ref)) { + DCHECK(attachment->IsTextureAttachment()); + attached_texture_level = attachment->level(); + DCHECK_GE(attached_texture_level, 0); + if (attached_texture_level != texture->base_level()) + reset_source_texture_base_level_max_level = true; + } + } + if (reset_source_texture_base_level_max_level) { + api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, + attached_texture_level); + api()->glTexParameteriFn(target, GL_TEXTURE_MAX_LEVEL, + attached_texture_level); + } + + gfx::Rect src(x, y, width, height); + const gfx::Rect dst(0, 0, size.width(), size.height()); + src.Intersect(dst); + + GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( + feature_info_.get(), internal_format); + if (workarounds().force_int_or_srgb_cube_texture_complete && + texture->target() == GL_TEXTURE_CUBE_MAP && + (GLES2Util::IsIntegerFormat(final_internal_format) || + GLES2Util::GetColorEncodingFromInternalFormat(final_internal_format) == + GL_SRGB)) { + TextureManager::DoTexImageArguments args = { + target, + level, + final_internal_format, + width, + height, + 1, + border, + format, + type, + nullptr, + pixels_size, + 0, + TextureManager::DoTexImageArguments::kTexImage2D}; + texture_manager()->WorkaroundCopyTexImageCubeMap( + &texture_state_, &state_, &framebuffer_state_, texture_ref, func_name, + args); + } + + if (src.x() != x || src.y() != y || + src.width() != width || src.height() != height || + final_internal_format == GL_BGRA_EXT) { + { + + std::unique_ptr zero(new char[pixels_size]); + memset(zero.get(), 0, pixels_size); + ScopedPixelUnpackState reset_restore(&state_); + api()->glTexImage2DFn(target, level, final_internal_format, width, height, + border, format, type, zero.get()); + } + + if (!src.IsEmpty()) { + GLint destX = src.x() - x; + GLint destY = src.y() - y; + if (requires_luma_blit) { + copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( + this, texture->service_id(), texture->target(), target, format, + type, level, destX, destY, 0, + src.x(), src.y(), src.width(), src.height(), + GetBoundReadFramebufferServiceId(), + GetBoundReadFramebufferInternalFormat()); + } else { + api()->glCopyTexSubImage2DFn(target, level, destX, destY, src.x(), + src.y(), src.width(), src.height()); + } + } + } else { + if (workarounds().init_two_cube_map_levels_before_copyteximage && + texture->target() == GL_TEXTURE_CUBE_MAP && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { + for (int i = 0; i < 2; ++i) { + TextureManager::DoTexImageArguments args = { + target, i, final_internal_format, width, height, 1, border, + format, type, nullptr, pixels_size, 0, + TextureManager::DoTexImageArguments::kTexImage2D }; + texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, + &state_, &framebuffer_state_, texture_ref, func_name, args); + } + } + + GLuint source_texture_service_id = 0; + GLenum source_texture_target = 0; + uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); + bool use_workaround = NeedsCopyTextureImageWorkaround( + final_internal_format, channels_exist, &source_texture_service_id, + &source_texture_target); + if (requires_luma_blit) { + copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( + this, texture->service_id(), texture->target(), target, format, + type, level, internal_format, x, y, width, height, + GetBoundReadFramebufferServiceId(), + GetBoundReadFramebufferInternalFormat()); + } else if (use_workaround) { + GLenum dest_texture_target = target; + GLenum framebuffer_target = GetReadFramebufferTarget(); + + GLenum temp_internal_format = 0; + if (channels_exist == GLES2Util::kRGBA) { + temp_internal_format = GL_RGBA; + } else if (channels_exist == GLES2Util::kRGB) { + temp_internal_format = GL_RGB; + } else { + NOTREACHED(); + } + + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.PushTextureUnpackState(); + GLuint temp_texture; + { + api()->glGenTexturesFn(1, &temp_texture); + ScopedTextureBinder binder(&state_, temp_texture, + source_texture_target); + api()->glCopyTexImage2DFn(source_texture_target, 0, + temp_internal_format, x, y, width, height, + border); + + api()->glFramebufferTexture2DEXTFn( + framebuffer_target, GL_COLOR_ATTACHMENT0, source_texture_target, + temp_texture, 0); + } + + DCHECK_EQ(static_cast(GL_TEXTURE_2D), dest_texture_target); + api()->glCopyTexImage2DFn(dest_texture_target, level, + final_internal_format, 0, 0, width, height, 0); + + api()->glFramebufferTexture2DEXTFn( + framebuffer_target, GL_COLOR_ATTACHMENT0, source_texture_target, + source_texture_service_id, 0); + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.RestoreUnpackState(); + + api()->glDeleteTexturesFn(1, &temp_texture); + } else { + if (workarounds().init_one_cube_map_level_before_copyteximage && + texture->target() == GL_TEXTURE_CUBE_MAP && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { + TextureManager::DoTexImageArguments args = { + target, level, final_internal_format, width, height, 1, border, + format, type, nullptr, pixels_size, 0, + TextureManager::DoTexImageArguments::kTexImage2D }; + texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, + &state_, &framebuffer_state_, texture_ref, func_name, args); + } + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.PushTextureUnpackState(); + api()->glCopyTexImage2DFn(target, level, final_internal_format, x, y, + width, height, border); + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.RestoreUnpackState(); + } + } + if (reset_source_texture_base_level_max_level) { + api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, + texture->base_level()); + api()->glTexParameteriFn(target, GL_TEXTURE_MAX_LEVEL, + texture->max_level()); + } + GLenum error = LOCAL_PEEK_GL_ERROR(func_name); + if (error == GL_NO_ERROR) { + texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, + width, height, 1, border, format, + type, gfx::Rect(width, height)); + texture->ApplyFormatWorkarounds(feature_info_.get()); + } + + ExitCommandProcessingEarly(); +} +",0,"void GLES2DecoderImpl::DoCopyTexImage2D( + GLenum target, + GLint level, + GLenum internal_format, + GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLint border) { + const char* func_name = ""glCopyTexImage2D""; + DCHECK(!ShouldDeferReads()); + TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( + &state_, target); + if (!texture_ref) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, func_name, ""unknown texture for target""); + return; + } + Texture* texture = texture_ref->texture(); + if (texture->IsImmutable()) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, func_name, ""texture is immutable""); + return; + } + if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || + border != 0) { + LOCAL_SET_GL_ERROR( + GL_INVALID_VALUE, func_name, ""dimensions out of range""); + return; + } + + if (!CheckBoundReadFramebufferValid(func_name, + GL_INVALID_FRAMEBUFFER_OPERATION)) { + return; + } + + GLenum read_format = GetBoundReadFramebufferInternalFormat(); + GLenum read_type = GetBoundReadFramebufferTextureType(); + if (!ValidateCopyTexFormat(func_name, internal_format, + read_format, read_type)) { + return; + } + + uint32_t pixels_size = 0; + GLenum format = + TextureManager::ExtractFormatFromStorageFormat(internal_format); + GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); + bool internal_format_unsized = internal_format == format; + if (internal_format_unsized && feature_info_->IsWebGL2OrES3Context()) { + DCHECK(type == GL_UNSIGNED_BYTE); + switch (internal_format) { + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE: + case GL_ALPHA: + case GL_BGRA_EXT: + break; + default: + format = GL_NONE; + break; + } + } + if (!format || !type) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + func_name, ""Invalid unsized internal format.""); + return; + } + + DCHECK(texture_manager()->ValidateTextureParameters( + GetErrorState(), func_name, true, format, type, internal_format, level)); + + if (!GLES2Util::ComputeImageDataSizes(width, height, 1, format, type, + state_.unpack_alignment, &pixels_size, + nullptr, nullptr)) { + LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, ""dimensions too large""); + return; + } + + if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, + func_name, ""source and destination textures are the same""); + return; + } + + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); + ScopedResolvedFramebufferBinder binder(this, false, true); + gfx::Size size = GetBoundReadFramebufferSize(); + + if (texture->IsAttachedToFramebuffer()) { + framebuffer_state_.clear_state_dirty = true; + } + + bool requires_luma_blit = + CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), + format); + if (requires_luma_blit && + !InitializeCopyTexImageBlitter(func_name)) { + return; + } + + bool reset_source_texture_base_level_max_level = false; + GLint attached_texture_level = -1; + Framebuffer* framebuffer = GetBoundReadFramebuffer(); + if (framebuffer) { + const Framebuffer::Attachment* attachment = + framebuffer->GetReadBufferAttachment(); + if (attachment->IsTexture(texture_ref)) { + DCHECK(attachment->IsTextureAttachment()); + attached_texture_level = attachment->level(); + DCHECK_GE(attached_texture_level, 0); + if (attached_texture_level != texture->base_level()) + reset_source_texture_base_level_max_level = true; + } + } + if (reset_source_texture_base_level_max_level) { + api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, + attached_texture_level); + api()->glTexParameteriFn(target, GL_TEXTURE_MAX_LEVEL, + attached_texture_level); + } + + gfx::Rect src(x, y, width, height); + const gfx::Rect dst(0, 0, size.width(), size.height()); + src.Intersect(dst); + + GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( + feature_info_.get(), internal_format); + if (workarounds().force_int_or_srgb_cube_texture_complete && + texture->target() == GL_TEXTURE_CUBE_MAP && + (GLES2Util::IsIntegerFormat(final_internal_format) || + GLES2Util::GetColorEncodingFromInternalFormat(final_internal_format) == + GL_SRGB)) { + TextureManager::DoTexImageArguments args = { + target, + level, + final_internal_format, + width, + height, + 1, + border, + format, + type, + nullptr, + pixels_size, + 0, + TextureManager::DoTexImageArguments::kTexImage2D}; + texture_manager()->WorkaroundCopyTexImageCubeMap( + &texture_state_, &state_, &framebuffer_state_, texture_ref, func_name, + args); + } + + if (src.x() != x || src.y() != y || + src.width() != width || src.height() != height || + final_internal_format == GL_BGRA_EXT) { + { + + std::unique_ptr zero(new char[pixels_size]); + memset(zero.get(), 0, pixels_size); + ScopedPixelUnpackState reset_restore(&state_); + api()->glTexImage2DFn(target, level, final_internal_format, width, height, + border, format, type, zero.get()); + } + + if (!src.IsEmpty()) { + GLint destX = src.x() - x; + GLint destY = src.y() - y; + if (requires_luma_blit) { + copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( + this, texture->service_id(), texture->target(), target, format, + type, level, destX, destY, 0, + src.x(), src.y(), src.width(), src.height(), + GetBoundReadFramebufferServiceId(), + GetBoundReadFramebufferInternalFormat()); + } else { + api()->glCopyTexSubImage2DFn(target, level, destX, destY, src.x(), + src.y(), src.width(), src.height()); + } + } + } else { + if (workarounds().init_two_cube_map_levels_before_copyteximage && + texture->target() == GL_TEXTURE_CUBE_MAP && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { + for (int i = 0; i < 2; ++i) { + TextureManager::DoTexImageArguments args = { + target, i, final_internal_format, width, height, 1, border, + format, type, nullptr, pixels_size, 0, + TextureManager::DoTexImageArguments::kTexImage2D }; + texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, + &state_, &framebuffer_state_, texture_ref, func_name, args); + } + } + + GLuint source_texture_service_id = 0; + GLenum source_texture_target = 0; + uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); + bool use_workaround = NeedsCopyTextureImageWorkaround( + final_internal_format, channels_exist, &source_texture_service_id, + &source_texture_target); + if (requires_luma_blit) { + copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( + this, texture->service_id(), texture->target(), target, format, + type, level, internal_format, x, y, width, height, + GetBoundReadFramebufferServiceId(), + GetBoundReadFramebufferInternalFormat()); + } else if (use_workaround) { + GLenum dest_texture_target = target; + GLenum framebuffer_target = GetReadFramebufferTarget(); + + GLenum temp_internal_format = 0; + if (channels_exist == GLES2Util::kRGBA) { + temp_internal_format = GL_RGBA; + } else if (channels_exist == GLES2Util::kRGB) { + temp_internal_format = GL_RGB; + } else { + NOTREACHED(); + } + + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.PushTextureUnpackState(); + GLuint temp_texture; + { + api()->glGenTexturesFn(1, &temp_texture); + ScopedTextureBinder binder(&state_, temp_texture, + source_texture_target); + api()->glCopyTexImage2DFn(source_texture_target, 0, + temp_internal_format, x, y, width, height, + border); + + api()->glFramebufferTexture2DEXTFn( + framebuffer_target, GL_COLOR_ATTACHMENT0, source_texture_target, + temp_texture, 0); + } + + DCHECK_EQ(static_cast(GL_TEXTURE_2D), dest_texture_target); + api()->glCopyTexImage2DFn(dest_texture_target, level, + final_internal_format, 0, 0, width, height, 0); + + api()->glFramebufferTexture2DEXTFn( + framebuffer_target, GL_COLOR_ATTACHMENT0, source_texture_target, + source_texture_service_id, 0); + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.RestoreUnpackState(); + + api()->glDeleteTexturesFn(1, &temp_texture); + } else { + if (workarounds().init_one_cube_map_level_before_copyteximage && + texture->target() == GL_TEXTURE_CUBE_MAP && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { + TextureManager::DoTexImageArguments args = { + target, level, final_internal_format, width, height, 1, border, + format, type, nullptr, pixels_size, 0, + TextureManager::DoTexImageArguments::kTexImage2D }; + texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, + &state_, &framebuffer_state_, texture_ref, func_name, args); + } + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.PushTextureUnpackState(); + api()->glCopyTexImage2DFn(target, level, final_internal_format, x, y, + width, height, border); + if (workarounds().clear_pixel_unpack_buffer_before_copyteximage) + state_.RestoreUnpackState(); + } + } + if (reset_source_texture_base_level_max_level) { + api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, + texture->base_level()); + api()->glTexParameteriFn(target, GL_TEXTURE_MAX_LEVEL, + texture->max_level()); + } + GLenum error = LOCAL_PEEK_GL_ERROR(func_name); + if (error == GL_NO_ERROR) { + texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, + width, height, 1, border, format, + type, gfx::Rect(width, height)); + texture->ApplyFormatWorkarounds(feature_info_.get()); + } + + ExitCommandProcessingEarly(); +} +","@@ -11384,29 +11384,24 @@ void GLES2DecoderImpl::GetTexParameterImpl( + return; + } + break; +- // Get the level information from the texture to avoid a Mac driver +- // bug where they store the levels in int16_t, making values bigger +- // than 2^15-1 overflow in the negative range. + case GL_TEXTURE_BASE_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->base_level()); +- } else { +- iparams[0] = texture->base_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_base_level()); ++ } else { ++ iparams[0] = texture->unclamped_base_level(); + } +- break; ++ return; + case GL_TEXTURE_MAX_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->max_level()); +- } else { +- iparams[0] = texture->max_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_max_level()); ++ } else { ++ iparams[0] = texture->unclamped_max_level(); + } +- break; ++ return; + case GL_TEXTURE_SWIZZLE_R: + if (fparams) { + fparams[0] = static_cast(texture->swizzle_r()); +@@ -17573,25 +17568,6 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + compatibility_internal_format = format_info->decompressed_internal_format; + } + +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); +- +- // TODO(zmo): We might need to emulate TexStorage using TexImage or +- // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying +- // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. +- if (dimension == ContextState::k2D) { +- api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, +- width, height); +- } else { +- api()->glTexStorage3DFn(target, levels, compatibility_internal_format, +- width, height, depth); +- } +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, +- texture->base_level()); +- + { + GLsizei level_width = width; + GLsizei level_height = height; +@@ -17620,6 +17596,29 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + texture->ApplyFormatWorkarounds(feature_info_.get()); + texture->SetImmutable(true); + } ++ ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); ++ ++ // TODO(zmo): We might need to emulate TexStorage using TexImage or ++ // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying ++ // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. ++ if (dimension == ContextState::k2D) { ++ api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, ++ width, height); ++ } else { ++ api()->glTexStorage3DFn(target, levels, compatibility_internal_format, ++ width, height, depth); ++ } ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) { ++ // Note base_level is already clamped due to texture->SetImmutable(true). ++ // This is necessary for certain NVidia Linux drivers; otherwise they ++ // may trigger segmentation fault. See https://crbug.com/877874. ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, ++ texture->base_level()); ++ } + } + + void GLES2DecoderImpl::DoTexStorage2DEXT(GLenum target,",2376,2612,4096 +10,"PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *replace_val, + int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC) +{ + pcre_extra *extra = pce->extra;/* Holds results of studying */ + pcre_extra extra_data; /* Used locally for exec options */ + int exoptions = 0; /* Execution options */ + int count = 0; /* Count of matched subpatterns */ + int *offsets; /* Array of subpattern offsets */ + char **subpat_names; /* Array for named subpatterns */ + int num_subpats; /* Number of captured subpatterns */ + int size_offsets; /* Size of the offsets array */ + int new_len; /* Length of needed storage */ + int alloc_len; /* Actual allocated length */ + int eval_result_len=0; /* Length of the eval'ed or + function-returned string */ + int match_len; /* Length of the current match */ + int backref; /* Backreference number */ + int eval; /* If the replacement string should be eval'ed */ + int start_offset; /* Where the new search starts */ + int g_notempty=0; /* If the match should not be empty */ + int replace_len=0; /* Length of replacement string */ + char *result, /* Result of replacement */ + *replace=NULL, /* Replacement string */ + *new_buf, /* Temporary buffer for re-allocation */ + *walkbuf, /* Location of current replacement in the result */ + *walk, /* Used to walk the replacement string */ + *match, /* The current match */ + *piece, /* The current piece of subject */ + *replace_end=NULL, /* End of replacement string */ + *eval_result, /* Result of eval or custom function */ + walk_last; /* Last walked character */ + int rc; + + if (extra == NULL) { + extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; + extra = &extra_data; + } + extra->match_limit = PCRE_G(backtrack_limit); + extra->match_limit_recursion = PCRE_G(recursion_limit); + + eval = pce->preg_options & PREG_REPLACE_EVAL; + if (is_callable_replace) { + if (eval) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Modifier /e cannot be used with replacement callback""); + return NULL; + } + } else { + replace = Z_STRVAL_P(replace_val); + replace_len = Z_STRLEN_P(replace_val); + replace_end = replace + replace_len; + } + + /* Calculate the size of the offsets array, and allocate memory for it. */ + rc = pcre_fullinfo(pce->re, extra, PCRE_INFO_CAPTURECOUNT, &num_subpats); + if (rc < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Internal pcre_fullinfo() error %d"", rc); + return NULL; + } + num_subpats++; + size_offsets = num_subpats * 3; + + /* + * Build a mapping from subpattern numbers to their names. We will always + * allocate the table, even though there may be no named subpatterns. This + * avoids somewhat more complicated logic in the inner loops. + */ + subpat_names = make_subpats_table(num_subpats, pce TSRMLS_CC); + if (!subpat_names) { + return NULL; + } + + offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); + + alloc_len = 2 * subject_len + 1; + result = safe_emalloc(alloc_len, sizeof(char), 0); + + /* Initialize */ + match = NULL; + *result_len = 0; + start_offset = 0; + PCRE_G(error_code) = PHP_PCRE_NO_ERROR; + + while (1) { + /* Execute the regular expression. */ + count = pcre_exec(pce->re, extra, subject, subject_len, start_offset, + exoptions|g_notempty, offsets, size_offsets); + + /* the string was already proved to be valid UTF-8 */ + exoptions |= PCRE_NO_UTF8_CHECK; + + /* Check for too many substrings condition. */ + if (count == 0) { + php_error_docref(NULL TSRMLS_CC,E_NOTICE, ""Matched, but too many substrings""); + count = size_offsets/3; + } + + piece = subject + start_offset; + + if (count > 0 && (limit == -1 || limit > 0)) { + if (replace_count) { + ++*replace_count; + } + /* Set the match location in subject */ + match = subject + offsets[0]; + + new_len = *result_len + offsets[0] - start_offset; /* part before the match */ + + /* If evaluating, do it and add the return string's length */ + if (eval) { + eval_result_len = preg_do_eval(replace, replace_len, subject, + offsets, count, &eval_result TSRMLS_CC); + new_len += eval_result_len; + } else if (is_callable_replace) { + /* Use custom function to get replacement string and its length. */ + eval_result_len = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, &eval_result TSRMLS_CC); + new_len += eval_result_len; + } else { /* do regular substitution */ + walk = replace; + walk_last = 0; + while (walk < replace_end) { + if ('\\' == *walk || '$' == *walk) { + if (walk_last == '\\') { + walk++; + walk_last = 0; + continue; + } + if (preg_get_backref(&walk, &backref)) { + if (backref < count) + new_len += offsets[(backref<<1)+1] - offsets[backref<<1]; + continue; + } + } + new_len++; + walk++; + walk_last = walk[-1]; + } + } + + if (new_len + 1 > alloc_len) { + alloc_len = 1 + alloc_len + 2 * new_len; + new_buf = emalloc(alloc_len); + memcpy(new_buf, result, *result_len); + efree(result); + result = new_buf; + } + /* copy the part of the string before the match */ + memcpy(&result[*result_len], piece, match-piece); + *result_len += match-piece; + + /* copy replacement and backrefs */ + walkbuf = result + *result_len; + + /* If evaluating or using custom function, copy result to the buffer + * and clean up. */ + if (eval || is_callable_replace) { + memcpy(walkbuf, eval_result, eval_result_len); + *result_len += eval_result_len; + STR_FREE(eval_result); + } else { /* do regular backreference copying */ + walk = replace; + walk_last = 0; + while (walk < replace_end) { + if ('\\' == *walk || '$' == *walk) { + if (walk_last == '\\') { + *(walkbuf-1) = *walk++; + walk_last = 0; + continue; + } + if (preg_get_backref(&walk, &backref)) { + if (backref < count) { + match_len = offsets[(backref<<1)+1] - offsets[backref<<1]; + memcpy(walkbuf, subject + offsets[backref<<1], match_len); + walkbuf += match_len; + } + continue; + } + } + *walkbuf++ = *walk++; + walk_last = walk[-1]; + } + *walkbuf = '\0'; + /* increment the result length by how much we've added to the string */ + *result_len += walkbuf - (result + *result_len); + } + + if (limit != -1) + limit--; + + } else if (count == PCRE_ERROR_NOMATCH || limit == 0) { + /* If we previously set PCRE_NOTEMPTY after a null match, + this is not necessarily the end. We need to advance + the start offset, and continue. Fudge the offset values + to achieve this, unless we're already at the end of the string. */ + if (g_notempty != 0 && start_offset < subject_len) { + offsets[0] = start_offset; + offsets[1] = start_offset + 1; + memcpy(&result[*result_len], piece, 1); + (*result_len)++; + } else { + new_len = *result_len + subject_len - start_offset; + if (new_len + 1 > alloc_len) { + alloc_len = new_len + 1; /* now we know exactly how long it is */ + new_buf = safe_emalloc(alloc_len, sizeof(char), 0); + memcpy(new_buf, result, *result_len); + efree(result); + result = new_buf; + } + /* stick that last bit of string on our output */ + memcpy(&result[*result_len], piece, subject_len - start_offset); + *result_len += subject_len - start_offset; + result[*result_len] = '\0'; + break; + } + } else { + pcre_handle_exec_error(count TSRMLS_CC); + efree(result); + result = NULL; + break; + } + + /* If we have matched an empty string, mimic what Perl's /g options does. + This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try + the match again at the same point. If this fails (picked up above) we + advance to the next character. */ + g_notempty = (offsets[1] == offsets[0])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0; + + /* Advance to the next piece. */ + start_offset = offsets[1]; + } + + efree(offsets); + efree(subpat_names); + + return result; +} +",0,"PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *replace_val, + int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC) +{ + pcre_extra *extra = pce->extra;/* Holds results of studying */ + pcre_extra extra_data; /* Used locally for exec options */ + int exoptions = 0; /* Execution options */ + int count = 0; /* Count of matched subpatterns */ + int *offsets; /* Array of subpattern offsets */ + char **subpat_names; /* Array for named subpatterns */ + int num_subpats; /* Number of captured subpatterns */ + int size_offsets; /* Size of the offsets array */ + int new_len; /* Length of needed storage */ + int alloc_len; /* Actual allocated length */ + int eval_result_len=0; /* Length of the eval'ed or + function-returned string */ + int match_len; /* Length of the current match */ + int backref; /* Backreference number */ + int eval; /* If the replacement string should be eval'ed */ + int start_offset; /* Where the new search starts */ + int g_notempty=0; /* If the match should not be empty */ + int replace_len=0; /* Length of replacement string */ + char *result, /* Result of replacement */ + *replace=NULL, /* Replacement string */ + *new_buf, /* Temporary buffer for re-allocation */ + *walkbuf, /* Location of current replacement in the result */ + *walk, /* Used to walk the replacement string */ + *match, /* The current match */ + *piece, /* The current piece of subject */ + *replace_end=NULL, /* End of replacement string */ + *eval_result, /* Result of eval or custom function */ + walk_last; /* Last walked character */ + int rc; + + if (extra == NULL) { + extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION; + extra = &extra_data; + } + extra->match_limit = PCRE_G(backtrack_limit); + extra->match_limit_recursion = PCRE_G(recursion_limit); + + eval = pce->preg_options & PREG_REPLACE_EVAL; + if (is_callable_replace) { + if (eval) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Modifier /e cannot be used with replacement callback""); + return NULL; + } + } else { + replace = Z_STRVAL_P(replace_val); + replace_len = Z_STRLEN_P(replace_val); + replace_end = replace + replace_len; + } + + /* Calculate the size of the offsets array, and allocate memory for it. */ + rc = pcre_fullinfo(pce->re, extra, PCRE_INFO_CAPTURECOUNT, &num_subpats); + if (rc < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, ""Internal pcre_fullinfo() error %d"", rc); + return NULL; + } + num_subpats++; + size_offsets = num_subpats * 3; + + /* + * Build a mapping from subpattern numbers to their names. We will always + * allocate the table, even though there may be no named subpatterns. This + * avoids somewhat more complicated logic in the inner loops. + */ + subpat_names = make_subpats_table(num_subpats, pce TSRMLS_CC); + if (!subpat_names) { + return NULL; + } + + offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); + + alloc_len = 2 * subject_len + 1; + result = safe_emalloc(alloc_len, sizeof(char), 0); + + /* Initialize */ + match = NULL; + *result_len = 0; + start_offset = 0; + PCRE_G(error_code) = PHP_PCRE_NO_ERROR; + + while (1) { + /* Execute the regular expression. */ + count = pcre_exec(pce->re, extra, subject, subject_len, start_offset, + exoptions|g_notempty, offsets, size_offsets); + + /* the string was already proved to be valid UTF-8 */ + exoptions |= PCRE_NO_UTF8_CHECK; + + /* Check for too many substrings condition. */ + if (count == 0) { + php_error_docref(NULL TSRMLS_CC,E_NOTICE, ""Matched, but too many substrings""); + count = size_offsets/3; + } + + piece = subject + start_offset; + + if (count > 0 && (limit == -1 || limit > 0)) { + if (replace_count) { + ++*replace_count; + } + /* Set the match location in subject */ + match = subject + offsets[0]; + + new_len = *result_len + offsets[0] - start_offset; /* part before the match */ + + /* If evaluating, do it and add the return string's length */ + if (eval) { + eval_result_len = preg_do_eval(replace, replace_len, subject, + offsets, count, &eval_result TSRMLS_CC); + new_len += eval_result_len; + } else if (is_callable_replace) { + /* Use custom function to get replacement string and its length. */ + eval_result_len = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, &eval_result TSRMLS_CC); + new_len += eval_result_len; + } else { /* do regular substitution */ + walk = replace; + walk_last = 0; + while (walk < replace_end) { + if ('\\' == *walk || '$' == *walk) { + if (walk_last == '\\') { + walk++; + walk_last = 0; + continue; + } + if (preg_get_backref(&walk, &backref)) { + if (backref < count) + new_len += offsets[(backref<<1)+1] - offsets[backref<<1]; + continue; + } + } + new_len++; + walk++; + walk_last = walk[-1]; + } + } + + if (new_len + 1 > alloc_len) { + alloc_len = 1 + alloc_len + 2 * new_len; + new_buf = emalloc(alloc_len); + memcpy(new_buf, result, *result_len); + efree(result); + result = new_buf; + } + /* copy the part of the string before the match */ + memcpy(&result[*result_len], piece, match-piece); + *result_len += match-piece; + + /* copy replacement and backrefs */ + walkbuf = result + *result_len; + + /* If evaluating or using custom function, copy result to the buffer + * and clean up. */ + if (eval || is_callable_replace) { + memcpy(walkbuf, eval_result, eval_result_len); + *result_len += eval_result_len; + STR_FREE(eval_result); + } else { /* do regular backreference copying */ + walk = replace; + walk_last = 0; + while (walk < replace_end) { + if ('\\' == *walk || '$' == *walk) { + if (walk_last == '\\') { + *(walkbuf-1) = *walk++; + walk_last = 0; + continue; + } + if (preg_get_backref(&walk, &backref)) { + if (backref < count) { + match_len = offsets[(backref<<1)+1] - offsets[backref<<1]; + memcpy(walkbuf, subject + offsets[backref<<1], match_len); + walkbuf += match_len; + } + continue; + } + } + *walkbuf++ = *walk++; + walk_last = walk[-1]; + } + *walkbuf = '\0'; + /* increment the result length by how much we've added to the string */ + *result_len += walkbuf - (result + *result_len); + } + + if (limit != -1) + limit--; + + } else if (count == PCRE_ERROR_NOMATCH || limit == 0) { + /* If we previously set PCRE_NOTEMPTY after a null match, + this is not necessarily the end. We need to advance + the start offset, and continue. Fudge the offset values + to achieve this, unless we're already at the end of the string. */ + if (g_notempty != 0 && start_offset < subject_len) { + offsets[0] = start_offset; + offsets[1] = start_offset + 1; + memcpy(&result[*result_len], piece, 1); + (*result_len)++; + } else { + new_len = *result_len + subject_len - start_offset; + if (new_len + 1 > alloc_len) { + alloc_len = new_len + 1; /* now we know exactly how long it is */ + new_buf = safe_emalloc(alloc_len, sizeof(char), 0); + memcpy(new_buf, result, *result_len); + efree(result); + result = new_buf; + } + /* stick that last bit of string on our output */ + memcpy(&result[*result_len], piece, subject_len - start_offset); + *result_len += subject_len - start_offset; + result[*result_len] = '\0'; + break; + } + } else { + pcre_handle_exec_error(count TSRMLS_CC); + efree(result); + result = NULL; + break; + } + + /* If we have matched an empty string, mimic what Perl's /g options does. + This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try + the match again at the same point. If this fails (picked up above) we + advance to the next character. */ + g_notempty = (offsets[1] == offsets[0])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0; + + /* Advance to the next piece. */ + start_offset = offsets[1]; + } + + efree(offsets); + efree(subpat_names); + + return result; +} +","@@ -640,7 +640,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec + } + + offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); +- ++ memset(offsets, 0, size_offsets*sizeof(int)); + /* Allocate match sets array and initialize the values. */ + if (global && subpats && subpats_order == PREG_PATTERN_ORDER) { + match_sets = (zval **)safe_emalloc(num_subpats, sizeof(zval *), 0);",2278,2514,4096 +5234,"static INT AirPDcapScanForKeys( + PAIRPDCAP_CONTEXT ctx, + const guint8 *data, + const guint mac_header_len, + const guint tot_len, + AIRPDCAP_SEC_ASSOCIATION_ID id +) +{ + const UCHAR *addr; + guint bodyLength; + PAIRPDCAP_SEC_ASSOCIATION sta_sa; + PAIRPDCAP_SEC_ASSOCIATION sa; + guint offset = 0; + const guint8 dot1x_header[] = { + 0xAA, /* DSAP=SNAP */ + 0xAA, /* SSAP=SNAP */ + 0x03, /* Control field=Unnumbered frame */ + 0x00, 0x00, 0x00, /* Org. code=encaps. Ethernet */ + 0x88, 0x8E /* Type: 802.1X authentication */ + }; + const guint8 bt_dot1x_header[] = { + 0xAA, /* DSAP=SNAP */ + 0xAA, /* SSAP=SNAP */ + 0x03, /* Control field=Unnumbered frame */ + 0x00, 0x19, 0x58, /* Org. code=Bluetooth SIG */ + 0x00, 0x03 /* Type: Bluetooth Security */ + }; + const guint8 tdls_header[] = { + 0xAA, /* DSAP=SNAP */ + 0xAA, /* SSAP=SNAP */ + 0x03, /* Control field=Unnumbered frame */ + 0x00, 0x00, 0x00, /* Org. code=encaps. Ethernet */ + 0x89, 0x0D, /* Type: 802.11 - Fast Roaming Remote Request */ + 0x02, /* Payload Type: TDLS */ + 0X0C /* Action Category: TDLS */ + }; + + const EAPOL_RSN_KEY *pEAPKey; +#ifdef _DEBUG +#define MSGBUF_LEN 255 + CHAR msgbuf[MSGBUF_LEN]; +#endif + AIRPDCAP_DEBUG_TRACE_START(""AirPDcapScanForKeys""); + + /* cache offset in the packet data */ + offset = mac_header_len; + + /* check if the packet has an LLC header and the packet is 802.1X authentication (IEEE 802.1X-2004, pg. 24) */ + if (memcmp(data+offset, dot1x_header, 8) == 0 || memcmp(data+offset, bt_dot1x_header, 8) == 0) { + + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Authentication: EAPOL packet"", AIRPDCAP_DEBUG_LEVEL_3); + + /* skip LLC header */ + offset+=8; + + /* check if the packet is a EAPOL-Key (0x03) (IEEE 802.1X-2004, pg. 25) */ + if (data[offset+1]!=3) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Not EAPOL-Key"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* get and check the body length (IEEE 802.1X-2004, pg. 25) */ + bodyLength=pntoh16(data+offset+2); + if ((tot_len-offset-4) < bodyLength) { /* Only check if frame is long enough for eapol header, ignore tailing garbage, see bug 9065 */ + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""EAPOL body too short"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* skip EAPOL MPDU and go to the first byte of the body */ + offset+=4; + + pEAPKey = (const EAPOL_RSN_KEY *) (data+offset); + + /* check if the key descriptor type is valid (IEEE 802.1X-2004, pg. 27) */ + if (/*pEAPKey->type!=0x1 &&*/ /* RC4 Key Descriptor Type (deprecated) */ + pEAPKey->type != AIRPDCAP_RSN_WPA2_KEY_DESCRIPTOR && /* IEEE 802.11 Key Descriptor Type (WPA2) */ + pEAPKey->type != AIRPDCAP_RSN_WPA_KEY_DESCRIPTOR) /* 254 = RSN_KEY_DESCRIPTOR - WPA, */ + { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Not valid key descriptor type"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* start with descriptor body */ + offset+=1; + + /* search for a cached Security Association for current BSSID and AP */ + sa = AirPDcapGetSaPtr(ctx, &id); + if (sa == NULL){ + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""No SA for BSSID found"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_REQ_DATA; + } + + /* It could be a Pairwise Key exchange, check */ + if (AirPDcapRsna4WHandshake(ctx, data, sa, offset, tot_len) == AIRPDCAP_RET_SUCCESS_HANDSHAKE) + return AIRPDCAP_RET_SUCCESS_HANDSHAKE; + + if (mac_header_len + GROUP_KEY_PAYLOAD_LEN_MIN > tot_len) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Message too short for Group Key"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* Verify the bitfields: Key = 0(groupwise) Mic = 1 Ack = 1 Secure = 1 */ + if (AIRPDCAP_EAP_KEY(data[offset+1])!=0 || + AIRPDCAP_EAP_ACK(data[offset+1])!=1 || + AIRPDCAP_EAP_MIC(data[offset]) != 1 || + AIRPDCAP_EAP_SEC(data[offset]) != 1){ + + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Key bitfields not correct for Group Key"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* force STA address to be the broadcast MAC so we create an SA for the groupkey */ + memcpy(id.sta, broadcast_mac, AIRPDCAP_MAC_LEN); + + /* get the Security Association structure for the broadcast MAC and AP */ + sa = AirPDcapGetSaPtr(ctx, &id); + if (sa == NULL){ + return AIRPDCAP_RET_REQ_DATA; + } + + /* Get the SA for the STA, since we need its pairwise key to decrpyt the group key */ + + /* get STA address */ + if ( (addr=AirPDcapGetStaAddress((const AIRPDCAP_MAC_FRAME_ADDR4 *)(data))) != NULL) { + memcpy(id.sta, addr, AIRPDCAP_MAC_LEN); +#ifdef _DEBUG + g_snprintf(msgbuf, MSGBUF_LEN, ""ST_MAC: %2X.%2X.%2X.%2X.%2X.%2X\t"", id.sta[0],id.sta[1],id.sta[2],id.sta[3],id.sta[4],id.sta[5]); +#endif + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", msgbuf, AIRPDCAP_DEBUG_LEVEL_3); + } else { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""SA not found"", AIRPDCAP_DEBUG_LEVEL_5); + return AIRPDCAP_RET_REQ_DATA; + } + + sta_sa = AirPDcapGetSaPtr(ctx, &id); + if (sta_sa == NULL){ + return AIRPDCAP_RET_REQ_DATA; + } + + /* Try to extract the group key and install it in the SA */ + return (AirPDcapDecryptWPABroadcastKey(pEAPKey, sta_sa->wpa.ptk+16, sa, tot_len-offset+1)); + + } else if (memcmp(data+offset, tdls_header, 10) == 0) { + const guint8 *initiator, *responder; + guint8 action; + guint status, offset_rsne = 0, offset_fte = 0, offset_link = 0, offset_timeout = 0; + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Authentication: TDLS Action Frame"", AIRPDCAP_DEBUG_LEVEL_3); + + /* skip LLC header */ + offset+=10; + + /* check if the packet is a TDLS response or confirm */ + action = data[offset]; + if (action!=1 && action!=2) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Not Response nor confirm"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* check status */ + offset++; + status=pntoh16(data+offset); + if (status!=0) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""TDLS setup not successfull"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* skip Token + capabilities */ + offset+=5; + + /* search for RSN, Fast BSS Transition, Link Identifier and Timeout Interval IEs */ + + while(offset < (tot_len - 2)) { + if (data[offset] == 48) { + offset_rsne = offset; + } else if (data[offset] == 55) { + offset_fte = offset; + } else if (data[offset] == 56) { + offset_timeout = offset; + } else if (data[offset] == 101) { + offset_link = offset; + } + + if (tot_len < offset + data[offset + 1] + 2) { + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + offset += data[offset + 1] + 2; + } + + if (offset_rsne == 0 || offset_fte == 0 || + offset_timeout == 0 || offset_link == 0) + { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Cannot Find all necessary IEs"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Found RSNE/Fast BSS/Timeout Interval/Link IEs"", AIRPDCAP_DEBUG_LEVEL_3); + + /* Will create a Security Association between 2 STA. Need to get both MAC address */ + initiator = &data[offset_link + 8]; + responder = &data[offset_link + 14]; + + if (memcmp(initiator, responder, AIRPDCAP_MAC_LEN) < 0) { + memcpy(id.sta, initiator, AIRPDCAP_MAC_LEN); + memcpy(id.bssid, responder, AIRPDCAP_MAC_LEN); + } else { + memcpy(id.sta, responder, AIRPDCAP_MAC_LEN); + memcpy(id.bssid, initiator, AIRPDCAP_MAC_LEN); + } + + sa = AirPDcapGetSaPtr(ctx, &id); + if (sa == NULL){ + return AIRPDCAP_RET_REQ_DATA; + } + + if (sa->validKey) { + if (memcmp(sa->wpa.nonce, data + offset_fte + 52, AIRPDCAP_WPA_NONCE_LEN) == 0) { + /* Already have valid key for this SA, no need to redo key derivation */ + return AIRPDCAP_RET_SUCCESS_HANDSHAKE; + } else { + /* We are opening a new session with the same two STA, save previous sa */ + AIRPDCAP_SEC_ASSOCIATION *tmp_sa = g_new(AIRPDCAP_SEC_ASSOCIATION, 1); + memcpy(tmp_sa, sa, sizeof(AIRPDCAP_SEC_ASSOCIATION)); + sa->next=tmp_sa; + sa->validKey = FALSE; + } + } + + if (AirPDcapTDLSDeriveKey(sa, data, offset_rsne, offset_fte, offset_timeout, offset_link, action) + == AIRPDCAP_RET_SUCCESS) { + AIRPDCAP_DEBUG_TRACE_END(""AirPDcapScanForKeys""); + return AIRPDCAP_RET_SUCCESS_HANDSHAKE; + } + } else { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Skipping: not an EAPOL packet"", AIRPDCAP_DEBUG_LEVEL_3); + } + + AIRPDCAP_DEBUG_TRACE_END(""AirPDcapScanForKeys""); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; +} +",0,"static INT AirPDcapScanForKeys( + PAIRPDCAP_CONTEXT ctx, + const guint8 *data, + const guint mac_header_len, + const guint tot_len, + AIRPDCAP_SEC_ASSOCIATION_ID id +) +{ + const UCHAR *addr; + guint bodyLength; + PAIRPDCAP_SEC_ASSOCIATION sta_sa; + PAIRPDCAP_SEC_ASSOCIATION sa; + guint offset = 0; + const guint8 dot1x_header[] = { + 0xAA, /* DSAP=SNAP */ + 0xAA, /* SSAP=SNAP */ + 0x03, /* Control field=Unnumbered frame */ + 0x00, 0x00, 0x00, /* Org. code=encaps. Ethernet */ + 0x88, 0x8E /* Type: 802.1X authentication */ + }; + const guint8 bt_dot1x_header[] = { + 0xAA, /* DSAP=SNAP */ + 0xAA, /* SSAP=SNAP */ + 0x03, /* Control field=Unnumbered frame */ + 0x00, 0x19, 0x58, /* Org. code=Bluetooth SIG */ + 0x00, 0x03 /* Type: Bluetooth Security */ + }; + const guint8 tdls_header[] = { + 0xAA, /* DSAP=SNAP */ + 0xAA, /* SSAP=SNAP */ + 0x03, /* Control field=Unnumbered frame */ + 0x00, 0x00, 0x00, /* Org. code=encaps. Ethernet */ + 0x89, 0x0D, /* Type: 802.11 - Fast Roaming Remote Request */ + 0x02, /* Payload Type: TDLS */ + 0X0C /* Action Category: TDLS */ + }; + + const EAPOL_RSN_KEY *pEAPKey; +#ifdef _DEBUG +#define MSGBUF_LEN 255 + CHAR msgbuf[MSGBUF_LEN]; +#endif + AIRPDCAP_DEBUG_TRACE_START(""AirPDcapScanForKeys""); + + /* cache offset in the packet data */ + offset = mac_header_len; + + /* check if the packet has an LLC header and the packet is 802.1X authentication (IEEE 802.1X-2004, pg. 24) */ + if (memcmp(data+offset, dot1x_header, 8) == 0 || memcmp(data+offset, bt_dot1x_header, 8) == 0) { + + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Authentication: EAPOL packet"", AIRPDCAP_DEBUG_LEVEL_3); + + /* skip LLC header */ + offset+=8; + + /* check if the packet is a EAPOL-Key (0x03) (IEEE 802.1X-2004, pg. 25) */ + if (data[offset+1]!=3) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Not EAPOL-Key"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* get and check the body length (IEEE 802.1X-2004, pg. 25) */ + bodyLength=pntoh16(data+offset+2); + if ((tot_len-offset-4) < bodyLength) { /* Only check if frame is long enough for eapol header, ignore tailing garbage, see bug 9065 */ + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""EAPOL body too short"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* skip EAPOL MPDU and go to the first byte of the body */ + offset+=4; + + pEAPKey = (const EAPOL_RSN_KEY *) (data+offset); + + /* check if the key descriptor type is valid (IEEE 802.1X-2004, pg. 27) */ + if (/*pEAPKey->type!=0x1 &&*/ /* RC4 Key Descriptor Type (deprecated) */ + pEAPKey->type != AIRPDCAP_RSN_WPA2_KEY_DESCRIPTOR && /* IEEE 802.11 Key Descriptor Type (WPA2) */ + pEAPKey->type != AIRPDCAP_RSN_WPA_KEY_DESCRIPTOR) /* 254 = RSN_KEY_DESCRIPTOR - WPA, */ + { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Not valid key descriptor type"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* start with descriptor body */ + offset+=1; + + /* search for a cached Security Association for current BSSID and AP */ + sa = AirPDcapGetSaPtr(ctx, &id); + if (sa == NULL){ + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""No SA for BSSID found"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_REQ_DATA; + } + + /* It could be a Pairwise Key exchange, check */ + if (AirPDcapRsna4WHandshake(ctx, data, sa, offset, tot_len) == AIRPDCAP_RET_SUCCESS_HANDSHAKE) + return AIRPDCAP_RET_SUCCESS_HANDSHAKE; + + if (mac_header_len + GROUP_KEY_PAYLOAD_LEN_MIN > tot_len) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Message too short for Group Key"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* Verify the bitfields: Key = 0(groupwise) Mic = 1 Ack = 1 Secure = 1 */ + if (AIRPDCAP_EAP_KEY(data[offset+1])!=0 || + AIRPDCAP_EAP_ACK(data[offset+1])!=1 || + AIRPDCAP_EAP_MIC(data[offset]) != 1 || + AIRPDCAP_EAP_SEC(data[offset]) != 1){ + + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Key bitfields not correct for Group Key"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* force STA address to be the broadcast MAC so we create an SA for the groupkey */ + memcpy(id.sta, broadcast_mac, AIRPDCAP_MAC_LEN); + + /* get the Security Association structure for the broadcast MAC and AP */ + sa = AirPDcapGetSaPtr(ctx, &id); + if (sa == NULL){ + return AIRPDCAP_RET_REQ_DATA; + } + + /* Get the SA for the STA, since we need its pairwise key to decrpyt the group key */ + + /* get STA address */ + if ( (addr=AirPDcapGetStaAddress((const AIRPDCAP_MAC_FRAME_ADDR4 *)(data))) != NULL) { + memcpy(id.sta, addr, AIRPDCAP_MAC_LEN); +#ifdef _DEBUG + g_snprintf(msgbuf, MSGBUF_LEN, ""ST_MAC: %2X.%2X.%2X.%2X.%2X.%2X\t"", id.sta[0],id.sta[1],id.sta[2],id.sta[3],id.sta[4],id.sta[5]); +#endif + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", msgbuf, AIRPDCAP_DEBUG_LEVEL_3); + } else { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""SA not found"", AIRPDCAP_DEBUG_LEVEL_5); + return AIRPDCAP_RET_REQ_DATA; + } + + sta_sa = AirPDcapGetSaPtr(ctx, &id); + if (sta_sa == NULL){ + return AIRPDCAP_RET_REQ_DATA; + } + + /* Try to extract the group key and install it in the SA */ + return (AirPDcapDecryptWPABroadcastKey(pEAPKey, sta_sa->wpa.ptk+16, sa, tot_len-offset+1)); + + } else if (memcmp(data+offset, tdls_header, 10) == 0) { + const guint8 *initiator, *responder; + guint8 action; + guint status, offset_rsne = 0, offset_fte = 0, offset_link = 0, offset_timeout = 0; + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Authentication: TDLS Action Frame"", AIRPDCAP_DEBUG_LEVEL_3); + + /* skip LLC header */ + offset+=10; + + /* check if the packet is a TDLS response or confirm */ + action = data[offset]; + if (action!=1 && action!=2) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Not Response nor confirm"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* check status */ + offset++; + status=pntoh16(data+offset); + if (status!=0) { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""TDLS setup not successfull"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + /* skip Token + capabilities */ + offset+=5; + + /* search for RSN, Fast BSS Transition, Link Identifier and Timeout Interval IEs */ + + while(offset < (tot_len - 2)) { + if (data[offset] == 48) { + offset_rsne = offset; + } else if (data[offset] == 55) { + offset_fte = offset; + } else if (data[offset] == 56) { + offset_timeout = offset; + } else if (data[offset] == 101) { + offset_link = offset; + } + + if (tot_len < offset + data[offset + 1] + 2) { + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + offset += data[offset + 1] + 2; + } + + if (offset_rsne == 0 || offset_fte == 0 || + offset_timeout == 0 || offset_link == 0) + { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Cannot Find all necessary IEs"", AIRPDCAP_DEBUG_LEVEL_3); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Found RSNE/Fast BSS/Timeout Interval/Link IEs"", AIRPDCAP_DEBUG_LEVEL_3); + + /* Will create a Security Association between 2 STA. Need to get both MAC address */ + initiator = &data[offset_link + 8]; + responder = &data[offset_link + 14]; + + if (memcmp(initiator, responder, AIRPDCAP_MAC_LEN) < 0) { + memcpy(id.sta, initiator, AIRPDCAP_MAC_LEN); + memcpy(id.bssid, responder, AIRPDCAP_MAC_LEN); + } else { + memcpy(id.sta, responder, AIRPDCAP_MAC_LEN); + memcpy(id.bssid, initiator, AIRPDCAP_MAC_LEN); + } + + sa = AirPDcapGetSaPtr(ctx, &id); + if (sa == NULL){ + return AIRPDCAP_RET_REQ_DATA; + } + + if (sa->validKey) { + if (memcmp(sa->wpa.nonce, data + offset_fte + 52, AIRPDCAP_WPA_NONCE_LEN) == 0) { + /* Already have valid key for this SA, no need to redo key derivation */ + return AIRPDCAP_RET_SUCCESS_HANDSHAKE; + } else { + /* We are opening a new session with the same two STA, save previous sa */ + AIRPDCAP_SEC_ASSOCIATION *tmp_sa = g_new(AIRPDCAP_SEC_ASSOCIATION, 1); + memcpy(tmp_sa, sa, sizeof(AIRPDCAP_SEC_ASSOCIATION)); + sa->next=tmp_sa; + sa->validKey = FALSE; + } + } + + if (AirPDcapTDLSDeriveKey(sa, data, offset_rsne, offset_fte, offset_timeout, offset_link, action) + == AIRPDCAP_RET_SUCCESS) { + AIRPDCAP_DEBUG_TRACE_END(""AirPDcapScanForKeys""); + return AIRPDCAP_RET_SUCCESS_HANDSHAKE; + } + } else { + AIRPDCAP_DEBUG_PRINT_LINE(""AirPDcapScanForKeys"", ""Skipping: not an EAPOL packet"", AIRPDCAP_DEBUG_LEVEL_3); + } + + AIRPDCAP_DEBUG_TRACE_END(""AirPDcapScanForKeys""); + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; +} +","@@ -351,7 +351,9 @@ AirPDcapDecryptWPABroadcastKey(const EAPOL_RSN_KEY *pEAPKey, guint8 *decryption_ + } + } + +- if (key_bytes_len < GROUP_KEY_MIN_LEN || key_bytes_len > eapol_len - sizeof(EAPOL_RSN_KEY)) { ++ if ((key_bytes_len < GROUP_KEY_MIN_LEN) || ++ (eapol_len < sizeof(EAPOL_RSN_KEY)) || ++ (key_bytes_len > eapol_len - sizeof(EAPOL_RSN_KEY))) { + return AIRPDCAP_RET_NO_VALID_HANDSHAKE; + } + ",2886,3122,4096 +398,"_dbus_poll (DBusPollFD *fds, + int n_fds, + int timeout_milliseconds) +{ +#define USE_CHRIS_IMPL 0 + +#if USE_CHRIS_IMPL + +#define DBUS_POLL_CHAR_BUFFER_SIZE 2000 + char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; + char *msgp; + + int ret = 0; + int i; + struct timeval tv; + int ready; + +#define DBUS_STACK_WSAEVENTS 256 + WSAEVENT eventsOnStack[DBUS_STACK_WSAEVENTS]; + WSAEVENT *pEvents = NULL; + if (n_fds > DBUS_STACK_WSAEVENTS) + pEvents = calloc(sizeof(WSAEVENT), n_fds); + else + pEvents = eventsOnStack; + + +#ifdef DBUS_ENABLE_VERBOSE_MODE + msgp = msg; + msgp += sprintf (msgp, ""WSAEventSelect: to=%d\n\t"", timeout_milliseconds); + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + + if (fdp->events & _DBUS_POLLIN) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (fdp->events & _DBUS_POLLOUT) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + msgp += sprintf (msgp, ""E:%d\n\t"", fdp->fd); + + if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE) + { + _dbus_assert_not_reached (""buffer overflow in _dbus_poll""); + } + } + + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); +#endif + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + WSAEVENT ev; + long lNetworkEvents = FD_OOB; + + ev = WSACreateEvent(); + + if (fdp->events & _DBUS_POLLIN) + lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE; + + if (fdp->events & _DBUS_POLLOUT) + lNetworkEvents |= FD_WRITE | FD_CONNECT; + + WSAEventSelect(fdp->fd, ev, lNetworkEvents); + + pEvents[i] = ev; + } + + + ready = WSAWaitForMultipleEvents (n_fds, pEvents, FALSE, timeout_milliseconds, FALSE); + + if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) + { + DBUS_SOCKET_SET_ERRNO (); + if (errno != WSAEWOULDBLOCK) + _dbus_verbose (""WSAWaitForMultipleEvents: failed: %s\n"", _dbus_strerror_from_errno ()); + ret = -1; + } + else if (ready == WSA_WAIT_TIMEOUT) + { + _dbus_verbose (""WSAWaitForMultipleEvents: WSA_WAIT_TIMEOUT\n""); + ret = 0; + } + else if (ready >= WSA_WAIT_EVENT_0 && ready < (int)(WSA_WAIT_EVENT_0 + n_fds)) + { + msgp = msg; + msgp += sprintf (msgp, ""WSAWaitForMultipleEvents: =%d\n\t"", ready); + + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + WSANETWORKEVENTS ne; + + fdp->revents = 0; + + WSAEnumNetworkEvents(fdp->fd, pEvents[i], &ne); + + if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) + fdp->revents |= _DBUS_POLLIN; + + if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT)) + fdp->revents |= _DBUS_POLLOUT; + + if (ne.lNetworkEvents & (FD_OOB)) + fdp->revents |= _DBUS_POLLERR; + + if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT)) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + if (ne.lNetworkEvents & (FD_OOB)) + msgp += sprintf (msgp, ""E:%d "", fdp->fd); + + msgp += sprintf (msgp, ""lNetworkEvents:%d "", ne.lNetworkEvents); + + if(ne.lNetworkEvents) + ret++; + + WSAEventSelect(fdp->fd, pEvents[i], 0); + } + + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); + } + else + { + _dbus_verbose (""WSAWaitForMultipleEvents: failed for unknown reason!""); + ret = -1; + } + + for(i = 0; i < n_fds; i++) + { + WSACloseEvent(pEvents[i]); + } + + if (n_fds > DBUS_STACK_WSAEVENTS) + free(pEvents); + + return ret; + +#else /* USE_CHRIS_IMPL */ + +#define DBUS_POLL_CHAR_BUFFER_SIZE 2000 + char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; + char *msgp; + + fd_set read_set, write_set, err_set; + int max_fd = 0; + int i; + struct timeval tv; + int ready; + + FD_ZERO (&read_set); + FD_ZERO (&write_set); + FD_ZERO (&err_set); + + +#ifdef DBUS_ENABLE_VERBOSE_MODE + msgp = msg; + msgp += sprintf (msgp, ""select: to=%d\n\t"", timeout_milliseconds); + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + + if (fdp->events & _DBUS_POLLIN) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (fdp->events & _DBUS_POLLOUT) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + msgp += sprintf (msgp, ""E:%d\n\t"", fdp->fd); + + if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE) + { + _dbus_assert_not_reached (""buffer overflow in _dbus_poll""); + } + } + + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); +#endif + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + if (fdp->events & _DBUS_POLLIN) + FD_SET (fdp->fd, &read_set); + + if (fdp->events & _DBUS_POLLOUT) + FD_SET (fdp->fd, &write_set); + + FD_SET (fdp->fd, &err_set); + + max_fd = MAX (max_fd, fdp->fd); + } + + tv.tv_sec = timeout_milliseconds < 0 ? 1 : timeout_milliseconds / 1000; + tv.tv_usec = timeout_milliseconds < 0 ? 0 : (timeout_milliseconds % 1000) * 1000; + + ready = select (max_fd + 1, &read_set, &write_set, &err_set, &tv); + + if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) + { + DBUS_SOCKET_SET_ERRNO (); + if (errno != WSAEWOULDBLOCK) + _dbus_verbose (""select: failed: %s\n"", _dbus_strerror_from_errno ()); + } + else if (ready == 0) + _dbus_verbose (""select: = 0\n""); + else + if (ready > 0) + { +#ifdef DBUS_ENABLE_VERBOSE_MODE + msgp = msg; + msgp += sprintf (msgp, ""select: = %d:\n\t"", ready); + + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + if (FD_ISSET (fdp->fd, &read_set)) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (FD_ISSET (fdp->fd, &write_set)) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + if (FD_ISSET (fdp->fd, &err_set)) + msgp += sprintf (msgp, ""E:%d\n\t"", fdp->fd); + } + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); +#endif + + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + fdp->revents = 0; + + if (FD_ISSET (fdp->fd, &read_set)) + fdp->revents |= _DBUS_POLLIN; + + if (FD_ISSET (fdp->fd, &write_set)) + fdp->revents |= _DBUS_POLLOUT; + + if (FD_ISSET (fdp->fd, &err_set)) + fdp->revents |= _DBUS_POLLERR; + } + } + return ready; +#endif /* USE_CHRIS_IMPL */ +} +",0,"_dbus_poll (DBusPollFD *fds, + int n_fds, + int timeout_milliseconds) +{ +#define USE_CHRIS_IMPL 0 + +#if USE_CHRIS_IMPL + +#define DBUS_POLL_CHAR_BUFFER_SIZE 2000 + char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; + char *msgp; + + int ret = 0; + int i; + struct timeval tv; + int ready; + +#define DBUS_STACK_WSAEVENTS 256 + WSAEVENT eventsOnStack[DBUS_STACK_WSAEVENTS]; + WSAEVENT *pEvents = NULL; + if (n_fds > DBUS_STACK_WSAEVENTS) + pEvents = calloc(sizeof(WSAEVENT), n_fds); + else + pEvents = eventsOnStack; + + +#ifdef DBUS_ENABLE_VERBOSE_MODE + msgp = msg; + msgp += sprintf (msgp, ""WSAEventSelect: to=%d\n\t"", timeout_milliseconds); + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + + if (fdp->events & _DBUS_POLLIN) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (fdp->events & _DBUS_POLLOUT) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + msgp += sprintf (msgp, ""E:%d\n\t"", fdp->fd); + + if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE) + { + _dbus_assert_not_reached (""buffer overflow in _dbus_poll""); + } + } + + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); +#endif + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + WSAEVENT ev; + long lNetworkEvents = FD_OOB; + + ev = WSACreateEvent(); + + if (fdp->events & _DBUS_POLLIN) + lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE; + + if (fdp->events & _DBUS_POLLOUT) + lNetworkEvents |= FD_WRITE | FD_CONNECT; + + WSAEventSelect(fdp->fd, ev, lNetworkEvents); + + pEvents[i] = ev; + } + + + ready = WSAWaitForMultipleEvents (n_fds, pEvents, FALSE, timeout_milliseconds, FALSE); + + if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) + { + DBUS_SOCKET_SET_ERRNO (); + if (errno != WSAEWOULDBLOCK) + _dbus_verbose (""WSAWaitForMultipleEvents: failed: %s\n"", _dbus_strerror_from_errno ()); + ret = -1; + } + else if (ready == WSA_WAIT_TIMEOUT) + { + _dbus_verbose (""WSAWaitForMultipleEvents: WSA_WAIT_TIMEOUT\n""); + ret = 0; + } + else if (ready >= WSA_WAIT_EVENT_0 && ready < (int)(WSA_WAIT_EVENT_0 + n_fds)) + { + msgp = msg; + msgp += sprintf (msgp, ""WSAWaitForMultipleEvents: =%d\n\t"", ready); + + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + WSANETWORKEVENTS ne; + + fdp->revents = 0; + + WSAEnumNetworkEvents(fdp->fd, pEvents[i], &ne); + + if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) + fdp->revents |= _DBUS_POLLIN; + + if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT)) + fdp->revents |= _DBUS_POLLOUT; + + if (ne.lNetworkEvents & (FD_OOB)) + fdp->revents |= _DBUS_POLLERR; + + if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT)) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + if (ne.lNetworkEvents & (FD_OOB)) + msgp += sprintf (msgp, ""E:%d "", fdp->fd); + + msgp += sprintf (msgp, ""lNetworkEvents:%d "", ne.lNetworkEvents); + + if(ne.lNetworkEvents) + ret++; + + WSAEventSelect(fdp->fd, pEvents[i], 0); + } + + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); + } + else + { + _dbus_verbose (""WSAWaitForMultipleEvents: failed for unknown reason!""); + ret = -1; + } + + for(i = 0; i < n_fds; i++) + { + WSACloseEvent(pEvents[i]); + } + + if (n_fds > DBUS_STACK_WSAEVENTS) + free(pEvents); + + return ret; + +#else /* USE_CHRIS_IMPL */ + +#define DBUS_POLL_CHAR_BUFFER_SIZE 2000 + char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; + char *msgp; + + fd_set read_set, write_set, err_set; + int max_fd = 0; + int i; + struct timeval tv; + int ready; + + FD_ZERO (&read_set); + FD_ZERO (&write_set); + FD_ZERO (&err_set); + + +#ifdef DBUS_ENABLE_VERBOSE_MODE + msgp = msg; + msgp += sprintf (msgp, ""select: to=%d\n\t"", timeout_milliseconds); + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + + if (fdp->events & _DBUS_POLLIN) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (fdp->events & _DBUS_POLLOUT) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + msgp += sprintf (msgp, ""E:%d\n\t"", fdp->fd); + + if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE) + { + _dbus_assert_not_reached (""buffer overflow in _dbus_poll""); + } + } + + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); +#endif + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + if (fdp->events & _DBUS_POLLIN) + FD_SET (fdp->fd, &read_set); + + if (fdp->events & _DBUS_POLLOUT) + FD_SET (fdp->fd, &write_set); + + FD_SET (fdp->fd, &err_set); + + max_fd = MAX (max_fd, fdp->fd); + } + + tv.tv_sec = timeout_milliseconds < 0 ? 1 : timeout_milliseconds / 1000; + tv.tv_usec = timeout_milliseconds < 0 ? 0 : (timeout_milliseconds % 1000) * 1000; + + ready = select (max_fd + 1, &read_set, &write_set, &err_set, &tv); + + if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) + { + DBUS_SOCKET_SET_ERRNO (); + if (errno != WSAEWOULDBLOCK) + _dbus_verbose (""select: failed: %s\n"", _dbus_strerror_from_errno ()); + } + else if (ready == 0) + _dbus_verbose (""select: = 0\n""); + else + if (ready > 0) + { +#ifdef DBUS_ENABLE_VERBOSE_MODE + msgp = msg; + msgp += sprintf (msgp, ""select: = %d:\n\t"", ready); + + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + if (FD_ISSET (fdp->fd, &read_set)) + msgp += sprintf (msgp, ""R:%d "", fdp->fd); + + if (FD_ISSET (fdp->fd, &write_set)) + msgp += sprintf (msgp, ""W:%d "", fdp->fd); + + if (FD_ISSET (fdp->fd, &err_set)) + msgp += sprintf (msgp, ""E:%d\n\t"", fdp->fd); + } + msgp += sprintf (msgp, ""\n""); + _dbus_verbose (""%s"",msg); +#endif + + for (i = 0; i < n_fds; i++) + { + DBusPollFD *fdp = &fds[i]; + + fdp->revents = 0; + + if (FD_ISSET (fdp->fd, &read_set)) + fdp->revents |= _DBUS_POLLIN; + + if (FD_ISSET (fdp->fd, &write_set)) + fdp->revents |= _DBUS_POLLOUT; + + if (FD_ISSET (fdp->fd, &err_set)) + fdp->revents |= _DBUS_POLLERR; + } + } + return ready; +#endif /* USE_CHRIS_IMPL */ +} +","@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format, + char buf[1024]; + int bufsize; + int len; ++ va_list args_copy; + + bufsize = sizeof (buf); +- len = _vsnprintf (buf, bufsize - 1, format, args); ++ DBUS_VA_COPY (args_copy, args); ++ len = _vsnprintf (buf, bufsize - 1, format, args_copy); ++ va_end (args_copy); + + while (len == -1) /* try again */ + { +@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format, + if (p == NULL) + return -1; + +- len = _vsnprintf (p, bufsize - 1, format, args); ++ DBUS_VA_COPY (args_copy, args); ++ len = _vsnprintf (p, bufsize - 1, format, args_copy); ++ va_end (args_copy); + free (p); + }",2057,2293,4096 +3822,"static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + u32 exec_control; + + vmcs_write16(GUEST_ES_SELECTOR, vmcs12->guest_es_selector); + vmcs_write16(GUEST_CS_SELECTOR, vmcs12->guest_cs_selector); + vmcs_write16(GUEST_SS_SELECTOR, vmcs12->guest_ss_selector); + vmcs_write16(GUEST_DS_SELECTOR, vmcs12->guest_ds_selector); + vmcs_write16(GUEST_FS_SELECTOR, vmcs12->guest_fs_selector); + vmcs_write16(GUEST_GS_SELECTOR, vmcs12->guest_gs_selector); + vmcs_write16(GUEST_LDTR_SELECTOR, vmcs12->guest_ldtr_selector); + vmcs_write16(GUEST_TR_SELECTOR, vmcs12->guest_tr_selector); + vmcs_write32(GUEST_ES_LIMIT, vmcs12->guest_es_limit); + vmcs_write32(GUEST_CS_LIMIT, vmcs12->guest_cs_limit); + vmcs_write32(GUEST_SS_LIMIT, vmcs12->guest_ss_limit); + vmcs_write32(GUEST_DS_LIMIT, vmcs12->guest_ds_limit); + vmcs_write32(GUEST_FS_LIMIT, vmcs12->guest_fs_limit); + vmcs_write32(GUEST_GS_LIMIT, vmcs12->guest_gs_limit); + vmcs_write32(GUEST_LDTR_LIMIT, vmcs12->guest_ldtr_limit); + vmcs_write32(GUEST_TR_LIMIT, vmcs12->guest_tr_limit); + vmcs_write32(GUEST_GDTR_LIMIT, vmcs12->guest_gdtr_limit); + vmcs_write32(GUEST_IDTR_LIMIT, vmcs12->guest_idtr_limit); + vmcs_write32(GUEST_ES_AR_BYTES, vmcs12->guest_es_ar_bytes); + vmcs_write32(GUEST_CS_AR_BYTES, vmcs12->guest_cs_ar_bytes); + vmcs_write32(GUEST_SS_AR_BYTES, vmcs12->guest_ss_ar_bytes); + vmcs_write32(GUEST_DS_AR_BYTES, vmcs12->guest_ds_ar_bytes); + vmcs_write32(GUEST_FS_AR_BYTES, vmcs12->guest_fs_ar_bytes); + vmcs_write32(GUEST_GS_AR_BYTES, vmcs12->guest_gs_ar_bytes); + vmcs_write32(GUEST_LDTR_AR_BYTES, vmcs12->guest_ldtr_ar_bytes); + vmcs_write32(GUEST_TR_AR_BYTES, vmcs12->guest_tr_ar_bytes); + vmcs_writel(GUEST_ES_BASE, vmcs12->guest_es_base); + vmcs_writel(GUEST_CS_BASE, vmcs12->guest_cs_base); + vmcs_writel(GUEST_SS_BASE, vmcs12->guest_ss_base); + vmcs_writel(GUEST_DS_BASE, vmcs12->guest_ds_base); + vmcs_writel(GUEST_FS_BASE, vmcs12->guest_fs_base); + vmcs_writel(GUEST_GS_BASE, vmcs12->guest_gs_base); + vmcs_writel(GUEST_LDTR_BASE, vmcs12->guest_ldtr_base); + vmcs_writel(GUEST_TR_BASE, vmcs12->guest_tr_base); + vmcs_writel(GUEST_GDTR_BASE, vmcs12->guest_gdtr_base); + vmcs_writel(GUEST_IDTR_BASE, vmcs12->guest_idtr_base); + + vmcs_write64(GUEST_IA32_DEBUGCTL, vmcs12->guest_ia32_debugctl); + vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, + vmcs12->vm_entry_intr_info_field); + vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, + vmcs12->vm_entry_exception_error_code); + vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, + vmcs12->vm_entry_instruction_len); + vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, + vmcs12->guest_interruptibility_info); + vmcs_write32(GUEST_SYSENTER_CS, vmcs12->guest_sysenter_cs); + kvm_set_dr(vcpu, 7, vmcs12->guest_dr7); + vmx_set_rflags(vcpu, vmcs12->guest_rflags); + vmcs_writel(GUEST_PENDING_DBG_EXCEPTIONS, + vmcs12->guest_pending_dbg_exceptions); + vmcs_writel(GUEST_SYSENTER_ESP, vmcs12->guest_sysenter_esp); + vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->guest_sysenter_eip); + + vmcs_write64(VMCS_LINK_POINTER, -1ull); + + vmcs_write32(PIN_BASED_VM_EXEC_CONTROL, + (vmcs_config.pin_based_exec_ctrl | + vmcs12->pin_based_vm_exec_control)); + + if (vmcs12->pin_based_vm_exec_control & PIN_BASED_VMX_PREEMPTION_TIMER) + vmcs_write32(VMX_PREEMPTION_TIMER_VALUE, + vmcs12->vmx_preemption_timer_value); + + /* + * Whether page-faults are trapped is determined by a combination of + * 3 settings: PFEC_MASK, PFEC_MATCH and EXCEPTION_BITMAP.PF. + * If enable_ept, L0 doesn't care about page faults and we should + * set all of these to L1's desires. However, if !enable_ept, L0 does + * care about (at least some) page faults, and because it is not easy + * (if at all possible?) to merge L0 and L1's desires, we simply ask + * to exit on each and every L2 page fault. This is done by setting + * MASK=MATCH=0 and (see below) EB.PF=1. + * Note that below we don't need special code to set EB.PF beyond the + * ""or""ing of the EB of vmcs01 and vmcs12, because when enable_ept, + * vmcs01's EB.PF is 0 so the ""or"" will take vmcs12's value, and when + * !enable_ept, EB.PF is 1, so the ""or"" will always be 1. + * + * A problem with this approach (when !enable_ept) is that L1 may be + * injected with more page faults than it asked for. This could have + * caused problems, but in practice existing hypervisors don't care. + * To fix this, we will need to emulate the PFEC checking (on the L1 + * page tables), using walk_addr(), when injecting PFs to L1. + */ + vmcs_write32(PAGE_FAULT_ERROR_CODE_MASK, + enable_ept ? vmcs12->page_fault_error_code_mask : 0); + vmcs_write32(PAGE_FAULT_ERROR_CODE_MATCH, + enable_ept ? vmcs12->page_fault_error_code_match : 0); + + if (cpu_has_secondary_exec_ctrls()) { + u32 exec_control = vmx_secondary_exec_control(vmx); + if (!vmx->rdtscp_enabled) + exec_control &= ~SECONDARY_EXEC_RDTSCP; + /* Take the following fields only from vmcs12 */ + exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; + if (nested_cpu_has(vmcs12, + CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) + exec_control |= vmcs12->secondary_vm_exec_control; + + if (exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) { + /* + * Translate L1 physical address to host physical + * address for vmcs02. Keep the page pinned, so this + * physical address remains valid. We keep a reference + * to it so we can release it later. + */ + if (vmx->nested.apic_access_page) /* shouldn't happen */ + nested_release_page(vmx->nested.apic_access_page); + vmx->nested.apic_access_page = + nested_get_page(vcpu, vmcs12->apic_access_addr); + /* + * If translation failed, no matter: This feature asks + * to exit when accessing the given address, and if it + * can never be accessed, this feature won't do + * anything anyway. + */ + if (!vmx->nested.apic_access_page) + exec_control &= + ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; + else + vmcs_write64(APIC_ACCESS_ADDR, + page_to_phys(vmx->nested.apic_access_page)); + } + + vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control); + } + + + /* + * Set host-state according to L0's settings (vmcs12 is irrelevant here) + * Some constant fields are set here by vmx_set_constant_host_state(). + * Other fields are different per CPU, and will be set later when + * vmx_vcpu_load() is called, and when vmx_save_host_state() is called. + */ + vmx_set_constant_host_state(vmx); + + /* + * HOST_RSP is normally set correctly in vmx_vcpu_run() just before + * entry, but only if the current (host) sp changed from the value + * we wrote last (vmx->host_rsp). This cache is no longer relevant + * if we switch vmcs, and rather than hold a separate cache per vmcs, + * here we just force the write to happen on entry. + */ + vmx->host_rsp = 0; + + exec_control = vmx_exec_control(vmx); /* L0's desires */ + exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING; + exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING; + exec_control &= ~CPU_BASED_TPR_SHADOW; + exec_control |= vmcs12->cpu_based_vm_exec_control; + /* + * Merging of IO and MSR bitmaps not currently supported. + * Rather, exit every time. + */ + exec_control &= ~CPU_BASED_USE_MSR_BITMAPS; + exec_control &= ~CPU_BASED_USE_IO_BITMAPS; + exec_control |= CPU_BASED_UNCOND_IO_EXITING; + + vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control); + + /* EXCEPTION_BITMAP and CR0_GUEST_HOST_MASK should basically be the + * bitwise-or of what L1 wants to trap for L2, and what we want to + * trap. Note that CR0.TS also needs updating - we do this later. + */ + update_exception_bitmap(vcpu); + vcpu->arch.cr0_guest_owned_bits &= ~vmcs12->cr0_guest_host_mask; + vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits); + + /* L2->L1 exit controls are emulated - the hardware exit is to L0 so + * we should use its exit controls. Note that VM_EXIT_LOAD_IA32_EFER + * bits are further modified by vmx_set_efer() below. + */ + vmcs_write32(VM_EXIT_CONTROLS, vmcs_config.vmexit_ctrl); + + /* vmcs12's VM_ENTRY_LOAD_IA32_EFER and VM_ENTRY_IA32E_MODE are + * emulated by vmx_set_efer(), below. + */ + vmcs_write32(VM_ENTRY_CONTROLS, + (vmcs12->vm_entry_controls & ~VM_ENTRY_LOAD_IA32_EFER & + ~VM_ENTRY_IA32E_MODE) | + (vmcs_config.vmentry_ctrl & ~VM_ENTRY_IA32E_MODE)); + + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PAT) + vmcs_write64(GUEST_IA32_PAT, vmcs12->guest_ia32_pat); + else if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) + vmcs_write64(GUEST_IA32_PAT, vmx->vcpu.arch.pat); + + + set_cr4_guest_host_mask(vmx); + + if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETING) + vmcs_write64(TSC_OFFSET, + vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset); + else + vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset); + + if (enable_vpid) { + /* + * Trivially support vpid by letting L2s share their parent + * L1's vpid. TODO: move to a more elaborate solution, giving + * each L2 its own vpid and exposing the vpid feature to L1. + */ + vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); + vmx_flush_tlb(vcpu); + } + + if (nested_cpu_has_ept(vmcs12)) { + kvm_mmu_unload(vcpu); + nested_ept_init_mmu_context(vcpu); + } + + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_EFER) + vcpu->arch.efer = vmcs12->guest_ia32_efer; + else if (vmcs12->vm_entry_controls & VM_ENTRY_IA32E_MODE) + vcpu->arch.efer |= (EFER_LMA | EFER_LME); + else + vcpu->arch.efer &= ~(EFER_LMA | EFER_LME); + /* Note: modifies VM_ENTRY/EXIT_CONTROLS and GUEST/HOST_IA32_EFER */ + vmx_set_efer(vcpu, vcpu->arch.efer); + + /* + * This sets GUEST_CR0 to vmcs12->guest_cr0, with possibly a modified + * TS bit (for lazy fpu) and bits which we consider mandatory enabled. + * The CR0_READ_SHADOW is what L2 should have expected to read given + * the specifications by L1; It's not enough to take + * vmcs12->cr0_read_shadow because on our cr0_guest_host_mask we we + * have more bits than L1 expected. + */ + vmx_set_cr0(vcpu, vmcs12->guest_cr0); + vmcs_writel(CR0_READ_SHADOW, nested_read_cr0(vmcs12)); + + vmx_set_cr4(vcpu, vmcs12->guest_cr4); + vmcs_writel(CR4_READ_SHADOW, nested_read_cr4(vmcs12)); + + /* shadow page tables on either EPT or shadow page tables */ + kvm_set_cr3(vcpu, vmcs12->guest_cr3); + kvm_mmu_reset_context(vcpu); + + /* + * L1 may access the L2's PDPTR, so save them to construct vmcs12 + */ + if (enable_ept) { + vmcs_write64(GUEST_PDPTR0, vmcs12->guest_pdptr0); + vmcs_write64(GUEST_PDPTR1, vmcs12->guest_pdptr1); + vmcs_write64(GUEST_PDPTR2, vmcs12->guest_pdptr2); + vmcs_write64(GUEST_PDPTR3, vmcs12->guest_pdptr3); + } + + kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->guest_rsp); + kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->guest_rip); +} +",0,"static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) +{ + struct vcpu_vmx *vmx = to_vmx(vcpu); + u32 exec_control; + + vmcs_write16(GUEST_ES_SELECTOR, vmcs12->guest_es_selector); + vmcs_write16(GUEST_CS_SELECTOR, vmcs12->guest_cs_selector); + vmcs_write16(GUEST_SS_SELECTOR, vmcs12->guest_ss_selector); + vmcs_write16(GUEST_DS_SELECTOR, vmcs12->guest_ds_selector); + vmcs_write16(GUEST_FS_SELECTOR, vmcs12->guest_fs_selector); + vmcs_write16(GUEST_GS_SELECTOR, vmcs12->guest_gs_selector); + vmcs_write16(GUEST_LDTR_SELECTOR, vmcs12->guest_ldtr_selector); + vmcs_write16(GUEST_TR_SELECTOR, vmcs12->guest_tr_selector); + vmcs_write32(GUEST_ES_LIMIT, vmcs12->guest_es_limit); + vmcs_write32(GUEST_CS_LIMIT, vmcs12->guest_cs_limit); + vmcs_write32(GUEST_SS_LIMIT, vmcs12->guest_ss_limit); + vmcs_write32(GUEST_DS_LIMIT, vmcs12->guest_ds_limit); + vmcs_write32(GUEST_FS_LIMIT, vmcs12->guest_fs_limit); + vmcs_write32(GUEST_GS_LIMIT, vmcs12->guest_gs_limit); + vmcs_write32(GUEST_LDTR_LIMIT, vmcs12->guest_ldtr_limit); + vmcs_write32(GUEST_TR_LIMIT, vmcs12->guest_tr_limit); + vmcs_write32(GUEST_GDTR_LIMIT, vmcs12->guest_gdtr_limit); + vmcs_write32(GUEST_IDTR_LIMIT, vmcs12->guest_idtr_limit); + vmcs_write32(GUEST_ES_AR_BYTES, vmcs12->guest_es_ar_bytes); + vmcs_write32(GUEST_CS_AR_BYTES, vmcs12->guest_cs_ar_bytes); + vmcs_write32(GUEST_SS_AR_BYTES, vmcs12->guest_ss_ar_bytes); + vmcs_write32(GUEST_DS_AR_BYTES, vmcs12->guest_ds_ar_bytes); + vmcs_write32(GUEST_FS_AR_BYTES, vmcs12->guest_fs_ar_bytes); + vmcs_write32(GUEST_GS_AR_BYTES, vmcs12->guest_gs_ar_bytes); + vmcs_write32(GUEST_LDTR_AR_BYTES, vmcs12->guest_ldtr_ar_bytes); + vmcs_write32(GUEST_TR_AR_BYTES, vmcs12->guest_tr_ar_bytes); + vmcs_writel(GUEST_ES_BASE, vmcs12->guest_es_base); + vmcs_writel(GUEST_CS_BASE, vmcs12->guest_cs_base); + vmcs_writel(GUEST_SS_BASE, vmcs12->guest_ss_base); + vmcs_writel(GUEST_DS_BASE, vmcs12->guest_ds_base); + vmcs_writel(GUEST_FS_BASE, vmcs12->guest_fs_base); + vmcs_writel(GUEST_GS_BASE, vmcs12->guest_gs_base); + vmcs_writel(GUEST_LDTR_BASE, vmcs12->guest_ldtr_base); + vmcs_writel(GUEST_TR_BASE, vmcs12->guest_tr_base); + vmcs_writel(GUEST_GDTR_BASE, vmcs12->guest_gdtr_base); + vmcs_writel(GUEST_IDTR_BASE, vmcs12->guest_idtr_base); + + vmcs_write64(GUEST_IA32_DEBUGCTL, vmcs12->guest_ia32_debugctl); + vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, + vmcs12->vm_entry_intr_info_field); + vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, + vmcs12->vm_entry_exception_error_code); + vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, + vmcs12->vm_entry_instruction_len); + vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, + vmcs12->guest_interruptibility_info); + vmcs_write32(GUEST_SYSENTER_CS, vmcs12->guest_sysenter_cs); + kvm_set_dr(vcpu, 7, vmcs12->guest_dr7); + vmx_set_rflags(vcpu, vmcs12->guest_rflags); + vmcs_writel(GUEST_PENDING_DBG_EXCEPTIONS, + vmcs12->guest_pending_dbg_exceptions); + vmcs_writel(GUEST_SYSENTER_ESP, vmcs12->guest_sysenter_esp); + vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->guest_sysenter_eip); + + vmcs_write64(VMCS_LINK_POINTER, -1ull); + + vmcs_write32(PIN_BASED_VM_EXEC_CONTROL, + (vmcs_config.pin_based_exec_ctrl | + vmcs12->pin_based_vm_exec_control)); + + if (vmcs12->pin_based_vm_exec_control & PIN_BASED_VMX_PREEMPTION_TIMER) + vmcs_write32(VMX_PREEMPTION_TIMER_VALUE, + vmcs12->vmx_preemption_timer_value); + + /* + * Whether page-faults are trapped is determined by a combination of + * 3 settings: PFEC_MASK, PFEC_MATCH and EXCEPTION_BITMAP.PF. + * If enable_ept, L0 doesn't care about page faults and we should + * set all of these to L1's desires. However, if !enable_ept, L0 does + * care about (at least some) page faults, and because it is not easy + * (if at all possible?) to merge L0 and L1's desires, we simply ask + * to exit on each and every L2 page fault. This is done by setting + * MASK=MATCH=0 and (see below) EB.PF=1. + * Note that below we don't need special code to set EB.PF beyond the + * ""or""ing of the EB of vmcs01 and vmcs12, because when enable_ept, + * vmcs01's EB.PF is 0 so the ""or"" will take vmcs12's value, and when + * !enable_ept, EB.PF is 1, so the ""or"" will always be 1. + * + * A problem with this approach (when !enable_ept) is that L1 may be + * injected with more page faults than it asked for. This could have + * caused problems, but in practice existing hypervisors don't care. + * To fix this, we will need to emulate the PFEC checking (on the L1 + * page tables), using walk_addr(), when injecting PFs to L1. + */ + vmcs_write32(PAGE_FAULT_ERROR_CODE_MASK, + enable_ept ? vmcs12->page_fault_error_code_mask : 0); + vmcs_write32(PAGE_FAULT_ERROR_CODE_MATCH, + enable_ept ? vmcs12->page_fault_error_code_match : 0); + + if (cpu_has_secondary_exec_ctrls()) { + u32 exec_control = vmx_secondary_exec_control(vmx); + if (!vmx->rdtscp_enabled) + exec_control &= ~SECONDARY_EXEC_RDTSCP; + /* Take the following fields only from vmcs12 */ + exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; + if (nested_cpu_has(vmcs12, + CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) + exec_control |= vmcs12->secondary_vm_exec_control; + + if (exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) { + /* + * Translate L1 physical address to host physical + * address for vmcs02. Keep the page pinned, so this + * physical address remains valid. We keep a reference + * to it so we can release it later. + */ + if (vmx->nested.apic_access_page) /* shouldn't happen */ + nested_release_page(vmx->nested.apic_access_page); + vmx->nested.apic_access_page = + nested_get_page(vcpu, vmcs12->apic_access_addr); + /* + * If translation failed, no matter: This feature asks + * to exit when accessing the given address, and if it + * can never be accessed, this feature won't do + * anything anyway. + */ + if (!vmx->nested.apic_access_page) + exec_control &= + ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; + else + vmcs_write64(APIC_ACCESS_ADDR, + page_to_phys(vmx->nested.apic_access_page)); + } + + vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control); + } + + + /* + * Set host-state according to L0's settings (vmcs12 is irrelevant here) + * Some constant fields are set here by vmx_set_constant_host_state(). + * Other fields are different per CPU, and will be set later when + * vmx_vcpu_load() is called, and when vmx_save_host_state() is called. + */ + vmx_set_constant_host_state(vmx); + + /* + * HOST_RSP is normally set correctly in vmx_vcpu_run() just before + * entry, but only if the current (host) sp changed from the value + * we wrote last (vmx->host_rsp). This cache is no longer relevant + * if we switch vmcs, and rather than hold a separate cache per vmcs, + * here we just force the write to happen on entry. + */ + vmx->host_rsp = 0; + + exec_control = vmx_exec_control(vmx); /* L0's desires */ + exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING; + exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING; + exec_control &= ~CPU_BASED_TPR_SHADOW; + exec_control |= vmcs12->cpu_based_vm_exec_control; + /* + * Merging of IO and MSR bitmaps not currently supported. + * Rather, exit every time. + */ + exec_control &= ~CPU_BASED_USE_MSR_BITMAPS; + exec_control &= ~CPU_BASED_USE_IO_BITMAPS; + exec_control |= CPU_BASED_UNCOND_IO_EXITING; + + vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control); + + /* EXCEPTION_BITMAP and CR0_GUEST_HOST_MASK should basically be the + * bitwise-or of what L1 wants to trap for L2, and what we want to + * trap. Note that CR0.TS also needs updating - we do this later. + */ + update_exception_bitmap(vcpu); + vcpu->arch.cr0_guest_owned_bits &= ~vmcs12->cr0_guest_host_mask; + vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits); + + /* L2->L1 exit controls are emulated - the hardware exit is to L0 so + * we should use its exit controls. Note that VM_EXIT_LOAD_IA32_EFER + * bits are further modified by vmx_set_efer() below. + */ + vmcs_write32(VM_EXIT_CONTROLS, vmcs_config.vmexit_ctrl); + + /* vmcs12's VM_ENTRY_LOAD_IA32_EFER and VM_ENTRY_IA32E_MODE are + * emulated by vmx_set_efer(), below. + */ + vmcs_write32(VM_ENTRY_CONTROLS, + (vmcs12->vm_entry_controls & ~VM_ENTRY_LOAD_IA32_EFER & + ~VM_ENTRY_IA32E_MODE) | + (vmcs_config.vmentry_ctrl & ~VM_ENTRY_IA32E_MODE)); + + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PAT) + vmcs_write64(GUEST_IA32_PAT, vmcs12->guest_ia32_pat); + else if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) + vmcs_write64(GUEST_IA32_PAT, vmx->vcpu.arch.pat); + + + set_cr4_guest_host_mask(vmx); + + if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETING) + vmcs_write64(TSC_OFFSET, + vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset); + else + vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset); + + if (enable_vpid) { + /* + * Trivially support vpid by letting L2s share their parent + * L1's vpid. TODO: move to a more elaborate solution, giving + * each L2 its own vpid and exposing the vpid feature to L1. + */ + vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); + vmx_flush_tlb(vcpu); + } + + if (nested_cpu_has_ept(vmcs12)) { + kvm_mmu_unload(vcpu); + nested_ept_init_mmu_context(vcpu); + } + + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_EFER) + vcpu->arch.efer = vmcs12->guest_ia32_efer; + else if (vmcs12->vm_entry_controls & VM_ENTRY_IA32E_MODE) + vcpu->arch.efer |= (EFER_LMA | EFER_LME); + else + vcpu->arch.efer &= ~(EFER_LMA | EFER_LME); + /* Note: modifies VM_ENTRY/EXIT_CONTROLS and GUEST/HOST_IA32_EFER */ + vmx_set_efer(vcpu, vcpu->arch.efer); + + /* + * This sets GUEST_CR0 to vmcs12->guest_cr0, with possibly a modified + * TS bit (for lazy fpu) and bits which we consider mandatory enabled. + * The CR0_READ_SHADOW is what L2 should have expected to read given + * the specifications by L1; It's not enough to take + * vmcs12->cr0_read_shadow because on our cr0_guest_host_mask we we + * have more bits than L1 expected. + */ + vmx_set_cr0(vcpu, vmcs12->guest_cr0); + vmcs_writel(CR0_READ_SHADOW, nested_read_cr0(vmcs12)); + + vmx_set_cr4(vcpu, vmcs12->guest_cr4); + vmcs_writel(CR4_READ_SHADOW, nested_read_cr4(vmcs12)); + + /* shadow page tables on either EPT or shadow page tables */ + kvm_set_cr3(vcpu, vmcs12->guest_cr3); + kvm_mmu_reset_context(vcpu); + + /* + * L1 may access the L2's PDPTR, so save them to construct vmcs12 + */ + if (enable_ept) { + vmcs_write64(GUEST_PDPTR0, vmcs12->guest_pdptr0); + vmcs_write64(GUEST_PDPTR1, vmcs12->guest_pdptr1); + vmcs_write64(GUEST_PDPTR2, vmcs12->guest_pdptr2); + vmcs_write64(GUEST_PDPTR3, vmcs12->guest_pdptr3); + } + + kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->guest_rsp); + kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->guest_rip); +} +","@@ -712,6 +712,7 @@ static void nested_release_page_clean(struct page *page) + kvm_release_page_clean(page); + } + ++static unsigned long nested_ept_get_cr3(struct kvm_vcpu *vcpu); + static u64 construct_eptp(unsigned long root_hpa); + static void kvm_cpu_vmxon(u64 addr); + static void kvm_cpu_vmxoff(void); +@@ -2161,6 +2162,7 @@ static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high; + static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high; + static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high; + static u32 nested_vmx_misc_low, nested_vmx_misc_high; ++static u32 nested_vmx_ept_caps; + static __init void nested_vmx_setup_ctls_msrs(void) + { + /* +@@ -6279,6 +6281,74 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu) + return 1; + } + ++/* Emulate the INVEPT instruction */ ++static int handle_invept(struct kvm_vcpu *vcpu) ++{ ++ u32 vmx_instruction_info, types; ++ unsigned long type; ++ gva_t gva; ++ struct x86_exception e; ++ struct { ++ u64 eptp, gpa; ++ } operand; ++ u64 eptp_mask = ((1ull << 51) - 1) & PAGE_MASK; ++ ++ if (!(nested_vmx_secondary_ctls_high & SECONDARY_EXEC_ENABLE_EPT) || ++ !(nested_vmx_ept_caps & VMX_EPT_INVEPT_BIT)) { ++ kvm_queue_exception(vcpu, UD_VECTOR); ++ return 1; ++ } ++ ++ if (!nested_vmx_check_permission(vcpu)) ++ return 1; ++ ++ if (!kvm_read_cr0_bits(vcpu, X86_CR0_PE)) { ++ kvm_queue_exception(vcpu, UD_VECTOR); ++ return 1; ++ } ++ ++ vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); ++ type = kvm_register_read(vcpu, (vmx_instruction_info >> 28) & 0xf); ++ ++ types = (nested_vmx_ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6; ++ ++ if (!(types & (1UL << type))) { ++ nested_vmx_failValid(vcpu, ++ VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); ++ return 1; ++ } ++ ++ /* According to the Intel VMX instruction reference, the memory ++ * operand is read even if it isn't needed (e.g., for type==global) ++ */ ++ if (get_vmx_mem_address(vcpu, vmcs_readl(EXIT_QUALIFICATION), ++ vmx_instruction_info, &gva)) ++ return 1; ++ if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &operand, ++ sizeof(operand), &e)) { ++ kvm_inject_page_fault(vcpu, &e); ++ return 1; ++ } ++ ++ switch (type) { ++ case VMX_EPT_EXTENT_CONTEXT: ++ if ((operand.eptp & eptp_mask) != ++ (nested_ept_get_cr3(vcpu) & eptp_mask)) ++ break; ++ case VMX_EPT_EXTENT_GLOBAL: ++ kvm_mmu_sync_roots(vcpu); ++ kvm_mmu_flush_tlb(vcpu); ++ nested_vmx_succeed(vcpu); ++ break; ++ default: ++ BUG_ON(1); ++ break; ++ } ++ ++ skip_emulated_instruction(vcpu); ++ return 1; ++} ++ + /* + * The exit handlers return 1 if the exit was handled fully and guest execution + * may resume. Otherwise they set the kvm_run parameter to indicate what needs +@@ -6323,6 +6393,7 @@ static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { + [EXIT_REASON_PAUSE_INSTRUCTION] = handle_pause, + [EXIT_REASON_MWAIT_INSTRUCTION] = handle_invalid_op, + [EXIT_REASON_MONITOR_INSTRUCTION] = handle_invalid_op, ++ [EXIT_REASON_INVEPT] = handle_invept, + }; + + static const int kvm_vmx_max_exit_handlers = +@@ -6549,6 +6620,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) + case EXIT_REASON_VMPTRST: case EXIT_REASON_VMREAD: + case EXIT_REASON_VMRESUME: case EXIT_REASON_VMWRITE: + case EXIT_REASON_VMOFF: case EXIT_REASON_VMON: ++ case EXIT_REASON_INVEPT: + /* + * VMX instructions trap unconditionally. This allows L1 to + * emulate them for its L2 guest, i.e., allows 3-level nesting!",3360,3596,4096 +18159,"static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define MonoColorType 1 +#define RGBColorType 3 + + char + property[MaxTextExtent]; + + CINInfo + cin; + + Image + *image; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + QuantumInfo + *quantum_info; + + QuantumType + quantum_type; + + register ssize_t + i; + + register PixelPacket + *q; + + size_t + length; + + ssize_t + count, + y; + + unsigned char + magick[4], + *pixels; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + File information. + */ + offset=0; + count=ReadBlob(image,4,magick); + offset+=count; + if ((count != 4) || + ((LocaleNCompare((char *) magick,""\200\052\137\327"",4) != 0))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + image->endian=(magick[0] == 0x80) && (magick[1] == 0x2a) && + (magick[2] == 0x5f) && (magick[3] == 0xd7) ? MSBEndian : LSBEndian; + cin.file.image_offset=ReadBlobLong(image); + offset+=4; + cin.file.generic_length=ReadBlobLong(image); + offset+=4; + cin.file.industry_length=ReadBlobLong(image); + offset+=4; + cin.file.user_length=ReadBlobLong(image); + offset+=4; + cin.file.file_size=ReadBlobLong(image); + offset+=4; + offset+=ReadBlob(image,sizeof(cin.file.version),(unsigned char *) + cin.file.version); + (void) CopyMagickString(property,cin.file.version,sizeof(cin.file.version)); + (void) SetImageProperty(image,""dpx:file.version"",property); + offset+=ReadBlob(image,sizeof(cin.file.filename),(unsigned char *) + cin.file.filename); + (void) CopyMagickString(property,cin.file.filename,sizeof(cin.file.filename)); + (void) SetImageProperty(image,""dpx:file.filename"",property); + offset+=ReadBlob(image,sizeof(cin.file.create_date),(unsigned char *) + cin.file.create_date); + (void) CopyMagickString(property,cin.file.create_date, + sizeof(cin.file.create_date)); + (void) SetImageProperty(image,""dpx:file.create_date"",property); + offset+=ReadBlob(image,sizeof(cin.file.create_time),(unsigned char *) + cin.file.create_time); + (void) CopyMagickString(property,cin.file.create_time, + sizeof(cin.file.create_time)); + (void) SetImageProperty(image,""dpx:file.create_time"",property); + offset+=ReadBlob(image,sizeof(cin.file.reserve),(unsigned char *) + cin.file.reserve); + /* + Image information. + */ + cin.image.orientation=(unsigned char) ReadBlobByte(image); + offset++; + if (cin.image.orientation != (unsigned char) (~0)) + (void) FormatImageProperty(image,""dpx:image.orientation"",""%d"", + cin.image.orientation); + switch (cin.image.orientation) + { + default: + case 0: image->orientation=TopLeftOrientation; break; + case 1: image->orientation=TopRightOrientation; break; + case 2: image->orientation=BottomLeftOrientation; break; + case 3: image->orientation=BottomRightOrientation; break; + case 4: image->orientation=LeftTopOrientation; break; + case 5: image->orientation=RightTopOrientation; break; + case 6: image->orientation=LeftBottomOrientation; break; + case 7: image->orientation=RightBottomOrientation; break; + } + cin.image.number_channels=(unsigned char) ReadBlobByte(image); + offset++; + offset+=ReadBlob(image,sizeof(cin.image.reserve1),(unsigned char *) + cin.image.reserve1); + for (i=0; i < 8; i++) + { + cin.image.channel[i].designator[0]=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].designator[1]=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].bits_per_pixel=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].reserve=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].pixels_per_line=ReadBlobLong(image); + offset+=4; + cin.image.channel[i].lines_per_image=ReadBlobLong(image); + offset+=4; + cin.image.channel[i].min_data=ReadBlobFloat(image); + offset+=4; + cin.image.channel[i].min_quantity=ReadBlobFloat(image); + offset+=4; + cin.image.channel[i].max_data=ReadBlobFloat(image); + offset+=4; + cin.image.channel[i].max_quantity=ReadBlobFloat(image); + offset+=4; + } + cin.image.white_point[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.white_point[0]) != MagickFalse) + image->chromaticity.white_point.x=cin.image.white_point[0]; + cin.image.white_point[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.white_point[1]) != MagickFalse) + image->chromaticity.white_point.y=cin.image.white_point[1]; + cin.image.red_primary_chromaticity[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.red_primary_chromaticity[0]) != MagickFalse) + image->chromaticity.red_primary.x=cin.image.red_primary_chromaticity[0]; + cin.image.red_primary_chromaticity[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.red_primary_chromaticity[1]) != MagickFalse) + image->chromaticity.red_primary.y=cin.image.red_primary_chromaticity[1]; + cin.image.green_primary_chromaticity[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.green_primary_chromaticity[0]) != MagickFalse) + image->chromaticity.red_primary.x=cin.image.green_primary_chromaticity[0]; + cin.image.green_primary_chromaticity[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.green_primary_chromaticity[1]) != MagickFalse) + image->chromaticity.green_primary.y=cin.image.green_primary_chromaticity[1]; + cin.image.blue_primary_chromaticity[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.blue_primary_chromaticity[0]) != MagickFalse) + image->chromaticity.blue_primary.x=cin.image.blue_primary_chromaticity[0]; + cin.image.blue_primary_chromaticity[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.blue_primary_chromaticity[1]) != MagickFalse) + image->chromaticity.blue_primary.y=cin.image.blue_primary_chromaticity[1]; + offset+=ReadBlob(image,sizeof(cin.image.label),(unsigned char *) + cin.image.label); + (void) CopyMagickString(property,cin.image.label,sizeof(cin.image.label)); + (void) SetImageProperty(image,""dpx:image.label"",property); + offset+=ReadBlob(image,sizeof(cin.image.reserve),(unsigned char *) + cin.image.reserve); + /* + Image data format information. + */ + cin.data_format.interleave=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.packing=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.sign=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.sense=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.line_pad=ReadBlobLong(image); + offset+=4; + cin.data_format.channel_pad=ReadBlobLong(image); + offset+=4; + offset+=ReadBlob(image,sizeof(cin.data_format.reserve),(unsigned char *) + cin.data_format.reserve); + /* + Image origination information. + */ + cin.origination.x_offset=(int) ReadBlobLong(image); + offset+=4; + if ((size_t) cin.origination.x_offset != ~0UL) + (void) FormatImageProperty(image,""dpx:origination.x_offset"",""%.20g"", + (double) cin.origination.x_offset); + cin.origination.y_offset=(ssize_t) ReadBlobLong(image); + offset+=4; + if ((size_t) cin.origination.y_offset != ~0UL) + (void) FormatImageProperty(image,""dpx:origination.y_offset"",""%.20g"", + (double) cin.origination.y_offset); + offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *) + cin.origination.filename); + (void) CopyMagickString(property,cin.origination.filename, + sizeof(cin.origination.filename)); + (void) SetImageProperty(image,""dpx:origination.filename"",property); + offset+=ReadBlob(image,sizeof(cin.origination.create_date),(unsigned char *) + cin.origination.create_date); + (void) CopyMagickString(property,cin.origination.create_date, + sizeof(cin.origination.create_date)); + (void) SetImageProperty(image,""dpx:origination.create_date"",property); + offset+=ReadBlob(image,sizeof(cin.origination.create_time),(unsigned char *) + cin.origination.create_time); + (void) CopyMagickString(property,cin.origination.create_time, + sizeof(cin.origination.create_time)); + (void) SetImageProperty(image,""dpx:origination.create_time"",property); + offset+=ReadBlob(image,sizeof(cin.origination.device),(unsigned char *) + cin.origination.device); + (void) CopyMagickString(property,cin.origination.device, + sizeof(cin.origination.device)); + (void) SetImageProperty(image,""dpx:origination.device"",property); + offset+=ReadBlob(image,sizeof(cin.origination.model),(unsigned char *) + cin.origination.model); + (void) CopyMagickString(property,cin.origination.model, + sizeof(cin.origination.model)); + (void) SetImageProperty(image,""dpx:origination.model"",property); + (void) ResetMagickMemory(cin.origination.serial,0, + sizeof(cin.origination.serial)); + offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *) + cin.origination.serial); + (void) CopyMagickString(property,cin.origination.serial, + sizeof(cin.origination.serial)); + (void) SetImageProperty(image,""dpx:origination.serial"",property); + cin.origination.x_pitch=ReadBlobFloat(image); + offset+=4; + cin.origination.y_pitch=ReadBlobFloat(image); + offset+=4; + cin.origination.gamma=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.origination.gamma) != MagickFalse) + image->gamma=cin.origination.gamma; + offset+=ReadBlob(image,sizeof(cin.origination.reserve),(unsigned char *) + cin.origination.reserve); + if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0)) + { + int + c; + + /* + Image film information. + */ + cin.film.id=ReadBlobByte(image); + offset++; + c=cin.film.id; + if (c != ~0) + (void) FormatImageProperty(image,""dpx:film.id"",""%d"",cin.film.id); + cin.film.type=ReadBlobByte(image); + offset++; + c=cin.film.type; + if (c != ~0) + (void) FormatImageProperty(image,""dpx:film.type"",""%d"",cin.film.type); + cin.film.offset=ReadBlobByte(image); + offset++; + c=cin.film.offset; + if (c != ~0) + (void) FormatImageProperty(image,""dpx:film.offset"",""%d"", + cin.film.offset); + cin.film.reserve1=ReadBlobByte(image); + offset++; + cin.film.prefix=ReadBlobLong(image); + offset+=4; + if (cin.film.prefix != ~0UL) + (void) FormatImageProperty(image,""dpx:film.prefix"",""%.20g"",(double) + cin.film.prefix); + cin.film.count=ReadBlobLong(image); + offset+=4; + offset+=ReadBlob(image,sizeof(cin.film.format),(unsigned char *) + cin.film.format); + (void) CopyMagickString(property,cin.film.format, + sizeof(cin.film.format)); + (void) SetImageProperty(image,""dpx:film.format"",property); + cin.film.frame_position=ReadBlobLong(image); + offset+=4; + if (cin.film.frame_position != ~0UL) + (void) FormatImageProperty(image,""dpx:film.frame_position"",""%.20g"", + (double) cin.film.frame_position); + cin.film.frame_rate=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.film.frame_rate) != MagickFalse) + (void) FormatImageProperty(image,""dpx:film.frame_rate"",""%g"", + cin.film.frame_rate); + offset+=ReadBlob(image,sizeof(cin.film.frame_id),(unsigned char *) + cin.film.frame_id); + (void) CopyMagickString(property,cin.film.frame_id, + sizeof(cin.film.frame_id)); + (void) SetImageProperty(image,""dpx:film.frame_id"",property); + offset+=ReadBlob(image,sizeof(cin.film.slate_info),(unsigned char *) + cin.film.slate_info); + (void) CopyMagickString(property,cin.film.slate_info, + sizeof(cin.film.slate_info)); + (void) SetImageProperty(image,""dpx:film.slate_info"",property); + offset+=ReadBlob(image,sizeof(cin.film.reserve),(unsigned char *) + cin.film.reserve); + } + if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0)) + { + StringInfo + *profile; + + /* + User defined data. + */ + profile=BlobToStringInfo((const void *) NULL,cin.file.user_length); + if (profile == (StringInfo *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + offset+=ReadBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) SetImageProfile(image,""dpx:user.data"",profile); + profile=DestroyStringInfo(profile); + } + for ( ; offset < (MagickOffsetType) cin.file.image_offset; offset++) + (void) ReadBlobByte(image); + image->depth=cin.image.channel[0].bits_per_pixel; + image->columns=cin.image.channel[0].pixels_per_line; + image->rows=cin.image.channel[0].lines_per_image; + if (image_info->ping) + { + (void) CloseBlob(image); + return(image); + } + /* + Convert CIN raster image to pixel packets. + */ + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + quantum_info->quantum=32; + quantum_info->pack=MagickFalse; + quantum_type=RGBQuantum; + pixels=GetQuantumPixels(quantum_info); + length=GetQuantumExtent(image,quantum_info,quantum_type); + length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue); + if (cin.image.number_channels == 1) + { + quantum_type=GrayQuantum; + length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue); + } + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + count=ReadBlob(image,length,pixels); + if ((size_t) count != length) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + SetQuantumImageType(image,quantum_type); + quantum_info=DestroyQuantumInfo(quantum_info); + if (EOFBlob(image) != MagickFalse) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + SetImageColorspace(image,LogColorspace); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define MonoColorType 1 +#define RGBColorType 3 + + char + property[MaxTextExtent]; + + CINInfo + cin; + + Image + *image; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + QuantumInfo + *quantum_info; + + QuantumType + quantum_type; + + register ssize_t + i; + + register PixelPacket + *q; + + size_t + length; + + ssize_t + count, + y; + + unsigned char + magick[4], + *pixels; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + File information. + */ + offset=0; + count=ReadBlob(image,4,magick); + offset+=count; + if ((count != 4) || + ((LocaleNCompare((char *) magick,""\200\052\137\327"",4) != 0))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + image->endian=(magick[0] == 0x80) && (magick[1] == 0x2a) && + (magick[2] == 0x5f) && (magick[3] == 0xd7) ? MSBEndian : LSBEndian; + cin.file.image_offset=ReadBlobLong(image); + offset+=4; + cin.file.generic_length=ReadBlobLong(image); + offset+=4; + cin.file.industry_length=ReadBlobLong(image); + offset+=4; + cin.file.user_length=ReadBlobLong(image); + offset+=4; + cin.file.file_size=ReadBlobLong(image); + offset+=4; + offset+=ReadBlob(image,sizeof(cin.file.version),(unsigned char *) + cin.file.version); + (void) CopyMagickString(property,cin.file.version,sizeof(cin.file.version)); + (void) SetImageProperty(image,""dpx:file.version"",property); + offset+=ReadBlob(image,sizeof(cin.file.filename),(unsigned char *) + cin.file.filename); + (void) CopyMagickString(property,cin.file.filename,sizeof(cin.file.filename)); + (void) SetImageProperty(image,""dpx:file.filename"",property); + offset+=ReadBlob(image,sizeof(cin.file.create_date),(unsigned char *) + cin.file.create_date); + (void) CopyMagickString(property,cin.file.create_date, + sizeof(cin.file.create_date)); + (void) SetImageProperty(image,""dpx:file.create_date"",property); + offset+=ReadBlob(image,sizeof(cin.file.create_time),(unsigned char *) + cin.file.create_time); + (void) CopyMagickString(property,cin.file.create_time, + sizeof(cin.file.create_time)); + (void) SetImageProperty(image,""dpx:file.create_time"",property); + offset+=ReadBlob(image,sizeof(cin.file.reserve),(unsigned char *) + cin.file.reserve); + /* + Image information. + */ + cin.image.orientation=(unsigned char) ReadBlobByte(image); + offset++; + if (cin.image.orientation != (unsigned char) (~0)) + (void) FormatImageProperty(image,""dpx:image.orientation"",""%d"", + cin.image.orientation); + switch (cin.image.orientation) + { + default: + case 0: image->orientation=TopLeftOrientation; break; + case 1: image->orientation=TopRightOrientation; break; + case 2: image->orientation=BottomLeftOrientation; break; + case 3: image->orientation=BottomRightOrientation; break; + case 4: image->orientation=LeftTopOrientation; break; + case 5: image->orientation=RightTopOrientation; break; + case 6: image->orientation=LeftBottomOrientation; break; + case 7: image->orientation=RightBottomOrientation; break; + } + cin.image.number_channels=(unsigned char) ReadBlobByte(image); + offset++; + offset+=ReadBlob(image,sizeof(cin.image.reserve1),(unsigned char *) + cin.image.reserve1); + for (i=0; i < 8; i++) + { + cin.image.channel[i].designator[0]=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].designator[1]=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].bits_per_pixel=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].reserve=(unsigned char) ReadBlobByte(image); + offset++; + cin.image.channel[i].pixels_per_line=ReadBlobLong(image); + offset+=4; + cin.image.channel[i].lines_per_image=ReadBlobLong(image); + offset+=4; + cin.image.channel[i].min_data=ReadBlobFloat(image); + offset+=4; + cin.image.channel[i].min_quantity=ReadBlobFloat(image); + offset+=4; + cin.image.channel[i].max_data=ReadBlobFloat(image); + offset+=4; + cin.image.channel[i].max_quantity=ReadBlobFloat(image); + offset+=4; + } + cin.image.white_point[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.white_point[0]) != MagickFalse) + image->chromaticity.white_point.x=cin.image.white_point[0]; + cin.image.white_point[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.white_point[1]) != MagickFalse) + image->chromaticity.white_point.y=cin.image.white_point[1]; + cin.image.red_primary_chromaticity[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.red_primary_chromaticity[0]) != MagickFalse) + image->chromaticity.red_primary.x=cin.image.red_primary_chromaticity[0]; + cin.image.red_primary_chromaticity[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.red_primary_chromaticity[1]) != MagickFalse) + image->chromaticity.red_primary.y=cin.image.red_primary_chromaticity[1]; + cin.image.green_primary_chromaticity[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.green_primary_chromaticity[0]) != MagickFalse) + image->chromaticity.red_primary.x=cin.image.green_primary_chromaticity[0]; + cin.image.green_primary_chromaticity[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.green_primary_chromaticity[1]) != MagickFalse) + image->chromaticity.green_primary.y=cin.image.green_primary_chromaticity[1]; + cin.image.blue_primary_chromaticity[0]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.blue_primary_chromaticity[0]) != MagickFalse) + image->chromaticity.blue_primary.x=cin.image.blue_primary_chromaticity[0]; + cin.image.blue_primary_chromaticity[1]=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.image.blue_primary_chromaticity[1]) != MagickFalse) + image->chromaticity.blue_primary.y=cin.image.blue_primary_chromaticity[1]; + offset+=ReadBlob(image,sizeof(cin.image.label),(unsigned char *) + cin.image.label); + (void) CopyMagickString(property,cin.image.label,sizeof(cin.image.label)); + (void) SetImageProperty(image,""dpx:image.label"",property); + offset+=ReadBlob(image,sizeof(cin.image.reserve),(unsigned char *) + cin.image.reserve); + /* + Image data format information. + */ + cin.data_format.interleave=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.packing=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.sign=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.sense=(unsigned char) ReadBlobByte(image); + offset++; + cin.data_format.line_pad=ReadBlobLong(image); + offset+=4; + cin.data_format.channel_pad=ReadBlobLong(image); + offset+=4; + offset+=ReadBlob(image,sizeof(cin.data_format.reserve),(unsigned char *) + cin.data_format.reserve); + /* + Image origination information. + */ + cin.origination.x_offset=(int) ReadBlobLong(image); + offset+=4; + if ((size_t) cin.origination.x_offset != ~0UL) + (void) FormatImageProperty(image,""dpx:origination.x_offset"",""%.20g"", + (double) cin.origination.x_offset); + cin.origination.y_offset=(ssize_t) ReadBlobLong(image); + offset+=4; + if ((size_t) cin.origination.y_offset != ~0UL) + (void) FormatImageProperty(image,""dpx:origination.y_offset"",""%.20g"", + (double) cin.origination.y_offset); + offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *) + cin.origination.filename); + (void) CopyMagickString(property,cin.origination.filename, + sizeof(cin.origination.filename)); + (void) SetImageProperty(image,""dpx:origination.filename"",property); + offset+=ReadBlob(image,sizeof(cin.origination.create_date),(unsigned char *) + cin.origination.create_date); + (void) CopyMagickString(property,cin.origination.create_date, + sizeof(cin.origination.create_date)); + (void) SetImageProperty(image,""dpx:origination.create_date"",property); + offset+=ReadBlob(image,sizeof(cin.origination.create_time),(unsigned char *) + cin.origination.create_time); + (void) CopyMagickString(property,cin.origination.create_time, + sizeof(cin.origination.create_time)); + (void) SetImageProperty(image,""dpx:origination.create_time"",property); + offset+=ReadBlob(image,sizeof(cin.origination.device),(unsigned char *) + cin.origination.device); + (void) CopyMagickString(property,cin.origination.device, + sizeof(cin.origination.device)); + (void) SetImageProperty(image,""dpx:origination.device"",property); + offset+=ReadBlob(image,sizeof(cin.origination.model),(unsigned char *) + cin.origination.model); + (void) CopyMagickString(property,cin.origination.model, + sizeof(cin.origination.model)); + (void) SetImageProperty(image,""dpx:origination.model"",property); + (void) ResetMagickMemory(cin.origination.serial,0, + sizeof(cin.origination.serial)); + offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *) + cin.origination.serial); + (void) CopyMagickString(property,cin.origination.serial, + sizeof(cin.origination.serial)); + (void) SetImageProperty(image,""dpx:origination.serial"",property); + cin.origination.x_pitch=ReadBlobFloat(image); + offset+=4; + cin.origination.y_pitch=ReadBlobFloat(image); + offset+=4; + cin.origination.gamma=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.origination.gamma) != MagickFalse) + image->gamma=cin.origination.gamma; + offset+=ReadBlob(image,sizeof(cin.origination.reserve),(unsigned char *) + cin.origination.reserve); + if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0)) + { + int + c; + + /* + Image film information. + */ + cin.film.id=ReadBlobByte(image); + offset++; + c=cin.film.id; + if (c != ~0) + (void) FormatImageProperty(image,""dpx:film.id"",""%d"",cin.film.id); + cin.film.type=ReadBlobByte(image); + offset++; + c=cin.film.type; + if (c != ~0) + (void) FormatImageProperty(image,""dpx:film.type"",""%d"",cin.film.type); + cin.film.offset=ReadBlobByte(image); + offset++; + c=cin.film.offset; + if (c != ~0) + (void) FormatImageProperty(image,""dpx:film.offset"",""%d"", + cin.film.offset); + cin.film.reserve1=ReadBlobByte(image); + offset++; + cin.film.prefix=ReadBlobLong(image); + offset+=4; + if (cin.film.prefix != ~0UL) + (void) FormatImageProperty(image,""dpx:film.prefix"",""%.20g"",(double) + cin.film.prefix); + cin.film.count=ReadBlobLong(image); + offset+=4; + offset+=ReadBlob(image,sizeof(cin.film.format),(unsigned char *) + cin.film.format); + (void) CopyMagickString(property,cin.film.format, + sizeof(cin.film.format)); + (void) SetImageProperty(image,""dpx:film.format"",property); + cin.film.frame_position=ReadBlobLong(image); + offset+=4; + if (cin.film.frame_position != ~0UL) + (void) FormatImageProperty(image,""dpx:film.frame_position"",""%.20g"", + (double) cin.film.frame_position); + cin.film.frame_rate=ReadBlobFloat(image); + offset+=4; + if (IsFloatDefined(cin.film.frame_rate) != MagickFalse) + (void) FormatImageProperty(image,""dpx:film.frame_rate"",""%g"", + cin.film.frame_rate); + offset+=ReadBlob(image,sizeof(cin.film.frame_id),(unsigned char *) + cin.film.frame_id); + (void) CopyMagickString(property,cin.film.frame_id, + sizeof(cin.film.frame_id)); + (void) SetImageProperty(image,""dpx:film.frame_id"",property); + offset+=ReadBlob(image,sizeof(cin.film.slate_info),(unsigned char *) + cin.film.slate_info); + (void) CopyMagickString(property,cin.film.slate_info, + sizeof(cin.film.slate_info)); + (void) SetImageProperty(image,""dpx:film.slate_info"",property); + offset+=ReadBlob(image,sizeof(cin.film.reserve),(unsigned char *) + cin.film.reserve); + } + if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0)) + { + StringInfo + *profile; + + /* + User defined data. + */ + profile=BlobToStringInfo((const void *) NULL,cin.file.user_length); + if (profile == (StringInfo *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + offset+=ReadBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) SetImageProfile(image,""dpx:user.data"",profile); + profile=DestroyStringInfo(profile); + } + for ( ; offset < (MagickOffsetType) cin.file.image_offset; offset++) + (void) ReadBlobByte(image); + image->depth=cin.image.channel[0].bits_per_pixel; + image->columns=cin.image.channel[0].pixels_per_line; + image->rows=cin.image.channel[0].lines_per_image; + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(image); + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + /* + Convert CIN raster image to pixel packets. + */ + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + quantum_info->quantum=32; + quantum_info->pack=MagickFalse; + quantum_type=RGBQuantum; + pixels=GetQuantumPixels(quantum_info); + length=GetQuantumExtent(image,quantum_info,quantum_type); + length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue); + if (cin.image.number_channels == 1) + { + quantum_type=GrayQuantum; + length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue); + } + for (y=0; y < (ssize_t) image->rows; y++) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + count=ReadBlob(image,length,pixels); + if ((size_t) count != length) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + SetQuantumImageType(image,quantum_type); + quantum_info=DestroyQuantumInfo(quantum_info); + if (EOFBlob(image) != MagickFalse) + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + SetImageColorspace(image,LogColorspace); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -721,11 +721,17 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception) + image->depth=cin.image.channel[0].bits_per_pixel; + image->columns=cin.image.channel[0].pixels_per_line; + image->rows=cin.image.channel[0].lines_per_image; +- if (image_info->ping) ++ if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(image); + } ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + /* + Convert CIN raster image to pixel packets. + */",3818,4054,4096 +18749,"static void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, + unsigned ExifLength, int NestingLevel) +{ + int de; + int a; + int NumDirEntries; + unsigned ThumbnailOffset = 0; + unsigned ThumbnailSize = 0; + char IndentString[25]; + + printf(""ProcessExifDir""); + if (NestingLevel > 4){ + ErrNonfatal(""Maximum directory nesting exceeded (corrupt exif header)"", 0,0); + return; + } + + memset(IndentString, ' ', 25); + IndentString[NestingLevel * 4] = '\0'; + + + NumDirEntries = Get16u(DirStart); + #define DIR_ENTRY_ADDR(Start, Entry) (Start+2+12*(Entry)) + + { + unsigned char * DirEnd; + DirEnd = DIR_ENTRY_ADDR(DirStart, NumDirEntries); + if (DirEnd+4 > (OffsetBase+ExifLength)){ + if (DirEnd+2 == OffsetBase+ExifLength || DirEnd == OffsetBase+ExifLength){ + }else{ + ErrNonfatal(""Illegally sized exif subdirectory (%d entries)"",NumDirEntries,0); + return; + } + } + if (DumpExifMap){ + printf(""Map: %05d-%05d: Directory\n"",(int)(DirStart-OffsetBase), (int)(DirEnd+4-OffsetBase)); + } + + + } + + if (ShowTags){ + printf(""(dir has %d entries)\n"",NumDirEntries); + } + + for (de=0;de= NUM_FORMATS) { + ErrNonfatal(""Illegal number format %d for tag %04x"", Format, Tag); + continue; + } + + if ((unsigned)Components > 0x10000){ + ErrNonfatal(""Illegal number of components %d for tag %04x"", Components, Tag); + continue; + } + + ByteCount = Components * BytesPerFormat[Format]; + + if (ByteCount > 4){ + + unsigned OffsetVal; + OffsetVal = Get32u(DirEntry+8); + if (OffsetVal+ByteCount > ExifLength){ + ErrNonfatal(""Illegal value pointer for tag %04x"", Tag,0); + continue; + } + ValuePtr = OffsetBase+OffsetVal; + + if (OffsetVal > ImageInfo.LargestExifOffset){ + ImageInfo.LargestExifOffset = OffsetVal; + } + + if (DumpExifMap){ + printf(""Map: %05d-%05d: Data for tag %04x\n"",OffsetVal, OffsetVal+ByteCount, Tag); + } + }else{ + ValuePtr = DirEntry+8; + } + + if (Tag == TAG_MAKER_NOTE){ + if (ShowTags){ + printf(""%s Maker note: "",IndentString); + } + ProcessMakerNote(ValuePtr, ByteCount, OffsetBase, ExifLength); + continue; + } + + if (ShowTags){ + for (a=0;;a++){ + if (a >= (int)TAG_TABLE_SIZE){ + printf(""%s"", IndentString); + printf("" Unknown Tag %04x Value = "", Tag); + break; + } + if (TagTable[a].Tag == Tag){ + printf(""%s"", IndentString); + printf("" %s = "",TagTable[a].Desc); + break; + } + } + + switch(Format){ + case FMT_BYTE: + if(ByteCount>1){ + printf(""%.*ls\n"", ByteCount/2, (wchar_t *)ValuePtr); + }else{ + PrintFormatNumber(ValuePtr, Format, ByteCount); + printf(""\n""); + } + break; + + case FMT_UNDEFINED: + + case FMT_STRING: + { + printf(""\""%s\"""", ValuePtr); + } + break; + + default: + PrintFormatNumber(ValuePtr, Format, ByteCount); + printf(""\n""); + } + } + + switch(Tag){ + + case TAG_MAKE: + strncpy(ImageInfo.CameraMake, (char *)ValuePtr, ByteCount < 31 ? ByteCount : 31); + break; + + case TAG_MODEL: + strncpy(ImageInfo.CameraModel, (char *)ValuePtr, ByteCount < 39 ? ByteCount : 39); + break; + + case TAG_SUBSEC_TIME: + strlcpy(ImageInfo.SubSecTime, (char *)ValuePtr, sizeof(ImageInfo.SubSecTime)); + break; + + case TAG_SUBSEC_TIME_ORIG: + strlcpy(ImageInfo.SubSecTimeOrig, (char *)ValuePtr, + sizeof(ImageInfo.SubSecTimeOrig)); + break; + + case TAG_SUBSEC_TIME_DIG: + strlcpy(ImageInfo.SubSecTimeDig, (char *)ValuePtr, + sizeof(ImageInfo.SubSecTimeDig)); + break; + + case TAG_DATETIME_DIGITIZED: + strlcpy(ImageInfo.DigitizedTime, (char *)ValuePtr, + sizeof(ImageInfo.DigitizedTime)); + + if (ImageInfo.numDateTimeTags >= MAX_DATE_COPIES){ + ErrNonfatal(""More than %d date fields! This is nuts"", MAX_DATE_COPIES, 0); + break; + } + ImageInfo.DateTimeOffsets[ImageInfo.numDateTimeTags++] = + (char *)ValuePtr - (char *)OffsetBase; + break; + + case TAG_DATETIME_ORIGINAL: + strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19); + + case TAG_DATETIME: + if (!isdigit(ImageInfo.DateTime[0])){ + strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19); + } + + if (ImageInfo.numDateTimeTags >= MAX_DATE_COPIES){ + ErrNonfatal(""More than %d date fields! This is nuts"", MAX_DATE_COPIES, 0); + break; + } + ImageInfo.DateTimeOffsets[ImageInfo.numDateTimeTags++] = + (char *)ValuePtr - (char *)OffsetBase; + break; + + case TAG_WINXP_COMMENT: + if (ImageInfo.Comments[0]){ // We already have a jpeg comment. + if (ShowTags) printf(""Windows XP commend and other comment in header\n""); + break; // Already have a windows comment, skip this one. + } + + if (ByteCount > 1){ + if (ByteCount > MAX_COMMENT_SIZE) ByteCount = MAX_COMMENT_SIZE; + memcpy(ImageInfo.Comments, ValuePtr, ByteCount); + ImageInfo.CommentWidchars = ByteCount/2; + } + break; + + case TAG_USERCOMMENT: + if (ImageInfo.Comments[0]){ // We already have a jpeg comment. + if (ShowTags) printf(""Multiple comments in exif header\n""); + break; // Already have a windows comment, skip this one. + } + + for (a=ByteCount;;){ + a--; + if ((ValuePtr)[a] == ' '){ + (ValuePtr)[a] = '\0'; + }else{ + break; + } + if (a == 0) break; + } + + { + int msiz = ExifLength - (ValuePtr-OffsetBase); + if (msiz > ByteCount) msiz = ByteCount; + if (msiz > MAX_COMMENT_SIZE - 1) msiz = MAX_COMMENT_SIZE - 1; + if (msiz > 5 && memcmp(ValuePtr, ""ASCII"", 5) == 0) { + for (a = 5; a < 10 && a < msiz; a++) { + int c = (ValuePtr)[a]; + if (c != '\0' && c != ' ') { + strncpy(ImageInfo.Comments, + (char *)ValuePtr + a, msiz - a); + break; + } + } + } else { + strncpy(ImageInfo.Comments, (char *)ValuePtr, msiz); + } + } + break; + + case TAG_FNUMBER: + ImageInfo.ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_APERTURE: + case TAG_MAXAPERTURE: + if (ImageInfo.ApertureFNumber == 0){ + ImageInfo.ApertureFNumber + = (float)exp(ConvertAnyFormat(ValuePtr, Format)*log(2)*0.5); + } + break; + + case TAG_FOCALLENGTH: + ImageInfo.FocalLength.num = Get32u(ValuePtr); + ImageInfo.FocalLength.denom = Get32u(4+(char *)ValuePtr); + break; + + case TAG_SUBJECT_DISTANCE: + ImageInfo.Distance = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_EXPOSURETIME: + ImageInfo.ExposureTime = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_SHUTTERSPEED: + if (ImageInfo.ExposureTime == 0){ + ImageInfo.ExposureTime + = (float)(1/exp(ConvertAnyFormat(ValuePtr, Format)*log(2))); + } + break; + + + case TAG_FLASH: + ImageInfo.FlashUsed=(int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_ORIENTATION: + if (NumOrientations >= 2){ + ErrNonfatal(""More than two orientation tags!"",0,0); + break; + } + OrientationPtr[NumOrientations] = ValuePtr; + OrientationNumFormat[NumOrientations] = Format; + if (NumOrientations == 0){ + ImageInfo.Orientation = (int)ConvertAnyFormat(ValuePtr, Format); + } + if (ImageInfo.Orientation < 0 || ImageInfo.Orientation > 8){ + ErrNonfatal(""Undefined rotation value %d"", ImageInfo.Orientation, 0); + ImageInfo.Orientation = 0; + } + NumOrientations += 1; + break; + + case TAG_EXIF_IMAGELENGTH: + case TAG_EXIF_IMAGEWIDTH: + a = (int)ConvertAnyFormat(ValuePtr, Format); + if (ExifImageWidth < a) ExifImageWidth = a; + break; + + case TAG_FOCAL_PLANE_XRES: + FocalplaneXRes = ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_FOCAL_PLANE_UNITS: + switch((int)ConvertAnyFormat(ValuePtr, Format)){ + case 1: FocalplaneUnits = 25.4; break; // inch + case 2: + FocalplaneUnits = 25.4; + break; + + case 3: FocalplaneUnits = 10; break; // centimeter + case 4: FocalplaneUnits = 1; break; // millimeter + case 5: FocalplaneUnits = .001; break; // micrometer + } + break; + + case TAG_EXPOSURE_BIAS: + ImageInfo.ExposureBias = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_WHITEBALANCE: + ImageInfo.Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_LIGHT_SOURCE: + ImageInfo.LightSource = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_METERING_MODE: + ImageInfo.MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_EXPOSURE_PROGRAM: + ImageInfo.ExposureProgram = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_EXPOSURE_INDEX: + if (ImageInfo.ISOequivalent == 0){ + ImageInfo.ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format); + } + break; + + case TAG_EXPOSURE_MODE: + ImageInfo.ExposureMode = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_ISO_EQUIVALENT: + ImageInfo.ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_DIGITALZOOMRATIO: + ImageInfo.DigitalZoomRatio = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_THUMBNAIL_OFFSET: + ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format); + DirWithThumbnailPtrs = DirStart; + break; + + case TAG_THUMBNAIL_LENGTH: + ThumbnailSize = (unsigned)ConvertAnyFormat(ValuePtr, Format); + ImageInfo.ThumbnailSizeOffset = ValuePtr-OffsetBase; + break; + + case TAG_EXIF_OFFSET: + if (ShowTags) printf(""%s Exif Dir:"",IndentString); + + case TAG_INTEROP_OFFSET: + if (Tag == TAG_INTEROP_OFFSET && ShowTags) printf(""%s Interop Dir:"",IndentString); + { + unsigned char * SubdirStart; + SubdirStart = OffsetBase + Get32u(ValuePtr); + if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){ + ErrNonfatal(""Illegal exif or interop ofset directory link"",0,0); + }else{ + ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1); + } + continue; + } + break; + + case TAG_GPSINFO: + if (ShowTags) printf(""%s GPS info dir:"",IndentString); + { + unsigned char * SubdirStart; + SubdirStart = OffsetBase + Get32u(ValuePtr); + if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){ + ErrNonfatal(""Illegal GPS directory link"",0,0); + }else{ + ProcessGpsInfo(SubdirStart, ByteCount, OffsetBase, ExifLength); + } + continue; + } + break; + + case TAG_FOCALLENGTH_35MM: + ImageInfo.FocalLength35mmEquiv = (unsigned)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_DISTANCE_RANGE: + ImageInfo.DistanceRange = (int)ConvertAnyFormat(ValuePtr, Format); + break; + } + } + + + { + unsigned char * SubdirStart; + unsigned Offset; + + if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){ + printf(""DirStart %p offset from dirstart %d"", DirStart, 2+12*NumDirEntries); + Offset = Get32u(DirStart+2+12*NumDirEntries); + if (Offset){ + SubdirStart = OffsetBase + Offset; + if (SubdirStart > OffsetBase+ExifLength || SubdirStart < OffsetBase){ + printf(""SubdirStart %p OffsetBase %p ExifLength %d Offset %d"", + SubdirStart, OffsetBase, ExifLength, Offset); + if (SubdirStart > OffsetBase && SubdirStart < OffsetBase+ExifLength+20){ + if (ShowTags) printf(""Thumbnail removed with Jhead 1.3 or earlier\n""); + }else{ + ErrNonfatal(""Illegal subdirectory link"",0,0); + } + }else{ + if (SubdirStart <= OffsetBase+ExifLength){ + if (ShowTags) printf(""%s Continued directory "",IndentString); + ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1); + } + } + if (Offset > ImageInfo.LargestExifOffset){ + ImageInfo.LargestExifOffset = Offset; + } + } + }else{ + } + } + + if (ThumbnailOffset){ + ImageInfo.ThumbnailAtEnd = FALSE; + + if (DumpExifMap){ + printf(""Map: %05d-%05d: Thumbnail\n"",ThumbnailOffset, ThumbnailOffset+ThumbnailSize); + } + + if (ThumbnailOffset <= ExifLength){ + if (ThumbnailSize > ExifLength-ThumbnailOffset){ + ThumbnailSize = ExifLength-ThumbnailOffset; + if (ShowTags) printf(""Thumbnail incorrectly placed in header\n""); + + } + ImageInfo.ThumbnailOffset = ThumbnailOffset; + ImageInfo.ThumbnailSize = ThumbnailSize; + + if (ShowTags){ + printf(""Thumbnail size: %d bytes\n"",ThumbnailSize); + } + } + } + printf(""returning from ProcessExifDir""); +} +",1,"static void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, + unsigned ExifLength, int NestingLevel) +{ + int de; + int a; + int NumDirEntries; + unsigned ThumbnailOffset = 0; + unsigned ThumbnailSize = 0; + char IndentString[25]; + + printf(""ProcessExifDir""); + if (NestingLevel > 4){ + ErrNonfatal(""Maximum directory nesting exceeded (corrupt exif header)"", 0,0); + return; + } + + memset(IndentString, ' ', 25); + IndentString[NestingLevel * 4] = '\0'; + + + NumDirEntries = Get16u(DirStart); + #define DIR_ENTRY_ADDR(Start, Entry) (Start+2+12*(Entry)) + + { + unsigned char * DirEnd; + DirEnd = DIR_ENTRY_ADDR(DirStart, NumDirEntries); + if (DirEnd+4 > (OffsetBase+ExifLength)){ + if (DirEnd+2 == OffsetBase+ExifLength || DirEnd == OffsetBase+ExifLength){ + }else{ + ErrNonfatal(""Illegally sized exif subdirectory (%d entries)"",NumDirEntries,0); + return; + } + } + if (DumpExifMap){ + printf(""Map: %05d-%05d: Directory\n"",(int)(DirStart-OffsetBase), (int)(DirEnd+4-OffsetBase)); + } + + + } + + if (ShowTags){ + printf(""(dir has %d entries)\n"",NumDirEntries); + } + + for (de=0;de= NUM_FORMATS) { + ErrNonfatal(""Illegal number format %d for tag %04x"", Format, Tag); + continue; + } + + if ((unsigned)Components > 0x10000){ + ErrNonfatal(""Illegal number of components %d for tag %04x"", Components, Tag); + continue; + } + + ByteCount = Components * BytesPerFormat[Format]; + + if (ByteCount > 4){ + + unsigned OffsetVal; + OffsetVal = Get32u(DirEntry+8); + if (OffsetVal > UINT32_MAX - ByteCount || OffsetVal+ByteCount > ExifLength){ + ErrNonfatal(""Illegal value pointer for tag %04x"", Tag,0); + continue; + } + ValuePtr = OffsetBase+OffsetVal; + + if (OffsetVal > ImageInfo.LargestExifOffset){ + ImageInfo.LargestExifOffset = OffsetVal; + } + + if (DumpExifMap){ + printf(""Map: %05d-%05d: Data for tag %04x\n"",OffsetVal, OffsetVal+ByteCount, Tag); + } + }else{ + ValuePtr = DirEntry+8; + } + + if (Tag == TAG_MAKER_NOTE){ + if (ShowTags){ + printf(""%s Maker note: "",IndentString); + } + ProcessMakerNote(ValuePtr, ByteCount, OffsetBase, ExifLength); + continue; + } + + if (ShowTags){ + for (a=0;;a++){ + if (a >= (int)TAG_TABLE_SIZE){ + printf(""%s"", IndentString); + printf("" Unknown Tag %04x Value = "", Tag); + break; + } + if (TagTable[a].Tag == Tag){ + printf(""%s"", IndentString); + printf("" %s = "",TagTable[a].Desc); + break; + } + } + + switch(Format){ + case FMT_BYTE: + if(ByteCount>1){ + printf(""%.*ls\n"", ByteCount/2, (wchar_t *)ValuePtr); + }else{ + PrintFormatNumber(ValuePtr, Format, ByteCount); + printf(""\n""); + } + break; + + case FMT_UNDEFINED: + + case FMT_STRING: + { + printf(""\""%s\"""", ValuePtr); + } + break; + + default: + PrintFormatNumber(ValuePtr, Format, ByteCount); + printf(""\n""); + } + } + + switch(Tag){ + + case TAG_MAKE: + strncpy(ImageInfo.CameraMake, (char *)ValuePtr, ByteCount < 31 ? ByteCount : 31); + break; + + case TAG_MODEL: + strncpy(ImageInfo.CameraModel, (char *)ValuePtr, ByteCount < 39 ? ByteCount : 39); + break; + + case TAG_SUBSEC_TIME: + strlcpy(ImageInfo.SubSecTime, (char *)ValuePtr, sizeof(ImageInfo.SubSecTime)); + break; + + case TAG_SUBSEC_TIME_ORIG: + strlcpy(ImageInfo.SubSecTimeOrig, (char *)ValuePtr, + sizeof(ImageInfo.SubSecTimeOrig)); + break; + + case TAG_SUBSEC_TIME_DIG: + strlcpy(ImageInfo.SubSecTimeDig, (char *)ValuePtr, + sizeof(ImageInfo.SubSecTimeDig)); + break; + + case TAG_DATETIME_DIGITIZED: + strlcpy(ImageInfo.DigitizedTime, (char *)ValuePtr, + sizeof(ImageInfo.DigitizedTime)); + + if (ImageInfo.numDateTimeTags >= MAX_DATE_COPIES){ + ErrNonfatal(""More than %d date fields! This is nuts"", MAX_DATE_COPIES, 0); + break; + } + ImageInfo.DateTimeOffsets[ImageInfo.numDateTimeTags++] = + (char *)ValuePtr - (char *)OffsetBase; + break; + + case TAG_DATETIME_ORIGINAL: + strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19); + + case TAG_DATETIME: + if (!isdigit(ImageInfo.DateTime[0])){ + strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19); + } + + if (ImageInfo.numDateTimeTags >= MAX_DATE_COPIES){ + ErrNonfatal(""More than %d date fields! This is nuts"", MAX_DATE_COPIES, 0); + break; + } + ImageInfo.DateTimeOffsets[ImageInfo.numDateTimeTags++] = + (char *)ValuePtr - (char *)OffsetBase; + break; + + case TAG_WINXP_COMMENT: + if (ImageInfo.Comments[0]){ // We already have a jpeg comment. + if (ShowTags) printf(""Windows XP commend and other comment in header\n""); + break; // Already have a windows comment, skip this one. + } + + if (ByteCount > 1){ + if (ByteCount > MAX_COMMENT_SIZE) ByteCount = MAX_COMMENT_SIZE; + memcpy(ImageInfo.Comments, ValuePtr, ByteCount); + ImageInfo.CommentWidchars = ByteCount/2; + } + break; + + case TAG_USERCOMMENT: + if (ImageInfo.Comments[0]){ // We already have a jpeg comment. + if (ShowTags) printf(""Multiple comments in exif header\n""); + break; // Already have a windows comment, skip this one. + } + + for (a=ByteCount;;){ + a--; + if ((ValuePtr)[a] == ' '){ + (ValuePtr)[a] = '\0'; + }else{ + break; + } + if (a == 0) break; + } + + { + int msiz = ExifLength - (ValuePtr-OffsetBase); + if (msiz > ByteCount) msiz = ByteCount; + if (msiz > MAX_COMMENT_SIZE - 1) msiz = MAX_COMMENT_SIZE - 1; + if (msiz > 5 && memcmp(ValuePtr, ""ASCII"", 5) == 0) { + for (a = 5; a < 10 && a < msiz; a++) { + int c = (ValuePtr)[a]; + if (c != '\0' && c != ' ') { + strncpy(ImageInfo.Comments, + (char *)ValuePtr + a, msiz - a); + break; + } + } + } else { + strncpy(ImageInfo.Comments, (char *)ValuePtr, msiz); + } + } + break; + + case TAG_FNUMBER: + ImageInfo.ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_APERTURE: + case TAG_MAXAPERTURE: + if (ImageInfo.ApertureFNumber == 0){ + ImageInfo.ApertureFNumber + = (float)exp(ConvertAnyFormat(ValuePtr, Format)*log(2)*0.5); + } + break; + + case TAG_FOCALLENGTH: + ImageInfo.FocalLength.num = Get32u(ValuePtr); + ImageInfo.FocalLength.denom = Get32u(4+(char *)ValuePtr); + break; + + case TAG_SUBJECT_DISTANCE: + ImageInfo.Distance = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_EXPOSURETIME: + ImageInfo.ExposureTime = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_SHUTTERSPEED: + if (ImageInfo.ExposureTime == 0){ + ImageInfo.ExposureTime + = (float)(1/exp(ConvertAnyFormat(ValuePtr, Format)*log(2))); + } + break; + + + case TAG_FLASH: + ImageInfo.FlashUsed=(int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_ORIENTATION: + if (NumOrientations >= 2){ + ErrNonfatal(""More than two orientation tags!"",0,0); + break; + } + OrientationPtr[NumOrientations] = ValuePtr; + OrientationNumFormat[NumOrientations] = Format; + if (NumOrientations == 0){ + ImageInfo.Orientation = (int)ConvertAnyFormat(ValuePtr, Format); + } + if (ImageInfo.Orientation < 0 || ImageInfo.Orientation > 8){ + ErrNonfatal(""Undefined rotation value %d"", ImageInfo.Orientation, 0); + ImageInfo.Orientation = 0; + } + NumOrientations += 1; + break; + + case TAG_EXIF_IMAGELENGTH: + case TAG_EXIF_IMAGEWIDTH: + a = (int)ConvertAnyFormat(ValuePtr, Format); + if (ExifImageWidth < a) ExifImageWidth = a; + break; + + case TAG_FOCAL_PLANE_XRES: + FocalplaneXRes = ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_FOCAL_PLANE_UNITS: + switch((int)ConvertAnyFormat(ValuePtr, Format)){ + case 1: FocalplaneUnits = 25.4; break; // inch + case 2: + FocalplaneUnits = 25.4; + break; + + case 3: FocalplaneUnits = 10; break; // centimeter + case 4: FocalplaneUnits = 1; break; // millimeter + case 5: FocalplaneUnits = .001; break; // micrometer + } + break; + + case TAG_EXPOSURE_BIAS: + ImageInfo.ExposureBias = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_WHITEBALANCE: + ImageInfo.Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_LIGHT_SOURCE: + ImageInfo.LightSource = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_METERING_MODE: + ImageInfo.MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_EXPOSURE_PROGRAM: + ImageInfo.ExposureProgram = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_EXPOSURE_INDEX: + if (ImageInfo.ISOequivalent == 0){ + ImageInfo.ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format); + } + break; + + case TAG_EXPOSURE_MODE: + ImageInfo.ExposureMode = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_ISO_EQUIVALENT: + ImageInfo.ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_DIGITALZOOMRATIO: + ImageInfo.DigitalZoomRatio = (float)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_THUMBNAIL_OFFSET: + ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format); + DirWithThumbnailPtrs = DirStart; + break; + + case TAG_THUMBNAIL_LENGTH: + ThumbnailSize = (unsigned)ConvertAnyFormat(ValuePtr, Format); + ImageInfo.ThumbnailSizeOffset = ValuePtr-OffsetBase; + break; + + case TAG_EXIF_OFFSET: + if (ShowTags) printf(""%s Exif Dir:"",IndentString); + + case TAG_INTEROP_OFFSET: + if (Tag == TAG_INTEROP_OFFSET && ShowTags) printf(""%s Interop Dir:"",IndentString); + { + unsigned char * SubdirStart; + SubdirStart = OffsetBase + Get32u(ValuePtr); + if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){ + ErrNonfatal(""Illegal exif or interop ofset directory link"",0,0); + }else{ + ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1); + } + continue; + } + break; + + case TAG_GPSINFO: + if (ShowTags) printf(""%s GPS info dir:"",IndentString); + { + unsigned char * SubdirStart; + SubdirStart = OffsetBase + Get32u(ValuePtr); + if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){ + ErrNonfatal(""Illegal GPS directory link"",0,0); + }else{ + ProcessGpsInfo(SubdirStart, ByteCount, OffsetBase, ExifLength); + } + continue; + } + break; + + case TAG_FOCALLENGTH_35MM: + ImageInfo.FocalLength35mmEquiv = (unsigned)ConvertAnyFormat(ValuePtr, Format); + break; + + case TAG_DISTANCE_RANGE: + ImageInfo.DistanceRange = (int)ConvertAnyFormat(ValuePtr, Format); + break; + } + } + + + { + unsigned char * SubdirStart; + unsigned Offset; + + if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){ + printf(""DirStart %p offset from dirstart %d"", DirStart, 2+12*NumDirEntries); + Offset = Get32u(DirStart+2+12*NumDirEntries); + if (Offset){ + SubdirStart = OffsetBase + Offset; + if (SubdirStart > OffsetBase+ExifLength || SubdirStart < OffsetBase){ + printf(""SubdirStart %p OffsetBase %p ExifLength %d Offset %d"", + SubdirStart, OffsetBase, ExifLength, Offset); + if (SubdirStart > OffsetBase && SubdirStart < OffsetBase+ExifLength+20){ + if (ShowTags) printf(""Thumbnail removed with Jhead 1.3 or earlier\n""); + }else{ + ErrNonfatal(""Illegal subdirectory link"",0,0); + } + }else{ + if (SubdirStart <= OffsetBase+ExifLength){ + if (ShowTags) printf(""%s Continued directory "",IndentString); + ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1); + } + } + if (Offset > ImageInfo.LargestExifOffset){ + ImageInfo.LargestExifOffset = Offset; + } + } + }else{ + } + } + + if (ThumbnailOffset){ + ImageInfo.ThumbnailAtEnd = FALSE; + + if (DumpExifMap){ + printf(""Map: %05d-%05d: Thumbnail\n"",ThumbnailOffset, ThumbnailOffset+ThumbnailSize); + } + + if (ThumbnailOffset <= ExifLength){ + if (ThumbnailSize > ExifLength-ThumbnailOffset){ + ThumbnailSize = ExifLength-ThumbnailOffset; + if (ShowTags) printf(""Thumbnail incorrectly placed in header\n""); + + } + ImageInfo.ThumbnailOffset = ThumbnailOffset; + ImageInfo.ThumbnailSize = ThumbnailSize; + + if (ShowTags){ + printf(""Thumbnail size: %d bytes\n"",ThumbnailSize); + } + } + } + printf(""returning from ProcessExifDir""); +} +","@@ -614,7 +614,7 @@ + + unsigned OffsetVal; + OffsetVal = Get32u(DirEntry+8); + // If its bigger than 4 bytes, the dir entry contains an offset. +- if (OffsetVal+ByteCount > ExifLength){ ++ if (OffsetVal > UINT32_MAX - ByteCount || OffsetVal+ByteCount > ExifLength){ + // Bogus pointer offset and / or bytecount value + ErrNonfatal(""Illegal value pointer for tag %04x"", Tag,0); + continue; +",3255,3491,4096 +17840,"ecc_decrypt_raw (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms) +{ + unsigned int nbits; + gpg_err_code_t rc; + struct pk_encoding_ctx ctx; + gcry_sexp_t l1 = NULL; + gcry_mpi_t data_e = NULL; + ECC_secret_key sk; + gcry_mpi_t mpi_g = NULL; + char *curvename = NULL; + mpi_ec_t ec = NULL; + mpi_point_struct kG; + mpi_point_struct R; + gcry_mpi_t r = NULL; + int flags = 0; + + memset (&sk, 0, sizeof sk); + point_init (&kG); + point_init (&R); + + _gcry_pk_util_init_encoding_ctx (&ctx, PUBKEY_OP_DECRYPT, + (nbits = ecc_get_nbits (keyparms))); + + /* Look for flags. */ + l1 = sexp_find_token (keyparms, ""flags"", 0); + if (l1) + { + rc = _gcry_pk_util_parse_flaglist (l1, &flags, NULL); + if (rc) + goto leave; + } + sexp_release (l1); + l1 = NULL; + + /* + * Extract the data. + */ + rc = _gcry_pk_util_preparse_encval (s_data, ecc_names, &l1, &ctx); + if (rc) + goto leave; + rc = sexp_extract_param (l1, NULL, ""e"", &data_e, NULL); + if (rc) + goto leave; + if (DBG_CIPHER) + log_printmpi (""ecc_decrypt d_e"", data_e); + if (mpi_is_opaque (data_e)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + } + + /* + * Extract the key. + */ + rc = sexp_extract_param (keyparms, NULL, ""-p?a?b?g?n?h?+d"", + &sk.E.p, &sk.E.a, &sk.E.b, &mpi_g, &sk.E.n, + &sk.E.h, &sk.d, NULL); + if (rc) + goto leave; + if (mpi_g) + { + point_init (&sk.E.G); + rc = _gcry_ecc_os2ec (&sk.E.G, mpi_g); + if (rc) + goto leave; + } + /* Add missing parameters using the optional curve parameter. */ + sexp_release (l1); + l1 = sexp_find_token (keyparms, ""curve"", 5); + if (l1) + { + curvename = sexp_nth_string (l1, 1); + if (curvename) + { + rc = _gcry_ecc_fill_in_curve (0, curvename, &sk.E, NULL); + if (rc) + goto leave; + } + } + /* Guess required fields if a curve parameter has not been given. */ + if (!curvename) + { + sk.E.model = MPI_EC_WEIERSTRASS; + sk.E.dialect = ECC_DIALECT_STANDARD; + if (!sk.E.h) + sk.E.h = mpi_const (MPI_C_ONE); + } + if (DBG_CIPHER) + { + log_debug (""ecc_decrypt info: %s/%s\n"", + _gcry_ecc_model2str (sk.E.model), + _gcry_ecc_dialect2str (sk.E.dialect)); + if (sk.E.name) + log_debug (""ecc_decrypt name: %s\n"", sk.E.name); + log_printmpi (""ecc_decrypt p"", sk.E.p); + log_printmpi (""ecc_decrypt a"", sk.E.a); + log_printmpi (""ecc_decrypt b"", sk.E.b); + log_printpnt (""ecc_decrypt g"", &sk.E.G, NULL); + log_printmpi (""ecc_decrypt n"", sk.E.n); + log_printmpi (""ecc_decrypt h"", sk.E.h); + if (!fips_mode ()) + log_printmpi (""ecc_decrypt d"", sk.d); + } + if (!sk.E.p || !sk.E.a || !sk.E.b || !sk.E.G.x || !sk.E.n || !sk.E.h || !sk.d) + { + rc = GPG_ERR_NO_OBJ; + goto leave; + } + + + ec = _gcry_mpi_ec_p_internal_new (sk.E.model, sk.E.dialect, flags, + sk.E.p, sk.E.a, sk.E.b); + + /* + * Compute the plaintext. + */ + if (ec->model == MPI_EC_MONTGOMERY) + rc = _gcry_ecc_mont_decodepoint (data_e, ec, &kG); + else + rc = _gcry_ecc_os2ec (&kG, data_e); + if (rc) + goto leave; + + if (DBG_CIPHER) + log_printpnt (""ecc_decrypt kG"", &kG, NULL); + + if (!(flags & PUBKEY_FLAG_DJB_TWEAK) + /* For X25519, by its definition, validation should not be done. */ + && !_gcry_mpi_ec_curve_point (&kG, ec)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + y = mpi_new (0); + + if (_gcry_mpi_ec_get_affine (x, y, &R, ec)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + /* + * Note for X25519. + * + * By the definition of X25519, this is the case where X25519 + * returns 0, mapping infinity to zero. However, we + * deliberately let it return an error. + * + * For X25519 ECDH, comming here means that it might be + * decrypted by anyone with the shared secret of 0 (the result + * of this function could be always 0 by other scalar values, + * other than the private key of SK.D). + * + * So, it looks like an encrypted message but it can be + * decrypted by anyone, or at least something wrong + * happens. Recipient should not proceed as if it were + * properly encrypted message. + * + * This handling is needed for our major usage of GnuPG, + * where it does the One-Pass Diffie-Hellman method, + * C(1, 1, ECC CDH), with an ephemeral key. + */ + } + + if (y) + r = _gcry_ecc_ec2os (x, y, sk.E.p); + else + { + unsigned char *rawmpi; + unsigned int rawmpilen; + + rawmpi = _gcry_mpi_get_buffer_extra (x, nbits/8, -1, + &rawmpilen, NULL); + if (!rawmpi) + { + rc = gpg_err_code_from_syserror (); + goto leave; + } + else + { + rawmpi[0] = 0x40; + rawmpilen++; + r = mpi_new (0); + mpi_set_opaque (r, rawmpi, rawmpilen*8); + } + } + if (!r) + rc = gpg_err_code_from_syserror (); + else + rc = 0; + mpi_free (x); + mpi_free (y); + } + if (DBG_CIPHER) + log_printmpi (""ecc_decrypt res"", r); + + if (!rc) + rc = sexp_build (r_plain, NULL, ""(value %m)"", r); + + leave: + point_free (&R); + point_free (&kG); + _gcry_mpi_release (r); + _gcry_mpi_release (sk.E.p); + _gcry_mpi_release (sk.E.a); + _gcry_mpi_release (sk.E.b); + _gcry_mpi_release (mpi_g); + point_free (&sk.E.G); + _gcry_mpi_release (sk.E.n); + _gcry_mpi_release (sk.E.h); + _gcry_mpi_release (sk.d); + _gcry_mpi_release (data_e); + xfree (curvename); + sexp_release (l1); + _gcry_mpi_ec_free (ec); + _gcry_pk_util_free_encoding_ctx (&ctx); + if (DBG_CIPHER) + log_debug (""ecc_decrypt => %s\n"", gpg_strerror (rc)); + return rc; +} +",1,"ecc_decrypt_raw (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms) +{ + unsigned int nbits; + gpg_err_code_t rc; + struct pk_encoding_ctx ctx; + gcry_sexp_t l1 = NULL; + gcry_mpi_t data_e = NULL; + ECC_secret_key sk; + gcry_mpi_t mpi_g = NULL; + char *curvename = NULL; + mpi_ec_t ec = NULL; + mpi_point_struct kG; + mpi_point_struct R; + gcry_mpi_t r = NULL; + int flags = 0; + + memset (&sk, 0, sizeof sk); + point_init (&kG); + point_init (&R); + + _gcry_pk_util_init_encoding_ctx (&ctx, PUBKEY_OP_DECRYPT, + (nbits = ecc_get_nbits (keyparms))); + + /* Look for flags. */ + l1 = sexp_find_token (keyparms, ""flags"", 0); + if (l1) + { + rc = _gcry_pk_util_parse_flaglist (l1, &flags, NULL); + if (rc) + goto leave; + } + sexp_release (l1); + l1 = NULL; + + /* + * Extract the data. + */ + rc = _gcry_pk_util_preparse_encval (s_data, ecc_names, &l1, &ctx); + if (rc) + goto leave; + rc = sexp_extract_param (l1, NULL, ""e"", &data_e, NULL); + if (rc) + goto leave; + if (DBG_CIPHER) + log_printmpi (""ecc_decrypt d_e"", data_e); + if (mpi_is_opaque (data_e)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + } + + /* + * Extract the key. + */ + rc = sexp_extract_param (keyparms, NULL, ""-p?a?b?g?n?h?+d"", + &sk.E.p, &sk.E.a, &sk.E.b, &mpi_g, &sk.E.n, + &sk.E.h, &sk.d, NULL); + if (rc) + goto leave; + if (mpi_g) + { + point_init (&sk.E.G); + rc = _gcry_ecc_os2ec (&sk.E.G, mpi_g); + if (rc) + goto leave; + } + /* Add missing parameters using the optional curve parameter. */ + sexp_release (l1); + l1 = sexp_find_token (keyparms, ""curve"", 5); + if (l1) + { + curvename = sexp_nth_string (l1, 1); + if (curvename) + { + rc = _gcry_ecc_fill_in_curve (0, curvename, &sk.E, NULL); + if (rc) + goto leave; + } + } + /* Guess required fields if a curve parameter has not been given. */ + if (!curvename) + { + sk.E.model = MPI_EC_WEIERSTRASS; + sk.E.dialect = ECC_DIALECT_STANDARD; + if (!sk.E.h) + sk.E.h = mpi_const (MPI_C_ONE); + } + if (DBG_CIPHER) + { + log_debug (""ecc_decrypt info: %s/%s\n"", + _gcry_ecc_model2str (sk.E.model), + _gcry_ecc_dialect2str (sk.E.dialect)); + if (sk.E.name) + log_debug (""ecc_decrypt name: %s\n"", sk.E.name); + log_printmpi (""ecc_decrypt p"", sk.E.p); + log_printmpi (""ecc_decrypt a"", sk.E.a); + log_printmpi (""ecc_decrypt b"", sk.E.b); + log_printpnt (""ecc_decrypt g"", &sk.E.G, NULL); + log_printmpi (""ecc_decrypt n"", sk.E.n); + log_printmpi (""ecc_decrypt h"", sk.E.h); + if (!fips_mode ()) + log_printmpi (""ecc_decrypt d"", sk.d); + } + if (!sk.E.p || !sk.E.a || !sk.E.b || !sk.E.G.x || !sk.E.n || !sk.E.h || !sk.d) + { + rc = GPG_ERR_NO_OBJ; + goto leave; + } + + + ec = _gcry_mpi_ec_p_internal_new (sk.E.model, sk.E.dialect, flags, + sk.E.p, sk.E.a, sk.E.b); + + /* + * Compute the plaintext. + */ + if (ec->model == MPI_EC_MONTGOMERY) + rc = _gcry_ecc_mont_decodepoint (data_e, ec, &kG); + else + rc = _gcry_ecc_os2ec (&kG, data_e); + if (rc) + goto leave; + + if (DBG_CIPHER) + log_printpnt (""ecc_decrypt kG"", &kG, NULL); + + if ((flags & PUBKEY_FLAG_DJB_TWEAK)) + { + /* For X25519, by its definition, validation should not be done. */ + /* (Instead, we do output check.) + * + * However, to mitigate secret key leak from our implementation, + * we also do input validation here. For constant-time + * implementation, we can remove this input validation. + */ + if (_gcry_mpi_ec_bad_point (&kG, ec)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + } + } + else if (!_gcry_mpi_ec_curve_point (&kG, ec)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + y = mpi_new (0); + + if (_gcry_mpi_ec_get_affine (x, y, &R, ec)) + { + rc = GPG_ERR_INV_DATA; + goto leave; + /* + * Note for X25519. + * + * By the definition of X25519, this is the case where X25519 + * returns 0, mapping infinity to zero. However, we + * deliberately let it return an error. + * + * For X25519 ECDH, comming here means that it might be + * decrypted by anyone with the shared secret of 0 (the result + * of this function could be always 0 by other scalar values, + * other than the private key of SK.D). + * + * So, it looks like an encrypted message but it can be + * decrypted by anyone, or at least something wrong + * happens. Recipient should not proceed as if it were + * properly encrypted message. + * + * This handling is needed for our major usage of GnuPG, + * where it does the One-Pass Diffie-Hellman method, + * C(1, 1, ECC CDH), with an ephemeral key. + */ + } + + if (y) + r = _gcry_ecc_ec2os (x, y, sk.E.p); + else + { + unsigned char *rawmpi; + unsigned int rawmpilen; + + rawmpi = _gcry_mpi_get_buffer_extra (x, nbits/8, -1, + &rawmpilen, NULL); + if (!rawmpi) + { + rc = gpg_err_code_from_syserror (); + goto leave; + } + else + { + rawmpi[0] = 0x40; + rawmpilen++; + r = mpi_new (0); + mpi_set_opaque (r, rawmpi, rawmpilen*8); + } + } + if (!r) + rc = gpg_err_code_from_syserror (); + else + rc = 0; + mpi_free (x); + mpi_free (y); + } + if (DBG_CIPHER) + log_printmpi (""ecc_decrypt res"", r); + + if (!rc) + rc = sexp_build (r_plain, NULL, ""(value %m)"", r); + + leave: + point_free (&R); + point_free (&kG); + _gcry_mpi_release (r); + _gcry_mpi_release (sk.E.p); + _gcry_mpi_release (sk.E.a); + _gcry_mpi_release (sk.E.b); + _gcry_mpi_release (mpi_g); + point_free (&sk.E.G); + _gcry_mpi_release (sk.E.n); + _gcry_mpi_release (sk.E.h); + _gcry_mpi_release (sk.d); + _gcry_mpi_release (data_e); + xfree (curvename); + sexp_release (l1); + _gcry_mpi_ec_free (ec); + _gcry_pk_util_free_encoding_ctx (&ctx); + if (DBG_CIPHER) + log_debug (""ecc_decrypt => %s\n"", gpg_strerror (rc)); + return rc; +} +","@@ -1628,9 +1628,22 @@ ecc_decrypt_raw (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms) + if (DBG_CIPHER) + log_printpnt (""ecc_decrypt kG"", &kG, NULL); + +- if (!(flags & PUBKEY_FLAG_DJB_TWEAK) ++ if ((flags & PUBKEY_FLAG_DJB_TWEAK)) ++ { + /* For X25519, by its definition, validation should not be done. */ +- && !_gcry_mpi_ec_curve_point (&kG, ec)) ++ /* (Instead, we do output check.) ++ * ++ * However, to mitigate secret key leak from our implementation, ++ * we also do input validation here. For constant-time ++ * implementation, we can remove this input validation. ++ */ ++ if (_gcry_mpi_ec_bad_point (&kG, ec)) ++ { ++ rc = GPG_ERR_INV_DATA; ++ goto leave; ++ } ++ } ++ else if (!_gcry_mpi_ec_curve_point (&kG, ec)) + { + rc = GPG_ERR_INV_DATA; + goto leave;",1841,2077,4096 +18862,"IMPEG2D_ERROR_CODES_T impeg2d_dec_p_b_slice(dec_state_t *ps_dec) +{ + WORD16 *pi2_vld_out; + UWORD32 i; + yuv_buf_t *ps_cur_frm_buf = &ps_dec->s_cur_frm_buf; + + UWORD32 u4_frm_offset = 0; + const dec_mb_params_t *ps_dec_mb_params; + IMPEG2D_ERROR_CODES_T e_error = (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE; + + pi2_vld_out = ps_dec->ai2_vld_buf; + memset(ps_dec->ai2_pred_mv,0,sizeof(ps_dec->ai2_pred_mv)); + + ps_dec->u2_prev_intra_mb = 0; + ps_dec->u2_first_mb = 1; + + ps_dec->u2_picture_width = ps_dec->u2_frame_width; + + if(ps_dec->u2_picture_structure != FRAME_PICTURE) + { + ps_dec->u2_picture_width <<= 1; + if(ps_dec->u2_picture_structure == BOTTOM_FIELD) + { + u4_frm_offset = ps_dec->u2_frame_width; + } + } + + + do + { + UWORD32 u4_x_offset, u4_y_offset; + + + UWORD32 u4_x_dst_offset = 0; + UWORD32 u4_y_dst_offset = 0; + UWORD8 *pu1_out_p; + UWORD8 *pu1_pred; + WORD32 u4_pred_strd; + + IMPEG2D_TRACE_MB_START(ps_dec->u2_mb_x, ps_dec->u2_mb_y); + + + + if(ps_dec->e_pic_type == B_PIC) + impeg2d_dec_pnb_mb_params(ps_dec); + else + impeg2d_dec_p_mb_params(ps_dec); + + IMPEG2D_TRACE_MB_START(ps_dec->u2_mb_x, ps_dec->u2_mb_y); + + u4_x_dst_offset = u4_frm_offset + (ps_dec->u2_mb_x << 4); + u4_y_dst_offset = (ps_dec->u2_mb_y << 4) * ps_dec->u2_picture_width; + pu1_out_p = ps_cur_frm_buf->pu1_y + u4_x_dst_offset + u4_y_dst_offset; + if(ps_dec->u2_prev_intra_mb == 0) + { + UWORD32 offset_x, offset_y, stride; + UWORD16 index = (ps_dec->u2_motion_type); + /*only for non intra mb's*/ + if(ps_dec->e_mb_pred == BIDIRECT) + { + ps_dec_mb_params = &ps_dec->ps_func_bi_direct[index]; + } + else + { + ps_dec_mb_params = &ps_dec->ps_func_forw_or_back[index]; + } + + stride = ps_dec->u2_picture_width; + + offset_x = u4_frm_offset + (ps_dec->u2_mb_x << 4); + + offset_y = (ps_dec->u2_mb_y << 4); + + ps_dec->s_dest_buf.pu1_y = ps_cur_frm_buf->pu1_y + offset_y * stride + offset_x; + + stride = stride >> 1; + + ps_dec->s_dest_buf.pu1_u = ps_cur_frm_buf->pu1_u + (offset_y >> 1) * stride + + (offset_x >> 1); + + ps_dec->s_dest_buf.pu1_v = ps_cur_frm_buf->pu1_v + (offset_y >> 1) * stride + + (offset_x >> 1); + + PROFILE_DISABLE_MC_IF0 + ps_dec_mb_params->pf_mc(ps_dec); + + } + for(i = 0; i < NUM_LUMA_BLKS; ++i) + { + if((ps_dec->u2_cbp & (1 << (BLOCKS_IN_MB - 1 - i))) != 0) + { + e_error = ps_dec->pf_vld_inv_quant(ps_dec, pi2_vld_out, ps_dec->pu1_inv_scan_matrix, + ps_dec->u2_prev_intra_mb, Y_LUMA, 0); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + u4_x_offset = gai2_impeg2_blk_x_off[i]; + + if(ps_dec->u2_field_dct == 0) + u4_y_offset = gai2_impeg2_blk_y_off_frm[i] ; + else + u4_y_offset = gai2_impeg2_blk_y_off_fld[i] ; + + + + + + IMPEG2D_IDCT_INP_STATISTICS(pi2_vld_out, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + PROFILE_DISABLE_IDCT_IF0 + { + WORD32 idx; + if(1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + idx = 0; + else + idx = 1; + + if(0 == ps_dec->u2_prev_intra_mb) + { + pu1_pred = pu1_out_p + u4_y_offset * ps_dec->u2_picture_width + u4_x_offset; + u4_pred_strd = ps_dec->u2_picture_width << ps_dec->u2_field_dct; + } + else + { + pu1_pred = (UWORD8 *)gau1_impeg2_zerobuf; + u4_pred_strd = 8; + } + + ps_dec->pf_idct_recon[idx * 2 + ps_dec->i4_last_value_one](pi2_vld_out, + ps_dec->ai2_idct_stg1, + pu1_pred, + pu1_out_p + u4_y_offset * ps_dec->u2_picture_width + u4_x_offset, + 8, + u4_pred_strd, + ps_dec->u2_picture_width << ps_dec->u2_field_dct, + ~ps_dec->u4_non_zero_cols, ~ps_dec->u4_non_zero_rows); + } + } + + } + + /* For U and V blocks, divide the x and y offsets by 2. */ + u4_x_dst_offset >>= 1; + u4_y_dst_offset >>= 2; + + + /* In case of chrominance blocks the DCT will be frame DCT */ + /* i = 0, U component and i = 1 is V componet */ + if((ps_dec->u2_cbp & 0x02) != 0) + { + pu1_out_p = ps_cur_frm_buf->pu1_u + u4_x_dst_offset + u4_y_dst_offset; + e_error = ps_dec->pf_vld_inv_quant(ps_dec, pi2_vld_out, ps_dec->pu1_inv_scan_matrix, + ps_dec->u2_prev_intra_mb, U_CHROMA, 0); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + + IMPEG2D_IDCT_INP_STATISTICS(pi2_vld_out, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + PROFILE_DISABLE_IDCT_IF0 + { + WORD32 idx; + if(1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + idx = 0; + else + idx = 1; + + if(0 == ps_dec->u2_prev_intra_mb) + { + pu1_pred = pu1_out_p; + u4_pred_strd = ps_dec->u2_picture_width >> 1; + } + else + { + pu1_pred = (UWORD8 *)gau1_impeg2_zerobuf; + u4_pred_strd = 8; + } + + ps_dec->pf_idct_recon[idx * 2 + ps_dec->i4_last_value_one](pi2_vld_out, + ps_dec->ai2_idct_stg1, + pu1_pred, + pu1_out_p, + 8, + u4_pred_strd, + ps_dec->u2_picture_width >> 1, + ~ps_dec->u4_non_zero_cols, ~ps_dec->u4_non_zero_rows); + + } + + } + + + if((ps_dec->u2_cbp & 0x01) != 0) + { + pu1_out_p = ps_cur_frm_buf->pu1_v + u4_x_dst_offset + u4_y_dst_offset; + e_error = ps_dec->pf_vld_inv_quant(ps_dec, pi2_vld_out, ps_dec->pu1_inv_scan_matrix, + ps_dec->u2_prev_intra_mb, V_CHROMA, 0); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + + IMPEG2D_IDCT_INP_STATISTICS(pi2_vld_out, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + PROFILE_DISABLE_IDCT_IF0 + { + WORD32 idx; + if(1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + idx = 0; + else + idx = 1; + if(0 == ps_dec->u2_prev_intra_mb) + { + pu1_pred = pu1_out_p; + u4_pred_strd = ps_dec->u2_picture_width >> 1; + } + else + { + pu1_pred = (UWORD8 *)gau1_impeg2_zerobuf; + u4_pred_strd = 8; + } + + ps_dec->pf_idct_recon[idx * 2 + ps_dec->i4_last_value_one](pi2_vld_out, + ps_dec->ai2_idct_stg1, + pu1_pred, + pu1_out_p, + 8, + u4_pred_strd, + ps_dec->u2_picture_width >> 1, + ~ps_dec->u4_non_zero_cols, ~ps_dec->u4_non_zero_rows); + + } + } + + + ps_dec->u2_num_mbs_left--; + ps_dec->u2_first_mb = 0; + ps_dec->u2_mb_x++; + + if(ps_dec->s_bit_stream.u4_offset > ps_dec->s_bit_stream.u4_max_offset) + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + else if (ps_dec->u2_mb_x == ps_dec->u2_num_horiz_mb) + { + ps_dec->u2_mb_x = 0; + ps_dec->u2_mb_y++; + + } + } + while(ps_dec->u2_num_mbs_left != 0 && impeg2d_bit_stream_nxt(&ps_dec->s_bit_stream,23) != 0x0); + return e_error; +} +",1,"IMPEG2D_ERROR_CODES_T impeg2d_dec_p_b_slice(dec_state_t *ps_dec) +{ + WORD16 *pi2_vld_out; + UWORD32 i; + yuv_buf_t *ps_cur_frm_buf = &ps_dec->s_cur_frm_buf; + + UWORD32 u4_frm_offset = 0; + const dec_mb_params_t *ps_dec_mb_params; + IMPEG2D_ERROR_CODES_T e_error = (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE; + + pi2_vld_out = ps_dec->ai2_vld_buf; + memset(ps_dec->ai2_pred_mv,0,sizeof(ps_dec->ai2_pred_mv)); + + ps_dec->u2_prev_intra_mb = 0; + ps_dec->u2_first_mb = 1; + + ps_dec->u2_picture_width = ps_dec->u2_frame_width; + + if(ps_dec->u2_picture_structure != FRAME_PICTURE) + { + ps_dec->u2_picture_width <<= 1; + if(ps_dec->u2_picture_structure == BOTTOM_FIELD) + { + u4_frm_offset = ps_dec->u2_frame_width; + } + } + + + do + { + UWORD32 u4_x_offset, u4_y_offset; + WORD32 ret; + + + UWORD32 u4_x_dst_offset = 0; + UWORD32 u4_y_dst_offset = 0; + UWORD8 *pu1_out_p; + UWORD8 *pu1_pred; + WORD32 u4_pred_strd; + + IMPEG2D_TRACE_MB_START(ps_dec->u2_mb_x, ps_dec->u2_mb_y); + + + + if(ps_dec->e_pic_type == B_PIC) + ret = impeg2d_dec_pnb_mb_params(ps_dec); + else + ret = impeg2d_dec_p_mb_params(ps_dec); + + if(ret) + return IMPEG2D_MB_TEX_DECODE_ERR; + IMPEG2D_TRACE_MB_START(ps_dec->u2_mb_x, ps_dec->u2_mb_y); + + u4_x_dst_offset = u4_frm_offset + (ps_dec->u2_mb_x << 4); + u4_y_dst_offset = (ps_dec->u2_mb_y << 4) * ps_dec->u2_picture_width; + pu1_out_p = ps_cur_frm_buf->pu1_y + u4_x_dst_offset + u4_y_dst_offset; + if(ps_dec->u2_prev_intra_mb == 0) + { + UWORD32 offset_x, offset_y, stride; + UWORD16 index = (ps_dec->u2_motion_type); + /*only for non intra mb's*/ + if(ps_dec->e_mb_pred == BIDIRECT) + { + ps_dec_mb_params = &ps_dec->ps_func_bi_direct[index]; + } + else + { + ps_dec_mb_params = &ps_dec->ps_func_forw_or_back[index]; + } + + stride = ps_dec->u2_picture_width; + + offset_x = u4_frm_offset + (ps_dec->u2_mb_x << 4); + + offset_y = (ps_dec->u2_mb_y << 4); + + ps_dec->s_dest_buf.pu1_y = ps_cur_frm_buf->pu1_y + offset_y * stride + offset_x; + + stride = stride >> 1; + + ps_dec->s_dest_buf.pu1_u = ps_cur_frm_buf->pu1_u + (offset_y >> 1) * stride + + (offset_x >> 1); + + ps_dec->s_dest_buf.pu1_v = ps_cur_frm_buf->pu1_v + (offset_y >> 1) * stride + + (offset_x >> 1); + + PROFILE_DISABLE_MC_IF0 + ps_dec_mb_params->pf_mc(ps_dec); + + } + for(i = 0; i < NUM_LUMA_BLKS; ++i) + { + if((ps_dec->u2_cbp & (1 << (BLOCKS_IN_MB - 1 - i))) != 0) + { + e_error = ps_dec->pf_vld_inv_quant(ps_dec, pi2_vld_out, ps_dec->pu1_inv_scan_matrix, + ps_dec->u2_prev_intra_mb, Y_LUMA, 0); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + u4_x_offset = gai2_impeg2_blk_x_off[i]; + + if(ps_dec->u2_field_dct == 0) + u4_y_offset = gai2_impeg2_blk_y_off_frm[i] ; + else + u4_y_offset = gai2_impeg2_blk_y_off_fld[i] ; + + + + + + IMPEG2D_IDCT_INP_STATISTICS(pi2_vld_out, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + PROFILE_DISABLE_IDCT_IF0 + { + WORD32 idx; + if(1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + idx = 0; + else + idx = 1; + + if(0 == ps_dec->u2_prev_intra_mb) + { + pu1_pred = pu1_out_p + u4_y_offset * ps_dec->u2_picture_width + u4_x_offset; + u4_pred_strd = ps_dec->u2_picture_width << ps_dec->u2_field_dct; + } + else + { + pu1_pred = (UWORD8 *)gau1_impeg2_zerobuf; + u4_pred_strd = 8; + } + + ps_dec->pf_idct_recon[idx * 2 + ps_dec->i4_last_value_one](pi2_vld_out, + ps_dec->ai2_idct_stg1, + pu1_pred, + pu1_out_p + u4_y_offset * ps_dec->u2_picture_width + u4_x_offset, + 8, + u4_pred_strd, + ps_dec->u2_picture_width << ps_dec->u2_field_dct, + ~ps_dec->u4_non_zero_cols, ~ps_dec->u4_non_zero_rows); + } + } + + } + + /* For U and V blocks, divide the x and y offsets by 2. */ + u4_x_dst_offset >>= 1; + u4_y_dst_offset >>= 2; + + + /* In case of chrominance blocks the DCT will be frame DCT */ + /* i = 0, U component and i = 1 is V componet */ + if((ps_dec->u2_cbp & 0x02) != 0) + { + pu1_out_p = ps_cur_frm_buf->pu1_u + u4_x_dst_offset + u4_y_dst_offset; + e_error = ps_dec->pf_vld_inv_quant(ps_dec, pi2_vld_out, ps_dec->pu1_inv_scan_matrix, + ps_dec->u2_prev_intra_mb, U_CHROMA, 0); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + + IMPEG2D_IDCT_INP_STATISTICS(pi2_vld_out, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + PROFILE_DISABLE_IDCT_IF0 + { + WORD32 idx; + if(1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + idx = 0; + else + idx = 1; + + if(0 == ps_dec->u2_prev_intra_mb) + { + pu1_pred = pu1_out_p; + u4_pred_strd = ps_dec->u2_picture_width >> 1; + } + else + { + pu1_pred = (UWORD8 *)gau1_impeg2_zerobuf; + u4_pred_strd = 8; + } + + ps_dec->pf_idct_recon[idx * 2 + ps_dec->i4_last_value_one](pi2_vld_out, + ps_dec->ai2_idct_stg1, + pu1_pred, + pu1_out_p, + 8, + u4_pred_strd, + ps_dec->u2_picture_width >> 1, + ~ps_dec->u4_non_zero_cols, ~ps_dec->u4_non_zero_rows); + + } + + } + + + if((ps_dec->u2_cbp & 0x01) != 0) + { + pu1_out_p = ps_cur_frm_buf->pu1_v + u4_x_dst_offset + u4_y_dst_offset; + e_error = ps_dec->pf_vld_inv_quant(ps_dec, pi2_vld_out, ps_dec->pu1_inv_scan_matrix, + ps_dec->u2_prev_intra_mb, V_CHROMA, 0); + if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error) + { + return e_error; + } + + + IMPEG2D_IDCT_INP_STATISTICS(pi2_vld_out, ps_dec->u4_non_zero_cols, ps_dec->u4_non_zero_rows); + + PROFILE_DISABLE_IDCT_IF0 + { + WORD32 idx; + if(1 == (ps_dec->u4_non_zero_cols | ps_dec->u4_non_zero_rows)) + idx = 0; + else + idx = 1; + if(0 == ps_dec->u2_prev_intra_mb) + { + pu1_pred = pu1_out_p; + u4_pred_strd = ps_dec->u2_picture_width >> 1; + } + else + { + pu1_pred = (UWORD8 *)gau1_impeg2_zerobuf; + u4_pred_strd = 8; + } + + ps_dec->pf_idct_recon[idx * 2 + ps_dec->i4_last_value_one](pi2_vld_out, + ps_dec->ai2_idct_stg1, + pu1_pred, + pu1_out_p, + 8, + u4_pred_strd, + ps_dec->u2_picture_width >> 1, + ~ps_dec->u4_non_zero_cols, ~ps_dec->u4_non_zero_rows); + + } + } + + + ps_dec->u2_num_mbs_left--; + ps_dec->u2_first_mb = 0; + ps_dec->u2_mb_x++; + + if(ps_dec->s_bit_stream.u4_offset > ps_dec->s_bit_stream.u4_max_offset) + { + return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR; + } + else if (ps_dec->u2_mb_x == ps_dec->u2_num_horiz_mb) + { + ps_dec->u2_mb_x = 0; + ps_dec->u2_mb_y++; + + } + } + while(ps_dec->u2_num_mbs_left != 0 && impeg2d_bit_stream_nxt(&ps_dec->s_bit_stream,23) != 0x0); + return e_error; +} +","@@ -60,7 +60,7 @@ + + * + * Values Returned : None + *******************************************************************************/ +-void impeg2d_dec_p_mb_params(dec_state_t *ps_dec) ++WORD32 impeg2d_dec_p_mb_params(dec_state_t *ps_dec) + { + stream_t *ps_stream = &ps_dec->s_bit_stream; + UWORD16 u2_mb_addr_incr; +@@ -180,6 +180,8 @@ + + ps_dec->e_mb_pred = (e_pred_direction_t)refPic; + ps_dec_mb_params = &ps_dec->ps_func_forw_or_back[index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; ++ if(NULL == ps_dec_mb_params->pf_func_mb_params) ++ return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + + } +@@ -223,6 +225,7 @@ + + ps_dec->u2_cbp = 0; + } + } ++ return 0; + } + + +@@ -237,7 +240,7 @@ + + * + * Values Returned : None + *******************************************************************************/ +-void impeg2d_dec_pnb_mb_params(dec_state_t *ps_dec) ++WORD32 impeg2d_dec_pnb_mb_params(dec_state_t *ps_dec) + { + stream_t *ps_stream = &ps_dec->s_bit_stream; + UWORD16 u2_mb_addr_incr; +@@ -373,6 +376,8 @@ + + ps_dec->e_mb_pred = BIDIRECT; + ps_dec_mb_params = &ps_dec->ps_func_bi_direct[u2_index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; ++ if(NULL == ps_dec_mb_params->pf_func_mb_params) ++ return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + } + else if(u2_mb_type & MB_FORW_OR_BACK) +@@ -384,6 +389,8 @@ + + ps_dec->e_mb_pred = (e_pred_direction_t)u2_refPic; + ps_dec_mb_params = &ps_dec->ps_func_forw_or_back[u2_index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; ++ if(NULL == ps_dec_mb_params->pf_func_mb_params) ++ return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + + } +@@ -427,6 +434,7 @@ + + ps_dec->u2_cbp = 0; + } + } ++ return 0; + } + + /******************************************************************************* +@@ -469,7 +477,7 @@ + + do + { + UWORD32 u4_x_offset, u4_y_offset; +- ++ WORD32 ret; + + + UWORD32 u4_x_dst_offset = 0; +@@ -482,10 +490,12 @@ + + + + if(ps_dec->e_pic_type == B_PIC) +- impeg2d_dec_pnb_mb_params(ps_dec); ++ ret = impeg2d_dec_pnb_mb_params(ps_dec); + else +- impeg2d_dec_p_mb_params(ps_dec); ++ ret = impeg2d_dec_p_mb_params(ps_dec); + ++ if(ret) ++ return IMPEG2D_MB_TEX_DECODE_ERR; + IMPEG2D_TRACE_MB_START(ps_dec->u2_mb_x, ps_dec->u2_mb_y); + + u4_x_dst_offset = u4_frm_offset + (ps_dec->u2_mb_x << 4); +",2281,2517,4096 +2211,"static unsigned long scan_swap_map(struct swap_info_struct *si, + unsigned char usage) +{ + unsigned long offset; + unsigned long scan_base; + unsigned long last_in_cluster = 0; + int latency_ration = LATENCY_LIMIT; + int found_free_cluster = 0; + + /* + * We try to cluster swap pages by allocating them sequentially + * in swap. Once we've allocated SWAPFILE_CLUSTER pages this + * way, however, we resort to first-free allocation, starting + * a new cluster. This prevents us from scattering swap pages + * all over the entire swap partition, so that we reduce + * overall disk seek times between swap pages. -- sct + * But we do now try to find an empty cluster. -Andrea + * And we let swap pages go all over an SSD partition. Hugh + */ + + si->flags += SWP_SCANNING; + scan_base = offset = si->cluster_next; + + if (unlikely(!si->cluster_nr--)) { + if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER) { + si->cluster_nr = SWAPFILE_CLUSTER - 1; + goto checks; + } + if (si->flags & SWP_DISCARDABLE) { + /* + * Start range check on racing allocations, in case + * they overlap the cluster we eventually decide on + * (we scan without swap_lock to allow preemption). + * It's hardly conceivable that cluster_nr could be + * wrapped during our scan, but don't depend on it. + */ + if (si->lowest_alloc) + goto checks; + si->lowest_alloc = si->max; + si->highest_alloc = 0; + } + spin_unlock(&swap_lock); + + /* + * If seek is expensive, start searching for new cluster from + * start of partition, to minimize the span of allocated swap. + * But if seek is cheap, search from our current position, so + * that swap is allocated from all over the partition: if the + * Flash Translation Layer only remaps within limited zones, + * we don't want to wear out the first zone too quickly. + */ + if (!(si->flags & SWP_SOLIDSTATE)) + scan_base = offset = si->lowest_bit; + last_in_cluster = offset + SWAPFILE_CLUSTER - 1; + + /* Locate the first empty (unaligned) cluster */ + for (; last_in_cluster <= si->highest_bit; offset++) { + if (si->swap_map[offset]) + last_in_cluster = offset + SWAPFILE_CLUSTER; + else if (offset == last_in_cluster) { + spin_lock(&swap_lock); + offset -= SWAPFILE_CLUSTER - 1; + si->cluster_next = offset; + si->cluster_nr = SWAPFILE_CLUSTER - 1; + found_free_cluster = 1; + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + + offset = si->lowest_bit; + last_in_cluster = offset + SWAPFILE_CLUSTER - 1; + + /* Locate the first empty (unaligned) cluster */ + for (; last_in_cluster < scan_base; offset++) { + if (si->swap_map[offset]) + last_in_cluster = offset + SWAPFILE_CLUSTER; + else if (offset == last_in_cluster) { + spin_lock(&swap_lock); + offset -= SWAPFILE_CLUSTER - 1; + si->cluster_next = offset; + si->cluster_nr = SWAPFILE_CLUSTER - 1; + found_free_cluster = 1; + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + + offset = scan_base; + spin_lock(&swap_lock); + si->cluster_nr = SWAPFILE_CLUSTER - 1; + si->lowest_alloc = 0; + } + +checks: + if (!(si->flags & SWP_WRITEOK)) + goto no_page; + if (!si->highest_bit) + goto no_page; + if (offset > si->highest_bit) + scan_base = offset = si->lowest_bit; + + /* reuse swap entry of cache-only swap if not busy. */ + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { + int swap_was_freed; + spin_unlock(&swap_lock); + swap_was_freed = __try_to_reclaim_swap(si, offset); + spin_lock(&swap_lock); + /* entry was freed successfully, try to use this again */ + if (swap_was_freed) + goto checks; + goto scan; /* check next one */ + } + + if (si->swap_map[offset]) + goto scan; + + if (offset == si->lowest_bit) + si->lowest_bit++; + if (offset == si->highest_bit) + si->highest_bit--; + si->inuse_pages++; + if (si->inuse_pages == si->pages) { + si->lowest_bit = si->max; + si->highest_bit = 0; + } + si->swap_map[offset] = usage; + si->cluster_next = offset + 1; + si->flags -= SWP_SCANNING; + + if (si->lowest_alloc) { + /* + * Only set when SWP_DISCARDABLE, and there's a scan + * for a free cluster in progress or just completed. + */ + if (found_free_cluster) { + /* + * To optimize wear-levelling, discard the + * old data of the cluster, taking care not to + * discard any of its pages that have already + * been allocated by racing tasks (offset has + * already stepped over any at the beginning). + */ + if (offset < si->highest_alloc && + si->lowest_alloc <= last_in_cluster) + last_in_cluster = si->lowest_alloc - 1; + si->flags |= SWP_DISCARDING; + spin_unlock(&swap_lock); + + if (offset < last_in_cluster) + discard_swap_cluster(si, offset, + last_in_cluster - offset + 1); + + spin_lock(&swap_lock); + si->lowest_alloc = 0; + si->flags &= ~SWP_DISCARDING; + + smp_mb(); /* wake_up_bit advises this */ + wake_up_bit(&si->flags, ilog2(SWP_DISCARDING)); + + } else if (si->flags & SWP_DISCARDING) { + /* + * Delay using pages allocated by racing tasks + * until the whole discard has been issued. We + * could defer that delay until swap_writepage, + * but it's easier to keep this self-contained. + */ + spin_unlock(&swap_lock); + wait_on_bit(&si->flags, ilog2(SWP_DISCARDING), + wait_for_discard, TASK_UNINTERRUPTIBLE); + spin_lock(&swap_lock); + } else { + /* + * Note pages allocated by racing tasks while + * scan for a free cluster is in progress, so + * that its final discard can exclude them. + */ + if (offset < si->lowest_alloc) + si->lowest_alloc = offset; + if (offset > si->highest_alloc) + si->highest_alloc = offset; + } + } + return offset; + +scan: + spin_unlock(&swap_lock); + while (++offset <= si->highest_bit) { + if (!si->swap_map[offset]) { + spin_lock(&swap_lock); + goto checks; + } + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { + spin_lock(&swap_lock); + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + offset = si->lowest_bit; + while (++offset < scan_base) { + if (!si->swap_map[offset]) { + spin_lock(&swap_lock); + goto checks; + } + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { + spin_lock(&swap_lock); + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + spin_lock(&swap_lock); + +no_page: + si->flags -= SWP_SCANNING; + return 0; +} +",0,"static unsigned long scan_swap_map(struct swap_info_struct *si, + unsigned char usage) +{ + unsigned long offset; + unsigned long scan_base; + unsigned long last_in_cluster = 0; + int latency_ration = LATENCY_LIMIT; + int found_free_cluster = 0; + + /* + * We try to cluster swap pages by allocating them sequentially + * in swap. Once we've allocated SWAPFILE_CLUSTER pages this + * way, however, we resort to first-free allocation, starting + * a new cluster. This prevents us from scattering swap pages + * all over the entire swap partition, so that we reduce + * overall disk seek times between swap pages. -- sct + * But we do now try to find an empty cluster. -Andrea + * And we let swap pages go all over an SSD partition. Hugh + */ + + si->flags += SWP_SCANNING; + scan_base = offset = si->cluster_next; + + if (unlikely(!si->cluster_nr--)) { + if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER) { + si->cluster_nr = SWAPFILE_CLUSTER - 1; + goto checks; + } + if (si->flags & SWP_DISCARDABLE) { + /* + * Start range check on racing allocations, in case + * they overlap the cluster we eventually decide on + * (we scan without swap_lock to allow preemption). + * It's hardly conceivable that cluster_nr could be + * wrapped during our scan, but don't depend on it. + */ + if (si->lowest_alloc) + goto checks; + si->lowest_alloc = si->max; + si->highest_alloc = 0; + } + spin_unlock(&swap_lock); + + /* + * If seek is expensive, start searching for new cluster from + * start of partition, to minimize the span of allocated swap. + * But if seek is cheap, search from our current position, so + * that swap is allocated from all over the partition: if the + * Flash Translation Layer only remaps within limited zones, + * we don't want to wear out the first zone too quickly. + */ + if (!(si->flags & SWP_SOLIDSTATE)) + scan_base = offset = si->lowest_bit; + last_in_cluster = offset + SWAPFILE_CLUSTER - 1; + + /* Locate the first empty (unaligned) cluster */ + for (; last_in_cluster <= si->highest_bit; offset++) { + if (si->swap_map[offset]) + last_in_cluster = offset + SWAPFILE_CLUSTER; + else if (offset == last_in_cluster) { + spin_lock(&swap_lock); + offset -= SWAPFILE_CLUSTER - 1; + si->cluster_next = offset; + si->cluster_nr = SWAPFILE_CLUSTER - 1; + found_free_cluster = 1; + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + + offset = si->lowest_bit; + last_in_cluster = offset + SWAPFILE_CLUSTER - 1; + + /* Locate the first empty (unaligned) cluster */ + for (; last_in_cluster < scan_base; offset++) { + if (si->swap_map[offset]) + last_in_cluster = offset + SWAPFILE_CLUSTER; + else if (offset == last_in_cluster) { + spin_lock(&swap_lock); + offset -= SWAPFILE_CLUSTER - 1; + si->cluster_next = offset; + si->cluster_nr = SWAPFILE_CLUSTER - 1; + found_free_cluster = 1; + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + + offset = scan_base; + spin_lock(&swap_lock); + si->cluster_nr = SWAPFILE_CLUSTER - 1; + si->lowest_alloc = 0; + } + +checks: + if (!(si->flags & SWP_WRITEOK)) + goto no_page; + if (!si->highest_bit) + goto no_page; + if (offset > si->highest_bit) + scan_base = offset = si->lowest_bit; + + /* reuse swap entry of cache-only swap if not busy. */ + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { + int swap_was_freed; + spin_unlock(&swap_lock); + swap_was_freed = __try_to_reclaim_swap(si, offset); + spin_lock(&swap_lock); + /* entry was freed successfully, try to use this again */ + if (swap_was_freed) + goto checks; + goto scan; /* check next one */ + } + + if (si->swap_map[offset]) + goto scan; + + if (offset == si->lowest_bit) + si->lowest_bit++; + if (offset == si->highest_bit) + si->highest_bit--; + si->inuse_pages++; + if (si->inuse_pages == si->pages) { + si->lowest_bit = si->max; + si->highest_bit = 0; + } + si->swap_map[offset] = usage; + si->cluster_next = offset + 1; + si->flags -= SWP_SCANNING; + + if (si->lowest_alloc) { + /* + * Only set when SWP_DISCARDABLE, and there's a scan + * for a free cluster in progress or just completed. + */ + if (found_free_cluster) { + /* + * To optimize wear-levelling, discard the + * old data of the cluster, taking care not to + * discard any of its pages that have already + * been allocated by racing tasks (offset has + * already stepped over any at the beginning). + */ + if (offset < si->highest_alloc && + si->lowest_alloc <= last_in_cluster) + last_in_cluster = si->lowest_alloc - 1; + si->flags |= SWP_DISCARDING; + spin_unlock(&swap_lock); + + if (offset < last_in_cluster) + discard_swap_cluster(si, offset, + last_in_cluster - offset + 1); + + spin_lock(&swap_lock); + si->lowest_alloc = 0; + si->flags &= ~SWP_DISCARDING; + + smp_mb(); /* wake_up_bit advises this */ + wake_up_bit(&si->flags, ilog2(SWP_DISCARDING)); + + } else if (si->flags & SWP_DISCARDING) { + /* + * Delay using pages allocated by racing tasks + * until the whole discard has been issued. We + * could defer that delay until swap_writepage, + * but it's easier to keep this self-contained. + */ + spin_unlock(&swap_lock); + wait_on_bit(&si->flags, ilog2(SWP_DISCARDING), + wait_for_discard, TASK_UNINTERRUPTIBLE); + spin_lock(&swap_lock); + } else { + /* + * Note pages allocated by racing tasks while + * scan for a free cluster is in progress, so + * that its final discard can exclude them. + */ + if (offset < si->lowest_alloc) + si->lowest_alloc = offset; + if (offset > si->highest_alloc) + si->highest_alloc = offset; + } + } + return offset; + +scan: + spin_unlock(&swap_lock); + while (++offset <= si->highest_bit) { + if (!si->swap_map[offset]) { + spin_lock(&swap_lock); + goto checks; + } + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { + spin_lock(&swap_lock); + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + offset = si->lowest_bit; + while (++offset < scan_base) { + if (!si->swap_map[offset]) { + spin_lock(&swap_lock); + goto checks; + } + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { + spin_lock(&swap_lock); + goto checks; + } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } + } + spin_lock(&swap_lock); + +no_page: + si->flags -= SWP_SCANNING; + return 0; +} +","@@ -932,9 +932,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud, + pmd = pmd_offset(pud, addr); + do { + next = pmd_addr_end(addr, end); +- if (unlikely(pmd_trans_huge(*pmd))) +- continue; +- if (pmd_none_or_clear_bad(pmd)) ++ if (pmd_none_or_trans_huge_or_clear_bad(pmd)) + continue; + ret = unuse_pte_range(vma, pmd, addr, next, entry, page); + if (ret)",1860,2096,4096 +5346,"static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh) +{ + struct net *net = sock_net(skb->sk); + const struct rtnl_link_ops *ops; + const struct rtnl_link_ops *m_ops = NULL; + struct net_device *dev; + struct net_device *master_dev = NULL; + struct ifinfomsg *ifm; + char kind[MODULE_NAME_LEN]; + char ifname[IFNAMSIZ]; + struct nlattr *tb[IFLA_MAX+1]; + struct nlattr *linkinfo[IFLA_INFO_MAX+1]; + unsigned char name_assign_type = NET_NAME_USER; + int err; + +#ifdef CONFIG_MODULES +replay: +#endif + err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); + if (err < 0) + return err; + + if (tb[IFLA_IFNAME]) + nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); + else + ifname[0] = '\0'; + + ifm = nlmsg_data(nlh); + if (ifm->ifi_index > 0) + dev = __dev_get_by_index(net, ifm->ifi_index); + else { + if (ifname[0]) + dev = __dev_get_by_name(net, ifname); + else + dev = NULL; + } + + if (dev) { + master_dev = netdev_master_upper_dev_get(dev); + if (master_dev) + m_ops = master_dev->rtnl_link_ops; + } + + err = validate_linkmsg(dev, tb); + if (err < 0) + return err; + + if (tb[IFLA_LINKINFO]) { + err = nla_parse_nested(linkinfo, IFLA_INFO_MAX, + tb[IFLA_LINKINFO], ifla_info_policy); + if (err < 0) + return err; + } else + memset(linkinfo, 0, sizeof(linkinfo)); + + if (linkinfo[IFLA_INFO_KIND]) { + nla_strlcpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind)); + ops = rtnl_link_ops_get(kind); + } else { + kind[0] = '\0'; + ops = NULL; + } + + if (1) { + struct nlattr *attr[ops ? ops->maxtype + 1 : 1]; + struct nlattr *slave_attr[m_ops ? m_ops->slave_maxtype + 1 : 1]; + struct nlattr **data = NULL; + struct nlattr **slave_data = NULL; + struct net *dest_net, *link_net = NULL; + + if (ops) { + if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) { + err = nla_parse_nested(attr, ops->maxtype, + linkinfo[IFLA_INFO_DATA], + ops->policy); + if (err < 0) + return err; + data = attr; + } + if (ops->validate) { + err = ops->validate(tb, data); + if (err < 0) + return err; + } + } + + if (m_ops) { + if (m_ops->slave_maxtype && + linkinfo[IFLA_INFO_SLAVE_DATA]) { + err = nla_parse_nested(slave_attr, + m_ops->slave_maxtype, + linkinfo[IFLA_INFO_SLAVE_DATA], + m_ops->slave_policy); + if (err < 0) + return err; + slave_data = slave_attr; + } + if (m_ops->slave_validate) { + err = m_ops->slave_validate(tb, slave_data); + if (err < 0) + return err; + } + } + + if (dev) { + int status = 0; + + if (nlh->nlmsg_flags & NLM_F_EXCL) + return -EEXIST; + if (nlh->nlmsg_flags & NLM_F_REPLACE) + return -EOPNOTSUPP; + + if (linkinfo[IFLA_INFO_DATA]) { + if (!ops || ops != dev->rtnl_link_ops || + !ops->changelink) + return -EOPNOTSUPP; + + err = ops->changelink(dev, tb, data); + if (err < 0) + return err; + status |= DO_SETLINK_NOTIFY; + } + + if (linkinfo[IFLA_INFO_SLAVE_DATA]) { + if (!m_ops || !m_ops->slave_changelink) + return -EOPNOTSUPP; + + err = m_ops->slave_changelink(master_dev, dev, + tb, slave_data); + if (err < 0) + return err; + status |= DO_SETLINK_NOTIFY; + } + + return do_setlink(skb, dev, ifm, tb, ifname, status); + } + + if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { + if (ifm->ifi_index == 0 && tb[IFLA_GROUP]) + return rtnl_group_changelink(skb, net, + nla_get_u32(tb[IFLA_GROUP]), + ifm, tb); + return -ENODEV; + } + + if (tb[IFLA_MAP] || tb[IFLA_MASTER] || tb[IFLA_PROTINFO]) + return -EOPNOTSUPP; + + if (!ops) { +#ifdef CONFIG_MODULES + if (kind[0]) { + __rtnl_unlock(); + request_module(""rtnl-link-%s"", kind); + rtnl_lock(); + ops = rtnl_link_ops_get(kind); + if (ops) + goto replay; + } +#endif + return -EOPNOTSUPP; + } + + if (!ops->setup) + return -EOPNOTSUPP; + + if (!ifname[0]) { + snprintf(ifname, IFNAMSIZ, ""%s%%d"", ops->kind); + name_assign_type = NET_NAME_ENUM; + } + + dest_net = rtnl_link_get_net(net, tb); + if (IS_ERR(dest_net)) + return PTR_ERR(dest_net); + + err = -EPERM; + if (!netlink_ns_capable(skb, dest_net->user_ns, CAP_NET_ADMIN)) + goto out; + + if (tb[IFLA_LINK_NETNSID]) { + int id = nla_get_s32(tb[IFLA_LINK_NETNSID]); + + link_net = get_net_ns_by_id(dest_net, id); + if (!link_net) { + err = -EINVAL; + goto out; + } + err = -EPERM; + if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) + goto out; + } + + dev = rtnl_create_link(link_net ? : dest_net, ifname, + name_assign_type, ops, tb); + if (IS_ERR(dev)) { + err = PTR_ERR(dev); + goto out; + } + + dev->ifindex = ifm->ifi_index; + + if (ops->newlink) { + err = ops->newlink(link_net ? : net, dev, tb, data); + /* Drivers should call free_netdev() in ->destructor + * and unregister it on failure after registration + * so that device could be finally freed in rtnl_unlock. + */ + if (err < 0) { + /* If device is not registered at all, free it now */ + if (dev->reg_state == NETREG_UNINITIALIZED) + free_netdev(dev); + goto out; + } + } else { + err = register_netdevice(dev); + if (err < 0) { + free_netdev(dev); + goto out; + } + } + err = rtnl_configure_link(dev, ifm); + if (err < 0) + goto out_unregister; + if (link_net) { + err = dev_change_net_namespace(dev, dest_net, ifname); + if (err < 0) + goto out_unregister; + } +out: + if (link_net) + put_net(link_net); + put_net(dest_net); + return err; +out_unregister: + if (ops->newlink) { + LIST_HEAD(list_kill); + + ops->dellink(dev, &list_kill); + unregister_netdevice_many(&list_kill); + } else { + unregister_netdevice(dev); + } + goto out; + } +} +",0,"static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh) +{ + struct net *net = sock_net(skb->sk); + const struct rtnl_link_ops *ops; + const struct rtnl_link_ops *m_ops = NULL; + struct net_device *dev; + struct net_device *master_dev = NULL; + struct ifinfomsg *ifm; + char kind[MODULE_NAME_LEN]; + char ifname[IFNAMSIZ]; + struct nlattr *tb[IFLA_MAX+1]; + struct nlattr *linkinfo[IFLA_INFO_MAX+1]; + unsigned char name_assign_type = NET_NAME_USER; + int err; + +#ifdef CONFIG_MODULES +replay: +#endif + err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); + if (err < 0) + return err; + + if (tb[IFLA_IFNAME]) + nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); + else + ifname[0] = '\0'; + + ifm = nlmsg_data(nlh); + if (ifm->ifi_index > 0) + dev = __dev_get_by_index(net, ifm->ifi_index); + else { + if (ifname[0]) + dev = __dev_get_by_name(net, ifname); + else + dev = NULL; + } + + if (dev) { + master_dev = netdev_master_upper_dev_get(dev); + if (master_dev) + m_ops = master_dev->rtnl_link_ops; + } + + err = validate_linkmsg(dev, tb); + if (err < 0) + return err; + + if (tb[IFLA_LINKINFO]) { + err = nla_parse_nested(linkinfo, IFLA_INFO_MAX, + tb[IFLA_LINKINFO], ifla_info_policy); + if (err < 0) + return err; + } else + memset(linkinfo, 0, sizeof(linkinfo)); + + if (linkinfo[IFLA_INFO_KIND]) { + nla_strlcpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind)); + ops = rtnl_link_ops_get(kind); + } else { + kind[0] = '\0'; + ops = NULL; + } + + if (1) { + struct nlattr *attr[ops ? ops->maxtype + 1 : 1]; + struct nlattr *slave_attr[m_ops ? m_ops->slave_maxtype + 1 : 1]; + struct nlattr **data = NULL; + struct nlattr **slave_data = NULL; + struct net *dest_net, *link_net = NULL; + + if (ops) { + if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) { + err = nla_parse_nested(attr, ops->maxtype, + linkinfo[IFLA_INFO_DATA], + ops->policy); + if (err < 0) + return err; + data = attr; + } + if (ops->validate) { + err = ops->validate(tb, data); + if (err < 0) + return err; + } + } + + if (m_ops) { + if (m_ops->slave_maxtype && + linkinfo[IFLA_INFO_SLAVE_DATA]) { + err = nla_parse_nested(slave_attr, + m_ops->slave_maxtype, + linkinfo[IFLA_INFO_SLAVE_DATA], + m_ops->slave_policy); + if (err < 0) + return err; + slave_data = slave_attr; + } + if (m_ops->slave_validate) { + err = m_ops->slave_validate(tb, slave_data); + if (err < 0) + return err; + } + } + + if (dev) { + int status = 0; + + if (nlh->nlmsg_flags & NLM_F_EXCL) + return -EEXIST; + if (nlh->nlmsg_flags & NLM_F_REPLACE) + return -EOPNOTSUPP; + + if (linkinfo[IFLA_INFO_DATA]) { + if (!ops || ops != dev->rtnl_link_ops || + !ops->changelink) + return -EOPNOTSUPP; + + err = ops->changelink(dev, tb, data); + if (err < 0) + return err; + status |= DO_SETLINK_NOTIFY; + } + + if (linkinfo[IFLA_INFO_SLAVE_DATA]) { + if (!m_ops || !m_ops->slave_changelink) + return -EOPNOTSUPP; + + err = m_ops->slave_changelink(master_dev, dev, + tb, slave_data); + if (err < 0) + return err; + status |= DO_SETLINK_NOTIFY; + } + + return do_setlink(skb, dev, ifm, tb, ifname, status); + } + + if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { + if (ifm->ifi_index == 0 && tb[IFLA_GROUP]) + return rtnl_group_changelink(skb, net, + nla_get_u32(tb[IFLA_GROUP]), + ifm, tb); + return -ENODEV; + } + + if (tb[IFLA_MAP] || tb[IFLA_MASTER] || tb[IFLA_PROTINFO]) + return -EOPNOTSUPP; + + if (!ops) { +#ifdef CONFIG_MODULES + if (kind[0]) { + __rtnl_unlock(); + request_module(""rtnl-link-%s"", kind); + rtnl_lock(); + ops = rtnl_link_ops_get(kind); + if (ops) + goto replay; + } +#endif + return -EOPNOTSUPP; + } + + if (!ops->setup) + return -EOPNOTSUPP; + + if (!ifname[0]) { + snprintf(ifname, IFNAMSIZ, ""%s%%d"", ops->kind); + name_assign_type = NET_NAME_ENUM; + } + + dest_net = rtnl_link_get_net(net, tb); + if (IS_ERR(dest_net)) + return PTR_ERR(dest_net); + + err = -EPERM; + if (!netlink_ns_capable(skb, dest_net->user_ns, CAP_NET_ADMIN)) + goto out; + + if (tb[IFLA_LINK_NETNSID]) { + int id = nla_get_s32(tb[IFLA_LINK_NETNSID]); + + link_net = get_net_ns_by_id(dest_net, id); + if (!link_net) { + err = -EINVAL; + goto out; + } + err = -EPERM; + if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) + goto out; + } + + dev = rtnl_create_link(link_net ? : dest_net, ifname, + name_assign_type, ops, tb); + if (IS_ERR(dev)) { + err = PTR_ERR(dev); + goto out; + } + + dev->ifindex = ifm->ifi_index; + + if (ops->newlink) { + err = ops->newlink(link_net ? : net, dev, tb, data); + /* Drivers should call free_netdev() in ->destructor + * and unregister it on failure after registration + * so that device could be finally freed in rtnl_unlock. + */ + if (err < 0) { + /* If device is not registered at all, free it now */ + if (dev->reg_state == NETREG_UNINITIALIZED) + free_netdev(dev); + goto out; + } + } else { + err = register_netdevice(dev); + if (err < 0) { + free_netdev(dev); + goto out; + } + } + err = rtnl_configure_link(dev, ifm); + if (err < 0) + goto out_unregister; + if (link_net) { + err = dev_change_net_namespace(dev, dest_net, ifname); + if (err < 0) + goto out_unregister; + } +out: + if (link_net) + put_net(link_net); + put_net(dest_net); + return err; +out_unregister: + if (ops->newlink) { + LIST_HEAD(list_kill); + + ops->dellink(dev, &list_kill); + unregister_netdevice_many(&list_kill); + } else { + unregister_netdevice(dev); + } + goto out; + } +} +","@@ -1180,14 +1180,16 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, + + static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev) + { +- struct rtnl_link_ifmap map = { +- .mem_start = dev->mem_start, +- .mem_end = dev->mem_end, +- .base_addr = dev->base_addr, +- .irq = dev->irq, +- .dma = dev->dma, +- .port = dev->if_port, +- }; ++ struct rtnl_link_ifmap map; ++ ++ memset(&map, 0, sizeof(map)); ++ map.mem_start = dev->mem_start; ++ map.mem_end = dev->mem_end; ++ map.base_addr = dev->base_addr; ++ map.irq = dev->irq; ++ map.dma = dev->dma; ++ map.port = dev->if_port; ++ + if (nla_put(skb, IFLA_MAP, sizeof(map), &map)) + return -EMSGSIZE; + ",1816,2052,4096 +873,"static void ssh_detect_bugs(Ssh ssh, char *vstring) +{ + char *imp; /* pointer to implementation part */ + imp = vstring; + imp += strcspn(imp, ""-""); + if (*imp) imp++; + imp += strcspn(imp, ""-""); + if (*imp) imp++; + + ssh->remote_bugs = 0; + + /* + * General notes on server version strings: + * - Not all servers reporting ""Cisco-1.25"" have all the bugs listed + * here -- in particular, we've heard of one that's perfectly happy + * with SSH1_MSG_IGNOREs -- but this string never seems to change, + * so we can't distinguish them. + */ + if (conf_get_int(ssh->conf, CONF_sshbug_ignore1) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_ignore1) == AUTO && + (!strcmp(imp, ""1.2.18"") || !strcmp(imp, ""1.2.19"") || + !strcmp(imp, ""1.2.20"") || !strcmp(imp, ""1.2.21"") || + !strcmp(imp, ""1.2.22"") || !strcmp(imp, ""Cisco-1.25"") || + !strcmp(imp, ""OSU_1.4alpha3"") || !strcmp(imp, ""OSU_1.5alpha4"")))) { + /* + * These versions don't support SSH1_MSG_IGNORE, so we have + * to use a different defence against password length + * sniffing. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_SSH1_IGNORE; + logevent(""We believe remote version has SSH-1 ignore bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_plainpw1) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_plainpw1) == AUTO && + (!strcmp(imp, ""Cisco-1.25"") || !strcmp(imp, ""OSU_1.4alpha3"")))) { + /* + * These versions need a plain password sent; they can't + * handle having a null and a random length of data after + * the password. + */ + ssh->remote_bugs |= BUG_NEEDS_SSH1_PLAIN_PASSWORD; + logevent(""We believe remote version needs a plain SSH-1 password""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_rsa1) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_rsa1) == AUTO && + (!strcmp(imp, ""Cisco-1.25"")))) { + /* + * These versions apparently have no clue whatever about + * RSA authentication and will panic and die if they see + * an AUTH_RSA message. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_RSA; + logevent(""We believe remote version can't handle SSH-1 RSA authentication""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_hmac2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_hmac2) == AUTO && + !wc_match(""* VShell"", imp) && + (wc_match(""2.1.0*"", imp) || wc_match(""2.0.*"", imp) || + wc_match(""2.2.0*"", imp) || wc_match(""2.3.0*"", imp) || + wc_match(""2.1 *"", imp)))) { + /* + * These versions have the HMAC bug. + */ + ssh->remote_bugs |= BUG_SSH2_HMAC; + logevent(""We believe remote version has SSH-2 HMAC bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_derivekey2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_derivekey2) == AUTO && + !wc_match(""* VShell"", imp) && + (wc_match(""2.0.0*"", imp) || wc_match(""2.0.10*"", imp) ))) { + /* + * These versions have the key-derivation bug (failing to + * include the literal shared secret in the hashes that + * generate the keys). + */ + ssh->remote_bugs |= BUG_SSH2_DERIVEKEY; + logevent(""We believe remote version has SSH-2 key-derivation bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_rsapad2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_rsapad2) == AUTO && + (wc_match(""OpenSSH_2.[5-9]*"", imp) || + wc_match(""OpenSSH_3.[0-2]*"", imp) || + wc_match(""mod_sftp/0.[0-8]*"", imp) || + wc_match(""mod_sftp/0.9.[0-8]"", imp)))) { + /* + * These versions have the SSH-2 RSA padding bug. + */ + ssh->remote_bugs |= BUG_SSH2_RSA_PADDING; + logevent(""We believe remote version has SSH-2 RSA padding bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_pksessid2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_pksessid2) == AUTO && + wc_match(""OpenSSH_2.[0-2]*"", imp))) { + /* + * These versions have the SSH-2 session-ID bug in + * public-key authentication. + */ + ssh->remote_bugs |= BUG_SSH2_PK_SESSIONID; + logevent(""We believe remote version has SSH-2 public-key-session-ID bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_rekey2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_rekey2) == AUTO && + (wc_match(""DigiSSH_2.0"", imp) || + wc_match(""OpenSSH_2.[0-4]*"", imp) || + wc_match(""OpenSSH_2.5.[0-3]*"", imp) || + wc_match(""Sun_SSH_1.0"", imp) || + wc_match(""Sun_SSH_1.0.1"", imp) || + /* All versions <= 1.2.6 (they changed their format in 1.2.7) */ + wc_match(""WeOnlyDo-*"", imp)))) { + /* + * These versions have the SSH-2 rekey bug. + */ + ssh->remote_bugs |= BUG_SSH2_REKEY; + logevent(""We believe remote version has SSH-2 rekey bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_maxpkt2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_maxpkt2) == AUTO && + (wc_match(""1.36_sshlib GlobalSCAPE"", imp) || + wc_match(""1.36 sshlib: GlobalScape"", imp)))) { + /* + * This version ignores our makpkt and needs to be throttled. + */ + ssh->remote_bugs |= BUG_SSH2_MAXPKT; + logevent(""We believe remote version ignores SSH-2 maximum packet size""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_ignore2) == FORCE_ON) { + /* + * Servers that don't support SSH2_MSG_IGNORE. Currently, + * none detected automatically. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_SSH2_IGNORE; + logevent(""We believe remote version has SSH-2 ignore bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_oldgex2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_oldgex2) == AUTO && + (wc_match(""OpenSSH_2.[235]*"", imp)))) { + /* + * These versions only support the original (pre-RFC4419) + * SSH-2 GEX request, and disconnect with a protocol error if + * we use the newer version. + */ + ssh->remote_bugs |= BUG_SSH2_OLDGEX; + logevent(""We believe remote version has outdated SSH-2 GEX""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_winadj) == FORCE_ON) { + /* + * Servers that don't support our winadj request for one + * reason or another. Currently, none detected automatically. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_WINADJ; + logevent(""We believe remote version has winadj bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_chanreq) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_chanreq) == AUTO && + (wc_match(""OpenSSH_[2-5].*"", imp) || + wc_match(""OpenSSH_6.[0-6]*"", imp) || + wc_match(""dropbear_0.[2-4][0-9]*"", imp) || + wc_match(""dropbear_0.5[01]*"", imp)))) { + /* + * These versions have the SSH-2 channel request bug. + * OpenSSH 6.7 and above do not: + * https://bugzilla.mindrot.org/show_bug.cgi?id=1818 + * dropbear_0.52 and above do not: + * https://secure.ucc.asn.au/hg/dropbear/rev/cd02449b709c + */ + ssh->remote_bugs |= BUG_SENDS_LATE_REQUEST_REPLY; + logevent(""We believe remote version has SSH-2 channel request bug""); + } +} +",0,"static void ssh_detect_bugs(Ssh ssh, char *vstring) +{ + char *imp; /* pointer to implementation part */ + imp = vstring; + imp += strcspn(imp, ""-""); + if (*imp) imp++; + imp += strcspn(imp, ""-""); + if (*imp) imp++; + + ssh->remote_bugs = 0; + + /* + * General notes on server version strings: + * - Not all servers reporting ""Cisco-1.25"" have all the bugs listed + * here -- in particular, we've heard of one that's perfectly happy + * with SSH1_MSG_IGNOREs -- but this string never seems to change, + * so we can't distinguish them. + */ + if (conf_get_int(ssh->conf, CONF_sshbug_ignore1) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_ignore1) == AUTO && + (!strcmp(imp, ""1.2.18"") || !strcmp(imp, ""1.2.19"") || + !strcmp(imp, ""1.2.20"") || !strcmp(imp, ""1.2.21"") || + !strcmp(imp, ""1.2.22"") || !strcmp(imp, ""Cisco-1.25"") || + !strcmp(imp, ""OSU_1.4alpha3"") || !strcmp(imp, ""OSU_1.5alpha4"")))) { + /* + * These versions don't support SSH1_MSG_IGNORE, so we have + * to use a different defence against password length + * sniffing. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_SSH1_IGNORE; + logevent(""We believe remote version has SSH-1 ignore bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_plainpw1) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_plainpw1) == AUTO && + (!strcmp(imp, ""Cisco-1.25"") || !strcmp(imp, ""OSU_1.4alpha3"")))) { + /* + * These versions need a plain password sent; they can't + * handle having a null and a random length of data after + * the password. + */ + ssh->remote_bugs |= BUG_NEEDS_SSH1_PLAIN_PASSWORD; + logevent(""We believe remote version needs a plain SSH-1 password""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_rsa1) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_rsa1) == AUTO && + (!strcmp(imp, ""Cisco-1.25"")))) { + /* + * These versions apparently have no clue whatever about + * RSA authentication and will panic and die if they see + * an AUTH_RSA message. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_RSA; + logevent(""We believe remote version can't handle SSH-1 RSA authentication""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_hmac2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_hmac2) == AUTO && + !wc_match(""* VShell"", imp) && + (wc_match(""2.1.0*"", imp) || wc_match(""2.0.*"", imp) || + wc_match(""2.2.0*"", imp) || wc_match(""2.3.0*"", imp) || + wc_match(""2.1 *"", imp)))) { + /* + * These versions have the HMAC bug. + */ + ssh->remote_bugs |= BUG_SSH2_HMAC; + logevent(""We believe remote version has SSH-2 HMAC bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_derivekey2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_derivekey2) == AUTO && + !wc_match(""* VShell"", imp) && + (wc_match(""2.0.0*"", imp) || wc_match(""2.0.10*"", imp) ))) { + /* + * These versions have the key-derivation bug (failing to + * include the literal shared secret in the hashes that + * generate the keys). + */ + ssh->remote_bugs |= BUG_SSH2_DERIVEKEY; + logevent(""We believe remote version has SSH-2 key-derivation bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_rsapad2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_rsapad2) == AUTO && + (wc_match(""OpenSSH_2.[5-9]*"", imp) || + wc_match(""OpenSSH_3.[0-2]*"", imp) || + wc_match(""mod_sftp/0.[0-8]*"", imp) || + wc_match(""mod_sftp/0.9.[0-8]"", imp)))) { + /* + * These versions have the SSH-2 RSA padding bug. + */ + ssh->remote_bugs |= BUG_SSH2_RSA_PADDING; + logevent(""We believe remote version has SSH-2 RSA padding bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_pksessid2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_pksessid2) == AUTO && + wc_match(""OpenSSH_2.[0-2]*"", imp))) { + /* + * These versions have the SSH-2 session-ID bug in + * public-key authentication. + */ + ssh->remote_bugs |= BUG_SSH2_PK_SESSIONID; + logevent(""We believe remote version has SSH-2 public-key-session-ID bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_rekey2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_rekey2) == AUTO && + (wc_match(""DigiSSH_2.0"", imp) || + wc_match(""OpenSSH_2.[0-4]*"", imp) || + wc_match(""OpenSSH_2.5.[0-3]*"", imp) || + wc_match(""Sun_SSH_1.0"", imp) || + wc_match(""Sun_SSH_1.0.1"", imp) || + /* All versions <= 1.2.6 (they changed their format in 1.2.7) */ + wc_match(""WeOnlyDo-*"", imp)))) { + /* + * These versions have the SSH-2 rekey bug. + */ + ssh->remote_bugs |= BUG_SSH2_REKEY; + logevent(""We believe remote version has SSH-2 rekey bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_maxpkt2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_maxpkt2) == AUTO && + (wc_match(""1.36_sshlib GlobalSCAPE"", imp) || + wc_match(""1.36 sshlib: GlobalScape"", imp)))) { + /* + * This version ignores our makpkt and needs to be throttled. + */ + ssh->remote_bugs |= BUG_SSH2_MAXPKT; + logevent(""We believe remote version ignores SSH-2 maximum packet size""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_ignore2) == FORCE_ON) { + /* + * Servers that don't support SSH2_MSG_IGNORE. Currently, + * none detected automatically. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_SSH2_IGNORE; + logevent(""We believe remote version has SSH-2 ignore bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_oldgex2) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_oldgex2) == AUTO && + (wc_match(""OpenSSH_2.[235]*"", imp)))) { + /* + * These versions only support the original (pre-RFC4419) + * SSH-2 GEX request, and disconnect with a protocol error if + * we use the newer version. + */ + ssh->remote_bugs |= BUG_SSH2_OLDGEX; + logevent(""We believe remote version has outdated SSH-2 GEX""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_winadj) == FORCE_ON) { + /* + * Servers that don't support our winadj request for one + * reason or another. Currently, none detected automatically. + */ + ssh->remote_bugs |= BUG_CHOKES_ON_WINADJ; + logevent(""We believe remote version has winadj bug""); + } + + if (conf_get_int(ssh->conf, CONF_sshbug_chanreq) == FORCE_ON || + (conf_get_int(ssh->conf, CONF_sshbug_chanreq) == AUTO && + (wc_match(""OpenSSH_[2-5].*"", imp) || + wc_match(""OpenSSH_6.[0-6]*"", imp) || + wc_match(""dropbear_0.[2-4][0-9]*"", imp) || + wc_match(""dropbear_0.5[01]*"", imp)))) { + /* + * These versions have the SSH-2 channel request bug. + * OpenSSH 6.7 and above do not: + * https://bugzilla.mindrot.org/show_bug.cgi?id=1818 + * dropbear_0.52 and above do not: + * https://secure.ucc.asn.au/hg/dropbear/rev/cd02449b709c + */ + ssh->remote_bugs |= BUG_SENDS_LATE_REQUEST_REPLY; + logevent(""We believe remote version has SSH-2 channel request bug""); + } +} +","@@ -573,10 +573,7 @@ struct ssh_channel { + } v; + union { + struct ssh_agent_channel { +- unsigned char *message; +- unsigned char msglen[4]; +- unsigned lensofar, totallen; +- int outstanding_requests; ++ bufchain inbuffer; + agent_pending_query *pending; + } a; + struct ssh_x11_channel { +@@ -3780,6 +3777,8 @@ static void ssh_throttle_conn(Ssh ssh, int adjust) + } + } + ++static void ssh_agentf_try_forward(struct ssh_channel *c); ++ + /* + * Throttle or unthrottle _all_ local data streams (for when sends + * on the SSH connection itself back up). +@@ -3806,7 +3805,12 @@ static void ssh_throttle_all(Ssh ssh, int enable, int bufsize) + x11_override_throttle(c->u.x11.xconn, enable); + break; + case CHAN_AGENT: +- /* Agent channels require no buffer management. */ ++ /* Agent forwarding channels are buffer-managed by ++ * checking ssh->throttled_all in ssh_agentf_try_forward. ++ * So at the moment we _un_throttle again, we must make an ++ * attempt to do something. */ ++ if (!enable) ++ ssh_agentf_try_forward(c); + break; + case CHAN_SOCKDATA: + pfd_override_throttle(c->u.pfd.pf, enable); +@@ -3848,29 +3852,113 @@ static void ssh_dialog_callback(void *sshv, int ret) + ssh_process_queued_incoming_data(ssh); + } + +-static void ssh_agentf_callback(void *cv, void *reply, int replylen) ++static void ssh_agentf_got_response(struct ssh_channel *c, ++ void *reply, int replylen) + { +- struct ssh_channel *c = (struct ssh_channel *)cv; +- const void *sentreply = reply; +- + c->u.a.pending = NULL; +- c->u.a.outstanding_requests--; +- if (!sentreply) { +- /* Fake SSH_AGENT_FAILURE. */ +- sentreply = ""\0\0\0\1\5""; ++ ++ if (!reply) { ++ /* The real agent didn't send any kind of reply at all for ++ * some reason, so fake an SSH_AGENT_FAILURE. */ ++ reply = ""\0\0\0\1\5""; + replylen = 5; + } +- ssh_send_channel_data(c, sentreply, replylen); +- if (reply) +- sfree(reply); ++ ++ ssh_send_channel_data(c, reply, replylen); ++} ++ ++static void ssh_agentf_callback(void *cv, void *reply, int replylen); ++ ++static void ssh_agentf_try_forward(struct ssh_channel *c) ++{ ++ unsigned datalen, lengthfield, messagelen; ++ unsigned char *message; ++ unsigned char msglen[4]; ++ void *reply; ++ int replylen; ++ + /* +- * If we've already seen an incoming EOF but haven't sent an +- * outgoing one, this may be the moment to send it. ++ * Don't try to parallelise agent requests. Wait for each one to ++ * return before attempting the next. + */ +- if (c->u.a.outstanding_requests == 0 && (c->closes & CLOSES_RCVD_EOF)) ++ if (c->u.a.pending) ++ return; ++ ++ /* ++ * If the outgoing side of the channel connection is currently ++ * throttled (for any reason, either that channel's window size or ++ * the entire SSH connection being throttled), don't submit any ++ * new forwarded requests to the real agent. This causes the input ++ * side of the agent forwarding not to be emptied, exerting the ++ * required back-pressure on the remote client, and encouraging it ++ * to read our responses before sending too many more requests. ++ */ ++ if (c->ssh->throttled_all || ++ (c->ssh->version == 2 && c->v.v2.remwindow == 0)) ++ return; ++ ++ while (1) { ++ /* ++ * Try to extract a complete message from the input buffer. ++ */ ++ datalen = bufchain_size(&c->u.a.inbuffer); ++ if (datalen < 4) ++ break; /* not even a length field available yet */ ++ ++ bufchain_fetch(&c->u.a.inbuffer, msglen, 4); ++ lengthfield = GET_32BIT(msglen); ++ if (lengthfield > datalen - 4) ++ break; /* a whole message is not yet available */ ++ ++ messagelen = lengthfield + 4; ++ ++ message = snewn(messagelen, unsigned char); ++ bufchain_fetch(&c->u.a.inbuffer, message, messagelen); ++ bufchain_consume(&c->u.a.inbuffer, messagelen); ++ c->u.a.pending = agent_query( ++ message, messagelen, &reply, &replylen, ssh_agentf_callback, c); ++ sfree(message); ++ ++ if (c->u.a.pending) ++ return; /* agent_query promised to reply in due course */ ++ ++ /* ++ * If the agent gave us an answer immediately, pass it ++ * straight on and go round this loop again. ++ */ ++ ssh_agentf_got_response(c, reply, replylen); ++ } ++ ++ /* ++ * If we get here (i.e. we left the above while loop via 'break' ++ * rather than 'return'), that means we've determined that the ++ * input buffer for the agent forwarding connection doesn't ++ * contain a complete request. ++ * ++ * So if there's potentially more data to come, we can return now, ++ * and wait for the remote client to send it. But if the remote ++ * has sent EOF, it would be a mistake to do that, because we'd be ++ * waiting a long time. So this is the moment to check for EOF, ++ * and respond appropriately. ++ */ ++ if (c->closes & CLOSES_RCVD_EOF) + sshfwd_write_eof(c); + } + ++static void ssh_agentf_callback(void *cv, void *reply, int replylen) ++{ ++ struct ssh_channel *c = (struct ssh_channel *)cv; ++ ++ ssh_agentf_got_response(c, reply, replylen); ++ sfree(reply); ++ ++ /* ++ * Now try to extract and send further messages from the channel's ++ * input-side buffer. ++ */ ++ ssh_agentf_try_forward(c); ++} ++ + /* + * Client-initiated disconnection. Send a DISCONNECT if `wire_reason' + * non-NULL, otherwise just close the connection. `client_reason' == NULL +@@ -5553,10 +5641,8 @@ static void ssh1_smsg_agent_open(Ssh ssh, struct Packet *pktin) + c->remoteid = remoteid; + c->halfopen = FALSE; + c->type = CHAN_AGENT; /* identify channel type */ +- c->u.a.lensofar = 0; +- c->u.a.message = NULL; + c->u.a.pending = NULL; +- c->u.a.outstanding_requests = 0; ++ bufchain_init(&c->u.a.inbuffer); + send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION, + PKT_INT, c->remoteid, PKT_INT, c->localid, + PKT_END); +@@ -5697,42 +5783,18 @@ static void ssh1_msg_channel_close(Ssh ssh, struct Packet *pktin) + static int ssh_agent_channel_data(struct ssh_channel *c, char *data, + int length) + { +- while (length > 0) { +- if (c->u.a.lensofar < 4) { +- unsigned int l = min(4 - c->u.a.lensofar, (unsigned)length); +- memcpy(c->u.a.msglen + c->u.a.lensofar, data, l); +- data += l; +- length -= l; +- c->u.a.lensofar += l; +- } +- if (c->u.a.lensofar == 4) { +- c->u.a.totallen = 4 + GET_32BIT(c->u.a.msglen); +- c->u.a.message = snewn(c->u.a.totallen, unsigned char); +- memcpy(c->u.a.message, c->u.a.msglen, 4); +- } +- if (c->u.a.lensofar >= 4 && length > 0) { +- unsigned int l = min(c->u.a.totallen - c->u.a.lensofar, +- (unsigned)length); +- memcpy(c->u.a.message + c->u.a.lensofar, data, l); +- data += l; +- length -= l; +- c->u.a.lensofar += l; +- } +- if (c->u.a.lensofar == c->u.a.totallen) { +- void *reply; +- int replylen; +- c->u.a.outstanding_requests++; +- c->u.a.pending = agent_query( +- c->u.a.message, c->u.a.totallen, &reply, &replylen, +- ssh_agentf_callback, c); +- if (!c->u.a.pending) +- ssh_agentf_callback(c, reply, replylen); +- sfree(c->u.a.message); +- c->u.a.message = NULL; +- c->u.a.lensofar = 0; +- } +- } +- return 0; /* agent channels never back up */ ++ bufchain_add(&c->u.a.inbuffer, data, length); ++ ssh_agentf_try_forward(c); ++ ++ /* ++ * We exert back-pressure on an agent forwarding client if and ++ * only if we're waiting for the response to an asynchronous agent ++ * request. This prevents the client running out of window while ++ * receiving the _first_ message, but means that if any message ++ * takes time to process, the client will be discouraged from ++ * sending an endless stream of further ones after it. ++ */ ++ return (c->u.a.pending ? bufchain_size(&c->u.a.inbuffer) : 0); + } + + static int ssh_channel_data(struct ssh_channel *c, int is_stderr, +@@ -7733,8 +7795,9 @@ static void ssh2_try_send_and_unthrottle(Ssh ssh, struct ssh_channel *c) + x11_unthrottle(c->u.x11.xconn); + break; + case CHAN_AGENT: +- /* agent sockets are request/response and need no +- * buffer management */ ++ /* Now that we've successfully sent all the outgoing ++ * replies we had, try to process more incoming data. */ ++ ssh_agentf_try_forward(c); + break; + case CHAN_SOCKDATA: + pfd_unthrottle(c->u.pfd.pf); +@@ -8160,7 +8223,8 @@ static void ssh_channel_close_local(struct ssh_channel *c, char const *reason) + case CHAN_AGENT: + if (c->u.a.pending) + agent_cancel_query(c->u.a.pending); +- sfree(c->u.a.message); ++ bufchain_clear(&c->u.a.inbuffer); ++ msg = ""Agent-forwarding connection closed""; + break; + case CHAN_SOCKDATA: + assert(c->u.pfd.pf != NULL); +@@ -8248,10 +8312,10 @@ static void ssh_channel_got_eof(struct ssh_channel *c) + assert(c->u.x11.xconn != NULL); + x11_send_eof(c->u.x11.xconn); + } else if (c->type == CHAN_AGENT) { +- if (c->u.a.outstanding_requests == 0) { +- /* Manufacture an outgoing EOF in response to the incoming one. */ +- sshfwd_write_eof(c); +- } ++ /* Just call try_forward, which will respond to the EOF now if ++ * appropriate, or wait until the queue of outstanding ++ * requests is dealt with if not */ ++ ssh_agentf_try_forward(c); + } else if (c->type == CHAN_SOCKDATA) { + assert(c->u.pfd.pf != NULL); + pfd_send_eof(c->u.pfd.pf); +@@ -8805,10 +8869,8 @@ static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin) + error = ""Agent forwarding is not enabled""; + else { + c->type = CHAN_AGENT; /* identify channel type */ +- c->u.a.lensofar = 0; +- c->u.a.message = NULL; ++ bufchain_init(&c->u.a.inbuffer); + c->u.a.pending = NULL; +- c->u.a.outstanding_requests = 0; + } + } else { + error = ""Unsupported channel type requested"";",2155,2391,4096 +430,"void DCTStream::transformDataUnit(Gushort *quantTable, + int dataIn[64], Guchar dataOut[64]) { + int v0, v1, v2, v3, v4, v5, v6, v7, t; + int *p; + int i; + + for (i = 0; i < 64; ++i) { + dataIn[i] *= quantTable[i]; + } + + for (i = 0; i < 64; i += 8) { + p = dataIn + i; + + if (p[1] == 0 && p[2] == 0 && p[3] == 0 && + p[4] == 0 && p[5] == 0 && p[6] == 0 && p[7] == 0) { + t = (dctSqrt2 * p[0] + 512) >> 10; + p[0] = t; + p[1] = t; + p[2] = t; + p[3] = t; + p[4] = t; + p[5] = t; + p[6] = t; + p[7] = t; + continue; + } + + v0 = (dctSqrt2 * p[0] + 128) >> 8; + v1 = (dctSqrt2 * p[4] + 128) >> 8; + v2 = p[2]; + v3 = p[6]; + v4 = (dctSqrt1d2 * (p[1] - p[7]) + 128) >> 8; + v7 = (dctSqrt1d2 * (p[1] + p[7]) + 128) >> 8; + v5 = p[3] << 4; + v6 = p[5] << 4; + + t = (v0 - v1+ 1) >> 1; + v0 = (v0 + v1 + 1) >> 1; + v1 = t; + t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8; + v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8; + v3 = t; + t = (v4 - v6 + 1) >> 1; + v4 = (v4 + v6 + 1) >> 1; + v6 = t; + t = (v7 + v5 + 1) >> 1; + v5 = (v7 - v5 + 1) >> 1; + v7 = t; + + t = (v0 - v3 + 1) >> 1; + v0 = (v0 + v3 + 1) >> 1; + v3 = t; + t = (v1 - v2 + 1) >> 1; + v1 = (v1 + v2 + 1) >> 1; + v2 = t; + t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12; + v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12; + v7 = t; + t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; + v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; + v6 = t; + + p[0] = v0 + v7; + p[7] = v0 - v7; + p[1] = v1 + v6; + p[6] = v1 - v6; + p[2] = v2 + v5; + p[5] = v2 - v5; + p[3] = v3 + v4; + p[4] = v3 - v4; + } + + for (i = 0; i < 8; ++i) { + p = dataIn + i; + + if (p[1*8] == 0 && p[2*8] == 0 && p[3*8] == 0 && + p[4*8] == 0 && p[5*8] == 0 && p[6*8] == 0 && p[7*8] == 0) { + t = (dctSqrt2 * dataIn[i+0] + 8192) >> 14; + p[0*8] = t; + p[1*8] = t; + p[2*8] = t; + p[3*8] = t; + p[4*8] = t; + p[5*8] = t; + p[6*8] = t; + p[7*8] = t; + continue; + } + + v0 = (dctSqrt2 * p[0*8] + 2048) >> 12; + v1 = (dctSqrt2 * p[4*8] + 2048) >> 12; + v2 = p[2*8]; + v3 = p[6*8]; + v4 = (dctSqrt1d2 * (p[1*8] - p[7*8]) + 2048) >> 12; + v7 = (dctSqrt1d2 * (p[1*8] + p[7*8]) + 2048) >> 12; + v5 = p[3*8]; + v6 = p[5*8]; + + t = (v0 - v1 + 1) >> 1; + v0 = (v0 + v1 + 1) >> 1; + v1 = t; + t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12; + v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12; + v3 = t; + t = (v4 - v6 + 1) >> 1; + v4 = (v4 + v6 + 1) >> 1; + v6 = t; + t = (v7 + v5 + 1) >> 1; + v5 = (v7 - v5 + 1) >> 1; + v7 = t; + + t = (v0 - v3 + 1) >> 1; + v0 = (v0 + v3 + 1) >> 1; + v3 = t; + t = (v1 - v2 + 1) >> 1; + v1 = (v1 + v2 + 1) >> 1; + v2 = t; + t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12; + v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12; + v7 = t; + t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; + v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; + v6 = t; + + p[0*8] = v0 + v7; + p[7*8] = v0 - v7; + p[1*8] = v1 + v6; + p[6*8] = v1 - v6; + p[2*8] = v2 + v5; + p[5*8] = v2 - v5; + p[3*8] = v3 + v4; + p[4*8] = v3 - v4; + } + + for (i = 0; i < 64; ++i) { + dataOut[i] = dctClip[dctClipOffset + 128 + ((dataIn[i] + 8) >> 4)]; + } +} +",0,"void DCTStream::transformDataUnit(Gushort *quantTable, + int dataIn[64], Guchar dataOut[64]) { + int v0, v1, v2, v3, v4, v5, v6, v7, t; + int *p; + int i; + + for (i = 0; i < 64; ++i) { + dataIn[i] *= quantTable[i]; + } + + for (i = 0; i < 64; i += 8) { + p = dataIn + i; + + if (p[1] == 0 && p[2] == 0 && p[3] == 0 && + p[4] == 0 && p[5] == 0 && p[6] == 0 && p[7] == 0) { + t = (dctSqrt2 * p[0] + 512) >> 10; + p[0] = t; + p[1] = t; + p[2] = t; + p[3] = t; + p[4] = t; + p[5] = t; + p[6] = t; + p[7] = t; + continue; + } + + v0 = (dctSqrt2 * p[0] + 128) >> 8; + v1 = (dctSqrt2 * p[4] + 128) >> 8; + v2 = p[2]; + v3 = p[6]; + v4 = (dctSqrt1d2 * (p[1] - p[7]) + 128) >> 8; + v7 = (dctSqrt1d2 * (p[1] + p[7]) + 128) >> 8; + v5 = p[3] << 4; + v6 = p[5] << 4; + + t = (v0 - v1+ 1) >> 1; + v0 = (v0 + v1 + 1) >> 1; + v1 = t; + t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8; + v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8; + v3 = t; + t = (v4 - v6 + 1) >> 1; + v4 = (v4 + v6 + 1) >> 1; + v6 = t; + t = (v7 + v5 + 1) >> 1; + v5 = (v7 - v5 + 1) >> 1; + v7 = t; + + t = (v0 - v3 + 1) >> 1; + v0 = (v0 + v3 + 1) >> 1; + v3 = t; + t = (v1 - v2 + 1) >> 1; + v1 = (v1 + v2 + 1) >> 1; + v2 = t; + t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12; + v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12; + v7 = t; + t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; + v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; + v6 = t; + + p[0] = v0 + v7; + p[7] = v0 - v7; + p[1] = v1 + v6; + p[6] = v1 - v6; + p[2] = v2 + v5; + p[5] = v2 - v5; + p[3] = v3 + v4; + p[4] = v3 - v4; + } + + for (i = 0; i < 8; ++i) { + p = dataIn + i; + + if (p[1*8] == 0 && p[2*8] == 0 && p[3*8] == 0 && + p[4*8] == 0 && p[5*8] == 0 && p[6*8] == 0 && p[7*8] == 0) { + t = (dctSqrt2 * dataIn[i+0] + 8192) >> 14; + p[0*8] = t; + p[1*8] = t; + p[2*8] = t; + p[3*8] = t; + p[4*8] = t; + p[5*8] = t; + p[6*8] = t; + p[7*8] = t; + continue; + } + + v0 = (dctSqrt2 * p[0*8] + 2048) >> 12; + v1 = (dctSqrt2 * p[4*8] + 2048) >> 12; + v2 = p[2*8]; + v3 = p[6*8]; + v4 = (dctSqrt1d2 * (p[1*8] - p[7*8]) + 2048) >> 12; + v7 = (dctSqrt1d2 * (p[1*8] + p[7*8]) + 2048) >> 12; + v5 = p[3*8]; + v6 = p[5*8]; + + t = (v0 - v1 + 1) >> 1; + v0 = (v0 + v1 + 1) >> 1; + v1 = t; + t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12; + v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12; + v3 = t; + t = (v4 - v6 + 1) >> 1; + v4 = (v4 + v6 + 1) >> 1; + v6 = t; + t = (v7 + v5 + 1) >> 1; + v5 = (v7 - v5 + 1) >> 1; + v7 = t; + + t = (v0 - v3 + 1) >> 1; + v0 = (v0 + v3 + 1) >> 1; + v3 = t; + t = (v1 - v2 + 1) >> 1; + v1 = (v1 + v2 + 1) >> 1; + v2 = t; + t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12; + v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12; + v7 = t; + t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; + v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; + v6 = t; + + p[0*8] = v0 + v7; + p[7*8] = v0 - v7; + p[1*8] = v1 + v6; + p[6*8] = v1 - v6; + p[2*8] = v2 + v5; + p[5*8] = v2 - v5; + p[3*8] = v3 + v4; + p[4*8] = v3 - v4; + } + + for (i = 0; i < 64; ++i) { + dataOut[i] = dctClip[dctClipOffset + 128 + ((dataIn[i] + 8) >> 4)]; + } +} +","@@ -14,7 +14,7 @@ + // under GPL version 2 or later + // + // Copyright (C) 2005 Jeff Muizelaar +-// Copyright (C) 2006-2010, 2012 Albert Astals Cid ++// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid + // Copyright (C) 2007 Krzysztof Kowalczyk + // Copyright (C) 2008 Julien Rebetez + // Copyright (C) 2009 Carlos Garcia Campos +@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() { + for (i = 0; i < columns && codingLine[i] < columns; ++i) { + refLine[i] = codingLine[i]; + } +- refLine[i++] = columns; +- refLine[i] = columns; ++ for (; i < columns + 2; ++i) { ++ refLine[i] = columns; ++ } + codingLine[0] = 0; + a0i = 0; + b1i = 0;",1884,2120,4096 +18792,"WORD32 ih264d_cavlc_4x4res_block_totalcoeff_11to16(UWORD32 u4_isdc, + UWORD32 u4_total_coeff_trail_one, /*!pu4_buffer; + + UWORD32 u4_bitstream_offset = ps_bitstrm->u4_ofst; + UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF; + UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16; + WORD16 i2_level_arr[16]; + + tu_sblk4x4_coeff_data_t *ps_tu_4x4; + WORD16 *pi2_coeff_data; + dec_struct_t *ps_dec = (dec_struct_t *)ps_bitstrm->pv_codec_handle; + + ps_tu_4x4 = (tu_sblk4x4_coeff_data_t *)ps_dec->pv_parse_tu_coeff_data; + ps_tu_4x4->u2_sig_coeff_map = 0; + pi2_coeff_data = &ps_tu_4x4->ai2_level[0]; + + i = u4_total_coeff - 1; + if(u4_trailing_ones) + { + /*********************************************************************/ + /* Decode Trailing Ones */ + /* read the sign of T1's and put them in level array */ + /*********************************************************************/ + UWORD32 u4_signs, u4_cnt = u4_trailing_ones; + WORD16 (*ppi2_trlone_lkup)[3] = + (WORD16 (*)[3])gai2_ih264d_trailing_one_level; + WORD16 *pi2_trlone_lkup; + + GETBITS(u4_signs, u4_bitstream_offset, pu4_bitstrm_buf, u4_cnt); + + pi2_trlone_lkup = ppi2_trlone_lkup[(1 << u4_cnt) - 2 + u4_signs]; + + while(u4_cnt--) + i2_level_arr[i--] = *pi2_trlone_lkup++; + } + + /****************************************************************/ + /* Decoding Levels Begins */ + /****************************************************************/ + if(i >= 0) + { + /****************************************************************/ + /* First level is decoded outside the loop as it has lot of */ + /* special cases. */ + /****************************************************************/ + UWORD32 u4_lev_suffix, u4_suffix_len, u4_lev_suffix_size; + UWORD16 u2_lev_code, u2_abs_value; + UWORD32 u4_lev_prefix; + + if(u4_trailing_ones < 3) + { + /*********************************************************/ + /* u4_suffix_len = 1 */ + /*********************************************************/ + /***************************************************************/ + /* Find leading zeros in next 32 bits */ + /***************************************************************/ + FIND_ONE_IN_STREAM_32(u4_lev_prefix, u4_bitstream_offset, + pu4_bitstrm_buf); + + u4_lev_suffix_size = + (15 <= u4_lev_prefix) ? (u4_lev_prefix - 3) : 1; + + GETBITS(u4_lev_suffix, u4_bitstream_offset, pu4_bitstrm_buf, + u4_lev_suffix_size); + u2_lev_code = 2 + (MIN(u4_lev_prefix,15) << 1) + u4_lev_suffix; + + if(16 <= u4_lev_prefix) + { + u2_lev_code += ((1 << (u4_lev_prefix - 3)) - 4096); + } + } + else + { + /*********************************************************/ + /*u4_suffix_len = 0 */ + /*********************************************************/ + /***************************************************************/ + /* Find leading zeros in next 32 bits */ + /***************************************************************/ + FIND_ONE_IN_STREAM_32(u4_lev_prefix, u4_bitstream_offset, + pu4_bitstrm_buf); + + /*********************************************************/ + /* Special decoding case when trailing ones are 3 */ + /*********************************************************/ + u2_lev_code = MIN(15, u4_lev_prefix); + + u2_lev_code += (3 == u4_trailing_ones) ? 0 : (2); + + if(14 == u4_lev_prefix) + u4_lev_suffix_size = 4; + else if(15 <= u4_lev_prefix) + { + u2_lev_code += 15; + u4_lev_suffix_size = (u4_lev_prefix - 3); + } + else + u4_lev_suffix_size = 0; + + if(16 <= u4_lev_prefix) + { + u2_lev_code += ((1 << (u4_lev_prefix - 3)) - 4096); + } + if(u4_lev_suffix_size) + { + GETBITS(u4_lev_suffix, u4_bitstream_offset, pu4_bitstrm_buf, + u4_lev_suffix_size); + u2_lev_code += u4_lev_suffix; + } + } + + u2_abs_value = (u2_lev_code + 2) >> 1; + /*********************************************************/ + /* If Level code is odd, level is negative else positive */ + /*********************************************************/ + i2_level_arr[i--] = (u2_lev_code & 1) ? -u2_abs_value : u2_abs_value; + + u4_suffix_len = (u2_abs_value > 3) ? 2 : 1; + + /*********************************************************/ + /* Now loop over the remaining levels */ + /*********************************************************/ + while(i >= 0) + { + + /***************************************************************/ + /* Find leading zeros in next 32 bits */ + /***************************************************************/ + FIND_ONE_IN_STREAM_32(u4_lev_prefix, u4_bitstream_offset, + pu4_bitstrm_buf); + + u4_lev_suffix_size = + (15 <= u4_lev_prefix) ? + (u4_lev_prefix - 3) : u4_suffix_len; + + /*********************************************************/ + /* Compute level code using prefix and suffix */ + /*********************************************************/ + GETBITS(u4_lev_suffix, u4_bitstream_offset, pu4_bitstrm_buf, + u4_lev_suffix_size); + u2_lev_code = (MIN(15,u4_lev_prefix) << u4_suffix_len) + + u4_lev_suffix; + + if(16 <= u4_lev_prefix) + { + u2_lev_code += ((1 << (u4_lev_prefix - 3)) - 4096); + } + u2_abs_value = (u2_lev_code + 2) >> 1; + + /*********************************************************/ + /* If Level code is odd, level is negative else positive */ + /*********************************************************/ + i2_level_arr[i--] = + (u2_lev_code & 1) ? -u2_abs_value : u2_abs_value; + + /*********************************************************/ + /* Increment suffix length if required */ + /*********************************************************/ + u4_suffix_len += + (u4_suffix_len < 6) ? + (u2_abs_value + > (3 + << (u4_suffix_len + - 1))) : + 0; + } + + /****************************************************************/ + /* Decoding Levels Ends */ + /****************************************************************/ + } + + if(u4_total_coeff < (16 - u4_isdc)) + { + UWORD32 u4_index; + const UWORD8 (*ppu1_total_zero_lkup)[16] = + (const UWORD8 (*)[16])gau1_ih264d_table_total_zero_11to15; + + NEXTBITS(u4_index, u4_bitstream_offset, pu4_bitstrm_buf, 4); + u4_total_zeroes = ppu1_total_zero_lkup[u4_total_coeff - 11][u4_index]; + + FLUSHBITS(u4_bitstream_offset, (u4_total_zeroes >> 4)); + u4_total_zeroes &= 0xf; + } + else + u4_total_zeroes = 0; + + /**************************************************************/ + /* Decode the runs and form the coefficient buffer */ + /**************************************************************/ + { + const UWORD8 *pu1_table_runbefore; + UWORD32 u4_run; + WORD32 k; + UWORD32 u4_scan_pos = u4_total_coeff + u4_total_zeroes - 1 + u4_isdc; + WORD32 u4_zeroes_left = u4_total_zeroes; + k = u4_total_coeff - 1; + + /**************************************************************/ + /* Decoding Runs for 0 < zeros left <=6 */ + /**************************************************************/ + pu1_table_runbefore = (UWORD8 *)gau1_ih264d_table_run_before; + while((u4_zeroes_left > 0) && k) + { + UWORD32 u4_code; + NEXTBITS(u4_code, u4_bitstream_offset, pu4_bitstrm_buf, 3); + + u4_code = pu1_table_runbefore[u4_code + (u4_zeroes_left << 3)]; + u4_run = u4_code >> 2; + + FLUSHBITS(u4_bitstream_offset, (u4_code & 0x03)); + SET_BIT(ps_tu_4x4->u2_sig_coeff_map, u4_scan_pos); + *pi2_coeff_data++ = i2_level_arr[k--]; + u4_zeroes_left -= u4_run; + u4_scan_pos -= (u4_run + 1); + } + /**************************************************************/ + /* Decoding Runs End */ + /**************************************************************/ + + /**************************************************************/ + /* Copy the remaining coefficients */ + /**************************************************************/ + if(u4_zeroes_left < 0) + return -1; + while(k >= 0) + { + SET_BIT(ps_tu_4x4->u2_sig_coeff_map, u4_scan_pos); + *pi2_coeff_data++ = i2_level_arr[k--]; + u4_scan_pos--; + } + } + + { + WORD32 offset; + offset = (UWORD8 *)pi2_coeff_data - (UWORD8 *)ps_tu_4x4; + offset = ALIGN4(offset); + ps_dec->pv_parse_tu_coeff_data = (void *)((UWORD8 *)ps_dec->pv_parse_tu_coeff_data + offset); + } + + ps_bitstrm->u4_ofst = u4_bitstream_offset; + return 0; +} +",1,"WORD32 ih264d_cavlc_4x4res_block_totalcoeff_11to16(UWORD32 u4_isdc, + UWORD32 u4_total_coeff_trail_one, /*!pu4_buffer; + + UWORD32 u4_bitstream_offset = ps_bitstrm->u4_ofst; + UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF; + UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16; + // To avoid error check at 4x4 level, allocating for 3 extra levels(16+3) + // since u4_trailing_ones can at the max be 3. This will be required when + // u4_total_coeff is less than u4_trailing_ones + WORD16 ai2_level_arr[19];// + WORD16 *i2_level_arr = &ai2_level_arr[3]; + + tu_sblk4x4_coeff_data_t *ps_tu_4x4; + WORD16 *pi2_coeff_data; + dec_struct_t *ps_dec = (dec_struct_t *)ps_bitstrm->pv_codec_handle; + + ps_tu_4x4 = (tu_sblk4x4_coeff_data_t *)ps_dec->pv_parse_tu_coeff_data; + ps_tu_4x4->u2_sig_coeff_map = 0; + pi2_coeff_data = &ps_tu_4x4->ai2_level[0]; + + i = u4_total_coeff - 1; + if(u4_trailing_ones) + { + /*********************************************************************/ + /* Decode Trailing Ones */ + /* read the sign of T1's and put them in level array */ + /*********************************************************************/ + UWORD32 u4_signs, u4_cnt = u4_trailing_ones; + WORD16 (*ppi2_trlone_lkup)[3] = + (WORD16 (*)[3])gai2_ih264d_trailing_one_level; + WORD16 *pi2_trlone_lkup; + + GETBITS(u4_signs, u4_bitstream_offset, pu4_bitstrm_buf, u4_cnt); + + pi2_trlone_lkup = ppi2_trlone_lkup[(1 << u4_cnt) - 2 + u4_signs]; + + while(u4_cnt--) + i2_level_arr[i--] = *pi2_trlone_lkup++; + } + + /****************************************************************/ + /* Decoding Levels Begins */ + /****************************************************************/ + if(i >= 0) + { + /****************************************************************/ + /* First level is decoded outside the loop as it has lot of */ + /* special cases. */ + /****************************************************************/ + UWORD32 u4_lev_suffix, u4_suffix_len, u4_lev_suffix_size; + UWORD16 u2_lev_code, u2_abs_value; + UWORD32 u4_lev_prefix; + + if(u4_trailing_ones < 3) + { + /*********************************************************/ + /* u4_suffix_len = 1 */ + /*********************************************************/ + /***************************************************************/ + /* Find leading zeros in next 32 bits */ + /***************************************************************/ + FIND_ONE_IN_STREAM_32(u4_lev_prefix, u4_bitstream_offset, + pu4_bitstrm_buf); + + u4_lev_suffix_size = + (15 <= u4_lev_prefix) ? (u4_lev_prefix - 3) : 1; + + GETBITS(u4_lev_suffix, u4_bitstream_offset, pu4_bitstrm_buf, + u4_lev_suffix_size); + u2_lev_code = 2 + (MIN(u4_lev_prefix,15) << 1) + u4_lev_suffix; + + if(16 <= u4_lev_prefix) + { + u2_lev_code += ((1 << (u4_lev_prefix - 3)) - 4096); + } + } + else + { + /*********************************************************/ + /*u4_suffix_len = 0 */ + /*********************************************************/ + /***************************************************************/ + /* Find leading zeros in next 32 bits */ + /***************************************************************/ + FIND_ONE_IN_STREAM_32(u4_lev_prefix, u4_bitstream_offset, + pu4_bitstrm_buf); + + /*********************************************************/ + /* Special decoding case when trailing ones are 3 */ + /*********************************************************/ + u2_lev_code = MIN(15, u4_lev_prefix); + + u2_lev_code += (3 == u4_trailing_ones) ? 0 : (2); + + if(14 == u4_lev_prefix) + u4_lev_suffix_size = 4; + else if(15 <= u4_lev_prefix) + { + u2_lev_code += 15; + u4_lev_suffix_size = (u4_lev_prefix - 3); + } + else + u4_lev_suffix_size = 0; + + if(16 <= u4_lev_prefix) + { + u2_lev_code += ((1 << (u4_lev_prefix - 3)) - 4096); + } + if(u4_lev_suffix_size) + { + GETBITS(u4_lev_suffix, u4_bitstream_offset, pu4_bitstrm_buf, + u4_lev_suffix_size); + u2_lev_code += u4_lev_suffix; + } + } + + u2_abs_value = (u2_lev_code + 2) >> 1; + /*********************************************************/ + /* If Level code is odd, level is negative else positive */ + /*********************************************************/ + i2_level_arr[i--] = (u2_lev_code & 1) ? -u2_abs_value : u2_abs_value; + + u4_suffix_len = (u2_abs_value > 3) ? 2 : 1; + + /*********************************************************/ + /* Now loop over the remaining levels */ + /*********************************************************/ + while(i >= 0) + { + + /***************************************************************/ + /* Find leading zeros in next 32 bits */ + /***************************************************************/ + FIND_ONE_IN_STREAM_32(u4_lev_prefix, u4_bitstream_offset, + pu4_bitstrm_buf); + + u4_lev_suffix_size = + (15 <= u4_lev_prefix) ? + (u4_lev_prefix - 3) : u4_suffix_len; + + /*********************************************************/ + /* Compute level code using prefix and suffix */ + /*********************************************************/ + GETBITS(u4_lev_suffix, u4_bitstream_offset, pu4_bitstrm_buf, + u4_lev_suffix_size); + u2_lev_code = (MIN(15,u4_lev_prefix) << u4_suffix_len) + + u4_lev_suffix; + + if(16 <= u4_lev_prefix) + { + u2_lev_code += ((1 << (u4_lev_prefix - 3)) - 4096); + } + u2_abs_value = (u2_lev_code + 2) >> 1; + + /*********************************************************/ + /* If Level code is odd, level is negative else positive */ + /*********************************************************/ + i2_level_arr[i--] = + (u2_lev_code & 1) ? -u2_abs_value : u2_abs_value; + + /*********************************************************/ + /* Increment suffix length if required */ + /*********************************************************/ + u4_suffix_len += + (u4_suffix_len < 6) ? + (u2_abs_value + > (3 + << (u4_suffix_len + - 1))) : + 0; + } + + /****************************************************************/ + /* Decoding Levels Ends */ + /****************************************************************/ + } + + if(u4_total_coeff < (16 - u4_isdc)) + { + UWORD32 u4_index; + const UWORD8 (*ppu1_total_zero_lkup)[16] = + (const UWORD8 (*)[16])gau1_ih264d_table_total_zero_11to15; + + NEXTBITS(u4_index, u4_bitstream_offset, pu4_bitstrm_buf, 4); + u4_total_zeroes = ppu1_total_zero_lkup[u4_total_coeff - 11][u4_index]; + + FLUSHBITS(u4_bitstream_offset, (u4_total_zeroes >> 4)); + u4_total_zeroes &= 0xf; + } + else + u4_total_zeroes = 0; + + /**************************************************************/ + /* Decode the runs and form the coefficient buffer */ + /**************************************************************/ + { + const UWORD8 *pu1_table_runbefore; + UWORD32 u4_run; + WORD32 k; + UWORD32 u4_scan_pos = u4_total_coeff + u4_total_zeroes - 1 + u4_isdc; + WORD32 u4_zeroes_left = u4_total_zeroes; + k = u4_total_coeff - 1; + + /**************************************************************/ + /* Decoding Runs for 0 < zeros left <=6 */ + /**************************************************************/ + pu1_table_runbefore = (UWORD8 *)gau1_ih264d_table_run_before; + while((u4_zeroes_left > 0) && k) + { + UWORD32 u4_code; + NEXTBITS(u4_code, u4_bitstream_offset, pu4_bitstrm_buf, 3); + + u4_code = pu1_table_runbefore[u4_code + (u4_zeroes_left << 3)]; + u4_run = u4_code >> 2; + + FLUSHBITS(u4_bitstream_offset, (u4_code & 0x03)); + SET_BIT(ps_tu_4x4->u2_sig_coeff_map, u4_scan_pos); + *pi2_coeff_data++ = i2_level_arr[k--]; + u4_zeroes_left -= u4_run; + u4_scan_pos -= (u4_run + 1); + } + /**************************************************************/ + /* Decoding Runs End */ + /**************************************************************/ + + /**************************************************************/ + /* Copy the remaining coefficients */ + /**************************************************************/ + if(u4_zeroes_left < 0) + return -1; + while(k >= 0) + { + SET_BIT(ps_tu_4x4->u2_sig_coeff_map, u4_scan_pos); + *pi2_coeff_data++ = i2_level_arr[k--]; + u4_scan_pos--; + } + } + + { + WORD32 offset; + offset = (UWORD8 *)pi2_coeff_data - (UWORD8 *)ps_tu_4x4; + offset = ALIGN4(offset); + ps_dec->pv_parse_tu_coeff_data = (void *)((UWORD8 *)ps_dec->pv_parse_tu_coeff_data + offset); + } + + ps_bitstrm->u4_ofst = u4_bitstream_offset; + return 0; +} +","@@ -443,7 +443,11 @@ + + UWORD32 u4_bitstream_offset = ps_bitstrm->u4_ofst; + UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF; + UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16; +- WORD16 i2_level_arr[16]; ++ // To avoid error check at 4x4 level, allocating for 3 extra levels(16+3) ++ // since u4_trailing_ones can at the max be 3. This will be required when ++ // u4_total_coeff is less than u4_trailing_ones ++ WORD16 ai2_level_arr[19]; ++ WORD16 *i2_level_arr = &ai2_level_arr[3]; + + tu_sblk4x4_coeff_data_t *ps_tu_4x4; + WORD16 *pi2_coeff_data; +@@ -721,7 +725,11 @@ + + UWORD32 u4_bitstream_offset = ps_bitstrm->u4_ofst; + UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF; + UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16; +- WORD16 i2_level_arr[16]; ++ // To avoid error check at 4x4 level, allocating for 3 extra levels(16+3) ++ // since u4_trailing_ones can at the max be 3. This will be required when ++ // u4_total_coeff is less than u4_trailing_ones ++ WORD16 ai2_level_arr[19];// ++ WORD16 *i2_level_arr = &ai2_level_arr[3]; + + tu_sblk4x4_coeff_data_t *ps_tu_4x4; + WORD16 *pi2_coeff_data; +@@ -993,7 +1001,11 @@ + + UWORD32 u4_bitstream_offset = ps_bitstrm->u4_ofst; + UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF; + UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16; +- WORD16 i2_level_arr[4]; ++ // To avoid error check at 4x4 level, allocating for 3 extra levels(4+3) ++ // since u4_trailing_ones can at the max be 3. This will be required when ++ // u4_total_coeff is less than u4_trailing_ones ++ WORD16 ai2_level_arr[7];// ++ WORD16 *i2_level_arr = &ai2_level_arr[3]; + + tu_sblk4x4_coeff_data_t *ps_tu_4x4; + WORD16 *pi2_coeff_data; +",2227,2463,4096 +17789,"gs_call_interp(i_ctx_t **pi_ctx_p, ref * pref, int user_errors, + int *pexit_code, ref * perror_object) +{ + ref *epref = pref; + ref doref; + ref *perrordict; + ref error_name; + int code, ccode; + ref saref; + i_ctx_t *i_ctx_p = *pi_ctx_p; + int *gc_signal = &imemory_system->gs_lib_ctx->gcsignal; + + *pexit_code = 0; + *gc_signal = 0; + ialloc_reset_requested(idmemory); +again: + /* Avoid a dangling error object that might get traced by a future GC. */ + make_null(perror_object); + o_stack.requested = e_stack.requested = d_stack.requested = 0; + while (*gc_signal) { /* Some routine below triggered a GC. */ + gs_gc_root_t epref_root; + + *gc_signal = 0; + /* Make sure that doref will get relocated properly if */ + /* a garbage collection happens with epref == &doref. */ + gs_register_ref_root(imemory_system, &epref_root, + (void **)&epref, ""gs_call_interp(epref)""); + code = interp_reclaim(pi_ctx_p, -1); + i_ctx_p = *pi_ctx_p; + gs_unregister_root(imemory_system, &epref_root, + ""gs_call_interp(epref)""); + if (code < 0) + return code; + } + code = interp(pi_ctx_p, epref, perror_object); + i_ctx_p = *pi_ctx_p; + if (!r_has_type(&i_ctx_p->error_object, t__invalid)) { + *perror_object = i_ctx_p->error_object; + make_t(&i_ctx_p->error_object, t__invalid); + } + /* Prevent a dangling reference to the GC signal in ticks_left */ + /* in the frame of interp, but be prepared to do a GC if */ + /* an allocation in this routine asks for it. */ + *gc_signal = 0; + set_gc_signal(i_ctx_p, 1); + if (esp < esbot) /* popped guard entry */ + esp = esbot; + switch (code) { + case gs_error_Fatal: + *pexit_code = 255; + return code; + case gs_error_Quit: + *perror_object = osp[-1]; + *pexit_code = code = osp->value.intval; + osp -= 2; + return + (code == 0 ? gs_error_Quit : + code < 0 && code > -100 ? code : gs_error_Fatal); + case gs_error_InterpreterExit: + return 0; + case gs_error_ExecStackUnderflow: +/****** WRONG -- must keep mark blocks intact ******/ + ref_stack_pop_block(&e_stack); + doref = *perror_object; + epref = &doref; + goto again; + case gs_error_VMreclaim: + /* Do the GC and continue. */ + /* We ignore the return value here, if it fails here + * we'll call it again having jumped to the ""again"" label. + * Where, assuming it fails again, we'll handle the error. + */ + (void)interp_reclaim(pi_ctx_p, + (osp->value.intval == 2 ? + avm_global : avm_local)); + i_ctx_p = *pi_ctx_p; + make_oper(&doref, 0, zpop); + epref = &doref; + goto again; + case gs_error_NeedInput: + case gs_error_interrupt: + return code; + } + /* Adjust osp in case of operand stack underflow */ + if (osp < osbot - 1) + osp = osbot - 1; + /* We have to handle stack over/underflow specially, because */ + /* we might be able to recover by adding or removing a block. */ + switch (code) { + case gs_error_dictstackoverflow: + /* We don't have to handle this specially: */ + /* The only places that could generate it */ + /* use check_dstack, which does a ref_stack_extend, */ + /* so if` we get this error, it's a real one. */ + if (osp >= ostop) { + if ((ccode = ref_stack_extend(&o_stack, 1)) < 0) + return ccode; + } + /* Skip system dictionaries for CET 20-02-02 */ + ccode = copy_stack(i_ctx_p, &d_stack, min_dstack_size, &saref); + if (ccode < 0) + return ccode; + ref_stack_pop_to(&d_stack, min_dstack_size); + dict_set_top(); + *++osp = saref; + break; + case gs_error_dictstackunderflow: + if (ref_stack_pop_block(&d_stack) >= 0) { + dict_set_top(); + doref = *perror_object; + epref = &doref; + goto again; + } + break; + case gs_error_execstackoverflow: + /* We don't have to handle this specially: */ + /* The only places that could generate it */ + /* use check_estack, which does a ref_stack_extend, */ + /* so if we get this error, it's a real one. */ + if (osp >= ostop) { + if ((ccode = ref_stack_extend(&o_stack, 1)) < 0) + return ccode; + } + ccode = copy_stack(i_ctx_p, &e_stack, 0, &saref); + if (ccode < 0) + return ccode; + { + uint count = ref_stack_count(&e_stack); + uint limit = ref_stack_max_count(&e_stack) - ES_HEADROOM; + + if (count > limit) { + /* + * If there is an e-stack mark within MIN_BLOCK_ESTACK of + * the new top, cut the stack back to remove the mark. + */ + int skip = count - limit; + int i; + + for (i = skip; i < skip + MIN_BLOCK_ESTACK; ++i) { + const ref *ep = ref_stack_index(&e_stack, i); + + if (r_has_type_attrs(ep, t_null, a_executable)) { + skip = i + 1; + break; + } + } + pop_estack(i_ctx_p, skip); + } + } + *++osp = saref; + break; + case gs_error_stackoverflow: + if (ref_stack_extend(&o_stack, o_stack.requested) >= 0) { /* We can't just re-execute the object, because */ + /* it might be a procedure being pushed as a */ + /* literal. We check for this case specially. */ + doref = *perror_object; + if (r_is_proc(&doref)) { + *++osp = doref; + make_null_proc(&doref); + } + epref = &doref; + goto again; + } + ccode = copy_stack(i_ctx_p, &o_stack, 0, &saref); + if (ccode < 0) + return ccode; + ref_stack_clear(&o_stack); + *++osp = saref; + break; + case gs_error_stackunderflow: + if (ref_stack_pop_block(&o_stack) >= 0) { + doref = *perror_object; + epref = &doref; + goto again; + } + break; + } + if (user_errors < 0) + return code; + if (gs_errorname(i_ctx_p, code, &error_name) < 0) + return code; /* out-of-range error code! */ + /* + * For greater Adobe compatibility, only the standard PostScript errors + * are defined in errordict; the rest are in gserrordict. + */ + if (dict_find_string(systemdict, ""errordict"", &perrordict) <= 0 || + (dict_find(perrordict, &error_name, &epref) <= 0 && + (dict_find_string(systemdict, ""gserrordict"", &perrordict) <= 0 || + dict_find(perrordict, &error_name, &epref) <= 0)) + ) + return code; /* error name not in errordict??? */ + doref = *epref; + epref = &doref; + /* Push the error object on the operand stack if appropriate. */ + if (!GS_ERROR_IS_INTERRUPT(code)) { + /* Replace the error object if within an oparray or .errorexec. */ + *++osp = *perror_object; + errorexec_find(i_ctx_p, osp); + } + goto again; +} +",1,"gs_call_interp(i_ctx_t **pi_ctx_p, ref * pref, int user_errors, + int *pexit_code, ref * perror_object) +{ + ref *epref = pref; + ref doref; + ref *perrordict; + ref error_name; + int code, ccode; + ref saref; + i_ctx_t *i_ctx_p = *pi_ctx_p; + int *gc_signal = &imemory_system->gs_lib_ctx->gcsignal; + + *pexit_code = 0; + *gc_signal = 0; + ialloc_reset_requested(idmemory); +again: + /* Avoid a dangling error object that might get traced by a future GC. */ + make_null(perror_object); + o_stack.requested = e_stack.requested = d_stack.requested = 0; + while (*gc_signal) { /* Some routine below triggered a GC. */ + gs_gc_root_t epref_root; + + *gc_signal = 0; + /* Make sure that doref will get relocated properly if */ + /* a garbage collection happens with epref == &doref. */ + gs_register_ref_root(imemory_system, &epref_root, + (void **)&epref, ""gs_call_interp(epref)""); + code = interp_reclaim(pi_ctx_p, -1); + i_ctx_p = *pi_ctx_p; + gs_unregister_root(imemory_system, &epref_root, + ""gs_call_interp(epref)""); + if (code < 0) + return code; + } + code = interp(pi_ctx_p, epref, perror_object); + i_ctx_p = *pi_ctx_p; + if (!r_has_type(&i_ctx_p->error_object, t__invalid)) { + *perror_object = i_ctx_p->error_object; + make_t(&i_ctx_p->error_object, t__invalid); + } + /* Prevent a dangling reference to the GC signal in ticks_left */ + /* in the frame of interp, but be prepared to do a GC if */ + /* an allocation in this routine asks for it. */ + *gc_signal = 0; + set_gc_signal(i_ctx_p, 1); + if (esp < esbot) /* popped guard entry */ + esp = esbot; + switch (code) { + case gs_error_Fatal: + *pexit_code = 255; + return code; + case gs_error_Quit: + *perror_object = osp[-1]; + *pexit_code = code = osp->value.intval; + osp -= 2; + return + (code == 0 ? gs_error_Quit : + code < 0 && code > -100 ? code : gs_error_Fatal); + case gs_error_InterpreterExit: + return 0; + case gs_error_ExecStackUnderflow: +/****** WRONG -- must keep mark blocks intact ******/ + ref_stack_pop_block(&e_stack); + doref = *perror_object; + epref = &doref; + goto again; + case gs_error_VMreclaim: + /* Do the GC and continue. */ + /* We ignore the return value here, if it fails here + * we'll call it again having jumped to the ""again"" label. + * Where, assuming it fails again, we'll handle the error. + */ + (void)interp_reclaim(pi_ctx_p, + (osp->value.intval == 2 ? + avm_global : avm_local)); + i_ctx_p = *pi_ctx_p; + make_oper(&doref, 0, zpop); + epref = &doref; + goto again; + case gs_error_NeedInput: + case gs_error_interrupt: + return code; + } + /* Adjust osp in case of operand stack underflow */ + if (osp < osbot - 1) + osp = osbot - 1; + /* We have to handle stack over/underflow specially, because */ + /* we might be able to recover by adding or removing a block. */ + switch (code) { + case gs_error_dictstackoverflow: + /* We don't have to handle this specially: */ + /* The only places that could generate it */ + /* use check_dstack, which does a ref_stack_extend, */ + /* so if` we get this error, it's a real one. */ + if (osp >= ostop) { + if ((ccode = ref_stack_extend(&o_stack, 1)) < 0) + return ccode; + } + /* Skip system dictionaries for CET 20-02-02 */ + ccode = copy_stack(i_ctx_p, &d_stack, min_dstack_size, &saref); + if (ccode < 0) + return ccode; + ref_stack_pop_to(&d_stack, min_dstack_size); + dict_set_top(); + *++osp = saref; + break; + case gs_error_dictstackunderflow: + if (ref_stack_pop_block(&d_stack) >= 0) { + dict_set_top(); + doref = *perror_object; + epref = &doref; + goto again; + } + break; + case gs_error_execstackoverflow: + /* We don't have to handle this specially: */ + /* The only places that could generate it */ + /* use check_estack, which does a ref_stack_extend, */ + /* so if we get this error, it's a real one. */ + if (osp >= ostop) { + if ((ccode = ref_stack_extend(&o_stack, 1)) < 0) + return ccode; + } + ccode = copy_stack(i_ctx_p, &e_stack, 0, &saref); + if (ccode < 0) + return ccode; + { + uint count = ref_stack_count(&e_stack); + uint limit = ref_stack_max_count(&e_stack) - ES_HEADROOM; + + if (count > limit) { + /* + * If there is an e-stack mark within MIN_BLOCK_ESTACK of + * the new top, cut the stack back to remove the mark. + */ + int skip = count - limit; + int i; + + for (i = skip; i < skip + MIN_BLOCK_ESTACK; ++i) { + const ref *ep = ref_stack_index(&e_stack, i); + + if (r_has_type_attrs(ep, t_null, a_executable)) { + skip = i + 1; + break; + } + } + pop_estack(i_ctx_p, skip); + } + } + *++osp = saref; + break; + case gs_error_stackoverflow: + if (ref_stack_extend(&o_stack, o_stack.requested) >= 0) { /* We can't just re-execute the object, because */ + /* it might be a procedure being pushed as a */ + /* literal. We check for this case specially. */ + doref = *perror_object; + if (r_is_proc(&doref)) { + *++osp = doref; + make_null_proc(&doref); + } + epref = &doref; + goto again; + } + ccode = copy_stack(i_ctx_p, &o_stack, 0, &saref); + if (ccode < 0) + return ccode; + ref_stack_clear(&o_stack); + *++osp = saref; + break; + case gs_error_stackunderflow: + if (ref_stack_pop_block(&o_stack) >= 0) { + doref = *perror_object; + epref = &doref; + goto again; + } + break; + } + if (user_errors < 0) + return code; + if (gs_errorname(i_ctx_p, code, &error_name) < 0) + return code; /* out-of-range error code! */ + /* + * For greater Adobe compatibility, only the standard PostScript errors + * are defined in errordict; the rest are in gserrordict. + */ + if (dict_find_string(systemdict, ""errordict"", &perrordict) <= 0 || + (dict_find(perrordict, &error_name, &epref) <= 0 && + (dict_find_string(systemdict, ""gserrordict"", &perrordict) <= 0 || + dict_find(perrordict, &error_name, &epref) <= 0)) + ) + return code; /* error name not in errordict??? */ + doref = *epref; + epref = &doref; + /* Push the error object on the operand stack if appropriate. */ + if (!GS_ERROR_IS_INTERRUPT(code)) { + /* Replace the error object if within an oparray or .errorexec. */ + osp++; + if (osp >= ostop) { + *pexit_code = gs_error_Fatal; + return_error(gs_error_Fatal); + } + *osp = *perror_object; + errorexec_find(i_ctx_p, osp); + } + goto again; +} +","@@ -676,7 +676,12 @@ again: + /* Push the error object on the operand stack if appropriate. */ + if (!GS_ERROR_IS_INTERRUPT(code)) { + /* Replace the error object if within an oparray or .errorexec. */ +- *++osp = *perror_object; ++ osp++; ++ if (osp >= ostop) { ++ *pexit_code = gs_error_Fatal; ++ return_error(gs_error_Fatal); ++ } ++ *osp = *perror_object; + errorexec_find(i_ctx_p, osp); + } + goto again;",1905,2141,4096 +7796,"epass2003_construct_fci(struct sc_card *card, const sc_file_t * file, + u8 * out, size_t * outlen) +{ + u8 *p = out; + u8 buf[64]; + unsigned char ops[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + int rv; + unsigned ii; + + if (*outlen < 2) + return SC_ERROR_BUFFER_TOO_SMALL; + + *p++ = 0x62; + p++; + if (file->type == SC_FILE_TYPE_WORKING_EF) { + if (file->ef_structure == SC_FILE_EF_TRANSPARENT) { + buf[0] = (file->size >> 8) & 0xFF; + buf[1] = file->size & 0xFF; + sc_asn1_put_tag(0x80, buf, 2, p, *outlen - (p - out), &p); + } + } + if (file->type == SC_FILE_TYPE_DF) { + buf[0] = 0x38; + buf[1] = 0x00; + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_WORKING_EF) { + buf[0] = file->ef_structure & 7; + if (file->ef_structure == SC_FILE_EF_TRANSPARENT) { + buf[1] = 0x00; + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED + || file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) { + buf[1] = 0x00; + buf[2] = 0x00; + buf[3] = 0x40; /* record length */ + buf[4] = 0x00; /* record count */ + sc_asn1_put_tag(0x82, buf, 5, p, *outlen - (p - out), &p); + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + + } + else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) { + buf[0] = 0x11; + buf[1] = 0x00; + } + else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + buf[0] = 0x12; + buf[1] = 0x00; + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_BSO) { + buf[0] = 0x10; + buf[1] = 0x00; + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + + buf[0] = (file->id >> 8) & 0xFF; + buf[1] = file->id & 0xFF; + sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p); + if (file->type == SC_FILE_TYPE_DF) { + if (file->namelen != 0) { + sc_asn1_put_tag(0x84, file->name, file->namelen, p, *outlen - (p - out), &p); + } + else { + return SC_ERROR_INVALID_ARGUMENTS; + } + } + if (file->type == SC_FILE_TYPE_DF) { + unsigned char data[2] = {0x00, 0x7F}; + /* 127 files at most */ + sc_asn1_put_tag(0x85, data, sizeof(data), p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_BSO) { + buf[0] = file->size & 0xff; + sc_asn1_put_tag(0x85, buf, 1, p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + buf[0] = (file->size >> 8) & 0xFF; + buf[1] = file->size & 0xFF; + sc_asn1_put_tag(0x85, buf, 2, p, *outlen - (p - out), &p); + } + } + if (file->sec_attr_len) { + memcpy(buf, file->sec_attr, file->sec_attr_len); + sc_asn1_put_tag(0x86, buf, file->sec_attr_len, p, *outlen - (p - out), &p); + } + else { + sc_log(card->ctx, ""SC_FILE_ACL""); + if (file->type == SC_FILE_TYPE_DF) { + ops[0] = SC_AC_OP_LIST_FILES; + ops[1] = SC_AC_OP_CREATE; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->type == SC_FILE_TYPE_WORKING_EF) { + if (file->ef_structure == SC_FILE_EF_TRANSPARENT) { + ops[0] = SC_AC_OP_READ; + ops[1] = SC_AC_OP_UPDATE; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED + || file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) { + ops[0] = SC_AC_OP_READ; + ops[1] = SC_AC_OP_UPDATE; + ops[2] = SC_AC_OP_WRITE; + ops[3] = SC_AC_OP_DELETE; + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + } + else if (file->type == SC_FILE_TYPE_BSO) { + ops[0] = SC_AC_OP_UPDATE; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) { + ops[1] = SC_AC_OP_UPDATE; + ops[2] = SC_AC_OP_CRYPTO; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + ops[0] = SC_AC_OP_READ; + ops[1] = SC_AC_OP_UPDATE; + ops[2] = SC_AC_OP_CRYPTO; + ops[3] = SC_AC_OP_DELETE; + } + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + + for (ii = 0; ii < sizeof(ops); ii++) { + const struct sc_acl_entry *entry; + + buf[ii] = 0xFF; + if (ops[ii] == 0xFF) + continue; + entry = sc_file_get_acl_entry(file, ops[ii]); + + rv = acl_to_ac_byte(card, entry); + LOG_TEST_RET(card->ctx, rv, ""Invalid ACL""); + + buf[ii] = rv; + } + sc_asn1_put_tag(0x86, buf, sizeof(ops), p, *outlen - (p - out), &p); + if(file->size == 256) + { + out[4]= 0x13; + } + + } + + /* VT ??? */ + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + unsigned char data[2] = {0x00, 0x66}; + sc_asn1_put_tag(0x87, data, sizeof(data), p, *outlen - (p - out), &p); + if(file->size == 256) + { + out[4]= 0x14; + } + } + + out[1] = p - out - 2; + + *outlen = p - out; + return 0; +} +",0,"epass2003_construct_fci(struct sc_card *card, const sc_file_t * file, + u8 * out, size_t * outlen) +{ + u8 *p = out; + u8 buf[64]; + unsigned char ops[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + int rv; + unsigned ii; + + if (*outlen < 2) + return SC_ERROR_BUFFER_TOO_SMALL; + + *p++ = 0x62; + p++; + if (file->type == SC_FILE_TYPE_WORKING_EF) { + if (file->ef_structure == SC_FILE_EF_TRANSPARENT) { + buf[0] = (file->size >> 8) & 0xFF; + buf[1] = file->size & 0xFF; + sc_asn1_put_tag(0x80, buf, 2, p, *outlen - (p - out), &p); + } + } + if (file->type == SC_FILE_TYPE_DF) { + buf[0] = 0x38; + buf[1] = 0x00; + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_WORKING_EF) { + buf[0] = file->ef_structure & 7; + if (file->ef_structure == SC_FILE_EF_TRANSPARENT) { + buf[1] = 0x00; + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED + || file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) { + buf[1] = 0x00; + buf[2] = 0x00; + buf[3] = 0x40; /* record length */ + buf[4] = 0x00; /* record count */ + sc_asn1_put_tag(0x82, buf, 5, p, *outlen - (p - out), &p); + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + + } + else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) { + buf[0] = 0x11; + buf[1] = 0x00; + } + else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + buf[0] = 0x12; + buf[1] = 0x00; + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_BSO) { + buf[0] = 0x10; + buf[1] = 0x00; + sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p); + } + + buf[0] = (file->id >> 8) & 0xFF; + buf[1] = file->id & 0xFF; + sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p); + if (file->type == SC_FILE_TYPE_DF) { + if (file->namelen != 0) { + sc_asn1_put_tag(0x84, file->name, file->namelen, p, *outlen - (p - out), &p); + } + else { + return SC_ERROR_INVALID_ARGUMENTS; + } + } + if (file->type == SC_FILE_TYPE_DF) { + unsigned char data[2] = {0x00, 0x7F}; + /* 127 files at most */ + sc_asn1_put_tag(0x85, data, sizeof(data), p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_BSO) { + buf[0] = file->size & 0xff; + sc_asn1_put_tag(0x85, buf, 1, p, *outlen - (p - out), &p); + } + else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + buf[0] = (file->size >> 8) & 0xFF; + buf[1] = file->size & 0xFF; + sc_asn1_put_tag(0x85, buf, 2, p, *outlen - (p - out), &p); + } + } + if (file->sec_attr_len) { + memcpy(buf, file->sec_attr, file->sec_attr_len); + sc_asn1_put_tag(0x86, buf, file->sec_attr_len, p, *outlen - (p - out), &p); + } + else { + sc_log(card->ctx, ""SC_FILE_ACL""); + if (file->type == SC_FILE_TYPE_DF) { + ops[0] = SC_AC_OP_LIST_FILES; + ops[1] = SC_AC_OP_CREATE; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->type == SC_FILE_TYPE_WORKING_EF) { + if (file->ef_structure == SC_FILE_EF_TRANSPARENT) { + ops[0] = SC_AC_OP_READ; + ops[1] = SC_AC_OP_UPDATE; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED + || file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) { + ops[0] = SC_AC_OP_READ; + ops[1] = SC_AC_OP_UPDATE; + ops[2] = SC_AC_OP_WRITE; + ops[3] = SC_AC_OP_DELETE; + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + } + else if (file->type == SC_FILE_TYPE_BSO) { + ops[0] = SC_AC_OP_UPDATE; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT || + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) { + ops[1] = SC_AC_OP_UPDATE; + ops[2] = SC_AC_OP_CRYPTO; + ops[3] = SC_AC_OP_DELETE; + } + else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + ops[0] = SC_AC_OP_READ; + ops[1] = SC_AC_OP_UPDATE; + ops[2] = SC_AC_OP_CRYPTO; + ops[3] = SC_AC_OP_DELETE; + } + } + else { + return SC_ERROR_NOT_SUPPORTED; + } + + for (ii = 0; ii < sizeof(ops); ii++) { + const struct sc_acl_entry *entry; + + buf[ii] = 0xFF; + if (ops[ii] == 0xFF) + continue; + entry = sc_file_get_acl_entry(file, ops[ii]); + + rv = acl_to_ac_byte(card, entry); + LOG_TEST_RET(card->ctx, rv, ""Invalid ACL""); + + buf[ii] = rv; + } + sc_asn1_put_tag(0x86, buf, sizeof(ops), p, *outlen - (p - out), &p); + if(file->size == 256) + { + out[4]= 0x13; + } + + } + + /* VT ??? */ + if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC|| + file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) { + unsigned char data[2] = {0x00, 0x66}; + sc_asn1_put_tag(0x87, data, sizeof(data), p, *outlen - (p - out), &p); + if(file->size == 256) + { + out[4]= 0x14; + } + } + + out[1] = p - out - 2; + + *outlen = p - out; + return 0; +} +","@@ -740,11 +740,11 @@ construct_mac_tlv(struct sc_card *card, unsigned char *apdu_buf, size_t data_tlv + memcpy(mac_tlv + 2, &mac[mac_len - 16], 8); + } + else { +- unsigned char iv[8] = { 0 }; ++ unsigned char iv[EVP_MAX_IV_LENGTH] = { 0 }; + unsigned char tmp[8] = { 0 }; + des_encrypt_cbc(exdata->sk_mac, 8, icv, apdu_buf, mac_len, mac); + des_decrypt_cbc(&exdata->sk_mac[8], 8, iv, &mac[mac_len - 8], 8, tmp); +- memset(iv, 0x00, 8); ++ memset(iv, 0x00, sizeof iv); + des_encrypt_cbc(exdata->sk_mac, 8, iv, tmp, 8, mac_tlv + 2); + } + +@@ -903,9 +903,9 @@ epass2003_sm_wrap_apdu(struct sc_card *card, struct sc_apdu *plain, struct sc_ap + * SW12(TLV)=0x99|0x02|SW1+SW2 + * MAC(TLV)=0x8e|0x08|MAC */ + static int +-decrypt_response(struct sc_card *card, unsigned char *in, unsigned char *out, size_t * out_len) ++decrypt_response(struct sc_card *card, unsigned char *in, size_t inlen, unsigned char *out, size_t * out_len) + { +- size_t in_len; ++ size_t cipher_len; + size_t i; + unsigned char iv[16] = { 0 }; + unsigned char plaintext[4096] = { 0 }; +@@ -922,37 +922,40 @@ decrypt_response(struct sc_card *card, unsigned char *in, unsigned char *out, si + + /* parse cipher length */ + if (0x01 == in[2] && 0x82 != in[1]) { +- in_len = in[1]; ++ cipher_len = in[1]; + i = 3; + } + else if (0x01 == in[3] && 0x81 == in[1]) { +- in_len = in[2]; ++ cipher_len = in[2]; + i = 4; + } + else if (0x01 == in[4] && 0x82 == in[1]) { +- in_len = in[2] * 0x100; +- in_len += in[3]; ++ cipher_len = in[2] * 0x100; ++ cipher_len += in[3]; + i = 5; + } + else { + return -1; + } + ++ if (cipher_len < 2 || i+cipher_len > inlen || cipher_len > sizeof plaintext) ++ return -1; ++ + /* decrypt */ + if (KEY_TYPE_AES == exdata->smtype) +- aes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], in_len - 1, plaintext); ++ aes128_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext); + else +- des3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], in_len - 1, plaintext); ++ des3_decrypt_cbc(exdata->sk_enc, 16, iv, &in[i], cipher_len - 1, plaintext); + + /* unpadding */ +- while (0x80 != plaintext[in_len - 2] && (in_len - 2 > 0)) +- in_len--; ++ while (0x80 != plaintext[cipher_len - 2] && (cipher_len - 2 > 0)) ++ cipher_len--; + +- if (2 == in_len) ++ if (2 == cipher_len) + return -1; + +- memcpy(out, plaintext, in_len - 2); +- *out_len = in_len - 2; ++ memcpy(out, plaintext, cipher_len - 2); ++ *out_len = cipher_len - 2; + return 0; + } + +@@ -974,7 +977,7 @@ epass2003_sm_unwrap_apdu(struct sc_card *card, struct sc_apdu *sm, struct sc_apd + r = sc_check_sw(card, sm->sw1, sm->sw2); + if (r == SC_SUCCESS) { + if (exdata->sm) { +- if (0 != decrypt_response(card, sm->resp, plain->resp, &len)) ++ if (0 != decrypt_response(card, sm->resp, sm->resplen, plain->resp, &len)) + return SC_ERROR_CARD_CMD_FAILED; + } + else {",2079,2315,4096 +18333,"static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image + *image; + + MagickBooleanType + has_merged_image, + skip_layers; + + MagickOffsetType + offset; + + MagickSizeType + length; + + MagickBooleanType + status; + + PSDInfo + psd_info; + + register ssize_t + i; + + ssize_t + count; + + unsigned char + *data; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read image header. + */ + image->endian=MSBEndian; + count=ReadBlob(image,4,(unsigned char *) psd_info.signature); + psd_info.version=ReadBlobMSBShort(image); + if ((count == 0) || (LocaleNCompare(psd_info.signature,""8BPS"",4) != 0) || + ((psd_info.version != 1) && (psd_info.version != 2))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + (void) ReadBlob(image,6,psd_info.reserved); + psd_info.channels=ReadBlobMSBShort(image); + if (psd_info.channels > MaxPSDChannels) + ThrowReaderException(CorruptImageError,""MaximumChannelsExceeded""); + psd_info.rows=ReadBlobMSBLong(image); + psd_info.columns=ReadBlobMSBLong(image); + if ((psd_info.version == 1) && ((psd_info.rows > 30000) || + (psd_info.columns > 30000))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + psd_info.depth=ReadBlobMSBShort(image); + if ((psd_info.depth != 1) && (psd_info.depth != 8) && (psd_info.depth != 16)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + psd_info.mode=ReadBlobMSBShort(image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Image is %.20g x %.20g with channels=%.20g, depth=%.20g, mode=%s"", + (double) psd_info.columns,(double) psd_info.rows,(double) + psd_info.channels,(double) psd_info.depth,ModeToString((PSDImageType) + psd_info.mode)); + /* + Initialize image. + */ + image->depth=psd_info.depth; + image->columns=psd_info.columns; + image->rows=psd_info.rows; + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + if (SetImageBackgroundColor(image,exception) == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + if (psd_info.mode == LabMode) + SetImageColorspace(image,LabColorspace,exception); + if (psd_info.mode == CMYKMode) + { + SetImageColorspace(image,CMYKColorspace,exception); + image->alpha_trait=psd_info.channels > 4 ? BlendPixelTrait : + UndefinedPixelTrait; + } + else if ((psd_info.mode == BitmapMode) || (psd_info.mode == GrayscaleMode) || + (psd_info.mode == DuotoneMode)) + { + status=AcquireImageColormap(image,psd_info.depth != 16 ? 256 : 65536, + exception); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Image colormap allocated""); + SetImageColorspace(image,GRAYColorspace,exception); + image->alpha_trait=psd_info.channels > 1 ? BlendPixelTrait : + UndefinedPixelTrait; + } + else + image->alpha_trait=psd_info.channels > 3 ? BlendPixelTrait : + UndefinedPixelTrait; + /* + Read PSD raster colormap only present for indexed and duotone images. + */ + length=ReadBlobMSBLong(image); + if (length != 0) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading colormap""); + if (psd_info.mode == DuotoneMode) + { + /* + Duotone image data; the format of this data is undocumented. + */ + data=(unsigned char *) AcquireQuantumMemory((size_t) length, + sizeof(*data)); + if (data == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + (void) ReadBlob(image,(size_t) length,data); + data=(unsigned char *) RelinquishMagickMemory(data); + } + else + { + size_t + number_colors; + + /* + Read PSD raster colormap. + */ + number_colors=length/3; + if (number_colors > 65536) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (AcquireImageColormap(image,number_colors,exception) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].red=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].green=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].blue=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->alpha_trait=UndefinedPixelTrait; + } + } + has_merged_image=MagickTrue; + length=ReadBlobMSBLong(image); + if (length != 0) + { + unsigned char + *blocks; + + /* + Image resources block. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading image resource blocks - %.20g bytes"",(double) + ((MagickOffsetType) length)); + blocks=(unsigned char *) AcquireQuantumMemory((size_t) length, + sizeof(*blocks)); + if (blocks == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,(size_t) length,blocks); + if ((count != (ssize_t) length) || + (LocaleNCompare((char *) blocks,""8BIM"",4) != 0)) + { + blocks=(unsigned char *) RelinquishMagickMemory(blocks); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + ParseImageResourceBlocks(image,blocks,(size_t) length,&has_merged_image, + exception); + blocks=(unsigned char *) RelinquishMagickMemory(blocks); + } + /* + Layer and mask block. + */ + length=GetPSDSize(&psd_info,image); + if (length == 8) + { + length=ReadBlobMSBLong(image); + length=ReadBlobMSBLong(image); + } + offset=TellBlob(image); + skip_layers=MagickFalse; + if ((image_info->number_scenes == 1) && (image_info->scene == 0) && + (has_merged_image != MagickFalse)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" read composite only""); + skip_layers=MagickTrue; + } + if (length == 0) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" image has no layers""); + } + else + { + if (ReadPSDLayers(image,image_info,&psd_info,skip_layers,exception) != + MagickTrue) + { + (void) CloseBlob(image); + image=DestroyImageList(image); + return((Image *) NULL); + } + + /* + Skip the rest of the layer and mask information. + */ + SeekBlob(image,offset+length,SEEK_SET); + } + /* + If we are only ""pinging"" the image, then we're done - so return. + */ + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + /* + Read the precombined layer, present for PSD < 4 compatibility. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading the precombined layer""); + if ((has_merged_image != MagickFalse) || (GetImageListLength(image) == 1)) + has_merged_image=(MagickBooleanType) ReadPSDMergedImage(image_info,image, + &psd_info,exception); + if ((has_merged_image == MagickFalse) && (GetImageListLength(image) == 1) && + (length != 0)) + { + SeekBlob(image,offset,SEEK_SET); + status=ReadPSDLayers(image,image_info,&psd_info,MagickFalse,exception); + if (status != MagickTrue) + { + (void) CloseBlob(image); + image=DestroyImageList(image); + return((Image *) NULL); + } + } + if ((has_merged_image == MagickFalse) && (GetImageListLength(image) > 1)) + { + Image + *merged; + + SetImageAlphaChannel(image,TransparentAlphaChannel,exception); + image->background_color.alpha=TransparentAlpha; + image->background_color.alpha_trait=BlendPixelTrait; + merged=MergeImageLayers(image,FlattenLayer,exception); + ReplaceImageInList(&image,merged); + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image + *image; + + MagickBooleanType + has_merged_image, + skip_layers; + + MagickOffsetType + offset; + + MagickSizeType + length; + + MagickBooleanType + status; + + PSDInfo + psd_info; + + register ssize_t + i; + + ssize_t + count; + + unsigned char + *data; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read image header. + */ + image->endian=MSBEndian; + count=ReadBlob(image,4,(unsigned char *) psd_info.signature); + psd_info.version=ReadBlobMSBShort(image); + if ((count == 0) || (LocaleNCompare(psd_info.signature,""8BPS"",4) != 0) || + ((psd_info.version != 1) && (psd_info.version != 2))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + (void) ReadBlob(image,6,psd_info.reserved); + psd_info.channels=ReadBlobMSBShort(image); + if (psd_info.channels > MaxPSDChannels) + ThrowReaderException(CorruptImageError,""MaximumChannelsExceeded""); + psd_info.rows=ReadBlobMSBLong(image); + psd_info.columns=ReadBlobMSBLong(image); + if ((psd_info.version == 1) && ((psd_info.rows > 30000) || + (psd_info.columns > 30000))) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + psd_info.depth=ReadBlobMSBShort(image); + if ((psd_info.depth != 1) && (psd_info.depth != 8) && (psd_info.depth != 16)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + psd_info.mode=ReadBlobMSBShort(image); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Image is %.20g x %.20g with channels=%.20g, depth=%.20g, mode=%s"", + (double) psd_info.columns,(double) psd_info.rows,(double) + psd_info.channels,(double) psd_info.depth,ModeToString((PSDImageType) + psd_info.mode)); + /* + Initialize image. + */ + image->depth=psd_info.depth; + image->columns=psd_info.columns; + image->rows=psd_info.rows; + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + if (SetImageBackgroundColor(image,exception) == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + if (psd_info.mode == LabMode) + SetImageColorspace(image,LabColorspace,exception); + if (psd_info.mode == CMYKMode) + { + SetImageColorspace(image,CMYKColorspace,exception); + image->alpha_trait=psd_info.channels > 4 ? BlendPixelTrait : + UndefinedPixelTrait; + } + else if ((psd_info.mode == BitmapMode) || (psd_info.mode == GrayscaleMode) || + (psd_info.mode == DuotoneMode)) + { + status=AcquireImageColormap(image,psd_info.depth != 16 ? 256 : 65536, + exception); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Image colormap allocated""); + SetImageColorspace(image,GRAYColorspace,exception); + image->alpha_trait=psd_info.channels > 1 ? BlendPixelTrait : + UndefinedPixelTrait; + } + else + image->alpha_trait=psd_info.channels > 3 ? BlendPixelTrait : + UndefinedPixelTrait; + /* + Read PSD raster colormap only present for indexed and duotone images. + */ + length=ReadBlobMSBLong(image); + if (length != 0) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading colormap""); + if (psd_info.mode == DuotoneMode) + { + /* + Duotone image data; the format of this data is undocumented. + */ + data=(unsigned char *) AcquireQuantumMemory((size_t) length, + sizeof(*data)); + if (data == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + (void) ReadBlob(image,(size_t) length,data); + data=(unsigned char *) RelinquishMagickMemory(data); + } + else + { + size_t + number_colors; + + /* + Read PSD raster colormap. + */ + number_colors=length/3; + if (number_colors > 65536) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (AcquireImageColormap(image,number_colors,exception) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].red=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].green=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + for (i=0; i < (ssize_t) image->colors; i++) + image->colormap[i].blue=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->alpha_trait=UndefinedPixelTrait; + } + } + if ((image->depth == 1) && (image->storage_class != PseudoClass)) + ThrowReaderException(CorruptImageError, ""ImproperImageHeader""); + has_merged_image=MagickTrue; + length=ReadBlobMSBLong(image); + if (length != 0) + { + unsigned char + *blocks; + + /* + Image resources block. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading image resource blocks - %.20g bytes"",(double) + ((MagickOffsetType) length)); + blocks=(unsigned char *) AcquireQuantumMemory((size_t) length, + sizeof(*blocks)); + if (blocks == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,(size_t) length,blocks); + if ((count != (ssize_t) length) || + (LocaleNCompare((char *) blocks,""8BIM"",4) != 0)) + { + blocks=(unsigned char *) RelinquishMagickMemory(blocks); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + ParseImageResourceBlocks(image,blocks,(size_t) length,&has_merged_image, + exception); + blocks=(unsigned char *) RelinquishMagickMemory(blocks); + } + /* + Layer and mask block. + */ + length=GetPSDSize(&psd_info,image); + if (length == 8) + { + length=ReadBlobMSBLong(image); + length=ReadBlobMSBLong(image); + } + offset=TellBlob(image); + skip_layers=MagickFalse; + if ((image_info->number_scenes == 1) && (image_info->scene == 0) && + (has_merged_image != MagickFalse)) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" read composite only""); + skip_layers=MagickTrue; + } + if (length == 0) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" image has no layers""); + } + else + { + if (ReadPSDLayers(image,image_info,&psd_info,skip_layers,exception) != + MagickTrue) + { + (void) CloseBlob(image); + image=DestroyImageList(image); + return((Image *) NULL); + } + + /* + Skip the rest of the layer and mask information. + */ + SeekBlob(image,offset+length,SEEK_SET); + } + /* + If we are only ""pinging"" the image, then we're done - so return. + */ + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + /* + Read the precombined layer, present for PSD < 4 compatibility. + */ + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" reading the precombined layer""); + if ((has_merged_image != MagickFalse) || (GetImageListLength(image) == 1)) + has_merged_image=(MagickBooleanType) ReadPSDMergedImage(image_info,image, + &psd_info,exception); + if ((has_merged_image == MagickFalse) && (GetImageListLength(image) == 1) && + (length != 0)) + { + SeekBlob(image,offset,SEEK_SET); + status=ReadPSDLayers(image,image_info,&psd_info,MagickFalse,exception); + if (status != MagickTrue) + { + (void) CloseBlob(image); + image=DestroyImageList(image); + return((Image *) NULL); + } + } + if ((has_merged_image == MagickFalse) && (GetImageListLength(image) > 1)) + { + Image + *merged; + + SetImageAlphaChannel(image,TransparentAlphaChannel,exception); + image->background_color.alpha=TransparentAlpha; + image->background_color.alpha_trait=BlendPixelTrait; + merged=MergeImageLayers(image,FlattenLayer,exception); + ReplaceImageInList(&image,merged); + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -1908,6 +1908,8 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) + image->alpha_trait=UndefinedPixelTrait; + } + } ++ if ((image->depth == 1) && (image->storage_class != PseudoClass)) ++ ThrowReaderException(CorruptImageError, ""ImproperImageHeader""); + has_merged_image=MagickTrue; + length=ReadBlobMSBLong(image); + if (length != 0)",2365,2601,4096 +18178,"MagickExport MagickBooleanType SetImageProperty(Image *image, + const char *property,const char *value,ExceptionInfo *exception) +{ + MagickBooleanType + status; + + MagickStatusType + flags; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if (image->properties == (void *) NULL) + image->properties=NewSplayTree(CompareSplayTreeString, + RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */ + if (value == (const char *) NULL) + return(DeleteImageProperty(image,property)); /* delete if NULL */ + status=MagickTrue; + if (strlen(property) <= 1) + { + /* + Do not 'set' single letter properties - read only shorthand. + */ + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + + /* FUTURE: binary chars or quotes in key should produce a error */ + /* Set attributes with known names or special prefixes + return result is found, or break to set a free form properity + */ + switch (*property) + { +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + case '8': + { + if (LocaleNCompare(""8bim:"",property,5) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; + } +#endif + case 'B': + case 'b': + { + if (LocaleCompare(""background"",property) == 0) + { + (void) QueryColorCompliance(value,AllCompliance, + &image->background_color,exception); + /* check for FUTURE: value exception?? */ + /* also add user input to splay tree */ + } + break; /* not an attribute, add as a property */ + } + case 'C': + case 'c': + { + if (LocaleCompare(""channels"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + if (LocaleCompare(""colorspace"",property) == 0) + { + ssize_t + colorspace; + + colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, + value); + if (colorspace < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + return(SetImageColorspace(image,(ColorspaceType) colorspace,exception)); + } + if (LocaleCompare(""compose"",property) == 0) + { + ssize_t + compose; + + compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value); + if (compose < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->compose=(CompositeOperator) compose; + return(MagickTrue); + } + if (LocaleCompare(""compress"",property) == 0) + { + ssize_t + compression; + + compression=ParseCommandOption(MagickCompressOptions,MagickFalse, + value); + if (compression < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->compression=(CompressionType) compression; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'D': + case 'd': + { + if (LocaleCompare(""delay"",property) == 0) + { + GeometryInfo + geometry_info; + + flags=ParseGeometry(value,&geometry_info); + if ((flags & GreaterValue) != 0) + { + if (image->delay > (size_t) floor(geometry_info.rho+0.5)) + image->delay=(size_t) floor(geometry_info.rho+0.5); + } + else + if ((flags & LessValue) != 0) + { + if (image->delay < (size_t) floor(geometry_info.rho+0.5)) + image->delay=(ssize_t) + floor(geometry_info.sigma+0.5); + } + else + image->delay=(size_t) floor(geometry_info.rho+0.5); + if ((flags & SigmaValue) != 0) + image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5); + return(MagickTrue); + } + if (LocaleCompare(""delay_units"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + if (LocaleCompare(""density"",property) == 0) + { + GeometryInfo + geometry_info; + + flags=ParseGeometry(value,&geometry_info); + image->resolution.x=geometry_info.rho; + image->resolution.y=geometry_info.sigma; + if ((flags & SigmaValue) == 0) + image->resolution.y=image->resolution.x; + return(MagickTrue); + } + if (LocaleCompare(""depth"",property) == 0) + { + image->depth=StringToUnsignedLong(value); + return(MagickTrue); + } + if (LocaleCompare(""dispose"",property) == 0) + { + ssize_t + dispose; + + dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value); + if (dispose < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->dispose=(DisposeType) dispose; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + case 'E': + case 'e': + { + if (LocaleNCompare(""exif:"",property,5) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } + case 'F': + case 'f': + { + if (LocaleNCompare(""fx:"",property,3) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } +#endif + case 'G': + case 'g': + { + if (LocaleCompare(""gamma"",property) == 0) + { + image->gamma=StringToDouble(value,(char **) NULL); + return(MagickTrue); + } + if (LocaleCompare(""gravity"",property) == 0) + { + ssize_t + gravity; + + gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value); + if (gravity < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->gravity=(GravityType) gravity; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'H': + case 'h': + { + if (LocaleCompare(""height"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } + case 'I': + case 'i': + { + if (LocaleCompare(""intensity"",property) == 0) + { + ssize_t + intensity; + + intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,value); + if (intensity < 0) + return(MagickFalse); + image->intensity=(PixelIntensityMethod) intensity; + return(MagickTrue); + } + if (LocaleCompare(""intent"",property) == 0) + { + ssize_t + rendering_intent; + + rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, + value); + if (rendering_intent < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->rendering_intent=(RenderingIntent) rendering_intent; + return(MagickTrue); + } + if (LocaleCompare(""interpolate"",property) == 0) + { + ssize_t + interpolate; + + interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, + value); + if (interpolate < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->interpolate=(PixelInterpolateMethod) interpolate; + return(MagickTrue); + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + if (LocaleNCompare(""iptc:"",property,5) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } +#endif + break; /* not an attribute, add as a property */ + } + case 'K': + case 'k': + if (LocaleCompare(""kurtosis"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'L': + case 'l': + { + if (LocaleCompare(""loop"",property) == 0) + { + image->iterations=StringToUnsignedLong(value); + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'M': + case 'm': + if ((LocaleCompare(""magick"",property) == 0) || + (LocaleCompare(""max"",property) == 0) || + (LocaleCompare(""mean"",property) == 0) || + (LocaleCompare(""min"",property) == 0) || + (LocaleCompare(""min"",property) == 0)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'O': + case 'o': + if (LocaleCompare(""opaque"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'P': + case 'p': + { + if (LocaleCompare(""page"",property) == 0) + { + char + *geometry; + + geometry=GetPageGeometry(value); + flags=ParseAbsoluteGeometry(geometry,&image->page); + geometry=DestroyString(geometry); + return(MagickTrue); + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + if (LocaleNCompare(""pixel:"",property,6) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } +#endif + if (LocaleCompare(""profile"",property) == 0) + { + ImageInfo + *image_info; + + StringInfo + *profile; + + image_info=AcquireImageInfo(); + (void) CopyMagickString(image_info->filename,value,MagickPathExtent); + (void) SetImageInfo(image_info,1,exception); + profile=FileToStringInfo(image_info->filename,~0UL,exception); + if (profile != (StringInfo *) NULL) + status=SetImageProfile(image,image_info->magick,profile,exception); + image_info=DestroyImageInfo(image_info); + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'R': + case 'r': + { + if (LocaleCompare(""rendering-intent"",property) == 0) + { + ssize_t + rendering_intent; + + rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, + value); + if (rendering_intent < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->rendering_intent=(RenderingIntent) rendering_intent; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'S': + case 's': + if ((LocaleCompare(""size"",property) == 0) || + (LocaleCompare(""skewness"",property) == 0) || + (LocaleCompare(""scenes"",property) == 0) || + (LocaleCompare(""standard-deviation"",property) == 0)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'T': + case 't': + { + if (LocaleCompare(""tile-offset"",property) == 0) + { + char + *geometry; + + geometry=GetPageGeometry(value); + flags=ParseAbsoluteGeometry(geometry,&image->tile_offset); + geometry=DestroyString(geometry); + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'U': + case 'u': + { + if (LocaleCompare(""units"",property) == 0) + { + ssize_t + units; + + units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value); + if (units < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->units=(ResolutionType) units; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'V': + case 'v': + { + if (LocaleCompare(""version"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } + case 'W': + case 'w': + { + if (LocaleCompare(""width"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + case 'X': + case 'x': + { + if (LocaleNCompare(""xmp:"",property,4) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } +#endif + } + /* Default: not an attribute, add as a property */ + status=AddValueToSplayTree((SplayTreeInfo *) image->properties, + ConstantString(property),ConstantString(value)); + /* FUTURE: error if status is bad? */ + return(status); +} +",1,"MagickExport MagickBooleanType SetImageProperty(Image *image, + const char *property,const char *value,ExceptionInfo *exception) +{ + MagickBooleanType + status; + + MagickStatusType + flags; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if (image->properties == (void *) NULL) + image->properties=NewSplayTree(CompareSplayTreeString, + RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */ + if (value == (const char *) NULL) + return(DeleteImageProperty(image,property)); /* delete if NULL */ + status=MagickTrue; + if (strlen(property) <= 1) + { + /* + Do not 'set' single letter properties - read only shorthand. + */ + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + + /* FUTURE: binary chars or quotes in key should produce a error */ + /* Set attributes with known names or special prefixes + return result is found, or break to set a free form properity + */ + switch (*property) + { +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + case '8': + { + if (LocaleNCompare(""8bim:"",property,5) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; + } +#endif + case 'B': + case 'b': + { + if (LocaleCompare(""background"",property) == 0) + { + (void) QueryColorCompliance(value,AllCompliance, + &image->background_color,exception); + /* check for FUTURE: value exception?? */ + /* also add user input to splay tree */ + } + break; /* not an attribute, add as a property */ + } + case 'C': + case 'c': + { + if (LocaleCompare(""channels"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + if (LocaleCompare(""colorspace"",property) == 0) + { + ssize_t + colorspace; + + colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, + value); + if (colorspace < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + return(SetImageColorspace(image,(ColorspaceType) colorspace,exception)); + } + if (LocaleCompare(""compose"",property) == 0) + { + ssize_t + compose; + + compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value); + if (compose < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->compose=(CompositeOperator) compose; + return(MagickTrue); + } + if (LocaleCompare(""compress"",property) == 0) + { + ssize_t + compression; + + compression=ParseCommandOption(MagickCompressOptions,MagickFalse, + value); + if (compression < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->compression=(CompressionType) compression; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'D': + case 'd': + { + if (LocaleCompare(""delay"",property) == 0) + { + GeometryInfo + geometry_info; + + flags=ParseGeometry(value,&geometry_info); + if ((flags & GreaterValue) != 0) + { + if (image->delay > (size_t) floor(geometry_info.rho+0.5)) + image->delay=(size_t) floor(geometry_info.rho+0.5); + } + else + if ((flags & LessValue) != 0) + { + if (image->delay < (size_t) floor(geometry_info.rho+0.5)) + image->delay=(ssize_t) + floor(geometry_info.sigma+0.5); + } + else + image->delay=(size_t) floor(geometry_info.rho+0.5); + if ((flags & SigmaValue) != 0) + image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5); + return(MagickTrue); + } + if (LocaleCompare(""delay_units"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + if (LocaleCompare(""density"",property) == 0) + { + GeometryInfo + geometry_info; + + flags=ParseGeometry(value,&geometry_info); + image->resolution.x=geometry_info.rho; + image->resolution.y=geometry_info.sigma; + if ((flags & SigmaValue) == 0) + image->resolution.y=image->resolution.x; + return(MagickTrue); + } + if (LocaleCompare(""depth"",property) == 0) + { + image->depth=StringToUnsignedLong(value); + return(MagickTrue); + } + if (LocaleCompare(""dispose"",property) == 0) + { + ssize_t + dispose; + + dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value); + if (dispose < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->dispose=(DisposeType) dispose; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + case 'E': + case 'e': + { + if (LocaleNCompare(""exif:"",property,5) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } + case 'F': + case 'f': + { + if (LocaleNCompare(""fx:"",property,3) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } +#endif + case 'G': + case 'g': + { + if (LocaleCompare(""gamma"",property) == 0) + { + image->gamma=StringToDouble(value,(char **) NULL); + return(MagickTrue); + } + if (LocaleCompare(""gravity"",property) == 0) + { + ssize_t + gravity; + + gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value); + if (gravity < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->gravity=(GravityType) gravity; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'H': + case 'h': + { + if (LocaleCompare(""height"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } + case 'I': + case 'i': + { + if (LocaleCompare(""intensity"",property) == 0) + { + ssize_t + intensity; + + intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,value); + if (intensity < 0) + return(MagickFalse); + image->intensity=(PixelIntensityMethod) intensity; + return(MagickTrue); + } + if (LocaleCompare(""intent"",property) == 0) + { + ssize_t + rendering_intent; + + rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, + value); + if (rendering_intent < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->rendering_intent=(RenderingIntent) rendering_intent; + return(MagickTrue); + } + if (LocaleCompare(""interpolate"",property) == 0) + { + ssize_t + interpolate; + + interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, + value); + if (interpolate < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->interpolate=(PixelInterpolateMethod) interpolate; + return(MagickTrue); + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + if (LocaleNCompare(""iptc:"",property,5) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } +#endif + break; /* not an attribute, add as a property */ + } + case 'K': + case 'k': + if (LocaleCompare(""kurtosis"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'L': + case 'l': + { + if (LocaleCompare(""loop"",property) == 0) + { + image->iterations=StringToUnsignedLong(value); + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'M': + case 'm': + if ((LocaleCompare(""magick"",property) == 0) || + (LocaleCompare(""max"",property) == 0) || + (LocaleCompare(""mean"",property) == 0) || + (LocaleCompare(""min"",property) == 0) || + (LocaleCompare(""min"",property) == 0)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'O': + case 'o': + if (LocaleCompare(""opaque"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'P': + case 'p': + { + if (LocaleCompare(""page"",property) == 0) + { + char + *geometry; + + geometry=GetPageGeometry(value); + flags=ParseAbsoluteGeometry(geometry,&image->page); + geometry=DestroyString(geometry); + return(MagickTrue); + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + if (LocaleNCompare(""pixel:"",property,6) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } +#endif + if (LocaleCompare(""profile"",property) == 0) + { + ImageInfo + *image_info; + + StringInfo + *profile; + + image_info=AcquireImageInfo(); + (void) CopyMagickString(image_info->filename,value,MagickPathExtent); + (void) SetImageInfo(image_info,1,exception); + profile=FileToStringInfo(image_info->filename,~0UL,exception); + if (profile != (StringInfo *) NULL) + status=SetImageProfile(image,image_info->magick,profile,exception); + image_info=DestroyImageInfo(image_info); + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'R': + case 'r': + { + if (LocaleCompare(""rendering-intent"",property) == 0) + { + ssize_t + rendering_intent; + + rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, + value); + if (rendering_intent < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->rendering_intent=(RenderingIntent) rendering_intent; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'S': + case 's': + if ((LocaleCompare(""size"",property) == 0) || + (LocaleCompare(""skewness"",property) == 0) || + (LocaleCompare(""scenes"",property) == 0) || + (LocaleCompare(""standard-deviation"",property) == 0)) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + case 'T': + case 't': + { + if (LocaleCompare(""tile-offset"",property) == 0) + { + char + *geometry; + + geometry=GetPageGeometry(value); + flags=ParseAbsoluteGeometry(geometry,&image->tile_offset); + geometry=DestroyString(geometry); + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'U': + case 'u': + { + if (LocaleCompare(""units"",property) == 0) + { + ssize_t + units; + + units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value); + if (units < 0) + return(MagickFalse); /* FUTURE: value exception?? */ + image->units=(ResolutionType) units; + return(MagickTrue); + } + break; /* not an attribute, add as a property */ + } + case 'V': + case 'v': + { + if (LocaleCompare(""version"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } + case 'W': + case 'w': + { + if (LocaleCompare(""width"",property) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } +#if 0 /* Percent escape's sets values with this prefix: for later use + Throwing an exception causes this setting to fail */ + case 'X': + case 'x': + { + if (LocaleNCompare(""xmp:"",property,4) == 0) + { + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse); + } + break; /* not an attribute, add as a property */ + } +#endif + } + /* Default: not an attribute, add as a property */ + status=AddValueToSplayTree((SplayTreeInfo *) image->properties, + ConstantString(property),ConstantString(value)); + /* FUTURE: error if status is bad? */ + return(status); +} +","@@ -213,7 +213,7 @@ MagickExport MagickBooleanType CloneImageProperties(Image *image, + % + % DefineImageProperty() associates an assignment string of the form + % ""key=value"" with an artifact or options. It is equivelent to +-% SetImageProperty() ++% SetImageProperty(). + % + % The format of the DefineImageProperty method is: + % +@@ -3962,7 +3962,7 @@ MagickExport MagickBooleanType SetImageProperty(Image *image, + { + /* + Do not 'set' single letter properties - read only shorthand. +- */ ++ */ + (void) ThrowMagickException(exception,GetMagickModule(),OptionError, + ""SetReadOnlyProperty"",""`%s'"",property); + return(MagickFalse);",3590,3826,4096 +18113," _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + uint32_t hmi_tmp = 0; + uint8_t *hmi_base = hmi_data; + uint16_t hmi_bpm = 0; + uint16_t hmi_division = 0; + + uint32_t *hmi_track_offset = NULL; + uint32_t i = 0; + uint32_t j = 0; + uint8_t *hmi_addr = NULL; + uint32_t *hmi_track_header_length = NULL; + struct _mdi *hmi_mdi = NULL; + uint32_t tempo_f = 5000000.0; + uint32_t *hmi_track_end = NULL; + uint8_t hmi_tracks_ended = 0; + uint8_t *hmi_running_event = NULL; + uint32_t setup_ret = 0; + uint32_t *hmi_delta = NULL; + + uint32_t smallest_delta = 0; + uint32_t subtract_delta = 0; + + uint32_t sample_count = 0; + float sample_count_f = 0; + float sample_remainder = 0; + + float samples_per_delta_f = 0.0; + + struct _note { + uint32_t length; + uint8_t channel; + } *note; + + UNUSED(hmi_size); + + if (memcmp(hmi_data, ""HMI-MIDISONG061595"", 18)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, NULL, 0); + return NULL; + } + + hmi_bpm = hmi_data[212]; + + hmi_division = 60; + + hmi_track_cnt = hmi_data[228]; + + hmi_mdi = _WM_initMDI(); + + _WM_midi_setup_divisions(hmi_mdi, hmi_division); + + if ((_WM_MixerOptions & WM_MO_ROUNDTEMPO)) { + tempo_f = (float) (60000000 / hmi_bpm) + 0.5f; + } else { + tempo_f = (float) (60000000 / hmi_bpm); + } + samples_per_delta_f = _WM_GetSamplesPerTick(hmi_division, (uint32_t)tempo_f); + + _WM_midi_setup_tempo(hmi_mdi, (uint32_t)tempo_f); + + hmi_track_offset = (uint32_t *)malloc(sizeof(uint32_t) * hmi_track_cnt); + hmi_track_header_length = malloc(sizeof(uint32_t) * hmi_track_cnt); + hmi_track_end = malloc(sizeof(uint32_t) * hmi_track_cnt); + hmi_delta = malloc(sizeof(uint32_t) * hmi_track_cnt); + note = malloc(sizeof(struct _note) * 128 * hmi_track_cnt); + hmi_running_event = malloc(sizeof(uint8_t) * 128 * hmi_track_cnt); + + hmi_data += 370; + + smallest_delta = 0xffffffff; + + if (hmi_size < (370 + (hmi_track_cnt * 17))) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + + hmi_track_offset[0] = *hmi_data; // To keep Xcode happy + + for (i = 0; i < hmi_track_cnt; i++) { + hmi_track_offset[i] = *hmi_data++; + hmi_track_offset[i] += (*hmi_data++ << 8); + hmi_track_offset[i] += (*hmi_data++ << 16); + hmi_track_offset[i] += (*hmi_data++ << 24); + + if (hmi_size < (hmi_track_offset[i] + 0x5a + 4)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + + hmi_addr = hmi_base + hmi_track_offset[i]; + + if (memcmp(hmi_addr, ""HMI-MIDITRACK"", 13)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, NULL, 0); + goto _hmi_end; + } + + hmi_track_header_length[i] = hmi_addr[0x57]; + hmi_track_header_length[i] += (hmi_addr[0x58] << 8); + hmi_track_header_length[i] += (hmi_addr[0x59] << 16); + hmi_track_header_length[i] += (hmi_addr[0x5a] << 24); + + hmi_addr += hmi_track_header_length[i]; + hmi_track_offset[i] += hmi_track_header_length[i]; + + hmi_delta[i] = 0; + if (*hmi_addr > 0x7f) { + do { + hmi_delta[i] = (hmi_delta[i] << 7) + (*hmi_addr & 0x7f); + hmi_addr++; + hmi_track_offset[i]++; + } while (*hmi_addr > 0x7f); + } + hmi_delta[i] = (hmi_delta[i] << 7) + (*hmi_addr & 0x7f); + hmi_track_offset[i]++; + hmi_addr++; + + if (hmi_delta[i] < smallest_delta) { + smallest_delta = hmi_delta[i]; + } + + hmi_track_end[i] = 0; + hmi_running_event[i] = 0; + + for (j = 0; j < 128; j++) { + hmi_tmp = (128 * i) + j; + note[hmi_tmp].length = 0; + note[hmi_tmp].channel = 0; + } + } + + subtract_delta = smallest_delta; + sample_count_f= (((float) smallest_delta * samples_per_delta_f) + sample_remainder); + + sample_count = (uint32_t) sample_count_f; + sample_remainder = sample_count_f - (float) sample_count; + + hmi_mdi->events[hmi_mdi->event_count - 1].samples_to_next += sample_count; + hmi_mdi->extra_info.approx_total_samples += sample_count; + + while (hmi_tracks_ended < hmi_track_cnt) { + smallest_delta = 0; + for (i = 0; i < hmi_track_cnt; i++) { + if (hmi_track_end[i]) continue; + + for (j = 0; j < 128; j++) { + hmi_tmp = (128 * i) + j; + if (note[hmi_tmp].length) { + note[hmi_tmp].length -= subtract_delta; + if (note[hmi_tmp].length) { + if ((!smallest_delta) || (smallest_delta > note[hmi_tmp].length)) { + smallest_delta = note[hmi_tmp].length; + } + } else { + _WM_midi_setup_noteoff(hmi_mdi, note[hmi_tmp].channel, j, 0); + } + } + } + + if (hmi_delta[i]) { + hmi_delta[i] -= subtract_delta; + if (hmi_delta[i]) { + if ((!smallest_delta) || (smallest_delta > hmi_delta[i])) { + smallest_delta = hmi_delta[i]; + } + continue; + } + } + + do { + hmi_data = hmi_base + hmi_track_offset[i]; + hmi_delta[i] = 0; + + if (hmi_data[0] == 0xfe) { + if (hmi_data[1] == 0x10) { + hmi_tmp = (hmi_data[4] + 5); + hmi_data += hmi_tmp; + hmi_track_offset[i] += hmi_tmp; + } else if (hmi_data[1] == 0x15) { + hmi_data += 4; + hmi_track_offset[i] += 4; + } + hmi_data += 4; + hmi_track_offset[i] += 4; + } else { + if ((setup_ret = _WM_SetupMidiEvent(hmi_mdi,hmi_data,hmi_running_event[i])) == 0) { + goto _hmi_end; + } + if ((hmi_data[0] == 0xff) && (hmi_data[1] == 0x2f) && (hmi_data[2] == 0x00)) { + hmi_track_end[i] = 1; + hmi_tracks_ended++; + for(j = 0; j < 128; j++) { + hmi_tmp = (128 * i) + j; + if (note[hmi_tmp].length) { + _WM_midi_setup_noteoff(hmi_mdi, note[hmi_tmp].channel, j, 0); + note[hmi_tmp].length = 0; + } + } + goto _hmi_next_track; + } + if ((*hmi_data == 0xF0) || (*hmi_data == 0xF7)) { + hmi_running_event[i] = 0; + } else if (*hmi_data < 0xF0) { + if (*hmi_data >= 0x80) { + hmi_running_event[i] = *hmi_data; + } + } + if ((hmi_running_event[i] & 0xf0) == 0x90) { + if (*hmi_data > 127) { + hmi_tmp = hmi_data[1]; + } else { + hmi_tmp = *hmi_data; + } + hmi_tmp += (i * 128); + + note[hmi_tmp].channel = hmi_running_event[i] & 0xf; + + hmi_data += setup_ret; + hmi_track_offset[i] += setup_ret; + + note[hmi_tmp].length = 0; + if (*hmi_data > 0x7f) { + do { + note[hmi_tmp].length = (note[hmi_tmp].length << 7) | (*hmi_data & 0x7F); + hmi_data++; + hmi_track_offset[i]++; + } while (*hmi_data > 0x7F); + } + note[hmi_tmp].length = (note[hmi_tmp].length << 7) | (*hmi_data & 0x7F); + hmi_data++; + hmi_track_offset[i]++; + + if (note[hmi_tmp].length) { + if ((!smallest_delta) || (smallest_delta > note[hmi_tmp].length)) { + smallest_delta = note[hmi_tmp].length; + } + } else { + _WM_midi_setup_noteoff(hmi_mdi, note[hmi_tmp].channel, j, 0); + } + + } else { + hmi_data += setup_ret; + hmi_track_offset[i] += setup_ret; + } + } + + if (*hmi_data > 0x7f) { + do { + hmi_delta[i] = (hmi_delta[i] << 7) | (*hmi_data & 0x7F); + hmi_data++; + hmi_track_offset[i]++; + } while (*hmi_data > 0x7F); + } + hmi_delta[i] = (hmi_delta[i] << 7) | (*hmi_data & 0x7F); + hmi_data++; + hmi_track_offset[i]++; + } while (!hmi_delta[i]); + if ((!smallest_delta) || (smallest_delta > hmi_delta[i])) { + smallest_delta = hmi_delta[i]; + } + + _hmi_next_track: + hmi_tmp = 0; + UNUSED(hmi_tmp); + } + + subtract_delta = smallest_delta; + sample_count_f= (((float) smallest_delta * samples_per_delta_f) + sample_remainder); + + sample_count = (uint32_t) sample_count_f; + sample_remainder = sample_count_f - (float) sample_count; + + hmi_mdi->events[hmi_mdi->event_count - 1].samples_to_next += sample_count; + hmi_mdi->extra_info.approx_total_samples += sample_count; + } + + if ((hmi_mdi->reverb = _WM_init_reverb(_WM_SampleRate, _WM_reverb_room_width, _WM_reverb_room_length, _WM_reverb_listen_posx, _WM_reverb_listen_posy)) == NULL) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, ""to init reverb"", 0); + goto _hmi_end; + } + + hmi_mdi->extra_info.current_sample = 0; + hmi_mdi->current_event = &hmi_mdi->events[0]; + hmi_mdi->samples_to_mix = 0; + hmi_mdi->note = NULL; + + _WM_ResetToStart(hmi_mdi); + +_hmi_end: + free(hmi_track_offset); + free(hmi_track_header_length); + free(hmi_track_end); + free(hmi_delta); + free(note); + free(hmi_running_event); + + if (hmi_mdi->reverb) return (hmi_mdi); + _WM_freeMDI(hmi_mdi); + return 0; +} +",1," _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + uint32_t hmi_tmp = 0; + uint8_t *hmi_base = hmi_data; + uint32_t data_siz; + uint16_t hmi_bpm = 0; + uint16_t hmi_division = 0; + + uint32_t *hmi_track_offset = NULL; + uint32_t i = 0; + uint32_t j = 0; + uint8_t *hmi_addr = NULL; + uint32_t *hmi_track_header_length = NULL; + struct _mdi *hmi_mdi = NULL; + uint32_t tempo_f = 5000000.0; + uint32_t *hmi_track_end = NULL; + uint8_t hmi_tracks_ended = 0; + uint8_t *hmi_running_event = NULL; + uint32_t setup_ret = 0; + uint32_t *hmi_delta = NULL; + + uint32_t smallest_delta = 0; + uint32_t subtract_delta = 0; + + uint32_t sample_count = 0; + float sample_count_f = 0; + float sample_remainder = 0; + + float samples_per_delta_f = 0.0; + + struct _note { + uint32_t length; + uint8_t channel; + } *note; + + + if (memcmp(hmi_data, ""HMI-MIDISONG061595"", 18)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, NULL, 0); + return NULL; + } + + hmi_bpm = hmi_data[212]; + + hmi_division = 60; + + hmi_track_cnt = hmi_data[228]; + + hmi_mdi = _WM_initMDI(); + + _WM_midi_setup_divisions(hmi_mdi, hmi_division); + + if ((_WM_MixerOptions & WM_MO_ROUNDTEMPO)) { + tempo_f = (float) (60000000 / hmi_bpm) + 0.5f; + } else { + tempo_f = (float) (60000000 / hmi_bpm); + } + samples_per_delta_f = _WM_GetSamplesPerTick(hmi_division, (uint32_t)tempo_f); + + _WM_midi_setup_tempo(hmi_mdi, (uint32_t)tempo_f); + + hmi_track_offset = (uint32_t *)malloc(sizeof(uint32_t) * hmi_track_cnt); + hmi_track_header_length = malloc(sizeof(uint32_t) * hmi_track_cnt); + hmi_track_end = malloc(sizeof(uint32_t) * hmi_track_cnt); + hmi_delta = malloc(sizeof(uint32_t) * hmi_track_cnt); + note = malloc(sizeof(struct _note) * 128 * hmi_track_cnt); + hmi_running_event = malloc(sizeof(uint8_t) * 128 * hmi_track_cnt); + + hmi_data += 370; + + smallest_delta = 0xffffffff; + + if (hmi_size < (370 + (hmi_track_cnt * 17))) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + + hmi_track_offset[0] = *hmi_data; // To keep Xcode happy + + for (i = 0; i < hmi_track_cnt; i++) { + hmi_track_offset[i] = *hmi_data++; + hmi_track_offset[i] += (*hmi_data++ << 8); + hmi_track_offset[i] += (*hmi_data++ << 16); + hmi_track_offset[i] += (*hmi_data++ << 24); + + if (hmi_size < (hmi_track_offset[i] + 0x5a + 4)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + + hmi_addr = hmi_base + hmi_track_offset[i]; + + if (memcmp(hmi_addr, ""HMI-MIDITRACK"", 13)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, NULL, 0); + goto _hmi_end; + } + + hmi_track_header_length[i] = hmi_addr[0x57]; + hmi_track_header_length[i] += (hmi_addr[0x58] << 8); + hmi_track_header_length[i] += (hmi_addr[0x59] << 16); + hmi_track_header_length[i] += (hmi_addr[0x5a] << 24); + + hmi_addr += hmi_track_header_length[i]; + hmi_track_offset[i] += hmi_track_header_length[i]; + + hmi_delta[i] = 0; + if (*hmi_addr > 0x7f) { + do { + hmi_delta[i] = (hmi_delta[i] << 7) + (*hmi_addr & 0x7f); + hmi_addr++; + hmi_track_offset[i]++; + } while (*hmi_addr > 0x7f); + } + hmi_delta[i] = (hmi_delta[i] << 7) + (*hmi_addr & 0x7f); + hmi_track_offset[i]++; + hmi_addr++; + + if (hmi_delta[i] < smallest_delta) { + smallest_delta = hmi_delta[i]; + } + + hmi_track_end[i] = 0; + hmi_running_event[i] = 0; + + for (j = 0; j < 128; j++) { + hmi_tmp = (128 * i) + j; + note[hmi_tmp].length = 0; + note[hmi_tmp].channel = 0; + } + } + + subtract_delta = smallest_delta; + sample_count_f= (((float) smallest_delta * samples_per_delta_f) + sample_remainder); + + sample_count = (uint32_t) sample_count_f; + sample_remainder = sample_count_f - (float) sample_count; + + hmi_mdi->events[hmi_mdi->event_count - 1].samples_to_next += sample_count; + hmi_mdi->extra_info.approx_total_samples += sample_count; + + while (hmi_tracks_ended < hmi_track_cnt) { + smallest_delta = 0; + for (i = 0; i < hmi_track_cnt; i++) { + if (hmi_track_end[i]) continue; + + for (j = 0; j < 128; j++) { + hmi_tmp = (128 * i) + j; + if (note[hmi_tmp].length) { + note[hmi_tmp].length -= subtract_delta; + if (note[hmi_tmp].length) { + if ((!smallest_delta) || (smallest_delta > note[hmi_tmp].length)) { + smallest_delta = note[hmi_tmp].length; + } + } else { + _WM_midi_setup_noteoff(hmi_mdi, note[hmi_tmp].channel, j, 0); + } + } + } + + if (hmi_delta[i]) { + hmi_delta[i] -= subtract_delta; + if (hmi_delta[i]) { + if ((!smallest_delta) || (smallest_delta > hmi_delta[i])) { + smallest_delta = hmi_delta[i]; + } + continue; + } + } + + do { + hmi_data = hmi_base + hmi_track_offset[i]; + hmi_delta[i] = 0; + if (hmi_track_offset[i] >= hmi_size) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + data_siz = hmi_size - hmi_track_offset[i]; + + if (hmi_data[0] == 0xfe) { + if (hmi_data[1] == 0x10) { + hmi_tmp = (hmi_data[4] + 5); + hmi_data += hmi_tmp; + hmi_track_offset[i] += hmi_tmp; + hmi_tmp += 4; + } else if (hmi_data[1] == 0x15) { + hmi_data += 4; + hmi_track_offset[i] += 4; + hmi_tmp = 8; + } else { + hmi_tmp = 4; + } + hmi_data += 4; + hmi_track_offset[i] += 4; + if (hmi_tmp > data_siz) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + data_siz -= hmi_tmp; + } else { + if ((setup_ret = _WM_SetupMidiEvent(hmi_mdi,hmi_data,data_siz,hmi_running_event[i])) == 0) { + goto _hmi_end; + } + if ((hmi_data[0] == 0xff) && (hmi_data[1] == 0x2f) && (hmi_data[2] == 0x00)) { + hmi_track_end[i] = 1; + hmi_tracks_ended++; + for(j = 0; j < 128; j++) { + hmi_tmp = (128 * i) + j; + if (note[hmi_tmp].length) { + _WM_midi_setup_noteoff(hmi_mdi, note[hmi_tmp].channel, j, 0); + note[hmi_tmp].length = 0; + } + } + goto _hmi_next_track; + } + if ((*hmi_data == 0xF0) || (*hmi_data == 0xF7)) { + hmi_running_event[i] = 0; + } else if (*hmi_data < 0xF0) { + if (*hmi_data >= 0x80) { + hmi_running_event[i] = *hmi_data; + } + } + if ((hmi_running_event[i] & 0xf0) == 0x90) { + if (*hmi_data > 127) { + hmi_tmp = hmi_data[1]; + } else { + hmi_tmp = *hmi_data; + } + hmi_tmp += (i * 128); + + note[hmi_tmp].channel = hmi_running_event[i] & 0xf; + + hmi_data += setup_ret; + hmi_track_offset[i] += setup_ret; + data_siz -= setup_ret; + + note[hmi_tmp].length = 0; + if (data_siz && *hmi_data > 0x7f) { + do { + if (!data_siz) break; + note[hmi_tmp].length = (note[hmi_tmp].length << 7) | (*hmi_data & 0x7F); + hmi_data++; + data_siz--; + hmi_track_offset[i]++; + } while (*hmi_data > 0x7F); + } + if (!data_siz) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + note[hmi_tmp].length = (note[hmi_tmp].length << 7) | (*hmi_data & 0x7F); + hmi_data++; + data_siz--; + hmi_track_offset[i]++; + + if (note[hmi_tmp].length) { + if ((!smallest_delta) || (smallest_delta > note[hmi_tmp].length)) { + smallest_delta = note[hmi_tmp].length; + } + } else { + _WM_midi_setup_noteoff(hmi_mdi, note[hmi_tmp].channel, j, 0); + } + + } else { + hmi_data += setup_ret; + hmi_track_offset[i] += setup_ret; + data_siz -= setup_ret; + } + } + + if (data_siz && *hmi_data > 0x7f) { + do { + if (!data_siz) break; + hmi_delta[i] = (hmi_delta[i] << 7) | (*hmi_data & 0x7F); + hmi_data++; + data_siz--; + hmi_track_offset[i]++; + } while (*hmi_data > 0x7F); + } + if (!data_siz) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); + goto _hmi_end; + } + hmi_delta[i] = (hmi_delta[i] << 7) | (*hmi_data & 0x7F); + hmi_data++; + data_siz--; + hmi_track_offset[i]++; + } while (!hmi_delta[i]); + if ((!smallest_delta) || (smallest_delta > hmi_delta[i])) { + smallest_delta = hmi_delta[i]; + } + + _hmi_next_track: + hmi_tmp = 0; + UNUSED(hmi_tmp); + } + + subtract_delta = smallest_delta; + sample_count_f= (((float) smallest_delta * samples_per_delta_f) + sample_remainder); + + sample_count = (uint32_t) sample_count_f; + sample_remainder = sample_count_f - (float) sample_count; + + hmi_mdi->events[hmi_mdi->event_count - 1].samples_to_next += sample_count; + hmi_mdi->extra_info.approx_total_samples += sample_count; + } + + if ((hmi_mdi->reverb = _WM_init_reverb(_WM_SampleRate, _WM_reverb_room_width, _WM_reverb_room_length, _WM_reverb_listen_posx, _WM_reverb_listen_posy)) == NULL) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, ""to init reverb"", 0); + goto _hmi_end; + } + + hmi_mdi->extra_info.current_sample = 0; + hmi_mdi->current_event = &hmi_mdi->events[0]; + hmi_mdi->samples_to_mix = 0; + hmi_mdi->note = NULL; + + _WM_ResetToStart(hmi_mdi); + +_hmi_end: + free(hmi_track_offset); + free(hmi_track_header_length); + free(hmi_track_end); + free(hmi_delta); + free(note); + free(hmi_running_event); + + if (hmi_mdi->reverb) return (hmi_mdi); + _WM_freeMDI(hmi_mdi); + return 0; +} +","@@ -42,10 +42,10 @@ struct _mdi * + _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + uint32_t hmi_tmp = 0; + uint8_t *hmi_base = hmi_data; ++ uint32_t data_siz; + uint16_t hmi_bpm = 0; + uint16_t hmi_division = 0; + +-// uint32_t hmi_duration_secs = 0; + uint32_t hmi_track_cnt = 0; + uint32_t *hmi_track_offset = NULL; + uint32_t i = 0; +@@ -74,8 +74,6 @@ _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + uint8_t channel; + } *note; + +- //FIXME: This needs to be used for sanity check. +- UNUSED(hmi_size); + + if (memcmp(hmi_data, ""HMI-MIDISONG061595"", 18)) { + _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, NULL, 0); +@@ -216,21 +214,35 @@ _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + do { + hmi_data = hmi_base + hmi_track_offset[i]; + hmi_delta[i] = 0; ++ if (hmi_track_offset[i] >= hmi_size) { ++ _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); ++ goto _hmi_end; ++ } ++ data_siz = hmi_size - hmi_track_offset[i]; + + if (hmi_data[0] == 0xfe) { + // HMI only event of some sort. + if (hmi_data[1] == 0x10) { + hmi_tmp = (hmi_data[4] + 5); + hmi_data += hmi_tmp; + hmi_track_offset[i] += hmi_tmp; ++ hmi_tmp += 4; + } else if (hmi_data[1] == 0x15) { + hmi_data += 4; + hmi_track_offset[i] += 4; ++ hmi_tmp = 8; ++ } else { ++ hmi_tmp = 4; + } + hmi_data += 4; + hmi_track_offset[i] += 4; ++ if (hmi_tmp > data_siz) { ++ _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); ++ goto _hmi_end; ++ } ++ data_siz -= hmi_tmp; + } else { +- if ((setup_ret = _WM_SetupMidiEvent(hmi_mdi,hmi_data,hmi_running_event[i])) == 0) { ++ if ((setup_ret = _WM_SetupMidiEvent(hmi_mdi,hmi_data,data_siz,hmi_running_event[i])) == 0) { + goto _hmi_end; + } + if ((hmi_data[0] == 0xff) && (hmi_data[1] == 0x2f) && (hmi_data[2] == 0x00)) { +@@ -269,17 +281,25 @@ _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + + hmi_data += setup_ret; + hmi_track_offset[i] += setup_ret; ++ data_siz -= setup_ret; + + note[hmi_tmp].length = 0; +- if (*hmi_data > 0x7f) { ++ if (data_siz && *hmi_data > 0x7f) { + do { ++ if (!data_siz) break; + note[hmi_tmp].length = (note[hmi_tmp].length << 7) | (*hmi_data & 0x7F); + hmi_data++; ++ data_siz--; + hmi_track_offset[i]++; + } while (*hmi_data > 0x7F); + } ++ if (!data_siz) { ++ _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); ++ goto _hmi_end; ++ } + note[hmi_tmp].length = (note[hmi_tmp].length << 7) | (*hmi_data & 0x7F); + hmi_data++; ++ data_siz--; + hmi_track_offset[i]++; + + if (note[hmi_tmp].length) { +@@ -293,20 +313,28 @@ _WM_ParseNewHmi(uint8_t *hmi_data, uint32_t hmi_size) { + } else { + hmi_data += setup_ret; + hmi_track_offset[i] += setup_ret; ++ data_siz -= setup_ret; + } + } + + // get track delta + // hmi_delta[i] = 0; // set at start of loop +- if (*hmi_data > 0x7f) { ++ if (data_siz && *hmi_data > 0x7f) { + do { ++ if (!data_siz) break; + hmi_delta[i] = (hmi_delta[i] << 7) | (*hmi_data & 0x7F); + hmi_data++; ++ data_siz--; + hmi_track_offset[i]++; + } while (*hmi_data > 0x7F); + } ++ if (!data_siz) { ++ _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_HMI, ""file too short"", 0); ++ goto _hmi_end; ++ } + hmi_delta[i] = (hmi_delta[i] << 7) | (*hmi_data & 0x7F); + hmi_data++; ++ data_siz--; + hmi_track_offset[i]++; + } while (!hmi_delta[i]); + if ((!smallest_delta) || (smallest_delta > hmi_delta[i])) {",2991,3227,4096 +5170,"zisofs_read_data(struct archive_read *a, + const void **buff, size_t *size, int64_t *offset) +{ + struct iso9660 *iso9660; + struct zisofs *zisofs; + const unsigned char *p; + size_t avail; + ssize_t bytes_read; + size_t uncompressed_size; + int r; + + iso9660 = (struct iso9660 *)(a->format->data); + zisofs = &iso9660->entry_zisofs; + + p = __archive_read_ahead(a, 1, &bytes_read); + if (bytes_read <= 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Truncated zisofs file body""); + return (ARCHIVE_FATAL); + } + if (bytes_read > iso9660->entry_bytes_remaining) + bytes_read = (ssize_t)iso9660->entry_bytes_remaining; + avail = bytes_read; + uncompressed_size = 0; + + if (!zisofs->initialized) { + size_t ceil, xsize; + + /* Allocate block pointers buffer. */ + ceil = (size_t)((zisofs->pz_uncompressed_size + + (((int64_t)1) << zisofs->pz_log2_bs) - 1) + >> zisofs->pz_log2_bs); + xsize = (ceil + 1) * 4; + if (zisofs->block_pointers_alloc < xsize) { + size_t alloc; + + if (zisofs->block_pointers != NULL) + free(zisofs->block_pointers); + alloc = ((xsize >> 10) + 1) << 10; + zisofs->block_pointers = malloc(alloc); + if (zisofs->block_pointers == NULL) { + archive_set_error(&a->archive, ENOMEM, + ""No memory for zisofs decompression""); + return (ARCHIVE_FATAL); + } + zisofs->block_pointers_alloc = alloc; + } + zisofs->block_pointers_size = xsize; + + /* Allocate uncompressed data buffer. */ + xsize = (size_t)1UL << zisofs->pz_log2_bs; + if (zisofs->uncompressed_buffer_size < xsize) { + if (zisofs->uncompressed_buffer != NULL) + free(zisofs->uncompressed_buffer); + zisofs->uncompressed_buffer = malloc(xsize); + if (zisofs->uncompressed_buffer == NULL) { + archive_set_error(&a->archive, ENOMEM, + ""No memory for zisofs decompression""); + return (ARCHIVE_FATAL); + } + } + zisofs->uncompressed_buffer_size = xsize; + + /* + * Read the file header, and check the magic code of zisofs. + */ + if (zisofs->header_avail < sizeof(zisofs->header)) { + xsize = sizeof(zisofs->header) - zisofs->header_avail; + if (avail < xsize) + xsize = avail; + memcpy(zisofs->header + zisofs->header_avail, p, xsize); + zisofs->header_avail += xsize; + avail -= xsize; + p += xsize; + } + if (!zisofs->header_passed && + zisofs->header_avail == sizeof(zisofs->header)) { + int err = 0; + + if (memcmp(zisofs->header, zisofs_magic, + sizeof(zisofs_magic)) != 0) + err = 1; + if (archive_le32dec(zisofs->header + 8) + != zisofs->pz_uncompressed_size) + err = 1; + if (zisofs->header[12] != 4) + err = 1; + if (zisofs->header[13] != zisofs->pz_log2_bs) + err = 1; + if (err) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs file body""); + return (ARCHIVE_FATAL); + } + zisofs->header_passed = 1; + } + /* + * Read block pointers. + */ + if (zisofs->header_passed && + zisofs->block_pointers_avail < zisofs->block_pointers_size) { + xsize = zisofs->block_pointers_size + - zisofs->block_pointers_avail; + if (avail < xsize) + xsize = avail; + memcpy(zisofs->block_pointers + + zisofs->block_pointers_avail, p, xsize); + zisofs->block_pointers_avail += xsize; + avail -= xsize; + p += xsize; + if (zisofs->block_pointers_avail + == zisofs->block_pointers_size) { + /* We've got all block pointers and initialize + * related variables. */ + zisofs->block_off = 0; + zisofs->block_avail = 0; + /* Complete a initialization */ + zisofs->initialized = 1; + } + } + + if (!zisofs->initialized) + goto next_data; /* We need more data. */ + } + + /* + * Get block offsets from block pointers. + */ + if (zisofs->block_avail == 0) { + uint32_t bst, bed; + + if (zisofs->block_off + 4 >= zisofs->block_pointers_size) { + /* There isn't a pair of offsets. */ + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs block pointers""); + return (ARCHIVE_FATAL); + } + bst = archive_le32dec( + zisofs->block_pointers + zisofs->block_off); + if (bst != zisofs->pz_offset + (bytes_read - avail)) { + /* TODO: Should we seek offset of current file + * by bst ? */ + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs block pointers(cannot seek)""); + return (ARCHIVE_FATAL); + } + bed = archive_le32dec( + zisofs->block_pointers + zisofs->block_off + 4); + if (bed < bst) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs block pointers""); + return (ARCHIVE_FATAL); + } + zisofs->block_avail = bed - bst; + zisofs->block_off += 4; + + /* Initialize compression library for new block. */ + if (zisofs->stream_valid) + r = inflateReset(&zisofs->stream); + else + r = inflateInit(&zisofs->stream); + if (r != Z_OK) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Can't initialize zisofs decompression.""); + return (ARCHIVE_FATAL); + } + zisofs->stream_valid = 1; + zisofs->stream.total_in = 0; + zisofs->stream.total_out = 0; + } + + /* + * Make uncompressed data. + */ + if (zisofs->block_avail == 0) { + memset(zisofs->uncompressed_buffer, 0, + zisofs->uncompressed_buffer_size); + uncompressed_size = zisofs->uncompressed_buffer_size; + } else { + zisofs->stream.next_in = (Bytef *)(uintptr_t)(const void *)p; + if (avail > zisofs->block_avail) + zisofs->stream.avail_in = zisofs->block_avail; + else + zisofs->stream.avail_in = (uInt)avail; + zisofs->stream.next_out = zisofs->uncompressed_buffer; + zisofs->stream.avail_out = + (uInt)zisofs->uncompressed_buffer_size; + + r = inflate(&zisofs->stream, 0); + switch (r) { + case Z_OK: /* Decompressor made some progress.*/ + case Z_STREAM_END: /* Found end of stream. */ + break; + default: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""zisofs decompression failed (%d)"", r); + return (ARCHIVE_FATAL); + } + uncompressed_size = + zisofs->uncompressed_buffer_size - zisofs->stream.avail_out; + avail -= zisofs->stream.next_in - p; + zisofs->block_avail -= (uint32_t)(zisofs->stream.next_in - p); + } +next_data: + bytes_read -= avail; + *buff = zisofs->uncompressed_buffer; + *size = uncompressed_size; + *offset = iso9660->entry_sparse_offset; + iso9660->entry_sparse_offset += uncompressed_size; + iso9660->entry_bytes_remaining -= bytes_read; + iso9660->current_position += bytes_read; + zisofs->pz_offset += (uint32_t)bytes_read; + iso9660->entry_bytes_unconsumed += bytes_read; + + return (ARCHIVE_OK); +} +",0,"zisofs_read_data(struct archive_read *a, + const void **buff, size_t *size, int64_t *offset) +{ + struct iso9660 *iso9660; + struct zisofs *zisofs; + const unsigned char *p; + size_t avail; + ssize_t bytes_read; + size_t uncompressed_size; + int r; + + iso9660 = (struct iso9660 *)(a->format->data); + zisofs = &iso9660->entry_zisofs; + + p = __archive_read_ahead(a, 1, &bytes_read); + if (bytes_read <= 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + ""Truncated zisofs file body""); + return (ARCHIVE_FATAL); + } + if (bytes_read > iso9660->entry_bytes_remaining) + bytes_read = (ssize_t)iso9660->entry_bytes_remaining; + avail = bytes_read; + uncompressed_size = 0; + + if (!zisofs->initialized) { + size_t ceil, xsize; + + /* Allocate block pointers buffer. */ + ceil = (size_t)((zisofs->pz_uncompressed_size + + (((int64_t)1) << zisofs->pz_log2_bs) - 1) + >> zisofs->pz_log2_bs); + xsize = (ceil + 1) * 4; + if (zisofs->block_pointers_alloc < xsize) { + size_t alloc; + + if (zisofs->block_pointers != NULL) + free(zisofs->block_pointers); + alloc = ((xsize >> 10) + 1) << 10; + zisofs->block_pointers = malloc(alloc); + if (zisofs->block_pointers == NULL) { + archive_set_error(&a->archive, ENOMEM, + ""No memory for zisofs decompression""); + return (ARCHIVE_FATAL); + } + zisofs->block_pointers_alloc = alloc; + } + zisofs->block_pointers_size = xsize; + + /* Allocate uncompressed data buffer. */ + xsize = (size_t)1UL << zisofs->pz_log2_bs; + if (zisofs->uncompressed_buffer_size < xsize) { + if (zisofs->uncompressed_buffer != NULL) + free(zisofs->uncompressed_buffer); + zisofs->uncompressed_buffer = malloc(xsize); + if (zisofs->uncompressed_buffer == NULL) { + archive_set_error(&a->archive, ENOMEM, + ""No memory for zisofs decompression""); + return (ARCHIVE_FATAL); + } + } + zisofs->uncompressed_buffer_size = xsize; + + /* + * Read the file header, and check the magic code of zisofs. + */ + if (zisofs->header_avail < sizeof(zisofs->header)) { + xsize = sizeof(zisofs->header) - zisofs->header_avail; + if (avail < xsize) + xsize = avail; + memcpy(zisofs->header + zisofs->header_avail, p, xsize); + zisofs->header_avail += xsize; + avail -= xsize; + p += xsize; + } + if (!zisofs->header_passed && + zisofs->header_avail == sizeof(zisofs->header)) { + int err = 0; + + if (memcmp(zisofs->header, zisofs_magic, + sizeof(zisofs_magic)) != 0) + err = 1; + if (archive_le32dec(zisofs->header + 8) + != zisofs->pz_uncompressed_size) + err = 1; + if (zisofs->header[12] != 4) + err = 1; + if (zisofs->header[13] != zisofs->pz_log2_bs) + err = 1; + if (err) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs file body""); + return (ARCHIVE_FATAL); + } + zisofs->header_passed = 1; + } + /* + * Read block pointers. + */ + if (zisofs->header_passed && + zisofs->block_pointers_avail < zisofs->block_pointers_size) { + xsize = zisofs->block_pointers_size + - zisofs->block_pointers_avail; + if (avail < xsize) + xsize = avail; + memcpy(zisofs->block_pointers + + zisofs->block_pointers_avail, p, xsize); + zisofs->block_pointers_avail += xsize; + avail -= xsize; + p += xsize; + if (zisofs->block_pointers_avail + == zisofs->block_pointers_size) { + /* We've got all block pointers and initialize + * related variables. */ + zisofs->block_off = 0; + zisofs->block_avail = 0; + /* Complete a initialization */ + zisofs->initialized = 1; + } + } + + if (!zisofs->initialized) + goto next_data; /* We need more data. */ + } + + /* + * Get block offsets from block pointers. + */ + if (zisofs->block_avail == 0) { + uint32_t bst, bed; + + if (zisofs->block_off + 4 >= zisofs->block_pointers_size) { + /* There isn't a pair of offsets. */ + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs block pointers""); + return (ARCHIVE_FATAL); + } + bst = archive_le32dec( + zisofs->block_pointers + zisofs->block_off); + if (bst != zisofs->pz_offset + (bytes_read - avail)) { + /* TODO: Should we seek offset of current file + * by bst ? */ + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs block pointers(cannot seek)""); + return (ARCHIVE_FATAL); + } + bed = archive_le32dec( + zisofs->block_pointers + zisofs->block_off + 4); + if (bed < bst) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + ""Illegal zisofs block pointers""); + return (ARCHIVE_FATAL); + } + zisofs->block_avail = bed - bst; + zisofs->block_off += 4; + + /* Initialize compression library for new block. */ + if (zisofs->stream_valid) + r = inflateReset(&zisofs->stream); + else + r = inflateInit(&zisofs->stream); + if (r != Z_OK) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""Can't initialize zisofs decompression.""); + return (ARCHIVE_FATAL); + } + zisofs->stream_valid = 1; + zisofs->stream.total_in = 0; + zisofs->stream.total_out = 0; + } + + /* + * Make uncompressed data. + */ + if (zisofs->block_avail == 0) { + memset(zisofs->uncompressed_buffer, 0, + zisofs->uncompressed_buffer_size); + uncompressed_size = zisofs->uncompressed_buffer_size; + } else { + zisofs->stream.next_in = (Bytef *)(uintptr_t)(const void *)p; + if (avail > zisofs->block_avail) + zisofs->stream.avail_in = zisofs->block_avail; + else + zisofs->stream.avail_in = (uInt)avail; + zisofs->stream.next_out = zisofs->uncompressed_buffer; + zisofs->stream.avail_out = + (uInt)zisofs->uncompressed_buffer_size; + + r = inflate(&zisofs->stream, 0); + switch (r) { + case Z_OK: /* Decompressor made some progress.*/ + case Z_STREAM_END: /* Found end of stream. */ + break; + default: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + ""zisofs decompression failed (%d)"", r); + return (ARCHIVE_FATAL); + } + uncompressed_size = + zisofs->uncompressed_buffer_size - zisofs->stream.avail_out; + avail -= zisofs->stream.next_in - p; + zisofs->block_avail -= (uint32_t)(zisofs->stream.next_in - p); + } +next_data: + bytes_read -= avail; + *buff = zisofs->uncompressed_buffer; + *size = uncompressed_size; + *offset = iso9660->entry_sparse_offset; + iso9660->entry_sparse_offset += uncompressed_size; + iso9660->entry_bytes_remaining -= bytes_read; + iso9660->current_position += bytes_read; + zisofs->pz_offset += (uint32_t)bytes_read; + iso9660->entry_bytes_unconsumed += bytes_read; + + return (ARCHIVE_OK); +} +","@@ -1091,7 +1091,7 @@ choose_volume(struct archive_read *a, struct iso9660 *iso9660) + /* This condition is unlikely; by way of caution. */ + vd = &(iso9660->joliet); + +- skipsize = LOGICAL_BLOCK_SIZE * vd->location; ++ skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location; + skipsize = __archive_read_consume(a, skipsize); + if (skipsize < 0) + return ((int)skipsize); +@@ -1129,7 +1129,7 @@ choose_volume(struct archive_read *a, struct iso9660 *iso9660) + && iso9660->seenJoliet) { + /* Switch reading data from primary to joliet. */ + vd = &(iso9660->joliet); +- skipsize = LOGICAL_BLOCK_SIZE * vd->location; ++ skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location; + skipsize -= iso9660->current_position; + skipsize = __archive_read_consume(a, skipsize); + if (skipsize < 0)",2068,2304,4096 +18227,"static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct minidump_directory *entry) { + int i; + + struct minidump_handle_operation_list *handle_operation_list; + struct minidump_memory_list *memory_list; + struct minidump_memory64_list *memory64_list; + struct minidump_memory_info_list *memory_info_list; + struct minidump_module_list *module_list; + struct minidump_thread_list *thread_list; + struct minidump_thread_ex_list *thread_ex_list; + struct minidump_thread_info_list *thread_info_list; + struct minidump_unloaded_module_list *unloaded_module_list; + + struct avrf_handle_operation *handle_operations; + struct minidump_memory_descriptor *memories; + struct minidump_memory_descriptor64 *memories64; + struct minidump_memory_info *memory_infos; + struct minidump_module *modules; + struct minidump_thread *threads; + struct minidump_thread_ex *ex_threads; + struct minidump_thread_info *thread_infos; + struct minidump_unloaded_module *unloaded_modules; + + /* We could confirm data sizes but a malcious MDMP will always get around + ** this! But we can ensure that the data is not outside of the file */ + if (entry->location.rva + entry->location.data_size > obj->b->length) { + eprintf(""[ERROR] Size Mismatch - Stream data is larger than file size!\n""); + return false; + } + + switch (entry->stream_type) { + case THREAD_LIST_STREAM: + thread_list = (struct minidump_thread_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_thread.format"", ""ddddq?? "" + ""ThreadId SuspendCount PriorityClass Priority "" + ""Teb (mdmp_memory_descriptor)Stack "" + ""(mdmp_location_descriptor)ThreadContext"", 0); + sdb_num_set (obj->kv, ""mdmp_thread_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_thread_list.format"", + sdb_fmt (""d[%i]? "" + ""NumberOfThreads (mdmp_thread)Threads"", + thread_list->number_of_threads), + 0); + + /* TODO: Not yet fully parsed or utilised */ + for (i = 0; i < thread_list->number_of_threads; i++) { + threads = (struct minidump_thread *)(&(thread_list->threads)); + r_list_append (obj->streams.threads, &(threads[i])); + } + break; + case MODULE_LIST_STREAM: + module_list = (struct minidump_module_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_module.format"", ""qddtd???qq "" + ""BaseOfImage SizeOfImage CheckSum "" + ""TimeDateStamp ModuleNameRVA "" + ""(mdmp_vs_fixedfileinfo)VersionInfo "" + ""(mdmp_location_descriptor)CvRecord "" + ""(mdmp_location_descriptor)MiscRecord "" + ""Reserved0 Reserved1"", 0); + sdb_num_set (obj->kv, ""mdmp_module_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_module_list.format"", + sdb_fmt (""d[%i]? "" + ""NumberOfModule (mdmp_module)Modules"", + module_list->number_of_modules, + 0), + 0); + + for (i = 0; i < module_list->number_of_modules; i++) { + modules = (struct minidump_module *)(&(module_list->modules)); + r_list_append(obj->streams.modules, &(modules[i])); + } + break; + case MEMORY_LIST_STREAM: + memory_list = (struct minidump_memory_list *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_memory_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_memory_list.format"", + sdb_fmt (""d[%i]? "" + ""NumberOfMemoryRanges "" + ""(mdmp_memory_descriptor)MemoryRanges "", + memory_list->number_of_memory_ranges, + 0), + 0); + + for (i = 0; i < memory_list->number_of_memory_ranges; i++) { + memories = (struct minidump_memory_descriptor *)(&(memory_list->memory_ranges)); + r_list_append (obj->streams.memories, &(memories[i])); + } + break; + case EXCEPTION_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.exception = (struct minidump_exception_stream *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_exception.format"", ""[4]E[4]Eqqdd[15]q "" + ""(mdmp_exception_code)ExceptionCode "" + ""(mdmp_exception_flags)ExceptionFlags "" + ""ExceptionRecord ExceptionAddress "" + ""NumberParameters __UnusedAlignment "" + ""ExceptionInformation"", 0); + sdb_num_set (obj->kv, ""mdmp_exception_stream.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_exception_stream.format"", ""dd?? "" + ""ThreadId __Alignment "" + ""(mdmp_exception)ExceptionRecord "" + ""(mdmp_location_descriptor)ThreadContext"", 0); + + break; + case SYSTEM_INFO_STREAM: + obj->streams.system_info = (struct minidump_system_info *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_system_info.offset"", + entry->location.rva, 0); + /* TODO: We need E as a byte! */ + sdb_set (obj->kv, ""mdmp_system_info.format"", ""[2]EwwbBddd[4]Ed[2]Ew[2]q "" + ""(mdmp_processor_architecture)ProcessorArchitecture "" + ""ProcessorLevel ProcessorRevision NumberOfProcessors "" + ""(mdmp_product_type)ProductType "" + ""MajorVersion MinorVersion BuildNumber (mdmp_platform_id)PlatformId "" + ""CsdVersionRva (mdmp_suite_mask)SuiteMask Reserved2 ProcessorFeatures"", 0); + + break; + case THREAD_EX_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + thread_ex_list = (struct minidump_thread_ex_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_thread_ex.format"", ""ddddq??? "" + ""ThreadId SuspendCount PriorityClass Priority "" + ""Teb (mdmp_memory_descriptor)Stack "" + ""(mdmp_location_descriptor)ThreadContext "" + ""(mdmp_memory_descriptor)BackingStore"", 0); + sdb_num_set (obj->kv, ""mdmp_thread_ex_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_thread_ex_list.format"", + sdb_fmt (""d[%i]? NumberOfThreads "" + ""(mdmp_thread_ex)Threads"", + thread_ex_list->number_of_threads, 0), + 0); + + for (i = 0; i < thread_ex_list->number_of_threads; i++) { + ex_threads = (struct minidump_thread_ex *)(&(thread_ex_list->threads)); + r_list_append (obj->streams.ex_threads, &(ex_threads[i])); + } + break; + case MEMORY_64_LIST_STREAM: + memory64_list = (struct minidump_memory64_list *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_memory64_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_memory64_list.format"", + sdb_fmt (""qq[%i]? NumberOfMemoryRanges "" + ""BaseRva "" + ""(mdmp_memory_descriptor64)MemoryRanges"", + memory64_list->number_of_memory_ranges), + 0); + + obj->streams.memories64.base_rva = memory64_list->base_rva; + for (i = 0; i < memory64_list->number_of_memory_ranges; i++) { + memories64 = (struct minidump_memory_descriptor64 *)(&(memory64_list->memory_ranges)); + r_list_append (obj->streams.memories64.memories, &(memories64[i])); + } + break; + case COMMENT_STREAM_A: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.comments_a = obj->b->buf + entry->location.rva; + + sdb_num_set (obj->kv, ""mdmp_comment_stream_a.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_comment_stream_a.format"", + ""s CommentA"", 0); + + break; + case COMMENT_STREAM_W: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.comments_w = obj->b->buf + entry->location.rva; + + sdb_num_set (obj->kv, ""mdmp_comment_stream_w.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_comment_stream_w.format"", + ""s CommentW"", 0); + + break; + case HANDLE_DATA_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.handle_data = (struct minidump_handle_data_stream *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_handle_data_stream.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_handle_data_stream.format"", ""dddd "" + ""SizeOfHeader SizeOfDescriptor "" + ""NumberOfDescriptors Reserved"", 0); + break; + case FUNCTION_TABLE_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.function_table = (struct minidump_function_table_stream *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_function_table_stream.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_function_table_stream.format"", ""dddddd "" + ""SizeOfHeader SizeOfDescriptor SizeOfNativeDescriptor "" + ""SizeOfFunctionEntry NumberOfDescriptors SizeOfAlignPad"", + 0); + break; + case UNLOADED_MODULE_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + unloaded_module_list = (struct minidump_unloaded_module_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_unloaded_module.format"", ""qddtd "" + ""BaseOfImage SizeOfImage CheckSum TimeDateStamp "" + ""ModuleNameRva"", 0); + sdb_num_set (obj->kv, ""mdmp_unloaded_module_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_unloaded_module_list.format"", ""ddd "" + ""SizeOfHeader SizeOfEntry NumberOfEntries"", 0); + + for (i = 0; i < unloaded_module_list->number_of_entries; i++) { + unloaded_modules = (struct minidump_unloaded_module *)((ut8 *)&unloaded_module_list + sizeof (struct minidump_unloaded_module_list)); + r_list_append (obj->streams.unloaded_modules, &(unloaded_modules[i])); + } + break; + case MISC_INFO_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.misc_info.misc_info_1 = (struct minidump_misc_info *)(obj->b->buf + entry->location.rva); + + /* TODO: Handle different sizes */ + sdb_num_set (obj->kv, ""mdmp_misc_info.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_misc_info.format"", ""d[4]Bdtttddddd "" + ""SizeOfInfo (mdmp_misc1_flags)Flags1 ProcessId "" + ""ProcessCreateTime ProcessUserTime ProcessKernelTime "" + ""ProcessorMaxMhz ProcessorCurrentMhz "" + ""ProcessorMhzLimit ProcessorMaxIdleState "" + ""ProcessorCurrentIdleState"", 0); + + break; + case MEMORY_INFO_LIST_STREAM: + memory_info_list = (struct minidump_memory_info_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_memory_info.format"", + ""qq[4]Edq[4]E[4]E[4]Ed BaseAddress AllocationBase "" + ""(mdmp_page_protect)AllocationProtect __Alignment1 RegionSize "" + ""(mdmp_mem_state)State (mdmp_page_protect)Protect "" + ""(mdmp_mem_type)Type __Alignment2"", 0); + sdb_num_set (obj->kv, ""mdmp_memory_info_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_memory_info_list.format"", + sdb_fmt (""ddq[%i]? SizeOfHeader SizeOfEntry "" + ""NumberOfEntries (mdmp_memory_info)MemoryInfo"", + memory_info_list->number_of_entries), + 0); + + for (i = 0; i < memory_info_list->number_of_entries; i++) { + memory_infos = (struct minidump_memory_info *)((ut8 *)memory_info_list + sizeof (struct minidump_memory_info_list)); + r_list_append (obj->streams.memory_infos, &(memory_infos[i])); + } + break; + case THREAD_INFO_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + thread_info_list = (struct minidump_thread_info_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_thread_info.format"", ""ddddttttqq "" + ""ThreadId DumpFlags DumpError ExitStatus CreateTime "" + ""ExitTime KernelTime UserTime StartAddress Affinity"", + 0); + sdb_num_set (obj->kv, ""mdmp_thread_info_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_thread_info_list.format"", ""ddd "" + ""SizeOfHeader SizeOfEntry NumberOfEntries"", 0); + + for (i = 0; i < thread_info_list->number_of_entries; i++) { + thread_infos = (struct minidump_thread_info *)((ut8 *)thread_info_list + sizeof (struct minidump_thread_info_list)); + r_list_append (obj->streams.thread_infos, &(thread_infos[i])); + } + break; + case HANDLE_OPERATION_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + handle_operation_list = (struct minidump_handle_operation_list *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_handle_operation_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_handle_operation_list.format"", ""dddd "" + ""SizeOfHeader SizeOfEntry NumberOfEntries Reserved"", 0); + + for (i = 0; i < handle_operation_list->number_of_entries; i++) { + handle_operations = (struct avrf_handle_operation *)((ut8 *)handle_operation_list + sizeof (struct minidump_handle_operation_list)); + r_list_append (obj->streams.operations, &(handle_operations[i])); + } + + break; + case LAST_RESERVED_STREAM: + /* TODO: Not yet fully parsed or utilised */ + break; + case UNUSED_STREAM: + case RESERVED_STREAM_0: + case RESERVED_STREAM_1: + /* Silently ignore reserved streams */ + break; + default: + eprintf (""[WARN] Invalid or unsupported enumeration encountered %i\n"", entry->stream_type); + return false; + } + return true; +} +",1,"static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct minidump_directory *entry) { + int i; + + struct minidump_handle_operation_list *handle_operation_list; + struct minidump_memory_list *memory_list; + struct minidump_memory64_list *memory64_list; + struct minidump_memory_info_list *memory_info_list; + struct minidump_module_list *module_list; + struct minidump_thread_list *thread_list; + struct minidump_thread_ex_list *thread_ex_list; + struct minidump_thread_info_list *thread_info_list; + struct minidump_unloaded_module_list *unloaded_module_list; + + struct avrf_handle_operation *handle_operations; + struct minidump_memory_descriptor *memories; + struct minidump_memory_descriptor64 *memories64; + struct minidump_memory_info *memory_infos; + struct minidump_module *modules; + struct minidump_thread *threads; + struct minidump_thread_ex *ex_threads; + struct minidump_thread_info *thread_infos; + struct minidump_unloaded_module *unloaded_modules; + + /* We could confirm data sizes but a malcious MDMP will always get around + ** this! But we can ensure that the data is not outside of the file */ + if (entry->location.rva + entry->location.data_size > obj->b->length) { + eprintf (""[ERROR] Size Mismatch - Stream data is larger than file size!\n""); + return false; + } + + switch (entry->stream_type) { + case THREAD_LIST_STREAM: + thread_list = (struct minidump_thread_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_thread.format"", ""ddddq?? "" + ""ThreadId SuspendCount PriorityClass Priority "" + ""Teb (mdmp_memory_descriptor)Stack "" + ""(mdmp_location_descriptor)ThreadContext"", 0); + sdb_num_set (obj->kv, ""mdmp_thread_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_thread_list.format"", + sdb_fmt (""d[%i]? "" + ""NumberOfThreads (mdmp_thread)Threads"", + thread_list->number_of_threads), + 0); + + /* TODO: Not yet fully parsed or utilised */ + for (i = 0; i < thread_list->number_of_threads; i++) { + threads = (struct minidump_thread *)(&(thread_list->threads)); + r_list_append (obj->streams.threads, &(threads[i])); + } + break; + case MODULE_LIST_STREAM: + module_list = (struct minidump_module_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_module.format"", ""qddtd???qq "" + ""BaseOfImage SizeOfImage CheckSum "" + ""TimeDateStamp ModuleNameRVA "" + ""(mdmp_vs_fixedfileinfo)VersionInfo "" + ""(mdmp_location_descriptor)CvRecord "" + ""(mdmp_location_descriptor)MiscRecord "" + ""Reserved0 Reserved1"", 0); + sdb_num_set (obj->kv, ""mdmp_module_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_module_list.format"", + sdb_fmt (""d[%i]? "" + ""NumberOfModule (mdmp_module)Modules"", + module_list->number_of_modules, + 0), + 0); + + for (i = 0; i < module_list->number_of_modules; i++) { + modules = (struct minidump_module *)(&(module_list->modules)); + r_list_append(obj->streams.modules, &(modules[i])); + } + break; + case MEMORY_LIST_STREAM: + memory_list = (struct minidump_memory_list *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_memory_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_memory_list.format"", + sdb_fmt (""d[%i]? "" + ""NumberOfMemoryRanges "" + ""(mdmp_memory_descriptor)MemoryRanges "", + memory_list->number_of_memory_ranges, + 0), + 0); + + for (i = 0; i < memory_list->number_of_memory_ranges; i++) { + memories = (struct minidump_memory_descriptor *)(&(memory_list->memory_ranges)); + r_list_append (obj->streams.memories, &(memories[i])); + } + break; + case EXCEPTION_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.exception = (struct minidump_exception_stream *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_exception.format"", ""[4]E[4]Eqqdd[15]q "" + ""(mdmp_exception_code)ExceptionCode "" + ""(mdmp_exception_flags)ExceptionFlags "" + ""ExceptionRecord ExceptionAddress "" + ""NumberParameters __UnusedAlignment "" + ""ExceptionInformation"", 0); + sdb_num_set (obj->kv, ""mdmp_exception_stream.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_exception_stream.format"", ""dd?? "" + ""ThreadId __Alignment "" + ""(mdmp_exception)ExceptionRecord "" + ""(mdmp_location_descriptor)ThreadContext"", 0); + + break; + case SYSTEM_INFO_STREAM: + obj->streams.system_info = (struct minidump_system_info *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_system_info.offset"", + entry->location.rva, 0); + /* TODO: We need E as a byte! */ + sdb_set (obj->kv, ""mdmp_system_info.format"", ""[2]EwwbBddd[4]Ed[2]Ew[2]q "" + ""(mdmp_processor_architecture)ProcessorArchitecture "" + ""ProcessorLevel ProcessorRevision NumberOfProcessors "" + ""(mdmp_product_type)ProductType "" + ""MajorVersion MinorVersion BuildNumber (mdmp_platform_id)PlatformId "" + ""CsdVersionRva (mdmp_suite_mask)SuiteMask Reserved2 ProcessorFeatures"", 0); + + break; + case THREAD_EX_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + thread_ex_list = (struct minidump_thread_ex_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_thread_ex.format"", ""ddddq??? "" + ""ThreadId SuspendCount PriorityClass Priority "" + ""Teb (mdmp_memory_descriptor)Stack "" + ""(mdmp_location_descriptor)ThreadContext "" + ""(mdmp_memory_descriptor)BackingStore"", 0); + sdb_num_set (obj->kv, ""mdmp_thread_ex_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_thread_ex_list.format"", + sdb_fmt (""d[%i]? NumberOfThreads "" + ""(mdmp_thread_ex)Threads"", + thread_ex_list->number_of_threads, 0), + 0); + + for (i = 0; i < thread_ex_list->number_of_threads; i++) { + ex_threads = (struct minidump_thread_ex *)(&(thread_ex_list->threads)); + r_list_append (obj->streams.ex_threads, &(ex_threads[i])); + } + break; + case MEMORY_64_LIST_STREAM: + memory64_list = (struct minidump_memory64_list *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_memory64_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_memory64_list.format"", + sdb_fmt (""qq[%i]? NumberOfMemoryRanges "" + ""BaseRva "" + ""(mdmp_memory_descriptor64)MemoryRanges"", + memory64_list->number_of_memory_ranges), + 0); + + obj->streams.memories64.base_rva = memory64_list->base_rva; + for (i = 0; i < memory64_list->number_of_memory_ranges; i++) { + memories64 = (struct minidump_memory_descriptor64 *)(&(memory64_list->memory_ranges)); + r_list_append (obj->streams.memories64.memories, &(memories64[i])); + } + break; + case COMMENT_STREAM_A: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.comments_a = obj->b->buf + entry->location.rva; + + sdb_num_set (obj->kv, ""mdmp_comment_stream_a.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_comment_stream_a.format"", + ""s CommentA"", 0); + + break; + case COMMENT_STREAM_W: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.comments_w = obj->b->buf + entry->location.rva; + + sdb_num_set (obj->kv, ""mdmp_comment_stream_w.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_comment_stream_w.format"", + ""s CommentW"", 0); + + break; + case HANDLE_DATA_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.handle_data = (struct minidump_handle_data_stream *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_handle_data_stream.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_handle_data_stream.format"", ""dddd "" + ""SizeOfHeader SizeOfDescriptor "" + ""NumberOfDescriptors Reserved"", 0); + break; + case FUNCTION_TABLE_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.function_table = (struct minidump_function_table_stream *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_function_table_stream.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_function_table_stream.format"", ""dddddd "" + ""SizeOfHeader SizeOfDescriptor SizeOfNativeDescriptor "" + ""SizeOfFunctionEntry NumberOfDescriptors SizeOfAlignPad"", + 0); + break; + case UNLOADED_MODULE_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + unloaded_module_list = (struct minidump_unloaded_module_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_unloaded_module.format"", ""qddtd "" + ""BaseOfImage SizeOfImage CheckSum TimeDateStamp "" + ""ModuleNameRva"", 0); + sdb_num_set (obj->kv, ""mdmp_unloaded_module_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_unloaded_module_list.format"", ""ddd "" + ""SizeOfHeader SizeOfEntry NumberOfEntries"", 0); + + for (i = 0; i < unloaded_module_list->number_of_entries; i++) { + unloaded_modules = (struct minidump_unloaded_module *)((ut8 *)&unloaded_module_list + sizeof (struct minidump_unloaded_module_list)); + r_list_append (obj->streams.unloaded_modules, &(unloaded_modules[i])); + } + break; + case MISC_INFO_STREAM: + /* TODO: Not yet fully parsed or utilised */ + obj->streams.misc_info.misc_info_1 = (struct minidump_misc_info *)(obj->b->buf + entry->location.rva); + + /* TODO: Handle different sizes */ + sdb_num_set (obj->kv, ""mdmp_misc_info.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_misc_info.format"", ""d[4]Bdtttddddd "" + ""SizeOfInfo (mdmp_misc1_flags)Flags1 ProcessId "" + ""ProcessCreateTime ProcessUserTime ProcessKernelTime "" + ""ProcessorMaxMhz ProcessorCurrentMhz "" + ""ProcessorMhzLimit ProcessorMaxIdleState "" + ""ProcessorCurrentIdleState"", 0); + + break; + case MEMORY_INFO_LIST_STREAM: + memory_info_list = (struct minidump_memory_info_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_memory_info.format"", + ""qq[4]Edq[4]E[4]E[4]Ed BaseAddress AllocationBase "" + ""(mdmp_page_protect)AllocationProtect __Alignment1 RegionSize "" + ""(mdmp_mem_state)State (mdmp_page_protect)Protect "" + ""(mdmp_mem_type)Type __Alignment2"", 0); + sdb_num_set (obj->kv, ""mdmp_memory_info_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_memory_info_list.format"", + sdb_fmt (""ddq[%i]? SizeOfHeader SizeOfEntry "" + ""NumberOfEntries (mdmp_memory_info)MemoryInfo"", + memory_info_list->number_of_entries), + 0); + + for (i = 0; i < memory_info_list->number_of_entries; i++) { + memory_infos = (struct minidump_memory_info *)((ut8 *)memory_info_list + sizeof (struct minidump_memory_info_list)); + r_list_append (obj->streams.memory_infos, &(memory_infos[i])); + } + break; + case THREAD_INFO_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + thread_info_list = (struct minidump_thread_info_list *)(obj->b->buf + entry->location.rva); + + sdb_set (obj->kv, ""mdmp_thread_info.format"", ""ddddttttqq "" + ""ThreadId DumpFlags DumpError ExitStatus CreateTime "" + ""ExitTime KernelTime UserTime StartAddress Affinity"", + 0); + sdb_num_set (obj->kv, ""mdmp_thread_info_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_thread_info_list.format"", ""ddd "" + ""SizeOfHeader SizeOfEntry NumberOfEntries"", 0); + + for (i = 0; i < thread_info_list->number_of_entries; i++) { + thread_infos = (struct minidump_thread_info *)((ut8 *)thread_info_list + sizeof (struct minidump_thread_info_list)); + r_list_append (obj->streams.thread_infos, &(thread_infos[i])); + } + break; + case HANDLE_OPERATION_LIST_STREAM: + /* TODO: Not yet fully parsed or utilised */ + handle_operation_list = (struct minidump_handle_operation_list *)(obj->b->buf + entry->location.rva); + + sdb_num_set (obj->kv, ""mdmp_handle_operation_list.offset"", + entry->location.rva, 0); + sdb_set (obj->kv, ""mdmp_handle_operation_list.format"", ""dddd "" + ""SizeOfHeader SizeOfEntry NumberOfEntries Reserved"", 0); + + for (i = 0; i < handle_operation_list->number_of_entries; i++) { + handle_operations = (struct avrf_handle_operation *)((ut8 *)handle_operation_list + sizeof (struct minidump_handle_operation_list)); + r_list_append (obj->streams.operations, &(handle_operations[i])); + } + + break; + case LAST_RESERVED_STREAM: + /* TODO: Not yet fully parsed or utilised */ + break; + case UNUSED_STREAM: + case RESERVED_STREAM_0: + case RESERVED_STREAM_1: + /* Silently ignore reserved streams */ + break; + default: + eprintf (""[WARN] Invalid or unsupported enumeration encountered %i\n"", entry->stream_type); + return false; + } + return true; +} +","@@ -362,7 +362,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m + /* We could confirm data sizes but a malcious MDMP will always get around + ** this! But we can ensure that the data is not outside of the file */ + if (entry->location.rva + entry->location.data_size > obj->b->length) { +- eprintf(""[ERROR] Size Mismatch - Stream data is larger than file size!\n""); ++ eprintf (""[ERROR] Size Mismatch - Stream data is larger than file size!\n""); + return false; + } + +@@ -646,10 +646,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m + + static bool r_bin_mdmp_init_directory(struct r_bin_mdmp_obj *obj) { + int i; +- ut8 *directory_base; +- struct minidump_directory *entry; +- +- directory_base = obj->b->buf + obj->hdr->stream_directory_rva; ++ struct minidump_directory entry; + + sdb_num_set (obj->kv, ""mdmp_directory.offset"", + obj->hdr->stream_directory_rva, 0); +@@ -658,9 +655,13 @@ static bool r_bin_mdmp_init_directory(struct r_bin_mdmp_obj *obj) { + ""(mdmp_location_descriptor)Location"", 0); + + /* Parse each entry in the directory */ ++ ut64 rvadir = obj->hdr->stream_directory_rva; + for (i = 0; i < (int)obj->hdr->number_of_streams; i++) { +- entry = (struct minidump_directory *)(directory_base + (i * sizeof (struct minidump_directory))); +- r_bin_mdmp_init_directory_entry (obj, entry); ++ ut32 delta = i * sizeof (struct minidump_directory); ++ int r = r_buf_read_at (obj->b, rvadir + delta, (ut8*) &entry, sizeof (struct minidump_directory)); ++ if (r) { ++ r_bin_mdmp_init_directory_entry (obj, &entry); ++ } + } + + return true;",3516,3752,4096 +227,"void FoFiType1C::convertToType1(char *psName, const char **newEncoding, GBool ascii, + FoFiOutputFunc outputFunc, + void *outputStream) { + int psNameLen; + Type1CEexecBuf eb; + Type1CIndex subrIdx; + Type1CIndexVal val; + GooString *buf; + char buf2[256]; + const char **enc; + GBool ok; + int i; + + if (psName) { + psNameLen = strlen(psName); + } else { + psName = name->getCString(); + psNameLen = name->getLength(); + } + + ok = gTrue; + (*outputFunc)(outputStream, ""%!FontType1-1.0: "", 17); + (*outputFunc)(outputStream, psName, psNameLen); + if (topDict.versionSID != 0) { + getString(topDict.versionSID, buf2, &ok); + (*outputFunc)(outputStream, buf2, strlen(buf2)); + } + (*outputFunc)(outputStream, ""\n"", 1); + (*outputFunc)(outputStream, ""12 dict begin\n"", 14); + (*outputFunc)(outputStream, ""/FontInfo 10 dict dup begin\n"", 28); + if (topDict.versionSID != 0) { + (*outputFunc)(outputStream, ""/version "", 9); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.noticeSID != 0) { + getString(topDict.noticeSID, buf2, &ok); + (*outputFunc)(outputStream, ""/Notice "", 8); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.copyrightSID != 0) { + getString(topDict.copyrightSID, buf2, &ok); + (*outputFunc)(outputStream, ""/Copyright "", 11); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.fullNameSID != 0) { + getString(topDict.fullNameSID, buf2, &ok); + (*outputFunc)(outputStream, ""/FullName "", 10); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.familyNameSID != 0) { + getString(topDict.familyNameSID, buf2, &ok); + (*outputFunc)(outputStream, ""/FamilyName "", 12); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.weightSID != 0) { + getString(topDict.weightSID, buf2, &ok); + (*outputFunc)(outputStream, ""/Weight "", 8); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.isFixedPitch) { + (*outputFunc)(outputStream, ""/isFixedPitch true def\n"", 23); + } else { + (*outputFunc)(outputStream, ""/isFixedPitch false def\n"", 24); + } + buf = GooString::format(""/ItalicAngle {0:.4g} def\n"", topDict.italicAngle); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/UnderlinePosition {0:.4g} def\n"", + topDict.underlinePosition); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/UnderlineThickness {0:.4g} def\n"", + topDict.underlineThickness); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + (*outputFunc)(outputStream, ""end readonly def\n"", 17); + (*outputFunc)(outputStream, ""/FontName /"", 11); + (*outputFunc)(outputStream, psName, psNameLen); + (*outputFunc)(outputStream, "" def\n"", 5); + buf = GooString::format(""/PaintType {0:d} def\n"", topDict.paintType); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + (*outputFunc)(outputStream, ""/FontType 1 def\n"", 16); + buf = GooString::format(""/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] readonly def\n"", + topDict.fontMatrix[0], topDict.fontMatrix[1], + topDict.fontMatrix[2], topDict.fontMatrix[3], + topDict.fontMatrix[4], topDict.fontMatrix[5]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] readonly def\n"", + topDict.fontBBox[0], topDict.fontBBox[1], + topDict.fontBBox[2], topDict.fontBBox[3]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/StrokeWidth {0:.4g} def\n"", topDict.strokeWidth); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + if (topDict.uniqueID != 0) { + buf = GooString::format(""/UniqueID {0:d} def\n"", topDict.uniqueID); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + + (*outputFunc)(outputStream, ""/Encoding "", 10); + if (!newEncoding && encoding == fofiType1StandardEncoding) { + (*outputFunc)(outputStream, ""StandardEncoding def\n"", 21); + } else { + (*outputFunc)(outputStream, ""256 array\n"", 10); + (*outputFunc)(outputStream, + ""0 1 255 {1 index exch /.notdef put} for\n"", 40); + enc = newEncoding ? newEncoding : (const char **)encoding; + for (i = 0; i < 256; ++i) { + if (enc[i]) { + buf = GooString::format(""dup {0:d} /{1:s} put\n"", i, enc[i]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + } + (*outputFunc)(outputStream, ""readonly def\n"", 13); + } + (*outputFunc)(outputStream, ""currentdict end\n"", 16); + + (*outputFunc)(outputStream, ""currentfile eexec\n"", 18); + eb.outputFunc = outputFunc; + eb.outputStream = outputStream; + eb.ascii = ascii; + eb.r1 = 55665; + eb.line = 0; + + eexecWrite(&eb, ""\x83\xca\x73\xd5""); + eexecWrite(&eb, ""dup /Private 32 dict dup begin\n""); + eexecWrite(&eb, ""/RD {string currentfile exch readstring pop}"" + "" executeonly def\n""); + eexecWrite(&eb, ""/ND {noaccess def} executeonly def\n""); + eexecWrite(&eb, ""/NP {noaccess put} executeonly def\n""); + eexecWrite(&eb, ""/MinFeature {16 16} def\n""); + eexecWrite(&eb, ""/password 5839 def\n""); + if (privateDicts[0].nBlueValues) { + eexecWrite(&eb, ""/BlueValues [""); + for (i = 0; i < privateDicts[0].nBlueValues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", + i > 0 ? "" "" : """", privateDicts[0].blueValues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nOtherBlues) { + eexecWrite(&eb, ""/OtherBlues [""); + for (i = 0; i < privateDicts[0].nOtherBlues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", + i > 0 ? "" "" : """", privateDicts[0].otherBlues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nFamilyBlues) { + eexecWrite(&eb, ""/FamilyBlues [""); + for (i = 0; i < privateDicts[0].nFamilyBlues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", + i > 0 ? "" "" : """", privateDicts[0].familyBlues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nFamilyOtherBlues) { + eexecWrite(&eb, ""/FamilyOtherBlues [""); + for (i = 0; i < privateDicts[0].nFamilyOtherBlues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", i > 0 ? "" "" : """", + privateDicts[0].familyOtherBlues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].blueScale != 0.039625) { + buf = GooString::format(""/BlueScale {0:.4g} def\n"", + privateDicts[0].blueScale); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].blueShift != 7) { + buf = GooString::format(""/BlueShift {0:d} def\n"", privateDicts[0].blueShift); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].blueFuzz != 1) { + buf = GooString::format(""/BlueFuzz {0:d} def\n"", privateDicts[0].blueFuzz); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].hasStdHW) { + buf = GooString::format(""/StdHW [{0:.4g}] def\n"", privateDicts[0].stdHW); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].hasStdVW) { + buf = GooString::format(""/StdVW [{0:.4g}] def\n"", privateDicts[0].stdVW); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].nStemSnapH) { + eexecWrite(&eb, ""/StemSnapH [""); + for (i = 0; i < privateDicts[0].nStemSnapH; ++i) { + buf = GooString::format(""{0:s}{1:.4g}"", + i > 0 ? "" "" : """", privateDicts[0].stemSnapH[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nStemSnapV) { + eexecWrite(&eb, ""/StemSnapV [""); + for (i = 0; i < privateDicts[0].nStemSnapV; ++i) { + buf = GooString::format(""{0:s}{1:.4g}"", + i > 0 ? "" "" : """", privateDicts[0].stemSnapV[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].hasForceBold) { + buf = GooString::format(""/ForceBold {0:s} def\n"", + privateDicts[0].forceBold ? ""true"" : ""false""); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].forceBoldThreshold != 0) { + buf = GooString::format(""/ForceBoldThreshold {0:.4g} def\n"", + privateDicts[0].forceBoldThreshold); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].languageGroup != 0) { + buf = GooString::format(""/LanguageGroup {0:d} def\n"", + privateDicts[0].languageGroup); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].expansionFactor != 0.06) { + buf = GooString::format(""/ExpansionFactor {0:.4g} def\n"", + privateDicts[0].expansionFactor); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + + ok = gTrue; + getIndex(privateDicts[0].subrsOffset, &subrIdx, &ok); + if (!ok) { + subrIdx.pos = -1; + } + + buf = GooString::format(""2 index /CharStrings {0:d} dict dup begin\n"", + nGlyphs); + eexecWrite(&eb, buf->getCString()); + delete buf; + for (i = 0; i < nGlyphs; ++i) { + ok = gTrue; + getIndexVal(&charStringsIdx, i, &val, &ok); + if (ok && i < charsetLength) { + getString(charset[i], buf2, &ok); + if (ok) { + eexecCvtGlyph(&eb, buf2, val.pos, val.len, &subrIdx, &privateDicts[0]); + } + } + } + eexecWrite(&eb, ""end\n""); + eexecWrite(&eb, ""end\n""); + eexecWrite(&eb, ""readonly put\n""); + eexecWrite(&eb, ""noaccess put\n""); + eexecWrite(&eb, ""dup /FontName get exch definefont pop\n""); + eexecWrite(&eb, ""mark currentfile closefile\n""); + + if (ascii && eb.line > 0) { + (*outputFunc)(outputStream, ""\n"", 1); + } + for (i = 0; i < 8; ++i) { + (*outputFunc)(outputStream, ""0000000000000000000000000000000000000000000000000000000000000000\n"", 65); + } + (*outputFunc)(outputStream, ""cleartomark\n"", 12); +} +",0,"void FoFiType1C::convertToType1(char *psName, const char **newEncoding, GBool ascii, + FoFiOutputFunc outputFunc, + void *outputStream) { + int psNameLen; + Type1CEexecBuf eb; + Type1CIndex subrIdx; + Type1CIndexVal val; + GooString *buf; + char buf2[256]; + const char **enc; + GBool ok; + int i; + + if (psName) { + psNameLen = strlen(psName); + } else { + psName = name->getCString(); + psNameLen = name->getLength(); + } + + ok = gTrue; + (*outputFunc)(outputStream, ""%!FontType1-1.0: "", 17); + (*outputFunc)(outputStream, psName, psNameLen); + if (topDict.versionSID != 0) { + getString(topDict.versionSID, buf2, &ok); + (*outputFunc)(outputStream, buf2, strlen(buf2)); + } + (*outputFunc)(outputStream, ""\n"", 1); + (*outputFunc)(outputStream, ""12 dict begin\n"", 14); + (*outputFunc)(outputStream, ""/FontInfo 10 dict dup begin\n"", 28); + if (topDict.versionSID != 0) { + (*outputFunc)(outputStream, ""/version "", 9); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.noticeSID != 0) { + getString(topDict.noticeSID, buf2, &ok); + (*outputFunc)(outputStream, ""/Notice "", 8); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.copyrightSID != 0) { + getString(topDict.copyrightSID, buf2, &ok); + (*outputFunc)(outputStream, ""/Copyright "", 11); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.fullNameSID != 0) { + getString(topDict.fullNameSID, buf2, &ok); + (*outputFunc)(outputStream, ""/FullName "", 10); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.familyNameSID != 0) { + getString(topDict.familyNameSID, buf2, &ok); + (*outputFunc)(outputStream, ""/FamilyName "", 12); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.weightSID != 0) { + getString(topDict.weightSID, buf2, &ok); + (*outputFunc)(outputStream, ""/Weight "", 8); + writePSString(buf2, outputFunc, outputStream); + (*outputFunc)(outputStream, "" readonly def\n"", 14); + } + if (topDict.isFixedPitch) { + (*outputFunc)(outputStream, ""/isFixedPitch true def\n"", 23); + } else { + (*outputFunc)(outputStream, ""/isFixedPitch false def\n"", 24); + } + buf = GooString::format(""/ItalicAngle {0:.4g} def\n"", topDict.italicAngle); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/UnderlinePosition {0:.4g} def\n"", + topDict.underlinePosition); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/UnderlineThickness {0:.4g} def\n"", + topDict.underlineThickness); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + (*outputFunc)(outputStream, ""end readonly def\n"", 17); + (*outputFunc)(outputStream, ""/FontName /"", 11); + (*outputFunc)(outputStream, psName, psNameLen); + (*outputFunc)(outputStream, "" def\n"", 5); + buf = GooString::format(""/PaintType {0:d} def\n"", topDict.paintType); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + (*outputFunc)(outputStream, ""/FontType 1 def\n"", 16); + buf = GooString::format(""/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] readonly def\n"", + topDict.fontMatrix[0], topDict.fontMatrix[1], + topDict.fontMatrix[2], topDict.fontMatrix[3], + topDict.fontMatrix[4], topDict.fontMatrix[5]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] readonly def\n"", + topDict.fontBBox[0], topDict.fontBBox[1], + topDict.fontBBox[2], topDict.fontBBox[3]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + buf = GooString::format(""/StrokeWidth {0:.4g} def\n"", topDict.strokeWidth); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + if (topDict.uniqueID != 0) { + buf = GooString::format(""/UniqueID {0:d} def\n"", topDict.uniqueID); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + + (*outputFunc)(outputStream, ""/Encoding "", 10); + if (!newEncoding && encoding == fofiType1StandardEncoding) { + (*outputFunc)(outputStream, ""StandardEncoding def\n"", 21); + } else { + (*outputFunc)(outputStream, ""256 array\n"", 10); + (*outputFunc)(outputStream, + ""0 1 255 {1 index exch /.notdef put} for\n"", 40); + enc = newEncoding ? newEncoding : (const char **)encoding; + for (i = 0; i < 256; ++i) { + if (enc[i]) { + buf = GooString::format(""dup {0:d} /{1:s} put\n"", i, enc[i]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + } + (*outputFunc)(outputStream, ""readonly def\n"", 13); + } + (*outputFunc)(outputStream, ""currentdict end\n"", 16); + + (*outputFunc)(outputStream, ""currentfile eexec\n"", 18); + eb.outputFunc = outputFunc; + eb.outputStream = outputStream; + eb.ascii = ascii; + eb.r1 = 55665; + eb.line = 0; + + eexecWrite(&eb, ""\x83\xca\x73\xd5""); + eexecWrite(&eb, ""dup /Private 32 dict dup begin\n""); + eexecWrite(&eb, ""/RD {string currentfile exch readstring pop}"" + "" executeonly def\n""); + eexecWrite(&eb, ""/ND {noaccess def} executeonly def\n""); + eexecWrite(&eb, ""/NP {noaccess put} executeonly def\n""); + eexecWrite(&eb, ""/MinFeature {16 16} def\n""); + eexecWrite(&eb, ""/password 5839 def\n""); + if (privateDicts[0].nBlueValues) { + eexecWrite(&eb, ""/BlueValues [""); + for (i = 0; i < privateDicts[0].nBlueValues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", + i > 0 ? "" "" : """", privateDicts[0].blueValues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nOtherBlues) { + eexecWrite(&eb, ""/OtherBlues [""); + for (i = 0; i < privateDicts[0].nOtherBlues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", + i > 0 ? "" "" : """", privateDicts[0].otherBlues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nFamilyBlues) { + eexecWrite(&eb, ""/FamilyBlues [""); + for (i = 0; i < privateDicts[0].nFamilyBlues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", + i > 0 ? "" "" : """", privateDicts[0].familyBlues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nFamilyOtherBlues) { + eexecWrite(&eb, ""/FamilyOtherBlues [""); + for (i = 0; i < privateDicts[0].nFamilyOtherBlues; ++i) { + buf = GooString::format(""{0:s}{1:d}"", i > 0 ? "" "" : """", + privateDicts[0].familyOtherBlues[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].blueScale != 0.039625) { + buf = GooString::format(""/BlueScale {0:.4g} def\n"", + privateDicts[0].blueScale); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].blueShift != 7) { + buf = GooString::format(""/BlueShift {0:d} def\n"", privateDicts[0].blueShift); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].blueFuzz != 1) { + buf = GooString::format(""/BlueFuzz {0:d} def\n"", privateDicts[0].blueFuzz); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].hasStdHW) { + buf = GooString::format(""/StdHW [{0:.4g}] def\n"", privateDicts[0].stdHW); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].hasStdVW) { + buf = GooString::format(""/StdVW [{0:.4g}] def\n"", privateDicts[0].stdVW); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].nStemSnapH) { + eexecWrite(&eb, ""/StemSnapH [""); + for (i = 0; i < privateDicts[0].nStemSnapH; ++i) { + buf = GooString::format(""{0:s}{1:.4g}"", + i > 0 ? "" "" : """", privateDicts[0].stemSnapH[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].nStemSnapV) { + eexecWrite(&eb, ""/StemSnapV [""); + for (i = 0; i < privateDicts[0].nStemSnapV; ++i) { + buf = GooString::format(""{0:s}{1:.4g}"", + i > 0 ? "" "" : """", privateDicts[0].stemSnapV[i]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, ""] def\n""); + } + if (privateDicts[0].hasForceBold) { + buf = GooString::format(""/ForceBold {0:s} def\n"", + privateDicts[0].forceBold ? ""true"" : ""false""); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].forceBoldThreshold != 0) { + buf = GooString::format(""/ForceBoldThreshold {0:.4g} def\n"", + privateDicts[0].forceBoldThreshold); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].languageGroup != 0) { + buf = GooString::format(""/LanguageGroup {0:d} def\n"", + privateDicts[0].languageGroup); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[0].expansionFactor != 0.06) { + buf = GooString::format(""/ExpansionFactor {0:.4g} def\n"", + privateDicts[0].expansionFactor); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + + ok = gTrue; + getIndex(privateDicts[0].subrsOffset, &subrIdx, &ok); + if (!ok) { + subrIdx.pos = -1; + } + + buf = GooString::format(""2 index /CharStrings {0:d} dict dup begin\n"", + nGlyphs); + eexecWrite(&eb, buf->getCString()); + delete buf; + for (i = 0; i < nGlyphs; ++i) { + ok = gTrue; + getIndexVal(&charStringsIdx, i, &val, &ok); + if (ok && i < charsetLength) { + getString(charset[i], buf2, &ok); + if (ok) { + eexecCvtGlyph(&eb, buf2, val.pos, val.len, &subrIdx, &privateDicts[0]); + } + } + } + eexecWrite(&eb, ""end\n""); + eexecWrite(&eb, ""end\n""); + eexecWrite(&eb, ""readonly put\n""); + eexecWrite(&eb, ""noaccess put\n""); + eexecWrite(&eb, ""dup /FontName get exch definefont pop\n""); + eexecWrite(&eb, ""mark currentfile closefile\n""); + + if (ascii && eb.line > 0) { + (*outputFunc)(outputStream, ""\n"", 1); + } + for (i = 0; i < 8; ++i) { + (*outputFunc)(outputStream, ""0000000000000000000000000000000000000000000000000000000000000000\n"", 65); + } + (*outputFunc)(outputStream, ""cleartomark\n"", 12); +} +","@@ -898,6 +898,9 @@ void FoFiType1C::convertToType0(char *psName, int *codeMap, int nCodes, + } + } + ++ if (fd >= nFDs) ++ continue; ++ + // font dictionary (unencrypted section) + (*outputFunc)(outputStream, ""16 dict begin\n"", 14); + (*outputFunc)(outputStream, ""/FontName /"", 11);",3524,3760,4096 +17794," irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, + const gnutls_datum_t *req_ca, int nreq, + const gnutls_pk_algorithm_t *pk_algos, + int pk_algos_len, gnutls_retr_st *answer) + { + struct t_irc_server *server; + gnutls_retr_st tls_struct; + const gnutls_datum_t *cert_list; + gnutls_datum_t filedatum; + unsigned int cert_list_len, status; + time_t cert_time; + char *cert_path0, *cert_path1, *cert_path2, *cert_str, *hostname; + const char *weechat_dir; + int rc, ret, i, j, hostname_match; +#if LIBGNUTLS_VERSION_NUMBER >= 0x010706 + gnutls_datum_t cinfo; + int rinfo; +#endif + + /* make C compiler happy */ + (void) req_ca; + (void) nreq; + (void) pk_algos; + (void) pk_algos_len; + + rc = 0; + + if (!data) + return -1; + + server = (struct t_irc_server *) data; + hostname = server->current_address; + hostname = server->current_address; + hostname_match = 0; + + weechat_printf (server->buffer, + _(""gnutls: connected using %d-bit Diffie-Hellman shared "" + ""secret exchange""), + IRC_SERVER_OPTION_INTEGER (server, + IRC_SERVER_OPTION_SSL_DHKEY_SIZE)); + if (gnutls_certificate_verify_peers2 (tls_session, &status) < 0) + { + weechat_printf (server->buffer, + _(""%sgnutls: error while checking peer's certificate""), + weechat_prefix (""error"")); + rc = -1; + } + else + { + /* some checks */ + if (status & GNUTLS_CERT_INVALID) + { + weechat_printf (server->buffer, + _(""%sgnutls: peer's certificate is NOT trusted""), + weechat_prefix (""error"")); + rc = -1; + } + else + { + weechat_printf (server->buffer, + _(""gnutls: peer's certificate is trusted"")); + } + if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) + { + weechat_printf (server->buffer, + _(""%sgnutls: peer's certificate issuer is unknown""), + weechat_prefix (""error"")); + rc = -1; + } + if (status & GNUTLS_CERT_REVOKED) + { + weechat_printf (server->buffer, + _(""%sgnutls: the certificate has been revoked""), + weechat_prefix (""error"")); + rc = -1; + } + /* check certificates */ + if (gnutls_x509_crt_init (&cert_temp) >= 0) + { + cert_list = gnutls_certificate_get_peers (tls_session, &cert_list_len); + if (cert_list) + { + weechat_printf (server->buffer, + NG_(""gnutls: receiving %d certificate"", + ""gnutls: receiving %d certificates"", + cert_list_len), + cert_list_len); + for (i = 0, j = (int) cert_list_len; i < j; i++) + { + if (gnutls_x509_crt_import (cert_temp, &cert_list[i], GNUTLS_X509_FMT_DER) >= 0) + { + /* checking if hostname matches in the first certificate */ + if (i == 0 && gnutls_x509_crt_check_hostname (cert_temp, hostname) != 0) + { + hostname_match = 1; + } + #if LIBGNUTLS_VERSION_NUMBER >= 0x010706 + /* displaying infos about certificate */ + #if LIBGNUTLS_VERSION_NUMBER < 0x020400 + rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_X509_CRT_ONELINE, &cinfo); + #else + rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_CRT_PRINT_ONELINE, &cinfo); + #endif + if (rinfo == 0) + { + weechat_printf (server->buffer, + _("" - certificate[%d] info:""), i + 1); + weechat_printf (server->buffer, + "" - %s"", cinfo.data); + gnutls_free (cinfo.data); + } + #endif + /* check expiration date */ + cert_time = gnutls_x509_crt_get_expiration_time (cert_temp); + if (cert_time < time(NULL)) + { + weechat_printf (server->buffer, + _(""%sgnutls: certificate has expired""), + weechat_prefix (""error"")); + rc = -1; + } + /* check expiration date */ + cert_time = gnutls_x509_crt_get_activation_time (cert_temp); + if (cert_time > time(NULL)) + { + weechat_printf (server->buffer, + _(""%sgnutls: certificate is not yet activated""), + weechat_prefix (""error"")); + rc = -1; + } + } + } + if (hostname_match == 0) + { + weechat_printf (server->buffer, + _(""%sgnutls: the hostname in the "" + ""certificate does NOT match \""%s\""""), + weechat_prefix (""error""), hostname); + rc = -1; + } + } + } + } + /* using client certificate if it exists */ + cert_path0 = (char *) IRC_SERVER_OPTION_STRING(server, + IRC_SERVER_OPTION_SSL_CERT); + if (cert_path0 && cert_path0[0]) + { + weechat_dir = weechat_info_get (""weechat_dir"", """"); + cert_path1 = weechat_string_replace (cert_path0, ""%h"", weechat_dir); + cert_path2 = (cert_path1) ? + weechat_string_expand_home (cert_path1) : NULL; + if (cert_path2) + { + cert_str = weechat_file_get_content (cert_path2); + if (cert_str) + { + weechat_printf (server->buffer, + _(""gnutls: sending one certificate"")); + filedatum.data = (unsigned char *) cert_str; + filedatum.size = strlen (cert_str); + /* certificate */ + gnutls_x509_crt_init (&server->tls_cert); + gnutls_x509_crt_import (server->tls_cert, &filedatum, + GNUTLS_X509_FMT_PEM); + /* key */ + gnutls_x509_privkey_init (&server->tls_cert_key); + ret = gnutls_x509_privkey_import (server->tls_cert_key, + &filedatum, + GNUTLS_X509_FMT_PEM); + if (ret < 0) + { + ret = gnutls_x509_privkey_import_pkcs8 (server->tls_cert_key, + &filedatum, + GNUTLS_X509_FMT_PEM, + NULL, + GNUTLS_PKCS_PLAIN); + } + if (ret < 0) + { + weechat_printf (server->buffer, + _(""%sgnutls: invalid certificate \""%s\"", "" + ""error: %s""), + weechat_prefix (""error""), cert_path2, + gnutls_strerror (ret)); + rc = -1; + } + else + { + tls_struct.type = GNUTLS_CRT_X509; + tls_struct.ncerts = 1; + tls_struct.deinit_all = 0; + tls_struct.cert.x509 = &server->tls_cert; + tls_struct.key.x509 = server->tls_cert_key; + #if LIBGNUTLS_VERSION_NUMBER >= 0x010706 + /* client certificate info */ + #if LIBGNUTLS_VERSION_NUMBER < 0x020400 + rinfo = gnutls_x509_crt_print (server->tls_cert, + GNUTLS_X509_CRT_ONELINE, + &cinfo); + #else + rinfo = gnutls_x509_crt_print (server->tls_cert, + GNUTLS_CRT_PRINT_ONELINE, + &cinfo); + #endif + if (rinfo == 0) + { + weechat_printf (server->buffer, + _("" - client certificate info (%s):""), + cert_path2); + weechat_printf (server->buffer, "" - %s"", cinfo.data); + gnutls_free (cinfo.data); + } + #endif + memcpy (answer, &tls_struct, sizeof (gnutls_retr_st)); + free (cert_str); + } + } + else + { + weechat_printf (server->buffer, + _(""%sgnutls: unable to read certifcate \""%s\""""), + weechat_prefix (""error""), cert_path2); + } + } + if (cert_path1) + free (cert_path1); + if (cert_path2) + free (cert_path2); + } + + /* an error should stop the handshake unless the user doesn't care */ + return rc; +} +",1," irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, + const gnutls_datum_t *req_ca, int nreq, + const gnutls_pk_algorithm_t *pk_algos, + int pk_algos_len, gnutls_retr_st *answer, + int action) + { + struct t_irc_server *server; + gnutls_retr_st tls_struct; + const gnutls_datum_t *cert_list; + gnutls_datum_t filedatum; + unsigned int cert_list_len, status; + time_t cert_time; + char *cert_path0, *cert_path1, *cert_path2, *cert_str, *hostname; + const char *weechat_dir; + int rc, ret, i, j, hostname_match; +#if LIBGNUTLS_VERSION_NUMBER >= 0x010706 + gnutls_datum_t cinfo; + int rinfo; +#endif + + /* make C compiler happy */ + (void) req_ca; + (void) nreq; + (void) pk_algos; + (void) pk_algos_len; + + rc = 0; + + if (!data) + return -1; + + server = (struct t_irc_server *) data; + hostname = server->current_address; + hostname = server->current_address; + hostname_match = 0; + + if (action == WEECHAT_HOOK_CONNECT_GNUTLS_CB_VERIFY_CERT) + { + weechat_printf (server->buffer, + _(""gnutls: connected using %d-bit Diffie-Hellman shared "" + ""secret exchange""), + IRC_SERVER_OPTION_INTEGER (server, + IRC_SERVER_OPTION_SSL_DHKEY_SIZE)); + if (gnutls_certificate_verify_peers2 (tls_session, &status) < 0) + { + weechat_printf (server->buffer, + _(""%sgnutls: error while checking peer's certificate""), + weechat_prefix (""error"")); + rc = -1; + } + else + { + /* some checks */ + if (status & GNUTLS_CERT_INVALID) + { + weechat_printf (server->buffer, + _(""%sgnutls: peer's certificate is NOT trusted""), + weechat_prefix (""error"")); + rc = -1; + } + else + { + weechat_printf (server->buffer, + _(""gnutls: peer's certificate is trusted"")); + } + if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) + { + weechat_printf (server->buffer, + _(""%sgnutls: peer's certificate issuer is unknown""), + weechat_prefix (""error"")); + rc = -1; + } + if (status & GNUTLS_CERT_REVOKED) + { + weechat_printf (server->buffer, + _(""%sgnutls: the certificate has been revoked""), + weechat_prefix (""error"")); + rc = -1; + } + + /* check certificates */ + if (gnutls_x509_crt_init (&cert_temp) >= 0) + { + cert_list = gnutls_certificate_get_peers (tls_session, &cert_list_len); + if (cert_list) + { + weechat_printf (server->buffer, + NG_(""gnutls: receiving %d certificate"", + ""gnutls: receiving %d certificates"", + cert_list_len), + cert_list_len); + for (i = 0, j = (int) cert_list_len; i < j; i++) + { + if (gnutls_x509_crt_import (cert_temp, &cert_list[i], GNUTLS_X509_FMT_DER) >= 0) + { + /* checking if hostname matches in the first certificate */ + if ((i == 0) && (gnutls_x509_crt_check_hostname (cert_temp, hostname) != 0)) + { + hostname_match = 1; + } + #if LIBGNUTLS_VERSION_NUMBER >= 0x010706 + /* displaying infos about certificate */ + #if LIBGNUTLS_VERSION_NUMBER < 0x020400 + rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_X509_CRT_ONELINE, &cinfo); + #else + rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_CRT_PRINT_ONELINE, &cinfo); + #endif + if (rinfo == 0) + { + weechat_printf (server->buffer, + _("" - certificate[%d] info:""), i + 1); + weechat_printf (server->buffer, + "" - %s"", cinfo.data); + gnutls_free (cinfo.data); + } + #endif + /* check expiration date */ + cert_time = gnutls_x509_crt_get_expiration_time (cert_temp); + if (cert_time < time (NULL)) + { + weechat_printf (server->buffer, + _(""%sgnutls: certificate has expired""), + weechat_prefix (""error"")); + rc = -1; + } + /* check activation date */ + cert_time = gnutls_x509_crt_get_activation_time (cert_temp); + if (cert_time > time (NULL)) + { + weechat_printf (server->buffer, + _(""%sgnutls: certificate is not yet activated""), + weechat_prefix (""error"")); + rc = -1; + } + } + } + if (hostname_match == 0) + { + weechat_printf (server->buffer, + _(""%sgnutls: the hostname in the "" + ""certificate does NOT match \""%s\""""), + weechat_prefix (""error""), hostname); + rc = -1; + } + } + } + } + } + else if (action == WEECHAT_HOOK_CONNECT_GNUTLS_CB_SET_CERT) + { + /* using client certificate if it exists */ + cert_path0 = (char *) IRC_SERVER_OPTION_STRING(server, + IRC_SERVER_OPTION_SSL_CERT); + if (cert_path0 && cert_path0[0]) + { + weechat_dir = weechat_info_get (""weechat_dir"", """"); + cert_path1 = weechat_string_replace (cert_path0, ""%h"", weechat_dir); + cert_path2 = (cert_path1) ? + weechat_string_expand_home (cert_path1) : NULL; + + if (cert_path2) + { + cert_str = weechat_file_get_content (cert_path2); + if (cert_str) + { + weechat_printf (server->buffer, + _(""gnutls: sending one certificate"")); + + filedatum.data = (unsigned char *) cert_str; + filedatum.size = strlen (cert_str); + + /* certificate */ + gnutls_x509_crt_init (&server->tls_cert); + gnutls_x509_crt_import (server->tls_cert, &filedatum, + GNUTLS_X509_FMT_PEM); + + /* key */ + gnutls_x509_privkey_init (&server->tls_cert_key); + ret = gnutls_x509_privkey_import (server->tls_cert_key, + &filedatum, + GNUTLS_X509_FMT_PEM); + if (ret < 0) + { + ret = gnutls_x509_privkey_import_pkcs8 (server->tls_cert_key, + &filedatum, + GNUTLS_X509_FMT_PEM, + NULL, + GNUTLS_PKCS_PLAIN); + } + if (ret < 0) + { + weechat_printf (server->buffer, + _(""%sgnutls: invalid certificate \""%s\"", "" + ""error: %s""), + weechat_prefix (""error""), cert_path2, + gnutls_strerror (ret)); + rc = -1; + } + else + { + tls_struct.type = GNUTLS_CRT_X509; + tls_struct.ncerts = 1; + tls_struct.deinit_all = 0; + tls_struct.cert.x509 = &server->tls_cert; + tls_struct.key.x509 = server->tls_cert_key; + #if LIBGNUTLS_VERSION_NUMBER >= 0x010706 + /* client certificate info */ + #if LIBGNUTLS_VERSION_NUMBER < 0x020400 + rinfo = gnutls_x509_crt_print (server->tls_cert, + GNUTLS_X509_CRT_ONELINE, + &cinfo); + #else + rinfo = gnutls_x509_crt_print (server->tls_cert, + GNUTLS_CRT_PRINT_ONELINE, + &cinfo); + #endif + if (rinfo == 0) + { + weechat_printf (server->buffer, + _("" - client certificate info (%s):""), + cert_path2); + weechat_printf (server->buffer, "" - %s"", cinfo.data); + gnutls_free (cinfo.data); + } + #endif + memcpy (answer, &tls_struct, sizeof (gnutls_retr_st)); + free (cert_str); + } + } + else + { + weechat_printf (server->buffer, + _(""%sgnutls: unable to read certifcate \""%s\""""), + weechat_prefix (""error""), cert_path2); + } + } + + if (cert_path1) + free (cert_path1); + if (cert_path2) + free (cert_path2); + } + } + + /* an error should stop the handshake unless the user doesn't care */ + return rc; +} +","@@ -2805,7 +2805,8 @@ int + irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, + const gnutls_datum_t *req_ca, int nreq, + const gnutls_pk_algorithm_t *pk_algos, +- int pk_algos_len, gnutls_retr_st *answer) ++ int pk_algos_len, gnutls_retr_st *answer, ++ int action) + { + struct t_irc_server *server; + gnutls_retr_st tls_struct; +@@ -2837,207 +2838,212 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session, + hostname = server->current_address; + hostname_match = 0; + +- weechat_printf (server->buffer, +- _(""gnutls: connected using %d-bit Diffie-Hellman shared "" +- ""secret exchange""), +- IRC_SERVER_OPTION_INTEGER (server, +- IRC_SERVER_OPTION_SSL_DHKEY_SIZE)); +- if (gnutls_certificate_verify_peers2 (tls_session, &status) < 0) ++ if (action == WEECHAT_HOOK_CONNECT_GNUTLS_CB_VERIFY_CERT) + { + weechat_printf (server->buffer, +- _(""%sgnutls: error while checking peer's certificate""), +- weechat_prefix (""error"")); +- rc = -1; +- } +- else +- { +- /* some checks */ +- if (status & GNUTLS_CERT_INVALID) ++ _(""gnutls: connected using %d-bit Diffie-Hellman shared "" ++ ""secret exchange""), ++ IRC_SERVER_OPTION_INTEGER (server, ++ IRC_SERVER_OPTION_SSL_DHKEY_SIZE)); ++ if (gnutls_certificate_verify_peers2 (tls_session, &status) < 0) + { + weechat_printf (server->buffer, +- _(""%sgnutls: peer's certificate is NOT trusted""), ++ _(""%sgnutls: error while checking peer's certificate""), + weechat_prefix (""error"")); + rc = -1; + } + else + { +- weechat_printf (server->buffer, +- _(""gnutls: peer's certificate is trusted"")); +- } +- if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) +- { +- weechat_printf (server->buffer, +- _(""%sgnutls: peer's certificate issuer is unknown""), +- weechat_prefix (""error"")); +- rc = -1; +- } +- if (status & GNUTLS_CERT_REVOKED) +- { +- weechat_printf (server->buffer, +- _(""%sgnutls: the certificate has been revoked""), +- weechat_prefix (""error"")); +- rc = -1; +- } +- +- /* check certificates */ +- if (gnutls_x509_crt_init (&cert_temp) >= 0) +- { +- cert_list = gnutls_certificate_get_peers (tls_session, &cert_list_len); +- if (cert_list) ++ /* some checks */ ++ if (status & GNUTLS_CERT_INVALID) ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: peer's certificate is NOT trusted""), ++ weechat_prefix (""error"")); ++ rc = -1; ++ } ++ else ++ { ++ weechat_printf (server->buffer, ++ _(""gnutls: peer's certificate is trusted"")); ++ } ++ if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) + { + weechat_printf (server->buffer, +- NG_(""gnutls: receiving %d certificate"", +- ""gnutls: receiving %d certificates"", +- cert_list_len), +- cert_list_len); +- for (i = 0, j = (int) cert_list_len; i < j; i++) ++ _(""%sgnutls: peer's certificate issuer is unknown""), ++ weechat_prefix (""error"")); ++ rc = -1; ++ } ++ if (status & GNUTLS_CERT_REVOKED) ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: the certificate has been revoked""), ++ weechat_prefix (""error"")); ++ rc = -1; ++ } ++ ++ /* check certificates */ ++ if (gnutls_x509_crt_init (&cert_temp) >= 0) ++ { ++ cert_list = gnutls_certificate_get_peers (tls_session, &cert_list_len); ++ if (cert_list) + { +- if (gnutls_x509_crt_import (cert_temp, &cert_list[i], GNUTLS_X509_FMT_DER) >= 0) ++ weechat_printf (server->buffer, ++ NG_(""gnutls: receiving %d certificate"", ++ ""gnutls: receiving %d certificates"", ++ cert_list_len), ++ cert_list_len); ++ for (i = 0, j = (int) cert_list_len; i < j; i++) + { +- /* checking if hostname matches in the first certificate */ +- if (i == 0 && gnutls_x509_crt_check_hostname (cert_temp, hostname) != 0) ++ if (gnutls_x509_crt_import (cert_temp, &cert_list[i], GNUTLS_X509_FMT_DER) >= 0) + { +- hostname_match = 1; +- } ++ /* checking if hostname matches in the first certificate */ ++ if ((i == 0) && (gnutls_x509_crt_check_hostname (cert_temp, hostname) != 0)) ++ { ++ hostname_match = 1; ++ } + #if LIBGNUTLS_VERSION_NUMBER >= 0x010706 +- /* displaying infos about certificate */ ++ /* displaying infos about certificate */ + #if LIBGNUTLS_VERSION_NUMBER < 0x020400 +- rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_X509_CRT_ONELINE, &cinfo); ++ rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_X509_CRT_ONELINE, &cinfo); + #else +- rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_CRT_PRINT_ONELINE, &cinfo); ++ rinfo = gnutls_x509_crt_print (cert_temp, GNUTLS_CRT_PRINT_ONELINE, &cinfo); + #endif +- if (rinfo == 0) +- { +- weechat_printf (server->buffer, +- _("" - certificate[%d] info:""), i + 1); +- weechat_printf (server->buffer, +- "" - %s"", cinfo.data); +- gnutls_free (cinfo.data); +- } ++ if (rinfo == 0) ++ { ++ weechat_printf (server->buffer, ++ _("" - certificate[%d] info:""), i + 1); ++ weechat_printf (server->buffer, ++ "" - %s"", cinfo.data); ++ gnutls_free (cinfo.data); ++ } + #endif +- /* check expiration date */ +- cert_time = gnutls_x509_crt_get_expiration_time (cert_temp); +- if (cert_time < time(NULL)) +- { +- weechat_printf (server->buffer, +- _(""%sgnutls: certificate has expired""), +- weechat_prefix (""error"")); +- rc = -1; +- } +- /* check expiration date */ +- cert_time = gnutls_x509_crt_get_activation_time (cert_temp); +- if (cert_time > time(NULL)) +- { +- weechat_printf (server->buffer, +- _(""%sgnutls: certificate is not yet activated""), +- weechat_prefix (""error"")); +- rc = -1; ++ /* check expiration date */ ++ cert_time = gnutls_x509_crt_get_expiration_time (cert_temp); ++ if (cert_time < time (NULL)) ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: certificate has expired""), ++ weechat_prefix (""error"")); ++ rc = -1; ++ } ++ /* check activation date */ ++ cert_time = gnutls_x509_crt_get_activation_time (cert_temp); ++ if (cert_time > time (NULL)) ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: certificate is not yet activated""), ++ weechat_prefix (""error"")); ++ rc = -1; ++ } + } + } +- } +- if (hostname_match == 0) +- { +- weechat_printf (server->buffer, +- _(""%sgnutls: the hostname in the "" +- ""certificate does NOT match \""%s\""""), +- weechat_prefix (""error""), hostname); +- rc = -1; ++ if (hostname_match == 0) ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: the hostname in the "" ++ ""certificate does NOT match \""%s\""""), ++ weechat_prefix (""error""), hostname); ++ rc = -1; ++ } + } + } + } + } +- +- /* using client certificate if it exists */ +- cert_path0 = (char *) IRC_SERVER_OPTION_STRING(server, +- IRC_SERVER_OPTION_SSL_CERT); +- if (cert_path0 && cert_path0[0]) ++ else if (action == WEECHAT_HOOK_CONNECT_GNUTLS_CB_SET_CERT) + { +- weechat_dir = weechat_info_get (""weechat_dir"", """"); +- cert_path1 = weechat_string_replace (cert_path0, ""%h"", weechat_dir); +- cert_path2 = (cert_path1) ? +- weechat_string_expand_home (cert_path1) : NULL; +- +- if (cert_path2) ++ /* using client certificate if it exists */ ++ cert_path0 = (char *) IRC_SERVER_OPTION_STRING(server, ++ IRC_SERVER_OPTION_SSL_CERT); ++ if (cert_path0 && cert_path0[0]) + { +- cert_str = weechat_file_get_content (cert_path2); +- if (cert_str) ++ weechat_dir = weechat_info_get (""weechat_dir"", """"); ++ cert_path1 = weechat_string_replace (cert_path0, ""%h"", weechat_dir); ++ cert_path2 = (cert_path1) ? ++ weechat_string_expand_home (cert_path1) : NULL; ++ ++ if (cert_path2) + { +- weechat_printf (server->buffer, +- _(""gnutls: sending one certificate"")); +- +- filedatum.data = (unsigned char *) cert_str; +- filedatum.size = strlen (cert_str); +- +- /* certificate */ +- gnutls_x509_crt_init (&server->tls_cert); +- gnutls_x509_crt_import (server->tls_cert, &filedatum, +- GNUTLS_X509_FMT_PEM); +- +- /* key */ +- gnutls_x509_privkey_init (&server->tls_cert_key); +- ret = gnutls_x509_privkey_import (server->tls_cert_key, +- &filedatum, +- GNUTLS_X509_FMT_PEM); +- if (ret < 0) +- { +- ret = gnutls_x509_privkey_import_pkcs8 (server->tls_cert_key, +- &filedatum, +- GNUTLS_X509_FMT_PEM, +- NULL, +- GNUTLS_PKCS_PLAIN); +- } +- if (ret < 0) ++ cert_str = weechat_file_get_content (cert_path2); ++ if (cert_str) + { + weechat_printf (server->buffer, +- _(""%sgnutls: invalid certificate \""%s\"", "" +- ""error: %s""), +- weechat_prefix (""error""), cert_path2, +- gnutls_strerror (ret)); +- rc = -1; +- } +- else +- { +- tls_struct.type = GNUTLS_CRT_X509; +- tls_struct.ncerts = 1; +- tls_struct.deinit_all = 0; +- tls_struct.cert.x509 = &server->tls_cert; +- tls_struct.key.x509 = server->tls_cert_key; ++ _(""gnutls: sending one certificate"")); ++ ++ filedatum.data = (unsigned char *) cert_str; ++ filedatum.size = strlen (cert_str); ++ ++ /* certificate */ ++ gnutls_x509_crt_init (&server->tls_cert); ++ gnutls_x509_crt_import (server->tls_cert, &filedatum, ++ GNUTLS_X509_FMT_PEM); ++ ++ /* key */ ++ gnutls_x509_privkey_init (&server->tls_cert_key); ++ ret = gnutls_x509_privkey_import (server->tls_cert_key, ++ &filedatum, ++ GNUTLS_X509_FMT_PEM); ++ if (ret < 0) ++ { ++ ret = gnutls_x509_privkey_import_pkcs8 (server->tls_cert_key, ++ &filedatum, ++ GNUTLS_X509_FMT_PEM, ++ NULL, ++ GNUTLS_PKCS_PLAIN); ++ } ++ if (ret < 0) ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: invalid certificate \""%s\"", "" ++ ""error: %s""), ++ weechat_prefix (""error""), cert_path2, ++ gnutls_strerror (ret)); ++ rc = -1; ++ } ++ else ++ { ++ tls_struct.type = GNUTLS_CRT_X509; ++ tls_struct.ncerts = 1; ++ tls_struct.deinit_all = 0; ++ tls_struct.cert.x509 = &server->tls_cert; ++ tls_struct.key.x509 = server->tls_cert_key; + #if LIBGNUTLS_VERSION_NUMBER >= 0x010706 +- /* client certificate info */ ++ /* client certificate info */ + #if LIBGNUTLS_VERSION_NUMBER < 0x020400 +- rinfo = gnutls_x509_crt_print (server->tls_cert, +- GNUTLS_X509_CRT_ONELINE, +- &cinfo); ++ rinfo = gnutls_x509_crt_print (server->tls_cert, ++ GNUTLS_X509_CRT_ONELINE, ++ &cinfo); + #else +- rinfo = gnutls_x509_crt_print (server->tls_cert, +- GNUTLS_CRT_PRINT_ONELINE, +- &cinfo); ++ rinfo = gnutls_x509_crt_print (server->tls_cert, ++ GNUTLS_CRT_PRINT_ONELINE, ++ &cinfo); + #endif +- if (rinfo == 0) +- { +- weechat_printf (server->buffer, +- _("" - client certificate info (%s):""), +- cert_path2); +- weechat_printf (server->buffer, "" - %s"", cinfo.data); +- gnutls_free (cinfo.data); +- } ++ if (rinfo == 0) ++ { ++ weechat_printf (server->buffer, ++ _("" - client certificate info (%s):""), ++ cert_path2); ++ weechat_printf (server->buffer, "" - %s"", cinfo.data); ++ gnutls_free (cinfo.data); ++ } + #endif +- memcpy (answer, &tls_struct, sizeof (gnutls_retr_st)); +- free (cert_str); ++ memcpy (answer, &tls_struct, sizeof (gnutls_retr_st)); ++ free (cert_str); ++ } ++ } ++ else ++ { ++ weechat_printf (server->buffer, ++ _(""%sgnutls: unable to read certifcate \""%s\""""), ++ weechat_prefix (""error""), cert_path2); + } + } +- else +- { +- weechat_printf (server->buffer, +- _(""%sgnutls: unable to read certifcate \""%s\""""), +- weechat_prefix (""error""), cert_path2); +- } ++ ++ if (cert_path1) ++ free (cert_path1); ++ if (cert_path2) ++ free (cert_path2); + } +- +- if (cert_path1) +- free (cert_path1); +- if (cert_path2) +- free (cert_path2); + } + + /* an error should stop the handshake unless the user doesn't care */",2059,2295,4096 +18299,"babel_print_v2(netdissect_options *ndo, + const u_char *cp, u_int length) +{ + u_int i; + u_short bodylen; + u_char v4_prefix[16] = + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; + u_char v6_prefix[16] = {0}; + + ND_TCHECK2(*cp, 4); + if (length < 4) + goto invalid; + bodylen = EXTRACT_16BITS(cp + 2); + ND_PRINT((ndo, "" (%u)"", bodylen)); + + /* Process the TLVs in the body */ + i = 0; + while(i < bodylen) { + const u_char *message; + u_int type, len; + + message = cp + 4 + i; + + ND_TCHECK2(*message, 1); + if((type = message[0]) == MESSAGE_PAD1) { + ND_PRINT((ndo, ndo->ndo_vflag ? ""\n\tPad 1"" : "" pad1"")); + i += 1; + continue; + } + + ND_TCHECK2(*message, 2); + ICHECK(i, 2); + len = message[1]; + + ND_TCHECK2(*message, 2 + len); + ICHECK(i, 2 + len); + + switch(type) { + case MESSAGE_PADN: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" padN"")); + else + ND_PRINT((ndo, ""\n\tPad %d"", len + 2)); + } + break; + + case MESSAGE_ACK_REQ: { + u_short nonce, interval; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" ack-req"")); + else { + ND_PRINT((ndo, ""\n\tAcknowledgment Request "")); + if(len < 6) goto invalid; + nonce = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + ND_PRINT((ndo, ""%04x %s"", nonce, format_interval(interval))); + } + } + break; + + case MESSAGE_ACK: { + u_short nonce; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" ack"")); + else { + ND_PRINT((ndo, ""\n\tAcknowledgment "")); + if(len < 2) goto invalid; + nonce = EXTRACT_16BITS(message + 2); + ND_PRINT((ndo, ""%04x"", nonce)); + } + } + break; + + case MESSAGE_HELLO: { + u_short seqno, interval; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" hello"")); + else { + ND_PRINT((ndo, ""\n\tHello "")); + if(len < 6) goto invalid; + seqno = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + ND_PRINT((ndo, ""seqno %u interval %s"", seqno, format_interval(interval))); + /* Extra data. */ + if(len > 6) + subtlvs_print(ndo, message + 8, message + 2 + len, type); + } + } + break; + + case MESSAGE_IHU: { + unsigned short txcost, interval; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" ihu"")); + else { + u_char address[16]; + int rc; + ND_PRINT((ndo, ""\n\tIHU "")); + if(len < 6) goto invalid; + txcost = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + rc = network_address(message[2], message + 8, len - 6, address); + if(rc < 0) { ND_PRINT((ndo, ""%s"", tstr)); break; } + ND_PRINT((ndo, ""%s txcost %u interval %s"", + format_address(ndo, address), txcost, format_interval(interval))); + /* Extra data. */ + if((u_int)rc < len - 6) + subtlvs_print(ndo, message + 8 + rc, message + 2 + len, + type); + } + } + break; + + case MESSAGE_ROUTER_ID: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" router-id"")); + else { + ND_PRINT((ndo, ""\n\tRouter Id"")); + if(len < 10) goto invalid; + ND_PRINT((ndo, "" %s"", format_id(message + 4))); + } + } + break; + + case MESSAGE_NH: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" nh"")); + else { + int rc; + u_char nh[16]; + ND_PRINT((ndo, ""\n\tNext Hop"")); + if(len < 2) goto invalid; + rc = network_address(message[2], message + 4, len - 2, nh); + if(rc < 0) goto invalid; + ND_PRINT((ndo, "" %s"", format_address(ndo, nh))); + } + } + break; + + case MESSAGE_UPDATE: { + if (!ndo->ndo_vflag) { + ND_PRINT((ndo, "" update"")); + if(len < 1) + ND_PRINT((ndo, ""/truncated"")); + else + ND_PRINT((ndo, ""%s%s%s"", + (message[3] & 0x80) ? ""/prefix"": """", + (message[3] & 0x40) ? ""/id"" : """", + (message[3] & 0x3f) ? ""/unknown"" : """")); + } else { + u_short interval, seqno, metric; + u_char plen; + int rc; + u_char prefix[16]; + ND_PRINT((ndo, ""\n\tUpdate"")); + if(len < 10) goto invalid; + plen = message[4] + (message[2] == 1 ? 96 : 0); + rc = network_prefix(message[2], message[4], message[5], + message + 12, + message[2] == 1 ? v4_prefix : v6_prefix, + len - 10, prefix); + if(rc < 0) goto invalid; + interval = EXTRACT_16BITS(message + 6); + seqno = EXTRACT_16BITS(message + 8); + metric = EXTRACT_16BITS(message + 10); + ND_PRINT((ndo, ""%s%s%s %s metric %u seqno %u interval %s"", + (message[3] & 0x80) ? ""/prefix"": """", + (message[3] & 0x40) ? ""/id"" : """", + (message[3] & 0x3f) ? ""/unknown"" : """", + format_prefix(ndo, prefix, plen), + metric, seqno, format_interval_update(interval))); + if(message[3] & 0x80) { + if(message[2] == 1) + memcpy(v4_prefix, prefix, 16); + else + memcpy(v6_prefix, prefix, 16); + } + /* extra data? */ + if((u_int)rc < len - 10) + subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type); + } + } + break; + + case MESSAGE_REQUEST: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" request"")); + else { + int rc; + u_char prefix[16], plen; + ND_PRINT((ndo, ""\n\tRequest "")); + if(len < 2) goto invalid; + plen = message[3] + (message[2] == 1 ? 96 : 0); + rc = network_prefix(message[2], message[3], 0, + message + 4, NULL, len - 2, prefix); + if(rc < 0) goto invalid; + ND_PRINT((ndo, ""for %s"", + message[2] == 0 ? ""any"" : format_prefix(ndo, prefix, plen))); + } + } + break; + + case MESSAGE_MH_REQUEST : { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" mh-request"")); + else { + int rc; + u_short seqno; + u_char prefix[16], plen; + ND_PRINT((ndo, ""\n\tMH-Request "")); + if(len < 14) goto invalid; + seqno = EXTRACT_16BITS(message + 4); + rc = network_prefix(message[2], message[3], 0, + message + 16, NULL, len - 14, prefix); + if(rc < 0) goto invalid; + plen = message[3] + (message[2] == 1 ? 96 : 0); + ND_PRINT((ndo, ""(%u hops) for %s seqno %u id %s"", + message[6], format_prefix(ndo, prefix, plen), + seqno, format_id(message + 8))); + } + } + break; + case MESSAGE_TSPC : + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" tspc"")); + else { + ND_PRINT((ndo, ""\n\tTS/PC "")); + if(len < 6) goto invalid; + ND_PRINT((ndo, ""timestamp %u packetcounter %u"", EXTRACT_32BITS (message + 4), + EXTRACT_16BITS(message + 2))); + } + break; + case MESSAGE_HMAC : { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" hmac"")); + else { + unsigned j; + ND_PRINT((ndo, ""\n\tHMAC "")); + if(len < 18) goto invalid; + ND_PRINT((ndo, ""key-id %u digest-%u "", EXTRACT_16BITS(message + 2), len - 2)); + for (j = 0; j < len - 2; j++) + ND_PRINT((ndo, ""%02X"", message[4 + j])); + } + } + break; + + case MESSAGE_UPDATE_SRC_SPECIFIC : { + if(!ndo->ndo_vflag) { + ND_PRINT((ndo, "" ss-update"")); + } else { + u_char prefix[16], src_prefix[16]; + u_short interval, seqno, metric; + u_char ae, plen, src_plen, omitted; + int rc; + int parsed_len = 10; + ND_PRINT((ndo, ""\n\tSS-Update"")); + if(len < 10) goto invalid; + ae = message[2]; + src_plen = message[3]; + plen = message[4]; + omitted = message[5]; + interval = EXTRACT_16BITS(message + 6); + seqno = EXTRACT_16BITS(message + 8); + metric = EXTRACT_16BITS(message + 10); + rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len, + ae == 1 ? v4_prefix : v6_prefix, + len - parsed_len, prefix); + if(rc < 0) goto invalid; + if(ae == 1) + plen += 96; + parsed_len += rc; + rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, src_prefix); + if(rc < 0) goto invalid; + if(ae == 1) + src_plen += 96; + parsed_len += rc; + + ND_PRINT((ndo, "" %s from"", format_prefix(ndo, prefix, plen))); + ND_PRINT((ndo, "" %s metric %u seqno %u interval %s"", + format_prefix(ndo, src_prefix, src_plen), + metric, seqno, format_interval_update(interval))); + /* extra data? */ + if((u_int)parsed_len < len) + subtlvs_print(ndo, message + 2 + parsed_len, + message + 2 + len, type); + } + } + break; + + case MESSAGE_REQUEST_SRC_SPECIFIC : { + if(!ndo->ndo_vflag) + ND_PRINT((ndo, "" ss-request"")); + else { + int rc, parsed_len = 3; + u_char ae, plen, src_plen, prefix[16], src_prefix[16]; + ND_PRINT((ndo, ""\n\tSS-Request "")); + if(len < 3) goto invalid; + ae = message[2]; + plen = message[3]; + src_plen = message[4]; + rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, prefix); + if(rc < 0) goto invalid; + if(ae == 1) + plen += 96; + parsed_len += rc; + rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, src_prefix); + if(rc < 0) goto invalid; + if(ae == 1) + src_plen += 96; + parsed_len += rc; + if(ae == 0) { + ND_PRINT((ndo, ""for any"")); + } else { + ND_PRINT((ndo, ""for (%s, "", format_prefix(ndo, prefix, plen))); + ND_PRINT((ndo, ""%s)"", format_prefix(ndo, src_prefix, src_plen))); + } + } + } + break; + + case MESSAGE_MH_REQUEST_SRC_SPECIFIC : { + if(!ndo->ndo_vflag) + ND_PRINT((ndo, "" ss-mh-request"")); + else { + int rc, parsed_len = 14; + u_short seqno; + u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc; + const u_char *router_id = NULL; + ND_PRINT((ndo, ""\n\tSS-MH-Request "")); + if(len < 14) goto invalid; + ae = message[2]; + plen = message[3]; + seqno = EXTRACT_16BITS(message + 4); + hopc = message[6]; + src_plen = message[7]; + router_id = message + 8; + rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, prefix); + if(rc < 0) goto invalid; + if(ae == 1) + plen += 96; + parsed_len += rc; + rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, src_prefix); + if(rc < 0) goto invalid; + if(ae == 1) + src_plen += 96; + ND_PRINT((ndo, ""(%u hops) for (%s, "", + hopc, format_prefix(ndo, prefix, plen))); + ND_PRINT((ndo, ""%s) seqno %u id %s"", + format_prefix(ndo, src_prefix, src_plen), + seqno, format_id(router_id))); + } + } + break; + + default: + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" unknown"")); + else + ND_PRINT((ndo, ""\n\tUnknown message type %d"", type)); + } + i += len + 2; + } + return; + + trunc: + ND_PRINT((ndo, "" %s"", tstr)); + return; + + invalid: + ND_PRINT((ndo, ""%s"", istr)); + return; +} +",1,"babel_print_v2(netdissect_options *ndo, + const u_char *cp, u_int length) +{ + u_int i; + u_short bodylen; + u_char v4_prefix[16] = + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; + u_char v6_prefix[16] = {0}; + + ND_TCHECK2(*cp, 4); + if (length < 4) + goto invalid; + bodylen = EXTRACT_16BITS(cp + 2); + ND_PRINT((ndo, "" (%u)"", bodylen)); + + /* Process the TLVs in the body */ + i = 0; + while(i < bodylen) { + const u_char *message; + u_int type, len; + + message = cp + 4 + i; + + ND_TCHECK2(*message, 1); + if((type = message[0]) == MESSAGE_PAD1) { + ND_PRINT((ndo, ndo->ndo_vflag ? ""\n\tPad 1"" : "" pad1"")); + i += 1; + continue; + } + + ND_TCHECK2(*message, 2); + ICHECK(i, 2); + len = message[1]; + + ND_TCHECK2(*message, 2 + len); + ICHECK(i, 2 + len); + + switch(type) { + case MESSAGE_PADN: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" padN"")); + else + ND_PRINT((ndo, ""\n\tPad %d"", len + 2)); + } + break; + + case MESSAGE_ACK_REQ: { + u_short nonce, interval; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" ack-req"")); + else { + ND_PRINT((ndo, ""\n\tAcknowledgment Request "")); + if(len < 6) goto invalid; + nonce = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + ND_PRINT((ndo, ""%04x %s"", nonce, format_interval(interval))); + } + } + break; + + case MESSAGE_ACK: { + u_short nonce; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" ack"")); + else { + ND_PRINT((ndo, ""\n\tAcknowledgment "")); + if(len < 2) goto invalid; + nonce = EXTRACT_16BITS(message + 2); + ND_PRINT((ndo, ""%04x"", nonce)); + } + } + break; + + case MESSAGE_HELLO: { + u_short seqno, interval; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" hello"")); + else { + ND_PRINT((ndo, ""\n\tHello "")); + if(len < 6) goto invalid; + seqno = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + ND_PRINT((ndo, ""seqno %u interval %s"", seqno, format_interval(interval))); + /* Extra data. */ + if(len > 6) + subtlvs_print(ndo, message + 8, message + 2 + len, type); + } + } + break; + + case MESSAGE_IHU: { + unsigned short txcost, interval; + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" ihu"")); + else { + u_char address[16]; + int rc; + ND_PRINT((ndo, ""\n\tIHU "")); + if(len < 6) goto invalid; + txcost = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + rc = network_address(message[2], message + 8, len - 6, address); + if(rc < 0) { ND_PRINT((ndo, ""%s"", tstr)); break; } + ND_PRINT((ndo, ""%s txcost %u interval %s"", + format_address(ndo, address), txcost, format_interval(interval))); + /* Extra data. */ + if((u_int)rc < len - 6) + subtlvs_print(ndo, message + 8 + rc, message + 2 + len, + type); + } + } + break; + + case MESSAGE_ROUTER_ID: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" router-id"")); + else { + ND_PRINT((ndo, ""\n\tRouter Id"")); + if(len < 10) goto invalid; + ND_PRINT((ndo, "" %s"", format_id(message + 4))); + } + } + break; + + case MESSAGE_NH: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" nh"")); + else { + int rc; + u_char nh[16]; + ND_PRINT((ndo, ""\n\tNext Hop"")); + if(len < 2) goto invalid; + rc = network_address(message[2], message + 4, len - 2, nh); + if(rc < 0) goto invalid; + ND_PRINT((ndo, "" %s"", format_address(ndo, nh))); + } + } + break; + + case MESSAGE_UPDATE: { + if (!ndo->ndo_vflag) { + ND_PRINT((ndo, "" update"")); + if(len < 10) + ND_PRINT((ndo, ""/truncated"")); + else + ND_PRINT((ndo, ""%s%s%s"", + (message[3] & 0x80) ? ""/prefix"": """", + (message[3] & 0x40) ? ""/id"" : """", + (message[3] & 0x3f) ? ""/unknown"" : """")); + } else { + u_short interval, seqno, metric; + u_char plen; + int rc; + u_char prefix[16]; + ND_PRINT((ndo, ""\n\tUpdate"")); + if(len < 10) goto invalid; + plen = message[4] + (message[2] == 1 ? 96 : 0); + rc = network_prefix(message[2], message[4], message[5], + message + 12, + message[2] == 1 ? v4_prefix : v6_prefix, + len - 10, prefix); + if(rc < 0) goto invalid; + interval = EXTRACT_16BITS(message + 6); + seqno = EXTRACT_16BITS(message + 8); + metric = EXTRACT_16BITS(message + 10); + ND_PRINT((ndo, ""%s%s%s %s metric %u seqno %u interval %s"", + (message[3] & 0x80) ? ""/prefix"": """", + (message[3] & 0x40) ? ""/id"" : """", + (message[3] & 0x3f) ? ""/unknown"" : """", + format_prefix(ndo, prefix, plen), + metric, seqno, format_interval_update(interval))); + if(message[3] & 0x80) { + if(message[2] == 1) + memcpy(v4_prefix, prefix, 16); + else + memcpy(v6_prefix, prefix, 16); + } + /* extra data? */ + if((u_int)rc < len - 10) + subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type); + } + } + break; + + case MESSAGE_REQUEST: { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" request"")); + else { + int rc; + u_char prefix[16], plen; + ND_PRINT((ndo, ""\n\tRequest "")); + if(len < 2) goto invalid; + plen = message[3] + (message[2] == 1 ? 96 : 0); + rc = network_prefix(message[2], message[3], 0, + message + 4, NULL, len - 2, prefix); + if(rc < 0) goto invalid; + ND_PRINT((ndo, ""for %s"", + message[2] == 0 ? ""any"" : format_prefix(ndo, prefix, plen))); + } + } + break; + + case MESSAGE_MH_REQUEST : { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" mh-request"")); + else { + int rc; + u_short seqno; + u_char prefix[16], plen; + ND_PRINT((ndo, ""\n\tMH-Request "")); + if(len < 14) goto invalid; + seqno = EXTRACT_16BITS(message + 4); + rc = network_prefix(message[2], message[3], 0, + message + 16, NULL, len - 14, prefix); + if(rc < 0) goto invalid; + plen = message[3] + (message[2] == 1 ? 96 : 0); + ND_PRINT((ndo, ""(%u hops) for %s seqno %u id %s"", + message[6], format_prefix(ndo, prefix, plen), + seqno, format_id(message + 8))); + } + } + break; + case MESSAGE_TSPC : + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" tspc"")); + else { + ND_PRINT((ndo, ""\n\tTS/PC "")); + if(len < 6) goto invalid; + ND_PRINT((ndo, ""timestamp %u packetcounter %u"", EXTRACT_32BITS (message + 4), + EXTRACT_16BITS(message + 2))); + } + break; + case MESSAGE_HMAC : { + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" hmac"")); + else { + unsigned j; + ND_PRINT((ndo, ""\n\tHMAC "")); + if(len < 18) goto invalid; + ND_PRINT((ndo, ""key-id %u digest-%u "", EXTRACT_16BITS(message + 2), len - 2)); + for (j = 0; j < len - 2; j++) + ND_PRINT((ndo, ""%02X"", message[4 + j])); + } + } + break; + + case MESSAGE_UPDATE_SRC_SPECIFIC : { + if(!ndo->ndo_vflag) { + ND_PRINT((ndo, "" ss-update"")); + } else { + u_char prefix[16], src_prefix[16]; + u_short interval, seqno, metric; + u_char ae, plen, src_plen, omitted; + int rc; + int parsed_len = 10; + ND_PRINT((ndo, ""\n\tSS-Update"")); + if(len < 10) goto invalid; + ae = message[2]; + src_plen = message[3]; + plen = message[4]; + omitted = message[5]; + interval = EXTRACT_16BITS(message + 6); + seqno = EXTRACT_16BITS(message + 8); + metric = EXTRACT_16BITS(message + 10); + rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len, + ae == 1 ? v4_prefix : v6_prefix, + len - parsed_len, prefix); + if(rc < 0) goto invalid; + if(ae == 1) + plen += 96; + parsed_len += rc; + rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, src_prefix); + if(rc < 0) goto invalid; + if(ae == 1) + src_plen += 96; + parsed_len += rc; + + ND_PRINT((ndo, "" %s from"", format_prefix(ndo, prefix, plen))); + ND_PRINT((ndo, "" %s metric %u seqno %u interval %s"", + format_prefix(ndo, src_prefix, src_plen), + metric, seqno, format_interval_update(interval))); + /* extra data? */ + if((u_int)parsed_len < len) + subtlvs_print(ndo, message + 2 + parsed_len, + message + 2 + len, type); + } + } + break; + + case MESSAGE_REQUEST_SRC_SPECIFIC : { + if(!ndo->ndo_vflag) + ND_PRINT((ndo, "" ss-request"")); + else { + int rc, parsed_len = 3; + u_char ae, plen, src_plen, prefix[16], src_prefix[16]; + ND_PRINT((ndo, ""\n\tSS-Request "")); + if(len < 3) goto invalid; + ae = message[2]; + plen = message[3]; + src_plen = message[4]; + rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, prefix); + if(rc < 0) goto invalid; + if(ae == 1) + plen += 96; + parsed_len += rc; + rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, src_prefix); + if(rc < 0) goto invalid; + if(ae == 1) + src_plen += 96; + parsed_len += rc; + if(ae == 0) { + ND_PRINT((ndo, ""for any"")); + } else { + ND_PRINT((ndo, ""for (%s, "", format_prefix(ndo, prefix, plen))); + ND_PRINT((ndo, ""%s)"", format_prefix(ndo, src_prefix, src_plen))); + } + } + } + break; + + case MESSAGE_MH_REQUEST_SRC_SPECIFIC : { + if(!ndo->ndo_vflag) + ND_PRINT((ndo, "" ss-mh-request"")); + else { + int rc, parsed_len = 14; + u_short seqno; + u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc; + const u_char *router_id = NULL; + ND_PRINT((ndo, ""\n\tSS-MH-Request "")); + if(len < 14) goto invalid; + ae = message[2]; + plen = message[3]; + seqno = EXTRACT_16BITS(message + 4); + hopc = message[6]; + src_plen = message[7]; + router_id = message + 8; + rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, prefix); + if(rc < 0) goto invalid; + if(ae == 1) + plen += 96; + parsed_len += rc; + rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, + NULL, len - parsed_len, src_prefix); + if(rc < 0) goto invalid; + if(ae == 1) + src_plen += 96; + ND_PRINT((ndo, ""(%u hops) for (%s, "", + hopc, format_prefix(ndo, prefix, plen))); + ND_PRINT((ndo, ""%s) seqno %u id %s"", + format_prefix(ndo, src_prefix, src_plen), + seqno, format_id(router_id))); + } + } + break; + + default: + if (!ndo->ndo_vflag) + ND_PRINT((ndo, "" unknown"")); + else + ND_PRINT((ndo, ""\n\tUnknown message type %d"", type)); + } + i += len + 2; + } + return; + + trunc: + ND_PRINT((ndo, "" %s"", tstr)); + return; + + invalid: + ND_PRINT((ndo, ""%s"", istr)); + return; +} +","@@ -480,7 +480,7 @@ babel_print_v2(netdissect_options *ndo, + case MESSAGE_UPDATE: { + if (!ndo->ndo_vflag) { + ND_PRINT((ndo, "" update"")); +- if(len < 1) ++ if(len < 10) + ND_PRINT((ndo, ""/truncated"")); + else + ND_PRINT((ndo, ""%s%s%s"",",3480,3716,4096 +15325,"void DesktopWindowTreeHostX11::InitX11Window( + const Widget::InitParams& params) { + unsigned long attribute_mask = CWBackPixel | CWBitGravity; + XSetWindowAttributes swa; + memset(&swa, 0, sizeof(swa)); + swa.background_pixmap = x11::None; + swa.bit_gravity = NorthWestGravity; + + int background_color; + + const views::LinuxUI* linux_ui = views::LinuxUI::instance(); + if (linux_ui && content_window()) { + ui::NativeTheme::ColorId target_color; + switch (params.type) { + case Widget::InitParams::TYPE_BUBBLE: + target_color = ui::NativeTheme::kColorId_BubbleBackground; + break; + case Widget::InitParams::TYPE_TOOLTIP: + target_color = ui::NativeTheme::kColorId_TooltipBackground; + break; + default: + target_color = ui::NativeTheme::kColorId_WindowBackground; + break; + } + + ui::NativeTheme* theme = linux_ui->GetNativeTheme(content_window()); + background_color = theme->GetSystemColor(target_color); + } else { + background_color = WhitePixel(xdisplay_, DefaultScreen(xdisplay_)); + } + swa.background_pixel = background_color; + + XAtom window_type; + switch (params.type) { + case Widget::InitParams::TYPE_MENU: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_MENU""); + break; + case Widget::InitParams::TYPE_TOOLTIP: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_TOOLTIP""); + break; + case Widget::InitParams::TYPE_POPUP: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_NOTIFICATION""); + break; + case Widget::InitParams::TYPE_DRAG: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_DND""); + break; + default: + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_NORMAL""); + break; + } + if (!activatable_) + swa.override_redirect = x11::True; + + override_redirect_ = swa.override_redirect == x11::True; + if (override_redirect_) + attribute_mask |= CWOverrideRedirect; + + bool enable_transparent_visuals; + switch (params.opacity) { + case Widget::InitParams::OPAQUE_WINDOW: + enable_transparent_visuals = false; + break; + case Widget::InitParams::TRANSLUCENT_WINDOW: + enable_transparent_visuals = true; + break; + case Widget::InitParams::INFER_OPACITY: + default: + enable_transparent_visuals = params.type == Widget::InitParams::TYPE_DRAG; + } + + Visual* visual = CopyFromParent; + int depth = CopyFromParent; + Colormap colormap = CopyFromParent; + ui::XVisualManager::GetInstance()->ChooseVisualForWindow( + enable_transparent_visuals, &visual, &depth, &colormap, + &use_argb_visual_); + + if (colormap != CopyFromParent) { + attribute_mask |= CWColormap; + swa.colormap = colormap; + } + + attribute_mask |= CWBorderPixel; + swa.border_pixel = 0; + + bounds_in_pixels_ = ToPixelRect(params.bounds); + bounds_in_pixels_.set_size(AdjustSize(bounds_in_pixels_.size())); + xwindow_ = XCreateWindow(xdisplay_, x_root_window_, bounds_in_pixels_.x(), + bounds_in_pixels_.y(), bounds_in_pixels_.width(), + bounds_in_pixels_.height(), + 0, // border width + depth, InputOutput, visual, attribute_mask, &swa); + if (ui::PlatformEventSource::GetInstance()) + ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); + open_windows().push_front(xwindow_); + + + long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | + KeyPressMask | KeyReleaseMask | + EnterWindowMask | LeaveWindowMask | + ExposureMask | VisibilityChangeMask | + StructureNotifyMask | PropertyChangeMask | + PointerMotionMask; + xwindow_events_ = + std::make_unique(xwindow_, event_mask); + XFlush(xdisplay_); + + if (ui::IsXInput2Available()) + ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); + + XAtom protocols[2]; + protocols[0] = gfx::GetAtom(""WM_DELETE_WINDOW""); + protocols[1] = gfx::GetAtom(""_NET_WM_PING""); + XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); + + XSetWMProperties(xdisplay_, xwindow_, nullptr, nullptr, nullptr, 0, nullptr, + nullptr, nullptr); + + static_assert(sizeof(long) >= sizeof(pid_t), + ""pid_t should not be larger than long""); + long pid = getpid(); + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(""_NET_WM_PID""), XA_CARDINAL, + 32, PropModeReplace, reinterpret_cast(&pid), + 1); + + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(""_NET_WM_WINDOW_TYPE""), + XA_ATOM, 32, PropModeReplace, + reinterpret_cast(&window_type), 1); + + + if ((params.type == Widget::InitParams::TYPE_POPUP || + params.type == Widget::InitParams::TYPE_BUBBLE) && + !params.force_show_in_taskbar) { + window_properties_.insert(gfx::GetAtom(""_NET_WM_STATE_SKIP_TASKBAR"")); + } + + is_always_on_top_ = params.keep_on_top; + if (is_always_on_top_) + window_properties_.insert(gfx::GetAtom(""_NET_WM_STATE_ABOVE"")); + + workspace_ = base::nullopt; + if (params.visible_on_all_workspaces) { + window_properties_.insert(gfx::GetAtom(""_NET_WM_STATE_STICKY"")); + ui::SetIntProperty(xwindow_, ""_NET_WM_DESKTOP"", ""CARDINAL"", kAllDesktops); + } else if (!params.workspace.empty()) { + int workspace; + if (base::StringToInt(params.workspace, &workspace)) + ui::SetIntProperty(xwindow_, ""_NET_WM_DESKTOP"", ""CARDINAL"", workspace); + } + + if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { + ui::SetWindowClassHint( + xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); + } + + const char* wm_role_name = nullptr; + if (!params.wm_role_name.empty()) { + wm_role_name = params.wm_role_name.c_str(); + } else { + switch (params.type) { + case Widget::InitParams::TYPE_POPUP: + wm_role_name = kX11WindowRolePopup; + break; + case Widget::InitParams::TYPE_BUBBLE: + wm_role_name = kX11WindowRoleBubble; + break; + default: + break; + } + } + if (wm_role_name) + ui::SetWindowRole(xdisplay_, xwindow_, std::string(wm_role_name)); + + if (params.remove_standard_frame) { + ui::SetHideTitlebarWhenMaximizedProperty(xwindow_, + ui::HIDE_TITLEBAR_WHEN_MAXIMIZED); + } + + if (views::LinuxUI::instance() && + views::LinuxUI::instance()->PreferDarkTheme()) { + const unsigned char kDarkGtkThemeVariant[] = ""dark""; + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(""_GTK_THEME_VARIANT""), + gfx::GetAtom(""UTF8_STRING""), 8, PropModeReplace, + kDarkGtkThemeVariant, base::size(kDarkGtkThemeVariant) - 1); + } + + ui::SetIntProperty(xwindow_, ""_NET_WM_BYPASS_COMPOSITOR"", ""CARDINAL"", 2); + + if (params.parent && params.parent->GetHost()) { + XID parent_xid = + params.parent->GetHost()->GetAcceleratedWidget(); + window_parent_ = GetHostForXID(parent_xid); + DCHECK(window_parent_); + window_parent_->window_children_.insert(this); + } + + gfx::ImageSkia* window_icon = + ViewsDelegate::GetInstance() + ? ViewsDelegate::GetInstance()->GetDefaultWindowIcon() + : nullptr; + if (window_icon) { + SetWindowIcons(gfx::ImageSkia(), *window_icon); + } + CreateCompositor(viz::FrameSinkId(), + params.type == Widget::InitParams::TYPE_TOOLTIP); + OnAcceleratedWidgetAvailable(); +} +",0,"void DesktopWindowTreeHostX11::InitX11Window( + const Widget::InitParams& params) { + unsigned long attribute_mask = CWBackPixel | CWBitGravity; + XSetWindowAttributes swa; + memset(&swa, 0, sizeof(swa)); + swa.background_pixmap = x11::None; + swa.bit_gravity = NorthWestGravity; + + int background_color; + + const views::LinuxUI* linux_ui = views::LinuxUI::instance(); + if (linux_ui && content_window()) { + ui::NativeTheme::ColorId target_color; + switch (params.type) { + case Widget::InitParams::TYPE_BUBBLE: + target_color = ui::NativeTheme::kColorId_BubbleBackground; + break; + case Widget::InitParams::TYPE_TOOLTIP: + target_color = ui::NativeTheme::kColorId_TooltipBackground; + break; + default: + target_color = ui::NativeTheme::kColorId_WindowBackground; + break; + } + + ui::NativeTheme* theme = linux_ui->GetNativeTheme(content_window()); + background_color = theme->GetSystemColor(target_color); + } else { + background_color = WhitePixel(xdisplay_, DefaultScreen(xdisplay_)); + } + swa.background_pixel = background_color; + + XAtom window_type; + switch (params.type) { + case Widget::InitParams::TYPE_MENU: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_MENU""); + break; + case Widget::InitParams::TYPE_TOOLTIP: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_TOOLTIP""); + break; + case Widget::InitParams::TYPE_POPUP: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_NOTIFICATION""); + break; + case Widget::InitParams::TYPE_DRAG: + swa.override_redirect = x11::True; + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_DND""); + break; + default: + window_type = gfx::GetAtom(""_NET_WM_WINDOW_TYPE_NORMAL""); + break; + } + if (!activatable_) + swa.override_redirect = x11::True; + + override_redirect_ = swa.override_redirect == x11::True; + if (override_redirect_) + attribute_mask |= CWOverrideRedirect; + + bool enable_transparent_visuals; + switch (params.opacity) { + case Widget::InitParams::OPAQUE_WINDOW: + enable_transparent_visuals = false; + break; + case Widget::InitParams::TRANSLUCENT_WINDOW: + enable_transparent_visuals = true; + break; + case Widget::InitParams::INFER_OPACITY: + default: + enable_transparent_visuals = params.type == Widget::InitParams::TYPE_DRAG; + } + + Visual* visual = CopyFromParent; + int depth = CopyFromParent; + Colormap colormap = CopyFromParent; + ui::XVisualManager::GetInstance()->ChooseVisualForWindow( + enable_transparent_visuals, &visual, &depth, &colormap, + &use_argb_visual_); + + if (colormap != CopyFromParent) { + attribute_mask |= CWColormap; + swa.colormap = colormap; + } + + attribute_mask |= CWBorderPixel; + swa.border_pixel = 0; + + bounds_in_pixels_ = ToPixelRect(params.bounds); + bounds_in_pixels_.set_size(AdjustSize(bounds_in_pixels_.size())); + xwindow_ = XCreateWindow(xdisplay_, x_root_window_, bounds_in_pixels_.x(), + bounds_in_pixels_.y(), bounds_in_pixels_.width(), + bounds_in_pixels_.height(), + 0, // border width + depth, InputOutput, visual, attribute_mask, &swa); + if (ui::PlatformEventSource::GetInstance()) + ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); + open_windows().push_front(xwindow_); + + + long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | + KeyPressMask | KeyReleaseMask | + EnterWindowMask | LeaveWindowMask | + ExposureMask | VisibilityChangeMask | + StructureNotifyMask | PropertyChangeMask | + PointerMotionMask; + xwindow_events_ = + std::make_unique(xwindow_, event_mask); + XFlush(xdisplay_); + + if (ui::IsXInput2Available()) + ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); + + XAtom protocols[2]; + protocols[0] = gfx::GetAtom(""WM_DELETE_WINDOW""); + protocols[1] = gfx::GetAtom(""_NET_WM_PING""); + XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); + + XSetWMProperties(xdisplay_, xwindow_, nullptr, nullptr, nullptr, 0, nullptr, + nullptr, nullptr); + + static_assert(sizeof(long) >= sizeof(pid_t), + ""pid_t should not be larger than long""); + long pid = getpid(); + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(""_NET_WM_PID""), XA_CARDINAL, + 32, PropModeReplace, reinterpret_cast(&pid), + 1); + + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(""_NET_WM_WINDOW_TYPE""), + XA_ATOM, 32, PropModeReplace, + reinterpret_cast(&window_type), 1); + + + if ((params.type == Widget::InitParams::TYPE_POPUP || + params.type == Widget::InitParams::TYPE_BUBBLE) && + !params.force_show_in_taskbar) { + window_properties_.insert(gfx::GetAtom(""_NET_WM_STATE_SKIP_TASKBAR"")); + } + + is_always_on_top_ = params.keep_on_top; + if (is_always_on_top_) + window_properties_.insert(gfx::GetAtom(""_NET_WM_STATE_ABOVE"")); + + workspace_ = base::nullopt; + if (params.visible_on_all_workspaces) { + window_properties_.insert(gfx::GetAtom(""_NET_WM_STATE_STICKY"")); + ui::SetIntProperty(xwindow_, ""_NET_WM_DESKTOP"", ""CARDINAL"", kAllDesktops); + } else if (!params.workspace.empty()) { + int workspace; + if (base::StringToInt(params.workspace, &workspace)) + ui::SetIntProperty(xwindow_, ""_NET_WM_DESKTOP"", ""CARDINAL"", workspace); + } + + if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { + ui::SetWindowClassHint( + xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); + } + + const char* wm_role_name = nullptr; + if (!params.wm_role_name.empty()) { + wm_role_name = params.wm_role_name.c_str(); + } else { + switch (params.type) { + case Widget::InitParams::TYPE_POPUP: + wm_role_name = kX11WindowRolePopup; + break; + case Widget::InitParams::TYPE_BUBBLE: + wm_role_name = kX11WindowRoleBubble; + break; + default: + break; + } + } + if (wm_role_name) + ui::SetWindowRole(xdisplay_, xwindow_, std::string(wm_role_name)); + + if (params.remove_standard_frame) { + ui::SetHideTitlebarWhenMaximizedProperty(xwindow_, + ui::HIDE_TITLEBAR_WHEN_MAXIMIZED); + } + + if (views::LinuxUI::instance() && + views::LinuxUI::instance()->PreferDarkTheme()) { + const unsigned char kDarkGtkThemeVariant[] = ""dark""; + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(""_GTK_THEME_VARIANT""), + gfx::GetAtom(""UTF8_STRING""), 8, PropModeReplace, + kDarkGtkThemeVariant, base::size(kDarkGtkThemeVariant) - 1); + } + + ui::SetIntProperty(xwindow_, ""_NET_WM_BYPASS_COMPOSITOR"", ""CARDINAL"", 2); + + if (params.parent && params.parent->GetHost()) { + XID parent_xid = + params.parent->GetHost()->GetAcceleratedWidget(); + window_parent_ = GetHostForXID(parent_xid); + DCHECK(window_parent_); + window_parent_->window_children_.insert(this); + } + + gfx::ImageSkia* window_icon = + ViewsDelegate::GetInstance() + ? ViewsDelegate::GetInstance()->GetDefaultWindowIcon() + : nullptr; + if (window_icon) { + SetWindowIcons(gfx::ImageSkia(), *window_icon); + } + CreateCompositor(viz::FrameSinkId(), + params.type == Widget::InitParams::TYPE_TOOLTIP); + OnAcceleratedWidgetAvailable(); +} +","@@ -855,10 +855,13 @@ bool DesktopWindowTreeHostX11::IsAlwaysOnTop() const { + } + + void DesktopWindowTreeHostX11::SetVisible(bool visible) { ++ if (is_compositor_set_visible_ == visible) ++ return; ++ ++ is_compositor_set_visible_ = visible; + if (compositor()) + compositor()->SetVisible(visible); +- if (IsVisible() != visible) +- native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); ++ native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); + } + + void DesktopWindowTreeHostX11::SetVisibleOnAllWorkspaces(bool always_visible) {",1886,2122,4096 +4286,"int md_run(struct mddev *mddev) +{ + int err; + struct md_rdev *rdev; + struct md_personality *pers; + + if (list_empty(&mddev->disks)) + /* cannot run an array with no devices.. */ + return -EINVAL; + + if (mddev->pers) + return -EBUSY; + /* Cannot run until previous stop completes properly */ + if (mddev->sysfs_active) + return -EBUSY; + + /* + * Analyze all RAID superblock(s) + */ + if (!mddev->raid_disks) { + if (!mddev->persistent) + return -EINVAL; + analyze_sbs(mddev); + } + + if (mddev->level != LEVEL_NONE) + request_module(""md-level-%d"", mddev->level); + else if (mddev->clevel[0]) + request_module(""md-%s"", mddev->clevel); + + /* + * Drop all container device buffers, from now on + * the only valid external interface is through the md + * device. + */ + rdev_for_each(rdev, mddev) { + if (test_bit(Faulty, &rdev->flags)) + continue; + sync_blockdev(rdev->bdev); + invalidate_bdev(rdev->bdev); + + /* perform some consistency tests on the device. + * We don't want the data to overlap the metadata, + * Internal Bitmap issues have been handled elsewhere. + */ + if (rdev->meta_bdev) { + /* Nothing to check */; + } else if (rdev->data_offset < rdev->sb_start) { + if (mddev->dev_sectors && + rdev->data_offset + mddev->dev_sectors + > rdev->sb_start) { + printk(""md: %s: data overlaps metadata\n"", + mdname(mddev)); + return -EINVAL; + } + } else { + if (rdev->sb_start + rdev->sb_size/512 + > rdev->data_offset) { + printk(""md: %s: metadata overlaps data\n"", + mdname(mddev)); + return -EINVAL; + } + } + sysfs_notify_dirent_safe(rdev->sysfs_state); + } + + if (mddev->bio_set == NULL) + mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0); + + spin_lock(&pers_lock); + pers = find_pers(mddev->level, mddev->clevel); + if (!pers || !try_module_get(pers->owner)) { + spin_unlock(&pers_lock); + if (mddev->level != LEVEL_NONE) + printk(KERN_WARNING ""md: personality for level %d is not loaded!\n"", + mddev->level); + else + printk(KERN_WARNING ""md: personality for level %s is not loaded!\n"", + mddev->clevel); + return -EINVAL; + } + spin_unlock(&pers_lock); + if (mddev->level != pers->level) { + mddev->level = pers->level; + mddev->new_level = pers->level; + } + strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); + + if (mddev->reshape_position != MaxSector && + pers->start_reshape == NULL) { + /* This personality cannot handle reshaping... */ + module_put(pers->owner); + return -EINVAL; + } + + if (pers->sync_request) { + /* Warn if this is a potentially silly + * configuration. + */ + char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; + struct md_rdev *rdev2; + int warned = 0; + + rdev_for_each(rdev, mddev) + rdev_for_each(rdev2, mddev) { + if (rdev < rdev2 && + rdev->bdev->bd_contains == + rdev2->bdev->bd_contains) { + printk(KERN_WARNING + ""%s: WARNING: %s appears to be"" + "" on the same physical disk as"" + "" %s.\n"", + mdname(mddev), + bdevname(rdev->bdev,b), + bdevname(rdev2->bdev,b2)); + warned = 1; + } + } + + if (warned) + printk(KERN_WARNING + ""True protection against single-disk"" + "" failure might be compromised.\n""); + } + + mddev->recovery = 0; + /* may be over-ridden by personality */ + mddev->resync_max_sectors = mddev->dev_sectors; + + mddev->ok_start_degraded = start_dirty_degraded; + + if (start_readonly && mddev->ro == 0) + mddev->ro = 2; /* read-only, but switch on first write */ + + err = pers->run(mddev); + if (err) + printk(KERN_ERR ""md: pers->run() failed ...\n""); + else if (pers->size(mddev, 0, 0) < mddev->array_sectors) { + WARN_ONCE(!mddev->external_size, ""%s: default size too small,"" + "" but 'external_size' not in effect?\n"", __func__); + printk(KERN_ERR + ""md: invalid array_size %llu > default size %llu\n"", + (unsigned long long)mddev->array_sectors / 2, + (unsigned long long)pers->size(mddev, 0, 0) / 2); + err = -EINVAL; + } + if (err == 0 && pers->sync_request && + (mddev->bitmap_info.file || mddev->bitmap_info.offset)) { + struct bitmap *bitmap; + + bitmap = bitmap_create(mddev, -1); + if (IS_ERR(bitmap)) { + err = PTR_ERR(bitmap); + printk(KERN_ERR ""%s: failed to create bitmap (%d)\n"", + mdname(mddev), err); + } else + mddev->bitmap = bitmap; + + } + if (err) { + mddev_detach(mddev); + if (mddev->private) + pers->free(mddev, mddev->private); + mddev->private = NULL; + module_put(pers->owner); + bitmap_destroy(mddev); + return err; + } + if (mddev->queue) { + mddev->queue->backing_dev_info.congested_data = mddev; + mddev->queue->backing_dev_info.congested_fn = md_congested; + blk_queue_merge_bvec(mddev->queue, md_mergeable_bvec); + } + if (pers->sync_request) { + if (mddev->kobj.sd && + sysfs_create_group(&mddev->kobj, &md_redundancy_group)) + printk(KERN_WARNING + ""md: cannot register extra attributes for %s\n"", + mdname(mddev)); + mddev->sysfs_action = sysfs_get_dirent_safe(mddev->kobj.sd, ""sync_action""); + } else if (mddev->ro == 2) /* auto-readonly not meaningful */ + mddev->ro = 0; + + atomic_set(&mddev->writes_pending,0); + atomic_set(&mddev->max_corr_read_errors, + MD_DEFAULT_MAX_CORRECTED_READ_ERRORS); + mddev->safemode = 0; + mddev->safemode_timer.function = md_safemode_timeout; + mddev->safemode_timer.data = (unsigned long) mddev; + mddev->safemode_delay = (200 * HZ)/1000 +1; /* 200 msec delay */ + mddev->in_sync = 1; + smp_wmb(); + spin_lock(&mddev->lock); + mddev->pers = pers; + mddev->ready = 1; + spin_unlock(&mddev->lock); + rdev_for_each(rdev, mddev) + if (rdev->raid_disk >= 0) + if (sysfs_link_rdev(mddev, rdev)) + /* failure here is OK */; + + set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + + if (mddev->flags & MD_UPDATE_SB_FLAGS) + md_update_sb(mddev, 0); + + md_new_event(mddev); + sysfs_notify_dirent_safe(mddev->sysfs_state); + sysfs_notify_dirent_safe(mddev->sysfs_action); + sysfs_notify(&mddev->kobj, NULL, ""degraded""); + return 0; +} +",0,"int md_run(struct mddev *mddev) +{ + int err; + struct md_rdev *rdev; + struct md_personality *pers; + + if (list_empty(&mddev->disks)) + /* cannot run an array with no devices.. */ + return -EINVAL; + + if (mddev->pers) + return -EBUSY; + /* Cannot run until previous stop completes properly */ + if (mddev->sysfs_active) + return -EBUSY; + + /* + * Analyze all RAID superblock(s) + */ + if (!mddev->raid_disks) { + if (!mddev->persistent) + return -EINVAL; + analyze_sbs(mddev); + } + + if (mddev->level != LEVEL_NONE) + request_module(""md-level-%d"", mddev->level); + else if (mddev->clevel[0]) + request_module(""md-%s"", mddev->clevel); + + /* + * Drop all container device buffers, from now on + * the only valid external interface is through the md + * device. + */ + rdev_for_each(rdev, mddev) { + if (test_bit(Faulty, &rdev->flags)) + continue; + sync_blockdev(rdev->bdev); + invalidate_bdev(rdev->bdev); + + /* perform some consistency tests on the device. + * We don't want the data to overlap the metadata, + * Internal Bitmap issues have been handled elsewhere. + */ + if (rdev->meta_bdev) { + /* Nothing to check */; + } else if (rdev->data_offset < rdev->sb_start) { + if (mddev->dev_sectors && + rdev->data_offset + mddev->dev_sectors + > rdev->sb_start) { + printk(""md: %s: data overlaps metadata\n"", + mdname(mddev)); + return -EINVAL; + } + } else { + if (rdev->sb_start + rdev->sb_size/512 + > rdev->data_offset) { + printk(""md: %s: metadata overlaps data\n"", + mdname(mddev)); + return -EINVAL; + } + } + sysfs_notify_dirent_safe(rdev->sysfs_state); + } + + if (mddev->bio_set == NULL) + mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0); + + spin_lock(&pers_lock); + pers = find_pers(mddev->level, mddev->clevel); + if (!pers || !try_module_get(pers->owner)) { + spin_unlock(&pers_lock); + if (mddev->level != LEVEL_NONE) + printk(KERN_WARNING ""md: personality for level %d is not loaded!\n"", + mddev->level); + else + printk(KERN_WARNING ""md: personality for level %s is not loaded!\n"", + mddev->clevel); + return -EINVAL; + } + spin_unlock(&pers_lock); + if (mddev->level != pers->level) { + mddev->level = pers->level; + mddev->new_level = pers->level; + } + strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); + + if (mddev->reshape_position != MaxSector && + pers->start_reshape == NULL) { + /* This personality cannot handle reshaping... */ + module_put(pers->owner); + return -EINVAL; + } + + if (pers->sync_request) { + /* Warn if this is a potentially silly + * configuration. + */ + char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; + struct md_rdev *rdev2; + int warned = 0; + + rdev_for_each(rdev, mddev) + rdev_for_each(rdev2, mddev) { + if (rdev < rdev2 && + rdev->bdev->bd_contains == + rdev2->bdev->bd_contains) { + printk(KERN_WARNING + ""%s: WARNING: %s appears to be"" + "" on the same physical disk as"" + "" %s.\n"", + mdname(mddev), + bdevname(rdev->bdev,b), + bdevname(rdev2->bdev,b2)); + warned = 1; + } + } + + if (warned) + printk(KERN_WARNING + ""True protection against single-disk"" + "" failure might be compromised.\n""); + } + + mddev->recovery = 0; + /* may be over-ridden by personality */ + mddev->resync_max_sectors = mddev->dev_sectors; + + mddev->ok_start_degraded = start_dirty_degraded; + + if (start_readonly && mddev->ro == 0) + mddev->ro = 2; /* read-only, but switch on first write */ + + err = pers->run(mddev); + if (err) + printk(KERN_ERR ""md: pers->run() failed ...\n""); + else if (pers->size(mddev, 0, 0) < mddev->array_sectors) { + WARN_ONCE(!mddev->external_size, ""%s: default size too small,"" + "" but 'external_size' not in effect?\n"", __func__); + printk(KERN_ERR + ""md: invalid array_size %llu > default size %llu\n"", + (unsigned long long)mddev->array_sectors / 2, + (unsigned long long)pers->size(mddev, 0, 0) / 2); + err = -EINVAL; + } + if (err == 0 && pers->sync_request && + (mddev->bitmap_info.file || mddev->bitmap_info.offset)) { + struct bitmap *bitmap; + + bitmap = bitmap_create(mddev, -1); + if (IS_ERR(bitmap)) { + err = PTR_ERR(bitmap); + printk(KERN_ERR ""%s: failed to create bitmap (%d)\n"", + mdname(mddev), err); + } else + mddev->bitmap = bitmap; + + } + if (err) { + mddev_detach(mddev); + if (mddev->private) + pers->free(mddev, mddev->private); + mddev->private = NULL; + module_put(pers->owner); + bitmap_destroy(mddev); + return err; + } + if (mddev->queue) { + mddev->queue->backing_dev_info.congested_data = mddev; + mddev->queue->backing_dev_info.congested_fn = md_congested; + blk_queue_merge_bvec(mddev->queue, md_mergeable_bvec); + } + if (pers->sync_request) { + if (mddev->kobj.sd && + sysfs_create_group(&mddev->kobj, &md_redundancy_group)) + printk(KERN_WARNING + ""md: cannot register extra attributes for %s\n"", + mdname(mddev)); + mddev->sysfs_action = sysfs_get_dirent_safe(mddev->kobj.sd, ""sync_action""); + } else if (mddev->ro == 2) /* auto-readonly not meaningful */ + mddev->ro = 0; + + atomic_set(&mddev->writes_pending,0); + atomic_set(&mddev->max_corr_read_errors, + MD_DEFAULT_MAX_CORRECTED_READ_ERRORS); + mddev->safemode = 0; + mddev->safemode_timer.function = md_safemode_timeout; + mddev->safemode_timer.data = (unsigned long) mddev; + mddev->safemode_delay = (200 * HZ)/1000 +1; /* 200 msec delay */ + mddev->in_sync = 1; + smp_wmb(); + spin_lock(&mddev->lock); + mddev->pers = pers; + mddev->ready = 1; + spin_unlock(&mddev->lock); + rdev_for_each(rdev, mddev) + if (rdev->raid_disk >= 0) + if (sysfs_link_rdev(mddev, rdev)) + /* failure here is OK */; + + set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + + if (mddev->flags & MD_UPDATE_SB_FLAGS) + md_update_sb(mddev, 0); + + md_new_event(mddev); + sysfs_notify_dirent_safe(mddev->sysfs_state); + sysfs_notify_dirent_safe(mddev->sysfs_action); + sysfs_notify(&mddev->kobj, NULL, ""degraded""); + return 0; +} +","@@ -5759,7 +5759,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg) + char *ptr; + int err; + +- file = kmalloc(sizeof(*file), GFP_NOIO); ++ file = kzalloc(sizeof(*file), GFP_NOIO); + if (!file) + return -ENOMEM; + ",1827,2063,4096 +17016,"xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node) +{ + xmlNodePtr deleteNode, cur, txt, textNode = NULL; + xmlDocPtr doc; + xsltStylesheetPtr style; + int internalize = 0, findSpaceAttr; + int xsltStylesheetElemDepth; + xmlAttrPtr attr; + xmlChar *value; + const xmlChar *name, *nsNameXSLT = NULL; + int strictWhitespace, inXSLText = 0; +#ifdef XSLT_REFACTORED_XSLT_NSCOMP + xsltNsMapPtr nsMapItem; +#endif + + if ((cctxt == NULL) || (cctxt->style == NULL) || + (node == NULL) || (node->type != XML_ELEMENT_NODE)) + return(-1); + + doc = node->doc; + if (doc == NULL) + goto internal_err; + + style = cctxt->style; + if ((style->dict != NULL) && (doc->dict == style->dict)) + internalize = 1; + else + style->internalized = 0; + + /* + * Init value of xml:space. Since this might be an embedded + * stylesheet, this is needed to be performed on the element + * where the stylesheet is rooted at, taking xml:space of + * ancestors into account. + */ + if (! cctxt->simplified) + xsltStylesheetElemDepth = cctxt->depth +1; + else + xsltStylesheetElemDepth = 0; + + if (xmlNodeGetSpacePreserve(node) != 1) + cctxt->inode->preserveWhitespace = 0; + else + cctxt->inode->preserveWhitespace = 1; + + /* + * Eval if we should keep the old incorrect behaviour. + */ + strictWhitespace = (cctxt->strict != 0) ? 1 : 0; + + nsNameXSLT = xsltConstNamespaceNameXSLT; + + deleteNode = NULL; + cur = node; + while (cur != NULL) { + if (deleteNode != NULL) { + +#ifdef WITH_XSLT_DEBUG_BLANKS + xsltGenericDebug(xsltGenericDebugContext, + ""xsltParsePreprocessStylesheetTree: removing node\n""); +#endif + xmlUnlinkNode(deleteNode); + xmlFreeNode(deleteNode); + deleteNode = NULL; + } + if (cur->type == XML_ELEMENT_NODE) { + + /* + * Clear the PSVI field. + */ + cur->psvi = NULL; + + xsltCompilerNodePush(cctxt, cur); + + inXSLText = 0; + textNode = NULL; + findSpaceAttr = 1; + cctxt->inode->stripWhitespace = 0; + /* + * TODO: I'd love to use a string pointer comparison here :-/ + */ + if (IS_XSLT_ELEM(cur)) { +#ifdef XSLT_REFACTORED_XSLT_NSCOMP + if (cur->ns->href != nsNameXSLT) { + nsMapItem = xsltNewNamespaceMapItem(cctxt, + doc, cur->ns, cur); + if (nsMapItem == NULL) + goto internal_err; + cur->ns->href = nsNameXSLT; + } +#endif + + if (cur->name == NULL) + goto process_attributes; + /* + * Mark the XSLT element for later recognition. + * TODO: Using the marker is still too dangerous, since if + * the parsing mechanism leaves out an XSLT element, then + * this might hit the transformation-mechanism, which + * will break if it doesn't expect such a marker. + */ + /* cur->psvi = (void *) xsltXSLTElemMarker; */ + + /* + * XSLT 2.0: ""Any whitespace text node whose parent is + * one of the following elements is removed from the "" + * tree, regardless of any xml:space attributes:..."" + * xsl:apply-imports, + * xsl:apply-templates, + * xsl:attribute-set, + * xsl:call-template, + * xsl:choose, + * xsl:stylesheet, xsl:transform. + * XSLT 2.0: xsl:analyze-string, + * xsl:character-map, + * xsl:next-match + * + * TODO: I'd love to use a string pointer comparison here :-/ + */ + name = cur->name; + switch (*name) { + case 't': + if ((name[0] == 't') && (name[1] == 'e') && + (name[2] == 'x') && (name[3] == 't') && + (name[4] == 0)) + { + /* + * Process the xsl:text element. + * ---------------------------- + * Mark it for later recognition. + */ + cur->psvi = (void *) xsltXSLTTextMarker; + /* + * For stylesheets, the set of + * whitespace-preserving element names + * consists of just xsl:text. + */ + findSpaceAttr = 0; + cctxt->inode->preserveWhitespace = 1; + inXSLText = 1; + } + break; + case 'c': + if (xmlStrEqual(name, BAD_CAST ""choose"") || + xmlStrEqual(name, BAD_CAST ""call-template"")) + cctxt->inode->stripWhitespace = 1; + break; + case 'a': + if (xmlStrEqual(name, BAD_CAST ""apply-templates"") || + xmlStrEqual(name, BAD_CAST ""apply-imports"") || + xmlStrEqual(name, BAD_CAST ""attribute-set"")) + + cctxt->inode->stripWhitespace = 1; + break; + default: + if (xsltStylesheetElemDepth == cctxt->depth) { + /* + * This is a xsl:stylesheet/xsl:transform. + */ + cctxt->inode->stripWhitespace = 1; + break; + } + + if ((cur->prev != NULL) && + (cur->prev->type == XML_TEXT_NODE)) + { + /* + * XSLT 2.0 : ""Any whitespace text node whose + * following-sibling node is an xsl:param or + * xsl:sort element is removed from the tree, + * regardless of any xml:space attributes."" + */ + if (((*name == 'p') || (*name == 's')) && + (xmlStrEqual(name, BAD_CAST ""param"") || + xmlStrEqual(name, BAD_CAST ""sort""))) + { + do { + if (IS_BLANK_NODE(cur->prev)) { + txt = cur->prev; + xmlUnlinkNode(txt); + xmlFreeNode(txt); + } else { + /* + * This will result in a content + * error, when hitting the parsing + * functions. + */ + break; + } + } while (cur->prev); + } + } + break; + } + } + +process_attributes: + /* + * Process attributes. + * ------------------ + */ + if (cur->properties != NULL) { + if (cur->children == NULL) + findSpaceAttr = 0; + attr = cur->properties; + do { +#ifdef XSLT_REFACTORED_XSLT_NSCOMP + if ((attr->ns) && (attr->ns->href != nsNameXSLT) && + xmlStrEqual(attr->ns->href, nsNameXSLT)) + { + nsMapItem = xsltNewNamespaceMapItem(cctxt, + doc, attr->ns, cur); + if (nsMapItem == NULL) + goto internal_err; + attr->ns->href = nsNameXSLT; + } +#endif + if (internalize) { + /* + * Internalize the attribute's value; the goal is to + * speed up operations and minimize used space by + * compiled stylesheets. + */ + txt = attr->children; + /* + * NOTE that this assumes only one + * text-node in the attribute's content. + */ + if ((txt != NULL) && (txt->content != NULL) && + (!xmlDictOwns(style->dict, txt->content))) + { + value = (xmlChar *) xmlDictLookup(style->dict, + txt->content, -1); + xmlNodeSetContent(txt, NULL); + txt->content = value; + } + } + /* + * Process xml:space attributes. + * ---------------------------- + */ + if ((findSpaceAttr != 0) && + (attr->ns != NULL) && + (attr->name != NULL) && + (attr->name[0] == 's') && + (attr->ns->prefix != NULL) && + (attr->ns->prefix[0] == 'x') && + (attr->ns->prefix[1] == 'm') && + (attr->ns->prefix[2] == 'l') && + (attr->ns->prefix[3] == 0)) + { + value = xmlGetNsProp(cur, BAD_CAST ""space"", + XML_XML_NAMESPACE); + if (value != NULL) { + if (xmlStrEqual(value, BAD_CAST ""preserve"")) { + cctxt->inode->preserveWhitespace = 1; + } else if (xmlStrEqual(value, BAD_CAST ""default"")) { + cctxt->inode->preserveWhitespace = 0; + } else { + /* Invalid value for xml:space. */ + xsltTransformError(NULL, style, cur, + ""Attribute xml:space: Invalid value.\n""); + cctxt->style->warnings++; + } + findSpaceAttr = 0; + xmlFree(value); + } + + } + attr = attr->next; + } while (attr != NULL); + } + /* + * We'll descend into the children of element nodes only. + */ + if (cur->children != NULL) { + cur = cur->children; + continue; + } + } else if ((cur->type == XML_TEXT_NODE) || + (cur->type == XML_CDATA_SECTION_NODE)) + { + /* + * Merge adjacent text/CDATA-section-nodes + * --------------------------------------- + * In order to avoid breaking of existing stylesheets, + * if the old behaviour is wanted (strictWhitespace == 0), + * then we *won't* merge adjacent text-nodes + * (except in xsl:text); this will ensure that whitespace-only + * text nodes are (incorrectly) not stripped in some cases. + * + * Example: : zoo + * Corrent (strict) result: zoo + * Incorrect (old) result : zoo + * + * NOTE that we *will* merge adjacent text-nodes if + * they are in xsl:text. + * Example, the following: + * zoo + * will result in both cases in: + * zoo + */ + cur->type = XML_TEXT_NODE; + if ((strictWhitespace != 0) || (inXSLText != 0)) { + /* + * New behaviour; merge nodes. + */ + if (textNode == NULL) + textNode = cur; + else { + if (cur->content != NULL) + xmlNodeAddContent(textNode, cur->content); + deleteNode = cur; + } + if ((cur->next == NULL) || + (cur->next->type == XML_ELEMENT_NODE)) + goto end_of_text; + else + goto next_sibling; + } else { + /* + * Old behaviour. + */ + if (textNode == NULL) + textNode = cur; + goto end_of_text; + } + } else if ((cur->type == XML_COMMENT_NODE) || + (cur->type == XML_PI_NODE)) + { + /* + * Remove processing instructions and comments. + */ + deleteNode = cur; + if ((cur->next == NULL) || + (cur->next->type == XML_ELEMENT_NODE)) + goto end_of_text; + else + goto next_sibling; + } else { + textNode = NULL; + /* + * Invalid node-type for this data-model. + */ + xsltTransformError(NULL, style, cur, + ""Invalid type of node for the XSLT data model.\n""); + cctxt->style->errors++; + goto next_sibling; + } + +end_of_text: + if (textNode) { + value = textNode->content; + /* + * At this point all adjacent text/CDATA-section nodes + * have been merged. + * + * Strip whitespace-only text-nodes. + * (cctxt->inode->stripWhitespace) + */ + if ((value == NULL) || (*value == 0) || + (((cctxt->inode->stripWhitespace) || + (! cctxt->inode->preserveWhitespace)) && + IS_BLANK(*value) && + xsltIsBlank(value))) + { + if (textNode != cur) { + xmlUnlinkNode(textNode); + xmlFreeNode(textNode); + } else + deleteNode = textNode; + textNode = NULL; + goto next_sibling; + } + /* + * Convert CDATA-section nodes to text-nodes. + * TODO: Can this produce problems? + */ + if (textNode->type != XML_TEXT_NODE) { + textNode->type = XML_TEXT_NODE; + textNode->name = xmlStringText; + } + if (internalize && + (textNode->content != NULL) && + (!xmlDictOwns(style->dict, textNode->content))) + { + /* + * Internalize the string. + */ + value = (xmlChar *) xmlDictLookup(style->dict, + textNode->content, -1); + xmlNodeSetContent(textNode, NULL); + textNode->content = value; + } + textNode = NULL; + /* + * Note that ""disable-output-escaping"" of the xsl:text + * element will be applied at a later level, when + * XSLT elements are processed. + */ + } + +next_sibling: + if (cur->type == XML_ELEMENT_NODE) { + xsltCompilerNodePop(cctxt, cur); + } + if (cur == node) + break; + if (cur->next != NULL) { + cur = cur->next; + } else { + cur = cur->parent; + inXSLText = 0; + goto next_sibling; + }; + } + if (deleteNode != NULL) { +#ifdef WITH_XSLT_DEBUG_PARSING + xsltGenericDebug(xsltGenericDebugContext, + ""xsltParsePreprocessStylesheetTree: removing node\n""); +#endif + xmlUnlinkNode(deleteNode); + xmlFreeNode(deleteNode); + } + return(0); + +internal_err: + return(-1); +} +",0,"xsltParsePreprocessStylesheetTree(xsltCompilerCtxtPtr cctxt, xmlNodePtr node) +{ + xmlNodePtr deleteNode, cur, txt, textNode = NULL; + xmlDocPtr doc; + xsltStylesheetPtr style; + int internalize = 0, findSpaceAttr; + int xsltStylesheetElemDepth; + xmlAttrPtr attr; + xmlChar *value; + const xmlChar *name, *nsNameXSLT = NULL; + int strictWhitespace, inXSLText = 0; +#ifdef XSLT_REFACTORED_XSLT_NSCOMP + xsltNsMapPtr nsMapItem; +#endif + + if ((cctxt == NULL) || (cctxt->style == NULL) || + (node == NULL) || (node->type != XML_ELEMENT_NODE)) + return(-1); + + doc = node->doc; + if (doc == NULL) + goto internal_err; + + style = cctxt->style; + if ((style->dict != NULL) && (doc->dict == style->dict)) + internalize = 1; + else + style->internalized = 0; + + /* + * Init value of xml:space. Since this might be an embedded + * stylesheet, this is needed to be performed on the element + * where the stylesheet is rooted at, taking xml:space of + * ancestors into account. + */ + if (! cctxt->simplified) + xsltStylesheetElemDepth = cctxt->depth +1; + else + xsltStylesheetElemDepth = 0; + + if (xmlNodeGetSpacePreserve(node) != 1) + cctxt->inode->preserveWhitespace = 0; + else + cctxt->inode->preserveWhitespace = 1; + + /* + * Eval if we should keep the old incorrect behaviour. + */ + strictWhitespace = (cctxt->strict != 0) ? 1 : 0; + + nsNameXSLT = xsltConstNamespaceNameXSLT; + + deleteNode = NULL; + cur = node; + while (cur != NULL) { + if (deleteNode != NULL) { + +#ifdef WITH_XSLT_DEBUG_BLANKS + xsltGenericDebug(xsltGenericDebugContext, + ""xsltParsePreprocessStylesheetTree: removing node\n""); +#endif + xmlUnlinkNode(deleteNode); + xmlFreeNode(deleteNode); + deleteNode = NULL; + } + if (cur->type == XML_ELEMENT_NODE) { + + /* + * Clear the PSVI field. + */ + cur->psvi = NULL; + + xsltCompilerNodePush(cctxt, cur); + + inXSLText = 0; + textNode = NULL; + findSpaceAttr = 1; + cctxt->inode->stripWhitespace = 0; + /* + * TODO: I'd love to use a string pointer comparison here :-/ + */ + if (IS_XSLT_ELEM(cur)) { +#ifdef XSLT_REFACTORED_XSLT_NSCOMP + if (cur->ns->href != nsNameXSLT) { + nsMapItem = xsltNewNamespaceMapItem(cctxt, + doc, cur->ns, cur); + if (nsMapItem == NULL) + goto internal_err; + cur->ns->href = nsNameXSLT; + } +#endif + + if (cur->name == NULL) + goto process_attributes; + /* + * Mark the XSLT element for later recognition. + * TODO: Using the marker is still too dangerous, since if + * the parsing mechanism leaves out an XSLT element, then + * this might hit the transformation-mechanism, which + * will break if it doesn't expect such a marker. + */ + /* cur->psvi = (void *) xsltXSLTElemMarker; */ + + /* + * XSLT 2.0: ""Any whitespace text node whose parent is + * one of the following elements is removed from the "" + * tree, regardless of any xml:space attributes:..."" + * xsl:apply-imports, + * xsl:apply-templates, + * xsl:attribute-set, + * xsl:call-template, + * xsl:choose, + * xsl:stylesheet, xsl:transform. + * XSLT 2.0: xsl:analyze-string, + * xsl:character-map, + * xsl:next-match + * + * TODO: I'd love to use a string pointer comparison here :-/ + */ + name = cur->name; + switch (*name) { + case 't': + if ((name[0] == 't') && (name[1] == 'e') && + (name[2] == 'x') && (name[3] == 't') && + (name[4] == 0)) + { + /* + * Process the xsl:text element. + * ---------------------------- + * Mark it for later recognition. + */ + cur->psvi = (void *) xsltXSLTTextMarker; + /* + * For stylesheets, the set of + * whitespace-preserving element names + * consists of just xsl:text. + */ + findSpaceAttr = 0; + cctxt->inode->preserveWhitespace = 1; + inXSLText = 1; + } + break; + case 'c': + if (xmlStrEqual(name, BAD_CAST ""choose"") || + xmlStrEqual(name, BAD_CAST ""call-template"")) + cctxt->inode->stripWhitespace = 1; + break; + case 'a': + if (xmlStrEqual(name, BAD_CAST ""apply-templates"") || + xmlStrEqual(name, BAD_CAST ""apply-imports"") || + xmlStrEqual(name, BAD_CAST ""attribute-set"")) + + cctxt->inode->stripWhitespace = 1; + break; + default: + if (xsltStylesheetElemDepth == cctxt->depth) { + /* + * This is a xsl:stylesheet/xsl:transform. + */ + cctxt->inode->stripWhitespace = 1; + break; + } + + if ((cur->prev != NULL) && + (cur->prev->type == XML_TEXT_NODE)) + { + /* + * XSLT 2.0 : ""Any whitespace text node whose + * following-sibling node is an xsl:param or + * xsl:sort element is removed from the tree, + * regardless of any xml:space attributes."" + */ + if (((*name == 'p') || (*name == 's')) && + (xmlStrEqual(name, BAD_CAST ""param"") || + xmlStrEqual(name, BAD_CAST ""sort""))) + { + do { + if (IS_BLANK_NODE(cur->prev)) { + txt = cur->prev; + xmlUnlinkNode(txt); + xmlFreeNode(txt); + } else { + /* + * This will result in a content + * error, when hitting the parsing + * functions. + */ + break; + } + } while (cur->prev); + } + } + break; + } + } + +process_attributes: + /* + * Process attributes. + * ------------------ + */ + if (cur->properties != NULL) { + if (cur->children == NULL) + findSpaceAttr = 0; + attr = cur->properties; + do { +#ifdef XSLT_REFACTORED_XSLT_NSCOMP + if ((attr->ns) && (attr->ns->href != nsNameXSLT) && + xmlStrEqual(attr->ns->href, nsNameXSLT)) + { + nsMapItem = xsltNewNamespaceMapItem(cctxt, + doc, attr->ns, cur); + if (nsMapItem == NULL) + goto internal_err; + attr->ns->href = nsNameXSLT; + } +#endif + if (internalize) { + /* + * Internalize the attribute's value; the goal is to + * speed up operations and minimize used space by + * compiled stylesheets. + */ + txt = attr->children; + /* + * NOTE that this assumes only one + * text-node in the attribute's content. + */ + if ((txt != NULL) && (txt->content != NULL) && + (!xmlDictOwns(style->dict, txt->content))) + { + value = (xmlChar *) xmlDictLookup(style->dict, + txt->content, -1); + xmlNodeSetContent(txt, NULL); + txt->content = value; + } + } + /* + * Process xml:space attributes. + * ---------------------------- + */ + if ((findSpaceAttr != 0) && + (attr->ns != NULL) && + (attr->name != NULL) && + (attr->name[0] == 's') && + (attr->ns->prefix != NULL) && + (attr->ns->prefix[0] == 'x') && + (attr->ns->prefix[1] == 'm') && + (attr->ns->prefix[2] == 'l') && + (attr->ns->prefix[3] == 0)) + { + value = xmlGetNsProp(cur, BAD_CAST ""space"", + XML_XML_NAMESPACE); + if (value != NULL) { + if (xmlStrEqual(value, BAD_CAST ""preserve"")) { + cctxt->inode->preserveWhitespace = 1; + } else if (xmlStrEqual(value, BAD_CAST ""default"")) { + cctxt->inode->preserveWhitespace = 0; + } else { + /* Invalid value for xml:space. */ + xsltTransformError(NULL, style, cur, + ""Attribute xml:space: Invalid value.\n""); + cctxt->style->warnings++; + } + findSpaceAttr = 0; + xmlFree(value); + } + + } + attr = attr->next; + } while (attr != NULL); + } + /* + * We'll descend into the children of element nodes only. + */ + if (cur->children != NULL) { + cur = cur->children; + continue; + } + } else if ((cur->type == XML_TEXT_NODE) || + (cur->type == XML_CDATA_SECTION_NODE)) + { + /* + * Merge adjacent text/CDATA-section-nodes + * --------------------------------------- + * In order to avoid breaking of existing stylesheets, + * if the old behaviour is wanted (strictWhitespace == 0), + * then we *won't* merge adjacent text-nodes + * (except in xsl:text); this will ensure that whitespace-only + * text nodes are (incorrectly) not stripped in some cases. + * + * Example: : zoo + * Corrent (strict) result: zoo + * Incorrect (old) result : zoo + * + * NOTE that we *will* merge adjacent text-nodes if + * they are in xsl:text. + * Example, the following: + * zoo + * will result in both cases in: + * zoo + */ + cur->type = XML_TEXT_NODE; + if ((strictWhitespace != 0) || (inXSLText != 0)) { + /* + * New behaviour; merge nodes. + */ + if (textNode == NULL) + textNode = cur; + else { + if (cur->content != NULL) + xmlNodeAddContent(textNode, cur->content); + deleteNode = cur; + } + if ((cur->next == NULL) || + (cur->next->type == XML_ELEMENT_NODE)) + goto end_of_text; + else + goto next_sibling; + } else { + /* + * Old behaviour. + */ + if (textNode == NULL) + textNode = cur; + goto end_of_text; + } + } else if ((cur->type == XML_COMMENT_NODE) || + (cur->type == XML_PI_NODE)) + { + /* + * Remove processing instructions and comments. + */ + deleteNode = cur; + if ((cur->next == NULL) || + (cur->next->type == XML_ELEMENT_NODE)) + goto end_of_text; + else + goto next_sibling; + } else { + textNode = NULL; + /* + * Invalid node-type for this data-model. + */ + xsltTransformError(NULL, style, cur, + ""Invalid type of node for the XSLT data model.\n""); + cctxt->style->errors++; + goto next_sibling; + } + +end_of_text: + if (textNode) { + value = textNode->content; + /* + * At this point all adjacent text/CDATA-section nodes + * have been merged. + * + * Strip whitespace-only text-nodes. + * (cctxt->inode->stripWhitespace) + */ + if ((value == NULL) || (*value == 0) || + (((cctxt->inode->stripWhitespace) || + (! cctxt->inode->preserveWhitespace)) && + IS_BLANK(*value) && + xsltIsBlank(value))) + { + if (textNode != cur) { + xmlUnlinkNode(textNode); + xmlFreeNode(textNode); + } else + deleteNode = textNode; + textNode = NULL; + goto next_sibling; + } + /* + * Convert CDATA-section nodes to text-nodes. + * TODO: Can this produce problems? + */ + if (textNode->type != XML_TEXT_NODE) { + textNode->type = XML_TEXT_NODE; + textNode->name = xmlStringText; + } + if (internalize && + (textNode->content != NULL) && + (!xmlDictOwns(style->dict, textNode->content))) + { + /* + * Internalize the string. + */ + value = (xmlChar *) xmlDictLookup(style->dict, + textNode->content, -1); + xmlNodeSetContent(textNode, NULL); + textNode->content = value; + } + textNode = NULL; + /* + * Note that ""disable-output-escaping"" of the xsl:text + * element will be applied at a later level, when + * XSLT elements are processed. + */ + } + +next_sibling: + if (cur->type == XML_ELEMENT_NODE) { + xsltCompilerNodePop(cctxt, cur); + } + if (cur == node) + break; + if (cur->next != NULL) { + cur = cur->next; + } else { + cur = cur->parent; + inXSLText = 0; + goto next_sibling; + }; + } + if (deleteNode != NULL) { +#ifdef WITH_XSLT_DEBUG_PARSING + xsltGenericDebug(xsltGenericDebugContext, + ""xsltParsePreprocessStylesheetTree: removing node\n""); +#endif + xmlUnlinkNode(deleteNode); + xmlFreeNode(deleteNode); + } + return(0); + +internal_err: + return(-1); +} +","@@ -5382,7 +5382,6 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) { + prop = xmlGetNsProp(template, (const xmlChar *)""name"", NULL); + if (prop != NULL) { + const xmlChar *URI; +- xsltTemplatePtr cur; + + /* + * TODO: Don't use xsltGetQNameURI(). +@@ -5405,19 +5404,6 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) { + ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1); + else + ret->nameURI = NULL; +- cur = ret->next; +- while (cur != NULL) { +- if ((URI != NULL && xmlStrEqual(cur->name, ret->name) && +- xmlStrEqual(cur->nameURI, URI) ) || +- (URI == NULL && cur->nameURI == NULL && +- xmlStrEqual(cur->name, ret->name))) { +- xsltTransformError(NULL, style, template, +- ""xsl:template: error duplicate name '%s'\n"", ret->name); +- style->errors++; +- goto error; +- } +- cur = cur->next; +- } + } + } + ",3294,3530,4096 +3341,"static int parse_options (char *options, struct super_block *sb, + unsigned int *inum, unsigned long *journal_devnum, + ext3_fsblk_t *n_blocks_count, int is_remount) +{ + struct ext3_sb_info *sbi = EXT3_SB(sb); + char * p; + substring_t args[MAX_OPT_ARGS]; + int data_opt = 0; + int option; + kuid_t uid; + kgid_t gid; +#ifdef CONFIG_QUOTA + int qfmt; +#endif + + if (!options) + return 1; + + while ((p = strsep (&options, "","")) != NULL) { + int token; + if (!*p) + continue; + /* + * Initialize args struct so we know whether arg was + * found; some options take optional arguments. + */ + args[0].to = args[0].from = NULL; + token = match_token(p, tokens, args); + switch (token) { + case Opt_bsd_df: + clear_opt (sbi->s_mount_opt, MINIX_DF); + break; + case Opt_minix_df: + set_opt (sbi->s_mount_opt, MINIX_DF); + break; + case Opt_grpid: + set_opt (sbi->s_mount_opt, GRPID); + break; + case Opt_nogrpid: + clear_opt (sbi->s_mount_opt, GRPID); + break; + case Opt_resuid: + if (match_int(&args[0], &option)) + return 0; + uid = make_kuid(current_user_ns(), option); + if (!uid_valid(uid)) { + ext3_msg(sb, KERN_ERR, ""Invalid uid value %d"", option); + return 0; + + } + sbi->s_resuid = uid; + break; + case Opt_resgid: + if (match_int(&args[0], &option)) + return 0; + gid = make_kgid(current_user_ns(), option); + if (!gid_valid(gid)) { + ext3_msg(sb, KERN_ERR, ""Invalid gid value %d"", option); + return 0; + } + sbi->s_resgid = gid; + break; + case Opt_sb: + /* handled by get_sb_block() instead of here */ + /* *sb_block = match_int(&args[0]); */ + break; + case Opt_err_panic: + clear_opt (sbi->s_mount_opt, ERRORS_CONT); + clear_opt (sbi->s_mount_opt, ERRORS_RO); + set_opt (sbi->s_mount_opt, ERRORS_PANIC); + break; + case Opt_err_ro: + clear_opt (sbi->s_mount_opt, ERRORS_CONT); + clear_opt (sbi->s_mount_opt, ERRORS_PANIC); + set_opt (sbi->s_mount_opt, ERRORS_RO); + break; + case Opt_err_cont: + clear_opt (sbi->s_mount_opt, ERRORS_RO); + clear_opt (sbi->s_mount_opt, ERRORS_PANIC); + set_opt (sbi->s_mount_opt, ERRORS_CONT); + break; + case Opt_nouid32: + set_opt (sbi->s_mount_opt, NO_UID32); + break; + case Opt_nocheck: + clear_opt (sbi->s_mount_opt, CHECK); + break; + case Opt_debug: + set_opt (sbi->s_mount_opt, DEBUG); + break; + case Opt_oldalloc: + ext3_msg(sb, KERN_WARNING, + ""Ignoring deprecated oldalloc option""); + break; + case Opt_orlov: + ext3_msg(sb, KERN_WARNING, + ""Ignoring deprecated orlov option""); + break; +#ifdef CONFIG_EXT3_FS_XATTR + case Opt_user_xattr: + set_opt (sbi->s_mount_opt, XATTR_USER); + break; + case Opt_nouser_xattr: + clear_opt (sbi->s_mount_opt, XATTR_USER); + break; +#else + case Opt_user_xattr: + case Opt_nouser_xattr: + ext3_msg(sb, KERN_INFO, + ""(no)user_xattr options not supported""); + break; +#endif +#ifdef CONFIG_EXT3_FS_POSIX_ACL + case Opt_acl: + set_opt(sbi->s_mount_opt, POSIX_ACL); + break; + case Opt_noacl: + clear_opt(sbi->s_mount_opt, POSIX_ACL); + break; +#else + case Opt_acl: + case Opt_noacl: + ext3_msg(sb, KERN_INFO, + ""(no)acl options not supported""); + break; +#endif + case Opt_reservation: + set_opt(sbi->s_mount_opt, RESERVATION); + break; + case Opt_noreservation: + clear_opt(sbi->s_mount_opt, RESERVATION); + break; + case Opt_journal_update: + /* @@@ FIXME */ + /* Eventually we will want to be able to create + a journal file here. For now, only allow the + user to specify an existing inode to be the + journal file. */ + if (is_remount) { + ext3_msg(sb, KERN_ERR, ""error: cannot specify "" + ""journal on remount""); + return 0; + } + set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); + break; + case Opt_journal_inum: + if (is_remount) { + ext3_msg(sb, KERN_ERR, ""error: cannot specify "" + ""journal on remount""); + return 0; + } + if (match_int(&args[0], &option)) + return 0; + *inum = option; + break; + case Opt_journal_dev: + if (is_remount) { + ext3_msg(sb, KERN_ERR, ""error: cannot specify "" + ""journal on remount""); + return 0; + } + if (match_int(&args[0], &option)) + return 0; + *journal_devnum = option; + break; + case Opt_noload: + set_opt (sbi->s_mount_opt, NOLOAD); + break; + case Opt_commit: + if (match_int(&args[0], &option)) + return 0; + if (option < 0) + return 0; + if (option == 0) + option = JBD_DEFAULT_MAX_COMMIT_AGE; + sbi->s_commit_interval = HZ * option; + break; + case Opt_data_journal: + data_opt = EXT3_MOUNT_JOURNAL_DATA; + goto datacheck; + case Opt_data_ordered: + data_opt = EXT3_MOUNT_ORDERED_DATA; + goto datacheck; + case Opt_data_writeback: + data_opt = EXT3_MOUNT_WRITEBACK_DATA; + datacheck: + if (is_remount) { + if (test_opt(sb, DATA_FLAGS) == data_opt) + break; + ext3_msg(sb, KERN_ERR, + ""error: cannot change "" + ""data mode on remount. The filesystem "" + ""is mounted in data=%s mode and you "" + ""try to remount it in data=%s mode."", + data_mode_string(test_opt(sb, + DATA_FLAGS)), + data_mode_string(data_opt)); + return 0; + } else { + clear_opt(sbi->s_mount_opt, DATA_FLAGS); + sbi->s_mount_opt |= data_opt; + } + break; + case Opt_data_err_abort: + set_opt(sbi->s_mount_opt, DATA_ERR_ABORT); + break; + case Opt_data_err_ignore: + clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); + break; +#ifdef CONFIG_QUOTA + case Opt_usrjquota: + if (!set_qf_name(sb, USRQUOTA, &args[0])) + return 0; + break; + case Opt_grpjquota: + if (!set_qf_name(sb, GRPQUOTA, &args[0])) + return 0; + break; + case Opt_offusrjquota: + if (!clear_qf_name(sb, USRQUOTA)) + return 0; + break; + case Opt_offgrpjquota: + if (!clear_qf_name(sb, GRPQUOTA)) + return 0; + break; + case Opt_jqfmt_vfsold: + qfmt = QFMT_VFS_OLD; + goto set_qf_format; + case Opt_jqfmt_vfsv0: + qfmt = QFMT_VFS_V0; + goto set_qf_format; + case Opt_jqfmt_vfsv1: + qfmt = QFMT_VFS_V1; +set_qf_format: + if (sb_any_quota_loaded(sb) && + sbi->s_jquota_fmt != qfmt) { + ext3_msg(sb, KERN_ERR, ""error: cannot change "" + ""journaled quota options when "" + ""quota turned on.""); + return 0; + } + sbi->s_jquota_fmt = qfmt; + break; + case Opt_quota: + case Opt_usrquota: + set_opt(sbi->s_mount_opt, QUOTA); + set_opt(sbi->s_mount_opt, USRQUOTA); + break; + case Opt_grpquota: + set_opt(sbi->s_mount_opt, QUOTA); + set_opt(sbi->s_mount_opt, GRPQUOTA); + break; + case Opt_noquota: + if (sb_any_quota_loaded(sb)) { + ext3_msg(sb, KERN_ERR, ""error: cannot change "" + ""quota options when quota turned on.""); + return 0; + } + clear_opt(sbi->s_mount_opt, QUOTA); + clear_opt(sbi->s_mount_opt, USRQUOTA); + clear_opt(sbi->s_mount_opt, GRPQUOTA); + break; +#else + case Opt_quota: + case Opt_usrquota: + case Opt_grpquota: + ext3_msg(sb, KERN_ERR, + ""error: quota options not supported.""); + break; + case Opt_usrjquota: + case Opt_grpjquota: + case Opt_offusrjquota: + case Opt_offgrpjquota: + case Opt_jqfmt_vfsold: + case Opt_jqfmt_vfsv0: + case Opt_jqfmt_vfsv1: + ext3_msg(sb, KERN_ERR, + ""error: journaled quota options not "" + ""supported.""); + break; + case Opt_noquota: + break; +#endif + case Opt_abort: + set_opt(sbi->s_mount_opt, ABORT); + break; + case Opt_nobarrier: + clear_opt(sbi->s_mount_opt, BARRIER); + break; + case Opt_barrier: + if (args[0].from) { + if (match_int(&args[0], &option)) + return 0; + } else + option = 1; /* No argument, default to 1 */ + if (option) + set_opt(sbi->s_mount_opt, BARRIER); + else + clear_opt(sbi->s_mount_opt, BARRIER); + break; + case Opt_ignore: + break; + case Opt_resize: + if (!is_remount) { + ext3_msg(sb, KERN_ERR, + ""error: resize option only available "" + ""for remount""); + return 0; + } + if (match_int(&args[0], &option) != 0) + return 0; + *n_blocks_count = option; + break; + case Opt_nobh: + ext3_msg(sb, KERN_WARNING, + ""warning: ignoring deprecated nobh option""); + break; + case Opt_bh: + ext3_msg(sb, KERN_WARNING, + ""warning: ignoring deprecated bh option""); + break; + default: + ext3_msg(sb, KERN_ERR, + ""error: unrecognized mount option \""%s\"" "" + ""or missing value"", p); + return 0; + } + } +#ifdef CONFIG_QUOTA + if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { + if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) + clear_opt(sbi->s_mount_opt, USRQUOTA); + if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) + clear_opt(sbi->s_mount_opt, GRPQUOTA); + + if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { + ext3_msg(sb, KERN_ERR, ""error: old and new quota "" + ""format mixing.""); + return 0; + } + + if (!sbi->s_jquota_fmt) { + ext3_msg(sb, KERN_ERR, ""error: journaled quota format "" + ""not specified.""); + return 0; + } + } else { + if (sbi->s_jquota_fmt) { + ext3_msg(sb, KERN_ERR, ""error: journaled quota format "" + ""specified with no journaling "" + ""enabled.""); + return 0; + } + } +#endif + return 1; +} +",0,"static int parse_options (char *options, struct super_block *sb, + unsigned int *inum, unsigned long *journal_devnum, + ext3_fsblk_t *n_blocks_count, int is_remount) +{ + struct ext3_sb_info *sbi = EXT3_SB(sb); + char * p; + substring_t args[MAX_OPT_ARGS]; + int data_opt = 0; + int option; + kuid_t uid; + kgid_t gid; +#ifdef CONFIG_QUOTA + int qfmt; +#endif + + if (!options) + return 1; + + while ((p = strsep (&options, "","")) != NULL) { + int token; + if (!*p) + continue; + /* + * Initialize args struct so we know whether arg was + * found; some options take optional arguments. + */ + args[0].to = args[0].from = NULL; + token = match_token(p, tokens, args); + switch (token) { + case Opt_bsd_df: + clear_opt (sbi->s_mount_opt, MINIX_DF); + break; + case Opt_minix_df: + set_opt (sbi->s_mount_opt, MINIX_DF); + break; + case Opt_grpid: + set_opt (sbi->s_mount_opt, GRPID); + break; + case Opt_nogrpid: + clear_opt (sbi->s_mount_opt, GRPID); + break; + case Opt_resuid: + if (match_int(&args[0], &option)) + return 0; + uid = make_kuid(current_user_ns(), option); + if (!uid_valid(uid)) { + ext3_msg(sb, KERN_ERR, ""Invalid uid value %d"", option); + return 0; + + } + sbi->s_resuid = uid; + break; + case Opt_resgid: + if (match_int(&args[0], &option)) + return 0; + gid = make_kgid(current_user_ns(), option); + if (!gid_valid(gid)) { + ext3_msg(sb, KERN_ERR, ""Invalid gid value %d"", option); + return 0; + } + sbi->s_resgid = gid; + break; + case Opt_sb: + /* handled by get_sb_block() instead of here */ + /* *sb_block = match_int(&args[0]); */ + break; + case Opt_err_panic: + clear_opt (sbi->s_mount_opt, ERRORS_CONT); + clear_opt (sbi->s_mount_opt, ERRORS_RO); + set_opt (sbi->s_mount_opt, ERRORS_PANIC); + break; + case Opt_err_ro: + clear_opt (sbi->s_mount_opt, ERRORS_CONT); + clear_opt (sbi->s_mount_opt, ERRORS_PANIC); + set_opt (sbi->s_mount_opt, ERRORS_RO); + break; + case Opt_err_cont: + clear_opt (sbi->s_mount_opt, ERRORS_RO); + clear_opt (sbi->s_mount_opt, ERRORS_PANIC); + set_opt (sbi->s_mount_opt, ERRORS_CONT); + break; + case Opt_nouid32: + set_opt (sbi->s_mount_opt, NO_UID32); + break; + case Opt_nocheck: + clear_opt (sbi->s_mount_opt, CHECK); + break; + case Opt_debug: + set_opt (sbi->s_mount_opt, DEBUG); + break; + case Opt_oldalloc: + ext3_msg(sb, KERN_WARNING, + ""Ignoring deprecated oldalloc option""); + break; + case Opt_orlov: + ext3_msg(sb, KERN_WARNING, + ""Ignoring deprecated orlov option""); + break; +#ifdef CONFIG_EXT3_FS_XATTR + case Opt_user_xattr: + set_opt (sbi->s_mount_opt, XATTR_USER); + break; + case Opt_nouser_xattr: + clear_opt (sbi->s_mount_opt, XATTR_USER); + break; +#else + case Opt_user_xattr: + case Opt_nouser_xattr: + ext3_msg(sb, KERN_INFO, + ""(no)user_xattr options not supported""); + break; +#endif +#ifdef CONFIG_EXT3_FS_POSIX_ACL + case Opt_acl: + set_opt(sbi->s_mount_opt, POSIX_ACL); + break; + case Opt_noacl: + clear_opt(sbi->s_mount_opt, POSIX_ACL); + break; +#else + case Opt_acl: + case Opt_noacl: + ext3_msg(sb, KERN_INFO, + ""(no)acl options not supported""); + break; +#endif + case Opt_reservation: + set_opt(sbi->s_mount_opt, RESERVATION); + break; + case Opt_noreservation: + clear_opt(sbi->s_mount_opt, RESERVATION); + break; + case Opt_journal_update: + /* @@@ FIXME */ + /* Eventually we will want to be able to create + a journal file here. For now, only allow the + user to specify an existing inode to be the + journal file. */ + if (is_remount) { + ext3_msg(sb, KERN_ERR, ""error: cannot specify "" + ""journal on remount""); + return 0; + } + set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); + break; + case Opt_journal_inum: + if (is_remount) { + ext3_msg(sb, KERN_ERR, ""error: cannot specify "" + ""journal on remount""); + return 0; + } + if (match_int(&args[0], &option)) + return 0; + *inum = option; + break; + case Opt_journal_dev: + if (is_remount) { + ext3_msg(sb, KERN_ERR, ""error: cannot specify "" + ""journal on remount""); + return 0; + } + if (match_int(&args[0], &option)) + return 0; + *journal_devnum = option; + break; + case Opt_noload: + set_opt (sbi->s_mount_opt, NOLOAD); + break; + case Opt_commit: + if (match_int(&args[0], &option)) + return 0; + if (option < 0) + return 0; + if (option == 0) + option = JBD_DEFAULT_MAX_COMMIT_AGE; + sbi->s_commit_interval = HZ * option; + break; + case Opt_data_journal: + data_opt = EXT3_MOUNT_JOURNAL_DATA; + goto datacheck; + case Opt_data_ordered: + data_opt = EXT3_MOUNT_ORDERED_DATA; + goto datacheck; + case Opt_data_writeback: + data_opt = EXT3_MOUNT_WRITEBACK_DATA; + datacheck: + if (is_remount) { + if (test_opt(sb, DATA_FLAGS) == data_opt) + break; + ext3_msg(sb, KERN_ERR, + ""error: cannot change "" + ""data mode on remount. The filesystem "" + ""is mounted in data=%s mode and you "" + ""try to remount it in data=%s mode."", + data_mode_string(test_opt(sb, + DATA_FLAGS)), + data_mode_string(data_opt)); + return 0; + } else { + clear_opt(sbi->s_mount_opt, DATA_FLAGS); + sbi->s_mount_opt |= data_opt; + } + break; + case Opt_data_err_abort: + set_opt(sbi->s_mount_opt, DATA_ERR_ABORT); + break; + case Opt_data_err_ignore: + clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); + break; +#ifdef CONFIG_QUOTA + case Opt_usrjquota: + if (!set_qf_name(sb, USRQUOTA, &args[0])) + return 0; + break; + case Opt_grpjquota: + if (!set_qf_name(sb, GRPQUOTA, &args[0])) + return 0; + break; + case Opt_offusrjquota: + if (!clear_qf_name(sb, USRQUOTA)) + return 0; + break; + case Opt_offgrpjquota: + if (!clear_qf_name(sb, GRPQUOTA)) + return 0; + break; + case Opt_jqfmt_vfsold: + qfmt = QFMT_VFS_OLD; + goto set_qf_format; + case Opt_jqfmt_vfsv0: + qfmt = QFMT_VFS_V0; + goto set_qf_format; + case Opt_jqfmt_vfsv1: + qfmt = QFMT_VFS_V1; +set_qf_format: + if (sb_any_quota_loaded(sb) && + sbi->s_jquota_fmt != qfmt) { + ext3_msg(sb, KERN_ERR, ""error: cannot change "" + ""journaled quota options when "" + ""quota turned on.""); + return 0; + } + sbi->s_jquota_fmt = qfmt; + break; + case Opt_quota: + case Opt_usrquota: + set_opt(sbi->s_mount_opt, QUOTA); + set_opt(sbi->s_mount_opt, USRQUOTA); + break; + case Opt_grpquota: + set_opt(sbi->s_mount_opt, QUOTA); + set_opt(sbi->s_mount_opt, GRPQUOTA); + break; + case Opt_noquota: + if (sb_any_quota_loaded(sb)) { + ext3_msg(sb, KERN_ERR, ""error: cannot change "" + ""quota options when quota turned on.""); + return 0; + } + clear_opt(sbi->s_mount_opt, QUOTA); + clear_opt(sbi->s_mount_opt, USRQUOTA); + clear_opt(sbi->s_mount_opt, GRPQUOTA); + break; +#else + case Opt_quota: + case Opt_usrquota: + case Opt_grpquota: + ext3_msg(sb, KERN_ERR, + ""error: quota options not supported.""); + break; + case Opt_usrjquota: + case Opt_grpjquota: + case Opt_offusrjquota: + case Opt_offgrpjquota: + case Opt_jqfmt_vfsold: + case Opt_jqfmt_vfsv0: + case Opt_jqfmt_vfsv1: + ext3_msg(sb, KERN_ERR, + ""error: journaled quota options not "" + ""supported.""); + break; + case Opt_noquota: + break; +#endif + case Opt_abort: + set_opt(sbi->s_mount_opt, ABORT); + break; + case Opt_nobarrier: + clear_opt(sbi->s_mount_opt, BARRIER); + break; + case Opt_barrier: + if (args[0].from) { + if (match_int(&args[0], &option)) + return 0; + } else + option = 1; /* No argument, default to 1 */ + if (option) + set_opt(sbi->s_mount_opt, BARRIER); + else + clear_opt(sbi->s_mount_opt, BARRIER); + break; + case Opt_ignore: + break; + case Opt_resize: + if (!is_remount) { + ext3_msg(sb, KERN_ERR, + ""error: resize option only available "" + ""for remount""); + return 0; + } + if (match_int(&args[0], &option) != 0) + return 0; + *n_blocks_count = option; + break; + case Opt_nobh: + ext3_msg(sb, KERN_WARNING, + ""warning: ignoring deprecated nobh option""); + break; + case Opt_bh: + ext3_msg(sb, KERN_WARNING, + ""warning: ignoring deprecated bh option""); + break; + default: + ext3_msg(sb, KERN_ERR, + ""error: unrecognized mount option \""%s\"" "" + ""or missing value"", p); + return 0; + } + } +#ifdef CONFIG_QUOTA + if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { + if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) + clear_opt(sbi->s_mount_opt, USRQUOTA); + if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) + clear_opt(sbi->s_mount_opt, GRPQUOTA); + + if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { + ext3_msg(sb, KERN_ERR, ""error: old and new quota "" + ""format mixing.""); + return 0; + } + + if (!sbi->s_jquota_fmt) { + ext3_msg(sb, KERN_ERR, ""error: journaled quota format "" + ""not specified.""); + return 0; + } + } else { + if (sbi->s_jquota_fmt) { + ext3_msg(sb, KERN_ERR, ""error: journaled quota format "" + ""specified with no journaling "" + ""enabled.""); + return 0; + } + } +#endif + return 1; +} +","@@ -353,7 +353,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb) + return bdev; + + fail: +- ext3_msg(sb, ""error: failed to open journal device %s: %ld"", ++ ext3_msg(sb, KERN_ERR, ""error: failed to open journal device %s: %ld"", + __bdevname(dev, b), PTR_ERR(bdev)); + + return NULL; +@@ -887,7 +887,7 @@ static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb) + /*todo: use simple_strtoll with >32bit ext3 */ + sb_block = simple_strtoul(options, &options, 0); + if (*options && *options != ',') { +- ext3_msg(sb, ""error: invalid sb specification: %s"", ++ ext3_msg(sb, KERN_ERR, ""error: invalid sb specification: %s"", + (char *) *data); + return 1; + }",2877,3113,4096 +18329,"void CL_Init( void ) { + Com_Printf( ""----- Client Initialization -----\n"" ); + + Con_Init (); + + if(!com_fullyInitialized) + { + CL_ClearState(); + clc.state = CA_DISCONNECTED; // no longer CA_UNINITIALIZED + cl_oldGameSet = qfalse; + } + + cls.realtime = 0; + + CL_InitInput (); + + cl_noprint = Cvar_Get( ""cl_noprint"", ""0"", 0 ); +#ifdef UPDATE_SERVER_NAME + cl_motd = Cvar_Get (""cl_motd"", ""1"", 0); +#endif + + cl_timeout = Cvar_Get (""cl_timeout"", ""200"", 0); + + cl_timeNudge = Cvar_Get (""cl_timeNudge"", ""0"", CVAR_TEMP ); + cl_shownet = Cvar_Get (""cl_shownet"", ""0"", CVAR_TEMP ); + cl_showSend = Cvar_Get (""cl_showSend"", ""0"", CVAR_TEMP ); + cl_showTimeDelta = Cvar_Get (""cl_showTimeDelta"", ""0"", CVAR_TEMP ); + cl_freezeDemo = Cvar_Get (""cl_freezeDemo"", ""0"", CVAR_TEMP ); + rcon_client_password = Cvar_Get (""rconPassword"", """", CVAR_TEMP ); + cl_activeAction = Cvar_Get( ""activeAction"", """", CVAR_TEMP ); + + cl_timedemo = Cvar_Get (""timedemo"", ""0"", 0); + cl_timedemoLog = Cvar_Get (""cl_timedemoLog"", """", CVAR_ARCHIVE); + cl_autoRecordDemo = Cvar_Get (""cl_autoRecordDemo"", ""0"", CVAR_ARCHIVE); + cl_aviFrameRate = Cvar_Get (""cl_aviFrameRate"", ""25"", CVAR_ARCHIVE); + cl_aviMotionJpeg = Cvar_Get (""cl_aviMotionJpeg"", ""1"", CVAR_ARCHIVE); + cl_forceavidemo = Cvar_Get (""cl_forceavidemo"", ""0"", 0); + + rconAddress = Cvar_Get (""rconAddress"", """", 0); + + cl_yawspeed = Cvar_Get (""cl_yawspeed"", ""140"", CVAR_ARCHIVE); + cl_pitchspeed = Cvar_Get (""cl_pitchspeed"", ""140"", CVAR_ARCHIVE); + cl_anglespeedkey = Cvar_Get (""cl_anglespeedkey"", ""1.5"", 0); + + cl_maxpackets = Cvar_Get (""cl_maxpackets"", ""30"", CVAR_ARCHIVE ); + cl_packetdup = Cvar_Get (""cl_packetdup"", ""1"", CVAR_ARCHIVE ); + + cl_run = Cvar_Get (""cl_run"", ""1"", CVAR_ARCHIVE); + cl_sensitivity = Cvar_Get (""sensitivity"", ""5"", CVAR_ARCHIVE); + cl_mouseAccel = Cvar_Get (""cl_mouseAccel"", ""0"", CVAR_ARCHIVE); + cl_freelook = Cvar_Get( ""cl_freelook"", ""1"", CVAR_ARCHIVE ); + + cl_mouseAccelStyle = Cvar_Get( ""cl_mouseAccelStyle"", ""0"", CVAR_ARCHIVE ); + cl_mouseAccelOffset = Cvar_Get( ""cl_mouseAccelOffset"", ""5"", CVAR_ARCHIVE ); + Cvar_CheckRange(cl_mouseAccelOffset, 0.001f, 50000.0f, qfalse); + + cl_showMouseRate = Cvar_Get (""cl_showmouserate"", ""0"", 0); + + cl_allowDownload = Cvar_Get (""cl_allowDownload"", ""0"", CVAR_ARCHIVE); + #ifdef USE_CURL_DLOPEN + cl_cURLLib = Cvar_Get(""cl_cURLLib"", DEFAULT_CURL_LIB, CVAR_ARCHIVE); + #endif + + cl_conXOffset = Cvar_Get (""cl_conXOffset"", ""0"", 0); +#ifdef __APPLE__ + cl_inGameVideo = Cvar_Get (""r_inGameVideo"", ""0"", CVAR_ARCHIVE); +#else + cl_inGameVideo = Cvar_Get (""r_inGameVideo"", ""1"", CVAR_ARCHIVE); +#endif + + cl_serverStatusResendTime = Cvar_Get (""cl_serverStatusResendTime"", ""750"", 0); + + Cvar_Get (""cg_autoswitch"", ""1"", CVAR_ARCHIVE); + + m_pitch = Cvar_Get (""m_pitch"", ""0.022"", CVAR_ARCHIVE); + m_yaw = Cvar_Get (""m_yaw"", ""0.022"", CVAR_ARCHIVE); + m_forward = Cvar_Get (""m_forward"", ""0.25"", CVAR_ARCHIVE); + m_side = Cvar_Get (""m_side"", ""0.25"", CVAR_ARCHIVE); +#ifdef __APPLE__ + m_filter = Cvar_Get (""m_filter"", ""1"", CVAR_ARCHIVE); +#else + m_filter = Cvar_Get (""m_filter"", ""0"", CVAR_ARCHIVE); +#endif + + j_pitch = Cvar_Get (""j_pitch"", ""0.022"", CVAR_ARCHIVE); + j_yaw = Cvar_Get (""j_yaw"", ""-0.022"", CVAR_ARCHIVE); + j_forward = Cvar_Get (""j_forward"", ""-0.25"", CVAR_ARCHIVE); + j_side = Cvar_Get (""j_side"", ""0.25"", CVAR_ARCHIVE); + j_up = Cvar_Get (""j_up"", ""0"", CVAR_ARCHIVE); + + j_pitch_axis = Cvar_Get (""j_pitch_axis"", ""3"", CVAR_ARCHIVE); + j_yaw_axis = Cvar_Get (""j_yaw_axis"", ""2"", CVAR_ARCHIVE); + j_forward_axis = Cvar_Get (""j_forward_axis"", ""1"", CVAR_ARCHIVE); + j_side_axis = Cvar_Get (""j_side_axis"", ""0"", CVAR_ARCHIVE); + j_up_axis = Cvar_Get (""j_up_axis"", ""4"", CVAR_ARCHIVE); + + Cvar_CheckRange(j_pitch_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_yaw_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_forward_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_side_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_up_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + + cl_motdString = Cvar_Get( ""cl_motdString"", """", CVAR_ROM ); + + Cvar_Get( ""cl_maxPing"", ""800"", CVAR_ARCHIVE ); + + cl_lanForcePackets = Cvar_Get (""cl_lanForcePackets"", ""1"", CVAR_ARCHIVE); + + cl_guidServerUniq = Cvar_Get (""cl_guidServerUniq"", ""1"", CVAR_ARCHIVE); + + cl_consoleKeys = Cvar_Get( ""cl_consoleKeys"", ""~ ` 0x7e 0x60"", CVAR_ARCHIVE); + + Cvar_Get (""name"", ""UnnamedPlayer"", CVAR_USERINFO | CVAR_ARCHIVE ); + cl_rate = Cvar_Get (""rate"", ""25000"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""snaps"", ""20"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""model"", ""sarge"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""headmodel"", ""sarge"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""team_model"", ""james"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""team_headmodel"", ""*james"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""g_redTeam"", ""Stroggs"", CVAR_SERVERINFO | CVAR_ARCHIVE); + Cvar_Get (""g_blueTeam"", ""Pagans"", CVAR_SERVERINFO | CVAR_ARCHIVE); + Cvar_Get (""color1"", ""4"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""color2"", ""5"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""handicap"", ""100"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""teamtask"", ""0"", CVAR_USERINFO ); + Cvar_Get (""sex"", ""male"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""cl_anonymous"", ""0"", CVAR_USERINFO | CVAR_ARCHIVE ); + + Cvar_Get (""password"", """", CVAR_USERINFO); + Cvar_Get (""cg_predictItems"", ""1"", CVAR_USERINFO | CVAR_ARCHIVE ); + +#ifdef USE_MUMBLE + cl_useMumble = Cvar_Get (""cl_useMumble"", ""0"", CVAR_ARCHIVE | CVAR_LATCH); + cl_mumbleScale = Cvar_Get (""cl_mumbleScale"", ""0.0254"", CVAR_ARCHIVE); +#endif + +#ifdef USE_VOIP + cl_voipSend = Cvar_Get (""cl_voipSend"", ""0"", 0); + cl_voipSendTarget = Cvar_Get (""cl_voipSendTarget"", ""spatial"", 0); + cl_voipGainDuringCapture = Cvar_Get (""cl_voipGainDuringCapture"", ""0.2"", CVAR_ARCHIVE); + cl_voipCaptureMult = Cvar_Get (""cl_voipCaptureMult"", ""2.0"", CVAR_ARCHIVE); + cl_voipUseVAD = Cvar_Get (""cl_voipUseVAD"", ""0"", CVAR_ARCHIVE); + cl_voipVADThreshold = Cvar_Get (""cl_voipVADThreshold"", ""0.25"", CVAR_ARCHIVE); + cl_voipShowMeter = Cvar_Get (""cl_voipShowMeter"", ""1"", CVAR_ARCHIVE); + + cl_voip = Cvar_Get (""cl_voip"", ""1"", CVAR_ARCHIVE); + Cvar_CheckRange( cl_voip, 0, 1, qtrue ); + cl_voipProtocol = Cvar_Get (""cl_voipProtocol"", cl_voip->integer ? ""opus"" : """", CVAR_USERINFO | CVAR_ROM); +#endif + + + Cvar_Get (""cg_viewsize"", ""100"", CVAR_ARCHIVE ); + Cvar_Get (""cg_stereoSeparation"", ""0"", CVAR_ROM); + + Cmd_AddCommand (""cmd"", CL_ForwardToServer_f); + Cmd_AddCommand (""configstrings"", CL_Configstrings_f); + Cmd_AddCommand (""clientinfo"", CL_Clientinfo_f); + Cmd_AddCommand (""snd_restart"", CL_Snd_Restart_f); + Cmd_AddCommand (""vid_restart"", CL_Vid_Restart_f); + Cmd_AddCommand (""disconnect"", CL_Disconnect_f); + Cmd_AddCommand (""record"", CL_Record_f); + Cmd_AddCommand (""demo"", CL_PlayDemo_f); + Cmd_SetCommandCompletionFunc( ""demo"", CL_CompleteDemoName ); + Cmd_AddCommand (""cinematic"", CL_PlayCinematic_f); + Cmd_AddCommand (""stoprecord"", CL_StopRecord_f); + Cmd_AddCommand (""connect"", CL_Connect_f); + Cmd_AddCommand (""reconnect"", CL_Reconnect_f); + Cmd_AddCommand (""localservers"", CL_LocalServers_f); + Cmd_AddCommand (""globalservers"", CL_GlobalServers_f); + Cmd_AddCommand (""rcon"", CL_Rcon_f); + Cmd_SetCommandCompletionFunc( ""rcon"", CL_CompleteRcon ); + Cmd_AddCommand (""ping"", CL_Ping_f ); + Cmd_AddCommand (""serverstatus"", CL_ServerStatus_f ); + Cmd_AddCommand (""showip"", CL_ShowIP_f ); + Cmd_AddCommand (""fs_openedList"", CL_OpenedPK3List_f ); + Cmd_AddCommand (""fs_referencedList"", CL_ReferencedPK3List_f ); + Cmd_AddCommand (""model"", CL_SetModel_f ); + Cmd_AddCommand (""video"", CL_Video_f ); + Cmd_AddCommand (""stopvideo"", CL_StopVideo_f ); + if( !com_dedicated->integer ) { + Cmd_AddCommand (""sayto"", CL_Sayto_f ); + Cmd_SetCommandCompletionFunc( ""sayto"", CL_CompletePlayerName ); + } + CL_InitRef(); + + SCR_Init (); + + + Cvar_Set( ""cl_running"", ""1"" ); + + CL_GenerateQKey(); + Cvar_Get( ""cl_guid"", """", CVAR_USERINFO | CVAR_ROM ); + CL_UpdateGUID( NULL, 0 ); + + Com_Printf( ""----- Client Initialization Complete -----\n"" ); +} +",1,"void CL_Init( void ) { + Com_Printf( ""----- Client Initialization -----\n"" ); + + Con_Init (); + + if(!com_fullyInitialized) + { + CL_ClearState(); + clc.state = CA_DISCONNECTED; // no longer CA_UNINITIALIZED + cl_oldGameSet = qfalse; + } + + cls.realtime = 0; + + CL_InitInput (); + + cl_noprint = Cvar_Get( ""cl_noprint"", ""0"", 0 ); +#ifdef UPDATE_SERVER_NAME + cl_motd = Cvar_Get (""cl_motd"", ""1"", 0); +#endif + + cl_timeout = Cvar_Get (""cl_timeout"", ""200"", 0); + + cl_timeNudge = Cvar_Get (""cl_timeNudge"", ""0"", CVAR_TEMP ); + cl_shownet = Cvar_Get (""cl_shownet"", ""0"", CVAR_TEMP ); + cl_showSend = Cvar_Get (""cl_showSend"", ""0"", CVAR_TEMP ); + cl_showTimeDelta = Cvar_Get (""cl_showTimeDelta"", ""0"", CVAR_TEMP ); + cl_freezeDemo = Cvar_Get (""cl_freezeDemo"", ""0"", CVAR_TEMP ); + rcon_client_password = Cvar_Get (""rconPassword"", """", CVAR_TEMP ); + cl_activeAction = Cvar_Get( ""activeAction"", """", CVAR_TEMP ); + + cl_timedemo = Cvar_Get (""timedemo"", ""0"", 0); + cl_timedemoLog = Cvar_Get (""cl_timedemoLog"", """", CVAR_ARCHIVE); + cl_autoRecordDemo = Cvar_Get (""cl_autoRecordDemo"", ""0"", CVAR_ARCHIVE); + cl_aviFrameRate = Cvar_Get (""cl_aviFrameRate"", ""25"", CVAR_ARCHIVE); + cl_aviMotionJpeg = Cvar_Get (""cl_aviMotionJpeg"", ""1"", CVAR_ARCHIVE); + cl_forceavidemo = Cvar_Get (""cl_forceavidemo"", ""0"", 0); + + rconAddress = Cvar_Get (""rconAddress"", """", 0); + + cl_yawspeed = Cvar_Get (""cl_yawspeed"", ""140"", CVAR_ARCHIVE); + cl_pitchspeed = Cvar_Get (""cl_pitchspeed"", ""140"", CVAR_ARCHIVE); + cl_anglespeedkey = Cvar_Get (""cl_anglespeedkey"", ""1.5"", 0); + + cl_maxpackets = Cvar_Get (""cl_maxpackets"", ""30"", CVAR_ARCHIVE ); + cl_packetdup = Cvar_Get (""cl_packetdup"", ""1"", CVAR_ARCHIVE ); + + cl_run = Cvar_Get (""cl_run"", ""1"", CVAR_ARCHIVE); + cl_sensitivity = Cvar_Get (""sensitivity"", ""5"", CVAR_ARCHIVE); + cl_mouseAccel = Cvar_Get (""cl_mouseAccel"", ""0"", CVAR_ARCHIVE); + cl_freelook = Cvar_Get( ""cl_freelook"", ""1"", CVAR_ARCHIVE ); + + cl_mouseAccelStyle = Cvar_Get( ""cl_mouseAccelStyle"", ""0"", CVAR_ARCHIVE ); + cl_mouseAccelOffset = Cvar_Get( ""cl_mouseAccelOffset"", ""5"", CVAR_ARCHIVE ); + Cvar_CheckRange(cl_mouseAccelOffset, 0.001f, 50000.0f, qfalse); + + cl_showMouseRate = Cvar_Get (""cl_showmouserate"", ""0"", 0); + + cl_allowDownload = Cvar_Get (""cl_allowDownload"", ""0"", CVAR_ARCHIVE); + #ifdef USE_CURL_DLOPEN + cl_cURLLib = Cvar_Get(""cl_cURLLib"", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED); + #endif + + cl_conXOffset = Cvar_Get (""cl_conXOffset"", ""0"", 0); +#ifdef __APPLE__ + cl_inGameVideo = Cvar_Get (""r_inGameVideo"", ""0"", CVAR_ARCHIVE); +#else + cl_inGameVideo = Cvar_Get (""r_inGameVideo"", ""1"", CVAR_ARCHIVE); +#endif + + cl_serverStatusResendTime = Cvar_Get (""cl_serverStatusResendTime"", ""750"", 0); + + Cvar_Get (""cg_autoswitch"", ""1"", CVAR_ARCHIVE); + + m_pitch = Cvar_Get (""m_pitch"", ""0.022"", CVAR_ARCHIVE); + m_yaw = Cvar_Get (""m_yaw"", ""0.022"", CVAR_ARCHIVE); + m_forward = Cvar_Get (""m_forward"", ""0.25"", CVAR_ARCHIVE); + m_side = Cvar_Get (""m_side"", ""0.25"", CVAR_ARCHIVE); +#ifdef __APPLE__ + m_filter = Cvar_Get (""m_filter"", ""1"", CVAR_ARCHIVE); +#else + m_filter = Cvar_Get (""m_filter"", ""0"", CVAR_ARCHIVE); +#endif + + j_pitch = Cvar_Get (""j_pitch"", ""0.022"", CVAR_ARCHIVE); + j_yaw = Cvar_Get (""j_yaw"", ""-0.022"", CVAR_ARCHIVE); + j_forward = Cvar_Get (""j_forward"", ""-0.25"", CVAR_ARCHIVE); + j_side = Cvar_Get (""j_side"", ""0.25"", CVAR_ARCHIVE); + j_up = Cvar_Get (""j_up"", ""0"", CVAR_ARCHIVE); + + j_pitch_axis = Cvar_Get (""j_pitch_axis"", ""3"", CVAR_ARCHIVE); + j_yaw_axis = Cvar_Get (""j_yaw_axis"", ""2"", CVAR_ARCHIVE); + j_forward_axis = Cvar_Get (""j_forward_axis"", ""1"", CVAR_ARCHIVE); + j_side_axis = Cvar_Get (""j_side_axis"", ""0"", CVAR_ARCHIVE); + j_up_axis = Cvar_Get (""j_up_axis"", ""4"", CVAR_ARCHIVE); + + Cvar_CheckRange(j_pitch_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_yaw_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_forward_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_side_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + Cvar_CheckRange(j_up_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue); + + cl_motdString = Cvar_Get( ""cl_motdString"", """", CVAR_ROM ); + + Cvar_Get( ""cl_maxPing"", ""800"", CVAR_ARCHIVE ); + + cl_lanForcePackets = Cvar_Get (""cl_lanForcePackets"", ""1"", CVAR_ARCHIVE); + + cl_guidServerUniq = Cvar_Get (""cl_guidServerUniq"", ""1"", CVAR_ARCHIVE); + + cl_consoleKeys = Cvar_Get( ""cl_consoleKeys"", ""~ ` 0x7e 0x60"", CVAR_ARCHIVE); + + Cvar_Get (""name"", ""UnnamedPlayer"", CVAR_USERINFO | CVAR_ARCHIVE ); + cl_rate = Cvar_Get (""rate"", ""25000"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""snaps"", ""20"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""model"", ""sarge"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""headmodel"", ""sarge"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""team_model"", ""james"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""team_headmodel"", ""*james"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""g_redTeam"", ""Stroggs"", CVAR_SERVERINFO | CVAR_ARCHIVE); + Cvar_Get (""g_blueTeam"", ""Pagans"", CVAR_SERVERINFO | CVAR_ARCHIVE); + Cvar_Get (""color1"", ""4"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""color2"", ""5"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""handicap"", ""100"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""teamtask"", ""0"", CVAR_USERINFO ); + Cvar_Get (""sex"", ""male"", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get (""cl_anonymous"", ""0"", CVAR_USERINFO | CVAR_ARCHIVE ); + + Cvar_Get (""password"", """", CVAR_USERINFO); + Cvar_Get (""cg_predictItems"", ""1"", CVAR_USERINFO | CVAR_ARCHIVE ); + +#ifdef USE_MUMBLE + cl_useMumble = Cvar_Get (""cl_useMumble"", ""0"", CVAR_ARCHIVE | CVAR_LATCH); + cl_mumbleScale = Cvar_Get (""cl_mumbleScale"", ""0.0254"", CVAR_ARCHIVE); +#endif + +#ifdef USE_VOIP + cl_voipSend = Cvar_Get (""cl_voipSend"", ""0"", 0); + cl_voipSendTarget = Cvar_Get (""cl_voipSendTarget"", ""spatial"", 0); + cl_voipGainDuringCapture = Cvar_Get (""cl_voipGainDuringCapture"", ""0.2"", CVAR_ARCHIVE); + cl_voipCaptureMult = Cvar_Get (""cl_voipCaptureMult"", ""2.0"", CVAR_ARCHIVE); + cl_voipUseVAD = Cvar_Get (""cl_voipUseVAD"", ""0"", CVAR_ARCHIVE); + cl_voipVADThreshold = Cvar_Get (""cl_voipVADThreshold"", ""0.25"", CVAR_ARCHIVE); + cl_voipShowMeter = Cvar_Get (""cl_voipShowMeter"", ""1"", CVAR_ARCHIVE); + + cl_voip = Cvar_Get (""cl_voip"", ""1"", CVAR_ARCHIVE); + Cvar_CheckRange( cl_voip, 0, 1, qtrue ); + cl_voipProtocol = Cvar_Get (""cl_voipProtocol"", cl_voip->integer ? ""opus"" : """", CVAR_USERINFO | CVAR_ROM); +#endif + + + Cvar_Get (""cg_viewsize"", ""100"", CVAR_ARCHIVE ); + Cvar_Get (""cg_stereoSeparation"", ""0"", CVAR_ROM); + + Cmd_AddCommand (""cmd"", CL_ForwardToServer_f); + Cmd_AddCommand (""configstrings"", CL_Configstrings_f); + Cmd_AddCommand (""clientinfo"", CL_Clientinfo_f); + Cmd_AddCommand (""snd_restart"", CL_Snd_Restart_f); + Cmd_AddCommand (""vid_restart"", CL_Vid_Restart_f); + Cmd_AddCommand (""disconnect"", CL_Disconnect_f); + Cmd_AddCommand (""record"", CL_Record_f); + Cmd_AddCommand (""demo"", CL_PlayDemo_f); + Cmd_SetCommandCompletionFunc( ""demo"", CL_CompleteDemoName ); + Cmd_AddCommand (""cinematic"", CL_PlayCinematic_f); + Cmd_AddCommand (""stoprecord"", CL_StopRecord_f); + Cmd_AddCommand (""connect"", CL_Connect_f); + Cmd_AddCommand (""reconnect"", CL_Reconnect_f); + Cmd_AddCommand (""localservers"", CL_LocalServers_f); + Cmd_AddCommand (""globalservers"", CL_GlobalServers_f); + Cmd_AddCommand (""rcon"", CL_Rcon_f); + Cmd_SetCommandCompletionFunc( ""rcon"", CL_CompleteRcon ); + Cmd_AddCommand (""ping"", CL_Ping_f ); + Cmd_AddCommand (""serverstatus"", CL_ServerStatus_f ); + Cmd_AddCommand (""showip"", CL_ShowIP_f ); + Cmd_AddCommand (""fs_openedList"", CL_OpenedPK3List_f ); + Cmd_AddCommand (""fs_referencedList"", CL_ReferencedPK3List_f ); + Cmd_AddCommand (""model"", CL_SetModel_f ); + Cmd_AddCommand (""video"", CL_Video_f ); + Cmd_AddCommand (""stopvideo"", CL_StopVideo_f ); + if( !com_dedicated->integer ) { + Cmd_AddCommand (""sayto"", CL_Sayto_f ); + Cmd_SetCommandCompletionFunc( ""sayto"", CL_CompletePlayerName ); + } + CL_InitRef(); + + SCR_Init (); + + + Cvar_Set( ""cl_running"", ""1"" ); + + CL_GenerateQKey(); + Cvar_Get( ""cl_guid"", """", CVAR_USERINFO | CVAR_ROM ); + CL_UpdateGUID( NULL, 0 ); + + Com_Printf( ""----- Client Initialization Complete -----\n"" ); +} +","@@ -3200,7 +3200,7 @@ void CL_InitRef( void ) { + Com_Printf( ""----- Initializing Renderer ----\n"" ); + + #ifdef USE_RENDERER_DLOPEN +- cl_renderer = Cvar_Get(""cl_renderer"", ""opengl2"", CVAR_ARCHIVE | CVAR_LATCH); ++ cl_renderer = Cvar_Get(""cl_renderer"", ""opengl2"", CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED); + + Com_sprintf(dllName, sizeof(dllName), ""renderer_%s_"" ARCH_STRING DLL_EXT, cl_renderer->string); + +@@ -3551,7 +3551,7 @@ void CL_Init( void ) { + + cl_allowDownload = Cvar_Get (""cl_allowDownload"", ""0"", CVAR_ARCHIVE); + #ifdef USE_CURL_DLOPEN +- cl_cURLLib = Cvar_Get(""cl_cURLLib"", DEFAULT_CURL_LIB, CVAR_ARCHIVE); ++ cl_cURLLib = Cvar_Get(""cl_cURLLib"", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED); + #endif + + cl_conXOffset = Cvar_Get (""cl_conXOffset"", ""0"", 0);",2594,2830,4096 +18090,"static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev) +{ + struct sock *sk; + struct packet_sock *po; + struct sockaddr_ll *sll; + union tpacket_uhdr h; + u8 *skb_head = skb->data; + int skb_len = skb->len; + unsigned int snaplen, res; + unsigned long status = TP_STATUS_USER; + unsigned short macoff, netoff, hdrlen; + struct sk_buff *copy_skb = NULL; + struct timespec ts; + __u32 ts_status; + bool is_drop_n_account = false; + + /* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. + * We may add members to them until current aligned size without forcing + * userspace to call getsockopt(..., PACKET_HDRLEN, ...). + */ + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); + + if (skb->pkt_type == PACKET_LOOPBACK) + goto drop; + + sk = pt->af_packet_priv; + po = pkt_sk(sk); + + if (!net_eq(dev_net(dev), sock_net(sk))) + goto drop; + + if (dev->header_ops) { + if (sk->sk_type != SOCK_DGRAM) + skb_push(skb, skb->data - skb_mac_header(skb)); + else if (skb->pkt_type == PACKET_OUTGOING) { + /* Special case: outgoing packets have ll header at head */ + skb_pull(skb, skb_network_offset(skb)); + } + } + + snaplen = skb->len; + + res = run_filter(skb, sk, snaplen); + if (!res) + goto drop_n_restore; + + if (skb->ip_summed == CHECKSUM_PARTIAL) + status |= TP_STATUS_CSUMNOTREADY; + else if (skb->pkt_type != PACKET_OUTGOING && + (skb->ip_summed == CHECKSUM_COMPLETE || + skb_csum_unnecessary(skb))) + status |= TP_STATUS_CSUM_VALID; + + if (snaplen > res) + snaplen = res; + + if (sk->sk_type == SOCK_DGRAM) { + macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 + + po->tp_reserve; + } else { + unsigned int maclen = skb_network_offset(skb); + netoff = TPACKET_ALIGN(po->tp_hdrlen + + (maclen < 16 ? 16 : maclen)) + + po->tp_reserve; + if (po->has_vnet_hdr) + netoff += sizeof(struct virtio_net_hdr); + macoff = netoff - maclen; + } + if (po->tp_version <= TPACKET_V2) { + if (macoff + snaplen > po->rx_ring.frame_size) { + if (po->copy_thresh && + atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { + if (skb_shared(skb)) { + copy_skb = skb_clone(skb, GFP_ATOMIC); + } else { + copy_skb = skb_get(skb); + skb_head = skb->data; + } + if (copy_skb) + skb_set_owner_r(copy_skb, sk); + } + snaplen = po->rx_ring.frame_size - macoff; + if ((int)snaplen < 0) + snaplen = 0; + } + } else if (unlikely(macoff + snaplen > + GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) { + u32 nval; + + nval = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len - macoff; + pr_err_once(""tpacket_rcv: packet too big, clamped from %u to %u. macoff=%u\n"", + snaplen, nval, macoff); + snaplen = nval; + if (unlikely((int)snaplen < 0)) { + snaplen = 0; + macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len; + } + } + spin_lock(&sk->sk_receive_queue.lock); + h.raw = packet_current_rx_frame(po, skb, + TP_STATUS_KERNEL, (macoff+snaplen)); + if (!h.raw) + goto drop_n_account; + if (po->tp_version <= TPACKET_V2) { + packet_increment_rx_head(po, &po->rx_ring); + /* + * LOSING will be reported till you read the stats, + * because it's COR - Clear On Read. + * Anyways, moving it for V1/V2 only as V3 doesn't need this + * at packet level. + */ + if (po->stats.stats1.tp_drops) + status |= TP_STATUS_LOSING; + } + po->stats.stats1.tp_packets++; + if (copy_skb) { + status |= TP_STATUS_COPY; + __skb_queue_tail(&sk->sk_receive_queue, copy_skb); + } + spin_unlock(&sk->sk_receive_queue.lock); + + if (po->has_vnet_hdr) { + if (virtio_net_hdr_from_skb(skb, h.raw + macoff - + sizeof(struct virtio_net_hdr), + vio_le(), true)) { + spin_lock(&sk->sk_receive_queue.lock); + goto drop_n_account; + } + } + + skb_copy_bits(skb, 0, h.raw + macoff, snaplen); + + if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) + getnstimeofday(&ts); + + status |= ts_status; + + switch (po->tp_version) { + case TPACKET_V1: + h.h1->tp_len = skb->len; + h.h1->tp_snaplen = snaplen; + h.h1->tp_mac = macoff; + h.h1->tp_net = netoff; + h.h1->tp_sec = ts.tv_sec; + h.h1->tp_usec = ts.tv_nsec / NSEC_PER_USEC; + hdrlen = sizeof(*h.h1); + break; + case TPACKET_V2: + h.h2->tp_len = skb->len; + h.h2->tp_snaplen = snaplen; + h.h2->tp_mac = macoff; + h.h2->tp_net = netoff; + h.h2->tp_sec = ts.tv_sec; + h.h2->tp_nsec = ts.tv_nsec; + if (skb_vlan_tag_present(skb)) { + h.h2->tp_vlan_tci = skb_vlan_tag_get(skb); + h.h2->tp_vlan_tpid = ntohs(skb->vlan_proto); + status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID; + } else { + h.h2->tp_vlan_tci = 0; + h.h2->tp_vlan_tpid = 0; + } + memset(h.h2->tp_padding, 0, sizeof(h.h2->tp_padding)); + hdrlen = sizeof(*h.h2); + break; + case TPACKET_V3: + /* tp_nxt_offset,vlan are already populated above. + * So DONT clear those fields here + */ + h.h3->tp_status |= status; + h.h3->tp_len = skb->len; + h.h3->tp_snaplen = snaplen; + h.h3->tp_mac = macoff; + h.h3->tp_net = netoff; + h.h3->tp_sec = ts.tv_sec; + h.h3->tp_nsec = ts.tv_nsec; + memset(h.h3->tp_padding, 0, sizeof(h.h3->tp_padding)); + hdrlen = sizeof(*h.h3); + break; + default: + BUG(); + } + + sll = h.raw + TPACKET_ALIGN(hdrlen); + sll->sll_halen = dev_parse_header(skb, sll->sll_addr); + sll->sll_family = AF_PACKET; + sll->sll_hatype = dev->type; + sll->sll_protocol = skb->protocol; + sll->sll_pkttype = skb->pkt_type; + if (unlikely(po->origdev)) + sll->sll_ifindex = orig_dev->ifindex; + else + sll->sll_ifindex = dev->ifindex; + + smp_mb(); + +#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 + if (po->tp_version <= TPACKET_V2) { + u8 *start, *end; + + end = (u8 *) PAGE_ALIGN((unsigned long) h.raw + + macoff + snaplen); + + for (start = h.raw; start < end; start += PAGE_SIZE) + flush_dcache_page(pgv_to_page(start)); + } + smp_wmb(); +#endif + + if (po->tp_version <= TPACKET_V2) { + __packet_set_status(po, h.raw, status); + sk->sk_data_ready(sk); + } else { + prb_clear_blk_fill_status(&po->rx_ring); + } + +drop_n_restore: + if (skb_head != skb->data && skb_shared(skb)) { + skb->data = skb_head; + skb->len = skb_len; + } +drop: + if (!is_drop_n_account) + consume_skb(skb); + else + kfree_skb(skb); + return 0; + +drop_n_account: + is_drop_n_account = true; + po->stats.stats1.tp_drops++; + spin_unlock(&sk->sk_receive_queue.lock); + + sk->sk_data_ready(sk); + kfree_skb(copy_skb); + goto drop_n_restore; +} +",1,"static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt, struct net_device *orig_dev) +{ + struct sock *sk; + struct packet_sock *po; + struct sockaddr_ll *sll; + union tpacket_uhdr h; + u8 *skb_head = skb->data; + int skb_len = skb->len; + unsigned int snaplen, res; + unsigned long status = TP_STATUS_USER; + unsigned short macoff, netoff, hdrlen; + struct sk_buff *copy_skb = NULL; + struct timespec ts; + __u32 ts_status; + bool is_drop_n_account = false; + bool do_vnet = false; + + /* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. + * We may add members to them until current aligned size without forcing + * userspace to call getsockopt(..., PACKET_HDRLEN, ...). + */ + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); + + if (skb->pkt_type == PACKET_LOOPBACK) + goto drop; + + sk = pt->af_packet_priv; + po = pkt_sk(sk); + + if (!net_eq(dev_net(dev), sock_net(sk))) + goto drop; + + if (dev->header_ops) { + if (sk->sk_type != SOCK_DGRAM) + skb_push(skb, skb->data - skb_mac_header(skb)); + else if (skb->pkt_type == PACKET_OUTGOING) { + /* Special case: outgoing packets have ll header at head */ + skb_pull(skb, skb_network_offset(skb)); + } + } + + snaplen = skb->len; + + res = run_filter(skb, sk, snaplen); + if (!res) + goto drop_n_restore; + + if (skb->ip_summed == CHECKSUM_PARTIAL) + status |= TP_STATUS_CSUMNOTREADY; + else if (skb->pkt_type != PACKET_OUTGOING && + (skb->ip_summed == CHECKSUM_COMPLETE || + skb_csum_unnecessary(skb))) + status |= TP_STATUS_CSUM_VALID; + + if (snaplen > res) + snaplen = res; + + if (sk->sk_type == SOCK_DGRAM) { + macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 + + po->tp_reserve; + } else { + unsigned int maclen = skb_network_offset(skb); + netoff = TPACKET_ALIGN(po->tp_hdrlen + + (maclen < 16 ? 16 : maclen)) + + po->tp_reserve; + if (po->has_vnet_hdr) { + netoff += sizeof(struct virtio_net_hdr); + do_vnet = true; + } + macoff = netoff - maclen; + } + if (po->tp_version <= TPACKET_V2) { + if (macoff + snaplen > po->rx_ring.frame_size) { + if (po->copy_thresh && + atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { + if (skb_shared(skb)) { + copy_skb = skb_clone(skb, GFP_ATOMIC); + } else { + copy_skb = skb_get(skb); + skb_head = skb->data; + } + if (copy_skb) + skb_set_owner_r(copy_skb, sk); + } + snaplen = po->rx_ring.frame_size - macoff; + if ((int)snaplen < 0) { + snaplen = 0; + do_vnet = false; + } + } + } else if (unlikely(macoff + snaplen > + GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) { + u32 nval; + + nval = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len - macoff; + pr_err_once(""tpacket_rcv: packet too big, clamped from %u to %u. macoff=%u\n"", + snaplen, nval, macoff); + snaplen = nval; + if (unlikely((int)snaplen < 0)) { + snaplen = 0; + macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len; + do_vnet = false; + } + } + spin_lock(&sk->sk_receive_queue.lock); + h.raw = packet_current_rx_frame(po, skb, + TP_STATUS_KERNEL, (macoff+snaplen)); + if (!h.raw) + goto drop_n_account; + if (po->tp_version <= TPACKET_V2) { + packet_increment_rx_head(po, &po->rx_ring); + /* + * LOSING will be reported till you read the stats, + * because it's COR - Clear On Read. + * Anyways, moving it for V1/V2 only as V3 doesn't need this + * at packet level. + */ + if (po->stats.stats1.tp_drops) + status |= TP_STATUS_LOSING; + } + po->stats.stats1.tp_packets++; + if (copy_skb) { + status |= TP_STATUS_COPY; + __skb_queue_tail(&sk->sk_receive_queue, copy_skb); + } + spin_unlock(&sk->sk_receive_queue.lock); + + if (do_vnet) { + if (virtio_net_hdr_from_skb(skb, h.raw + macoff - + sizeof(struct virtio_net_hdr), + vio_le(), true)) { + spin_lock(&sk->sk_receive_queue.lock); + goto drop_n_account; + } + } + + skb_copy_bits(skb, 0, h.raw + macoff, snaplen); + + if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) + getnstimeofday(&ts); + + status |= ts_status; + + switch (po->tp_version) { + case TPACKET_V1: + h.h1->tp_len = skb->len; + h.h1->tp_snaplen = snaplen; + h.h1->tp_mac = macoff; + h.h1->tp_net = netoff; + h.h1->tp_sec = ts.tv_sec; + h.h1->tp_usec = ts.tv_nsec / NSEC_PER_USEC; + hdrlen = sizeof(*h.h1); + break; + case TPACKET_V2: + h.h2->tp_len = skb->len; + h.h2->tp_snaplen = snaplen; + h.h2->tp_mac = macoff; + h.h2->tp_net = netoff; + h.h2->tp_sec = ts.tv_sec; + h.h2->tp_nsec = ts.tv_nsec; + if (skb_vlan_tag_present(skb)) { + h.h2->tp_vlan_tci = skb_vlan_tag_get(skb); + h.h2->tp_vlan_tpid = ntohs(skb->vlan_proto); + status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID; + } else { + h.h2->tp_vlan_tci = 0; + h.h2->tp_vlan_tpid = 0; + } + memset(h.h2->tp_padding, 0, sizeof(h.h2->tp_padding)); + hdrlen = sizeof(*h.h2); + break; + case TPACKET_V3: + /* tp_nxt_offset,vlan are already populated above. + * So DONT clear those fields here + */ + h.h3->tp_status |= status; + h.h3->tp_len = skb->len; + h.h3->tp_snaplen = snaplen; + h.h3->tp_mac = macoff; + h.h3->tp_net = netoff; + h.h3->tp_sec = ts.tv_sec; + h.h3->tp_nsec = ts.tv_nsec; + memset(h.h3->tp_padding, 0, sizeof(h.h3->tp_padding)); + hdrlen = sizeof(*h.h3); + break; + default: + BUG(); + } + + sll = h.raw + TPACKET_ALIGN(hdrlen); + sll->sll_halen = dev_parse_header(skb, sll->sll_addr); + sll->sll_family = AF_PACKET; + sll->sll_hatype = dev->type; + sll->sll_protocol = skb->protocol; + sll->sll_pkttype = skb->pkt_type; + if (unlikely(po->origdev)) + sll->sll_ifindex = orig_dev->ifindex; + else + sll->sll_ifindex = dev->ifindex; + + smp_mb(); + +#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 + if (po->tp_version <= TPACKET_V2) { + u8 *start, *end; + + end = (u8 *) PAGE_ALIGN((unsigned long) h.raw + + macoff + snaplen); + + for (start = h.raw; start < end; start += PAGE_SIZE) + flush_dcache_page(pgv_to_page(start)); + } + smp_wmb(); +#endif + + if (po->tp_version <= TPACKET_V2) { + __packet_set_status(po, h.raw, status); + sk->sk_data_ready(sk); + } else { + prb_clear_blk_fill_status(&po->rx_ring); + } + +drop_n_restore: + if (skb_head != skb->data && skb_shared(skb)) { + skb->data = skb_head; + skb->len = skb_len; + } +drop: + if (!is_drop_n_account) + consume_skb(skb); + else + kfree_skb(skb); + return 0; + +drop_n_account: + is_drop_n_account = true; + po->stats.stats1.tp_drops++; + spin_unlock(&sk->sk_receive_queue.lock); + + sk->sk_data_ready(sk); + kfree_skb(copy_skb); + goto drop_n_restore; +} +","@@ -2191,6 +2191,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + struct timespec ts; + __u32 ts_status; + bool is_drop_n_account = false; ++ bool do_vnet = false; + + /* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. + * We may add members to them until current aligned size without forcing +@@ -2241,8 +2242,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + netoff = TPACKET_ALIGN(po->tp_hdrlen + + (maclen < 16 ? 16 : maclen)) + + po->tp_reserve; +- if (po->has_vnet_hdr) ++ if (po->has_vnet_hdr) { + netoff += sizeof(struct virtio_net_hdr); ++ do_vnet = true; ++ } + macoff = netoff - maclen; + } + if (po->tp_version <= TPACKET_V2) { +@@ -2259,8 +2262,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + skb_set_owner_r(copy_skb, sk); + } + snaplen = po->rx_ring.frame_size - macoff; +- if ((int)snaplen < 0) ++ if ((int)snaplen < 0) { + snaplen = 0; ++ do_vnet = false; ++ } + } + } else if (unlikely(macoff + snaplen > + GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) { +@@ -2273,6 +2278,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + if (unlikely((int)snaplen < 0)) { + snaplen = 0; + macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len; ++ do_vnet = false; + } + } + spin_lock(&sk->sk_receive_queue.lock); +@@ -2298,7 +2304,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + } + spin_unlock(&sk->sk_receive_queue.lock); + +- if (po->has_vnet_hdr) { ++ if (do_vnet) { + if (virtio_net_hdr_from_skb(skb, h.raw + macoff - + sizeof(struct virtio_net_hdr), + vio_le(), true)) {",2092,2328,4096 +17847,"static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */ +{ + zval **value; + zend_uchar key_type; + zend_bool close_fp = 1; + ulong int_key; + struct _phar_t *p_obj = (struct _phar_t*) puser; + uint str_key_len, base_len = p_obj->l, fname_len; + phar_entry_data *data; + php_stream *fp; + size_t contents_len; + char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, *temp = NULL; + phar_zstr key; + char *str_key; + zend_class_entry *ce = p_obj->c; + phar_archive_object *phar_obj = p_obj->p; + char *str = ""[stream]""; + + iter->funcs->get_current_data(iter, &value TSRMLS_CC); + + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + + if (!value) { + /* failure in get_current_data */ + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned no value"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + switch (Z_TYPE_PP(value)) { +#if PHP_VERSION_ID >= 60000 + case IS_UNICODE: + zval_unicode_to_string(*(value) TSRMLS_CC); + /* break intentionally omitted */ +#endif + case IS_STRING: + break; + case IS_RESOURCE: + php_stream_from_zval_no_verify(fp, value); + + if (!fp) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, ""Iterator %v returned an invalid stream handle"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + if (iter->funcs->get_current_key) { + key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC); + + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + + if (key_type == HASH_KEY_IS_LONG) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + if (key_type > 9) { /* IS_UNICODE == 10 */ +#if PHP_VERSION_ID < 60000 +/* this can never happen, but fixes a compile warning */ + spprintf(&str_key, 0, ""%s"", key); +#else + spprintf(&str_key, 0, ""%v"", key); + ezfree(key); +#endif + } else { + PHAR_STR(key, str_key); + } + + save = str_key; + + if (str_key[str_key_len - 1] == '\0') { + str_key_len--; + } + + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + close_fp = 0; + opened = (char *) estrndup(str, sizeof(""[stream]"") - 1); + goto after_open_fp; + case IS_OBJECT: + if (instanceof_function(Z_OBJCE_PP(value), spl_ce_SplFileInfo TSRMLS_CC)) { + char *test = NULL; + zval dummy; + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(*value TSRMLS_CC); + + if (!base_len) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, ""Iterator %v returns an SplFileInfo object, so base directory must be specified"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + switch (intern->type) { + case SPL_FS_DIR: +#if PHP_VERSION_ID >= 60000 + test = spl_filesystem_object_get_path(intern, NULL, NULL TSRMLS_CC).s; +#elif PHP_VERSION_ID >= 50300 + test = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC); +#else + test = intern->path; +#endif + fname_len = spprintf(&fname, 0, ""%s%c%s"", test, DEFAULT_SLASH, intern->u.dir.entry.d_name); + php_stat(fname, fname_len, FS_IS_DIR, &dummy TSRMLS_CC); + + if (Z_BVAL(dummy)) { + /* ignore directories */ + efree(fname); + return ZEND_HASH_APPLY_KEEP; + } + + test = expand_filepath(fname, NULL TSRMLS_CC); + efree(fname); + + if (test) { + fname = test; + fname_len = strlen(fname); + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Could not resolve file path""); + return ZEND_HASH_APPLY_STOP; + } + + save = fname; + goto phar_spl_fileinfo; + case SPL_FS_INFO: + case SPL_FS_FILE: +#if PHP_VERSION_ID >= 60000 + if (intern->file_name_type == IS_UNICODE) { + zval zv; + + INIT_ZVAL(zv); + Z_UNIVAL(zv) = intern->file_name; + Z_UNILEN(zv) = intern->file_name_len; + Z_TYPE(zv) = IS_UNICODE; + + zval_copy_ctor(&zv); + zval_unicode_to_string(&zv TSRMLS_CC); + fname = expand_filepath(Z_STRVAL(zv), NULL TSRMLS_CC); + ezfree(Z_UNIVAL(zv)); + } else { + fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC); + } +#else + fname = expand_filepath(intern->file_name, NULL TSRMLS_CC); +#endif + if (!fname) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Could not resolve file path""); + return ZEND_HASH_APPLY_STOP; + } + + fname_len = strlen(fname); + save = fname; + goto phar_spl_fileinfo; + } + } + /* fall-through */ + default: + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid value (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + fname = Z_STRVAL_PP(value); + fname_len = Z_STRLEN_PP(value); + +phar_spl_fileinfo: + if (base_len) { + temp = expand_filepath(base, NULL TSRMLS_CC); + if (!temp) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Could not resolve file path""); + if (save) { + efree(save); + } + return ZEND_HASH_APPLY_STOP; + } + base = temp; + base_len = strlen(base); + + if (strstr(fname, base)) { + str_key_len = fname_len - base_len; + + if (str_key_len <= 0) { + if (save) { + efree(save); + efree(temp); + } + return ZEND_HASH_APPLY_KEEP; + } + + str_key = fname + base_len; + + if (*str_key == '/' || *str_key == '\\') { + str_key++; + str_key_len--; + } + + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a path \""%s\"" that is not in the base directory \""%s\"""", ce->name, fname, base); + + if (save) { + efree(save); + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } + } else { + if (iter->funcs->get_current_key) { + key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC); + + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + + if (key_type == HASH_KEY_IS_LONG) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + if (key_type > 9) { /* IS_UNICODE == 10 */ +#if PHP_VERSION_ID < 60000 +/* this can never happen, but fixes a compile warning */ + spprintf(&str_key, 0, ""%s"", key); +#else + spprintf(&str_key, 0, ""%v"", key); + ezfree(key); +#endif + } else { + PHAR_STR(key, str_key); + } + + save = str_key; + + if (str_key[str_key_len - 1] == '\0') str_key_len--; + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + } +#if PHP_API_VERSION < 20100412 + if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a path \""%s\"" that safe mode prevents opening"", ce->name, fname); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } +#endif + + if (php_check_open_basedir(fname TSRMLS_CC)) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a path \""%s\"" that open_basedir prevents opening"", ce->name, fname); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } + + /* try to open source file, then create internal phar file and copy contents */ + fp = php_stream_open_wrapper(fname, ""rb"", STREAM_MUST_SEEK|0, &opened); + + if (!fp) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a file that could not be opened \""%s\"""", ce->name, fname); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } +after_open_fp: + if (str_key_len >= sizeof("".phar"")-1 && !memcmp(str_key, "".phar"", sizeof("".phar"")-1)) { + /* silently skip any files that would be added to the magic .phar directory */ + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + if (opened) { + efree(opened); + } + + if (close_fp) { + php_stream_close(fp); + } + + return ZEND_HASH_APPLY_KEEP; + } + + if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, str_key, str_key_len, ""w+b"", 0, &error, 1 TSRMLS_CC))) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, ""Entry %s cannot be created: %s"", str_key, error); + efree(error); + + if (save) { + efree(save); + } + + if (opened) { + efree(opened); + } + + if (temp) { + efree(temp); + } + + if (close_fp) { + php_stream_close(fp); + } + + return ZEND_HASH_APPLY_STOP; + + } else { + if (error) { + efree(error); + } + /* convert to PHAR_UFP */ + if (data->internal_file->fp_type == PHAR_MOD) { + php_stream_close(data->internal_file->fp); + } + + data->internal_file->fp = NULL; + data->internal_file->fp_type = PHAR_UFP; + data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp); + data->fp = NULL; + phar_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len); + data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize = + php_stream_tell(p_obj->fp) - data->internal_file->offset; + } + + if (close_fp) { + php_stream_close(fp); + } + + add_assoc_string(p_obj->ret, str_key, opened, 0); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len; + phar_entry_delref(data TSRMLS_CC); + + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ +",1,"static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */ +{ + zval **value; + zend_uchar key_type; + zend_bool close_fp = 1; + ulong int_key; + struct _phar_t *p_obj = (struct _phar_t*) puser; + uint str_key_len, base_len = p_obj->l, fname_len; + phar_entry_data *data; + php_stream *fp; + size_t contents_len; + char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, *temp = NULL; + phar_zstr key; + char *str_key; + zend_class_entry *ce = p_obj->c; + phar_archive_object *phar_obj = p_obj->p; + char *str = ""[stream]""; + + iter->funcs->get_current_data(iter, &value TSRMLS_CC); + + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + + if (!value) { + /* failure in get_current_data */ + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned no value"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + switch (Z_TYPE_PP(value)) { +#if PHP_VERSION_ID >= 60000 + case IS_UNICODE: + zval_unicode_to_string(*(value) TSRMLS_CC); + /* break intentionally omitted */ +#endif + case IS_STRING: + break; + case IS_RESOURCE: + php_stream_from_zval_no_verify(fp, value); + + if (!fp) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, ""Iterator %v returned an invalid stream handle"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + if (iter->funcs->get_current_key) { + key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC); + + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + + if (key_type == HASH_KEY_IS_LONG) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + if (key_type > 9) { /* IS_UNICODE == 10 */ +#if PHP_VERSION_ID < 60000 +/* this can never happen, but fixes a compile warning */ + spprintf(&str_key, 0, ""%s"", key); +#else + spprintf(&str_key, 0, ""%v"", key); + ezfree(key); +#endif + } else { + PHAR_STR(key, str_key); + } + + save = str_key; + + if (str_key[str_key_len - 1] == '\0') { + str_key_len--; + } + + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + close_fp = 0; + opened = (char *) estrndup(str, sizeof(""[stream]"") - 1); + goto after_open_fp; + case IS_OBJECT: + if (instanceof_function(Z_OBJCE_PP(value), spl_ce_SplFileInfo TSRMLS_CC)) { + char *test = NULL; + zval dummy; + spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(*value TSRMLS_CC); + + if (!base_len) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, ""Iterator %v returns an SplFileInfo object, so base directory must be specified"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + switch (intern->type) { + case SPL_FS_DIR: +#if PHP_VERSION_ID >= 60000 + test = spl_filesystem_object_get_path(intern, NULL, NULL TSRMLS_CC).s; +#elif PHP_VERSION_ID >= 50300 + test = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC); +#else + test = intern->path; +#endif + fname_len = spprintf(&fname, 0, ""%s%c%s"", test, DEFAULT_SLASH, intern->u.dir.entry.d_name); + php_stat(fname, fname_len, FS_IS_DIR, &dummy TSRMLS_CC); + + if (Z_BVAL(dummy)) { + /* ignore directories */ + efree(fname); + return ZEND_HASH_APPLY_KEEP; + } + + test = expand_filepath(fname, NULL TSRMLS_CC); + efree(fname); + + if (test) { + fname = test; + fname_len = strlen(fname); + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Could not resolve file path""); + return ZEND_HASH_APPLY_STOP; + } + + save = fname; + goto phar_spl_fileinfo; + case SPL_FS_INFO: + case SPL_FS_FILE: +#if PHP_VERSION_ID >= 60000 + if (intern->file_name_type == IS_UNICODE) { + zval zv; + + INIT_ZVAL(zv); + Z_UNIVAL(zv) = intern->file_name; + Z_UNILEN(zv) = intern->file_name_len; + Z_TYPE(zv) = IS_UNICODE; + + zval_copy_ctor(&zv); + zval_unicode_to_string(&zv TSRMLS_CC); + fname = expand_filepath(Z_STRVAL(zv), NULL TSRMLS_CC); + ezfree(Z_UNIVAL(zv)); + } else { + fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC); + } +#else + fname = expand_filepath(intern->file_name, NULL TSRMLS_CC); +#endif + if (!fname) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Could not resolve file path""); + return ZEND_HASH_APPLY_STOP; + } + + fname_len = strlen(fname); + save = fname; + goto phar_spl_fileinfo; + } + } + /* fall-through */ + default: + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid value (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + fname = Z_STRVAL_PP(value); + fname_len = Z_STRLEN_PP(value); + +phar_spl_fileinfo: + if (base_len) { + temp = expand_filepath(base, NULL TSRMLS_CC); + if (!temp) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Could not resolve file path""); + if (save) { + efree(save); + } + return ZEND_HASH_APPLY_STOP; + } + + base = temp; + base_len = strlen(base); + + if (strstr(fname, base)) { + str_key_len = fname_len - base_len; + + if (str_key_len <= 0) { + if (save) { + efree(save); + efree(temp); + } + return ZEND_HASH_APPLY_KEEP; + } + + str_key = fname + base_len; + + if (*str_key == '/' || *str_key == '\\') { + str_key++; + str_key_len--; + } + + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a path \""%s\"" that is not in the base directory \""%s\"""", ce->name, fname, base); + + if (save) { + efree(save); + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } + } else { + if (iter->funcs->get_current_key) { + key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC); + + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + + if (key_type == HASH_KEY_IS_LONG) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + + if (key_type > 9) { /* IS_UNICODE == 10 */ +#if PHP_VERSION_ID < 60000 +/* this can never happen, but fixes a compile warning */ + spprintf(&str_key, 0, ""%s"", key); +#else + spprintf(&str_key, 0, ""%v"", key); + ezfree(key); +#endif + } else { + PHAR_STR(key, str_key); + } + + save = str_key; + + if (str_key[str_key_len - 1] == '\0') str_key_len--; + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned an invalid key (must return a string)"", ce->name); + return ZEND_HASH_APPLY_STOP; + } + } +#if PHP_API_VERSION < 20100412 + if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a path \""%s\"" that safe mode prevents opening"", ce->name, fname); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } +#endif + + if (php_check_open_basedir(fname TSRMLS_CC)) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a path \""%s\"" that open_basedir prevents opening"", ce->name, fname); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } + + /* try to open source file, then create internal phar file and copy contents */ + fp = php_stream_open_wrapper(fname, ""rb"", STREAM_MUST_SEEK|0, &opened); + + if (!fp) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, ""Iterator %v returned a file that could not be opened \""%s\"""", ce->name, fname); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + return ZEND_HASH_APPLY_STOP; + } +after_open_fp: + if (str_key_len >= sizeof("".phar"")-1 && !memcmp(str_key, "".phar"", sizeof("".phar"")-1)) { + /* silently skip any files that would be added to the magic .phar directory */ + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + if (opened) { + efree(opened); + } + + if (close_fp) { + php_stream_close(fp); + } + + return ZEND_HASH_APPLY_KEEP; + } + + if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, str_key, str_key_len, ""w+b"", 0, &error, 1 TSRMLS_CC))) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, ""Entry %s cannot be created: %s"", str_key, error); + efree(error); + + if (save) { + efree(save); + } + + if (opened) { + efree(opened); + } + + if (temp) { + efree(temp); + } + + if (close_fp) { + php_stream_close(fp); + } + + return ZEND_HASH_APPLY_STOP; + + } else { + if (error) { + efree(error); + } + /* convert to PHAR_UFP */ + if (data->internal_file->fp_type == PHAR_MOD) { + php_stream_close(data->internal_file->fp); + } + + data->internal_file->fp = NULL; + data->internal_file->fp_type = PHAR_UFP; + data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp); + data->fp = NULL; + phar_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len); + data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize = + php_stream_tell(p_obj->fp) - data->internal_file->offset; + } + + if (close_fp) { + php_stream_close(fp); + } + + add_assoc_string(p_obj->ret, str_key, opened, 0); + + if (save) { + efree(save); + } + + if (temp) { + efree(temp); + } + + data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len; + phar_entry_delref(data TSRMLS_CC); + + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ +","@@ -1269,7 +1269,7 @@ PHP_METHOD(Phar, __construct) + INIT_PZVAL(&arg2); + ZVAL_LONG(&arg2, flags); + +- zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj), ++ zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj), + &spl_ce_RecursiveDirectoryIterator->constructor, ""__construct"", NULL, &arg1, &arg2); + + if (!phar_data->is_persistent) { +@@ -1293,7 +1293,7 @@ PHP_METHOD(Phar, getSupportedSignatures) + if (zend_parse_parameters_none() == FAILURE) { + return; + } +- ++ + array_init(return_value); + + add_next_index_stringl(return_value, ""MD5"", 3, 1); +@@ -1320,7 +1320,7 @@ PHP_METHOD(Phar, getSupportedCompression) + if (zend_parse_parameters_none() == FAILURE) { + return; + } +- ++ + array_init(return_value); + phar_request_initialize(TSRMLS_C); + +@@ -1608,7 +1608,7 @@ phar_spl_fileinfo: + } + return ZEND_HASH_APPLY_STOP; + } +- ++ + base = temp; + base_len = strlen(base); + +@@ -1805,7 +1805,7 @@ after_open_fp: + /* {{{ proto array Phar::buildFromDirectory(string base_dir[, string regex]) + * Construct a phar archive from an existing directory, recursively. + * Optional second parameter is a regular expression for filtering directory contents. +- * ++ * + * Return value is an array mapping phar index to actual files added. + */ + PHP_METHOD(Phar, buildFromDirectory) +@@ -1845,7 +1845,7 @@ PHP_METHOD(Phar, buildFromDirectory) + ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS); + #endif + +- zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator, ++ zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator, + &spl_ce_RecursiveDirectoryIterator->constructor, ""__construct"", NULL, &arg, &arg2); + + if (EG(exception)) { +@@ -1862,7 +1862,7 @@ PHP_METHOD(Phar, buildFromDirectory) + RETURN_FALSE; + } + +- zend_call_method_with_1_params(&iteriter, spl_ce_RecursiveIteratorIterator, ++ zend_call_method_with_1_params(&iteriter, spl_ce_RecursiveIteratorIterator, + &spl_ce_RecursiveIteratorIterator->constructor, ""__construct"", NULL, iter); + + if (EG(exception)) { +@@ -1887,7 +1887,7 @@ PHP_METHOD(Phar, buildFromDirectory) + INIT_PZVAL(&arg2); + ZVAL_STRINGL(&arg2, regex, regex_len, 0); + +- zend_call_method_with_2_params(®exiter, spl_ce_RegexIterator, ++ zend_call_method_with_2_params(®exiter, spl_ce_RegexIterator, + &spl_ce_RegexIterator->constructor, ""__construct"", NULL, iteriter, &arg2); + } + +@@ -2008,7 +2008,7 @@ PHP_METHOD(Phar, buildFromIterator) + PHP_METHOD(Phar, count) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2173,7 +2173,7 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c + spprintf(&newname, 0, ""%s.%s"", strtok(basename, "".""), ext); + efree(basename); + +- ++ + + basepath = estrndup(oldpath, (strlen(oldpath) - oldname_len)); + phar->fname_len = spprintf(&newpath, 0, ""%s%s"", basepath, newname); +@@ -2419,7 +2419,9 @@ no_copy: + zend_hash_destroy(&(phar->manifest)); + zend_hash_destroy(&(phar->mounted_dirs)); + zend_hash_destroy(&(phar->virtual_dirs)); +- php_stream_close(phar->fp); ++ if (phar->fp) { ++ php_stream_close(phar->fp); ++ } + efree(phar->fname); + efree(phar); + return NULL; +@@ -2639,7 +2641,7 @@ PHP_METHOD(Phar, convertToData) + PHP_METHOD(Phar, isCompressed) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2663,7 +2665,7 @@ PHP_METHOD(Phar, isWritable) + { + php_stream_statbuf ssb; + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2741,7 +2743,7 @@ PHP_METHOD(Phar, delete) + PHP_METHOD(Phar, getAlias) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2758,7 +2760,7 @@ PHP_METHOD(Phar, getAlias) + PHP_METHOD(Phar, getPath) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2874,7 +2876,7 @@ valid_alias: + PHP_METHOD(Phar, getVersion) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2889,7 +2891,7 @@ PHP_METHOD(Phar, getVersion) + PHP_METHOD(Phar, startBuffering) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2904,7 +2906,7 @@ PHP_METHOD(Phar, startBuffering) + PHP_METHOD(Phar, isBuffering) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -2921,7 +2923,7 @@ PHP_METHOD(Phar, stopBuffering) + char *error; + + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -3156,7 +3158,7 @@ PHP_METHOD(Phar, setSignatureAlgorithm) + PHP_METHOD(Phar, getSignature) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -3200,7 +3202,7 @@ PHP_METHOD(Phar, getSignature) + PHP_METHOD(Phar, getModified) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -3462,7 +3464,7 @@ PHP_METHOD(Phar, decompressFiles) + { + char *error; + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -3983,7 +3985,7 @@ PHP_METHOD(Phar, getStub) + phar_entry_info *stub; + + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4086,7 +4088,7 @@ PHP_METHOD(Phar, hasMetadata) + PHP_METHOD(Phar, getMetadata) + { + PHAR_ARCHIVE_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4544,7 +4546,7 @@ PHP_METHOD(PharFileInfo, __construct) + INIT_PZVAL(&arg1); + ZVAL_STRINGL(&arg1, fname, fname_len, 0); + +- zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj), ++ zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj), + &spl_ce_SplFileInfo->constructor, ""__construct"", NULL, &arg1); + } + /* }}} */ +@@ -4582,7 +4584,7 @@ PHP_METHOD(PharFileInfo, __destruct) + PHP_METHOD(PharFileInfo, getCompressedSize) + { + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4624,7 +4626,7 @@ PHP_METHOD(PharFileInfo, isCompressed) + PHP_METHOD(PharFileInfo, getCRC32) + { + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4650,7 +4652,7 @@ PHP_METHOD(PharFileInfo, getCRC32) + PHP_METHOD(PharFileInfo, isCRCChecked) + { + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4665,7 +4667,7 @@ PHP_METHOD(PharFileInfo, isCRCChecked) + PHP_METHOD(PharFileInfo, getPharFlags) + { + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4743,7 +4745,7 @@ PHP_METHOD(PharFileInfo, chmod) + PHP_METHOD(PharFileInfo, hasMetadata) + { + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4758,7 +4760,7 @@ PHP_METHOD(PharFileInfo, hasMetadata) + PHP_METHOD(PharFileInfo, getMetadata) + { + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4839,7 +4841,7 @@ PHP_METHOD(PharFileInfo, delMetadata) + char *error; + + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -4897,7 +4899,7 @@ PHP_METHOD(PharFileInfo, getContent) + phar_entry_info *link; + + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + } +@@ -5071,7 +5073,7 @@ PHP_METHOD(PharFileInfo, decompress) + { + char *error; + PHAR_ENTRY_OBJECT(); +- ++ + if (zend_parse_parameters_none() == FAILURE) { + return; + }",2933,3169,4096 +9633,"static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp) +{ + SCEnter(); + + AppLayerProtoDetectProbingParserPort *pp_port = NULL; + AppLayerProtoDetectProbingParserElement *pp_pe = NULL; + + printf(""\nProtocol Detection Configuration\n""); + + for ( ; pp != NULL; pp = pp->next) { + /* print ip protocol */ + if (pp->ipproto == IPPROTO_TCP) + printf(""IPProto: TCP\n""); + else if (pp->ipproto == IPPROTO_UDP) + printf(""IPProto: UDP\n""); + else + printf(""IPProto: %""PRIu8""\n"", pp->ipproto); + + pp_port = pp->port; + for ( ; pp_port != NULL; pp_port = pp_port->next) { + if (pp_port->dp != NULL) { + printf("" Port: %""PRIu16 ""\n"", pp_port->port); + + printf("" Destination port: (max-depth: %""PRIu16 "", "" + ""mask - %""PRIu32"")\n"", + pp_port->dp_max_depth, + pp_port->alproto_mask); + pp_pe = pp_port->dp; + for ( ; pp_pe != NULL; pp_pe = pp_pe->next) { + + if (pp_pe->alproto == ALPROTO_HTTP) + printf("" alproto: ALPROTO_HTTP\n""); + else if (pp_pe->alproto == ALPROTO_FTP) + printf("" alproto: ALPROTO_FTP\n""); + else if (pp_pe->alproto == ALPROTO_FTPDATA) + printf("" alproto: ALPROTO_FTPDATA\n""); + else if (pp_pe->alproto == ALPROTO_SMTP) + printf("" alproto: ALPROTO_SMTP\n""); + else if (pp_pe->alproto == ALPROTO_TLS) + printf("" alproto: ALPROTO_TLS\n""); + else if (pp_pe->alproto == ALPROTO_SSH) + printf("" alproto: ALPROTO_SSH\n""); + else if (pp_pe->alproto == ALPROTO_IMAP) + printf("" alproto: ALPROTO_IMAP\n""); + else if (pp_pe->alproto == ALPROTO_MSN) + printf("" alproto: ALPROTO_MSN\n""); + else if (pp_pe->alproto == ALPROTO_JABBER) + printf("" alproto: ALPROTO_JABBER\n""); + else if (pp_pe->alproto == ALPROTO_SMB) + printf("" alproto: ALPROTO_SMB\n""); + else if (pp_pe->alproto == ALPROTO_SMB2) + printf("" alproto: ALPROTO_SMB2\n""); + else if (pp_pe->alproto == ALPROTO_DCERPC) + printf("" alproto: ALPROTO_DCERPC\n""); + else if (pp_pe->alproto == ALPROTO_IRC) + printf("" alproto: ALPROTO_IRC\n""); + else if (pp_pe->alproto == ALPROTO_DNS) + printf("" alproto: ALPROTO_DNS\n""); + else if (pp_pe->alproto == ALPROTO_MODBUS) + printf("" alproto: ALPROTO_MODBUS\n""); + else if (pp_pe->alproto == ALPROTO_ENIP) + printf("" alproto: ALPROTO_ENIP\n""); + else if (pp_pe->alproto == ALPROTO_NFS) + printf("" alproto: ALPROTO_NFS\n""); + else if (pp_pe->alproto == ALPROTO_NTP) + printf("" alproto: ALPROTO_NTP\n""); + else if (pp_pe->alproto == ALPROTO_TFTP) + printf("" alproto: ALPROTO_TFTP\n""); + else if (pp_pe->alproto == ALPROTO_IKEV2) + printf("" alproto: ALPROTO_IKEV2\n""); + else if (pp_pe->alproto == ALPROTO_KRB5) + printf("" alproto: ALPROTO_KRB5\n""); + else if (pp_pe->alproto == ALPROTO_DHCP) + printf("" alproto: ALPROTO_DHCP\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST) + printf("" alproto: ALPROTO_TEMPLATE_RUST\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE) + printf("" alproto: ALPROTO_TEMPLATE\n""); + else if (pp_pe->alproto == ALPROTO_DNP3) + printf("" alproto: ALPROTO_DNP3\n""); + else + printf(""impossible\n""); + + printf("" port: %""PRIu16 ""\n"", pp_pe->port); + printf("" mask: %""PRIu32 ""\n"", pp_pe->alproto_mask); + printf("" min_depth: %""PRIu32 ""\n"", pp_pe->min_depth); + printf("" max_depth: %""PRIu32 ""\n"", pp_pe->max_depth); + + printf(""\n""); + } + } + + if (pp_port->sp == NULL) { + continue; + } + + printf("" Source port: (max-depth: %""PRIu16 "", "" + ""mask - %""PRIu32"")\n"", + pp_port->sp_max_depth, + pp_port->alproto_mask); + pp_pe = pp_port->sp; + for ( ; pp_pe != NULL; pp_pe = pp_pe->next) { + + if (pp_pe->alproto == ALPROTO_HTTP) + printf("" alproto: ALPROTO_HTTP\n""); + else if (pp_pe->alproto == ALPROTO_FTP) + printf("" alproto: ALPROTO_FTP\n""); + else if (pp_pe->alproto == ALPROTO_FTPDATA) + printf("" alproto: ALPROTO_FTPDATA\n""); + else if (pp_pe->alproto == ALPROTO_SMTP) + printf("" alproto: ALPROTO_SMTP\n""); + else if (pp_pe->alproto == ALPROTO_TLS) + printf("" alproto: ALPROTO_TLS\n""); + else if (pp_pe->alproto == ALPROTO_SSH) + printf("" alproto: ALPROTO_SSH\n""); + else if (pp_pe->alproto == ALPROTO_IMAP) + printf("" alproto: ALPROTO_IMAP\n""); + else if (pp_pe->alproto == ALPROTO_MSN) + printf("" alproto: ALPROTO_MSN\n""); + else if (pp_pe->alproto == ALPROTO_JABBER) + printf("" alproto: ALPROTO_JABBER\n""); + else if (pp_pe->alproto == ALPROTO_SMB) + printf("" alproto: ALPROTO_SMB\n""); + else if (pp_pe->alproto == ALPROTO_SMB2) + printf("" alproto: ALPROTO_SMB2\n""); + else if (pp_pe->alproto == ALPROTO_DCERPC) + printf("" alproto: ALPROTO_DCERPC\n""); + else if (pp_pe->alproto == ALPROTO_IRC) + printf("" alproto: ALPROTO_IRC\n""); + else if (pp_pe->alproto == ALPROTO_DNS) + printf("" alproto: ALPROTO_DNS\n""); + else if (pp_pe->alproto == ALPROTO_MODBUS) + printf("" alproto: ALPROTO_MODBUS\n""); + else if (pp_pe->alproto == ALPROTO_ENIP) + printf("" alproto: ALPROTO_ENIP\n""); + else if (pp_pe->alproto == ALPROTO_NFS) + printf("" alproto: ALPROTO_NFS\n""); + else if (pp_pe->alproto == ALPROTO_NTP) + printf("" alproto: ALPROTO_NTP\n""); + else if (pp_pe->alproto == ALPROTO_TFTP) + printf("" alproto: ALPROTO_TFTP\n""); + else if (pp_pe->alproto == ALPROTO_IKEV2) + printf("" alproto: ALPROTO_IKEV2\n""); + else if (pp_pe->alproto == ALPROTO_KRB5) + printf("" alproto: ALPROTO_KRB5\n""); + else if (pp_pe->alproto == ALPROTO_DHCP) + printf("" alproto: ALPROTO_DHCP\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST) + printf("" alproto: ALPROTO_TEMPLATE_RUST\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE) + printf("" alproto: ALPROTO_TEMPLATE\n""); + else if (pp_pe->alproto == ALPROTO_DNP3) + printf("" alproto: ALPROTO_DNP3\n""); + else + printf(""impossible\n""); + + printf("" port: %""PRIu16 ""\n"", pp_pe->port); + printf("" mask: %""PRIu32 ""\n"", pp_pe->alproto_mask); + printf("" min_depth: %""PRIu32 ""\n"", pp_pe->min_depth); + printf("" max_depth: %""PRIu32 ""\n"", pp_pe->max_depth); + + printf(""\n""); + } + } + } + + SCReturn; +} +",0,"static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp) +{ + SCEnter(); + + AppLayerProtoDetectProbingParserPort *pp_port = NULL; + AppLayerProtoDetectProbingParserElement *pp_pe = NULL; + + printf(""\nProtocol Detection Configuration\n""); + + for ( ; pp != NULL; pp = pp->next) { + /* print ip protocol */ + if (pp->ipproto == IPPROTO_TCP) + printf(""IPProto: TCP\n""); + else if (pp->ipproto == IPPROTO_UDP) + printf(""IPProto: UDP\n""); + else + printf(""IPProto: %""PRIu8""\n"", pp->ipproto); + + pp_port = pp->port; + for ( ; pp_port != NULL; pp_port = pp_port->next) { + if (pp_port->dp != NULL) { + printf("" Port: %""PRIu16 ""\n"", pp_port->port); + + printf("" Destination port: (max-depth: %""PRIu16 "", "" + ""mask - %""PRIu32"")\n"", + pp_port->dp_max_depth, + pp_port->alproto_mask); + pp_pe = pp_port->dp; + for ( ; pp_pe != NULL; pp_pe = pp_pe->next) { + + if (pp_pe->alproto == ALPROTO_HTTP) + printf("" alproto: ALPROTO_HTTP\n""); + else if (pp_pe->alproto == ALPROTO_FTP) + printf("" alproto: ALPROTO_FTP\n""); + else if (pp_pe->alproto == ALPROTO_FTPDATA) + printf("" alproto: ALPROTO_FTPDATA\n""); + else if (pp_pe->alproto == ALPROTO_SMTP) + printf("" alproto: ALPROTO_SMTP\n""); + else if (pp_pe->alproto == ALPROTO_TLS) + printf("" alproto: ALPROTO_TLS\n""); + else if (pp_pe->alproto == ALPROTO_SSH) + printf("" alproto: ALPROTO_SSH\n""); + else if (pp_pe->alproto == ALPROTO_IMAP) + printf("" alproto: ALPROTO_IMAP\n""); + else if (pp_pe->alproto == ALPROTO_MSN) + printf("" alproto: ALPROTO_MSN\n""); + else if (pp_pe->alproto == ALPROTO_JABBER) + printf("" alproto: ALPROTO_JABBER\n""); + else if (pp_pe->alproto == ALPROTO_SMB) + printf("" alproto: ALPROTO_SMB\n""); + else if (pp_pe->alproto == ALPROTO_SMB2) + printf("" alproto: ALPROTO_SMB2\n""); + else if (pp_pe->alproto == ALPROTO_DCERPC) + printf("" alproto: ALPROTO_DCERPC\n""); + else if (pp_pe->alproto == ALPROTO_IRC) + printf("" alproto: ALPROTO_IRC\n""); + else if (pp_pe->alproto == ALPROTO_DNS) + printf("" alproto: ALPROTO_DNS\n""); + else if (pp_pe->alproto == ALPROTO_MODBUS) + printf("" alproto: ALPROTO_MODBUS\n""); + else if (pp_pe->alproto == ALPROTO_ENIP) + printf("" alproto: ALPROTO_ENIP\n""); + else if (pp_pe->alproto == ALPROTO_NFS) + printf("" alproto: ALPROTO_NFS\n""); + else if (pp_pe->alproto == ALPROTO_NTP) + printf("" alproto: ALPROTO_NTP\n""); + else if (pp_pe->alproto == ALPROTO_TFTP) + printf("" alproto: ALPROTO_TFTP\n""); + else if (pp_pe->alproto == ALPROTO_IKEV2) + printf("" alproto: ALPROTO_IKEV2\n""); + else if (pp_pe->alproto == ALPROTO_KRB5) + printf("" alproto: ALPROTO_KRB5\n""); + else if (pp_pe->alproto == ALPROTO_DHCP) + printf("" alproto: ALPROTO_DHCP\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST) + printf("" alproto: ALPROTO_TEMPLATE_RUST\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE) + printf("" alproto: ALPROTO_TEMPLATE\n""); + else if (pp_pe->alproto == ALPROTO_DNP3) + printf("" alproto: ALPROTO_DNP3\n""); + else + printf(""impossible\n""); + + printf("" port: %""PRIu16 ""\n"", pp_pe->port); + printf("" mask: %""PRIu32 ""\n"", pp_pe->alproto_mask); + printf("" min_depth: %""PRIu32 ""\n"", pp_pe->min_depth); + printf("" max_depth: %""PRIu32 ""\n"", pp_pe->max_depth); + + printf(""\n""); + } + } + + if (pp_port->sp == NULL) { + continue; + } + + printf("" Source port: (max-depth: %""PRIu16 "", "" + ""mask - %""PRIu32"")\n"", + pp_port->sp_max_depth, + pp_port->alproto_mask); + pp_pe = pp_port->sp; + for ( ; pp_pe != NULL; pp_pe = pp_pe->next) { + + if (pp_pe->alproto == ALPROTO_HTTP) + printf("" alproto: ALPROTO_HTTP\n""); + else if (pp_pe->alproto == ALPROTO_FTP) + printf("" alproto: ALPROTO_FTP\n""); + else if (pp_pe->alproto == ALPROTO_FTPDATA) + printf("" alproto: ALPROTO_FTPDATA\n""); + else if (pp_pe->alproto == ALPROTO_SMTP) + printf("" alproto: ALPROTO_SMTP\n""); + else if (pp_pe->alproto == ALPROTO_TLS) + printf("" alproto: ALPROTO_TLS\n""); + else if (pp_pe->alproto == ALPROTO_SSH) + printf("" alproto: ALPROTO_SSH\n""); + else if (pp_pe->alproto == ALPROTO_IMAP) + printf("" alproto: ALPROTO_IMAP\n""); + else if (pp_pe->alproto == ALPROTO_MSN) + printf("" alproto: ALPROTO_MSN\n""); + else if (pp_pe->alproto == ALPROTO_JABBER) + printf("" alproto: ALPROTO_JABBER\n""); + else if (pp_pe->alproto == ALPROTO_SMB) + printf("" alproto: ALPROTO_SMB\n""); + else if (pp_pe->alproto == ALPROTO_SMB2) + printf("" alproto: ALPROTO_SMB2\n""); + else if (pp_pe->alproto == ALPROTO_DCERPC) + printf("" alproto: ALPROTO_DCERPC\n""); + else if (pp_pe->alproto == ALPROTO_IRC) + printf("" alproto: ALPROTO_IRC\n""); + else if (pp_pe->alproto == ALPROTO_DNS) + printf("" alproto: ALPROTO_DNS\n""); + else if (pp_pe->alproto == ALPROTO_MODBUS) + printf("" alproto: ALPROTO_MODBUS\n""); + else if (pp_pe->alproto == ALPROTO_ENIP) + printf("" alproto: ALPROTO_ENIP\n""); + else if (pp_pe->alproto == ALPROTO_NFS) + printf("" alproto: ALPROTO_NFS\n""); + else if (pp_pe->alproto == ALPROTO_NTP) + printf("" alproto: ALPROTO_NTP\n""); + else if (pp_pe->alproto == ALPROTO_TFTP) + printf("" alproto: ALPROTO_TFTP\n""); + else if (pp_pe->alproto == ALPROTO_IKEV2) + printf("" alproto: ALPROTO_IKEV2\n""); + else if (pp_pe->alproto == ALPROTO_KRB5) + printf("" alproto: ALPROTO_KRB5\n""); + else if (pp_pe->alproto == ALPROTO_DHCP) + printf("" alproto: ALPROTO_DHCP\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST) + printf("" alproto: ALPROTO_TEMPLATE_RUST\n""); + else if (pp_pe->alproto == ALPROTO_TEMPLATE) + printf("" alproto: ALPROTO_TEMPLATE\n""); + else if (pp_pe->alproto == ALPROTO_DNP3) + printf("" alproto: ALPROTO_DNP3\n""); + else + printf(""impossible\n""); + + printf("" port: %""PRIu16 ""\n"", pp_pe->port); + printf("" mask: %""PRIu32 ""\n"", pp_pe->alproto_mask); + printf("" min_depth: %""PRIu32 ""\n"", pp_pe->min_depth); + printf("" max_depth: %""PRIu32 ""\n"", pp_pe->max_depth); + + printf(""\n""); + } + } + } + + SCReturn; +} +","@@ -1361,6 +1361,7 @@ AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx, + (direction & STREAM_TOSERVER) ? ""toserver"" : ""toclient""); + + AppProto alproto = ALPROTO_UNKNOWN; ++ AppProto pm_alproto = ALPROTO_UNKNOWN; + + if (!FLOW_IS_PM_DONE(f, direction)) { + AppProto pm_results[ALPROTO_MAX]; +@@ -1371,7 +1372,15 @@ AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx, + pm_results); + if (pm_matches > 0) { + alproto = pm_results[0]; +- goto end; ++ ++ /* HACK: if detected protocol is dcerpc/udp, we run PP as well ++ * to avoid misdetecting DNS as DCERPC. */ ++ if (!(ipproto == IPPROTO_UDP && alproto == ALPROTO_DCERPC)) ++ goto end; ++ ++ pm_alproto = alproto; ++ ++ /* fall through */ + } + } + +@@ -1388,6 +1397,9 @@ AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx, + } + + end: ++ if (alproto == ALPROTO_UNKNOWN) ++ alproto = pm_alproto; ++ + SCReturnUInt(alproto); + } + ",2000,2236,4096 +17867,"static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) +{ + AVIOContext *pb = s->pb; + APEContext *ape = s->priv_data; + AVStream *st; + uint32_t tag; + int i; + int total_blocks; + int64_t pts; + + /* TODO: Skip any leading junk such as id3v2 tags */ + ape->junklength = 0; + + tag = avio_rl32(pb); + if (tag != MKTAG('M', 'A', 'C', ' ')) + return -1; + + ape->fileversion = avio_rl16(pb); + + if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) { + av_log(s, AV_LOG_ERROR, ""Unsupported file version - %d.%02d\n"", ape->fileversion / 1000, (ape->fileversion % 1000) / 10); + return -1; + } + + if (ape->fileversion >= 3980) { + ape->padding1 = avio_rl16(pb); + ape->descriptorlength = avio_rl32(pb); + ape->headerlength = avio_rl32(pb); + ape->seektablelength = avio_rl32(pb); + ape->wavheaderlength = avio_rl32(pb); + ape->audiodatalength = avio_rl32(pb); + ape->audiodatalength_high = avio_rl32(pb); + ape->wavtaillength = avio_rl32(pb); + avio_read(pb, ape->md5, 16); + + /* Skip any unknown bytes at the end of the descriptor. + This is for future compatibility */ + if (ape->descriptorlength > 52) + avio_seek(pb, ape->descriptorlength - 52, SEEK_CUR); + + /* Read header data */ + ape->compressiontype = avio_rl16(pb); + ape->formatflags = avio_rl16(pb); + ape->blocksperframe = avio_rl32(pb); + ape->finalframeblocks = avio_rl32(pb); + ape->totalframes = avio_rl32(pb); + ape->bps = avio_rl16(pb); + ape->channels = avio_rl16(pb); + ape->samplerate = avio_rl32(pb); + } else { + ape->descriptorlength = 0; + ape->headerlength = 32; + + ape->compressiontype = avio_rl16(pb); + ape->formatflags = avio_rl16(pb); + ape->channels = avio_rl16(pb); + ape->samplerate = avio_rl32(pb); + ape->wavheaderlength = avio_rl32(pb); + ape->wavtaillength = avio_rl32(pb); + ape->totalframes = avio_rl32(pb); + ape->finalframeblocks = avio_rl32(pb); + + if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) { + avio_seek(pb, 4, SEEK_CUR); /* Skip the peak level */ + ape->headerlength += 4; + } + + if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) { + ape->seektablelength = avio_rl32(pb); + ape->headerlength += 4; + ape->seektablelength *= sizeof(int32_t); + } else + ape->seektablelength = ape->totalframes * sizeof(int32_t); + + if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT) + ape->bps = 8; + else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT) + ape->bps = 24; + else + ape->bps = 16; + + if (ape->fileversion >= 3950) + ape->blocksperframe = 73728 * 4; + else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000)) + ape->blocksperframe = 73728; + else + ape->blocksperframe = 9216; + + /* Skip any stored wav header */ + if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER)) + avio_seek(pb, ape->wavheaderlength, SEEK_CUR); + } + + if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){ + av_log(s, AV_LOG_ERROR, ""Too many frames: %d\n"", ape->totalframes); + return -1; + } + ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame)); + if(!ape->frames) + return AVERROR(ENOMEM); + ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength; + ape->currentframe = 0; + + + ape->totalsamples = ape->finalframeblocks; + if (ape->totalframes > 1) + ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1); + + if (ape->seektablelength > 0) { + ape->seektable = av_malloc(ape->seektablelength); + for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++) + ape->seektable[i] = avio_rl32(pb); + } + + ape->frames[0].pos = ape->firstframe; + ape->frames[0].nblocks = ape->blocksperframe; + ape->frames[0].skip = 0; + for (i = 1; i < ape->totalframes; i++) { + ape->frames[i].pos = ape->seektable[i]; //ape->frames[i-1].pos + ape->blocksperframe; + ape->frames[i].nblocks = ape->blocksperframe; + ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos; + ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3; + } + ape->frames[ape->totalframes - 1].size = ape->finalframeblocks * 4; + ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks; + + for (i = 0; i < ape->totalframes; i++) { + if(ape->frames[i].skip){ + ape->frames[i].pos -= ape->frames[i].skip; + ape->frames[i].size += ape->frames[i].skip; + } + ape->frames[i].size = (ape->frames[i].size + 3) & ~3; + } + + + ape_dumpinfo(s, ape); + + /* try to read APE tags */ + if (!url_is_streamed(pb)) { + ff_ape_parse_tag(s); + avio_seek(pb, 0, SEEK_SET); + } + + av_log(s, AV_LOG_DEBUG, ""Decoding file - v%d.%02d, compression level %d\n"", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype); + + /* now we are ready: build format streams */ + st = av_new_stream(s, 0); + if (!st) + return -1; + + total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks; + + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_APE; + st->codec->codec_tag = MKTAG('A', 'P', 'E', ' '); + st->codec->channels = ape->channels; + st->codec->sample_rate = ape->samplerate; + st->codec->bits_per_coded_sample = ape->bps; + st->codec->frame_size = MAC_SUBFRAME_SIZE; + + st->nb_frames = ape->totalframes; + st->start_time = 0; + st->duration = total_blocks / MAC_SUBFRAME_SIZE; + av_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate); + + st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE); + st->codec->extradata_size = APE_EXTRADATA_SIZE; + AV_WL16(st->codec->extradata + 0, ape->fileversion); + AV_WL16(st->codec->extradata + 2, ape->compressiontype); + AV_WL16(st->codec->extradata + 4, ape->formatflags); + + pts = 0; + for (i = 0; i < ape->totalframes; i++) { + ape->frames[i].pts = pts; + av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME); + pts += ape->blocksperframe / MAC_SUBFRAME_SIZE; + } + + return 0; +} +",1,"static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) +{ + AVIOContext *pb = s->pb; + APEContext *ape = s->priv_data; + AVStream *st; + uint32_t tag; + int i; + int total_blocks; + int64_t pts; + + /* TODO: Skip any leading junk such as id3v2 tags */ + ape->junklength = 0; + + tag = avio_rl32(pb); + if (tag != MKTAG('M', 'A', 'C', ' ')) + return -1; + + ape->fileversion = avio_rl16(pb); + + if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) { + av_log(s, AV_LOG_ERROR, ""Unsupported file version - %d.%02d\n"", ape->fileversion / 1000, (ape->fileversion % 1000) / 10); + return -1; + } + + if (ape->fileversion >= 3980) { + ape->padding1 = avio_rl16(pb); + ape->descriptorlength = avio_rl32(pb); + ape->headerlength = avio_rl32(pb); + ape->seektablelength = avio_rl32(pb); + ape->wavheaderlength = avio_rl32(pb); + ape->audiodatalength = avio_rl32(pb); + ape->audiodatalength_high = avio_rl32(pb); + ape->wavtaillength = avio_rl32(pb); + avio_read(pb, ape->md5, 16); + + /* Skip any unknown bytes at the end of the descriptor. + This is for future compatibility */ + if (ape->descriptorlength > 52) + avio_seek(pb, ape->descriptorlength - 52, SEEK_CUR); + + /* Read header data */ + ape->compressiontype = avio_rl16(pb); + ape->formatflags = avio_rl16(pb); + ape->blocksperframe = avio_rl32(pb); + ape->finalframeblocks = avio_rl32(pb); + ape->totalframes = avio_rl32(pb); + ape->bps = avio_rl16(pb); + ape->channels = avio_rl16(pb); + ape->samplerate = avio_rl32(pb); + } else { + ape->descriptorlength = 0; + ape->headerlength = 32; + + ape->compressiontype = avio_rl16(pb); + ape->formatflags = avio_rl16(pb); + ape->channels = avio_rl16(pb); + ape->samplerate = avio_rl32(pb); + ape->wavheaderlength = avio_rl32(pb); + ape->wavtaillength = avio_rl32(pb); + ape->totalframes = avio_rl32(pb); + ape->finalframeblocks = avio_rl32(pb); + + if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) { + avio_seek(pb, 4, SEEK_CUR); /* Skip the peak level */ + ape->headerlength += 4; + } + + if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) { + ape->seektablelength = avio_rl32(pb); + ape->headerlength += 4; + ape->seektablelength *= sizeof(int32_t); + } else + ape->seektablelength = ape->totalframes * sizeof(int32_t); + + if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT) + ape->bps = 8; + else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT) + ape->bps = 24; + else + ape->bps = 16; + + if (ape->fileversion >= 3950) + ape->blocksperframe = 73728 * 4; + else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000)) + ape->blocksperframe = 73728; + else + ape->blocksperframe = 9216; + + /* Skip any stored wav header */ + if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER)) + avio_seek(pb, ape->wavheaderlength, SEEK_CUR); + } + + if(!ape->totalframes){ + av_log(s, AV_LOG_ERROR, ""No frames in the file!\n""); + return AVERROR(EINVAL); + } + if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){ + av_log(s, AV_LOG_ERROR, ""Too many frames: %d\n"", ape->totalframes); + return -1; + } + ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame)); + if(!ape->frames) + return AVERROR(ENOMEM); + ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength; + ape->currentframe = 0; + + + ape->totalsamples = ape->finalframeblocks; + if (ape->totalframes > 1) + ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1); + + if (ape->seektablelength > 0) { + ape->seektable = av_malloc(ape->seektablelength); + for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++) + ape->seektable[i] = avio_rl32(pb); + } + + ape->frames[0].pos = ape->firstframe; + ape->frames[0].nblocks = ape->blocksperframe; + ape->frames[0].skip = 0; + for (i = 1; i < ape->totalframes; i++) { + ape->frames[i].pos = ape->seektable[i]; //ape->frames[i-1].pos + ape->blocksperframe; + ape->frames[i].nblocks = ape->blocksperframe; + ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos; + ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3; + } + ape->frames[ape->totalframes - 1].size = ape->finalframeblocks * 4; + ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks; + + for (i = 0; i < ape->totalframes; i++) { + if(ape->frames[i].skip){ + ape->frames[i].pos -= ape->frames[i].skip; + ape->frames[i].size += ape->frames[i].skip; + } + ape->frames[i].size = (ape->frames[i].size + 3) & ~3; + } + + + ape_dumpinfo(s, ape); + + /* try to read APE tags */ + if (!url_is_streamed(pb)) { + ff_ape_parse_tag(s); + avio_seek(pb, 0, SEEK_SET); + } + + av_log(s, AV_LOG_DEBUG, ""Decoding file - v%d.%02d, compression level %d\n"", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype); + + /* now we are ready: build format streams */ + st = av_new_stream(s, 0); + if (!st) + return -1; + + total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks; + + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_APE; + st->codec->codec_tag = MKTAG('A', 'P', 'E', ' '); + st->codec->channels = ape->channels; + st->codec->sample_rate = ape->samplerate; + st->codec->bits_per_coded_sample = ape->bps; + st->codec->frame_size = MAC_SUBFRAME_SIZE; + + st->nb_frames = ape->totalframes; + st->start_time = 0; + st->duration = total_blocks / MAC_SUBFRAME_SIZE; + av_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate); + + st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE); + st->codec->extradata_size = APE_EXTRADATA_SIZE; + AV_WL16(st->codec->extradata + 0, ape->fileversion); + AV_WL16(st->codec->extradata + 2, ape->compressiontype); + AV_WL16(st->codec->extradata + 4, ape->formatflags); + + pts = 0; + for (i = 0; i < ape->totalframes; i++) { + ape->frames[i].pts = pts; + av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME); + pts += ape->blocksperframe / MAC_SUBFRAME_SIZE; + } + + return 0; +} +","@@ -242,6 +242,10 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) + avio_seek(pb, ape->wavheaderlength, SEEK_CUR); + } + ++ if(!ape->totalframes){ ++ av_log(s, AV_LOG_ERROR, ""No frames in the file!\n""); ++ return AVERROR(EINVAL); ++ } + if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){ + av_log(s, AV_LOG_ERROR, ""Too many frames: %d\n"", ape->totalframes); + return -1;",2072,2308,4096 +18723,"xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) { + /* + * URGENT TODO: Normally inst->psvi Should never be reserved here, + * BUT: since if we include the same stylesheet from + * multiple imports, then the stylesheet will be parsed + * again. We simply must not try to compute the stylesheet again. + * TODO: Get to the point where we don't need to query the + * namespace- and local-name of the node, but can evaluate this + * using cctxt->style->inode->category; + */ + if ((inst == NULL) || (inst->type != XML_ELEMENT_NODE) || + (inst->psvi != NULL)) + return; + + if (IS_XSLT_ELEM(inst)) { + xsltStylePreCompPtr cur; + + if (IS_XSLT_NAME(inst, ""apply-templates"")) { + xsltCheckInstructionElement(style, inst); + xsltApplyTemplatesComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""with-param"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""apply-templates"", + BAD_CAST ""call-template""); + xsltWithParamComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""value-of"")) { + xsltCheckInstructionElement(style, inst); + xsltValueOfComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""copy"")) { + xsltCheckInstructionElement(style, inst); + xsltCopyComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""copy-of"")) { + xsltCheckInstructionElement(style, inst); + xsltCopyOfComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""if"")) { + xsltCheckInstructionElement(style, inst); + xsltIfComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""when"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""choose"", NULL); + xsltWhenComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""choose"")) { + xsltCheckInstructionElement(style, inst); + xsltChooseComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""for-each"")) { + xsltCheckInstructionElement(style, inst); + xsltForEachComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""apply-imports"")) { + xsltCheckInstructionElement(style, inst); + xsltApplyImportsComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""attribute"")) { + xmlNodePtr parent = inst->parent; + + if ((parent == NULL) || (parent->ns == NULL) || + ((parent->ns != inst->ns) && + (!xmlStrEqual(parent->ns->href, inst->ns->href))) || + (!xmlStrEqual(parent->name, BAD_CAST ""attribute-set""))) { + xsltCheckInstructionElement(style, inst); + } + xsltAttributeComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""element"")) { + xsltCheckInstructionElement(style, inst); + xsltElementComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""text"")) { + xsltCheckInstructionElement(style, inst); + xsltTextComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""sort"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""apply-templates"", + BAD_CAST ""for-each""); + xsltSortComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""comment"")) { + xsltCheckInstructionElement(style, inst); + xsltCommentComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""number"")) { + xsltCheckInstructionElement(style, inst); + xsltNumberComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""processing-instruction"")) { + xsltCheckInstructionElement(style, inst); + xsltProcessingInstructionComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""call-template"")) { + xsltCheckInstructionElement(style, inst); + xsltCallTemplateComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""param"")) { + if (xsltCheckTopLevelElement(style, inst, 0) == 0) + xsltCheckInstructionElement(style, inst); + xsltParamComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""variable"")) { + if (xsltCheckTopLevelElement(style, inst, 0) == 0) + xsltCheckInstructionElement(style, inst); + xsltVariableComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""otherwise"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""choose"", NULL); + xsltCheckInstructionElement(style, inst); + return; + } else if (IS_XSLT_NAME(inst, ""template"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""output"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""preserve-space"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""strip-space"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if ((IS_XSLT_NAME(inst, ""stylesheet"")) || + (IS_XSLT_NAME(inst, ""transform""))) { + xmlNodePtr parent = inst->parent; + + if ((parent == NULL) || (parent->type != XML_DOCUMENT_NODE)) { + xsltTransformError(NULL, style, inst, + ""element %s only allowed only as root element\n"", + inst->name); + style->errors++; + } + return; + } else if (IS_XSLT_NAME(inst, ""key"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""message"")) { + xsltCheckInstructionElement(style, inst); + return; + } else if (IS_XSLT_NAME(inst, ""attribute-set"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""namespace-alias"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""include"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""import"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""decimal-format"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""fallback"")) { + xsltCheckInstructionElement(style, inst); + return; + } else if (IS_XSLT_NAME(inst, ""document"")) { + xsltCheckInstructionElement(style, inst); + inst->psvi = (void *) xsltDocumentComp(style, inst, + (xsltTransformFunction) xsltDocumentElem); + } else { + xsltTransformError(NULL, style, inst, + ""xsltStylePreCompute: unknown xsl:%s\n"", inst->name); + if (style != NULL) style->warnings++; + } + + cur = (xsltStylePreCompPtr) inst->psvi; + /* + * A ns-list is build for every XSLT item in the + * node-tree. This is needed for XPath expressions. + */ + if (cur != NULL) { + int i = 0; + + cur->nsList = xmlGetNsList(inst->doc, inst); + if (cur->nsList != NULL) { + while (cur->nsList[i] != NULL) + i++; + } + cur->nsNr = i; + } + } else { + inst->psvi = + (void *) xsltPreComputeExtModuleElement(style, inst); + + /* + * Unknown element, maybe registered at the context + * level. Mark it for later recognition. + */ + if (inst->psvi == NULL) + inst->psvi = (void *) xsltExtMarker; + } +} +",1,"xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) { + /* + * URGENT TODO: Normally inst->psvi Should never be reserved here, + * BUT: since if we include the same stylesheet from + * multiple imports, then the stylesheet will be parsed + * again. We simply must not try to compute the stylesheet again. + * TODO: Get to the point where we don't need to query the + * namespace- and local-name of the node, but can evaluate this + * using cctxt->style->inode->category; + */ + if ((inst == NULL) || (inst->type != XML_ELEMENT_NODE) || + (inst->psvi != NULL)) + return; + + if (IS_XSLT_ELEM(inst)) { + xsltStylePreCompPtr cur; + + if (IS_XSLT_NAME(inst, ""apply-templates"")) { + xsltCheckInstructionElement(style, inst); + xsltApplyTemplatesComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""with-param"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""apply-templates"", + BAD_CAST ""call-template""); + xsltWithParamComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""value-of"")) { + xsltCheckInstructionElement(style, inst); + xsltValueOfComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""copy"")) { + xsltCheckInstructionElement(style, inst); + xsltCopyComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""copy-of"")) { + xsltCheckInstructionElement(style, inst); + xsltCopyOfComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""if"")) { + xsltCheckInstructionElement(style, inst); + xsltIfComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""when"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""choose"", NULL); + xsltWhenComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""choose"")) { + xsltCheckInstructionElement(style, inst); + xsltChooseComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""for-each"")) { + xsltCheckInstructionElement(style, inst); + xsltForEachComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""apply-imports"")) { + xsltCheckInstructionElement(style, inst); + xsltApplyImportsComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""attribute"")) { + xmlNodePtr parent = inst->parent; + + if ((parent == NULL) || + (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) || + ((parent->ns != inst->ns) && + (!xmlStrEqual(parent->ns->href, inst->ns->href))) || + (!xmlStrEqual(parent->name, BAD_CAST ""attribute-set""))) { + xsltCheckInstructionElement(style, inst); + } + xsltAttributeComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""element"")) { + xsltCheckInstructionElement(style, inst); + xsltElementComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""text"")) { + xsltCheckInstructionElement(style, inst); + xsltTextComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""sort"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""apply-templates"", + BAD_CAST ""for-each""); + xsltSortComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""comment"")) { + xsltCheckInstructionElement(style, inst); + xsltCommentComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""number"")) { + xsltCheckInstructionElement(style, inst); + xsltNumberComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""processing-instruction"")) { + xsltCheckInstructionElement(style, inst); + xsltProcessingInstructionComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""call-template"")) { + xsltCheckInstructionElement(style, inst); + xsltCallTemplateComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""param"")) { + if (xsltCheckTopLevelElement(style, inst, 0) == 0) + xsltCheckInstructionElement(style, inst); + xsltParamComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""variable"")) { + if (xsltCheckTopLevelElement(style, inst, 0) == 0) + xsltCheckInstructionElement(style, inst); + xsltVariableComp(style, inst); + } else if (IS_XSLT_NAME(inst, ""otherwise"")) { + xsltCheckParentElement(style, inst, BAD_CAST ""choose"", NULL); + xsltCheckInstructionElement(style, inst); + return; + } else if (IS_XSLT_NAME(inst, ""template"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""output"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""preserve-space"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""strip-space"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if ((IS_XSLT_NAME(inst, ""stylesheet"")) || + (IS_XSLT_NAME(inst, ""transform""))) { + xmlNodePtr parent = inst->parent; + + if ((parent == NULL) || (parent->type != XML_DOCUMENT_NODE)) { + xsltTransformError(NULL, style, inst, + ""element %s only allowed only as root element\n"", + inst->name); + style->errors++; + } + return; + } else if (IS_XSLT_NAME(inst, ""key"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""message"")) { + xsltCheckInstructionElement(style, inst); + return; + } else if (IS_XSLT_NAME(inst, ""attribute-set"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""namespace-alias"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""include"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""import"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""decimal-format"")) { + xsltCheckTopLevelElement(style, inst, 1); + return; + } else if (IS_XSLT_NAME(inst, ""fallback"")) { + xsltCheckInstructionElement(style, inst); + return; + } else if (IS_XSLT_NAME(inst, ""document"")) { + xsltCheckInstructionElement(style, inst); + inst->psvi = (void *) xsltDocumentComp(style, inst, + (xsltTransformFunction) xsltDocumentElem); + } else { + xsltTransformError(NULL, style, inst, + ""xsltStylePreCompute: unknown xsl:%s\n"", inst->name); + if (style != NULL) style->warnings++; + } + + cur = (xsltStylePreCompPtr) inst->psvi; + /* + * A ns-list is build for every XSLT item in the + * node-tree. This is needed for XPath expressions. + */ + if (cur != NULL) { + int i = 0; + + cur->nsList = xmlGetNsList(inst->doc, inst); + if (cur->nsList != NULL) { + while (cur->nsList[i] != NULL) + i++; + } + cur->nsNr = i; + } + } else { + inst->psvi = + (void *) xsltPreComputeExtModuleElement(style, inst); + + /* + * Unknown element, maybe registered at the context + * level. Mark it for later recognition. + */ + if (inst->psvi == NULL) + inst->psvi = (void *) xsltExtMarker; + } +} +","@@ -949,6 +949,8 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) { + #ifdef XSLT_REFACTORED + comp->nsPrefix = prefix; + comp->name = name; ++#else ++ (void)name; /* Suppress unused variable warning. */ + #endif + } else if (prefix != NULL) { + xsltTransformError(NULL, style, inst, +@@ -1074,6 +1076,8 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) { + #ifdef XSLT_REFACTORED + comp->nsPrefix = prefix; + comp->name = name; ++#else ++ (void)name; /* Suppress unused variable warning. */ + #endif + } else { + xsltTransformError(NULL, style, inst, +@@ -1301,7 +1305,8 @@ xsltGetQNameProperty(xsltStylesheetPtr style, xmlNodePtr inst, + if (prop == NULL) { + style->errors++; + } else { +- *localName = prop; ++ if (localName) ++ *localName = prop; + if (hasProp) + *hasProp = 1; + if (URI != NULL) { +@@ -2245,7 +2250,8 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) { + } else if (IS_XSLT_NAME(inst, ""attribute"")) { + xmlNodePtr parent = inst->parent; + +- if ((parent == NULL) || (parent->ns == NULL) || ++ if ((parent == NULL) || ++ (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) || + ((parent->ns != inst->ns) && + (!xmlStrEqual(parent->ns->href, inst->ns->href))) || + (!xmlStrEqual(parent->name, BAD_CAST ""attribute-set""))) {",1877,2113,4096 +18373,"void MigrationTest::SetUpVersion74Database() { + sql::Connection connection; + ASSERT_TRUE(connection.Open(GetDatabasePath())); + ASSERT_TRUE(connection.BeginTransaction()); + ASSERT_TRUE(connection.Execute( + ""CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"" + ""INSERT INTO 'share_version' VALUES('nick@chromium.org',74);"" + ""CREATE TABLE models (model_id BLOB primary key, last_download_timestamp"" + "" INT, initial_sync_ended BOOLEAN default 0);"" + ""INSERT INTO 'models' VALUES(X'C2881000',694,1);"" + ""CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"" + ""ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"" + ""fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"" + ""tion_state INT default 0, bookmarks_added_during_autofill_migration"" + "" INT default 0, autofill_migration_time INT default 0, autofill_ent"" + ""ries_added_during_migration INT default 0, autofill_profiles_added_"" + ""during_migration INT default 0);"" + ""INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'"" + "",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542"" + "",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"" + ""CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas"" + ""e_version bigint default -1,server_version bigint default 0,mtime b"" + ""igint default 0,server_mtime bigint default 0,ctime bigint default "" + ""0,server_ctime bigint default 0,server_position_in_parent bigint de"" + ""fault 0,local_external_id bigint default 0,id varchar(255) default "" + ""'r',parent_id varchar(255) default 'r',server_parent_id varchar(255"" + "") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)"" + "" default 'r',is_unsynced bit default 0,is_unapplied_update bit defa"" + ""ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d"" + ""efault 0,server_is_del bit default 0,non_unique_name varchar,server"" + ""_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"" + ""nt_tag varchar,specifics blob,server_specifics blob);"" + ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) + "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"" + ""');"" + ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) + "",-2097152,4,'s_ID_2','s_ID"" + ""_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "" + ""Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"" + ""36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"" + ""6F6F676C652E636F6D2F32120B4153414447414447414447');"" + ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) + "",-3145728,3,'s_ID_4','s_ID"" + ""_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"" + ""elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"" + ""76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"" + ""68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"" + ""F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"" + ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) + "",1048576,7,'s_ID_5','s_ID_"" + ""9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"" + ""LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"" + ""47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"" + ""36F6D2F12084147464447415347');"" + ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) + "",-4194304,6,'s_ID_6','s_ID"" + ""_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"" + "",NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) + "",1048576,0,'s_ID_7','r','r"" + ""','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"" + ""e',NULL,NULL,NULL);"" + ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) + "",1048576,0,'s_ID_8','s_ID_"" + ""7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"" + ""ome_bookmarks',NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) + "",1048576,1,'s_ID_9','s_ID_"" + ""8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"" + "",'bookmark_bar',NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) + "",2097152,2,'s_ID_10','s_I"" + ""D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"" + ""kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) + "",-1048576,8,'s_ID_11','s_"" + ""ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"" + ""ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"" + ""03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"" + ""290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"" + ""84146414756415346');"" + ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) + "",0,9,'s_ID_12','s_ID_6','"" + ""s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"" + ""okmarks',NULL,NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) + "",-917504,10,'s_ID_13','s_"" + ""ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"" + ""rporation for Assigned Names and Numbers','ICANN | Internet Corpora"" + ""tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"" + ""703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"" + ""28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"" + ""5346');"" + ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) + "",1048576,11,'s_ID_14','s_"" + ""ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"" + ""oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"" + ""474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"" + ""703A2F2F7765626B69742E6F72672F781205504E473259');"" + )); + ASSERT_TRUE(connection.CommitTransaction()); +} +",1,"void MigrationTest::SetUpVersion74Database() { + sql::Connection connection; + ASSERT_TRUE(connection.Open(GetDatabasePath())); + ASSERT_TRUE(connection.BeginTransaction()); + ASSERT_TRUE(connection.Execute( + ""CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"" + ""INSERT INTO 'share_version' VALUES('nick@chromium.org',74);"" + ""CREATE TABLE models (model_id BLOB primary key, last_download_timestamp"" + "" INT, initial_sync_ended BOOLEAN default 0);"" + ""INSERT INTO 'models' VALUES(X'C2881000',694,1);"" + ""CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"" + ""ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"" + ""fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"" + ""tion_state INT default 0, bookmarks_added_during_autofill_migration"" + "" INT default 0, autofill_migration_time INT default 0, autofill_ent"" + ""ries_added_during_migration INT default 0, autofill_profiles_added_"" + ""during_migration INT default 0);"" + ""INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'"" + "",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542"" + "",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"" + ""CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas"" + ""e_version bigint default -1,server_version bigint default 0,mtime b"" + ""igint default 0,server_mtime bigint default 0,ctime bigint default "" + ""0,server_ctime bigint default 0,server_position_in_parent bigint de"" + ""fault 0,local_external_id bigint default 0,id varchar(255) default "" + ""'r',parent_id varchar(255) default 'r',server_parent_id varchar(255"" + "") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)"" + "" default 'r',is_unsynced bit default 0,is_unapplied_update bit defa"" + ""ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d"" + ""efault 0,server_is_del bit default 0,non_unique_name varchar,server"" + ""_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"" + ""nt_tag varchar,specifics blob,server_specifics blob);"" + ""INSERT INTO 'metas' VALUES(1,-1,0,129079956640320000,0,1290799566403200"" + ""00,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"" + ""');"" + ""INSERT INTO 'metas' VALUES(2,669,669,128976886618480000,128976886618480"" + ""000,128976886618480000,128976886618480000,-2097152,4,'s_ID_2','s_ID"" + ""_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "" + ""Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"" + ""36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"" + ""6F6F676C652E636F6D2F32120B4153414447414447414447');"" + ""INSERT INTO 'metas' VALUES(4,681,681,129002163642690000,129002163642690"" + ""000,129002163642690000,129002163642690000,-3145728,3,'s_ID_4','s_ID"" + ""_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"" + ""elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"" + ""76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"" + ""68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"" + ""F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"" + ""INSERT INTO 'metas' VALUES(5,677,677,129001555500000000,129001555500000"" + ""000,129001555500000000,129001555500000000,1048576,7,'s_ID_5','s_ID_"" + ""9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"" + ""LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"" + ""47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"" + ""36F6D2F12084147464447415347');"" + ""INSERT INTO 'metas' VALUES(6,694,694,129053976170000000,129053976170000"" + ""000,129053976170000000,129053976170000000,-4194304,6,'s_ID_6','s_ID"" + ""_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"" + "",NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(7,663,663,128976864758480000,128976864758480"" + ""000,128976864758480000,128976864758480000,1048576,0,'s_ID_7','r','r"" + ""','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"" + ""e',NULL,NULL,NULL);"" + ""INSERT INTO 'metas' VALUES(8,664,664,128976864758480000,128976864758480"" + ""000,128976864758480000,128976864758480000,1048576,0,'s_ID_8','s_ID_"" + ""7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"" + ""ome_bookmarks',NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(9,665,665,128976864758480000,128976864758480"" + ""000,128976864758480000,128976864758480000,1048576,1,'s_ID_9','s_ID_"" + ""8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"" + "",'bookmark_bar',NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(10,666,666,128976864758480000,12897686475848"" + ""0000,128976864758480000,128976864758480000,2097152,2,'s_ID_10','s_I"" + ""D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"" + ""kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(11,683,683,129079956948440000,12907995694844"" + ""0000,129079956948440000,129079956948440000,-1048576,8,'s_ID_11','s_"" + ""ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"" + ""ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"" + ""03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"" + ""290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"" + ""84146414756415346');"" + ""INSERT INTO 'metas' VALUES(12,685,685,129079957513650000,12907995751365"" + ""0000,129079957513650000,129079957513650000,0,9,'s_ID_12','s_ID_6','"" + ""s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"" + ""okmarks',NULL,NULL,X'C2881000',X'C2881000');"" + ""INSERT INTO 'metas' VALUES(13,687,687,129079957985300000,12907995798530"" + ""0000,129079957985300000,129079957985300000,-917504,10,'s_ID_13','s_"" + ""ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"" + ""rporation for Assigned Names and Numbers','ICANN | Internet Corpora"" + ""tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"" + ""703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"" + ""28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"" + ""5346');"" + ""INSERT INTO 'metas' VALUES(14,692,692,129079958383000000,12907995838300"" + ""0000,129079958383000000,129079958383000000,1048576,11,'s_ID_14','s_"" + ""ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"" + ""oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"" + ""474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"" + ""703A2F2F7765626B69742E6F72672F781205504E473259');"" + )); + ASSERT_TRUE(connection.CommitTransaction()); +} +","@@ -18,8 +18,6 @@ + #include ""chrome/browser/sync/syncable/directory_manager.h"" + #include ""chrome/browser/sync/syncable/syncable-inl.h"" + #include ""chrome/browser/sync/syncable/syncable.h"" +-#include ""chrome/browser/sync/util/sqlite_utils.h"" +-#include ""chrome/browser/sync/util/time.h"" + #include ""sql/connection.h"" + #include ""sql/statement.h"" + #include ""testing/gtest/include/gtest/gtest-param-test.h"" +@@ -52,7 +50,6 @@ class MigrationTest : public testing::TestWithParam { + void SetUpVersion73Database(); + void SetUpVersion74Database(); + void SetUpVersion75Database(); +- void SetUpVersion76Database(); + + void SetUpCurrentDatabaseAndCheckVersion() { + SetUpVersion70Database(); // Prepopulates data. +@@ -72,227 +69,6 @@ class MigrationTest : public testing::TestWithParam { + + class DirectoryBackingStoreTest : public MigrationTest {}; + +-#if defined(OS_WIN) +- +-// On Windows, we used to store timestamps in FILETIME format. +-#define LEGACY_META_PROTO_TIMES_1 129079956640320000 +-#define LEGACY_META_PROTO_TIMES_2 128976886618480000 +-#define LEGACY_META_PROTO_TIMES_4 129002163642690000 +-#define LEGACY_META_PROTO_TIMES_5 129001555500000000 +-#define LEGACY_META_PROTO_TIMES_6 129053976170000000 +-#define LEGACY_META_PROTO_TIMES_7 128976864758480000 +-#define LEGACY_META_PROTO_TIMES_8 128976864758480000 +-#define LEGACY_META_PROTO_TIMES_9 128976864758480000 +-#define LEGACY_META_PROTO_TIMES_10 128976864758480000 +-#define LEGACY_META_PROTO_TIMES_11 129079956948440000 +-#define LEGACY_META_PROTO_TIMES_12 129079957513650000 +-#define LEGACY_META_PROTO_TIMES_13 129079957985300000 +-#define LEGACY_META_PROTO_TIMES_14 129079958383000000 +- +-// Generated via: +-// +-// ruby -ane '$F[1].sub!(""LEGACY_"", """"); $F[2] = Integer($F[2]) / 10000 - 11644473600000; print ""#{$F[0]} #{$F[1]} #{$F[2]}\n""' +-// +-// Magic numbers taken from +-// http://stackoverflow.com/questions/5398557/java-library-for-dealing-with-win32-filetime . +- +-// Now we store them in Java format (ms since the Unix epoch). +-#define META_PROTO_TIMES_1 1263522064032 +-#define META_PROTO_TIMES_2 1253215061848 +-#define META_PROTO_TIMES_4 1255742764269 +-#define META_PROTO_TIMES_5 1255681950000 +-#define META_PROTO_TIMES_6 1260924017000 +-#define META_PROTO_TIMES_7 1253212875848 +-#define META_PROTO_TIMES_8 1253212875848 +-#define META_PROTO_TIMES_9 1253212875848 +-#define META_PROTO_TIMES_10 1253212875848 +-#define META_PROTO_TIMES_11 1263522094844 +-#define META_PROTO_TIMES_12 1263522151365 +-#define META_PROTO_TIMES_13 1263522198530 +-#define META_PROTO_TIMES_14 1263522238300 +- +-#else +- +-// On other platforms, we used to store timestamps in time_t format (s +-// since the Unix epoch). +-#define LEGACY_META_PROTO_TIMES_1 1263522064 +-#define LEGACY_META_PROTO_TIMES_2 1253215061 +-#define LEGACY_META_PROTO_TIMES_4 1255742764 +-#define LEGACY_META_PROTO_TIMES_5 1255681950 +-#define LEGACY_META_PROTO_TIMES_6 1260924017 +-#define LEGACY_META_PROTO_TIMES_7 1253212875 +-#define LEGACY_META_PROTO_TIMES_8 1253212875 +-#define LEGACY_META_PROTO_TIMES_9 1253212875 +-#define LEGACY_META_PROTO_TIMES_10 1253212875 +-#define LEGACY_META_PROTO_TIMES_11 1263522094 +-#define LEGACY_META_PROTO_TIMES_12 1263522151 +-#define LEGACY_META_PROTO_TIMES_13 1263522198 +-#define LEGACY_META_PROTO_TIMES_14 1263522238 +- +-// Now we store them in Java format (ms since the Unix epoch). +-#define META_PROTO_TIMES_1 1263522064000 +-#define META_PROTO_TIMES_2 1253215061000 +-#define META_PROTO_TIMES_4 1255742764000 +-#define META_PROTO_TIMES_5 1255681950000 +-#define META_PROTO_TIMES_6 1260924017000 +-#define META_PROTO_TIMES_7 1253212875000 +-#define META_PROTO_TIMES_8 1253212875000 +-#define META_PROTO_TIMES_9 1253212875000 +-#define META_PROTO_TIMES_10 1253212875000 +-#define META_PROTO_TIMES_11 1263522094000 +-#define META_PROTO_TIMES_12 1263522151000 +-#define META_PROTO_TIMES_13 1263522198000 +-#define META_PROTO_TIMES_14 1263522238000 +- +-#endif +- +-// Helper macros for the database dumps in the SetUpVersion*Database +-// functions. +-#define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x +-#define META_PROTO_TIMES(x) META_PROTO_TIMES_##x +-#define STR(s) #s +-#define XSTR(s) STR(s) +-#define LEGACY_PROTO_TIME_VALS(x) \ +- XSTR(LEGACY_META_PROTO_TIMES(x)) "","" \ +- XSTR(LEGACY_META_PROTO_TIMES(x)) "","" \ +- XSTR(LEGACY_META_PROTO_TIMES(x)) "","" \ +- XSTR(LEGACY_META_PROTO_TIMES(x)) +- +-namespace { +- +-// Helper functions for testing. +- +-// Returns a map from metahandle -> expected legacy time (in proto +-// format). +-std::map GetExpectedLegacyMetaProtoTimes() { +- std::map expected_legacy_meta_proto_times; +- expected_legacy_meta_proto_times[1] = LEGACY_META_PROTO_TIMES(1); +- expected_legacy_meta_proto_times[2] = LEGACY_META_PROTO_TIMES(2); +- expected_legacy_meta_proto_times[4] = LEGACY_META_PROTO_TIMES(4); +- expected_legacy_meta_proto_times[5] = LEGACY_META_PROTO_TIMES(5); +- expected_legacy_meta_proto_times[6] = LEGACY_META_PROTO_TIMES(6); +- expected_legacy_meta_proto_times[7] = LEGACY_META_PROTO_TIMES(7); +- expected_legacy_meta_proto_times[8] = LEGACY_META_PROTO_TIMES(8); +- expected_legacy_meta_proto_times[9] = LEGACY_META_PROTO_TIMES(9); +- expected_legacy_meta_proto_times[10] = LEGACY_META_PROTO_TIMES(10); +- expected_legacy_meta_proto_times[11] = LEGACY_META_PROTO_TIMES(11); +- expected_legacy_meta_proto_times[12] = LEGACY_META_PROTO_TIMES(12); +- expected_legacy_meta_proto_times[13] = LEGACY_META_PROTO_TIMES(13); +- expected_legacy_meta_proto_times[14] = LEGACY_META_PROTO_TIMES(14); +- return expected_legacy_meta_proto_times; +-} +- +-// Returns a map from metahandle -> expected time (in proto format). +-std::map GetExpectedMetaProtoTimes() { +- std::map expected_meta_proto_times; +- expected_meta_proto_times[1] = META_PROTO_TIMES(1); +- expected_meta_proto_times[2] = META_PROTO_TIMES(2); +- expected_meta_proto_times[4] = META_PROTO_TIMES(4); +- expected_meta_proto_times[5] = META_PROTO_TIMES(5); +- expected_meta_proto_times[6] = META_PROTO_TIMES(6); +- expected_meta_proto_times[7] = META_PROTO_TIMES(7); +- expected_meta_proto_times[8] = META_PROTO_TIMES(8); +- expected_meta_proto_times[9] = META_PROTO_TIMES(9); +- expected_meta_proto_times[10] = META_PROTO_TIMES(10); +- expected_meta_proto_times[11] = META_PROTO_TIMES(11); +- expected_meta_proto_times[12] = META_PROTO_TIMES(12); +- expected_meta_proto_times[13] = META_PROTO_TIMES(13); +- expected_meta_proto_times[14] = META_PROTO_TIMES(14); +- return expected_meta_proto_times; +-} +- +-// Returns a map from metahandle -> expected time (as a Time object). +-std::map GetExpectedMetaTimes() { +- std::map expected_meta_times; +- const std::map& expected_meta_proto_times = +- GetExpectedMetaProtoTimes(); +- for (std::map::const_iterator it = +- expected_meta_proto_times.begin(); +- it != expected_meta_proto_times.end(); ++it) { +- expected_meta_times[it->first] = +- browser_sync::ProtoTimeToTime(it->second); +- } +- return expected_meta_times; +-} +- +-// Extracts a map from metahandle -> time (in proto format) from the +-// given database. +-std::map GetMetaProtoTimes(sqlite3* db_handle) { +- sqlite_utils::SQLStatement statement; +- statement.prepare( +- db_handle, +- ""SELECT metahandle, mtime, server_mtime, ctime, server_ctime FROM metas""); +- EXPECT_EQ(5, statement.column_count()); +- std::map meta_times; +- while (true) { +- int query_result = statement.step(); +- if (query_result != SQLITE_ROW) { +- EXPECT_EQ(SQLITE_DONE, query_result); +- break; +- } +- int64 metahandle = statement.column_int64(0); +- int64 mtime = statement.column_int64(1); +- int64 server_mtime = statement.column_int64(2); +- int64 ctime = statement.column_int64(3); +- int64 server_ctime = statement.column_int64(4); +- EXPECT_EQ(mtime, server_mtime); +- EXPECT_EQ(mtime, ctime); +- EXPECT_EQ(mtime, server_ctime); +- meta_times[metahandle] = mtime; +- } +- return meta_times; +-} +- +-::testing::AssertionResult AssertTimesMatch(const char* t1_expr, +- const char* t2_expr, +- const base::Time& t1, +- const base::Time& t2) { +- if (t1 == t2) +- return ::testing::AssertionSuccess(); +- +- return ::testing::AssertionFailure() +- << t1_expr << "" and "" << t2_expr +- << "" (internal values: "" << t1.ToInternalValue() +- << "" and "" << t2.ToInternalValue() +- << "") (proto time: "" << browser_sync::TimeToProtoTime(t1) +- << "" and "" << browser_sync::TimeToProtoTime(t2) +- << "") do not match""; +-} +- +-// Expect that all time fields of the given entry kernel will be the +-// given time. +-void ExpectTime(const EntryKernel& entry_kernel, +- const base::Time& expected_time) { +- EXPECT_PRED_FORMAT2(AssertTimesMatch, +- expected_time, entry_kernel.ref(CTIME)); +- EXPECT_PRED_FORMAT2(AssertTimesMatch, +- expected_time, entry_kernel.ref(SERVER_CTIME)); +- EXPECT_PRED_FORMAT2(AssertTimesMatch, +- expected_time, entry_kernel.ref(MTIME)); +- EXPECT_PRED_FORMAT2(AssertTimesMatch, +- expected_time, entry_kernel.ref(SERVER_MTIME)); +-} +- +-// Expect that all the entries in |index| have times matching those in +-// the given map (from metahandle to expect time). +-void ExpectTimes(const MetahandlesIndex& index, +- const std::map& expected_times) { +- for (MetahandlesIndex::const_iterator it = index.begin(); +- it != index.end(); ++it) { +- int64 meta_handle = (*it)->ref(META_HANDLE); +- SCOPED_TRACE(meta_handle); +- std::map::const_iterator it2 = +- expected_times.find(meta_handle); +- if (it2 == expected_times.end()) { +- ADD_FAILURE() << ""Could not find expected time for "" << meta_handle; +- continue; +- } +- ExpectTime(**it, it2->second); +- } +-} +- +-} // namespace +- + void MigrationTest::SetUpVersion67Database() { + // This is a version 67 database dump whose contents were backformed from + // the contents of the version 68 database dump (the v68 migration was +@@ -324,68 +100,68 @@ void MigrationTest::SetUpVersion67Database() { + ""bookmark_url varchar,server_bookmark_url varchar,"" + ""singleton_tag varchar,bookmark_favicon blob,"" + ""server_bookmark_favicon blob);"" +- ""INSERT INTO metas VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"" ++ ""INSERT INTO metas VALUES(1,-1,0,129079956640320000,0,"" ++ ""129079956640320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"" + ""NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,"" ++ ""INSERT INTO metas VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,-2097152,"" + ""4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"" + ""'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item',"" + ""'http://www.google.com/','http://www.google.com/2',NULL,'AASGASGA',"" + ""'ASADGADGADG');"" +- ""INSERT INTO metas VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,"" ++ ""INSERT INTO metas VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,"" + ""3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"" + ""'Welcome to Chromium',NULL,'Welcome to Chromium',"" + ""'Welcome to Chromium','Welcome to Chromium',"" + ""'http://www.google.com/chrome/intl/en/welcome.html',"" + ""'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"" + ""NULL);"" +- ""INSERT INTO metas VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,"" + ""7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"" + ""'Google',NULL,'Google','Google','Google','http://www.google.com/',"" + ""'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"" +- ""INSERT INTO metas VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,"" ++ ""INSERT INTO metas VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,"" + ""6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"" + ""'The Internet',NULL,'The Internet','The Internet',"" + ""'The Internet',NULL,NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "","" ++ ""INSERT INTO metas VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,"" + ""1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"" + ""'Google Chrome',NULL,'Google Chrome','Google Chrome',"" + ""'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);"" +- ""INSERT INTO metas VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,"" + ""0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"" + ""NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL,"" + ""'google_chrome_bookmarks',NULL,NULL);"" +- ""INSERT INTO metas VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "","" ++ ""INSERT INTO metas VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,"" + ""1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"" + ""1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar',"" + ""NULL,NULL,'bookmark_bar',NULL,NULL);"" +- ""INSERT INTO metas VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,"" ++ ""INSERT INTO metas VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,2097152,"" + ""2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"" + ""'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks',"" + ""'Other Bookmarks',NULL,NULL,'other_bookmarks',"" + ""NULL,NULL);"" +- ""INSERT INTO metas VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,"" ++ ""INSERT INTO metas VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,"" + ""8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"" + ""'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)',"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',"" + ""'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"" + ""'AGATWA','AFAGVASF');"" +- ""INSERT INTO metas VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO metas VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"" + ""'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks',"" + ""'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,"" ++ ""INSERT INTO metas VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,"" + ""10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"" + ""1,'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN Internet Corporation for Assigned Names and Numbers',"" +@@ -394,8 +170,8 @@ void MigrationTest::SetUpVersion67Database() { + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'http://www.icann.com/','http://www.icann.com/',NULL,"" + ""'PNGAXF0AAFF','DAAFASF');"" +- ""INSERT INTO metas VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,"" + ""11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"" + ""'The WebKit Open Source Project',NULL,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" +@@ -446,68 +222,68 @@ void MigrationTest::SetUpVersion68Database() { + ""bookmark_url varchar,server_bookmark_url varchar,"" + ""singleton_tag varchar,bookmark_favicon blob,"" + ""server_bookmark_favicon blob);"" +- ""INSERT INTO metas VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"" ++ ""INSERT INTO metas VALUES(1,-1,0,129079956640320000,0,"" ++ ""129079956640320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"" + ""NULL,NULL,NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,"" ++ ""INSERT INTO metas VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,-2097152,"" + ""4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"" + ""'Deleted Item','Deleted Item','http://www.google.com/',"" + ""'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG');"" +- ""INSERT INTO metas VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,"" ++ ""INSERT INTO metas VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,"" + ""3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"" + ""'Welcome to Chromium','Welcome to Chromium',"" + ""'http://www.google.com/chrome/intl/en/welcome.html',"" + ""'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"" + ""NULL);"" +- ""INSERT INTO metas VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,"" + ""7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"" + ""'Google','Google','http://www.google.com/',"" + ""'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"" +- ""INSERT INTO metas VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,"" ++ ""INSERT INTO metas VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,"" + ""6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"" + ""'The Internet','The Internet',NULL,NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "","" ++ ""INSERT INTO metas VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,"" + ""1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"" + ""'Google Chrome','Google Chrome',NULL,NULL,'google_chrome',NULL,"" + ""NULL);"" +- ""INSERT INTO metas VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,"" + ""0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"" + ""'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL);"" +- ""INSERT INTO metas VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "","" ++ ""INSERT INTO metas VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,"" + ""1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"" + ""1,'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,"" + ""NULL);"" +- ""INSERT INTO metas VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,"" ++ ""INSERT INTO metas VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,2097152,"" + ""2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"" + ""'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"" + ""NULL,NULL);"" +- ""INSERT INTO metas VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,"" ++ ""INSERT INTO metas VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,"" + ""8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',"" + ""'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"" + ""'AGATWA','AFAGVASF');"" +- ""INSERT INTO metas VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO metas VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"" + ""'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,"" ++ ""INSERT INTO metas VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,"" + ""10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"" + ""1,'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'http://www.icann.com/','http://www.icann.com/',NULL,"" + ""'PNGAXF0AAFF','DAAFASF');"" +- ""INSERT INTO metas VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,"" + ""11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" + ""'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y');"" +@@ -551,19 +327,19 @@ void MigrationTest::SetUpVersion69Database() { + ""singleton_tag varchar,bookmark_favicon blob,"" + ""server_bookmark_favicon blob, specifics blob, "" + ""server_specifics blob);"" +- ""INSERT INTO metas VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL,"" ++ ""INSERT INTO metas VALUES(1,-1,0,129079956640320000,0,129079956640320000,"" ++ ""0,0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL,"" + ""NULL,NULL,X'',X'');"" +- ""INSERT INTO metas VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,"" ++ ""INSERT INTO metas VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,-2097152,"" + ""4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"" + ""'Deleted Item','Deleted Item','http://www.google.com/',"" + ""'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG',"" + ""X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841415"" + ""34741534741',X'C28810260A17687474703A2F2F7777772E676F6F676C652E636F"" + ""6D2F32120B4153414447414447414447');"" +- ""INSERT INTO metas VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,"" ++ ""INSERT INTO metas VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,"" + ""3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"" + ""'Welcome to Chromium','Welcome to Chromium',"" + ""'http://www.google.com/chrome/intl/en/welcome.html',"" +@@ -572,61 +348,61 @@ void MigrationTest::SetUpVersion69Database() { + ""D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A3168"" + ""7474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F6"" + ""56E2F77656C636F6D652E68746D6C1200');"" +- ""INSERT INTO metas VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,"" ++ ""INSERT INTO metas VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,7,"" + ""'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"" + ""'Google','Google','http://www.google.com/',"" + ""'http://www.google.com/',NULL,'AGASGASG','AGFDGASG',X'C28810220A166"" + ""87474703A2F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'"" + ""C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464"" + ""447415347');"" +- ""INSERT INTO metas VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6"" ++ ""INSERT INTO metas VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,6"" + "",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,'The Internet',"" + ""'The Internet',NULL,NULL,NULL,NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,"" ++ ""INSERT INTO metas VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,'Google Chrome',"" + ""'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,"" ++ ""INSERT INTO metas VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"" + ""'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,"" ++ ""INSERT INTO metas VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,1,"" + ""'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,1,"" + ""'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,"" ++ ""INSERT INTO metas VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,2097152,2,"" + ""'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"" + ""'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"" + ""NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,"" ++ ""INSERT INTO metas VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,"" + ""8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',"" + ""'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"" + ""'AGATWA','AFAGVASF',X'C28810220A18687474703A2F2F6465762E6368726F6D6"" + ""9756D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F646576"" + ""2E6368726F6D69756D2E6F72672F6F7468657212084146414756415346');"" +- ""INSERT INTO metas VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO metas VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"" + ""'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,"" ++ ""INSERT INTO metas VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,"" + ""10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"" + ""1,'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'http://www.icann.com/','http://www.icann.com/',NULL,'PNGAXF0AAFF',"" + ""'DAAFASF',X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F1"" + ""20B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963"" + ""616E6E2E636F6D2F120744414146415346');"" +- ""INSERT INTO metas VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,"" ++ ""INSERT INTO metas VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,11,"" + ""'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" + ""'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y',"" +@@ -680,73 +456,74 @@ void MigrationTest::SetUpVersion70Database() { + ""non_unique_name varchar,server_non_unique_name varchar(255),"" + ""unique_server_tag varchar,unique_client_tag varchar,"" + ""specifics blob,server_specifics blob);"" +- ""INSERT INTO metas VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"" +- ""INSERT INTO metas VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) "","" ++ ""INSERT INTO metas VALUES(1,-1,0,129079956640320000,0,129079956640320000,"" ++ ""0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"" ++ ""INSERT INTO metas VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,"" + ""-2097152,4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,"" + ""1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A"" + ""2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X'C2881026"" + ""0A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B415341444741"" + ""4447414447');"" +- ""INSERT INTO metas VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,"" ++ ""INSERT INTO metas VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,"" + ""3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"" + ""'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A"" + ""31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E74"" + ""6C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F"" + ""2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"" + ""6C636F6D652E68746D6C1200');"" +- ""INSERT INTO metas VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,"" ++ ""INSERT INTO metas VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,7,"" + ""'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"" + ""'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C6"" + ""52E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F77777"" + ""72E676F6F676C652E636F6D2F12084147464447415347');"" +- ""INSERT INTO metas VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,"" ++ ""INSERT INTO metas VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,"" + ""6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"" + ""'The Internet',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,"" ++ ""INSERT INTO metas VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome',"" + ""'Google Chrome','google_chrome',NULL,NULL,NULL);"" +- ""INSERT INTO metas VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,"" ++ ""INSERT INTO metas VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"" + ""'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',"" + ""X'C2881000');"" +- ""INSERT INTO metas VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,"" + ""1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,"" + ""'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000',"" + ""X'C2881000');"" +- ""INSERT INTO metas VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "","" ++ ""INSERT INTO metas VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,"" + ""2097152,2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"" + ""'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO metas VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,"" ++ ""INSERT INTO metas VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,"" + ""8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',"" + ""NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F"" + ""72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636872"" + ""6F6D69756D2E6F72672F6F7468657212084146414756415346');"" +- ""INSERT INTO metas VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO metas VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"" + ""'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"" + ""X'C2881000');"" +- ""INSERT INTO metas VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,"" ++ ""INSERT INTO metas VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,"" + ""10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F"" + ""120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E69"" + ""63616E6E2E636F6D2F120744414146415346');"" +- ""INSERT INTO metas VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,"" ++ ""INSERT INTO metas VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,"" + ""11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" + ""NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"" +@@ -778,73 +555,73 @@ void MigrationTest::SetUpVersion71Database() { + ""non_unique_name varchar,server_non_unique_name varchar(255),"" + ""unique_server_tag varchar,unique_client_tag varchar,specifics blob,"" + ""server_specifics blob);"" +- ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"" ++ ""INSERT INTO 'metas' VALUES(1,-1,0,129079956640320000,0,"" ++ ""129079956640320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"" + ""NULL,NULL,X'',X'');"" +- ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,4,"" ++ ""INSERT INTO 'metas' VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,-2097152,4,"" + ""'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"" + ""'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"" + ""7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"" + ""7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"" + ""47');"" +- ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,3,"" ++ ""INSERT INTO 'metas' VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,3,"" + ""'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"" + ""'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"" + ""687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"" + ""656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"" + ""772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"" + ""652E68746D6C1200');"" +- ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,"" ++ ""INSERT INTO 'metas' VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,7,"" + ""'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"" + ""'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"" + ""E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"" + ""76F6F676C652E636F6D2F12084147464447415347');"" +- ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6,"" ++ ""INSERT INTO 'metas' VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,6,"" + ""'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"" + ""'The Internet',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,"" ++ ""INSERT INTO 'metas' VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"" + "",'google_chrome',NULL,NULL,NULL);"" +- ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,"" ++ ""INSERT INTO 'metas' VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"" + ""'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,"" ++ ""INSERT INTO 'metas' VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,1,"" + ""'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"" + ""'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,"" ++ ""INSERT INTO 'metas' VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,2097152,2,"" + ""'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"" + ""'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,8,"" ++ ""INSERT INTO 'metas' VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,8,"" + ""'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"" + ""NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"" + ""206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"" + ""D2E6F72672F6F7468657212084146414756415346');"" +- ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO 'metas' VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"" + ""'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"" + ""X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,10,"" ++ ""INSERT INTO 'metas' VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,10,"" + ""'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"" + ""NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"" + ""E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"" + ""E636F6D2F120744414146415346');"" +- ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,"" ++ ""INSERT INTO 'metas' VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,11,"" + ""'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" + ""NULL,NULL,""""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"" +@@ -882,73 +659,73 @@ void MigrationTest::SetUpVersion72Database() { + ""non_unique_name varchar,server_non_unique_name varchar(255),"" + ""unique_server_tag varchar,unique_client_tag varchar,specifics blob,"" + ""server_specifics blob);"" +- ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"" ++ ""INSERT INTO 'metas' VALUES(1,-1,0,129079956640320000,0,"" ++ ""129079956640320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"" + ""NULL,NULL,X'',X'');"" +- ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,4,"" ++ ""INSERT INTO 'metas' VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,-2097152,4,"" + ""'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"" + ""'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"" + ""7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"" + ""7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"" + ""47');"" +- ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,3,"" ++ ""INSERT INTO 'metas' VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,3,"" + ""'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"" + ""'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"" + ""687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"" + ""656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"" + ""772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"" + ""652E68746D6C1200');"" +- ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,"" ++ ""INSERT INTO 'metas' VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,7,"" + ""'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"" + ""'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"" + ""E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"" + ""76F6F676C652E636F6D2F12084147464447415347');"" +- ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6,"" ++ ""INSERT INTO 'metas' VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,6,"" + ""'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"" + ""'The Internet',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,"" ++ ""INSERT INTO 'metas' VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"" + "",'google_chrome',NULL,NULL,NULL);"" +- ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,"" ++ ""INSERT INTO 'metas' VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"" + ""'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,"" ++ ""INSERT INTO 'metas' VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,1,"" + ""'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"" + ""'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,"" ++ ""INSERT INTO 'metas' VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,2097152,2,"" + ""'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"" + ""'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,8,"" ++ ""INSERT INTO 'metas' VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,8,"" + ""'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"" + ""NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"" + ""206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"" + ""D2E6F72672F6F7468657212084146414756415346');"" +- ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO 'metas' VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"" + ""'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"" + ""X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,10,"" ++ ""INSERT INTO 'metas' VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,10,"" + ""'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"" + ""NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"" + ""E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"" + ""E636F6D2F120744414146415346');"" +- ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,"" ++ ""INSERT INTO 'metas' VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,11,"" + ""'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" + ""NULL,NULL,""""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"" +@@ -986,73 +763,73 @@ void MigrationTest::SetUpVersion73Database() { + ""non_unique_name varchar,server_non_unique_name varchar(255),"" + ""unique_server_tag varchar,unique_client_tag varchar,specifics blob,"" + ""server_specifics blob);"" +- ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"" ++ ""INSERT INTO 'metas' VALUES(1,-1,0,129079956640320000,0,"" ++ ""129079956640320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"" + ""NULL,NULL,X'',X'');"" +- ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,4,"" ++ ""INSERT INTO 'metas' VALUES(2,669,669,128976886618480000,"" ++ ""128976886618480000,128976886618480000,128976886618480000,-2097152,4,"" + ""'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"" + ""'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"" + ""7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"" + ""7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"" + ""47');"" +- ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,3,"" ++ ""INSERT INTO 'metas' VALUES(4,681,681,129002163642690000,"" ++ ""129002163642690000,129002163642690000,129002163642690000,-3145728,3,"" + ""'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"" + ""'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"" + ""687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"" + ""656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"" + ""772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"" + ""652E68746D6C1200');"" +- ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,"" ++ ""INSERT INTO 'metas' VALUES(5,677,677,129001555500000000,"" ++ ""129001555500000000,129001555500000000,129001555500000000,1048576,7,"" + ""'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"" + ""'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"" + ""E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"" + ""76F6F676C652E636F6D2F12084147464447415347');"" +- ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6,"" ++ ""INSERT INTO 'metas' VALUES(6,694,694,129053976170000000,"" ++ ""129053976170000000,129053976170000000,129053976170000000,-4194304,6,"" + ""'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"" + ""'The Internet',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,"" ++ ""INSERT INTO 'metas' VALUES(7,663,663,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"" + "",'google_chrome',NULL,NULL,NULL);"" +- ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,"" ++ ""INSERT INTO 'metas' VALUES(8,664,664,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,0,"" + ""'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"" + ""'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,"" ++ ""INSERT INTO 'metas' VALUES(9,665,665,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,1048576,1,"" + ""'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"" + ""'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,"" ++ ""INSERT INTO 'metas' VALUES(10,666,666,128976864758480000,"" ++ ""128976864758480000,128976864758480000,128976864758480000,2097152,2,"" + ""'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"" + ""'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"" + ""X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,8,"" ++ ""INSERT INTO 'metas' VALUES(11,683,683,129079956948440000,"" ++ ""129079956948440000,129079956948440000,129079956948440000,-1048576,8,"" + ""'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"" + ""'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"" + ""NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"" + ""206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"" + ""D2E6F72672F6F7468657212084146414756415346');"" +- ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,"" ++ ""INSERT INTO 'metas' VALUES(12,685,685,129079957513650000,"" ++ ""129079957513650000,129079957513650000,129079957513650000,0,9,"" + ""'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"" + ""'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"" + ""X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,10,"" ++ ""INSERT INTO 'metas' VALUES(13,687,687,129079957985300000,"" ++ ""129079957985300000,129079957985300000,129079957985300000,-917504,10,"" + ""'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',"" + ""'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"" + ""NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"" + ""E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"" + ""E636F6D2F120744414146415346');"" +- ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,"" ++ ""INSERT INTO 'metas' VALUES(14,692,692,129079958383000000,"" ++ ""129079958383000000,129079958383000000,129079958383000000,1048576,11,"" + ""'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"" + ""'The WebKit Open Source Project','The WebKit Open Source Project',"" + ""NULL,NULL,""""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"" +@@ -1103,69 +880,69 @@ void MigrationTest::SetUpVersion74Database() { + ""efault 0,server_is_del bit default 0,non_unique_name varchar,server"" + ""_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"" + ""nt_tag varchar,specifics blob,server_specifics blob);"" +- ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"" ++ ""INSERT INTO 'metas' VALUES(1,-1,0,129079956640320000,0,1290799566403200"" ++ ""00,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"" + ""');"" +- ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,4,'s_ID_2','s_ID"" ++ ""INSERT INTO 'metas' VALUES(2,669,669,128976886618480000,128976886618480"" ++ ""000,128976886618480000,128976886618480000,-2097152,4,'s_ID_2','s_ID"" + ""_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "" + ""Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"" + ""36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"" + ""6F6F676C652E636F6D2F32120B4153414447414447414447');"" +- ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,3,'s_ID_4','s_ID"" ++ ""INSERT INTO 'metas' VALUES(4,681,681,129002163642690000,129002163642690"" ++ ""000,129002163642690000,129002163642690000,-3145728,3,'s_ID_4','s_ID"" + ""_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"" + ""elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"" + ""76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"" + ""68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"" + ""F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"" +- ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,'s_ID_5','s_ID_"" ++ ""INSERT INTO 'metas' VALUES(5,677,677,129001555500000000,129001555500000"" ++ ""000,129001555500000000,129001555500000000,1048576,7,'s_ID_5','s_ID_"" + ""9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"" + ""LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"" + ""47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"" + ""36F6D2F12084147464447415347');"" +- ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6,'s_ID_6','s_ID"" ++ ""INSERT INTO 'metas' VALUES(6,694,694,129053976170000000,129053976170000"" ++ ""000,129053976170000000,129053976170000000,-4194304,6,'s_ID_6','s_ID"" + ""_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"" + "",NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,'s_ID_7','r','r"" ++ ""INSERT INTO 'metas' VALUES(7,663,663,128976864758480000,128976864758480"" ++ ""000,128976864758480000,128976864758480000,1048576,0,'s_ID_7','r','r"" + ""','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"" + ""e',NULL,NULL,NULL);"" +- ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,'s_ID_8','s_ID_"" ++ ""INSERT INTO 'metas' VALUES(8,664,664,128976864758480000,128976864758480"" ++ ""000,128976864758480000,128976864758480000,1048576,0,'s_ID_8','s_ID_"" + ""7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"" + ""ome_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,'s_ID_9','s_ID_"" ++ ""INSERT INTO 'metas' VALUES(9,665,665,128976864758480000,128976864758480"" ++ ""000,128976864758480000,128976864758480000,1048576,1,'s_ID_9','s_ID_"" + ""8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"" + "",'bookmark_bar',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,'s_ID_10','s_I"" ++ ""INSERT INTO 'metas' VALUES(10,666,666,128976864758480000,12897686475848"" ++ ""0000,128976864758480000,128976864758480000,2097152,2,'s_ID_10','s_I"" + ""D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"" + ""kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,8,'s_ID_11','s_"" ++ ""INSERT INTO 'metas' VALUES(11,683,683,129079956948440000,12907995694844"" ++ ""0000,129079956948440000,129079956948440000,-1048576,8,'s_ID_11','s_"" + ""ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"" + ""ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"" + ""03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"" + ""290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"" + ""84146414756415346');"" +- ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,'s_ID_12','s_ID_6','"" ++ ""INSERT INTO 'metas' VALUES(12,685,685,129079957513650000,12907995751365"" ++ ""0000,129079957513650000,129079957513650000,0,9,'s_ID_12','s_ID_6','"" + ""s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"" + ""okmarks',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,10,'s_ID_13','s_"" ++ ""INSERT INTO 'metas' VALUES(13,687,687,129079957985300000,12907995798530"" ++ ""0000,129079957985300000,129079957985300000,-917504,10,'s_ID_13','s_"" + ""ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"" + ""rporation for Assigned Names and Numbers','ICANN | Internet Corpora"" + ""tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"" + ""703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"" + ""28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"" + ""5346');"" +- ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,'s_ID_14','s_"" ++ ""INSERT INTO 'metas' VALUES(14,692,692,129079958383000000,12907995838300"" ++ ""0000,129079958383000000,129079958383000000,1048576,11,'s_ID_14','s_"" + ""ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"" + ""oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"" + ""474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"" +@@ -1206,72 +983,72 @@ void MigrationTest::SetUpVersion75Database() { + ""dir bit default 0,server_is_del bit default 0,non_unique_name varc"" + ""har,server_non_unique_name varchar(255),unique_server_tag varchar,"" + ""unique_client_tag varchar,specifics blob,server_specifics blob);"" +- ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL"" ++ ""INSERT INTO 'metas' VALUES(1,-1,0,129079956640320000,0,129079956640"" ++ ""320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL"" + ""L,X'',X'');"" +- ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,4,'s_ID_"" ++ ""INSERT INTO 'metas' VALUES(2,669,669,128976886618480000,12897688661"" ++ ""8480000,128976886618480000,128976886618480000,-2097152,4,'s_ID_"" + ""2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Ite"" + ""m','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772"" + ""E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A176874"" + ""74703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474"" + ""14447');"" +- ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,3,'s_ID_"" ++ ""INSERT INTO 'metas' VALUES(4,681,681,129002163642690000,12900216364"" ++ ""2690000,129002163642690000,129002163642690000,-3145728,3,'s_ID_"" + ""4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to "" + ""Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A316874747"" + ""03A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F65"" + ""6E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7"" + ""777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"" + ""6C636F6D652E68746D6C1200');"" +- ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,'s_ID_5"" ++ ""INSERT INTO 'metas' VALUES(5,677,677,129001555500000000,12900155550"" ++ ""0000000,129001555500000000,129001555500000000,1048576,7,'s_ID_5"" + ""','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Goo"" + ""gle',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C65"" + ""2E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F777"" + ""7772E676F6F676C652E636F6D2F12084147464447415347');"" +- ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6,'s_ID_"" ++ ""INSERT INTO 'metas' VALUES(6,694,694,129053976170000000,12905397617"" ++ ""0000000,129053976170000000,129053976170000000,-4194304,6,'s_ID_"" + ""6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The In"" + ""ternet',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,'s_ID_7"" ++ ""INSERT INTO 'metas' VALUES(7,663,663,128976864758480000,12897686475"" ++ ""8480000,128976864758480000,128976864758480000,1048576,0,'s_ID_7"" + ""','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','"" + ""google_chrome',NULL,NULL,NULL);"" +- ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,'s_ID_8"" ++ ""INSERT INTO 'metas' VALUES(8,664,664,128976864758480000,12897686475"" ++ ""8480000,128976864758480000,128976864758480000,1048576,0,'s_ID_8"" + ""','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks'"" + "",'google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,'s_ID_9"" ++ ""INSERT INTO 'metas' VALUES(9,665,665,128976864758480000,12897686475"" ++ ""8480000,128976864758480000,128976864758480000,1048576,1,'s_ID_9"" + ""','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','B"" + ""ookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,'s_ID_"" ++ ""INSERT INTO 'metas' VALUES(10,666,666,128976864758480000,1289768647"" ++ ""58480000,128976864758480000,128976864758480000,2097152,2,'s_ID_"" + ""10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks"" + ""','Other Bookmarks','other_bookmarks',NULL,X'C2881000',X'C28810"" + ""00');"" +- ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,8,'s_ID"" ++ ""INSERT INTO 'metas' VALUES(11,683,683,129079956948440000,1290799569"" ++ ""48440000,129079956948440000,129079956948440000,-1048576,8,'s_ID"" + ""_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chr"" + ""omium Projects)','Home (The Chromium Projects)',NULL,NULL,X'C28"" + ""810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641"" + ""4741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"" + ""D2E6F72672F6F7468657212084146414756415346');"" +- ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,'s_ID_12','s"" ++ ""INSERT INTO 'metas' VALUES(12,685,685,129079957513650000,1290799575"" ++ ""13650000,129079957513650000,129079957513650000,0,9,'s_ID_12','s"" + ""_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmark"" + ""s','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,10,'s_ID"" ++ ""INSERT INTO 'metas' VALUES(13,687,687,129079957985300000,1290799579"" ++ ""85300000,129079957985300000,129079957985300000,-917504,10,'s_ID"" + ""_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN |"" + "" Internet Corporation for Assigned Names and Numbers','ICANN | "" + ""Internet Corporation for Assigned Names and Numbers',NULL,NULL,"" + ""X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"" + ""E474158463041414646',X'C28810200A15687474703A2F2F7777772E696361"" + ""6E6E2E636F6D2F120744414146415346');"" +- ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,'s_ID"" ++ ""INSERT INTO 'metas' VALUES(14,692,692,129079958383000000,1290799583"" ++ ""83000000,129079958383000000,129079958383000000,1048576,11,'s_ID"" + ""_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Op"" + ""en Source Project','The WebKit Open Source Project',NULL,NULL,X"" + ""'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',"" +@@ -1281,104 +1058,6 @@ void MigrationTest::SetUpVersion75Database() { + ASSERT_TRUE(connection.CommitTransaction()); + } + +-void MigrationTest::SetUpVersion76Database() { +- sql::Connection connection; +- ASSERT_TRUE(connection.Open(GetDatabasePath())); +- ASSERT_TRUE(connection.BeginTransaction()); +- ASSERT_TRUE(connection.Execute( +- ""CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"" +- ""INSERT INTO 'share_version' VALUES('nick@chromium.org',76);"" +- ""CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"" +- ""itial_sync_ended BOOLEAN default 0);"" +- ""INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"" +- ""CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"" +- ""_version bigint default -1,server_version bigint default 0,mtime big"" +- ""int default 0,server_mtime bigint default 0,ctime bigint default 0,s"" +- ""erver_ctime bigint default 0,server_position_in_parent bigint defaul"" +- ""t 0,local_external_id bigint default 0,id varchar(255) default 'r',p"" +- ""arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"" +- ""ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"" +- ""t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"" +- ""_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"" +- ""server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"" +- ""e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"" +- ""har,specifics blob,server_specifics blob);"" +- ""INSERT INTO 'metas' VALUES(1,-1,0,"" LEGACY_PROTO_TIME_VALS(1) +- "",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'')"" +- "";"" +- ""INSERT INTO 'metas' VALUES(2,669,669,"" LEGACY_PROTO_TIME_VALS(2) +- "",-2097152,4,'s_ID_2','s_ID_9"" +- ""','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted Ite"" +- ""m',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6"" +- ""D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E676F6F6"" +- ""76C652E636F6D2F32120B4153414447414447414447');"" +- ""INSERT INTO 'metas' VALUES(4,681,681,"" LEGACY_PROTO_TIME_VALS(4) +- "",-3145728,3,'s_ID_4','s_ID_9"" +- ""','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','Welc"" +- ""ome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E676F6"" +- ""F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746"" +- ""D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6"" +- ""368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"" +- ""INSERT INTO 'metas' VALUES(5,677,677,"" LEGACY_PROTO_TIME_VALS(5) +- "",1048576,7,'s_ID_5','s_ID_9'"" +- "",'s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NULL,"" +- ""X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F1208414741"" +- ""5347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D"" +- ""2F12084147464447415347');"" +- ""INSERT INTO 'metas' VALUES(6,694,694,"" LEGACY_PROTO_TIME_VALS(6) +- "",-4194304,6,'s_ID_6','s_ID_9"" +- ""','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL,NU"" +- ""LL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(7,663,663,"" LEGACY_PROTO_TIME_VALS(7) +- "",1048576,0,'s_ID_7','r','r',"" +- ""'r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrome',"" +- ""NULL,NULL,NULL);"" +- ""INSERT INTO 'metas' VALUES(8,664,664,"" LEGACY_PROTO_TIME_VALS(8) +- "",1048576,0,'s_ID_8','s_ID_7'"" +- "",'s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chrome"" +- ""_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(9,665,665,"" LEGACY_PROTO_TIME_VALS(9) +- "",1048576,1,'s_ID_9','s_ID_8'"" +- "",'s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar','b"" +- ""ookmark_bar',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(10,666,666,"" LEGACY_PROTO_TIME_VALS(10) +- "",2097152,2,'s_ID_10','s_ID_"" +- ""8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Bookma"" +- ""rks','other_bookmarks',NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(11,683,683,"" LEGACY_PROTO_TIME_VALS(11) +- "",-1048576,8,'s_ID_11','s_ID"" +- ""_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projects)"" +- ""','Home (The Chromium Projects)',NULL,NULL,X'C28810220A18687474703A2"" +- ""F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1"" +- ""D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120841464"" +- ""14756415346');"" +- ""INSERT INTO 'metas' VALUES(12,685,685,"" LEGACY_PROTO_TIME_VALS(12) +- "",0,9,'s_ID_12','s_ID_6','s_"" +- ""ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"" +- ""arks',NULL,NULL,X'C2881000',X'C2881000');"" +- ""INSERT INTO 'metas' VALUES(13,687,687,"" LEGACY_PROTO_TIME_VALS(13) +- "",-917504,10,'s_ID_13','s_ID"" +- ""_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Corpo"" +- ""ration for Assigned Names and Numbers','ICANN | Internet Corporation"" +- "" for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474703A2"" +- ""F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C288102"" +- ""00A15687474703A2F2F7777772E6963616E6E2E636F6D2F120744414146415346');"" +- ""INSERT INTO 'metas' VALUES(14,692,692,"" LEGACY_PROTO_TIME_VALS(14) +- "",1048576,11,'s_ID_14','s_ID"" +- ""_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Proje"" +- ""ct','The WebKit Open Source Project',NULL,NULL,X'C288101A0A126874747"" +- ""03A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2"" +- ""F2F7765626B69742E6F72672F781205504E473259');"" +- ""CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"" +- ""y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"" +- ""ult -2, cache_guid TEXT , notification_state BLOB);"" +- ""INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"" +- ""'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"" +- ""9010788312004066376x-6609234393368420856x',NULL);"" +- )); +- ASSERT_TRUE(connection.CommitTransaction()); +-} +- + TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) { + SetUpVersion67Database(); + +@@ -1698,37 +1377,6 @@ TEST_F(DirectoryBackingStoreTest, MigrateVersion75To76) { + ""autofill_profiles_added_during_migration"")); + } + +-TEST_F(DirectoryBackingStoreTest, MigrateVersion76To77) { +- SetUpVersion76Database(); +- +- scoped_ptr dbs( +- new DirectoryBackingStore(GetUsername(), GetDatabasePath())); +- dbs->BeginLoad(); +- ASSERT_FALSE(dbs->needs_column_refresh_); +- +- EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(), +- GetMetaProtoTimes(dbs->load_dbhandle_)); +- // Since we the proto times are expected to be in a legacy format, +- // they may not be compatible with ProtoTimeToTime, so we don't call +- // ExpectTimes(). +- +- ASSERT_TRUE(dbs->MigrateVersion76To77()); +- ASSERT_EQ(77, dbs->GetVersion()); +- +- EXPECT_EQ(GetExpectedMetaProtoTimes(), +- GetMetaProtoTimes(dbs->load_dbhandle_)); +- +- { +- MetahandlesIndex index; +- STLElementDeleter index_deleter(&index); +- dbs->LoadEntries(&index); +- ExpectTimes(index, GetExpectedMetaTimes()); +- } +- +- dbs->EndLoad(); +- ASSERT_FALSE(dbs->needs_column_refresh_); +-} +- + TEST_P(MigrationTest, ToCurrentVersion) { + switch (GetParam()) { + case 67: +@@ -1758,9 +1406,6 @@ TEST_P(MigrationTest, ToCurrentVersion) { + case 75: + SetUpVersion75Database(); + break; +- case 76: +- SetUpVersion76Database(); +- break; + default: + // If you see this error, it may mean that you've increased the + // database version number but you haven't finished adding unit tests +@@ -1771,13 +1416,11 @@ TEST_P(MigrationTest, ToCurrentVersion) { + // 2. Set a breakpoint in this function and run the unit test. + // 3. Allow this test to run to completion (step out of the call), + // without allowing ~MigrationTest to execute. +- // 4. Examine this->temp_dir_ to determine the location of the ++ // 4. Examine this->scoped_dir_ to determine the location of the + // test database (it is currently of the version you need). +- // 5. Dump this using the sqlite3 command line tool: ++ // 5. Dump this using the sqlite command line tool: + // > .output foo_dump.sql + // > .dump +- // 6. Replace the timestamp columns with META_PROTO_TIMES(x) (or +- // LEGACY_META_PROTO_TIMES(x) if before Version 77). + FAIL() << ""Need to supply database dump for version "" << GetParam(); + } + +@@ -1870,11 +1513,6 @@ TEST_P(MigrationTest, ToCurrentVersion) { + MetahandlesIndex index; + STLElementDeleter index_deleter(&index); + dbs->LoadEntries(&index); +- +- EXPECT_EQ(GetExpectedMetaProtoTimes(), +- GetMetaProtoTimes(dbs->load_dbhandle_)); +- ExpectTimes(index, GetExpectedMetaTimes()); +- + dbs->EndLoad(); + + MetahandlesIndex::iterator it = index.begin();",3047,3283,4096 +10810,"static bool LookupAltName(const String& name, String& altName) +{ + struct FontCodepage { + const WCHAR* name; + int codePage; + }; + + struct NamePair { + const WCHAR* name; + FontCodepage altNameCodepage; + }; + + const int japaneseCodepage = 932; + const int simplifiedChineseCodepage = 936; + const int koreanCodepage = 949; + const int traditionalChineseCodepage = 950; + + static const NamePair namePairs[] = { + {L""\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF"", {L""MS PGothic"", japaneseCodepage}}, + {L""ms pgothic"", {L""\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF"", japaneseCodepage}}, + {L""\xFF2D\xFF33 \xFF30\x660E\x671D"", {L""MS PMincho"", japaneseCodepage}}, + {L""ms pmincho"", {L""\xFF2D\xFF33 \xFF30\x660E\x671D"", japaneseCodepage}}, + {L""\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF"", {L""MS Gothic"", japaneseCodepage}}, + {L""ms gothic"", {L""\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF"", japaneseCodepage}}, + {L""\xFF2D\xFF33 \x660E\x671D"", {L""MS Mincho"", japaneseCodepage}}, + {L""ms mincho"", {L""\xFF2D\xFF33 \x660E\x671D"", japaneseCodepage}}, + {L""\x30E1\x30A4\x30EA\x30AA"", {L""Meiryo"", japaneseCodepage}}, + {L""meiryo"", {L""\x30E1\x30A4\x30EA\x30AA"", japaneseCodepage}}, + {L""\xBC14\xD0D5"", {L""Batang"", koreanCodepage}}, + {L""batang"", {L""\xBC14\xD0D5"", koreanCodepage}}, + {L""\xBC14\xD0D5\xCCB4"", {L""Batangche"", koreanCodepage}}, + {L""batangche"", {L""\xBC14\xD0D5\xCCB4"", koreanCodepage}}, + {L""\xAD74\xB9BC"", {L""Gulim"", koreanCodepage}}, + {L""gulim"", {L""\xAD74\xB9BC"", koreanCodepage}}, + {L""\xAD74\xB9BC\xCCB4"", {L""Gulimche"", koreanCodepage}}, + {L""gulimche"", {L""\xAD74\xB9BC\xCCB4"", koreanCodepage}}, + {L""\xB3CB\xC6C0"", {L""Dotum"", koreanCodepage}}, + {L""dotum"", {L""\xB3CB\xC6C0"", koreanCodepage}}, + {L""\xB3CB\xC6C0\xCCB4"", {L""Dotumche"", koreanCodepage}}, + {L""dotumche"", {L""\xB3CB\xC6C0\xCCB4"", koreanCodepage}}, + {L""\xAD81\xC11C"", {L""Gungsuh"", koreanCodepage}}, + {L""gungsuh"", {L""\xAD81\xC11C"", koreanCodepage}}, + {L""\xAD81\xC11C\xCCB4"", {L""Gungsuhche"", koreanCodepage}}, + {L""gungsuhche"", {L""\xAD81\xC11C\xCCB4"", koreanCodepage}}, + {L""\xB9D1\xC740 \xACE0\xB515"", {L""Malgun Gothic"", koreanCodepage}}, + {L""malgun gothic"", {L""\xB9D1\xC740 \xACE0\xB515"", koreanCodepage}}, + {L""\x5B8B\x4F53"", {L""SimSun"", simplifiedChineseCodepage}}, + {L""simsun"", {L""\x5B8B\x4F53"", simplifiedChineseCodepage}}, + {L""\x5B8B\x4F53-ExtB"", {L""SimSun-ExtB"", simplifiedChineseCodepage}}, + {L""simsun-extb"", {L""\x5B8B\x4F53-extb"", simplifiedChineseCodepage}}, + {L""\x9ED1\x4F53"", {L""SimHei"", simplifiedChineseCodepage}}, + {L""simhei"", {L""\x9ED1\x4F53"", simplifiedChineseCodepage}}, + {L""\x65B0\x5B8B\x4F53"", {L""NSimSun"", simplifiedChineseCodepage}}, + {L""nsimsun"", {L""\x65B0\x5B8B\x4F53"", simplifiedChineseCodepage}}, + {L""\x5FAE\x8F6F\x96C5\x9ED1"", {L""Microsoft Yahei"", simplifiedChineseCodepage}}, + {L""microsoft yahei"", {L""\x5FAE\x8F6F\x96C5\x9ED1"", simplifiedChineseCodepage}}, + {L""\x4EFF\x5B8B"", {L""FangSong"", simplifiedChineseCodepage}}, + {L""fangsong"", {L""\x4EFF\x5B8B"", simplifiedChineseCodepage}}, + {L""\x6977\x4F53"", {L""KaiTi"", simplifiedChineseCodepage}}, + {L""kaiti"", {L""\x6977\x4F53"", simplifiedChineseCodepage}}, + {L""\x4EFF\x5B8B_GB2312"", {L""FangSong_GB2312"", simplifiedChineseCodepage}}, + {L""fangsong_gb2312"", {L""\x4EFF\x5B8B_gb2312"", simplifiedChineseCodepage}}, + {L""\x6977\x4F53"", {L""KaiTi_GB2312"", simplifiedChineseCodepage}}, + {L""kaiti_gb2312"", {L""\x6977\x4F53_gb2312"", simplifiedChineseCodepage}}, + {L""\x65B0\x7D30\x660E\x9AD4"", {L""PMingLiu"", traditionalChineseCodepage}}, + {L""pmingliu"", {L""\x65B0\x7D30\x660E\x9AD4"", traditionalChineseCodepage}}, + {L""\x65B0\x7D30\x660E\x9AD4-ExtB"", {L""PMingLiu-ExtB"", traditionalChineseCodepage}}, + {L""pmingliu-extb"", {L""\x65B0\x7D30\x660E\x9AD4-extb"", traditionalChineseCodepage}}, + {L""\x7D30\x660E\x9AD4"", {L""MingLiu"", traditionalChineseCodepage}}, + {L""mingliu"", {L""\x7D30\x660E\x9AD4"", traditionalChineseCodepage}}, + {L""\x7D30\x660E\x9AD4-ExtB"", {L""MingLiu-ExtB"", traditionalChineseCodepage}}, + {L""mingliu-extb"", {L""x65B0\x7D30\x660E\x9AD4-extb"", traditionalChineseCodepage}}, + {L""\x5FAE\x8EDF\x6B63\x9ED1\x9AD4"", {L""Microsoft JhengHei"", traditionalChineseCodepage}}, + {L""microsoft jhengHei"", {L""\x5FAE\x8EDF\x6B63\x9ED1\x9AD4"", traditionalChineseCodepage}}, + {L""\x6A19\x6977\x9AD4"", {L""DFKai-SB"", traditionalChineseCodepage}}, + {L""dfkai-sb"", {L""\x6A19\x6977\x9AD4"", traditionalChineseCodepage}}, + {L""\x6587\x6cc9\x9a5b\x6b63\x9ed1"", {L""WenQuanYi Zen Hei"", traditionalChineseCodepage}}, + {L""wenquanyi zen hei"", {L""\x6587\x6cc9\x9a5b\x6b63\x9ed1"", traditionalChineseCodepage}}, + {L""\x6587\x6cc9\x9a7f\x6b63\x9ed1"", {L""WenQuanYi Zen Hei"", simplifiedChineseCodepage}}, + {L""wenquanyi zen hei"", {L""\x6587\x6cc9\x9a7f\x6b63\x9ed1"", simplifiedChineseCodepage}}, + {L""\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", + {L""AR PL ShanHeiSun Uni"", traditionalChineseCodepage}}, + {L""ar pl shanheisun uni"", + {L""\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", traditionalChineseCodepage}}, + {L""\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", + {L""AR PL ShanHeiSun Uni"", simplifiedChineseCodepage}}, + {L""ar pl shanheisun uni"", + {L""\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", simplifiedChineseCodepage}}, + {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", {L""AR PL ZenKai Uni"", traditionalChineseCodepage}}, + {L""ar pl zenkai uni"", {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", traditionalChineseCodepage}}, + {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", {L""AR PL ZenKai Uni"", simplifiedChineseCodepage}}, + {L""ar pl zenkai uni"", {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", simplifiedChineseCodepage}}, + }; + + typedef HashMap NameMap; + static NameMap* fontNameMap = 0; + + if (!fontNameMap) { + fontNameMap = new NameMap; + for (size_t i = 0; i < WTF_ARRAY_LENGTH(namePairs); ++i) + fontNameMap->set(String(namePairs[i].name), &(namePairs[i].altNameCodepage)); + } + + bool isAscii = false; + String n; + if (name.containsOnlyASCII()) { + isAscii = true; + n = name.lower(); + } else + n = name; + + NameMap::iterator iter = fontNameMap->find(n); + if (iter == fontNameMap->end()) + return false; + + static int systemCp = ::GetACP(); + int fontCp = iter->value->codePage; + + if ((isAscii && systemCp == fontCp) || (!isAscii && systemCp != fontCp)) { + altName = String(iter->value->name); + return true; + } + + return false; +} +",0,"static bool LookupAltName(const String& name, String& altName) +{ + struct FontCodepage { + const WCHAR* name; + int codePage; + }; + + struct NamePair { + const WCHAR* name; + FontCodepage altNameCodepage; + }; + + const int japaneseCodepage = 932; + const int simplifiedChineseCodepage = 936; + const int koreanCodepage = 949; + const int traditionalChineseCodepage = 950; + + static const NamePair namePairs[] = { + {L""\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF"", {L""MS PGothic"", japaneseCodepage}}, + {L""ms pgothic"", {L""\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF"", japaneseCodepage}}, + {L""\xFF2D\xFF33 \xFF30\x660E\x671D"", {L""MS PMincho"", japaneseCodepage}}, + {L""ms pmincho"", {L""\xFF2D\xFF33 \xFF30\x660E\x671D"", japaneseCodepage}}, + {L""\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF"", {L""MS Gothic"", japaneseCodepage}}, + {L""ms gothic"", {L""\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF"", japaneseCodepage}}, + {L""\xFF2D\xFF33 \x660E\x671D"", {L""MS Mincho"", japaneseCodepage}}, + {L""ms mincho"", {L""\xFF2D\xFF33 \x660E\x671D"", japaneseCodepage}}, + {L""\x30E1\x30A4\x30EA\x30AA"", {L""Meiryo"", japaneseCodepage}}, + {L""meiryo"", {L""\x30E1\x30A4\x30EA\x30AA"", japaneseCodepage}}, + {L""\xBC14\xD0D5"", {L""Batang"", koreanCodepage}}, + {L""batang"", {L""\xBC14\xD0D5"", koreanCodepage}}, + {L""\xBC14\xD0D5\xCCB4"", {L""Batangche"", koreanCodepage}}, + {L""batangche"", {L""\xBC14\xD0D5\xCCB4"", koreanCodepage}}, + {L""\xAD74\xB9BC"", {L""Gulim"", koreanCodepage}}, + {L""gulim"", {L""\xAD74\xB9BC"", koreanCodepage}}, + {L""\xAD74\xB9BC\xCCB4"", {L""Gulimche"", koreanCodepage}}, + {L""gulimche"", {L""\xAD74\xB9BC\xCCB4"", koreanCodepage}}, + {L""\xB3CB\xC6C0"", {L""Dotum"", koreanCodepage}}, + {L""dotum"", {L""\xB3CB\xC6C0"", koreanCodepage}}, + {L""\xB3CB\xC6C0\xCCB4"", {L""Dotumche"", koreanCodepage}}, + {L""dotumche"", {L""\xB3CB\xC6C0\xCCB4"", koreanCodepage}}, + {L""\xAD81\xC11C"", {L""Gungsuh"", koreanCodepage}}, + {L""gungsuh"", {L""\xAD81\xC11C"", koreanCodepage}}, + {L""\xAD81\xC11C\xCCB4"", {L""Gungsuhche"", koreanCodepage}}, + {L""gungsuhche"", {L""\xAD81\xC11C\xCCB4"", koreanCodepage}}, + {L""\xB9D1\xC740 \xACE0\xB515"", {L""Malgun Gothic"", koreanCodepage}}, + {L""malgun gothic"", {L""\xB9D1\xC740 \xACE0\xB515"", koreanCodepage}}, + {L""\x5B8B\x4F53"", {L""SimSun"", simplifiedChineseCodepage}}, + {L""simsun"", {L""\x5B8B\x4F53"", simplifiedChineseCodepage}}, + {L""\x5B8B\x4F53-ExtB"", {L""SimSun-ExtB"", simplifiedChineseCodepage}}, + {L""simsun-extb"", {L""\x5B8B\x4F53-extb"", simplifiedChineseCodepage}}, + {L""\x9ED1\x4F53"", {L""SimHei"", simplifiedChineseCodepage}}, + {L""simhei"", {L""\x9ED1\x4F53"", simplifiedChineseCodepage}}, + {L""\x65B0\x5B8B\x4F53"", {L""NSimSun"", simplifiedChineseCodepage}}, + {L""nsimsun"", {L""\x65B0\x5B8B\x4F53"", simplifiedChineseCodepage}}, + {L""\x5FAE\x8F6F\x96C5\x9ED1"", {L""Microsoft Yahei"", simplifiedChineseCodepage}}, + {L""microsoft yahei"", {L""\x5FAE\x8F6F\x96C5\x9ED1"", simplifiedChineseCodepage}}, + {L""\x4EFF\x5B8B"", {L""FangSong"", simplifiedChineseCodepage}}, + {L""fangsong"", {L""\x4EFF\x5B8B"", simplifiedChineseCodepage}}, + {L""\x6977\x4F53"", {L""KaiTi"", simplifiedChineseCodepage}}, + {L""kaiti"", {L""\x6977\x4F53"", simplifiedChineseCodepage}}, + {L""\x4EFF\x5B8B_GB2312"", {L""FangSong_GB2312"", simplifiedChineseCodepage}}, + {L""fangsong_gb2312"", {L""\x4EFF\x5B8B_gb2312"", simplifiedChineseCodepage}}, + {L""\x6977\x4F53"", {L""KaiTi_GB2312"", simplifiedChineseCodepage}}, + {L""kaiti_gb2312"", {L""\x6977\x4F53_gb2312"", simplifiedChineseCodepage}}, + {L""\x65B0\x7D30\x660E\x9AD4"", {L""PMingLiu"", traditionalChineseCodepage}}, + {L""pmingliu"", {L""\x65B0\x7D30\x660E\x9AD4"", traditionalChineseCodepage}}, + {L""\x65B0\x7D30\x660E\x9AD4-ExtB"", {L""PMingLiu-ExtB"", traditionalChineseCodepage}}, + {L""pmingliu-extb"", {L""\x65B0\x7D30\x660E\x9AD4-extb"", traditionalChineseCodepage}}, + {L""\x7D30\x660E\x9AD4"", {L""MingLiu"", traditionalChineseCodepage}}, + {L""mingliu"", {L""\x7D30\x660E\x9AD4"", traditionalChineseCodepage}}, + {L""\x7D30\x660E\x9AD4-ExtB"", {L""MingLiu-ExtB"", traditionalChineseCodepage}}, + {L""mingliu-extb"", {L""x65B0\x7D30\x660E\x9AD4-extb"", traditionalChineseCodepage}}, + {L""\x5FAE\x8EDF\x6B63\x9ED1\x9AD4"", {L""Microsoft JhengHei"", traditionalChineseCodepage}}, + {L""microsoft jhengHei"", {L""\x5FAE\x8EDF\x6B63\x9ED1\x9AD4"", traditionalChineseCodepage}}, + {L""\x6A19\x6977\x9AD4"", {L""DFKai-SB"", traditionalChineseCodepage}}, + {L""dfkai-sb"", {L""\x6A19\x6977\x9AD4"", traditionalChineseCodepage}}, + {L""\x6587\x6cc9\x9a5b\x6b63\x9ed1"", {L""WenQuanYi Zen Hei"", traditionalChineseCodepage}}, + {L""wenquanyi zen hei"", {L""\x6587\x6cc9\x9a5b\x6b63\x9ed1"", traditionalChineseCodepage}}, + {L""\x6587\x6cc9\x9a7f\x6b63\x9ed1"", {L""WenQuanYi Zen Hei"", simplifiedChineseCodepage}}, + {L""wenquanyi zen hei"", {L""\x6587\x6cc9\x9a7f\x6b63\x9ed1"", simplifiedChineseCodepage}}, + {L""\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", + {L""AR PL ShanHeiSun Uni"", traditionalChineseCodepage}}, + {L""ar pl shanheisun uni"", + {L""\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", traditionalChineseCodepage}}, + {L""\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", + {L""AR PL ShanHeiSun Uni"", simplifiedChineseCodepage}}, + {L""ar pl shanheisun uni"", + {L""\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069"", simplifiedChineseCodepage}}, + {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", {L""AR PL ZenKai Uni"", traditionalChineseCodepage}}, + {L""ar pl zenkai uni"", {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", traditionalChineseCodepage}}, + {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", {L""AR PL ZenKai Uni"", simplifiedChineseCodepage}}, + {L""ar pl zenkai uni"", {L""\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069"", simplifiedChineseCodepage}}, + }; + + typedef HashMap NameMap; + static NameMap* fontNameMap = 0; + + if (!fontNameMap) { + fontNameMap = new NameMap; + for (size_t i = 0; i < WTF_ARRAY_LENGTH(namePairs); ++i) + fontNameMap->set(String(namePairs[i].name), &(namePairs[i].altNameCodepage)); + } + + bool isAscii = false; + String n; + if (name.containsOnlyASCII()) { + isAscii = true; + n = name.lower(); + } else + n = name; + + NameMap::iterator iter = fontNameMap->find(n); + if (iter == fontNameMap->end()) + return false; + + static int systemCp = ::GetACP(); + int fontCp = iter->value->codePage; + + if ((isAscii && systemCp == fontCp) || (!isAscii && systemCp != fontCp)) { + altName = String(iter->value->name); + return true; + } + + return false; +} +","@@ -37,8 +37,8 @@ + #include ""core/platform/graphics/SimpleFontData.h"" + #include ""core/platform/graphics/chromium/FontPlatformDataChromiumWin.h"" + #include ""core/platform/graphics/chromium/FontUtilsChromiumWin.h"" +-#include ""core/platform/win/HWndDC.h"" + #include ""platform/LayoutTestSupport.h"" ++#include ""platform/win/HWndDC.h"" + #include ""wtf/HashMap.h"" + #include ""wtf/HashSet.h"" + #include ""wtf/text/StringHash.h""",2941,3177,4096 +6271,"static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) +{ + const char + *option; + + Image + *image; + + int + jp2_status; + + MagickBooleanType + status; + + opj_codec_t + *jp2_codec; + + opj_codestream_index_t + *codestream_index = (opj_codestream_index_t *) NULL; + + opj_dparameters_t + parameters; + + opj_image_t + *jp2_image; + + opj_stream_t + *jp2_stream; + + register ssize_t + i; + + ssize_t + y; + + unsigned char + sans[4]; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Initialize JP2 codec. + */ + if (ReadBlob(image,4,sans) != 4) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + (void) SeekBlob(image,SEEK_SET,0); + if (LocaleCompare(image_info->magick,""JPT"") == 0) + jp2_codec=opj_create_decompress(OPJ_CODEC_JPT); + else + if (IsJ2K(sans,4) != MagickFalse) + jp2_codec=opj_create_decompress(OPJ_CODEC_J2K); + else + jp2_codec=opj_create_decompress(OPJ_CODEC_JP2); + opj_set_warning_handler(jp2_codec,JP2WarningHandler,exception); + opj_set_error_handler(jp2_codec,JP2ErrorHandler,exception); + opj_set_default_decoder_parameters(¶meters); + option=GetImageOption(image_info,""jp2:reduce-factor""); + if (option != (const char *) NULL) + parameters.cp_reduce=StringToInteger(option); + option=GetImageOption(image_info,""jp2:quality-layers""); + if (option == (const char *) NULL) + option=GetImageOption(image_info,""jp2:layer-number""); + if (option != (const char *) NULL) + parameters.cp_layer=StringToInteger(option); + if (opj_setup_decoder(jp2_codec,¶meters) == 0) + { + opj_destroy_codec(jp2_codec); + ThrowReaderException(DelegateError,""UnableToManageJP2Stream""); + } + jp2_stream=opj_stream_create(OPJ_J2K_STREAM_CHUNK_SIZE,OPJ_TRUE); + opj_stream_set_read_function(jp2_stream,JP2ReadHandler); + opj_stream_set_write_function(jp2_stream,JP2WriteHandler); + opj_stream_set_seek_function(jp2_stream,JP2SeekHandler); + opj_stream_set_skip_function(jp2_stream,JP2SkipHandler); + opj_stream_set_user_data(jp2_stream,image,NULL); + opj_stream_set_user_data_length(jp2_stream,GetBlobSize(image)); + if (opj_read_header(jp2_stream,jp2_codec,&jp2_image) == 0) + { + opj_stream_destroy(jp2_stream); + opj_destroy_codec(jp2_codec); + ThrowReaderException(DelegateError,""UnableToDecodeImageFile""); + } + jp2_status=1; + if ((image->columns != 0) && (image->rows != 0)) + { + /* + Extract an area from the image. + */ + jp2_status=opj_set_decode_area(jp2_codec,jp2_image, + (OPJ_INT32) image->extract_info.x,(OPJ_INT32) image->extract_info.y, + (OPJ_INT32) image->extract_info.x+(ssize_t) image->columns, + (OPJ_INT32) image->extract_info.y+(ssize_t) image->rows); + if (jp2_status == 0) + { + opj_stream_destroy(jp2_stream); + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + ThrowReaderException(DelegateError,""UnableToDecodeImageFile""); + } + } + if ((image_info->number_scenes != 0) && (image_info->scene != 0)) + jp2_status=opj_get_decoded_tile(jp2_codec,jp2_stream,jp2_image, + (unsigned int) image_info->scene-1); + else + if (image->ping == MagickFalse) + { + jp2_status=opj_decode(jp2_codec,jp2_stream,jp2_image); + if (jp2_status != 0) + jp2_status=opj_end_decompress(jp2_codec,jp2_stream); + } + if (jp2_status == 0) + { + opj_stream_destroy(jp2_stream); + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + ThrowReaderException(DelegateError,""UnableToDecodeImageFile""); + } + opj_stream_destroy(jp2_stream); + for (i=0; i < (ssize_t) jp2_image->numcomps; i++) + { + if ((jp2_image->comps[0].dx == 0) || (jp2_image->comps[0].dy == 0) || + (jp2_image->comps[0].dx != jp2_image->comps[i].dx) || + (jp2_image->comps[0].dy != jp2_image->comps[i].dy) || + (jp2_image->comps[0].prec != jp2_image->comps[i].prec) || + (jp2_image->comps[0].sgnd != jp2_image->comps[i].sgnd) || + ((image->ping == MagickFalse) && (jp2_image->comps[i].data == NULL))) + { + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + ThrowReaderException(CoderError,""IrregularChannelGeometryNotSupported"") + } + } + /* + Convert JP2 image. + */ + image->columns=(size_t) jp2_image->comps[0].w; + image->rows=(size_t) jp2_image->comps[0].h; + image->depth=jp2_image->comps[0].prec; + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + image->compression=JPEG2000Compression; + if (jp2_image->color_space == 2) + { + SetImageColorspace(image,GRAYColorspace); + if (jp2_image->numcomps > 1) + image->matte=MagickTrue; + } + else + if (jp2_image->color_space == 3) + SetImageColorspace(image,Rec601YCbCrColorspace); + if (jp2_image->numcomps > 3) + image->matte=MagickTrue; + if (jp2_image->icc_profile_buf != (unsigned char *) NULL) + { + StringInfo + *profile; + + profile=BlobToStringInfo(jp2_image->icc_profile_buf, + jp2_image->icc_profile_len); + if (profile != (StringInfo *) NULL) + SetImageProfile(image,""icc"",profile); + } + if (image->ping != MagickFalse) + { + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + opj_destroy_cstr_index(&codestream_index); + return(GetFirstImageInList(image)); + } + for (y=0; y < (ssize_t) image->rows; y++) + { + register PixelPacket + *magick_restrict q; + + register ssize_t + x; + + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + register ssize_t + i; + + for (i=0; i < (ssize_t) jp2_image->numcomps; i++) + { + double + pixel, + scale; + + scale=QuantumRange/(double) ((1UL << jp2_image->comps[i].prec)-1); + pixel=scale*(jp2_image->comps[i].data[y/jp2_image->comps[i].dy* + image->columns/jp2_image->comps[i].dx+x/jp2_image->comps[i].dx]+ + (jp2_image->comps[i].sgnd ? 1UL << (jp2_image->comps[i].prec-1) : 0)); + switch (i) + { + case 0: + { + q->red=ClampToQuantum(pixel); + q->green=q->red; + q->blue=q->red; + q->opacity=OpaqueOpacity; + break; + } + case 1: + { + if (jp2_image->numcomps == 2) + { + q->opacity=ClampToQuantum(QuantumRange-pixel); + break; + } + q->green=ClampToQuantum(pixel); + break; + } + case 2: + { + q->blue=ClampToQuantum(pixel); + break; + } + case 3: + { + q->opacity=ClampToQuantum(QuantumRange-pixel); + break; + } + } + } + q++; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + /* + Free resources. + */ + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + opj_destroy_cstr_index(&codestream_index); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",0,"static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) +{ + const char + *option; + + Image + *image; + + int + jp2_status; + + MagickBooleanType + status; + + opj_codec_t + *jp2_codec; + + opj_codestream_index_t + *codestream_index = (opj_codestream_index_t *) NULL; + + opj_dparameters_t + parameters; + + opj_image_t + *jp2_image; + + opj_stream_t + *jp2_stream; + + register ssize_t + i; + + ssize_t + y; + + unsigned char + sans[4]; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Initialize JP2 codec. + */ + if (ReadBlob(image,4,sans) != 4) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + (void) SeekBlob(image,SEEK_SET,0); + if (LocaleCompare(image_info->magick,""JPT"") == 0) + jp2_codec=opj_create_decompress(OPJ_CODEC_JPT); + else + if (IsJ2K(sans,4) != MagickFalse) + jp2_codec=opj_create_decompress(OPJ_CODEC_J2K); + else + jp2_codec=opj_create_decompress(OPJ_CODEC_JP2); + opj_set_warning_handler(jp2_codec,JP2WarningHandler,exception); + opj_set_error_handler(jp2_codec,JP2ErrorHandler,exception); + opj_set_default_decoder_parameters(¶meters); + option=GetImageOption(image_info,""jp2:reduce-factor""); + if (option != (const char *) NULL) + parameters.cp_reduce=StringToInteger(option); + option=GetImageOption(image_info,""jp2:quality-layers""); + if (option == (const char *) NULL) + option=GetImageOption(image_info,""jp2:layer-number""); + if (option != (const char *) NULL) + parameters.cp_layer=StringToInteger(option); + if (opj_setup_decoder(jp2_codec,¶meters) == 0) + { + opj_destroy_codec(jp2_codec); + ThrowReaderException(DelegateError,""UnableToManageJP2Stream""); + } + jp2_stream=opj_stream_create(OPJ_J2K_STREAM_CHUNK_SIZE,OPJ_TRUE); + opj_stream_set_read_function(jp2_stream,JP2ReadHandler); + opj_stream_set_write_function(jp2_stream,JP2WriteHandler); + opj_stream_set_seek_function(jp2_stream,JP2SeekHandler); + opj_stream_set_skip_function(jp2_stream,JP2SkipHandler); + opj_stream_set_user_data(jp2_stream,image,NULL); + opj_stream_set_user_data_length(jp2_stream,GetBlobSize(image)); + if (opj_read_header(jp2_stream,jp2_codec,&jp2_image) == 0) + { + opj_stream_destroy(jp2_stream); + opj_destroy_codec(jp2_codec); + ThrowReaderException(DelegateError,""UnableToDecodeImageFile""); + } + jp2_status=1; + if ((image->columns != 0) && (image->rows != 0)) + { + /* + Extract an area from the image. + */ + jp2_status=opj_set_decode_area(jp2_codec,jp2_image, + (OPJ_INT32) image->extract_info.x,(OPJ_INT32) image->extract_info.y, + (OPJ_INT32) image->extract_info.x+(ssize_t) image->columns, + (OPJ_INT32) image->extract_info.y+(ssize_t) image->rows); + if (jp2_status == 0) + { + opj_stream_destroy(jp2_stream); + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + ThrowReaderException(DelegateError,""UnableToDecodeImageFile""); + } + } + if ((image_info->number_scenes != 0) && (image_info->scene != 0)) + jp2_status=opj_get_decoded_tile(jp2_codec,jp2_stream,jp2_image, + (unsigned int) image_info->scene-1); + else + if (image->ping == MagickFalse) + { + jp2_status=opj_decode(jp2_codec,jp2_stream,jp2_image); + if (jp2_status != 0) + jp2_status=opj_end_decompress(jp2_codec,jp2_stream); + } + if (jp2_status == 0) + { + opj_stream_destroy(jp2_stream); + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + ThrowReaderException(DelegateError,""UnableToDecodeImageFile""); + } + opj_stream_destroy(jp2_stream); + for (i=0; i < (ssize_t) jp2_image->numcomps; i++) + { + if ((jp2_image->comps[0].dx == 0) || (jp2_image->comps[0].dy == 0) || + (jp2_image->comps[0].dx != jp2_image->comps[i].dx) || + (jp2_image->comps[0].dy != jp2_image->comps[i].dy) || + (jp2_image->comps[0].prec != jp2_image->comps[i].prec) || + (jp2_image->comps[0].sgnd != jp2_image->comps[i].sgnd) || + ((image->ping == MagickFalse) && (jp2_image->comps[i].data == NULL))) + { + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + ThrowReaderException(CoderError,""IrregularChannelGeometryNotSupported"") + } + } + /* + Convert JP2 image. + */ + image->columns=(size_t) jp2_image->comps[0].w; + image->rows=(size_t) jp2_image->comps[0].h; + image->depth=jp2_image->comps[0].prec; + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + image->compression=JPEG2000Compression; + if (jp2_image->color_space == 2) + { + SetImageColorspace(image,GRAYColorspace); + if (jp2_image->numcomps > 1) + image->matte=MagickTrue; + } + else + if (jp2_image->color_space == 3) + SetImageColorspace(image,Rec601YCbCrColorspace); + if (jp2_image->numcomps > 3) + image->matte=MagickTrue; + if (jp2_image->icc_profile_buf != (unsigned char *) NULL) + { + StringInfo + *profile; + + profile=BlobToStringInfo(jp2_image->icc_profile_buf, + jp2_image->icc_profile_len); + if (profile != (StringInfo *) NULL) + SetImageProfile(image,""icc"",profile); + } + if (image->ping != MagickFalse) + { + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + opj_destroy_cstr_index(&codestream_index); + return(GetFirstImageInList(image)); + } + for (y=0; y < (ssize_t) image->rows; y++) + { + register PixelPacket + *magick_restrict q; + + register ssize_t + x; + + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + register ssize_t + i; + + for (i=0; i < (ssize_t) jp2_image->numcomps; i++) + { + double + pixel, + scale; + + scale=QuantumRange/(double) ((1UL << jp2_image->comps[i].prec)-1); + pixel=scale*(jp2_image->comps[i].data[y/jp2_image->comps[i].dy* + image->columns/jp2_image->comps[i].dx+x/jp2_image->comps[i].dx]+ + (jp2_image->comps[i].sgnd ? 1UL << (jp2_image->comps[i].prec-1) : 0)); + switch (i) + { + case 0: + { + q->red=ClampToQuantum(pixel); + q->green=q->red; + q->blue=q->red; + q->opacity=OpaqueOpacity; + break; + } + case 1: + { + if (jp2_image->numcomps == 2) + { + q->opacity=ClampToQuantum(QuantumRange-pixel); + break; + } + q->green=ClampToQuantum(pixel); + break; + } + case 2: + { + q->blue=ClampToQuantum(pixel); + break; + } + case 3: + { + q->opacity=ClampToQuantum(QuantumRange-pixel); + break; + } + } + } + q++; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + /* + Free resources. + */ + opj_destroy_codec(jp2_codec); + opj_image_destroy(jp2_image); + opj_destroy_cstr_index(&codestream_index); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -924,7 +924,7 @@ static MagickBooleanType WriteJP2Image(const ImageInfo *image_info,Image *image) + ¶meters.subsampling_dx,¶meters.subsampling_dy); + property=GetImageProperty(image,""comment""); + if (property != (const char *) NULL) +- parameters.cp_comment=property; ++ parameters.cp_comment=(char *) property; + channels=3; + jp2_colorspace=OPJ_CLRSPC_SRGB; + if (image->colorspace == YUVColorspace)",2313,2549,4096 +9622,"parse_cmdline(int argc, char **argv) +{ + int c; + bool reopen_log = false; + int signum; + struct utsname uname_buf; + int longindex; + int curind; + bool bad_option = false; + unsigned facility; + mode_t new_umask_val; + + struct option long_options[] = { + {""use-file"", required_argument, NULL, 'f'}, +#if defined _WITH_VRRP_ && defined _WITH_LVS_ + {""vrrp"", no_argument, NULL, 'P'}, + {""check"", no_argument, NULL, 'C'}, +#endif +#ifdef _WITH_BFD_ + {""no_bfd"", no_argument, NULL, 'B'}, +#endif + {""all"", no_argument, NULL, 3 }, + {""log-console"", no_argument, NULL, 'l'}, + {""log-detail"", no_argument, NULL, 'D'}, + {""log-facility"", required_argument, NULL, 'S'}, + {""log-file"", optional_argument, NULL, 'g'}, + {""flush-log-file"", no_argument, NULL, 2 }, + {""no-syslog"", no_argument, NULL, 'G'}, + {""umask"", required_argument, NULL, 'u'}, +#ifdef _WITH_VRRP_ + {""release-vips"", no_argument, NULL, 'X'}, + {""dont-release-vrrp"", no_argument, NULL, 'V'}, +#endif +#ifdef _WITH_LVS_ + {""dont-release-ipvs"", no_argument, NULL, 'I'}, +#endif + {""dont-respawn"", no_argument, NULL, 'R'}, + {""dont-fork"", no_argument, NULL, 'n'}, + {""dump-conf"", no_argument, NULL, 'd'}, + {""pid"", required_argument, NULL, 'p'}, +#ifdef _WITH_VRRP_ + {""vrrp_pid"", required_argument, NULL, 'r'}, +#endif +#ifdef _WITH_LVS_ + {""checkers_pid"", required_argument, NULL, 'c'}, + {""address-monitoring"", no_argument, NULL, 'a'}, +#endif +#ifdef _WITH_BFD_ + {""bfd_pid"", required_argument, NULL, 'b'}, +#endif +#ifdef _WITH_SNMP_ + {""snmp"", no_argument, NULL, 'x'}, + {""snmp-agent-socket"", required_argument, NULL, 'A'}, +#endif + {""core-dump"", no_argument, NULL, 'm'}, + {""core-dump-pattern"", optional_argument, NULL, 'M'}, +#ifdef _MEM_CHECK_LOG_ + {""mem-check-log"", no_argument, NULL, 'L'}, +#endif +#if HAVE_DECL_CLONE_NEWNET + {""namespace"", required_argument, NULL, 's'}, +#endif + {""config-id"", required_argument, NULL, 'i'}, + {""signum"", required_argument, NULL, 4 }, + {""config-test"", optional_argument, NULL, 't'}, +#ifdef _WITH_PERF_ + {""perf"", optional_argument, NULL, 5 }, +#endif +#ifdef WITH_DEBUG_OPTIONS + {""debug"", optional_argument, NULL, 6 }, +#endif + {""version"", no_argument, NULL, 'v'}, + {""help"", no_argument, NULL, 'h'}, + + {NULL, 0, NULL, 0 } + }; + + /* Unfortunately, if a short option is used, getopt_long() doesn't change the value + * of longindex, so we need to ensure that before calling getopt_long(), longindex + * is set to a known invalid value */ + curind = optind; + while (longindex = -1, (c = getopt_long(argc, argv, "":vhlndu:DRS:f:p:i:mM::g::Gt::"" +#if defined _WITH_VRRP_ && defined _WITH_LVS_ + ""PC"" +#endif +#ifdef _WITH_VRRP_ + ""r:VX"" +#endif +#ifdef _WITH_LVS_ + ""ac:I"" +#endif +#ifdef _WITH_BFD_ + ""Bb:"" +#endif +#ifdef _WITH_SNMP_ + ""xA:"" +#endif +#ifdef _MEM_CHECK_LOG_ + ""L"" +#endif +#if HAVE_DECL_CLONE_NEWNET + ""s:"" +#endif + , long_options, &longindex)) != -1) { + + /* Check for an empty option argument. For example --use-file= returns + * a 0 length option, which we don't want */ + if (longindex >= 0 && long_options[longindex].has_arg == required_argument && optarg && !optarg[0]) { + c = ':'; + optarg = NULL; + } + + switch (c) { + case 'v': + fprintf(stderr, ""%s"", version_string); +#ifdef GIT_COMMIT + fprintf(stderr, "", git commit %s"", GIT_COMMIT); +#endif + fprintf(stderr, ""\n\n%s\n\n"", COPYRIGHT_STRING); + fprintf(stderr, ""Built with kernel headers for Linux %d.%d.%d\n"", + (LINUX_VERSION_CODE >> 16) & 0xff, + (LINUX_VERSION_CODE >> 8) & 0xff, + (LINUX_VERSION_CODE ) & 0xff); + uname(&uname_buf); + fprintf(stderr, ""Running on %s %s %s\n\n"", uname_buf.sysname, uname_buf.release, uname_buf.version); + fprintf(stderr, ""configure options: %s\n\n"", KEEPALIVED_CONFIGURE_OPTIONS); + fprintf(stderr, ""Config options: %s\n\n"", CONFIGURATION_OPTIONS); + fprintf(stderr, ""System options: %s\n"", SYSTEM_OPTIONS); + exit(0); + break; + case 'h': + usage(argv[0]); + exit(0); + break; + case 'l': + __set_bit(LOG_CONSOLE_BIT, &debug); + reopen_log = true; + break; + case 'n': + __set_bit(DONT_FORK_BIT, &debug); + break; + case 'd': + __set_bit(DUMP_CONF_BIT, &debug); + break; +#ifdef _WITH_VRRP_ + case 'V': + __set_bit(DONT_RELEASE_VRRP_BIT, &debug); + break; +#endif +#ifdef _WITH_LVS_ + case 'I': + __set_bit(DONT_RELEASE_IPVS_BIT, &debug); + break; +#endif + case 'D': + if (__test_bit(LOG_DETAIL_BIT, &debug)) + __set_bit(LOG_EXTRA_DETAIL_BIT, &debug); + else + __set_bit(LOG_DETAIL_BIT, &debug); + break; + case 'R': + __set_bit(DONT_RESPAWN_BIT, &debug); + break; +#ifdef _WITH_VRRP_ + case 'X': + __set_bit(RELEASE_VIPS_BIT, &debug); + break; +#endif + case 'S': + if (!read_unsigned(optarg, &facility, 0, LOG_FACILITY_MAX, false)) + fprintf(stderr, ""Invalid log facility '%s'\n"", optarg); + else { + log_facility = LOG_FACILITY[facility].facility; + reopen_log = true; + } + break; + case 'g': + if (optarg && optarg[0]) + log_file_name = optarg; + else + log_file_name = ""/tmp/keepalived.log""; + open_log_file(log_file_name, NULL, NULL, NULL); + break; + case 'G': + __set_bit(NO_SYSLOG_BIT, &debug); + reopen_log = true; + break; + case 'u': + new_umask_val = set_umask(optarg); + if (umask_cmdline) + umask_val = new_umask_val; + break; + case 't': + __set_bit(CONFIG_TEST_BIT, &debug); + __set_bit(DONT_RESPAWN_BIT, &debug); + __set_bit(DONT_FORK_BIT, &debug); + __set_bit(NO_SYSLOG_BIT, &debug); + if (optarg && optarg[0]) { + int fd = open(optarg, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (fd == -1) { + fprintf(stderr, ""Unable to open config-test log file %s\n"", optarg); + exit(EXIT_FAILURE); + } + dup2(fd, STDERR_FILENO); + close(fd); + } + break; + case 'f': + conf_file = optarg; + break; + case 2: /* --flush-log-file */ + set_flush_log_file(); + break; +#if defined _WITH_VRRP_ && defined _WITH_LVS_ + case 'P': + __clear_bit(DAEMON_CHECKERS, &daemon_mode); + break; + case 'C': + __clear_bit(DAEMON_VRRP, &daemon_mode); + break; +#endif +#ifdef _WITH_BFD_ + case 'B': + __clear_bit(DAEMON_BFD, &daemon_mode); + break; +#endif + case 'p': + main_pidfile = optarg; + break; +#ifdef _WITH_LVS_ + case 'c': + checkers_pidfile = optarg; + break; + case 'a': + __set_bit(LOG_ADDRESS_CHANGES, &debug); + break; +#endif +#ifdef _WITH_VRRP_ + case 'r': + vrrp_pidfile = optarg; + break; +#endif +#ifdef _WITH_BFD_ + case 'b': + bfd_pidfile = optarg; + break; +#endif +#ifdef _WITH_SNMP_ + case 'x': + snmp = 1; + break; + case 'A': + snmp_socket = optarg; + break; +#endif + case 'M': + set_core_dump_pattern = true; + if (optarg && optarg[0]) + core_dump_pattern = optarg; + /* ... falls through ... */ + case 'm': + create_core_dump = true; + break; +#ifdef _MEM_CHECK_LOG_ + case 'L': + __set_bit(MEM_CHECK_LOG_BIT, &debug); + break; +#endif +#if HAVE_DECL_CLONE_NEWNET + case 's': + override_namespace = MALLOC(strlen(optarg) + 1); + strcpy(override_namespace, optarg); + break; +#endif + case 'i': + FREE_PTR(config_id); + config_id = MALLOC(strlen(optarg) + 1); + strcpy(config_id, optarg); + break; + case 4: /* --signum */ + signum = get_signum(optarg); + if (signum == -1) { + fprintf(stderr, ""Unknown sigfunc %s\n"", optarg); + exit(1); + } + + printf(""%d\n"", signum); + exit(0); + break; + case 3: /* --all */ + __set_bit(RUN_ALL_CHILDREN, &daemon_mode); +#ifdef _WITH_VRRP_ + __set_bit(DAEMON_VRRP, &daemon_mode); +#endif +#ifdef _WITH_LVS_ + __set_bit(DAEMON_CHECKERS, &daemon_mode); +#endif +#ifdef _WITH_BFD_ + __set_bit(DAEMON_BFD, &daemon_mode); +#endif + break; +#ifdef _WITH_PERF_ + case 5: + if (optarg && optarg[0]) { + if (!strcmp(optarg, ""run"")) + perf_run = PERF_RUN; + else if (!strcmp(optarg, ""all"")) + perf_run = PERF_ALL; + else if (!strcmp(optarg, ""end"")) + perf_run = PERF_END; + else + log_message(LOG_INFO, ""Unknown perf start point %s"", optarg); + } + else + perf_run = PERF_RUN; + + break; +#endif +#ifdef WITH_DEBUG_OPTIONS + case 6: + set_debug_options(optarg && optarg[0] ? optarg : NULL); + break; +#endif + case '?': + if (optopt && argv[curind][1] != '-') + fprintf(stderr, ""Unknown option -%c\n"", optopt); + else + fprintf(stderr, ""Unknown option %s\n"", argv[curind]); + bad_option = true; + break; + case ':': + if (optopt && argv[curind][1] != '-') + fprintf(stderr, ""Missing parameter for option -%c\n"", optopt); + else + fprintf(stderr, ""Missing parameter for option --%s\n"", long_options[longindex].name); + bad_option = true; + break; + default: + exit(1); + break; + } + curind = optind; + } + + if (optind < argc) { + printf(""Unexpected argument(s): ""); + while (optind < argc) + printf(""%s "", argv[optind++]); + printf(""\n""); + } + + if (bad_option) + exit(1); + + return reopen_log; +} +",0,"parse_cmdline(int argc, char **argv) +{ + int c; + bool reopen_log = false; + int signum; + struct utsname uname_buf; + int longindex; + int curind; + bool bad_option = false; + unsigned facility; + mode_t new_umask_val; + + struct option long_options[] = { + {""use-file"", required_argument, NULL, 'f'}, +#if defined _WITH_VRRP_ && defined _WITH_LVS_ + {""vrrp"", no_argument, NULL, 'P'}, + {""check"", no_argument, NULL, 'C'}, +#endif +#ifdef _WITH_BFD_ + {""no_bfd"", no_argument, NULL, 'B'}, +#endif + {""all"", no_argument, NULL, 3 }, + {""log-console"", no_argument, NULL, 'l'}, + {""log-detail"", no_argument, NULL, 'D'}, + {""log-facility"", required_argument, NULL, 'S'}, + {""log-file"", optional_argument, NULL, 'g'}, + {""flush-log-file"", no_argument, NULL, 2 }, + {""no-syslog"", no_argument, NULL, 'G'}, + {""umask"", required_argument, NULL, 'u'}, +#ifdef _WITH_VRRP_ + {""release-vips"", no_argument, NULL, 'X'}, + {""dont-release-vrrp"", no_argument, NULL, 'V'}, +#endif +#ifdef _WITH_LVS_ + {""dont-release-ipvs"", no_argument, NULL, 'I'}, +#endif + {""dont-respawn"", no_argument, NULL, 'R'}, + {""dont-fork"", no_argument, NULL, 'n'}, + {""dump-conf"", no_argument, NULL, 'd'}, + {""pid"", required_argument, NULL, 'p'}, +#ifdef _WITH_VRRP_ + {""vrrp_pid"", required_argument, NULL, 'r'}, +#endif +#ifdef _WITH_LVS_ + {""checkers_pid"", required_argument, NULL, 'c'}, + {""address-monitoring"", no_argument, NULL, 'a'}, +#endif +#ifdef _WITH_BFD_ + {""bfd_pid"", required_argument, NULL, 'b'}, +#endif +#ifdef _WITH_SNMP_ + {""snmp"", no_argument, NULL, 'x'}, + {""snmp-agent-socket"", required_argument, NULL, 'A'}, +#endif + {""core-dump"", no_argument, NULL, 'm'}, + {""core-dump-pattern"", optional_argument, NULL, 'M'}, +#ifdef _MEM_CHECK_LOG_ + {""mem-check-log"", no_argument, NULL, 'L'}, +#endif +#if HAVE_DECL_CLONE_NEWNET + {""namespace"", required_argument, NULL, 's'}, +#endif + {""config-id"", required_argument, NULL, 'i'}, + {""signum"", required_argument, NULL, 4 }, + {""config-test"", optional_argument, NULL, 't'}, +#ifdef _WITH_PERF_ + {""perf"", optional_argument, NULL, 5 }, +#endif +#ifdef WITH_DEBUG_OPTIONS + {""debug"", optional_argument, NULL, 6 }, +#endif + {""version"", no_argument, NULL, 'v'}, + {""help"", no_argument, NULL, 'h'}, + + {NULL, 0, NULL, 0 } + }; + + /* Unfortunately, if a short option is used, getopt_long() doesn't change the value + * of longindex, so we need to ensure that before calling getopt_long(), longindex + * is set to a known invalid value */ + curind = optind; + while (longindex = -1, (c = getopt_long(argc, argv, "":vhlndu:DRS:f:p:i:mM::g::Gt::"" +#if defined _WITH_VRRP_ && defined _WITH_LVS_ + ""PC"" +#endif +#ifdef _WITH_VRRP_ + ""r:VX"" +#endif +#ifdef _WITH_LVS_ + ""ac:I"" +#endif +#ifdef _WITH_BFD_ + ""Bb:"" +#endif +#ifdef _WITH_SNMP_ + ""xA:"" +#endif +#ifdef _MEM_CHECK_LOG_ + ""L"" +#endif +#if HAVE_DECL_CLONE_NEWNET + ""s:"" +#endif + , long_options, &longindex)) != -1) { + + /* Check for an empty option argument. For example --use-file= returns + * a 0 length option, which we don't want */ + if (longindex >= 0 && long_options[longindex].has_arg == required_argument && optarg && !optarg[0]) { + c = ':'; + optarg = NULL; + } + + switch (c) { + case 'v': + fprintf(stderr, ""%s"", version_string); +#ifdef GIT_COMMIT + fprintf(stderr, "", git commit %s"", GIT_COMMIT); +#endif + fprintf(stderr, ""\n\n%s\n\n"", COPYRIGHT_STRING); + fprintf(stderr, ""Built with kernel headers for Linux %d.%d.%d\n"", + (LINUX_VERSION_CODE >> 16) & 0xff, + (LINUX_VERSION_CODE >> 8) & 0xff, + (LINUX_VERSION_CODE ) & 0xff); + uname(&uname_buf); + fprintf(stderr, ""Running on %s %s %s\n\n"", uname_buf.sysname, uname_buf.release, uname_buf.version); + fprintf(stderr, ""configure options: %s\n\n"", KEEPALIVED_CONFIGURE_OPTIONS); + fprintf(stderr, ""Config options: %s\n\n"", CONFIGURATION_OPTIONS); + fprintf(stderr, ""System options: %s\n"", SYSTEM_OPTIONS); + exit(0); + break; + case 'h': + usage(argv[0]); + exit(0); + break; + case 'l': + __set_bit(LOG_CONSOLE_BIT, &debug); + reopen_log = true; + break; + case 'n': + __set_bit(DONT_FORK_BIT, &debug); + break; + case 'd': + __set_bit(DUMP_CONF_BIT, &debug); + break; +#ifdef _WITH_VRRP_ + case 'V': + __set_bit(DONT_RELEASE_VRRP_BIT, &debug); + break; +#endif +#ifdef _WITH_LVS_ + case 'I': + __set_bit(DONT_RELEASE_IPVS_BIT, &debug); + break; +#endif + case 'D': + if (__test_bit(LOG_DETAIL_BIT, &debug)) + __set_bit(LOG_EXTRA_DETAIL_BIT, &debug); + else + __set_bit(LOG_DETAIL_BIT, &debug); + break; + case 'R': + __set_bit(DONT_RESPAWN_BIT, &debug); + break; +#ifdef _WITH_VRRP_ + case 'X': + __set_bit(RELEASE_VIPS_BIT, &debug); + break; +#endif + case 'S': + if (!read_unsigned(optarg, &facility, 0, LOG_FACILITY_MAX, false)) + fprintf(stderr, ""Invalid log facility '%s'\n"", optarg); + else { + log_facility = LOG_FACILITY[facility].facility; + reopen_log = true; + } + break; + case 'g': + if (optarg && optarg[0]) + log_file_name = optarg; + else + log_file_name = ""/tmp/keepalived.log""; + open_log_file(log_file_name, NULL, NULL, NULL); + break; + case 'G': + __set_bit(NO_SYSLOG_BIT, &debug); + reopen_log = true; + break; + case 'u': + new_umask_val = set_umask(optarg); + if (umask_cmdline) + umask_val = new_umask_val; + break; + case 't': + __set_bit(CONFIG_TEST_BIT, &debug); + __set_bit(DONT_RESPAWN_BIT, &debug); + __set_bit(DONT_FORK_BIT, &debug); + __set_bit(NO_SYSLOG_BIT, &debug); + if (optarg && optarg[0]) { + int fd = open(optarg, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (fd == -1) { + fprintf(stderr, ""Unable to open config-test log file %s\n"", optarg); + exit(EXIT_FAILURE); + } + dup2(fd, STDERR_FILENO); + close(fd); + } + break; + case 'f': + conf_file = optarg; + break; + case 2: /* --flush-log-file */ + set_flush_log_file(); + break; +#if defined _WITH_VRRP_ && defined _WITH_LVS_ + case 'P': + __clear_bit(DAEMON_CHECKERS, &daemon_mode); + break; + case 'C': + __clear_bit(DAEMON_VRRP, &daemon_mode); + break; +#endif +#ifdef _WITH_BFD_ + case 'B': + __clear_bit(DAEMON_BFD, &daemon_mode); + break; +#endif + case 'p': + main_pidfile = optarg; + break; +#ifdef _WITH_LVS_ + case 'c': + checkers_pidfile = optarg; + break; + case 'a': + __set_bit(LOG_ADDRESS_CHANGES, &debug); + break; +#endif +#ifdef _WITH_VRRP_ + case 'r': + vrrp_pidfile = optarg; + break; +#endif +#ifdef _WITH_BFD_ + case 'b': + bfd_pidfile = optarg; + break; +#endif +#ifdef _WITH_SNMP_ + case 'x': + snmp = 1; + break; + case 'A': + snmp_socket = optarg; + break; +#endif + case 'M': + set_core_dump_pattern = true; + if (optarg && optarg[0]) + core_dump_pattern = optarg; + /* ... falls through ... */ + case 'm': + create_core_dump = true; + break; +#ifdef _MEM_CHECK_LOG_ + case 'L': + __set_bit(MEM_CHECK_LOG_BIT, &debug); + break; +#endif +#if HAVE_DECL_CLONE_NEWNET + case 's': + override_namespace = MALLOC(strlen(optarg) + 1); + strcpy(override_namespace, optarg); + break; +#endif + case 'i': + FREE_PTR(config_id); + config_id = MALLOC(strlen(optarg) + 1); + strcpy(config_id, optarg); + break; + case 4: /* --signum */ + signum = get_signum(optarg); + if (signum == -1) { + fprintf(stderr, ""Unknown sigfunc %s\n"", optarg); + exit(1); + } + + printf(""%d\n"", signum); + exit(0); + break; + case 3: /* --all */ + __set_bit(RUN_ALL_CHILDREN, &daemon_mode); +#ifdef _WITH_VRRP_ + __set_bit(DAEMON_VRRP, &daemon_mode); +#endif +#ifdef _WITH_LVS_ + __set_bit(DAEMON_CHECKERS, &daemon_mode); +#endif +#ifdef _WITH_BFD_ + __set_bit(DAEMON_BFD, &daemon_mode); +#endif + break; +#ifdef _WITH_PERF_ + case 5: + if (optarg && optarg[0]) { + if (!strcmp(optarg, ""run"")) + perf_run = PERF_RUN; + else if (!strcmp(optarg, ""all"")) + perf_run = PERF_ALL; + else if (!strcmp(optarg, ""end"")) + perf_run = PERF_END; + else + log_message(LOG_INFO, ""Unknown perf start point %s"", optarg); + } + else + perf_run = PERF_RUN; + + break; +#endif +#ifdef WITH_DEBUG_OPTIONS + case 6: + set_debug_options(optarg && optarg[0] ? optarg : NULL); + break; +#endif + case '?': + if (optopt && argv[curind][1] != '-') + fprintf(stderr, ""Unknown option -%c\n"", optopt); + else + fprintf(stderr, ""Unknown option %s\n"", argv[curind]); + bad_option = true; + break; + case ':': + if (optopt && argv[curind][1] != '-') + fprintf(stderr, ""Missing parameter for option -%c\n"", optopt); + else + fprintf(stderr, ""Missing parameter for option --%s\n"", long_options[longindex].name); + bad_option = true; + break; + default: + exit(1); + break; + } + curind = optind; + } + + if (optind < argc) { + printf(""Unexpected argument(s): ""); + while (optind < argc) + printf(""%s "", argv[optind++]); + printf(""\n""); + } + + if (bad_option) + exit(1); + + return reopen_log; +} +","@@ -882,7 +882,7 @@ set_umask(const char *optarg) + + if (*endptr || umask_long < 0 || umask_long & ~0777L) { + fprintf(stderr, ""Invalid --umask option %s"", optarg); +- return; ++ return 0; + } + + umask_val = umask_long & 0777;",2826,3062,4096 +17528,"WORD32 impeg2d_dec_pnb_mb_params(dec_state_t *ps_dec) +{ + stream_t *ps_stream = &ps_dec->s_bit_stream; + UWORD16 u2_mb_addr_incr; + UWORD16 u2_total_len; + UWORD16 u2_len; + UWORD16 u2_mb_type; + UWORD32 u4_next_word; + const dec_mb_params_t *ps_dec_mb_params; + if(impeg2d_bit_stream_nxt(ps_stream,1) == 1) + { + impeg2d_bit_stream_flush(ps_stream,1); + + } + else + { + u2_mb_addr_incr = impeg2d_get_mb_addr_incr(ps_stream); + + if(ps_dec->u2_first_mb) + { + /****************************************************************/ + /* Section 6.3.17 */ + /* The first MB of a slice cannot be skipped */ + /* But the mb_addr_incr can be > 1, because at the beginning of */ + /* a slice, it indicates the offset from the last MB in the */ + /* previous row. Hence for the first slice in a row, the */ + /* mb_addr_incr needs to be 1. */ + /****************************************************************/ + /* MB_x is set to zero whenever MB_y changes. */ + ps_dec->u2_mb_x = u2_mb_addr_incr - 1; + /* For error resilience */ + ps_dec->u2_mb_x = MIN(ps_dec->u2_mb_x, (ps_dec->u2_num_horiz_mb - 1)); + + /****************************************************************/ + /* mb_addr_incr is forced to 1 because in this decoder it is used */ + /* more as an indicator of the number of MBs skipped than the */ + /* as defined by the standard (Section 6.3.17) */ + /****************************************************************/ + u2_mb_addr_incr = 1; + ps_dec->u2_first_mb = 0; + } + else + { + /****************************************************************/ + /* In MPEG-2, the last MB of the row cannot be skipped and the */ + /* mb_addr_incr cannot be such that it will take the current MB */ + /* beyond the current row */ + /* In MPEG-1, the slice could start and end anywhere and is not */ + /* restricted to a row like in MPEG-2. Hence this check should */ + /* not be done for MPEG-1 streams. */ + /****************************************************************/ + if(ps_dec->u2_is_mpeg2 && + ((ps_dec->u2_mb_x + u2_mb_addr_incr) > ps_dec->u2_num_horiz_mb)) + { + u2_mb_addr_incr = ps_dec->u2_num_horiz_mb - ps_dec->u2_mb_x; + } + + if ((u2_mb_addr_incr - 1) > ps_dec->u2_num_mbs_left) + { + /* If the number of skip MBs are more than the number of MBs + * left, indicate error. + */ + return IV_FAIL; + } + + impeg2d_dec_skip_mbs(ps_dec, (UWORD16)(u2_mb_addr_incr - 1)); + } + + } + u4_next_word = (UWORD16)impeg2d_bit_stream_nxt(ps_stream,16); + /*-----------------------------------------------------------------------*/ + /* MB type */ + /*-----------------------------------------------------------------------*/ + { + u2_mb_type = ps_dec->pu2_mb_type[BITS((UWORD16)u4_next_word,15,10)]; + u2_len = BITS(u2_mb_type,15,8); + u2_total_len = u2_len; + u4_next_word = (UWORD16)LSW((UWORD16)u4_next_word << u2_len); + } + /*-----------------------------------------------------------------------*/ + /* motion type */ + /*-----------------------------------------------------------------------*/ + { + WORD32 i4_motion_type = ps_dec->u2_motion_type; + + if((u2_mb_type & MB_FORW_OR_BACK) && ps_dec->u2_read_motion_type) + { + ps_dec->u2_motion_type = BITS((UWORD16)u4_next_word,15,14); + u2_total_len += MB_MOTION_TYPE_LEN; + u4_next_word = (UWORD16)LSW((UWORD16)u4_next_word << MB_MOTION_TYPE_LEN); + i4_motion_type = ps_dec->u2_motion_type; + + } + + + if ((u2_mb_type & MB_FORW_OR_BACK) && + ((i4_motion_type == 0) || + (i4_motion_type == 3) || + (i4_motion_type == 4) || + (i4_motion_type >= 7))) + { + i4_motion_type = 1; + } + + } + /*-----------------------------------------------------------------------*/ + /* dct type */ + /*-----------------------------------------------------------------------*/ + { + if((u2_mb_type & MB_CODED) && ps_dec->u2_read_dct_type) + { + ps_dec->u2_field_dct = BIT((UWORD16)u4_next_word,15); + u2_total_len += MB_DCT_TYPE_LEN; + u4_next_word = (UWORD16)LSW((UWORD16)u4_next_word << MB_DCT_TYPE_LEN); + } + } + /*-----------------------------------------------------------------------*/ + /* Quant scale code */ + /*-----------------------------------------------------------------------*/ + if(u2_mb_type & MB_QUANT) + { + UWORD16 u2_quant_scale_code; + u2_quant_scale_code = BITS((UWORD16)u4_next_word,15,11); + + ps_dec->u1_quant_scale = (ps_dec->u2_q_scale_type) ? + gau1_impeg2_non_linear_quant_scale[u2_quant_scale_code] : (u2_quant_scale_code << 1); + u2_total_len += MB_QUANT_SCALE_CODE_LEN; + } + impeg2d_bit_stream_flush(ps_stream,u2_total_len); + /*-----------------------------------------------------------------------*/ + /* Set the function pointers */ + /*-----------------------------------------------------------------------*/ + ps_dec->u2_coded_mb = (UWORD16)(u2_mb_type & MB_CODED); + + if(u2_mb_type & MB_BIDRECT) + { + UWORD16 u2_index = (ps_dec->u2_motion_type); + + ps_dec->u2_prev_intra_mb = 0; + ps_dec->e_mb_pred = BIDIRECT; + ps_dec_mb_params = &ps_dec->ps_func_bi_direct[u2_index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; + if(NULL == ps_dec_mb_params->pf_func_mb_params) + return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + } + else if(u2_mb_type & MB_FORW_OR_BACK) + { + + UWORD16 u2_refPic = !(u2_mb_type & MB_MV_FORW); + UWORD16 u2_index = (ps_dec->u2_motion_type); + ps_dec->u2_prev_intra_mb = 0; + ps_dec->e_mb_pred = (e_pred_direction_t)u2_refPic; + ps_dec_mb_params = &ps_dec->ps_func_forw_or_back[u2_index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; + if(NULL == ps_dec_mb_params->pf_func_mb_params) + return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + + } + else if(u2_mb_type & MB_TYPE_INTRA) + { + ps_dec->u2_prev_intra_mb = 1; + impeg2d_dec_intra_mb(ps_dec); + + } + else + { + ps_dec->u2_prev_intra_mb =0; + ps_dec->e_mb_pred = FORW; + ps_dec->u2_motion_type = 0; + impeg2d_dec_0mv_coded_mb(ps_dec); + } + + /*-----------------------------------------------------------------------*/ + /* decode cbp */ + /*-----------------------------------------------------------------------*/ + if((u2_mb_type & MB_TYPE_INTRA)) + { + ps_dec->u2_cbp = 0x3f; + ps_dec->u2_prev_intra_mb = 1; + } + else + { + ps_dec->u2_prev_intra_mb = 0; + ps_dec->u2_def_dc_pred[Y_LUMA] = 128 << ps_dec->u2_intra_dc_precision; + ps_dec->u2_def_dc_pred[U_CHROMA] = 128 << ps_dec->u2_intra_dc_precision; + ps_dec->u2_def_dc_pred[V_CHROMA] = 128 << ps_dec->u2_intra_dc_precision; + if((ps_dec->u2_coded_mb)) + { + UWORD16 cbpValue; + cbpValue = gau2_impeg2d_cbp_code[impeg2d_bit_stream_nxt(ps_stream,MB_CBP_LEN)]; + ps_dec->u2_cbp = cbpValue & 0xFF; + impeg2d_bit_stream_flush(ps_stream,(cbpValue >> 8) & 0x0FF); + } + else + { + ps_dec->u2_cbp = 0; + } + } + return 0; +} +",0,"WORD32 impeg2d_dec_pnb_mb_params(dec_state_t *ps_dec) +{ + stream_t *ps_stream = &ps_dec->s_bit_stream; + UWORD16 u2_mb_addr_incr; + UWORD16 u2_total_len; + UWORD16 u2_len; + UWORD16 u2_mb_type; + UWORD32 u4_next_word; + const dec_mb_params_t *ps_dec_mb_params; + if(impeg2d_bit_stream_nxt(ps_stream,1) == 1) + { + impeg2d_bit_stream_flush(ps_stream,1); + + } + else + { + u2_mb_addr_incr = impeg2d_get_mb_addr_incr(ps_stream); + + if(ps_dec->u2_first_mb) + { + /****************************************************************/ + /* Section 6.3.17 */ + /* The first MB of a slice cannot be skipped */ + /* But the mb_addr_incr can be > 1, because at the beginning of */ + /* a slice, it indicates the offset from the last MB in the */ + /* previous row. Hence for the first slice in a row, the */ + /* mb_addr_incr needs to be 1. */ + /****************************************************************/ + /* MB_x is set to zero whenever MB_y changes. */ + ps_dec->u2_mb_x = u2_mb_addr_incr - 1; + /* For error resilience */ + ps_dec->u2_mb_x = MIN(ps_dec->u2_mb_x, (ps_dec->u2_num_horiz_mb - 1)); + + /****************************************************************/ + /* mb_addr_incr is forced to 1 because in this decoder it is used */ + /* more as an indicator of the number of MBs skipped than the */ + /* as defined by the standard (Section 6.3.17) */ + /****************************************************************/ + u2_mb_addr_incr = 1; + ps_dec->u2_first_mb = 0; + } + else + { + /****************************************************************/ + /* In MPEG-2, the last MB of the row cannot be skipped and the */ + /* mb_addr_incr cannot be such that it will take the current MB */ + /* beyond the current row */ + /* In MPEG-1, the slice could start and end anywhere and is not */ + /* restricted to a row like in MPEG-2. Hence this check should */ + /* not be done for MPEG-1 streams. */ + /****************************************************************/ + if(ps_dec->u2_is_mpeg2 && + ((ps_dec->u2_mb_x + u2_mb_addr_incr) > ps_dec->u2_num_horiz_mb)) + { + u2_mb_addr_incr = ps_dec->u2_num_horiz_mb - ps_dec->u2_mb_x; + } + + if ((u2_mb_addr_incr - 1) > ps_dec->u2_num_mbs_left) + { + /* If the number of skip MBs are more than the number of MBs + * left, indicate error. + */ + return IV_FAIL; + } + + impeg2d_dec_skip_mbs(ps_dec, (UWORD16)(u2_mb_addr_incr - 1)); + } + + } + u4_next_word = (UWORD16)impeg2d_bit_stream_nxt(ps_stream,16); + /*-----------------------------------------------------------------------*/ + /* MB type */ + /*-----------------------------------------------------------------------*/ + { + u2_mb_type = ps_dec->pu2_mb_type[BITS((UWORD16)u4_next_word,15,10)]; + u2_len = BITS(u2_mb_type,15,8); + u2_total_len = u2_len; + u4_next_word = (UWORD16)LSW((UWORD16)u4_next_word << u2_len); + } + /*-----------------------------------------------------------------------*/ + /* motion type */ + /*-----------------------------------------------------------------------*/ + { + WORD32 i4_motion_type = ps_dec->u2_motion_type; + + if((u2_mb_type & MB_FORW_OR_BACK) && ps_dec->u2_read_motion_type) + { + ps_dec->u2_motion_type = BITS((UWORD16)u4_next_word,15,14); + u2_total_len += MB_MOTION_TYPE_LEN; + u4_next_word = (UWORD16)LSW((UWORD16)u4_next_word << MB_MOTION_TYPE_LEN); + i4_motion_type = ps_dec->u2_motion_type; + + } + + + if ((u2_mb_type & MB_FORW_OR_BACK) && + ((i4_motion_type == 0) || + (i4_motion_type == 3) || + (i4_motion_type == 4) || + (i4_motion_type >= 7))) + { + i4_motion_type = 1; + } + + } + /*-----------------------------------------------------------------------*/ + /* dct type */ + /*-----------------------------------------------------------------------*/ + { + if((u2_mb_type & MB_CODED) && ps_dec->u2_read_dct_type) + { + ps_dec->u2_field_dct = BIT((UWORD16)u4_next_word,15); + u2_total_len += MB_DCT_TYPE_LEN; + u4_next_word = (UWORD16)LSW((UWORD16)u4_next_word << MB_DCT_TYPE_LEN); + } + } + /*-----------------------------------------------------------------------*/ + /* Quant scale code */ + /*-----------------------------------------------------------------------*/ + if(u2_mb_type & MB_QUANT) + { + UWORD16 u2_quant_scale_code; + u2_quant_scale_code = BITS((UWORD16)u4_next_word,15,11); + + ps_dec->u1_quant_scale = (ps_dec->u2_q_scale_type) ? + gau1_impeg2_non_linear_quant_scale[u2_quant_scale_code] : (u2_quant_scale_code << 1); + u2_total_len += MB_QUANT_SCALE_CODE_LEN; + } + impeg2d_bit_stream_flush(ps_stream,u2_total_len); + /*-----------------------------------------------------------------------*/ + /* Set the function pointers */ + /*-----------------------------------------------------------------------*/ + ps_dec->u2_coded_mb = (UWORD16)(u2_mb_type & MB_CODED); + + if(u2_mb_type & MB_BIDRECT) + { + UWORD16 u2_index = (ps_dec->u2_motion_type); + + ps_dec->u2_prev_intra_mb = 0; + ps_dec->e_mb_pred = BIDIRECT; + ps_dec_mb_params = &ps_dec->ps_func_bi_direct[u2_index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; + if(NULL == ps_dec_mb_params->pf_func_mb_params) + return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + } + else if(u2_mb_type & MB_FORW_OR_BACK) + { + + UWORD16 u2_refPic = !(u2_mb_type & MB_MV_FORW); + UWORD16 u2_index = (ps_dec->u2_motion_type); + ps_dec->u2_prev_intra_mb = 0; + ps_dec->e_mb_pred = (e_pred_direction_t)u2_refPic; + ps_dec_mb_params = &ps_dec->ps_func_forw_or_back[u2_index]; + ps_dec->s_mb_type = ps_dec_mb_params->s_mb_type; + if(NULL == ps_dec_mb_params->pf_func_mb_params) + return -1; + ps_dec_mb_params->pf_func_mb_params(ps_dec); + + } + else if(u2_mb_type & MB_TYPE_INTRA) + { + ps_dec->u2_prev_intra_mb = 1; + impeg2d_dec_intra_mb(ps_dec); + + } + else + { + ps_dec->u2_prev_intra_mb =0; + ps_dec->e_mb_pred = FORW; + ps_dec->u2_motion_type = 0; + impeg2d_dec_0mv_coded_mb(ps_dec); + } + + /*-----------------------------------------------------------------------*/ + /* decode cbp */ + /*-----------------------------------------------------------------------*/ + if((u2_mb_type & MB_TYPE_INTRA)) + { + ps_dec->u2_cbp = 0x3f; + ps_dec->u2_prev_intra_mb = 1; + } + else + { + ps_dec->u2_prev_intra_mb = 0; + ps_dec->u2_def_dc_pred[Y_LUMA] = 128 << ps_dec->u2_intra_dc_precision; + ps_dec->u2_def_dc_pred[U_CHROMA] = 128 << ps_dec->u2_intra_dc_precision; + ps_dec->u2_def_dc_pred[V_CHROMA] = 128 << ps_dec->u2_intra_dc_precision; + if((ps_dec->u2_coded_mb)) + { + UWORD16 cbpValue; + cbpValue = gau2_impeg2d_cbp_code[impeg2d_bit_stream_nxt(ps_stream,MB_CBP_LEN)]; + ps_dec->u2_cbp = cbpValue & 0xFF; + impeg2d_bit_stream_flush(ps_stream,(cbpValue >> 8) & 0x0FF); + } + else + { + ps_dec->u2_cbp = 0; + } + } + return 0; +} +","@@ -510,6 +510,12 @@ + + + if(ret) + return IMPEG2D_MB_TEX_DECODE_ERR; ++ ++ if(0 >= ps_dec->u2_num_mbs_left) ++ { ++ break; ++ } ++ + IMPEG2D_TRACE_MB_START(ps_dec->u2_mb_x, ps_dec->u2_mb_y); + + u4_x_dst_offset = u4_frm_offset + (ps_dec->u2_mb_x << 4); +",1930,2166,4096 +18177,"static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile) +{ + jpc_dec_tcomp_t *tcomp; + int compno; + int rlvlno; + jpc_dec_rlvl_t *rlvl; + jpc_dec_band_t *band; + jpc_dec_prc_t *prc; + int bndno; + jpc_tsfb_band_t *bnd; + int bandno; + jpc_dec_ccp_t *ccp; + int prccnt; + jpc_dec_cblk_t *cblk; + int cblkcnt; + uint_fast32_t tlprcxstart; + uint_fast32_t tlprcystart; + uint_fast32_t brprcxend; + uint_fast32_t brprcyend; + uint_fast32_t tlcbgxstart; + uint_fast32_t tlcbgystart; + uint_fast32_t brcbgxend; + uint_fast32_t brcbgyend; + uint_fast32_t cbgxstart; + uint_fast32_t cbgystart; + uint_fast32_t cbgxend; + uint_fast32_t cbgyend; + uint_fast32_t tlcblkxstart; + uint_fast32_t tlcblkystart; + uint_fast32_t brcblkxend; + uint_fast32_t brcblkyend; + uint_fast32_t cblkxstart; + uint_fast32_t cblkystart; + uint_fast32_t cblkxend; + uint_fast32_t cblkyend; + uint_fast32_t tmpxstart; + uint_fast32_t tmpystart; + uint_fast32_t tmpxend; + uint_fast32_t tmpyend; + jpc_dec_cp_t *cp; + jpc_tsfb_band_t bnds[64]; + jpc_pchg_t *pchg; + int pchgno; + jpc_dec_cmpt_t *cmpt; + + cp = tile->cp; + tile->realmode = 0; + if (cp->mctid == JPC_MCT_ICT) { + tile->realmode = 1; + } + + for (compno = 0, tcomp = tile->tcomps, cmpt = dec->cmpts; compno < + dec->numcomps; ++compno, ++tcomp, ++cmpt) { + ccp = &tile->cp->ccps[compno]; + if (ccp->qmfbid == JPC_COX_INS) { + tile->realmode = 1; + } + tcomp->numrlvls = ccp->numrlvls; + if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls, + sizeof(jpc_dec_rlvl_t)))) { + return -1; + } + if (!(tcomp->data = jas_seq2d_create(JPC_CEILDIV(tile->xstart, + cmpt->hstep), JPC_CEILDIV(tile->ystart, cmpt->vstep), + JPC_CEILDIV(tile->xend, cmpt->hstep), JPC_CEILDIV(tile->yend, + cmpt->vstep)))) { + return -1; + } + if (!(tcomp->tsfb = jpc_cod_gettsfb(ccp->qmfbid, + tcomp->numrlvls - 1))) { + return -1; + } + { + jpc_tsfb_getbands(tcomp->tsfb, jas_seq2d_xstart(tcomp->data), + jas_seq2d_ystart(tcomp->data), jas_seq2d_xend(tcomp->data), + jas_seq2d_yend(tcomp->data), bnds); + } + for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls; + ++rlvlno, ++rlvl) { + rlvl->bands = 0; + rlvl->xstart = JPC_CEILDIVPOW2(tcomp->xstart, + tcomp->numrlvls - 1 - rlvlno); + rlvl->ystart = JPC_CEILDIVPOW2(tcomp->ystart, + tcomp->numrlvls - 1 - rlvlno); + rlvl->xend = JPC_CEILDIVPOW2(tcomp->xend, + tcomp->numrlvls - 1 - rlvlno); + rlvl->yend = JPC_CEILDIVPOW2(tcomp->yend, + tcomp->numrlvls - 1 - rlvlno); + rlvl->prcwidthexpn = ccp->prcwidthexpns[rlvlno]; + rlvl->prcheightexpn = ccp->prcheightexpns[rlvlno]; + tlprcxstart = JPC_FLOORDIVPOW2(rlvl->xstart, + rlvl->prcwidthexpn) << rlvl->prcwidthexpn; + tlprcystart = JPC_FLOORDIVPOW2(rlvl->ystart, + rlvl->prcheightexpn) << rlvl->prcheightexpn; + brprcxend = JPC_CEILDIVPOW2(rlvl->xend, + rlvl->prcwidthexpn) << rlvl->prcwidthexpn; + brprcyend = JPC_CEILDIVPOW2(rlvl->yend, + rlvl->prcheightexpn) << rlvl->prcheightexpn; + rlvl->numhprcs = (brprcxend - tlprcxstart) >> + rlvl->prcwidthexpn; + rlvl->numvprcs = (brprcyend - tlprcystart) >> + rlvl->prcheightexpn; + rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs; + + if (rlvl->xstart >= rlvl->xend || rlvl->ystart >= rlvl->yend) { + rlvl->bands = 0; + rlvl->numprcs = 0; + rlvl->numhprcs = 0; + rlvl->numvprcs = 0; + continue; + } + if (!rlvlno) { + tlcbgxstart = tlprcxstart; + tlcbgystart = tlprcystart; + brcbgxend = brprcxend; + brcbgyend = brprcyend; + rlvl->cbgwidthexpn = rlvl->prcwidthexpn; + rlvl->cbgheightexpn = rlvl->prcheightexpn; + } else { + tlcbgxstart = JPC_CEILDIVPOW2(tlprcxstart, 1); + tlcbgystart = JPC_CEILDIVPOW2(tlprcystart, 1); + brcbgxend = JPC_CEILDIVPOW2(brprcxend, 1); + brcbgyend = JPC_CEILDIVPOW2(brprcyend, 1); + rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; + rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; + } + rlvl->cblkwidthexpn = JAS_MIN(ccp->cblkwidthexpn, + rlvl->cbgwidthexpn); + rlvl->cblkheightexpn = JAS_MIN(ccp->cblkheightexpn, + rlvl->cbgheightexpn); + + rlvl->numbands = (!rlvlno) ? 1 : 3; + if (!(rlvl->bands = jas_alloc2(rlvl->numbands, + sizeof(jpc_dec_band_t)))) { + return -1; + } + for (bandno = 0, band = rlvl->bands; + bandno < rlvl->numbands; ++bandno, ++band) { + bndno = (!rlvlno) ? 0 : (3 * (rlvlno - 1) + + bandno + 1); + bnd = &bnds[bndno]; + + band->orient = bnd->orient; + band->stepsize = ccp->stepsizes[bndno]; + band->analgain = JPC_NOMINALGAIN(ccp->qmfbid, + tcomp->numrlvls - 1, rlvlno, band->orient); + band->absstepsize = jpc_calcabsstepsize(band->stepsize, + cmpt->prec + band->analgain); + band->numbps = ccp->numguardbits + + JPC_QCX_GETEXPN(band->stepsize) - 1; + band->roishift = (ccp->roishift + band->numbps >= JPC_PREC) ? + (JPC_PREC - 1 - band->numbps) : ccp->roishift; + band->data = 0; + band->prcs = 0; + if (bnd->xstart == bnd->xend || bnd->ystart == bnd->yend) { + continue; + } + if (!(band->data = jas_seq2d_create(0, 0, 0, 0))) { + return -1; + } + jas_seq2d_bindsub(band->data, tcomp->data, bnd->locxstart, + bnd->locystart, bnd->locxend, bnd->locyend); + jas_seq2d_setshift(band->data, bnd->xstart, bnd->ystart); + + assert(rlvl->numprcs); + + if (!(band->prcs = jas_alloc2(rlvl->numprcs, + sizeof(jpc_dec_prc_t)))) { + return -1; + } + +/************************************************/ + cbgxstart = tlcbgxstart; + cbgystart = tlcbgystart; + for (prccnt = rlvl->numprcs, prc = band->prcs; + prccnt > 0; --prccnt, ++prc) { + cbgxend = cbgxstart + (1 << rlvl->cbgwidthexpn); + cbgyend = cbgystart + (1 << rlvl->cbgheightexpn); + prc->xstart = JAS_MAX(cbgxstart, JAS_CAST(uint_fast32_t, + jas_seq2d_xstart(band->data))); + prc->ystart = JAS_MAX(cbgystart, JAS_CAST(uint_fast32_t, + jas_seq2d_ystart(band->data))); + prc->xend = JAS_MIN(cbgxend, JAS_CAST(uint_fast32_t, + jas_seq2d_xend(band->data))); + prc->yend = JAS_MIN(cbgyend, JAS_CAST(uint_fast32_t, + jas_seq2d_yend(band->data))); + if (prc->xend > prc->xstart && prc->yend > prc->ystart) { + tlcblkxstart = JPC_FLOORDIVPOW2(prc->xstart, + rlvl->cblkwidthexpn) << rlvl->cblkwidthexpn; + tlcblkystart = JPC_FLOORDIVPOW2(prc->ystart, + rlvl->cblkheightexpn) << rlvl->cblkheightexpn; + brcblkxend = JPC_CEILDIVPOW2(prc->xend, + rlvl->cblkwidthexpn) << rlvl->cblkwidthexpn; + brcblkyend = JPC_CEILDIVPOW2(prc->yend, + rlvl->cblkheightexpn) << rlvl->cblkheightexpn; + prc->numhcblks = (brcblkxend - tlcblkxstart) >> + rlvl->cblkwidthexpn; + prc->numvcblks = (brcblkyend - tlcblkystart) >> + rlvl->cblkheightexpn; + prc->numcblks = prc->numhcblks * prc->numvcblks; + assert(prc->numcblks > 0); + + if (!(prc->incltagtree = jpc_tagtree_create( + prc->numhcblks, prc->numvcblks))) { + return -1; + } + if (!(prc->numimsbstagtree = jpc_tagtree_create( + prc->numhcblks, prc->numvcblks))) { + return -1; + } + if (!(prc->cblks = jas_alloc2(prc->numcblks, + sizeof(jpc_dec_cblk_t)))) { + return -1; + } + + cblkxstart = cbgxstart; + cblkystart = cbgystart; + for (cblkcnt = prc->numcblks, cblk = prc->cblks; + cblkcnt > 0;) { + cblkxend = cblkxstart + (1 << rlvl->cblkwidthexpn); + cblkyend = cblkystart + (1 << rlvl->cblkheightexpn); + tmpxstart = JAS_MAX(cblkxstart, prc->xstart); + tmpystart = JAS_MAX(cblkystart, prc->ystart); + tmpxend = JAS_MIN(cblkxend, prc->xend); + tmpyend = JAS_MIN(cblkyend, prc->yend); + if (tmpxend > tmpxstart && tmpyend > tmpystart) { + cblk->firstpassno = -1; + cblk->mqdec = 0; + cblk->nulldec = 0; + cblk->flags = 0; + cblk->numpasses = 0; + cblk->segs.head = 0; + cblk->segs.tail = 0; + cblk->curseg = 0; + cblk->numimsbs = 0; + cblk->numlenbits = 3; + cblk->flags = 0; + if (!(cblk->data = jas_seq2d_create(0, 0, 0, + 0))) { + return -1; + } + jas_seq2d_bindsub(cblk->data, band->data, + tmpxstart, tmpystart, tmpxend, tmpyend); + ++cblk; + --cblkcnt; + } + cblkxstart += 1 << rlvl->cblkwidthexpn; + if (cblkxstart >= cbgxend) { + cblkxstart = cbgxstart; + cblkystart += 1 << rlvl->cblkheightexpn; + } + } + + } else { + prc->cblks = 0; + prc->incltagtree = 0; + prc->numimsbstagtree = 0; + } + cbgxstart += 1 << rlvl->cbgwidthexpn; + if (cbgxstart >= brcbgxend) { + cbgxstart = tlcbgxstart; + cbgystart += 1 << rlvl->cbgheightexpn; + } + + } +/********************************************/ + } + } + } + + if (!(tile->pi = jpc_dec_pi_create(dec, tile))) { + return -1; + } + + for (pchgno = 0; pchgno < jpc_pchglist_numpchgs(tile->cp->pchglist); + ++pchgno) { + pchg = jpc_pchg_copy(jpc_pchglist_get(tile->cp->pchglist, pchgno)); + assert(pchg); + jpc_pi_addpchg(tile->pi, pchg); + } + jpc_pi_init(tile->pi); + + return 0; +} +",1,"static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile) +{ + jpc_dec_tcomp_t *tcomp; + int compno; + int rlvlno; + jpc_dec_rlvl_t *rlvl; + jpc_dec_band_t *band; + jpc_dec_prc_t *prc; + int bndno; + jpc_tsfb_band_t *bnd; + int bandno; + jpc_dec_ccp_t *ccp; + int prccnt; + jpc_dec_cblk_t *cblk; + int cblkcnt; + uint_fast32_t tlprcxstart; + uint_fast32_t tlprcystart; + uint_fast32_t brprcxend; + uint_fast32_t brprcyend; + uint_fast32_t tlcbgxstart; + uint_fast32_t tlcbgystart; + uint_fast32_t brcbgxend; + uint_fast32_t brcbgyend; + uint_fast32_t cbgxstart; + uint_fast32_t cbgystart; + uint_fast32_t cbgxend; + uint_fast32_t cbgyend; + uint_fast32_t tlcblkxstart; + uint_fast32_t tlcblkystart; + uint_fast32_t brcblkxend; + uint_fast32_t brcblkyend; + uint_fast32_t cblkxstart; + uint_fast32_t cblkystart; + uint_fast32_t cblkxend; + uint_fast32_t cblkyend; + uint_fast32_t tmpxstart; + uint_fast32_t tmpystart; + uint_fast32_t tmpxend; + uint_fast32_t tmpyend; + jpc_dec_cp_t *cp; + jpc_tsfb_band_t bnds[JPC_MAXBANDS]; + jpc_pchg_t *pchg; + int pchgno; + jpc_dec_cmpt_t *cmpt; + + cp = tile->cp; + tile->realmode = 0; + if (cp->mctid == JPC_MCT_ICT) { + tile->realmode = 1; + } + + for (compno = 0, tcomp = tile->tcomps, cmpt = dec->cmpts; compno < + dec->numcomps; ++compno, ++tcomp, ++cmpt) { + ccp = &tile->cp->ccps[compno]; + if (ccp->qmfbid == JPC_COX_INS) { + tile->realmode = 1; + } + tcomp->numrlvls = ccp->numrlvls; + if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls, + sizeof(jpc_dec_rlvl_t)))) { + return -1; + } + if (!(tcomp->data = jas_seq2d_create(JPC_CEILDIV(tile->xstart, + cmpt->hstep), JPC_CEILDIV(tile->ystart, cmpt->vstep), + JPC_CEILDIV(tile->xend, cmpt->hstep), JPC_CEILDIV(tile->yend, + cmpt->vstep)))) { + return -1; + } + if (!(tcomp->tsfb = jpc_cod_gettsfb(ccp->qmfbid, + tcomp->numrlvls - 1))) { + return -1; + } + { + jpc_tsfb_getbands(tcomp->tsfb, jas_seq2d_xstart(tcomp->data), + jas_seq2d_ystart(tcomp->data), jas_seq2d_xend(tcomp->data), + jas_seq2d_yend(tcomp->data), bnds); + } + for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls; + ++rlvlno, ++rlvl) { + rlvl->bands = 0; + rlvl->xstart = JPC_CEILDIVPOW2(tcomp->xstart, + tcomp->numrlvls - 1 - rlvlno); + rlvl->ystart = JPC_CEILDIVPOW2(tcomp->ystart, + tcomp->numrlvls - 1 - rlvlno); + rlvl->xend = JPC_CEILDIVPOW2(tcomp->xend, + tcomp->numrlvls - 1 - rlvlno); + rlvl->yend = JPC_CEILDIVPOW2(tcomp->yend, + tcomp->numrlvls - 1 - rlvlno); + rlvl->prcwidthexpn = ccp->prcwidthexpns[rlvlno]; + rlvl->prcheightexpn = ccp->prcheightexpns[rlvlno]; + tlprcxstart = JPC_FLOORDIVPOW2(rlvl->xstart, + rlvl->prcwidthexpn) << rlvl->prcwidthexpn; + tlprcystart = JPC_FLOORDIVPOW2(rlvl->ystart, + rlvl->prcheightexpn) << rlvl->prcheightexpn; + brprcxend = JPC_CEILDIVPOW2(rlvl->xend, + rlvl->prcwidthexpn) << rlvl->prcwidthexpn; + brprcyend = JPC_CEILDIVPOW2(rlvl->yend, + rlvl->prcheightexpn) << rlvl->prcheightexpn; + rlvl->numhprcs = (brprcxend - tlprcxstart) >> + rlvl->prcwidthexpn; + rlvl->numvprcs = (brprcyend - tlprcystart) >> + rlvl->prcheightexpn; + rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs; + + if (rlvl->xstart >= rlvl->xend || rlvl->ystart >= rlvl->yend) { + rlvl->bands = 0; + rlvl->numprcs = 0; + rlvl->numhprcs = 0; + rlvl->numvprcs = 0; + continue; + } + if (!rlvlno) { + tlcbgxstart = tlprcxstart; + tlcbgystart = tlprcystart; + brcbgxend = brprcxend; + brcbgyend = brprcyend; + rlvl->cbgwidthexpn = rlvl->prcwidthexpn; + rlvl->cbgheightexpn = rlvl->prcheightexpn; + } else { + tlcbgxstart = JPC_CEILDIVPOW2(tlprcxstart, 1); + tlcbgystart = JPC_CEILDIVPOW2(tlprcystart, 1); + brcbgxend = JPC_CEILDIVPOW2(brprcxend, 1); + brcbgyend = JPC_CEILDIVPOW2(brprcyend, 1); + rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; + rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; + } + rlvl->cblkwidthexpn = JAS_MIN(ccp->cblkwidthexpn, + rlvl->cbgwidthexpn); + rlvl->cblkheightexpn = JAS_MIN(ccp->cblkheightexpn, + rlvl->cbgheightexpn); + + rlvl->numbands = (!rlvlno) ? 1 : 3; + if (!(rlvl->bands = jas_alloc2(rlvl->numbands, + sizeof(jpc_dec_band_t)))) { + return -1; + } + for (bandno = 0, band = rlvl->bands; + bandno < rlvl->numbands; ++bandno, ++band) { + bndno = (!rlvlno) ? 0 : (3 * (rlvlno - 1) + + bandno + 1); + bnd = &bnds[bndno]; + + band->orient = bnd->orient; + band->stepsize = ccp->stepsizes[bndno]; + band->analgain = JPC_NOMINALGAIN(ccp->qmfbid, + tcomp->numrlvls - 1, rlvlno, band->orient); + band->absstepsize = jpc_calcabsstepsize(band->stepsize, + cmpt->prec + band->analgain); + band->numbps = ccp->numguardbits + + JPC_QCX_GETEXPN(band->stepsize) - 1; + band->roishift = (ccp->roishift + band->numbps >= JPC_PREC) ? + (JPC_PREC - 1 - band->numbps) : ccp->roishift; + band->data = 0; + band->prcs = 0; + if (bnd->xstart == bnd->xend || bnd->ystart == bnd->yend) { + continue; + } + if (!(band->data = jas_seq2d_create(0, 0, 0, 0))) { + return -1; + } + jas_seq2d_bindsub(band->data, tcomp->data, bnd->locxstart, + bnd->locystart, bnd->locxend, bnd->locyend); + jas_seq2d_setshift(band->data, bnd->xstart, bnd->ystart); + + assert(rlvl->numprcs); + + if (!(band->prcs = jas_alloc2(rlvl->numprcs, + sizeof(jpc_dec_prc_t)))) { + return -1; + } + +/************************************************/ + cbgxstart = tlcbgxstart; + cbgystart = tlcbgystart; + for (prccnt = rlvl->numprcs, prc = band->prcs; + prccnt > 0; --prccnt, ++prc) { + cbgxend = cbgxstart + (1 << rlvl->cbgwidthexpn); + cbgyend = cbgystart + (1 << rlvl->cbgheightexpn); + prc->xstart = JAS_MAX(cbgxstart, JAS_CAST(uint_fast32_t, + jas_seq2d_xstart(band->data))); + prc->ystart = JAS_MAX(cbgystart, JAS_CAST(uint_fast32_t, + jas_seq2d_ystart(band->data))); + prc->xend = JAS_MIN(cbgxend, JAS_CAST(uint_fast32_t, + jas_seq2d_xend(band->data))); + prc->yend = JAS_MIN(cbgyend, JAS_CAST(uint_fast32_t, + jas_seq2d_yend(band->data))); + if (prc->xend > prc->xstart && prc->yend > prc->ystart) { + tlcblkxstart = JPC_FLOORDIVPOW2(prc->xstart, + rlvl->cblkwidthexpn) << rlvl->cblkwidthexpn; + tlcblkystart = JPC_FLOORDIVPOW2(prc->ystart, + rlvl->cblkheightexpn) << rlvl->cblkheightexpn; + brcblkxend = JPC_CEILDIVPOW2(prc->xend, + rlvl->cblkwidthexpn) << rlvl->cblkwidthexpn; + brcblkyend = JPC_CEILDIVPOW2(prc->yend, + rlvl->cblkheightexpn) << rlvl->cblkheightexpn; + prc->numhcblks = (brcblkxend - tlcblkxstart) >> + rlvl->cblkwidthexpn; + prc->numvcblks = (brcblkyend - tlcblkystart) >> + rlvl->cblkheightexpn; + prc->numcblks = prc->numhcblks * prc->numvcblks; + assert(prc->numcblks > 0); + + if (!(prc->incltagtree = jpc_tagtree_create( + prc->numhcblks, prc->numvcblks))) { + return -1; + } + if (!(prc->numimsbstagtree = jpc_tagtree_create( + prc->numhcblks, prc->numvcblks))) { + return -1; + } + if (!(prc->cblks = jas_alloc2(prc->numcblks, + sizeof(jpc_dec_cblk_t)))) { + return -1; + } + + cblkxstart = cbgxstart; + cblkystart = cbgystart; + for (cblkcnt = prc->numcblks, cblk = prc->cblks; + cblkcnt > 0;) { + cblkxend = cblkxstart + (1 << rlvl->cblkwidthexpn); + cblkyend = cblkystart + (1 << rlvl->cblkheightexpn); + tmpxstart = JAS_MAX(cblkxstart, prc->xstart); + tmpystart = JAS_MAX(cblkystart, prc->ystart); + tmpxend = JAS_MIN(cblkxend, prc->xend); + tmpyend = JAS_MIN(cblkyend, prc->yend); + if (tmpxend > tmpxstart && tmpyend > tmpystart) { + cblk->firstpassno = -1; + cblk->mqdec = 0; + cblk->nulldec = 0; + cblk->flags = 0; + cblk->numpasses = 0; + cblk->segs.head = 0; + cblk->segs.tail = 0; + cblk->curseg = 0; + cblk->numimsbs = 0; + cblk->numlenbits = 3; + cblk->flags = 0; + if (!(cblk->data = jas_seq2d_create(0, 0, 0, + 0))) { + return -1; + } + jas_seq2d_bindsub(cblk->data, band->data, + tmpxstart, tmpystart, tmpxend, tmpyend); + ++cblk; + --cblkcnt; + } + cblkxstart += 1 << rlvl->cblkwidthexpn; + if (cblkxstart >= cbgxend) { + cblkxstart = cbgxstart; + cblkystart += 1 << rlvl->cblkheightexpn; + } + } + + } else { + prc->cblks = 0; + prc->incltagtree = 0; + prc->numimsbstagtree = 0; + } + cbgxstart += 1 << rlvl->cbgwidthexpn; + if (cbgxstart >= brcbgxend) { + cbgxstart = tlcbgxstart; + cbgystart += 1 << rlvl->cbgheightexpn; + } + + } +/********************************************/ + } + } + } + + if (!(tile->pi = jpc_dec_pi_create(dec, tile))) { + return -1; + } + + for (pchgno = 0; pchgno < jpc_pchglist_numpchgs(tile->cp->pchglist); + ++pchgno) { + pchg = jpc_pchg_copy(jpc_pchglist_get(tile->cp->pchglist, pchgno)); + assert(pchg); + jpc_pi_addpchg(tile->pi, pchg); + } + jpc_pi_init(tile->pi); + + return 0; +} +","@@ -712,7 +712,7 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile) + uint_fast32_t tmpxend; + uint_fast32_t tmpyend; + jpc_dec_cp_t *cp; +- jpc_tsfb_band_t bnds[64]; ++ jpc_tsfb_band_t bnds[JPC_MAXBANDS]; + jpc_pchg_t *pchg; + int pchgno; + jpc_dec_cmpt_t *cmpt;",3621,3857,4096 +6472,"static int iw_prepare_processing(struct iw_context *ctx, int w, int h) +{ + int i,j; + int output_maxcolorcode_int; + int strategy1, strategy2; + int flag; + + if(ctx->output_profile==0) { + iw_set_error(ctx,""Output profile not set""); + return 0; + } + + if(!ctx->prng) { + ctx->prng = iwpvt_prng_create(ctx); + } + + if(ctx->randomize) { + ctx->random_seed = iwpvt_util_randomize(ctx->prng); + } + + if(ctx->req.out_true_valid) { + ctx->resize_settings[IW_DIMENSION_H].out_true_size = ctx->req.out_true_width; + ctx->resize_settings[IW_DIMENSION_V].out_true_size = ctx->req.out_true_height; + } + else { + ctx->resize_settings[IW_DIMENSION_H].out_true_size = (double)w; + ctx->resize_settings[IW_DIMENSION_V].out_true_size = (double)h; + } + + if(!iw_check_image_dimensions(ctx,ctx->img1.width,ctx->img1.height)) { + return 0; + } + if(!iw_check_image_dimensions(ctx,w,h)) { + return 0; + } + + if(ctx->to_grayscale) { + prepare_grayscale(ctx); + } + + init_channel_info(ctx); + + ctx->img2.width = w; + ctx->img2.height = h; + + if(ctx->input_start_x<0) ctx->input_start_x=0; + if(ctx->input_start_y<0) ctx->input_start_y=0; + if(ctx->input_start_x>ctx->img1.width-1) ctx->input_start_x=ctx->img1.width-1; + if(ctx->input_start_y>ctx->img1.height-1) ctx->input_start_x=ctx->img1.height-1; + if(ctx->input_w<0) ctx->input_w = ctx->img1.width - ctx->input_start_x; + if(ctx->input_h<0) ctx->input_h = ctx->img1.height - ctx->input_start_y; + if(ctx->input_w<1) ctx->input_w = 1; + if(ctx->input_h<1) ctx->input_h = 1; + if(ctx->input_w>(ctx->img1.width-ctx->input_start_x)) ctx->input_w=ctx->img1.width-ctx->input_start_x; + if(ctx->input_h>(ctx->img1.height-ctx->input_start_y)) ctx->input_h=ctx->img1.height-ctx->input_start_y; + + if(ctx->req.output_cs_valid) { + ctx->img2cs = ctx->req.output_cs; + + if(ctx->output_profile&IW_PROFILE_ALWAYSLINEAR) { + if(ctx->img2cs.cstype!=IW_CSTYPE_LINEAR) { + iw_warning(ctx,""Forcing output colorspace to linear; required by the output format.""); + iw_make_linear_csdescr(&ctx->img2cs); + } + } + } + else { + if(ctx->output_profile&IW_PROFILE_ALWAYSLINEAR) { + iw_make_linear_csdescr(&ctx->img2cs); + } + else { + iw_make_srgb_csdescr_2(&ctx->img2cs); + } + } + + if(ctx->img1.sampletype!=IW_SAMPLETYPE_FLOATINGPOINT) { + ctx->input_maxcolorcode_int = (1 << ctx->img1.bit_depth)-1; + ctx->input_maxcolorcode = (double)ctx->input_maxcolorcode_int; + + for(i=0;iimg1_ci[i].maxcolorcode_int<=0) { + ctx->img1_ci[i].maxcolorcode_int = ctx->input_maxcolorcode_int; + } + ctx->img1_ci[i].maxcolorcode_dbl = (double)ctx->img1_ci[i].maxcolorcode_int; + + if(ctx->img1_ci[i].maxcolorcode_int != ctx->input_maxcolorcode_int) { + ctx->support_reduced_input_bitdepths = 1; + } + } + } + + if(ctx->support_reduced_input_bitdepths || + ctx->img1.sampletype==IW_SAMPLETYPE_FLOATINGPOINT) + { + for(i=0;iimg1_numchannels_physical;i++) { + ctx->img1_ci[i].disable_fast_get_sample=1; + } + } + + for(i=0;i<2;i++) { // horizontal, vertical + for(j=0;j<3;j++) { // red, green, blue + if(fabs(ctx->resize_settings[i].channel_offset[j])>0.00001) { + ctx->resize_settings[i].use_offset=1; + } + } + } + + if(ctx->to_grayscale && + (ctx->resize_settings[IW_DIMENSION_H].use_offset || + ctx->resize_settings[IW_DIMENSION_V].use_offset) ) + { + iw_warning(ctx,""Disabling channel offset, due to grayscale output.""); + ctx->resize_settings[IW_DIMENSION_H].use_offset=0; + ctx->resize_settings[IW_DIMENSION_V].use_offset=0; + } + + decide_how_to_apply_bkgd(ctx); + + for(i=0;i<2;i++) { + if(ctx->resize_settings[i].use_offset || + (ctx->apply_bkgd && + ctx->apply_bkgd_strategy==IW_BKGD_STRATEGY_EARLY && + ctx->resize_settings[i].edge_policy==IW_EDGE_POLICY_TRANSPARENT)) + { + ctx->resize_settings[i].disable_rrctx_cache=1; + } + } + + decide_strategy(ctx,&strategy1,&strategy2); + + switch(strategy1) { // input-to-intermediate + case IW_STRAT1_RGBA_RGBA: + ctx->intermed_imgtype = IW_IMGTYPE_RGBA; + break; + case IW_STRAT1_GA_RGBA: + ctx->intermed_imgtype = IW_IMGTYPE_RGBA; + ctx->intermed_ci[0].corresponding_input_channel=0; + ctx->intermed_ci[1].corresponding_input_channel=0; + ctx->intermed_ci[2].corresponding_input_channel=0; + ctx->intermed_ci[3].corresponding_input_channel=1; + break; + case IW_STRAT1_RGB_RGB: + case IW_STRAT1_RGBA_RGB: + ctx->intermed_imgtype = IW_IMGTYPE_RGB; + break; + case IW_STRAT1_G_RGB: + case IW_STRAT1_GA_RGB: + ctx->intermed_imgtype = IW_IMGTYPE_RGB; + ctx->intermed_ci[0].corresponding_input_channel=0; + ctx->intermed_ci[1].corresponding_input_channel=0; + ctx->intermed_ci[2].corresponding_input_channel=0; + break; + case IW_STRAT1_RGBA_GA: + ctx->intermed_imgtype = IW_IMGTYPE_GRAYA; + ctx->intermed_ci[0].cvt_to_grayscale=1; + ctx->intermed_ci[0].corresponding_input_channel=0; + ctx->intermed_ci[1].corresponding_input_channel=3; + break; + case IW_STRAT1_GA_GA: + ctx->intermed_imgtype = IW_IMGTYPE_GRAYA; + break; + case IW_STRAT1_RGB_G: + ctx->intermed_imgtype = IW_IMGTYPE_GRAY; + ctx->intermed_ci[0].cvt_to_grayscale=1; + ctx->intermed_ci[0].corresponding_input_channel=0; + break; + case IW_STRAT1_G_G: + ctx->intermed_imgtype = IW_IMGTYPE_GRAY; + ctx->intermed_ci[0].corresponding_input_channel=0; + break; + default: + iw_set_errorf(ctx,""Internal error, unknown strategy %d"",strategy1); + return 0; + } + + ctx->intermed_numchannels = iw_imgtype_num_channels(ctx->intermed_imgtype); + ctx->intermed_alpha_channel_index = iw_imgtype_alpha_channel_index(ctx->intermed_imgtype); + + for(i=0;iintermed_numchannels;i++) { + ctx->intermed_ci[i].corresponding_output_channel = i; + } + + switch(strategy2) { // intermediate-to-output + case IW_STRAT2_RGBA_RGBA: + ctx->img2.imgtype = IW_IMGTYPE_RGBA; + break; + case IW_STRAT2_RGB_RGB: + ctx->img2.imgtype = IW_IMGTYPE_RGB; + break; + case IW_STRAT2_RGBA_RGB: + ctx->img2.imgtype = IW_IMGTYPE_RGB; + ctx->intermed_ci[3].corresponding_output_channel= -1; + break; + case IW_STRAT2_GA_GA: + ctx->img2.imgtype = IW_IMGTYPE_GRAYA; + break; + case IW_STRAT2_G_G: + ctx->img2.imgtype = IW_IMGTYPE_GRAY; + break; + case IW_STRAT2_GA_G: + ctx->img2.imgtype = IW_IMGTYPE_GRAY; + ctx->intermed_ci[1].corresponding_output_channel= -1; + break; + default: + iw_set_error(ctx,""Internal error""); + return 0; + } + + ctx->img2_numchannels = iw_imgtype_num_channels(ctx->img2.imgtype); + + iw_set_intermed_channeltypes(ctx); + iw_set_out_channeltypes(ctx); + + if(IW_IMGTYPE_HAS_ALPHA(ctx->intermed_imgtype)) { + for(i=0;iintermed_numchannels;i++) { + if(ctx->intermed_ci[i].channeltype!=IW_CHANNELTYPE_ALPHA) + ctx->intermed_ci[i].need_unassoc_alpha_processing = 1; + } + } + + + decide_output_bit_depth(ctx); + + if(ctx->img2.sampletype==IW_SAMPLETYPE_FLOATINGPOINT) { + flag=0; + for(i=0;ireq.color_count[i]) flag=1; + } + if(flag) { + iw_warning(ctx,""Posterization is not supported with floating point output.""); + } + } + else { + output_maxcolorcode_int = (1 << ctx->img2.bit_depth)-1; + + for(i=0;iimg2_numchannels;i++) { + ctx->img2_ci[i].maxcolorcode_int = output_maxcolorcode_int; + } + + if((ctx->output_profile&IW_PROFILE_REDUCEDBITDEPTHS)) { + for(i=0;iimg2_numchannels;i++) { + int mccr; + mccr = ctx->req.output_maxcolorcode[ctx->img2_ci[i].channeltype]; + if(mccr>0) { + if(mccr>output_maxcolorcode_int) mccr=output_maxcolorcode_int; + ctx->img2_ci[i].maxcolorcode_int = mccr; + } + } + } + + for(i=0;iimg2_numchannels;i++) { + if(ctx->img2_ci[i].maxcolorcode_int != output_maxcolorcode_int) { + ctx->reduced_output_maxcolor_flag = 1; + ctx->disable_output_lookup_tables = 1; + } + + ctx->img2_ci[i].maxcolorcode_dbl = (double)ctx->img2_ci[i].maxcolorcode_int; + } + } + + for(i=0;iimg2_numchannels;i++) { + ctx->img2_ci[i].color_count = ctx->req.color_count[ctx->img2_ci[i].channeltype]; + if(ctx->img2_ci[i].color_count) { + iw_restrict_to_range(2,ctx->img2_ci[i].maxcolorcode_int,&ctx->img2_ci[i].color_count); + } + if(ctx->img2_ci[i].color_count==1+ctx->img2_ci[i].maxcolorcode_int) { + ctx->img2_ci[i].color_count = 0; + } + + ctx->img2_ci[i].ditherfamily = ctx->ditherfamily_by_channeltype[ctx->img2_ci[i].channeltype]; + ctx->img2_ci[i].dithersubtype = ctx->dithersubtype_by_channeltype[ctx->img2_ci[i].channeltype]; + } + + for(i=0;iimg2_numchannels;i++) { + if(ctx->img2_ci[i].ditherfamily==IW_DITHERFAMILY_ERRDIFF) { + ctx->uses_errdiffdither=1; + } + } + + if(!ctx->support_reduced_input_bitdepths && ctx->img1.sampletype==IW_SAMPLETYPE_UINT) { + iw_make_x_to_linear_table(ctx,&ctx->input_color_corr_table,&ctx->img1,&ctx->img1cs); + } + + if(ctx->img1_bkgd_label_set) { + for(i=0;i<3;i++) { + ctx->img1_bkgd_label_lin.c[i] = x_to_linear_sample(ctx->img1_bkgd_label_inputcs.c[i],&ctx->img1cs); + } + ctx->img1_bkgd_label_lin.c[3] = ctx->img1_bkgd_label_inputcs.c[3]; + } + + if(ctx->apply_bkgd) { + prepare_apply_bkgd(ctx); + } + + if(ctx->req.output_rendering_intent==IW_INTENT_UNKNOWN) { + ctx->img2.rendering_intent = ctx->img1.rendering_intent; + } + else { + ctx->img2.rendering_intent = ctx->req.output_rendering_intent; + } + + if(ctx->resize_settings[IW_DIMENSION_H].family==IW_RESIZETYPE_AUTO) { + iw_set_auto_resizetype(ctx,ctx->input_w,ctx->img2.width,IW_DIMENSION_H); + } + if(ctx->resize_settings[IW_DIMENSION_V].family==IW_RESIZETYPE_AUTO) { + iw_set_auto_resizetype(ctx,ctx->input_h,ctx->img2.height,IW_DIMENSION_V); + } + + if(IW_IMGTYPE_HAS_ALPHA(ctx->img2.imgtype)) { + if(!ctx->opt_strip_alpha) { + ctx->opt_palette = 0; + ctx->opt_binary_trns = 0; + } + } + + return 1; +} +",0,"static int iw_prepare_processing(struct iw_context *ctx, int w, int h) +{ + int i,j; + int output_maxcolorcode_int; + int strategy1, strategy2; + int flag; + + if(ctx->output_profile==0) { + iw_set_error(ctx,""Output profile not set""); + return 0; + } + + if(!ctx->prng) { + ctx->prng = iwpvt_prng_create(ctx); + } + + if(ctx->randomize) { + ctx->random_seed = iwpvt_util_randomize(ctx->prng); + } + + if(ctx->req.out_true_valid) { + ctx->resize_settings[IW_DIMENSION_H].out_true_size = ctx->req.out_true_width; + ctx->resize_settings[IW_DIMENSION_V].out_true_size = ctx->req.out_true_height; + } + else { + ctx->resize_settings[IW_DIMENSION_H].out_true_size = (double)w; + ctx->resize_settings[IW_DIMENSION_V].out_true_size = (double)h; + } + + if(!iw_check_image_dimensions(ctx,ctx->img1.width,ctx->img1.height)) { + return 0; + } + if(!iw_check_image_dimensions(ctx,w,h)) { + return 0; + } + + if(ctx->to_grayscale) { + prepare_grayscale(ctx); + } + + init_channel_info(ctx); + + ctx->img2.width = w; + ctx->img2.height = h; + + if(ctx->input_start_x<0) ctx->input_start_x=0; + if(ctx->input_start_y<0) ctx->input_start_y=0; + if(ctx->input_start_x>ctx->img1.width-1) ctx->input_start_x=ctx->img1.width-1; + if(ctx->input_start_y>ctx->img1.height-1) ctx->input_start_x=ctx->img1.height-1; + if(ctx->input_w<0) ctx->input_w = ctx->img1.width - ctx->input_start_x; + if(ctx->input_h<0) ctx->input_h = ctx->img1.height - ctx->input_start_y; + if(ctx->input_w<1) ctx->input_w = 1; + if(ctx->input_h<1) ctx->input_h = 1; + if(ctx->input_w>(ctx->img1.width-ctx->input_start_x)) ctx->input_w=ctx->img1.width-ctx->input_start_x; + if(ctx->input_h>(ctx->img1.height-ctx->input_start_y)) ctx->input_h=ctx->img1.height-ctx->input_start_y; + + if(ctx->req.output_cs_valid) { + ctx->img2cs = ctx->req.output_cs; + + if(ctx->output_profile&IW_PROFILE_ALWAYSLINEAR) { + if(ctx->img2cs.cstype!=IW_CSTYPE_LINEAR) { + iw_warning(ctx,""Forcing output colorspace to linear; required by the output format.""); + iw_make_linear_csdescr(&ctx->img2cs); + } + } + } + else { + if(ctx->output_profile&IW_PROFILE_ALWAYSLINEAR) { + iw_make_linear_csdescr(&ctx->img2cs); + } + else { + iw_make_srgb_csdescr_2(&ctx->img2cs); + } + } + + if(ctx->img1.sampletype!=IW_SAMPLETYPE_FLOATINGPOINT) { + ctx->input_maxcolorcode_int = (1 << ctx->img1.bit_depth)-1; + ctx->input_maxcolorcode = (double)ctx->input_maxcolorcode_int; + + for(i=0;iimg1_ci[i].maxcolorcode_int<=0) { + ctx->img1_ci[i].maxcolorcode_int = ctx->input_maxcolorcode_int; + } + ctx->img1_ci[i].maxcolorcode_dbl = (double)ctx->img1_ci[i].maxcolorcode_int; + + if(ctx->img1_ci[i].maxcolorcode_int != ctx->input_maxcolorcode_int) { + ctx->support_reduced_input_bitdepths = 1; + } + } + } + + if(ctx->support_reduced_input_bitdepths || + ctx->img1.sampletype==IW_SAMPLETYPE_FLOATINGPOINT) + { + for(i=0;iimg1_numchannels_physical;i++) { + ctx->img1_ci[i].disable_fast_get_sample=1; + } + } + + for(i=0;i<2;i++) { // horizontal, vertical + for(j=0;j<3;j++) { // red, green, blue + if(fabs(ctx->resize_settings[i].channel_offset[j])>0.00001) { + ctx->resize_settings[i].use_offset=1; + } + } + } + + if(ctx->to_grayscale && + (ctx->resize_settings[IW_DIMENSION_H].use_offset || + ctx->resize_settings[IW_DIMENSION_V].use_offset) ) + { + iw_warning(ctx,""Disabling channel offset, due to grayscale output.""); + ctx->resize_settings[IW_DIMENSION_H].use_offset=0; + ctx->resize_settings[IW_DIMENSION_V].use_offset=0; + } + + decide_how_to_apply_bkgd(ctx); + + for(i=0;i<2;i++) { + if(ctx->resize_settings[i].use_offset || + (ctx->apply_bkgd && + ctx->apply_bkgd_strategy==IW_BKGD_STRATEGY_EARLY && + ctx->resize_settings[i].edge_policy==IW_EDGE_POLICY_TRANSPARENT)) + { + ctx->resize_settings[i].disable_rrctx_cache=1; + } + } + + decide_strategy(ctx,&strategy1,&strategy2); + + switch(strategy1) { // input-to-intermediate + case IW_STRAT1_RGBA_RGBA: + ctx->intermed_imgtype = IW_IMGTYPE_RGBA; + break; + case IW_STRAT1_GA_RGBA: + ctx->intermed_imgtype = IW_IMGTYPE_RGBA; + ctx->intermed_ci[0].corresponding_input_channel=0; + ctx->intermed_ci[1].corresponding_input_channel=0; + ctx->intermed_ci[2].corresponding_input_channel=0; + ctx->intermed_ci[3].corresponding_input_channel=1; + break; + case IW_STRAT1_RGB_RGB: + case IW_STRAT1_RGBA_RGB: + ctx->intermed_imgtype = IW_IMGTYPE_RGB; + break; + case IW_STRAT1_G_RGB: + case IW_STRAT1_GA_RGB: + ctx->intermed_imgtype = IW_IMGTYPE_RGB; + ctx->intermed_ci[0].corresponding_input_channel=0; + ctx->intermed_ci[1].corresponding_input_channel=0; + ctx->intermed_ci[2].corresponding_input_channel=0; + break; + case IW_STRAT1_RGBA_GA: + ctx->intermed_imgtype = IW_IMGTYPE_GRAYA; + ctx->intermed_ci[0].cvt_to_grayscale=1; + ctx->intermed_ci[0].corresponding_input_channel=0; + ctx->intermed_ci[1].corresponding_input_channel=3; + break; + case IW_STRAT1_GA_GA: + ctx->intermed_imgtype = IW_IMGTYPE_GRAYA; + break; + case IW_STRAT1_RGB_G: + ctx->intermed_imgtype = IW_IMGTYPE_GRAY; + ctx->intermed_ci[0].cvt_to_grayscale=1; + ctx->intermed_ci[0].corresponding_input_channel=0; + break; + case IW_STRAT1_G_G: + ctx->intermed_imgtype = IW_IMGTYPE_GRAY; + ctx->intermed_ci[0].corresponding_input_channel=0; + break; + default: + iw_set_errorf(ctx,""Internal error, unknown strategy %d"",strategy1); + return 0; + } + + ctx->intermed_numchannels = iw_imgtype_num_channels(ctx->intermed_imgtype); + ctx->intermed_alpha_channel_index = iw_imgtype_alpha_channel_index(ctx->intermed_imgtype); + + for(i=0;iintermed_numchannels;i++) { + ctx->intermed_ci[i].corresponding_output_channel = i; + } + + switch(strategy2) { // intermediate-to-output + case IW_STRAT2_RGBA_RGBA: + ctx->img2.imgtype = IW_IMGTYPE_RGBA; + break; + case IW_STRAT2_RGB_RGB: + ctx->img2.imgtype = IW_IMGTYPE_RGB; + break; + case IW_STRAT2_RGBA_RGB: + ctx->img2.imgtype = IW_IMGTYPE_RGB; + ctx->intermed_ci[3].corresponding_output_channel= -1; + break; + case IW_STRAT2_GA_GA: + ctx->img2.imgtype = IW_IMGTYPE_GRAYA; + break; + case IW_STRAT2_G_G: + ctx->img2.imgtype = IW_IMGTYPE_GRAY; + break; + case IW_STRAT2_GA_G: + ctx->img2.imgtype = IW_IMGTYPE_GRAY; + ctx->intermed_ci[1].corresponding_output_channel= -1; + break; + default: + iw_set_error(ctx,""Internal error""); + return 0; + } + + ctx->img2_numchannels = iw_imgtype_num_channels(ctx->img2.imgtype); + + iw_set_intermed_channeltypes(ctx); + iw_set_out_channeltypes(ctx); + + if(IW_IMGTYPE_HAS_ALPHA(ctx->intermed_imgtype)) { + for(i=0;iintermed_numchannels;i++) { + if(ctx->intermed_ci[i].channeltype!=IW_CHANNELTYPE_ALPHA) + ctx->intermed_ci[i].need_unassoc_alpha_processing = 1; + } + } + + + decide_output_bit_depth(ctx); + + if(ctx->img2.sampletype==IW_SAMPLETYPE_FLOATINGPOINT) { + flag=0; + for(i=0;ireq.color_count[i]) flag=1; + } + if(flag) { + iw_warning(ctx,""Posterization is not supported with floating point output.""); + } + } + else { + output_maxcolorcode_int = (1 << ctx->img2.bit_depth)-1; + + for(i=0;iimg2_numchannels;i++) { + ctx->img2_ci[i].maxcolorcode_int = output_maxcolorcode_int; + } + + if((ctx->output_profile&IW_PROFILE_REDUCEDBITDEPTHS)) { + for(i=0;iimg2_numchannels;i++) { + int mccr; + mccr = ctx->req.output_maxcolorcode[ctx->img2_ci[i].channeltype]; + if(mccr>0) { + if(mccr>output_maxcolorcode_int) mccr=output_maxcolorcode_int; + ctx->img2_ci[i].maxcolorcode_int = mccr; + } + } + } + + for(i=0;iimg2_numchannels;i++) { + if(ctx->img2_ci[i].maxcolorcode_int != output_maxcolorcode_int) { + ctx->reduced_output_maxcolor_flag = 1; + ctx->disable_output_lookup_tables = 1; + } + + ctx->img2_ci[i].maxcolorcode_dbl = (double)ctx->img2_ci[i].maxcolorcode_int; + } + } + + for(i=0;iimg2_numchannels;i++) { + ctx->img2_ci[i].color_count = ctx->req.color_count[ctx->img2_ci[i].channeltype]; + if(ctx->img2_ci[i].color_count) { + iw_restrict_to_range(2,ctx->img2_ci[i].maxcolorcode_int,&ctx->img2_ci[i].color_count); + } + if(ctx->img2_ci[i].color_count==1+ctx->img2_ci[i].maxcolorcode_int) { + ctx->img2_ci[i].color_count = 0; + } + + ctx->img2_ci[i].ditherfamily = ctx->ditherfamily_by_channeltype[ctx->img2_ci[i].channeltype]; + ctx->img2_ci[i].dithersubtype = ctx->dithersubtype_by_channeltype[ctx->img2_ci[i].channeltype]; + } + + for(i=0;iimg2_numchannels;i++) { + if(ctx->img2_ci[i].ditherfamily==IW_DITHERFAMILY_ERRDIFF) { + ctx->uses_errdiffdither=1; + } + } + + if(!ctx->support_reduced_input_bitdepths && ctx->img1.sampletype==IW_SAMPLETYPE_UINT) { + iw_make_x_to_linear_table(ctx,&ctx->input_color_corr_table,&ctx->img1,&ctx->img1cs); + } + + if(ctx->img1_bkgd_label_set) { + for(i=0;i<3;i++) { + ctx->img1_bkgd_label_lin.c[i] = x_to_linear_sample(ctx->img1_bkgd_label_inputcs.c[i],&ctx->img1cs); + } + ctx->img1_bkgd_label_lin.c[3] = ctx->img1_bkgd_label_inputcs.c[3]; + } + + if(ctx->apply_bkgd) { + prepare_apply_bkgd(ctx); + } + + if(ctx->req.output_rendering_intent==IW_INTENT_UNKNOWN) { + ctx->img2.rendering_intent = ctx->img1.rendering_intent; + } + else { + ctx->img2.rendering_intent = ctx->req.output_rendering_intent; + } + + if(ctx->resize_settings[IW_DIMENSION_H].family==IW_RESIZETYPE_AUTO) { + iw_set_auto_resizetype(ctx,ctx->input_w,ctx->img2.width,IW_DIMENSION_H); + } + if(ctx->resize_settings[IW_DIMENSION_V].family==IW_RESIZETYPE_AUTO) { + iw_set_auto_resizetype(ctx,ctx->input_h,ctx->img2.height,IW_DIMENSION_V); + } + + if(IW_IMGTYPE_HAS_ALPHA(ctx->img2.imgtype)) { + if(!ctx->opt_strip_alpha) { + ctx->opt_palette = 0; + ctx->opt_binary_trns = 0; + } + } + + return 1; +} +","@@ -922,8 +922,6 @@ static int iw_process_cols_to_intermediate(struct iw_context *ctx, int channel, + return retval; + } + +-// 'handle_alpha_flag' must be set if an alpha channel exists and this is not +-// the alpha channel. + static int iw_process_rows_intermediate_to_final(struct iw_context *ctx, int intermed_channel, + const struct iw_csdescr *out_csdescr) + { +@@ -951,13 +949,27 @@ static int iw_process_rows_intermediate_to_final(struct iw_context *ctx, int int + iw_tmpsample *out_pix = NULL; + int num_in_pix; + int num_out_pix; ++ struct iw_channelinfo_out default_ci_out; + + num_in_pix = ctx->intermed_canvas_width; + num_out_pix = ctx->img2.width; + + int_ci = &ctx->intermed_ci[intermed_channel]; + output_channel = int_ci->corresponding_output_channel; +- out_ci = &ctx->img2_ci[output_channel]; ++ if(output_channel>=0) { ++ out_ci = &ctx->img2_ci[output_channel]; ++ } ++ else { ++ // If there is no output channelinfo struct, create a temporary one to ++ // use. ++ // TODO: This is admittedly ugly, but we use these settings for a few ++ // things even when there is no corresponding output channel, and I ++ // don't remember exactly why. ++ iw_zeromem(&default_ci_out, sizeof(struct iw_channelinfo_out)); ++ default_ci_out.channeltype = IW_CHANNELTYPE_NONALPHA; ++ out_ci = &default_ci_out; ++ } ++ + is_alpha_channel = (int_ci->channeltype==IW_CHANNELTYPE_ALPHA); + bkgd_has_transparency = iw_bkgd_has_transparency(ctx); + ",3080,3316,4096 +7479,"static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) +{ + int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; + int ld; + int save_point = temp_alloc_save(f); + float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); + float *u=NULL,*v=NULL; + float *A = f->A[blocktype]; + + + + + + + + { + float *d,*e, *AA, *e_stop; + d = &buf2[n2-2]; + AA = A; + e = &buffer[0]; + e_stop = &buffer[n2]; + while (e != e_stop) { + d[1] = (e[0] * AA[0] - e[2]*AA[1]); + d[0] = (e[0] * AA[1] + e[2]*AA[0]); + d -= 2; + AA += 2; + e += 4; + } + + e = &buffer[n2-3]; + while (d >= buf2) { + d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); + d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); + d -= 2; + AA += 2; + e -= 4; + } + } + + + u = buffer; + v = buf2; + + { + float *AA = &A[n2-8]; + float *d0,*d1, *e0, *e1; + + e0 = &v[n4]; + e1 = &v[0]; + + d0 = &u[n4]; + d1 = &u[0]; + + while (AA >= A) { + float v40_20, v41_21; + + v41_21 = e0[1] - e1[1]; + v40_20 = e0[0] - e1[0]; + d0[1] = e0[1] + e1[1]; + d0[0] = e0[0] + e1[0]; + d1[1] = v41_21*AA[4] - v40_20*AA[5]; + d1[0] = v40_20*AA[4] + v41_21*AA[5]; + + v41_21 = e0[3] - e1[3]; + v40_20 = e0[2] - e1[2]; + d0[3] = e0[3] + e1[3]; + d0[2] = e0[2] + e1[2]; + d1[3] = v41_21*AA[0] - v40_20*AA[1]; + d1[2] = v40_20*AA[0] + v41_21*AA[1]; + + AA -= 8; + + d0 += 4; + d1 += 4; + e0 += 4; + e1 += 4; + } + } + + ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + + + + imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); + imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); + + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); + + l=2; + for (; l < (ld-3)>>1; ++l) { + int k0 = n >> (l+2), k0_2 = k0>>1; + int lim = 1 << (l+1); + int i; + for (i=0; i < lim; ++i) + imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); + } + + for (; l < ld-6; ++l) { + int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; + int rlim = n >> (l+6), r; + int lim = 1 << (l+1); + int i_off; + float *A0 = A; + i_off = n2-1; + for (r=rlim; r > 0; --r) { + imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); + A0 += k1*4; + i_off -= 8; + } + } + + imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); + + + { + uint16 *bitrev = f->bit_reverse[blocktype]; + + float *d0 = &v[n4-4]; + float *d1 = &v[n2-4]; + while (d0 >= v) { + int k4; + + k4 = bitrev[0]; + d1[3] = u[k4+0]; + d1[2] = u[k4+1]; + d0[3] = u[k4+2]; + d0[2] = u[k4+3]; + + k4 = bitrev[1]; + d1[1] = u[k4+0]; + d1[0] = u[k4+1]; + d0[1] = u[k4+2]; + d0[0] = u[k4+3]; + + d0 -= 4; + d1 -= 4; + bitrev += 2; + } + } + + + assert(v == buf2); + + { + float *C = f->C[blocktype]; + float *d, *e; + + d = v; + e = v + n2 - 4; + + while (d < e) { + float a02,a11,b0,b1,b2,b3; + + a02 = d[0] - e[2]; + a11 = d[1] + e[3]; + + b0 = C[1]*a02 + C[0]*a11; + b1 = C[1]*a11 - C[0]*a02; + + b2 = d[0] + e[ 2]; + b3 = d[1] - e[ 3]; + + d[0] = b2 + b0; + d[1] = b3 + b1; + e[2] = b2 - b0; + e[3] = b1 - b3; + + a02 = d[2] - e[0]; + a11 = d[3] + e[1]; + + b0 = C[3]*a02 + C[2]*a11; + b1 = C[3]*a11 - C[2]*a02; + + b2 = d[2] + e[ 0]; + b3 = d[3] - e[ 1]; + + d[2] = b2 + b0; + d[3] = b3 + b1; + e[0] = b2 - b0; + e[1] = b1 - b3; + + C += 4; + d += 4; + e -= 4; + } + } + + + + + + { + float *d0,*d1,*d2,*d3; + + float *B = f->B[blocktype] + n2 - 8; + float *e = buf2 + n2 - 8; + d0 = &buffer[0]; + d1 = &buffer[n2-4]; + d2 = &buffer[n2]; + d3 = &buffer[n-4]; + while (e >= v) { + float p0,p1,p2,p3; + + p3 = e[6]*B[7] - e[7]*B[6]; + p2 = -e[6]*B[6] - e[7]*B[7]; + + d0[0] = p3; + d1[3] = - p3; + d2[0] = p2; + d3[3] = p2; + + p1 = e[4]*B[5] - e[5]*B[4]; + p0 = -e[4]*B[4] - e[5]*B[5]; + + d0[1] = p1; + d1[2] = - p1; + d2[1] = p0; + d3[2] = p0; + + p3 = e[2]*B[3] - e[3]*B[2]; + p2 = -e[2]*B[2] - e[3]*B[3]; + + d0[2] = p3; + d1[1] = - p3; + d2[2] = p2; + d3[1] = p2; + + p1 = e[0]*B[1] - e[1]*B[0]; + p0 = -e[0]*B[0] - e[1]*B[1]; + + d0[3] = p1; + d1[0] = - p1; + d2[3] = p0; + d3[0] = p0; + + B -= 8; + e -= 8; + d0 += 4; + d2 += 4; + d1 -= 4; + d3 -= 4; + } + } + + temp_free(f,buf2); + temp_alloc_restore(f,save_point); +} +",0,"static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) +{ + int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; + int ld; + int save_point = temp_alloc_save(f); + float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); + float *u=NULL,*v=NULL; + float *A = f->A[blocktype]; + + + + + + + + { + float *d,*e, *AA, *e_stop; + d = &buf2[n2-2]; + AA = A; + e = &buffer[0]; + e_stop = &buffer[n2]; + while (e != e_stop) { + d[1] = (e[0] * AA[0] - e[2]*AA[1]); + d[0] = (e[0] * AA[1] + e[2]*AA[0]); + d -= 2; + AA += 2; + e += 4; + } + + e = &buffer[n2-3]; + while (d >= buf2) { + d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); + d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); + d -= 2; + AA += 2; + e -= 4; + } + } + + + u = buffer; + v = buf2; + + { + float *AA = &A[n2-8]; + float *d0,*d1, *e0, *e1; + + e0 = &v[n4]; + e1 = &v[0]; + + d0 = &u[n4]; + d1 = &u[0]; + + while (AA >= A) { + float v40_20, v41_21; + + v41_21 = e0[1] - e1[1]; + v40_20 = e0[0] - e1[0]; + d0[1] = e0[1] + e1[1]; + d0[0] = e0[0] + e1[0]; + d1[1] = v41_21*AA[4] - v40_20*AA[5]; + d1[0] = v40_20*AA[4] + v41_21*AA[5]; + + v41_21 = e0[3] - e1[3]; + v40_20 = e0[2] - e1[2]; + d0[3] = e0[3] + e1[3]; + d0[2] = e0[2] + e1[2]; + d1[3] = v41_21*AA[0] - v40_20*AA[1]; + d1[2] = v40_20*AA[0] + v41_21*AA[1]; + + AA -= 8; + + d0 += 4; + d1 += 4; + e0 += 4; + e1 += 4; + } + } + + ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + + + + imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); + imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); + + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); + + l=2; + for (; l < (ld-3)>>1; ++l) { + int k0 = n >> (l+2), k0_2 = k0>>1; + int lim = 1 << (l+1); + int i; + for (i=0; i < lim; ++i) + imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); + } + + for (; l < ld-6; ++l) { + int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; + int rlim = n >> (l+6), r; + int lim = 1 << (l+1); + int i_off; + float *A0 = A; + i_off = n2-1; + for (r=rlim; r > 0; --r) { + imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); + A0 += k1*4; + i_off -= 8; + } + } + + imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); + + + { + uint16 *bitrev = f->bit_reverse[blocktype]; + + float *d0 = &v[n4-4]; + float *d1 = &v[n2-4]; + while (d0 >= v) { + int k4; + + k4 = bitrev[0]; + d1[3] = u[k4+0]; + d1[2] = u[k4+1]; + d0[3] = u[k4+2]; + d0[2] = u[k4+3]; + + k4 = bitrev[1]; + d1[1] = u[k4+0]; + d1[0] = u[k4+1]; + d0[1] = u[k4+2]; + d0[0] = u[k4+3]; + + d0 -= 4; + d1 -= 4; + bitrev += 2; + } + } + + + assert(v == buf2); + + { + float *C = f->C[blocktype]; + float *d, *e; + + d = v; + e = v + n2 - 4; + + while (d < e) { + float a02,a11,b0,b1,b2,b3; + + a02 = d[0] - e[2]; + a11 = d[1] + e[3]; + + b0 = C[1]*a02 + C[0]*a11; + b1 = C[1]*a11 - C[0]*a02; + + b2 = d[0] + e[ 2]; + b3 = d[1] - e[ 3]; + + d[0] = b2 + b0; + d[1] = b3 + b1; + e[2] = b2 - b0; + e[3] = b1 - b3; + + a02 = d[2] - e[0]; + a11 = d[3] + e[1]; + + b0 = C[3]*a02 + C[2]*a11; + b1 = C[3]*a11 - C[2]*a02; + + b2 = d[2] + e[ 0]; + b3 = d[3] - e[ 1]; + + d[2] = b2 + b0; + d[3] = b3 + b1; + e[0] = b2 - b0; + e[1] = b1 - b3; + + C += 4; + d += 4; + e -= 4; + } + } + + + + + + { + float *d0,*d1,*d2,*d3; + + float *B = f->B[blocktype] + n2 - 8; + float *e = buf2 + n2 - 8; + d0 = &buffer[0]; + d1 = &buffer[n2-4]; + d2 = &buffer[n2]; + d3 = &buffer[n-4]; + while (e >= v) { + float p0,p1,p2,p3; + + p3 = e[6]*B[7] - e[7]*B[6]; + p2 = -e[6]*B[6] - e[7]*B[7]; + + d0[0] = p3; + d1[3] = - p3; + d2[0] = p2; + d3[3] = p2; + + p1 = e[4]*B[5] - e[5]*B[4]; + p0 = -e[4]*B[4] - e[5]*B[5]; + + d0[1] = p1; + d1[2] = - p1; + d2[1] = p0; + d3[2] = p0; + + p3 = e[2]*B[3] - e[3]*B[2]; + p2 = -e[2]*B[2] - e[3]*B[3]; + + d0[2] = p3; + d1[1] = - p3; + d2[2] = p2; + d3[1] = p2; + + p1 = e[0]*B[1] - e[1]*B[0]; + p0 = -e[0]*B[0] - e[1]*B[1]; + + d0[3] = p1; + d1[0] = - p1; + d2[3] = p0; + d3[0] = p0; + + B -= 8; + e -= 8; + d0 += 4; + d2 += 4; + d1 -= 4; + d3 -= 4; + } + } + + temp_free(f,buf2); + temp_alloc_restore(f,save_point); +} +","@@ -3,9 +3,9 @@ + // + // Original version written by Sean Barrett in 2007. + // +-// Originally sponsored by RAD Game Tools. Seeking sponsored +-// by Phillip Bennefall, Marc Andersen, Aaron Baker, Elias Software, +-// Aras Pranckevicius, and Sean Barrett. ++// Originally sponsored by RAD Game Tools. Seeking implementation ++// sponsored by Phillip Bennefall, Marc Andersen, Aaron Baker, ++// Elias Software, Aras Pranckevicius, and Sean Barrett. + // + // LICENSE + // +@@ -32,6 +32,7 @@ + // manxorist@github saga musix github:infatum + // + // Partial history: ++// 1.12 - 2017/11/21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files + // 1.11 - 2017/07/23 - fix MinGW compilation + // 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory + // 1.09 - 2016/04/04 - back out 'truncation of last frame' fix from previous version +@@ -2042,14 +2043,19 @@ static int residue_decode(vorb *f, Codebook *book, float *target, int offset, in + return TRUE; + } + ++// n is 1/2 of the blocksize -- ++// specification: ""Correct per-vector decode length is [n]/2"" + static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) + { + int i,j,pass; + Residue *r = f->residue_config + rn; + int rtype = f->residue_types[rn]; + int c = r->classbook; + int classwords = f->codebooks[c].dimensions; +- int n_read = r->end - r->begin; ++ unsigned int actual_size = rtype == 2 ? n*2 : n; ++ unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size); ++ unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size); ++ int n_read = limit_r_end - limit_r_begin; + int part_read = n_read / r->part_size; + int temp_alloc_point = temp_alloc_save(f); + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE +@@ -4077,7 +4083,10 @@ static int start_decoder(vorb *f) + int i,max_part_read=0; + for (i=0; i < f->residue_count; ++i) { + Residue *r = f->residue_config + i; +- int n_read = r->end - r->begin; ++ unsigned int actual_size = f->blocksize_1 / 2; ++ unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size; ++ unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size; ++ int n_read = limit_r_end - limit_r_begin; + int part_read = n_read / r->part_size; + if (part_read > max_part_read) + max_part_read = part_read; +@@ -4088,6 +4097,8 @@ static int start_decoder(vorb *f) + classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); + #endif + ++ // maximum reasonable partition size is f->blocksize_1 ++ + f->temp_memory_required = classify_mem; + if (imdct_mem > f->temp_memory_required) + f->temp_memory_required = imdct_mem; +@@ -5351,6 +5362,8 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in + #endif // STB_VORBIS_NO_PULLDATA_API + + /* Version history ++ 1.12 - 2017/11/21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files ++ 1.11 - 2017/07/23 - fix MinGW compilation + 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory + 1.09 - 2016/04/04 - back out 'avoid discarding last frame' fix from previous version + 1.08 - 2016/04/02 - fixed multiple warnings; fix setup memory leaks;",2401,2637,4096 +4849,"static void dump_vmcs(void) +{ + u32 vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS); + u32 vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS); + u32 cpu_based_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); + u32 pin_based_exec_ctrl = vmcs_read32(PIN_BASED_VM_EXEC_CONTROL); + u32 secondary_exec_control = 0; + unsigned long cr4 = vmcs_readl(GUEST_CR4); + u64 efer = vmcs_read64(GUEST_IA32_EFER); + int i, n; + + if (cpu_has_secondary_exec_ctrls()) + secondary_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); + + pr_err(""*** Guest State ***\n""); + pr_err(""CR0: actual=0x%016lx, shadow=0x%016lx, gh_mask=%016lx\n"", + vmcs_readl(GUEST_CR0), vmcs_readl(CR0_READ_SHADOW), + vmcs_readl(CR0_GUEST_HOST_MASK)); + pr_err(""CR4: actual=0x%016lx, shadow=0x%016lx, gh_mask=%016lx\n"", + cr4, vmcs_readl(CR4_READ_SHADOW), vmcs_readl(CR4_GUEST_HOST_MASK)); + pr_err(""CR3 = 0x%016lx\n"", vmcs_readl(GUEST_CR3)); + if ((secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) && + (cr4 & X86_CR4_PAE) && !(efer & EFER_LMA)) + { + pr_err(""PDPTR0 = 0x%016llx PDPTR1 = 0x%016llx\n"", + vmcs_read64(GUEST_PDPTR0), vmcs_read64(GUEST_PDPTR1)); + pr_err(""PDPTR2 = 0x%016llx PDPTR3 = 0x%016llx\n"", + vmcs_read64(GUEST_PDPTR2), vmcs_read64(GUEST_PDPTR3)); + } + pr_err(""RSP = 0x%016lx RIP = 0x%016lx\n"", + vmcs_readl(GUEST_RSP), vmcs_readl(GUEST_RIP)); + pr_err(""RFLAGS=0x%08lx DR7 = 0x%016lx\n"", + vmcs_readl(GUEST_RFLAGS), vmcs_readl(GUEST_DR7)); + pr_err(""Sysenter RSP=%016lx CS:RIP=%04x:%016lx\n"", + vmcs_readl(GUEST_SYSENTER_ESP), + vmcs_read32(GUEST_SYSENTER_CS), vmcs_readl(GUEST_SYSENTER_EIP)); + vmx_dump_sel(""CS: "", GUEST_CS_SELECTOR); + vmx_dump_sel(""DS: "", GUEST_DS_SELECTOR); + vmx_dump_sel(""SS: "", GUEST_SS_SELECTOR); + vmx_dump_sel(""ES: "", GUEST_ES_SELECTOR); + vmx_dump_sel(""FS: "", GUEST_FS_SELECTOR); + vmx_dump_sel(""GS: "", GUEST_GS_SELECTOR); + vmx_dump_dtsel(""GDTR:"", GUEST_GDTR_LIMIT); + vmx_dump_sel(""LDTR:"", GUEST_LDTR_SELECTOR); + vmx_dump_dtsel(""IDTR:"", GUEST_IDTR_LIMIT); + vmx_dump_sel(""TR: "", GUEST_TR_SELECTOR); + if ((vmexit_ctl & (VM_EXIT_SAVE_IA32_PAT | VM_EXIT_SAVE_IA32_EFER)) || + (vmentry_ctl & (VM_ENTRY_LOAD_IA32_PAT | VM_ENTRY_LOAD_IA32_EFER))) + pr_err(""EFER = 0x%016llx PAT = 0x%016llx\n"", + efer, vmcs_read64(GUEST_IA32_PAT)); + pr_err(""DebugCtl = 0x%016llx DebugExceptions = 0x%016lx\n"", + vmcs_read64(GUEST_IA32_DEBUGCTL), + vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS)); + if (vmentry_ctl & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL) + pr_err(""PerfGlobCtl = 0x%016llx\n"", + vmcs_read64(GUEST_IA32_PERF_GLOBAL_CTRL)); + if (vmentry_ctl & VM_ENTRY_LOAD_BNDCFGS) + pr_err(""BndCfgS = 0x%016llx\n"", vmcs_read64(GUEST_BNDCFGS)); + pr_err(""Interruptibility = %08x ActivityState = %08x\n"", + vmcs_read32(GUEST_INTERRUPTIBILITY_INFO), + vmcs_read32(GUEST_ACTIVITY_STATE)); + if (secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) + pr_err(""InterruptStatus = %04x\n"", + vmcs_read16(GUEST_INTR_STATUS)); + + pr_err(""*** Host State ***\n""); + pr_err(""RIP = 0x%016lx RSP = 0x%016lx\n"", + vmcs_readl(HOST_RIP), vmcs_readl(HOST_RSP)); + pr_err(""CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x TR=%04x\n"", + vmcs_read16(HOST_CS_SELECTOR), vmcs_read16(HOST_SS_SELECTOR), + vmcs_read16(HOST_DS_SELECTOR), vmcs_read16(HOST_ES_SELECTOR), + vmcs_read16(HOST_FS_SELECTOR), vmcs_read16(HOST_GS_SELECTOR), + vmcs_read16(HOST_TR_SELECTOR)); + pr_err(""FSBase=%016lx GSBase=%016lx TRBase=%016lx\n"", + vmcs_readl(HOST_FS_BASE), vmcs_readl(HOST_GS_BASE), + vmcs_readl(HOST_TR_BASE)); + pr_err(""GDTBase=%016lx IDTBase=%016lx\n"", + vmcs_readl(HOST_GDTR_BASE), vmcs_readl(HOST_IDTR_BASE)); + pr_err(""CR0=%016lx CR3=%016lx CR4=%016lx\n"", + vmcs_readl(HOST_CR0), vmcs_readl(HOST_CR3), + vmcs_readl(HOST_CR4)); + pr_err(""Sysenter RSP=%016lx CS:RIP=%04x:%016lx\n"", + vmcs_readl(HOST_IA32_SYSENTER_ESP), + vmcs_read32(HOST_IA32_SYSENTER_CS), + vmcs_readl(HOST_IA32_SYSENTER_EIP)); + if (vmexit_ctl & (VM_EXIT_LOAD_IA32_PAT | VM_EXIT_LOAD_IA32_EFER)) + pr_err(""EFER = 0x%016llx PAT = 0x%016llx\n"", + vmcs_read64(HOST_IA32_EFER), + vmcs_read64(HOST_IA32_PAT)); + if (vmexit_ctl & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL) + pr_err(""PerfGlobCtl = 0x%016llx\n"", + vmcs_read64(HOST_IA32_PERF_GLOBAL_CTRL)); + + pr_err(""*** Control State ***\n""); + pr_err(""PinBased=%08x CPUBased=%08x SecondaryExec=%08x\n"", + pin_based_exec_ctrl, cpu_based_exec_ctrl, secondary_exec_control); + pr_err(""EntryControls=%08x ExitControls=%08x\n"", vmentry_ctl, vmexit_ctl); + pr_err(""ExceptionBitmap=%08x PFECmask=%08x PFECmatch=%08x\n"", + vmcs_read32(EXCEPTION_BITMAP), + vmcs_read32(PAGE_FAULT_ERROR_CODE_MASK), + vmcs_read32(PAGE_FAULT_ERROR_CODE_MATCH)); + pr_err(""VMEntry: intr_info=%08x errcode=%08x ilen=%08x\n"", + vmcs_read32(VM_ENTRY_INTR_INFO_FIELD), + vmcs_read32(VM_ENTRY_EXCEPTION_ERROR_CODE), + vmcs_read32(VM_ENTRY_INSTRUCTION_LEN)); + pr_err(""VMExit: intr_info=%08x errcode=%08x ilen=%08x\n"", + vmcs_read32(VM_EXIT_INTR_INFO), + vmcs_read32(VM_EXIT_INTR_ERROR_CODE), + vmcs_read32(VM_EXIT_INSTRUCTION_LEN)); + pr_err("" reason=%08x qualification=%016lx\n"", + vmcs_read32(VM_EXIT_REASON), vmcs_readl(EXIT_QUALIFICATION)); + pr_err(""IDTVectoring: info=%08x errcode=%08x\n"", + vmcs_read32(IDT_VECTORING_INFO_FIELD), + vmcs_read32(IDT_VECTORING_ERROR_CODE)); + pr_err(""TSC Offset = 0x%016llx\n"", vmcs_read64(TSC_OFFSET)); + if (secondary_exec_control & SECONDARY_EXEC_TSC_SCALING) + pr_err(""TSC Multiplier = 0x%016llx\n"", + vmcs_read64(TSC_MULTIPLIER)); + if (cpu_based_exec_ctrl & CPU_BASED_TPR_SHADOW) + pr_err(""TPR Threshold = 0x%02x\n"", vmcs_read32(TPR_THRESHOLD)); + if (pin_based_exec_ctrl & PIN_BASED_POSTED_INTR) + pr_err(""PostedIntrVec = 0x%02x\n"", vmcs_read16(POSTED_INTR_NV)); + if ((secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT)) + pr_err(""EPT pointer = 0x%016llx\n"", vmcs_read64(EPT_POINTER)); + n = vmcs_read32(CR3_TARGET_COUNT); + for (i = 0; i + 1 < n; i += 4) + pr_err(""CR3 target%u=%016lx target%u=%016lx\n"", + i, vmcs_readl(CR3_TARGET_VALUE0 + i * 2), + i + 1, vmcs_readl(CR3_TARGET_VALUE0 + i * 2 + 2)); + if (i < n) + pr_err(""CR3 target%u=%016lx\n"", + i, vmcs_readl(CR3_TARGET_VALUE0 + i * 2)); + if (secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) + pr_err(""PLE Gap=%08x Window=%08x\n"", + vmcs_read32(PLE_GAP), vmcs_read32(PLE_WINDOW)); + if (secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) + pr_err(""Virtual processor ID = 0x%04x\n"", + vmcs_read16(VIRTUAL_PROCESSOR_ID)); +} +",0,"static void dump_vmcs(void) +{ + u32 vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS); + u32 vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS); + u32 cpu_based_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); + u32 pin_based_exec_ctrl = vmcs_read32(PIN_BASED_VM_EXEC_CONTROL); + u32 secondary_exec_control = 0; + unsigned long cr4 = vmcs_readl(GUEST_CR4); + u64 efer = vmcs_read64(GUEST_IA32_EFER); + int i, n; + + if (cpu_has_secondary_exec_ctrls()) + secondary_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); + + pr_err(""*** Guest State ***\n""); + pr_err(""CR0: actual=0x%016lx, shadow=0x%016lx, gh_mask=%016lx\n"", + vmcs_readl(GUEST_CR0), vmcs_readl(CR0_READ_SHADOW), + vmcs_readl(CR0_GUEST_HOST_MASK)); + pr_err(""CR4: actual=0x%016lx, shadow=0x%016lx, gh_mask=%016lx\n"", + cr4, vmcs_readl(CR4_READ_SHADOW), vmcs_readl(CR4_GUEST_HOST_MASK)); + pr_err(""CR3 = 0x%016lx\n"", vmcs_readl(GUEST_CR3)); + if ((secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) && + (cr4 & X86_CR4_PAE) && !(efer & EFER_LMA)) + { + pr_err(""PDPTR0 = 0x%016llx PDPTR1 = 0x%016llx\n"", + vmcs_read64(GUEST_PDPTR0), vmcs_read64(GUEST_PDPTR1)); + pr_err(""PDPTR2 = 0x%016llx PDPTR3 = 0x%016llx\n"", + vmcs_read64(GUEST_PDPTR2), vmcs_read64(GUEST_PDPTR3)); + } + pr_err(""RSP = 0x%016lx RIP = 0x%016lx\n"", + vmcs_readl(GUEST_RSP), vmcs_readl(GUEST_RIP)); + pr_err(""RFLAGS=0x%08lx DR7 = 0x%016lx\n"", + vmcs_readl(GUEST_RFLAGS), vmcs_readl(GUEST_DR7)); + pr_err(""Sysenter RSP=%016lx CS:RIP=%04x:%016lx\n"", + vmcs_readl(GUEST_SYSENTER_ESP), + vmcs_read32(GUEST_SYSENTER_CS), vmcs_readl(GUEST_SYSENTER_EIP)); + vmx_dump_sel(""CS: "", GUEST_CS_SELECTOR); + vmx_dump_sel(""DS: "", GUEST_DS_SELECTOR); + vmx_dump_sel(""SS: "", GUEST_SS_SELECTOR); + vmx_dump_sel(""ES: "", GUEST_ES_SELECTOR); + vmx_dump_sel(""FS: "", GUEST_FS_SELECTOR); + vmx_dump_sel(""GS: "", GUEST_GS_SELECTOR); + vmx_dump_dtsel(""GDTR:"", GUEST_GDTR_LIMIT); + vmx_dump_sel(""LDTR:"", GUEST_LDTR_SELECTOR); + vmx_dump_dtsel(""IDTR:"", GUEST_IDTR_LIMIT); + vmx_dump_sel(""TR: "", GUEST_TR_SELECTOR); + if ((vmexit_ctl & (VM_EXIT_SAVE_IA32_PAT | VM_EXIT_SAVE_IA32_EFER)) || + (vmentry_ctl & (VM_ENTRY_LOAD_IA32_PAT | VM_ENTRY_LOAD_IA32_EFER))) + pr_err(""EFER = 0x%016llx PAT = 0x%016llx\n"", + efer, vmcs_read64(GUEST_IA32_PAT)); + pr_err(""DebugCtl = 0x%016llx DebugExceptions = 0x%016lx\n"", + vmcs_read64(GUEST_IA32_DEBUGCTL), + vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS)); + if (vmentry_ctl & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL) + pr_err(""PerfGlobCtl = 0x%016llx\n"", + vmcs_read64(GUEST_IA32_PERF_GLOBAL_CTRL)); + if (vmentry_ctl & VM_ENTRY_LOAD_BNDCFGS) + pr_err(""BndCfgS = 0x%016llx\n"", vmcs_read64(GUEST_BNDCFGS)); + pr_err(""Interruptibility = %08x ActivityState = %08x\n"", + vmcs_read32(GUEST_INTERRUPTIBILITY_INFO), + vmcs_read32(GUEST_ACTIVITY_STATE)); + if (secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) + pr_err(""InterruptStatus = %04x\n"", + vmcs_read16(GUEST_INTR_STATUS)); + + pr_err(""*** Host State ***\n""); + pr_err(""RIP = 0x%016lx RSP = 0x%016lx\n"", + vmcs_readl(HOST_RIP), vmcs_readl(HOST_RSP)); + pr_err(""CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x TR=%04x\n"", + vmcs_read16(HOST_CS_SELECTOR), vmcs_read16(HOST_SS_SELECTOR), + vmcs_read16(HOST_DS_SELECTOR), vmcs_read16(HOST_ES_SELECTOR), + vmcs_read16(HOST_FS_SELECTOR), vmcs_read16(HOST_GS_SELECTOR), + vmcs_read16(HOST_TR_SELECTOR)); + pr_err(""FSBase=%016lx GSBase=%016lx TRBase=%016lx\n"", + vmcs_readl(HOST_FS_BASE), vmcs_readl(HOST_GS_BASE), + vmcs_readl(HOST_TR_BASE)); + pr_err(""GDTBase=%016lx IDTBase=%016lx\n"", + vmcs_readl(HOST_GDTR_BASE), vmcs_readl(HOST_IDTR_BASE)); + pr_err(""CR0=%016lx CR3=%016lx CR4=%016lx\n"", + vmcs_readl(HOST_CR0), vmcs_readl(HOST_CR3), + vmcs_readl(HOST_CR4)); + pr_err(""Sysenter RSP=%016lx CS:RIP=%04x:%016lx\n"", + vmcs_readl(HOST_IA32_SYSENTER_ESP), + vmcs_read32(HOST_IA32_SYSENTER_CS), + vmcs_readl(HOST_IA32_SYSENTER_EIP)); + if (vmexit_ctl & (VM_EXIT_LOAD_IA32_PAT | VM_EXIT_LOAD_IA32_EFER)) + pr_err(""EFER = 0x%016llx PAT = 0x%016llx\n"", + vmcs_read64(HOST_IA32_EFER), + vmcs_read64(HOST_IA32_PAT)); + if (vmexit_ctl & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL) + pr_err(""PerfGlobCtl = 0x%016llx\n"", + vmcs_read64(HOST_IA32_PERF_GLOBAL_CTRL)); + + pr_err(""*** Control State ***\n""); + pr_err(""PinBased=%08x CPUBased=%08x SecondaryExec=%08x\n"", + pin_based_exec_ctrl, cpu_based_exec_ctrl, secondary_exec_control); + pr_err(""EntryControls=%08x ExitControls=%08x\n"", vmentry_ctl, vmexit_ctl); + pr_err(""ExceptionBitmap=%08x PFECmask=%08x PFECmatch=%08x\n"", + vmcs_read32(EXCEPTION_BITMAP), + vmcs_read32(PAGE_FAULT_ERROR_CODE_MASK), + vmcs_read32(PAGE_FAULT_ERROR_CODE_MATCH)); + pr_err(""VMEntry: intr_info=%08x errcode=%08x ilen=%08x\n"", + vmcs_read32(VM_ENTRY_INTR_INFO_FIELD), + vmcs_read32(VM_ENTRY_EXCEPTION_ERROR_CODE), + vmcs_read32(VM_ENTRY_INSTRUCTION_LEN)); + pr_err(""VMExit: intr_info=%08x errcode=%08x ilen=%08x\n"", + vmcs_read32(VM_EXIT_INTR_INFO), + vmcs_read32(VM_EXIT_INTR_ERROR_CODE), + vmcs_read32(VM_EXIT_INSTRUCTION_LEN)); + pr_err("" reason=%08x qualification=%016lx\n"", + vmcs_read32(VM_EXIT_REASON), vmcs_readl(EXIT_QUALIFICATION)); + pr_err(""IDTVectoring: info=%08x errcode=%08x\n"", + vmcs_read32(IDT_VECTORING_INFO_FIELD), + vmcs_read32(IDT_VECTORING_ERROR_CODE)); + pr_err(""TSC Offset = 0x%016llx\n"", vmcs_read64(TSC_OFFSET)); + if (secondary_exec_control & SECONDARY_EXEC_TSC_SCALING) + pr_err(""TSC Multiplier = 0x%016llx\n"", + vmcs_read64(TSC_MULTIPLIER)); + if (cpu_based_exec_ctrl & CPU_BASED_TPR_SHADOW) + pr_err(""TPR Threshold = 0x%02x\n"", vmcs_read32(TPR_THRESHOLD)); + if (pin_based_exec_ctrl & PIN_BASED_POSTED_INTR) + pr_err(""PostedIntrVec = 0x%02x\n"", vmcs_read16(POSTED_INTR_NV)); + if ((secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT)) + pr_err(""EPT pointer = 0x%016llx\n"", vmcs_read64(EPT_POINTER)); + n = vmcs_read32(CR3_TARGET_COUNT); + for (i = 0; i + 1 < n; i += 4) + pr_err(""CR3 target%u=%016lx target%u=%016lx\n"", + i, vmcs_readl(CR3_TARGET_VALUE0 + i * 2), + i + 1, vmcs_readl(CR3_TARGET_VALUE0 + i * 2 + 2)); + if (i < n) + pr_err(""CR3 target%u=%016lx\n"", + i, vmcs_readl(CR3_TARGET_VALUE0 + i * 2)); + if (secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) + pr_err(""PLE Gap=%08x Window=%08x\n"", + vmcs_read32(PLE_GAP), vmcs_read32(PLE_WINDOW)); + if (secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID) + pr_err(""Virtual processor ID = 0x%04x\n"", + vmcs_read16(VIRTUAL_PROCESSOR_ID)); +} +","@@ -1389,10 +1389,10 @@ static inline bool nested_cpu_has_posted_intr(struct vmcs12 *vmcs12) + return vmcs12->pin_based_vm_exec_control & PIN_BASED_POSTED_INTR; + } + +-static inline bool is_exception(u32 intr_info) ++static inline bool is_nmi(u32 intr_info) + { + return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VALID_MASK)) +- == (INTR_TYPE_HARD_EXCEPTION | INTR_INFO_VALID_MASK); ++ == (INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK); + } + + static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, +@@ -5728,7 +5728,7 @@ static int handle_exception(struct kvm_vcpu *vcpu) + if (is_machine_check(intr_info)) + return handle_machine_check(vcpu); + +- if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR) ++ if (is_nmi(intr_info)) + return 1; /* already handled by vmx_vcpu_run() */ + + if (is_no_device(intr_info)) { +@@ -8170,7 +8170,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) + + switch (exit_reason) { + case EXIT_REASON_EXCEPTION_NMI: +- if (!is_exception(intr_info)) ++ if (is_nmi(intr_info)) + return false; + else if (is_page_fault(intr_info)) + return enable_ept; +@@ -8765,8 +8765,7 @@ static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx) + kvm_machine_check(); + + /* We need to handle NMIs before interrupts are enabled */ +- if ((exit_intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR && +- (exit_intr_info & INTR_INFO_VALID_MASK)) { ++ if (is_nmi(exit_intr_info)) { + kvm_before_handle_nmi(&vmx->vcpu); + asm(""int $2""); + kvm_after_handle_nmi(&vmx->vcpu);",2426,2662,4096 +9063,"static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) +{ + int cb_size = 1 << log2_cb_size; + HEVCLocalContext *lc = s->HEVClc; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; + int length = cb_size >> log2_min_cb_size; + int min_cb_width = s->ps.sps->min_cb_width; + int x_cb = x0 >> log2_min_cb_size; + int y_cb = y0 >> log2_min_cb_size; + int idx = log2_cb_size - 2; + int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; + int x, y, ret; + + lc->cu.x = x0; + lc->cu.y = y0; + lc->cu.pred_mode = MODE_INTRA; + lc->cu.part_mode = PART_2Nx2N; + lc->cu.intra_split_flag = 0; + + SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; + for (x = 0; x < 4; x++) + lc->pu.intra_pred_mode[x] = 1; + if (s->ps.pps->transquant_bypass_enable_flag) { + lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(s); + if (lc->cu.cu_transquant_bypass_flag) + set_deblocking_bypass(s, x0, y0, log2_cb_size); + } else + lc->cu.cu_transquant_bypass_flag = 0; + + if (s->sh.slice_type != HEVC_SLICE_I) { + uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb); + + x = y_cb * min_cb_width + x_cb; + for (y = 0; y < length; y++) { + memset(&s->skip_flag[x], skip_flag, length); + x += min_cb_width; + } + lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER; + } else { + x = y_cb * min_cb_width + x_cb; + for (y = 0; y < length; y++) { + memset(&s->skip_flag[x], 0, length); + x += min_cb_width; + } + } + + if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { + hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); + intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); + + if (!s->sh.disable_deblocking_filter_flag) + ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size); + } else { + int pcm_flag = 0; + + if (s->sh.slice_type != HEVC_SLICE_I) + lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); + if (lc->cu.pred_mode != MODE_INTRA || + log2_cb_size == s->ps.sps->log2_min_cb_size) { + lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size); + lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && + lc->cu.pred_mode == MODE_INTRA; + } + + if (lc->cu.pred_mode == MODE_INTRA) { + if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled_flag && + log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size && + log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) { + pcm_flag = ff_hevc_pcm_flag_decode(s); + } + if (pcm_flag) { + intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); + ret = hls_pcm_sample(s, x0, y0, log2_cb_size); + if (s->ps.sps->pcm.loop_filter_disable_flag) + set_deblocking_bypass(s, x0, y0, log2_cb_size); + + if (ret < 0) + return ret; + } else { + intra_prediction_unit(s, x0, y0, log2_cb_size); + } + } else { + intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); + switch (lc->cu.part_mode) { + case PART_2Nx2N: + hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); + break; + case PART_2NxN: + hls_prediction_unit(s, x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx); + hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx); + break; + case PART_Nx2N: + hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1); + hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1); + break; + case PART_2NxnU: + hls_prediction_unit(s, x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx); + hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx); + break; + case PART_2NxnD: + hls_prediction_unit(s, x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx); + hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx); + break; + case PART_nLx2N: + hls_prediction_unit(s, x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2); + hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2); + break; + case PART_nRx2N: + hls_prediction_unit(s, x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2); + hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2); + break; + case PART_NxN: + hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1); + hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1); + hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1); + hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1); + break; + } + } + + if (!pcm_flag) { + int rqt_root_cbf = 1; + + if (lc->cu.pred_mode != MODE_INTRA && + !(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) { + rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(s); + } + if (rqt_root_cbf) { + const static int cbf[2] = { 0 }; + lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? + s->ps.sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : + s->ps.sps->max_transform_hierarchy_depth_inter; + ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0, + log2_cb_size, + log2_cb_size, 0, 0, cbf, cbf); + if (ret < 0) + return ret; + } else { + if (!s->sh.disable_deblocking_filter_flag) + ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size); + } + } + } + + if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) + ff_hevc_set_qPy(s, x0, y0, log2_cb_size); + + x = y_cb * min_cb_width + x_cb; + for (y = 0; y < length; y++) { + memset(&s->qp_y_tab[x], lc->qp_y, length); + x += min_cb_width; + } + + if(((x0 + (1<qPy_pred = lc->qp_y; + } + + set_ct_depth(s, x0, y0, log2_cb_size, lc->ct_depth); + + return 0; +} +",0,"static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) +{ + int cb_size = 1 << log2_cb_size; + HEVCLocalContext *lc = s->HEVClc; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; + int length = cb_size >> log2_min_cb_size; + int min_cb_width = s->ps.sps->min_cb_width; + int x_cb = x0 >> log2_min_cb_size; + int y_cb = y0 >> log2_min_cb_size; + int idx = log2_cb_size - 2; + int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; + int x, y, ret; + + lc->cu.x = x0; + lc->cu.y = y0; + lc->cu.pred_mode = MODE_INTRA; + lc->cu.part_mode = PART_2Nx2N; + lc->cu.intra_split_flag = 0; + + SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; + for (x = 0; x < 4; x++) + lc->pu.intra_pred_mode[x] = 1; + if (s->ps.pps->transquant_bypass_enable_flag) { + lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(s); + if (lc->cu.cu_transquant_bypass_flag) + set_deblocking_bypass(s, x0, y0, log2_cb_size); + } else + lc->cu.cu_transquant_bypass_flag = 0; + + if (s->sh.slice_type != HEVC_SLICE_I) { + uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb); + + x = y_cb * min_cb_width + x_cb; + for (y = 0; y < length; y++) { + memset(&s->skip_flag[x], skip_flag, length); + x += min_cb_width; + } + lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER; + } else { + x = y_cb * min_cb_width + x_cb; + for (y = 0; y < length; y++) { + memset(&s->skip_flag[x], 0, length); + x += min_cb_width; + } + } + + if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { + hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); + intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); + + if (!s->sh.disable_deblocking_filter_flag) + ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size); + } else { + int pcm_flag = 0; + + if (s->sh.slice_type != HEVC_SLICE_I) + lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); + if (lc->cu.pred_mode != MODE_INTRA || + log2_cb_size == s->ps.sps->log2_min_cb_size) { + lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size); + lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && + lc->cu.pred_mode == MODE_INTRA; + } + + if (lc->cu.pred_mode == MODE_INTRA) { + if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled_flag && + log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size && + log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) { + pcm_flag = ff_hevc_pcm_flag_decode(s); + } + if (pcm_flag) { + intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); + ret = hls_pcm_sample(s, x0, y0, log2_cb_size); + if (s->ps.sps->pcm.loop_filter_disable_flag) + set_deblocking_bypass(s, x0, y0, log2_cb_size); + + if (ret < 0) + return ret; + } else { + intra_prediction_unit(s, x0, y0, log2_cb_size); + } + } else { + intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); + switch (lc->cu.part_mode) { + case PART_2Nx2N: + hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); + break; + case PART_2NxN: + hls_prediction_unit(s, x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx); + hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx); + break; + case PART_Nx2N: + hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1); + hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1); + break; + case PART_2NxnU: + hls_prediction_unit(s, x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx); + hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx); + break; + case PART_2NxnD: + hls_prediction_unit(s, x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx); + hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx); + break; + case PART_nLx2N: + hls_prediction_unit(s, x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2); + hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2); + break; + case PART_nRx2N: + hls_prediction_unit(s, x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2); + hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2); + break; + case PART_NxN: + hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1); + hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1); + hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1); + hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1); + break; + } + } + + if (!pcm_flag) { + int rqt_root_cbf = 1; + + if (lc->cu.pred_mode != MODE_INTRA && + !(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) { + rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(s); + } + if (rqt_root_cbf) { + const static int cbf[2] = { 0 }; + lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? + s->ps.sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : + s->ps.sps->max_transform_hierarchy_depth_inter; + ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0, + log2_cb_size, + log2_cb_size, 0, 0, cbf, cbf); + if (ret < 0) + return ret; + } else { + if (!s->sh.disable_deblocking_filter_flag) + ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size); + } + } + } + + if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) + ff_hevc_set_qPy(s, x0, y0, log2_cb_size); + + x = y_cb * min_cb_width + x_cb; + for (y = 0; y < length; y++) { + memset(&s->qp_y_tab[x], lc->qp_y, length); + x += min_cb_width; + } + + if(((x0 + (1<qPy_pred = lc->qp_y; + } + + set_ct_depth(s, x0, y0, log2_cb_size, lc->ct_depth); + + return 0; +} +","@@ -488,6 +488,11 @@ static int hls_slice_header(HEVCContext *s) + + // Coded parameters + sh->first_slice_in_pic_flag = get_bits1(gb); ++ if (s->ref && sh->first_slice_in_pic_flag) { ++ av_log(s->avctx, AV_LOG_ERROR, ""Two slices reporting being the first in the same frame.\n""); ++ return 1; // This slice will be skiped later, do not corrupt state ++ } ++ + if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) { + s->seq_decode = (s->seq_decode + 1) & 0xff; + s->max_ra = INT_MAX; +@@ -2918,6 +2923,11 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) + ret = hls_slice_header(s); + if (ret < 0) + return ret; ++ if (ret == 1) { ++ ret = AVERROR_INVALIDDATA; ++ goto fail; ++ } ++ + + if ( + (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) || +@@ -2927,10 +2937,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) + } + + if (s->sh.first_slice_in_pic_flag) { +- if (s->ref) { +- av_log(s->avctx, AV_LOG_ERROR, ""Two slices reporting being the first in the same frame.\n""); +- goto fail; +- } + if (s->max_ra == INT_MAX) { + if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) { + s->max_ra = s->poc;",2254,2490,4096 +18074," static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + struct bpf_insn *insn, + struct bpf_reg_state *dst_reg, + struct bpf_reg_state src_reg) +{ + struct bpf_reg_state *regs = cur_regs(env); + u8 opcode = BPF_OP(insn->code); + bool src_known, dst_known; + s64 smin_val, smax_val; + u64 umin_val, umax_val; + + if (BPF_CLASS(insn->code) != BPF_ALU64) { + /* 32-bit ALU ops are (32,32)->64 */ + coerce_reg_to_size(dst_reg, 4); + coerce_reg_to_size(&src_reg, 4); + } + smin_val = src_reg.smin_value; + smax_val = src_reg.smax_value; + umin_val = src_reg.umin_value; + umax_val = src_reg.umax_value; + src_known = tnum_is_const(src_reg.var_off); + dst_known = tnum_is_const(dst_reg->var_off); + + switch (opcode) { + case BPF_ADD: + if (signed_add_overflows(dst_reg->smin_value, smin_val) || + signed_add_overflows(dst_reg->smax_value, smax_val)) { + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value += smin_val; + dst_reg->smax_value += smax_val; + } + if (dst_reg->umin_value + umin_val < umin_val || + dst_reg->umax_value + umax_val < umax_val) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value += umin_val; + dst_reg->umax_value += umax_val; + } + dst_reg->var_off = tnum_add(dst_reg->var_off, src_reg.var_off); + break; + case BPF_SUB: + if (signed_sub_overflows(dst_reg->smin_value, smax_val) || + signed_sub_overflows(dst_reg->smax_value, smin_val)) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value -= smax_val; + dst_reg->smax_value -= smin_val; + } + if (dst_reg->umin_value < umax_val) { + /* Overflow possible, we know nothing */ + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + /* Cannot overflow (as long as bounds are consistent) */ + dst_reg->umin_value -= umax_val; + dst_reg->umax_value -= umin_val; + } + dst_reg->var_off = tnum_sub(dst_reg->var_off, src_reg.var_off); + break; + case BPF_MUL: + dst_reg->var_off = tnum_mul(dst_reg->var_off, src_reg.var_off); + if (smin_val < 0 || dst_reg->smin_value < 0) { + /* Ain't nobody got time to multiply that sign */ + __mark_reg_unbounded(dst_reg); + __update_reg_bounds(dst_reg); + break; + } + /* Both values are positive, so we can work with unsigned and + * copy the result to signed (unless it exceeds S64_MAX). + */ + if (umax_val > U32_MAX || dst_reg->umax_value > U32_MAX) { + /* Potential overflow, we know nothing */ + __mark_reg_unbounded(dst_reg); + /* (except what we can learn from the var_off) */ + __update_reg_bounds(dst_reg); + break; + } + dst_reg->umin_value *= umin_val; + dst_reg->umax_value *= umax_val; + if (dst_reg->umax_value > S64_MAX) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + break; + case BPF_AND: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value & + src_reg.var_off.value); + break; + } + /* We get our minimum from the var_off, since that's inherently + * bitwise. Our maximum is the minimum of the operands' maxima. + */ + dst_reg->var_off = tnum_and(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = dst_reg->var_off.value; + dst_reg->umax_value = min(dst_reg->umax_value, umax_val); + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ANDing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ANDing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_OR: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value | + src_reg.var_off.value); + break; + } + /* We get our maximum from the var_off, and our minimum is the + * maximum of the operands' minima + */ + dst_reg->var_off = tnum_or(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = max(dst_reg->umin_value, umin_val); + dst_reg->umax_value = dst_reg->var_off.value | + dst_reg->var_off.mask; + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ORing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ORing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_LSH: + if (umax_val > 63) { + /* Shifts greater than 63 are undefined. This includes + * shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* We lose all sign bit information (except what we can pick + * up from var_off) + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + /* If we might shift our top bit out, then we know nothing */ + if (dst_reg->umax_value > 1ULL << (63 - umax_val)) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value <<= umin_val; + dst_reg->umax_value <<= umax_val; + } + if (src_known) + dst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val); + else + dst_reg->var_off = tnum_lshift(tnum_unknown, umin_val); + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_RSH: + if (umax_val > 63) { + /* Shifts greater than 63 are undefined. This includes + * shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* BPF_RSH is an unsigned shift. If the value in dst_reg might + * be negative, then either: + * 1) src_reg might be zero, so the sign bit of the result is + * unknown, so we lose our signed bounds + * 2) it's known negative, thus the unsigned bounds capture the + * signed bounds + * 3) the signed bounds cross zero, so they tell us nothing + * about the result + * If the value in dst_reg is known nonnegative, then again the + * unsigned bounts capture the signed bounds. + * Thus, in all cases it suffices to blow away our signed bounds + * and rely on inferring new ones from the unsigned bounds and + * var_off of the result. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + if (src_known) + dst_reg->var_off = tnum_rshift(dst_reg->var_off, + umin_val); + else + dst_reg->var_off = tnum_rshift(tnum_unknown, umin_val); + dst_reg->umin_value >>= umax_val; + dst_reg->umax_value >>= umin_val; + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + default: + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + + __reg_deduce_bounds(dst_reg); + __reg_bound_offset(dst_reg); + return 0; +} +",1," static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + struct bpf_insn *insn, + struct bpf_reg_state *dst_reg, + struct bpf_reg_state src_reg) +{ + struct bpf_reg_state *regs = cur_regs(env); + u8 opcode = BPF_OP(insn->code); + bool src_known, dst_known; + s64 smin_val, smax_val; + u64 umin_val, umax_val; + u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; + + smin_val = src_reg.smin_value; + smax_val = src_reg.smax_value; + umin_val = src_reg.umin_value; + umax_val = src_reg.umax_value; + src_known = tnum_is_const(src_reg.var_off); + dst_known = tnum_is_const(dst_reg->var_off); + + switch (opcode) { + case BPF_ADD: + if (signed_add_overflows(dst_reg->smin_value, smin_val) || + signed_add_overflows(dst_reg->smax_value, smax_val)) { + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value += smin_val; + dst_reg->smax_value += smax_val; + } + if (dst_reg->umin_value + umin_val < umin_val || + dst_reg->umax_value + umax_val < umax_val) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value += umin_val; + dst_reg->umax_value += umax_val; + } + dst_reg->var_off = tnum_add(dst_reg->var_off, src_reg.var_off); + break; + case BPF_SUB: + if (signed_sub_overflows(dst_reg->smin_value, smax_val) || + signed_sub_overflows(dst_reg->smax_value, smin_val)) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value -= smax_val; + dst_reg->smax_value -= smin_val; + } + if (dst_reg->umin_value < umax_val) { + /* Overflow possible, we know nothing */ + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + /* Cannot overflow (as long as bounds are consistent) */ + dst_reg->umin_value -= umax_val; + dst_reg->umax_value -= umin_val; + } + dst_reg->var_off = tnum_sub(dst_reg->var_off, src_reg.var_off); + break; + case BPF_MUL: + dst_reg->var_off = tnum_mul(dst_reg->var_off, src_reg.var_off); + if (smin_val < 0 || dst_reg->smin_value < 0) { + /* Ain't nobody got time to multiply that sign */ + __mark_reg_unbounded(dst_reg); + __update_reg_bounds(dst_reg); + break; + } + /* Both values are positive, so we can work with unsigned and + * copy the result to signed (unless it exceeds S64_MAX). + */ + if (umax_val > U32_MAX || dst_reg->umax_value > U32_MAX) { + /* Potential overflow, we know nothing */ + __mark_reg_unbounded(dst_reg); + /* (except what we can learn from the var_off) */ + __update_reg_bounds(dst_reg); + break; + } + dst_reg->umin_value *= umin_val; + dst_reg->umax_value *= umax_val; + if (dst_reg->umax_value > S64_MAX) { + /* Overflow possible, we know nothing */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + break; + case BPF_AND: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value & + src_reg.var_off.value); + break; + } + /* We get our minimum from the var_off, since that's inherently + * bitwise. Our maximum is the minimum of the operands' maxima. + */ + dst_reg->var_off = tnum_and(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = dst_reg->var_off.value; + dst_reg->umax_value = min(dst_reg->umax_value, umax_val); + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ANDing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ANDing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_OR: + if (src_known && dst_known) { + __mark_reg_known(dst_reg, dst_reg->var_off.value | + src_reg.var_off.value); + break; + } + /* We get our maximum from the var_off, and our minimum is the + * maximum of the operands' minima + */ + dst_reg->var_off = tnum_or(dst_reg->var_off, src_reg.var_off); + dst_reg->umin_value = max(dst_reg->umin_value, umin_val); + dst_reg->umax_value = dst_reg->var_off.value | + dst_reg->var_off.mask; + if (dst_reg->smin_value < 0 || smin_val < 0) { + /* Lose signed bounds when ORing negative numbers, + * ain't nobody got time for that. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + } else { + /* ORing two positives gives a positive, so safe to + * cast result into s64. + */ + dst_reg->smin_value = dst_reg->umin_value; + dst_reg->smax_value = dst_reg->umax_value; + } + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_LSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* We lose all sign bit information (except what we can pick + * up from var_off) + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + /* If we might shift our top bit out, then we know nothing */ + if (dst_reg->umax_value > 1ULL << (63 - umax_val)) { + dst_reg->umin_value = 0; + dst_reg->umax_value = U64_MAX; + } else { + dst_reg->umin_value <<= umin_val; + dst_reg->umax_value <<= umax_val; + } + if (src_known) + dst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val); + else + dst_reg->var_off = tnum_lshift(tnum_unknown, umin_val); + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + case BPF_RSH: + if (umax_val >= insn_bitness) { + /* Shifts greater than 31 or 63 are undefined. + * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + /* BPF_RSH is an unsigned shift. If the value in dst_reg might + * be negative, then either: + * 1) src_reg might be zero, so the sign bit of the result is + * unknown, so we lose our signed bounds + * 2) it's known negative, thus the unsigned bounds capture the + * signed bounds + * 3) the signed bounds cross zero, so they tell us nothing + * about the result + * If the value in dst_reg is known nonnegative, then again the + * unsigned bounts capture the signed bounds. + * Thus, in all cases it suffices to blow away our signed bounds + * and rely on inferring new ones from the unsigned bounds and + * var_off of the result. + */ + dst_reg->smin_value = S64_MIN; + dst_reg->smax_value = S64_MAX; + if (src_known) + dst_reg->var_off = tnum_rshift(dst_reg->var_off, + umin_val); + else + dst_reg->var_off = tnum_rshift(tnum_unknown, umin_val); + dst_reg->umin_value >>= umax_val; + dst_reg->umax_value >>= umin_val; + /* We may learn something more from the var_off */ + __update_reg_bounds(dst_reg); + break; + default: + mark_reg_unknown(env, regs, insn->dst_reg); + break; + } + + if (BPF_CLASS(insn->code) != BPF_ALU64) { + /* 32-bit ALU ops are (32,32)->32 */ + coerce_reg_to_size(dst_reg, 4); + coerce_reg_to_size(&src_reg, 4); + } + + __reg_deduce_bounds(dst_reg); + __reg_bound_offset(dst_reg); + return 0; +} +","@@ -2017,6 +2017,10 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, + return 0; + } + ++/* WARNING: This function does calculations on 64-bit values, but the actual ++ * execution may occur on 32-bit values. Therefore, things like bitshifts ++ * need extra checks in the 32-bit case. ++ */ + static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + struct bpf_insn *insn, + struct bpf_reg_state *dst_reg, +@@ -2027,12 +2031,8 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + bool src_known, dst_known; + s64 smin_val, smax_val; + u64 umin_val, umax_val; ++ u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; + +- if (BPF_CLASS(insn->code) != BPF_ALU64) { +- /* 32-bit ALU ops are (32,32)->64 */ +- coerce_reg_to_size(dst_reg, 4); +- coerce_reg_to_size(&src_reg, 4); +- } + smin_val = src_reg.smin_value; + smax_val = src_reg.smax_value; + umin_val = src_reg.umin_value; +@@ -2168,9 +2168,9 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + __update_reg_bounds(dst_reg); + break; + case BPF_LSH: +- if (umax_val > 63) { +- /* Shifts greater than 63 are undefined. This includes +- * shifts by a negative number. ++ if (umax_val >= insn_bitness) { ++ /* Shifts greater than 31 or 63 are undefined. ++ * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; +@@ -2196,9 +2196,9 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + __update_reg_bounds(dst_reg); + break; + case BPF_RSH: +- if (umax_val > 63) { +- /* Shifts greater than 63 are undefined. This includes +- * shifts by a negative number. ++ if (umax_val >= insn_bitness) { ++ /* Shifts greater than 31 or 63 are undefined. ++ * This includes shifts by a negative number. + */ + mark_reg_unknown(env, regs, insn->dst_reg); + break; +@@ -2234,6 +2234,12 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, + break; + } + ++ if (BPF_CLASS(insn->code) != BPF_ALU64) { ++ /* 32-bit ALU ops are (32,32)->32 */ ++ coerce_reg_to_size(dst_reg, 4); ++ coerce_reg_to_size(&src_reg, 4); ++ } ++ + __reg_deduce_bounds(dst_reg); + __reg_bound_offset(dst_reg); + return 0;",2283,2519,4096 +9644,"MagickExport Image *HoughLineImage(const Image *image,const size_t width, + const size_t height,const size_t threshold,ExceptionInfo *exception) +{ +#define HoughLineImageTag ""HoughLine/Image"" + + CacheView + *image_view; + + char + message[MagickPathExtent], + path[MagickPathExtent]; + + const char + *artifact; + + double + hough_height; + + Image + *lines_image = NULL; + + ImageInfo + *image_info; + + int + file; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + MatrixInfo + *accumulator; + + PointInfo + center; + + register ssize_t + y; + + size_t + accumulator_height, + accumulator_width, + line_count; + + /* + Create the accumulator. + */ + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + accumulator_width=180; + hough_height=((sqrt(2.0)*(double) (image->rows > image->columns ? + image->rows : image->columns))/2.0); + accumulator_height=(size_t) (2.0*hough_height); + accumulator=AcquireMatrixInfo(accumulator_width,accumulator_height, + sizeof(double),exception); + if (accumulator == (MatrixInfo *) NULL) + ThrowImageException(ResourceLimitError,""MemoryAllocationFailed""); + if (NullMatrix(accumulator) == MagickFalse) + { + accumulator=DestroyMatrixInfo(accumulator); + ThrowImageException(ResourceLimitError,""MemoryAllocationFailed""); + } + /* + Populate the accumulator. + */ + status=MagickTrue; + progress=0; + center.x=(double) image->columns/2.0; + center.y=(double) image->rows/2.0; + image_view=AcquireVirtualCacheView(image,exception); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); + if (p == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + if (GetPixelIntensity(image,p) > (QuantumRange/2.0)) + { + register ssize_t + i; + + for (i=0; i < 180; i++) + { + double + count, + radius; + + radius=(((double) x-center.x)*cos(DegreesToRadians((double) i)))+ + (((double) y-center.y)*sin(DegreesToRadians((double) i))); + (void) GetMatrixElement(accumulator,i,(ssize_t) + MagickRound(radius+hough_height),&count); + count++; + (void) SetMatrixElement(accumulator,i,(ssize_t) + MagickRound(radius+hough_height),&count); + } + } + p+=GetPixelChannels(image); + } + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,CannyEdgeImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + if (status == MagickFalse) + { + accumulator=DestroyMatrixInfo(accumulator); + return((Image *) NULL); + } + /* + Generate line segments from accumulator. + */ + file=AcquireUniqueFileResource(path); + if (file == -1) + { + accumulator=DestroyMatrixInfo(accumulator); + return((Image *) NULL); + } + (void) FormatLocaleString(message,MagickPathExtent, + ""# Hough line transform: %.20gx%.20g%+.20g\n"",(double) width, + (double) height,(double) threshold); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + (void) FormatLocaleString(message,MagickPathExtent, + ""viewbox 0 0 %.20g %.20g\n"",(double) image->columns,(double) image->rows); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + (void) FormatLocaleString(message,MagickPathExtent, + ""# x1,y1 x2,y2 # count angle distance\n""); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + line_count=image->columns > image->rows ? image->columns/4 : image->rows/4; + if (threshold != 0) + line_count=threshold; + for (y=0; y < (ssize_t) accumulator_height; y++) + { + register ssize_t + x; + + for (x=0; x < (ssize_t) accumulator_width; x++) + { + double + count; + + (void) GetMatrixElement(accumulator,x,y,&count); + if (count >= (double) line_count) + { + double + maxima; + + SegmentInfo + line; + + ssize_t + v; + + /* + Is point a local maxima? + */ + maxima=count; + for (v=(-((ssize_t) height/2)); v <= (((ssize_t) height/2)); v++) + { + ssize_t + u; + + for (u=(-((ssize_t) width/2)); u <= (((ssize_t) width/2)); u++) + { + if ((u != 0) || (v !=0)) + { + (void) GetMatrixElement(accumulator,x+u,y+v,&count); + if (count > maxima) + { + maxima=count; + break; + } + } + } + if (u < (ssize_t) (width/2)) + break; + } + (void) GetMatrixElement(accumulator,x,y,&count); + if (maxima > count) + continue; + if ((x >= 45) && (x <= 135)) + { + /* + y = (r-x cos(t))/sin(t) + */ + line.x1=0.0; + line.y1=((double) (y-(accumulator_height/2.0))-((line.x1- + (image->columns/2.0))*cos(DegreesToRadians((double) x))))/ + sin(DegreesToRadians((double) x))+(image->rows/2.0); + line.x2=(double) image->columns; + line.y2=((double) (y-(accumulator_height/2.0))-((line.x2- + (image->columns/2.0))*cos(DegreesToRadians((double) x))))/ + sin(DegreesToRadians((double) x))+(image->rows/2.0); + } + else + { + /* + x = (r-y cos(t))/sin(t) + */ + line.y1=0.0; + line.x1=((double) (y-(accumulator_height/2.0))-((line.y1- + (image->rows/2.0))*sin(DegreesToRadians((double) x))))/ + cos(DegreesToRadians((double) x))+(image->columns/2.0); + line.y2=(double) image->rows; + line.x2=((double) (y-(accumulator_height/2.0))-((line.y2- + (image->rows/2.0))*sin(DegreesToRadians((double) x))))/ + cos(DegreesToRadians((double) x))+(image->columns/2.0); + } + (void) FormatLocaleString(message,MagickPathExtent, + ""line %g,%g %g,%g # %g %g %g\n"",line.x1,line.y1,line.x2,line.y2, + maxima,(double) x,(double) y); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + } + } + } + (void) close(file); + /* + Render lines to image canvas. + */ + image_info=AcquireImageInfo(); + image_info->background_color=image->background_color; + (void) FormatLocaleString(image_info->filename,MagickPathExtent,""%s"",path); + artifact=GetImageArtifact(image,""background""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""background"",artifact); + artifact=GetImageArtifact(image,""fill""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""fill"",artifact); + artifact=GetImageArtifact(image,""stroke""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""stroke"",artifact); + artifact=GetImageArtifact(image,""strokewidth""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""strokewidth"",artifact); + lines_image=RenderHoughLines(image_info,image->columns,image->rows,exception); + artifact=GetImageArtifact(image,""hough-lines:accumulator""); + if ((lines_image != (Image *) NULL) && + (IsStringTrue(artifact) != MagickFalse)) + { + Image + *accumulator_image; + + accumulator_image=MatrixToImage(accumulator,exception); + if (accumulator_image != (Image *) NULL) + AppendImageToList(&lines_image,accumulator_image); + } + /* + Free resources. + */ + accumulator=DestroyMatrixInfo(accumulator); + image_info=DestroyImageInfo(image_info); + (void) RelinquishUniqueFileResource(path); + return(GetFirstImageInList(lines_image)); +} +",0,"MagickExport Image *HoughLineImage(const Image *image,const size_t width, + const size_t height,const size_t threshold,ExceptionInfo *exception) +{ +#define HoughLineImageTag ""HoughLine/Image"" + + CacheView + *image_view; + + char + message[MagickPathExtent], + path[MagickPathExtent]; + + const char + *artifact; + + double + hough_height; + + Image + *lines_image = NULL; + + ImageInfo + *image_info; + + int + file; + + MagickBooleanType + status; + + MagickOffsetType + progress; + + MatrixInfo + *accumulator; + + PointInfo + center; + + register ssize_t + y; + + size_t + accumulator_height, + accumulator_width, + line_count; + + /* + Create the accumulator. + */ + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + accumulator_width=180; + hough_height=((sqrt(2.0)*(double) (image->rows > image->columns ? + image->rows : image->columns))/2.0); + accumulator_height=(size_t) (2.0*hough_height); + accumulator=AcquireMatrixInfo(accumulator_width,accumulator_height, + sizeof(double),exception); + if (accumulator == (MatrixInfo *) NULL) + ThrowImageException(ResourceLimitError,""MemoryAllocationFailed""); + if (NullMatrix(accumulator) == MagickFalse) + { + accumulator=DestroyMatrixInfo(accumulator); + ThrowImageException(ResourceLimitError,""MemoryAllocationFailed""); + } + /* + Populate the accumulator. + */ + status=MagickTrue; + progress=0; + center.x=(double) image->columns/2.0; + center.y=(double) image->rows/2.0; + image_view=AcquireVirtualCacheView(image,exception); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); + if (p == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + if (GetPixelIntensity(image,p) > (QuantumRange/2.0)) + { + register ssize_t + i; + + for (i=0; i < 180; i++) + { + double + count, + radius; + + radius=(((double) x-center.x)*cos(DegreesToRadians((double) i)))+ + (((double) y-center.y)*sin(DegreesToRadians((double) i))); + (void) GetMatrixElement(accumulator,i,(ssize_t) + MagickRound(radius+hough_height),&count); + count++; + (void) SetMatrixElement(accumulator,i,(ssize_t) + MagickRound(radius+hough_height),&count); + } + } + p+=GetPixelChannels(image); + } + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; + +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,CannyEdgeImageTag,progress,image->rows); + if (proceed == MagickFalse) + status=MagickFalse; + } + } + image_view=DestroyCacheView(image_view); + if (status == MagickFalse) + { + accumulator=DestroyMatrixInfo(accumulator); + return((Image *) NULL); + } + /* + Generate line segments from accumulator. + */ + file=AcquireUniqueFileResource(path); + if (file == -1) + { + accumulator=DestroyMatrixInfo(accumulator); + return((Image *) NULL); + } + (void) FormatLocaleString(message,MagickPathExtent, + ""# Hough line transform: %.20gx%.20g%+.20g\n"",(double) width, + (double) height,(double) threshold); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + (void) FormatLocaleString(message,MagickPathExtent, + ""viewbox 0 0 %.20g %.20g\n"",(double) image->columns,(double) image->rows); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + (void) FormatLocaleString(message,MagickPathExtent, + ""# x1,y1 x2,y2 # count angle distance\n""); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + line_count=image->columns > image->rows ? image->columns/4 : image->rows/4; + if (threshold != 0) + line_count=threshold; + for (y=0; y < (ssize_t) accumulator_height; y++) + { + register ssize_t + x; + + for (x=0; x < (ssize_t) accumulator_width; x++) + { + double + count; + + (void) GetMatrixElement(accumulator,x,y,&count); + if (count >= (double) line_count) + { + double + maxima; + + SegmentInfo + line; + + ssize_t + v; + + /* + Is point a local maxima? + */ + maxima=count; + for (v=(-((ssize_t) height/2)); v <= (((ssize_t) height/2)); v++) + { + ssize_t + u; + + for (u=(-((ssize_t) width/2)); u <= (((ssize_t) width/2)); u++) + { + if ((u != 0) || (v !=0)) + { + (void) GetMatrixElement(accumulator,x+u,y+v,&count); + if (count > maxima) + { + maxima=count; + break; + } + } + } + if (u < (ssize_t) (width/2)) + break; + } + (void) GetMatrixElement(accumulator,x,y,&count); + if (maxima > count) + continue; + if ((x >= 45) && (x <= 135)) + { + /* + y = (r-x cos(t))/sin(t) + */ + line.x1=0.0; + line.y1=((double) (y-(accumulator_height/2.0))-((line.x1- + (image->columns/2.0))*cos(DegreesToRadians((double) x))))/ + sin(DegreesToRadians((double) x))+(image->rows/2.0); + line.x2=(double) image->columns; + line.y2=((double) (y-(accumulator_height/2.0))-((line.x2- + (image->columns/2.0))*cos(DegreesToRadians((double) x))))/ + sin(DegreesToRadians((double) x))+(image->rows/2.0); + } + else + { + /* + x = (r-y cos(t))/sin(t) + */ + line.y1=0.0; + line.x1=((double) (y-(accumulator_height/2.0))-((line.y1- + (image->rows/2.0))*sin(DegreesToRadians((double) x))))/ + cos(DegreesToRadians((double) x))+(image->columns/2.0); + line.y2=(double) image->rows; + line.x2=((double) (y-(accumulator_height/2.0))-((line.y2- + (image->rows/2.0))*sin(DegreesToRadians((double) x))))/ + cos(DegreesToRadians((double) x))+(image->columns/2.0); + } + (void) FormatLocaleString(message,MagickPathExtent, + ""line %g,%g %g,%g # %g %g %g\n"",line.x1,line.y1,line.x2,line.y2, + maxima,(double) x,(double) y); + if (write(file,message,strlen(message)) != (ssize_t) strlen(message)) + status=MagickFalse; + } + } + } + (void) close(file); + /* + Render lines to image canvas. + */ + image_info=AcquireImageInfo(); + image_info->background_color=image->background_color; + (void) FormatLocaleString(image_info->filename,MagickPathExtent,""%s"",path); + artifact=GetImageArtifact(image,""background""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""background"",artifact); + artifact=GetImageArtifact(image,""fill""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""fill"",artifact); + artifact=GetImageArtifact(image,""stroke""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""stroke"",artifact); + artifact=GetImageArtifact(image,""strokewidth""); + if (artifact != (const char *) NULL) + (void) SetImageOption(image_info,""strokewidth"",artifact); + lines_image=RenderHoughLines(image_info,image->columns,image->rows,exception); + artifact=GetImageArtifact(image,""hough-lines:accumulator""); + if ((lines_image != (Image *) NULL) && + (IsStringTrue(artifact) != MagickFalse)) + { + Image + *accumulator_image; + + accumulator_image=MatrixToImage(accumulator,exception); + if (accumulator_image != (Image *) NULL) + AppendImageToList(&lines_image,accumulator_image); + } + /* + Free resources. + */ + accumulator=DestroyMatrixInfo(accumulator); + image_info=DestroyImageInfo(image_info); + (void) RelinquishUniqueFileResource(path); + return(GetFirstImageInList(lines_image)); +} +","@@ -2288,7 +2288,7 @@ MagickExport Image *MeanShiftImage(const Image *image,const size_t width, + } + } + } +- gamma=1.0/count; ++ gamma=PerceptibleReciprocal(count); + mean_location.x=gamma*sum_location.x; + mean_location.y=gamma*sum_location.y; + mean_pixel.red=gamma*sum_pixel.red;",2230,2466,4096 +17998,"static long vfio_pci_ioctl(void *device_data, + unsigned int cmd, unsigned long arg) +{ + struct vfio_pci_device *vdev = device_data; + unsigned long minsz; + + if (cmd == VFIO_DEVICE_GET_INFO) { + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + info.flags = VFIO_DEVICE_FLAGS_PCI; + + if (vdev->reset_works) + info.flags |= VFIO_DEVICE_FLAGS_RESET; + + info.num_regions = VFIO_PCI_NUM_REGIONS + vdev->num_regions; + info.num_irqs = VFIO_PCI_NUM_IRQS; + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; + + } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) { + struct pci_dev *pdev = vdev->pdev; + struct vfio_region_info info; + struct vfio_info_cap caps = { .buf = NULL, .size = 0 }; + int i, ret; + + minsz = offsetofend(struct vfio_region_info, offset); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + switch (info.index) { + case VFIO_PCI_CONFIG_REGION_INDEX: + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = pdev->cfg_size; + info.flags = VFIO_REGION_INFO_FLAG_READ | + VFIO_REGION_INFO_FLAG_WRITE; + break; + case VFIO_PCI_BAR0_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX: + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = pci_resource_len(pdev, info.index); + if (!info.size) { + info.flags = 0; + break; + } + + info.flags = VFIO_REGION_INFO_FLAG_READ | + VFIO_REGION_INFO_FLAG_WRITE; + if (vdev->bar_mmap_supported[info.index]) { + info.flags |= VFIO_REGION_INFO_FLAG_MMAP; + if (info.index == vdev->msix_bar) { + ret = msix_sparse_mmap_cap(vdev, &caps); + if (ret) + return ret; + } + } + + break; + case VFIO_PCI_ROM_REGION_INDEX: + { + void __iomem *io; + size_t size; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.flags = 0; + + /* Report the BAR size, not the ROM size */ + info.size = pci_resource_len(pdev, info.index); + if (!info.size) { + /* Shadow ROMs appear as PCI option ROMs */ + if (pdev->resource[PCI_ROM_RESOURCE].flags & + IORESOURCE_ROM_SHADOW) + info.size = 0x20000; + else + break; + } + + /* Is it really there? */ + io = pci_map_rom(pdev, &size); + if (!io || !size) { + info.size = 0; + break; + } + pci_unmap_rom(pdev, io); + + info.flags = VFIO_REGION_INFO_FLAG_READ; + break; + } + case VFIO_PCI_VGA_REGION_INDEX: + if (!vdev->has_vga) + return -EINVAL; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = 0xc0000; + info.flags = VFIO_REGION_INFO_FLAG_READ | + VFIO_REGION_INFO_FLAG_WRITE; + + break; + default: + if (info.index >= + VFIO_PCI_NUM_REGIONS + vdev->num_regions) + return -EINVAL; + + i = info.index - VFIO_PCI_NUM_REGIONS; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = vdev->region[i].size; + info.flags = vdev->region[i].flags; + + ret = region_type_cap(vdev, &caps, + vdev->region[i].type, + vdev->region[i].subtype); + if (ret) + return ret; + } + + if (caps.size) { + info.flags |= VFIO_REGION_INFO_FLAG_CAPS; + if (info.argsz < sizeof(info) + caps.size) { + info.argsz = sizeof(info) + caps.size; + info.cap_offset = 0; + } else { + vfio_info_cap_shift(&caps, sizeof(info)); + if (copy_to_user((void __user *)arg + + sizeof(info), caps.buf, + caps.size)) { + kfree(caps.buf); + return -EFAULT; + } + info.cap_offset = sizeof(info); + } + + kfree(caps.buf); + } + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; + + } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) { + struct vfio_irq_info info; + + minsz = offsetofend(struct vfio_irq_info, count); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz || info.index >= VFIO_PCI_NUM_IRQS) + return -EINVAL; + + switch (info.index) { + case VFIO_PCI_INTX_IRQ_INDEX ... VFIO_PCI_MSIX_IRQ_INDEX: + case VFIO_PCI_REQ_IRQ_INDEX: + break; + case VFIO_PCI_ERR_IRQ_INDEX: + if (pci_is_pcie(vdev->pdev)) + break; + /* pass thru to return error */ + default: + return -EINVAL; + } + + info.flags = VFIO_IRQ_INFO_EVENTFD; + + info.count = vfio_pci_get_irq_count(vdev, info.index); + + if (info.index == VFIO_PCI_INTX_IRQ_INDEX) + info.flags |= (VFIO_IRQ_INFO_MASKABLE | + VFIO_IRQ_INFO_AUTOMASKED); + else + info.flags |= VFIO_IRQ_INFO_NORESIZE; + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; + + } else if (cmd == VFIO_DEVICE_SET_IRQS) { + struct vfio_irq_set hdr; + u8 *data = NULL; + int ret = 0; + + minsz = offsetofend(struct vfio_irq_set, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz || hdr.index >= VFIO_PCI_NUM_IRQS || + hdr.flags & ~(VFIO_IRQ_SET_DATA_TYPE_MASK | + VFIO_IRQ_SET_ACTION_TYPE_MASK)) + return -EINVAL; + + if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) { + size_t size; + int max = vfio_pci_get_irq_count(vdev, hdr.index); + + if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL) + size = sizeof(uint8_t); + else if (hdr.flags & VFIO_IRQ_SET_DATA_EVENTFD) + size = sizeof(int32_t); + else + return -EINVAL; + + if (hdr.argsz - minsz < hdr.count * size || + hdr.start >= max || hdr.start + hdr.count > max) + return -EINVAL; + + data = memdup_user((void __user *)(arg + minsz), + hdr.count * size); + if (IS_ERR(data)) + return PTR_ERR(data); + } + + mutex_lock(&vdev->igate); + + ret = vfio_pci_set_irqs_ioctl(vdev, hdr.flags, hdr.index, + hdr.start, hdr.count, data); + + mutex_unlock(&vdev->igate); + kfree(data); + + return ret; + + } else if (cmd == VFIO_DEVICE_RESET) { + return vdev->reset_works ? + pci_try_reset_function(vdev->pdev) : -EINVAL; + + } else if (cmd == VFIO_DEVICE_GET_PCI_HOT_RESET_INFO) { + struct vfio_pci_hot_reset_info hdr; + struct vfio_pci_fill_info fill = { 0 }; + struct vfio_pci_dependent_device *devices = NULL; + bool slot = false; + int ret = 0; + + minsz = offsetofend(struct vfio_pci_hot_reset_info, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz) + return -EINVAL; + + hdr.flags = 0; + + /* Can we do a slot or bus reset or neither? */ + if (!pci_probe_reset_slot(vdev->pdev->slot)) + slot = true; + else if (pci_probe_reset_bus(vdev->pdev->bus)) + return -ENODEV; + + /* How many devices are affected? */ + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_count_devs, + &fill.max, slot); + if (ret) + return ret; + + WARN_ON(!fill.max); /* Should always be at least one */ + + /* + * If there's enough space, fill it now, otherwise return + * -ENOSPC and the number of devices affected. + */ + if (hdr.argsz < sizeof(hdr) + (fill.max * sizeof(*devices))) { + ret = -ENOSPC; + hdr.count = fill.max; + goto reset_info_exit; + } + + devices = kcalloc(fill.max, sizeof(*devices), GFP_KERNEL); + if (!devices) + return -ENOMEM; + + fill.devices = devices; + + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_fill_devs, + &fill, slot); + + /* + * If a device was removed between counting and filling, + * we may come up short of fill.max. If a device was + * added, we'll have a return of -EAGAIN above. + */ + if (!ret) + hdr.count = fill.cur; + +reset_info_exit: + if (copy_to_user((void __user *)arg, &hdr, minsz)) + ret = -EFAULT; + + if (!ret) { + if (copy_to_user((void __user *)(arg + minsz), devices, + hdr.count * sizeof(*devices))) + ret = -EFAULT; + } + + kfree(devices); + return ret; + + } else if (cmd == VFIO_DEVICE_PCI_HOT_RESET) { + struct vfio_pci_hot_reset hdr; + int32_t *group_fds; + struct vfio_pci_group_entry *groups; + struct vfio_pci_group_info info; + bool slot = false; + int i, count = 0, ret = 0; + + minsz = offsetofend(struct vfio_pci_hot_reset, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz || hdr.flags) + return -EINVAL; + + /* Can we do a slot or bus reset or neither? */ + if (!pci_probe_reset_slot(vdev->pdev->slot)) + slot = true; + else if (pci_probe_reset_bus(vdev->pdev->bus)) + return -ENODEV; + + /* + * We can't let userspace give us an arbitrarily large + * buffer to copy, so verify how many we think there + * could be. Note groups can have multiple devices so + * one group per device is the max. + */ + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_count_devs, + &count, slot); + if (ret) + return ret; + + /* Somewhere between 1 and count is OK */ + if (!hdr.count || hdr.count > count) + return -EINVAL; + + group_fds = kcalloc(hdr.count, sizeof(*group_fds), GFP_KERNEL); + groups = kcalloc(hdr.count, sizeof(*groups), GFP_KERNEL); + if (!group_fds || !groups) { + kfree(group_fds); + kfree(groups); + return -ENOMEM; + } + + if (copy_from_user(group_fds, (void __user *)(arg + minsz), + hdr.count * sizeof(*group_fds))) { + kfree(group_fds); + kfree(groups); + return -EFAULT; + } + + /* + * For each group_fd, get the group through the vfio external + * user interface and store the group and iommu ID. This + * ensures the group is held across the reset. + */ + for (i = 0; i < hdr.count; i++) { + struct vfio_group *group; + struct fd f = fdget(group_fds[i]); + if (!f.file) { + ret = -EBADF; + break; + } + + group = vfio_group_get_external_user(f.file); + fdput(f); + if (IS_ERR(group)) { + ret = PTR_ERR(group); + break; + } + + groups[i].group = group; + groups[i].id = vfio_external_user_iommu_id(group); + } + + kfree(group_fds); + + /* release reference to groups on error */ + if (ret) + goto hot_reset_release; + + info.count = hdr.count; + info.groups = groups; + + /* + * Test whether all the affected devices are contained + * by the set of groups provided by the user. + */ + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_validate_devs, + &info, slot); + if (!ret) + /* User has access, do the reset */ + ret = slot ? pci_try_reset_slot(vdev->pdev->slot) : + pci_try_reset_bus(vdev->pdev->bus); + +hot_reset_release: + for (i--; i >= 0; i--) + vfio_group_put_external_user(groups[i].group); + + kfree(groups); + return ret; + } + + return -ENOTTY; +} +",1,"static long vfio_pci_ioctl(void *device_data, + unsigned int cmd, unsigned long arg) +{ + struct vfio_pci_device *vdev = device_data; + unsigned long minsz; + + if (cmd == VFIO_DEVICE_GET_INFO) { + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + info.flags = VFIO_DEVICE_FLAGS_PCI; + + if (vdev->reset_works) + info.flags |= VFIO_DEVICE_FLAGS_RESET; + + info.num_regions = VFIO_PCI_NUM_REGIONS + vdev->num_regions; + info.num_irqs = VFIO_PCI_NUM_IRQS; + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; + + } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) { + struct pci_dev *pdev = vdev->pdev; + struct vfio_region_info info; + struct vfio_info_cap caps = { .buf = NULL, .size = 0 }; + int i, ret; + + minsz = offsetofend(struct vfio_region_info, offset); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + switch (info.index) { + case VFIO_PCI_CONFIG_REGION_INDEX: + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = pdev->cfg_size; + info.flags = VFIO_REGION_INFO_FLAG_READ | + VFIO_REGION_INFO_FLAG_WRITE; + break; + case VFIO_PCI_BAR0_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX: + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = pci_resource_len(pdev, info.index); + if (!info.size) { + info.flags = 0; + break; + } + + info.flags = VFIO_REGION_INFO_FLAG_READ | + VFIO_REGION_INFO_FLAG_WRITE; + if (vdev->bar_mmap_supported[info.index]) { + info.flags |= VFIO_REGION_INFO_FLAG_MMAP; + if (info.index == vdev->msix_bar) { + ret = msix_sparse_mmap_cap(vdev, &caps); + if (ret) + return ret; + } + } + + break; + case VFIO_PCI_ROM_REGION_INDEX: + { + void __iomem *io; + size_t size; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.flags = 0; + + /* Report the BAR size, not the ROM size */ + info.size = pci_resource_len(pdev, info.index); + if (!info.size) { + /* Shadow ROMs appear as PCI option ROMs */ + if (pdev->resource[PCI_ROM_RESOURCE].flags & + IORESOURCE_ROM_SHADOW) + info.size = 0x20000; + else + break; + } + + /* Is it really there? */ + io = pci_map_rom(pdev, &size); + if (!io || !size) { + info.size = 0; + break; + } + pci_unmap_rom(pdev, io); + + info.flags = VFIO_REGION_INFO_FLAG_READ; + break; + } + case VFIO_PCI_VGA_REGION_INDEX: + if (!vdev->has_vga) + return -EINVAL; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = 0xc0000; + info.flags = VFIO_REGION_INFO_FLAG_READ | + VFIO_REGION_INFO_FLAG_WRITE; + + break; + default: + if (info.index >= + VFIO_PCI_NUM_REGIONS + vdev->num_regions) + return -EINVAL; + + i = info.index - VFIO_PCI_NUM_REGIONS; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.size = vdev->region[i].size; + info.flags = vdev->region[i].flags; + + ret = region_type_cap(vdev, &caps, + vdev->region[i].type, + vdev->region[i].subtype); + if (ret) + return ret; + } + + if (caps.size) { + info.flags |= VFIO_REGION_INFO_FLAG_CAPS; + if (info.argsz < sizeof(info) + caps.size) { + info.argsz = sizeof(info) + caps.size; + info.cap_offset = 0; + } else { + vfio_info_cap_shift(&caps, sizeof(info)); + if (copy_to_user((void __user *)arg + + sizeof(info), caps.buf, + caps.size)) { + kfree(caps.buf); + return -EFAULT; + } + info.cap_offset = sizeof(info); + } + + kfree(caps.buf); + } + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; + + } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) { + struct vfio_irq_info info; + + minsz = offsetofend(struct vfio_irq_info, count); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz || info.index >= VFIO_PCI_NUM_IRQS) + return -EINVAL; + + switch (info.index) { + case VFIO_PCI_INTX_IRQ_INDEX ... VFIO_PCI_MSIX_IRQ_INDEX: + case VFIO_PCI_REQ_IRQ_INDEX: + break; + case VFIO_PCI_ERR_IRQ_INDEX: + if (pci_is_pcie(vdev->pdev)) + break; + /* pass thru to return error */ + default: + return -EINVAL; + } + + info.flags = VFIO_IRQ_INFO_EVENTFD; + + info.count = vfio_pci_get_irq_count(vdev, info.index); + + if (info.index == VFIO_PCI_INTX_IRQ_INDEX) + info.flags |= (VFIO_IRQ_INFO_MASKABLE | + VFIO_IRQ_INFO_AUTOMASKED); + else + info.flags |= VFIO_IRQ_INFO_NORESIZE; + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; + + } else if (cmd == VFIO_DEVICE_SET_IRQS) { + struct vfio_irq_set hdr; + size_t size; + u8 *data = NULL; + int max, ret = 0; + + minsz = offsetofend(struct vfio_irq_set, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz || hdr.index >= VFIO_PCI_NUM_IRQS || + hdr.count >= (U32_MAX - hdr.start) || + hdr.flags & ~(VFIO_IRQ_SET_DATA_TYPE_MASK | + VFIO_IRQ_SET_ACTION_TYPE_MASK)) + return -EINVAL; + + max = vfio_pci_get_irq_count(vdev, hdr.index); + if (hdr.start >= max || hdr.start + hdr.count > max) + return -EINVAL; + + switch (hdr.flags & VFIO_IRQ_SET_DATA_TYPE_MASK) { + case VFIO_IRQ_SET_DATA_NONE: + size = 0; + break; + case VFIO_IRQ_SET_DATA_BOOL: + size = sizeof(uint8_t); + break; + case VFIO_IRQ_SET_DATA_EVENTFD: + size = sizeof(int32_t); + break; + default: + return -EINVAL; + } + + if (size) { + if (hdr.argsz - minsz < hdr.count * size) + return -EINVAL; + + data = memdup_user((void __user *)(arg + minsz), + hdr.count * size); + if (IS_ERR(data)) + return PTR_ERR(data); + } + + mutex_lock(&vdev->igate); + + ret = vfio_pci_set_irqs_ioctl(vdev, hdr.flags, hdr.index, + hdr.start, hdr.count, data); + + mutex_unlock(&vdev->igate); + kfree(data); + + return ret; + + } else if (cmd == VFIO_DEVICE_RESET) { + return vdev->reset_works ? + pci_try_reset_function(vdev->pdev) : -EINVAL; + + } else if (cmd == VFIO_DEVICE_GET_PCI_HOT_RESET_INFO) { + struct vfio_pci_hot_reset_info hdr; + struct vfio_pci_fill_info fill = { 0 }; + struct vfio_pci_dependent_device *devices = NULL; + bool slot = false; + int ret = 0; + + minsz = offsetofend(struct vfio_pci_hot_reset_info, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz) + return -EINVAL; + + hdr.flags = 0; + + /* Can we do a slot or bus reset or neither? */ + if (!pci_probe_reset_slot(vdev->pdev->slot)) + slot = true; + else if (pci_probe_reset_bus(vdev->pdev->bus)) + return -ENODEV; + + /* How many devices are affected? */ + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_count_devs, + &fill.max, slot); + if (ret) + return ret; + + WARN_ON(!fill.max); /* Should always be at least one */ + + /* + * If there's enough space, fill it now, otherwise return + * -ENOSPC and the number of devices affected. + */ + if (hdr.argsz < sizeof(hdr) + (fill.max * sizeof(*devices))) { + ret = -ENOSPC; + hdr.count = fill.max; + goto reset_info_exit; + } + + devices = kcalloc(fill.max, sizeof(*devices), GFP_KERNEL); + if (!devices) + return -ENOMEM; + + fill.devices = devices; + + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_fill_devs, + &fill, slot); + + /* + * If a device was removed between counting and filling, + * we may come up short of fill.max. If a device was + * added, we'll have a return of -EAGAIN above. + */ + if (!ret) + hdr.count = fill.cur; + +reset_info_exit: + if (copy_to_user((void __user *)arg, &hdr, minsz)) + ret = -EFAULT; + + if (!ret) { + if (copy_to_user((void __user *)(arg + minsz), devices, + hdr.count * sizeof(*devices))) + ret = -EFAULT; + } + + kfree(devices); + return ret; + + } else if (cmd == VFIO_DEVICE_PCI_HOT_RESET) { + struct vfio_pci_hot_reset hdr; + int32_t *group_fds; + struct vfio_pci_group_entry *groups; + struct vfio_pci_group_info info; + bool slot = false; + int i, count = 0, ret = 0; + + minsz = offsetofend(struct vfio_pci_hot_reset, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz || hdr.flags) + return -EINVAL; + + /* Can we do a slot or bus reset or neither? */ + if (!pci_probe_reset_slot(vdev->pdev->slot)) + slot = true; + else if (pci_probe_reset_bus(vdev->pdev->bus)) + return -ENODEV; + + /* + * We can't let userspace give us an arbitrarily large + * buffer to copy, so verify how many we think there + * could be. Note groups can have multiple devices so + * one group per device is the max. + */ + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_count_devs, + &count, slot); + if (ret) + return ret; + + /* Somewhere between 1 and count is OK */ + if (!hdr.count || hdr.count > count) + return -EINVAL; + + group_fds = kcalloc(hdr.count, sizeof(*group_fds), GFP_KERNEL); + groups = kcalloc(hdr.count, sizeof(*groups), GFP_KERNEL); + if (!group_fds || !groups) { + kfree(group_fds); + kfree(groups); + return -ENOMEM; + } + + if (copy_from_user(group_fds, (void __user *)(arg + minsz), + hdr.count * sizeof(*group_fds))) { + kfree(group_fds); + kfree(groups); + return -EFAULT; + } + + /* + * For each group_fd, get the group through the vfio external + * user interface and store the group and iommu ID. This + * ensures the group is held across the reset. + */ + for (i = 0; i < hdr.count; i++) { + struct vfio_group *group; + struct fd f = fdget(group_fds[i]); + if (!f.file) { + ret = -EBADF; + break; + } + + group = vfio_group_get_external_user(f.file); + fdput(f); + if (IS_ERR(group)) { + ret = PTR_ERR(group); + break; + } + + groups[i].group = group; + groups[i].id = vfio_external_user_iommu_id(group); + } + + kfree(group_fds); + + /* release reference to groups on error */ + if (ret) + goto hot_reset_release; + + info.count = hdr.count; + info.groups = groups; + + /* + * Test whether all the affected devices are contained + * by the set of groups provided by the user. + */ + ret = vfio_pci_for_each_slot_or_bus(vdev->pdev, + vfio_pci_validate_devs, + &info, slot); + if (!ret) + /* User has access, do the reset */ + ret = slot ? pci_try_reset_slot(vdev->pdev->slot) : + pci_try_reset_bus(vdev->pdev->bus); + +hot_reset_release: + for (i--; i >= 0; i--) + vfio_group_put_external_user(groups[i].group); + + kfree(groups); + return ret; + } + + return -ENOTTY; +} +","@@ -829,32 +829,41 @@ static long vfio_pci_ioctl(void *device_data, + + } else if (cmd == VFIO_DEVICE_SET_IRQS) { + struct vfio_irq_set hdr; ++ size_t size; + u8 *data = NULL; +- int ret = 0; ++ int max, ret = 0; + + minsz = offsetofend(struct vfio_irq_set, count); + + if (copy_from_user(&hdr, (void __user *)arg, minsz)) + return -EFAULT; + + if (hdr.argsz < minsz || hdr.index >= VFIO_PCI_NUM_IRQS || ++ hdr.count >= (U32_MAX - hdr.start) || + hdr.flags & ~(VFIO_IRQ_SET_DATA_TYPE_MASK | + VFIO_IRQ_SET_ACTION_TYPE_MASK)) + return -EINVAL; + +- if (!(hdr.flags & VFIO_IRQ_SET_DATA_NONE)) { +- size_t size; +- int max = vfio_pci_get_irq_count(vdev, hdr.index); ++ max = vfio_pci_get_irq_count(vdev, hdr.index); ++ if (hdr.start >= max || hdr.start + hdr.count > max) ++ return -EINVAL; + +- if (hdr.flags & VFIO_IRQ_SET_DATA_BOOL) +- size = sizeof(uint8_t); +- else if (hdr.flags & VFIO_IRQ_SET_DATA_EVENTFD) +- size = sizeof(int32_t); +- else +- return -EINVAL; ++ switch (hdr.flags & VFIO_IRQ_SET_DATA_TYPE_MASK) { ++ case VFIO_IRQ_SET_DATA_NONE: ++ size = 0; ++ break; ++ case VFIO_IRQ_SET_DATA_BOOL: ++ size = sizeof(uint8_t); ++ break; ++ case VFIO_IRQ_SET_DATA_EVENTFD: ++ size = sizeof(int32_t); ++ break; ++ default: ++ return -EINVAL; ++ } + +- if (hdr.argsz - minsz < hdr.count * size || +- hdr.start >= max || hdr.start + hdr.count > max) ++ if (size) { ++ if (hdr.argsz - minsz < hdr.count * size) + return -EINVAL; + + data = memdup_user((void __user *)(arg + minsz),",3045,3281,4096 +36,"static inline void cached_cmyk_conv(unsigned char *restrict const pr, unsigned char *restrict const pg, unsigned char *restrict const pb, + unsigned int *restrict const C, unsigned int *restrict const M, unsigned int *restrict const Y, unsigned int *restrict const K, + unsigned int c, unsigned int m, unsigned int y, unsigned int k) +{ +#ifdef SLOWCMYK + unsigned int r, g, b; + unsigned int cm, c1m, cm1, c1m1, c1m1y, c1m1y1, c1my, c1my1, cm1y, cm1y1, cmy, cmy1; + unsigned int x0, x1; + + if (c == *C && m == *M && y == *Y && k == *K) + { + /* Nothing to do */ + } + else if (k == 0 && c == 0 && m == 0 && y == 0) + { + *C = 0; + *M = 0; + *Y = 0; + *K = 0; + *pr = *pg = *pb = 255; + } + else if (k == 255) + { + *C = 0; + *M = 0; + *Y = 0; + *K = 255; + *pr = *pg = *pb = 0; + } + else + { + *C = c; + *M = m; + *Y = y; + *K = k; + c += c>>7; + m += m>>7; + y += y>>7; + k += k>>7; + y >>= 1; /* Ditch 1 bit of Y to avoid overflow */ + cm = c * m; + c1m = (m<<8) - cm; + cm1 = (c<<8) - cm; + c1m1 = ((256 - m)<<8) - cm1; + c1m1y = c1m1 * y; + c1m1y1 = (c1m1<<7) - c1m1y; + c1my = c1m * y; + c1my1 = (c1m<<7) - c1my; + cm1y = cm1 * y; + cm1y1 = (cm1<<7) - cm1y; + cmy = cm * y; + cmy1 = (cm<<7) - cmy; + + /* this is a matrix multiplication, unrolled for performance */ + x1 = c1m1y1 * k; /* 0 0 0 1 */ + x0 = (c1m1y1<<8) - x1; /* 0 0 0 0 */ + x1 = x1>>8; /* From 23 fractional bits to 15 */ + r = g = b = x0; + r += 35 * x1; /* 0.1373f */ + g += 31 * x1; /* 0.1216f */ + b += 32 * x1; /* 0.1255f */ + + x1 = c1m1y * k; /* 0 0 1 1 */ + x0 = (c1m1y<<8) - x1; /* 0 0 1 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + r += 28 * x1; /* 0.1098f */ + g += 26 * x1; /* 0.1020f */ + r += x0; + x0 >>= 8; /* From 23 fractional bits to 15 */ + g += 243 * x0; /* 0.9490f */ + + x1 = c1my1 * k; /* 0 1 0 1 */ + x0 = (c1my1<<8) - x1; /* 0 1 0 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + r += 36 * x1; /* 0.1412f */ + r += 237 * x0; /* 0.9255f */ + b += 141 * x0; /* 0.5490f */ + + x1 = c1my * k; /* 0 1 1 1 */ + x0 = (c1my<<8) - x1; /* 0 1 1 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + r += 34 * x1; /* 0.1333f */ + r += 238 * x0; /* 0.9294f */ + g += 28 * x0; /* 0.1098f */ + b += 36 * x0; /* 0.1412f */ + + x1 = cm1y1 * k; /* 1 0 0 1 */ + x0 = (cm1y1<<8) - x1; /* 1 0 0 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + g += 15 * x1; /* 0.0588f */ + b += 36 * x1; /* 0.1412f */ + g += 174 * x0; /* 0.6784f */ + b += 240 * x0; /* 0.9373f */ + + x1 = cm1y * k; /* 1 0 1 1 */ + x0 = (cm1y<<8) - x1; /* 1 0 1 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + g += 19 * x1; /* 0.0745f */ + g += 167 * x0; /* 0.6510f */ + b += 80 * x0; /* 0.3137f */ + + x1 = cmy1 * k; /* 1 1 0 1 */ + x0 = (cmy1<<8) - x1; /* 1 1 0 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + b += 2 * x1; /* 0.0078f */ + r += 46 * x0; /* 0.1804f */ + g += 49 * x0; /* 0.1922f */ + b += 147 * x0; /* 0.5725f */ + + x0 = cmy * (256-k); /* 1 1 1 0 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + r += 54 * x0; /* 0.2118f */ + g += 54 * x0; /* 0.2119f */ + b += 57 * x0; /* 0.2235f */ + + r -= (r>>8); + g -= (g>>8); + b -= (b>>8); + *pr = r>>23; + *pg = g>>23; + *pb = b>>23; + } +#else + *pr = 255 - (unsigned char)fz_mini(c + k, 255); + *pg = 255 - (unsigned char)fz_mini(m + k, 255); + *pb = 255 - (unsigned char)fz_mini(y + k, 255); +#endif +} +",0,"static inline void cached_cmyk_conv(unsigned char *restrict const pr, unsigned char *restrict const pg, unsigned char *restrict const pb, + unsigned int *restrict const C, unsigned int *restrict const M, unsigned int *restrict const Y, unsigned int *restrict const K, + unsigned int c, unsigned int m, unsigned int y, unsigned int k) +{ +#ifdef SLOWCMYK + unsigned int r, g, b; + unsigned int cm, c1m, cm1, c1m1, c1m1y, c1m1y1, c1my, c1my1, cm1y, cm1y1, cmy, cmy1; + unsigned int x0, x1; + + if (c == *C && m == *M && y == *Y && k == *K) + { + /* Nothing to do */ + } + else if (k == 0 && c == 0 && m == 0 && y == 0) + { + *C = 0; + *M = 0; + *Y = 0; + *K = 0; + *pr = *pg = *pb = 255; + } + else if (k == 255) + { + *C = 0; + *M = 0; + *Y = 0; + *K = 255; + *pr = *pg = *pb = 0; + } + else + { + *C = c; + *M = m; + *Y = y; + *K = k; + c += c>>7; + m += m>>7; + y += y>>7; + k += k>>7; + y >>= 1; /* Ditch 1 bit of Y to avoid overflow */ + cm = c * m; + c1m = (m<<8) - cm; + cm1 = (c<<8) - cm; + c1m1 = ((256 - m)<<8) - cm1; + c1m1y = c1m1 * y; + c1m1y1 = (c1m1<<7) - c1m1y; + c1my = c1m * y; + c1my1 = (c1m<<7) - c1my; + cm1y = cm1 * y; + cm1y1 = (cm1<<7) - cm1y; + cmy = cm * y; + cmy1 = (cm<<7) - cmy; + + /* this is a matrix multiplication, unrolled for performance */ + x1 = c1m1y1 * k; /* 0 0 0 1 */ + x0 = (c1m1y1<<8) - x1; /* 0 0 0 0 */ + x1 = x1>>8; /* From 23 fractional bits to 15 */ + r = g = b = x0; + r += 35 * x1; /* 0.1373f */ + g += 31 * x1; /* 0.1216f */ + b += 32 * x1; /* 0.1255f */ + + x1 = c1m1y * k; /* 0 0 1 1 */ + x0 = (c1m1y<<8) - x1; /* 0 0 1 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + r += 28 * x1; /* 0.1098f */ + g += 26 * x1; /* 0.1020f */ + r += x0; + x0 >>= 8; /* From 23 fractional bits to 15 */ + g += 243 * x0; /* 0.9490f */ + + x1 = c1my1 * k; /* 0 1 0 1 */ + x0 = (c1my1<<8) - x1; /* 0 1 0 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + r += 36 * x1; /* 0.1412f */ + r += 237 * x0; /* 0.9255f */ + b += 141 * x0; /* 0.5490f */ + + x1 = c1my * k; /* 0 1 1 1 */ + x0 = (c1my<<8) - x1; /* 0 1 1 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + r += 34 * x1; /* 0.1333f */ + r += 238 * x0; /* 0.9294f */ + g += 28 * x0; /* 0.1098f */ + b += 36 * x0; /* 0.1412f */ + + x1 = cm1y1 * k; /* 1 0 0 1 */ + x0 = (cm1y1<<8) - x1; /* 1 0 0 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + g += 15 * x1; /* 0.0588f */ + b += 36 * x1; /* 0.1412f */ + g += 174 * x0; /* 0.6784f */ + b += 240 * x0; /* 0.9373f */ + + x1 = cm1y * k; /* 1 0 1 1 */ + x0 = (cm1y<<8) - x1; /* 1 0 1 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + g += 19 * x1; /* 0.0745f */ + g += 167 * x0; /* 0.6510f */ + b += 80 * x0; /* 0.3137f */ + + x1 = cmy1 * k; /* 1 1 0 1 */ + x0 = (cmy1<<8) - x1; /* 1 1 0 0 */ + x1 >>= 8; /* From 23 fractional bits to 15 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + b += 2 * x1; /* 0.0078f */ + r += 46 * x0; /* 0.1804f */ + g += 49 * x0; /* 0.1922f */ + b += 147 * x0; /* 0.5725f */ + + x0 = cmy * (256-k); /* 1 1 1 0 */ + x0 >>= 8; /* From 23 fractional bits to 15 */ + r += 54 * x0; /* 0.2118f */ + g += 54 * x0; /* 0.2119f */ + b += 57 * x0; /* 0.2235f */ + + r -= (r>>8); + g -= (g>>8); + b -= (b>>8); + *pr = r>>23; + *pg = g>>23; + *pb = b>>23; + } +#else + *pr = 255 - (unsigned char)fz_mini(c + k, 255); + *pg = 255 - (unsigned char)fz_mini(m + k, 255); + *pb = 255 - (unsigned char)fz_mini(y + k, 255); +#endif +} +","@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ + fz_drop_color_converter(ctx, &cached->base); + fz_drop_hash_table(ctx, cached->hash); + fz_free(ctx, cached); ++ cc->opaque = NULL; + fz_rethrow(ctx); + } + }",1964,2200,4096 +2266,"raptor_rdfxml_start_element_handler(void *user_data, + raptor_xml_element* xml_element) +{ + raptor_parser* rdf_parser; + raptor_rdfxml_parser* rdf_xml_parser; + raptor_rdfxml_element* element; + int ns_attributes_count = 0; + raptor_qname** named_attrs = NULL; + int i; + int count_bumped = 0; + + rdf_parser = (raptor_parser*)user_data; + rdf_xml_parser = (raptor_rdfxml_parser*)rdf_parser->context; + + if(rdf_parser->failed) + return; + + raptor_rdfxml_update_document_locator(rdf_parser); + + /* Create new element structure */ + element = RAPTOR_CALLOC(raptor_rdfxml_element*, 1, sizeof(*element)); + if(!element) { + raptor_parser_fatal_error(rdf_parser, ""Out of memory""); + rdf_parser->failed = 1; + return; + } + element->world = rdf_parser->world; + element->xml_element = xml_element; + + raptor_rdfxml_element_push(rdf_xml_parser, element); + + named_attrs = raptor_xml_element_get_attributes(xml_element); + ns_attributes_count = raptor_xml_element_get_attributes_count(xml_element); + + /* RDF-specific processing of attributes */ + if(ns_attributes_count) { + raptor_qname** new_named_attrs; + int offset = 0; + raptor_rdfxml_element* parent_element; + + parent_element = element->parent; + + /* Allocate new array to move namespaced-attributes to if + * rdf processing is performed + */ + new_named_attrs = RAPTOR_CALLOC(raptor_qname**, ns_attributes_count, + sizeof(raptor_qname*)); + if(!new_named_attrs) { + raptor_parser_fatal_error(rdf_parser, ""Out of memory""); + rdf_parser->failed = 1; + return; + } + + for(i = 0; i < ns_attributes_count; i++) { + raptor_qname* attr = named_attrs[i]; + + /* If: + * 1 We are handling RDF content and RDF processing is allowed on + * this element + * OR + * 2 We are not handling RDF content and + * this element is at the top level (top level Desc. / typedNode) + * i.e. we have no parent + * then handle the RDF attributes + */ + if((parent_element && + rdf_content_type_info[parent_element->child_content_type].rdf_processing) || + !parent_element) { + + /* Save pointers to some RDF M&S attributes */ + + /* If RDF namespace-prefixed attributes */ + if(attr->nspace && attr->nspace->is_rdf_ms) { + const unsigned char *attr_name = attr->local_name; + int j; + + for(j = 0; j <= RDF_NS_LAST; j++) + if(!strcmp((const char*)attr_name, + raptor_rdf_ns_terms_info[j].name)) { + element->rdf_attr[j] = attr->value; + element->rdf_attr_count++; + /* Delete it if it was stored elsewhere */ +#ifdef RAPTOR_DEBUG_VERBOSE + RAPTOR_DEBUG3(""Found RDF namespace attribute '%s' URI %s\n"", + (char*)attr_name, attr->value); +#endif + /* make sure value isn't deleted from qname structure */ + attr->value = NULL; + raptor_free_qname(attr); + attr = NULL; + break; + } + } /* end if RDF namespaced-prefixed attributes */ + + if(!attr) + continue; + + /* If non namespace-prefixed RDF attributes found on an element */ + if(RAPTOR_OPTIONS_GET_NUMERIC(rdf_parser, RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES) && + !attr->nspace) { + const unsigned char *attr_name = attr->local_name; + int j; + + for(j = 0; j <= RDF_NS_LAST; j++) + if(!strcmp((const char*)attr_name, + raptor_rdf_ns_terms_info[j].name)) { + element->rdf_attr[j] = attr->value; + element->rdf_attr_count++; + if(!raptor_rdf_ns_terms_info[j].allowed_unprefixed_on_attribute) + raptor_parser_warning(rdf_parser, + ""Using rdf attribute '%s' without the RDF namespace has been deprecated."", + attr_name); + + /* Delete it if it was stored elsewhere */ + /* make sure value isn't deleted from qname structure */ + attr->value = NULL; + raptor_free_qname(attr); + attr = NULL; + break; + } + } /* end if non-namespace prefixed RDF attributes */ + + if(!attr) + continue; + + } /* end if leave literal XML alone */ + + if(attr) + new_named_attrs[offset++] = attr; + } + + /* new attribute count is set from attributes that haven't been skipped */ + ns_attributes_count = offset; + if(!ns_attributes_count) { + /* all attributes were deleted so delete the new array */ + RAPTOR_FREE(raptor_qname_array, new_named_attrs); + new_named_attrs = NULL; + } + + RAPTOR_FREE(raptor_qname_array, named_attrs); + named_attrs = new_named_attrs; + raptor_xml_element_set_attributes(xml_element, + named_attrs, ns_attributes_count); + } /* end if ns_attributes_count */ + + + /* start from unknown; if we have a parent, it may set this */ + element->state = RAPTOR_STATE_UNKNOWN; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_UNKNOWN; + + if(element->parent && + element->parent->child_content_type != RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_UNKNOWN) { + element->content_type = element->parent->child_content_type; + + if(element->parent->content_type == RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_RESOURCE && + element->content_type != RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_COLLECTION && + element->content_type != RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_DAML_COLLECTION) { + raptor_qname* parent_el_name; + parent_el_name = raptor_xml_element_get_name(element->parent->xml_element); + /* If parent has an rdf:resource, this element should not be here */ + raptor_parser_error(rdf_parser, + ""property element '%s' has multiple object node elements, skipping."", + parent_el_name->local_name); + element->state = RAPTOR_STATE_SKIPPING; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PRESERVED; + + } else { + if(!element->parent->child_state) { + raptor_parser_fatal_error(rdf_parser, + ""%s: Internal error: no parent element child_state set"", + __func__); + return; + } + + element->state = element->parent->child_state; + element->parent->xml_element->content_element_seen++; + count_bumped++; + + /* leave literal XML alone */ + if(!rdf_content_type_info[element->content_type].cdata_allowed) { + if(element->parent->xml_element->content_element_seen && + element->parent->xml_element->content_cdata_seen) { + raptor_qname* parent_el_name; + + parent_el_name = raptor_xml_element_get_name(element->parent->xml_element); + /* Uh oh - mixed content, the parent element has cdata too */ + raptor_parser_warning(rdf_parser, ""element '%s' has mixed content."", + parent_el_name->local_name); + } + + /* If there is some existing all-whitespace content cdata + * before this node element, delete it + */ + if(element->parent->content_type == RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PROPERTIES && + element->parent->xml_element->content_element_seen && + element->parent->content_cdata_all_whitespace && + element->parent->xml_element->content_cdata_length) { + + element->parent->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_RESOURCE; + + raptor_free_stringbuffer(element->parent->xml_element->content_cdata_sb); + element->parent->xml_element->content_cdata_sb = NULL; + element->parent->xml_element->content_cdata_length = 0; + } + + } /* end if leave literal XML alone */ + + } /* end if parent has no rdf:resource */ + + } /* end if element->parent */ + + +#ifdef RAPTOR_DEBUG_VERBOSE + RAPTOR_DEBUG2(""Using content type %s\n"", + rdf_content_type_info[element->content_type].name); + + fprintf(stderr, ""raptor_rdfxml_start_element_handler: Start ns-element: ""); + raptor_print_xml_element(xml_element, stderr); +#endif + + + /* Check for non namespaced stuff when not in a parseType literal, other */ + if(rdf_content_type_info[element->content_type].rdf_processing) { + const raptor_namespace* ns; + + ns = raptor_xml_element_get_name(xml_element)->nspace; + /* The element */ + + /* If has no namespace or the namespace has no name (xmlns="""") */ + if((!ns || (ns && !raptor_namespace_get_uri(ns))) && element->parent) { + raptor_qname* parent_el_name; + + parent_el_name = raptor_xml_element_get_name(element->parent->xml_element); + + raptor_parser_error(rdf_parser, + ""Using an element '%s' without a namespace is forbidden."", + parent_el_name->local_name); + element->state = RAPTOR_STATE_SKIPPING; + /* Remove count above so that parent thinks this is empty */ + if(count_bumped) + element->parent->xml_element->content_element_seen--; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PRESERVED; + } + + + /* Check for any remaining non-namespaced attributes */ + if(named_attrs) { + for(i = 0; i < ns_attributes_count; i++) { + raptor_qname *attr = named_attrs[i]; + /* Check if any attributes are non-namespaced */ + if(!attr->nspace || + (attr->nspace && !raptor_namespace_get_uri(attr->nspace))) { + raptor_parser_error(rdf_parser, + ""Using an attribute '%s' without a namespace is forbidden."", + attr->local_name); + raptor_free_qname(attr); + named_attrs[i] = NULL; + } + } + } + } + + + if(element->rdf_attr[RDF_NS_aboutEach] || + element->rdf_attr[RDF_NS_aboutEachPrefix]) { + raptor_parser_warning(rdf_parser, + ""element '%s' has aboutEach / aboutEachPrefix, skipping."", + raptor_xml_element_get_name(xml_element)->local_name); + element->state = RAPTOR_STATE_SKIPPING; + /* Remove count above so that parent thinks this is empty */ + if(count_bumped) + element->parent->xml_element->content_element_seen--; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PRESERVED; + } + + /* Right, now ready to enter the grammar */ + raptor_rdfxml_start_element_grammar(rdf_parser, element); + + return; +} +",0,"raptor_rdfxml_start_element_handler(void *user_data, + raptor_xml_element* xml_element) +{ + raptor_parser* rdf_parser; + raptor_rdfxml_parser* rdf_xml_parser; + raptor_rdfxml_element* element; + int ns_attributes_count = 0; + raptor_qname** named_attrs = NULL; + int i; + int count_bumped = 0; + + rdf_parser = (raptor_parser*)user_data; + rdf_xml_parser = (raptor_rdfxml_parser*)rdf_parser->context; + + if(rdf_parser->failed) + return; + + raptor_rdfxml_update_document_locator(rdf_parser); + + /* Create new element structure */ + element = RAPTOR_CALLOC(raptor_rdfxml_element*, 1, sizeof(*element)); + if(!element) { + raptor_parser_fatal_error(rdf_parser, ""Out of memory""); + rdf_parser->failed = 1; + return; + } + element->world = rdf_parser->world; + element->xml_element = xml_element; + + raptor_rdfxml_element_push(rdf_xml_parser, element); + + named_attrs = raptor_xml_element_get_attributes(xml_element); + ns_attributes_count = raptor_xml_element_get_attributes_count(xml_element); + + /* RDF-specific processing of attributes */ + if(ns_attributes_count) { + raptor_qname** new_named_attrs; + int offset = 0; + raptor_rdfxml_element* parent_element; + + parent_element = element->parent; + + /* Allocate new array to move namespaced-attributes to if + * rdf processing is performed + */ + new_named_attrs = RAPTOR_CALLOC(raptor_qname**, ns_attributes_count, + sizeof(raptor_qname*)); + if(!new_named_attrs) { + raptor_parser_fatal_error(rdf_parser, ""Out of memory""); + rdf_parser->failed = 1; + return; + } + + for(i = 0; i < ns_attributes_count; i++) { + raptor_qname* attr = named_attrs[i]; + + /* If: + * 1 We are handling RDF content and RDF processing is allowed on + * this element + * OR + * 2 We are not handling RDF content and + * this element is at the top level (top level Desc. / typedNode) + * i.e. we have no parent + * then handle the RDF attributes + */ + if((parent_element && + rdf_content_type_info[parent_element->child_content_type].rdf_processing) || + !parent_element) { + + /* Save pointers to some RDF M&S attributes */ + + /* If RDF namespace-prefixed attributes */ + if(attr->nspace && attr->nspace->is_rdf_ms) { + const unsigned char *attr_name = attr->local_name; + int j; + + for(j = 0; j <= RDF_NS_LAST; j++) + if(!strcmp((const char*)attr_name, + raptor_rdf_ns_terms_info[j].name)) { + element->rdf_attr[j] = attr->value; + element->rdf_attr_count++; + /* Delete it if it was stored elsewhere */ +#ifdef RAPTOR_DEBUG_VERBOSE + RAPTOR_DEBUG3(""Found RDF namespace attribute '%s' URI %s\n"", + (char*)attr_name, attr->value); +#endif + /* make sure value isn't deleted from qname structure */ + attr->value = NULL; + raptor_free_qname(attr); + attr = NULL; + break; + } + } /* end if RDF namespaced-prefixed attributes */ + + if(!attr) + continue; + + /* If non namespace-prefixed RDF attributes found on an element */ + if(RAPTOR_OPTIONS_GET_NUMERIC(rdf_parser, RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES) && + !attr->nspace) { + const unsigned char *attr_name = attr->local_name; + int j; + + for(j = 0; j <= RDF_NS_LAST; j++) + if(!strcmp((const char*)attr_name, + raptor_rdf_ns_terms_info[j].name)) { + element->rdf_attr[j] = attr->value; + element->rdf_attr_count++; + if(!raptor_rdf_ns_terms_info[j].allowed_unprefixed_on_attribute) + raptor_parser_warning(rdf_parser, + ""Using rdf attribute '%s' without the RDF namespace has been deprecated."", + attr_name); + + /* Delete it if it was stored elsewhere */ + /* make sure value isn't deleted from qname structure */ + attr->value = NULL; + raptor_free_qname(attr); + attr = NULL; + break; + } + } /* end if non-namespace prefixed RDF attributes */ + + if(!attr) + continue; + + } /* end if leave literal XML alone */ + + if(attr) + new_named_attrs[offset++] = attr; + } + + /* new attribute count is set from attributes that haven't been skipped */ + ns_attributes_count = offset; + if(!ns_attributes_count) { + /* all attributes were deleted so delete the new array */ + RAPTOR_FREE(raptor_qname_array, new_named_attrs); + new_named_attrs = NULL; + } + + RAPTOR_FREE(raptor_qname_array, named_attrs); + named_attrs = new_named_attrs; + raptor_xml_element_set_attributes(xml_element, + named_attrs, ns_attributes_count); + } /* end if ns_attributes_count */ + + + /* start from unknown; if we have a parent, it may set this */ + element->state = RAPTOR_STATE_UNKNOWN; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_UNKNOWN; + + if(element->parent && + element->parent->child_content_type != RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_UNKNOWN) { + element->content_type = element->parent->child_content_type; + + if(element->parent->content_type == RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_RESOURCE && + element->content_type != RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_COLLECTION && + element->content_type != RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_DAML_COLLECTION) { + raptor_qname* parent_el_name; + parent_el_name = raptor_xml_element_get_name(element->parent->xml_element); + /* If parent has an rdf:resource, this element should not be here */ + raptor_parser_error(rdf_parser, + ""property element '%s' has multiple object node elements, skipping."", + parent_el_name->local_name); + element->state = RAPTOR_STATE_SKIPPING; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PRESERVED; + + } else { + if(!element->parent->child_state) { + raptor_parser_fatal_error(rdf_parser, + ""%s: Internal error: no parent element child_state set"", + __func__); + return; + } + + element->state = element->parent->child_state; + element->parent->xml_element->content_element_seen++; + count_bumped++; + + /* leave literal XML alone */ + if(!rdf_content_type_info[element->content_type].cdata_allowed) { + if(element->parent->xml_element->content_element_seen && + element->parent->xml_element->content_cdata_seen) { + raptor_qname* parent_el_name; + + parent_el_name = raptor_xml_element_get_name(element->parent->xml_element); + /* Uh oh - mixed content, the parent element has cdata too */ + raptor_parser_warning(rdf_parser, ""element '%s' has mixed content."", + parent_el_name->local_name); + } + + /* If there is some existing all-whitespace content cdata + * before this node element, delete it + */ + if(element->parent->content_type == RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PROPERTIES && + element->parent->xml_element->content_element_seen && + element->parent->content_cdata_all_whitespace && + element->parent->xml_element->content_cdata_length) { + + element->parent->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_RESOURCE; + + raptor_free_stringbuffer(element->parent->xml_element->content_cdata_sb); + element->parent->xml_element->content_cdata_sb = NULL; + element->parent->xml_element->content_cdata_length = 0; + } + + } /* end if leave literal XML alone */ + + } /* end if parent has no rdf:resource */ + + } /* end if element->parent */ + + +#ifdef RAPTOR_DEBUG_VERBOSE + RAPTOR_DEBUG2(""Using content type %s\n"", + rdf_content_type_info[element->content_type].name); + + fprintf(stderr, ""raptor_rdfxml_start_element_handler: Start ns-element: ""); + raptor_print_xml_element(xml_element, stderr); +#endif + + + /* Check for non namespaced stuff when not in a parseType literal, other */ + if(rdf_content_type_info[element->content_type].rdf_processing) { + const raptor_namespace* ns; + + ns = raptor_xml_element_get_name(xml_element)->nspace; + /* The element */ + + /* If has no namespace or the namespace has no name (xmlns="""") */ + if((!ns || (ns && !raptor_namespace_get_uri(ns))) && element->parent) { + raptor_qname* parent_el_name; + + parent_el_name = raptor_xml_element_get_name(element->parent->xml_element); + + raptor_parser_error(rdf_parser, + ""Using an element '%s' without a namespace is forbidden."", + parent_el_name->local_name); + element->state = RAPTOR_STATE_SKIPPING; + /* Remove count above so that parent thinks this is empty */ + if(count_bumped) + element->parent->xml_element->content_element_seen--; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PRESERVED; + } + + + /* Check for any remaining non-namespaced attributes */ + if(named_attrs) { + for(i = 0; i < ns_attributes_count; i++) { + raptor_qname *attr = named_attrs[i]; + /* Check if any attributes are non-namespaced */ + if(!attr->nspace || + (attr->nspace && !raptor_namespace_get_uri(attr->nspace))) { + raptor_parser_error(rdf_parser, + ""Using an attribute '%s' without a namespace is forbidden."", + attr->local_name); + raptor_free_qname(attr); + named_attrs[i] = NULL; + } + } + } + } + + + if(element->rdf_attr[RDF_NS_aboutEach] || + element->rdf_attr[RDF_NS_aboutEachPrefix]) { + raptor_parser_warning(rdf_parser, + ""element '%s' has aboutEach / aboutEachPrefix, skipping."", + raptor_xml_element_get_name(xml_element)->local_name); + element->state = RAPTOR_STATE_SKIPPING; + /* Remove count above so that parent thinks this is empty */ + if(count_bumped) + element->parent->xml_element->content_element_seen--; + element->content_type = RAPTOR_RDFXML_ELEMENT_CONTENT_TYPE_PRESERVED; + } + + /* Right, now ready to enter the grammar */ + raptor_rdfxml_start_element_grammar(rdf_parser, element); + + return; +} +","@@ -1004,6 +1004,9 @@ raptor_rdfxml_parse_start(raptor_parser* rdf_parser) + raptor_sax2_set_option(rdf_xml_parser->sax2, + RAPTOR_OPTION_NO_FILE, NULL, + RAPTOR_OPTIONS_GET_NUMERIC(rdf_parser, RAPTOR_OPTION_NO_FILE)); ++ raptor_sax2_set_option(rdf_xml_parser->sax2, ++ RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES, NULL, ++ RAPTOR_OPTIONS_GET_NUMERIC(rdf_parser, RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES)); + if(rdf_parser->uri_filter) + raptor_sax2_set_uri_filter(rdf_xml_parser->sax2, rdf_parser->uri_filter, + rdf_parser->uri_filter_user_data);",2384,2620,4096 +18789,"status_t BnOMX::onTransact( + uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { + switch (code) { + case LIVES_LOCALLY: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + node_id node = (node_id)data.readInt32(); + pid_t pid = (pid_t)data.readInt32(); + reply->writeInt32(livesLocally(node, pid)); + + return OK; + } + + case LIST_NODES: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + List list; + listNodes(&list); + + reply->writeInt32(list.size()); + for (List::iterator it = list.begin(); + it != list.end(); ++it) { + ComponentInfo &cur = *it; + + reply->writeString8(cur.mName); + reply->writeInt32(cur.mRoles.size()); + for (List::iterator role_it = cur.mRoles.begin(); + role_it != cur.mRoles.end(); ++role_it) { + reply->writeString8(*role_it); + } + } + + return NO_ERROR; + } + + case ALLOCATE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + const char *name = data.readCString(); + + sp observer = + interface_cast(data.readStrongBinder()); + + node_id node; + + status_t err = allocateNode(name, observer, &node); + reply->writeInt32(err); + if (err == OK) { + reply->writeInt32((int32_t)node); + } + + return NO_ERROR; + } + + case FREE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + reply->writeInt32(freeNode(node)); + + return NO_ERROR; + } + + case SEND_COMMAND: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + OMX_COMMANDTYPE cmd = + static_cast(data.readInt32()); + + OMX_S32 param = data.readInt32(); + reply->writeInt32(sendCommand(node, cmd, param)); + + return NO_ERROR; + } + + case GET_PARAMETER: + case SET_PARAMETER: + case GET_CONFIG: + case SET_CONFIG: + case SET_INTERNAL_OPTION: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_INDEXTYPE index = static_cast(data.readInt32()); + + size_t size = data.readInt64(); + + void *params = malloc(size); + data.read(params, size); + + status_t err; + switch (code) { + case GET_PARAMETER: + err = getParameter(node, index, params, size); + break; + case SET_PARAMETER: + err = setParameter(node, index, params, size); + break; + case GET_CONFIG: + err = getConfig(node, index, params, size); + break; + case SET_CONFIG: + err = setConfig(node, index, params, size); + break; + case SET_INTERNAL_OPTION: + { + InternalOptionType type = + (InternalOptionType)data.readInt32(); + + err = setInternalOption(node, index, type, params, size); + break; + } + + default: + TRESPASS(); + } + + reply->writeInt32(err); + + if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { + reply->write(params, size); + } + + free(params); + params = NULL; + + return NO_ERROR; + } + + case GET_STATE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_STATETYPE state = OMX_StateInvalid; + + status_t err = getState(node, &state); + reply->writeInt32(state); + reply->writeInt32(err); + + return NO_ERROR; + } + + case ENABLE_GRAPHIC_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + status_t err = enableGraphicBuffers(node, port_index, enable); + reply->writeInt32(err); + + return NO_ERROR; + } + + case GET_GRAPHIC_BUFFER_USAGE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + OMX_U32 usage = 0; + status_t err = getGraphicBufferUsage(node, port_index, &usage); + reply->writeInt32(err); + reply->writeInt32(usage); + + return NO_ERROR; + } + + case USE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + + buffer_id buffer; + status_t err = useBuffer(node, port_index, params, &buffer); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case USE_GRAPHIC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + + buffer_id buffer; + status_t err = useGraphicBuffer( + node, port_index, graphicBuffer, &buffer); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case UPDATE_GRAPHIC_BUFFER_IN_META: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + buffer_id buffer = (buffer_id)data.readInt32(); + + status_t err = updateGraphicBufferInMeta( + node, port_index, graphicBuffer, buffer); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CREATE_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + sp bufferProducer; + status_t err = createInputSurface(node, port_index, + &bufferProducer); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeStrongBinder(bufferProducer->asBinder()); + } + + return NO_ERROR; + } + + case SIGNAL_END_OF_INPUT_STREAM: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + status_t err = signalEndOfInputStream(node); + reply->writeInt32(err); + + return NO_ERROR; + } + + case STORE_META_DATA_IN_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + status_t err = storeMetaDataInBuffers(node, port_index, enable); + reply->writeInt32(err); + + return NO_ERROR; + } + + case PREPARE_FOR_ADAPTIVE_PLAYBACK: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + OMX_U32 max_width = data.readInt32(); + OMX_U32 max_height = data.readInt32(); + + status_t err = prepareForAdaptivePlayback( + node, port_index, enable, max_width, max_height); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CONFIGURE_VIDEO_TUNNEL_MODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + OMX_BOOL tunneled = (OMX_BOOL)data.readInt32(); + OMX_U32 audio_hw_sync = data.readInt32(); + + native_handle_t *sideband_handle; + status_t err = configureVideoTunnelMode( + node, port_index, tunneled, audio_hw_sync, &sideband_handle); + reply->writeInt32(err); + reply->writeNativeHandle(sideband_handle); + + return NO_ERROR; + } + + case ALLOC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + if (!isSecure(node) || port_index != 0 /* kPortIndexInput */) { + ALOGE(""b/24310423""); + reply->writeInt32(INVALID_OPERATION); + return NO_ERROR; + } + + size_t size = data.readInt64(); + + buffer_id buffer; + void *buffer_data; + status_t err = allocateBuffer( + node, port_index, size, &buffer, &buffer_data); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + reply->writeInt64((uintptr_t)buffer_data); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER_WITH_BACKUP: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + + buffer_id buffer; + status_t err = allocateBufferWithBackup( + node, port_index, params, &buffer); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case FREE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + reply->writeInt32(freeBuffer(node, port_index, buffer)); + + return NO_ERROR; + } + + case FILL_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + reply->writeInt32(fillBuffer(node, buffer)); + + return NO_ERROR; + } + + case EMPTY_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + OMX_U32 range_offset = data.readInt32(); + OMX_U32 range_length = data.readInt32(); + OMX_U32 flags = data.readInt32(); + OMX_TICKS timestamp = data.readInt64(); + + reply->writeInt32( + emptyBuffer( + node, buffer, range_offset, range_length, + flags, timestamp)); + + return NO_ERROR; + } + + case GET_EXTENSION_INDEX: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + const char *parameter_name = data.readCString(); + + OMX_INDEXTYPE index; + status_t err = getExtensionIndex(node, parameter_name, &index); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32(index); + } + + return OK; + } + + default: + return BBinder::onTransact(code, data, reply, flags); + } +} +",1,"status_t BnOMX::onTransact( + uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { + switch (code) { + case LIVES_LOCALLY: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + node_id node = (node_id)data.readInt32(); + pid_t pid = (pid_t)data.readInt32(); + reply->writeInt32(livesLocally(node, pid)); + + return OK; + } + + case LIST_NODES: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + List list; + listNodes(&list); + + reply->writeInt32(list.size()); + for (List::iterator it = list.begin(); + it != list.end(); ++it) { + ComponentInfo &cur = *it; + + reply->writeString8(cur.mName); + reply->writeInt32(cur.mRoles.size()); + for (List::iterator role_it = cur.mRoles.begin(); + role_it != cur.mRoles.end(); ++role_it) { + reply->writeString8(*role_it); + } + } + + return NO_ERROR; + } + + case ALLOCATE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + const char *name = data.readCString(); + + sp observer = + interface_cast(data.readStrongBinder()); + + node_id node; + + status_t err = allocateNode(name, observer, &node); + reply->writeInt32(err); + if (err == OK) { + reply->writeInt32((int32_t)node); + } + + return NO_ERROR; + } + + case FREE_NODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + reply->writeInt32(freeNode(node)); + + return NO_ERROR; + } + + case SEND_COMMAND: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + OMX_COMMANDTYPE cmd = + static_cast(data.readInt32()); + + OMX_S32 param = data.readInt32(); + reply->writeInt32(sendCommand(node, cmd, param)); + + return NO_ERROR; + } + + case GET_PARAMETER: + case SET_PARAMETER: + case GET_CONFIG: + case SET_CONFIG: + case SET_INTERNAL_OPTION: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_INDEXTYPE index = static_cast(data.readInt32()); + + size_t size = data.readInt64(); + + void *params = malloc(size); + data.read(params, size); + + status_t err; + switch (code) { + case GET_PARAMETER: + err = getParameter(node, index, params, size); + break; + case SET_PARAMETER: + err = setParameter(node, index, params, size); + break; + case GET_CONFIG: + err = getConfig(node, index, params, size); + break; + case SET_CONFIG: + err = setConfig(node, index, params, size); + break; + case SET_INTERNAL_OPTION: + { + InternalOptionType type = + (InternalOptionType)data.readInt32(); + + err = setInternalOption(node, index, type, params, size); + break; + } + + default: + TRESPASS(); + } + + reply->writeInt32(err); + + if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { + reply->write(params, size); + } + + free(params); + params = NULL; + + return NO_ERROR; + } + + case GET_STATE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_STATETYPE state = OMX_StateInvalid; + + status_t err = getState(node, &state); + reply->writeInt32(state); + reply->writeInt32(err); + + return NO_ERROR; + } + + case ENABLE_GRAPHIC_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + status_t err = enableGraphicBuffers(node, port_index, enable); + reply->writeInt32(err); + + return NO_ERROR; + } + + case GET_GRAPHIC_BUFFER_USAGE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + OMX_U32 usage = 0; + status_t err = getGraphicBufferUsage(node, port_index, &usage); + reply->writeInt32(err); + reply->writeInt32(usage); + + return NO_ERROR; + } + + case USE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + + buffer_id buffer; + status_t err = useBuffer(node, port_index, params, &buffer); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case USE_GRAPHIC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + + buffer_id buffer; + status_t err = useGraphicBuffer( + node, port_index, graphicBuffer, &buffer); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case UPDATE_GRAPHIC_BUFFER_IN_META: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp graphicBuffer = new GraphicBuffer(); + data.read(*graphicBuffer); + buffer_id buffer = (buffer_id)data.readInt32(); + + status_t err = updateGraphicBufferInMeta( + node, port_index, graphicBuffer, buffer); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CREATE_INPUT_SURFACE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + sp bufferProducer; + status_t err = createInputSurface(node, port_index, + &bufferProducer); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeStrongBinder(bufferProducer->asBinder()); + } + + return NO_ERROR; + } + + case SIGNAL_END_OF_INPUT_STREAM: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + + status_t err = signalEndOfInputStream(node); + reply->writeInt32(err); + + return NO_ERROR; + } + + case STORE_META_DATA_IN_BUFFERS: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + + status_t err = storeMetaDataInBuffers(node, port_index, enable); + reply->writeInt32(err); + + return NO_ERROR; + } + + case PREPARE_FOR_ADAPTIVE_PLAYBACK: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + OMX_BOOL enable = (OMX_BOOL)data.readInt32(); + OMX_U32 max_width = data.readInt32(); + OMX_U32 max_height = data.readInt32(); + + status_t err = prepareForAdaptivePlayback( + node, port_index, enable, max_width, max_height); + reply->writeInt32(err); + + return NO_ERROR; + } + + case CONFIGURE_VIDEO_TUNNEL_MODE: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + + OMX_BOOL tunneled = (OMX_BOOL)data.readInt32(); + OMX_U32 audio_hw_sync = data.readInt32(); + + native_handle_t *sideband_handle = NULL; + status_t err = configureVideoTunnelMode( + node, port_index, tunneled, audio_hw_sync, &sideband_handle); + reply->writeInt32(err); + if(err == OK){ + reply->writeNativeHandle(sideband_handle); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + if (!isSecure(node) || port_index != 0 /* kPortIndexInput */) { + ALOGE(""b/24310423""); + reply->writeInt32(INVALID_OPERATION); + return NO_ERROR; + } + + size_t size = data.readInt64(); + + buffer_id buffer; + void *buffer_data; + status_t err = allocateBuffer( + node, port_index, size, &buffer, &buffer_data); + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + reply->writeInt64((uintptr_t)buffer_data); + } + + return NO_ERROR; + } + + case ALLOC_BUFFER_WITH_BACKUP: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + sp params = + interface_cast(data.readStrongBinder()); + + buffer_id buffer; + status_t err = allocateBufferWithBackup( + node, port_index, params, &buffer); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32((int32_t)buffer); + } + + return NO_ERROR; + } + + case FREE_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + OMX_U32 port_index = data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + reply->writeInt32(freeBuffer(node, port_index, buffer)); + + return NO_ERROR; + } + + case FILL_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + reply->writeInt32(fillBuffer(node, buffer)); + + return NO_ERROR; + } + + case EMPTY_BUFFER: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + buffer_id buffer = (buffer_id)data.readInt32(); + OMX_U32 range_offset = data.readInt32(); + OMX_U32 range_length = data.readInt32(); + OMX_U32 flags = data.readInt32(); + OMX_TICKS timestamp = data.readInt64(); + + reply->writeInt32( + emptyBuffer( + node, buffer, range_offset, range_length, + flags, timestamp)); + + return NO_ERROR; + } + + case GET_EXTENSION_INDEX: + { + CHECK_OMX_INTERFACE(IOMX, data, reply); + + node_id node = (node_id)data.readInt32(); + const char *parameter_name = data.readCString(); + + OMX_INDEXTYPE index; + status_t err = getExtensionIndex(node, parameter_name, &index); + + reply->writeInt32(err); + + if (err == OK) { + reply->writeInt32(index); + } + + return OK; + } + + default: + return BBinder::onTransact(code, data, reply, flags); + } +} +","@@ -381,7 +381,7 @@ + + remote()->transact(CONFIGURE_VIDEO_TUNNEL_MODE, data, &reply); + + status_t err = reply.readInt32(); +- if (sidebandHandle) { ++ if (err == OK && sidebandHandle) { + *sidebandHandle = (native_handle_t *)reply.readNativeHandle(); + } + return err; +@@ -833,11 +833,13 @@ + + OMX_BOOL tunneled = (OMX_BOOL)data.readInt32(); + OMX_U32 audio_hw_sync = data.readInt32(); + +- native_handle_t *sideband_handle; ++ native_handle_t *sideband_handle = NULL; + status_t err = configureVideoTunnelMode( + node, port_index, tunneled, audio_hw_sync, &sideband_handle); + reply->writeInt32(err); +- reply->writeNativeHandle(sideband_handle); ++ if(err == OK){ ++ reply->writeNativeHandle(sideband_handle); ++ } + + return NO_ERROR; + } +",2600,2836,4096 +1318,"unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, + unsigned char *limit, int *al) +{ + int extdatalen = 0; + unsigned char *orig = buf; + unsigned char *ret = buf; +# ifndef OPENSSL_NO_EC + /* See if we support any ECC ciphersuites */ + int using_ecc = 0; + if (s->version >= TLS1_VERSION || SSL_IS_DTLS(s)) { + int i; + unsigned long alg_k, alg_a; + STACK_OF(SSL_CIPHER) *cipher_stack = SSL_get_ciphers(s); + + for (i = 0; i < sk_SSL_CIPHER_num(cipher_stack); i++) { + SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i); + + alg_k = c->algorithm_mkey; + alg_a = c->algorithm_auth; + if ((alg_k & (SSL_kEECDH | SSL_kECDHr | SSL_kECDHe) + || (alg_a & SSL_aECDSA))) { + using_ecc = 1; + break; + } + } + } +# endif + + /* don't add extensions for SSLv3 unless doing secure renegotiation */ + if (s->client_version == SSL3_VERSION && !s->s3->send_connection_binding) + return orig; + + ret += 2; + + if (ret >= limit) + return NULL; /* this really never occurs, but ... */ + + if (s->tlsext_hostname != NULL) { + /* Add TLS extension servername to the Client Hello message */ + unsigned long size_str; + long lenmax; + + /*- + * check for enough space. + * 4 for the servername type and entension length + * 2 for servernamelist length + * 1 for the hostname type + * 2 for hostname length + * + hostname length + */ + + if ((lenmax = limit - ret - 9) < 0 + || (size_str = + strlen(s->tlsext_hostname)) > (unsigned long)lenmax) + return NULL; + + /* extension type and length */ + s2n(TLSEXT_TYPE_server_name, ret); + s2n(size_str + 5, ret); + + /* length of servername list */ + s2n(size_str + 3, ret); + + /* hostname type, length and hostname */ + *(ret++) = (unsigned char)TLSEXT_NAMETYPE_host_name; + s2n(size_str, ret); + memcpy(ret, s->tlsext_hostname, size_str); + ret += size_str; + } + + /* Add RI if renegotiating */ + if (s->renegotiate) { + int el; + + if (!ssl_add_clienthello_renegotiate_ext(s, 0, &el, 0)) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + if ((limit - ret - 4 - el) < 0) + return NULL; + + s2n(TLSEXT_TYPE_renegotiate, ret); + s2n(el, ret); + + if (!ssl_add_clienthello_renegotiate_ext(s, ret, &el, el)) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + ret += el; + } +# ifndef OPENSSL_NO_SRP + /* Add SRP username if there is one */ + if (s->srp_ctx.login != NULL) { /* Add TLS extension SRP username to the + * Client Hello message */ + + int login_len = strlen(s->srp_ctx.login); + if (login_len > 255 || login_len == 0) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + /*- + * check for enough space. + * 4 for the srp type type and entension length + * 1 for the srp user identity + * + srp user identity length + */ + if ((limit - ret - 5 - login_len) < 0) + return NULL; + + /* fill in the extension */ + s2n(TLSEXT_TYPE_srp, ret); + s2n(login_len + 1, ret); + (*ret++) = (unsigned char)login_len; + memcpy(ret, s->srp_ctx.login, login_len); + ret += login_len; + } +# endif + +# ifndef OPENSSL_NO_EC + if (using_ecc) { + /* + * Add TLS extension ECPointFormats to the ClientHello message + */ + long lenmax; + const unsigned char *pcurves, *pformats; + size_t num_curves, num_formats, curves_list_len; + + tls1_get_formatlist(s, &pformats, &num_formats); + + if ((lenmax = limit - ret - 5) < 0) + return NULL; + if (num_formats > (size_t)lenmax) + return NULL; + if (num_formats > 255) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + s2n(TLSEXT_TYPE_ec_point_formats, ret); + /* The point format list has 1-byte length. */ + s2n(num_formats + 1, ret); + *(ret++) = (unsigned char)num_formats; + memcpy(ret, pformats, num_formats); + ret += num_formats; + + /* + * Add TLS extension EllipticCurves to the ClientHello message + */ + pcurves = s->tlsext_ellipticcurvelist; + if (!tls1_get_curvelist(s, 0, &pcurves, &num_curves)) + return NULL; + + if ((lenmax = limit - ret - 6) < 0) + return NULL; + if (num_curves > (size_t)lenmax / 2) + return NULL; + if (num_curves > 65532 / 2) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + curves_list_len = 2 * num_curves; + s2n(TLSEXT_TYPE_elliptic_curves, ret); + s2n(curves_list_len + 2, ret); + s2n(curves_list_len, ret); + memcpy(ret, pcurves, curves_list_len); + ret += curves_list_len; + } +# endif /* OPENSSL_NO_EC */ + + if (!(SSL_get_options(s) & SSL_OP_NO_TICKET)) { + int ticklen; + if (!s->new_session && s->session && s->session->tlsext_tick) + ticklen = s->session->tlsext_ticklen; + else if (s->session && s->tlsext_session_ticket && + s->tlsext_session_ticket->data) { + ticklen = s->tlsext_session_ticket->length; + s->session->tlsext_tick = OPENSSL_malloc(ticklen); + if (!s->session->tlsext_tick) + return NULL; + memcpy(s->session->tlsext_tick, + s->tlsext_session_ticket->data, ticklen); + s->session->tlsext_ticklen = ticklen; + } else + ticklen = 0; + if (ticklen == 0 && s->tlsext_session_ticket && + s->tlsext_session_ticket->data == NULL) + goto skip_ext; + /* + * Check for enough room 2 for extension type, 2 for len rest for + * ticket + */ + if ((long)(limit - ret - 4 - ticklen) < 0) + return NULL; + s2n(TLSEXT_TYPE_session_ticket, ret); + s2n(ticklen, ret); + if (ticklen) { + memcpy(ret, s->session->tlsext_tick, ticklen); + ret += ticklen; + } + } + skip_ext: + + if (SSL_CLIENT_USE_SIGALGS(s)) { + size_t salglen; + const unsigned char *salg; + salglen = tls12_get_psigalgs(s, &salg); + if ((size_t)(limit - ret) < salglen + 6) + return NULL; + s2n(TLSEXT_TYPE_signature_algorithms, ret); + s2n(salglen + 2, ret); + s2n(salglen, ret); + memcpy(ret, salg, salglen); + ret += salglen; + } +# ifdef TLSEXT_TYPE_opaque_prf_input + if (s->s3->client_opaque_prf_input != NULL) { + size_t col = s->s3->client_opaque_prf_input_len; + + if ((long)(limit - ret - 6 - col < 0)) + return NULL; + if (col > 0xFFFD) /* can't happen */ + return NULL; + + s2n(TLSEXT_TYPE_opaque_prf_input, ret); + s2n(col + 2, ret); + s2n(col, ret); + memcpy(ret, s->s3->client_opaque_prf_input, col); + ret += col; + } +# endif + + if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { + int i; + long extlen, idlen, itmp; + OCSP_RESPID *id; + + idlen = 0; + for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { + id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); + itmp = i2d_OCSP_RESPID(id, NULL); + if (itmp <= 0) + return NULL; + idlen += itmp + 2; + } + + if (s->tlsext_ocsp_exts) { + extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL); + if (extlen < 0) + return NULL; + } else + extlen = 0; + + if ((long)(limit - ret - 7 - extlen - idlen) < 0) + return NULL; + s2n(TLSEXT_TYPE_status_request, ret); + if (extlen + idlen > 0xFFF0) + return NULL; + s2n(extlen + idlen + 5, ret); + *(ret++) = TLSEXT_STATUSTYPE_ocsp; + s2n(idlen, ret); + for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { + /* save position of id len */ + unsigned char *q = ret; + id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); + /* skip over id len */ + ret += 2; + itmp = i2d_OCSP_RESPID(id, &ret); + /* write id len */ + s2n(itmp, q); + } + s2n(extlen, ret); + if (extlen > 0) + i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret); + } +# ifndef OPENSSL_NO_HEARTBEATS + /* Add Heartbeat extension */ + if ((limit - ret - 4 - 1) < 0) + return NULL; + s2n(TLSEXT_TYPE_heartbeat, ret); + s2n(1, ret); + /*- + * Set mode: + * 1: peer may send requests + * 2: peer not allowed to send requests + */ + if (s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_RECV_REQUESTS) + *(ret++) = SSL_TLSEXT_HB_DONT_SEND_REQUESTS; + else + *(ret++) = SSL_TLSEXT_HB_ENABLED; +# endif + +# ifndef OPENSSL_NO_NEXTPROTONEG + if (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len) { + /* + * The client advertises an emtpy extension to indicate its support + * for Next Protocol Negotiation + */ + if (limit - ret - 4 < 0) + return NULL; + s2n(TLSEXT_TYPE_next_proto_neg, ret); + s2n(0, ret); + } +# endif + + if (s->alpn_client_proto_list && !s->s3->tmp.finish_md_len) { + if ((size_t)(limit - ret) < 6 + s->alpn_client_proto_list_len) + return NULL; + s2n(TLSEXT_TYPE_application_layer_protocol_negotiation, ret); + s2n(2 + s->alpn_client_proto_list_len, ret); + s2n(s->alpn_client_proto_list_len, ret); + memcpy(ret, s->alpn_client_proto_list, s->alpn_client_proto_list_len); + ret += s->alpn_client_proto_list_len; + s->cert->alpn_sent = 1; + } +# ifndef OPENSSL_NO_SRTP + if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s)) { + int el; + + ssl_add_clienthello_use_srtp_ext(s, 0, &el, 0); + + if ((limit - ret - 4 - el) < 0) + return NULL; + + s2n(TLSEXT_TYPE_use_srtp, ret); + s2n(el, ret); + + if (ssl_add_clienthello_use_srtp_ext(s, ret, &el, el)) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + ret += el; + } +# endif + custom_ext_init(&s->cert->cli_ext); + /* Add custom TLS Extensions to ClientHello */ + if (!custom_ext_add(s, 0, &ret, limit, al)) + return NULL; + + /* + * Add padding to workaround bugs in F5 terminators. See + * https://tools.ietf.org/html/draft-agl-tls-padding-03 NB: because this + * code works out the length of all existing extensions it MUST always + * appear last. + */ + if (s->options & SSL_OP_TLSEXT_PADDING) { + int hlen = ret - (unsigned char *)s->init_buf->data; + /* + * The code in s23_clnt.c to build ClientHello messages includes the + * 5-byte record header in the buffer, while the code in s3_clnt.c + * does not. + */ + if (s->state == SSL23_ST_CW_CLNT_HELLO_A) + hlen -= 5; + if (hlen > 0xff && hlen < 0x200) { + hlen = 0x200 - hlen; + if (hlen >= 4) + hlen -= 4; + else + hlen = 0; + + s2n(TLSEXT_TYPE_padding, ret); + s2n(hlen, ret); + memset(ret, 0, hlen); + ret += hlen; + } + } + + if ((extdatalen = ret - orig - 2) == 0) + return orig; + + s2n(extdatalen, orig); + return ret; +} +",0,"unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, + unsigned char *limit, int *al) +{ + int extdatalen = 0; + unsigned char *orig = buf; + unsigned char *ret = buf; +# ifndef OPENSSL_NO_EC + /* See if we support any ECC ciphersuites */ + int using_ecc = 0; + if (s->version >= TLS1_VERSION || SSL_IS_DTLS(s)) { + int i; + unsigned long alg_k, alg_a; + STACK_OF(SSL_CIPHER) *cipher_stack = SSL_get_ciphers(s); + + for (i = 0; i < sk_SSL_CIPHER_num(cipher_stack); i++) { + SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i); + + alg_k = c->algorithm_mkey; + alg_a = c->algorithm_auth; + if ((alg_k & (SSL_kEECDH | SSL_kECDHr | SSL_kECDHe) + || (alg_a & SSL_aECDSA))) { + using_ecc = 1; + break; + } + } + } +# endif + + /* don't add extensions for SSLv3 unless doing secure renegotiation */ + if (s->client_version == SSL3_VERSION && !s->s3->send_connection_binding) + return orig; + + ret += 2; + + if (ret >= limit) + return NULL; /* this really never occurs, but ... */ + + if (s->tlsext_hostname != NULL) { + /* Add TLS extension servername to the Client Hello message */ + unsigned long size_str; + long lenmax; + + /*- + * check for enough space. + * 4 for the servername type and entension length + * 2 for servernamelist length + * 1 for the hostname type + * 2 for hostname length + * + hostname length + */ + + if ((lenmax = limit - ret - 9) < 0 + || (size_str = + strlen(s->tlsext_hostname)) > (unsigned long)lenmax) + return NULL; + + /* extension type and length */ + s2n(TLSEXT_TYPE_server_name, ret); + s2n(size_str + 5, ret); + + /* length of servername list */ + s2n(size_str + 3, ret); + + /* hostname type, length and hostname */ + *(ret++) = (unsigned char)TLSEXT_NAMETYPE_host_name; + s2n(size_str, ret); + memcpy(ret, s->tlsext_hostname, size_str); + ret += size_str; + } + + /* Add RI if renegotiating */ + if (s->renegotiate) { + int el; + + if (!ssl_add_clienthello_renegotiate_ext(s, 0, &el, 0)) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + if ((limit - ret - 4 - el) < 0) + return NULL; + + s2n(TLSEXT_TYPE_renegotiate, ret); + s2n(el, ret); + + if (!ssl_add_clienthello_renegotiate_ext(s, ret, &el, el)) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + ret += el; + } +# ifndef OPENSSL_NO_SRP + /* Add SRP username if there is one */ + if (s->srp_ctx.login != NULL) { /* Add TLS extension SRP username to the + * Client Hello message */ + + int login_len = strlen(s->srp_ctx.login); + if (login_len > 255 || login_len == 0) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + /*- + * check for enough space. + * 4 for the srp type type and entension length + * 1 for the srp user identity + * + srp user identity length + */ + if ((limit - ret - 5 - login_len) < 0) + return NULL; + + /* fill in the extension */ + s2n(TLSEXT_TYPE_srp, ret); + s2n(login_len + 1, ret); + (*ret++) = (unsigned char)login_len; + memcpy(ret, s->srp_ctx.login, login_len); + ret += login_len; + } +# endif + +# ifndef OPENSSL_NO_EC + if (using_ecc) { + /* + * Add TLS extension ECPointFormats to the ClientHello message + */ + long lenmax; + const unsigned char *pcurves, *pformats; + size_t num_curves, num_formats, curves_list_len; + + tls1_get_formatlist(s, &pformats, &num_formats); + + if ((lenmax = limit - ret - 5) < 0) + return NULL; + if (num_formats > (size_t)lenmax) + return NULL; + if (num_formats > 255) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + + s2n(TLSEXT_TYPE_ec_point_formats, ret); + /* The point format list has 1-byte length. */ + s2n(num_formats + 1, ret); + *(ret++) = (unsigned char)num_formats; + memcpy(ret, pformats, num_formats); + ret += num_formats; + + /* + * Add TLS extension EllipticCurves to the ClientHello message + */ + pcurves = s->tlsext_ellipticcurvelist; + if (!tls1_get_curvelist(s, 0, &pcurves, &num_curves)) + return NULL; + + if ((lenmax = limit - ret - 6) < 0) + return NULL; + if (num_curves > (size_t)lenmax / 2) + return NULL; + if (num_curves > 65532 / 2) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + curves_list_len = 2 * num_curves; + s2n(TLSEXT_TYPE_elliptic_curves, ret); + s2n(curves_list_len + 2, ret); + s2n(curves_list_len, ret); + memcpy(ret, pcurves, curves_list_len); + ret += curves_list_len; + } +# endif /* OPENSSL_NO_EC */ + + if (!(SSL_get_options(s) & SSL_OP_NO_TICKET)) { + int ticklen; + if (!s->new_session && s->session && s->session->tlsext_tick) + ticklen = s->session->tlsext_ticklen; + else if (s->session && s->tlsext_session_ticket && + s->tlsext_session_ticket->data) { + ticklen = s->tlsext_session_ticket->length; + s->session->tlsext_tick = OPENSSL_malloc(ticklen); + if (!s->session->tlsext_tick) + return NULL; + memcpy(s->session->tlsext_tick, + s->tlsext_session_ticket->data, ticklen); + s->session->tlsext_ticklen = ticklen; + } else + ticklen = 0; + if (ticklen == 0 && s->tlsext_session_ticket && + s->tlsext_session_ticket->data == NULL) + goto skip_ext; + /* + * Check for enough room 2 for extension type, 2 for len rest for + * ticket + */ + if ((long)(limit - ret - 4 - ticklen) < 0) + return NULL; + s2n(TLSEXT_TYPE_session_ticket, ret); + s2n(ticklen, ret); + if (ticklen) { + memcpy(ret, s->session->tlsext_tick, ticklen); + ret += ticklen; + } + } + skip_ext: + + if (SSL_CLIENT_USE_SIGALGS(s)) { + size_t salglen; + const unsigned char *salg; + salglen = tls12_get_psigalgs(s, &salg); + if ((size_t)(limit - ret) < salglen + 6) + return NULL; + s2n(TLSEXT_TYPE_signature_algorithms, ret); + s2n(salglen + 2, ret); + s2n(salglen, ret); + memcpy(ret, salg, salglen); + ret += salglen; + } +# ifdef TLSEXT_TYPE_opaque_prf_input + if (s->s3->client_opaque_prf_input != NULL) { + size_t col = s->s3->client_opaque_prf_input_len; + + if ((long)(limit - ret - 6 - col < 0)) + return NULL; + if (col > 0xFFFD) /* can't happen */ + return NULL; + + s2n(TLSEXT_TYPE_opaque_prf_input, ret); + s2n(col + 2, ret); + s2n(col, ret); + memcpy(ret, s->s3->client_opaque_prf_input, col); + ret += col; + } +# endif + + if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { + int i; + long extlen, idlen, itmp; + OCSP_RESPID *id; + + idlen = 0; + for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { + id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); + itmp = i2d_OCSP_RESPID(id, NULL); + if (itmp <= 0) + return NULL; + idlen += itmp + 2; + } + + if (s->tlsext_ocsp_exts) { + extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL); + if (extlen < 0) + return NULL; + } else + extlen = 0; + + if ((long)(limit - ret - 7 - extlen - idlen) < 0) + return NULL; + s2n(TLSEXT_TYPE_status_request, ret); + if (extlen + idlen > 0xFFF0) + return NULL; + s2n(extlen + idlen + 5, ret); + *(ret++) = TLSEXT_STATUSTYPE_ocsp; + s2n(idlen, ret); + for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { + /* save position of id len */ + unsigned char *q = ret; + id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); + /* skip over id len */ + ret += 2; + itmp = i2d_OCSP_RESPID(id, &ret); + /* write id len */ + s2n(itmp, q); + } + s2n(extlen, ret); + if (extlen > 0) + i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret); + } +# ifndef OPENSSL_NO_HEARTBEATS + /* Add Heartbeat extension */ + if ((limit - ret - 4 - 1) < 0) + return NULL; + s2n(TLSEXT_TYPE_heartbeat, ret); + s2n(1, ret); + /*- + * Set mode: + * 1: peer may send requests + * 2: peer not allowed to send requests + */ + if (s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_RECV_REQUESTS) + *(ret++) = SSL_TLSEXT_HB_DONT_SEND_REQUESTS; + else + *(ret++) = SSL_TLSEXT_HB_ENABLED; +# endif + +# ifndef OPENSSL_NO_NEXTPROTONEG + if (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len) { + /* + * The client advertises an emtpy extension to indicate its support + * for Next Protocol Negotiation + */ + if (limit - ret - 4 < 0) + return NULL; + s2n(TLSEXT_TYPE_next_proto_neg, ret); + s2n(0, ret); + } +# endif + + if (s->alpn_client_proto_list && !s->s3->tmp.finish_md_len) { + if ((size_t)(limit - ret) < 6 + s->alpn_client_proto_list_len) + return NULL; + s2n(TLSEXT_TYPE_application_layer_protocol_negotiation, ret); + s2n(2 + s->alpn_client_proto_list_len, ret); + s2n(s->alpn_client_proto_list_len, ret); + memcpy(ret, s->alpn_client_proto_list, s->alpn_client_proto_list_len); + ret += s->alpn_client_proto_list_len; + s->cert->alpn_sent = 1; + } +# ifndef OPENSSL_NO_SRTP + if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s)) { + int el; + + ssl_add_clienthello_use_srtp_ext(s, 0, &el, 0); + + if ((limit - ret - 4 - el) < 0) + return NULL; + + s2n(TLSEXT_TYPE_use_srtp, ret); + s2n(el, ret); + + if (ssl_add_clienthello_use_srtp_ext(s, ret, &el, el)) { + SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); + return NULL; + } + ret += el; + } +# endif + custom_ext_init(&s->cert->cli_ext); + /* Add custom TLS Extensions to ClientHello */ + if (!custom_ext_add(s, 0, &ret, limit, al)) + return NULL; + + /* + * Add padding to workaround bugs in F5 terminators. See + * https://tools.ietf.org/html/draft-agl-tls-padding-03 NB: because this + * code works out the length of all existing extensions it MUST always + * appear last. + */ + if (s->options & SSL_OP_TLSEXT_PADDING) { + int hlen = ret - (unsigned char *)s->init_buf->data; + /* + * The code in s23_clnt.c to build ClientHello messages includes the + * 5-byte record header in the buffer, while the code in s3_clnt.c + * does not. + */ + if (s->state == SSL23_ST_CW_CLNT_HELLO_A) + hlen -= 5; + if (hlen > 0xff && hlen < 0x200) { + hlen = 0x200 - hlen; + if (hlen >= 4) + hlen -= 4; + else + hlen = 0; + + s2n(TLSEXT_TYPE_padding, ret); + s2n(hlen, ret); + memset(ret, 0, hlen); + ret += hlen; + } + } + + if ((extdatalen = ret - orig - 2) == 0) + return orig; + + s2n(extdatalen, orig); + return ret; +} +","@@ -1867,11 +1867,11 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + 0x02, 0x03, /* SHA-1/ECDSA */ + }; + +- if (data >= (limit - 2)) ++ if (limit - data <= 2) + return; + data += 2; + +- if (data > (limit - 4)) ++ if (limit - data < 4) + return; + n2s(data, type); + n2s(data, size); +@@ -1879,7 +1879,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + if (type != TLSEXT_TYPE_server_name) + return; + +- if (data + size > limit) ++ if (limit - data < size) + return; + data += size; + +@@ -1887,7 +1887,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + const size_t len1 = sizeof(kSafariExtensionsBlock); + const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock); + +- if (data + len1 + len2 != limit) ++ if (limit - data != (int)(len1 + len2)) + return; + if (memcmp(data, kSafariExtensionsBlock, len1) != 0) + return; +@@ -1896,7 +1896,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + } else { + const size_t len = sizeof(kSafariExtensionsBlock); + +- if (data + len != limit) ++ if (limit - data != (int)(len)) + return; + if (memcmp(data, kSafariExtensionsBlock, len) != 0) + return; +@@ -2053,19 +2053,19 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, + if (data == limit) + goto ri_check; + +- if (data > (limit - 2)) ++ if (limit - data < 2) + goto err; + + n2s(data, len); + +- if (data + len != limit) ++ if (limit - data != len) + goto err; + +- while (data <= (limit - 4)) { ++ while (limit - data >= 4) { + n2s(data, type); + n2s(data, size); + +- if (data + size > (limit)) ++ if (limit - data < size) + goto err; + # if 0 + fprintf(stderr, ""Received extension type %d size %d\n"", type, size); +@@ -2472,18 +2472,18 @@ static int ssl_scan_clienthello_custom_tlsext(SSL *s, + if (s->hit || s->cert->srv_ext.meths_count == 0) + return 1; + +- if (data >= limit - 2) ++ if (limit - data <= 2) + return 1; + n2s(data, len); + +- if (data > limit - len) ++ if (limit - data < len) + return 1; + +- while (data <= limit - 4) { ++ while (limit - data >= 4) { + n2s(data, type); + n2s(data, size); + +- if (data + size > limit) ++ if (limit - data < size) + return 1; + if (custom_ext_parse(s, 1 /* server */ , type, data, size, al) <= 0) + return 0; +@@ -2569,20 +2569,20 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p, + SSL_TLSEXT_HB_DONT_SEND_REQUESTS); + # endif + +- if (data >= (d + n - 2)) ++ if ((d + n) - data <= 2) + goto ri_check; + + n2s(data, length); +- if (data + length != d + n) { ++ if ((d + n) - data != length) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + +- while (data <= (d + n - 4)) { ++ while ((d + n) - data >= 4) { + n2s(data, type); + n2s(data, size); + +- if (data + size > (d + n)) ++ if ((d + n) - data < size) + goto ri_check; + + if (s->tlsext_debug_cb) +@@ -3307,29 +3307,33 @@ int tls1_process_ticket(SSL *s, unsigned char *session_id, int len, + /* Skip past DTLS cookie */ + if (SSL_IS_DTLS(s)) { + i = *(p++); +- p += i; +- if (p >= limit) ++ ++ if (limit - p <= i) + return -1; ++ ++ p += i; + } + /* Skip past cipher list */ + n2s(p, i); +- p += i; +- if (p >= limit) ++ if (limit - p <= i) + return -1; ++ p += i; ++ + /* Skip past compression algorithm list */ + i = *(p++); +- p += i; +- if (p > limit) ++ if (limit - p < i) + return -1; ++ p += i; ++ + /* Now at start of extensions */ +- if ((p + 2) >= limit) ++ if (limit - p <= 2) + return 0; + n2s(p, i); +- while ((p + 4) <= limit) { ++ while (limit - p >= 4) { + unsigned short type, size; + n2s(p, type); + n2s(p, size); +- if (p + size > limit) ++ if (limit - p < size) + return 0; + if (type == TLSEXT_TYPE_session_ticket) { + int r;",3420,3656,4096 +18239,"int tmx_check_pretran(sip_msg_t *msg) +{ + unsigned int chid; + unsigned int slotid; + int dsize; + struct via_param *vbr; + str scallid; + str scseqmet; + str scseqnum; + str sftag; + str svbranch = {NULL, 0}; + pretran_t *it; + + if(_tmx_ptran_table==NULL) { + LM_ERR(""pretran hash table not initialized yet\n""); + return -1; + } + if(get_route_type()!=REQUEST_ROUTE) { + LM_ERR(""invalid usage - not in request route\n""); + return -1; + } + if(msg->first_line.type!=SIP_REQUEST) { + LM_ERR(""invalid usage - not a sip request\n""); + return -1; + } + if(parse_headers(msg, HDR_FROM_F|HDR_VIA1_F|HDR_CALLID_F|HDR_CSEQ_F, 0)<0) { + LM_ERR(""failed to parse required headers\n""); + return -1; + } + if(msg->cseq==NULL || msg->cseq->parsed==NULL) { + LM_ERR(""failed to parse cseq headers\n""); + return -1; + } + if(get_cseq(msg)->method_id==METHOD_ACK + || get_cseq(msg)->method_id==METHOD_CANCEL) { + LM_DBG(""no pre-transaction management for ACK or CANCEL\n""); + return -1; + } + if (msg->via1==0) { + LM_ERR(""failed to get Via header\n""); + return -1; + } + if (parse_from_header(msg)<0 || get_from(msg)->tag_value.len==0) { + LM_ERR(""failed to get From header\n""); + return -1; + } + if (msg->callid==NULL || msg->callid->body.s==NULL) { + LM_ERR(""failed to parse callid headers\n""); + return -1; + } + + vbr = msg->via1->branch; + + scallid = msg->callid->body; + trim(&scallid); + scseqmet = get_cseq(msg)->method; + trim(&scseqmet); + scseqnum = get_cseq(msg)->number; + trim(&scseqnum); + sftag = get_from(msg)->tag_value; + trim(&sftag); + + chid = get_hash1_raw(msg->callid->body.s, msg->callid->body.len); + slotid = chid & (_tmx_ptran_size-1); + + if(unlikely(_tmx_proc_ptran == NULL)) { + _tmx_proc_ptran = (pretran_t*)shm_malloc(sizeof(pretran_t)); + if(_tmx_proc_ptran == NULL) { + LM_ERR(""not enough memory for pretran structure\n""); + return -1; + } + memset(_tmx_proc_ptran, 0, sizeof(pretran_t)); + _tmx_proc_ptran->pid = my_pid(); + } + dsize = scallid.len + scseqnum.len + scseqmet.len + + sftag.len + 4; + if(likely(vbr!=NULL)) { + svbranch = vbr->value; + trim(&svbranch); + dsize += svbranch.len; + } + if(dsize<256) dsize = 256; + + tmx_pretran_unlink(); + + if(dsize > _tmx_proc_ptran->dbuf.len) { + if(_tmx_proc_ptran->dbuf.s) shm_free(_tmx_proc_ptran->dbuf.s); + _tmx_proc_ptran->dbuf.s = (char*)shm_malloc(dsize); + if(_tmx_proc_ptran->dbuf.s==NULL) { + LM_ERR(""not enough memory for pretran data\n""); + return -1; + } + _tmx_proc_ptran->dbuf.len = dsize; + } + _tmx_proc_ptran->hid = chid; + _tmx_proc_ptran->cseqmetid = (get_cseq(msg))->method_id; + + _tmx_proc_ptran->callid.s = _tmx_proc_ptran->dbuf.s; + memcpy(_tmx_proc_ptran->callid.s, scallid.s, scallid.len); + _tmx_proc_ptran->callid.len = scallid.len; + _tmx_proc_ptran->callid.s[_tmx_proc_ptran->callid.len] = '\0'; + + _tmx_proc_ptran->ftag.s = _tmx_proc_ptran->callid.s + + _tmx_proc_ptran->callid.len + 1; + memcpy(_tmx_proc_ptran->ftag.s, sftag.s, sftag.len); + _tmx_proc_ptran->ftag.len = sftag.len; + _tmx_proc_ptran->ftag.s[_tmx_proc_ptran->ftag.len] = '\0'; + + _tmx_proc_ptran->cseqnum.s = _tmx_proc_ptran->ftag.s + + _tmx_proc_ptran->ftag.len + 1; + memcpy(_tmx_proc_ptran->cseqnum.s, scseqnum.s, scseqnum.len); + _tmx_proc_ptran->cseqnum.len = scseqnum.len; + _tmx_proc_ptran->cseqnum.s[_tmx_proc_ptran->cseqnum.len] = '\0'; + + _tmx_proc_ptran->cseqmet.s = _tmx_proc_ptran->cseqnum.s + + _tmx_proc_ptran->cseqnum.len + 1; + memcpy(_tmx_proc_ptran->cseqmet.s, scseqmet.s, scseqmet.len); + _tmx_proc_ptran->cseqmet.len = scseqmet.len; + _tmx_proc_ptran->cseqmet.s[_tmx_proc_ptran->cseqmet.len] = '\0'; + + if(likely(vbr!=NULL)) { + _tmx_proc_ptran->vbranch.s = _tmx_proc_ptran->cseqmet.s + + _tmx_proc_ptran->cseqmet.len + 1; + memcpy(_tmx_proc_ptran->vbranch.s, svbranch.s, svbranch.len); + _tmx_proc_ptran->vbranch.len = svbranch.len; + _tmx_proc_ptran->vbranch.s[_tmx_proc_ptran->vbranch.len] = '\0'; + } else { + _tmx_proc_ptran->vbranch.s = NULL; + _tmx_proc_ptran->vbranch.len = 0; + } + + lock_get(&_tmx_ptran_table[slotid].lock); + it = _tmx_ptran_table[slotid].plist; + tmx_pretran_link_safe(slotid); + for(; it!=NULL; it=it->next) { + if(_tmx_proc_ptran->hid != it->hid + || _tmx_proc_ptran->cseqmetid != it->cseqmetid + || _tmx_proc_ptran->callid.len != it->callid.len + || _tmx_proc_ptran->ftag.len != it->ftag.len + || _tmx_proc_ptran->cseqmet.len != it->cseqmet.len + || _tmx_proc_ptran->cseqnum.len != it->cseqnum.len) + continue; + if(_tmx_proc_ptran->vbranch.s != NULL && it->vbranch.s != NULL) { + if(_tmx_proc_ptran->vbranch.len != it->vbranch.len) + continue; + /* shortcut - check last char in Via branch + * - kamailio/ser adds there branch index => in case of paralel + * forking by previous hop, catch it here quickly */ + if(_tmx_proc_ptran->vbranch.s[it->vbranch.len-1] + != it->vbranch.s[it->vbranch.len-1]) + continue; + if(memcmp(_tmx_proc_ptran->vbranch.s, + it->vbranch.s, it->vbranch.len)!=0) + continue; + /* shall stop by matching magic cookie? + * if (vbr && vbr->value.s && vbr->value.len > MCOOKIE_LEN + * && memcmp(vbr->value.s, MCOOKIE, MCOOKIE_LEN)==0) { + * LM_DBG(""rfc3261 cookie found in Via branch\n""); + * } + */ + } + if(memcmp(_tmx_proc_ptran->callid.s, + it->callid.s, it->callid.len)!=0 + || memcmp(_tmx_proc_ptran->ftag.s, + it->ftag.s, it->ftag.len)!=0 + || memcmp(_tmx_proc_ptran->cseqnum.s, + it->cseqnum.s, it->cseqnum.len)!=0) + continue; + if((it->cseqmetid==METHOD_OTHER || it->cseqmetid==METHOD_UNDEF) + && memcmp(_tmx_proc_ptran->cseqmet.s, + it->cseqmet.s, it->cseqmet.len)!=0) + continue; + LM_DBG(""matched another pre-transaction by pid %d for [%.*s]\n"", + it->pid, it->callid.len, it->callid.s); + lock_release(&_tmx_ptran_table[slotid].lock); + return 1; + } + lock_release(&_tmx_ptran_table[slotid].lock); + return 0; +} +",1,"int tmx_check_pretran(sip_msg_t *msg) +{ + unsigned int chid; + unsigned int slotid; + int dsize; + struct via_param *vbr; + str scallid; + str scseqmet; + str scseqnum; + str sftag; + str svbranch = {NULL, 0}; + pretran_t *it; + + if(_tmx_ptran_table==NULL) { + LM_ERR(""pretran hash table not initialized yet\n""); + return -1; + } + if(get_route_type()!=REQUEST_ROUTE) { + LM_ERR(""invalid usage - not in request route\n""); + return -1; + } + if(msg->first_line.type!=SIP_REQUEST) { + LM_ERR(""invalid usage - not a sip request\n""); + return -1; + } + if(parse_headers(msg, HDR_FROM_F|HDR_VIA1_F|HDR_CALLID_F|HDR_CSEQ_F, 0)<0) { + LM_ERR(""failed to parse required headers\n""); + return -1; + } + if(msg->cseq==NULL || msg->cseq->parsed==NULL) { + LM_ERR(""failed to parse cseq headers\n""); + return -1; + } + if(get_cseq(msg)->method_id==METHOD_ACK + || get_cseq(msg)->method_id==METHOD_CANCEL) { + LM_DBG(""no pre-transaction management for ACK or CANCEL\n""); + return -1; + } + if (msg->via1==0) { + LM_ERR(""failed to get Via header\n""); + return -1; + } + if (parse_from_header(msg)<0 || get_from(msg)->tag_value.len==0) { + LM_ERR(""failed to get From header\n""); + return -1; + } + if (msg->callid==NULL || msg->callid->body.s==NULL) { + LM_ERR(""failed to parse callid headers\n""); + return -1; + } + + vbr = msg->via1->branch; + + scallid = msg->callid->body; + trim(&scallid); + scseqmet = get_cseq(msg)->method; + trim(&scseqmet); + scseqnum = get_cseq(msg)->number; + trim(&scseqnum); + sftag = get_from(msg)->tag_value; + trim(&sftag); + + chid = get_hash1_raw(msg->callid->body.s, msg->callid->body.len); + slotid = chid & (_tmx_ptran_size-1); + + if(unlikely(_tmx_proc_ptran == NULL)) { + _tmx_proc_ptran = (pretran_t*)shm_malloc(sizeof(pretran_t)); + if(_tmx_proc_ptran == NULL) { + LM_ERR(""not enough memory for pretran structure\n""); + return -1; + } + memset(_tmx_proc_ptran, 0, sizeof(pretran_t)); + _tmx_proc_ptran->pid = my_pid(); + } + dsize = scallid.len + scseqnum.len + scseqmet.len + + sftag.len + 4; + if(likely(vbr!=NULL)) { + svbranch = vbr->value; + trim(&svbranch); + dsize += svbranch.len + 1; + } + if(dsize<256) dsize = 256; + + tmx_pretran_unlink(); + + if(dsize > _tmx_proc_ptran->dbuf.len) { + if(_tmx_proc_ptran->dbuf.s) shm_free(_tmx_proc_ptran->dbuf.s); + _tmx_proc_ptran->dbuf.s = (char*)shm_malloc(dsize); + if(_tmx_proc_ptran->dbuf.s==NULL) { + LM_ERR(""not enough memory for pretran data\n""); + return -1; + } + _tmx_proc_ptran->dbuf.len = dsize; + } + _tmx_proc_ptran->hid = chid; + _tmx_proc_ptran->cseqmetid = (get_cseq(msg))->method_id; + + _tmx_proc_ptran->callid.s = _tmx_proc_ptran->dbuf.s; + memcpy(_tmx_proc_ptran->callid.s, scallid.s, scallid.len); + _tmx_proc_ptran->callid.len = scallid.len; + _tmx_proc_ptran->callid.s[_tmx_proc_ptran->callid.len] = '\0'; + + _tmx_proc_ptran->ftag.s = _tmx_proc_ptran->callid.s + + _tmx_proc_ptran->callid.len + 1; + memcpy(_tmx_proc_ptran->ftag.s, sftag.s, sftag.len); + _tmx_proc_ptran->ftag.len = sftag.len; + _tmx_proc_ptran->ftag.s[_tmx_proc_ptran->ftag.len] = '\0'; + + _tmx_proc_ptran->cseqnum.s = _tmx_proc_ptran->ftag.s + + _tmx_proc_ptran->ftag.len + 1; + memcpy(_tmx_proc_ptran->cseqnum.s, scseqnum.s, scseqnum.len); + _tmx_proc_ptran->cseqnum.len = scseqnum.len; + _tmx_proc_ptran->cseqnum.s[_tmx_proc_ptran->cseqnum.len] = '\0'; + + _tmx_proc_ptran->cseqmet.s = _tmx_proc_ptran->cseqnum.s + + _tmx_proc_ptran->cseqnum.len + 1; + memcpy(_tmx_proc_ptran->cseqmet.s, scseqmet.s, scseqmet.len); + _tmx_proc_ptran->cseqmet.len = scseqmet.len; + _tmx_proc_ptran->cseqmet.s[_tmx_proc_ptran->cseqmet.len] = '\0'; + + if(likely(vbr!=NULL)) { + _tmx_proc_ptran->vbranch.s = _tmx_proc_ptran->cseqmet.s + + _tmx_proc_ptran->cseqmet.len + 1; + memcpy(_tmx_proc_ptran->vbranch.s, svbranch.s, svbranch.len); + _tmx_proc_ptran->vbranch.len = svbranch.len; + _tmx_proc_ptran->vbranch.s[_tmx_proc_ptran->vbranch.len] = '\0'; + } else { + _tmx_proc_ptran->vbranch.s = NULL; + _tmx_proc_ptran->vbranch.len = 0; + } + + lock_get(&_tmx_ptran_table[slotid].lock); + it = _tmx_ptran_table[slotid].plist; + tmx_pretran_link_safe(slotid); + for(; it!=NULL; it=it->next) { + if(_tmx_proc_ptran->hid != it->hid + || _tmx_proc_ptran->cseqmetid != it->cseqmetid + || _tmx_proc_ptran->callid.len != it->callid.len + || _tmx_proc_ptran->ftag.len != it->ftag.len + || _tmx_proc_ptran->cseqmet.len != it->cseqmet.len + || _tmx_proc_ptran->cseqnum.len != it->cseqnum.len) + continue; + if(_tmx_proc_ptran->vbranch.s != NULL && it->vbranch.s != NULL) { + if(_tmx_proc_ptran->vbranch.len != it->vbranch.len) + continue; + /* shortcut - check last char in Via branch + * - kamailio/ser adds there branch index => in case of paralel + * forking by previous hop, catch it here quickly */ + if(_tmx_proc_ptran->vbranch.s[it->vbranch.len-1] + != it->vbranch.s[it->vbranch.len-1]) + continue; + if(memcmp(_tmx_proc_ptran->vbranch.s, + it->vbranch.s, it->vbranch.len)!=0) + continue; + /* shall stop by matching magic cookie? + * if (vbr && vbr->value.s && vbr->value.len > MCOOKIE_LEN + * && memcmp(vbr->value.s, MCOOKIE, MCOOKIE_LEN)==0) { + * LM_DBG(""rfc3261 cookie found in Via branch\n""); + * } + */ + } + if(memcmp(_tmx_proc_ptran->callid.s, + it->callid.s, it->callid.len)!=0 + || memcmp(_tmx_proc_ptran->ftag.s, + it->ftag.s, it->ftag.len)!=0 + || memcmp(_tmx_proc_ptran->cseqnum.s, + it->cseqnum.s, it->cseqnum.len)!=0) + continue; + if((it->cseqmetid==METHOD_OTHER || it->cseqmetid==METHOD_UNDEF) + && memcmp(_tmx_proc_ptran->cseqmet.s, + it->cseqmet.s, it->cseqmet.len)!=0) + continue; + LM_DBG(""matched another pre-transaction by pid %d for [%.*s]\n"", + it->pid, it->callid.len, it->callid.s); + lock_release(&_tmx_ptran_table[slotid].lock); + return 1; + } + lock_release(&_tmx_ptran_table[slotid].lock); + return 0; +} +","@@ -260,7 +260,7 @@ int tmx_check_pretran(sip_msg_t *msg) + if(likely(vbr!=NULL)) { + svbranch = vbr->value; + trim(&svbranch); +- dsize += svbranch.len; ++ dsize += svbranch.len + 1; + } + if(dsize<256) dsize = 256; + ",2070,2306,4096 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.pkl new file mode 100644 index 0000000000000000000000000000000000000000..8c858bc4d2724f8dcf840929450bc7aa39367515 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ac8fed8211c95846e15f9d12e3a57eee3f8975aebd3265a51835dba8b67f54f +size 2772048 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.csv new file mode 100644 index 0000000000000000000000000000000000000000..904b2f651e3053a69eecdb47f038cea3fb0619c8 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.csv @@ -0,0 +1,44639 @@ +idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting +18024,"parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + guint32 str_tbl, guint8 *level, guint8 *codepage_stag, guint8 *codepage_attr, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); + guint32 off = offset; + guint32 len; + guint str_len; + guint32 ent; + guint32 idx; + guint8 peek; + guint32 tag_len; /* Length of the index (uintvar) from a LITERAL tag */ + guint8 tag_save_known = 0; /* Will contain peek & 0x3F (tag identity) */ + guint8 tag_new_known = 0; /* Will contain peek & 0x3F (tag identity) */ + const char *tag_save_literal; /* Will contain the LITERAL tag identity */ + const char *tag_new_literal; /* Will contain the LITERAL tag identity */ + guint8 parsing_tag_content = FALSE; /* Are we parsing content from a + tag with content: Content + + The initial state is FALSE. + This state will trigger recursion. */ + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag_defined (level = %u, offset = %u)\n"", *level, offset)); + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); + if ((peek & 0x3F) < 4) switch (peek) { /* Global tokens in state = STAG + but not the LITERAL tokens */ + case 0x00: /* SWITCH_PAGE */ + *codepage_stag = tvb_get_guint8 (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 2, + "" | Tag | T -->%3d "" + ""| SWITCH_PAGE (Tag code page) "" + ""|"", + *codepage_stag); + off += 2; + break; + case 0x01: /* END: only possible for Tag with Content */ + if (tag_save_known) { /* Known TAG */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| END (Known Tag 0x%02X) "" + ""| %s"", + *level, *codepage_stag, + tag_save_known, Indent (*level), + tag_save_literal); /* We already looked it up! */ + } else { /* Literal TAG */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| END (Literal Tag) "" + ""| %s"", + *level, *codepage_stag, Indent (*level), + tag_save_literal ? tag_save_literal : """"); + } + (*level)--; + off++; + /* Reset code page: not needed as return from recursion */ + DebugLog((""STAG: level = %u, Return: len = %u\n"", *level, off - offset)); + return (off - offset); + case 0x02: /* ENTITY */ + ent = tvb_get_guintvar (tvb, off+1, &len); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| ENTITY "" + ""| %s'&#%u;'"", + *level, *codepage_stag, Indent (*level), ent); + off += 1+len; + break; + case 0x03: /* STR_I */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| STR_I (Inline string) "" + ""| %s\'%s\'"", + *level, *codepage_stag, Indent(*level), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + case 0x40: /* EXT_I_0 */ + case 0x41: /* EXT_I_1 */ + case 0x42: /* EXT_I_2 */ + /* Extension tokens */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| EXT_I_%1x (Extension Token) "" + ""| %s(%s: \'%s\')"", + *level, *codepage_stag, + peek & 0x0f, Indent (*level), + map_token (map->global, 0, peek), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + case 0x43: /* PI */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| PI (XML Processing Instruction) "" + ""| %s= tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (PI) "" + ""| %s?>"", + *level, *codepage_stag, Indent (*level)); + break; + case 0x80: /* EXT_T_0 */ + case 0x81: /* EXT_T_1 */ + case 0x82: /* EXT_T_2 */ + /* Extension tokens */ + idx = tvb_get_guintvar (tvb, off+1, &len); + { char *s; + if (map->ext_t[peek & 0x03]) + s = (map->ext_t[peek & 0x03])(tvb, idx, str_tbl); + else + s = wmem_strdup_printf(wmem_packet_scope(), ""EXT_T_%1x (%s)"", peek & 0x03, + map_token (map->global, 0, peek)); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| EXT_T_%1x (Extension Token) "" + ""| %s%s"", + *level, *codepage_stag, peek & 0x0f, Indent (*level), + s); + } + off += 1+len; + break; + case 0x83: /* STR_T */ + idx = tvb_get_guintvar (tvb, off+1, &len); + str_len = tvb_strsize (tvb, str_tbl+idx); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| STR_T (Tableref string) "" + ""| %s\'%s\'"", + *level, *codepage_stag, Indent (*level), + tvb_format_text (tvb, str_tbl+idx, str_len-1)); + off += 1+len; + break; + case 0xC0: /* EXT_0 */ + case 0xC1: /* EXT_1 */ + case 0xC2: /* EXT_2 */ + /* Extension tokens */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| EXT_%1x (Extension Token) "" + ""| %s(%s)"", + *level, *codepage_stag, peek & 0x0f, Indent (*level), + map_token (map->global, 0, peek)); + off++; + break; + case 0xC3: /* OPAQUE - WBXML 1.1 and newer */ + if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */ + char *str; + if (tag_save_known) { /* Knwon tag */ + if (map->opaque_binary_tag) { + str = map->opaque_binary_tag(tvb, off + 1, + tag_save_known, *codepage_stag, &len); + } else { + str = default_opaque_binary_tag(tvb, off + 1, + tag_save_known, *codepage_stag, &len); + } + } else { /* lITERAL tag */ + if (map->opaque_literal_tag) { + str = map->opaque_literal_tag(tvb, off + 1, + tag_save_literal, *codepage_stag, &len); + } else { + str = default_opaque_literal_tag(tvb, off + 1, + tag_save_literal, *codepage_stag, &len); + } + } + proto_tree_add_text (tree, tvb, off, 1 + len, + "" %3d | Tag | T %3d "" + ""| OPAQUE (Opaque data) "" + ""| %s%s"", + *level, *codepage_stag, Indent (*level), str); + off += 1 + len; + } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| RESERVED_2 (Invalid Token!) "" + ""| WBXML 1.0 parsing stops here."", + *level, *codepage_stag); + /* Stop processing as it is impossible to parse now */ + off = tvb_len; + DebugLog((""STAG: level = %u, Return: len = %u\n"", *level, off - offset)); + return (off - offset); + } + break; + + /* No default clause, as all cases have been treated */ + } else { /* LITERAL or Known TAG */ + /* We must store the initial tag, and also retrieve the new tag. + * For efficiency reasons, we store the literal tag representation + * for known tags too, so we can easily close the tag without the + * need of a new lookup and avoiding storage of token codepage. + * + * There are 4 possibilities: + * + * 1. Known tag followed by a known tag + * 2. Known tag followed by a LITERAL tag + * 3. LITERAL tag followed by Known tag + * 4. LITERAL tag followed by LITERAL tag + */ + + /* Store the new tag */ + tag_len = 0; + if ((peek & 0x3F) == 4) { /* LITERAL */ + DebugLog((""STAG: LITERAL tag (peek = 0x%02X, off = %u) - TableRef follows!\n"", peek, off)); + idx = tvb_get_guintvar (tvb, off+1, &tag_len); + str_len = tvb_strsize (tvb, str_tbl+idx); + tag_new_literal = (const gchar*)tvb_get_ptr (tvb, str_tbl+idx, str_len); + tag_new_known = 0; /* invalidate known tag_new */ + } else { /* Known tag */ + tag_new_known = peek & 0x3F; + tag_new_literal = map_token (map->tags, *codepage_stag, + tag_new_known); + /* Stored looked up tag name string */ + } + + /* Parsing of TAG starts HERE */ + if (peek & 0x40) { /* Content present */ + /* Content follows + * [!] An explicit END token is expected in these cases! + * ==> Recursion possible if we encounter a tag with content; + * recursion will return at the explicit END token. + */ + if (parsing_tag_content) { /* Recurse */ + DebugLog((""STAG: Tag in Tag - RECURSE! (off = %u)\n"", off)); + /* Do not process the attribute list: + * recursion will take care of it */ + (*level)++; + len = parse_wbxml_tag_defined (tree, tvb, off, str_tbl, + level, codepage_stag, codepage_attr, map); + off += len; + } else { /* Now we will have content to parse */ + /* Save the start tag so we can properly close it later. */ + if ((peek & 0x3F) == 4) { /* Literal tag */ + tag_save_literal = tag_new_literal; + tag_save_known = 0; + } else { /* Known tag */ + tag_save_known = tag_new_known; + tag_save_literal = tag_new_literal; + /* The last statement avoids needless lookups */ + } + /* Process the attribute list if present */ + if (peek & 0x80) { /* Content and Attribute list present */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02X (AC) "" + ""| %s<%s"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL_AC (Literal tag) (AC) "" + ""| %s<%s"", + *level, *codepage_stag, Indent (*level), tag_new_literal); + off += 1 + tag_len; + } + len = parse_wbxml_attribute_list_defined (tree, tvb, + off, str_tbl, *level, codepage_attr, map); + /* Check that there is still room in packet */ + off += len; + if (off >= tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", + *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (attribute list) "" + ""| %s>"", + *level, *codepage_stag, Indent (*level)); + } else { /* Content, no Attribute list */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02X (.C) "" + ""| %s<%s>"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL_C (Literal Tag) (.C) "" + ""| %s<%s>"", + *level, *codepage_stag, Indent (*level), + tag_new_literal); + off += 1 + tag_len; + } + } + /* The data that follows in the parsing process + * represents content for the opening tag + * we've just processed in the lines above. + * Next time we encounter a tag with content: recurse + */ + parsing_tag_content = TRUE; + DebugLog((""Tag in Tag - No recursion this time! (off = %u)\n"", off)); + } + } else { /* No Content */ + DebugLog(("" in Tag - No recursion! (off = %u)\n"", off)); + (*level)++; + if (peek & 0x80) { /* No Content, Attribute list present */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02X (A.) "" + ""| %s<%s"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + len = parse_wbxml_attribute_list_defined (tree, tvb, + off, str_tbl, *level, codepage_attr, map); + /* Check that there is still room in packet */ + off += len; + if (off > tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (Known Tag) "" + ""| %s/>"", + *level, *codepage_stag, Indent (*level)); + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL_A (Literal Tag) (A.) "" + ""| %s<%s"", + *level, *codepage_stag, Indent (*level), tag_new_literal); + off += 1 + tag_len; + len = parse_wbxml_attribute_list_defined (tree, tvb, + off, str_tbl, *level, codepage_attr, map); + /* Check that there is still room in packet */ + off += len; + if (off >= tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (Literal Tag) "" + ""| %s/>"", + *level, *codepage_stag, Indent (*level)); + } + } else { /* No Content, No Attribute list */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02x (..) "" + ""| %s<%s />"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL (Literal Tag) (..) "" + ""| %s<%s />"", + *level, *codepage_stag, Indent (*level), + tag_new_literal); + off += 1 + tag_len; + } + } + (*level)--; + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", *level, off - offset)); + return (off - offset); +} +",1,"parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + guint32 str_tbl, guint8 *level, guint8 *codepage_stag, guint8 *codepage_attr, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); + guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; + guint32 idx; + guint8 peek; + guint32 tag_len; /* Length of the index (uintvar) from a LITERAL tag */ + guint8 tag_save_known = 0; /* Will contain peek & 0x3F (tag identity) */ + guint8 tag_new_known = 0; /* Will contain peek & 0x3F (tag identity) */ + const char *tag_save_literal; /* Will contain the LITERAL tag identity */ + const char *tag_new_literal; /* Will contain the LITERAL tag identity */ + guint8 parsing_tag_content = FALSE; /* Are we parsing content from a + tag with content: Content + + The initial state is FALSE. + This state will trigger recursion. */ + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag_defined (level = %u, offset = %u)\n"", *level, offset)); + last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); + if ((peek & 0x3F) < 4) switch (peek) { /* Global tokens in state = STAG + but not the LITERAL tokens */ + case 0x00: /* SWITCH_PAGE */ + *codepage_stag = tvb_get_guint8 (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 2, + "" | Tag | T -->%3d "" + ""| SWITCH_PAGE (Tag code page) "" + ""|"", + *codepage_stag); + off += 2; + break; + case 0x01: /* END: only possible for Tag with Content */ + if (tag_save_known) { /* Known TAG */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| END (Known Tag 0x%02X) "" + ""| %s"", + *level, *codepage_stag, + tag_save_known, Indent (*level), + tag_save_literal); /* We already looked it up! */ + } else { /* Literal TAG */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| END (Literal Tag) "" + ""| %s"", + *level, *codepage_stag, Indent (*level), + tag_save_literal ? tag_save_literal : """"); + } + (*level)--; + off++; + /* Reset code page: not needed as return from recursion */ + DebugLog((""STAG: level = %u, Return: len = %u\n"", *level, off - offset)); + return (off - offset); + case 0x02: /* ENTITY */ + ent = tvb_get_guintvar (tvb, off+1, &len); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| ENTITY "" + ""| %s'&#%u;'"", + *level, *codepage_stag, Indent (*level), ent); + off += 1+len; + break; + case 0x03: /* STR_I */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| STR_I (Inline string) "" + ""| %s\'%s\'"", + *level, *codepage_stag, Indent(*level), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + case 0x40: /* EXT_I_0 */ + case 0x41: /* EXT_I_1 */ + case 0x42: /* EXT_I_2 */ + /* Extension tokens */ + len = tvb_strsize (tvb, off+1); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| EXT_I_%1x (Extension Token) "" + ""| %s(%s: \'%s\')"", + *level, *codepage_stag, + peek & 0x0f, Indent (*level), + map_token (map->global, 0, peek), + tvb_format_text (tvb, off+1, len-1)); + off += 1+len; + break; + case 0x43: /* PI */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| PI (XML Processing Instruction) "" + ""| %s= tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (PI) "" + ""| %s?>"", + *level, *codepage_stag, Indent (*level)); + break; + case 0x80: /* EXT_T_0 */ + case 0x81: /* EXT_T_1 */ + case 0x82: /* EXT_T_2 */ + /* Extension tokens */ + idx = tvb_get_guintvar (tvb, off+1, &len); + { char *s; + if (map->ext_t[peek & 0x03]) + s = (map->ext_t[peek & 0x03])(tvb, idx, str_tbl); + else + s = wmem_strdup_printf(wmem_packet_scope(), ""EXT_T_%1x (%s)"", peek & 0x03, + map_token (map->global, 0, peek)); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| EXT_T_%1x (Extension Token) "" + ""| %s%s"", + *level, *codepage_stag, peek & 0x0f, Indent (*level), + s); + } + off += 1+len; + break; + case 0x83: /* STR_T */ + idx = tvb_get_guintvar (tvb, off+1, &len); + str_len = tvb_strsize (tvb, str_tbl+idx); + proto_tree_add_text (tree, tvb, off, 1+len, + "" %3d | Tag | T %3d "" + ""| STR_T (Tableref string) "" + ""| %s\'%s\'"", + *level, *codepage_stag, Indent (*level), + tvb_format_text (tvb, str_tbl+idx, str_len-1)); + off += 1+len; + break; + case 0xC0: /* EXT_0 */ + case 0xC1: /* EXT_1 */ + case 0xC2: /* EXT_2 */ + /* Extension tokens */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| EXT_%1x (Extension Token) "" + ""| %s(%s)"", + *level, *codepage_stag, peek & 0x0f, Indent (*level), + map_token (map->global, 0, peek)); + off++; + break; + case 0xC3: /* OPAQUE - WBXML 1.1 and newer */ + if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */ + char *str; + if (tag_save_known) { /* Knwon tag */ + if (map->opaque_binary_tag) { + str = map->opaque_binary_tag(tvb, off + 1, + tag_save_known, *codepage_stag, &len); + } else { + str = default_opaque_binary_tag(tvb, off + 1, + tag_save_known, *codepage_stag, &len); + } + } else { /* lITERAL tag */ + if (map->opaque_literal_tag) { + str = map->opaque_literal_tag(tvb, off + 1, + tag_save_literal, *codepage_stag, &len); + } else { + str = default_opaque_literal_tag(tvb, off + 1, + tag_save_literal, *codepage_stag, &len); + } + } + proto_tree_add_text (tree, tvb, off, 1 + len, + "" %3d | Tag | T %3d "" + ""| OPAQUE (Opaque data) "" + ""| %s%s"", + *level, *codepage_stag, Indent (*level), str); + off += 1 + len; + } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| RESERVED_2 (Invalid Token!) "" + ""| WBXML 1.0 parsing stops here."", + *level, *codepage_stag); + /* Stop processing as it is impossible to parse now */ + off = tvb_len; + DebugLog((""STAG: level = %u, Return: len = %u\n"", *level, off - offset)); + return (off - offset); + } + break; + + /* No default clause, as all cases have been treated */ + } else { /* LITERAL or Known TAG */ + /* We must store the initial tag, and also retrieve the new tag. + * For efficiency reasons, we store the literal tag representation + * for known tags too, so we can easily close the tag without the + * need of a new lookup and avoiding storage of token codepage. + * + * There are 4 possibilities: + * + * 1. Known tag followed by a known tag + * 2. Known tag followed by a LITERAL tag + * 3. LITERAL tag followed by Known tag + * 4. LITERAL tag followed by LITERAL tag + */ + + /* Store the new tag */ + tag_len = 0; + if ((peek & 0x3F) == 4) { /* LITERAL */ + DebugLog((""STAG: LITERAL tag (peek = 0x%02X, off = %u) - TableRef follows!\n"", peek, off)); + idx = tvb_get_guintvar (tvb, off+1, &tag_len); + str_len = tvb_strsize (tvb, str_tbl+idx); + tag_new_literal = (const gchar*)tvb_get_ptr (tvb, str_tbl+idx, str_len); + tag_new_known = 0; /* invalidate known tag_new */ + } else { /* Known tag */ + tag_new_known = peek & 0x3F; + tag_new_literal = map_token (map->tags, *codepage_stag, + tag_new_known); + /* Stored looked up tag name string */ + } + + /* Parsing of TAG starts HERE */ + if (peek & 0x40) { /* Content present */ + /* Content follows + * [!] An explicit END token is expected in these cases! + * ==> Recursion possible if we encounter a tag with content; + * recursion will return at the explicit END token. + */ + if (parsing_tag_content) { /* Recurse */ + DebugLog((""STAG: Tag in Tag - RECURSE! (off = %u)\n"", off)); + /* Do not process the attribute list: + * recursion will take care of it */ + (*level)++; + len = parse_wbxml_tag_defined (tree, tvb, off, str_tbl, + level, codepage_stag, codepage_attr, map); + off += len; + } else { /* Now we will have content to parse */ + /* Save the start tag so we can properly close it later. */ + if ((peek & 0x3F) == 4) { /* Literal tag */ + tag_save_literal = tag_new_literal; + tag_save_known = 0; + } else { /* Known tag */ + tag_save_known = tag_new_known; + tag_save_literal = tag_new_literal; + /* The last statement avoids needless lookups */ + } + /* Process the attribute list if present */ + if (peek & 0x80) { /* Content and Attribute list present */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02X (AC) "" + ""| %s<%s"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL_AC (Literal tag) (AC) "" + ""| %s<%s"", + *level, *codepage_stag, Indent (*level), tag_new_literal); + off += 1 + tag_len; + } + len = parse_wbxml_attribute_list_defined (tree, tvb, + off, str_tbl, *level, codepage_attr, map); + /* Check that there is still room in packet */ + off += len; + if (off >= tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", + *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (attribute list) "" + ""| %s>"", + *level, *codepage_stag, Indent (*level)); + } else { /* Content, no Attribute list */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02X (.C) "" + ""| %s<%s>"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL_C (Literal Tag) (.C) "" + ""| %s<%s>"", + *level, *codepage_stag, Indent (*level), + tag_new_literal); + off += 1 + tag_len; + } + } + /* The data that follows in the parsing process + * represents content for the opening tag + * we've just processed in the lines above. + * Next time we encounter a tag with content: recurse + */ + parsing_tag_content = TRUE; + DebugLog((""Tag in Tag - No recursion this time! (off = %u)\n"", off)); + } + } else { /* No Content */ + DebugLog(("" in Tag - No recursion! (off = %u)\n"", off)); + (*level)++; + if (peek & 0x80) { /* No Content, Attribute list present */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02X (A.) "" + ""| %s<%s"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + len = parse_wbxml_attribute_list_defined (tree, tvb, + off, str_tbl, *level, codepage_attr, map); + /* Check that there is still room in packet */ + off += len; + if (off > tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (Known Tag) "" + ""| %s/>"", + *level, *codepage_stag, Indent (*level)); + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL_A (Literal Tag) (A.) "" + ""| %s<%s"", + *level, *codepage_stag, Indent (*level), tag_new_literal); + off += 1 + tag_len; + len = parse_wbxml_attribute_list_defined (tree, tvb, + off, str_tbl, *level, codepage_attr, map); + /* Check that there is still room in packet */ + off += len; + if (off >= tvb_len) { + DebugLog((""STAG: level = %u, ThrowException: len = %u (short frame)\n"", *level, off - offset)); + /* + * TODO - Do we need to free g_malloc()ed memory? + */ + THROW(ReportedBoundsError); + } + proto_tree_add_text (tree, tvb, off-1, 1, + "" %3d | Tag | T %3d "" + ""| END (Literal Tag) "" + ""| %s/>"", + *level, *codepage_stag, Indent (*level)); + } + } else { /* No Content, No Attribute list */ + if (tag_new_known) { /* Known tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| Known Tag 0x%02x (..) "" + ""| %s<%s />"", + *level, *codepage_stag, tag_new_known, + Indent (*level), tag_new_literal); + /* Tag string already looked up earlier! */ + off++; + } else { /* LITERAL tag */ + proto_tree_add_text (tree, tvb, off, 1, + "" %3d | Tag | T %3d "" + ""| LITERAL (Literal Tag) (..) "" + ""| %s<%s />"", + *level, *codepage_stag, Indent (*level), + tag_new_literal); + off += 1 + tag_len; + } + } + (*level)--; + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ + if (off < last_off) { + THROW(ReportedBoundsError); + } + last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", *level, off - offset)); + return (off - offset); +} +","@@ -7304,7 +7304,7 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -7323,6 +7323,7 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag_defined (level = %u, offset = %u)\n"", *level, offset)); ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); +@@ -7694,6 +7695,10 @@ parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", *level, off - offset)); + return (off - offset); +@@ -7711,7 +7716,7 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + guint8 *codepage_stag, guint8 *codepage_attr) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -7732,6 +7737,7 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + tag_save_literal = NULL; /* Prevents compiler warning */ + + DebugLog((""parse_wbxml_tag (level = %u, offset = %u)\n"", *level, offset)); ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n"", *level, peek, off, tvb_len)); +@@ -8091,6 +8097,10 @@ parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset, + /* TODO: Do I have to reset code page here? */ + } + } /* if (tag & 0x3F) >= 5 */ ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* while */ + DebugLog((""STAG: level = %u, Return: len = %u (end of function body)\n"", + *level, off - offset)); +@@ -8126,7 +8136,7 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + const wbxml_decoding *map) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -8138,6 +8148,7 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + DebugLog((""parse_wbxml_attr_defined (level = %u, offset = %u)\n"", + level, offset)); + /* Parse attributes */ ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" +@@ -8330,6 +8341,10 @@ parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb, + off++; + } + } ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset)); +@@ -8350,7 +8365,7 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + guint32 offset, guint32 str_tbl, guint8 level, guint8 *codepage_attr) + { + guint32 tvb_len = tvb_reported_length (tvb); +- guint32 off = offset; ++ guint32 off = offset, last_off; + guint32 len; + guint str_len; + guint32 ent; +@@ -8359,6 +8374,7 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + + DebugLog((""parse_wbxml_attr (level = %u, offset = %u)\n"", level, offset)); + /* Parse attributes */ ++ last_off = off; + while (off < tvb_len) { + peek = tvb_get_guint8 (tvb, off); + DebugLog((""ATTR: (top of while) level = %3u, peek = 0x%02X, "" +@@ -8516,6 +8532,10 @@ parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb, + off++; + } + } ++ if (off < last_off) { ++ THROW(ReportedBoundsError); ++ } ++ last_off = off; + } /* End WHILE */ + DebugLog((""ATTR: level = %u, Return: len = %u (end of function body)\n"", + level, off - offset));",4839,5075,6144 +18273,"static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image *image, *image2=NULL, + *rotated_image; + register Quantum *q; + + unsigned int status; + MATHeader MATLAB_HDR; + size_t size; + size_t CellType; + QuantumInfo *quantum_info; + ImageInfo *clone_info; + int i; + ssize_t ldblk; + unsigned char *BImgBuff = NULL; + double MinVal, MaxVal; + unsigned z, z2; + unsigned Frames; + int logging; + int sample_size; + MagickOffsetType filepos=0x80; + + unsigned int (*ReadBlobXXXLong)(Image *image); + unsigned short (*ReadBlobXXXShort)(Image *image); + void (*ReadBlobDoublesXXX)(Image * image, size_t len, double *data); + void (*ReadBlobFloatsXXX)(Image * image, size_t len, float *data); + + + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + logging = LogMagickEvent(CoderEvent,GetMagickModule(),""enter""); + + /* + Open image file. + */ + image = AcquireImage(image_info,exception); + image2 = (Image *) NULL; + + status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read MATLAB image. + */ + quantum_info=(QuantumInfo *) NULL; + clone_info=(ImageInfo *) NULL; + if (ReadBlob(image,124,(unsigned char *) &MATLAB_HDR.identific) != 124) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (strncmp(MATLAB_HDR.identific,""MATLAB"",6) != 0) + { + image=ReadMATImageV4(image_info,image,exception); + if (image == NULL) + { + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + return((Image *) NULL); + } + goto END_OF_READING; + } + MATLAB_HDR.Version = ReadBlobLSBShort(image); + if(ReadBlob(image,2,(unsigned char *) &MATLAB_HDR.EndianIndicator) != 2) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + + if (logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),"" Endian %c%c"", + MATLAB_HDR.EndianIndicator[0],MATLAB_HDR.EndianIndicator[1]); + if (!strncmp(MATLAB_HDR.EndianIndicator, ""IM"", 2)) + { + ReadBlobXXXLong = ReadBlobLSBLong; + ReadBlobXXXShort = ReadBlobLSBShort; + ReadBlobDoublesXXX = ReadBlobDoublesLSB; + ReadBlobFloatsXXX = ReadBlobFloatsLSB; + image->endian = LSBEndian; + } + else if (!strncmp(MATLAB_HDR.EndianIndicator, ""MI"", 2)) + { + ReadBlobXXXLong = ReadBlobMSBLong; + ReadBlobXXXShort = ReadBlobMSBShort; + ReadBlobDoublesXXX = ReadBlobDoublesMSB; + ReadBlobFloatsXXX = ReadBlobFloatsMSB; + image->endian = MSBEndian; + } + else + { +MATLAB_KO: + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + + filepos = TellBlob(image); + while(!EOFBlob(image)) /* object parser loop */ + { + Frames = 1; + if (filepos != (unsigned int) filepos) + break; + if(SeekBlob(image,filepos,SEEK_SET) != filepos) break; + /* printf(""pos=%X\n"",TellBlob(image)); */ + + MATLAB_HDR.DataType = ReadBlobXXXLong(image); + if(EOFBlob(image)) break; + MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image); + if(EOFBlob(image)) break; + if((MagickSizeType) (MATLAB_HDR.ObjectSize+filepos) > GetBlobSize(image)) + goto MATLAB_KO; + filepos += (MagickOffsetType) MATLAB_HDR.ObjectSize + 4 + 4; + + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + clone_info=CloneImageInfo(image_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + image2 = image; +#if defined(MAGICKCORE_ZLIB_DELEGATE) + if(MATLAB_HDR.DataType == miCOMPRESSED) + { + image2 = decompress_block(image,&MATLAB_HDR.ObjectSize,clone_info,exception); + if(image2==NULL) continue; + MATLAB_HDR.DataType = ReadBlobXXXLong(image2); /* replace compressed object type. */ + } +#endif + + if (MATLAB_HDR.DataType != miMATRIX) + { + clone_info=DestroyImageInfo(clone_info); +#if defined(MAGICKCORE_ZLIB_DELEGATE) + if (image2 != image) + DeleteImageFromList(&image2); +#endif + continue; /* skip another objects. */ + } + + MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2); + MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2); + + MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2); + MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF; + MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF; + + MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2); + if(image!=image2) + MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); /* ??? don't understand why ?? */ + MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); + MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2); + MATLAB_HDR.SizeX = ReadBlobXXXLong(image2); + MATLAB_HDR.SizeY = ReadBlobXXXLong(image2); + + + switch(MATLAB_HDR.DimFlag) + { + case 8: z2=z=1; break; /* 2D matrix*/ + case 12: z2=z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/ + (void) ReadBlobXXXLong(image2); + if(z!=3) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, + ""MultidimensionalMatricesAreNotSupported""); + } + break; + case 16: z2=z = ReadBlobXXXLong(image2); /* 4D matrix animation */ + if(z!=3 && z!=1) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, + ""MultidimensionalMatricesAreNotSupported""); + } + Frames = ReadBlobXXXLong(image2); + if (Frames == 0) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (AcquireMagickResource(ListLengthResource,Frames) == MagickFalse) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(ResourceLimitError,""ListLengthExceedsLimit""); + } + break; + default: + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, ""MultidimensionalMatricesAreNotSupported""); + } + + MATLAB_HDR.Flag1 = ReadBlobXXXShort(image2); + MATLAB_HDR.NameFlag = ReadBlobXXXShort(image2); + + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + ""MATLAB_HDR.StructureClass %d"",MATLAB_HDR.StructureClass); + if (MATLAB_HDR.StructureClass != mxCHAR_CLASS && + MATLAB_HDR.StructureClass != mxSINGLE_CLASS && /* float + complex float */ + MATLAB_HDR.StructureClass != mxDOUBLE_CLASS && /* double + complex double */ + MATLAB_HDR.StructureClass != mxINT8_CLASS && + MATLAB_HDR.StructureClass != mxUINT8_CLASS && /* uint8 + uint8 3D */ + MATLAB_HDR.StructureClass != mxINT16_CLASS && + MATLAB_HDR.StructureClass != mxUINT16_CLASS && /* uint16 + uint16 3D */ + MATLAB_HDR.StructureClass != mxINT32_CLASS && + MATLAB_HDR.StructureClass != mxUINT32_CLASS && /* uint32 + uint32 3D */ + MATLAB_HDR.StructureClass != mxINT64_CLASS && + MATLAB_HDR.StructureClass != mxUINT64_CLASS) /* uint64 + uint64 3D */ + { + if ((image2 != (Image*) NULL) && (image2 != image)) + { + CloseBlob(image2); + DeleteImageFromList(&image2); + } + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + ThrowReaderException(CoderError,""UnsupportedCellTypeInTheMatrix""); + } + + switch (MATLAB_HDR.NameFlag) + { + case 0: + size = ReadBlobXXXLong(image2); /* Object name string size */ + size = 4 * (((size_t) size + 3 + 1) / 4); + (void) SeekBlob(image2, size, SEEK_CUR); + break; + case 1: + case 2: + case 3: + case 4: + (void) ReadBlob(image2, 4, (unsigned char *) &size); /* Object name string */ + break; + default: + goto MATLAB_KO; + } + + CellType = ReadBlobXXXLong(image2); /* Additional object type */ + if (logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""MATLAB_HDR.CellType: %.20g"",(double) CellType); + + /* data size */ + if (ReadBlob(image2, 4, (unsigned char *) &size) != 4) + goto MATLAB_KO; + + NEXT_FRAME: + switch (CellType) + { + case miINT8: + case miUINT8: + sample_size = 8; + if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL) + image->depth = 1; + else + image->depth = 8; /* Byte type cell */ + ldblk = (ssize_t) MATLAB_HDR.SizeX; + break; + case miINT16: + case miUINT16: + sample_size = 16; + image->depth = 16; /* Word type cell */ + ldblk = (ssize_t) (2 * MATLAB_HDR.SizeX); + break; + case miINT32: + case miUINT32: + sample_size = 32; + image->depth = 32; /* Dword type cell */ + ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX); + break; + case miINT64: + case miUINT64: + sample_size = 64; + image->depth = 64; /* Qword type cell */ + ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX); + break; + case miSINGLE: + sample_size = 32; + image->depth = 32; /* double type cell */ + (void) SetImageOption(clone_info,""quantum:format"",""floating-point""); + if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) + { /* complex float type cell */ + } + ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX); + break; + case miDOUBLE: + sample_size = 64; + image->depth = 64; /* double type cell */ + (void) SetImageOption(clone_info,""quantum:format"",""floating-point""); +DisableMSCWarning(4127) + if (sizeof(double) != 8) +RestoreMSCWarning + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, ""IncompatibleSizeOfDouble""); + } + if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) + { /* complex double type cell */ + } + ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX); + break; + default: + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (clone_info) + clone_info=DestroyImageInfo(clone_info); + ThrowReaderException(CoderError, ""UnsupportedCellTypeInTheMatrix""); + } + (void) sample_size; + image->columns = MATLAB_HDR.SizeX; + image->rows = MATLAB_HDR.SizeY; + image->colors = GetQuantumRange(image->depth); + if (image->columns == 0 || image->rows == 0) + goto MATLAB_KO; + if((unsigned int)ldblk*MATLAB_HDR.SizeY > MATLAB_HDR.ObjectSize) + goto MATLAB_KO; + /* Image is gray when no complex flag is set and 2D Matrix */ + if ((MATLAB_HDR.DimFlag == 8) && + ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0)) + { + image->type=GrayscaleType; + SetImageColorspace(image,GRAYColorspace,exception); + } + + + /* + If ping is true, then only set image size and colors without + reading any image data. + */ + if (image_info->ping) + { + size_t temp = image->columns; + image->columns = image->rows; + image->rows = temp; + goto done_reading; /* !!!!!! BAD !!!! */ + } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + return(DestroyImageList(image)); + } + (void) SetImageBackgroundColor(image,exception); + quantum_info=AcquireQuantumInfo(clone_info,image); + if (quantum_info == (QuantumInfo *) NULL) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + /* ----- Load raster data ----- */ + BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(double)); /* Ldblk was set in the check phase */ + if (BImgBuff == NULL) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (quantum_info != (QuantumInfo *) NULL) + quantum_info=DestroyQuantumInfo(quantum_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) memset(BImgBuff,0,ldblk*sizeof(double)); + + MinVal = 0; + MaxVal = 0; + if (CellType==miDOUBLE || CellType==miSINGLE) /* Find Min and Max Values for floats */ + { + CalcMinMax(image2,image_info->endian,MATLAB_HDR.SizeX,MATLAB_HDR.SizeY, + CellType,ldblk,BImgBuff,&quantum_info->minimum, + &quantum_info->maximum); + } + + /* Main loop for reading all scanlines */ + if(z==1) z=0; /* read grey scanlines */ + /* else read color scanlines */ + do + { + for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++) + { + q=GetAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT set image pixels returns unexpected NULL on a row %u."", (unsigned)(MATLAB_HDR.SizeY-i-1)); + goto done_reading; /* Skip image rotation, when cannot set image pixels */ + } + if(ReadBlob(image2,ldblk,(unsigned char *)BImgBuff) != (ssize_t) ldblk) + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT cannot read scanrow %u from a file."", (unsigned)(MATLAB_HDR.SizeY-i-1)); + goto ExitLoop; + } + if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL)) + { + FixLogical((unsigned char *)BImgBuff,ldblk); + if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0) + { +ImportQuantumPixelsFailed: + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT failed to ImportQuantumPixels for a row %u"", (unsigned)(MATLAB_HDR.SizeY-i-1)); + break; + } + } + else + { + if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0) + goto ImportQuantumPixelsFailed; + + + if (z<=1 && /* fix only during a last pass z==0 || z==1 */ + (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64)) + FixSignedValues(image,q,MATLAB_HDR.SizeX); + } + + if (!SyncAuthenticPixels(image,exception)) + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT failed to sync image pixels for a row %u"", (unsigned)(MATLAB_HDR.SizeY-i-1)); + goto ExitLoop; + } + } + } while(z-- >= 2); +ExitLoop: + if (i != (long) MATLAB_HDR.SizeY) + goto END_OF_READING; + + /* Read complex part of numbers here */ + if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) + { /* Find Min and Max Values for complex parts of floats */ + CellType = ReadBlobXXXLong(image2); /* Additional object type */ + i = ReadBlobXXXLong(image2); /* size of a complex part - toss away*/ + + if (CellType==miDOUBLE || CellType==miSINGLE) + { + CalcMinMax(image2, image_info->endian, MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &MinVal, &MaxVal); + } + + if (CellType==miDOUBLE) + for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++) + { + ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff); + if (EOFBlob(image) != MagickFalse) + break; + InsertComplexDoubleRow(image, (double *)BImgBuff, i, MinVal, MaxVal, + exception); + } + + if (CellType==miSINGLE) + for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++) + { + ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff); + if (EOFBlob(image) != MagickFalse) + break; + InsertComplexFloatRow(image,(float *)BImgBuff,i,MinVal,MaxVal, + exception); + } + } + + /* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! */ + if ((MATLAB_HDR.DimFlag == 8) && + ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0)) + image->type=GrayscaleType; + if (image->depth == 1) + image->type=BilevelType; + + if(image2==image) + image2 = NULL; /* Remove shadow copy to an image before rotation. */ + + /* Rotate image. */ + rotated_image = RotateImage(image, 90.0, exception); + if (rotated_image != (Image *) NULL) + { + /* Remove page offsets added by RotateImage */ + rotated_image->page.x=0; + rotated_image->page.y=0; + rotated_image->colors = image->colors; + DestroyBlob(rotated_image); + rotated_image->blob=ReferenceBlob(image->blob); + AppendImageToList(&image,rotated_image); + DeleteImageFromList(&image); + } + +done_reading: + + if(image2!=NULL) + if(image2!=image) + { + DeleteImageFromList(&image2); + if(clone_info) + { + if(clone_info->file) + { + fclose(clone_info->file); + clone_info->file = NULL; + (void) remove_utf8(clone_info->filename); + } + } + } + if (EOFBlob(image) != MagickFalse) + break; + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image,exception); + if (image->next == (Image *) NULL) break; + image=SyncNextImageInList(image); + image->columns=image->rows=0; + image->colors=0; + + /* row scan buffer is no longer needed */ + RelinquishMagickMemory(BImgBuff); + BImgBuff = NULL; + if (quantum_info != (QuantumInfo *) NULL) + quantum_info=DestroyQuantumInfo(quantum_info); + + if(--Frames>0) + { + z = z2; + if(image2==NULL) image2 = image; + if(!EOFBlob(image) && TellBlob(image)file) + { + fclose(clone_info->file); + clone_info->file = NULL; + (void) remove_utf8(clone_info->filename); + } + } + } + + if (clone_info) + clone_info=DestroyImageInfo(clone_info); + } + +END_OF_READING: + RelinquishMagickMemory(BImgBuff); + if (quantum_info != (QuantumInfo *) NULL) + quantum_info=DestroyQuantumInfo(quantum_info); + CloseBlob(image); + + + { + Image *p; + ssize_t scene=0; + + /* + Rewind list, removing any empty images while rewinding. + */ + p=image; + image=NULL; + while (p != (Image *) NULL) + { + Image *tmp=p; + if ((p->rows == 0) || (p->columns == 0)) { + p=p->previous; + if (tmp == image2) + image2=(Image *) NULL; + DeleteImageFromList(&tmp); + } else { + image=p; + p=p->previous; + } + } + + /* + Fix scene numbers + */ + for (p=image; p != (Image *) NULL; p=p->next) + p->scene=scene++; + } + + if(clone_info != NULL) /* cleanup garbage file from compression */ + { + if(clone_info->file) + { + fclose(clone_info->file); + clone_info->file = NULL; + (void) remove_utf8(clone_info->filename); + } + DestroyImageInfo(clone_info); + clone_info = NULL; + } + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),""return""); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (image == (Image *) NULL) + ThrowReaderException(CorruptImageError,""ImproperImageHeader"") + return(image); +} +",1,"static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ + Image *image, *image2=NULL, + *rotated_image; + register Quantum *q; + + unsigned int status; + MATHeader MATLAB_HDR; + size_t size; + size_t CellType; + QuantumInfo *quantum_info; + ImageInfo *clone_info; + int i; + ssize_t ldblk; + unsigned char *BImgBuff = NULL; + double MinVal, MaxVal; + unsigned z, z2; + unsigned Frames; + int logging; + int sample_size; + MagickOffsetType filepos=0x80; + + unsigned int (*ReadBlobXXXLong)(Image *image); + unsigned short (*ReadBlobXXXShort)(Image *image); + void (*ReadBlobDoublesXXX)(Image * image, size_t len, double *data); + void (*ReadBlobFloatsXXX)(Image * image, size_t len, float *data); + + + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + logging = LogMagickEvent(CoderEvent,GetMagickModule(),""enter""); + + /* + Open image file. + */ + image = AcquireImage(image_info,exception); + image2 = (Image *) NULL; + + status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read MATLAB image. + */ + quantum_info=(QuantumInfo *) NULL; + clone_info=(ImageInfo *) NULL; + if (ReadBlob(image,124,(unsigned char *) &MATLAB_HDR.identific) != 124) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (strncmp(MATLAB_HDR.identific,""MATLAB"",6) != 0) + { + image=ReadMATImageV4(image_info,image,exception); + if (image == NULL) + { + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + return((Image *) NULL); + } + goto END_OF_READING; + } + MATLAB_HDR.Version = ReadBlobLSBShort(image); + if(ReadBlob(image,2,(unsigned char *) &MATLAB_HDR.EndianIndicator) != 2) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + + if (logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),"" Endian %c%c"", + MATLAB_HDR.EndianIndicator[0],MATLAB_HDR.EndianIndicator[1]); + if (!strncmp(MATLAB_HDR.EndianIndicator, ""IM"", 2)) + { + ReadBlobXXXLong = ReadBlobLSBLong; + ReadBlobXXXShort = ReadBlobLSBShort; + ReadBlobDoublesXXX = ReadBlobDoublesLSB; + ReadBlobFloatsXXX = ReadBlobFloatsLSB; + image->endian = LSBEndian; + } + else if (!strncmp(MATLAB_HDR.EndianIndicator, ""MI"", 2)) + { + ReadBlobXXXLong = ReadBlobMSBLong; + ReadBlobXXXShort = ReadBlobMSBShort; + ReadBlobDoublesXXX = ReadBlobDoublesMSB; + ReadBlobFloatsXXX = ReadBlobFloatsMSB; + image->endian = MSBEndian; + } + else + { +MATLAB_KO: + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + + filepos = TellBlob(image); + while(filepos < GetBlobSize(image) && !EOFBlob(image)) /* object parser loop */ + { + Frames = 1; + if(filepos > GetBlobSize(image) || filepos < 0) + break; + if(SeekBlob(image,filepos,SEEK_SET) != filepos) break; + /* printf(""pos=%X\n"",TellBlob(image)); */ + + MATLAB_HDR.DataType = ReadBlobXXXLong(image); + if(EOFBlob(image)) break; + MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image); + if(EOFBlob(image)) break; + if((MagickSizeType) (MATLAB_HDR.ObjectSize+filepos) >= GetBlobSize(image)) + goto MATLAB_KO; + filepos += (MagickOffsetType) MATLAB_HDR.ObjectSize + 4 + 4; + + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + clone_info=CloneImageInfo(image_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + image2 = image; +#if defined(MAGICKCORE_ZLIB_DELEGATE) + if(MATLAB_HDR.DataType == miCOMPRESSED) + { + image2 = decompress_block(image,&MATLAB_HDR.ObjectSize,clone_info,exception); + if(image2==NULL) continue; + MATLAB_HDR.DataType = ReadBlobXXXLong(image2); /* replace compressed object type. */ + } +#endif + + if (MATLAB_HDR.DataType != miMATRIX) + { + clone_info=DestroyImageInfo(clone_info); +#if defined(MAGICKCORE_ZLIB_DELEGATE) + if (image2 != image) + DeleteImageFromList(&image2); +#endif + continue; /* skip another objects. */ + } + + MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2); + MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2); + + MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2); + MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF; + MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF; + + MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2); + if(image!=image2) + MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); /* ??? don't understand why ?? */ + MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); + MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2); + MATLAB_HDR.SizeX = ReadBlobXXXLong(image2); + MATLAB_HDR.SizeY = ReadBlobXXXLong(image2); + + + switch(MATLAB_HDR.DimFlag) + { + case 8: z2=z=1; break; /* 2D matrix*/ + case 12: z2=z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/ + (void) ReadBlobXXXLong(image2); + if(z!=3) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, + ""MultidimensionalMatricesAreNotSupported""); + } + break; + case 16: z2=z = ReadBlobXXXLong(image2); /* 4D matrix animation */ + if(z!=3 && z!=1) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, + ""MultidimensionalMatricesAreNotSupported""); + } + Frames = ReadBlobXXXLong(image2); + if (Frames == 0) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (AcquireMagickResource(ListLengthResource,Frames) == MagickFalse) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(ResourceLimitError,""ListLengthExceedsLimit""); + } + break; + default: + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, ""MultidimensionalMatricesAreNotSupported""); + } + + MATLAB_HDR.Flag1 = ReadBlobXXXShort(image2); + MATLAB_HDR.NameFlag = ReadBlobXXXShort(image2); + + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + ""MATLAB_HDR.StructureClass %d"",MATLAB_HDR.StructureClass); + if (MATLAB_HDR.StructureClass != mxCHAR_CLASS && + MATLAB_HDR.StructureClass != mxSINGLE_CLASS && /* float + complex float */ + MATLAB_HDR.StructureClass != mxDOUBLE_CLASS && /* double + complex double */ + MATLAB_HDR.StructureClass != mxINT8_CLASS && + MATLAB_HDR.StructureClass != mxUINT8_CLASS && /* uint8 + uint8 3D */ + MATLAB_HDR.StructureClass != mxINT16_CLASS && + MATLAB_HDR.StructureClass != mxUINT16_CLASS && /* uint16 + uint16 3D */ + MATLAB_HDR.StructureClass != mxINT32_CLASS && + MATLAB_HDR.StructureClass != mxUINT32_CLASS && /* uint32 + uint32 3D */ + MATLAB_HDR.StructureClass != mxINT64_CLASS && + MATLAB_HDR.StructureClass != mxUINT64_CLASS) /* uint64 + uint64 3D */ + { + if ((image2 != (Image*) NULL) && (image2 != image)) + { + CloseBlob(image2); + DeleteImageFromList(&image2); + } + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + ThrowReaderException(CoderError,""UnsupportedCellTypeInTheMatrix""); + } + + switch (MATLAB_HDR.NameFlag) + { + case 0: + size = ReadBlobXXXLong(image2); /* Object name string size */ + size = 4 * (((size_t) size + 3 + 1) / 4); + (void) SeekBlob(image2, size, SEEK_CUR); + break; + case 1: + case 2: + case 3: + case 4: + (void) ReadBlob(image2, 4, (unsigned char *) &size); /* Object name string */ + break; + default: + goto MATLAB_KO; + } + + CellType = ReadBlobXXXLong(image2); /* Additional object type */ + if (logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""MATLAB_HDR.CellType: %.20g"",(double) CellType); + + /* data size */ + if (ReadBlob(image2, 4, (unsigned char *) &size) != 4) + goto MATLAB_KO; + + NEXT_FRAME: + switch (CellType) + { + case miINT8: + case miUINT8: + sample_size = 8; + if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL) + image->depth = 1; + else + image->depth = 8; /* Byte type cell */ + ldblk = (ssize_t) MATLAB_HDR.SizeX; + break; + case miINT16: + case miUINT16: + sample_size = 16; + image->depth = 16; /* Word type cell */ + ldblk = (ssize_t) (2 * MATLAB_HDR.SizeX); + break; + case miINT32: + case miUINT32: + sample_size = 32; + image->depth = 32; /* Dword type cell */ + ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX); + break; + case miINT64: + case miUINT64: + sample_size = 64; + image->depth = 64; /* Qword type cell */ + ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX); + break; + case miSINGLE: + sample_size = 32; + image->depth = 32; /* double type cell */ + (void) SetImageOption(clone_info,""quantum:format"",""floating-point""); + if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) + { /* complex float type cell */ + } + ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX); + break; + case miDOUBLE: + sample_size = 64; + image->depth = 64; /* double type cell */ + (void) SetImageOption(clone_info,""quantum:format"",""floating-point""); +DisableMSCWarning(4127) + if (sizeof(double) != 8) +RestoreMSCWarning + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, ""IncompatibleSizeOfDouble""); + } + if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) + { /* complex double type cell */ + } + ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX); + break; + default: + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (clone_info) + clone_info=DestroyImageInfo(clone_info); + ThrowReaderException(CoderError, ""UnsupportedCellTypeInTheMatrix""); + } + (void) sample_size; + image->columns = MATLAB_HDR.SizeX; + image->rows = MATLAB_HDR.SizeY; + image->colors = GetQuantumRange(image->depth); + if (image->columns == 0 || image->rows == 0) + goto MATLAB_KO; + if((unsigned int)ldblk*MATLAB_HDR.SizeY > MATLAB_HDR.ObjectSize) + goto MATLAB_KO; + /* Image is gray when no complex flag is set and 2D Matrix */ + if ((MATLAB_HDR.DimFlag == 8) && + ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0)) + { + image->type=GrayscaleType; + SetImageColorspace(image,GRAYColorspace,exception); + } + + + /* + If ping is true, then only set image size and colors without + reading any image data. + */ + if (image_info->ping) + { + size_t temp = image->columns; + image->columns = image->rows; + image->rows = temp; + goto done_reading; /* !!!!!! BAD !!!! */ + } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + return(DestroyImageList(image)); + } + (void) SetImageBackgroundColor(image,exception); + quantum_info=AcquireQuantumInfo(clone_info,image); + if (quantum_info == (QuantumInfo *) NULL) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + /* ----- Load raster data ----- */ + BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(double)); /* Ldblk was set in the check phase */ + if (BImgBuff == NULL) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (quantum_info != (QuantumInfo *) NULL) + quantum_info=DestroyQuantumInfo(quantum_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) memset(BImgBuff,0,ldblk*sizeof(double)); + + MinVal = 0; + MaxVal = 0; + if (CellType==miDOUBLE || CellType==miSINGLE) /* Find Min and Max Values for floats */ + { + CalcMinMax(image2,image_info->endian,MATLAB_HDR.SizeX,MATLAB_HDR.SizeY, + CellType,ldblk,BImgBuff,&quantum_info->minimum, + &quantum_info->maximum); + } + + /* Main loop for reading all scanlines */ + if(z==1) z=0; /* read grey scanlines */ + /* else read color scanlines */ + do + { + for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++) + { + q=GetAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT set image pixels returns unexpected NULL on a row %u."", (unsigned)(MATLAB_HDR.SizeY-i-1)); + goto done_reading; /* Skip image rotation, when cannot set image pixels */ + } + if(ReadBlob(image2,ldblk,(unsigned char *)BImgBuff) != (ssize_t) ldblk) + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT cannot read scanrow %u from a file."", (unsigned)(MATLAB_HDR.SizeY-i-1)); + ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + goto ExitLoop; + } + if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL)) + { + FixLogical((unsigned char *)BImgBuff,ldblk); + if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0) + { +ImportQuantumPixelsFailed: + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT failed to ImportQuantumPixels for a row %u"", (unsigned)(MATLAB_HDR.SizeY-i-1)); + break; + } + } + else + { + if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0) + goto ImportQuantumPixelsFailed; + + + if (z<=1 && /* fix only during a last pass z==0 || z==1 */ + (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64)) + FixSignedValues(image,q,MATLAB_HDR.SizeX); + } + + if (!SyncAuthenticPixels(image,exception)) + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT failed to sync image pixels for a row %u"", (unsigned)(MATLAB_HDR.SizeY-i-1)); + goto ExitLoop; + } + } + } while(z-- >= 2); +ExitLoop: + if (i != (long) MATLAB_HDR.SizeY) + goto END_OF_READING; + + /* Read complex part of numbers here */ + if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) + { /* Find Min and Max Values for complex parts of floats */ + CellType = ReadBlobXXXLong(image2); /* Additional object type */ + i = ReadBlobXXXLong(image2); /* size of a complex part - toss away*/ + + if (CellType==miDOUBLE || CellType==miSINGLE) + { + CalcMinMax(image2, image_info->endian, MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &MinVal, &MaxVal); + } + + if (CellType==miDOUBLE) + for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++) + { + ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff); + if (EOFBlob(image) != MagickFalse) + break; + InsertComplexDoubleRow(image, (double *)BImgBuff, i, MinVal, MaxVal, + exception); + } + + if (CellType==miSINGLE) + for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++) + { + ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff); + if (EOFBlob(image) != MagickFalse) + break; + InsertComplexFloatRow(image,(float *)BImgBuff,i,MinVal,MaxVal, + exception); + } + } + + /* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! */ + if ((MATLAB_HDR.DimFlag == 8) && + ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0)) + image->type=GrayscaleType; + if (image->depth == 1) + image->type=BilevelType; + + if(image2==image) + image2 = NULL; /* Remove shadow copy to an image before rotation. */ + + /* Rotate image. */ + rotated_image = RotateImage(image, 90.0, exception); + if (rotated_image != (Image *) NULL) + { + /* Remove page offsets added by RotateImage */ + rotated_image->page.x=0; + rotated_image->page.y=0; + rotated_image->colors = image->colors; + DestroyBlob(rotated_image); + rotated_image->blob=ReferenceBlob(image->blob); + AppendImageToList(&image,rotated_image); + DeleteImageFromList(&image); + } + +done_reading: + + if(image2!=NULL) + if(image2!=image) + { + DeleteImageFromList(&image2); + if(clone_info) + { + if(clone_info->file) + { + fclose(clone_info->file); + clone_info->file = NULL; + (void) remove_utf8(clone_info->filename); + } + } + } + if (EOFBlob(image) != MagickFalse) + break; + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image,exception); + if (image->next == (Image *) NULL) break; + image=SyncNextImageInList(image); + image->columns=image->rows=0; + image->colors=0; + + /* row scan buffer is no longer needed */ + RelinquishMagickMemory(BImgBuff); + BImgBuff = NULL; + if (quantum_info != (QuantumInfo *) NULL) + quantum_info=DestroyQuantumInfo(quantum_info); + + if(--Frames>0) + { + z = z2; + if(image2==NULL) image2 = image; + if(!EOFBlob(image) && TellBlob(image)file) + { + fclose(clone_info->file); + clone_info->file = NULL; + (void) remove_utf8(clone_info->filename); + } + } + } + + if (clone_info) + clone_info=DestroyImageInfo(clone_info); + } + +END_OF_READING: + RelinquishMagickMemory(BImgBuff); + if (quantum_info != (QuantumInfo *) NULL) + quantum_info=DestroyQuantumInfo(quantum_info); + CloseBlob(image); + + + { + Image *p; + ssize_t scene=0; + + /* + Rewind list, removing any empty images while rewinding. + */ + p=image; + image=NULL; + while (p != (Image *) NULL) + { + Image *tmp=p; + if ((p->rows == 0) || (p->columns == 0)) { + p=p->previous; + if (tmp == image2) + image2=(Image *) NULL; + DeleteImageFromList(&tmp); + } else { + image=p; + p=p->previous; + } + } + + /* + Fix scene numbers + */ + for (p=image; p != (Image *) NULL; p=p->next) + p->scene=scene++; + } + + if(clone_info != NULL) /* cleanup garbage file from compression */ + { + if(clone_info->file) + { + fclose(clone_info->file); + clone_info->file = NULL; + (void) remove_utf8(clone_info->filename); + } + DestroyImageInfo(clone_info); + clone_info = NULL; + } + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),""return""); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + if (image == (Image *) NULL) + ThrowReaderException(CorruptImageError,""ImproperImageHeader"") + return(image); +} +","@@ -641,6 +641,7 @@ static Image *ReadMATImageV4(const ImageInfo *image_info,Image *image, + Object parser loop. + */ + ldblk=ReadBlobLSBLong(image); ++ if(EOFBlob(image)) break; + if ((ldblk > 9999) || (ldblk < 0)) + break; + HDR.Type[3]=ldblk % 10; ldblk /= 10; /* T digit */ +@@ -961,10 +962,10 @@ static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception) + } + + filepos = TellBlob(image); +- while(!EOFBlob(image)) /* object parser loop */ ++ while(filepos < GetBlobSize(image) && !EOFBlob(image)) /* object parser loop */ + { + Frames = 1; +- if (filepos != (unsigned int) filepos) ++ if(filepos > GetBlobSize(image) || filepos < 0) + break; + if(SeekBlob(image,filepos,SEEK_SET) != filepos) break; + /* printf(""pos=%X\n"",TellBlob(image)); */ +@@ -973,7 +974,7 @@ static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception) + if(EOFBlob(image)) break; + MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image); + if(EOFBlob(image)) break; +- if((MagickSizeType) (MATLAB_HDR.ObjectSize+filepos) > GetBlobSize(image)) ++ if((MagickSizeType) (MATLAB_HDR.ObjectSize+filepos) >= GetBlobSize(image)) + goto MATLAB_KO; + filepos += (MagickOffsetType) MATLAB_HDR.ObjectSize + 4 + 4; + +@@ -1276,6 +1277,7 @@ RestoreMSCWarning + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + "" MAT cannot read scanrow %u from a file."", (unsigned)(MATLAB_HDR.SizeY-i-1)); ++ ThrowReaderException(CorruptImageError,""UnexpectedEndOfFile""); + goto ExitLoop; + } + if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL))",5637,5873,6144 +18025,"fp_set_per_packet_inf_from_conv(umts_fp_conversation_info_t *p_conv_data, + tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree _U_) +{ + fp_info *fpi; + guint8 tfi, c_t; + int offset = 0, i=0, j=0, num_tbs, chan, tb_size, tb_bit_off; + gboolean is_control_frame; + umts_mac_info *macinf; + rlc_info *rlcinf; + guint8 fake_lchid=0; + gint *cur_val=NULL; + + fpi = wmem_new0(wmem_file_scope(), fp_info); + p_add_proto_data(wmem_file_scope(), pinfo, proto_fp, 0, fpi); + + fpi->iface_type = p_conv_data->iface_type; + fpi->division = p_conv_data->division; + fpi->release = 7; /* Set values greater then the checks performed */ + fpi->release_year = 2006; + fpi->release_month = 12; + fpi->channel = p_conv_data->channel; + fpi->dch_crc_present = p_conv_data->dch_crc_present; + /*fpi->paging_indications;*/ + fpi->link_type = FP_Link_Ethernet; + +#if 0 + /*Only do this the first run, signals that we need to reset the RLC fragtable*/ + if (!pinfo->fd->flags.visited && p_conv_data->reset_frag ) { + fpi->reset_frag = p_conv_data->reset_frag; + p_conv_data->reset_frag = FALSE; + } +#endif + /* remember 'lower' UDP layer port information so we can later + * differentiate 'lower' UDP layer from 'user data' UDP layer */ + fpi->srcport = pinfo->srcport; + fpi->destport = pinfo->destport; + + fpi->com_context_id = p_conv_data->com_context_id; + + if (pinfo->link_dir == P2P_DIR_UL) { + fpi->is_uplink = TRUE; + } else { + fpi->is_uplink = FALSE; + } + + is_control_frame = tvb_get_guint8(tvb, offset) & 0x01; + + switch (fpi->channel) { + case CHANNEL_HSDSCH: /* HS-DSCH - High Speed Downlink Shared Channel */ + fpi->hsdsch_entity = p_conv_data->hsdsch_entity; + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + fpi->hsdsch_macflowd_id = p_conv_data->hsdsch_macdflow_id; + macinf->content[0] = hsdsch_macdflow_id_mac_content_map[p_conv_data->hsdsch_macdflow_id]; /*MAC_CONTENT_PS_DTCH;*/ + macinf->lchid[0] = p_conv_data->hsdsch_macdflow_id; + /*macinf->content[0] = lchId_type_table[p_conv_data->edch_lchId[0]];*/ + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + + /*Figure out RLC_MODE based on MACd-flow-ID, basically MACd-flow-ID = 0 then it's SRB0 == UM else AM*/ + rlcinf->mode[0] = hsdsch_macdflow_id_rlc_map[p_conv_data->hsdsch_macdflow_id]; + + if (fpi->hsdsch_entity == hs /*&& !rlc_is_ciphered(pinfo)*/) { + for (i=0; ihrnti))) != NULL) { + j = 1 << i; + fpi->hsdhsch_macfdlow_is_mux[i] = j & *cur_val; + } else { + fpi->hsdhsch_macfdlow_is_mux[i] = FALSE; + } + + } + } + /* Make configurable ?(available in NBAP?) */ + /* urnti[MAX_RLC_CHANS] */ + /* + switch (p_conv_data->rlc_mode) { + case FP_RLC_TM: + rlcinf->mode[0] = RLC_TM; + break; + case FP_RLC_UM: + rlcinf->mode[0] = RLC_UM; + break; + case FP_RLC_AM: + rlcinf->mode[0] = RLC_AM; + break; + case FP_RLC_MODE_UNKNOWN: + default: + rlcinf->mode[0] = RLC_UNKNOWN_MODE; + break; + }*/ + /* rbid[MAX_RLC_CHANS] */ + /* For RLC re-assembly to work we urnti signaled from NBAP */ + rlcinf->urnti[0] = fpi->com_context_id; + rlcinf->li_size[0] = RLC_LI_7BITS; + rlcinf->ciphered[0] = FALSE; + rlcinf->deciphered[0] = FALSE; + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + + + return fpi; + + case CHANNEL_EDCH: + /*Most configuration is now done in the actual dissecting function*/ + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + fpi->no_ddi_entries = p_conv_data->no_ddi_entries; + for (i=0; ino_ddi_entries; i++) { + fpi->edch_ddi[i] = p_conv_data->edch_ddi[i]; /*Set the DDI value*/ + fpi->edch_macd_pdu_size[i] = p_conv_data->edch_macd_pdu_size[i]; /*Set the size*/ + fpi->edch_lchId[i] = p_conv_data->edch_lchId[i]; /*Set the channel id for this entry*/ + /*macinf->content[i] = lchId_type_table[p_conv_data->edch_lchId[i]]; */ /*Set the proper Content type for the mac layer.*/ + /* rlcinf->mode[i] = lchId_rlc_map[p_conv_data->edch_lchId[i]];*/ /* Set RLC mode by lchid to RLC_MODE map in nbap.h */ + + } + fpi->edch_type = p_conv_data->edch_type; + + /* macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + macinf->content[0] = MAC_CONTENT_PS_DTCH;*/ + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + + + /* For RLC re-assembly to work we need a urnti signaled from NBAP */ + rlcinf->urnti[0] = fpi->com_context_id; + /* rlcinf->mode[0] = RLC_AM;*/ + rlcinf->li_size[0] = RLC_LI_7BITS; + rlcinf->ciphered[0] = FALSE; + rlcinf->deciphered[0] = FALSE; + + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + + return fpi; + + case CHANNEL_PCH: + fpi->paging_indications = p_conv_data->paging_indications; + fpi->num_chans = p_conv_data->num_dch_in_flow; + /* Set offset to point to first TFI + */ + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + /* Set offset to TFI */ + offset = 3; + break; + case CHANNEL_DCH: + fpi->num_chans = p_conv_data->num_dch_in_flow; + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + offset = 2; /*To correctly read the tfi*/ + fakes = 5; /* Reset fake counter. */ + for (chan=0; chan < fpi->num_chans; chan++) { /*Iterate over the what channels*/ + /*Iterate over the transport blocks*/ + /*tfi = tvb_get_guint8(tvb, offset);*/ + /*TFI is 5 bits according to 3GPP TS 25.321, paragraph 6.2.4.4*/ + tfi = tvb_get_bits8(tvb, 3+offset*8, 5); + + /*Figure out the number of tbs and size*/ + num_tbs = (fpi->is_uplink) ? p_conv_data->fp_dch_channel_info[chan].ul_chan_num_tbs[tfi] : p_conv_data->fp_dch_channel_info[chan].dl_chan_num_tbs[tfi]; + tb_size= (fpi->is_uplink) ? p_conv_data->fp_dch_channel_info[i].ul_chan_tf_size[tfi] : p_conv_data->fp_dch_channel_info[i].dl_chan_tf_size[tfi]; + + /*TODO: This stuff has to be reworked!*/ + /*Generates a fake logical channel id for non multiplexed channel*/ + if ( p_conv_data->dchs_in_flow_list[chan] != 31 && (p_conv_data->dchs_in_flow_list[chan] == 24 && + tb_size != 340) ) { + fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]); + } + tb_bit_off = (2+p_conv_data->num_dch_in_flow)*8; /*Point to the C/T of first TB*/ + /*Set configuration for individual blocks*/ + for (j=0; j < num_tbs && j+chan < MAX_MAC_FRAMES; j++) { + /*Set transport channel id (useful for debugging)*/ + macinf->trchid[j+chan] = p_conv_data->dchs_in_flow_list[chan]; + + /*Transport Channel m31 and 24 might be multiplexed!*/ + if ( p_conv_data->dchs_in_flow_list[chan] == 31 || p_conv_data->dchs_in_flow_list[chan] == 24) { + + /****** MUST FIGURE OUT IF THIS IS REALLY MULTIPLEXED OR NOT*******/ + /*If Trchid == 31 and only on TB, we have no multiplexing*/ + if (0/*p_conv_data->dchs_in_flow_list[chan] == 31 && num_tbs == 1*/) { + macinf->ctmux[j+chan] = FALSE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + + macinf->lchid[j+chan] = 1; + + macinf->content[j+chan] = lchId_type_table[1]; /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ + rlcinf->mode[j+chan] = lchId_rlc_map[1]; /*Based RLC mode on logical channel id*/ + + } + /*Indicate we don't have multiplexing.*/ + else if (p_conv_data->dchs_in_flow_list[chan] == 24 && tb_size != 340) { + macinf->ctmux[j+chan] = FALSE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + + /*g_warning(""settin this for %d"", pinfo->num);*/ + macinf->lchid[j+chan] = fake_lchid; + macinf->fake_chid[j+chan] = TRUE; + macinf->content[j+chan] = MAC_CONTENT_PS_DTCH; /*lchId_type_table[fake_lchid];*/ /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ + rlcinf->mode[j+chan] = RLC_AM;/*lchId_rlc_map[fake_lchid];*/ /*Based RLC mode on logical channel id*/ + } + /*We have multiplexing*/ + else { + macinf->ctmux[j+chan] = TRUE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + + /* Peek at C/T, different RLC params for different logical channels */ + /*C/T is 4 bits according to 3GPP TS 25.321, paragraph 9.2.1, from MAC header (not FP)*/ + c_t = tvb_get_bits8(tvb, tb_bit_off/*(2+p_conv_data->num_dch_in_flow)*8*/, 4); /* c_t = tvb_get_guint8(tvb, offset);*/ + macinf->lchid[j+chan] = c_t+1; + + macinf->content[j+chan] = lchId_type_table[c_t+1]; /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ + rlcinf->mode[j+chan] = lchId_rlc_map[c_t+1]; /*Based RLC mode on logical channel id*/ + } + } else { + fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]); + macinf->ctmux[j+chan] = FALSE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + /*macinf->content[j+chan] = MAC_CONTENT_CS_DTCH;*/ + macinf->content[j+chan] = lchId_type_table[fake_lchid]; + + + rlcinf->mode[j+chan] = lchId_rlc_map[fake_lchid]; + + /*Generate virtual logical channel id*/ + /************************/ + /*TODO: Once proper lchid is always set, this has to be removed*/ + macinf->fake_chid[j+chan] = TRUE; + macinf->lchid[j+chan] = fake_lchid; /*make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]);*/ + /************************/ + } + + /*** Set rlc info ***/ + rlcinf->urnti[j+chan] = p_conv_data->com_context_id; + rlcinf->li_size[j+chan] = RLC_LI_7BITS; +#if 0 + /*If this entry exists, SECRUITY_MODE is completed (signled by RRC)*/ + if ( rrc_ciph_inf && g_tree_lookup(rrc_ciph_inf, GINT_TO_POINTER((gint)p_conv_data->com_context_id)) != NULL ) { + rlcinf->ciphered[j+chan] = TRUE; + } else { + rlcinf->ciphered[j+chan] = FALSE; + } +#endif + rlcinf->ciphered[j+chan] = FALSE; + rlcinf->deciphered[j+chan] = FALSE; + rlcinf->rbid[j+chan] = macinf->lchid[j+chan]; + + + /*Step over this TB and it's C/T flag.*/ + tb_bit_off += tb_size+4; + } + + offset++; + } + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + /* Set offset to point to first TFI + * the Number of TFI's = number of DCH's in the flow + */ + offset = 2; + break; + case CHANNEL_FACH_FDD: + fpi->num_chans = p_conv_data->num_dch_in_flow; + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + /* Set offset to point to first TFI + * the Number of TFI's = number of DCH's in the flow + */ + offset = 2; + /* Set MAC data */ + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + macinf->ctmux[0] = 1; + macinf->content[0] = MAC_CONTENT_DCCH; + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + /* Set RLC data */ + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + /* Make configurable ?(avaliable in NBAP?) */ + /* For RLC re-assembly to work we need to fake urnti */ + rlcinf->urnti[0] = fpi->channel; + rlcinf->mode[0] = RLC_AM; + /* rbid[MAX_RLC_CHANS] */ + rlcinf->li_size[0] = RLC_LI_7BITS; + rlcinf->ciphered[0] = FALSE; + rlcinf->deciphered[0] = FALSE; + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + break; + + case CHANNEL_RACH_FDD: + fpi->num_chans = p_conv_data->num_dch_in_flow; + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + /* Set offset to point to first TFI + * the Number of TFI's = number of DCH's in the flow + */ + offset = 2; + /* set MAC data */ + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + for ( chan = 0; chan < fpi->num_chans; chan++ ) { + macinf->ctmux[chan] = 1; + macinf->content[chan] = MAC_CONTENT_DCCH; + rlcinf->urnti[chan] = fpi->com_context_id; /*Note that MAC probably will change this*/ + } + + + + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + break; + case CHANNEL_HSDSCH_COMMON: + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + break; + default: + expert_add_info(pinfo, NULL, &ei_fp_transport_channel_type_unknown); + return NULL; + } + + /* Peek at the packet as the per packet info seems not to take the tfi into account */ + for (i=0; inum_chans; i++) { + tfi = tvb_get_guint8(tvb, offset); + + /*TFI is 5 bits according to 3GPP TS 25.321, paragraph 6.2.4.4*/ + /*tfi = tvb_get_bits8(tvb, offset*8, 5);*/ + if (pinfo->link_dir == P2P_DIR_UL) { + fpi->chan_tf_size[i] = p_conv_data->fp_dch_channel_info[i].ul_chan_tf_size[tfi]; + fpi->chan_num_tbs[i] = p_conv_data->fp_dch_channel_info[i].ul_chan_num_tbs[tfi]; + } else { + fpi->chan_tf_size[i] = p_conv_data->fp_dch_channel_info[i].dl_chan_tf_size[tfi]; + fpi->chan_num_tbs[i] = p_conv_data->fp_dch_channel_info[i].dl_chan_num_tbs[tfi]; + } + offset++; + } + + + return fpi; +} +",1,"fp_set_per_packet_inf_from_conv(umts_fp_conversation_info_t *p_conv_data, + tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree _U_) +{ + fp_info *fpi; + guint8 tfi, c_t; + int offset = 0, i=0, j=0, num_tbs, chan, tb_size, tb_bit_off; + gboolean is_control_frame; + umts_mac_info *macinf; + rlc_info *rlcinf; + guint8 fake_lchid=0; + gint *cur_val=NULL; + + fpi = wmem_new0(wmem_file_scope(), fp_info); + p_add_proto_data(wmem_file_scope(), pinfo, proto_fp, 0, fpi); + + fpi->iface_type = p_conv_data->iface_type; + fpi->division = p_conv_data->division; + fpi->release = 7; /* Set values greater then the checks performed */ + fpi->release_year = 2006; + fpi->release_month = 12; + fpi->channel = p_conv_data->channel; + fpi->dch_crc_present = p_conv_data->dch_crc_present; + /*fpi->paging_indications;*/ + fpi->link_type = FP_Link_Ethernet; + +#if 0 + /*Only do this the first run, signals that we need to reset the RLC fragtable*/ + if (!pinfo->fd->flags.visited && p_conv_data->reset_frag ) { + fpi->reset_frag = p_conv_data->reset_frag; + p_conv_data->reset_frag = FALSE; + } +#endif + /* remember 'lower' UDP layer port information so we can later + * differentiate 'lower' UDP layer from 'user data' UDP layer */ + fpi->srcport = pinfo->srcport; + fpi->destport = pinfo->destport; + + fpi->com_context_id = p_conv_data->com_context_id; + + if (pinfo->link_dir == P2P_DIR_UL) { + fpi->is_uplink = TRUE; + } else { + fpi->is_uplink = FALSE; + } + + is_control_frame = tvb_get_guint8(tvb, offset) & 0x01; + + switch (fpi->channel) { + case CHANNEL_HSDSCH: /* HS-DSCH - High Speed Downlink Shared Channel */ + fpi->hsdsch_entity = p_conv_data->hsdsch_entity; + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + fpi->hsdsch_macflowd_id = p_conv_data->hsdsch_macdflow_id; + macinf->content[0] = hsdsch_macdflow_id_mac_content_map[p_conv_data->hsdsch_macdflow_id]; /*MAC_CONTENT_PS_DTCH;*/ + macinf->lchid[0] = p_conv_data->hsdsch_macdflow_id; + /*macinf->content[0] = lchId_type_table[p_conv_data->edch_lchId[0]];*/ + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + + /*Figure out RLC_MODE based on MACd-flow-ID, basically MACd-flow-ID = 0 then it's SRB0 == UM else AM*/ + rlcinf->mode[0] = hsdsch_macdflow_id_rlc_map[p_conv_data->hsdsch_macdflow_id]; + + if (fpi->hsdsch_entity == hs /*&& !rlc_is_ciphered(pinfo)*/) { + for (i=0; ihrnti))) != NULL) { + j = 1 << i; + fpi->hsdhsch_macfdlow_is_mux[i] = j & *cur_val; + } else { + fpi->hsdhsch_macfdlow_is_mux[i] = FALSE; + } + + } + } + /* Make configurable ?(available in NBAP?) */ + /* urnti[MAX_RLC_CHANS] */ + /* + switch (p_conv_data->rlc_mode) { + case FP_RLC_TM: + rlcinf->mode[0] = RLC_TM; + break; + case FP_RLC_UM: + rlcinf->mode[0] = RLC_UM; + break; + case FP_RLC_AM: + rlcinf->mode[0] = RLC_AM; + break; + case FP_RLC_MODE_UNKNOWN: + default: + rlcinf->mode[0] = RLC_UNKNOWN_MODE; + break; + }*/ + /* rbid[MAX_RLC_CHANS] */ + /* For RLC re-assembly to work we urnti signaled from NBAP */ + rlcinf->urnti[0] = fpi->com_context_id; + rlcinf->li_size[0] = RLC_LI_7BITS; + rlcinf->ciphered[0] = FALSE; + rlcinf->deciphered[0] = FALSE; + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + + + return fpi; + + case CHANNEL_EDCH: + /*Most configuration is now done in the actual dissecting function*/ + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + fpi->no_ddi_entries = p_conv_data->no_ddi_entries; + for (i=0; ino_ddi_entries; i++) { + fpi->edch_ddi[i] = p_conv_data->edch_ddi[i]; /*Set the DDI value*/ + fpi->edch_macd_pdu_size[i] = p_conv_data->edch_macd_pdu_size[i]; /*Set the size*/ + fpi->edch_lchId[i] = p_conv_data->edch_lchId[i]; /*Set the channel id for this entry*/ + /*macinf->content[i] = lchId_type_table[p_conv_data->edch_lchId[i]]; */ /*Set the proper Content type for the mac layer.*/ + /* rlcinf->mode[i] = lchId_rlc_map[p_conv_data->edch_lchId[i]];*/ /* Set RLC mode by lchid to RLC_MODE map in nbap.h */ + + } + fpi->edch_type = p_conv_data->edch_type; + + /* macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + macinf->content[0] = MAC_CONTENT_PS_DTCH;*/ + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + + + /* For RLC re-assembly to work we need a urnti signaled from NBAP */ + rlcinf->urnti[0] = fpi->com_context_id; + /* rlcinf->mode[0] = RLC_AM;*/ + rlcinf->li_size[0] = RLC_LI_7BITS; + rlcinf->ciphered[0] = FALSE; + rlcinf->deciphered[0] = FALSE; + + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + + return fpi; + + case CHANNEL_PCH: + fpi->paging_indications = p_conv_data->paging_indications; + fpi->num_chans = p_conv_data->num_dch_in_flow; + /* Set offset to point to first TFI + */ + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + /* Set offset to TFI */ + offset = 3; + break; + case CHANNEL_DCH: + fpi->num_chans = p_conv_data->num_dch_in_flow; + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + offset = 2; /*To correctly read the tfi*/ + fakes = 5; /* Reset fake counter. */ + for (chan=0; chan < fpi->num_chans; chan++) { /*Iterate over the what channels*/ + /*Iterate over the transport blocks*/ + /*tfi = tvb_get_guint8(tvb, offset);*/ + /*TFI is 5 bits according to 3GPP TS 25.321, paragraph 6.2.4.4*/ + tfi = tvb_get_bits8(tvb, 3+offset*8, 5); + + /*Figure out the number of tbs and size*/ + num_tbs = (fpi->is_uplink) ? p_conv_data->fp_dch_channel_info[chan].ul_chan_num_tbs[tfi] : p_conv_data->fp_dch_channel_info[chan].dl_chan_num_tbs[tfi]; + tb_size= (fpi->is_uplink) ? p_conv_data->fp_dch_channel_info[i].ul_chan_tf_size[tfi] : p_conv_data->fp_dch_channel_info[i].dl_chan_tf_size[tfi]; + + /*TODO: This stuff has to be reworked!*/ + /*Generates a fake logical channel id for non multiplexed channel*/ + if ( p_conv_data->dchs_in_flow_list[chan] != 31 && (p_conv_data->dchs_in_flow_list[chan] == 24 && + tb_size != 340) ) { + fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]); + } + tb_bit_off = (2+p_conv_data->num_dch_in_flow)*8; /*Point to the C/T of first TB*/ + /*Set configuration for individual blocks*/ + for (j=0; j < num_tbs && j+chan < MAX_MAC_FRAMES; j++) { + /*Set transport channel id (useful for debugging)*/ + macinf->trchid[j+chan] = p_conv_data->dchs_in_flow_list[chan]; + + /*Transport Channel m31 and 24 might be multiplexed!*/ + if ( p_conv_data->dchs_in_flow_list[chan] == 31 || p_conv_data->dchs_in_flow_list[chan] == 24) { + + /****** MUST FIGURE OUT IF THIS IS REALLY MULTIPLEXED OR NOT*******/ + /*If Trchid == 31 and only on TB, we have no multiplexing*/ + if (0/*p_conv_data->dchs_in_flow_list[chan] == 31 && num_tbs == 1*/) { + macinf->ctmux[j+chan] = FALSE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + + macinf->lchid[j+chan] = 1; + + macinf->content[j+chan] = lchId_type_table[1]; /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ + rlcinf->mode[j+chan] = lchId_rlc_map[1]; /*Based RLC mode on logical channel id*/ + + } + /*Indicate we don't have multiplexing.*/ + else if (p_conv_data->dchs_in_flow_list[chan] == 24 && tb_size != 340) { + macinf->ctmux[j+chan] = FALSE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + + /*g_warning(""settin this for %d"", pinfo->num);*/ + macinf->lchid[j+chan] = fake_lchid; + macinf->fake_chid[j+chan] = TRUE; + macinf->content[j+chan] = MAC_CONTENT_PS_DTCH; /*lchId_type_table[fake_lchid];*/ /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ + rlcinf->mode[j+chan] = RLC_AM;/*lchId_rlc_map[fake_lchid];*/ /*Based RLC mode on logical channel id*/ + } + /*We have multiplexing*/ + else { + macinf->ctmux[j+chan] = TRUE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + + /* Peek at C/T, different RLC params for different logical channels */ + /*C/T is 4 bits according to 3GPP TS 25.321, paragraph 9.2.1, from MAC header (not FP)*/ + c_t = (tvb_get_bits8(tvb, tb_bit_off/*(2+p_conv_data->num_dch_in_flow)*8*/, 4) + 1) % 0xf; /* c_t = tvb_get_guint8(tvb, offset);*/ + macinf->lchid[j+chan] = c_t; + + macinf->content[j+chan] = lchId_type_table[c_t]; /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ + rlcinf->mode[j+chan] = lchId_rlc_map[c_t]; /*Based RLC mode on logical channel id*/ + } + } else { + fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]); + macinf->ctmux[j+chan] = FALSE;/*Set TRUE if this channel is multiplexed (ie. C/T flag exists)*/ + /*macinf->content[j+chan] = MAC_CONTENT_CS_DTCH;*/ + macinf->content[j+chan] = lchId_type_table[fake_lchid]; + + + rlcinf->mode[j+chan] = lchId_rlc_map[fake_lchid]; + + /*Generate virtual logical channel id*/ + /************************/ + /*TODO: Once proper lchid is always set, this has to be removed*/ + macinf->fake_chid[j+chan] = TRUE; + macinf->lchid[j+chan] = fake_lchid; /*make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]);*/ + /************************/ + } + + /*** Set rlc info ***/ + rlcinf->urnti[j+chan] = p_conv_data->com_context_id; + rlcinf->li_size[j+chan] = RLC_LI_7BITS; +#if 0 + /*If this entry exists, SECRUITY_MODE is completed (signled by RRC)*/ + if ( rrc_ciph_inf && g_tree_lookup(rrc_ciph_inf, GINT_TO_POINTER((gint)p_conv_data->com_context_id)) != NULL ) { + rlcinf->ciphered[j+chan] = TRUE; + } else { + rlcinf->ciphered[j+chan] = FALSE; + } +#endif + rlcinf->ciphered[j+chan] = FALSE; + rlcinf->deciphered[j+chan] = FALSE; + rlcinf->rbid[j+chan] = macinf->lchid[j+chan]; + + + /*Step over this TB and it's C/T flag.*/ + tb_bit_off += tb_size+4; + } + + offset++; + } + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + /* Set offset to point to first TFI + * the Number of TFI's = number of DCH's in the flow + */ + offset = 2; + break; + case CHANNEL_FACH_FDD: + fpi->num_chans = p_conv_data->num_dch_in_flow; + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + /* Set offset to point to first TFI + * the Number of TFI's = number of DCH's in the flow + */ + offset = 2; + /* Set MAC data */ + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + macinf->ctmux[0] = 1; + macinf->content[0] = MAC_CONTENT_DCCH; + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + /* Set RLC data */ + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + /* Make configurable ?(avaliable in NBAP?) */ + /* For RLC re-assembly to work we need to fake urnti */ + rlcinf->urnti[0] = fpi->channel; + rlcinf->mode[0] = RLC_AM; + /* rbid[MAX_RLC_CHANS] */ + rlcinf->li_size[0] = RLC_LI_7BITS; + rlcinf->ciphered[0] = FALSE; + rlcinf->deciphered[0] = FALSE; + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + break; + + case CHANNEL_RACH_FDD: + fpi->num_chans = p_conv_data->num_dch_in_flow; + if (is_control_frame) { + /* control frame, we're done */ + return fpi; + } + /* Set offset to point to first TFI + * the Number of TFI's = number of DCH's in the flow + */ + offset = 2; + /* set MAC data */ + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + for ( chan = 0; chan < fpi->num_chans; chan++ ) { + macinf->ctmux[chan] = 1; + macinf->content[chan] = MAC_CONTENT_DCCH; + rlcinf->urnti[chan] = fpi->com_context_id; /*Note that MAC probably will change this*/ + } + + + + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + break; + case CHANNEL_HSDSCH_COMMON: + rlcinf = wmem_new0(wmem_file_scope(), rlc_info); + macinf = wmem_new0(wmem_file_scope(), umts_mac_info); + p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf); + p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf); + break; + default: + expert_add_info(pinfo, NULL, &ei_fp_transport_channel_type_unknown); + return NULL; + } + + /* Peek at the packet as the per packet info seems not to take the tfi into account */ + for (i=0; inum_chans; i++) { + tfi = tvb_get_guint8(tvb, offset); + + /*TFI is 5 bits according to 3GPP TS 25.321, paragraph 6.2.4.4*/ + /*tfi = tvb_get_bits8(tvb, offset*8, 5);*/ + if (pinfo->link_dir == P2P_DIR_UL) { + fpi->chan_tf_size[i] = p_conv_data->fp_dch_channel_info[i].ul_chan_tf_size[tfi]; + fpi->chan_num_tbs[i] = p_conv_data->fp_dch_channel_info[i].ul_chan_num_tbs[tfi]; + } else { + fpi->chan_tf_size[i] = p_conv_data->fp_dch_channel_info[i].dl_chan_tf_size[tfi]; + fpi->chan_num_tbs[i] = p_conv_data->fp_dch_channel_info[i].dl_chan_num_tbs[tfi]; + } + offset++; + } + + + return fpi; +} +","@@ -4098,11 +4098,11 @@ fp_set_per_packet_inf_from_conv(umts_fp_conversation_info_t *p_conv_data, + + /* Peek at C/T, different RLC params for different logical channels */ + /*C/T is 4 bits according to 3GPP TS 25.321, paragraph 9.2.1, from MAC header (not FP)*/ +- c_t = tvb_get_bits8(tvb, tb_bit_off/*(2+p_conv_data->num_dch_in_flow)*8*/, 4); /* c_t = tvb_get_guint8(tvb, offset);*/ +- macinf->lchid[j+chan] = c_t+1; ++ c_t = (tvb_get_bits8(tvb, tb_bit_off/*(2+p_conv_data->num_dch_in_flow)*8*/, 4) + 1) % 0xf; /* c_t = tvb_get_guint8(tvb, offset);*/ ++ macinf->lchid[j+chan] = c_t; + +- macinf->content[j+chan] = lchId_type_table[c_t+1]; /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ +- rlcinf->mode[j+chan] = lchId_rlc_map[c_t+1]; /*Based RLC mode on logical channel id*/ ++ macinf->content[j+chan] = lchId_type_table[c_t]; /*Base MAC content on logical channel id (Table is in packet-nbap.h)*/ ++ rlcinf->mode[j+chan] = lchId_rlc_map[c_t]; /*Based RLC mode on logical channel id*/ + } + } else { + fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]);",4519,4755,6144 +18091,"static Image *ReadWPGImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + typedef struct + { + size_t FileId; + MagickOffsetType DataOffset; + unsigned int ProductType; + unsigned int FileType; + unsigned char MajorVersion; + unsigned char MinorVersion; + unsigned int EncryptKey; + unsigned int Reserved; + } WPGHeader; + + typedef struct + { + unsigned char RecType; + size_t RecordLength; + } WPGRecord; + + typedef struct + { + unsigned char Class; + unsigned char RecType; + size_t Extension; + size_t RecordLength; + } WPG2Record; + + typedef struct + { + unsigned HorizontalUnits; + unsigned VerticalUnits; + unsigned char PosSizePrecision; + } WPG2Start; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType1; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned char Depth; + unsigned char Compression; + } WPG2BitmapType1; + + typedef struct + { + unsigned int RotAngle; + unsigned int LowLeftX; + unsigned int LowLeftY; + unsigned int UpRightX; + unsigned int UpRightY; + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType2; + + typedef struct + { + unsigned int StartIndex; + unsigned int NumOfEntries; + } WPGColorMapRec; + + /* + typedef struct { + size_t PS_unknown1; + unsigned int PS_unknown2; + unsigned int PS_unknown3; + } WPGPSl1Record; + */ + + Image + *image; + + unsigned int + status; + + WPGHeader + Header; + + WPGRecord + Rec; + + WPG2Record + Rec2; + + WPG2Start StartWPG; + + WPGBitmapType1 + BitmapHeader1; + + WPG2BitmapType1 + Bitmap2Header1; + + WPGBitmapType2 + BitmapHeader2; + + WPGColorMapRec + WPG_Palette; + + int + i, + bpp, + WPG2Flags; + + ssize_t + ldblk; + + size_t + one; + + unsigned char + *BImgBuff; + + tCTM CTM; /*current transform matrix*/ + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + one=1; + image=AcquireImage(image_info); + image->depth=8; + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read WPG image. + */ + Header.FileId=ReadBlobLSBLong(image); + Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image); + Header.ProductType=ReadBlobLSBShort(image); + Header.FileType=ReadBlobLSBShort(image); + Header.MajorVersion=ReadBlobByte(image); + Header.MinorVersion=ReadBlobByte(image); + Header.EncryptKey=ReadBlobLSBShort(image); + Header.Reserved=ReadBlobLSBShort(image); + + if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (Header.EncryptKey!=0) + ThrowReaderException(CoderError,""EncryptedWPGImageFileNotSupported""); + + image->columns = 1; + image->rows = 1; + image->colors = 0; + bpp=0; + BitmapHeader2.RotAngle=0; + Rec2.RecordLength = 0; + + switch(Header.FileType) + { + case 1: /* WPG level 1 */ + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec.RecordLength; + + switch(Rec.RecType) + { + case 0x0B: /* bitmap type 1 */ + BitmapHeader1.Width=ReadBlobLSBShort(image); + BitmapHeader1.Height=ReadBlobLSBShort(image); + if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader1.Depth=ReadBlobLSBShort(image); + BitmapHeader1.HorzRes=ReadBlobLSBShort(image); + BitmapHeader1.VertRes=ReadBlobLSBShort(image); + + if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes) + { + image->units=PixelsPerCentimeterResolution; + image->x_resolution=BitmapHeader1.HorzRes/470.0; + image->y_resolution=BitmapHeader1.VertRes/470.0; + } + image->columns=BitmapHeader1.Width; + image->rows=BitmapHeader1.Height; + bpp=BitmapHeader1.Depth; + + goto UnpackRaster; + + case 0x0E: /*Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + if ((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) > + (Rec2.RecordLength-2-2) / 3) + ThrowReaderException(CorruptImageError,""InvalidColormapIndex""); + image->colors=WPG_Palette.NumOfEntries; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + } + break; + + case 0x11: /* Start PS l1 */ + if(Rec.RecordLength > 8) + image=ExtractPostscript(image,image_info, + TellBlob(image)+8, /* skip PS header in the wpg */ + (ssize_t) Rec.RecordLength-8,exception); + break; + + case 0x14: /* bitmap type 2 */ + BitmapHeader2.RotAngle=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftX=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftY=ReadBlobLSBShort(image); + BitmapHeader2.UpRightX=ReadBlobLSBShort(image); + BitmapHeader2.UpRightY=ReadBlobLSBShort(image); + BitmapHeader2.Width=ReadBlobLSBShort(image); + BitmapHeader2.Height=ReadBlobLSBShort(image); + if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader2.Depth=ReadBlobLSBShort(image); + BitmapHeader2.HorzRes=ReadBlobLSBShort(image); + BitmapHeader2.VertRes=ReadBlobLSBShort(image); + + image->units=PixelsPerCentimeterResolution; + image->page.width=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)/470.0); + image->page.height=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)/470.0); + image->page.x=(int) (BitmapHeader2.LowLeftX/470.0); + image->page.y=(int) (BitmapHeader2.LowLeftX/470.0); + if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes) + { + image->x_resolution=BitmapHeader2.HorzRes/470.0; + image->y_resolution=BitmapHeader2.VertRes/470.0; + } + image->columns=BitmapHeader2.Width; + image->rows=BitmapHeader2.Height; + bpp=BitmapHeader2.Depth; + + UnpackRaster: + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + break; + if ((image->colors == 0) && (bpp != 24)) + { + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + { + NoMemory: + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + /* printf(""Load default colormap \n""); */ + for (i=0; (i < (int) image->colors) && (i < 256); i++) + { + image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red); + image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green); + image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue); + } + } + else + { + if (bpp < 24) + if ( (image->colors < (one << bpp)) && (bpp != 24) ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + if (bpp == 1) + { + if(image->colormap[0].red==0 && + image->colormap[0].green==0 && + image->colormap[0].blue==0 && + image->colormap[1].red==0 && + image->colormap[1].green==0 && + image->colormap[1].blue==0) + { /* fix crippled monochrome palette */ + image->colormap[1].red = + image->colormap[1].green = + image->colormap[1].blue = QuantumRange; + } + } + + if(UnpackWPGRaster(image,bpp) < 0) + /* The raster cannot be unpacked */ + { + DecompressionFailed: + ThrowReaderException(CoderError,""UnableToDecompressImage""); + } + + if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping) + { + /* flop command */ + if(BitmapHeader2.RotAngle & 0x8000) + { + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + ReplaceImageInList(&image,flop_image); + } + } + /* flip command */ + if(BitmapHeader2.RotAngle & 0x2000) + { + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + ReplaceImageInList(&image,flip_image); + } + } + /* rotate command */ + if(BitmapHeader2.RotAngle & 0x0FFF) + { + Image + *rotate_image; + + rotate_image=RotateImage(image,(BitmapHeader2.RotAngle & + 0x0FFF), exception); + if (rotate_image != (Image *) NULL) { + DuplicateBlob(rotate_image,image); + ReplaceImageInList(&image,rotate_image); + } + } + } + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=1; + image->colors=0; + break; + + case 0x1B: /* Postscript l2 */ + if(Rec.RecordLength>0x3C) + image=ExtractPostscript(image,image_info, + TellBlob(image)+0x3C, /* skip PS l2 header in the wpg */ + (ssize_t) Rec.RecordLength-0x3C,exception); + break; + } + } + break; + + case 2: /* WPG level 2 */ + (void) memset(CTM,0,sizeof(CTM)); + StartWPG.PosSizePrecision = 0; + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec2.Class=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rec2.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec2.Extension); + Rd_WP_DWORD(image,&Rec2.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec2.RecordLength; + + switch(Rec2.RecType) + { + case 1: + StartWPG.HorizontalUnits=ReadBlobLSBShort(image); + StartWPG.VerticalUnits=ReadBlobLSBShort(image); + StartWPG.PosSizePrecision=ReadBlobByte(image); + break; + case 0x0C: /* Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + if ((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) > + (Rec2.RecordLength-2-2) / 3) + ThrowReaderException(CorruptImageError,""InvalidColormapIndex""); + image->colors=WPG_Palette.NumOfEntries; + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((char) + ReadBlobByte(image)); + (void) ReadBlobByte(image); /*Opacity??*/ + } + break; + case 0x0E: + Bitmap2Header1.Width=ReadBlobLSBShort(image); + Bitmap2Header1.Height=ReadBlobLSBShort(image); + if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + Bitmap2Header1.Depth=ReadBlobByte(image); + Bitmap2Header1.Compression=ReadBlobByte(image); + + if(Bitmap2Header1.Compression > 1) + continue; /*Unknown compression method */ + switch(Bitmap2Header1.Depth) + { + case 1: + bpp=1; + break; + case 2: + bpp=2; + break; + case 3: + bpp=4; + break; + case 4: + bpp=8; + break; + case 8: + bpp=24; + break; + default: + continue; /*Ignore raster with unknown depth*/ + } + image->columns=Bitmap2Header1.Width; + image->rows=Bitmap2Header1.Height; + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + break; + if ((image->colors == 0) && (bpp != 24)) + { + size_t + one; + + one=1; + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + } + else + { + if(bpp < 24) + if( image->colors<(one << bpp) && bpp!=24 ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + + switch(Bitmap2Header1.Compression) + { + case 0: /*Uncompressed raster*/ + { + ldblk=(ssize_t) ((bpp*image->columns+7)/8); + BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) + ldblk+1,sizeof(*BImgBuff)); + if (BImgBuff == (unsigned char *) NULL) + goto NoMemory; + + for(i=0; i< (ssize_t) image->rows; i++) + { + (void) ReadBlob(image,ldblk,BImgBuff); + InsertRow(BImgBuff,i,image,bpp); + } + + if(BImgBuff) + BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); + break; + } + case 1: /*RLE for WPG2 */ + { + if( UnpackWPG2Raster(image,bpp) < 0) + goto DecompressionFailed; + break; + } + } + + if(CTM[0][0]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + ReplaceImageInList(&image,flop_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0; + Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll); + Tx(1,2)=0; Tx(2,2)=1; */ + } + if(CTM[1][1]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + ReplaceImageInList(&image,flip_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + float_matrix Tx(3,3); + Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0; + Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll); + Tx(2,2)=1; */ + } + + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=1; + image->colors=0; + break; + + case 0x12: /* Postscript WPG2*/ + i=ReadBlobLSBShort(image); + if(Rec2.RecordLength > (unsigned int) i) + image=ExtractPostscript(image,image_info, + TellBlob(image)+i, /*skip PS header in the wpg2*/ + (ssize_t) (Rec2.RecordLength-i-2),exception); + break; + + case 0x1B: /*bitmap rectangle*/ + WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); + (void) WPG2Flags; + break; + } + } + + break; + + default: + { + ThrowReaderException(CoderError,""DataEncodingSchemeIsNotSupported""); + } + } + + Finish: + (void) CloseBlob(image); + + { + Image + *p; + + ssize_t + scene=0; + + /* + Rewind list, removing any empty images while rewinding. + */ + p=image; + image=NULL; + while (p != (Image *) NULL) + { + Image *tmp=p; + if ((p->rows == 0) || (p->columns == 0)) { + p=p->previous; + DeleteImageFromList(&tmp); + } else { + image=p; + p=p->previous; + } + } + /* + Fix scene numbers. + */ + for (p=image; p != (Image *) NULL; p=p->next) + p->scene=(size_t) scene++; + } + if (image == (Image *) NULL) + ThrowReaderException(CorruptImageError, + ""ImageFileDoesNotContainAnyImageData""); + return(image); +} +",1,"static Image *ReadWPGImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + typedef struct + { + size_t FileId; + MagickOffsetType DataOffset; + unsigned int ProductType; + unsigned int FileType; + unsigned char MajorVersion; + unsigned char MinorVersion; + unsigned int EncryptKey; + unsigned int Reserved; + } WPGHeader; + + typedef struct + { + unsigned char RecType; + size_t RecordLength; + } WPGRecord; + + typedef struct + { + unsigned char Class; + unsigned char RecType; + size_t Extension; + size_t RecordLength; + } WPG2Record; + + typedef struct + { + unsigned HorizontalUnits; + unsigned VerticalUnits; + unsigned char PosSizePrecision; + } WPG2Start; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType1; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned char Depth; + unsigned char Compression; + } WPG2BitmapType1; + + typedef struct + { + unsigned int RotAngle; + unsigned int LowLeftX; + unsigned int LowLeftY; + unsigned int UpRightX; + unsigned int UpRightY; + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType2; + + typedef struct + { + unsigned int StartIndex; + unsigned int NumOfEntries; + } WPGColorMapRec; + + /* + typedef struct { + size_t PS_unknown1; + unsigned int PS_unknown2; + unsigned int PS_unknown3; + } WPGPSl1Record; + */ + + Image + *image; + + unsigned int + status; + + WPGHeader + Header; + + WPGRecord + Rec; + + WPG2Record + Rec2; + + WPG2Start StartWPG; + + WPGBitmapType1 + BitmapHeader1; + + WPG2BitmapType1 + Bitmap2Header1; + + WPGBitmapType2 + BitmapHeader2; + + WPGColorMapRec + WPG_Palette; + + int + i, + bpp, + WPG2Flags; + + ssize_t + ldblk; + + size_t + one; + + unsigned char + *BImgBuff; + + tCTM CTM; /*current transform matrix*/ + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + one=1; + image=AcquireImage(image_info); + image->depth=8; + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read WPG image. + */ + Header.FileId=ReadBlobLSBLong(image); + Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image); + Header.ProductType=ReadBlobLSBShort(image); + Header.FileType=ReadBlobLSBShort(image); + Header.MajorVersion=ReadBlobByte(image); + Header.MinorVersion=ReadBlobByte(image); + Header.EncryptKey=ReadBlobLSBShort(image); + Header.Reserved=ReadBlobLSBShort(image); + + if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (Header.EncryptKey!=0) + ThrowReaderException(CoderError,""EncryptedWPGImageFileNotSupported""); + + image->columns = 1; + image->rows = 1; + image->colors = 0; + bpp=0; + BitmapHeader2.RotAngle=0; + Rec2.RecordLength = 0; + + switch(Header.FileType) + { + case 1: /* WPG level 1 */ + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec.RecordLength); + if (Rec.RecordLength > GetBlobSize(image)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec.RecordLength; + + switch(Rec.RecType) + { + case 0x0B: /* bitmap type 1 */ + BitmapHeader1.Width=ReadBlobLSBShort(image); + BitmapHeader1.Height=ReadBlobLSBShort(image); + if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader1.Depth=ReadBlobLSBShort(image); + BitmapHeader1.HorzRes=ReadBlobLSBShort(image); + BitmapHeader1.VertRes=ReadBlobLSBShort(image); + + if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes) + { + image->units=PixelsPerCentimeterResolution; + image->x_resolution=BitmapHeader1.HorzRes/470.0; + image->y_resolution=BitmapHeader1.VertRes/470.0; + } + image->columns=BitmapHeader1.Width; + image->rows=BitmapHeader1.Height; + bpp=BitmapHeader1.Depth; + + goto UnpackRaster; + + case 0x0E: /*Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + if ((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) > + (Rec2.RecordLength-2-2) / 3) + ThrowReaderException(CorruptImageError,""InvalidColormapIndex""); + image->colors=WPG_Palette.NumOfEntries; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + } + break; + + case 0x11: /* Start PS l1 */ + if(Rec.RecordLength > 8) + image=ExtractPostscript(image,image_info, + TellBlob(image)+8, /* skip PS header in the wpg */ + (ssize_t) Rec.RecordLength-8,exception); + break; + + case 0x14: /* bitmap type 2 */ + BitmapHeader2.RotAngle=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftX=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftY=ReadBlobLSBShort(image); + BitmapHeader2.UpRightX=ReadBlobLSBShort(image); + BitmapHeader2.UpRightY=ReadBlobLSBShort(image); + BitmapHeader2.Width=ReadBlobLSBShort(image); + BitmapHeader2.Height=ReadBlobLSBShort(image); + if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader2.Depth=ReadBlobLSBShort(image); + BitmapHeader2.HorzRes=ReadBlobLSBShort(image); + BitmapHeader2.VertRes=ReadBlobLSBShort(image); + + image->units=PixelsPerCentimeterResolution; + image->page.width=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)/470.0); + image->page.height=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)/470.0); + image->page.x=(int) (BitmapHeader2.LowLeftX/470.0); + image->page.y=(int) (BitmapHeader2.LowLeftX/470.0); + if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes) + { + image->x_resolution=BitmapHeader2.HorzRes/470.0; + image->y_resolution=BitmapHeader2.VertRes/470.0; + } + image->columns=BitmapHeader2.Width; + image->rows=BitmapHeader2.Height; + bpp=BitmapHeader2.Depth; + + UnpackRaster: + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + break; + if ((image->colors == 0) && (bpp != 24)) + { + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + { + NoMemory: + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + /* printf(""Load default colormap \n""); */ + for (i=0; (i < (int) image->colors) && (i < 256); i++) + { + image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red); + image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green); + image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue); + } + } + else + { + if (bpp < 24) + if ( (image->colors < (one << bpp)) && (bpp != 24) ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + if (bpp == 1) + { + if(image->colormap[0].red==0 && + image->colormap[0].green==0 && + image->colormap[0].blue==0 && + image->colormap[1].red==0 && + image->colormap[1].green==0 && + image->colormap[1].blue==0) + { /* fix crippled monochrome palette */ + image->colormap[1].red = + image->colormap[1].green = + image->colormap[1].blue = QuantumRange; + } + } + + if(UnpackWPGRaster(image,bpp) < 0) + /* The raster cannot be unpacked */ + { + DecompressionFailed: + ThrowReaderException(CoderError,""UnableToDecompressImage""); + } + + if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping) + { + /* flop command */ + if(BitmapHeader2.RotAngle & 0x8000) + { + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + ReplaceImageInList(&image,flop_image); + } + } + /* flip command */ + if(BitmapHeader2.RotAngle & 0x2000) + { + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + ReplaceImageInList(&image,flip_image); + } + } + /* rotate command */ + if(BitmapHeader2.RotAngle & 0x0FFF) + { + Image + *rotate_image; + + rotate_image=RotateImage(image,(BitmapHeader2.RotAngle & + 0x0FFF), exception); + if (rotate_image != (Image *) NULL) { + DuplicateBlob(rotate_image,image); + ReplaceImageInList(&image,rotate_image); + } + } + } + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=1; + image->colors=0; + break; + + case 0x1B: /* Postscript l2 */ + if(Rec.RecordLength>0x3C) + image=ExtractPostscript(image,image_info, + TellBlob(image)+0x3C, /* skip PS l2 header in the wpg */ + (ssize_t) Rec.RecordLength-0x3C,exception); + break; + } + } + break; + + case 2: /* WPG level 2 */ + (void) memset(CTM,0,sizeof(CTM)); + StartWPG.PosSizePrecision = 0; + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec2.Class=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rec2.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec2.Extension); + Rd_WP_DWORD(image,&Rec2.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec2.RecordLength; + + switch(Rec2.RecType) + { + case 1: + StartWPG.HorizontalUnits=ReadBlobLSBShort(image); + StartWPG.VerticalUnits=ReadBlobLSBShort(image); + StartWPG.PosSizePrecision=ReadBlobByte(image); + break; + case 0x0C: /* Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + if ((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) > + (Rec2.RecordLength-2-2) / 3) + ThrowReaderException(CorruptImageError,""InvalidColormapIndex""); + image->colors=WPG_Palette.NumOfEntries; + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((char) + ReadBlobByte(image)); + (void) ReadBlobByte(image); /*Opacity??*/ + } + break; + case 0x0E: + Bitmap2Header1.Width=ReadBlobLSBShort(image); + Bitmap2Header1.Height=ReadBlobLSBShort(image); + if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + Bitmap2Header1.Depth=ReadBlobByte(image); + Bitmap2Header1.Compression=ReadBlobByte(image); + + if(Bitmap2Header1.Compression > 1) + continue; /*Unknown compression method */ + switch(Bitmap2Header1.Depth) + { + case 1: + bpp=1; + break; + case 2: + bpp=2; + break; + case 3: + bpp=4; + break; + case 4: + bpp=8; + break; + case 8: + bpp=24; + break; + default: + continue; /*Ignore raster with unknown depth*/ + } + image->columns=Bitmap2Header1.Width; + image->rows=Bitmap2Header1.Height; + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + break; + if ((image->colors == 0) && (bpp != 24)) + { + size_t + one; + + one=1; + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + } + else + { + if(bpp < 24) + if( image->colors<(one << bpp) && bpp!=24 ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + + switch(Bitmap2Header1.Compression) + { + case 0: /*Uncompressed raster*/ + { + ldblk=(ssize_t) ((bpp*image->columns+7)/8); + BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) + ldblk+1,sizeof(*BImgBuff)); + if (BImgBuff == (unsigned char *) NULL) + goto NoMemory; + + for(i=0; i< (ssize_t) image->rows; i++) + { + (void) ReadBlob(image,ldblk,BImgBuff); + InsertRow(BImgBuff,i,image,bpp); + } + + if(BImgBuff) + BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); + break; + } + case 1: /*RLE for WPG2 */ + { + if( UnpackWPG2Raster(image,bpp) < 0) + goto DecompressionFailed; + break; + } + } + + if(CTM[0][0]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + ReplaceImageInList(&image,flop_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0; + Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll); + Tx(1,2)=0; Tx(2,2)=1; */ + } + if(CTM[1][1]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + ReplaceImageInList(&image,flip_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + float_matrix Tx(3,3); + Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0; + Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll); + Tx(2,2)=1; */ + } + + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=1; + image->colors=0; + break; + + case 0x12: /* Postscript WPG2*/ + i=ReadBlobLSBShort(image); + if(Rec2.RecordLength > (unsigned int) i) + image=ExtractPostscript(image,image_info, + TellBlob(image)+i, /*skip PS header in the wpg2*/ + (ssize_t) (Rec2.RecordLength-i-2),exception); + break; + + case 0x1B: /*bitmap rectangle*/ + WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); + (void) WPG2Flags; + break; + } + } + + break; + + default: + { + ThrowReaderException(CoderError,""DataEncodingSchemeIsNotSupported""); + } + } + + Finish: + (void) CloseBlob(image); + + { + Image + *p; + + ssize_t + scene=0; + + /* + Rewind list, removing any empty images while rewinding. + */ + p=image; + image=NULL; + while (p != (Image *) NULL) + { + Image *tmp=p; + if ((p->rows == 0) || (p->columns == 0)) { + p=p->previous; + DeleteImageFromList(&tmp); + } else { + image=p; + p=p->previous; + } + } + /* + Fix scene numbers. + */ + for (p=image; p != (Image *) NULL; p=p->next) + p->scene=(size_t) scene++; + } + if (image == (Image *) NULL) + ThrowReaderException(CorruptImageError, + ""ImageFileDoesNotContainAnyImageData""); + return(image); +} +","@@ -1045,6 +1045,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info, + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec.RecordLength); ++ if (Rec.RecordLength > GetBlobSize(image)) ++ ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if(EOFBlob(image)) + break; + ",4753,4989,6144 +4866,"void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 *dirnum, + uint16 *defconfig, uint16 *deffillorder, uint32 *deftilewidth, + uint32 *deftilelength, uint32 *defrowsperstrip, + struct crop_mask *crop_data, struct pagedef *page, + struct dump_opts *dump, + unsigned int *imagelist, unsigned int *image_count ) + { + int c, good_args = 0; + char *opt_offset = NULL; /* Position in string of value sought */ + char *opt_ptr = NULL; /* Pointer to next token in option set */ + char *sep = NULL; /* Pointer to a token separator */ + unsigned int i, j, start, end; +#if !HAVE_DECL_OPTARG + extern int optind; + extern char* optarg; +#endif + + *mp++ = 'w'; + *mp = '\0'; + while ((c = getopt(argc, argv, + ""ac:d:e:f:hil:m:p:r:stvw:z:BCD:E:F:H:I:J:K:LMN:O:P:R:S:U:V:X:Y:Z:"")) != -1) + { + good_args++; + switch (c) { + case 'a': mode[0] = 'a'; /* append to output */ + break; + case 'c': if (!processCompressOptions(optarg)) /* compression scheme */ + { + TIFFError (""Unknown compression option"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'd': start = strtoul(optarg, NULL, 0); /* initial IFD offset */ + if (start == 0) + { + TIFFError ("""",""Directory offset must be greater than zero""); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + *dirnum = start - 1; + break; + case 'e': switch (tolower((int) optarg[0])) /* image export modes*/ + { + case 'c': crop_data->exp_mode = ONE_FILE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Composite */ + case 'd': crop_data->exp_mode = ONE_FILE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Divided */ + case 'i': crop_data->exp_mode = FILE_PER_IMAGE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Image */ + case 'm': crop_data->exp_mode = FILE_PER_IMAGE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Multiple */ + case 's': crop_data->exp_mode = FILE_PER_SELECTION; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Sections */ + default: TIFFError (""Unknown export mode"",""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'f': if (streq(optarg, ""lsb2msb"")) /* fill order */ + *deffillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, ""msb2lsb"")) + *deffillorder = FILLORDER_MSB2LSB; + else + { + TIFFError (""Unknown fill order"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'h': usage(); + break; + case 'i': ignore = TRUE; /* ignore errors */ + break; + case 'l': outtiled = TRUE; /* tile length */ + *deftilelength = atoi(optarg); + break; + case 'p': /* planar configuration */ + if (streq(optarg, ""separate"")) + *defconfig = PLANARCONFIG_SEPARATE; + else if (streq(optarg, ""contig"")) + *defconfig = PLANARCONFIG_CONTIG; + else + { + TIFFError (""Unkown planar configuration"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'r': /* rows/strip */ + *defrowsperstrip = atol(optarg); + break; + case 's': /* generate stripped output */ + outtiled = FALSE; + break; + case 't': /* generate tiled output */ + outtiled = TRUE; + break; + case 'v': TIFFError(""Library Release"", ""%s"", TIFFGetVersion()); + TIFFError (""Tiffcrop version"", ""%s, last updated: %s"", + tiffcrop_version_id, tiffcrop_rev_date); + TIFFError (""Tiffcp code"", ""Copyright (c) 1988-1997 Sam Leffler""); + TIFFError ("" "", ""Copyright (c) 1991-1997 Silicon Graphics, Inc""); + TIFFError (""Tiffcrop additions"", ""Copyright (c) 2007-2010 Richard Nolde""); + exit (0); + break; + case 'w': /* tile width */ + outtiled = TRUE; + *deftilewidth = atoi(optarg); + break; + case 'z': /* regions of an image specified as x1,y1,x2,y2:x3,y3,x4,y4 etc */ + crop_data->crop_mode |= CROP_REGIONS; + for (i = 0, opt_ptr = strtok (optarg, "":""); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, "":"")), i++) + { + crop_data->regions++; + if (sscanf(opt_ptr, ""%lf,%lf,%lf,%lf"", + &crop_data->corners[i].X1, &crop_data->corners[i].Y1, + &crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4) + { + TIFFError (""Unable to parse coordinates for region"", ""%d %s"", i, optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + } + /* check for remaining elements over MAX_REGIONS */ + if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) + { + TIFFError (""Region list exceeds limit of"", ""%d regions %s"", MAX_REGIONS, optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1);; + } + break; + /* options for file open modes */ + case 'B': *mp++ = 'b'; *mp = '\0'; + break; + case 'L': *mp++ = 'l'; *mp = '\0'; + break; + case 'M': *mp++ = 'm'; *mp = '\0'; + break; + case 'C': *mp++ = 'c'; *mp = '\0'; + break; + /* options for Debugging / data dump */ + case 'D': for (i = 0, opt_ptr = strtok (optarg, "",""); + (opt_ptr != NULL); + (opt_ptr = strtok (NULL, "","")), i++) + { + opt_offset = strpbrk(opt_ptr, "":=""); + if (opt_offset == NULL) + { + TIFFError(""Invalid dump option"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + + *opt_offset = '\0'; + /* convert option to lowercase */ + end = strlen (opt_ptr); + for (i = 0; i < end; i++) + *(opt_ptr + i) = tolower((int) *(opt_ptr + i)); + /* Look for dump format specification */ + if (strncmp(opt_ptr, ""for"", 3) == 0) + { + /* convert value to lowercase */ + end = strlen (opt_offset + 1); + for (i = 1; i <= end; i++) + *(opt_offset + i) = tolower((int) *(opt_offset + i)); + /* check dump format value */ + if (strncmp (opt_offset + 1, ""txt"", 3) == 0) + { + dump->format = DUMP_TEXT; + strcpy (dump->mode, ""w""); + } + else + { + if (strncmp(opt_offset + 1, ""raw"", 3) == 0) + { + dump->format = DUMP_RAW; + strcpy (dump->mode, ""wb""); + } + else + { + TIFFError(""parse_command_opts"", ""Unknown dump format %s"", opt_offset + 1); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + } + } + else + { /* Look for dump level specification */ + if (strncmp (opt_ptr, ""lev"", 3) == 0) + dump->level = atoi(opt_offset + 1); + /* Look for input data dump file name */ + if (strncmp (opt_ptr, ""in"", 2) == 0) + { + strncpy (dump->infilename, opt_offset + 1, PATH_MAX - 20); + dump->infilename[PATH_MAX - 20] = '\0'; + } + /* Look for output data dump file name */ + if (strncmp (opt_ptr, ""out"", 3) == 0) + { + strncpy (dump->outfilename, opt_offset + 1, PATH_MAX - 20); + dump->outfilename[PATH_MAX - 20] = '\0'; + } + if (strncmp (opt_ptr, ""deb"", 3) == 0) + dump->debug = atoi(opt_offset + 1); + } + } + if ((strlen(dump->infilename)) || (strlen(dump->outfilename))) + { + if (dump->level == 1) + TIFFError("""",""Defaulting to dump level 1, no data.""); + if (dump->format == DUMP_NONE) + { + TIFFError("""", ""You must specify a dump format for dump files""); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + } + break; + + /* image manipulation routine options */ + case 'm': /* margins to exclude from selection, uppercase M was already used */ + /* order of values must be TOP, LEFT, BOTTOM, RIGHT */ + crop_data->crop_mode |= CROP_MARGINS; + for (i = 0, opt_ptr = strtok (optarg, "",:""); + ((opt_ptr != NULL) && (i < 4)); + (opt_ptr = strtok (NULL, "",:"")), i++) + { + crop_data->margins[i] = atof(opt_ptr); + } + break; + case 'E': /* edge reference */ + switch (tolower((int) optarg[0])) + { + case 't': crop_data->edge_ref = EDGE_TOP; + break; + case 'b': crop_data->edge_ref = EDGE_BOTTOM; + break; + case 'l': crop_data->edge_ref = EDGE_LEFT; + break; + case 'r': crop_data->edge_ref = EDGE_RIGHT; + break; + default: TIFFError (""Edge reference must be top, bottom, left, or right"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'F': /* flip eg mirror image or cropped segment, M was already used */ + crop_data->crop_mode |= CROP_MIRROR; + switch (tolower((int) optarg[0])) + { + case 'h': crop_data->mirror = MIRROR_HORIZ; + break; + case 'v': crop_data->mirror = MIRROR_VERT; + break; + case 'b': crop_data->mirror = MIRROR_BOTH; + break; + default: TIFFError (""Flip mode must be horiz, vert, or both"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'H': /* set horizontal resolution to new value */ + page->hres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'I': /* invert the color space, eg black to white */ + crop_data->crop_mode |= CROP_INVERT; + /* The PHOTOMETIC_INTERPRETATION tag may be updated */ + if (streq(optarg, ""black"")) + { + crop_data->photometric = PHOTOMETRIC_MINISBLACK; + continue; + } + if (streq(optarg, ""white"")) + { + crop_data->photometric = PHOTOMETRIC_MINISWHITE; + continue; + } + if (streq(optarg, ""data"")) + { + crop_data->photometric = INVERT_DATA_ONLY; + continue; + } + if (streq(optarg, ""both"")) + { + crop_data->photometric = INVERT_DATA_AND_TAG; + continue; + } + + TIFFError(""Missing or unknown option for inverting PHOTOMETRIC_INTERPRETATION"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + break; + case 'J': /* horizontal margin for sectioned ouput pages */ + page->hmargin = atof(optarg); + page->mode |= PAGE_MODE_MARGINS; + break; + case 'K': /* vertical margin for sectioned ouput pages*/ + page->vmargin = atof(optarg); + page->mode |= PAGE_MODE_MARGINS; + break; + case 'N': /* list of images to process */ + for (i = 0, opt_ptr = strtok (optarg, "",""); + ((opt_ptr != NULL) && (i < MAX_IMAGES)); + (opt_ptr = strtok (NULL, "",""))) + { /* We do not know how many images are in file yet + * so we build a list to include the maximum allowed + * and follow it until we hit the end of the file. + * Image count is not accurate for odd, even, last + * so page numbers won't be valid either. + */ + if (streq(opt_ptr, ""odd"")) + { + for (j = 1; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = (MAX_IMAGES - 1) / 2; + break; + } + else + { + if (streq(opt_ptr, ""even"")) + { + for (j = 2; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = MAX_IMAGES / 2; + break; + } + else + { + if (streq(opt_ptr, ""last"")) + imagelist[i++] = MAX_IMAGES; + else /* single value between commas */ + { + sep = strpbrk(opt_ptr, "":-""); + if (!sep) + imagelist[i++] = atoi(opt_ptr); + else + { + *sep = '\0'; + start = atoi (opt_ptr); + if (!strcmp((sep + 1), ""last"")) + end = MAX_IMAGES; + else + end = atoi (sep + 1); + for (j = start; j <= end && j - start + i < MAX_IMAGES; j++) + imagelist[i++] = j; + } + } + } + } + } + *image_count = i; + break; + case 'O': /* page orientation */ + switch (tolower((int) optarg[0])) + { + case 'a': page->orient = ORIENTATION_AUTO; + break; + case 'p': page->orient = ORIENTATION_PORTRAIT; + break; + case 'l': page->orient = ORIENTATION_LANDSCAPE; + break; + default: TIFFError (""Orientation must be portrait, landscape, or auto."", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'P': /* page size selection */ + if (sscanf(optarg, ""%lfx%lf"", &page->width, &page->length) == 2) + { + strcpy (page->name, ""Custom""); + page->mode |= PAGE_MODE_PAPERSIZE; + break; + } + if (get_page_geometry (optarg, page)) + { + if (!strcmp(optarg, ""list"")) + { + TIFFError("""", ""Name Width Length (in inches)""); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("""", ""%-15.15s %5.2f %5.2f"", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (-1); + } + + TIFFError (""Invalid paper size"", ""%s"", optarg); + TIFFError ("""", ""Select one of:""); + TIFFError("""", ""Name Width Length (in inches)""); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("""", ""%-15.15s %5.2f %5.2f"", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (-1); + } + else + { + page->mode |= PAGE_MODE_PAPERSIZE; + } + break; + case 'R': /* rotate image or cropped segment */ + crop_data->crop_mode |= CROP_ROTATE; + switch (strtoul(optarg, NULL, 0)) + { + case 90: crop_data->rotation = (uint16)90; + break; + case 180: crop_data->rotation = (uint16)180; + break; + case 270: crop_data->rotation = (uint16)270; + break; + default: TIFFError (""Rotation must be 90, 180, or 270 degrees clockwise"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'S': /* subdivide into Cols:Rows sections, eg 3:2 would be 3 across and 2 down */ + sep = strpbrk(optarg, "",:""); + if (sep) + { + *sep = '\0'; + page->cols = atoi(optarg); + page->rows = atoi(sep +1); + } + else + { + page->cols = atoi(optarg); + page->rows = atoi(optarg); + } + if ((page->cols * page->rows) > MAX_SECTIONS) + { + TIFFError (""Limit for subdivisions, ie rows x columns, exceeded"", ""%d"", MAX_SECTIONS); + exit (-1); + } + page->mode |= PAGE_MODE_ROWSCOLS; + break; + case 'U': /* units for measurements and offsets */ + if (streq(optarg, ""in"")) + { + crop_data->res_unit = RESUNIT_INCH; + page->res_unit = RESUNIT_INCH; + } + else if (streq(optarg, ""cm"")) + { + crop_data->res_unit = RESUNIT_CENTIMETER; + page->res_unit = RESUNIT_CENTIMETER; + } + else if (streq(optarg, ""px"")) + { + crop_data->res_unit = RESUNIT_NONE; + page->res_unit = RESUNIT_NONE; + } + else + { + TIFFError (""Illegal unit of measure"",""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'V': /* set vertical resolution to new value */ + page->vres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'X': /* selection width */ + crop_data->crop_mode |= CROP_WIDTH; + crop_data->width = atof(optarg); + break; + case 'Y': /* selection length */ + crop_data->crop_mode |= CROP_LENGTH; + crop_data->length = atof(optarg); + break; + case 'Z': /* zones of an image X:Y read as zone X of Y */ + crop_data->crop_mode |= CROP_ZONES; + for (i = 0, opt_ptr = strtok (optarg, "",""); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, "","")), i++) + { + crop_data->zones++; + opt_offset = strchr(opt_ptr, ':'); + if (!opt_offset) { + TIFFError(""Wrong parameter syntax for -Z"", ""tiffcrop -h""); + exit(-1); + } + *opt_offset = '\0'; + crop_data->zonelist[i].position = atoi(opt_ptr); + crop_data->zonelist[i].total = atoi(opt_offset + 1); + } + /* check for remaining elements over MAX_REGIONS */ + if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) + { + TIFFError(""Zone list exceeds region limit"", ""%d"", MAX_REGIONS); + exit (-1); + } + break; + case '?': TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + /*NOTREACHED*/ + } + } + } /* end process_command_opts */ +",0,"void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 *dirnum, + uint16 *defconfig, uint16 *deffillorder, uint32 *deftilewidth, + uint32 *deftilelength, uint32 *defrowsperstrip, + struct crop_mask *crop_data, struct pagedef *page, + struct dump_opts *dump, + unsigned int *imagelist, unsigned int *image_count ) + { + int c, good_args = 0; + char *opt_offset = NULL; /* Position in string of value sought */ + char *opt_ptr = NULL; /* Pointer to next token in option set */ + char *sep = NULL; /* Pointer to a token separator */ + unsigned int i, j, start, end; +#if !HAVE_DECL_OPTARG + extern int optind; + extern char* optarg; +#endif + + *mp++ = 'w'; + *mp = '\0'; + while ((c = getopt(argc, argv, + ""ac:d:e:f:hil:m:p:r:stvw:z:BCD:E:F:H:I:J:K:LMN:O:P:R:S:U:V:X:Y:Z:"")) != -1) + { + good_args++; + switch (c) { + case 'a': mode[0] = 'a'; /* append to output */ + break; + case 'c': if (!processCompressOptions(optarg)) /* compression scheme */ + { + TIFFError (""Unknown compression option"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'd': start = strtoul(optarg, NULL, 0); /* initial IFD offset */ + if (start == 0) + { + TIFFError ("""",""Directory offset must be greater than zero""); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + *dirnum = start - 1; + break; + case 'e': switch (tolower((int) optarg[0])) /* image export modes*/ + { + case 'c': crop_data->exp_mode = ONE_FILE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Composite */ + case 'd': crop_data->exp_mode = ONE_FILE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Divided */ + case 'i': crop_data->exp_mode = FILE_PER_IMAGE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Image */ + case 'm': crop_data->exp_mode = FILE_PER_IMAGE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Multiple */ + case 's': crop_data->exp_mode = FILE_PER_SELECTION; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Sections */ + default: TIFFError (""Unknown export mode"",""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'f': if (streq(optarg, ""lsb2msb"")) /* fill order */ + *deffillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, ""msb2lsb"")) + *deffillorder = FILLORDER_MSB2LSB; + else + { + TIFFError (""Unknown fill order"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'h': usage(); + break; + case 'i': ignore = TRUE; /* ignore errors */ + break; + case 'l': outtiled = TRUE; /* tile length */ + *deftilelength = atoi(optarg); + break; + case 'p': /* planar configuration */ + if (streq(optarg, ""separate"")) + *defconfig = PLANARCONFIG_SEPARATE; + else if (streq(optarg, ""contig"")) + *defconfig = PLANARCONFIG_CONTIG; + else + { + TIFFError (""Unkown planar configuration"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'r': /* rows/strip */ + *defrowsperstrip = atol(optarg); + break; + case 's': /* generate stripped output */ + outtiled = FALSE; + break; + case 't': /* generate tiled output */ + outtiled = TRUE; + break; + case 'v': TIFFError(""Library Release"", ""%s"", TIFFGetVersion()); + TIFFError (""Tiffcrop version"", ""%s, last updated: %s"", + tiffcrop_version_id, tiffcrop_rev_date); + TIFFError (""Tiffcp code"", ""Copyright (c) 1988-1997 Sam Leffler""); + TIFFError ("" "", ""Copyright (c) 1991-1997 Silicon Graphics, Inc""); + TIFFError (""Tiffcrop additions"", ""Copyright (c) 2007-2010 Richard Nolde""); + exit (0); + break; + case 'w': /* tile width */ + outtiled = TRUE; + *deftilewidth = atoi(optarg); + break; + case 'z': /* regions of an image specified as x1,y1,x2,y2:x3,y3,x4,y4 etc */ + crop_data->crop_mode |= CROP_REGIONS; + for (i = 0, opt_ptr = strtok (optarg, "":""); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, "":"")), i++) + { + crop_data->regions++; + if (sscanf(opt_ptr, ""%lf,%lf,%lf,%lf"", + &crop_data->corners[i].X1, &crop_data->corners[i].Y1, + &crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4) + { + TIFFError (""Unable to parse coordinates for region"", ""%d %s"", i, optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + } + /* check for remaining elements over MAX_REGIONS */ + if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) + { + TIFFError (""Region list exceeds limit of"", ""%d regions %s"", MAX_REGIONS, optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1);; + } + break; + /* options for file open modes */ + case 'B': *mp++ = 'b'; *mp = '\0'; + break; + case 'L': *mp++ = 'l'; *mp = '\0'; + break; + case 'M': *mp++ = 'm'; *mp = '\0'; + break; + case 'C': *mp++ = 'c'; *mp = '\0'; + break; + /* options for Debugging / data dump */ + case 'D': for (i = 0, opt_ptr = strtok (optarg, "",""); + (opt_ptr != NULL); + (opt_ptr = strtok (NULL, "","")), i++) + { + opt_offset = strpbrk(opt_ptr, "":=""); + if (opt_offset == NULL) + { + TIFFError(""Invalid dump option"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + + *opt_offset = '\0'; + /* convert option to lowercase */ + end = strlen (opt_ptr); + for (i = 0; i < end; i++) + *(opt_ptr + i) = tolower((int) *(opt_ptr + i)); + /* Look for dump format specification */ + if (strncmp(opt_ptr, ""for"", 3) == 0) + { + /* convert value to lowercase */ + end = strlen (opt_offset + 1); + for (i = 1; i <= end; i++) + *(opt_offset + i) = tolower((int) *(opt_offset + i)); + /* check dump format value */ + if (strncmp (opt_offset + 1, ""txt"", 3) == 0) + { + dump->format = DUMP_TEXT; + strcpy (dump->mode, ""w""); + } + else + { + if (strncmp(opt_offset + 1, ""raw"", 3) == 0) + { + dump->format = DUMP_RAW; + strcpy (dump->mode, ""wb""); + } + else + { + TIFFError(""parse_command_opts"", ""Unknown dump format %s"", opt_offset + 1); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + } + } + else + { /* Look for dump level specification */ + if (strncmp (opt_ptr, ""lev"", 3) == 0) + dump->level = atoi(opt_offset + 1); + /* Look for input data dump file name */ + if (strncmp (opt_ptr, ""in"", 2) == 0) + { + strncpy (dump->infilename, opt_offset + 1, PATH_MAX - 20); + dump->infilename[PATH_MAX - 20] = '\0'; + } + /* Look for output data dump file name */ + if (strncmp (opt_ptr, ""out"", 3) == 0) + { + strncpy (dump->outfilename, opt_offset + 1, PATH_MAX - 20); + dump->outfilename[PATH_MAX - 20] = '\0'; + } + if (strncmp (opt_ptr, ""deb"", 3) == 0) + dump->debug = atoi(opt_offset + 1); + } + } + if ((strlen(dump->infilename)) || (strlen(dump->outfilename))) + { + if (dump->level == 1) + TIFFError("""",""Defaulting to dump level 1, no data.""); + if (dump->format == DUMP_NONE) + { + TIFFError("""", ""You must specify a dump format for dump files""); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + } + break; + + /* image manipulation routine options */ + case 'm': /* margins to exclude from selection, uppercase M was already used */ + /* order of values must be TOP, LEFT, BOTTOM, RIGHT */ + crop_data->crop_mode |= CROP_MARGINS; + for (i = 0, opt_ptr = strtok (optarg, "",:""); + ((opt_ptr != NULL) && (i < 4)); + (opt_ptr = strtok (NULL, "",:"")), i++) + { + crop_data->margins[i] = atof(opt_ptr); + } + break; + case 'E': /* edge reference */ + switch (tolower((int) optarg[0])) + { + case 't': crop_data->edge_ref = EDGE_TOP; + break; + case 'b': crop_data->edge_ref = EDGE_BOTTOM; + break; + case 'l': crop_data->edge_ref = EDGE_LEFT; + break; + case 'r': crop_data->edge_ref = EDGE_RIGHT; + break; + default: TIFFError (""Edge reference must be top, bottom, left, or right"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'F': /* flip eg mirror image or cropped segment, M was already used */ + crop_data->crop_mode |= CROP_MIRROR; + switch (tolower((int) optarg[0])) + { + case 'h': crop_data->mirror = MIRROR_HORIZ; + break; + case 'v': crop_data->mirror = MIRROR_VERT; + break; + case 'b': crop_data->mirror = MIRROR_BOTH; + break; + default: TIFFError (""Flip mode must be horiz, vert, or both"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'H': /* set horizontal resolution to new value */ + page->hres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'I': /* invert the color space, eg black to white */ + crop_data->crop_mode |= CROP_INVERT; + /* The PHOTOMETIC_INTERPRETATION tag may be updated */ + if (streq(optarg, ""black"")) + { + crop_data->photometric = PHOTOMETRIC_MINISBLACK; + continue; + } + if (streq(optarg, ""white"")) + { + crop_data->photometric = PHOTOMETRIC_MINISWHITE; + continue; + } + if (streq(optarg, ""data"")) + { + crop_data->photometric = INVERT_DATA_ONLY; + continue; + } + if (streq(optarg, ""both"")) + { + crop_data->photometric = INVERT_DATA_AND_TAG; + continue; + } + + TIFFError(""Missing or unknown option for inverting PHOTOMETRIC_INTERPRETATION"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + break; + case 'J': /* horizontal margin for sectioned ouput pages */ + page->hmargin = atof(optarg); + page->mode |= PAGE_MODE_MARGINS; + break; + case 'K': /* vertical margin for sectioned ouput pages*/ + page->vmargin = atof(optarg); + page->mode |= PAGE_MODE_MARGINS; + break; + case 'N': /* list of images to process */ + for (i = 0, opt_ptr = strtok (optarg, "",""); + ((opt_ptr != NULL) && (i < MAX_IMAGES)); + (opt_ptr = strtok (NULL, "",""))) + { /* We do not know how many images are in file yet + * so we build a list to include the maximum allowed + * and follow it until we hit the end of the file. + * Image count is not accurate for odd, even, last + * so page numbers won't be valid either. + */ + if (streq(opt_ptr, ""odd"")) + { + for (j = 1; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = (MAX_IMAGES - 1) / 2; + break; + } + else + { + if (streq(opt_ptr, ""even"")) + { + for (j = 2; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = MAX_IMAGES / 2; + break; + } + else + { + if (streq(opt_ptr, ""last"")) + imagelist[i++] = MAX_IMAGES; + else /* single value between commas */ + { + sep = strpbrk(opt_ptr, "":-""); + if (!sep) + imagelist[i++] = atoi(opt_ptr); + else + { + *sep = '\0'; + start = atoi (opt_ptr); + if (!strcmp((sep + 1), ""last"")) + end = MAX_IMAGES; + else + end = atoi (sep + 1); + for (j = start; j <= end && j - start + i < MAX_IMAGES; j++) + imagelist[i++] = j; + } + } + } + } + } + *image_count = i; + break; + case 'O': /* page orientation */ + switch (tolower((int) optarg[0])) + { + case 'a': page->orient = ORIENTATION_AUTO; + break; + case 'p': page->orient = ORIENTATION_PORTRAIT; + break; + case 'l': page->orient = ORIENTATION_LANDSCAPE; + break; + default: TIFFError (""Orientation must be portrait, landscape, or auto."", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'P': /* page size selection */ + if (sscanf(optarg, ""%lfx%lf"", &page->width, &page->length) == 2) + { + strcpy (page->name, ""Custom""); + page->mode |= PAGE_MODE_PAPERSIZE; + break; + } + if (get_page_geometry (optarg, page)) + { + if (!strcmp(optarg, ""list"")) + { + TIFFError("""", ""Name Width Length (in inches)""); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("""", ""%-15.15s %5.2f %5.2f"", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (-1); + } + + TIFFError (""Invalid paper size"", ""%s"", optarg); + TIFFError ("""", ""Select one of:""); + TIFFError("""", ""Name Width Length (in inches)""); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("""", ""%-15.15s %5.2f %5.2f"", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (-1); + } + else + { + page->mode |= PAGE_MODE_PAPERSIZE; + } + break; + case 'R': /* rotate image or cropped segment */ + crop_data->crop_mode |= CROP_ROTATE; + switch (strtoul(optarg, NULL, 0)) + { + case 90: crop_data->rotation = (uint16)90; + break; + case 180: crop_data->rotation = (uint16)180; + break; + case 270: crop_data->rotation = (uint16)270; + break; + default: TIFFError (""Rotation must be 90, 180, or 270 degrees clockwise"", ""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'S': /* subdivide into Cols:Rows sections, eg 3:2 would be 3 across and 2 down */ + sep = strpbrk(optarg, "",:""); + if (sep) + { + *sep = '\0'; + page->cols = atoi(optarg); + page->rows = atoi(sep +1); + } + else + { + page->cols = atoi(optarg); + page->rows = atoi(optarg); + } + if ((page->cols * page->rows) > MAX_SECTIONS) + { + TIFFError (""Limit for subdivisions, ie rows x columns, exceeded"", ""%d"", MAX_SECTIONS); + exit (-1); + } + page->mode |= PAGE_MODE_ROWSCOLS; + break; + case 'U': /* units for measurements and offsets */ + if (streq(optarg, ""in"")) + { + crop_data->res_unit = RESUNIT_INCH; + page->res_unit = RESUNIT_INCH; + } + else if (streq(optarg, ""cm"")) + { + crop_data->res_unit = RESUNIT_CENTIMETER; + page->res_unit = RESUNIT_CENTIMETER; + } + else if (streq(optarg, ""px"")) + { + crop_data->res_unit = RESUNIT_NONE; + page->res_unit = RESUNIT_NONE; + } + else + { + TIFFError (""Illegal unit of measure"",""%s"", optarg); + TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + } + break; + case 'V': /* set vertical resolution to new value */ + page->vres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'X': /* selection width */ + crop_data->crop_mode |= CROP_WIDTH; + crop_data->width = atof(optarg); + break; + case 'Y': /* selection length */ + crop_data->crop_mode |= CROP_LENGTH; + crop_data->length = atof(optarg); + break; + case 'Z': /* zones of an image X:Y read as zone X of Y */ + crop_data->crop_mode |= CROP_ZONES; + for (i = 0, opt_ptr = strtok (optarg, "",""); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, "","")), i++) + { + crop_data->zones++; + opt_offset = strchr(opt_ptr, ':'); + if (!opt_offset) { + TIFFError(""Wrong parameter syntax for -Z"", ""tiffcrop -h""); + exit(-1); + } + *opt_offset = '\0'; + crop_data->zonelist[i].position = atoi(opt_ptr); + crop_data->zonelist[i].total = atoi(opt_offset + 1); + } + /* check for remaining elements over MAX_REGIONS */ + if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) + { + TIFFError(""Zone list exceeds region limit"", ""%d"", MAX_REGIONS); + exit (-1); + } + break; + case '?': TIFFError (""For valid options type"", ""tiffcrop -h""); + exit (-1); + /*NOTREACHED*/ + } + } + } /* end process_command_opts */ +","@@ -819,9 +819,18 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, + } + } + +- tilebuf = _TIFFmalloc(tile_buffsize); ++ /* Add 3 padding bytes for extractContigSamplesShifted32bits */ ++ if( tile_buffsize > 0xFFFFFFFFU - 3 ) ++ { ++ TIFFError(""readContigTilesIntoBuffer"", ""Integer overflow when calculating buffer size.""); ++ exit(-1); ++ } ++ tilebuf = _TIFFmalloc(tile_buffsize + 3); + if (tilebuf == 0) + return 0; ++ tilebuf[tile_buffsize] = 0; ++ tilebuf[tile_buffsize+1] = 0; ++ tilebuf[tile_buffsize+2] = 0; + + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + for (row = 0; row < imagelength; row += tl)",4813,5049,6144 +17868,"void parser(void) +{ + char *arg; +#ifndef MINIMAL + char *sitearg; +#endif +#ifdef WITH_RFC2640 + char *narg = NULL; +#endif + size_t n; + +#ifdef IMPLICIT_TLS + (void) tls_init_new_session(); + data_protection_level = CPL_PRIVATE; +#endif + for (;;) { + xferfd = -1; + if (state_needs_update != 0) { + state_needs_update = 0; + setprocessname(""pure-ftpd (IDLE)""); +#ifdef FTPWHO + if (shm_data_cur != NULL) { + ftpwho_lock(); + shm_data_cur->state = FTPWHO_STATE_IDLE; + *shm_data_cur->filename = 0; + ftpwho_unlock(); + } +#endif + } + doreply(); + alarm(idletime * 2); + switch (sfgets()) { + case -1: +#ifdef BORING_MODE + die(421, LOG_INFO, MSG_TIMEOUT); +#else + die(421, LOG_INFO, MSG_TIMEOUT_PARSER); +#endif + case -2: + return; + } +#ifdef DEBUG + if (debug != 0) { + addreply(0, ""%s"", cmd); + } +#endif + n = (size_t) 0U; + while ((isalpha((unsigned char) cmd[n]) || cmd[n] == '@') && + n < cmdsize) { + cmd[n] = (char) tolower((unsigned char) cmd[n]); + n++; + } + if (n >= cmdsize) { /* overparanoid, it should never happen */ + die(421, LOG_WARNING, MSG_LINE_TOO_LONG); + } + if (n == (size_t) 0U) { + nop: + addreply_noformat(500, ""?""); + continue; + } +#ifdef SKIP_COMMAND_TRAILING_SPACES + while (isspace((unsigned char) cmd[n]) && n < cmdsize) { + cmd[n++] = 0; + } + arg = cmd + n; + while (cmd[n] != 0 && n < cmdsize) { + n++; + } + n--; + while (isspace((unsigned char) cmd[n])) { + cmd[n--] = 0; + } +#else + if (cmd[n] == 0) { + arg = cmd + n; + } else if (isspace((unsigned char) cmd[n])) { + cmd[n] = 0; + arg = cmd + n + 1; + } else { + goto nop; + } +#endif + if (logging != 0) { +#ifdef DEBUG + logfile(LOG_DEBUG, MSG_DEBUG_COMMAND "" [%s] [%s]"", + cmd, arg); +#else + logfile(LOG_DEBUG, MSG_DEBUG_COMMAND "" [%s] [%s]"", + cmd, strcmp(cmd, ""pass"") ? arg : ""<*>""); +#endif + } +#ifdef WITH_RFC2640 + narg = charset_client2fs(arg); + arg = narg; +#endif + /* + * antiidle() is called with dummy commands, usually used by clients + * who are wanting extra idle time. We give them some, but not too much. + * When we jump to wayout, the idle timer is not zeroed. It means that + * we didn't issue an 'active' command like RETR. + */ + +#ifndef MINIMAL + if (!strcmp(cmd, ""noop"")) { + antiidle(); + donoop(); + goto wayout; + } +#endif + if (!strcmp(cmd, ""user"")) { +#ifdef WITH_TLS + if (enforce_tls_auth > 1 && tls_cnx == NULL) { + die(421, LOG_WARNING, MSG_TLS_NEEDED); + } +#endif + douser(arg); + } else if (!strcmp(cmd, ""acct"")) { + addreply(202, MSG_WHOAREYOU); + } else if (!strcmp(cmd, ""pass"")) { + if (guest == 0) { + randomdelay(); + } + dopass(arg); + } else if (!strcmp(cmd, ""quit"")) { + addreply(221, MSG_GOODBYE, + (unsigned long long) ((uploaded + 1023ULL) / 1024ULL), + (unsigned long long) ((downloaded + 1023ULL) / 1024ULL)); + return; + } else if (!strcmp(cmd, ""syst"")) { + antiidle(); + addreply_noformat(215, ""UNIX Type: L8""); + goto wayout; +#ifdef WITH_TLS + } else if (enforce_tls_auth > 0 && + !strcmp(cmd, ""auth"") && !strcasecmp(arg, ""tls"")) { + addreply_noformat(234, ""AUTH TLS OK.""); + doreply(); + if (tls_cnx == NULL) { + (void) tls_init_new_session(); + } + goto wayout; + } else if (!strcmp(cmd, ""pbsz"")) { + addreply_noformat(tls_cnx == NULL ? 503 : 200, ""PBSZ=0""); + } else if (!strcmp(cmd, ""prot"")) { + if (tls_cnx == NULL) { + addreply_noformat(503, MSG_PROT_BEFORE_PBSZ); + goto wayout; + } + switch (*arg) { + case 0: + addreply_noformat(503, MSG_MISSING_ARG); + data_protection_level = CPL_NONE; + break; + case 'C': + if (arg[1] == 0) { + addreply(200, MSG_PROT_OK, ""clear""); + data_protection_level = CPL_CLEAR; + break; + } + case 'S': + case 'E': + if (arg[1] == 0) { + addreply(200, MSG_PROT_UNKNOWN_LEVEL, arg, ""private""); + data_protection_level = CPL_PRIVATE; + break; + } + case 'P': + if (arg[1] == 0) { + addreply(200, MSG_PROT_OK, ""private""); + data_protection_level = CPL_PRIVATE; + break; + } + default: + addreply_noformat(534, ""Fallback to [C]""); + data_protection_level = CPL_CLEAR; + break; + } +#endif + } else if (!strcmp(cmd, ""auth"") || !strcmp(cmd, ""adat"")) { + addreply_noformat(500, MSG_AUTH_UNIMPLEMENTED); + } else if (!strcmp(cmd, ""type"")) { + antiidle(); + dotype(arg); + goto wayout; + } else if (!strcmp(cmd, ""mode"")) { + antiidle(); + domode(arg); + goto wayout; +#ifndef MINIMAL + } else if (!strcmp(cmd, ""feat"")) { + dofeat(); + goto wayout; + } else if (!strcmp(cmd, ""opts"")) { + doopts(arg); + goto wayout; +#endif + } else if (!strcmp(cmd, ""stru"")) { + dostru(arg); + goto wayout; +#ifndef MINIMAL + } else if (!strcmp(cmd, ""help"")) { + goto help_site; +#endif +#ifdef DEBUG + } else if (!strcmp(cmd, ""xdbg"")) { + debug++; + addreply(200, MSG_XDBG_OK, debug); + goto wayout; +#endif + } else if (loggedin == 0) { + /* from this point, all commands need authentication */ + addreply_noformat(530, MSG_NOT_LOGGED_IN); + goto wayout; + } else { + if (!strcmp(cmd, ""cwd"") || !strcmp(cmd, ""xcwd"")) { + antiidle(); + docwd(arg); + goto wayout; + } else if (!strcmp(cmd, ""port"")) { + doport(arg); +#ifndef MINIMAL + } else if (!strcmp(cmd, ""eprt"")) { + doeprt(arg); + } else if (!strcmp(cmd, ""esta"") && + disallow_passive == 0 && + STORAGE_FAMILY(force_passive_ip) == 0) { + doesta(); + } else if (!strcmp(cmd, ""estp"")) { + doestp(); +#endif + } else if (disallow_passive == 0 && + (!strcmp(cmd, ""pasv"") || !strcmp(cmd, ""p@sw""))) { + dopasv(0); + } else if (disallow_passive == 0 && + (!strcmp(cmd, ""epsv"") && + (broken_client_compat == 0 || + STORAGE_FAMILY(ctrlconn) == AF_INET6))) { + if (!strcasecmp(arg, ""all"")) { + epsv_all = 1; + addreply_noformat(220, MSG_ACTIVE_DISABLED); + } else if (!strcmp(arg, ""2"") && !v6ready) { + addreply_noformat(522, MSG_ONLY_IPV4); + } else { + dopasv(1); + } +#ifndef MINIMAL + } else if (disallow_passive == 0 && !strcmp(cmd, ""spsv"")) { + dopasv(2); + } else if (!strcmp(cmd, ""allo"")) { + if (*arg == 0) { + addreply_noformat(501, MSG_STAT_FAILURE); + } else { + const off_t size = (off_t) strtoull(arg, NULL, 10); + + if (size < (off_t) 0) { + addreply_noformat(501, MSG_STAT_FAILURE); + } else { + doallo(size); + } + } +#endif + } else if (!strcmp(cmd, ""pwd"") || !strcmp(cmd, ""xpwd"")) { +#ifdef WITH_RFC2640 + char *nwd; +#endif + antiidle(); +#ifdef WITH_RFC2640 + nwd = charset_fs2client(wd); + addreply(257, ""\""%s\"" "" MSG_IS_YOUR_CURRENT_LOCATION, nwd); + free(nwd); +#else + addreply(257, ""\""%s\"" "" MSG_IS_YOUR_CURRENT_LOCATION, wd); +#endif + goto wayout; + } else if (!strcmp(cmd, ""cdup"") || !strcmp(cmd, ""xcup"")) { + docwd(""..""); + } else if (!strcmp(cmd, ""retr"")) { + if (*arg != 0) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } + else +#endif + { + doretr(arg); + } + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""rest"")) { + antiidle(); + if (*arg != 0) { + dorest(arg); + } else { + addreply_noformat(501, MSG_NO_RESTART_POINT); + restartat = (off_t) 0; + } + goto wayout; + } else if (!strcmp(cmd, ""dele"")) { + if (*arg != 0) { + dodele(arg); + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""stor"")) { + arg = revealextraspc(arg); + if (*arg != 0) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + dostor(arg, 0, autorename); + } + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""appe"")) { + arg = revealextraspc(arg); + if (*arg != 0) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + dostor(arg, 1, 0); + } + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } +#ifndef MINIMAL + } else if (!strcmp(cmd, ""stou"")) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + dostou(); + } +#endif +#ifndef DISABLE_MKD_RMD + } else if (!strcmp(cmd, ""mkd"") || !strcmp(cmd, ""xmkd"")) { + arg = revealextraspc(arg); + if (*arg != 0) { + domkd(arg); + } else { + addreply_noformat(501, MSG_NO_DIRECTORY_NAME); + } + } else if (!strcmp(cmd, ""rmd"") || !strcmp(cmd, ""xrmd"")) { + if (*arg != 0) { + dormd(arg); + } else { + addreply_noformat(550, MSG_NO_DIRECTORY_NAME); + } +#endif +#ifndef MINIMAL + } else if (!strcmp(cmd, ""stat"")) { + if (*arg != 0) { + modern_listings = 0; + donlist(arg, 1, 1, 1, 1); + } else { + addreply_noformat(211, ""http://www.pureftpd.org/""); + } +#endif + } else if (!strcmp(cmd, ""list"")) { +#ifndef MINIMAL + modern_listings = 0; +#endif +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + donlist(arg, 0, 1, 0, 1); + } + } else if (!strcmp(cmd, ""nlst"")) { +#ifndef MINIMAL + modern_listings = 0; +#endif +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + donlist(arg, 0, 0, 0, broken_client_compat); + } +#ifndef MINIMAL + } else if (!strcmp(cmd, ""mlst"")) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + domlst(*arg != 0 ? arg : "".""); + } + } else if (!strcmp(cmd, ""mlsd"")) { + modern_listings = 1; +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + donlist(arg, 0, 1, 1, 0); + } +#endif + } else if (!strcmp(cmd, ""abor"")) { + addreply_noformat(226, MSG_ABOR_SUCCESS); +#ifndef MINIMAL + } else if (!strcmp(cmd, ""site"")) { + if ((sitearg = arg) != NULL) { + while (*sitearg != 0 && !isspace((unsigned char) *sitearg)) { + sitearg++; + } + if (*sitearg != 0) { + *sitearg++ = 0; + } + } + if (!strcasecmp(arg, ""idle"")) { + if (sitearg == NULL || *sitearg == 0) { + addreply_noformat(501, ""SITE IDLE: "" MSG_MISSING_ARG); + } else { + unsigned long int i = 0; + + i = strtoul(sitearg, &sitearg, 10); + if (sitearg && *sitearg) + addreply(501, MSG_GARBAGE_FOUND "" : %s"", sitearg); + else if (i > MAX_SITE_IDLE) + addreply_noformat(501, MSG_VALUE_TOO_LARGE); + else { + idletime = i; + addreply(200, MSG_IDLE_TIME, idletime); + idletime_noop = (double) idletime * 2.0; + } + } + } else if (!strcasecmp(arg, ""time"")) { + dositetime(); + } else if (!strcasecmp(arg, ""help"")) { + help_site: + + addreply_noformat(214, MSG_SITE_HELP CRLF +# ifdef WITH_DIRALIASES + "" ALIAS"" CRLF +# endif + "" CHMOD"" CRLF "" IDLE"" CRLF "" UTIME""); + addreply_noformat(214, ""Pure-FTPd - http://pureftpd.org/""); + } else if (!strcasecmp(arg, ""chmod"")) { + char *sitearg2; + mode_t mode; + + parsechmod: + if (sitearg == NULL || *sitearg == 0) { + addreply_noformat(501, MSG_MISSING_ARG); + goto chmod_wayout; + } + sitearg2 = sitearg; + while (*sitearg2 != 0 && !isspace((unsigned char) *sitearg2)) { + sitearg2++; + } + while (*sitearg2 != 0 && isspace((unsigned char) *sitearg2)) { + sitearg2++; + } + if (*sitearg2 == 0) { + addreply_noformat(550, MSG_NO_FILE_NAME); + goto chmod_wayout; + } + mode = (mode_t) strtoul(sitearg, NULL, 8); + if (mode > (mode_t) 07777) { + addreply_noformat(501, MSG_BAD_CHMOD); + goto chmod_wayout; + } + dochmod(sitearg2, mode); + chmod_wayout: + (void) 0; + } else if (!strcasecmp(arg, ""utime"")) { + char *sitearg2; + + if (sitearg == NULL || *sitearg == 0) { + addreply_noformat(501, MSG_NO_FILE_NAME); + goto utime_wayout; + } + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + addreply_noformat(501, MSG_MISSING_ARG); + goto utime_wayout; + } + if (strcasecmp(sitearg2, "" UTC"") != 0) { + addreply_noformat(500, ""UTC Only""); + goto utime_wayout; + } + *sitearg2-- = 0; + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + utime_no_arg: + addreply_noformat(501, MSG_MISSING_ARG); + goto utime_wayout; + } + *sitearg2-- = 0; + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + goto utime_no_arg; + } + *sitearg2-- = 0; + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + goto utime_no_arg; + } + *sitearg2++ = 0; + if (*sitearg2 == 0) { + goto utime_no_arg; + } + doutime(sitearg, sitearg2); + utime_wayout: + (void) 0; +# ifdef WITH_DIRALIASES + } else if (!strcasecmp(arg, ""alias"")) { + if (sitearg == NULL || *sitearg == 0) { + print_aliases(); + } else { + const char *alias; + + if ((alias = lookup_alias(sitearg)) != NULL) { + addreply(214, MSG_ALIASES_ALIAS, sitearg, alias); + } else { + addreply(502, MSG_ALIASES_UNKNOWN, sitearg); + } + } +# endif + } else if (*arg != 0) { + addreply(500, ""SITE %s "" MSG_UNKNOWN_EXTENSION, arg); + } else { + addreply_noformat(500, ""SITE: "" MSG_MISSING_ARG); + } +#endif + } else if (!strcmp(cmd, ""mdtm"")) { + domdtm(arg); + } else if (!strcmp(cmd, ""size"")) { + dosize(arg); +#ifndef MINIMAL + } else if (!strcmp(cmd, ""chmod"")) { + sitearg = arg; + goto parsechmod; +#endif + } else if (!strcmp(cmd, ""rnfr"")) { + if (*arg != 0) { + dornfr(arg); + } else { + addreply_noformat(550, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""rnto"")) { + arg = revealextraspc(arg); + if (*arg != 0) { + dornto(arg); + } else { + addreply_noformat(550, MSG_NO_FILE_NAME); + } + } else { + addreply_noformat(500, MSG_UNKNOWN_COMMAND); + } + } + noopidle = (time_t) -1; + wayout: +#ifdef WITH_RFC2640 + free(narg); + narg = NULL; +#endif +#ifdef THROTTLING + if (throttling_delay != 0UL) { + usleep2(throttling_delay); + } +#else + (void) 0; +#endif + } +} +",1,"void parser(void) +{ + char *arg; +#ifndef MINIMAL + char *sitearg; +#endif +#ifdef WITH_RFC2640 + char *narg = NULL; +#endif + size_t n; + +#ifdef IMPLICIT_TLS + (void) tls_init_new_session(); + data_protection_level = CPL_PRIVATE; +#endif + for (;;) { + xferfd = -1; + if (state_needs_update != 0) { + state_needs_update = 0; + setprocessname(""pure-ftpd (IDLE)""); +#ifdef FTPWHO + if (shm_data_cur != NULL) { + ftpwho_lock(); + shm_data_cur->state = FTPWHO_STATE_IDLE; + *shm_data_cur->filename = 0; + ftpwho_unlock(); + } +#endif + } + doreply(); + alarm(idletime * 2); + switch (sfgets()) { + case -1: +#ifdef BORING_MODE + die(421, LOG_INFO, MSG_TIMEOUT); +#else + die(421, LOG_INFO, MSG_TIMEOUT_PARSER); +#endif + case -2: + return; + } +#ifdef DEBUG + if (debug != 0) { + addreply(0, ""%s"", cmd); + } +#endif + n = (size_t) 0U; + while ((isalpha((unsigned char) cmd[n]) || cmd[n] == '@') && + n < cmdsize) { + cmd[n] = (char) tolower((unsigned char) cmd[n]); + n++; + } + if (n >= cmdsize) { /* overparanoid, it should never happen */ + die(421, LOG_WARNING, MSG_LINE_TOO_LONG); + } + if (n == (size_t) 0U) { + nop: + addreply_noformat(500, ""?""); + continue; + } +#ifdef SKIP_COMMAND_TRAILING_SPACES + while (isspace((unsigned char) cmd[n]) && n < cmdsize) { + cmd[n++] = 0; + } + arg = cmd + n; + while (cmd[n] != 0 && n < cmdsize) { + n++; + } + n--; + while (isspace((unsigned char) cmd[n])) { + cmd[n--] = 0; + } +#else + if (cmd[n] == 0) { + arg = cmd + n; + } else if (isspace((unsigned char) cmd[n])) { + cmd[n] = 0; + arg = cmd + n + 1; + } else { + goto nop; + } +#endif + if (logging != 0) { +#ifdef DEBUG + logfile(LOG_DEBUG, MSG_DEBUG_COMMAND "" [%s] [%s]"", + cmd, arg); +#else + logfile(LOG_DEBUG, MSG_DEBUG_COMMAND "" [%s] [%s]"", + cmd, strcmp(cmd, ""pass"") ? arg : ""<*>""); +#endif + } +#ifdef WITH_RFC2640 + narg = charset_client2fs(arg); + arg = narg; +#endif + /* + * antiidle() is called with dummy commands, usually used by clients + * who are wanting extra idle time. We give them some, but not too much. + * When we jump to wayout, the idle timer is not zeroed. It means that + * we didn't issue an 'active' command like RETR. + */ + +#ifndef MINIMAL + if (!strcmp(cmd, ""noop"")) { + antiidle(); + donoop(); + goto wayout; + } +#endif + if (!strcmp(cmd, ""user"")) { +#ifdef WITH_TLS + if (enforce_tls_auth > 1 && tls_cnx == NULL) { + die(421, LOG_WARNING, MSG_TLS_NEEDED); + } +#endif + douser(arg); + } else if (!strcmp(cmd, ""acct"")) { + addreply(202, MSG_WHOAREYOU); + } else if (!strcmp(cmd, ""pass"")) { + if (guest == 0) { + randomdelay(); + } + dopass(arg); + } else if (!strcmp(cmd, ""quit"")) { + addreply(221, MSG_GOODBYE, + (unsigned long long) ((uploaded + 1023ULL) / 1024ULL), + (unsigned long long) ((downloaded + 1023ULL) / 1024ULL)); + return; + } else if (!strcmp(cmd, ""syst"")) { + antiidle(); + addreply_noformat(215, ""UNIX Type: L8""); + goto wayout; +#ifdef WITH_TLS + } else if (enforce_tls_auth > 0 && + !strcmp(cmd, ""auth"") && !strcasecmp(arg, ""tls"")) { + addreply_noformat(234, ""AUTH TLS OK.""); + doreply(); + if (tls_cnx == NULL) { + flush_cmd(); + (void) tls_init_new_session(); + } + goto wayout; + } else if (!strcmp(cmd, ""pbsz"")) { + addreply_noformat(tls_cnx == NULL ? 503 : 200, ""PBSZ=0""); + } else if (!strcmp(cmd, ""prot"")) { + if (tls_cnx == NULL) { + addreply_noformat(503, MSG_PROT_BEFORE_PBSZ); + goto wayout; + } + switch (*arg) { + case 0: + addreply_noformat(503, MSG_MISSING_ARG); + data_protection_level = CPL_NONE; + break; + case 'C': + if (arg[1] == 0) { + addreply(200, MSG_PROT_OK, ""clear""); + data_protection_level = CPL_CLEAR; + break; + } + case 'S': + case 'E': + if (arg[1] == 0) { + addreply(200, MSG_PROT_UNKNOWN_LEVEL, arg, ""private""); + data_protection_level = CPL_PRIVATE; + break; + } + case 'P': + if (arg[1] == 0) { + addreply(200, MSG_PROT_OK, ""private""); + data_protection_level = CPL_PRIVATE; + break; + } + default: + addreply_noformat(534, ""Fallback to [C]""); + data_protection_level = CPL_CLEAR; + break; + } +#endif + } else if (!strcmp(cmd, ""auth"") || !strcmp(cmd, ""adat"")) { + addreply_noformat(500, MSG_AUTH_UNIMPLEMENTED); + } else if (!strcmp(cmd, ""type"")) { + antiidle(); + dotype(arg); + goto wayout; + } else if (!strcmp(cmd, ""mode"")) { + antiidle(); + domode(arg); + goto wayout; +#ifndef MINIMAL + } else if (!strcmp(cmd, ""feat"")) { + dofeat(); + goto wayout; + } else if (!strcmp(cmd, ""opts"")) { + doopts(arg); + goto wayout; +#endif + } else if (!strcmp(cmd, ""stru"")) { + dostru(arg); + goto wayout; +#ifndef MINIMAL + } else if (!strcmp(cmd, ""help"")) { + goto help_site; +#endif +#ifdef DEBUG + } else if (!strcmp(cmd, ""xdbg"")) { + debug++; + addreply(200, MSG_XDBG_OK, debug); + goto wayout; +#endif + } else if (loggedin == 0) { + /* from this point, all commands need authentication */ + addreply_noformat(530, MSG_NOT_LOGGED_IN); + goto wayout; + } else { + if (!strcmp(cmd, ""cwd"") || !strcmp(cmd, ""xcwd"")) { + antiidle(); + docwd(arg); + goto wayout; + } else if (!strcmp(cmd, ""port"")) { + doport(arg); +#ifndef MINIMAL + } else if (!strcmp(cmd, ""eprt"")) { + doeprt(arg); + } else if (!strcmp(cmd, ""esta"") && + disallow_passive == 0 && + STORAGE_FAMILY(force_passive_ip) == 0) { + doesta(); + } else if (!strcmp(cmd, ""estp"")) { + doestp(); +#endif + } else if (disallow_passive == 0 && + (!strcmp(cmd, ""pasv"") || !strcmp(cmd, ""p@sw""))) { + dopasv(0); + } else if (disallow_passive == 0 && + (!strcmp(cmd, ""epsv"") && + (broken_client_compat == 0 || + STORAGE_FAMILY(ctrlconn) == AF_INET6))) { + if (!strcasecmp(arg, ""all"")) { + epsv_all = 1; + addreply_noformat(220, MSG_ACTIVE_DISABLED); + } else if (!strcmp(arg, ""2"") && !v6ready) { + addreply_noformat(522, MSG_ONLY_IPV4); + } else { + dopasv(1); + } +#ifndef MINIMAL + } else if (disallow_passive == 0 && !strcmp(cmd, ""spsv"")) { + dopasv(2); + } else if (!strcmp(cmd, ""allo"")) { + if (*arg == 0) { + addreply_noformat(501, MSG_STAT_FAILURE); + } else { + const off_t size = (off_t) strtoull(arg, NULL, 10); + + if (size < (off_t) 0) { + addreply_noformat(501, MSG_STAT_FAILURE); + } else { + doallo(size); + } + } +#endif + } else if (!strcmp(cmd, ""pwd"") || !strcmp(cmd, ""xpwd"")) { +#ifdef WITH_RFC2640 + char *nwd; +#endif + antiidle(); +#ifdef WITH_RFC2640 + nwd = charset_fs2client(wd); + addreply(257, ""\""%s\"" "" MSG_IS_YOUR_CURRENT_LOCATION, nwd); + free(nwd); +#else + addreply(257, ""\""%s\"" "" MSG_IS_YOUR_CURRENT_LOCATION, wd); +#endif + goto wayout; + } else if (!strcmp(cmd, ""cdup"") || !strcmp(cmd, ""xcup"")) { + docwd(""..""); + } else if (!strcmp(cmd, ""retr"")) { + if (*arg != 0) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } + else +#endif + { + doretr(arg); + } + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""rest"")) { + antiidle(); + if (*arg != 0) { + dorest(arg); + } else { + addreply_noformat(501, MSG_NO_RESTART_POINT); + restartat = (off_t) 0; + } + goto wayout; + } else if (!strcmp(cmd, ""dele"")) { + if (*arg != 0) { + dodele(arg); + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""stor"")) { + arg = revealextraspc(arg); + if (*arg != 0) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + dostor(arg, 0, autorename); + } + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""appe"")) { + arg = revealextraspc(arg); + if (*arg != 0) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + dostor(arg, 1, 0); + } + } else { + addreply_noformat(501, MSG_NO_FILE_NAME); + } +#ifndef MINIMAL + } else if (!strcmp(cmd, ""stou"")) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + dostou(); + } +#endif +#ifndef DISABLE_MKD_RMD + } else if (!strcmp(cmd, ""mkd"") || !strcmp(cmd, ""xmkd"")) { + arg = revealextraspc(arg); + if (*arg != 0) { + domkd(arg); + } else { + addreply_noformat(501, MSG_NO_DIRECTORY_NAME); + } + } else if (!strcmp(cmd, ""rmd"") || !strcmp(cmd, ""xrmd"")) { + if (*arg != 0) { + dormd(arg); + } else { + addreply_noformat(550, MSG_NO_DIRECTORY_NAME); + } +#endif +#ifndef MINIMAL + } else if (!strcmp(cmd, ""stat"")) { + if (*arg != 0) { + modern_listings = 0; + donlist(arg, 1, 1, 1, 1); + } else { + addreply_noformat(211, ""http://www.pureftpd.org/""); + } +#endif + } else if (!strcmp(cmd, ""list"")) { +#ifndef MINIMAL + modern_listings = 0; +#endif +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + donlist(arg, 0, 1, 0, 1); + } + } else if (!strcmp(cmd, ""nlst"")) { +#ifndef MINIMAL + modern_listings = 0; +#endif +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + donlist(arg, 0, 0, 0, broken_client_compat); + } +#ifndef MINIMAL + } else if (!strcmp(cmd, ""mlst"")) { +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + domlst(*arg != 0 ? arg : "".""); + } + } else if (!strcmp(cmd, ""mlsd"")) { + modern_listings = 1; +#ifdef WITH_TLS + if (enforce_tls_auth == 3 && + data_protection_level != CPL_PRIVATE) { + addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); + } else +#endif + { + donlist(arg, 0, 1, 1, 0); + } +#endif + } else if (!strcmp(cmd, ""abor"")) { + addreply_noformat(226, MSG_ABOR_SUCCESS); +#ifndef MINIMAL + } else if (!strcmp(cmd, ""site"")) { + if ((sitearg = arg) != NULL) { + while (*sitearg != 0 && !isspace((unsigned char) *sitearg)) { + sitearg++; + } + if (*sitearg != 0) { + *sitearg++ = 0; + } + } + if (!strcasecmp(arg, ""idle"")) { + if (sitearg == NULL || *sitearg == 0) { + addreply_noformat(501, ""SITE IDLE: "" MSG_MISSING_ARG); + } else { + unsigned long int i = 0; + + i = strtoul(sitearg, &sitearg, 10); + if (sitearg && *sitearg) + addreply(501, MSG_GARBAGE_FOUND "" : %s"", sitearg); + else if (i > MAX_SITE_IDLE) + addreply_noformat(501, MSG_VALUE_TOO_LARGE); + else { + idletime = i; + addreply(200, MSG_IDLE_TIME, idletime); + idletime_noop = (double) idletime * 2.0; + } + } + } else if (!strcasecmp(arg, ""time"")) { + dositetime(); + } else if (!strcasecmp(arg, ""help"")) { + help_site: + + addreply_noformat(214, MSG_SITE_HELP CRLF +# ifdef WITH_DIRALIASES + "" ALIAS"" CRLF +# endif + "" CHMOD"" CRLF "" IDLE"" CRLF "" UTIME""); + addreply_noformat(214, ""Pure-FTPd - http://pureftpd.org/""); + } else if (!strcasecmp(arg, ""chmod"")) { + char *sitearg2; + mode_t mode; + + parsechmod: + if (sitearg == NULL || *sitearg == 0) { + addreply_noformat(501, MSG_MISSING_ARG); + goto chmod_wayout; + } + sitearg2 = sitearg; + while (*sitearg2 != 0 && !isspace((unsigned char) *sitearg2)) { + sitearg2++; + } + while (*sitearg2 != 0 && isspace((unsigned char) *sitearg2)) { + sitearg2++; + } + if (*sitearg2 == 0) { + addreply_noformat(550, MSG_NO_FILE_NAME); + goto chmod_wayout; + } + mode = (mode_t) strtoul(sitearg, NULL, 8); + if (mode > (mode_t) 07777) { + addreply_noformat(501, MSG_BAD_CHMOD); + goto chmod_wayout; + } + dochmod(sitearg2, mode); + chmod_wayout: + (void) 0; + } else if (!strcasecmp(arg, ""utime"")) { + char *sitearg2; + + if (sitearg == NULL || *sitearg == 0) { + addreply_noformat(501, MSG_NO_FILE_NAME); + goto utime_wayout; + } + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + addreply_noformat(501, MSG_MISSING_ARG); + goto utime_wayout; + } + if (strcasecmp(sitearg2, "" UTC"") != 0) { + addreply_noformat(500, ""UTC Only""); + goto utime_wayout; + } + *sitearg2-- = 0; + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + utime_no_arg: + addreply_noformat(501, MSG_MISSING_ARG); + goto utime_wayout; + } + *sitearg2-- = 0; + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + goto utime_no_arg; + } + *sitearg2-- = 0; + if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || + sitearg2 == sitearg) { + goto utime_no_arg; + } + *sitearg2++ = 0; + if (*sitearg2 == 0) { + goto utime_no_arg; + } + doutime(sitearg, sitearg2); + utime_wayout: + (void) 0; +# ifdef WITH_DIRALIASES + } else if (!strcasecmp(arg, ""alias"")) { + if (sitearg == NULL || *sitearg == 0) { + print_aliases(); + } else { + const char *alias; + + if ((alias = lookup_alias(sitearg)) != NULL) { + addreply(214, MSG_ALIASES_ALIAS, sitearg, alias); + } else { + addreply(502, MSG_ALIASES_UNKNOWN, sitearg); + } + } +# endif + } else if (*arg != 0) { + addreply(500, ""SITE %s "" MSG_UNKNOWN_EXTENSION, arg); + } else { + addreply_noformat(500, ""SITE: "" MSG_MISSING_ARG); + } +#endif + } else if (!strcmp(cmd, ""mdtm"")) { + domdtm(arg); + } else if (!strcmp(cmd, ""size"")) { + dosize(arg); +#ifndef MINIMAL + } else if (!strcmp(cmd, ""chmod"")) { + sitearg = arg; + goto parsechmod; +#endif + } else if (!strcmp(cmd, ""rnfr"")) { + if (*arg != 0) { + dornfr(arg); + } else { + addreply_noformat(550, MSG_NO_FILE_NAME); + } + } else if (!strcmp(cmd, ""rnto"")) { + arg = revealextraspc(arg); + if (*arg != 0) { + dornto(arg); + } else { + addreply_noformat(550, MSG_NO_FILE_NAME); + } + } else { + addreply_noformat(500, MSG_UNKNOWN_COMMAND); + } + } + noopidle = (time_t) -1; + wayout: +#ifdef WITH_RFC2640 + free(narg); + narg = NULL; +#endif +#ifdef THROTTLING + if (throttling_delay != 0UL) { + usleep2(throttling_delay); + } +#else + (void) 0; +#endif + } +} +","@@ -57,14 +57,20 @@ static void randomdelay(void) + * -Frank. + */ + ++static size_t scanned; ++static size_t readnbd; ++ ++static void flush_cmd(void) ++{ ++ scanned = readnbd = (size_t) 0U; ++} ++ + int sfgets(void) + { + struct pollfd pfd; + int pollret; + ssize_t readnb; + signed char seen_r = 0; +- static size_t scanned; +- static size_t readnbd; + + if (scanned > (size_t) 0U) { /* support pipelining */ + readnbd -= scanned; +@@ -362,6 +368,7 @@ void parser(void) + addreply_noformat(234, ""AUTH TLS OK.""); + doreply(); + if (tls_cnx == NULL) { ++ flush_cmd(); + (void) tls_init_new_session(); + } + goto wayout;",4784,5020,6144 +7134,"static MagickBooleanType WriteICONImage(const ImageInfo *image_info, + Image *image) +{ + const char + *option; + + IconFile + icon_file; + + IconInfo + icon_info; + + Image + *images, + *next; + + MagickBooleanType + status; + + MagickOffsetType + offset, + scene; + + register const IndexPacket + *indexes; + + register const PixelPacket + *p; + + register ssize_t + i, + x; + + register unsigned char + *q; + + size_t + bytes_per_line, + scanline_pad; + + ssize_t + y; + + unsigned char + bit, + byte, + *pixels; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + images=(Image *) NULL; + option=GetImageOption(image_info,""icon:auto-resize""); + if (option != (const char *) NULL) + { + images=AutoResizeImage(image,option,&scene,&image->exception); + if (images == (Image *) NULL) + ThrowWriterException(ImageError,""InvalidDimensions""); + } + else + { + scene=0; + next=image; + do + { + if ((image->columns > 256L) || (image->rows > 256L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + scene++; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != + MagickFalse)); + } + /* + Dump out a ICON header template to be properly initialized later. + */ + (void) WriteBlobLSBShort(image,0); + (void) WriteBlobLSBShort(image,1); + (void) WriteBlobLSBShort(image,(unsigned char) scene); + (void) ResetMagickMemory(&icon_file,0,sizeof(icon_file)); + (void) ResetMagickMemory(&icon_info,0,sizeof(icon_info)); + scene=0; + next=(images != (Image *) NULL) ? images : image; + do + { + (void) WriteBlobByte(image,icon_file.directory[scene].width); + (void) WriteBlobByte(image,icon_file.directory[scene].height); + (void) WriteBlobByte(image,icon_file.directory[scene].colors); + (void) WriteBlobByte(image,icon_file.directory[scene].reserved); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].size); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].offset); + scene++; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse)); + scene=0; + next=(images != (Image *) NULL) ? images : image; + do + { + if ((next->columns > 255L) && (next->rows > 255L) && + ((next->compression == UndefinedCompression) || + (next->compression == ZipCompression))) + { + Image + *write_image; + + ImageInfo + *write_info; + + size_t + length; + + unsigned char + *png; + + write_image=CloneImage(next,0,0,MagickTrue,&image->exception); + if (write_image == (Image *) NULL) + { + images=DestroyImageList(images); + return(MagickFalse); + } + write_info=CloneImageInfo(image_info); + (void) CopyMagickString(write_info->filename,""PNG:"",MaxTextExtent); + + /* Don't write any ancillary chunks except for gAMA */ + (void) SetImageArtifact(write_image,""png:include-chunk"",""none,gama""); + + /* Only write PNG32 formatted PNG (32-bit RGBA), 8 bits per channel */ + (void) SetImageArtifact(write_image,""png:format"",""png32""); + + png=(unsigned char *) ImageToBlob(write_info,write_image,&length, + &image->exception); + write_image=DestroyImage(write_image); + write_info=DestroyImageInfo(write_info); + if (png == (unsigned char *) NULL) + { + images=DestroyImageList(images); + return(MagickFalse); + } + icon_file.directory[scene].width=0; + icon_file.directory[scene].height=0; + icon_file.directory[scene].colors=0; + icon_file.directory[scene].reserved=0; + icon_file.directory[scene].planes=1; + icon_file.directory[scene].bits_per_pixel=32; + icon_file.directory[scene].size=(size_t) length; + icon_file.directory[scene].offset=(size_t) TellBlob(image); + (void) WriteBlob(image,(size_t) length,png); + png=(unsigned char *) RelinquishMagickMemory(png); + } + else + { + /* + Initialize ICON raster file header. + */ + (void) TransformImageColorspace(image,sRGBColorspace); + icon_info.file_size=14+12+28; + icon_info.offset_bits=icon_info.file_size; + icon_info.compression=BI_RGB; + if ((next->storage_class != DirectClass) && (next->colors > 256)) + (void) SetImageStorageClass(next,DirectClass); + if (next->storage_class == DirectClass) + { + /* + Full color ICON raster. + */ + icon_info.number_colors=0; + icon_info.bits_per_pixel=32; + icon_info.compression=(size_t) BI_RGB; + } + else + { + size_t + one; + + /* + Colormapped ICON raster. + */ + icon_info.bits_per_pixel=8; + if (next->colors <= 256) + icon_info.bits_per_pixel=8; + if (next->colors <= 16) + icon_info.bits_per_pixel=4; + if (next->colors <= 2) + icon_info.bits_per_pixel=1; + one=1; + icon_info.number_colors=one << icon_info.bits_per_pixel; + if (icon_info.number_colors < next->colors) + { + (void) SetImageStorageClass(next,DirectClass); + icon_info.number_colors=0; + icon_info.bits_per_pixel=(unsigned short) 24; + icon_info.compression=(size_t) BI_RGB; + } + else + { + size_t + one; + + one=1; + icon_info.file_size+=3*(one << icon_info.bits_per_pixel); + icon_info.offset_bits+=3*(one << icon_info.bits_per_pixel); + icon_info.file_size+=(one << icon_info.bits_per_pixel); + icon_info.offset_bits+=(one << icon_info.bits_per_pixel); + } + } + bytes_per_line=(((next->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + icon_info.ba_offset=0; + icon_info.width=(ssize_t) next->columns; + icon_info.height=(ssize_t) next->rows; + icon_info.planes=1; + icon_info.image_size=bytes_per_line*next->rows; + icon_info.size=40; + icon_info.size+=(4*icon_info.number_colors); + icon_info.size+=icon_info.image_size; + icon_info.size+=(((icon_info.width+31) & ~31) >> 3)*icon_info.height; + icon_info.file_size+=icon_info.image_size; + icon_info.x_pixels=0; + icon_info.y_pixels=0; + switch (next->units) + { + case UndefinedResolution: + case PixelsPerInchResolution: + { + icon_info.x_pixels=(size_t) (100.0*next->x_resolution/2.54); + icon_info.y_pixels=(size_t) (100.0*next->y_resolution/2.54); + break; + } + case PixelsPerCentimeterResolution: + { + icon_info.x_pixels=(size_t) (100.0*next->x_resolution); + icon_info.y_pixels=(size_t) (100.0*next->y_resolution); + break; + } + } + icon_info.colors_important=icon_info.number_colors; + /* + Convert MIFF to ICON raster pixels. + */ + pixels=(unsigned char *) AcquireQuantumMemory((size_t) + icon_info.image_size,sizeof(*pixels)); + if (pixels == (unsigned char *) NULL) + { + images=DestroyImageList(images); + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) ResetMagickMemory(pixels,0,(size_t) icon_info.image_size); + switch (icon_info.bits_per_pixel) + { + case 1: + { + size_t + bit, + byte; + + /* + Convert PseudoClass image to a ICON monochrome image. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(next); + q=pixels+(next->rows-y-1)*bytes_per_line; + bit=0; + byte=0; + for (x=0; x < (ssize_t) next->columns; x++) + { + byte<<=1; + byte|=GetPixelIndex(indexes+x) != 0 ? 0x01 : 0x00; + bit++; + if (bit == 8) + { + *q++=(unsigned char) byte; + bit=0; + byte=0; + } + } + if (bit != 0) + *q++=(unsigned char) (byte << (8-bit)); + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 4: + { + size_t + nibble, + byte; + + /* + Convert PseudoClass image to a ICON monochrome image. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(next); + q=pixels+(next->rows-y-1)*bytes_per_line; + nibble=0; + byte=0; + for (x=0; x < (ssize_t) next->columns; x++) + { + byte<<=4; + byte|=((size_t) GetPixelIndex(indexes+x) & 0x0f); + nibble++; + if (nibble == 2) + { + *q++=(unsigned char) byte; + nibble=0; + byte=0; + } + } + if (nibble != 0) + *q++=(unsigned char) (byte << 4); + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 8: + { + /* + Convert PseudoClass packet to ICON pixel. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(next); + q=pixels+(next->rows-y-1)*bytes_per_line; + for (x=0; x < (ssize_t) next->columns; x++) + *q++=(unsigned char) GetPixelIndex(indexes+x); + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 24: + case 32: + { + /* + Convert DirectClass packet to ICON BGR888 or BGRA8888 pixel. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + q=pixels+(next->rows-y-1)*bytes_per_line; + for (x=0; x < (ssize_t) next->columns; x++) + { + *q++=ScaleQuantumToChar(GetPixelBlue(p)); + *q++=ScaleQuantumToChar(GetPixelGreen(p)); + *q++=ScaleQuantumToChar(GetPixelRed(p)); + if (next->matte == MagickFalse) + *q++=ScaleQuantumToChar(QuantumRange); + else + *q++=ScaleQuantumToChar(GetPixelAlpha(p)); + p++; + } + if (icon_info.bits_per_pixel == 24) + for (x=3L*(ssize_t) next->columns; x < (ssize_t) bytes_per_line; x++) + *q++=0x00; + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + } + /* + Write 40-byte version 3+ bitmap header. + */ + icon_file.directory[scene].width=(unsigned char) icon_info.width; + icon_file.directory[scene].height=(unsigned char) icon_info.height; + icon_file.directory[scene].colors=(unsigned char) + icon_info.number_colors; + icon_file.directory[scene].reserved=0; + icon_file.directory[scene].planes=icon_info.planes; + icon_file.directory[scene].bits_per_pixel=icon_info.bits_per_pixel; + icon_file.directory[scene].size=icon_info.size; + icon_file.directory[scene].offset=(size_t) TellBlob(image); + (void) WriteBlobLSBLong(image,(unsigned int) 40); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.width); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.height*2); + (void) WriteBlobLSBShort(image,icon_info.planes); + (void) WriteBlobLSBShort(image,icon_info.bits_per_pixel); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.compression); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.image_size); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.x_pixels); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.y_pixels); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.number_colors); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.colors_important); + if (next->storage_class == PseudoClass) + { + unsigned char + *icon_colormap; + + /* + Dump colormap to file. + */ + icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t) + (1UL << icon_info.bits_per_pixel),4UL*sizeof(*icon_colormap)); + if (icon_colormap == (unsigned char *) NULL) + { + images=DestroyImageList(images); + ThrowWriterException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + q=icon_colormap; + for (i=0; i < (ssize_t) next->colors; i++) + { + *q++=ScaleQuantumToChar(next->colormap[i].blue); + *q++=ScaleQuantumToChar(next->colormap[i].green); + *q++=ScaleQuantumToChar(next->colormap[i].red); + *q++=(unsigned char) 0x0; + } + for ( ; i < (ssize_t) (1UL << icon_info.bits_per_pixel); i++) + { + *q++=(unsigned char) 0x00; + *q++=(unsigned char) 0x00; + *q++=(unsigned char) 0x00; + *q++=(unsigned char) 0x00; + } + (void) WriteBlob(image,(size_t) (4UL*(1UL << + icon_info.bits_per_pixel)),icon_colormap); + icon_colormap=(unsigned char *) RelinquishMagickMemory( + icon_colormap); + } + (void) WriteBlob(image,(size_t) icon_info.image_size,pixels); + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + /* + Write matte mask. + */ + scanline_pad=(((next->columns+31) & ~31)-next->columns) >> 3; + for (y=((ssize_t) next->rows - 1); y >= 0; y--) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + bit=0; + byte=0; + for (x=0; x < (ssize_t) next->columns; x++) + { + byte<<=1; + if ((next->matte != MagickFalse) && + (GetPixelOpacity(p) == (Quantum) TransparentOpacity)) + byte|=0x01; + bit++; + if (bit == 8) + { + (void) WriteBlobByte(image,(unsigned char) byte); + bit=0; + byte=0; + } + p++; + } + if (bit != 0) + (void) WriteBlobByte(image,(unsigned char) (byte << (8-bit))); + for (i=0; i < (ssize_t) scanline_pad; i++) + (void) WriteBlobByte(image,(unsigned char) 0); + } + } + if (GetNextImageInList(next) == (Image *) NULL) + break; + status=SetImageProgress(next,SaveImagesTag,scene++, + GetImageListLength(next)); + if (status == MagickFalse) + break; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse)); + offset=SeekBlob(image,0,SEEK_SET); + (void) offset; + (void) WriteBlobLSBShort(image,0); + (void) WriteBlobLSBShort(image,1); + (void) WriteBlobLSBShort(image,(unsigned short) (scene+1)); + scene=0; + next=(images != (Image *) NULL) ? images : image; + do + { + (void) WriteBlobByte(image,icon_file.directory[scene].width); + (void) WriteBlobByte(image,icon_file.directory[scene].height); + (void) WriteBlobByte(image,icon_file.directory[scene].colors); + (void) WriteBlobByte(image,icon_file.directory[scene].reserved); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].size); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].offset); + scene++; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse)); + (void) CloseBlob(image); + images=DestroyImageList(images); + return(MagickTrue); +} +",0,"static MagickBooleanType WriteICONImage(const ImageInfo *image_info, + Image *image) +{ + const char + *option; + + IconFile + icon_file; + + IconInfo + icon_info; + + Image + *images, + *next; + + MagickBooleanType + status; + + MagickOffsetType + offset, + scene; + + register const IndexPacket + *indexes; + + register const PixelPacket + *p; + + register ssize_t + i, + x; + + register unsigned char + *q; + + size_t + bytes_per_line, + scanline_pad; + + ssize_t + y; + + unsigned char + bit, + byte, + *pixels; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%s"",image->filename); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + images=(Image *) NULL; + option=GetImageOption(image_info,""icon:auto-resize""); + if (option != (const char *) NULL) + { + images=AutoResizeImage(image,option,&scene,&image->exception); + if (images == (Image *) NULL) + ThrowWriterException(ImageError,""InvalidDimensions""); + } + else + { + scene=0; + next=image; + do + { + if ((image->columns > 256L) || (image->rows > 256L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + scene++; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != + MagickFalse)); + } + /* + Dump out a ICON header template to be properly initialized later. + */ + (void) WriteBlobLSBShort(image,0); + (void) WriteBlobLSBShort(image,1); + (void) WriteBlobLSBShort(image,(unsigned char) scene); + (void) ResetMagickMemory(&icon_file,0,sizeof(icon_file)); + (void) ResetMagickMemory(&icon_info,0,sizeof(icon_info)); + scene=0; + next=(images != (Image *) NULL) ? images : image; + do + { + (void) WriteBlobByte(image,icon_file.directory[scene].width); + (void) WriteBlobByte(image,icon_file.directory[scene].height); + (void) WriteBlobByte(image,icon_file.directory[scene].colors); + (void) WriteBlobByte(image,icon_file.directory[scene].reserved); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].size); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].offset); + scene++; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse)); + scene=0; + next=(images != (Image *) NULL) ? images : image; + do + { + if ((next->columns > 255L) && (next->rows > 255L) && + ((next->compression == UndefinedCompression) || + (next->compression == ZipCompression))) + { + Image + *write_image; + + ImageInfo + *write_info; + + size_t + length; + + unsigned char + *png; + + write_image=CloneImage(next,0,0,MagickTrue,&image->exception); + if (write_image == (Image *) NULL) + { + images=DestroyImageList(images); + return(MagickFalse); + } + write_info=CloneImageInfo(image_info); + (void) CopyMagickString(write_info->filename,""PNG:"",MaxTextExtent); + + /* Don't write any ancillary chunks except for gAMA */ + (void) SetImageArtifact(write_image,""png:include-chunk"",""none,gama""); + + /* Only write PNG32 formatted PNG (32-bit RGBA), 8 bits per channel */ + (void) SetImageArtifact(write_image,""png:format"",""png32""); + + png=(unsigned char *) ImageToBlob(write_info,write_image,&length, + &image->exception); + write_image=DestroyImage(write_image); + write_info=DestroyImageInfo(write_info); + if (png == (unsigned char *) NULL) + { + images=DestroyImageList(images); + return(MagickFalse); + } + icon_file.directory[scene].width=0; + icon_file.directory[scene].height=0; + icon_file.directory[scene].colors=0; + icon_file.directory[scene].reserved=0; + icon_file.directory[scene].planes=1; + icon_file.directory[scene].bits_per_pixel=32; + icon_file.directory[scene].size=(size_t) length; + icon_file.directory[scene].offset=(size_t) TellBlob(image); + (void) WriteBlob(image,(size_t) length,png); + png=(unsigned char *) RelinquishMagickMemory(png); + } + else + { + /* + Initialize ICON raster file header. + */ + (void) TransformImageColorspace(image,sRGBColorspace); + icon_info.file_size=14+12+28; + icon_info.offset_bits=icon_info.file_size; + icon_info.compression=BI_RGB; + if ((next->storage_class != DirectClass) && (next->colors > 256)) + (void) SetImageStorageClass(next,DirectClass); + if (next->storage_class == DirectClass) + { + /* + Full color ICON raster. + */ + icon_info.number_colors=0; + icon_info.bits_per_pixel=32; + icon_info.compression=(size_t) BI_RGB; + } + else + { + size_t + one; + + /* + Colormapped ICON raster. + */ + icon_info.bits_per_pixel=8; + if (next->colors <= 256) + icon_info.bits_per_pixel=8; + if (next->colors <= 16) + icon_info.bits_per_pixel=4; + if (next->colors <= 2) + icon_info.bits_per_pixel=1; + one=1; + icon_info.number_colors=one << icon_info.bits_per_pixel; + if (icon_info.number_colors < next->colors) + { + (void) SetImageStorageClass(next,DirectClass); + icon_info.number_colors=0; + icon_info.bits_per_pixel=(unsigned short) 24; + icon_info.compression=(size_t) BI_RGB; + } + else + { + size_t + one; + + one=1; + icon_info.file_size+=3*(one << icon_info.bits_per_pixel); + icon_info.offset_bits+=3*(one << icon_info.bits_per_pixel); + icon_info.file_size+=(one << icon_info.bits_per_pixel); + icon_info.offset_bits+=(one << icon_info.bits_per_pixel); + } + } + bytes_per_line=(((next->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + icon_info.ba_offset=0; + icon_info.width=(ssize_t) next->columns; + icon_info.height=(ssize_t) next->rows; + icon_info.planes=1; + icon_info.image_size=bytes_per_line*next->rows; + icon_info.size=40; + icon_info.size+=(4*icon_info.number_colors); + icon_info.size+=icon_info.image_size; + icon_info.size+=(((icon_info.width+31) & ~31) >> 3)*icon_info.height; + icon_info.file_size+=icon_info.image_size; + icon_info.x_pixels=0; + icon_info.y_pixels=0; + switch (next->units) + { + case UndefinedResolution: + case PixelsPerInchResolution: + { + icon_info.x_pixels=(size_t) (100.0*next->x_resolution/2.54); + icon_info.y_pixels=(size_t) (100.0*next->y_resolution/2.54); + break; + } + case PixelsPerCentimeterResolution: + { + icon_info.x_pixels=(size_t) (100.0*next->x_resolution); + icon_info.y_pixels=(size_t) (100.0*next->y_resolution); + break; + } + } + icon_info.colors_important=icon_info.number_colors; + /* + Convert MIFF to ICON raster pixels. + */ + pixels=(unsigned char *) AcquireQuantumMemory((size_t) + icon_info.image_size,sizeof(*pixels)); + if (pixels == (unsigned char *) NULL) + { + images=DestroyImageList(images); + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) ResetMagickMemory(pixels,0,(size_t) icon_info.image_size); + switch (icon_info.bits_per_pixel) + { + case 1: + { + size_t + bit, + byte; + + /* + Convert PseudoClass image to a ICON monochrome image. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(next); + q=pixels+(next->rows-y-1)*bytes_per_line; + bit=0; + byte=0; + for (x=0; x < (ssize_t) next->columns; x++) + { + byte<<=1; + byte|=GetPixelIndex(indexes+x) != 0 ? 0x01 : 0x00; + bit++; + if (bit == 8) + { + *q++=(unsigned char) byte; + bit=0; + byte=0; + } + } + if (bit != 0) + *q++=(unsigned char) (byte << (8-bit)); + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 4: + { + size_t + nibble, + byte; + + /* + Convert PseudoClass image to a ICON monochrome image. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(next); + q=pixels+(next->rows-y-1)*bytes_per_line; + nibble=0; + byte=0; + for (x=0; x < (ssize_t) next->columns; x++) + { + byte<<=4; + byte|=((size_t) GetPixelIndex(indexes+x) & 0x0f); + nibble++; + if (nibble == 2) + { + *q++=(unsigned char) byte; + nibble=0; + byte=0; + } + } + if (nibble != 0) + *q++=(unsigned char) (byte << 4); + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 8: + { + /* + Convert PseudoClass packet to ICON pixel. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(next); + q=pixels+(next->rows-y-1)*bytes_per_line; + for (x=0; x < (ssize_t) next->columns; x++) + *q++=(unsigned char) GetPixelIndex(indexes+x); + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 24: + case 32: + { + /* + Convert DirectClass packet to ICON BGR888 or BGRA8888 pixel. + */ + for (y=0; y < (ssize_t) next->rows; y++) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + q=pixels+(next->rows-y-1)*bytes_per_line; + for (x=0; x < (ssize_t) next->columns; x++) + { + *q++=ScaleQuantumToChar(GetPixelBlue(p)); + *q++=ScaleQuantumToChar(GetPixelGreen(p)); + *q++=ScaleQuantumToChar(GetPixelRed(p)); + if (next->matte == MagickFalse) + *q++=ScaleQuantumToChar(QuantumRange); + else + *q++=ScaleQuantumToChar(GetPixelAlpha(p)); + p++; + } + if (icon_info.bits_per_pixel == 24) + for (x=3L*(ssize_t) next->columns; x < (ssize_t) bytes_per_line; x++) + *q++=0x00; + if (next->previous == (Image *) NULL) + { + status=SetImageProgress(next,SaveImageTag,y,next->rows); + if (status == MagickFalse) + break; + } + } + break; + } + } + /* + Write 40-byte version 3+ bitmap header. + */ + icon_file.directory[scene].width=(unsigned char) icon_info.width; + icon_file.directory[scene].height=(unsigned char) icon_info.height; + icon_file.directory[scene].colors=(unsigned char) + icon_info.number_colors; + icon_file.directory[scene].reserved=0; + icon_file.directory[scene].planes=icon_info.planes; + icon_file.directory[scene].bits_per_pixel=icon_info.bits_per_pixel; + icon_file.directory[scene].size=icon_info.size; + icon_file.directory[scene].offset=(size_t) TellBlob(image); + (void) WriteBlobLSBLong(image,(unsigned int) 40); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.width); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.height*2); + (void) WriteBlobLSBShort(image,icon_info.planes); + (void) WriteBlobLSBShort(image,icon_info.bits_per_pixel); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.compression); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.image_size); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.x_pixels); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.y_pixels); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.number_colors); + (void) WriteBlobLSBLong(image,(unsigned int) icon_info.colors_important); + if (next->storage_class == PseudoClass) + { + unsigned char + *icon_colormap; + + /* + Dump colormap to file. + */ + icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t) + (1UL << icon_info.bits_per_pixel),4UL*sizeof(*icon_colormap)); + if (icon_colormap == (unsigned char *) NULL) + { + images=DestroyImageList(images); + ThrowWriterException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + q=icon_colormap; + for (i=0; i < (ssize_t) next->colors; i++) + { + *q++=ScaleQuantumToChar(next->colormap[i].blue); + *q++=ScaleQuantumToChar(next->colormap[i].green); + *q++=ScaleQuantumToChar(next->colormap[i].red); + *q++=(unsigned char) 0x0; + } + for ( ; i < (ssize_t) (1UL << icon_info.bits_per_pixel); i++) + { + *q++=(unsigned char) 0x00; + *q++=(unsigned char) 0x00; + *q++=(unsigned char) 0x00; + *q++=(unsigned char) 0x00; + } + (void) WriteBlob(image,(size_t) (4UL*(1UL << + icon_info.bits_per_pixel)),icon_colormap); + icon_colormap=(unsigned char *) RelinquishMagickMemory( + icon_colormap); + } + (void) WriteBlob(image,(size_t) icon_info.image_size,pixels); + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + /* + Write matte mask. + */ + scanline_pad=(((next->columns+31) & ~31)-next->columns) >> 3; + for (y=((ssize_t) next->rows - 1); y >= 0; y--) + { + p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception); + if (p == (const PixelPacket *) NULL) + break; + bit=0; + byte=0; + for (x=0; x < (ssize_t) next->columns; x++) + { + byte<<=1; + if ((next->matte != MagickFalse) && + (GetPixelOpacity(p) == (Quantum) TransparentOpacity)) + byte|=0x01; + bit++; + if (bit == 8) + { + (void) WriteBlobByte(image,(unsigned char) byte); + bit=0; + byte=0; + } + p++; + } + if (bit != 0) + (void) WriteBlobByte(image,(unsigned char) (byte << (8-bit))); + for (i=0; i < (ssize_t) scanline_pad; i++) + (void) WriteBlobByte(image,(unsigned char) 0); + } + } + if (GetNextImageInList(next) == (Image *) NULL) + break; + status=SetImageProgress(next,SaveImagesTag,scene++, + GetImageListLength(next)); + if (status == MagickFalse) + break; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse)); + offset=SeekBlob(image,0,SEEK_SET); + (void) offset; + (void) WriteBlobLSBShort(image,0); + (void) WriteBlobLSBShort(image,1); + (void) WriteBlobLSBShort(image,(unsigned short) (scene+1)); + scene=0; + next=(images != (Image *) NULL) ? images : image; + do + { + (void) WriteBlobByte(image,icon_file.directory[scene].width); + (void) WriteBlobByte(image,icon_file.directory[scene].height); + (void) WriteBlobByte(image,icon_file.directory[scene].colors); + (void) WriteBlobByte(image,icon_file.directory[scene].reserved); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes); + (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].size); + (void) WriteBlobLSBLong(image,(unsigned int) + icon_file.directory[scene].offset); + scene++; + next=SyncNextImageInList(next); + } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse)); + (void) CloseBlob(image); + images=DestroyImageList(images); + return(MagickTrue); +} +","@@ -462,6 +462,12 @@ static Image *ReadICONImage(const ImageInfo *image_info, + (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + bytes_per_line=(((image->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + (void) bytes_per_line;",4485,4721,6144 +367,"int ssl3_accept(SSL *s) +{ + BUF_MEM *buf; + unsigned long alg_k, Time = (unsigned long)time(NULL); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + int ret = -1; + int new_state, state, skip = 0; + + RAND_add(&Time, sizeof(Time), 0); + ERR_clear_error(); + clear_sys_error(); + + if (s->info_callback != NULL) + cb = s->info_callback; + else if (s->ctx->info_callback != NULL) + cb = s->ctx->info_callback; + + /* init things to blank */ + s->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) + SSL_clear(s); + + if (s->cert == NULL) { + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); + return (-1); + } +#ifndef OPENSSL_NO_HEARTBEATS + /* + * If we're awaiting a HeartbeatResponse, pretend we already got and + * don't await it anymore, because Heartbeats don't make sense during + * handshakes anyway. + */ + if (s->tlsext_hb_pending) { + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + for (;;) { + state = s->state; + + switch (s->state) { + case SSL_ST_RENEGOTIATE: + s->renegotiate = 1; + /* s->state=SSL_ST_ACCEPT; */ + + case SSL_ST_BEFORE: + case SSL_ST_ACCEPT: + case SSL_ST_BEFORE | SSL_ST_ACCEPT: + case SSL_ST_OK | SSL_ST_ACCEPT: + + s->server = 1; + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_START, 1); + + if ((s->version >> 8) != 3) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->type = SSL_ST_ACCEPT; + + if (s->init_buf == NULL) { + if ((buf = BUF_MEM_new()) == NULL) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { + BUF_MEM_free(buf); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + s->init_buf = buf; + } + + if (!ssl3_setup_buffers(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + s->init_num = 0; + s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + /* + * Should have been reset by ssl3_get_finished, too. + */ + s->s3->change_cipher_spec = 0; + + if (s->state != SSL_ST_RENEGOTIATE) { + /* + * Ok, we now need to push on a buffering BIO so that the + * output is sent in a way that TCP likes :-) + */ + if (!ssl_init_wbio_buffer(s, 1)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ssl3_init_finished_mac(s); + s->state = SSL3_ST_SR_CLNT_HELLO_A; + s->ctx->stats.sess_accept++; + } else if (!s->s3->send_connection_binding && + !(s->options & + SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + /* + * Server attempting to renegotiate with client that doesn't + * support secure renegotiation. + */ + SSLerr(SSL_F_SSL3_ACCEPT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } else { + /* + * s->state == SSL_ST_RENEGOTIATE, we will just send a + * HelloRequest + */ + s->ctx->stats.sess_accept_renegotiate++; + s->state = SSL3_ST_SW_HELLO_REQ_A; + } + break; + + case SSL3_ST_SW_HELLO_REQ_A: + case SSL3_ST_SW_HELLO_REQ_B: + + s->shutdown = 0; + ret = ssl3_send_hello_request(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + + ssl3_init_finished_mac(s); + break; + + case SSL3_ST_SW_HELLO_REQ_C: + s->state = SSL_ST_OK; + break; + + case SSL3_ST_SR_CLNT_HELLO_A: + case SSL3_ST_SR_CLNT_HELLO_B: + case SSL3_ST_SR_CLNT_HELLO_C: + + s->shutdown = 0; + ret = ssl3_get_client_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_SRP + s->state = SSL3_ST_SR_CLNT_HELLO_D; + case SSL3_ST_SR_CLNT_HELLO_D: + { + int al; + if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { + /* + * callback indicates firther work to be done + */ + s->rwstate = SSL_X509_LOOKUP; + goto end; + } + if (ret != SSL_ERROR_NONE) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + /* + * This is not really an error but the only means to for + * a client to detect whether srp is supported. + */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + } +#endif + + s->renegotiate = 2; + s->state = SSL3_ST_SW_SRVR_HELLO_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_SRVR_HELLO_A: + case SSL3_ST_SW_SRVR_HELLO_B: + ret = ssl3_send_server_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->hit) { + if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; + else + s->state = SSL3_ST_SW_CHANGE_A; + } +#else + if (s->hit) + s->state = SSL3_ST_SW_CHANGE_A; +#endif + else + s->state = SSL3_ST_SW_CERT_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_A: + case SSL3_ST_SW_CERT_B: + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or KRB5 or SRP */ + if (! + (s->s3->tmp. + new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 | + SSL_aSRP)) +&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + ret = ssl3_send_server_certificate(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->tlsext_status_expected) + s->state = SSL3_ST_SW_CERT_STATUS_A; + else + s->state = SSL3_ST_SW_KEY_EXCH_A; + } else { + skip = 1; + s->state = SSL3_ST_SW_KEY_EXCH_A; + } +#else + } else + skip = 1; + + s->state = SSL3_ST_SW_KEY_EXCH_A; +#endif + s->init_num = 0; + break; + + case SSL3_ST_SW_KEY_EXCH_A: + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * clear this, it may get reset by + * send_server_key_exchange + */ + s->s3->tmp.use_rsa_tmp = 0; + + /* + * only send if a DH key exchange, fortezza or RSA but we have a + * sign only certificate PSK: may send PSK identity hints For + * ECC ciphersuites, we send a serverKeyExchange message only if + * the cipher suite is either ECDH-anon or ECDHE. In other cases, + * the server certificate contains the server's public key for + * key exchange. + */ + if (0 + /* + * PSK: send ServerKeyExchange if PSK identity hint if + * provided + */ +#ifndef OPENSSL_NO_PSK + || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + || (alg_k & SSL_kEDH) + || (alg_k & SSL_kEECDH) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys + [SSL_PKEY_RSA_ENC].privatekey) * + 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + ) { + ret = ssl3_send_server_key_exchange(s); + if (ret <= 0) + goto end; + } else + skip = 1; + + s->state = SSL3_ST_SW_CERT_REQ_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_REQ_A: + case SSL3_ST_SW_CERT_REQ_B: + if ( /* don't request cert unless asked for it: */ + !(s->verify_mode & SSL_VERIFY_PEER) || + /* + * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert + * during re-negotiation: + */ + ((s->session->peer != NULL) && + (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || + /* + * never request cert in anonymous ciphersuites (see + * section ""Certificate request"" in SSL 3 drafts and in + * RFC 2246): + */ + ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + /* + * ... except when the application insists on + * verification (against the specs, but s3_clnt.c accepts + * this for SSL 3) + */ + !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || + /* + * never request cert in Kerberos ciphersuites + */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* + * With normal PSK Certificates and Certificate Requests + * are omitted + */ + || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + /* no cert request */ + skip = 1; + s->s3->tmp.cert_request = 0; + s->state = SSL3_ST_SW_SRVR_DONE_A; + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + } else { + s->s3->tmp.cert_request = 1; + ret = ssl3_send_certificate_request(s); + if (ret <= 0) + goto end; +#ifndef NETSCAPE_HANG_BUG + s->state = SSL3_ST_SW_SRVR_DONE_A; +#else + s->state = SSL3_ST_SW_FLUSH; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; +#endif + s->init_num = 0; + } + break; + + case SSL3_ST_SW_SRVR_DONE_A: + case SSL3_ST_SW_SRVR_DONE_B: + ret = ssl3_send_server_done(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + break; + + case SSL3_ST_SW_FLUSH: + + /* + * This code originally checked to see if any data was pending + * using BIO_CTRL_INFO and then flushed. This caused problems as + * documented in PR#1939. The proposed fix doesn't completely + * resolve this issue as buggy implementations of + * BIO_CTRL_PENDING still exist. So instead we just flush + * unconditionally. + */ + + s->rwstate = SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) { + ret = -1; + goto end; + } + s->rwstate = SSL_NOTHING; + + s->state = s->s3->tmp.next_state; + break; + + case SSL3_ST_SR_CERT_A: + case SSL3_ST_SR_CERT_B: + if (s->s3->tmp.cert_request) { + ret = ssl3_get_client_certificate(s); + if (ret <= 0) + goto end; + } + s->init_num = 0; + s->state = SSL3_ST_SR_KEY_EXCH_A; + break; + + case SSL3_ST_SR_KEY_EXCH_A: + case SSL3_ST_SR_KEY_EXCH_B: + ret = ssl3_get_client_key_exchange(s); + if (ret <= 0) + goto end; + if (ret == 2) { + /* + * For the ECDH ciphersuites when the client sends its ECDH + * pub key in a certificate, the CertificateVerify message is + * not sent. Also for GOST ciphersuites when the client uses + * its key from the certificate for key exchange. + */ +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + } else if (SSL_USE_SIGALGS(s)) { + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + if (!s->session->peer) + break; + /* + * For sigalgs freeze the handshake buffer at this point and + * digest cached records. + */ + if (!s->s3->handshake_buffer) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } else { + int offset = 0; + int dgst_num; + + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + + /* + * We need to get hashes here so if there is a client cert, + * it can be verified FIXME - digest processing for + * CertificateVerify should be generalized. But it is next + * step + */ + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) + if (s->s3->handshake_dgst[dgst_num]) { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s, + EVP_MD_CTX_type + (s-> + s3->handshake_dgst + [dgst_num]), + &(s->s3-> + tmp.cert_verify_md + [offset])); + dgst_size = + EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) { + s->state = SSL_ST_ERR; + ret = -1; + goto end; + } + offset += dgst_size; + } + } + break; + + case SSL3_ST_SR_CERT_VRFY_A: + case SSL3_ST_SR_CERT_VRFY_B: + ret = ssl3_get_cert_verify(s); + if (ret <= 0) + goto end; + +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + break; + +#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + case SSL3_ST_SR_NEXT_PROTO_A: + case SSL3_ST_SR_NEXT_PROTO_B: + /* + * Enable CCS for NPN. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. This *should* be the + * first time we have received one - but we check anyway to be + * cautious. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + + ret = ssl3_get_next_proto(s); + if (ret <= 0) + goto end; + s->init_num = 0; + s->state = SSL3_ST_SR_FINISHED_A; + break; +#endif + + case SSL3_ST_SR_FINISHED_A: + case SSL3_ST_SR_FINISHED_B: + /* + * Enable CCS for handshakes without NPN. In NPN the CCS flag has + * already been set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B); + if (ret <= 0) + goto end; + if (s->hit) + s->state = SSL_ST_OK; +#ifndef OPENSSL_NO_TLSEXT + else if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; +#endif + else + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + +#ifndef OPENSSL_NO_TLSEXT + case SSL3_ST_SW_SESSION_TICKET_A: + case SSL3_ST_SW_SESSION_TICKET_B: + ret = ssl3_send_newsession_ticket(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_STATUS_A: + case SSL3_ST_SW_CERT_STATUS_B: + ret = ssl3_send_cert_status(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_KEY_EXCH_A; + s->init_num = 0; + break; + +#endif + + case SSL3_ST_SW_CHANGE_A: + case SSL3_ST_SW_CHANGE_B: + + s->session->cipher = s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ret = ssl3_send_change_cipher_spec(s, + SSL3_ST_SW_CHANGE_A, + SSL3_ST_SW_CHANGE_B); + + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FINISHED_A; + s->init_num = 0; + + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) + { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + break; + + case SSL3_ST_SW_FINISHED_A: + case SSL3_ST_SW_FINISHED_B: + ret = ssl3_send_finished(s, + SSL3_ST_SW_FINISHED_A, + SSL3_ST_SW_FINISHED_B, + s->method-> + ssl3_enc->server_finished_label, + s->method-> + ssl3_enc->server_finished_label_len); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FLUSH; + if (s->hit) { +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) { + s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A; + } else + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#endif + } else + s->s3->tmp.next_state = SSL_ST_OK; + s->init_num = 0; + break; + + case SSL_ST_OK: + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + BUF_MEM_free(s->init_buf); + s->init_buf = NULL; + + /* remove buffering on output */ + ssl_free_wbio_buffer(s); + + s->init_num = 0; + + if (s->renegotiate == 2) { /* skipped if we just sent a + * HelloRequest */ + s->renegotiate = 0; + s->new_session = 0; + + ssl_update_cache(s, SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + /* s->server=1; */ + s->handshake_func = ssl3_accept; + + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_DONE, 1); + } + + ret = 1; + goto end; + /* break; */ + + case SSL_ST_ERR: + default: + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); + ret = -1; + goto end; + /* break; */ + } + + if (!s->s3->tmp.reuse_message && !skip) { + if (s->debug) { + if ((ret = BIO_flush(s->wbio)) <= 0) + goto end; + } + + if ((cb != NULL) && (s->state != state)) { + new_state = s->state; + s->state = state; + cb(s, SSL_CB_ACCEPT_LOOP, 1); + s->state = new_state; + } + } + skip = 0; + } +",0,"int ssl3_accept(SSL *s) +{ + BUF_MEM *buf; + unsigned long alg_k, Time = (unsigned long)time(NULL); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + int ret = -1; + int new_state, state, skip = 0; + + RAND_add(&Time, sizeof(Time), 0); + ERR_clear_error(); + clear_sys_error(); + + if (s->info_callback != NULL) + cb = s->info_callback; + else if (s->ctx->info_callback != NULL) + cb = s->ctx->info_callback; + + /* init things to blank */ + s->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) + SSL_clear(s); + + if (s->cert == NULL) { + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); + return (-1); + } +#ifndef OPENSSL_NO_HEARTBEATS + /* + * If we're awaiting a HeartbeatResponse, pretend we already got and + * don't await it anymore, because Heartbeats don't make sense during + * handshakes anyway. + */ + if (s->tlsext_hb_pending) { + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + for (;;) { + state = s->state; + + switch (s->state) { + case SSL_ST_RENEGOTIATE: + s->renegotiate = 1; + /* s->state=SSL_ST_ACCEPT; */ + + case SSL_ST_BEFORE: + case SSL_ST_ACCEPT: + case SSL_ST_BEFORE | SSL_ST_ACCEPT: + case SSL_ST_OK | SSL_ST_ACCEPT: + + s->server = 1; + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_START, 1); + + if ((s->version >> 8) != 3) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->type = SSL_ST_ACCEPT; + + if (s->init_buf == NULL) { + if ((buf = BUF_MEM_new()) == NULL) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { + BUF_MEM_free(buf); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + s->init_buf = buf; + } + + if (!ssl3_setup_buffers(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + s->init_num = 0; + s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + /* + * Should have been reset by ssl3_get_finished, too. + */ + s->s3->change_cipher_spec = 0; + + if (s->state != SSL_ST_RENEGOTIATE) { + /* + * Ok, we now need to push on a buffering BIO so that the + * output is sent in a way that TCP likes :-) + */ + if (!ssl_init_wbio_buffer(s, 1)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ssl3_init_finished_mac(s); + s->state = SSL3_ST_SR_CLNT_HELLO_A; + s->ctx->stats.sess_accept++; + } else if (!s->s3->send_connection_binding && + !(s->options & + SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + /* + * Server attempting to renegotiate with client that doesn't + * support secure renegotiation. + */ + SSLerr(SSL_F_SSL3_ACCEPT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } else { + /* + * s->state == SSL_ST_RENEGOTIATE, we will just send a + * HelloRequest + */ + s->ctx->stats.sess_accept_renegotiate++; + s->state = SSL3_ST_SW_HELLO_REQ_A; + } + break; + + case SSL3_ST_SW_HELLO_REQ_A: + case SSL3_ST_SW_HELLO_REQ_B: + + s->shutdown = 0; + ret = ssl3_send_hello_request(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + + ssl3_init_finished_mac(s); + break; + + case SSL3_ST_SW_HELLO_REQ_C: + s->state = SSL_ST_OK; + break; + + case SSL3_ST_SR_CLNT_HELLO_A: + case SSL3_ST_SR_CLNT_HELLO_B: + case SSL3_ST_SR_CLNT_HELLO_C: + + s->shutdown = 0; + ret = ssl3_get_client_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_SRP + s->state = SSL3_ST_SR_CLNT_HELLO_D; + case SSL3_ST_SR_CLNT_HELLO_D: + { + int al; + if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { + /* + * callback indicates firther work to be done + */ + s->rwstate = SSL_X509_LOOKUP; + goto end; + } + if (ret != SSL_ERROR_NONE) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + /* + * This is not really an error but the only means to for + * a client to detect whether srp is supported. + */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + } +#endif + + s->renegotiate = 2; + s->state = SSL3_ST_SW_SRVR_HELLO_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_SRVR_HELLO_A: + case SSL3_ST_SW_SRVR_HELLO_B: + ret = ssl3_send_server_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->hit) { + if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; + else + s->state = SSL3_ST_SW_CHANGE_A; + } +#else + if (s->hit) + s->state = SSL3_ST_SW_CHANGE_A; +#endif + else + s->state = SSL3_ST_SW_CERT_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_A: + case SSL3_ST_SW_CERT_B: + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or KRB5 or SRP */ + if (! + (s->s3->tmp. + new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 | + SSL_aSRP)) +&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + ret = ssl3_send_server_certificate(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->tlsext_status_expected) + s->state = SSL3_ST_SW_CERT_STATUS_A; + else + s->state = SSL3_ST_SW_KEY_EXCH_A; + } else { + skip = 1; + s->state = SSL3_ST_SW_KEY_EXCH_A; + } +#else + } else + skip = 1; + + s->state = SSL3_ST_SW_KEY_EXCH_A; +#endif + s->init_num = 0; + break; + + case SSL3_ST_SW_KEY_EXCH_A: + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * clear this, it may get reset by + * send_server_key_exchange + */ + s->s3->tmp.use_rsa_tmp = 0; + + /* + * only send if a DH key exchange, fortezza or RSA but we have a + * sign only certificate PSK: may send PSK identity hints For + * ECC ciphersuites, we send a serverKeyExchange message only if + * the cipher suite is either ECDH-anon or ECDHE. In other cases, + * the server certificate contains the server's public key for + * key exchange. + */ + if (0 + /* + * PSK: send ServerKeyExchange if PSK identity hint if + * provided + */ +#ifndef OPENSSL_NO_PSK + || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + || (alg_k & SSL_kEDH) + || (alg_k & SSL_kEECDH) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys + [SSL_PKEY_RSA_ENC].privatekey) * + 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + ) { + ret = ssl3_send_server_key_exchange(s); + if (ret <= 0) + goto end; + } else + skip = 1; + + s->state = SSL3_ST_SW_CERT_REQ_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_REQ_A: + case SSL3_ST_SW_CERT_REQ_B: + if ( /* don't request cert unless asked for it: */ + !(s->verify_mode & SSL_VERIFY_PEER) || + /* + * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert + * during re-negotiation: + */ + ((s->session->peer != NULL) && + (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || + /* + * never request cert in anonymous ciphersuites (see + * section ""Certificate request"" in SSL 3 drafts and in + * RFC 2246): + */ + ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + /* + * ... except when the application insists on + * verification (against the specs, but s3_clnt.c accepts + * this for SSL 3) + */ + !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || + /* + * never request cert in Kerberos ciphersuites + */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* + * With normal PSK Certificates and Certificate Requests + * are omitted + */ + || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + /* no cert request */ + skip = 1; + s->s3->tmp.cert_request = 0; + s->state = SSL3_ST_SW_SRVR_DONE_A; + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + } else { + s->s3->tmp.cert_request = 1; + ret = ssl3_send_certificate_request(s); + if (ret <= 0) + goto end; +#ifndef NETSCAPE_HANG_BUG + s->state = SSL3_ST_SW_SRVR_DONE_A; +#else + s->state = SSL3_ST_SW_FLUSH; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; +#endif + s->init_num = 0; + } + break; + + case SSL3_ST_SW_SRVR_DONE_A: + case SSL3_ST_SW_SRVR_DONE_B: + ret = ssl3_send_server_done(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + break; + + case SSL3_ST_SW_FLUSH: + + /* + * This code originally checked to see if any data was pending + * using BIO_CTRL_INFO and then flushed. This caused problems as + * documented in PR#1939. The proposed fix doesn't completely + * resolve this issue as buggy implementations of + * BIO_CTRL_PENDING still exist. So instead we just flush + * unconditionally. + */ + + s->rwstate = SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) { + ret = -1; + goto end; + } + s->rwstate = SSL_NOTHING; + + s->state = s->s3->tmp.next_state; + break; + + case SSL3_ST_SR_CERT_A: + case SSL3_ST_SR_CERT_B: + if (s->s3->tmp.cert_request) { + ret = ssl3_get_client_certificate(s); + if (ret <= 0) + goto end; + } + s->init_num = 0; + s->state = SSL3_ST_SR_KEY_EXCH_A; + break; + + case SSL3_ST_SR_KEY_EXCH_A: + case SSL3_ST_SR_KEY_EXCH_B: + ret = ssl3_get_client_key_exchange(s); + if (ret <= 0) + goto end; + if (ret == 2) { + /* + * For the ECDH ciphersuites when the client sends its ECDH + * pub key in a certificate, the CertificateVerify message is + * not sent. Also for GOST ciphersuites when the client uses + * its key from the certificate for key exchange. + */ +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + } else if (SSL_USE_SIGALGS(s)) { + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + if (!s->session->peer) + break; + /* + * For sigalgs freeze the handshake buffer at this point and + * digest cached records. + */ + if (!s->s3->handshake_buffer) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } else { + int offset = 0; + int dgst_num; + + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + + /* + * We need to get hashes here so if there is a client cert, + * it can be verified FIXME - digest processing for + * CertificateVerify should be generalized. But it is next + * step + */ + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) + if (s->s3->handshake_dgst[dgst_num]) { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s, + EVP_MD_CTX_type + (s-> + s3->handshake_dgst + [dgst_num]), + &(s->s3-> + tmp.cert_verify_md + [offset])); + dgst_size = + EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) { + s->state = SSL_ST_ERR; + ret = -1; + goto end; + } + offset += dgst_size; + } + } + break; + + case SSL3_ST_SR_CERT_VRFY_A: + case SSL3_ST_SR_CERT_VRFY_B: + ret = ssl3_get_cert_verify(s); + if (ret <= 0) + goto end; + +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + break; + +#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + case SSL3_ST_SR_NEXT_PROTO_A: + case SSL3_ST_SR_NEXT_PROTO_B: + /* + * Enable CCS for NPN. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. This *should* be the + * first time we have received one - but we check anyway to be + * cautious. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + + ret = ssl3_get_next_proto(s); + if (ret <= 0) + goto end; + s->init_num = 0; + s->state = SSL3_ST_SR_FINISHED_A; + break; +#endif + + case SSL3_ST_SR_FINISHED_A: + case SSL3_ST_SR_FINISHED_B: + /* + * Enable CCS for handshakes without NPN. In NPN the CCS flag has + * already been set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B); + if (ret <= 0) + goto end; + if (s->hit) + s->state = SSL_ST_OK; +#ifndef OPENSSL_NO_TLSEXT + else if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; +#endif + else + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + +#ifndef OPENSSL_NO_TLSEXT + case SSL3_ST_SW_SESSION_TICKET_A: + case SSL3_ST_SW_SESSION_TICKET_B: + ret = ssl3_send_newsession_ticket(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_STATUS_A: + case SSL3_ST_SW_CERT_STATUS_B: + ret = ssl3_send_cert_status(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_KEY_EXCH_A; + s->init_num = 0; + break; + +#endif + + case SSL3_ST_SW_CHANGE_A: + case SSL3_ST_SW_CHANGE_B: + + s->session->cipher = s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ret = ssl3_send_change_cipher_spec(s, + SSL3_ST_SW_CHANGE_A, + SSL3_ST_SW_CHANGE_B); + + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FINISHED_A; + s->init_num = 0; + + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) + { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + break; + + case SSL3_ST_SW_FINISHED_A: + case SSL3_ST_SW_FINISHED_B: + ret = ssl3_send_finished(s, + SSL3_ST_SW_FINISHED_A, + SSL3_ST_SW_FINISHED_B, + s->method-> + ssl3_enc->server_finished_label, + s->method-> + ssl3_enc->server_finished_label_len); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FLUSH; + if (s->hit) { +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) { + s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A; + } else + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#endif + } else + s->s3->tmp.next_state = SSL_ST_OK; + s->init_num = 0; + break; + + case SSL_ST_OK: + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + BUF_MEM_free(s->init_buf); + s->init_buf = NULL; + + /* remove buffering on output */ + ssl_free_wbio_buffer(s); + + s->init_num = 0; + + if (s->renegotiate == 2) { /* skipped if we just sent a + * HelloRequest */ + s->renegotiate = 0; + s->new_session = 0; + + ssl_update_cache(s, SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + /* s->server=1; */ + s->handshake_func = ssl3_accept; + + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_DONE, 1); + } + + ret = 1; + goto end; + /* break; */ + + case SSL_ST_ERR: + default: + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); + ret = -1; + goto end; + /* break; */ + } + + if (!s->s3->tmp.reuse_message && !skip) { + if (s->debug) { + if ((ret = BIO_flush(s->wbio)) <= 0) + goto end; + } + + if ((cb != NULL) && (s->state != state)) { + new_state = s->state; + s->state = state; + cb(s, SSL_CB_ACCEPT_LOOP, 1); + s->state = new_state; + } + } + skip = 0; + } +","@@ -2780,7 +2780,7 @@ int ssl3_get_client_key_exchange(SSL *s) + + if (s->session->psk_identity != NULL) + OPENSSL_free(s->session->psk_identity); +- s->session->psk_identity = BUF_strdup((char *)p); ++ s->session->psk_identity = BUF_strndup((char *)p, i); + if (s->session->psk_identity == NULL) { + SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto psk_err; +",5295,5531,6144 +9020,"static int megasas_init_fw(struct megasas_instance *instance) +{ + u32 max_sectors_1; + u32 max_sectors_2, tmp_sectors, msix_enable; + u32 scratch_pad_1, scratch_pad_2, scratch_pad_3, status_reg; + resource_size_t base_addr; + struct megasas_ctrl_info *ctrl_info = NULL; + unsigned long bar_list; + int i, j, loop, fw_msix_count = 0; + struct IOV_111 *iovPtr; + struct fusion_context *fusion; + bool do_adp_reset = true; + + fusion = instance->ctrl_context; + + /* Find first memory bar */ + bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); + instance->bar = find_first_bit(&bar_list, BITS_PER_LONG); + if (pci_request_selected_regions(instance->pdev, 1<bar, + ""megasas: LSI"")) { + dev_printk(KERN_DEBUG, &instance->pdev->dev, ""IO memory region busy!\n""); + return -EBUSY; + } + + base_addr = pci_resource_start(instance->pdev, instance->bar); + instance->reg_set = ioremap_nocache(base_addr, 8192); + + if (!instance->reg_set) { + dev_printk(KERN_DEBUG, &instance->pdev->dev, ""Failed to map IO mem\n""); + goto fail_ioremap; + } + + if (instance->adapter_type != MFI_SERIES) + instance->instancet = &megasas_instance_template_fusion; + else { + switch (instance->pdev->device) { + case PCI_DEVICE_ID_LSI_SAS1078R: + case PCI_DEVICE_ID_LSI_SAS1078DE: + instance->instancet = &megasas_instance_template_ppc; + break; + case PCI_DEVICE_ID_LSI_SAS1078GEN2: + case PCI_DEVICE_ID_LSI_SAS0079GEN2: + instance->instancet = &megasas_instance_template_gen2; + break; + case PCI_DEVICE_ID_LSI_SAS0073SKINNY: + case PCI_DEVICE_ID_LSI_SAS0071SKINNY: + instance->instancet = &megasas_instance_template_skinny; + break; + case PCI_DEVICE_ID_LSI_SAS1064R: + case PCI_DEVICE_ID_DELL_PERC5: + default: + instance->instancet = &megasas_instance_template_xscale; + instance->pd_list_not_supported = 1; + break; + } + } + + if (megasas_transition_to_ready(instance, 0)) { + if (instance->adapter_type >= INVADER_SERIES) { + status_reg = instance->instancet->read_fw_status_reg( + instance); + do_adp_reset = status_reg & MFI_RESET_ADAPTER; + } + + if (do_adp_reset) { + atomic_set(&instance->fw_reset_no_pci_access, 1); + instance->instancet->adp_reset + (instance, instance->reg_set); + atomic_set(&instance->fw_reset_no_pci_access, 0); + dev_info(&instance->pdev->dev, + ""FW restarted successfully from %s!\n"", + __func__); + + /*waiting for about 30 second before retry*/ + ssleep(30); + + if (megasas_transition_to_ready(instance, 0)) + goto fail_ready_state; + } else { + goto fail_ready_state; + } + } + + megasas_init_ctrl_params(instance); + + if (megasas_set_dma_mask(instance)) + goto fail_ready_state; + + if (megasas_alloc_ctrl_mem(instance)) + goto fail_alloc_dma_buf; + + if (megasas_alloc_ctrl_dma_buffers(instance)) + goto fail_alloc_dma_buf; + + fusion = instance->ctrl_context; + + if (instance->adapter_type >= VENTURA_SERIES) { + scratch_pad_2 = + megasas_readl(instance, + &instance->reg_set->outbound_scratch_pad_2); + instance->max_raid_mapsize = ((scratch_pad_2 >> + MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT) & + MR_MAX_RAID_MAP_SIZE_MASK); + } + + /* Check if MSI-X is supported while in ready state */ + msix_enable = (instance->instancet->read_fw_status_reg(instance) & + 0x4000000) >> 0x1a; + if (msix_enable && !msix_disable) { + int irq_flags = PCI_IRQ_MSIX; + + scratch_pad_1 = megasas_readl + (instance, &instance->reg_set->outbound_scratch_pad_1); + /* Check max MSI-X vectors */ + if (fusion) { + if (instance->adapter_type == THUNDERBOLT_SERIES) { + /* Thunderbolt Series*/ + instance->msix_vectors = (scratch_pad_1 + & MR_MAX_REPLY_QUEUES_OFFSET) + 1; + fw_msix_count = instance->msix_vectors; + } else { + instance->msix_vectors = ((scratch_pad_1 + & MR_MAX_REPLY_QUEUES_EXT_OFFSET) + >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1; + + /* + * For Invader series, > 8 MSI-x vectors + * supported by FW/HW implies combined + * reply queue mode is enabled. + * For Ventura series, > 16 MSI-x vectors + * supported by FW/HW implies combined + * reply queue mode is enabled. + */ + switch (instance->adapter_type) { + case INVADER_SERIES: + if (instance->msix_vectors > 8) + instance->msix_combined = true; + break; + case AERO_SERIES: + case VENTURA_SERIES: + if (instance->msix_vectors > 16) + instance->msix_combined = true; + break; + } + + if (rdpq_enable) + instance->is_rdpq = (scratch_pad_1 & MR_RDPQ_MODE_OFFSET) ? + 1 : 0; + fw_msix_count = instance->msix_vectors; + /* Save 1-15 reply post index address to local memory + * Index 0 is already saved from reg offset + * MPI2_REPLY_POST_HOST_INDEX_OFFSET + */ + for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) { + instance->reply_post_host_index_addr[loop] = + (u32 __iomem *) + ((u8 __iomem *)instance->reg_set + + MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET + + (loop * 0x10)); + } + } + if (msix_vectors) + instance->msix_vectors = min(msix_vectors, + instance->msix_vectors); + } else /* MFI adapters */ + instance->msix_vectors = 1; + /* Don't bother allocating more MSI-X vectors than cpus */ + instance->msix_vectors = min(instance->msix_vectors, + (unsigned int)num_online_cpus()); + if (smp_affinity_enable) + irq_flags |= PCI_IRQ_AFFINITY; + i = pci_alloc_irq_vectors(instance->pdev, 1, + instance->msix_vectors, irq_flags); + if (i > 0) + instance->msix_vectors = i; + else + instance->msix_vectors = 0; + } + /* + * MSI-X host index 0 is common for all adapter. + * It is used for all MPT based Adapters. + */ + if (instance->msix_combined) { + instance->reply_post_host_index_addr[0] = + (u32 *)((u8 *)instance->reg_set + + MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET); + } else { + instance->reply_post_host_index_addr[0] = + (u32 *)((u8 *)instance->reg_set + + MPI2_REPLY_POST_HOST_INDEX_OFFSET); + } + + if (!instance->msix_vectors) { + i = pci_alloc_irq_vectors(instance->pdev, 1, 1, PCI_IRQ_LEGACY); + if (i < 0) + goto fail_init_adapter; + } + + megasas_setup_reply_map(instance); + + dev_info(&instance->pdev->dev, + ""firmware supports msix\t: (%d)"", fw_msix_count); + dev_info(&instance->pdev->dev, + ""current msix/online cpus\t: (%d/%d)\n"", + instance->msix_vectors, (unsigned int)num_online_cpus()); + dev_info(&instance->pdev->dev, + ""RDPQ mode\t: (%s)\n"", instance->is_rdpq ? ""enabled"" : ""disabled""); + + tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, + (unsigned long)instance); + + /* + * Below are default value for legacy Firmware. + * non-fusion based controllers + */ + instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; + instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; + /* Get operational params, sge flags, send init cmd to controller */ + if (instance->instancet->init_adapter(instance)) + goto fail_init_adapter; + + if (instance->adapter_type >= VENTURA_SERIES) { + scratch_pad_3 = + megasas_readl(instance, + &instance->reg_set->outbound_scratch_pad_3); + if ((scratch_pad_3 & MR_NVME_PAGE_SIZE_MASK) >= + MR_DEFAULT_NVME_PAGE_SHIFT) + instance->nvme_page_size = + (1 << (scratch_pad_3 & MR_NVME_PAGE_SIZE_MASK)); + + dev_info(&instance->pdev->dev, + ""NVME page size\t: (%d)\n"", instance->nvme_page_size); + } + + if (instance->msix_vectors ? + megasas_setup_irqs_msix(instance, 1) : + megasas_setup_irqs_ioapic(instance)) + goto fail_init_adapter; + + instance->instancet->enable_intr(instance); + + dev_info(&instance->pdev->dev, ""INIT adapter done\n""); + + megasas_setup_jbod_map(instance); + + if (megasas_get_device_list(instance) != SUCCESS) { + dev_err(&instance->pdev->dev, + ""%s: megasas_get_device_list failed\n"", + __func__); + goto fail_get_ld_pd_list; + } + + /* stream detection initialization */ + if (instance->adapter_type >= VENTURA_SERIES) { + fusion->stream_detect_by_ld = + kcalloc(MAX_LOGICAL_DRIVES_EXT, + sizeof(struct LD_STREAM_DETECT *), + GFP_KERNEL); + if (!fusion->stream_detect_by_ld) { + dev_err(&instance->pdev->dev, + ""unable to allocate stream detection for pool of LDs\n""); + goto fail_get_ld_pd_list; + } + for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) { + fusion->stream_detect_by_ld[i] = + kzalloc(sizeof(struct LD_STREAM_DETECT), + GFP_KERNEL); + if (!fusion->stream_detect_by_ld[i]) { + dev_err(&instance->pdev->dev, + ""unable to allocate stream detect by LD\n ""); + for (j = 0; j < i; ++j) + kfree(fusion->stream_detect_by_ld[j]); + kfree(fusion->stream_detect_by_ld); + fusion->stream_detect_by_ld = NULL; + goto fail_get_ld_pd_list; + } + fusion->stream_detect_by_ld[i]->mru_bit_map + = MR_STREAM_BITMAP; + } + } + + /* + * Compute the max allowed sectors per IO: The controller info has two + * limits on max sectors. Driver should use the minimum of these two. + * + * 1 << stripe_sz_ops.min = max sectors per strip + * + * Note that older firmwares ( < FW ver 30) didn't report information + * to calculate max_sectors_1. So the number ended up as zero always. + */ + tmp_sectors = 0; + ctrl_info = instance->ctrl_info_buf; + + max_sectors_1 = (1 << ctrl_info->stripe_sz_ops.min) * + le16_to_cpu(ctrl_info->max_strips_per_io); + max_sectors_2 = le32_to_cpu(ctrl_info->max_request_size); + + tmp_sectors = min_t(u32, max_sectors_1, max_sectors_2); + + instance->peerIsPresent = ctrl_info->cluster.peerIsPresent; + instance->passive = ctrl_info->cluster.passive; + memcpy(instance->clusterId, ctrl_info->clusterId, sizeof(instance->clusterId)); + instance->UnevenSpanSupport = + ctrl_info->adapterOperations2.supportUnevenSpans; + if (instance->UnevenSpanSupport) { + struct fusion_context *fusion = instance->ctrl_context; + if (MR_ValidateMapInfo(instance, instance->map_id)) + fusion->fast_path_io = 1; + else + fusion->fast_path_io = 0; + + } + if (ctrl_info->host_interface.SRIOV) { + instance->requestorId = ctrl_info->iov.requestorId; + if (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) { + if (!ctrl_info->adapterOperations2.activePassive) + instance->PlasmaFW111 = 1; + + dev_info(&instance->pdev->dev, ""SR-IOV: firmware type: %s\n"", + instance->PlasmaFW111 ? ""1.11"" : ""new""); + + if (instance->PlasmaFW111) { + iovPtr = (struct IOV_111 *) + ((unsigned char *)ctrl_info + IOV_111_OFFSET); + instance->requestorId = iovPtr->requestorId; + } + } + dev_info(&instance->pdev->dev, ""SRIOV: VF requestorId %d\n"", + instance->requestorId); + } + + instance->crash_dump_fw_support = + ctrl_info->adapterOperations3.supportCrashDump; + instance->crash_dump_drv_support = + (instance->crash_dump_fw_support && + instance->crash_dump_buf); + if (instance->crash_dump_drv_support) + megasas_set_crash_dump_params(instance, + MR_CRASH_BUF_TURN_OFF); + + else { + if (instance->crash_dump_buf) + dma_free_coherent(&instance->pdev->dev, + CRASH_DMA_BUF_SIZE, + instance->crash_dump_buf, + instance->crash_dump_h); + instance->crash_dump_buf = NULL; + } + + if (instance->snapdump_wait_time) { + megasas_get_snapdump_properties(instance); + dev_info(&instance->pdev->dev, ""Snap dump wait time\t: %d\n"", + instance->snapdump_wait_time); + } + + dev_info(&instance->pdev->dev, + ""pci id\t\t: (0x%04x)/(0x%04x)/(0x%04x)/(0x%04x)\n"", + le16_to_cpu(ctrl_info->pci.vendor_id), + le16_to_cpu(ctrl_info->pci.device_id), + le16_to_cpu(ctrl_info->pci.sub_vendor_id), + le16_to_cpu(ctrl_info->pci.sub_device_id)); + dev_info(&instance->pdev->dev, ""unevenspan support : %s\n"", + instance->UnevenSpanSupport ? ""yes"" : ""no""); + dev_info(&instance->pdev->dev, ""firmware crash dump : %s\n"", + instance->crash_dump_drv_support ? ""yes"" : ""no""); + dev_info(&instance->pdev->dev, ""jbod sync map : %s\n"", + instance->use_seqnum_jbod_fp ? ""yes"" : ""no""); + + instance->max_sectors_per_req = instance->max_num_sge * + SGE_BUFFER_SIZE / 512; + if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) + instance->max_sectors_per_req = tmp_sectors; + + /* Check for valid throttlequeuedepth module parameter */ + if (throttlequeuedepth && + throttlequeuedepth <= instance->max_scsi_cmds) + instance->throttlequeuedepth = throttlequeuedepth; + else + instance->throttlequeuedepth = + MEGASAS_THROTTLE_QUEUE_DEPTH; + + if ((resetwaittime < 1) || + (resetwaittime > MEGASAS_RESET_WAIT_TIME)) + resetwaittime = MEGASAS_RESET_WAIT_TIME; + + if ((scmd_timeout < 10) || (scmd_timeout > MEGASAS_DEFAULT_CMD_TIMEOUT)) + scmd_timeout = MEGASAS_DEFAULT_CMD_TIMEOUT; + + /* Launch SR-IOV heartbeat timer */ + if (instance->requestorId) { + if (!megasas_sriov_start_heartbeat(instance, 1)) { + megasas_start_timer(instance); + } else { + instance->skip_heartbeat_timer_del = 1; + goto fail_get_ld_pd_list; + } + } + + /* + * Create and start watchdog thread which will monitor + * controller state every 1 sec and trigger OCR when + * it enters fault state + */ + if (instance->adapter_type != MFI_SERIES) + if (megasas_fusion_start_watchdog(instance) != SUCCESS) + goto fail_start_watchdog; + + return 0; + +fail_start_watchdog: + if (instance->requestorId && !instance->skip_heartbeat_timer_del) + del_timer_sync(&instance->sriov_heartbeat_timer); +fail_get_ld_pd_list: + instance->instancet->disable_intr(instance); + megasas_destroy_irqs(instance); +fail_init_adapter: + if (instance->msix_vectors) + pci_free_irq_vectors(instance->pdev); + instance->msix_vectors = 0; +fail_alloc_dma_buf: + megasas_free_ctrl_dma_buffers(instance); + megasas_free_ctrl_mem(instance); +fail_ready_state: + iounmap(instance->reg_set); + +fail_ioremap: + pci_release_selected_regions(instance->pdev, 1<bar); + + dev_err(&instance->pdev->dev, ""Failed from %s %d\n"", + __func__, __LINE__); + return -EINVAL; +} +",0,"static int megasas_init_fw(struct megasas_instance *instance) +{ + u32 max_sectors_1; + u32 max_sectors_2, tmp_sectors, msix_enable; + u32 scratch_pad_1, scratch_pad_2, scratch_pad_3, status_reg; + resource_size_t base_addr; + struct megasas_ctrl_info *ctrl_info = NULL; + unsigned long bar_list; + int i, j, loop, fw_msix_count = 0; + struct IOV_111 *iovPtr; + struct fusion_context *fusion; + bool do_adp_reset = true; + + fusion = instance->ctrl_context; + + /* Find first memory bar */ + bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); + instance->bar = find_first_bit(&bar_list, BITS_PER_LONG); + if (pci_request_selected_regions(instance->pdev, 1<bar, + ""megasas: LSI"")) { + dev_printk(KERN_DEBUG, &instance->pdev->dev, ""IO memory region busy!\n""); + return -EBUSY; + } + + base_addr = pci_resource_start(instance->pdev, instance->bar); + instance->reg_set = ioremap_nocache(base_addr, 8192); + + if (!instance->reg_set) { + dev_printk(KERN_DEBUG, &instance->pdev->dev, ""Failed to map IO mem\n""); + goto fail_ioremap; + } + + if (instance->adapter_type != MFI_SERIES) + instance->instancet = &megasas_instance_template_fusion; + else { + switch (instance->pdev->device) { + case PCI_DEVICE_ID_LSI_SAS1078R: + case PCI_DEVICE_ID_LSI_SAS1078DE: + instance->instancet = &megasas_instance_template_ppc; + break; + case PCI_DEVICE_ID_LSI_SAS1078GEN2: + case PCI_DEVICE_ID_LSI_SAS0079GEN2: + instance->instancet = &megasas_instance_template_gen2; + break; + case PCI_DEVICE_ID_LSI_SAS0073SKINNY: + case PCI_DEVICE_ID_LSI_SAS0071SKINNY: + instance->instancet = &megasas_instance_template_skinny; + break; + case PCI_DEVICE_ID_LSI_SAS1064R: + case PCI_DEVICE_ID_DELL_PERC5: + default: + instance->instancet = &megasas_instance_template_xscale; + instance->pd_list_not_supported = 1; + break; + } + } + + if (megasas_transition_to_ready(instance, 0)) { + if (instance->adapter_type >= INVADER_SERIES) { + status_reg = instance->instancet->read_fw_status_reg( + instance); + do_adp_reset = status_reg & MFI_RESET_ADAPTER; + } + + if (do_adp_reset) { + atomic_set(&instance->fw_reset_no_pci_access, 1); + instance->instancet->adp_reset + (instance, instance->reg_set); + atomic_set(&instance->fw_reset_no_pci_access, 0); + dev_info(&instance->pdev->dev, + ""FW restarted successfully from %s!\n"", + __func__); + + /*waiting for about 30 second before retry*/ + ssleep(30); + + if (megasas_transition_to_ready(instance, 0)) + goto fail_ready_state; + } else { + goto fail_ready_state; + } + } + + megasas_init_ctrl_params(instance); + + if (megasas_set_dma_mask(instance)) + goto fail_ready_state; + + if (megasas_alloc_ctrl_mem(instance)) + goto fail_alloc_dma_buf; + + if (megasas_alloc_ctrl_dma_buffers(instance)) + goto fail_alloc_dma_buf; + + fusion = instance->ctrl_context; + + if (instance->adapter_type >= VENTURA_SERIES) { + scratch_pad_2 = + megasas_readl(instance, + &instance->reg_set->outbound_scratch_pad_2); + instance->max_raid_mapsize = ((scratch_pad_2 >> + MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT) & + MR_MAX_RAID_MAP_SIZE_MASK); + } + + /* Check if MSI-X is supported while in ready state */ + msix_enable = (instance->instancet->read_fw_status_reg(instance) & + 0x4000000) >> 0x1a; + if (msix_enable && !msix_disable) { + int irq_flags = PCI_IRQ_MSIX; + + scratch_pad_1 = megasas_readl + (instance, &instance->reg_set->outbound_scratch_pad_1); + /* Check max MSI-X vectors */ + if (fusion) { + if (instance->adapter_type == THUNDERBOLT_SERIES) { + /* Thunderbolt Series*/ + instance->msix_vectors = (scratch_pad_1 + & MR_MAX_REPLY_QUEUES_OFFSET) + 1; + fw_msix_count = instance->msix_vectors; + } else { + instance->msix_vectors = ((scratch_pad_1 + & MR_MAX_REPLY_QUEUES_EXT_OFFSET) + >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1; + + /* + * For Invader series, > 8 MSI-x vectors + * supported by FW/HW implies combined + * reply queue mode is enabled. + * For Ventura series, > 16 MSI-x vectors + * supported by FW/HW implies combined + * reply queue mode is enabled. + */ + switch (instance->adapter_type) { + case INVADER_SERIES: + if (instance->msix_vectors > 8) + instance->msix_combined = true; + break; + case AERO_SERIES: + case VENTURA_SERIES: + if (instance->msix_vectors > 16) + instance->msix_combined = true; + break; + } + + if (rdpq_enable) + instance->is_rdpq = (scratch_pad_1 & MR_RDPQ_MODE_OFFSET) ? + 1 : 0; + fw_msix_count = instance->msix_vectors; + /* Save 1-15 reply post index address to local memory + * Index 0 is already saved from reg offset + * MPI2_REPLY_POST_HOST_INDEX_OFFSET + */ + for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) { + instance->reply_post_host_index_addr[loop] = + (u32 __iomem *) + ((u8 __iomem *)instance->reg_set + + MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET + + (loop * 0x10)); + } + } + if (msix_vectors) + instance->msix_vectors = min(msix_vectors, + instance->msix_vectors); + } else /* MFI adapters */ + instance->msix_vectors = 1; + /* Don't bother allocating more MSI-X vectors than cpus */ + instance->msix_vectors = min(instance->msix_vectors, + (unsigned int)num_online_cpus()); + if (smp_affinity_enable) + irq_flags |= PCI_IRQ_AFFINITY; + i = pci_alloc_irq_vectors(instance->pdev, 1, + instance->msix_vectors, irq_flags); + if (i > 0) + instance->msix_vectors = i; + else + instance->msix_vectors = 0; + } + /* + * MSI-X host index 0 is common for all adapter. + * It is used for all MPT based Adapters. + */ + if (instance->msix_combined) { + instance->reply_post_host_index_addr[0] = + (u32 *)((u8 *)instance->reg_set + + MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET); + } else { + instance->reply_post_host_index_addr[0] = + (u32 *)((u8 *)instance->reg_set + + MPI2_REPLY_POST_HOST_INDEX_OFFSET); + } + + if (!instance->msix_vectors) { + i = pci_alloc_irq_vectors(instance->pdev, 1, 1, PCI_IRQ_LEGACY); + if (i < 0) + goto fail_init_adapter; + } + + megasas_setup_reply_map(instance); + + dev_info(&instance->pdev->dev, + ""firmware supports msix\t: (%d)"", fw_msix_count); + dev_info(&instance->pdev->dev, + ""current msix/online cpus\t: (%d/%d)\n"", + instance->msix_vectors, (unsigned int)num_online_cpus()); + dev_info(&instance->pdev->dev, + ""RDPQ mode\t: (%s)\n"", instance->is_rdpq ? ""enabled"" : ""disabled""); + + tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, + (unsigned long)instance); + + /* + * Below are default value for legacy Firmware. + * non-fusion based controllers + */ + instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; + instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; + /* Get operational params, sge flags, send init cmd to controller */ + if (instance->instancet->init_adapter(instance)) + goto fail_init_adapter; + + if (instance->adapter_type >= VENTURA_SERIES) { + scratch_pad_3 = + megasas_readl(instance, + &instance->reg_set->outbound_scratch_pad_3); + if ((scratch_pad_3 & MR_NVME_PAGE_SIZE_MASK) >= + MR_DEFAULT_NVME_PAGE_SHIFT) + instance->nvme_page_size = + (1 << (scratch_pad_3 & MR_NVME_PAGE_SIZE_MASK)); + + dev_info(&instance->pdev->dev, + ""NVME page size\t: (%d)\n"", instance->nvme_page_size); + } + + if (instance->msix_vectors ? + megasas_setup_irqs_msix(instance, 1) : + megasas_setup_irqs_ioapic(instance)) + goto fail_init_adapter; + + instance->instancet->enable_intr(instance); + + dev_info(&instance->pdev->dev, ""INIT adapter done\n""); + + megasas_setup_jbod_map(instance); + + if (megasas_get_device_list(instance) != SUCCESS) { + dev_err(&instance->pdev->dev, + ""%s: megasas_get_device_list failed\n"", + __func__); + goto fail_get_ld_pd_list; + } + + /* stream detection initialization */ + if (instance->adapter_type >= VENTURA_SERIES) { + fusion->stream_detect_by_ld = + kcalloc(MAX_LOGICAL_DRIVES_EXT, + sizeof(struct LD_STREAM_DETECT *), + GFP_KERNEL); + if (!fusion->stream_detect_by_ld) { + dev_err(&instance->pdev->dev, + ""unable to allocate stream detection for pool of LDs\n""); + goto fail_get_ld_pd_list; + } + for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) { + fusion->stream_detect_by_ld[i] = + kzalloc(sizeof(struct LD_STREAM_DETECT), + GFP_KERNEL); + if (!fusion->stream_detect_by_ld[i]) { + dev_err(&instance->pdev->dev, + ""unable to allocate stream detect by LD\n ""); + for (j = 0; j < i; ++j) + kfree(fusion->stream_detect_by_ld[j]); + kfree(fusion->stream_detect_by_ld); + fusion->stream_detect_by_ld = NULL; + goto fail_get_ld_pd_list; + } + fusion->stream_detect_by_ld[i]->mru_bit_map + = MR_STREAM_BITMAP; + } + } + + /* + * Compute the max allowed sectors per IO: The controller info has two + * limits on max sectors. Driver should use the minimum of these two. + * + * 1 << stripe_sz_ops.min = max sectors per strip + * + * Note that older firmwares ( < FW ver 30) didn't report information + * to calculate max_sectors_1. So the number ended up as zero always. + */ + tmp_sectors = 0; + ctrl_info = instance->ctrl_info_buf; + + max_sectors_1 = (1 << ctrl_info->stripe_sz_ops.min) * + le16_to_cpu(ctrl_info->max_strips_per_io); + max_sectors_2 = le32_to_cpu(ctrl_info->max_request_size); + + tmp_sectors = min_t(u32, max_sectors_1, max_sectors_2); + + instance->peerIsPresent = ctrl_info->cluster.peerIsPresent; + instance->passive = ctrl_info->cluster.passive; + memcpy(instance->clusterId, ctrl_info->clusterId, sizeof(instance->clusterId)); + instance->UnevenSpanSupport = + ctrl_info->adapterOperations2.supportUnevenSpans; + if (instance->UnevenSpanSupport) { + struct fusion_context *fusion = instance->ctrl_context; + if (MR_ValidateMapInfo(instance, instance->map_id)) + fusion->fast_path_io = 1; + else + fusion->fast_path_io = 0; + + } + if (ctrl_info->host_interface.SRIOV) { + instance->requestorId = ctrl_info->iov.requestorId; + if (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) { + if (!ctrl_info->adapterOperations2.activePassive) + instance->PlasmaFW111 = 1; + + dev_info(&instance->pdev->dev, ""SR-IOV: firmware type: %s\n"", + instance->PlasmaFW111 ? ""1.11"" : ""new""); + + if (instance->PlasmaFW111) { + iovPtr = (struct IOV_111 *) + ((unsigned char *)ctrl_info + IOV_111_OFFSET); + instance->requestorId = iovPtr->requestorId; + } + } + dev_info(&instance->pdev->dev, ""SRIOV: VF requestorId %d\n"", + instance->requestorId); + } + + instance->crash_dump_fw_support = + ctrl_info->adapterOperations3.supportCrashDump; + instance->crash_dump_drv_support = + (instance->crash_dump_fw_support && + instance->crash_dump_buf); + if (instance->crash_dump_drv_support) + megasas_set_crash_dump_params(instance, + MR_CRASH_BUF_TURN_OFF); + + else { + if (instance->crash_dump_buf) + dma_free_coherent(&instance->pdev->dev, + CRASH_DMA_BUF_SIZE, + instance->crash_dump_buf, + instance->crash_dump_h); + instance->crash_dump_buf = NULL; + } + + if (instance->snapdump_wait_time) { + megasas_get_snapdump_properties(instance); + dev_info(&instance->pdev->dev, ""Snap dump wait time\t: %d\n"", + instance->snapdump_wait_time); + } + + dev_info(&instance->pdev->dev, + ""pci id\t\t: (0x%04x)/(0x%04x)/(0x%04x)/(0x%04x)\n"", + le16_to_cpu(ctrl_info->pci.vendor_id), + le16_to_cpu(ctrl_info->pci.device_id), + le16_to_cpu(ctrl_info->pci.sub_vendor_id), + le16_to_cpu(ctrl_info->pci.sub_device_id)); + dev_info(&instance->pdev->dev, ""unevenspan support : %s\n"", + instance->UnevenSpanSupport ? ""yes"" : ""no""); + dev_info(&instance->pdev->dev, ""firmware crash dump : %s\n"", + instance->crash_dump_drv_support ? ""yes"" : ""no""); + dev_info(&instance->pdev->dev, ""jbod sync map : %s\n"", + instance->use_seqnum_jbod_fp ? ""yes"" : ""no""); + + instance->max_sectors_per_req = instance->max_num_sge * + SGE_BUFFER_SIZE / 512; + if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) + instance->max_sectors_per_req = tmp_sectors; + + /* Check for valid throttlequeuedepth module parameter */ + if (throttlequeuedepth && + throttlequeuedepth <= instance->max_scsi_cmds) + instance->throttlequeuedepth = throttlequeuedepth; + else + instance->throttlequeuedepth = + MEGASAS_THROTTLE_QUEUE_DEPTH; + + if ((resetwaittime < 1) || + (resetwaittime > MEGASAS_RESET_WAIT_TIME)) + resetwaittime = MEGASAS_RESET_WAIT_TIME; + + if ((scmd_timeout < 10) || (scmd_timeout > MEGASAS_DEFAULT_CMD_TIMEOUT)) + scmd_timeout = MEGASAS_DEFAULT_CMD_TIMEOUT; + + /* Launch SR-IOV heartbeat timer */ + if (instance->requestorId) { + if (!megasas_sriov_start_heartbeat(instance, 1)) { + megasas_start_timer(instance); + } else { + instance->skip_heartbeat_timer_del = 1; + goto fail_get_ld_pd_list; + } + } + + /* + * Create and start watchdog thread which will monitor + * controller state every 1 sec and trigger OCR when + * it enters fault state + */ + if (instance->adapter_type != MFI_SERIES) + if (megasas_fusion_start_watchdog(instance) != SUCCESS) + goto fail_start_watchdog; + + return 0; + +fail_start_watchdog: + if (instance->requestorId && !instance->skip_heartbeat_timer_del) + del_timer_sync(&instance->sriov_heartbeat_timer); +fail_get_ld_pd_list: + instance->instancet->disable_intr(instance); + megasas_destroy_irqs(instance); +fail_init_adapter: + if (instance->msix_vectors) + pci_free_irq_vectors(instance->pdev); + instance->msix_vectors = 0; +fail_alloc_dma_buf: + megasas_free_ctrl_dma_buffers(instance); + megasas_free_ctrl_mem(instance); +fail_ready_state: + iounmap(instance->reg_set); + +fail_ioremap: + pci_release_selected_regions(instance->pdev, 1<bar); + + dev_err(&instance->pdev->dev, ""Failed from %s %d\n"", + __func__, __LINE__); + return -EINVAL; +} +","@@ -4188,6 +4188,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance) + if (megasas_create_frame_pool(instance)) { + dev_printk(KERN_DEBUG, &instance->pdev->dev, ""Error creating frame DMA pool\n""); + megasas_free_cmds(instance); ++ return -ENOMEM; + } + + return 0;",3982,4218,6144 +18110,"static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + Image *image) +{ +#define MaxCount 128 +#define PictCropRegionOp 0x01 +#define PictEndOfPictureOp 0xff +#define PictJPEGOp 0x8200 +#define PictInfoOp 0x0C00 +#define PictInfoSize 512 +#define PictPixmapOp 0x9A +#define PictPICTOp 0x98 +#define PictVersion 0x11 + + const StringInfo + *profile; + + double + x_resolution, + y_resolution; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + PICTPixmap + pixmap; + + PICTRectangle + bounds, + crop_rectangle, + destination_rectangle, + frame_rectangle, + size_rectangle, + source_rectangle; + + register const IndexPacket + *indexes; + + register const PixelPacket + *p; + + register ssize_t + i, + x; + + size_t + bytes_per_line, + count, + row_bytes, + storage_class; + + ssize_t + y; + + unsigned char + *buffer, + *packed_scanline, + *scanline; + + + unsigned short + base_address, + transfer_mode; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if ((image->columns > 65535L) || (image->rows > 65535L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) + (void) TransformImageColorspace(image,sRGBColorspace); + /* + Initialize image info. + */ + size_rectangle.top=0; + size_rectangle.left=0; + size_rectangle.bottom=(short) image->rows; + size_rectangle.right=(short) image->columns; + frame_rectangle=size_rectangle; + crop_rectangle=size_rectangle; + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; + row_bytes=image->columns; + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; + bounds.right=(short) image->columns; + pixmap.version=0; + pixmap.pack_type=0; + pixmap.pack_size=0; + pixmap.pixel_type=0; + pixmap.bits_per_pixel=8; + pixmap.component_count=1; + pixmap.component_size=8; + pixmap.plane_bytes=0; + pixmap.table=0; + pixmap.reserved=0; + transfer_mode=0; + x_resolution=image->x_resolution != 0.0 ? image->x_resolution : + DefaultResolution; + y_resolution=image->y_resolution != 0.0 ? image->y_resolution : + DefaultResolution; + storage_class=image->storage_class; + if (image_info->compression == JPEGCompression) + storage_class=DirectClass; + if (storage_class == DirectClass) + { + pixmap.component_count=image->matte != MagickFalse ? 4 : 3; + pixmap.pixel_type=16; + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; + row_bytes=4*image->columns; + } + /* + Allocate memory. + */ + bytes_per_line=image->columns; + if (storage_class == DirectClass) + bytes_per_line*=image->matte != MagickFalse ? 4 : 3; + buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer)); + packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t) + (row_bytes+MaxCount),sizeof(*packed_scanline)); + scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline)); + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) ResetMagickMemory(scanline,0,row_bytes); + (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /* + Write header, header size, size bounding box, version, and reserved. + */ + (void) ResetMagickMemory(buffer,0,PictInfoSize); + (void) WriteBlob(image,PictInfoSize,buffer); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right); + (void) WriteBlobMSBShort(image,PictVersion); + (void) WriteBlobMSBShort(image,0x02ff); /* version #2 */ + (void) WriteBlobMSBShort(image,PictInfoOp); + (void) WriteBlobMSBLong(image,0xFFFE0000UL); + /* + Write full size of the file, resolution, frame bounding box, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right); + (void) WriteBlobMSBLong(image,0x00000000L); + profile=GetImageProfile(image,""iptc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0x1f2); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobString(image,""8BIM""); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + } + profile=GetImageProfile(image,""icc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,4); + (void) WriteBlobMSBLong(image,0x00000002UL); + } + /* + Write crop region opcode and crop bounding box. + */ + (void) WriteBlobMSBShort(image,PictCropRegionOp); + (void) WriteBlobMSBShort(image,0xa); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right); + if (image_info->compression == JPEGCompression) + { + Image + *jpeg_image; + + ImageInfo + *jpeg_info; + + size_t + length; + + unsigned char + *blob; + + jpeg_image=CloneImage(image,0,0,MagickTrue,&image->exception); + if (jpeg_image == (Image *) NULL) + { + (void) CloseBlob(image); + return(MagickFalse); + } + jpeg_info=CloneImageInfo(image_info); + (void) CopyMagickString(jpeg_info->magick,""JPEG"",MaxTextExtent); + length=0; + blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length, + &image->exception); + jpeg_info=DestroyImageInfo(jpeg_info); + if (blob == (unsigned char *) NULL) + return(MagickFalse); + jpeg_image=DestroyImage(jpeg_image); + (void) WriteBlobMSBShort(image,PictJPEGOp); + (void) WriteBlobMSBLong(image,(unsigned int) length+154); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x40000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00400000UL); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00566A70UL); + (void) WriteBlobMSBLong(image,0x65670000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000001UL); + (void) WriteBlobMSBLong(image,0x00016170UL); + (void) WriteBlobMSBLong(image,0x706C0000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x87AC0001UL); + (void) WriteBlobMSBLong(image,0x0B466F74UL); + (void) WriteBlobMSBLong(image,0x6F202D20UL); + (void) WriteBlobMSBLong(image,0x4A504547UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x0018FFFFUL); + (void) WriteBlob(image,length,blob); + if ((length & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + blob=(unsigned char *) RelinquishMagickMemory(blob); + } + /* + Write picture opcode, row bytes, and picture bounding box, and version. + */ + if (storage_class == PseudoClass) + (void) WriteBlobMSBShort(image,PictPICTOp); + else + { + (void) WriteBlobMSBShort(image,PictPixmapOp); + (void) WriteBlobMSBLong(image,(size_t) base_address); + } + (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000)); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.top); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.left); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.right); + /* + Write pack type, pack size, resolution, pixel type, and pixel size. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size); + (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel); + /* + Write component count, size, plane bytes, table size, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved); + if (storage_class == PseudoClass) + { + /* + Write image colormap. + */ + (void) WriteBlobMSBLong(image,0x00000000L); /* color seed */ + (void) WriteBlobMSBShort(image,0L); /* color flags */ + (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1)); + for (i=0; i < (ssize_t) image->colors; i++) + { + (void) WriteBlobMSBShort(image,(unsigned short) i); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].red)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].green)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].blue)); + } + } + /* + Write source and destination rectangle. + */ + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode); + /* + Write picture data. + */ + count=0; + if (storage_class == PseudoClass) + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(image); + for (x=0; x < (ssize_t) image->columns; x++) + scanline[x]=(unsigned char) GetPixelIndex(indexes+x); + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image_info->compression == JPEGCompression) + { + (void) ResetMagickMemory(scanline,0,row_bytes); + for (y=0; y < (ssize_t) image->rows; y++) + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + } + else + { + register unsigned char + *blue, + *green, + *opacity, + *red; + + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + opacity=scanline+3*image->columns; + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); + if (p == (const PixelPacket *) NULL) + break; + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + if (image->matte != MagickFalse) + { + opacity=scanline; + red=scanline+image->columns; + green=scanline+2*image->columns; + blue=scanline+3*image->columns; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + *red++=ScaleQuantumToChar(GetPixelRed(p)); + *green++=ScaleQuantumToChar(GetPixelGreen(p)); + *blue++=ScaleQuantumToChar(GetPixelBlue(p)); + if (image->matte != MagickFalse) + *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(p))); + p++; + } + count+=EncodeImage(image,scanline,bytes_per_line,packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if ((count & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + (void) WriteBlobMSBShort(image,PictEndOfPictureOp); + offset=TellBlob(image); + offset=SeekBlob(image,512,SEEK_SET); + (void) WriteBlobMSBShort(image,(unsigned short) offset); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + (void) CloseBlob(image); + return(MagickTrue); +} +",1,"static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + Image *image) +{ +#define MaxCount 128 +#define PictCropRegionOp 0x01 +#define PictEndOfPictureOp 0xff +#define PictJPEGOp 0x8200 +#define PictInfoOp 0x0C00 +#define PictInfoSize 512 +#define PictPixmapOp 0x9A +#define PictPICTOp 0x98 +#define PictVersion 0x11 + + const StringInfo + *profile; + + double + x_resolution, + y_resolution; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + PICTPixmap + pixmap; + + PICTRectangle + bounds, + crop_rectangle, + destination_rectangle, + frame_rectangle, + size_rectangle, + source_rectangle; + + register const IndexPacket + *indexes; + + register const PixelPacket + *p; + + register ssize_t + i, + x; + + size_t + bytes_per_line, + count, + row_bytes, + storage_class; + + ssize_t + y; + + unsigned char + *buffer, + *packed_scanline, + *scanline; + + + unsigned short + base_address, + transfer_mode; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if ((image->columns > 65535L) || (image->rows > 65535L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) + (void) TransformImageColorspace(image,sRGBColorspace); + /* + Initialize image info. + */ + size_rectangle.top=0; + size_rectangle.left=0; + size_rectangle.bottom=(short) image->rows; + size_rectangle.right=(short) image->columns; + frame_rectangle=size_rectangle; + crop_rectangle=size_rectangle; + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; + row_bytes=image->columns; + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; + bounds.right=(short) image->columns; + pixmap.version=0; + pixmap.pack_type=0; + pixmap.pack_size=0; + pixmap.pixel_type=0; + pixmap.bits_per_pixel=8; + pixmap.component_count=1; + pixmap.component_size=8; + pixmap.plane_bytes=0; + pixmap.table=0; + pixmap.reserved=0; + transfer_mode=0; + x_resolution=image->x_resolution != 0.0 ? image->x_resolution : + DefaultResolution; + y_resolution=image->y_resolution != 0.0 ? image->y_resolution : + DefaultResolution; + storage_class=image->storage_class; + if (image_info->compression == JPEGCompression) + storage_class=DirectClass; + if (storage_class == DirectClass) + { + pixmap.component_count=image->matte != MagickFalse ? 4 : 3; + pixmap.pixel_type=16; + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; + row_bytes=4*image->columns; + } + /* + Allocate memory. + */ + bytes_per_line=image->columns; + if (storage_class == DirectClass) + bytes_per_line*=image->matte != MagickFalse ? 4 : 3; + buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer)); + packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t) + (row_bytes+MaxCount),sizeof(*packed_scanline)); + scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline)); + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) + { + if (scanline != (unsigned char *) NULL) + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + if (packed_scanline != (unsigned char *) NULL) + packed_scanline=(unsigned char *) RelinquishMagickMemory( + packed_scanline); + if (buffer != (unsigned char *) NULL) + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) ResetMagickMemory(scanline,0,row_bytes); + (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /* + Write header, header size, size bounding box, version, and reserved. + */ + (void) ResetMagickMemory(buffer,0,PictInfoSize); + (void) WriteBlob(image,PictInfoSize,buffer); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right); + (void) WriteBlobMSBShort(image,PictVersion); + (void) WriteBlobMSBShort(image,0x02ff); /* version #2 */ + (void) WriteBlobMSBShort(image,PictInfoOp); + (void) WriteBlobMSBLong(image,0xFFFE0000UL); + /* + Write full size of the file, resolution, frame bounding box, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right); + (void) WriteBlobMSBLong(image,0x00000000L); + profile=GetImageProfile(image,""iptc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0x1f2); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobString(image,""8BIM""); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + } + profile=GetImageProfile(image,""icc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,4); + (void) WriteBlobMSBLong(image,0x00000002UL); + } + /* + Write crop region opcode and crop bounding box. + */ + (void) WriteBlobMSBShort(image,PictCropRegionOp); + (void) WriteBlobMSBShort(image,0xa); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right); + if (image_info->compression == JPEGCompression) + { + Image + *jpeg_image; + + ImageInfo + *jpeg_info; + + size_t + length; + + unsigned char + *blob; + + jpeg_image=CloneImage(image,0,0,MagickTrue,&image->exception); + if (jpeg_image == (Image *) NULL) + { + (void) CloseBlob(image); + return(MagickFalse); + } + jpeg_info=CloneImageInfo(image_info); + (void) CopyMagickString(jpeg_info->magick,""JPEG"",MaxTextExtent); + length=0; + blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length, + &image->exception); + jpeg_info=DestroyImageInfo(jpeg_info); + if (blob == (unsigned char *) NULL) + return(MagickFalse); + jpeg_image=DestroyImage(jpeg_image); + (void) WriteBlobMSBShort(image,PictJPEGOp); + (void) WriteBlobMSBLong(image,(unsigned int) length+154); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x40000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00400000UL); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00566A70UL); + (void) WriteBlobMSBLong(image,0x65670000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000001UL); + (void) WriteBlobMSBLong(image,0x00016170UL); + (void) WriteBlobMSBLong(image,0x706C0000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x87AC0001UL); + (void) WriteBlobMSBLong(image,0x0B466F74UL); + (void) WriteBlobMSBLong(image,0x6F202D20UL); + (void) WriteBlobMSBLong(image,0x4A504547UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x0018FFFFUL); + (void) WriteBlob(image,length,blob); + if ((length & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + blob=(unsigned char *) RelinquishMagickMemory(blob); + } + /* + Write picture opcode, row bytes, and picture bounding box, and version. + */ + if (storage_class == PseudoClass) + (void) WriteBlobMSBShort(image,PictPICTOp); + else + { + (void) WriteBlobMSBShort(image,PictPixmapOp); + (void) WriteBlobMSBLong(image,(size_t) base_address); + } + (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000)); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.top); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.left); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.right); + /* + Write pack type, pack size, resolution, pixel type, and pixel size. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size); + (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel); + /* + Write component count, size, plane bytes, table size, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved); + if (storage_class == PseudoClass) + { + /* + Write image colormap. + */ + (void) WriteBlobMSBLong(image,0x00000000L); /* color seed */ + (void) WriteBlobMSBShort(image,0L); /* color flags */ + (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1)); + for (i=0; i < (ssize_t) image->colors; i++) + { + (void) WriteBlobMSBShort(image,(unsigned short) i); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].red)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].green)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].blue)); + } + } + /* + Write source and destination rectangle. + */ + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode); + /* + Write picture data. + */ + count=0; + if (storage_class == PseudoClass) + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); + if (p == (const PixelPacket *) NULL) + break; + indexes=GetVirtualIndexQueue(image); + for (x=0; x < (ssize_t) image->columns; x++) + scanline[x]=(unsigned char) GetPixelIndex(indexes+x); + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image_info->compression == JPEGCompression) + { + (void) ResetMagickMemory(scanline,0,row_bytes); + for (y=0; y < (ssize_t) image->rows; y++) + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + } + else + { + register unsigned char + *blue, + *green, + *opacity, + *red; + + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + opacity=scanline+3*image->columns; + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); + if (p == (const PixelPacket *) NULL) + break; + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + if (image->matte != MagickFalse) + { + opacity=scanline; + red=scanline+image->columns; + green=scanline+2*image->columns; + blue=scanline+3*image->columns; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + *red++=ScaleQuantumToChar(GetPixelRed(p)); + *green++=ScaleQuantumToChar(GetPixelGreen(p)); + *blue++=ScaleQuantumToChar(GetPixelBlue(p)); + if (image->matte != MagickFalse) + *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(p))); + p++; + } + count+=EncodeImage(image,scanline,bytes_per_line,packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if ((count & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + (void) WriteBlobMSBShort(image,PictEndOfPictureOp); + offset=TellBlob(image); + offset=SeekBlob(image,512,SEEK_SET); + (void) WriteBlobMSBShort(image,(unsigned short) offset); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + (void) CloseBlob(image); + return(MagickTrue); +} +","@@ -1758,7 +1758,16 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) +- ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); ++ { ++ if (scanline != (unsigned char *) NULL) ++ scanline=(unsigned char *) RelinquishMagickMemory(scanline); ++ if (packed_scanline != (unsigned char *) NULL) ++ packed_scanline=(unsigned char *) RelinquishMagickMemory( ++ packed_scanline); ++ if (buffer != (unsigned char *) NULL) ++ buffer=(unsigned char *) RelinquishMagickMemory(buffer); ++ ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); ++ } + (void) ResetMagickMemory(scanline,0,row_bytes); + (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /*",4737,4973,6144 +18123,"static Image *ReadOneJNGImage(MngInfo *mng_info, + const ImageInfo *image_info, ExceptionInfo *exception) +{ + Image + *alpha_image, + *color_image, + *image, + *jng_image; + + ImageInfo + *alpha_image_info, + *color_image_info; + + MagickBooleanType + logging; + + int + unique_filenames; + + ssize_t + y; + + MagickBooleanType + status; + + png_uint_32 + jng_height, + jng_width; + + png_byte + jng_color_type, + jng_image_sample_depth, + jng_image_compression_method, + jng_image_interlace_method, + jng_alpha_sample_depth, + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method; + + register const PixelPacket + *s; + + register ssize_t + i, + x; + + register PixelPacket + *q; + + register unsigned char + *p; + + unsigned int + read_JSEP, + reading_idat; + + size_t + length; + + jng_alpha_compression_method=0; + jng_alpha_sample_depth=8; + jng_color_type=0; + jng_height=0; + jng_width=0; + alpha_image=(Image *) NULL; + color_image=(Image *) NULL; + alpha_image_info=(ImageInfo *) NULL; + color_image_info=(ImageInfo *) NULL; + unique_filenames=0; + + logging=LogMagickEvent(CoderEvent,GetMagickModule(), + "" Enter ReadOneJNGImage()""); + + image=mng_info->image; + + if (GetAuthenticPixelQueue(image) != (PixelPacket *) NULL) + { + /* + Allocate next image structure. + */ + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" AcquireNextImage()""); + + AcquireNextImage(image_info,image); + + if (GetNextImageInList(image) == (Image *) NULL) + return(DestroyImageList(image)); + + image=SyncNextImageInList(image); + } + mng_info->image=image; + + /* + Signature bytes have already been read. + */ + + read_JSEP=MagickFalse; + reading_idat=MagickFalse; + for (;;) + { + char + type[MaxTextExtent]; + + unsigned char + *chunk; + + unsigned int + count; + + /* + Read a new JNG chunk. + */ + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + break; + + type[0]='\0'; + (void) ConcatenateMagickString(type,""errr"",MaxTextExtent); + length=ReadBlobMSBLong(image); + count=(unsigned int) ReadBlob(image,4,(unsigned char *) type); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading JNG chunk type %c%c%c%c, length: %.20g"", + type[0],type[1],type[2],type[3],(double) length); + + if (length > PNG_UINT_31_MAX || count == 0) + ThrowReaderException(CorruptImageError,""CorruptImage""); + + p=NULL; + chunk=(unsigned char *) NULL; + + if (length != 0) + { + chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); + + if (chunk == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + for (i=0; i < (ssize_t) length; i++) + chunk[i]=(unsigned char) ReadBlobByte(image); + + p=chunk; + } + + (void) ReadBlobMSBLong(image); /* read crc word */ + + if (memcmp(type,mng_JHDR,4) == 0) + { + if (length == 16) + { + jng_width=(size_t) ((p[0] << 24) | (p[1] << 16) | + (p[2] << 8) | p[3]); + jng_height=(size_t) ((p[4] << 24) | (p[5] << 16) | + (p[6] << 8) | p[7]); + if ((jng_width == 0) || (jng_height == 0)) + ThrowReaderException(CorruptImageError,""NegativeOrZeroImageSize""); + jng_color_type=p[8]; + jng_image_sample_depth=p[9]; + jng_image_compression_method=p[10]; + jng_image_interlace_method=p[11]; + + image->interlace=jng_image_interlace_method != 0 ? PNGInterlace : + NoInterlace; + + jng_alpha_sample_depth=p[12]; + jng_alpha_compression_method=p[13]; + jng_alpha_filter_method=p[14]; + jng_alpha_interlace_method=p[15]; + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_width: %16lu, jng_height: %16lu\n"" + "" jng_color_type: %16d, jng_image_sample_depth: %3d\n"" + "" jng_image_compression_method:%3d"", + (unsigned long) jng_width, (unsigned long) jng_height, + jng_color_type, jng_image_sample_depth, + jng_image_compression_method); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_image_interlace_method: %3d"" + "" jng_alpha_sample_depth: %3d"", + jng_image_interlace_method, + jng_alpha_sample_depth); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_alpha_compression_method:%3d\n"" + "" jng_alpha_filter_method: %3d\n"" + "" jng_alpha_interlace_method: %3d"", + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method); + } + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + + if ((reading_idat == MagickFalse) && (read_JSEP == MagickFalse) && + ((memcmp(type,mng_JDAT,4) == 0) || (memcmp(type,mng_JdAA,4) == 0) || + (memcmp(type,mng_IDAT,4) == 0) || (memcmp(type,mng_JDAA,4) == 0))) + { + /* + o create color_image + o open color_blob, attached to color_image + o if (color type has alpha) + open alpha_blob, attached to alpha_image + */ + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating color_blob.""); + + color_image_info=(ImageInfo *)AcquireMagickMemory(sizeof(ImageInfo)); + + if (color_image_info == (ImageInfo *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + GetImageInfo(color_image_info); + color_image=AcquireImage(color_image_info); + + if (color_image == (Image *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + (void) AcquireUniqueFilename(color_image->filename); + unique_filenames++; + status=OpenBlob(color_image_info,color_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + color_image=DestroyImage(color_image); + return(DestroyImageList(image)); + } + + if ((image_info->ping == MagickFalse) && (jng_color_type >= 12)) + { + alpha_image_info=(ImageInfo *) + AcquireMagickMemory(sizeof(ImageInfo)); + + if (alpha_image_info == (ImageInfo *) NULL) + { + color_image=DestroyImage(color_image); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + GetImageInfo(alpha_image_info); + alpha_image=AcquireImage(alpha_image_info); + + if (alpha_image == (Image *) NULL) + { + alpha_image_info=DestroyImageInfo(alpha_image_info); + color_image=DestroyImage(color_image); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating alpha_blob.""); + + (void) AcquireUniqueFilename(alpha_image->filename); + unique_filenames++; + status=OpenBlob(alpha_image_info,alpha_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + alpha_image=DestroyImage(alpha_image); + alpha_image_info=DestroyImageInfo(alpha_image_info); + color_image=DestroyImage(color_image); + return(DestroyImageList(image)); + } + + if (jng_alpha_compression_method == 0) + { + unsigned char + data[18]; + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing IHDR chunk to alpha_blob.""); + + (void) WriteBlob(alpha_image,8,(const unsigned char *) + ""\211PNG\r\n\032\n""); + + (void) WriteBlobMSBULong(alpha_image,13L); + PNGType(data,mng_IHDR); + LogPNGChunk(logging,mng_IHDR,13L); + PNGLong(data+4,jng_width); + PNGLong(data+8,jng_height); + data[12]=jng_alpha_sample_depth; + data[13]=0; /* color_type gray */ + data[14]=0; /* compression method 0 */ + data[15]=0; /* filter_method 0 */ + data[16]=0; /* interlace_method 0 */ + (void) WriteBlob(alpha_image,17,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,17)); + } + } + reading_idat=MagickTrue; + } + + if (memcmp(type,mng_JDAT,4) == 0) + { + /* Copy chunk to color_image->blob */ + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + + (void) WriteBlob(color_image,length,chunk); + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_IDAT,4) == 0) + { + png_byte + data[5]; + + /* Copy IDAT header and chunk data to alpha_image->blob */ + + if (alpha_image != NULL && image_info->ping == MagickFalse) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying IDAT chunk data to alpha_blob.""); + + (void) WriteBlobMSBULong(alpha_image,(size_t) length); + PNGType(data,mng_IDAT); + LogPNGChunk(logging,mng_IDAT,length); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlob(alpha_image,length,chunk); + (void) WriteBlobMSBULong(alpha_image, + crc32(crc32(0,data,4),chunk,(uInt) length)); + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if ((memcmp(type,mng_JDAA,4) == 0) || (memcmp(type,mng_JdAA,4) == 0)) + { + /* Copy chunk data to alpha_image->blob */ + + if (alpha_image != NULL && image_info->ping == MagickFalse) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAA chunk data to alpha_blob.""); + + (void) WriteBlob(alpha_image,length,chunk); + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_JSEP,4) == 0) + { + read_JSEP=MagickTrue; + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_bKGD,4) == 0) + { + if (length == 2) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=image->background_color.red; + image->background_color.blue=image->background_color.red; + } + + if (length == 6) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=ScaleCharToQuantum(p[3]); + image->background_color.blue=ScaleCharToQuantum(p[5]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_gAMA,4) == 0) + { + if (length == 4) + image->gamma=((float) mng_get_long(p))*0.00001; + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_cHRM,4) == 0) + { + if (length == 32) + { + image->chromaticity.white_point.x=0.00001*mng_get_long(p); + image->chromaticity.white_point.y=0.00001*mng_get_long(&p[4]); + image->chromaticity.red_primary.x=0.00001*mng_get_long(&p[8]); + image->chromaticity.red_primary.y=0.00001*mng_get_long(&p[12]); + image->chromaticity.green_primary.x=0.00001*mng_get_long(&p[16]); + image->chromaticity.green_primary.y=0.00001*mng_get_long(&p[20]); + image->chromaticity.blue_primary.x=0.00001*mng_get_long(&p[24]); + image->chromaticity.blue_primary.y=0.00001*mng_get_long(&p[28]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_sRGB,4) == 0) + { + if (length == 1) + { + image->rendering_intent= + Magick_RenderingIntent_from_PNG_RenderingIntent(p[0]); + image->gamma=1.000f/2.200f; + image->chromaticity.red_primary.x=0.6400f; + image->chromaticity.red_primary.y=0.3300f; + image->chromaticity.green_primary.x=0.3000f; + image->chromaticity.green_primary.y=0.6000f; + image->chromaticity.blue_primary.x=0.1500f; + image->chromaticity.blue_primary.y=0.0600f; + image->chromaticity.white_point.x=0.3127f; + image->chromaticity.white_point.y=0.3290f; + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_oFFs,4) == 0) + { + if (length > 8) + { + image->page.x=(ssize_t) mng_get_long(p); + image->page.y=(ssize_t) mng_get_long(&p[4]); + + if ((int) p[8] != 0) + { + image->page.x/=10000; + image->page.y/=10000; + } + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_pHYs,4) == 0) + { + if (length > 8) + { + image->x_resolution=(double) mng_get_long(p); + image->y_resolution=(double) mng_get_long(&p[4]); + if ((int) p[8] == PNG_RESOLUTION_METER) + { + image->units=PixelsPerCentimeterResolution; + image->x_resolution=image->x_resolution/100.0f; + image->y_resolution=image->y_resolution/100.0f; + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + +#if 0 + if (memcmp(type,mng_iCCP,4) == 0) + { + /* To do: */ + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } +#endif + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + if (memcmp(type,mng_IEND,4)) + continue; + + break; + } + + + /* IEND found */ + + /* + Finish up reading image data: + + o read main image from color_blob. + + o close color_blob. + + o if (color_type has alpha) + if alpha_encoding is PNG + read secondary image from alpha_blob via ReadPNG + if alpha_encoding is JPEG + read secondary image from alpha_blob via ReadJPEG + + o close alpha_blob. + + o copy intensity of secondary image into + opacity samples of main image. + + o destroy the secondary image. + */ + + if (color_image_info == (ImageInfo *) NULL) + { + assert(color_image == (Image *) NULL); + assert(alpha_image == (Image *) NULL); + return(DestroyImageList(image)); + } + + if (color_image == (Image *) NULL) + { + assert(alpha_image == (Image *) NULL); + return(DestroyImageList(image)); + } + + (void) SeekBlob(color_image,0,SEEK_SET); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading jng_image from color_blob.""); + + assert(color_image_info != (ImageInfo *) NULL); + (void) FormatLocaleString(color_image_info->filename,MaxTextExtent,""%s"", + color_image->filename); + + color_image_info->ping=MagickFalse; /* To do: avoid this */ + jng_image=ReadImage(color_image_info,exception); + + (void) RelinquishUniqueFileResource(color_image->filename); + unique_filenames--; + color_image=DestroyImage(color_image); + color_image_info=DestroyImageInfo(color_image_info); + + if (jng_image == (Image *) NULL) + return(DestroyImageList(image)); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying jng_image pixels to main image.""); + image->columns=jng_width; + image->rows=jng_height; + length=image->columns*sizeof(PixelPacket); + + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1,&image->exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + (void) CopyMagickMemory(q,s,length); + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + + jng_image=DestroyImage(jng_image); + + if (image_info->ping == MagickFalse) + { + if (jng_color_type >= 12) + { + if (jng_alpha_compression_method == 0) + { + png_byte + data[5]; + (void) WriteBlobMSBULong(alpha_image,0x00000000L); + PNGType(data,mng_IEND); + LogPNGChunk(logging,mng_IEND,0L); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,4)); + } + + (void) SeekBlob(alpha_image,0,SEEK_SET); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading opacity from alpha_blob.""); + + (void) FormatLocaleString(alpha_image_info->filename,MaxTextExtent, + ""%s"",alpha_image->filename); + + jng_image=ReadImage(alpha_image_info,exception); + + if (jng_image != (Image *) NULL) + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1, + &image->exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + + if (image->matte != MagickFalse) + for (x=(ssize_t) image->columns; x != 0; x--,q++,s++) + SetPixelOpacity(q,QuantumRange- + GetPixelRed(s)); + + else + for (x=(ssize_t) image->columns; x != 0; x--,q++,s++) + { + SetPixelAlpha(q,GetPixelRed(s)); + if (GetPixelOpacity(q) != OpaqueOpacity) + image->matte=MagickTrue; + } + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + (void) RelinquishUniqueFileResource(alpha_image->filename); + unique_filenames--; + alpha_image=DestroyImage(alpha_image); + alpha_image_info=DestroyImageInfo(alpha_image_info); + if (jng_image != (Image *) NULL) + jng_image=DestroyImage(jng_image); + } + } + + /* Read the JNG image. */ + + if (mng_info->mng_type == 0) + { + mng_info->mng_width=jng_width; + mng_info->mng_height=jng_height; + } + + if (image->page.width == 0 && image->page.height == 0) + { + image->page.width=jng_width; + image->page.height=jng_height; + } + + if (image->page.x == 0 && image->page.y == 0) + { + image->page.x=mng_info->x_off[mng_info->object_id]; + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + else + { + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + mng_info->image_found++; + status=SetImageProgress(image,LoadImagesTag,2*TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + return(DestroyImageList(image)); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" exit ReadOneJNGImage(); unique_filenames=%d"",unique_filenames); + + return(image); +} +",1,"static Image *ReadOneJNGImage(MngInfo *mng_info, + const ImageInfo *image_info, ExceptionInfo *exception) +{ + Image + *alpha_image, + *color_image, + *image, + *jng_image; + + ImageInfo + *alpha_image_info, + *color_image_info; + + MagickBooleanType + logging; + + int + unique_filenames; + + ssize_t + y; + + MagickBooleanType + status; + + png_uint_32 + jng_height, + jng_width; + + png_byte + jng_color_type, + jng_image_sample_depth, + jng_image_compression_method, + jng_image_interlace_method, + jng_alpha_sample_depth, + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method; + + register const PixelPacket + *s; + + register ssize_t + i, + x; + + register PixelPacket + *q; + + register unsigned char + *p; + + unsigned int + read_JSEP, + reading_idat; + + size_t + length; + + jng_alpha_compression_method=0; + jng_alpha_sample_depth=8; + jng_color_type=0; + jng_height=0; + jng_width=0; + alpha_image=(Image *) NULL; + color_image=(Image *) NULL; + alpha_image_info=(ImageInfo *) NULL; + color_image_info=(ImageInfo *) NULL; + unique_filenames=0; + + logging=LogMagickEvent(CoderEvent,GetMagickModule(), + "" Enter ReadOneJNGImage()""); + + image=mng_info->image; + + if (GetAuthenticPixelQueue(image) != (PixelPacket *) NULL) + { + /* + Allocate next image structure. + */ + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" AcquireNextImage()""); + + AcquireNextImage(image_info,image); + + if (GetNextImageInList(image) == (Image *) NULL) + return(DestroyImageList(image)); + + image=SyncNextImageInList(image); + } + mng_info->image=image; + + /* + Signature bytes have already been read. + */ + + read_JSEP=MagickFalse; + reading_idat=MagickFalse; + for (;;) + { + char + type[MaxTextExtent]; + + unsigned char + *chunk; + + unsigned int + count; + + /* + Read a new JNG chunk. + */ + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + break; + + type[0]='\0'; + (void) ConcatenateMagickString(type,""errr"",MaxTextExtent); + length=ReadBlobMSBLong(image); + count=(unsigned int) ReadBlob(image,4,(unsigned char *) type); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading JNG chunk type %c%c%c%c, length: %.20g"", + type[0],type[1],type[2],type[3],(double) length); + + if (length > PNG_UINT_31_MAX || count == 0) + ThrowReaderException(CorruptImageError,""CorruptImage""); + + p=NULL; + chunk=(unsigned char *) NULL; + + if (length != 0) + { + chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); + + if (chunk == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + for (i=0; i < (ssize_t) length; i++) + chunk[i]=(unsigned char) ReadBlobByte(image); + + p=chunk; + } + + (void) ReadBlobMSBLong(image); /* read crc word */ + + if (memcmp(type,mng_JHDR,4) == 0) + { + if (length == 16) + { + jng_width=(size_t) ((p[0] << 24) | (p[1] << 16) | + (p[2] << 8) | p[3]); + jng_height=(size_t) ((p[4] << 24) | (p[5] << 16) | + (p[6] << 8) | p[7]); + if ((jng_width == 0) || (jng_height == 0)) + ThrowReaderException(CorruptImageError,""NegativeOrZeroImageSize""); + jng_color_type=p[8]; + jng_image_sample_depth=p[9]; + jng_image_compression_method=p[10]; + jng_image_interlace_method=p[11]; + + image->interlace=jng_image_interlace_method != 0 ? PNGInterlace : + NoInterlace; + + jng_alpha_sample_depth=p[12]; + jng_alpha_compression_method=p[13]; + jng_alpha_filter_method=p[14]; + jng_alpha_interlace_method=p[15]; + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_width: %16lu, jng_height: %16lu\n"" + "" jng_color_type: %16d, jng_image_sample_depth: %3d\n"" + "" jng_image_compression_method:%3d"", + (unsigned long) jng_width, (unsigned long) jng_height, + jng_color_type, jng_image_sample_depth, + jng_image_compression_method); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_image_interlace_method: %3d"" + "" jng_alpha_sample_depth: %3d"", + jng_image_interlace_method, + jng_alpha_sample_depth); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_alpha_compression_method:%3d\n"" + "" jng_alpha_filter_method: %3d\n"" + "" jng_alpha_interlace_method: %3d"", + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method); + } + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + + if ((reading_idat == MagickFalse) && (read_JSEP == MagickFalse) && + ((memcmp(type,mng_JDAT,4) == 0) || (memcmp(type,mng_JdAA,4) == 0) || + (memcmp(type,mng_IDAT,4) == 0) || (memcmp(type,mng_JDAA,4) == 0))) + { + /* + o create color_image + o open color_blob, attached to color_image + o if (color type has alpha) + open alpha_blob, attached to alpha_image + */ + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating color_blob.""); + + color_image_info=(ImageInfo *)AcquireMagickMemory(sizeof(ImageInfo)); + + if (color_image_info == (ImageInfo *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + GetImageInfo(color_image_info); + color_image=AcquireImage(color_image_info); + + if (color_image == (Image *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + (void) AcquireUniqueFilename(color_image->filename); + unique_filenames++; + status=OpenBlob(color_image_info,color_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + color_image=DestroyImage(color_image); + return(DestroyImageList(image)); + } + + if ((image_info->ping == MagickFalse) && (jng_color_type >= 12)) + { + alpha_image_info=(ImageInfo *) + AcquireMagickMemory(sizeof(ImageInfo)); + + if (alpha_image_info == (ImageInfo *) NULL) + { + color_image=DestroyImage(color_image); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + GetImageInfo(alpha_image_info); + alpha_image=AcquireImage(alpha_image_info); + + if (alpha_image == (Image *) NULL) + { + alpha_image_info=DestroyImageInfo(alpha_image_info); + color_image=DestroyImage(color_image); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating alpha_blob.""); + + (void) AcquireUniqueFilename(alpha_image->filename); + unique_filenames++; + status=OpenBlob(alpha_image_info,alpha_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + alpha_image=DestroyImage(alpha_image); + alpha_image_info=DestroyImageInfo(alpha_image_info); + color_image=DestroyImage(color_image); + return(DestroyImageList(image)); + } + + if (jng_alpha_compression_method == 0) + { + unsigned char + data[18]; + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing IHDR chunk to alpha_blob.""); + + (void) WriteBlob(alpha_image,8,(const unsigned char *) + ""\211PNG\r\n\032\n""); + + (void) WriteBlobMSBULong(alpha_image,13L); + PNGType(data,mng_IHDR); + LogPNGChunk(logging,mng_IHDR,13L); + PNGLong(data+4,jng_width); + PNGLong(data+8,jng_height); + data[12]=jng_alpha_sample_depth; + data[13]=0; /* color_type gray */ + data[14]=0; /* compression method 0 */ + data[15]=0; /* filter_method 0 */ + data[16]=0; /* interlace_method 0 */ + (void) WriteBlob(alpha_image,17,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,17)); + } + } + reading_idat=MagickTrue; + } + + if (memcmp(type,mng_JDAT,4) == 0) + { + /* Copy chunk to color_image->blob */ + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + + if (length != 0) + { + (void) WriteBlob(color_image,length,chunk); + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + } + + continue; + } + + if (memcmp(type,mng_IDAT,4) == 0) + { + png_byte + data[5]; + + /* Copy IDAT header and chunk data to alpha_image->blob */ + + if (alpha_image != NULL && image_info->ping == MagickFalse) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying IDAT chunk data to alpha_blob.""); + + (void) WriteBlobMSBULong(alpha_image,(size_t) length); + PNGType(data,mng_IDAT); + LogPNGChunk(logging,mng_IDAT,length); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlob(alpha_image,length,chunk); + (void) WriteBlobMSBULong(alpha_image, + crc32(crc32(0,data,4),chunk,(uInt) length)); + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if ((memcmp(type,mng_JDAA,4) == 0) || (memcmp(type,mng_JdAA,4) == 0)) + { + /* Copy chunk data to alpha_image->blob */ + + if (alpha_image != NULL && image_info->ping == MagickFalse) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAA chunk data to alpha_blob.""); + + (void) WriteBlob(alpha_image,length,chunk); + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_JSEP,4) == 0) + { + read_JSEP=MagickTrue; + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_bKGD,4) == 0) + { + if (length == 2) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=image->background_color.red; + image->background_color.blue=image->background_color.red; + } + + if (length == 6) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=ScaleCharToQuantum(p[3]); + image->background_color.blue=ScaleCharToQuantum(p[5]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_gAMA,4) == 0) + { + if (length == 4) + image->gamma=((float) mng_get_long(p))*0.00001; + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_cHRM,4) == 0) + { + if (length == 32) + { + image->chromaticity.white_point.x=0.00001*mng_get_long(p); + image->chromaticity.white_point.y=0.00001*mng_get_long(&p[4]); + image->chromaticity.red_primary.x=0.00001*mng_get_long(&p[8]); + image->chromaticity.red_primary.y=0.00001*mng_get_long(&p[12]); + image->chromaticity.green_primary.x=0.00001*mng_get_long(&p[16]); + image->chromaticity.green_primary.y=0.00001*mng_get_long(&p[20]); + image->chromaticity.blue_primary.x=0.00001*mng_get_long(&p[24]); + image->chromaticity.blue_primary.y=0.00001*mng_get_long(&p[28]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_sRGB,4) == 0) + { + if (length == 1) + { + image->rendering_intent= + Magick_RenderingIntent_from_PNG_RenderingIntent(p[0]); + image->gamma=1.000f/2.200f; + image->chromaticity.red_primary.x=0.6400f; + image->chromaticity.red_primary.y=0.3300f; + image->chromaticity.green_primary.x=0.3000f; + image->chromaticity.green_primary.y=0.6000f; + image->chromaticity.blue_primary.x=0.1500f; + image->chromaticity.blue_primary.y=0.0600f; + image->chromaticity.white_point.x=0.3127f; + image->chromaticity.white_point.y=0.3290f; + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_oFFs,4) == 0) + { + if (length > 8) + { + image->page.x=(ssize_t) mng_get_long(p); + image->page.y=(ssize_t) mng_get_long(&p[4]); + + if ((int) p[8] != 0) + { + image->page.x/=10000; + image->page.y/=10000; + } + } + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_pHYs,4) == 0) + { + if (length > 8) + { + image->x_resolution=(double) mng_get_long(p); + image->y_resolution=(double) mng_get_long(&p[4]); + if ((int) p[8] == PNG_RESOLUTION_METER) + { + image->units=PixelsPerCentimeterResolution; + image->x_resolution=image->x_resolution/100.0f; + image->y_resolution=image->y_resolution/100.0f; + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + +#if 0 + if (memcmp(type,mng_iCCP,4) == 0) + { + /* To do: */ + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } +#endif + + if (length != 0) + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + if (memcmp(type,mng_IEND,4)) + continue; + + break; + } + + + /* IEND found */ + + /* + Finish up reading image data: + + o read main image from color_blob. + + o close color_blob. + + o if (color_type has alpha) + if alpha_encoding is PNG + read secondary image from alpha_blob via ReadPNG + if alpha_encoding is JPEG + read secondary image from alpha_blob via ReadJPEG + + o close alpha_blob. + + o copy intensity of secondary image into + opacity samples of main image. + + o destroy the secondary image. + */ + + if (color_image_info == (ImageInfo *) NULL) + { + assert(color_image == (Image *) NULL); + assert(alpha_image == (Image *) NULL); + return(DestroyImageList(image)); + } + + if (color_image == (Image *) NULL) + { + assert(alpha_image == (Image *) NULL); + return(DestroyImageList(image)); + } + + (void) SeekBlob(color_image,0,SEEK_SET); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading jng_image from color_blob.""); + + assert(color_image_info != (ImageInfo *) NULL); + (void) FormatLocaleString(color_image_info->filename,MaxTextExtent,""%s"", + color_image->filename); + + color_image_info->ping=MagickFalse; /* To do: avoid this */ + jng_image=ReadImage(color_image_info,exception); + + (void) RelinquishUniqueFileResource(color_image->filename); + unique_filenames--; + color_image=DestroyImage(color_image); + color_image_info=DestroyImageInfo(color_image_info); + + if (jng_image == (Image *) NULL) + return(DestroyImageList(image)); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying jng_image pixels to main image.""); + image->columns=jng_width; + image->rows=jng_height; + length=image->columns*sizeof(PixelPacket); + + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1,&image->exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + (void) CopyMagickMemory(q,s,length); + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + + jng_image=DestroyImage(jng_image); + + if (image_info->ping == MagickFalse) + { + if (jng_color_type >= 12) + { + if (jng_alpha_compression_method == 0) + { + png_byte + data[5]; + (void) WriteBlobMSBULong(alpha_image,0x00000000L); + PNGType(data,mng_IEND); + LogPNGChunk(logging,mng_IEND,0L); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,4)); + } + + (void) SeekBlob(alpha_image,0,SEEK_SET); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading opacity from alpha_blob.""); + + (void) FormatLocaleString(alpha_image_info->filename,MaxTextExtent, + ""%s"",alpha_image->filename); + + jng_image=ReadImage(alpha_image_info,exception); + + if (jng_image != (Image *) NULL) + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1, + &image->exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + + if (image->matte != MagickFalse) + for (x=(ssize_t) image->columns; x != 0; x--,q++,s++) + SetPixelOpacity(q,QuantumRange- + GetPixelRed(s)); + + else + for (x=(ssize_t) image->columns; x != 0; x--,q++,s++) + { + SetPixelAlpha(q,GetPixelRed(s)); + if (GetPixelOpacity(q) != OpaqueOpacity) + image->matte=MagickTrue; + } + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + (void) RelinquishUniqueFileResource(alpha_image->filename); + unique_filenames--; + alpha_image=DestroyImage(alpha_image); + alpha_image_info=DestroyImageInfo(alpha_image_info); + if (jng_image != (Image *) NULL) + jng_image=DestroyImage(jng_image); + } + } + + /* Read the JNG image. */ + + if (mng_info->mng_type == 0) + { + mng_info->mng_width=jng_width; + mng_info->mng_height=jng_height; + } + + if (image->page.width == 0 && image->page.height == 0) + { + image->page.width=jng_width; + image->page.height=jng_height; + } + + if (image->page.x == 0 && image->page.y == 0) + { + image->page.x=mng_info->x_off[mng_info->object_id]; + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + else + { + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + mng_info->image_found++; + status=SetImageProgress(image,LoadImagesTag,2*TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + return(DestroyImageList(image)); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" exit ReadOneJNGImage(); unique_filenames=%d"",unique_filenames); + + return(image); +} +","@@ -4477,10 +4477,11 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + +- (void) WriteBlob(color_image,length,chunk); +- + if (length != 0) +- chunk=(unsigned char *) RelinquishMagickMemory(chunk); ++ { ++ (void) WriteBlob(color_image,length,chunk); ++ chunk=(unsigned char *) RelinquishMagickMemory(chunk); ++ } + + continue; + }",5230,5466,6144 +18798,"WORD32 ihevcd_decode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) +{ + WORD32 ret = IV_SUCCESS; + codec_t *ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); + ivd_video_decode_ip_t *ps_dec_ip; + ivd_video_decode_op_t *ps_dec_op; + + WORD32 proc_idx = 0; + WORD32 prev_proc_idx = 0; + + /* Initialize error code */ + ps_codec->i4_error_code = 0; + + ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip; + ps_dec_op = (ivd_video_decode_op_t *)pv_api_op; + + { + UWORD32 u4_size = ps_dec_op->u4_size; + memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t)); + ps_dec_op->u4_size = u4_size; //Restore size field + } + if(ps_codec->i4_init_done != 1) + { + ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR; + ps_dec_op->u4_error_code |= IHEVCD_INIT_NOT_DONE; + return IV_FAIL; + } + + if(ps_codec->u4_pic_cnt >= NUM_FRAMES_LIMIT) + { + ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR; + ps_dec_op->u4_error_code |= IHEVCD_NUM_FRAMES_LIMIT_REACHED; + return IV_FAIL; + } + + /* If reset flag is set, flush the existing buffers */ + if(ps_codec->i4_reset_flag) + { + ps_codec->i4_flush_mode = 1; + } + + /*Data memory barries instruction,so that bitstream write by the application is complete*/ + /* In case the decoder is not in flush mode check for input buffer validity */ + if(0 == ps_codec->i4_flush_mode) + { + if(ps_dec_ip->pv_stream_buffer == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL; + return IV_FAIL; + } + if(ps_dec_ip->u4_num_Bytes <= MIN_START_CODE_LEN) + { + if((WORD32)ps_dec_ip->u4_num_Bytes > 0) + ps_dec_op->u4_num_bytes_consumed = ps_dec_ip->u4_num_Bytes; + else + ps_dec_op->u4_num_bytes_consumed = 0; + + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV; + return IV_FAIL; + + } + } + +#ifdef APPLY_CONCEALMENT + { + WORD32 num_mbs; + + num_mbs = (ps_codec->i4_wd * ps_codec->i4_ht + 255) >> 8; + /* Reset MB Count at the beginning of every process call */ + ps_codec->mb_count = 0; + memset(ps_codec->mb_map, 0, ((num_mbs + 7) >> 3)); + } +#endif + + if(0 == ps_codec->i4_share_disp_buf && ps_codec->i4_header_mode == 0) + { + UWORD32 i; + if(ps_dec_ip->s_out_buffer.u4_num_bufs == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS; + return IV_FAIL; + } + + for(i = 0; i < ps_dec_ip->s_out_buffer.u4_num_bufs; i++) + { + if(ps_dec_ip->s_out_buffer.pu1_bufs[i] == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL; + return IV_FAIL; + } + + if(ps_dec_ip->s_out_buffer.u4_min_out_buf_size[i] == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUF_SIZE; + return IV_FAIL; + } + } + } + + ps_codec->ps_out_buffer = &ps_dec_ip->s_out_buffer; + ps_codec->u4_ts = ps_dec_ip->u4_ts; + if(ps_codec->i4_flush_mode) + { + + ps_dec_op->u4_pic_wd = ps_codec->i4_disp_wd; + ps_dec_op->u4_pic_ht = ps_codec->i4_disp_ht; + + ps_dec_op->u4_new_seq = 0; + + ps_codec->ps_disp_buf = (pic_buf_t *)ihevc_disp_mgr_get( + (disp_mgr_t *)ps_codec->pv_disp_buf_mgr, &ps_codec->i4_disp_buf_id); + /* In case of non-shared mode, then convert/copy the frame to output buffer */ + /* Only if the codec is in non-shared mode or in shared mode but needs 420P output */ + if((ps_codec->ps_disp_buf) + && ((0 == ps_codec->i4_share_disp_buf) + || (IV_YUV_420P + == ps_codec->e_chroma_fmt))) + { + + process_ctxt_t *ps_proc = &ps_codec->as_process[prev_proc_idx]; + if(0 == ps_proc->i4_init_done) + { + ihevcd_init_proc_ctxt(ps_proc, 0); + } + + /* Output buffer check */ + ret = ihevcd_check_out_buf_size(ps_codec); + RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); + + /* Set remaining number of rows to be processed */ + ret = ihevcd_fmt_conv(ps_codec, &ps_codec->as_process[prev_proc_idx], + ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], 0, + ps_codec->i4_disp_ht); + + ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->i4_disp_buf_id, BUF_MGR_DISP); + } + + ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op); + + if(1 == ps_dec_op->u4_output_present) + { + WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD; + WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT; + + if(ypos < 0) + ypos = 0; + + if(xpos < 0) + xpos = 0; + + INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd, + xpos, + ypos, + ps_codec->e_chroma_fmt, + ps_codec->i4_disp_wd, + ps_codec->i4_disp_ht); + } + + + if(NULL == ps_codec->ps_disp_buf) + { + /* If in flush mode and there are no more buffers to flush, + * check for the reset flag and reset the decoder */ + if(ps_codec->i4_reset_flag) + { + ihevcd_init(ps_codec); + } + return (IV_FAIL); + } + + return (IV_SUCCESS); + + } + /* In case of shared mode, check if there is a free buffer for reconstruction */ + if((0 == ps_codec->i4_header_mode) && (1 == ps_codec->i4_share_disp_buf)) + { + WORD32 buf_status; + buf_status = 1; + if(ps_codec->pv_pic_buf_mgr) + buf_status = ihevc_buf_mgr_check_free((buf_mgr_t *)ps_codec->pv_pic_buf_mgr); + + /* If there is no free buffer, then return with an error code */ + if(0 == buf_status) + { + ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + return IV_FAIL; + } + } + ps_codec->i4_bytes_remaining = ps_dec_ip->u4_num_Bytes; + ps_codec->pu1_inp_bitsbuf = (UWORD8 *)ps_dec_ip->pv_stream_buffer; + ps_codec->s_parse.i4_end_of_frame = 0; + + ps_codec->i4_pic_present = 0; + ps_codec->i4_slice_error = 0; + ps_codec->ps_disp_buf = NULL; + + if(ps_codec->i4_num_cores > 1) + { + ithread_set_affinity(0); + } + while(MIN_START_CODE_LEN < ps_codec->i4_bytes_remaining) + { + WORD32 nal_len; + WORD32 nal_ofst; + WORD32 bits_len; + + if(ps_codec->i4_slice_error) + { + slice_header_t *ps_slice_hdr_next = ps_codec->s_parse.ps_slice_hdr_base + (ps_codec->s_parse.i4_cur_slice_idx & (MAX_SLICE_HDR_CNT - 1)); + WORD32 next_slice_addr = ps_slice_hdr_next->i2_ctb_x + + ps_slice_hdr_next->i2_ctb_y * ps_codec->s_parse.ps_sps->i2_pic_wd_in_ctb; + if(ps_codec->s_parse.i4_next_ctb_indx == next_slice_addr) + ps_codec->i4_slice_error = 0; + } + + if(ps_codec->pu1_bitsbuf_dynamic) + { + ps_codec->pu1_bitsbuf = ps_codec->pu1_bitsbuf_dynamic; + ps_codec->u4_bitsbuf_size = ps_codec->u4_bitsbuf_size_dynamic; + } + else + { + ps_codec->pu1_bitsbuf = ps_codec->pu1_bitsbuf_static; + ps_codec->u4_bitsbuf_size = ps_codec->u4_bitsbuf_size_static; + } + + nal_ofst = ihevcd_nal_search_start_code(ps_codec->pu1_inp_bitsbuf, + ps_codec->i4_bytes_remaining); + + ps_codec->i4_nal_ofst = nal_ofst; + { + WORD32 bytes_remaining = ps_codec->i4_bytes_remaining - nal_ofst; + + bytes_remaining = MIN((UWORD32)bytes_remaining, ps_codec->u4_bitsbuf_size); + ihevcd_nal_remv_emuln_bytes(ps_codec->pu1_inp_bitsbuf + nal_ofst, + ps_codec->pu1_bitsbuf, + bytes_remaining, + &nal_len, &bits_len); + + /* Decoder may read upto 8 extra bytes at the end of frame */ + /* These are not used, but still set them to zero to avoid uninitialized reads */ + if(bits_len < (WORD32)(ps_codec->u4_bitsbuf_size - 8)) + { + memset(ps_codec->pu1_bitsbuf + bits_len, 0, 2 * sizeof(UWORD32)); + } + } + /* This may be used to update the offsets for tiles and entropy sync row offsets */ + ps_codec->i4_num_emln_bytes = nal_len - bits_len; + ps_codec->i4_nal_len = nal_len; + + ihevcd_bits_init(&ps_codec->s_parse.s_bitstrm, ps_codec->pu1_bitsbuf, + bits_len); + + ret = ihevcd_nal_unit(ps_codec); + + /* If the frame is incomplete and + * the bytes remaining is zero or a header is received, + * complete the frame treating it to be in error */ + if(ps_codec->i4_pic_present && + (ps_codec->s_parse.i4_next_ctb_indx != ps_codec->s_parse.ps_sps->i4_pic_size_in_ctb)) + { + if((ps_codec->i4_bytes_remaining - (nal_len + nal_ofst) <= MIN_START_CODE_LEN) || + (ps_codec->i4_header_in_slice_mode)) + { + slice_header_t *ps_slice_hdr_next; + + ps_codec->s_parse.i4_cur_slice_idx--; + if(ps_codec->s_parse.i4_cur_slice_idx < 0) + ps_codec->s_parse.i4_cur_slice_idx = 0; + + ps_slice_hdr_next = ps_codec->s_parse.ps_slice_hdr_base + ((ps_codec->s_parse.i4_cur_slice_idx + 1) & (MAX_SLICE_HDR_CNT - 1)); + ps_slice_hdr_next->i2_ctb_x = 0; + ps_slice_hdr_next->i2_ctb_y = ps_codec->s_parse.ps_sps->i2_pic_ht_in_ctb; + ps_codec->i4_slice_error = 1; + continue; + } + } + + + if(IHEVCD_IGNORE_SLICE == ret) + { + ps_codec->s_parse.i4_cur_slice_idx = MAX(0, (ps_codec->s_parse.i4_cur_slice_idx - 1)); + ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len); + ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len); + + continue; + } + + if((IVD_RES_CHANGED == ret) || + (IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED == ret)) + { + break; + } + + /* Update bytes remaining and bytes consumed and input bitstream pointer */ + /* Do not consume the NAL in the following cases */ + /* Slice header reached during header decode mode */ + /* TODO: Next picture's slice reached */ + if(ret != IHEVCD_SLICE_IN_HEADER_MODE) + { + if((0 == ps_codec->i4_slice_error) || + (ps_codec->i4_bytes_remaining - (nal_len + nal_ofst) <= MIN_START_CODE_LEN)) + { + ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len); + ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len); + } + if(ret != IHEVCD_SUCCESS) + break; + + if(ps_codec->s_parse.i4_end_of_frame) + break; + } + else + { + ret = IHEVCD_SUCCESS; + break; + } + + /* Allocate dynamic bitstream buffer once SPS is decoded */ + if((ps_codec->u4_allocate_dynamic_done == 0) && ps_codec->i4_sps_done) + { + WORD32 ret; + ret = ihevcd_allocate_dynamic_bufs(ps_codec); + if(ret != IV_SUCCESS) + { + /* Free any dynamic buffers that are allocated */ + ihevcd_free_dynamic_bufs(ps_codec); + ps_codec->i4_error_code = IVD_MEM_ALLOC_FAILED; + ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR; + ps_dec_op->u4_error_code |= IVD_MEM_ALLOC_FAILED; + + return IV_FAIL; + } + } + + BREAK_AFTER_SLICE_NAL(); + } + + if((ps_codec->u4_pic_cnt == 0) && (ret != IHEVCD_SUCCESS)) + { + ps_codec->i4_error_code = ret; + + ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op); + return IV_FAIL; + } + + if(1 == ps_codec->i4_pic_present) + { + WORD32 i; + sps_t *ps_sps = ps_codec->s_parse.ps_sps; + ps_codec->i4_first_pic_done = 1; + + /*TODO temporary fix: end_of_frame is checked before adding format conversion to job queue */ + if(ps_codec->i4_num_cores > 1 && ps_codec->s_parse.i4_end_of_frame) + { + + /* Add job queue for format conversion / frame copy for each ctb row */ + /* Only if the codec is in non-shared mode or in shared mode but needs 420P output */ + process_ctxt_t *ps_proc; + + /* i4_num_cores - 1 contexts are currently being used by other threads */ + ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1]; + + if((ps_codec->ps_disp_buf) && + ((0 == ps_codec->i4_share_disp_buf) || (IV_YUV_420P == ps_codec->e_chroma_fmt))) + { + /* If format conversion jobs were not issued in pic_init() add them here */ + if((0 == ps_codec->u4_enable_fmt_conv_ahead) || + (ps_codec->i4_disp_buf_id == ps_proc->i4_cur_pic_buf_id)) + for(i = 0; i < ps_sps->i2_pic_ht_in_ctb; i++) + { + proc_job_t s_job; + IHEVCD_ERROR_T ret; + s_job.i4_cmd = CMD_FMTCONV; + s_job.i2_ctb_cnt = 0; + s_job.i2_ctb_x = 0; + s_job.i2_ctb_y = i; + s_job.i2_slice_idx = 0; + s_job.i4_tu_coeff_data_ofst = 0; + ret = ihevcd_jobq_queue((jobq_t *)ps_codec->s_parse.pv_proc_jobq, + &s_job, sizeof(proc_job_t), 1); + if(ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS) + return (WORD32)ret; + } + } + /* Reached end of frame : Signal terminate */ + /* The terminate flag is checked only after all the jobs are dequeued */ + ret = ihevcd_jobq_terminate((jobq_t *)ps_codec->s_parse.pv_proc_jobq); + + while(1) + { + IHEVCD_ERROR_T ret; + proc_job_t s_job; + process_ctxt_t *ps_proc; + + /* i4_num_cores - 1 contexts are currently being used by other threads */ + ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1]; + + ret = ihevcd_jobq_dequeue((jobq_t *)ps_proc->pv_proc_jobq, &s_job, + sizeof(proc_job_t), 1); + if((IHEVCD_ERROR_T)IHEVCD_SUCCESS != ret) + break; + + ps_proc->i4_ctb_cnt = s_job.i2_ctb_cnt; + ps_proc->i4_ctb_x = s_job.i2_ctb_x; + ps_proc->i4_ctb_y = s_job.i2_ctb_y; + ps_proc->i4_cur_slice_idx = s_job.i2_slice_idx; + + if(CMD_PROCESS == s_job.i4_cmd) + { + ihevcd_init_proc_ctxt(ps_proc, s_job.i4_tu_coeff_data_ofst); + + ihevcd_process(ps_proc); + } + else if(CMD_FMTCONV == s_job.i4_cmd) + { + sps_t *ps_sps = ps_codec->s_parse.ps_sps; + WORD32 num_rows = 1 << ps_sps->i1_log2_ctb_size; + if(0 == ps_proc->i4_init_done) + { + ihevcd_init_proc_ctxt(ps_proc, 0); + } + + num_rows = MIN(num_rows, (ps_codec->i4_disp_ht - (s_job.i2_ctb_y << ps_sps->i1_log2_ctb_size))); + if(num_rows < 0) + num_rows = 0; + + ihevcd_fmt_conv(ps_codec, ps_proc, + ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], + s_job.i2_ctb_y << ps_sps->i1_log2_ctb_size, + num_rows); + } + } + } + /* In case of non-shared mode and while running in single core mode, then convert/copy the frame to output buffer */ + /* Only if the codec is in non-shared mode or in shared mode but needs 420P output */ + else if((ps_codec->ps_disp_buf) && ((0 == ps_codec->i4_share_disp_buf) || + (IV_YUV_420P == ps_codec->e_chroma_fmt)) && + (ps_codec->s_parse.i4_end_of_frame)) + { + process_ctxt_t *ps_proc = &ps_codec->as_process[proc_idx]; + /* Set remaining number of rows to be processed */ + ps_codec->s_fmt_conv.i4_num_rows = ps_codec->i4_disp_ht + - ps_codec->s_fmt_conv.i4_cur_row; + if(0 == ps_proc->i4_init_done) + { + ihevcd_init_proc_ctxt(ps_proc, 0); + } + + if(ps_codec->s_fmt_conv.i4_num_rows < 0) + ps_codec->s_fmt_conv.i4_num_rows = 0; + + ret = ihevcd_fmt_conv(ps_codec, ps_proc, + ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], + ps_codec->s_fmt_conv.i4_cur_row, + ps_codec->s_fmt_conv.i4_num_rows); + ps_codec->s_fmt_conv.i4_cur_row += ps_codec->s_fmt_conv.i4_num_rows; + + } + + + DEBUG_DUMP_MV_MAP(ps_codec); + + /* Mark MV Buf as needed for reference */ + ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_mv_buf_mgr, + ps_codec->as_process[proc_idx].i4_cur_mv_bank_buf_id, + BUF_MGR_REF); + + /* Mark pic buf as needed for reference */ + ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->as_process[proc_idx].i4_cur_pic_buf_id, + BUF_MGR_REF); + + /* Mark pic buf as needed for display */ + ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->as_process[proc_idx].i4_cur_pic_buf_id, + BUF_MGR_DISP); + + /* Insert the current picture as short term reference */ + ihevc_dpb_mgr_insert_ref((dpb_mgr_t *)ps_codec->pv_dpb_mgr, + ps_codec->as_process[proc_idx].ps_cur_pic, + ps_codec->as_process[proc_idx].i4_cur_pic_buf_id); + + /* If a frame was displayed (in non-shared mode), then release it from display manager */ + if((0 == ps_codec->i4_share_disp_buf) && (ps_codec->ps_disp_buf)) + ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->i4_disp_buf_id, BUF_MGR_DISP); + + /* Wait for threads */ + for(i = 0; i < (ps_codec->i4_num_cores - 1); i++) + { + if(ps_codec->ai4_process_thread_created[i]) + { + ithread_join(ps_codec->apv_process_thread_handle[i], NULL); + ps_codec->ai4_process_thread_created[i] = 0; + } + } + + DEBUG_VALIDATE_PADDED_REGION(&ps_codec->as_process[proc_idx]); + if(ps_codec->u4_pic_cnt > 0) + { + DEBUG_DUMP_PIC_PU(ps_codec); + } + DEBUG_DUMP_PIC_BUFFERS(ps_codec); + + /* Increment the number of pictures decoded */ + ps_codec->u4_pic_cnt++; + } + ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op); + + if(1 == ps_dec_op->u4_output_present) + { + WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD; + WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT; + + if(ypos < 0) + ypos = 0; + + if(xpos < 0) + xpos = 0; + + INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd, + xpos, + ypos, + ps_codec->e_chroma_fmt, + ps_codec->i4_disp_wd, + ps_codec->i4_disp_ht); + } + + + return ret; +} +",1,"WORD32 ihevcd_decode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) +{ + WORD32 ret = IV_SUCCESS; + codec_t *ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle); + ivd_video_decode_ip_t *ps_dec_ip; + ivd_video_decode_op_t *ps_dec_op; + + WORD32 proc_idx = 0; + WORD32 prev_proc_idx = 0; + + /* Initialize error code */ + ps_codec->i4_error_code = 0; + + ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip; + ps_dec_op = (ivd_video_decode_op_t *)pv_api_op; + + { + UWORD32 u4_size = ps_dec_op->u4_size; + memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t)); + ps_dec_op->u4_size = u4_size; //Restore size field + } + if(ps_codec->i4_init_done != 1) + { + ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR; + ps_dec_op->u4_error_code |= IHEVCD_INIT_NOT_DONE; + return IV_FAIL; + } + + if(ps_codec->u4_pic_cnt >= NUM_FRAMES_LIMIT) + { + ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR; + ps_dec_op->u4_error_code |= IHEVCD_NUM_FRAMES_LIMIT_REACHED; + return IV_FAIL; + } + + /* If reset flag is set, flush the existing buffers */ + if(ps_codec->i4_reset_flag) + { + ps_codec->i4_flush_mode = 1; + } + + /*Data memory barries instruction,so that bitstream write by the application is complete*/ + /* In case the decoder is not in flush mode check for input buffer validity */ + if(0 == ps_codec->i4_flush_mode) + { + if(ps_dec_ip->pv_stream_buffer == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL; + return IV_FAIL; + } + if(ps_dec_ip->u4_num_Bytes <= MIN_START_CODE_LEN) + { + if((WORD32)ps_dec_ip->u4_num_Bytes > 0) + ps_dec_op->u4_num_bytes_consumed = ps_dec_ip->u4_num_Bytes; + else + ps_dec_op->u4_num_bytes_consumed = 0; + + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV; + return IV_FAIL; + + } + } + +#ifdef APPLY_CONCEALMENT + { + WORD32 num_mbs; + + num_mbs = (ps_codec->i4_wd * ps_codec->i4_ht + 255) >> 8; + /* Reset MB Count at the beginning of every process call */ + ps_codec->mb_count = 0; + memset(ps_codec->mb_map, 0, ((num_mbs + 7) >> 3)); + } +#endif + + if(0 == ps_codec->i4_share_disp_buf && ps_codec->i4_header_mode == 0) + { + UWORD32 i; + if(ps_dec_ip->s_out_buffer.u4_num_bufs == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS; + return IV_FAIL; + } + + for(i = 0; i < ps_dec_ip->s_out_buffer.u4_num_bufs; i++) + { + if(ps_dec_ip->s_out_buffer.pu1_bufs[i] == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL; + return IV_FAIL; + } + + if(ps_dec_ip->s_out_buffer.u4_min_out_buf_size[i] == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUF_SIZE; + return IV_FAIL; + } + } + } + + ps_codec->ps_out_buffer = &ps_dec_ip->s_out_buffer; + ps_codec->u4_ts = ps_dec_ip->u4_ts; + if(ps_codec->i4_flush_mode) + { + + ps_dec_op->u4_pic_wd = ps_codec->i4_disp_wd; + ps_dec_op->u4_pic_ht = ps_codec->i4_disp_ht; + + ps_dec_op->u4_new_seq = 0; + + ps_codec->ps_disp_buf = (pic_buf_t *)ihevc_disp_mgr_get( + (disp_mgr_t *)ps_codec->pv_disp_buf_mgr, &ps_codec->i4_disp_buf_id); + /* In case of non-shared mode, then convert/copy the frame to output buffer */ + /* Only if the codec is in non-shared mode or in shared mode but needs 420P output */ + if((ps_codec->ps_disp_buf) + && ((0 == ps_codec->i4_share_disp_buf) + || (IV_YUV_420P + == ps_codec->e_chroma_fmt))) + { + + process_ctxt_t *ps_proc = &ps_codec->as_process[prev_proc_idx]; + if(0 == ps_proc->i4_init_done) + { + ihevcd_init_proc_ctxt(ps_proc, 0); + } + + /* Output buffer check */ + ret = ihevcd_check_out_buf_size(ps_codec); + RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret); + + /* Set remaining number of rows to be processed */ + ret = ihevcd_fmt_conv(ps_codec, &ps_codec->as_process[prev_proc_idx], + ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], 0, + ps_codec->i4_disp_ht); + + ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->i4_disp_buf_id, BUF_MGR_DISP); + } + + ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op); + + if(1 == ps_dec_op->u4_output_present) + { + WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD; + WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT; + + if(ypos < 0) + ypos = 0; + + if(xpos < 0) + xpos = 0; + + INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd, + xpos, + ypos, + ps_codec->e_chroma_fmt, + ps_codec->i4_disp_wd, + ps_codec->i4_disp_ht); + } + + + if(NULL == ps_codec->ps_disp_buf) + { + /* If in flush mode and there are no more buffers to flush, + * check for the reset flag and reset the decoder */ + if(ps_codec->i4_reset_flag) + { + ihevcd_init(ps_codec); + } + return (IV_FAIL); + } + + return (IV_SUCCESS); + + } + /* In case of shared mode, check if there is a free buffer for reconstruction */ + if((0 == ps_codec->i4_header_mode) && (1 == ps_codec->i4_share_disp_buf)) + { + WORD32 buf_status; + buf_status = 1; + if(ps_codec->pv_pic_buf_mgr) + buf_status = ihevc_buf_mgr_check_free((buf_mgr_t *)ps_codec->pv_pic_buf_mgr); + + /* If there is no free buffer, then return with an error code */ + if(0 == buf_status) + { + ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + return IV_FAIL; + } + } + ps_codec->i4_bytes_remaining = ps_dec_ip->u4_num_Bytes; + ps_codec->pu1_inp_bitsbuf = (UWORD8 *)ps_dec_ip->pv_stream_buffer; + ps_codec->s_parse.i4_end_of_frame = 0; + + ps_codec->i4_pic_present = 0; + ps_codec->i4_slice_error = 0; + ps_codec->ps_disp_buf = NULL; + + if(ps_codec->i4_num_cores > 1) + { + ithread_set_affinity(0); + } + while(MIN_START_CODE_LEN < ps_codec->i4_bytes_remaining) + { + WORD32 nal_len; + WORD32 nal_ofst; + WORD32 bits_len; + + if(ps_codec->i4_slice_error) + { + slice_header_t *ps_slice_hdr_next = ps_codec->s_parse.ps_slice_hdr_base + (ps_codec->s_parse.i4_cur_slice_idx & (MAX_SLICE_HDR_CNT - 1)); + WORD32 next_slice_addr = ps_slice_hdr_next->i2_ctb_x + + ps_slice_hdr_next->i2_ctb_y * ps_codec->s_parse.ps_sps->i2_pic_wd_in_ctb; + if(ps_codec->s_parse.i4_next_ctb_indx == next_slice_addr) + ps_codec->i4_slice_error = 0; + } + + if(ps_codec->pu1_bitsbuf_dynamic) + { + ps_codec->pu1_bitsbuf = ps_codec->pu1_bitsbuf_dynamic; + ps_codec->u4_bitsbuf_size = ps_codec->u4_bitsbuf_size_dynamic; + } + else + { + ps_codec->pu1_bitsbuf = ps_codec->pu1_bitsbuf_static; + ps_codec->u4_bitsbuf_size = ps_codec->u4_bitsbuf_size_static; + } + + nal_ofst = ihevcd_nal_search_start_code(ps_codec->pu1_inp_bitsbuf, + ps_codec->i4_bytes_remaining); + + ps_codec->i4_nal_ofst = nal_ofst; + { + WORD32 bytes_remaining = ps_codec->i4_bytes_remaining - nal_ofst; + + bytes_remaining = MIN((UWORD32)bytes_remaining, ps_codec->u4_bitsbuf_size); + ihevcd_nal_remv_emuln_bytes(ps_codec->pu1_inp_bitsbuf + nal_ofst, + ps_codec->pu1_bitsbuf, + bytes_remaining, + &nal_len, &bits_len); + + /* Decoder may read upto 8 extra bytes at the end of frame */ + /* These are not used, but still set them to zero to avoid uninitialized reads */ + if(bits_len < (WORD32)(ps_codec->u4_bitsbuf_size - 8)) + { + memset(ps_codec->pu1_bitsbuf + bits_len, 0, 2 * sizeof(UWORD32)); + } + } + /* This may be used to update the offsets for tiles and entropy sync row offsets */ + ps_codec->i4_num_emln_bytes = nal_len - bits_len; + ps_codec->i4_nal_len = nal_len; + + ihevcd_bits_init(&ps_codec->s_parse.s_bitstrm, ps_codec->pu1_bitsbuf, + bits_len); + + ret = ihevcd_nal_unit(ps_codec); + + /* If the frame is incomplete and + * the bytes remaining is zero or a header is received, + * complete the frame treating it to be in error */ + if(ps_codec->i4_pic_present && + (ps_codec->s_parse.i4_next_ctb_indx != ps_codec->s_parse.ps_sps->i4_pic_size_in_ctb)) + { + if((ps_codec->i4_bytes_remaining - (nal_len + nal_ofst) <= MIN_START_CODE_LEN) || + (ps_codec->i4_header_in_slice_mode)) + { + slice_header_t *ps_slice_hdr_next; + + ps_codec->s_parse.i4_cur_slice_idx--; + if(ps_codec->s_parse.i4_cur_slice_idx < 0) + ps_codec->s_parse.i4_cur_slice_idx = 0; + + ps_slice_hdr_next = ps_codec->s_parse.ps_slice_hdr_base + ((ps_codec->s_parse.i4_cur_slice_idx + 1) & (MAX_SLICE_HDR_CNT - 1)); + ps_slice_hdr_next->i2_ctb_x = 0; + ps_slice_hdr_next->i2_ctb_y = ps_codec->s_parse.ps_sps->i2_pic_ht_in_ctb; + ps_codec->i4_slice_error = 1; + continue; + } + } + + + if(IHEVCD_IGNORE_SLICE == ret) + { + ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len); + ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len); + + continue; + } + + if((IVD_RES_CHANGED == ret) || + (IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED == ret)) + { + break; + } + + /* Update bytes remaining and bytes consumed and input bitstream pointer */ + /* Do not consume the NAL in the following cases */ + /* Slice header reached during header decode mode */ + /* TODO: Next picture's slice reached */ + if(ret != IHEVCD_SLICE_IN_HEADER_MODE) + { + if((0 == ps_codec->i4_slice_error) || + (ps_codec->i4_bytes_remaining - (nal_len + nal_ofst) <= MIN_START_CODE_LEN)) + { + ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len); + ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len); + } + if(ret != IHEVCD_SUCCESS) + break; + + if(ps_codec->s_parse.i4_end_of_frame) + break; + } + else + { + ret = IHEVCD_SUCCESS; + break; + } + + /* Allocate dynamic bitstream buffer once SPS is decoded */ + if((ps_codec->u4_allocate_dynamic_done == 0) && ps_codec->i4_sps_done) + { + WORD32 ret; + ret = ihevcd_allocate_dynamic_bufs(ps_codec); + if(ret != IV_SUCCESS) + { + /* Free any dynamic buffers that are allocated */ + ihevcd_free_dynamic_bufs(ps_codec); + ps_codec->i4_error_code = IVD_MEM_ALLOC_FAILED; + ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR; + ps_dec_op->u4_error_code |= IVD_MEM_ALLOC_FAILED; + + return IV_FAIL; + } + } + + BREAK_AFTER_SLICE_NAL(); + } + + if((ps_codec->u4_pic_cnt == 0) && (ret != IHEVCD_SUCCESS)) + { + ps_codec->i4_error_code = ret; + + ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op); + return IV_FAIL; + } + + if(1 == ps_codec->i4_pic_present) + { + WORD32 i; + sps_t *ps_sps = ps_codec->s_parse.ps_sps; + ps_codec->i4_first_pic_done = 1; + + /*TODO temporary fix: end_of_frame is checked before adding format conversion to job queue */ + if(ps_codec->i4_num_cores > 1 && ps_codec->s_parse.i4_end_of_frame) + { + + /* Add job queue for format conversion / frame copy for each ctb row */ + /* Only if the codec is in non-shared mode or in shared mode but needs 420P output */ + process_ctxt_t *ps_proc; + + /* i4_num_cores - 1 contexts are currently being used by other threads */ + ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1]; + + if((ps_codec->ps_disp_buf) && + ((0 == ps_codec->i4_share_disp_buf) || (IV_YUV_420P == ps_codec->e_chroma_fmt))) + { + /* If format conversion jobs were not issued in pic_init() add them here */ + if((0 == ps_codec->u4_enable_fmt_conv_ahead) || + (ps_codec->i4_disp_buf_id == ps_proc->i4_cur_pic_buf_id)) + for(i = 0; i < ps_sps->i2_pic_ht_in_ctb; i++) + { + proc_job_t s_job; + IHEVCD_ERROR_T ret; + s_job.i4_cmd = CMD_FMTCONV; + s_job.i2_ctb_cnt = 0; + s_job.i2_ctb_x = 0; + s_job.i2_ctb_y = i; + s_job.i2_slice_idx = 0; + s_job.i4_tu_coeff_data_ofst = 0; + ret = ihevcd_jobq_queue((jobq_t *)ps_codec->s_parse.pv_proc_jobq, + &s_job, sizeof(proc_job_t), 1); + if(ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS) + return (WORD32)ret; + } + } + /* Reached end of frame : Signal terminate */ + /* The terminate flag is checked only after all the jobs are dequeued */ + ret = ihevcd_jobq_terminate((jobq_t *)ps_codec->s_parse.pv_proc_jobq); + + while(1) + { + IHEVCD_ERROR_T ret; + proc_job_t s_job; + process_ctxt_t *ps_proc; + + /* i4_num_cores - 1 contexts are currently being used by other threads */ + ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1]; + + ret = ihevcd_jobq_dequeue((jobq_t *)ps_proc->pv_proc_jobq, &s_job, + sizeof(proc_job_t), 1); + if((IHEVCD_ERROR_T)IHEVCD_SUCCESS != ret) + break; + + ps_proc->i4_ctb_cnt = s_job.i2_ctb_cnt; + ps_proc->i4_ctb_x = s_job.i2_ctb_x; + ps_proc->i4_ctb_y = s_job.i2_ctb_y; + ps_proc->i4_cur_slice_idx = s_job.i2_slice_idx; + + if(CMD_PROCESS == s_job.i4_cmd) + { + ihevcd_init_proc_ctxt(ps_proc, s_job.i4_tu_coeff_data_ofst); + + ihevcd_process(ps_proc); + } + else if(CMD_FMTCONV == s_job.i4_cmd) + { + sps_t *ps_sps = ps_codec->s_parse.ps_sps; + WORD32 num_rows = 1 << ps_sps->i1_log2_ctb_size; + if(0 == ps_proc->i4_init_done) + { + ihevcd_init_proc_ctxt(ps_proc, 0); + } + + num_rows = MIN(num_rows, (ps_codec->i4_disp_ht - (s_job.i2_ctb_y << ps_sps->i1_log2_ctb_size))); + if(num_rows < 0) + num_rows = 0; + + ihevcd_fmt_conv(ps_codec, ps_proc, + ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], + s_job.i2_ctb_y << ps_sps->i1_log2_ctb_size, + num_rows); + } + } + } + /* In case of non-shared mode and while running in single core mode, then convert/copy the frame to output buffer */ + /* Only if the codec is in non-shared mode or in shared mode but needs 420P output */ + else if((ps_codec->ps_disp_buf) && ((0 == ps_codec->i4_share_disp_buf) || + (IV_YUV_420P == ps_codec->e_chroma_fmt)) && + (ps_codec->s_parse.i4_end_of_frame)) + { + process_ctxt_t *ps_proc = &ps_codec->as_process[proc_idx]; + /* Set remaining number of rows to be processed */ + ps_codec->s_fmt_conv.i4_num_rows = ps_codec->i4_disp_ht + - ps_codec->s_fmt_conv.i4_cur_row; + if(0 == ps_proc->i4_init_done) + { + ihevcd_init_proc_ctxt(ps_proc, 0); + } + + if(ps_codec->s_fmt_conv.i4_num_rows < 0) + ps_codec->s_fmt_conv.i4_num_rows = 0; + + ret = ihevcd_fmt_conv(ps_codec, ps_proc, + ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], + ps_codec->s_fmt_conv.i4_cur_row, + ps_codec->s_fmt_conv.i4_num_rows); + ps_codec->s_fmt_conv.i4_cur_row += ps_codec->s_fmt_conv.i4_num_rows; + + } + + + DEBUG_DUMP_MV_MAP(ps_codec); + + /* Mark MV Buf as needed for reference */ + ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_mv_buf_mgr, + ps_codec->as_process[proc_idx].i4_cur_mv_bank_buf_id, + BUF_MGR_REF); + + /* Mark pic buf as needed for reference */ + ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->as_process[proc_idx].i4_cur_pic_buf_id, + BUF_MGR_REF); + + /* Mark pic buf as needed for display */ + ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->as_process[proc_idx].i4_cur_pic_buf_id, + BUF_MGR_DISP); + + /* Insert the current picture as short term reference */ + ihevc_dpb_mgr_insert_ref((dpb_mgr_t *)ps_codec->pv_dpb_mgr, + ps_codec->as_process[proc_idx].ps_cur_pic, + ps_codec->as_process[proc_idx].i4_cur_pic_buf_id); + + /* If a frame was displayed (in non-shared mode), then release it from display manager */ + if((0 == ps_codec->i4_share_disp_buf) && (ps_codec->ps_disp_buf)) + ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, + ps_codec->i4_disp_buf_id, BUF_MGR_DISP); + + /* Wait for threads */ + for(i = 0; i < (ps_codec->i4_num_cores - 1); i++) + { + if(ps_codec->ai4_process_thread_created[i]) + { + ithread_join(ps_codec->apv_process_thread_handle[i], NULL); + ps_codec->ai4_process_thread_created[i] = 0; + } + } + + DEBUG_VALIDATE_PADDED_REGION(&ps_codec->as_process[proc_idx]); + if(ps_codec->u4_pic_cnt > 0) + { + DEBUG_DUMP_PIC_PU(ps_codec); + } + DEBUG_DUMP_PIC_BUFFERS(ps_codec); + + /* Increment the number of pictures decoded */ + ps_codec->u4_pic_cnt++; + } + ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op); + + if(1 == ps_dec_op->u4_output_present) + { + WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD; + WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT; + + if(ypos < 0) + ypos = 0; + + if(xpos < 0) + xpos = 0; + + INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0], + ps_dec_ip->s_out_buffer.pu1_bufs[1], + ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd, + xpos, + ypos, + ps_codec->e_chroma_fmt, + ps_codec->i4_disp_wd, + ps_codec->i4_disp_ht); + } + + + return ret; +} +","@@ -668,7 +668,6 @@ + + + if(IHEVCD_IGNORE_SLICE == ret) + { +- ps_codec->s_parse.i4_cur_slice_idx = MAX(0, (ps_codec->s_parse.i4_cur_slice_idx - 1)); + ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len); + ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len); + +",5118,5354,6144 +18199,"static int mxf_parse_structural_metadata(MXFContext *mxf) +{ + MXFPackage *material_package = NULL; + int i, j, k, ret; + + av_log(mxf->fc, AV_LOG_TRACE, ""metadata sets count %d\n"", mxf->metadata_sets_count); + /* TODO: handle multiple material packages (OP3x) */ + for (i = 0; i < mxf->packages_count; i++) { + material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage); + if (material_package) break; + } + if (!material_package) { + av_log(mxf->fc, AV_LOG_ERROR, ""no material package found\n""); + return AVERROR_INVALIDDATA; + } + + mxf_add_umid_metadata(&mxf->fc->metadata, ""material_package_umid"", material_package); + if (material_package->name && material_package->name[0]) + av_dict_set(&mxf->fc->metadata, ""material_package_name"", material_package->name, 0); + mxf_parse_package_comments(mxf, &mxf->fc->metadata, material_package); + + for (i = 0; i < material_package->tracks_count; i++) { + MXFPackage *source_package = NULL; + MXFTrack *material_track = NULL; + MXFTrack *source_track = NULL; + MXFTrack *temp_track = NULL; + MXFDescriptor *descriptor = NULL; + MXFStructuralComponent *component = NULL; + MXFTimecodeComponent *mxf_tc = NULL; + UID *essence_container_ul = NULL; + const MXFCodecUL *codec_ul = NULL; + const MXFCodecUL *container_ul = NULL; + const MXFCodecUL *pix_fmt_ul = NULL; + AVStream *st; + AVTimecode tc; + int flags; + + if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i], Track))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve material track strong ref\n""); + continue; + } + + if ((component = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref, TimecodeComponent))) { + mxf_tc = (MXFTimecodeComponent*)component; + flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0; + if (av_timecode_init(&tc, mxf_tc->rate, flags, mxf_tc->start_frame, mxf->fc) == 0) { + mxf_add_timecode_metadata(&mxf->fc->metadata, ""timecode"", &tc); + } + } + + if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref, Sequence))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve material track sequence strong ref\n""); + continue; + } + + for (j = 0; j < material_track->sequence->structural_components_count; j++) { + component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j], TimecodeComponent); + if (!component) + continue; + + mxf_tc = (MXFTimecodeComponent*)component; + flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0; + if (av_timecode_init(&tc, mxf_tc->rate, flags, mxf_tc->start_frame, mxf->fc) == 0) { + mxf_add_timecode_metadata(&mxf->fc->metadata, ""timecode"", &tc); + break; + } + } + + /* TODO: handle multiple source clips, only finds first valid source clip */ + if(material_track->sequence->structural_components_count > 1) + av_log(mxf->fc, AV_LOG_WARNING, ""material track %d: has %d components\n"", + material_track->track_id, material_track->sequence->structural_components_count); + + for (j = 0; j < material_track->sequence->structural_components_count; j++) { + component = mxf_resolve_sourceclip(mxf, &material_track->sequence->structural_components_refs[j]); + if (!component) + continue; + + source_package = mxf_resolve_source_package(mxf, component->source_package_ul, component->source_package_uid); + if (!source_package) { + av_log(mxf->fc, AV_LOG_TRACE, ""material track %d: no corresponding source package found\n"", material_track->track_id); + continue; + } + for (k = 0; k < source_package->tracks_count; k++) { + if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k], Track))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve source track strong ref\n""); + ret = AVERROR_INVALIDDATA; + goto fail_and_free; + } + if (temp_track->track_id == component->source_track_id) { + source_track = temp_track; + break; + } + } + if (!source_track) { + av_log(mxf->fc, AV_LOG_ERROR, ""material track %d: no corresponding source track found\n"", material_track->track_id); + break; + } + + for (k = 0; k < mxf->essence_container_data_count; k++) { + MXFEssenceContainerData *essence_data; + + if (!(essence_data = mxf_resolve_strong_ref(mxf, &mxf->essence_container_data_refs[k], EssenceContainerData))) { + av_log(mxf, AV_LOG_TRACE, ""could not resolve essence container data strong ref\n""); + continue; + } + if (!memcmp(component->source_package_ul, essence_data->package_ul, sizeof(UID)) && !memcmp(component->source_package_uid, essence_data->package_uid, sizeof(UID))) { + source_track->body_sid = essence_data->body_sid; + source_track->index_sid = essence_data->index_sid; + break; + } + } + + if(source_track && component) + break; + } + if (!source_track || !component || !source_package) { + if((ret = mxf_add_metadata_stream(mxf, material_track))) + goto fail_and_free; + continue; + } + + if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve source track sequence strong ref\n""); + ret = AVERROR_INVALIDDATA; + goto fail_and_free; + } + + /* 0001GL00.MXF.A1.mxf_opatom.mxf has the same SourcePackageID as 0001GL.MXF.V1.mxf_opatom.mxf + * This would result in both files appearing to have two streams. Work around this by sanity checking DataDefinition */ + if (memcmp(material_track->sequence->data_definition_ul, source_track->sequence->data_definition_ul, 16)) { + av_log(mxf->fc, AV_LOG_ERROR, ""material track %d: DataDefinition mismatch\n"", material_track->track_id); + continue; + } + + st = avformat_new_stream(mxf->fc, NULL); + if (!st) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not allocate stream\n""); + ret = AVERROR(ENOMEM); + goto fail_and_free; + } + st->id = material_track->track_id; + st->priv_data = source_track; + + source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref, AnyType); + descriptor = mxf_resolve_multidescriptor(mxf, source_package->descriptor, source_track->track_id); + + /* A SourceClip from a EssenceGroup may only be a single frame of essence data. The clips duration is then how many + * frames its suppose to repeat for. Descriptor->duration, if present, contains the real duration of the essence data */ + if (descriptor && descriptor->duration != AV_NOPTS_VALUE) + source_track->original_duration = st->duration = FFMIN(descriptor->duration, component->duration); + else + source_track->original_duration = st->duration = component->duration; + + if (st->duration == -1) + st->duration = AV_NOPTS_VALUE; + st->start_time = component->start_position; + if (material_track->edit_rate.num <= 0 || + material_track->edit_rate.den <= 0) { + av_log(mxf->fc, AV_LOG_WARNING, + ""Invalid edit rate (%d/%d) found on stream #%d, "" + ""defaulting to 25/1\n"", + material_track->edit_rate.num, + material_track->edit_rate.den, st->index); + material_track->edit_rate = (AVRational){25, 1}; + } + avpriv_set_pts_info(st, 64, material_track->edit_rate.den, material_track->edit_rate.num); + + /* ensure SourceTrack EditRate == MaterialTrack EditRate since only + * the former is accessible via st->priv_data */ + source_track->edit_rate = material_track->edit_rate; + + PRINT_KEY(mxf->fc, ""data definition ul"", source_track->sequence->data_definition_ul); + codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, &source_track->sequence->data_definition_ul); + st->codecpar->codec_type = codec_ul->id; + + if (!descriptor) { + av_log(mxf->fc, AV_LOG_INFO, ""source track %d: stream %d, no descriptor found\n"", source_track->track_id, st->index); + continue; + } + PRINT_KEY(mxf->fc, ""essence codec ul"", descriptor->essence_codec_ul); + PRINT_KEY(mxf->fc, ""essence container ul"", descriptor->essence_container_ul); + essence_container_ul = &descriptor->essence_container_ul; + source_track->wrapping = (mxf->op == OPAtom) ? ClipWrapped : mxf_get_wrapping_kind(essence_container_ul); + if (source_track->wrapping == UnknownWrapped) + av_log(mxf->fc, AV_LOG_INFO, ""wrapping of stream %d is unknown\n"", st->index); + /* HACK: replacing the original key with mxf_encrypted_essence_container + * is not allowed according to s429-6, try to find correct information anyway */ + if (IS_KLV_KEY(essence_container_ul, mxf_encrypted_essence_container)) { + av_log(mxf->fc, AV_LOG_INFO, ""broken encrypted mxf file\n""); + for (k = 0; k < mxf->metadata_sets_count; k++) { + MXFMetadataSet *metadata = mxf->metadata_sets[k]; + if (metadata->type == CryptoContext) { + essence_container_ul = &((MXFCryptoContext *)metadata)->source_container_ul; + break; + } + } + } + + /* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */ + codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->essence_codec_ul); + st->codecpar->codec_id = (enum AVCodecID)codec_ul->id; + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) { + codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->codec_ul); + st->codecpar->codec_id = (enum AVCodecID)codec_ul->id; + } + + av_log(mxf->fc, AV_LOG_VERBOSE, ""%s: Universal Label: "", + avcodec_get_name(st->codecpar->codec_id)); + for (k = 0; k < 16; k++) { + av_log(mxf->fc, AV_LOG_VERBOSE, ""%.2x"", + descriptor->essence_codec_ul[k]); + if (!(k+1 & 19) || k == 5) + av_log(mxf->fc, AV_LOG_VERBOSE, "".""); + } + av_log(mxf->fc, AV_LOG_VERBOSE, ""\n""); + + mxf_add_umid_metadata(&st->metadata, ""file_package_umid"", source_package); + if (source_package->name && source_package->name[0]) + av_dict_set(&st->metadata, ""file_package_name"", source_package->name, 0); + if (material_track->name && material_track->name[0]) + av_dict_set(&st->metadata, ""track_name"", material_track->name, 0); + + mxf_parse_physical_source_package(mxf, source_track, st); + + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + source_track->intra_only = mxf_is_intra_only(descriptor); + container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + st->codecpar->codec_id = container_ul->id; + st->codecpar->width = descriptor->width; + st->codecpar->height = descriptor->height; /* Field height, not frame height */ + switch (descriptor->frame_layout) { + case FullFrame: + st->codecpar->field_order = AV_FIELD_PROGRESSIVE; + break; + case OneField: + /* Every other line is stored and needs to be duplicated. */ + av_log(mxf->fc, AV_LOG_INFO, ""OneField frame layout isn't currently supported\n""); + break; /* The correct thing to do here is fall through, but by breaking we might be + able to decode some streams at half the vertical resolution, rather than not al all. + It's also for compatibility with the old behavior. */ + case MixedFields: + break; + case SegmentedFrame: + st->codecpar->field_order = AV_FIELD_PROGRESSIVE; + case SeparateFields: + av_log(mxf->fc, AV_LOG_DEBUG, ""video_line_map: (%d, %d), field_dominance: %d\n"", + descriptor->video_line_map[0], descriptor->video_line_map[1], + descriptor->field_dominance); + if ((descriptor->video_line_map[0] > 0) && (descriptor->video_line_map[1] > 0)) { + /* Detect coded field order from VideoLineMap: + * (even, even) => bottom field coded first + * (even, odd) => top field coded first + * (odd, even) => top field coded first + * (odd, odd) => bottom field coded first + */ + if ((descriptor->video_line_map[0] + descriptor->video_line_map[1]) % 2) { + switch (descriptor->field_dominance) { + case MXF_FIELD_DOMINANCE_DEFAULT: + case MXF_FIELD_DOMINANCE_FF: + st->codecpar->field_order = AV_FIELD_TT; + break; + case MXF_FIELD_DOMINANCE_FL: + st->codecpar->field_order = AV_FIELD_TB; + break; + default: + avpriv_request_sample(mxf->fc, + ""Field dominance %d support"", + descriptor->field_dominance); + } + } else { + switch (descriptor->field_dominance) { + case MXF_FIELD_DOMINANCE_DEFAULT: + case MXF_FIELD_DOMINANCE_FF: + st->codecpar->field_order = AV_FIELD_BB; + break; + case MXF_FIELD_DOMINANCE_FL: + st->codecpar->field_order = AV_FIELD_BT; + break; + default: + avpriv_request_sample(mxf->fc, + ""Field dominance %d support"", + descriptor->field_dominance); + } + } + } + /* Turn field height into frame height. */ + st->codecpar->height *= 2; + break; + default: + av_log(mxf->fc, AV_LOG_INFO, ""Unknown frame layout type: %d\n"", descriptor->frame_layout); + } + if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) { + st->codecpar->format = descriptor->pix_fmt; + if (st->codecpar->format == AV_PIX_FMT_NONE) { + pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls, + &descriptor->essence_codec_ul); + st->codecpar->format = (enum AVPixelFormat)pix_fmt_ul->id; + if (st->codecpar->format== AV_PIX_FMT_NONE) { + st->codecpar->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls, + &descriptor->essence_codec_ul)->id; + if (!st->codecpar->codec_tag) { + /* support files created before RP224v10 by defaulting to UYVY422 + if subsampling is 4:2:2 and component depth is 8-bit */ + if (descriptor->horiz_subsampling == 2 && + descriptor->vert_subsampling == 1 && + descriptor->component_depth == 8) { + st->codecpar->format = AV_PIX_FMT_UYVY422; + } + } + } + } + } + st->need_parsing = AVSTREAM_PARSE_HEADERS; + if (material_track->sequence->origin) { + av_dict_set_int(&st->metadata, ""material_track_origin"", material_track->sequence->origin, 0); + } + if (source_track->sequence->origin) { + av_dict_set_int(&st->metadata, ""source_track_origin"", source_track->sequence->origin, 0); + } + if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) + st->display_aspect_ratio = descriptor->aspect_ratio; + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul); + /* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */ + if (st->codecpar->codec_id == AV_CODEC_ID_NONE || (st->codecpar->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE)) + st->codecpar->codec_id = (enum AVCodecID)container_ul->id; + st->codecpar->channels = descriptor->channels; + st->codecpar->bits_per_coded_sample = descriptor->bits_per_sample; + + if (descriptor->sample_rate.den > 0) { + st->codecpar->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den; + avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num); + } else { + av_log(mxf->fc, AV_LOG_WARNING, ""invalid sample rate (%d/%d) "" + ""found for stream #%d, time base forced to 1/48000\n"", + descriptor->sample_rate.num, descriptor->sample_rate.den, + st->index); + avpriv_set_pts_info(st, 64, 1, 48000); + } + + /* if duration is set, rescale it from EditRate to SampleRate */ + if (st->duration != AV_NOPTS_VALUE) + st->duration = av_rescale_q(st->duration, + av_inv_q(material_track->edit_rate), + st->time_base); + + /* TODO: implement AV_CODEC_ID_RAWAUDIO */ + if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) { + if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; + else if (descriptor->bits_per_sample == 32) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; + } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) { + if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S24BE; + else if (descriptor->bits_per_sample == 32) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE; + } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) { + st->need_parsing = AVSTREAM_PARSE_FULL; + } + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { + enum AVMediaType type; + container_ul = mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + st->codecpar->codec_id = container_ul->id; + type = avcodec_get_type(st->codecpar->codec_id); + if (type == AVMEDIA_TYPE_SUBTITLE) + st->codecpar->codec_type = type; + if (container_ul->desc) + av_dict_set(&st->metadata, ""data_type"", container_ul->desc, 0); + } + if (descriptor->extradata) { + if (!ff_alloc_extradata(st->codecpar, descriptor->extradata_size)) { + memcpy(st->codecpar->extradata, descriptor->extradata, descriptor->extradata_size); + } + } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) { + int coded_width = mxf_get_codec_ul(mxf_intra_only_picture_coded_width, + &descriptor->essence_codec_ul)->id; + if (coded_width) + st->codecpar->width = coded_width; + ret = ff_generate_avci_extradata(st); + if (ret < 0) + return ret; + } + if (st->codecpar->codec_type != AVMEDIA_TYPE_DATA && source_track->wrapping != FrameWrapped) { + /* TODO: decode timestamps */ + st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; + } + } + + ret = 0; +fail_and_free: + return ret; +} +",1,"static int mxf_parse_structural_metadata(MXFContext *mxf) +{ + MXFPackage *material_package = NULL; + int i, j, k, ret; + + av_log(mxf->fc, AV_LOG_TRACE, ""metadata sets count %d\n"", mxf->metadata_sets_count); + /* TODO: handle multiple material packages (OP3x) */ + for (i = 0; i < mxf->packages_count; i++) { + material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage); + if (material_package) break; + } + if (!material_package) { + av_log(mxf->fc, AV_LOG_ERROR, ""no material package found\n""); + return AVERROR_INVALIDDATA; + } + + mxf_add_umid_metadata(&mxf->fc->metadata, ""material_package_umid"", material_package); + if (material_package->name && material_package->name[0]) + av_dict_set(&mxf->fc->metadata, ""material_package_name"", material_package->name, 0); + mxf_parse_package_comments(mxf, &mxf->fc->metadata, material_package); + + for (i = 0; i < material_package->tracks_count; i++) { + MXFPackage *source_package = NULL; + MXFTrack *material_track = NULL; + MXFTrack *source_track = NULL; + MXFTrack *temp_track = NULL; + MXFDescriptor *descriptor = NULL; + MXFStructuralComponent *component = NULL; + MXFTimecodeComponent *mxf_tc = NULL; + UID *essence_container_ul = NULL; + const MXFCodecUL *codec_ul = NULL; + const MXFCodecUL *container_ul = NULL; + const MXFCodecUL *pix_fmt_ul = NULL; + AVStream *st; + AVTimecode tc; + int flags; + + if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i], Track))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve material track strong ref\n""); + continue; + } + + if ((component = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref, TimecodeComponent))) { + mxf_tc = (MXFTimecodeComponent*)component; + flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0; + if (av_timecode_init(&tc, mxf_tc->rate, flags, mxf_tc->start_frame, mxf->fc) == 0) { + mxf_add_timecode_metadata(&mxf->fc->metadata, ""timecode"", &tc); + } + } + + if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref, Sequence))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve material track sequence strong ref\n""); + continue; + } + + for (j = 0; j < material_track->sequence->structural_components_count; j++) { + component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j], TimecodeComponent); + if (!component) + continue; + + mxf_tc = (MXFTimecodeComponent*)component; + flags = mxf_tc->drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0; + if (av_timecode_init(&tc, mxf_tc->rate, flags, mxf_tc->start_frame, mxf->fc) == 0) { + mxf_add_timecode_metadata(&mxf->fc->metadata, ""timecode"", &tc); + break; + } + } + + /* TODO: handle multiple source clips, only finds first valid source clip */ + if(material_track->sequence->structural_components_count > 1) + av_log(mxf->fc, AV_LOG_WARNING, ""material track %d: has %d components\n"", + material_track->track_id, material_track->sequence->structural_components_count); + + for (j = 0; j < material_track->sequence->structural_components_count; j++) { + component = mxf_resolve_sourceclip(mxf, &material_track->sequence->structural_components_refs[j]); + if (!component) + continue; + + source_package = mxf_resolve_source_package(mxf, component->source_package_ul, component->source_package_uid); + if (!source_package) { + av_log(mxf->fc, AV_LOG_TRACE, ""material track %d: no corresponding source package found\n"", material_track->track_id); + continue; + } + for (k = 0; k < source_package->tracks_count; k++) { + if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k], Track))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve source track strong ref\n""); + ret = AVERROR_INVALIDDATA; + goto fail_and_free; + } + if (temp_track->track_id == component->source_track_id) { + source_track = temp_track; + break; + } + } + if (!source_track) { + av_log(mxf->fc, AV_LOG_ERROR, ""material track %d: no corresponding source track found\n"", material_track->track_id); + break; + } + + for (k = 0; k < mxf->essence_container_data_count; k++) { + MXFEssenceContainerData *essence_data; + + if (!(essence_data = mxf_resolve_strong_ref(mxf, &mxf->essence_container_data_refs[k], EssenceContainerData))) { + av_log(mxf->fc, AV_LOG_TRACE, ""could not resolve essence container data strong ref\n""); + continue; + } + if (!memcmp(component->source_package_ul, essence_data->package_ul, sizeof(UID)) && !memcmp(component->source_package_uid, essence_data->package_uid, sizeof(UID))) { + source_track->body_sid = essence_data->body_sid; + source_track->index_sid = essence_data->index_sid; + break; + } + } + + if(source_track && component) + break; + } + if (!source_track || !component || !source_package) { + if((ret = mxf_add_metadata_stream(mxf, material_track))) + goto fail_and_free; + continue; + } + + if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not resolve source track sequence strong ref\n""); + ret = AVERROR_INVALIDDATA; + goto fail_and_free; + } + + /* 0001GL00.MXF.A1.mxf_opatom.mxf has the same SourcePackageID as 0001GL.MXF.V1.mxf_opatom.mxf + * This would result in both files appearing to have two streams. Work around this by sanity checking DataDefinition */ + if (memcmp(material_track->sequence->data_definition_ul, source_track->sequence->data_definition_ul, 16)) { + av_log(mxf->fc, AV_LOG_ERROR, ""material track %d: DataDefinition mismatch\n"", material_track->track_id); + continue; + } + + st = avformat_new_stream(mxf->fc, NULL); + if (!st) { + av_log(mxf->fc, AV_LOG_ERROR, ""could not allocate stream\n""); + ret = AVERROR(ENOMEM); + goto fail_and_free; + } + st->id = material_track->track_id; + st->priv_data = source_track; + + source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref, AnyType); + descriptor = mxf_resolve_multidescriptor(mxf, source_package->descriptor, source_track->track_id); + + /* A SourceClip from a EssenceGroup may only be a single frame of essence data. The clips duration is then how many + * frames its suppose to repeat for. Descriptor->duration, if present, contains the real duration of the essence data */ + if (descriptor && descriptor->duration != AV_NOPTS_VALUE) + source_track->original_duration = st->duration = FFMIN(descriptor->duration, component->duration); + else + source_track->original_duration = st->duration = component->duration; + + if (st->duration == -1) + st->duration = AV_NOPTS_VALUE; + st->start_time = component->start_position; + if (material_track->edit_rate.num <= 0 || + material_track->edit_rate.den <= 0) { + av_log(mxf->fc, AV_LOG_WARNING, + ""Invalid edit rate (%d/%d) found on stream #%d, "" + ""defaulting to 25/1\n"", + material_track->edit_rate.num, + material_track->edit_rate.den, st->index); + material_track->edit_rate = (AVRational){25, 1}; + } + avpriv_set_pts_info(st, 64, material_track->edit_rate.den, material_track->edit_rate.num); + + /* ensure SourceTrack EditRate == MaterialTrack EditRate since only + * the former is accessible via st->priv_data */ + source_track->edit_rate = material_track->edit_rate; + + PRINT_KEY(mxf->fc, ""data definition ul"", source_track->sequence->data_definition_ul); + codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, &source_track->sequence->data_definition_ul); + st->codecpar->codec_type = codec_ul->id; + + if (!descriptor) { + av_log(mxf->fc, AV_LOG_INFO, ""source track %d: stream %d, no descriptor found\n"", source_track->track_id, st->index); + continue; + } + PRINT_KEY(mxf->fc, ""essence codec ul"", descriptor->essence_codec_ul); + PRINT_KEY(mxf->fc, ""essence container ul"", descriptor->essence_container_ul); + essence_container_ul = &descriptor->essence_container_ul; + source_track->wrapping = (mxf->op == OPAtom) ? ClipWrapped : mxf_get_wrapping_kind(essence_container_ul); + if (source_track->wrapping == UnknownWrapped) + av_log(mxf->fc, AV_LOG_INFO, ""wrapping of stream %d is unknown\n"", st->index); + /* HACK: replacing the original key with mxf_encrypted_essence_container + * is not allowed according to s429-6, try to find correct information anyway */ + if (IS_KLV_KEY(essence_container_ul, mxf_encrypted_essence_container)) { + av_log(mxf->fc, AV_LOG_INFO, ""broken encrypted mxf file\n""); + for (k = 0; k < mxf->metadata_sets_count; k++) { + MXFMetadataSet *metadata = mxf->metadata_sets[k]; + if (metadata->type == CryptoContext) { + essence_container_ul = &((MXFCryptoContext *)metadata)->source_container_ul; + break; + } + } + } + + /* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */ + codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->essence_codec_ul); + st->codecpar->codec_id = (enum AVCodecID)codec_ul->id; + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) { + codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->codec_ul); + st->codecpar->codec_id = (enum AVCodecID)codec_ul->id; + } + + av_log(mxf->fc, AV_LOG_VERBOSE, ""%s: Universal Label: "", + avcodec_get_name(st->codecpar->codec_id)); + for (k = 0; k < 16; k++) { + av_log(mxf->fc, AV_LOG_VERBOSE, ""%.2x"", + descriptor->essence_codec_ul[k]); + if (!(k+1 & 19) || k == 5) + av_log(mxf->fc, AV_LOG_VERBOSE, "".""); + } + av_log(mxf->fc, AV_LOG_VERBOSE, ""\n""); + + mxf_add_umid_metadata(&st->metadata, ""file_package_umid"", source_package); + if (source_package->name && source_package->name[0]) + av_dict_set(&st->metadata, ""file_package_name"", source_package->name, 0); + if (material_track->name && material_track->name[0]) + av_dict_set(&st->metadata, ""track_name"", material_track->name, 0); + + mxf_parse_physical_source_package(mxf, source_track, st); + + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + source_track->intra_only = mxf_is_intra_only(descriptor); + container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + st->codecpar->codec_id = container_ul->id; + st->codecpar->width = descriptor->width; + st->codecpar->height = descriptor->height; /* Field height, not frame height */ + switch (descriptor->frame_layout) { + case FullFrame: + st->codecpar->field_order = AV_FIELD_PROGRESSIVE; + break; + case OneField: + /* Every other line is stored and needs to be duplicated. */ + av_log(mxf->fc, AV_LOG_INFO, ""OneField frame layout isn't currently supported\n""); + break; /* The correct thing to do here is fall through, but by breaking we might be + able to decode some streams at half the vertical resolution, rather than not al all. + It's also for compatibility with the old behavior. */ + case MixedFields: + break; + case SegmentedFrame: + st->codecpar->field_order = AV_FIELD_PROGRESSIVE; + case SeparateFields: + av_log(mxf->fc, AV_LOG_DEBUG, ""video_line_map: (%d, %d), field_dominance: %d\n"", + descriptor->video_line_map[0], descriptor->video_line_map[1], + descriptor->field_dominance); + if ((descriptor->video_line_map[0] > 0) && (descriptor->video_line_map[1] > 0)) { + /* Detect coded field order from VideoLineMap: + * (even, even) => bottom field coded first + * (even, odd) => top field coded first + * (odd, even) => top field coded first + * (odd, odd) => bottom field coded first + */ + if ((descriptor->video_line_map[0] + descriptor->video_line_map[1]) % 2) { + switch (descriptor->field_dominance) { + case MXF_FIELD_DOMINANCE_DEFAULT: + case MXF_FIELD_DOMINANCE_FF: + st->codecpar->field_order = AV_FIELD_TT; + break; + case MXF_FIELD_DOMINANCE_FL: + st->codecpar->field_order = AV_FIELD_TB; + break; + default: + avpriv_request_sample(mxf->fc, + ""Field dominance %d support"", + descriptor->field_dominance); + } + } else { + switch (descriptor->field_dominance) { + case MXF_FIELD_DOMINANCE_DEFAULT: + case MXF_FIELD_DOMINANCE_FF: + st->codecpar->field_order = AV_FIELD_BB; + break; + case MXF_FIELD_DOMINANCE_FL: + st->codecpar->field_order = AV_FIELD_BT; + break; + default: + avpriv_request_sample(mxf->fc, + ""Field dominance %d support"", + descriptor->field_dominance); + } + } + } + /* Turn field height into frame height. */ + st->codecpar->height *= 2; + break; + default: + av_log(mxf->fc, AV_LOG_INFO, ""Unknown frame layout type: %d\n"", descriptor->frame_layout); + } + if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) { + st->codecpar->format = descriptor->pix_fmt; + if (st->codecpar->format == AV_PIX_FMT_NONE) { + pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls, + &descriptor->essence_codec_ul); + st->codecpar->format = (enum AVPixelFormat)pix_fmt_ul->id; + if (st->codecpar->format== AV_PIX_FMT_NONE) { + st->codecpar->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls, + &descriptor->essence_codec_ul)->id; + if (!st->codecpar->codec_tag) { + /* support files created before RP224v10 by defaulting to UYVY422 + if subsampling is 4:2:2 and component depth is 8-bit */ + if (descriptor->horiz_subsampling == 2 && + descriptor->vert_subsampling == 1 && + descriptor->component_depth == 8) { + st->codecpar->format = AV_PIX_FMT_UYVY422; + } + } + } + } + } + st->need_parsing = AVSTREAM_PARSE_HEADERS; + if (material_track->sequence->origin) { + av_dict_set_int(&st->metadata, ""material_track_origin"", material_track->sequence->origin, 0); + } + if (source_track->sequence->origin) { + av_dict_set_int(&st->metadata, ""source_track_origin"", source_track->sequence->origin, 0); + } + if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) + st->display_aspect_ratio = descriptor->aspect_ratio; + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul); + /* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */ + if (st->codecpar->codec_id == AV_CODEC_ID_NONE || (st->codecpar->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE)) + st->codecpar->codec_id = (enum AVCodecID)container_ul->id; + st->codecpar->channels = descriptor->channels; + st->codecpar->bits_per_coded_sample = descriptor->bits_per_sample; + + if (descriptor->sample_rate.den > 0) { + st->codecpar->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den; + avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num); + } else { + av_log(mxf->fc, AV_LOG_WARNING, ""invalid sample rate (%d/%d) "" + ""found for stream #%d, time base forced to 1/48000\n"", + descriptor->sample_rate.num, descriptor->sample_rate.den, + st->index); + avpriv_set_pts_info(st, 64, 1, 48000); + } + + /* if duration is set, rescale it from EditRate to SampleRate */ + if (st->duration != AV_NOPTS_VALUE) + st->duration = av_rescale_q(st->duration, + av_inv_q(material_track->edit_rate), + st->time_base); + + /* TODO: implement AV_CODEC_ID_RAWAUDIO */ + if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) { + if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; + else if (descriptor->bits_per_sample == 32) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; + } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) { + if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S24BE; + else if (descriptor->bits_per_sample == 32) + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE; + } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) { + st->need_parsing = AVSTREAM_PARSE_FULL; + } + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { + enum AVMediaType type; + container_ul = mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul); + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) + st->codecpar->codec_id = container_ul->id; + type = avcodec_get_type(st->codecpar->codec_id); + if (type == AVMEDIA_TYPE_SUBTITLE) + st->codecpar->codec_type = type; + if (container_ul->desc) + av_dict_set(&st->metadata, ""data_type"", container_ul->desc, 0); + } + if (descriptor->extradata) { + if (!ff_alloc_extradata(st->codecpar, descriptor->extradata_size)) { + memcpy(st->codecpar->extradata, descriptor->extradata, descriptor->extradata_size); + } + } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) { + int coded_width = mxf_get_codec_ul(mxf_intra_only_picture_coded_width, + &descriptor->essence_codec_ul)->id; + if (coded_width) + st->codecpar->width = coded_width; + ret = ff_generate_avci_extradata(st); + if (ret < 0) + return ret; + } + if (st->codecpar->codec_type != AVMEDIA_TYPE_DATA && source_track->wrapping != FrameWrapped) { + /* TODO: decode timestamps */ + st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; + } + } + + ret = 0; +fail_and_free: + return ret; +} +","@@ -2155,7 +2155,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) + MXFEssenceContainerData *essence_data; + + if (!(essence_data = mxf_resolve_strong_ref(mxf, &mxf->essence_container_data_refs[k], EssenceContainerData))) { +- av_log(mxf, AV_LOG_TRACE, ""could not resolve essence container data strong ref\n""); ++ av_log(mxf->fc, AV_LOG_TRACE, ""could not resolve essence container data strong ref\n""); + continue; + } + if (!memcmp(component->source_package_ul, essence_data->package_ul, sizeof(UID)) && !memcmp(component->source_package_uid, essence_data->package_uid, sizeof(UID))) {",4818,5054,6144 +18210,"static Image *ReadPICTImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ +#define ThrowPICTException(exception,message) \ +{ \ + if (tile_image != (Image *) NULL) \ + tile_image=DestroyImage(tile_image); \ + if (read_info != (ImageInfo *) NULL) \ + read_info=DestroyImageInfo(read_info); \ + ThrowReaderException((exception),(message)); \ +} + + char + geometry[MagickPathExtent], + header_ole[4]; + + Image + *image, + *tile_image; + + ImageInfo + *read_info; + + int + c, + code; + + MagickBooleanType + jpeg, + status; + + PICTRectangle + frame; + + PICTPixmap + pixmap; + + Quantum + index; + + register Quantum + *q; + + register ssize_t + i, + x; + + size_t + extent, + length; + + ssize_t + count, + flags, + j, + version, + y; + + StringInfo + *profile; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read PICT header. + */ + read_info=(ImageInfo *) NULL; + tile_image=(Image *) NULL; + pixmap.bits_per_pixel=0; + pixmap.component_count=0; + /* + Skip header : 512 for standard PICT and 4, ie ""PICT"" for OLE2. + */ + header_ole[0]=ReadBlobByte(image); + header_ole[1]=ReadBlobByte(image); + header_ole[2]=ReadBlobByte(image); + header_ole[3]=ReadBlobByte(image); + if (!((header_ole[0] == 0x50) && (header_ole[1] == 0x49) && + (header_ole[2] == 0x43) && (header_ole[3] == 0x54 ))) + for (i=0; i < 508; i++) + if (ReadBlobByte(image) == EOF) + break; + (void) ReadBlobMSBShort(image); /* skip picture size */ + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + while ((c=ReadBlobByte(image)) == 0) ; + if (c != 0x11) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + version=(ssize_t) ReadBlobByte(image); + if (version == 2) + { + c=ReadBlobByte(image); + if (c != 0xff) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + } + else + if (version != 1) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if ((frame.left < 0) || (frame.right < 0) || (frame.top < 0) || + (frame.bottom < 0) || (frame.left >= frame.right) || + (frame.top >= frame.bottom)) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + /* + Create black canvas. + */ + flags=0; + image->depth=8; + image->columns=(size_t) (frame.right-frame.left); + image->rows=(size_t) (frame.bottom-frame.top); + image->resolution.x=DefaultResolution; + image->resolution.y=DefaultResolution; + image->units=UndefinedResolution; + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status != MagickFalse) + status=ResetImagePixels(image,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + /* + Interpret PICT opcodes. + */ + jpeg=MagickFalse; + for (code=0; EOFBlob(image) == MagickFalse; ) + { + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if ((version == 1) || ((TellBlob(image) % 2) != 0)) + code=ReadBlobByte(image); + if (version == 2) + code=ReadBlobMSBSignedShort(image); + if (code < 0) + break; + if (code == 0) + continue; + if (code > 0xa1) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%04X:"",code); + } + else + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" %04X %s: %s"",code,codes[code].name,codes[code].description); + switch (code) + { + case 0x01: + { + /* + Clipping rectangle. + */ + length=ReadBlobMSBShort(image); + if (length != 0x000a) + { + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; + break; + } + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (((frame.left & 0x8000) != 0) || ((frame.top & 0x8000) != 0)) + break; + image->columns=(size_t) (frame.right-frame.left); + image->rows=(size_t) (frame.bottom-frame.top); + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status != MagickFalse) + status=ResetImagePixels(image,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + break; + } + case 0x12: + case 0x13: + case 0x14: + { + ssize_t + pattern; + + size_t + height, + width; + + /* + Skip pattern definition. + */ + pattern=(ssize_t) ReadBlobMSBShort(image); + for (i=0; i < 8; i++) + if (ReadBlobByte(image) == EOF) + break; + if (pattern == 2) + { + for (i=0; i < 5; i++) + if (ReadBlobByte(image) == EOF) + break; + break; + } + if (pattern != 1) + ThrowPICTException(CorruptImageError,""UnknownPatternType""); + length=ReadBlobMSBShort(image); + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (ReadPixmap(image,&pixmap) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + image->depth=(size_t) pixmap.component_size; + image->resolution.x=1.0*pixmap.horizontal_resolution; + image->resolution.y=1.0*pixmap.vertical_resolution; + image->units=PixelsPerInchResolution; + (void) ReadBlobMSBLong(image); + flags=(ssize_t) ReadBlobMSBShort(image); + length=ReadBlobMSBShort(image); + for (i=0; i <= (ssize_t) length; i++) + (void) ReadBlobMSBLong(image); + width=(size_t) (frame.bottom-frame.top); + height=(size_t) (frame.right-frame.left); + if (pixmap.bits_per_pixel <= 8) + length&=0x7fff; + if (pixmap.bits_per_pixel == 16) + width<<=1; + if (length == 0) + length=width; + if (length < 8) + { + for (i=0; i < (ssize_t) (length*height); i++) + if (ReadBlobByte(image) == EOF) + break; + } + else + for (i=0; i < (ssize_t) height; i++) + { + if (EOFBlob(image) != MagickFalse) + break; + if (length > 200) + { + for (j=0; j < (ssize_t) ReadBlobMSBShort(image); j++) + if (ReadBlobByte(image) == EOF) + break; + } + else + for (j=0; j < (ssize_t) ReadBlobByte(image); j++) + if (ReadBlobByte(image) == EOF) + break; + } + break; + } + case 0x1b: + { + /* + Initialize image background color. + */ + image->background_color.red=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + image->background_color.green=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + image->background_color.blue=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + break; + } + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + { + /* + Skip polygon or region. + */ + length=ReadBlobMSBShort(image); + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; + break; + } + case 0x90: + case 0x91: + case 0x98: + case 0x99: + case 0x9a: + case 0x9b: + { + PICTRectangle + source, + destination; + + register unsigned char + *p; + + size_t + j; + + ssize_t + bytes_per_line; + + unsigned char + *pixels; + + /* + Pixmap clipped by a rectangle. + */ + bytes_per_line=0; + if ((code != 0x9a) && (code != 0x9b)) + bytes_per_line=(ssize_t) ReadBlobMSBShort(image); + else + { + (void) ReadBlobMSBShort(image); + (void) ReadBlobMSBShort(image); + (void) ReadBlobMSBShort(image); + } + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + /* + Initialize tile image. + */ + tile_image=CloneImage(image,(size_t) (frame.right-frame.left), + (size_t) (frame.bottom-frame.top),MagickTrue,exception); + if (tile_image == (Image *) NULL) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if ((code == 0x9a) || (code == 0x9b) || + ((bytes_per_line & 0x8000) != 0)) + { + if (ReadPixmap(image,&pixmap) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + tile_image->depth=(size_t) pixmap.component_size; + tile_image->alpha_trait=pixmap.component_count == 4 ? + BlendPixelTrait : UndefinedPixelTrait; + tile_image->resolution.x=(double) pixmap.horizontal_resolution; + tile_image->resolution.y=(double) pixmap.vertical_resolution; + tile_image->units=PixelsPerInchResolution; + if (tile_image->alpha_trait != UndefinedPixelTrait) + (void) SetImageAlpha(tile_image,OpaqueAlpha,exception); + } + if ((code != 0x9a) && (code != 0x9b)) + { + /* + Initialize colormap. + */ + tile_image->colors=2; + if ((bytes_per_line & 0x8000) != 0) + { + (void) ReadBlobMSBLong(image); + flags=(ssize_t) ReadBlobMSBShort(image); + tile_image->colors=1UL*ReadBlobMSBShort(image)+1; + } + status=AcquireImageColormap(tile_image,tile_image->colors, + exception); + if (status == MagickFalse) + ThrowPICTException(ResourceLimitError, + ""MemoryAllocationFailed""); + if ((bytes_per_line & 0x8000) != 0) + { + for (i=0; i < (ssize_t) tile_image->colors; i++) + { + j=ReadBlobMSBShort(image) % tile_image->colors; + if ((flags & 0x8000) != 0) + j=(size_t) i; + tile_image->colormap[j].red=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + tile_image->colormap[j].green=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + tile_image->colormap[j].blue=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + } + } + else + { + for (i=0; i < (ssize_t) tile_image->colors; i++) + { + tile_image->colormap[i].red=(Quantum) (QuantumRange- + tile_image->colormap[i].red); + tile_image->colormap[i].green=(Quantum) (QuantumRange- + tile_image->colormap[i].green); + tile_image->colormap[i].blue=(Quantum) (QuantumRange- + tile_image->colormap[i].blue); + } + } + } + if (EOFBlob(image) != MagickFalse) + ThrowPICTException(CorruptImageError, + ""InsufficientImageDataInFile""); + if (ReadRectangle(image,&source) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (ReadRectangle(image,&destination) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + (void) ReadBlobMSBShort(image); + if ((code == 0x91) || (code == 0x99) || (code == 0x9b)) + { + /* + Skip region. + */ + length=ReadBlobMSBShort(image); + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; + } + if ((code != 0x9a) && (code != 0x9b) && + (bytes_per_line & 0x8000) == 0) + pixels=DecodeImage(image,tile_image,(size_t) bytes_per_line,1, + &extent); + else + pixels=DecodeImage(image,tile_image,(size_t) bytes_per_line, + (unsigned int) pixmap.bits_per_pixel,&extent); + if (pixels == (unsigned char *) NULL) + ThrowPICTException(CorruptImageError,""UnableToUncompressImage""); + /* + Convert PICT tile image to pixel packets. + */ + p=pixels; + for (y=0; y < (ssize_t) tile_image->rows; y++) + { + if (p > (pixels+extent+image->columns)) + { + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + ThrowPICTException(CorruptImageError,""NotEnoughPixelData""); + } + q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) tile_image->columns; x++) + { + if (tile_image->storage_class == PseudoClass) + { + index=(Quantum) ConstrainColormapIndex(tile_image,(ssize_t) + *p,exception); + SetPixelIndex(tile_image,index,q); + SetPixelRed(tile_image, + tile_image->colormap[(ssize_t) index].red,q); + SetPixelGreen(tile_image, + tile_image->colormap[(ssize_t) index].green,q); + SetPixelBlue(tile_image, + tile_image->colormap[(ssize_t) index].blue,q); + } + else + { + if (pixmap.bits_per_pixel == 16) + { + i=(ssize_t) (*p++); + j=(size_t) (*p); + SetPixelRed(tile_image,ScaleCharToQuantum( + (unsigned char) ((i & 0x7c) << 1)),q); + SetPixelGreen(tile_image,ScaleCharToQuantum( + (unsigned char) (((i & 0x03) << 6) | + ((j & 0xe0) >> 2))),q); + SetPixelBlue(tile_image,ScaleCharToQuantum( + (unsigned char) ((j & 0x1f) << 3)),q); + } + else + if (tile_image->alpha_trait == UndefinedPixelTrait) + { + if (p > (pixels+extent+2*image->columns)) + ThrowPICTException(CorruptImageError, + ""NotEnoughPixelData""); + SetPixelRed(tile_image,ScaleCharToQuantum(*p),q); + SetPixelGreen(tile_image,ScaleCharToQuantum( + *(p+tile_image->columns)),q); + SetPixelBlue(tile_image,ScaleCharToQuantum( + *(p+2*tile_image->columns)),q); + } + else + { + if (p > (pixels+extent+3*image->columns)) + ThrowPICTException(CorruptImageError, + ""NotEnoughPixelData""); + SetPixelAlpha(tile_image,ScaleCharToQuantum(*p),q); + SetPixelRed(tile_image,ScaleCharToQuantum( + *(p+tile_image->columns)),q); + SetPixelGreen(tile_image,ScaleCharToQuantum( + *(p+2*tile_image->columns)),q); + SetPixelBlue(tile_image,ScaleCharToQuantum( + *(p+3*tile_image->columns)),q); + } + } + p++; + q+=GetPixelChannels(tile_image); + } + if (SyncAuthenticPixels(tile_image,exception) == MagickFalse) + break; + if ((tile_image->storage_class == DirectClass) && + (pixmap.bits_per_pixel != 16)) + { + p+=(pixmap.component_count-1)*tile_image->columns; + if (p < pixels) + break; + } + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + tile_image->rows); + if (status == MagickFalse) + break; + } + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + if ((jpeg == MagickFalse) && (EOFBlob(image) == MagickFalse)) + if ((code == 0x9a) || (code == 0x9b) || + ((bytes_per_line & 0x8000) != 0)) + (void) CompositeImage(image,tile_image,CopyCompositeOp, + MagickTrue,(ssize_t) destination.left,(ssize_t) + destination.top,exception); + tile_image=DestroyImage(tile_image); + break; + } + case 0xa1: + { + unsigned char + *info; + + size_t + type; + + /* + Comment. + */ + type=ReadBlobMSBShort(image); + length=ReadBlobMSBShort(image); + if (length == 0) + break; + (void) ReadBlobMSBLong(image); + length-=MagickMin(length,4); + if (length == 0) + break; + info=(unsigned char *) AcquireQuantumMemory(length,sizeof(*info)); + if (info == (unsigned char *) NULL) + break; + count=ReadBlob(image,length,info); + if (count != (ssize_t) length) + { + info=(unsigned char *) RelinquishMagickMemory(info); + ThrowPICTException(ResourceLimitError,""UnableToReadImageData""); + } + switch (type) + { + case 0xe0: + { + profile=BlobToStringInfo((const void *) NULL,length); + SetStringInfoDatum(profile,info); + status=SetImageProfile(image,""icc"",profile,exception); + profile=DestroyStringInfo(profile); + if (status == MagickFalse) + { + info=(unsigned char *) RelinquishMagickMemory(info); + ThrowPICTException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + break; + } + case 0x1f2: + { + profile=BlobToStringInfo((const void *) NULL,length); + SetStringInfoDatum(profile,info); + status=SetImageProfile(image,""iptc"",profile,exception); + if (status == MagickFalse) + { + info=(unsigned char *) RelinquishMagickMemory(info); + ThrowPICTException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + profile=DestroyStringInfo(profile); + break; + } + default: + break; + } + info=(unsigned char *) RelinquishMagickMemory(info); + break; + } + default: + { + /* + Skip to next op code. + */ + if (codes[code].length == -1) + (void) ReadBlobMSBShort(image); + else + for (i=0; i < (ssize_t) codes[code].length; i++) + if (ReadBlobByte(image) == EOF) + break; + } + } + } + if (code == 0xc00) + { + /* + Skip header. + */ + for (i=0; i < 24; i++) + if (ReadBlobByte(image) == EOF) + break; + continue; + } + if (((code >= 0xb0) && (code <= 0xcf)) || + ((code >= 0x8000) && (code <= 0x80ff))) + continue; + if (code == 0x8200) + { + char + filename[MaxTextExtent]; + + FILE + *file; + + int + unique_file; + + /* + Embedded JPEG. + */ + jpeg=MagickTrue; + read_info=CloneImageInfo(image_info); + SetImageInfoBlob(read_info,(void *) NULL,0); + file=(FILE *) NULL; + unique_file=AcquireUniqueFileResource(filename); + (void) FormatLocaleString(read_info->filename,MaxTextExtent,""jpeg:%s"", + filename); + if (unique_file != -1) + file=fdopen(unique_file,""wb""); + if ((unique_file == -1) || (file == (FILE *) NULL)) + { + (void) RelinquishUniqueFileResource(read_info->filename); + (void) CopyMagickString(image->filename,read_info->filename, + MagickPathExtent); + ThrowPICTException(FileOpenError,""UnableToCreateTemporaryFile""); + } + length=ReadBlobMSBLong(image); + if (length > 154) + { + for (i=0; i < 6; i++) + (void) ReadBlobMSBLong(image); + if (ReadRectangle(image,&frame) == MagickFalse) + { + (void) fclose(file); + (void) RelinquishUniqueFileResource(read_info->filename); + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + } + for (i=0; i < 122; i++) + if (ReadBlobByte(image) == EOF) + break; + for (i=0; i < (ssize_t) (length-154); i++) + { + c=ReadBlobByte(image); + if (c == EOF) + break; + (void) fputc(c,file); + } + } + (void) fclose(file); + (void) close(unique_file); + tile_image=ReadImage(read_info,exception); + (void) RelinquishUniqueFileResource(filename); + read_info=DestroyImageInfo(read_info); + if (tile_image == (Image *) NULL) + continue; + (void) FormatLocaleString(geometry,MagickPathExtent,""%.20gx%.20g"", + (double) MagickMax(image->columns,tile_image->columns), + (double) MagickMax(image->rows,tile_image->rows)); + (void) SetImageExtent(image, + MagickMax(image->columns,tile_image->columns), + MagickMax(image->rows,tile_image->rows),exception); + (void) TransformImageColorspace(image,tile_image->colorspace,exception); + (void) CompositeImage(image,tile_image,CopyCompositeOp,MagickTrue, + (ssize_t) frame.left,(ssize_t) frame.right,exception); + image->compression=tile_image->compression; + tile_image=DestroyImage(tile_image); + continue; + } + if ((code == 0xff) || (code == 0xffff)) + break; + if (((code >= 0xd0) && (code <= 0xfe)) || + ((code >= 0x8100) && (code <= 0xffff))) + { + /* + Skip reserved. + */ + length=ReadBlobMSBShort(image); + for (i=0; i < (ssize_t) length; i++) + if (ReadBlobByte(image) == EOF) + break; + continue; + } + if ((code >= 0x100) && (code <= 0x7fff)) + { + /* + Skip reserved. + */ + length=(size_t) ((code >> 7) & 0xff); + for (i=0; i < (ssize_t) length; i++) + if (ReadBlobByte(image) == EOF) + break; + continue; + } + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadPICTImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ +#define ThrowPICTException(exception,message) \ +{ \ + if (tile_image != (Image *) NULL) \ + tile_image=DestroyImage(tile_image); \ + if (read_info != (ImageInfo *) NULL) \ + read_info=DestroyImageInfo(read_info); \ + ThrowReaderException((exception),(message)); \ +} + + char + geometry[MagickPathExtent], + header_ole[4]; + + Image + *image, + *tile_image; + + ImageInfo + *read_info; + + int + c, + code; + + MagickBooleanType + jpeg, + status; + + PICTRectangle + frame; + + PICTPixmap + pixmap; + + Quantum + index; + + register Quantum + *q; + + register ssize_t + i, + x; + + size_t + extent, + length; + + ssize_t + count, + flags, + j, + version, + y; + + StringInfo + *profile; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + image=AcquireImage(image_info,exception); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read PICT header. + */ + read_info=(ImageInfo *) NULL; + tile_image=(Image *) NULL; + pixmap.bits_per_pixel=0; + pixmap.component_count=0; + /* + Skip header : 512 for standard PICT and 4, ie ""PICT"" for OLE2. + */ + header_ole[0]=ReadBlobByte(image); + header_ole[1]=ReadBlobByte(image); + header_ole[2]=ReadBlobByte(image); + header_ole[3]=ReadBlobByte(image); + if (!((header_ole[0] == 0x50) && (header_ole[1] == 0x49) && + (header_ole[2] == 0x43) && (header_ole[3] == 0x54 ))) + for (i=0; i < 508; i++) + if (ReadBlobByte(image) == EOF) + break; + (void) ReadBlobMSBShort(image); /* skip picture size */ + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + while ((c=ReadBlobByte(image)) == 0) ; + if (c != 0x11) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + version=(ssize_t) ReadBlobByte(image); + if (version == 2) + { + c=ReadBlobByte(image); + if (c != 0xff) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + } + else + if (version != 1) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if ((frame.left < 0) || (frame.right < 0) || (frame.top < 0) || + (frame.bottom < 0) || (frame.left >= frame.right) || + (frame.top >= frame.bottom)) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + /* + Create black canvas. + */ + flags=0; + image->depth=8; + image->columns=(size_t) (frame.right-frame.left); + image->rows=(size_t) (frame.bottom-frame.top); + image->resolution.x=DefaultResolution; + image->resolution.y=DefaultResolution; + image->units=UndefinedResolution; + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + { + (void) CloseBlob(image); + return(GetFirstImageInList(image)); + } + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status != MagickFalse) + status=ResetImagePixels(image,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + /* + Interpret PICT opcodes. + */ + jpeg=MagickFalse; + for (code=0; EOFBlob(image) == MagickFalse; ) + { + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if ((version == 1) || ((TellBlob(image) % 2) != 0)) + code=ReadBlobByte(image); + if (version == 2) + code=ReadBlobMSBSignedShort(image); + if (code < 0) + break; + if (code == 0) + continue; + if (code > 0xa1) + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%04X:"",code); + } + else + { + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" %04X %s: %s"",code,codes[code].name,codes[code].description); + switch (code) + { + case 0x01: + { + /* + Clipping rectangle. + */ + length=ReadBlobMSBShort(image); + if (length != 0x000a) + { + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; + break; + } + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (((frame.left & 0x8000) != 0) || ((frame.top & 0x8000) != 0)) + break; + image->columns=(size_t) (frame.right-frame.left); + image->rows=(size_t) (frame.bottom-frame.top); + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status != MagickFalse) + status=ResetImagePixels(image,exception); + if (status == MagickFalse) + return(DestroyImageList(image)); + break; + } + case 0x12: + case 0x13: + case 0x14: + { + ssize_t + pattern; + + size_t + height, + width; + + /* + Skip pattern definition. + */ + pattern=(ssize_t) ReadBlobMSBShort(image); + for (i=0; i < 8; i++) + if (ReadBlobByte(image) == EOF) + break; + if (pattern == 2) + { + for (i=0; i < 5; i++) + if (ReadBlobByte(image) == EOF) + break; + break; + } + if (pattern != 1) + ThrowPICTException(CorruptImageError,""UnknownPatternType""); + length=ReadBlobMSBShort(image); + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (ReadPixmap(image,&pixmap) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + image->depth=(size_t) pixmap.component_size; + image->resolution.x=1.0*pixmap.horizontal_resolution; + image->resolution.y=1.0*pixmap.vertical_resolution; + image->units=PixelsPerInchResolution; + (void) ReadBlobMSBLong(image); + flags=(ssize_t) ReadBlobMSBShort(image); + length=ReadBlobMSBShort(image); + for (i=0; i <= (ssize_t) length; i++) + (void) ReadBlobMSBLong(image); + width=(size_t) (frame.bottom-frame.top); + height=(size_t) (frame.right-frame.left); + if (pixmap.bits_per_pixel <= 8) + length&=0x7fff; + if (pixmap.bits_per_pixel == 16) + width<<=1; + if (length == 0) + length=width; + if (length < 8) + { + for (i=0; i < (ssize_t) (length*height); i++) + if (ReadBlobByte(image) == EOF) + break; + } + else + for (i=0; i < (ssize_t) height; i++) + { + if (EOFBlob(image) != MagickFalse) + break; + if (length > 200) + { + for (j=0; j < (ssize_t) ReadBlobMSBShort(image); j++) + if (ReadBlobByte(image) == EOF) + break; + } + else + for (j=0; j < (ssize_t) ReadBlobByte(image); j++) + if (ReadBlobByte(image) == EOF) + break; + } + break; + } + case 0x1b: + { + /* + Initialize image background color. + */ + image->background_color.red=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + image->background_color.green=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + image->background_color.blue=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + break; + } + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + { + /* + Skip polygon or region. + */ + length=ReadBlobMSBShort(image); + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; + break; + } + case 0x90: + case 0x91: + case 0x98: + case 0x99: + case 0x9a: + case 0x9b: + { + PICTRectangle + source, + destination; + + register unsigned char + *p; + + size_t + j; + + ssize_t + bytes_per_line; + + unsigned char + *pixels; + + /* + Pixmap clipped by a rectangle. + */ + bytes_per_line=0; + if ((code != 0x9a) && (code != 0x9b)) + bytes_per_line=(ssize_t) ReadBlobMSBShort(image); + else + { + (void) ReadBlobMSBShort(image); + (void) ReadBlobMSBShort(image); + (void) ReadBlobMSBShort(image); + } + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + /* + Initialize tile image. + */ + tile_image=CloneImage(image,(size_t) (frame.right-frame.left), + (size_t) (frame.bottom-frame.top),MagickTrue,exception); + if (tile_image == (Image *) NULL) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if ((code == 0x9a) || (code == 0x9b) || + ((bytes_per_line & 0x8000) != 0)) + { + if (ReadPixmap(image,&pixmap) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + tile_image->depth=(size_t) pixmap.component_size; + tile_image->alpha_trait=pixmap.component_count == 4 ? + BlendPixelTrait : UndefinedPixelTrait; + tile_image->resolution.x=(double) pixmap.horizontal_resolution; + tile_image->resolution.y=(double) pixmap.vertical_resolution; + tile_image->units=PixelsPerInchResolution; + if (tile_image->alpha_trait != UndefinedPixelTrait) + (void) SetImageAlpha(tile_image,OpaqueAlpha,exception); + } + if ((code != 0x9a) && (code != 0x9b)) + { + /* + Initialize colormap. + */ + tile_image->colors=2; + if ((bytes_per_line & 0x8000) != 0) + { + (void) ReadBlobMSBLong(image); + flags=(ssize_t) ReadBlobMSBShort(image); + tile_image->colors=1UL*ReadBlobMSBShort(image)+1; + } + status=AcquireImageColormap(tile_image,tile_image->colors, + exception); + if (status == MagickFalse) + ThrowPICTException(ResourceLimitError, + ""MemoryAllocationFailed""); + if ((bytes_per_line & 0x8000) != 0) + { + for (i=0; i < (ssize_t) tile_image->colors; i++) + { + j=ReadBlobMSBShort(image) % tile_image->colors; + if ((flags & 0x8000) != 0) + j=(size_t) i; + tile_image->colormap[j].red=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + tile_image->colormap[j].green=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + tile_image->colormap[j].blue=(Quantum) + ScaleShortToQuantum(ReadBlobMSBShort(image)); + } + } + else + { + for (i=0; i < (ssize_t) tile_image->colors; i++) + { + tile_image->colormap[i].red=(Quantum) (QuantumRange- + tile_image->colormap[i].red); + tile_image->colormap[i].green=(Quantum) (QuantumRange- + tile_image->colormap[i].green); + tile_image->colormap[i].blue=(Quantum) (QuantumRange- + tile_image->colormap[i].blue); + } + } + } + if (EOFBlob(image) != MagickFalse) + ThrowPICTException(CorruptImageError, + ""InsufficientImageDataInFile""); + if (ReadRectangle(image,&source) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (ReadRectangle(image,&destination) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + (void) ReadBlobMSBShort(image); + if ((code == 0x91) || (code == 0x99) || (code == 0x9b)) + { + /* + Skip region. + */ + length=ReadBlobMSBShort(image); + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; + } + if ((code != 0x9a) && (code != 0x9b) && + (bytes_per_line & 0x8000) == 0) + pixels=DecodeImage(image,tile_image,(size_t) bytes_per_line,1, + &extent); + else + pixels=DecodeImage(image,tile_image,(size_t) bytes_per_line, + (unsigned int) pixmap.bits_per_pixel,&extent); + if (pixels == (unsigned char *) NULL) + ThrowPICTException(CorruptImageError,""UnableToUncompressImage""); + /* + Convert PICT tile image to pixel packets. + */ + p=pixels; + for (y=0; y < (ssize_t) tile_image->rows; y++) + { + if (p > (pixels+extent+image->columns)) + { + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + ThrowPICTException(CorruptImageError,""NotEnoughPixelData""); + } + q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1, + exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) tile_image->columns; x++) + { + if (tile_image->storage_class == PseudoClass) + { + index=(Quantum) ConstrainColormapIndex(tile_image,(ssize_t) + *p,exception); + SetPixelIndex(tile_image,index,q); + SetPixelRed(tile_image, + tile_image->colormap[(ssize_t) index].red,q); + SetPixelGreen(tile_image, + tile_image->colormap[(ssize_t) index].green,q); + SetPixelBlue(tile_image, + tile_image->colormap[(ssize_t) index].blue,q); + } + else + { + if (pixmap.bits_per_pixel == 16) + { + i=(ssize_t) (*p++); + j=(size_t) (*p); + SetPixelRed(tile_image,ScaleCharToQuantum( + (unsigned char) ((i & 0x7c) << 1)),q); + SetPixelGreen(tile_image,ScaleCharToQuantum( + (unsigned char) (((i & 0x03) << 6) | + ((j & 0xe0) >> 2))),q); + SetPixelBlue(tile_image,ScaleCharToQuantum( + (unsigned char) ((j & 0x1f) << 3)),q); + } + else + if (tile_image->alpha_trait == UndefinedPixelTrait) + { + if (p > (pixels+extent+2*image->columns)) + ThrowPICTException(CorruptImageError, + ""NotEnoughPixelData""); + SetPixelRed(tile_image,ScaleCharToQuantum(*p),q); + SetPixelGreen(tile_image,ScaleCharToQuantum( + *(p+tile_image->columns)),q); + SetPixelBlue(tile_image,ScaleCharToQuantum( + *(p+2*tile_image->columns)),q); + } + else + { + if (p > (pixels+extent+3*image->columns)) + ThrowPICTException(CorruptImageError, + ""NotEnoughPixelData""); + SetPixelAlpha(tile_image,ScaleCharToQuantum(*p),q); + SetPixelRed(tile_image,ScaleCharToQuantum( + *(p+tile_image->columns)),q); + SetPixelGreen(tile_image,ScaleCharToQuantum( + *(p+2*tile_image->columns)),q); + SetPixelBlue(tile_image,ScaleCharToQuantum( + *(p+3*tile_image->columns)),q); + } + } + p++; + q+=GetPixelChannels(tile_image); + } + if (SyncAuthenticPixels(tile_image,exception) == MagickFalse) + break; + if ((tile_image->storage_class == DirectClass) && + (pixmap.bits_per_pixel != 16)) + { + p+=(pixmap.component_count-1)*tile_image->columns; + if (p < pixels) + break; + } + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + tile_image->rows); + if (status == MagickFalse) + break; + } + pixels=(unsigned char *) RelinquishMagickMemory(pixels); + if ((jpeg == MagickFalse) && (EOFBlob(image) == MagickFalse)) + if ((code == 0x9a) || (code == 0x9b) || + ((bytes_per_line & 0x8000) != 0)) + (void) CompositeImage(image,tile_image,CopyCompositeOp, + MagickTrue,(ssize_t) destination.left,(ssize_t) + destination.top,exception); + tile_image=DestroyImage(tile_image); + break; + } + case 0xa1: + { + unsigned char + *info; + + size_t + type; + + /* + Comment. + */ + type=ReadBlobMSBShort(image); + length=ReadBlobMSBShort(image); + if (length == 0) + break; + (void) ReadBlobMSBLong(image); + length-=MagickMin(length,4); + if (length == 0) + break; + info=(unsigned char *) AcquireQuantumMemory(length,sizeof(*info)); + if (info == (unsigned char *) NULL) + break; + count=ReadBlob(image,length,info); + if (count != (ssize_t) length) + { + info=(unsigned char *) RelinquishMagickMemory(info); + ThrowPICTException(ResourceLimitError,""UnableToReadImageData""); + } + switch (type) + { + case 0xe0: + { + profile=BlobToStringInfo((const void *) NULL,length); + SetStringInfoDatum(profile,info); + status=SetImageProfile(image,""icc"",profile,exception); + profile=DestroyStringInfo(profile); + if (status == MagickFalse) + { + info=(unsigned char *) RelinquishMagickMemory(info); + ThrowPICTException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + break; + } + case 0x1f2: + { + profile=BlobToStringInfo((const void *) NULL,length); + SetStringInfoDatum(profile,info); + status=SetImageProfile(image,""iptc"",profile,exception); + if (status == MagickFalse) + { + info=(unsigned char *) RelinquishMagickMemory(info); + ThrowPICTException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + profile=DestroyStringInfo(profile); + break; + } + default: + break; + } + info=(unsigned char *) RelinquishMagickMemory(info); + break; + } + default: + { + /* + Skip to next op code. + */ + if (codes[code].length == -1) + (void) ReadBlobMSBShort(image); + else + for (i=0; i < (ssize_t) codes[code].length; i++) + if (ReadBlobByte(image) == EOF) + break; + } + } + } + if (code == 0xc00) + { + /* + Skip header. + */ + for (i=0; i < 24; i++) + if (ReadBlobByte(image) == EOF) + break; + continue; + } + if (((code >= 0xb0) && (code <= 0xcf)) || + ((code >= 0x8000) && (code <= 0x80ff))) + continue; + if (code == 0x8200) + { + char + filename[MaxTextExtent]; + + FILE + *file; + + int + unique_file; + + /* + Embedded JPEG. + */ + jpeg=MagickTrue; + read_info=CloneImageInfo(image_info); + SetImageInfoBlob(read_info,(void *) NULL,0); + file=(FILE *) NULL; + unique_file=AcquireUniqueFileResource(filename); + (void) FormatLocaleString(read_info->filename,MaxTextExtent,""jpeg:%s"", + filename); + if (unique_file != -1) + file=fdopen(unique_file,""wb""); + if ((unique_file == -1) || (file == (FILE *) NULL)) + { + (void) RelinquishUniqueFileResource(read_info->filename); + (void) CopyMagickString(image->filename,read_info->filename, + MagickPathExtent); + ThrowPICTException(FileOpenError,""UnableToCreateTemporaryFile""); + } + length=ReadBlobMSBLong(image); + if (length > 154) + { + for (i=0; i < 6; i++) + (void) ReadBlobMSBLong(image); + if (ReadRectangle(image,&frame) == MagickFalse) + { + (void) fclose(file); + (void) RelinquishUniqueFileResource(read_info->filename); + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + } + for (i=0; i < 122; i++) + if (ReadBlobByte(image) == EOF) + break; + for (i=0; i < (ssize_t) (length-154); i++) + { + c=ReadBlobByte(image); + if (c == EOF) + break; + if (fputc(c,file) != c) + break; + } + } + (void) fclose(file); + (void) close(unique_file); + tile_image=ReadImage(read_info,exception); + (void) RelinquishUniqueFileResource(filename); + read_info=DestroyImageInfo(read_info); + if (tile_image == (Image *) NULL) + continue; + (void) FormatLocaleString(geometry,MagickPathExtent,""%.20gx%.20g"", + (double) MagickMax(image->columns,tile_image->columns), + (double) MagickMax(image->rows,tile_image->rows)); + (void) SetImageExtent(image, + MagickMax(image->columns,tile_image->columns), + MagickMax(image->rows,tile_image->rows),exception); + (void) TransformImageColorspace(image,tile_image->colorspace,exception); + (void) CompositeImage(image,tile_image,CopyCompositeOp,MagickTrue, + (ssize_t) frame.left,(ssize_t) frame.right,exception); + image->compression=tile_image->compression; + tile_image=DestroyImage(tile_image); + continue; + } + if ((code == 0xff) || (code == 0xffff)) + break; + if (((code >= 0xd0) && (code <= 0xfe)) || + ((code >= 0x8100) && (code <= 0xffff))) + { + /* + Skip reserved. + */ + length=ReadBlobMSBShort(image); + for (i=0; i < (ssize_t) length; i++) + if (ReadBlobByte(image) == EOF) + break; + continue; + } + if ((code >= 0x100) && (code <= 0x7fff)) + { + /* + Skip reserved. + */ + length=(size_t) ((code >> 7) & 0xff); + for (i=0; i < (ssize_t) length; i++) + if (ReadBlobByte(image) == EOF) + break; + continue; + } + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -1472,7 +1472,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + c=ReadBlobByte(image); + if (c == EOF) + break; +- (void) fputc(c,file); ++ if (fputc(c,file) != c) ++ break; + } + } + (void) fclose(file);",5894,6130,6144 +17961,"struct json_object* json_tokener_parse_ex(struct json_tokener *tok, + const char *str, int len) +{ + struct json_object *obj = NULL; + char c = '\1'; +#ifdef HAVE_SETLOCALE + char *oldlocale=NULL, *tmplocale; + + tmplocale = setlocale(LC_NUMERIC, NULL); + if (tmplocale) oldlocale = strdup(tmplocale); + setlocale(LC_NUMERIC, ""C""); +#endif + + tok->char_offset = 0; + tok->err = json_tokener_success; + + while (PEEK_CHAR(c, tok)) { + + redo_char: + switch(state) { + + case json_tokener_state_eatws: + /* Advance until we change state */ + while (isspace((int)c)) { + if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok))) + goto out; + } + if(c == '/' && !(tok->flags & JSON_TOKENER_STRICT)) { + printbuf_reset(tok->pb); + printbuf_memappend_fast(tok->pb, &c, 1); + state = json_tokener_state_comment_start; + } else { + state = saved_state; + goto redo_char; + } + break; + + case json_tokener_state_start: + switch(c) { + case '{': + state = json_tokener_state_eatws; + saved_state = json_tokener_state_object_field_start; + current = json_object_new_object(); + break; + case '[': + state = json_tokener_state_eatws; + saved_state = json_tokener_state_array; + current = json_object_new_array(); + break; + case 'I': + case 'i': + state = json_tokener_state_inf; + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; + case 'N': + case 'n': + state = json_tokener_state_null; // or NaN + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; + case '\'': + if (tok->flags & JSON_TOKENER_STRICT) { + /* in STRICT mode only double-quote are allowed */ + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + case '""': + state = json_tokener_state_string; + printbuf_reset(tok->pb); + tok->quote_char = c; + break; + case 'T': + case 't': + case 'F': + case 'f': + state = json_tokener_state_boolean; + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; +#if defined(__GNUC__) + case '0' ... '9': +#else + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': +#endif + case '-': + state = json_tokener_state_number; + printbuf_reset(tok->pb); + tok->is_double = 0; + goto redo_char; + default: + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + break; + + case json_tokener_state_finish: + if(tok->depth == 0) goto out; + obj = json_object_get(current); + json_tokener_reset_level(tok, tok->depth); + tok->depth--; + goto redo_char; + + case json_tokener_state_inf: /* aka starts with 'i' */ + { + int size; + int size_inf; + int is_negative = 0; + + printbuf_memappend_fast(tok->pb, &c, 1); + size = json_min(tok->st_pos+1, json_null_str_len); + size_inf = json_min(tok->st_pos+1, json_inf_str_len); + char *infbuf = tok->pb->buf; + if (*infbuf == '-') + { + infbuf++; + is_negative = 1; + } + if ((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_inf_str, infbuf, size_inf) == 0) || + (strncmp(json_inf_str, infbuf, size_inf) == 0) + ) + { + if (tok->st_pos == json_inf_str_len) + { + current = json_object_new_double(is_negative ? -INFINITY : INFINITY); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + tok->st_pos++; + } + break; + case json_tokener_state_null: /* aka starts with 'n' */ + { + int size; + int size_nan; + printbuf_memappend_fast(tok->pb, &c, 1); + size = json_min(tok->st_pos+1, json_null_str_len); + size_nan = json_min(tok->st_pos+1, json_nan_str_len); + if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_null_str, tok->pb->buf, size) == 0) + || (strncmp(json_null_str, tok->pb->buf, size) == 0) + ) { + if (tok->st_pos == json_null_str_len) { + current = NULL; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } + else if ((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_nan_str, tok->pb->buf, size_nan) == 0) || + (strncmp(json_nan_str, tok->pb->buf, size_nan) == 0) + ) + { + if (tok->st_pos == json_nan_str_len) + { + current = json_object_new_double(NAN); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_null; + goto out; + } + tok->st_pos++; + } + break; + + case json_tokener_state_comment_start: + if(c == '*') { + state = json_tokener_state_comment; + } else if(c == '/') { + state = json_tokener_state_comment_eol; + } else { + tok->err = json_tokener_error_parse_comment; + goto out; + } + printbuf_memappend_fast(tok->pb, &c, 1); + break; + + case json_tokener_state_comment: + { + /* Advance until we change state */ + const char *case_start = str; + while(c != '*') { + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + printbuf_memappend_fast(tok->pb, case_start, 1+str-case_start); + state = json_tokener_state_comment_end; + } + break; + + case json_tokener_state_comment_eol: + { + /* Advance until we change state */ + const char *case_start = str; + while(c != '\n') { + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + MC_DEBUG(""json_tokener_comment: %s\n"", tok->pb->buf); + state = json_tokener_state_eatws; + } + break; + + case json_tokener_state_comment_end: + printbuf_memappend_fast(tok->pb, &c, 1); + if(c == '/') { + MC_DEBUG(""json_tokener_comment: %s\n"", tok->pb->buf); + state = json_tokener_state_eatws; + } else { + state = json_tokener_state_comment; + } + break; + + case json_tokener_state_string: + { + /* Advance until we change state */ + const char *case_start = str; + while(1) { + if(c == tok->quote_char) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + current = json_object_new_string_len(tok->pb->buf, tok->pb->bpos); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + break; + } else if(c == '\\') { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + saved_state = json_tokener_state_string; + state = json_tokener_state_string_escape; + break; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + } + break; + + case json_tokener_state_string_escape: + switch(c) { + case '""': + case '\\': + case '/': + printbuf_memappend_fast(tok->pb, &c, 1); + state = saved_state; + break; + case 'b': + case 'n': + case 'r': + case 't': + case 'f': + if(c == 'b') printbuf_memappend_fast(tok->pb, ""\b"", 1); + else if(c == 'n') printbuf_memappend_fast(tok->pb, ""\n"", 1); + else if(c == 'r') printbuf_memappend_fast(tok->pb, ""\r"", 1); + else if(c == 't') printbuf_memappend_fast(tok->pb, ""\t"", 1); + else if(c == 'f') printbuf_memappend_fast(tok->pb, ""\f"", 1); + state = saved_state; + break; + case 'u': + tok->ucs_char = 0; + tok->st_pos = 0; + state = json_tokener_state_escape_unicode; + break; + default: + tok->err = json_tokener_error_parse_string; + goto out; + } + break; + + case json_tokener_state_escape_unicode: + { + unsigned int got_hi_surrogate = 0; + + /* Handle a 4-byte sequence, or two sequences if a surrogate pair */ + while(1) { + if(strchr(json_hex_chars, c)) { + tok->ucs_char += ((unsigned int)hexdigit(c) << ((3-tok->st_pos++)*4)); + if(tok->st_pos == 4) { + unsigned char unescaped_utf[4]; + + if (got_hi_surrogate) { + if (IS_LOW_SURROGATE(tok->ucs_char)) { + /* Recalculate the ucs_char, then fall thru to process normally */ + tok->ucs_char = DECODE_SURROGATE_PAIR(got_hi_surrogate, tok->ucs_char); + } else { + /* Hi surrogate was not followed by a low surrogate */ + /* Replace the hi and process the rest normally */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + got_hi_surrogate = 0; + } + + if (tok->ucs_char < 0x80) { + unescaped_utf[0] = tok->ucs_char; + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 1); + } else if (tok->ucs_char < 0x800) { + unescaped_utf[0] = 0xc0 | (tok->ucs_char >> 6); + unescaped_utf[1] = 0x80 | (tok->ucs_char & 0x3f); + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 2); + } else if (IS_HIGH_SURROGATE(tok->ucs_char)) { + /* Got a high surrogate. Remember it and look for the + * the beginning of another sequence, which should be the + * low surrogate. + */ + got_hi_surrogate = tok->ucs_char; + /* Not at end, and the next two chars should be ""\u"" */ + if ((tok->char_offset+1 != len) && + (tok->char_offset+2 != len) && + (str[1] == '\\') && + (str[2] == 'u')) + { + /* Advance through the 16 bit surrogate, and move on to the + * next sequence. The next step is to process the following + * characters. + */ + if( !ADVANCE_CHAR(str, tok) || !ADVANCE_CHAR(str, tok) ) { + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + /* Advance to the first char of the next sequence and + * continue processing with the next sequence. + */ + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + goto out; + } + tok->ucs_char = 0; + tok->st_pos = 0; + continue; /* other json_tokener_state_escape_unicode */ + } else { + /* Got a high surrogate without another sequence following + * it. Put a replacement char in for the hi surrogate + * and pretend we finished. + */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + } else if (IS_LOW_SURROGATE(tok->ucs_char)) { + /* Got a low surrogate not preceded by a high */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } else if (tok->ucs_char < 0x10000) { + unescaped_utf[0] = 0xe0 | (tok->ucs_char >> 12); + unescaped_utf[1] = 0x80 | ((tok->ucs_char >> 6) & 0x3f); + unescaped_utf[2] = 0x80 | (tok->ucs_char & 0x3f); + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 3); + } else if (tok->ucs_char < 0x110000) { + unescaped_utf[0] = 0xf0 | ((tok->ucs_char >> 18) & 0x07); + unescaped_utf[1] = 0x80 | ((tok->ucs_char >> 12) & 0x3f); + unescaped_utf[2] = 0x80 | ((tok->ucs_char >> 6) & 0x3f); + unescaped_utf[3] = 0x80 | (tok->ucs_char & 0x3f); + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 4); + } else { + /* Don't know what we got--insert the replacement char */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + state = saved_state; + break; + } + } else { + tok->err = json_tokener_error_parse_string; + goto out; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + if (got_hi_surrogate) /* Clean up any pending chars */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + goto out; + } + } + } + break; + + case json_tokener_state_boolean: + { + int size1, size2; + printbuf_memappend_fast(tok->pb, &c, 1); + size1 = json_min(tok->st_pos+1, json_true_str_len); + size2 = json_min(tok->st_pos+1, json_false_str_len); + if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_true_str, tok->pb->buf, size1) == 0) + || (strncmp(json_true_str, tok->pb->buf, size1) == 0) + ) { + if(tok->st_pos == json_true_str_len) { + current = json_object_new_boolean(1); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_false_str, tok->pb->buf, size2) == 0) + || (strncmp(json_false_str, tok->pb->buf, size2) == 0)) { + if(tok->st_pos == json_false_str_len) { + current = json_object_new_boolean(0); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_boolean; + goto out; + } + tok->st_pos++; + } + break; + + case json_tokener_state_number: + { + /* Advance until we change state */ + const char *case_start = str; + int case_len=0; + while(c && strchr(json_number_chars, c)) { + ++case_len; + if(c == '.' || c == 'e' || c == 'E') + tok->is_double = 1; + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, case_len); + goto out; + } + } + if (case_len>0) + printbuf_memappend_fast(tok->pb, case_start, case_len); + + if (tok->pb->buf[0] == '-' && case_len == 1 && + (c == 'i' || c == 'I')) + { + state = json_tokener_state_inf; + goto redo_char; + } + } + { + int64_t num64; + double numd; + if (!tok->is_double && json_parse_int64(tok->pb->buf, &num64) == 0) { + if (num64 && tok->pb->buf[0]=='0' && (tok->flags & JSON_TOKENER_STRICT)) { + /* in strict mode, number must not start with 0 */ + tok->err = json_tokener_error_parse_number; + goto out; + } + current = json_object_new_int64(num64); + } + else if(tok->is_double && json_parse_double(tok->pb->buf, &numd) == 0) + { + current = json_object_new_double_s(numd, tok->pb->buf); + } else { + tok->err = json_tokener_error_parse_number; + goto out; + } + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + break; + + case json_tokener_state_array_after_sep: + case json_tokener_state_array: + if(c == ']') { + if (state == json_tokener_state_array_after_sep && + (tok->flags & JSON_TOKENER_STRICT)) + { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else { + if(tok->depth >= tok->max_depth-1) { + tok->err = json_tokener_error_depth; + goto out; + } + state = json_tokener_state_array_add; + tok->depth++; + json_tokener_reset_level(tok, tok->depth); + goto redo_char; + } + break; + + case json_tokener_state_array_add: + json_object_array_add(current, obj); + saved_state = json_tokener_state_array_sep; + state = json_tokener_state_eatws; + goto redo_char; + + case json_tokener_state_array_sep: + if(c == ']') { + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else if(c == ',') { + saved_state = json_tokener_state_array_after_sep; + state = json_tokener_state_eatws; + } else { + tok->err = json_tokener_error_parse_array; + goto out; + } + break; + + case json_tokener_state_object_field_start: + case json_tokener_state_object_field_start_after_sep: + if(c == '}') { + if (state == json_tokener_state_object_field_start_after_sep && + (tok->flags & JSON_TOKENER_STRICT)) + { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else if (c == '""' || c == '\'') { + tok->quote_char = c; + printbuf_reset(tok->pb); + state = json_tokener_state_object_field; + } else { + tok->err = json_tokener_error_parse_object_key_name; + goto out; + } + break; + + case json_tokener_state_object_field: + { + /* Advance until we change state */ + const char *case_start = str; + while(1) { + if(c == tok->quote_char) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + obj_field_name = strdup(tok->pb->buf); + saved_state = json_tokener_state_object_field_end; + state = json_tokener_state_eatws; + break; + } else if(c == '\\') { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + saved_state = json_tokener_state_object_field; + state = json_tokener_state_string_escape; + break; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + } + break; + + case json_tokener_state_object_field_end: + if(c == ':') { + saved_state = json_tokener_state_object_value; + state = json_tokener_state_eatws; + } else { + tok->err = json_tokener_error_parse_object_key_sep; + goto out; + } + break; + + case json_tokener_state_object_value: + if(tok->depth >= tok->max_depth-1) { + tok->err = json_tokener_error_depth; + goto out; + } + state = json_tokener_state_object_value_add; + tok->depth++; + json_tokener_reset_level(tok, tok->depth); + goto redo_char; + + case json_tokener_state_object_value_add: + json_object_object_add(current, obj_field_name, obj); + free(obj_field_name); + obj_field_name = NULL; + saved_state = json_tokener_state_object_sep; + state = json_tokener_state_eatws; + goto redo_char; + + case json_tokener_state_object_sep: + if(c == '}') { + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else if(c == ',') { + saved_state = json_tokener_state_object_field_start_after_sep; + state = json_tokener_state_eatws; + } else { + tok->err = json_tokener_error_parse_object_value_sep; + goto out; + } + break; + + } + if (!ADVANCE_CHAR(str, tok)) + goto out; + } /* while(POP_CHAR) */ +",1,"struct json_object* json_tokener_parse_ex(struct json_tokener *tok, + const char *str, int len) +{ + struct json_object *obj = NULL; + char c = '\1'; +#ifdef HAVE_SETLOCALE + char *oldlocale=NULL, *tmplocale; + + tmplocale = setlocale(LC_NUMERIC, NULL); + if (tmplocale) oldlocale = strdup(tmplocale); + setlocale(LC_NUMERIC, ""C""); +#endif + + tok->char_offset = 0; + tok->err = json_tokener_success; + + /* this interface is presently not 64-bit clean due to the int len argument + and the internal printbuf interface that takes 32-bit int len arguments + so the function limits the maximum string size to INT32_MAX (2GB). + If the function is called with len == -1 then strlen is called to check + the string length is less than INT32_MAX (2GB) */ + if ((len < -1) || (len == -1 && strlen(str) > INT32_MAX)) { + tok->err = json_tokener_error_size; + return NULL; + } + + while (PEEK_CHAR(c, tok)) { + + redo_char: + switch(state) { + + case json_tokener_state_eatws: + /* Advance until we change state */ + while (isspace((int)c)) { + if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok))) + goto out; + } + if(c == '/' && !(tok->flags & JSON_TOKENER_STRICT)) { + printbuf_reset(tok->pb); + printbuf_memappend_fast(tok->pb, &c, 1); + state = json_tokener_state_comment_start; + } else { + state = saved_state; + goto redo_char; + } + break; + + case json_tokener_state_start: + switch(c) { + case '{': + state = json_tokener_state_eatws; + saved_state = json_tokener_state_object_field_start; + current = json_object_new_object(); + break; + case '[': + state = json_tokener_state_eatws; + saved_state = json_tokener_state_array; + current = json_object_new_array(); + break; + case 'I': + case 'i': + state = json_tokener_state_inf; + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; + case 'N': + case 'n': + state = json_tokener_state_null; // or NaN + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; + case '\'': + if (tok->flags & JSON_TOKENER_STRICT) { + /* in STRICT mode only double-quote are allowed */ + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + case '""': + state = json_tokener_state_string; + printbuf_reset(tok->pb); + tok->quote_char = c; + break; + case 'T': + case 't': + case 'F': + case 'f': + state = json_tokener_state_boolean; + printbuf_reset(tok->pb); + tok->st_pos = 0; + goto redo_char; +#if defined(__GNUC__) + case '0' ... '9': +#else + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': +#endif + case '-': + state = json_tokener_state_number; + printbuf_reset(tok->pb); + tok->is_double = 0; + goto redo_char; + default: + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + break; + + case json_tokener_state_finish: + if(tok->depth == 0) goto out; + obj = json_object_get(current); + json_tokener_reset_level(tok, tok->depth); + tok->depth--; + goto redo_char; + + case json_tokener_state_inf: /* aka starts with 'i' */ + { + int size; + int size_inf; + int is_negative = 0; + + printbuf_memappend_fast(tok->pb, &c, 1); + size = json_min(tok->st_pos+1, json_null_str_len); + size_inf = json_min(tok->st_pos+1, json_inf_str_len); + char *infbuf = tok->pb->buf; + if (*infbuf == '-') + { + infbuf++; + is_negative = 1; + } + if ((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_inf_str, infbuf, size_inf) == 0) || + (strncmp(json_inf_str, infbuf, size_inf) == 0) + ) + { + if (tok->st_pos == json_inf_str_len) + { + current = json_object_new_double(is_negative ? -INFINITY : INFINITY); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + tok->st_pos++; + } + break; + case json_tokener_state_null: /* aka starts with 'n' */ + { + int size; + int size_nan; + printbuf_memappend_fast(tok->pb, &c, 1); + size = json_min(tok->st_pos+1, json_null_str_len); + size_nan = json_min(tok->st_pos+1, json_nan_str_len); + if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_null_str, tok->pb->buf, size) == 0) + || (strncmp(json_null_str, tok->pb->buf, size) == 0) + ) { + if (tok->st_pos == json_null_str_len) { + current = NULL; + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } + else if ((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_nan_str, tok->pb->buf, size_nan) == 0) || + (strncmp(json_nan_str, tok->pb->buf, size_nan) == 0) + ) + { + if (tok->st_pos == json_nan_str_len) + { + current = json_object_new_double(NAN); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_null; + goto out; + } + tok->st_pos++; + } + break; + + case json_tokener_state_comment_start: + if(c == '*') { + state = json_tokener_state_comment; + } else if(c == '/') { + state = json_tokener_state_comment_eol; + } else { + tok->err = json_tokener_error_parse_comment; + goto out; + } + printbuf_memappend_fast(tok->pb, &c, 1); + break; + + case json_tokener_state_comment: + { + /* Advance until we change state */ + const char *case_start = str; + while(c != '*') { + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + printbuf_memappend_fast(tok->pb, case_start, 1+str-case_start); + state = json_tokener_state_comment_end; + } + break; + + case json_tokener_state_comment_eol: + { + /* Advance until we change state */ + const char *case_start = str; + while(c != '\n') { + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + MC_DEBUG(""json_tokener_comment: %s\n"", tok->pb->buf); + state = json_tokener_state_eatws; + } + break; + + case json_tokener_state_comment_end: + printbuf_memappend_fast(tok->pb, &c, 1); + if(c == '/') { + MC_DEBUG(""json_tokener_comment: %s\n"", tok->pb->buf); + state = json_tokener_state_eatws; + } else { + state = json_tokener_state_comment; + } + break; + + case json_tokener_state_string: + { + /* Advance until we change state */ + const char *case_start = str; + while(1) { + if(c == tok->quote_char) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + current = json_object_new_string_len(tok->pb->buf, tok->pb->bpos); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + break; + } else if(c == '\\') { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + saved_state = json_tokener_state_string; + state = json_tokener_state_string_escape; + break; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + } + break; + + case json_tokener_state_string_escape: + switch(c) { + case '""': + case '\\': + case '/': + printbuf_memappend_fast(tok->pb, &c, 1); + state = saved_state; + break; + case 'b': + case 'n': + case 'r': + case 't': + case 'f': + if(c == 'b') printbuf_memappend_fast(tok->pb, ""\b"", 1); + else if(c == 'n') printbuf_memappend_fast(tok->pb, ""\n"", 1); + else if(c == 'r') printbuf_memappend_fast(tok->pb, ""\r"", 1); + else if(c == 't') printbuf_memappend_fast(tok->pb, ""\t"", 1); + else if(c == 'f') printbuf_memappend_fast(tok->pb, ""\f"", 1); + state = saved_state; + break; + case 'u': + tok->ucs_char = 0; + tok->st_pos = 0; + state = json_tokener_state_escape_unicode; + break; + default: + tok->err = json_tokener_error_parse_string; + goto out; + } + break; + + case json_tokener_state_escape_unicode: + { + unsigned int got_hi_surrogate = 0; + + /* Handle a 4-byte sequence, or two sequences if a surrogate pair */ + while(1) { + if(strchr(json_hex_chars, c)) { + tok->ucs_char += ((unsigned int)hexdigit(c) << ((3-tok->st_pos++)*4)); + if(tok->st_pos == 4) { + unsigned char unescaped_utf[4]; + + if (got_hi_surrogate) { + if (IS_LOW_SURROGATE(tok->ucs_char)) { + /* Recalculate the ucs_char, then fall thru to process normally */ + tok->ucs_char = DECODE_SURROGATE_PAIR(got_hi_surrogate, tok->ucs_char); + } else { + /* Hi surrogate was not followed by a low surrogate */ + /* Replace the hi and process the rest normally */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + got_hi_surrogate = 0; + } + + if (tok->ucs_char < 0x80) { + unescaped_utf[0] = tok->ucs_char; + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 1); + } else if (tok->ucs_char < 0x800) { + unescaped_utf[0] = 0xc0 | (tok->ucs_char >> 6); + unescaped_utf[1] = 0x80 | (tok->ucs_char & 0x3f); + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 2); + } else if (IS_HIGH_SURROGATE(tok->ucs_char)) { + /* Got a high surrogate. Remember it and look for the + * the beginning of another sequence, which should be the + * low surrogate. + */ + got_hi_surrogate = tok->ucs_char; + /* Not at end, and the next two chars should be ""\u"" */ + if ((tok->char_offset+1 != len) && + (tok->char_offset+2 != len) && + (str[1] == '\\') && + (str[2] == 'u')) + { + /* Advance through the 16 bit surrogate, and move on to the + * next sequence. The next step is to process the following + * characters. + */ + if( !ADVANCE_CHAR(str, tok) || !ADVANCE_CHAR(str, tok) ) { + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + /* Advance to the first char of the next sequence and + * continue processing with the next sequence. + */ + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + goto out; + } + tok->ucs_char = 0; + tok->st_pos = 0; + continue; /* other json_tokener_state_escape_unicode */ + } else { + /* Got a high surrogate without another sequence following + * it. Put a replacement char in for the hi surrogate + * and pretend we finished. + */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + } else if (IS_LOW_SURROGATE(tok->ucs_char)) { + /* Got a low surrogate not preceded by a high */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } else if (tok->ucs_char < 0x10000) { + unescaped_utf[0] = 0xe0 | (tok->ucs_char >> 12); + unescaped_utf[1] = 0x80 | ((tok->ucs_char >> 6) & 0x3f); + unescaped_utf[2] = 0x80 | (tok->ucs_char & 0x3f); + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 3); + } else if (tok->ucs_char < 0x110000) { + unescaped_utf[0] = 0xf0 | ((tok->ucs_char >> 18) & 0x07); + unescaped_utf[1] = 0x80 | ((tok->ucs_char >> 12) & 0x3f); + unescaped_utf[2] = 0x80 | ((tok->ucs_char >> 6) & 0x3f); + unescaped_utf[3] = 0x80 | (tok->ucs_char & 0x3f); + printbuf_memappend_fast(tok->pb, (char*)unescaped_utf, 4); + } else { + /* Don't know what we got--insert the replacement char */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + } + state = saved_state; + break; + } + } else { + tok->err = json_tokener_error_parse_string; + goto out; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + if (got_hi_surrogate) /* Clean up any pending chars */ + printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3); + goto out; + } + } + } + break; + + case json_tokener_state_boolean: + { + int size1, size2; + printbuf_memappend_fast(tok->pb, &c, 1); + size1 = json_min(tok->st_pos+1, json_true_str_len); + size2 = json_min(tok->st_pos+1, json_false_str_len); + if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_true_str, tok->pb->buf, size1) == 0) + || (strncmp(json_true_str, tok->pb->buf, size1) == 0) + ) { + if(tok->st_pos == json_true_str_len) { + current = json_object_new_boolean(1); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else if((!(tok->flags & JSON_TOKENER_STRICT) && + strncasecmp(json_false_str, tok->pb->buf, size2) == 0) + || (strncmp(json_false_str, tok->pb->buf, size2) == 0)) { + if(tok->st_pos == json_false_str_len) { + current = json_object_new_boolean(0); + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + } else { + tok->err = json_tokener_error_parse_boolean; + goto out; + } + tok->st_pos++; + } + break; + + case json_tokener_state_number: + { + /* Advance until we change state */ + const char *case_start = str; + int case_len=0; + while(c && strchr(json_number_chars, c)) { + ++case_len; + if(c == '.' || c == 'e' || c == 'E') + tok->is_double = 1; + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, case_len); + goto out; + } + } + if (case_len>0) + printbuf_memappend_fast(tok->pb, case_start, case_len); + + if (tok->pb->buf[0] == '-' && case_len == 1 && + (c == 'i' || c == 'I')) + { + state = json_tokener_state_inf; + goto redo_char; + } + } + { + int64_t num64; + double numd; + if (!tok->is_double && json_parse_int64(tok->pb->buf, &num64) == 0) { + if (num64 && tok->pb->buf[0]=='0' && (tok->flags & JSON_TOKENER_STRICT)) { + /* in strict mode, number must not start with 0 */ + tok->err = json_tokener_error_parse_number; + goto out; + } + current = json_object_new_int64(num64); + } + else if(tok->is_double && json_parse_double(tok->pb->buf, &numd) == 0) + { + current = json_object_new_double_s(numd, tok->pb->buf); + } else { + tok->err = json_tokener_error_parse_number; + goto out; + } + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + goto redo_char; + } + break; + + case json_tokener_state_array_after_sep: + case json_tokener_state_array: + if(c == ']') { + if (state == json_tokener_state_array_after_sep && + (tok->flags & JSON_TOKENER_STRICT)) + { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else { + if(tok->depth >= tok->max_depth-1) { + tok->err = json_tokener_error_depth; + goto out; + } + state = json_tokener_state_array_add; + tok->depth++; + json_tokener_reset_level(tok, tok->depth); + goto redo_char; + } + break; + + case json_tokener_state_array_add: + json_object_array_add(current, obj); + saved_state = json_tokener_state_array_sep; + state = json_tokener_state_eatws; + goto redo_char; + + case json_tokener_state_array_sep: + if(c == ']') { + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else if(c == ',') { + saved_state = json_tokener_state_array_after_sep; + state = json_tokener_state_eatws; + } else { + tok->err = json_tokener_error_parse_array; + goto out; + } + break; + + case json_tokener_state_object_field_start: + case json_tokener_state_object_field_start_after_sep: + if(c == '}') { + if (state == json_tokener_state_object_field_start_after_sep && + (tok->flags & JSON_TOKENER_STRICT)) + { + tok->err = json_tokener_error_parse_unexpected; + goto out; + } + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else if (c == '""' || c == '\'') { + tok->quote_char = c; + printbuf_reset(tok->pb); + state = json_tokener_state_object_field; + } else { + tok->err = json_tokener_error_parse_object_key_name; + goto out; + } + break; + + case json_tokener_state_object_field: + { + /* Advance until we change state */ + const char *case_start = str; + while(1) { + if(c == tok->quote_char) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + obj_field_name = strdup(tok->pb->buf); + saved_state = json_tokener_state_object_field_end; + state = json_tokener_state_eatws; + break; + } else if(c == '\\') { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + saved_state = json_tokener_state_object_field; + state = json_tokener_state_string_escape; + break; + } + if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) { + printbuf_memappend_fast(tok->pb, case_start, str-case_start); + goto out; + } + } + } + break; + + case json_tokener_state_object_field_end: + if(c == ':') { + saved_state = json_tokener_state_object_value; + state = json_tokener_state_eatws; + } else { + tok->err = json_tokener_error_parse_object_key_sep; + goto out; + } + break; + + case json_tokener_state_object_value: + if(tok->depth >= tok->max_depth-1) { + tok->err = json_tokener_error_depth; + goto out; + } + state = json_tokener_state_object_value_add; + tok->depth++; + json_tokener_reset_level(tok, tok->depth); + goto redo_char; + + case json_tokener_state_object_value_add: + json_object_object_add(current, obj_field_name, obj); + free(obj_field_name); + obj_field_name = NULL; + saved_state = json_tokener_state_object_sep; + state = json_tokener_state_eatws; + goto redo_char; + + case json_tokener_state_object_sep: + if(c == '}') { + saved_state = json_tokener_state_finish; + state = json_tokener_state_eatws; + } else if(c == ',') { + saved_state = json_tokener_state_object_field_start_after_sep; + state = json_tokener_state_eatws; + } else { + tok->err = json_tokener_error_parse_object_value_sep; + goto out; + } + break; + + } + if (!ADVANCE_CHAR(str, tok)) + goto out; + } /* while(POP_CHAR) */ +","@@ -81,6 +81,7 @@ static const char* json_tokener_errors[] = { + ""object value separator ',' expected"", + ""invalid string sequence"", + ""expected comment"", ++ ""buffer size overflow"" + }; + + const char *json_tokener_error_desc(enum json_tokener_error jerr) +@@ -243,6 +244,16 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, + tok->char_offset = 0; + tok->err = json_tokener_success; + ++ /* this interface is presently not 64-bit clean due to the int len argument ++ and the internal printbuf interface that takes 32-bit int len arguments ++ so the function limits the maximum string size to INT32_MAX (2GB). ++ If the function is called with len == -1 then strlen is called to check ++ the string length is less than INT32_MAX (2GB) */ ++ if ((len < -1) || (len == -1 && strlen(str) > INT32_MAX)) { ++ tok->err = json_tokener_error_size; ++ return NULL; ++ } ++ + while (PEEK_CHAR(c, tok)) { + + redo_char:",5106,5342,6144 +18191,"static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + Image *image,ExceptionInfo *exception) +{ +#define MaxCount 128 +#define PictCropRegionOp 0x01 +#define PictEndOfPictureOp 0xff +#define PictJPEGOp 0x8200 +#define PictInfoOp 0x0C00 +#define PictInfoSize 512 +#define PictPixmapOp 0x9A +#define PictPICTOp 0x98 +#define PictVersion 0x11 + + const StringInfo + *profile; + + double + x_resolution, + y_resolution; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + PICTPixmap + pixmap; + + PICTRectangle + bounds, + crop_rectangle, + destination_rectangle, + frame_rectangle, + size_rectangle, + source_rectangle; + + register const Quantum + *p; + + register ssize_t + i, + x; + + size_t + bytes_per_line, + count, + storage_class; + + ssize_t + y; + + unsigned char + *buffer, + *packed_scanline, + *scanline; + + unsigned short + base_address, + row_bytes, + transfer_mode; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if ((image->columns > 65535L) || (image->rows > 65535L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) TransformImageColorspace(image,sRGBColorspace,exception); + /* + Initialize image info. + */ + size_rectangle.top=0; + size_rectangle.left=0; + size_rectangle.bottom=(short) image->rows; + size_rectangle.right=(short) image->columns; + frame_rectangle=size_rectangle; + crop_rectangle=size_rectangle; + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; + row_bytes=(unsigned short) (image->columns | 0x8000); + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; + bounds.right=(short) image->columns; + pixmap.version=0; + pixmap.pack_type=0; + pixmap.pack_size=0; + pixmap.pixel_type=0; + pixmap.bits_per_pixel=8; + pixmap.component_count=1; + pixmap.component_size=8; + pixmap.plane_bytes=0; + pixmap.table=0; + pixmap.reserved=0; + transfer_mode=0; + x_resolution=image->resolution.x != 0.0 ? image->resolution.x : + DefaultResolution; + y_resolution=image->resolution.y != 0.0 ? image->resolution.y : + DefaultResolution; + storage_class=image->storage_class; + if (image_info->compression == JPEGCompression) + storage_class=DirectClass; + if (storage_class == DirectClass) + { + pixmap.component_count=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + pixmap.pixel_type=16; + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; + row_bytes=(unsigned short) ((4*image->columns) | 0x8000); + } + /* + Allocate memory. + */ + bytes_per_line=image->columns; + if (storage_class == DirectClass) + bytes_per_line*=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer)); + packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t) + (row_bytes+MaxCount),sizeof(*packed_scanline)); + scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline)); + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) ResetMagickMemory(scanline,0,row_bytes); + (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /* + Write header, header size, size bounding box, version, and reserved. + */ + (void) ResetMagickMemory(buffer,0,PictInfoSize); + (void) WriteBlob(image,PictInfoSize,buffer); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right); + (void) WriteBlobMSBShort(image,PictVersion); + (void) WriteBlobMSBShort(image,0x02ff); /* version #2 */ + (void) WriteBlobMSBShort(image,PictInfoOp); + (void) WriteBlobMSBLong(image,0xFFFE0000UL); + /* + Write full size of the file, resolution, frame bounding box, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right); + (void) WriteBlobMSBLong(image,0x00000000L); + profile=GetImageProfile(image,""iptc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0x1f2); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobString(image,""8BIM""); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + } + profile=GetImageProfile(image,""icc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,4); + (void) WriteBlobMSBLong(image,0x00000002UL); + } + /* + Write crop region opcode and crop bounding box. + */ + (void) WriteBlobMSBShort(image,PictCropRegionOp); + (void) WriteBlobMSBShort(image,0xa); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right); + if (image_info->compression == JPEGCompression) + { + Image + *jpeg_image; + + ImageInfo + *jpeg_info; + + size_t + length; + + unsigned char + *blob; + + jpeg_image=CloneImage(image,0,0,MagickTrue,exception); + if (jpeg_image == (Image *) NULL) + { + (void) CloseBlob(image); + return(MagickFalse); + } + jpeg_info=CloneImageInfo(image_info); + (void) CopyMagickString(jpeg_info->magick,""JPEG"",MagickPathExtent); + length=0; + blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length, + exception); + jpeg_info=DestroyImageInfo(jpeg_info); + if (blob == (unsigned char *) NULL) + return(MagickFalse); + jpeg_image=DestroyImage(jpeg_image); + (void) WriteBlobMSBShort(image,PictJPEGOp); + (void) WriteBlobMSBLong(image,(unsigned int) length+154); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x40000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00400000UL); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00566A70UL); + (void) WriteBlobMSBLong(image,0x65670000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000001UL); + (void) WriteBlobMSBLong(image,0x00016170UL); + (void) WriteBlobMSBLong(image,0x706C0000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x87AC0001UL); + (void) WriteBlobMSBLong(image,0x0B466F74UL); + (void) WriteBlobMSBLong(image,0x6F202D20UL); + (void) WriteBlobMSBLong(image,0x4A504547UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x0018FFFFUL); + (void) WriteBlob(image,length,blob); + if ((length & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + blob=(unsigned char *) RelinquishMagickMemory(blob); + } + /* + Write picture opcode, row bytes, and picture bounding box, and version. + */ + if (storage_class == PseudoClass) + (void) WriteBlobMSBShort(image,PictPICTOp); + else + { + (void) WriteBlobMSBShort(image,PictPixmapOp); + (void) WriteBlobMSBLong(image,(size_t) base_address); + } + (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000)); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.top); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.left); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.right); + /* + Write pack type, pack size, resolution, pixel type, and pixel size. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size); + (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel); + /* + Write component count, size, plane bytes, table size, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved); + if (storage_class == PseudoClass) + { + /* + Write image colormap. + */ + (void) WriteBlobMSBLong(image,0x00000000L); /* color seed */ + (void) WriteBlobMSBShort(image,0L); /* color flags */ + (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1)); + for (i=0; i < (ssize_t) image->colors; i++) + { + (void) WriteBlobMSBShort(image,(unsigned short) i); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].red)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].green)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].blue)); + } + } + /* + Write source and destination rectangle. + */ + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode); + /* + Write picture data. + */ + count=0; + if (storage_class == PseudoClass) + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + scanline[x]=(unsigned char) GetPixelIndex(image,p); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image_info->compression == JPEGCompression) + { + (void) ResetMagickMemory(scanline,0,row_bytes); + for (y=0; y < (ssize_t) image->rows; y++) + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + } + else + { + register unsigned char + *blue, + *green, + *opacity, + *red; + + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + opacity=scanline+3*image->columns; + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + if (image->alpha_trait != UndefinedPixelTrait) + { + opacity=scanline; + red=scanline+image->columns; + green=scanline+2*image->columns; + blue=scanline+3*image->columns; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + *red++=ScaleQuantumToChar(GetPixelRed(image,p)); + *green++=ScaleQuantumToChar(GetPixelGreen(image,p)); + *blue++=ScaleQuantumToChar(GetPixelBlue(image,p)); + if (image->alpha_trait != UndefinedPixelTrait) + *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p))); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,bytes_per_line & 0x7FFF, + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if ((count & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + (void) WriteBlobMSBShort(image,PictEndOfPictureOp); + offset=TellBlob(image); + offset=SeekBlob(image,512,SEEK_SET); + (void) WriteBlobMSBShort(image,(unsigned short) offset); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + (void) CloseBlob(image); + return(MagickTrue); +} +",1,"static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + Image *image,ExceptionInfo *exception) +{ +#define MaxCount 128 +#define PictCropRegionOp 0x01 +#define PictEndOfPictureOp 0xff +#define PictJPEGOp 0x8200 +#define PictInfoOp 0x0C00 +#define PictInfoSize 512 +#define PictPixmapOp 0x9A +#define PictPICTOp 0x98 +#define PictVersion 0x11 + + const StringInfo + *profile; + + double + x_resolution, + y_resolution; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + PICTPixmap + pixmap; + + PICTRectangle + bounds, + crop_rectangle, + destination_rectangle, + frame_rectangle, + size_rectangle, + source_rectangle; + + register const Quantum + *p; + + register ssize_t + i, + x; + + size_t + bytes_per_line, + count, + row_bytes, + storage_class; + + ssize_t + y; + + unsigned char + *buffer, + *packed_scanline, + *scanline; + + unsigned short + base_address, + transfer_mode; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if ((image->columns > 65535L) || (image->rows > 65535L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) TransformImageColorspace(image,sRGBColorspace,exception); + /* + Initialize image info. + */ + size_rectangle.top=0; + size_rectangle.left=0; + size_rectangle.bottom=(short) image->rows; + size_rectangle.right=(short) image->columns; + frame_rectangle=size_rectangle; + crop_rectangle=size_rectangle; + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; + row_bytes=image->columns; + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; + bounds.right=(short) image->columns; + pixmap.version=0; + pixmap.pack_type=0; + pixmap.pack_size=0; + pixmap.pixel_type=0; + pixmap.bits_per_pixel=8; + pixmap.component_count=1; + pixmap.component_size=8; + pixmap.plane_bytes=0; + pixmap.table=0; + pixmap.reserved=0; + transfer_mode=0; + x_resolution=image->resolution.x != 0.0 ? image->resolution.x : + DefaultResolution; + y_resolution=image->resolution.y != 0.0 ? image->resolution.y : + DefaultResolution; + storage_class=image->storage_class; + if (image_info->compression == JPEGCompression) + storage_class=DirectClass; + if (storage_class == DirectClass) + { + pixmap.component_count=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + pixmap.pixel_type=16; + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; + row_bytes=4*image->columns; + } + /* + Allocate memory. + */ + bytes_per_line=image->columns; + if (storage_class == DirectClass) + bytes_per_line*=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer)); + packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t) + (row_bytes+MaxCount),sizeof(*packed_scanline)); + scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline)); + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) ResetMagickMemory(scanline,0,row_bytes); + (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /* + Write header, header size, size bounding box, version, and reserved. + */ + (void) ResetMagickMemory(buffer,0,PictInfoSize); + (void) WriteBlob(image,PictInfoSize,buffer); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right); + (void) WriteBlobMSBShort(image,PictVersion); + (void) WriteBlobMSBShort(image,0x02ff); /* version #2 */ + (void) WriteBlobMSBShort(image,PictInfoOp); + (void) WriteBlobMSBLong(image,0xFFFE0000UL); + /* + Write full size of the file, resolution, frame bounding box, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right); + (void) WriteBlobMSBLong(image,0x00000000L); + profile=GetImageProfile(image,""iptc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0x1f2); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobString(image,""8BIM""); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + } + profile=GetImageProfile(image,""icc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,4); + (void) WriteBlobMSBLong(image,0x00000002UL); + } + /* + Write crop region opcode and crop bounding box. + */ + (void) WriteBlobMSBShort(image,PictCropRegionOp); + (void) WriteBlobMSBShort(image,0xa); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right); + if (image_info->compression == JPEGCompression) + { + Image + *jpeg_image; + + ImageInfo + *jpeg_info; + + size_t + length; + + unsigned char + *blob; + + jpeg_image=CloneImage(image,0,0,MagickTrue,exception); + if (jpeg_image == (Image *) NULL) + { + (void) CloseBlob(image); + return(MagickFalse); + } + jpeg_info=CloneImageInfo(image_info); + (void) CopyMagickString(jpeg_info->magick,""JPEG"",MagickPathExtent); + length=0; + blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length, + exception); + jpeg_info=DestroyImageInfo(jpeg_info); + if (blob == (unsigned char *) NULL) + return(MagickFalse); + jpeg_image=DestroyImage(jpeg_image); + (void) WriteBlobMSBShort(image,PictJPEGOp); + (void) WriteBlobMSBLong(image,(unsigned int) length+154); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00010000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x40000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00400000UL); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00566A70UL); + (void) WriteBlobMSBLong(image,0x65670000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000001UL); + (void) WriteBlobMSBLong(image,0x00016170UL); + (void) WriteBlobMSBLong(image,0x706C0000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x87AC0001UL); + (void) WriteBlobMSBLong(image,0x0B466F74UL); + (void) WriteBlobMSBLong(image,0x6F202D20UL); + (void) WriteBlobMSBLong(image,0x4A504547UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x00000000UL); + (void) WriteBlobMSBLong(image,0x0018FFFFUL); + (void) WriteBlob(image,length,blob); + if ((length & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + blob=(unsigned char *) RelinquishMagickMemory(blob); + } + /* + Write picture opcode, row bytes, and picture bounding box, and version. + */ + if (storage_class == PseudoClass) + (void) WriteBlobMSBShort(image,PictPICTOp); + else + { + (void) WriteBlobMSBShort(image,PictPixmapOp); + (void) WriteBlobMSBLong(image,(size_t) base_address); + } + (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000)); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.top); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.left); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.right); + /* + Write pack type, pack size, resolution, pixel type, and pixel size. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size); + (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel); + /* + Write component count, size, plane bytes, table size, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved); + if (storage_class == PseudoClass) + { + /* + Write image colormap. + */ + (void) WriteBlobMSBLong(image,0x00000000L); /* color seed */ + (void) WriteBlobMSBShort(image,0L); /* color flags */ + (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1)); + for (i=0; i < (ssize_t) image->colors; i++) + { + (void) WriteBlobMSBShort(image,(unsigned short) i); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].red)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].green)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].blue)); + } + } + /* + Write source and destination rectangle. + */ + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode); + /* + Write picture data. + */ + count=0; + if (storage_class == PseudoClass) + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + scanline[x]=(unsigned char) GetPixelIndex(image,p); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image_info->compression == JPEGCompression) + { + (void) ResetMagickMemory(scanline,0,row_bytes); + for (y=0; y < (ssize_t) image->rows; y++) + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + } + else + { + register unsigned char + *blue, + *green, + *opacity, + *red; + + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + opacity=scanline+3*image->columns; + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + if (image->alpha_trait != UndefinedPixelTrait) + { + opacity=scanline; + red=scanline+image->columns; + green=scanline+2*image->columns; + blue=scanline+3*image->columns; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + *red++=ScaleQuantumToChar(GetPixelRed(image,p)); + *green++=ScaleQuantumToChar(GetPixelGreen(image,p)); + *blue++=ScaleQuantumToChar(GetPixelBlue(image,p)); + if (image->alpha_trait != UndefinedPixelTrait) + *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p))); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,bytes_per_line & 0x7FFF, + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if ((count & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + (void) WriteBlobMSBShort(image,PictEndOfPictureOp); + offset=TellBlob(image); + offset=SeekBlob(image,512,SEEK_SET); + (void) WriteBlobMSBShort(image,(unsigned short) offset); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + (void) CloseBlob(image); + return(MagickTrue); +} +","@@ -1637,6 +1637,7 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + size_t + bytes_per_line, + count, ++ row_bytes, + storage_class; + + ssize_t +@@ -1649,7 +1650,6 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + + unsigned short + base_address, +- row_bytes, + transfer_mode; + + /* +@@ -1681,7 +1681,7 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; +- row_bytes=(unsigned short) (image->columns | 0x8000); ++ row_bytes=image->columns; + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; +@@ -1711,7 +1711,7 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; +- row_bytes=(unsigned short) ((4*image->columns) | 0x8000); ++ row_bytes=4*image->columns; + } + /* + Allocate memory.",4774,5010,6144 +18211,"static Image *ReadOneJNGImage(MngInfo *mng_info, + const ImageInfo *image_info, ExceptionInfo *exception) +{ + Image + *alpha_image, + *color_image, + *image, + *jng_image; + + ImageInfo + *alpha_image_info, + *color_image_info; + + MagickBooleanType + logging; + + ssize_t + y; + + MagickBooleanType + status; + + png_uint_32 + jng_height, + jng_width; + + png_byte + jng_color_type, + jng_image_sample_depth, + jng_image_compression_method, + jng_image_interlace_method, + jng_alpha_sample_depth, + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method; + + register const Quantum + *s; + + register ssize_t + i, + x; + + register Quantum + *q; + + register unsigned char + *p; + + unsigned int + read_JSEP, + reading_idat; + + size_t + length; + + jng_alpha_compression_method=0; + jng_alpha_sample_depth=8; + jng_color_type=0; + jng_height=0; + jng_width=0; + alpha_image=(Image *) NULL; + color_image=(Image *) NULL; + alpha_image_info=(ImageInfo *) NULL; + color_image_info=(ImageInfo *) NULL; + + logging=LogMagickEvent(CoderEvent,GetMagickModule(), + "" Enter ReadOneJNGImage()""); + + image=mng_info->image; + + if (GetAuthenticPixelQueue(image) != (Quantum *) NULL) + { + /* + Allocate next image structure. + */ + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" AcquireNextImage()""); + + AcquireNextImage(image_info,image,exception); + + if (GetNextImageInList(image) == (Image *) NULL) + return(DestroyImageList(image)); + + image=SyncNextImageInList(image); + } + mng_info->image=image; + + /* + Signature bytes have already been read. + */ + + read_JSEP=MagickFalse; + reading_idat=MagickFalse; + for (;;) + { + char + type[MagickPathExtent]; + + unsigned char + *chunk; + + unsigned int + count; + + /* + Read a new JNG chunk. + */ + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + break; + + type[0]='\0'; + (void) ConcatenateMagickString(type,""errr"",MagickPathExtent); + length=(size_t) ReadBlobMSBLong(image); + count=(unsigned int) ReadBlob(image,4,(unsigned char *) type); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading JNG chunk type %c%c%c%c, length: %.20g"", + type[0],type[1],type[2],type[3],(double) length); + + if (length > PNG_UINT_31_MAX || count == 0) + { + DestroyJNG(NULL,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (length > GetBlobSize(image)) + { + DestroyJNG(NULL,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + } + + p=NULL; + chunk=(unsigned char *) NULL; + + if (length != 0) + { + chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); + + if (chunk == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + + for (i=0; i < (ssize_t) length; i++) + { + int + c; + + c=ReadBlobByte(image); + if (c == EOF) + break; + chunk[i]=(unsigned char) c; + } + for ( ; i < (ssize_t) length; i++) + chunk[i]='\0'; + + p=chunk; + } + + (void) ReadBlobMSBLong(image); /* read crc word */ + + if (memcmp(type,mng_JHDR,4) == 0) + { + if (length == 16) + { + jng_width=(png_uint_32)mng_get_long(p); + jng_height=(png_uint_32)mng_get_long(&p[4]); + if ((jng_width == 0) || (jng_height == 0)) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError, + ""NegativeOrZeroImageSize""); + } + jng_color_type=p[8]; + jng_image_sample_depth=p[9]; + jng_image_compression_method=p[10]; + jng_image_interlace_method=p[11]; + + image->interlace=jng_image_interlace_method != 0 ? PNGInterlace : + NoInterlace; + + jng_alpha_sample_depth=p[12]; + jng_alpha_compression_method=p[13]; + jng_alpha_filter_method=p[14]; + jng_alpha_interlace_method=p[15]; + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_width: %16lu, jng_height: %16lu\n"" + "" jng_color_type: %16d, jng_image_sample_depth: %3d\n"" + "" jng_image_compression_method:%3d"", + (unsigned long) jng_width, (unsigned long) jng_height, + jng_color_type, jng_image_sample_depth, + jng_image_compression_method); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_image_interlace_method: %3d"" + "" jng_alpha_sample_depth: %3d"", + jng_image_interlace_method, + jng_alpha_sample_depth); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_alpha_compression_method:%3d\n"" + "" jng_alpha_filter_method: %3d\n"" + "" jng_alpha_interlace_method: %3d"", + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method); + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + if (jng_width > 65535 || jng_height > 65535 || + (long) jng_width > GetMagickResourceLimit(WidthResource) || + (long) jng_height > GetMagickResourceLimit(HeightResource)) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" JNG width or height too large: (%lu x %lu)"", + (long) jng_width, (long) jng_height); + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + + continue; + } + + + if ((reading_idat == MagickFalse) && (read_JSEP == MagickFalse) && + ((memcmp(type,mng_JDAT,4) == 0) || (memcmp(type,mng_JdAA,4) == 0) || + (memcmp(type,mng_IDAT,4) == 0) || (memcmp(type,mng_JDAA,4) == 0))) + { + /* + o create color_image + o open color_blob, attached to color_image + o if (color type has alpha) + open alpha_blob, attached to alpha_image + */ + + color_image_info=(ImageInfo *)AcquireMagickMemory(sizeof(ImageInfo)); + + if (color_image_info == (ImageInfo *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + GetImageInfo(color_image_info); + color_image=AcquireImage(color_image_info,exception); + + if (color_image == (Image *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating color_blob.""); + + (void) AcquireUniqueFilename(color_image->filename); + status=OpenBlob(color_image_info,color_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + return(DestroyImageList(image)); + } + + if ((image_info->ping == MagickFalse) && (jng_color_type >= 12)) + { + alpha_image_info=(ImageInfo *) + AcquireMagickMemory(sizeof(ImageInfo)); + + if (alpha_image_info == (ImageInfo *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + GetImageInfo(alpha_image_info); + alpha_image=AcquireImage(alpha_image_info,exception); + + if (alpha_image == (Image *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating alpha_blob.""); + + (void) AcquireUniqueFilename(alpha_image->filename); + status=OpenBlob(alpha_image_info,alpha_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + return(DestroyImageList(image)); + } + + if (jng_alpha_compression_method == 0) + { + unsigned char + data[18]; + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing IHDR chunk to alpha_blob.""); + + (void) WriteBlob(alpha_image,8,(const unsigned char *) + ""\211PNG\r\n\032\n""); + + (void) WriteBlobMSBULong(alpha_image,13L); + PNGType(data,mng_IHDR); + LogPNGChunk(logging,mng_IHDR,13L); + PNGLong(data+4,jng_width); + PNGLong(data+8,jng_height); + data[12]=jng_alpha_sample_depth; + data[13]=0; /* color_type gray */ + data[14]=0; /* compression method 0 */ + data[15]=0; /* filter_method 0 */ + data[16]=0; /* interlace_method 0 */ + (void) WriteBlob(alpha_image,17,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,17)); + } + } + reading_idat=MagickTrue; + } + + if (memcmp(type,mng_JDAT,4) == 0) + { + /* Copy chunk to color_image->blob */ + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + + if ((length != 0) && (color_image != (Image *) NULL)) + (void) WriteBlob(color_image,length,chunk); + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_IDAT,4) == 0) + { + png_byte + data[5]; + + /* Copy IDAT header and chunk data to alpha_image->blob */ + + if (alpha_image != NULL && image_info->ping == MagickFalse) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying IDAT chunk data to alpha_blob.""); + + (void) WriteBlobMSBULong(alpha_image,(size_t) length); + PNGType(data,mng_IDAT); + LogPNGChunk(logging,mng_IDAT,length); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlob(alpha_image,length,chunk); + (void) WriteBlobMSBULong(alpha_image, + crc32(crc32(0,data,4),chunk,(uInt) length)); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if ((memcmp(type,mng_JDAA,4) == 0) || (memcmp(type,mng_JdAA,4) == 0)) + { + /* Copy chunk data to alpha_image->blob */ + + if ((alpha_image != NULL) && (image_info->ping == MagickFalse) && + (length != 0)) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAA chunk data to alpha_blob.""); + + (void) WriteBlob(alpha_image,length,chunk); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_JSEP,4) == 0) + { + read_JSEP=MagickTrue; + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_bKGD,4) == 0) + { + if (length == 2) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=image->background_color.red; + image->background_color.blue=image->background_color.red; + } + + if (length == 6) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=ScaleCharToQuantum(p[3]); + image->background_color.blue=ScaleCharToQuantum(p[5]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_gAMA,4) == 0) + { + if (length == 4) + image->gamma=((float) mng_get_long(p))*0.00001; + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_cHRM,4) == 0) + { + if (length == 32) + { + image->chromaticity.white_point.x=0.00001*mng_get_long(p); + image->chromaticity.white_point.y=0.00001*mng_get_long(&p[4]); + image->chromaticity.red_primary.x=0.00001*mng_get_long(&p[8]); + image->chromaticity.red_primary.y=0.00001*mng_get_long(&p[12]); + image->chromaticity.green_primary.x=0.00001*mng_get_long(&p[16]); + image->chromaticity.green_primary.y=0.00001*mng_get_long(&p[20]); + image->chromaticity.blue_primary.x=0.00001*mng_get_long(&p[24]); + image->chromaticity.blue_primary.y=0.00001*mng_get_long(&p[28]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_sRGB,4) == 0) + { + if (length == 1) + { + image->rendering_intent= + Magick_RenderingIntent_from_PNG_RenderingIntent(p[0]); + image->gamma=1.000f/2.200f; + image->chromaticity.red_primary.x=0.6400f; + image->chromaticity.red_primary.y=0.3300f; + image->chromaticity.green_primary.x=0.3000f; + image->chromaticity.green_primary.y=0.6000f; + image->chromaticity.blue_primary.x=0.1500f; + image->chromaticity.blue_primary.y=0.0600f; + image->chromaticity.white_point.x=0.3127f; + image->chromaticity.white_point.y=0.3290f; + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_oFFs,4) == 0) + { + if (length > 8) + { + image->page.x=(ssize_t) mng_get_long(p); + image->page.y=(ssize_t) mng_get_long(&p[4]); + + if ((int) p[8] != 0) + { + image->page.x/=10000; + image->page.y/=10000; + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_pHYs,4) == 0) + { + if (length > 8) + { + image->resolution.x=(double) mng_get_long(p); + image->resolution.y=(double) mng_get_long(&p[4]); + if ((int) p[8] == PNG_RESOLUTION_METER) + { + image->units=PixelsPerCentimeterResolution; + image->resolution.x=image->resolution.x/100.0f; + image->resolution.y=image->resolution.y/100.0f; + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + +#if 0 + if (memcmp(type,mng_iCCP,4) == 0) + { + /* To do: */ + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } +#endif + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + if (memcmp(type,mng_IEND,4)) + continue; + + break; + } + + + /* IEND found */ + + /* + Finish up reading image data: + + o read main image from color_blob. + + o close color_blob. + + o if (color_type has alpha) + if alpha_encoding is PNG + read secondary image from alpha_blob via ReadPNG + if alpha_encoding is JPEG + read secondary image from alpha_blob via ReadJPEG + + o close alpha_blob. + + o copy intensity of secondary image into + alpha samples of main image. + + o destroy the secondary image. + */ + + if (color_image_info == (ImageInfo *) NULL) + { + assert(color_image == (Image *) NULL); + assert(alpha_image == (Image *) NULL); + if (color_image != (Image *) NULL) + color_image=DestroyImageList(color_image); + return(DestroyImageList(image)); + } + + if (color_image == (Image *) NULL) + { + assert(alpha_image == (Image *) NULL); + ThrowReaderException(CorruptImageError,""InsufficientImageDataInFile""); + } + + (void) SeekBlob(color_image,0,SEEK_SET); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading jng_image from color_blob.""); + + assert(color_image_info != (ImageInfo *) NULL); + (void) FormatLocaleString(color_image_info->filename,MagickPathExtent, + ""jpeg:%s"",color_image->filename); + + color_image_info->ping=MagickFalse; /* To do: avoid this */ + jng_image=ReadImage(color_image_info,exception); + + (void) RelinquishUniqueFileResource(color_image->filename); + color_image=DestroyImage(color_image); + color_image_info=DestroyImageInfo(color_image_info); + + if (jng_image == (Image *) NULL) + { + DestroyJNG(NULL,NULL,NULL,&alpha_image,&alpha_image_info); + return(DestroyImageList(image)); + } + + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying jng_image pixels to main image.""); + + image->rows=jng_height; + image->columns=jng_width; + + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + { + DestroyJNG(NULL,&color_image,&color_image_info,&alpha_image, + &alpha_image_info); + jng_image=DestroyImageList(jng_image); + return(DestroyImageList(image)); + } + if ((image->columns != jng_image->columns) || + (image->rows != jng_image->rows)) + { + DestroyJNG(NULL,&color_image,&color_image_info,&alpha_image, + &alpha_image_info); + jng_image=DestroyImageList(jng_image); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1,exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if ((s == (const Quantum *) NULL) || (q == (Quantum *) NULL)) + break; + for (x=(ssize_t) image->columns; x != 0; x--) + { + SetPixelRed(image,GetPixelRed(jng_image,s),q); + SetPixelGreen(image,GetPixelGreen(jng_image,s),q); + SetPixelBlue(image,GetPixelBlue(jng_image,s),q); + q+=GetPixelChannels(image); + s+=GetPixelChannels(jng_image); + } + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + + jng_image=DestroyImage(jng_image); + + if ((image_info->ping == MagickFalse) && (jng_color_type >= 12)) + { + if (jng_alpha_compression_method == 0) + { + png_byte + data[5]; + (void) WriteBlobMSBULong(alpha_image,0x00000000L); + PNGType(data,mng_IEND); + LogPNGChunk(logging,mng_IEND,0L); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,4)); + } + + (void) CloseBlob(alpha_image); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading alpha from alpha_blob.""); + + (void) FormatLocaleString(alpha_image_info->filename,MagickPathExtent, + ""%s"",alpha_image->filename); + + jng_image=ReadImage(alpha_image_info,exception); + + if (jng_image != (Image *) NULL) + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1,exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if ((s == (const Quantum *) NULL) || (q == (Quantum *) NULL)) + break; + + if (image->alpha_trait != UndefinedPixelTrait) + for (x=(ssize_t) image->columns; x != 0; x--) + { + SetPixelAlpha(image,GetPixelRed(jng_image,s),q); + q+=GetPixelChannels(image); + s+=GetPixelChannels(jng_image); + } + + else + for (x=(ssize_t) image->columns; x != 0; x--) + { + SetPixelAlpha(image,GetPixelRed(jng_image,s),q); + if (GetPixelAlpha(image,q) != OpaqueAlpha) + image->alpha_trait=BlendPixelTrait; + q+=GetPixelChannels(image); + s+=GetPixelChannels(jng_image); + } + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + (void) RelinquishUniqueFileResource(alpha_image->filename); + alpha_image=DestroyImage(alpha_image); + alpha_image_info=DestroyImageInfo(alpha_image_info); + if (jng_image != (Image *) NULL) + jng_image=DestroyImage(jng_image); + } + + /* Read the JNG image. */ + + if (mng_info->mng_type == 0) + { + mng_info->mng_width=jng_width; + mng_info->mng_height=jng_height; + } + + if (image->page.width == 0 && image->page.height == 0) + { + image->page.width=jng_width; + image->page.height=jng_height; + } + + if (image->page.x == 0 && image->page.y == 0) + { + image->page.x=mng_info->x_off[mng_info->object_id]; + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + else + { + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + mng_info->image_found++; + status=SetImageProgress(image,LoadImagesTag,2*TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + return(DestroyImageList(image)); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" exit ReadOneJNGImage()""); + + return(image); +} +",1,"static Image *ReadOneJNGImage(MngInfo *mng_info, + const ImageInfo *image_info, ExceptionInfo *exception) +{ + Image + *alpha_image, + *color_image, + *image, + *jng_image; + + ImageInfo + *alpha_image_info, + *color_image_info; + + MagickBooleanType + logging; + + ssize_t + y; + + MagickBooleanType + status; + + png_uint_32 + jng_height, + jng_width; + + png_byte + jng_color_type, + jng_image_sample_depth, + jng_image_compression_method, + jng_image_interlace_method, + jng_alpha_sample_depth, + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method; + + register const Quantum + *s; + + register ssize_t + i, + x; + + register Quantum + *q; + + register unsigned char + *p; + + unsigned int + read_JSEP, + reading_idat; + + size_t + length; + + jng_alpha_compression_method=0; + jng_alpha_sample_depth=8; + jng_color_type=0; + jng_height=0; + jng_width=0; + alpha_image=(Image *) NULL; + color_image=(Image *) NULL; + alpha_image_info=(ImageInfo *) NULL; + color_image_info=(ImageInfo *) NULL; + + logging=LogMagickEvent(CoderEvent,GetMagickModule(), + "" Enter ReadOneJNGImage()""); + + image=mng_info->image; + + if (GetAuthenticPixelQueue(image) != (Quantum *) NULL) + { + /* + Allocate next image structure. + */ + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" AcquireNextImage()""); + + AcquireNextImage(image_info,image,exception); + + if (GetNextImageInList(image) == (Image *) NULL) + return(DestroyImageList(image)); + + image=SyncNextImageInList(image); + } + mng_info->image=image; + + /* + Signature bytes have already been read. + */ + + read_JSEP=MagickFalse; + reading_idat=MagickFalse; + for (;;) + { + char + type[MagickPathExtent]; + + unsigned char + *chunk; + + unsigned int + count; + + /* + Read a new JNG chunk. + */ + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + break; + + type[0]='\0'; + (void) ConcatenateMagickString(type,""errr"",MagickPathExtent); + length=(size_t) ReadBlobMSBLong(image); + count=(unsigned int) ReadBlob(image,4,(unsigned char *) type); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading JNG chunk type %c%c%c%c, length: %.20g"", + type[0],type[1],type[2],type[3],(double) length); + + if (length > PNG_UINT_31_MAX || count == 0) + { + DestroyJNG(NULL,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (length > GetBlobSize(image)) + { + DestroyJNG(NULL,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + } + + p=NULL; + chunk=(unsigned char *) NULL; + + if (length != 0) + { + chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); + + if (chunk == (unsigned char *) NULL) + { + DestroyJNG(NULL,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + for (i=0; i < (ssize_t) length; i++) + { + int + c; + + c=ReadBlobByte(image); + if (c == EOF) + break; + chunk[i]=(unsigned char) c; + } + for ( ; i < (ssize_t) length; i++) + chunk[i]='\0'; + + p=chunk; + } + + (void) ReadBlobMSBLong(image); /* read crc word */ + + if (memcmp(type,mng_JHDR,4) == 0) + { + if (length == 16) + { + jng_width=(png_uint_32)mng_get_long(p); + jng_height=(png_uint_32)mng_get_long(&p[4]); + if ((jng_width == 0) || (jng_height == 0)) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError, + ""NegativeOrZeroImageSize""); + } + jng_color_type=p[8]; + jng_image_sample_depth=p[9]; + jng_image_compression_method=p[10]; + jng_image_interlace_method=p[11]; + + image->interlace=jng_image_interlace_method != 0 ? PNGInterlace : + NoInterlace; + + jng_alpha_sample_depth=p[12]; + jng_alpha_compression_method=p[13]; + jng_alpha_filter_method=p[14]; + jng_alpha_interlace_method=p[15]; + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_width: %16lu, jng_height: %16lu\n"" + "" jng_color_type: %16d, jng_image_sample_depth: %3d\n"" + "" jng_image_compression_method:%3d"", + (unsigned long) jng_width, (unsigned long) jng_height, + jng_color_type, jng_image_sample_depth, + jng_image_compression_method); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_image_interlace_method: %3d"" + "" jng_alpha_sample_depth: %3d"", + jng_image_interlace_method, + jng_alpha_sample_depth); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" jng_alpha_compression_method:%3d\n"" + "" jng_alpha_filter_method: %3d\n"" + "" jng_alpha_interlace_method: %3d"", + jng_alpha_compression_method, + jng_alpha_filter_method, + jng_alpha_interlace_method); + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + if (jng_width > 65535 || jng_height > 65535 || + (long) jng_width > GetMagickResourceLimit(WidthResource) || + (long) jng_height > GetMagickResourceLimit(HeightResource)) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" JNG width or height too large: (%lu x %lu)"", + (long) jng_width, (long) jng_height); + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + + continue; + } + + + if ((reading_idat == MagickFalse) && (read_JSEP == MagickFalse) && + ((memcmp(type,mng_JDAT,4) == 0) || (memcmp(type,mng_JdAA,4) == 0) || + (memcmp(type,mng_IDAT,4) == 0) || (memcmp(type,mng_JDAA,4) == 0))) + { + /* + o create color_image + o open color_blob, attached to color_image + o if (color type has alpha) + open alpha_blob, attached to alpha_image + */ + + color_image_info=(ImageInfo *)AcquireMagickMemory(sizeof(ImageInfo)); + + if (color_image_info == (ImageInfo *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + GetImageInfo(color_image_info); + color_image=AcquireImage(color_image_info,exception); + + if (color_image == (Image *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating color_blob.""); + + (void) AcquireUniqueFilename(color_image->filename); + status=OpenBlob(color_image_info,color_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + return(DestroyImageList(image)); + } + + if ((image_info->ping == MagickFalse) && (jng_color_type >= 12)) + { + alpha_image_info=(ImageInfo *) + AcquireMagickMemory(sizeof(ImageInfo)); + + if (alpha_image_info == (ImageInfo *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + GetImageInfo(alpha_image_info); + alpha_image=AcquireImage(alpha_image_info,exception); + + if (alpha_image == (Image *) NULL) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Creating alpha_blob.""); + + (void) AcquireUniqueFilename(alpha_image->filename); + status=OpenBlob(alpha_image_info,alpha_image,WriteBinaryBlobMode, + exception); + + if (status == MagickFalse) + { + DestroyJNG(chunk,&color_image,&color_image_info, + &alpha_image,&alpha_image_info); + return(DestroyImageList(image)); + } + + if (jng_alpha_compression_method == 0) + { + unsigned char + data[18]; + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing IHDR chunk to alpha_blob.""); + + (void) WriteBlob(alpha_image,8,(const unsigned char *) + ""\211PNG\r\n\032\n""); + + (void) WriteBlobMSBULong(alpha_image,13L); + PNGType(data,mng_IHDR); + LogPNGChunk(logging,mng_IHDR,13L); + PNGLong(data+4,jng_width); + PNGLong(data+8,jng_height); + data[12]=jng_alpha_sample_depth; + data[13]=0; /* color_type gray */ + data[14]=0; /* compression method 0 */ + data[15]=0; /* filter_method 0 */ + data[16]=0; /* interlace_method 0 */ + (void) WriteBlob(alpha_image,17,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,17)); + } + } + reading_idat=MagickTrue; + } + + if (memcmp(type,mng_JDAT,4) == 0) + { + /* Copy chunk to color_image->blob */ + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + + if ((length != 0) && (color_image != (Image *) NULL)) + (void) WriteBlob(color_image,length,chunk); + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_IDAT,4) == 0) + { + png_byte + data[5]; + + /* Copy IDAT header and chunk data to alpha_image->blob */ + + if (alpha_image != NULL && image_info->ping == MagickFalse) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying IDAT chunk data to alpha_blob.""); + + (void) WriteBlobMSBULong(alpha_image,(size_t) length); + PNGType(data,mng_IDAT); + LogPNGChunk(logging,mng_IDAT,length); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlob(alpha_image,length,chunk); + (void) WriteBlobMSBULong(alpha_image, + crc32(crc32(0,data,4),chunk,(uInt) length)); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if ((memcmp(type,mng_JDAA,4) == 0) || (memcmp(type,mng_JdAA,4) == 0)) + { + /* Copy chunk data to alpha_image->blob */ + + if ((alpha_image != NULL) && (image_info->ping == MagickFalse) && + (length != 0)) + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAA chunk data to alpha_blob.""); + + (void) WriteBlob(alpha_image,length,chunk); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_JSEP,4) == 0) + { + read_JSEP=MagickTrue; + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_bKGD,4) == 0) + { + if (length == 2) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=image->background_color.red; + image->background_color.blue=image->background_color.red; + } + + if (length == 6) + { + image->background_color.red=ScaleCharToQuantum(p[1]); + image->background_color.green=ScaleCharToQuantum(p[3]); + image->background_color.blue=ScaleCharToQuantum(p[5]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_gAMA,4) == 0) + { + if (length == 4) + image->gamma=((float) mng_get_long(p))*0.00001; + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_cHRM,4) == 0) + { + if (length == 32) + { + image->chromaticity.white_point.x=0.00001*mng_get_long(p); + image->chromaticity.white_point.y=0.00001*mng_get_long(&p[4]); + image->chromaticity.red_primary.x=0.00001*mng_get_long(&p[8]); + image->chromaticity.red_primary.y=0.00001*mng_get_long(&p[12]); + image->chromaticity.green_primary.x=0.00001*mng_get_long(&p[16]); + image->chromaticity.green_primary.y=0.00001*mng_get_long(&p[20]); + image->chromaticity.blue_primary.x=0.00001*mng_get_long(&p[24]); + image->chromaticity.blue_primary.y=0.00001*mng_get_long(&p[28]); + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_sRGB,4) == 0) + { + if (length == 1) + { + image->rendering_intent= + Magick_RenderingIntent_from_PNG_RenderingIntent(p[0]); + image->gamma=1.000f/2.200f; + image->chromaticity.red_primary.x=0.6400f; + image->chromaticity.red_primary.y=0.3300f; + image->chromaticity.green_primary.x=0.3000f; + image->chromaticity.green_primary.y=0.6000f; + image->chromaticity.blue_primary.x=0.1500f; + image->chromaticity.blue_primary.y=0.0600f; + image->chromaticity.white_point.x=0.3127f; + image->chromaticity.white_point.y=0.3290f; + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + + if (memcmp(type,mng_oFFs,4) == 0) + { + if (length > 8) + { + image->page.x=(ssize_t) mng_get_long(p); + image->page.y=(ssize_t) mng_get_long(&p[4]); + + if ((int) p[8] != 0) + { + image->page.x/=10000; + image->page.y/=10000; + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } + + if (memcmp(type,mng_pHYs,4) == 0) + { + if (length > 8) + { + image->resolution.x=(double) mng_get_long(p); + image->resolution.y=(double) mng_get_long(&p[4]); + if ((int) p[8] == PNG_RESOLUTION_METER) + { + image->units=PixelsPerCentimeterResolution; + image->resolution.x=image->resolution.x/100.0f; + image->resolution.y=image->resolution.y/100.0f; + } + } + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + continue; + } + +#if 0 + if (memcmp(type,mng_iCCP,4) == 0) + { + /* To do: */ + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + continue; + } +#endif + + chunk=(unsigned char *) RelinquishMagickMemory(chunk); + + if (memcmp(type,mng_IEND,4)) + continue; + + break; + } + + + /* IEND found */ + + /* + Finish up reading image data: + + o read main image from color_blob. + + o close color_blob. + + o if (color_type has alpha) + if alpha_encoding is PNG + read secondary image from alpha_blob via ReadPNG + if alpha_encoding is JPEG + read secondary image from alpha_blob via ReadJPEG + + o close alpha_blob. + + o copy intensity of secondary image into + alpha samples of main image. + + o destroy the secondary image. + */ + + if (color_image_info == (ImageInfo *) NULL) + { + assert(color_image == (Image *) NULL); + assert(alpha_image == (Image *) NULL); + if (color_image != (Image *) NULL) + color_image=DestroyImageList(color_image); + return(DestroyImageList(image)); + } + + if (color_image == (Image *) NULL) + { + assert(alpha_image == (Image *) NULL); + ThrowReaderException(CorruptImageError,""InsufficientImageDataInFile""); + } + + (void) SeekBlob(color_image,0,SEEK_SET); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading jng_image from color_blob.""); + + assert(color_image_info != (ImageInfo *) NULL); + (void) FormatLocaleString(color_image_info->filename,MagickPathExtent, + ""jpeg:%s"",color_image->filename); + + color_image_info->ping=MagickFalse; /* To do: avoid this */ + jng_image=ReadImage(color_image_info,exception); + + (void) RelinquishUniqueFileResource(color_image->filename); + color_image=DestroyImage(color_image); + color_image_info=DestroyImageInfo(color_image_info); + + if (jng_image == (Image *) NULL) + { + DestroyJNG(NULL,NULL,NULL,&alpha_image,&alpha_image_info); + return(DestroyImageList(image)); + } + + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying jng_image pixels to main image.""); + + image->rows=jng_height; + image->columns=jng_width; + + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + { + DestroyJNG(NULL,&color_image,&color_image_info,&alpha_image, + &alpha_image_info); + jng_image=DestroyImageList(jng_image); + return(DestroyImageList(image)); + } + if ((image->columns != jng_image->columns) || + (image->rows != jng_image->rows)) + { + DestroyJNG(NULL,&color_image,&color_image_info,&alpha_image, + &alpha_image_info); + jng_image=DestroyImageList(jng_image); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1,exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if ((s == (const Quantum *) NULL) || (q == (Quantum *) NULL)) + break; + for (x=(ssize_t) image->columns; x != 0; x--) + { + SetPixelRed(image,GetPixelRed(jng_image,s),q); + SetPixelGreen(image,GetPixelGreen(jng_image,s),q); + SetPixelBlue(image,GetPixelBlue(jng_image,s),q); + q+=GetPixelChannels(image); + s+=GetPixelChannels(jng_image); + } + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + + jng_image=DestroyImage(jng_image); + + if ((image_info->ping == MagickFalse) && (jng_color_type >= 12)) + { + if (jng_alpha_compression_method == 0) + { + png_byte + data[5]; + (void) WriteBlobMSBULong(alpha_image,0x00000000L); + PNGType(data,mng_IEND); + LogPNGChunk(logging,mng_IEND,0L); + (void) WriteBlob(alpha_image,4,data); + (void) WriteBlobMSBULong(alpha_image,crc32(0,data,4)); + } + + (void) CloseBlob(alpha_image); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Reading alpha from alpha_blob.""); + + (void) FormatLocaleString(alpha_image_info->filename,MagickPathExtent, + ""%s"",alpha_image->filename); + + jng_image=ReadImage(alpha_image_info,exception); + + if (jng_image != (Image *) NULL) + for (y=0; y < (ssize_t) image->rows; y++) + { + s=GetVirtualPixels(jng_image,0,y,image->columns,1,exception); + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if ((s == (const Quantum *) NULL) || (q == (Quantum *) NULL)) + break; + + if (image->alpha_trait != UndefinedPixelTrait) + for (x=(ssize_t) image->columns; x != 0; x--) + { + SetPixelAlpha(image,GetPixelRed(jng_image,s),q); + q+=GetPixelChannels(image); + s+=GetPixelChannels(jng_image); + } + + else + for (x=(ssize_t) image->columns; x != 0; x--) + { + SetPixelAlpha(image,GetPixelRed(jng_image,s),q); + if (GetPixelAlpha(image,q) != OpaqueAlpha) + image->alpha_trait=BlendPixelTrait; + q+=GetPixelChannels(image); + s+=GetPixelChannels(jng_image); + } + + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + (void) RelinquishUniqueFileResource(alpha_image->filename); + alpha_image=DestroyImage(alpha_image); + alpha_image_info=DestroyImageInfo(alpha_image_info); + if (jng_image != (Image *) NULL) + jng_image=DestroyImage(jng_image); + } + + /* Read the JNG image. */ + + if (mng_info->mng_type == 0) + { + mng_info->mng_width=jng_width; + mng_info->mng_height=jng_height; + } + + if (image->page.width == 0 && image->page.height == 0) + { + image->page.width=jng_width; + image->page.height=jng_height; + } + + if (image->page.x == 0 && image->page.y == 0) + { + image->page.x=mng_info->x_off[mng_info->object_id]; + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + else + { + image->page.y=mng_info->y_off[mng_info->object_id]; + } + + mng_info->image_found++; + status=SetImageProgress(image,LoadImagesTag,2*TellBlob(image), + 2*GetBlobSize(image)); + + if (status == MagickFalse) + return(DestroyImageList(image)); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" exit ReadOneJNGImage()""); + + return(image); +} +","@@ -4560,7 +4560,11 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk)); + + if (chunk == (unsigned char *) NULL) +- ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ { ++ DestroyJNG(NULL,&color_image,&color_image_info, ++ &alpha_image,&alpha_image_info); ++ ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); ++ } + + for (i=0; i < (ssize_t) length; i++) + { +@@ -4587,13 +4591,12 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + jng_width=(png_uint_32)mng_get_long(p); + jng_height=(png_uint_32)mng_get_long(&p[4]); + if ((jng_width == 0) || (jng_height == 0)) +- { +- DestroyJNG(chunk,&color_image,&color_image_info, +- &alpha_image,&alpha_image_info); +- +- ThrowReaderException(CorruptImageError, +- ""NegativeOrZeroImageSize""); +- } ++ { ++ DestroyJNG(chunk,&color_image,&color_image_info, ++ &alpha_image,&alpha_image_info); ++ ThrowReaderException(CorruptImageError, ++ ""NegativeOrZeroImageSize""); ++ } + jng_color_type=p[8]; + jng_image_sample_depth=p[9]; + jng_image_compression_method=p[10];",5784,6020,6144 +7732,"static CURLcode create_conn(struct Curl_easy *data, + struct connectdata **in_connect, + bool *async) +{ + CURLcode result = CURLE_OK; + struct connectdata *conn; + struct connectdata *conn_temp = NULL; + bool reuse; + bool connections_available = TRUE; + bool force_reuse = FALSE; + bool waitpipe = FALSE; + size_t max_host_connections = Curl_multi_max_host_connections(data->multi); + size_t max_total_connections = Curl_multi_max_total_connections(data->multi); + + *async = FALSE; + + /************************************************************* + * Check input data + *************************************************************/ + if(!data->change.url) { + result = CURLE_URL_MALFORMAT; + goto out; + } + + /* First, split up the current URL in parts so that we can use the + parts for checking against the already present connections. In order + to not have to modify everything at once, we allocate a temporary + connection data struct and fill in for comparison purposes. */ + conn = allocate_conn(data); + + if(!conn) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + /* We must set the return variable as soon as possible, so that our + parent can cleanup any possible allocs we may have done before + any failure */ + *in_connect = conn; + + result = parseurlandfillconn(data, conn); + if(result) + goto out; + + if(data->set.str[STRING_BEARER]) { + conn->oauth_bearer = strdup(data->set.str[STRING_BEARER]); + if(!conn->oauth_bearer) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + } + +#ifdef USE_UNIX_SOCKETS + if(data->set.str[STRING_UNIX_SOCKET_PATH]) { + conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]); + if(conn->unix_domain_socket == NULL) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + conn->abstract_unix_socket = data->set.abstract_unix_socket; + } +#endif + + /* After the unix socket init but before the proxy vars are used, parse and + initialize the proxy vars */ +#ifndef CURL_DISABLE_PROXY + result = create_conn_helper_init_proxy(conn); + if(result) + goto out; +#endif + + /************************************************************* + * If the protocol is using SSL and HTTP proxy is used, we set + * the tunnel_proxy bit. + *************************************************************/ + if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy) + conn->bits.tunnel_proxy = TRUE; + + /************************************************************* + * Figure out the remote port number and fix it in the URL + *************************************************************/ + result = parse_remote_port(data, conn); + if(result) + goto out; + + /* Check for overridden login details and set them accordingly so they + they are known when protocol->setup_connection is called! */ + result = override_login(data, conn, &conn->user, &conn->passwd, + &conn->options); + if(result) + goto out; + + result = set_login(conn); /* default credentials */ + if(result) + goto out; + + /************************************************************* + * Process the ""connect to"" linked list of hostname/port mappings. + * Do this after the remote port number has been fixed in the URL. + *************************************************************/ + result = parse_connect_to_slist(data, conn, data->set.connect_to); + if(result) + goto out; + + /************************************************************* + * IDN-fix the hostnames + *************************************************************/ + result = fix_hostname(conn, &conn->host); + if(result) + goto out; + if(conn->bits.conn_to_host) { + result = fix_hostname(conn, &conn->conn_to_host); + if(result) + goto out; + } + if(conn->bits.httpproxy) { + result = fix_hostname(conn, &conn->http_proxy.host); + if(result) + goto out; + } + if(conn->bits.socksproxy) { + result = fix_hostname(conn, &conn->socks_proxy.host); + if(result) + goto out; + } + + /************************************************************* + * Check whether the host and the ""connect to host"" are equal. + * Do this after the hostnames have been IDN-fixed. + *************************************************************/ + if(conn->bits.conn_to_host && + strcasecompare(conn->conn_to_host.name, conn->host.name)) { + conn->bits.conn_to_host = FALSE; + } + + /************************************************************* + * Check whether the port and the ""connect to port"" are equal. + * Do this after the remote port number has been fixed in the URL. + *************************************************************/ + if(conn->bits.conn_to_port && conn->conn_to_port == conn->remote_port) { + conn->bits.conn_to_port = FALSE; + } + + /************************************************************* + * If the ""connect to"" feature is used with an HTTP proxy, + * we set the tunnel_proxy bit. + *************************************************************/ + if((conn->bits.conn_to_host || conn->bits.conn_to_port) && + conn->bits.httpproxy) + conn->bits.tunnel_proxy = TRUE; + + /************************************************************* + * Setup internals depending on protocol. Needs to be done after + * we figured out what/if proxy to use. + *************************************************************/ + result = setup_connection_internals(conn); + if(result) + goto out; + + conn->recv[FIRSTSOCKET] = Curl_recv_plain; + conn->send[FIRSTSOCKET] = Curl_send_plain; + conn->recv[SECONDARYSOCKET] = Curl_recv_plain; + conn->send[SECONDARYSOCKET] = Curl_send_plain; + + conn->bits.tcp_fastopen = data->set.tcp_fastopen; + + /*********************************************************************** + * file: is a special case in that it doesn't need a network connection + ***********************************************************************/ +#ifndef CURL_DISABLE_FILE + if(conn->handler->flags & PROTOPT_NONETWORK) { + bool done; + /* this is supposed to be the connect function so we better at least check + that the file is present here! */ + DEBUGASSERT(conn->handler->connect_it); + Curl_persistconninfo(conn); + result = conn->handler->connect_it(conn, &done); + + /* Setup a ""faked"" transfer that'll do nothing */ + if(!result) { + conn->data = data; + conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are ""connected */ + + result = Curl_conncache_add_conn(data->state.conn_cache, conn); + if(result) + goto out; + + /* + * Setup whatever necessary for a resumed transfer + */ + result = setup_range(data); + if(result) { + DEBUGASSERT(conn->handler->done); + /* we ignore the return code for the protocol-specific DONE */ + (void)conn->handler->done(conn, result, FALSE); + goto out; + } + + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ + -1, NULL); /* no upload */ + } + + /* since we skip do_init() */ + Curl_init_do(data, conn); + + goto out; + } +#endif + + /* Get a cloned copy of the SSL config situation stored in the + connection struct. But to get this going nicely, we must first make + sure that the strings in the master copy are pointing to the correct + strings in the session handle strings array! + + Keep in mind that the pointers in the master copy are pointing to strings + that will be freed as part of the Curl_easy struct, but all cloned + copies will be separately allocated. + */ + data->set.ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_ORIG]; + data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY]; + data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_ORIG]; + data->set.proxy_ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_PROXY]; + data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE]; + data->set.proxy_ssl.primary.random_file = + data->set.str[STRING_SSL_RANDOM_FILE]; + data->set.ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET]; + data->set.proxy_ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET]; + data->set.ssl.primary.cipher_list = + data->set.str[STRING_SSL_CIPHER_LIST_ORIG]; + data->set.proxy_ssl.primary.cipher_list = + data->set.str[STRING_SSL_CIPHER_LIST_PROXY]; + data->set.ssl.primary.cipher_list13 = + data->set.str[STRING_SSL_CIPHER13_LIST_ORIG]; + data->set.proxy_ssl.primary.cipher_list13 = + data->set.str[STRING_SSL_CIPHER13_LIST_PROXY]; + + data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG]; + data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY]; + data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_ORIG]; + data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY]; + data->set.ssl.cert = data->set.str[STRING_CERT_ORIG]; + data->set.proxy_ssl.cert = data->set.str[STRING_CERT_PROXY]; + data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE_ORIG]; + data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY]; + data->set.ssl.key = data->set.str[STRING_KEY_ORIG]; + data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY]; + data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE_ORIG]; + data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY]; + data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_ORIG]; + data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY]; + data->set.ssl.primary.clientcert = data->set.str[STRING_CERT_ORIG]; + data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY]; +#ifdef USE_TLS_SRP + data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_ORIG]; + data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY]; + data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_ORIG]; + data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY]; +#endif + + if(!Curl_clone_primary_ssl_config(&data->set.ssl.primary, + &conn->ssl_config)) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + if(!Curl_clone_primary_ssl_config(&data->set.proxy_ssl.primary, + &conn->proxy_ssl_config)) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + prune_dead_connections(data); + + /************************************************************* + * Check the current list of connections to see if we can + * re-use an already existing one or if we have to create a + * new one. + *************************************************************/ + + DEBUGASSERT(conn->user); + DEBUGASSERT(conn->passwd); + + /* reuse_fresh is TRUE if we are told to use a new connection by force, but + we only acknowledge this option if this is not a re-used connection + already (which happens due to follow-location or during a HTTP + authentication phase). */ + if(data->set.reuse_fresh && !data->state.this_is_a_follow) + reuse = FALSE; + else + reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse, &waitpipe); + + /* If we found a reusable connection that is now marked as in use, we may + still want to open a new connection if we are pipelining. */ + if(reuse && !force_reuse && IsPipeliningPossible(data, conn_temp)) { + size_t pipelen = conn_temp->send_pipe.size + conn_temp->recv_pipe.size; + if(pipelen > 0) { + infof(data, ""Found connection %ld, with requests in the pipe (%zu)\n"", + conn_temp->connection_id, pipelen); + + if(Curl_conncache_bundle_size(conn_temp) < max_host_connections && + Curl_conncache_size(data) < max_total_connections) { + /* We want a new connection anyway */ + reuse = FALSE; + + infof(data, ""We can reuse, but we want a new connection anyway\n""); + Curl_conncache_return_conn(conn_temp); + } + } + } + + if(reuse) { + /* + * We already have a connection for this, we got the former connection + * in the conn_temp variable and thus we need to cleanup the one we + * just allocated before we can move along and use the previously + * existing one. + */ + reuse_conn(conn, conn_temp); +#ifdef USE_SSL + free(conn->ssl_extra); +#endif + free(conn); /* we don't need this anymore */ + conn = conn_temp; + *in_connect = conn; + + infof(data, ""Re-using existing connection! (#%ld) with %s %s\n"", + conn->connection_id, + conn->bits.proxy?""proxy"":""host"", + conn->socks_proxy.host.name ? conn->socks_proxy.host.dispname : + conn->http_proxy.host.name ? conn->http_proxy.host.dispname : + conn->host.dispname); + } + else { + /* We have decided that we want a new connection. However, we may not + be able to do that if we have reached the limit of how many + connections we are allowed to open. */ + + if(conn->handler->flags & PROTOPT_ALPN_NPN) { + /* The protocol wants it, so set the bits if enabled in the easy handle + (default) */ + if(data->set.ssl_enable_alpn) + conn->bits.tls_enable_alpn = TRUE; + if(data->set.ssl_enable_npn) + conn->bits.tls_enable_npn = TRUE; + } + + if(waitpipe) + /* There is a connection that *might* become usable for pipelining + ""soon"", and we wait for that */ + connections_available = FALSE; + else { + /* this gets a lock on the conncache */ + struct connectbundle *bundle = + Curl_conncache_find_bundle(conn, data->state.conn_cache); + + if(max_host_connections > 0 && bundle && + (bundle->num_connections >= max_host_connections)) { + struct connectdata *conn_candidate; + + /* The bundle is full. Extract the oldest connection. */ + conn_candidate = Curl_conncache_extract_bundle(data, bundle); + Curl_conncache_unlock(conn); + + if(conn_candidate) + (void)Curl_disconnect(data, conn_candidate, + /* dead_connection */ FALSE); + else { + infof(data, ""No more connections allowed to host: %zu\n"", + max_host_connections); + connections_available = FALSE; + } + } + else + Curl_conncache_unlock(conn); + + } + + if(connections_available && + (max_total_connections > 0) && + (Curl_conncache_size(data) >= max_total_connections)) { + struct connectdata *conn_candidate; + + /* The cache is full. Let's see if we can kill a connection. */ + conn_candidate = Curl_conncache_extract_oldest(data); + if(conn_candidate) + (void)Curl_disconnect(data, conn_candidate, + /* dead_connection */ FALSE); + else { + infof(data, ""No connections available in cache\n""); + connections_available = FALSE; + } + } + + if(!connections_available) { + infof(data, ""No connections available.\n""); + + conn_free(conn); + *in_connect = NULL; + + result = CURLE_NO_CONNECTION_AVAILABLE; + goto out; + } + else { + /* + * This is a brand new connection, so let's store it in the connection + * cache of ours! + */ + result = Curl_conncache_add_conn(data->state.conn_cache, conn); + if(result) + goto out; + } + +#if defined(USE_NTLM) + /* If NTLM is requested in a part of this connection, make sure we don't + assume the state is fine as this is a fresh connection and NTLM is + connection based. */ + if((data->state.authhost.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && + data->state.authhost.done) { + infof(data, ""NTLM picked AND auth done set, clear picked!\n""); + data->state.authhost.picked = CURLAUTH_NONE; + data->state.authhost.done = FALSE; + } + + if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && + data->state.authproxy.done) { + infof(data, ""NTLM-proxy picked AND auth done set, clear picked!\n""); + data->state.authproxy.picked = CURLAUTH_NONE; + data->state.authproxy.done = FALSE; + } +#endif + } + + /* Setup and init stuff before DO starts, in preparing for the transfer. */ + Curl_init_do(data, conn); + + /* + * Setup whatever necessary for a resumed transfer + */ + result = setup_range(data); + if(result) + goto out; + + /* Continue connectdata initialization here. */ + + /* + * Inherit the proper values from the urldata struct AFTER we have arranged + * the persistent connection stuff + */ + conn->seek_func = data->set.seek_func; + conn->seek_client = data->set.seek_client; + + /************************************************************* + * Resolve the address of the server or proxy + *************************************************************/ + result = resolve_server(data, conn, async); + +out: + return result; +} +",0,"static CURLcode create_conn(struct Curl_easy *data, + struct connectdata **in_connect, + bool *async) +{ + CURLcode result = CURLE_OK; + struct connectdata *conn; + struct connectdata *conn_temp = NULL; + bool reuse; + bool connections_available = TRUE; + bool force_reuse = FALSE; + bool waitpipe = FALSE; + size_t max_host_connections = Curl_multi_max_host_connections(data->multi); + size_t max_total_connections = Curl_multi_max_total_connections(data->multi); + + *async = FALSE; + + /************************************************************* + * Check input data + *************************************************************/ + if(!data->change.url) { + result = CURLE_URL_MALFORMAT; + goto out; + } + + /* First, split up the current URL in parts so that we can use the + parts for checking against the already present connections. In order + to not have to modify everything at once, we allocate a temporary + connection data struct and fill in for comparison purposes. */ + conn = allocate_conn(data); + + if(!conn) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + /* We must set the return variable as soon as possible, so that our + parent can cleanup any possible allocs we may have done before + any failure */ + *in_connect = conn; + + result = parseurlandfillconn(data, conn); + if(result) + goto out; + + if(data->set.str[STRING_BEARER]) { + conn->oauth_bearer = strdup(data->set.str[STRING_BEARER]); + if(!conn->oauth_bearer) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + } + +#ifdef USE_UNIX_SOCKETS + if(data->set.str[STRING_UNIX_SOCKET_PATH]) { + conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]); + if(conn->unix_domain_socket == NULL) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + conn->abstract_unix_socket = data->set.abstract_unix_socket; + } +#endif + + /* After the unix socket init but before the proxy vars are used, parse and + initialize the proxy vars */ +#ifndef CURL_DISABLE_PROXY + result = create_conn_helper_init_proxy(conn); + if(result) + goto out; +#endif + + /************************************************************* + * If the protocol is using SSL and HTTP proxy is used, we set + * the tunnel_proxy bit. + *************************************************************/ + if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy) + conn->bits.tunnel_proxy = TRUE; + + /************************************************************* + * Figure out the remote port number and fix it in the URL + *************************************************************/ + result = parse_remote_port(data, conn); + if(result) + goto out; + + /* Check for overridden login details and set them accordingly so they + they are known when protocol->setup_connection is called! */ + result = override_login(data, conn, &conn->user, &conn->passwd, + &conn->options); + if(result) + goto out; + + result = set_login(conn); /* default credentials */ + if(result) + goto out; + + /************************************************************* + * Process the ""connect to"" linked list of hostname/port mappings. + * Do this after the remote port number has been fixed in the URL. + *************************************************************/ + result = parse_connect_to_slist(data, conn, data->set.connect_to); + if(result) + goto out; + + /************************************************************* + * IDN-fix the hostnames + *************************************************************/ + result = fix_hostname(conn, &conn->host); + if(result) + goto out; + if(conn->bits.conn_to_host) { + result = fix_hostname(conn, &conn->conn_to_host); + if(result) + goto out; + } + if(conn->bits.httpproxy) { + result = fix_hostname(conn, &conn->http_proxy.host); + if(result) + goto out; + } + if(conn->bits.socksproxy) { + result = fix_hostname(conn, &conn->socks_proxy.host); + if(result) + goto out; + } + + /************************************************************* + * Check whether the host and the ""connect to host"" are equal. + * Do this after the hostnames have been IDN-fixed. + *************************************************************/ + if(conn->bits.conn_to_host && + strcasecompare(conn->conn_to_host.name, conn->host.name)) { + conn->bits.conn_to_host = FALSE; + } + + /************************************************************* + * Check whether the port and the ""connect to port"" are equal. + * Do this after the remote port number has been fixed in the URL. + *************************************************************/ + if(conn->bits.conn_to_port && conn->conn_to_port == conn->remote_port) { + conn->bits.conn_to_port = FALSE; + } + + /************************************************************* + * If the ""connect to"" feature is used with an HTTP proxy, + * we set the tunnel_proxy bit. + *************************************************************/ + if((conn->bits.conn_to_host || conn->bits.conn_to_port) && + conn->bits.httpproxy) + conn->bits.tunnel_proxy = TRUE; + + /************************************************************* + * Setup internals depending on protocol. Needs to be done after + * we figured out what/if proxy to use. + *************************************************************/ + result = setup_connection_internals(conn); + if(result) + goto out; + + conn->recv[FIRSTSOCKET] = Curl_recv_plain; + conn->send[FIRSTSOCKET] = Curl_send_plain; + conn->recv[SECONDARYSOCKET] = Curl_recv_plain; + conn->send[SECONDARYSOCKET] = Curl_send_plain; + + conn->bits.tcp_fastopen = data->set.tcp_fastopen; + + /*********************************************************************** + * file: is a special case in that it doesn't need a network connection + ***********************************************************************/ +#ifndef CURL_DISABLE_FILE + if(conn->handler->flags & PROTOPT_NONETWORK) { + bool done; + /* this is supposed to be the connect function so we better at least check + that the file is present here! */ + DEBUGASSERT(conn->handler->connect_it); + Curl_persistconninfo(conn); + result = conn->handler->connect_it(conn, &done); + + /* Setup a ""faked"" transfer that'll do nothing */ + if(!result) { + conn->data = data; + conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are ""connected */ + + result = Curl_conncache_add_conn(data->state.conn_cache, conn); + if(result) + goto out; + + /* + * Setup whatever necessary for a resumed transfer + */ + result = setup_range(data); + if(result) { + DEBUGASSERT(conn->handler->done); + /* we ignore the return code for the protocol-specific DONE */ + (void)conn->handler->done(conn, result, FALSE); + goto out; + } + + Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */ + -1, NULL); /* no upload */ + } + + /* since we skip do_init() */ + Curl_init_do(data, conn); + + goto out; + } +#endif + + /* Get a cloned copy of the SSL config situation stored in the + connection struct. But to get this going nicely, we must first make + sure that the strings in the master copy are pointing to the correct + strings in the session handle strings array! + + Keep in mind that the pointers in the master copy are pointing to strings + that will be freed as part of the Curl_easy struct, but all cloned + copies will be separately allocated. + */ + data->set.ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_ORIG]; + data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY]; + data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_ORIG]; + data->set.proxy_ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_PROXY]; + data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE]; + data->set.proxy_ssl.primary.random_file = + data->set.str[STRING_SSL_RANDOM_FILE]; + data->set.ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET]; + data->set.proxy_ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET]; + data->set.ssl.primary.cipher_list = + data->set.str[STRING_SSL_CIPHER_LIST_ORIG]; + data->set.proxy_ssl.primary.cipher_list = + data->set.str[STRING_SSL_CIPHER_LIST_PROXY]; + data->set.ssl.primary.cipher_list13 = + data->set.str[STRING_SSL_CIPHER13_LIST_ORIG]; + data->set.proxy_ssl.primary.cipher_list13 = + data->set.str[STRING_SSL_CIPHER13_LIST_PROXY]; + + data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG]; + data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY]; + data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_ORIG]; + data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY]; + data->set.ssl.cert = data->set.str[STRING_CERT_ORIG]; + data->set.proxy_ssl.cert = data->set.str[STRING_CERT_PROXY]; + data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE_ORIG]; + data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY]; + data->set.ssl.key = data->set.str[STRING_KEY_ORIG]; + data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY]; + data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE_ORIG]; + data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY]; + data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_ORIG]; + data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY]; + data->set.ssl.primary.clientcert = data->set.str[STRING_CERT_ORIG]; + data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY]; +#ifdef USE_TLS_SRP + data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_ORIG]; + data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY]; + data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_ORIG]; + data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY]; +#endif + + if(!Curl_clone_primary_ssl_config(&data->set.ssl.primary, + &conn->ssl_config)) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + if(!Curl_clone_primary_ssl_config(&data->set.proxy_ssl.primary, + &conn->proxy_ssl_config)) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + prune_dead_connections(data); + + /************************************************************* + * Check the current list of connections to see if we can + * re-use an already existing one or if we have to create a + * new one. + *************************************************************/ + + DEBUGASSERT(conn->user); + DEBUGASSERT(conn->passwd); + + /* reuse_fresh is TRUE if we are told to use a new connection by force, but + we only acknowledge this option if this is not a re-used connection + already (which happens due to follow-location or during a HTTP + authentication phase). */ + if(data->set.reuse_fresh && !data->state.this_is_a_follow) + reuse = FALSE; + else + reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse, &waitpipe); + + /* If we found a reusable connection that is now marked as in use, we may + still want to open a new connection if we are pipelining. */ + if(reuse && !force_reuse && IsPipeliningPossible(data, conn_temp)) { + size_t pipelen = conn_temp->send_pipe.size + conn_temp->recv_pipe.size; + if(pipelen > 0) { + infof(data, ""Found connection %ld, with requests in the pipe (%zu)\n"", + conn_temp->connection_id, pipelen); + + if(Curl_conncache_bundle_size(conn_temp) < max_host_connections && + Curl_conncache_size(data) < max_total_connections) { + /* We want a new connection anyway */ + reuse = FALSE; + + infof(data, ""We can reuse, but we want a new connection anyway\n""); + Curl_conncache_return_conn(conn_temp); + } + } + } + + if(reuse) { + /* + * We already have a connection for this, we got the former connection + * in the conn_temp variable and thus we need to cleanup the one we + * just allocated before we can move along and use the previously + * existing one. + */ + reuse_conn(conn, conn_temp); +#ifdef USE_SSL + free(conn->ssl_extra); +#endif + free(conn); /* we don't need this anymore */ + conn = conn_temp; + *in_connect = conn; + + infof(data, ""Re-using existing connection! (#%ld) with %s %s\n"", + conn->connection_id, + conn->bits.proxy?""proxy"":""host"", + conn->socks_proxy.host.name ? conn->socks_proxy.host.dispname : + conn->http_proxy.host.name ? conn->http_proxy.host.dispname : + conn->host.dispname); + } + else { + /* We have decided that we want a new connection. However, we may not + be able to do that if we have reached the limit of how many + connections we are allowed to open. */ + + if(conn->handler->flags & PROTOPT_ALPN_NPN) { + /* The protocol wants it, so set the bits if enabled in the easy handle + (default) */ + if(data->set.ssl_enable_alpn) + conn->bits.tls_enable_alpn = TRUE; + if(data->set.ssl_enable_npn) + conn->bits.tls_enable_npn = TRUE; + } + + if(waitpipe) + /* There is a connection that *might* become usable for pipelining + ""soon"", and we wait for that */ + connections_available = FALSE; + else { + /* this gets a lock on the conncache */ + struct connectbundle *bundle = + Curl_conncache_find_bundle(conn, data->state.conn_cache); + + if(max_host_connections > 0 && bundle && + (bundle->num_connections >= max_host_connections)) { + struct connectdata *conn_candidate; + + /* The bundle is full. Extract the oldest connection. */ + conn_candidate = Curl_conncache_extract_bundle(data, bundle); + Curl_conncache_unlock(conn); + + if(conn_candidate) + (void)Curl_disconnect(data, conn_candidate, + /* dead_connection */ FALSE); + else { + infof(data, ""No more connections allowed to host: %zu\n"", + max_host_connections); + connections_available = FALSE; + } + } + else + Curl_conncache_unlock(conn); + + } + + if(connections_available && + (max_total_connections > 0) && + (Curl_conncache_size(data) >= max_total_connections)) { + struct connectdata *conn_candidate; + + /* The cache is full. Let's see if we can kill a connection. */ + conn_candidate = Curl_conncache_extract_oldest(data); + if(conn_candidate) + (void)Curl_disconnect(data, conn_candidate, + /* dead_connection */ FALSE); + else { + infof(data, ""No connections available in cache\n""); + connections_available = FALSE; + } + } + + if(!connections_available) { + infof(data, ""No connections available.\n""); + + conn_free(conn); + *in_connect = NULL; + + result = CURLE_NO_CONNECTION_AVAILABLE; + goto out; + } + else { + /* + * This is a brand new connection, so let's store it in the connection + * cache of ours! + */ + result = Curl_conncache_add_conn(data->state.conn_cache, conn); + if(result) + goto out; + } + +#if defined(USE_NTLM) + /* If NTLM is requested in a part of this connection, make sure we don't + assume the state is fine as this is a fresh connection and NTLM is + connection based. */ + if((data->state.authhost.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && + data->state.authhost.done) { + infof(data, ""NTLM picked AND auth done set, clear picked!\n""); + data->state.authhost.picked = CURLAUTH_NONE; + data->state.authhost.done = FALSE; + } + + if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && + data->state.authproxy.done) { + infof(data, ""NTLM-proxy picked AND auth done set, clear picked!\n""); + data->state.authproxy.picked = CURLAUTH_NONE; + data->state.authproxy.done = FALSE; + } +#endif + } + + /* Setup and init stuff before DO starts, in preparing for the transfer. */ + Curl_init_do(data, conn); + + /* + * Setup whatever necessary for a resumed transfer + */ + result = setup_range(data); + if(result) + goto out; + + /* Continue connectdata initialization here. */ + + /* + * Inherit the proper values from the urldata struct AFTER we have arranged + * the persistent connection stuff + */ + conn->seek_func = data->set.seek_func; + conn->seek_client = data->set.seek_client; + + /************************************************************* + * Resolve the address of the server or proxy + *************************************************************/ + result = resolve_server(data, conn, async); + +out: + return result; +} +","@@ -331,10 +331,12 @@ CURLcode Curl_close(struct Curl_easy *data) + and detach this handle from there. */ + curl_multi_remove_handle(data->multi, data); + +- if(data->multi_easy) ++ if(data->multi_easy) { + /* when curl_easy_perform() is used, it creates its own multi handle to + use and this is the one */ + curl_multi_cleanup(data->multi_easy); ++ data->multi_easy = NULL; ++ } + + /* Destroy the timeout list that is held in the easy handle. It is + /normally/ done by curl_multi_remove_handle() but this is ""just in",3882,4118,6144 +18751,"WORD32 ih264d_mark_err_slice_skip(dec_struct_t * ps_dec, + WORD32 num_mb_skip, + UWORD8 u1_is_idr_slice, + UWORD16 u2_frame_num, + pocstruct_t *ps_cur_poc, + WORD32 prev_slice_err) +{ + WORD32 i2_cur_mb_addr; + UWORD32 u1_num_mbs, u1_num_mbsNby2; + UWORD32 u1_mb_idx = ps_dec->u1_mb_idx; + UWORD32 i2_mb_skip_run; + + UWORD32 u1_num_mbs_next, u1_end_of_row; + const UWORD32 i2_pic_wdin_mbs = ps_dec->u2_frm_wd_in_mbs; + UWORD32 u1_slice_end; + UWORD32 u1_tfr_n_mb; + UWORD32 u1_decode_nmb; + dec_bit_stream_t * const ps_bitstrm = ps_dec->ps_bitstrm; + dec_slice_params_t * ps_slice = ps_dec->ps_cur_slice; + UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer; + UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst; + deblk_mb_t *ps_cur_deblk_mb; + dec_mb_info_t *ps_cur_mb_info; + parse_pmbarams_t *ps_parse_mb_data; + UWORD32 u1_inter_mb_type; + UWORD32 u1_deblk_mb_type; + UWORD16 u2_total_mbs_coded; + UWORD32 u1_mbaff = ps_slice->u1_mbaff_frame_flag; + parse_part_params_t *ps_part_info; + WORD32 ret; + + + if(ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) + { + ih264d_err_pic_dispbuf_mgr(ps_dec); + return 0; + } + ps_dec->ps_dpb_cmds->u1_long_term_reference_flag = 0; + if(prev_slice_err == 1) + { + /* first slice - missing/header corruption */ + ps_dec->ps_cur_slice->u2_frame_num = u2_frame_num; + + + if(!ps_dec->u1_first_slice_in_stream) + { + ih264d_end_of_pic(ps_dec, u1_is_idr_slice, + ps_dec->ps_cur_slice->u2_frame_num); + ps_dec->s_cur_pic_poc.u2_frame_num = + ps_dec->ps_cur_slice->u2_frame_num; + } + + { + WORD32 i, j, poc = 0; + + ps_dec->ps_cur_slice->u2_first_mb_in_slice = 0; + + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff; + ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_bp; + ps_dec->p_motion_compensate = ih264d_motion_compensate_bp; + + if(ps_dec->ps_cur_pic != NULL) + poc = ps_dec->ps_cur_pic->i4_poc + 2; + + j = 0; + for(i = 0; i < MAX_NUM_PIC_PARAMS; i++) + if(ps_dec->ps_pps[i].u1_is_valid == TRUE) + j = i; + { + ps_dec->ps_cur_slice->u1_slice_type = P_SLICE; + ps_dec->ps_cur_slice->u1_nal_ref_idc = 1; + ps_dec->ps_cur_slice->u1_nal_unit_type = 1; + ret = ih264d_start_of_pic(ps_dec, poc, ps_cur_poc, + ps_dec->ps_cur_slice->u2_frame_num, + &ps_dec->ps_pps[j]); + + if(ret != OK) + { + return ret; + } + } + + ps_dec->ps_ref_pic_buf_lx[0][0]->u1_pic_buf_id = 0; + + ps_dec->u4_output_present = 0; + + { + ih264d_get_next_display_field(ps_dec, + ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + /* If error code is non-zero then there is no buffer available for display, + hence avoid format conversion */ + + if(0 != ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = ps_dec->s_disp_frame_info.u4_y_ht; + } + else + ps_dec->u4_output_present = 1; + } + + if(ps_dec->u1_separate_parse == 1) + { + if(ps_dec->u4_dec_thread_created == 0) + { + ithread_create(ps_dec->pv_dec_thread_handle, NULL, + (void *)ih264d_decode_picture_thread, + (void *)ps_dec); + + ps_dec->u4_dec_thread_created = 1; + } + + if((ps_dec->u4_num_cores == 3) && + ((ps_dec->u4_app_disable_deblk_frm == 0) || ps_dec->i1_recon_in_thread3_flag) + && (ps_dec->u4_bs_deblk_thread_created == 0)) + { + ps_dec->u4_start_recon_deblk = 0; + ithread_create(ps_dec->pv_bs_deblk_thread_handle, NULL, + (void *)ih264d_recon_deblk_thread, + (void *)ps_dec); + ps_dec->u4_bs_deblk_thread_created = 1; + + } + } + } + } + else + { + + dec_slice_struct_t *ps_parse_cur_slice; + ps_parse_cur_slice = ps_dec->ps_dec_slice_buf + ps_dec->u2_cur_slice_num; + + if(ps_dec->u1_slice_header_done + && ps_parse_cur_slice == ps_dec->ps_parse_cur_slice) + { + u1_num_mbs = ps_dec->u4_num_mbs_cur_nmb; + + if(u1_num_mbs) + { + ps_cur_mb_info = ps_dec->ps_nmb_info + u1_num_mbs - 1; + } + else + { + if(ps_dec->u1_separate_parse) + { + ps_cur_mb_info = ps_dec->ps_nmb_info - 1; + } + else + { + ps_cur_mb_info = ps_dec->ps_nmb_info + + ps_dec->u4_num_mbs_prev_nmb - 1; + } + } + + ps_dec->u2_mby = ps_cur_mb_info->u2_mby; + ps_dec->u2_mbx = ps_cur_mb_info->u2_mbx; + + ps_dec->u1_mb_ngbr_availablity = + ps_cur_mb_info->u1_mb_ngbr_availablity; + + ps_dec->pv_parse_tu_coeff_data = ps_dec->pv_prev_mb_parse_tu_coeff_data; + ps_dec->u2_cur_mb_addr--; + ps_dec->i4_submb_ofst -= SUB_BLK_SIZE; + + if(u1_num_mbs) + { + if (ps_dec->u1_pr_sl_type == P_SLICE + || ps_dec->u1_pr_sl_type == B_SLICE) + { + ps_dec->pf_mvpred_ref_tfr_nby2mb(ps_dec, u1_mb_idx, u1_num_mbs); + ps_dec->ps_part = ps_dec->ps_parse_part_params; + } + + u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec->u2_mbx - 1; + u1_end_of_row = (!u1_num_mbs_next) + && (!(u1_mbaff && (u1_num_mbs & 0x01))); + u1_slice_end = 1; + u1_tfr_n_mb = 1; + ps_cur_mb_info->u1_end_of_slice = u1_slice_end; + + if(ps_dec->u1_separate_parse) + { + ih264d_parse_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, + u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); + ps_dec->ps_nmb_info += u1_num_mbs; + } + else + { + ih264d_decode_recon_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, + u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); + } + ps_dec->u2_total_mbs_coded += u1_num_mbs; + ps_dec->u1_mb_idx = 0; + ps_dec->u4_num_mbs_cur_nmb = 0; + } + + if(ps_dec->u2_total_mbs_coded + >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + ps_dec->u1_pic_decode_done = 1; + return 0; + } + + ps_dec->u2_cur_slice_num++; + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + ps_dec->ps_parse_cur_slice++; + + } + else + { + ps_dec->ps_parse_cur_slice = ps_dec->ps_dec_slice_buf + + ps_dec->u2_cur_slice_num; + } + } + + /******************************************************/ + /* Initializations to new slice */ + /******************************************************/ + { + WORD32 num_entries; + WORD32 size; + UWORD8 *pu1_buf; + + num_entries = MAX_FRAMES; + if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) && + (0 == ps_dec->i4_display_delay)) + { + num_entries = 1; + } + num_entries = ((2 * num_entries) + 1); + if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc) + { + num_entries *= 2; + } + size = num_entries * sizeof(void *); + size += PAD_MAP_IDX_POC * sizeof(void *); + + pu1_buf = (UWORD8 *)ps_dec->pv_map_ref_idx_to_poc_buf; + pu1_buf += size * ps_dec->u2_cur_slice_num; + ps_dec->ps_parse_cur_slice->ppv_map_ref_idx_to_poc = (volatile void **)pu1_buf; + } + + ps_dec->ps_cur_slice->u2_first_mb_in_slice = ps_dec->u2_total_mbs_coded << u1_mbaff; + ps_dec->ps_cur_slice->i1_slice_alpha_c0_offset = 0; + ps_dec->ps_cur_slice->i1_slice_beta_offset = 0; + + if(ps_dec->ps_cur_slice->u1_field_pic_flag) + ps_dec->u2_prv_frame_num = ps_dec->ps_cur_slice->u2_frame_num; + + ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice = ps_dec->u2_total_mbs_coded << u1_mbaff; + ps_dec->ps_parse_cur_slice->u2_log2Y_crwd = ps_dec->ps_cur_slice->u2_log2Y_crwd; + + + if(ps_dec->u1_separate_parse) + { + ps_dec->ps_parse_cur_slice->pv_tu_coeff_data_start = ps_dec->pv_parse_tu_coeff_data; + } + else + { + ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_parse_tu_coeff_data; + } + + /******************************************************/ + /* Initializations specific to P slice */ + /******************************************************/ + u1_inter_mb_type = P_MB; + u1_deblk_mb_type = D_INTER_MB; + + ps_dec->ps_cur_slice->u1_slice_type = P_SLICE; + ps_dec->ps_parse_cur_slice->slice_type = P_SLICE; + ps_dec->pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_pmb; + ps_dec->ps_part = ps_dec->ps_parse_part_params; + + /******************************************************/ + /* Parsing / decoding the slice */ + /******************************************************/ + ps_dec->u1_slice_header_done = 2; + ps_dec->u1_qp = ps_slice->u1_slice_qp; + ih264d_update_qp(ps_dec, 0); + u1_mb_idx = ps_dec->u1_mb_idx; + ps_parse_mb_data = ps_dec->ps_parse_mb_data; + u1_num_mbs = u1_mb_idx; + + u1_slice_end = 0; + u1_tfr_n_mb = 0; + u1_decode_nmb = 0; + u1_num_mbsNby2 = 0; + i2_cur_mb_addr = ps_dec->u2_total_mbs_coded; + i2_mb_skip_run = num_mb_skip; + + while(!u1_slice_end) + { + UWORD8 u1_mb_type; + + if(i2_cur_mb_addr > ps_dec->ps_cur_sps->u2_max_mb_addr) + break; + + ps_cur_mb_info = ps_dec->ps_nmb_info + u1_num_mbs; + ps_dec->u4_num_mbs_cur_nmb = u1_num_mbs; + + ps_cur_mb_info->u1_Mux = 0; + ps_dec->u4_num_pmbair = (u1_num_mbs >> u1_mbaff); + ps_cur_deblk_mb = ps_dec->ps_deblk_mbn + u1_num_mbs; + + ps_cur_mb_info->u1_end_of_slice = 0; + + /* Storing Default partition info */ + ps_parse_mb_data->u1_num_part = 1; + ps_parse_mb_data->u1_isI_mb = 0; + + /**************************************************************/ + /* Get the required information for decoding of MB */ + /**************************************************************/ + /* mb_x, mb_y, neighbor availablity, */ + if (u1_mbaff) + ih264d_get_mb_info_cavlc_mbaff(ps_dec, i2_cur_mb_addr, ps_cur_mb_info, i2_mb_skip_run); + else + ih264d_get_mb_info_cavlc_nonmbaff(ps_dec, i2_cur_mb_addr, ps_cur_mb_info, i2_mb_skip_run); + + /* Set the deblocking parameters for this MB */ + if(ps_dec->u4_app_disable_deblk_frm == 0) + { + ih264d_set_deblocking_parameters(ps_cur_deblk_mb, ps_slice, + ps_dec->u1_mb_ngbr_availablity, + ps_dec->u1_cur_mb_fld_dec_flag); + } + + /* Set appropriate flags in ps_cur_mb_info and ps_dec */ + ps_dec->i1_prev_mb_qp_delta = 0; + ps_dec->u1_sub_mb_num = 0; + ps_cur_mb_info->u1_mb_type = MB_SKIP; + ps_cur_mb_info->u1_mb_mc_mode = PRED_16x16; + ps_cur_mb_info->u1_cbp = 0; + + /* Storing Skip partition info */ + ps_part_info = ps_dec->ps_part; + ps_part_info->u1_is_direct = PART_DIRECT_16x16; + ps_part_info->u1_sub_mb_num = 0; + ps_dec->ps_part++; + + /* Update Nnzs */ + ih264d_update_nnz_for_skipmb(ps_dec, ps_cur_mb_info, CAVLC); + + ps_cur_mb_info->ps_curmb->u1_mb_type = u1_inter_mb_type; + ps_cur_deblk_mb->u1_mb_type |= u1_deblk_mb_type; + + i2_mb_skip_run--; + + ps_cur_deblk_mb->u1_mb_qp = ps_dec->u1_qp; + + if (u1_mbaff) + { + ih264d_update_mbaff_left_nnz(ps_dec, ps_cur_mb_info); + } + + /**************************************************************/ + /* Get next Macroblock address */ + /**************************************************************/ + i2_cur_mb_addr++; + + u1_num_mbs++; + u1_num_mbsNby2++; + ps_parse_mb_data++; + + /****************************************************************/ + /* Check for End Of Row and other flags that determine when to */ + /* do DMA setup for N/2-Mb, Decode for N-Mb, and Transfer for */ + /* N-Mb */ + /****************************************************************/ + u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec->u2_mbx - 1; + u1_end_of_row = (!u1_num_mbs_next) && (!(u1_mbaff && (u1_num_mbs & 0x01))); + u1_slice_end = !i2_mb_skip_run; + u1_tfr_n_mb = (u1_num_mbs == ps_dec->u1_recon_mb_grp) || u1_end_of_row + || u1_slice_end; + u1_decode_nmb = u1_tfr_n_mb || u1_slice_end; + ps_cur_mb_info->u1_end_of_slice = u1_slice_end; + + if(u1_decode_nmb) + { + ps_dec->pf_mvpred_ref_tfr_nby2mb(ps_dec, u1_mb_idx, u1_num_mbs); + u1_num_mbsNby2 = 0; + + ps_parse_mb_data = ps_dec->ps_parse_mb_data; + ps_dec->ps_part = ps_dec->ps_parse_part_params; + + if(ps_dec->u1_separate_parse) + { + ih264d_parse_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, + u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); + ps_dec->ps_nmb_info += u1_num_mbs; + } + else + { + ih264d_decode_recon_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, u1_num_mbs_next, + u1_tfr_n_mb, u1_end_of_row); + } + ps_dec->u2_total_mbs_coded += u1_num_mbs; + if(u1_tfr_n_mb) + u1_num_mbs = 0; + u1_mb_idx = u1_num_mbs; + ps_dec->u1_mb_idx = u1_num_mbs; + } + } + + ps_dec->u4_num_mbs_cur_nmb = 0; + ps_dec->ps_cur_slice->u4_mbs_in_slice = i2_cur_mb_addr + - ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice; + + + H264_DEC_DEBUG_PRINT(""Mbs in slice: %d\n"", ps_dec->ps_cur_slice->u4_mbs_in_slice); + + ps_dec->u2_cur_slice_num++; + + /* incremented here only if first slice is inserted */ + if(ps_dec->u4_first_slice_in_pic != 0) + ps_dec->ps_parse_cur_slice++; + + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + + if(ps_dec->u2_total_mbs_coded + >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + ps_dec->u1_pic_decode_done = 1; + } + + return 0; + +} +",1,"WORD32 ih264d_mark_err_slice_skip(dec_struct_t * ps_dec, + WORD32 num_mb_skip, + UWORD8 u1_is_idr_slice, + UWORD16 u2_frame_num, + pocstruct_t *ps_cur_poc, + WORD32 prev_slice_err) +{ + WORD32 i2_cur_mb_addr; + UWORD32 u1_num_mbs, u1_num_mbsNby2; + UWORD32 u1_mb_idx = ps_dec->u1_mb_idx; + UWORD32 i2_mb_skip_run; + + UWORD32 u1_num_mbs_next, u1_end_of_row; + const UWORD32 i2_pic_wdin_mbs = ps_dec->u2_frm_wd_in_mbs; + UWORD32 u1_slice_end; + UWORD32 u1_tfr_n_mb; + UWORD32 u1_decode_nmb; + dec_bit_stream_t * const ps_bitstrm = ps_dec->ps_bitstrm; + dec_slice_params_t * ps_slice = ps_dec->ps_cur_slice; + UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer; + UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst; + deblk_mb_t *ps_cur_deblk_mb; + dec_mb_info_t *ps_cur_mb_info; + parse_pmbarams_t *ps_parse_mb_data; + UWORD32 u1_inter_mb_type; + UWORD32 u1_deblk_mb_type; + UWORD16 u2_total_mbs_coded; + UWORD32 u1_mbaff = ps_slice->u1_mbaff_frame_flag; + parse_part_params_t *ps_part_info; + WORD32 ret; + + + if(ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) + { + ih264d_err_pic_dispbuf_mgr(ps_dec); + return 0; + } + ps_dec->ps_dpb_cmds->u1_long_term_reference_flag = 0; + if(prev_slice_err == 1) + { + /* first slice - missing/header corruption */ + ps_dec->ps_cur_slice->u2_frame_num = u2_frame_num; + + + if(!ps_dec->u1_first_slice_in_stream) + { + ih264d_end_of_pic(ps_dec, u1_is_idr_slice, + ps_dec->ps_cur_slice->u2_frame_num); + ps_dec->s_cur_pic_poc.u2_frame_num = + ps_dec->ps_cur_slice->u2_frame_num; + } + + { + WORD32 i, j, poc = 0; + + ps_dec->ps_cur_slice->u2_first_mb_in_slice = 0; + + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff; + ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_bp; + ps_dec->p_motion_compensate = ih264d_motion_compensate_bp; + + if(ps_dec->ps_cur_pic != NULL) + poc = ps_dec->ps_cur_pic->i4_poc + 2; + + j = 0; + for(i = 0; i < MAX_NUM_PIC_PARAMS; i++) + if(ps_dec->ps_pps[i].u1_is_valid == TRUE) + j = i; + { + ps_dec->ps_cur_slice->u1_slice_type = P_SLICE; + ps_dec->ps_cur_slice->u1_nal_ref_idc = 1; + ps_dec->ps_cur_slice->u1_nal_unit_type = 1; + ret = ih264d_start_of_pic(ps_dec, poc, ps_cur_poc, + ps_dec->ps_cur_slice->u2_frame_num, + &ps_dec->ps_pps[j]); + + if(ret != OK) + { + return ret; + } + } + + ps_dec->ps_ref_pic_buf_lx[0][0]->u1_pic_buf_id = 0; + + ps_dec->u4_output_present = 0; + + { + ih264d_get_next_display_field(ps_dec, + ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + /* If error code is non-zero then there is no buffer available for display, + hence avoid format conversion */ + + if(0 != ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = ps_dec->s_disp_frame_info.u4_y_ht; + } + else + ps_dec->u4_output_present = 1; + } + + if(ps_dec->u1_separate_parse == 1) + { + if(ps_dec->u4_dec_thread_created == 0) + { + ithread_create(ps_dec->pv_dec_thread_handle, NULL, + (void *)ih264d_decode_picture_thread, + (void *)ps_dec); + + ps_dec->u4_dec_thread_created = 1; + } + + if((ps_dec->u4_num_cores == 3) && + ((ps_dec->u4_app_disable_deblk_frm == 0) || ps_dec->i1_recon_in_thread3_flag) + && (ps_dec->u4_bs_deblk_thread_created == 0)) + { + ps_dec->u4_start_recon_deblk = 0; + ithread_create(ps_dec->pv_bs_deblk_thread_handle, NULL, + (void *)ih264d_recon_deblk_thread, + (void *)ps_dec); + ps_dec->u4_bs_deblk_thread_created = 1; + + } + } + } + ps_dec->u4_first_slice_in_pic = 0; + } + else + { + + dec_slice_struct_t *ps_parse_cur_slice; + ps_parse_cur_slice = ps_dec->ps_dec_slice_buf + ps_dec->u2_cur_slice_num; + + if(ps_dec->u1_slice_header_done + && ps_parse_cur_slice == ps_dec->ps_parse_cur_slice) + { + u1_num_mbs = ps_dec->u4_num_mbs_cur_nmb; + + if(u1_num_mbs) + { + ps_cur_mb_info = ps_dec->ps_nmb_info + u1_num_mbs - 1; + } + else + { + if(ps_dec->u1_separate_parse) + { + ps_cur_mb_info = ps_dec->ps_nmb_info - 1; + } + else + { + ps_cur_mb_info = ps_dec->ps_nmb_info + + ps_dec->u4_num_mbs_prev_nmb - 1; + } + } + + ps_dec->u2_mby = ps_cur_mb_info->u2_mby; + ps_dec->u2_mbx = ps_cur_mb_info->u2_mbx; + + ps_dec->u1_mb_ngbr_availablity = + ps_cur_mb_info->u1_mb_ngbr_availablity; + + ps_dec->pv_parse_tu_coeff_data = ps_dec->pv_prev_mb_parse_tu_coeff_data; + ps_dec->u2_cur_mb_addr--; + ps_dec->i4_submb_ofst -= SUB_BLK_SIZE; + + if(u1_num_mbs) + { + if (ps_dec->u1_pr_sl_type == P_SLICE + || ps_dec->u1_pr_sl_type == B_SLICE) + { + ps_dec->pf_mvpred_ref_tfr_nby2mb(ps_dec, u1_mb_idx, u1_num_mbs); + ps_dec->ps_part = ps_dec->ps_parse_part_params; + } + + u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec->u2_mbx - 1; + u1_end_of_row = (!u1_num_mbs_next) + && (!(u1_mbaff && (u1_num_mbs & 0x01))); + u1_slice_end = 1; + u1_tfr_n_mb = 1; + ps_cur_mb_info->u1_end_of_slice = u1_slice_end; + + if(ps_dec->u1_separate_parse) + { + ih264d_parse_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, + u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); + ps_dec->ps_nmb_info += u1_num_mbs; + } + else + { + ih264d_decode_recon_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, + u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); + } + ps_dec->u2_total_mbs_coded += u1_num_mbs; + ps_dec->u1_mb_idx = 0; + ps_dec->u4_num_mbs_cur_nmb = 0; + } + + if(ps_dec->u2_total_mbs_coded + >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + ps_dec->u1_pic_decode_done = 1; + return 0; + } + + ps_dec->u2_cur_slice_num++; + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + ps_dec->ps_parse_cur_slice++; + + } + else + { + ps_dec->ps_parse_cur_slice = ps_dec->ps_dec_slice_buf + + ps_dec->u2_cur_slice_num; + } + } + + /******************************************************/ + /* Initializations to new slice */ + /******************************************************/ + { + WORD32 num_entries; + WORD32 size; + UWORD8 *pu1_buf; + + num_entries = MAX_FRAMES; + if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) && + (0 == ps_dec->i4_display_delay)) + { + num_entries = 1; + } + num_entries = ((2 * num_entries) + 1); + if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc) + { + num_entries *= 2; + } + size = num_entries * sizeof(void *); + size += PAD_MAP_IDX_POC * sizeof(void *); + + pu1_buf = (UWORD8 *)ps_dec->pv_map_ref_idx_to_poc_buf; + pu1_buf += size * ps_dec->u2_cur_slice_num; + ps_dec->ps_parse_cur_slice->ppv_map_ref_idx_to_poc = (volatile void **)pu1_buf; + } + + ps_dec->ps_cur_slice->u2_first_mb_in_slice = ps_dec->u2_total_mbs_coded << u1_mbaff; + ps_dec->ps_cur_slice->i1_slice_alpha_c0_offset = 0; + ps_dec->ps_cur_slice->i1_slice_beta_offset = 0; + + if(ps_dec->ps_cur_slice->u1_field_pic_flag) + ps_dec->u2_prv_frame_num = ps_dec->ps_cur_slice->u2_frame_num; + + ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice = ps_dec->u2_total_mbs_coded << u1_mbaff; + ps_dec->ps_parse_cur_slice->u2_log2Y_crwd = ps_dec->ps_cur_slice->u2_log2Y_crwd; + + + if(ps_dec->u1_separate_parse) + { + ps_dec->ps_parse_cur_slice->pv_tu_coeff_data_start = ps_dec->pv_parse_tu_coeff_data; + } + else + { + ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_parse_tu_coeff_data; + } + + /******************************************************/ + /* Initializations specific to P slice */ + /******************************************************/ + u1_inter_mb_type = P_MB; + u1_deblk_mb_type = D_INTER_MB; + + ps_dec->ps_cur_slice->u1_slice_type = P_SLICE; + ps_dec->ps_parse_cur_slice->slice_type = P_SLICE; + ps_dec->pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_pmb; + ps_dec->ps_part = ps_dec->ps_parse_part_params; + + /******************************************************/ + /* Parsing / decoding the slice */ + /******************************************************/ + ps_dec->u1_slice_header_done = 2; + ps_dec->u1_qp = ps_slice->u1_slice_qp; + ih264d_update_qp(ps_dec, 0); + u1_mb_idx = ps_dec->u1_mb_idx; + ps_parse_mb_data = ps_dec->ps_parse_mb_data; + u1_num_mbs = u1_mb_idx; + + u1_slice_end = 0; + u1_tfr_n_mb = 0; + u1_decode_nmb = 0; + u1_num_mbsNby2 = 0; + i2_cur_mb_addr = ps_dec->u2_total_mbs_coded; + i2_mb_skip_run = num_mb_skip; + + while(!u1_slice_end) + { + UWORD8 u1_mb_type; + + if(i2_cur_mb_addr > ps_dec->ps_cur_sps->u2_max_mb_addr) + break; + + ps_cur_mb_info = ps_dec->ps_nmb_info + u1_num_mbs; + ps_dec->u4_num_mbs_cur_nmb = u1_num_mbs; + + ps_cur_mb_info->u1_Mux = 0; + ps_dec->u4_num_pmbair = (u1_num_mbs >> u1_mbaff); + ps_cur_deblk_mb = ps_dec->ps_deblk_mbn + u1_num_mbs; + + ps_cur_mb_info->u1_end_of_slice = 0; + + /* Storing Default partition info */ + ps_parse_mb_data->u1_num_part = 1; + ps_parse_mb_data->u1_isI_mb = 0; + + /**************************************************************/ + /* Get the required information for decoding of MB */ + /**************************************************************/ + /* mb_x, mb_y, neighbor availablity, */ + if (u1_mbaff) + ih264d_get_mb_info_cavlc_mbaff(ps_dec, i2_cur_mb_addr, ps_cur_mb_info, i2_mb_skip_run); + else + ih264d_get_mb_info_cavlc_nonmbaff(ps_dec, i2_cur_mb_addr, ps_cur_mb_info, i2_mb_skip_run); + + /* Set the deblocking parameters for this MB */ + if(ps_dec->u4_app_disable_deblk_frm == 0) + { + ih264d_set_deblocking_parameters(ps_cur_deblk_mb, ps_slice, + ps_dec->u1_mb_ngbr_availablity, + ps_dec->u1_cur_mb_fld_dec_flag); + } + + /* Set appropriate flags in ps_cur_mb_info and ps_dec */ + ps_dec->i1_prev_mb_qp_delta = 0; + ps_dec->u1_sub_mb_num = 0; + ps_cur_mb_info->u1_mb_type = MB_SKIP; + ps_cur_mb_info->u1_mb_mc_mode = PRED_16x16; + ps_cur_mb_info->u1_cbp = 0; + + /* Storing Skip partition info */ + ps_part_info = ps_dec->ps_part; + ps_part_info->u1_is_direct = PART_DIRECT_16x16; + ps_part_info->u1_sub_mb_num = 0; + ps_dec->ps_part++; + + /* Update Nnzs */ + ih264d_update_nnz_for_skipmb(ps_dec, ps_cur_mb_info, CAVLC); + + ps_cur_mb_info->ps_curmb->u1_mb_type = u1_inter_mb_type; + ps_cur_deblk_mb->u1_mb_type |= u1_deblk_mb_type; + + i2_mb_skip_run--; + + ps_cur_deblk_mb->u1_mb_qp = ps_dec->u1_qp; + + if (u1_mbaff) + { + ih264d_update_mbaff_left_nnz(ps_dec, ps_cur_mb_info); + } + + /**************************************************************/ + /* Get next Macroblock address */ + /**************************************************************/ + i2_cur_mb_addr++; + + u1_num_mbs++; + u1_num_mbsNby2++; + ps_parse_mb_data++; + + /****************************************************************/ + /* Check for End Of Row and other flags that determine when to */ + /* do DMA setup for N/2-Mb, Decode for N-Mb, and Transfer for */ + /* N-Mb */ + /****************************************************************/ + u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec->u2_mbx - 1; + u1_end_of_row = (!u1_num_mbs_next) && (!(u1_mbaff && (u1_num_mbs & 0x01))); + u1_slice_end = !i2_mb_skip_run; + u1_tfr_n_mb = (u1_num_mbs == ps_dec->u1_recon_mb_grp) || u1_end_of_row + || u1_slice_end; + u1_decode_nmb = u1_tfr_n_mb || u1_slice_end; + ps_cur_mb_info->u1_end_of_slice = u1_slice_end; + + if(u1_decode_nmb) + { + ps_dec->pf_mvpred_ref_tfr_nby2mb(ps_dec, u1_mb_idx, u1_num_mbs); + u1_num_mbsNby2 = 0; + + ps_parse_mb_data = ps_dec->ps_parse_mb_data; + ps_dec->ps_part = ps_dec->ps_parse_part_params; + + if(ps_dec->u1_separate_parse) + { + ih264d_parse_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, + u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); + ps_dec->ps_nmb_info += u1_num_mbs; + } + else + { + ih264d_decode_recon_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, u1_num_mbs_next, + u1_tfr_n_mb, u1_end_of_row); + } + ps_dec->u2_total_mbs_coded += u1_num_mbs; + if(u1_tfr_n_mb) + u1_num_mbs = 0; + u1_mb_idx = u1_num_mbs; + ps_dec->u1_mb_idx = u1_num_mbs; + } + } + + ps_dec->u4_num_mbs_cur_nmb = 0; + ps_dec->ps_cur_slice->u4_mbs_in_slice = i2_cur_mb_addr + - ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice; + + + H264_DEC_DEBUG_PRINT(""Mbs in slice: %d\n"", ps_dec->ps_cur_slice->u4_mbs_in_slice); + + + /* incremented here only if first slice is inserted */ + if(ps_dec->u4_first_slice_in_pic != 0) + { + ps_dec->ps_parse_cur_slice++; + ps_dec->u2_cur_slice_num++; + } + + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + + if(ps_dec->u2_total_mbs_coded + >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + ps_dec->u1_pic_decode_done = 1; + } + + return 0; + +} +","@@ -1550,6 +1550,7 @@ + + } + } + } ++ ps_dec->u4_first_slice_in_pic = 0; + } + else + { +@@ -1842,11 +1843,13 @@ + + + H264_DEC_DEBUG_PRINT(""Mbs in slice: %d\n"", ps_dec->ps_cur_slice->u4_mbs_in_slice); + +- ps_dec->u2_cur_slice_num++; + + /* incremented here only if first slice is inserted */ + if(ps_dec->u4_first_slice_in_pic != 0) ++ { + ps_dec->ps_parse_cur_slice++; ++ ps_dec->u2_cur_slice_num++; ++ } + + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; +",4082,4318,6144 +18722," xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + xmlNodePtr node, const xmlChar *mode, + const xmlChar *modeURI) { + int i; + xsltStepOpPtr step, sel = NULL; + xsltStepStates states = {0, 0, NULL}; /* // may require backtrack */ + + if ((comp == NULL) || (node == NULL) || (ctxt == NULL)) { + xsltTransformError(ctxt, NULL, node, + ""xsltTestCompMatch: null arg\n""); + return(-1); + } + if (mode != NULL) { + if (comp->mode == NULL) + return(0); + /* + * both mode strings must be interned on the stylesheet dictionary + */ + if (comp->mode != mode) + return(0); + } else { + if (comp->mode != NULL) + return(0); + } + if (modeURI != NULL) { + if (comp->modeURI == NULL) + return(0); + /* + * both modeURI strings must be interned on the stylesheet dictionary + */ + if (comp->modeURI != modeURI) + return(0); + } else { + if (comp->modeURI != NULL) + return(0); + } + + i = 0; +restart: + for (;i < comp->nbStep;i++) { + step = &comp->steps[i]; + if (step->op != XSLT_OP_PREDICATE) + sel = step; + switch (step->op) { + case XSLT_OP_END: + goto found; + case XSLT_OP_ROOT: + if ((node->type == XML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (node->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (node->type == XML_HTML_DOCUMENT_NODE)) + continue; + if ((node->type == XML_ELEMENT_NODE) && (node->name[0] == ' ')) + continue; + goto rollback; + case XSLT_OP_ELEM: + if (node->type != XML_ELEMENT_NODE) + goto rollback; + if (step->value == NULL) + continue; + if (step->value[0] != node->name[0]) + goto rollback; + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 != NULL) + goto rollback; + } else if (node->ns->href != NULL) { + if (step->value2 == NULL) + goto rollback; + if (!xmlStrEqual(step->value2, node->ns->href)) + goto rollback; + } + continue; + case XSLT_OP_ATTR: + if (node->type != XML_ATTRIBUTE_NODE) + goto rollback; + if (step->value != NULL) { + if (step->value[0] != node->name[0]) + goto rollback; + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + } + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 != NULL) + goto rollback; + } else if (step->value2 != NULL) { + if (!xmlStrEqual(step->value2, node->ns->href)) + goto rollback; + } + continue; + case XSLT_OP_PARENT: + if ((node->type == XML_DOCUMENT_NODE) || + (node->type == XML_HTML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (node->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (node->type == XML_NAMESPACE_DECL)) + goto rollback; + node = node->parent; + if (node == NULL) + goto rollback; + if (step->value == NULL) + continue; + if (step->value[0] != node->name[0]) + goto rollback; + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 != NULL) + goto rollback; + } else if (node->ns->href != NULL) { + if (step->value2 == NULL) + goto rollback; + if (!xmlStrEqual(step->value2, node->ns->href)) + goto rollback; + } + continue; + case XSLT_OP_ANCESTOR: + /* TODO: implement coalescing of ANCESTOR/NODE ops */ + if (step->value == NULL) { + step = &comp->steps[i+1]; + if (step->op == XSLT_OP_ROOT) + goto found; + /* added NS, ID and KEY as a result of bug 168208 */ + if ((step->op != XSLT_OP_ELEM) && + (step->op != XSLT_OP_ALL) && + (step->op != XSLT_OP_NS) && + (step->op != XSLT_OP_ID) && + (step->op != XSLT_OP_KEY)) + goto rollback; + } + if (node == NULL) + goto rollback; + if ((node->type == XML_DOCUMENT_NODE) || + (node->type == XML_HTML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (node->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (node->type == XML_NAMESPACE_DECL)) + goto rollback; + node = node->parent; + if ((step->op != XSLT_OP_ELEM) && step->op != XSLT_OP_ALL) { + xsltPatPushState(ctxt, &states, i, node); + continue; + } + i++; + if (step->value == NULL) { + xsltPatPushState(ctxt, &states, i - 1, node); + continue; + } + while (node != NULL) { + if ((node->type == XML_ELEMENT_NODE) && + (step->value[0] == node->name[0]) && + (xmlStrEqual(step->value, node->name))) { + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 == NULL) + break; + } else if (node->ns->href != NULL) { + if ((step->value2 != NULL) && + (xmlStrEqual(step->value2, node->ns->href))) + break; + } + } + node = node->parent; + } + if (node == NULL) + goto rollback; + xsltPatPushState(ctxt, &states, i - 1, node); + continue; + case XSLT_OP_ID: { + /* TODO Handle IDs decently, must be done differently */ + xmlAttrPtr id; + + if (node->type != XML_ELEMENT_NODE) + goto rollback; + + id = xmlGetID(node->doc, step->value); + if ((id == NULL) || (id->parent != node)) + goto rollback; + break; + } + case XSLT_OP_KEY: { + xmlNodeSetPtr list; + int indx; + + list = xsltGetKey(ctxt, step->value, + step->value3, step->value2); + if (list == NULL) + goto rollback; + for (indx = 0;indx < list->nodeNr;indx++) + if (list->nodeTab[indx] == node) + break; + if (indx >= list->nodeNr) + goto rollback; + break; + } + case XSLT_OP_NS: + if (node->type != XML_ELEMENT_NODE) + goto rollback; + if (node->ns == NULL) { + if (step->value != NULL) + goto rollback; + } else if (node->ns->href != NULL) { + if (step->value == NULL) + goto rollback; + if (!xmlStrEqual(step->value, node->ns->href)) + goto rollback; + } + break; + case XSLT_OP_ALL: + if (node->type != XML_ELEMENT_NODE) + goto rollback; + break; + case XSLT_OP_PREDICATE: { + xmlNodePtr oldNode; + xmlDocPtr doc; + int oldCS, oldCP; + int pos = 0, len = 0; + int isRVT; + /* + * when there is cascading XSLT_OP_PREDICATE, then use a + * direct computation approach. It's not done directly + * at the beginning of the routine to filter out as much + * as possible this costly computation. + */ + if (comp->direct) { + if (states.states != NULL) { + /* Free the rollback states */ + xmlFree(states.states); + } + return(xsltTestCompMatchDirect(ctxt, comp, node, + comp->nsList, comp->nsNr)); + } + + doc = node->doc; + if (XSLT_IS_RES_TREE_FRAG(doc)) + isRVT = 1; + else + isRVT = 0; + /* + * Depending on the last selection, one may need to + * recompute contextSize and proximityPosition. + */ + oldCS = ctxt->xpathCtxt->contextSize; + oldCP = ctxt->xpathCtxt->proximityPosition; + if ((sel != NULL) && + (sel->op == XSLT_OP_ELEM) && + (sel->value != NULL) && + (node->type == XML_ELEMENT_NODE) && + (node->parent != NULL)) { + xmlNodePtr previous; + int nocache = 0; + previous = (xmlNodePtr) + XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); + if ((previous != NULL) && + (previous->parent == node->parent)) { + /* + * just walk back to adjust the index + */ + int indx = 0; + xmlNodePtr sibling = node; + while (sibling != NULL) { + if (sibling == previous) + break; + if ((sibling->type == XML_ELEMENT_NODE) && + (previous->name != NULL) && + (sibling->name != NULL) && + (previous->name[0] == sibling->name[0]) && + (xmlStrEqual(previous->name, sibling->name))) + { + if ((sel->value2 == NULL) || + ((sibling->ns != NULL) && + (xmlStrEqual(sel->value2, + sibling->ns->href)))) + indx++; + } + sibling = sibling->prev; + } + if (sibling == NULL) { + /* hum going backward in document order ... */ + indx = 0; + sibling = node; + while (sibling != NULL) { + if (sibling == previous) + break; + if ((sibling->type == XML_ELEMENT_NODE) && + (previous->name != NULL) && + (sibling->name != NULL) && + (previous->name[0] == sibling->name[0]) && + (xmlStrEqual(previous->name, sibling->name))) + { + if ((sel->value2 == NULL) || + ((sibling->ns != NULL) && + (xmlStrEqual(sel->value2, + sibling->ns->href)))) + { + indx--; + } + } + sibling = sibling->next; + } + } + if (sibling != NULL) { + pos = XSLT_RUNTIME_EXTRA(ctxt, + sel->indexExtra, ival) + indx; + /* + * If the node is in a Value Tree we need to + * save len, but cannot cache the node! + * (bugs 153137 and 158840) + */ + if (node->doc != NULL) { + len = XSLT_RUNTIME_EXTRA(ctxt, + sel->lenExtra, ival); + if (!isRVT) { + XSLT_RUNTIME_EXTRA(ctxt, + sel->previousExtra, ptr) = node; + XSLT_RUNTIME_EXTRA(ctxt, + sel->indexExtra, ival) = pos; + } + } + } else + pos = 0; + } else { + /* + * recompute the index + */ + xmlNodePtr parent = node->parent; + xmlNodePtr siblings = NULL; + if (parent) siblings = parent->children; + while (siblings != NULL) { + if (siblings->type == XML_ELEMENT_NODE) { + if (siblings == node) { + len++; + pos = len; + } else if ((node->name != NULL) && + (siblings->name != NULL) && + (node->name[0] == siblings->name[0]) && + (xmlStrEqual(node->name, siblings->name))) { + if ((sel->value2 == NULL) || + ((siblings->ns != NULL) && + (xmlStrEqual(sel->value2, + siblings->ns->href)))) + len++; + } + } + siblings = siblings->next; + } + if ((parent == NULL) || (node->doc == NULL)) + nocache = 1; + else { + while (parent->parent != NULL) + parent = parent->parent; + if (((parent->type != XML_DOCUMENT_NODE) && + (parent->type != XML_HTML_DOCUMENT_NODE)) || + (parent != (xmlNodePtr) node->doc)) + nocache = 1; + } + } + if (pos != 0) { + ctxt->xpathCtxt->contextSize = len; + ctxt->xpathCtxt->proximityPosition = pos; + /* + * If the node is in a Value Tree we cannot + * cache it ! + */ + if ((!isRVT) && (node->doc != NULL) && + (nocache == 0)) { + XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = + node; + XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = + pos; + XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = + len; + } + } + } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) && + (node->type == XML_ELEMENT_NODE)) { + xmlNodePtr previous; + int nocache = 0; + previous = (xmlNodePtr) + XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); + if ((previous != NULL) && + (previous->parent == node->parent)) { + /* + * just walk back to adjust the index + */ + int indx = 0; + xmlNodePtr sibling = node; + while (sibling != NULL) { + if (sibling == previous) + break; + if (sibling->type == XML_ELEMENT_NODE) + indx++; + sibling = sibling->prev; + } + if (sibling == NULL) { + /* hum going backward in document order ... */ + indx = 0; + sibling = node; + while (sibling != NULL) { + if (sibling == previous) + break; + if (sibling->type == XML_ELEMENT_NODE) + indx--; + sibling = sibling->next; + } + } + if (sibling != NULL) { + pos = XSLT_RUNTIME_EXTRA(ctxt, + sel->indexExtra, ival) + indx; + /* + * If the node is in a Value Tree we cannot + * cache it ! + */ + if ((node->doc != NULL) && !isRVT) { + len = XSLT_RUNTIME_EXTRA(ctxt, + sel->lenExtra, ival); + XSLT_RUNTIME_EXTRA(ctxt, + sel->previousExtra, ptr) = node; + XSLT_RUNTIME_EXTRA(ctxt, + sel->indexExtra, ival) = pos; + } + } else + pos = 0; + } else { + /* + * recompute the index + */ + xmlNodePtr parent = node->parent; + xmlNodePtr siblings = NULL; + if (parent) siblings = parent->children; + while (siblings != NULL) { + if (siblings->type == XML_ELEMENT_NODE) { + len++; + if (siblings == node) { + pos = len; + } + } + siblings = siblings->next; + } + if ((parent == NULL) || (node->doc == NULL)) + nocache = 1; + else { + while (parent->parent != NULL) + parent = parent->parent; + if (((parent->type != XML_DOCUMENT_NODE) && + (parent->type != XML_HTML_DOCUMENT_NODE)) || + (parent != (xmlNodePtr) node->doc)) + nocache = 1; + } + } + if (pos != 0) { + ctxt->xpathCtxt->contextSize = len; + ctxt->xpathCtxt->proximityPosition = pos; + /* + * If the node is in a Value Tree we cannot + * cache it ! + */ + if ((node->doc != NULL) && (nocache == 0) && !isRVT) { + XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = + node; + XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = + pos; + XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = + len; + } + } + } + oldNode = ctxt->node; + ctxt->node = node; + if (step->value == NULL) + goto wrong_index; + if (step->comp == NULL) + goto wrong_index; + if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList, + comp->nsNr)) + goto wrong_index; + + if (pos != 0) { + ctxt->xpathCtxt->contextSize = oldCS; + ctxt->xpathCtxt->proximityPosition = oldCP; + } + ctxt->node = oldNode; + break; +wrong_index: + if (pos != 0) { + ctxt->xpathCtxt->contextSize = oldCS; + ctxt->xpathCtxt->proximityPosition = oldCP; + } + ctxt->node = oldNode; + goto rollback; + } + case XSLT_OP_PI: + if (node->type != XML_PI_NODE) + goto rollback; + if (step->value != NULL) { + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + } + break; + case XSLT_OP_COMMENT: + if (node->type != XML_COMMENT_NODE) + goto rollback; + break; + case XSLT_OP_TEXT: + if ((node->type != XML_TEXT_NODE) && + (node->type != XML_CDATA_SECTION_NODE)) + goto rollback; + break; + case XSLT_OP_NODE: + switch (node->type) { + case XML_ELEMENT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_TEXT_NODE: + break; + default: + goto rollback; + } + break; + } + } +found: + if (states.states != NULL) { + /* Free the rollback states */ + xmlFree(states.states); + } + return(1); +rollback: + /* got an error try to rollback */ + if (states.states == NULL) + return(0); + if (states.nbstates <= 0) { + xmlFree(states.states); + return(0); + } + states.nbstates--; + i = states.states[states.nbstates].step; + node = states.states[states.nbstates].node; +#if 0 + fprintf(stderr, ""Pop: %d, %s\n"", i, node->name); +#endif + goto restart; +} +",1," xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + xmlNodePtr matchNode, const xmlChar *mode, + const xmlChar *modeURI) { + int i; + xmlNodePtr node = matchNode; + xsltStepOpPtr step, sel = NULL; + xsltStepStates states = {0, 0, NULL}; /* // may require backtrack */ + + if ((comp == NULL) || (node == NULL) || (ctxt == NULL)) { + xsltTransformError(ctxt, NULL, node, + ""xsltTestCompMatch: null arg\n""); + return(-1); + } + if (mode != NULL) { + if (comp->mode == NULL) + return(0); + /* + * both mode strings must be interned on the stylesheet dictionary + */ + if (comp->mode != mode) + return(0); + } else { + if (comp->mode != NULL) + return(0); + } + if (modeURI != NULL) { + if (comp->modeURI == NULL) + return(0); + /* + * both modeURI strings must be interned on the stylesheet dictionary + */ + if (comp->modeURI != modeURI) + return(0); + } else { + if (comp->modeURI != NULL) + return(0); + } + + i = 0; +restart: + for (;i < comp->nbStep;i++) { + step = &comp->steps[i]; + if (step->op != XSLT_OP_PREDICATE) + sel = step; + switch (step->op) { + case XSLT_OP_END: + goto found; + case XSLT_OP_ROOT: + if ((node->type == XML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (node->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (node->type == XML_HTML_DOCUMENT_NODE)) + continue; + if ((node->type == XML_ELEMENT_NODE) && (node->name[0] == ' ')) + continue; + goto rollback; + case XSLT_OP_ELEM: + if (node->type != XML_ELEMENT_NODE) + goto rollback; + if (step->value == NULL) + continue; + if (step->value[0] != node->name[0]) + goto rollback; + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 != NULL) + goto rollback; + } else if (node->ns->href != NULL) { + if (step->value2 == NULL) + goto rollback; + if (!xmlStrEqual(step->value2, node->ns->href)) + goto rollback; + } + continue; + case XSLT_OP_ATTR: + if (node->type != XML_ATTRIBUTE_NODE) + goto rollback; + if (step->value != NULL) { + if (step->value[0] != node->name[0]) + goto rollback; + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + } + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 != NULL) + goto rollback; + } else if (step->value2 != NULL) { + if (!xmlStrEqual(step->value2, node->ns->href)) + goto rollback; + } + continue; + case XSLT_OP_PARENT: + if ((node->type == XML_DOCUMENT_NODE) || + (node->type == XML_HTML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (node->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (node->type == XML_NAMESPACE_DECL)) + goto rollback; + node = node->parent; + if (node == NULL) + goto rollback; + if (step->value == NULL) + continue; + if (step->value[0] != node->name[0]) + goto rollback; + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 != NULL) + goto rollback; + } else if (node->ns->href != NULL) { + if (step->value2 == NULL) + goto rollback; + if (!xmlStrEqual(step->value2, node->ns->href)) + goto rollback; + } + continue; + case XSLT_OP_ANCESTOR: + /* TODO: implement coalescing of ANCESTOR/NODE ops */ + if (step->value == NULL) { + step = &comp->steps[i+1]; + if (step->op == XSLT_OP_ROOT) + goto found; + /* added NS, ID and KEY as a result of bug 168208 */ + if ((step->op != XSLT_OP_ELEM) && + (step->op != XSLT_OP_ALL) && + (step->op != XSLT_OP_NS) && + (step->op != XSLT_OP_ID) && + (step->op != XSLT_OP_KEY)) + goto rollback; + } + if (node == NULL) + goto rollback; + if ((node->type == XML_DOCUMENT_NODE) || + (node->type == XML_HTML_DOCUMENT_NODE) || +#ifdef LIBXML_DOCB_ENABLED + (node->type == XML_DOCB_DOCUMENT_NODE) || +#endif + (node->type == XML_NAMESPACE_DECL)) + goto rollback; + node = node->parent; + if ((step->op != XSLT_OP_ELEM) && step->op != XSLT_OP_ALL) { + xsltPatPushState(ctxt, &states, i, node); + continue; + } + i++; + if (step->value == NULL) { + xsltPatPushState(ctxt, &states, i - 1, node); + continue; + } + while (node != NULL) { + if ((node->type == XML_ELEMENT_NODE) && + (step->value[0] == node->name[0]) && + (xmlStrEqual(step->value, node->name))) { + /* Namespace test */ + if (node->ns == NULL) { + if (step->value2 == NULL) + break; + } else if (node->ns->href != NULL) { + if ((step->value2 != NULL) && + (xmlStrEqual(step->value2, node->ns->href))) + break; + } + } + node = node->parent; + } + if (node == NULL) + goto rollback; + xsltPatPushState(ctxt, &states, i - 1, node); + continue; + case XSLT_OP_ID: { + /* TODO Handle IDs decently, must be done differently */ + xmlAttrPtr id; + + if (node->type != XML_ELEMENT_NODE) + goto rollback; + + id = xmlGetID(node->doc, step->value); + if ((id == NULL) || (id->parent != node)) + goto rollback; + break; + } + case XSLT_OP_KEY: { + xmlNodeSetPtr list; + int indx; + + list = xsltGetKey(ctxt, step->value, + step->value3, step->value2); + if (list == NULL) + goto rollback; + for (indx = 0;indx < list->nodeNr;indx++) + if (list->nodeTab[indx] == node) + break; + if (indx >= list->nodeNr) + goto rollback; + break; + } + case XSLT_OP_NS: + if (node->type != XML_ELEMENT_NODE) + goto rollback; + if (node->ns == NULL) { + if (step->value != NULL) + goto rollback; + } else if (node->ns->href != NULL) { + if (step->value == NULL) + goto rollback; + if (!xmlStrEqual(step->value, node->ns->href)) + goto rollback; + } + break; + case XSLT_OP_ALL: + if (node->type != XML_ELEMENT_NODE) + goto rollback; + break; + case XSLT_OP_PREDICATE: { + /* + * When there is cascading XSLT_OP_PREDICATE or a predicate + * after an op which hasn't been optimized yet, then use a + * direct computation approach. It's not done directly + * at the beginning of the routine to filter out as much + * as possible this costly computation. + */ + if (comp->direct) { + if (states.states != NULL) { + /* Free the rollback states */ + xmlFree(states.states); + } + return(xsltTestCompMatchDirect(ctxt, comp, matchNode, + comp->nsList, comp->nsNr)); + } + + if (!xsltTestPredicateMatch(ctxt, comp, node, step, sel)) + goto rollback; + + break; + } + case XSLT_OP_PI: + if (node->type != XML_PI_NODE) + goto rollback; + if (step->value != NULL) { + if (!xmlStrEqual(step->value, node->name)) + goto rollback; + } + break; + case XSLT_OP_COMMENT: + if (node->type != XML_COMMENT_NODE) + goto rollback; + break; + case XSLT_OP_TEXT: + if ((node->type != XML_TEXT_NODE) && + (node->type != XML_CDATA_SECTION_NODE)) + goto rollback; + break; + case XSLT_OP_NODE: + switch (node->type) { + case XML_ELEMENT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_PI_NODE: + case XML_COMMENT_NODE: + case XML_TEXT_NODE: + break; + default: + goto rollback; + } + break; + } + } +found: + if (states.states != NULL) { + /* Free the rollback states */ + xmlFree(states.states); + } + return(1); +rollback: + /* got an error try to rollback */ + if (states.states == NULL) + return(0); + if (states.nbstates <= 0) { + xmlFree(states.states); + return(0); + } + states.nbstates--; + i = states.states[states.nbstates].step; + node = states.states[states.nbstates].node; +#if 0 + fprintf(stderr, ""Pop: %d, %s\n"", i, node->name); +#endif + goto restart; +} +","@@ -451,11 +451,14 @@ xsltReverseCompMatch(xsltParserContextPtr ctxt, xsltCompMatchPtr comp) { + xsltCompMatchAdd(ctxt, comp, XSLT_OP_END, NULL, NULL, 0); + + /* +- * detect consecutive XSLT_OP_PREDICATE indicating a direct +- * matching should be done. ++ * Detect consecutive XSLT_OP_PREDICATE and predicates on ops which ++ * haven't been optimized yet indicating a direct matching should be done. + */ + for (i = 0;i < comp->nbStep - 1;i++) { +- if ((comp->steps[i].op == XSLT_OP_PREDICATE) && ++ xsltOp op = comp->steps[i].op; ++ ++ if ((op != XSLT_OP_ELEM) && ++ (op != XSLT_OP_ALL) && + (comp->steps[i + 1].op == XSLT_OP_PREDICATE)) { + + comp->direct = 1; +@@ -620,6 +623,280 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + return(0); + } + ++/** ++ * xsltTestPredicateMatch: ++ * @ctxt: a XSLT process context ++ * @comp: the precompiled pattern ++ * @node: a node ++ * @step: the predicate step ++ * @sel: the previous step ++ * ++ * Test whether the node matches the predicate ++ * ++ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure ++ */ ++static int ++xsltTestPredicateMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, ++ xmlNodePtr node, xsltStepOpPtr step, ++ xsltStepOpPtr sel) { ++ xmlNodePtr oldNode; ++ xmlDocPtr doc; ++ int oldCS, oldCP; ++ int pos = 0, len = 0; ++ int isRVT; ++ int match; ++ ++ if (step->value == NULL) ++ return(0); ++ if (step->comp == NULL) ++ return(0); ++ ++ doc = node->doc; ++ if (XSLT_IS_RES_TREE_FRAG(doc)) ++ isRVT = 1; ++ else ++ isRVT = 0; ++ ++ /* ++ * Recompute contextSize and proximityPosition. ++ * ++ * TODO: Make this work for additional ops. Currently, only XSLT_OP_ELEM ++ * and XSLT_OP_ALL are supported. ++ */ ++ oldCS = ctxt->xpathCtxt->contextSize; ++ oldCP = ctxt->xpathCtxt->proximityPosition; ++ if ((sel != NULL) && ++ (sel->op == XSLT_OP_ELEM) && ++ (sel->value != NULL) && ++ (node->type == XML_ELEMENT_NODE) && ++ (node->parent != NULL)) { ++ xmlNodePtr previous; ++ int nocache = 0; ++ ++ previous = (xmlNodePtr) ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); ++ if ((previous != NULL) && ++ (previous->parent == node->parent)) { ++ /* ++ * just walk back to adjust the index ++ */ ++ int indx = 0; ++ xmlNodePtr sibling = node; ++ ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if ((sibling->type == XML_ELEMENT_NODE) && ++ (previous->name != NULL) && ++ (sibling->name != NULL) && ++ (previous->name[0] == sibling->name[0]) && ++ (xmlStrEqual(previous->name, sibling->name))) ++ { ++ if ((sel->value2 == NULL) || ++ ((sibling->ns != NULL) && ++ (xmlStrEqual(sel->value2, sibling->ns->href)))) ++ indx++; ++ } ++ sibling = sibling->prev; ++ } ++ if (sibling == NULL) { ++ /* hum going backward in document order ... */ ++ indx = 0; ++ sibling = node; ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if ((sibling->type == XML_ELEMENT_NODE) && ++ (previous->name != NULL) && ++ (sibling->name != NULL) && ++ (previous->name[0] == sibling->name[0]) && ++ (xmlStrEqual(previous->name, sibling->name))) ++ { ++ if ((sel->value2 == NULL) || ++ ((sibling->ns != NULL) && ++ (xmlStrEqual(sel->value2, ++ sibling->ns->href)))) ++ { ++ indx--; ++ } ++ } ++ sibling = sibling->next; ++ } ++ } ++ if (sibling != NULL) { ++ pos = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) + indx; ++ /* ++ * If the node is in a Value Tree we need to ++ * save len, but cannot cache the node! ++ * (bugs 153137 and 158840) ++ */ ++ if (node->doc != NULL) { ++ len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival); ++ if (!isRVT) { ++ XSLT_RUNTIME_EXTRA(ctxt, ++ sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ } ++ } ++ } else ++ pos = 0; ++ } else { ++ /* ++ * recompute the index ++ */ ++ xmlNodePtr parent = node->parent; ++ xmlNodePtr siblings = NULL; ++ ++ if (parent) siblings = parent->children; ++ ++ while (siblings != NULL) { ++ if (siblings->type == XML_ELEMENT_NODE) { ++ if (siblings == node) { ++ len++; ++ pos = len; ++ } else if ((node->name != NULL) && ++ (siblings->name != NULL) && ++ (node->name[0] == siblings->name[0]) && ++ (xmlStrEqual(node->name, siblings->name))) { ++ if ((sel->value2 == NULL) || ++ ((siblings->ns != NULL) && ++ (xmlStrEqual(sel->value2, siblings->ns->href)))) ++ len++; ++ } ++ } ++ siblings = siblings->next; ++ } ++ if ((parent == NULL) || (node->doc == NULL)) ++ nocache = 1; ++ else { ++ while (parent->parent != NULL) ++ parent = parent->parent; ++ if (((parent->type != XML_DOCUMENT_NODE) && ++ (parent->type != XML_HTML_DOCUMENT_NODE)) || ++ (parent != (xmlNodePtr) node->doc)) ++ nocache = 1; ++ } ++ } ++ if (pos != 0) { ++ ctxt->xpathCtxt->contextSize = len; ++ ctxt->xpathCtxt->proximityPosition = pos; ++ /* ++ * If the node is in a Value Tree we cannot ++ * cache it ! ++ */ ++ if ((!isRVT) && (node->doc != NULL) && ++ (nocache == 0)) { ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len; ++ } ++ } ++ } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) && ++ (node->type == XML_ELEMENT_NODE)) { ++ xmlNodePtr previous; ++ int nocache = 0; ++ ++ previous = (xmlNodePtr) ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); ++ if ((previous != NULL) && ++ (previous->parent == node->parent)) { ++ /* ++ * just walk back to adjust the index ++ */ ++ int indx = 0; ++ xmlNodePtr sibling = node; ++ ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if (sibling->type == XML_ELEMENT_NODE) ++ indx++; ++ sibling = sibling->prev; ++ } ++ if (sibling == NULL) { ++ /* hum going backward in document order ... */ ++ indx = 0; ++ sibling = node; ++ while (sibling != NULL) { ++ if (sibling == previous) ++ break; ++ if (sibling->type == XML_ELEMENT_NODE) ++ indx--; ++ sibling = sibling->next; ++ } ++ } ++ if (sibling != NULL) { ++ pos = XSLT_RUNTIME_EXTRA(ctxt, ++ sel->indexExtra, ival) + indx; ++ /* ++ * If the node is in a Value Tree we cannot ++ * cache it ! ++ */ ++ if ((node->doc != NULL) && !isRVT) { ++ len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival); ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ } ++ } else ++ pos = 0; ++ } else { ++ /* ++ * recompute the index ++ */ ++ xmlNodePtr parent = node->parent; ++ xmlNodePtr siblings = NULL; ++ ++ if (parent) siblings = parent->children; ++ ++ while (siblings != NULL) { ++ if (siblings->type == XML_ELEMENT_NODE) { ++ len++; ++ if (siblings == node) { ++ pos = len; ++ } ++ } ++ siblings = siblings->next; ++ } ++ if ((parent == NULL) || (node->doc == NULL)) ++ nocache = 1; ++ else { ++ while (parent->parent != NULL) ++ parent = parent->parent; ++ if (((parent->type != XML_DOCUMENT_NODE) && ++ (parent->type != XML_HTML_DOCUMENT_NODE)) || ++ (parent != (xmlNodePtr) node->doc)) ++ nocache = 1; ++ } ++ } ++ if (pos != 0) { ++ ctxt->xpathCtxt->contextSize = len; ++ ctxt->xpathCtxt->proximityPosition = pos; ++ /* ++ * If the node is in a Value Tree we cannot ++ * cache it ! ++ */ ++ if ((node->doc != NULL) && (nocache == 0) && !isRVT) { ++ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos; ++ XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len; ++ } ++ } ++ } ++ ++ oldNode = ctxt->node; ++ ctxt->node = node; ++ ++ match = xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList, comp->nsNr); ++ ++ if (pos != 0) { ++ ctxt->xpathCtxt->contextSize = oldCS; ++ ctxt->xpathCtxt->proximityPosition = oldCP; ++ } ++ ctxt->node = oldNode; ++ ++ return match; ++} ++ + /** + * xsltTestCompMatch: + * @ctxt: a XSLT process context +@@ -634,9 +911,10 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + */ + static int + xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, +- xmlNodePtr node, const xmlChar *mode, ++ xmlNodePtr matchNode, const xmlChar *mode, + const xmlChar *modeURI) { + int i; ++ xmlNodePtr node = matchNode; + xsltStepOpPtr step, sel = NULL; + xsltStepStates states = {0, 0, NULL}; /* // may require backtrack */ + +@@ -854,14 +1132,9 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + goto rollback; + break; + case XSLT_OP_PREDICATE: { +- xmlNodePtr oldNode; +- xmlDocPtr doc; +- int oldCS, oldCP; +- int pos = 0, len = 0; +- int isRVT; +- + /* +- * when there is cascading XSLT_OP_PREDICATE, then use a ++ * When there is cascading XSLT_OP_PREDICATE or a predicate ++ * after an op which hasn't been optimized yet, then use a + * direct computation approach. It's not done directly + * at the beginning of the routine to filter out as much + * as possible this costly computation. +@@ -871,278 +1144,14 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, + /* Free the rollback states */ + xmlFree(states.states); + } +- return(xsltTestCompMatchDirect(ctxt, comp, node, ++ return(xsltTestCompMatchDirect(ctxt, comp, matchNode, + comp->nsList, comp->nsNr)); + } + +- doc = node->doc; +- if (XSLT_IS_RES_TREE_FRAG(doc)) +- isRVT = 1; +- else +- isRVT = 0; +- +- /* +- * Depending on the last selection, one may need to +- * recompute contextSize and proximityPosition. +- */ +- oldCS = ctxt->xpathCtxt->contextSize; +- oldCP = ctxt->xpathCtxt->proximityPosition; +- if ((sel != NULL) && +- (sel->op == XSLT_OP_ELEM) && +- (sel->value != NULL) && +- (node->type == XML_ELEMENT_NODE) && +- (node->parent != NULL)) { +- xmlNodePtr previous; +- int nocache = 0; +- +- previous = (xmlNodePtr) +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); +- if ((previous != NULL) && +- (previous->parent == node->parent)) { +- /* +- * just walk back to adjust the index +- */ +- int indx = 0; +- xmlNodePtr sibling = node; +- +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if ((sibling->type == XML_ELEMENT_NODE) && +- (previous->name != NULL) && +- (sibling->name != NULL) && +- (previous->name[0] == sibling->name[0]) && +- (xmlStrEqual(previous->name, sibling->name))) +- { +- if ((sel->value2 == NULL) || +- ((sibling->ns != NULL) && +- (xmlStrEqual(sel->value2, +- sibling->ns->href)))) +- indx++; +- } +- sibling = sibling->prev; +- } +- if (sibling == NULL) { +- /* hum going backward in document order ... */ +- indx = 0; +- sibling = node; +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if ((sibling->type == XML_ELEMENT_NODE) && +- (previous->name != NULL) && +- (sibling->name != NULL) && +- (previous->name[0] == sibling->name[0]) && +- (xmlStrEqual(previous->name, sibling->name))) +- { +- if ((sel->value2 == NULL) || +- ((sibling->ns != NULL) && +- (xmlStrEqual(sel->value2, +- sibling->ns->href)))) +- { +- indx--; +- } +- } +- sibling = sibling->next; +- } +- } +- if (sibling != NULL) { +- pos = XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) + indx; +- /* +- * If the node is in a Value Tree we need to +- * save len, but cannot cache the node! +- * (bugs 153137 and 158840) +- */ +- if (node->doc != NULL) { +- len = XSLT_RUNTIME_EXTRA(ctxt, +- sel->lenExtra, ival); +- if (!isRVT) { +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->previousExtra, ptr) = node; +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) = pos; +- } +- } +- } else +- pos = 0; +- } else { +- /* +- * recompute the index +- */ +- xmlNodePtr parent = node->parent; +- xmlNodePtr siblings = NULL; +- +- if (parent) siblings = parent->children; +- +- while (siblings != NULL) { +- if (siblings->type == XML_ELEMENT_NODE) { +- if (siblings == node) { +- len++; +- pos = len; +- } else if ((node->name != NULL) && +- (siblings->name != NULL) && +- (node->name[0] == siblings->name[0]) && +- (xmlStrEqual(node->name, siblings->name))) { +- if ((sel->value2 == NULL) || +- ((siblings->ns != NULL) && +- (xmlStrEqual(sel->value2, +- siblings->ns->href)))) +- len++; +- } +- } +- siblings = siblings->next; +- } +- if ((parent == NULL) || (node->doc == NULL)) +- nocache = 1; +- else { +- while (parent->parent != NULL) +- parent = parent->parent; +- if (((parent->type != XML_DOCUMENT_NODE) && +- (parent->type != XML_HTML_DOCUMENT_NODE)) || +- (parent != (xmlNodePtr) node->doc)) +- nocache = 1; +- } +- } +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = len; +- ctxt->xpathCtxt->proximityPosition = pos; +- /* +- * If the node is in a Value Tree we cannot +- * cache it ! +- */ +- if ((!isRVT) && (node->doc != NULL) && +- (nocache == 0)) { +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = +- node; +- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = +- pos; +- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = +- len; +- } +- } +- } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) && +- (node->type == XML_ELEMENT_NODE)) { +- xmlNodePtr previous; +- int nocache = 0; +- +- previous = (xmlNodePtr) +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); +- if ((previous != NULL) && +- (previous->parent == node->parent)) { +- /* +- * just walk back to adjust the index +- */ +- int indx = 0; +- xmlNodePtr sibling = node; +- +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if (sibling->type == XML_ELEMENT_NODE) +- indx++; +- sibling = sibling->prev; +- } +- if (sibling == NULL) { +- /* hum going backward in document order ... */ +- indx = 0; +- sibling = node; +- while (sibling != NULL) { +- if (sibling == previous) +- break; +- if (sibling->type == XML_ELEMENT_NODE) +- indx--; +- sibling = sibling->next; +- } +- } +- if (sibling != NULL) { +- pos = XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) + indx; +- /* +- * If the node is in a Value Tree we cannot +- * cache it ! +- */ +- if ((node->doc != NULL) && !isRVT) { +- len = XSLT_RUNTIME_EXTRA(ctxt, +- sel->lenExtra, ival); +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->previousExtra, ptr) = node; +- XSLT_RUNTIME_EXTRA(ctxt, +- sel->indexExtra, ival) = pos; +- } +- } else +- pos = 0; +- } else { +- /* +- * recompute the index +- */ +- xmlNodePtr parent = node->parent; +- xmlNodePtr siblings = NULL; +- +- if (parent) siblings = parent->children; +- +- while (siblings != NULL) { +- if (siblings->type == XML_ELEMENT_NODE) { +- len++; +- if (siblings == node) { +- pos = len; +- } +- } +- siblings = siblings->next; +- } +- if ((parent == NULL) || (node->doc == NULL)) +- nocache = 1; +- else { +- while (parent->parent != NULL) +- parent = parent->parent; +- if (((parent->type != XML_DOCUMENT_NODE) && +- (parent->type != XML_HTML_DOCUMENT_NODE)) || +- (parent != (xmlNodePtr) node->doc)) +- nocache = 1; +- } +- } +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = len; +- ctxt->xpathCtxt->proximityPosition = pos; +- /* +- * If the node is in a Value Tree we cannot +- * cache it ! +- */ +- if ((node->doc != NULL) && (nocache == 0) && !isRVT) { +- XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = +- node; +- XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = +- pos; +- XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = +- len; +- } +- } +- } +- oldNode = ctxt->node; +- ctxt->node = node; +- +- if (step->value == NULL) +- goto wrong_index; +- if (step->comp == NULL) +- goto wrong_index; +- +- if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList, +- comp->nsNr)) +- goto wrong_index; ++ if (!xsltTestPredicateMatch(ctxt, comp, node, step, sel)) ++ goto rollback; + +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = oldCS; +- ctxt->xpathCtxt->proximityPosition = oldCP; +- } +- ctxt->node = oldNode; + break; +-wrong_index: +- if (pos != 0) { +- ctxt->xpathCtxt->contextSize = oldCS; +- ctxt->xpathCtxt->proximityPosition = oldCP; +- } +- ctxt->node = oldNode; +- goto rollback; + } + case XSLT_OP_PI: + if (node->type != XML_PI_NODE) +@@ -1424,6 +1433,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, + if (CUR != ',') { + xsltTransformError(NULL, NULL, NULL, + ""xsltCompileIdKeyPattern : , expected\n""); ++ xmlFree(lit); + ctxt->error = 1; + return; + } +@@ -2080,9 +2090,34 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, + const xmlChar *name = NULL; + float priority; /* the priority */ + +- if ((style == NULL) || (cur == NULL) || (cur->match == NULL)) ++ if ((style == NULL) || (cur == NULL)) + return(-1); + ++ /* Register named template */ ++ if (cur->name != NULL) { ++ if (style->namedTemplates == NULL) { ++ style->namedTemplates = xmlHashCreate(10); ++ if (style->namedTemplates == NULL) ++ return(-1); ++ } ++ else { ++ void *dup = xmlHashLookup2(style->namedTemplates, cur->name, ++ cur->nameURI); ++ if (dup != NULL) { ++ xsltTransformError(NULL, style, NULL, ++ ""xsl:template: error duplicate name '%s'\n"", ++ cur->name); ++ style->errors++; ++ return(-1); ++ } ++ } ++ ++ xmlHashAddEntry2(style->namedTemplates, cur->name, cur->nameURI, cur); ++ } ++ ++ if (cur->match == NULL) ++ return(0); ++ + priority = cur->priority; + pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem, + style, NULL, 1); +@@ -2552,5 +2587,7 @@ xsltFreeTemplateHashes(xsltStylesheetPtr style) { + xsltFreeCompMatchList(style->piMatch); + if (style->commentMatch != NULL) + xsltFreeCompMatchList(style->commentMatch); ++ if (style->namedTemplates != NULL) ++ xmlHashFree(style->namedTemplates, NULL); + } + ",4337,4573,6144 +17240,"bool venc_dev::venc_set_param(void *paramData,OMX_INDEXTYPE index ) +{ + DEBUG_PRINT_LOW(""venc_set_param:: venc-720p""); + struct v4l2_format fmt; + struct v4l2_requestbuffers bufreq; + int ret; + + switch ((int)index) { + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *portDefn; + portDefn = (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamPortDefinition""); + + if (portDefn->nPortIndex == PORT_INDEX_IN) { + if (!venc_set_encode_framerate(portDefn->format.video.xFramerate, 0)) { + return false; + } + + if (!venc_set_color_format(portDefn->format.video.eColorFormat)) { + return false; + } + if (enable_mv_narrow_searchrange && + (m_sVenc_cfg.input_width * m_sVenc_cfg.input_height) >= + (OMX_CORE_1080P_WIDTH * OMX_CORE_1080P_HEIGHT)) { + if (venc_set_searchrange() == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set search range""); + } + } + if (m_sVenc_cfg.input_height != portDefn->format.video.nFrameHeight || + m_sVenc_cfg.input_width != portDefn->format.video.nFrameWidth) { + DEBUG_PRINT_LOW(""Basic parameter has changed""); + m_sVenc_cfg.input_height = portDefn->format.video.nFrameHeight; + m_sVenc_cfg.input_width = portDefn->format.video.nFrameWidth; + fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + fmt.fmt.pix_mp.height = m_sVenc_cfg.input_height; + fmt.fmt.pix_mp.width = m_sVenc_cfg.input_width; + fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12; + fmt.fmt.pix_mp.colorspace = V4L2_COLORSPACE_BT878; + + if (ioctl(m_nDriver_fd, VIDIOC_S_FMT, &fmt)) { + DEBUG_PRINT_ERROR(""VIDIOC_S_FMT OUTPUT_MPLANE Failed""); + hw_overload = errno == EBUSY; + return false; + } + + m_sInput_buff_property.datasize=fmt.fmt.pix_mp.plane_fmt[0].sizeimage; + bufreq.memory = V4L2_MEMORY_USERPTR; + bufreq.count = portDefn->nBufferCountActual; + bufreq.type=V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + + if (ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq)) { + DEBUG_PRINT_ERROR(""VIDIOC_REQBUFS OUTPUT_MPLANE Failed""); + return false; + } + + if (bufreq.count == portDefn->nBufferCountActual) + m_sInput_buff_property.mincount = m_sInput_buff_property.actualcount = bufreq.count; + + if (portDefn->nBufferCountActual >= m_sInput_buff_property.mincount) + m_sInput_buff_property.actualcount = portDefn->nBufferCountActual; + } + + DEBUG_PRINT_LOW(""input: actual: %u, min: %u, count_req: %u"", + (unsigned int)portDefn->nBufferCountActual, (unsigned int)m_sInput_buff_property.mincount, bufreq.count); + if (m_sVenc_cfg.input_width * m_sVenc_cfg.input_height >= 3840 * 2160) { + if (venc_set_perf_mode(V4L2_MPEG_VIDC_VIDEO_PERF_POWER_SAVE) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set Power save mode""); + } + } + } else if (portDefn->nPortIndex == PORT_INDEX_OUT) { + m_sVenc_cfg.dvs_height = portDefn->format.video.nFrameHeight; + m_sVenc_cfg.dvs_width = portDefn->format.video.nFrameWidth; + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + fmt.fmt.pix_mp.height = m_sVenc_cfg.dvs_height; + fmt.fmt.pix_mp.width = m_sVenc_cfg.dvs_width; + fmt.fmt.pix_mp.pixelformat = m_sVenc_cfg.codectype; + + if (ioctl(m_nDriver_fd, VIDIOC_S_FMT, &fmt)) { + DEBUG_PRINT_ERROR(""VIDIOC_S_FMT CAPTURE_MPLANE Failed""); + hw_overload = errno == EBUSY; + return false; + } + + m_sOutput_buff_property.datasize = fmt.fmt.pix_mp.plane_fmt[0].sizeimage; + + if (!venc_set_target_bitrate(portDefn->format.video.nBitrate, 0)) { + return false; + } + + m_sOutput_buff_property.actualcount = portDefn->nBufferCountActual; + bufreq.memory = V4L2_MEMORY_USERPTR; + bufreq.count = portDefn->nBufferCountActual; + bufreq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + + if (ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting o/p buffer count failed: requested: %u, current: %u"", + (unsigned int)portDefn->nBufferCountActual, (unsigned int)m_sOutput_buff_property.actualcount); + return false; + } + + if (bufreq.count == portDefn->nBufferCountActual) + m_sOutput_buff_property.mincount = m_sOutput_buff_property.actualcount = bufreq.count; + + if (portDefn->nBufferCountActual >= m_sOutput_buff_property.mincount) + m_sOutput_buff_property.actualcount = portDefn->nBufferCountActual; + + if (num_planes > 1) + extradata_info.count = m_sOutput_buff_property.actualcount; + + DEBUG_PRINT_LOW(""Output: actual: %u, min: %u, count_req: %u"", + (unsigned int)portDefn->nBufferCountActual, (unsigned int)m_sOutput_buff_property.mincount, bufreq.count); + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamPortDefinition""); + } + + break; + } + case OMX_IndexParamVideoPortFormat: + { + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFmt; + portFmt =(OMX_VIDEO_PARAM_PORTFORMATTYPE *)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoPortFormat""); + + if (portFmt->nPortIndex == (OMX_U32) PORT_INDEX_IN) { + if (!venc_set_color_format(portFmt->eColorFormat)) { + return false; + } + } else if (portFmt->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (!venc_set_encode_framerate(portFmt->xFramerate, 0)) { + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoPortFormat""); + } + + break; + } + case OMX_IndexParamVideoBitrate: + { + OMX_VIDEO_PARAM_BITRATETYPE* pParam; + pParam = (OMX_VIDEO_PARAM_BITRATETYPE*)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoBitrate""); + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (!venc_set_target_bitrate(pParam->nTargetBitrate, 0)) { + DEBUG_PRINT_ERROR(""ERROR: Target Bit Rate setting failed""); + return false; + } + + if (!venc_set_ratectrl_cfg(pParam->eControlRate)) { + DEBUG_PRINT_ERROR(""ERROR: Rate Control setting failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoBitrate""); + } + + break; + } + case OMX_IndexParamVideoMpeg4: + { + OMX_VIDEO_PARAM_MPEG4TYPE* pParam; + OMX_U32 bFrames = 0; + + pParam = (OMX_VIDEO_PARAM_MPEG4TYPE*)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoMpeg4""); + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (!venc_set_voptiming_cfg(pParam->nTimeIncRes)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting vop_timing failed""); + return false; + } + + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level""); + return false; + } else { + if (pParam->eProfile == OMX_VIDEO_MPEG4ProfileAdvancedSimple) { + if (pParam->nBFrames) { + bFrames = pParam->nBFrames; + } + } else { + if (pParam->nBFrames) { + DEBUG_PRINT_ERROR(""Warning: B frames not supported""); + bFrames = 0; + } + } + } + + if (!venc_set_intra_period (pParam->nPFrames,bFrames)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting intra period failed""); + return false; + } + + if (!venc_set_multislice_cfg(OMX_IndexParamVideoMpeg4,pParam->nSliceHeaderSpacing)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating slice_config""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoMpeg4""); + } + + break; + } + case OMX_IndexParamVideoH263: + { + OMX_VIDEO_PARAM_H263TYPE* pParam = (OMX_VIDEO_PARAM_H263TYPE*)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoH263""); + OMX_U32 bFrames = 0; + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level""); + return false; + } + + if (pParam->nBFrames) + DEBUG_PRINT_ERROR(""WARNING: B frame not supported for H.263""); + + if (venc_set_intra_period (pParam->nPFrames, bFrames) == false) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting intra period failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoH263""); + } + + break; + } + case OMX_IndexParamVideoAvc: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoAvc""); + OMX_VIDEO_PARAM_AVCTYPE* pParam = (OMX_VIDEO_PARAM_AVCTYPE*)paramData; + OMX_U32 bFrames = 0; + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + DEBUG_PRINT_LOW(""pParam->eProfile :%d ,pParam->eLevel %d"", + pParam->eProfile,pParam->eLevel); + + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (pParam->eProfile,pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level %d, %d"", + pParam->eProfile, pParam->eLevel); + return false; + } else { + if ((pParam->eProfile != OMX_VIDEO_AVCProfileBaseline) && + (pParam->eProfile != (OMX_VIDEO_AVCPROFILETYPE) QOMX_VIDEO_AVCProfileConstrainedBaseline)) { + if (pParam->nBFrames) { + bFrames = pParam->nBFrames; + } + } else { + if (pParam->nBFrames) { + DEBUG_PRINT_ERROR(""Warning: B frames not supported""); + bFrames = 0; + } + } + } + + if (!venc_set_intra_period (pParam->nPFrames, bFrames)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting intra period failed""); + return false; + } + + if (!venc_set_entropy_config (pParam->bEntropyCodingCABAC, pParam->nCabacInitIdc)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting Entropy failed""); + return false; + } + + if (!venc_set_inloop_filter (pParam->eLoopFilterMode)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting Inloop filter failed""); + return false; + } + + if (!venc_set_multislice_cfg(OMX_IndexParamVideoAvc, pParam->nSliceHeaderSpacing)) { + DEBUG_PRINT_ERROR(""WARNING: Unsuccessful in updating slice_config""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoAvc""); + } + + break; + } + case (OMX_INDEXTYPE)OMX_IndexParamVideoVp8: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoVp8""); + OMX_VIDEO_PARAM_VP8TYPE* pParam = (OMX_VIDEO_PARAM_VP8TYPE*)paramData; + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level %d, %d"", + pParam->eProfile, pParam->eLevel); + return false; + } + if(venc_set_vpx_error_resilience(pParam->bErrorResilientMode) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set vpx error resilience""); + return false; + } + if(!venc_set_ltrmode(1, 1)) { + DEBUG_PRINT_ERROR(""ERROR: Failed to enable ltrmode""); + return false; + } + + if (m_codec == OMX_VIDEO_CodingVP8) { + DEBUG_PRINT_LOW(""Disable Hier-P as LTR is being set""); + if (!venc_set_hier_layers(QOMX_HIERARCHICALCODING_P, 0)) { + DEBUG_PRINT_ERROR(""Disabling Hier P count failed""); + } + } + + break; + } + case (OMX_INDEXTYPE)OMX_IndexParamVideoHevc: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoHevc""); + OMX_VIDEO_PARAM_HEVCTYPE* pParam = (OMX_VIDEO_PARAM_HEVCTYPE*)paramData; + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level %d, %d"", + pParam->eProfile, pParam->eLevel); + return false; + } + if (!venc_set_inloop_filter(OMX_VIDEO_AVCLoopFilterEnable)) + DEBUG_PRINT_HIGH(""WARN: Request for setting Inloop filter failed for HEVC encoder""); + + break; + } + case OMX_IndexParamVideoIntraRefresh: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoIntraRefresh""); + OMX_VIDEO_PARAM_INTRAREFRESHTYPE *intra_refresh = + (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)paramData; + + if (intra_refresh->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (venc_set_intra_refresh(intra_refresh->eRefreshMode, intra_refresh->nCirMBs) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting Intra refresh failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoIntraRefresh""); + } + + break; + } + case OMX_IndexParamVideoErrorCorrection: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoErrorCorrection""); + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *error_resilience = + (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)paramData; + + if (error_resilience->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (venc_set_error_resilience(error_resilience) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting Intra refresh failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoErrorCorrection""); + } + + break; + } + case OMX_IndexParamVideoProfileLevelCurrent: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoProfileLevelCurrent""); + OMX_VIDEO_PARAM_PROFILELEVELTYPE *profile_level = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)paramData; + + if (profile_level->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (profile_level->eProfile, + profile_level->eLevel)) { + DEBUG_PRINT_ERROR(""WARNING: Unsuccessful in updating Profile and level""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoProfileLevelCurrent""); + } + + break; + } + case OMX_IndexParamVideoQuantization: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoQuantization""); + OMX_VIDEO_PARAM_QUANTIZATIONTYPE *session_qp = + (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)paramData; + if (session_qp->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (venc_set_session_qp (session_qp->nQpI, + session_qp->nQpP, + session_qp->nQpB) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting Session QP failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoQuantization""); + } + + break; + } + case QOMX_IndexParamVideoInitialQp: + { + QOMX_EXTNINDEX_VIDEO_INITIALQP * initqp = + (QOMX_EXTNINDEX_VIDEO_INITIALQP *)paramData; + if (initqp->bEnableInitQp) { + DEBUG_PRINT_LOW(""Enable initial QP: %d"", (int)initqp->bEnableInitQp); + if(venc_enable_initial_qp(initqp) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to enable initial QP""); + return OMX_ErrorUnsupportedSetting; + } + } else + DEBUG_PRINT_ERROR(""ERROR: setting QOMX_IndexParamVideoEnableInitialQp""); + break; + } + case OMX_QcomIndexParamVideoQPRange: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_QcomIndexParamVideoQPRange""); + OMX_QCOM_VIDEO_PARAM_QPRANGETYPE *session_qp_range = + (OMX_QCOM_VIDEO_PARAM_QPRANGETYPE *)paramData; + + if(session_qp_range->nPortIndex == (OMX_U32)PORT_INDEX_OUT) { + if(venc_set_session_qp_range (session_qp_range->minQP, + session_qp_range->maxQP) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting QP Range[%u %u] failed"", + (unsigned int)session_qp_range->minQP, (unsigned int)session_qp_range->maxQP); + return false; + } else { + session_qp_values.minqp = session_qp_range->minQP; + session_qp_values.maxqp = session_qp_range->maxQP; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_QcomIndexParamVideoQPRange""); + } + + break; + } + case OMX_QcomIndexEnableSliceDeliveryMode: + { + QOMX_EXTNINDEX_PARAMTYPE* pParam = + (QOMX_EXTNINDEX_PARAMTYPE*)paramData; + + if (pParam->nPortIndex == PORT_INDEX_OUT) { + if (venc_set_slice_delivery_mode(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""Setting slice delivery mode failed""); + return OMX_ErrorUnsupportedSetting; + } + } else { + DEBUG_PRINT_ERROR(""OMX_QcomIndexEnableSliceDeliveryMode "" + ""called on wrong port(%u)"", (unsigned int)pParam->nPortIndex); + return OMX_ErrorBadPortIndex; + } + + break; + } + case OMX_ExtraDataVideoEncoderSliceInfo: + { + DEBUG_PRINT_LOW(""venc_set_param: OMX_ExtraDataVideoEncoderSliceInfo""); + OMX_BOOL extra_data = *(OMX_BOOL *)(paramData); + + if (venc_set_extradata(OMX_ExtraDataVideoEncoderSliceInfo, extra_data) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting OMX_ExtraDataVideoEncoderSliceInfo failed""); + return false; + } + + extradata = true; + break; + } + case OMX_ExtraDataVideoEncoderMBInfo: + { + DEBUG_PRINT_LOW(""venc_set_param: OMX_ExtraDataVideoEncoderMBInfo""); + OMX_BOOL extra_data = *(OMX_BOOL *)(paramData); + + if (venc_set_extradata(OMX_ExtraDataVideoEncoderMBInfo, extra_data) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting OMX_ExtraDataVideoEncoderMBInfo failed""); + return false; + } + + extradata = true; + break; + } + case OMX_QcomIndexParamSequenceHeaderWithIDR: + { + PrependSPSPPSToIDRFramesParams * pParam = + (PrependSPSPPSToIDRFramesParams *)paramData; + + DEBUG_PRINT_LOW(""set inband sps/pps: %d"", pParam->bEnable); + if(venc_set_inband_video_header(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""ERROR: set inband sps/pps failed""); + return OMX_ErrorUnsupportedSetting; + } + + break; + } + case OMX_QcomIndexParamH264AUDelimiter: + { + OMX_QCOM_VIDEO_CONFIG_H264_AUD * pParam = + (OMX_QCOM_VIDEO_CONFIG_H264_AUD *)paramData; + + DEBUG_PRINT_LOW(""set AU delimiters: %d"", pParam->bEnable); + if(venc_set_au_delimiter(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""ERROR: set H264 AU delimiter failed""); + return OMX_ErrorUnsupportedSetting; + } + + break; + } + case OMX_QcomIndexHierarchicalStructure: + { + QOMX_VIDEO_HIERARCHICALLAYERS* pParam = + (QOMX_VIDEO_HIERARCHICALLAYERS*)paramData; + + if (pParam->nPortIndex == PORT_INDEX_OUT) { + if (!venc_set_hier_layers(pParam->eHierarchicalCodingType, pParam->nNumLayers)) { + DEBUG_PRINT_ERROR(""Setting Hier P count failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""OMX_QcomIndexHierarchicalStructure called on wrong port(%d)"", (int)pParam->nPortIndex); + return false; + } + + if (m_codec == OMX_VIDEO_CodingVP8) { + DEBUG_PRINT_LOW(""Disable LTR as HIER-P is being set""); + if(!venc_set_ltrmode(0, 1)) { + DEBUG_PRINT_ERROR(""ERROR: Failed to disable ltrmode""); + } + } + break; + } + case OMX_QcomIndexParamPerfLevel: + { + OMX_QCOM_VIDEO_PARAM_PERF_LEVEL *pParam = + (OMX_QCOM_VIDEO_PARAM_PERF_LEVEL *)paramData; + DEBUG_PRINT_LOW(""Set perf level: %d"", pParam->ePerfLevel); + if(!venc_set_perf_level(pParam->ePerfLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set perf level to %d"", pParam->ePerfLevel); + return false; + } else { + performance_level.perflevel = (unsigned int) pParam->ePerfLevel; + } + break; + } + case OMX_QcomIndexParamH264VUITimingInfo: + { + OMX_QCOM_VIDEO_PARAM_VUI_TIMING_INFO *pParam = + (OMX_QCOM_VIDEO_PARAM_VUI_TIMING_INFO *)paramData; + DEBUG_PRINT_LOW(""Set VUI timing info: %d"", pParam->bEnable); + if(venc_set_vui_timing_info(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set vui timing info to %d"", pParam->bEnable); + return false; + } else { + vui_timing_info.enabled = (unsigned int) pParam->bEnable; + } + break; + } + case OMX_QcomIndexParamPeakBitrate: + { + OMX_QCOM_VIDEO_PARAM_PEAK_BITRATE *pParam = + (OMX_QCOM_VIDEO_PARAM_PEAK_BITRATE *)paramData; + DEBUG_PRINT_LOW(""Set peak bitrate: %u"", (unsigned int)pParam->nPeakBitrate); + if(venc_set_peak_bitrate(pParam->nPeakBitrate) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set peak bitrate to %u"", (unsigned int)pParam->nPeakBitrate); + return false; + } else { + peak_bitrate.peakbitrate = (unsigned int) pParam->nPeakBitrate; + } + break; + } + case OMX_QcomIndexParamSetMVSearchrange: + { + DEBUG_PRINT_LOW(""venc_set_config: OMX_QcomIndexParamSetMVSearchrange""); + is_searchrange_set = true; + if (!venc_set_searchrange()) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set search range""); + return false; + } + } + break; + case OMX_QcomIndexParamVideoLTRCount: + { + DEBUG_PRINT_LOW(""venc_set_param: OMX_QcomIndexParamVideoLTRCount""); + OMX_QCOM_VIDEO_PARAM_LTRCOUNT_TYPE* pParam = + (OMX_QCOM_VIDEO_PARAM_LTRCOUNT_TYPE*)paramData; + if (pParam->nCount > 0) { + if (venc_set_ltrmode(1, pParam->nCount) == false) { + DEBUG_PRINT_ERROR(""ERROR: Enable LTR mode failed""); + return false; + } + } else { + if (venc_set_ltrmode(0, 0) == false) { + DEBUG_PRINT_ERROR(""ERROR: Disable LTR mode failed""); + return false; + } + } + break; + } + case OMX_QcomIndexParamVideoHybridHierpMode: + { + QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE* pParam = + (QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE*)paramData; + + if (!venc_set_hybrid_hierp(pParam->nHpLayers)) { + DEBUG_PRINT_ERROR(""Setting hybrid Hier-P mode failed""); + return OMX_ErrorUnsupportedSetting; + } + break; + } + case OMX_IndexParamVideoSliceFMO: + default: + DEBUG_PRINT_ERROR(""ERROR: Unsupported parameter in venc_set_param: %u"", + index); + break; + } + + return true; +} +",0,"bool venc_dev::venc_set_param(void *paramData,OMX_INDEXTYPE index ) +{ + DEBUG_PRINT_LOW(""venc_set_param:: venc-720p""); + struct v4l2_format fmt; + struct v4l2_requestbuffers bufreq; + int ret; + + switch ((int)index) { + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *portDefn; + portDefn = (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamPortDefinition""); + + if (portDefn->nPortIndex == PORT_INDEX_IN) { + if (!venc_set_encode_framerate(portDefn->format.video.xFramerate, 0)) { + return false; + } + + if (!venc_set_color_format(portDefn->format.video.eColorFormat)) { + return false; + } + if (enable_mv_narrow_searchrange && + (m_sVenc_cfg.input_width * m_sVenc_cfg.input_height) >= + (OMX_CORE_1080P_WIDTH * OMX_CORE_1080P_HEIGHT)) { + if (venc_set_searchrange() == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set search range""); + } + } + if (m_sVenc_cfg.input_height != portDefn->format.video.nFrameHeight || + m_sVenc_cfg.input_width != portDefn->format.video.nFrameWidth) { + DEBUG_PRINT_LOW(""Basic parameter has changed""); + m_sVenc_cfg.input_height = portDefn->format.video.nFrameHeight; + m_sVenc_cfg.input_width = portDefn->format.video.nFrameWidth; + fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + fmt.fmt.pix_mp.height = m_sVenc_cfg.input_height; + fmt.fmt.pix_mp.width = m_sVenc_cfg.input_width; + fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12; + fmt.fmt.pix_mp.colorspace = V4L2_COLORSPACE_BT878; + + if (ioctl(m_nDriver_fd, VIDIOC_S_FMT, &fmt)) { + DEBUG_PRINT_ERROR(""VIDIOC_S_FMT OUTPUT_MPLANE Failed""); + hw_overload = errno == EBUSY; + return false; + } + + m_sInput_buff_property.datasize=fmt.fmt.pix_mp.plane_fmt[0].sizeimage; + bufreq.memory = V4L2_MEMORY_USERPTR; + bufreq.count = portDefn->nBufferCountActual; + bufreq.type=V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + + if (ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq)) { + DEBUG_PRINT_ERROR(""VIDIOC_REQBUFS OUTPUT_MPLANE Failed""); + return false; + } + + if (bufreq.count == portDefn->nBufferCountActual) + m_sInput_buff_property.mincount = m_sInput_buff_property.actualcount = bufreq.count; + + if (portDefn->nBufferCountActual >= m_sInput_buff_property.mincount) + m_sInput_buff_property.actualcount = portDefn->nBufferCountActual; + } + + DEBUG_PRINT_LOW(""input: actual: %u, min: %u, count_req: %u"", + (unsigned int)portDefn->nBufferCountActual, (unsigned int)m_sInput_buff_property.mincount, bufreq.count); + if (m_sVenc_cfg.input_width * m_sVenc_cfg.input_height >= 3840 * 2160) { + if (venc_set_perf_mode(V4L2_MPEG_VIDC_VIDEO_PERF_POWER_SAVE) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set Power save mode""); + } + } + } else if (portDefn->nPortIndex == PORT_INDEX_OUT) { + m_sVenc_cfg.dvs_height = portDefn->format.video.nFrameHeight; + m_sVenc_cfg.dvs_width = portDefn->format.video.nFrameWidth; + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + fmt.fmt.pix_mp.height = m_sVenc_cfg.dvs_height; + fmt.fmt.pix_mp.width = m_sVenc_cfg.dvs_width; + fmt.fmt.pix_mp.pixelformat = m_sVenc_cfg.codectype; + + if (ioctl(m_nDriver_fd, VIDIOC_S_FMT, &fmt)) { + DEBUG_PRINT_ERROR(""VIDIOC_S_FMT CAPTURE_MPLANE Failed""); + hw_overload = errno == EBUSY; + return false; + } + + m_sOutput_buff_property.datasize = fmt.fmt.pix_mp.plane_fmt[0].sizeimage; + + if (!venc_set_target_bitrate(portDefn->format.video.nBitrate, 0)) { + return false; + } + + m_sOutput_buff_property.actualcount = portDefn->nBufferCountActual; + bufreq.memory = V4L2_MEMORY_USERPTR; + bufreq.count = portDefn->nBufferCountActual; + bufreq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + + if (ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting o/p buffer count failed: requested: %u, current: %u"", + (unsigned int)portDefn->nBufferCountActual, (unsigned int)m_sOutput_buff_property.actualcount); + return false; + } + + if (bufreq.count == portDefn->nBufferCountActual) + m_sOutput_buff_property.mincount = m_sOutput_buff_property.actualcount = bufreq.count; + + if (portDefn->nBufferCountActual >= m_sOutput_buff_property.mincount) + m_sOutput_buff_property.actualcount = portDefn->nBufferCountActual; + + if (num_planes > 1) + extradata_info.count = m_sOutput_buff_property.actualcount; + + DEBUG_PRINT_LOW(""Output: actual: %u, min: %u, count_req: %u"", + (unsigned int)portDefn->nBufferCountActual, (unsigned int)m_sOutput_buff_property.mincount, bufreq.count); + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamPortDefinition""); + } + + break; + } + case OMX_IndexParamVideoPortFormat: + { + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFmt; + portFmt =(OMX_VIDEO_PARAM_PORTFORMATTYPE *)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoPortFormat""); + + if (portFmt->nPortIndex == (OMX_U32) PORT_INDEX_IN) { + if (!venc_set_color_format(portFmt->eColorFormat)) { + return false; + } + } else if (portFmt->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (!venc_set_encode_framerate(portFmt->xFramerate, 0)) { + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoPortFormat""); + } + + break; + } + case OMX_IndexParamVideoBitrate: + { + OMX_VIDEO_PARAM_BITRATETYPE* pParam; + pParam = (OMX_VIDEO_PARAM_BITRATETYPE*)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoBitrate""); + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (!venc_set_target_bitrate(pParam->nTargetBitrate, 0)) { + DEBUG_PRINT_ERROR(""ERROR: Target Bit Rate setting failed""); + return false; + } + + if (!venc_set_ratectrl_cfg(pParam->eControlRate)) { + DEBUG_PRINT_ERROR(""ERROR: Rate Control setting failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoBitrate""); + } + + break; + } + case OMX_IndexParamVideoMpeg4: + { + OMX_VIDEO_PARAM_MPEG4TYPE* pParam; + OMX_U32 bFrames = 0; + + pParam = (OMX_VIDEO_PARAM_MPEG4TYPE*)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoMpeg4""); + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (!venc_set_voptiming_cfg(pParam->nTimeIncRes)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting vop_timing failed""); + return false; + } + + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level""); + return false; + } else { + if (pParam->eProfile == OMX_VIDEO_MPEG4ProfileAdvancedSimple) { + if (pParam->nBFrames) { + bFrames = pParam->nBFrames; + } + } else { + if (pParam->nBFrames) { + DEBUG_PRINT_ERROR(""Warning: B frames not supported""); + bFrames = 0; + } + } + } + + if (!venc_set_intra_period (pParam->nPFrames,bFrames)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting intra period failed""); + return false; + } + + if (!venc_set_multislice_cfg(OMX_IndexParamVideoMpeg4,pParam->nSliceHeaderSpacing)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating slice_config""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoMpeg4""); + } + + break; + } + case OMX_IndexParamVideoH263: + { + OMX_VIDEO_PARAM_H263TYPE* pParam = (OMX_VIDEO_PARAM_H263TYPE*)paramData; + DEBUG_PRINT_LOW(""venc_set_param: OMX_IndexParamVideoH263""); + OMX_U32 bFrames = 0; + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level""); + return false; + } + + if (pParam->nBFrames) + DEBUG_PRINT_ERROR(""WARNING: B frame not supported for H.263""); + + if (venc_set_intra_period (pParam->nPFrames, bFrames) == false) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting intra period failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoH263""); + } + + break; + } + case OMX_IndexParamVideoAvc: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoAvc""); + OMX_VIDEO_PARAM_AVCTYPE* pParam = (OMX_VIDEO_PARAM_AVCTYPE*)paramData; + OMX_U32 bFrames = 0; + + if (pParam->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + DEBUG_PRINT_LOW(""pParam->eProfile :%d ,pParam->eLevel %d"", + pParam->eProfile,pParam->eLevel); + + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (pParam->eProfile,pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level %d, %d"", + pParam->eProfile, pParam->eLevel); + return false; + } else { + if ((pParam->eProfile != OMX_VIDEO_AVCProfileBaseline) && + (pParam->eProfile != (OMX_VIDEO_AVCPROFILETYPE) QOMX_VIDEO_AVCProfileConstrainedBaseline)) { + if (pParam->nBFrames) { + bFrames = pParam->nBFrames; + } + } else { + if (pParam->nBFrames) { + DEBUG_PRINT_ERROR(""Warning: B frames not supported""); + bFrames = 0; + } + } + } + + if (!venc_set_intra_period (pParam->nPFrames, bFrames)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting intra period failed""); + return false; + } + + if (!venc_set_entropy_config (pParam->bEntropyCodingCABAC, pParam->nCabacInitIdc)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting Entropy failed""); + return false; + } + + if (!venc_set_inloop_filter (pParam->eLoopFilterMode)) { + DEBUG_PRINT_ERROR(""ERROR: Request for setting Inloop filter failed""); + return false; + } + + if (!venc_set_multislice_cfg(OMX_IndexParamVideoAvc, pParam->nSliceHeaderSpacing)) { + DEBUG_PRINT_ERROR(""WARNING: Unsuccessful in updating slice_config""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoAvc""); + } + + break; + } + case (OMX_INDEXTYPE)OMX_IndexParamVideoVp8: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoVp8""); + OMX_VIDEO_PARAM_VP8TYPE* pParam = (OMX_VIDEO_PARAM_VP8TYPE*)paramData; + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level %d, %d"", + pParam->eProfile, pParam->eLevel); + return false; + } + if(venc_set_vpx_error_resilience(pParam->bErrorResilientMode) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set vpx error resilience""); + return false; + } + if(!venc_set_ltrmode(1, 1)) { + DEBUG_PRINT_ERROR(""ERROR: Failed to enable ltrmode""); + return false; + } + + if (m_codec == OMX_VIDEO_CodingVP8) { + DEBUG_PRINT_LOW(""Disable Hier-P as LTR is being set""); + if (!venc_set_hier_layers(QOMX_HIERARCHICALCODING_P, 0)) { + DEBUG_PRINT_ERROR(""Disabling Hier P count failed""); + } + } + + break; + } + case (OMX_INDEXTYPE)OMX_IndexParamVideoHevc: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoHevc""); + OMX_VIDEO_PARAM_HEVCTYPE* pParam = (OMX_VIDEO_PARAM_HEVCTYPE*)paramData; + if (!venc_set_profile_level (pParam->eProfile, pParam->eLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Unsuccessful in updating Profile and level %d, %d"", + pParam->eProfile, pParam->eLevel); + return false; + } + if (!venc_set_inloop_filter(OMX_VIDEO_AVCLoopFilterEnable)) + DEBUG_PRINT_HIGH(""WARN: Request for setting Inloop filter failed for HEVC encoder""); + + break; + } + case OMX_IndexParamVideoIntraRefresh: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoIntraRefresh""); + OMX_VIDEO_PARAM_INTRAREFRESHTYPE *intra_refresh = + (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)paramData; + + if (intra_refresh->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (venc_set_intra_refresh(intra_refresh->eRefreshMode, intra_refresh->nCirMBs) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting Intra refresh failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoIntraRefresh""); + } + + break; + } + case OMX_IndexParamVideoErrorCorrection: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoErrorCorrection""); + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *error_resilience = + (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)paramData; + + if (error_resilience->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (venc_set_error_resilience(error_resilience) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting Intra refresh failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoErrorCorrection""); + } + + break; + } + case OMX_IndexParamVideoProfileLevelCurrent: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoProfileLevelCurrent""); + OMX_VIDEO_PARAM_PROFILELEVELTYPE *profile_level = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)paramData; + + if (profile_level->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + m_profile_set = false; + m_level_set = false; + + if (!venc_set_profile_level (profile_level->eProfile, + profile_level->eLevel)) { + DEBUG_PRINT_ERROR(""WARNING: Unsuccessful in updating Profile and level""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoProfileLevelCurrent""); + } + + break; + } + case OMX_IndexParamVideoQuantization: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_IndexParamVideoQuantization""); + OMX_VIDEO_PARAM_QUANTIZATIONTYPE *session_qp = + (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)paramData; + if (session_qp->nPortIndex == (OMX_U32) PORT_INDEX_OUT) { + if (venc_set_session_qp (session_qp->nQpI, + session_qp->nQpP, + session_qp->nQpB) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting Session QP failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_IndexParamVideoQuantization""); + } + + break; + } + case QOMX_IndexParamVideoInitialQp: + { + QOMX_EXTNINDEX_VIDEO_INITIALQP * initqp = + (QOMX_EXTNINDEX_VIDEO_INITIALQP *)paramData; + if (initqp->bEnableInitQp) { + DEBUG_PRINT_LOW(""Enable initial QP: %d"", (int)initqp->bEnableInitQp); + if(venc_enable_initial_qp(initqp) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to enable initial QP""); + return OMX_ErrorUnsupportedSetting; + } + } else + DEBUG_PRINT_ERROR(""ERROR: setting QOMX_IndexParamVideoEnableInitialQp""); + break; + } + case OMX_QcomIndexParamVideoQPRange: + { + DEBUG_PRINT_LOW(""venc_set_param:OMX_QcomIndexParamVideoQPRange""); + OMX_QCOM_VIDEO_PARAM_QPRANGETYPE *session_qp_range = + (OMX_QCOM_VIDEO_PARAM_QPRANGETYPE *)paramData; + + if(session_qp_range->nPortIndex == (OMX_U32)PORT_INDEX_OUT) { + if(venc_set_session_qp_range (session_qp_range->minQP, + session_qp_range->maxQP) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting QP Range[%u %u] failed"", + (unsigned int)session_qp_range->minQP, (unsigned int)session_qp_range->maxQP); + return false; + } else { + session_qp_values.minqp = session_qp_range->minQP; + session_qp_values.maxqp = session_qp_range->maxQP; + } + } else { + DEBUG_PRINT_ERROR(""ERROR: Invalid Port Index for OMX_QcomIndexParamVideoQPRange""); + } + + break; + } + case OMX_QcomIndexEnableSliceDeliveryMode: + { + QOMX_EXTNINDEX_PARAMTYPE* pParam = + (QOMX_EXTNINDEX_PARAMTYPE*)paramData; + + if (pParam->nPortIndex == PORT_INDEX_OUT) { + if (venc_set_slice_delivery_mode(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""Setting slice delivery mode failed""); + return OMX_ErrorUnsupportedSetting; + } + } else { + DEBUG_PRINT_ERROR(""OMX_QcomIndexEnableSliceDeliveryMode "" + ""called on wrong port(%u)"", (unsigned int)pParam->nPortIndex); + return OMX_ErrorBadPortIndex; + } + + break; + } + case OMX_ExtraDataVideoEncoderSliceInfo: + { + DEBUG_PRINT_LOW(""venc_set_param: OMX_ExtraDataVideoEncoderSliceInfo""); + OMX_BOOL extra_data = *(OMX_BOOL *)(paramData); + + if (venc_set_extradata(OMX_ExtraDataVideoEncoderSliceInfo, extra_data) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting OMX_ExtraDataVideoEncoderSliceInfo failed""); + return false; + } + + extradata = true; + break; + } + case OMX_ExtraDataVideoEncoderMBInfo: + { + DEBUG_PRINT_LOW(""venc_set_param: OMX_ExtraDataVideoEncoderMBInfo""); + OMX_BOOL extra_data = *(OMX_BOOL *)(paramData); + + if (venc_set_extradata(OMX_ExtraDataVideoEncoderMBInfo, extra_data) == false) { + DEBUG_PRINT_ERROR(""ERROR: Setting OMX_ExtraDataVideoEncoderMBInfo failed""); + return false; + } + + extradata = true; + break; + } + case OMX_QcomIndexParamSequenceHeaderWithIDR: + { + PrependSPSPPSToIDRFramesParams * pParam = + (PrependSPSPPSToIDRFramesParams *)paramData; + + DEBUG_PRINT_LOW(""set inband sps/pps: %d"", pParam->bEnable); + if(venc_set_inband_video_header(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""ERROR: set inband sps/pps failed""); + return OMX_ErrorUnsupportedSetting; + } + + break; + } + case OMX_QcomIndexParamH264AUDelimiter: + { + OMX_QCOM_VIDEO_CONFIG_H264_AUD * pParam = + (OMX_QCOM_VIDEO_CONFIG_H264_AUD *)paramData; + + DEBUG_PRINT_LOW(""set AU delimiters: %d"", pParam->bEnable); + if(venc_set_au_delimiter(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""ERROR: set H264 AU delimiter failed""); + return OMX_ErrorUnsupportedSetting; + } + + break; + } + case OMX_QcomIndexHierarchicalStructure: + { + QOMX_VIDEO_HIERARCHICALLAYERS* pParam = + (QOMX_VIDEO_HIERARCHICALLAYERS*)paramData; + + if (pParam->nPortIndex == PORT_INDEX_OUT) { + if (!venc_set_hier_layers(pParam->eHierarchicalCodingType, pParam->nNumLayers)) { + DEBUG_PRINT_ERROR(""Setting Hier P count failed""); + return false; + } + } else { + DEBUG_PRINT_ERROR(""OMX_QcomIndexHierarchicalStructure called on wrong port(%d)"", (int)pParam->nPortIndex); + return false; + } + + if (m_codec == OMX_VIDEO_CodingVP8) { + DEBUG_PRINT_LOW(""Disable LTR as HIER-P is being set""); + if(!venc_set_ltrmode(0, 1)) { + DEBUG_PRINT_ERROR(""ERROR: Failed to disable ltrmode""); + } + } + break; + } + case OMX_QcomIndexParamPerfLevel: + { + OMX_QCOM_VIDEO_PARAM_PERF_LEVEL *pParam = + (OMX_QCOM_VIDEO_PARAM_PERF_LEVEL *)paramData; + DEBUG_PRINT_LOW(""Set perf level: %d"", pParam->ePerfLevel); + if(!venc_set_perf_level(pParam->ePerfLevel)) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set perf level to %d"", pParam->ePerfLevel); + return false; + } else { + performance_level.perflevel = (unsigned int) pParam->ePerfLevel; + } + break; + } + case OMX_QcomIndexParamH264VUITimingInfo: + { + OMX_QCOM_VIDEO_PARAM_VUI_TIMING_INFO *pParam = + (OMX_QCOM_VIDEO_PARAM_VUI_TIMING_INFO *)paramData; + DEBUG_PRINT_LOW(""Set VUI timing info: %d"", pParam->bEnable); + if(venc_set_vui_timing_info(pParam->bEnable) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set vui timing info to %d"", pParam->bEnable); + return false; + } else { + vui_timing_info.enabled = (unsigned int) pParam->bEnable; + } + break; + } + case OMX_QcomIndexParamPeakBitrate: + { + OMX_QCOM_VIDEO_PARAM_PEAK_BITRATE *pParam = + (OMX_QCOM_VIDEO_PARAM_PEAK_BITRATE *)paramData; + DEBUG_PRINT_LOW(""Set peak bitrate: %u"", (unsigned int)pParam->nPeakBitrate); + if(venc_set_peak_bitrate(pParam->nPeakBitrate) == false) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set peak bitrate to %u"", (unsigned int)pParam->nPeakBitrate); + return false; + } else { + peak_bitrate.peakbitrate = (unsigned int) pParam->nPeakBitrate; + } + break; + } + case OMX_QcomIndexParamSetMVSearchrange: + { + DEBUG_PRINT_LOW(""venc_set_config: OMX_QcomIndexParamSetMVSearchrange""); + is_searchrange_set = true; + if (!venc_set_searchrange()) { + DEBUG_PRINT_ERROR(""ERROR: Failed to set search range""); + return false; + } + } + break; + case OMX_QcomIndexParamVideoLTRCount: + { + DEBUG_PRINT_LOW(""venc_set_param: OMX_QcomIndexParamVideoLTRCount""); + OMX_QCOM_VIDEO_PARAM_LTRCOUNT_TYPE* pParam = + (OMX_QCOM_VIDEO_PARAM_LTRCOUNT_TYPE*)paramData; + if (pParam->nCount > 0) { + if (venc_set_ltrmode(1, pParam->nCount) == false) { + DEBUG_PRINT_ERROR(""ERROR: Enable LTR mode failed""); + return false; + } + } else { + if (venc_set_ltrmode(0, 0) == false) { + DEBUG_PRINT_ERROR(""ERROR: Disable LTR mode failed""); + return false; + } + } + break; + } + case OMX_QcomIndexParamVideoHybridHierpMode: + { + QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE* pParam = + (QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE*)paramData; + + if (!venc_set_hybrid_hierp(pParam->nHpLayers)) { + DEBUG_PRINT_ERROR(""Setting hybrid Hier-P mode failed""); + return OMX_ErrorUnsupportedSetting; + } + break; + } + case OMX_IndexParamVideoSliceFMO: + default: + DEBUG_PRINT_ERROR(""ERROR: Unsupported parameter in venc_set_param: %u"", + index); + break; + } + + return true; +} +","@@ -681,6 +681,11 @@ + + + int venc_dev::venc_output_log_buffers(const char *buffer_addr, int buffer_len) + { ++ if (venc_handle->is_secure_session()) { ++ DEBUG_PRINT_ERROR(""logging secure output buffers is not allowed!""); ++ return -1; ++ } ++ + if (!m_debug.outfile) { + int size = 0; + if(m_sVenc_cfg.codectype == V4L2_PIX_FMT_MPEG4) { +@@ -764,6 +769,11 @@ + + } + + int venc_dev::venc_input_log_buffers(OMX_BUFFERHEADERTYPE *pbuffer, int fd, int plane_offset) { ++ if (venc_handle->is_secure_session()) { ++ DEBUG_PRINT_ERROR(""logging secure input buffers is not allowed!""); ++ return -1; ++ } ++ + if (!m_debug.infile) { + int size = snprintf(m_debug.infile_name, PROPERTY_VALUE_MAX, ""%s/input_enc_%lu_%lu_%p.yuv"", + m_debug.log_loc, m_sVenc_cfg.input_width, m_sVenc_cfg.input_height, this); +",5612,5848,6144 +17620,"IHEVCD_ERROR_T ihevcd_parse_coding_unit(codec_t *ps_codec, + WORD32 x0, + WORD32 y0, + WORD32 log2_cb_size) +{ + IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; + sps_t *ps_sps; + pps_t *ps_pps; + WORD32 cb_size; + slice_header_t *ps_slice_hdr; + WORD32 skip_flag; + WORD32 pcm_flag; + UWORD32 *pu4_skip_top = ps_codec->s_parse.pu4_skip_cu_top; + UWORD32 u4_skip_left = ps_codec->s_parse.u4_skip_cu_left; + bitstrm_t *ps_bitstrm = &ps_codec->s_parse.s_bitstrm; + tu_t *ps_tu = ps_codec->s_parse.ps_tu; + + WORD32 cu_pos_x; + WORD32 cu_pos_y; + cab_ctxt_t *ps_cabac = &ps_codec->s_parse.s_cabac; + + ASSERT(0 == (x0 % 8)); + ASSERT(0 == (y0 % 8)); + + ps_codec->s_parse.s_cu.i4_tu_cnt = 0; + ps_sps = ps_codec->s_parse.ps_sps; + ps_pps = ps_codec->s_parse.ps_pps; + + cu_pos_x = ps_codec->s_parse.s_cu.i4_pos_x; + cu_pos_y = ps_codec->s_parse.s_cu.i4_pos_y; + + + + ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr; + + + cb_size = 1 << log2_cb_size; + + ps_codec->s_parse.s_cu.i4_cu_transquant_bypass = 0; + + if(ps_pps->i1_transquant_bypass_enable_flag) + { + TRACE_CABAC_CTXT(""cu_transquant_bypass_flag"", ps_cabac->u4_range, IHEVC_CAB_CU_TQ_BYPASS_FLAG); + ps_codec->s_parse.s_cu.i4_cu_transquant_bypass = + ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, + IHEVC_CAB_CU_TQ_BYPASS_FLAG); + /* Update transquant_bypass in ps_tu */ + + AEV_TRACE(""cu_transquant_bypass_flag"", ps_codec->s_parse.s_cu.i4_cu_transquant_bypass, + ps_cabac->u4_range); + + if(ps_codec->s_parse.s_cu.i4_cu_transquant_bypass) + { + UWORD8 *pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag; + UWORD32 u4_mask; + WORD32 i; + WORD32 numbytes_row; + numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) / 64; + pu1_pic_no_loop_filter_flag += (y0 / 8) * numbytes_row; + pu1_pic_no_loop_filter_flag += (x0 / 64); + + /* Generate (cb_size / 8) number of 1s */ + /* i.e (log2_cb_size - 2) number of 1s */ + u4_mask = LSB_ONES((cb_size >> 3)); + for(i = 0; i < (cb_size / 8); i++) + { + *pu1_pic_no_loop_filter_flag |= (u4_mask << (((x0) / 8) % 8)); + pu1_pic_no_loop_filter_flag += numbytes_row; + } + } + } + + { + UWORD32 u4_skip_top = 0; + UWORD32 u4_mask; + UWORD32 u4_top_mask, u4_left_mask; + UWORD32 u4_min_cu_x = x0 / 8; + UWORD32 u4_min_cu_y = y0 / 8; + + pu4_skip_top += (u4_min_cu_x / 32); + + + if(ps_slice_hdr->i1_slice_type != ISLICE) + { + WORD32 ctx_idx_inc; + ctx_idx_inc = 0; + + if((0 != cu_pos_y) || + ((0 != ps_codec->s_parse.i4_ctb_slice_y) && + (0 != ps_codec->s_parse.i4_ctb_tile_y))) + { + u4_skip_top = *pu4_skip_top; + u4_skip_top >>= (u4_min_cu_x % 32); + if(u4_skip_top & 1) + ctx_idx_inc++; + } + + /*****************************************************************/ + /* If cu_pos_x is non-zero then left is available */ + /* If cu_pos_x is zero then ensure both the following are true */ + /* Current CTB is not the first CTB in a tile row */ + /* Current CTB is not the first CTB in a slice */ + /*****************************************************************/ + if((0 != cu_pos_x) || + (((0 != ps_codec->s_parse.i4_ctb_slice_x) || (0 != ps_codec->s_parse.i4_ctb_slice_y)) && + (0 != ps_codec->s_parse.i4_ctb_tile_x))) + { + u4_skip_left >>= (u4_min_cu_y % 32); + if(u4_skip_left & 1) + ctx_idx_inc++; + } + TRACE_CABAC_CTXT(""cu_skip_flag"", ps_cabac->u4_range, (IHEVC_CAB_SKIP_FLAG + ctx_idx_inc)); + skip_flag = ihevcd_cabac_decode_bin(ps_cabac, + ps_bitstrm, + (IHEVC_CAB_SKIP_FLAG + ctx_idx_inc)); + + AEV_TRACE(""cu_skip_flag"", skip_flag, ps_cabac->u4_range); + } + else + skip_flag = 0; + + /* Update top skip_flag */ + u4_skip_top = *pu4_skip_top; + /* Since Max cb_size is 64, maximum of 8 bits will be set or reset */ + /* Also since Coding block will be within 64x64 grid, only 8bits within a WORD32 + * need to be updated. These 8 bits will not cross 8 bit boundaries + */ + u4_mask = LSB_ONES(cb_size / 8); + u4_top_mask = u4_mask << (u4_min_cu_x % 32); + + + if(skip_flag) + { + u4_skip_top |= u4_top_mask; + } + else + { + u4_skip_top &= ~u4_top_mask; + } + *pu4_skip_top = u4_skip_top; + + /* Update left skip_flag */ + u4_skip_left = ps_codec->s_parse.u4_skip_cu_left; + u4_mask = LSB_ONES(cb_size / 8); + u4_left_mask = u4_mask << (u4_min_cu_y % 32); + + if(skip_flag) + { + u4_skip_left |= u4_left_mask; + } + else + { + u4_skip_left &= ~u4_left_mask; + } + ps_codec->s_parse.u4_skip_cu_left = u4_skip_left; + } + ps_codec->s_parse.i4_cu_pcm_flag = 0; + + if(skip_flag) + { + WORD32 ctb_x_base; + WORD32 ctb_y_base; + + ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size; + ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size; + + ps_tu->b1_cb_cbf = 0; + ps_tu->b1_cr_cbf = 0; + ps_tu->b1_y_cbf = 0; + ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2); + ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2); + ps_tu->b1_transquant_bypass = 0; + ps_tu->b3_size = (log2_cb_size - 2); + ps_tu->b7_qp = ps_codec->s_parse.u4_qp; + ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; + ps_tu->b6_luma_intra_mode = INTRA_PRED_NONE; + + /* Set the first TU in CU flag */ + { + if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) && + (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2)) + { + ps_tu->b1_first_tu_in_cu = 1; + } + else + { + ps_tu->b1_first_tu_in_cu = 0; + } + } + + ps_codec->s_parse.ps_tu++; + ps_codec->s_parse.s_cu.i4_tu_cnt++; + ps_codec->s_parse.i4_pic_tu_idx++; + + ps_codec->s_parse.s_cu.i4_pred_mode = PRED_MODE_SKIP; + ps_codec->s_parse.s_cu.i4_part_mode = PART_2Nx2N; + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ps_pu->b2_part_idx = 0; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size); + STATS_UPDATE_PU_SKIP_SIZE(ps_pu); + } + } + else + { + WORD32 pred_mode; + WORD32 part_mode; + WORD32 intra_split_flag; + WORD32 is_mincb; + cb_size = (1 << log2_cb_size); + is_mincb = (cb_size == (1 << ps_sps->i1_log2_min_coding_block_size)); + pcm_flag = 0; + if(ps_slice_hdr->i1_slice_type != ISLICE) + { + TRACE_CABAC_CTXT(""pred_mode_flag"", ps_cabac->u4_range, IHEVC_CAB_PRED_MODE); + pred_mode = ihevcd_cabac_decode_bin(ps_cabac, + ps_bitstrm, + IHEVC_CAB_PRED_MODE); + + AEV_TRACE(""pred_mode_flag"", pred_mode, ps_cabac->u4_range); + } + else + { + pred_mode = PRED_MODE_INTRA; + } + + /* If current CU is intra then set corresponging bit in picture level intra map */ + if(PRED_MODE_INTRA == pred_mode) + { + UWORD8 *pu1_pic_intra_flag = ps_codec->s_parse.pu1_pic_intra_flag; + UWORD32 u4_mask; + WORD32 i; + WORD32 numbytes_row; + numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) / 64; + pu1_pic_intra_flag += (y0 / 8) * numbytes_row; + pu1_pic_intra_flag += (x0 / 64); + + /* Generate (cb_size / 8) number of 1s */ + /* i.e (log2_cb_size - 2) number of 1s */ + u4_mask = LSB_ONES((cb_size >> 3)); + for(i = 0; i < (cb_size / 8); i++) + { + *pu1_pic_intra_flag |= (u4_mask << (((x0) / 8) % 8)); + pu1_pic_intra_flag += numbytes_row; + } + } + + ps_codec->s_parse.s_cu.i4_pred_mode = pred_mode; + intra_split_flag = 0; + if((PRED_MODE_INTRA != pred_mode) || + is_mincb) + { + UWORD32 bin; + if(PRED_MODE_INTRA == pred_mode) + { + TRACE_CABAC_CTXT(""part_mode"", ps_cabac->u4_range, IHEVC_CAB_PART_MODE); + bin = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, IHEVC_CAB_PART_MODE); + part_mode = (bin) ? PART_2Nx2N : PART_NxN; + } + else + { + WORD32 amp_enabled = ps_sps->i1_amp_enabled_flag; + + UWORD32 u4_max_bin_cnt = 0; + + + + if(amp_enabled && !is_mincb) + { + part_mode = ihevcd_parse_part_mode_amp(ps_cabac, ps_bitstrm); + } + else + { + WORD32 ctxt_inc = IHEVC_CAB_PART_MODE; + + u4_max_bin_cnt = 2; + if((is_mincb) && (cb_size > 8)) + { + u4_max_bin_cnt++; + } + + part_mode = -1; + TRACE_CABAC_CTXT(""part_mode"", ps_cabac->u4_range, IHEVC_CAB_PART_MODE); + do + { + bin = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, + ctxt_inc++); + part_mode++; + }while(--u4_max_bin_cnt && !bin); + + /* If the last bin was zero, then increment part mode by 1 */ + if(!bin) + part_mode++; + } + + + } + + AEV_TRACE(""part_mode"", part_mode, ps_cabac->u4_range); + + } + else + { + part_mode = 0; + intra_split_flag = 0; + } + ps_codec->s_parse.s_cu.i4_part_mode = part_mode; + + if((PRED_MODE_INTRA == ps_codec->s_parse.s_cu.i4_pred_mode) && + (PART_NxN == ps_codec->s_parse.s_cu.i4_part_mode)) + { + intra_split_flag = 1; + } + ps_codec->s_parse.s_cu.i4_part_mode = part_mode; + ps_codec->s_parse.s_cu.i4_intra_split_flag = intra_split_flag; + if(pred_mode == PRED_MODE_INTRA) + { + ps_codec->s_parse.i4_cu_pcm_flag = 0; + ihevcd_parse_coding_unit_intra(ps_codec, x0, y0, log2_cb_size); + pcm_flag = ps_codec->s_parse.i4_cu_pcm_flag; + + } + else + { + if(part_mode == PART_2Nx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size); + ps_pu->b2_part_idx = 0; + } + else if(part_mode == PART_2NxN) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size / 2); + ps_pu->b2_part_idx = 0; + + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size / 2), cb_size, cb_size / 2); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_Nx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size / 2, cb_size); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 2), y0, cb_size / 2, cb_size); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_2NxnU) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size / 4); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size / 4), cb_size, cb_size * 3 / 4); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_2NxnD) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size * 3 / 4); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size * 3 / 4), cb_size, cb_size / 4); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_nLx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size / 4, cb_size); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 4), y0, cb_size * 3 / 4, cb_size); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_nRx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size * 3 / 4, cb_size); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size * 3 / 4), y0, cb_size / 4, cb_size); + ps_pu->b2_part_idx = 1; + } + else + { /* PART_NxN */ + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size / 2, cb_size / 2); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 2), y0, cb_size / 2, cb_size / 2); + + ps_pu->b2_part_idx = 1; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size / 2), cb_size / 2, cb_size / 2); + + ps_pu->b2_part_idx = 2; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 2), y0 + (cb_size / 2), cb_size / 2, cb_size / 2); + + ps_pu->b2_part_idx = 3; + } + } + + if(!pcm_flag) + { + WORD32 no_residual_syntax_flag = 0; + pu_t *ps_pu; + /* Since ps_pu is incremented for each PU parsed, decrement by 1 to + * access last decoded PU + */ + ps_pu = ps_codec->s_parse.ps_pu - 1; + if((PRED_MODE_INTRA != pred_mode) && + (!((part_mode == PART_2Nx2N) && ps_pu->b1_merge_flag))) + { + + TRACE_CABAC_CTXT(""rqt_root_cbf"", ps_cabac->u4_range, IHEVC_CAB_NORES_IDX); + no_residual_syntax_flag = ihevcd_cabac_decode_bin(ps_cabac, + ps_bitstrm, + IHEVC_CAB_NORES_IDX); + + AEV_TRACE(""rqt_root_cbf"", no_residual_syntax_flag, + ps_cabac->u4_range); + /* TODO: HACK FOR COMPLIANCE WITH HM REFERENCE DECODER */ + /*********************************************************/ + /* currently the HM decoder expects qtroot cbf instead of */ + /* no_residue_flag which has opposite meaning */ + /* This will be fixed once the software / spec is fixed */ + /*********************************************************/ + no_residual_syntax_flag = 1 - no_residual_syntax_flag; + } + + if(!no_residual_syntax_flag) + { + + ps_codec->s_parse.s_cu.i4_max_trafo_depth = (pred_mode == PRED_MODE_INTRA) ? + (ps_sps->i1_max_transform_hierarchy_depth_intra + intra_split_flag) : + (ps_sps->i1_max_transform_hierarchy_depth_inter); + ret = ihevcd_parse_transform_tree(ps_codec, x0, y0, x0, y0, + log2_cb_size, 0, 0, + ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]); + RETURN_IF((IHEVCD_ERROR_T)IHEVCD_SUCCESS != ret, ret); + } + else + { + WORD32 ctb_x_base; + WORD32 ctb_y_base; + + ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size; + ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size; + + ps_tu = ps_codec->s_parse.ps_tu; + ps_tu->b1_cb_cbf = 0; + ps_tu->b1_cr_cbf = 0; + ps_tu->b1_y_cbf = 0; + ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2); + ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2); + ps_tu->b1_transquant_bypass = 0; + ps_tu->b3_size = (log2_cb_size - 2); + ps_tu->b7_qp = ps_codec->s_parse.u4_qp; + ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; + ps_tu->b6_luma_intra_mode = ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]; + + /* Set the first TU in CU flag */ + { + if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) && + (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2)) + { + ps_tu->b1_first_tu_in_cu = 1; + } + else + { + ps_tu->b1_first_tu_in_cu = 0; + } + } + ps_codec->s_parse.ps_tu++; + ps_codec->s_parse.s_cu.i4_tu_cnt++; + ps_codec->s_parse.i4_pic_tu_idx++; + + } + } + + } + + + + + return ret; +} +",0,"IHEVCD_ERROR_T ihevcd_parse_coding_unit(codec_t *ps_codec, + WORD32 x0, + WORD32 y0, + WORD32 log2_cb_size) +{ + IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; + sps_t *ps_sps; + pps_t *ps_pps; + WORD32 cb_size; + slice_header_t *ps_slice_hdr; + WORD32 skip_flag; + WORD32 pcm_flag; + UWORD32 *pu4_skip_top = ps_codec->s_parse.pu4_skip_cu_top; + UWORD32 u4_skip_left = ps_codec->s_parse.u4_skip_cu_left; + bitstrm_t *ps_bitstrm = &ps_codec->s_parse.s_bitstrm; + tu_t *ps_tu = ps_codec->s_parse.ps_tu; + + WORD32 cu_pos_x; + WORD32 cu_pos_y; + cab_ctxt_t *ps_cabac = &ps_codec->s_parse.s_cabac; + + ASSERT(0 == (x0 % 8)); + ASSERT(0 == (y0 % 8)); + + ps_codec->s_parse.s_cu.i4_tu_cnt = 0; + ps_sps = ps_codec->s_parse.ps_sps; + ps_pps = ps_codec->s_parse.ps_pps; + + cu_pos_x = ps_codec->s_parse.s_cu.i4_pos_x; + cu_pos_y = ps_codec->s_parse.s_cu.i4_pos_y; + + + + ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr; + + + cb_size = 1 << log2_cb_size; + + ps_codec->s_parse.s_cu.i4_cu_transquant_bypass = 0; + + if(ps_pps->i1_transquant_bypass_enable_flag) + { + TRACE_CABAC_CTXT(""cu_transquant_bypass_flag"", ps_cabac->u4_range, IHEVC_CAB_CU_TQ_BYPASS_FLAG); + ps_codec->s_parse.s_cu.i4_cu_transquant_bypass = + ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, + IHEVC_CAB_CU_TQ_BYPASS_FLAG); + /* Update transquant_bypass in ps_tu */ + + AEV_TRACE(""cu_transquant_bypass_flag"", ps_codec->s_parse.s_cu.i4_cu_transquant_bypass, + ps_cabac->u4_range); + + if(ps_codec->s_parse.s_cu.i4_cu_transquant_bypass) + { + UWORD8 *pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag; + UWORD32 u4_mask; + WORD32 i; + WORD32 numbytes_row; + numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) / 64; + pu1_pic_no_loop_filter_flag += (y0 / 8) * numbytes_row; + pu1_pic_no_loop_filter_flag += (x0 / 64); + + /* Generate (cb_size / 8) number of 1s */ + /* i.e (log2_cb_size - 2) number of 1s */ + u4_mask = LSB_ONES((cb_size >> 3)); + for(i = 0; i < (cb_size / 8); i++) + { + *pu1_pic_no_loop_filter_flag |= (u4_mask << (((x0) / 8) % 8)); + pu1_pic_no_loop_filter_flag += numbytes_row; + } + } + } + + { + UWORD32 u4_skip_top = 0; + UWORD32 u4_mask; + UWORD32 u4_top_mask, u4_left_mask; + UWORD32 u4_min_cu_x = x0 / 8; + UWORD32 u4_min_cu_y = y0 / 8; + + pu4_skip_top += (u4_min_cu_x / 32); + + + if(ps_slice_hdr->i1_slice_type != ISLICE) + { + WORD32 ctx_idx_inc; + ctx_idx_inc = 0; + + if((0 != cu_pos_y) || + ((0 != ps_codec->s_parse.i4_ctb_slice_y) && + (0 != ps_codec->s_parse.i4_ctb_tile_y))) + { + u4_skip_top = *pu4_skip_top; + u4_skip_top >>= (u4_min_cu_x % 32); + if(u4_skip_top & 1) + ctx_idx_inc++; + } + + /*****************************************************************/ + /* If cu_pos_x is non-zero then left is available */ + /* If cu_pos_x is zero then ensure both the following are true */ + /* Current CTB is not the first CTB in a tile row */ + /* Current CTB is not the first CTB in a slice */ + /*****************************************************************/ + if((0 != cu_pos_x) || + (((0 != ps_codec->s_parse.i4_ctb_slice_x) || (0 != ps_codec->s_parse.i4_ctb_slice_y)) && + (0 != ps_codec->s_parse.i4_ctb_tile_x))) + { + u4_skip_left >>= (u4_min_cu_y % 32); + if(u4_skip_left & 1) + ctx_idx_inc++; + } + TRACE_CABAC_CTXT(""cu_skip_flag"", ps_cabac->u4_range, (IHEVC_CAB_SKIP_FLAG + ctx_idx_inc)); + skip_flag = ihevcd_cabac_decode_bin(ps_cabac, + ps_bitstrm, + (IHEVC_CAB_SKIP_FLAG + ctx_idx_inc)); + + AEV_TRACE(""cu_skip_flag"", skip_flag, ps_cabac->u4_range); + } + else + skip_flag = 0; + + /* Update top skip_flag */ + u4_skip_top = *pu4_skip_top; + /* Since Max cb_size is 64, maximum of 8 bits will be set or reset */ + /* Also since Coding block will be within 64x64 grid, only 8bits within a WORD32 + * need to be updated. These 8 bits will not cross 8 bit boundaries + */ + u4_mask = LSB_ONES(cb_size / 8); + u4_top_mask = u4_mask << (u4_min_cu_x % 32); + + + if(skip_flag) + { + u4_skip_top |= u4_top_mask; + } + else + { + u4_skip_top &= ~u4_top_mask; + } + *pu4_skip_top = u4_skip_top; + + /* Update left skip_flag */ + u4_skip_left = ps_codec->s_parse.u4_skip_cu_left; + u4_mask = LSB_ONES(cb_size / 8); + u4_left_mask = u4_mask << (u4_min_cu_y % 32); + + if(skip_flag) + { + u4_skip_left |= u4_left_mask; + } + else + { + u4_skip_left &= ~u4_left_mask; + } + ps_codec->s_parse.u4_skip_cu_left = u4_skip_left; + } + ps_codec->s_parse.i4_cu_pcm_flag = 0; + + if(skip_flag) + { + WORD32 ctb_x_base; + WORD32 ctb_y_base; + + ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size; + ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size; + + ps_tu->b1_cb_cbf = 0; + ps_tu->b1_cr_cbf = 0; + ps_tu->b1_y_cbf = 0; + ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2); + ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2); + ps_tu->b1_transquant_bypass = 0; + ps_tu->b3_size = (log2_cb_size - 2); + ps_tu->b7_qp = ps_codec->s_parse.u4_qp; + ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; + ps_tu->b6_luma_intra_mode = INTRA_PRED_NONE; + + /* Set the first TU in CU flag */ + { + if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) && + (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2)) + { + ps_tu->b1_first_tu_in_cu = 1; + } + else + { + ps_tu->b1_first_tu_in_cu = 0; + } + } + + ps_codec->s_parse.ps_tu++; + ps_codec->s_parse.s_cu.i4_tu_cnt++; + ps_codec->s_parse.i4_pic_tu_idx++; + + ps_codec->s_parse.s_cu.i4_pred_mode = PRED_MODE_SKIP; + ps_codec->s_parse.s_cu.i4_part_mode = PART_2Nx2N; + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ps_pu->b2_part_idx = 0; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size); + STATS_UPDATE_PU_SKIP_SIZE(ps_pu); + } + } + else + { + WORD32 pred_mode; + WORD32 part_mode; + WORD32 intra_split_flag; + WORD32 is_mincb; + cb_size = (1 << log2_cb_size); + is_mincb = (cb_size == (1 << ps_sps->i1_log2_min_coding_block_size)); + pcm_flag = 0; + if(ps_slice_hdr->i1_slice_type != ISLICE) + { + TRACE_CABAC_CTXT(""pred_mode_flag"", ps_cabac->u4_range, IHEVC_CAB_PRED_MODE); + pred_mode = ihevcd_cabac_decode_bin(ps_cabac, + ps_bitstrm, + IHEVC_CAB_PRED_MODE); + + AEV_TRACE(""pred_mode_flag"", pred_mode, ps_cabac->u4_range); + } + else + { + pred_mode = PRED_MODE_INTRA; + } + + /* If current CU is intra then set corresponging bit in picture level intra map */ + if(PRED_MODE_INTRA == pred_mode) + { + UWORD8 *pu1_pic_intra_flag = ps_codec->s_parse.pu1_pic_intra_flag; + UWORD32 u4_mask; + WORD32 i; + WORD32 numbytes_row; + numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) / 64; + pu1_pic_intra_flag += (y0 / 8) * numbytes_row; + pu1_pic_intra_flag += (x0 / 64); + + /* Generate (cb_size / 8) number of 1s */ + /* i.e (log2_cb_size - 2) number of 1s */ + u4_mask = LSB_ONES((cb_size >> 3)); + for(i = 0; i < (cb_size / 8); i++) + { + *pu1_pic_intra_flag |= (u4_mask << (((x0) / 8) % 8)); + pu1_pic_intra_flag += numbytes_row; + } + } + + ps_codec->s_parse.s_cu.i4_pred_mode = pred_mode; + intra_split_flag = 0; + if((PRED_MODE_INTRA != pred_mode) || + is_mincb) + { + UWORD32 bin; + if(PRED_MODE_INTRA == pred_mode) + { + TRACE_CABAC_CTXT(""part_mode"", ps_cabac->u4_range, IHEVC_CAB_PART_MODE); + bin = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, IHEVC_CAB_PART_MODE); + part_mode = (bin) ? PART_2Nx2N : PART_NxN; + } + else + { + WORD32 amp_enabled = ps_sps->i1_amp_enabled_flag; + + UWORD32 u4_max_bin_cnt = 0; + + + + if(amp_enabled && !is_mincb) + { + part_mode = ihevcd_parse_part_mode_amp(ps_cabac, ps_bitstrm); + } + else + { + WORD32 ctxt_inc = IHEVC_CAB_PART_MODE; + + u4_max_bin_cnt = 2; + if((is_mincb) && (cb_size > 8)) + { + u4_max_bin_cnt++; + } + + part_mode = -1; + TRACE_CABAC_CTXT(""part_mode"", ps_cabac->u4_range, IHEVC_CAB_PART_MODE); + do + { + bin = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, + ctxt_inc++); + part_mode++; + }while(--u4_max_bin_cnt && !bin); + + /* If the last bin was zero, then increment part mode by 1 */ + if(!bin) + part_mode++; + } + + + } + + AEV_TRACE(""part_mode"", part_mode, ps_cabac->u4_range); + + } + else + { + part_mode = 0; + intra_split_flag = 0; + } + ps_codec->s_parse.s_cu.i4_part_mode = part_mode; + + if((PRED_MODE_INTRA == ps_codec->s_parse.s_cu.i4_pred_mode) && + (PART_NxN == ps_codec->s_parse.s_cu.i4_part_mode)) + { + intra_split_flag = 1; + } + ps_codec->s_parse.s_cu.i4_part_mode = part_mode; + ps_codec->s_parse.s_cu.i4_intra_split_flag = intra_split_flag; + if(pred_mode == PRED_MODE_INTRA) + { + ps_codec->s_parse.i4_cu_pcm_flag = 0; + ihevcd_parse_coding_unit_intra(ps_codec, x0, y0, log2_cb_size); + pcm_flag = ps_codec->s_parse.i4_cu_pcm_flag; + + } + else + { + if(part_mode == PART_2Nx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size); + ps_pu->b2_part_idx = 0; + } + else if(part_mode == PART_2NxN) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size / 2); + ps_pu->b2_part_idx = 0; + + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size / 2), cb_size, cb_size / 2); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_Nx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size / 2, cb_size); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 2), y0, cb_size / 2, cb_size); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_2NxnU) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size / 4); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size / 4), cb_size, cb_size * 3 / 4); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_2NxnD) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size * 3 / 4); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size * 3 / 4), cb_size, cb_size / 4); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_nLx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size / 4, cb_size); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 4), y0, cb_size * 3 / 4, cb_size); + + ps_pu->b2_part_idx = 1; + } + else if(part_mode == PART_nRx2N) + { + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size * 3 / 4, cb_size); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size * 3 / 4), y0, cb_size / 4, cb_size); + ps_pu->b2_part_idx = 1; + } + else + { /* PART_NxN */ + pu_t *ps_pu = ps_codec->s_parse.ps_pu; + + ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size / 2, cb_size / 2); + ps_pu->b2_part_idx = 0; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 2), y0, cb_size / 2, cb_size / 2); + + ps_pu->b2_part_idx = 1; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size / 2), cb_size / 2, cb_size / 2); + + ps_pu->b2_part_idx = 2; + ps_pu = ps_codec->s_parse.ps_pu; + ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size / 2), y0 + (cb_size / 2), cb_size / 2, cb_size / 2); + + ps_pu->b2_part_idx = 3; + } + } + + if(!pcm_flag) + { + WORD32 no_residual_syntax_flag = 0; + pu_t *ps_pu; + /* Since ps_pu is incremented for each PU parsed, decrement by 1 to + * access last decoded PU + */ + ps_pu = ps_codec->s_parse.ps_pu - 1; + if((PRED_MODE_INTRA != pred_mode) && + (!((part_mode == PART_2Nx2N) && ps_pu->b1_merge_flag))) + { + + TRACE_CABAC_CTXT(""rqt_root_cbf"", ps_cabac->u4_range, IHEVC_CAB_NORES_IDX); + no_residual_syntax_flag = ihevcd_cabac_decode_bin(ps_cabac, + ps_bitstrm, + IHEVC_CAB_NORES_IDX); + + AEV_TRACE(""rqt_root_cbf"", no_residual_syntax_flag, + ps_cabac->u4_range); + /* TODO: HACK FOR COMPLIANCE WITH HM REFERENCE DECODER */ + /*********************************************************/ + /* currently the HM decoder expects qtroot cbf instead of */ + /* no_residue_flag which has opposite meaning */ + /* This will be fixed once the software / spec is fixed */ + /*********************************************************/ + no_residual_syntax_flag = 1 - no_residual_syntax_flag; + } + + if(!no_residual_syntax_flag) + { + + ps_codec->s_parse.s_cu.i4_max_trafo_depth = (pred_mode == PRED_MODE_INTRA) ? + (ps_sps->i1_max_transform_hierarchy_depth_intra + intra_split_flag) : + (ps_sps->i1_max_transform_hierarchy_depth_inter); + ret = ihevcd_parse_transform_tree(ps_codec, x0, y0, x0, y0, + log2_cb_size, 0, 0, + ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]); + RETURN_IF((IHEVCD_ERROR_T)IHEVCD_SUCCESS != ret, ret); + } + else + { + WORD32 ctb_x_base; + WORD32 ctb_y_base; + + ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size; + ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size; + + ps_tu = ps_codec->s_parse.ps_tu; + ps_tu->b1_cb_cbf = 0; + ps_tu->b1_cr_cbf = 0; + ps_tu->b1_y_cbf = 0; + ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2); + ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2); + ps_tu->b1_transquant_bypass = 0; + ps_tu->b3_size = (log2_cb_size - 2); + ps_tu->b7_qp = ps_codec->s_parse.u4_qp; + ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; + ps_tu->b6_luma_intra_mode = ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]; + + /* Set the first TU in CU flag */ + { + if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) && + (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2)) + { + ps_tu->b1_first_tu_in_cu = 1; + } + else + { + ps_tu->b1_first_tu_in_cu = 0; + } + } + ps_codec->s_parse.ps_tu++; + ps_codec->s_parse.s_cu.i4_tu_cnt++; + ps_codec->s_parse.i4_pic_tu_idx++; + + } + } + + } + + + + + return ret; +} +","@@ -2177,6 +2177,98 @@ + + ******************************************************************************* + * + * @brief ++ * Set ctb skip ++ * ++ * @par Description: ++ * During error, sets tu and pu params of a ctb as skip. ++ * ++ * @param[in] ps_codec ++ * Pointer to codec context ++ * ++ * @returns None ++ * ++ * @remarks ++ * ++ * ++ ******************************************************************************* ++ */ ++void ihevcd_set_ctb_skip(codec_t *ps_codec) ++{ ++ tu_t *ps_tu; ++ pu_t *ps_pu; ++ sps_t *ps_sps = ps_codec->s_parse.ps_sps; ++ WORD32 ctb_size = 1 << ps_sps->i1_log2_ctb_size; ++ WORD32 ctb_skip_wd, ctb_skip_ht; ++ WORD32 rows_remaining, cols_remaining; ++ WORD32 tu_abs_x, tu_abs_y; ++ WORD32 numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) / 64; ++ UWORD8 *pu1_pic_intra_flag; ++ UWORD32 u4_mask; ++ WORD32 pu_x,pu_y; ++ ++ /* Set pu wd and ht based on whether the ctb is complete or not */ ++ rows_remaining = ps_sps->i2_pic_height_in_luma_samples ++ - (ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size); ++ ctb_skip_ht = MIN(ctb_size, rows_remaining); ++ ++ cols_remaining = ps_sps->i2_pic_width_in_luma_samples ++ - (ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size); ++ ctb_skip_wd = MIN(ctb_size, cols_remaining); ++ ++ ps_codec->s_parse.s_cu.i4_pred_mode = PRED_MODE_SKIP; ++ ps_codec->s_parse.s_cu.i4_part_mode = PART_2Nx2N; ++ ++ for (pu_y = 0; pu_y < ctb_skip_ht ; pu_y += MIN_CU_SIZE) ++ { ++ for (pu_x = 0; pu_x < ctb_skip_wd ; pu_x += MIN_CU_SIZE) ++ { ++ ps_tu = ps_codec->s_parse.ps_tu; ++ ps_tu->b1_cb_cbf = 0; ++ ps_tu->b1_cr_cbf = 0; ++ ps_tu->b1_y_cbf = 0; ++ ps_tu->b4_pos_x = pu_x >> 2; ++ ps_tu->b4_pos_y = pu_y >> 2; ++ ps_tu->b1_transquant_bypass = 0; ++ ps_tu->b3_size = 1; ++ ps_tu->b7_qp = ps_codec->s_parse.u4_qp; ++ ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; ++ ps_tu->b6_luma_intra_mode = INTRA_PRED_NONE; ++ ps_tu->b1_first_tu_in_cu = 1; ++ ++ ps_codec->s_parse.ps_tu++; ++ ps_codec->s_parse.s_cu.i4_tu_cnt++; ++ ps_codec->s_parse.i4_pic_tu_idx++; ++ ++ tu_abs_x = (ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size) + pu_x; ++ tu_abs_y = (ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size) + pu_y; ++ pu1_pic_intra_flag = ps_codec->s_parse.pu1_pic_intra_flag; ++ pu1_pic_intra_flag += (tu_abs_y >> 3) * numbytes_row; ++ pu1_pic_intra_flag += (tu_abs_x >> 6); ++ u4_mask = (LSB_ONES((MIN_CU_SIZE >> 3)) << (((tu_abs_x) / 8) % 8)); ++ u4_mask = ~u4_mask; ++ *pu1_pic_intra_flag &= u4_mask; ++ ++ ps_pu = ps_codec->s_parse.ps_pu; ++ ps_pu->b2_part_idx = 0; ++ ps_pu->b4_pos_x = pu_x >> 2; ++ ps_pu->b4_pos_y = pu_y >> 2; ++ ps_pu->b4_wd = 1; ++ ps_pu->b4_ht = 1; ++ ps_pu->b1_intra_flag = 0; ++ ps_pu->b3_part_mode = ps_codec->s_parse.s_cu.i4_part_mode; ++ ps_pu->b1_merge_flag = 1; ++ ps_pu->b3_merge_idx = 0; ++ ++ ps_codec->s_parse.ps_pu++; ++ ps_codec->s_parse.i4_pic_pu_idx++; ++ } ++ } ++} ++ ++/** ++ ******************************************************************************* ++ * ++ * @brief + * Parses Slice data syntax + * + * @par Description: +@@ -2640,19 +2732,8 @@ + + if (ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS) + { + /* Reset tu and pu parameters, and signal current ctb as skip */ +- WORD32 pu_skip_wd, pu_skip_ht; +- WORD32 rows_remaining, cols_remaining; + WORD32 tu_coeff_data_reset_size; + +- /* Set pu wd and ht based on whether the ctb is complete or not */ +- rows_remaining = ps_sps->i2_pic_height_in_luma_samples +- - (ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size); +- pu_skip_ht = MIN(ctb_size, rows_remaining); +- +- cols_remaining = ps_sps->i2_pic_width_in_luma_samples +- - (ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size); +- pu_skip_wd = MIN(ctb_size, cols_remaining); +- + ps_codec->s_parse.ps_tu = ps_tu; + ps_codec->s_parse.s_cu.i4_tu_cnt = i4_tu_cnt; + ps_codec->s_parse.i4_pic_tu_idx = i4_pic_tu_idx; +@@ -2660,41 +2741,11 @@ + + ps_codec->s_parse.ps_pu = ps_pu; + ps_codec->s_parse.i4_pic_pu_idx = i4_pic_pu_idx; + +- ps_tu->b1_cb_cbf = 0; +- ps_tu->b1_cr_cbf = 0; +- ps_tu->b1_y_cbf = 0; +- ps_tu->b4_pos_x = 0; +- ps_tu->b4_pos_y = 0; +- ps_tu->b1_transquant_bypass = 0; +- ps_tu->b3_size = (ps_sps->i1_log2_ctb_size - 2); +- ps_tu->b7_qp = ps_codec->s_parse.u4_qp; +- ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; +- ps_tu->b6_luma_intra_mode = INTRA_PRED_NONE; +- ps_tu->b1_first_tu_in_cu = 1; +- + tu_coeff_data_reset_size = (UWORD8 *)ps_codec->s_parse.pv_tu_coeff_data - pu1_tu_coeff_data; + memset(pu1_tu_coeff_data, 0, tu_coeff_data_reset_size); + ps_codec->s_parse.pv_tu_coeff_data = (void *)pu1_tu_coeff_data; + +- ps_codec->s_parse.ps_tu++; +- ps_codec->s_parse.s_cu.i4_tu_cnt++; +- ps_codec->s_parse.i4_pic_tu_idx++; +- +- ps_codec->s_parse.s_cu.i4_pred_mode = PRED_MODE_SKIP; +- ps_codec->s_parse.s_cu.i4_part_mode = PART_2Nx2N; +- +- ps_pu->b2_part_idx = 0; +- ps_pu->b4_pos_x = 0; +- ps_pu->b4_pos_y = 0; +- ps_pu->b4_wd = (pu_skip_wd >> 2) - 1; +- ps_pu->b4_ht = (pu_skip_ht >> 2) - 1; +- ps_pu->b1_intra_flag = 0; +- ps_pu->b3_part_mode = ps_codec->s_parse.s_cu.i4_part_mode; +- ps_pu->b1_merge_flag = 1; +- ps_pu->b3_merge_idx = 0; +- +- ps_codec->s_parse.ps_pu++; +- ps_codec->s_parse.i4_pic_pu_idx++; ++ ihevcd_set_ctb_skip(ps_codec); + + /* Set slice error to suppress further parsing and + * signal end of slice. +@@ -2706,52 +2757,7 @@ + + } + else + { +- tu_t *ps_tu = ps_codec->s_parse.ps_tu; +- pu_t *ps_pu = ps_codec->s_parse.ps_pu; +- WORD32 pu_skip_wd, pu_skip_ht; +- WORD32 rows_remaining, cols_remaining; +- +- /* Set pu wd and ht based on whether the ctb is complete or not */ +- rows_remaining = ps_sps->i2_pic_height_in_luma_samples +- - (ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size); +- pu_skip_ht = MIN(ctb_size, rows_remaining); +- +- cols_remaining = ps_sps->i2_pic_width_in_luma_samples +- - (ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size); +- pu_skip_wd = MIN(ctb_size, cols_remaining); +- +- ps_tu->b1_cb_cbf = 0; +- ps_tu->b1_cr_cbf = 0; +- ps_tu->b1_y_cbf = 0; +- ps_tu->b4_pos_x = 0; +- ps_tu->b4_pos_y = 0; +- ps_tu->b1_transquant_bypass = 0; +- ps_tu->b3_size = (ps_sps->i1_log2_ctb_size - 2); +- ps_tu->b7_qp = ps_codec->s_parse.u4_qp; +- ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; +- ps_tu->b6_luma_intra_mode = INTRA_PRED_NONE; +- ps_tu->b1_first_tu_in_cu = 1; +- +- ps_codec->s_parse.ps_tu++; +- ps_codec->s_parse.s_cu.i4_tu_cnt++; +- ps_codec->s_parse.i4_pic_tu_idx++; +- +- ps_codec->s_parse.s_cu.i4_pred_mode = PRED_MODE_SKIP; +- ps_codec->s_parse.s_cu.i4_part_mode = PART_2Nx2N; +- +- ps_pu->b2_part_idx = 0; +- ps_pu->b4_pos_x = 0; +- ps_pu->b4_pos_y = 0; +- ps_pu->b4_wd = (pu_skip_wd >> 2) - 1; +- ps_pu->b4_ht = (pu_skip_ht >> 2) - 1; +- ps_pu->b1_intra_flag = 0; +- ps_pu->b3_part_mode = ps_codec->s_parse.s_cu.i4_part_mode; +- ps_pu->b1_merge_flag = 1; +- ps_pu->b3_merge_idx = 0; +- +- ps_codec->s_parse.ps_pu++; +- ps_codec->s_parse.i4_pic_pu_idx++; +- ++ ihevcd_set_ctb_skip(ps_codec); + } + + if(0 == ps_codec->i4_slice_error) +",5006,5242,6144 +17978,"int ssl3_accept(SSL *s) + { + BUF_MEM *buf; + unsigned long alg_k,Time=(unsigned long)time(NULL); + void (*cb)(const SSL *ssl,int type,int val)=NULL; + int ret= -1; + int new_state,state,skip=0; + + RAND_add(&Time,sizeof(Time),0); + ERR_clear_error(); + clear_sys_error(); + + if (s->info_callback != NULL) + cb=s->info_callback; + else if (s->ctx->info_callback != NULL) + cb=s->ctx->info_callback; + + /* init things to blank */ + s->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); + + if (s->cert == NULL) + { + SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_NO_CERTIFICATE_SET); + return(-1); + } + +#ifndef OPENSSL_NO_HEARTBEATS + /* If we're awaiting a HeartbeatResponse, pretend we + * already got and don't await it anymore, because + * Heartbeats don't make sense during handshakes anyway. + */ + if (s->tlsext_hb_pending) + { + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + for (;;) + { + state=s->state; + + switch (s->state) + { + case SSL_ST_RENEGOTIATE: + s->renegotiate=1; + /* s->state=SSL_ST_ACCEPT; */ + + case SSL_ST_BEFORE: + case SSL_ST_ACCEPT: + case SSL_ST_BEFORE|SSL_ST_ACCEPT: + case SSL_ST_OK|SSL_ST_ACCEPT: + + s->server=1; + if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); + + if ((s->version>>8) != 3) + { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + return -1; + } + + if (!ssl_security(s, SSL_SECOP_VERSION, 0, + s->version, NULL)) + { + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_VERSION_TOO_LOW); + return -1; + } + + s->type=SSL_ST_ACCEPT; + + if (s->init_buf == NULL) + { + if ((buf=BUF_MEM_new()) == NULL) + { + ret= -1; + goto end; + } + if (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH)) + { + BUF_MEM_free(buf); + ret= -1; + goto end; + } + s->init_buf=buf; + } + + if (!ssl3_setup_buffers(s)) + { + ret= -1; + goto end; + } + + s->init_num=0; + s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + /* Should have been reset by ssl3_get_finished, too. */ + s->s3->change_cipher_spec = 0; + + if (s->state != SSL_ST_RENEGOTIATE) + { + /* Ok, we now need to push on a buffering BIO so that + * the output is sent in a way that TCP likes :-) + */ + if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; } + + ssl3_init_finished_mac(s); + s->state=SSL3_ST_SR_CLNT_HELLO_A; + s->ctx->stats.sess_accept++; + } + else if (!s->s3->send_connection_binding && + !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) + { + /* Server attempting to renegotiate with + * client that doesn't support secure + * renegotiation. + */ + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); + ret = -1; + goto end; + } + else + { + /* s->state == SSL_ST_RENEGOTIATE, + * we will just send a HelloRequest */ + s->ctx->stats.sess_accept_renegotiate++; + s->state=SSL3_ST_SW_HELLO_REQ_A; + } + break; + + case SSL3_ST_SW_HELLO_REQ_A: + case SSL3_ST_SW_HELLO_REQ_B: + + s->shutdown=0; + ret=ssl3_send_hello_request(s); + if (ret <= 0) goto end; + s->s3->tmp.next_state=SSL3_ST_SW_HELLO_REQ_C; + s->state=SSL3_ST_SW_FLUSH; + s->init_num=0; + + ssl3_init_finished_mac(s); + break; + + case SSL3_ST_SW_HELLO_REQ_C: + s->state=SSL_ST_OK; + break; + + case SSL3_ST_SR_CLNT_HELLO_A: + case SSL3_ST_SR_CLNT_HELLO_B: + case SSL3_ST_SR_CLNT_HELLO_C: + + ret=ssl3_get_client_hello(s); + if (ret <= 0) goto end; +#ifndef OPENSSL_NO_SRP + s->state = SSL3_ST_SR_CLNT_HELLO_D; + case SSL3_ST_SR_CLNT_HELLO_D: + { + int al; + if ((ret = ssl_check_srp_ext_ClientHello(s,&al)) < 0) + { + /* callback indicates firther work to be done */ + s->rwstate=SSL_X509_LOOKUP; + goto end; + } + if (ret != SSL_ERROR_NONE) + { + ssl3_send_alert(s,SSL3_AL_FATAL,al); + /* This is not really an error but the only means to + for a client to detect whether srp is supported. */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_CLIENTHELLO_TLSEXT); + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + ret= -1; + goto end; + } + } +#endif + + s->renegotiate = 2; + s->state=SSL3_ST_SW_SRVR_HELLO_A; + s->init_num=0; + break; + + case SSL3_ST_SW_SRVR_HELLO_A: + case SSL3_ST_SW_SRVR_HELLO_B: + ret=ssl3_send_server_hello(s); + if (ret <= 0) goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->hit) + { + if (s->tlsext_ticket_expected) + s->state=SSL3_ST_SW_SESSION_TICKET_A; + else + s->state=SSL3_ST_SW_CHANGE_A; + } +#else + if (s->hit) + s->state=SSL3_ST_SW_CHANGE_A; +#endif + else + s->state = SSL3_ST_SW_CERT_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_A: + case SSL3_ST_SW_CERT_B: + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or KRB5 or SRP */ + if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aKRB5|SSL_aSRP)) + && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) + { + ret=ssl3_send_server_certificate(s); + if (ret <= 0) goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->tlsext_status_expected) + s->state=SSL3_ST_SW_CERT_STATUS_A; + else + s->state=SSL3_ST_SW_KEY_EXCH_A; + } + else + { + skip = 1; + s->state=SSL3_ST_SW_KEY_EXCH_A; + } +#else + } + else + skip=1; + + s->state=SSL3_ST_SW_KEY_EXCH_A; +#endif + s->init_num=0; + break; + + case SSL3_ST_SW_KEY_EXCH_A: + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* clear this, it may get reset by + * send_server_key_exchange */ + if ((s->options & SSL_OP_EPHEMERAL_RSA) +#ifndef OPENSSL_NO_KRB5 + && !(alg_k & SSL_kKRB5) +#endif /* OPENSSL_NO_KRB5 */ + ) + /* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key + * even when forbidden by protocol specs + * (handshake may fail as clients are not required to + * be able to handle this) */ + s->s3->tmp.use_rsa_tmp=1; + else + s->s3->tmp.use_rsa_tmp=0; + + + /* only send if a DH key exchange, fortezza or + * RSA but we have a sign only certificate + * + * PSK: may send PSK identity hints + * + * For ECC ciphersuites, we send a serverKeyExchange + * message only if the cipher suite is either + * ECDH-anon or ECDHE. In other cases, the + * server certificate contains the server's + * public key for key exchange. + */ + if (s->s3->tmp.use_rsa_tmp + /* PSK: send ServerKeyExchange if PSK identity + * hint if provided */ + #ifndef OPENSSL_NO_PSK + || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + || (alg_k & SSL_kDHE) + || (alg_k & SSL_kECDHE) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + ) + { + ret=ssl3_send_server_key_exchange(s); + if (ret <= 0) goto end; + } + else + skip=1; + + s->state=SSL3_ST_SW_CERT_REQ_A; + s->init_num=0; + break; + + case SSL3_ST_SW_CERT_REQ_A: + case SSL3_ST_SW_CERT_REQ_B: + if (/* don't request cert unless asked for it: */ + !(s->verify_mode & SSL_VERIFY_PEER) || + /* if SSL_VERIFY_CLIENT_ONCE is set, + * don't request cert during re-negotiation: */ + ((s->session->peer != NULL) && + (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || + /* never request cert in anonymous ciphersuites + * (see section ""Certificate request"" in SSL 3 drafts + * and in RFC 2246): */ + ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + /* ... except when the application insists on verification + * (against the specs, but s3_clnt.c accepts this for SSL 3) */ + !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || + /* never request cert in Kerberos ciphersuites */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* With normal PSK Certificates and + * Certificate Requests are omitted */ + || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) + { + /* no cert request */ + skip=1; + s->s3->tmp.cert_request=0; + s->state=SSL3_ST_SW_SRVR_DONE_A; + if (s->s3->handshake_buffer) + if (!ssl3_digest_cached_records(s)) + return -1; + } + else + { + s->s3->tmp.cert_request=1; + ret=ssl3_send_certificate_request(s); + if (ret <= 0) goto end; +#ifndef NETSCAPE_HANG_BUG + s->state=SSL3_ST_SW_SRVR_DONE_A; +#else + s->state=SSL3_ST_SW_FLUSH; + s->s3->tmp.next_state=SSL3_ST_SR_CERT_A; +#endif + s->init_num=0; + } + break; + + case SSL3_ST_SW_SRVR_DONE_A: + case SSL3_ST_SW_SRVR_DONE_B: + ret=ssl3_send_server_done(s); + if (ret <= 0) goto end; + s->s3->tmp.next_state=SSL3_ST_SR_CERT_A; + s->state=SSL3_ST_SW_FLUSH; + s->init_num=0; + break; + + case SSL3_ST_SW_FLUSH: + + /* This code originally checked to see if + * any data was pending using BIO_CTRL_INFO + * and then flushed. This caused problems + * as documented in PR#1939. The proposed + * fix doesn't completely resolve this issue + * as buggy implementations of BIO_CTRL_PENDING + * still exist. So instead we just flush + * unconditionally. + */ + + s->rwstate=SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) + { + ret= -1; + goto end; + } + s->rwstate=SSL_NOTHING; + + s->state=s->s3->tmp.next_state; + break; + + case SSL3_ST_SR_CERT_A: + case SSL3_ST_SR_CERT_B: + if (s->s3->tmp.cert_request) + { + ret=ssl3_get_client_certificate(s); + if (ret <= 0) goto end; + } + s->init_num=0; + s->state=SSL3_ST_SR_KEY_EXCH_A; + break; + + case SSL3_ST_SR_KEY_EXCH_A: + case SSL3_ST_SR_KEY_EXCH_B: + ret=ssl3_get_client_key_exchange(s); + if (ret <= 0) + goto end; + if (ret == 2) + { + /* For the ECDH ciphersuites when + * the client sends its ECDH pub key in + * a certificate, the CertificateVerify + * message is not sent. + * Also for GOST ciphersuites when + * the client uses its key from the certificate + * for key exchange. + */ +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state=SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state=SSL3_ST_SR_NEXT_PROTO_A; + else + s->state=SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + } + else if (SSL_USE_SIGALGS(s)) + { + s->state=SSL3_ST_SR_CERT_VRFY_A; + s->init_num=0; + if (!s->session->peer) + break; + /* For sigalgs freeze the handshake buffer + * at this point and digest cached records. + */ + if (!s->s3->handshake_buffer) + { + SSLerr(SSL_F_SSL3_ACCEPT,ERR_R_INTERNAL_ERROR); + return -1; + } + s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; + if (!ssl3_digest_cached_records(s)) + return -1; + } + else + { + int offset=0; + int dgst_num; + + s->state=SSL3_ST_SR_CERT_VRFY_A; + s->init_num=0; + + /* We need to get hashes here so if there is + * a client cert, it can be verified + * FIXME - digest processing for CertificateVerify + * should be generalized. But it is next step + */ + if (s->s3->handshake_buffer) + if (!ssl3_digest_cached_records(s)) + return -1; + for (dgst_num=0; dgst_nums3->handshake_dgst[dgst_num]) + { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s,EVP_MD_CTX_type(s->s3->handshake_dgst[dgst_num]),&(s->s3->tmp.cert_verify_md[offset])); + dgst_size=EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) + { + ret = -1; + goto end; + } + offset+=dgst_size; + } + } + break; + + case SSL3_ST_SR_CERT_VRFY_A: + case SSL3_ST_SR_CERT_VRFY_B: + /* + * This *should* be the first time we enable CCS, but be + * extra careful about surrounding code changes. We need + * to set this here because we don't know if we're + * expecting a CertificateVerify or not. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + /* we should decide if we expected this one */ + ret=ssl3_get_cert_verify(s); + if (ret <= 0) goto end; + +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state=SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state=SSL3_ST_SR_NEXT_PROTO_A; + else + s->state=SSL3_ST_SR_FINISHED_A; +#endif + s->init_num=0; + break; + +#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + case SSL3_ST_SR_NEXT_PROTO_A: + case SSL3_ST_SR_NEXT_PROTO_B: + /* + * Enable CCS for resumed handshakes with NPN. + * In a full handshake with NPN, we end up here through + * SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was + * already set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + + ret=ssl3_get_next_proto(s); + if (ret <= 0) goto end; + s->init_num = 0; + s->state=SSL3_ST_SR_FINISHED_A; + break; +#endif + + case SSL3_ST_SR_FINISHED_A: + case SSL3_ST_SR_FINISHED_B: + /* + * Enable CCS for resumed handshakes without NPN. + * In a full handshake, we end up here through + * SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was + * already set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B); + if (ret <= 0) goto end; + if (s->hit) + s->state=SSL_ST_OK; +#ifndef OPENSSL_NO_TLSEXT + else if (s->tlsext_ticket_expected) + s->state=SSL3_ST_SW_SESSION_TICKET_A; +#endif + else + s->state=SSL3_ST_SW_CHANGE_A; + s->init_num=0; + break; + +#ifndef OPENSSL_NO_TLSEXT + case SSL3_ST_SW_SESSION_TICKET_A: + case SSL3_ST_SW_SESSION_TICKET_B: + ret=ssl3_send_newsession_ticket(s); + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_CHANGE_A; + s->init_num=0; + break; + + case SSL3_ST_SW_CERT_STATUS_A: + case SSL3_ST_SW_CERT_STATUS_B: + ret=ssl3_send_cert_status(s); + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_KEY_EXCH_A; + s->init_num=0; + break; + +#endif + + case SSL3_ST_SW_CHANGE_A: + case SSL3_ST_SW_CHANGE_B: + + s->session->cipher=s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) + { ret= -1; goto end; } + + ret=ssl3_send_change_cipher_spec(s, + SSL3_ST_SW_CHANGE_A,SSL3_ST_SW_CHANGE_B); + + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_FINISHED_A; + s->init_num=0; + + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) + { + ret= -1; + goto end; + } + + break; + + case SSL3_ST_SW_FINISHED_A: + case SSL3_ST_SW_FINISHED_B: + ret=ssl3_send_finished(s, + SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, + s->method->ssl3_enc->server_finished_label, + s->method->ssl3_enc->server_finished_label_len); + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_FLUSH; + if (s->hit) + { +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + { + s->s3->tmp.next_state=SSL3_ST_SR_NEXT_PROTO_A; + } + else + s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; +#endif + } + else + s->s3->tmp.next_state=SSL_ST_OK; + s->init_num=0; + break; + + case SSL_ST_OK: + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + BUF_MEM_free(s->init_buf); + s->init_buf=NULL; + + /* remove buffering on output */ + ssl_free_wbio_buffer(s); + + s->init_num=0; + + if (s->renegotiate == 2) /* skipped if we just sent a HelloRequest */ + { + s->renegotiate=0; + s->new_session=0; + + ssl_update_cache(s,SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + /* s->server=1; */ + s->handshake_func=ssl3_accept; + + if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); + } + + ret = 1; + goto end; + /* break; */ + + default: + SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_UNKNOWN_STATE); + ret= -1; + goto end; + /* break; */ + } + + if (!s->s3->tmp.reuse_message && !skip) + { + if (s->debug) + { + if ((ret=BIO_flush(s->wbio)) <= 0) + goto end; + } + + + if ((cb != NULL) && (s->state != state)) + { + new_state=s->state; + s->state=state; + cb(s,SSL_CB_ACCEPT_LOOP,1); + s->state=new_state; + } + } + skip=0; + } +",1,"int ssl3_accept(SSL *s) + { + BUF_MEM *buf; + unsigned long alg_k,Time=(unsigned long)time(NULL); + void (*cb)(const SSL *ssl,int type,int val)=NULL; + int ret= -1; + int new_state,state,skip=0; + + RAND_add(&Time,sizeof(Time),0); + ERR_clear_error(); + clear_sys_error(); + + if (s->info_callback != NULL) + cb=s->info_callback; + else if (s->ctx->info_callback != NULL) + cb=s->ctx->info_callback; + + /* init things to blank */ + s->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); + + if (s->cert == NULL) + { + SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_NO_CERTIFICATE_SET); + return(-1); + } + +#ifndef OPENSSL_NO_HEARTBEATS + /* If we're awaiting a HeartbeatResponse, pretend we + * already got and don't await it anymore, because + * Heartbeats don't make sense during handshakes anyway. + */ + if (s->tlsext_hb_pending) + { + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + for (;;) + { + state=s->state; + + switch (s->state) + { + case SSL_ST_RENEGOTIATE: + s->renegotiate=1; + /* s->state=SSL_ST_ACCEPT; */ + + case SSL_ST_BEFORE: + case SSL_ST_ACCEPT: + case SSL_ST_BEFORE|SSL_ST_ACCEPT: + case SSL_ST_OK|SSL_ST_ACCEPT: + + s->server=1; + if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); + + if ((s->version>>8) != 3) + { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + return -1; + } + + if (!ssl_security(s, SSL_SECOP_VERSION, 0, + s->version, NULL)) + { + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_VERSION_TOO_LOW); + return -1; + } + + s->type=SSL_ST_ACCEPT; + + if (s->init_buf == NULL) + { + if ((buf=BUF_MEM_new()) == NULL) + { + ret= -1; + goto end; + } + if (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH)) + { + BUF_MEM_free(buf); + ret= -1; + goto end; + } + s->init_buf=buf; + } + + if (!ssl3_setup_buffers(s)) + { + ret= -1; + goto end; + } + + s->init_num=0; + s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + /* Should have been reset by ssl3_get_finished, too. */ + s->s3->change_cipher_spec = 0; + + if (s->state != SSL_ST_RENEGOTIATE) + { + /* Ok, we now need to push on a buffering BIO so that + * the output is sent in a way that TCP likes :-) + */ + if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; } + + ssl3_init_finished_mac(s); + s->state=SSL3_ST_SR_CLNT_HELLO_A; + s->ctx->stats.sess_accept++; + } + else if (!s->s3->send_connection_binding && + !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) + { + /* Server attempting to renegotiate with + * client that doesn't support secure + * renegotiation. + */ + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); + ret = -1; + goto end; + } + else + { + /* s->state == SSL_ST_RENEGOTIATE, + * we will just send a HelloRequest */ + s->ctx->stats.sess_accept_renegotiate++; + s->state=SSL3_ST_SW_HELLO_REQ_A; + } + break; + + case SSL3_ST_SW_HELLO_REQ_A: + case SSL3_ST_SW_HELLO_REQ_B: + + s->shutdown=0; + ret=ssl3_send_hello_request(s); + if (ret <= 0) goto end; + s->s3->tmp.next_state=SSL3_ST_SW_HELLO_REQ_C; + s->state=SSL3_ST_SW_FLUSH; + s->init_num=0; + + ssl3_init_finished_mac(s); + break; + + case SSL3_ST_SW_HELLO_REQ_C: + s->state=SSL_ST_OK; + break; + + case SSL3_ST_SR_CLNT_HELLO_A: + case SSL3_ST_SR_CLNT_HELLO_B: + case SSL3_ST_SR_CLNT_HELLO_C: + + ret=ssl3_get_client_hello(s); + if (ret <= 0) goto end; +#ifndef OPENSSL_NO_SRP + s->state = SSL3_ST_SR_CLNT_HELLO_D; + case SSL3_ST_SR_CLNT_HELLO_D: + { + int al; + if ((ret = ssl_check_srp_ext_ClientHello(s,&al)) < 0) + { + /* callback indicates firther work to be done */ + s->rwstate=SSL_X509_LOOKUP; + goto end; + } + if (ret != SSL_ERROR_NONE) + { + ssl3_send_alert(s,SSL3_AL_FATAL,al); + /* This is not really an error but the only means to + for a client to detect whether srp is supported. */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_CLIENTHELLO_TLSEXT); + ret = SSL_TLSEXT_ERR_ALERT_FATAL; + ret= -1; + goto end; + } + } +#endif + + s->renegotiate = 2; + s->state=SSL3_ST_SW_SRVR_HELLO_A; + s->init_num=0; + break; + + case SSL3_ST_SW_SRVR_HELLO_A: + case SSL3_ST_SW_SRVR_HELLO_B: + ret=ssl3_send_server_hello(s); + if (ret <= 0) goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->hit) + { + if (s->tlsext_ticket_expected) + s->state=SSL3_ST_SW_SESSION_TICKET_A; + else + s->state=SSL3_ST_SW_CHANGE_A; + } +#else + if (s->hit) + s->state=SSL3_ST_SW_CHANGE_A; +#endif + else + s->state = SSL3_ST_SW_CERT_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_A: + case SSL3_ST_SW_CERT_B: + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or KRB5 or SRP */ + if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aKRB5|SSL_aSRP)) + && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) + { + ret=ssl3_send_server_certificate(s); + if (ret <= 0) goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->tlsext_status_expected) + s->state=SSL3_ST_SW_CERT_STATUS_A; + else + s->state=SSL3_ST_SW_KEY_EXCH_A; + } + else + { + skip = 1; + s->state=SSL3_ST_SW_KEY_EXCH_A; + } +#else + } + else + skip=1; + + s->state=SSL3_ST_SW_KEY_EXCH_A; +#endif + s->init_num=0; + break; + + case SSL3_ST_SW_KEY_EXCH_A: + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * clear this, it may get reset by + * send_server_key_exchange + */ + s->s3->tmp.use_rsa_tmp=0; + + + /* only send if a DH key exchange, fortezza or + * RSA but we have a sign only certificate + * + * PSK: may send PSK identity hints + * + * For ECC ciphersuites, we send a serverKeyExchange + * message only if the cipher suite is either + * ECDH-anon or ECDHE. In other cases, the + * server certificate contains the server's + * public key for key exchange. + */ + if ( + /* PSK: send ServerKeyExchange if PSK identity + * hint if provided */ + #ifndef OPENSSL_NO_PSK + || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + || (alg_k & SSL_kDHE) + || (alg_k & SSL_kECDHE) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + ) + { + ret=ssl3_send_server_key_exchange(s); + if (ret <= 0) goto end; + } + else + skip=1; + + s->state=SSL3_ST_SW_CERT_REQ_A; + s->init_num=0; + break; + + case SSL3_ST_SW_CERT_REQ_A: + case SSL3_ST_SW_CERT_REQ_B: + if (/* don't request cert unless asked for it: */ + !(s->verify_mode & SSL_VERIFY_PEER) || + /* if SSL_VERIFY_CLIENT_ONCE is set, + * don't request cert during re-negotiation: */ + ((s->session->peer != NULL) && + (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || + /* never request cert in anonymous ciphersuites + * (see section ""Certificate request"" in SSL 3 drafts + * and in RFC 2246): */ + ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + /* ... except when the application insists on verification + * (against the specs, but s3_clnt.c accepts this for SSL 3) */ + !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || + /* never request cert in Kerberos ciphersuites */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* With normal PSK Certificates and + * Certificate Requests are omitted */ + || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) + { + /* no cert request */ + skip=1; + s->s3->tmp.cert_request=0; + s->state=SSL3_ST_SW_SRVR_DONE_A; + if (s->s3->handshake_buffer) + if (!ssl3_digest_cached_records(s)) + return -1; + } + else + { + s->s3->tmp.cert_request=1; + ret=ssl3_send_certificate_request(s); + if (ret <= 0) goto end; +#ifndef NETSCAPE_HANG_BUG + s->state=SSL3_ST_SW_SRVR_DONE_A; +#else + s->state=SSL3_ST_SW_FLUSH; + s->s3->tmp.next_state=SSL3_ST_SR_CERT_A; +#endif + s->init_num=0; + } + break; + + case SSL3_ST_SW_SRVR_DONE_A: + case SSL3_ST_SW_SRVR_DONE_B: + ret=ssl3_send_server_done(s); + if (ret <= 0) goto end; + s->s3->tmp.next_state=SSL3_ST_SR_CERT_A; + s->state=SSL3_ST_SW_FLUSH; + s->init_num=0; + break; + + case SSL3_ST_SW_FLUSH: + + /* This code originally checked to see if + * any data was pending using BIO_CTRL_INFO + * and then flushed. This caused problems + * as documented in PR#1939. The proposed + * fix doesn't completely resolve this issue + * as buggy implementations of BIO_CTRL_PENDING + * still exist. So instead we just flush + * unconditionally. + */ + + s->rwstate=SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) + { + ret= -1; + goto end; + } + s->rwstate=SSL_NOTHING; + + s->state=s->s3->tmp.next_state; + break; + + case SSL3_ST_SR_CERT_A: + case SSL3_ST_SR_CERT_B: + if (s->s3->tmp.cert_request) + { + ret=ssl3_get_client_certificate(s); + if (ret <= 0) goto end; + } + s->init_num=0; + s->state=SSL3_ST_SR_KEY_EXCH_A; + break; + + case SSL3_ST_SR_KEY_EXCH_A: + case SSL3_ST_SR_KEY_EXCH_B: + ret=ssl3_get_client_key_exchange(s); + if (ret <= 0) + goto end; + if (ret == 2) + { + /* For the ECDH ciphersuites when + * the client sends its ECDH pub key in + * a certificate, the CertificateVerify + * message is not sent. + * Also for GOST ciphersuites when + * the client uses its key from the certificate + * for key exchange. + */ +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state=SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state=SSL3_ST_SR_NEXT_PROTO_A; + else + s->state=SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + } + else if (SSL_USE_SIGALGS(s)) + { + s->state=SSL3_ST_SR_CERT_VRFY_A; + s->init_num=0; + if (!s->session->peer) + break; + /* For sigalgs freeze the handshake buffer + * at this point and digest cached records. + */ + if (!s->s3->handshake_buffer) + { + SSLerr(SSL_F_SSL3_ACCEPT,ERR_R_INTERNAL_ERROR); + return -1; + } + s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; + if (!ssl3_digest_cached_records(s)) + return -1; + } + else + { + int offset=0; + int dgst_num; + + s->state=SSL3_ST_SR_CERT_VRFY_A; + s->init_num=0; + + /* We need to get hashes here so if there is + * a client cert, it can be verified + * FIXME - digest processing for CertificateVerify + * should be generalized. But it is next step + */ + if (s->s3->handshake_buffer) + if (!ssl3_digest_cached_records(s)) + return -1; + for (dgst_num=0; dgst_nums3->handshake_dgst[dgst_num]) + { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s,EVP_MD_CTX_type(s->s3->handshake_dgst[dgst_num]),&(s->s3->tmp.cert_verify_md[offset])); + dgst_size=EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) + { + ret = -1; + goto end; + } + offset+=dgst_size; + } + } + break; + + case SSL3_ST_SR_CERT_VRFY_A: + case SSL3_ST_SR_CERT_VRFY_B: + /* + * This *should* be the first time we enable CCS, but be + * extra careful about surrounding code changes. We need + * to set this here because we don't know if we're + * expecting a CertificateVerify or not. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + /* we should decide if we expected this one */ + ret=ssl3_get_cert_verify(s); + if (ret <= 0) goto end; + +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state=SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state=SSL3_ST_SR_NEXT_PROTO_A; + else + s->state=SSL3_ST_SR_FINISHED_A; +#endif + s->init_num=0; + break; + +#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + case SSL3_ST_SR_NEXT_PROTO_A: + case SSL3_ST_SR_NEXT_PROTO_B: + /* + * Enable CCS for resumed handshakes with NPN. + * In a full handshake with NPN, we end up here through + * SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was + * already set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + + ret=ssl3_get_next_proto(s); + if (ret <= 0) goto end; + s->init_num = 0; + s->state=SSL3_ST_SR_FINISHED_A; + break; +#endif + + case SSL3_ST_SR_FINISHED_A: + case SSL3_ST_SR_FINISHED_B: + /* + * Enable CCS for resumed handshakes without NPN. + * In a full handshake, we end up here through + * SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was + * already set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B); + if (ret <= 0) goto end; + if (s->hit) + s->state=SSL_ST_OK; +#ifndef OPENSSL_NO_TLSEXT + else if (s->tlsext_ticket_expected) + s->state=SSL3_ST_SW_SESSION_TICKET_A; +#endif + else + s->state=SSL3_ST_SW_CHANGE_A; + s->init_num=0; + break; + +#ifndef OPENSSL_NO_TLSEXT + case SSL3_ST_SW_SESSION_TICKET_A: + case SSL3_ST_SW_SESSION_TICKET_B: + ret=ssl3_send_newsession_ticket(s); + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_CHANGE_A; + s->init_num=0; + break; + + case SSL3_ST_SW_CERT_STATUS_A: + case SSL3_ST_SW_CERT_STATUS_B: + ret=ssl3_send_cert_status(s); + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_KEY_EXCH_A; + s->init_num=0; + break; + +#endif + + case SSL3_ST_SW_CHANGE_A: + case SSL3_ST_SW_CHANGE_B: + + s->session->cipher=s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) + { ret= -1; goto end; } + + ret=ssl3_send_change_cipher_spec(s, + SSL3_ST_SW_CHANGE_A,SSL3_ST_SW_CHANGE_B); + + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_FINISHED_A; + s->init_num=0; + + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) + { + ret= -1; + goto end; + } + + break; + + case SSL3_ST_SW_FINISHED_A: + case SSL3_ST_SW_FINISHED_B: + ret=ssl3_send_finished(s, + SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, + s->method->ssl3_enc->server_finished_label, + s->method->ssl3_enc->server_finished_label_len); + if (ret <= 0) goto end; + s->state=SSL3_ST_SW_FLUSH; + if (s->hit) + { +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + { + s->s3->tmp.next_state=SSL3_ST_SR_NEXT_PROTO_A; + } + else + s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; +#endif + } + else + s->s3->tmp.next_state=SSL_ST_OK; + s->init_num=0; + break; + + case SSL_ST_OK: + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + BUF_MEM_free(s->init_buf); + s->init_buf=NULL; + + /* remove buffering on output */ + ssl_free_wbio_buffer(s); + + s->init_num=0; + + if (s->renegotiate == 2) /* skipped if we just sent a HelloRequest */ + { + s->renegotiate=0; + s->new_session=0; + + ssl_update_cache(s,SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + /* s->server=1; */ + s->handshake_func=ssl3_accept; + + if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); + } + + ret = 1; + goto end; + /* break; */ + + default: + SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_UNKNOWN_STATE); + ret= -1; + goto end; + /* break; */ + } + + if (!s->s3->tmp.reuse_message && !skip) + { + if (s->debug) + { + if ((ret=BIO_flush(s->wbio)) <= 0) + goto end; + } + + + if ((cb != NULL) && (s->state != state)) + { + new_state=s->state; + s->state=state; + cb(s,SSL_CB_ACCEPT_LOOP,1); + s->state=new_state; + } + } + skip=0; + } +","@@ -453,20 +453,11 @@ int ssl3_accept(SSL *s) + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + +- /* clear this, it may get reset by +- * send_server_key_exchange */ +- if ((s->options & SSL_OP_EPHEMERAL_RSA) +-#ifndef OPENSSL_NO_KRB5 +- && !(alg_k & SSL_kKRB5) +-#endif /* OPENSSL_NO_KRB5 */ +- ) +- /* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key +- * even when forbidden by protocol specs +- * (handshake may fail as clients are not required to +- * be able to handle this) */ +- s->s3->tmp.use_rsa_tmp=1; +- else +- s->s3->tmp.use_rsa_tmp=0; ++ /* ++ * clear this, it may get reset by ++ * send_server_key_exchange ++ */ ++ s->s3->tmp.use_rsa_tmp=0; + + + /* only send if a DH key exchange, fortezza or +@@ -480,7 +471,7 @@ int ssl3_accept(SSL *s) + * server certificate contains the server's + * public key for key exchange. + */ +- if (s->s3->tmp.use_rsa_tmp ++ if ( + /* PSK: send ServerKeyExchange if PSK identity + * hint if provided */ + #ifndef OPENSSL_NO_PSK",5504,5740,6144 +3887,"unsigned int __sk_run_filter(void *ctx, const struct sock_filter_int *insn) +{ + u64 stack[MAX_BPF_STACK / sizeof(u64)]; + u64 regs[MAX_BPF_REG], tmp; + void *ptr; + int off; + +#define K insn->imm +#define A regs[insn->a_reg] +#define X regs[insn->x_reg] +#define R0 regs[0] + +#define CONT ({insn++; goto select_insn; }) +#define CONT_JMP ({insn++; goto select_insn; }) + + static const void *jumptable[256] = { + [0 ... 255] = &&default_label, + /* Now overwrite non-defaults ... */ +#define DL(A, B, C) [A|B|C] = &&A##_##B##_##C + DL(BPF_ALU, BPF_ADD, BPF_X), + DL(BPF_ALU, BPF_ADD, BPF_K), + DL(BPF_ALU, BPF_SUB, BPF_X), + DL(BPF_ALU, BPF_SUB, BPF_K), + DL(BPF_ALU, BPF_AND, BPF_X), + DL(BPF_ALU, BPF_AND, BPF_K), + DL(BPF_ALU, BPF_OR, BPF_X), + DL(BPF_ALU, BPF_OR, BPF_K), + DL(BPF_ALU, BPF_LSH, BPF_X), + DL(BPF_ALU, BPF_LSH, BPF_K), + DL(BPF_ALU, BPF_RSH, BPF_X), + DL(BPF_ALU, BPF_RSH, BPF_K), + DL(BPF_ALU, BPF_XOR, BPF_X), + DL(BPF_ALU, BPF_XOR, BPF_K), + DL(BPF_ALU, BPF_MUL, BPF_X), + DL(BPF_ALU, BPF_MUL, BPF_K), + DL(BPF_ALU, BPF_MOV, BPF_X), + DL(BPF_ALU, BPF_MOV, BPF_K), + DL(BPF_ALU, BPF_DIV, BPF_X), + DL(BPF_ALU, BPF_DIV, BPF_K), + DL(BPF_ALU, BPF_MOD, BPF_X), + DL(BPF_ALU, BPF_MOD, BPF_K), + DL(BPF_ALU, BPF_NEG, 0), + DL(BPF_ALU, BPF_END, BPF_TO_BE), + DL(BPF_ALU, BPF_END, BPF_TO_LE), + DL(BPF_ALU64, BPF_ADD, BPF_X), + DL(BPF_ALU64, BPF_ADD, BPF_K), + DL(BPF_ALU64, BPF_SUB, BPF_X), + DL(BPF_ALU64, BPF_SUB, BPF_K), + DL(BPF_ALU64, BPF_AND, BPF_X), + DL(BPF_ALU64, BPF_AND, BPF_K), + DL(BPF_ALU64, BPF_OR, BPF_X), + DL(BPF_ALU64, BPF_OR, BPF_K), + DL(BPF_ALU64, BPF_LSH, BPF_X), + DL(BPF_ALU64, BPF_LSH, BPF_K), + DL(BPF_ALU64, BPF_RSH, BPF_X), + DL(BPF_ALU64, BPF_RSH, BPF_K), + DL(BPF_ALU64, BPF_XOR, BPF_X), + DL(BPF_ALU64, BPF_XOR, BPF_K), + DL(BPF_ALU64, BPF_MUL, BPF_X), + DL(BPF_ALU64, BPF_MUL, BPF_K), + DL(BPF_ALU64, BPF_MOV, BPF_X), + DL(BPF_ALU64, BPF_MOV, BPF_K), + DL(BPF_ALU64, BPF_ARSH, BPF_X), + DL(BPF_ALU64, BPF_ARSH, BPF_K), + DL(BPF_ALU64, BPF_DIV, BPF_X), + DL(BPF_ALU64, BPF_DIV, BPF_K), + DL(BPF_ALU64, BPF_MOD, BPF_X), + DL(BPF_ALU64, BPF_MOD, BPF_K), + DL(BPF_ALU64, BPF_NEG, 0), + DL(BPF_JMP, BPF_CALL, 0), + DL(BPF_JMP, BPF_JA, 0), + DL(BPF_JMP, BPF_JEQ, BPF_X), + DL(BPF_JMP, BPF_JEQ, BPF_K), + DL(BPF_JMP, BPF_JNE, BPF_X), + DL(BPF_JMP, BPF_JNE, BPF_K), + DL(BPF_JMP, BPF_JGT, BPF_X), + DL(BPF_JMP, BPF_JGT, BPF_K), + DL(BPF_JMP, BPF_JGE, BPF_X), + DL(BPF_JMP, BPF_JGE, BPF_K), + DL(BPF_JMP, BPF_JSGT, BPF_X), + DL(BPF_JMP, BPF_JSGT, BPF_K), + DL(BPF_JMP, BPF_JSGE, BPF_X), + DL(BPF_JMP, BPF_JSGE, BPF_K), + DL(BPF_JMP, BPF_JSET, BPF_X), + DL(BPF_JMP, BPF_JSET, BPF_K), + DL(BPF_JMP, BPF_EXIT, 0), + DL(BPF_STX, BPF_MEM, BPF_B), + DL(BPF_STX, BPF_MEM, BPF_H), + DL(BPF_STX, BPF_MEM, BPF_W), + DL(BPF_STX, BPF_MEM, BPF_DW), + DL(BPF_STX, BPF_XADD, BPF_W), + DL(BPF_STX, BPF_XADD, BPF_DW), + DL(BPF_ST, BPF_MEM, BPF_B), + DL(BPF_ST, BPF_MEM, BPF_H), + DL(BPF_ST, BPF_MEM, BPF_W), + DL(BPF_ST, BPF_MEM, BPF_DW), + DL(BPF_LDX, BPF_MEM, BPF_B), + DL(BPF_LDX, BPF_MEM, BPF_H), + DL(BPF_LDX, BPF_MEM, BPF_W), + DL(BPF_LDX, BPF_MEM, BPF_DW), + DL(BPF_LD, BPF_ABS, BPF_W), + DL(BPF_LD, BPF_ABS, BPF_H), + DL(BPF_LD, BPF_ABS, BPF_B), + DL(BPF_LD, BPF_IND, BPF_W), + DL(BPF_LD, BPF_IND, BPF_H), + DL(BPF_LD, BPF_IND, BPF_B), +#undef DL + }; + + regs[FP_REG] = (u64) (unsigned long) &stack[ARRAY_SIZE(stack)]; + regs[ARG1_REG] = (u64) (unsigned long) ctx; + +select_insn: + goto *jumptable[insn->code]; + + /* ALU */ +#define ALU(OPCODE, OP) \ + BPF_ALU64_##OPCODE##_BPF_X: \ + A = A OP X; \ + CONT; \ + BPF_ALU_##OPCODE##_BPF_X: \ + A = (u32) A OP (u32) X; \ + CONT; \ + BPF_ALU64_##OPCODE##_BPF_K: \ + A = A OP K; \ + CONT; \ + BPF_ALU_##OPCODE##_BPF_K: \ + A = (u32) A OP (u32) K; \ + CONT; + + ALU(BPF_ADD, +) + ALU(BPF_SUB, -) + ALU(BPF_AND, &) + ALU(BPF_OR, |) + ALU(BPF_LSH, <<) + ALU(BPF_RSH, >>) + ALU(BPF_XOR, ^) + ALU(BPF_MUL, *) +#undef ALU + BPF_ALU_BPF_NEG_0: + A = (u32) -A; + CONT; + BPF_ALU64_BPF_NEG_0: + A = -A; + CONT; + BPF_ALU_BPF_MOV_BPF_X: + A = (u32) X; + CONT; + BPF_ALU_BPF_MOV_BPF_K: + A = (u32) K; + CONT; + BPF_ALU64_BPF_MOV_BPF_X: + A = X; + CONT; + BPF_ALU64_BPF_MOV_BPF_K: + A = K; + CONT; + BPF_ALU64_BPF_ARSH_BPF_X: + (*(s64 *) &A) >>= X; + CONT; + BPF_ALU64_BPF_ARSH_BPF_K: + (*(s64 *) &A) >>= K; + CONT; + BPF_ALU64_BPF_MOD_BPF_X: + if (unlikely(X == 0)) + return 0; + tmp = A; + A = do_div(tmp, X); + CONT; + BPF_ALU_BPF_MOD_BPF_X: + if (unlikely(X == 0)) + return 0; + tmp = (u32) A; + A = do_div(tmp, (u32) X); + CONT; + BPF_ALU64_BPF_MOD_BPF_K: + tmp = A; + A = do_div(tmp, K); + CONT; + BPF_ALU_BPF_MOD_BPF_K: + tmp = (u32) A; + A = do_div(tmp, (u32) K); + CONT; + BPF_ALU64_BPF_DIV_BPF_X: + if (unlikely(X == 0)) + return 0; + do_div(A, X); + CONT; + BPF_ALU_BPF_DIV_BPF_X: + if (unlikely(X == 0)) + return 0; + tmp = (u32) A; + do_div(tmp, (u32) X); + A = (u32) tmp; + CONT; + BPF_ALU64_BPF_DIV_BPF_K: + do_div(A, K); + CONT; + BPF_ALU_BPF_DIV_BPF_K: + tmp = (u32) A; + do_div(tmp, (u32) K); + A = (u32) tmp; + CONT; + BPF_ALU_BPF_END_BPF_TO_BE: + switch (K) { + case 16: + A = (__force u16) cpu_to_be16(A); + break; + case 32: + A = (__force u32) cpu_to_be32(A); + break; + case 64: + A = (__force u64) cpu_to_be64(A); + break; + } + CONT; + BPF_ALU_BPF_END_BPF_TO_LE: + switch (K) { + case 16: + A = (__force u16) cpu_to_le16(A); + break; + case 32: + A = (__force u32) cpu_to_le32(A); + break; + case 64: + A = (__force u64) cpu_to_le64(A); + break; + } + CONT; + + /* CALL */ + BPF_JMP_BPF_CALL_0: + /* Function call scratches R1-R5 registers, preserves R6-R9, + * and stores return value into R0. + */ + R0 = (__bpf_call_base + insn->imm)(regs[1], regs[2], regs[3], + regs[4], regs[5]); + CONT; + + /* JMP */ + BPF_JMP_BPF_JA_0: + insn += insn->off; + CONT; + BPF_JMP_BPF_JEQ_BPF_X: + if (A == X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JEQ_BPF_K: + if (A == K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JNE_BPF_X: + if (A != X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JNE_BPF_K: + if (A != K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGT_BPF_X: + if (A > X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGT_BPF_K: + if (A > K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGE_BPF_X: + if (A >= X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGE_BPF_K: + if (A >= K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGT_BPF_X: + if (((s64)A) > ((s64)X)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGT_BPF_K: + if (((s64)A) > ((s64)K)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGE_BPF_X: + if (((s64)A) >= ((s64)X)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGE_BPF_K: + if (((s64)A) >= ((s64)K)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSET_BPF_X: + if (A & X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSET_BPF_K: + if (A & K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_EXIT_0: + return R0; + + /* STX and ST and LDX*/ +#define LDST(SIZEOP, SIZE) \ + BPF_STX_BPF_MEM_##SIZEOP: \ + *(SIZE *)(unsigned long) (A + insn->off) = X; \ + CONT; \ + BPF_ST_BPF_MEM_##SIZEOP: \ + *(SIZE *)(unsigned long) (A + insn->off) = K; \ + CONT; \ + BPF_LDX_BPF_MEM_##SIZEOP: \ + A = *(SIZE *)(unsigned long) (X + insn->off); \ + CONT; + + LDST(BPF_B, u8) + LDST(BPF_H, u16) + LDST(BPF_W, u32) + LDST(BPF_DW, u64) +#undef LDST + BPF_STX_BPF_XADD_BPF_W: /* lock xadd *(u32 *)(A + insn->off) += X */ + atomic_add((u32) X, (atomic_t *)(unsigned long) + (A + insn->off)); + CONT; + BPF_STX_BPF_XADD_BPF_DW: /* lock xadd *(u64 *)(A + insn->off) += X */ + atomic64_add((u64) X, (atomic64_t *)(unsigned long) + (A + insn->off)); + CONT; + BPF_LD_BPF_ABS_BPF_W: /* R0 = ntohl(*(u32 *) (skb->data + K)) */ + off = K; +load_word: + /* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are only + * appearing in the programs where ctx == skb. All programs + * keep 'ctx' in regs[CTX_REG] == R6, sk_convert_filter() + * saves it in R6, internal BPF verifier will check that + * R6 == ctx. + * + * BPF_ABS and BPF_IND are wrappers of function calls, so + * they scratch R1-R5 registers, preserve R6-R9, and store + * return value into R0. + * + * Implicit input: + * ctx + * + * Explicit input: + * X == any register + * K == 32-bit immediate + * + * Output: + * R0 - 8/16/32-bit skb data converted to cpu endianness + */ + ptr = load_pointer((struct sk_buff *) ctx, off, 4, &tmp); + if (likely(ptr != NULL)) { + R0 = get_unaligned_be32(ptr); + CONT; + } + return 0; + BPF_LD_BPF_ABS_BPF_H: /* R0 = ntohs(*(u16 *) (skb->data + K)) */ + off = K; +load_half: + ptr = load_pointer((struct sk_buff *) ctx, off, 2, &tmp); + if (likely(ptr != NULL)) { + R0 = get_unaligned_be16(ptr); + CONT; + } + return 0; + BPF_LD_BPF_ABS_BPF_B: /* R0 = *(u8 *) (ctx + K) */ + off = K; +load_byte: + ptr = load_pointer((struct sk_buff *) ctx, off, 1, &tmp); + if (likely(ptr != NULL)) { + R0 = *(u8 *)ptr; + CONT; + } + return 0; + BPF_LD_BPF_IND_BPF_W: /* R0 = ntohl(*(u32 *) (skb->data + X + K)) */ + off = K + X; + goto load_word; + BPF_LD_BPF_IND_BPF_H: /* R0 = ntohs(*(u16 *) (skb->data + X + K)) */ + off = K + X; + goto load_half; + BPF_LD_BPF_IND_BPF_B: /* R0 = *(u8 *) (skb->data + X + K) */ + off = K + X; + goto load_byte; + + default_label: + /* If we ever reach this, we have a bug somewhere. */ + WARN_RATELIMIT(1, ""unknown opcode %02x\n"", insn->code); + return 0; +#undef CONT_JMP +#undef CONT + +#undef R0 +#undef X +#undef A +#undef K +} +",0,"unsigned int __sk_run_filter(void *ctx, const struct sock_filter_int *insn) +{ + u64 stack[MAX_BPF_STACK / sizeof(u64)]; + u64 regs[MAX_BPF_REG], tmp; + void *ptr; + int off; + +#define K insn->imm +#define A regs[insn->a_reg] +#define X regs[insn->x_reg] +#define R0 regs[0] + +#define CONT ({insn++; goto select_insn; }) +#define CONT_JMP ({insn++; goto select_insn; }) + + static const void *jumptable[256] = { + [0 ... 255] = &&default_label, + /* Now overwrite non-defaults ... */ +#define DL(A, B, C) [A|B|C] = &&A##_##B##_##C + DL(BPF_ALU, BPF_ADD, BPF_X), + DL(BPF_ALU, BPF_ADD, BPF_K), + DL(BPF_ALU, BPF_SUB, BPF_X), + DL(BPF_ALU, BPF_SUB, BPF_K), + DL(BPF_ALU, BPF_AND, BPF_X), + DL(BPF_ALU, BPF_AND, BPF_K), + DL(BPF_ALU, BPF_OR, BPF_X), + DL(BPF_ALU, BPF_OR, BPF_K), + DL(BPF_ALU, BPF_LSH, BPF_X), + DL(BPF_ALU, BPF_LSH, BPF_K), + DL(BPF_ALU, BPF_RSH, BPF_X), + DL(BPF_ALU, BPF_RSH, BPF_K), + DL(BPF_ALU, BPF_XOR, BPF_X), + DL(BPF_ALU, BPF_XOR, BPF_K), + DL(BPF_ALU, BPF_MUL, BPF_X), + DL(BPF_ALU, BPF_MUL, BPF_K), + DL(BPF_ALU, BPF_MOV, BPF_X), + DL(BPF_ALU, BPF_MOV, BPF_K), + DL(BPF_ALU, BPF_DIV, BPF_X), + DL(BPF_ALU, BPF_DIV, BPF_K), + DL(BPF_ALU, BPF_MOD, BPF_X), + DL(BPF_ALU, BPF_MOD, BPF_K), + DL(BPF_ALU, BPF_NEG, 0), + DL(BPF_ALU, BPF_END, BPF_TO_BE), + DL(BPF_ALU, BPF_END, BPF_TO_LE), + DL(BPF_ALU64, BPF_ADD, BPF_X), + DL(BPF_ALU64, BPF_ADD, BPF_K), + DL(BPF_ALU64, BPF_SUB, BPF_X), + DL(BPF_ALU64, BPF_SUB, BPF_K), + DL(BPF_ALU64, BPF_AND, BPF_X), + DL(BPF_ALU64, BPF_AND, BPF_K), + DL(BPF_ALU64, BPF_OR, BPF_X), + DL(BPF_ALU64, BPF_OR, BPF_K), + DL(BPF_ALU64, BPF_LSH, BPF_X), + DL(BPF_ALU64, BPF_LSH, BPF_K), + DL(BPF_ALU64, BPF_RSH, BPF_X), + DL(BPF_ALU64, BPF_RSH, BPF_K), + DL(BPF_ALU64, BPF_XOR, BPF_X), + DL(BPF_ALU64, BPF_XOR, BPF_K), + DL(BPF_ALU64, BPF_MUL, BPF_X), + DL(BPF_ALU64, BPF_MUL, BPF_K), + DL(BPF_ALU64, BPF_MOV, BPF_X), + DL(BPF_ALU64, BPF_MOV, BPF_K), + DL(BPF_ALU64, BPF_ARSH, BPF_X), + DL(BPF_ALU64, BPF_ARSH, BPF_K), + DL(BPF_ALU64, BPF_DIV, BPF_X), + DL(BPF_ALU64, BPF_DIV, BPF_K), + DL(BPF_ALU64, BPF_MOD, BPF_X), + DL(BPF_ALU64, BPF_MOD, BPF_K), + DL(BPF_ALU64, BPF_NEG, 0), + DL(BPF_JMP, BPF_CALL, 0), + DL(BPF_JMP, BPF_JA, 0), + DL(BPF_JMP, BPF_JEQ, BPF_X), + DL(BPF_JMP, BPF_JEQ, BPF_K), + DL(BPF_JMP, BPF_JNE, BPF_X), + DL(BPF_JMP, BPF_JNE, BPF_K), + DL(BPF_JMP, BPF_JGT, BPF_X), + DL(BPF_JMP, BPF_JGT, BPF_K), + DL(BPF_JMP, BPF_JGE, BPF_X), + DL(BPF_JMP, BPF_JGE, BPF_K), + DL(BPF_JMP, BPF_JSGT, BPF_X), + DL(BPF_JMP, BPF_JSGT, BPF_K), + DL(BPF_JMP, BPF_JSGE, BPF_X), + DL(BPF_JMP, BPF_JSGE, BPF_K), + DL(BPF_JMP, BPF_JSET, BPF_X), + DL(BPF_JMP, BPF_JSET, BPF_K), + DL(BPF_JMP, BPF_EXIT, 0), + DL(BPF_STX, BPF_MEM, BPF_B), + DL(BPF_STX, BPF_MEM, BPF_H), + DL(BPF_STX, BPF_MEM, BPF_W), + DL(BPF_STX, BPF_MEM, BPF_DW), + DL(BPF_STX, BPF_XADD, BPF_W), + DL(BPF_STX, BPF_XADD, BPF_DW), + DL(BPF_ST, BPF_MEM, BPF_B), + DL(BPF_ST, BPF_MEM, BPF_H), + DL(BPF_ST, BPF_MEM, BPF_W), + DL(BPF_ST, BPF_MEM, BPF_DW), + DL(BPF_LDX, BPF_MEM, BPF_B), + DL(BPF_LDX, BPF_MEM, BPF_H), + DL(BPF_LDX, BPF_MEM, BPF_W), + DL(BPF_LDX, BPF_MEM, BPF_DW), + DL(BPF_LD, BPF_ABS, BPF_W), + DL(BPF_LD, BPF_ABS, BPF_H), + DL(BPF_LD, BPF_ABS, BPF_B), + DL(BPF_LD, BPF_IND, BPF_W), + DL(BPF_LD, BPF_IND, BPF_H), + DL(BPF_LD, BPF_IND, BPF_B), +#undef DL + }; + + regs[FP_REG] = (u64) (unsigned long) &stack[ARRAY_SIZE(stack)]; + regs[ARG1_REG] = (u64) (unsigned long) ctx; + +select_insn: + goto *jumptable[insn->code]; + + /* ALU */ +#define ALU(OPCODE, OP) \ + BPF_ALU64_##OPCODE##_BPF_X: \ + A = A OP X; \ + CONT; \ + BPF_ALU_##OPCODE##_BPF_X: \ + A = (u32) A OP (u32) X; \ + CONT; \ + BPF_ALU64_##OPCODE##_BPF_K: \ + A = A OP K; \ + CONT; \ + BPF_ALU_##OPCODE##_BPF_K: \ + A = (u32) A OP (u32) K; \ + CONT; + + ALU(BPF_ADD, +) + ALU(BPF_SUB, -) + ALU(BPF_AND, &) + ALU(BPF_OR, |) + ALU(BPF_LSH, <<) + ALU(BPF_RSH, >>) + ALU(BPF_XOR, ^) + ALU(BPF_MUL, *) +#undef ALU + BPF_ALU_BPF_NEG_0: + A = (u32) -A; + CONT; + BPF_ALU64_BPF_NEG_0: + A = -A; + CONT; + BPF_ALU_BPF_MOV_BPF_X: + A = (u32) X; + CONT; + BPF_ALU_BPF_MOV_BPF_K: + A = (u32) K; + CONT; + BPF_ALU64_BPF_MOV_BPF_X: + A = X; + CONT; + BPF_ALU64_BPF_MOV_BPF_K: + A = K; + CONT; + BPF_ALU64_BPF_ARSH_BPF_X: + (*(s64 *) &A) >>= X; + CONT; + BPF_ALU64_BPF_ARSH_BPF_K: + (*(s64 *) &A) >>= K; + CONT; + BPF_ALU64_BPF_MOD_BPF_X: + if (unlikely(X == 0)) + return 0; + tmp = A; + A = do_div(tmp, X); + CONT; + BPF_ALU_BPF_MOD_BPF_X: + if (unlikely(X == 0)) + return 0; + tmp = (u32) A; + A = do_div(tmp, (u32) X); + CONT; + BPF_ALU64_BPF_MOD_BPF_K: + tmp = A; + A = do_div(tmp, K); + CONT; + BPF_ALU_BPF_MOD_BPF_K: + tmp = (u32) A; + A = do_div(tmp, (u32) K); + CONT; + BPF_ALU64_BPF_DIV_BPF_X: + if (unlikely(X == 0)) + return 0; + do_div(A, X); + CONT; + BPF_ALU_BPF_DIV_BPF_X: + if (unlikely(X == 0)) + return 0; + tmp = (u32) A; + do_div(tmp, (u32) X); + A = (u32) tmp; + CONT; + BPF_ALU64_BPF_DIV_BPF_K: + do_div(A, K); + CONT; + BPF_ALU_BPF_DIV_BPF_K: + tmp = (u32) A; + do_div(tmp, (u32) K); + A = (u32) tmp; + CONT; + BPF_ALU_BPF_END_BPF_TO_BE: + switch (K) { + case 16: + A = (__force u16) cpu_to_be16(A); + break; + case 32: + A = (__force u32) cpu_to_be32(A); + break; + case 64: + A = (__force u64) cpu_to_be64(A); + break; + } + CONT; + BPF_ALU_BPF_END_BPF_TO_LE: + switch (K) { + case 16: + A = (__force u16) cpu_to_le16(A); + break; + case 32: + A = (__force u32) cpu_to_le32(A); + break; + case 64: + A = (__force u64) cpu_to_le64(A); + break; + } + CONT; + + /* CALL */ + BPF_JMP_BPF_CALL_0: + /* Function call scratches R1-R5 registers, preserves R6-R9, + * and stores return value into R0. + */ + R0 = (__bpf_call_base + insn->imm)(regs[1], regs[2], regs[3], + regs[4], regs[5]); + CONT; + + /* JMP */ + BPF_JMP_BPF_JA_0: + insn += insn->off; + CONT; + BPF_JMP_BPF_JEQ_BPF_X: + if (A == X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JEQ_BPF_K: + if (A == K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JNE_BPF_X: + if (A != X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JNE_BPF_K: + if (A != K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGT_BPF_X: + if (A > X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGT_BPF_K: + if (A > K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGE_BPF_X: + if (A >= X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JGE_BPF_K: + if (A >= K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGT_BPF_X: + if (((s64)A) > ((s64)X)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGT_BPF_K: + if (((s64)A) > ((s64)K)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGE_BPF_X: + if (((s64)A) >= ((s64)X)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSGE_BPF_K: + if (((s64)A) >= ((s64)K)) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSET_BPF_X: + if (A & X) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_JSET_BPF_K: + if (A & K) { + insn += insn->off; + CONT_JMP; + } + CONT; + BPF_JMP_BPF_EXIT_0: + return R0; + + /* STX and ST and LDX*/ +#define LDST(SIZEOP, SIZE) \ + BPF_STX_BPF_MEM_##SIZEOP: \ + *(SIZE *)(unsigned long) (A + insn->off) = X; \ + CONT; \ + BPF_ST_BPF_MEM_##SIZEOP: \ + *(SIZE *)(unsigned long) (A + insn->off) = K; \ + CONT; \ + BPF_LDX_BPF_MEM_##SIZEOP: \ + A = *(SIZE *)(unsigned long) (X + insn->off); \ + CONT; + + LDST(BPF_B, u8) + LDST(BPF_H, u16) + LDST(BPF_W, u32) + LDST(BPF_DW, u64) +#undef LDST + BPF_STX_BPF_XADD_BPF_W: /* lock xadd *(u32 *)(A + insn->off) += X */ + atomic_add((u32) X, (atomic_t *)(unsigned long) + (A + insn->off)); + CONT; + BPF_STX_BPF_XADD_BPF_DW: /* lock xadd *(u64 *)(A + insn->off) += X */ + atomic64_add((u64) X, (atomic64_t *)(unsigned long) + (A + insn->off)); + CONT; + BPF_LD_BPF_ABS_BPF_W: /* R0 = ntohl(*(u32 *) (skb->data + K)) */ + off = K; +load_word: + /* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are only + * appearing in the programs where ctx == skb. All programs + * keep 'ctx' in regs[CTX_REG] == R6, sk_convert_filter() + * saves it in R6, internal BPF verifier will check that + * R6 == ctx. + * + * BPF_ABS and BPF_IND are wrappers of function calls, so + * they scratch R1-R5 registers, preserve R6-R9, and store + * return value into R0. + * + * Implicit input: + * ctx + * + * Explicit input: + * X == any register + * K == 32-bit immediate + * + * Output: + * R0 - 8/16/32-bit skb data converted to cpu endianness + */ + ptr = load_pointer((struct sk_buff *) ctx, off, 4, &tmp); + if (likely(ptr != NULL)) { + R0 = get_unaligned_be32(ptr); + CONT; + } + return 0; + BPF_LD_BPF_ABS_BPF_H: /* R0 = ntohs(*(u16 *) (skb->data + K)) */ + off = K; +load_half: + ptr = load_pointer((struct sk_buff *) ctx, off, 2, &tmp); + if (likely(ptr != NULL)) { + R0 = get_unaligned_be16(ptr); + CONT; + } + return 0; + BPF_LD_BPF_ABS_BPF_B: /* R0 = *(u8 *) (ctx + K) */ + off = K; +load_byte: + ptr = load_pointer((struct sk_buff *) ctx, off, 1, &tmp); + if (likely(ptr != NULL)) { + R0 = *(u8 *)ptr; + CONT; + } + return 0; + BPF_LD_BPF_IND_BPF_W: /* R0 = ntohl(*(u32 *) (skb->data + X + K)) */ + off = K + X; + goto load_word; + BPF_LD_BPF_IND_BPF_H: /* R0 = ntohs(*(u16 *) (skb->data + X + K)) */ + off = K + X; + goto load_half; + BPF_LD_BPF_IND_BPF_B: /* R0 = *(u8 *) (skb->data + X + K) */ + off = K + X; + goto load_byte; + + default_label: + /* If we ever reach this, we have a bug somewhere. */ + WARN_RATELIMIT(1, ""unknown opcode %02x\n"", insn->code); + return 0; +#undef CONT_JMP +#undef CONT + +#undef R0 +#undef X +#undef A +#undef K +} +","@@ -600,6 +600,9 @@ static u64 __skb_get_nlattr(u64 ctx, u64 A, u64 X, u64 r4, u64 r5) + if (skb_is_nonlinear(skb)) + return 0; + ++ if (skb->len < sizeof(struct nlattr)) ++ return 0; ++ + if (A > skb->len - sizeof(struct nlattr)) + return 0; + +@@ -618,11 +621,14 @@ static u64 __skb_get_nlattr_nest(u64 ctx, u64 A, u64 X, u64 r4, u64 r5) + if (skb_is_nonlinear(skb)) + return 0; + ++ if (skb->len < sizeof(struct nlattr)) ++ return 0; ++ + if (A > skb->len - sizeof(struct nlattr)) + return 0; + + nla = (struct nlattr *) &skb->data[A]; +- if (nla->nla_len > A - skb->len) ++ if (nla->nla_len > skb->len - A) + return 0; + + nla = nla_find_nested(nla, X);",4389,4625,6144 +18169,"static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define ThrowPCXException(severity,tag) \ + { \ + scanline=(unsigned char *) RelinquishMagickMemory(scanline); \ + pixel_info=RelinquishVirtualMemory(pixel_info); \ + ThrowReaderException(severity,tag); \ + } + + Image + *image; + + int + bits, + id, + mask; + + MagickBooleanType + status; + + MagickOffsetType + offset, + *page_table; + + MemoryInfo + *pixel_info; + + PCXInfo + pcx_info; + + register IndexPacket + *indexes; + + register ssize_t + x; + + register PixelPacket + *q; + + register ssize_t + i; + + register unsigned char + *p, + *r; + + size_t + one, + pcx_packets; + + ssize_t + count, + y; + + unsigned char + packet, + pcx_colormap[768], + *pixels, + *scanline; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Determine if this a PCX file. + */ + page_table=(MagickOffsetType *) NULL; + if (LocaleCompare(image_info->magick,""DCX"") == 0) + { + size_t + magic; + + /* + Read the DCX page table. + */ + magic=ReadBlobLSBLong(image); + if (magic != 987654321) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + page_table=(MagickOffsetType *) AcquireQuantumMemory(1024UL, + sizeof(*page_table)); + if (page_table == (MagickOffsetType *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + for (id=0; id < 1024; id++) + { + page_table[id]=(MagickOffsetType) ReadBlobLSBLong(image); + if (page_table[id] == 0) + break; + } + } + if (page_table != (MagickOffsetType *) NULL) + { + offset=SeekBlob(image,(MagickOffsetType) page_table[0],SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + count=ReadBlob(image,1,&pcx_info.identifier); + for (id=1; id < 1024; id++) + { + int + bits_per_pixel; + + /* + Verify PCX identifier. + */ + pcx_info.version=(unsigned char) ReadBlobByte(image); + if ((count == 0) || (pcx_info.identifier != 0x0a)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + pcx_info.encoding=(unsigned char) ReadBlobByte(image); + bits_per_pixel=ReadBlobByte(image); + if (bits_per_pixel == -1) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + pcx_info.bits_per_pixel=(unsigned char) bits_per_pixel; + pcx_info.left=ReadBlobLSBShort(image); + pcx_info.top=ReadBlobLSBShort(image); + pcx_info.right=ReadBlobLSBShort(image); + pcx_info.bottom=ReadBlobLSBShort(image); + pcx_info.horizontal_resolution=ReadBlobLSBShort(image); + pcx_info.vertical_resolution=ReadBlobLSBShort(image); + /* + Read PCX raster colormap. + */ + image->columns=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.right- + pcx_info.left)+1UL; + image->rows=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.bottom- + pcx_info.top)+1UL; + if ((image->columns == 0) || (image->rows == 0) || + (pcx_info.bits_per_pixel == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + image->depth=pcx_info.bits_per_pixel <= 8 ? 8U : MAGICKCORE_QUANTUM_DEPTH; + image->units=PixelsPerInchResolution; + image->x_resolution=(double) pcx_info.horizontal_resolution; + image->y_resolution=(double) pcx_info.vertical_resolution; + image->colors=16; + count=ReadBlob(image,3*image->colors,pcx_colormap); + pcx_info.reserved=(unsigned char) ReadBlobByte(image); + pcx_info.planes=(unsigned char) ReadBlobByte(image); + if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + one=1; + if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1)) + if ((pcx_info.version == 3) || (pcx_info.version == 5) || + ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)) + image->colors=(size_t) MagickMin(one << (1UL* + (pcx_info.bits_per_pixel*pcx_info.planes)),256UL); + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1)) + image->storage_class=DirectClass; + p=pcx_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } + pcx_info.bytes_per_line=ReadBlobLSBShort(image); + pcx_info.palette_info=ReadBlobLSBShort(image); + for (i=0; i < 58; i++) + (void) ReadBlobByte(image); + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + /* + Read image data. + */ + pcx_packets=(size_t) image->rows*pcx_info.bytes_per_line*pcx_info.planes; + if ((size_t) (pcx_info.bits_per_pixel*pcx_info.planes*image->columns) > + (pcx_packets*8U)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + scanline=(unsigned char *) AcquireQuantumMemory(MagickMax(image->columns, + pcx_info.bytes_per_line),MagickMax(8,pcx_info.planes)*sizeof(*scanline)); + pixel_info=AcquireVirtualMemory(pcx_packets,2*sizeof(*pixels)); + if ((scanline == (unsigned char *) NULL) || + (pixel_info == (MemoryInfo *) NULL)) + { + if (scanline != (unsigned char *) NULL) + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + if (pixel_info != (MemoryInfo *) NULL) + pixel_info=RelinquishVirtualMemory(pixel_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); + /* + Uncompress image data. + */ + p=pixels; + if (pcx_info.encoding == 0) + while (pcx_packets != 0) + { + packet=(unsigned char) ReadBlobByte(image); + if (EOFBlob(image) != MagickFalse) + ThrowPCXException(CorruptImageError,""UnexpectedEndOfFile""); + *p++=packet; + pcx_packets--; + } + else + while (pcx_packets != 0) + { + packet=(unsigned char) ReadBlobByte(image); + if (EOFBlob(image) != MagickFalse) + ThrowPCXException(CorruptImageError,""UnexpectedEndOfFile""); + if ((packet & 0xc0) != 0xc0) + { + *p++=packet; + pcx_packets--; + continue; + } + count=(ssize_t) (packet & 0x3f); + packet=(unsigned char) ReadBlobByte(image); + if (EOFBlob(image) != MagickFalse) + ThrowPCXException(CorruptImageError,""UnexpectedEndOfFile""); + for ( ; count != 0; count--) + { + *p++=packet; + pcx_packets--; + if (pcx_packets == 0) + break; + } + } + if (image->storage_class == DirectClass) + image->matte=pcx_info.planes > 3 ? MagickTrue : MagickFalse; + else + if ((pcx_info.version == 5) || + ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)) + { + /* + Initialize image colormap. + */ + if (image->colors > 256) + ThrowPCXException(CorruptImageError,""ColormapExceeds256Colors""); + if ((pcx_info.bits_per_pixel*pcx_info.planes) == 1) + { + /* + Monochrome colormap. + */ + image->colormap[0].red=(Quantum) 0; + image->colormap[0].green=(Quantum) 0; + image->colormap[0].blue=(Quantum) 0; + image->colormap[1].red=QuantumRange; + image->colormap[1].green=QuantumRange; + image->colormap[1].blue=QuantumRange; + } + else + if (image->colors > 16) + { + /* + 256 color images have their color map at the end of the file. + */ + pcx_info.colormap_signature=(unsigned char) ReadBlobByte(image); + count=ReadBlob(image,3*image->colors,pcx_colormap); + p=pcx_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } + } + } + /* + Convert PCX raster image to pixel packets. + */ + for (y=0; y < (ssize_t) image->rows; y++) + { + p=pixels+(y*pcx_info.bytes_per_line*pcx_info.planes); + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + r=scanline; + if (image->storage_class == DirectClass) + for (i=0; i < pcx_info.planes; i++) + { + r=scanline+i; + for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++) + { + switch (i) + { + case 0: + { + *r=(*p++); + break; + } + case 1: + { + *r=(*p++); + break; + } + case 2: + { + *r=(*p++); + break; + } + case 3: + default: + { + *r=(*p++); + break; + } + } + r+=pcx_info.planes; + } + } + else + if (pcx_info.planes > 1) + { + for (x=0; x < (ssize_t) image->columns; x++) + *r++=0; + for (i=0; i < pcx_info.planes; i++) + { + r=scanline; + for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++) + { + bits=(*p++); + for (mask=0x80; mask != 0; mask>>=1) + { + if (bits & mask) + *r|=1 << i; + r++; + } + } + } + } + else + switch (pcx_info.bits_per_pixel) + { + case 1: + { + register ssize_t + bit; + + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + for (bit=7; bit >= 0; bit--) + *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00); + p++; + } + if ((image->columns % 8) != 0) + { + for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--) + *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00); + p++; + } + break; + } + case 2: + { + for (x=0; x < ((ssize_t) image->columns-3); x+=4) + { + *r++=(*p >> 6) & 0x3; + *r++=(*p >> 4) & 0x3; + *r++=(*p >> 2) & 0x3; + *r++=(*p) & 0x3; + p++; + } + if ((image->columns % 4) != 0) + { + for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--) + *r++=(unsigned char) ((*p >> (i*2)) & 0x03); + p++; + } + break; + } + case 4: + { + for (x=0; x < ((ssize_t) image->columns-1); x+=2) + { + *r++=(*p >> 4) & 0xf; + *r++=(*p) & 0xf; + p++; + } + if ((image->columns % 2) != 0) + *r++=(*p++ >> 4) & 0xf; + break; + } + case 8: + { + (void) CopyMagickMemory(r,p,image->columns); + break; + } + default: + break; + } + /* + Transfer image scanline. + */ + r=scanline; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->storage_class == PseudoClass) + SetPixelIndex(indexes+x,*r++) + else + { + SetPixelRed(q,ScaleCharToQuantum(*r++)); + SetPixelGreen(q,ScaleCharToQuantum(*r++)); + SetPixelBlue(q,ScaleCharToQuantum(*r++)); + if (image->matte != MagickFalse) + SetPixelAlpha(q,ScaleCharToQuantum(*r++)); + } + q++; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (image->storage_class == PseudoClass) + (void) SyncImage(image); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + pixel_info=RelinquishVirtualMemory(pixel_info); + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + break; + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if (page_table == (MagickOffsetType *) NULL) + break; + if (page_table[id] == 0) + break; + offset=SeekBlob(image,(MagickOffsetType) page_table[id],SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + count=ReadBlob(image,1,&pcx_info.identifier); + if ((count != 0) && (pcx_info.identifier == 0x0a)) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } + if (page_table != (MagickOffsetType *) NULL) + page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception) +{ +#define ThrowPCXException(severity,tag) \ + { \ + scanline=(unsigned char *) RelinquishMagickMemory(scanline); \ + pixel_info=RelinquishVirtualMemory(pixel_info); \ + ThrowReaderException(severity,tag); \ + } + + Image + *image; + + int + bits, + id, + mask; + + MagickBooleanType + status; + + MagickOffsetType + offset, + *page_table; + + MemoryInfo + *pixel_info; + + PCXInfo + pcx_info; + + register IndexPacket + *indexes; + + register ssize_t + x; + + register PixelPacket + *q; + + register ssize_t + i; + + register unsigned char + *p, + *r; + + size_t + one, + pcx_packets; + + ssize_t + count, + y; + + unsigned char + packet, + pcx_colormap[768], + *pixels, + *scanline; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Determine if this a PCX file. + */ + page_table=(MagickOffsetType *) NULL; + if (LocaleCompare(image_info->magick,""DCX"") == 0) + { + size_t + magic; + + /* + Read the DCX page table. + */ + magic=ReadBlobLSBLong(image); + if (magic != 987654321) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + page_table=(MagickOffsetType *) AcquireQuantumMemory(1024UL, + sizeof(*page_table)); + if (page_table == (MagickOffsetType *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + for (id=0; id < 1024; id++) + { + page_table[id]=(MagickOffsetType) ReadBlobLSBLong(image); + if (page_table[id] == 0) + break; + } + } + if (page_table != (MagickOffsetType *) NULL) + { + offset=SeekBlob(image,(MagickOffsetType) page_table[0],SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + count=ReadBlob(image,1,&pcx_info.identifier); + for (id=1; id < 1024; id++) + { + int + bits_per_pixel; + + /* + Verify PCX identifier. + */ + pcx_info.version=(unsigned char) ReadBlobByte(image); + if ((count == 0) || (pcx_info.identifier != 0x0a)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + pcx_info.encoding=(unsigned char) ReadBlobByte(image); + bits_per_pixel=ReadBlobByte(image); + if (bits_per_pixel == -1) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + pcx_info.bits_per_pixel=(unsigned char) bits_per_pixel; + pcx_info.left=ReadBlobLSBShort(image); + pcx_info.top=ReadBlobLSBShort(image); + pcx_info.right=ReadBlobLSBShort(image); + pcx_info.bottom=ReadBlobLSBShort(image); + pcx_info.horizontal_resolution=ReadBlobLSBShort(image); + pcx_info.vertical_resolution=ReadBlobLSBShort(image); + /* + Read PCX raster colormap. + */ + image->columns=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.right- + pcx_info.left)+1UL; + image->rows=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.bottom- + pcx_info.top)+1UL; + if ((image->columns == 0) || (image->rows == 0) || + (pcx_info.bits_per_pixel == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + image->depth=pcx_info.bits_per_pixel <= 8 ? 8U : MAGICKCORE_QUANTUM_DEPTH; + image->units=PixelsPerInchResolution; + image->x_resolution=(double) pcx_info.horizontal_resolution; + image->y_resolution=(double) pcx_info.vertical_resolution; + image->colors=16; + count=ReadBlob(image,3*image->colors,pcx_colormap); + pcx_info.reserved=(unsigned char) ReadBlobByte(image); + pcx_info.planes=(unsigned char) ReadBlobByte(image); + if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + one=1; + if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1)) + if ((pcx_info.version == 3) || (pcx_info.version == 5) || + ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)) + image->colors=(size_t) MagickMin(one << (1UL* + (pcx_info.bits_per_pixel*pcx_info.planes)),256UL); + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1)) + image->storage_class=DirectClass; + p=pcx_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } + pcx_info.bytes_per_line=ReadBlobLSBShort(image); + pcx_info.palette_info=ReadBlobLSBShort(image); + for (i=0; i < 58; i++) + (void) ReadBlobByte(image); + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + /* + Read image data. + */ + pcx_packets=(size_t) image->rows*pcx_info.bytes_per_line*pcx_info.planes; + if ((size_t) (pcx_info.bits_per_pixel*pcx_info.planes*image->columns) > + (pcx_packets*8U)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + scanline=(unsigned char *) AcquireQuantumMemory(MagickMax(image->columns, + pcx_info.bytes_per_line),MagickMax(8,pcx_info.planes)*sizeof(*scanline)); + pixel_info=AcquireVirtualMemory(pcx_packets,2*sizeof(*pixels)); + if ((scanline == (unsigned char *) NULL) || + (pixel_info == (MemoryInfo *) NULL)) + { + if (scanline != (unsigned char *) NULL) + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + if (pixel_info != (MemoryInfo *) NULL) + pixel_info=RelinquishVirtualMemory(pixel_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); + /* + Uncompress image data. + */ + p=pixels; + if (pcx_info.encoding == 0) + while (pcx_packets != 0) + { + packet=(unsigned char) ReadBlobByte(image); + if (EOFBlob(image) != MagickFalse) + ThrowPCXException(CorruptImageError,""UnexpectedEndOfFile""); + *p++=packet; + pcx_packets--; + } + else + while (pcx_packets != 0) + { + packet=(unsigned char) ReadBlobByte(image); + if (EOFBlob(image) != MagickFalse) + ThrowPCXException(CorruptImageError,""UnexpectedEndOfFile""); + if ((packet & 0xc0) != 0xc0) + { + *p++=packet; + pcx_packets--; + continue; + } + count=(ssize_t) (packet & 0x3f); + packet=(unsigned char) ReadBlobByte(image); + if (EOFBlob(image) != MagickFalse) + ThrowPCXException(CorruptImageError,""UnexpectedEndOfFile""); + for ( ; count != 0; count--) + { + *p++=packet; + pcx_packets--; + if (pcx_packets == 0) + break; + } + } + if (image->storage_class == DirectClass) + image->matte=pcx_info.planes > 3 ? MagickTrue : MagickFalse; + else + if ((pcx_info.version == 5) || + ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)) + { + /* + Initialize image colormap. + */ + if (image->colors > 256) + ThrowPCXException(CorruptImageError,""ColormapExceeds256Colors""); + if ((pcx_info.bits_per_pixel*pcx_info.planes) == 1) + { + /* + Monochrome colormap. + */ + image->colormap[0].red=(Quantum) 0; + image->colormap[0].green=(Quantum) 0; + image->colormap[0].blue=(Quantum) 0; + image->colormap[1].red=QuantumRange; + image->colormap[1].green=QuantumRange; + image->colormap[1].blue=QuantumRange; + } + else + if (image->colors > 16) + { + /* + 256 color images have their color map at the end of the file. + */ + pcx_info.colormap_signature=(unsigned char) ReadBlobByte(image); + count=ReadBlob(image,3*image->colors,pcx_colormap); + p=pcx_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ScaleCharToQuantum(*p++); + image->colormap[i].green=ScaleCharToQuantum(*p++); + image->colormap[i].blue=ScaleCharToQuantum(*p++); + } + } + } + /* + Convert PCX raster image to pixel packets. + */ + for (y=0; y < (ssize_t) image->rows; y++) + { + p=pixels+(y*pcx_info.bytes_per_line*pcx_info.planes); + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + r=scanline; + if (image->storage_class == DirectClass) + for (i=0; i < pcx_info.planes; i++) + { + r=scanline+i; + for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++) + { + switch (i) + { + case 0: + { + *r=(*p++); + break; + } + case 1: + { + *r=(*p++); + break; + } + case 2: + { + *r=(*p++); + break; + } + case 3: + default: + { + *r=(*p++); + break; + } + } + r+=pcx_info.planes; + } + } + else + if (pcx_info.planes > 1) + { + for (x=0; x < (ssize_t) image->columns; x++) + *r++=0; + for (i=0; i < pcx_info.planes; i++) + { + r=scanline; + for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++) + { + bits=(*p++); + for (mask=0x80; mask != 0; mask>>=1) + { + if (bits & mask) + *r|=1 << i; + r++; + } + } + } + } + else + switch (pcx_info.bits_per_pixel) + { + case 1: + { + register ssize_t + bit; + + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + for (bit=7; bit >= 0; bit--) + *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00); + p++; + } + if ((image->columns % 8) != 0) + { + for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--) + *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00); + p++; + } + break; + } + case 2: + { + for (x=0; x < ((ssize_t) image->columns-3); x+=4) + { + *r++=(*p >> 6) & 0x3; + *r++=(*p >> 4) & 0x3; + *r++=(*p >> 2) & 0x3; + *r++=(*p) & 0x3; + p++; + } + if ((image->columns % 4) != 0) + { + for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--) + *r++=(unsigned char) ((*p >> (i*2)) & 0x03); + p++; + } + break; + } + case 4: + { + for (x=0; x < ((ssize_t) image->columns-1); x+=2) + { + *r++=(*p >> 4) & 0xf; + *r++=(*p) & 0xf; + p++; + } + if ((image->columns % 2) != 0) + *r++=(*p++ >> 4) & 0xf; + break; + } + case 8: + { + (void) CopyMagickMemory(r,p,image->columns); + break; + } + default: + break; + } + /* + Transfer image scanline. + */ + r=scanline; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->storage_class == PseudoClass) + SetPixelIndex(indexes+x,*r++) + else + { + SetPixelRed(q,ScaleCharToQuantum(*r++)); + SetPixelGreen(q,ScaleCharToQuantum(*r++)); + SetPixelBlue(q,ScaleCharToQuantum(*r++)); + if (image->matte != MagickFalse) + SetPixelAlpha(q,ScaleCharToQuantum(*r++)); + } + q++; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (image->storage_class == PseudoClass) + (void) SyncImage(image); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + pixel_info=RelinquishVirtualMemory(pixel_info); + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError,""UnexpectedEndOfFile"", + image->filename); + break; + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if (page_table == (MagickOffsetType *) NULL) + break; + if (page_table[id] == 0) + break; + offset=SeekBlob(image,(MagickOffsetType) page_table[id],SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + count=ReadBlob(image,1,&pcx_info.identifier); + if ((count != 0) && (pcx_info.identifier == 0x0a)) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } + if (page_table != (MagickOffsetType *) NULL) + page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table); + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -395,6 +395,12 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception) + if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + /* + Read image data. + */",3951,4187,6144 +18130,"int yr_execute_code( + YR_RULES* rules, + YR_SCAN_CONTEXT* context, + int timeout, + time_t start_time) +{ + int64_t mem[MEM_SIZE]; + int32_t sp = 0; + uint8_t* ip = rules->code_start; + + YR_VALUE args[MAX_FUNCTION_ARGS]; + YR_VALUE *stack; + YR_VALUE r1; + YR_VALUE r2; + YR_VALUE r3; + + #ifdef PROFILING_ENABLED + YR_RULE* current_rule = NULL; + #endif + + YR_RULE* rule; + YR_MATCH* match; + YR_OBJECT_FUNCTION* function; + + char* identifier; + char* args_fmt; + + int i; + int found; + int count; + int result = ERROR_SUCCESS; + int stop = FALSE; + int cycle = 0; + int tidx = context->tidx; + int stack_size; + + #ifdef PROFILING_ENABLED + clock_t start = clock(); + #endif + + yr_get_configuration(YR_CONFIG_STACK_SIZE, (void*) &stack_size); + + stack = (YR_VALUE*) yr_malloc(stack_size * sizeof(YR_VALUE)); + + if (stack == NULL) + return ERROR_INSUFFICIENT_MEMORY; + + while(!stop) + { + switch(*ip) + { + case OP_NOP: + break; + + case OP_HALT: + assert(sp == 0); // When HALT is reached the stack should be empty. + stop = TRUE; + break; + + case OP_PUSH: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + push(r1); + break; + + case OP_POP: + pop(r1); + break; + + case OP_CLEAR_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + mem[r1.i] = 0; + break; + + case OP_ADD_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + pop(r2); + if (!is_undef(r2)) + mem[r1.i] += r2.i; + break; + + case OP_INCR_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + mem[r1.i]++; + break; + + case OP_PUSH_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + r1.i = mem[r1.i]; + push(r1); + break; + + case OP_POP_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + pop(r2); + mem[r1.i] = r2.i; + break; + + case OP_SWAPUNDEF: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + pop(r2); + + if (is_undef(r2)) + { + r1.i = mem[r1.i]; + push(r1); + } + else + { + push(r2); + } + break; + + case OP_JNUNDEF: + pop(r1); + push(r1); + + ip = jmp_if(!is_undef(r1), ip); + break; + + case OP_JLE: + pop(r2); + pop(r1); + push(r1); + push(r2); + + ip = jmp_if(r1.i <= r2.i, ip); + break; + + case OP_JTRUE: + pop(r1); + push(r1); + + ip = jmp_if(!is_undef(r1) && r1.i, ip); + break; + + case OP_JFALSE: + pop(r1); + push(r1); + + ip = jmp_if(is_undef(r1) || !r1.i, ip); + break; + + case OP_AND: + pop(r2); + pop(r1); + + if (is_undef(r1) || is_undef(r2)) + r1.i = 0; + else + r1.i = r1.i && r2.i; + + push(r1); + break; + + case OP_OR: + pop(r2); + pop(r1); + + if (is_undef(r1)) + { + push(r2); + } + else if (is_undef(r2)) + { + push(r1); + } + else + { + r1.i = r1.i || r2.i; + push(r1); + } + break; + + case OP_NOT: + pop(r1); + + if (is_undef(r1)) + r1.i = UNDEFINED; + else + r1.i= !r1.i; + + push(r1); + break; + + case OP_MOD: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + if (r2.i != 0) + r1.i = r1.i % r2.i; + else + r1.i = UNDEFINED; + push(r1); + break; + + case OP_SHR: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i >> r2.i; + push(r1); + break; + + case OP_SHL: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i << r2.i; + push(r1); + break; + + case OP_BITWISE_NOT: + pop(r1); + ensure_defined(r1); + r1.i = ~r1.i; + push(r1); + break; + + case OP_BITWISE_AND: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i & r2.i; + push(r1); + break; + + case OP_BITWISE_OR: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i | r2.i; + push(r1); + break; + + case OP_BITWISE_XOR: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i ^ r2.i; + push(r1); + break; + + case OP_PUSH_RULE: + rule = *(YR_RULE**)(ip + 1); + ip += sizeof(uint64_t); + r1.i = rule->t_flags[tidx] & RULE_TFLAGS_MATCH ? 1 : 0; + push(r1); + break; + + case OP_INIT_RULE: + #ifdef PROFILING_ENABLED + current_rule = *(YR_RULE**)(ip + 1); + #endif + ip += sizeof(uint64_t); + break; + + case OP_MATCH_RULE: + pop(r1); + rule = *(YR_RULE**)(ip + 1); + ip += sizeof(uint64_t); + + if (!is_undef(r1) && r1.i) + rule->t_flags[tidx] |= RULE_TFLAGS_MATCH; + else if (RULE_IS_GLOBAL(rule)) + rule->ns->t_flags[tidx] |= NAMESPACE_TFLAGS_UNSATISFIED_GLOBAL; + + #ifdef PROFILING_ENABLED + rule->clock_ticks += clock() - start; + start = clock(); + #endif + break; + + case OP_OBJ_LOAD: + identifier = *(char**)(ip + 1); + ip += sizeof(uint64_t); + + r1.o = (YR_OBJECT*) yr_hash_table_lookup( + context->objects_table, + identifier, + NULL); + + assert(r1.o != NULL); + push(r1); + break; + + case OP_OBJ_FIELD: + identifier = *(char**)(ip + 1); + ip += sizeof(uint64_t); + + pop(r1); + ensure_defined(r1); + + r1.o = yr_object_lookup_field(r1.o, identifier); + + assert(r1.o != NULL); + push(r1); + break; + + case OP_OBJ_VALUE: + pop(r1); + ensure_defined(r1); + + switch(r1.o->type) + { + case OBJECT_TYPE_INTEGER: + r1.i = ((YR_OBJECT_INTEGER*) r1.o)->value; + break; + + case OBJECT_TYPE_FLOAT: + if (isnan(((YR_OBJECT_DOUBLE*) r1.o)->value)) + r1.i = UNDEFINED; + else + r1.d = ((YR_OBJECT_DOUBLE*) r1.o)->value; + break; + + case OBJECT_TYPE_STRING: + if (((YR_OBJECT_STRING*) r1.o)->value == NULL) + r1.i = UNDEFINED; + else + r1.p = ((YR_OBJECT_STRING*) r1.o)->value; + break; + + default: + assert(FALSE); + } + + push(r1); + break; + + case OP_INDEX_ARRAY: + pop(r1); // index + pop(r2); // array + + ensure_defined(r1); + ensure_defined(r2); + assert(r2.o->type == OBJECT_TYPE_ARRAY); + + r1.o = yr_object_array_get_item(r2.o, 0, (int) r1.i); + + if (r1.o == NULL) + r1.i = UNDEFINED; + + push(r1); + break; + + case OP_LOOKUP_DICT: + pop(r1); // key + pop(r2); // dictionary + + ensure_defined(r1); + ensure_defined(r2); + assert(r2.o->type == OBJECT_TYPE_DICTIONARY); + + r1.o = yr_object_dict_get_item( + r2.o, 0, r1.ss->c_string); + + if (r1.o == NULL) + r1.i = UNDEFINED; + + push(r1); + break; + + case OP_CALL: + args_fmt = *(char**)(ip + 1); + ip += sizeof(uint64_t); + + i = (int) strlen(args_fmt); + count = 0; + + + while (i > 0) + { + pop(r1); + + if (is_undef(r1)) // count the number of undefined args + count++; + + args[i - 1] = r1; + i--; + } + + pop(r2); + ensure_defined(r2); + + if (count > 0) + { + + r1.i = UNDEFINED; + push(r1); + break; + } + + function = (YR_OBJECT_FUNCTION*) r2.o; + result = ERROR_INTERNAL_FATAL_ERROR; + + for (i = 0; i < MAX_OVERLOADED_FUNCTIONS; i++) + { + if (function->prototypes[i].arguments_fmt == NULL) + break; + + if (strcmp(function->prototypes[i].arguments_fmt, args_fmt) == 0) + { + result = function->prototypes[i].code(args, context, function); + break; + } + } + + assert(i < MAX_OVERLOADED_FUNCTIONS); + + if (result == ERROR_SUCCESS) + { + r1.o = function->return_obj; + push(r1); + } + else + { + stop = TRUE; + } + + break; + + case OP_FOUND: + pop(r1); + r1.i = r1.s->matches[tidx].tail != NULL ? 1 : 0; + push(r1); + break; + + case OP_FOUND_AT: + pop(r2); + pop(r1); + + if (is_undef(r1)) + { + r1.i = 0; + push(r1); + break; + } + + match = r2.s->matches[tidx].head; + r3.i = FALSE; + + while (match != NULL) + { + if (r1.i == match->base + match->offset) + { + r3.i = TRUE; + break; + } + + if (r1.i < match->base + match->offset) + break; + + match = match->next; + } + + push(r3); + break; + + case OP_FOUND_IN: + pop(r3); + pop(r2); + pop(r1); + + ensure_defined(r1); + ensure_defined(r2); + + match = r3.s->matches[tidx].head; + r3.i = FALSE; + + while (match != NULL && !r3.i) + { + if (match->base + match->offset >= r1.i && + match->base + match->offset <= r2.i) + { + r3.i = TRUE; + } + + if (match->base + match->offset > r2.i) + break; + + match = match->next; + } + + push(r3); + break; + + case OP_COUNT: + pop(r1); + r1.i = r1.s->matches[tidx].count; + push(r1); + break; + + case OP_OFFSET: + pop(r2); + pop(r1); + + ensure_defined(r1); + + match = r2.s->matches[tidx].head; + i = 1; + r3.i = UNDEFINED; + + while (match != NULL && r3.i == UNDEFINED) + { + if (r1.i == i) + r3.i = match->base + match->offset; + + i++; + match = match->next; + } + + push(r3); + break; + + case OP_LENGTH: + pop(r2); + pop(r1); + + ensure_defined(r1); + + match = r2.s->matches[tidx].head; + i = 1; + r3.i = UNDEFINED; + + while (match != NULL && r3.i == UNDEFINED) + { + if (r1.i == i) + r3.i = match->match_length; + + i++; + match = match->next; + } + + push(r3); + break; + + case OP_OF: + found = 0; + count = 0; + pop(r1); + + while (!is_undef(r1)) + { + if (r1.s->matches[tidx].tail != NULL) + found++; + count++; + pop(r1); + } + + pop(r2); + + if (is_undef(r2)) + r1.i = found >= count ? 1 : 0; + else + r1.i = found >= r2.i ? 1 : 0; + + push(r1); + break; + + case OP_FILESIZE: + r1.i = context->file_size; + push(r1); + break; + + case OP_ENTRYPOINT: + r1.i = context->entry_point; + push(r1); + break; + + case OP_INT8: + pop(r1); + r1.i = read_int8_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT16: + pop(r1); + r1.i = read_int16_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT32: + pop(r1); + r1.i = read_int32_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT8: + pop(r1); + r1.i = read_uint8_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT16: + pop(r1); + r1.i = read_uint16_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT32: + pop(r1); + r1.i = read_uint32_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT8BE: + pop(r1); + r1.i = read_int8_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT16BE: + pop(r1); + r1.i = read_int16_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT32BE: + pop(r1); + r1.i = read_int32_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT8BE: + pop(r1); + r1.i = read_uint8_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT16BE: + pop(r1); + r1.i = read_uint16_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT32BE: + pop(r1); + r1.i = read_uint32_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_CONTAINS: + pop(r2); + pop(r1); + + ensure_defined(r1); + ensure_defined(r2); + + r1.i = memmem(r1.ss->c_string, r1.ss->length, + r2.ss->c_string, r2.ss->length) != NULL; + push(r1); + break; + + case OP_IMPORT: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + + result = yr_modules_load((char*) r1.p, context); + + if (result != ERROR_SUCCESS) + stop = TRUE; + + break; + + case OP_MATCHES: + + pop(r2); + pop(r1); + + ensure_defined(r2); + ensure_defined(r1); + + if (r1.ss->length == 0) + { + r1.i = FALSE; + push(r1); + break; + } + + result = yr_re_exec( + (uint8_t*) r2.re->code, + (uint8_t*) r1.ss->c_string, + r1.ss->length, + 0, + r2.re->flags | RE_FLAGS_SCAN, + NULL, + NULL, + &found); + + if (result != ERROR_SUCCESS) + stop = TRUE; + + r1.i = found >= 0; + push(r1); + break; + + case OP_INT_TO_DBL: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + r2 = stack[sp - r1.i]; + if (is_undef(r2)) + stack[sp - r1.i].i = UNDEFINED; + else + stack[sp - r1.i].d = (double) r2.i; + break; + + case OP_STR_TO_BOOL: + pop(r1); + ensure_defined(r1); + r1.i = r1.ss->length > 0; + push(r1); + break; + + case OP_INT_EQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i == r2.i; + push(r1); + break; + + case OP_INT_NEQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i != r2.i; + push(r1); + break; + + case OP_INT_LT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i < r2.i; + push(r1); + break; + + case OP_INT_GT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i > r2.i; + push(r1); + break; + + case OP_INT_LE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i <= r2.i; + push(r1); + break; + + case OP_INT_GE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i >= r2.i; + push(r1); + break; + + case OP_INT_ADD: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i + r2.i; + push(r1); + break; + + case OP_INT_SUB: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i - r2.i; + push(r1); + break; + + case OP_INT_MUL: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i * r2.i; + push(r1); + break; + + case OP_INT_DIV: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + if (r2.i != 0) + r1.i = r1.i / r2.i; + else + r1.i = UNDEFINED; + push(r1); + break; + + case OP_INT_MINUS: + pop(r1); + ensure_defined(r1); + r1.i = -r1.i; + push(r1); + break; + + case OP_DBL_LT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d < r2.d; + push(r1); + break; + + case OP_DBL_GT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d > r2.d; + push(r1); + break; + + case OP_DBL_LE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d <= r2.d; + push(r1); + break; + + case OP_DBL_GE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d >= r2.d; + push(r1); + break; + + case OP_DBL_EQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d == r2.d; + push(r1); + break; + + case OP_DBL_NEQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d != r2.d; + push(r1); + break; + + case OP_DBL_ADD: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d + r2.d; + push(r1); + break; + + case OP_DBL_SUB: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d - r2.d; + push(r1); + break; + + case OP_DBL_MUL: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d * r2.d; + push(r1); + break; + + case OP_DBL_DIV: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d / r2.d; + push(r1); + break; + + case OP_DBL_MINUS: + pop(r1); + ensure_defined(r1); + r1.d = -r1.d; + push(r1); + break; + + case OP_STR_EQ: + case OP_STR_NEQ: + case OP_STR_LT: + case OP_STR_LE: + case OP_STR_GT: + case OP_STR_GE: + + pop(r2); + pop(r1); + + ensure_defined(r1); + ensure_defined(r2); + + switch(*ip) + { + case OP_STR_EQ: + r1.i = (sized_string_cmp(r1.ss, r2.ss) == 0); + break; + case OP_STR_NEQ: + r1.i = (sized_string_cmp(r1.ss, r2.ss) != 0); + break; + case OP_STR_LT: + r1.i = (sized_string_cmp(r1.ss, r2.ss) < 0); + break; + case OP_STR_LE: + r1.i = (sized_string_cmp(r1.ss, r2.ss) <= 0); + break; + case OP_STR_GT: + r1.i = (sized_string_cmp(r1.ss, r2.ss) > 0); + break; + case OP_STR_GE: + r1.i = (sized_string_cmp(r1.ss, r2.ss) >= 0); + break; + } + + push(r1); + break; + + default: + assert(FALSE); + } + + if (timeout > 0) // timeout == 0 means no timeout + { + + if (++cycle == 10) + { + if (difftime(time(NULL), start_time) > timeout) + { + #ifdef PROFILING_ENABLED + assert(current_rule != NULL); + current_rule->clock_ticks += clock() - start; + #endif + result = ERROR_SCAN_TIMEOUT; + stop = TRUE; + } + + cycle = 0; + } + } + + ip++; + } + + yr_modules_unload_all(context); + yr_free(stack); + + return result; +} +",1,"int yr_execute_code( + YR_RULES* rules, + YR_SCAN_CONTEXT* context, + int timeout, + time_t start_time) +{ + int64_t mem[MEM_SIZE]; + int32_t sp = 0; + uint8_t* ip = rules->code_start; + + YR_VALUE args[MAX_FUNCTION_ARGS]; + YR_VALUE *stack; + YR_VALUE r1; + YR_VALUE r2; + YR_VALUE r3; + + #ifdef PROFILING_ENABLED + YR_RULE* current_rule = NULL; + #endif + + YR_RULE* rule; + YR_MATCH* match; + YR_OBJECT_FUNCTION* function; + YR_OBJECT** obj_ptr; + YR_ARENA* obj_arena; + + char* identifier; + char* args_fmt; + + int i; + int found; + int count; + int result = ERROR_SUCCESS; + int stop = FALSE; + int cycle = 0; + int tidx = context->tidx; + int stack_size; + + #ifdef PROFILING_ENABLED + clock_t start = clock(); + #endif + + yr_get_configuration(YR_CONFIG_STACK_SIZE, (void*) &stack_size); + + stack = (YR_VALUE*) yr_malloc(stack_size * sizeof(YR_VALUE)); + + if (stack == NULL) + return ERROR_INSUFFICIENT_MEMORY; + + FAIL_ON_ERROR_WITH_CLEANUP( + yr_arena_create(1024, 0, &obj_arena), + yr_free(stack)); + + while(!stop) + { + switch(*ip) + { + case OP_NOP: + break; + + case OP_HALT: + assert(sp == 0); // When HALT is reached the stack should be empty. + stop = TRUE; + break; + + case OP_PUSH: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + push(r1); + break; + + case OP_POP: + pop(r1); + break; + + case OP_CLEAR_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + mem[r1.i] = 0; + break; + + case OP_ADD_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + pop(r2); + if (!is_undef(r2)) + mem[r1.i] += r2.i; + break; + + case OP_INCR_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + mem[r1.i]++; + break; + + case OP_PUSH_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + r1.i = mem[r1.i]; + push(r1); + break; + + case OP_POP_M: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + pop(r2); + mem[r1.i] = r2.i; + break; + + case OP_SWAPUNDEF: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + pop(r2); + + if (is_undef(r2)) + { + r1.i = mem[r1.i]; + push(r1); + } + else + { + push(r2); + } + break; + + case OP_JNUNDEF: + pop(r1); + push(r1); + + ip = jmp_if(!is_undef(r1), ip); + break; + + case OP_JLE: + pop(r2); + pop(r1); + push(r1); + push(r2); + + ip = jmp_if(r1.i <= r2.i, ip); + break; + + case OP_JTRUE: + pop(r1); + push(r1); + + ip = jmp_if(!is_undef(r1) && r1.i, ip); + break; + + case OP_JFALSE: + pop(r1); + push(r1); + + ip = jmp_if(is_undef(r1) || !r1.i, ip); + break; + + case OP_AND: + pop(r2); + pop(r1); + + if (is_undef(r1) || is_undef(r2)) + r1.i = 0; + else + r1.i = r1.i && r2.i; + + push(r1); + break; + + case OP_OR: + pop(r2); + pop(r1); + + if (is_undef(r1)) + { + push(r2); + } + else if (is_undef(r2)) + { + push(r1); + } + else + { + r1.i = r1.i || r2.i; + push(r1); + } + break; + + case OP_NOT: + pop(r1); + + if (is_undef(r1)) + r1.i = UNDEFINED; + else + r1.i= !r1.i; + + push(r1); + break; + + case OP_MOD: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + if (r2.i != 0) + r1.i = r1.i % r2.i; + else + r1.i = UNDEFINED; + push(r1); + break; + + case OP_SHR: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i >> r2.i; + push(r1); + break; + + case OP_SHL: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i << r2.i; + push(r1); + break; + + case OP_BITWISE_NOT: + pop(r1); + ensure_defined(r1); + r1.i = ~r1.i; + push(r1); + break; + + case OP_BITWISE_AND: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i & r2.i; + push(r1); + break; + + case OP_BITWISE_OR: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i | r2.i; + push(r1); + break; + + case OP_BITWISE_XOR: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i ^ r2.i; + push(r1); + break; + + case OP_PUSH_RULE: + rule = *(YR_RULE**)(ip + 1); + ip += sizeof(uint64_t); + r1.i = rule->t_flags[tidx] & RULE_TFLAGS_MATCH ? 1 : 0; + push(r1); + break; + + case OP_INIT_RULE: + #ifdef PROFILING_ENABLED + current_rule = *(YR_RULE**)(ip + 1); + #endif + ip += sizeof(uint64_t); + break; + + case OP_MATCH_RULE: + pop(r1); + rule = *(YR_RULE**)(ip + 1); + ip += sizeof(uint64_t); + + if (!is_undef(r1) && r1.i) + rule->t_flags[tidx] |= RULE_TFLAGS_MATCH; + else if (RULE_IS_GLOBAL(rule)) + rule->ns->t_flags[tidx] |= NAMESPACE_TFLAGS_UNSATISFIED_GLOBAL; + + #ifdef PROFILING_ENABLED + rule->clock_ticks += clock() - start; + start = clock(); + #endif + + assert(sp == 0); + break; + + case OP_OBJ_LOAD: + identifier = *(char**)(ip + 1); + ip += sizeof(uint64_t); + + r1.o = (YR_OBJECT*) yr_hash_table_lookup( + context->objects_table, + identifier, + NULL); + + assert(r1.o != NULL); + push(r1); + break; + + case OP_OBJ_FIELD: + identifier = *(char**)(ip + 1); + ip += sizeof(uint64_t); + + pop(r1); + ensure_defined(r1); + + r1.o = yr_object_lookup_field(r1.o, identifier); + + assert(r1.o != NULL); + push(r1); + break; + + case OP_OBJ_VALUE: + pop(r1); + ensure_defined(r1); + + switch(r1.o->type) + { + case OBJECT_TYPE_INTEGER: + r1.i = ((YR_OBJECT_INTEGER*) r1.o)->value; + break; + + case OBJECT_TYPE_FLOAT: + if (isnan(((YR_OBJECT_DOUBLE*) r1.o)->value)) + r1.i = UNDEFINED; + else + r1.d = ((YR_OBJECT_DOUBLE*) r1.o)->value; + break; + + case OBJECT_TYPE_STRING: + if (((YR_OBJECT_STRING*) r1.o)->value == NULL) + r1.i = UNDEFINED; + else + r1.p = ((YR_OBJECT_STRING*) r1.o)->value; + break; + + default: + assert(FALSE); + } + + push(r1); + break; + + case OP_INDEX_ARRAY: + pop(r1); // index + pop(r2); // array + + ensure_defined(r1); + ensure_defined(r2); + assert(r2.o->type == OBJECT_TYPE_ARRAY); + + r1.o = yr_object_array_get_item(r2.o, 0, (int) r1.i); + + if (r1.o == NULL) + r1.i = UNDEFINED; + + push(r1); + break; + + case OP_LOOKUP_DICT: + pop(r1); // key + pop(r2); // dictionary + + ensure_defined(r1); + ensure_defined(r2); + assert(r2.o->type == OBJECT_TYPE_DICTIONARY); + + r1.o = yr_object_dict_get_item( + r2.o, 0, r1.ss->c_string); + + if (r1.o == NULL) + r1.i = UNDEFINED; + + push(r1); + break; + + case OP_CALL: + args_fmt = *(char**)(ip + 1); + ip += sizeof(uint64_t); + + i = (int) strlen(args_fmt); + count = 0; + + + while (i > 0) + { + pop(r1); + + if (is_undef(r1)) // count the number of undefined args + count++; + + args[i - 1] = r1; + i--; + } + + pop(r2); + ensure_defined(r2); + + if (count > 0) + { + + r1.i = UNDEFINED; + push(r1); + break; + } + + function = (YR_OBJECT_FUNCTION*) r2.o; + result = ERROR_INTERNAL_FATAL_ERROR; + + for (i = 0; i < MAX_OVERLOADED_FUNCTIONS; i++) + { + if (function->prototypes[i].arguments_fmt == NULL) + break; + + if (strcmp(function->prototypes[i].arguments_fmt, args_fmt) == 0) + { + result = function->prototypes[i].code(args, context, function); + break; + } + } + + // if i == MAX_OVERLOADED_FUNCTIONS at this point no matching + // prototype was found, but this shouldn't happen. + + assert(i < MAX_OVERLOADED_FUNCTIONS); + + // make a copy of the returned object and push the copy into the stack + // function->return_obj can't be pushed because it can change in + // subsequent calls to the same function. + + if (result == ERROR_SUCCESS) + result = yr_object_copy(function->return_obj, &r1.o); + + // a pointer to the copied object is stored in a arena in order to + // free the object before exiting yr_execute_code + + if (result == ERROR_SUCCESS) + result = yr_arena_write_data(obj_arena, &r1.o, sizeof(r1.o), NULL); + + stop = (result != ERROR_SUCCESS); + push(r1); + break; + + case OP_FOUND: + pop(r1); + r1.i = r1.s->matches[tidx].tail != NULL ? 1 : 0; + push(r1); + break; + + case OP_FOUND_AT: + pop(r2); + pop(r1); + + if (is_undef(r1)) + { + r1.i = 0; + push(r1); + break; + } + + match = r2.s->matches[tidx].head; + r3.i = FALSE; + + while (match != NULL) + { + if (r1.i == match->base + match->offset) + { + r3.i = TRUE; + break; + } + + if (r1.i < match->base + match->offset) + break; + + match = match->next; + } + + push(r3); + break; + + case OP_FOUND_IN: + pop(r3); + pop(r2); + pop(r1); + + ensure_defined(r1); + ensure_defined(r2); + + match = r3.s->matches[tidx].head; + r3.i = FALSE; + + while (match != NULL && !r3.i) + { + if (match->base + match->offset >= r1.i && + match->base + match->offset <= r2.i) + { + r3.i = TRUE; + } + + if (match->base + match->offset > r2.i) + break; + + match = match->next; + } + + push(r3); + break; + + case OP_COUNT: + pop(r1); + r1.i = r1.s->matches[tidx].count; + push(r1); + break; + + case OP_OFFSET: + pop(r2); + pop(r1); + + ensure_defined(r1); + + match = r2.s->matches[tidx].head; + i = 1; + r3.i = UNDEFINED; + + while (match != NULL && r3.i == UNDEFINED) + { + if (r1.i == i) + r3.i = match->base + match->offset; + + i++; + match = match->next; + } + + push(r3); + break; + + case OP_LENGTH: + pop(r2); + pop(r1); + + ensure_defined(r1); + + match = r2.s->matches[tidx].head; + i = 1; + r3.i = UNDEFINED; + + while (match != NULL && r3.i == UNDEFINED) + { + if (r1.i == i) + r3.i = match->match_length; + + i++; + match = match->next; + } + + push(r3); + break; + + case OP_OF: + found = 0; + count = 0; + pop(r1); + + while (!is_undef(r1)) + { + if (r1.s->matches[tidx].tail != NULL) + found++; + count++; + pop(r1); + } + + pop(r2); + + if (is_undef(r2)) + r1.i = found >= count ? 1 : 0; + else + r1.i = found >= r2.i ? 1 : 0; + + push(r1); + break; + + case OP_FILESIZE: + r1.i = context->file_size; + push(r1); + break; + + case OP_ENTRYPOINT: + r1.i = context->entry_point; + push(r1); + break; + + case OP_INT8: + pop(r1); + r1.i = read_int8_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT16: + pop(r1); + r1.i = read_int16_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT32: + pop(r1); + r1.i = read_int32_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT8: + pop(r1); + r1.i = read_uint8_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT16: + pop(r1); + r1.i = read_uint16_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT32: + pop(r1); + r1.i = read_uint32_t_little_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT8BE: + pop(r1); + r1.i = read_int8_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT16BE: + pop(r1); + r1.i = read_int16_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_INT32BE: + pop(r1); + r1.i = read_int32_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT8BE: + pop(r1); + r1.i = read_uint8_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT16BE: + pop(r1); + r1.i = read_uint16_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_UINT32BE: + pop(r1); + r1.i = read_uint32_t_big_endian(context->iterator, (size_t) r1.i); + push(r1); + break; + + case OP_CONTAINS: + pop(r2); + pop(r1); + + ensure_defined(r1); + ensure_defined(r2); + + r1.i = memmem(r1.ss->c_string, r1.ss->length, + r2.ss->c_string, r2.ss->length) != NULL; + push(r1); + break; + + case OP_IMPORT: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + + result = yr_modules_load((char*) r1.p, context); + + if (result != ERROR_SUCCESS) + stop = TRUE; + + break; + + case OP_MATCHES: + + pop(r2); + pop(r1); + + ensure_defined(r2); + ensure_defined(r1); + + if (r1.ss->length == 0) + { + r1.i = FALSE; + push(r1); + break; + } + + result = yr_re_exec( + (uint8_t*) r2.re->code, + (uint8_t*) r1.ss->c_string, + r1.ss->length, + 0, + r2.re->flags | RE_FLAGS_SCAN, + NULL, + NULL, + &found); + + if (result != ERROR_SUCCESS) + stop = TRUE; + + r1.i = found >= 0; + push(r1); + break; + + case OP_INT_TO_DBL: + r1.i = *(uint64_t*)(ip + 1); + ip += sizeof(uint64_t); + r2 = stack[sp - r1.i]; + if (is_undef(r2)) + stack[sp - r1.i].i = UNDEFINED; + else + stack[sp - r1.i].d = (double) r2.i; + break; + + case OP_STR_TO_BOOL: + pop(r1); + ensure_defined(r1); + r1.i = r1.ss->length > 0; + push(r1); + break; + + case OP_INT_EQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i == r2.i; + push(r1); + break; + + case OP_INT_NEQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i != r2.i; + push(r1); + break; + + case OP_INT_LT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i < r2.i; + push(r1); + break; + + case OP_INT_GT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i > r2.i; + push(r1); + break; + + case OP_INT_LE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i <= r2.i; + push(r1); + break; + + case OP_INT_GE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i >= r2.i; + push(r1); + break; + + case OP_INT_ADD: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i + r2.i; + push(r1); + break; + + case OP_INT_SUB: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i - r2.i; + push(r1); + break; + + case OP_INT_MUL: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.i * r2.i; + push(r1); + break; + + case OP_INT_DIV: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + if (r2.i != 0) + r1.i = r1.i / r2.i; + else + r1.i = UNDEFINED; + push(r1); + break; + + case OP_INT_MINUS: + pop(r1); + ensure_defined(r1); + r1.i = -r1.i; + push(r1); + break; + + case OP_DBL_LT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d < r2.d; + push(r1); + break; + + case OP_DBL_GT: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d > r2.d; + push(r1); + break; + + case OP_DBL_LE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d <= r2.d; + push(r1); + break; + + case OP_DBL_GE: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d >= r2.d; + push(r1); + break; + + case OP_DBL_EQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d == r2.d; + push(r1); + break; + + case OP_DBL_NEQ: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.i = r1.d != r2.d; + push(r1); + break; + + case OP_DBL_ADD: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d + r2.d; + push(r1); + break; + + case OP_DBL_SUB: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d - r2.d; + push(r1); + break; + + case OP_DBL_MUL: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d * r2.d; + push(r1); + break; + + case OP_DBL_DIV: + pop(r2); + pop(r1); + ensure_defined(r2); + ensure_defined(r1); + r1.d = r1.d / r2.d; + push(r1); + break; + + case OP_DBL_MINUS: + pop(r1); + ensure_defined(r1); + r1.d = -r1.d; + push(r1); + break; + + case OP_STR_EQ: + case OP_STR_NEQ: + case OP_STR_LT: + case OP_STR_LE: + case OP_STR_GT: + case OP_STR_GE: + + pop(r2); + pop(r1); + + ensure_defined(r1); + ensure_defined(r2); + + switch(*ip) + { + case OP_STR_EQ: + r1.i = (sized_string_cmp(r1.ss, r2.ss) == 0); + break; + case OP_STR_NEQ: + r1.i = (sized_string_cmp(r1.ss, r2.ss) != 0); + break; + case OP_STR_LT: + r1.i = (sized_string_cmp(r1.ss, r2.ss) < 0); + break; + case OP_STR_LE: + r1.i = (sized_string_cmp(r1.ss, r2.ss) <= 0); + break; + case OP_STR_GT: + r1.i = (sized_string_cmp(r1.ss, r2.ss) > 0); + break; + case OP_STR_GE: + r1.i = (sized_string_cmp(r1.ss, r2.ss) >= 0); + break; + } + + push(r1); + break; + + default: + assert(FALSE); + } + + if (timeout > 0) // timeout == 0 means no timeout + { + + if (++cycle == 10) + { + if (difftime(time(NULL), start_time) > timeout) + { + #ifdef PROFILING_ENABLED + assert(current_rule != NULL); + current_rule->clock_ticks += clock() - start; + #endif + result = ERROR_SCAN_TIMEOUT; + stop = TRUE; + } + + cycle = 0; + } + } + + ip++; + } + + obj_ptr = (YR_OBJECT**) yr_arena_base_address(obj_arena); + + while (obj_ptr != NULL) + { + yr_object_destroy(*obj_ptr); + + obj_ptr = (YR_OBJECT**) yr_arena_next_address( + obj_arena, obj_ptr, sizeof(YR_OBJECT*)); + } + + yr_arena_destroy(obj_arena); + yr_modules_unload_all(context); + yr_free(stack); + + return result; +} +","@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #include + #include + ++#include + #include + #include + #include +@@ -177,6 +178,8 @@ int yr_execute_code( + YR_RULE* rule; + YR_MATCH* match; + YR_OBJECT_FUNCTION* function; ++ YR_OBJECT** obj_ptr; ++ YR_ARENA* obj_arena; + + char* identifier; + char* args_fmt; +@@ -201,6 +204,10 @@ int yr_execute_code( + if (stack == NULL) + return ERROR_INSUFFICIENT_MEMORY; + ++ FAIL_ON_ERROR_WITH_CLEANUP( ++ yr_arena_create(1024, 0, &obj_arena), ++ yr_free(stack)); ++ + while(!stop) + { + switch(*ip) +@@ -437,6 +444,8 @@ int yr_execute_code( + rule->clock_ticks += clock() - start; + start = clock(); + #endif ++ ++ assert(sp == 0); + break; + + case OP_OBJ_LOAD: +@@ -577,18 +586,26 @@ int yr_execute_code( + } + } + ++ // if i == MAX_OVERLOADED_FUNCTIONS at this point no matching ++ // prototype was found, but this shouldn't happen. ++ + assert(i < MAX_OVERLOADED_FUNCTIONS); + ++ // make a copy of the returned object and push the copy into the stack ++ // function->return_obj can't be pushed because it can change in ++ // subsequent calls to the same function. ++ + if (result == ERROR_SUCCESS) +- { +- r1.o = function->return_obj; +- push(r1); +- } +- else +- { +- stop = TRUE; +- } ++ result = yr_object_copy(function->return_obj, &r1.o); ++ ++ // a pointer to the copied object is stored in a arena in order to ++ // free the object before exiting yr_execute_code + ++ if (result == ERROR_SUCCESS) ++ result = yr_arena_write_data(obj_arena, &r1.o, sizeof(r1.o), NULL); ++ ++ stop = (result != ERROR_SUCCESS); ++ push(r1); + break; + + case OP_FOUND: +@@ -1146,6 +1163,17 @@ int yr_execute_code( + ip++; + } + ++ obj_ptr = (YR_OBJECT**) yr_arena_base_address(obj_arena); ++ ++ while (obj_ptr != NULL) ++ { ++ yr_object_destroy(*obj_ptr); ++ ++ obj_ptr = (YR_OBJECT**) yr_arena_next_address( ++ obj_arena, obj_ptr, sizeof(YR_OBJECT*)); ++ } ++ ++ yr_arena_destroy(obj_arena); + yr_modules_unload_all(context); + yr_free(stack); + ",5599,5835,6144 +15915,"bool GLES2DecoderImpl::GetHelper( + GLenum pname, GLint* params, GLsizei* num_written) { + DCHECK(num_written); + switch (pname) { + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + *num_written = 1; + { + Framebuffer* framebuffer = GetBoundReadFramebuffer(); + if (framebuffer && + framebuffer->IsPossiblyComplete(feature_info_.get()) != + GL_FRAMEBUFFER_COMPLETE) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, ""glGetIntegerv"", ""incomplete framebuffer""); + if (params) { + *params = 0; + } + return true; + } + } + if (params) { + if (feature_info_->gl_version_info().is_es) { + api()->glGetIntegervFn(pname, params); + } else { + if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { + *params = GLES2Util::GetGLReadPixelsImplementationFormat( + GetBoundReadFramebufferInternalFormat(), + GetBoundReadFramebufferTextureType(), + feature_info_->feature_flags().ext_read_format_bgra); + } else { + *params = GLES2Util::GetGLReadPixelsImplementationType( + GetBoundReadFramebufferInternalFormat(), + GetBoundReadFramebufferTextureType()); + } + } + if (*params == GL_HALF_FLOAT && feature_info_->IsWebGL1OrES2Context()) { + *params = GL_HALF_FLOAT_OES; + } + if (*params == GL_SRGB_ALPHA_EXT) { + *params = GL_RGBA; + } + if (*params == GL_SRGB_EXT) { + *params = GL_RGB; + } + } + return true; + default: + break; + } + + if (!gl_version_info().is_es) { + switch (pname) { + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + *num_written = 1; + if (params) { + *params = group_->max_fragment_uniform_vectors(); + } + return true; + case GL_MAX_VARYING_VECTORS: + *num_written = 1; + if (params) { + *params = group_->max_varying_vectors(); + } + return true; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + *num_written = 1; + if (params) { + *params = group_->max_vertex_uniform_vectors(); + } + return true; + } + } + if (feature_info_->IsWebGL2OrES3Context()) { + switch (pname) { + case GL_MAX_VARYING_COMPONENTS: { + if (gl_version_info().is_es) { + *num_written = 1; + break; + } + + GLint max_varying_vectors = 0; + api()->glGetIntegervFn(GL_MAX_VARYING_VECTORS, &max_varying_vectors); + *num_written = 1; + if (params) { + *params = max_varying_vectors * 4; + } + return true; + } + case GL_READ_BUFFER: + *num_written = 1; + if (params) { + Framebuffer* framebuffer = GetBoundReadFramebuffer(); + GLenum read_buffer; + if (framebuffer) { + read_buffer = framebuffer->read_buffer(); + } else { + read_buffer = back_buffer_read_buffer_; + } + *params = static_cast(read_buffer); + } + return true; + case GL_TRANSFORM_FEEDBACK_ACTIVE: + *num_written = 1; + if (params) { + *params = + static_cast(state_.bound_transform_feedback->active()); + } + return true; + case GL_TRANSFORM_FEEDBACK_PAUSED: + *num_written = 1; + if (params) { + *params = + static_cast(state_.bound_transform_feedback->paused()); + } + return true; + case GL_WINDOW_RECTANGLE_EXT: + *num_written = 4; + DCHECK(!params); + return true; + } + } + switch (pname) { + case GL_MAX_VIEWPORT_DIMS: + *num_written = 2; + if (offscreen_target_frame_buffer_.get()) { + if (params) { + params[0] = renderbuffer_manager()->max_renderbuffer_size(); + params[1] = renderbuffer_manager()->max_renderbuffer_size(); + } + return true; + } + break; + case GL_MAX_SAMPLES: + *num_written = 1; + if (params) { + params[0] = renderbuffer_manager()->max_samples(); + } + return true; + case GL_MAX_RENDERBUFFER_SIZE: + *num_written = 1; + if (params) { + params[0] = renderbuffer_manager()->max_renderbuffer_size(); + } + return true; + case GL_MAX_TEXTURE_SIZE: + *num_written = 1; + if (params) { + params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); + } + return true; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + *num_written = 1; + if (params) { + params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); + } + return true; + case GL_MAX_COLOR_ATTACHMENTS_EXT: + *num_written = 1; + if (params) { + params[0] = group_->max_color_attachments(); + } + return true; + case GL_MAX_DRAW_BUFFERS_ARB: + *num_written = 1; + if (params) { + params[0] = group_->max_draw_buffers(); + } + return true; + case GL_ALPHA_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasAlphaMRT() && + framebuffer->HasSameInternalFormatsMRT()) { + if (gl_version_info().is_desktop_core_profile) { + for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) { + if (framebuffer->HasColorAttachment(i)) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, + GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); + break; + } + } + } else { + api()->glGetIntegervFn(GL_ALPHA_BITS, &v); + } + } + } else { + v = (ClientExposedBackBufferHasAlpha() ? 8 : 0); + } + params[0] = v; + } + return true; + case GL_DEPTH_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + if (gl_version_info().is_desktop_core_profile) { + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasDepthAttachment()) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); + } + } else { + v = (back_buffer_has_depth_ ? 24 : 0); + } + } else { + api()->glGetIntegervFn(GL_DEPTH_BITS, &v); + } + params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; + } + return true; + case GL_RED_BITS: + case GL_GREEN_BITS: + case GL_BLUE_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + if (gl_version_info().is_desktop_core_profile) { + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasSameInternalFormatsMRT()) { + GLenum framebuffer_enum = 0; + switch (pname) { + case GL_RED_BITS: + framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; + break; + case GL_GREEN_BITS: + framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; + break; + case GL_BLUE_BITS: + framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE; + break; + } + for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) { + if (framebuffer->HasColorAttachment(i)) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, + framebuffer_enum, &v); + break; + } + } + } + } else { + v = 8; + } + } else { + api()->glGetIntegervFn(pname, &v); + } + params[0] = v; + } + return true; + case GL_STENCIL_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + if (gl_version_info().is_desktop_core_profile) { + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasStencilAttachment()) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, + GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); + } + } else { + v = (back_buffer_has_stencil_ ? 8 : 0); + } + } else { + api()->glGetIntegervFn(GL_STENCIL_BITS, &v); + } + params[0] = BoundFramebufferHasStencilAttachment() ? v : 0; + } + return true; + case GL_COMPRESSED_TEXTURE_FORMATS: + *num_written = validators_->compressed_texture_format.GetValues().size(); + if (params) { + for (GLint ii = 0; ii < *num_written; ++ii) { + params[ii] = validators_->compressed_texture_format.GetValues()[ii]; + } + } + return true; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + *num_written = 1; + if (params) { + *params = validators_->compressed_texture_format.GetValues().size(); + } + return true; + case GL_NUM_SHADER_BINARY_FORMATS: + *num_written = 1; + if (params) { + *params = validators_->shader_binary_format.GetValues().size(); + } + return true; + case GL_SHADER_BINARY_FORMATS: + *num_written = validators_->shader_binary_format.GetValues().size(); + if (params) { + for (GLint ii = 0; ii < *num_written; ++ii) { + params[ii] = validators_->shader_binary_format.GetValues()[ii]; + } + } + return true; + case GL_SHADER_COMPILER: + *num_written = 1; + if (params) { + *params = GL_TRUE; + } + return true; + case GL_ARRAY_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_array_buffer.get()); + } + return true; + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), + state_.vertex_attrib_manager->element_array_buffer()); + } + return true; + case GL_COPY_READ_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_copy_read_buffer.get()); + } + return true; + case GL_COPY_WRITE_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_copy_write_buffer.get()); + } + return true; + case GL_PIXEL_PACK_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_pixel_pack_buffer.get()); + } + return true; + case GL_PIXEL_UNPACK_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_pixel_unpack_buffer.get()); + } + return true; + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_transform_feedback_buffer.get()); + } + return true; + case GL_UNIFORM_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_uniform_buffer.get()); + } + return true; + case GL_FRAMEBUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + framebuffer_manager(), + GetFramebufferInfoForTarget(GL_FRAMEBUFFER)); + } + return true; + case GL_READ_FRAMEBUFFER_BINDING_EXT: + *num_written = 1; + if (params) { + *params = GetClientId( + framebuffer_manager(), + GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT)); + } + return true; + case GL_RENDERBUFFER_BINDING: + *num_written = 1; + if (params) { + Renderbuffer* renderbuffer = + GetRenderbufferInfoForTarget(GL_RENDERBUFFER); + if (renderbuffer) { + *params = renderbuffer->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_CURRENT_PROGRAM: + *num_written = 1; + if (params) { + *params = GetClientId(program_manager(), state_.current_program.get()); + } + return true; + case GL_VERTEX_ARRAY_BINDING_OES: + *num_written = 1; + if (params) { + if (state_.vertex_attrib_manager.get() != + state_.default_vertex_attrib_manager.get()) { + GLuint client_id = 0; + vertex_array_manager_->GetClientId( + state_.vertex_attrib_manager->service_id(), &client_id); + *params = client_id; + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_2D: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_2d.get()) { + *params = unit.bound_texture_2d->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_CUBE_MAP: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_cube_map.get()) { + *params = unit.bound_texture_cube_map->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_external_oes.get()) { + *params = unit.bound_texture_external_oes->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_RECTANGLE_ARB: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_rectangle_arb.get()) { + *params = unit.bound_texture_rectangle_arb->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_BIND_GENERATES_RESOURCE_CHROMIUM: + *num_written = 1; + if (params) { + params[0] = group_->bind_generates_resource() ? 1 : 0; + } + return true; + case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: + *num_written = 1; + if (params) { + params[0] = group_->max_dual_source_draw_buffers(); + } + return true; + + case GL_MAJOR_VERSION: + *num_written = 1; + if (params) { + params[0] = 3; + } + return true; + case GL_MINOR_VERSION: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + + case GL_NUM_EXTENSIONS: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + case GL_GPU_DISJOINT_EXT: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + case GL_TIMESTAMP_EXT: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + case GL_TEXTURE_BINDING_2D_ARRAY: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_2d_array.get()) { + *params = unit.bound_texture_2d_array->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_3D: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_3d.get()) { + *params = unit.bound_texture_3d->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_SAMPLER_BINDING: + *num_written = 1; + if (params) { + DCHECK_LT(state_.active_texture_unit, state_.sampler_units.size()); + Sampler* sampler = + state_.sampler_units[state_.active_texture_unit].get(); + *params = sampler ? sampler->client_id() : 0; + } + return true; + case GL_TRANSFORM_FEEDBACK_BINDING: + *num_written = 1; + if (params) { + *params = state_.bound_transform_feedback->client_id(); + } + return true; + case GL_NUM_PROGRAM_BINARY_FORMATS: + *num_written = 1; + if (params) { + *params = 0; + } + return true; + case GL_PROGRAM_BINARY_FORMATS: + *num_written = 0; + return true; + default: + if (pname >= GL_DRAW_BUFFER0_ARB && pname <= GL_DRAW_BUFFER15_ARB) { + *num_written = 1; + if (params) { + if (pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) { + Framebuffer* framebuffer = + GetFramebufferInfoForTarget(GL_FRAMEBUFFER); + if (framebuffer) { + *params = framebuffer->GetDrawBuffer(pname); + } else { // backbuffer + if (pname == GL_DRAW_BUFFER0_ARB) + *params = back_buffer_draw_buffer_; + else + *params = GL_NONE; + } + } else { + *params = GL_NONE; + } + } + return true; + } + + *num_written = util_.GLGetNumValuesReturned(pname); + if (*num_written) + break; + + return false; + } + + if (params) { + DCHECK(*num_written); + pname = AdjustGetPname(pname); + api()->glGetIntegervFn(pname, params); + } + return true; +} +",0,"bool GLES2DecoderImpl::GetHelper( + GLenum pname, GLint* params, GLsizei* num_written) { + DCHECK(num_written); + switch (pname) { + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + *num_written = 1; + { + Framebuffer* framebuffer = GetBoundReadFramebuffer(); + if (framebuffer && + framebuffer->IsPossiblyComplete(feature_info_.get()) != + GL_FRAMEBUFFER_COMPLETE) { + LOCAL_SET_GL_ERROR( + GL_INVALID_OPERATION, ""glGetIntegerv"", ""incomplete framebuffer""); + if (params) { + *params = 0; + } + return true; + } + } + if (params) { + if (feature_info_->gl_version_info().is_es) { + api()->glGetIntegervFn(pname, params); + } else { + if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { + *params = GLES2Util::GetGLReadPixelsImplementationFormat( + GetBoundReadFramebufferInternalFormat(), + GetBoundReadFramebufferTextureType(), + feature_info_->feature_flags().ext_read_format_bgra); + } else { + *params = GLES2Util::GetGLReadPixelsImplementationType( + GetBoundReadFramebufferInternalFormat(), + GetBoundReadFramebufferTextureType()); + } + } + if (*params == GL_HALF_FLOAT && feature_info_->IsWebGL1OrES2Context()) { + *params = GL_HALF_FLOAT_OES; + } + if (*params == GL_SRGB_ALPHA_EXT) { + *params = GL_RGBA; + } + if (*params == GL_SRGB_EXT) { + *params = GL_RGB; + } + } + return true; + default: + break; + } + + if (!gl_version_info().is_es) { + switch (pname) { + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + *num_written = 1; + if (params) { + *params = group_->max_fragment_uniform_vectors(); + } + return true; + case GL_MAX_VARYING_VECTORS: + *num_written = 1; + if (params) { + *params = group_->max_varying_vectors(); + } + return true; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + *num_written = 1; + if (params) { + *params = group_->max_vertex_uniform_vectors(); + } + return true; + } + } + if (feature_info_->IsWebGL2OrES3Context()) { + switch (pname) { + case GL_MAX_VARYING_COMPONENTS: { + if (gl_version_info().is_es) { + *num_written = 1; + break; + } + + GLint max_varying_vectors = 0; + api()->glGetIntegervFn(GL_MAX_VARYING_VECTORS, &max_varying_vectors); + *num_written = 1; + if (params) { + *params = max_varying_vectors * 4; + } + return true; + } + case GL_READ_BUFFER: + *num_written = 1; + if (params) { + Framebuffer* framebuffer = GetBoundReadFramebuffer(); + GLenum read_buffer; + if (framebuffer) { + read_buffer = framebuffer->read_buffer(); + } else { + read_buffer = back_buffer_read_buffer_; + } + *params = static_cast(read_buffer); + } + return true; + case GL_TRANSFORM_FEEDBACK_ACTIVE: + *num_written = 1; + if (params) { + *params = + static_cast(state_.bound_transform_feedback->active()); + } + return true; + case GL_TRANSFORM_FEEDBACK_PAUSED: + *num_written = 1; + if (params) { + *params = + static_cast(state_.bound_transform_feedback->paused()); + } + return true; + case GL_WINDOW_RECTANGLE_EXT: + *num_written = 4; + DCHECK(!params); + return true; + } + } + switch (pname) { + case GL_MAX_VIEWPORT_DIMS: + *num_written = 2; + if (offscreen_target_frame_buffer_.get()) { + if (params) { + params[0] = renderbuffer_manager()->max_renderbuffer_size(); + params[1] = renderbuffer_manager()->max_renderbuffer_size(); + } + return true; + } + break; + case GL_MAX_SAMPLES: + *num_written = 1; + if (params) { + params[0] = renderbuffer_manager()->max_samples(); + } + return true; + case GL_MAX_RENDERBUFFER_SIZE: + *num_written = 1; + if (params) { + params[0] = renderbuffer_manager()->max_renderbuffer_size(); + } + return true; + case GL_MAX_TEXTURE_SIZE: + *num_written = 1; + if (params) { + params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); + } + return true; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + *num_written = 1; + if (params) { + params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); + } + return true; + case GL_MAX_COLOR_ATTACHMENTS_EXT: + *num_written = 1; + if (params) { + params[0] = group_->max_color_attachments(); + } + return true; + case GL_MAX_DRAW_BUFFERS_ARB: + *num_written = 1; + if (params) { + params[0] = group_->max_draw_buffers(); + } + return true; + case GL_ALPHA_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasAlphaMRT() && + framebuffer->HasSameInternalFormatsMRT()) { + if (gl_version_info().is_desktop_core_profile) { + for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) { + if (framebuffer->HasColorAttachment(i)) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, + GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); + break; + } + } + } else { + api()->glGetIntegervFn(GL_ALPHA_BITS, &v); + } + } + } else { + v = (ClientExposedBackBufferHasAlpha() ? 8 : 0); + } + params[0] = v; + } + return true; + case GL_DEPTH_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + if (gl_version_info().is_desktop_core_profile) { + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasDepthAttachment()) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); + } + } else { + v = (back_buffer_has_depth_ ? 24 : 0); + } + } else { + api()->glGetIntegervFn(GL_DEPTH_BITS, &v); + } + params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; + } + return true; + case GL_RED_BITS: + case GL_GREEN_BITS: + case GL_BLUE_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + if (gl_version_info().is_desktop_core_profile) { + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasSameInternalFormatsMRT()) { + GLenum framebuffer_enum = 0; + switch (pname) { + case GL_RED_BITS: + framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; + break; + case GL_GREEN_BITS: + framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; + break; + case GL_BLUE_BITS: + framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE; + break; + } + for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) { + if (framebuffer->HasColorAttachment(i)) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, + framebuffer_enum, &v); + break; + } + } + } + } else { + v = 8; + } + } else { + api()->glGetIntegervFn(pname, &v); + } + params[0] = v; + } + return true; + case GL_STENCIL_BITS: + *num_written = 1; + if (params) { + GLint v = 0; + if (gl_version_info().is_desktop_core_profile) { + Framebuffer* framebuffer = GetBoundDrawFramebuffer(); + if (framebuffer) { + if (framebuffer->HasStencilAttachment()) { + api()->glGetFramebufferAttachmentParameterivEXTFn( + GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, + GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); + } + } else { + v = (back_buffer_has_stencil_ ? 8 : 0); + } + } else { + api()->glGetIntegervFn(GL_STENCIL_BITS, &v); + } + params[0] = BoundFramebufferHasStencilAttachment() ? v : 0; + } + return true; + case GL_COMPRESSED_TEXTURE_FORMATS: + *num_written = validators_->compressed_texture_format.GetValues().size(); + if (params) { + for (GLint ii = 0; ii < *num_written; ++ii) { + params[ii] = validators_->compressed_texture_format.GetValues()[ii]; + } + } + return true; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + *num_written = 1; + if (params) { + *params = validators_->compressed_texture_format.GetValues().size(); + } + return true; + case GL_NUM_SHADER_BINARY_FORMATS: + *num_written = 1; + if (params) { + *params = validators_->shader_binary_format.GetValues().size(); + } + return true; + case GL_SHADER_BINARY_FORMATS: + *num_written = validators_->shader_binary_format.GetValues().size(); + if (params) { + for (GLint ii = 0; ii < *num_written; ++ii) { + params[ii] = validators_->shader_binary_format.GetValues()[ii]; + } + } + return true; + case GL_SHADER_COMPILER: + *num_written = 1; + if (params) { + *params = GL_TRUE; + } + return true; + case GL_ARRAY_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_array_buffer.get()); + } + return true; + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), + state_.vertex_attrib_manager->element_array_buffer()); + } + return true; + case GL_COPY_READ_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_copy_read_buffer.get()); + } + return true; + case GL_COPY_WRITE_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_copy_write_buffer.get()); + } + return true; + case GL_PIXEL_PACK_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_pixel_pack_buffer.get()); + } + return true; + case GL_PIXEL_UNPACK_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_pixel_unpack_buffer.get()); + } + return true; + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_transform_feedback_buffer.get()); + } + return true; + case GL_UNIFORM_BUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + buffer_manager(), state_.bound_uniform_buffer.get()); + } + return true; + case GL_FRAMEBUFFER_BINDING: + *num_written = 1; + if (params) { + *params = GetClientId( + framebuffer_manager(), + GetFramebufferInfoForTarget(GL_FRAMEBUFFER)); + } + return true; + case GL_READ_FRAMEBUFFER_BINDING_EXT: + *num_written = 1; + if (params) { + *params = GetClientId( + framebuffer_manager(), + GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT)); + } + return true; + case GL_RENDERBUFFER_BINDING: + *num_written = 1; + if (params) { + Renderbuffer* renderbuffer = + GetRenderbufferInfoForTarget(GL_RENDERBUFFER); + if (renderbuffer) { + *params = renderbuffer->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_CURRENT_PROGRAM: + *num_written = 1; + if (params) { + *params = GetClientId(program_manager(), state_.current_program.get()); + } + return true; + case GL_VERTEX_ARRAY_BINDING_OES: + *num_written = 1; + if (params) { + if (state_.vertex_attrib_manager.get() != + state_.default_vertex_attrib_manager.get()) { + GLuint client_id = 0; + vertex_array_manager_->GetClientId( + state_.vertex_attrib_manager->service_id(), &client_id); + *params = client_id; + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_2D: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_2d.get()) { + *params = unit.bound_texture_2d->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_CUBE_MAP: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_cube_map.get()) { + *params = unit.bound_texture_cube_map->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_external_oes.get()) { + *params = unit.bound_texture_external_oes->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_RECTANGLE_ARB: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_rectangle_arb.get()) { + *params = unit.bound_texture_rectangle_arb->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_BIND_GENERATES_RESOURCE_CHROMIUM: + *num_written = 1; + if (params) { + params[0] = group_->bind_generates_resource() ? 1 : 0; + } + return true; + case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: + *num_written = 1; + if (params) { + params[0] = group_->max_dual_source_draw_buffers(); + } + return true; + + case GL_MAJOR_VERSION: + *num_written = 1; + if (params) { + params[0] = 3; + } + return true; + case GL_MINOR_VERSION: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + + case GL_NUM_EXTENSIONS: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + case GL_GPU_DISJOINT_EXT: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + case GL_TIMESTAMP_EXT: + *num_written = 1; + if (params) { + params[0] = 0; + } + return true; + case GL_TEXTURE_BINDING_2D_ARRAY: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_2d_array.get()) { + *params = unit.bound_texture_2d_array->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_TEXTURE_BINDING_3D: + *num_written = 1; + if (params) { + TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; + if (unit.bound_texture_3d.get()) { + *params = unit.bound_texture_3d->client_id(); + } else { + *params = 0; + } + } + return true; + case GL_SAMPLER_BINDING: + *num_written = 1; + if (params) { + DCHECK_LT(state_.active_texture_unit, state_.sampler_units.size()); + Sampler* sampler = + state_.sampler_units[state_.active_texture_unit].get(); + *params = sampler ? sampler->client_id() : 0; + } + return true; + case GL_TRANSFORM_FEEDBACK_BINDING: + *num_written = 1; + if (params) { + *params = state_.bound_transform_feedback->client_id(); + } + return true; + case GL_NUM_PROGRAM_BINARY_FORMATS: + *num_written = 1; + if (params) { + *params = 0; + } + return true; + case GL_PROGRAM_BINARY_FORMATS: + *num_written = 0; + return true; + default: + if (pname >= GL_DRAW_BUFFER0_ARB && pname <= GL_DRAW_BUFFER15_ARB) { + *num_written = 1; + if (params) { + if (pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) { + Framebuffer* framebuffer = + GetFramebufferInfoForTarget(GL_FRAMEBUFFER); + if (framebuffer) { + *params = framebuffer->GetDrawBuffer(pname); + } else { // backbuffer + if (pname == GL_DRAW_BUFFER0_ARB) + *params = back_buffer_draw_buffer_; + else + *params = GL_NONE; + } + } else { + *params = GL_NONE; + } + } + return true; + } + + *num_written = util_.GLGetNumValuesReturned(pname); + if (*num_written) + break; + + return false; + } + + if (params) { + DCHECK(*num_written); + pname = AdjustGetPname(pname); + api()->glGetIntegervFn(pname, params); + } + return true; +} +","@@ -11384,29 +11384,24 @@ void GLES2DecoderImpl::GetTexParameterImpl( + return; + } + break; +- // Get the level information from the texture to avoid a Mac driver +- // bug where they store the levels in int16_t, making values bigger +- // than 2^15-1 overflow in the negative range. + case GL_TEXTURE_BASE_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->base_level()); +- } else { +- iparams[0] = texture->base_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_base_level()); ++ } else { ++ iparams[0] = texture->unclamped_base_level(); + } +- break; ++ return; + case GL_TEXTURE_MAX_LEVEL: +- if (workarounds().use_shadowed_tex_level_params) { +- if (fparams) { +- fparams[0] = static_cast(texture->max_level()); +- } else { +- iparams[0] = texture->max_level(); +- } +- return; ++ // Use shadowed value in case it's clamped; also because older MacOSX ++ // stores the value on int16_t (see https://crbug.com/610153). ++ if (fparams) { ++ fparams[0] = static_cast(texture->unclamped_max_level()); ++ } else { ++ iparams[0] = texture->unclamped_max_level(); + } +- break; ++ return; + case GL_TEXTURE_SWIZZLE_R: + if (fparams) { + fparams[0] = static_cast(texture->swizzle_r()); +@@ -17573,25 +17568,6 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + compatibility_internal_format = format_info->decompressed_internal_format; + } + +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); +- +- // TODO(zmo): We might need to emulate TexStorage using TexImage or +- // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying +- // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. +- if (dimension == ContextState::k2D) { +- api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, +- width, height); +- } else { +- api()->glTexStorage3DFn(target, levels, compatibility_internal_format, +- width, height, depth); +- } +- if (workarounds().reset_base_mipmap_level_before_texstorage && +- texture->base_level() > 0) +- api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, +- texture->base_level()); +- + { + GLsizei level_width = width; + GLsizei level_height = height; +@@ -17620,6 +17596,29 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target, + texture->ApplyFormatWorkarounds(feature_info_.get()); + texture->SetImmutable(true); + } ++ ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); ++ ++ // TODO(zmo): We might need to emulate TexStorage using TexImage or ++ // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying ++ // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. ++ if (dimension == ContextState::k2D) { ++ api()->glTexStorage2DEXTFn(target, levels, compatibility_internal_format, ++ width, height); ++ } else { ++ api()->glTexStorage3DFn(target, levels, compatibility_internal_format, ++ width, height, depth); ++ } ++ if (workarounds().reset_base_mipmap_level_before_texstorage && ++ texture->base_level() > 0) { ++ // Note base_level is already clamped due to texture->SetImmutable(true). ++ // This is necessary for certain NVidia Linux drivers; otherwise they ++ // may trigger segmentation fault. See https://crbug.com/877874. ++ api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, ++ texture->base_level()); ++ } + } + + void GLES2DecoderImpl::DoTexStorage2DEXT(GLenum target,",4168,4404,6144 +18171,"static Image *ReadWPGImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + typedef struct + { + size_t FileId; + MagickOffsetType DataOffset; + unsigned int ProductType; + unsigned int FileType; + unsigned char MajorVersion; + unsigned char MinorVersion; + unsigned int EncryptKey; + unsigned int Reserved; + } WPGHeader; + + typedef struct + { + unsigned char RecType; + size_t RecordLength; + } WPGRecord; + + typedef struct + { + unsigned char Class; + unsigned char RecType; + size_t Extension; + size_t RecordLength; + } WPG2Record; + + typedef struct + { + unsigned HorizontalUnits; + unsigned VerticalUnits; + unsigned char PosSizePrecision; + } WPG2Start; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType1; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned char Depth; + unsigned char Compression; + } WPG2BitmapType1; + + typedef struct + { + unsigned int RotAngle; + unsigned int LowLeftX; + unsigned int LowLeftY; + unsigned int UpRightX; + unsigned int UpRightY; + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType2; + + typedef struct + { + unsigned int StartIndex; + unsigned int NumOfEntries; + } WPGColorMapRec; + + /* + typedef struct { + size_t PS_unknown1; + unsigned int PS_unknown2; + unsigned int PS_unknown3; + } WPGPSl1Record; + */ + + Image + *image; + + unsigned int + status; + + WPGHeader + Header; + + WPGRecord + Rec; + + WPG2Record + Rec2; + + WPG2Start StartWPG; + + WPGBitmapType1 + BitmapHeader1; + + WPG2BitmapType1 + Bitmap2Header1; + + WPGBitmapType2 + BitmapHeader2; + + WPGColorMapRec + WPG_Palette; + + int + i, + bpp, + WPG2Flags; + + ssize_t + ldblk; + + size_t + one; + + unsigned char + *BImgBuff; + + tCTM CTM; /*current transform matrix*/ + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + one=1; + image=AcquireImage(image_info); + image->depth=8; + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read WPG image. + */ + Header.FileId=ReadBlobLSBLong(image); + Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image); + Header.ProductType=ReadBlobLSBShort(image); + Header.FileType=ReadBlobLSBShort(image); + Header.MajorVersion=ReadBlobByte(image); + Header.MinorVersion=ReadBlobByte(image); + Header.EncryptKey=ReadBlobLSBShort(image); + Header.Reserved=ReadBlobLSBShort(image); + + if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (Header.EncryptKey!=0) + ThrowReaderException(CoderError,""EncryptedWPGImageFileNotSupported""); + + image->columns = 1; + image->rows = 1; + image->colors = 0; + bpp=0; + BitmapHeader2.RotAngle=0; + + switch(Header.FileType) + { + case 1: /* WPG level 1 */ + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec.RecordLength; + + switch(Rec.RecType) + { + case 0x0B: /* bitmap type 1 */ + BitmapHeader1.Width=ReadBlobLSBShort(image); + BitmapHeader1.Height=ReadBlobLSBShort(image); + if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader1.Depth=ReadBlobLSBShort(image); + BitmapHeader1.HorzRes=ReadBlobLSBShort(image); + BitmapHeader1.VertRes=ReadBlobLSBShort(image); + + if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes) + { + image->units=PixelsPerCentimeterResolution; + image->x_resolution=BitmapHeader1.HorzRes/470.0; + image->y_resolution=BitmapHeader1.VertRes/470.0; + } + image->columns=BitmapHeader1.Width; + image->rows=BitmapHeader1.Height; + bpp=BitmapHeader1.Depth; + + goto UnpackRaster; + + case 0x0E: /*Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + + image->colors=WPG_Palette.NumOfEntries; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + } + break; + + case 0x11: /* Start PS l1 */ + if(Rec.RecordLength > 8) + image=ExtractPostscript(image,image_info, + TellBlob(image)+8, /* skip PS header in the wpg */ + (ssize_t) Rec.RecordLength-8,exception); + break; + + case 0x14: /* bitmap type 2 */ + BitmapHeader2.RotAngle=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftX=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftY=ReadBlobLSBShort(image); + BitmapHeader2.UpRightX=ReadBlobLSBShort(image); + BitmapHeader2.UpRightY=ReadBlobLSBShort(image); + BitmapHeader2.Width=ReadBlobLSBShort(image); + BitmapHeader2.Height=ReadBlobLSBShort(image); + if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader2.Depth=ReadBlobLSBShort(image); + BitmapHeader2.HorzRes=ReadBlobLSBShort(image); + BitmapHeader2.VertRes=ReadBlobLSBShort(image); + + image->units=PixelsPerCentimeterResolution; + image->page.width=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)/470.0); + image->page.height=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)/470.0); + image->page.x=(int) (BitmapHeader2.LowLeftX/470.0); + image->page.y=(int) (BitmapHeader2.LowLeftX/470.0); + if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes) + { + image->x_resolution=BitmapHeader2.HorzRes/470.0; + image->y_resolution=BitmapHeader2.VertRes/470.0; + } + image->columns=BitmapHeader2.Width; + image->rows=BitmapHeader2.Height; + bpp=BitmapHeader2.Depth; + + UnpackRaster: + if ((image->colors == 0) && (bpp != 24)) + { + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + { + NoMemory: + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + /* printf(""Load default colormap \n""); */ + for (i=0; (i < (int) image->colors) && (i < 256); i++) + { + image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red); + image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green); + image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue); + } + } + else + { + if (bpp < 24) + if ( (image->colors < (one << bpp)) && (bpp != 24) ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + if (bpp == 1) + { + if(image->colormap[0].red==0 && + image->colormap[0].green==0 && + image->colormap[0].blue==0 && + image->colormap[1].red==0 && + image->colormap[1].green==0 && + image->colormap[1].blue==0) + { /* fix crippled monochrome palette */ + image->colormap[1].red = + image->colormap[1].green = + image->colormap[1].blue = QuantumRange; + } + } + + if(UnpackWPGRaster(image,bpp) < 0) + /* The raster cannot be unpacked */ + { + DecompressionFailed: + ThrowReaderException(CoderError,""UnableToDecompressImage""); + } + + if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping) + { + /* flop command */ + if(BitmapHeader2.RotAngle & 0x8000) + { + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flop_image); + } + } + /* flip command */ + if(BitmapHeader2.RotAngle & 0x2000) + { + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flip_image); + } + } + + /* rotate command */ + if(BitmapHeader2.RotAngle & 0x0FFF) + { + Image + *rotate_image; + + rotate_image=RotateImage(image,(BitmapHeader2.RotAngle & + 0x0FFF), exception); + if (rotate_image != (Image *) NULL) { + DuplicateBlob(rotate_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,rotate_image); + } + } + } + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=0; + image->colors=0; + break; + + case 0x1B: /* Postscript l2 */ + if(Rec.RecordLength>0x3C) + image=ExtractPostscript(image,image_info, + TellBlob(image)+0x3C, /* skip PS l2 header in the wpg */ + (ssize_t) Rec.RecordLength-0x3C,exception); + break; + } + } + break; + + case 2: /* WPG level 2 */ + (void) memset(CTM,0,sizeof(CTM)); + StartWPG.PosSizePrecision = 0; + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec2.Class=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rec2.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec2.Extension); + Rd_WP_DWORD(image,&Rec2.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec2.RecordLength; + + switch(Rec2.RecType) + { + case 1: + StartWPG.HorizontalUnits=ReadBlobLSBShort(image); + StartWPG.VerticalUnits=ReadBlobLSBShort(image); + StartWPG.PosSizePrecision=ReadBlobByte(image); + break; + case 0x0C: /* Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + + image->colors=WPG_Palette.NumOfEntries; + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((char) + ReadBlobByte(image)); + (void) ReadBlobByte(image); /*Opacity??*/ + } + break; + case 0x0E: + Bitmap2Header1.Width=ReadBlobLSBShort(image); + Bitmap2Header1.Height=ReadBlobLSBShort(image); + if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + Bitmap2Header1.Depth=ReadBlobByte(image); + Bitmap2Header1.Compression=ReadBlobByte(image); + + if(Bitmap2Header1.Compression > 1) + continue; /*Unknown compression method */ + switch(Bitmap2Header1.Depth) + { + case 1: + bpp=1; + break; + case 2: + bpp=2; + break; + case 3: + bpp=4; + break; + case 4: + bpp=8; + break; + case 8: + bpp=24; + break; + default: + continue; /*Ignore raster with unknown depth*/ + } + image->columns=Bitmap2Header1.Width; + image->rows=Bitmap2Header1.Height; + + if ((image->colors == 0) && (bpp != 24)) + { + size_t + one; + + one=1; + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + } + else + { + if(bpp < 24) + if( image->colors<(one << bpp) && bpp!=24 ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + + switch(Bitmap2Header1.Compression) + { + case 0: /*Uncompressed raster*/ + { + ldblk=(ssize_t) ((bpp*image->columns+7)/8); + BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) + ldblk,sizeof(*BImgBuff)); + if (BImgBuff == (unsigned char *) NULL) + goto NoMemory; + + for(i=0; i< (ssize_t) image->rows; i++) + { + (void) ReadBlob(image,ldblk,BImgBuff); + InsertRow(BImgBuff,i,image,bpp); + } + + if(BImgBuff) + BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);; + break; + } + case 1: /*RLE for WPG2 */ + { + if( UnpackWPG2Raster(image,bpp) < 0) + goto DecompressionFailed; + break; + } + } + + if(CTM[0][0]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flop_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0; + Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll); + Tx(1,2)=0; Tx(2,2)=1; */ + } + if(CTM[1][1]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flip_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + float_matrix Tx(3,3); + Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0; + Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll); + Tx(2,2)=1; */ + } + + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=1; + image->colors=0; + break; + + case 0x12: /* Postscript WPG2*/ + i=ReadBlobLSBShort(image); + if(Rec2.RecordLength > (unsigned int) i) + image=ExtractPostscript(image,image_info, + TellBlob(image)+i, /*skip PS header in the wpg2*/ + (ssize_t) (Rec2.RecordLength-i-2),exception); + break; + + case 0x1B: /*bitmap rectangle*/ + WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); + (void) WPG2Flags; + break; + } + } + + break; + + default: + { + ThrowReaderException(CoderError,""DataEncodingSchemeIsNotSupported""); + } + } + + Finish: + (void) CloseBlob(image); + + { + Image + *p; + + ssize_t + scene=0; + + /* + Rewind list, removing any empty images while rewinding. + */ + p=image; + image=NULL; + while (p != (Image *) NULL) + { + Image *tmp=p; + if ((p->rows == 0) || (p->columns == 0)) { + p=p->previous; + DeleteImageFromList(&tmp); + } else { + image=p; + p=p->previous; + } + } + /* + Fix scene numbers. + */ + for (p=image; p != (Image *) NULL; p=p->next) + p->scene=(size_t) scene++; + } + if (image == (Image *) NULL) + ThrowReaderException(CorruptImageError, + ""ImageFileDoesNotContainAnyImageData""); + return(image); +} +",1,"static Image *ReadWPGImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + typedef struct + { + size_t FileId; + MagickOffsetType DataOffset; + unsigned int ProductType; + unsigned int FileType; + unsigned char MajorVersion; + unsigned char MinorVersion; + unsigned int EncryptKey; + unsigned int Reserved; + } WPGHeader; + + typedef struct + { + unsigned char RecType; + size_t RecordLength; + } WPGRecord; + + typedef struct + { + unsigned char Class; + unsigned char RecType; + size_t Extension; + size_t RecordLength; + } WPG2Record; + + typedef struct + { + unsigned HorizontalUnits; + unsigned VerticalUnits; + unsigned char PosSizePrecision; + } WPG2Start; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType1; + + typedef struct + { + unsigned int Width; + unsigned int Height; + unsigned char Depth; + unsigned char Compression; + } WPG2BitmapType1; + + typedef struct + { + unsigned int RotAngle; + unsigned int LowLeftX; + unsigned int LowLeftY; + unsigned int UpRightX; + unsigned int UpRightY; + unsigned int Width; + unsigned int Height; + unsigned int Depth; + unsigned int HorzRes; + unsigned int VertRes; + } WPGBitmapType2; + + typedef struct + { + unsigned int StartIndex; + unsigned int NumOfEntries; + } WPGColorMapRec; + + /* + typedef struct { + size_t PS_unknown1; + unsigned int PS_unknown2; + unsigned int PS_unknown3; + } WPGPSl1Record; + */ + + Image + *image; + + unsigned int + status; + + WPGHeader + Header; + + WPGRecord + Rec; + + WPG2Record + Rec2; + + WPG2Start StartWPG; + + WPGBitmapType1 + BitmapHeader1; + + WPG2BitmapType1 + Bitmap2Header1; + + WPGBitmapType2 + BitmapHeader2; + + WPGColorMapRec + WPG_Palette; + + int + i, + bpp, + WPG2Flags; + + ssize_t + ldblk; + + size_t + one; + + unsigned char + *BImgBuff; + + tCTM CTM; /*current transform matrix*/ + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + one=1; + image=AcquireImage(image_info); + image->depth=8; + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + /* + Read WPG image. + */ + Header.FileId=ReadBlobLSBLong(image); + Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image); + Header.ProductType=ReadBlobLSBShort(image); + Header.FileType=ReadBlobLSBShort(image); + Header.MajorVersion=ReadBlobByte(image); + Header.MinorVersion=ReadBlobByte(image); + Header.EncryptKey=ReadBlobLSBShort(image); + Header.Reserved=ReadBlobLSBShort(image); + + if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + if (Header.EncryptKey!=0) + ThrowReaderException(CoderError,""EncryptedWPGImageFileNotSupported""); + + image->columns = 1; + image->rows = 1; + image->colors = 0; + bpp=0; + BitmapHeader2.RotAngle=0; + + switch(Header.FileType) + { + case 1: /* WPG level 1 */ + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec.RecordLength; + + switch(Rec.RecType) + { + case 0x0B: /* bitmap type 1 */ + BitmapHeader1.Width=ReadBlobLSBShort(image); + BitmapHeader1.Height=ReadBlobLSBShort(image); + if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader1.Depth=ReadBlobLSBShort(image); + BitmapHeader1.HorzRes=ReadBlobLSBShort(image); + BitmapHeader1.VertRes=ReadBlobLSBShort(image); + + if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes) + { + image->units=PixelsPerCentimeterResolution; + image->x_resolution=BitmapHeader1.HorzRes/470.0; + image->y_resolution=BitmapHeader1.VertRes/470.0; + } + image->columns=BitmapHeader1.Width; + image->rows=BitmapHeader1.Height; + bpp=BitmapHeader1.Depth; + + goto UnpackRaster; + + case 0x0E: /*Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + + image->colors=WPG_Palette.NumOfEntries; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((unsigned char) + ReadBlobByte(image)); + } + break; + + case 0x11: /* Start PS l1 */ + if(Rec.RecordLength > 8) + image=ExtractPostscript(image,image_info, + TellBlob(image)+8, /* skip PS header in the wpg */ + (ssize_t) Rec.RecordLength-8,exception); + break; + + case 0x14: /* bitmap type 2 */ + BitmapHeader2.RotAngle=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftX=ReadBlobLSBShort(image); + BitmapHeader2.LowLeftY=ReadBlobLSBShort(image); + BitmapHeader2.UpRightX=ReadBlobLSBShort(image); + BitmapHeader2.UpRightY=ReadBlobLSBShort(image); + BitmapHeader2.Width=ReadBlobLSBShort(image); + BitmapHeader2.Height=ReadBlobLSBShort(image); + if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + BitmapHeader2.Depth=ReadBlobLSBShort(image); + BitmapHeader2.HorzRes=ReadBlobLSBShort(image); + BitmapHeader2.VertRes=ReadBlobLSBShort(image); + + image->units=PixelsPerCentimeterResolution; + image->page.width=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)/470.0); + image->page.height=(unsigned int) + ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)/470.0); + image->page.x=(int) (BitmapHeader2.LowLeftX/470.0); + image->page.y=(int) (BitmapHeader2.LowLeftX/470.0); + if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes) + { + image->x_resolution=BitmapHeader2.HorzRes/470.0; + image->y_resolution=BitmapHeader2.VertRes/470.0; + } + image->columns=BitmapHeader2.Width; + image->rows=BitmapHeader2.Height; + bpp=BitmapHeader2.Depth; + + UnpackRaster: + if ((image->colors == 0) && (bpp != 24)) + { + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + { + NoMemory: + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + } + /* printf(""Load default colormap \n""); */ + for (i=0; (i < (int) image->colors) && (i < 256); i++) + { + image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red); + image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green); + image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue); + } + } + else + { + if (bpp < 24) + if ( (image->colors < (one << bpp)) && (bpp != 24) ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + if (bpp == 1) + { + if(image->colormap[0].red==0 && + image->colormap[0].green==0 && + image->colormap[0].blue==0 && + image->colormap[1].red==0 && + image->colormap[1].green==0 && + image->colormap[1].blue==0) + { /* fix crippled monochrome palette */ + image->colormap[1].red = + image->colormap[1].green = + image->colormap[1].blue = QuantumRange; + } + } + + if(UnpackWPGRaster(image,bpp) < 0) + /* The raster cannot be unpacked */ + { + DecompressionFailed: + ThrowReaderException(CoderError,""UnableToDecompressImage""); + } + + if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping) + { + /* flop command */ + if(BitmapHeader2.RotAngle & 0x8000) + { + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flop_image); + } + } + /* flip command */ + if(BitmapHeader2.RotAngle & 0x2000) + { + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flip_image); + } + } + + /* rotate command */ + if(BitmapHeader2.RotAngle & 0x0FFF) + { + Image + *rotate_image; + + rotate_image=RotateImage(image,(BitmapHeader2.RotAngle & + 0x0FFF), exception); + if (rotate_image != (Image *) NULL) { + DuplicateBlob(rotate_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,rotate_image); + } + } + } + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=0; + image->colors=0; + break; + + case 0x1B: /* Postscript l2 */ + if(Rec.RecordLength>0x3C) + image=ExtractPostscript(image,image_info, + TellBlob(image)+0x3C, /* skip PS l2 header in the wpg */ + (ssize_t) Rec.RecordLength-0x3C,exception); + break; + } + } + break; + + case 2: /* WPG level 2 */ + (void) memset(CTM,0,sizeof(CTM)); + StartWPG.PosSizePrecision = 0; + while(!EOFBlob(image)) /* object parser loop */ + { + (void) SeekBlob(image,Header.DataOffset,SEEK_SET); + if(EOFBlob(image)) + break; + + Rec2.Class=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rec2.RecType=(i=ReadBlobByte(image)); + if(i==EOF) + break; + Rd_WP_DWORD(image,&Rec2.Extension); + Rd_WP_DWORD(image,&Rec2.RecordLength); + if(EOFBlob(image)) + break; + + Header.DataOffset=TellBlob(image)+Rec2.RecordLength; + + switch(Rec2.RecType) + { + case 1: + StartWPG.HorizontalUnits=ReadBlobLSBShort(image); + StartWPG.VerticalUnits=ReadBlobLSBShort(image); + StartWPG.PosSizePrecision=ReadBlobByte(image); + break; + case 0x0C: /* Color palette */ + WPG_Palette.StartIndex=ReadBlobLSBShort(image); + WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); + + image->colors=WPG_Palette.NumOfEntries; + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError, + ""MemoryAllocationFailed""); + for (i=WPG_Palette.StartIndex; + i < (int)WPG_Palette.NumOfEntries; i++) + { + image->colormap[i].red=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].green=ScaleCharToQuantum((char) + ReadBlobByte(image)); + image->colormap[i].blue=ScaleCharToQuantum((char) + ReadBlobByte(image)); + (void) ReadBlobByte(image); /*Opacity??*/ + } + break; + case 0x0E: + Bitmap2Header1.Width=ReadBlobLSBShort(image); + Bitmap2Header1.Height=ReadBlobLSBShort(image); + if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + Bitmap2Header1.Depth=ReadBlobByte(image); + Bitmap2Header1.Compression=ReadBlobByte(image); + + if(Bitmap2Header1.Compression > 1) + continue; /*Unknown compression method */ + switch(Bitmap2Header1.Depth) + { + case 1: + bpp=1; + break; + case 2: + bpp=2; + break; + case 3: + bpp=4; + break; + case 4: + bpp=8; + break; + case 8: + bpp=24; + break; + default: + continue; /*Ignore raster with unknown depth*/ + } + image->columns=Bitmap2Header1.Width; + image->rows=Bitmap2Header1.Height; + + if ((image->colors == 0) && (bpp != 24)) + { + size_t + one; + + one=1; + image->colors=one << bpp; + if (!AcquireImageColormap(image,image->colors)) + goto NoMemory; + } + else + { + if(bpp < 24) + if( image->colors<(one << bpp) && bpp!=24 ) + image->colormap=(PixelPacket *) ResizeQuantumMemory( + image->colormap,(size_t) (one << bpp), + sizeof(*image->colormap)); + } + + + switch(Bitmap2Header1.Compression) + { + case 0: /*Uncompressed raster*/ + { + ldblk=(ssize_t) ((bpp*image->columns+7)/8); + BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) + ldblk,sizeof(*BImgBuff)); + if (BImgBuff == (unsigned char *) NULL) + goto NoMemory; + + for(i=0; i< (ssize_t) image->rows; i++) + { + (void) ReadBlob(image,ldblk,BImgBuff); + InsertRow(BImgBuff,i,image,bpp); + } + + if(BImgBuff) + BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);; + break; + } + case 1: /*RLE for WPG2 */ + { + if( UnpackWPG2Raster(image,bpp) < 0) + goto DecompressionFailed; + break; + } + } + + if(CTM[0][0]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flop_image; + + flop_image = FlopImage(image, exception); + if (flop_image != (Image *) NULL) { + DuplicateBlob(flop_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flop_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0; + Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll); + Tx(1,2)=0; Tx(2,2)=1; */ + } + if(CTM[1][1]<0 && !image_info->ping) + { /*?? RotAngle=360-RotAngle;*/ + Image + *flip_image; + + flip_image = FlipImage(image, exception); + if (flip_image != (Image *) NULL) { + DuplicateBlob(flip_image,image); + (void) RemoveLastImageFromList(&image); + AppendImageToList(&image,flip_image); + } + /* Try to change CTM according to Flip - I am not sure, must be checked. + float_matrix Tx(3,3); + Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0; + Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0; + Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll); + Tx(2,2)=1; */ + } + + + /* Allocate next image structure. */ + AcquireNextImage(image_info,image); + image->depth=8; + if (image->next == (Image *) NULL) + goto Finish; + image=SyncNextImageInList(image); + image->columns=image->rows=1; + image->colors=0; + break; + + case 0x12: /* Postscript WPG2*/ + i=ReadBlobLSBShort(image); + if(Rec2.RecordLength > (unsigned int) i) + image=ExtractPostscript(image,image_info, + TellBlob(image)+i, /*skip PS header in the wpg2*/ + (ssize_t) (Rec2.RecordLength-i-2),exception); + break; + + case 0x1B: /*bitmap rectangle*/ + WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); + (void) WPG2Flags; + break; + } + } + + break; + + default: + { + ThrowReaderException(CoderError,""DataEncodingSchemeIsNotSupported""); + } + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + + Finish: + (void) CloseBlob(image); + + { + Image + *p; + + ssize_t + scene=0; + + /* + Rewind list, removing any empty images while rewinding. + */ + p=image; + image=NULL; + while (p != (Image *) NULL) + { + Image *tmp=p; + if ((p->rows == 0) || (p->columns == 0)) { + p=p->previous; + DeleteImageFromList(&tmp); + } else { + image=p; + p=p->previous; + } + } + /* + Fix scene numbers. + */ + for (p=image; p != (Image *) NULL; p=p->next) + p->scene=(size_t) scene++; + } + if (image == (Image *) NULL) + ThrowReaderException(CorruptImageError, + ""ImageFileDoesNotContainAnyImageData""); + return(image); +} +","@@ -1413,6 +1413,12 @@ static Image *ReadWPGImage(const ImageInfo *image_info, + ThrowReaderException(CoderError,""DataEncodingSchemeIsNotSupported""); + } + } ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + + Finish: + (void) CloseBlob(image);",4652,4888,6144 +518,"qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, + guint32 fourcc, const guint8 * stsd_data, gchar ** codec_name) +{ + GstCaps *caps; + const GstStructure *s; + const gchar *name; + + switch (fourcc) { + case GST_MAKE_FOURCC ('p', 'n', 'g', ' '): + _codec (""PNG still images""); + caps = gst_caps_new_simple (""image/png"", NULL); + break; + case GST_MAKE_FOURCC ('j', 'p', 'e', 'g'): + _codec (""JPEG still images""); + caps = gst_caps_new_simple (""image/jpeg"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'j', 'p', 'a'): + case GST_MAKE_FOURCC ('A', 'V', 'D', 'J'): + case GST_MAKE_FOURCC ('M', 'J', 'P', 'G'): + _codec (""Motion-JPEG""); + caps = gst_caps_new_simple (""image/jpeg"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'j', 'p', 'b'): + _codec (""Motion-JPEG format B""); + caps = gst_caps_new_simple (""video/x-mjpeg-b"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'j', 'p', '2'): + _codec (""JPEG-2000""); + /* override to what it should be according to spec, avoid palette_data */ + stream->bits_per_sample = 24; + caps = gst_caps_new_simple (""image/x-j2c"", ""fields"", G_TYPE_INT, 1, NULL); + break; + case GST_MAKE_FOURCC ('S', 'V', 'Q', '3'): + _codec (""Sorensen video v.3""); + caps = gst_caps_new_simple (""video/x-svq"", + ""svqversion"", G_TYPE_INT, 3, NULL); + break; + case GST_MAKE_FOURCC ('s', 'v', 'q', 'i'): + case GST_MAKE_FOURCC ('S', 'V', 'Q', '1'): + _codec (""Sorensen video v.1""); + caps = gst_caps_new_simple (""video/x-svq"", + ""svqversion"", G_TYPE_INT, 1, NULL); + break; + case GST_MAKE_FOURCC ('r', 'a', 'w', ' '): + { + guint16 bps; + + _codec (""Raw RGB video""); + bps = QT_UINT16 (stsd_data + 98); + /* set common stuff */ + caps = gst_caps_new_simple (""video/x-raw-rgb"", + ""endianness"", G_TYPE_INT, G_BYTE_ORDER, ""depth"", G_TYPE_INT, bps, + NULL); + + switch (bps) { + case 15: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 16, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""red_mask"", G_TYPE_INT, 0x7c00, + ""green_mask"", G_TYPE_INT, 0x03e0, + ""blue_mask"", G_TYPE_INT, 0x001f, NULL); + break; + case 16: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 16, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""red_mask"", G_TYPE_INT, 0xf800, + ""green_mask"", G_TYPE_INT, 0x07e0, + ""blue_mask"", G_TYPE_INT, 0x001f, NULL); + break; + case 24: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 24, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""red_mask"", G_TYPE_INT, 0xff0000, + ""green_mask"", G_TYPE_INT, 0x00ff00, + ""blue_mask"", G_TYPE_INT, 0x0000ff, NULL); + break; + case 32: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 32, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""alpha_mask"", G_TYPE_INT, 0xff000000, + ""red_mask"", G_TYPE_INT, 0x00ff0000, + ""green_mask"", G_TYPE_INT, 0x0000ff00, + ""blue_mask"", G_TYPE_INT, 0x000000ff, NULL); + break; + default: + /* unknown */ + break; + } + break; + } + case GST_MAKE_FOURCC ('y', 'v', '1', '2'): + _codec (""Raw planar YUV 4:2:0""); + caps = gst_caps_new_simple (""video/x-raw-yuv"", + ""format"", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), + NULL); + break; + case GST_MAKE_FOURCC ('y', 'u', 'v', '2'): + case GST_MAKE_FOURCC ('Y', 'u', 'v', '2'): + _codec (""Raw packed YUV 4:2:2""); + caps = gst_caps_new_simple (""video/x-raw-yuv"", + ""format"", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), + NULL); + break; + case GST_MAKE_FOURCC ('2', 'v', 'u', 'y'): + _codec (""Raw packed YUV 4:2:0""); + caps = gst_caps_new_simple (""video/x-raw-yuv"", + ""format"", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), + NULL); + break; + case GST_MAKE_FOURCC ('m', 'p', 'e', 'g'): + case GST_MAKE_FOURCC ('m', 'p', 'g', '1'): + _codec (""MPEG-1 video""); + caps = gst_caps_new_simple (""video/mpeg"", ""mpegversion"", G_TYPE_INT, 1, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('h', 'd', 'v', '1'): // HDV 720p30 + case GST_MAKE_FOURCC ('h', 'd', 'v', '2'): // HDV 1080i60 + case GST_MAKE_FOURCC ('h', 'd', 'v', '3'): // HDV 1080i50 + case GST_MAKE_FOURCC ('h', 'd', 'v', '5'): // HDV 720p25 + case GST_MAKE_FOURCC ('h', 'd', 'v', '6'): // HDV 1080i60 + case GST_MAKE_FOURCC ('m', 'x', '5', 'n'): // MPEG2 IMX NTSC 525/60 50mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '5', 'p'): // MPEG2 IMX PAL 625/60 50mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '4', 'n'): // MPEG2 IMX NTSC 525/60 40mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '4', 'p'): // MPEG2 IMX PAL 625/60 40mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '3', 'n'): // MPEG2 IMX NTSC 525/60 30mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '3', 'p'): // MPEG2 IMX PAL 625/50 30mb/s produced by FCP + case GST_MAKE_FOURCC ('x', 'd', 'v', '2'): // XDCAM HD 1080i60 + case GST_MAKE_FOURCC ('A', 'V', 'm', 'p'): // AVID IMX PAL + case GST_MAKE_FOURCC ('m', 'p', 'g', '2'): // AVID IMX PAL + _codec (""MPEG-2 video""); + caps = gst_caps_new_simple (""video/mpeg"", ""mpegversion"", G_TYPE_INT, 2, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('g', 'i', 'f', ' '): + _codec (""GIF still images""); + caps = gst_caps_new_simple (""image/gif"", NULL); + break; + case GST_MAKE_FOURCC ('h', '2', '6', '3'): + case GST_MAKE_FOURCC ('H', '2', '6', '3'): + case GST_MAKE_FOURCC ('s', '2', '6', '3'): + case GST_MAKE_FOURCC ('U', '2', '6', '3'): + _codec (""H.263""); + /* ffmpeg uses the height/width props, don't know why */ + caps = gst_caps_new_simple (""video/x-h263"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'p', '4', 'v'): + _codec (""MPEG-4 video""); + caps = gst_caps_new_simple (""video/mpeg"", ""mpegversion"", G_TYPE_INT, 4, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('3', 'i', 'v', 'd'): + case GST_MAKE_FOURCC ('3', 'I', 'V', 'D'): + _codec (""Microsoft MPEG-4 4.3""); /* FIXME? */ + caps = gst_caps_new_simple (""video/x-msmpeg"", + ""msmpegversion"", G_TYPE_INT, 43, NULL); + break; + case GST_MAKE_FOURCC ('3', 'I', 'V', '1'): + case GST_MAKE_FOURCC ('3', 'I', 'V', '2'): + _codec (""3ivX video""); + caps = gst_caps_new_simple (""video/x-3ivx"", NULL); + break; + case GST_MAKE_FOURCC ('D', 'I', 'V', '3'): + _codec (""DivX 3""); + caps = gst_caps_new_simple (""video/x-divx"", + ""divxversion"", G_TYPE_INT, 3, NULL); + break; + case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'): + case GST_MAKE_FOURCC ('d', 'i', 'v', 'x'): + _codec (""DivX 4""); + caps = gst_caps_new_simple (""video/x-divx"", + ""divxversion"", G_TYPE_INT, 4, NULL); + break; + case GST_MAKE_FOURCC ('D', 'X', '5', '0'): + _codec (""DivX 5""); + caps = gst_caps_new_simple (""video/x-divx"", + ""divxversion"", G_TYPE_INT, 5, NULL); + break; + case GST_MAKE_FOURCC ('X', 'V', 'I', 'D'): + case GST_MAKE_FOURCC ('x', 'v', 'i', 'd'): + _codec (""XVID MPEG-4""); + caps = gst_caps_new_simple (""video/x-xvid"", NULL); + break; + + case GST_MAKE_FOURCC ('F', 'M', 'P', '4'): + case GST_MAKE_FOURCC ('U', 'M', 'P', '4'): + caps = gst_caps_new_simple (""video/mpeg"", + ""mpegversion"", G_TYPE_INT, 4, NULL); + if (codec_name) + *codec_name = g_strdup (""FFmpeg MPEG-4""); + break; + + case GST_MAKE_FOURCC ('c', 'v', 'i', 'd'): + _codec (""Cinepak""); + caps = gst_caps_new_simple (""video/x-cinepak"", NULL); + break; + case GST_MAKE_FOURCC ('q', 'd', 'r', 'w'): + _codec (""Apple QuickDraw""); + caps = gst_caps_new_simple (""video/x-qdrw"", NULL); + break; + case GST_MAKE_FOURCC ('r', 'p', 'z', 'a'): + _codec (""Apple video""); + caps = gst_caps_new_simple (""video/x-apple-video"", NULL); + break; + case GST_MAKE_FOURCC ('a', 'v', 'c', '1'): + _codec (""H.264 / AVC""); + caps = gst_caps_new_simple (""video/x-h264"", NULL); + break; + case GST_MAKE_FOURCC ('r', 'l', 'e', ' '): + _codec (""Run-length encoding""); + caps = gst_caps_new_simple (""video/x-rle"", + ""layout"", G_TYPE_STRING, ""quicktime"", NULL); + break; + case GST_MAKE_FOURCC ('i', 'v', '3', '2'): + _codec (""Indeo Video 3""); + caps = gst_caps_new_simple (""video/x-indeo"", + ""indeoversion"", G_TYPE_INT, 3, NULL); + break; + case GST_MAKE_FOURCC ('I', 'V', '4', '1'): + case GST_MAKE_FOURCC ('i', 'v', '4', '1'): + _codec (""Intel Video 4""); + caps = gst_caps_new_simple (""video/x-indeo"", + ""indeoversion"", G_TYPE_INT, 4, NULL); + break; + case GST_MAKE_FOURCC ('d', 'v', 'c', 'p'): + case GST_MAKE_FOURCC ('d', 'v', 'c', ' '): + case GST_MAKE_FOURCC ('d', 'v', 's', 'd'): + case GST_MAKE_FOURCC ('D', 'V', 'S', 'D'): + case GST_MAKE_FOURCC ('d', 'v', 'c', 's'): + case GST_MAKE_FOURCC ('D', 'V', 'C', 'S'): + case GST_MAKE_FOURCC ('d', 'v', '2', '5'): + case GST_MAKE_FOURCC ('d', 'v', 'p', 'p'): + _codec (""DV Video""); + caps = gst_caps_new_simple (""video/x-dv"", ""dvversion"", G_TYPE_INT, 25, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('d', 'v', '5', 'n'): //DVCPRO50 NTSC + case GST_MAKE_FOURCC ('d', 'v', '5', 'p'): //DVCPRO50 PAL + _codec (""DVCPro50 Video""); + caps = gst_caps_new_simple (""video/x-dv"", ""dvversion"", G_TYPE_INT, 50, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('d', 'v', 'h', '5'): //DVCPRO HD 50i produced by FCP + case GST_MAKE_FOURCC ('d', 'v', 'h', '6'): //DVCPRO HD 60i produced by FCP + _codec (""DVCProHD Video""); + caps = gst_caps_new_simple (""video/x-dv"", ""dvversion"", G_TYPE_INT, 100, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('s', 'm', 'c', ' '): + _codec (""Apple Graphics (SMC)""); + caps = gst_caps_new_simple (""video/x-smc"", NULL); + break; + case GST_MAKE_FOURCC ('V', 'P', '3', '1'): + _codec (""VP3""); + caps = gst_caps_new_simple (""video/x-vp3"", NULL); + break; + case GST_MAKE_FOURCC ('X', 'i', 'T', 'h'): + _codec (""Theora""); + caps = gst_caps_new_simple (""video/x-theora"", NULL); + /* theora uses one byte of padding in the data stream because it does not + * allow 0 sized packets while theora does */ + stream->padding = 1; + break; + case GST_MAKE_FOURCC ('d', 'r', 'a', 'c'): + _codec (""Dirac""); + caps = gst_caps_new_simple (""video/x-dirac"", NULL); + break; + case GST_MAKE_FOURCC ('t', 'i', 'f', 'f'): + _codec (""TIFF still images""); + caps = gst_caps_new_simple (""image/tiff"", NULL); + break; + case GST_MAKE_FOURCC ('k', 'p', 'c', 'd'): + default: + { + char *s; + + s = g_strdup_printf (""video/x-gst-fourcc-%"" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (fourcc)); + caps = gst_caps_new_simple (s, NULL); + break; + } + } + + /* enable clipping for raw video streams */ + s = gst_caps_get_structure (caps, 0); + name = gst_structure_get_name (s); + if (g_str_has_prefix (name, ""video/x-raw-"")) { + stream->need_clip = TRUE; + } + return caps; +} +",0,"qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, + guint32 fourcc, const guint8 * stsd_data, gchar ** codec_name) +{ + GstCaps *caps; + const GstStructure *s; + const gchar *name; + + switch (fourcc) { + case GST_MAKE_FOURCC ('p', 'n', 'g', ' '): + _codec (""PNG still images""); + caps = gst_caps_new_simple (""image/png"", NULL); + break; + case GST_MAKE_FOURCC ('j', 'p', 'e', 'g'): + _codec (""JPEG still images""); + caps = gst_caps_new_simple (""image/jpeg"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'j', 'p', 'a'): + case GST_MAKE_FOURCC ('A', 'V', 'D', 'J'): + case GST_MAKE_FOURCC ('M', 'J', 'P', 'G'): + _codec (""Motion-JPEG""); + caps = gst_caps_new_simple (""image/jpeg"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'j', 'p', 'b'): + _codec (""Motion-JPEG format B""); + caps = gst_caps_new_simple (""video/x-mjpeg-b"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'j', 'p', '2'): + _codec (""JPEG-2000""); + /* override to what it should be according to spec, avoid palette_data */ + stream->bits_per_sample = 24; + caps = gst_caps_new_simple (""image/x-j2c"", ""fields"", G_TYPE_INT, 1, NULL); + break; + case GST_MAKE_FOURCC ('S', 'V', 'Q', '3'): + _codec (""Sorensen video v.3""); + caps = gst_caps_new_simple (""video/x-svq"", + ""svqversion"", G_TYPE_INT, 3, NULL); + break; + case GST_MAKE_FOURCC ('s', 'v', 'q', 'i'): + case GST_MAKE_FOURCC ('S', 'V', 'Q', '1'): + _codec (""Sorensen video v.1""); + caps = gst_caps_new_simple (""video/x-svq"", + ""svqversion"", G_TYPE_INT, 1, NULL); + break; + case GST_MAKE_FOURCC ('r', 'a', 'w', ' '): + { + guint16 bps; + + _codec (""Raw RGB video""); + bps = QT_UINT16 (stsd_data + 98); + /* set common stuff */ + caps = gst_caps_new_simple (""video/x-raw-rgb"", + ""endianness"", G_TYPE_INT, G_BYTE_ORDER, ""depth"", G_TYPE_INT, bps, + NULL); + + switch (bps) { + case 15: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 16, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""red_mask"", G_TYPE_INT, 0x7c00, + ""green_mask"", G_TYPE_INT, 0x03e0, + ""blue_mask"", G_TYPE_INT, 0x001f, NULL); + break; + case 16: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 16, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""red_mask"", G_TYPE_INT, 0xf800, + ""green_mask"", G_TYPE_INT, 0x07e0, + ""blue_mask"", G_TYPE_INT, 0x001f, NULL); + break; + case 24: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 24, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""red_mask"", G_TYPE_INT, 0xff0000, + ""green_mask"", G_TYPE_INT, 0x00ff00, + ""blue_mask"", G_TYPE_INT, 0x0000ff, NULL); + break; + case 32: + gst_caps_set_simple (caps, + ""bpp"", G_TYPE_INT, 32, + ""endianness"", G_TYPE_INT, G_BIG_ENDIAN, + ""alpha_mask"", G_TYPE_INT, 0xff000000, + ""red_mask"", G_TYPE_INT, 0x00ff0000, + ""green_mask"", G_TYPE_INT, 0x0000ff00, + ""blue_mask"", G_TYPE_INT, 0x000000ff, NULL); + break; + default: + /* unknown */ + break; + } + break; + } + case GST_MAKE_FOURCC ('y', 'v', '1', '2'): + _codec (""Raw planar YUV 4:2:0""); + caps = gst_caps_new_simple (""video/x-raw-yuv"", + ""format"", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), + NULL); + break; + case GST_MAKE_FOURCC ('y', 'u', 'v', '2'): + case GST_MAKE_FOURCC ('Y', 'u', 'v', '2'): + _codec (""Raw packed YUV 4:2:2""); + caps = gst_caps_new_simple (""video/x-raw-yuv"", + ""format"", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), + NULL); + break; + case GST_MAKE_FOURCC ('2', 'v', 'u', 'y'): + _codec (""Raw packed YUV 4:2:0""); + caps = gst_caps_new_simple (""video/x-raw-yuv"", + ""format"", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), + NULL); + break; + case GST_MAKE_FOURCC ('m', 'p', 'e', 'g'): + case GST_MAKE_FOURCC ('m', 'p', 'g', '1'): + _codec (""MPEG-1 video""); + caps = gst_caps_new_simple (""video/mpeg"", ""mpegversion"", G_TYPE_INT, 1, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('h', 'd', 'v', '1'): // HDV 720p30 + case GST_MAKE_FOURCC ('h', 'd', 'v', '2'): // HDV 1080i60 + case GST_MAKE_FOURCC ('h', 'd', 'v', '3'): // HDV 1080i50 + case GST_MAKE_FOURCC ('h', 'd', 'v', '5'): // HDV 720p25 + case GST_MAKE_FOURCC ('h', 'd', 'v', '6'): // HDV 1080i60 + case GST_MAKE_FOURCC ('m', 'x', '5', 'n'): // MPEG2 IMX NTSC 525/60 50mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '5', 'p'): // MPEG2 IMX PAL 625/60 50mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '4', 'n'): // MPEG2 IMX NTSC 525/60 40mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '4', 'p'): // MPEG2 IMX PAL 625/60 40mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '3', 'n'): // MPEG2 IMX NTSC 525/60 30mb/s produced by FCP + case GST_MAKE_FOURCC ('m', 'x', '3', 'p'): // MPEG2 IMX PAL 625/50 30mb/s produced by FCP + case GST_MAKE_FOURCC ('x', 'd', 'v', '2'): // XDCAM HD 1080i60 + case GST_MAKE_FOURCC ('A', 'V', 'm', 'p'): // AVID IMX PAL + case GST_MAKE_FOURCC ('m', 'p', 'g', '2'): // AVID IMX PAL + _codec (""MPEG-2 video""); + caps = gst_caps_new_simple (""video/mpeg"", ""mpegversion"", G_TYPE_INT, 2, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('g', 'i', 'f', ' '): + _codec (""GIF still images""); + caps = gst_caps_new_simple (""image/gif"", NULL); + break; + case GST_MAKE_FOURCC ('h', '2', '6', '3'): + case GST_MAKE_FOURCC ('H', '2', '6', '3'): + case GST_MAKE_FOURCC ('s', '2', '6', '3'): + case GST_MAKE_FOURCC ('U', '2', '6', '3'): + _codec (""H.263""); + /* ffmpeg uses the height/width props, don't know why */ + caps = gst_caps_new_simple (""video/x-h263"", NULL); + break; + case GST_MAKE_FOURCC ('m', 'p', '4', 'v'): + _codec (""MPEG-4 video""); + caps = gst_caps_new_simple (""video/mpeg"", ""mpegversion"", G_TYPE_INT, 4, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('3', 'i', 'v', 'd'): + case GST_MAKE_FOURCC ('3', 'I', 'V', 'D'): + _codec (""Microsoft MPEG-4 4.3""); /* FIXME? */ + caps = gst_caps_new_simple (""video/x-msmpeg"", + ""msmpegversion"", G_TYPE_INT, 43, NULL); + break; + case GST_MAKE_FOURCC ('3', 'I', 'V', '1'): + case GST_MAKE_FOURCC ('3', 'I', 'V', '2'): + _codec (""3ivX video""); + caps = gst_caps_new_simple (""video/x-3ivx"", NULL); + break; + case GST_MAKE_FOURCC ('D', 'I', 'V', '3'): + _codec (""DivX 3""); + caps = gst_caps_new_simple (""video/x-divx"", + ""divxversion"", G_TYPE_INT, 3, NULL); + break; + case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'): + case GST_MAKE_FOURCC ('d', 'i', 'v', 'x'): + _codec (""DivX 4""); + caps = gst_caps_new_simple (""video/x-divx"", + ""divxversion"", G_TYPE_INT, 4, NULL); + break; + case GST_MAKE_FOURCC ('D', 'X', '5', '0'): + _codec (""DivX 5""); + caps = gst_caps_new_simple (""video/x-divx"", + ""divxversion"", G_TYPE_INT, 5, NULL); + break; + case GST_MAKE_FOURCC ('X', 'V', 'I', 'D'): + case GST_MAKE_FOURCC ('x', 'v', 'i', 'd'): + _codec (""XVID MPEG-4""); + caps = gst_caps_new_simple (""video/x-xvid"", NULL); + break; + + case GST_MAKE_FOURCC ('F', 'M', 'P', '4'): + case GST_MAKE_FOURCC ('U', 'M', 'P', '4'): + caps = gst_caps_new_simple (""video/mpeg"", + ""mpegversion"", G_TYPE_INT, 4, NULL); + if (codec_name) + *codec_name = g_strdup (""FFmpeg MPEG-4""); + break; + + case GST_MAKE_FOURCC ('c', 'v', 'i', 'd'): + _codec (""Cinepak""); + caps = gst_caps_new_simple (""video/x-cinepak"", NULL); + break; + case GST_MAKE_FOURCC ('q', 'd', 'r', 'w'): + _codec (""Apple QuickDraw""); + caps = gst_caps_new_simple (""video/x-qdrw"", NULL); + break; + case GST_MAKE_FOURCC ('r', 'p', 'z', 'a'): + _codec (""Apple video""); + caps = gst_caps_new_simple (""video/x-apple-video"", NULL); + break; + case GST_MAKE_FOURCC ('a', 'v', 'c', '1'): + _codec (""H.264 / AVC""); + caps = gst_caps_new_simple (""video/x-h264"", NULL); + break; + case GST_MAKE_FOURCC ('r', 'l', 'e', ' '): + _codec (""Run-length encoding""); + caps = gst_caps_new_simple (""video/x-rle"", + ""layout"", G_TYPE_STRING, ""quicktime"", NULL); + break; + case GST_MAKE_FOURCC ('i', 'v', '3', '2'): + _codec (""Indeo Video 3""); + caps = gst_caps_new_simple (""video/x-indeo"", + ""indeoversion"", G_TYPE_INT, 3, NULL); + break; + case GST_MAKE_FOURCC ('I', 'V', '4', '1'): + case GST_MAKE_FOURCC ('i', 'v', '4', '1'): + _codec (""Intel Video 4""); + caps = gst_caps_new_simple (""video/x-indeo"", + ""indeoversion"", G_TYPE_INT, 4, NULL); + break; + case GST_MAKE_FOURCC ('d', 'v', 'c', 'p'): + case GST_MAKE_FOURCC ('d', 'v', 'c', ' '): + case GST_MAKE_FOURCC ('d', 'v', 's', 'd'): + case GST_MAKE_FOURCC ('D', 'V', 'S', 'D'): + case GST_MAKE_FOURCC ('d', 'v', 'c', 's'): + case GST_MAKE_FOURCC ('D', 'V', 'C', 'S'): + case GST_MAKE_FOURCC ('d', 'v', '2', '5'): + case GST_MAKE_FOURCC ('d', 'v', 'p', 'p'): + _codec (""DV Video""); + caps = gst_caps_new_simple (""video/x-dv"", ""dvversion"", G_TYPE_INT, 25, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('d', 'v', '5', 'n'): //DVCPRO50 NTSC + case GST_MAKE_FOURCC ('d', 'v', '5', 'p'): //DVCPRO50 PAL + _codec (""DVCPro50 Video""); + caps = gst_caps_new_simple (""video/x-dv"", ""dvversion"", G_TYPE_INT, 50, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('d', 'v', 'h', '5'): //DVCPRO HD 50i produced by FCP + case GST_MAKE_FOURCC ('d', 'v', 'h', '6'): //DVCPRO HD 60i produced by FCP + _codec (""DVCProHD Video""); + caps = gst_caps_new_simple (""video/x-dv"", ""dvversion"", G_TYPE_INT, 100, + ""systemstream"", G_TYPE_BOOLEAN, FALSE, NULL); + break; + case GST_MAKE_FOURCC ('s', 'm', 'c', ' '): + _codec (""Apple Graphics (SMC)""); + caps = gst_caps_new_simple (""video/x-smc"", NULL); + break; + case GST_MAKE_FOURCC ('V', 'P', '3', '1'): + _codec (""VP3""); + caps = gst_caps_new_simple (""video/x-vp3"", NULL); + break; + case GST_MAKE_FOURCC ('X', 'i', 'T', 'h'): + _codec (""Theora""); + caps = gst_caps_new_simple (""video/x-theora"", NULL); + /* theora uses one byte of padding in the data stream because it does not + * allow 0 sized packets while theora does */ + stream->padding = 1; + break; + case GST_MAKE_FOURCC ('d', 'r', 'a', 'c'): + _codec (""Dirac""); + caps = gst_caps_new_simple (""video/x-dirac"", NULL); + break; + case GST_MAKE_FOURCC ('t', 'i', 'f', 'f'): + _codec (""TIFF still images""); + caps = gst_caps_new_simple (""image/tiff"", NULL); + break; + case GST_MAKE_FOURCC ('k', 'p', 'c', 'd'): + default: + { + char *s; + + s = g_strdup_printf (""video/x-gst-fourcc-%"" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (fourcc)); + caps = gst_caps_new_simple (s, NULL); + break; + } + } + + /* enable clipping for raw video streams */ + s = gst_caps_get_structure (caps, 0); + name = gst_structure_get_name (s); + if (g_str_has_prefix (name, ""video/x-raw-"")) { + stream->need_clip = TRUE; + } + return caps; +} +","@@ -3058,13 +3058,13 @@ qtdemux_parse_samples (GstQTDemux * qtdemux, QtDemuxStream * stream, + stream->min_duration = 0; + time = 0; + index = 0; +- for (i = 0; i < n_sample_times; i++) { ++ for (i = 0; (i < n_sample_times) && (index < stream->n_samples); i++) { + guint32 n; + guint32 duration; + + n = QT_UINT32 ((guint8 *) stts->data + 16 + 8 * i); + duration = QT_UINT32 ((guint8 *) stts->data + 16 + 8 * i + 4); +- for (j = 0; j < n; j++) { ++ for (j = 0; (j < n) && (index < stream->n_samples); j++) { + GST_DEBUG_OBJECT (qtdemux, ""sample %d: timestamp %"" GST_TIME_FORMAT, + index, GST_TIME_ARGS (timestamp)); + +@@ -3092,7 +3092,7 @@ qtdemux_parse_samples (GstQTDemux * qtdemux, QtDemuxStream * stream, + for (i = 0; i < n_sample_syncs; i++) { + /* note that the first sample is index 1, not 0 */ + index = QT_UINT32 ((guint8 *) stss->data + offset); +- if (index > 0) { ++ if (index > 0 && index <= stream->n_samples) { + samples[index - 1].keyframe = TRUE; + offset += 4; + } +@@ -3191,7 +3191,7 @@ qtdemux_parse_samples (GstQTDemux * qtdemux, QtDemuxStream * stream, + for (i = 0, j = 0; (j < stream->n_samples) && (i < n_entries); i++) { + count = QT_UINT32 (ctts_data + 16 + i * 8); + soffset = QT_UINT32 (ctts_data + 20 + i * 8); +- for (k = 0; k < count; k++, j++) { ++ for (k = 0; (k < count) && (j < stream->n_samples); k++, j++) { + /* we operate with very small soffset values here, it shouldn't overflow */ + samples[j].pts_offset = soffset * GST_SECOND / stream->timescale; + }",3900,4136,6144 +18233,"NO_INLINE JsVar *jspeFactor() { + if (lex->tk==LEX_ID) { + JsVar *a = jspGetNamedVariable(jslGetTokenValueAsString(lex)); + JSP_ASSERT_MATCH(LEX_ID); +#ifndef SAVE_ON_FLASH + if (lex->tk==LEX_TEMPLATE_LITERAL) + jsExceptionHere(JSET_SYNTAXERROR, ""Tagged template literals not supported""); + else if (lex->tk==LEX_ARROW_FUNCTION && jsvIsName(a)) { + JsVar *funcVar = jspeArrowFunction(0,a); + jsvUnLock(a); + a=funcVar; + } +#endif + return a; + } else if (lex->tk==LEX_INT) { + JsVar *v = 0; + if (JSP_SHOULD_EXECUTE) { + v = jsvNewFromLongInteger(stringToInt(jslGetTokenValueAsString(lex))); + } + JSP_ASSERT_MATCH(LEX_INT); + return v; + } else if (lex->tk==LEX_FLOAT) { + JsVar *v = 0; + if (JSP_SHOULD_EXECUTE) { + v = jsvNewFromFloat(stringToFloat(jslGetTokenValueAsString(lex))); + } + JSP_ASSERT_MATCH(LEX_FLOAT); + return v; + } else if (lex->tk=='(') { + JSP_ASSERT_MATCH('('); + if (!jspCheckStackPosition()) return 0; +#ifdef SAVE_ON_FLASH + JsVar *a = jspeExpression(); + if (!JSP_SHOULDNT_PARSE) JSP_MATCH_WITH_RETURN(')',a); + return a; +#else + return jspeExpressionOrArrowFunction(); +#endif + + } else if (lex->tk==LEX_R_TRUE) { + JSP_ASSERT_MATCH(LEX_R_TRUE); + return JSP_SHOULD_EXECUTE ? jsvNewFromBool(true) : 0; + } else if (lex->tk==LEX_R_FALSE) { + JSP_ASSERT_MATCH(LEX_R_FALSE); + return JSP_SHOULD_EXECUTE ? jsvNewFromBool(false) : 0; + } else if (lex->tk==LEX_R_NULL) { + JSP_ASSERT_MATCH(LEX_R_NULL); + return JSP_SHOULD_EXECUTE ? jsvNewWithFlags(JSV_NULL) : 0; + } else if (lex->tk==LEX_R_UNDEFINED) { + JSP_ASSERT_MATCH(LEX_R_UNDEFINED); + return 0; + } else if (lex->tk==LEX_STR) { + JsVar *a = 0; + if (JSP_SHOULD_EXECUTE) + a = jslGetTokenValueAsVar(lex); + JSP_ASSERT_MATCH(LEX_STR); + return a; +#ifndef SAVE_ON_FLASH + } else if (lex->tk==LEX_TEMPLATE_LITERAL) { + return jspeTemplateLiteral(); +#endif + } else if (lex->tk==LEX_REGEX) { + JsVar *a = 0; +#ifdef SAVE_ON_FLASH + jsExceptionHere(JSET_SYNTAXERROR, ""RegEx are not supported in this version of Espruino\n""); +#else + JsVar *regex = jslGetTokenValueAsVar(lex); + size_t regexEnd = 0, regexLen = 0; + JsvStringIterator it; + jsvStringIteratorNew(&it, regex, 0); + while (jsvStringIteratorHasChar(&it)) { + regexLen++; + if (jsvStringIteratorGetChar(&it)=='/') + regexEnd = regexLen; + jsvStringIteratorNext(&it); + } + jsvStringIteratorFree(&it); + JsVar *flags = 0; + if (regexEnd < regexLen) + flags = jsvNewFromStringVar(regex, regexEnd, JSVAPPENDSTRINGVAR_MAXLENGTH); + JsVar *regexSource = jsvNewFromStringVar(regex, 1, regexEnd-2); + a = jswrap_regexp_constructor(regexSource, flags); + jsvUnLock3(regex, flags, regexSource); +#endif + JSP_ASSERT_MATCH(LEX_REGEX); + return a; + } else if (lex->tk=='{') { + if (!jspCheckStackPosition()) return 0; + return jspeFactorObject(); + } else if (lex->tk=='[') { + if (!jspCheckStackPosition()) return 0; + return jspeFactorArray(); + } else if (lex->tk==LEX_R_FUNCTION) { + if (!jspCheckStackPosition()) return 0; + JSP_ASSERT_MATCH(LEX_R_FUNCTION); + return jspeFunctionDefinition(true); +#ifndef SAVE_ON_FLASH + } else if (lex->tk==LEX_R_CLASS) { + if (!jspCheckStackPosition()) return 0; + JSP_ASSERT_MATCH(LEX_R_CLASS); + return jspeClassDefinition(true); + } else if (lex->tk==LEX_R_SUPER) { + JSP_ASSERT_MATCH(LEX_R_SUPER); + /* This is kind of nasty, since super appears to do + three different things. + + * In the constructor it references the extended class's constructor + * in a method it references the constructor's prototype. + * in a static method it references the extended class's constructor (but this is different) + */ + + if (jsvIsObject(execInfo.thisVar)) { + JsVar *proto1 = jsvObjectGetChild(execInfo.thisVar, JSPARSE_INHERITS_VAR, 0); // if we're in a method, get __proto__ first + JsVar *proto2 = jsvIsObject(proto1) ? jsvObjectGetChild(proto1, JSPARSE_INHERITS_VAR, 0) : 0; // still in method, get __proto__.__proto__ + jsvUnLock(proto1); + if (!proto2) { + jsExceptionHere(JSET_SYNTAXERROR, ""Calling 'super' outside of class""); + return 0; + } + if (lex->tk=='(') return proto2; // eg. used in a constructor + JsVar *proto3 = jsvIsFunction(proto2) ? jsvObjectGetChild(proto2, JSPARSE_PROTOTYPE_VAR, 0) : 0; + jsvUnLock(proto2); + return proto3; + } else if (jsvIsFunction(execInfo.thisVar)) { + JsVar *proto1 = jsvObjectGetChild(execInfo.thisVar, JSPARSE_PROTOTYPE_VAR, 0); + JsVar *proto2 = jsvIsObject(proto1) ? jsvObjectGetChild(proto1, JSPARSE_INHERITS_VAR, 0) : 0; + jsvUnLock(proto1); + if (!proto2) { + jsExceptionHere(JSET_SYNTAXERROR, ""Calling 'super' outside of class""); + return 0; + } + return proto2; + } + jsExceptionHere(JSET_SYNTAXERROR, ""Calling 'super' outside of class""); + return 0; +#endif + } else if (lex->tk==LEX_R_THIS) { + JSP_ASSERT_MATCH(LEX_R_THIS); + return jsvLockAgain( execInfo.thisVar ? execInfo.thisVar : execInfo.root ); + } else if (lex->tk==LEX_R_DELETE) { + if (!jspCheckStackPosition()) return 0; + return jspeFactorDelete(); + } else if (lex->tk==LEX_R_TYPEOF) { + if (!jspCheckStackPosition()) return 0; + return jspeFactorTypeOf(); + } else if (lex->tk==LEX_R_VOID) { + JSP_ASSERT_MATCH(LEX_R_VOID); + jsvUnLock(jspeUnaryExpression()); + return 0; + } + JSP_MATCH(LEX_EOF); + jsExceptionHere(JSET_SYNTAXERROR, ""Unexpected end of Input\n""); + return 0; +} + +NO_INLINE JsVar *__jspePostfixExpression(JsVar *a) { + while (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) { + int op = lex->tk; + JSP_ASSERT_MATCH(op); + if (JSP_SHOULD_EXECUTE) { + JsVar *one = jsvNewFromInteger(1); + JsVar *oldValue = jsvAsNumberAndUnLock(jsvSkipName(a)); // keep the old value (but convert to number) + JsVar *res = jsvMathsOpSkipNames(oldValue, one, op==LEX_PLUSPLUS ? '+' : '-'); + jsvUnLock(one); + + jspReplaceWith(a, res); + jsvUnLock(res); + jsvUnLock(a); + a = oldValue; + } + } + return a; +} + +NO_INLINE JsVar *jspePostfixExpression() { + JsVar *a; + if (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) { + int op = lex->tk; + JSP_ASSERT_MATCH(op); + a = jspePostfixExpression(); + if (JSP_SHOULD_EXECUTE) { + JsVar *one = jsvNewFromInteger(1); + JsVar *res = jsvMathsOpSkipNames(a, one, op==LEX_PLUSPLUS ? '+' : '-'); + jsvUnLock(one); + jspReplaceWith(a, res); + jsvUnLock(res); + } + } else + a = jspeFactorFunctionCall(); + return __jspePostfixExpression(a); +} + +NO_INLINE JsVar *jspeUnaryExpression() { + if (lex->tk=='!' || lex->tk=='~' || lex->tk=='-' || lex->tk=='+') { + short tk = lex->tk; + JSP_ASSERT_MATCH(tk); + if (!JSP_SHOULD_EXECUTE) { + return jspeUnaryExpression(); + } + if (tk=='!') { // logical not + return jsvNewFromBool(!jsvGetBoolAndUnLock(jsvSkipNameAndUnLock(jspeUnaryExpression()))); + } else if (tk=='~') { // bitwise not + return jsvNewFromInteger(~jsvGetIntegerAndUnLock(jsvSkipNameAndUnLock(jspeUnaryExpression()))); + } else if (tk=='-') { // unary minus + return jsvNegateAndUnLock(jspeUnaryExpression()); // names already skipped + } else if (tk=='+') { // unary plus (convert to number) + JsVar *v = jsvSkipNameAndUnLock(jspeUnaryExpression()); + JsVar *r = jsvAsNumber(v); // names already skipped + jsvUnLock(v); + return r; + } + assert(0); + return 0; + } else + return jspePostfixExpression(); +} + + +unsigned int jspeGetBinaryExpressionPrecedence(int op) { + switch (op) { + case LEX_OROR: return 1; break; + case LEX_ANDAND: return 2; break; + case '|' : return 3; break; + case '^' : return 4; break; + case '&' : return 5; break; + case LEX_EQUAL: + case LEX_NEQUAL: + case LEX_TYPEEQUAL: + case LEX_NTYPEEQUAL: return 6; + case LEX_LEQUAL: + case LEX_GEQUAL: + case '<': + case '>': + case LEX_R_INSTANCEOF: return 7; + case LEX_R_IN: return (execInfo.execute&EXEC_FOR_INIT)?0:7; + case LEX_LSHIFT: + case LEX_RSHIFT: + case LEX_RSHIFTUNSIGNED: return 8; + case '+': + case '-': return 9; + case '*': + case '/': + case '%': return 10; + default: return 0; + } +} + +NO_INLINE JsVar *__jspeBinaryExpression(JsVar *a, unsigned int lastPrecedence) { + /* This one's a bit strange. Basically all the ops have their own precedence, it's not + * like & and | share the same precedence. We don't want to recurse for each one, + * so instead we do this. + * + * We deal with an expression in recursion ONLY if it's of higher precedence + * than the current one, otherwise we stick in the while loop. + */ + unsigned int precedence = jspeGetBinaryExpressionPrecedence(lex->tk); + while (precedence && precedence>lastPrecedence) { + int op = lex->tk; + JSP_ASSERT_MATCH(op); + + if (op==LEX_ANDAND || op==LEX_OROR) { + bool aValue = jsvGetBoolAndUnLock(jsvSkipName(a)); + if ((!aValue && op==LEX_ANDAND) || + (aValue && op==LEX_OROR)) { + JSP_SAVE_EXECUTE(); + jspSetNoExecute(); + jsvUnLock(__jspeBinaryExpression(jspeUnaryExpression(),precedence)); + JSP_RESTORE_EXECUTE(); + } else { + jsvUnLock(a); + a = __jspeBinaryExpression(jspeUnaryExpression(),precedence); + } + } else { // else it's a more 'normal' logical expression - just use Maths + JsVar *b = __jspeBinaryExpression(jspeUnaryExpression(),precedence); + if (JSP_SHOULD_EXECUTE) { + if (op==LEX_R_IN) { + JsVar *av = jsvSkipName(a); // needle + JsVar *bv = jsvSkipName(b); // haystack + if (jsvIsArray(bv) || jsvIsObject(bv)) { // search keys, NOT values + av = jsvAsArrayIndexAndUnLock(av); + JsVar *varFound = jspGetVarNamedField( bv, av, true); + jsvUnLock(a); + a = jsvNewFromBool(varFound!=0); + jsvUnLock(varFound); + } else {// else it will be undefined + jsExceptionHere(JSET_ERROR, ""Cannot use 'in' operator to search a %t"", bv); + jsvUnLock(a); + a = 0; + } + jsvUnLock2(av, bv); + } else if (op==LEX_R_INSTANCEOF) { + bool inst = false; + JsVar *av = jsvSkipName(a); + JsVar *bv = jsvSkipName(b); + if (!jsvIsFunction(bv)) { + jsExceptionHere(JSET_ERROR, ""Expecting a function on RHS in instanceof check, got %t"", bv); + } else { + if (jsvIsObject(av) || jsvIsFunction(av)) { + JsVar *bproto = jspGetNamedField(bv, JSPARSE_PROTOTYPE_VAR, false); + JsVar *proto = jsvObjectGetChild(av, JSPARSE_INHERITS_VAR, 0); + while (proto) { + if (proto == bproto) inst=true; + JsVar *childProto = jsvObjectGetChild(proto, JSPARSE_INHERITS_VAR, 0); + jsvUnLock(proto); + proto = childProto; + } + if (jspIsConstructor(bv, ""Object"")) inst = true; + jsvUnLock(bproto); + } + if (!inst) { + const char *name = jswGetBasicObjectName(av); + if (name) { + inst = jspIsConstructor(bv, name); + } + if (!inst && (jsvIsArray(av) || jsvIsArrayBuffer(av)) && + jspIsConstructor(bv, ""Object"")) + inst = true; + } + } + jsvUnLock3(av, bv, a); + a = jsvNewFromBool(inst); + } else { // --------------------------------------------- NORMAL + JsVar *res = jsvMathsOpSkipNames(a, b, op); + jsvUnLock(a); a = res; + } + } + jsvUnLock(b); + } + precedence = jspeGetBinaryExpressionPrecedence(lex->tk); + } + return a; +} + +JsVar *jspeBinaryExpression() { + return __jspeBinaryExpression(jspeUnaryExpression(),0); +} + +NO_INLINE JsVar *__jspeConditionalExpression(JsVar *lhs) { + if (lex->tk=='?') { + JSP_ASSERT_MATCH('?'); + if (!JSP_SHOULD_EXECUTE) { + jsvUnLock(jspeAssignmentExpression()); + JSP_MATCH(':'); + jsvUnLock(jspeAssignmentExpression()); + } else { + bool first = jsvGetBoolAndUnLock(jsvSkipName(lhs)); + jsvUnLock(lhs); + if (first) { + lhs = jspeAssignmentExpression(); + JSP_MATCH(':'); + JSP_SAVE_EXECUTE(); + jspSetNoExecute(); + jsvUnLock(jspeAssignmentExpression()); + JSP_RESTORE_EXECUTE(); + } else { + JSP_SAVE_EXECUTE(); + jspSetNoExecute(); + jsvUnLock(jspeAssignmentExpression()); + JSP_RESTORE_EXECUTE(); + JSP_MATCH(':'); + lhs = jspeAssignmentExpression(); + } + } + } + + return lhs; +} + +JsVar *jspeConditionalExpression() { + return __jspeConditionalExpression(jspeBinaryExpression()); +} + +NO_INLINE JsVar *__jspeAssignmentExpression(JsVar *lhs) { + if (lex->tk=='=' || lex->tk==LEX_PLUSEQUAL || lex->tk==LEX_MINUSEQUAL || + lex->tk==LEX_MULEQUAL || lex->tk==LEX_DIVEQUAL || lex->tk==LEX_MODEQUAL || + lex->tk==LEX_ANDEQUAL || lex->tk==LEX_OREQUAL || + lex->tk==LEX_XOREQUAL || lex->tk==LEX_RSHIFTEQUAL || + lex->tk==LEX_LSHIFTEQUAL || lex->tk==LEX_RSHIFTUNSIGNEDEQUAL) { + JsVar *rhs; + + int op = lex->tk; + JSP_ASSERT_MATCH(op); + rhs = jspeAssignmentExpression(); + rhs = jsvSkipNameAndUnLock(rhs); // ensure we get rid of any references on the RHS + + if (JSP_SHOULD_EXECUTE && lhs) { + if (op=='=') { + /* If we're assigning to this and we don't have a parent, + * add it to the symbol table root */ + if (!jsvGetRefs(lhs) && jsvIsName(lhs)) { + if (!jsvIsArrayBufferName(lhs) && !jsvIsNewChild(lhs)) + jsvAddName(execInfo.root, lhs); + } + jspReplaceWith(lhs, rhs); + } else { + if (op==LEX_PLUSEQUAL) op='+'; + else if (op==LEX_MINUSEQUAL) op='-'; + else if (op==LEX_MULEQUAL) op='*'; + else if (op==LEX_DIVEQUAL) op='/'; + else if (op==LEX_MODEQUAL) op='%'; + else if (op==LEX_ANDEQUAL) op='&'; + else if (op==LEX_OREQUAL) op='|'; + else if (op==LEX_XOREQUAL) op='^'; + else if (op==LEX_RSHIFTEQUAL) op=LEX_RSHIFT; + else if (op==LEX_LSHIFTEQUAL) op=LEX_LSHIFT; + else if (op==LEX_RSHIFTUNSIGNEDEQUAL) op=LEX_RSHIFTUNSIGNED; + if (op=='+' && jsvIsName(lhs)) { + JsVar *currentValue = jsvSkipName(lhs); + if (jsvIsString(currentValue) && !jsvIsFlatString(currentValue) && jsvGetRefs(currentValue)==1 && rhs!=currentValue) { + /* A special case for string += where this is the only use of the string + * and we're not appending to ourselves. In this case we can do a + * simple append (rather than clone + append)*/ + JsVar *str = jsvAsString(rhs, false); + jsvAppendStringVarComplete(currentValue, str); + jsvUnLock(str); + op = 0; + } + jsvUnLock(currentValue); + } + if (op) { + /* Fallback which does a proper add */ + JsVar *res = jsvMathsOpSkipNames(lhs,rhs,op); + jspReplaceWith(lhs, res); + jsvUnLock(res); + } + } + } + jsvUnLock(rhs); + } + return lhs; +} + + +JsVar *jspeAssignmentExpression() { + return __jspeAssignmentExpression(jspeConditionalExpression()); +} + +NO_INLINE JsVar *jspeExpression() { + while (!JSP_SHOULDNT_PARSE) { + JsVar *a = jspeAssignmentExpression(); + if (lex->tk!=',') return a; + jsvUnLock(a); + JSP_ASSERT_MATCH(','); + } + return 0; +} + +/** Parse a block `{ ... }` but assume brackets are already parsed */ +NO_INLINE void jspeBlockNoBrackets() { + if (JSP_SHOULD_EXECUTE) { + while (lex->tk && lex->tk!='}') { + jsvUnLock(jspeStatement()); + if (JSP_HAS_ERROR) { + if (lex && !(execInfo.execute&EXEC_ERROR_LINE_REPORTED)) { + execInfo.execute = (JsExecFlags)(execInfo.execute | EXEC_ERROR_LINE_REPORTED); + JsVar *stackTrace = jsvObjectGetChild(execInfo.hiddenRoot, JSPARSE_STACKTRACE_VAR, JSV_STRING_0); + if (stackTrace) { + jsvAppendPrintf(stackTrace, ""at ""); + jspAppendStackTrace(stackTrace); + jsvUnLock(stackTrace); + } + } + } + if (JSP_SHOULDNT_PARSE) + return; + } + } else { + int brackets = 0; + while (lex->tk && (brackets || lex->tk != '}')) { + if (lex->tk == '{') brackets++; + if (lex->tk == '}') brackets--; + JSP_ASSERT_MATCH(lex->tk); + } + } +",1,"NO_INLINE JsVar *jspeFactor() { + if (lex->tk==LEX_ID) { + JsVar *a = jspGetNamedVariable(jslGetTokenValueAsString(lex)); + JSP_ASSERT_MATCH(LEX_ID); +#ifndef SAVE_ON_FLASH + if (lex->tk==LEX_TEMPLATE_LITERAL) + jsExceptionHere(JSET_SYNTAXERROR, ""Tagged template literals not supported""); + else if (lex->tk==LEX_ARROW_FUNCTION && jsvIsName(a)) { + JsVar *funcVar = jspeArrowFunction(0,a); + jsvUnLock(a); + a=funcVar; + } +#endif + return a; + } else if (lex->tk==LEX_INT) { + JsVar *v = 0; + if (JSP_SHOULD_EXECUTE) { + v = jsvNewFromLongInteger(stringToInt(jslGetTokenValueAsString(lex))); + } + JSP_ASSERT_MATCH(LEX_INT); + return v; + } else if (lex->tk==LEX_FLOAT) { + JsVar *v = 0; + if (JSP_SHOULD_EXECUTE) { + v = jsvNewFromFloat(stringToFloat(jslGetTokenValueAsString(lex))); + } + JSP_ASSERT_MATCH(LEX_FLOAT); + return v; + } else if (lex->tk=='(') { + JSP_ASSERT_MATCH('('); + if (!jspCheckStackPosition()) return 0; +#ifdef SAVE_ON_FLASH + JsVar *a = jspeExpression(); + if (!JSP_SHOULDNT_PARSE) JSP_MATCH_WITH_RETURN(')',a); + return a; +#else + return jspeExpressionOrArrowFunction(); +#endif + + } else if (lex->tk==LEX_R_TRUE) { + JSP_ASSERT_MATCH(LEX_R_TRUE); + return JSP_SHOULD_EXECUTE ? jsvNewFromBool(true) : 0; + } else if (lex->tk==LEX_R_FALSE) { + JSP_ASSERT_MATCH(LEX_R_FALSE); + return JSP_SHOULD_EXECUTE ? jsvNewFromBool(false) : 0; + } else if (lex->tk==LEX_R_NULL) { + JSP_ASSERT_MATCH(LEX_R_NULL); + return JSP_SHOULD_EXECUTE ? jsvNewWithFlags(JSV_NULL) : 0; + } else if (lex->tk==LEX_R_UNDEFINED) { + JSP_ASSERT_MATCH(LEX_R_UNDEFINED); + return 0; + } else if (lex->tk==LEX_STR) { + JsVar *a = 0; + if (JSP_SHOULD_EXECUTE) + a = jslGetTokenValueAsVar(lex); + JSP_ASSERT_MATCH(LEX_STR); + return a; +#ifndef SAVE_ON_FLASH + } else if (lex->tk==LEX_TEMPLATE_LITERAL) { + return jspeTemplateLiteral(); +#endif + } else if (lex->tk==LEX_REGEX) { + JsVar *a = 0; +#ifdef SAVE_ON_FLASH + jsExceptionHere(JSET_SYNTAXERROR, ""RegEx are not supported in this version of Espruino\n""); +#else + JsVar *regex = jslGetTokenValueAsVar(lex); + size_t regexEnd = 0, regexLen = 0; + JsvStringIterator it; + jsvStringIteratorNew(&it, regex, 0); + while (jsvStringIteratorHasChar(&it)) { + regexLen++; + if (jsvStringIteratorGetChar(&it)=='/') + regexEnd = regexLen; + jsvStringIteratorNext(&it); + } + jsvStringIteratorFree(&it); + JsVar *flags = 0; + if (regexEnd < regexLen) + flags = jsvNewFromStringVar(regex, regexEnd, JSVAPPENDSTRINGVAR_MAXLENGTH); + JsVar *regexSource = jsvNewFromStringVar(regex, 1, regexEnd-2); + a = jswrap_regexp_constructor(regexSource, flags); + jsvUnLock3(regex, flags, regexSource); +#endif + JSP_ASSERT_MATCH(LEX_REGEX); + return a; + } else if (lex->tk=='{') { + if (!jspCheckStackPosition()) return 0; + return jspeFactorObject(); + } else if (lex->tk=='[') { + if (!jspCheckStackPosition()) return 0; + return jspeFactorArray(); + } else if (lex->tk==LEX_R_FUNCTION) { + if (!jspCheckStackPosition()) return 0; + JSP_ASSERT_MATCH(LEX_R_FUNCTION); + return jspeFunctionDefinition(true); +#ifndef SAVE_ON_FLASH + } else if (lex->tk==LEX_R_CLASS) { + if (!jspCheckStackPosition()) return 0; + JSP_ASSERT_MATCH(LEX_R_CLASS); + return jspeClassDefinition(true); + } else if (lex->tk==LEX_R_SUPER) { + JSP_ASSERT_MATCH(LEX_R_SUPER); + /* This is kind of nasty, since super appears to do + three different things. + + * In the constructor it references the extended class's constructor + * in a method it references the constructor's prototype. + * in a static method it references the extended class's constructor (but this is different) + */ + + if (jsvIsObject(execInfo.thisVar)) { + JsVar *proto1 = jsvObjectGetChild(execInfo.thisVar, JSPARSE_INHERITS_VAR, 0); // if we're in a method, get __proto__ first + JsVar *proto2 = jsvIsObject(proto1) ? jsvObjectGetChild(proto1, JSPARSE_INHERITS_VAR, 0) : 0; // still in method, get __proto__.__proto__ + jsvUnLock(proto1); + if (!proto2) { + jsExceptionHere(JSET_SYNTAXERROR, ""Calling 'super' outside of class""); + return 0; + } + if (lex->tk=='(') return proto2; // eg. used in a constructor + JsVar *proto3 = jsvIsFunction(proto2) ? jsvObjectGetChild(proto2, JSPARSE_PROTOTYPE_VAR, 0) : 0; + jsvUnLock(proto2); + return proto3; + } else if (jsvIsFunction(execInfo.thisVar)) { + JsVar *proto1 = jsvObjectGetChild(execInfo.thisVar, JSPARSE_PROTOTYPE_VAR, 0); + JsVar *proto2 = jsvIsObject(proto1) ? jsvObjectGetChild(proto1, JSPARSE_INHERITS_VAR, 0) : 0; + jsvUnLock(proto1); + if (!proto2) { + jsExceptionHere(JSET_SYNTAXERROR, ""Calling 'super' outside of class""); + return 0; + } + return proto2; + } + jsExceptionHere(JSET_SYNTAXERROR, ""Calling 'super' outside of class""); + return 0; +#endif + } else if (lex->tk==LEX_R_THIS) { + JSP_ASSERT_MATCH(LEX_R_THIS); + return jsvLockAgain( execInfo.thisVar ? execInfo.thisVar : execInfo.root ); + } else if (lex->tk==LEX_R_DELETE) { + if (!jspCheckStackPosition()) return 0; + return jspeFactorDelete(); + } else if (lex->tk==LEX_R_TYPEOF) { + if (!jspCheckStackPosition()) return 0; + return jspeFactorTypeOf(); + } else if (lex->tk==LEX_R_VOID) { + if (!jspCheckStackPosition()) return 0; + JSP_ASSERT_MATCH(LEX_R_VOID); + jsvUnLock(jspeUnaryExpression()); + return 0; + } + JSP_MATCH(LEX_EOF); + jsExceptionHere(JSET_SYNTAXERROR, ""Unexpected end of Input\n""); + return 0; +} + +NO_INLINE JsVar *__jspePostfixExpression(JsVar *a) { + while (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) { + int op = lex->tk; + JSP_ASSERT_MATCH(op); + if (JSP_SHOULD_EXECUTE) { + JsVar *one = jsvNewFromInteger(1); + JsVar *oldValue = jsvAsNumberAndUnLock(jsvSkipName(a)); // keep the old value (but convert to number) + JsVar *res = jsvMathsOpSkipNames(oldValue, one, op==LEX_PLUSPLUS ? '+' : '-'); + jsvUnLock(one); + + jspReplaceWith(a, res); + jsvUnLock(res); + jsvUnLock(a); + a = oldValue; + } + } + return a; +} + +NO_INLINE JsVar *jspePostfixExpression() { + JsVar *a; + if (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) { + int op = lex->tk; + JSP_ASSERT_MATCH(op); + a = jspePostfixExpression(); + if (JSP_SHOULD_EXECUTE) { + JsVar *one = jsvNewFromInteger(1); + JsVar *res = jsvMathsOpSkipNames(a, one, op==LEX_PLUSPLUS ? '+' : '-'); + jsvUnLock(one); + jspReplaceWith(a, res); + jsvUnLock(res); + } + } else + a = jspeFactorFunctionCall(); + return __jspePostfixExpression(a); +} + +NO_INLINE JsVar *jspeUnaryExpression() { + if (lex->tk=='!' || lex->tk=='~' || lex->tk=='-' || lex->tk=='+') { + short tk = lex->tk; + JSP_ASSERT_MATCH(tk); + if (!JSP_SHOULD_EXECUTE) { + return jspeUnaryExpression(); + } + if (tk=='!') { // logical not + return jsvNewFromBool(!jsvGetBoolAndUnLock(jsvSkipNameAndUnLock(jspeUnaryExpression()))); + } else if (tk=='~') { // bitwise not + return jsvNewFromInteger(~jsvGetIntegerAndUnLock(jsvSkipNameAndUnLock(jspeUnaryExpression()))); + } else if (tk=='-') { // unary minus + return jsvNegateAndUnLock(jspeUnaryExpression()); // names already skipped + } else if (tk=='+') { // unary plus (convert to number) + JsVar *v = jsvSkipNameAndUnLock(jspeUnaryExpression()); + JsVar *r = jsvAsNumber(v); // names already skipped + jsvUnLock(v); + return r; + } + assert(0); + return 0; + } else + return jspePostfixExpression(); +} + + +unsigned int jspeGetBinaryExpressionPrecedence(int op) { + switch (op) { + case LEX_OROR: return 1; break; + case LEX_ANDAND: return 2; break; + case '|' : return 3; break; + case '^' : return 4; break; + case '&' : return 5; break; + case LEX_EQUAL: + case LEX_NEQUAL: + case LEX_TYPEEQUAL: + case LEX_NTYPEEQUAL: return 6; + case LEX_LEQUAL: + case LEX_GEQUAL: + case '<': + case '>': + case LEX_R_INSTANCEOF: return 7; + case LEX_R_IN: return (execInfo.execute&EXEC_FOR_INIT)?0:7; + case LEX_LSHIFT: + case LEX_RSHIFT: + case LEX_RSHIFTUNSIGNED: return 8; + case '+': + case '-': return 9; + case '*': + case '/': + case '%': return 10; + default: return 0; + } +} + +NO_INLINE JsVar *__jspeBinaryExpression(JsVar *a, unsigned int lastPrecedence) { + /* This one's a bit strange. Basically all the ops have their own precedence, it's not + * like & and | share the same precedence. We don't want to recurse for each one, + * so instead we do this. + * + * We deal with an expression in recursion ONLY if it's of higher precedence + * than the current one, otherwise we stick in the while loop. + */ + unsigned int precedence = jspeGetBinaryExpressionPrecedence(lex->tk); + while (precedence && precedence>lastPrecedence) { + int op = lex->tk; + JSP_ASSERT_MATCH(op); + + if (op==LEX_ANDAND || op==LEX_OROR) { + bool aValue = jsvGetBoolAndUnLock(jsvSkipName(a)); + if ((!aValue && op==LEX_ANDAND) || + (aValue && op==LEX_OROR)) { + JSP_SAVE_EXECUTE(); + jspSetNoExecute(); + jsvUnLock(__jspeBinaryExpression(jspeUnaryExpression(),precedence)); + JSP_RESTORE_EXECUTE(); + } else { + jsvUnLock(a); + a = __jspeBinaryExpression(jspeUnaryExpression(),precedence); + } + } else { // else it's a more 'normal' logical expression - just use Maths + JsVar *b = __jspeBinaryExpression(jspeUnaryExpression(),precedence); + if (JSP_SHOULD_EXECUTE) { + if (op==LEX_R_IN) { + JsVar *av = jsvSkipName(a); // needle + JsVar *bv = jsvSkipName(b); // haystack + if (jsvIsArray(bv) || jsvIsObject(bv)) { // search keys, NOT values + av = jsvAsArrayIndexAndUnLock(av); + JsVar *varFound = jspGetVarNamedField( bv, av, true); + jsvUnLock(a); + a = jsvNewFromBool(varFound!=0); + jsvUnLock(varFound); + } else {// else it will be undefined + jsExceptionHere(JSET_ERROR, ""Cannot use 'in' operator to search a %t"", bv); + jsvUnLock(a); + a = 0; + } + jsvUnLock2(av, bv); + } else if (op==LEX_R_INSTANCEOF) { + bool inst = false; + JsVar *av = jsvSkipName(a); + JsVar *bv = jsvSkipName(b); + if (!jsvIsFunction(bv)) { + jsExceptionHere(JSET_ERROR, ""Expecting a function on RHS in instanceof check, got %t"", bv); + } else { + if (jsvIsObject(av) || jsvIsFunction(av)) { + JsVar *bproto = jspGetNamedField(bv, JSPARSE_PROTOTYPE_VAR, false); + JsVar *proto = jsvObjectGetChild(av, JSPARSE_INHERITS_VAR, 0); + while (proto) { + if (proto == bproto) inst=true; + JsVar *childProto = jsvObjectGetChild(proto, JSPARSE_INHERITS_VAR, 0); + jsvUnLock(proto); + proto = childProto; + } + if (jspIsConstructor(bv, ""Object"")) inst = true; + jsvUnLock(bproto); + } + if (!inst) { + const char *name = jswGetBasicObjectName(av); + if (name) { + inst = jspIsConstructor(bv, name); + } + if (!inst && (jsvIsArray(av) || jsvIsArrayBuffer(av)) && + jspIsConstructor(bv, ""Object"")) + inst = true; + } + } + jsvUnLock3(av, bv, a); + a = jsvNewFromBool(inst); + } else { // --------------------------------------------- NORMAL + JsVar *res = jsvMathsOpSkipNames(a, b, op); + jsvUnLock(a); a = res; + } + } + jsvUnLock(b); + } + precedence = jspeGetBinaryExpressionPrecedence(lex->tk); + } + return a; +} + +JsVar *jspeBinaryExpression() { + return __jspeBinaryExpression(jspeUnaryExpression(),0); +} + +NO_INLINE JsVar *__jspeConditionalExpression(JsVar *lhs) { + if (lex->tk=='?') { + JSP_ASSERT_MATCH('?'); + if (!JSP_SHOULD_EXECUTE) { + jsvUnLock(jspeAssignmentExpression()); + JSP_MATCH(':'); + jsvUnLock(jspeAssignmentExpression()); + } else { + bool first = jsvGetBoolAndUnLock(jsvSkipName(lhs)); + jsvUnLock(lhs); + if (first) { + lhs = jspeAssignmentExpression(); + JSP_MATCH(':'); + JSP_SAVE_EXECUTE(); + jspSetNoExecute(); + jsvUnLock(jspeAssignmentExpression()); + JSP_RESTORE_EXECUTE(); + } else { + JSP_SAVE_EXECUTE(); + jspSetNoExecute(); + jsvUnLock(jspeAssignmentExpression()); + JSP_RESTORE_EXECUTE(); + JSP_MATCH(':'); + lhs = jspeAssignmentExpression(); + } + } + } + + return lhs; +} + +JsVar *jspeConditionalExpression() { + return __jspeConditionalExpression(jspeBinaryExpression()); +} + +NO_INLINE JsVar *__jspeAssignmentExpression(JsVar *lhs) { + if (lex->tk=='=' || lex->tk==LEX_PLUSEQUAL || lex->tk==LEX_MINUSEQUAL || + lex->tk==LEX_MULEQUAL || lex->tk==LEX_DIVEQUAL || lex->tk==LEX_MODEQUAL || + lex->tk==LEX_ANDEQUAL || lex->tk==LEX_OREQUAL || + lex->tk==LEX_XOREQUAL || lex->tk==LEX_RSHIFTEQUAL || + lex->tk==LEX_LSHIFTEQUAL || lex->tk==LEX_RSHIFTUNSIGNEDEQUAL) { + JsVar *rhs; + + int op = lex->tk; + JSP_ASSERT_MATCH(op); + rhs = jspeAssignmentExpression(); + rhs = jsvSkipNameAndUnLock(rhs); // ensure we get rid of any references on the RHS + + if (JSP_SHOULD_EXECUTE && lhs) { + if (op=='=') { + /* If we're assigning to this and we don't have a parent, + * add it to the symbol table root */ + if (!jsvGetRefs(lhs) && jsvIsName(lhs)) { + if (!jsvIsArrayBufferName(lhs) && !jsvIsNewChild(lhs)) + jsvAddName(execInfo.root, lhs); + } + jspReplaceWith(lhs, rhs); + } else { + if (op==LEX_PLUSEQUAL) op='+'; + else if (op==LEX_MINUSEQUAL) op='-'; + else if (op==LEX_MULEQUAL) op='*'; + else if (op==LEX_DIVEQUAL) op='/'; + else if (op==LEX_MODEQUAL) op='%'; + else if (op==LEX_ANDEQUAL) op='&'; + else if (op==LEX_OREQUAL) op='|'; + else if (op==LEX_XOREQUAL) op='^'; + else if (op==LEX_RSHIFTEQUAL) op=LEX_RSHIFT; + else if (op==LEX_LSHIFTEQUAL) op=LEX_LSHIFT; + else if (op==LEX_RSHIFTUNSIGNEDEQUAL) op=LEX_RSHIFTUNSIGNED; + if (op=='+' && jsvIsName(lhs)) { + JsVar *currentValue = jsvSkipName(lhs); + if (jsvIsString(currentValue) && !jsvIsFlatString(currentValue) && jsvGetRefs(currentValue)==1 && rhs!=currentValue) { + /* A special case for string += where this is the only use of the string + * and we're not appending to ourselves. In this case we can do a + * simple append (rather than clone + append)*/ + JsVar *str = jsvAsString(rhs, false); + jsvAppendStringVarComplete(currentValue, str); + jsvUnLock(str); + op = 0; + } + jsvUnLock(currentValue); + } + if (op) { + /* Fallback which does a proper add */ + JsVar *res = jsvMathsOpSkipNames(lhs,rhs,op); + jspReplaceWith(lhs, res); + jsvUnLock(res); + } + } + } + jsvUnLock(rhs); + } + return lhs; +} + + +JsVar *jspeAssignmentExpression() { + return __jspeAssignmentExpression(jspeConditionalExpression()); +} + +NO_INLINE JsVar *jspeExpression() { + while (!JSP_SHOULDNT_PARSE) { + JsVar *a = jspeAssignmentExpression(); + if (lex->tk!=',') return a; + jsvUnLock(a); + JSP_ASSERT_MATCH(','); + } + return 0; +} + +/** Parse a block `{ ... }` but assume brackets are already parsed */ +NO_INLINE void jspeBlockNoBrackets() { + if (JSP_SHOULD_EXECUTE) { + while (lex->tk && lex->tk!='}') { + jsvUnLock(jspeStatement()); + if (JSP_HAS_ERROR) { + if (lex && !(execInfo.execute&EXEC_ERROR_LINE_REPORTED)) { + execInfo.execute = (JsExecFlags)(execInfo.execute | EXEC_ERROR_LINE_REPORTED); + JsVar *stackTrace = jsvObjectGetChild(execInfo.hiddenRoot, JSPARSE_STACKTRACE_VAR, JSV_STRING_0); + if (stackTrace) { + jsvAppendPrintf(stackTrace, ""at ""); + jspAppendStackTrace(stackTrace); + jsvUnLock(stackTrace); + } + } + } + if (JSP_SHOULDNT_PARSE) + return; + } + } else { + int brackets = 0; + while (lex->tk && (brackets || lex->tk != '}')) { + if (lex->tk == '{') brackets++; + if (lex->tk == '}') brackets--; + JSP_ASSERT_MATCH(lex->tk); + } + } +","@@ -1716,6 +1716,7 @@ NO_INLINE JsVar *jspeFactor() { + if (!jspCheckStackPosition()) return 0; + return jspeFactorTypeOf(); + } else if (lex->tk==LEX_R_VOID) { ++ if (!jspCheckStackPosition()) return 0; + JSP_ASSERT_MATCH(LEX_R_VOID); + jsvUnLock(jspeUnaryExpression()); + return 0;",4739,4975,6144 +18804,"IHEVCD_ERROR_T ihevcd_parse_sps(codec_t *ps_codec) +{ + IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; + WORD32 value; + + WORD32 i; + WORD32 vps_id; + WORD32 sps_max_sub_layers; + WORD32 sps_id; + WORD32 sps_temporal_id_nesting_flag; + sps_t *ps_sps; + profile_tier_lvl_info_t s_ptl; + bitstrm_t *ps_bitstrm = &ps_codec->s_parse.s_bitstrm; + WORD32 ctb_log2_size_y = 0; + + + BITS_PARSE(""video_parameter_set_id"", value, ps_bitstrm, 4); + vps_id = value; + vps_id = CLIP3(vps_id, 0, MAX_VPS_CNT - 1); + + BITS_PARSE(""sps_max_sub_layers_minus1"", value, ps_bitstrm, 3); + sps_max_sub_layers = value + 1; + sps_max_sub_layers = CLIP3(sps_max_sub_layers, 1, 7); + + BITS_PARSE(""sps_temporal_id_nesting_flag"", value, ps_bitstrm, 1); + sps_temporal_id_nesting_flag = value; + + ret = ihevcd_profile_tier_level(ps_bitstrm, &(s_ptl), 1, + (sps_max_sub_layers - 1)); + + UEV_PARSE(""seq_parameter_set_id"", value, ps_bitstrm); + sps_id = value; + + if((sps_id >= MAX_SPS_CNT) || (sps_id < 0)) + { + if(ps_codec->i4_sps_done) + return IHEVCD_UNSUPPORTED_SPS_ID; + else + sps_id = 0; + } + + + ps_sps = (ps_codec->s_parse.ps_sps_base + MAX_SPS_CNT - 1); + ps_sps->i1_sps_id = sps_id; + ps_sps->i1_vps_id = vps_id; + ps_sps->i1_sps_max_sub_layers = sps_max_sub_layers; + ps_sps->i1_sps_temporal_id_nesting_flag = sps_temporal_id_nesting_flag; + /* This is used only during initialization to get reorder count etc */ + ps_codec->i4_sps_id = sps_id; + memcpy(&ps_sps->s_ptl, &s_ptl, sizeof(profile_tier_lvl_info_t)); + + UEV_PARSE(""chroma_format_idc"", value, ps_bitstrm); + ps_sps->i1_chroma_format_idc = value; + + if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_YUV420) + { + ps_codec->s_parse.i4_error_code = IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC; + return (IHEVCD_ERROR_T)IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC; + } + + if(CHROMA_FMT_IDC_YUV444_PLANES == ps_sps->i1_chroma_format_idc) + { + BITS_PARSE(""separate_colour_plane_flag"", value, ps_bitstrm, 1); + ps_sps->i1_separate_colour_plane_flag = value; + } + else + { + ps_sps->i1_separate_colour_plane_flag = 0; + } + + UEV_PARSE(""pic_width_in_luma_samples"", value, ps_bitstrm); + ps_sps->i2_pic_width_in_luma_samples = value; + + UEV_PARSE(""pic_height_in_luma_samples"", value, ps_bitstrm); + ps_sps->i2_pic_height_in_luma_samples = value; + + if((0 >= ps_sps->i2_pic_width_in_luma_samples) || (0 >= ps_sps->i2_pic_height_in_luma_samples)) + return IHEVCD_INVALID_PARAMETER; + + /* i2_pic_width_in_luma_samples and i2_pic_height_in_luma_samples + should be multiples of min_cb_size. Here these are aligned to 8, + i.e. smallest CB size */ + ps_sps->i2_pic_width_in_luma_samples = ALIGN8(ps_sps->i2_pic_width_in_luma_samples); + ps_sps->i2_pic_height_in_luma_samples = ALIGN8(ps_sps->i2_pic_height_in_luma_samples); + + BITS_PARSE(""pic_cropping_flag"", value, ps_bitstrm, 1); + ps_sps->i1_pic_cropping_flag = value; + + if(ps_sps->i1_pic_cropping_flag) + { + + UEV_PARSE(""pic_crop_left_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_left_offset = value; + + UEV_PARSE(""pic_crop_right_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_right_offset = value; + + UEV_PARSE(""pic_crop_top_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_top_offset = value; + + UEV_PARSE(""pic_crop_bottom_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_bottom_offset = value; + } + else + { + ps_sps->i2_pic_crop_left_offset = 0; + ps_sps->i2_pic_crop_right_offset = 0; + ps_sps->i2_pic_crop_top_offset = 0; + ps_sps->i2_pic_crop_bottom_offset = 0; + } + + + UEV_PARSE(""bit_depth_luma_minus8"", value, ps_bitstrm); + if(0 != value) + return IHEVCD_UNSUPPORTED_BIT_DEPTH; + + UEV_PARSE(""bit_depth_chroma_minus8"", value, ps_bitstrm); + if(0 != value) + return IHEVCD_UNSUPPORTED_BIT_DEPTH; + + UEV_PARSE(""log2_max_pic_order_cnt_lsb_minus4"", value, ps_bitstrm); + ps_sps->i1_log2_max_pic_order_cnt_lsb = value + 4; + + BITS_PARSE(""sps_sub_layer_ordering_info_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sps_sub_layer_ordering_info_present_flag = value; + + + i = (ps_sps->i1_sps_sub_layer_ordering_info_present_flag ? 0 : (ps_sps->i1_sps_max_sub_layers - 1)); + for(; i < ps_sps->i1_sps_max_sub_layers; i++) + { + UEV_PARSE(""max_dec_pic_buffering"", value, ps_bitstrm); + ps_sps->ai1_sps_max_dec_pic_buffering[i] = value + 1; + + if(ps_sps->ai1_sps_max_dec_pic_buffering[i] > MAX_DPB_SIZE) + { + return IHEVCD_INVALID_PARAMETER; + } + + UEV_PARSE(""num_reorder_pics"", value, ps_bitstrm); + ps_sps->ai1_sps_max_num_reorder_pics[i] = value; + + if(ps_sps->ai1_sps_max_num_reorder_pics[i] > ps_sps->ai1_sps_max_dec_pic_buffering[i]) + { + return IHEVCD_INVALID_PARAMETER; + } + + UEV_PARSE(""max_latency_increase"", value, ps_bitstrm); + ps_sps->ai1_sps_max_latency_increase[i] = value; + } + UEV_PARSE(""log2_min_coding_block_size_minus3"", value, ps_bitstrm); + ps_sps->i1_log2_min_coding_block_size = value + 3; + + UEV_PARSE(""log2_diff_max_min_coding_block_size"", value, ps_bitstrm); + ps_sps->i1_log2_diff_max_min_coding_block_size = value; + + ctb_log2_size_y = ps_sps->i1_log2_min_coding_block_size + ps_sps->i1_log2_diff_max_min_coding_block_size; + + UEV_PARSE(""log2_min_transform_block_size_minus2"", value, ps_bitstrm); + ps_sps->i1_log2_min_transform_block_size = value + 2; + + UEV_PARSE(""log2_diff_max_min_transform_block_size"", value, ps_bitstrm); + ps_sps->i1_log2_diff_max_min_transform_block_size = value; + + ps_sps->i1_log2_max_transform_block_size = ps_sps->i1_log2_min_transform_block_size + + ps_sps->i1_log2_diff_max_min_transform_block_size; + + if ((ps_sps->i1_log2_max_transform_block_size < 0) || + (ps_sps->i1_log2_max_transform_block_size > MIN(ctb_log2_size_y, 5))) + { + return IHEVCD_INVALID_PARAMETER; + } + + ps_sps->i1_log2_ctb_size = ps_sps->i1_log2_min_coding_block_size + + ps_sps->i1_log2_diff_max_min_coding_block_size; + + if((ps_sps->i1_log2_min_coding_block_size < 3) || + (ps_sps->i1_log2_min_transform_block_size < 2) || + (ps_sps->i1_log2_diff_max_min_transform_block_size < 0) || + (ps_sps->i1_log2_max_transform_block_size > ps_sps->i1_log2_ctb_size) || + (ps_sps->i1_log2_ctb_size < 4) || + (ps_sps->i1_log2_ctb_size > 6)) + { + return IHEVCD_INVALID_PARAMETER; + } + + ps_sps->i1_log2_min_pcm_coding_block_size = 0; + ps_sps->i1_log2_diff_max_min_pcm_coding_block_size = 0; + + UEV_PARSE(""max_transform_hierarchy_depth_inter"", value, ps_bitstrm); + ps_sps->i1_max_transform_hierarchy_depth_inter = value; + + UEV_PARSE(""max_transform_hierarchy_depth_intra"", value, ps_bitstrm); + ps_sps->i1_max_transform_hierarchy_depth_intra = value; + + /* String has a d (enabled) in order to match with HM */ + BITS_PARSE(""scaling_list_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_scaling_list_enable_flag = value; + + if(ps_sps->i1_scaling_list_enable_flag) + { + COPY_DEFAULT_SCALING_LIST(ps_sps->pi2_scaling_mat); + BITS_PARSE(""sps_scaling_list_data_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sps_scaling_list_data_present_flag = value; + + if(ps_sps->i1_sps_scaling_list_data_present_flag) + ihevcd_scaling_list_data(ps_codec, ps_sps->pi2_scaling_mat); + } + else + { + COPY_FLAT_SCALING_LIST(ps_sps->pi2_scaling_mat); + } + /* String is asymmetric_motion_partitions_enabled_flag instead of amp_enabled_flag in order to match with HM */ + BITS_PARSE(""asymmetric_motion_partitions_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_amp_enabled_flag = value; + + BITS_PARSE(""sample_adaptive_offset_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sample_adaptive_offset_enabled_flag = value; + + BITS_PARSE(""pcm_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_pcm_enabled_flag = value; + + if(ps_sps->i1_pcm_enabled_flag) + { + BITS_PARSE(""pcm_sample_bit_depth_luma"", value, ps_bitstrm, 4); + ps_sps->i1_pcm_sample_bit_depth_luma = value + 1; + + BITS_PARSE(""pcm_sample_bit_depth_chroma"", value, ps_bitstrm, 4); + ps_sps->i1_pcm_sample_bit_depth_chroma = value + 1; + + UEV_PARSE(""log2_min_pcm_coding_block_size_minus3"", value, ps_bitstrm); + ps_sps->i1_log2_min_pcm_coding_block_size = value + 3; + + UEV_PARSE(""log2_diff_max_min_pcm_coding_block_size"", value, ps_bitstrm); + ps_sps->i1_log2_diff_max_min_pcm_coding_block_size = value; + BITS_PARSE(""pcm_loop_filter_disable_flag"", value, ps_bitstrm, 1); + ps_sps->i1_pcm_loop_filter_disable_flag = value; + + } + UEV_PARSE(""num_short_term_ref_pic_sets"", value, ps_bitstrm); + ps_sps->i1_num_short_term_ref_pic_sets = value; + + ps_sps->i1_num_short_term_ref_pic_sets = CLIP3(ps_sps->i1_num_short_term_ref_pic_sets, 0, MAX_STREF_PICS_SPS); + + for(i = 0; i < ps_sps->i1_num_short_term_ref_pic_sets; i++) + ihevcd_short_term_ref_pic_set(ps_bitstrm, &ps_sps->as_stref_picset[0], ps_sps->i1_num_short_term_ref_pic_sets, i, &ps_sps->as_stref_picset[i]); + + BITS_PARSE(""long_term_ref_pics_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_long_term_ref_pics_present_flag = value; + + if(ps_sps->i1_long_term_ref_pics_present_flag) + { + UEV_PARSE(""num_long_term_ref_pics_sps"", value, ps_bitstrm); + ps_sps->i1_num_long_term_ref_pics_sps = value; + + for(i = 0; i < ps_sps->i1_num_long_term_ref_pics_sps; i++) + { + BITS_PARSE(""lt_ref_pic_poc_lsb_sps[ i ]"", value, ps_bitstrm, ps_sps->i1_log2_max_pic_order_cnt_lsb); + ps_sps->ai1_lt_ref_pic_poc_lsb_sps[i] = value; + + BITS_PARSE(""used_by_curr_pic_lt_sps_flag[ i ]"", value, ps_bitstrm, 1); + ps_sps->ai1_used_by_curr_pic_lt_sps_flag[i] = value; + } + } + + BITS_PARSE(""sps_temporal_mvp_enable_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sps_temporal_mvp_enable_flag = value; + + /* Print matches HM 8-2 */ + BITS_PARSE(""sps_strong_intra_smoothing_enable_flag"", value, ps_bitstrm, 1); + ps_sps->i1_strong_intra_smoothing_enable_flag = value; + + BITS_PARSE(""vui_parameters_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_vui_parameters_present_flag = value; + + if(ps_sps->i1_vui_parameters_present_flag) + ihevcd_parse_vui_parameters(ps_bitstrm, + &ps_sps->s_vui_parameters, + ps_sps->i1_sps_max_sub_layers - 1); + + + BITS_PARSE(""sps_extension_flag"", value, ps_bitstrm, 1); + + + { + WORD32 numerator; + WORD32 ceil_offset; + + ceil_offset = (1 << ps_sps->i1_log2_ctb_size) - 1; + numerator = ps_sps->i2_pic_width_in_luma_samples; + + ps_sps->i2_pic_wd_in_ctb = ((numerator + ceil_offset) / + (1 << ps_sps->i1_log2_ctb_size)); + + numerator = ps_sps->i2_pic_height_in_luma_samples; + ps_sps->i2_pic_ht_in_ctb = ((numerator + ceil_offset) / + (1 << ps_sps->i1_log2_ctb_size)); + + ps_sps->i4_pic_size_in_ctb = ps_sps->i2_pic_ht_in_ctb * + ps_sps->i2_pic_wd_in_ctb; + + if(0 == ps_codec->i4_sps_done) + ps_codec->s_parse.i4_next_ctb_indx = ps_sps->i4_pic_size_in_ctb; + + numerator = ps_sps->i2_pic_width_in_luma_samples; + ps_sps->i2_pic_wd_in_min_cb = numerator / + (1 << ps_sps->i1_log2_min_coding_block_size); + + numerator = ps_sps->i2_pic_height_in_luma_samples; + ps_sps->i2_pic_ht_in_min_cb = numerator / + (1 << ps_sps->i1_log2_min_coding_block_size); + } + if((0 != ps_codec->i4_first_pic_done) && + ((ps_codec->i4_wd != ps_sps->i2_pic_width_in_luma_samples) || + (ps_codec->i4_ht != ps_sps->i2_pic_height_in_luma_samples))) + { + ps_codec->i4_reset_flag = 1; + return (IHEVCD_ERROR_T)IVD_RES_CHANGED; + } + + /* Update display width and display height */ + { + WORD32 disp_wd, disp_ht; + WORD32 crop_unit_x, crop_unit_y; + crop_unit_x = 1; + crop_unit_y = 1; + + if(CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) + { + crop_unit_x = 2; + crop_unit_y = 2; + } + + disp_wd = ps_sps->i2_pic_width_in_luma_samples; + disp_wd -= ps_sps->i2_pic_crop_left_offset * crop_unit_x; + disp_wd -= ps_sps->i2_pic_crop_right_offset * crop_unit_x; + + + disp_ht = ps_sps->i2_pic_height_in_luma_samples; + disp_ht -= ps_sps->i2_pic_crop_top_offset * crop_unit_y; + disp_ht -= ps_sps->i2_pic_crop_bottom_offset * crop_unit_y; + + if((0 >= disp_wd) || (0 >= disp_ht)) + return IHEVCD_INVALID_PARAMETER; + + ps_codec->i4_disp_wd = disp_wd; + ps_codec->i4_disp_ht = disp_ht; + + + ps_codec->i4_wd = ps_sps->i2_pic_width_in_luma_samples; + ps_codec->i4_ht = ps_sps->i2_pic_height_in_luma_samples; + + { + WORD32 ref_strd; + ref_strd = ALIGN32(ps_sps->i2_pic_width_in_luma_samples + PAD_WD); + if(ps_codec->i4_strd < ref_strd) + { + ps_codec->i4_strd = ref_strd; + } + } + + if(0 == ps_codec->i4_share_disp_buf) + { + if(ps_codec->i4_disp_strd < ps_codec->i4_disp_wd) + { + ps_codec->i4_disp_strd = ps_codec->i4_disp_wd; + } + } + else + { + if(ps_codec->i4_disp_strd < ps_codec->i4_strd) + { + ps_codec->i4_disp_strd = ps_codec->i4_strd; + } + } + } + + ps_codec->i4_sps_done = 1; + return ret; +} +",1,"IHEVCD_ERROR_T ihevcd_parse_sps(codec_t *ps_codec) +{ + IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; + WORD32 value; + + WORD32 i; + WORD32 vps_id; + WORD32 sps_max_sub_layers; + WORD32 sps_id; + WORD32 sps_temporal_id_nesting_flag; + sps_t *ps_sps; + profile_tier_lvl_info_t s_ptl; + bitstrm_t *ps_bitstrm = &ps_codec->s_parse.s_bitstrm; + WORD32 ctb_log2_size_y = 0; + + + BITS_PARSE(""video_parameter_set_id"", value, ps_bitstrm, 4); + vps_id = value; + vps_id = CLIP3(vps_id, 0, MAX_VPS_CNT - 1); + + BITS_PARSE(""sps_max_sub_layers_minus1"", value, ps_bitstrm, 3); + sps_max_sub_layers = value + 1; + sps_max_sub_layers = CLIP3(sps_max_sub_layers, 1, 7); + + BITS_PARSE(""sps_temporal_id_nesting_flag"", value, ps_bitstrm, 1); + sps_temporal_id_nesting_flag = value; + + ret = ihevcd_profile_tier_level(ps_bitstrm, &(s_ptl), 1, + (sps_max_sub_layers - 1)); + + UEV_PARSE(""seq_parameter_set_id"", value, ps_bitstrm); + sps_id = value; + + if((sps_id >= MAX_SPS_CNT) || (sps_id < 0)) + { + if(ps_codec->i4_sps_done) + return IHEVCD_UNSUPPORTED_SPS_ID; + else + sps_id = 0; + } + + + ps_sps = (ps_codec->s_parse.ps_sps_base + MAX_SPS_CNT - 1); + ps_sps->i1_sps_id = sps_id; + ps_sps->i1_vps_id = vps_id; + ps_sps->i1_sps_max_sub_layers = sps_max_sub_layers; + ps_sps->i1_sps_temporal_id_nesting_flag = sps_temporal_id_nesting_flag; + /* This is used only during initialization to get reorder count etc */ + ps_codec->i4_sps_id = sps_id; + memcpy(&ps_sps->s_ptl, &s_ptl, sizeof(profile_tier_lvl_info_t)); + + UEV_PARSE(""chroma_format_idc"", value, ps_bitstrm); + ps_sps->i1_chroma_format_idc = value; + + if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_YUV420) + { + ps_codec->s_parse.i4_error_code = IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC; + return (IHEVCD_ERROR_T)IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC; + } + + if(CHROMA_FMT_IDC_YUV444_PLANES == ps_sps->i1_chroma_format_idc) + { + BITS_PARSE(""separate_colour_plane_flag"", value, ps_bitstrm, 1); + ps_sps->i1_separate_colour_plane_flag = value; + } + else + { + ps_sps->i1_separate_colour_plane_flag = 0; + } + + UEV_PARSE(""pic_width_in_luma_samples"", value, ps_bitstrm); + ps_sps->i2_pic_width_in_luma_samples = value; + + UEV_PARSE(""pic_height_in_luma_samples"", value, ps_bitstrm); + ps_sps->i2_pic_height_in_luma_samples = value; + + if((0 >= ps_sps->i2_pic_width_in_luma_samples) || (0 >= ps_sps->i2_pic_height_in_luma_samples)) + return IHEVCD_INVALID_PARAMETER; + + /* i2_pic_width_in_luma_samples and i2_pic_height_in_luma_samples + should be multiples of min_cb_size. Here these are aligned to 8, + i.e. smallest CB size */ + ps_sps->i2_pic_width_in_luma_samples = ALIGN8(ps_sps->i2_pic_width_in_luma_samples); + ps_sps->i2_pic_height_in_luma_samples = ALIGN8(ps_sps->i2_pic_height_in_luma_samples); + + BITS_PARSE(""pic_cropping_flag"", value, ps_bitstrm, 1); + ps_sps->i1_pic_cropping_flag = value; + + if(ps_sps->i1_pic_cropping_flag) + { + + UEV_PARSE(""pic_crop_left_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_left_offset = value; + + UEV_PARSE(""pic_crop_right_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_right_offset = value; + + UEV_PARSE(""pic_crop_top_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_top_offset = value; + + UEV_PARSE(""pic_crop_bottom_offset"", value, ps_bitstrm); + ps_sps->i2_pic_crop_bottom_offset = value; + } + else + { + ps_sps->i2_pic_crop_left_offset = 0; + ps_sps->i2_pic_crop_right_offset = 0; + ps_sps->i2_pic_crop_top_offset = 0; + ps_sps->i2_pic_crop_bottom_offset = 0; + } + + + UEV_PARSE(""bit_depth_luma_minus8"", value, ps_bitstrm); + if(0 != value) + return IHEVCD_UNSUPPORTED_BIT_DEPTH; + + UEV_PARSE(""bit_depth_chroma_minus8"", value, ps_bitstrm); + if(0 != value) + return IHEVCD_UNSUPPORTED_BIT_DEPTH; + + UEV_PARSE(""log2_max_pic_order_cnt_lsb_minus4"", value, ps_bitstrm); + ps_sps->i1_log2_max_pic_order_cnt_lsb = value + 4; + + BITS_PARSE(""sps_sub_layer_ordering_info_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sps_sub_layer_ordering_info_present_flag = value; + + + i = (ps_sps->i1_sps_sub_layer_ordering_info_present_flag ? 0 : (ps_sps->i1_sps_max_sub_layers - 1)); + for(; i < ps_sps->i1_sps_max_sub_layers; i++) + { + UEV_PARSE(""max_dec_pic_buffering"", value, ps_bitstrm); + ps_sps->ai1_sps_max_dec_pic_buffering[i] = value + 1; + + if(ps_sps->ai1_sps_max_dec_pic_buffering[i] > MAX_DPB_SIZE) + { + return IHEVCD_INVALID_PARAMETER; + } + + UEV_PARSE(""num_reorder_pics"", value, ps_bitstrm); + ps_sps->ai1_sps_max_num_reorder_pics[i] = value; + + if(ps_sps->ai1_sps_max_num_reorder_pics[i] > ps_sps->ai1_sps_max_dec_pic_buffering[i]) + { + return IHEVCD_INVALID_PARAMETER; + } + + UEV_PARSE(""max_latency_increase"", value, ps_bitstrm); + ps_sps->ai1_sps_max_latency_increase[i] = value; + } + UEV_PARSE(""log2_min_coding_block_size_minus3"", value, ps_bitstrm); + ps_sps->i1_log2_min_coding_block_size = value + 3; + + UEV_PARSE(""log2_diff_max_min_coding_block_size"", value, ps_bitstrm); + ps_sps->i1_log2_diff_max_min_coding_block_size = value; + + ctb_log2_size_y = ps_sps->i1_log2_min_coding_block_size + ps_sps->i1_log2_diff_max_min_coding_block_size; + + UEV_PARSE(""log2_min_transform_block_size_minus2"", value, ps_bitstrm); + ps_sps->i1_log2_min_transform_block_size = value + 2; + + UEV_PARSE(""log2_diff_max_min_transform_block_size"", value, ps_bitstrm); + ps_sps->i1_log2_diff_max_min_transform_block_size = value; + + ps_sps->i1_log2_max_transform_block_size = ps_sps->i1_log2_min_transform_block_size + + ps_sps->i1_log2_diff_max_min_transform_block_size; + + if ((ps_sps->i1_log2_max_transform_block_size < 0) || + (ps_sps->i1_log2_max_transform_block_size > MIN(ctb_log2_size_y, 5))) + { + return IHEVCD_INVALID_PARAMETER; + } + + ps_sps->i1_log2_ctb_size = ps_sps->i1_log2_min_coding_block_size + + ps_sps->i1_log2_diff_max_min_coding_block_size; + + if((ps_sps->i1_log2_min_coding_block_size < 3) || + (ps_sps->i1_log2_min_transform_block_size < 2) || + (ps_sps->i1_log2_diff_max_min_transform_block_size < 0) || + (ps_sps->i1_log2_max_transform_block_size > ps_sps->i1_log2_ctb_size) || + (ps_sps->i1_log2_ctb_size < 4) || + (ps_sps->i1_log2_ctb_size > 6)) + { + return IHEVCD_INVALID_PARAMETER; + } + + ps_sps->i1_log2_min_pcm_coding_block_size = 0; + ps_sps->i1_log2_diff_max_min_pcm_coding_block_size = 0; + + UEV_PARSE(""max_transform_hierarchy_depth_inter"", value, ps_bitstrm); + ps_sps->i1_max_transform_hierarchy_depth_inter = value; + + UEV_PARSE(""max_transform_hierarchy_depth_intra"", value, ps_bitstrm); + ps_sps->i1_max_transform_hierarchy_depth_intra = value; + + /* String has a d (enabled) in order to match with HM */ + BITS_PARSE(""scaling_list_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_scaling_list_enable_flag = value; + + if(ps_sps->i1_scaling_list_enable_flag) + { + COPY_DEFAULT_SCALING_LIST(ps_sps->pi2_scaling_mat); + BITS_PARSE(""sps_scaling_list_data_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sps_scaling_list_data_present_flag = value; + + if(ps_sps->i1_sps_scaling_list_data_present_flag) + ihevcd_scaling_list_data(ps_codec, ps_sps->pi2_scaling_mat); + } + else + { + COPY_FLAT_SCALING_LIST(ps_sps->pi2_scaling_mat); + } + /* String is asymmetric_motion_partitions_enabled_flag instead of amp_enabled_flag in order to match with HM */ + BITS_PARSE(""asymmetric_motion_partitions_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_amp_enabled_flag = value; + + BITS_PARSE(""sample_adaptive_offset_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sample_adaptive_offset_enabled_flag = value; + + BITS_PARSE(""pcm_enabled_flag"", value, ps_bitstrm, 1); + ps_sps->i1_pcm_enabled_flag = value; + + if(ps_sps->i1_pcm_enabled_flag) + { + BITS_PARSE(""pcm_sample_bit_depth_luma"", value, ps_bitstrm, 4); + ps_sps->i1_pcm_sample_bit_depth_luma = value + 1; + + BITS_PARSE(""pcm_sample_bit_depth_chroma"", value, ps_bitstrm, 4); + ps_sps->i1_pcm_sample_bit_depth_chroma = value + 1; + + UEV_PARSE(""log2_min_pcm_coding_block_size_minus3"", value, ps_bitstrm); + ps_sps->i1_log2_min_pcm_coding_block_size = value + 3; + + UEV_PARSE(""log2_diff_max_min_pcm_coding_block_size"", value, ps_bitstrm); + ps_sps->i1_log2_diff_max_min_pcm_coding_block_size = value; + BITS_PARSE(""pcm_loop_filter_disable_flag"", value, ps_bitstrm, 1); + ps_sps->i1_pcm_loop_filter_disable_flag = value; + + } + UEV_PARSE(""num_short_term_ref_pic_sets"", value, ps_bitstrm); + ps_sps->i1_num_short_term_ref_pic_sets = value; + + ps_sps->i1_num_short_term_ref_pic_sets = CLIP3(ps_sps->i1_num_short_term_ref_pic_sets, 0, MAX_STREF_PICS_SPS); + + for(i = 0; i < ps_sps->i1_num_short_term_ref_pic_sets; i++) + ihevcd_short_term_ref_pic_set(ps_bitstrm, &ps_sps->as_stref_picset[0], ps_sps->i1_num_short_term_ref_pic_sets, i, &ps_sps->as_stref_picset[i]); + + BITS_PARSE(""long_term_ref_pics_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_long_term_ref_pics_present_flag = value; + + if(ps_sps->i1_long_term_ref_pics_present_flag) + { + UEV_PARSE(""num_long_term_ref_pics_sps"", value, ps_bitstrm); + ps_sps->i1_num_long_term_ref_pics_sps = value; + + for(i = 0; i < ps_sps->i1_num_long_term_ref_pics_sps; i++) + { + BITS_PARSE(""lt_ref_pic_poc_lsb_sps[ i ]"", value, ps_bitstrm, ps_sps->i1_log2_max_pic_order_cnt_lsb); + ps_sps->ai1_lt_ref_pic_poc_lsb_sps[i] = value; + + BITS_PARSE(""used_by_curr_pic_lt_sps_flag[ i ]"", value, ps_bitstrm, 1); + ps_sps->ai1_used_by_curr_pic_lt_sps_flag[i] = value; + } + } + + BITS_PARSE(""sps_temporal_mvp_enable_flag"", value, ps_bitstrm, 1); + ps_sps->i1_sps_temporal_mvp_enable_flag = value; + + /* Print matches HM 8-2 */ + BITS_PARSE(""sps_strong_intra_smoothing_enable_flag"", value, ps_bitstrm, 1); + ps_sps->i1_strong_intra_smoothing_enable_flag = value; + + BITS_PARSE(""vui_parameters_present_flag"", value, ps_bitstrm, 1); + ps_sps->i1_vui_parameters_present_flag = value; + + if(ps_sps->i1_vui_parameters_present_flag) + ihevcd_parse_vui_parameters(ps_bitstrm, + &ps_sps->s_vui_parameters, + ps_sps->i1_sps_max_sub_layers - 1); + + + BITS_PARSE(""sps_extension_flag"", value, ps_bitstrm, 1); + + if((UWORD8 *)ps_bitstrm->pu4_buf > ps_bitstrm->pu1_buf_max) + { + return IHEVCD_INVALID_PARAMETER; + } + + { + WORD32 numerator; + WORD32 ceil_offset; + + ceil_offset = (1 << ps_sps->i1_log2_ctb_size) - 1; + numerator = ps_sps->i2_pic_width_in_luma_samples; + + ps_sps->i2_pic_wd_in_ctb = ((numerator + ceil_offset) / + (1 << ps_sps->i1_log2_ctb_size)); + + numerator = ps_sps->i2_pic_height_in_luma_samples; + ps_sps->i2_pic_ht_in_ctb = ((numerator + ceil_offset) / + (1 << ps_sps->i1_log2_ctb_size)); + + ps_sps->i4_pic_size_in_ctb = ps_sps->i2_pic_ht_in_ctb * + ps_sps->i2_pic_wd_in_ctb; + + if(0 == ps_codec->i4_sps_done) + ps_codec->s_parse.i4_next_ctb_indx = ps_sps->i4_pic_size_in_ctb; + + numerator = ps_sps->i2_pic_width_in_luma_samples; + ps_sps->i2_pic_wd_in_min_cb = numerator / + (1 << ps_sps->i1_log2_min_coding_block_size); + + numerator = ps_sps->i2_pic_height_in_luma_samples; + ps_sps->i2_pic_ht_in_min_cb = numerator / + (1 << ps_sps->i1_log2_min_coding_block_size); + } + if((0 != ps_codec->i4_first_pic_done) && + ((ps_codec->i4_wd != ps_sps->i2_pic_width_in_luma_samples) || + (ps_codec->i4_ht != ps_sps->i2_pic_height_in_luma_samples))) + { + ps_codec->i4_reset_flag = 1; + return (IHEVCD_ERROR_T)IVD_RES_CHANGED; + } + + /* Update display width and display height */ + { + WORD32 disp_wd, disp_ht; + WORD32 crop_unit_x, crop_unit_y; + crop_unit_x = 1; + crop_unit_y = 1; + + if(CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) + { + crop_unit_x = 2; + crop_unit_y = 2; + } + + disp_wd = ps_sps->i2_pic_width_in_luma_samples; + disp_wd -= ps_sps->i2_pic_crop_left_offset * crop_unit_x; + disp_wd -= ps_sps->i2_pic_crop_right_offset * crop_unit_x; + + + disp_ht = ps_sps->i2_pic_height_in_luma_samples; + disp_ht -= ps_sps->i2_pic_crop_top_offset * crop_unit_y; + disp_ht -= ps_sps->i2_pic_crop_bottom_offset * crop_unit_y; + + if((0 >= disp_wd) || (0 >= disp_ht)) + return IHEVCD_INVALID_PARAMETER; + + ps_codec->i4_disp_wd = disp_wd; + ps_codec->i4_disp_ht = disp_ht; + + + ps_codec->i4_wd = ps_sps->i2_pic_width_in_luma_samples; + ps_codec->i4_ht = ps_sps->i2_pic_height_in_luma_samples; + + { + WORD32 ref_strd; + ref_strd = ALIGN32(ps_sps->i2_pic_width_in_luma_samples + PAD_WD); + if(ps_codec->i4_strd < ref_strd) + { + ps_codec->i4_strd = ref_strd; + } + } + + if(0 == ps_codec->i4_share_disp_buf) + { + if(ps_codec->i4_disp_strd < ps_codec->i4_disp_wd) + { + ps_codec->i4_disp_strd = ps_codec->i4_disp_wd; + } + } + else + { + if(ps_codec->i4_disp_strd < ps_codec->i4_strd) + { + ps_codec->i4_disp_strd = ps_codec->i4_strd; + } + } + } + + ps_codec->i4_sps_done = 1; + return ret; +} +","@@ -1462,6 +1462,10 @@ + + + BITS_PARSE(""sps_extension_flag"", value, ps_bitstrm, 1); + ++ if((UWORD8 *)ps_bitstrm->pu4_buf > ps_bitstrm->pu1_buf_max) ++ { ++ return IHEVCD_INVALID_PARAMETER; ++ } + + { + WORD32 numerator; +",4126,4362,6144 +1571,"int udhcpc_main(int argc UNUSED_PARAM, char **argv) +{ + uint8_t *message; + const char *str_V, *str_h, *str_F, *str_r; + IF_FEATURE_UDHCPC_ARPING(const char *str_a = ""2000"";) + IF_FEATURE_UDHCP_PORT(char *str_P;) + void *clientid_mac_ptr; + llist_t *list_O = NULL; + llist_t *list_x = NULL; + int tryagain_timeout = 20; + int discover_timeout = 3; + int discover_retries = 3; + uint32_t server_addr = server_addr; /* for compiler */ + uint32_t requested_ip = 0; + uint32_t xid = xid; /* for compiler */ + int packet_num; + int timeout; /* must be signed */ + unsigned already_waited_sec; + unsigned opt; + IF_FEATURE_UDHCPC_ARPING(unsigned arpping_ms;) + int max_fd; + int retval; + fd_set rfds; + + /* Default options */ + IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) + IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) + client_config.interface = ""eth0""; + client_config.script = CONFIG_UDHCPC_DEFAULT_SCRIPT; + str_V = ""udhcp ""BB_VER; + + /* Parse command line */ + /* O,x: list; -T,-t,-A take numeric param */ + opt_complementary = ""O::x::T+:t+:A+"" IF_UDHCP_VERBOSE("":vv"") ; + IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) + opt = getopt32(argv, ""CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"" + USE_FOR_MMU(""b"") + IF_FEATURE_UDHCPC_ARPING(""a::"") + IF_FEATURE_UDHCP_PORT(""P:"") + ""v"" + , &str_V, &str_h, &str_h, &str_F + , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ + , &client_config.script /* s */ + , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ + , &list_O + , &list_x + IF_FEATURE_UDHCPC_ARPING(, &str_a) + IF_FEATURE_UDHCP_PORT(, &str_P) + IF_UDHCP_VERBOSE(, &dhcp_verbose) + ); + if (opt & (OPT_h|OPT_H)) { + bb_error_msg(""option -h NAME is deprecated, use -x hostname:NAME""); + client_config.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0); + } + if (opt & OPT_F) { + /* FQDN option format: [0x51][len][flags][0][0] */ + client_config.fqdn = alloc_dhcp_option(DHCP_FQDN, str_F, 3); + /* Flag bits: 0000NEOS + * S: 1 = Client requests server to update A RR in DNS as well as PTR + * O: 1 = Server indicates to client that DNS has been updated regardless + * E: 1 = Name is in DNS format, i.e. <4>host<6>domain<3>com<0>, + * not ""host.domain.com"". Format 0 is obsolete. + * N: 1 = Client requests server to not update DNS (S must be 0 then) + * Two [0] bytes which follow are deprecated and must be 0. + */ + client_config.fqdn[OPT_DATA + 0] = 0x1; + /*client_config.fqdn[OPT_DATA + 1] = 0; - xzalloc did it */ + /*client_config.fqdn[OPT_DATA + 2] = 0; */ + } + if (opt & OPT_r) + requested_ip = inet_addr(str_r); +#if ENABLE_FEATURE_UDHCP_PORT + if (opt & OPT_P) { + CLIENT_PORT = xatou16(str_P); + SERVER_PORT = CLIENT_PORT - 1; + } +#endif + IF_FEATURE_UDHCPC_ARPING(arpping_ms = xatou(str_a);) + while (list_O) { + char *optstr = llist_pop(&list_O); + unsigned n = bb_strtou(optstr, NULL, 0); + if (errno || n > 254) { + n = udhcp_option_idx(optstr); + n = dhcp_optflags[n].code; + } + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + } + if (!(opt & OPT_o)) { + unsigned i, n; + for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) { + if (dhcp_optflags[i].flags & OPTION_REQ) { + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + } + } + } + while (list_x) { + char *optstr = llist_pop(&list_x); + char *colon = strchr(optstr, ':'); + if (colon) + *colon = ' '; + /* now it looks similar to udhcpd's config file line: + * ""optname optval"", using the common routine: */ + udhcp_str2optset(optstr, &client_config.options); + } + + if (udhcp_read_interface(client_config.interface, + &client_config.ifindex, + NULL, + client_config.client_mac) + ) { + return 1; + } + + clientid_mac_ptr = NULL; + if (!(opt & OPT_C) && !udhcp_find_option(client_config.options, DHCP_CLIENT_ID)) { + /* not suppressed and not set, set the default client ID */ + client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, """", 7); + client_config.clientid[OPT_DATA] = 1; /* type: ethernet */ + clientid_mac_ptr = client_config.clientid + OPT_DATA+1; + memcpy(clientid_mac_ptr, client_config.client_mac, 6); + } + if (str_V[0] != '\0') { + client_config.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0); + } + +#if !BB_MMU + /* on NOMMU reexec (i.e., background) early */ + if (!(opt & OPT_f)) { + bb_daemonize_or_rexec(0 /* flags */, argv); + logmode = LOGMODE_NONE; + } +#endif + if (opt & OPT_S) { + openlog(applet_name, LOG_PID, LOG_DAEMON); + logmode |= LOGMODE_SYSLOG; + } + + /* Make sure fd 0,1,2 are open */ + bb_sanitize_stdio(); + /* Equivalent of doing a fflush after every \n */ + setlinebuf(stdout); + /* Create pidfile */ + write_pidfile(client_config.pidfile); + /* Goes to stdout (unless NOMMU) and possibly syslog */ + bb_info_msg(""%s (v""BB_VER"") started"", applet_name); + /* Set up the signal pipe */ + udhcp_sp_setup(); + /* We want random_xid to be random... */ + srand(monotonic_us()); + + state = INIT_SELECTING; + udhcp_run_script(NULL, ""deconfig""); + change_listen_mode(LISTEN_RAW); + packet_num = 0; + timeout = 0; + already_waited_sec = 0; + + /* Main event loop. select() waits on signal pipe and possibly + * on sockfd. + * ""continue"" statements in code below jump to the top of the loop. + */ + for (;;) { + struct timeval tv; + struct dhcp_packet packet; + /* silence ""uninitialized!"" warning */ + unsigned timestamp_before_wait = timestamp_before_wait; + + + /* Was opening raw or udp socket here + * if (listen_mode != LISTEN_NONE && sockfd < 0), + * but on fast network renew responses return faster + * than we open sockets. Thus this code is moved + * to change_listen_mode(). Thus we open listen socket + * BEFORE we send renew request (see ""case BOUND:""). */ + + max_fd = udhcp_sp_fd_set(&rfds, sockfd); + + tv.tv_sec = timeout - already_waited_sec; + tv.tv_usec = 0; + retval = 0; + /* If we already timed out, fall through with retval = 0, else... */ + if ((int)tv.tv_sec > 0) { + log1(""Waiting on select %u seconds"", (int)tv.tv_sec); + timestamp_before_wait = (unsigned)monotonic_sec(); + retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); + if (retval < 0) { + /* EINTR? A signal was caught, don't panic */ + if (errno == EINTR) { + already_waited_sec += (unsigned)monotonic_sec() - timestamp_before_wait; + continue; + } + /* Else: an error occured, panic! */ + bb_perror_msg_and_die(""select""); + } + } + + /* If timeout dropped to zero, time to become active: + * resend discover/renew/whatever + */ + if (retval == 0) { + /* When running on a bridge, the ifindex may have changed + * (e.g. if member interfaces were added/removed + * or if the status of the bridge changed). + * Refresh ifindex and client_mac: + */ + if (udhcp_read_interface(client_config.interface, + &client_config.ifindex, + NULL, + client_config.client_mac) + ) { + goto ret0; /* iface is gone? */ + } + if (clientid_mac_ptr) + memcpy(clientid_mac_ptr, client_config.client_mac, 6); + + /* We will restart the wait in any case */ + already_waited_sec = 0; + + switch (state) { + case INIT_SELECTING: + if (!discover_retries || packet_num < discover_retries) { + if (packet_num == 0) + xid = random_xid(); + /* broadcast */ + send_discover(xid, requested_ip); + timeout = discover_timeout; + packet_num++; + continue; + } + leasefail: + udhcp_run_script(NULL, ""leasefail""); +#if BB_MMU /* -b is not supported on NOMMU */ + if (opt & OPT_b) { /* background if no lease */ + bb_info_msg(""No lease, forking to background""); + client_background(); + /* do not background again! */ + opt = ((opt & ~OPT_b) | OPT_f); + } else +#endif + if (opt & OPT_n) { /* abort if no lease */ + bb_info_msg(""No lease, failing""); + retval = 1; + goto ret; + } + /* wait before trying again */ + timeout = tryagain_timeout; + packet_num = 0; + continue; + case REQUESTING: + if (!discover_retries || packet_num < discover_retries) { + /* send broadcast select packet */ + send_select(xid, server_addr, requested_ip); + timeout = discover_timeout; + packet_num++; + continue; + } + /* Timed out, go back to init state. + * ""discover...select...discover..."" loops + * were seen in the wild. Treat them similarly + * to ""no response to discover"" case */ + change_listen_mode(LISTEN_RAW); + state = INIT_SELECTING; + goto leasefail; + case BOUND: + /* 1/2 lease passed, enter renewing state */ + state = RENEWING; + client_config.first_secs = 0; /* make secs field count from 0 */ + change_listen_mode(LISTEN_KERNEL); + log1(""Entering renew state""); + /* fall right through */ + case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ + case_RENEW_REQUESTED: + case RENEWING: + if (timeout > 60) { + /* send an unicast renew request */ + /* Sometimes observed to fail (EADDRNOTAVAIL) to bind + * a new UDP socket for sending inside send_renew. + * I hazard to guess existing listening socket + * is somehow conflicting with it, but why is it + * not deterministic then?! Strange. + * Anyway, it does recover by eventually failing through + * into INIT_SELECTING state. + */ + send_renew(xid, server_addr, requested_ip); + timeout >>= 1; + continue; + } + /* Timed out, enter rebinding state */ + log1(""Entering rebinding state""); + state = REBINDING; + /* fall right through */ + case REBINDING: + /* Switch to bcast receive */ + change_listen_mode(LISTEN_RAW); + /* Lease is *really* about to run out, + * try to find DHCP server using broadcast */ + if (timeout > 0) { + /* send a broadcast renew request */ + send_renew(xid, 0 /*INADDR_ANY*/, requested_ip); + timeout >>= 1; + continue; + } + /* Timed out, enter init state */ + bb_info_msg(""Lease lost, entering init state""); + udhcp_run_script(NULL, ""deconfig""); + state = INIT_SELECTING; + client_config.first_secs = 0; /* make secs field count from 0 */ + /*timeout = 0; - already is */ + packet_num = 0; + continue; + /* case RELEASED: */ + } + /* yah, I know, *you* say it would never happen */ + timeout = INT_MAX; + continue; /* back to main loop */ + } /* if select timed out */ + + /* select() didn't timeout, something happened */ + + /* Is it a signal? */ + /* note: udhcp_sp_read checks FD_ISSET before reading */ + switch (udhcp_sp_read(&rfds)) { + case SIGUSR1: + client_config.first_secs = 0; /* make secs field count from 0 */ + already_waited_sec = 0; + perform_renew(); + if (state == RENEW_REQUESTED) { + /* We might be either on the same network + * (in which case renew might work), + * or we might be on a completely different one + * (in which case renew won't ever succeed). + * For the second case, must make sure timeout + * is not too big, or else we can send + * futile renew requests for hours. + * (Ab)use -A TIMEOUT value (usually 20 sec) + * as a cap on the timeout. + */ + if (timeout > tryagain_timeout) + timeout = tryagain_timeout; + goto case_RENEW_REQUESTED; + } + /* Start things over */ + packet_num = 0; + /* Kill any timeouts, user wants this to hurry along */ + timeout = 0; + continue; + case SIGUSR2: + perform_release(server_addr, requested_ip); + timeout = INT_MAX; + continue; + case SIGTERM: + bb_info_msg(""Received SIGTERM""); + goto ret0; + } + + /* Is it a packet? */ + if (listen_mode == LISTEN_NONE || !FD_ISSET(sockfd, &rfds)) + continue; /* no */ + + { + int len; + + /* A packet is ready, read it */ + if (listen_mode == LISTEN_KERNEL) + len = udhcp_recv_kernel_packet(&packet, sockfd); + else + len = udhcp_recv_raw_packet(&packet, sockfd); + if (len == -1) { + /* Error is severe, reopen socket */ + bb_info_msg(""Read error: %s, reopening socket"", strerror(errno)); + sleep(discover_timeout); /* 3 seconds by default */ + change_listen_mode(listen_mode); /* just close and reopen */ + } + /* If this packet will turn out to be unrelated/bogus, + * we will go back and wait for next one. + * Be sure timeout is properly decreased. */ + already_waited_sec += (unsigned)monotonic_sec() - timestamp_before_wait; + if (len < 0) + continue; + } + + if (packet.xid != xid) { + log1(""xid %x (our is %x), ignoring packet"", + (unsigned)packet.xid, (unsigned)xid); + continue; + } + + /* Ignore packets that aren't for us */ + if (packet.hlen != 6 + || memcmp(packet.chaddr, client_config.client_mac, 6) != 0 + ) { + log1(""chaddr does not match, ignoring packet""); // log2? + continue; + } + + message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); + if (message == NULL) { + bb_error_msg(""no message type option, ignoring packet""); + continue; + } + + switch (state) { + case INIT_SELECTING: + /* Must be a DHCPOFFER */ + if (*message == DHCPOFFER) { + uint8_t *temp; + +/* What exactly is server's IP? There are several values. + * Example DHCP offer captured with tchdump: + * + * 10.34.25.254:67 > 10.34.25.202:68 // IP header's src + * BOOTP fields: + * Your-IP 10.34.25.202 + * Server-IP 10.34.32.125 // ""next server"" IP + * Gateway-IP 10.34.25.254 // relay's address (if DHCP relays are in use) + * DHCP options: + * DHCP-Message Option 53, length 1: Offer + * Server-ID Option 54, length 4: 10.34.255.7 // ""server ID"" + * Default-Gateway Option 3, length 4: 10.34.25.254 // router + * + * We think that real server IP (one to use in renew/release) + * is one in Server-ID option. But I am not 100% sure. + * IP header's src and Gateway-IP (same in this example) + * might work too. + * ""Next server"" and router are definitely wrong ones to use, though... + */ +/* We used to ignore pcakets without DHCP_SERVER_ID. + * I've got user reports from people who run ""address-less"" servers. + * They either supply DHCP_SERVER_ID of 0.0.0.0 or don't supply it at all. + * They say ISC DHCP client supports this case. + */ + server_addr = 0; + temp = udhcp_get_option(&packet, DHCP_SERVER_ID); + if (!temp) { + bb_error_msg(""no server ID, using 0.0.0.0""); + } else { + /* it IS unaligned sometimes, don't ""optimize"" */ + move_from_unaligned32(server_addr, temp); + } + /*xid = packet.xid; - already is */ + requested_ip = packet.yiaddr; + + /* enter requesting state */ + state = REQUESTING; + timeout = 0; + packet_num = 0; + already_waited_sec = 0; + } + continue; + case REQUESTING: + case RENEWING: + case RENEW_REQUESTED: + case REBINDING: + if (*message == DHCPACK) { + unsigned start; + uint32_t lease_seconds; + struct in_addr temp_addr; + uint8_t *temp; + + temp = udhcp_get_option(&packet, DHCP_LEASE_TIME); + if (!temp) { + bb_error_msg(""no lease time with ACK, using 1 hour lease""); + lease_seconds = 60 * 60; + } else { + /* it IS unaligned sometimes, don't ""optimize"" */ + move_from_unaligned32(lease_seconds, temp); + lease_seconds = ntohl(lease_seconds); + /* paranoia: must not be too small and not prone to overflows */ + if (lease_seconds < 0x10) + lease_seconds = 0x10; + if (lease_seconds >= 0x10000000) + lease_seconds = 0x0fffffff; + } +#if ENABLE_FEATURE_UDHCPC_ARPING + if (opt & OPT_a) { +/* RFC 2131 3.1 paragraph 5: + * ""The client receives the DHCPACK message with configuration + * parameters. The client SHOULD perform a final check on the + * parameters (e.g., ARP for allocated network address), and notes + * the duration of the lease specified in the DHCPACK message. At this + * point, the client is configured. If the client detects that the + * address is already in use (e.g., through the use of ARP), + * the client MUST send a DHCPDECLINE message to the server and restarts + * the configuration process..."" */ + if (!arpping(packet.yiaddr, + NULL, + (uint32_t) 0, + client_config.client_mac, + client_config.interface, + arpping_ms) + ) { + bb_info_msg(""Offered address is in use "" + ""(got ARP reply), declining""); + send_decline(/*xid,*/ server_addr, packet.yiaddr); + + if (state != REQUESTING) + udhcp_run_script(NULL, ""deconfig""); + change_listen_mode(LISTEN_RAW); + state = INIT_SELECTING; + client_config.first_secs = 0; /* make secs field count from 0 */ + requested_ip = 0; + timeout = tryagain_timeout; + packet_num = 0; + already_waited_sec = 0; + continue; /* back to main loop */ + } + } +#endif + /* enter bound state */ + temp_addr.s_addr = packet.yiaddr; + bb_info_msg(""Lease of %s obtained, lease time %u"", + inet_ntoa(temp_addr), (unsigned)lease_seconds); + requested_ip = packet.yiaddr; + + start = monotonic_sec(); + udhcp_run_script(&packet, state == REQUESTING ? ""bound"" : ""renew""); + already_waited_sec = (unsigned)monotonic_sec() - start; + timeout = lease_seconds / 2; + if ((unsigned)timeout < already_waited_sec) { + /* Something went wrong. Back to discover state */ + timeout = already_waited_sec = 0; + } + + state = BOUND; + change_listen_mode(LISTEN_NONE); + if (opt & OPT_q) { /* quit after lease */ + goto ret0; + } + /* future renew failures should not exit (JM) */ + opt &= ~OPT_n; +#if BB_MMU /* NOMMU case backgrounded earlier */ + if (!(opt & OPT_f)) { + client_background(); + /* do not background again! */ + opt = ((opt & ~OPT_b) | OPT_f); + } +#endif + /* make future renew packets use different xid */ + /* xid = random_xid(); ...but why bother? */ + + continue; /* back to main loop */ + } + if (*message == DHCPNAK) { + /* If network has more than one DHCP server, + * ""wrong"" server can reply first, with a NAK. + * Do not interpret it as a NAK from ""our"" server. + */ + if (server_addr != 0) { + uint32_t svid; + uint8_t *temp; + + temp = udhcp_get_option(&packet, DHCP_SERVER_ID); + if (!temp) { + non_matching_svid: + log1(""%s with wrong server ID, ignoring packet"", + ""Received DHCP NAK"" + ); + continue; + } + move_from_unaligned32(svid, temp); + if (svid != server_addr) + goto non_matching_svid; + } + /* return to init state */ + bb_info_msg(""Received DHCP NAK""); + udhcp_run_script(&packet, ""nak""); + if (state != REQUESTING) + udhcp_run_script(NULL, ""deconfig""); + change_listen_mode(LISTEN_RAW); + sleep(3); /* avoid excessive network traffic */ + state = INIT_SELECTING; + client_config.first_secs = 0; /* make secs field count from 0 */ + requested_ip = 0; + timeout = 0; + packet_num = 0; + already_waited_sec = 0; + } + continue; + /* case BOUND: - ignore all packets */ + /* case RELEASED: - ignore all packets */ + } + /* back to main loop */ + } /* for (;;) - main loop ends */ + + ret0: + if (opt & OPT_R) /* release on quit */ + perform_release(server_addr, requested_ip); + retval = 0; + ret: + /*if (client_config.pidfile) - remove_pidfile has its own check */ + remove_pidfile(client_config.pidfile); + return retval; +} +",0,"int udhcpc_main(int argc UNUSED_PARAM, char **argv) +{ + uint8_t *message; + const char *str_V, *str_h, *str_F, *str_r; + IF_FEATURE_UDHCPC_ARPING(const char *str_a = ""2000"";) + IF_FEATURE_UDHCP_PORT(char *str_P;) + void *clientid_mac_ptr; + llist_t *list_O = NULL; + llist_t *list_x = NULL; + int tryagain_timeout = 20; + int discover_timeout = 3; + int discover_retries = 3; + uint32_t server_addr = server_addr; /* for compiler */ + uint32_t requested_ip = 0; + uint32_t xid = xid; /* for compiler */ + int packet_num; + int timeout; /* must be signed */ + unsigned already_waited_sec; + unsigned opt; + IF_FEATURE_UDHCPC_ARPING(unsigned arpping_ms;) + int max_fd; + int retval; + fd_set rfds; + + /* Default options */ + IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) + IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) + client_config.interface = ""eth0""; + client_config.script = CONFIG_UDHCPC_DEFAULT_SCRIPT; + str_V = ""udhcp ""BB_VER; + + /* Parse command line */ + /* O,x: list; -T,-t,-A take numeric param */ + opt_complementary = ""O::x::T+:t+:A+"" IF_UDHCP_VERBOSE("":vv"") ; + IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) + opt = getopt32(argv, ""CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"" + USE_FOR_MMU(""b"") + IF_FEATURE_UDHCPC_ARPING(""a::"") + IF_FEATURE_UDHCP_PORT(""P:"") + ""v"" + , &str_V, &str_h, &str_h, &str_F + , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ + , &client_config.script /* s */ + , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ + , &list_O + , &list_x + IF_FEATURE_UDHCPC_ARPING(, &str_a) + IF_FEATURE_UDHCP_PORT(, &str_P) + IF_UDHCP_VERBOSE(, &dhcp_verbose) + ); + if (opt & (OPT_h|OPT_H)) { + bb_error_msg(""option -h NAME is deprecated, use -x hostname:NAME""); + client_config.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0); + } + if (opt & OPT_F) { + /* FQDN option format: [0x51][len][flags][0][0] */ + client_config.fqdn = alloc_dhcp_option(DHCP_FQDN, str_F, 3); + /* Flag bits: 0000NEOS + * S: 1 = Client requests server to update A RR in DNS as well as PTR + * O: 1 = Server indicates to client that DNS has been updated regardless + * E: 1 = Name is in DNS format, i.e. <4>host<6>domain<3>com<0>, + * not ""host.domain.com"". Format 0 is obsolete. + * N: 1 = Client requests server to not update DNS (S must be 0 then) + * Two [0] bytes which follow are deprecated and must be 0. + */ + client_config.fqdn[OPT_DATA + 0] = 0x1; + /*client_config.fqdn[OPT_DATA + 1] = 0; - xzalloc did it */ + /*client_config.fqdn[OPT_DATA + 2] = 0; */ + } + if (opt & OPT_r) + requested_ip = inet_addr(str_r); +#if ENABLE_FEATURE_UDHCP_PORT + if (opt & OPT_P) { + CLIENT_PORT = xatou16(str_P); + SERVER_PORT = CLIENT_PORT - 1; + } +#endif + IF_FEATURE_UDHCPC_ARPING(arpping_ms = xatou(str_a);) + while (list_O) { + char *optstr = llist_pop(&list_O); + unsigned n = bb_strtou(optstr, NULL, 0); + if (errno || n > 254) { + n = udhcp_option_idx(optstr); + n = dhcp_optflags[n].code; + } + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + } + if (!(opt & OPT_o)) { + unsigned i, n; + for (i = 0; (n = dhcp_optflags[i].code) != 0; i++) { + if (dhcp_optflags[i].flags & OPTION_REQ) { + client_config.opt_mask[n >> 3] |= 1 << (n & 7); + } + } + } + while (list_x) { + char *optstr = llist_pop(&list_x); + char *colon = strchr(optstr, ':'); + if (colon) + *colon = ' '; + /* now it looks similar to udhcpd's config file line: + * ""optname optval"", using the common routine: */ + udhcp_str2optset(optstr, &client_config.options); + } + + if (udhcp_read_interface(client_config.interface, + &client_config.ifindex, + NULL, + client_config.client_mac) + ) { + return 1; + } + + clientid_mac_ptr = NULL; + if (!(opt & OPT_C) && !udhcp_find_option(client_config.options, DHCP_CLIENT_ID)) { + /* not suppressed and not set, set the default client ID */ + client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, """", 7); + client_config.clientid[OPT_DATA] = 1; /* type: ethernet */ + clientid_mac_ptr = client_config.clientid + OPT_DATA+1; + memcpy(clientid_mac_ptr, client_config.client_mac, 6); + } + if (str_V[0] != '\0') { + client_config.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0); + } + +#if !BB_MMU + /* on NOMMU reexec (i.e., background) early */ + if (!(opt & OPT_f)) { + bb_daemonize_or_rexec(0 /* flags */, argv); + logmode = LOGMODE_NONE; + } +#endif + if (opt & OPT_S) { + openlog(applet_name, LOG_PID, LOG_DAEMON); + logmode |= LOGMODE_SYSLOG; + } + + /* Make sure fd 0,1,2 are open */ + bb_sanitize_stdio(); + /* Equivalent of doing a fflush after every \n */ + setlinebuf(stdout); + /* Create pidfile */ + write_pidfile(client_config.pidfile); + /* Goes to stdout (unless NOMMU) and possibly syslog */ + bb_info_msg(""%s (v""BB_VER"") started"", applet_name); + /* Set up the signal pipe */ + udhcp_sp_setup(); + /* We want random_xid to be random... */ + srand(monotonic_us()); + + state = INIT_SELECTING; + udhcp_run_script(NULL, ""deconfig""); + change_listen_mode(LISTEN_RAW); + packet_num = 0; + timeout = 0; + already_waited_sec = 0; + + /* Main event loop. select() waits on signal pipe and possibly + * on sockfd. + * ""continue"" statements in code below jump to the top of the loop. + */ + for (;;) { + struct timeval tv; + struct dhcp_packet packet; + /* silence ""uninitialized!"" warning */ + unsigned timestamp_before_wait = timestamp_before_wait; + + + /* Was opening raw or udp socket here + * if (listen_mode != LISTEN_NONE && sockfd < 0), + * but on fast network renew responses return faster + * than we open sockets. Thus this code is moved + * to change_listen_mode(). Thus we open listen socket + * BEFORE we send renew request (see ""case BOUND:""). */ + + max_fd = udhcp_sp_fd_set(&rfds, sockfd); + + tv.tv_sec = timeout - already_waited_sec; + tv.tv_usec = 0; + retval = 0; + /* If we already timed out, fall through with retval = 0, else... */ + if ((int)tv.tv_sec > 0) { + log1(""Waiting on select %u seconds"", (int)tv.tv_sec); + timestamp_before_wait = (unsigned)monotonic_sec(); + retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); + if (retval < 0) { + /* EINTR? A signal was caught, don't panic */ + if (errno == EINTR) { + already_waited_sec += (unsigned)monotonic_sec() - timestamp_before_wait; + continue; + } + /* Else: an error occured, panic! */ + bb_perror_msg_and_die(""select""); + } + } + + /* If timeout dropped to zero, time to become active: + * resend discover/renew/whatever + */ + if (retval == 0) { + /* When running on a bridge, the ifindex may have changed + * (e.g. if member interfaces were added/removed + * or if the status of the bridge changed). + * Refresh ifindex and client_mac: + */ + if (udhcp_read_interface(client_config.interface, + &client_config.ifindex, + NULL, + client_config.client_mac) + ) { + goto ret0; /* iface is gone? */ + } + if (clientid_mac_ptr) + memcpy(clientid_mac_ptr, client_config.client_mac, 6); + + /* We will restart the wait in any case */ + already_waited_sec = 0; + + switch (state) { + case INIT_SELECTING: + if (!discover_retries || packet_num < discover_retries) { + if (packet_num == 0) + xid = random_xid(); + /* broadcast */ + send_discover(xid, requested_ip); + timeout = discover_timeout; + packet_num++; + continue; + } + leasefail: + udhcp_run_script(NULL, ""leasefail""); +#if BB_MMU /* -b is not supported on NOMMU */ + if (opt & OPT_b) { /* background if no lease */ + bb_info_msg(""No lease, forking to background""); + client_background(); + /* do not background again! */ + opt = ((opt & ~OPT_b) | OPT_f); + } else +#endif + if (opt & OPT_n) { /* abort if no lease */ + bb_info_msg(""No lease, failing""); + retval = 1; + goto ret; + } + /* wait before trying again */ + timeout = tryagain_timeout; + packet_num = 0; + continue; + case REQUESTING: + if (!discover_retries || packet_num < discover_retries) { + /* send broadcast select packet */ + send_select(xid, server_addr, requested_ip); + timeout = discover_timeout; + packet_num++; + continue; + } + /* Timed out, go back to init state. + * ""discover...select...discover..."" loops + * were seen in the wild. Treat them similarly + * to ""no response to discover"" case */ + change_listen_mode(LISTEN_RAW); + state = INIT_SELECTING; + goto leasefail; + case BOUND: + /* 1/2 lease passed, enter renewing state */ + state = RENEWING; + client_config.first_secs = 0; /* make secs field count from 0 */ + change_listen_mode(LISTEN_KERNEL); + log1(""Entering renew state""); + /* fall right through */ + case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ + case_RENEW_REQUESTED: + case RENEWING: + if (timeout > 60) { + /* send an unicast renew request */ + /* Sometimes observed to fail (EADDRNOTAVAIL) to bind + * a new UDP socket for sending inside send_renew. + * I hazard to guess existing listening socket + * is somehow conflicting with it, but why is it + * not deterministic then?! Strange. + * Anyway, it does recover by eventually failing through + * into INIT_SELECTING state. + */ + send_renew(xid, server_addr, requested_ip); + timeout >>= 1; + continue; + } + /* Timed out, enter rebinding state */ + log1(""Entering rebinding state""); + state = REBINDING; + /* fall right through */ + case REBINDING: + /* Switch to bcast receive */ + change_listen_mode(LISTEN_RAW); + /* Lease is *really* about to run out, + * try to find DHCP server using broadcast */ + if (timeout > 0) { + /* send a broadcast renew request */ + send_renew(xid, 0 /*INADDR_ANY*/, requested_ip); + timeout >>= 1; + continue; + } + /* Timed out, enter init state */ + bb_info_msg(""Lease lost, entering init state""); + udhcp_run_script(NULL, ""deconfig""); + state = INIT_SELECTING; + client_config.first_secs = 0; /* make secs field count from 0 */ + /*timeout = 0; - already is */ + packet_num = 0; + continue; + /* case RELEASED: */ + } + /* yah, I know, *you* say it would never happen */ + timeout = INT_MAX; + continue; /* back to main loop */ + } /* if select timed out */ + + /* select() didn't timeout, something happened */ + + /* Is it a signal? */ + /* note: udhcp_sp_read checks FD_ISSET before reading */ + switch (udhcp_sp_read(&rfds)) { + case SIGUSR1: + client_config.first_secs = 0; /* make secs field count from 0 */ + already_waited_sec = 0; + perform_renew(); + if (state == RENEW_REQUESTED) { + /* We might be either on the same network + * (in which case renew might work), + * or we might be on a completely different one + * (in which case renew won't ever succeed). + * For the second case, must make sure timeout + * is not too big, or else we can send + * futile renew requests for hours. + * (Ab)use -A TIMEOUT value (usually 20 sec) + * as a cap on the timeout. + */ + if (timeout > tryagain_timeout) + timeout = tryagain_timeout; + goto case_RENEW_REQUESTED; + } + /* Start things over */ + packet_num = 0; + /* Kill any timeouts, user wants this to hurry along */ + timeout = 0; + continue; + case SIGUSR2: + perform_release(server_addr, requested_ip); + timeout = INT_MAX; + continue; + case SIGTERM: + bb_info_msg(""Received SIGTERM""); + goto ret0; + } + + /* Is it a packet? */ + if (listen_mode == LISTEN_NONE || !FD_ISSET(sockfd, &rfds)) + continue; /* no */ + + { + int len; + + /* A packet is ready, read it */ + if (listen_mode == LISTEN_KERNEL) + len = udhcp_recv_kernel_packet(&packet, sockfd); + else + len = udhcp_recv_raw_packet(&packet, sockfd); + if (len == -1) { + /* Error is severe, reopen socket */ + bb_info_msg(""Read error: %s, reopening socket"", strerror(errno)); + sleep(discover_timeout); /* 3 seconds by default */ + change_listen_mode(listen_mode); /* just close and reopen */ + } + /* If this packet will turn out to be unrelated/bogus, + * we will go back and wait for next one. + * Be sure timeout is properly decreased. */ + already_waited_sec += (unsigned)monotonic_sec() - timestamp_before_wait; + if (len < 0) + continue; + } + + if (packet.xid != xid) { + log1(""xid %x (our is %x), ignoring packet"", + (unsigned)packet.xid, (unsigned)xid); + continue; + } + + /* Ignore packets that aren't for us */ + if (packet.hlen != 6 + || memcmp(packet.chaddr, client_config.client_mac, 6) != 0 + ) { + log1(""chaddr does not match, ignoring packet""); // log2? + continue; + } + + message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); + if (message == NULL) { + bb_error_msg(""no message type option, ignoring packet""); + continue; + } + + switch (state) { + case INIT_SELECTING: + /* Must be a DHCPOFFER */ + if (*message == DHCPOFFER) { + uint8_t *temp; + +/* What exactly is server's IP? There are several values. + * Example DHCP offer captured with tchdump: + * + * 10.34.25.254:67 > 10.34.25.202:68 // IP header's src + * BOOTP fields: + * Your-IP 10.34.25.202 + * Server-IP 10.34.32.125 // ""next server"" IP + * Gateway-IP 10.34.25.254 // relay's address (if DHCP relays are in use) + * DHCP options: + * DHCP-Message Option 53, length 1: Offer + * Server-ID Option 54, length 4: 10.34.255.7 // ""server ID"" + * Default-Gateway Option 3, length 4: 10.34.25.254 // router + * + * We think that real server IP (one to use in renew/release) + * is one in Server-ID option. But I am not 100% sure. + * IP header's src and Gateway-IP (same in this example) + * might work too. + * ""Next server"" and router are definitely wrong ones to use, though... + */ +/* We used to ignore pcakets without DHCP_SERVER_ID. + * I've got user reports from people who run ""address-less"" servers. + * They either supply DHCP_SERVER_ID of 0.0.0.0 or don't supply it at all. + * They say ISC DHCP client supports this case. + */ + server_addr = 0; + temp = udhcp_get_option(&packet, DHCP_SERVER_ID); + if (!temp) { + bb_error_msg(""no server ID, using 0.0.0.0""); + } else { + /* it IS unaligned sometimes, don't ""optimize"" */ + move_from_unaligned32(server_addr, temp); + } + /*xid = packet.xid; - already is */ + requested_ip = packet.yiaddr; + + /* enter requesting state */ + state = REQUESTING; + timeout = 0; + packet_num = 0; + already_waited_sec = 0; + } + continue; + case REQUESTING: + case RENEWING: + case RENEW_REQUESTED: + case REBINDING: + if (*message == DHCPACK) { + unsigned start; + uint32_t lease_seconds; + struct in_addr temp_addr; + uint8_t *temp; + + temp = udhcp_get_option(&packet, DHCP_LEASE_TIME); + if (!temp) { + bb_error_msg(""no lease time with ACK, using 1 hour lease""); + lease_seconds = 60 * 60; + } else { + /* it IS unaligned sometimes, don't ""optimize"" */ + move_from_unaligned32(lease_seconds, temp); + lease_seconds = ntohl(lease_seconds); + /* paranoia: must not be too small and not prone to overflows */ + if (lease_seconds < 0x10) + lease_seconds = 0x10; + if (lease_seconds >= 0x10000000) + lease_seconds = 0x0fffffff; + } +#if ENABLE_FEATURE_UDHCPC_ARPING + if (opt & OPT_a) { +/* RFC 2131 3.1 paragraph 5: + * ""The client receives the DHCPACK message with configuration + * parameters. The client SHOULD perform a final check on the + * parameters (e.g., ARP for allocated network address), and notes + * the duration of the lease specified in the DHCPACK message. At this + * point, the client is configured. If the client detects that the + * address is already in use (e.g., through the use of ARP), + * the client MUST send a DHCPDECLINE message to the server and restarts + * the configuration process..."" */ + if (!arpping(packet.yiaddr, + NULL, + (uint32_t) 0, + client_config.client_mac, + client_config.interface, + arpping_ms) + ) { + bb_info_msg(""Offered address is in use "" + ""(got ARP reply), declining""); + send_decline(/*xid,*/ server_addr, packet.yiaddr); + + if (state != REQUESTING) + udhcp_run_script(NULL, ""deconfig""); + change_listen_mode(LISTEN_RAW); + state = INIT_SELECTING; + client_config.first_secs = 0; /* make secs field count from 0 */ + requested_ip = 0; + timeout = tryagain_timeout; + packet_num = 0; + already_waited_sec = 0; + continue; /* back to main loop */ + } + } +#endif + /* enter bound state */ + temp_addr.s_addr = packet.yiaddr; + bb_info_msg(""Lease of %s obtained, lease time %u"", + inet_ntoa(temp_addr), (unsigned)lease_seconds); + requested_ip = packet.yiaddr; + + start = monotonic_sec(); + udhcp_run_script(&packet, state == REQUESTING ? ""bound"" : ""renew""); + already_waited_sec = (unsigned)monotonic_sec() - start; + timeout = lease_seconds / 2; + if ((unsigned)timeout < already_waited_sec) { + /* Something went wrong. Back to discover state */ + timeout = already_waited_sec = 0; + } + + state = BOUND; + change_listen_mode(LISTEN_NONE); + if (opt & OPT_q) { /* quit after lease */ + goto ret0; + } + /* future renew failures should not exit (JM) */ + opt &= ~OPT_n; +#if BB_MMU /* NOMMU case backgrounded earlier */ + if (!(opt & OPT_f)) { + client_background(); + /* do not background again! */ + opt = ((opt & ~OPT_b) | OPT_f); + } +#endif + /* make future renew packets use different xid */ + /* xid = random_xid(); ...but why bother? */ + + continue; /* back to main loop */ + } + if (*message == DHCPNAK) { + /* If network has more than one DHCP server, + * ""wrong"" server can reply first, with a NAK. + * Do not interpret it as a NAK from ""our"" server. + */ + if (server_addr != 0) { + uint32_t svid; + uint8_t *temp; + + temp = udhcp_get_option(&packet, DHCP_SERVER_ID); + if (!temp) { + non_matching_svid: + log1(""%s with wrong server ID, ignoring packet"", + ""Received DHCP NAK"" + ); + continue; + } + move_from_unaligned32(svid, temp); + if (svid != server_addr) + goto non_matching_svid; + } + /* return to init state */ + bb_info_msg(""Received DHCP NAK""); + udhcp_run_script(&packet, ""nak""); + if (state != REQUESTING) + udhcp_run_script(NULL, ""deconfig""); + change_listen_mode(LISTEN_RAW); + sleep(3); /* avoid excessive network traffic */ + state = INIT_SELECTING; + client_config.first_secs = 0; /* make secs field count from 0 */ + requested_ip = 0; + timeout = 0; + packet_num = 0; + already_waited_sec = 0; + } + continue; + /* case BOUND: - ignore all packets */ + /* case RELEASED: - ignore all packets */ + } + /* back to main loop */ + } /* for (;;) - main loop ends */ + + ret0: + if (opt & OPT_R) /* release on quit */ + perform_release(server_addr, requested_ip); + retval = 0; + ret: + /*if (client_config.pidfile) - remove_pidfile has its own check */ + remove_pidfile(client_config.pidfile); + return retval; +} +","@@ -113,7 +113,7 @@ static const uint8_t len_of_option_as_string[] = { + [OPTION_IP ] = sizeof(""255.255.255.255 ""), + [OPTION_IP_PAIR ] = sizeof(""255.255.255.255 "") * 2, + [OPTION_STATIC_ROUTES ] = sizeof(""255.255.255.255/32 255.255.255.255 ""), +- [OPTION_6RD ] = sizeof(""32 128 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 255.255.255.255 ""), ++ [OPTION_6RD ] = sizeof(""132 128 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 255.255.255.255 ""), + [OPTION_STRING ] = 1, + [OPTION_STRING_HOST ] = 1, + #if ENABLE_FEATURE_UDHCP_RFC3397 +@@ -222,7 +222,7 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ + type = optflag->flags & OPTION_TYPE_MASK; + optlen = dhcp_option_lengths[type]; + upper_length = len_of_option_as_string[type] +- * ((unsigned)(len + optlen - 1) / (unsigned)optlen); ++ * ((unsigned)(len + optlen) / (unsigned)optlen); + + dest = ret = xmalloc(upper_length + strlen(opt_name) + 2); + dest += sprintf(ret, ""%s="", opt_name);",5555,5791,6144 +11896,"InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements) +{ + reset(); + + ASSERT(resolver.position().root() == m_block); + + bool appliedStartWidth = resolver.position().m_pos > 0; + bool includeEndWidth = true; + LineMidpointState& lineMidpointState = resolver.midpointState(); + + LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block->style())); + + skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width); + + if (resolver.position().atEnd()) + return resolver.position(); + + bool ignoringSpaces = false; + InlineIterator ignoreStart; + + bool currentCharacterIsSpace = false; + bool currentCharacterShouldCollapseIfPreWap = false; + TrailingObjects trailingObjects; + + InlineIterator lBreak = resolver.position(); + + InlineIterator current = resolver.position(); + RenderObject* last = current.m_obj; + bool atStart = true; + + bool startingNewParagraph = lineInfo.previousLineBrokeCleanly(); + lineInfo.setPreviousLineBrokeCleanly(false); + + bool autoWrapWasEverTrueOnLine = false; + bool floatsFitOnLine = true; + + RenderStyle* blockStyle = m_block->style(); + bool allowImagesToBreak = !m_block->document().inQuirksMode() || !m_block->isTableCell() || !blockStyle->logicalWidth().isIntrinsicOrAuto(); + + EWhiteSpace currWS = blockStyle->whiteSpace(); + EWhiteSpace lastWS = currWS; + while (current.m_obj) { + RenderStyle* currentStyle = current.m_obj->style(); + RenderObject* next = bidiNextSkippingEmptyInlines(m_block, current.m_obj); + if (next && next->parent() && !next->parent()->isDescendantOf(current.m_obj->parent())) + includeEndWidth = true; + + currWS = current.m_obj->isReplaced() ? current.m_obj->parent()->style()->whiteSpace() : currentStyle->whiteSpace(); + lastWS = last->isReplaced() ? last->parent()->style()->whiteSpace() : last->style()->whiteSpace(); + + bool autoWrap = RenderStyle::autoWrap(currWS); + autoWrapWasEverTrueOnLine = autoWrapWasEverTrueOnLine || autoWrap; + + bool preserveNewline = current.m_obj->isSVGInlineText() ? false : RenderStyle::preserveNewline(currWS); + + bool collapseWhiteSpace = RenderStyle::collapseWhiteSpace(currWS); + + if (current.m_obj->isBR()) { + if (width.fitsOnLine()) { + lBreak.moveToStartOf(current.m_obj); + lBreak.increment(); + + if (startingNewParagraph) + lineInfo.setEmpty(false, m_block, &width); + trailingObjects.clear(); + lineInfo.setPreviousLineBrokeCleanly(true); + + if (ignoringSpaces && currentStyle->clear() != CNONE) + ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj); + + if (!lineInfo.isEmpty()) + m_clear = currentStyle->clear(); + } + goto end; + } + + if (current.m_obj->isOutOfFlowPositioned()) { + RenderBox* box = toRenderBox(current.m_obj); + bool isInlineType = box->style()->isOriginalDisplayInlineType(); + if (!isInlineType) + m_block->setStaticInlinePositionForChild(box, m_block->logicalHeight(), m_block->startOffsetForContent(m_block->logicalHeight())); + else { + box->layer()->setStaticBlockPosition(m_block->logicalHeight()); + } + + if (isInlineType || current.m_obj->container()->isRenderInline()) { + if (ignoringSpaces) + ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj); + trailingObjects.appendBoxIfNeeded(box); + } else + m_positionedObjects.append(box); + width.addUncommittedWidth(inlineLogicalWidth(current.m_obj)); + renderTextInfo.m_lineBreakIterator.resetPriorContext(); + } else if (current.m_obj->isFloating()) { + RenderBox* floatBox = toRenderBox(current.m_obj); + FloatingObject* f = m_block->insertFloatingObject(floatBox); + if (floatsFitOnLine && width.fitsOnLine(f->logicalWidth(m_block->isHorizontalWritingMode()))) { + m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, lineInfo, width); + if (lBreak.m_obj == current.m_obj) { + ASSERT(!lBreak.m_pos); + lBreak.increment(); + } + } else + floatsFitOnLine = false; + renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter); + } else if (current.m_obj->isRenderInline()) { + ASSERT(isEmptyInline(current.m_obj)); + + RenderInline* flowBox = toRenderInline(current.m_obj); + + bool requiresLineBox = alwaysRequiresLineBox(current.m_obj); + if (requiresLineBox || requiresLineBoxForContent(flowBox, lineInfo)) { + if (requiresLineBox) + lineInfo.setEmpty(false, m_block, &width); + if (ignoringSpaces) { + trailingObjects.clear(); + ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj); + } else if (blockStyle->collapseWhiteSpace() && resolver.position().m_obj == current.m_obj + && shouldSkipWhitespaceAfterStartObject(m_block, current.m_obj, lineMidpointState)) { + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = true; + ignoringSpaces = true; + } + } + + width.addUncommittedWidth(inlineLogicalWidth(current.m_obj) + borderPaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)); + } else if (current.m_obj->isReplaced()) { + RenderBox* replacedBox = toRenderBox(current.m_obj); + + if (atStart) + width.updateAvailableWidth(replacedBox->logicalHeight()); + + if ((autoWrap || RenderStyle::autoWrap(lastWS)) && (!current.m_obj->isImage() || allowImagesToBreak)) { + width.commit(); + lBreak.moveToStartOf(current.m_obj); + } + + if (ignoringSpaces) + stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, 0)); + + lineInfo.setEmpty(false, m_block, &width); + ignoringSpaces = false; + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = false; + trailingObjects.clear(); + + LayoutUnit replacedLogicalWidth = m_block->logicalWidthForChild(replacedBox) + m_block->marginStartForChild(replacedBox) + m_block->marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj); + if (current.m_obj->isListMarker()) { + if (blockStyle->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, current.m_obj, lineMidpointState)) { + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = true; + ignoringSpaces = true; + } + if (toRenderListMarker(current.m_obj)->isInside()) + width.addUncommittedWidth(replacedLogicalWidth); + } else + width.addUncommittedWidth(replacedLogicalWidth); + if (current.m_obj->isRubyRun()) + width.applyOverhang(toRenderRubyRun(current.m_obj), last, next); + renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter); + } else if (current.m_obj->isText()) { + if (!current.m_pos) + appliedStartWidth = false; + + RenderText* t = toRenderText(current.m_obj); + + bool isSVGText = t->isSVGInlineText(); + + if (t->style()->hasTextCombine() && current.m_obj->isCombineText() && !toRenderCombineText(current.m_obj)->isCombined()) { + RenderCombineText* combineRenderer = toRenderCombineText(current.m_obj); + combineRenderer->combineText(); + if (iteratorIsBeyondEndOfRenderCombineText(lBreak, combineRenderer)) { + ASSERT(iteratorIsBeyondEndOfRenderCombineText(resolver.position(), combineRenderer)); + lBreak.increment(); + resolver.increment(); + } + } + + RenderStyle* style = t->style(lineInfo.isFirstLine()); + const Font& f = style->font(); + bool isFixedPitch = f.isFixedPitch(); + + unsigned lastSpace = current.m_pos; + float wordSpacing = currentStyle->wordSpacing(); + float lastSpaceWordSpacing = 0; + float wordSpacingForWordMeasurement = 0; + + float wrapW = width.uncommittedWidth() + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true); + float charWidth = 0; + bool breakWords = currentStyle->breakWords() && ((autoWrap && !width.committedWidth()) || currWS == PRE); + bool midWordBreak = false; + bool breakAll = currentStyle->wordBreak() == BreakAllWordBreak && autoWrap; + float hyphenWidth = 0; + + if (isSVGText) { + breakWords = false; + breakAll = false; + } + + if (t->isWordBreak()) { + width.commit(); + lBreak.moveToStartOf(current.m_obj); + ASSERT(current.m_pos == t->textLength()); + } + + if (renderTextInfo.m_text != t) { + renderTextInfo.m_text = t; + renderTextInfo.m_font = &f; + renderTextInfo.m_layout = f.createLayout(t, width.currentWidth(), collapseWhiteSpace); + renderTextInfo.m_lineBreakIterator.resetStringAndReleaseIterator(t->text(), style->locale()); + } else if (renderTextInfo.m_layout && renderTextInfo.m_font != &f) { + renderTextInfo.m_font = &f; + renderTextInfo.m_layout = f.createLayout(t, width.currentWidth(), collapseWhiteSpace); + } + + TextLayout* textLayout = renderTextInfo.m_layout.get(); + + float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0; + + UChar lastCharacter = renderTextInfo.m_lineBreakIterator.lastCharacter(); + UChar secondToLastCharacter = renderTextInfo.m_lineBreakIterator.secondToLastCharacter(); + for (; current.m_pos < t->textLength(); current.fastIncrementInTextNode()) { + bool previousCharacterIsSpace = currentCharacterIsSpace; + bool previousCharacterShouldCollapseIfPreWap = currentCharacterShouldCollapseIfPreWap; + UChar c = current.current(); + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = c == ' ' || c == '\t' || (!preserveNewline && (c == '\n')); + + if (!collapseWhiteSpace || !currentCharacterIsSpace) + lineInfo.setEmpty(false, m_block, &width); + + if (c == softHyphen && autoWrap && !hyphenWidth) { + hyphenWidth = measureHyphenWidth(t, f); + width.addUncommittedWidth(hyphenWidth); + } + + bool applyWordSpacing = false; + + if ((breakAll || breakWords) && !midWordBreak) { + wrapW += charWidth; + bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && current.m_pos + 1 < t->textLength() && U16_IS_TRAIL((*t)[current.m_pos + 1]); + charWidth = textWidth(t, current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace, 0, textLayout); + midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth(); + } + + bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(renderTextInfo.m_lineBreakIterator, current.m_pos, current.m_nextBreakablePosition)); + + if (betweenWords || midWordBreak) { + bool stoppedIgnoringSpaces = false; + if (ignoringSpaces) { + lastSpaceWordSpacing = 0; + if (!currentCharacterIsSpace) { + ignoringSpaces = false; + wordSpacingForWordMeasurement = 0; + lastSpace = current.m_pos; // e.g., ""Foo goo"", don't add in any of the ignored spaces. + stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); + stoppedIgnoringSpaces = true; + } else { + goto nextCharacter; + } + } + + wordMeasurements.grow(wordMeasurements.size() + 1); + WordMeasurement& wordMeasurement = wordMeasurements.last(); + + wordMeasurement.renderer = t; + wordMeasurement.endOffset = current.m_pos; + wordMeasurement.startOffset = lastSpace; + + float additionalTmpW; + if (wordTrailingSpaceWidth && c == ' ') + additionalTmpW = textWidth(t, lastSpace, current.m_pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth; + else + additionalTmpW = textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout); + + wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasurement; + additionalTmpW += lastSpaceWordSpacing; + width.addUncommittedWidth(additionalTmpW); + if (!appliedStartWidth) { + width.addUncommittedWidth(inlineLogicalWidth(current.m_obj, true, false)); + appliedStartWidth = true; + } + + applyWordSpacing = wordSpacing && currentCharacterIsSpace; + + if (!width.committedWidth() && autoWrap && !width.fitsOnLine()) + width.fitBelowFloats(); + + if (autoWrap || breakWords) { + bool lineWasTooWide = false; + if (width.fitsOnLine() && currentCharacterIsSpace && currentStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { + float charWidth = textWidth(t, current.m_pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0); + if (!width.fitsOnLine(charWidth)) { + lineWasTooWide = true; + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + skipTrailingWhitespace(lBreak, lineInfo); + } + } + if (lineWasTooWide || !width.fitsOnLine()) { + if (lBreak.atTextParagraphSeparator()) { + if (!stoppedIgnoringSpaces && current.m_pos > 0) + ensureCharacterGetsLineBox(lineMidpointState, current); + lBreak.increment(); + lineInfo.setPreviousLineBrokeCleanly(true); + wordMeasurement.endOffset = lBreak.m_pos; + } + if (lBreak.m_obj && lBreak.m_pos && lBreak.m_obj->isText() && toRenderText(lBreak.m_obj)->textLength() && toRenderText(lBreak.m_obj)->characterAt(lBreak.m_pos - 1) == softHyphen) + m_hyphenated = true; + if (lBreak.m_pos && lBreak.m_pos != (unsigned)wordMeasurement.endOffset && !wordMeasurement.width) { + if (charWidth) { + wordMeasurement.endOffset = lBreak.m_pos; + wordMeasurement.width = charWidth; + } + } + if (ignoringSpaces || !collapseWhiteSpace || !currentCharacterIsSpace || !previousCharacterIsSpace) + goto end; + } else { + if (!betweenWords || (midWordBreak && !autoWrap)) + width.addUncommittedWidth(-additionalTmpW); + if (hyphenWidth) { + width.addUncommittedWidth(-hyphenWidth); + hyphenWidth = 0; + } + } + } + + if (c == '\n' && preserveNewline) { + if (!stoppedIgnoringSpaces && current.m_pos > 0) + ensureCharacterGetsLineBox(lineMidpointState, current); + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + lBreak.increment(); + lineInfo.setPreviousLineBrokeCleanly(true); + return lBreak; + } + + if (autoWrap && betweenWords) { + width.commit(); + wrapW = 0; + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + breakWords = false; + } + + if (midWordBreak && !U16_IS_TRAIL(c) && !(category(c) & (Mark_NonSpacing | Mark_Enclosing | Mark_SpacingCombining))) { + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + midWordBreak &= (breakWords || breakAll); + } + + if (betweenWords) { + lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; + wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurement.width) ? wordSpacing : 0; + lastSpace = current.m_pos; + } + + if (!ignoringSpaces && currentStyle->collapseWhiteSpace()) { + if (currentCharacterIsSpace && previousCharacterIsSpace) { + ignoringSpaces = true; + + startIgnoringSpaces(lineMidpointState, ignoreStart); + trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace); + } + } + } else if (ignoringSpaces) { + ignoringSpaces = false; + lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; + wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurements.last().width) ? wordSpacing : 0; + lastSpace = current.m_pos; // e.g., ""Foo goo"", don't add in any of the ignored spaces. + stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); + } + + if (isSVGText && current.m_pos > 0) { + if (toRenderSVGInlineText(t)->characterStartsNewTextChunk(current.m_pos)) + ensureCharacterGetsLineBox(lineMidpointState, current); + } + + if (currentCharacterIsSpace && !previousCharacterIsSpace) { + ignoreStart.m_obj = current.m_obj; + ignoreStart.m_pos = current.m_pos; + } + + if (!currentCharacterIsSpace && previousCharacterShouldCollapseIfPreWap) { + if (autoWrap && currentStyle->breakOnlyAfterWhiteSpace()) + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + } + + if (collapseWhiteSpace && currentCharacterIsSpace && !ignoringSpaces) + trailingObjects.setTrailingWhitespace(toRenderText(current.m_obj)); + else if (!currentStyle->collapseWhiteSpace() || !currentCharacterIsSpace) + trailingObjects.clear(); + + atStart = false; + nextCharacter: + secondToLastCharacter = lastCharacter; + lastCharacter = c; + } + + renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondToLastCharacter); + + wordMeasurements.grow(wordMeasurements.size() + 1); + WordMeasurement& wordMeasurement = wordMeasurements.last(); + wordMeasurement.renderer = t; + + float additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout); + wordMeasurement.startOffset = lastSpace; + wordMeasurement.endOffset = current.m_pos; + wordMeasurement.width = ignoringSpaces ? 0 : additionalTmpW + wordSpacingForWordMeasurement; + additionalTmpW += lastSpaceWordSpacing; + width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(current.m_obj, !appliedStartWidth, includeEndWidth)); + includeEndWidth = false; + + if (!width.fitsOnLine()) { + if (!m_hyphenated && lBreak.previousInSameNode() == softHyphen) + m_hyphenated = true; + + if (m_hyphenated) + goto end; + } + } else + ASSERT_NOT_REACHED(); + + bool checkForBreak = autoWrap; + if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && currWS == NOWRAP) + checkForBreak = true; + else if (next && current.m_obj->isText() && next->isText() && !next->isBR() && (autoWrap || next->style()->autoWrap())) { + if (autoWrap && currentCharacterIsSpace) + checkForBreak = true; + else { + RenderText* nextText = toRenderText(next); + if (nextText->textLength()) { + UChar c = nextText->characterAt(0); + checkForBreak = !currentCharacterIsSpace && (c == ' ' || c == '\t' || (c == '\n' && !next->preservesNewline())); + } else if (nextText->isWordBreak()) + checkForBreak = true; + + if (!width.fitsOnLine() && !width.committedWidth()) + width.fitBelowFloats(); + + bool canPlaceOnLine = width.fitsOnLine() || !autoWrapWasEverTrueOnLine; + if (canPlaceOnLine && checkForBreak) { + width.commit(); + lBreak.moveToStartOf(next); + } + } + } + + if (checkForBreak && !width.fitsOnLine()) { + if (currentCharacterIsSpace && !ignoringSpaces && currentStyle->collapseWhiteSpace()) + trailingObjects.clear(); + + if (width.committedWidth()) + goto end; + + width.fitBelowFloats(); + + if (!width.fitsOnLine()) + goto end; + } else if (blockStyle->autoWrap() && !width.fitsOnLine() && !width.committedWidth()) { + width.fitBelowFloats(); + } + + if (!current.m_obj->isFloatingOrOutOfFlowPositioned()) { + last = current.m_obj; + if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(last)->isInside())) { + width.commit(); + lBreak.moveToStartOf(next); + } + } + + if (!collapseWhiteSpace) + currentCharacterIsSpace = false; + + current.moveToStartOf(next); + atStart = false; + } + + if (width.fitsOnLine() || lastWS == NOWRAP) + lBreak.clear(); + + end: + ShapeInsideInfo* shapeInfo = m_block->layoutShapeInsideInfo(); + bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); + + if (lBreak == resolver.position() && (!lBreak.m_obj || !lBreak.m_obj->isBR()) && segmentAllowsOverflow) { + if (blockStyle->whiteSpace() == PRE && !current.m_pos) { + lBreak.moveTo(last, last->isText() ? last->length() : 0); + } else if (lBreak.m_obj) { + lBreak.moveTo(current.m_obj, current.m_pos); + } + } + + if (lBreak == resolver.position() && segmentAllowsOverflow) + lBreak.increment(); + + checkMidpoints(lineMidpointState, lBreak); + + trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, lBreak, TrailingObjects::CollapseFirstSpace); + + if (lBreak.m_pos > 0) { + lBreak.m_pos--; + lBreak.increment(); + } + + return lBreak; +} +",0,"InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements) +{ + reset(); + + ASSERT(resolver.position().root() == m_block); + + bool appliedStartWidth = resolver.position().m_pos > 0; + bool includeEndWidth = true; + LineMidpointState& lineMidpointState = resolver.midpointState(); + + LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block->style())); + + skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width); + + if (resolver.position().atEnd()) + return resolver.position(); + + bool ignoringSpaces = false; + InlineIterator ignoreStart; + + bool currentCharacterIsSpace = false; + bool currentCharacterShouldCollapseIfPreWap = false; + TrailingObjects trailingObjects; + + InlineIterator lBreak = resolver.position(); + + InlineIterator current = resolver.position(); + RenderObject* last = current.m_obj; + bool atStart = true; + + bool startingNewParagraph = lineInfo.previousLineBrokeCleanly(); + lineInfo.setPreviousLineBrokeCleanly(false); + + bool autoWrapWasEverTrueOnLine = false; + bool floatsFitOnLine = true; + + RenderStyle* blockStyle = m_block->style(); + bool allowImagesToBreak = !m_block->document().inQuirksMode() || !m_block->isTableCell() || !blockStyle->logicalWidth().isIntrinsicOrAuto(); + + EWhiteSpace currWS = blockStyle->whiteSpace(); + EWhiteSpace lastWS = currWS; + while (current.m_obj) { + RenderStyle* currentStyle = current.m_obj->style(); + RenderObject* next = bidiNextSkippingEmptyInlines(m_block, current.m_obj); + if (next && next->parent() && !next->parent()->isDescendantOf(current.m_obj->parent())) + includeEndWidth = true; + + currWS = current.m_obj->isReplaced() ? current.m_obj->parent()->style()->whiteSpace() : currentStyle->whiteSpace(); + lastWS = last->isReplaced() ? last->parent()->style()->whiteSpace() : last->style()->whiteSpace(); + + bool autoWrap = RenderStyle::autoWrap(currWS); + autoWrapWasEverTrueOnLine = autoWrapWasEverTrueOnLine || autoWrap; + + bool preserveNewline = current.m_obj->isSVGInlineText() ? false : RenderStyle::preserveNewline(currWS); + + bool collapseWhiteSpace = RenderStyle::collapseWhiteSpace(currWS); + + if (current.m_obj->isBR()) { + if (width.fitsOnLine()) { + lBreak.moveToStartOf(current.m_obj); + lBreak.increment(); + + if (startingNewParagraph) + lineInfo.setEmpty(false, m_block, &width); + trailingObjects.clear(); + lineInfo.setPreviousLineBrokeCleanly(true); + + if (ignoringSpaces && currentStyle->clear() != CNONE) + ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj); + + if (!lineInfo.isEmpty()) + m_clear = currentStyle->clear(); + } + goto end; + } + + if (current.m_obj->isOutOfFlowPositioned()) { + RenderBox* box = toRenderBox(current.m_obj); + bool isInlineType = box->style()->isOriginalDisplayInlineType(); + if (!isInlineType) + m_block->setStaticInlinePositionForChild(box, m_block->logicalHeight(), m_block->startOffsetForContent(m_block->logicalHeight())); + else { + box->layer()->setStaticBlockPosition(m_block->logicalHeight()); + } + + if (isInlineType || current.m_obj->container()->isRenderInline()) { + if (ignoringSpaces) + ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj); + trailingObjects.appendBoxIfNeeded(box); + } else + m_positionedObjects.append(box); + width.addUncommittedWidth(inlineLogicalWidth(current.m_obj)); + renderTextInfo.m_lineBreakIterator.resetPriorContext(); + } else if (current.m_obj->isFloating()) { + RenderBox* floatBox = toRenderBox(current.m_obj); + FloatingObject* f = m_block->insertFloatingObject(floatBox); + if (floatsFitOnLine && width.fitsOnLine(f->logicalWidth(m_block->isHorizontalWritingMode()))) { + m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, lineInfo, width); + if (lBreak.m_obj == current.m_obj) { + ASSERT(!lBreak.m_pos); + lBreak.increment(); + } + } else + floatsFitOnLine = false; + renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter); + } else if (current.m_obj->isRenderInline()) { + ASSERT(isEmptyInline(current.m_obj)); + + RenderInline* flowBox = toRenderInline(current.m_obj); + + bool requiresLineBox = alwaysRequiresLineBox(current.m_obj); + if (requiresLineBox || requiresLineBoxForContent(flowBox, lineInfo)) { + if (requiresLineBox) + lineInfo.setEmpty(false, m_block, &width); + if (ignoringSpaces) { + trailingObjects.clear(); + ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj); + } else if (blockStyle->collapseWhiteSpace() && resolver.position().m_obj == current.m_obj + && shouldSkipWhitespaceAfterStartObject(m_block, current.m_obj, lineMidpointState)) { + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = true; + ignoringSpaces = true; + } + } + + width.addUncommittedWidth(inlineLogicalWidth(current.m_obj) + borderPaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)); + } else if (current.m_obj->isReplaced()) { + RenderBox* replacedBox = toRenderBox(current.m_obj); + + if (atStart) + width.updateAvailableWidth(replacedBox->logicalHeight()); + + if ((autoWrap || RenderStyle::autoWrap(lastWS)) && (!current.m_obj->isImage() || allowImagesToBreak)) { + width.commit(); + lBreak.moveToStartOf(current.m_obj); + } + + if (ignoringSpaces) + stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, 0)); + + lineInfo.setEmpty(false, m_block, &width); + ignoringSpaces = false; + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = false; + trailingObjects.clear(); + + LayoutUnit replacedLogicalWidth = m_block->logicalWidthForChild(replacedBox) + m_block->marginStartForChild(replacedBox) + m_block->marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj); + if (current.m_obj->isListMarker()) { + if (blockStyle->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, current.m_obj, lineMidpointState)) { + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = true; + ignoringSpaces = true; + } + if (toRenderListMarker(current.m_obj)->isInside()) + width.addUncommittedWidth(replacedLogicalWidth); + } else + width.addUncommittedWidth(replacedLogicalWidth); + if (current.m_obj->isRubyRun()) + width.applyOverhang(toRenderRubyRun(current.m_obj), last, next); + renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter); + } else if (current.m_obj->isText()) { + if (!current.m_pos) + appliedStartWidth = false; + + RenderText* t = toRenderText(current.m_obj); + + bool isSVGText = t->isSVGInlineText(); + + if (t->style()->hasTextCombine() && current.m_obj->isCombineText() && !toRenderCombineText(current.m_obj)->isCombined()) { + RenderCombineText* combineRenderer = toRenderCombineText(current.m_obj); + combineRenderer->combineText(); + if (iteratorIsBeyondEndOfRenderCombineText(lBreak, combineRenderer)) { + ASSERT(iteratorIsBeyondEndOfRenderCombineText(resolver.position(), combineRenderer)); + lBreak.increment(); + resolver.increment(); + } + } + + RenderStyle* style = t->style(lineInfo.isFirstLine()); + const Font& f = style->font(); + bool isFixedPitch = f.isFixedPitch(); + + unsigned lastSpace = current.m_pos; + float wordSpacing = currentStyle->wordSpacing(); + float lastSpaceWordSpacing = 0; + float wordSpacingForWordMeasurement = 0; + + float wrapW = width.uncommittedWidth() + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true); + float charWidth = 0; + bool breakWords = currentStyle->breakWords() && ((autoWrap && !width.committedWidth()) || currWS == PRE); + bool midWordBreak = false; + bool breakAll = currentStyle->wordBreak() == BreakAllWordBreak && autoWrap; + float hyphenWidth = 0; + + if (isSVGText) { + breakWords = false; + breakAll = false; + } + + if (t->isWordBreak()) { + width.commit(); + lBreak.moveToStartOf(current.m_obj); + ASSERT(current.m_pos == t->textLength()); + } + + if (renderTextInfo.m_text != t) { + renderTextInfo.m_text = t; + renderTextInfo.m_font = &f; + renderTextInfo.m_layout = f.createLayout(t, width.currentWidth(), collapseWhiteSpace); + renderTextInfo.m_lineBreakIterator.resetStringAndReleaseIterator(t->text(), style->locale()); + } else if (renderTextInfo.m_layout && renderTextInfo.m_font != &f) { + renderTextInfo.m_font = &f; + renderTextInfo.m_layout = f.createLayout(t, width.currentWidth(), collapseWhiteSpace); + } + + TextLayout* textLayout = renderTextInfo.m_layout.get(); + + float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0; + + UChar lastCharacter = renderTextInfo.m_lineBreakIterator.lastCharacter(); + UChar secondToLastCharacter = renderTextInfo.m_lineBreakIterator.secondToLastCharacter(); + for (; current.m_pos < t->textLength(); current.fastIncrementInTextNode()) { + bool previousCharacterIsSpace = currentCharacterIsSpace; + bool previousCharacterShouldCollapseIfPreWap = currentCharacterShouldCollapseIfPreWap; + UChar c = current.current(); + currentCharacterShouldCollapseIfPreWap = currentCharacterIsSpace = c == ' ' || c == '\t' || (!preserveNewline && (c == '\n')); + + if (!collapseWhiteSpace || !currentCharacterIsSpace) + lineInfo.setEmpty(false, m_block, &width); + + if (c == softHyphen && autoWrap && !hyphenWidth) { + hyphenWidth = measureHyphenWidth(t, f); + width.addUncommittedWidth(hyphenWidth); + } + + bool applyWordSpacing = false; + + if ((breakAll || breakWords) && !midWordBreak) { + wrapW += charWidth; + bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && current.m_pos + 1 < t->textLength() && U16_IS_TRAIL((*t)[current.m_pos + 1]); + charWidth = textWidth(t, current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace, 0, textLayout); + midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth(); + } + + bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(renderTextInfo.m_lineBreakIterator, current.m_pos, current.m_nextBreakablePosition)); + + if (betweenWords || midWordBreak) { + bool stoppedIgnoringSpaces = false; + if (ignoringSpaces) { + lastSpaceWordSpacing = 0; + if (!currentCharacterIsSpace) { + ignoringSpaces = false; + wordSpacingForWordMeasurement = 0; + lastSpace = current.m_pos; // e.g., ""Foo goo"", don't add in any of the ignored spaces. + stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); + stoppedIgnoringSpaces = true; + } else { + goto nextCharacter; + } + } + + wordMeasurements.grow(wordMeasurements.size() + 1); + WordMeasurement& wordMeasurement = wordMeasurements.last(); + + wordMeasurement.renderer = t; + wordMeasurement.endOffset = current.m_pos; + wordMeasurement.startOffset = lastSpace; + + float additionalTmpW; + if (wordTrailingSpaceWidth && c == ' ') + additionalTmpW = textWidth(t, lastSpace, current.m_pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth; + else + additionalTmpW = textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout); + + wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasurement; + additionalTmpW += lastSpaceWordSpacing; + width.addUncommittedWidth(additionalTmpW); + if (!appliedStartWidth) { + width.addUncommittedWidth(inlineLogicalWidth(current.m_obj, true, false)); + appliedStartWidth = true; + } + + applyWordSpacing = wordSpacing && currentCharacterIsSpace; + + if (!width.committedWidth() && autoWrap && !width.fitsOnLine()) + width.fitBelowFloats(); + + if (autoWrap || breakWords) { + bool lineWasTooWide = false; + if (width.fitsOnLine() && currentCharacterIsSpace && currentStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { + float charWidth = textWidth(t, current.m_pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0); + if (!width.fitsOnLine(charWidth)) { + lineWasTooWide = true; + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + skipTrailingWhitespace(lBreak, lineInfo); + } + } + if (lineWasTooWide || !width.fitsOnLine()) { + if (lBreak.atTextParagraphSeparator()) { + if (!stoppedIgnoringSpaces && current.m_pos > 0) + ensureCharacterGetsLineBox(lineMidpointState, current); + lBreak.increment(); + lineInfo.setPreviousLineBrokeCleanly(true); + wordMeasurement.endOffset = lBreak.m_pos; + } + if (lBreak.m_obj && lBreak.m_pos && lBreak.m_obj->isText() && toRenderText(lBreak.m_obj)->textLength() && toRenderText(lBreak.m_obj)->characterAt(lBreak.m_pos - 1) == softHyphen) + m_hyphenated = true; + if (lBreak.m_pos && lBreak.m_pos != (unsigned)wordMeasurement.endOffset && !wordMeasurement.width) { + if (charWidth) { + wordMeasurement.endOffset = lBreak.m_pos; + wordMeasurement.width = charWidth; + } + } + if (ignoringSpaces || !collapseWhiteSpace || !currentCharacterIsSpace || !previousCharacterIsSpace) + goto end; + } else { + if (!betweenWords || (midWordBreak && !autoWrap)) + width.addUncommittedWidth(-additionalTmpW); + if (hyphenWidth) { + width.addUncommittedWidth(-hyphenWidth); + hyphenWidth = 0; + } + } + } + + if (c == '\n' && preserveNewline) { + if (!stoppedIgnoringSpaces && current.m_pos > 0) + ensureCharacterGetsLineBox(lineMidpointState, current); + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + lBreak.increment(); + lineInfo.setPreviousLineBrokeCleanly(true); + return lBreak; + } + + if (autoWrap && betweenWords) { + width.commit(); + wrapW = 0; + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + breakWords = false; + } + + if (midWordBreak && !U16_IS_TRAIL(c) && !(category(c) & (Mark_NonSpacing | Mark_Enclosing | Mark_SpacingCombining))) { + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + midWordBreak &= (breakWords || breakAll); + } + + if (betweenWords) { + lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; + wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurement.width) ? wordSpacing : 0; + lastSpace = current.m_pos; + } + + if (!ignoringSpaces && currentStyle->collapseWhiteSpace()) { + if (currentCharacterIsSpace && previousCharacterIsSpace) { + ignoringSpaces = true; + + startIgnoringSpaces(lineMidpointState, ignoreStart); + trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace); + } + } + } else if (ignoringSpaces) { + ignoringSpaces = false; + lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; + wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurements.last().width) ? wordSpacing : 0; + lastSpace = current.m_pos; // e.g., ""Foo goo"", don't add in any of the ignored spaces. + stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); + } + + if (isSVGText && current.m_pos > 0) { + if (toRenderSVGInlineText(t)->characterStartsNewTextChunk(current.m_pos)) + ensureCharacterGetsLineBox(lineMidpointState, current); + } + + if (currentCharacterIsSpace && !previousCharacterIsSpace) { + ignoreStart.m_obj = current.m_obj; + ignoreStart.m_pos = current.m_pos; + } + + if (!currentCharacterIsSpace && previousCharacterShouldCollapseIfPreWap) { + if (autoWrap && currentStyle->breakOnlyAfterWhiteSpace()) + lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition); + } + + if (collapseWhiteSpace && currentCharacterIsSpace && !ignoringSpaces) + trailingObjects.setTrailingWhitespace(toRenderText(current.m_obj)); + else if (!currentStyle->collapseWhiteSpace() || !currentCharacterIsSpace) + trailingObjects.clear(); + + atStart = false; + nextCharacter: + secondToLastCharacter = lastCharacter; + lastCharacter = c; + } + + renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondToLastCharacter); + + wordMeasurements.grow(wordMeasurements.size() + 1); + WordMeasurement& wordMeasurement = wordMeasurements.last(); + wordMeasurement.renderer = t; + + float additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout); + wordMeasurement.startOffset = lastSpace; + wordMeasurement.endOffset = current.m_pos; + wordMeasurement.width = ignoringSpaces ? 0 : additionalTmpW + wordSpacingForWordMeasurement; + additionalTmpW += lastSpaceWordSpacing; + width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(current.m_obj, !appliedStartWidth, includeEndWidth)); + includeEndWidth = false; + + if (!width.fitsOnLine()) { + if (!m_hyphenated && lBreak.previousInSameNode() == softHyphen) + m_hyphenated = true; + + if (m_hyphenated) + goto end; + } + } else + ASSERT_NOT_REACHED(); + + bool checkForBreak = autoWrap; + if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && currWS == NOWRAP) + checkForBreak = true; + else if (next && current.m_obj->isText() && next->isText() && !next->isBR() && (autoWrap || next->style()->autoWrap())) { + if (autoWrap && currentCharacterIsSpace) + checkForBreak = true; + else { + RenderText* nextText = toRenderText(next); + if (nextText->textLength()) { + UChar c = nextText->characterAt(0); + checkForBreak = !currentCharacterIsSpace && (c == ' ' || c == '\t' || (c == '\n' && !next->preservesNewline())); + } else if (nextText->isWordBreak()) + checkForBreak = true; + + if (!width.fitsOnLine() && !width.committedWidth()) + width.fitBelowFloats(); + + bool canPlaceOnLine = width.fitsOnLine() || !autoWrapWasEverTrueOnLine; + if (canPlaceOnLine && checkForBreak) { + width.commit(); + lBreak.moveToStartOf(next); + } + } + } + + if (checkForBreak && !width.fitsOnLine()) { + if (currentCharacterIsSpace && !ignoringSpaces && currentStyle->collapseWhiteSpace()) + trailingObjects.clear(); + + if (width.committedWidth()) + goto end; + + width.fitBelowFloats(); + + if (!width.fitsOnLine()) + goto end; + } else if (blockStyle->autoWrap() && !width.fitsOnLine() && !width.committedWidth()) { + width.fitBelowFloats(); + } + + if (!current.m_obj->isFloatingOrOutOfFlowPositioned()) { + last = current.m_obj; + if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(last)->isInside())) { + width.commit(); + lBreak.moveToStartOf(next); + } + } + + if (!collapseWhiteSpace) + currentCharacterIsSpace = false; + + current.moveToStartOf(next); + atStart = false; + } + + if (width.fitsOnLine() || lastWS == NOWRAP) + lBreak.clear(); + + end: + ShapeInsideInfo* shapeInfo = m_block->layoutShapeInsideInfo(); + bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); + + if (lBreak == resolver.position() && (!lBreak.m_obj || !lBreak.m_obj->isBR()) && segmentAllowsOverflow) { + if (blockStyle->whiteSpace() == PRE && !current.m_pos) { + lBreak.moveTo(last, last->isText() ? last->length() : 0); + } else if (lBreak.m_obj) { + lBreak.moveTo(current.m_obj, current.m_pos); + } + } + + if (lBreak == resolver.position() && segmentAllowsOverflow) + lBreak.increment(); + + checkMidpoints(lineMidpointState, lBreak); + + trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, lBreak, TrailingObjects::CollapseFirstSpace); + + if (lBreak.m_pos > 0) { + lBreak.m_pos--; + lBreak.increment(); + } + + return lBreak; +} +","@@ -1313,7 +1313,8 @@ static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver, + // tree to see which parent inline is the isolate. We could change enterIsolate + // to take a RenderObject and do this logic there, but that would be a layering + // violation for BidiResolver (which knows nothing about RenderObject). +- RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj, currentRoot)); ++ RenderInline* isolatedInline = toRenderInline(highestContainingIsolateWithinRoot(startObj, currentRoot)); ++ ASSERT(isolatedInline); + + InlineBidiResolver isolatedResolver; + EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi();",5102,5338,6144 +7752,"static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + Image *image,ExceptionInfo *exception) +{ +#define MaxCount 128 +#define PictCropRegionOp 0x01 +#define PictEndOfPictureOp 0xff +#define PictJPEGOp 0x8200 +#define PictInfoOp 0x0C00 +#define PictInfoSize 512 +#define PictPixmapOp 0x9A +#define PictPICTOp 0x98 +#define PictVersion 0x11 + + const StringInfo + *profile; + + double + x_resolution, + y_resolution; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + PICTPixmap + pixmap; + + PICTRectangle + bounds, + crop_rectangle, + destination_rectangle, + frame_rectangle, + size_rectangle, + source_rectangle; + + register const Quantum + *p; + + register ssize_t + i, + x; + + size_t + bytes_per_line, + count, + row_bytes, + storage_class; + + ssize_t + y; + + unsigned char + *buffer, + *packed_scanline, + *scanline; + + unsigned short + base_address, + transfer_mode; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if ((image->columns > 65535L) || (image->rows > 65535L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) TransformImageColorspace(image,sRGBColorspace,exception); + /* + Initialize image info. + */ + size_rectangle.top=0; + size_rectangle.left=0; + size_rectangle.bottom=(short) image->rows; + size_rectangle.right=(short) image->columns; + frame_rectangle=size_rectangle; + crop_rectangle=size_rectangle; + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; + row_bytes=image->columns; + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; + bounds.right=(short) image->columns; + pixmap.version=0; + pixmap.pack_type=0; + pixmap.pack_size=0; + pixmap.pixel_type=0; + pixmap.bits_per_pixel=8; + pixmap.component_count=1; + pixmap.component_size=8; + pixmap.plane_bytes=0; + pixmap.table=0; + pixmap.reserved=0; + transfer_mode=0; + x_resolution=image->resolution.x != 0.0 ? image->resolution.x : + DefaultResolution; + y_resolution=image->resolution.y != 0.0 ? image->resolution.y : + DefaultResolution; + storage_class=image->storage_class; + if (image_info->compression == JPEGCompression) + storage_class=DirectClass; + if (storage_class == DirectClass) + { + pixmap.component_count=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + pixmap.pixel_type=16; + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; + row_bytes=4*image->columns; + } + /* + Allocate memory. + */ + bytes_per_line=image->columns; + if (storage_class == DirectClass) + bytes_per_line*=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer)); + packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t) + (row_bytes+MaxCount),sizeof(*packed_scanline)); + scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline)); + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) + { + if (scanline != (unsigned char *) NULL) + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + if (packed_scanline != (unsigned char *) NULL) + packed_scanline=(unsigned char *) RelinquishMagickMemory( + packed_scanline); + if (buffer != (unsigned char *) NULL) + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) memset(scanline,0,row_bytes); + (void) memset(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /* + Write header, header size, size bounding box, version, and reserved. + */ + (void) memset(buffer,0,PictInfoSize); + (void) WriteBlob(image,PictInfoSize,buffer); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right); + (void) WriteBlobMSBShort(image,PictVersion); + (void) WriteBlobMSBShort(image,0x02ff); /* version #2 */ + (void) WriteBlobMSBShort(image,PictInfoOp); + (void) WriteBlobMSBLong(image,0xFFFE0000U); + /* + Write full size of the file, resolution, frame bounding box, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right); + (void) WriteBlobMSBLong(image,0x00000000L); + profile=GetImageProfile(image,""iptc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0x1f2); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobString(image,""8BIM""); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + } + profile=GetImageProfile(image,""icc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,4); + (void) WriteBlobMSBLong(image,0x00000002U); + } + /* + Write crop region opcode and crop bounding box. + */ + (void) WriteBlobMSBShort(image,PictCropRegionOp); + (void) WriteBlobMSBShort(image,0xa); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right); + if (image_info->compression == JPEGCompression) + { + Image + *jpeg_image; + + ImageInfo + *jpeg_info; + + size_t + length; + + unsigned char + *blob; + + jpeg_image=CloneImage(image,0,0,MagickTrue,exception); + if (jpeg_image == (Image *) NULL) + { + (void) CloseBlob(image); + return(MagickFalse); + } + jpeg_info=CloneImageInfo(image_info); + (void) CopyMagickString(jpeg_info->magick,""JPEG"",MagickPathExtent); + length=0; + blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length, + exception); + jpeg_info=DestroyImageInfo(jpeg_info); + if (blob == (unsigned char *) NULL) + return(MagickFalse); + jpeg_image=DestroyImage(jpeg_image); + (void) WriteBlobMSBShort(image,PictJPEGOp); + (void) WriteBlobMSBLong(image,(unsigned int) length+154); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00010000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00010000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x40000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00400000U); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00566A70U); + (void) WriteBlobMSBLong(image,0x65670000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000001U); + (void) WriteBlobMSBLong(image,0x00016170U); + (void) WriteBlobMSBLong(image,0x706C0000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,length); + (void) WriteBlobMSBShort(image,0x0001); + (void) WriteBlobMSBLong(image,0x0B466F74U); + (void) WriteBlobMSBLong(image,0x6F202D20U); + (void) WriteBlobMSBLong(image,0x4A504547U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x0018FFFFU); + (void) WriteBlob(image,length,blob); + if ((length & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + blob=(unsigned char *) RelinquishMagickMemory(blob); + } + /* + Write picture opcode, row bytes, and picture bounding box, and version. + */ + if (storage_class == PseudoClass) + (void) WriteBlobMSBShort(image,PictPICTOp); + else + { + (void) WriteBlobMSBShort(image,PictPixmapOp); + (void) WriteBlobMSBLong(image,(unsigned int) base_address); + } + (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000)); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.top); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.left); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.right); + /* + Write pack type, pack size, resolution, pixel type, and pixel size. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size); + (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel); + /* + Write component count, size, plane bytes, table size, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved); + if (storage_class == PseudoClass) + { + /* + Write image colormap. + */ + (void) WriteBlobMSBLong(image,0x00000000L); /* color seed */ + (void) WriteBlobMSBShort(image,0L); /* color flags */ + (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1)); + for (i=0; i < (ssize_t) image->colors; i++) + { + (void) WriteBlobMSBShort(image,(unsigned short) i); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].red)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].green)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].blue)); + } + } + /* + Write source and destination rectangle. + */ + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode); + /* + Write picture data. + */ + count=0; + if (storage_class == PseudoClass) + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + scanline[x]=(unsigned char) GetPixelIndex(image,p); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image_info->compression == JPEGCompression) + { + (void) memset(scanline,0,row_bytes); + for (y=0; y < (ssize_t) image->rows; y++) + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + } + else + { + register unsigned char + *blue, + *green, + *opacity, + *red; + + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + opacity=scanline+3*image->columns; + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + if (image->alpha_trait != UndefinedPixelTrait) + { + opacity=scanline; + red=scanline+image->columns; + green=scanline+2*image->columns; + blue=scanline+3*image->columns; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + *red++=ScaleQuantumToChar(GetPixelRed(image,p)); + *green++=ScaleQuantumToChar(GetPixelGreen(image,p)); + *blue++=ScaleQuantumToChar(GetPixelBlue(image,p)); + if (image->alpha_trait != UndefinedPixelTrait) + *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p))); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,bytes_per_line,packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if ((count & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + (void) WriteBlobMSBShort(image,PictEndOfPictureOp); + offset=TellBlob(image); + offset=SeekBlob(image,512,SEEK_SET); + (void) WriteBlobMSBShort(image,(unsigned short) offset); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + (void) CloseBlob(image); + return(MagickTrue); +} +",0,"static MagickBooleanType WritePICTImage(const ImageInfo *image_info, + Image *image,ExceptionInfo *exception) +{ +#define MaxCount 128 +#define PictCropRegionOp 0x01 +#define PictEndOfPictureOp 0xff +#define PictJPEGOp 0x8200 +#define PictInfoOp 0x0C00 +#define PictInfoSize 512 +#define PictPixmapOp 0x9A +#define PictPICTOp 0x98 +#define PictVersion 0x11 + + const StringInfo + *profile; + + double + x_resolution, + y_resolution; + + MagickBooleanType + status; + + MagickOffsetType + offset; + + PICTPixmap + pixmap; + + PICTRectangle + bounds, + crop_rectangle, + destination_rectangle, + frame_rectangle, + size_rectangle, + source_rectangle; + + register const Quantum + *p; + + register ssize_t + i, + x; + + size_t + bytes_per_line, + count, + row_bytes, + storage_class; + + ssize_t + y; + + unsigned char + *buffer, + *packed_scanline, + *scanline; + + unsigned short + base_address, + transfer_mode; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + if ((image->columns > 65535L) || (image->rows > 65535L)) + ThrowWriterException(ImageError,""WidthOrHeightExceedsLimit""); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + (void) TransformImageColorspace(image,sRGBColorspace,exception); + /* + Initialize image info. + */ + size_rectangle.top=0; + size_rectangle.left=0; + size_rectangle.bottom=(short) image->rows; + size_rectangle.right=(short) image->columns; + frame_rectangle=size_rectangle; + crop_rectangle=size_rectangle; + source_rectangle=size_rectangle; + destination_rectangle=size_rectangle; + base_address=0xff; + row_bytes=image->columns; + bounds.top=0; + bounds.left=0; + bounds.bottom=(short) image->rows; + bounds.right=(short) image->columns; + pixmap.version=0; + pixmap.pack_type=0; + pixmap.pack_size=0; + pixmap.pixel_type=0; + pixmap.bits_per_pixel=8; + pixmap.component_count=1; + pixmap.component_size=8; + pixmap.plane_bytes=0; + pixmap.table=0; + pixmap.reserved=0; + transfer_mode=0; + x_resolution=image->resolution.x != 0.0 ? image->resolution.x : + DefaultResolution; + y_resolution=image->resolution.y != 0.0 ? image->resolution.y : + DefaultResolution; + storage_class=image->storage_class; + if (image_info->compression == JPEGCompression) + storage_class=DirectClass; + if (storage_class == DirectClass) + { + pixmap.component_count=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + pixmap.pixel_type=16; + pixmap.bits_per_pixel=32; + pixmap.pack_type=0x04; + transfer_mode=0x40; + row_bytes=4*image->columns; + } + /* + Allocate memory. + */ + bytes_per_line=image->columns; + if (storage_class == DirectClass) + bytes_per_line*=image->alpha_trait != UndefinedPixelTrait ? 4 : 3; + buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer)); + packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t) + (row_bytes+MaxCount),sizeof(*packed_scanline)); + scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline)); + if ((buffer == (unsigned char *) NULL) || + (packed_scanline == (unsigned char *) NULL) || + (scanline == (unsigned char *) NULL)) + { + if (scanline != (unsigned char *) NULL) + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + if (packed_scanline != (unsigned char *) NULL) + packed_scanline=(unsigned char *) RelinquishMagickMemory( + packed_scanline); + if (buffer != (unsigned char *) NULL) + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + } + (void) memset(scanline,0,row_bytes); + (void) memset(packed_scanline,0,(size_t) (row_bytes+MaxCount)); + /* + Write header, header size, size bounding box, version, and reserved. + */ + (void) memset(buffer,0,PictInfoSize); + (void) WriteBlob(image,PictInfoSize,buffer); + (void) WriteBlobMSBShort(image,0); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right); + (void) WriteBlobMSBShort(image,PictVersion); + (void) WriteBlobMSBShort(image,0x02ff); /* version #2 */ + (void) WriteBlobMSBShort(image,PictInfoOp); + (void) WriteBlobMSBLong(image,0xFFFE0000U); + /* + Write full size of the file, resolution, frame bounding box, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right); + (void) WriteBlobMSBLong(image,0x00000000L); + profile=GetImageProfile(image,""iptc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0x1f2); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobString(image,""8BIM""); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + } + profile=GetImageProfile(image,""icc""); + if (profile != (StringInfo *) NULL) + { + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,(unsigned short) + (GetStringInfoLength(profile)+4)); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlob(image,GetStringInfoLength(profile), + GetStringInfoDatum(profile)); + (void) WriteBlobMSBShort(image,0xa1); + (void) WriteBlobMSBShort(image,0xe0); + (void) WriteBlobMSBShort(image,4); + (void) WriteBlobMSBLong(image,0x00000002U); + } + /* + Write crop region opcode and crop bounding box. + */ + (void) WriteBlobMSBShort(image,PictCropRegionOp); + (void) WriteBlobMSBShort(image,0xa); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right); + if (image_info->compression == JPEGCompression) + { + Image + *jpeg_image; + + ImageInfo + *jpeg_info; + + size_t + length; + + unsigned char + *blob; + + jpeg_image=CloneImage(image,0,0,MagickTrue,exception); + if (jpeg_image == (Image *) NULL) + { + (void) CloseBlob(image); + return(MagickFalse); + } + jpeg_info=CloneImageInfo(image_info); + (void) CopyMagickString(jpeg_info->magick,""JPEG"",MagickPathExtent); + length=0; + blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length, + exception); + jpeg_info=DestroyImageInfo(jpeg_info); + if (blob == (unsigned char *) NULL) + return(MagickFalse); + jpeg_image=DestroyImage(jpeg_image); + (void) WriteBlobMSBShort(image,PictJPEGOp); + (void) WriteBlobMSBLong(image,(unsigned int) length+154); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00010000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00010000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x40000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00400000U); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00566A70U); + (void) WriteBlobMSBLong(image,0x65670000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000001U); + (void) WriteBlobMSBLong(image,0x00016170U); + (void) WriteBlobMSBLong(image,0x706C0000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBShort(image,768); + (void) WriteBlobMSBShort(image,(unsigned short) image->columns); + (void) WriteBlobMSBShort(image,(unsigned short) image->rows); + (void) WriteBlobMSBShort(image,(unsigned short) x_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) y_resolution); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBLong(image,length); + (void) WriteBlobMSBShort(image,0x0001); + (void) WriteBlobMSBLong(image,0x0B466F74U); + (void) WriteBlobMSBLong(image,0x6F202D20U); + (void) WriteBlobMSBLong(image,0x4A504547U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x00000000U); + (void) WriteBlobMSBLong(image,0x0018FFFFU); + (void) WriteBlob(image,length,blob); + if ((length & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + blob=(unsigned char *) RelinquishMagickMemory(blob); + } + /* + Write picture opcode, row bytes, and picture bounding box, and version. + */ + if (storage_class == PseudoClass) + (void) WriteBlobMSBShort(image,PictPICTOp); + else + { + (void) WriteBlobMSBShort(image,PictPixmapOp); + (void) WriteBlobMSBLong(image,(unsigned int) base_address); + } + (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000)); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.top); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.left); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) bounds.right); + /* + Write pack type, pack size, resolution, pixel type, and pixel size. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size); + (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5)); + (void) WriteBlobMSBShort(image,0x0000); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel); + /* + Write component count, size, plane bytes, table size, and reserved. + */ + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count); + (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table); + (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved); + if (storage_class == PseudoClass) + { + /* + Write image colormap. + */ + (void) WriteBlobMSBLong(image,0x00000000L); /* color seed */ + (void) WriteBlobMSBShort(image,0L); /* color flags */ + (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1)); + for (i=0; i < (ssize_t) image->colors; i++) + { + (void) WriteBlobMSBShort(image,(unsigned short) i); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].red)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].green)); + (void) WriteBlobMSBShort(image,ScaleQuantumToShort( + image->colormap[i].blue)); + } + } + /* + Write source and destination rectangle. + */ + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom); + (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right); + (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode); + /* + Write picture data. + */ + count=0; + if (storage_class == PseudoClass) + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + scanline[x]=(unsigned char) GetPixelIndex(image,p); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + else + if (image_info->compression == JPEGCompression) + { + (void) memset(scanline,0,row_bytes); + for (y=0; y < (ssize_t) image->rows; y++) + count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF), + packed_scanline); + } + else + { + register unsigned char + *blue, + *green, + *opacity, + *red; + + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + opacity=scanline+3*image->columns; + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + red=scanline; + green=scanline+image->columns; + blue=scanline+2*image->columns; + if (image->alpha_trait != UndefinedPixelTrait) + { + opacity=scanline; + red=scanline+image->columns; + green=scanline+2*image->columns; + blue=scanline+3*image->columns; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + *red++=ScaleQuantumToChar(GetPixelRed(image,p)); + *green++=ScaleQuantumToChar(GetPixelGreen(image,p)); + *blue++=ScaleQuantumToChar(GetPixelBlue(image,p)); + if (image->alpha_trait != UndefinedPixelTrait) + *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p))); + p+=GetPixelChannels(image); + } + count+=EncodeImage(image,scanline,bytes_per_line,packed_scanline); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + } + if ((count & 0x01) != 0) + (void) WriteBlobByte(image,'\0'); + (void) WriteBlobMSBShort(image,PictEndOfPictureOp); + offset=TellBlob(image); + offset=SeekBlob(image,512,SEEK_SET); + (void) WriteBlobMSBShort(image,(unsigned short) offset); + scanline=(unsigned char *) RelinquishMagickMemory(scanline); + packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline); + buffer=(unsigned char *) RelinquishMagickMemory(buffer); + (void) CloseBlob(image); + return(MagickTrue); +} +","@@ -982,6 +982,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + Clipping rectangle. + */ + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + if (length != 0x000a) + { + for (i=0; i < (ssize_t) (length-2); i++) +@@ -1030,6 +1033,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + if (pattern != 1) + ThrowPICTException(CorruptImageError,""UnknownPatternType""); + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + if (ReadRectangle(image,&frame) == MagickFalse) + ThrowPICTException(CorruptImageError,""ImproperImageHeader""); + if (ReadPixmap(image,&pixmap) == MagickFalse) +@@ -1041,6 +1047,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + (void) ReadBlobMSBLong(image); + flags=(ssize_t) ReadBlobMSBShort(image); + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + for (i=0; i <= (ssize_t) length; i++) + (void) ReadBlobMSBLong(image); + width=(size_t) (frame.bottom-frame.top); +@@ -1101,6 +1110,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + Skip polygon or region. + */ + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; +@@ -1223,6 +1235,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + Skip region. + */ + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + for (i=0; i < (ssize_t) (length-2); i++) + if (ReadBlobByte(image) == EOF) + break; +@@ -1345,6 +1360,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + */ + type=ReadBlobMSBShort(image); + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + if (length == 0) + break; + (void) ReadBlobMSBLong(image); +@@ -1454,6 +1472,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + ThrowPICTException(FileOpenError,""UnableToCreateTemporaryFile""); + } + length=ReadBlobMSBLong(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + if (length > 154) + { + for (i=0; i < 6; i++) +@@ -1505,6 +1526,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + Skip reserved. + */ + length=ReadBlobMSBShort(image); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + for (i=0; i < (ssize_t) length; i++) + if (ReadBlobByte(image) == EOF) + break; +@@ -1516,6 +1540,9 @@ static Image *ReadPICTImage(const ImageInfo *image_info, + Skip reserved. + */ + length=(size_t) ((code >> 7) & 0xff); ++ if (length > GetBlobSize(image)) ++ ThrowPICTException(CorruptImageError, ++ ""InsufficientImageDataInFile""); + for (i=0; i < (ssize_t) length; i++) + if (ReadBlobByte(image) == EOF) + break;",4822,5058,6144 +675," _bdf_parse_glyphs( char* line, + unsigned long linelen, + unsigned long lineno, + void* call_data, + void* client_data ) + { + int c, mask_index; + char* s; + unsigned char* bp; + unsigned long i, slen, nibbles; + + _bdf_parse_t* p; + bdf_glyph_t* glyph; + bdf_font_t* font; + + FT_Memory memory; + FT_Error error = BDF_Err_Ok; + + FT_UNUSED( call_data ); + FT_UNUSED( lineno ); /* only used in debug mode */ + + + p = (_bdf_parse_t *)client_data; + + font = p->font; + memory = font->memory; + + /* Check for a comment. */ + if ( ft_memcmp( line, ""COMMENT"", 7 ) == 0 ) + { + linelen -= 7; + + s = line + 7; + if ( *s != 0 ) + { + s++; + linelen--; + } + error = _bdf_add_comment( p->font, s, linelen ); + goto Exit; + } + + /* The very first thing expected is the number of glyphs. */ + if ( !( p->flags & _BDF_GLYPHS ) ) + { + if ( ft_memcmp( line, ""CHARS"", 5 ) != 0 ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""CHARS"" )); + error = BDF_Err_Missing_Chars_Field; + goto Exit; + } + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 ); + + /* Make sure the number of glyphs is non-zero. */ + if ( p->cnt == 0 ) + font->glyphs_size = 64; + + /* Limit ourselves to 1,114,112 glyphs in the font (this is the */ + /* number of code points available in Unicode). */ + if ( p->cnt >= 0x110000UL ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG5, lineno, ""CHARS"" )); + error = BDF_Err_Invalid_Argument; + goto Exit; + } + + if ( FT_NEW_ARRAY( font->glyphs, font->glyphs_size ) ) + goto Exit; + + p->flags |= _BDF_GLYPHS; + + goto Exit; + } + + /* Check for the ENDFONT field. */ + if ( ft_memcmp( line, ""ENDFONT"", 7 ) == 0 ) + { + /* Sort the glyphs by encoding. */ + ft_qsort( (char *)font->glyphs, + font->glyphs_used, + sizeof ( bdf_glyph_t ), + by_encoding ); + + p->flags &= ~_BDF_START; + + goto Exit; + } + + /* Check for the ENDCHAR field. */ + if ( ft_memcmp( line, ""ENDCHAR"", 7 ) == 0 ) + { + p->glyph_enc = 0; + p->flags &= ~_BDF_GLYPH_BITS; + + goto Exit; + } + + /* Check whether a glyph is being scanned but should be */ + /* ignored because it is an unencoded glyph. */ + if ( ( p->flags & _BDF_GLYPH ) && + p->glyph_enc == -1 && + p->opts->keep_unencoded == 0 ) + goto Exit; + + /* Check for the STARTCHAR field. */ + if ( ft_memcmp( line, ""STARTCHAR"", 9 ) == 0 ) + { + /* Set the character name in the parse info first until the */ + /* encoding can be checked for an unencoded character. */ + FT_FREE( p->glyph_name ); + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + _bdf_list_shift( &p->list, 1 ); + + s = _bdf_list_join( &p->list, ' ', &slen ); + + if ( !s ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG8, lineno, ""STARTCHAR"" )); + error = BDF_Err_Invalid_File_Format; + goto Exit; + } + + if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) ) + goto Exit; + + FT_MEM_COPY( p->glyph_name, s, slen + 1 ); + + p->flags |= _BDF_GLYPH; + + FT_TRACE4(( DBGMSG1, lineno, s )); + + goto Exit; + } + + /* Check for the ENCODING field. */ + if ( ft_memcmp( line, ""ENCODING"", 8 ) == 0 ) + { + if ( !( p->flags & _BDF_GLYPH ) ) + { + /* Missing STARTCHAR field. */ + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""STARTCHAR"" )); + error = BDF_Err_Missing_Startchar_Field; + goto Exit; + } + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 ); + + /* Normalize negative encoding values. The specification only */ + /* allows -1, but we can be more generous here. */ + if ( p->glyph_enc < -1 ) + p->glyph_enc = -1; + + /* Check for alternative encoding format. */ + if ( p->glyph_enc == -1 && p->list.used > 2 ) + p->glyph_enc = _bdf_atol( p->list.field[2], 0, 10 ); + + FT_TRACE4(( DBGMSG2, p->glyph_enc )); + + /* Check that the encoding is in the Unicode range because */ + /* otherwise p->have (a bitmap with static size) overflows. */ + if ( p->glyph_enc > 0 && + (size_t)p->glyph_enc >= sizeof ( p->have ) * 8 ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG5, lineno, ""ENCODING"" )); + error = BDF_Err_Invalid_File_Format; + goto Exit; + } + + /* Check whether this encoding has already been encountered. */ + /* If it has then change it to unencoded so it gets added if */ + /* indicated. */ + if ( p->glyph_enc >= 0 ) + { + if ( _bdf_glyph_modified( p->have, p->glyph_enc ) ) + { + /* Emit a message saying a glyph has been moved to the */ + /* unencoded area. */ + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG12, + p->glyph_enc, p->glyph_name )); + p->glyph_enc = -1; + font->modified = 1; + } + else + _bdf_set_glyph_modified( p->have, p->glyph_enc ); + } + + if ( p->glyph_enc >= 0 ) + { + /* Make sure there are enough glyphs allocated in case the */ + /* number of characters happen to be wrong. */ + if ( font->glyphs_used == font->glyphs_size ) + { + if ( FT_RENEW_ARRAY( font->glyphs, + font->glyphs_size, + font->glyphs_size + 64 ) ) + goto Exit; + + font->glyphs_size += 64; + } + + glyph = font->glyphs + font->glyphs_used++; + glyph->name = p->glyph_name; + glyph->encoding = p->glyph_enc; + + /* Reset the initial glyph info. */ + p->glyph_name = 0; + } + else + { + /* Unencoded glyph. Check whether it should */ + /* be added or not. */ + if ( p->opts->keep_unencoded != 0 ) + { + /* Allocate the next unencoded glyph. */ + if ( font->unencoded_used == font->unencoded_size ) + { + if ( FT_RENEW_ARRAY( font->unencoded , + font->unencoded_size, + font->unencoded_size + 4 ) ) + goto Exit; + + font->unencoded_size += 4; + } + + glyph = font->unencoded + font->unencoded_used; + glyph->name = p->glyph_name; + glyph->encoding = font->unencoded_used++; + } + else + /* Free up the glyph name if the unencoded shouldn't be */ + /* kept. */ + FT_FREE( p->glyph_name ); + + p->glyph_name = 0; + } + + /* Clear the flags that might be added when width and height are */ + /* checked for consistency. */ + p->flags &= ~( _BDF_GLYPH_WIDTH_CHECK | _BDF_GLYPH_HEIGHT_CHECK ); + + p->flags |= _BDF_ENCODING; + + goto Exit; + } + + /* Point at the glyph being constructed. */ + if ( p->glyph_enc == -1 ) + glyph = font->unencoded + ( font->unencoded_used - 1 ); + else + glyph = font->glyphs + ( font->glyphs_used - 1 ); + + /* Check whether a bitmap is being constructed. */ + if ( p->flags & _BDF_BITMAP ) + { + /* If there are more rows than are specified in the glyph metrics, */ + /* ignore the remaining lines. */ + if ( p->row >= (unsigned long)glyph->bbx.height ) + { + if ( !( p->flags & _BDF_GLYPH_HEIGHT_CHECK ) ) + { + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG13, glyph->encoding )); + p->flags |= _BDF_GLYPH_HEIGHT_CHECK; + font->modified = 1; + } + + goto Exit; + } + + /* Only collect the number of nibbles indicated by the glyph */ + /* metrics. If there are more columns, they are simply ignored. */ + nibbles = glyph->bpr << 1; + bp = glyph->bitmap + p->row * glyph->bpr; + + for ( i = 0; i < nibbles; i++ ) + { + c = line[i]; + if ( !sbitset( hdigits, c ) ) + break; + *bp = (FT_Byte)( ( *bp << 4 ) + a2i[c] ); + if ( i + 1 < nibbles && ( i & 1 ) ) + *++bp = 0; + } + + /* If any line has not enough columns, */ + /* indicate they have been padded with zero bits. */ + if ( i < nibbles && + !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) ) + { + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG16, glyph->encoding )); + p->flags |= _BDF_GLYPH_WIDTH_CHECK; + font->modified = 1; + } + + /* Remove possible garbage at the right. */ + mask_index = ( glyph->bbx.width * p->font->bpp ) & 7; + if ( glyph->bbx.width ) + *bp &= nibble_mask[mask_index]; + + /* If any line has extra columns, indicate they have been removed. */ + if ( i == nibbles && + sbitset( hdigits, line[nibbles] ) && + !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) ) + { + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG14, glyph->encoding )); + p->flags |= _BDF_GLYPH_WIDTH_CHECK; + font->modified = 1; + } + + p->row++; + goto Exit; + } + + /* Expect the SWIDTH (scalable width) field next. */ + if ( ft_memcmp( line, ""SWIDTH"", 6 ) == 0 ) + { + if ( !( p->flags & _BDF_ENCODING ) ) + goto Missing_Encoding; + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); + p->flags |= _BDF_SWIDTH; + + goto Exit; + } + + /* Expect the DWIDTH (scalable width) field next. */ + if ( ft_memcmp( line, ""DWIDTH"", 6 ) == 0 ) + { + if ( !( p->flags & _BDF_ENCODING ) ) + goto Missing_Encoding; + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); + + if ( !( p->flags & _BDF_SWIDTH ) ) + { + /* Missing SWIDTH field. Emit an auto correction message and set */ + /* the scalable width from the device width. */ + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG9, lineno )); + + glyph->swidth = (unsigned short)FT_MulDiv( + glyph->dwidth, 72000L, + (FT_Long)( font->point_size * + font->resolution_x ) ); + } + + p->flags |= _BDF_DWIDTH; + goto Exit; + } + + /* Expect the BBX field next. */ + if ( ft_memcmp( line, ""BBX"", 3 ) == 0 ) + { + if ( !( p->flags & _BDF_ENCODING ) ) + goto Missing_Encoding; + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + glyph->bbx.width = _bdf_atos( p->list.field[1], 0, 10 ); + glyph->bbx.height = _bdf_atos( p->list.field[2], 0, 10 ); + glyph->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 ); + glyph->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 ); + + /* Generate the ascent and descent of the character. */ + glyph->bbx.ascent = (short)( glyph->bbx.height + glyph->bbx.y_offset ); + glyph->bbx.descent = (short)( -glyph->bbx.y_offset ); + + /* Determine the overall font bounding box as the characters are */ + /* loaded so corrections can be done later if indicated. */ + p->maxas = (short)FT_MAX( glyph->bbx.ascent, p->maxas ); + p->maxds = (short)FT_MAX( glyph->bbx.descent, p->maxds ); + + p->rbearing = (short)( glyph->bbx.width + glyph->bbx.x_offset ); + + p->maxrb = (short)FT_MAX( p->rbearing, p->maxrb ); + p->minlb = (short)FT_MIN( glyph->bbx.x_offset, p->minlb ); + p->maxlb = (short)FT_MAX( glyph->bbx.x_offset, p->maxlb ); + + if ( !( p->flags & _BDF_DWIDTH ) ) + { + /* Missing DWIDTH field. Emit an auto correction message and set */ + /* the device width to the glyph width. */ + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG10, lineno )); + glyph->dwidth = glyph->bbx.width; + } + + /* If the BDF_CORRECT_METRICS flag is set, then adjust the SWIDTH */ + /* value if necessary. */ + if ( p->opts->correct_metrics != 0 ) + { + /* Determine the point size of the glyph. */ + unsigned short sw = (unsigned short)FT_MulDiv( + glyph->dwidth, 72000L, + (FT_Long)( font->point_size * + font->resolution_x ) ); + + + if ( sw != glyph->swidth ) + { + glyph->swidth = sw; + + if ( p->glyph_enc == -1 ) + _bdf_set_glyph_modified( font->umod, + font->unencoded_used - 1 ); + else + _bdf_set_glyph_modified( font->nmod, glyph->encoding ); + + p->flags |= _BDF_SWIDTH_ADJ; + font->modified = 1; + } + } + + p->flags |= _BDF_BBX; + goto Exit; + } + + /* And finally, gather up the bitmap. */ + if ( ft_memcmp( line, ""BITMAP"", 6 ) == 0 ) + { + unsigned long bitmap_size; + + + if ( !( p->flags & _BDF_BBX ) ) + { + /* Missing BBX field. */ + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""BBX"" )); + error = BDF_Err_Missing_Bbx_Field; + goto Exit; + } + + /* Allocate enough space for the bitmap. */ + glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3; + + bitmap_size = glyph->bpr * glyph->bbx.height; + if ( glyph->bpr > 0xFFFFU || bitmap_size > 0xFFFFU ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG4, lineno )); + error = BDF_Err_Bbx_Too_Big; + goto Exit; + } + else + glyph->bytes = (unsigned short)bitmap_size; + + if ( FT_NEW_ARRAY( glyph->bitmap, glyph->bytes ) ) + goto Exit; + + p->row = 0; + p->flags |= _BDF_BITMAP; + + goto Exit; + } + + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG9, lineno )); + error = BDF_Err_Invalid_File_Format; + goto Exit; + + Missing_Encoding: + /* Missing ENCODING field. */ + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""ENCODING"" )); + error = BDF_Err_Missing_Encoding_Field; + + Exit: + if ( error && ( p->flags & _BDF_GLYPH ) ) + FT_FREE( p->glyph_name ); + + return error; + } +",0," _bdf_parse_glyphs( char* line, + unsigned long linelen, + unsigned long lineno, + void* call_data, + void* client_data ) + { + int c, mask_index; + char* s; + unsigned char* bp; + unsigned long i, slen, nibbles; + + _bdf_parse_t* p; + bdf_glyph_t* glyph; + bdf_font_t* font; + + FT_Memory memory; + FT_Error error = BDF_Err_Ok; + + FT_UNUSED( call_data ); + FT_UNUSED( lineno ); /* only used in debug mode */ + + + p = (_bdf_parse_t *)client_data; + + font = p->font; + memory = font->memory; + + /* Check for a comment. */ + if ( ft_memcmp( line, ""COMMENT"", 7 ) == 0 ) + { + linelen -= 7; + + s = line + 7; + if ( *s != 0 ) + { + s++; + linelen--; + } + error = _bdf_add_comment( p->font, s, linelen ); + goto Exit; + } + + /* The very first thing expected is the number of glyphs. */ + if ( !( p->flags & _BDF_GLYPHS ) ) + { + if ( ft_memcmp( line, ""CHARS"", 5 ) != 0 ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""CHARS"" )); + error = BDF_Err_Missing_Chars_Field; + goto Exit; + } + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 ); + + /* Make sure the number of glyphs is non-zero. */ + if ( p->cnt == 0 ) + font->glyphs_size = 64; + + /* Limit ourselves to 1,114,112 glyphs in the font (this is the */ + /* number of code points available in Unicode). */ + if ( p->cnt >= 0x110000UL ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG5, lineno, ""CHARS"" )); + error = BDF_Err_Invalid_Argument; + goto Exit; + } + + if ( FT_NEW_ARRAY( font->glyphs, font->glyphs_size ) ) + goto Exit; + + p->flags |= _BDF_GLYPHS; + + goto Exit; + } + + /* Check for the ENDFONT field. */ + if ( ft_memcmp( line, ""ENDFONT"", 7 ) == 0 ) + { + /* Sort the glyphs by encoding. */ + ft_qsort( (char *)font->glyphs, + font->glyphs_used, + sizeof ( bdf_glyph_t ), + by_encoding ); + + p->flags &= ~_BDF_START; + + goto Exit; + } + + /* Check for the ENDCHAR field. */ + if ( ft_memcmp( line, ""ENDCHAR"", 7 ) == 0 ) + { + p->glyph_enc = 0; + p->flags &= ~_BDF_GLYPH_BITS; + + goto Exit; + } + + /* Check whether a glyph is being scanned but should be */ + /* ignored because it is an unencoded glyph. */ + if ( ( p->flags & _BDF_GLYPH ) && + p->glyph_enc == -1 && + p->opts->keep_unencoded == 0 ) + goto Exit; + + /* Check for the STARTCHAR field. */ + if ( ft_memcmp( line, ""STARTCHAR"", 9 ) == 0 ) + { + /* Set the character name in the parse info first until the */ + /* encoding can be checked for an unencoded character. */ + FT_FREE( p->glyph_name ); + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + _bdf_list_shift( &p->list, 1 ); + + s = _bdf_list_join( &p->list, ' ', &slen ); + + if ( !s ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG8, lineno, ""STARTCHAR"" )); + error = BDF_Err_Invalid_File_Format; + goto Exit; + } + + if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) ) + goto Exit; + + FT_MEM_COPY( p->glyph_name, s, slen + 1 ); + + p->flags |= _BDF_GLYPH; + + FT_TRACE4(( DBGMSG1, lineno, s )); + + goto Exit; + } + + /* Check for the ENCODING field. */ + if ( ft_memcmp( line, ""ENCODING"", 8 ) == 0 ) + { + if ( !( p->flags & _BDF_GLYPH ) ) + { + /* Missing STARTCHAR field. */ + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""STARTCHAR"" )); + error = BDF_Err_Missing_Startchar_Field; + goto Exit; + } + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 ); + + /* Normalize negative encoding values. The specification only */ + /* allows -1, but we can be more generous here. */ + if ( p->glyph_enc < -1 ) + p->glyph_enc = -1; + + /* Check for alternative encoding format. */ + if ( p->glyph_enc == -1 && p->list.used > 2 ) + p->glyph_enc = _bdf_atol( p->list.field[2], 0, 10 ); + + FT_TRACE4(( DBGMSG2, p->glyph_enc )); + + /* Check that the encoding is in the Unicode range because */ + /* otherwise p->have (a bitmap with static size) overflows. */ + if ( p->glyph_enc > 0 && + (size_t)p->glyph_enc >= sizeof ( p->have ) * 8 ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG5, lineno, ""ENCODING"" )); + error = BDF_Err_Invalid_File_Format; + goto Exit; + } + + /* Check whether this encoding has already been encountered. */ + /* If it has then change it to unencoded so it gets added if */ + /* indicated. */ + if ( p->glyph_enc >= 0 ) + { + if ( _bdf_glyph_modified( p->have, p->glyph_enc ) ) + { + /* Emit a message saying a glyph has been moved to the */ + /* unencoded area. */ + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG12, + p->glyph_enc, p->glyph_name )); + p->glyph_enc = -1; + font->modified = 1; + } + else + _bdf_set_glyph_modified( p->have, p->glyph_enc ); + } + + if ( p->glyph_enc >= 0 ) + { + /* Make sure there are enough glyphs allocated in case the */ + /* number of characters happen to be wrong. */ + if ( font->glyphs_used == font->glyphs_size ) + { + if ( FT_RENEW_ARRAY( font->glyphs, + font->glyphs_size, + font->glyphs_size + 64 ) ) + goto Exit; + + font->glyphs_size += 64; + } + + glyph = font->glyphs + font->glyphs_used++; + glyph->name = p->glyph_name; + glyph->encoding = p->glyph_enc; + + /* Reset the initial glyph info. */ + p->glyph_name = 0; + } + else + { + /* Unencoded glyph. Check whether it should */ + /* be added or not. */ + if ( p->opts->keep_unencoded != 0 ) + { + /* Allocate the next unencoded glyph. */ + if ( font->unencoded_used == font->unencoded_size ) + { + if ( FT_RENEW_ARRAY( font->unencoded , + font->unencoded_size, + font->unencoded_size + 4 ) ) + goto Exit; + + font->unencoded_size += 4; + } + + glyph = font->unencoded + font->unencoded_used; + glyph->name = p->glyph_name; + glyph->encoding = font->unencoded_used++; + } + else + /* Free up the glyph name if the unencoded shouldn't be */ + /* kept. */ + FT_FREE( p->glyph_name ); + + p->glyph_name = 0; + } + + /* Clear the flags that might be added when width and height are */ + /* checked for consistency. */ + p->flags &= ~( _BDF_GLYPH_WIDTH_CHECK | _BDF_GLYPH_HEIGHT_CHECK ); + + p->flags |= _BDF_ENCODING; + + goto Exit; + } + + /* Point at the glyph being constructed. */ + if ( p->glyph_enc == -1 ) + glyph = font->unencoded + ( font->unencoded_used - 1 ); + else + glyph = font->glyphs + ( font->glyphs_used - 1 ); + + /* Check whether a bitmap is being constructed. */ + if ( p->flags & _BDF_BITMAP ) + { + /* If there are more rows than are specified in the glyph metrics, */ + /* ignore the remaining lines. */ + if ( p->row >= (unsigned long)glyph->bbx.height ) + { + if ( !( p->flags & _BDF_GLYPH_HEIGHT_CHECK ) ) + { + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG13, glyph->encoding )); + p->flags |= _BDF_GLYPH_HEIGHT_CHECK; + font->modified = 1; + } + + goto Exit; + } + + /* Only collect the number of nibbles indicated by the glyph */ + /* metrics. If there are more columns, they are simply ignored. */ + nibbles = glyph->bpr << 1; + bp = glyph->bitmap + p->row * glyph->bpr; + + for ( i = 0; i < nibbles; i++ ) + { + c = line[i]; + if ( !sbitset( hdigits, c ) ) + break; + *bp = (FT_Byte)( ( *bp << 4 ) + a2i[c] ); + if ( i + 1 < nibbles && ( i & 1 ) ) + *++bp = 0; + } + + /* If any line has not enough columns, */ + /* indicate they have been padded with zero bits. */ + if ( i < nibbles && + !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) ) + { + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG16, glyph->encoding )); + p->flags |= _BDF_GLYPH_WIDTH_CHECK; + font->modified = 1; + } + + /* Remove possible garbage at the right. */ + mask_index = ( glyph->bbx.width * p->font->bpp ) & 7; + if ( glyph->bbx.width ) + *bp &= nibble_mask[mask_index]; + + /* If any line has extra columns, indicate they have been removed. */ + if ( i == nibbles && + sbitset( hdigits, line[nibbles] ) && + !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) ) + { + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG14, glyph->encoding )); + p->flags |= _BDF_GLYPH_WIDTH_CHECK; + font->modified = 1; + } + + p->row++; + goto Exit; + } + + /* Expect the SWIDTH (scalable width) field next. */ + if ( ft_memcmp( line, ""SWIDTH"", 6 ) == 0 ) + { + if ( !( p->flags & _BDF_ENCODING ) ) + goto Missing_Encoding; + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); + p->flags |= _BDF_SWIDTH; + + goto Exit; + } + + /* Expect the DWIDTH (scalable width) field next. */ + if ( ft_memcmp( line, ""DWIDTH"", 6 ) == 0 ) + { + if ( !( p->flags & _BDF_ENCODING ) ) + goto Missing_Encoding; + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); + + if ( !( p->flags & _BDF_SWIDTH ) ) + { + /* Missing SWIDTH field. Emit an auto correction message and set */ + /* the scalable width from the device width. */ + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG9, lineno )); + + glyph->swidth = (unsigned short)FT_MulDiv( + glyph->dwidth, 72000L, + (FT_Long)( font->point_size * + font->resolution_x ) ); + } + + p->flags |= _BDF_DWIDTH; + goto Exit; + } + + /* Expect the BBX field next. */ + if ( ft_memcmp( line, ""BBX"", 3 ) == 0 ) + { + if ( !( p->flags & _BDF_ENCODING ) ) + goto Missing_Encoding; + + error = _bdf_list_split( &p->list, (char *)"" +"", line, linelen ); + if ( error ) + goto Exit; + + glyph->bbx.width = _bdf_atos( p->list.field[1], 0, 10 ); + glyph->bbx.height = _bdf_atos( p->list.field[2], 0, 10 ); + glyph->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 ); + glyph->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 ); + + /* Generate the ascent and descent of the character. */ + glyph->bbx.ascent = (short)( glyph->bbx.height + glyph->bbx.y_offset ); + glyph->bbx.descent = (short)( -glyph->bbx.y_offset ); + + /* Determine the overall font bounding box as the characters are */ + /* loaded so corrections can be done later if indicated. */ + p->maxas = (short)FT_MAX( glyph->bbx.ascent, p->maxas ); + p->maxds = (short)FT_MAX( glyph->bbx.descent, p->maxds ); + + p->rbearing = (short)( glyph->bbx.width + glyph->bbx.x_offset ); + + p->maxrb = (short)FT_MAX( p->rbearing, p->maxrb ); + p->minlb = (short)FT_MIN( glyph->bbx.x_offset, p->minlb ); + p->maxlb = (short)FT_MAX( glyph->bbx.x_offset, p->maxlb ); + + if ( !( p->flags & _BDF_DWIDTH ) ) + { + /* Missing DWIDTH field. Emit an auto correction message and set */ + /* the device width to the glyph width. */ + FT_TRACE2(( ""_bdf_parse_glyphs: "" ACMSG10, lineno )); + glyph->dwidth = glyph->bbx.width; + } + + /* If the BDF_CORRECT_METRICS flag is set, then adjust the SWIDTH */ + /* value if necessary. */ + if ( p->opts->correct_metrics != 0 ) + { + /* Determine the point size of the glyph. */ + unsigned short sw = (unsigned short)FT_MulDiv( + glyph->dwidth, 72000L, + (FT_Long)( font->point_size * + font->resolution_x ) ); + + + if ( sw != glyph->swidth ) + { + glyph->swidth = sw; + + if ( p->glyph_enc == -1 ) + _bdf_set_glyph_modified( font->umod, + font->unencoded_used - 1 ); + else + _bdf_set_glyph_modified( font->nmod, glyph->encoding ); + + p->flags |= _BDF_SWIDTH_ADJ; + font->modified = 1; + } + } + + p->flags |= _BDF_BBX; + goto Exit; + } + + /* And finally, gather up the bitmap. */ + if ( ft_memcmp( line, ""BITMAP"", 6 ) == 0 ) + { + unsigned long bitmap_size; + + + if ( !( p->flags & _BDF_BBX ) ) + { + /* Missing BBX field. */ + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""BBX"" )); + error = BDF_Err_Missing_Bbx_Field; + goto Exit; + } + + /* Allocate enough space for the bitmap. */ + glyph->bpr = ( glyph->bbx.width * p->font->bpp + 7 ) >> 3; + + bitmap_size = glyph->bpr * glyph->bbx.height; + if ( glyph->bpr > 0xFFFFU || bitmap_size > 0xFFFFU ) + { + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG4, lineno )); + error = BDF_Err_Bbx_Too_Big; + goto Exit; + } + else + glyph->bytes = (unsigned short)bitmap_size; + + if ( FT_NEW_ARRAY( glyph->bitmap, glyph->bytes ) ) + goto Exit; + + p->row = 0; + p->flags |= _BDF_BITMAP; + + goto Exit; + } + + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG9, lineno )); + error = BDF_Err_Invalid_File_Format; + goto Exit; + + Missing_Encoding: + /* Missing ENCODING field. */ + FT_ERROR(( ""_bdf_parse_glyphs: "" ERRMSG1, lineno, ""ENCODING"" )); + error = BDF_Err_Missing_Encoding_Field; + + Exit: + if ( error && ( p->flags & _BDF_GLYPH ) ) + FT_FREE( p->glyph_name ); + + return error; + } +","@@ -2169,7 +2169,10 @@ + p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1], 0, 10 ); + + if ( FT_NEW_ARRAY( p->font->props, p->cnt ) ) ++ { ++ p->font->props_size = 0; + goto Exit; ++ } + + p->flags |= _BDF_PROPS; + *next = _bdf_parse_properties;",4155,4391,6144 +8966,"parse_args_recurse (int *argcp, + const char ***argvp, + bool in_file, + int *total_parsed_argc_p) +{ + SetupOp *op; + int argc = *argcp; + const char **argv = *argvp; + /* I can't imagine a case where someone wants more than this. + * If you do...you should be able to pass multiple files + * via a single tmpfs and linking them there, etc. + * + * We're adding this hardening due to precedent from + * http://googleprojectzero.blogspot.com/2014/08/the-poisoned-nul-byte-2014-edition.html + * + * I picked 9000 because the Internet told me to and it was hard to + * resist. + */ + static const uint32_t MAX_ARGS = 9000; + + if (*total_parsed_argc_p > MAX_ARGS) + die (""Exceeded maximum number of arguments %u"", MAX_ARGS); + + while (argc > 0) + { + const char *arg = argv[0]; + + if (strcmp (arg, ""--help"") == 0) + { + usage (EXIT_SUCCESS, stdout); + } + else if (strcmp (arg, ""--version"") == 0) + { + print_version_and_exit (); + } + else if (strcmp (arg, ""--args"") == 0) + { + int the_fd; + char *endptr; + const char *p, *data_end; + size_t data_len; + cleanup_free const char **data_argv = NULL; + const char **data_argv_copy; + int data_argc; + int i; + + if (in_file) + die (""--args not supported in arguments file""); + + if (argc < 2) + die (""--args takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + /* opt_args_data is essentially a recursive argv array, which we must + * keep allocated until exit time, since its argv entries get used + * by the other cases in parse_args_recurse() when we recurse. */ + opt_args_data = load_file_data (the_fd, &data_len); + if (opt_args_data == NULL) + die_with_error (""Can't read --args data""); + (void) close (the_fd); + + data_end = opt_args_data + data_len; + data_argc = 0; + + p = opt_args_data; + while (p != NULL && p < data_end) + { + data_argc++; + (*total_parsed_argc_p)++; + if (*total_parsed_argc_p > MAX_ARGS) + die (""Exceeded maximum number of arguments %u"", MAX_ARGS); + p = memchr (p, 0, data_end - p); + if (p != NULL) + p++; + } + + data_argv = xcalloc (sizeof (char *) * (data_argc + 1)); + + i = 0; + p = opt_args_data; + while (p != NULL && p < data_end) + { + /* Note: load_file_data always adds a nul terminator, so this is safe + * even for the last string. */ + data_argv[i++] = p; + p = memchr (p, 0, data_end - p); + if (p != NULL) + p++; + } + + data_argv_copy = data_argv; /* Don't change data_argv, we need to free it */ + parse_args_recurse (&data_argc, &data_argv_copy, TRUE, total_parsed_argc_p); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--unshare-all"") == 0) + { + /* Keep this in order with the older (legacy) --unshare arguments, + * we use the --try variants of user and cgroup, since we want + * to support systems/kernels without support for those. + */ + opt_unshare_user_try = opt_unshare_ipc = opt_unshare_pid = + opt_unshare_uts = opt_unshare_cgroup_try = + opt_unshare_net = TRUE; + } + /* Begin here the older individual --unshare variants */ + else if (strcmp (arg, ""--unshare-user"") == 0) + { + opt_unshare_user = TRUE; + } + else if (strcmp (arg, ""--unshare-user-try"") == 0) + { + opt_unshare_user_try = TRUE; + } + else if (strcmp (arg, ""--unshare-ipc"") == 0) + { + opt_unshare_ipc = TRUE; + } + else if (strcmp (arg, ""--unshare-pid"") == 0) + { + opt_unshare_pid = TRUE; + } + else if (strcmp (arg, ""--unshare-net"") == 0) + { + opt_unshare_net = TRUE; + } + else if (strcmp (arg, ""--unshare-uts"") == 0) + { + opt_unshare_uts = TRUE; + } + else if (strcmp (arg, ""--unshare-cgroup"") == 0) + { + opt_unshare_cgroup = TRUE; + } + else if (strcmp (arg, ""--unshare-cgroup-try"") == 0) + { + opt_unshare_cgroup_try = TRUE; + } + /* Begin here the newer --share variants */ + else if (strcmp (arg, ""--share-net"") == 0) + { + opt_unshare_net = FALSE; + } + /* End --share variants, other arguments begin */ + else if (strcmp (arg, ""--chdir"") == 0) + { + if (argc < 2) + die (""--chdir takes one argument""); + + opt_chdir_path = argv[1]; + argv++; + argc--; + } + else if (strcmp (arg, ""--remount-ro"") == 0) + { + if (argc < 2) + die (""--remount-ro takes one argument""); + + SetupOp *op = setup_op_new (SETUP_REMOUNT_RO_NO_RECURSIVE); + op->dest = argv[1]; + + argv++; + argc--; + } + else if (strcmp(arg, ""--bind"") == 0 || + strcmp(arg, ""--bind-try"") == 0) + { + if (argc < 3) + die (""%s takes two arguments"", arg); + + op = setup_op_new (SETUP_BIND_MOUNT); + op->source = argv[1]; + op->dest = argv[2]; + if (strcmp(arg, ""--bind-try"") == 0) + op->flags = ALLOW_NOTEXIST; + + argv += 2; + argc -= 2; + } + else if (strcmp(arg, ""--ro-bind"") == 0 || + strcmp(arg, ""--ro-bind-try"") == 0) + { + if (argc < 3) + die (""%s takes two arguments"", arg); + + op = setup_op_new (SETUP_RO_BIND_MOUNT); + op->source = argv[1]; + op->dest = argv[2]; + if (strcmp(arg, ""--ro-bind-try"") == 0) + op->flags = ALLOW_NOTEXIST; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--dev-bind"") == 0 || + strcmp (arg, ""--dev-bind-try"") == 0) + { + if (argc < 3) + die (""%s takes two arguments"", arg); + + op = setup_op_new (SETUP_DEV_BIND_MOUNT); + op->source = argv[1]; + op->dest = argv[2]; + if (strcmp(arg, ""--dev-bind-try"") == 0) + op->flags = ALLOW_NOTEXIST; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--proc"") == 0) + { + if (argc < 2) + die (""--proc takes an argument""); + + op = setup_op_new (SETUP_MOUNT_PROC); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--exec-label"") == 0) + { + if (argc < 2) + die (""--exec-label takes an argument""); + opt_exec_label = argv[1]; + die_unless_label_valid (opt_exec_label); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--file-label"") == 0) + { + if (argc < 2) + die (""--file-label takes an argument""); + opt_file_label = argv[1]; + die_unless_label_valid (opt_file_label); + if (label_create_file (opt_file_label)) + die_with_error (""--file-label setup failed""); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--dev"") == 0) + { + if (argc < 2) + die (""--dev takes an argument""); + + op = setup_op_new (SETUP_MOUNT_DEV); + op->dest = argv[1]; + opt_needs_devpts = TRUE; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--tmpfs"") == 0) + { + if (argc < 2) + die (""--tmpfs takes an argument""); + + op = setup_op_new (SETUP_MOUNT_TMPFS); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--mqueue"") == 0) + { + if (argc < 2) + die (""--mqueue takes an argument""); + + op = setup_op_new (SETUP_MOUNT_MQUEUE); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--dir"") == 0) + { + if (argc < 2) + die (""--dir takes an argument""); + + op = setup_op_new (SETUP_MAKE_DIR); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--file"") == 0) + { + int file_fd; + char *endptr; + + if (argc < 3) + die (""--file takes two arguments""); + + file_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + op = setup_op_new (SETUP_MAKE_FILE); + op->fd = file_fd; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--bind-data"") == 0) + { + int file_fd; + char *endptr; + + if (argc < 3) + die (""--bind-data takes two arguments""); + + file_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + op = setup_op_new (SETUP_MAKE_BIND_FILE); + op->fd = file_fd; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--ro-bind-data"") == 0) + { + int file_fd; + char *endptr; + + if (argc < 3) + die (""--ro-bind-data takes two arguments""); + + file_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + op = setup_op_new (SETUP_MAKE_RO_BIND_FILE); + op->fd = file_fd; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--symlink"") == 0) + { + if (argc < 3) + die (""--symlink takes two arguments""); + + op = setup_op_new (SETUP_MAKE_SYMLINK); + op->source = argv[1]; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--lock-file"") == 0) + { + if (argc < 2) + die (""--lock-file takes an argument""); + + (void) lock_file_new (argv[1]); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--sync-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--sync-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_sync_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--block-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--block-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_block_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--userns-block-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--userns-block-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_userns_block_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--info-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--info-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_info_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--json-status-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--json-status-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_json_status_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--seccomp"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--seccomp takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_seccomp_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--setenv"") == 0) + { + if (argc < 3) + die (""--setenv takes two arguments""); + + xsetenv (argv[1], argv[2], 1); + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--unsetenv"") == 0) + { + if (argc < 2) + die (""--unsetenv takes an argument""); + + xunsetenv (argv[1]); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--uid"") == 0) + { + int the_uid; + char *endptr; + + if (argc < 2) + die (""--uid takes an argument""); + + the_uid = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_uid < 0) + die (""Invalid uid: %s"", argv[1]); + + opt_sandbox_uid = the_uid; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--gid"") == 0) + { + int the_gid; + char *endptr; + + if (argc < 2) + die (""--gid takes an argument""); + + the_gid = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_gid < 0) + die (""Invalid gid: %s"", argv[1]); + + opt_sandbox_gid = the_gid; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--hostname"") == 0) + { + if (argc < 2) + die (""--hostname takes an argument""); + + op = setup_op_new (SETUP_SET_HOSTNAME); + op->dest = argv[1]; + op->flags = NO_CREATE_DEST; + + opt_sandbox_hostname = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--new-session"") == 0) + { + opt_new_session = TRUE; + } + else if (strcmp (arg, ""--die-with-parent"") == 0) + { + opt_die_with_parent = TRUE; + } + else if (strcmp (arg, ""--as-pid-1"") == 0) + { + opt_as_pid_1 = TRUE; + } + else if (strcmp (arg, ""--cap-add"") == 0) + { + cap_value_t cap; + if (argc < 2) + die (""--cap-add takes an argument""); + + opt_cap_add_or_drop_used = TRUE; + + if (strcasecmp (argv[1], ""ALL"") == 0) + { + requested_caps[0] = requested_caps[1] = 0xFFFFFFFF; + } + else + { + if (cap_from_name (argv[1], &cap) < 0) + die (""unknown cap: %s"", argv[1]); + + if (cap < 32) + requested_caps[0] |= CAP_TO_MASK_0 (cap); + else + requested_caps[1] |= CAP_TO_MASK_1 (cap - 32); + } + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--cap-drop"") == 0) + { + cap_value_t cap; + if (argc < 2) + die (""--cap-drop takes an argument""); + + opt_cap_add_or_drop_used = TRUE; + + if (strcasecmp (argv[1], ""ALL"") == 0) + { + requested_caps[0] = requested_caps[1] = 0; + } + else + { + if (cap_from_name (argv[1], &cap) < 0) + die (""unknown cap: %s"", argv[1]); + + if (cap < 32) + requested_caps[0] &= ~CAP_TO_MASK_0 (cap); + else + requested_caps[1] &= ~CAP_TO_MASK_1 (cap - 32); + } + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--"") == 0) + { + argv += 1; + argc -= 1; + break; + } + else if (*arg == '-') + { + die (""Unknown option %s"", arg); + } + else + { + break; + } + + argv++; + argc--; + } + + *argcp = argc; + *argvp = argv; +} +",0,"parse_args_recurse (int *argcp, + const char ***argvp, + bool in_file, + int *total_parsed_argc_p) +{ + SetupOp *op; + int argc = *argcp; + const char **argv = *argvp; + /* I can't imagine a case where someone wants more than this. + * If you do...you should be able to pass multiple files + * via a single tmpfs and linking them there, etc. + * + * We're adding this hardening due to precedent from + * http://googleprojectzero.blogspot.com/2014/08/the-poisoned-nul-byte-2014-edition.html + * + * I picked 9000 because the Internet told me to and it was hard to + * resist. + */ + static const uint32_t MAX_ARGS = 9000; + + if (*total_parsed_argc_p > MAX_ARGS) + die (""Exceeded maximum number of arguments %u"", MAX_ARGS); + + while (argc > 0) + { + const char *arg = argv[0]; + + if (strcmp (arg, ""--help"") == 0) + { + usage (EXIT_SUCCESS, stdout); + } + else if (strcmp (arg, ""--version"") == 0) + { + print_version_and_exit (); + } + else if (strcmp (arg, ""--args"") == 0) + { + int the_fd; + char *endptr; + const char *p, *data_end; + size_t data_len; + cleanup_free const char **data_argv = NULL; + const char **data_argv_copy; + int data_argc; + int i; + + if (in_file) + die (""--args not supported in arguments file""); + + if (argc < 2) + die (""--args takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + /* opt_args_data is essentially a recursive argv array, which we must + * keep allocated until exit time, since its argv entries get used + * by the other cases in parse_args_recurse() when we recurse. */ + opt_args_data = load_file_data (the_fd, &data_len); + if (opt_args_data == NULL) + die_with_error (""Can't read --args data""); + (void) close (the_fd); + + data_end = opt_args_data + data_len; + data_argc = 0; + + p = opt_args_data; + while (p != NULL && p < data_end) + { + data_argc++; + (*total_parsed_argc_p)++; + if (*total_parsed_argc_p > MAX_ARGS) + die (""Exceeded maximum number of arguments %u"", MAX_ARGS); + p = memchr (p, 0, data_end - p); + if (p != NULL) + p++; + } + + data_argv = xcalloc (sizeof (char *) * (data_argc + 1)); + + i = 0; + p = opt_args_data; + while (p != NULL && p < data_end) + { + /* Note: load_file_data always adds a nul terminator, so this is safe + * even for the last string. */ + data_argv[i++] = p; + p = memchr (p, 0, data_end - p); + if (p != NULL) + p++; + } + + data_argv_copy = data_argv; /* Don't change data_argv, we need to free it */ + parse_args_recurse (&data_argc, &data_argv_copy, TRUE, total_parsed_argc_p); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--unshare-all"") == 0) + { + /* Keep this in order with the older (legacy) --unshare arguments, + * we use the --try variants of user and cgroup, since we want + * to support systems/kernels without support for those. + */ + opt_unshare_user_try = opt_unshare_ipc = opt_unshare_pid = + opt_unshare_uts = opt_unshare_cgroup_try = + opt_unshare_net = TRUE; + } + /* Begin here the older individual --unshare variants */ + else if (strcmp (arg, ""--unshare-user"") == 0) + { + opt_unshare_user = TRUE; + } + else if (strcmp (arg, ""--unshare-user-try"") == 0) + { + opt_unshare_user_try = TRUE; + } + else if (strcmp (arg, ""--unshare-ipc"") == 0) + { + opt_unshare_ipc = TRUE; + } + else if (strcmp (arg, ""--unshare-pid"") == 0) + { + opt_unshare_pid = TRUE; + } + else if (strcmp (arg, ""--unshare-net"") == 0) + { + opt_unshare_net = TRUE; + } + else if (strcmp (arg, ""--unshare-uts"") == 0) + { + opt_unshare_uts = TRUE; + } + else if (strcmp (arg, ""--unshare-cgroup"") == 0) + { + opt_unshare_cgroup = TRUE; + } + else if (strcmp (arg, ""--unshare-cgroup-try"") == 0) + { + opt_unshare_cgroup_try = TRUE; + } + /* Begin here the newer --share variants */ + else if (strcmp (arg, ""--share-net"") == 0) + { + opt_unshare_net = FALSE; + } + /* End --share variants, other arguments begin */ + else if (strcmp (arg, ""--chdir"") == 0) + { + if (argc < 2) + die (""--chdir takes one argument""); + + opt_chdir_path = argv[1]; + argv++; + argc--; + } + else if (strcmp (arg, ""--remount-ro"") == 0) + { + if (argc < 2) + die (""--remount-ro takes one argument""); + + SetupOp *op = setup_op_new (SETUP_REMOUNT_RO_NO_RECURSIVE); + op->dest = argv[1]; + + argv++; + argc--; + } + else if (strcmp(arg, ""--bind"") == 0 || + strcmp(arg, ""--bind-try"") == 0) + { + if (argc < 3) + die (""%s takes two arguments"", arg); + + op = setup_op_new (SETUP_BIND_MOUNT); + op->source = argv[1]; + op->dest = argv[2]; + if (strcmp(arg, ""--bind-try"") == 0) + op->flags = ALLOW_NOTEXIST; + + argv += 2; + argc -= 2; + } + else if (strcmp(arg, ""--ro-bind"") == 0 || + strcmp(arg, ""--ro-bind-try"") == 0) + { + if (argc < 3) + die (""%s takes two arguments"", arg); + + op = setup_op_new (SETUP_RO_BIND_MOUNT); + op->source = argv[1]; + op->dest = argv[2]; + if (strcmp(arg, ""--ro-bind-try"") == 0) + op->flags = ALLOW_NOTEXIST; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--dev-bind"") == 0 || + strcmp (arg, ""--dev-bind-try"") == 0) + { + if (argc < 3) + die (""%s takes two arguments"", arg); + + op = setup_op_new (SETUP_DEV_BIND_MOUNT); + op->source = argv[1]; + op->dest = argv[2]; + if (strcmp(arg, ""--dev-bind-try"") == 0) + op->flags = ALLOW_NOTEXIST; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--proc"") == 0) + { + if (argc < 2) + die (""--proc takes an argument""); + + op = setup_op_new (SETUP_MOUNT_PROC); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--exec-label"") == 0) + { + if (argc < 2) + die (""--exec-label takes an argument""); + opt_exec_label = argv[1]; + die_unless_label_valid (opt_exec_label); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--file-label"") == 0) + { + if (argc < 2) + die (""--file-label takes an argument""); + opt_file_label = argv[1]; + die_unless_label_valid (opt_file_label); + if (label_create_file (opt_file_label)) + die_with_error (""--file-label setup failed""); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--dev"") == 0) + { + if (argc < 2) + die (""--dev takes an argument""); + + op = setup_op_new (SETUP_MOUNT_DEV); + op->dest = argv[1]; + opt_needs_devpts = TRUE; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--tmpfs"") == 0) + { + if (argc < 2) + die (""--tmpfs takes an argument""); + + op = setup_op_new (SETUP_MOUNT_TMPFS); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--mqueue"") == 0) + { + if (argc < 2) + die (""--mqueue takes an argument""); + + op = setup_op_new (SETUP_MOUNT_MQUEUE); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--dir"") == 0) + { + if (argc < 2) + die (""--dir takes an argument""); + + op = setup_op_new (SETUP_MAKE_DIR); + op->dest = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--file"") == 0) + { + int file_fd; + char *endptr; + + if (argc < 3) + die (""--file takes two arguments""); + + file_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + op = setup_op_new (SETUP_MAKE_FILE); + op->fd = file_fd; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--bind-data"") == 0) + { + int file_fd; + char *endptr; + + if (argc < 3) + die (""--bind-data takes two arguments""); + + file_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + op = setup_op_new (SETUP_MAKE_BIND_FILE); + op->fd = file_fd; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--ro-bind-data"") == 0) + { + int file_fd; + char *endptr; + + if (argc < 3) + die (""--ro-bind-data takes two arguments""); + + file_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + op = setup_op_new (SETUP_MAKE_RO_BIND_FILE); + op->fd = file_fd; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--symlink"") == 0) + { + if (argc < 3) + die (""--symlink takes two arguments""); + + op = setup_op_new (SETUP_MAKE_SYMLINK); + op->source = argv[1]; + op->dest = argv[2]; + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--lock-file"") == 0) + { + if (argc < 2) + die (""--lock-file takes an argument""); + + (void) lock_file_new (argv[1]); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--sync-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--sync-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_sync_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--block-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--block-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_block_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--userns-block-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--userns-block-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_userns_block_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--info-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--info-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_info_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--json-status-fd"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--json-status-fd takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_json_status_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--seccomp"") == 0) + { + int the_fd; + char *endptr; + + if (argc < 2) + die (""--seccomp takes an argument""); + + the_fd = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0) + die (""Invalid fd: %s"", argv[1]); + + opt_seccomp_fd = the_fd; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--setenv"") == 0) + { + if (argc < 3) + die (""--setenv takes two arguments""); + + xsetenv (argv[1], argv[2], 1); + + argv += 2; + argc -= 2; + } + else if (strcmp (arg, ""--unsetenv"") == 0) + { + if (argc < 2) + die (""--unsetenv takes an argument""); + + xunsetenv (argv[1]); + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--uid"") == 0) + { + int the_uid; + char *endptr; + + if (argc < 2) + die (""--uid takes an argument""); + + the_uid = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_uid < 0) + die (""Invalid uid: %s"", argv[1]); + + opt_sandbox_uid = the_uid; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--gid"") == 0) + { + int the_gid; + char *endptr; + + if (argc < 2) + die (""--gid takes an argument""); + + the_gid = strtol (argv[1], &endptr, 10); + if (argv[1][0] == 0 || endptr[0] != 0 || the_gid < 0) + die (""Invalid gid: %s"", argv[1]); + + opt_sandbox_gid = the_gid; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--hostname"") == 0) + { + if (argc < 2) + die (""--hostname takes an argument""); + + op = setup_op_new (SETUP_SET_HOSTNAME); + op->dest = argv[1]; + op->flags = NO_CREATE_DEST; + + opt_sandbox_hostname = argv[1]; + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--new-session"") == 0) + { + opt_new_session = TRUE; + } + else if (strcmp (arg, ""--die-with-parent"") == 0) + { + opt_die_with_parent = TRUE; + } + else if (strcmp (arg, ""--as-pid-1"") == 0) + { + opt_as_pid_1 = TRUE; + } + else if (strcmp (arg, ""--cap-add"") == 0) + { + cap_value_t cap; + if (argc < 2) + die (""--cap-add takes an argument""); + + opt_cap_add_or_drop_used = TRUE; + + if (strcasecmp (argv[1], ""ALL"") == 0) + { + requested_caps[0] = requested_caps[1] = 0xFFFFFFFF; + } + else + { + if (cap_from_name (argv[1], &cap) < 0) + die (""unknown cap: %s"", argv[1]); + + if (cap < 32) + requested_caps[0] |= CAP_TO_MASK_0 (cap); + else + requested_caps[1] |= CAP_TO_MASK_1 (cap - 32); + } + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--cap-drop"") == 0) + { + cap_value_t cap; + if (argc < 2) + die (""--cap-drop takes an argument""); + + opt_cap_add_or_drop_used = TRUE; + + if (strcasecmp (argv[1], ""ALL"") == 0) + { + requested_caps[0] = requested_caps[1] = 0; + } + else + { + if (cap_from_name (argv[1], &cap) < 0) + die (""unknown cap: %s"", argv[1]); + + if (cap < 32) + requested_caps[0] &= ~CAP_TO_MASK_0 (cap); + else + requested_caps[1] &= ~CAP_TO_MASK_1 (cap - 32); + } + + argv += 1; + argc -= 1; + } + else if (strcmp (arg, ""--"") == 0) + { + argv += 1; + argc -= 1; + break; + } + else if (*arg == '-') + { + die (""Unknown option %s"", arg); + } + else + { + break; + } + + argv++; + argc--; + } + + *argcp = argc; + *argvp = argv; +} +","@@ -2046,7 +2046,7 @@ main (int argc, + char **argv) + { + mode_t old_umask; +- cleanup_free char *base_path = NULL; ++ const char *base_path = NULL; + int clone_flags; + char *old_cwd = NULL; + pid_t pid; +@@ -2187,15 +2187,12 @@ main (int argc, + die_with_error (""Can't open /proc""); + + /* We need *some* mountpoint where we can mount the root tmpfs. +- We first try in /run, and if that fails, try in /tmp. */ +- base_path = xasprintf (""/run/user/%d/.bubblewrap"", real_uid); +- if (ensure_dir (base_path, 0755)) +- { +- free (base_path); +- base_path = xasprintf (""/tmp/.bubblewrap-%d"", real_uid); +- if (ensure_dir (base_path, 0755)) +- die_with_error (""Creating root mountpoint failed""); +- } ++ * Because we use pivot_root, it won't appear to be mounted from ++ * the perspective of the sandboxed process, so we can use anywhere ++ * that is sure to exist, that is sure to not be a symlink controlled ++ * by someone malicious, and that we won't immediately need to ++ * access ourselves. */ ++ base_path = ""/tmp""; + + __debug__ ((""creating new namespace\n"")); + +@@ -2400,7 +2397,8 @@ main (int argc, + /* We create a subdir ""$base_path/newroot"" for the new root, that + * way we can pivot_root to base_path, and put the old root at + * ""$base_path/oldroot"". This avoids problems accessing the oldroot +- * dir if the user requested to bind mount something over / */ ++ * dir if the user requested to bind mount something over / (or ++ * over /tmp, now that we use that for base_path). */ + + if (mkdir (""newroot"", 0755)) + die_with_error (""Creating newroot failed"");",4661,4897,6144 +9458,"int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) + { + int al,i,j,ret; + unsigned int n; + SSL3_RECORD *rr; + void (*cb)(const SSL *ssl,int type2,int val)=NULL; + + if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ + if (!ssl3_setup_read_buffer(s)) + return(-1); + + if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE)) || + (peek && (type != SSL3_RT_APPLICATION_DATA))) + { + SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); + return -1; + } + + if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) + /* (partially) satisfy request from storage */ + { + unsigned char *src = s->s3->handshake_fragment; + unsigned char *dst = buf; + unsigned int k; + + /* peek == 0 */ + n = 0; + while ((len > 0) && (s->s3->handshake_fragment_len > 0)) + { + *dst++ = *src++; + len--; s->s3->handshake_fragment_len--; + n++; + } + /* move any remaining fragment bytes: */ + for (k = 0; k < s->s3->handshake_fragment_len; k++) + s->s3->handshake_fragment[k] = *src++; + return n; + } + + /* Now s->s3->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */ + + if (!s->in_handshake && SSL_in_init(s)) + { + /* type == SSL3_RT_APPLICATION_DATA */ + i=s->handshake_func(s); + if (i < 0) return(i); + if (i == 0) + { + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); + return(-1); + } + } +start: + s->rwstate=SSL_NOTHING; + + /*- + * s->s3->rrec.type - is the type of record + * s->s3->rrec.data, - data + * s->s3->rrec.off, - offset into 'data' for next read + * s->s3->rrec.length, - number of bytes. + */ + rr = &(s->s3->rrec); + + /* get new packet if necessary */ + if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) + { + ret=ssl3_get_record(s); + if (ret <= 0) return(ret); + } + + /* we now have a packet which can be read and processed */ + + if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, + * reset by ssl3_get_finished */ + && (rr->type != SSL3_RT_HANDSHAKE)) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); + goto f_err; + } + + /* If the other end has shut down, throw anything we read away + * (even in 'peek' mode) */ + if (s->shutdown & SSL_RECEIVED_SHUTDOWN) + { + rr->length=0; + s->rwstate=SSL_NOTHING; + return(0); + } + + + if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ + { + /* make sure that we are not getting application data when we + * are doing a handshake for the first time */ + if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && + (s->enc_read_ctx == NULL)) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE); + goto f_err; + } + + if (len <= 0) return(len); + + if ((unsigned int)len > rr->length) + n = rr->length; + else + n = (unsigned int)len; + + memcpy(buf,&(rr->data[rr->off]),n); + if (!peek) + { + rr->length-=n; + rr->off+=n; + if (rr->length == 0) + { + s->rstate=SSL_ST_READ_HEADER; + rr->off=0; + if (s->mode & SSL_MODE_RELEASE_BUFFERS && s->s3->rbuf.left == 0) + ssl3_release_read_buffer(s); + } + } + return(n); + } + + + /* If we get here, then type != rr->type; if we have a handshake + * message, then it was unexpected (Hello Request or Client Hello). */ + + /* In case of record types for which we have 'fragment' storage, + * fill that so that we can process the data at a fixed place. + */ + { + unsigned int dest_maxlen = 0; + unsigned char *dest = NULL; + unsigned int *dest_len = NULL; + + if (rr->type == SSL3_RT_HANDSHAKE) + { + dest_maxlen = sizeof s->s3->handshake_fragment; + dest = s->s3->handshake_fragment; + dest_len = &s->s3->handshake_fragment_len; + } + else if (rr->type == SSL3_RT_ALERT) + { + dest_maxlen = sizeof s->s3->alert_fragment; + dest = s->s3->alert_fragment; + dest_len = &s->s3->alert_fragment_len; + } +#ifndef OPENSSL_NO_HEARTBEATS + else if (rr->type == TLS1_RT_HEARTBEAT) + { + tls1_process_heartbeat(s); + + /* Exit and notify application to read again */ + rr->length = 0; + s->rwstate=SSL_READING; + BIO_clear_retry_flags(SSL_get_rbio(s)); + BIO_set_retry_read(SSL_get_rbio(s)); + return(-1); + } +#endif + + if (dest_maxlen > 0) + { + n = dest_maxlen - *dest_len; /* available space in 'dest' */ + if (rr->length < n) + n = rr->length; /* available bytes */ + + /* now move 'n' bytes: */ + while (n-- > 0) + { + dest[(*dest_len)++] = rr->data[rr->off++]; + rr->length--; + } + + if (*dest_len < dest_maxlen) + goto start; /* fragment was too small */ + } + } + + /*- + * s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE; + * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT. + * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) + */ + + /* If we are a client, check for an incoming 'Hello Request': */ + if ((!s->server) && + (s->s3->handshake_fragment_len >= 4) && + (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) && + (s->session != NULL) && (s->session->cipher != NULL)) + { + s->s3->handshake_fragment_len = 0; + + if ((s->s3->handshake_fragment[1] != 0) || + (s->s3->handshake_fragment[2] != 0) || + (s->s3->handshake_fragment[3] != 0)) + { + al=SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_HELLO_REQUEST); + goto f_err; + } + + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg); + + if (SSL_is_init_finished(s) && + !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && + !s->s3->renegotiate) + { + ssl3_renegotiate(s); + if (ssl3_renegotiate_check(s)) + { + i=s->handshake_func(s); + if (i < 0) return(i); + if (i == 0) + { + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); + return(-1); + } + + if (!(s->mode & SSL_MODE_AUTO_RETRY)) + { + if (s->s3->rbuf.left == 0) /* no read-ahead left? */ + { + BIO *bio; + /* In the case where we try to read application data, + * but we trigger an SSL handshake, we return -1 with + * the retry option set. Otherwise renegotiation may + * cause nasty problems in the blocking world */ + s->rwstate=SSL_READING; + bio=SSL_get_rbio(s); + BIO_clear_retry_flags(bio); + BIO_set_retry_read(bio); + return(-1); + } + } + } + } + /* we either finished a handshake or ignored the request, + * now try again to obtain the (application) data we were asked for */ + goto start; + } + /* If we are a server and get a client hello when renegotiation isn't + * allowed send back a no renegotiation alert and carry on. + * WARNING: experimental code, needs reviewing (steve) + */ + if (s->server && + SSL_is_init_finished(s) && + !s->s3->send_connection_binding && + (s->version > SSL3_VERSION) && + (s->s3->handshake_fragment_len >= 4) && + (s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) && + (s->session != NULL) && (s->session->cipher != NULL) && + !(s->ctx->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) + + { + /*s->s3->handshake_fragment_len = 0;*/ + rr->length = 0; + ssl3_send_alert(s,SSL3_AL_WARNING, SSL_AD_NO_RENEGOTIATION); + goto start; + } + if (s->s3->alert_fragment_len >= 2) + { + int alert_level = s->s3->alert_fragment[0]; + int alert_descr = s->s3->alert_fragment[1]; + + s->s3->alert_fragment_len = 0; + + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg); + + if (s->info_callback != NULL) + cb=s->info_callback; + else if (s->ctx->info_callback != NULL) + cb=s->ctx->info_callback; + + if (cb != NULL) + { + j = (alert_level << 8) | alert_descr; + cb(s, SSL_CB_READ_ALERT, j); + } + + if (alert_level == 1) /* warning */ + { + s->s3->warn_alert = alert_descr; + if (alert_descr == SSL_AD_CLOSE_NOTIFY) + { + s->shutdown |= SSL_RECEIVED_SHUTDOWN; + return(0); + } + /* This is a warning but we receive it if we requested + * renegotiation and the peer denied it. Terminate with + * a fatal alert because if application tried to + * renegotiatie it presumably had a good reason and + * expects it to succeed. + * + * In future we might have a renegotiation where we + * don't care if the peer refused it where we carry on. + */ + else if (alert_descr == SSL_AD_NO_RENEGOTIATION) + { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_NO_RENEGOTIATION); + goto f_err; + } +#ifdef SSL_AD_MISSING_SRP_USERNAME + else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME) + return(0); +#endif + } + else if (alert_level == 2) /* fatal */ + { + char tmp[16]; + + s->rwstate=SSL_NOTHING; + s->s3->fatal_alert = alert_descr; + SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); + BIO_snprintf(tmp,sizeof tmp,""%d"",alert_descr); + ERR_add_error_data(2,""SSL alert number "",tmp); + s->shutdown|=SSL_RECEIVED_SHUTDOWN; + SSL_CTX_remove_session(s->ctx,s->session); + return(0); + } + else + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE); + goto f_err; + } + + goto start; + } + + if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */ + { + s->rwstate=SSL_NOTHING; + rr->length=0; + return(0); + } + + if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) + { + /* 'Change Cipher Spec' is just a single byte, so we know + * exactly what the record payload has to look like */ + if ( (rr->length != 1) || (rr->off != 0) || + (rr->data[0] != SSL3_MT_CCS)) + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC); + goto f_err; + } + + /* Check we have a cipher to change to */ + if (s->s3->tmp.new_cipher == NULL) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY); + goto f_err; + } + + if (!(s->s3->flags & SSL3_FLAGS_CCS_OK)) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY); + goto f_err; + } + + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + + rr->length=0; + + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg); + + s->s3->change_cipher_spec=1; + if (!ssl3_do_change_cipher_spec(s)) + goto err; + else + goto start; + } + + /* Unexpected handshake message (Client Hello, or protocol violation) */ + if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake) + { + if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && + !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) + { +#if 0 /* worked only because C operator preferences are not as expected (and + * because this is not really needed for clients except for detecting + * protocol violations): */ + s->state=SSL_ST_BEFORE|(s->server) + ?SSL_ST_ACCEPT + :SSL_ST_CONNECT; +#else + s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; +#endif + s->renegotiate=1; + s->new_session=1; + } + i=s->handshake_func(s); + if (i < 0) return(i); + if (i == 0) + { + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); + return(-1); + } + + if (!(s->mode & SSL_MODE_AUTO_RETRY)) + { + if (s->s3->rbuf.left == 0) /* no read-ahead left? */ + { + BIO *bio; + /* In the case where we try to read application data, + * but we trigger an SSL handshake, we return -1 with + * the retry option set. Otherwise renegotiation may + * cause nasty problems in the blocking world */ + s->rwstate=SSL_READING; + bio=SSL_get_rbio(s); + BIO_clear_retry_flags(bio); + BIO_set_retry_read(bio); + return(-1); + } + } + goto start; + } + + switch (rr->type) + { + default: +#ifndef OPENSSL_NO_TLS + /* TLS up to v1.1 just ignores unknown message types: + * TLS v1.2 give an unexpected message alert. + */ + if (s->version >= TLS1_VERSION && s->version <= TLS1_1_VERSION) + { + rr->length = 0; + goto start; + } +#endif + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); + goto f_err; + case SSL3_RT_CHANGE_CIPHER_SPEC: + case SSL3_RT_ALERT: + case SSL3_RT_HANDSHAKE: + /* we already handled all of these, with the possible exception + * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that + * should not happen when type != rr->type */ + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,ERR_R_INTERNAL_ERROR); + goto f_err; + case SSL3_RT_APPLICATION_DATA: + /* At this point, we were expecting handshake data, + * but have application data. If the library was + * running inside ssl3_read() (i.e. in_read_app_data + * is set) and it makes sense to read application data + * at this point (session renegotiation not yet started), + * we will indulge it. + */ + if (s->s3->in_read_app_data && + (s->s3->total_renegotiations != 0) && + (( + (s->state & SSL_ST_CONNECT) && + (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && + (s->state <= SSL3_ST_CR_SRVR_HELLO_A) + ) || ( + (s->state & SSL_ST_ACCEPT) && + (s->state <= SSL3_ST_SW_HELLO_REQ_A) && + (s->state >= SSL3_ST_SR_CLNT_HELLO_A) + ) + )) + { + s->s3->in_read_app_data=2; + return(-1); + } + else + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); + goto f_err; + } + } + /* not reached */ + +f_err: + ssl3_send_alert(s,SSL3_AL_FATAL,al); +err: + return(-1); + } +",0,"int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) + { + int al,i,j,ret; + unsigned int n; + SSL3_RECORD *rr; + void (*cb)(const SSL *ssl,int type2,int val)=NULL; + + if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ + if (!ssl3_setup_read_buffer(s)) + return(-1); + + if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE)) || + (peek && (type != SSL3_RT_APPLICATION_DATA))) + { + SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); + return -1; + } + + if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) + /* (partially) satisfy request from storage */ + { + unsigned char *src = s->s3->handshake_fragment; + unsigned char *dst = buf; + unsigned int k; + + /* peek == 0 */ + n = 0; + while ((len > 0) && (s->s3->handshake_fragment_len > 0)) + { + *dst++ = *src++; + len--; s->s3->handshake_fragment_len--; + n++; + } + /* move any remaining fragment bytes: */ + for (k = 0; k < s->s3->handshake_fragment_len; k++) + s->s3->handshake_fragment[k] = *src++; + return n; + } + + /* Now s->s3->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */ + + if (!s->in_handshake && SSL_in_init(s)) + { + /* type == SSL3_RT_APPLICATION_DATA */ + i=s->handshake_func(s); + if (i < 0) return(i); + if (i == 0) + { + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); + return(-1); + } + } +start: + s->rwstate=SSL_NOTHING; + + /*- + * s->s3->rrec.type - is the type of record + * s->s3->rrec.data, - data + * s->s3->rrec.off, - offset into 'data' for next read + * s->s3->rrec.length, - number of bytes. + */ + rr = &(s->s3->rrec); + + /* get new packet if necessary */ + if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) + { + ret=ssl3_get_record(s); + if (ret <= 0) return(ret); + } + + /* we now have a packet which can be read and processed */ + + if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, + * reset by ssl3_get_finished */ + && (rr->type != SSL3_RT_HANDSHAKE)) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); + goto f_err; + } + + /* If the other end has shut down, throw anything we read away + * (even in 'peek' mode) */ + if (s->shutdown & SSL_RECEIVED_SHUTDOWN) + { + rr->length=0; + s->rwstate=SSL_NOTHING; + return(0); + } + + + if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ + { + /* make sure that we are not getting application data when we + * are doing a handshake for the first time */ + if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && + (s->enc_read_ctx == NULL)) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE); + goto f_err; + } + + if (len <= 0) return(len); + + if ((unsigned int)len > rr->length) + n = rr->length; + else + n = (unsigned int)len; + + memcpy(buf,&(rr->data[rr->off]),n); + if (!peek) + { + rr->length-=n; + rr->off+=n; + if (rr->length == 0) + { + s->rstate=SSL_ST_READ_HEADER; + rr->off=0; + if (s->mode & SSL_MODE_RELEASE_BUFFERS && s->s3->rbuf.left == 0) + ssl3_release_read_buffer(s); + } + } + return(n); + } + + + /* If we get here, then type != rr->type; if we have a handshake + * message, then it was unexpected (Hello Request or Client Hello). */ + + /* In case of record types for which we have 'fragment' storage, + * fill that so that we can process the data at a fixed place. + */ + { + unsigned int dest_maxlen = 0; + unsigned char *dest = NULL; + unsigned int *dest_len = NULL; + + if (rr->type == SSL3_RT_HANDSHAKE) + { + dest_maxlen = sizeof s->s3->handshake_fragment; + dest = s->s3->handshake_fragment; + dest_len = &s->s3->handshake_fragment_len; + } + else if (rr->type == SSL3_RT_ALERT) + { + dest_maxlen = sizeof s->s3->alert_fragment; + dest = s->s3->alert_fragment; + dest_len = &s->s3->alert_fragment_len; + } +#ifndef OPENSSL_NO_HEARTBEATS + else if (rr->type == TLS1_RT_HEARTBEAT) + { + tls1_process_heartbeat(s); + + /* Exit and notify application to read again */ + rr->length = 0; + s->rwstate=SSL_READING; + BIO_clear_retry_flags(SSL_get_rbio(s)); + BIO_set_retry_read(SSL_get_rbio(s)); + return(-1); + } +#endif + + if (dest_maxlen > 0) + { + n = dest_maxlen - *dest_len; /* available space in 'dest' */ + if (rr->length < n) + n = rr->length; /* available bytes */ + + /* now move 'n' bytes: */ + while (n-- > 0) + { + dest[(*dest_len)++] = rr->data[rr->off++]; + rr->length--; + } + + if (*dest_len < dest_maxlen) + goto start; /* fragment was too small */ + } + } + + /*- + * s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE; + * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT. + * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) + */ + + /* If we are a client, check for an incoming 'Hello Request': */ + if ((!s->server) && + (s->s3->handshake_fragment_len >= 4) && + (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) && + (s->session != NULL) && (s->session->cipher != NULL)) + { + s->s3->handshake_fragment_len = 0; + + if ((s->s3->handshake_fragment[1] != 0) || + (s->s3->handshake_fragment[2] != 0) || + (s->s3->handshake_fragment[3] != 0)) + { + al=SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_HELLO_REQUEST); + goto f_err; + } + + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg); + + if (SSL_is_init_finished(s) && + !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && + !s->s3->renegotiate) + { + ssl3_renegotiate(s); + if (ssl3_renegotiate_check(s)) + { + i=s->handshake_func(s); + if (i < 0) return(i); + if (i == 0) + { + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); + return(-1); + } + + if (!(s->mode & SSL_MODE_AUTO_RETRY)) + { + if (s->s3->rbuf.left == 0) /* no read-ahead left? */ + { + BIO *bio; + /* In the case where we try to read application data, + * but we trigger an SSL handshake, we return -1 with + * the retry option set. Otherwise renegotiation may + * cause nasty problems in the blocking world */ + s->rwstate=SSL_READING; + bio=SSL_get_rbio(s); + BIO_clear_retry_flags(bio); + BIO_set_retry_read(bio); + return(-1); + } + } + } + } + /* we either finished a handshake or ignored the request, + * now try again to obtain the (application) data we were asked for */ + goto start; + } + /* If we are a server and get a client hello when renegotiation isn't + * allowed send back a no renegotiation alert and carry on. + * WARNING: experimental code, needs reviewing (steve) + */ + if (s->server && + SSL_is_init_finished(s) && + !s->s3->send_connection_binding && + (s->version > SSL3_VERSION) && + (s->s3->handshake_fragment_len >= 4) && + (s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) && + (s->session != NULL) && (s->session->cipher != NULL) && + !(s->ctx->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) + + { + /*s->s3->handshake_fragment_len = 0;*/ + rr->length = 0; + ssl3_send_alert(s,SSL3_AL_WARNING, SSL_AD_NO_RENEGOTIATION); + goto start; + } + if (s->s3->alert_fragment_len >= 2) + { + int alert_level = s->s3->alert_fragment[0]; + int alert_descr = s->s3->alert_fragment[1]; + + s->s3->alert_fragment_len = 0; + + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg); + + if (s->info_callback != NULL) + cb=s->info_callback; + else if (s->ctx->info_callback != NULL) + cb=s->ctx->info_callback; + + if (cb != NULL) + { + j = (alert_level << 8) | alert_descr; + cb(s, SSL_CB_READ_ALERT, j); + } + + if (alert_level == 1) /* warning */ + { + s->s3->warn_alert = alert_descr; + if (alert_descr == SSL_AD_CLOSE_NOTIFY) + { + s->shutdown |= SSL_RECEIVED_SHUTDOWN; + return(0); + } + /* This is a warning but we receive it if we requested + * renegotiation and the peer denied it. Terminate with + * a fatal alert because if application tried to + * renegotiatie it presumably had a good reason and + * expects it to succeed. + * + * In future we might have a renegotiation where we + * don't care if the peer refused it where we carry on. + */ + else if (alert_descr == SSL_AD_NO_RENEGOTIATION) + { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_NO_RENEGOTIATION); + goto f_err; + } +#ifdef SSL_AD_MISSING_SRP_USERNAME + else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME) + return(0); +#endif + } + else if (alert_level == 2) /* fatal */ + { + char tmp[16]; + + s->rwstate=SSL_NOTHING; + s->s3->fatal_alert = alert_descr; + SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); + BIO_snprintf(tmp,sizeof tmp,""%d"",alert_descr); + ERR_add_error_data(2,""SSL alert number "",tmp); + s->shutdown|=SSL_RECEIVED_SHUTDOWN; + SSL_CTX_remove_session(s->ctx,s->session); + return(0); + } + else + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE); + goto f_err; + } + + goto start; + } + + if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */ + { + s->rwstate=SSL_NOTHING; + rr->length=0; + return(0); + } + + if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) + { + /* 'Change Cipher Spec' is just a single byte, so we know + * exactly what the record payload has to look like */ + if ( (rr->length != 1) || (rr->off != 0) || + (rr->data[0] != SSL3_MT_CCS)) + { + al=SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC); + goto f_err; + } + + /* Check we have a cipher to change to */ + if (s->s3->tmp.new_cipher == NULL) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY); + goto f_err; + } + + if (!(s->s3->flags & SSL3_FLAGS_CCS_OK)) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY); + goto f_err; + } + + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + + rr->length=0; + + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg); + + s->s3->change_cipher_spec=1; + if (!ssl3_do_change_cipher_spec(s)) + goto err; + else + goto start; + } + + /* Unexpected handshake message (Client Hello, or protocol violation) */ + if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake) + { + if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && + !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) + { +#if 0 /* worked only because C operator preferences are not as expected (and + * because this is not really needed for clients except for detecting + * protocol violations): */ + s->state=SSL_ST_BEFORE|(s->server) + ?SSL_ST_ACCEPT + :SSL_ST_CONNECT; +#else + s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; +#endif + s->renegotiate=1; + s->new_session=1; + } + i=s->handshake_func(s); + if (i < 0) return(i); + if (i == 0) + { + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); + return(-1); + } + + if (!(s->mode & SSL_MODE_AUTO_RETRY)) + { + if (s->s3->rbuf.left == 0) /* no read-ahead left? */ + { + BIO *bio; + /* In the case where we try to read application data, + * but we trigger an SSL handshake, we return -1 with + * the retry option set. Otherwise renegotiation may + * cause nasty problems in the blocking world */ + s->rwstate=SSL_READING; + bio=SSL_get_rbio(s); + BIO_clear_retry_flags(bio); + BIO_set_retry_read(bio); + return(-1); + } + } + goto start; + } + + switch (rr->type) + { + default: +#ifndef OPENSSL_NO_TLS + /* TLS up to v1.1 just ignores unknown message types: + * TLS v1.2 give an unexpected message alert. + */ + if (s->version >= TLS1_VERSION && s->version <= TLS1_1_VERSION) + { + rr->length = 0; + goto start; + } +#endif + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); + goto f_err; + case SSL3_RT_CHANGE_CIPHER_SPEC: + case SSL3_RT_ALERT: + case SSL3_RT_HANDSHAKE: + /* we already handled all of these, with the possible exception + * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that + * should not happen when type != rr->type */ + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,ERR_R_INTERNAL_ERROR); + goto f_err; + case SSL3_RT_APPLICATION_DATA: + /* At this point, we were expecting handshake data, + * but have application data. If the library was + * running inside ssl3_read() (i.e. in_read_app_data + * is set) and it makes sense to read application data + * at this point (session renegotiation not yet started), + * we will indulge it. + */ + if (s->s3->in_read_app_data && + (s->s3->total_renegotiations != 0) && + (( + (s->state & SSL_ST_CONNECT) && + (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && + (s->state <= SSL3_ST_CR_SRVR_HELLO_A) + ) || ( + (s->state & SSL_ST_ACCEPT) && + (s->state <= SSL3_ST_SW_HELLO_REQ_A) && + (s->state >= SSL3_ST_SR_CLNT_HELLO_A) + ) + )) + { + s->s3->in_read_app_data=2; + return(-1); + } + else + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); + goto f_err; + } + } + /* not reached */ + +f_err: + ssl3_send_alert(s,SSL3_AL_FATAL,al); +err: + return(-1); + } +","@@ -197,6 +197,8 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) + * at once (as long as it fits into the buffer). */ + if (SSL_IS_DTLS(s)) + { ++ if (left == 0 && extend) ++ return 0; + if (left > 0 && n > left) + n = left; + }",4315,4551,6144 +1314,"int ssl3_accept(SSL *s) +{ + BUF_MEM *buf; + unsigned long alg_k, Time = (unsigned long)time(NULL); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + int ret = -1; + int new_state, state, skip = 0; + + RAND_add(&Time, sizeof(Time), 0); + ERR_clear_error(); + clear_sys_error(); + + if (s->info_callback != NULL) + cb = s->info_callback; + else if (s->ctx->info_callback != NULL) + cb = s->ctx->info_callback; + + /* init things to blank */ + s->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) + SSL_clear(s); + + if (s->cert == NULL) { + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); + return (-1); + } +#ifndef OPENSSL_NO_HEARTBEATS + /* + * If we're awaiting a HeartbeatResponse, pretend we already got and + * don't await it anymore, because Heartbeats don't make sense during + * handshakes anyway. + */ + if (s->tlsext_hb_pending) { + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + for (;;) { + state = s->state; + + switch (s->state) { + case SSL_ST_RENEGOTIATE: + s->renegotiate = 1; + /* s->state=SSL_ST_ACCEPT; */ + + case SSL_ST_BEFORE: + case SSL_ST_ACCEPT: + case SSL_ST_BEFORE | SSL_ST_ACCEPT: + case SSL_ST_OK | SSL_ST_ACCEPT: + + s->server = 1; + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_START, 1); + + if ((s->version >> 8) != 3) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->type = SSL_ST_ACCEPT; + + if (s->init_buf == NULL) { + if ((buf = BUF_MEM_new()) == NULL) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { + BUF_MEM_free(buf); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + s->init_buf = buf; + } + + if (!ssl3_setup_buffers(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + s->init_num = 0; + s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + /* + * Should have been reset by ssl3_get_finished, too. + */ + s->s3->change_cipher_spec = 0; + + if (s->state != SSL_ST_RENEGOTIATE) { + /* + * Ok, we now need to push on a buffering BIO so that the + * output is sent in a way that TCP likes :-) + */ + if (!ssl_init_wbio_buffer(s, 1)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ssl3_init_finished_mac(s); + s->state = SSL3_ST_SR_CLNT_HELLO_A; + s->ctx->stats.sess_accept++; + } else if (!s->s3->send_connection_binding && + !(s->options & + SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + /* + * Server attempting to renegotiate with client that doesn't + * support secure renegotiation. + */ + SSLerr(SSL_F_SSL3_ACCEPT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } else { + /* + * s->state == SSL_ST_RENEGOTIATE, we will just send a + * HelloRequest + */ + s->ctx->stats.sess_accept_renegotiate++; + s->state = SSL3_ST_SW_HELLO_REQ_A; + } + break; + + case SSL3_ST_SW_HELLO_REQ_A: + case SSL3_ST_SW_HELLO_REQ_B: + + s->shutdown = 0; + ret = ssl3_send_hello_request(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + + ssl3_init_finished_mac(s); + break; + + case SSL3_ST_SW_HELLO_REQ_C: + s->state = SSL_ST_OK; + break; + + case SSL3_ST_SR_CLNT_HELLO_A: + case SSL3_ST_SR_CLNT_HELLO_B: + case SSL3_ST_SR_CLNT_HELLO_C: + + s->shutdown = 0; + ret = ssl3_get_client_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_SRP + s->state = SSL3_ST_SR_CLNT_HELLO_D; + case SSL3_ST_SR_CLNT_HELLO_D: + { + int al; + if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { + /* + * callback indicates firther work to be done + */ + s->rwstate = SSL_X509_LOOKUP; + goto end; + } + if (ret != SSL_ERROR_NONE) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + /* + * This is not really an error but the only means to for + * a client to detect whether srp is supported. + */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + } +#endif + + s->renegotiate = 2; + s->state = SSL3_ST_SW_SRVR_HELLO_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_SRVR_HELLO_A: + case SSL3_ST_SW_SRVR_HELLO_B: + ret = ssl3_send_server_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->hit) { + if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; + else + s->state = SSL3_ST_SW_CHANGE_A; + } +#else + if (s->hit) + s->state = SSL3_ST_SW_CHANGE_A; +#endif + else + s->state = SSL3_ST_SW_CERT_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_A: + case SSL3_ST_SW_CERT_B: + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or KRB5 or SRP */ + if (! + (s->s3->tmp. + new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 | + SSL_aSRP)) +&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + ret = ssl3_send_server_certificate(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->tlsext_status_expected) + s->state = SSL3_ST_SW_CERT_STATUS_A; + else + s->state = SSL3_ST_SW_KEY_EXCH_A; + } else { + skip = 1; + s->state = SSL3_ST_SW_KEY_EXCH_A; + } +#else + } else + skip = 1; + + s->state = SSL3_ST_SW_KEY_EXCH_A; +#endif + s->init_num = 0; + break; + + case SSL3_ST_SW_KEY_EXCH_A: + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * clear this, it may get reset by + * send_server_key_exchange + */ + s->s3->tmp.use_rsa_tmp = 0; + + /* + * only send if a DH key exchange, fortezza or RSA but we have a + * sign only certificate PSK: may send PSK identity hints For + * ECC ciphersuites, we send a serverKeyExchange message only if + * the cipher suite is either ECDH-anon or ECDHE. In other cases, + * the server certificate contains the server's public key for + * key exchange. + */ + if (0 + /* + * PSK: send ServerKeyExchange if PSK identity hint if + * provided + */ +#ifndef OPENSSL_NO_PSK + || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + || (alg_k & SSL_kEDH) + || (alg_k & SSL_kEECDH) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys + [SSL_PKEY_RSA_ENC].privatekey) * + 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + ) { + ret = ssl3_send_server_key_exchange(s); + if (ret <= 0) + goto end; + } else + skip = 1; + + s->state = SSL3_ST_SW_CERT_REQ_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_REQ_A: + case SSL3_ST_SW_CERT_REQ_B: + if ( /* don't request cert unless asked for it: */ + !(s->verify_mode & SSL_VERIFY_PEER) || + /* + * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert + * during re-negotiation: + */ + ((s->session->peer != NULL) && + (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || + /* + * never request cert in anonymous ciphersuites (see + * section ""Certificate request"" in SSL 3 drafts and in + * RFC 2246): + */ + ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + /* + * ... except when the application insists on + * verification (against the specs, but s3_clnt.c accepts + * this for SSL 3) + */ + !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || + /* + * never request cert in Kerberos ciphersuites + */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* + * With normal PSK Certificates and Certificate Requests + * are omitted + */ + || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + /* no cert request */ + skip = 1; + s->s3->tmp.cert_request = 0; + s->state = SSL3_ST_SW_SRVR_DONE_A; + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + } else { + s->s3->tmp.cert_request = 1; + ret = ssl3_send_certificate_request(s); + if (ret <= 0) + goto end; +#ifndef NETSCAPE_HANG_BUG + s->state = SSL3_ST_SW_SRVR_DONE_A; +#else + s->state = SSL3_ST_SW_FLUSH; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; +#endif + s->init_num = 0; + } + break; + + case SSL3_ST_SW_SRVR_DONE_A: + case SSL3_ST_SW_SRVR_DONE_B: + ret = ssl3_send_server_done(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + break; + + case SSL3_ST_SW_FLUSH: + + /* + * This code originally checked to see if any data was pending + * using BIO_CTRL_INFO and then flushed. This caused problems as + * documented in PR#1939. The proposed fix doesn't completely + * resolve this issue as buggy implementations of + * BIO_CTRL_PENDING still exist. So instead we just flush + * unconditionally. + */ + + s->rwstate = SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) { + ret = -1; + goto end; + } + s->rwstate = SSL_NOTHING; + + s->state = s->s3->tmp.next_state; + break; + + case SSL3_ST_SR_CERT_A: + case SSL3_ST_SR_CERT_B: + if (s->s3->tmp.cert_request) { + ret = ssl3_get_client_certificate(s); + if (ret <= 0) + goto end; + } + s->init_num = 0; + s->state = SSL3_ST_SR_KEY_EXCH_A; + break; + + case SSL3_ST_SR_KEY_EXCH_A: + case SSL3_ST_SR_KEY_EXCH_B: + ret = ssl3_get_client_key_exchange(s); + if (ret <= 0) + goto end; + if (ret == 2) { + /* + * For the ECDH ciphersuites when the client sends its ECDH + * pub key in a certificate, the CertificateVerify message is + * not sent. Also for GOST ciphersuites when the client uses + * its key from the certificate for key exchange. + */ +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + } else if (SSL_USE_SIGALGS(s)) { + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + if (!s->session->peer) + break; + /* + * For sigalgs freeze the handshake buffer at this point and + * digest cached records. + */ + if (!s->s3->handshake_buffer) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } else { + int offset = 0; + int dgst_num; + + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + + /* + * We need to get hashes here so if there is a client cert, + * it can be verified FIXME - digest processing for + * CertificateVerify should be generalized. But it is next + * step + */ + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) + if (s->s3->handshake_dgst[dgst_num]) { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s, + EVP_MD_CTX_type + (s-> + s3->handshake_dgst + [dgst_num]), + &(s->s3-> + tmp.cert_verify_md + [offset])); + dgst_size = + EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) { + s->state = SSL_ST_ERR; + ret = -1; + goto end; + } + offset += dgst_size; + } + } + break; + + case SSL3_ST_SR_CERT_VRFY_A: + case SSL3_ST_SR_CERT_VRFY_B: + ret = ssl3_get_cert_verify(s); + if (ret <= 0) + goto end; + +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + break; + +#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + case SSL3_ST_SR_NEXT_PROTO_A: + case SSL3_ST_SR_NEXT_PROTO_B: + /* + * Enable CCS for NPN. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. This *should* be the + * first time we have received one - but we check anyway to be + * cautious. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + + ret = ssl3_get_next_proto(s); + if (ret <= 0) + goto end; + s->init_num = 0; + s->state = SSL3_ST_SR_FINISHED_A; + break; +#endif + + case SSL3_ST_SR_FINISHED_A: + case SSL3_ST_SR_FINISHED_B: + /* + * Enable CCS for handshakes without NPN. In NPN the CCS flag has + * already been set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B); + if (ret <= 0) + goto end; + if (s->hit) + s->state = SSL_ST_OK; +#ifndef OPENSSL_NO_TLSEXT + else if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; +#endif + else + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + +#ifndef OPENSSL_NO_TLSEXT + case SSL3_ST_SW_SESSION_TICKET_A: + case SSL3_ST_SW_SESSION_TICKET_B: + ret = ssl3_send_newsession_ticket(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_STATUS_A: + case SSL3_ST_SW_CERT_STATUS_B: + ret = ssl3_send_cert_status(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_KEY_EXCH_A; + s->init_num = 0; + break; + +#endif + + case SSL3_ST_SW_CHANGE_A: + case SSL3_ST_SW_CHANGE_B: + + s->session->cipher = s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ret = ssl3_send_change_cipher_spec(s, + SSL3_ST_SW_CHANGE_A, + SSL3_ST_SW_CHANGE_B); + + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FINISHED_A; + s->init_num = 0; + + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) + { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + break; + + case SSL3_ST_SW_FINISHED_A: + case SSL3_ST_SW_FINISHED_B: + ret = ssl3_send_finished(s, + SSL3_ST_SW_FINISHED_A, + SSL3_ST_SW_FINISHED_B, + s->method-> + ssl3_enc->server_finished_label, + s->method-> + ssl3_enc->server_finished_label_len); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FLUSH; + if (s->hit) { +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) { + s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A; + } else + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#endif + } else + s->s3->tmp.next_state = SSL_ST_OK; + s->init_num = 0; + break; + + case SSL_ST_OK: + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + BUF_MEM_free(s->init_buf); + s->init_buf = NULL; + + /* remove buffering on output */ + ssl_free_wbio_buffer(s); + + s->init_num = 0; + + if (s->renegotiate == 2) { /* skipped if we just sent a + * HelloRequest */ + s->renegotiate = 0; + s->new_session = 0; + + ssl_update_cache(s, SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + /* s->server=1; */ + s->handshake_func = ssl3_accept; + + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_DONE, 1); + } + + ret = 1; + goto end; + /* break; */ + + case SSL_ST_ERR: + default: + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); + ret = -1; + goto end; + /* break; */ + } + + if (!s->s3->tmp.reuse_message && !skip) { + if (s->debug) { + if ((ret = BIO_flush(s->wbio)) <= 0) + goto end; + } + + if ((cb != NULL) && (s->state != state)) { + new_state = s->state; + s->state = state; + cb(s, SSL_CB_ACCEPT_LOOP, 1); + s->state = new_state; + } + } + skip = 0; + } +",0,"int ssl3_accept(SSL *s) +{ + BUF_MEM *buf; + unsigned long alg_k, Time = (unsigned long)time(NULL); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + int ret = -1; + int new_state, state, skip = 0; + + RAND_add(&Time, sizeof(Time), 0); + ERR_clear_error(); + clear_sys_error(); + + if (s->info_callback != NULL) + cb = s->info_callback; + else if (s->ctx->info_callback != NULL) + cb = s->ctx->info_callback; + + /* init things to blank */ + s->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) + SSL_clear(s); + + if (s->cert == NULL) { + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); + return (-1); + } +#ifndef OPENSSL_NO_HEARTBEATS + /* + * If we're awaiting a HeartbeatResponse, pretend we already got and + * don't await it anymore, because Heartbeats don't make sense during + * handshakes anyway. + */ + if (s->tlsext_hb_pending) { + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + for (;;) { + state = s->state; + + switch (s->state) { + case SSL_ST_RENEGOTIATE: + s->renegotiate = 1; + /* s->state=SSL_ST_ACCEPT; */ + + case SSL_ST_BEFORE: + case SSL_ST_ACCEPT: + case SSL_ST_BEFORE | SSL_ST_ACCEPT: + case SSL_ST_OK | SSL_ST_ACCEPT: + + s->server = 1; + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_START, 1); + + if ((s->version >> 8) != 3) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->type = SSL_ST_ACCEPT; + + if (s->init_buf == NULL) { + if ((buf = BUF_MEM_new()) == NULL) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { + BUF_MEM_free(buf); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + s->init_buf = buf; + } + + if (!ssl3_setup_buffers(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + s->init_num = 0; + s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; + s->s3->flags &= ~SSL3_FLAGS_CCS_OK; + /* + * Should have been reset by ssl3_get_finished, too. + */ + s->s3->change_cipher_spec = 0; + + if (s->state != SSL_ST_RENEGOTIATE) { + /* + * Ok, we now need to push on a buffering BIO so that the + * output is sent in a way that TCP likes :-) + */ + if (!ssl_init_wbio_buffer(s, 1)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ssl3_init_finished_mac(s); + s->state = SSL3_ST_SR_CLNT_HELLO_A; + s->ctx->stats.sess_accept++; + } else if (!s->s3->send_connection_binding && + !(s->options & + SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + /* + * Server attempting to renegotiate with client that doesn't + * support secure renegotiation. + */ + SSLerr(SSL_F_SSL3_ACCEPT, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } else { + /* + * s->state == SSL_ST_RENEGOTIATE, we will just send a + * HelloRequest + */ + s->ctx->stats.sess_accept_renegotiate++; + s->state = SSL3_ST_SW_HELLO_REQ_A; + } + break; + + case SSL3_ST_SW_HELLO_REQ_A: + case SSL3_ST_SW_HELLO_REQ_B: + + s->shutdown = 0; + ret = ssl3_send_hello_request(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + + ssl3_init_finished_mac(s); + break; + + case SSL3_ST_SW_HELLO_REQ_C: + s->state = SSL_ST_OK; + break; + + case SSL3_ST_SR_CLNT_HELLO_A: + case SSL3_ST_SR_CLNT_HELLO_B: + case SSL3_ST_SR_CLNT_HELLO_C: + + s->shutdown = 0; + ret = ssl3_get_client_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_SRP + s->state = SSL3_ST_SR_CLNT_HELLO_D; + case SSL3_ST_SR_CLNT_HELLO_D: + { + int al; + if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { + /* + * callback indicates firther work to be done + */ + s->rwstate = SSL_X509_LOOKUP; + goto end; + } + if (ret != SSL_ERROR_NONE) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + /* + * This is not really an error but the only means to for + * a client to detect whether srp is supported. + */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + } +#endif + + s->renegotiate = 2; + s->state = SSL3_ST_SW_SRVR_HELLO_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_SRVR_HELLO_A: + case SSL3_ST_SW_SRVR_HELLO_B: + ret = ssl3_send_server_hello(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->hit) { + if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; + else + s->state = SSL3_ST_SW_CHANGE_A; + } +#else + if (s->hit) + s->state = SSL3_ST_SW_CHANGE_A; +#endif + else + s->state = SSL3_ST_SW_CERT_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_A: + case SSL3_ST_SW_CERT_B: + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or KRB5 or SRP */ + if (! + (s->s3->tmp. + new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 | + SSL_aSRP)) +&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + ret = ssl3_send_server_certificate(s); + if (ret <= 0) + goto end; +#ifndef OPENSSL_NO_TLSEXT + if (s->tlsext_status_expected) + s->state = SSL3_ST_SW_CERT_STATUS_A; + else + s->state = SSL3_ST_SW_KEY_EXCH_A; + } else { + skip = 1; + s->state = SSL3_ST_SW_KEY_EXCH_A; + } +#else + } else + skip = 1; + + s->state = SSL3_ST_SW_KEY_EXCH_A; +#endif + s->init_num = 0; + break; + + case SSL3_ST_SW_KEY_EXCH_A: + case SSL3_ST_SW_KEY_EXCH_B: + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * clear this, it may get reset by + * send_server_key_exchange + */ + s->s3->tmp.use_rsa_tmp = 0; + + /* + * only send if a DH key exchange, fortezza or RSA but we have a + * sign only certificate PSK: may send PSK identity hints For + * ECC ciphersuites, we send a serverKeyExchange message only if + * the cipher suite is either ECDH-anon or ECDHE. In other cases, + * the server certificate contains the server's public key for + * key exchange. + */ + if (0 + /* + * PSK: send ServerKeyExchange if PSK identity hint if + * provided + */ +#ifndef OPENSSL_NO_PSK + || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + || (alg_k & SSL_kEDH) + || (alg_k & SSL_kEECDH) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys + [SSL_PKEY_RSA_ENC].privatekey) * + 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + ) { + ret = ssl3_send_server_key_exchange(s); + if (ret <= 0) + goto end; + } else + skip = 1; + + s->state = SSL3_ST_SW_CERT_REQ_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_REQ_A: + case SSL3_ST_SW_CERT_REQ_B: + if ( /* don't request cert unless asked for it: */ + !(s->verify_mode & SSL_VERIFY_PEER) || + /* + * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert + * during re-negotiation: + */ + ((s->session->peer != NULL) && + (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || + /* + * never request cert in anonymous ciphersuites (see + * section ""Certificate request"" in SSL 3 drafts and in + * RFC 2246): + */ + ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && + /* + * ... except when the application insists on + * verification (against the specs, but s3_clnt.c accepts + * this for SSL 3) + */ + !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || + /* + * never request cert in Kerberos ciphersuites + */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || + /* don't request certificate for SRP auth */ + (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* + * With normal PSK Certificates and Certificate Requests + * are omitted + */ + || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + /* no cert request */ + skip = 1; + s->s3->tmp.cert_request = 0; + s->state = SSL3_ST_SW_SRVR_DONE_A; + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + } else { + s->s3->tmp.cert_request = 1; + ret = ssl3_send_certificate_request(s); + if (ret <= 0) + goto end; +#ifndef NETSCAPE_HANG_BUG + s->state = SSL3_ST_SW_SRVR_DONE_A; +#else + s->state = SSL3_ST_SW_FLUSH; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; +#endif + s->init_num = 0; + } + break; + + case SSL3_ST_SW_SRVR_DONE_A: + case SSL3_ST_SW_SRVR_DONE_B: + ret = ssl3_send_server_done(s); + if (ret <= 0) + goto end; + s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; + s->state = SSL3_ST_SW_FLUSH; + s->init_num = 0; + break; + + case SSL3_ST_SW_FLUSH: + + /* + * This code originally checked to see if any data was pending + * using BIO_CTRL_INFO and then flushed. This caused problems as + * documented in PR#1939. The proposed fix doesn't completely + * resolve this issue as buggy implementations of + * BIO_CTRL_PENDING still exist. So instead we just flush + * unconditionally. + */ + + s->rwstate = SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) { + ret = -1; + goto end; + } + s->rwstate = SSL_NOTHING; + + s->state = s->s3->tmp.next_state; + break; + + case SSL3_ST_SR_CERT_A: + case SSL3_ST_SR_CERT_B: + if (s->s3->tmp.cert_request) { + ret = ssl3_get_client_certificate(s); + if (ret <= 0) + goto end; + } + s->init_num = 0; + s->state = SSL3_ST_SR_KEY_EXCH_A; + break; + + case SSL3_ST_SR_KEY_EXCH_A: + case SSL3_ST_SR_KEY_EXCH_B: + ret = ssl3_get_client_key_exchange(s); + if (ret <= 0) + goto end; + if (ret == 2) { + /* + * For the ECDH ciphersuites when the client sends its ECDH + * pub key in a certificate, the CertificateVerify message is + * not sent. Also for GOST ciphersuites when the client uses + * its key from the certificate for key exchange. + */ +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + } else if (SSL_USE_SIGALGS(s)) { + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + if (!s->session->peer) + break; + /* + * For sigalgs freeze the handshake buffer at this point and + * digest cached records. + */ + if (!s->s3->handshake_buffer) { + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + s->state = SSL_ST_ERR; + return -1; + } + s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } else { + int offset = 0; + int dgst_num; + + s->state = SSL3_ST_SR_CERT_VRFY_A; + s->init_num = 0; + + /* + * We need to get hashes here so if there is a client cert, + * it can be verified FIXME - digest processing for + * CertificateVerify should be generalized. But it is next + * step + */ + if (s->s3->handshake_buffer) { + if (!ssl3_digest_cached_records(s)) { + s->state = SSL_ST_ERR; + return -1; + } + } + for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) + if (s->s3->handshake_dgst[dgst_num]) { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s, + EVP_MD_CTX_type + (s-> + s3->handshake_dgst + [dgst_num]), + &(s->s3-> + tmp.cert_verify_md + [offset])); + dgst_size = + EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) { + s->state = SSL_ST_ERR; + ret = -1; + goto end; + } + offset += dgst_size; + } + } + break; + + case SSL3_ST_SR_CERT_VRFY_A: + case SSL3_ST_SR_CERT_VRFY_B: + ret = ssl3_get_cert_verify(s); + if (ret <= 0) + goto end; + +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) + s->state = SSL3_ST_SR_NEXT_PROTO_A; + else + s->state = SSL3_ST_SR_FINISHED_A; +#endif + s->init_num = 0; + break; + +#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + case SSL3_ST_SR_NEXT_PROTO_A: + case SSL3_ST_SR_NEXT_PROTO_B: + /* + * Enable CCS for NPN. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. This *should* be the + * first time we have received one - but we check anyway to be + * cautious. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + + ret = ssl3_get_next_proto(s); + if (ret <= 0) + goto end; + s->init_num = 0; + s->state = SSL3_ST_SR_FINISHED_A; + break; +#endif + + case SSL3_ST_SR_FINISHED_A: + case SSL3_ST_SR_FINISHED_B: + /* + * Enable CCS for handshakes without NPN. In NPN the CCS flag has + * already been set. Receiving a CCS clears the flag, so make + * sure not to re-enable it to ban duplicates. + * s->s3->change_cipher_spec is set when a CCS is + * processed in s3_pkt.c, and remains set until + * the client's Finished message is read. + */ + if (!s->s3->change_cipher_spec) + s->s3->flags |= SSL3_FLAGS_CCS_OK; + ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B); + if (ret <= 0) + goto end; + if (s->hit) + s->state = SSL_ST_OK; +#ifndef OPENSSL_NO_TLSEXT + else if (s->tlsext_ticket_expected) + s->state = SSL3_ST_SW_SESSION_TICKET_A; +#endif + else + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + +#ifndef OPENSSL_NO_TLSEXT + case SSL3_ST_SW_SESSION_TICKET_A: + case SSL3_ST_SW_SESSION_TICKET_B: + ret = ssl3_send_newsession_ticket(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_CHANGE_A; + s->init_num = 0; + break; + + case SSL3_ST_SW_CERT_STATUS_A: + case SSL3_ST_SW_CERT_STATUS_B: + ret = ssl3_send_cert_status(s); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_KEY_EXCH_A; + s->init_num = 0; + break; + +#endif + + case SSL3_ST_SW_CHANGE_A: + case SSL3_ST_SW_CHANGE_B: + + s->session->cipher = s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + ret = ssl3_send_change_cipher_spec(s, + SSL3_ST_SW_CHANGE_A, + SSL3_ST_SW_CHANGE_B); + + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FINISHED_A; + s->init_num = 0; + + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) + { + ret = -1; + s->state = SSL_ST_ERR; + goto end; + } + + break; + + case SSL3_ST_SW_FINISHED_A: + case SSL3_ST_SW_FINISHED_B: + ret = ssl3_send_finished(s, + SSL3_ST_SW_FINISHED_A, + SSL3_ST_SW_FINISHED_B, + s->method-> + ssl3_enc->server_finished_label, + s->method-> + ssl3_enc->server_finished_label_len); + if (ret <= 0) + goto end; + s->state = SSL3_ST_SW_FLUSH; + if (s->hit) { +#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#else + if (s->s3->next_proto_neg_seen) { + s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A; + } else + s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; +#endif + } else + s->s3->tmp.next_state = SSL_ST_OK; + s->init_num = 0; + break; + + case SSL_ST_OK: + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + BUF_MEM_free(s->init_buf); + s->init_buf = NULL; + + /* remove buffering on output */ + ssl_free_wbio_buffer(s); + + s->init_num = 0; + + if (s->renegotiate == 2) { /* skipped if we just sent a + * HelloRequest */ + s->renegotiate = 0; + s->new_session = 0; + + ssl_update_cache(s, SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + /* s->server=1; */ + s->handshake_func = ssl3_accept; + + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_DONE, 1); + } + + ret = 1; + goto end; + /* break; */ + + case SSL_ST_ERR: + default: + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); + ret = -1; + goto end; + /* break; */ + } + + if (!s->s3->tmp.reuse_message && !skip) { + if (s->debug) { + if ((ret = BIO_flush(s->wbio)) <= 0) + goto end; + } + + if ((cb != NULL) && (s->state != state)) { + new_state = s->state; + s->state = state; + cb(s, SSL_CB_ACCEPT_LOOP, 1); + s->state = new_state; + } + } + skip = 0; + } +","@@ -980,7 +980,7 @@ int ssl3_get_client_hello(SSL *s) + + session_length = *(p + SSL3_RANDOM_SIZE); + +- if (p + SSL3_RANDOM_SIZE + session_length + 1 >= d + n) { ++ if (SSL3_RANDOM_SIZE + session_length + 1 >= (d + n) - p) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -998,7 +998,7 @@ int ssl3_get_client_hello(SSL *s) + /* get the session-id */ + j = *(p++); + +- if (p + j > d + n) { ++ if ((d + n) - p < j) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -1054,14 +1054,14 @@ int ssl3_get_client_hello(SSL *s) + + if (SSL_IS_DTLS(s)) { + /* cookie stuff */ +- if (p + 1 > d + n) { ++ if ((d + n) - p < 1) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + cookie_len = *(p++); + +- if (p + cookie_len > d + n) { ++ if ((d + n ) - p < cookie_len) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -1131,7 +1131,7 @@ int ssl3_get_client_hello(SSL *s) + } + } + +- if (p + 2 > d + n) { ++ if ((d + n ) - p < 2) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -1145,7 +1145,7 @@ int ssl3_get_client_hello(SSL *s) + } + + /* i bytes of cipher data + 1 byte for compression length later */ +- if ((p + i + 1) > (d + n)) { ++ if ((d + n) - p < i + 1) { + /* not enough data */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); +@@ -1211,7 +1211,7 @@ int ssl3_get_client_hello(SSL *s) + + /* compression */ + i = *(p++); +- if ((p + i) > (d + n)) { ++ if ((d + n) - p < i) { + /* not enough data */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH);",5283,5519,6144 +18627,"EnumTraits::ToMojom( + media::VideoCaptureError input) { + switch (input) { + case media::VideoCaptureError::kNone: + return media::mojom::VideoCaptureError::kNone; + case media::VideoCaptureError:: + kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested: + return media::mojom::VideoCaptureError:: + kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested; + case media::VideoCaptureError::kVideoCaptureControllerIsAlreadyInErrorState: + return media::mojom::VideoCaptureError:: + kVideoCaptureControllerIsAlreadyInErrorState; + case media::VideoCaptureError::kVideoCaptureManagerDeviceConnectionLost: + return media::mojom::VideoCaptureError:: + kVideoCaptureManagerDeviceConnectionLost; + case media::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError: + return media::mojom::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError; + case media::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceEncounteredFatalError: + return media::mojom::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceEncounteredFatalError; + case media::VideoCaptureError::kV4L2FailedToOpenV4L2DeviceDriverFile: + return media::mojom::VideoCaptureError:: + kV4L2FailedToOpenV4L2DeviceDriverFile; + case media::VideoCaptureError::kV4L2ThisIsNotAV4L2VideoCaptureDevice: + return media::mojom::VideoCaptureError:: + kV4L2ThisIsNotAV4L2VideoCaptureDevice; + case media::VideoCaptureError::kV4L2FailedToFindASupportedCameraFormat: + return media::mojom::VideoCaptureError:: + kV4L2FailedToFindASupportedCameraFormat; + case media::VideoCaptureError::kV4L2FailedToSetVideoCaptureFormat: + return media::mojom::VideoCaptureError:: + kV4L2FailedToSetVideoCaptureFormat; + case media::VideoCaptureError::kV4L2UnsupportedPixelFormat: + return media::mojom::VideoCaptureError::kV4L2UnsupportedPixelFormat; + case media::VideoCaptureError::kV4L2FailedToSetCameraFramerate: + return media::mojom::VideoCaptureError::kV4L2FailedToSetCameraFramerate; + case media::VideoCaptureError::kV4L2ErrorRequestingMmapBuffers: + return media::mojom::VideoCaptureError::kV4L2ErrorRequestingMmapBuffers; + case media::VideoCaptureError::kV4L2AllocateBufferFailed: + return media::mojom::VideoCaptureError::kV4L2AllocateBufferFailed; + case media::VideoCaptureError::kV4L2VidiocStreamonFailed: + return media::mojom::VideoCaptureError::kV4L2VidiocStreamonFailed; + case media::VideoCaptureError::kV4L2VidiocStreamoffFailed: + return media::mojom::VideoCaptureError::kV4L2VidiocStreamoffFailed; + case media::VideoCaptureError::kV4L2FailedToVidiocReqbufsWithCount0: + return media::mojom::VideoCaptureError:: + kV4L2FailedToVidiocReqbufsWithCount0; + case media::VideoCaptureError::kV4L2PollFailed: + return media::mojom::VideoCaptureError::kV4L2PollFailed; + case media::VideoCaptureError:: + kV4L2MultipleContinuousTimeoutsWhileReadPolling: + return media::mojom::VideoCaptureError:: + kV4L2MultipleContinuousTimeoutsWhileReadPolling; + case media::VideoCaptureError::kV4L2FailedToDequeueCaptureBuffer: + return media::mojom::VideoCaptureError::kV4L2FailedToDequeueCaptureBuffer; + case media::VideoCaptureError::kV4L2FailedToEnqueueCaptureBuffer: + return media::mojom::VideoCaptureError::kV4L2FailedToEnqueueCaptureBuffer; + case media::VideoCaptureError:: + kSingleClientVideoCaptureHostLostConnectionToDevice: + return media::mojom::VideoCaptureError:: + kSingleClientVideoCaptureHostLostConnectionToDevice; + case media::VideoCaptureError::kSingleClientVideoCaptureDeviceLaunchAborted: + return media::mojom::VideoCaptureError:: + kSingleClientVideoCaptureDeviceLaunchAborted; + case media::VideoCaptureError:: + kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed: + return media::mojom::VideoCaptureError:: + kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed; + case media::VideoCaptureError::kFileVideoCaptureDeviceCouldNotOpenVideoFile: + return media::mojom::VideoCaptureError:: + kFileVideoCaptureDeviceCouldNotOpenVideoFile; + case media::VideoCaptureError:: + kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate: + return media::mojom::VideoCaptureError:: + kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate; + case media::VideoCaptureError:: + kErrorFakeDeviceIntentionallyEmittingErrorEvent: + return media::mojom::VideoCaptureError:: + kErrorFakeDeviceIntentionallyEmittingErrorEvent; + case media::VideoCaptureError::kDeviceClientTooManyFramesDroppedY16: + return media::mojom::VideoCaptureError:: + kDeviceClientTooManyFramesDroppedY16; + case media::VideoCaptureError:: + kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType: + return media::mojom::VideoCaptureError:: + kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType; + case media::VideoCaptureError:: + kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound: + return media::mojom::VideoCaptureError:: + kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound; + case media::VideoCaptureError:: + kInProcessDeviceLauncherFailedToCreateDeviceInstance: + return media::mojom::VideoCaptureError:: + kInProcessDeviceLauncherFailedToCreateDeviceInstance; + case media::VideoCaptureError:: + kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart: + return media::mojom::VideoCaptureError:: + kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart; + case media::VideoCaptureError:: + kServiceDeviceLauncherServiceRespondedWithDeviceNotFound: + return media::mojom::VideoCaptureError:: + kServiceDeviceLauncherServiceRespondedWithDeviceNotFound; + case media::VideoCaptureError:: + kServiceDeviceLauncherConnectionLostWhileWaitingForCallback: + return media::mojom::VideoCaptureError:: + kServiceDeviceLauncherConnectionLostWhileWaitingForCallback; + case media::VideoCaptureError::kIntentionalErrorRaisedByUnitTest: + return media::mojom::VideoCaptureError::kIntentionalErrorRaisedByUnitTest; + case media::VideoCaptureError::kCrosHalV3FailedToStartDeviceThread: + return media::mojom::VideoCaptureError:: + kCrosHalV3FailedToStartDeviceThread; + case media::VideoCaptureError::kCrosHalV3DeviceDelegateMojoConnectionError: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateMojoConnectionError; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetCameraInfo: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetCameraInfo; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateMissingSensorOrientationInfo: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateMissingSensorOrientationInfo; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToOpenCameraDevice: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToOpenCameraDevice; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToConfigureStreams: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToConfigureStreams; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerHalRequestedTooManyBuffers: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerHalRequestedTooManyBuffers; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerUnsupportedVideoPixelFormat: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerUnsupportedVideoPixelFormat; + case media::VideoCaptureError::kCrosHalV3BufferManagerFailedToDupFd: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToDupFd; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToRegisterBuffer: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToRegisterBuffer; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerProcessCaptureRequestFailed: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerProcessCaptureRequestFailed; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidPendingResultId: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidPendingResultId; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedInvalidShutterTime: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedInvalidShutterTime; + case media::VideoCaptureError::kCrosHalV3BufferManagerFatalDeviceError: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFatalDeviceError; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut; + case media::VideoCaptureError::kCrosHalV3BufferManagerInvalidJpegBlob: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidJpegBlob; + case media::VideoCaptureError::kAndroidFailedToAllocate: + return media::mojom::VideoCaptureError::kAndroidFailedToAllocate; + case media::VideoCaptureError::kAndroidFailedToStartCapture: + return media::mojom::VideoCaptureError::kAndroidFailedToStartCapture; + case media::VideoCaptureError::kAndroidFailedToStopCapture: + return media::mojom::VideoCaptureError::kAndroidFailedToStopCapture; + case media::VideoCaptureError::kAndroidApi1CameraErrorCallbackReceived: + return media::mojom::VideoCaptureError:: + kAndroidApi1CameraErrorCallbackReceived; + case media::VideoCaptureError::kAndroidApi2CameraDeviceErrorReceived: + return media::mojom::VideoCaptureError:: + kAndroidApi2CameraDeviceErrorReceived; + case media::VideoCaptureError::kAndroidApi2CaptureSessionConfigureFailed: + return media::mojom::VideoCaptureError:: + kAndroidApi2CaptureSessionConfigureFailed; + case media::VideoCaptureError::kAndroidApi2ImageReaderUnexpectedImageFormat: + return media::mojom::VideoCaptureError:: + kAndroidApi2ImageReaderUnexpectedImageFormat; + case media::VideoCaptureError:: + kAndroidApi2ImageReaderSizeDidNotMatchImageSize: + return media::mojom::VideoCaptureError:: + kAndroidApi2ImageReaderSizeDidNotMatchImageSize; + case media::VideoCaptureError::kAndroidApi2ErrorRestartingPreview: + return media::mojom::VideoCaptureError:: + kAndroidApi2ErrorRestartingPreview; + case media::VideoCaptureError::kAndroidScreenCaptureUnsupportedFormat: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureUnsupportedFormat; + case media::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartCaptureMachine: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartCaptureMachine; + case media::VideoCaptureError:: + kAndroidScreenCaptureTheUserDeniedScreenCapture: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureTheUserDeniedScreenCapture; + case media::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartScreenCapture: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartScreenCapture; + case media::VideoCaptureError::kWinDirectShowCantGetCaptureFormatSettings: + return media::mojom::VideoCaptureError:: + kWinDirectShowCantGetCaptureFormatSettings; + case media::VideoCaptureError:: + kWinDirectShowFailedToGetNumberOfCapabilities: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToGetNumberOfCapabilities; + case media::VideoCaptureError:: + kWinDirectShowFailedToGetCaptureDeviceCapabilities: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToGetCaptureDeviceCapabilities; + case media::VideoCaptureError:: + kWinDirectShowFailedToSetCaptureDeviceOutputFormat: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToSetCaptureDeviceOutputFormat; + case media::VideoCaptureError::kWinDirectShowFailedToConnectTheCaptureGraph: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToConnectTheCaptureGraph; + case media::VideoCaptureError::kWinDirectShowFailedToPauseTheCaptureDevice: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToPauseTheCaptureDevice; + case media::VideoCaptureError::kWinDirectShowFailedToStartTheCaptureDevice: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToStartTheCaptureDevice; + case media::VideoCaptureError::kWinDirectShowFailedToStopTheCaptureGraph: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToStopTheCaptureGraph; + case media::VideoCaptureError::kWinMediaFoundationEngineIsNull: + return media::mojom::VideoCaptureError::kWinMediaFoundationEngineIsNull; + case media::VideoCaptureError::kWinMediaFoundationEngineGetSourceFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationEngineGetSourceFailed; + case media::VideoCaptureError:: + kWinMediaFoundationFillPhotoCapabilitiesFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationFillPhotoCapabilitiesFailed; + case media::VideoCaptureError:: + kWinMediaFoundationFillVideoCapabilitiesFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationFillVideoCapabilitiesFailed; + case media::VideoCaptureError::kWinMediaFoundationNoVideoCapabilityFound: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationNoVideoCapabilityFound; + case media::VideoCaptureError:: + kWinMediaFoundationGetAvailableDeviceMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationGetAvailableDeviceMediaTypeFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSetCurrentDeviceMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSetCurrentDeviceMediaTypeFailed; + case media::VideoCaptureError::kWinMediaFoundationEngineGetSinkFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationEngineGetSinkFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSinkRemoveAllStreamsFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkRemoveAllStreamsFailed; + case media::VideoCaptureError:: + kWinMediaFoundationCreateSinkVideoMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationCreateSinkVideoMediaTypeFailed; + case media::VideoCaptureError:: + kWinMediaFoundationConvertToVideoSinkMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationConvertToVideoSinkMediaTypeFailed; + case media::VideoCaptureError::kWinMediaFoundationSinkAddStreamFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkAddStreamFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSinkSetSampleCallbackFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkSetSampleCallbackFailed; + case media::VideoCaptureError::kWinMediaFoundationEngineStartPreviewFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationEngineStartPreviewFailed; + case media::VideoCaptureError::kWinMediaFoundationGetMediaEventStatusFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationGetMediaEventStatusFailed; + case media::VideoCaptureError::kMacSetCaptureDeviceFailed: + return media::mojom::VideoCaptureError::kMacSetCaptureDeviceFailed; + case media::VideoCaptureError::kMacCouldNotStartCaptureDevice: + return media::mojom::VideoCaptureError::kMacCouldNotStartCaptureDevice; + case media::VideoCaptureError::kMacReceivedFrameWithUnexpectedResolution: + return media::mojom::VideoCaptureError:: + kMacReceivedFrameWithUnexpectedResolution; + case media::VideoCaptureError::kMacUpdateCaptureResolutionFailed: + return media::mojom::VideoCaptureError::kMacUpdateCaptureResolutionFailed; + case media::VideoCaptureError::kMacDeckLinkDeviceIdNotFoundInTheSystem: + return media::mojom::VideoCaptureError:: + kMacDeckLinkDeviceIdNotFoundInTheSystem; + case media::VideoCaptureError::kMacDeckLinkErrorQueryingInputInterface: + return media::mojom::VideoCaptureError:: + kMacDeckLinkErrorQueryingInputInterface; + case media::VideoCaptureError::kMacDeckLinkErrorCreatingDisplayModeIterator: + return media::mojom::VideoCaptureError:: + kMacDeckLinkErrorCreatingDisplayModeIterator; + case media::VideoCaptureError::kMacDeckLinkCouldNotFindADisplayMode: + return media::mojom::VideoCaptureError:: + kMacDeckLinkCouldNotFindADisplayMode; + case media::VideoCaptureError:: + kMacDeckLinkCouldNotSelectTheVideoFormatWeLike: + return media::mojom::VideoCaptureError:: + kMacDeckLinkCouldNotSelectTheVideoFormatWeLike; + case media::VideoCaptureError::kMacDeckLinkCouldNotStartCapturing: + return media::mojom::VideoCaptureError:: + kMacDeckLinkCouldNotStartCapturing; + case media::VideoCaptureError::kMacDeckLinkUnsupportedPixelFormat: + return media::mojom::VideoCaptureError:: + kMacDeckLinkUnsupportedPixelFormat; + case media::VideoCaptureError:: + kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification: + return media::mojom::VideoCaptureError:: + kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification; + case media::VideoCaptureError::kAndroidApi2ErrorConfiguringCamera: + return media::mojom::VideoCaptureError:: + kAndroidApi2ErrorConfiguringCamera; + case media::VideoCaptureError::kCrosHalV3DeviceDelegateFailedToFlush: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToFlush; + } + NOTREACHED(); + return media::mojom::VideoCaptureError::kNone; +} +",1,"EnumTraits::ToMojom( + media::VideoCaptureError input) { + switch (input) { + case media::VideoCaptureError::kNone: + return media::mojom::VideoCaptureError::kNone; + case media::VideoCaptureError:: + kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested: + return media::mojom::VideoCaptureError:: + kVideoCaptureControllerInvalidOrUnsupportedVideoCaptureParametersRequested; + case media::VideoCaptureError::kVideoCaptureControllerIsAlreadyInErrorState: + return media::mojom::VideoCaptureError:: + kVideoCaptureControllerIsAlreadyInErrorState; + case media::VideoCaptureError::kVideoCaptureManagerDeviceConnectionLost: + return media::mojom::VideoCaptureError:: + kVideoCaptureManagerDeviceConnectionLost; + case media::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError: + return media::mojom::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceAleradyEndedOnFatalError; + case media::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceEncounteredFatalError: + return media::mojom::VideoCaptureError:: + kFrameSinkVideoCaptureDeviceEncounteredFatalError; + case media::VideoCaptureError::kV4L2FailedToOpenV4L2DeviceDriverFile: + return media::mojom::VideoCaptureError:: + kV4L2FailedToOpenV4L2DeviceDriverFile; + case media::VideoCaptureError::kV4L2ThisIsNotAV4L2VideoCaptureDevice: + return media::mojom::VideoCaptureError:: + kV4L2ThisIsNotAV4L2VideoCaptureDevice; + case media::VideoCaptureError::kV4L2FailedToFindASupportedCameraFormat: + return media::mojom::VideoCaptureError:: + kV4L2FailedToFindASupportedCameraFormat; + case media::VideoCaptureError::kV4L2FailedToSetVideoCaptureFormat: + return media::mojom::VideoCaptureError:: + kV4L2FailedToSetVideoCaptureFormat; + case media::VideoCaptureError::kV4L2UnsupportedPixelFormat: + return media::mojom::VideoCaptureError::kV4L2UnsupportedPixelFormat; + case media::VideoCaptureError::kV4L2FailedToSetCameraFramerate: + return media::mojom::VideoCaptureError::kV4L2FailedToSetCameraFramerate; + case media::VideoCaptureError::kV4L2ErrorRequestingMmapBuffers: + return media::mojom::VideoCaptureError::kV4L2ErrorRequestingMmapBuffers; + case media::VideoCaptureError::kV4L2AllocateBufferFailed: + return media::mojom::VideoCaptureError::kV4L2AllocateBufferFailed; + case media::VideoCaptureError::kV4L2VidiocStreamonFailed: + return media::mojom::VideoCaptureError::kV4L2VidiocStreamonFailed; + case media::VideoCaptureError::kV4L2VidiocStreamoffFailed: + return media::mojom::VideoCaptureError::kV4L2VidiocStreamoffFailed; + case media::VideoCaptureError::kV4L2FailedToVidiocReqbufsWithCount0: + return media::mojom::VideoCaptureError:: + kV4L2FailedToVidiocReqbufsWithCount0; + case media::VideoCaptureError::kV4L2PollFailed: + return media::mojom::VideoCaptureError::kV4L2PollFailed; + case media::VideoCaptureError:: + kV4L2MultipleContinuousTimeoutsWhileReadPolling: + return media::mojom::VideoCaptureError:: + kV4L2MultipleContinuousTimeoutsWhileReadPolling; + case media::VideoCaptureError::kV4L2FailedToDequeueCaptureBuffer: + return media::mojom::VideoCaptureError::kV4L2FailedToDequeueCaptureBuffer; + case media::VideoCaptureError::kV4L2FailedToEnqueueCaptureBuffer: + return media::mojom::VideoCaptureError::kV4L2FailedToEnqueueCaptureBuffer; + case media::VideoCaptureError:: + kSingleClientVideoCaptureHostLostConnectionToDevice: + return media::mojom::VideoCaptureError:: + kSingleClientVideoCaptureHostLostConnectionToDevice; + case media::VideoCaptureError::kSingleClientVideoCaptureDeviceLaunchAborted: + return media::mojom::VideoCaptureError:: + kSingleClientVideoCaptureDeviceLaunchAborted; + case media::VideoCaptureError:: + kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed: + return media::mojom::VideoCaptureError:: + kDesktopCaptureDeviceWebrtcDesktopCapturerHasFailed; + case media::VideoCaptureError::kFileVideoCaptureDeviceCouldNotOpenVideoFile: + return media::mojom::VideoCaptureError:: + kFileVideoCaptureDeviceCouldNotOpenVideoFile; + case media::VideoCaptureError:: + kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate: + return media::mojom::VideoCaptureError:: + kDeviceCaptureLinuxFailedToCreateVideoCaptureDelegate; + case media::VideoCaptureError:: + kErrorFakeDeviceIntentionallyEmittingErrorEvent: + return media::mojom::VideoCaptureError:: + kErrorFakeDeviceIntentionallyEmittingErrorEvent; + case media::VideoCaptureError::kDeviceClientTooManyFramesDroppedY16: + return media::mojom::VideoCaptureError:: + kDeviceClientTooManyFramesDroppedY16; + case media::VideoCaptureError:: + kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType: + return media::mojom::VideoCaptureError:: + kDeviceMediaToMojoAdapterEncounteredUnsupportedBufferType; + case media::VideoCaptureError:: + kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound: + return media::mojom::VideoCaptureError:: + kVideoCaptureManagerProcessDeviceStartQueueDeviceInfoNotFound; + case media::VideoCaptureError:: + kInProcessDeviceLauncherFailedToCreateDeviceInstance: + return media::mojom::VideoCaptureError:: + kInProcessDeviceLauncherFailedToCreateDeviceInstance; + case media::VideoCaptureError:: + kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart: + return media::mojom::VideoCaptureError:: + kServiceDeviceLauncherLostConnectionToDeviceFactoryDuringDeviceStart; + case media::VideoCaptureError:: + kServiceDeviceLauncherServiceRespondedWithDeviceNotFound: + return media::mojom::VideoCaptureError:: + kServiceDeviceLauncherServiceRespondedWithDeviceNotFound; + case media::VideoCaptureError:: + kServiceDeviceLauncherConnectionLostWhileWaitingForCallback: + return media::mojom::VideoCaptureError:: + kServiceDeviceLauncherConnectionLostWhileWaitingForCallback; + case media::VideoCaptureError::kIntentionalErrorRaisedByUnitTest: + return media::mojom::VideoCaptureError::kIntentionalErrorRaisedByUnitTest; + case media::VideoCaptureError::kCrosHalV3FailedToStartDeviceThread: + return media::mojom::VideoCaptureError:: + kCrosHalV3FailedToStartDeviceThread; + case media::VideoCaptureError::kCrosHalV3DeviceDelegateMojoConnectionError: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateMojoConnectionError; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetCameraInfo: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetCameraInfo; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateMissingSensorOrientationInfo: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateMissingSensorOrientationInfo; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToOpenCameraDevice: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToOpenCameraDevice; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToInitializeCameraDevice; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToConfigureStreams: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToConfigureStreams; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateWrongNumberOfStreamsConfigured; + case media::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings: + return media::mojom::VideoCaptureError:: + kCrosHalV3DeviceDelegateFailedToGetDefaultRequestSettings; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerHalRequestedTooManyBuffers: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerHalRequestedTooManyBuffers; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToCreateGpuMemoryBuffer; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToMapGpuMemoryBuffer; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerUnsupportedVideoPixelFormat: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerUnsupportedVideoPixelFormat; + case media::VideoCaptureError::kCrosHalV3BufferManagerFailedToDupFd: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToDupFd; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToWrapGpuMemoryHandle; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToRegisterBuffer: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToRegisterBuffer; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerProcessCaptureRequestFailed: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerProcessCaptureRequestFailed; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidPendingResultId: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidPendingResultId; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedDuplicatedPartialMetadata; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerIncorrectNumberOfOutputBuffersReceived; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidTypeOfOutputBuffersReceived; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedMultipleResultBuffersForFrame; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerUnknownStreamInCamera3NotifyMsg; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedInvalidShutterTime: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedInvalidShutterTime; + case media::VideoCaptureError::kCrosHalV3BufferManagerFatalDeviceError: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFatalDeviceError; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerReceivedFrameIsOutOfOrder; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerFailedToUnwrapReleaseFenceFd; + case media::VideoCaptureError:: + kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerSyncWaitOnReleaseFenceTimedOut; + case media::VideoCaptureError::kCrosHalV3BufferManagerInvalidJpegBlob: + return media::mojom::VideoCaptureError:: + kCrosHalV3BufferManagerInvalidJpegBlob; + case media::VideoCaptureError::kAndroidFailedToAllocate: + return media::mojom::VideoCaptureError::kAndroidFailedToAllocate; + case media::VideoCaptureError::kAndroidFailedToStartCapture: + return media::mojom::VideoCaptureError::kAndroidFailedToStartCapture; + case media::VideoCaptureError::kAndroidFailedToStopCapture: + return media::mojom::VideoCaptureError::kAndroidFailedToStopCapture; + case media::VideoCaptureError::kAndroidApi1CameraErrorCallbackReceived: + return media::mojom::VideoCaptureError:: + kAndroidApi1CameraErrorCallbackReceived; + case media::VideoCaptureError::kAndroidApi2CameraDeviceErrorReceived: + return media::mojom::VideoCaptureError:: + kAndroidApi2CameraDeviceErrorReceived; + case media::VideoCaptureError::kAndroidApi2CaptureSessionConfigureFailed: + return media::mojom::VideoCaptureError:: + kAndroidApi2CaptureSessionConfigureFailed; + case media::VideoCaptureError::kAndroidApi2ImageReaderUnexpectedImageFormat: + return media::mojom::VideoCaptureError:: + kAndroidApi2ImageReaderUnexpectedImageFormat; + case media::VideoCaptureError:: + kAndroidApi2ImageReaderSizeDidNotMatchImageSize: + return media::mojom::VideoCaptureError:: + kAndroidApi2ImageReaderSizeDidNotMatchImageSize; + case media::VideoCaptureError::kAndroidApi2ErrorRestartingPreview: + return media::mojom::VideoCaptureError:: + kAndroidApi2ErrorRestartingPreview; + case media::VideoCaptureError::kAndroidScreenCaptureUnsupportedFormat: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureUnsupportedFormat; + case media::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartCaptureMachine: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartCaptureMachine; + case media::VideoCaptureError:: + kAndroidScreenCaptureTheUserDeniedScreenCapture: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureTheUserDeniedScreenCapture; + case media::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartScreenCapture: + return media::mojom::VideoCaptureError:: + kAndroidScreenCaptureFailedToStartScreenCapture; + case media::VideoCaptureError::kWinDirectShowCantGetCaptureFormatSettings: + return media::mojom::VideoCaptureError:: + kWinDirectShowCantGetCaptureFormatSettings; + case media::VideoCaptureError:: + kWinDirectShowFailedToGetNumberOfCapabilities: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToGetNumberOfCapabilities; + case media::VideoCaptureError:: + kWinDirectShowFailedToGetCaptureDeviceCapabilities: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToGetCaptureDeviceCapabilities; + case media::VideoCaptureError:: + kWinDirectShowFailedToSetCaptureDeviceOutputFormat: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToSetCaptureDeviceOutputFormat; + case media::VideoCaptureError::kWinDirectShowFailedToConnectTheCaptureGraph: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToConnectTheCaptureGraph; + case media::VideoCaptureError::kWinDirectShowFailedToPauseTheCaptureDevice: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToPauseTheCaptureDevice; + case media::VideoCaptureError::kWinDirectShowFailedToStartTheCaptureDevice: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToStartTheCaptureDevice; + case media::VideoCaptureError::kWinDirectShowFailedToStopTheCaptureGraph: + return media::mojom::VideoCaptureError:: + kWinDirectShowFailedToStopTheCaptureGraph; + case media::VideoCaptureError::kWinMediaFoundationEngineIsNull: + return media::mojom::VideoCaptureError::kWinMediaFoundationEngineIsNull; + case media::VideoCaptureError::kWinMediaFoundationEngineGetSourceFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationEngineGetSourceFailed; + case media::VideoCaptureError:: + kWinMediaFoundationFillPhotoCapabilitiesFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationFillPhotoCapabilitiesFailed; + case media::VideoCaptureError:: + kWinMediaFoundationFillVideoCapabilitiesFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationFillVideoCapabilitiesFailed; + case media::VideoCaptureError::kWinMediaFoundationNoVideoCapabilityFound: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationNoVideoCapabilityFound; + case media::VideoCaptureError:: + kWinMediaFoundationGetAvailableDeviceMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationGetAvailableDeviceMediaTypeFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSetCurrentDeviceMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSetCurrentDeviceMediaTypeFailed; + case media::VideoCaptureError::kWinMediaFoundationEngineGetSinkFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationEngineGetSinkFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkQueryCapturePreviewInterfaceFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSinkRemoveAllStreamsFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkRemoveAllStreamsFailed; + case media::VideoCaptureError:: + kWinMediaFoundationCreateSinkVideoMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationCreateSinkVideoMediaTypeFailed; + case media::VideoCaptureError:: + kWinMediaFoundationConvertToVideoSinkMediaTypeFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationConvertToVideoSinkMediaTypeFailed; + case media::VideoCaptureError::kWinMediaFoundationSinkAddStreamFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkAddStreamFailed; + case media::VideoCaptureError:: + kWinMediaFoundationSinkSetSampleCallbackFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationSinkSetSampleCallbackFailed; + case media::VideoCaptureError::kWinMediaFoundationEngineStartPreviewFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationEngineStartPreviewFailed; + case media::VideoCaptureError::kWinMediaFoundationGetMediaEventStatusFailed: + return media::mojom::VideoCaptureError:: + kWinMediaFoundationGetMediaEventStatusFailed; + case media::VideoCaptureError::kMacSetCaptureDeviceFailed: + return media::mojom::VideoCaptureError::kMacSetCaptureDeviceFailed; + case media::VideoCaptureError::kMacCouldNotStartCaptureDevice: + return media::mojom::VideoCaptureError::kMacCouldNotStartCaptureDevice; + case media::VideoCaptureError::kMacReceivedFrameWithUnexpectedResolution: + return media::mojom::VideoCaptureError:: + kMacReceivedFrameWithUnexpectedResolution; + case media::VideoCaptureError::kMacUpdateCaptureResolutionFailed: + return media::mojom::VideoCaptureError::kMacUpdateCaptureResolutionFailed; + case media::VideoCaptureError::kMacDeckLinkDeviceIdNotFoundInTheSystem: + return media::mojom::VideoCaptureError:: + kMacDeckLinkDeviceIdNotFoundInTheSystem; + case media::VideoCaptureError::kMacDeckLinkErrorQueryingInputInterface: + return media::mojom::VideoCaptureError:: + kMacDeckLinkErrorQueryingInputInterface; + case media::VideoCaptureError::kMacDeckLinkErrorCreatingDisplayModeIterator: + return media::mojom::VideoCaptureError:: + kMacDeckLinkErrorCreatingDisplayModeIterator; + case media::VideoCaptureError::kMacDeckLinkCouldNotFindADisplayMode: + return media::mojom::VideoCaptureError:: + kMacDeckLinkCouldNotFindADisplayMode; + case media::VideoCaptureError:: + kMacDeckLinkCouldNotSelectTheVideoFormatWeLike: + return media::mojom::VideoCaptureError:: + kMacDeckLinkCouldNotSelectTheVideoFormatWeLike; + case media::VideoCaptureError::kMacDeckLinkCouldNotStartCapturing: + return media::mojom::VideoCaptureError:: + kMacDeckLinkCouldNotStartCapturing; + case media::VideoCaptureError::kMacDeckLinkUnsupportedPixelFormat: + return media::mojom::VideoCaptureError:: + kMacDeckLinkUnsupportedPixelFormat; + case media::VideoCaptureError:: + kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification: + return media::mojom::VideoCaptureError:: + kMacAvFoundationReceivedAVCaptureSessionRuntimeErrorNotification; + case media::VideoCaptureError::kAndroidApi2ErrorConfiguringCamera: + return media::mojom::VideoCaptureError:: + kAndroidApi2ErrorConfiguringCamera; + } + NOTREACHED(); + return media::mojom::VideoCaptureError::kNone; +} +","@@ -658,9 +658,6 @@ EnumTraits::ToMojom( + case media::VideoCaptureError::kAndroidApi2ErrorConfiguringCamera: + return media::mojom::VideoCaptureError:: + kAndroidApi2ErrorConfiguringCamera; +- case media::VideoCaptureError::kCrosHalV3DeviceDelegateFailedToFlush: +- return media::mojom::VideoCaptureError:: +- kCrosHalV3DeviceDelegateFailedToFlush; + } + NOTREACHED(); + return media::mojom::VideoCaptureError::kNone; +@@ -1179,9 +1176,6 @@ bool EnumTraits:: + case media::mojom::VideoCaptureError::kAndroidApi2ErrorConfiguringCamera: + *output = media::VideoCaptureError::kAndroidApi2ErrorConfiguringCamera; + return true; +- case media::mojom::VideoCaptureError::kCrosHalV3DeviceDelegateFailedToFlush: +- *output = media::VideoCaptureError::kCrosHalV3DeviceDelegateFailedToFlush; +- return true; + } + NOTREACHED(); + return false;",4885,5121,6144 +18164,"static Image *ReadICONImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + IconFile + icon_file; + + IconInfo + icon_info; + + Image + *image; + + MagickBooleanType + status; + + register IndexPacket + *indexes; + + register ssize_t + i, + x; + + register PixelPacket + *q; + + register unsigned char + *p; + + size_t + bit, + byte, + bytes_per_line, + one, + scanline_pad; + + ssize_t + count, + offset, + y; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%s"",image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + icon_file.reserved=(short) ReadBlobLSBShort(image); + icon_file.resource_type=(short) ReadBlobLSBShort(image); + icon_file.count=(short) ReadBlobLSBShort(image); + if ((icon_file.reserved != 0) || + ((icon_file.resource_type != 1) && (icon_file.resource_type != 2)) || + (icon_file.count > MaxIcons)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + for (i=0; i < icon_file.count; i++) + { + icon_file.directory[i].width=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].height=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].colors=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].reserved=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].planes=(unsigned short) ReadBlobLSBShort(image); + icon_file.directory[i].bits_per_pixel=(unsigned short) + ReadBlobLSBShort(image); + icon_file.directory[i].size=ReadBlobLSBLong(image); + icon_file.directory[i].offset=ReadBlobLSBLong(image); + } + one=1; + for (i=0; i < icon_file.count; i++) + { + /* + Verify Icon identifier. + */ + offset=(ssize_t) SeekBlob(image,(MagickOffsetType) + icon_file.directory[i].offset,SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + icon_info.size=ReadBlobLSBLong(image); + icon_info.width=(unsigned char) ((int) ReadBlobLSBLong(image)); + icon_info.height=(unsigned char) ((int) ReadBlobLSBLong(image)/2); + icon_info.planes=ReadBlobLSBShort(image); + icon_info.bits_per_pixel=ReadBlobLSBShort(image); + if (((icon_info.planes == 18505) && (icon_info.bits_per_pixel == 21060)) || + (icon_info.size == 0x474e5089)) + { + Image + *icon_image; + + ImageInfo + *read_info; + + size_t + length; + + unsigned char + *png; + + /* + Icon image encoded as a compressed PNG image. + */ + length=icon_file.directory[i].size; + png=(unsigned char *) AcquireQuantumMemory(length+16,sizeof(*png)); + if (png == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + (void) CopyMagickMemory(png,""\211PNG\r\n\032\n\000\000\000\015"",12); + png[12]=(unsigned char) icon_info.planes; + png[13]=(unsigned char) (icon_info.planes >> 8); + png[14]=(unsigned char) icon_info.bits_per_pixel; + png[15]=(unsigned char) (icon_info.bits_per_pixel >> 8); + count=ReadBlob(image,length-16,png+16); + icon_image=(Image *) NULL; + if (count > 0) + { + read_info=CloneImageInfo(image_info); + (void) CopyMagickString(read_info->magick,""PNG"",MaxTextExtent); + icon_image=BlobToImage(read_info,png,length+16,exception); + read_info=DestroyImageInfo(read_info); + } + png=(unsigned char *) RelinquishMagickMemory(png); + if (icon_image == (Image *) NULL) + { + if (count != (ssize_t) (length-16)) + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + image=DestroyImageList(image); + return((Image *) NULL); + } + DestroyBlob(icon_image); + icon_image->blob=ReferenceBlob(image->blob); + ReplaceImageInList(&image,icon_image); + icon_image->scene=i; + } + else + { + if (icon_info.bits_per_pixel > 32) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + icon_info.compression=ReadBlobLSBLong(image); + icon_info.image_size=ReadBlobLSBLong(image); + icon_info.x_pixels=ReadBlobLSBLong(image); + icon_info.y_pixels=ReadBlobLSBLong(image); + icon_info.number_colors=ReadBlobLSBLong(image); + icon_info.colors_important=ReadBlobLSBLong(image); + image->matte=MagickTrue; + image->columns=(size_t) icon_file.directory[i].width; + if ((ssize_t) image->columns > icon_info.width) + image->columns=(size_t) icon_info.width; + if (image->columns == 0) + image->columns=256; + image->rows=(size_t) icon_file.directory[i].height; + if ((ssize_t) image->rows > icon_info.height) + image->rows=(size_t) icon_info.height; + if (image->rows == 0) + image->rows=256; + image->depth=icon_info.bits_per_pixel; + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" scene = %.20g"",(double) i); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" size = %.20g"",(double) icon_info.size); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" width = %.20g"",(double) icon_file.directory[i].width); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" height = %.20g"",(double) icon_file.directory[i].height); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" colors = %.20g"",(double ) icon_info.number_colors); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" planes = %.20g"",(double) icon_info.planes); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" bpp = %.20g"",(double) icon_info.bits_per_pixel); + } + if ((icon_info.number_colors != 0) || (icon_info.bits_per_pixel <= 16U)) + { + image->storage_class=PseudoClass; + image->colors=icon_info.number_colors; + if (image->colors == 0) + image->colors=one << icon_info.bits_per_pixel; + } + if (image->storage_class == PseudoClass) + { + register ssize_t + i; + + unsigned char + *icon_colormap; + + /* + Read Icon raster colormap. + */ + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t) + image->colors,4UL*sizeof(*icon_colormap)); + if (icon_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,(size_t) (4*image->colors),icon_colormap); + if (count != (ssize_t) (4*image->colors)) + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + p=icon_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].blue=(Quantum) ScaleCharToQuantum(*p++); + image->colormap[i].green=(Quantum) ScaleCharToQuantum(*p++); + image->colormap[i].red=(Quantum) ScaleCharToQuantum(*p++); + p++; + } + icon_colormap=(unsigned char *) RelinquishMagickMemory(icon_colormap); + } + /* + Convert Icon raster image to pixel packets. + */ + if ((image_info->ping != MagickFalse) && + (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + bytes_per_line=(((image->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + (void) bytes_per_line; + scanline_pad=((((image->columns*icon_info.bits_per_pixel)+31) & ~31)- + (image->columns*icon_info.bits_per_pixel)) >> 3; + switch (icon_info.bits_per_pixel) + { + case 1: + { + /* + Convert bitmap scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < (ssize_t) (image->columns-7); x+=8) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < 8; bit++) + SetPixelIndex(indexes+x+bit,((byte & (0x80 >> bit)) != 0 ? + 0x01 : 0x00)); + } + if ((image->columns % 8) != 0) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < (image->columns % 8); bit++) + SetPixelIndex(indexes+x+bit,((byte & (0x80 >> bit)) != 0 ? + 0x01 : 0x00)); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 4: + { + /* + Read 4-bit Icon scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < ((ssize_t) image->columns-1); x+=2) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(indexes+x,((byte >> 4) & 0xf)); + SetPixelIndex(indexes+x+1,((byte) & 0xf)); + } + if ((image->columns % 2) != 0) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(indexes+x,((byte >> 4) & 0xf)); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 8: + { + /* + Convert PseudoColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < (ssize_t) image->columns; x++) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(indexes+x,byte); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 16: + { + /* + Convert PseudoColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < (ssize_t) image->columns; x++) + { + byte=(size_t) ReadBlobByte(image); + byte|=(size_t) (ReadBlobByte(image) << 8); + SetPixelIndex(indexes+x,byte); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 24: + case 32: + { + /* + Convert DirectColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + if (icon_info.bits_per_pixel == 32) + SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + q++; + } + if (icon_info.bits_per_pixel == 24) + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + default: + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (image_info->ping == MagickFalse) + (void) SyncImage(image); + if (icon_info.bits_per_pixel != 32) + { + /* + Read the ICON alpha mask. + */ + image->storage_class=DirectClass; + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < 8; bit++) + SetPixelOpacity(q+x+bit,(((byte & (0x80 >> bit)) != 0) ? + TransparentOpacity : OpaqueOpacity)); + } + if ((image->columns % 8) != 0) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < (image->columns % 8); bit++) + SetPixelOpacity(q+x+bit,(((byte & (0x80 >> bit)) != 0) ? + TransparentOpacity : OpaqueOpacity)); + } + if ((image->columns % 32) != 0) + for (x=0; x < (ssize_t) ((32-(image->columns % 32))/8); x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + } + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + break; + } + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if (i < (ssize_t) (icon_file.count-1)) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadICONImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + IconFile + icon_file; + + IconInfo + icon_info; + + Image + *image; + + MagickBooleanType + status; + + register IndexPacket + *indexes; + + register ssize_t + i, + x; + + register PixelPacket + *q; + + register unsigned char + *p; + + size_t + bit, + byte, + bytes_per_line, + one, + scanline_pad; + + ssize_t + count, + offset, + y; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""%s"",image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + icon_file.reserved=(short) ReadBlobLSBShort(image); + icon_file.resource_type=(short) ReadBlobLSBShort(image); + icon_file.count=(short) ReadBlobLSBShort(image); + if ((icon_file.reserved != 0) || + ((icon_file.resource_type != 1) && (icon_file.resource_type != 2)) || + (icon_file.count > MaxIcons)) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + for (i=0; i < icon_file.count; i++) + { + icon_file.directory[i].width=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].height=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].colors=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].reserved=(unsigned char) ReadBlobByte(image); + icon_file.directory[i].planes=(unsigned short) ReadBlobLSBShort(image); + icon_file.directory[i].bits_per_pixel=(unsigned short) + ReadBlobLSBShort(image); + icon_file.directory[i].size=ReadBlobLSBLong(image); + icon_file.directory[i].offset=ReadBlobLSBLong(image); + } + one=1; + for (i=0; i < icon_file.count; i++) + { + /* + Verify Icon identifier. + */ + offset=(ssize_t) SeekBlob(image,(MagickOffsetType) + icon_file.directory[i].offset,SEEK_SET); + if (offset < 0) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + icon_info.size=ReadBlobLSBLong(image); + icon_info.width=(unsigned char) ((int) ReadBlobLSBLong(image)); + icon_info.height=(unsigned char) ((int) ReadBlobLSBLong(image)/2); + icon_info.planes=ReadBlobLSBShort(image); + icon_info.bits_per_pixel=ReadBlobLSBShort(image); + if (((icon_info.planes == 18505) && (icon_info.bits_per_pixel == 21060)) || + (icon_info.size == 0x474e5089)) + { + Image + *icon_image; + + ImageInfo + *read_info; + + size_t + length; + + unsigned char + *png; + + /* + Icon image encoded as a compressed PNG image. + */ + length=icon_file.directory[i].size; + png=(unsigned char *) AcquireQuantumMemory(length+16,sizeof(*png)); + if (png == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + (void) CopyMagickMemory(png,""\211PNG\r\n\032\n\000\000\000\015"",12); + png[12]=(unsigned char) icon_info.planes; + png[13]=(unsigned char) (icon_info.planes >> 8); + png[14]=(unsigned char) icon_info.bits_per_pixel; + png[15]=(unsigned char) (icon_info.bits_per_pixel >> 8); + count=ReadBlob(image,length-16,png+16); + icon_image=(Image *) NULL; + if (count > 0) + { + read_info=CloneImageInfo(image_info); + (void) CopyMagickString(read_info->magick,""PNG"",MaxTextExtent); + icon_image=BlobToImage(read_info,png,length+16,exception); + read_info=DestroyImageInfo(read_info); + } + png=(unsigned char *) RelinquishMagickMemory(png); + if (icon_image == (Image *) NULL) + { + if (count != (ssize_t) (length-16)) + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + image=DestroyImageList(image); + return((Image *) NULL); + } + DestroyBlob(icon_image); + icon_image->blob=ReferenceBlob(image->blob); + ReplaceImageInList(&image,icon_image); + icon_image->scene=i; + } + else + { + if (icon_info.bits_per_pixel > 32) + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + icon_info.compression=ReadBlobLSBLong(image); + icon_info.image_size=ReadBlobLSBLong(image); + icon_info.x_pixels=ReadBlobLSBLong(image); + icon_info.y_pixels=ReadBlobLSBLong(image); + icon_info.number_colors=ReadBlobLSBLong(image); + icon_info.colors_important=ReadBlobLSBLong(image); + image->matte=MagickTrue; + image->columns=(size_t) icon_file.directory[i].width; + if ((ssize_t) image->columns > icon_info.width) + image->columns=(size_t) icon_info.width; + if (image->columns == 0) + image->columns=256; + image->rows=(size_t) icon_file.directory[i].height; + if ((ssize_t) image->rows > icon_info.height) + image->rows=(size_t) icon_info.height; + if (image->rows == 0) + image->rows=256; + image->depth=icon_info.bits_per_pixel; + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" scene = %.20g"",(double) i); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" size = %.20g"",(double) icon_info.size); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" width = %.20g"",(double) icon_file.directory[i].width); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" height = %.20g"",(double) icon_file.directory[i].height); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" colors = %.20g"",(double ) icon_info.number_colors); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" planes = %.20g"",(double) icon_info.planes); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" bpp = %.20g"",(double) icon_info.bits_per_pixel); + } + if ((icon_info.number_colors != 0) || (icon_info.bits_per_pixel <= 16U)) + { + image->storage_class=PseudoClass; + image->colors=icon_info.number_colors; + if (image->colors == 0) + image->colors=one << icon_info.bits_per_pixel; + } + if (image->storage_class == PseudoClass) + { + register ssize_t + i; + + unsigned char + *icon_colormap; + + /* + Read Icon raster colormap. + */ + if (AcquireImageColormap(image,image->colors) == MagickFalse) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t) + image->colors,4UL*sizeof(*icon_colormap)); + if (icon_colormap == (unsigned char *) NULL) + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + count=ReadBlob(image,(size_t) (4*image->colors),icon_colormap); + if (count != (ssize_t) (4*image->colors)) + ThrowReaderException(CorruptImageError, + ""InsufficientImageDataInFile""); + p=icon_colormap; + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].blue=(Quantum) ScaleCharToQuantum(*p++); + image->colormap[i].green=(Quantum) ScaleCharToQuantum(*p++); + image->colormap[i].red=(Quantum) ScaleCharToQuantum(*p++); + p++; + } + icon_colormap=(unsigned char *) RelinquishMagickMemory(icon_colormap); + } + /* + Convert Icon raster image to pixel packets. + */ + if ((image_info->ping != MagickFalse) && + (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + bytes_per_line=(((image->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + (void) bytes_per_line; + scanline_pad=((((image->columns*icon_info.bits_per_pixel)+31) & ~31)- + (image->columns*icon_info.bits_per_pixel)) >> 3; + switch (icon_info.bits_per_pixel) + { + case 1: + { + /* + Convert bitmap scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < (ssize_t) (image->columns-7); x+=8) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < 8; bit++) + SetPixelIndex(indexes+x+bit,((byte & (0x80 >> bit)) != 0 ? + 0x01 : 0x00)); + } + if ((image->columns % 8) != 0) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < (image->columns % 8); bit++) + SetPixelIndex(indexes+x+bit,((byte & (0x80 >> bit)) != 0 ? + 0x01 : 0x00)); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 4: + { + /* + Read 4-bit Icon scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < ((ssize_t) image->columns-1); x+=2) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(indexes+x,((byte >> 4) & 0xf)); + SetPixelIndex(indexes+x+1,((byte) & 0xf)); + } + if ((image->columns % 2) != 0) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(indexes+x,((byte >> 4) & 0xf)); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 8: + { + /* + Convert PseudoColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < (ssize_t) image->columns; x++) + { + byte=(size_t) ReadBlobByte(image); + SetPixelIndex(indexes+x,byte); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 16: + { + /* + Convert PseudoColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + for (x=0; x < (ssize_t) image->columns; x++) + { + byte=(size_t) ReadBlobByte(image); + byte|=(size_t) (ReadBlobByte(image) << 8); + SetPixelIndex(indexes+x,byte); + } + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case 24: + case 32: + { + /* + Convert DirectColor scanline. + */ + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + if (icon_info.bits_per_pixel == 32) + SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); + q++; + } + if (icon_info.bits_per_pixel == 24) + for (x=0; x < (ssize_t) scanline_pad; x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,image->rows-y-1, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + default: + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (image_info->ping == MagickFalse) + (void) SyncImage(image); + if (icon_info.bits_per_pixel != 32) + { + /* + Read the ICON alpha mask. + */ + image->storage_class=DirectClass; + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + for (x=0; x < ((ssize_t) image->columns-7); x+=8) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < 8; bit++) + SetPixelOpacity(q+x+bit,(((byte & (0x80 >> bit)) != 0) ? + TransparentOpacity : OpaqueOpacity)); + } + if ((image->columns % 8) != 0) + { + byte=(size_t) ReadBlobByte(image); + for (bit=0; bit < (image->columns % 8); bit++) + SetPixelOpacity(q+x+bit,(((byte & (0x80 >> bit)) != 0) ? + TransparentOpacity : OpaqueOpacity)); + } + if ((image->columns % 32) != 0) + for (x=0; x < (ssize_t) ((32-(image->columns % 32))/8); x++) + (void) ReadBlobByte(image); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + } + if (EOFBlob(image) != MagickFalse) + { + ThrowFileException(exception,CorruptImageError, + ""UnexpectedEndOfFile"",image->filename); + break; + } + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + if (i < (ssize_t) (icon_file.count-1)) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,TellBlob(image), + GetBlobSize(image)); + if (status == MagickFalse) + break; + } + } + (void) CloseBlob(image); + return(GetFirstImageInList(image)); +} +","@@ -462,6 +462,12 @@ static Image *ReadICONImage(const ImageInfo *image_info, + (image_info->number_scenes != 0)) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; ++ status=SetImageExtent(image,image->columns,image->rows); ++ if (status == MagickFalse) ++ { ++ InheritException(exception,&image->exception); ++ return(DestroyImageList(image)); ++ } + bytes_per_line=(((image->columns*icon_info.bits_per_pixel)+31) & + ~31) >> 3; + (void) bytes_per_line;",4228,4464,6144 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.pkl new file mode 100644 index 0000000000000000000000000000000000000000..03dbefc0948f35807358a9b5c1785e29f00fc4a8 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2635305f1e4ddccb6dc7e183894ed7c6ed1d33c4764c2ac8850fb5cdbc4bcfce +size 1517863 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.csv new file mode 100644 index 0000000000000000000000000000000000000000..837b17ef4b70bce30ba31e4b4510d049c6793cce --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.csv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c92a8691a2893a0ffeb2368f40fe89d5b2c602529c3a8cb5a09d1046c353290 +size 12322643 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.pkl new file mode 100644 index 0000000000000000000000000000000000000000..a97299d22d613c2fccc95c7c17c6e7a44487d47d --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ed9a3b0a9224cd1a88c50ea73fc94584d71b9158d7f462a3045e00fbccc0345 +size 8499392 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.csv new file mode 100644 index 0000000000000000000000000000000000000000..18987aa832b4c7a96928d70b8e1fea9b2f2ddb1d --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.csv @@ -0,0 +1,15813 @@ +idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting +18733,"WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) +{ + /* ! */ + + dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle); + + WORD32 i4_err_status = 0; + UWORD8 *pu1_buf = NULL; + WORD32 buflen; + UWORD32 u4_max_ofst, u4_length_of_start_code = 0; + + UWORD32 bytes_consumed = 0; + UWORD32 cur_slice_is_nonref = 0; + UWORD32 u4_next_is_aud; + UWORD32 u4_first_start_code_found = 0; + WORD32 ret = 0,api_ret_value = IV_SUCCESS; + WORD32 header_data_left = 0,frame_data_left = 0; + UWORD8 *pu1_bitstrm_buf; + ivd_video_decode_ip_t *ps_dec_ip; + ivd_video_decode_op_t *ps_dec_op; + + ithread_set_name((void*)""Parse_thread""); + + ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip; + ps_dec_op = (ivd_video_decode_op_t *)pv_api_op; + + { + UWORD32 u4_size; + u4_size = ps_dec_op->u4_size; + memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t)); + ps_dec_op->u4_size = u4_size; + } + + ps_dec->pv_dec_out = ps_dec_op; + if(ps_dec->init_done != 1) + { + return IV_FAIL; + } + + /*Data memory barries instruction,so that bitstream write by the application is complete*/ + DATA_SYNC(); + + if(0 == ps_dec->u1_flushfrm) + { + if(ps_dec_ip->pv_stream_buffer == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL; + return IV_FAIL; + } + if(ps_dec_ip->u4_num_Bytes <= 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV; + return IV_FAIL; + + } + } + ps_dec->u1_pic_decode_done = 0; + + ps_dec_op->u4_num_bytes_consumed = 0; + + ps_dec->ps_out_buffer = NULL; + + if(ps_dec_ip->u4_size + >= offsetof(ivd_video_decode_ip_t, s_out_buffer)) + ps_dec->ps_out_buffer = &ps_dec_ip->s_out_buffer; + + ps_dec->u4_fmt_conv_cur_row = 0; + + ps_dec->u4_output_present = 0; + ps_dec->s_disp_op.u4_error_code = 1; + ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS; + if(0 == ps_dec->u4_share_disp_buf + && ps_dec->i4_decode_header == 0) + { + UWORD32 i; + if(ps_dec->ps_out_buffer->u4_num_bufs == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS; + return IV_FAIL; + } + + for(i = 0; i < ps_dec->ps_out_buffer->u4_num_bufs; i++) + { + if(ps_dec->ps_out_buffer->pu1_bufs[i] == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL; + return IV_FAIL; + } + + if(ps_dec->ps_out_buffer->u4_min_out_buf_size[i] == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= + IVD_DISP_FRM_ZERO_OP_BUF_SIZE; + return IV_FAIL; + } + } + } + + if(ps_dec->u4_total_frames_decoded >= NUM_FRAMES_LIMIT) + { + ps_dec_op->u4_error_code = ERROR_FRAME_LIMIT_OVER; + return IV_FAIL; + } + + /* ! */ + ps_dec->u4_ts = ps_dec_ip->u4_ts; + + ps_dec_op->u4_error_code = 0; + ps_dec_op->e_pic_type = -1; + ps_dec_op->u4_output_present = 0; + ps_dec_op->u4_frame_decoded_flag = 0; + + ps_dec->i4_frametype = -1; + ps_dec->i4_content_type = -1; + /* + * For field pictures, set the bottom and top picture decoded u4_flag correctly. + */ + { + if((TOP_FIELD_ONLY | BOT_FIELD_ONLY) == ps_dec->u1_top_bottom_decoded) + { + ps_dec->u1_top_bottom_decoded = 0; + } + } + ps_dec->u4_slice_start_code_found = 0; + + /* In case the deocder is not in flush mode(in shared mode), + then decoder has to pick up a buffer to write current frame. + Check if a frame is available in such cases */ + + if(ps_dec->u1_init_dec_flag == 1 && ps_dec->u4_share_disp_buf == 1 + && ps_dec->u1_flushfrm == 0) + { + UWORD32 i; + + WORD32 disp_avail = 0, free_id; + + /* Check if at least one buffer is available with the codec */ + /* If not then return to application with error */ + for(i = 0; i < ps_dec->u1_pic_bufs; i++) + { + if(0 == ps_dec->u4_disp_buf_mapping[i] + || 1 == ps_dec->u4_disp_buf_to_be_freed[i]) + { + disp_avail = 1; + break; + } + + } + + if(0 == disp_avail) + { + /* If something is queued for display wait for that buffer to be returned */ + + ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + return (IV_FAIL); + } + + while(1) + { + pic_buffer_t *ps_pic_buf; + ps_pic_buf = (pic_buffer_t *)ih264_buf_mgr_get_next_free( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, &free_id); + + if(ps_pic_buf == NULL) + { + UWORD32 i, display_queued = 0; + + /* check if any buffer was given for display which is not returned yet */ + for(i = 0; i < (MAX_DISP_BUFS_NEW); i++) + { + if(0 != ps_dec->u4_disp_buf_mapping[i]) + { + display_queued = 1; + break; + } + } + /* If some buffer is queued for display, then codec has to singal an error and wait + for that buffer to be returned. + If nothing is queued for display then codec has ownership of all display buffers + and it can reuse any of the existing buffers and continue decoding */ + + if(1 == display_queued) + { + /* If something is queued for display wait for that buffer to be returned */ + ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; + ps_dec_op->u4_error_code |= (1 + << IVD_UNSUPPORTEDPARAM); + return (IV_FAIL); + } + } + else + { + /* If the buffer is with display, then mark it as in use and then look for a buffer again */ + if(1 == ps_dec->u4_disp_buf_mapping[free_id]) + { + ih264_buf_mgr_set_status( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + free_id, + BUF_MGR_IO); + } + else + { + /** + * Found a free buffer for present call. Release it now. + * Will be again obtained later. + */ + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + free_id, + BUF_MGR_IO); + break; + } + } + } + + } + + if(ps_dec->u1_flushfrm && ps_dec->u1_init_dec_flag) + { + + ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + if(0 == ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = 0; + ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht; + ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), + ps_dec->u4_fmt_conv_cur_row, + ps_dec->u4_fmt_conv_num_rows); + ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows; + ps_dec->u4_output_present = 1; + + } + ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op)); + + ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width; + ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height; + + ps_dec_op->u4_new_seq = 0; + + ps_dec_op->u4_output_present = ps_dec->u4_output_present; + ps_dec_op->u4_progressive_frame_flag = + ps_dec->s_disp_op.u4_progressive_frame_flag; + ps_dec_op->e_output_format = + ps_dec->s_disp_op.e_output_format; + ps_dec_op->s_disp_frm_buf = ps_dec->s_disp_op.s_disp_frm_buf; + ps_dec_op->e4_fld_type = ps_dec->s_disp_op.e4_fld_type; + ps_dec_op->u4_ts = ps_dec->s_disp_op.u4_ts; + ps_dec_op->u4_disp_buf_id = ps_dec->s_disp_op.u4_disp_buf_id; + + /*In the case of flush ,since no frame is decoded set pic type as invalid*/ + ps_dec_op->u4_is_ref_flag = -1; + ps_dec_op->e_pic_type = IV_NA_FRAME; + ps_dec_op->u4_frame_decoded_flag = 0; + + if(0 == ps_dec->s_disp_op.u4_error_code) + { + return (IV_SUCCESS); + } + else + return (IV_FAIL); + + } + if(ps_dec->u1_res_changed == 1) + { + /*if resolution has changed and all buffers have been flushed, reset decoder*/ + ih264d_init_decoder(ps_dec); + } + + ps_dec->u4_prev_nal_skipped = 0; + + ps_dec->u2_cur_mb_addr = 0; + ps_dec->u2_total_mbs_coded = 0; + ps_dec->u2_cur_slice_num = 0; + ps_dec->cur_dec_mb_num = 0; + ps_dec->cur_recon_mb_num = 0; + ps_dec->u4_first_slice_in_pic = 2; + ps_dec->u1_first_pb_nal_in_pic = 1; + ps_dec->u1_slice_header_done = 0; + ps_dec->u1_dangling_field = 0; + + ps_dec->u4_dec_thread_created = 0; + ps_dec->u4_bs_deblk_thread_created = 0; + ps_dec->u4_cur_bs_mb_num = 0; + ps_dec->u4_start_recon_deblk = 0; + + DEBUG_THREADS_PRINTF("" Starting process call\n""); + + + ps_dec->u4_pic_buf_got = 0; + + do + { + WORD32 buf_size; + + pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer + + ps_dec_op->u4_num_bytes_consumed; + + u4_max_ofst = ps_dec_ip->u4_num_Bytes + - ps_dec_op->u4_num_bytes_consumed; + + /* If dynamic bitstream buffer is not allocated and + * header decode is done, then allocate dynamic bitstream buffer + */ + if((NULL == ps_dec->pu1_bits_buf_dynamic) && + (ps_dec->i4_header_decoded & 1)) + { + WORD32 size; + + void *pv_buf; + void *pv_mem_ctxt = ps_dec->pv_mem_ctxt; + size = MAX(256000, ps_dec->u2_pic_wd * ps_dec->u2_pic_ht * 3 / 2); + pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size); + RETURN_IF((NULL == pv_buf), IV_FAIL); + ps_dec->pu1_bits_buf_dynamic = pv_buf; + ps_dec->u4_dynamic_bits_buf_size = size; + } + + if(ps_dec->pu1_bits_buf_dynamic) + { + pu1_bitstrm_buf = ps_dec->pu1_bits_buf_dynamic; + buf_size = ps_dec->u4_dynamic_bits_buf_size; + } + else + { + pu1_bitstrm_buf = ps_dec->pu1_bits_buf_static; + buf_size = ps_dec->u4_static_bits_buf_size; + } + + u4_next_is_aud = 0; + + buflen = ih264d_find_start_code(pu1_buf, 0, u4_max_ofst, + &u4_length_of_start_code, + &u4_next_is_aud); + + if(buflen == -1) + buflen = 0; + /* Ignore bytes beyond the allocated size of intermediate buffer */ + buflen = MIN(buflen, buf_size); + + bytes_consumed = buflen + u4_length_of_start_code; + ps_dec_op->u4_num_bytes_consumed += bytes_consumed; + + { + UWORD8 u1_firstbyte, u1_nal_ref_idc; + + if(ps_dec->i4_app_skip_mode == IVD_SKIP_B) + { + u1_firstbyte = *(pu1_buf + u4_length_of_start_code); + u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_firstbyte)); + if(u1_nal_ref_idc == 0) + { + /*skip non reference frames*/ + cur_slice_is_nonref = 1; + continue; + } + else + { + if(1 == cur_slice_is_nonref) + { + /*We have encountered a referenced frame,return to app*/ + ps_dec_op->u4_num_bytes_consumed -= + bytes_consumed; + ps_dec_op->e_pic_type = IV_B_FRAME; + ps_dec_op->u4_error_code = + IVD_DEC_FRM_SKIPPED; + ps_dec_op->u4_error_code |= (1 + << IVD_UNSUPPORTEDPARAM); + ps_dec_op->u4_frame_decoded_flag = 0; + ps_dec_op->u4_size = + sizeof(ivd_video_decode_op_t); + /*signal the decode thread*/ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + + return (IV_FAIL); + } + } + + } + + } + + + if(buflen) + { + memcpy(pu1_bitstrm_buf, pu1_buf + u4_length_of_start_code, + buflen); + /* Decoder may read extra 8 bytes near end of the frame */ + if((buflen + 8) < buf_size) + { + memset(pu1_bitstrm_buf + buflen, 0, 8); + } + u4_first_start_code_found = 1; + + } + else + { + /*start code not found*/ + + if(u4_first_start_code_found == 0) + { + /*no start codes found in current process call*/ + + ps_dec->i4_error_code = ERROR_START_CODE_NOT_FOUND; + ps_dec_op->u4_error_code |= 1 << IVD_INSUFFICIENTDATA; + + if(ps_dec->u4_pic_buf_got == 0) + { + + ih264d_fill_output_struct_from_context(ps_dec, + ps_dec_op); + + ps_dec_op->u4_error_code = ps_dec->i4_error_code; + ps_dec_op->u4_frame_decoded_flag = 0; + + return (IV_FAIL); + } + else + { + ps_dec->u1_pic_decode_done = 1; + continue; + } + } + else + { + /* a start code has already been found earlier in the same process call*/ + frame_data_left = 0; + continue; + } + + } + + ps_dec->u4_return_to_app = 0; + ret = ih264d_parse_nal_unit(dec_hdl, ps_dec_op, + pu1_bitstrm_buf, buflen); + if(ret != OK) + { + UWORD32 error = ih264d_map_error(ret); + ps_dec_op->u4_error_code = error | ret; + api_ret_value = IV_FAIL; + + if((ret == IVD_RES_CHANGED) + || (ret == IVD_MEM_ALLOC_FAILED) + || (ret == ERROR_UNAVAIL_PICBUF_T) + || (ret == ERROR_UNAVAIL_MVBUF_T) + || (ret == ERROR_INV_SPS_PPS_T)) + { + ps_dec->u4_slice_start_code_found = 0; + break; + } + + if((ret == ERROR_INCOMPLETE_FRAME) || (ret == ERROR_DANGLING_FIELD_IN_PIC)) + { + ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; + api_ret_value = IV_FAIL; + break; + } + + if(ret == ERROR_IN_LAST_SLICE_OF_PIC) + { + api_ret_value = IV_FAIL; + break; + } + + } + + if(ps_dec->u4_return_to_app) + { + /*We have encountered a referenced frame,return to app*/ + ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; + ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + ps_dec_op->u4_frame_decoded_flag = 0; + ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); + /*signal the decode thread*/ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + return (IV_FAIL); + + } + + + + header_data_left = ((ps_dec->i4_decode_header == 1) + && (ps_dec->i4_header_decoded != 3) + && (ps_dec_op->u4_num_bytes_consumed + < ps_dec_ip->u4_num_Bytes)); + frame_data_left = (((ps_dec->i4_decode_header == 0) + && ((ps_dec->u1_pic_decode_done == 0) + || (u4_next_is_aud == 1))) + && (ps_dec_op->u4_num_bytes_consumed + < ps_dec_ip->u4_num_Bytes)); + } + while(( header_data_left == 1)||(frame_data_left == 1)); + + if((ps_dec->u4_slice_start_code_found == 1) + && (ret != IVD_MEM_ALLOC_FAILED) + && ps_dec->u2_total_mbs_coded < ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + WORD32 num_mb_skipped; + WORD32 prev_slice_err; + pocstruct_t temp_poc; + WORD32 ret1; + + num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + - ps_dec->u2_total_mbs_coded; + + if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0)) + prev_slice_err = 1; + + else + prev_slice_err = 2; + + ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num, + &temp_poc, prev_slice_err); + + if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T)) + { + return IV_FAIL; + } + } + + if((ret == IVD_RES_CHANGED) + || (ret == IVD_MEM_ALLOC_FAILED) + || (ret == ERROR_UNAVAIL_PICBUF_T) + || (ret == ERROR_UNAVAIL_MVBUF_T) + || (ret == ERROR_INV_SPS_PPS_T)) + { + + /* signal the decode thread */ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet */ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + /* dont consume bitstream for change in resolution case */ + if(ret == IVD_RES_CHANGED) + { + ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; + } + return IV_FAIL; + } + + + if(ps_dec->u1_separate_parse) + { + /* If Format conversion is not complete, + complete it here */ + if(ps_dec->u4_num_cores == 2) + { + + /*do deblocking of all mbs*/ + if((ps_dec->u4_nmb_deblk == 0) &&(ps_dec->u4_start_recon_deblk == 1) && (ps_dec->ps_cur_sps->u1_mb_aff_flag == 0)) + { + UWORD32 u4_num_mbs,u4_max_addr; + tfr_ctxt_t s_tfr_ctxt; + tfr_ctxt_t *ps_tfr_cxt = &s_tfr_ctxt; + pad_mgr_t *ps_pad_mgr = &ps_dec->s_pad_mgr; + + /*BS is done for all mbs while parsing*/ + u4_max_addr = (ps_dec->u2_frm_wd_in_mbs * ps_dec->u2_frm_ht_in_mbs) - 1; + ps_dec->u4_cur_bs_mb_num = u4_max_addr + 1; + + + ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt, + ps_dec->u2_frm_wd_in_mbs, 0); + + + u4_num_mbs = u4_max_addr + - ps_dec->u4_cur_deblk_mb_num + 1; + + DEBUG_PERF_PRINTF(""mbs left for deblocking= %d \n"",u4_num_mbs); + + if(u4_num_mbs != 0) + ih264d_check_mb_map_deblk(ps_dec, u4_num_mbs, + ps_tfr_cxt,1); + + ps_dec->u4_start_recon_deblk = 0; + + } + + } + + /*signal the decode thread*/ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + } + + + DATA_SYNC(); + + + if((ps_dec_op->u4_error_code & 0xff) + != ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED) + { + ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width; + ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height; + } + + if(ps_dec->i4_header_decoded != 3) + { + ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA); + + } + + if(ps_dec->i4_decode_header == 1 && ps_dec->i4_header_decoded != 3) + { + ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA); + + } + if(ps_dec->u4_prev_nal_skipped) + { + /*We have encountered a referenced frame,return to app*/ + ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + ps_dec_op->u4_frame_decoded_flag = 0; + ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + return (IV_FAIL); + + } + + if((ps_dec->u4_slice_start_code_found == 1) + && (ERROR_DANGLING_FIELD_IN_PIC != i4_err_status)) + { + /* + * For field pictures, set the bottom and top picture decoded u4_flag correctly. + */ + + if(ps_dec->ps_cur_slice->u1_field_pic_flag) + { + if(1 == ps_dec->ps_cur_slice->u1_bottom_field_flag) + { + ps_dec->u1_top_bottom_decoded |= BOT_FIELD_ONLY; + } + else + { + ps_dec->u1_top_bottom_decoded |= TOP_FIELD_ONLY; + } + } + + /* if new frame in not found (if we are still getting slices from previous frame) + * ih264d_deblock_display is not called. Such frames will not be added to reference /display + */ + if((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0) + { + /* Calling Function to deblock Picture and Display */ + ret = ih264d_deblock_display(ps_dec); + if(ret != 0) + { + return IV_FAIL; + } + } + + + /*set to complete ,as we dont support partial frame decode*/ + if(ps_dec->i4_header_decoded == 3) + { + ps_dec->u2_total_mbs_coded = ps_dec->ps_cur_sps->u2_max_mb_addr + 1; + } + + /*Update the i4_frametype at the end of picture*/ + if(ps_dec->ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL) + { + ps_dec->i4_frametype = IV_IDR_FRAME; + } + else if(ps_dec->i4_pic_type == B_SLICE) + { + ps_dec->i4_frametype = IV_B_FRAME; + } + else if(ps_dec->i4_pic_type == P_SLICE) + { + ps_dec->i4_frametype = IV_P_FRAME; + } + else if(ps_dec->i4_pic_type == I_SLICE) + { + ps_dec->i4_frametype = IV_I_FRAME; + } + else + { + H264_DEC_DEBUG_PRINT(""Shouldn't come here\n""); + } + + ps_dec->i4_content_type = ps_dec->ps_cur_slice->u1_field_pic_flag; + + ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + 2; + ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + - ps_dec->ps_cur_slice->u1_field_pic_flag; + + } + + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + + + { + /* In case the decoder is configured to run in low delay mode, + * then get display buffer and then format convert. + * Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles + */ + + if((IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode) + && ps_dec->u1_init_dec_flag) + { + + ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + if(0 == ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = 0; + ps_dec->u4_output_present = 1; + } + } + + ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op); + + /* If Format conversion is not complete, + complete it here */ + if(ps_dec->u4_output_present && + (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht)) + { + ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht + - ps_dec->u4_fmt_conv_cur_row; + ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), + ps_dec->u4_fmt_conv_cur_row, + ps_dec->u4_fmt_conv_num_rows); + ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows; + } + + ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op)); + } + + if(ps_dec->i4_decode_header == 1 && (ps_dec->i4_header_decoded & 1) == 1) + { + ps_dec_op->u4_progressive_frame_flag = 1; + if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid))) + { + if((0 == ps_dec->ps_sps->u1_frame_mbs_only_flag) + && (0 == ps_dec->ps_sps->u1_mb_aff_flag)) + ps_dec_op->u4_progressive_frame_flag = 0; + + } + } + + /*Data memory barrier instruction,so that yuv write by the library is complete*/ + DATA_SYNC(); + + H264_DEC_DEBUG_PRINT(""The num bytes consumed: %d\n"", + ps_dec_op->u4_num_bytes_consumed); + return api_ret_value; +} +",1,"WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) +{ + /* ! */ + + dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle); + + WORD32 i4_err_status = 0; + UWORD8 *pu1_buf = NULL; + WORD32 buflen; + UWORD32 u4_max_ofst, u4_length_of_start_code = 0; + + UWORD32 bytes_consumed = 0; + UWORD32 cur_slice_is_nonref = 0; + UWORD32 u4_next_is_aud; + UWORD32 u4_first_start_code_found = 0; + WORD32 ret = 0,api_ret_value = IV_SUCCESS; + WORD32 header_data_left = 0,frame_data_left = 0; + UWORD8 *pu1_bitstrm_buf; + ivd_video_decode_ip_t *ps_dec_ip; + ivd_video_decode_op_t *ps_dec_op; + + ithread_set_name((void*)""Parse_thread""); + + ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip; + ps_dec_op = (ivd_video_decode_op_t *)pv_api_op; + + { + UWORD32 u4_size; + u4_size = ps_dec_op->u4_size; + memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t)); + ps_dec_op->u4_size = u4_size; + } + + ps_dec->pv_dec_out = ps_dec_op; + if(ps_dec->init_done != 1) + { + return IV_FAIL; + } + + /*Data memory barries instruction,so that bitstream write by the application is complete*/ + DATA_SYNC(); + + if(0 == ps_dec->u1_flushfrm) + { + if(ps_dec_ip->pv_stream_buffer == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL; + return IV_FAIL; + } + if(ps_dec_ip->u4_num_Bytes <= 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV; + return IV_FAIL; + + } + } + ps_dec->u1_pic_decode_done = 0; + + ps_dec_op->u4_num_bytes_consumed = 0; + + ps_dec->ps_out_buffer = NULL; + + if(ps_dec_ip->u4_size + >= offsetof(ivd_video_decode_ip_t, s_out_buffer)) + ps_dec->ps_out_buffer = &ps_dec_ip->s_out_buffer; + + ps_dec->u4_fmt_conv_cur_row = 0; + + ps_dec->u4_output_present = 0; + ps_dec->s_disp_op.u4_error_code = 1; + ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS; + if(0 == ps_dec->u4_share_disp_buf + && ps_dec->i4_decode_header == 0) + { + UWORD32 i; + if(ps_dec->ps_out_buffer->u4_num_bufs == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS; + return IV_FAIL; + } + + for(i = 0; i < ps_dec->ps_out_buffer->u4_num_bufs; i++) + { + if(ps_dec->ps_out_buffer->pu1_bufs[i] == NULL) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL; + return IV_FAIL; + } + + if(ps_dec->ps_out_buffer->u4_min_out_buf_size[i] == 0) + { + ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; + ps_dec_op->u4_error_code |= + IVD_DISP_FRM_ZERO_OP_BUF_SIZE; + return IV_FAIL; + } + } + } + + if(ps_dec->u4_total_frames_decoded >= NUM_FRAMES_LIMIT) + { + ps_dec_op->u4_error_code = ERROR_FRAME_LIMIT_OVER; + return IV_FAIL; + } + + /* ! */ + ps_dec->u4_ts = ps_dec_ip->u4_ts; + + ps_dec_op->u4_error_code = 0; + ps_dec_op->e_pic_type = -1; + ps_dec_op->u4_output_present = 0; + ps_dec_op->u4_frame_decoded_flag = 0; + + ps_dec->i4_frametype = -1; + ps_dec->i4_content_type = -1; + /* + * For field pictures, set the bottom and top picture decoded u4_flag correctly. + */ + { + if((TOP_FIELD_ONLY | BOT_FIELD_ONLY) == ps_dec->u1_top_bottom_decoded) + { + ps_dec->u1_top_bottom_decoded = 0; + } + } + ps_dec->u4_slice_start_code_found = 0; + + /* In case the deocder is not in flush mode(in shared mode), + then decoder has to pick up a buffer to write current frame. + Check if a frame is available in such cases */ + + if(ps_dec->u1_init_dec_flag == 1 && ps_dec->u4_share_disp_buf == 1 + && ps_dec->u1_flushfrm == 0) + { + UWORD32 i; + + WORD32 disp_avail = 0, free_id; + + /* Check if at least one buffer is available with the codec */ + /* If not then return to application with error */ + for(i = 0; i < ps_dec->u1_pic_bufs; i++) + { + if(0 == ps_dec->u4_disp_buf_mapping[i] + || 1 == ps_dec->u4_disp_buf_to_be_freed[i]) + { + disp_avail = 1; + break; + } + + } + + if(0 == disp_avail) + { + /* If something is queued for display wait for that buffer to be returned */ + + ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + return (IV_FAIL); + } + + while(1) + { + pic_buffer_t *ps_pic_buf; + ps_pic_buf = (pic_buffer_t *)ih264_buf_mgr_get_next_free( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, &free_id); + + if(ps_pic_buf == NULL) + { + UWORD32 i, display_queued = 0; + + /* check if any buffer was given for display which is not returned yet */ + for(i = 0; i < (MAX_DISP_BUFS_NEW); i++) + { + if(0 != ps_dec->u4_disp_buf_mapping[i]) + { + display_queued = 1; + break; + } + } + /* If some buffer is queued for display, then codec has to singal an error and wait + for that buffer to be returned. + If nothing is queued for display then codec has ownership of all display buffers + and it can reuse any of the existing buffers and continue decoding */ + + if(1 == display_queued) + { + /* If something is queued for display wait for that buffer to be returned */ + ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL; + ps_dec_op->u4_error_code |= (1 + << IVD_UNSUPPORTEDPARAM); + return (IV_FAIL); + } + } + else + { + /* If the buffer is with display, then mark it as in use and then look for a buffer again */ + if(1 == ps_dec->u4_disp_buf_mapping[free_id]) + { + ih264_buf_mgr_set_status( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + free_id, + BUF_MGR_IO); + } + else + { + /** + * Found a free buffer for present call. Release it now. + * Will be again obtained later. + */ + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + free_id, + BUF_MGR_IO); + break; + } + } + } + + } + + if(ps_dec->u1_flushfrm && ps_dec->u1_init_dec_flag) + { + + ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + if(0 == ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = 0; + ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht; + ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), + ps_dec->u4_fmt_conv_cur_row, + ps_dec->u4_fmt_conv_num_rows); + ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows; + ps_dec->u4_output_present = 1; + + } + ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op)); + + ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width; + ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height; + + ps_dec_op->u4_new_seq = 0; + + ps_dec_op->u4_output_present = ps_dec->u4_output_present; + ps_dec_op->u4_progressive_frame_flag = + ps_dec->s_disp_op.u4_progressive_frame_flag; + ps_dec_op->e_output_format = + ps_dec->s_disp_op.e_output_format; + ps_dec_op->s_disp_frm_buf = ps_dec->s_disp_op.s_disp_frm_buf; + ps_dec_op->e4_fld_type = ps_dec->s_disp_op.e4_fld_type; + ps_dec_op->u4_ts = ps_dec->s_disp_op.u4_ts; + ps_dec_op->u4_disp_buf_id = ps_dec->s_disp_op.u4_disp_buf_id; + + /*In the case of flush ,since no frame is decoded set pic type as invalid*/ + ps_dec_op->u4_is_ref_flag = -1; + ps_dec_op->e_pic_type = IV_NA_FRAME; + ps_dec_op->u4_frame_decoded_flag = 0; + + if(0 == ps_dec->s_disp_op.u4_error_code) + { + return (IV_SUCCESS); + } + else + return (IV_FAIL); + + } + if(ps_dec->u1_res_changed == 1) + { + /*if resolution has changed and all buffers have been flushed, reset decoder*/ + ih264d_init_decoder(ps_dec); + } + + ps_dec->u4_prev_nal_skipped = 0; + + ps_dec->u2_cur_mb_addr = 0; + ps_dec->u2_total_mbs_coded = 0; + ps_dec->u2_cur_slice_num = 0; + ps_dec->cur_dec_mb_num = 0; + ps_dec->cur_recon_mb_num = 0; + ps_dec->u4_first_slice_in_pic = 2; + ps_dec->u1_first_pb_nal_in_pic = 1; + ps_dec->u1_slice_header_done = 0; + ps_dec->u1_dangling_field = 0; + + ps_dec->u4_dec_thread_created = 0; + ps_dec->u4_bs_deblk_thread_created = 0; + ps_dec->u4_cur_bs_mb_num = 0; + ps_dec->u4_start_recon_deblk = 0; + + DEBUG_THREADS_PRINTF("" Starting process call\n""); + + + ps_dec->u4_pic_buf_got = 0; + + do + { + WORD32 buf_size; + + pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer + + ps_dec_op->u4_num_bytes_consumed; + + u4_max_ofst = ps_dec_ip->u4_num_Bytes + - ps_dec_op->u4_num_bytes_consumed; + + /* If dynamic bitstream buffer is not allocated and + * header decode is done, then allocate dynamic bitstream buffer + */ + if((NULL == ps_dec->pu1_bits_buf_dynamic) && + (ps_dec->i4_header_decoded & 1)) + { + WORD32 size; + + void *pv_buf; + void *pv_mem_ctxt = ps_dec->pv_mem_ctxt; + size = MAX(256000, ps_dec->u2_pic_wd * ps_dec->u2_pic_ht * 3 / 2); + pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size); + RETURN_IF((NULL == pv_buf), IV_FAIL); + ps_dec->pu1_bits_buf_dynamic = pv_buf; + ps_dec->u4_dynamic_bits_buf_size = size; + } + + if(ps_dec->pu1_bits_buf_dynamic) + { + pu1_bitstrm_buf = ps_dec->pu1_bits_buf_dynamic; + buf_size = ps_dec->u4_dynamic_bits_buf_size; + } + else + { + pu1_bitstrm_buf = ps_dec->pu1_bits_buf_static; + buf_size = ps_dec->u4_static_bits_buf_size; + } + + u4_next_is_aud = 0; + + buflen = ih264d_find_start_code(pu1_buf, 0, u4_max_ofst, + &u4_length_of_start_code, + &u4_next_is_aud); + + if(buflen == -1) + buflen = 0; + /* Ignore bytes beyond the allocated size of intermediate buffer */ + buflen = MIN(buflen, buf_size); + + bytes_consumed = buflen + u4_length_of_start_code; + ps_dec_op->u4_num_bytes_consumed += bytes_consumed; + + { + UWORD8 u1_firstbyte, u1_nal_ref_idc; + + if(ps_dec->i4_app_skip_mode == IVD_SKIP_B) + { + u1_firstbyte = *(pu1_buf + u4_length_of_start_code); + u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_firstbyte)); + if(u1_nal_ref_idc == 0) + { + /*skip non reference frames*/ + cur_slice_is_nonref = 1; + continue; + } + else + { + if(1 == cur_slice_is_nonref) + { + /*We have encountered a referenced frame,return to app*/ + ps_dec_op->u4_num_bytes_consumed -= + bytes_consumed; + ps_dec_op->e_pic_type = IV_B_FRAME; + ps_dec_op->u4_error_code = + IVD_DEC_FRM_SKIPPED; + ps_dec_op->u4_error_code |= (1 + << IVD_UNSUPPORTEDPARAM); + ps_dec_op->u4_frame_decoded_flag = 0; + ps_dec_op->u4_size = + sizeof(ivd_video_decode_op_t); + /*signal the decode thread*/ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + + return (IV_FAIL); + } + } + + } + + } + + + if(buflen) + { + memcpy(pu1_bitstrm_buf, pu1_buf + u4_length_of_start_code, + buflen); + /* Decoder may read extra 8 bytes near end of the frame */ + if((buflen + 8) < buf_size) + { + memset(pu1_bitstrm_buf + buflen, 0, 8); + } + u4_first_start_code_found = 1; + + } + else + { + /*start code not found*/ + + if(u4_first_start_code_found == 0) + { + /*no start codes found in current process call*/ + + ps_dec->i4_error_code = ERROR_START_CODE_NOT_FOUND; + ps_dec_op->u4_error_code |= 1 << IVD_INSUFFICIENTDATA; + + if(ps_dec->u4_pic_buf_got == 0) + { + + ih264d_fill_output_struct_from_context(ps_dec, + ps_dec_op); + + ps_dec_op->u4_error_code = ps_dec->i4_error_code; + ps_dec_op->u4_frame_decoded_flag = 0; + + return (IV_FAIL); + } + else + { + ps_dec->u1_pic_decode_done = 1; + continue; + } + } + else + { + /* a start code has already been found earlier in the same process call*/ + frame_data_left = 0; + continue; + } + + } + + ps_dec->u4_return_to_app = 0; + ret = ih264d_parse_nal_unit(dec_hdl, ps_dec_op, + pu1_bitstrm_buf, buflen); + if(ret != OK) + { + UWORD32 error = ih264d_map_error(ret); + ps_dec_op->u4_error_code = error | ret; + api_ret_value = IV_FAIL; + + if((ret == IVD_RES_CHANGED) + || (ret == IVD_MEM_ALLOC_FAILED) + || (ret == ERROR_UNAVAIL_PICBUF_T) + || (ret == ERROR_UNAVAIL_MVBUF_T) + || (ret == ERROR_INV_SPS_PPS_T)) + { + ps_dec->u4_slice_start_code_found = 0; + break; + } + + if((ret == ERROR_INCOMPLETE_FRAME) || (ret == ERROR_DANGLING_FIELD_IN_PIC)) + { + ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; + api_ret_value = IV_FAIL; + break; + } + + if(ret == ERROR_IN_LAST_SLICE_OF_PIC) + { + api_ret_value = IV_FAIL; + break; + } + + } + + if(ps_dec->u4_return_to_app) + { + /*We have encountered a referenced frame,return to app*/ + ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; + ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + ps_dec_op->u4_frame_decoded_flag = 0; + ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); + /*signal the decode thread*/ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + return (IV_FAIL); + + } + + + + header_data_left = ((ps_dec->i4_decode_header == 1) + && (ps_dec->i4_header_decoded != 3) + && (ps_dec_op->u4_num_bytes_consumed + < ps_dec_ip->u4_num_Bytes)); + frame_data_left = (((ps_dec->i4_decode_header == 0) + && ((ps_dec->u1_pic_decode_done == 0) + || (u4_next_is_aud == 1))) + && (ps_dec_op->u4_num_bytes_consumed + < ps_dec_ip->u4_num_Bytes)); + } + while(( header_data_left == 1)||(frame_data_left == 1)); + + if((ps_dec->u4_slice_start_code_found == 1) + && (ret != IVD_MEM_ALLOC_FAILED) + && ps_dec->u2_total_mbs_coded < ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + WORD32 num_mb_skipped; + WORD32 prev_slice_err; + pocstruct_t temp_poc; + WORD32 ret1; + + num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + - ps_dec->u2_total_mbs_coded; + + if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0)) + prev_slice_err = 1; + + else + prev_slice_err = 2; + + if(ps_dec->u4_first_slice_in_pic && (ps_dec->u2_total_mbs_coded == 0)) + prev_slice_err = 1; + + ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num, + &temp_poc, prev_slice_err); + + if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T)) + { + return IV_FAIL; + } + } + + if((ret == IVD_RES_CHANGED) + || (ret == IVD_MEM_ALLOC_FAILED) + || (ret == ERROR_UNAVAIL_PICBUF_T) + || (ret == ERROR_UNAVAIL_MVBUF_T) + || (ret == ERROR_INV_SPS_PPS_T)) + { + + /* signal the decode thread */ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet */ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + /* dont consume bitstream for change in resolution case */ + if(ret == IVD_RES_CHANGED) + { + ps_dec_op->u4_num_bytes_consumed -= bytes_consumed; + } + return IV_FAIL; + } + + + if(ps_dec->u1_separate_parse) + { + /* If Format conversion is not complete, + complete it here */ + if(ps_dec->u4_num_cores == 2) + { + + /*do deblocking of all mbs*/ + if((ps_dec->u4_nmb_deblk == 0) &&(ps_dec->u4_start_recon_deblk == 1) && (ps_dec->ps_cur_sps->u1_mb_aff_flag == 0)) + { + UWORD32 u4_num_mbs,u4_max_addr; + tfr_ctxt_t s_tfr_ctxt; + tfr_ctxt_t *ps_tfr_cxt = &s_tfr_ctxt; + pad_mgr_t *ps_pad_mgr = &ps_dec->s_pad_mgr; + + /*BS is done for all mbs while parsing*/ + u4_max_addr = (ps_dec->u2_frm_wd_in_mbs * ps_dec->u2_frm_ht_in_mbs) - 1; + ps_dec->u4_cur_bs_mb_num = u4_max_addr + 1; + + + ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt, + ps_dec->u2_frm_wd_in_mbs, 0); + + + u4_num_mbs = u4_max_addr + - ps_dec->u4_cur_deblk_mb_num + 1; + + DEBUG_PERF_PRINTF(""mbs left for deblocking= %d \n"",u4_num_mbs); + + if(u4_num_mbs != 0) + ih264d_check_mb_map_deblk(ps_dec, u4_num_mbs, + ps_tfr_cxt,1); + + ps_dec->u4_start_recon_deblk = 0; + + } + + } + + /*signal the decode thread*/ + ih264d_signal_decode_thread(ps_dec); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + } + + + DATA_SYNC(); + + + if((ps_dec_op->u4_error_code & 0xff) + != ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED) + { + ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width; + ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height; + } + + if(ps_dec->i4_header_decoded != 3) + { + ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA); + + } + + if(ps_dec->i4_decode_header == 1 && ps_dec->i4_header_decoded != 3) + { + ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA); + + } + if(ps_dec->u4_prev_nal_skipped) + { + /*We have encountered a referenced frame,return to app*/ + ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED; + ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM); + ps_dec_op->u4_frame_decoded_flag = 0; + ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + return (IV_FAIL); + + } + + if((ps_dec->u4_slice_start_code_found == 1) + && (ERROR_DANGLING_FIELD_IN_PIC != i4_err_status)) + { + /* + * For field pictures, set the bottom and top picture decoded u4_flag correctly. + */ + + if(ps_dec->ps_cur_slice->u1_field_pic_flag) + { + if(1 == ps_dec->ps_cur_slice->u1_bottom_field_flag) + { + ps_dec->u1_top_bottom_decoded |= BOT_FIELD_ONLY; + } + else + { + ps_dec->u1_top_bottom_decoded |= TOP_FIELD_ONLY; + } + } + + /* if new frame in not found (if we are still getting slices from previous frame) + * ih264d_deblock_display is not called. Such frames will not be added to reference /display + */ + if((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0) + { + /* Calling Function to deblock Picture and Display */ + ret = ih264d_deblock_display(ps_dec); + if(ret != 0) + { + return IV_FAIL; + } + } + + + /*set to complete ,as we dont support partial frame decode*/ + if(ps_dec->i4_header_decoded == 3) + { + ps_dec->u2_total_mbs_coded = ps_dec->ps_cur_sps->u2_max_mb_addr + 1; + } + + /*Update the i4_frametype at the end of picture*/ + if(ps_dec->ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL) + { + ps_dec->i4_frametype = IV_IDR_FRAME; + } + else if(ps_dec->i4_pic_type == B_SLICE) + { + ps_dec->i4_frametype = IV_B_FRAME; + } + else if(ps_dec->i4_pic_type == P_SLICE) + { + ps_dec->i4_frametype = IV_P_FRAME; + } + else if(ps_dec->i4_pic_type == I_SLICE) + { + ps_dec->i4_frametype = IV_I_FRAME; + } + else + { + H264_DEC_DEBUG_PRINT(""Shouldn't come here\n""); + } + + ps_dec->i4_content_type = ps_dec->ps_cur_slice->u1_field_pic_flag; + + ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + 2; + ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + - ps_dec->ps_cur_slice->u1_field_pic_flag; + + } + + /* close deblock thread if it is not closed yet*/ + if(ps_dec->u4_num_cores == 3) + { + ih264d_signal_bs_deblk_thread(ps_dec); + } + + + { + /* In case the decoder is configured to run in low delay mode, + * then get display buffer and then format convert. + * Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles + */ + + if((IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode) + && ps_dec->u1_init_dec_flag) + { + + ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + if(0 == ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = 0; + ps_dec->u4_output_present = 1; + } + } + + ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op); + + /* If Format conversion is not complete, + complete it here */ + if(ps_dec->u4_output_present && + (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht)) + { + ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht + - ps_dec->u4_fmt_conv_cur_row; + ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), + ps_dec->u4_fmt_conv_cur_row, + ps_dec->u4_fmt_conv_num_rows); + ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows; + } + + ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op)); + } + + if(ps_dec->i4_decode_header == 1 && (ps_dec->i4_header_decoded & 1) == 1) + { + ps_dec_op->u4_progressive_frame_flag = 1; + if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid))) + { + if((0 == ps_dec->ps_sps->u1_frame_mbs_only_flag) + && (0 == ps_dec->ps_sps->u1_mb_aff_flag)) + ps_dec_op->u4_progressive_frame_flag = 0; + + } + } + + /*Data memory barrier instruction,so that yuv write by the library is complete*/ + DATA_SYNC(); + + H264_DEC_DEBUG_PRINT(""The num bytes consumed: %d\n"", + ps_dec_op->u4_num_bytes_consumed); + return api_ret_value; +} +","@@ -2140,6 +2140,9 @@ + + else + prev_slice_err = 2; + ++ if(ps_dec->u4_first_slice_in_pic && (ps_dec->u2_total_mbs_coded == 0)) ++ prev_slice_err = 1; ++ + ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num, + &temp_poc, prev_slice_err); + +",6308,6544,8192 +18346,"static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image, + ExceptionInfo *exception) +{ + char + buffer[MagickPathExtent], + format, + magick[MagickPathExtent]; + + const char + *value; + + MagickBooleanType + status; + + MagickOffsetType + scene; + + Quantum + index; + + QuantumAny + pixel; + + QuantumInfo + *quantum_info; + + QuantumType + quantum_type; + + register unsigned char + *q; + + size_t + extent, + imageListLength, + packet_size; + + ssize_t + count, + y; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + scene=0; + imageListLength=GetImageListLength(image); + do + { + QuantumAny + max_value; + + /* + Write PNM file header. + */ + packet_size=3; + quantum_type=RGBQuantum; + (void) CopyMagickString(magick,image_info->magick,MagickPathExtent); + max_value=GetQuantumRange(image->depth); + switch (magick[1]) + { + case 'A': + case 'a': + { + format='7'; + break; + } + case 'B': + case 'b': + { + format='4'; + if (image_info->compression == NoCompression) + format='1'; + break; + } + case 'F': + case 'f': + { + format='F'; + if (SetImageGray(image,exception) != MagickFalse) + format='f'; + break; + } + case 'G': + case 'g': + { + format='5'; + if (image_info->compression == NoCompression) + format='2'; + break; + } + case 'N': + case 'n': + { + if ((image_info->type != TrueColorType) && + (SetImageGray(image,exception) != MagickFalse)) + { + format='5'; + if (image_info->compression == NoCompression) + format='2'; + if (SetImageMonochrome(image,exception) != MagickFalse) + { + format='4'; + if (image_info->compression == NoCompression) + format='1'; + } + break; + } + } + default: + { + format='6'; + if (image_info->compression == NoCompression) + format='3'; + break; + } + } + (void) FormatLocaleString(buffer,MagickPathExtent,""P%c\n"",format); + (void) WriteBlobString(image,buffer); + value=GetImageProperty(image,""comment"",exception); + if (value != (const char *) NULL) + { + register const char + *p; + + /* + Write comments to file. + */ + (void) WriteBlobByte(image,'#'); + for (p=value; *p != '\0'; p++) + { + (void) WriteBlobByte(image,(unsigned char) *p); + if ((*p == '\n') || (*p == '\r')) + (void) WriteBlobByte(image,'#'); + } + (void) WriteBlobByte(image,'\n'); + } + if (format != '7') + { + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g %.20g\n"", + (double) image->columns,(double) image->rows); + (void) WriteBlobString(image,buffer); + } + else + { + char + type[MagickPathExtent]; + + /* + PAM header. + */ + (void) FormatLocaleString(buffer,MagickPathExtent, + ""WIDTH %.20g\nHEIGHT %.20g\n"",(double) image->columns,(double) + image->rows); + (void) WriteBlobString(image,buffer); + quantum_type=GetQuantumType(image,exception); + switch (quantum_type) + { + case CMYKQuantum: + case CMYKAQuantum: + { + packet_size=4; + (void) CopyMagickString(type,""CMYK"",MagickPathExtent); + break; + } + case GrayQuantum: + case GrayAlphaQuantum: + { + packet_size=1; + (void) CopyMagickString(type,""GRAYSCALE"",MagickPathExtent); + if (IdentifyImageMonochrome(image,exception) != MagickFalse) + (void) CopyMagickString(type,""BLACKANDWHITE"",MagickPathExtent); + break; + } + default: + { + quantum_type=RGBQuantum; + if (image->alpha_trait != UndefinedPixelTrait) + quantum_type=RGBAQuantum; + packet_size=3; + (void) CopyMagickString(type,""RGB"",MagickPathExtent); + break; + } + } + if (image->alpha_trait != UndefinedPixelTrait) + { + packet_size++; + (void) ConcatenateMagickString(type,""_ALPHA"",MagickPathExtent); + } + if (image->depth > 32) + image->depth=32; + (void) FormatLocaleString(buffer,MagickPathExtent, + ""DEPTH %.20g\nMAXVAL %.20g\n"",(double) packet_size,(double) + ((MagickOffsetType) GetQuantumRange(image->depth))); + (void) WriteBlobString(image,buffer); + (void) FormatLocaleString(buffer,MagickPathExtent, + ""TUPLTYPE %s\nENDHDR\n"",type); + (void) WriteBlobString(image,buffer); + } + /* + Convert runextent encoded to PNM raster pixels. + */ + switch (format) + { + case '1': + { + unsigned char + pixels[2048]; + + /* + Convert image to a PBM image. + */ + (void) SetImageType(image,BilevelType,exception); + q=pixels; + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + *q++=(unsigned char) (GetPixelLuma(image,p) >= (QuantumRange/2.0) ? + '0' : '1'); + *q++=' '; + if ((q-pixels+1) >= (ssize_t) sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + } + p+=GetPixelChannels(image); + } + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (q != pixels) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + } + break; + } + case '2': + { + unsigned char + pixels[2048]; + + /* + Convert image to a PGM image. + */ + if (image->depth <= 8) + (void) WriteBlobString(image,""255\n""); + else + if (image->depth <= 16) + (void) WriteBlobString(image,""65535\n""); + else + (void) WriteBlobString(image,""4294967295\n""); + q=pixels; + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + index=ClampToQuantum(GetPixelLuma(image,p)); + if (image->depth <= 8) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent,""%u "", + ScaleQuantumToChar(index)); + else + if (image->depth <= 16) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u "",ScaleQuantumToShort(index)); + else + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u "",ScaleQuantumToLong(index)); + extent=(size_t) count; + (void) strncpy((char *) q,buffer,extent); + q+=extent; + if ((q-pixels+extent+1) >= sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + } + p+=GetPixelChannels(image); + } + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (q != pixels) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + } + break; + } + case '3': + { + unsigned char + pixels[2048]; + + /* + Convert image to a PNM image. + */ + (void) TransformImageColorspace(image,sRGBColorspace,exception); + if (image->depth <= 8) + (void) WriteBlobString(image,""255\n""); + else + if (image->depth <= 16) + (void) WriteBlobString(image,""65535\n""); + else + (void) WriteBlobString(image,""4294967295\n""); + q=pixels; + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->depth <= 8) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u %u %u "",ScaleQuantumToChar(GetPixelRed(image,p)), + ScaleQuantumToChar(GetPixelGreen(image,p)), + ScaleQuantumToChar(GetPixelBlue(image,p))); + else + if (image->depth <= 16) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u %u %u "",ScaleQuantumToShort(GetPixelRed(image,p)), + ScaleQuantumToShort(GetPixelGreen(image,p)), + ScaleQuantumToShort(GetPixelBlue(image,p))); + else + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u %u %u "",ScaleQuantumToLong(GetPixelRed(image,p)), + ScaleQuantumToLong(GetPixelGreen(image,p)), + ScaleQuantumToLong(GetPixelBlue(image,p))); + extent=(size_t) count; + (void) strncpy((char *) q,buffer,extent); + q+=extent; + if ((q-pixels+extent+1) >= sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + } + p+=GetPixelChannels(image); + } + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (q != pixels) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + } + break; + } + case '4': + { + register unsigned char + *pixels; + + /* + Convert image to a PBM image. + */ + (void) SetImageType(image,BilevelType,exception); + image->depth=1; + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + quantum_info->min_is_white=MagickTrue; + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + GrayQuantum,pixels,exception); + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case '5': + { + register unsigned char + *pixels; + + /* + Convert image to a PGM image. + */ + if (image->depth > 32) + image->depth=32; + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g\n"",(double) + ((MagickOffsetType) GetQuantumRange(image->depth))); + (void) WriteBlobString(image,buffer); + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + quantum_info->min_is_white=MagickTrue; + pixels=GetQuantumPixels(quantum_info); + extent=GetQuantumExtent(image,quantum_info,GrayQuantum); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + q=pixels; + switch (image->depth) + { + case 8: + case 16: + case 32: + { + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + GrayQuantum,pixels,exception); + break; + } + default: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + if (IsPixelGray(image,p) == MagickFalse) + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma( + image,p)),max_value); + else + { + if (image->depth == 8) + pixel=ScaleQuantumToChar(GetPixelRed(image,p)); + else + pixel=ScaleQuantumToAny(GetPixelRed(image,p), + max_value); + } + q=PopCharPixel((unsigned char) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + if (IsPixelGray(image,p) == MagickFalse) + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image, + p)),max_value); + else + { + if (image->depth == 16) + pixel=ScaleQuantumToShort(GetPixelRed(image,p)); + else + pixel=ScaleQuantumToAny(GetPixelRed(image,p), + max_value); + } + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + if (IsPixelGray(image,p) == MagickFalse) + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p)), + max_value); + else + { + if (image->depth == 16) + pixel=ScaleQuantumToLong(GetPixelRed(image,p)); + else + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + } + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + } + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case '6': + { + register unsigned char + *pixels; + + /* + Convert image to a PNM image. + */ + (void) TransformImageColorspace(image,sRGBColorspace,exception); + if (image->depth > 32) + image->depth=32; + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g\n"",(double) + ((MagickOffsetType) GetQuantumRange(image->depth))); + (void) WriteBlobString(image,buffer); + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + pixels=GetQuantumPixels(quantum_info); + extent=GetQuantumExtent(image,quantum_info,quantum_type); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + q=pixels; + switch (image->depth) + { + case 8: + case 16: + case 32: + { + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + break; + } + default: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + } + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case '7': + { + register unsigned char + *pixels; + + /* + Convert image to a PAM. + */ + if (image->depth > 32) + image->depth=32; + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + q=pixels; + switch (image->depth) + { + case 8: + case 16: + case 32: + { + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + break; + } + default: + { + switch (quantum_type) + { + case GrayQuantum: + case GrayAlphaQuantum: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma( + image,p)),max_value); + q=PopCharPixel((unsigned char) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=(unsigned char) ScaleQuantumToAny( + GetPixelAlpha(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma( + image,p)),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=(unsigned char) ScaleQuantumToAny( + GetPixelAlpha(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image, + p)),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=(unsigned char) ScaleQuantumToAny( + GetPixelAlpha(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + case CMYKQuantum: + case CMYKAQuantum: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlack(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlack(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlack(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + default: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + } + extent=(size_t) (q-pixels); + break; + } + } + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case 'F': + case 'f': + { + register unsigned char + *pixels; + + (void) WriteBlobString(image,image->endian == LSBEndian ? ""-1.0\n"" : + ""1.0\n""); + image->depth=32; + quantum_type=format == 'f' ? GrayQuantum : RGBQuantum; + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat); + if (status == MagickFalse) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + pixels=GetQuantumPixels(quantum_info); + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + register const Quantum + *magick_restrict p; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + (void) WriteBlob(image,extent,pixels); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + } + if (GetNextImageInList(image) == (Image *) NULL) + break; + image=SyncNextImageInList(image); + status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); + if (status == MagickFalse) + break; + } while (image_info->adjoin != MagickFalse); + (void) CloseBlob(image); + return(MagickTrue); +} +",1,"static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image, + ExceptionInfo *exception) +{ + char + buffer[MagickPathExtent], + format, + magick[MagickPathExtent]; + + const char + *value; + + MagickBooleanType + status; + + MagickOffsetType + scene; + + Quantum + index; + + QuantumAny + pixel; + + QuantumInfo + *quantum_info; + + QuantumType + quantum_type; + + register unsigned char + *q; + + size_t + extent, + imageListLength, + packet_size; + + ssize_t + count, + y; + + /* + Open output image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); + if (status == MagickFalse) + return(status); + scene=0; + imageListLength=GetImageListLength(image); + do + { + QuantumAny + max_value; + + /* + Write PNM file header. + */ + packet_size=3; + quantum_type=RGBQuantum; + (void) CopyMagickString(magick,image_info->magick,MagickPathExtent); + max_value=GetQuantumRange(image->depth); + switch (magick[1]) + { + case 'A': + case 'a': + { + format='7'; + break; + } + case 'B': + case 'b': + { + format='4'; + if (image_info->compression == NoCompression) + format='1'; + break; + } + case 'F': + case 'f': + { + format='F'; + if (SetImageGray(image,exception) != MagickFalse) + format='f'; + break; + } + case 'G': + case 'g': + { + format='5'; + if (image_info->compression == NoCompression) + format='2'; + break; + } + case 'N': + case 'n': + { + if ((image_info->type != TrueColorType) && + (SetImageGray(image,exception) != MagickFalse)) + { + format='5'; + if (image_info->compression == NoCompression) + format='2'; + if (SetImageMonochrome(image,exception) != MagickFalse) + { + format='4'; + if (image_info->compression == NoCompression) + format='1'; + } + break; + } + } + default: + { + format='6'; + if (image_info->compression == NoCompression) + format='3'; + break; + } + } + (void) FormatLocaleString(buffer,MagickPathExtent,""P%c\n"",format); + (void) WriteBlobString(image,buffer); + value=GetImageProperty(image,""comment"",exception); + if (value != (const char *) NULL) + { + register const char + *p; + + /* + Write comments to file. + */ + (void) WriteBlobByte(image,'#'); + for (p=value; *p != '\0'; p++) + { + (void) WriteBlobByte(image,(unsigned char) *p); + if ((*p == '\n') || (*p == '\r')) + (void) WriteBlobByte(image,'#'); + } + (void) WriteBlobByte(image,'\n'); + } + if (format != '7') + { + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g %.20g\n"", + (double) image->columns,(double) image->rows); + (void) WriteBlobString(image,buffer); + } + else + { + char + type[MagickPathExtent]; + + /* + PAM header. + */ + (void) FormatLocaleString(buffer,MagickPathExtent, + ""WIDTH %.20g\nHEIGHT %.20g\n"",(double) image->columns,(double) + image->rows); + (void) WriteBlobString(image,buffer); + quantum_type=GetQuantumType(image,exception); + switch (quantum_type) + { + case CMYKQuantum: + case CMYKAQuantum: + { + packet_size=4; + (void) CopyMagickString(type,""CMYK"",MagickPathExtent); + break; + } + case GrayQuantum: + case GrayAlphaQuantum: + { + packet_size=1; + (void) CopyMagickString(type,""GRAYSCALE"",MagickPathExtent); + if (IdentifyImageMonochrome(image,exception) != MagickFalse) + (void) CopyMagickString(type,""BLACKANDWHITE"",MagickPathExtent); + break; + } + default: + { + quantum_type=RGBQuantum; + if (image->alpha_trait != UndefinedPixelTrait) + quantum_type=RGBAQuantum; + packet_size=3; + (void) CopyMagickString(type,""RGB"",MagickPathExtent); + break; + } + } + if (image->alpha_trait != UndefinedPixelTrait) + { + packet_size++; + (void) ConcatenateMagickString(type,""_ALPHA"",MagickPathExtent); + } + if (image->depth > 32) + image->depth=32; + (void) FormatLocaleString(buffer,MagickPathExtent, + ""DEPTH %.20g\nMAXVAL %.20g\n"",(double) packet_size,(double) + ((MagickOffsetType) GetQuantumRange(image->depth))); + (void) WriteBlobString(image,buffer); + (void) FormatLocaleString(buffer,MagickPathExtent, + ""TUPLTYPE %s\nENDHDR\n"",type); + (void) WriteBlobString(image,buffer); + } + /* + Convert runextent encoded to PNM raster pixels. + */ + switch (format) + { + case '1': + { + unsigned char + pixels[2048]; + + /* + Convert image to a PBM image. + */ + (void) SetImageType(image,BilevelType,exception); + q=pixels; + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + *q++=(unsigned char) (GetPixelLuma(image,p) >= (QuantumRange/2.0) ? + '0' : '1'); + *q++=' '; + if ((q-pixels+1) >= (ssize_t) sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + } + p+=GetPixelChannels(image); + } + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (q != pixels) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + } + break; + } + case '2': + { + unsigned char + pixels[2048]; + + /* + Convert image to a PGM image. + */ + if (image->depth <= 8) + (void) WriteBlobString(image,""255\n""); + else + if (image->depth <= 16) + (void) WriteBlobString(image,""65535\n""); + else + (void) WriteBlobString(image,""4294967295\n""); + q=pixels; + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + index=ClampToQuantum(GetPixelLuma(image,p)); + if (image->depth <= 8) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent,""%u "", + ScaleQuantumToChar(index)); + else + if (image->depth <= 16) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u "",ScaleQuantumToShort(index)); + else + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u "",ScaleQuantumToLong(index)); + extent=(size_t) count; + (void) strncpy((char *) q,buffer,extent); + q+=extent; + if ((q-pixels+extent+2) >= sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + } + p+=GetPixelChannels(image); + } + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (q != pixels) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + } + break; + } + case '3': + { + unsigned char + pixels[2048]; + + /* + Convert image to a PNM image. + */ + (void) TransformImageColorspace(image,sRGBColorspace,exception); + if (image->depth <= 8) + (void) WriteBlobString(image,""255\n""); + else + if (image->depth <= 16) + (void) WriteBlobString(image,""65535\n""); + else + (void) WriteBlobString(image,""4294967295\n""); + q=pixels; + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + if (image->depth <= 8) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u %u %u "",ScaleQuantumToChar(GetPixelRed(image,p)), + ScaleQuantumToChar(GetPixelGreen(image,p)), + ScaleQuantumToChar(GetPixelBlue(image,p))); + else + if (image->depth <= 16) + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u %u %u "",ScaleQuantumToShort(GetPixelRed(image,p)), + ScaleQuantumToShort(GetPixelGreen(image,p)), + ScaleQuantumToShort(GetPixelBlue(image,p))); + else + count=(ssize_t) FormatLocaleString(buffer,MagickPathExtent, + ""%u %u %u "",ScaleQuantumToLong(GetPixelRed(image,p)), + ScaleQuantumToLong(GetPixelGreen(image,p)), + ScaleQuantumToLong(GetPixelBlue(image,p))); + extent=(size_t) count; + (void) strncpy((char *) q,buffer,extent); + q+=extent; + if ((q-pixels+extent+2) >= sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + } + p+=GetPixelChannels(image); + } + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + q=pixels; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + if (q != pixels) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); + } + break; + } + case '4': + { + register unsigned char + *pixels; + + /* + Convert image to a PBM image. + */ + (void) SetImageType(image,BilevelType,exception); + image->depth=1; + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + quantum_info->min_is_white=MagickTrue; + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + GrayQuantum,pixels,exception); + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case '5': + { + register unsigned char + *pixels; + + /* + Convert image to a PGM image. + */ + if (image->depth > 32) + image->depth=32; + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g\n"",(double) + ((MagickOffsetType) GetQuantumRange(image->depth))); + (void) WriteBlobString(image,buffer); + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + quantum_info->min_is_white=MagickTrue; + pixels=GetQuantumPixels(quantum_info); + extent=GetQuantumExtent(image,quantum_info,GrayQuantum); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + q=pixels; + switch (image->depth) + { + case 8: + case 16: + case 32: + { + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + GrayQuantum,pixels,exception); + break; + } + default: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + if (IsPixelGray(image,p) == MagickFalse) + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma( + image,p)),max_value); + else + { + if (image->depth == 8) + pixel=ScaleQuantumToChar(GetPixelRed(image,p)); + else + pixel=ScaleQuantumToAny(GetPixelRed(image,p), + max_value); + } + q=PopCharPixel((unsigned char) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + if (IsPixelGray(image,p) == MagickFalse) + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image, + p)),max_value); + else + { + if (image->depth == 16) + pixel=ScaleQuantumToShort(GetPixelRed(image,p)); + else + pixel=ScaleQuantumToAny(GetPixelRed(image,p), + max_value); + } + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + if (IsPixelGray(image,p) == MagickFalse) + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p)), + max_value); + else + { + if (image->depth == 16) + pixel=ScaleQuantumToLong(GetPixelRed(image,p)); + else + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + } + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + } + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case '6': + { + register unsigned char + *pixels; + + /* + Convert image to a PNM image. + */ + (void) TransformImageColorspace(image,sRGBColorspace,exception); + if (image->depth > 32) + image->depth=32; + (void) FormatLocaleString(buffer,MagickPathExtent,""%.20g\n"",(double) + ((MagickOffsetType) GetQuantumRange(image->depth))); + (void) WriteBlobString(image,buffer); + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + pixels=GetQuantumPixels(quantum_info); + extent=GetQuantumExtent(image,quantum_info,quantum_type); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + q=pixels; + switch (image->depth) + { + case 8: + case 16: + case 32: + { + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + break; + } + default: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + p+=GetPixelChannels(image); + } + extent=(size_t) (q-pixels); + break; + } + } + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case '7': + { + register unsigned char + *pixels; + + /* + Convert image to a PAM. + */ + if (image->depth > 32) + image->depth=32; + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + (void) SetQuantumEndian(image,quantum_info,MSBEndian); + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + register const Quantum + *magick_restrict p; + + register ssize_t + x; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + q=pixels; + switch (image->depth) + { + case 8: + case 16: + case 32: + { + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + break; + } + default: + { + switch (quantum_type) + { + case GrayQuantum: + case GrayAlphaQuantum: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma( + image,p)),max_value); + q=PopCharPixel((unsigned char) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=(unsigned char) ScaleQuantumToAny( + GetPixelAlpha(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma( + image,p)),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=(unsigned char) ScaleQuantumToAny( + GetPixelAlpha(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image, + p)),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=(unsigned char) ScaleQuantumToAny( + GetPixelAlpha(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + case CMYKQuantum: + case CMYKAQuantum: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlack(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlack(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlack(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + default: + { + if (image->depth <= 8) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopCharPixel((unsigned char) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + if (image->depth <= 16) + { + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopShortPixel(MSBEndian,(unsigned short) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + pixel=ScaleQuantumToAny(GetPixelRed(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelGreen(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + pixel=ScaleQuantumToAny(GetPixelBlue(image,p),max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + if (image->alpha_trait != UndefinedPixelTrait) + { + pixel=ScaleQuantumToAny(GetPixelAlpha(image,p), + max_value); + q=PopLongPixel(MSBEndian,(unsigned int) pixel,q); + } + p+=GetPixelChannels(image); + } + break; + } + } + extent=(size_t) (q-pixels); + break; + } + } + count=WriteBlob(image,extent,pixels); + if (count != (ssize_t) extent) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + case 'F': + case 'f': + { + register unsigned char + *pixels; + + (void) WriteBlobString(image,image->endian == LSBEndian ? ""-1.0\n"" : + ""1.0\n""); + image->depth=32; + quantum_type=format == 'f' ? GrayQuantum : RGBQuantum; + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat); + if (status == MagickFalse) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + pixels=GetQuantumPixels(quantum_info); + for (y=(ssize_t) image->rows-1; y >= 0; y--) + { + register const Quantum + *magick_restrict p; + + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + (void) WriteBlob(image,extent,pixels); + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + } + if (GetNextImageInList(image) == (Image *) NULL) + break; + image=SyncNextImageInList(image); + status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); + if (status == MagickFalse) + break; + } while (image_info->adjoin != MagickFalse); + (void) CloseBlob(image); + return(MagickTrue); +} +","@@ -1826,7 +1826,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image, + extent=(size_t) count; + (void) strncpy((char *) q,buffer,extent); + q+=extent; +- if ((q-pixels+extent+1) >= sizeof(pixels)) ++ if ((q-pixels+extent+2) >= sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels); +@@ -1901,7 +1901,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image, + extent=(size_t) count; + (void) strncpy((char *) q,buffer,extent); + q+=extent; +- if ((q-pixels+extent+1) >= sizeof(pixels)) ++ if ((q-pixels+extent+2) >= sizeof(pixels)) + { + *q++='\n'; + (void) WriteBlob(image,q-pixels,pixels);",7486,7722,8192 +17552,"WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec, + WORD32 i4_poc, + pocstruct_t *ps_temp_poc, + UWORD16 u2_frame_num, + dec_pic_params_t *ps_pps) +{ + pocstruct_t *ps_prev_poc = &ps_dec->s_cur_pic_poc; + pocstruct_t *ps_cur_poc = ps_temp_poc; + + pic_buffer_t *pic_buf; + + ivd_video_decode_op_t * ps_dec_output = + (ivd_video_decode_op_t *)ps_dec->pv_dec_out; + dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice; + dec_seq_params_t *ps_seq = ps_pps->ps_sps; + UWORD8 u1_bottom_field_flag = ps_cur_slice->u1_bottom_field_flag; + UWORD8 u1_field_pic_flag = ps_cur_slice->u1_field_pic_flag; + /* high profile related declarations */ + high_profile_tools_t s_high_profile; + WORD32 ret; + + H264_MUTEX_LOCK(&ps_dec->process_disp_mutex); + + ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb; + ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb; + ps_prev_poc->i4_delta_pic_order_cnt_bottom = + ps_cur_poc->i4_delta_pic_order_cnt_bottom; + ps_prev_poc->i4_delta_pic_order_cnt[0] = + ps_cur_poc->i4_delta_pic_order_cnt[0]; + ps_prev_poc->i4_delta_pic_order_cnt[1] = + ps_cur_poc->i4_delta_pic_order_cnt[1]; + ps_prev_poc->u1_bot_field = ps_dec->ps_cur_slice->u1_bottom_field_flag; + ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst; + ps_prev_poc->u2_frame_num = u2_frame_num; + ps_dec->i1_prev_mb_qp_delta = 0; + ps_dec->i1_next_ctxt_idx = 0; + + + ps_dec->u4_nmb_deblk = 0; + if(ps_dec->u4_num_cores == 1) + ps_dec->u4_nmb_deblk = 1; + + + + if(ps_seq->u1_mb_aff_flag == 1) + { + ps_dec->u4_nmb_deblk = 0; + if(ps_dec->u4_num_cores > 2) + ps_dec->u4_num_cores = 2; + } + + ps_dec->u4_use_intrapred_line_copy = 0; + + + + if (ps_seq->u1_mb_aff_flag == 0) + { + ps_dec->u4_use_intrapred_line_copy = 1; + } + + ps_dec->u4_app_disable_deblk_frm = 0; + /* If degrade is enabled, set the degrade flags appropriately */ + if(ps_dec->i4_degrade_type && ps_dec->i4_degrade_pics) + { + WORD32 degrade_pic; + ps_dec->i4_degrade_pic_cnt++; + degrade_pic = 0; + + /* If degrade is to be done in all frames, then do not check further */ + switch(ps_dec->i4_degrade_pics) + { + case 4: + { + degrade_pic = 1; + break; + } + case 3: + { + if(ps_cur_slice->u1_slice_type != I_SLICE) + degrade_pic = 1; + + break; + } + case 2: + { + + /* If pic count hits non-degrade interval or it is an islice, then do not degrade */ + if((ps_cur_slice->u1_slice_type != I_SLICE) + && (ps_dec->i4_degrade_pic_cnt + != ps_dec->i4_nondegrade_interval)) + degrade_pic = 1; + + break; + } + case 1: + { + /* Check if the current picture is non-ref */ + if(0 == ps_cur_slice->u1_nal_ref_idc) + { + degrade_pic = 1; + } + break; + } + + } + if(degrade_pic) + { + if(ps_dec->i4_degrade_type & 0x2) + ps_dec->u4_app_disable_deblk_frm = 1; + + /* MC degrading is done only for non-ref pictures */ + if(0 == ps_cur_slice->u1_nal_ref_idc) + { + if(ps_dec->i4_degrade_type & 0x4) + ps_dec->i4_mv_frac_mask = 0; + + if(ps_dec->i4_degrade_type & 0x8) + ps_dec->i4_mv_frac_mask = 0; + } + } + else + ps_dec->i4_degrade_pic_cnt = 0; + } + + { + dec_err_status_t * ps_err = ps_dec->ps_dec_err_status; + if(ps_dec->u1_sl_typ_5_9 + && ((ps_cur_slice->u1_slice_type == I_SLICE) + || (ps_cur_slice->u1_slice_type + == SI_SLICE))) + ps_err->u1_cur_pic_type = PIC_TYPE_I; + else + ps_err->u1_cur_pic_type = PIC_TYPE_UNKNOWN; + + if(ps_err->u1_pic_aud_i == PIC_TYPE_I) + { + ps_err->u1_cur_pic_type = PIC_TYPE_I; + ps_err->u1_pic_aud_i = PIC_TYPE_UNKNOWN; + } + + if(ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL) + { + if(ps_err->u1_err_flag) + ih264d_reset_ref_bufs(ps_dec->ps_dpb_mgr); + ps_err->u1_err_flag = ACCEPT_ALL_PICS; + } + } + + if(ps_dec->u1_init_dec_flag && ps_dec->s_prev_seq_params.u1_eoseq_pending) + { + /* Reset the decoder picture buffers */ + WORD32 j; + for(j = 0; j < MAX_DISP_BUFS_NEW; j++) + { + + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + ps_dec->au1_pic_buf_id_mv_buf_id_map[j], + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_IO); + } + + /* reset the decoder structure parameters related to buffer handling */ + ps_dec->u1_second_field = 0; + ps_dec->i4_cur_display_seq = 0; + + /********************************************************************/ + /* indicate in the decoder output i4_status that some frames are being */ + /* dropped, so that it resets timestamp and wait for a new sequence */ + /********************************************************************/ + + ps_dec->s_prev_seq_params.u1_eoseq_pending = 0; + } + ret = ih264d_init_pic(ps_dec, u2_frame_num, i4_poc, ps_pps); + if(ret != OK) + return ret; + + ps_dec->pv_parse_tu_coeff_data = ps_dec->pv_pic_tu_coeff_data; + ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_pic_tu_coeff_data; + ps_dec->ps_nmb_info = ps_dec->ps_frm_mb_info; + if(ps_dec->u1_separate_parse) + { + UWORD16 pic_wd = ps_dec->u4_width_at_init; + UWORD16 pic_ht = ps_dec->u4_height_at_init; + UWORD32 num_mbs; + + if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid))) + { + pic_wd = ps_dec->u2_pic_wd; + pic_ht = ps_dec->u2_pic_ht; + } + num_mbs = (pic_wd * pic_ht) >> 8; + + if(ps_dec->pu1_dec_mb_map) + { + memset((void *)ps_dec->pu1_dec_mb_map, 0, num_mbs); + } + + if(ps_dec->pu1_recon_mb_map) + { + + memset((void *)ps_dec->pu1_recon_mb_map, 0, num_mbs); + } + + if(ps_dec->pu2_slice_num_map) + { + memset((void *)ps_dec->pu2_slice_num_map, 0, + (num_mbs * sizeof(UWORD16))); + } + + } + + ps_dec->ps_parse_cur_slice = &(ps_dec->ps_dec_slice_buf[0]); + ps_dec->ps_decode_cur_slice = &(ps_dec->ps_dec_slice_buf[0]); + ps_dec->ps_computebs_cur_slice = &(ps_dec->ps_dec_slice_buf[0]); + ps_dec->u2_cur_slice_num = 0; + + /* Initialize all the HP toolsets to zero */ + ps_dec->s_high_profile.u1_scaling_present = 0; + ps_dec->s_high_profile.u1_transform8x8_present = 0; + + /* Get Next Free Picture */ + if(1 == ps_dec->u4_share_disp_buf) + { + UWORD32 i; + /* Free any buffer that is in the queue to be freed */ + for(i = 0; i < MAX_DISP_BUFS_NEW; i++) + { + if(0 == ps_dec->u4_disp_buf_to_be_freed[i]) + continue; + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, i, + BUF_MGR_IO); + ps_dec->u4_disp_buf_to_be_freed[i] = 0; + ps_dec->u4_disp_buf_mapping[i] = 0; + + } + } + if(!(u1_field_pic_flag && 0 != ps_dec->u1_top_bottom_decoded)) //ps_dec->u1_second_field)) + { + pic_buffer_t *ps_cur_pic; + WORD32 cur_pic_buf_id, cur_mv_buf_id; + col_mv_buf_t *ps_col_mv; + while(1) + { + ps_cur_pic = (pic_buffer_t *)ih264_buf_mgr_get_next_free( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + &cur_pic_buf_id); + if(ps_cur_pic == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_PICBUF_T; + return ERROR_UNAVAIL_PICBUF_T; + } + if(0 == ps_dec->u4_disp_buf_mapping[cur_pic_buf_id]) + { + break; + } + + } + ps_col_mv = (col_mv_buf_t *)ih264_buf_mgr_get_next_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + &cur_mv_buf_id); + if(ps_col_mv == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_MVBUF_T; + return ERROR_UNAVAIL_MVBUF_T; + } + + ps_dec->ps_cur_pic = ps_cur_pic; + ps_dec->u1_pic_buf_id = cur_pic_buf_id; + ps_cur_pic->u4_ts = ps_dec->u4_ts; + + + ps_cur_pic->u1_mv_buf_id = cur_mv_buf_id; + ps_dec->au1_pic_buf_id_mv_buf_id_map[cur_pic_buf_id] = cur_mv_buf_id; + + ps_cur_pic->pu1_col_zero_flag = (UWORD8 *)ps_col_mv->pv_col_zero_flag; + ps_cur_pic->ps_mv = (mv_pred_t *)ps_col_mv->pv_mv; + ps_dec->au1_pic_buf_ref_flag[cur_pic_buf_id] = 0; + if(ps_dec->u1_first_slice_in_stream) + { + /*make first entry of list0 point to cur pic,so that if first Islice is in error, ref pic struct will have valid entries*/ + ps_dec->ps_ref_pic_buf_lx[0] = ps_dec->ps_dpb_mgr->ps_init_dpb[0]; + *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][0]) = *ps_cur_pic; + /* Initialize for field reference as well */ + *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][MAX_REF_BUFS]) = *ps_cur_pic; + } + + if(!ps_dec->ps_cur_pic) + { + WORD32 j; + H264_DEC_DEBUG_PRINT(""------- Display Buffers Reset --------\n""); + for(j = 0; j < MAX_DISP_BUFS_NEW; j++) + { + + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + ps_dec->au1_pic_buf_id_mv_buf_id_map[j], + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_IO); + } + + ps_dec->i4_cur_display_seq = 0; + ps_dec->i4_prev_max_display_seq = 0; + ps_dec->i4_max_poc = 0; + + ps_cur_pic = (pic_buffer_t *)ih264_buf_mgr_get_next_free( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + &cur_pic_buf_id); + if(ps_cur_pic == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_PICBUF_T; + return ERROR_UNAVAIL_PICBUF_T; + } + + ps_col_mv = (col_mv_buf_t *)ih264_buf_mgr_get_next_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + &cur_mv_buf_id); + if(ps_col_mv == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_MVBUF_T; + return ERROR_UNAVAIL_MVBUF_T; + } + + ps_dec->ps_cur_pic = ps_cur_pic; + ps_dec->u1_pic_buf_id = cur_pic_buf_id; + ps_cur_pic->u4_ts = ps_dec->u4_ts; + ps_dec->apv_buf_id_pic_buf_map[cur_pic_buf_id] = (void *)ps_cur_pic; + + ps_cur_pic->u1_mv_buf_id = cur_mv_buf_id; + ps_dec->au1_pic_buf_id_mv_buf_id_map[cur_pic_buf_id] = cur_mv_buf_id; + + ps_cur_pic->pu1_col_zero_flag = (UWORD8 *)ps_col_mv->pv_col_zero_flag; + ps_cur_pic->ps_mv = (mv_pred_t *)ps_col_mv->pv_mv; + ps_dec->au1_pic_buf_ref_flag[cur_pic_buf_id] = 0; + + } + + ps_dec->ps_cur_pic->u1_picturetype = u1_field_pic_flag; + ps_dec->ps_cur_pic->u4_pack_slc_typ = SKIP_NONE; + H264_DEC_DEBUG_PRINT(""got a buffer\n""); + } + else + { + H264_DEC_DEBUG_PRINT(""did not get a buffer\n""); + } + + ps_dec->u4_pic_buf_got = 1; + + ps_dec->ps_cur_pic->i4_poc = i4_poc; + ps_dec->ps_cur_pic->i4_frame_num = u2_frame_num; + ps_dec->ps_cur_pic->i4_pic_num = u2_frame_num; + ps_dec->ps_cur_pic->i4_top_field_order_cnt = ps_pps->i4_top_field_order_cnt; + ps_dec->ps_cur_pic->i4_bottom_field_order_cnt = + ps_pps->i4_bottom_field_order_cnt; + ps_dec->ps_cur_pic->i4_avg_poc = ps_pps->i4_avg_poc; + ps_dec->ps_cur_pic->u4_time_stamp = ps_dec->u4_pts; + + ps_dec->s_cur_pic = *(ps_dec->ps_cur_pic); + if(u1_field_pic_flag && u1_bottom_field_flag) + { + WORD32 i4_temp_poc; + WORD32 i4_top_field_order_poc, i4_bot_field_order_poc; + /* Point to odd lines, since it's bottom field */ + ps_dec->s_cur_pic.pu1_buf1 += ps_dec->s_cur_pic.u2_frm_wd_y; + ps_dec->s_cur_pic.pu1_buf2 += ps_dec->s_cur_pic.u2_frm_wd_uv; + ps_dec->s_cur_pic.pu1_buf3 += ps_dec->s_cur_pic.u2_frm_wd_uv; + ps_dec->s_cur_pic.ps_mv += + ((ps_dec->u2_pic_ht * ps_dec->u2_pic_wd) >> 5); + ps_dec->s_cur_pic.pu1_col_zero_flag += ((ps_dec->u2_pic_ht + * ps_dec->u2_pic_wd) >> 5); + ps_dec->ps_cur_pic->u1_picturetype |= BOT_FLD; + i4_top_field_order_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt; + i4_bot_field_order_poc = ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + i4_temp_poc = MIN(i4_top_field_order_poc, + i4_bot_field_order_poc); + ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc; + } + + ps_cur_slice->u1_mbaff_frame_flag = ps_seq->u1_mb_aff_flag + && (!u1_field_pic_flag); + + ps_dec->ps_cur_pic->u1_picturetype |= (ps_cur_slice->u1_mbaff_frame_flag + << 2); + + ps_dec->ps_cur_mb_row = ps_dec->ps_nbr_mb_row; //[0]; + ps_dec->ps_cur_mb_row++; //Increment by 1 ,so that left mb will always be valid + ps_dec->ps_top_mb_row = + ps_dec->ps_nbr_mb_row + + ((ps_dec->u2_frm_wd_in_mbs + 1) + << (1 + - ps_dec->ps_cur_sps->u1_frame_mbs_only_flag)); + ps_dec->ps_top_mb_row++; //Increment by 1 ,so that left mb will always be valid + + ps_dec->pu1_y = ps_dec->pu1_y_scratch[0]; + ps_dec->pu1_u = ps_dec->pu1_u_scratch[0]; + ps_dec->pu1_v = ps_dec->pu1_v_scratch[0]; + ps_dec->u1_yuv_scratch_idx = 0; + /* CHANGED CODE */ + ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv; + ps_dec->ps_mv_top = ps_dec->ps_mv_top_p[0]; + /* CHANGED CODE */ + ps_dec->u1_mv_top_p = 0; + ps_dec->u1_mb_idx = 0; + /* CHANGED CODE */ + ps_dec->ps_mv_left = ps_dec->s_cur_pic.ps_mv; + ps_dec->pu1_yleft = 0; + ps_dec->pu1_uleft = 0; + ps_dec->pu1_vleft = 0; + ps_dec->u1_not_wait_rec = 2; + ps_dec->u2_total_mbs_coded = 0; + ps_dec->i4_submb_ofst = -(SUB_BLK_SIZE); + ps_dec->u4_pred_info_idx = 0; + ps_dec->u4_pred_info_pkd_idx = 0; + ps_dec->u4_dma_buf_idx = 0; + ps_dec->ps_mv = ps_dec->s_cur_pic.ps_mv; + ps_dec->ps_mv_bank_cur = ps_dec->s_cur_pic.ps_mv; + ps_dec->pu1_col_zero_flag = ps_dec->s_cur_pic.pu1_col_zero_flag; + ps_dec->ps_part = ps_dec->ps_parse_part_params; + ps_dec->i2_prev_slice_mbx = -1; + ps_dec->i2_prev_slice_mby = 0; + ps_dec->u2_mv_2mb[0] = 0; + ps_dec->u2_mv_2mb[1] = 0; + ps_dec->u1_last_pic_not_decoded = 0; + + ps_dec->u2_cur_slice_num_dec_thread = 0; + ps_dec->u2_cur_slice_num_bs = 0; + ps_dec->u4_intra_pred_line_ofst = 0; + ps_dec->pu1_cur_y_intra_pred_line = ps_dec->pu1_y_intra_pred_line; + ps_dec->pu1_cur_u_intra_pred_line = ps_dec->pu1_u_intra_pred_line; + ps_dec->pu1_cur_v_intra_pred_line = ps_dec->pu1_v_intra_pred_line; + + ps_dec->pu1_cur_y_intra_pred_line_base = ps_dec->pu1_y_intra_pred_line; + ps_dec->pu1_cur_u_intra_pred_line_base = ps_dec->pu1_u_intra_pred_line; + ps_dec->pu1_cur_v_intra_pred_line_base = ps_dec->pu1_v_intra_pred_line; + + + + + + ps_dec->pu1_prev_y_intra_pred_line = ps_dec->pu1_y_intra_pred_line + + (ps_dec->u2_frm_wd_in_mbs * MB_SIZE); + + ps_dec->pu1_prev_u_intra_pred_line = ps_dec->pu1_u_intra_pred_line + + ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE * YUV420SP_FACTOR; + ps_dec->pu1_prev_v_intra_pred_line = ps_dec->pu1_v_intra_pred_line + + ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE; + + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic; + ps_dec->ps_deblk_mbn_curr = ps_dec->ps_deblk_mbn; + ps_dec->ps_deblk_mbn_prev = ps_dec->ps_deblk_mbn + ps_dec->u1_recon_mb_grp; + /* Initialize The Function Pointer Depending Upon the Entropy and MbAff Flag */ + { + if(ps_cur_slice->u1_mbaff_frame_flag) + { + ps_dec->pf_compute_bs = ih264d_compute_bs_mbaff; + ps_dec->pf_mvpred = ih264d_mvpred_mbaff; + } + else + { + ps_dec->pf_compute_bs = ih264d_compute_bs_non_mbaff; + ps_dec->u1_cur_mb_fld_dec_flag = ps_cur_slice->u1_field_pic_flag; + } + } + /* Set up the Parameter for DMA transfer */ + { + UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; + + UWORD8 u1_mbaff = ps_cur_slice->u1_mbaff_frame_flag; + + UWORD8 uc_lastmbs = (((ps_dec->u2_pic_wd) >> 4) + % (ps_dec->u1_recon_mb_grp >> u1_mbaff)); + UWORD16 ui16_lastmbs_widthY = + (uc_lastmbs ? (uc_lastmbs << 4) : ((ps_dec->u1_recon_mb_grp + >> u1_mbaff) << 4)); + UWORD16 ui16_lastmbs_widthUV = + uc_lastmbs ? (uc_lastmbs << 3) : ((ps_dec->u1_recon_mb_grp + >> u1_mbaff) << 3); + + ps_dec->s_tran_addrecon.pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1; + ps_dec->s_tran_addrecon.pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2; + ps_dec->s_tran_addrecon.pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3; + + ps_dec->s_tran_addrecon.u2_frm_wd_y = ps_dec->u2_frm_wd_y + << u1_field_pic_flag; + ps_dec->s_tran_addrecon.u2_frm_wd_uv = ps_dec->u2_frm_wd_uv + << u1_field_pic_flag; + + if(u1_field_pic_flag) + { + ui16_lastmbs_widthY += ps_dec->u2_frm_wd_y; + ui16_lastmbs_widthUV += ps_dec->u2_frm_wd_uv; + } + + /* Normal Increment of Pointer */ + ps_dec->s_tran_addrecon.u4_inc_y[0] = ((ps_dec->u1_recon_mb_grp << 4) + >> u1_mbaff); + ps_dec->s_tran_addrecon.u4_inc_uv[0] = ((ps_dec->u1_recon_mb_grp << 4) + >> u1_mbaff); + + /* End of Row Increment */ + ps_dec->s_tran_addrecon.u4_inc_y[1] = (ui16_lastmbs_widthY + + (PAD_LEN_Y_H << 1) + + ps_dec->s_tran_addrecon.u2_frm_wd_y + * ((15 << u1_mbaff) + u1_mbaff)); + ps_dec->s_tran_addrecon.u4_inc_uv[1] = (ui16_lastmbs_widthUV + + (PAD_LEN_UV_H << 2) + + ps_dec->s_tran_addrecon.u2_frm_wd_uv + * ((15 << u1_mbaff) + u1_mbaff)); + + /* Assign picture numbers to each frame/field */ + /* only once per picture. */ + ih264d_assign_pic_num(ps_dec); + ps_dec->s_tran_addrecon.u2_mv_top_left_inc = (ps_dec->u1_recon_mb_grp + << 2) - 1 - (u1_mbaff << 2); + ps_dec->s_tran_addrecon.u2_mv_left_inc = ((ps_dec->u1_recon_mb_grp + >> u1_mbaff) - 1) << (4 + u1_mbaff); + } + /**********************************************************************/ + /* High profile related initialization at pictrue level */ + /**********************************************************************/ + if(ps_seq->u1_profile_idc == HIGH_PROFILE_IDC) + { + if((ps_seq->i4_seq_scaling_matrix_present_flag) + || (ps_pps->i4_pic_scaling_matrix_present_flag)) + { + ih264d_form_scaling_matrix_picture(ps_seq, ps_pps, ps_dec); + ps_dec->s_high_profile.u1_scaling_present = 1; + } + else + { + ih264d_form_default_scaling_matrix(ps_dec); + } + + if(ps_pps->i4_transform_8x8_mode_flag) + { + ps_dec->s_high_profile.u1_transform8x8_present = 1; + } + } + else + { + ih264d_form_default_scaling_matrix(ps_dec); + } + + /* required while reading the transform_size_8x8 u4_flag */ + ps_dec->s_high_profile.u1_direct_8x8_inference_flag = + ps_seq->u1_direct_8x8_inference_flag; + ps_dec->s_high_profile.s_cavlc_ctxt = ps_dec->s_cavlc_ctxt; + + ps_dec->i1_recon_in_thread3_flag = 1; + ps_dec->ps_frame_buf_ip_recon = &ps_dec->s_tran_addrecon; + if(ps_dec->u1_separate_parse) + { + memcpy(&ps_dec->s_tran_addrecon_parse, &ps_dec->s_tran_addrecon, + sizeof(tfr_ctxt_t)); + if(ps_dec->u4_num_cores >= 3 && ps_dec->i1_recon_in_thread3_flag) + { + memcpy(&ps_dec->s_tran_iprecon, &ps_dec->s_tran_addrecon, + sizeof(tfr_ctxt_t)); + ps_dec->ps_frame_buf_ip_recon = &ps_dec->s_tran_iprecon; + } + } + + + ih264d_init_deblk_tfr_ctxt(ps_dec,&(ps_dec->s_pad_mgr), &(ps_dec->s_tran_addrecon), + ps_dec->u2_frm_wd_in_mbs, 0); + + ps_dec->ps_cur_deblk_mb = ps_dec->ps_deblk_pic; + ps_dec->u4_cur_deblk_mb_num = 0; + + ps_dec->u4_deblk_mb_x = 0; + ps_dec->u4_deblk_mb_y = 0; + ps_dec->pu4_wt_ofsts = ps_dec->pu4_wts_ofsts_mat; + + H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex); + return OK; +} +",0,"WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec, + WORD32 i4_poc, + pocstruct_t *ps_temp_poc, + UWORD16 u2_frame_num, + dec_pic_params_t *ps_pps) +{ + pocstruct_t *ps_prev_poc = &ps_dec->s_cur_pic_poc; + pocstruct_t *ps_cur_poc = ps_temp_poc; + + pic_buffer_t *pic_buf; + + ivd_video_decode_op_t * ps_dec_output = + (ivd_video_decode_op_t *)ps_dec->pv_dec_out; + dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice; + dec_seq_params_t *ps_seq = ps_pps->ps_sps; + UWORD8 u1_bottom_field_flag = ps_cur_slice->u1_bottom_field_flag; + UWORD8 u1_field_pic_flag = ps_cur_slice->u1_field_pic_flag; + /* high profile related declarations */ + high_profile_tools_t s_high_profile; + WORD32 ret; + + H264_MUTEX_LOCK(&ps_dec->process_disp_mutex); + + ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb; + ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb; + ps_prev_poc->i4_delta_pic_order_cnt_bottom = + ps_cur_poc->i4_delta_pic_order_cnt_bottom; + ps_prev_poc->i4_delta_pic_order_cnt[0] = + ps_cur_poc->i4_delta_pic_order_cnt[0]; + ps_prev_poc->i4_delta_pic_order_cnt[1] = + ps_cur_poc->i4_delta_pic_order_cnt[1]; + ps_prev_poc->u1_bot_field = ps_dec->ps_cur_slice->u1_bottom_field_flag; + ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst; + ps_prev_poc->u2_frame_num = u2_frame_num; + ps_dec->i1_prev_mb_qp_delta = 0; + ps_dec->i1_next_ctxt_idx = 0; + + + ps_dec->u4_nmb_deblk = 0; + if(ps_dec->u4_num_cores == 1) + ps_dec->u4_nmb_deblk = 1; + + + + if(ps_seq->u1_mb_aff_flag == 1) + { + ps_dec->u4_nmb_deblk = 0; + if(ps_dec->u4_num_cores > 2) + ps_dec->u4_num_cores = 2; + } + + ps_dec->u4_use_intrapred_line_copy = 0; + + + + if (ps_seq->u1_mb_aff_flag == 0) + { + ps_dec->u4_use_intrapred_line_copy = 1; + } + + ps_dec->u4_app_disable_deblk_frm = 0; + /* If degrade is enabled, set the degrade flags appropriately */ + if(ps_dec->i4_degrade_type && ps_dec->i4_degrade_pics) + { + WORD32 degrade_pic; + ps_dec->i4_degrade_pic_cnt++; + degrade_pic = 0; + + /* If degrade is to be done in all frames, then do not check further */ + switch(ps_dec->i4_degrade_pics) + { + case 4: + { + degrade_pic = 1; + break; + } + case 3: + { + if(ps_cur_slice->u1_slice_type != I_SLICE) + degrade_pic = 1; + + break; + } + case 2: + { + + /* If pic count hits non-degrade interval or it is an islice, then do not degrade */ + if((ps_cur_slice->u1_slice_type != I_SLICE) + && (ps_dec->i4_degrade_pic_cnt + != ps_dec->i4_nondegrade_interval)) + degrade_pic = 1; + + break; + } + case 1: + { + /* Check if the current picture is non-ref */ + if(0 == ps_cur_slice->u1_nal_ref_idc) + { + degrade_pic = 1; + } + break; + } + + } + if(degrade_pic) + { + if(ps_dec->i4_degrade_type & 0x2) + ps_dec->u4_app_disable_deblk_frm = 1; + + /* MC degrading is done only for non-ref pictures */ + if(0 == ps_cur_slice->u1_nal_ref_idc) + { + if(ps_dec->i4_degrade_type & 0x4) + ps_dec->i4_mv_frac_mask = 0; + + if(ps_dec->i4_degrade_type & 0x8) + ps_dec->i4_mv_frac_mask = 0; + } + } + else + ps_dec->i4_degrade_pic_cnt = 0; + } + + { + dec_err_status_t * ps_err = ps_dec->ps_dec_err_status; + if(ps_dec->u1_sl_typ_5_9 + && ((ps_cur_slice->u1_slice_type == I_SLICE) + || (ps_cur_slice->u1_slice_type + == SI_SLICE))) + ps_err->u1_cur_pic_type = PIC_TYPE_I; + else + ps_err->u1_cur_pic_type = PIC_TYPE_UNKNOWN; + + if(ps_err->u1_pic_aud_i == PIC_TYPE_I) + { + ps_err->u1_cur_pic_type = PIC_TYPE_I; + ps_err->u1_pic_aud_i = PIC_TYPE_UNKNOWN; + } + + if(ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL) + { + if(ps_err->u1_err_flag) + ih264d_reset_ref_bufs(ps_dec->ps_dpb_mgr); + ps_err->u1_err_flag = ACCEPT_ALL_PICS; + } + } + + if(ps_dec->u1_init_dec_flag && ps_dec->s_prev_seq_params.u1_eoseq_pending) + { + /* Reset the decoder picture buffers */ + WORD32 j; + for(j = 0; j < MAX_DISP_BUFS_NEW; j++) + { + + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + ps_dec->au1_pic_buf_id_mv_buf_id_map[j], + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_IO); + } + + /* reset the decoder structure parameters related to buffer handling */ + ps_dec->u1_second_field = 0; + ps_dec->i4_cur_display_seq = 0; + + /********************************************************************/ + /* indicate in the decoder output i4_status that some frames are being */ + /* dropped, so that it resets timestamp and wait for a new sequence */ + /********************************************************************/ + + ps_dec->s_prev_seq_params.u1_eoseq_pending = 0; + } + ret = ih264d_init_pic(ps_dec, u2_frame_num, i4_poc, ps_pps); + if(ret != OK) + return ret; + + ps_dec->pv_parse_tu_coeff_data = ps_dec->pv_pic_tu_coeff_data; + ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_pic_tu_coeff_data; + ps_dec->ps_nmb_info = ps_dec->ps_frm_mb_info; + if(ps_dec->u1_separate_parse) + { + UWORD16 pic_wd = ps_dec->u4_width_at_init; + UWORD16 pic_ht = ps_dec->u4_height_at_init; + UWORD32 num_mbs; + + if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid))) + { + pic_wd = ps_dec->u2_pic_wd; + pic_ht = ps_dec->u2_pic_ht; + } + num_mbs = (pic_wd * pic_ht) >> 8; + + if(ps_dec->pu1_dec_mb_map) + { + memset((void *)ps_dec->pu1_dec_mb_map, 0, num_mbs); + } + + if(ps_dec->pu1_recon_mb_map) + { + + memset((void *)ps_dec->pu1_recon_mb_map, 0, num_mbs); + } + + if(ps_dec->pu2_slice_num_map) + { + memset((void *)ps_dec->pu2_slice_num_map, 0, + (num_mbs * sizeof(UWORD16))); + } + + } + + ps_dec->ps_parse_cur_slice = &(ps_dec->ps_dec_slice_buf[0]); + ps_dec->ps_decode_cur_slice = &(ps_dec->ps_dec_slice_buf[0]); + ps_dec->ps_computebs_cur_slice = &(ps_dec->ps_dec_slice_buf[0]); + ps_dec->u2_cur_slice_num = 0; + + /* Initialize all the HP toolsets to zero */ + ps_dec->s_high_profile.u1_scaling_present = 0; + ps_dec->s_high_profile.u1_transform8x8_present = 0; + + /* Get Next Free Picture */ + if(1 == ps_dec->u4_share_disp_buf) + { + UWORD32 i; + /* Free any buffer that is in the queue to be freed */ + for(i = 0; i < MAX_DISP_BUFS_NEW; i++) + { + if(0 == ps_dec->u4_disp_buf_to_be_freed[i]) + continue; + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, i, + BUF_MGR_IO); + ps_dec->u4_disp_buf_to_be_freed[i] = 0; + ps_dec->u4_disp_buf_mapping[i] = 0; + + } + } + if(!(u1_field_pic_flag && 0 != ps_dec->u1_top_bottom_decoded)) //ps_dec->u1_second_field)) + { + pic_buffer_t *ps_cur_pic; + WORD32 cur_pic_buf_id, cur_mv_buf_id; + col_mv_buf_t *ps_col_mv; + while(1) + { + ps_cur_pic = (pic_buffer_t *)ih264_buf_mgr_get_next_free( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + &cur_pic_buf_id); + if(ps_cur_pic == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_PICBUF_T; + return ERROR_UNAVAIL_PICBUF_T; + } + if(0 == ps_dec->u4_disp_buf_mapping[cur_pic_buf_id]) + { + break; + } + + } + ps_col_mv = (col_mv_buf_t *)ih264_buf_mgr_get_next_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + &cur_mv_buf_id); + if(ps_col_mv == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_MVBUF_T; + return ERROR_UNAVAIL_MVBUF_T; + } + + ps_dec->ps_cur_pic = ps_cur_pic; + ps_dec->u1_pic_buf_id = cur_pic_buf_id; + ps_cur_pic->u4_ts = ps_dec->u4_ts; + + + ps_cur_pic->u1_mv_buf_id = cur_mv_buf_id; + ps_dec->au1_pic_buf_id_mv_buf_id_map[cur_pic_buf_id] = cur_mv_buf_id; + + ps_cur_pic->pu1_col_zero_flag = (UWORD8 *)ps_col_mv->pv_col_zero_flag; + ps_cur_pic->ps_mv = (mv_pred_t *)ps_col_mv->pv_mv; + ps_dec->au1_pic_buf_ref_flag[cur_pic_buf_id] = 0; + if(ps_dec->u1_first_slice_in_stream) + { + /*make first entry of list0 point to cur pic,so that if first Islice is in error, ref pic struct will have valid entries*/ + ps_dec->ps_ref_pic_buf_lx[0] = ps_dec->ps_dpb_mgr->ps_init_dpb[0]; + *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][0]) = *ps_cur_pic; + /* Initialize for field reference as well */ + *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][MAX_REF_BUFS]) = *ps_cur_pic; + } + + if(!ps_dec->ps_cur_pic) + { + WORD32 j; + H264_DEC_DEBUG_PRINT(""------- Display Buffers Reset --------\n""); + for(j = 0; j < MAX_DISP_BUFS_NEW; j++) + { + + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + ps_dec->au1_pic_buf_id_mv_buf_id_map[j], + BUF_MGR_REF); + ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + j, + BUF_MGR_IO); + } + + ps_dec->i4_cur_display_seq = 0; + ps_dec->i4_prev_max_display_seq = 0; + ps_dec->i4_max_poc = 0; + + ps_cur_pic = (pic_buffer_t *)ih264_buf_mgr_get_next_free( + (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, + &cur_pic_buf_id); + if(ps_cur_pic == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_PICBUF_T; + return ERROR_UNAVAIL_PICBUF_T; + } + + ps_col_mv = (col_mv_buf_t *)ih264_buf_mgr_get_next_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr, + &cur_mv_buf_id); + if(ps_col_mv == NULL) + { + ps_dec->i4_error_code = ERROR_UNAVAIL_MVBUF_T; + return ERROR_UNAVAIL_MVBUF_T; + } + + ps_dec->ps_cur_pic = ps_cur_pic; + ps_dec->u1_pic_buf_id = cur_pic_buf_id; + ps_cur_pic->u4_ts = ps_dec->u4_ts; + ps_dec->apv_buf_id_pic_buf_map[cur_pic_buf_id] = (void *)ps_cur_pic; + + ps_cur_pic->u1_mv_buf_id = cur_mv_buf_id; + ps_dec->au1_pic_buf_id_mv_buf_id_map[cur_pic_buf_id] = cur_mv_buf_id; + + ps_cur_pic->pu1_col_zero_flag = (UWORD8 *)ps_col_mv->pv_col_zero_flag; + ps_cur_pic->ps_mv = (mv_pred_t *)ps_col_mv->pv_mv; + ps_dec->au1_pic_buf_ref_flag[cur_pic_buf_id] = 0; + + } + + ps_dec->ps_cur_pic->u1_picturetype = u1_field_pic_flag; + ps_dec->ps_cur_pic->u4_pack_slc_typ = SKIP_NONE; + H264_DEC_DEBUG_PRINT(""got a buffer\n""); + } + else + { + H264_DEC_DEBUG_PRINT(""did not get a buffer\n""); + } + + ps_dec->u4_pic_buf_got = 1; + + ps_dec->ps_cur_pic->i4_poc = i4_poc; + ps_dec->ps_cur_pic->i4_frame_num = u2_frame_num; + ps_dec->ps_cur_pic->i4_pic_num = u2_frame_num; + ps_dec->ps_cur_pic->i4_top_field_order_cnt = ps_pps->i4_top_field_order_cnt; + ps_dec->ps_cur_pic->i4_bottom_field_order_cnt = + ps_pps->i4_bottom_field_order_cnt; + ps_dec->ps_cur_pic->i4_avg_poc = ps_pps->i4_avg_poc; + ps_dec->ps_cur_pic->u4_time_stamp = ps_dec->u4_pts; + + ps_dec->s_cur_pic = *(ps_dec->ps_cur_pic); + if(u1_field_pic_flag && u1_bottom_field_flag) + { + WORD32 i4_temp_poc; + WORD32 i4_top_field_order_poc, i4_bot_field_order_poc; + /* Point to odd lines, since it's bottom field */ + ps_dec->s_cur_pic.pu1_buf1 += ps_dec->s_cur_pic.u2_frm_wd_y; + ps_dec->s_cur_pic.pu1_buf2 += ps_dec->s_cur_pic.u2_frm_wd_uv; + ps_dec->s_cur_pic.pu1_buf3 += ps_dec->s_cur_pic.u2_frm_wd_uv; + ps_dec->s_cur_pic.ps_mv += + ((ps_dec->u2_pic_ht * ps_dec->u2_pic_wd) >> 5); + ps_dec->s_cur_pic.pu1_col_zero_flag += ((ps_dec->u2_pic_ht + * ps_dec->u2_pic_wd) >> 5); + ps_dec->ps_cur_pic->u1_picturetype |= BOT_FLD; + i4_top_field_order_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt; + i4_bot_field_order_poc = ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + i4_temp_poc = MIN(i4_top_field_order_poc, + i4_bot_field_order_poc); + ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc; + } + + ps_cur_slice->u1_mbaff_frame_flag = ps_seq->u1_mb_aff_flag + && (!u1_field_pic_flag); + + ps_dec->ps_cur_pic->u1_picturetype |= (ps_cur_slice->u1_mbaff_frame_flag + << 2); + + ps_dec->ps_cur_mb_row = ps_dec->ps_nbr_mb_row; //[0]; + ps_dec->ps_cur_mb_row++; //Increment by 1 ,so that left mb will always be valid + ps_dec->ps_top_mb_row = + ps_dec->ps_nbr_mb_row + + ((ps_dec->u2_frm_wd_in_mbs + 1) + << (1 + - ps_dec->ps_cur_sps->u1_frame_mbs_only_flag)); + ps_dec->ps_top_mb_row++; //Increment by 1 ,so that left mb will always be valid + + ps_dec->pu1_y = ps_dec->pu1_y_scratch[0]; + ps_dec->pu1_u = ps_dec->pu1_u_scratch[0]; + ps_dec->pu1_v = ps_dec->pu1_v_scratch[0]; + ps_dec->u1_yuv_scratch_idx = 0; + /* CHANGED CODE */ + ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv; + ps_dec->ps_mv_top = ps_dec->ps_mv_top_p[0]; + /* CHANGED CODE */ + ps_dec->u1_mv_top_p = 0; + ps_dec->u1_mb_idx = 0; + /* CHANGED CODE */ + ps_dec->ps_mv_left = ps_dec->s_cur_pic.ps_mv; + ps_dec->pu1_yleft = 0; + ps_dec->pu1_uleft = 0; + ps_dec->pu1_vleft = 0; + ps_dec->u1_not_wait_rec = 2; + ps_dec->u2_total_mbs_coded = 0; + ps_dec->i4_submb_ofst = -(SUB_BLK_SIZE); + ps_dec->u4_pred_info_idx = 0; + ps_dec->u4_pred_info_pkd_idx = 0; + ps_dec->u4_dma_buf_idx = 0; + ps_dec->ps_mv = ps_dec->s_cur_pic.ps_mv; + ps_dec->ps_mv_bank_cur = ps_dec->s_cur_pic.ps_mv; + ps_dec->pu1_col_zero_flag = ps_dec->s_cur_pic.pu1_col_zero_flag; + ps_dec->ps_part = ps_dec->ps_parse_part_params; + ps_dec->i2_prev_slice_mbx = -1; + ps_dec->i2_prev_slice_mby = 0; + ps_dec->u2_mv_2mb[0] = 0; + ps_dec->u2_mv_2mb[1] = 0; + ps_dec->u1_last_pic_not_decoded = 0; + + ps_dec->u2_cur_slice_num_dec_thread = 0; + ps_dec->u2_cur_slice_num_bs = 0; + ps_dec->u4_intra_pred_line_ofst = 0; + ps_dec->pu1_cur_y_intra_pred_line = ps_dec->pu1_y_intra_pred_line; + ps_dec->pu1_cur_u_intra_pred_line = ps_dec->pu1_u_intra_pred_line; + ps_dec->pu1_cur_v_intra_pred_line = ps_dec->pu1_v_intra_pred_line; + + ps_dec->pu1_cur_y_intra_pred_line_base = ps_dec->pu1_y_intra_pred_line; + ps_dec->pu1_cur_u_intra_pred_line_base = ps_dec->pu1_u_intra_pred_line; + ps_dec->pu1_cur_v_intra_pred_line_base = ps_dec->pu1_v_intra_pred_line; + + + + + + ps_dec->pu1_prev_y_intra_pred_line = ps_dec->pu1_y_intra_pred_line + + (ps_dec->u2_frm_wd_in_mbs * MB_SIZE); + + ps_dec->pu1_prev_u_intra_pred_line = ps_dec->pu1_u_intra_pred_line + + ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE * YUV420SP_FACTOR; + ps_dec->pu1_prev_v_intra_pred_line = ps_dec->pu1_v_intra_pred_line + + ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE; + + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic; + ps_dec->ps_deblk_mbn_curr = ps_dec->ps_deblk_mbn; + ps_dec->ps_deblk_mbn_prev = ps_dec->ps_deblk_mbn + ps_dec->u1_recon_mb_grp; + /* Initialize The Function Pointer Depending Upon the Entropy and MbAff Flag */ + { + if(ps_cur_slice->u1_mbaff_frame_flag) + { + ps_dec->pf_compute_bs = ih264d_compute_bs_mbaff; + ps_dec->pf_mvpred = ih264d_mvpred_mbaff; + } + else + { + ps_dec->pf_compute_bs = ih264d_compute_bs_non_mbaff; + ps_dec->u1_cur_mb_fld_dec_flag = ps_cur_slice->u1_field_pic_flag; + } + } + /* Set up the Parameter for DMA transfer */ + { + UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; + + UWORD8 u1_mbaff = ps_cur_slice->u1_mbaff_frame_flag; + + UWORD8 uc_lastmbs = (((ps_dec->u2_pic_wd) >> 4) + % (ps_dec->u1_recon_mb_grp >> u1_mbaff)); + UWORD16 ui16_lastmbs_widthY = + (uc_lastmbs ? (uc_lastmbs << 4) : ((ps_dec->u1_recon_mb_grp + >> u1_mbaff) << 4)); + UWORD16 ui16_lastmbs_widthUV = + uc_lastmbs ? (uc_lastmbs << 3) : ((ps_dec->u1_recon_mb_grp + >> u1_mbaff) << 3); + + ps_dec->s_tran_addrecon.pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1; + ps_dec->s_tran_addrecon.pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2; + ps_dec->s_tran_addrecon.pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3; + + ps_dec->s_tran_addrecon.u2_frm_wd_y = ps_dec->u2_frm_wd_y + << u1_field_pic_flag; + ps_dec->s_tran_addrecon.u2_frm_wd_uv = ps_dec->u2_frm_wd_uv + << u1_field_pic_flag; + + if(u1_field_pic_flag) + { + ui16_lastmbs_widthY += ps_dec->u2_frm_wd_y; + ui16_lastmbs_widthUV += ps_dec->u2_frm_wd_uv; + } + + /* Normal Increment of Pointer */ + ps_dec->s_tran_addrecon.u4_inc_y[0] = ((ps_dec->u1_recon_mb_grp << 4) + >> u1_mbaff); + ps_dec->s_tran_addrecon.u4_inc_uv[0] = ((ps_dec->u1_recon_mb_grp << 4) + >> u1_mbaff); + + /* End of Row Increment */ + ps_dec->s_tran_addrecon.u4_inc_y[1] = (ui16_lastmbs_widthY + + (PAD_LEN_Y_H << 1) + + ps_dec->s_tran_addrecon.u2_frm_wd_y + * ((15 << u1_mbaff) + u1_mbaff)); + ps_dec->s_tran_addrecon.u4_inc_uv[1] = (ui16_lastmbs_widthUV + + (PAD_LEN_UV_H << 2) + + ps_dec->s_tran_addrecon.u2_frm_wd_uv + * ((15 << u1_mbaff) + u1_mbaff)); + + /* Assign picture numbers to each frame/field */ + /* only once per picture. */ + ih264d_assign_pic_num(ps_dec); + ps_dec->s_tran_addrecon.u2_mv_top_left_inc = (ps_dec->u1_recon_mb_grp + << 2) - 1 - (u1_mbaff << 2); + ps_dec->s_tran_addrecon.u2_mv_left_inc = ((ps_dec->u1_recon_mb_grp + >> u1_mbaff) - 1) << (4 + u1_mbaff); + } + /**********************************************************************/ + /* High profile related initialization at pictrue level */ + /**********************************************************************/ + if(ps_seq->u1_profile_idc == HIGH_PROFILE_IDC) + { + if((ps_seq->i4_seq_scaling_matrix_present_flag) + || (ps_pps->i4_pic_scaling_matrix_present_flag)) + { + ih264d_form_scaling_matrix_picture(ps_seq, ps_pps, ps_dec); + ps_dec->s_high_profile.u1_scaling_present = 1; + } + else + { + ih264d_form_default_scaling_matrix(ps_dec); + } + + if(ps_pps->i4_transform_8x8_mode_flag) + { + ps_dec->s_high_profile.u1_transform8x8_present = 1; + } + } + else + { + ih264d_form_default_scaling_matrix(ps_dec); + } + + /* required while reading the transform_size_8x8 u4_flag */ + ps_dec->s_high_profile.u1_direct_8x8_inference_flag = + ps_seq->u1_direct_8x8_inference_flag; + ps_dec->s_high_profile.s_cavlc_ctxt = ps_dec->s_cavlc_ctxt; + + ps_dec->i1_recon_in_thread3_flag = 1; + ps_dec->ps_frame_buf_ip_recon = &ps_dec->s_tran_addrecon; + if(ps_dec->u1_separate_parse) + { + memcpy(&ps_dec->s_tran_addrecon_parse, &ps_dec->s_tran_addrecon, + sizeof(tfr_ctxt_t)); + if(ps_dec->u4_num_cores >= 3 && ps_dec->i1_recon_in_thread3_flag) + { + memcpy(&ps_dec->s_tran_iprecon, &ps_dec->s_tran_addrecon, + sizeof(tfr_ctxt_t)); + ps_dec->ps_frame_buf_ip_recon = &ps_dec->s_tran_iprecon; + } + } + + + ih264d_init_deblk_tfr_ctxt(ps_dec,&(ps_dec->s_pad_mgr), &(ps_dec->s_tran_addrecon), + ps_dec->u2_frm_wd_in_mbs, 0); + + ps_dec->ps_cur_deblk_mb = ps_dec->ps_deblk_pic; + ps_dec->u4_cur_deblk_mb_num = 0; + + ps_dec->u4_deblk_mb_x = 0; + ps_dec->u4_deblk_mb_y = 0; + ps_dec->pu4_wt_ofsts = ps_dec->pu4_wts_ofsts_mat; + + H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex); + return OK; +} +","@@ -1152,19 +1152,19 @@ + + + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if(u4_temp & MASK_ERR_PIC_SET_ID) +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + /* discard slice if pic param is invalid */ + COPYTHECONTEXT(""SH: pic_parameter_set_id"", u4_temp); + ps_pps = &ps_dec->ps_pps[u4_temp]; + if(FALSE == ps_pps->u1_is_valid) + { +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + } + ps_seq = ps_pps->ps_sps; + if(!ps_seq) +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + if(FALSE == ps_seq->u1_is_valid) +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + + /* Get the frame num */ + u2_frame_num = ih264d_get_bits_h264(ps_bitstrm, +@@ -1213,7 +1213,7 @@ + + u4_idr_pic_id = ih264d_uev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + if(u4_idr_pic_id > 65535) +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + COPYTHECONTEXT(""SH: "", u4_idr_pic_id); + } + +@@ -1228,7 +1228,7 @@ + + ps_bitstrm, + ps_seq->u1_log2_max_pic_order_cnt_lsb_minus); + if(i_temp < 0 || i_temp >= ps_seq->i4_max_pic_order_cntLsb) +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + s_tmp_poc.i4_pic_order_cnt_lsb = i_temp; + COPYTHECONTEXT(""SH: pic_order_cnt_lsb"", s_tmp_poc.i4_pic_order_cnt_lsb); + +@@ -1265,7 +1265,7 @@ + + { + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if(u4_temp > MAX_REDUNDANT_PIC_CNT) +- return ERROR_INV_SPS_PPS_T; ++ return ERROR_INV_SLICE_HDR_T; + u1_redundant_pic_cnt = u4_temp; + COPYTHECONTEXT(""SH: redundant_pic_cnt"", u1_redundant_pic_cnt); + } +",6058,6294,8192 +7750,"static MagickBooleanType WritePNGImage(const ImageInfo *image_info,Image *image) +{ + MagickBooleanType + excluding, + logging, + status; + + MngInfo + *mng_info; + + const char + *value; + + int + source; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + logging=LogMagickEvent(CoderEvent,GetMagickModule(),""Enter WritePNGImage()""); + /* + Allocate a MngInfo structure. + */ + mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo)); + + if (mng_info == (MngInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + + /* + Initialize members of the MngInfo structure. + */ + (void) memset(mng_info,0,sizeof(MngInfo)); + mng_info->image=image; + mng_info->equal_backgrounds=MagickTrue; + + /* See if user has requested a specific PNG subformat */ + + mng_info->write_png8=LocaleCompare(image_info->magick,""PNG8"") == 0; + mng_info->write_png24=LocaleCompare(image_info->magick,""PNG24"") == 0; + mng_info->write_png32=LocaleCompare(image_info->magick,""PNG32"") == 0; + mng_info->write_png48=LocaleCompare(image_info->magick,""PNG48"") == 0; + mng_info->write_png64=LocaleCompare(image_info->magick,""PNG64"") == 0; + + value=GetImageOption(image_info,""png:format""); + + if (value != (char *) NULL || LocaleCompare(image_info->magick,""PNG00"") == 0) + { + mng_info->write_png8 = MagickFalse; + mng_info->write_png24 = MagickFalse; + mng_info->write_png32 = MagickFalse; + mng_info->write_png48 = MagickFalse; + mng_info->write_png64 = MagickFalse; + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Format=%s"",value); + + if (LocaleCompare(value,""png8"") == 0) + mng_info->write_png8 = MagickTrue; + + else if (LocaleCompare(value,""png24"") == 0) + mng_info->write_png24 = MagickTrue; + + else if (LocaleCompare(value,""png32"") == 0) + mng_info->write_png32 = MagickTrue; + + else if (LocaleCompare(value,""png48"") == 0) + mng_info->write_png48 = MagickTrue; + + else if (LocaleCompare(value,""png64"") == 0) + mng_info->write_png64 = MagickTrue; + + else if ((LocaleCompare(value,""png00"") == 0) || + LocaleCompare(image_info->magick,""PNG00"") == 0) + { + /* Retrieve png:IHDR.bit-depth-orig and png:IHDR.color-type-orig */ + value=GetImageProperty(image,""png:IHDR.bit-depth-orig""); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png00 inherited bit depth=%s"",value); + + if (value != (char *) NULL) + { + + if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_depth = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_depth = 2; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_depth = 4; + + else if (LocaleCompare(value,""8"") == 0) + mng_info->write_png_depth = 8; + + else if (LocaleCompare(value,""16"") == 0) + mng_info->write_png_depth = 16; + } + + value=GetImageProperty(image,""png:IHDR.color-type-orig""); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png00 inherited color type=%s"",value); + + if (value != (char *) NULL) + { + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_colortype = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_colortype = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_colortype = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_colortype = 5; + + else if (LocaleCompare(value,""6"") == 0) + mng_info->write_png_colortype = 7; + } + } + } + + if (mng_info->write_png8) + { + mng_info->write_png_colortype = /* 3 */ 4; + mng_info->write_png_depth = 8; + image->depth = 8; + } + + if (mng_info->write_png24) + { + mng_info->write_png_colortype = /* 2 */ 3; + mng_info->write_png_depth = 8; + image->depth = 8; + + if (image->matte != MagickFalse) + (void) SetImageType(image,TrueColorMatteType); + + else + (void) SetImageType(image,TrueColorType); + + (void) SyncImage(image); + } + + if (mng_info->write_png32) + { + mng_info->write_png_colortype = /* 6 */ 7; + mng_info->write_png_depth = 8; + image->depth = 8; + image->matte = MagickTrue; + (void) SetImageType(image,TrueColorMatteType); + (void) SyncImage(image); + } + + if (mng_info->write_png48) + { + mng_info->write_png_colortype = /* 2 */ 3; + mng_info->write_png_depth = 16; + image->depth = 16; + + if (image->matte != MagickFalse) + (void) SetImageType(image,TrueColorMatteType); + + else + (void) SetImageType(image,TrueColorType); + + (void) SyncImage(image); + } + + if (mng_info->write_png64) + { + mng_info->write_png_colortype = /* 6 */ 7; + mng_info->write_png_depth = 16; + image->depth = 16; + image->matte = MagickTrue; + (void) SetImageType(image,TrueColorMatteType); + (void) SyncImage(image); + } + + value=GetImageOption(image_info,""png:bit-depth""); + + if (value != (char *) NULL) + { + if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_depth = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_depth = 2; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_depth = 4; + + else if (LocaleCompare(value,""8"") == 0) + mng_info->write_png_depth = 8; + + else if (LocaleCompare(value,""16"") == 0) + mng_info->write_png_depth = 16; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:bit-depth"", + ""=%s"",value); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:bit-depth=%d was defined.\n"",mng_info->write_png_depth); + } + + value=GetImageOption(image_info,""png:color-type""); + + if (value != (char *) NULL) + { + /* We must store colortype+1 because 0 is a valid colortype */ + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_colortype = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_colortype = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_colortype = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_colortype = 5; + + else if (LocaleCompare(value,""6"") == 0) + mng_info->write_png_colortype = 7; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:color-type"", + ""=%s"",value); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:color-type=%d was defined.\n"",mng_info->write_png_colortype-1); + } + + /* Check for chunks to be excluded: + * + * The default is to not exclude any known chunks except for any + * listed in the ""unused_chunks"" array, above. + * + * Chunks can be listed for exclusion via a ""png:exclude-chunk"" + * define (in the image properties or in the image artifacts) + * or via a mng_info member. For convenience, in addition + * to or instead of a comma-separated list of chunks, the + * ""exclude-chunk"" string can be simply ""all"" or ""none"". + * + * The exclude-chunk define takes priority over the mng_info. + * + * A ""png:include-chunk"" define takes priority over both the + * mng_info and the ""png:exclude-chunk"" define. Like the + * ""exclude-chunk"" string, it can define ""all"" or ""none"" as + * well as a comma-separated list. Chunks that are unknown to + * ImageMagick are always excluded, regardless of their ""copy-safe"" + * status according to the PNG specification, and even if they + * appear in the ""include-chunk"" list. Such defines appearing among + * the image options take priority over those found among the image + * artifacts. + * + * Finally, all chunks listed in the ""unused_chunks"" array are + * automatically excluded, regardless of the other instructions + * or lack thereof. + * + * if you exclude sRGB but not gAMA (recommended), then sRGB chunk + * will not be written and the gAMA chunk will only be written if it + * is not between .45 and .46, or approximately (1.0/2.2). + * + * If you exclude tRNS and the image has transparency, the colortype + * is forced to be 4 or 6 (GRAY_ALPHA or RGB_ALPHA). + * + * The -strip option causes StripImage() to set the png:include-chunk + * artifact to ""none,trns,gama"". + */ + + mng_info->ping_exclude_bKGD=MagickFalse; + mng_info->ping_exclude_caNv=MagickFalse; + mng_info->ping_exclude_cHRM=MagickFalse; + mng_info->ping_exclude_date=MagickFalse; + mng_info->ping_exclude_eXIf=MagickFalse; + mng_info->ping_exclude_EXIF=MagickFalse; /* hex-encoded EXIF in zTXt */ + mng_info->ping_exclude_gAMA=MagickFalse; + mng_info->ping_exclude_iCCP=MagickFalse; + /* mng_info->ping_exclude_iTXt=MagickFalse; */ + mng_info->ping_exclude_oFFs=MagickFalse; + mng_info->ping_exclude_pHYs=MagickFalse; + mng_info->ping_exclude_sRGB=MagickFalse; + mng_info->ping_exclude_tEXt=MagickFalse; + mng_info->ping_exclude_tIME=MagickFalse; + mng_info->ping_exclude_tRNS=MagickFalse; + mng_info->ping_exclude_zCCP=MagickFalse; /* hex-encoded iCCP in zTXt */ + mng_info->ping_exclude_zTXt=MagickFalse; + + mng_info->ping_preserve_colormap=MagickFalse; + + value=GetImageOption(image_info,""png:preserve-colormap""); + if (value == NULL) + value=GetImageArtifact(image,""png:preserve-colormap""); + if (value != NULL) + mng_info->ping_preserve_colormap=MagickTrue; + + + mng_info->ping_preserve_iCCP=MagickFalse; + + value=GetImageOption(image_info,""png:preserve-iCCP""); + if (value == NULL) + value=GetImageArtifact(image,""png:preserve-iCCP""); + if (value != NULL) + mng_info->ping_preserve_iCCP=MagickTrue; + + /* These compression-level, compression-strategy, and compression-filter + * defines take precedence over values from the -quality option. + */ + value=GetImageOption(image_info,""png:compression-level""); + if (value == NULL) + value=GetImageArtifact(image,""png:compression-level""); + if (value != NULL) + { + /* To do: use a ""LocaleInteger:()"" function here. */ + + /* We have to add 1 to everything because 0 is a valid input, + * and we want to use 0 (the default) to mean undefined. + */ + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_compression_level = 1; + + else if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_compression_level = 2; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_compression_level = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_compression_level = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_compression_level = 5; + + else if (LocaleCompare(value,""5"") == 0) + mng_info->write_png_compression_level = 6; + + else if (LocaleCompare(value,""6"") == 0) + mng_info->write_png_compression_level = 7; + + else if (LocaleCompare(value,""7"") == 0) + mng_info->write_png_compression_level = 8; + + else if (LocaleCompare(value,""8"") == 0) + mng_info->write_png_compression_level = 9; + + else if (LocaleCompare(value,""9"") == 0) + mng_info->write_png_compression_level = 10; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:compression-level"", + ""=%s"",value); + } + + value=GetImageOption(image_info,""png:compression-strategy""); + if (value == NULL) + value=GetImageArtifact(image,""png:compression-strategy""); + if (value != NULL) + { + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; + + else if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_compression_strategy = Z_FILTERED+1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_compression_strategy = Z_HUFFMAN_ONLY+1; + + else if (LocaleCompare(value,""3"") == 0) +#ifdef Z_RLE /* Z_RLE was added to zlib-1.2.0 */ + mng_info->write_png_compression_strategy = Z_RLE+1; +#else + mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; +#endif + + else if (LocaleCompare(value,""4"") == 0) +#ifdef Z_FIXED /* Z_FIXED was added to zlib-1.2.2.2 */ + mng_info->write_png_compression_strategy = Z_FIXED+1; +#else + mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; +#endif + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:compression-strategy"", + ""=%s"",value); + } + + value=GetImageOption(image_info,""png:compression-filter""); + if (value == NULL) + value=GetImageArtifact(image,""png:compression-filter""); + if (value != NULL) + { + /* To do: combinations of filters allowed by libpng + * masks 0x08 through 0xf8 + * + * Implement this as a comma-separated list of 0,1,2,3,4,5 + * where 5 is a special case meaning PNG_ALL_FILTERS. + */ + + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_compression_filter = 1; + + else if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_compression_filter = 2; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_compression_filter = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_compression_filter = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_compression_filter = 5; + + else if (LocaleCompare(value,""5"") == 0) + mng_info->write_png_compression_filter = 6; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:compression-filter"", + ""=%s"",value); + } + + for (source=0; source<8; source++) + { + value = NULL; + + if (source == 0) + value=GetImageOption(image_info,""png:exclude-chunks""); + + if (source == 1) + value=GetImageArtifact(image,""png:exclude-chunks""); + + if (source == 2) + value=GetImageOption(image_info,""png:exclude-chunk""); + + if (source == 3) + value=GetImageArtifact(image,""png:exclude-chunk""); + + if (source == 4) + value=GetImageOption(image_info,""png:include-chunks""); + + if (source == 5) + value=GetImageArtifact(image,""png:include-chunks""); + + if (source == 6) + value=GetImageOption(image_info,""png:include-chunk""); + + if (source == 7) + value=GetImageArtifact(image,""png:include-chunk""); + + if (value == NULL) + continue; + + if (source < 4) + excluding = MagickTrue; + else + excluding = MagickFalse; + + if (logging != MagickFalse) + { + if (source == 0 || source == 2) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:exclude-chunk=%s found in image options.\n"", value); + else if (source == 1 || source == 3) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:exclude-chunk=%s found in image artifacts.\n"", value); + else if (source == 4 || source == 6) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:include-chunk=%s found in image options.\n"", value); + else /* if (source == 5 || source == 7) */ + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:include-chunk=%s found in image artifacts.\n"", value); + } + + if (IsOptionMember(""all"",value) != MagickFalse) + { + mng_info->ping_exclude_bKGD=excluding; + mng_info->ping_exclude_caNv=excluding; + mng_info->ping_exclude_cHRM=excluding; + mng_info->ping_exclude_date=excluding; + mng_info->ping_exclude_EXIF=excluding; + mng_info->ping_exclude_eXIf=excluding; + mng_info->ping_exclude_gAMA=excluding; + mng_info->ping_exclude_iCCP=excluding; + /* mng_info->ping_exclude_iTXt=excluding; */ + mng_info->ping_exclude_oFFs=excluding; + mng_info->ping_exclude_pHYs=excluding; + mng_info->ping_exclude_sRGB=excluding; + mng_info->ping_exclude_tIME=excluding; + mng_info->ping_exclude_tEXt=excluding; + mng_info->ping_exclude_tRNS=excluding; + mng_info->ping_exclude_zCCP=excluding; + mng_info->ping_exclude_zTXt=excluding; + } + + if (IsOptionMember(""none"",value) != MagickFalse) + { + mng_info->ping_exclude_bKGD=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_caNv=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_cHRM=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_date=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_eXIf=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_EXIF=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_gAMA=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_iCCP=excluding != MagickFalse ? MagickFalse : + MagickTrue; + /* mng_info->ping_exclude_iTXt=!excluding; */ + mng_info->ping_exclude_oFFs=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_pHYs=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_sRGB=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_tEXt=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_tIME=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_tRNS=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_zCCP=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_zTXt=excluding != MagickFalse ? MagickFalse : + MagickTrue; + } + + if (IsOptionMember(""bkgd"",value) != MagickFalse) + mng_info->ping_exclude_bKGD=excluding; + + if (IsOptionMember(""caNv"",value) != MagickFalse) + mng_info->ping_exclude_caNv=excluding; + + if (IsOptionMember(""chrm"",value) != MagickFalse) + mng_info->ping_exclude_cHRM=excluding; + + if (IsOptionMember(""date"",value) != MagickFalse) + mng_info->ping_exclude_date=excluding; + + if (IsOptionMember(""exif"",value) != MagickFalse) + { + mng_info->ping_exclude_EXIF=excluding; + mng_info->ping_exclude_eXIf=excluding; + } + + if (IsOptionMember(""gama"",value) != MagickFalse) + mng_info->ping_exclude_gAMA=excluding; + + if (IsOptionMember(""iccp"",value) != MagickFalse) + mng_info->ping_exclude_iCCP=excluding; + +#if 0 + if (IsOptionMember(""itxt"",value) != MagickFalse) + mng_info->ping_exclude_iTXt=excluding; +#endif + + if (IsOptionMember(""offs"",value) != MagickFalse) + mng_info->ping_exclude_oFFs=excluding; + + if (IsOptionMember(""phys"",value) != MagickFalse) + mng_info->ping_exclude_pHYs=excluding; + + if (IsOptionMember(""srgb"",value) != MagickFalse) + mng_info->ping_exclude_sRGB=excluding; + + if (IsOptionMember(""text"",value) != MagickFalse) + mng_info->ping_exclude_tEXt=excluding; + + if (IsOptionMember(""time"",value) != MagickFalse) + mng_info->ping_exclude_tIME=excluding; + + if (IsOptionMember(""trns"",value) != MagickFalse) + mng_info->ping_exclude_tRNS=excluding; + + if (IsOptionMember(""zccp"",value) != MagickFalse) + mng_info->ping_exclude_zCCP=excluding; + + if (IsOptionMember(""ztxt"",value) != MagickFalse) + mng_info->ping_exclude_zTXt=excluding; + } + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Chunks to be excluded from the output png:""); + if (mng_info->ping_exclude_bKGD != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" bKGD""); + if (mng_info->ping_exclude_caNv != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" caNv""); + if (mng_info->ping_exclude_cHRM != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" cHRM""); + if (mng_info->ping_exclude_date != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" date""); + if (mng_info->ping_exclude_EXIF != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" EXIF""); + if (mng_info->ping_exclude_eXIf != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" eXIf""); + if (mng_info->ping_exclude_gAMA != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" gAMA""); + if (mng_info->ping_exclude_iCCP != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" iCCP""); +#if 0 + if (mng_info->ping_exclude_iTXt != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" iTXt""); +#endif + + if (mng_info->ping_exclude_oFFs != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" oFFs""); + if (mng_info->ping_exclude_pHYs != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" pHYs""); + if (mng_info->ping_exclude_sRGB != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" sRGB""); + if (mng_info->ping_exclude_tEXt != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" tEXt""); + if (mng_info->ping_exclude_tIME != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" tIME""); + if (mng_info->ping_exclude_tRNS != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" tRNS""); + if (mng_info->ping_exclude_zCCP != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" zCCP""); + if (mng_info->ping_exclude_zTXt != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" zTXt""); + } + + mng_info->need_blob = MagickTrue; + + status=WriteOnePNGImage(mng_info,image_info,image); + + (void) CloseBlob(image); + + mng_info=MngInfoFreeStruct(mng_info); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""exit WritePNGImage()""); + + return(status); +} +",0,"static MagickBooleanType WritePNGImage(const ImageInfo *image_info,Image *image) +{ + MagickBooleanType + excluding, + logging, + status; + + MngInfo + *mng_info; + + const char + *value; + + int + source; + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + logging=LogMagickEvent(CoderEvent,GetMagickModule(),""Enter WritePNGImage()""); + /* + Allocate a MngInfo structure. + */ + mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo)); + + if (mng_info == (MngInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + + /* + Initialize members of the MngInfo structure. + */ + (void) memset(mng_info,0,sizeof(MngInfo)); + mng_info->image=image; + mng_info->equal_backgrounds=MagickTrue; + + /* See if user has requested a specific PNG subformat */ + + mng_info->write_png8=LocaleCompare(image_info->magick,""PNG8"") == 0; + mng_info->write_png24=LocaleCompare(image_info->magick,""PNG24"") == 0; + mng_info->write_png32=LocaleCompare(image_info->magick,""PNG32"") == 0; + mng_info->write_png48=LocaleCompare(image_info->magick,""PNG48"") == 0; + mng_info->write_png64=LocaleCompare(image_info->magick,""PNG64"") == 0; + + value=GetImageOption(image_info,""png:format""); + + if (value != (char *) NULL || LocaleCompare(image_info->magick,""PNG00"") == 0) + { + mng_info->write_png8 = MagickFalse; + mng_info->write_png24 = MagickFalse; + mng_info->write_png32 = MagickFalse; + mng_info->write_png48 = MagickFalse; + mng_info->write_png64 = MagickFalse; + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Format=%s"",value); + + if (LocaleCompare(value,""png8"") == 0) + mng_info->write_png8 = MagickTrue; + + else if (LocaleCompare(value,""png24"") == 0) + mng_info->write_png24 = MagickTrue; + + else if (LocaleCompare(value,""png32"") == 0) + mng_info->write_png32 = MagickTrue; + + else if (LocaleCompare(value,""png48"") == 0) + mng_info->write_png48 = MagickTrue; + + else if (LocaleCompare(value,""png64"") == 0) + mng_info->write_png64 = MagickTrue; + + else if ((LocaleCompare(value,""png00"") == 0) || + LocaleCompare(image_info->magick,""PNG00"") == 0) + { + /* Retrieve png:IHDR.bit-depth-orig and png:IHDR.color-type-orig */ + value=GetImageProperty(image,""png:IHDR.bit-depth-orig""); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png00 inherited bit depth=%s"",value); + + if (value != (char *) NULL) + { + + if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_depth = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_depth = 2; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_depth = 4; + + else if (LocaleCompare(value,""8"") == 0) + mng_info->write_png_depth = 8; + + else if (LocaleCompare(value,""16"") == 0) + mng_info->write_png_depth = 16; + } + + value=GetImageProperty(image,""png:IHDR.color-type-orig""); + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png00 inherited color type=%s"",value); + + if (value != (char *) NULL) + { + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_colortype = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_colortype = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_colortype = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_colortype = 5; + + else if (LocaleCompare(value,""6"") == 0) + mng_info->write_png_colortype = 7; + } + } + } + + if (mng_info->write_png8) + { + mng_info->write_png_colortype = /* 3 */ 4; + mng_info->write_png_depth = 8; + image->depth = 8; + } + + if (mng_info->write_png24) + { + mng_info->write_png_colortype = /* 2 */ 3; + mng_info->write_png_depth = 8; + image->depth = 8; + + if (image->matte != MagickFalse) + (void) SetImageType(image,TrueColorMatteType); + + else + (void) SetImageType(image,TrueColorType); + + (void) SyncImage(image); + } + + if (mng_info->write_png32) + { + mng_info->write_png_colortype = /* 6 */ 7; + mng_info->write_png_depth = 8; + image->depth = 8; + image->matte = MagickTrue; + (void) SetImageType(image,TrueColorMatteType); + (void) SyncImage(image); + } + + if (mng_info->write_png48) + { + mng_info->write_png_colortype = /* 2 */ 3; + mng_info->write_png_depth = 16; + image->depth = 16; + + if (image->matte != MagickFalse) + (void) SetImageType(image,TrueColorMatteType); + + else + (void) SetImageType(image,TrueColorType); + + (void) SyncImage(image); + } + + if (mng_info->write_png64) + { + mng_info->write_png_colortype = /* 6 */ 7; + mng_info->write_png_depth = 16; + image->depth = 16; + image->matte = MagickTrue; + (void) SetImageType(image,TrueColorMatteType); + (void) SyncImage(image); + } + + value=GetImageOption(image_info,""png:bit-depth""); + + if (value != (char *) NULL) + { + if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_depth = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_depth = 2; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_depth = 4; + + else if (LocaleCompare(value,""8"") == 0) + mng_info->write_png_depth = 8; + + else if (LocaleCompare(value,""16"") == 0) + mng_info->write_png_depth = 16; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:bit-depth"", + ""=%s"",value); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:bit-depth=%d was defined.\n"",mng_info->write_png_depth); + } + + value=GetImageOption(image_info,""png:color-type""); + + if (value != (char *) NULL) + { + /* We must store colortype+1 because 0 is a valid colortype */ + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_colortype = 1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_colortype = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_colortype = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_colortype = 5; + + else if (LocaleCompare(value,""6"") == 0) + mng_info->write_png_colortype = 7; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:color-type"", + ""=%s"",value); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:color-type=%d was defined.\n"",mng_info->write_png_colortype-1); + } + + /* Check for chunks to be excluded: + * + * The default is to not exclude any known chunks except for any + * listed in the ""unused_chunks"" array, above. + * + * Chunks can be listed for exclusion via a ""png:exclude-chunk"" + * define (in the image properties or in the image artifacts) + * or via a mng_info member. For convenience, in addition + * to or instead of a comma-separated list of chunks, the + * ""exclude-chunk"" string can be simply ""all"" or ""none"". + * + * The exclude-chunk define takes priority over the mng_info. + * + * A ""png:include-chunk"" define takes priority over both the + * mng_info and the ""png:exclude-chunk"" define. Like the + * ""exclude-chunk"" string, it can define ""all"" or ""none"" as + * well as a comma-separated list. Chunks that are unknown to + * ImageMagick are always excluded, regardless of their ""copy-safe"" + * status according to the PNG specification, and even if they + * appear in the ""include-chunk"" list. Such defines appearing among + * the image options take priority over those found among the image + * artifacts. + * + * Finally, all chunks listed in the ""unused_chunks"" array are + * automatically excluded, regardless of the other instructions + * or lack thereof. + * + * if you exclude sRGB but not gAMA (recommended), then sRGB chunk + * will not be written and the gAMA chunk will only be written if it + * is not between .45 and .46, or approximately (1.0/2.2). + * + * If you exclude tRNS and the image has transparency, the colortype + * is forced to be 4 or 6 (GRAY_ALPHA or RGB_ALPHA). + * + * The -strip option causes StripImage() to set the png:include-chunk + * artifact to ""none,trns,gama"". + */ + + mng_info->ping_exclude_bKGD=MagickFalse; + mng_info->ping_exclude_caNv=MagickFalse; + mng_info->ping_exclude_cHRM=MagickFalse; + mng_info->ping_exclude_date=MagickFalse; + mng_info->ping_exclude_eXIf=MagickFalse; + mng_info->ping_exclude_EXIF=MagickFalse; /* hex-encoded EXIF in zTXt */ + mng_info->ping_exclude_gAMA=MagickFalse; + mng_info->ping_exclude_iCCP=MagickFalse; + /* mng_info->ping_exclude_iTXt=MagickFalse; */ + mng_info->ping_exclude_oFFs=MagickFalse; + mng_info->ping_exclude_pHYs=MagickFalse; + mng_info->ping_exclude_sRGB=MagickFalse; + mng_info->ping_exclude_tEXt=MagickFalse; + mng_info->ping_exclude_tIME=MagickFalse; + mng_info->ping_exclude_tRNS=MagickFalse; + mng_info->ping_exclude_zCCP=MagickFalse; /* hex-encoded iCCP in zTXt */ + mng_info->ping_exclude_zTXt=MagickFalse; + + mng_info->ping_preserve_colormap=MagickFalse; + + value=GetImageOption(image_info,""png:preserve-colormap""); + if (value == NULL) + value=GetImageArtifact(image,""png:preserve-colormap""); + if (value != NULL) + mng_info->ping_preserve_colormap=MagickTrue; + + + mng_info->ping_preserve_iCCP=MagickFalse; + + value=GetImageOption(image_info,""png:preserve-iCCP""); + if (value == NULL) + value=GetImageArtifact(image,""png:preserve-iCCP""); + if (value != NULL) + mng_info->ping_preserve_iCCP=MagickTrue; + + /* These compression-level, compression-strategy, and compression-filter + * defines take precedence over values from the -quality option. + */ + value=GetImageOption(image_info,""png:compression-level""); + if (value == NULL) + value=GetImageArtifact(image,""png:compression-level""); + if (value != NULL) + { + /* To do: use a ""LocaleInteger:()"" function here. */ + + /* We have to add 1 to everything because 0 is a valid input, + * and we want to use 0 (the default) to mean undefined. + */ + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_compression_level = 1; + + else if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_compression_level = 2; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_compression_level = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_compression_level = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_compression_level = 5; + + else if (LocaleCompare(value,""5"") == 0) + mng_info->write_png_compression_level = 6; + + else if (LocaleCompare(value,""6"") == 0) + mng_info->write_png_compression_level = 7; + + else if (LocaleCompare(value,""7"") == 0) + mng_info->write_png_compression_level = 8; + + else if (LocaleCompare(value,""8"") == 0) + mng_info->write_png_compression_level = 9; + + else if (LocaleCompare(value,""9"") == 0) + mng_info->write_png_compression_level = 10; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:compression-level"", + ""=%s"",value); + } + + value=GetImageOption(image_info,""png:compression-strategy""); + if (value == NULL) + value=GetImageArtifact(image,""png:compression-strategy""); + if (value != NULL) + { + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; + + else if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_compression_strategy = Z_FILTERED+1; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_compression_strategy = Z_HUFFMAN_ONLY+1; + + else if (LocaleCompare(value,""3"") == 0) +#ifdef Z_RLE /* Z_RLE was added to zlib-1.2.0 */ + mng_info->write_png_compression_strategy = Z_RLE+1; +#else + mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; +#endif + + else if (LocaleCompare(value,""4"") == 0) +#ifdef Z_FIXED /* Z_FIXED was added to zlib-1.2.2.2 */ + mng_info->write_png_compression_strategy = Z_FIXED+1; +#else + mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; +#endif + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:compression-strategy"", + ""=%s"",value); + } + + value=GetImageOption(image_info,""png:compression-filter""); + if (value == NULL) + value=GetImageArtifact(image,""png:compression-filter""); + if (value != NULL) + { + /* To do: combinations of filters allowed by libpng + * masks 0x08 through 0xf8 + * + * Implement this as a comma-separated list of 0,1,2,3,4,5 + * where 5 is a special case meaning PNG_ALL_FILTERS. + */ + + if (LocaleCompare(value,""0"") == 0) + mng_info->write_png_compression_filter = 1; + + else if (LocaleCompare(value,""1"") == 0) + mng_info->write_png_compression_filter = 2; + + else if (LocaleCompare(value,""2"") == 0) + mng_info->write_png_compression_filter = 3; + + else if (LocaleCompare(value,""3"") == 0) + mng_info->write_png_compression_filter = 4; + + else if (LocaleCompare(value,""4"") == 0) + mng_info->write_png_compression_filter = 5; + + else if (LocaleCompare(value,""5"") == 0) + mng_info->write_png_compression_filter = 6; + + else + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""ignoring invalid defined png:compression-filter"", + ""=%s"",value); + } + + for (source=0; source<8; source++) + { + value = NULL; + + if (source == 0) + value=GetImageOption(image_info,""png:exclude-chunks""); + + if (source == 1) + value=GetImageArtifact(image,""png:exclude-chunks""); + + if (source == 2) + value=GetImageOption(image_info,""png:exclude-chunk""); + + if (source == 3) + value=GetImageArtifact(image,""png:exclude-chunk""); + + if (source == 4) + value=GetImageOption(image_info,""png:include-chunks""); + + if (source == 5) + value=GetImageArtifact(image,""png:include-chunks""); + + if (source == 6) + value=GetImageOption(image_info,""png:include-chunk""); + + if (source == 7) + value=GetImageArtifact(image,""png:include-chunk""); + + if (value == NULL) + continue; + + if (source < 4) + excluding = MagickTrue; + else + excluding = MagickFalse; + + if (logging != MagickFalse) + { + if (source == 0 || source == 2) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:exclude-chunk=%s found in image options.\n"", value); + else if (source == 1 || source == 3) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:exclude-chunk=%s found in image artifacts.\n"", value); + else if (source == 4 || source == 6) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:include-chunk=%s found in image options.\n"", value); + else /* if (source == 5 || source == 7) */ + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" png:include-chunk=%s found in image artifacts.\n"", value); + } + + if (IsOptionMember(""all"",value) != MagickFalse) + { + mng_info->ping_exclude_bKGD=excluding; + mng_info->ping_exclude_caNv=excluding; + mng_info->ping_exclude_cHRM=excluding; + mng_info->ping_exclude_date=excluding; + mng_info->ping_exclude_EXIF=excluding; + mng_info->ping_exclude_eXIf=excluding; + mng_info->ping_exclude_gAMA=excluding; + mng_info->ping_exclude_iCCP=excluding; + /* mng_info->ping_exclude_iTXt=excluding; */ + mng_info->ping_exclude_oFFs=excluding; + mng_info->ping_exclude_pHYs=excluding; + mng_info->ping_exclude_sRGB=excluding; + mng_info->ping_exclude_tIME=excluding; + mng_info->ping_exclude_tEXt=excluding; + mng_info->ping_exclude_tRNS=excluding; + mng_info->ping_exclude_zCCP=excluding; + mng_info->ping_exclude_zTXt=excluding; + } + + if (IsOptionMember(""none"",value) != MagickFalse) + { + mng_info->ping_exclude_bKGD=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_caNv=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_cHRM=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_date=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_eXIf=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_EXIF=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_gAMA=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_iCCP=excluding != MagickFalse ? MagickFalse : + MagickTrue; + /* mng_info->ping_exclude_iTXt=!excluding; */ + mng_info->ping_exclude_oFFs=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_pHYs=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_sRGB=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_tEXt=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_tIME=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_tRNS=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_zCCP=excluding != MagickFalse ? MagickFalse : + MagickTrue; + mng_info->ping_exclude_zTXt=excluding != MagickFalse ? MagickFalse : + MagickTrue; + } + + if (IsOptionMember(""bkgd"",value) != MagickFalse) + mng_info->ping_exclude_bKGD=excluding; + + if (IsOptionMember(""caNv"",value) != MagickFalse) + mng_info->ping_exclude_caNv=excluding; + + if (IsOptionMember(""chrm"",value) != MagickFalse) + mng_info->ping_exclude_cHRM=excluding; + + if (IsOptionMember(""date"",value) != MagickFalse) + mng_info->ping_exclude_date=excluding; + + if (IsOptionMember(""exif"",value) != MagickFalse) + { + mng_info->ping_exclude_EXIF=excluding; + mng_info->ping_exclude_eXIf=excluding; + } + + if (IsOptionMember(""gama"",value) != MagickFalse) + mng_info->ping_exclude_gAMA=excluding; + + if (IsOptionMember(""iccp"",value) != MagickFalse) + mng_info->ping_exclude_iCCP=excluding; + +#if 0 + if (IsOptionMember(""itxt"",value) != MagickFalse) + mng_info->ping_exclude_iTXt=excluding; +#endif + + if (IsOptionMember(""offs"",value) != MagickFalse) + mng_info->ping_exclude_oFFs=excluding; + + if (IsOptionMember(""phys"",value) != MagickFalse) + mng_info->ping_exclude_pHYs=excluding; + + if (IsOptionMember(""srgb"",value) != MagickFalse) + mng_info->ping_exclude_sRGB=excluding; + + if (IsOptionMember(""text"",value) != MagickFalse) + mng_info->ping_exclude_tEXt=excluding; + + if (IsOptionMember(""time"",value) != MagickFalse) + mng_info->ping_exclude_tIME=excluding; + + if (IsOptionMember(""trns"",value) != MagickFalse) + mng_info->ping_exclude_tRNS=excluding; + + if (IsOptionMember(""zccp"",value) != MagickFalse) + mng_info->ping_exclude_zCCP=excluding; + + if (IsOptionMember(""ztxt"",value) != MagickFalse) + mng_info->ping_exclude_zTXt=excluding; + } + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Chunks to be excluded from the output png:""); + if (mng_info->ping_exclude_bKGD != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" bKGD""); + if (mng_info->ping_exclude_caNv != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" caNv""); + if (mng_info->ping_exclude_cHRM != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" cHRM""); + if (mng_info->ping_exclude_date != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" date""); + if (mng_info->ping_exclude_EXIF != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" EXIF""); + if (mng_info->ping_exclude_eXIf != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" eXIf""); + if (mng_info->ping_exclude_gAMA != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" gAMA""); + if (mng_info->ping_exclude_iCCP != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" iCCP""); +#if 0 + if (mng_info->ping_exclude_iTXt != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" iTXt""); +#endif + + if (mng_info->ping_exclude_oFFs != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" oFFs""); + if (mng_info->ping_exclude_pHYs != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" pHYs""); + if (mng_info->ping_exclude_sRGB != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" sRGB""); + if (mng_info->ping_exclude_tEXt != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" tEXt""); + if (mng_info->ping_exclude_tIME != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" tIME""); + if (mng_info->ping_exclude_tRNS != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" tRNS""); + if (mng_info->ping_exclude_zCCP != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" zCCP""); + if (mng_info->ping_exclude_zTXt != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" zTXt""); + } + + mng_info->need_blob = MagickTrue; + + status=WriteOnePNGImage(mng_info,image_info,image); + + (void) CloseBlob(image); + + mng_info=MngInfoFreeStruct(mng_info); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""exit WritePNGImage()""); + + return(status); +} +","@@ -4584,7 +4584,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + +- if (length != 0) ++ if ((length != 0) && (color_image != (Image *) NULL)) + { + (void) WriteBlob(color_image,length,chunk); + chunk=(unsigned char *) RelinquishMagickMemory(chunk);",6427,6663,8192 +9292,"main(int argc, char **argv) +{ + register int cnt, op, i; + bpf_u_int32 localnet =0 , netmask = 0; + int timezone_offset = 0; + register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName; + pcap_handler callback; + int dlt; + const char *dlt_name; + struct bpf_program fcode; +#ifndef _WIN32 + RETSIGTYPE (*oldhandler)(int); +#endif + struct dump_info dumpinfo; + u_char *pcap_userdata; + char ebuf[PCAP_ERRBUF_SIZE]; + char VFileLine[PATH_MAX + 1]; + char *username = NULL; + char *chroot_dir = NULL; + char *ret = NULL; + char *end; +#ifdef HAVE_PCAP_FINDALLDEVS + pcap_if_t *devlist; + long devnum; +#endif + int status; + FILE *VFile; +#ifdef HAVE_CAPSICUM + cap_rights_t rights; + int cansandbox; +#endif /* HAVE_CAPSICUM */ + int Oflag = 1; /* run filter code optimizer */ + int yflag_dlt = -1; + const char *yflag_dlt_name = NULL; + + netdissect_options Ndo; + netdissect_options *ndo = &Ndo; + + /* + * Initialize the netdissect code. + */ + if (nd_init(ebuf, sizeof ebuf) == -1) + error(""%s"", ebuf); + + memset(ndo, 0, sizeof(*ndo)); + ndo_set_function_pointers(ndo); + ndo->ndo_snaplen = DEFAULT_SNAPLEN; + + cnt = -1; + device = NULL; + infile = NULL; + RFileName = NULL; + VFileName = NULL; + VFile = NULL; + WFileName = NULL; + dlt = -1; + if ((cp = strrchr(argv[0], '/')) != NULL) + ndo->program_name = program_name = cp + 1; + else + ndo->program_name = program_name = argv[0]; + +#ifdef _WIN32 + if (pcap_wsockinit() != 0) + error(""Attempting to initialize Winsock failed""); +#endif /* _WIN32 */ + + /* + * On platforms where the CPU doesn't support unaligned loads, + * force unaligned accesses to abort with SIGBUS, rather than + * being fixed up (slowly) by the OS kernel; on those platforms, + * misaligned accesses are bugs, and we want tcpdump to crash so + * that the bugs are reported. + */ + if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0) + error(""%s"", ebuf); + + while ( + (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1) + switch (op) { + + case 'a': + /* compatibility for old -a */ + break; + + case 'A': + ++ndo->ndo_Aflag; + break; + + case 'b': + ++ndo->ndo_bflag; + break; + +#if defined(HAVE_PCAP_CREATE) || defined(_WIN32) + case 'B': + Bflag = atoi(optarg)*1024; + if (Bflag <= 0) + error(""invalid packet buffer size %s"", optarg); + break; +#endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */ + + case 'c': + cnt = atoi(optarg); + if (cnt <= 0) + error(""invalid packet count %s"", optarg); + break; + + case 'C': + Cflag = atoi(optarg) * 1000000; + if (Cflag <= 0) + error(""invalid file size %s"", optarg); + break; + + case 'd': + ++dflag; + break; + + case 'D': + Dflag++; + break; + + case 'L': + Lflag++; + break; + + case 'e': + ++ndo->ndo_eflag; + break; + + case 'E': +#ifndef HAVE_LIBCRYPTO + warning(""crypto code not compiled in""); +#endif + ndo->ndo_espsecret = optarg; + break; + + case 'f': + ++ndo->ndo_fflag; + break; + + case 'F': + infile = optarg; + break; + + case 'G': + Gflag = atoi(optarg); + if (Gflag < 0) + error(""invalid number of seconds %s"", optarg); + + /* We will create one file initially. */ + Gflag_count = 0; + + /* Grab the current time for rotation use. */ + if ((Gflag_time = time(NULL)) == (time_t)-1) { + error(""main: can't get current time: %s"", + pcap_strerror(errno)); + } + break; + + case 'h': + print_usage(); + exit_tcpdump(0); + break; + + case 'H': + ++ndo->ndo_Hflag; + break; + + case 'i': + device = optarg; + break; + +#ifdef HAVE_PCAP_CREATE + case 'I': + ++Iflag; + break; +#endif /* HAVE_PCAP_CREATE */ + +#ifdef HAVE_PCAP_SET_TSTAMP_TYPE + case 'j': + jflag = pcap_tstamp_type_name_to_val(optarg); + if (jflag < 0) + error(""invalid time stamp type %s"", optarg); + break; + + case 'J': + Jflag++; + break; +#endif + + case 'l': +#ifdef _WIN32 + /* + * _IOLBF is the same as _IOFBF in Microsoft's C + * libraries; the only alternative they offer + * is _IONBF. + * + * XXX - this should really be checking for MSVC++, + * not _WIN32, if, for example, MinGW has its own + * C library that is more UNIX-compatible. + */ + setvbuf(stdout, NULL, _IONBF, 0); +#else /* _WIN32 */ +#ifdef HAVE_SETLINEBUF + setlinebuf(stdout); +#else + setvbuf(stdout, NULL, _IOLBF, 0); +#endif +#endif /* _WIN32 */ + break; + + case 'K': + ++ndo->ndo_Kflag; + break; + + case 'm': + if (nd_have_smi_support()) { + if (nd_load_smi_module(optarg, ebuf, sizeof ebuf) == -1) + error(""%s"", ebuf); + } else { + (void)fprintf(stderr, ""%s: ignoring option `-m %s' "", + program_name, optarg); + (void)fprintf(stderr, ""(no libsmi support)\n""); + } + break; + + case 'M': + /* TCP-MD5 shared secret */ +#ifndef HAVE_LIBCRYPTO + warning(""crypto code not compiled in""); +#endif + ndo->ndo_sigsecret = optarg; + break; + + case 'n': + ++ndo->ndo_nflag; + break; + + case 'N': + ++ndo->ndo_Nflag; + break; + + case 'O': + Oflag = 0; + break; + + case 'p': + ++pflag; + break; + + case 'q': + ++ndo->ndo_qflag; + ++ndo->ndo_suppress_default_print; + break; + +#ifdef HAVE_PCAP_SETDIRECTION + case 'Q': + if (ascii_strcasecmp(optarg, ""in"") == 0) + Qflag = PCAP_D_IN; + else if (ascii_strcasecmp(optarg, ""out"") == 0) + Qflag = PCAP_D_OUT; + else if (ascii_strcasecmp(optarg, ""inout"") == 0) + Qflag = PCAP_D_INOUT; + else + error(""unknown capture direction `%s'"", optarg); + break; +#endif /* HAVE_PCAP_SETDIRECTION */ + + case 'r': + RFileName = optarg; + break; + + case 's': + ndo->ndo_snaplen = strtol(optarg, &end, 0); + if (optarg == end || *end != '\0' + || ndo->ndo_snaplen < 0 || ndo->ndo_snaplen > MAXIMUM_SNAPLEN) + error(""invalid snaplen %s"", optarg); + else if (ndo->ndo_snaplen == 0) + ndo->ndo_snaplen = MAXIMUM_SNAPLEN; + break; + + case 'S': + ++ndo->ndo_Sflag; + break; + + case 't': + ++ndo->ndo_tflag; + break; + + case 'T': + if (ascii_strcasecmp(optarg, ""vat"") == 0) + ndo->ndo_packettype = PT_VAT; + else if (ascii_strcasecmp(optarg, ""wb"") == 0) + ndo->ndo_packettype = PT_WB; + else if (ascii_strcasecmp(optarg, ""rpc"") == 0) + ndo->ndo_packettype = PT_RPC; + else if (ascii_strcasecmp(optarg, ""rtp"") == 0) + ndo->ndo_packettype = PT_RTP; + else if (ascii_strcasecmp(optarg, ""rtcp"") == 0) + ndo->ndo_packettype = PT_RTCP; + else if (ascii_strcasecmp(optarg, ""snmp"") == 0) + ndo->ndo_packettype = PT_SNMP; + else if (ascii_strcasecmp(optarg, ""cnfp"") == 0) + ndo->ndo_packettype = PT_CNFP; + else if (ascii_strcasecmp(optarg, ""tftp"") == 0) + ndo->ndo_packettype = PT_TFTP; + else if (ascii_strcasecmp(optarg, ""aodv"") == 0) + ndo->ndo_packettype = PT_AODV; + else if (ascii_strcasecmp(optarg, ""carp"") == 0) + ndo->ndo_packettype = PT_CARP; + else if (ascii_strcasecmp(optarg, ""radius"") == 0) + ndo->ndo_packettype = PT_RADIUS; + else if (ascii_strcasecmp(optarg, ""zmtp1"") == 0) + ndo->ndo_packettype = PT_ZMTP1; + else if (ascii_strcasecmp(optarg, ""vxlan"") == 0) + ndo->ndo_packettype = PT_VXLAN; + else if (ascii_strcasecmp(optarg, ""pgm"") == 0) + ndo->ndo_packettype = PT_PGM; + else if (ascii_strcasecmp(optarg, ""pgm_zmtp1"") == 0) + ndo->ndo_packettype = PT_PGM_ZMTP1; + else if (ascii_strcasecmp(optarg, ""lmp"") == 0) + ndo->ndo_packettype = PT_LMP; + else if (ascii_strcasecmp(optarg, ""resp"") == 0) + ndo->ndo_packettype = PT_RESP; + else + error(""unknown packet type `%s'"", optarg); + break; + + case 'u': + ++ndo->ndo_uflag; + break; + +#ifdef HAVE_PCAP_DUMP_FLUSH + case 'U': + ++Uflag; + break; +#endif + + case 'v': + ++ndo->ndo_vflag; + break; + + case 'V': + VFileName = optarg; + break; + + case 'w': + WFileName = optarg; + break; + + case 'W': + Wflag = atoi(optarg); + if (Wflag <= 0) + error(""invalid number of output files %s"", optarg); + WflagChars = getWflagChars(Wflag); + break; + + case 'x': + ++ndo->ndo_xflag; + ++ndo->ndo_suppress_default_print; + break; + + case 'X': + ++ndo->ndo_Xflag; + ++ndo->ndo_suppress_default_print; + break; + + case 'y': + yflag_dlt_name = optarg; + yflag_dlt = + pcap_datalink_name_to_val(yflag_dlt_name); + if (yflag_dlt < 0) + error(""invalid data link type %s"", yflag_dlt_name); + break; + +#ifdef HAVE_PCAP_SET_PARSER_DEBUG + case 'Y': + { + /* Undocumented flag */ + pcap_set_parser_debug(1); + } + break; +#endif + case 'z': + zflag = optarg; + break; + + case 'Z': + username = optarg; + break; + + case '#': + ndo->ndo_packet_number = 1; + break; + + case OPTION_VERSION: + print_version(); + exit_tcpdump(0); + break; + +#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION + case OPTION_TSTAMP_PRECISION: + ndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg); + if (ndo->ndo_tstamp_precision < 0) + error(""unsupported time stamp precision""); + break; +#endif + +#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE + case OPTION_IMMEDIATE_MODE: + immediate_mode = 1; + break; +#endif + + default: + print_usage(); + exit_tcpdump(1); + /* NOTREACHED */ + } + +#ifdef HAVE_PCAP_FINDALLDEVS + if (Dflag) + show_devices_and_exit(); +#endif + + switch (ndo->ndo_tflag) { + + case 0: /* Default */ + case 4: /* Default + Date*/ + timezone_offset = gmt2local(0); + break; + + case 1: /* No time stamp */ + case 2: /* Unix timeval style */ + case 3: /* Microseconds since previous packet */ + case 5: /* Microseconds since first packet */ + break; + + default: /* Not supported */ + error(""only -t, -tt, -ttt, -tttt and -ttttt are supported""); + break; + } + + if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL)) + error(""-f can not be used with -V or -r""); + + if (VFileName != NULL && RFileName != NULL) + error(""-V and -r are mutually exclusive.""); + +#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE + /* + * If we're printing dissected packets to the standard output + * rather than saving raw packets to a file, and the standard + * output is a terminal, use immediate mode, as the user's + * probably expecting to see packets pop up immediately. + */ + if (WFileName == NULL && isatty(1)) + immediate_mode = 1; +#endif + +#ifdef WITH_CHROOT + /* if run as root, prepare for chrooting */ + if (getuid() == 0 || geteuid() == 0) { + /* future extensibility for cmd-line arguments */ + if (!chroot_dir) + chroot_dir = WITH_CHROOT; + } +#endif + +#ifdef WITH_USER + /* if run as root, prepare for dropping root privileges */ + if (getuid() == 0 || geteuid() == 0) { + /* Run with '-Z root' to restore old behaviour */ + if (!username) + username = WITH_USER; + } +#endif + + if (RFileName != NULL || VFileName != NULL) { + /* + * If RFileName is non-null, it's the pathname of a + * savefile to read. If VFileName is non-null, it's + * the pathname of a file containing a list of pathnames + * (one per line) of savefiles to read. + * + * In either case, we're reading a savefile, not doing + * a live capture. + */ +#ifndef _WIN32 + /* + * We don't need network access, so relinquish any set-UID + * or set-GID privileges we have (if any). + * + * We do *not* want set-UID privileges when opening a + * trace file, as that might let the user read other + * people's trace files (especially if we're set-UID + * root). + */ + if (setgid(getgid()) != 0 || setuid(getuid()) != 0 ) + fprintf(stderr, ""Warning: setgid/setuid failed !\n""); +#endif /* _WIN32 */ + if (VFileName != NULL) { + if (VFileName[0] == '-' && VFileName[1] == '\0') + VFile = stdin; + else + VFile = fopen(VFileName, ""r""); + + if (VFile == NULL) + error(""Unable to open file: %s\n"", pcap_strerror(errno)); + + ret = get_next_file(VFile, VFileLine); + if (!ret) + error(""Nothing in %s\n"", VFileName); + RFileName = VFileLine; + } + +#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION + pd = pcap_open_offline_with_tstamp_precision(RFileName, + ndo->ndo_tstamp_precision, ebuf); +#else + pd = pcap_open_offline(RFileName, ebuf); +#endif + + if (pd == NULL) + error(""%s"", ebuf); +#ifdef HAVE_CAPSICUM + cap_rights_init(&rights, CAP_READ); + if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 && + errno != ENOSYS) { + error(""unable to limit pcap descriptor""); + } +#endif + dlt = pcap_datalink(pd); + dlt_name = pcap_datalink_val_to_name(dlt); + if (dlt_name == NULL) { + fprintf(stderr, ""reading from file %s, link-type %u\n"", + RFileName, dlt); + } else { + fprintf(stderr, + ""reading from file %s, link-type %s (%s)\n"", + RFileName, dlt_name, + pcap_datalink_val_to_description(dlt)); + } + } else { + /* + * We're doing a live capture. + */ + if (device == NULL) { + /* + * No interface was specified. Pick one. + */ +#ifdef HAVE_PCAP_FINDALLDEVS + /* + * Find the list of interfaces, and pick + * the first interface. + */ + if (pcap_findalldevs(&devlist, ebuf) >= 0 && + devlist != NULL) { + device = strdup(devlist->name); + pcap_freealldevs(devlist); + } +#else /* HAVE_PCAP_FINDALLDEVS */ + /* + * Use whatever interface pcap_lookupdev() + * chooses. + */ + device = pcap_lookupdev(ebuf); +#endif + if (device == NULL) + error(""%s"", ebuf); + } + + /* + * Try to open the interface with the specified name. + */ + pd = open_interface(device, ndo, ebuf); + if (pd == NULL) { + /* + * That failed. If we can get a list of + * interfaces, and the interface name + * is purely numeric, try to use it as + * a 1-based index in the list of + * interfaces. + */ +#ifdef HAVE_PCAP_FINDALLDEVS + devnum = parse_interface_number(device); + if (devnum == -1) { + /* + * It's not a number; just report + * the open error and fail. + */ + error(""%s"", ebuf); + } + + /* + * OK, it's a number; try to find the + * interface with that index, and try + * to open it. + * + * find_interface_by_number() exits if it + * couldn't be found. + */ + device = find_interface_by_number(devnum); + pd = open_interface(device, ndo, ebuf); + if (pd == NULL) + error(""%s"", ebuf); +#else /* HAVE_PCAP_FINDALLDEVS */ + /* + * We can't get a list of interfaces; just + * fail. + */ + error(""%s"", ebuf); +#endif /* HAVE_PCAP_FINDALLDEVS */ + } + + /* + * Let user own process after socket has been opened. + */ +#ifndef _WIN32 + if (setgid(getgid()) != 0 || setuid(getuid()) != 0) + fprintf(stderr, ""Warning: setgid/setuid failed !\n""); +#endif /* _WIN32 */ +#if !defined(HAVE_PCAP_CREATE) && defined(_WIN32) + if(Bflag != 0) + if(pcap_setbuff(pd, Bflag)==-1){ + error(""%s"", pcap_geterr(pd)); + } +#endif /* !defined(HAVE_PCAP_CREATE) && defined(_WIN32) */ + if (Lflag) + show_dlts_and_exit(pd, device); + if (yflag_dlt >= 0) { +#ifdef HAVE_PCAP_SET_DATALINK + if (pcap_set_datalink(pd, yflag_dlt) < 0) + error(""%s"", pcap_geterr(pd)); +#else + /* + * We don't actually support changing the + * data link type, so we only let them + * set it to what it already is. + */ + if (yflag_dlt != pcap_datalink(pd)) { + error(""%s is not one of the DLTs supported by this device\n"", + yflag_dlt_name); + } +#endif + (void)fprintf(stderr, ""%s: data link type %s\n"", + program_name, yflag_dlt_name); + (void)fflush(stderr); + } + i = pcap_snapshot(pd); + if (ndo->ndo_snaplen < i) { + warning(""snaplen raised from %d to %d"", ndo->ndo_snaplen, i); + ndo->ndo_snaplen = i; + } + if(ndo->ndo_fflag != 0) { + if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) { + warning(""foreign (-f) flag used but: %s"", ebuf); + } + } + + } + if (infile) + cmdbuf = read_infile(infile); + else + cmdbuf = copy_argv(&argv[optind]); + +#ifdef HAVE_PCAP_SET_OPTIMIZER_DEBUG + pcap_set_optimizer_debug(dflag); +#endif + if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) + error(""%s"", pcap_geterr(pd)); + if (dflag) { + bpf_dump(&fcode, dflag); + pcap_close(pd); + free(cmdbuf); + pcap_freecode(&fcode); + exit_tcpdump(0); + } + init_print(ndo, localnet, netmask, timezone_offset); + +#ifndef _WIN32 + (void)setsignal(SIGPIPE, cleanup); + (void)setsignal(SIGTERM, cleanup); + (void)setsignal(SIGINT, cleanup); +#endif /* _WIN32 */ +#if defined(HAVE_FORK) || defined(HAVE_VFORK) + (void)setsignal(SIGCHLD, child_cleanup); +#endif + /* Cooperate with nohup(1) */ +#ifndef _WIN32 + if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) + (void)setsignal(SIGHUP, oldhandler); +#endif /* _WIN32 */ + +#ifndef _WIN32 + /* + * If a user name was specified with ""-Z"", attempt to switch to + * that user's UID. This would probably be used with sudo, + * to allow tcpdump to be run in a special restricted + * account (if you just want to allow users to open capture + * devices, and can't just give users that permission, + * you'd make tcpdump set-UID or set-GID). + * + * Tcpdump doesn't necessarily write only to one savefile; + * the general only way to allow a -Z instance to write to + * savefiles as the user under whose UID it's run, rather + * than as the user specified with -Z, would thus be to switch + * to the original user ID before opening a capture file and + * then switch back to the -Z user ID after opening the savefile. + * Switching to the -Z user ID only after opening the first + * savefile doesn't handle the general case. + */ + + if (getuid() == 0 || geteuid() == 0) { +#ifdef HAVE_LIBCAP_NG + /* Initialize capng */ + capng_clear(CAPNG_SELECT_BOTH); + if (username) { + capng_updatev( + CAPNG_ADD, + CAPNG_PERMITTED | CAPNG_EFFECTIVE, + CAP_SETUID, + CAP_SETGID, + -1); + } + if (chroot_dir) { + capng_update( + CAPNG_ADD, + CAPNG_PERMITTED | CAPNG_EFFECTIVE, + CAP_SYS_CHROOT + ); + } + + if (WFileName) { + capng_update( + CAPNG_ADD, + CAPNG_PERMITTED | CAPNG_EFFECTIVE, + CAP_DAC_OVERRIDE + ); + } + capng_apply(CAPNG_SELECT_BOTH); +#endif /* HAVE_LIBCAP_NG */ + if (username || chroot_dir) + droproot(username, chroot_dir); + + } +#endif /* _WIN32 */ + + if (pcap_setfilter(pd, &fcode) < 0) + error(""%s"", pcap_geterr(pd)); +#ifdef HAVE_CAPSICUM + if (RFileName == NULL && VFileName == NULL) { + static const unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF }; + + /* + * The various libpcap devices use a combination of + * read (bpf), ioctl (bpf, netmap), poll (netmap) + * so we add the relevant access rights. + */ + cap_rights_init(&rights, CAP_IOCTL, CAP_READ, CAP_EVENT); + if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 && + errno != ENOSYS) { + error(""unable to limit pcap descriptor""); + } + if (cap_ioctls_limit(pcap_fileno(pd), cmds, + sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) { + error(""unable to limit ioctls on pcap descriptor""); + } + } +#endif + if (WFileName) { + pcap_dumper_t *p; + /* Do not exceed the default PATH_MAX for files. */ + dumpinfo.CurrentFileName = (char *)malloc(PATH_MAX + 1); + + if (dumpinfo.CurrentFileName == NULL) + error(""malloc of dumpinfo.CurrentFileName""); + + /* We do not need numbering for dumpfiles if Cflag isn't set. */ + if (Cflag != 0) + MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, WflagChars); + else + MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0); + + p = pcap_dump_open(pd, dumpinfo.CurrentFileName); +#ifdef HAVE_LIBCAP_NG + /* Give up CAP_DAC_OVERRIDE capability. + * Only allow it to be restored if the -C or -G flag have been + * set since we may need to create more files later on. + */ + capng_update( + CAPNG_DROP, + (Cflag || Gflag ? 0 : CAPNG_PERMITTED) + | CAPNG_EFFECTIVE, + CAP_DAC_OVERRIDE + ); + capng_apply(CAPNG_SELECT_BOTH); +#endif /* HAVE_LIBCAP_NG */ + if (p == NULL) + error(""%s"", pcap_geterr(pd)); +#ifdef HAVE_CAPSICUM + set_dumper_capsicum_rights(p); +#endif + if (Cflag != 0 || Gflag != 0) { +#ifdef HAVE_CAPSICUM + dumpinfo.WFileName = strdup(basename(WFileName)); + if (dumpinfo.WFileName == NULL) { + error(""Unable to allocate memory for file %s"", + WFileName); + } + dumpinfo.dirfd = open(dirname(WFileName), + O_DIRECTORY | O_RDONLY); + if (dumpinfo.dirfd < 0) { + error(""unable to open directory %s"", + dirname(WFileName)); + } + cap_rights_init(&rights, CAP_CREATE, CAP_FCNTL, + CAP_FTRUNCATE, CAP_LOOKUP, CAP_SEEK, CAP_WRITE); + if (cap_rights_limit(dumpinfo.dirfd, &rights) < 0 && + errno != ENOSYS) { + error(""unable to limit directory rights""); + } + if (cap_fcntls_limit(dumpinfo.dirfd, CAP_FCNTL_GETFL) < 0 && + errno != ENOSYS) { + error(""unable to limit dump descriptor fcntls""); + } +#else /* !HAVE_CAPSICUM */ + dumpinfo.WFileName = WFileName; +#endif + callback = dump_packet_and_trunc; + dumpinfo.pd = pd; + dumpinfo.p = p; + pcap_userdata = (u_char *)&dumpinfo; + } else { + callback = dump_packet; + pcap_userdata = (u_char *)p; + } +#ifdef HAVE_PCAP_DUMP_FLUSH + if (Uflag) + pcap_dump_flush(p); +#endif + } else { + dlt = pcap_datalink(pd); + ndo->ndo_if_printer = get_if_printer(ndo, dlt); + callback = print_packet; + pcap_userdata = (u_char *)ndo; + } + +#ifdef SIGNAL_REQ_INFO + /* + * We can't get statistics when reading from a file rather + * than capturing from a device. + */ + if (RFileName == NULL) + (void)setsignal(SIGNAL_REQ_INFO, requestinfo); +#endif + + if (ndo->ndo_vflag > 0 && WFileName) { + /* + * When capturing to a file, ""-v"" means tcpdump should, + * every 10 seconds, ""v""erbosely report the number of + * packets captured. + */ +#ifdef USE_WIN32_MM_TIMER + /* call verbose_stats_dump() each 1000 +/-100msec */ + timer_id = timeSetEvent(1000, 100, verbose_stats_dump, 0, TIME_PERIODIC); + setvbuf(stderr, NULL, _IONBF, 0); +#elif defined(HAVE_ALARM) + (void)setsignal(SIGALRM, verbose_stats_dump); + alarm(1); +#endif + } + + if (RFileName == NULL) { + /* + * Live capture (if -V was specified, we set RFileName + * to a file from the -V file). Print a message to + * the standard error on UN*X. + */ + if (!ndo->ndo_vflag && !WFileName) { + (void)fprintf(stderr, + ""%s: verbose output suppressed, use -v or -vv for full protocol decode\n"", + program_name); + } else + (void)fprintf(stderr, ""%s: "", program_name); + dlt = pcap_datalink(pd); + dlt_name = pcap_datalink_val_to_name(dlt); + if (dlt_name == NULL) { + (void)fprintf(stderr, ""listening on %s, link-type %u, capture size %u bytes\n"", + device, dlt, ndo->ndo_snaplen); + } else { + (void)fprintf(stderr, ""listening on %s, link-type %s (%s), capture size %u bytes\n"", + device, dlt_name, + pcap_datalink_val_to_description(dlt), ndo->ndo_snaplen); + } + (void)fflush(stderr); + } + +#ifdef HAVE_CAPSICUM + cansandbox = (ndo->ndo_nflag && VFileName == NULL && zflag == NULL); + if (cansandbox && cap_enter() < 0 && errno != ENOSYS) + error(""unable to enter the capability mode""); +#endif /* HAVE_CAPSICUM */ + + do { + status = pcap_loop(pd, cnt, callback, pcap_userdata); + if (WFileName == NULL) { + /* + * We're printing packets. Flush the printed output, + * so it doesn't get intermingled with error output. + */ + if (status == -2) { + /* + * We got interrupted, so perhaps we didn't + * manage to finish a line we were printing. + * Print an extra newline, just in case. + */ + putchar('\n'); + } + (void)fflush(stdout); + } + if (status == -2) { + /* + * We got interrupted. If we are reading multiple + * files (via -V) set these so that we stop. + */ + VFileName = NULL; + ret = NULL; + } + if (status == -1) { + /* + * Error. Report it. + */ + (void)fprintf(stderr, ""%s: pcap_loop: %s\n"", + program_name, pcap_geterr(pd)); + } + if (RFileName == NULL) { + /* + * We're doing a live capture. Report the capture + * statistics. + */ + info(1); + } + pcap_close(pd); + if (VFileName != NULL) { + ret = get_next_file(VFile, VFileLine); + if (ret) { + int new_dlt; + + RFileName = VFileLine; + pd = pcap_open_offline(RFileName, ebuf); + if (pd == NULL) + error(""%s"", ebuf); +#ifdef HAVE_CAPSICUM + cap_rights_init(&rights, CAP_READ); + if (cap_rights_limit(fileno(pcap_file(pd)), + &rights) < 0 && errno != ENOSYS) { + error(""unable to limit pcap descriptor""); + } +#endif + new_dlt = pcap_datalink(pd); + if (new_dlt != dlt) { + /* + * The new file has a different + * link-layer header type from the + * previous one. + */ + if (WFileName != NULL) { + /* + * We're writing raw packets + * that match the filter to + * a pcap file. pcap files + * don't support multiple + * different link-layer + * header types, so we fail + * here. + */ + error(""%s: new dlt does not match original"", RFileName); + } + + /* + * We're printing the decoded packets; + * switch to the new DLT. + * + * To do that, we need to change + * the printer, change the DLT name, + * and recompile the filter with + * the new DLT. + */ + dlt = new_dlt; + ndo->ndo_if_printer = get_if_printer(ndo, dlt); + if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) + error(""%s"", pcap_geterr(pd)); + } + + /* + * Set the filter on the new file. + */ + if (pcap_setfilter(pd, &fcode) < 0) + error(""%s"", pcap_geterr(pd)); + + /* + * Report the new file. + */ + dlt_name = pcap_datalink_val_to_name(dlt); + if (dlt_name == NULL) { + fprintf(stderr, ""reading from file %s, link-type %u\n"", + RFileName, dlt); + } else { + fprintf(stderr, + ""reading from file %s, link-type %s (%s)\n"", + RFileName, dlt_name, + pcap_datalink_val_to_description(dlt)); + } + } + } + } + while (ret != NULL); + + free(cmdbuf); + pcap_freecode(&fcode); + exit_tcpdump(status == -1 ? 1 : 0); +} +",0,"main(int argc, char **argv) +{ + register int cnt, op, i; + bpf_u_int32 localnet =0 , netmask = 0; + int timezone_offset = 0; + register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName; + pcap_handler callback; + int dlt; + const char *dlt_name; + struct bpf_program fcode; +#ifndef _WIN32 + RETSIGTYPE (*oldhandler)(int); +#endif + struct dump_info dumpinfo; + u_char *pcap_userdata; + char ebuf[PCAP_ERRBUF_SIZE]; + char VFileLine[PATH_MAX + 1]; + char *username = NULL; + char *chroot_dir = NULL; + char *ret = NULL; + char *end; +#ifdef HAVE_PCAP_FINDALLDEVS + pcap_if_t *devlist; + long devnum; +#endif + int status; + FILE *VFile; +#ifdef HAVE_CAPSICUM + cap_rights_t rights; + int cansandbox; +#endif /* HAVE_CAPSICUM */ + int Oflag = 1; /* run filter code optimizer */ + int yflag_dlt = -1; + const char *yflag_dlt_name = NULL; + + netdissect_options Ndo; + netdissect_options *ndo = &Ndo; + + /* + * Initialize the netdissect code. + */ + if (nd_init(ebuf, sizeof ebuf) == -1) + error(""%s"", ebuf); + + memset(ndo, 0, sizeof(*ndo)); + ndo_set_function_pointers(ndo); + ndo->ndo_snaplen = DEFAULT_SNAPLEN; + + cnt = -1; + device = NULL; + infile = NULL; + RFileName = NULL; + VFileName = NULL; + VFile = NULL; + WFileName = NULL; + dlt = -1; + if ((cp = strrchr(argv[0], '/')) != NULL) + ndo->program_name = program_name = cp + 1; + else + ndo->program_name = program_name = argv[0]; + +#ifdef _WIN32 + if (pcap_wsockinit() != 0) + error(""Attempting to initialize Winsock failed""); +#endif /* _WIN32 */ + + /* + * On platforms where the CPU doesn't support unaligned loads, + * force unaligned accesses to abort with SIGBUS, rather than + * being fixed up (slowly) by the OS kernel; on those platforms, + * misaligned accesses are bugs, and we want tcpdump to crash so + * that the bugs are reported. + */ + if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0) + error(""%s"", ebuf); + + while ( + (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1) + switch (op) { + + case 'a': + /* compatibility for old -a */ + break; + + case 'A': + ++ndo->ndo_Aflag; + break; + + case 'b': + ++ndo->ndo_bflag; + break; + +#if defined(HAVE_PCAP_CREATE) || defined(_WIN32) + case 'B': + Bflag = atoi(optarg)*1024; + if (Bflag <= 0) + error(""invalid packet buffer size %s"", optarg); + break; +#endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */ + + case 'c': + cnt = atoi(optarg); + if (cnt <= 0) + error(""invalid packet count %s"", optarg); + break; + + case 'C': + Cflag = atoi(optarg) * 1000000; + if (Cflag <= 0) + error(""invalid file size %s"", optarg); + break; + + case 'd': + ++dflag; + break; + + case 'D': + Dflag++; + break; + + case 'L': + Lflag++; + break; + + case 'e': + ++ndo->ndo_eflag; + break; + + case 'E': +#ifndef HAVE_LIBCRYPTO + warning(""crypto code not compiled in""); +#endif + ndo->ndo_espsecret = optarg; + break; + + case 'f': + ++ndo->ndo_fflag; + break; + + case 'F': + infile = optarg; + break; + + case 'G': + Gflag = atoi(optarg); + if (Gflag < 0) + error(""invalid number of seconds %s"", optarg); + + /* We will create one file initially. */ + Gflag_count = 0; + + /* Grab the current time for rotation use. */ + if ((Gflag_time = time(NULL)) == (time_t)-1) { + error(""main: can't get current time: %s"", + pcap_strerror(errno)); + } + break; + + case 'h': + print_usage(); + exit_tcpdump(0); + break; + + case 'H': + ++ndo->ndo_Hflag; + break; + + case 'i': + device = optarg; + break; + +#ifdef HAVE_PCAP_CREATE + case 'I': + ++Iflag; + break; +#endif /* HAVE_PCAP_CREATE */ + +#ifdef HAVE_PCAP_SET_TSTAMP_TYPE + case 'j': + jflag = pcap_tstamp_type_name_to_val(optarg); + if (jflag < 0) + error(""invalid time stamp type %s"", optarg); + break; + + case 'J': + Jflag++; + break; +#endif + + case 'l': +#ifdef _WIN32 + /* + * _IOLBF is the same as _IOFBF in Microsoft's C + * libraries; the only alternative they offer + * is _IONBF. + * + * XXX - this should really be checking for MSVC++, + * not _WIN32, if, for example, MinGW has its own + * C library that is more UNIX-compatible. + */ + setvbuf(stdout, NULL, _IONBF, 0); +#else /* _WIN32 */ +#ifdef HAVE_SETLINEBUF + setlinebuf(stdout); +#else + setvbuf(stdout, NULL, _IOLBF, 0); +#endif +#endif /* _WIN32 */ + break; + + case 'K': + ++ndo->ndo_Kflag; + break; + + case 'm': + if (nd_have_smi_support()) { + if (nd_load_smi_module(optarg, ebuf, sizeof ebuf) == -1) + error(""%s"", ebuf); + } else { + (void)fprintf(stderr, ""%s: ignoring option `-m %s' "", + program_name, optarg); + (void)fprintf(stderr, ""(no libsmi support)\n""); + } + break; + + case 'M': + /* TCP-MD5 shared secret */ +#ifndef HAVE_LIBCRYPTO + warning(""crypto code not compiled in""); +#endif + ndo->ndo_sigsecret = optarg; + break; + + case 'n': + ++ndo->ndo_nflag; + break; + + case 'N': + ++ndo->ndo_Nflag; + break; + + case 'O': + Oflag = 0; + break; + + case 'p': + ++pflag; + break; + + case 'q': + ++ndo->ndo_qflag; + ++ndo->ndo_suppress_default_print; + break; + +#ifdef HAVE_PCAP_SETDIRECTION + case 'Q': + if (ascii_strcasecmp(optarg, ""in"") == 0) + Qflag = PCAP_D_IN; + else if (ascii_strcasecmp(optarg, ""out"") == 0) + Qflag = PCAP_D_OUT; + else if (ascii_strcasecmp(optarg, ""inout"") == 0) + Qflag = PCAP_D_INOUT; + else + error(""unknown capture direction `%s'"", optarg); + break; +#endif /* HAVE_PCAP_SETDIRECTION */ + + case 'r': + RFileName = optarg; + break; + + case 's': + ndo->ndo_snaplen = strtol(optarg, &end, 0); + if (optarg == end || *end != '\0' + || ndo->ndo_snaplen < 0 || ndo->ndo_snaplen > MAXIMUM_SNAPLEN) + error(""invalid snaplen %s"", optarg); + else if (ndo->ndo_snaplen == 0) + ndo->ndo_snaplen = MAXIMUM_SNAPLEN; + break; + + case 'S': + ++ndo->ndo_Sflag; + break; + + case 't': + ++ndo->ndo_tflag; + break; + + case 'T': + if (ascii_strcasecmp(optarg, ""vat"") == 0) + ndo->ndo_packettype = PT_VAT; + else if (ascii_strcasecmp(optarg, ""wb"") == 0) + ndo->ndo_packettype = PT_WB; + else if (ascii_strcasecmp(optarg, ""rpc"") == 0) + ndo->ndo_packettype = PT_RPC; + else if (ascii_strcasecmp(optarg, ""rtp"") == 0) + ndo->ndo_packettype = PT_RTP; + else if (ascii_strcasecmp(optarg, ""rtcp"") == 0) + ndo->ndo_packettype = PT_RTCP; + else if (ascii_strcasecmp(optarg, ""snmp"") == 0) + ndo->ndo_packettype = PT_SNMP; + else if (ascii_strcasecmp(optarg, ""cnfp"") == 0) + ndo->ndo_packettype = PT_CNFP; + else if (ascii_strcasecmp(optarg, ""tftp"") == 0) + ndo->ndo_packettype = PT_TFTP; + else if (ascii_strcasecmp(optarg, ""aodv"") == 0) + ndo->ndo_packettype = PT_AODV; + else if (ascii_strcasecmp(optarg, ""carp"") == 0) + ndo->ndo_packettype = PT_CARP; + else if (ascii_strcasecmp(optarg, ""radius"") == 0) + ndo->ndo_packettype = PT_RADIUS; + else if (ascii_strcasecmp(optarg, ""zmtp1"") == 0) + ndo->ndo_packettype = PT_ZMTP1; + else if (ascii_strcasecmp(optarg, ""vxlan"") == 0) + ndo->ndo_packettype = PT_VXLAN; + else if (ascii_strcasecmp(optarg, ""pgm"") == 0) + ndo->ndo_packettype = PT_PGM; + else if (ascii_strcasecmp(optarg, ""pgm_zmtp1"") == 0) + ndo->ndo_packettype = PT_PGM_ZMTP1; + else if (ascii_strcasecmp(optarg, ""lmp"") == 0) + ndo->ndo_packettype = PT_LMP; + else if (ascii_strcasecmp(optarg, ""resp"") == 0) + ndo->ndo_packettype = PT_RESP; + else + error(""unknown packet type `%s'"", optarg); + break; + + case 'u': + ++ndo->ndo_uflag; + break; + +#ifdef HAVE_PCAP_DUMP_FLUSH + case 'U': + ++Uflag; + break; +#endif + + case 'v': + ++ndo->ndo_vflag; + break; + + case 'V': + VFileName = optarg; + break; + + case 'w': + WFileName = optarg; + break; + + case 'W': + Wflag = atoi(optarg); + if (Wflag <= 0) + error(""invalid number of output files %s"", optarg); + WflagChars = getWflagChars(Wflag); + break; + + case 'x': + ++ndo->ndo_xflag; + ++ndo->ndo_suppress_default_print; + break; + + case 'X': + ++ndo->ndo_Xflag; + ++ndo->ndo_suppress_default_print; + break; + + case 'y': + yflag_dlt_name = optarg; + yflag_dlt = + pcap_datalink_name_to_val(yflag_dlt_name); + if (yflag_dlt < 0) + error(""invalid data link type %s"", yflag_dlt_name); + break; + +#ifdef HAVE_PCAP_SET_PARSER_DEBUG + case 'Y': + { + /* Undocumented flag */ + pcap_set_parser_debug(1); + } + break; +#endif + case 'z': + zflag = optarg; + break; + + case 'Z': + username = optarg; + break; + + case '#': + ndo->ndo_packet_number = 1; + break; + + case OPTION_VERSION: + print_version(); + exit_tcpdump(0); + break; + +#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION + case OPTION_TSTAMP_PRECISION: + ndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg); + if (ndo->ndo_tstamp_precision < 0) + error(""unsupported time stamp precision""); + break; +#endif + +#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE + case OPTION_IMMEDIATE_MODE: + immediate_mode = 1; + break; +#endif + + default: + print_usage(); + exit_tcpdump(1); + /* NOTREACHED */ + } + +#ifdef HAVE_PCAP_FINDALLDEVS + if (Dflag) + show_devices_and_exit(); +#endif + + switch (ndo->ndo_tflag) { + + case 0: /* Default */ + case 4: /* Default + Date*/ + timezone_offset = gmt2local(0); + break; + + case 1: /* No time stamp */ + case 2: /* Unix timeval style */ + case 3: /* Microseconds since previous packet */ + case 5: /* Microseconds since first packet */ + break; + + default: /* Not supported */ + error(""only -t, -tt, -ttt, -tttt and -ttttt are supported""); + break; + } + + if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL)) + error(""-f can not be used with -V or -r""); + + if (VFileName != NULL && RFileName != NULL) + error(""-V and -r are mutually exclusive.""); + +#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE + /* + * If we're printing dissected packets to the standard output + * rather than saving raw packets to a file, and the standard + * output is a terminal, use immediate mode, as the user's + * probably expecting to see packets pop up immediately. + */ + if (WFileName == NULL && isatty(1)) + immediate_mode = 1; +#endif + +#ifdef WITH_CHROOT + /* if run as root, prepare for chrooting */ + if (getuid() == 0 || geteuid() == 0) { + /* future extensibility for cmd-line arguments */ + if (!chroot_dir) + chroot_dir = WITH_CHROOT; + } +#endif + +#ifdef WITH_USER + /* if run as root, prepare for dropping root privileges */ + if (getuid() == 0 || geteuid() == 0) { + /* Run with '-Z root' to restore old behaviour */ + if (!username) + username = WITH_USER; + } +#endif + + if (RFileName != NULL || VFileName != NULL) { + /* + * If RFileName is non-null, it's the pathname of a + * savefile to read. If VFileName is non-null, it's + * the pathname of a file containing a list of pathnames + * (one per line) of savefiles to read. + * + * In either case, we're reading a savefile, not doing + * a live capture. + */ +#ifndef _WIN32 + /* + * We don't need network access, so relinquish any set-UID + * or set-GID privileges we have (if any). + * + * We do *not* want set-UID privileges when opening a + * trace file, as that might let the user read other + * people's trace files (especially if we're set-UID + * root). + */ + if (setgid(getgid()) != 0 || setuid(getuid()) != 0 ) + fprintf(stderr, ""Warning: setgid/setuid failed !\n""); +#endif /* _WIN32 */ + if (VFileName != NULL) { + if (VFileName[0] == '-' && VFileName[1] == '\0') + VFile = stdin; + else + VFile = fopen(VFileName, ""r""); + + if (VFile == NULL) + error(""Unable to open file: %s\n"", pcap_strerror(errno)); + + ret = get_next_file(VFile, VFileLine); + if (!ret) + error(""Nothing in %s\n"", VFileName); + RFileName = VFileLine; + } + +#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION + pd = pcap_open_offline_with_tstamp_precision(RFileName, + ndo->ndo_tstamp_precision, ebuf); +#else + pd = pcap_open_offline(RFileName, ebuf); +#endif + + if (pd == NULL) + error(""%s"", ebuf); +#ifdef HAVE_CAPSICUM + cap_rights_init(&rights, CAP_READ); + if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 && + errno != ENOSYS) { + error(""unable to limit pcap descriptor""); + } +#endif + dlt = pcap_datalink(pd); + dlt_name = pcap_datalink_val_to_name(dlt); + if (dlt_name == NULL) { + fprintf(stderr, ""reading from file %s, link-type %u\n"", + RFileName, dlt); + } else { + fprintf(stderr, + ""reading from file %s, link-type %s (%s)\n"", + RFileName, dlt_name, + pcap_datalink_val_to_description(dlt)); + } + } else { + /* + * We're doing a live capture. + */ + if (device == NULL) { + /* + * No interface was specified. Pick one. + */ +#ifdef HAVE_PCAP_FINDALLDEVS + /* + * Find the list of interfaces, and pick + * the first interface. + */ + if (pcap_findalldevs(&devlist, ebuf) >= 0 && + devlist != NULL) { + device = strdup(devlist->name); + pcap_freealldevs(devlist); + } +#else /* HAVE_PCAP_FINDALLDEVS */ + /* + * Use whatever interface pcap_lookupdev() + * chooses. + */ + device = pcap_lookupdev(ebuf); +#endif + if (device == NULL) + error(""%s"", ebuf); + } + + /* + * Try to open the interface with the specified name. + */ + pd = open_interface(device, ndo, ebuf); + if (pd == NULL) { + /* + * That failed. If we can get a list of + * interfaces, and the interface name + * is purely numeric, try to use it as + * a 1-based index in the list of + * interfaces. + */ +#ifdef HAVE_PCAP_FINDALLDEVS + devnum = parse_interface_number(device); + if (devnum == -1) { + /* + * It's not a number; just report + * the open error and fail. + */ + error(""%s"", ebuf); + } + + /* + * OK, it's a number; try to find the + * interface with that index, and try + * to open it. + * + * find_interface_by_number() exits if it + * couldn't be found. + */ + device = find_interface_by_number(devnum); + pd = open_interface(device, ndo, ebuf); + if (pd == NULL) + error(""%s"", ebuf); +#else /* HAVE_PCAP_FINDALLDEVS */ + /* + * We can't get a list of interfaces; just + * fail. + */ + error(""%s"", ebuf); +#endif /* HAVE_PCAP_FINDALLDEVS */ + } + + /* + * Let user own process after socket has been opened. + */ +#ifndef _WIN32 + if (setgid(getgid()) != 0 || setuid(getuid()) != 0) + fprintf(stderr, ""Warning: setgid/setuid failed !\n""); +#endif /* _WIN32 */ +#if !defined(HAVE_PCAP_CREATE) && defined(_WIN32) + if(Bflag != 0) + if(pcap_setbuff(pd, Bflag)==-1){ + error(""%s"", pcap_geterr(pd)); + } +#endif /* !defined(HAVE_PCAP_CREATE) && defined(_WIN32) */ + if (Lflag) + show_dlts_and_exit(pd, device); + if (yflag_dlt >= 0) { +#ifdef HAVE_PCAP_SET_DATALINK + if (pcap_set_datalink(pd, yflag_dlt) < 0) + error(""%s"", pcap_geterr(pd)); +#else + /* + * We don't actually support changing the + * data link type, so we only let them + * set it to what it already is. + */ + if (yflag_dlt != pcap_datalink(pd)) { + error(""%s is not one of the DLTs supported by this device\n"", + yflag_dlt_name); + } +#endif + (void)fprintf(stderr, ""%s: data link type %s\n"", + program_name, yflag_dlt_name); + (void)fflush(stderr); + } + i = pcap_snapshot(pd); + if (ndo->ndo_snaplen < i) { + warning(""snaplen raised from %d to %d"", ndo->ndo_snaplen, i); + ndo->ndo_snaplen = i; + } + if(ndo->ndo_fflag != 0) { + if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) { + warning(""foreign (-f) flag used but: %s"", ebuf); + } + } + + } + if (infile) + cmdbuf = read_infile(infile); + else + cmdbuf = copy_argv(&argv[optind]); + +#ifdef HAVE_PCAP_SET_OPTIMIZER_DEBUG + pcap_set_optimizer_debug(dflag); +#endif + if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) + error(""%s"", pcap_geterr(pd)); + if (dflag) { + bpf_dump(&fcode, dflag); + pcap_close(pd); + free(cmdbuf); + pcap_freecode(&fcode); + exit_tcpdump(0); + } + init_print(ndo, localnet, netmask, timezone_offset); + +#ifndef _WIN32 + (void)setsignal(SIGPIPE, cleanup); + (void)setsignal(SIGTERM, cleanup); + (void)setsignal(SIGINT, cleanup); +#endif /* _WIN32 */ +#if defined(HAVE_FORK) || defined(HAVE_VFORK) + (void)setsignal(SIGCHLD, child_cleanup); +#endif + /* Cooperate with nohup(1) */ +#ifndef _WIN32 + if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) + (void)setsignal(SIGHUP, oldhandler); +#endif /* _WIN32 */ + +#ifndef _WIN32 + /* + * If a user name was specified with ""-Z"", attempt to switch to + * that user's UID. This would probably be used with sudo, + * to allow tcpdump to be run in a special restricted + * account (if you just want to allow users to open capture + * devices, and can't just give users that permission, + * you'd make tcpdump set-UID or set-GID). + * + * Tcpdump doesn't necessarily write only to one savefile; + * the general only way to allow a -Z instance to write to + * savefiles as the user under whose UID it's run, rather + * than as the user specified with -Z, would thus be to switch + * to the original user ID before opening a capture file and + * then switch back to the -Z user ID after opening the savefile. + * Switching to the -Z user ID only after opening the first + * savefile doesn't handle the general case. + */ + + if (getuid() == 0 || geteuid() == 0) { +#ifdef HAVE_LIBCAP_NG + /* Initialize capng */ + capng_clear(CAPNG_SELECT_BOTH); + if (username) { + capng_updatev( + CAPNG_ADD, + CAPNG_PERMITTED | CAPNG_EFFECTIVE, + CAP_SETUID, + CAP_SETGID, + -1); + } + if (chroot_dir) { + capng_update( + CAPNG_ADD, + CAPNG_PERMITTED | CAPNG_EFFECTIVE, + CAP_SYS_CHROOT + ); + } + + if (WFileName) { + capng_update( + CAPNG_ADD, + CAPNG_PERMITTED | CAPNG_EFFECTIVE, + CAP_DAC_OVERRIDE + ); + } + capng_apply(CAPNG_SELECT_BOTH); +#endif /* HAVE_LIBCAP_NG */ + if (username || chroot_dir) + droproot(username, chroot_dir); + + } +#endif /* _WIN32 */ + + if (pcap_setfilter(pd, &fcode) < 0) + error(""%s"", pcap_geterr(pd)); +#ifdef HAVE_CAPSICUM + if (RFileName == NULL && VFileName == NULL) { + static const unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF }; + + /* + * The various libpcap devices use a combination of + * read (bpf), ioctl (bpf, netmap), poll (netmap) + * so we add the relevant access rights. + */ + cap_rights_init(&rights, CAP_IOCTL, CAP_READ, CAP_EVENT); + if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 && + errno != ENOSYS) { + error(""unable to limit pcap descriptor""); + } + if (cap_ioctls_limit(pcap_fileno(pd), cmds, + sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) { + error(""unable to limit ioctls on pcap descriptor""); + } + } +#endif + if (WFileName) { + pcap_dumper_t *p; + /* Do not exceed the default PATH_MAX for files. */ + dumpinfo.CurrentFileName = (char *)malloc(PATH_MAX + 1); + + if (dumpinfo.CurrentFileName == NULL) + error(""malloc of dumpinfo.CurrentFileName""); + + /* We do not need numbering for dumpfiles if Cflag isn't set. */ + if (Cflag != 0) + MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, WflagChars); + else + MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0); + + p = pcap_dump_open(pd, dumpinfo.CurrentFileName); +#ifdef HAVE_LIBCAP_NG + /* Give up CAP_DAC_OVERRIDE capability. + * Only allow it to be restored if the -C or -G flag have been + * set since we may need to create more files later on. + */ + capng_update( + CAPNG_DROP, + (Cflag || Gflag ? 0 : CAPNG_PERMITTED) + | CAPNG_EFFECTIVE, + CAP_DAC_OVERRIDE + ); + capng_apply(CAPNG_SELECT_BOTH); +#endif /* HAVE_LIBCAP_NG */ + if (p == NULL) + error(""%s"", pcap_geterr(pd)); +#ifdef HAVE_CAPSICUM + set_dumper_capsicum_rights(p); +#endif + if (Cflag != 0 || Gflag != 0) { +#ifdef HAVE_CAPSICUM + dumpinfo.WFileName = strdup(basename(WFileName)); + if (dumpinfo.WFileName == NULL) { + error(""Unable to allocate memory for file %s"", + WFileName); + } + dumpinfo.dirfd = open(dirname(WFileName), + O_DIRECTORY | O_RDONLY); + if (dumpinfo.dirfd < 0) { + error(""unable to open directory %s"", + dirname(WFileName)); + } + cap_rights_init(&rights, CAP_CREATE, CAP_FCNTL, + CAP_FTRUNCATE, CAP_LOOKUP, CAP_SEEK, CAP_WRITE); + if (cap_rights_limit(dumpinfo.dirfd, &rights) < 0 && + errno != ENOSYS) { + error(""unable to limit directory rights""); + } + if (cap_fcntls_limit(dumpinfo.dirfd, CAP_FCNTL_GETFL) < 0 && + errno != ENOSYS) { + error(""unable to limit dump descriptor fcntls""); + } +#else /* !HAVE_CAPSICUM */ + dumpinfo.WFileName = WFileName; +#endif + callback = dump_packet_and_trunc; + dumpinfo.pd = pd; + dumpinfo.p = p; + pcap_userdata = (u_char *)&dumpinfo; + } else { + callback = dump_packet; + pcap_userdata = (u_char *)p; + } +#ifdef HAVE_PCAP_DUMP_FLUSH + if (Uflag) + pcap_dump_flush(p); +#endif + } else { + dlt = pcap_datalink(pd); + ndo->ndo_if_printer = get_if_printer(ndo, dlt); + callback = print_packet; + pcap_userdata = (u_char *)ndo; + } + +#ifdef SIGNAL_REQ_INFO + /* + * We can't get statistics when reading from a file rather + * than capturing from a device. + */ + if (RFileName == NULL) + (void)setsignal(SIGNAL_REQ_INFO, requestinfo); +#endif + + if (ndo->ndo_vflag > 0 && WFileName) { + /* + * When capturing to a file, ""-v"" means tcpdump should, + * every 10 seconds, ""v""erbosely report the number of + * packets captured. + */ +#ifdef USE_WIN32_MM_TIMER + /* call verbose_stats_dump() each 1000 +/-100msec */ + timer_id = timeSetEvent(1000, 100, verbose_stats_dump, 0, TIME_PERIODIC); + setvbuf(stderr, NULL, _IONBF, 0); +#elif defined(HAVE_ALARM) + (void)setsignal(SIGALRM, verbose_stats_dump); + alarm(1); +#endif + } + + if (RFileName == NULL) { + /* + * Live capture (if -V was specified, we set RFileName + * to a file from the -V file). Print a message to + * the standard error on UN*X. + */ + if (!ndo->ndo_vflag && !WFileName) { + (void)fprintf(stderr, + ""%s: verbose output suppressed, use -v or -vv for full protocol decode\n"", + program_name); + } else + (void)fprintf(stderr, ""%s: "", program_name); + dlt = pcap_datalink(pd); + dlt_name = pcap_datalink_val_to_name(dlt); + if (dlt_name == NULL) { + (void)fprintf(stderr, ""listening on %s, link-type %u, capture size %u bytes\n"", + device, dlt, ndo->ndo_snaplen); + } else { + (void)fprintf(stderr, ""listening on %s, link-type %s (%s), capture size %u bytes\n"", + device, dlt_name, + pcap_datalink_val_to_description(dlt), ndo->ndo_snaplen); + } + (void)fflush(stderr); + } + +#ifdef HAVE_CAPSICUM + cansandbox = (ndo->ndo_nflag && VFileName == NULL && zflag == NULL); + if (cansandbox && cap_enter() < 0 && errno != ENOSYS) + error(""unable to enter the capability mode""); +#endif /* HAVE_CAPSICUM */ + + do { + status = pcap_loop(pd, cnt, callback, pcap_userdata); + if (WFileName == NULL) { + /* + * We're printing packets. Flush the printed output, + * so it doesn't get intermingled with error output. + */ + if (status == -2) { + /* + * We got interrupted, so perhaps we didn't + * manage to finish a line we were printing. + * Print an extra newline, just in case. + */ + putchar('\n'); + } + (void)fflush(stdout); + } + if (status == -2) { + /* + * We got interrupted. If we are reading multiple + * files (via -V) set these so that we stop. + */ + VFileName = NULL; + ret = NULL; + } + if (status == -1) { + /* + * Error. Report it. + */ + (void)fprintf(stderr, ""%s: pcap_loop: %s\n"", + program_name, pcap_geterr(pd)); + } + if (RFileName == NULL) { + /* + * We're doing a live capture. Report the capture + * statistics. + */ + info(1); + } + pcap_close(pd); + if (VFileName != NULL) { + ret = get_next_file(VFile, VFileLine); + if (ret) { + int new_dlt; + + RFileName = VFileLine; + pd = pcap_open_offline(RFileName, ebuf); + if (pd == NULL) + error(""%s"", ebuf); +#ifdef HAVE_CAPSICUM + cap_rights_init(&rights, CAP_READ); + if (cap_rights_limit(fileno(pcap_file(pd)), + &rights) < 0 && errno != ENOSYS) { + error(""unable to limit pcap descriptor""); + } +#endif + new_dlt = pcap_datalink(pd); + if (new_dlt != dlt) { + /* + * The new file has a different + * link-layer header type from the + * previous one. + */ + if (WFileName != NULL) { + /* + * We're writing raw packets + * that match the filter to + * a pcap file. pcap files + * don't support multiple + * different link-layer + * header types, so we fail + * here. + */ + error(""%s: new dlt does not match original"", RFileName); + } + + /* + * We're printing the decoded packets; + * switch to the new DLT. + * + * To do that, we need to change + * the printer, change the DLT name, + * and recompile the filter with + * the new DLT. + */ + dlt = new_dlt; + ndo->ndo_if_printer = get_if_printer(ndo, dlt); + if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) + error(""%s"", pcap_geterr(pd)); + } + + /* + * Set the filter on the new file. + */ + if (pcap_setfilter(pd, &fcode) < 0) + error(""%s"", pcap_geterr(pd)); + + /* + * Report the new file. + */ + dlt_name = pcap_datalink_val_to_name(dlt); + if (dlt_name == NULL) { + fprintf(stderr, ""reading from file %s, link-type %u\n"", + RFileName, dlt); + } else { + fprintf(stderr, + ""reading from file %s, link-type %s (%s)\n"", + RFileName, dlt_name, + pcap_datalink_val_to_description(dlt)); + } + } + } + } + while (ret != NULL); + + free(cmdbuf); + pcap_freecode(&fcode); + exit_tcpdump(status == -1 ? 1 : 0); +} +","@@ -699,13 +699,15 @@ static char * + get_next_file(FILE *VFile, char *ptr) + { + char *ret; ++ size_t len; + + ret = fgets(ptr, PATH_MAX, VFile); + if (!ret) + return NULL; + +- if (ptr[strlen(ptr) - 1] == '\n') +- ptr[strlen(ptr) - 1] = '\0'; ++ len = strlen (ptr); ++ if (len > 0 && ptr[len - 1] == '\n') ++ ptr[len - 1] = '\0'; + + return ret; + }",7833,8069,8192 +18252,"add_job(cupsd_client_t *con, /* I - Client connection */ + cupsd_printer_t *printer, /* I - Destination printer */ + mime_type_t *filetype) /* I - First print file type, if any */ +{ + http_status_t status; /* Policy status */ + ipp_attribute_t *attr, /* Current attribute */ + *auth_info; /* auth-info attribute */ + const char *mandatory; /* Current mandatory job attribute */ + const char *val; /* Default option value */ + int priority; /* Job priority */ + cupsd_job_t *job; /* Current job */ + char job_uri[HTTP_MAX_URI]; /* Job URI */ + int kbytes; /* Size of print file */ + int i; /* Looping var */ + int lowerpagerange; /* Page range bound */ + int exact; /* Did we have an exact match? */ + ipp_attribute_t *media_col, /* media-col attribute */ + *media_margin; /* media-*-margin attribute */ + ipp_t *unsup_col; /* media-col in unsupported response */ + static const char * const readonly[] =/* List of read-only attributes */ + { + ""date-time-at-completed"", + ""date-time-at-creation"", + ""date-time-at-processing"", + ""job-detailed-status-messages"", + ""job-document-access-errors"", + ""job-id"", + ""job-impressions-completed"", + ""job-k-octets-completed"", + ""job-media-sheets-completed"", + ""job-pages-completed"", + ""job-printer-up-time"", + ""job-printer-uri"", + ""job-state"", + ""job-state-message"", + ""job-state-reasons"", + ""job-uri"", + ""number-of-documents"", + ""number-of-intervening-jobs"", + ""output-device-assigned"", + ""time-at-completed"", + ""time-at-creation"", + ""time-at-processing"" + }; + + + cupsdLogMessage(CUPSD_LOG_DEBUG2, ""add_job(%p[%d], %p(%s), %p(%s/%s))"", + con, con->number, printer, printer->name, + filetype, filetype ? filetype->super : ""none"", + filetype ? filetype->type : ""none""); + + /* + * Check remote printing to non-shared printer... + */ + + if (!printer->shared && + _cups_strcasecmp(con->http->hostname, ""localhost"") && + _cups_strcasecmp(con->http->hostname, ServerName)) + { + send_ipp_status(con, IPP_NOT_AUTHORIZED, + _(""The printer or class is not shared."")); + return (NULL); + } + + /* + * Check policy... + */ + + auth_info = ippFindAttribute(con->request, ""auth-info"", IPP_TAG_TEXT); + + if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK) + { + send_http_error(con, status, printer); + return (NULL); + } + else if (printer->num_auth_info_required == 1 && + !strcmp(printer->auth_info_required[0], ""negotiate"") && + !con->username[0]) + { + send_http_error(con, HTTP_UNAUTHORIZED, printer); + return (NULL); + } +#ifdef HAVE_SSL + else if (auth_info && !con->http->tls && + !httpAddrLocalhost(con->http->hostaddr)) + { + /* + * Require encryption of auth-info over non-local connections... + */ + + send_http_error(con, HTTP_UPGRADE_REQUIRED, printer); + return (NULL); + } +#endif /* HAVE_SSL */ + + /* + * See if the printer is accepting jobs... + */ + + if (!printer->accepting) + { + send_ipp_status(con, IPP_NOT_ACCEPTING, + _(""Destination \""%s\"" is not accepting jobs.""), + printer->name); + return (NULL); + } + + /* + * Validate job template attributes; for now just document-format, + * copies, job-sheets, number-up, page-ranges, mandatory attributes, and + * media... + */ + + for (i = 0; i < (int)(sizeof(readonly) / sizeof(readonly[0])); i ++) + { + if ((attr = ippFindAttribute(con->request, readonly[i], IPP_TAG_ZERO)) != NULL) + { + ippDeleteAttribute(con->request, attr); + + if (StrictConformance) + { + send_ipp_status(con, IPP_BAD_REQUEST, _(""The '%s' Job Status attribute cannot be supplied in a job creation request.""), readonly[i]); + return (NULL); + } + + cupsdLogMessage(CUPSD_LOG_INFO, ""Unexpected '%s' Job Status attribute in a job creation request."", readonly[i]); + } + } + + if (printer->pc) + { + for (mandatory = (char *)cupsArrayFirst(printer->pc->mandatory); + mandatory; + mandatory = (char *)cupsArrayNext(printer->pc->mandatory)) + { + if (!ippFindAttribute(con->request, mandatory, IPP_TAG_ZERO)) + { + /* + * Missing a required attribute... + */ + + send_ipp_status(con, IPP_CONFLICT, + _(""The \""%s\"" attribute is required for print jobs.""), + mandatory); + return (NULL); + } + } + } + + if (filetype && printer->filetypes && + !cupsArrayFind(printer->filetypes, filetype)) + { + char mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2]; + /* MIME media type string */ + + + snprintf(mimetype, sizeof(mimetype), ""%s/%s"", filetype->super, + filetype->type); + + send_ipp_status(con, IPP_DOCUMENT_FORMAT, + _(""Unsupported format \""%s\"".""), mimetype); + + ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE, + ""document-format"", NULL, mimetype); + + return (NULL); + } + + if ((attr = ippFindAttribute(con->request, ""copies"", + IPP_TAG_INTEGER)) != NULL) + { + if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad copies value %d.""), + attr->values[0].integer); + ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER, + ""copies"", attr->values[0].integer); + return (NULL); + } + } + + if ((attr = ippFindAttribute(con->request, ""job-sheets"", + IPP_TAG_ZERO)) != NULL) + { + if (attr->value_tag != IPP_TAG_KEYWORD && + attr->value_tag != IPP_TAG_NAME) + { + send_ipp_status(con, IPP_BAD_REQUEST, _(""Bad job-sheets value type."")); + return (NULL); + } + + if (attr->num_values > 2) + { + send_ipp_status(con, IPP_BAD_REQUEST, + _(""Too many job-sheets values (%d > 2).""), + attr->num_values); + return (NULL); + } + + for (i = 0; i < attr->num_values; i ++) + if (strcmp(attr->values[i].string.text, ""none"") && + !cupsdFindBanner(attr->values[i].string.text)) + { + send_ipp_status(con, IPP_BAD_REQUEST, _(""Bad job-sheets value \""%s\"".""), + attr->values[i].string.text); + return (NULL); + } + } + + if ((attr = ippFindAttribute(con->request, ""number-up"", + IPP_TAG_INTEGER)) != NULL) + { + if (attr->values[0].integer != 1 && + attr->values[0].integer != 2 && + attr->values[0].integer != 4 && + attr->values[0].integer != 6 && + attr->values[0].integer != 9 && + attr->values[0].integer != 16) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad number-up value %d.""), + attr->values[0].integer); + ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER, + ""number-up"", attr->values[0].integer); + return (NULL); + } + } + + if ((attr = ippFindAttribute(con->request, ""page-ranges"", + IPP_TAG_RANGE)) != NULL) + { + for (i = 0, lowerpagerange = 1; i < attr->num_values; i ++) + { + if (attr->values[i].range.lower < lowerpagerange || + attr->values[i].range.lower > attr->values[i].range.upper) + { + send_ipp_status(con, IPP_BAD_REQUEST, + _(""Bad page-ranges values %d-%d.""), + attr->values[i].range.lower, + attr->values[i].range.upper); + return (NULL); + } + + lowerpagerange = attr->values[i].range.upper + 1; + } + } + + /* + * Do media selection as needed... + */ + + if (!ippFindAttribute(con->request, ""PageRegion"", IPP_TAG_ZERO) && + !ippFindAttribute(con->request, ""PageSize"", IPP_TAG_ZERO) && + _ppdCacheGetPageSize(printer->pc, con->request, NULL, &exact)) + { + if (!exact && + (media_col = ippFindAttribute(con->request, ""media-col"", + IPP_TAG_BEGIN_COLLECTION)) != NULL) + { + send_ipp_status(con, IPP_OK_SUBST, _(""Unsupported margins."")); + + unsup_col = ippNew(); + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-bottom-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-bottom-margin"", media_margin->values[0].integer); + + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-left-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-left-margin"", media_margin->values[0].integer); + + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-right-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-right-margin"", media_margin->values[0].integer); + + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-top-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-top-margin"", media_margin->values[0].integer); + + ippAddCollection(con->response, IPP_TAG_UNSUPPORTED_GROUP, ""media-col"", + unsup_col); + ippDelete(unsup_col); + } + } + + /* + * Make sure we aren't over our limit... + */ + + if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs) + cupsdCleanJobs(); + + if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs) + { + send_ipp_status(con, IPP_NOT_POSSIBLE, _(""Too many active jobs."")); + return (NULL); + } + + if ((i = check_quotas(con, printer)) < 0) + { + send_ipp_status(con, IPP_NOT_POSSIBLE, _(""Quota limit reached."")); + return (NULL); + } + else if (i == 0) + { + send_ipp_status(con, IPP_NOT_AUTHORIZED, _(""Not allowed to print."")); + return (NULL); + } + + /* + * Create the job and set things up... + */ + + if ((attr = ippFindAttribute(con->request, ""job-priority"", + IPP_TAG_INTEGER)) != NULL) + priority = attr->values[0].integer; + else + { + if ((val = cupsGetOption(""job-priority"", printer->num_options, + printer->options)) != NULL) + priority = atoi(val); + else + priority = 50; + + ippAddInteger(con->request, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-priority"", + priority); + } + + if ((attr = ippFindAttribute(con->request, ""job-name"", IPP_TAG_ZERO)) == NULL) + ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, ""job-name"", NULL, ""Untitled""); + else if ((attr->value_tag != IPP_TAG_NAME && + attr->value_tag != IPP_TAG_NAMELANG) || + attr->num_values != 1) + { + send_ipp_status(con, IPP_ATTRIBUTES, + _(""Bad job-name value: Wrong type or count."")); + if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL) + attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP; + return (NULL); + } + else if (!ippValidateAttribute(attr)) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad job-name value: %s""), + cupsLastErrorString()); + if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL) + attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP; + return (NULL); + } + + if ((job = cupsdAddJob(priority, printer->name)) == NULL) + { + send_ipp_status(con, IPP_INTERNAL_ERROR, + _(""Unable to add job for destination \""%s\"".""), + printer->name); + return (NULL); + } + + job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE); + job->attrs = con->request; + job->dirty = 1; + con->request = ippNewRequest(job->attrs->request.op.operation_id); + + cupsdMarkDirty(CUPSD_DIRTY_JOBS); + + add_job_uuid(job); + apply_printer_defaults(printer, job); + + attr = ippFindAttribute(job->attrs, ""requesting-user-name"", IPP_TAG_NAME); + if (con->username[0]) + { + cupsdSetString(&job->username, con->username); + + if (attr) + ippSetString(job->attrs, &attr, 0, con->username); + } + else if (attr) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + ""add_job: requesting-user-name=\""%s\"""", + attr->values[0].string.text); + + cupsdSetString(&job->username, attr->values[0].string.text); + } + else + cupsdSetString(&job->username, ""anonymous""); + + if (!attr) + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, + ""job-originating-user-name"", NULL, job->username); + else + { + ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); + ippSetName(job->attrs, &attr, ""job-originating-user-name""); + } + + if (con->username[0] || auth_info) + { + save_auth_info(con, job, auth_info); + + /* + * Remove the auth-info attribute from the attribute data... + */ + + if (auth_info) + ippDeleteAttribute(job->attrs, auth_info); + } + + if ((attr = ippFindAttribute(con->request, ""job-name"", IPP_TAG_NAME)) != NULL) + cupsdSetString(&(job->name), attr->values[0].string.text); + + if ((attr = ippFindAttribute(job->attrs, ""job-originating-host-name"", + IPP_TAG_ZERO)) != NULL) + { + /* + * Request contains a job-originating-host-name attribute; validate it... + */ + + if (attr->value_tag != IPP_TAG_NAME || + attr->num_values != 1 || + strcmp(con->http->hostname, ""localhost"")) + { + /* + * Can't override the value if we aren't connected via localhost. + * Also, we can only have 1 value and it must be a name value. + */ + + ippDeleteAttribute(job->attrs, attr); + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, ""job-originating-host-name"", NULL, con->http->hostname); + } + else + ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); + } + else + { + /* + * No job-originating-host-name attribute, so use the hostname from + * the connection... + */ + + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, + ""job-originating-host-name"", NULL, con->http->hostname); + } + + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""date-time-at-completed""); + ippAddDate(job->attrs, IPP_TAG_JOB, ""date-time-at-creation"", ippTimeToDate(time(NULL))); + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""date-time-at-processing""); + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""time-at-completed""); + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""time-at-creation"", time(NULL)); + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""time-at-processing""); + + /* + * Add remaining job attributes... + */ + + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-id"", job->id); + job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM, + ""job-state"", IPP_JOB_STOPPED); + job->state_value = (ipp_jstate_t)job->state->values[0].integer; + job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, + ""job-state-reasons"", NULL, ""job-incoming""); + job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-impressions-completed"", 0); + job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, + ""job-media-sheets-completed"", 0); + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, ""job-printer-uri"", NULL, + printer->uri); + + if ((attr = ippFindAttribute(job->attrs, ""job-k-octets"", IPP_TAG_INTEGER)) != NULL) + attr->values[0].integer = 0; + else + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-k-octets"", 0); + + if ((attr = ippFindAttribute(job->attrs, ""job-hold-until"", + IPP_TAG_KEYWORD)) == NULL) + attr = ippFindAttribute(job->attrs, ""job-hold-until"", IPP_TAG_NAME); + if (!attr) + { + if ((val = cupsGetOption(""job-hold-until"", printer->num_options, + printer->options)) == NULL) + val = ""no-hold""; + + attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, + ""job-hold-until"", NULL, val); + } + + if (printer->holding_new_jobs) + { + /* + * Hold all new jobs on this printer... + */ + + if (attr && strcmp(attr->values[0].string.text, ""no-hold"")) + cupsdSetJobHoldUntil(job, ippGetString(attr, 0, NULL), 0); + else + cupsdSetJobHoldUntil(job, ""indefinite"", 0); + + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + + ippSetString(job->attrs, &job->reasons, 0, ""job-held-on-create""); + } + else if (attr && strcmp(attr->values[0].string.text, ""no-hold"")) + { + /* + * Hold job until specified time... + */ + + cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0); + + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + + ippSetString(job->attrs, &job->reasons, 0, ""job-hold-until-specified""); + } + else if (job->attrs->request.op.operation_id == IPP_CREATE_JOB) + { + job->hold_until = time(NULL) + MultipleOperationTimeout; + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + } + else + { + job->state->values[0].integer = IPP_JOB_PENDING; + job->state_value = IPP_JOB_PENDING; + + ippSetString(job->attrs, &job->reasons, 0, ""none""); + } + + if (!(printer->type & CUPS_PRINTER_REMOTE) || Classification) + { + /* + * Add job sheets options... + */ + + if ((attr = ippFindAttribute(job->attrs, ""job-sheets"", + IPP_TAG_ZERO)) == NULL) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + ""Adding default job-sheets values \""%s,%s\""..."", + printer->job_sheets[0], printer->job_sheets[1]); + + attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, ""job-sheets"", + 2, NULL, NULL); + ippSetString(job->attrs, &attr, 0, printer->job_sheets[0]); + ippSetString(job->attrs, &attr, 1, printer->job_sheets[1]); + } + + job->job_sheets = attr; + + /* + * Enforce classification level if set... + */ + + if (Classification) + { + cupsdLogMessage(CUPSD_LOG_INFO, + ""Classification=\""%s\"", ClassifyOverride=%d"", + Classification ? Classification : ""(null)"", + ClassifyOverride); + + if (ClassifyOverride) + { + if (!strcmp(attr->values[0].string.text, ""none"") && + (attr->num_values == 1 || + !strcmp(attr->values[1].string.text, ""none""))) + { + /* + * Force the leading banner to have the classification on it... + */ + + ippSetString(job->attrs, &attr, 0, Classification); + + cupsdLogJob(job, CUPSD_LOG_NOTICE, ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s,none\"", "" + ""job-originating-user-name=\""%s\"""", + Classification, job->username); + } + else if (attr->num_values == 2 && + strcmp(attr->values[0].string.text, + attr->values[1].string.text) && + strcmp(attr->values[0].string.text, ""none"") && + strcmp(attr->values[1].string.text, ""none"")) + { + /* + * Can't put two different security markings on the same document! + */ + + ippSetString(job->attrs, &attr, 1, attr->values[0].string.text); + + cupsdLogJob(job, CUPSD_LOG_NOTICE, ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s,%s\"", "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, + attr->values[1].string.text, job->username); + } + else if (strcmp(attr->values[0].string.text, Classification) && + strcmp(attr->values[0].string.text, ""none"") && + (attr->num_values == 1 || + (strcmp(attr->values[1].string.text, Classification) && + strcmp(attr->values[1].string.text, ""none"")))) + { + if (attr->num_values == 1) + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION OVERRIDDEN "" + ""job-sheets=\""%s\"", "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, job->username); + else + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION OVERRIDDEN "" + ""job-sheets=\""%s,%s\"",fffff "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, + attr->values[1].string.text, job->username); + } + } + else if (strcmp(attr->values[0].string.text, Classification) && + (attr->num_values == 1 || + strcmp(attr->values[1].string.text, Classification))) + { + /* + * Force the banner to have the classification on it... + */ + + if (attr->num_values > 1 && + !strcmp(attr->values[0].string.text, attr->values[1].string.text)) + { + ippSetString(job->attrs, &attr, 0, Classification); + ippSetString(job->attrs, &attr, 1, Classification); + } + else + { + if (attr->num_values == 1 || + strcmp(attr->values[0].string.text, ""none"")) + ippSetString(job->attrs, &attr, 0, Classification); + + if (attr->num_values > 1 && + strcmp(attr->values[1].string.text, ""none"")) + ippSetString(job->attrs, &attr, 1, Classification); + } + + if (attr->num_values > 1) + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s,%s\"", "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, + attr->values[1].string.text, job->username); + else + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s\"", "" + ""job-originating-user-name=\""%s\"""", + Classification, job->username); + } + } + + /* + * See if we need to add the starting sheet... + */ + + if (!(printer->type & CUPS_PRINTER_REMOTE)) + { + cupsdLogJob(job, CUPSD_LOG_INFO, ""Adding start banner page \""%s\""."", + attr->values[0].string.text); + + if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0) + { + cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE, + ""Aborting job because the start banner could not be "" + ""copied.""); + return (NULL); + } + + cupsdUpdateQuota(printer, job->username, 0, kbytes); + } + } + else if ((attr = ippFindAttribute(job->attrs, ""job-sheets"", + IPP_TAG_ZERO)) != NULL) + job->job_sheets = attr; + + /* + * Fill in the response info... + */ + + httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), ""ipp"", NULL, + con->clientname, con->clientport, ""/jobs/%d"", job->id); + ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, ""job-uri"", NULL, + job_uri); + + ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-id"", job->id); + + ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, ""job-state"", + job->state_value); + ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_TEXT, ""job-state-message"", NULL, """"); + ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, ""job-state-reasons"", + NULL, job->reasons->values[0].string.text); + + con->response->request.status.status_code = IPP_OK; + + /* + * Add any job subscriptions... + */ + + add_job_subscriptions(con, job); + + /* + * Set all but the first two attributes to the job attributes group... + */ + + for (attr = job->attrs->attrs->next->next; attr; attr = attr->next) + attr->group_tag = IPP_TAG_JOB; + + /* + * Fire the ""job created"" event... + */ + + cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, ""Job created.""); + + /* + * Return the new job... + */ + + return (job); +} +",1,"add_job(cupsd_client_t *con, /* I - Client connection */ + cupsd_printer_t *printer, /* I - Destination printer */ + mime_type_t *filetype) /* I - First print file type, if any */ +{ + http_status_t status; /* Policy status */ + ipp_attribute_t *attr, /* Current attribute */ + *auth_info; /* auth-info attribute */ + const char *mandatory; /* Current mandatory job attribute */ + const char *val; /* Default option value */ + int priority; /* Job priority */ + cupsd_job_t *job; /* Current job */ + char job_uri[HTTP_MAX_URI]; /* Job URI */ + int kbytes; /* Size of print file */ + int i; /* Looping var */ + int lowerpagerange; /* Page range bound */ + int exact; /* Did we have an exact match? */ + ipp_attribute_t *media_col, /* media-col attribute */ + *media_margin; /* media-*-margin attribute */ + ipp_t *unsup_col; /* media-col in unsupported response */ + static const char * const readonly[] =/* List of read-only attributes */ + { + ""date-time-at-completed"", + ""date-time-at-creation"", + ""date-time-at-processing"", + ""job-detailed-status-messages"", + ""job-document-access-errors"", + ""job-id"", + ""job-impressions-completed"", + ""job-k-octets-completed"", + ""job-media-sheets-completed"", + ""job-pages-completed"", + ""job-printer-up-time"", + ""job-printer-uri"", + ""job-state"", + ""job-state-message"", + ""job-state-reasons"", + ""job-uri"", + ""number-of-documents"", + ""number-of-intervening-jobs"", + ""output-device-assigned"", + ""time-at-completed"", + ""time-at-creation"", + ""time-at-processing"" + }; + + + cupsdLogMessage(CUPSD_LOG_DEBUG2, ""add_job(%p[%d], %p(%s), %p(%s/%s))"", + con, con->number, printer, printer->name, + filetype, filetype ? filetype->super : ""none"", + filetype ? filetype->type : ""none""); + + /* + * Check remote printing to non-shared printer... + */ + + if (!printer->shared && + _cups_strcasecmp(con->http->hostname, ""localhost"") && + _cups_strcasecmp(con->http->hostname, ServerName)) + { + send_ipp_status(con, IPP_NOT_AUTHORIZED, + _(""The printer or class is not shared."")); + return (NULL); + } + + /* + * Check policy... + */ + + auth_info = ippFindAttribute(con->request, ""auth-info"", IPP_TAG_TEXT); + + if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK) + { + send_http_error(con, status, printer); + return (NULL); + } + else if (printer->num_auth_info_required == 1 && + !strcmp(printer->auth_info_required[0], ""negotiate"") && + !con->username[0]) + { + send_http_error(con, HTTP_UNAUTHORIZED, printer); + return (NULL); + } +#ifdef HAVE_SSL + else if (auth_info && !con->http->tls && + !httpAddrLocalhost(con->http->hostaddr)) + { + /* + * Require encryption of auth-info over non-local connections... + */ + + send_http_error(con, HTTP_UPGRADE_REQUIRED, printer); + return (NULL); + } +#endif /* HAVE_SSL */ + + /* + * See if the printer is accepting jobs... + */ + + if (!printer->accepting) + { + send_ipp_status(con, IPP_NOT_ACCEPTING, + _(""Destination \""%s\"" is not accepting jobs.""), + printer->name); + return (NULL); + } + + /* + * Validate job template attributes; for now just document-format, + * copies, job-sheets, number-up, page-ranges, mandatory attributes, and + * media... + */ + + for (i = 0; i < (int)(sizeof(readonly) / sizeof(readonly[0])); i ++) + { + if ((attr = ippFindAttribute(con->request, readonly[i], IPP_TAG_ZERO)) != NULL) + { + ippDeleteAttribute(con->request, attr); + + if (StrictConformance) + { + send_ipp_status(con, IPP_BAD_REQUEST, _(""The '%s' Job Status attribute cannot be supplied in a job creation request.""), readonly[i]); + return (NULL); + } + + cupsdLogMessage(CUPSD_LOG_INFO, ""Unexpected '%s' Job Status attribute in a job creation request."", readonly[i]); + } + } + + if (printer->pc) + { + for (mandatory = (char *)cupsArrayFirst(printer->pc->mandatory); + mandatory; + mandatory = (char *)cupsArrayNext(printer->pc->mandatory)) + { + if (!ippFindAttribute(con->request, mandatory, IPP_TAG_ZERO)) + { + /* + * Missing a required attribute... + */ + + send_ipp_status(con, IPP_CONFLICT, + _(""The \""%s\"" attribute is required for print jobs.""), + mandatory); + return (NULL); + } + } + } + + if (filetype && printer->filetypes && + !cupsArrayFind(printer->filetypes, filetype)) + { + char mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2]; + /* MIME media type string */ + + + snprintf(mimetype, sizeof(mimetype), ""%s/%s"", filetype->super, + filetype->type); + + send_ipp_status(con, IPP_DOCUMENT_FORMAT, + _(""Unsupported format \""%s\"".""), mimetype); + + ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE, + ""document-format"", NULL, mimetype); + + return (NULL); + } + + if ((attr = ippFindAttribute(con->request, ""copies"", + IPP_TAG_INTEGER)) != NULL) + { + if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad copies value %d.""), + attr->values[0].integer); + ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER, + ""copies"", attr->values[0].integer); + return (NULL); + } + } + + if ((attr = ippFindAttribute(con->request, ""job-sheets"", + IPP_TAG_ZERO)) != NULL) + { + if (attr->value_tag != IPP_TAG_KEYWORD && + attr->value_tag != IPP_TAG_NAME) + { + send_ipp_status(con, IPP_BAD_REQUEST, _(""Bad job-sheets value type."")); + return (NULL); + } + + if (attr->num_values > 2) + { + send_ipp_status(con, IPP_BAD_REQUEST, + _(""Too many job-sheets values (%d > 2).""), + attr->num_values); + return (NULL); + } + + for (i = 0; i < attr->num_values; i ++) + if (strcmp(attr->values[i].string.text, ""none"") && + !cupsdFindBanner(attr->values[i].string.text)) + { + send_ipp_status(con, IPP_BAD_REQUEST, _(""Bad job-sheets value \""%s\"".""), + attr->values[i].string.text); + return (NULL); + } + } + + if ((attr = ippFindAttribute(con->request, ""number-up"", + IPP_TAG_INTEGER)) != NULL) + { + if (attr->values[0].integer != 1 && + attr->values[0].integer != 2 && + attr->values[0].integer != 4 && + attr->values[0].integer != 6 && + attr->values[0].integer != 9 && + attr->values[0].integer != 16) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad number-up value %d.""), + attr->values[0].integer); + ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER, + ""number-up"", attr->values[0].integer); + return (NULL); + } + } + + if ((attr = ippFindAttribute(con->request, ""page-ranges"", + IPP_TAG_RANGE)) != NULL) + { + for (i = 0, lowerpagerange = 1; i < attr->num_values; i ++) + { + if (attr->values[i].range.lower < lowerpagerange || + attr->values[i].range.lower > attr->values[i].range.upper) + { + send_ipp_status(con, IPP_BAD_REQUEST, + _(""Bad page-ranges values %d-%d.""), + attr->values[i].range.lower, + attr->values[i].range.upper); + return (NULL); + } + + lowerpagerange = attr->values[i].range.upper + 1; + } + } + + /* + * Do media selection as needed... + */ + + if (!ippFindAttribute(con->request, ""PageRegion"", IPP_TAG_ZERO) && + !ippFindAttribute(con->request, ""PageSize"", IPP_TAG_ZERO) && + _ppdCacheGetPageSize(printer->pc, con->request, NULL, &exact)) + { + if (!exact && + (media_col = ippFindAttribute(con->request, ""media-col"", + IPP_TAG_BEGIN_COLLECTION)) != NULL) + { + send_ipp_status(con, IPP_OK_SUBST, _(""Unsupported margins."")); + + unsup_col = ippNew(); + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-bottom-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-bottom-margin"", media_margin->values[0].integer); + + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-left-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-left-margin"", media_margin->values[0].integer); + + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-right-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-right-margin"", media_margin->values[0].integer); + + if ((media_margin = ippFindAttribute(media_col->values[0].collection, + ""media-top-margin"", + IPP_TAG_INTEGER)) != NULL) + ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + ""media-top-margin"", media_margin->values[0].integer); + + ippAddCollection(con->response, IPP_TAG_UNSUPPORTED_GROUP, ""media-col"", + unsup_col); + ippDelete(unsup_col); + } + } + + /* + * Make sure we aren't over our limit... + */ + + if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs) + cupsdCleanJobs(); + + if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs) + { + send_ipp_status(con, IPP_NOT_POSSIBLE, _(""Too many active jobs."")); + return (NULL); + } + + if ((i = check_quotas(con, printer)) < 0) + { + send_ipp_status(con, IPP_NOT_POSSIBLE, _(""Quota limit reached."")); + return (NULL); + } + else if (i == 0) + { + send_ipp_status(con, IPP_NOT_AUTHORIZED, _(""Not allowed to print."")); + return (NULL); + } + + /* + * Create the job and set things up... + */ + + if ((attr = ippFindAttribute(con->request, ""job-priority"", + IPP_TAG_INTEGER)) != NULL) + priority = attr->values[0].integer; + else + { + if ((val = cupsGetOption(""job-priority"", printer->num_options, + printer->options)) != NULL) + priority = atoi(val); + else + priority = 50; + + ippAddInteger(con->request, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-priority"", + priority); + } + + if ((attr = ippFindAttribute(con->request, ""job-name"", IPP_TAG_ZERO)) == NULL) + ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, ""job-name"", NULL, ""Untitled""); + else if ((attr->value_tag != IPP_TAG_NAME && + attr->value_tag != IPP_TAG_NAMELANG) || + attr->num_values != 1) + { + send_ipp_status(con, IPP_ATTRIBUTES, + _(""Bad job-name value: Wrong type or count."")); + if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL) + attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP; + return (NULL); + } + else if (!ippValidateAttribute(attr)) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad job-name value: %s""), + cupsLastErrorString()); + if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL) + attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP; + return (NULL); + } + + attr = ippFindAttribute(con->request, ""requesting-user-name"", IPP_TAG_NAME); + + if (attr && !ippValidateAttribute(attr)) + { + send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad requesting-user-name value: %s""), cupsLastErrorString()); + if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL) + attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP; + return (NULL); + } + + if ((job = cupsdAddJob(priority, printer->name)) == NULL) + { + send_ipp_status(con, IPP_INTERNAL_ERROR, + _(""Unable to add job for destination \""%s\"".""), + printer->name); + return (NULL); + } + + job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE); + job->attrs = con->request; + job->dirty = 1; + con->request = ippNewRequest(job->attrs->request.op.operation_id); + + cupsdMarkDirty(CUPSD_DIRTY_JOBS); + + add_job_uuid(job); + apply_printer_defaults(printer, job); + + if (con->username[0]) + { + cupsdSetString(&job->username, con->username); + + if (attr) + ippSetString(job->attrs, &attr, 0, con->username); + } + else if (attr) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + ""add_job: requesting-user-name=\""%s\"""", + attr->values[0].string.text); + + cupsdSetString(&job->username, attr->values[0].string.text); + } + else + cupsdSetString(&job->username, ""anonymous""); + + if (!attr) + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, + ""job-originating-user-name"", NULL, job->username); + else + { + ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); + ippSetName(job->attrs, &attr, ""job-originating-user-name""); + } + + if (con->username[0] || auth_info) + { + save_auth_info(con, job, auth_info); + + /* + * Remove the auth-info attribute from the attribute data... + */ + + if (auth_info) + ippDeleteAttribute(job->attrs, auth_info); + } + + if ((attr = ippFindAttribute(con->request, ""job-name"", IPP_TAG_NAME)) != NULL) + cupsdSetString(&(job->name), attr->values[0].string.text); + + if ((attr = ippFindAttribute(job->attrs, ""job-originating-host-name"", + IPP_TAG_ZERO)) != NULL) + { + /* + * Request contains a job-originating-host-name attribute; validate it... + */ + + if (attr->value_tag != IPP_TAG_NAME || + attr->num_values != 1 || + strcmp(con->http->hostname, ""localhost"")) + { + /* + * Can't override the value if we aren't connected via localhost. + * Also, we can only have 1 value and it must be a name value. + */ + + ippDeleteAttribute(job->attrs, attr); + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, ""job-originating-host-name"", NULL, con->http->hostname); + } + else + ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); + } + else + { + /* + * No job-originating-host-name attribute, so use the hostname from + * the connection... + */ + + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, + ""job-originating-host-name"", NULL, con->http->hostname); + } + + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""date-time-at-completed""); + ippAddDate(job->attrs, IPP_TAG_JOB, ""date-time-at-creation"", ippTimeToDate(time(NULL))); + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""date-time-at-processing""); + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""time-at-completed""); + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""time-at-creation"", time(NULL)); + ippAddOutOfBand(job->attrs, IPP_TAG_JOB, IPP_TAG_NOVALUE, ""time-at-processing""); + + /* + * Add remaining job attributes... + */ + + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-id"", job->id); + job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM, + ""job-state"", IPP_JOB_STOPPED); + job->state_value = (ipp_jstate_t)job->state->values[0].integer; + job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, + ""job-state-reasons"", NULL, ""job-incoming""); + job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-impressions-completed"", 0); + job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, + ""job-media-sheets-completed"", 0); + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, ""job-printer-uri"", NULL, + printer->uri); + + if ((attr = ippFindAttribute(job->attrs, ""job-k-octets"", IPP_TAG_INTEGER)) != NULL) + attr->values[0].integer = 0; + else + ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-k-octets"", 0); + + if ((attr = ippFindAttribute(job->attrs, ""job-hold-until"", + IPP_TAG_KEYWORD)) == NULL) + attr = ippFindAttribute(job->attrs, ""job-hold-until"", IPP_TAG_NAME); + if (!attr) + { + if ((val = cupsGetOption(""job-hold-until"", printer->num_options, + printer->options)) == NULL) + val = ""no-hold""; + + attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, + ""job-hold-until"", NULL, val); + } + + if (printer->holding_new_jobs) + { + /* + * Hold all new jobs on this printer... + */ + + if (attr && strcmp(attr->values[0].string.text, ""no-hold"")) + cupsdSetJobHoldUntil(job, ippGetString(attr, 0, NULL), 0); + else + cupsdSetJobHoldUntil(job, ""indefinite"", 0); + + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + + ippSetString(job->attrs, &job->reasons, 0, ""job-held-on-create""); + } + else if (attr && strcmp(attr->values[0].string.text, ""no-hold"")) + { + /* + * Hold job until specified time... + */ + + cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0); + + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + + ippSetString(job->attrs, &job->reasons, 0, ""job-hold-until-specified""); + } + else if (job->attrs->request.op.operation_id == IPP_CREATE_JOB) + { + job->hold_until = time(NULL) + MultipleOperationTimeout; + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + } + else + { + job->state->values[0].integer = IPP_JOB_PENDING; + job->state_value = IPP_JOB_PENDING; + + ippSetString(job->attrs, &job->reasons, 0, ""none""); + } + + if (!(printer->type & CUPS_PRINTER_REMOTE) || Classification) + { + /* + * Add job sheets options... + */ + + if ((attr = ippFindAttribute(job->attrs, ""job-sheets"", + IPP_TAG_ZERO)) == NULL) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + ""Adding default job-sheets values \""%s,%s\""..."", + printer->job_sheets[0], printer->job_sheets[1]); + + attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, ""job-sheets"", + 2, NULL, NULL); + ippSetString(job->attrs, &attr, 0, printer->job_sheets[0]); + ippSetString(job->attrs, &attr, 1, printer->job_sheets[1]); + } + + job->job_sheets = attr; + + /* + * Enforce classification level if set... + */ + + if (Classification) + { + cupsdLogMessage(CUPSD_LOG_INFO, + ""Classification=\""%s\"", ClassifyOverride=%d"", + Classification ? Classification : ""(null)"", + ClassifyOverride); + + if (ClassifyOverride) + { + if (!strcmp(attr->values[0].string.text, ""none"") && + (attr->num_values == 1 || + !strcmp(attr->values[1].string.text, ""none""))) + { + /* + * Force the leading banner to have the classification on it... + */ + + ippSetString(job->attrs, &attr, 0, Classification); + + cupsdLogJob(job, CUPSD_LOG_NOTICE, ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s,none\"", "" + ""job-originating-user-name=\""%s\"""", + Classification, job->username); + } + else if (attr->num_values == 2 && + strcmp(attr->values[0].string.text, + attr->values[1].string.text) && + strcmp(attr->values[0].string.text, ""none"") && + strcmp(attr->values[1].string.text, ""none"")) + { + /* + * Can't put two different security markings on the same document! + */ + + ippSetString(job->attrs, &attr, 1, attr->values[0].string.text); + + cupsdLogJob(job, CUPSD_LOG_NOTICE, ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s,%s\"", "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, + attr->values[1].string.text, job->username); + } + else if (strcmp(attr->values[0].string.text, Classification) && + strcmp(attr->values[0].string.text, ""none"") && + (attr->num_values == 1 || + (strcmp(attr->values[1].string.text, Classification) && + strcmp(attr->values[1].string.text, ""none"")))) + { + if (attr->num_values == 1) + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION OVERRIDDEN "" + ""job-sheets=\""%s\"", "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, job->username); + else + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION OVERRIDDEN "" + ""job-sheets=\""%s,%s\"",fffff "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, + attr->values[1].string.text, job->username); + } + } + else if (strcmp(attr->values[0].string.text, Classification) && + (attr->num_values == 1 || + strcmp(attr->values[1].string.text, Classification))) + { + /* + * Force the banner to have the classification on it... + */ + + if (attr->num_values > 1 && + !strcmp(attr->values[0].string.text, attr->values[1].string.text)) + { + ippSetString(job->attrs, &attr, 0, Classification); + ippSetString(job->attrs, &attr, 1, Classification); + } + else + { + if (attr->num_values == 1 || + strcmp(attr->values[0].string.text, ""none"")) + ippSetString(job->attrs, &attr, 0, Classification); + + if (attr->num_values > 1 && + strcmp(attr->values[1].string.text, ""none"")) + ippSetString(job->attrs, &attr, 1, Classification); + } + + if (attr->num_values > 1) + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s,%s\"", "" + ""job-originating-user-name=\""%s\"""", + attr->values[0].string.text, + attr->values[1].string.text, job->username); + else + cupsdLogJob(job, CUPSD_LOG_NOTICE, + ""CLASSIFICATION FORCED "" + ""job-sheets=\""%s\"", "" + ""job-originating-user-name=\""%s\"""", + Classification, job->username); + } + } + + /* + * See if we need to add the starting sheet... + */ + + if (!(printer->type & CUPS_PRINTER_REMOTE)) + { + cupsdLogJob(job, CUPSD_LOG_INFO, ""Adding start banner page \""%s\""."", + attr->values[0].string.text); + + if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0) + { + cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE, + ""Aborting job because the start banner could not be "" + ""copied.""); + return (NULL); + } + + cupsdUpdateQuota(printer, job->username, 0, kbytes); + } + } + else if ((attr = ippFindAttribute(job->attrs, ""job-sheets"", + IPP_TAG_ZERO)) != NULL) + job->job_sheets = attr; + + /* + * Fill in the response info... + */ + + httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), ""ipp"", NULL, + con->clientname, con->clientport, ""/jobs/%d"", job->id); + ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, ""job-uri"", NULL, + job_uri); + + ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, ""job-id"", job->id); + + ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, ""job-state"", + job->state_value); + ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_TEXT, ""job-state-message"", NULL, """"); + ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, ""job-state-reasons"", + NULL, job->reasons->values[0].string.text); + + con->response->request.status.status_code = IPP_OK; + + /* + * Add any job subscriptions... + */ + + add_job_subscriptions(con, job); + + /* + * Set all but the first two attributes to the job attributes group... + */ + + for (attr = job->attrs->attrs->next->next; attr; attr = attr->next) + attr->group_tag = IPP_TAG_JOB; + + /* + * Fire the ""job created"" event... + */ + + cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, ""Job created.""); + + /* + * Return the new job... + */ + + return (job); +} +","@@ -1597,6 +1597,16 @@ add_job(cupsd_client_t *con, /* I - Client connection */ + return (NULL); + } + ++ attr = ippFindAttribute(con->request, ""requesting-user-name"", IPP_TAG_NAME); ++ ++ if (attr && !ippValidateAttribute(attr)) ++ { ++ send_ipp_status(con, IPP_ATTRIBUTES, _(""Bad requesting-user-name value: %s""), cupsLastErrorString()); ++ if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL) ++ attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP; ++ return (NULL); ++ } ++ + if ((job = cupsdAddJob(priority, printer->name)) == NULL) + { + send_ipp_status(con, IPP_INTERNAL_ERROR, +@@ -1615,8 +1625,6 @@ add_job(cupsd_client_t *con, /* I - Client connection */ + add_job_uuid(job); + apply_printer_defaults(printer, job); + +- attr = ippFindAttribute(job->attrs, ""requesting-user-name"", IPP_TAG_NAME); +- + if (con->username[0]) + { + cupsdSetString(&job->username, con->username);",6204,6440,8192 +7012,"TIFFReadDirectory(TIFF* tif) +{ + static const char module[] = ""TIFFReadDirectory""; + TIFFDirEntry* dir; + uint16 dircount; + TIFFDirEntry* dp; + uint16 di; + const TIFFField* fip; + uint32 fii=FAILED_FII; + toff_t nextdiroff; + int bitspersample_read = FALSE; + + tif->tif_diroff=tif->tif_nextdiroff; + if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff)) + return 0; /* last offset or bad offset (IFD looping) */ + (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ + tif->tif_curdir++; + nextdiroff = tif->tif_nextdiroff; + dircount=TIFFFetchDirectory(tif,nextdiroff,&dir,&tif->tif_nextdiroff); + if (!dircount) + { + TIFFErrorExt(tif->tif_clientdata,module, + ""Failed to read directory at offset "" TIFF_UINT64_FORMAT,nextdiroff); + return 0; + } + TIFFReadDirectoryCheckOrder(tif,dir,dircount); + + /* + * Mark duplicates of any tag to be ignored (bugzilla 1994) + * to avoid certain pathological problems. + */ + { + TIFFDirEntry* ma; + uint16 mb; + for (ma=dir, mb=0; mbtdir_tag==na->tdir_tag) + na->tdir_tag=IGNORE; + } + } + } + + tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ + tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */ + /* free any old stuff and reinit */ + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + /* + * Electronic Arts writes gray-scale TIFF files + * without a PlanarConfiguration directory entry. + * Thus we setup a default value here, even though + * the TIFF spec says there is no default value. + */ + TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); + /* + * Setup default value and then make a pass over + * the fields to check type and tag information, + * and to extract info required to size data + * structures. A second pass is made afterwards + * to read in everything not taken in the first pass. + * But we must process the Compression tag first + * in order to merge in codec-private tag definitions (otherwise + * we may get complaints about unknown tags). However, the + * Compression tag may be dependent on the SamplesPerPixel + * tag value because older TIFF specs permitted Compression + * to be written as a SamplesPerPixel-count tag entry. + * Thus if we don't first figure out the correct SamplesPerPixel + * tag value then we may end up ignoring the Compression tag + * value because it has an incorrect count value (if the + * true value of SamplesPerPixel is not 1). + */ + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_SAMPLESPERPIXEL); + if (dp) + { + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_tag=IGNORE; + } + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_COMPRESSION); + if (dp) + { + /* + * The 5.0 spec says the Compression tag has one value, while + * earlier specs say it has one value per sample. Because of + * this, we accept the tag if one value is supplied with either + * count. + */ + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + TIFFReadDirEntryOutputErr(tif,err,module,""Compression"",0); + goto bad; + } + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,value)) + goto bad; + dp->tdir_tag=IGNORE; + } + else + { + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE)) + goto bad; + } + /* + * First real pass over the directory. + */ + for (di=0, dp=dir; ditdir_tag!=IGNORE) + { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + if (fii == FAILED_FII) + { + TIFFWarningExt(tif->tif_clientdata, module, + ""Unknown field with tag %d (0x%x) encountered"", + dp->tdir_tag,dp->tdir_tag); + /* the following knowingly leaks the + anonymous field structure */ + if (!_TIFFMergeFields(tif, + _TIFFCreateAnonField(tif, + dp->tdir_tag, + (TIFFDataType) dp->tdir_type), + 1)) { + TIFFWarningExt(tif->tif_clientdata, + module, + ""Registering anonymous field with tag %d (0x%x) failed"", + dp->tdir_tag, + dp->tdir_tag); + dp->tdir_tag=IGNORE; + } else { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + assert(fii != FAILED_FII); + } + } + } + if (dp->tdir_tag!=IGNORE) + { + fip=tif->tif_fields[fii]; + if (fip->field_bit==FIELD_IGNORE) + dp->tdir_tag=IGNORE; + else + { + switch (dp->tdir_tag) + { + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEOFFSETS: + case TIFFTAG_TILEBYTECOUNTS: + TIFFSetFieldBit(tif,fip->field_bit); + break; + case TIFFTAG_IMAGEWIDTH: + case TIFFTAG_IMAGELENGTH: + case TIFFTAG_IMAGEDEPTH: + case TIFFTAG_TILELENGTH: + case TIFFTAG_TILEWIDTH: + case TIFFTAG_TILEDEPTH: + case TIFFTAG_PLANARCONFIG: + case TIFFTAG_ROWSPERSTRIP: + case TIFFTAG_EXTRASAMPLES: + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_tag=IGNORE; + break; + } + } + } + } + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) planarconfig tag says it's separate, + * c) strip offsets/bytecounts tag are both present and + * d) both contain exactly one value, then we consistently find + * that the buggy implementation of the buggy compression scheme + * matches contig planarconfig best. So we 'fix-up' the tag here + */ + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG)&& + (tif->tif_dir.td_planarconfig==PLANARCONFIG_SEPARATE)) + { + if (!_TIFFFillStriles(tif)) + goto bad; + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_STRIPOFFSETS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount, + TIFFTAG_STRIPBYTECOUNTS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + tif->tif_dir.td_planarconfig=PLANARCONFIG_CONTIG; + TIFFWarningExt(tif->tif_clientdata,module, + ""Planarconfig tag value assumed incorrect, "" + ""assuming data is contig instead of chunky""); + } + } + } + /* + * Allocate directory structure and setup defaults. + */ + if (!TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) + { + MissingRequired(tif,""ImageLength""); + goto bad; + } + /* + * Setup appropriate structures (by strip or by tile) + */ + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); + tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth; + tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip; + tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth; + tif->tif_flags &= ~TIFF_ISTILED; + } else { + tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); + tif->tif_flags |= TIFF_ISTILED; + } + if (!tif->tif_dir.td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero number of %s"", + isTiled(tif) ? ""tiles"" : ""strips""); + goto bad; + } + tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips; + if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE) + tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel; + if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { +#ifdef OJPEG_SUPPORT + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG) && + (isTiled(tif)==0) && + (tif->tif_dir.td_nstrips==1)) { + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) it's not a tiled TIFF, + * and c) the number of strips is 1, + * then we tolerate the absence of stripoffsets tag, + * because, presumably, all required data is in the + * JpegInterchangeFormat stream. + */ + TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); + } else +#endif + { + MissingRequired(tif, + isTiled(tif) ? ""TileOffsets"" : ""StripOffsets""); + goto bad; + } + } + /* + * Second pass: extract other information. + */ + for (di=0, dp=dir; ditdir_tag) + { + case IGNORE: + break; + case TIFFTAG_MINSAMPLEVALUE: + case TIFFTAG_MAXSAMPLEVALUE: + case TIFFTAG_BITSPERSAMPLE: + case TIFFTAG_DATATYPE: + case TIFFTAG_SAMPLEFORMAT: + /* + * The MinSampleValue, MaxSampleValue, BitsPerSample + * DataType and SampleFormat tags are supposed to be + * written as one value/sample, but some vendors + * incorrectly write one value only -- so we accept + * that as well (yuck). Other vendors write correct + * value for NumberOfSamples, but incorrect one for + * BitsPerSample and friends, and we will read this + * too. + */ + { + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : ""unknown tagname"",0); + goto bad; + } + if (!TIFFSetField(tif,dp->tdir_tag,value)) + goto bad; + if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE ) + bitspersample_read = TRUE; + } + break; + case TIFFTAG_SMINSAMPLEVALUE: + case TIFFTAG_SMAXSAMPLEVALUE: + { + + double *data = NULL; + enum TIFFReadDirEntryErr err; + uint32 saved_flags; + int m; + if (dp->tdir_count != (uint64)tif->tif_dir.td_samplesperpixel) + err = TIFFReadDirEntryErrCount; + else + err = TIFFReadDirEntryDoubleArray(tif, dp, &data); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : ""unknown tagname"",0); + goto bad; + } + saved_flags = tif->tif_flags; + tif->tif_flags |= TIFF_PERSAMPLE; + m = TIFFSetField(tif,dp->tdir_tag,data); + tif->tif_flags = saved_flags; + _TIFFfree(data); + if (!m) + goto bad; + } + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: +#if defined(DEFER_STRILE_LOAD) + _TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry), + dp, sizeof(TIFFDirEntry) ); +#else + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset)) + goto bad; +#endif + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: +#if defined(DEFER_STRILE_LOAD) + _TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry), + dp, sizeof(TIFFDirEntry) ); +#else + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount)) + goto bad; +#endif + break; + case TIFFTAG_COLORMAP: + case TIFFTAG_TRANSFERFUNCTION: + { + enum TIFFReadDirEntryErr err; + uint32 countpersample; + uint32 countrequired; + uint32 incrementpersample; + uint16* value=NULL; + /* It would be dangerous to instantiate those tag values */ + /* since if td_bitspersample has not yet been read (due to */ + /* unordered tags), it could be read afterwards with a */ + /* values greater than the default one (1), which may cause */ + /* crashes in user code */ + if( !bitspersample_read ) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + ""Ignoring %s since BitsPerSample tag not found"", + fip ? fip->field_name : ""unknown tagname""); + continue; + } + /* ColorMap or TransferFunction for high bit */ + /* depths do not make much sense and could be */ + /* used as a denial of service vector */ + if (tif->tif_dir.td_bitspersample > 24) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + ""Ignoring %s because BitsPerSample=%d>24"", + fip ? fip->field_name : ""unknown tagname"", + tif->tif_dir.td_bitspersample); + continue; + } + countpersample=(1U<tif_dir.td_bitspersample); + if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample)) + { + countrequired=countpersample; + incrementpersample=0; + } + else + { + countrequired=3*countpersample; + incrementpersample=countpersample; + } + if (dp->tdir_count!=(uint64)countrequired) + err=TIFFReadDirEntryErrCount; + else + err=TIFFReadDirEntryShortArray(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : ""unknown tagname"",1); + } + else + { + TIFFSetField(tif,dp->tdir_tag,value,value+incrementpersample,value+2*incrementpersample); + _TIFFfree(value); + } + } + break; +/* BEGIN REV 4.0 COMPATIBILITY */ + case TIFFTAG_OSUBFILETYPE: + { + uint16 valueo; + uint32 value; + if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk) + { + switch (valueo) + { + case OFILETYPE_REDUCEDIMAGE: value=FILETYPE_REDUCEDIMAGE; break; + case OFILETYPE_PAGE: value=FILETYPE_PAGE; break; + default: value=0; break; + } + if (value!=0) + TIFFSetField(tif,TIFFTAG_SUBFILETYPE,value); + } + } + break; +/* END REV 4.0 COMPATIBILITY */ + default: + (void) TIFFFetchNormalTag(tif, dp, TRUE); + break; + } + } + /* + * OJPEG hack: + * - If a) compression is OJPEG, and b) photometric tag is missing, + * then we consistently find that photometric should be YCbCr + * - If a) compression is OJPEG, and b) photometric tag says it's RGB, + * then we consistently find that the buggy implementation of the + * buggy compression scheme matches photometric YCbCr instead. + * - If a) compression is OJPEG, and b) bitspersample tag is missing, + * then we consistently find bitspersample should be 8. + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is RGB or YCbCr, then we consistently find + * samplesperpixel should be 3 + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is MINISWHITE or MINISBLACK, then we consistently + * find samplesperpixel should be 3 + */ + if (tif->tif_dir.td_compression==COMPRESSION_OJPEG) + { + if (!TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) + { + TIFFWarningExt(tif->tif_clientdata, module, + ""Photometric tag is missing, assuming data is YCbCr""); + if (!TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_YCBCR)) + goto bad; + } + else if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + tif->tif_dir.td_photometric=PHOTOMETRIC_YCBCR; + TIFFWarningExt(tif->tif_clientdata, module, + ""Photometric tag value assumed incorrect, "" + ""assuming data is YCbCr instead of RGB""); + } + if (!TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) + { + TIFFWarningExt(tif->tif_clientdata,module, + ""BitsPerSample tag is missing, assuming 8 bits per sample""); + if (!TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8)) + goto bad; + } + if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + { + if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + TIFFWarningExt(tif->tif_clientdata,module, + ""SamplesPerPixel tag is missing, "" + ""assuming correct SamplesPerPixel value is 3""); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + if (tif->tif_dir.td_photometric==PHOTOMETRIC_YCBCR) + { + TIFFWarningExt(tif->tif_clientdata,module, + ""SamplesPerPixel tag is missing, "" + ""applying correct SamplesPerPixel value of 3""); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + else if ((tif->tif_dir.td_photometric==PHOTOMETRIC_MINISWHITE) + || (tif->tif_dir.td_photometric==PHOTOMETRIC_MINISBLACK)) + { + /* + * SamplesPerPixel tag is missing, but is not required + * by spec. Assume correct SamplesPerPixel value of 1. + */ + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1)) + goto bad; + } + } + } + /* + * Verify Palette image has a Colormap. + */ + if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE && + !TIFFFieldSet(tif, FIELD_COLORMAP)) { + if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3) + tif->tif_dir.td_photometric = PHOTOMETRIC_RGB; + else if (tif->tif_dir.td_bitspersample>=8) + tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK; + else { + MissingRequired(tif, ""Colormap""); + goto bad; + } + } + /* + * OJPEG hack: + * We do no further messing with strip/tile offsets/bytecounts in OJPEG + * TIFFs + */ + if (tif->tif_dir.td_compression!=COMPRESSION_OJPEG) + { + /* + * Attempt to deal with a missing StripByteCounts tag. + */ + if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { + /* + * Some manufacturers violate the spec by not giving + * the size of the strips. In this case, assume there + * is one uncompressed strip of data. + */ + if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && + tif->tif_dir.td_nstrips > 1) || + (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE && + tif->tif_dir.td_nstrips != (uint32)tif->tif_dir.td_samplesperpixel)) { + MissingRequired(tif, ""StripByteCounts""); + goto bad; + } + TIFFWarningExt(tif->tif_clientdata, module, + ""TIFF directory is missing required "" + ""\""StripByteCounts\"" field, calculating from imagelength""); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + /* + * Assume we have wrong StripByteCount value (in case + * of single strip) in following cases: + * - it is equal to zero along with StripOffset; + * - it is larger than file itself (in case of uncompressed + * image); + * - it is smaller than the size of the bytes per row + * multiplied on the number of rows. The last case should + * not be checked in the case of writing new image, + * because we may do not know the exact strip size + * until the whole image will be written and directory + * dumped out. + */ + #define BYTECOUNTLOOKSBAD \ + ( (tif->tif_dir.td_stripbytecount[0] == 0 && tif->tif_dir.td_stripoffset[0] != 0) || \ + (tif->tif_dir.td_compression == COMPRESSION_NONE && \ + tif->tif_dir.td_stripbytecount[0] > TIFFGetFileSize(tif) - tif->tif_dir.td_stripoffset[0]) || \ + (tif->tif_mode == O_RDONLY && \ + tif->tif_dir.td_compression == COMPRESSION_NONE && \ + tif->tif_dir.td_stripbytecount[0] < TIFFScanlineSize64(tif) * tif->tif_dir.td_imagelength) ) + + } else if (tif->tif_dir.td_nstrips == 1 + && _TIFFFillStriles(tif) + && tif->tif_dir.td_stripoffset[0] != 0 + && BYTECOUNTLOOKSBAD) { + /* + * XXX: Plexus (and others) sometimes give a value of + * zero for a tag when they don't know what the + * correct value is! Try and handle the simple case + * of estimating the size of a one strip image. + */ + TIFFWarningExt(tif->tif_clientdata, module, + ""Bogus \""StripByteCounts\"" field, ignoring and calculating from imagelength""); + if(EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + +#if !defined(DEFER_STRILE_LOAD) + } else if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG + && tif->tif_dir.td_nstrips > 2 + && tif->tif_dir.td_compression == COMPRESSION_NONE + && tif->tif_dir.td_stripbytecount[0] != tif->tif_dir.td_stripbytecount[1] + && tif->tif_dir.td_stripbytecount[0] != 0 + && tif->tif_dir.td_stripbytecount[1] != 0 ) { + /* + * XXX: Some vendors fill StripByteCount array with + * absolutely wrong values (it can be equal to + * StripOffset array, for example). Catch this case + * here. + * + * We avoid this check if deferring strile loading + * as it would always force us to load the strip/tile + * information. + */ + TIFFWarningExt(tif->tif_clientdata, module, + ""Wrong \""StripByteCounts\"" field, ignoring and calculating from imagelength""); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; +#endif /* !defined(DEFER_STRILE_LOAD) */ + } + } + if (dir) + { + _TIFFfree(dir); + dir=NULL; + } + if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) + { + if (tif->tif_dir.td_bitspersample>=16) + tif->tif_dir.td_maxsamplevalue=0xFFFF; + else + tif->tif_dir.td_maxsamplevalue = (uint16)((1L<tif_dir.td_bitspersample)-1); + } + /* + * XXX: We can optimize checking for the strip bounds using the sorted + * bytecounts array. See also comments for TIFFAppendToStrip() + * function in tif_write.c. + */ +#if !defined(DEFER_STRILE_LOAD) + if (tif->tif_dir.td_nstrips > 1) { + uint32 strip; + + tif->tif_dir.td_stripbytecountsorted = 1; + for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { + if (tif->tif_dir.td_stripoffset[strip - 1] > + tif->tif_dir.td_stripoffset[strip]) { + tif->tif_dir.td_stripbytecountsorted = 0; + break; + } + } + } +#endif /* !defined(DEFER_STRILE_LOAD) */ + + /* + * An opportunity for compression mode dependent tag fixup + */ + (*tif->tif_fixuptags)(tif); + + /* + * Some manufacturers make life difficult by writing + * large amounts of uncompressed data as a single strip. + * This is contrary to the recommendations of the spec. + * The following makes an attempt at breaking such images + * into strips closer to the recommended 8k bytes. A + * side effect, however, is that the RowsPerStrip tag + * value may be changed. + */ + if ((tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)&& + (tif->tif_dir.td_nstrips==1)&& + (tif->tif_dir.td_compression==COMPRESSION_NONE)&& + ((tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED))==TIFF_STRIPCHOP)) + { + if ( !_TIFFFillStriles(tif) || !tif->tif_dir.td_stripbytecount ) + return 0; + ChopUpSingleUncompressedStrip(tif); + } + + /* + * Clear the dirty directory flag. + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + + /* + * Reinitialize i/o since we are starting on a new directory. + */ + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + tif->tif_col = (uint32) -1; + tif->tif_curtile = (uint32) -1; + tif->tif_tilesize = (tmsize_t) -1; + + tif->tif_scanlinesize = TIFFScanlineSize(tif); + if (!tif->tif_scanlinesize) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero scanline size""); + return (0); + } + + if (isTiled(tif)) { + tif->tif_tilesize = TIFFTileSize(tif); + if (!tif->tif_tilesize) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero tile size""); + return (0); + } + } else { + if (!TIFFStripSize(tif)) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero strip size""); + return (0); + } + } + return (1); +bad: + if (dir) + _TIFFfree(dir); + return (0); +} +",0,"TIFFReadDirectory(TIFF* tif) +{ + static const char module[] = ""TIFFReadDirectory""; + TIFFDirEntry* dir; + uint16 dircount; + TIFFDirEntry* dp; + uint16 di; + const TIFFField* fip; + uint32 fii=FAILED_FII; + toff_t nextdiroff; + int bitspersample_read = FALSE; + + tif->tif_diroff=tif->tif_nextdiroff; + if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff)) + return 0; /* last offset or bad offset (IFD looping) */ + (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ + tif->tif_curdir++; + nextdiroff = tif->tif_nextdiroff; + dircount=TIFFFetchDirectory(tif,nextdiroff,&dir,&tif->tif_nextdiroff); + if (!dircount) + { + TIFFErrorExt(tif->tif_clientdata,module, + ""Failed to read directory at offset "" TIFF_UINT64_FORMAT,nextdiroff); + return 0; + } + TIFFReadDirectoryCheckOrder(tif,dir,dircount); + + /* + * Mark duplicates of any tag to be ignored (bugzilla 1994) + * to avoid certain pathological problems. + */ + { + TIFFDirEntry* ma; + uint16 mb; + for (ma=dir, mb=0; mbtdir_tag==na->tdir_tag) + na->tdir_tag=IGNORE; + } + } + } + + tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ + tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */ + /* free any old stuff and reinit */ + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + /* + * Electronic Arts writes gray-scale TIFF files + * without a PlanarConfiguration directory entry. + * Thus we setup a default value here, even though + * the TIFF spec says there is no default value. + */ + TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); + /* + * Setup default value and then make a pass over + * the fields to check type and tag information, + * and to extract info required to size data + * structures. A second pass is made afterwards + * to read in everything not taken in the first pass. + * But we must process the Compression tag first + * in order to merge in codec-private tag definitions (otherwise + * we may get complaints about unknown tags). However, the + * Compression tag may be dependent on the SamplesPerPixel + * tag value because older TIFF specs permitted Compression + * to be written as a SamplesPerPixel-count tag entry. + * Thus if we don't first figure out the correct SamplesPerPixel + * tag value then we may end up ignoring the Compression tag + * value because it has an incorrect count value (if the + * true value of SamplesPerPixel is not 1). + */ + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_SAMPLESPERPIXEL); + if (dp) + { + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_tag=IGNORE; + } + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_COMPRESSION); + if (dp) + { + /* + * The 5.0 spec says the Compression tag has one value, while + * earlier specs say it has one value per sample. Because of + * this, we accept the tag if one value is supplied with either + * count. + */ + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + TIFFReadDirEntryOutputErr(tif,err,module,""Compression"",0); + goto bad; + } + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,value)) + goto bad; + dp->tdir_tag=IGNORE; + } + else + { + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE)) + goto bad; + } + /* + * First real pass over the directory. + */ + for (di=0, dp=dir; ditdir_tag!=IGNORE) + { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + if (fii == FAILED_FII) + { + TIFFWarningExt(tif->tif_clientdata, module, + ""Unknown field with tag %d (0x%x) encountered"", + dp->tdir_tag,dp->tdir_tag); + /* the following knowingly leaks the + anonymous field structure */ + if (!_TIFFMergeFields(tif, + _TIFFCreateAnonField(tif, + dp->tdir_tag, + (TIFFDataType) dp->tdir_type), + 1)) { + TIFFWarningExt(tif->tif_clientdata, + module, + ""Registering anonymous field with tag %d (0x%x) failed"", + dp->tdir_tag, + dp->tdir_tag); + dp->tdir_tag=IGNORE; + } else { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + assert(fii != FAILED_FII); + } + } + } + if (dp->tdir_tag!=IGNORE) + { + fip=tif->tif_fields[fii]; + if (fip->field_bit==FIELD_IGNORE) + dp->tdir_tag=IGNORE; + else + { + switch (dp->tdir_tag) + { + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEOFFSETS: + case TIFFTAG_TILEBYTECOUNTS: + TIFFSetFieldBit(tif,fip->field_bit); + break; + case TIFFTAG_IMAGEWIDTH: + case TIFFTAG_IMAGELENGTH: + case TIFFTAG_IMAGEDEPTH: + case TIFFTAG_TILELENGTH: + case TIFFTAG_TILEWIDTH: + case TIFFTAG_TILEDEPTH: + case TIFFTAG_PLANARCONFIG: + case TIFFTAG_ROWSPERSTRIP: + case TIFFTAG_EXTRASAMPLES: + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_tag=IGNORE; + break; + } + } + } + } + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) planarconfig tag says it's separate, + * c) strip offsets/bytecounts tag are both present and + * d) both contain exactly one value, then we consistently find + * that the buggy implementation of the buggy compression scheme + * matches contig planarconfig best. So we 'fix-up' the tag here + */ + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG)&& + (tif->tif_dir.td_planarconfig==PLANARCONFIG_SEPARATE)) + { + if (!_TIFFFillStriles(tif)) + goto bad; + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_STRIPOFFSETS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount, + TIFFTAG_STRIPBYTECOUNTS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + tif->tif_dir.td_planarconfig=PLANARCONFIG_CONTIG; + TIFFWarningExt(tif->tif_clientdata,module, + ""Planarconfig tag value assumed incorrect, "" + ""assuming data is contig instead of chunky""); + } + } + } + /* + * Allocate directory structure and setup defaults. + */ + if (!TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) + { + MissingRequired(tif,""ImageLength""); + goto bad; + } + /* + * Setup appropriate structures (by strip or by tile) + */ + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); + tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth; + tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip; + tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth; + tif->tif_flags &= ~TIFF_ISTILED; + } else { + tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); + tif->tif_flags |= TIFF_ISTILED; + } + if (!tif->tif_dir.td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero number of %s"", + isTiled(tif) ? ""tiles"" : ""strips""); + goto bad; + } + tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips; + if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE) + tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel; + if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { +#ifdef OJPEG_SUPPORT + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG) && + (isTiled(tif)==0) && + (tif->tif_dir.td_nstrips==1)) { + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) it's not a tiled TIFF, + * and c) the number of strips is 1, + * then we tolerate the absence of stripoffsets tag, + * because, presumably, all required data is in the + * JpegInterchangeFormat stream. + */ + TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); + } else +#endif + { + MissingRequired(tif, + isTiled(tif) ? ""TileOffsets"" : ""StripOffsets""); + goto bad; + } + } + /* + * Second pass: extract other information. + */ + for (di=0, dp=dir; ditdir_tag) + { + case IGNORE: + break; + case TIFFTAG_MINSAMPLEVALUE: + case TIFFTAG_MAXSAMPLEVALUE: + case TIFFTAG_BITSPERSAMPLE: + case TIFFTAG_DATATYPE: + case TIFFTAG_SAMPLEFORMAT: + /* + * The MinSampleValue, MaxSampleValue, BitsPerSample + * DataType and SampleFormat tags are supposed to be + * written as one value/sample, but some vendors + * incorrectly write one value only -- so we accept + * that as well (yuck). Other vendors write correct + * value for NumberOfSamples, but incorrect one for + * BitsPerSample and friends, and we will read this + * too. + */ + { + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : ""unknown tagname"",0); + goto bad; + } + if (!TIFFSetField(tif,dp->tdir_tag,value)) + goto bad; + if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE ) + bitspersample_read = TRUE; + } + break; + case TIFFTAG_SMINSAMPLEVALUE: + case TIFFTAG_SMAXSAMPLEVALUE: + { + + double *data = NULL; + enum TIFFReadDirEntryErr err; + uint32 saved_flags; + int m; + if (dp->tdir_count != (uint64)tif->tif_dir.td_samplesperpixel) + err = TIFFReadDirEntryErrCount; + else + err = TIFFReadDirEntryDoubleArray(tif, dp, &data); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : ""unknown tagname"",0); + goto bad; + } + saved_flags = tif->tif_flags; + tif->tif_flags |= TIFF_PERSAMPLE; + m = TIFFSetField(tif,dp->tdir_tag,data); + tif->tif_flags = saved_flags; + _TIFFfree(data); + if (!m) + goto bad; + } + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: +#if defined(DEFER_STRILE_LOAD) + _TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry), + dp, sizeof(TIFFDirEntry) ); +#else + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset)) + goto bad; +#endif + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: +#if defined(DEFER_STRILE_LOAD) + _TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry), + dp, sizeof(TIFFDirEntry) ); +#else + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount)) + goto bad; +#endif + break; + case TIFFTAG_COLORMAP: + case TIFFTAG_TRANSFERFUNCTION: + { + enum TIFFReadDirEntryErr err; + uint32 countpersample; + uint32 countrequired; + uint32 incrementpersample; + uint16* value=NULL; + /* It would be dangerous to instantiate those tag values */ + /* since if td_bitspersample has not yet been read (due to */ + /* unordered tags), it could be read afterwards with a */ + /* values greater than the default one (1), which may cause */ + /* crashes in user code */ + if( !bitspersample_read ) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + ""Ignoring %s since BitsPerSample tag not found"", + fip ? fip->field_name : ""unknown tagname""); + continue; + } + /* ColorMap or TransferFunction for high bit */ + /* depths do not make much sense and could be */ + /* used as a denial of service vector */ + if (tif->tif_dir.td_bitspersample > 24) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + ""Ignoring %s because BitsPerSample=%d>24"", + fip ? fip->field_name : ""unknown tagname"", + tif->tif_dir.td_bitspersample); + continue; + } + countpersample=(1U<tif_dir.td_bitspersample); + if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample)) + { + countrequired=countpersample; + incrementpersample=0; + } + else + { + countrequired=3*countpersample; + incrementpersample=countpersample; + } + if (dp->tdir_count!=(uint64)countrequired) + err=TIFFReadDirEntryErrCount; + else + err=TIFFReadDirEntryShortArray(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : ""unknown tagname"",1); + } + else + { + TIFFSetField(tif,dp->tdir_tag,value,value+incrementpersample,value+2*incrementpersample); + _TIFFfree(value); + } + } + break; +/* BEGIN REV 4.0 COMPATIBILITY */ + case TIFFTAG_OSUBFILETYPE: + { + uint16 valueo; + uint32 value; + if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk) + { + switch (valueo) + { + case OFILETYPE_REDUCEDIMAGE: value=FILETYPE_REDUCEDIMAGE; break; + case OFILETYPE_PAGE: value=FILETYPE_PAGE; break; + default: value=0; break; + } + if (value!=0) + TIFFSetField(tif,TIFFTAG_SUBFILETYPE,value); + } + } + break; +/* END REV 4.0 COMPATIBILITY */ + default: + (void) TIFFFetchNormalTag(tif, dp, TRUE); + break; + } + } + /* + * OJPEG hack: + * - If a) compression is OJPEG, and b) photometric tag is missing, + * then we consistently find that photometric should be YCbCr + * - If a) compression is OJPEG, and b) photometric tag says it's RGB, + * then we consistently find that the buggy implementation of the + * buggy compression scheme matches photometric YCbCr instead. + * - If a) compression is OJPEG, and b) bitspersample tag is missing, + * then we consistently find bitspersample should be 8. + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is RGB or YCbCr, then we consistently find + * samplesperpixel should be 3 + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is MINISWHITE or MINISBLACK, then we consistently + * find samplesperpixel should be 3 + */ + if (tif->tif_dir.td_compression==COMPRESSION_OJPEG) + { + if (!TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) + { + TIFFWarningExt(tif->tif_clientdata, module, + ""Photometric tag is missing, assuming data is YCbCr""); + if (!TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_YCBCR)) + goto bad; + } + else if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + tif->tif_dir.td_photometric=PHOTOMETRIC_YCBCR; + TIFFWarningExt(tif->tif_clientdata, module, + ""Photometric tag value assumed incorrect, "" + ""assuming data is YCbCr instead of RGB""); + } + if (!TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) + { + TIFFWarningExt(tif->tif_clientdata,module, + ""BitsPerSample tag is missing, assuming 8 bits per sample""); + if (!TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8)) + goto bad; + } + if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + { + if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + TIFFWarningExt(tif->tif_clientdata,module, + ""SamplesPerPixel tag is missing, "" + ""assuming correct SamplesPerPixel value is 3""); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + if (tif->tif_dir.td_photometric==PHOTOMETRIC_YCBCR) + { + TIFFWarningExt(tif->tif_clientdata,module, + ""SamplesPerPixel tag is missing, "" + ""applying correct SamplesPerPixel value of 3""); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + else if ((tif->tif_dir.td_photometric==PHOTOMETRIC_MINISWHITE) + || (tif->tif_dir.td_photometric==PHOTOMETRIC_MINISBLACK)) + { + /* + * SamplesPerPixel tag is missing, but is not required + * by spec. Assume correct SamplesPerPixel value of 1. + */ + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1)) + goto bad; + } + } + } + /* + * Verify Palette image has a Colormap. + */ + if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE && + !TIFFFieldSet(tif, FIELD_COLORMAP)) { + if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3) + tif->tif_dir.td_photometric = PHOTOMETRIC_RGB; + else if (tif->tif_dir.td_bitspersample>=8) + tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK; + else { + MissingRequired(tif, ""Colormap""); + goto bad; + } + } + /* + * OJPEG hack: + * We do no further messing with strip/tile offsets/bytecounts in OJPEG + * TIFFs + */ + if (tif->tif_dir.td_compression!=COMPRESSION_OJPEG) + { + /* + * Attempt to deal with a missing StripByteCounts tag. + */ + if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { + /* + * Some manufacturers violate the spec by not giving + * the size of the strips. In this case, assume there + * is one uncompressed strip of data. + */ + if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && + tif->tif_dir.td_nstrips > 1) || + (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE && + tif->tif_dir.td_nstrips != (uint32)tif->tif_dir.td_samplesperpixel)) { + MissingRequired(tif, ""StripByteCounts""); + goto bad; + } + TIFFWarningExt(tif->tif_clientdata, module, + ""TIFF directory is missing required "" + ""\""StripByteCounts\"" field, calculating from imagelength""); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + /* + * Assume we have wrong StripByteCount value (in case + * of single strip) in following cases: + * - it is equal to zero along with StripOffset; + * - it is larger than file itself (in case of uncompressed + * image); + * - it is smaller than the size of the bytes per row + * multiplied on the number of rows. The last case should + * not be checked in the case of writing new image, + * because we may do not know the exact strip size + * until the whole image will be written and directory + * dumped out. + */ + #define BYTECOUNTLOOKSBAD \ + ( (tif->tif_dir.td_stripbytecount[0] == 0 && tif->tif_dir.td_stripoffset[0] != 0) || \ + (tif->tif_dir.td_compression == COMPRESSION_NONE && \ + tif->tif_dir.td_stripbytecount[0] > TIFFGetFileSize(tif) - tif->tif_dir.td_stripoffset[0]) || \ + (tif->tif_mode == O_RDONLY && \ + tif->tif_dir.td_compression == COMPRESSION_NONE && \ + tif->tif_dir.td_stripbytecount[0] < TIFFScanlineSize64(tif) * tif->tif_dir.td_imagelength) ) + + } else if (tif->tif_dir.td_nstrips == 1 + && _TIFFFillStriles(tif) + && tif->tif_dir.td_stripoffset[0] != 0 + && BYTECOUNTLOOKSBAD) { + /* + * XXX: Plexus (and others) sometimes give a value of + * zero for a tag when they don't know what the + * correct value is! Try and handle the simple case + * of estimating the size of a one strip image. + */ + TIFFWarningExt(tif->tif_clientdata, module, + ""Bogus \""StripByteCounts\"" field, ignoring and calculating from imagelength""); + if(EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + +#if !defined(DEFER_STRILE_LOAD) + } else if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG + && tif->tif_dir.td_nstrips > 2 + && tif->tif_dir.td_compression == COMPRESSION_NONE + && tif->tif_dir.td_stripbytecount[0] != tif->tif_dir.td_stripbytecount[1] + && tif->tif_dir.td_stripbytecount[0] != 0 + && tif->tif_dir.td_stripbytecount[1] != 0 ) { + /* + * XXX: Some vendors fill StripByteCount array with + * absolutely wrong values (it can be equal to + * StripOffset array, for example). Catch this case + * here. + * + * We avoid this check if deferring strile loading + * as it would always force us to load the strip/tile + * information. + */ + TIFFWarningExt(tif->tif_clientdata, module, + ""Wrong \""StripByteCounts\"" field, ignoring and calculating from imagelength""); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; +#endif /* !defined(DEFER_STRILE_LOAD) */ + } + } + if (dir) + { + _TIFFfree(dir); + dir=NULL; + } + if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) + { + if (tif->tif_dir.td_bitspersample>=16) + tif->tif_dir.td_maxsamplevalue=0xFFFF; + else + tif->tif_dir.td_maxsamplevalue = (uint16)((1L<tif_dir.td_bitspersample)-1); + } + /* + * XXX: We can optimize checking for the strip bounds using the sorted + * bytecounts array. See also comments for TIFFAppendToStrip() + * function in tif_write.c. + */ +#if !defined(DEFER_STRILE_LOAD) + if (tif->tif_dir.td_nstrips > 1) { + uint32 strip; + + tif->tif_dir.td_stripbytecountsorted = 1; + for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { + if (tif->tif_dir.td_stripoffset[strip - 1] > + tif->tif_dir.td_stripoffset[strip]) { + tif->tif_dir.td_stripbytecountsorted = 0; + break; + } + } + } +#endif /* !defined(DEFER_STRILE_LOAD) */ + + /* + * An opportunity for compression mode dependent tag fixup + */ + (*tif->tif_fixuptags)(tif); + + /* + * Some manufacturers make life difficult by writing + * large amounts of uncompressed data as a single strip. + * This is contrary to the recommendations of the spec. + * The following makes an attempt at breaking such images + * into strips closer to the recommended 8k bytes. A + * side effect, however, is that the RowsPerStrip tag + * value may be changed. + */ + if ((tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)&& + (tif->tif_dir.td_nstrips==1)&& + (tif->tif_dir.td_compression==COMPRESSION_NONE)&& + ((tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED))==TIFF_STRIPCHOP)) + { + if ( !_TIFFFillStriles(tif) || !tif->tif_dir.td_stripbytecount ) + return 0; + ChopUpSingleUncompressedStrip(tif); + } + + /* + * Clear the dirty directory flag. + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + + /* + * Reinitialize i/o since we are starting on a new directory. + */ + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + tif->tif_col = (uint32) -1; + tif->tif_curtile = (uint32) -1; + tif->tif_tilesize = (tmsize_t) -1; + + tif->tif_scanlinesize = TIFFScanlineSize(tif); + if (!tif->tif_scanlinesize) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero scanline size""); + return (0); + } + + if (isTiled(tif)) { + tif->tif_tilesize = TIFFTileSize(tif); + if (!tif->tif_tilesize) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero tile size""); + return (0); + } + } else { + if (!TIFFStripSize(tif)) { + TIFFErrorExt(tif->tif_clientdata, module, + ""Cannot handle zero strip size""); + return (0); + } + } + return (1); +bad: + if (dir) + _TIFFfree(dir); + return (0); +} +","@@ -5502,8 +5502,7 @@ ChopUpSingleUncompressedStrip(TIFF* tif) + uint64 rowblockbytes; + uint64 stripbytes; + uint32 strip; +- uint64 nstrips64; +- uint32 nstrips32; ++ uint32 nstrips; + uint32 rowsperstrip; + uint64* newcounts; + uint64* newoffsets; +@@ -5534,18 +5533,17 @@ ChopUpSingleUncompressedStrip(TIFF* tif) + return; + + /* +- * never increase the number of strips in an image ++ * never increase the number of rows per strip + */ + if (rowsperstrip >= td->td_rowsperstrip) + return; +- nstrips64 = TIFFhowmany_64(bytecount, stripbytes); +- if ((nstrips64==0)||(nstrips64>0xFFFFFFFF)) /* something is wonky, do nothing. */ +- return; +- nstrips32 = (uint32)nstrips64; ++ nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip); ++ if( nstrips == 0 ) ++ return; + +- newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64), ++ newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), + ""for chopped \""StripByteCounts\"" array""); +- newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64), ++ newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), + ""for chopped \""StripOffsets\"" array""); + if (newcounts == NULL || newoffsets == NULL) { + /* +@@ -5562,18 +5560,18 @@ ChopUpSingleUncompressedStrip(TIFF* tif) + * Fill the strip information arrays with new bytecounts and offsets + * that reflect the broken-up format. + */ +- for (strip = 0; strip < nstrips32; strip++) { ++ for (strip = 0; strip < nstrips; strip++) { + if (stripbytes > bytecount) + stripbytes = bytecount; + newcounts[strip] = stripbytes; +- newoffsets[strip] = offset; ++ newoffsets[strip] = stripbytes ? offset : 0; + offset += stripbytes; + bytecount -= stripbytes; + } + /* + * Replace old single strip info with multi-strip info. + */ +- td->td_stripsperimage = td->td_nstrips = nstrips32; ++ td->td_stripsperimage = td->td_nstrips = nstrips; + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + + _TIFFfree(td->td_stripbytecount);",6812,7048,8192 +18232,"static int _6502_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) { + char addrbuf[64]; + const int buffsize = sizeof (addrbuf) - 1; + + memset (op, '\0', sizeof (RAnalOp)); + op->size = snes_op_get_size (1, 1, &snes_op[data[0]]); //snes-arch is similiar to nes/6502 + op->addr = addr; + op->type = R_ANAL_OP_TYPE_UNK; + op->id = data[0]; + r_strbuf_init (&op->esil); + switch (data[0]) { + case 0x02: + case 0x03: + case 0x04: + case 0x07: + case 0x0b: + case 0x0c: + case 0x0f: + case 0x12: + case 0x13: + case 0x14: + case 0x17: + case 0x1a: + case 0x1b: + case 0x1c: + case 0x1f: + case 0x22: + case 0x23: + case 0x27: + case 0x2b: + case 0x2f: + case 0x32: + case 0x33: + case 0x34: + case 0x37: + case 0x3a: + case 0x3b: + case 0x3c: + case 0x3f: + case 0x42: + case 0x43: + case 0x44: + case 0x47: + case 0x4b: + case 0x4f: + case 0x52: + case 0x53: + case 0x54: + case 0x57: + case 0x5a: + case 0x5b: + case 0x5c: + case 0x5f: + case 0x62: + case 0x63: + case 0x64: + case 0x67: + case 0x6b: + case 0x6f: + case 0x72: + case 0x73: + case 0x74: + case 0x77: + case 0x7a: + case 0x7b: + case 0x7c: + case 0x7f: + case 0x80: + case 0x82: + case 0x83: + case 0x87: + case 0x89: + case 0x8b: + case 0x8f: + case 0x92: + case 0x93: + case 0x97: + case 0x9b: + case 0x9c: + case 0x9e: + case 0x9f: + case 0xa3: + case 0xa7: + case 0xab: + case 0xaf: + case 0xb2: + case 0xb3: + case 0xb7: + case 0xbb: + case 0xbf: + case 0xc2: + case 0xc3: + case 0xc7: + case 0xcb: + case 0xcf: + case 0xd2: + case 0xd3: + case 0xd4: + case 0xd7: + case 0xda: + case 0xdb: + case 0xdc: + case 0xdf: + case 0xe2: + case 0xe3: + case 0xe7: + case 0xeb: + case 0xef: + case 0xf2: + case 0xf3: + case 0xf4: + case 0xf7: + case 0xfa: + case 0xfb: + case 0xfc: + case 0xff: + op->size = 1; + op->type = R_ANAL_OP_TYPE_ILL; + break; + + case 0x00: // brk + op->cycles = 7; + op->type = R_ANAL_OP_TYPE_SWI; + op->size = 1; + r_strbuf_set (&op->esil, "",1,I,=,0,D,=,flags,0x10,|,0x100,sp,+,=[1],pc,1,+,0xfe,sp,+,=[2],3,sp,-=,0xfffe,[2],pc,=""); + break; + + case 0x78: // sei + case 0x58: // cli + case 0x38: // sec + case 0x18: // clc + case 0xf8: // sed + case 0xd8: // cld + case 0xb8: // clv + op->cycles = 2; + op->type = R_ANAL_OP_TYPE_NOP; + _6502_anal_esil_flags (op, data[0]); + break; + case 0x24: // bit $ff + case 0x2c: // bit $ffff + op->type = R_ANAL_OP_TYPE_MOV; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 0); + r_strbuf_setf (&op->esil, ""a,%s,[1],&,0x80,&,!,!,N,=,a,%s,[1],&,0x40,&,!,!,V,=,a,%s,[1],&,0xff,&,!,Z,="",addrbuf, addrbuf, addrbuf); + break; + case 0x69: // adc #$ff + case 0x65: // adc $ff + case 0x75: // adc $ff,x + case 0x6d: // adc $ffff + case 0x7d: // adc $ffff,x + case 0x79: // adc $ffff,y + case 0x61: // adc ($ff,x) + case 0x71: // adc ($ff,y) + op->type = R_ANAL_OP_TYPE_ADD; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x69) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + r_strbuf_append (&op->esil, "",a,a,=,$z,Z,=""); + break; + case 0xe9: // sbc #$ff + case 0xe5: // sbc $ff + case 0xf5: // sbc $ff,x + case 0xed: // sbc $ffff + case 0xfd: // sbc $ffff,x + case 0xf9: // sbc $ffff,y + case 0xe1: // sbc ($ff,x) + case 0xf1: // sbc ($ff,y) + op->type = R_ANAL_OP_TYPE_SUB; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0xe9) // immediate mode + r_strbuf_setf (&op->esil, ""C,!,%s,+,a,-="", addrbuf); + else r_strbuf_setf (&op->esil, ""C,!,%s,[1],+,a,-="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",a,a,=,$z,Z,=,C,!=""); + break; + case 0x09: // ora #$ff + case 0x05: // ora $ff + case 0x15: // ora $ff,x + case 0x0d: // ora $ffff + case 0x1d: // ora $ffff,x + case 0x19: // ora $ffff,y + case 0x01: // ora ($ff,x) + case 0x11: // ora ($ff),y + op->type = R_ANAL_OP_TYPE_OR; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x09) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,|="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,|="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x29: // and #$ff + case 0x25: // and $ff + case 0x35: // and $ff,x + case 0x2d: // and $ffff + case 0x3d: // and $ffff,x + case 0x39: // and $ffff,y + case 0x21: // and ($ff,x) + case 0x31: // and ($ff),y + op->type = R_ANAL_OP_TYPE_AND; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x29) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,&="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,&="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x49: // eor #$ff + case 0x45: // eor $ff + case 0x55: // eor $ff,x + case 0x4d: // eor $ffff + case 0x5d: // eor $ffff,x + case 0x59: // eor $ffff,y + case 0x41: // eor ($ff,x) + case 0x51: // eor ($ff),y + op->type = R_ANAL_OP_TYPE_XOR; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x49) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,^="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,^="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x0a: // asl a + case 0x06: // asl $ff + case 0x16: // asl $ff,x + case 0x0e: // asl $ffff + case 0x1e: // asl $ffff,x + op->type = R_ANAL_OP_TYPE_SHL; + if (data[0] == 0x0a) { + r_strbuf_set (&op->esil, ""1,a,<<=,$c7,C,=,a,a,=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""1,%s,[1],<<,%s,=[1],$c7,C,="", addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x4a: // lsr a + case 0x46: // lsr $ff + case 0x56: // lsr $ff,x + case 0x4e: // lsr $ffff + case 0x5e: // lsr $ffff,x + op->type = R_ANAL_OP_TYPE_SHR; + if (data[0] == 0x4a) { + r_strbuf_set (&op->esil, ""1,a,&,C,=,1,a,>>=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""1,%s,[1],&,C,=,1,%s,[1],>>,%s,=[1]"", addrbuf, addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x2a: // rol a + case 0x26: // rol $ff + case 0x36: // rol $ff,x + case 0x2e: // rol $ffff + case 0x3e: // rol $ffff,x + op->type = R_ANAL_OP_TYPE_ROL; + if (data[0] == 0x2a) { + r_strbuf_set (&op->esil, ""1,a,<<,C,|,a,=,$c7,C,=,a,a,=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""1,%s,[1],<<,C,|,%s,=[1],$c7,C,="", addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x6a: // ror a + case 0x66: // ror $ff + case 0x76: // ror $ff,x + case 0x6e: // ror $ffff + case 0x7e: // ror $ffff,x + op->type = R_ANAL_OP_TYPE_ROR; + if (data[0] == 0x6a) { + r_strbuf_set (&op->esil, ""C,N,=,1,a,&,C,=,1,a,>>,7,N,<<,|,a,=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""C,N,=,1,%s,[1],&,C,=,1,%s,[1],>>,7,N,<<,|,%s,=[1]"", addrbuf, addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xe6: // inc $ff + case 0xf6: // inc $ff,x + case 0xee: // inc $ffff + case 0xfe: // inc $ffff,x + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""%s,++=[1]"", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xc6: // dec $ff + case 0xd6: // dec $ff,x + case 0xce: // dec $ffff + case 0xde: // dec $ffff,x + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""%s,--=[1]"", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xe8: // inx + case 0xc8: // iny + op->cycles = 2; + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_inc_reg (op, data[0], ""+""); + break; + case 0xca: // dex + case 0x88: // dey + op->cycles = 2; + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_inc_reg (op, data[0], ""-""); + break; + case 0xc9: // cmp #$ff + case 0xc5: // cmp $ff + case 0xd5: // cmp $ff,x + case 0xcd: // cmp $ffff + case 0xdd: // cmp $ffff,x + case 0xd9: // cmp $ffff,y + case 0xc1: // cmp ($ff,x) + case 0xd1: // cmp ($ff),y + op->type = R_ANAL_OP_TYPE_CMP; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0xc9) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,=="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,=="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",C,!,C,=""); + break; + case 0xe0: // cpx #$ff + case 0xe4: // cpx $ff + case 0xec: // cpx $ffff + op->type = R_ANAL_OP_TYPE_CMP; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 0); + if (data[0] == 0xe0) // immediate mode + r_strbuf_setf (&op->esil, ""%s,x,=="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],x,=="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",C,!,C,=""); + break; + case 0xc0: // cpy #$ff + case 0xc4: // cpy $ff + case 0xcc: // cpy $ffff + op->type = R_ANAL_OP_TYPE_CMP; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 0); + if (data[0] == 0xc0) // immediate mode + r_strbuf_setf (&op->esil, ""%s,y,=="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],y,=="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",C,!,C,=""); + break; + case 0x10: // bpl $ffff + case 0x30: // bmi $ffff + case 0x50: // bvc $ffff + case 0x70: // bvs $ffff + case 0x90: // bcc $ffff + case 0xb0: // bcs $ffff + case 0xd0: // bne $ffff + case 0xf0: // beq $ffff + op->cycles = 2; + op->failcycles = 3; + op->type = R_ANAL_OP_TYPE_CJMP; + if (data[1] <= 127) + op->jump = addr + data[1] + op->size; + else op->jump = addr - (256 - data[1]) + op->size; + op->fail = addr + op->size; + _6502_anal_esil_ccall (op, data[0]); + break; + case 0x20: // jsr $ffff + op->cycles = 6; + op->type = R_ANAL_OP_TYPE_CALL; + op->jump = data[1] | data[2] << 8; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = 2; + r_strbuf_setf (&op->esil, ""1,pc,-,0xff,sp,+,=[2],0x%04x,pc,=,2,sp,-="", op->jump); + break; + case 0x4c: // jmp $ffff + op->cycles = 3; + op->type = R_ANAL_OP_TYPE_JMP; + op->jump = data[1] | data[2] << 8; + r_strbuf_setf (&op->esil, ""0x%04x,pc,="", op->jump); + break; + case 0x6c: // jmp ($ffff) + op->cycles = 5; + op->type = R_ANAL_OP_TYPE_UJMP; + r_strbuf_setf (&op->esil, ""0x%04x,[2],pc,="", data[1] | data[2] << 8); + break; + case 0x60: // rts + op->eob = true; + op->type = R_ANAL_OP_TYPE_RET; + op->cycles = 6; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = -2; + r_strbuf_set (&op->esil, ""0x101,sp,+,[2],pc,=,pc,++=,2,sp,+=""); + break; + case 0x40: // rti + op->eob = true; + op->type = R_ANAL_OP_TYPE_RET; + op->cycles = 6; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = -3; + r_strbuf_set (&op->esil, ""0x101,sp,+,[1],flags,=,0x102,sp,+,[2],pc,=,3,sp,+=""); + break; + case 0xea: // nop + op->type = R_ANAL_OP_TYPE_NOP; + op->cycles = 2; + break; + case 0xa9: // lda #$ff + case 0xa5: // lda $ff + case 0xb5: // lda $ff,x + case 0xad: // lda $ffff + case 0xbd: // lda $ffff,x + case 0xb9: // lda $ffff,y + case 0xa1: // lda ($ff,x) + case 0xb1: // lda ($ff),y + op->type = R_ANAL_OP_TYPE_LOAD; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0xa9) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xa2: // ldx #$ff + case 0xa6: // ldx $ff + case 0xb6: // ldx $ff,y + case 0xae: // ldx $ffff + case 0xbe: // ldx $ffff,y + op->type = R_ANAL_OP_TYPE_LOAD; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'y'); + if (data[0] == 0xa2) // immediate mode + r_strbuf_setf (&op->esil, ""%s,x,="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],x,="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xa0: // ldy #$ff + case 0xa4: // ldy $ff + case 0xb4: // ldy $ff,x + case 0xac: // ldy $ffff + case 0xbc: // ldy $ffff,x + op->type = R_ANAL_OP_TYPE_LOAD; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 'x'); + if (data[0] == 0xa0) // immediate mode + r_strbuf_setf (&op->esil, ""%s,y,="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],y,="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x85: // sta $ff + case 0x95: // sta $ff,x + case 0x8d: // sta $ffff + case 0x9d: // sta $ffff,x + case 0x99: // sta $ffff,y + case 0x81: // sta ($ff,x) + case 0x91: // sta ($ff),y + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + r_strbuf_setf (&op->esil, ""a,%s,=[1]"", addrbuf); + break; + case 0x86: // stx $ff + case 0x96: // stx $ff,y + case 0x8e: // stx $ffff + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'y'); + r_strbuf_setf (&op->esil, ""x,%s,=[1]"", addrbuf); + break; + case 0x84: // sty $ff + case 0x94: // sty $ff,x + case 0x8c: // sty $ffff + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""y,%s,=[1]"", addrbuf); + break; + case 0x08: // php + case 0x48: // pha + op->type = R_ANAL_OP_TYPE_PUSH; + op->cycles = 3; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = 1; + _6502_anal_esil_push (op, data[0]); + break; + case 0x28: // plp + case 0x68: // plp + op->type = R_ANAL_OP_TYPE_POP; + op->cycles = 4; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = -1; + _6502_anal_esil_pop (op, data[0]); + break; + case 0xaa: // tax + case 0x8a: // txa + case 0xa8: // tay + case 0x98: // tya + op->type = R_ANAL_OP_TYPE_MOV; + op->cycles = 2; + _6502_anal_esil_mov (op, data[0]); + break; + case 0x9a: // txs + op->type = R_ANAL_OP_TYPE_MOV; + op->cycles = 2; + op->stackop = R_ANAL_STACK_SET; + _6502_anal_esil_mov (op, data[0]); + break; + case 0xba: // tsx + op->type = R_ANAL_OP_TYPE_MOV; + op->cycles = 2; + op->stackop = R_ANAL_STACK_GET; + _6502_anal_esil_mov (op, data[0]); + break; + } + return op->size; +} +",1,"static int _6502_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) { + char addrbuf[64]; + const int buffsize = sizeof (addrbuf) - 1; + + memset (op, '\0', sizeof (RAnalOp)); + op->size = snes_op_get_size (1, 1, &snes_op[data[0]]); //snes-arch is similiar to nes/6502 + op->addr = addr; + op->type = R_ANAL_OP_TYPE_UNK; + op->id = data[0]; + r_strbuf_init (&op->esil); + switch (data[0]) { + case 0x02: + case 0x03: + case 0x04: + case 0x07: + case 0x0b: + case 0x0c: + case 0x0f: + case 0x12: + case 0x13: + case 0x14: + case 0x17: + case 0x1a: + case 0x1b: + case 0x1c: + case 0x1f: + case 0x22: + case 0x23: + case 0x27: + case 0x2b: + case 0x2f: + case 0x32: + case 0x33: + case 0x34: + case 0x37: + case 0x3a: + case 0x3b: + case 0x3c: + case 0x3f: + case 0x42: + case 0x43: + case 0x44: + case 0x47: + case 0x4b: + case 0x4f: + case 0x52: + case 0x53: + case 0x54: + case 0x57: + case 0x5a: + case 0x5b: + case 0x5c: + case 0x5f: + case 0x62: + case 0x63: + case 0x64: + case 0x67: + case 0x6b: + case 0x6f: + case 0x72: + case 0x73: + case 0x74: + case 0x77: + case 0x7a: + case 0x7b: + case 0x7c: + case 0x7f: + case 0x80: + case 0x82: + case 0x83: + case 0x87: + case 0x89: + case 0x8b: + case 0x8f: + case 0x92: + case 0x93: + case 0x97: + case 0x9b: + case 0x9c: + case 0x9e: + case 0x9f: + case 0xa3: + case 0xa7: + case 0xab: + case 0xaf: + case 0xb2: + case 0xb3: + case 0xb7: + case 0xbb: + case 0xbf: + case 0xc2: + case 0xc3: + case 0xc7: + case 0xcb: + case 0xcf: + case 0xd2: + case 0xd3: + case 0xd4: + case 0xd7: + case 0xda: + case 0xdb: + case 0xdc: + case 0xdf: + case 0xe2: + case 0xe3: + case 0xe7: + case 0xeb: + case 0xef: + case 0xf2: + case 0xf3: + case 0xf4: + case 0xf7: + case 0xfa: + case 0xfb: + case 0xfc: + case 0xff: + op->size = 1; + op->type = R_ANAL_OP_TYPE_ILL; + break; + + case 0x00: // brk + op->cycles = 7; + op->type = R_ANAL_OP_TYPE_SWI; + op->size = 1; + r_strbuf_set (&op->esil, "",1,I,=,0,D,=,flags,0x10,|,0x100,sp,+,=[1],pc,1,+,0xfe,sp,+,=[2],3,sp,-=,0xfffe,[2],pc,=""); + break; + + case 0x78: // sei + case 0x58: // cli + case 0x38: // sec + case 0x18: // clc + case 0xf8: // sed + case 0xd8: // cld + case 0xb8: // clv + op->cycles = 2; + op->type = R_ANAL_OP_TYPE_NOP; + _6502_anal_esil_flags (op, data[0]); + break; + case 0x24: // bit $ff + case 0x2c: // bit $ffff + op->type = R_ANAL_OP_TYPE_MOV; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 0); + r_strbuf_setf (&op->esil, ""a,%s,[1],&,0x80,&,!,!,N,=,a,%s,[1],&,0x40,&,!,!,V,=,a,%s,[1],&,0xff,&,!,Z,="",addrbuf, addrbuf, addrbuf); + break; + case 0x69: // adc #$ff + case 0x65: // adc $ff + case 0x75: // adc $ff,x + case 0x6d: // adc $ffff + case 0x7d: // adc $ffff,x + case 0x79: // adc $ffff,y + case 0x61: // adc ($ff,x) + case 0x71: // adc ($ff,y) + op->type = R_ANAL_OP_TYPE_ADD; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x69) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + r_strbuf_append (&op->esil, "",a,a,=,$z,Z,=""); + break; + case 0xe9: // sbc #$ff + case 0xe5: // sbc $ff + case 0xf5: // sbc $ff,x + case 0xed: // sbc $ffff + case 0xfd: // sbc $ffff,x + case 0xf9: // sbc $ffff,y + case 0xe1: // sbc ($ff,x) + case 0xf1: // sbc ($ff,y) + op->type = R_ANAL_OP_TYPE_SUB; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0xe9) // immediate mode + r_strbuf_setf (&op->esil, ""C,!,%s,+,a,-="", addrbuf); + else r_strbuf_setf (&op->esil, ""C,!,%s,[1],+,a,-="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",a,a,=,$z,Z,=,C,!=""); + break; + case 0x09: // ora #$ff + case 0x05: // ora $ff + case 0x15: // ora $ff,x + case 0x0d: // ora $ffff + case 0x1d: // ora $ffff,x + case 0x19: // ora $ffff,y + case 0x01: // ora ($ff,x) + case 0x11: // ora ($ff),y + op->type = R_ANAL_OP_TYPE_OR; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x09) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,|="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,|="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x29: // and #$ff + case 0x25: // and $ff + case 0x35: // and $ff,x + case 0x2d: // and $ffff + case 0x3d: // and $ffff,x + case 0x39: // and $ffff,y + case 0x21: // and ($ff,x) + case 0x31: // and ($ff),y + op->type = R_ANAL_OP_TYPE_AND; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x29) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,&="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,&="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x49: // eor #$ff + case 0x45: // eor $ff + case 0x55: // eor $ff,x + case 0x4d: // eor $ffff + case 0x5d: // eor $ffff,x + case 0x59: // eor $ffff,y + case 0x41: // eor ($ff,x) + case 0x51: // eor ($ff),y + op->type = R_ANAL_OP_TYPE_XOR; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0x49) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,^="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,^="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x0a: // asl a + case 0x06: // asl $ff + case 0x16: // asl $ff,x + case 0x0e: // asl $ffff + case 0x1e: // asl $ffff,x + op->type = R_ANAL_OP_TYPE_SHL; + if (data[0] == 0x0a) { + r_strbuf_set (&op->esil, ""1,a,<<=,$c7,C,=,a,a,=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""1,%s,[1],<<,%s,=[1],$c7,C,="", addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x4a: // lsr a + case 0x46: // lsr $ff + case 0x56: // lsr $ff,x + case 0x4e: // lsr $ffff + case 0x5e: // lsr $ffff,x + op->type = R_ANAL_OP_TYPE_SHR; + if (data[0] == 0x4a) { + r_strbuf_set (&op->esil, ""1,a,&,C,=,1,a,>>=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""1,%s,[1],&,C,=,1,%s,[1],>>,%s,=[1]"", addrbuf, addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x2a: // rol a + case 0x26: // rol $ff + case 0x36: // rol $ff,x + case 0x2e: // rol $ffff + case 0x3e: // rol $ffff,x + op->type = R_ANAL_OP_TYPE_ROL; + if (data[0] == 0x2a) { + r_strbuf_set (&op->esil, ""1,a,<<,C,|,a,=,$c7,C,=,a,a,=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""1,%s,[1],<<,C,|,%s,=[1],$c7,C,="", addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x6a: // ror a + case 0x66: // ror $ff + case 0x76: // ror $ff,x + case 0x6e: // ror $ffff + case 0x7e: // ror $ffff,x + op->type = R_ANAL_OP_TYPE_ROR; + if (data[0] == 0x6a) { + r_strbuf_set (&op->esil, ""C,N,=,1,a,&,C,=,1,a,>>,7,N,<<,|,a,=""); + } else { + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""C,N,=,1,%s,[1],&,C,=,1,%s,[1],>>,7,N,<<,|,%s,=[1]"", addrbuf, addrbuf, addrbuf); + } + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xe6: // inc $ff + case 0xf6: // inc $ff,x + case 0xee: // inc $ffff + case 0xfe: // inc $ffff,x + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""%s,++=[1]"", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xc6: // dec $ff + case 0xd6: // dec $ff,x + case 0xce: // dec $ffff + case 0xde: // dec $ffff,x + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""%s,--=[1]"", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xe8: // inx + case 0xc8: // iny + op->cycles = 2; + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_inc_reg (op, data[0], ""+""); + break; + case 0xca: // dex + case 0x88: // dey + op->cycles = 2; + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_inc_reg (op, data[0], ""-""); + break; + case 0xc9: // cmp #$ff + case 0xc5: // cmp $ff + case 0xd5: // cmp $ff,x + case 0xcd: // cmp $ffff + case 0xdd: // cmp $ffff,x + case 0xd9: // cmp $ffff,y + case 0xc1: // cmp ($ff,x) + case 0xd1: // cmp ($ff),y + op->type = R_ANAL_OP_TYPE_CMP; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0xc9) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,=="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,=="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",C,!,C,=""); + break; + case 0xe0: // cpx #$ff + case 0xe4: // cpx $ff + case 0xec: // cpx $ffff + op->type = R_ANAL_OP_TYPE_CMP; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 0); + if (data[0] == 0xe0) // immediate mode + r_strbuf_setf (&op->esil, ""%s,x,=="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],x,=="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",C,!,C,=""); + break; + case 0xc0: // cpy #$ff + case 0xc4: // cpy $ff + case 0xcc: // cpy $ffff + op->type = R_ANAL_OP_TYPE_CMP; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 0); + if (data[0] == 0xc0) // immediate mode + r_strbuf_setf (&op->esil, ""%s,y,=="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],y,=="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_BNZ); + r_strbuf_append (&op->esil, "",C,!,C,=""); + break; + case 0x10: // bpl $ffff + case 0x30: // bmi $ffff + case 0x50: // bvc $ffff + case 0x70: // bvs $ffff + case 0x90: // bcc $ffff + case 0xb0: // bcs $ffff + case 0xd0: // bne $ffff + case 0xf0: // beq $ffff + op->cycles = 2; + op->failcycles = 3; + op->type = R_ANAL_OP_TYPE_CJMP; + if (len > 1) { + if (data[1] <= 127) { + op->jump = addr + data[1] + op->size; + } else { + op->jump = addr - (256 - data[1]) + op->size; + } + } else { + op->jump = addr; + } + op->fail = addr + op->size; + _6502_anal_esil_ccall (op, data[0]); + break; + case 0x20: // jsr $ffff + op->cycles = 6; + op->type = R_ANAL_OP_TYPE_CALL; + op->jump = data[1] | data[2] << 8; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = 2; + r_strbuf_setf (&op->esil, ""1,pc,-,0xff,sp,+,=[2],0x%04x,pc,=,2,sp,-="", op->jump); + break; + case 0x4c: // jmp $ffff + op->cycles = 3; + op->type = R_ANAL_OP_TYPE_JMP; + op->jump = data[1] | data[2] << 8; + r_strbuf_setf (&op->esil, ""0x%04x,pc,="", op->jump); + break; + case 0x6c: // jmp ($ffff) + op->cycles = 5; + op->type = R_ANAL_OP_TYPE_UJMP; + r_strbuf_setf (&op->esil, ""0x%04x,[2],pc,="", data[1] | data[2] << 8); + break; + case 0x60: // rts + op->eob = true; + op->type = R_ANAL_OP_TYPE_RET; + op->cycles = 6; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = -2; + r_strbuf_set (&op->esil, ""0x101,sp,+,[2],pc,=,pc,++=,2,sp,+=""); + break; + case 0x40: // rti + op->eob = true; + op->type = R_ANAL_OP_TYPE_RET; + op->cycles = 6; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = -3; + r_strbuf_set (&op->esil, ""0x101,sp,+,[1],flags,=,0x102,sp,+,[2],pc,=,3,sp,+=""); + break; + case 0xea: // nop + op->type = R_ANAL_OP_TYPE_NOP; + op->cycles = 2; + break; + case 0xa9: // lda #$ff + case 0xa5: // lda $ff + case 0xb5: // lda $ff,x + case 0xad: // lda $ffff + case 0xbd: // lda $ffff,x + case 0xb9: // lda $ffff,y + case 0xa1: // lda ($ff,x) + case 0xb1: // lda ($ff),y + op->type = R_ANAL_OP_TYPE_LOAD; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + if (data[0] == 0xa9) // immediate mode + r_strbuf_setf (&op->esil, ""%s,a,="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],a,="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xa2: // ldx #$ff + case 0xa6: // ldx $ff + case 0xb6: // ldx $ff,y + case 0xae: // ldx $ffff + case 0xbe: // ldx $ffff,y + op->type = R_ANAL_OP_TYPE_LOAD; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'y'); + if (data[0] == 0xa2) // immediate mode + r_strbuf_setf (&op->esil, ""%s,x,="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],x,="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0xa0: // ldy #$ff + case 0xa4: // ldy $ff + case 0xb4: // ldy $ff,x + case 0xac: // ldy $ffff + case 0xbc: // ldy $ffff,x + op->type = R_ANAL_OP_TYPE_LOAD; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 'x'); + if (data[0] == 0xa0) // immediate mode + r_strbuf_setf (&op->esil, ""%s,y,="", addrbuf); + else r_strbuf_setf (&op->esil, ""%s,[1],y,="", addrbuf); + _6502_anal_update_flags (op, _6502_FLAGS_NZ); + break; + case 0x85: // sta $ff + case 0x95: // sta $ff,x + case 0x8d: // sta $ffff + case 0x9d: // sta $ffff,x + case 0x99: // sta $ffff,y + case 0x81: // sta ($ff,x) + case 0x91: // sta ($ff),y + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern1 (op, data, addrbuf, buffsize); + r_strbuf_setf (&op->esil, ""a,%s,=[1]"", addrbuf); + break; + case 0x86: // stx $ff + case 0x96: // stx $ff,y + case 0x8e: // stx $ffff + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern2 (op, data, addrbuf, buffsize, 'y'); + r_strbuf_setf (&op->esil, ""x,%s,=[1]"", addrbuf); + break; + case 0x84: // sty $ff + case 0x94: // sty $ff,x + case 0x8c: // sty $ffff + op->type = R_ANAL_OP_TYPE_STORE; + _6502_anal_esil_get_addr_pattern3 (op, data, addrbuf, buffsize, 'x'); + r_strbuf_setf (&op->esil, ""y,%s,=[1]"", addrbuf); + break; + case 0x08: // php + case 0x48: // pha + op->type = R_ANAL_OP_TYPE_PUSH; + op->cycles = 3; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = 1; + _6502_anal_esil_push (op, data[0]); + break; + case 0x28: // plp + case 0x68: // plp + op->type = R_ANAL_OP_TYPE_POP; + op->cycles = 4; + op->stackop = R_ANAL_STACK_INC; + op->stackptr = -1; + _6502_anal_esil_pop (op, data[0]); + break; + case 0xaa: // tax + case 0x8a: // txa + case 0xa8: // tay + case 0x98: // tya + op->type = R_ANAL_OP_TYPE_MOV; + op->cycles = 2; + _6502_anal_esil_mov (op, data[0]); + break; + case 0x9a: // txs + op->type = R_ANAL_OP_TYPE_MOV; + op->cycles = 2; + op->stackop = R_ANAL_STACK_SET; + _6502_anal_esil_mov (op, data[0]); + break; + case 0xba: // tsx + op->type = R_ANAL_OP_TYPE_MOV; + op->cycles = 2; + op->stackop = R_ANAL_STACK_GET; + _6502_anal_esil_mov (op, data[0]); + break; + } + return op->size; +} +","@@ -682,9 +682,15 @@ static int _6502_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le + op->cycles = 2; + op->failcycles = 3; + op->type = R_ANAL_OP_TYPE_CJMP; +- if (data[1] <= 127) +- op->jump = addr + data[1] + op->size; +- else op->jump = addr - (256 - data[1]) + op->size; ++ if (len > 1) { ++ if (data[1] <= 127) { ++ op->jump = addr + data[1] + op->size; ++ } else { ++ op->jump = addr - (256 - data[1]) + op->size; ++ } ++ } else { ++ op->jump = addr; ++ } + op->fail = addr + op->size; + // FIXME: add a type of conditional + // op->cond = R_ANAL_COND_LE;",6443,6679,8192 +18344,"WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + const char *option,const char *arg1n,const char *arg2n) +{ + const char /* percent escaped versions of the args */ + *arg1, + *arg2; + + Image + *new_images; + + MagickStatusType + status; + + ssize_t + parse; + +#define _image_info (cli_wand->wand.image_info) +#define _images (cli_wand->wand.images) +#define _exception (cli_wand->wand.exception) +#define _draw_info (cli_wand->draw_info) +#define _quantize_info (cli_wand->quantize_info) +#define _process_flags (cli_wand->process_flags) +#define _option_type ((CommandOptionFlags) cli_wand->command->flags) +#define IfNormalOp (*option=='-') +#define IfPlusOp (*option!='-') +#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse + + assert(cli_wand != (MagickCLI *) NULL); + assert(cli_wand->signature == MagickWandSignature); + assert(cli_wand->wand.signature == MagickWandSignature); + assert(_images != (Image *) NULL); /* _images must be present */ + + if (cli_wand->wand.debug != MagickFalse) + (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), + ""- List Operator: %s \""%s\"" \""%s\"""", option, + arg1n == (const char *) NULL ? ""null"" : arg1n, + arg2n == (const char *) NULL ? ""null"" : arg2n); + + arg1 = arg1n; + arg2 = arg2n; + + /* Interpret Percent Escapes in Arguments - using first image */ + if ( (((_process_flags & ProcessInterpretProperities) != 0 ) + || ((_option_type & AlwaysInterpretArgsFlag) != 0) + ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { + /* Interpret Percent escapes in argument 1 */ + if (arg1n != (char *) NULL) { + arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); + if (arg1 == (char *) NULL) { + CLIWandException(OptionWarning,""InterpretPropertyFailure"",option); + arg1=arg1n; /* use the given argument as is */ + } + } + if (arg2n != (char *) NULL) { + arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); + if (arg2 == (char *) NULL) { + CLIWandException(OptionWarning,""InterpretPropertyFailure"",option); + arg2=arg2n; /* use the given argument as is */ + } + } + } +#undef _process_flags +#undef _option_type + + status=MagickTrue; + new_images=NewImageList(); + + switch (*(option+1)) + { + case 'a': + { + if (LocaleCompare(""append"",option+1) == 0) + { + new_images=AppendImages(_images,IsNormalOp,_exception); + break; + } + if (LocaleCompare(""average"",option+1) == 0) + { + CLIWandWarnReplaced(""-evaluate-sequence Mean""); + (void) CLIListOperatorImages(cli_wand,""-evaluate-sequence"",""Mean"", + NULL); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'c': + { + if (LocaleCompare(""channel-fx"",option+1) == 0) + { + new_images=ChannelFxImage(_images,arg1,_exception); + break; + } + if (LocaleCompare(""clut"",option+1) == 0) + { + Image + *clut_image; + + /* FUTURE - make this a compose option, and thus can be used + with layers compose or even compose last image over all other + _images. + */ + new_images=RemoveFirstImageFromList(&_images); + clut_image=RemoveLastImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (clut_image == (Image *) NULL) + break; + (void) ClutImage(new_images,clut_image,new_images->interpolate, + _exception); + clut_image=DestroyImage(clut_image); + break; + } + if (LocaleCompare(""coalesce"",option+1) == 0) + { + new_images=CoalesceImages(_images,_exception); + break; + } + if (LocaleCompare(""combine"",option+1) == 0) + { + parse=(ssize_t) _images->colorspace; + if (_images->number_channels < GetImageListLength(_images)) + parse=sRGBColorspace; + if ( IfPlusOp ) + parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); + if (parse < 0) + CLIWandExceptArgBreak(OptionError,""UnrecognizedColorspace"",option, + arg1); + new_images=CombineImages(_images,(ColorspaceType) parse,_exception); + break; + } + if (LocaleCompare(""compare"",option+1) == 0) + { + double + distortion; + + Image + *image, + *reconstruct_image; + + MetricType + metric; + + /* + Mathematically and visually annotate the difference between an + image and its reconstruction. + */ + image=RemoveFirstImageFromList(&_images); + reconstruct_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (reconstruct_image == (Image *) NULL) + { + image=DestroyImage(image); + break; + } + metric=UndefinedErrorMetric; + option=GetImageOption(_image_info,""metric""); + if (option != (const char *) NULL) + metric=(MetricType) ParseCommandOption(MagickMetricOptions, + MagickFalse,option); + new_images=CompareImages(image,reconstruct_image,metric,&distortion, + _exception); + (void) distortion; + reconstruct_image=DestroyImage(reconstruct_image); + image=DestroyImage(image); + break; + } + if (LocaleCompare(""complex"",option+1) == 0) + { + parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1); + if (parse < 0) + CLIWandExceptArgBreak(OptionError,""UnrecognizedEvaluateOperator"", + option,arg1); + new_images=ComplexImages(_images,(ComplexOperator) parse,_exception); + break; + } + if (LocaleCompare(""composite"",option+1) == 0) + { + CompositeOperator + compose; + + const char* + value; + + MagickBooleanType + clip_to_self; + + Image + *mask_image, + *source_image; + + RectangleInfo + geometry; + + /* Compose value from ""-compose"" option only */ + value=GetImageOption(_image_info,""compose""); + if (value == (const char *) NULL) + compose=OverCompositeOp; /* use Over not source_image->compose */ + else + compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, + MagickFalse,value); + + /* Get ""clip-to-self"" expert setting (false is normal) */ + clip_to_self=GetCompositeClipToSelf(compose); + value=GetImageOption(_image_info,""compose:clip-to-self""); + if (value != (const char *) NULL) + clip_to_self=IsStringTrue(value); + value=GetImageOption(_image_info,""compose:outside-overlay""); + if (value != (const char *) NULL) + clip_to_self=IsStringFalse(value); /* deprecated */ + + new_images=RemoveFirstImageFromList(&_images); + source_image=RemoveFirstImageFromList(&_images); + if (source_image == (Image *) NULL) + break; /* FUTURE - produce Exception, rather than silent fail */ + + /* FUTURE - this should not be here! - should be part of -geometry */ + if (source_image->geometry != (char *) NULL) + { + RectangleInfo + resize_geometry; + + (void) ParseRegionGeometry(source_image,source_image->geometry, + &resize_geometry,_exception); + if ((source_image->columns != resize_geometry.width) || + (source_image->rows != resize_geometry.height)) + { + Image + *resize_image; + + resize_image=ResizeImage(source_image,resize_geometry.width, + resize_geometry.height,source_image->filter,_exception); + if (resize_image != (Image *) NULL) + { + source_image=DestroyImage(source_image); + source_image=resize_image; + } + } + } + SetGeometry(source_image,&geometry); + (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); + GravityAdjustGeometry(new_images->columns,new_images->rows, + new_images->gravity, &geometry); + mask_image=RemoveFirstImageFromList(&_images); + if (mask_image == (Image *) NULL) + status&=CompositeImage(new_images,source_image,compose,clip_to_self, + geometry.x,geometry.y,_exception); + else + { + if ((compose == DisplaceCompositeOp) || + (compose == DistortCompositeOp)) + { + status&=CompositeImage(source_image,mask_image, + CopyGreenCompositeOp,MagickTrue,0,0,_exception); + status&=CompositeImage(new_images,source_image,compose, + clip_to_self,geometry.x,geometry.y,_exception); + } + else + { + Image + *clone_image; + + clone_image=CloneImage(new_images,0,0,MagickTrue,_exception); + if (clone_image == (Image *) NULL) + break; + status&=CompositeImage(new_images,source_image,compose, + clip_to_self,geometry.x,geometry.y,_exception); + status&=CompositeImage(new_images,mask_image, + CopyAlphaCompositeOp,MagickTrue,0,0,_exception); + status&=CompositeImage(clone_image,new_images,OverCompositeOp, + clip_to_self,0,0,_exception); + new_images=DestroyImageList(new_images); + new_images=clone_image; + } + mask_image=DestroyImage(mask_image); + } + source_image=DestroyImage(source_image); + break; + } + if (LocaleCompare(""copy"",option+1) == 0) + { + Image + *source_image; + + OffsetInfo + offset; + + RectangleInfo + geometry; + + /* + Copy image pixels. + */ + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + if (IsGeometry(arg2) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + (void) ParsePageGeometry(_images,arg2,&geometry,_exception); + offset.x=geometry.x; + offset.y=geometry.y; + source_image=_images; + if (source_image->next != (Image *) NULL) + source_image=source_image->next; + (void) ParsePageGeometry(source_image,arg1,&geometry,_exception); + (void) CopyImagePixels(_images,source_image,&geometry,&offset, + _exception); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'd': + { + if (LocaleCompare(""deconstruct"",option+1) == 0) + { + CLIWandWarnReplaced(""-layer CompareAny""); + (void) CLIListOperatorImages(cli_wand,""-layer"",""CompareAny"",NULL); + break; + } + if (LocaleCompare(""delete"",option+1) == 0) + { + if (IfNormalOp) + DeleteImages(&_images,arg1,_exception); + else + DeleteImages(&_images,""-1"",_exception); + break; + } + if (LocaleCompare(""duplicate"",option+1) == 0) + { + if (IfNormalOp) + { + const char + *p; + + size_t + number_duplicates; + + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option, + arg1); + number_duplicates=(size_t) StringToLong(arg1); + p=strchr(arg1,','); + if (p == (const char *) NULL) + new_images=DuplicateImages(_images,number_duplicates,""-1"", + _exception); + else + new_images=DuplicateImages(_images,number_duplicates,p, + _exception); + } + else + new_images=DuplicateImages(_images,1,""-1"",_exception); + AppendImageToList(&_images, new_images); + new_images=(Image *) NULL; + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'e': + { + if (LocaleCompare(""evaluate-sequence"",option+1) == 0) + { + parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); + if (parse < 0) + CLIWandExceptArgBreak(OptionError,""UnrecognizedEvaluateOperator"", + option,arg1); + new_images=EvaluateImages(_images,(MagickEvaluateOperator) parse, + _exception); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'f': + { + if (LocaleCompare(""fft"",option+1) == 0) + { + new_images=ForwardFourierTransformImage(_images,IsNormalOp, + _exception); + break; + } + if (LocaleCompare(""flatten"",option+1) == 0) + { + /* REDIRECTED to use -layers flatten instead */ + (void) CLIListOperatorImages(cli_wand,""-layers"",option+1,NULL); + break; + } + if (LocaleCompare(""fx"",option+1) == 0) + { + new_images=FxImage(_images,arg1,_exception); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'h': + { + if (LocaleCompare(""hald-clut"",option+1) == 0) + { + /* FUTURE - make this a compose option (and thus layers compose ) + or perhaps compose last image over all other _images. + */ + Image + *hald_image; + + new_images=RemoveFirstImageFromList(&_images); + hald_image=RemoveLastImageFromList(&_images); + if (hald_image == (Image *) NULL) + break; + (void) HaldClutImage(new_images,hald_image,_exception); + hald_image=DestroyImage(hald_image); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'i': + { + if (LocaleCompare(""ift"",option+1) == 0) + { + Image + *magnitude_image, + *phase_image; + + magnitude_image=RemoveFirstImageFromList(&_images); + phase_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (phase_image == (Image *) NULL) + break; + new_images=InverseFourierTransformImage(magnitude_image,phase_image, + IsNormalOp,_exception); + magnitude_image=DestroyImage(magnitude_image); + phase_image=DestroyImage(phase_image); + break; + } + if (LocaleCompare(""insert"",option+1) == 0) + { + Image + *insert_image, + *index_image; + + ssize_t + index; + + if (IfNormalOp && (IsGeometry(arg1) == MagickFalse)) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + index=0; + insert_image=RemoveLastImageFromList(&_images); + if (IfNormalOp) + index=(ssize_t) StringToLong(arg1); + index_image=insert_image; + if (index == 0) + PrependImageToList(&_images,insert_image); + else if (index == (ssize_t) GetImageListLength(_images)) + AppendImageToList(&_images,insert_image); + else + { + index_image=GetImageFromList(_images,index-1); + if (index_image == (Image *) NULL) + { + insert_image=DestroyImage(insert_image); + CLIWandExceptArgBreak(OptionError,""NoSuchImage"",option,arg1); + } + InsertImageInList(&index_image,insert_image); + } + _images=GetFirstImageInList(index_image); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'l': + { + if (LocaleCompare(""layers"",option+1) == 0) + { + parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); + if ( parse < 0 ) + CLIWandExceptArgBreak(OptionError,""UnrecognizedLayerMethod"", + option,arg1); + switch ((LayerMethod) parse) + { + case CoalesceLayer: + { + new_images=CoalesceImages(_images,_exception); + break; + } + case CompareAnyLayer: + case CompareClearLayer: + case CompareOverlayLayer: + default: + { + new_images=CompareImagesLayers(_images,(LayerMethod) parse, + _exception); + break; + } + case MergeLayer: + case FlattenLayer: + case MosaicLayer: + case TrimBoundsLayer: + { + new_images=MergeImageLayers(_images,(LayerMethod) parse, + _exception); + break; + } + case DisposeLayer: + { + new_images=DisposeImages(_images,_exception); + break; + } + case OptimizeImageLayer: + { + new_images=OptimizeImageLayers(_images,_exception); + break; + } + case OptimizePlusLayer: + { + new_images=OptimizePlusImageLayers(_images,_exception); + break; + } + case OptimizeTransLayer: + { + OptimizeImageTransparency(_images,_exception); + break; + } + case RemoveDupsLayer: + { + RemoveDuplicateLayers(&_images,_exception); + break; + } + case RemoveZeroLayer: + { + RemoveZeroDelayLayers(&_images,_exception); + break; + } + case OptimizeLayer: + { /* General Purpose, GIF Animation Optimizer. */ + new_images=CoalesceImages(_images,_exception); + if (new_images == (Image *) NULL) + break; + _images=DestroyImageList(_images); + _images=OptimizeImageLayers(new_images,_exception); + if (_images == (Image *) NULL) + break; + new_images=DestroyImageList(new_images); + OptimizeImageTransparency(_images,_exception); + (void) RemapImages(_quantize_info,_images,(Image *) NULL, + _exception); + break; + } + case CompositeLayer: + { + Image + *source; + + RectangleInfo + geometry; + + CompositeOperator + compose; + + const char* + value; + + value=GetImageOption(_image_info,""compose""); + compose=OverCompositeOp; /* Default to Over */ + if (value != (const char *) NULL) + compose=(CompositeOperator) ParseCommandOption( + MagickComposeOptions,MagickFalse,value); + + /* Split image sequence at the first 'NULL:' image. */ + source=_images; + while (source != (Image *) NULL) + { + source=GetNextImageInList(source); + if ((source != (Image *) NULL) && + (LocaleCompare(source->magick,""NULL"") == 0)) + break; + } + if (source != (Image *) NULL) + { + if ((GetPreviousImageInList(source) == (Image *) NULL) || + (GetNextImageInList(source) == (Image *) NULL)) + source=(Image *) NULL; + else + { /* Separate the two lists, junk the null: image. */ + source=SplitImageList(source->previous); + DeleteImageFromList(&source); + } + } + if (source == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""MissingNullSeparator"",""layers Composite""); + break; + } + /* Adjust offset with gravity and virtual canvas. */ + SetGeometry(_images,&geometry); + (void) ParseAbsoluteGeometry(_images->geometry,&geometry); + geometry.width=source->page.width != 0 ? + source->page.width : source->columns; + geometry.height=source->page.height != 0 ? + source->page.height : source->rows; + GravityAdjustGeometry(_images->page.width != 0 ? + _images->page.width : _images->columns, + _images->page.height != 0 ? _images->page.height : + _images->rows,_images->gravity,&geometry); + + /* Compose the two image sequences together */ + CompositeLayers(_images,compose,source,geometry.x,geometry.y, + _exception); + source=DestroyImageList(source); + break; + } + } + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'm': + { + if (LocaleCompare(""map"",option+1) == 0) + { + CLIWandWarnReplaced(""+remap""); + (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); + break; + } + if (LocaleCompare(""metric"",option+1) == 0) + { + (void) SetImageOption(_image_info,option+1,arg1); + break; + } + if (LocaleCompare(""morph"",option+1) == 0) + { + Image + *morph_image; + + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + morph_image=MorphImages(_images,StringToUnsignedLong(arg1), + _exception); + if (morph_image == (Image *) NULL) + break; + _images=DestroyImageList(_images); + _images=morph_image; + break; + } + if (LocaleCompare(""mosaic"",option+1) == 0) + { + /* REDIRECTED to use -layers mosaic instead */ + (void) CLIListOperatorImages(cli_wand,""-layers"",option+1,NULL); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'p': + { + if (LocaleCompare(""poly"",option+1) == 0) + { + double + *args; + + ssize_t + count; + + /* convert argument string into an array of doubles */ + args = StringToArrayOfDoubles(arg1,&count,_exception); + if (args == (double *) NULL ) + CLIWandExceptArgBreak(OptionError,""InvalidNumberList"",option,arg1); + new_images=PolynomialImage(_images,(size_t) (count >> 1),args, + _exception); + args=(double *) RelinquishMagickMemory(args); + break; + } + if (LocaleCompare(""process"",option+1) == 0) + { + /* FUTURE: better parsing using ScriptToken() from string ??? */ + char + **arguments; + + int + j, + number_arguments; + + arguments=StringToArgv(arg1,&number_arguments); + if (arguments == (char **) NULL) + break; + if (strchr(arguments[1],'=') != (char *) NULL) + { + char + breaker, + quote, + *token; + + const char + *arguments; + + int + next, + status; + + size_t + length; + + TokenInfo + *token_info; + + /* + Support old style syntax, filter=""-option arg1"". + */ + assert(arg1 != (const char *) NULL); + length=strlen(arg1); + token=(char *) NULL; + if (~length >= (MagickPathExtent-1)) + token=(char *) AcquireQuantumMemory(length+MagickPathExtent, + sizeof(*token)); + if (token == (char *) NULL) + break; + next=0; + arguments=arg1; + token_info=AcquireTokenInfo(); + status=Tokenizer(token_info,0,token,length,arguments,"""",""="", + ""\"""",'\0',&breaker,&next,"e); + token_info=DestroyTokenInfo(token_info); + if (status == 0) + { + const char + *argv; + + argv=(&(arguments[next])); + (void) InvokeDynamicImageFilter(token,&_images,1,&argv, + _exception); + } + token=DestroyString(token); + break; + } + (void) SubstituteString(&arguments[1],""-"",""""); + (void) InvokeDynamicImageFilter(arguments[1],&_images, + number_arguments-2,(const char **) arguments+2,_exception); + for (j=0; j < number_arguments; j++) + arguments[j]=DestroyString(arguments[j]); + arguments=(char **) RelinquishMagickMemory(arguments); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'r': + { + if (LocaleCompare(""remap"",option+1) == 0) + { + (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); + break; + } + if (LocaleCompare(""reverse"",option+1) == 0) + { + ReverseImageList(&_images); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 's': + { + if (LocaleCompare(""smush"",option+1) == 0) + { + /* FUTURE: this option needs more work to make better */ + ssize_t + offset; + + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + offset=(ssize_t) StringToLong(arg1); + new_images=SmushImages(_images,IsNormalOp,offset,_exception); + break; + } + if (LocaleCompare(""subimage"",option+1) == 0) + { + Image + *base_image, + *compare_image; + + const char + *value; + + MetricType + metric; + + double + similarity; + + RectangleInfo + offset; + + base_image=GetImageFromList(_images,0); + compare_image=GetImageFromList(_images,1); + + /* Comparision Metric */ + metric=UndefinedErrorMetric; + value=GetImageOption(_image_info,""metric""); + if (value != (const char *) NULL) + metric=(MetricType) ParseCommandOption(MagickMetricOptions, + MagickFalse,value); + + new_images=SimilarityImage(base_image,compare_image,metric,0.0, + &offset,&similarity,_exception); + + if (new_images != (Image *) NULL) + { + char + result[MagickPathExtent]; + + (void) FormatLocaleString(result,MagickPathExtent,""%lf"", + similarity); + (void) SetImageProperty(new_images,""subimage:similarity"",result, + _exception); + (void) FormatLocaleString(result,MagickPathExtent,""%+ld"",(long) + offset.x); + (void) SetImageProperty(new_images,""subimage:x"",result, + _exception); + (void) FormatLocaleString(result,MagickPathExtent,""%+ld"",(long) + offset.y); + (void) SetImageProperty(new_images,""subimage:y"",result, + _exception); + (void) FormatLocaleString(result,MagickPathExtent, + ""%lux%lu%+ld%+ld"",(unsigned long) offset.width,(unsigned long) + offset.height,(long) offset.x,(long) offset.y); + (void) SetImageProperty(new_images,""subimage:offset"",result, + _exception); + } + break; + } + if (LocaleCompare(""swap"",option+1) == 0) + { + Image + *p, + *q, + *swap; + + ssize_t + index, + swap_index; + + index=(-1); + swap_index=(-2); + if (IfNormalOp) { + GeometryInfo + geometry_info; + + MagickStatusType + flags; + + swap_index=(-1); + flags=ParseGeometry(arg1,&geometry_info); + if ((flags & RhoValue) == 0) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + index=(ssize_t) geometry_info.rho; + if ((flags & SigmaValue) != 0) + swap_index=(ssize_t) geometry_info.sigma; + } + p=GetImageFromList(_images,index); + q=GetImageFromList(_images,swap_index); + if ((p == (Image *) NULL) || (q == (Image *) NULL)) { + if (IfNormalOp) + CLIWandExceptArgBreak(OptionError,""InvalidImageIndex"",option,arg1) + else + CLIWandExceptionBreak(OptionError,""TwoOrMoreImagesRequired"",option); + } + if (p == q) + CLIWandExceptArgBreak(OptionError,""InvalidImageIndex"",option,arg1); + swap=CloneImage(p,0,0,MagickTrue,_exception); + if (swap == (Image *) NULL) + CLIWandExceptArgBreak(ResourceLimitError,""MemoryAllocationFailed"", + option,GetExceptionMessage(errno)); + ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); + ReplaceImageInList(&q,swap); + _images=GetFirstImageInList(q); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + default: + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + + /* clean up percent escape interpreted strings */ + if (arg1 != arg1n ) + arg1=DestroyString((char *)arg1); + if (arg2 != arg2n ) + arg2=DestroyString((char *)arg2); + + /* if new image list generated, replace existing image list */ + if (new_images == (Image *) NULL) + return(status == 0 ? MagickFalse : MagickTrue); + _images=DestroyImageList(_images); + _images=GetFirstImageInList(new_images); + return(status == 0 ? MagickFalse : MagickTrue); + +#undef _image_info +#undef _images +#undef _exception +#undef _draw_info +#undef _quantize_info +#undef IfNormalOp +#undef IfPlusOp +#undef IsNormalOp +} +",1,"WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + const char *option,const char *arg1n,const char *arg2n) +{ + const char /* percent escaped versions of the args */ + *arg1, + *arg2; + + Image + *new_images; + + MagickStatusType + status; + + ssize_t + parse; + +#define _image_info (cli_wand->wand.image_info) +#define _images (cli_wand->wand.images) +#define _exception (cli_wand->wand.exception) +#define _draw_info (cli_wand->draw_info) +#define _quantize_info (cli_wand->quantize_info) +#define _process_flags (cli_wand->process_flags) +#define _option_type ((CommandOptionFlags) cli_wand->command->flags) +#define IfNormalOp (*option=='-') +#define IfPlusOp (*option!='-') +#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse + + assert(cli_wand != (MagickCLI *) NULL); + assert(cli_wand->signature == MagickWandSignature); + assert(cli_wand->wand.signature == MagickWandSignature); + assert(_images != (Image *) NULL); /* _images must be present */ + + if (cli_wand->wand.debug != MagickFalse) + (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), + ""- List Operator: %s \""%s\"" \""%s\"""", option, + arg1n == (const char *) NULL ? ""null"" : arg1n, + arg2n == (const char *) NULL ? ""null"" : arg2n); + + arg1 = arg1n; + arg2 = arg2n; + + /* Interpret Percent Escapes in Arguments - using first image */ + if ( (((_process_flags & ProcessInterpretProperities) != 0 ) + || ((_option_type & AlwaysInterpretArgsFlag) != 0) + ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { + /* Interpret Percent escapes in argument 1 */ + if (arg1n != (char *) NULL) { + arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); + if (arg1 == (char *) NULL) { + CLIWandException(OptionWarning,""InterpretPropertyFailure"",option); + arg1=arg1n; /* use the given argument as is */ + } + } + if (arg2n != (char *) NULL) { + arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); + if (arg2 == (char *) NULL) { + CLIWandException(OptionWarning,""InterpretPropertyFailure"",option); + arg2=arg2n; /* use the given argument as is */ + } + } + } +#undef _process_flags +#undef _option_type + + status=MagickTrue; + new_images=NewImageList(); + + switch (*(option+1)) + { + case 'a': + { + if (LocaleCompare(""append"",option+1) == 0) + { + new_images=AppendImages(_images,IsNormalOp,_exception); + break; + } + if (LocaleCompare(""average"",option+1) == 0) + { + CLIWandWarnReplaced(""-evaluate-sequence Mean""); + (void) CLIListOperatorImages(cli_wand,""-evaluate-sequence"",""Mean"", + NULL); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'c': + { + if (LocaleCompare(""channel-fx"",option+1) == 0) + { + new_images=ChannelFxImage(_images,arg1,_exception); + break; + } + if (LocaleCompare(""clut"",option+1) == 0) + { + Image + *clut_image; + + /* FUTURE - make this a compose option, and thus can be used + with layers compose or even compose last image over all other + _images. + */ + new_images=RemoveFirstImageFromList(&_images); + clut_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (clut_image == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""ImageSequenceRequired"",""`%s'"",option); + new_images=DestroyImage(new_images); + status=MagickFalse; + break; + } + (void) ClutImage(new_images,clut_image,new_images->interpolate, + _exception); + clut_image=DestroyImage(clut_image); + break; + } + if (LocaleCompare(""coalesce"",option+1) == 0) + { + new_images=CoalesceImages(_images,_exception); + break; + } + if (LocaleCompare(""combine"",option+1) == 0) + { + parse=(ssize_t) _images->colorspace; + if (_images->number_channels < GetImageListLength(_images)) + parse=sRGBColorspace; + if ( IfPlusOp ) + parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); + if (parse < 0) + CLIWandExceptArgBreak(OptionError,""UnrecognizedColorspace"",option, + arg1); + new_images=CombineImages(_images,(ColorspaceType) parse,_exception); + break; + } + if (LocaleCompare(""compare"",option+1) == 0) + { + double + distortion; + + Image + *image, + *reconstruct_image; + + MetricType + metric; + + /* + Mathematically and visually annotate the difference between an + image and its reconstruction. + */ + image=RemoveFirstImageFromList(&_images); + reconstruct_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (reconstruct_image == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""ImageSequenceRequired"",""`%s'"",option); + image=DestroyImage(image); + status=MagickFalse; + break; + } + metric=UndefinedErrorMetric; + option=GetImageOption(_image_info,""metric""); + if (option != (const char *) NULL) + metric=(MetricType) ParseCommandOption(MagickMetricOptions, + MagickFalse,option); + new_images=CompareImages(image,reconstruct_image,metric,&distortion, + _exception); + (void) distortion; + reconstruct_image=DestroyImage(reconstruct_image); + image=DestroyImage(image); + break; + } + if (LocaleCompare(""complex"",option+1) == 0) + { + parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1); + if (parse < 0) + CLIWandExceptArgBreak(OptionError,""UnrecognizedEvaluateOperator"", + option,arg1); + new_images=ComplexImages(_images,(ComplexOperator) parse,_exception); + break; + } + if (LocaleCompare(""composite"",option+1) == 0) + { + CompositeOperator + compose; + + const char* + value; + + MagickBooleanType + clip_to_self; + + Image + *mask_image, + *source_image; + + RectangleInfo + geometry; + + /* Compose value from ""-compose"" option only */ + value=GetImageOption(_image_info,""compose""); + if (value == (const char *) NULL) + compose=OverCompositeOp; /* use Over not source_image->compose */ + else + compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, + MagickFalse,value); + + /* Get ""clip-to-self"" expert setting (false is normal) */ + clip_to_self=GetCompositeClipToSelf(compose); + value=GetImageOption(_image_info,""compose:clip-to-self""); + if (value != (const char *) NULL) + clip_to_self=IsStringTrue(value); + value=GetImageOption(_image_info,""compose:outside-overlay""); + if (value != (const char *) NULL) + clip_to_self=IsStringFalse(value); /* deprecated */ + + new_images=RemoveFirstImageFromList(&_images); + source_image=RemoveFirstImageFromList(&_images); + if (source_image == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""ImageSequenceRequired"",""`%s'"",option); + new_images=DestroyImage(new_images); + status=MagickFalse; + break; + } + + /* FUTURE - this should not be here! - should be part of -geometry */ + if (source_image->geometry != (char *) NULL) + { + RectangleInfo + resize_geometry; + + (void) ParseRegionGeometry(source_image,source_image->geometry, + &resize_geometry,_exception); + if ((source_image->columns != resize_geometry.width) || + (source_image->rows != resize_geometry.height)) + { + Image + *resize_image; + + resize_image=ResizeImage(source_image,resize_geometry.width, + resize_geometry.height,source_image->filter,_exception); + if (resize_image != (Image *) NULL) + { + source_image=DestroyImage(source_image); + source_image=resize_image; + } + } + } + SetGeometry(source_image,&geometry); + (void) ParseAbsoluteGeometry(source_image->geometry,&geometry); + GravityAdjustGeometry(new_images->columns,new_images->rows, + new_images->gravity, &geometry); + mask_image=RemoveFirstImageFromList(&_images); + if (mask_image == (Image *) NULL) + status&=CompositeImage(new_images,source_image,compose,clip_to_self, + geometry.x,geometry.y,_exception); + else + { + if ((compose == DisplaceCompositeOp) || + (compose == DistortCompositeOp)) + { + status&=CompositeImage(source_image,mask_image, + CopyGreenCompositeOp,MagickTrue,0,0,_exception); + status&=CompositeImage(new_images,source_image,compose, + clip_to_self,geometry.x,geometry.y,_exception); + } + else + { + Image + *clone_image; + + clone_image=CloneImage(new_images,0,0,MagickTrue,_exception); + if (clone_image == (Image *) NULL) + break; + status&=CompositeImage(new_images,source_image,compose, + clip_to_self,geometry.x,geometry.y,_exception); + status&=CompositeImage(new_images,mask_image, + CopyAlphaCompositeOp,MagickTrue,0,0,_exception); + status&=CompositeImage(clone_image,new_images,OverCompositeOp, + clip_to_self,0,0,_exception); + new_images=DestroyImageList(new_images); + new_images=clone_image; + } + mask_image=DestroyImage(mask_image); + } + source_image=DestroyImage(source_image); + break; + } + if (LocaleCompare(""copy"",option+1) == 0) + { + Image + *source_image; + + OffsetInfo + offset; + + RectangleInfo + geometry; + + /* + Copy image pixels. + */ + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + if (IsGeometry(arg2) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + (void) ParsePageGeometry(_images,arg2,&geometry,_exception); + offset.x=geometry.x; + offset.y=geometry.y; + source_image=_images; + if (source_image->next != (Image *) NULL) + source_image=source_image->next; + (void) ParsePageGeometry(source_image,arg1,&geometry,_exception); + (void) CopyImagePixels(_images,source_image,&geometry,&offset, + _exception); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'd': + { + if (LocaleCompare(""deconstruct"",option+1) == 0) + { + CLIWandWarnReplaced(""-layer CompareAny""); + (void) CLIListOperatorImages(cli_wand,""-layer"",""CompareAny"",NULL); + break; + } + if (LocaleCompare(""delete"",option+1) == 0) + { + if (IfNormalOp) + DeleteImages(&_images,arg1,_exception); + else + DeleteImages(&_images,""-1"",_exception); + break; + } + if (LocaleCompare(""duplicate"",option+1) == 0) + { + if (IfNormalOp) + { + const char + *p; + + size_t + number_duplicates; + + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option, + arg1); + number_duplicates=(size_t) StringToLong(arg1); + p=strchr(arg1,','); + if (p == (const char *) NULL) + new_images=DuplicateImages(_images,number_duplicates,""-1"", + _exception); + else + new_images=DuplicateImages(_images,number_duplicates,p, + _exception); + } + else + new_images=DuplicateImages(_images,1,""-1"",_exception); + AppendImageToList(&_images, new_images); + new_images=(Image *) NULL; + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'e': + { + if (LocaleCompare(""evaluate-sequence"",option+1) == 0) + { + parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1); + if (parse < 0) + CLIWandExceptArgBreak(OptionError,""UnrecognizedEvaluateOperator"", + option,arg1); + new_images=EvaluateImages(_images,(MagickEvaluateOperator) parse, + _exception); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'f': + { + if (LocaleCompare(""fft"",option+1) == 0) + { + new_images=ForwardFourierTransformImage(_images,IsNormalOp, + _exception); + break; + } + if (LocaleCompare(""flatten"",option+1) == 0) + { + /* REDIRECTED to use -layers flatten instead */ + (void) CLIListOperatorImages(cli_wand,""-layers"",option+1,NULL); + break; + } + if (LocaleCompare(""fx"",option+1) == 0) + { + new_images=FxImage(_images,arg1,_exception); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'h': + { + if (LocaleCompare(""hald-clut"",option+1) == 0) + { + /* FUTURE - make this a compose option (and thus layers compose ) + or perhaps compose last image over all other _images. + */ + Image + *hald_image; + + new_images=RemoveFirstImageFromList(&_images); + hald_image=RemoveLastImageFromList(&_images); + if (hald_image == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""ImageSequenceRequired"",""`%s'"",option); + new_images=DestroyImage(new_images); + status=MagickFalse; + break; + } + (void) HaldClutImage(new_images,hald_image,_exception); + hald_image=DestroyImage(hald_image); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'i': + { + if (LocaleCompare(""ift"",option+1) == 0) + { + Image + *magnitude_image, + *phase_image; + + magnitude_image=RemoveFirstImageFromList(&_images); + phase_image=RemoveFirstImageFromList(&_images); + if (phase_image == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""ImageSequenceRequired"",""`%s'"",option); + magnitude_image=DestroyImage(magnitude_image); + status=MagickFalse; + break; + } + new_images=InverseFourierTransformImage(magnitude_image,phase_image, + IsNormalOp,_exception); + magnitude_image=DestroyImage(magnitude_image); + phase_image=DestroyImage(phase_image); + break; + } + if (LocaleCompare(""insert"",option+1) == 0) + { + Image + *insert_image, + *index_image; + + ssize_t + index; + + if (IfNormalOp && (IsGeometry(arg1) == MagickFalse)) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + index=0; + insert_image=RemoveLastImageFromList(&_images); + if (IfNormalOp) + index=(ssize_t) StringToLong(arg1); + index_image=insert_image; + if (index == 0) + PrependImageToList(&_images,insert_image); + else if (index == (ssize_t) GetImageListLength(_images)) + AppendImageToList(&_images,insert_image); + else + { + index_image=GetImageFromList(_images,index-1); + if (index_image == (Image *) NULL) + { + insert_image=DestroyImage(insert_image); + CLIWandExceptArgBreak(OptionError,""NoSuchImage"",option,arg1); + } + InsertImageInList(&index_image,insert_image); + } + _images=GetFirstImageInList(index_image); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'l': + { + if (LocaleCompare(""layers"",option+1) == 0) + { + parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1); + if ( parse < 0 ) + CLIWandExceptArgBreak(OptionError,""UnrecognizedLayerMethod"", + option,arg1); + switch ((LayerMethod) parse) + { + case CoalesceLayer: + { + new_images=CoalesceImages(_images,_exception); + break; + } + case CompareAnyLayer: + case CompareClearLayer: + case CompareOverlayLayer: + default: + { + new_images=CompareImagesLayers(_images,(LayerMethod) parse, + _exception); + break; + } + case MergeLayer: + case FlattenLayer: + case MosaicLayer: + case TrimBoundsLayer: + { + new_images=MergeImageLayers(_images,(LayerMethod) parse, + _exception); + break; + } + case DisposeLayer: + { + new_images=DisposeImages(_images,_exception); + break; + } + case OptimizeImageLayer: + { + new_images=OptimizeImageLayers(_images,_exception); + break; + } + case OptimizePlusLayer: + { + new_images=OptimizePlusImageLayers(_images,_exception); + break; + } + case OptimizeTransLayer: + { + OptimizeImageTransparency(_images,_exception); + break; + } + case RemoveDupsLayer: + { + RemoveDuplicateLayers(&_images,_exception); + break; + } + case RemoveZeroLayer: + { + RemoveZeroDelayLayers(&_images,_exception); + break; + } + case OptimizeLayer: + { /* General Purpose, GIF Animation Optimizer. */ + new_images=CoalesceImages(_images,_exception); + if (new_images == (Image *) NULL) + break; + _images=DestroyImageList(_images); + _images=OptimizeImageLayers(new_images,_exception); + if (_images == (Image *) NULL) + break; + new_images=DestroyImageList(new_images); + OptimizeImageTransparency(_images,_exception); + (void) RemapImages(_quantize_info,_images,(Image *) NULL, + _exception); + break; + } + case CompositeLayer: + { + Image + *source; + + RectangleInfo + geometry; + + CompositeOperator + compose; + + const char* + value; + + value=GetImageOption(_image_info,""compose""); + compose=OverCompositeOp; /* Default to Over */ + if (value != (const char *) NULL) + compose=(CompositeOperator) ParseCommandOption( + MagickComposeOptions,MagickFalse,value); + + /* Split image sequence at the first 'NULL:' image. */ + source=_images; + while (source != (Image *) NULL) + { + source=GetNextImageInList(source); + if ((source != (Image *) NULL) && + (LocaleCompare(source->magick,""NULL"") == 0)) + break; + } + if (source != (Image *) NULL) + { + if ((GetPreviousImageInList(source) == (Image *) NULL) || + (GetNextImageInList(source) == (Image *) NULL)) + source=(Image *) NULL; + else + { /* Separate the two lists, junk the null: image. */ + source=SplitImageList(source->previous); + DeleteImageFromList(&source); + } + } + if (source == (Image *) NULL) + { + (void) ThrowMagickException(_exception,GetMagickModule(), + OptionError,""MissingNullSeparator"",""layers Composite""); + break; + } + /* Adjust offset with gravity and virtual canvas. */ + SetGeometry(_images,&geometry); + (void) ParseAbsoluteGeometry(_images->geometry,&geometry); + geometry.width=source->page.width != 0 ? + source->page.width : source->columns; + geometry.height=source->page.height != 0 ? + source->page.height : source->rows; + GravityAdjustGeometry(_images->page.width != 0 ? + _images->page.width : _images->columns, + _images->page.height != 0 ? _images->page.height : + _images->rows,_images->gravity,&geometry); + + /* Compose the two image sequences together */ + CompositeLayers(_images,compose,source,geometry.x,geometry.y, + _exception); + source=DestroyImageList(source); + break; + } + } + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'm': + { + if (LocaleCompare(""map"",option+1) == 0) + { + CLIWandWarnReplaced(""+remap""); + (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); + break; + } + if (LocaleCompare(""metric"",option+1) == 0) + { + (void) SetImageOption(_image_info,option+1,arg1); + break; + } + if (LocaleCompare(""morph"",option+1) == 0) + { + Image + *morph_image; + + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + morph_image=MorphImages(_images,StringToUnsignedLong(arg1), + _exception); + if (morph_image == (Image *) NULL) + break; + _images=DestroyImageList(_images); + _images=morph_image; + break; + } + if (LocaleCompare(""mosaic"",option+1) == 0) + { + /* REDIRECTED to use -layers mosaic instead */ + (void) CLIListOperatorImages(cli_wand,""-layers"",option+1,NULL); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'p': + { + if (LocaleCompare(""poly"",option+1) == 0) + { + double + *args; + + ssize_t + count; + + /* convert argument string into an array of doubles */ + args = StringToArrayOfDoubles(arg1,&count,_exception); + if (args == (double *) NULL ) + CLIWandExceptArgBreak(OptionError,""InvalidNumberList"",option,arg1); + new_images=PolynomialImage(_images,(size_t) (count >> 1),args, + _exception); + args=(double *) RelinquishMagickMemory(args); + break; + } + if (LocaleCompare(""process"",option+1) == 0) + { + /* FUTURE: better parsing using ScriptToken() from string ??? */ + char + **arguments; + + int + j, + number_arguments; + + arguments=StringToArgv(arg1,&number_arguments); + if (arguments == (char **) NULL) + break; + if (strchr(arguments[1],'=') != (char *) NULL) + { + char + breaker, + quote, + *token; + + const char + *arguments; + + int + next, + status; + + size_t + length; + + TokenInfo + *token_info; + + /* + Support old style syntax, filter=""-option arg1"". + */ + assert(arg1 != (const char *) NULL); + length=strlen(arg1); + token=(char *) NULL; + if (~length >= (MagickPathExtent-1)) + token=(char *) AcquireQuantumMemory(length+MagickPathExtent, + sizeof(*token)); + if (token == (char *) NULL) + break; + next=0; + arguments=arg1; + token_info=AcquireTokenInfo(); + status=Tokenizer(token_info,0,token,length,arguments,"""",""="", + ""\"""",'\0',&breaker,&next,"e); + token_info=DestroyTokenInfo(token_info); + if (status == 0) + { + const char + *argv; + + argv=(&(arguments[next])); + (void) InvokeDynamicImageFilter(token,&_images,1,&argv, + _exception); + } + token=DestroyString(token); + break; + } + (void) SubstituteString(&arguments[1],""-"",""""); + (void) InvokeDynamicImageFilter(arguments[1],&_images, + number_arguments-2,(const char **) arguments+2,_exception); + for (j=0; j < number_arguments; j++) + arguments[j]=DestroyString(arguments[j]); + arguments=(char **) RelinquishMagickMemory(arguments); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 'r': + { + if (LocaleCompare(""remap"",option+1) == 0) + { + (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception); + break; + } + if (LocaleCompare(""reverse"",option+1) == 0) + { + ReverseImageList(&_images); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + case 's': + { + if (LocaleCompare(""smush"",option+1) == 0) + { + /* FUTURE: this option needs more work to make better */ + ssize_t + offset; + + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + offset=(ssize_t) StringToLong(arg1); + new_images=SmushImages(_images,IsNormalOp,offset,_exception); + break; + } + if (LocaleCompare(""subimage"",option+1) == 0) + { + Image + *base_image, + *compare_image; + + const char + *value; + + MetricType + metric; + + double + similarity; + + RectangleInfo + offset; + + base_image=GetImageFromList(_images,0); + compare_image=GetImageFromList(_images,1); + + /* Comparision Metric */ + metric=UndefinedErrorMetric; + value=GetImageOption(_image_info,""metric""); + if (value != (const char *) NULL) + metric=(MetricType) ParseCommandOption(MagickMetricOptions, + MagickFalse,value); + + new_images=SimilarityImage(base_image,compare_image,metric,0.0, + &offset,&similarity,_exception); + + if (new_images != (Image *) NULL) + { + char + result[MagickPathExtent]; + + (void) FormatLocaleString(result,MagickPathExtent,""%lf"", + similarity); + (void) SetImageProperty(new_images,""subimage:similarity"",result, + _exception); + (void) FormatLocaleString(result,MagickPathExtent,""%+ld"",(long) + offset.x); + (void) SetImageProperty(new_images,""subimage:x"",result, + _exception); + (void) FormatLocaleString(result,MagickPathExtent,""%+ld"",(long) + offset.y); + (void) SetImageProperty(new_images,""subimage:y"",result, + _exception); + (void) FormatLocaleString(result,MagickPathExtent, + ""%lux%lu%+ld%+ld"",(unsigned long) offset.width,(unsigned long) + offset.height,(long) offset.x,(long) offset.y); + (void) SetImageProperty(new_images,""subimage:offset"",result, + _exception); + } + break; + } + if (LocaleCompare(""swap"",option+1) == 0) + { + Image + *p, + *q, + *swap; + + ssize_t + index, + swap_index; + + index=(-1); + swap_index=(-2); + if (IfNormalOp) { + GeometryInfo + geometry_info; + + MagickStatusType + flags; + + swap_index=(-1); + flags=ParseGeometry(arg1,&geometry_info); + if ((flags & RhoValue) == 0) + CLIWandExceptArgBreak(OptionError,""InvalidArgument"",option,arg1); + index=(ssize_t) geometry_info.rho; + if ((flags & SigmaValue) != 0) + swap_index=(ssize_t) geometry_info.sigma; + } + p=GetImageFromList(_images,index); + q=GetImageFromList(_images,swap_index); + if ((p == (Image *) NULL) || (q == (Image *) NULL)) { + if (IfNormalOp) + CLIWandExceptArgBreak(OptionError,""InvalidImageIndex"",option,arg1) + else + CLIWandExceptionBreak(OptionError,""TwoOrMoreImagesRequired"",option); + } + if (p == q) + CLIWandExceptArgBreak(OptionError,""InvalidImageIndex"",option,arg1); + swap=CloneImage(p,0,0,MagickTrue,_exception); + if (swap == (Image *) NULL) + CLIWandExceptArgBreak(ResourceLimitError,""MemoryAllocationFailed"", + option,GetExceptionMessage(errno)); + ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception)); + ReplaceImageInList(&q,swap); + _images=GetFirstImageInList(q); + break; + } + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + default: + CLIWandExceptionBreak(OptionError,""UnrecognizedOption"",option); + } + + /* clean up percent escape interpreted strings */ + if (arg1 != arg1n ) + arg1=DestroyString((char *)arg1); + if (arg2 != arg2n ) + arg2=DestroyString((char *)arg2); + + /* if new image list generated, replace existing image list */ + if (new_images == (Image *) NULL) + return(status == 0 ? MagickFalse : MagickTrue); + _images=DestroyImageList(_images); + _images=GetFirstImageInList(new_images); + return(status == 0 ? MagickFalse : MagickTrue); + +#undef _image_info +#undef _images +#undef _exception +#undef _draw_info +#undef _quantize_info +#undef IfNormalOp +#undef IfPlusOp +#undef IsNormalOp +} +","@@ -3821,10 +3821,16 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + _images. + */ + new_images=RemoveFirstImageFromList(&_images); +- clut_image=RemoveLastImageFromList(&_images); ++ clut_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (clut_image == (Image *) NULL) +- break; ++ { ++ (void) ThrowMagickException(_exception,GetMagickModule(), ++ OptionError,""ImageSequenceRequired"",""`%s'"",option); ++ new_images=DestroyImage(new_images); ++ status=MagickFalse; ++ break; ++ } + (void) ClutImage(new_images,clut_image,new_images->interpolate, + _exception); + clut_image=DestroyImage(clut_image); +@@ -3868,8 +3874,11 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + reconstruct_image=RemoveFirstImageFromList(&_images); + /* FUTURE - produce Exception, rather than silent fail */ + if (reconstruct_image == (Image *) NULL) +- { ++ { ++ (void) ThrowMagickException(_exception,GetMagickModule(), ++ OptionError,""ImageSequenceRequired"",""`%s'"",option); + image=DestroyImage(image); ++ status=MagickFalse; + break; + } + metric=UndefinedErrorMetric; +@@ -3931,7 +3940,13 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + new_images=RemoveFirstImageFromList(&_images); + source_image=RemoveFirstImageFromList(&_images); + if (source_image == (Image *) NULL) +- break; /* FUTURE - produce Exception, rather than silent fail */ ++ { ++ (void) ThrowMagickException(_exception,GetMagickModule(), ++ OptionError,""ImageSequenceRequired"",""`%s'"",option); ++ new_images=DestroyImage(new_images); ++ status=MagickFalse; ++ break; ++ } + + /* FUTURE - this should not be here! - should be part of -geometry */ + if (source_image->geometry != (char *) NULL) +@@ -4121,7 +4136,13 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + new_images=RemoveFirstImageFromList(&_images); + hald_image=RemoveLastImageFromList(&_images); + if (hald_image == (Image *) NULL) +- break; ++ { ++ (void) ThrowMagickException(_exception,GetMagickModule(), ++ OptionError,""ImageSequenceRequired"",""`%s'"",option); ++ new_images=DestroyImage(new_images); ++ status=MagickFalse; ++ break; ++ } + (void) HaldClutImage(new_images,hald_image,_exception); + hald_image=DestroyImage(hald_image); + break; +@@ -4136,15 +4157,20 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand, + *magnitude_image, + *phase_image; + +- magnitude_image=RemoveFirstImageFromList(&_images); +- phase_image=RemoveFirstImageFromList(&_images); +- /* FUTURE - produce Exception, rather than silent fail */ +- if (phase_image == (Image *) NULL) +- break; +- new_images=InverseFourierTransformImage(magnitude_image,phase_image, +- IsNormalOp,_exception); +- magnitude_image=DestroyImage(magnitude_image); +- phase_image=DestroyImage(phase_image); ++ magnitude_image=RemoveFirstImageFromList(&_images); ++ phase_image=RemoveFirstImageFromList(&_images); ++ if (phase_image == (Image *) NULL) ++ { ++ (void) ThrowMagickException(_exception,GetMagickModule(), ++ OptionError,""ImageSequenceRequired"",""`%s'"",option); ++ magnitude_image=DestroyImage(magnitude_image); ++ status=MagickFalse; ++ break; ++ } ++ new_images=InverseFourierTransformImage(magnitude_image,phase_image, ++ IsNormalOp,_exception); ++ magnitude_image=DestroyImage(magnitude_image); ++ phase_image=DestroyImage(phase_image); + break; + } + if (LocaleCompare(""insert"",option+1) == 0)",6694,6930,8192 +7749,"static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image) +{ + const char + *option; + + Image + *next_image; + + MagickBooleanType + status; + + volatile MagickBooleanType + logging; + + MngInfo + *mng_info; + + int + image_count, + need_iterations, + need_matte; + + volatile int +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + need_local_plte, +#endif + all_images_are_gray, + need_defi, + use_global_plte; + + register ssize_t + i; + + unsigned char + chunk[800]; + + volatile unsigned int + write_jng, + write_mng; + + volatile size_t + scene; + + size_t + final_delay=0, + initial_delay, + imageListLength; + +#if (PNG_LIBPNG_VER < 10200) + if (image_info->verbose) + printf(""Your PNG library (libpng-%s) is rather old.\n"", + PNG_LIBPNG_VER_STRING); +#endif + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + logging=LogMagickEvent(CoderEvent,GetMagickModule(),""Enter WriteMNGImage()""); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + + /* + Allocate a MngInfo structure. + */ + mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo)); + if (mng_info == (MngInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + /* + Initialize members of the MngInfo structure. + */ + (void) memset(mng_info,0,sizeof(MngInfo)); + mng_info->image=image; + write_mng=LocaleCompare(image_info->magick,""MNG"") == 0; + + /* + * See if user has requested a specific PNG subformat to be used + * for all of the PNGs in the MNG being written, e.g., + * + * convert *.png png8:animation.mng + * + * To do: check -define png:bit_depth and png:color_type as well, + * or perhaps use mng:bit_depth and mng:color_type instead for + * global settings. + */ + + mng_info->write_png8=LocaleCompare(image_info->magick,""PNG8"") == 0; + mng_info->write_png24=LocaleCompare(image_info->magick,""PNG24"") == 0; + mng_info->write_png32=LocaleCompare(image_info->magick,""PNG32"") == 0; + + write_jng=MagickFalse; + if (image_info->compression == JPEGCompression) + write_jng=MagickTrue; + + mng_info->adjoin=image_info->adjoin && + (GetNextImageInList(image) != (Image *) NULL) && write_mng; + + if (logging != MagickFalse) + { + /* Log some info about the input */ + Image + *p; + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Checking input image(s)\n"" + "" Image_info depth: %.20g, Type: %d"", + (double) image_info->depth, image_info->type); + + scene=0; + for (p=image; p != (Image *) NULL; p=GetNextImageInList(p)) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Scene: %.20g\n, Image depth: %.20g"", + (double) scene++, (double) p->depth); + + if (p->matte) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Matte: True""); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Matte: False""); + + if (p->storage_class == PseudoClass) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Storage class: PseudoClass""); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Storage class: DirectClass""); + + if (p->colors) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Number of colors: %.20g"",(double) p->colors); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Number of colors: unspecified""); + + if (mng_info->adjoin == MagickFalse) + break; + } + } + + use_global_plte=MagickFalse; + all_images_are_gray=MagickFalse; +#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED + need_local_plte=MagickTrue; +#endif + need_defi=MagickFalse; + need_matte=MagickFalse; + mng_info->framing_mode=1; + mng_info->old_framing_mode=1; + + if (write_mng) + if (image_info->page != (char *) NULL) + { + /* + Determine image bounding box. + */ + SetGeometry(image,&mng_info->page); + (void) ParseMetaGeometry(image_info->page,&mng_info->page.x, + &mng_info->page.y,&mng_info->page.width,&mng_info->page.height); + } + if (write_mng) + { + unsigned int + need_geom; + + unsigned short + red, + green, + blue; + + mng_info->page=image->page; + need_geom=MagickTrue; + if (mng_info->page.width || mng_info->page.height) + need_geom=MagickFalse; + /* + Check all the scenes. + */ + initial_delay=image->delay; + need_iterations=MagickFalse; + mng_info->equal_chrms=image->chromaticity.red_primary.x != 0.0; + mng_info->equal_physs=MagickTrue, + mng_info->equal_gammas=MagickTrue; + mng_info->equal_srgbs=MagickTrue; + mng_info->equal_backgrounds=MagickTrue; + image_count=0; +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + all_images_are_gray=MagickTrue; + mng_info->equal_palettes=MagickFalse; + need_local_plte=MagickFalse; +#endif + for (next_image=image; next_image != (Image *) NULL; ) + { + if (need_geom) + { + if ((next_image->columns+next_image->page.x) > mng_info->page.width) + mng_info->page.width=next_image->columns+next_image->page.x; + + if ((next_image->rows+next_image->page.y) > mng_info->page.height) + mng_info->page.height=next_image->rows+next_image->page.y; + } + + if (next_image->page.x || next_image->page.y) + need_defi=MagickTrue; + + if (next_image->matte) + need_matte=MagickTrue; + + if ((int) next_image->dispose >= BackgroundDispose) + if (next_image->matte || next_image->page.x || next_image->page.y || + ((next_image->columns < mng_info->page.width) && + (next_image->rows < mng_info->page.height))) + mng_info->need_fram=MagickTrue; + + if (next_image->iterations) + need_iterations=MagickTrue; + + final_delay=next_image->delay; + + if (final_delay != initial_delay || final_delay > 1UL* + next_image->ticks_per_second) + mng_info->need_fram=1; + +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + /* + check for global palette possibility. + */ + if (image->matte != MagickFalse) + need_local_plte=MagickTrue; + + if (need_local_plte == 0) + { + if (SetImageGray(image,&image->exception) == MagickFalse) + all_images_are_gray=MagickFalse; + mng_info->equal_palettes=PalettesAreEqual(image,next_image); + if (use_global_plte == 0) + use_global_plte=mng_info->equal_palettes; + need_local_plte=!mng_info->equal_palettes; + } +#endif + if (GetNextImageInList(next_image) != (Image *) NULL) + { + if (next_image->background_color.red != + next_image->next->background_color.red || + next_image->background_color.green != + next_image->next->background_color.green || + next_image->background_color.blue != + next_image->next->background_color.blue) + mng_info->equal_backgrounds=MagickFalse; + + if (next_image->gamma != next_image->next->gamma) + mng_info->equal_gammas=MagickFalse; + + if (next_image->rendering_intent != + next_image->next->rendering_intent) + mng_info->equal_srgbs=MagickFalse; + + if ((next_image->units != next_image->next->units) || + (next_image->x_resolution != next_image->next->x_resolution) || + (next_image->y_resolution != next_image->next->y_resolution)) + mng_info->equal_physs=MagickFalse; + + if (mng_info->equal_chrms) + { + if (next_image->chromaticity.red_primary.x != + next_image->next->chromaticity.red_primary.x || + next_image->chromaticity.red_primary.y != + next_image->next->chromaticity.red_primary.y || + next_image->chromaticity.green_primary.x != + next_image->next->chromaticity.green_primary.x || + next_image->chromaticity.green_primary.y != + next_image->next->chromaticity.green_primary.y || + next_image->chromaticity.blue_primary.x != + next_image->next->chromaticity.blue_primary.x || + next_image->chromaticity.blue_primary.y != + next_image->next->chromaticity.blue_primary.y || + next_image->chromaticity.white_point.x != + next_image->next->chromaticity.white_point.x || + next_image->chromaticity.white_point.y != + next_image->next->chromaticity.white_point.y) + mng_info->equal_chrms=MagickFalse; + } + } + image_count++; + next_image=GetNextImageInList(next_image); + } + if (image_count < 2) + { + mng_info->equal_backgrounds=MagickFalse; + mng_info->equal_chrms=MagickFalse; + mng_info->equal_gammas=MagickFalse; + mng_info->equal_srgbs=MagickFalse; + mng_info->equal_physs=MagickFalse; + use_global_plte=MagickFalse; +#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED + need_local_plte=MagickTrue; +#endif + need_iterations=MagickFalse; + } + + if (mng_info->need_fram == MagickFalse) + { + /* + Only certain framing rates 100/n are exactly representable without + the FRAM chunk but we'll allow some slop in VLC files + */ + if (final_delay == 0) + { + if (need_iterations != MagickFalse) + { + /* + It's probably a GIF with loop; don't run it *too* fast. + */ + if (mng_info->adjoin) + { + final_delay=10; + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""input has zero delay between all frames; assuming"", + "" 10 cs `%s'"",""""); + } + } + else + mng_info->ticks_per_second=0; + } + if (final_delay != 0) + mng_info->ticks_per_second=(png_uint_32) + (image->ticks_per_second/final_delay); + if (final_delay > 50) + mng_info->ticks_per_second=2; + + if (final_delay > 75) + mng_info->ticks_per_second=1; + + if (final_delay > 125) + mng_info->need_fram=MagickTrue; + + if (need_defi && final_delay > 2 && (final_delay != 4) && + (final_delay != 5) && (final_delay != 10) && (final_delay != 20) && + (final_delay != 25) && (final_delay != 50) && + (final_delay != (size_t) image->ticks_per_second)) + mng_info->need_fram=MagickTrue; /* make it exact; cannot be VLC */ + } + + if (mng_info->need_fram != MagickFalse) + mng_info->ticks_per_second=1UL*image->ticks_per_second; + /* + If pseudocolor, we should also check to see if all the + palettes are identical and write a global PLTE if they are. + ../glennrp Feb 99. + */ + /* + Write the MNG version 1.0 signature and MHDR chunk. + */ + (void) WriteBlob(image,8,(const unsigned char *) ""\212MNG\r\n\032\n""); + (void) WriteBlobMSBULong(image,28L); /* chunk data length=28 */ + PNGType(chunk,mng_MHDR); + LogPNGChunk(logging,mng_MHDR,28L); + PNGLong(chunk+4,(png_uint_32) mng_info->page.width); + PNGLong(chunk+8,(png_uint_32) mng_info->page.height); + PNGLong(chunk+12,mng_info->ticks_per_second); + PNGLong(chunk+16,0L); /* layer count=unknown */ + PNGLong(chunk+20,0L); /* frame count=unknown */ + PNGLong(chunk+24,0L); /* play time=unknown */ + if (write_jng) + { + if (need_matte) + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,27L); /* simplicity=LC+JNG */ + + else + PNGLong(chunk+28,25L); /* simplicity=VLC+JNG */ + } + + else + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,19L); /* simplicity=LC+JNG, no transparency */ + + else + PNGLong(chunk+28,17L); /* simplicity=VLC+JNG, no transparency */ + } + } + + else + { + if (need_matte) + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,11L); /* simplicity=LC */ + + else + PNGLong(chunk+28,9L); /* simplicity=VLC */ + } + + else + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,3L); /* simplicity=LC, no transparency */ + + else + PNGLong(chunk+28,1L); /* simplicity=VLC, no transparency */ + } + } + (void) WriteBlob(image,32,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,32)); + option=GetImageOption(image_info,""mng:need-cacheoff""); + if (option != (const char *) NULL) + { + size_t + length; + + /* + Write ""nEED CACHEOFF"" to turn playback caching off for streaming MNG. + */ + PNGType(chunk,mng_nEED); + length=CopyMagickString((char *) chunk+4,""CACHEOFF"",20); + (void) WriteBlobMSBULong(image,(size_t) length); + LogPNGChunk(logging,mng_nEED,(size_t) length); + length+=4; + (void) WriteBlob(image,length,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) length)); + } + if ((GetPreviousImageInList(image) == (Image *) NULL) && + (GetNextImageInList(image) != (Image *) NULL) && + (image->iterations != 1)) + { + /* + Write MNG TERM chunk + */ + (void) WriteBlobMSBULong(image,10L); /* data length=10 */ + PNGType(chunk,mng_TERM); + LogPNGChunk(logging,mng_TERM,10L); + chunk[4]=3; /* repeat animation */ + chunk[5]=0; /* show last frame when done */ + PNGLong(chunk+6,(png_uint_32) (mng_info->ticks_per_second* + final_delay/MagickMax(image->ticks_per_second,1))); + + if (image->iterations == 0) + PNGLong(chunk+10,PNG_UINT_31_MAX); + + else + PNGLong(chunk+10,(png_uint_32) image->iterations); + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" TERM delay: %.20g"",(double) (mng_info->ticks_per_second* + final_delay/MagickMax(image->ticks_per_second,1))); + + if (image->iterations == 0) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" TERM iterations: %.20g"",(double) PNG_UINT_31_MAX); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Image iterations: %.20g"",(double) image->iterations); + } + (void) WriteBlob(image,14,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,14)); + } + /* + To do: check for cHRM+gAMA == sRGB, and write sRGB instead. + */ + if ((image->colorspace == sRGBColorspace || image->rendering_intent) && + mng_info->equal_srgbs) + { + /* + Write MNG sRGB chunk + */ + (void) WriteBlobMSBULong(image,1L); + PNGType(chunk,mng_sRGB); + LogPNGChunk(logging,mng_sRGB,1L); + + if (image->rendering_intent != UndefinedIntent) + chunk[4]=(unsigned char) + Magick_RenderingIntent_to_PNG_RenderingIntent( + (image->rendering_intent)); + + else + chunk[4]=(unsigned char) + Magick_RenderingIntent_to_PNG_RenderingIntent( + (PerceptualIntent)); + + (void) WriteBlob(image,5,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,5)); + mng_info->have_write_global_srgb=MagickTrue; + } + + else + { + if (image->gamma && mng_info->equal_gammas) + { + /* + Write MNG gAMA chunk + */ + (void) WriteBlobMSBULong(image,4L); + PNGType(chunk,mng_gAMA); + LogPNGChunk(logging,mng_gAMA,4L); + PNGLong(chunk+4,(png_uint_32) (100000*image->gamma+0.5)); + (void) WriteBlob(image,8,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,8)); + mng_info->have_write_global_gama=MagickTrue; + } + if (mng_info->equal_chrms) + { + PrimaryInfo + primary; + + /* + Write MNG cHRM chunk + */ + (void) WriteBlobMSBULong(image,32L); + PNGType(chunk,mng_cHRM); + LogPNGChunk(logging,mng_cHRM,32L); + primary=image->chromaticity.white_point; + PNGLong(chunk+4,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+8,(png_uint_32) (100000*primary.y+0.5)); + primary=image->chromaticity.red_primary; + PNGLong(chunk+12,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+16,(png_uint_32) (100000*primary.y+0.5)); + primary=image->chromaticity.green_primary; + PNGLong(chunk+20,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+24,(png_uint_32) (100000*primary.y+0.5)); + primary=image->chromaticity.blue_primary; + PNGLong(chunk+28,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+32,(png_uint_32) (100000*primary.y+0.5)); + (void) WriteBlob(image,36,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,36)); + mng_info->have_write_global_chrm=MagickTrue; + } + } + if (image->x_resolution && image->y_resolution && mng_info->equal_physs) + { + /* + Write MNG pHYs chunk + */ + (void) WriteBlobMSBULong(image,9L); + PNGType(chunk,mng_pHYs); + LogPNGChunk(logging,mng_pHYs,9L); + + if (image->units == PixelsPerInchResolution) + { + PNGLong(chunk+4,(png_uint_32) + (image->x_resolution*100.0/2.54+0.5)); + + PNGLong(chunk+8,(png_uint_32) + (image->y_resolution*100.0/2.54+0.5)); + + chunk[12]=1; + } + + else + { + if (image->units == PixelsPerCentimeterResolution) + { + PNGLong(chunk+4,(png_uint_32) + (image->x_resolution*100.0+0.5)); + + PNGLong(chunk+8,(png_uint_32) + (image->y_resolution*100.0+0.5)); + + chunk[12]=1; + } + + else + { + PNGLong(chunk+4,(png_uint_32) (image->x_resolution+0.5)); + PNGLong(chunk+8,(png_uint_32) (image->y_resolution+0.5)); + chunk[12]=0; + } + } + (void) WriteBlob(image,13,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,13)); + } + /* + Write MNG BACK chunk and global bKGD chunk, if the image is transparent + or does not cover the entire frame. + */ + if (write_mng && (image->matte || image->page.x > 0 || + image->page.y > 0 || (image->page.width && + (image->page.width+image->page.x < mng_info->page.width)) + || (image->page.height && (image->page.height+image->page.y + < mng_info->page.height)))) + { + (void) WriteBlobMSBULong(image,6L); + PNGType(chunk,mng_BACK); + LogPNGChunk(logging,mng_BACK,6L); + red=ScaleQuantumToShort(image->background_color.red); + green=ScaleQuantumToShort(image->background_color.green); + blue=ScaleQuantumToShort(image->background_color.blue); + PNGShort(chunk+4,red); + PNGShort(chunk+6,green); + PNGShort(chunk+8,blue); + (void) WriteBlob(image,10,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,10)); + if (mng_info->equal_backgrounds) + { + (void) WriteBlobMSBULong(image,6L); + PNGType(chunk,mng_bKGD); + LogPNGChunk(logging,mng_bKGD,6L); + (void) WriteBlob(image,10,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,10)); + } + } + +#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED + if ((need_local_plte == MagickFalse) && + (image->storage_class == PseudoClass) && + (all_images_are_gray == MagickFalse)) + { + size_t + data_length; + + /* + Write MNG PLTE chunk + */ + data_length=3*image->colors; + (void) WriteBlobMSBULong(image,data_length); + PNGType(chunk,mng_PLTE); + LogPNGChunk(logging,mng_PLTE,data_length); + + for (i=0; i < (ssize_t) image->colors; i++) + { + chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red) & 0xff; + chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green) & 0xff; + chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue) & 0xff; + } + + (void) WriteBlob(image,data_length+4,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) (data_length+4))); + mng_info->have_write_global_plte=MagickTrue; + } +#endif + } + scene=0; + mng_info->delay=0; +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + mng_info->equal_palettes=MagickFalse; +#endif + imageListLength=GetImageListLength(image); + do + { + if (mng_info->adjoin) + { +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + /* + If we aren't using a global palette for the entire MNG, check to + see if we can use one for two or more consecutive images. + */ + if (need_local_plte && use_global_plte && !all_images_are_gray) + { + if (mng_info->IsPalette) + { + /* + When equal_palettes is true, this image has the same palette + as the previous PseudoClass image + */ + mng_info->have_write_global_plte=mng_info->equal_palettes; + mng_info->equal_palettes=PalettesAreEqual(image,image->next); + if (mng_info->equal_palettes && !mng_info->have_write_global_plte) + { + /* + Write MNG PLTE chunk + */ + size_t + data_length; + + data_length=3*image->colors; + (void) WriteBlobMSBULong(image,data_length); + PNGType(chunk,mng_PLTE); + LogPNGChunk(logging,mng_PLTE,data_length); + + for (i=0; i < (ssize_t) image->colors; i++) + { + chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red); + chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green); + chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue); + } + + (void) WriteBlob(image,data_length+4,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk, + (uInt) (data_length+4))); + mng_info->have_write_global_plte=MagickTrue; + } + } + else + mng_info->have_write_global_plte=MagickFalse; + } +#endif + if (need_defi) + { + ssize_t + previous_x, + previous_y; + + if (scene != 0) + { + previous_x=mng_info->page.x; + previous_y=mng_info->page.y; + } + else + { + previous_x=0; + previous_y=0; + } + mng_info->page=image->page; + if ((mng_info->page.x != previous_x) || + (mng_info->page.y != previous_y)) + { + (void) WriteBlobMSBULong(image,12L); /* data length=12 */ + PNGType(chunk,mng_DEFI); + LogPNGChunk(logging,mng_DEFI,12L); + chunk[4]=0; /* object 0 MSB */ + chunk[5]=0; /* object 0 LSB */ + chunk[6]=0; /* visible */ + chunk[7]=0; /* abstract */ + PNGLong(chunk+8,(png_uint_32) mng_info->page.x); + PNGLong(chunk+12,(png_uint_32) mng_info->page.y); + (void) WriteBlob(image,16,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,16)); + } + } + } + + mng_info->write_mng=write_mng; + + if ((int) image->dispose >= 3) + mng_info->framing_mode=3; + + if (mng_info->need_fram && mng_info->adjoin && + ((image->delay != mng_info->delay) || + (mng_info->framing_mode != mng_info->old_framing_mode))) + { + if (image->delay == mng_info->delay) + { + /* + Write a MNG FRAM chunk with the new framing mode. + */ + (void) WriteBlobMSBULong(image,1L); /* data length=1 */ + PNGType(chunk,mng_FRAM); + LogPNGChunk(logging,mng_FRAM,1L); + chunk[4]=(unsigned char) mng_info->framing_mode; + (void) WriteBlob(image,5,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,5)); + } + else + { + /* + Write a MNG FRAM chunk with the delay. + */ + (void) WriteBlobMSBULong(image,10L); /* data length=10 */ + PNGType(chunk,mng_FRAM); + LogPNGChunk(logging,mng_FRAM,10L); + chunk[4]=(unsigned char) mng_info->framing_mode; + chunk[5]=0; /* frame name separator (no name) */ + chunk[6]=2; /* flag for changing default delay */ + chunk[7]=0; /* flag for changing frame timeout */ + chunk[8]=0; /* flag for changing frame clipping */ + chunk[9]=0; /* flag for changing frame sync_id */ + PNGLong(chunk+10,(png_uint_32) + ((mng_info->ticks_per_second* + image->delay)/MagickMax(image->ticks_per_second,1))); + (void) WriteBlob(image,14,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,14)); + mng_info->delay=(png_uint_32) image->delay; + } + mng_info->old_framing_mode=mng_info->framing_mode; + } + +#if defined(JNG_SUPPORTED) + if (image_info->compression == JPEGCompression) + { + ImageInfo + *write_info; + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing JNG object.""); + /* To do: specify the desired alpha compression method. */ + write_info=CloneImageInfo(image_info); + write_info->compression=UndefinedCompression; + status=WriteOneJNGImage(mng_info,write_info,image); + write_info=DestroyImageInfo(write_info); + } + else +#endif + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing PNG object.""); + + mng_info->need_blob = MagickFalse; + mng_info->ping_preserve_colormap = MagickFalse; + + /* We don't want any ancillary chunks written */ + mng_info->ping_exclude_bKGD=MagickTrue; + mng_info->ping_exclude_caNv=MagickTrue; + mng_info->ping_exclude_cHRM=MagickTrue; + mng_info->ping_exclude_date=MagickTrue; + mng_info->ping_exclude_EXIF=MagickTrue; + mng_info->ping_exclude_eXIf=MagickTrue; + mng_info->ping_exclude_gAMA=MagickTrue; + mng_info->ping_exclude_iCCP=MagickTrue; + /* mng_info->ping_exclude_iTXt=MagickTrue; */ + mng_info->ping_exclude_oFFs=MagickTrue; + mng_info->ping_exclude_pHYs=MagickTrue; + mng_info->ping_exclude_sRGB=MagickTrue; + mng_info->ping_exclude_tEXt=MagickTrue; + mng_info->ping_exclude_tRNS=MagickTrue; + mng_info->ping_exclude_zCCP=MagickTrue; + mng_info->ping_exclude_zTXt=MagickTrue; + + status=WriteOnePNGImage(mng_info,image_info,image); + } + + if (status == MagickFalse) + { + mng_info=MngInfoFreeStruct(mng_info); + (void) CloseBlob(image); + return(MagickFalse); + } + (void) CatchImageException(image); + if (GetNextImageInList(image) == (Image *) NULL) + break; + image=SyncNextImageInList(image); + status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); + + if (status == MagickFalse) + break; + + } while (mng_info->adjoin); + + if (write_mng) + { + while (GetPreviousImageInList(image) != (Image *) NULL) + image=GetPreviousImageInList(image); + /* + Write the MEND chunk. + */ + (void) WriteBlobMSBULong(image,0x00000000L); + PNGType(chunk,mng_MEND); + LogPNGChunk(logging,mng_MEND,0L); + (void) WriteBlob(image,4,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,4)); + } + /* + Relinquish resources. + */ + (void) CloseBlob(image); + mng_info=MngInfoFreeStruct(mng_info); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""exit WriteMNGImage()""); + + return(MagickTrue); +} +",0,"static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image) +{ + const char + *option; + + Image + *next_image; + + MagickBooleanType + status; + + volatile MagickBooleanType + logging; + + MngInfo + *mng_info; + + int + image_count, + need_iterations, + need_matte; + + volatile int +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + need_local_plte, +#endif + all_images_are_gray, + need_defi, + use_global_plte; + + register ssize_t + i; + + unsigned char + chunk[800]; + + volatile unsigned int + write_jng, + write_mng; + + volatile size_t + scene; + + size_t + final_delay=0, + initial_delay, + imageListLength; + +#if (PNG_LIBPNG_VER < 10200) + if (image_info->verbose) + printf(""Your PNG library (libpng-%s) is rather old.\n"", + PNG_LIBPNG_VER_STRING); +#endif + + /* + Open image file. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"",image->filename); + logging=LogMagickEvent(CoderEvent,GetMagickModule(),""Enter WriteMNGImage()""); + status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); + if (status == MagickFalse) + return(status); + + /* + Allocate a MngInfo structure. + */ + mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo)); + if (mng_info == (MngInfo *) NULL) + ThrowWriterException(ResourceLimitError,""MemoryAllocationFailed""); + /* + Initialize members of the MngInfo structure. + */ + (void) memset(mng_info,0,sizeof(MngInfo)); + mng_info->image=image; + write_mng=LocaleCompare(image_info->magick,""MNG"") == 0; + + /* + * See if user has requested a specific PNG subformat to be used + * for all of the PNGs in the MNG being written, e.g., + * + * convert *.png png8:animation.mng + * + * To do: check -define png:bit_depth and png:color_type as well, + * or perhaps use mng:bit_depth and mng:color_type instead for + * global settings. + */ + + mng_info->write_png8=LocaleCompare(image_info->magick,""PNG8"") == 0; + mng_info->write_png24=LocaleCompare(image_info->magick,""PNG24"") == 0; + mng_info->write_png32=LocaleCompare(image_info->magick,""PNG32"") == 0; + + write_jng=MagickFalse; + if (image_info->compression == JPEGCompression) + write_jng=MagickTrue; + + mng_info->adjoin=image_info->adjoin && + (GetNextImageInList(image) != (Image *) NULL) && write_mng; + + if (logging != MagickFalse) + { + /* Log some info about the input */ + Image + *p; + + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Checking input image(s)\n"" + "" Image_info depth: %.20g, Type: %d"", + (double) image_info->depth, image_info->type); + + scene=0; + for (p=image; p != (Image *) NULL; p=GetNextImageInList(p)) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Scene: %.20g\n, Image depth: %.20g"", + (double) scene++, (double) p->depth); + + if (p->matte) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Matte: True""); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Matte: False""); + + if (p->storage_class == PseudoClass) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Storage class: PseudoClass""); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Storage class: DirectClass""); + + if (p->colors) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Number of colors: %.20g"",(double) p->colors); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Number of colors: unspecified""); + + if (mng_info->adjoin == MagickFalse) + break; + } + } + + use_global_plte=MagickFalse; + all_images_are_gray=MagickFalse; +#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED + need_local_plte=MagickTrue; +#endif + need_defi=MagickFalse; + need_matte=MagickFalse; + mng_info->framing_mode=1; + mng_info->old_framing_mode=1; + + if (write_mng) + if (image_info->page != (char *) NULL) + { + /* + Determine image bounding box. + */ + SetGeometry(image,&mng_info->page); + (void) ParseMetaGeometry(image_info->page,&mng_info->page.x, + &mng_info->page.y,&mng_info->page.width,&mng_info->page.height); + } + if (write_mng) + { + unsigned int + need_geom; + + unsigned short + red, + green, + blue; + + mng_info->page=image->page; + need_geom=MagickTrue; + if (mng_info->page.width || mng_info->page.height) + need_geom=MagickFalse; + /* + Check all the scenes. + */ + initial_delay=image->delay; + need_iterations=MagickFalse; + mng_info->equal_chrms=image->chromaticity.red_primary.x != 0.0; + mng_info->equal_physs=MagickTrue, + mng_info->equal_gammas=MagickTrue; + mng_info->equal_srgbs=MagickTrue; + mng_info->equal_backgrounds=MagickTrue; + image_count=0; +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + all_images_are_gray=MagickTrue; + mng_info->equal_palettes=MagickFalse; + need_local_plte=MagickFalse; +#endif + for (next_image=image; next_image != (Image *) NULL; ) + { + if (need_geom) + { + if ((next_image->columns+next_image->page.x) > mng_info->page.width) + mng_info->page.width=next_image->columns+next_image->page.x; + + if ((next_image->rows+next_image->page.y) > mng_info->page.height) + mng_info->page.height=next_image->rows+next_image->page.y; + } + + if (next_image->page.x || next_image->page.y) + need_defi=MagickTrue; + + if (next_image->matte) + need_matte=MagickTrue; + + if ((int) next_image->dispose >= BackgroundDispose) + if (next_image->matte || next_image->page.x || next_image->page.y || + ((next_image->columns < mng_info->page.width) && + (next_image->rows < mng_info->page.height))) + mng_info->need_fram=MagickTrue; + + if (next_image->iterations) + need_iterations=MagickTrue; + + final_delay=next_image->delay; + + if (final_delay != initial_delay || final_delay > 1UL* + next_image->ticks_per_second) + mng_info->need_fram=1; + +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + /* + check for global palette possibility. + */ + if (image->matte != MagickFalse) + need_local_plte=MagickTrue; + + if (need_local_plte == 0) + { + if (SetImageGray(image,&image->exception) == MagickFalse) + all_images_are_gray=MagickFalse; + mng_info->equal_palettes=PalettesAreEqual(image,next_image); + if (use_global_plte == 0) + use_global_plte=mng_info->equal_palettes; + need_local_plte=!mng_info->equal_palettes; + } +#endif + if (GetNextImageInList(next_image) != (Image *) NULL) + { + if (next_image->background_color.red != + next_image->next->background_color.red || + next_image->background_color.green != + next_image->next->background_color.green || + next_image->background_color.blue != + next_image->next->background_color.blue) + mng_info->equal_backgrounds=MagickFalse; + + if (next_image->gamma != next_image->next->gamma) + mng_info->equal_gammas=MagickFalse; + + if (next_image->rendering_intent != + next_image->next->rendering_intent) + mng_info->equal_srgbs=MagickFalse; + + if ((next_image->units != next_image->next->units) || + (next_image->x_resolution != next_image->next->x_resolution) || + (next_image->y_resolution != next_image->next->y_resolution)) + mng_info->equal_physs=MagickFalse; + + if (mng_info->equal_chrms) + { + if (next_image->chromaticity.red_primary.x != + next_image->next->chromaticity.red_primary.x || + next_image->chromaticity.red_primary.y != + next_image->next->chromaticity.red_primary.y || + next_image->chromaticity.green_primary.x != + next_image->next->chromaticity.green_primary.x || + next_image->chromaticity.green_primary.y != + next_image->next->chromaticity.green_primary.y || + next_image->chromaticity.blue_primary.x != + next_image->next->chromaticity.blue_primary.x || + next_image->chromaticity.blue_primary.y != + next_image->next->chromaticity.blue_primary.y || + next_image->chromaticity.white_point.x != + next_image->next->chromaticity.white_point.x || + next_image->chromaticity.white_point.y != + next_image->next->chromaticity.white_point.y) + mng_info->equal_chrms=MagickFalse; + } + } + image_count++; + next_image=GetNextImageInList(next_image); + } + if (image_count < 2) + { + mng_info->equal_backgrounds=MagickFalse; + mng_info->equal_chrms=MagickFalse; + mng_info->equal_gammas=MagickFalse; + mng_info->equal_srgbs=MagickFalse; + mng_info->equal_physs=MagickFalse; + use_global_plte=MagickFalse; +#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED + need_local_plte=MagickTrue; +#endif + need_iterations=MagickFalse; + } + + if (mng_info->need_fram == MagickFalse) + { + /* + Only certain framing rates 100/n are exactly representable without + the FRAM chunk but we'll allow some slop in VLC files + */ + if (final_delay == 0) + { + if (need_iterations != MagickFalse) + { + /* + It's probably a GIF with loop; don't run it *too* fast. + */ + if (mng_info->adjoin) + { + final_delay=10; + (void) ThrowMagickException(&image->exception, + GetMagickModule(),CoderWarning, + ""input has zero delay between all frames; assuming"", + "" 10 cs `%s'"",""""); + } + } + else + mng_info->ticks_per_second=0; + } + if (final_delay != 0) + mng_info->ticks_per_second=(png_uint_32) + (image->ticks_per_second/final_delay); + if (final_delay > 50) + mng_info->ticks_per_second=2; + + if (final_delay > 75) + mng_info->ticks_per_second=1; + + if (final_delay > 125) + mng_info->need_fram=MagickTrue; + + if (need_defi && final_delay > 2 && (final_delay != 4) && + (final_delay != 5) && (final_delay != 10) && (final_delay != 20) && + (final_delay != 25) && (final_delay != 50) && + (final_delay != (size_t) image->ticks_per_second)) + mng_info->need_fram=MagickTrue; /* make it exact; cannot be VLC */ + } + + if (mng_info->need_fram != MagickFalse) + mng_info->ticks_per_second=1UL*image->ticks_per_second; + /* + If pseudocolor, we should also check to see if all the + palettes are identical and write a global PLTE if they are. + ../glennrp Feb 99. + */ + /* + Write the MNG version 1.0 signature and MHDR chunk. + */ + (void) WriteBlob(image,8,(const unsigned char *) ""\212MNG\r\n\032\n""); + (void) WriteBlobMSBULong(image,28L); /* chunk data length=28 */ + PNGType(chunk,mng_MHDR); + LogPNGChunk(logging,mng_MHDR,28L); + PNGLong(chunk+4,(png_uint_32) mng_info->page.width); + PNGLong(chunk+8,(png_uint_32) mng_info->page.height); + PNGLong(chunk+12,mng_info->ticks_per_second); + PNGLong(chunk+16,0L); /* layer count=unknown */ + PNGLong(chunk+20,0L); /* frame count=unknown */ + PNGLong(chunk+24,0L); /* play time=unknown */ + if (write_jng) + { + if (need_matte) + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,27L); /* simplicity=LC+JNG */ + + else + PNGLong(chunk+28,25L); /* simplicity=VLC+JNG */ + } + + else + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,19L); /* simplicity=LC+JNG, no transparency */ + + else + PNGLong(chunk+28,17L); /* simplicity=VLC+JNG, no transparency */ + } + } + + else + { + if (need_matte) + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,11L); /* simplicity=LC */ + + else + PNGLong(chunk+28,9L); /* simplicity=VLC */ + } + + else + { + if (need_defi || mng_info->need_fram || use_global_plte) + PNGLong(chunk+28,3L); /* simplicity=LC, no transparency */ + + else + PNGLong(chunk+28,1L); /* simplicity=VLC, no transparency */ + } + } + (void) WriteBlob(image,32,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,32)); + option=GetImageOption(image_info,""mng:need-cacheoff""); + if (option != (const char *) NULL) + { + size_t + length; + + /* + Write ""nEED CACHEOFF"" to turn playback caching off for streaming MNG. + */ + PNGType(chunk,mng_nEED); + length=CopyMagickString((char *) chunk+4,""CACHEOFF"",20); + (void) WriteBlobMSBULong(image,(size_t) length); + LogPNGChunk(logging,mng_nEED,(size_t) length); + length+=4; + (void) WriteBlob(image,length,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) length)); + } + if ((GetPreviousImageInList(image) == (Image *) NULL) && + (GetNextImageInList(image) != (Image *) NULL) && + (image->iterations != 1)) + { + /* + Write MNG TERM chunk + */ + (void) WriteBlobMSBULong(image,10L); /* data length=10 */ + PNGType(chunk,mng_TERM); + LogPNGChunk(logging,mng_TERM,10L); + chunk[4]=3; /* repeat animation */ + chunk[5]=0; /* show last frame when done */ + PNGLong(chunk+6,(png_uint_32) (mng_info->ticks_per_second* + final_delay/MagickMax(image->ticks_per_second,1))); + + if (image->iterations == 0) + PNGLong(chunk+10,PNG_UINT_31_MAX); + + else + PNGLong(chunk+10,(png_uint_32) image->iterations); + + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" TERM delay: %.20g"",(double) (mng_info->ticks_per_second* + final_delay/MagickMax(image->ticks_per_second,1))); + + if (image->iterations == 0) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" TERM iterations: %.20g"",(double) PNG_UINT_31_MAX); + + else + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Image iterations: %.20g"",(double) image->iterations); + } + (void) WriteBlob(image,14,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,14)); + } + /* + To do: check for cHRM+gAMA == sRGB, and write sRGB instead. + */ + if ((image->colorspace == sRGBColorspace || image->rendering_intent) && + mng_info->equal_srgbs) + { + /* + Write MNG sRGB chunk + */ + (void) WriteBlobMSBULong(image,1L); + PNGType(chunk,mng_sRGB); + LogPNGChunk(logging,mng_sRGB,1L); + + if (image->rendering_intent != UndefinedIntent) + chunk[4]=(unsigned char) + Magick_RenderingIntent_to_PNG_RenderingIntent( + (image->rendering_intent)); + + else + chunk[4]=(unsigned char) + Magick_RenderingIntent_to_PNG_RenderingIntent( + (PerceptualIntent)); + + (void) WriteBlob(image,5,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,5)); + mng_info->have_write_global_srgb=MagickTrue; + } + + else + { + if (image->gamma && mng_info->equal_gammas) + { + /* + Write MNG gAMA chunk + */ + (void) WriteBlobMSBULong(image,4L); + PNGType(chunk,mng_gAMA); + LogPNGChunk(logging,mng_gAMA,4L); + PNGLong(chunk+4,(png_uint_32) (100000*image->gamma+0.5)); + (void) WriteBlob(image,8,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,8)); + mng_info->have_write_global_gama=MagickTrue; + } + if (mng_info->equal_chrms) + { + PrimaryInfo + primary; + + /* + Write MNG cHRM chunk + */ + (void) WriteBlobMSBULong(image,32L); + PNGType(chunk,mng_cHRM); + LogPNGChunk(logging,mng_cHRM,32L); + primary=image->chromaticity.white_point; + PNGLong(chunk+4,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+8,(png_uint_32) (100000*primary.y+0.5)); + primary=image->chromaticity.red_primary; + PNGLong(chunk+12,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+16,(png_uint_32) (100000*primary.y+0.5)); + primary=image->chromaticity.green_primary; + PNGLong(chunk+20,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+24,(png_uint_32) (100000*primary.y+0.5)); + primary=image->chromaticity.blue_primary; + PNGLong(chunk+28,(png_uint_32) (100000*primary.x+0.5)); + PNGLong(chunk+32,(png_uint_32) (100000*primary.y+0.5)); + (void) WriteBlob(image,36,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,36)); + mng_info->have_write_global_chrm=MagickTrue; + } + } + if (image->x_resolution && image->y_resolution && mng_info->equal_physs) + { + /* + Write MNG pHYs chunk + */ + (void) WriteBlobMSBULong(image,9L); + PNGType(chunk,mng_pHYs); + LogPNGChunk(logging,mng_pHYs,9L); + + if (image->units == PixelsPerInchResolution) + { + PNGLong(chunk+4,(png_uint_32) + (image->x_resolution*100.0/2.54+0.5)); + + PNGLong(chunk+8,(png_uint_32) + (image->y_resolution*100.0/2.54+0.5)); + + chunk[12]=1; + } + + else + { + if (image->units == PixelsPerCentimeterResolution) + { + PNGLong(chunk+4,(png_uint_32) + (image->x_resolution*100.0+0.5)); + + PNGLong(chunk+8,(png_uint_32) + (image->y_resolution*100.0+0.5)); + + chunk[12]=1; + } + + else + { + PNGLong(chunk+4,(png_uint_32) (image->x_resolution+0.5)); + PNGLong(chunk+8,(png_uint_32) (image->y_resolution+0.5)); + chunk[12]=0; + } + } + (void) WriteBlob(image,13,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,13)); + } + /* + Write MNG BACK chunk and global bKGD chunk, if the image is transparent + or does not cover the entire frame. + */ + if (write_mng && (image->matte || image->page.x > 0 || + image->page.y > 0 || (image->page.width && + (image->page.width+image->page.x < mng_info->page.width)) + || (image->page.height && (image->page.height+image->page.y + < mng_info->page.height)))) + { + (void) WriteBlobMSBULong(image,6L); + PNGType(chunk,mng_BACK); + LogPNGChunk(logging,mng_BACK,6L); + red=ScaleQuantumToShort(image->background_color.red); + green=ScaleQuantumToShort(image->background_color.green); + blue=ScaleQuantumToShort(image->background_color.blue); + PNGShort(chunk+4,red); + PNGShort(chunk+6,green); + PNGShort(chunk+8,blue); + (void) WriteBlob(image,10,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,10)); + if (mng_info->equal_backgrounds) + { + (void) WriteBlobMSBULong(image,6L); + PNGType(chunk,mng_bKGD); + LogPNGChunk(logging,mng_bKGD,6L); + (void) WriteBlob(image,10,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,10)); + } + } + +#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED + if ((need_local_plte == MagickFalse) && + (image->storage_class == PseudoClass) && + (all_images_are_gray == MagickFalse)) + { + size_t + data_length; + + /* + Write MNG PLTE chunk + */ + data_length=3*image->colors; + (void) WriteBlobMSBULong(image,data_length); + PNGType(chunk,mng_PLTE); + LogPNGChunk(logging,mng_PLTE,data_length); + + for (i=0; i < (ssize_t) image->colors; i++) + { + chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red) & 0xff; + chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green) & 0xff; + chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue) & 0xff; + } + + (void) WriteBlob(image,data_length+4,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) (data_length+4))); + mng_info->have_write_global_plte=MagickTrue; + } +#endif + } + scene=0; + mng_info->delay=0; +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + mng_info->equal_palettes=MagickFalse; +#endif + imageListLength=GetImageListLength(image); + do + { + if (mng_info->adjoin) + { +#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_MNG_FEATURES_SUPPORTED) + /* + If we aren't using a global palette for the entire MNG, check to + see if we can use one for two or more consecutive images. + */ + if (need_local_plte && use_global_plte && !all_images_are_gray) + { + if (mng_info->IsPalette) + { + /* + When equal_palettes is true, this image has the same palette + as the previous PseudoClass image + */ + mng_info->have_write_global_plte=mng_info->equal_palettes; + mng_info->equal_palettes=PalettesAreEqual(image,image->next); + if (mng_info->equal_palettes && !mng_info->have_write_global_plte) + { + /* + Write MNG PLTE chunk + */ + size_t + data_length; + + data_length=3*image->colors; + (void) WriteBlobMSBULong(image,data_length); + PNGType(chunk,mng_PLTE); + LogPNGChunk(logging,mng_PLTE,data_length); + + for (i=0; i < (ssize_t) image->colors; i++) + { + chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red); + chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green); + chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue); + } + + (void) WriteBlob(image,data_length+4,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk, + (uInt) (data_length+4))); + mng_info->have_write_global_plte=MagickTrue; + } + } + else + mng_info->have_write_global_plte=MagickFalse; + } +#endif + if (need_defi) + { + ssize_t + previous_x, + previous_y; + + if (scene != 0) + { + previous_x=mng_info->page.x; + previous_y=mng_info->page.y; + } + else + { + previous_x=0; + previous_y=0; + } + mng_info->page=image->page; + if ((mng_info->page.x != previous_x) || + (mng_info->page.y != previous_y)) + { + (void) WriteBlobMSBULong(image,12L); /* data length=12 */ + PNGType(chunk,mng_DEFI); + LogPNGChunk(logging,mng_DEFI,12L); + chunk[4]=0; /* object 0 MSB */ + chunk[5]=0; /* object 0 LSB */ + chunk[6]=0; /* visible */ + chunk[7]=0; /* abstract */ + PNGLong(chunk+8,(png_uint_32) mng_info->page.x); + PNGLong(chunk+12,(png_uint_32) mng_info->page.y); + (void) WriteBlob(image,16,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,16)); + } + } + } + + mng_info->write_mng=write_mng; + + if ((int) image->dispose >= 3) + mng_info->framing_mode=3; + + if (mng_info->need_fram && mng_info->adjoin && + ((image->delay != mng_info->delay) || + (mng_info->framing_mode != mng_info->old_framing_mode))) + { + if (image->delay == mng_info->delay) + { + /* + Write a MNG FRAM chunk with the new framing mode. + */ + (void) WriteBlobMSBULong(image,1L); /* data length=1 */ + PNGType(chunk,mng_FRAM); + LogPNGChunk(logging,mng_FRAM,1L); + chunk[4]=(unsigned char) mng_info->framing_mode; + (void) WriteBlob(image,5,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,5)); + } + else + { + /* + Write a MNG FRAM chunk with the delay. + */ + (void) WriteBlobMSBULong(image,10L); /* data length=10 */ + PNGType(chunk,mng_FRAM); + LogPNGChunk(logging,mng_FRAM,10L); + chunk[4]=(unsigned char) mng_info->framing_mode; + chunk[5]=0; /* frame name separator (no name) */ + chunk[6]=2; /* flag for changing default delay */ + chunk[7]=0; /* flag for changing frame timeout */ + chunk[8]=0; /* flag for changing frame clipping */ + chunk[9]=0; /* flag for changing frame sync_id */ + PNGLong(chunk+10,(png_uint_32) + ((mng_info->ticks_per_second* + image->delay)/MagickMax(image->ticks_per_second,1))); + (void) WriteBlob(image,14,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,14)); + mng_info->delay=(png_uint_32) image->delay; + } + mng_info->old_framing_mode=mng_info->framing_mode; + } + +#if defined(JNG_SUPPORTED) + if (image_info->compression == JPEGCompression) + { + ImageInfo + *write_info; + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing JNG object.""); + /* To do: specify the desired alpha compression method. */ + write_info=CloneImageInfo(image_info); + write_info->compression=UndefinedCompression; + status=WriteOneJNGImage(mng_info,write_info,image); + write_info=DestroyImageInfo(write_info); + } + else +#endif + { + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Writing PNG object.""); + + mng_info->need_blob = MagickFalse; + mng_info->ping_preserve_colormap = MagickFalse; + + /* We don't want any ancillary chunks written */ + mng_info->ping_exclude_bKGD=MagickTrue; + mng_info->ping_exclude_caNv=MagickTrue; + mng_info->ping_exclude_cHRM=MagickTrue; + mng_info->ping_exclude_date=MagickTrue; + mng_info->ping_exclude_EXIF=MagickTrue; + mng_info->ping_exclude_eXIf=MagickTrue; + mng_info->ping_exclude_gAMA=MagickTrue; + mng_info->ping_exclude_iCCP=MagickTrue; + /* mng_info->ping_exclude_iTXt=MagickTrue; */ + mng_info->ping_exclude_oFFs=MagickTrue; + mng_info->ping_exclude_pHYs=MagickTrue; + mng_info->ping_exclude_sRGB=MagickTrue; + mng_info->ping_exclude_tEXt=MagickTrue; + mng_info->ping_exclude_tRNS=MagickTrue; + mng_info->ping_exclude_zCCP=MagickTrue; + mng_info->ping_exclude_zTXt=MagickTrue; + + status=WriteOnePNGImage(mng_info,image_info,image); + } + + if (status == MagickFalse) + { + mng_info=MngInfoFreeStruct(mng_info); + (void) CloseBlob(image); + return(MagickFalse); + } + (void) CatchImageException(image); + if (GetNextImageInList(image) == (Image *) NULL) + break; + image=SyncNextImageInList(image); + status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); + + if (status == MagickFalse) + break; + + } while (mng_info->adjoin); + + if (write_mng) + { + while (GetPreviousImageInList(image) != (Image *) NULL) + image=GetPreviousImageInList(image); + /* + Write the MEND chunk. + */ + (void) WriteBlobMSBULong(image,0x00000000L); + PNGType(chunk,mng_MEND); + LogPNGChunk(logging,mng_MEND,0L); + (void) WriteBlob(image,4,chunk); + (void) WriteBlobMSBULong(image,crc32(0,chunk,4)); + } + /* + Relinquish resources. + */ + (void) CloseBlob(image); + mng_info=MngInfoFreeStruct(mng_info); + + if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""exit WriteMNGImage()""); + + return(MagickTrue); +} +","@@ -4584,7 +4584,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info, + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "" Copying JDAT chunk data to color_blob.""); + +- if (length != 0) ++ if ((length != 0) && (color_image != (Image *) NULL)) + { + (void) WriteBlob(color_image,length,chunk); + chunk=(unsigned char *) RelinquishMagickMemory(chunk);",7948,8184,8192 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.pkl new file mode 100644 index 0000000000000000000000000000000000000000..34ecfeaf833fcbedf2b5727ffdafe9ad2244a778 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e9e5230bfd33be0e75e67a8bf42f3609680d0647c3dd6c55bc95af482db39b5 +size 505355 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.csv new file mode 100644 index 0000000000000000000000000000000000000000..d4326957d84450fa39e34585e319d512d274890b --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.csv @@ -0,0 +1,14008 @@ +idx,func_before,vul,func_after,patch,code_token_length,total_token_length,max_tokens_setting +18105,"isis_print(netdissect_options *ndo, + const uint8_t *p, u_int length) +{ + const struct isis_common_header *isis_header; + + const struct isis_iih_lan_header *header_iih_lan; + const struct isis_iih_ptp_header *header_iih_ptp; + const struct isis_lsp_header *header_lsp; + const struct isis_csnp_header *header_csnp; + const struct isis_psnp_header *header_psnp; + + const struct isis_tlv_lsp *tlv_lsp; + const struct isis_tlv_ptp_adj *tlv_ptp_adj; + const struct isis_tlv_is_reach *tlv_is_reach; + const struct isis_tlv_es_reach *tlv_es_reach; + + uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len; + uint8_t ext_is_len, ext_ip_len, mt_len; + const uint8_t *optr, *pptr, *tptr; + u_short packet_len,pdu_len, key_id; + u_int i,vendor_id; + int sigcheck; + + packet_len=length; + optr = p; /* initialize the _o_riginal pointer to the packet start - + need it for parsing the checksum TLV and authentication + TLV verification */ + isis_header = (const struct isis_common_header *)p; + ND_TCHECK(*isis_header); + if (length < ISIS_COMMON_HEADER_SIZE) + goto trunc; + pptr = p+(ISIS_COMMON_HEADER_SIZE); + header_iih_lan = (const struct isis_iih_lan_header *)pptr; + header_iih_ptp = (const struct isis_iih_ptp_header *)pptr; + header_lsp = (const struct isis_lsp_header *)pptr; + header_csnp = (const struct isis_csnp_header *)pptr; + header_psnp = (const struct isis_psnp_header *)pptr; + + if (!ndo->ndo_eflag) + ND_PRINT((ndo, ""IS-IS"")); + + /* + * Sanity checking of the header. + */ + + if (isis_header->version != ISIS_VERSION) { + ND_PRINT((ndo, ""version %d packet not supported"", isis_header->version)); + return (0); + } + + if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) { + ND_PRINT((ndo, ""system ID length of %d is not supported"", + isis_header->id_length)); + return (0); + } + + if (isis_header->pdu_version != ISIS_VERSION) { + ND_PRINT((ndo, ""version %d packet not supported"", isis_header->pdu_version)); + return (0); + } + + if (length < isis_header->fixed_len) { + ND_PRINT((ndo, ""fixed header length %u > packet length %u"", isis_header->fixed_len, length)); + return (0); + } + + if (isis_header->fixed_len < ISIS_COMMON_HEADER_SIZE) { + ND_PRINT((ndo, ""fixed header length %u < minimum header size %u"", isis_header->fixed_len, (u_int)ISIS_COMMON_HEADER_SIZE)); + return (0); + } + + max_area = isis_header->max_area; + switch(max_area) { + case 0: + max_area = 3; /* silly shit */ + break; + case 255: + ND_PRINT((ndo, ""bad packet -- 255 areas"")); + return (0); + default: + break; + } + + id_length = isis_header->id_length; + switch(id_length) { + case 0: + id_length = 6; /* silly shit again */ + break; + case 1: /* 1-8 are valid sys-ID lenghts */ + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + break; + case 255: + id_length = 0; /* entirely useless */ + break; + default: + break; + } + + /* toss any non 6-byte sys-ID len PDUs */ + if (id_length != 6 ) { + ND_PRINT((ndo, ""bad packet -- illegal sys-ID length (%u)"", id_length)); + return (0); + } + + pdu_type=isis_header->pdu_type; + + /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/ + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, ""%s%s"", + ndo->ndo_eflag ? """" : "", "", + tok2str(isis_pdu_values, ""unknown PDU-Type %u"", pdu_type))); + } else { + /* ok they seem to want to know everything - lets fully decode it */ + ND_PRINT((ndo, ""%slength %u"", ndo->ndo_eflag ? """" : "", "", length)); + + ND_PRINT((ndo, ""\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)"", + tok2str(isis_pdu_values, + ""unknown, type %u"", + pdu_type), + isis_header->fixed_len, + isis_header->version, + isis_header->pdu_version, + id_length, + isis_header->id_length, + max_area, + isis_header->max_area)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, optr, ""\n\t"", 8)) /* provide the _o_riginal pointer */ + return (0); /* for optionally debugging the common header */ + } + } + + switch (pdu_type) { + + case ISIS_PDU_L1_LAN_IIH: + case ISIS_PDU_L2_LAN_IIH: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_iih_lan); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", + isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN))); + ND_PRINT((ndo, "", lan-id %s, prio %u"", + isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN), + header_iih_lan->priority)); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, holding time: %us, Flags: [%s]"", + isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN), + EXTRACT_16BITS(header_iih_lan->holding_time), + tok2str(isis_iih_circuit_type_values, + ""unknown circuit type 0x%02x"", + header_iih_lan->circuit_type))); + + ND_PRINT((ndo, ""\n\t lan-id: %s, Priority: %u, PDU length: %u"", + isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN), + (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK, + pdu_len)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_IIH_LAN_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); + break; + + case ISIS_PDU_PTP_IIH: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_iih_ptp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, holding time: %us, Flags: [%s]"", + isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN), + EXTRACT_16BITS(header_iih_ptp->holding_time), + tok2str(isis_iih_circuit_type_values, + ""unknown circuit type 0x%02x"", + header_iih_ptp->circuit_type))); + + ND_PRINT((ndo, ""\n\t circuit-id: 0x%02x, PDU length: %u"", + header_iih_ptp->circuit_id, + pdu_len)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_IIH_PTP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_LSP: + case ISIS_PDU_L2_LSP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE)); + return (0); + } + ND_TCHECK(*header_lsp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", lsp-id %s, seq 0x%08x, lifetime %5us"", + isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), + EXTRACT_32BITS(header_lsp->sequence_number), + EXTRACT_16BITS(header_lsp->remaining_lifetime))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_lsp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x"", + isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), + EXTRACT_32BITS(header_lsp->sequence_number), + EXTRACT_16BITS(header_lsp->remaining_lifetime), + EXTRACT_16BITS(header_lsp->checksum))); + + osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id, + EXTRACT_16BITS(header_lsp->checksum), + 12, length-12); + + ND_PRINT((ndo, "", PDU length: %u, Flags: [ %s"", + pdu_len, + ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? ""Overload bit set, "" : """")); + + if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? ""default "" : """")); + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? ""delay "" : """")); + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? ""expense "" : """")); + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? ""error "" : """")); + ND_PRINT((ndo, ""ATT bit set, "")); + } + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? ""P bit set, "" : """")); + ND_PRINT((ndo, ""%s ]"", tok2str(isis_lsp_istype_values, ""Unknown(0x%x)"", + ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)))); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_LSP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_CSNP: + case ISIS_PDU_L2_CSNP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_csnp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", isis_print_id(header_csnp->source_id, NODE_ID_LEN))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_csnp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, PDU length: %u"", + isis_print_id(header_csnp->source_id, NODE_ID_LEN), + pdu_len)); + ND_PRINT((ndo, ""\n\t start lsp-id: %s"", + isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN))); + ND_PRINT((ndo, ""\n\t end lsp-id: %s"", + isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN))); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_CSNP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_PSNP: + case ISIS_PDU_L2_PSNP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) { + ND_PRINT((ndo, ""- bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_psnp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", isis_print_id(header_psnp->source_id, NODE_ID_LEN))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_psnp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, PDU length: %u"", + isis_print_id(header_psnp->source_id, NODE_ID_LEN), + pdu_len)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_PSNP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); + break; + + default: + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + (void)print_unknown_data(ndo, pptr, ""\n\t "", length); + return (0); + } + + /* + * Now print the TLV's. + */ + + while (packet_len > 0) { + ND_TCHECK2(*pptr, 2); + if (packet_len < 2) + goto trunc; + tlv_type = *pptr++; + tlv_len = *pptr++; + tmp =tlv_len; /* copy temporary len & pointer to packet data */ + tptr = pptr; + packet_len -= 2; + + /* first lets see if we know the TLVs name*/ + ND_PRINT((ndo, ""\n\t %s TLV #%u, length: %u"", + tok2str(isis_tlv_values, + ""unknown"", + tlv_type), + tlv_type, + tlv_len)); + + if (tlv_len == 0) /* something is invalid */ + continue; + + if (packet_len < tlv_len) + goto trunc; + + /* now check if we have a decoder otherwise do a hexdump at the end*/ + switch (tlv_type) { + case ISIS_TLV_AREA_ADDR: + ND_TCHECK2(*tptr, 1); + alen = *tptr++; + while (tmp && alen < tmp) { + ND_PRINT((ndo, ""\n\t Area address (length: %u): %s"", + alen, + isonsap_string(ndo, tptr, alen))); + tptr += alen; + tmp -= alen + 1; + if (tmp==0) /* if this is the last area address do not attemt a boundary check */ + break; + ND_TCHECK2(*tptr, 1); + alen = *tptr++; + } + break; + case ISIS_TLV_ISNEIGH: + while (tmp >= ETHER_ADDR_LEN) { + ND_TCHECK2(*tptr, ETHER_ADDR_LEN); + ND_PRINT((ndo, ""\n\t SNPA: %s"", isis_print_id(tptr, ETHER_ADDR_LEN))); + tmp -= ETHER_ADDR_LEN; + tptr += ETHER_ADDR_LEN; + } + break; + + case ISIS_TLV_ISNEIGH_VARLEN: + if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */ + goto trunctlv; + lan_alen = *tptr++; /* LAN address length */ + if (lan_alen == 0) { + ND_PRINT((ndo, ""\n\t LAN address length 0 bytes (invalid)"")); + break; + } + tmp --; + ND_PRINT((ndo, ""\n\t LAN address length %u bytes "", lan_alen)); + while (tmp >= lan_alen) { + ND_TCHECK2(*tptr, lan_alen); + ND_PRINT((ndo, ""\n\t\tIS Neighbor: %s"", isis_print_id(tptr, lan_alen))); + tmp -= lan_alen; + tptr +=lan_alen; + } + break; + + case ISIS_TLV_PADDING: + break; + + case ISIS_TLV_MT_IS_REACH: + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + while (tmp >= 2+NODE_ID_LEN+3+1) { + ext_is_len = isis_print_ext_is_reach(ndo, tptr, ""\n\t "", tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + + case ISIS_TLV_IS_ALIAS_ID: + while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */ + ext_is_len = isis_print_ext_is_reach(ndo, tptr, ""\n\t "", tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + + case ISIS_TLV_EXT_IS_REACH: + while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */ + ext_is_len = isis_print_ext_is_reach(ndo, tptr, ""\n\t "", tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + case ISIS_TLV_IS_REACH: + ND_TCHECK2(*tptr,1); /* check if there is one byte left to read out the virtual flag */ + ND_PRINT((ndo, ""\n\t %s"", + tok2str(isis_is_reach_virtual_values, + ""bogus virtual flag 0x%02x"", + *tptr++))); + tlv_is_reach = (const struct isis_tlv_is_reach *)tptr; + while (tmp >= sizeof(struct isis_tlv_is_reach)) { + ND_TCHECK(*tlv_is_reach); + ND_PRINT((ndo, ""\n\t IS Neighbor: %s"", + isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN))); + isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block); + tmp -= sizeof(struct isis_tlv_is_reach); + tlv_is_reach++; + } + break; + + case ISIS_TLV_ESNEIGH: + tlv_es_reach = (const struct isis_tlv_es_reach *)tptr; + while (tmp >= sizeof(struct isis_tlv_es_reach)) { + ND_TCHECK(*tlv_es_reach); + ND_PRINT((ndo, ""\n\t ES Neighbor: %s"", + isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN))); + isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block); + tmp -= sizeof(struct isis_tlv_es_reach); + tlv_es_reach++; + } + break; + + /* those two TLVs share the same format */ + case ISIS_TLV_INT_IP_REACH: + case ISIS_TLV_EXT_IP_REACH: + if (!isis_print_tlv_ip_reach(ndo, pptr, ""\n\t "", tlv_len)) + return (1); + break; + + case ISIS_TLV_EXTD_IP_REACH: + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_MT_IP_REACH: + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) { /* did something go wrong ? */ + goto trunctlv; + } + tptr+=mt_len; + tmp-=mt_len; + + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_IP6_REACH: + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET6); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_MT_IP6_REACH: + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) { /* did something go wrong ? */ + goto trunctlv; + } + tptr+=mt_len; + tmp-=mt_len; + + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET6); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_IP6ADDR: + while (tmp>=sizeof(struct in6_addr)) { + ND_TCHECK2(*tptr, sizeof(struct in6_addr)); + + ND_PRINT((ndo, ""\n\t IPv6 interface address: %s"", + ip6addr_string(ndo, tptr))); + + tptr += sizeof(struct in6_addr); + tmp -= sizeof(struct in6_addr); + } + break; + case ISIS_TLV_AUTH: + ND_TCHECK2(*tptr, 1); + + ND_PRINT((ndo, ""\n\t %s: "", + tok2str(isis_subtlv_auth_values, + ""unknown Authentication type 0x%02x"", + *tptr))); + + switch (*tptr) { + case ISIS_SUBTLV_AUTH_SIMPLE: + if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend)) + goto trunctlv; + break; + case ISIS_SUBTLV_AUTH_MD5: + for(i=1;i=1) { + ND_TCHECK2(*tptr, 1); + ND_PRINT((ndo, ""\n\t Adjacency State: %s (%u)"", + tok2str(isis_ptp_adjancey_values, ""unknown"", *tptr), + *tptr)); + tmp--; + } + if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) { + ND_TCHECK(tlv_ptp_adj->extd_local_circuit_id); + ND_PRINT((ndo, ""\n\t Extended Local circuit-ID: 0x%08x"", + EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id))); + tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id); + } + if(tmp>=SYSTEM_ID_LEN) { + ND_TCHECK2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN); + ND_PRINT((ndo, ""\n\t Neighbor System-ID: %s"", + isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))); + tmp-=SYSTEM_ID_LEN; + } + if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) { + ND_TCHECK(tlv_ptp_adj->neighbor_extd_local_circuit_id); + ND_PRINT((ndo, ""\n\t Neighbor Extended Local circuit-ID: 0x%08x"", + EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id))); + } + break; + + case ISIS_TLV_PROTOCOLS: + ND_PRINT((ndo, ""\n\t NLPID(s): "")); + while (tmp>0) { + ND_TCHECK2(*(tptr), 1); + ND_PRINT((ndo, ""%s (0x%02x)"", + tok2str(nlpid_values, + ""unknown"", + *tptr), + *tptr)); + if (tmp>1) /* further NPLIDs ? - put comma */ + ND_PRINT((ndo, "", "")); + tptr++; + tmp--; + } + break; + + case ISIS_TLV_MT_PORT_CAP: + { + ND_TCHECK2(*(tptr), 2); + + ND_PRINT((ndo, ""\n\t RES: %d, MTID(s): %d"", + (EXTRACT_16BITS (tptr) >> 12), + (EXTRACT_16BITS (tptr) & 0x0fff))); + + tmp = tmp-2; + tptr = tptr+2; + + if (tmp) + isis_print_mt_port_cap_subtlv(ndo, tptr, tmp); + + break; + } + + case ISIS_TLV_MT_CAPABILITY: + + ND_TCHECK2(*(tptr), 2); + + ND_PRINT((ndo, ""\n\t O: %d, RES: %d, MTID(s): %d"", + (EXTRACT_16BITS(tptr) >> 15) & 0x01, + (EXTRACT_16BITS(tptr) >> 12) & 0x07, + EXTRACT_16BITS(tptr) & 0x0fff)); + + tmp = tmp-2; + tptr = tptr+2; + + if (tmp) + isis_print_mt_capability_subtlv(ndo, tptr, tmp); + + break; + + case ISIS_TLV_TE_ROUTER_ID: + ND_TCHECK2(*pptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t Traffic Engineering Router ID: %s"", ipaddr_string(ndo, pptr))); + break; + + case ISIS_TLV_IPADDR: + while (tmp>=sizeof(struct in_addr)) { + ND_TCHECK2(*tptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t IPv4 interface address: %s"", ipaddr_string(ndo, tptr))); + tptr += sizeof(struct in_addr); + tmp -= sizeof(struct in_addr); + } + break; + + case ISIS_TLV_HOSTNAME: + ND_PRINT((ndo, ""\n\t Hostname: "")); + if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend)) + goto trunctlv; + break; + + case ISIS_TLV_SHARED_RISK_GROUP: + if (tmp < NODE_ID_LEN) + break; + ND_TCHECK2(*tptr, NODE_ID_LEN); + ND_PRINT((ndo, ""\n\t IS Neighbor: %s"", isis_print_id(tptr, NODE_ID_LEN))); + tptr+=(NODE_ID_LEN); + tmp-=(NODE_ID_LEN); + + if (tmp < 1) + break; + ND_TCHECK2(*tptr, 1); + ND_PRINT((ndo, "", Flags: [%s]"", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? ""numbered"" : ""unnumbered"")); + tmp--; + + if (tmp < sizeof(struct in_addr)) + break; + ND_TCHECK2(*tptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t IPv4 interface address: %s"", ipaddr_string(ndo, tptr))); + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); + + if (tmp < sizeof(struct in_addr)) + break; + ND_TCHECK2(*tptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t IPv4 neighbor address: %s"", ipaddr_string(ndo, tptr))); + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); + + while (tmp>=4) { + ND_TCHECK2(*tptr, 4); + ND_PRINT((ndo, ""\n\t Link-ID: 0x%08x"", EXTRACT_32BITS(tptr))); + tptr+=4; + tmp-=4; + } + break; + + case ISIS_TLV_LSP: + tlv_lsp = (const struct isis_tlv_lsp *)tptr; + while(tmp>=sizeof(struct isis_tlv_lsp)) { + ND_TCHECK((tlv_lsp->lsp_id)[LSP_ID_LEN-1]); + ND_PRINT((ndo, ""\n\t lsp-id: %s"", + isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN))); + ND_TCHECK2(tlv_lsp->sequence_number, 4); + ND_PRINT((ndo, "", seq: 0x%08x"", EXTRACT_32BITS(tlv_lsp->sequence_number))); + ND_TCHECK2(tlv_lsp->remaining_lifetime, 2); + ND_PRINT((ndo, "", lifetime: %5ds"", EXTRACT_16BITS(tlv_lsp->remaining_lifetime))); + ND_TCHECK2(tlv_lsp->checksum, 2); + ND_PRINT((ndo, "", chksum: 0x%04x"", EXTRACT_16BITS(tlv_lsp->checksum))); + tmp-=sizeof(struct isis_tlv_lsp); + tlv_lsp++; + } + break; + + case ISIS_TLV_CHECKSUM: + if (tmp < ISIS_TLV_CHECKSUM_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_CHECKSUM_MINLEN); + ND_PRINT((ndo, ""\n\t checksum: 0x%04x "", EXTRACT_16BITS(tptr))); + /* do not attempt to verify the checksum if it is zero + * most likely a HMAC-MD5 TLV is also present and + * to avoid conflicts the checksum TLV is zeroed. + * see rfc3358 for details + */ + osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr, + length); + break; + + case ISIS_TLV_POI: + if (tlv_len >= SYSTEM_ID_LEN + 1) { + ND_TCHECK2(*tptr, SYSTEM_ID_LEN + 1); + ND_PRINT((ndo, ""\n\t Purge Originator System-ID: %s"", + isis_print_id(tptr + 1, SYSTEM_ID_LEN))); + } + + if (tlv_len == 2 * SYSTEM_ID_LEN + 1) { + ND_TCHECK2(*tptr, 2 * SYSTEM_ID_LEN + 1); + ND_PRINT((ndo, ""\n\t Received from System-ID: %s"", + isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN))); + } + break; + + case ISIS_TLV_MT_SUPPORTED: + if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) + break; + while (tmp>1) { + /* length can only be a multiple of 2, otherwise there is + something broken -> so decode down until length is 1 */ + if (tmp!=1) { + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + } else { + ND_PRINT((ndo, ""\n\t invalid MT-ID"")); + break; + } + } + break; + + case ISIS_TLV_RESTART_SIGNALING: + /* first attempt to decode the flags */ + if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN); + ND_PRINT((ndo, ""\n\t Flags [%s]"", + bittok2str(isis_restart_flag_values, ""none"", *tptr))); + tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + + /* is there anything other than the flags field? */ + if (tmp == 0) + break; + + if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN); + + ND_PRINT((ndo, "", Remaining holding time %us"", EXTRACT_16BITS(tptr))); + tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + + /* is there an additional sysid field present ?*/ + if (tmp == SYSTEM_ID_LEN) { + ND_TCHECK2(*tptr, SYSTEM_ID_LEN); + ND_PRINT((ndo, "", for %s"", isis_print_id(tptr,SYSTEM_ID_LEN))); + } + break; + + case ISIS_TLV_IDRP_INFO: + if (tmp < ISIS_TLV_IDRP_INFO_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN); + ND_PRINT((ndo, ""\n\t Inter-Domain Information Type: %s"", + tok2str(isis_subtlv_idrp_values, + ""Unknown (0x%02x)"", + *tptr))); + switch (*tptr++) { + case ISIS_SUBTLV_IDRP_ASN: + ND_TCHECK2(*tptr, 2); /* fetch AS number */ + ND_PRINT((ndo, ""AS Number: %u"", EXTRACT_16BITS(tptr))); + break; + case ISIS_SUBTLV_IDRP_LOCAL: + case ISIS_SUBTLV_IDRP_RES: + default: + if (!print_unknown_data(ndo, tptr, ""\n\t "", tlv_len - 1)) + return(0); + break; + } + break; + + case ISIS_TLV_LSP_BUFFERSIZE: + if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN); + ND_PRINT((ndo, ""\n\t LSP Buffersize: %u"", EXTRACT_16BITS(tptr))); + break; + + case ISIS_TLV_PART_DIS: + while (tmp >= SYSTEM_ID_LEN) { + ND_TCHECK2(*tptr, SYSTEM_ID_LEN); + ND_PRINT((ndo, ""\n\t %s"", isis_print_id(tptr, SYSTEM_ID_LEN))); + tptr+=SYSTEM_ID_LEN; + tmp-=SYSTEM_ID_LEN; + } + break; + + case ISIS_TLV_PREFIX_NEIGH: + if (tmp < sizeof(struct isis_metric_block)) + break; + ND_TCHECK2(*tptr, sizeof(struct isis_metric_block)); + ND_PRINT((ndo, ""\n\t Metric Block"")); + isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr); + tptr+=sizeof(struct isis_metric_block); + tmp-=sizeof(struct isis_metric_block); + + while(tmp>0) { + ND_TCHECK2(*tptr, 1); + prefix_len=*tptr++; /* read out prefix length in semioctets*/ + if (prefix_len < 2) { + ND_PRINT((ndo, ""\n\t\tAddress: prefix length %u < 2"", prefix_len)); + break; + } + tmp--; + if (tmp < prefix_len/2) + break; + ND_TCHECK2(*tptr, prefix_len / 2); + ND_PRINT((ndo, ""\n\t\tAddress: %s/%u"", + isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4)); + tptr+=prefix_len/2; + tmp-=prefix_len/2; + } + break; + + case ISIS_TLV_IIH_SEQNR: + if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN); /* check if four bytes are on the wire */ + ND_PRINT((ndo, ""\n\t Sequence number: %u"", EXTRACT_32BITS(tptr))); + break; + + case ISIS_TLV_VENDOR_PRIVATE: + if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN); /* check if enough byte for a full oui */ + vendor_id = EXTRACT_24BITS(tptr); + ND_PRINT((ndo, ""\n\t Vendor: %s (%u)"", + tok2str(oui_values, ""Unknown"", vendor_id), + vendor_id)); + tptr+=3; + tmp-=3; + if (tmp > 0) /* hexdump the rest */ + if (!print_unknown_data(ndo, tptr, ""\n\t\t"", tmp)) + return(0); + break; + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case ISIS_TLV_DECNET_PHASE4: + case ISIS_TLV_LUCENT_PRIVATE: + case ISIS_TLV_IPAUTH: + case ISIS_TLV_NORTEL_PRIVATE1: + case ISIS_TLV_NORTEL_PRIVATE2: + + default: + if (ndo->ndo_vflag <= 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t\t"", tlv_len)) + return(0); + } + break; + } + /* do we want to see an additionally hexdump ? */ + if (ndo->ndo_vflag> 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", tlv_len)) + return(0); + } + + pptr += tlv_len; + packet_len -= tlv_len; + } + + if (packet_len != 0) { + ND_PRINT((ndo, ""\n\t %u straggler bytes"", packet_len)); + } + return (1); + + trunc: + ND_PRINT((ndo, ""%s"", tstr)); + return (1); + + trunctlv: + ND_PRINT((ndo, ""\n\t\t"")); + ND_PRINT((ndo, ""%s"", tstr)); + return(1); +} +",1,"isis_print(netdissect_options *ndo, + const uint8_t *p, u_int length) +{ + const struct isis_common_header *isis_header; + + const struct isis_iih_lan_header *header_iih_lan; + const struct isis_iih_ptp_header *header_iih_ptp; + const struct isis_lsp_header *header_lsp; + const struct isis_csnp_header *header_csnp; + const struct isis_psnp_header *header_psnp; + + const struct isis_tlv_lsp *tlv_lsp; + const struct isis_tlv_ptp_adj *tlv_ptp_adj; + const struct isis_tlv_is_reach *tlv_is_reach; + const struct isis_tlv_es_reach *tlv_es_reach; + + uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len; + uint8_t ext_is_len, ext_ip_len, mt_len; + const uint8_t *optr, *pptr, *tptr; + u_short packet_len,pdu_len, key_id; + u_int i,vendor_id; + int sigcheck; + + packet_len=length; + optr = p; /* initialize the _o_riginal pointer to the packet start - + need it for parsing the checksum TLV and authentication + TLV verification */ + isis_header = (const struct isis_common_header *)p; + ND_TCHECK(*isis_header); + if (length < ISIS_COMMON_HEADER_SIZE) + goto trunc; + pptr = p+(ISIS_COMMON_HEADER_SIZE); + header_iih_lan = (const struct isis_iih_lan_header *)pptr; + header_iih_ptp = (const struct isis_iih_ptp_header *)pptr; + header_lsp = (const struct isis_lsp_header *)pptr; + header_csnp = (const struct isis_csnp_header *)pptr; + header_psnp = (const struct isis_psnp_header *)pptr; + + if (!ndo->ndo_eflag) + ND_PRINT((ndo, ""IS-IS"")); + + /* + * Sanity checking of the header. + */ + + if (isis_header->version != ISIS_VERSION) { + ND_PRINT((ndo, ""version %d packet not supported"", isis_header->version)); + return (0); + } + + if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) { + ND_PRINT((ndo, ""system ID length of %d is not supported"", + isis_header->id_length)); + return (0); + } + + if (isis_header->pdu_version != ISIS_VERSION) { + ND_PRINT((ndo, ""version %d packet not supported"", isis_header->pdu_version)); + return (0); + } + + if (length < isis_header->fixed_len) { + ND_PRINT((ndo, ""fixed header length %u > packet length %u"", isis_header->fixed_len, length)); + return (0); + } + + if (isis_header->fixed_len < ISIS_COMMON_HEADER_SIZE) { + ND_PRINT((ndo, ""fixed header length %u < minimum header size %u"", isis_header->fixed_len, (u_int)ISIS_COMMON_HEADER_SIZE)); + return (0); + } + + max_area = isis_header->max_area; + switch(max_area) { + case 0: + max_area = 3; /* silly shit */ + break; + case 255: + ND_PRINT((ndo, ""bad packet -- 255 areas"")); + return (0); + default: + break; + } + + id_length = isis_header->id_length; + switch(id_length) { + case 0: + id_length = 6; /* silly shit again */ + break; + case 1: /* 1-8 are valid sys-ID lenghts */ + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + break; + case 255: + id_length = 0; /* entirely useless */ + break; + default: + break; + } + + /* toss any non 6-byte sys-ID len PDUs */ + if (id_length != 6 ) { + ND_PRINT((ndo, ""bad packet -- illegal sys-ID length (%u)"", id_length)); + return (0); + } + + pdu_type=isis_header->pdu_type; + + /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/ + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, ""%s%s"", + ndo->ndo_eflag ? """" : "", "", + tok2str(isis_pdu_values, ""unknown PDU-Type %u"", pdu_type))); + } else { + /* ok they seem to want to know everything - lets fully decode it */ + ND_PRINT((ndo, ""%slength %u"", ndo->ndo_eflag ? """" : "", "", length)); + + ND_PRINT((ndo, ""\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)"", + tok2str(isis_pdu_values, + ""unknown, type %u"", + pdu_type), + isis_header->fixed_len, + isis_header->version, + isis_header->pdu_version, + id_length, + isis_header->id_length, + max_area, + isis_header->max_area)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, optr, ""\n\t"", 8)) /* provide the _o_riginal pointer */ + return (0); /* for optionally debugging the common header */ + } + } + + switch (pdu_type) { + + case ISIS_PDU_L1_LAN_IIH: + case ISIS_PDU_L2_LAN_IIH: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_iih_lan); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", + isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN))); + ND_PRINT((ndo, "", lan-id %s, prio %u"", + isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN), + header_iih_lan->priority)); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, holding time: %us, Flags: [%s]"", + isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN), + EXTRACT_16BITS(header_iih_lan->holding_time), + tok2str(isis_iih_circuit_type_values, + ""unknown circuit type 0x%02x"", + header_iih_lan->circuit_type))); + + ND_PRINT((ndo, ""\n\t lan-id: %s, Priority: %u, PDU length: %u"", + isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN), + (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK, + pdu_len)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_IIH_LAN_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); + break; + + case ISIS_PDU_PTP_IIH: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_iih_ptp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, holding time: %us, Flags: [%s]"", + isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN), + EXTRACT_16BITS(header_iih_ptp->holding_time), + tok2str(isis_iih_circuit_type_values, + ""unknown circuit type 0x%02x"", + header_iih_ptp->circuit_type))); + + ND_PRINT((ndo, ""\n\t circuit-id: 0x%02x, PDU length: %u"", + header_iih_ptp->circuit_id, + pdu_len)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_IIH_PTP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_LSP: + case ISIS_PDU_L2_LSP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE)); + return (0); + } + ND_TCHECK(*header_lsp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", lsp-id %s, seq 0x%08x, lifetime %5us"", + isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), + EXTRACT_32BITS(header_lsp->sequence_number), + EXTRACT_16BITS(header_lsp->remaining_lifetime))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_lsp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x"", + isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), + EXTRACT_32BITS(header_lsp->sequence_number), + EXTRACT_16BITS(header_lsp->remaining_lifetime), + EXTRACT_16BITS(header_lsp->checksum))); + + osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id, + EXTRACT_16BITS(header_lsp->checksum), + 12, length-12); + + ND_PRINT((ndo, "", PDU length: %u, Flags: [ %s"", + pdu_len, + ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? ""Overload bit set, "" : """")); + + if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? ""default "" : """")); + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? ""delay "" : """")); + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? ""expense "" : """")); + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? ""error "" : """")); + ND_PRINT((ndo, ""ATT bit set, "")); + } + ND_PRINT((ndo, ""%s"", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? ""P bit set, "" : """")); + ND_PRINT((ndo, ""%s ]"", tok2str(isis_lsp_istype_values, ""Unknown(0x%x)"", + ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)))); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_LSP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_CSNP: + case ISIS_PDU_L2_CSNP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) { + ND_PRINT((ndo, "", bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_csnp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", isis_print_id(header_csnp->source_id, NODE_ID_LEN))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_csnp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, PDU length: %u"", + isis_print_id(header_csnp->source_id, NODE_ID_LEN), + pdu_len)); + ND_PRINT((ndo, ""\n\t start lsp-id: %s"", + isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN))); + ND_PRINT((ndo, ""\n\t end lsp-id: %s"", + isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN))); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_CSNP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_PSNP: + case ISIS_PDU_L2_PSNP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) { + ND_PRINT((ndo, ""- bogus fixed header length %u should be %lu"", + isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE))); + return (0); + } + ND_TCHECK(*header_psnp); + if (length < ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE) + goto trunc; + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", src-id %s"", isis_print_id(header_psnp->source_id, NODE_ID_LEN))); + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + pdu_len=EXTRACT_16BITS(header_psnp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + ND_PRINT((ndo, ""\n\t source-id: %s, PDU length: %u"", + isis_print_id(header_psnp->source_id, NODE_ID_LEN), + pdu_len)); + + if (ndo->ndo_vflag > 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", ISIS_PSNP_HEADER_SIZE)) + return (0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); + break; + + default: + if (ndo->ndo_vflag == 0) { + ND_PRINT((ndo, "", length %u"", length)); + return (1); + } + (void)print_unknown_data(ndo, pptr, ""\n\t "", length); + return (0); + } + + /* + * Now print the TLV's. + */ + + while (packet_len > 0) { + ND_TCHECK2(*pptr, 2); + if (packet_len < 2) + goto trunc; + tlv_type = *pptr++; + tlv_len = *pptr++; + tmp =tlv_len; /* copy temporary len & pointer to packet data */ + tptr = pptr; + packet_len -= 2; + + /* first lets see if we know the TLVs name*/ + ND_PRINT((ndo, ""\n\t %s TLV #%u, length: %u"", + tok2str(isis_tlv_values, + ""unknown"", + tlv_type), + tlv_type, + tlv_len)); + + if (tlv_len == 0) /* something is invalid */ + continue; + + if (packet_len < tlv_len) + goto trunc; + + /* now check if we have a decoder otherwise do a hexdump at the end*/ + switch (tlv_type) { + case ISIS_TLV_AREA_ADDR: + ND_TCHECK2(*tptr, 1); + alen = *tptr++; + while (tmp && alen < tmp) { + ND_TCHECK2(*tptr, alen); + ND_PRINT((ndo, ""\n\t Area address (length: %u): %s"", + alen, + isonsap_string(ndo, tptr, alen))); + tptr += alen; + tmp -= alen + 1; + if (tmp==0) /* if this is the last area address do not attemt a boundary check */ + break; + ND_TCHECK2(*tptr, 1); + alen = *tptr++; + } + break; + case ISIS_TLV_ISNEIGH: + while (tmp >= ETHER_ADDR_LEN) { + ND_TCHECK2(*tptr, ETHER_ADDR_LEN); + ND_PRINT((ndo, ""\n\t SNPA: %s"", isis_print_id(tptr, ETHER_ADDR_LEN))); + tmp -= ETHER_ADDR_LEN; + tptr += ETHER_ADDR_LEN; + } + break; + + case ISIS_TLV_ISNEIGH_VARLEN: + if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */ + goto trunctlv; + lan_alen = *tptr++; /* LAN address length */ + if (lan_alen == 0) { + ND_PRINT((ndo, ""\n\t LAN address length 0 bytes (invalid)"")); + break; + } + tmp --; + ND_PRINT((ndo, ""\n\t LAN address length %u bytes "", lan_alen)); + while (tmp >= lan_alen) { + ND_TCHECK2(*tptr, lan_alen); + ND_PRINT((ndo, ""\n\t\tIS Neighbor: %s"", isis_print_id(tptr, lan_alen))); + tmp -= lan_alen; + tptr +=lan_alen; + } + break; + + case ISIS_TLV_PADDING: + break; + + case ISIS_TLV_MT_IS_REACH: + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + while (tmp >= 2+NODE_ID_LEN+3+1) { + ext_is_len = isis_print_ext_is_reach(ndo, tptr, ""\n\t "", tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + + case ISIS_TLV_IS_ALIAS_ID: + while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */ + ext_is_len = isis_print_ext_is_reach(ndo, tptr, ""\n\t "", tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + + case ISIS_TLV_EXT_IS_REACH: + while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */ + ext_is_len = isis_print_ext_is_reach(ndo, tptr, ""\n\t "", tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + case ISIS_TLV_IS_REACH: + ND_TCHECK2(*tptr,1); /* check if there is one byte left to read out the virtual flag */ + ND_PRINT((ndo, ""\n\t %s"", + tok2str(isis_is_reach_virtual_values, + ""bogus virtual flag 0x%02x"", + *tptr++))); + tlv_is_reach = (const struct isis_tlv_is_reach *)tptr; + while (tmp >= sizeof(struct isis_tlv_is_reach)) { + ND_TCHECK(*tlv_is_reach); + ND_PRINT((ndo, ""\n\t IS Neighbor: %s"", + isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN))); + isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block); + tmp -= sizeof(struct isis_tlv_is_reach); + tlv_is_reach++; + } + break; + + case ISIS_TLV_ESNEIGH: + tlv_es_reach = (const struct isis_tlv_es_reach *)tptr; + while (tmp >= sizeof(struct isis_tlv_es_reach)) { + ND_TCHECK(*tlv_es_reach); + ND_PRINT((ndo, ""\n\t ES Neighbor: %s"", + isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN))); + isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block); + tmp -= sizeof(struct isis_tlv_es_reach); + tlv_es_reach++; + } + break; + + /* those two TLVs share the same format */ + case ISIS_TLV_INT_IP_REACH: + case ISIS_TLV_EXT_IP_REACH: + if (!isis_print_tlv_ip_reach(ndo, pptr, ""\n\t "", tlv_len)) + return (1); + break; + + case ISIS_TLV_EXTD_IP_REACH: + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_MT_IP_REACH: + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) { /* did something go wrong ? */ + goto trunctlv; + } + tptr+=mt_len; + tmp-=mt_len; + + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_IP6_REACH: + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET6); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_MT_IP6_REACH: + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) { /* did something go wrong ? */ + goto trunctlv; + } + tptr+=mt_len; + tmp-=mt_len; + + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, ""\n\t "", AF_INET6); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_IP6ADDR: + while (tmp>=sizeof(struct in6_addr)) { + ND_TCHECK2(*tptr, sizeof(struct in6_addr)); + + ND_PRINT((ndo, ""\n\t IPv6 interface address: %s"", + ip6addr_string(ndo, tptr))); + + tptr += sizeof(struct in6_addr); + tmp -= sizeof(struct in6_addr); + } + break; + case ISIS_TLV_AUTH: + ND_TCHECK2(*tptr, 1); + + ND_PRINT((ndo, ""\n\t %s: "", + tok2str(isis_subtlv_auth_values, + ""unknown Authentication type 0x%02x"", + *tptr))); + + switch (*tptr) { + case ISIS_SUBTLV_AUTH_SIMPLE: + if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend)) + goto trunctlv; + break; + case ISIS_SUBTLV_AUTH_MD5: + for(i=1;i=1) { + ND_TCHECK2(*tptr, 1); + ND_PRINT((ndo, ""\n\t Adjacency State: %s (%u)"", + tok2str(isis_ptp_adjancey_values, ""unknown"", *tptr), + *tptr)); + tmp--; + } + if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) { + ND_TCHECK(tlv_ptp_adj->extd_local_circuit_id); + ND_PRINT((ndo, ""\n\t Extended Local circuit-ID: 0x%08x"", + EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id))); + tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id); + } + if(tmp>=SYSTEM_ID_LEN) { + ND_TCHECK2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN); + ND_PRINT((ndo, ""\n\t Neighbor System-ID: %s"", + isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))); + tmp-=SYSTEM_ID_LEN; + } + if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) { + ND_TCHECK(tlv_ptp_adj->neighbor_extd_local_circuit_id); + ND_PRINT((ndo, ""\n\t Neighbor Extended Local circuit-ID: 0x%08x"", + EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id))); + } + break; + + case ISIS_TLV_PROTOCOLS: + ND_PRINT((ndo, ""\n\t NLPID(s): "")); + while (tmp>0) { + ND_TCHECK2(*(tptr), 1); + ND_PRINT((ndo, ""%s (0x%02x)"", + tok2str(nlpid_values, + ""unknown"", + *tptr), + *tptr)); + if (tmp>1) /* further NPLIDs ? - put comma */ + ND_PRINT((ndo, "", "")); + tptr++; + tmp--; + } + break; + + case ISIS_TLV_MT_PORT_CAP: + { + ND_TCHECK2(*(tptr), 2); + + ND_PRINT((ndo, ""\n\t RES: %d, MTID(s): %d"", + (EXTRACT_16BITS (tptr) >> 12), + (EXTRACT_16BITS (tptr) & 0x0fff))); + + tmp = tmp-2; + tptr = tptr+2; + + if (tmp) + isis_print_mt_port_cap_subtlv(ndo, tptr, tmp); + + break; + } + + case ISIS_TLV_MT_CAPABILITY: + + ND_TCHECK2(*(tptr), 2); + + ND_PRINT((ndo, ""\n\t O: %d, RES: %d, MTID(s): %d"", + (EXTRACT_16BITS(tptr) >> 15) & 0x01, + (EXTRACT_16BITS(tptr) >> 12) & 0x07, + EXTRACT_16BITS(tptr) & 0x0fff)); + + tmp = tmp-2; + tptr = tptr+2; + + if (tmp) + isis_print_mt_capability_subtlv(ndo, tptr, tmp); + + break; + + case ISIS_TLV_TE_ROUTER_ID: + ND_TCHECK2(*pptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t Traffic Engineering Router ID: %s"", ipaddr_string(ndo, pptr))); + break; + + case ISIS_TLV_IPADDR: + while (tmp>=sizeof(struct in_addr)) { + ND_TCHECK2(*tptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t IPv4 interface address: %s"", ipaddr_string(ndo, tptr))); + tptr += sizeof(struct in_addr); + tmp -= sizeof(struct in_addr); + } + break; + + case ISIS_TLV_HOSTNAME: + ND_PRINT((ndo, ""\n\t Hostname: "")); + if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend)) + goto trunctlv; + break; + + case ISIS_TLV_SHARED_RISK_GROUP: + if (tmp < NODE_ID_LEN) + break; + ND_TCHECK2(*tptr, NODE_ID_LEN); + ND_PRINT((ndo, ""\n\t IS Neighbor: %s"", isis_print_id(tptr, NODE_ID_LEN))); + tptr+=(NODE_ID_LEN); + tmp-=(NODE_ID_LEN); + + if (tmp < 1) + break; + ND_TCHECK2(*tptr, 1); + ND_PRINT((ndo, "", Flags: [%s]"", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? ""numbered"" : ""unnumbered"")); + tmp--; + + if (tmp < sizeof(struct in_addr)) + break; + ND_TCHECK2(*tptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t IPv4 interface address: %s"", ipaddr_string(ndo, tptr))); + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); + + if (tmp < sizeof(struct in_addr)) + break; + ND_TCHECK2(*tptr, sizeof(struct in_addr)); + ND_PRINT((ndo, ""\n\t IPv4 neighbor address: %s"", ipaddr_string(ndo, tptr))); + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); + + while (tmp>=4) { + ND_TCHECK2(*tptr, 4); + ND_PRINT((ndo, ""\n\t Link-ID: 0x%08x"", EXTRACT_32BITS(tptr))); + tptr+=4; + tmp-=4; + } + break; + + case ISIS_TLV_LSP: + tlv_lsp = (const struct isis_tlv_lsp *)tptr; + while(tmp>=sizeof(struct isis_tlv_lsp)) { + ND_TCHECK((tlv_lsp->lsp_id)[LSP_ID_LEN-1]); + ND_PRINT((ndo, ""\n\t lsp-id: %s"", + isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN))); + ND_TCHECK2(tlv_lsp->sequence_number, 4); + ND_PRINT((ndo, "", seq: 0x%08x"", EXTRACT_32BITS(tlv_lsp->sequence_number))); + ND_TCHECK2(tlv_lsp->remaining_lifetime, 2); + ND_PRINT((ndo, "", lifetime: %5ds"", EXTRACT_16BITS(tlv_lsp->remaining_lifetime))); + ND_TCHECK2(tlv_lsp->checksum, 2); + ND_PRINT((ndo, "", chksum: 0x%04x"", EXTRACT_16BITS(tlv_lsp->checksum))); + tmp-=sizeof(struct isis_tlv_lsp); + tlv_lsp++; + } + break; + + case ISIS_TLV_CHECKSUM: + if (tmp < ISIS_TLV_CHECKSUM_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_CHECKSUM_MINLEN); + ND_PRINT((ndo, ""\n\t checksum: 0x%04x "", EXTRACT_16BITS(tptr))); + /* do not attempt to verify the checksum if it is zero + * most likely a HMAC-MD5 TLV is also present and + * to avoid conflicts the checksum TLV is zeroed. + * see rfc3358 for details + */ + osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr, + length); + break; + + case ISIS_TLV_POI: + if (tlv_len >= SYSTEM_ID_LEN + 1) { + ND_TCHECK2(*tptr, SYSTEM_ID_LEN + 1); + ND_PRINT((ndo, ""\n\t Purge Originator System-ID: %s"", + isis_print_id(tptr + 1, SYSTEM_ID_LEN))); + } + + if (tlv_len == 2 * SYSTEM_ID_LEN + 1) { + ND_TCHECK2(*tptr, 2 * SYSTEM_ID_LEN + 1); + ND_PRINT((ndo, ""\n\t Received from System-ID: %s"", + isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN))); + } + break; + + case ISIS_TLV_MT_SUPPORTED: + if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) + break; + while (tmp>1) { + /* length can only be a multiple of 2, otherwise there is + something broken -> so decode down until length is 1 */ + if (tmp!=1) { + mt_len = isis_print_mtid(ndo, tptr, ""\n\t ""); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + } else { + ND_PRINT((ndo, ""\n\t invalid MT-ID"")); + break; + } + } + break; + + case ISIS_TLV_RESTART_SIGNALING: + /* first attempt to decode the flags */ + if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN); + ND_PRINT((ndo, ""\n\t Flags [%s]"", + bittok2str(isis_restart_flag_values, ""none"", *tptr))); + tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + + /* is there anything other than the flags field? */ + if (tmp == 0) + break; + + if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN); + + ND_PRINT((ndo, "", Remaining holding time %us"", EXTRACT_16BITS(tptr))); + tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + + /* is there an additional sysid field present ?*/ + if (tmp == SYSTEM_ID_LEN) { + ND_TCHECK2(*tptr, SYSTEM_ID_LEN); + ND_PRINT((ndo, "", for %s"", isis_print_id(tptr,SYSTEM_ID_LEN))); + } + break; + + case ISIS_TLV_IDRP_INFO: + if (tmp < ISIS_TLV_IDRP_INFO_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN); + ND_PRINT((ndo, ""\n\t Inter-Domain Information Type: %s"", + tok2str(isis_subtlv_idrp_values, + ""Unknown (0x%02x)"", + *tptr))); + switch (*tptr++) { + case ISIS_SUBTLV_IDRP_ASN: + ND_TCHECK2(*tptr, 2); /* fetch AS number */ + ND_PRINT((ndo, ""AS Number: %u"", EXTRACT_16BITS(tptr))); + break; + case ISIS_SUBTLV_IDRP_LOCAL: + case ISIS_SUBTLV_IDRP_RES: + default: + if (!print_unknown_data(ndo, tptr, ""\n\t "", tlv_len - 1)) + return(0); + break; + } + break; + + case ISIS_TLV_LSP_BUFFERSIZE: + if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN); + ND_PRINT((ndo, ""\n\t LSP Buffersize: %u"", EXTRACT_16BITS(tptr))); + break; + + case ISIS_TLV_PART_DIS: + while (tmp >= SYSTEM_ID_LEN) { + ND_TCHECK2(*tptr, SYSTEM_ID_LEN); + ND_PRINT((ndo, ""\n\t %s"", isis_print_id(tptr, SYSTEM_ID_LEN))); + tptr+=SYSTEM_ID_LEN; + tmp-=SYSTEM_ID_LEN; + } + break; + + case ISIS_TLV_PREFIX_NEIGH: + if (tmp < sizeof(struct isis_metric_block)) + break; + ND_TCHECK2(*tptr, sizeof(struct isis_metric_block)); + ND_PRINT((ndo, ""\n\t Metric Block"")); + isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr); + tptr+=sizeof(struct isis_metric_block); + tmp-=sizeof(struct isis_metric_block); + + while(tmp>0) { + ND_TCHECK2(*tptr, 1); + prefix_len=*tptr++; /* read out prefix length in semioctets*/ + if (prefix_len < 2) { + ND_PRINT((ndo, ""\n\t\tAddress: prefix length %u < 2"", prefix_len)); + break; + } + tmp--; + if (tmp < prefix_len/2) + break; + ND_TCHECK2(*tptr, prefix_len / 2); + ND_PRINT((ndo, ""\n\t\tAddress: %s/%u"", + isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4)); + tptr+=prefix_len/2; + tmp-=prefix_len/2; + } + break; + + case ISIS_TLV_IIH_SEQNR: + if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN); /* check if four bytes are on the wire */ + ND_PRINT((ndo, ""\n\t Sequence number: %u"", EXTRACT_32BITS(tptr))); + break; + + case ISIS_TLV_VENDOR_PRIVATE: + if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN) + break; + ND_TCHECK2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN); /* check if enough byte for a full oui */ + vendor_id = EXTRACT_24BITS(tptr); + ND_PRINT((ndo, ""\n\t Vendor: %s (%u)"", + tok2str(oui_values, ""Unknown"", vendor_id), + vendor_id)); + tptr+=3; + tmp-=3; + if (tmp > 0) /* hexdump the rest */ + if (!print_unknown_data(ndo, tptr, ""\n\t\t"", tmp)) + return(0); + break; + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case ISIS_TLV_DECNET_PHASE4: + case ISIS_TLV_LUCENT_PRIVATE: + case ISIS_TLV_IPAUTH: + case ISIS_TLV_NORTEL_PRIVATE1: + case ISIS_TLV_NORTEL_PRIVATE2: + + default: + if (ndo->ndo_vflag <= 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t\t"", tlv_len)) + return(0); + } + break; + } + /* do we want to see an additionally hexdump ? */ + if (ndo->ndo_vflag> 1) { + if (!print_unknown_data(ndo, pptr, ""\n\t "", tlv_len)) + return(0); + } + + pptr += tlv_len; + packet_len -= tlv_len; + } + + if (packet_len != 0) { + ND_PRINT((ndo, ""\n\t %u straggler bytes"", packet_len)); + } + return (1); + + trunc: + ND_PRINT((ndo, ""%s"", tstr)); + return (1); + + trunctlv: + ND_PRINT((ndo, ""\n\t\t"")); + ND_PRINT((ndo, ""%s"", tstr)); + return(1); +} +","@@ -2532,6 +2532,7 @@ isis_print(netdissect_options *ndo, + ND_TCHECK2(*tptr, 1); + alen = *tptr++; + while (tmp && alen < tmp) { ++ ND_TCHECK2(*tptr, alen); + ND_PRINT((ndo, ""\n\t Area address (length: %u): %s"", + alen, + isonsap_string(ndo, tptr, alen)));",9847,10083,11000 +18805,"WORD32 ih264d_parse_decode_slice(UWORD8 u1_is_idr_slice, + UWORD8 u1_nal_ref_idc, + dec_struct_t *ps_dec /* Decoder parameters */ + ) +{ + dec_bit_stream_t * ps_bitstrm = ps_dec->ps_bitstrm; + dec_pic_params_t *ps_pps; + dec_seq_params_t *ps_seq; + dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice; + pocstruct_t s_tmp_poc; + WORD32 i_delta_poc[2]; + WORD32 i4_poc = 0; + UWORD16 u2_first_mb_in_slice, u2_frame_num; + UWORD8 u1_field_pic_flag, u1_redundant_pic_cnt = 0, u1_slice_type; + UWORD32 u4_idr_pic_id = 0; + UWORD8 u1_bottom_field_flag, u1_pic_order_cnt_type; + + UWORD8 u1_nal_unit_type; + UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer; + UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst; + WORD8 i1_is_end_of_poc; + + WORD32 ret, end_of_frame; + WORD32 prev_slice_err, num_mb_skipped; + UWORD8 u1_mbaff; + pocstruct_t *ps_cur_poc; + + UWORD32 u4_temp; + WORD32 i_temp; + UWORD32 u4_call_end_of_pic = 0; + + /* read FirstMbInSlice and slice type*/ + ps_dec->ps_dpb_cmds->u1_dpb_commands_read_slc = 0; + u2_first_mb_in_slice = ih264d_uev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + if(u2_first_mb_in_slice + > (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)) + { + + return ERROR_CORRUPTED_SLICE; + } + + /*we currently don not support ASO*/ + if(((u2_first_mb_in_slice << ps_cur_slice->u1_mbaff_frame_flag) + <= ps_dec->u2_cur_mb_addr) && (ps_dec->u4_first_slice_in_pic == 0)) + { + return ERROR_CORRUPTED_SLICE; + } + + COPYTHECONTEXT(""SH: first_mb_in_slice"",u2_first_mb_in_slice); + + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + + if(u4_temp > 9) + return ERROR_INV_SLC_TYPE_T; + + u1_slice_type = u4_temp; + COPYTHECONTEXT(""SH: slice_type"",(u1_slice_type)); + ps_dec->u1_sl_typ_5_9 = 0; + /* Find Out the Slice Type is 5 to 9 or not then Set the Flag */ + /* u1_sl_typ_5_9 = 1 .Which tells that all the slices in the Pic*/ + /* will be of same type of current */ + if(u1_slice_type > 4) + { + u1_slice_type -= 5; + ps_dec->u1_sl_typ_5_9 = 1; + } + + { + UWORD32 skip; + + if((ps_dec->i4_app_skip_mode == IVD_SKIP_PB) + || (ps_dec->i4_dec_skip_mode == IVD_SKIP_PB)) + { + UWORD32 u4_bit_stream_offset = 0; + + if(ps_dec->u1_nal_unit_type == IDR_SLICE_NAL) + { + skip = 0; + + ps_dec->i4_dec_skip_mode = IVD_SKIP_NONE; + } + else if((I_SLICE == u1_slice_type) + && (1 >= ps_dec->ps_cur_sps->u1_num_ref_frames)) + { + skip = 0; + + ps_dec->i4_dec_skip_mode = IVD_SKIP_NONE; + } + else + { + skip = 1; + } + + /* If one frame worth of data is already skipped, do not skip the next one */ + if((0 == u2_first_mb_in_slice) && (1 == ps_dec->u4_prev_nal_skipped)) + { + skip = 0; + } + + if(skip) + { + ps_dec->u4_prev_nal_skipped = 1; + ps_dec->i4_dec_skip_mode = IVD_SKIP_PB; + return 0; + } + else + { + /* If the previous NAL was skipped, then + do not process that buffer in this call. + Return to app and process it in the next call. + This is necessary to handle cases where I/IDR is not complete in + the current buffer and application intends to fill the remaining part of the bitstream + later. This ensures we process only frame worth of data in every call */ + if(1 == ps_dec->u4_prev_nal_skipped) + { + ps_dec->u4_return_to_app = 1; + return 0; + } + } + } + + } + + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if(u4_temp & MASK_ERR_PIC_SET_ID) + return ERROR_INV_SLICE_HDR_T; + /* discard slice if pic param is invalid */ + COPYTHECONTEXT(""SH: pic_parameter_set_id"", u4_temp); + ps_pps = &ps_dec->ps_pps[u4_temp]; + if(FALSE == ps_pps->u1_is_valid) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_seq = ps_pps->ps_sps; + if(!ps_seq) + return ERROR_INV_SLICE_HDR_T; + if(FALSE == ps_seq->u1_is_valid) + return ERROR_INV_SLICE_HDR_T; + + /* Get the frame num */ + u2_frame_num = ih264d_get_bits_h264(ps_bitstrm, + ps_seq->u1_bits_in_frm_num); + + + COPYTHECONTEXT(""SH: frame_num"", u2_frame_num); + if(!ps_dec->u1_first_slice_in_stream && (ps_dec->u4_first_slice_in_pic == 2)) + { + pocstruct_t *ps_prev_poc = &ps_dec->s_prev_pic_poc; + pocstruct_t *ps_cur_poc = &ps_dec->s_cur_pic_poc; + + ps_dec->u2_mbx = 0xffff; + ps_dec->u2_mby = 0; + + if((0 == u1_is_idr_slice) && ps_cur_slice->u1_nal_ref_idc) + ps_dec->u2_prev_ref_frame_num = ps_cur_slice->u2_frame_num; + + if(u1_is_idr_slice || ps_cur_slice->u1_mmco_equalto5) + ps_dec->u2_prev_ref_frame_num = 0; + + if(ps_dec->ps_cur_sps->u1_gaps_in_frame_num_value_allowed_flag) + { + ih264d_decode_gaps_in_frame_num(ps_dec, u2_frame_num); + } + + ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst; + ps_prev_poc->u2_frame_num = ps_cur_poc->u2_frame_num; + ps_prev_poc->u1_mmco_equalto5 = ps_cur_slice->u1_mmco_equalto5; + if(ps_cur_slice->u1_nal_ref_idc) + { + ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb; + ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb; + ps_prev_poc->i4_delta_pic_order_cnt_bottom = + ps_cur_poc->i4_delta_pic_order_cnt_bottom; + ps_prev_poc->i4_delta_pic_order_cnt[0] = + ps_cur_poc->i4_delta_pic_order_cnt[0]; + ps_prev_poc->i4_delta_pic_order_cnt[1] = + ps_cur_poc->i4_delta_pic_order_cnt[1]; + ps_prev_poc->u1_bot_field = ps_cur_poc->u1_bot_field; + } + + ps_dec->u2_total_mbs_coded = 0; + } + /* Get the field related flags */ + if(!ps_seq->u1_frame_mbs_only_flag) + { + + u1_field_pic_flag = ih264d_get_bit_h264(ps_bitstrm); + COPYTHECONTEXT(""SH: field_pic_flag"", u1_field_pic_flag); + u1_bottom_field_flag = 0; + + if(u1_field_pic_flag) + { + ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan_fld; + u1_bottom_field_flag = ih264d_get_bit_h264(ps_bitstrm); + COPYTHECONTEXT(""SH: bottom_field_flag"", u1_bottom_field_flag); + + } + else + { + ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan; + } + } + else + { + u1_field_pic_flag = 0; + u1_bottom_field_flag = 0; + + ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan; + } + + u1_nal_unit_type = SLICE_NAL; + if(u1_is_idr_slice) + { + if(0 == u1_field_pic_flag) + { + ps_dec->u1_top_bottom_decoded = TOP_FIELD_ONLY | BOT_FIELD_ONLY; + } + u1_nal_unit_type = IDR_SLICE_NAL; + u4_idr_pic_id = ih264d_uev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + if(u4_idr_pic_id > 65535) + return ERROR_INV_SLICE_HDR_T; + COPYTHECONTEXT(""SH: "", u4_idr_pic_id); + } + + /* read delta pic order count information*/ + i_delta_poc[0] = i_delta_poc[1] = 0; + s_tmp_poc.i4_pic_order_cnt_lsb = 0; + s_tmp_poc.i4_delta_pic_order_cnt_bottom = 0; + u1_pic_order_cnt_type = ps_seq->u1_pic_order_cnt_type; + if(u1_pic_order_cnt_type == 0) + { + i_temp = ih264d_get_bits_h264( + ps_bitstrm, + ps_seq->u1_log2_max_pic_order_cnt_lsb_minus); + if(i_temp < 0 || i_temp >= ps_seq->i4_max_pic_order_cntLsb) + return ERROR_INV_SLICE_HDR_T; + s_tmp_poc.i4_pic_order_cnt_lsb = i_temp; + COPYTHECONTEXT(""SH: pic_order_cnt_lsb"", s_tmp_poc.i4_pic_order_cnt_lsb); + + if((ps_pps->u1_pic_order_present_flag == 1) && (!u1_field_pic_flag)) + { + s_tmp_poc.i4_delta_pic_order_cnt_bottom = ih264d_sev( + pu4_bitstrm_ofst, pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: delta_pic_order_cnt_bottom"", + s_tmp_poc.i4_delta_pic_order_cnt_bottom); + } + } + + s_tmp_poc.i4_delta_pic_order_cnt[0] = 0; + s_tmp_poc.i4_delta_pic_order_cnt[1] = 0; + if(u1_pic_order_cnt_type == 1 + && (!ps_seq->u1_delta_pic_order_always_zero_flag)) + { + s_tmp_poc.i4_delta_pic_order_cnt[0] = ih264d_sev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: delta_pic_order_cnt[0]"", + s_tmp_poc.i4_delta_pic_order_cnt[0]); + + if(ps_pps->u1_pic_order_present_flag && !u1_field_pic_flag) + { + s_tmp_poc.i4_delta_pic_order_cnt[1] = ih264d_sev( + pu4_bitstrm_ofst, pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: delta_pic_order_cnt[1]"", + s_tmp_poc.i4_delta_pic_order_cnt[1]); + } + } + + if(ps_pps->u1_redundant_pic_cnt_present_flag) + { + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if(u4_temp > MAX_REDUNDANT_PIC_CNT) + return ERROR_INV_SLICE_HDR_T; + u1_redundant_pic_cnt = u4_temp; + COPYTHECONTEXT(""SH: redundant_pic_cnt"", u1_redundant_pic_cnt); + } + + /*--------------------------------------------------------------------*/ + /* Check if the slice is part of new picture */ + /*--------------------------------------------------------------------*/ + /* First slice of a picture is always considered as part of new picture */ + + i1_is_end_of_poc = 1; + ps_dec->ps_dec_err_status->u1_err_flag &= MASK_REJECT_CUR_PIC; + + if(ps_dec->u4_first_slice_in_pic != 2) + { + i1_is_end_of_poc = ih264d_is_end_of_pic(u2_frame_num, u1_nal_ref_idc, + &s_tmp_poc, &ps_dec->s_cur_pic_poc, + ps_cur_slice, u1_pic_order_cnt_type, + u1_nal_unit_type, u4_idr_pic_id, + u1_field_pic_flag, + u1_bottom_field_flag); + if(i1_is_end_of_poc) + { + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_INCOMPLETE_FRAME; + } + + } + + /*--------------------------------------------------------------------*/ + /* Check for error in slice and parse the missing/corrupted MB's */ + /* as skip-MB's in an inserted P-slice */ + /*--------------------------------------------------------------------*/ + u1_mbaff = ps_seq->u1_mb_aff_flag && (!u1_field_pic_flag); + prev_slice_err = 0; + + if(i1_is_end_of_poc || ps_dec->u1_first_slice_in_stream) + { + if(u2_frame_num != ps_dec->u2_prv_frame_num + && ps_dec->u1_top_bottom_decoded != 0 + && ps_dec->u1_top_bottom_decoded + != (TOP_FIELD_ONLY | BOT_FIELD_ONLY)) + { + ps_dec->u1_dangling_field = 1; + if(ps_dec->u4_first_slice_in_pic) + { + prev_slice_err = 1; + } + else + { + prev_slice_err = 2; + } + + if(ps_dec->u1_top_bottom_decoded ==TOP_FIELD_ONLY) + ps_cur_slice->u1_bottom_field_flag = 1; + else + ps_cur_slice->u1_bottom_field_flag = 0; + + num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + - ps_dec->u2_total_mbs_coded; + ps_cur_poc = &ps_dec->s_cur_pic_poc; + + + u1_is_idr_slice = ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL; + } + else if(ps_dec->u4_first_slice_in_pic == 2) + { + if(u2_first_mb_in_slice > 0) + { + prev_slice_err = 1; + num_mb_skipped = u2_first_mb_in_slice << u1_mbaff; + ps_cur_poc = &s_tmp_poc; + + ps_cur_slice->u4_idr_pic_id = u4_idr_pic_id; + ps_cur_slice->u1_field_pic_flag = u1_field_pic_flag; + ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag; + ps_cur_slice->i4_pic_order_cnt_lsb = + s_tmp_poc.i4_pic_order_cnt_lsb; + ps_cur_slice->u1_nal_unit_type = u1_nal_unit_type; + ps_cur_slice->u1_redundant_pic_cnt = u1_redundant_pic_cnt; + ps_cur_slice->u1_nal_ref_idc = u1_nal_ref_idc; + ps_cur_slice->u1_pic_order_cnt_type = u1_pic_order_cnt_type; + ps_cur_slice->u1_mbaff_frame_flag = ps_seq->u1_mb_aff_flag + && (!u1_field_pic_flag); + } + + } + else + { + if(ps_dec->u4_first_slice_in_pic) + { + /* if valid slice header is not decoded do start of pic processing + * since in the current process call, frame num is not updated in the slice structure yet + * ih264d_is_end_of_pic is checked with valid frame num of previous process call, + * although i1_is_end_of_poc is set there could be more slices in the frame, + * so conceal only till cur slice */ + prev_slice_err = 1; + num_mb_skipped = u2_first_mb_in_slice << u1_mbaff; + } + else + { + /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame + * completely */ + prev_slice_err = 2; + num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + - ps_dec->u2_total_mbs_coded; + } + ps_cur_poc = &s_tmp_poc; + } + } + else + { + if((u2_first_mb_in_slice << u1_mbaff) > ps_dec->u2_total_mbs_coded) + { + prev_slice_err = 2; + num_mb_skipped = (u2_first_mb_in_slice << u1_mbaff) + - ps_dec->u2_total_mbs_coded; + ps_cur_poc = &s_tmp_poc; + } + else if((u2_first_mb_in_slice << u1_mbaff) < ps_dec->u2_total_mbs_coded) + { + return ERROR_CORRUPTED_SLICE; + } + } + + if(prev_slice_err) + { + ret = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, u1_is_idr_slice, u2_frame_num, ps_cur_poc, prev_slice_err); + + if(ps_dec->u1_dangling_field == 1) + { + ps_dec->u1_second_field = 1 - ps_dec->u1_second_field; + ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag; + ps_dec->u2_prv_frame_num = u2_frame_num; + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_DANGLING_FIELD_IN_PIC; + } + + if(prev_slice_err == 2) + { + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_INCOMPLETE_FRAME; + } + + if(ps_dec->u2_total_mbs_coded + >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + /* return if all MBs in frame are parsed*/ + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_IN_LAST_SLICE_OF_PIC; + } + + if(ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) + { + ih264d_err_pic_dispbuf_mgr(ps_dec); + return ERROR_NEW_FRAME_EXPECTED; + } + + if(ret != OK) + return ret; + + i1_is_end_of_poc = 0; + } + + if (ps_dec->u4_first_slice_in_pic == 0) + { + ps_dec->ps_parse_cur_slice++; + ps_dec->u2_cur_slice_num++; + } + + if((ps_dec->u1_separate_parse == 0) && (ps_dec->u4_first_slice_in_pic == 0)) + { + ps_dec->ps_decode_cur_slice++; + } + ps_dec->u1_slice_header_done = 0; + + + if(u1_field_pic_flag) + { + ps_dec->u2_prv_frame_num = u2_frame_num; + } + + if(ps_cur_slice->u1_mmco_equalto5) + { + WORD32 i4_temp_poc; + WORD32 i4_top_field_order_poc, i4_bot_field_order_poc; + + if(!ps_cur_slice->u1_field_pic_flag) // or a complementary field pair + { + i4_top_field_order_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt; + i4_bot_field_order_poc = + ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + i4_temp_poc = MIN(i4_top_field_order_poc, + i4_bot_field_order_poc); + } + else if(!ps_cur_slice->u1_bottom_field_flag) + i4_temp_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt; + else + i4_temp_poc = ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + + ps_dec->ps_cur_pic->i4_top_field_order_cnt = i4_temp_poc + - ps_dec->ps_cur_pic->i4_top_field_order_cnt; + ps_dec->ps_cur_pic->i4_bottom_field_order_cnt = i4_temp_poc + - ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + + ps_dec->ps_cur_pic->i4_poc = i4_temp_poc; + ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc; + } + if(ps_dec->u4_first_slice_in_pic == 2) + { + ret = ih264d_decode_pic_order_cnt(u1_is_idr_slice, u2_frame_num, + &ps_dec->s_prev_pic_poc, + &s_tmp_poc, ps_cur_slice, ps_pps, + u1_nal_ref_idc, + u1_bottom_field_flag, + u1_field_pic_flag, &i4_poc); + if(ret != OK) + return ret; + /* Display seq no calculations */ + if(i4_poc >= ps_dec->i4_max_poc) + ps_dec->i4_max_poc = i4_poc; + /* IDR Picture or POC wrap around */ + if(i4_poc == 0) + { + ps_dec->i4_prev_max_display_seq = ps_dec->i4_prev_max_display_seq + + ps_dec->i4_max_poc + + ps_dec->u1_max_dec_frame_buffering + 1; + ps_dec->i4_max_poc = 0; + } + } + + /*--------------------------------------------------------------------*/ + /* Copy the values read from the bitstream to the slice header and then*/ + /* If the slice is first slice in picture, then do Start of Picture */ + /* processing. */ + /*--------------------------------------------------------------------*/ + ps_cur_slice->i4_delta_pic_order_cnt[0] = i_delta_poc[0]; + ps_cur_slice->i4_delta_pic_order_cnt[1] = i_delta_poc[1]; + ps_cur_slice->u4_idr_pic_id = u4_idr_pic_id; + ps_cur_slice->u2_first_mb_in_slice = u2_first_mb_in_slice; + ps_cur_slice->u1_field_pic_flag = u1_field_pic_flag; + ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag; + ps_cur_slice->u1_slice_type = u1_slice_type; + ps_cur_slice->i4_pic_order_cnt_lsb = s_tmp_poc.i4_pic_order_cnt_lsb; + + ps_cur_slice->u1_nal_unit_type = u1_nal_unit_type; + ps_cur_slice->u1_redundant_pic_cnt = u1_redundant_pic_cnt; + ps_cur_slice->u1_nal_ref_idc = u1_nal_ref_idc; + ps_cur_slice->u1_pic_order_cnt_type = u1_pic_order_cnt_type; + + if(ps_seq->u1_frame_mbs_only_flag) + ps_cur_slice->u1_direct_8x8_inference_flag = + ps_seq->u1_direct_8x8_inference_flag; + else + ps_cur_slice->u1_direct_8x8_inference_flag = 1; + + if(u1_slice_type == B_SLICE) + { + ps_cur_slice->u1_direct_spatial_mv_pred_flag = ih264d_get_bit_h264( + ps_bitstrm); + COPYTHECONTEXT(""SH: direct_spatial_mv_pred_flag"", + ps_cur_slice->u1_direct_spatial_mv_pred_flag); + + if(ps_cur_slice->u1_direct_spatial_mv_pred_flag) + ps_cur_slice->pf_decodeDirect = ih264d_decode_spatial_direct; + else + ps_cur_slice->pf_decodeDirect = ih264d_decode_temporal_direct; + if(!((ps_pps->ps_sps->u1_mb_aff_flag) && (!u1_field_pic_flag))) + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaffB; + } + else + { + if(!((ps_pps->ps_sps->u1_mb_aff_flag) && (!u1_field_pic_flag))) + + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff; + } + + if(ps_dec->u4_first_slice_in_pic == 2) + { + if(u2_first_mb_in_slice == 0) + { + ret = ih264d_start_of_pic(ps_dec, i4_poc, &s_tmp_poc, u2_frame_num, ps_pps); + if(ret != OK) + return ret; + } + + ps_dec->u4_output_present = 0; + + { + ih264d_get_next_display_field(ps_dec, + ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + /* If error code is non-zero then there is no buffer available for display, + hence avoid format conversion */ + + if(0 != ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = ps_dec->s_disp_frame_info.u4_y_ht; + } + else + ps_dec->u4_output_present = 1; + } + if(ps_dec->u1_separate_parse == 1) + { + if(ps_dec->u4_dec_thread_created == 0) + { + ithread_create(ps_dec->pv_dec_thread_handle, NULL, + (void *)ih264d_decode_picture_thread, + (void *)ps_dec); + + ps_dec->u4_dec_thread_created = 1; + } + + if((ps_dec->u4_num_cores == 3) && + ((ps_dec->u4_app_disable_deblk_frm == 0) || ps_dec->i1_recon_in_thread3_flag) + && (ps_dec->u4_bs_deblk_thread_created == 0)) + { + ps_dec->u4_start_recon_deblk = 0; + ithread_create(ps_dec->pv_bs_deblk_thread_handle, NULL, + (void *)ih264d_recon_deblk_thread, + (void *)ps_dec); + ps_dec->u4_bs_deblk_thread_created = 1; + } + } + + } + + /* INITIALIZATION of fn ptrs for MC and formMbPartInfo functions */ + { + UWORD8 uc_nofield_nombaff; + + + + uc_nofield_nombaff = ((ps_dec->ps_cur_slice->u1_field_pic_flag == 0) + && (ps_dec->ps_cur_slice->u1_mbaff_frame_flag == 0) + && (u1_slice_type != B_SLICE) + && (ps_dec->ps_cur_pps->u1_wted_pred_flag == 0)); + + /* Initialise MC and formMbPartInfo fn ptrs one time based on profile_idc */ + + if(uc_nofield_nombaff) + { + ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_bp; + ps_dec->p_motion_compensate = ih264d_motion_compensate_bp; + } + else + { + ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_mp; + ps_dec->p_motion_compensate = ih264d_motion_compensate_mp; + } + + + } + + /* + * Decide whether to decode the current picture or not + */ + { + dec_err_status_t * ps_err = ps_dec->ps_dec_err_status; + if(ps_err->u4_frm_sei_sync == u2_frame_num) + { + ps_err->u1_err_flag = ACCEPT_ALL_PICS; + ps_err->u4_frm_sei_sync = SYNC_FRM_DEFAULT; + } + ps_err->u4_cur_frm = u2_frame_num; + } + + /* Decision for decoding if the picture is to be skipped */ + { + WORD32 i4_skip_b_pic, i4_skip_p_pic; + + i4_skip_b_pic = (ps_dec->u4_skip_frm_mask & B_SLC_BIT) + && (B_SLICE == u1_slice_type) && (0 == u1_nal_ref_idc); + + i4_skip_p_pic = (ps_dec->u4_skip_frm_mask & P_SLC_BIT) + && (P_SLICE == u1_slice_type) && (0 == u1_nal_ref_idc); + + /**************************************************************/ + /* Skip the B picture if skip mask is set for B picture and */ + /* Current B picture is a non reference B picture or there is */ + /* no user for reference B picture */ + /**************************************************************/ + if(i4_skip_b_pic) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= B_SLC_BIT; + /* Don't decode the picture in SKIP-B mode if that picture is B */ + /* and also it is not to be used as a reference picture */ + ps_dec->u1_last_pic_not_decoded = 1; + + return OK; + } + /**************************************************************/ + /* Skip the P picture if skip mask is set for P picture and */ + /* Current P picture is a non reference P picture or there is */ + /* no user for reference P picture */ + /**************************************************************/ + if(i4_skip_p_pic) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= P_SLC_BIT; + /* Don't decode the picture in SKIP-P mode if that picture is P */ + /* and also it is not to be used as a reference picture */ + ps_dec->u1_last_pic_not_decoded = 1; + + return OK; + } + } + + { + UWORD16 u2_mb_x, u2_mb_y; + + ps_dec->i4_submb_ofst = ((u2_first_mb_in_slice + << ps_cur_slice->u1_mbaff_frame_flag) * SUB_BLK_SIZE) + - SUB_BLK_SIZE; + if(u2_first_mb_in_slice) + { + UWORD8 u1_mb_aff; + UWORD8 u1_field_pic; + UWORD16 u2_frm_wd_in_mbs; + u2_frm_wd_in_mbs = ps_seq->u2_frm_wd_in_mbs; + u1_mb_aff = ps_cur_slice->u1_mbaff_frame_flag; + u1_field_pic = ps_cur_slice->u1_field_pic_flag; + + { + UWORD32 x_offset; + UWORD32 y_offset; + UWORD32 u4_frame_stride; + tfr_ctxt_t *ps_trns_addr; // = &ps_dec->s_tran_addrecon_parse; + + if(ps_dec->u1_separate_parse) + { + ps_trns_addr = &ps_dec->s_tran_addrecon_parse; + } + else + { + ps_trns_addr = &ps_dec->s_tran_addrecon; + } + u2_mb_x = MOD(u2_first_mb_in_slice, u2_frm_wd_in_mbs); + u2_mb_y = DIV(u2_first_mb_in_slice, u2_frm_wd_in_mbs); + + u2_mb_y <<= u1_mb_aff; + + if((u2_mb_x > u2_frm_wd_in_mbs - 1) + || (u2_mb_y > ps_dec->u2_frm_ht_in_mbs - 1)) + { + return ERROR_CORRUPTED_SLICE; + } + + u4_frame_stride = ps_dec->u2_frm_wd_y << u1_field_pic; + x_offset = u2_mb_x << 4; + y_offset = (u2_mb_y * u4_frame_stride) << 4; + + ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1 + x_offset + + y_offset; + + u4_frame_stride = ps_dec->u2_frm_wd_uv << u1_field_pic; + x_offset >>= 1; + y_offset = (u2_mb_y * u4_frame_stride) << 3; + + x_offset *= YUV420SP_FACTOR; + + ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2 + x_offset + + y_offset; + ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3 + x_offset + + y_offset; + + ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y; + ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u; + ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v; + + + if(ps_dec->u1_separate_parse == 1) + { + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic + + (u2_first_mb_in_slice << u1_mb_aff); + } + else + { + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic + + (u2_first_mb_in_slice << u1_mb_aff); + } + + ps_dec->u2_cur_mb_addr = (u2_first_mb_in_slice << u1_mb_aff); + + ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv + + ((u2_first_mb_in_slice << u1_mb_aff) << 4); + } + } + else + { + tfr_ctxt_t *ps_trns_addr; + + if(ps_dec->u1_separate_parse) + { + ps_trns_addr = &ps_dec->s_tran_addrecon_parse; + } + else + { + ps_trns_addr = &ps_dec->s_tran_addrecon; + } + + u2_mb_x = 0xffff; + u2_mb_y = 0; + ps_dec->u2_cur_mb_addr = 0; + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic; + ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv; + ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1; + ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2; + ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3; + + ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y; + ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u; + ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v; + + } + + ps_dec->ps_part = ps_dec->ps_parse_part_params; + + ps_dec->u2_mbx = + (MOD(u2_first_mb_in_slice - 1, ps_seq->u2_frm_wd_in_mbs)); + ps_dec->u2_mby = + (DIV(u2_first_mb_in_slice - 1, ps_seq->u2_frm_wd_in_mbs)); + ps_dec->u2_mby <<= ps_cur_slice->u1_mbaff_frame_flag; + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + } + + /* RBSP stop bit is used for CABAC decoding*/ + ps_bitstrm->u4_max_ofst += ps_dec->ps_cur_pps->u1_entropy_coding_mode; + + ps_dec->u1_B = (u1_slice_type == B_SLICE); + ps_dec->u4_next_mb_skip = 0; + + ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice = + ps_dec->ps_cur_slice->u2_first_mb_in_slice; + ps_dec->ps_parse_cur_slice->slice_type = + ps_dec->ps_cur_slice->u1_slice_type; + + + ps_dec->u4_start_recon_deblk = 1; + { + WORD32 num_entries; + WORD32 size; + UWORD8 *pu1_buf; + + num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init); + num_entries = 2 * ((2 * num_entries) + 1); + + size = num_entries * sizeof(void *); + size += PAD_MAP_IDX_POC * sizeof(void *); + + pu1_buf = (UWORD8 *)ps_dec->pv_map_ref_idx_to_poc_buf; + pu1_buf += size * ps_dec->u2_cur_slice_num; + ps_dec->ps_parse_cur_slice->ppv_map_ref_idx_to_poc = ( void *)pu1_buf; + } + + if(ps_dec->u1_separate_parse) + { + ps_dec->ps_parse_cur_slice->pv_tu_coeff_data_start = ps_dec->pv_parse_tu_coeff_data; + } + else + { + ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_parse_tu_coeff_data; + } + + if(u1_slice_type == I_SLICE) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= I_SLC_BIT; + + ret = ih264d_parse_islice(ps_dec, u2_first_mb_in_slice); + + if(ps_dec->i4_pic_type != B_SLICE && ps_dec->i4_pic_type != P_SLICE) + ps_dec->i4_pic_type = I_SLICE; + + } + else if(u1_slice_type == P_SLICE) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= P_SLC_BIT; + ret = ih264d_parse_pslice(ps_dec, u2_first_mb_in_slice); + ps_dec->u1_pr_sl_type = u1_slice_type; + if(ps_dec->i4_pic_type != B_SLICE) + ps_dec->i4_pic_type = P_SLICE; + } + else if(u1_slice_type == B_SLICE) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= B_SLC_BIT; + ret = ih264d_parse_bslice(ps_dec, u2_first_mb_in_slice); + ps_dec->u1_pr_sl_type = u1_slice_type; + ps_dec->i4_pic_type = B_SLICE; + } + else + return ERROR_INV_SLC_TYPE_T; + + + if(ps_dec->u1_slice_header_done) + { + /* set to zero to indicate a valid slice has been decoded */ + /* first slice header successfully decoded */ + ps_dec->u4_first_slice_in_pic = 0; + ps_dec->u1_first_slice_in_stream = 0; + } + + if(ret != OK) + return ret; + + /* storing last Mb X and MbY of the slice */ + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + + /* End of Picture detection */ + + if(ps_dec->u2_total_mbs_coded >= (ps_seq->u2_max_mb_addr + 1)) + { + ps_dec->u1_pic_decode_done = 1; + + } + + { + dec_err_status_t * ps_err = ps_dec->ps_dec_err_status; + if((ps_err->u1_err_flag & REJECT_PB_PICS) + && (ps_err->u1_cur_pic_type == PIC_TYPE_I)) + { + ps_err->u1_err_flag = ACCEPT_ALL_PICS; + } + } + + PRINT_BIN_BIT_RATIO(ps_dec) + + return ret; +} +",1,"WORD32 ih264d_parse_decode_slice(UWORD8 u1_is_idr_slice, + UWORD8 u1_nal_ref_idc, + dec_struct_t *ps_dec /* Decoder parameters */ + ) +{ + dec_bit_stream_t * ps_bitstrm = ps_dec->ps_bitstrm; + dec_pic_params_t *ps_pps; + dec_seq_params_t *ps_seq; + dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice; + pocstruct_t s_tmp_poc; + WORD32 i_delta_poc[2]; + WORD32 i4_poc = 0; + UWORD16 u2_first_mb_in_slice, u2_frame_num; + UWORD8 u1_field_pic_flag, u1_redundant_pic_cnt = 0, u1_slice_type; + UWORD32 u4_idr_pic_id = 0; + UWORD8 u1_bottom_field_flag, u1_pic_order_cnt_type; + + UWORD8 u1_nal_unit_type; + UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer; + UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst; + WORD8 i1_is_end_of_poc; + + WORD32 ret, end_of_frame; + WORD32 prev_slice_err, num_mb_skipped; + UWORD8 u1_mbaff; + pocstruct_t *ps_cur_poc; + + UWORD32 u4_temp; + WORD32 i_temp; + UWORD32 u4_call_end_of_pic = 0; + + /* read FirstMbInSlice and slice type*/ + ps_dec->ps_dpb_cmds->u1_dpb_commands_read_slc = 0; + u2_first_mb_in_slice = ih264d_uev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + if(u2_first_mb_in_slice + > (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)) + { + + return ERROR_CORRUPTED_SLICE; + } + + /*we currently don not support ASO*/ + if(((u2_first_mb_in_slice << ps_cur_slice->u1_mbaff_frame_flag) + <= ps_dec->u2_cur_mb_addr) && (ps_dec->u4_first_slice_in_pic == 0)) + { + return ERROR_CORRUPTED_SLICE; + } + + COPYTHECONTEXT(""SH: first_mb_in_slice"",u2_first_mb_in_slice); + + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + + if(u4_temp > 9) + return ERROR_INV_SLC_TYPE_T; + + u1_slice_type = u4_temp; + COPYTHECONTEXT(""SH: slice_type"",(u1_slice_type)); + ps_dec->u1_sl_typ_5_9 = 0; + /* Find Out the Slice Type is 5 to 9 or not then Set the Flag */ + /* u1_sl_typ_5_9 = 1 .Which tells that all the slices in the Pic*/ + /* will be of same type of current */ + if(u1_slice_type > 4) + { + u1_slice_type -= 5; + ps_dec->u1_sl_typ_5_9 = 1; + } + + { + UWORD32 skip; + + if((ps_dec->i4_app_skip_mode == IVD_SKIP_PB) + || (ps_dec->i4_dec_skip_mode == IVD_SKIP_PB)) + { + UWORD32 u4_bit_stream_offset = 0; + + if(ps_dec->u1_nal_unit_type == IDR_SLICE_NAL) + { + skip = 0; + + ps_dec->i4_dec_skip_mode = IVD_SKIP_NONE; + } + else if((I_SLICE == u1_slice_type) + && (1 >= ps_dec->ps_cur_sps->u1_num_ref_frames)) + { + skip = 0; + + ps_dec->i4_dec_skip_mode = IVD_SKIP_NONE; + } + else + { + skip = 1; + } + + /* If one frame worth of data is already skipped, do not skip the next one */ + if((0 == u2_first_mb_in_slice) && (1 == ps_dec->u4_prev_nal_skipped)) + { + skip = 0; + } + + if(skip) + { + ps_dec->u4_prev_nal_skipped = 1; + ps_dec->i4_dec_skip_mode = IVD_SKIP_PB; + return 0; + } + else + { + /* If the previous NAL was skipped, then + do not process that buffer in this call. + Return to app and process it in the next call. + This is necessary to handle cases where I/IDR is not complete in + the current buffer and application intends to fill the remaining part of the bitstream + later. This ensures we process only frame worth of data in every call */ + if(1 == ps_dec->u4_prev_nal_skipped) + { + ps_dec->u4_return_to_app = 1; + return 0; + } + } + } + + } + + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if(u4_temp & MASK_ERR_PIC_SET_ID) + return ERROR_INV_SLICE_HDR_T; + /* discard slice if pic param is invalid */ + COPYTHECONTEXT(""SH: pic_parameter_set_id"", u4_temp); + ps_pps = &ps_dec->ps_pps[u4_temp]; + if(FALSE == ps_pps->u1_is_valid) + { + return ERROR_INV_SLICE_HDR_T; + } + ps_seq = ps_pps->ps_sps; + if(!ps_seq) + return ERROR_INV_SLICE_HDR_T; + if(FALSE == ps_seq->u1_is_valid) + return ERROR_INV_SLICE_HDR_T; + + /* Get the frame num */ + u2_frame_num = ih264d_get_bits_h264(ps_bitstrm, + ps_seq->u1_bits_in_frm_num); + + + COPYTHECONTEXT(""SH: frame_num"", u2_frame_num); + if(!ps_dec->u1_first_slice_in_stream && ps_dec->u4_first_slice_in_pic) + { + pocstruct_t *ps_prev_poc = &ps_dec->s_prev_pic_poc; + pocstruct_t *ps_cur_poc = &ps_dec->s_cur_pic_poc; + + ps_dec->u2_mbx = 0xffff; + ps_dec->u2_mby = 0; + + if((0 == u1_is_idr_slice) && ps_cur_slice->u1_nal_ref_idc) + ps_dec->u2_prev_ref_frame_num = ps_cur_slice->u2_frame_num; + + if(u1_is_idr_slice || ps_cur_slice->u1_mmco_equalto5) + ps_dec->u2_prev_ref_frame_num = 0; + + if(ps_dec->ps_cur_sps->u1_gaps_in_frame_num_value_allowed_flag) + { + ih264d_decode_gaps_in_frame_num(ps_dec, u2_frame_num); + } + + ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst; + ps_prev_poc->u2_frame_num = ps_cur_poc->u2_frame_num; + ps_prev_poc->u1_mmco_equalto5 = ps_cur_slice->u1_mmco_equalto5; + if(ps_cur_slice->u1_nal_ref_idc) + { + ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb; + ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb; + ps_prev_poc->i4_delta_pic_order_cnt_bottom = + ps_cur_poc->i4_delta_pic_order_cnt_bottom; + ps_prev_poc->i4_delta_pic_order_cnt[0] = + ps_cur_poc->i4_delta_pic_order_cnt[0]; + ps_prev_poc->i4_delta_pic_order_cnt[1] = + ps_cur_poc->i4_delta_pic_order_cnt[1]; + ps_prev_poc->u1_bot_field = ps_cur_poc->u1_bot_field; + } + + ps_dec->u2_total_mbs_coded = 0; + } + /* Get the field related flags */ + if(!ps_seq->u1_frame_mbs_only_flag) + { + + u1_field_pic_flag = ih264d_get_bit_h264(ps_bitstrm); + COPYTHECONTEXT(""SH: field_pic_flag"", u1_field_pic_flag); + u1_bottom_field_flag = 0; + + if(u1_field_pic_flag) + { + ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan_fld; + u1_bottom_field_flag = ih264d_get_bit_h264(ps_bitstrm); + COPYTHECONTEXT(""SH: bottom_field_flag"", u1_bottom_field_flag); + + } + else + { + ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan; + } + } + else + { + u1_field_pic_flag = 0; + u1_bottom_field_flag = 0; + + ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan; + } + + u1_nal_unit_type = SLICE_NAL; + if(u1_is_idr_slice) + { + if(0 == u1_field_pic_flag) + { + ps_dec->u1_top_bottom_decoded = TOP_FIELD_ONLY | BOT_FIELD_ONLY; + } + u1_nal_unit_type = IDR_SLICE_NAL; + u4_idr_pic_id = ih264d_uev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + if(u4_idr_pic_id > 65535) + return ERROR_INV_SLICE_HDR_T; + COPYTHECONTEXT(""SH: "", u4_idr_pic_id); + } + + /* read delta pic order count information*/ + i_delta_poc[0] = i_delta_poc[1] = 0; + s_tmp_poc.i4_pic_order_cnt_lsb = 0; + s_tmp_poc.i4_delta_pic_order_cnt_bottom = 0; + u1_pic_order_cnt_type = ps_seq->u1_pic_order_cnt_type; + if(u1_pic_order_cnt_type == 0) + { + i_temp = ih264d_get_bits_h264( + ps_bitstrm, + ps_seq->u1_log2_max_pic_order_cnt_lsb_minus); + if(i_temp < 0 || i_temp >= ps_seq->i4_max_pic_order_cntLsb) + return ERROR_INV_SLICE_HDR_T; + s_tmp_poc.i4_pic_order_cnt_lsb = i_temp; + COPYTHECONTEXT(""SH: pic_order_cnt_lsb"", s_tmp_poc.i4_pic_order_cnt_lsb); + + if((ps_pps->u1_pic_order_present_flag == 1) && (!u1_field_pic_flag)) + { + s_tmp_poc.i4_delta_pic_order_cnt_bottom = ih264d_sev( + pu4_bitstrm_ofst, pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: delta_pic_order_cnt_bottom"", + s_tmp_poc.i4_delta_pic_order_cnt_bottom); + } + } + + s_tmp_poc.i4_delta_pic_order_cnt[0] = 0; + s_tmp_poc.i4_delta_pic_order_cnt[1] = 0; + if(u1_pic_order_cnt_type == 1 + && (!ps_seq->u1_delta_pic_order_always_zero_flag)) + { + s_tmp_poc.i4_delta_pic_order_cnt[0] = ih264d_sev(pu4_bitstrm_ofst, + pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: delta_pic_order_cnt[0]"", + s_tmp_poc.i4_delta_pic_order_cnt[0]); + + if(ps_pps->u1_pic_order_present_flag && !u1_field_pic_flag) + { + s_tmp_poc.i4_delta_pic_order_cnt[1] = ih264d_sev( + pu4_bitstrm_ofst, pu4_bitstrm_buf); + COPYTHECONTEXT(""SH: delta_pic_order_cnt[1]"", + s_tmp_poc.i4_delta_pic_order_cnt[1]); + } + } + + if(ps_pps->u1_redundant_pic_cnt_present_flag) + { + u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf); + if(u4_temp > MAX_REDUNDANT_PIC_CNT) + return ERROR_INV_SLICE_HDR_T; + u1_redundant_pic_cnt = u4_temp; + COPYTHECONTEXT(""SH: redundant_pic_cnt"", u1_redundant_pic_cnt); + } + + /*--------------------------------------------------------------------*/ + /* Check if the slice is part of new picture */ + /*--------------------------------------------------------------------*/ + /* First slice of a picture is always considered as part of new picture */ + + i1_is_end_of_poc = 1; + ps_dec->ps_dec_err_status->u1_err_flag &= MASK_REJECT_CUR_PIC; + + if(ps_dec->u4_first_slice_in_pic == 0) + { + i1_is_end_of_poc = ih264d_is_end_of_pic(u2_frame_num, u1_nal_ref_idc, + &s_tmp_poc, &ps_dec->s_cur_pic_poc, + ps_cur_slice, u1_pic_order_cnt_type, + u1_nal_unit_type, u4_idr_pic_id, + u1_field_pic_flag, + u1_bottom_field_flag); + if(i1_is_end_of_poc) + { + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_INCOMPLETE_FRAME; + } + + } + + /*--------------------------------------------------------------------*/ + /* Check for error in slice and parse the missing/corrupted MB's */ + /* as skip-MB's in an inserted P-slice */ + /*--------------------------------------------------------------------*/ + u1_mbaff = ps_seq->u1_mb_aff_flag && (!u1_field_pic_flag); + prev_slice_err = 0; + + if(i1_is_end_of_poc || ps_dec->u1_first_slice_in_stream) + { + if(u2_frame_num != ps_dec->u2_prv_frame_num + && ps_dec->u1_top_bottom_decoded != 0 + && ps_dec->u1_top_bottom_decoded + != (TOP_FIELD_ONLY | BOT_FIELD_ONLY)) + { + ps_dec->u1_dangling_field = 1; + if(ps_dec->u4_first_slice_in_pic) + { + prev_slice_err = 1; + } + else + { + prev_slice_err = 2; + } + + if(ps_dec->u1_top_bottom_decoded ==TOP_FIELD_ONLY) + ps_cur_slice->u1_bottom_field_flag = 1; + else + ps_cur_slice->u1_bottom_field_flag = 0; + + num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + - ps_dec->u2_total_mbs_coded; + ps_cur_poc = &ps_dec->s_cur_pic_poc; + + + u1_is_idr_slice = ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL; + } + else if(ps_dec->u4_first_slice_in_pic) + { + if(u2_first_mb_in_slice > 0) + { + prev_slice_err = 1; + num_mb_skipped = u2_first_mb_in_slice << u1_mbaff; + ps_cur_poc = &s_tmp_poc; + + ps_cur_slice->u4_idr_pic_id = u4_idr_pic_id; + ps_cur_slice->u1_field_pic_flag = u1_field_pic_flag; + ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag; + ps_cur_slice->i4_pic_order_cnt_lsb = + s_tmp_poc.i4_pic_order_cnt_lsb; + ps_cur_slice->u1_nal_unit_type = u1_nal_unit_type; + ps_cur_slice->u1_redundant_pic_cnt = u1_redundant_pic_cnt; + ps_cur_slice->u1_nal_ref_idc = u1_nal_ref_idc; + ps_cur_slice->u1_pic_order_cnt_type = u1_pic_order_cnt_type; + ps_cur_slice->u1_mbaff_frame_flag = ps_seq->u1_mb_aff_flag + && (!u1_field_pic_flag); + } + + } + else + { + /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame + * completely */ + prev_slice_err = 2; + num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs + * ps_dec->u2_frm_wd_in_mbs) + - ps_dec->u2_total_mbs_coded; + ps_cur_poc = &s_tmp_poc; + } + } + else + { + if((u2_first_mb_in_slice << u1_mbaff) > ps_dec->u2_total_mbs_coded) + { + prev_slice_err = 2; + num_mb_skipped = (u2_first_mb_in_slice << u1_mbaff) + - ps_dec->u2_total_mbs_coded; + ps_cur_poc = &s_tmp_poc; + } + else if((u2_first_mb_in_slice << u1_mbaff) < ps_dec->u2_total_mbs_coded) + { + return ERROR_CORRUPTED_SLICE; + } + } + + if(prev_slice_err) + { + ret = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, u1_is_idr_slice, u2_frame_num, ps_cur_poc, prev_slice_err); + + if(ps_dec->u1_dangling_field == 1) + { + ps_dec->u1_second_field = 1 - ps_dec->u1_second_field; + ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag; + ps_dec->u2_prv_frame_num = u2_frame_num; + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_DANGLING_FIELD_IN_PIC; + } + + if(prev_slice_err == 2) + { + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_INCOMPLETE_FRAME; + } + + if(ps_dec->u2_total_mbs_coded + >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) + { + /* return if all MBs in frame are parsed*/ + ps_dec->u1_first_slice_in_stream = 0; + return ERROR_IN_LAST_SLICE_OF_PIC; + } + + if(ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) + { + ih264d_err_pic_dispbuf_mgr(ps_dec); + return ERROR_NEW_FRAME_EXPECTED; + } + + if(ret != OK) + return ret; + + i1_is_end_of_poc = 0; + } + + if (ps_dec->u4_first_slice_in_pic == 0) + { + ps_dec->ps_parse_cur_slice++; + ps_dec->u2_cur_slice_num++; + } + + if((ps_dec->u1_separate_parse == 0) && (ps_dec->u4_first_slice_in_pic == 0)) + { + ps_dec->ps_decode_cur_slice++; + } + ps_dec->u1_slice_header_done = 0; + + + if(u1_field_pic_flag) + { + ps_dec->u2_prv_frame_num = u2_frame_num; + } + + if(ps_cur_slice->u1_mmco_equalto5) + { + WORD32 i4_temp_poc; + WORD32 i4_top_field_order_poc, i4_bot_field_order_poc; + + if(!ps_cur_slice->u1_field_pic_flag) // or a complementary field pair + { + i4_top_field_order_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt; + i4_bot_field_order_poc = + ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + i4_temp_poc = MIN(i4_top_field_order_poc, + i4_bot_field_order_poc); + } + else if(!ps_cur_slice->u1_bottom_field_flag) + i4_temp_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt; + else + i4_temp_poc = ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + + ps_dec->ps_cur_pic->i4_top_field_order_cnt = i4_temp_poc + - ps_dec->ps_cur_pic->i4_top_field_order_cnt; + ps_dec->ps_cur_pic->i4_bottom_field_order_cnt = i4_temp_poc + - ps_dec->ps_cur_pic->i4_bottom_field_order_cnt; + + ps_dec->ps_cur_pic->i4_poc = i4_temp_poc; + ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc; + } + if(ps_dec->u4_first_slice_in_pic) + { + ret = ih264d_decode_pic_order_cnt(u1_is_idr_slice, u2_frame_num, + &ps_dec->s_prev_pic_poc, + &s_tmp_poc, ps_cur_slice, ps_pps, + u1_nal_ref_idc, + u1_bottom_field_flag, + u1_field_pic_flag, &i4_poc); + if(ret != OK) + return ret; + /* Display seq no calculations */ + if(i4_poc >= ps_dec->i4_max_poc) + ps_dec->i4_max_poc = i4_poc; + /* IDR Picture or POC wrap around */ + if(i4_poc == 0) + { + ps_dec->i4_prev_max_display_seq = ps_dec->i4_prev_max_display_seq + + ps_dec->i4_max_poc + + ps_dec->u1_max_dec_frame_buffering + 1; + ps_dec->i4_max_poc = 0; + } + } + + /*--------------------------------------------------------------------*/ + /* Copy the values read from the bitstream to the slice header and then*/ + /* If the slice is first slice in picture, then do Start of Picture */ + /* processing. */ + /*--------------------------------------------------------------------*/ + ps_cur_slice->i4_delta_pic_order_cnt[0] = i_delta_poc[0]; + ps_cur_slice->i4_delta_pic_order_cnt[1] = i_delta_poc[1]; + ps_cur_slice->u4_idr_pic_id = u4_idr_pic_id; + ps_cur_slice->u2_first_mb_in_slice = u2_first_mb_in_slice; + ps_cur_slice->u1_field_pic_flag = u1_field_pic_flag; + ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag; + ps_cur_slice->u1_slice_type = u1_slice_type; + ps_cur_slice->i4_pic_order_cnt_lsb = s_tmp_poc.i4_pic_order_cnt_lsb; + + ps_cur_slice->u1_nal_unit_type = u1_nal_unit_type; + ps_cur_slice->u1_redundant_pic_cnt = u1_redundant_pic_cnt; + ps_cur_slice->u1_nal_ref_idc = u1_nal_ref_idc; + ps_cur_slice->u1_pic_order_cnt_type = u1_pic_order_cnt_type; + + if(ps_seq->u1_frame_mbs_only_flag) + ps_cur_slice->u1_direct_8x8_inference_flag = + ps_seq->u1_direct_8x8_inference_flag; + else + ps_cur_slice->u1_direct_8x8_inference_flag = 1; + + if(u1_slice_type == B_SLICE) + { + ps_cur_slice->u1_direct_spatial_mv_pred_flag = ih264d_get_bit_h264( + ps_bitstrm); + COPYTHECONTEXT(""SH: direct_spatial_mv_pred_flag"", + ps_cur_slice->u1_direct_spatial_mv_pred_flag); + + if(ps_cur_slice->u1_direct_spatial_mv_pred_flag) + ps_cur_slice->pf_decodeDirect = ih264d_decode_spatial_direct; + else + ps_cur_slice->pf_decodeDirect = ih264d_decode_temporal_direct; + if(!((ps_pps->ps_sps->u1_mb_aff_flag) && (!u1_field_pic_flag))) + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaffB; + } + else + { + if(!((ps_pps->ps_sps->u1_mb_aff_flag) && (!u1_field_pic_flag))) + + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff; + } + + if(ps_dec->u4_first_slice_in_pic) + { + if(u2_first_mb_in_slice == 0) + { + ret = ih264d_start_of_pic(ps_dec, i4_poc, &s_tmp_poc, u2_frame_num, ps_pps); + if(ret != OK) + return ret; + } + + ps_dec->u4_output_present = 0; + + { + ih264d_get_next_display_field(ps_dec, + ps_dec->ps_out_buffer, + &(ps_dec->s_disp_op)); + /* If error code is non-zero then there is no buffer available for display, + hence avoid format conversion */ + + if(0 != ps_dec->s_disp_op.u4_error_code) + { + ps_dec->u4_fmt_conv_cur_row = ps_dec->s_disp_frame_info.u4_y_ht; + } + else + ps_dec->u4_output_present = 1; + } + if(ps_dec->u1_separate_parse == 1) + { + if(ps_dec->u4_dec_thread_created == 0) + { + ithread_create(ps_dec->pv_dec_thread_handle, NULL, + (void *)ih264d_decode_picture_thread, + (void *)ps_dec); + + ps_dec->u4_dec_thread_created = 1; + } + + if((ps_dec->u4_num_cores == 3) && + ((ps_dec->u4_app_disable_deblk_frm == 0) || ps_dec->i1_recon_in_thread3_flag) + && (ps_dec->u4_bs_deblk_thread_created == 0)) + { + ps_dec->u4_start_recon_deblk = 0; + ithread_create(ps_dec->pv_bs_deblk_thread_handle, NULL, + (void *)ih264d_recon_deblk_thread, + (void *)ps_dec); + ps_dec->u4_bs_deblk_thread_created = 1; + } + } + + } + + /* INITIALIZATION of fn ptrs for MC and formMbPartInfo functions */ + { + UWORD8 uc_nofield_nombaff; + + + + uc_nofield_nombaff = ((ps_dec->ps_cur_slice->u1_field_pic_flag == 0) + && (ps_dec->ps_cur_slice->u1_mbaff_frame_flag == 0) + && (u1_slice_type != B_SLICE) + && (ps_dec->ps_cur_pps->u1_wted_pred_flag == 0)); + + /* Initialise MC and formMbPartInfo fn ptrs one time based on profile_idc */ + + if(uc_nofield_nombaff) + { + ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_bp; + ps_dec->p_motion_compensate = ih264d_motion_compensate_bp; + } + else + { + ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_mp; + ps_dec->p_motion_compensate = ih264d_motion_compensate_mp; + } + + + } + + /* + * Decide whether to decode the current picture or not + */ + { + dec_err_status_t * ps_err = ps_dec->ps_dec_err_status; + if(ps_err->u4_frm_sei_sync == u2_frame_num) + { + ps_err->u1_err_flag = ACCEPT_ALL_PICS; + ps_err->u4_frm_sei_sync = SYNC_FRM_DEFAULT; + } + ps_err->u4_cur_frm = u2_frame_num; + } + + /* Decision for decoding if the picture is to be skipped */ + { + WORD32 i4_skip_b_pic, i4_skip_p_pic; + + i4_skip_b_pic = (ps_dec->u4_skip_frm_mask & B_SLC_BIT) + && (B_SLICE == u1_slice_type) && (0 == u1_nal_ref_idc); + + i4_skip_p_pic = (ps_dec->u4_skip_frm_mask & P_SLC_BIT) + && (P_SLICE == u1_slice_type) && (0 == u1_nal_ref_idc); + + /**************************************************************/ + /* Skip the B picture if skip mask is set for B picture and */ + /* Current B picture is a non reference B picture or there is */ + /* no user for reference B picture */ + /**************************************************************/ + if(i4_skip_b_pic) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= B_SLC_BIT; + /* Don't decode the picture in SKIP-B mode if that picture is B */ + /* and also it is not to be used as a reference picture */ + ps_dec->u1_last_pic_not_decoded = 1; + + return OK; + } + /**************************************************************/ + /* Skip the P picture if skip mask is set for P picture and */ + /* Current P picture is a non reference P picture or there is */ + /* no user for reference P picture */ + /**************************************************************/ + if(i4_skip_p_pic) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= P_SLC_BIT; + /* Don't decode the picture in SKIP-P mode if that picture is P */ + /* and also it is not to be used as a reference picture */ + ps_dec->u1_last_pic_not_decoded = 1; + + return OK; + } + } + + { + UWORD16 u2_mb_x, u2_mb_y; + + ps_dec->i4_submb_ofst = ((u2_first_mb_in_slice + << ps_cur_slice->u1_mbaff_frame_flag) * SUB_BLK_SIZE) + - SUB_BLK_SIZE; + if(u2_first_mb_in_slice) + { + UWORD8 u1_mb_aff; + UWORD8 u1_field_pic; + UWORD16 u2_frm_wd_in_mbs; + u2_frm_wd_in_mbs = ps_seq->u2_frm_wd_in_mbs; + u1_mb_aff = ps_cur_slice->u1_mbaff_frame_flag; + u1_field_pic = ps_cur_slice->u1_field_pic_flag; + + { + UWORD32 x_offset; + UWORD32 y_offset; + UWORD32 u4_frame_stride; + tfr_ctxt_t *ps_trns_addr; // = &ps_dec->s_tran_addrecon_parse; + + if(ps_dec->u1_separate_parse) + { + ps_trns_addr = &ps_dec->s_tran_addrecon_parse; + } + else + { + ps_trns_addr = &ps_dec->s_tran_addrecon; + } + u2_mb_x = MOD(u2_first_mb_in_slice, u2_frm_wd_in_mbs); + u2_mb_y = DIV(u2_first_mb_in_slice, u2_frm_wd_in_mbs); + + u2_mb_y <<= u1_mb_aff; + + if((u2_mb_x > u2_frm_wd_in_mbs - 1) + || (u2_mb_y > ps_dec->u2_frm_ht_in_mbs - 1)) + { + return ERROR_CORRUPTED_SLICE; + } + + u4_frame_stride = ps_dec->u2_frm_wd_y << u1_field_pic; + x_offset = u2_mb_x << 4; + y_offset = (u2_mb_y * u4_frame_stride) << 4; + + ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1 + x_offset + + y_offset; + + u4_frame_stride = ps_dec->u2_frm_wd_uv << u1_field_pic; + x_offset >>= 1; + y_offset = (u2_mb_y * u4_frame_stride) << 3; + + x_offset *= YUV420SP_FACTOR; + + ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2 + x_offset + + y_offset; + ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3 + x_offset + + y_offset; + + ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y; + ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u; + ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v; + + + if(ps_dec->u1_separate_parse == 1) + { + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic + + (u2_first_mb_in_slice << u1_mb_aff); + } + else + { + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic + + (u2_first_mb_in_slice << u1_mb_aff); + } + + ps_dec->u2_cur_mb_addr = (u2_first_mb_in_slice << u1_mb_aff); + + ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv + + ((u2_first_mb_in_slice << u1_mb_aff) << 4); + } + } + else + { + tfr_ctxt_t *ps_trns_addr; + + if(ps_dec->u1_separate_parse) + { + ps_trns_addr = &ps_dec->s_tran_addrecon_parse; + } + else + { + ps_trns_addr = &ps_dec->s_tran_addrecon; + } + + u2_mb_x = 0xffff; + u2_mb_y = 0; + ps_dec->u2_cur_mb_addr = 0; + ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic; + ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv; + ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1; + ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2; + ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3; + + ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y; + ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u; + ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v; + + } + + ps_dec->ps_part = ps_dec->ps_parse_part_params; + + ps_dec->u2_mbx = + (MOD(u2_first_mb_in_slice - 1, ps_seq->u2_frm_wd_in_mbs)); + ps_dec->u2_mby = + (DIV(u2_first_mb_in_slice - 1, ps_seq->u2_frm_wd_in_mbs)); + ps_dec->u2_mby <<= ps_cur_slice->u1_mbaff_frame_flag; + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + } + + /* RBSP stop bit is used for CABAC decoding*/ + ps_bitstrm->u4_max_ofst += ps_dec->ps_cur_pps->u1_entropy_coding_mode; + + ps_dec->u1_B = (u1_slice_type == B_SLICE); + ps_dec->u4_next_mb_skip = 0; + + ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice = + ps_dec->ps_cur_slice->u2_first_mb_in_slice; + ps_dec->ps_parse_cur_slice->slice_type = + ps_dec->ps_cur_slice->u1_slice_type; + + + ps_dec->u4_start_recon_deblk = 1; + { + WORD32 num_entries; + WORD32 size; + UWORD8 *pu1_buf; + + num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init); + num_entries = 2 * ((2 * num_entries) + 1); + + size = num_entries * sizeof(void *); + size += PAD_MAP_IDX_POC * sizeof(void *); + + pu1_buf = (UWORD8 *)ps_dec->pv_map_ref_idx_to_poc_buf; + pu1_buf += size * ps_dec->u2_cur_slice_num; + ps_dec->ps_parse_cur_slice->ppv_map_ref_idx_to_poc = ( void *)pu1_buf; + } + + if(ps_dec->u1_separate_parse) + { + ps_dec->ps_parse_cur_slice->pv_tu_coeff_data_start = ps_dec->pv_parse_tu_coeff_data; + } + else + { + ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_parse_tu_coeff_data; + } + + if(u1_slice_type == I_SLICE) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= I_SLC_BIT; + + ret = ih264d_parse_islice(ps_dec, u2_first_mb_in_slice); + + if(ps_dec->i4_pic_type != B_SLICE && ps_dec->i4_pic_type != P_SLICE) + ps_dec->i4_pic_type = I_SLICE; + + } + else if(u1_slice_type == P_SLICE) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= P_SLC_BIT; + ret = ih264d_parse_pslice(ps_dec, u2_first_mb_in_slice); + ps_dec->u1_pr_sl_type = u1_slice_type; + if(ps_dec->i4_pic_type != B_SLICE) + ps_dec->i4_pic_type = P_SLICE; + } + else if(u1_slice_type == B_SLICE) + { + ps_dec->ps_cur_pic->u4_pack_slc_typ |= B_SLC_BIT; + ret = ih264d_parse_bslice(ps_dec, u2_first_mb_in_slice); + ps_dec->u1_pr_sl_type = u1_slice_type; + ps_dec->i4_pic_type = B_SLICE; + } + else + return ERROR_INV_SLC_TYPE_T; + + + if(ps_dec->u1_slice_header_done) + { + /* set to zero to indicate a valid slice has been decoded */ + ps_dec->u1_first_slice_in_stream = 0; + } + + if(ret != OK) + return ret; + + /* storing last Mb X and MbY of the slice */ + ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; + ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; + + /* End of Picture detection */ + + if(ps_dec->u2_total_mbs_coded >= (ps_seq->u2_max_mb_addr + 1)) + { + ps_dec->u1_pic_decode_done = 1; + + } + + { + dec_err_status_t * ps_err = ps_dec->ps_dec_err_status; + if((ps_err->u1_err_flag & REJECT_PB_PICS) + && (ps_err->u1_cur_pic_type == PIC_TYPE_I)) + { + ps_err->u1_err_flag = ACCEPT_ALL_PICS; + } + } + + PRINT_BIN_BIT_RATIO(ps_dec) + + return ret; +} +","@@ -737,6 +737,7 @@ + + ps_dec->u4_deblk_mb_y = 0; + ps_dec->pu4_wt_ofsts = ps_dec->pu4_wts_ofsts_mat; + ++ ps_dec->u4_first_slice_in_pic = 0; + H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex); + return OK; + } +@@ -1136,7 +1137,7 @@ + + + COPYTHECONTEXT(""SH: frame_num"", u2_frame_num); + // H264_DEC_DEBUG_PRINT(""Second field: %d frame num: %d prv_frame_num: %d \n"", ps_dec->u1_second_field, u2_frame_num, ps_dec->u2_prv_frame_num); +- if(!ps_dec->u1_first_slice_in_stream && (ps_dec->u4_first_slice_in_pic == 2)) ++ if(!ps_dec->u1_first_slice_in_stream && ps_dec->u4_first_slice_in_pic) + { + pocstruct_t *ps_prev_poc = &ps_dec->s_prev_pic_poc; + pocstruct_t *ps_cur_poc = &ps_dec->s_cur_pic_poc; +@@ -1276,7 +1277,7 @@ + + i1_is_end_of_poc = 1; + ps_dec->ps_dec_err_status->u1_err_flag &= MASK_REJECT_CUR_PIC; + +- if(ps_dec->u4_first_slice_in_pic != 2) ++ if(ps_dec->u4_first_slice_in_pic == 0) + { + i1_is_end_of_poc = ih264d_is_end_of_pic(u2_frame_num, u1_nal_ref_idc, + &s_tmp_poc, &ps_dec->s_cur_pic_poc, +@@ -1329,7 +1330,7 @@ + + + u1_is_idr_slice = ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL; + } +- else if(ps_dec->u4_first_slice_in_pic == 2) ++ else if(ps_dec->u4_first_slice_in_pic) + { + if(u2_first_mb_in_slice > 0) + { +@@ -1354,25 +1355,12 @@ + + } + else + { +- +- if(ps_dec->u4_first_slice_in_pic) +- { +- /* if valid slice header is not decoded do start of pic processing +- * since in the current process call, frame num is not updated in the slice structure yet +- * ih264d_is_end_of_pic is checked with valid frame num of previous process call, +- * although i1_is_end_of_poc is set there could be more slices in the frame, +- * so conceal only till cur slice */ +- prev_slice_err = 1; +- num_mb_skipped = u2_first_mb_in_slice << u1_mbaff; +- } +- else +- { +- /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame +- * completely */ +- prev_slice_err = 2; +- num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) +- - ps_dec->u2_total_mbs_coded; +- } ++ /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame ++ * completely */ ++ prev_slice_err = 2; ++ num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs ++ * ps_dec->u2_frm_wd_in_mbs) ++ - ps_dec->u2_total_mbs_coded; + ps_cur_poc = &s_tmp_poc; + } + } +@@ -1475,7 +1463,7 @@ + + ps_dec->ps_cur_pic->i4_poc = i4_temp_poc; + ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc; + } +- if(ps_dec->u4_first_slice_in_pic == 2) ++ if(ps_dec->u4_first_slice_in_pic) + { + ret = ih264d_decode_pic_order_cnt(u1_is_idr_slice, u2_frame_num, + &ps_dec->s_prev_pic_poc, +@@ -1543,7 +1531,7 @@ + + ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff; + } + +- if(ps_dec->u4_first_slice_in_pic == 2) ++ if(ps_dec->u4_first_slice_in_pic) + { + if(u2_first_mb_in_slice == 0) + { +@@ -1863,8 +1851,6 @@ + + if(ps_dec->u1_slice_header_done) + { + /* set to zero to indicate a valid slice has been decoded */ +- /* first slice header successfully decoded */ +- ps_dec->u4_first_slice_in_pic = 0; + ps_dec->u1_first_slice_in_stream = 0; + } + +",8540,8776,11000 +8570,"static int ssl_parse_client_hello( mbedtls_ssl_context *ssl ) +{ + int ret, got_common_suite; + size_t i, j; + size_t ciph_offset, comp_offset, ext_offset; + size_t msg_len, ciph_len, sess_len, comp_len, ext_len; +#if defined(MBEDTLS_SSL_PROTO_DTLS) + size_t cookie_offset, cookie_len; +#endif + unsigned char *buf, *p, *ext; +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renegotiation_info_seen = 0; +#endif + int handshake_failure = 0; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + int major, minor; + + /* If there is no signature-algorithm extension present, + * we need to fall back to the default values for allowed + * signature-hash pairs. */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + int sig_hash_alg_ext_present = 0; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""=> parse client hello"" ) ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +read_record_header: +#endif + /* + * If renegotiating, then the input was read with mbedtls_ssl_read_record(), + * otherwise read it ourselves manually in order to support SSLv2 + * ClientHello, which doesn't use the same record layer format. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + if( ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 ) + { + /* No alert on a read error. */ + MBEDTLS_SSL_DEBUG_RET( 1, ""mbedtls_ssl_fetch_input"", ret ); + return( ret ); + } + } + + buf = ssl->in_hdr; + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM ) +#endif + if( ( buf[0] & 0x80 ) != 0 ) + return( ssl_parse_client_hello_v2( ssl ) ); +#endif + + MBEDTLS_SSL_DEBUG_BUF( 4, ""record header"", buf, mbedtls_ssl_hdr_len( ssl ) ); + + /* + * SSLv3/TLS Client Hello + * + * Record layer: + * 0 . 0 message type + * 1 . 2 protocol version + * 3 . 11 DTLS: epoch + record sequence number + * 3 . 4 message length + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, message type: %d"", + buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, message len.: %d"", + ( ssl->in_len[0] << 8 ) | ssl->in_len[1] ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, protocol version: [%d:%d]"", + buf[1], buf[2] ) ); + + mbedtls_ssl_read_version( &major, &minor, ssl->conf->transport, buf + 1 ); + + /* According to RFC 5246 Appendix E.1, the version here is typically + * ""{03,00}, the lowest version number supported by the client, [or] the + * value of ClientHello.client_version"", so the only meaningful check here + * is the major version shouldn't be less than 3 */ + if( major < MBEDTLS_SSL_MAJOR_VERSION_3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* For DTLS if this is the initial handshake, remember the client sequence + * number to use it in our next message (RFC 6347 4.2.1) */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + /* Epoch should be 0 for initial handshakes */ + if( ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + memcpy( ssl->out_ctr + 2, ssl->in_ctr + 2, 6 ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""replayed record, discarding"" ) ); + ssl->next_record_offset = 0; + ssl->in_left = 0; + goto read_record_header; + } + + /* No MAC to check yet, so we can update right now */ + mbedtls_ssl_dtls_replay_update( ssl ); +#endif + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + msg_len = ( ssl->in_len[0] << 8 ) | ssl->in_len[1]; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Set by mbedtls_ssl_read_record() */ + msg_len = ssl->in_hslen; + } + else +#endif + { + if( msg_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( ( ret = mbedtls_ssl_fetch_input( ssl, + mbedtls_ssl_hdr_len( ssl ) + msg_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ""mbedtls_ssl_fetch_input"", ret ); + return( ret ); + } + + /* Done reading this record, get ready for the next one */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->next_record_offset = msg_len + mbedtls_ssl_hdr_len( ssl ); + else +#endif + ssl->in_left = 0; + } + + buf = ssl->in_msg; + + MBEDTLS_SSL_DEBUG_BUF( 4, ""record contents"", buf, msg_len ); + + ssl->handshake->update_checksum( ssl, buf, msg_len ); + + /* + * Handshake layer: + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 DTLS only: message seqence number + * 6 . 8 DTLS only: fragment offset + * 9 . 11 DTLS only: fragment length + */ + if( msg_len < mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, handshake type: %d"", buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, handshake len.: %d"", + ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ) ); + + /* We don't support fragmentation of ClientHello (yet?) */ + if( buf[1] != 0 || + msg_len != mbedtls_ssl_hs_hdr_len( ssl ) + ( ( buf[2] << 8 ) | buf[3] ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + /* + * Copy the client's handshake message_seq on initial handshakes, + * check sequence number on renego. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + /* This couldn't be done in ssl_prepare_handshake_record() */ + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + + if( cli_msg_seq != ssl->handshake->in_msg_seq ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message_seq: "" + ""%d (expected %d)"", cli_msg_seq, + ssl->handshake->in_msg_seq ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->handshake->in_msg_seq++; + } + else +#endif + { + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + ssl->handshake->out_msg_seq = cli_msg_seq; + ssl->handshake->in_msg_seq = cli_msg_seq + 1; + } + + /* + * For now we don't support fragmentation, so make sure + * fragment_offset == 0 and fragment_length == length + */ + if( ssl->in_msg[6] != 0 || ssl->in_msg[7] != 0 || ssl->in_msg[8] != 0 || + memcmp( ssl->in_msg + 1, ssl->in_msg + 9, 3 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""ClientHello fragmentation not supported"" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + buf += mbedtls_ssl_hs_hdr_len( ssl ); + msg_len -= mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * ClientHello layer: + * 0 . 1 protocol version + * 2 . 33 random bytes (starting with 4 bytes of Unix time) + * 34 . 35 session id length (1 byte) + * 35 . 34+x session id + * 35+x . 35+x DTLS only: cookie length (1 byte) + * 36+x . .. DTLS only: cookie + * .. . .. ciphersuite list length (2 bytes) + * .. . .. ciphersuite list + * .. . .. compression alg. list length (1 byte) + * .. . .. compression alg. list + * .. . .. extensions length (2 bytes, optional) + * .. . .. extensions (optional) + */ + + /* + * Minimal length (with everything empty and extensions ommitted) is + * 2 + 32 + 1 + 2 + 1 = 38 bytes. Check that first, so that we can + * read at least up to session id length without worrying. + */ + if( msg_len < 38 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Check and save the protocol version + */ + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, version"", buf, 2 ); + + mbedtls_ssl_read_version( &ssl->major_ver, &ssl->minor_ver, + ssl->conf->transport, buf ); + + ssl->handshake->max_major_ver = ssl->major_ver; + ssl->handshake->max_minor_ver = ssl->minor_ver; + + if( ssl->major_ver < ssl->conf->min_major_ver || + ssl->minor_ver < ssl->conf->min_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""client only supports ssl smaller than minimum"" + "" [%d:%d] < [%d:%d]"", + ssl->major_ver, ssl->minor_ver, + ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + if( ssl->major_ver > ssl->conf->max_major_ver ) + { + ssl->major_ver = ssl->conf->max_major_ver; + ssl->minor_ver = ssl->conf->max_minor_ver; + } + else if( ssl->minor_ver > ssl->conf->max_minor_ver ) + ssl->minor_ver = ssl->conf->max_minor_ver; + + /* + * Save client random (inc. Unix time) + */ + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, random bytes"", buf + 2, 32 ); + + memcpy( ssl->handshake->randbytes, buf + 2, 32 ); + + /* + * Check the session ID length and save session ID + */ + sess_len = buf[34]; + + if( sess_len > sizeof( ssl->session_negotiate->id ) || + sess_len + 34 + 2 > msg_len ) /* 2 for cipherlist length field */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, session id"", buf + 35, sess_len ); + + ssl->session_negotiate->id_len = sess_len; + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); + memcpy( ssl->session_negotiate->id, buf + 35, + ssl->session_negotiate->id_len ); + + /* + * Check the cookie length and content + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + cookie_offset = 35 + sess_len; + cookie_len = buf[cookie_offset]; + + if( cookie_offset + 1 + cookie_len + 2 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, cookie"", + buf + cookie_offset + 1, cookie_len ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( ssl->conf->f_cookie_check != NULL +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + if( ssl->conf->f_cookie_check( ssl->conf->p_cookie, + buf + cookie_offset + 1, cookie_len, + ssl->cli_id, ssl->cli_id_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""cookie verification failed"" ) ); + ssl->handshake->verify_cookie_len = 1; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""cookie verification passed"" ) ); + ssl->handshake->verify_cookie_len = 0; + } + } + else +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + { + /* We know we didn't send a cookie, so it should be empty */ + if( cookie_len != 0 ) + { + /* This may be an attacker's probe, so don't send an alert */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""cookie verification skipped"" ) ); + } + + /* + * Check the ciphersuitelist length (will be parsed later) + */ + ciph_offset = cookie_offset + 1 + cookie_len; + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + ciph_offset = 35 + sess_len; + + ciph_len = ( buf[ciph_offset + 0] << 8 ) + | ( buf[ciph_offset + 1] ); + + if( ciph_len < 2 || + ciph_len + 2 + ciph_offset + 1 > msg_len || /* 1 for comp. alg. len */ + ( ciph_len % 2 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, ciphersuitelist"", + buf + ciph_offset + 2, ciph_len ); + + /* + * Check the compression algorithms length and pick one + */ + comp_offset = ciph_offset + 2 + ciph_len; + + comp_len = buf[comp_offset]; + + if( comp_len < 1 || + comp_len > 16 || + comp_len + comp_offset + 1 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, compression"", + buf + comp_offset + 1, comp_len ); + + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#if defined(MBEDTLS_ZLIB_SUPPORT) + for( i = 0; i < comp_len; ++i ) + { + if( buf[comp_offset + 1 + i] == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_DEFLATE; + break; + } + } +#endif + + /* See comments in ssl_write_client_hello() */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#endif + + /* Do not parse the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + /* + * Check the extension length + */ + ext_offset = comp_offset + 1 + comp_len; + if( msg_len > ext_offset ) + { + if( msg_len < ext_offset + 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ext_len = ( buf[ext_offset + 0] << 8 ) + | ( buf[ext_offset + 1] ); + + if( ( ext_len > 0 && ext_len < 4 ) || + msg_len != ext_offset + 2 + ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } + else + ext_len = 0; + + ext = buf + ext_offset + 2; + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello extensions"", ext, ext_len ); + + while( ext_len != 0 ) + { + unsigned int ext_id = ( ( ext[0] << 8 ) + | ( ext[1] ) ); + unsigned int ext_size = ( ( ext[2] << 8 ) + | ( ext[3] ) ); + + if( ext_size + 4 > ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + switch( ext_id ) + { +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + case MBEDTLS_TLS_EXT_SERVERNAME: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found ServerName extension"" ) ); + if( ssl->conf->f_sni == NULL ) + break; + + ret = ssl_parse_servername_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + + case MBEDTLS_TLS_EXT_RENEGOTIATION_INFO: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found renegotiation extension"" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + renegotiation_info_seen = 1; +#endif + + ret = ssl_parse_renegotiation_info( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + case MBEDTLS_TLS_EXT_SIG_ALG: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found signature_algorithms extension"" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + break; +#endif + ret = ssl_parse_signature_algorithms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + + sig_hash_alg_ext_present = 1; + break; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found supported elliptic curves extension"" ) ); + + ret = ssl_parse_supported_elliptic_curves( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + + case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found supported point formats extension"" ) ); + ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT; + + ret = ssl_parse_supported_point_formats( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_ECJPAKE_KKPP: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found ecjpake kkpp extension"" ) ); + + ret = ssl_parse_ecjpake_kkpp( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + case MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found max fragment length extension"" ) ); + + ret = ssl_parse_max_fragment_length_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + case MBEDTLS_TLS_EXT_TRUNCATED_HMAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found truncated hmac extension"" ) ); + + ret = ssl_parse_truncated_hmac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + case MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found encrypt then mac extension"" ) ); + + ret = ssl_parse_encrypt_then_mac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + case MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found extended master secret extension"" ) ); + + ret = ssl_parse_extended_ms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + case MBEDTLS_TLS_EXT_SESSION_TICKET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found session ticket extension"" ) ); + + ret = ssl_parse_session_ticket_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) + case MBEDTLS_TLS_EXT_ALPN: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found alpn extension"" ) ); + + ret = ssl_parse_alpn_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""unknown extension found: %d (ignoring)"", + ext_id ) ); + } + + ext_len -= 4 + ext_size; + ext += 4 + ext_size; + + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) && + p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""received FALLBACK_SCSV"" ) ); + + if( ssl->minor_ver < ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""inapropriate fallback"" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + break; + } + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + + /* + * Try to fall back to default hash SHA1 if the client + * hasn't provided any preferred signature-hash combinations. + */ + if( sig_hash_alg_ext_present == 0 ) + { + mbedtls_md_type_t md_default = MBEDTLS_MD_SHA1; + + if( mbedtls_ssl_check_sig_hash( ssl, md_default ) != 0 ) + md_default = MBEDTLS_MD_NONE; + + mbedtls_ssl_sig_hash_set_const_hash( &ssl->handshake->hash_algs, md_default ); + } + +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + + /* + * Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ + for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""received TLS_EMPTY_RENEGOTIATION_INFO "" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""received RENEGOTIATION SCSV "" + ""during renegotiation"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + break; + } + } + + /* + * Renegotiation security checks + */ + if( ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""legacy renegotiation, breaking off handshake"" ) ); + handshake_failure = 1; + } +#if defined(MBEDTLS_SSL_RENEGOTIATION) + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION && + renegotiation_info_seen == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""renegotiation_info extension missing (secure)"" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""legacy renegotiation not allowed"" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + renegotiation_info_seen == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""renegotiation_info extension present (legacy)"" ) ); + handshake_failure = 1; + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + if( handshake_failure == 1 ) + { + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Search for a matching ciphersuite + * (At the end because we need information from the EC-based extensions + * and certificate from the SNI callback triggered by the SNI extension.) + */ + got_common_suite = 0; + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + ciphersuite_info = NULL; +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) + for( i = 0; ciphersuites[i] != 0; i++ ) +#else + for( i = 0; ciphersuites[i] != 0; i++ ) + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) +#endif + { + if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || + p[1] != ( ( ciphersuites[i] ) & 0xFF ) ) + continue; + + got_common_suite = 1; + + if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i], + &ciphersuite_info ) ) != 0 ) + return( ret ); + + if( ciphersuite_info != NULL ) + goto have_ciphersuite; + } + + if( got_common_suite ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""got ciphersuites in common, "" + ""but none of them usable"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""got no ciphersuites in common"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + +have_ciphersuite: + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""selected ciphersuite: %s"", ciphersuite_info->name ) ); + + ssl->session_negotiate->ciphersuite = ciphersuites[i]; + ssl->transform_negotiate->ciphersuite_info = ciphersuite_info; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_recv_flight_completed( ssl ); +#endif + + /* Debugging-only output for testsuite */ +#if defined(MBEDTLS_DEBUG_C) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + mbedtls_pk_type_t sig_alg = mbedtls_ssl_get_ciphersuite_sig_alg( ciphersuite_info ); + if( sig_alg != MBEDTLS_PK_NONE ) + { + mbedtls_md_type_t md_alg = mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, + sig_alg ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, signature_algorithm ext: %d"", + mbedtls_ssl_hash_from_md_alg( md_alg ) ) ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""no hash algorithm for signature algorithm "" + ""%d - should not happen"", sig_alg ) ); + } + } +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""<= parse client hello"" ) ); + + return( 0 ); +} +",0,"static int ssl_parse_client_hello( mbedtls_ssl_context *ssl ) +{ + int ret, got_common_suite; + size_t i, j; + size_t ciph_offset, comp_offset, ext_offset; + size_t msg_len, ciph_len, sess_len, comp_len, ext_len; +#if defined(MBEDTLS_SSL_PROTO_DTLS) + size_t cookie_offset, cookie_len; +#endif + unsigned char *buf, *p, *ext; +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renegotiation_info_seen = 0; +#endif + int handshake_failure = 0; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + int major, minor; + + /* If there is no signature-algorithm extension present, + * we need to fall back to the default values for allowed + * signature-hash pairs. */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + int sig_hash_alg_ext_present = 0; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""=> parse client hello"" ) ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) +read_record_header: +#endif + /* + * If renegotiating, then the input was read with mbedtls_ssl_read_record(), + * otherwise read it ourselves manually in order to support SSLv2 + * ClientHello, which doesn't use the same record layer format. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) +#endif + { + if( ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 ) + { + /* No alert on a read error. */ + MBEDTLS_SSL_DEBUG_RET( 1, ""mbedtls_ssl_fetch_input"", ret ); + return( ret ); + } + } + + buf = ssl->in_hdr; + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM ) +#endif + if( ( buf[0] & 0x80 ) != 0 ) + return( ssl_parse_client_hello_v2( ssl ) ); +#endif + + MBEDTLS_SSL_DEBUG_BUF( 4, ""record header"", buf, mbedtls_ssl_hdr_len( ssl ) ); + + /* + * SSLv3/TLS Client Hello + * + * Record layer: + * 0 . 0 message type + * 1 . 2 protocol version + * 3 . 11 DTLS: epoch + record sequence number + * 3 . 4 message length + */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, message type: %d"", + buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_MSG_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, message len.: %d"", + ( ssl->in_len[0] << 8 ) | ssl->in_len[1] ) ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, protocol version: [%d:%d]"", + buf[1], buf[2] ) ); + + mbedtls_ssl_read_version( &major, &minor, ssl->conf->transport, buf + 1 ); + + /* According to RFC 5246 Appendix E.1, the version here is typically + * ""{03,00}, the lowest version number supported by the client, [or] the + * value of ClientHello.client_version"", so the only meaningful check here + * is the major version shouldn't be less than 3 */ + if( major < MBEDTLS_SSL_MAJOR_VERSION_3 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* For DTLS if this is the initial handshake, remember the client sequence + * number to use it in our next message (RFC 6347 4.2.1) */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + /* Epoch should be 0 for initial handshakes */ + if( ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + memcpy( ssl->out_ctr + 2, ssl->in_ctr + 2, 6 ); + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""replayed record, discarding"" ) ); + ssl->next_record_offset = 0; + ssl->in_left = 0; + goto read_record_header; + } + + /* No MAC to check yet, so we can update right now */ + mbedtls_ssl_dtls_replay_update( ssl ); +#endif + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + msg_len = ( ssl->in_len[0] << 8 ) | ssl->in_len[1]; + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) + { + /* Set by mbedtls_ssl_read_record() */ + msg_len = ssl->in_hslen; + } + else +#endif + { + if( msg_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + if( ( ret = mbedtls_ssl_fetch_input( ssl, + mbedtls_ssl_hdr_len( ssl ) + msg_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ""mbedtls_ssl_fetch_input"", ret ); + return( ret ); + } + + /* Done reading this record, get ready for the next one */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->next_record_offset = msg_len + mbedtls_ssl_hdr_len( ssl ); + else +#endif + ssl->in_left = 0; + } + + buf = ssl->in_msg; + + MBEDTLS_SSL_DEBUG_BUF( 4, ""record contents"", buf, msg_len ); + + ssl->handshake->update_checksum( ssl, buf, msg_len ); + + /* + * Handshake layer: + * 0 . 0 handshake type + * 1 . 3 handshake length + * 4 . 5 DTLS only: message seqence number + * 6 . 8 DTLS only: fragment offset + * 9 . 11 DTLS only: fragment length + */ + if( msg_len < mbedtls_ssl_hs_hdr_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, handshake type: %d"", buf[0] ) ); + + if( buf[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, handshake len.: %d"", + ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ) ); + + /* We don't support fragmentation of ClientHello (yet?) */ + if( buf[1] != 0 || + msg_len != mbedtls_ssl_hs_hdr_len( ssl ) + ( ( buf[2] << 8 ) | buf[3] ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + /* + * Copy the client's handshake message_seq on initial handshakes, + * check sequence number on renego. + */ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + /* This couldn't be done in ssl_prepare_handshake_record() */ + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + + if( cli_msg_seq != ssl->handshake->in_msg_seq ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message_seq: "" + ""%d (expected %d)"", cli_msg_seq, + ssl->handshake->in_msg_seq ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ssl->handshake->in_msg_seq++; + } + else +#endif + { + unsigned int cli_msg_seq = ( ssl->in_msg[4] << 8 ) | + ssl->in_msg[5]; + ssl->handshake->out_msg_seq = cli_msg_seq; + ssl->handshake->in_msg_seq = cli_msg_seq + 1; + } + + /* + * For now we don't support fragmentation, so make sure + * fragment_offset == 0 and fragment_length == length + */ + if( ssl->in_msg[6] != 0 || ssl->in_msg[7] != 0 || ssl->in_msg[8] != 0 || + memcmp( ssl->in_msg + 1, ssl->in_msg + 9, 3 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""ClientHello fragmentation not supported"" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + buf += mbedtls_ssl_hs_hdr_len( ssl ); + msg_len -= mbedtls_ssl_hs_hdr_len( ssl ); + + /* + * ClientHello layer: + * 0 . 1 protocol version + * 2 . 33 random bytes (starting with 4 bytes of Unix time) + * 34 . 35 session id length (1 byte) + * 35 . 34+x session id + * 35+x . 35+x DTLS only: cookie length (1 byte) + * 36+x . .. DTLS only: cookie + * .. . .. ciphersuite list length (2 bytes) + * .. . .. ciphersuite list + * .. . .. compression alg. list length (1 byte) + * .. . .. compression alg. list + * .. . .. extensions length (2 bytes, optional) + * .. . .. extensions (optional) + */ + + /* + * Minimal length (with everything empty and extensions ommitted) is + * 2 + 32 + 1 + 2 + 1 = 38 bytes. Check that first, so that we can + * read at least up to session id length without worrying. + */ + if( msg_len < 38 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Check and save the protocol version + */ + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, version"", buf, 2 ); + + mbedtls_ssl_read_version( &ssl->major_ver, &ssl->minor_ver, + ssl->conf->transport, buf ); + + ssl->handshake->max_major_ver = ssl->major_ver; + ssl->handshake->max_minor_ver = ssl->minor_ver; + + if( ssl->major_ver < ssl->conf->min_major_ver || + ssl->minor_ver < ssl->conf->min_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""client only supports ssl smaller than minimum"" + "" [%d:%d] < [%d:%d]"", + ssl->major_ver, ssl->minor_ver, + ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); + } + + if( ssl->major_ver > ssl->conf->max_major_ver ) + { + ssl->major_ver = ssl->conf->max_major_ver; + ssl->minor_ver = ssl->conf->max_minor_ver; + } + else if( ssl->minor_ver > ssl->conf->max_minor_ver ) + ssl->minor_ver = ssl->conf->max_minor_ver; + + /* + * Save client random (inc. Unix time) + */ + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, random bytes"", buf + 2, 32 ); + + memcpy( ssl->handshake->randbytes, buf + 2, 32 ); + + /* + * Check the session ID length and save session ID + */ + sess_len = buf[34]; + + if( sess_len > sizeof( ssl->session_negotiate->id ) || + sess_len + 34 + 2 > msg_len ) /* 2 for cipherlist length field */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, session id"", buf + 35, sess_len ); + + ssl->session_negotiate->id_len = sess_len; + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); + memcpy( ssl->session_negotiate->id, buf + 35, + ssl->session_negotiate->id_len ); + + /* + * Check the cookie length and content + */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + cookie_offset = 35 + sess_len; + cookie_len = buf[cookie_offset]; + + if( cookie_offset + 1 + cookie_len + 2 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, cookie"", + buf + cookie_offset + 1, cookie_len ); + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( ssl->conf->f_cookie_check != NULL +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE +#endif + ) + { + if( ssl->conf->f_cookie_check( ssl->conf->p_cookie, + buf + cookie_offset + 1, cookie_len, + ssl->cli_id, ssl->cli_id_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""cookie verification failed"" ) ); + ssl->handshake->verify_cookie_len = 1; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""cookie verification passed"" ) ); + ssl->handshake->verify_cookie_len = 0; + } + } + else +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + { + /* We know we didn't send a cookie, so it should be empty */ + if( cookie_len != 0 ) + { + /* This may be an attacker's probe, so don't send an alert */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""cookie verification skipped"" ) ); + } + + /* + * Check the ciphersuitelist length (will be parsed later) + */ + ciph_offset = cookie_offset + 1 + cookie_len; + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + ciph_offset = 35 + sess_len; + + ciph_len = ( buf[ciph_offset + 0] << 8 ) + | ( buf[ciph_offset + 1] ); + + if( ciph_len < 2 || + ciph_len + 2 + ciph_offset + 1 > msg_len || /* 1 for comp. alg. len */ + ( ciph_len % 2 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, ciphersuitelist"", + buf + ciph_offset + 2, ciph_len ); + + /* + * Check the compression algorithms length and pick one + */ + comp_offset = ciph_offset + 2 + ciph_len; + + comp_len = buf[comp_offset]; + + if( comp_len < 1 || + comp_len > 16 || + comp_len + comp_offset + 1 > msg_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello, compression"", + buf + comp_offset + 1, comp_len ); + + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#if defined(MBEDTLS_ZLIB_SUPPORT) + for( i = 0; i < comp_len; ++i ) + { + if( buf[comp_offset + 1 + i] == MBEDTLS_SSL_COMPRESS_DEFLATE ) + { + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_DEFLATE; + break; + } + } +#endif + + /* See comments in ssl_write_client_hello() */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; +#endif + + /* Do not parse the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + /* + * Check the extension length + */ + ext_offset = comp_offset + 1 + comp_len; + if( msg_len > ext_offset ) + { + if( msg_len < ext_offset + 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + ext_len = ( buf[ext_offset + 0] << 8 ) + | ( buf[ext_offset + 1] ); + + if( ( ext_len > 0 && ext_len < 4 ) || + msg_len != ext_offset + 2 + ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } + else + ext_len = 0; + + ext = buf + ext_offset + 2; + MBEDTLS_SSL_DEBUG_BUF( 3, ""client hello extensions"", ext, ext_len ); + + while( ext_len != 0 ) + { + unsigned int ext_id = ( ( ext[0] << 8 ) + | ( ext[1] ) ); + unsigned int ext_size = ( ( ext[2] << 8 ) + | ( ext[3] ) ); + + if( ext_size + 4 > ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + switch( ext_id ) + { +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + case MBEDTLS_TLS_EXT_SERVERNAME: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found ServerName extension"" ) ); + if( ssl->conf->f_sni == NULL ) + break; + + ret = ssl_parse_servername_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + + case MBEDTLS_TLS_EXT_RENEGOTIATION_INFO: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found renegotiation extension"" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + renegotiation_info_seen = 1; +#endif + + ret = ssl_parse_renegotiation_info( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + case MBEDTLS_TLS_EXT_SIG_ALG: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found signature_algorithms extension"" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + break; +#endif + ret = ssl_parse_signature_algorithms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + + sig_hash_alg_ext_present = 1; + break; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + +#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found supported elliptic curves extension"" ) ); + + ret = ssl_parse_supported_elliptic_curves( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; + + case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found supported point formats extension"" ) ); + ssl->handshake->cli_exts |= MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT; + + ret = ssl_parse_supported_point_formats( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + case MBEDTLS_TLS_EXT_ECJPAKE_KKPP: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found ecjpake kkpp extension"" ) ); + + ret = ssl_parse_ecjpake_kkpp( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + case MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found max fragment length extension"" ) ); + + ret = ssl_parse_max_fragment_length_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + case MBEDTLS_TLS_EXT_TRUNCATED_HMAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found truncated hmac extension"" ) ); + + ret = ssl_parse_truncated_hmac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + case MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found encrypt then mac extension"" ) ); + + ret = ssl_parse_encrypt_then_mac_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + case MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found extended master secret extension"" ) ); + + ret = ssl_parse_extended_ms_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + case MBEDTLS_TLS_EXT_SESSION_TICKET: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found session ticket extension"" ) ); + + ret = ssl_parse_session_ticket_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_ALPN) + case MBEDTLS_TLS_EXT_ALPN: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""found alpn extension"" ) ); + + ret = ssl_parse_alpn_ext( ssl, ext + 4, ext_size ); + if( ret != 0 ) + return( ret ); + break; +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""unknown extension found: %d (ignoring)"", + ext_id ) ); + } + + ext_len -= 4 + ext_size; + ext += 4 + ext_size; + + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client hello message"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + } +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) && + p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""received FALLBACK_SCSV"" ) ); + + if( ssl->minor_ver < ssl->conf->max_minor_ver ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""inapropriate fallback"" ) ); + + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK ); + + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + break; + } + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + + /* + * Try to fall back to default hash SHA1 if the client + * hasn't provided any preferred signature-hash combinations. + */ + if( sig_hash_alg_ext_present == 0 ) + { + mbedtls_md_type_t md_default = MBEDTLS_MD_SHA1; + + if( mbedtls_ssl_check_sig_hash( ssl, md_default ) != 0 ) + md_default = MBEDTLS_MD_NONE; + + mbedtls_ssl_sig_hash_set_const_hash( &ssl->handshake->hash_algs, md_default ); + } + +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + + /* + * Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV + */ + for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 ) + { + if( p[0] == 0 && p[1] == MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""received TLS_EMPTY_RENEGOTIATION_INFO "" ) ); +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""received RENEGOTIATION SCSV "" + ""during renegotiation"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } +#endif + ssl->secure_renegotiation = MBEDTLS_SSL_SECURE_RENEGOTIATION; + break; + } + } + + /* + * Renegotiation security checks + */ + if( ssl->secure_renegotiation != MBEDTLS_SSL_SECURE_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""legacy renegotiation, breaking off handshake"" ) ); + handshake_failure = 1; + } +#if defined(MBEDTLS_SSL_RENEGOTIATION) + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION && + renegotiation_info_seen == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""renegotiation_info extension missing (secure)"" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""legacy renegotiation not allowed"" ) ); + handshake_failure = 1; + } + else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION && + renegotiation_info_seen == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""renegotiation_info extension present (legacy)"" ) ); + handshake_failure = 1; + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + + if( handshake_failure == 1 ) + { + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); + } + + /* + * Search for a matching ciphersuite + * (At the end because we need information from the EC-based extensions + * and certificate from the SNI callback triggered by the SNI extension.) + */ + got_common_suite = 0; + ciphersuites = ssl->conf->ciphersuite_list[ssl->minor_ver]; + ciphersuite_info = NULL; +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) + for( i = 0; ciphersuites[i] != 0; i++ ) +#else + for( i = 0; ciphersuites[i] != 0; i++ ) + for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) +#endif + { + if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || + p[1] != ( ( ciphersuites[i] ) & 0xFF ) ) + continue; + + got_common_suite = 1; + + if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i], + &ciphersuite_info ) ) != 0 ) + return( ret ); + + if( ciphersuite_info != NULL ) + goto have_ciphersuite; + } + + if( got_common_suite ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""got ciphersuites in common, "" + ""but none of them usable"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""got no ciphersuites in common"" ) ); + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN ); + } + +have_ciphersuite: + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""selected ciphersuite: %s"", ciphersuite_info->name ) ); + + ssl->session_negotiate->ciphersuite = ciphersuites[i]; + ssl->transform_negotiate->ciphersuite_info = ciphersuite_info; + + ssl->state++; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + mbedtls_ssl_recv_flight_completed( ssl ); +#endif + + /* Debugging-only output for testsuite */ +#if defined(MBEDTLS_DEBUG_C) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + mbedtls_pk_type_t sig_alg = mbedtls_ssl_get_ciphersuite_sig_alg( ciphersuite_info ); + if( sig_alg != MBEDTLS_PK_NONE ) + { + mbedtls_md_type_t md_alg = mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, + sig_alg ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""client hello v3, signature_algorithm ext: %d"", + mbedtls_ssl_hash_from_md_alg( md_alg ) ) ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( ""no hash algorithm for signature algorithm "" + ""%d - should not happen"", sig_alg ) ); + } + } +#endif + + MBEDTLS_SSL_DEBUG_MSG( 2, ( ""<= parse client hello"" ) ); + + return( 0 ); +} +","@@ -3436,7 +3436,7 @@ static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned cha + /* + * Receive client pre-shared key identity name + */ +- if( *p + 2 > end ) ++ if( end - *p < 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client key exchange message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); +@@ -3445,7 +3445,7 @@ static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned cha + n = ( (*p)[0] << 8 ) | (*p)[1]; + *p += 2; + +- if( n < 1 || n > 65535 || *p + n > end ) ++ if( n < 1 || n > 65535 || n > (size_t) ( end - *p ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( ""bad client key exchange message"" ) ); + return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );",8222,8458,11000 +6225,"bgp_attr_print(netdissect_options *ndo, + u_int atype, const u_char *pptr, u_int len) +{ + int i; + uint16_t af; + uint8_t safi, snpa, nhlen; + union { /* copy buffer for bandwidth values */ + float f; + uint32_t i; + } bw; + int advance; + u_int tlen; + const u_char *tptr; + char buf[MAXHOSTNAMELEN + 100]; + int as_size; + + tptr = pptr; + tlen=len; + + switch (atype) { + case BGPTYPE_ORIGIN: + if (len != 1) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK(*tptr); + ND_PRINT((ndo, ""%s"", tok2str(bgp_origin_values, + ""Unknown Origin Typecode"", + tptr[0]))); + } + break; + + /* + * Process AS4 byte path and AS2 byte path attributes here. + */ + case BGPTYPE_AS4_PATH: + case BGPTYPE_AS_PATH: + if (len % 2) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + if (!len) { + ND_PRINT((ndo, ""empty"")); + break; + } + + /* + * BGP updates exchanged between New speakers that support 4 + * byte AS, ASs are always encoded in 4 bytes. There is no + * definitive way to find this, just by the packet's + * contents. So, check for packet's TLV's sanity assuming + * 2 bytes first, and it does not pass, assume that ASs are + * encoded in 4 bytes format and move on. + */ + as_size = bgp_attr_get_as_size(ndo, atype, pptr, len); + + while (tptr < pptr + len) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_open_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + for (i = 0; i < tptr[1] * as_size; i += as_size) { + ND_TCHECK2(tptr[2 + i], as_size); + ND_PRINT((ndo, ""%s "", + as_printf(ndo, astostr, sizeof(astostr), + as_size == 2 ? + EXTRACT_16BITS(&tptr[2 + i]) : + EXTRACT_32BITS(&tptr[2 + i])))); + } + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_close_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + tptr += 2 + tptr[1] * as_size; + } + break; + case BGPTYPE_NEXT_HOP: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + } + break; + case BGPTYPE_MULTI_EXIT_DISC: + case BGPTYPE_LOCAL_PREF: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%u"", EXTRACT_32BITS(tptr))); + } + break; + case BGPTYPE_ATOMIC_AGGREGATE: + if (len != 0) + ND_PRINT((ndo, ""invalid len"")); + break; + case BGPTYPE_AGGREGATOR: + + /* + * Depending on the AS encoded is of 2 bytes or of 4 bytes, + * the length of this PA can be either 6 bytes or 8 bytes. + */ + if (len != 6 && len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], len); + if (len == 6) { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)), + ipaddr_string(ndo, tptr + 2))); + } else { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4))); + } + break; + case BGPTYPE_AGGREGATOR4: + if (len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), + ipaddr_string(ndo, tptr + 4))); + break; + case BGPTYPE_COMMUNITIES: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint32_t comm; + ND_TCHECK2(tptr[0], 4); + comm = EXTRACT_32BITS(tptr); + switch (comm) { + case BGP_COMMUNITY_NO_EXPORT: + ND_PRINT((ndo, "" NO_EXPORT"")); + break; + case BGP_COMMUNITY_NO_ADVERT: + ND_PRINT((ndo, "" NO_ADVERTISE"")); + break; + case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: + ND_PRINT((ndo, "" NO_EXPORT_SUBCONFED"")); + break; + default: + ND_PRINT((ndo, ""%u:%u%s"", + (comm >> 16) & 0xffff, + comm & 0xffff, + (tlen>4) ? "", "" : """")); + break; + } + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_ORIGINATOR_ID: + if (len != 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + break; + case BGPTYPE_CLUSTER_LIST: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s%s"", + ipaddr_string(ndo, tptr), + (tlen>4) ? "", "" : """")); + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_MP_REACH_NLRI: + ND_TCHECK2(tptr[0], 3); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + goto done; + break; + } + + tptr +=3; + + ND_TCHECK(tptr[0]); + nhlen = tptr[0]; + tlen = nhlen; + tptr++; + + if (tlen) { + int nnh = 0; + ND_PRINT((ndo, ""\n\t nexthop: "")); + while (tlen > 0) { + if ( nnh++ > 0 ) { + ND_PRINT((ndo, "", "" )); + } + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + tlen -= sizeof(struct in_addr); + tptr += sizeof(struct in_addr); + } + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + if (tlen < (int)sizeof(struct in6_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)); + ND_PRINT((ndo, ""%s"", ip6addr_string(ndo, tptr))); + tlen -= sizeof(struct in6_addr); + tptr += sizeof(struct in6_addr); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + tlen -= (sizeof(struct in_addr)); + tptr += (sizeof(struct in_addr)); + } + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""%s"", isonsap_string(ndo, tptr, tlen))); + tptr += tlen; + tlen = 0; + break; + + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < BGP_VPN_RD_LEN+1) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN))); + /* rfc986 mapped IPv4 address ? */ + if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) + ND_PRINT((ndo, "" = %s"", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4))); + /* rfc1888 mapped IPv6 address ? */ + else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) + ND_PRINT((ndo, "" = %s"", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3))); + tptr += tlen; + tlen = 0; + } + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""no AFI %u/SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + tptr += tlen; + tlen = 0; + goto done; + break; + } + } + } + ND_PRINT((ndo, "", nh-length: %u"", nhlen)); + tptr += tlen; + + ND_TCHECK(tptr[0]); + snpa = tptr[0]; + tptr++; + + if (snpa) { + ND_PRINT((ndo, ""\n\t %u SNPA"", snpa)); + for (/*nothing*/; snpa > 0; snpa--) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""\n\t %d bytes"", tptr[0])); + tptr += tptr[0] + 1; + } + } else { + ND_PRINT((ndo, "", no SNPA"")); + } + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*tptr,tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + done: + break; + + case BGPTYPE_MP_UNREACH_NLRI: + ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + if (len == BGP_MP_NLRI_MINSIZE) + ND_PRINT((ndo, ""\n\t End-of-Rib Marker (empty NLRI)"")); + + tptr += 3; + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*(tptr-3),tlen); + ND_PRINT((ndo, ""no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr-3, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + break; + case BGPTYPE_EXTD_COMMUNITIES: + if (len % 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint16_t extd_comm; + + ND_TCHECK2(tptr[0], 2); + extd_comm=EXTRACT_16BITS(tptr); + + ND_PRINT((ndo, ""\n\t %s (0x%04x), Flags [%s]"", + tok2str(bgp_extd_comm_subtype_values, + ""unknown extd community typecode"", + extd_comm), + extd_comm, + bittok2str(bgp_extd_comm_flag_values, ""none"", extd_comm))); + + ND_TCHECK2(*(tptr+2), 6); + switch(extd_comm) { + case BGP_EXT_COM_RT_0: + case BGP_EXT_COM_RO_0: + case BGP_EXT_COM_L2VPN_RT_0: + ND_PRINT((ndo, "": %u:%u (= %s)"", + EXTRACT_16BITS(tptr+2), + EXTRACT_32BITS(tptr+4), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_EXT_COM_RT_1: + case BGP_EXT_COM_RO_1: + case BGP_EXT_COM_L2VPN_RT_1: + case BGP_EXT_COM_VRF_RT_IMP: + ND_PRINT((ndo, "": %s:%u"", + ipaddr_string(ndo, tptr+2), + EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_RT_2: + case BGP_EXT_COM_RO_2: + ND_PRINT((ndo, "": %s:%u"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_LINKBAND: + bw.i = EXTRACT_32BITS(tptr+2); + ND_PRINT((ndo, "": bandwidth: %.3f Mbps"", + bw.f*8/1000000)); + break; + case BGP_EXT_COM_VPN_ORIGIN: + case BGP_EXT_COM_VPN_ORIGIN2: + case BGP_EXT_COM_VPN_ORIGIN3: + case BGP_EXT_COM_VPN_ORIGIN4: + case BGP_EXT_COM_OSPF_RID: + case BGP_EXT_COM_OSPF_RID2: + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr+2))); + break; + case BGP_EXT_COM_OSPF_RTYPE: + case BGP_EXT_COM_OSPF_RTYPE2: + ND_PRINT((ndo, "": area:%s, router-type:%s, metric-type:%s%s"", + ipaddr_string(ndo, tptr+2), + tok2str(bgp_extd_comm_ospf_rtype_values, + ""unknown (0x%02x)"", + *(tptr+6)), + (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? ""E2"" : """", + ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? ""E1"" : """")); + break; + case BGP_EXT_COM_L2INFO: + ND_PRINT((ndo, "": %s Control Flags [0x%02x]:MTU %u"", + tok2str(l2vpn_encaps_values, + ""unknown encaps"", + *(tptr+2)), + *(tptr+3), + EXTRACT_16BITS(tptr+4))); + break; + case BGP_EXT_COM_SOURCE_AS: + ND_PRINT((ndo, "": AS %u"", EXTRACT_16BITS(tptr+2))); + break; + default: + ND_TCHECK2(*tptr,8); + print_unknown_data(ndo, tptr, ""\n\t "", 8); + break; + } + tlen -=8; + tptr +=8; + } + break; + + case BGPTYPE_PMSI_TUNNEL: + { + uint8_t tunnel_type, flags; + + ND_TCHECK2(tptr[0], 5); + tunnel_type = *(tptr+1); + flags = *tptr; + tlen = len; + + ND_PRINT((ndo, ""\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u"", + tok2str(bgp_pmsi_tunnel_values, ""Unknown"", tunnel_type), + tunnel_type, + bittok2str(bgp_pmsi_flag_values, ""none"", flags), + EXTRACT_24BITS(tptr+2)>>4)); + + tptr +=5; + tlen -= 5; + + switch (tunnel_type) { + case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */ + case BGP_PMSI_TUNNEL_PIM_BIDIR: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Sender %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + + case BGP_PMSI_TUNNEL_PIM_SSM: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_PMSI_TUNNEL_INGRESS: + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""\n\t Tunnel-Endpoint %s"", + ipaddr_string(ndo, tptr))); + break; + case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */ + case BGP_PMSI_TUNNEL_LDP_MP2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, LSP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + case BGP_PMSI_TUNNEL_RSVP_P2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + } + } + break; + } + case BGPTYPE_AIGP: + { + uint8_t type; + uint16_t length; + + tlen = len; + + while (tlen >= 3) { + + ND_TCHECK2(tptr[0], 3); + + type = *tptr; + length = EXTRACT_16BITS(tptr+1); + tptr += 3; + tlen -= 3; + + ND_PRINT((ndo, ""\n\t %s TLV (%u), length %u"", + tok2str(bgp_aigp_values, ""Unknown"", type), + type, length)); + + if (length < 3) + goto trunc; + length -= 3; + + /* + * Check if we can read the TLV data. + */ + ND_TCHECK2(tptr[3], length); + + switch (type) { + + case BGP_AIGP_TLV: + if (length < 8) + goto trunc; + ND_PRINT((ndo, "", metric %"" PRIu64, + EXTRACT_64BITS(tptr))); + break; + + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr,""\n\t "", length); + } + } + + tptr += length; + tlen -= length; + } + break; + } + case BGPTYPE_ATTR_SET: + ND_TCHECK2(tptr[0], 4); + if (len < 4) + goto trunc; + ND_PRINT((ndo, ""\n\t Origin AS: %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)))); + tptr+=4; + len -=4; + + while (len) { + u_int aflags, alenlen, alen; + + ND_TCHECK2(tptr[0], 2); + if (len < 2) + goto trunc; + aflags = *tptr; + atype = *(tptr + 1); + tptr += 2; + len -= 2; + alenlen = bgp_attr_lenlen(aflags, tptr); + ND_TCHECK2(tptr[0], alenlen); + if (len < alenlen) + goto trunc; + alen = bgp_attr_len(aflags, tptr); + tptr += alenlen; + len -= alenlen; + + ND_PRINT((ndo, ""\n\t %s (%u), length: %u"", + tok2str(bgp_attr_values, + ""Unknown Attribute"", atype), + atype, + alen)); + + if (aflags) { + ND_PRINT((ndo, "", Flags [%s%s%s%s"", + aflags & 0x80 ? ""O"" : """", + aflags & 0x40 ? ""T"" : """", + aflags & 0x20 ? ""P"" : """", + aflags & 0x10 ? ""E"" : """")); + if (aflags & 0xf) + ND_PRINT((ndo, ""+%x"", aflags & 0xf)); + ND_PRINT((ndo, ""]: "")); + } + /* FIXME check for recursion */ + if (!bgp_attr_print(ndo, atype, tptr, alen)) + return 0; + tptr += alen; + len -= alen; + } + break; + + case BGPTYPE_LARGE_COMMUNITY: + if (len == 0 || len % 12) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_PRINT((ndo, ""\n\t "")); + while (len > 0) { + ND_TCHECK2(*tptr, 12); + ND_PRINT((ndo, ""%u:%u:%u%s"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + (len > 12) ? "", "" : """")); + tptr += 12; + len -= 12; + } + break; + default: + ND_TCHECK2(*pptr,len); + ND_PRINT((ndo, ""\n\t no Attribute %u decoder"", atype)); /* we have no decoder for the attribute */ + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, pptr, ""\n\t "", len); + break; + } + if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/ + ND_TCHECK2(*pptr,len); + print_unknown_data(ndo, pptr, ""\n\t "", len); + } + return 1; + +trunc: + return 0; +} +",0,"bgp_attr_print(netdissect_options *ndo, + u_int atype, const u_char *pptr, u_int len) +{ + int i; + uint16_t af; + uint8_t safi, snpa, nhlen; + union { /* copy buffer for bandwidth values */ + float f; + uint32_t i; + } bw; + int advance; + u_int tlen; + const u_char *tptr; + char buf[MAXHOSTNAMELEN + 100]; + int as_size; + + tptr = pptr; + tlen=len; + + switch (atype) { + case BGPTYPE_ORIGIN: + if (len != 1) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK(*tptr); + ND_PRINT((ndo, ""%s"", tok2str(bgp_origin_values, + ""Unknown Origin Typecode"", + tptr[0]))); + } + break; + + /* + * Process AS4 byte path and AS2 byte path attributes here. + */ + case BGPTYPE_AS4_PATH: + case BGPTYPE_AS_PATH: + if (len % 2) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + if (!len) { + ND_PRINT((ndo, ""empty"")); + break; + } + + /* + * BGP updates exchanged between New speakers that support 4 + * byte AS, ASs are always encoded in 4 bytes. There is no + * definitive way to find this, just by the packet's + * contents. So, check for packet's TLV's sanity assuming + * 2 bytes first, and it does not pass, assume that ASs are + * encoded in 4 bytes format and move on. + */ + as_size = bgp_attr_get_as_size(ndo, atype, pptr, len); + + while (tptr < pptr + len) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_open_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + for (i = 0; i < tptr[1] * as_size; i += as_size) { + ND_TCHECK2(tptr[2 + i], as_size); + ND_PRINT((ndo, ""%s "", + as_printf(ndo, astostr, sizeof(astostr), + as_size == 2 ? + EXTRACT_16BITS(&tptr[2 + i]) : + EXTRACT_32BITS(&tptr[2 + i])))); + } + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_close_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + tptr += 2 + tptr[1] * as_size; + } + break; + case BGPTYPE_NEXT_HOP: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + } + break; + case BGPTYPE_MULTI_EXIT_DISC: + case BGPTYPE_LOCAL_PREF: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%u"", EXTRACT_32BITS(tptr))); + } + break; + case BGPTYPE_ATOMIC_AGGREGATE: + if (len != 0) + ND_PRINT((ndo, ""invalid len"")); + break; + case BGPTYPE_AGGREGATOR: + + /* + * Depending on the AS encoded is of 2 bytes or of 4 bytes, + * the length of this PA can be either 6 bytes or 8 bytes. + */ + if (len != 6 && len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], len); + if (len == 6) { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)), + ipaddr_string(ndo, tptr + 2))); + } else { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4))); + } + break; + case BGPTYPE_AGGREGATOR4: + if (len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), + ipaddr_string(ndo, tptr + 4))); + break; + case BGPTYPE_COMMUNITIES: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint32_t comm; + ND_TCHECK2(tptr[0], 4); + comm = EXTRACT_32BITS(tptr); + switch (comm) { + case BGP_COMMUNITY_NO_EXPORT: + ND_PRINT((ndo, "" NO_EXPORT"")); + break; + case BGP_COMMUNITY_NO_ADVERT: + ND_PRINT((ndo, "" NO_ADVERTISE"")); + break; + case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: + ND_PRINT((ndo, "" NO_EXPORT_SUBCONFED"")); + break; + default: + ND_PRINT((ndo, ""%u:%u%s"", + (comm >> 16) & 0xffff, + comm & 0xffff, + (tlen>4) ? "", "" : """")); + break; + } + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_ORIGINATOR_ID: + if (len != 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + break; + case BGPTYPE_CLUSTER_LIST: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s%s"", + ipaddr_string(ndo, tptr), + (tlen>4) ? "", "" : """")); + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_MP_REACH_NLRI: + ND_TCHECK2(tptr[0], 3); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + goto done; + break; + } + + tptr +=3; + + ND_TCHECK(tptr[0]); + nhlen = tptr[0]; + tlen = nhlen; + tptr++; + + if (tlen) { + int nnh = 0; + ND_PRINT((ndo, ""\n\t nexthop: "")); + while (tlen > 0) { + if ( nnh++ > 0 ) { + ND_PRINT((ndo, "", "" )); + } + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + tlen -= sizeof(struct in_addr); + tptr += sizeof(struct in_addr); + } + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + if (tlen < (int)sizeof(struct in6_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)); + ND_PRINT((ndo, ""%s"", ip6addr_string(ndo, tptr))); + tlen -= sizeof(struct in6_addr); + tptr += sizeof(struct in6_addr); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + tlen -= (sizeof(struct in_addr)); + tptr += (sizeof(struct in_addr)); + } + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""%s"", isonsap_string(ndo, tptr, tlen))); + tptr += tlen; + tlen = 0; + break; + + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < BGP_VPN_RD_LEN+1) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN))); + /* rfc986 mapped IPv4 address ? */ + if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) + ND_PRINT((ndo, "" = %s"", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4))); + /* rfc1888 mapped IPv6 address ? */ + else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) + ND_PRINT((ndo, "" = %s"", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3))); + tptr += tlen; + tlen = 0; + } + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""no AFI %u/SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + tptr += tlen; + tlen = 0; + goto done; + break; + } + } + } + ND_PRINT((ndo, "", nh-length: %u"", nhlen)); + tptr += tlen; + + ND_TCHECK(tptr[0]); + snpa = tptr[0]; + tptr++; + + if (snpa) { + ND_PRINT((ndo, ""\n\t %u SNPA"", snpa)); + for (/*nothing*/; snpa > 0; snpa--) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""\n\t %d bytes"", tptr[0])); + tptr += tptr[0] + 1; + } + } else { + ND_PRINT((ndo, "", no SNPA"")); + } + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*tptr,tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + done: + break; + + case BGPTYPE_MP_UNREACH_NLRI: + ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + if (len == BGP_MP_NLRI_MINSIZE) + ND_PRINT((ndo, ""\n\t End-of-Rib Marker (empty NLRI)"")); + + tptr += 3; + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*(tptr-3),tlen); + ND_PRINT((ndo, ""no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr-3, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + break; + case BGPTYPE_EXTD_COMMUNITIES: + if (len % 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint16_t extd_comm; + + ND_TCHECK2(tptr[0], 2); + extd_comm=EXTRACT_16BITS(tptr); + + ND_PRINT((ndo, ""\n\t %s (0x%04x), Flags [%s]"", + tok2str(bgp_extd_comm_subtype_values, + ""unknown extd community typecode"", + extd_comm), + extd_comm, + bittok2str(bgp_extd_comm_flag_values, ""none"", extd_comm))); + + ND_TCHECK2(*(tptr+2), 6); + switch(extd_comm) { + case BGP_EXT_COM_RT_0: + case BGP_EXT_COM_RO_0: + case BGP_EXT_COM_L2VPN_RT_0: + ND_PRINT((ndo, "": %u:%u (= %s)"", + EXTRACT_16BITS(tptr+2), + EXTRACT_32BITS(tptr+4), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_EXT_COM_RT_1: + case BGP_EXT_COM_RO_1: + case BGP_EXT_COM_L2VPN_RT_1: + case BGP_EXT_COM_VRF_RT_IMP: + ND_PRINT((ndo, "": %s:%u"", + ipaddr_string(ndo, tptr+2), + EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_RT_2: + case BGP_EXT_COM_RO_2: + ND_PRINT((ndo, "": %s:%u"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_LINKBAND: + bw.i = EXTRACT_32BITS(tptr+2); + ND_PRINT((ndo, "": bandwidth: %.3f Mbps"", + bw.f*8/1000000)); + break; + case BGP_EXT_COM_VPN_ORIGIN: + case BGP_EXT_COM_VPN_ORIGIN2: + case BGP_EXT_COM_VPN_ORIGIN3: + case BGP_EXT_COM_VPN_ORIGIN4: + case BGP_EXT_COM_OSPF_RID: + case BGP_EXT_COM_OSPF_RID2: + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr+2))); + break; + case BGP_EXT_COM_OSPF_RTYPE: + case BGP_EXT_COM_OSPF_RTYPE2: + ND_PRINT((ndo, "": area:%s, router-type:%s, metric-type:%s%s"", + ipaddr_string(ndo, tptr+2), + tok2str(bgp_extd_comm_ospf_rtype_values, + ""unknown (0x%02x)"", + *(tptr+6)), + (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? ""E2"" : """", + ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? ""E1"" : """")); + break; + case BGP_EXT_COM_L2INFO: + ND_PRINT((ndo, "": %s Control Flags [0x%02x]:MTU %u"", + tok2str(l2vpn_encaps_values, + ""unknown encaps"", + *(tptr+2)), + *(tptr+3), + EXTRACT_16BITS(tptr+4))); + break; + case BGP_EXT_COM_SOURCE_AS: + ND_PRINT((ndo, "": AS %u"", EXTRACT_16BITS(tptr+2))); + break; + default: + ND_TCHECK2(*tptr,8); + print_unknown_data(ndo, tptr, ""\n\t "", 8); + break; + } + tlen -=8; + tptr +=8; + } + break; + + case BGPTYPE_PMSI_TUNNEL: + { + uint8_t tunnel_type, flags; + + ND_TCHECK2(tptr[0], 5); + tunnel_type = *(tptr+1); + flags = *tptr; + tlen = len; + + ND_PRINT((ndo, ""\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u"", + tok2str(bgp_pmsi_tunnel_values, ""Unknown"", tunnel_type), + tunnel_type, + bittok2str(bgp_pmsi_flag_values, ""none"", flags), + EXTRACT_24BITS(tptr+2)>>4)); + + tptr +=5; + tlen -= 5; + + switch (tunnel_type) { + case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */ + case BGP_PMSI_TUNNEL_PIM_BIDIR: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Sender %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + + case BGP_PMSI_TUNNEL_PIM_SSM: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_PMSI_TUNNEL_INGRESS: + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""\n\t Tunnel-Endpoint %s"", + ipaddr_string(ndo, tptr))); + break; + case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */ + case BGP_PMSI_TUNNEL_LDP_MP2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, LSP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + case BGP_PMSI_TUNNEL_RSVP_P2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + } + } + break; + } + case BGPTYPE_AIGP: + { + uint8_t type; + uint16_t length; + + tlen = len; + + while (tlen >= 3) { + + ND_TCHECK2(tptr[0], 3); + + type = *tptr; + length = EXTRACT_16BITS(tptr+1); + tptr += 3; + tlen -= 3; + + ND_PRINT((ndo, ""\n\t %s TLV (%u), length %u"", + tok2str(bgp_aigp_values, ""Unknown"", type), + type, length)); + + if (length < 3) + goto trunc; + length -= 3; + + /* + * Check if we can read the TLV data. + */ + ND_TCHECK2(tptr[3], length); + + switch (type) { + + case BGP_AIGP_TLV: + if (length < 8) + goto trunc; + ND_PRINT((ndo, "", metric %"" PRIu64, + EXTRACT_64BITS(tptr))); + break; + + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr,""\n\t "", length); + } + } + + tptr += length; + tlen -= length; + } + break; + } + case BGPTYPE_ATTR_SET: + ND_TCHECK2(tptr[0], 4); + if (len < 4) + goto trunc; + ND_PRINT((ndo, ""\n\t Origin AS: %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)))); + tptr+=4; + len -=4; + + while (len) { + u_int aflags, alenlen, alen; + + ND_TCHECK2(tptr[0], 2); + if (len < 2) + goto trunc; + aflags = *tptr; + atype = *(tptr + 1); + tptr += 2; + len -= 2; + alenlen = bgp_attr_lenlen(aflags, tptr); + ND_TCHECK2(tptr[0], alenlen); + if (len < alenlen) + goto trunc; + alen = bgp_attr_len(aflags, tptr); + tptr += alenlen; + len -= alenlen; + + ND_PRINT((ndo, ""\n\t %s (%u), length: %u"", + tok2str(bgp_attr_values, + ""Unknown Attribute"", atype), + atype, + alen)); + + if (aflags) { + ND_PRINT((ndo, "", Flags [%s%s%s%s"", + aflags & 0x80 ? ""O"" : """", + aflags & 0x40 ? ""T"" : """", + aflags & 0x20 ? ""P"" : """", + aflags & 0x10 ? ""E"" : """")); + if (aflags & 0xf) + ND_PRINT((ndo, ""+%x"", aflags & 0xf)); + ND_PRINT((ndo, ""]: "")); + } + /* FIXME check for recursion */ + if (!bgp_attr_print(ndo, atype, tptr, alen)) + return 0; + tptr += alen; + len -= alen; + } + break; + + case BGPTYPE_LARGE_COMMUNITY: + if (len == 0 || len % 12) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_PRINT((ndo, ""\n\t "")); + while (len > 0) { + ND_TCHECK2(*tptr, 12); + ND_PRINT((ndo, ""%u:%u:%u%s"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + (len > 12) ? "", "" : """")); + tptr += 12; + len -= 12; + } + break; + default: + ND_TCHECK2(*pptr,len); + ND_PRINT((ndo, ""\n\t no Attribute %u decoder"", atype)); /* we have no decoder for the attribute */ + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, pptr, ""\n\t "", len); + break; + } + if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/ + ND_TCHECK2(*pptr,len); + print_unknown_data(ndo, pptr, ""\n\t "", len); + } + return 1; + +trunc: + return 0; +} +","@@ -761,32 +761,48 @@ decode_rt_routing_info(netdissect_options *ndo, + { + uint8_t route_target[8]; + u_int plen; ++ char asbuf[sizeof(astostr)]; /* bgp_vpn_rd_print() overwrites astostr */ + ++ /* NLRI ""prefix length"" from RFC 2858 Section 4. */ + ND_TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + ++ /* NLRI ""prefix"" (ibid), valid lengths are { 0, 32, 33, ..., 96 } bits. ++ * RFC 4684 Section 4 defines the layout of ""origin AS"" and ""route ++ * target"" fields inside the ""prefix"" depending on its length. ++ */ + if (0 == plen) { ++ /* Without ""origin AS"", without ""route target"". */ + snprintf(buf, buflen, ""default route target""); + return 1; + } + + if (32 > plen) + return -1; + ++ /* With at least ""origin AS"", possibly with ""route target"". */ ++ ND_TCHECK_32BITS(pptr + 1); ++ as_printf(ndo, asbuf, sizeof(asbuf), EXTRACT_32BITS(pptr + 1)); ++ + plen-=32; /* adjust prefix length */ + + if (64 < plen) + return -1; + ++ /* From now on (plen + 7) / 8 evaluates to { 0, 1, 2, ..., 8 } ++ * and gives the number of octets in the variable-length ""route ++ * target"" field inside this NLRI ""prefix"". Look for it. ++ */ + memset(&route_target, 0, sizeof(route_target)); +- ND_TCHECK2(pptr[1], (plen + 7) / 8); +- memcpy(&route_target, &pptr[1], (plen + 7) / 8); ++ ND_TCHECK2(pptr[5], (plen + 7) / 8); ++ memcpy(&route_target, &pptr[5], (plen + 7) / 8); ++ /* Which specification says to do this? */ + if (plen % 8) { + ((u_char *)&route_target)[(plen + 7) / 8 - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + snprintf(buf, buflen, ""origin AS: %s, route target %s"", +- as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)), ++ asbuf, + bgp_vpn_rd_print(ndo, (u_char *)&route_target)); + + return 5 + (plen + 7) / 8;",9829,10065,11000 +18294," bgp_attr_print(netdissect_options *ndo, + u_int atype, const u_char *pptr, u_int len) + { + int i; + uint16_t af; + uint8_t safi, snpa, nhlen; + union { /* copy buffer for bandwidth values */ + float f; + uint32_t i; + } bw; + int advance; + u_int tlen; + const u_char *tptr; + char buf[MAXHOSTNAMELEN + 100]; + int as_size; + + tptr = pptr; + tlen=len; + + switch (atype) { + case BGPTYPE_ORIGIN: + if (len != 1) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK(*tptr); + ND_PRINT((ndo, ""%s"", tok2str(bgp_origin_values, + ""Unknown Origin Typecode"", + tptr[0]))); + } + break; + + /* + * Process AS4 byte path and AS2 byte path attributes here. + */ + case BGPTYPE_AS4_PATH: + case BGPTYPE_AS_PATH: + if (len % 2) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + if (!len) { + ND_PRINT((ndo, ""empty"")); + break; + } + + /* + * BGP updates exchanged between New speakers that support 4 + * byte AS, ASs are always encoded in 4 bytes. There is no + * definitive way to find this, just by the packet's + * contents. So, check for packet's TLV's sanity assuming + * 2 bytes first, and it does not pass, assume that ASs are + * encoded in 4 bytes format and move on. + */ + as_size = bgp_attr_get_as_size(ndo, atype, pptr, len); + + while (tptr < pptr + len) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_open_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + for (i = 0; i < tptr[1] * as_size; i += as_size) { + ND_TCHECK2(tptr[2 + i], as_size); + ND_PRINT((ndo, ""%s "", + as_printf(ndo, astostr, sizeof(astostr), + as_size == 2 ? + EXTRACT_16BITS(&tptr[2 + i]) : + EXTRACT_32BITS(&tptr[2 + i])))); + } + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_close_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + tptr += 2 + tptr[1] * as_size; + } + break; + case BGPTYPE_NEXT_HOP: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + } + break; + case BGPTYPE_MULTI_EXIT_DISC: + case BGPTYPE_LOCAL_PREF: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%u"", EXTRACT_32BITS(tptr))); + } + break; + case BGPTYPE_ATOMIC_AGGREGATE: + if (len != 0) + ND_PRINT((ndo, ""invalid len"")); + break; + case BGPTYPE_AGGREGATOR: + + /* + * Depending on the AS encoded is of 2 bytes or of 4 bytes, + * the length of this PA can be either 6 bytes or 8 bytes. + */ + if (len != 6 && len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], len); + if (len == 6) { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)), + ipaddr_string(ndo, tptr + 2))); + } else { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4))); + } + break; + case BGPTYPE_AGGREGATOR4: + if (len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), + ipaddr_string(ndo, tptr + 4))); + break; + case BGPTYPE_COMMUNITIES: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint32_t comm; + ND_TCHECK2(tptr[0], 4); + comm = EXTRACT_32BITS(tptr); + switch (comm) { + case BGP_COMMUNITY_NO_EXPORT: + ND_PRINT((ndo, "" NO_EXPORT"")); + break; + case BGP_COMMUNITY_NO_ADVERT: + ND_PRINT((ndo, "" NO_ADVERTISE"")); + break; + case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: + ND_PRINT((ndo, "" NO_EXPORT_SUBCONFED"")); + break; + default: + ND_PRINT((ndo, ""%u:%u%s"", + (comm >> 16) & 0xffff, + comm & 0xffff, + (tlen>4) ? "", "" : """")); + break; + } + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_ORIGINATOR_ID: + if (len != 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + break; + case BGPTYPE_CLUSTER_LIST: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s%s"", + ipaddr_string(ndo, tptr), + (tlen>4) ? "", "" : """")); + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_MP_REACH_NLRI: + ND_TCHECK2(tptr[0], 3); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + goto done; + break; + } + + tptr +=3; + + ND_TCHECK(tptr[0]); + nhlen = tptr[0]; + tlen = nhlen; + tptr++; + + if (tlen) { + int nnh = 0; + ND_PRINT((ndo, ""\n\t nexthop: "")); + while (tlen > 0) { + if ( nnh++ > 0 ) { + ND_PRINT((ndo, "", "" )); + } + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + tlen -= sizeof(struct in_addr); + tptr += sizeof(struct in_addr); + } + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + if (tlen < (int)sizeof(struct in6_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)); + ND_PRINT((ndo, ""%s"", ip6addr_string(ndo, tptr))); + tlen -= sizeof(struct in6_addr); + tptr += sizeof(struct in6_addr); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + tlen -= (sizeof(struct in_addr)); + tptr += (sizeof(struct in_addr)); + } + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""%s"", isonsap_string(ndo, tptr, tlen))); + tptr += tlen; + tlen = 0; + break; + + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < BGP_VPN_RD_LEN+1) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN))); + /* rfc986 mapped IPv4 address ? */ + if (tlen == BGP_VPN_RD_LEN + 4 + sizeof(struct in_addr) + && EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) + ND_PRINT((ndo, "" = %s"", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4))); + /* rfc1888 mapped IPv6 address ? */ + else if (tlen == BGP_VPN_RD_LEN + 3 + sizeof(struct in6_addr) + && EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) + ND_PRINT((ndo, "" = %s"", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3))); + tptr += tlen; + tlen = 0; + } + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""no AFI %u/SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + tptr += tlen; + tlen = 0; + goto done; + break; + } + } + } + ND_PRINT((ndo, "", nh-length: %u"", nhlen)); + tptr += tlen; + + ND_TCHECK(tptr[0]); + snpa = tptr[0]; + tptr++; + + if (snpa) { + ND_PRINT((ndo, ""\n\t %u SNPA"", snpa)); + for (/*nothing*/; snpa > 0; snpa--) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""\n\t %d bytes"", tptr[0])); + tptr += tptr[0] + 1; + } + } else { + ND_PRINT((ndo, "", no SNPA"")); + } + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*tptr,tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + done: + break; + + case BGPTYPE_MP_UNREACH_NLRI: + ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + if (len == BGP_MP_NLRI_MINSIZE) + ND_PRINT((ndo, ""\n\t End-of-Rib Marker (empty NLRI)"")); + + tptr += 3; + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*(tptr-3),tlen); + ND_PRINT((ndo, ""no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr-3, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + break; + case BGPTYPE_EXTD_COMMUNITIES: + if (len % 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint16_t extd_comm; + + ND_TCHECK2(tptr[0], 2); + extd_comm=EXTRACT_16BITS(tptr); + + ND_PRINT((ndo, ""\n\t %s (0x%04x), Flags [%s]"", + tok2str(bgp_extd_comm_subtype_values, + ""unknown extd community typecode"", + extd_comm), + extd_comm, + bittok2str(bgp_extd_comm_flag_values, ""none"", extd_comm))); + + ND_TCHECK2(*(tptr+2), 6); + switch(extd_comm) { + case BGP_EXT_COM_RT_0: + case BGP_EXT_COM_RO_0: + case BGP_EXT_COM_L2VPN_RT_0: + ND_PRINT((ndo, "": %u:%u (= %s)"", + EXTRACT_16BITS(tptr+2), + EXTRACT_32BITS(tptr+4), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_EXT_COM_RT_1: + case BGP_EXT_COM_RO_1: + case BGP_EXT_COM_L2VPN_RT_1: + case BGP_EXT_COM_VRF_RT_IMP: + ND_PRINT((ndo, "": %s:%u"", + ipaddr_string(ndo, tptr+2), + EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_RT_2: + case BGP_EXT_COM_RO_2: + ND_PRINT((ndo, "": %s:%u"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_LINKBAND: + bw.i = EXTRACT_32BITS(tptr+2); + ND_PRINT((ndo, "": bandwidth: %.3f Mbps"", + bw.f*8/1000000)); + break; + case BGP_EXT_COM_VPN_ORIGIN: + case BGP_EXT_COM_VPN_ORIGIN2: + case BGP_EXT_COM_VPN_ORIGIN3: + case BGP_EXT_COM_VPN_ORIGIN4: + case BGP_EXT_COM_OSPF_RID: + case BGP_EXT_COM_OSPF_RID2: + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr+2))); + break; + case BGP_EXT_COM_OSPF_RTYPE: + case BGP_EXT_COM_OSPF_RTYPE2: + ND_PRINT((ndo, "": area:%s, router-type:%s, metric-type:%s%s"", + ipaddr_string(ndo, tptr+2), + tok2str(bgp_extd_comm_ospf_rtype_values, + ""unknown (0x%02x)"", + *(tptr+6)), + (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? ""E2"" : """", + ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? ""E1"" : """")); + break; + case BGP_EXT_COM_L2INFO: + ND_PRINT((ndo, "": %s Control Flags [0x%02x]:MTU %u"", + tok2str(l2vpn_encaps_values, + ""unknown encaps"", + *(tptr+2)), + *(tptr+3), + EXTRACT_16BITS(tptr+4))); + break; + case BGP_EXT_COM_SOURCE_AS: + ND_PRINT((ndo, "": AS %u"", EXTRACT_16BITS(tptr+2))); + break; + default: + ND_TCHECK2(*tptr,8); + print_unknown_data(ndo, tptr, ""\n\t "", 8); + break; + } + tlen -=8; + tptr +=8; + } + break; + + case BGPTYPE_PMSI_TUNNEL: + { + uint8_t tunnel_type, flags; + + ND_TCHECK2(tptr[0], 5); + tunnel_type = *(tptr+1); + flags = *tptr; + tlen = len; + + ND_PRINT((ndo, ""\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u"", + tok2str(bgp_pmsi_tunnel_values, ""Unknown"", tunnel_type), + tunnel_type, + bittok2str(bgp_pmsi_flag_values, ""none"", flags), + EXTRACT_24BITS(tptr+2)>>4)); + + tptr +=5; + tlen -= 5; + + switch (tunnel_type) { + case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */ + case BGP_PMSI_TUNNEL_PIM_BIDIR: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Sender %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + + case BGP_PMSI_TUNNEL_PIM_SSM: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_PMSI_TUNNEL_INGRESS: + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""\n\t Tunnel-Endpoint %s"", + ipaddr_string(ndo, tptr))); + break; + case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */ + case BGP_PMSI_TUNNEL_LDP_MP2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, LSP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + case BGP_PMSI_TUNNEL_RSVP_P2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + } + } + break; + } + case BGPTYPE_AIGP: + { + uint8_t type; + uint16_t length; + + tlen = len; + + while (tlen >= 3) { + + ND_TCHECK2(tptr[0], 3); + + type = *tptr; + length = EXTRACT_16BITS(tptr+1); + tptr += 3; + tlen -= 3; + + ND_PRINT((ndo, ""\n\t %s TLV (%u), length %u"", + tok2str(bgp_aigp_values, ""Unknown"", type), + type, length)); + + if (length < 3) + goto trunc; + length -= 3; + + /* + * Check if we can read the TLV data. + */ + ND_TCHECK2(tptr[3], length); + + switch (type) { + + case BGP_AIGP_TLV: + if (length < 8) + goto trunc; + ND_PRINT((ndo, "", metric %"" PRIu64, + EXTRACT_64BITS(tptr))); + break; + + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr,""\n\t "", length); + } + } + + tptr += length; + tlen -= length; + } + break; + } + case BGPTYPE_ATTR_SET: + ND_TCHECK2(tptr[0], 4); + if (len < 4) + goto trunc; + ND_PRINT((ndo, ""\n\t Origin AS: %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)))); + tptr+=4; + len -=4; + + while (len) { + u_int aflags, alenlen, alen; + + ND_TCHECK2(tptr[0], 2); + if (len < 2) + goto trunc; + aflags = *tptr; + atype = *(tptr + 1); + tptr += 2; + len -= 2; + alenlen = bgp_attr_lenlen(aflags, tptr); + ND_TCHECK2(tptr[0], alenlen); + if (len < alenlen) + goto trunc; + alen = bgp_attr_len(aflags, tptr); + tptr += alenlen; + len -= alenlen; + + ND_PRINT((ndo, ""\n\t %s (%u), length: %u"", + tok2str(bgp_attr_values, + ""Unknown Attribute"", atype), + atype, + alen)); + + if (aflags) { + ND_PRINT((ndo, "", Flags [%s%s%s%s"", + aflags & 0x80 ? ""O"" : """", + aflags & 0x40 ? ""T"" : """", + aflags & 0x20 ? ""P"" : """", + aflags & 0x10 ? ""E"" : """")); + if (aflags & 0xf) + ND_PRINT((ndo, ""+%x"", aflags & 0xf)); + ND_PRINT((ndo, ""]: "")); + } + /* FIXME check for recursion */ + if (!bgp_attr_print(ndo, atype, tptr, alen)) + return 0; + tptr += alen; + len -= alen; + } + break; + + case BGPTYPE_LARGE_COMMUNITY: + if (len == 0 || len % 12) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_PRINT((ndo, ""\n\t "")); + while (len > 0) { + ND_TCHECK2(*tptr, 12); + ND_PRINT((ndo, ""%u:%u:%u%s"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + (len > 12) ? "", "" : """")); + tptr += 12; + len -= 12; + } + break; + default: + ND_TCHECK2(*pptr,len); + ND_PRINT((ndo, ""\n\t no Attribute %u decoder"", atype)); /* we have no decoder for the attribute */ + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, pptr, ""\n\t "", len); + break; + } + if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/ + ND_TCHECK2(*pptr,len); + print_unknown_data(ndo, pptr, ""\n\t "", len); + } + return 1; + +trunc: + return 0; +} +",1," bgp_attr_print(netdissect_options *ndo, + u_int atype, const u_char *pptr, u_int len, const unsigned attr_set_level) + { + int i; + uint16_t af; + uint8_t safi, snpa, nhlen; + union { /* copy buffer for bandwidth values */ + float f; + uint32_t i; + } bw; + int advance; + u_int tlen; + const u_char *tptr; + char buf[MAXHOSTNAMELEN + 100]; + int as_size; + + tptr = pptr; + tlen=len; + + switch (atype) { + case BGPTYPE_ORIGIN: + if (len != 1) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK(*tptr); + ND_PRINT((ndo, ""%s"", tok2str(bgp_origin_values, + ""Unknown Origin Typecode"", + tptr[0]))); + } + break; + + /* + * Process AS4 byte path and AS2 byte path attributes here. + */ + case BGPTYPE_AS4_PATH: + case BGPTYPE_AS_PATH: + if (len % 2) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + if (!len) { + ND_PRINT((ndo, ""empty"")); + break; + } + + /* + * BGP updates exchanged between New speakers that support 4 + * byte AS, ASs are always encoded in 4 bytes. There is no + * definitive way to find this, just by the packet's + * contents. So, check for packet's TLV's sanity assuming + * 2 bytes first, and it does not pass, assume that ASs are + * encoded in 4 bytes format and move on. + */ + as_size = bgp_attr_get_as_size(ndo, atype, pptr, len); + + while (tptr < pptr + len) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_open_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + for (i = 0; i < tptr[1] * as_size; i += as_size) { + ND_TCHECK2(tptr[2 + i], as_size); + ND_PRINT((ndo, ""%s "", + as_printf(ndo, astostr, sizeof(astostr), + as_size == 2 ? + EXTRACT_16BITS(&tptr[2 + i]) : + EXTRACT_32BITS(&tptr[2 + i])))); + } + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""%s"", tok2str(bgp_as_path_segment_close_values, + ""?"", tptr[0]))); + ND_TCHECK(tptr[1]); + tptr += 2 + tptr[1] * as_size; + } + break; + case BGPTYPE_NEXT_HOP: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + } + break; + case BGPTYPE_MULTI_EXIT_DISC: + case BGPTYPE_LOCAL_PREF: + if (len != 4) + ND_PRINT((ndo, ""invalid len"")); + else { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%u"", EXTRACT_32BITS(tptr))); + } + break; + case BGPTYPE_ATOMIC_AGGREGATE: + if (len != 0) + ND_PRINT((ndo, ""invalid len"")); + break; + case BGPTYPE_AGGREGATOR: + + /* + * Depending on the AS encoded is of 2 bytes or of 4 bytes, + * the length of this PA can be either 6 bytes or 8 bytes. + */ + if (len != 6 && len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], len); + if (len == 6) { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)), + ipaddr_string(ndo, tptr + 2))); + } else { + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4))); + } + break; + case BGPTYPE_AGGREGATOR4: + if (len != 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, "" AS #%s, origin %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), + ipaddr_string(ndo, tptr + 4))); + break; + case BGPTYPE_COMMUNITIES: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint32_t comm; + ND_TCHECK2(tptr[0], 4); + comm = EXTRACT_32BITS(tptr); + switch (comm) { + case BGP_COMMUNITY_NO_EXPORT: + ND_PRINT((ndo, "" NO_EXPORT"")); + break; + case BGP_COMMUNITY_NO_ADVERT: + ND_PRINT((ndo, "" NO_ADVERTISE"")); + break; + case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: + ND_PRINT((ndo, "" NO_EXPORT_SUBCONFED"")); + break; + default: + ND_PRINT((ndo, ""%u:%u%s"", + (comm >> 16) & 0xffff, + comm & 0xffff, + (tlen>4) ? "", "" : """")); + break; + } + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_ORIGINATOR_ID: + if (len != 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + break; + case BGPTYPE_CLUSTER_LIST: + if (len % 4) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""%s%s"", + ipaddr_string(ndo, tptr), + (tlen>4) ? "", "" : """")); + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_MP_REACH_NLRI: + ND_TCHECK2(tptr[0], 3); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + goto done; + break; + } + + tptr +=3; + + ND_TCHECK(tptr[0]); + nhlen = tptr[0]; + tlen = nhlen; + tptr++; + + if (tlen) { + int nnh = 0; + ND_PRINT((ndo, ""\n\t nexthop: "")); + while (tlen > 0) { + if ( nnh++ > 0 ) { + ND_PRINT((ndo, "", "" )); + } + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"",ipaddr_string(ndo, tptr))); + tlen -= sizeof(struct in_addr); + tptr += sizeof(struct in_addr); + } + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + if (tlen < (int)sizeof(struct in6_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)); + ND_PRINT((ndo, ""%s"", ip6addr_string(ndo, tptr))); + tlen -= sizeof(struct in6_addr); + tptr += sizeof(struct in6_addr); + } + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN))); + tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); + } + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < (int)sizeof(struct in_addr)) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], sizeof(struct in_addr)); + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr))); + tlen -= (sizeof(struct in_addr)); + tptr += (sizeof(struct in_addr)); + } + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""%s"", isonsap_string(ndo, tptr, tlen))); + tptr += tlen; + tlen = 0; + break; + + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < BGP_VPN_RD_LEN+1) { + ND_PRINT((ndo, ""invalid len"")); + tlen = 0; + } else { + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""RD: %s, %s"", + bgp_vpn_rd_print(ndo, tptr), + isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN))); + /* rfc986 mapped IPv4 address ? */ + if (tlen == BGP_VPN_RD_LEN + 4 + sizeof(struct in_addr) + && EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) + ND_PRINT((ndo, "" = %s"", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4))); + /* rfc1888 mapped IPv6 address ? */ + else if (tlen == BGP_VPN_RD_LEN + 3 + sizeof(struct in6_addr) + && EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) + ND_PRINT((ndo, "" = %s"", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3))); + tptr += tlen; + tlen = 0; + } + break; + default: + ND_TCHECK2(tptr[0], tlen); + ND_PRINT((ndo, ""no AFI %u/SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + tptr += tlen; + tlen = 0; + goto done; + break; + } + } + } + ND_PRINT((ndo, "", nh-length: %u"", nhlen)); + tptr += tlen; + + ND_TCHECK(tptr[0]); + snpa = tptr[0]; + tptr++; + + if (snpa) { + ND_PRINT((ndo, ""\n\t %u SNPA"", snpa)); + for (/*nothing*/; snpa > 0; snpa--) { + ND_TCHECK(tptr[0]); + ND_PRINT((ndo, ""\n\t %d bytes"", tptr[0])); + tptr += tptr[0] + 1; + } + } else { + ND_PRINT((ndo, "", no SNPA"")); + } + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*tptr,tlen); + ND_PRINT((ndo, ""\n\t no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + done: + break; + + case BGPTYPE_MP_UNREACH_NLRI: + ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + ND_PRINT((ndo, ""\n\t AFI: %s (%u), %sSAFI: %s (%u)"", + tok2str(af_values, ""Unknown AFI"", af), + af, + (safi>128) ? ""vendor specific "" : """", /* 128 is meanwhile wellknown */ + tok2str(bgp_safi_values, ""Unknown SAFI"", safi), + safi)); + + if (len == BGP_MP_NLRI_MINSIZE) + ND_PRINT((ndo, ""\n\t End-of-Rib Marker (empty NLRI)"")); + + tptr += 3; + + while (tptr < pptr + len) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); + if (advance == -1) + ND_PRINT((ndo, ""\n\t (illegal prefix length)"")); + else if (advance == -2) + goto trunc; + else + ND_PRINT((ndo, ""\n\t %s"", buf)); + break; + default: + ND_TCHECK2(*(tptr-3),tlen); + ND_PRINT((ndo, ""no AFI %u / SAFI %u decoder"", af, safi)); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tptr-3, ""\n\t "", tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + break; + case BGPTYPE_EXTD_COMMUNITIES: + if (len % 8) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + while (tlen>0) { + uint16_t extd_comm; + + ND_TCHECK2(tptr[0], 2); + extd_comm=EXTRACT_16BITS(tptr); + + ND_PRINT((ndo, ""\n\t %s (0x%04x), Flags [%s]"", + tok2str(bgp_extd_comm_subtype_values, + ""unknown extd community typecode"", + extd_comm), + extd_comm, + bittok2str(bgp_extd_comm_flag_values, ""none"", extd_comm))); + + ND_TCHECK2(*(tptr+2), 6); + switch(extd_comm) { + case BGP_EXT_COM_RT_0: + case BGP_EXT_COM_RO_0: + case BGP_EXT_COM_L2VPN_RT_0: + ND_PRINT((ndo, "": %u:%u (= %s)"", + EXTRACT_16BITS(tptr+2), + EXTRACT_32BITS(tptr+4), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_EXT_COM_RT_1: + case BGP_EXT_COM_RO_1: + case BGP_EXT_COM_L2VPN_RT_1: + case BGP_EXT_COM_VRF_RT_IMP: + ND_PRINT((ndo, "": %s:%u"", + ipaddr_string(ndo, tptr+2), + EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_RT_2: + case BGP_EXT_COM_RO_2: + ND_PRINT((ndo, "": %s:%u"", + as_printf(ndo, astostr, sizeof(astostr), + EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6))); + break; + case BGP_EXT_COM_LINKBAND: + bw.i = EXTRACT_32BITS(tptr+2); + ND_PRINT((ndo, "": bandwidth: %.3f Mbps"", + bw.f*8/1000000)); + break; + case BGP_EXT_COM_VPN_ORIGIN: + case BGP_EXT_COM_VPN_ORIGIN2: + case BGP_EXT_COM_VPN_ORIGIN3: + case BGP_EXT_COM_VPN_ORIGIN4: + case BGP_EXT_COM_OSPF_RID: + case BGP_EXT_COM_OSPF_RID2: + ND_PRINT((ndo, ""%s"", ipaddr_string(ndo, tptr+2))); + break; + case BGP_EXT_COM_OSPF_RTYPE: + case BGP_EXT_COM_OSPF_RTYPE2: + ND_PRINT((ndo, "": area:%s, router-type:%s, metric-type:%s%s"", + ipaddr_string(ndo, tptr+2), + tok2str(bgp_extd_comm_ospf_rtype_values, + ""unknown (0x%02x)"", + *(tptr+6)), + (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? ""E2"" : """", + ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? ""E1"" : """")); + break; + case BGP_EXT_COM_L2INFO: + ND_PRINT((ndo, "": %s Control Flags [0x%02x]:MTU %u"", + tok2str(l2vpn_encaps_values, + ""unknown encaps"", + *(tptr+2)), + *(tptr+3), + EXTRACT_16BITS(tptr+4))); + break; + case BGP_EXT_COM_SOURCE_AS: + ND_PRINT((ndo, "": AS %u"", EXTRACT_16BITS(tptr+2))); + break; + default: + ND_TCHECK2(*tptr,8); + print_unknown_data(ndo, tptr, ""\n\t "", 8); + break; + } + tlen -=8; + tptr +=8; + } + break; + + case BGPTYPE_PMSI_TUNNEL: + { + uint8_t tunnel_type, flags; + + ND_TCHECK2(tptr[0], 5); + tunnel_type = *(tptr+1); + flags = *tptr; + tlen = len; + + ND_PRINT((ndo, ""\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u"", + tok2str(bgp_pmsi_tunnel_values, ""Unknown"", tunnel_type), + tunnel_type, + bittok2str(bgp_pmsi_flag_values, ""none"", flags), + EXTRACT_24BITS(tptr+2)>>4)); + + tptr +=5; + tlen -= 5; + + switch (tunnel_type) { + case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */ + case BGP_PMSI_TUNNEL_PIM_BIDIR: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Sender %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + + case BGP_PMSI_TUNNEL_PIM_SSM: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, P-Group %s"", + ipaddr_string(ndo, tptr), + ipaddr_string(ndo, tptr+4))); + break; + case BGP_PMSI_TUNNEL_INGRESS: + ND_TCHECK2(tptr[0], 4); + ND_PRINT((ndo, ""\n\t Tunnel-Endpoint %s"", + ipaddr_string(ndo, tptr))); + break; + case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */ + case BGP_PMSI_TUNNEL_LDP_MP2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Root-Node %s, LSP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + case BGP_PMSI_TUNNEL_RSVP_P2MP: + ND_TCHECK2(tptr[0], 8); + ND_PRINT((ndo, ""\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x"", + ipaddr_string(ndo, tptr), + EXTRACT_32BITS(tptr+4))); + break; + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr, ""\n\t "", tlen); + } + } + break; + } + case BGPTYPE_AIGP: + { + uint8_t type; + uint16_t length; + + tlen = len; + + while (tlen >= 3) { + + ND_TCHECK2(tptr[0], 3); + + type = *tptr; + length = EXTRACT_16BITS(tptr+1); + tptr += 3; + tlen -= 3; + + ND_PRINT((ndo, ""\n\t %s TLV (%u), length %u"", + tok2str(bgp_aigp_values, ""Unknown"", type), + type, length)); + + if (length < 3) + goto trunc; + length -= 3; + + /* + * Check if we can read the TLV data. + */ + ND_TCHECK2(tptr[3], length); + + switch (type) { + + case BGP_AIGP_TLV: + if (length < 8) + goto trunc; + ND_PRINT((ndo, "", metric %"" PRIu64, + EXTRACT_64BITS(tptr))); + break; + + default: + if (ndo->ndo_vflag <= 1) { + print_unknown_data(ndo, tptr,""\n\t "", length); + } + } + + tptr += length; + tlen -= length; + } + break; + } + case BGPTYPE_ATTR_SET: + ND_TCHECK2(tptr[0], 4); + if (len < 4) + goto trunc; + ND_PRINT((ndo, ""\n\t Origin AS: %s"", + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)))); + tptr+=4; + len -=4; + + while (len) { + u_int aflags, alenlen, alen; + + ND_TCHECK2(tptr[0], 2); + if (len < 2) + goto trunc; + aflags = *tptr; + atype = *(tptr + 1); + tptr += 2; + len -= 2; + alenlen = bgp_attr_lenlen(aflags, tptr); + ND_TCHECK2(tptr[0], alenlen); + if (len < alenlen) + goto trunc; + alen = bgp_attr_len(aflags, tptr); + tptr += alenlen; + len -= alenlen; + + ND_PRINT((ndo, ""\n\t %s (%u), length: %u"", + tok2str(bgp_attr_values, + ""Unknown Attribute"", atype), + atype, + alen)); + + if (aflags) { + ND_PRINT((ndo, "", Flags [%s%s%s%s"", + aflags & 0x80 ? ""O"" : """", + aflags & 0x40 ? ""T"" : """", + aflags & 0x20 ? ""P"" : """", + aflags & 0x10 ? ""E"" : """")); + if (aflags & 0xf) + ND_PRINT((ndo, ""+%x"", aflags & 0xf)); + ND_PRINT((ndo, ""]: "")); + } + /* The protocol encoding per se allows ATTR_SET to be nested as many times + * as the message can accommodate. This printer used to be able to recurse + * into ATTR_SET contents until the stack exhaustion, but now there is a + * limit on that (if live protocol exchange goes that many levels deep, + * something is probably wrong anyway). Feel free to refine this value if + * you can find the spec with respective normative text. + */ + if (attr_set_level == 10) + ND_PRINT((ndo, ""(too many nested levels, not recursing)"")); + else if (!bgp_attr_print(ndo, atype, tptr, alen, attr_set_level + 1)) + return 0; + tptr += alen; + len -= alen; + } + break; + + case BGPTYPE_LARGE_COMMUNITY: + if (len == 0 || len % 12) { + ND_PRINT((ndo, ""invalid len"")); + break; + } + ND_PRINT((ndo, ""\n\t "")); + while (len > 0) { + ND_TCHECK2(*tptr, 12); + ND_PRINT((ndo, ""%u:%u:%u%s"", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + (len > 12) ? "", "" : """")); + tptr += 12; + len -= 12; + } + break; + default: + ND_TCHECK2(*pptr,len); + ND_PRINT((ndo, ""\n\t no Attribute %u decoder"", atype)); /* we have no decoder for the attribute */ + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, pptr, ""\n\t "", len); + break; + } + if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/ + ND_TCHECK2(*pptr,len); + print_unknown_data(ndo, pptr, ""\n\t "", len); + } + return 1; + +trunc: + return 0; +} +","@@ -1361,7 +1361,7 @@ bgp_attr_get_as_size(netdissect_options *ndo, + + static int + bgp_attr_print(netdissect_options *ndo, +- u_int atype, const u_char *pptr, u_int len) ++ u_int atype, const u_char *pptr, u_int len, const unsigned attr_set_level) + { + int i; + uint16_t af; +@@ -2284,8 +2284,16 @@ bgp_attr_print(netdissect_options *ndo, + ND_PRINT((ndo, ""+%x"", aflags & 0xf)); + ND_PRINT((ndo, ""]: "")); + } +- /* FIXME check for recursion */ +- if (!bgp_attr_print(ndo, atype, tptr, alen)) ++ /* The protocol encoding per se allows ATTR_SET to be nested as many times ++ * as the message can accommodate. This printer used to be able to recurse ++ * into ATTR_SET contents until the stack exhaustion, but now there is a ++ * limit on that (if live protocol exchange goes that many levels deep, ++ * something is probably wrong anyway). Feel free to refine this value if ++ * you can find the spec with respective normative text. ++ */ ++ if (attr_set_level == 10) ++ ND_PRINT((ndo, ""(too many nested levels, not recursing)"")); ++ else if (!bgp_attr_print(ndo, atype, tptr, alen, attr_set_level + 1)) + return 0; + tptr += alen; + len -= alen; +@@ -2592,7 +2600,7 @@ bgp_update_print(netdissect_options *ndo, + goto trunc; + if (length < alen) + goto trunc; +- if (!bgp_attr_print(ndo, atype, p, alen)) ++ if (!bgp_attr_print(ndo, atype, p, alen, 0)) + goto trunc; + p += alen; + len -= alen;",9871,10107,11000 +18172,"static Image *ReadTIFFImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + const char + *option; + + float + *chromaticity, + x_position, + y_position, + x_resolution, + y_resolution; + + Image + *image; + + int + tiff_status; + + MagickBooleanType + status; + + MagickSizeType + number_pixels; + + QuantumInfo + *quantum_info; + + QuantumType + quantum_type; + + register ssize_t + i; + + size_t + pad; + + ssize_t + y; + + TIFF + *tiff; + + TIFFMethodType + method; + + uint16 + compress_tag, + bits_per_sample, + endian, + extra_samples, + interlace, + max_sample_value, + min_sample_value, + orientation, + pages, + photometric, + *sample_info, + sample_format, + samples_per_pixel, + units, + value; + + uint32 + height, + rows_per_strip, + width; + + unsigned char + *pixels; + + /* + Open image. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + (void) SetMagickThreadValue(tiff_exception,exception); + tiff=TIFFClientOpen(image->filename,""rb"",(thandle_t) image,TIFFReadBlob, + TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob, + TIFFUnmapBlob); + if (tiff == (TIFF *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + if (image_info->number_scenes != 0) + { + /* + Generate blank images for subimage specification (e.g. image.tif[4]. + We need to check the number of directores because it is possible that + the subimage(s) are stored in the photoshop profile. + */ + if (image_info->scene < (size_t)TIFFNumberOfDirectories(tiff)) + { + for (i=0; i < (ssize_t) image_info->scene; i++) + { + status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse; + if (status == MagickFalse) + { + TIFFClose(tiff); + image=DestroyImageList(image); + return((Image *) NULL); + } + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + TIFFClose(tiff); + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + } + } + } + do + { +DisableMSCWarning(4127) + if (0 && (image_info->verbose != MagickFalse)) + TIFFPrintDirectory(tiff,stdout,MagickFalse); +RestoreMSCWarning + if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) || + (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric) != 1)) + { + TIFFClose(tiff); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (sample_format == SAMPLEFORMAT_IEEEFP) + (void) SetImageProperty(image,""quantum:format"",""floating-point""); + switch (photometric) + { + case PHOTOMETRIC_MINISBLACK: + { + (void) SetImageProperty(image,""tiff:photometric"",""min-is-black""); + break; + } + case PHOTOMETRIC_MINISWHITE: + { + (void) SetImageProperty(image,""tiff:photometric"",""min-is-white""); + break; + } + case PHOTOMETRIC_PALETTE: + { + (void) SetImageProperty(image,""tiff:photometric"",""palette""); + break; + } + case PHOTOMETRIC_RGB: + { + (void) SetImageProperty(image,""tiff:photometric"",""RGB""); + break; + } + case PHOTOMETRIC_CIELAB: + { + (void) SetImageProperty(image,""tiff:photometric"",""CIELAB""); + break; + } + case PHOTOMETRIC_LOGL: + { + (void) SetImageProperty(image,""tiff:photometric"",""CIE Log2(L)""); + break; + } + case PHOTOMETRIC_LOGLUV: + { + (void) SetImageProperty(image,""tiff:photometric"",""LOGLUV""); + break; + } +#if defined(PHOTOMETRIC_MASK) + case PHOTOMETRIC_MASK: + { + (void) SetImageProperty(image,""tiff:photometric"",""MASK""); + break; + } +#endif + case PHOTOMETRIC_SEPARATED: + { + (void) SetImageProperty(image,""tiff:photometric"",""separated""); + break; + } + case PHOTOMETRIC_YCBCR: + { + (void) SetImageProperty(image,""tiff:photometric"",""YCBCR""); + break; + } + default: + { + (void) SetImageProperty(image,""tiff:photometric"",""unknown""); + break; + } + } + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Geometry: %ux%u"", + (unsigned int) width,(unsigned int) height); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Interlace: %u"", + interlace); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Bits per sample: %u"",bits_per_sample); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Min sample value: %u"",min_sample_value); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Max sample value: %u"",max_sample_value); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Photometric "" + ""interpretation: %s"",GetImageProperty(image,""tiff:photometric"")); + } + image->columns=(size_t) width; + image->rows=(size_t) height; + image->depth=(size_t) bits_per_sample; + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Image depth: %.20g"", + (double) image->depth); + image->endian=MSBEndian; + if (endian == FILLORDER_LSB2MSB) + image->endian=LSBEndian; +#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN) + if (TIFFIsBigEndian(tiff) == 0) + { + (void) SetImageProperty(image,""tiff:endian"",""lsb""); + image->endian=LSBEndian; + } + else + { + (void) SetImageProperty(image,""tiff:endian"",""msb""); + image->endian=MSBEndian; + } +#endif + if ((photometric == PHOTOMETRIC_MINISBLACK) || + (photometric == PHOTOMETRIC_MINISWHITE)) + SetImageColorspace(image,GRAYColorspace); + if (photometric == PHOTOMETRIC_SEPARATED) + SetImageColorspace(image,CMYKColorspace); + if (photometric == PHOTOMETRIC_CIELAB) + SetImageColorspace(image,LabColorspace); + TIFFGetProfiles(tiff,image,image_info->ping); + TIFFGetProperties(tiff,image); + option=GetImageOption(image_info,""tiff:exif-properties""); + if ((option == (const char *) NULL) || + (IsMagickTrue(option) != MagickFalse)) + TIFFGetEXIFProperties(tiff,image); + if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution) == 1) && + (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution) == 1)) + { + image->x_resolution=x_resolution; + image->y_resolution=y_resolution; + } + if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units) == 1) + { + if (units == RESUNIT_INCH) + image->units=PixelsPerInchResolution; + if (units == RESUNIT_CENTIMETER) + image->units=PixelsPerCentimeterResolution; + } + if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position) == 1) && + (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position) == 1)) + { + image->page.x=(ssize_t) ceil(x_position*image->x_resolution-0.5); + image->page.y=(ssize_t) ceil(y_position*image->y_resolution-0.5); + } + if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation) == 1) + image->orientation=(OrientationType) orientation; + if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1) + { + if (chromaticity != (float *) NULL) + { + image->chromaticity.white_point.x=chromaticity[0]; + image->chromaticity.white_point.y=chromaticity[1]; + } + } + if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1) + { + if (chromaticity != (float *) NULL) + { + image->chromaticity.red_primary.x=chromaticity[0]; + image->chromaticity.red_primary.y=chromaticity[1]; + image->chromaticity.green_primary.x=chromaticity[2]; + image->chromaticity.green_primary.y=chromaticity[3]; + image->chromaticity.blue_primary.x=chromaticity[4]; + image->chromaticity.blue_primary.y=chromaticity[5]; + } + } +#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919) + if ((compress_tag != COMPRESSION_NONE) && + (TIFFIsCODECConfigured(compress_tag) == 0)) + { + TIFFClose(tiff); + ThrowReaderException(CoderError,""CompressNotSupported""); + } +#endif + switch (compress_tag) + { + case COMPRESSION_NONE: image->compression=NoCompression; break; + case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break; + case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break; + case COMPRESSION_JPEG: + { + image->compression=JPEGCompression; +#if defined(JPEG_SUPPORT) + { + char + sampling_factor[MaxTextExtent]; + + int + tiff_status; + + uint16 + horizontal, + vertical; + + tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING, + &horizontal,&vertical); + if (tiff_status == 1) + { + (void) FormatLocaleString(sampling_factor,MaxTextExtent,""%dx%d"", + horizontal,vertical); + (void) SetImageProperty(image,""jpeg:sampling-factor"", + sampling_factor); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Sampling Factors: %s"",sampling_factor); + } + } +#endif + break; + } + case COMPRESSION_OJPEG: image->compression=JPEGCompression; break; +#if defined(COMPRESSION_LZMA) + case COMPRESSION_LZMA: image->compression=LZMACompression; break; +#endif + case COMPRESSION_LZW: image->compression=LZWCompression; break; + case COMPRESSION_DEFLATE: image->compression=ZipCompression; break; + case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break; + default: image->compression=RLECompression; break; + } + /* + Allocate memory for the image and pixel buffer. + */ + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + if (sample_format == SAMPLEFORMAT_UINT) + status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat); + if (sample_format == SAMPLEFORMAT_INT) + status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat); + if (sample_format == SAMPLEFORMAT_IEEEFP) + status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat); + if (status == MagickFalse) + { + TIFFClose(tiff); + quantum_info=DestroyQuantumInfo(quantum_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + status=MagickTrue; + switch (photometric) + { + case PHOTOMETRIC_MINISBLACK: + { + quantum_info->min_is_white=MagickFalse; + break; + } + case PHOTOMETRIC_MINISWHITE: + { + quantum_info->min_is_white=MagickTrue; + break; + } + default: + break; + } + tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples, + &sample_info); + if (tiff_status == 1) + { + (void) SetImageProperty(image,""tiff:alpha"",""unspecified""); + if (extra_samples == 0) + { + if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB)) + image->matte=MagickTrue; + } + else + for (i=0; i < extra_samples; i++) + { + image->matte=MagickTrue; + if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA) + { + SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha); + (void) SetImageProperty(image,""tiff:alpha"",""associated""); + } + else + if (sample_info[i] == EXTRASAMPLE_UNASSALPHA) + (void) SetImageProperty(image,""tiff:alpha"",""unassociated""); + } + } + if ((photometric == PHOTOMETRIC_PALETTE) && + (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize)) + { + size_t + colors; + + colors=(size_t) GetQuantumRange(bits_per_sample)+1; + if (AcquireImageColormap(image,colors) == MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + } + if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages) == 1) + image->scene=value; + if (image->storage_class == PseudoClass) + { + int + tiff_status; + + size_t + range; + + uint16 + *blue_colormap, + *green_colormap, + *red_colormap; + + /* + Initialize colormap. + */ + tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap, + &green_colormap,&blue_colormap); + if (tiff_status == 1) + { + if ((red_colormap != (uint16 *) NULL) && + (green_colormap != (uint16 *) NULL) && + (blue_colormap != (uint16 *) NULL)) + { + range=255; /* might be old style 8-bit colormap */ + for (i=0; i < (ssize_t) image->colors; i++) + if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) || + (blue_colormap[i] >= 256)) + { + range=65535; + break; + } + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ClampToQuantum(((double) + QuantumRange*red_colormap[i])/range); + image->colormap[i].green=ClampToQuantum(((double) + QuantumRange*green_colormap[i])/range); + image->colormap[i].blue=ClampToQuantum(((double) + QuantumRange*blue_colormap[i])/range); + } + } + } + if (image->matte == MagickFalse) + image->depth=GetImageDepth(image,exception); + } + if (image_info->ping != MagickFalse) + { + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + { + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + goto next_tiff_frame; + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + method=ReadGenericMethod; + if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1) + { + char + value[MaxTextExtent]; + + method=ReadStripMethod; + (void) FormatLocaleString(value,MaxTextExtent,""%u"",(unsigned int) + rows_per_strip); + (void) SetImageProperty(image,""tiff:rows-per-strip"",value); + } + if ((samples_per_pixel >= 2) && (interlace == PLANARCONFIG_CONTIG)) + method=ReadRGBAMethod; + if ((samples_per_pixel >= 2) && (interlace == PLANARCONFIG_SEPARATE)) + method=ReadCMYKAMethod; + if ((photometric != PHOTOMETRIC_RGB) && + (photometric != PHOTOMETRIC_CIELAB) && + (photometric != PHOTOMETRIC_SEPARATED)) + method=ReadGenericMethod; + if (image->storage_class == PseudoClass) + method=ReadSingleSampleMethod; + if ((photometric == PHOTOMETRIC_MINISBLACK) || + (photometric == PHOTOMETRIC_MINISWHITE)) + method=ReadSingleSampleMethod; + if ((photometric != PHOTOMETRIC_SEPARATED) && + (interlace == PLANARCONFIG_SEPARATE) && (bits_per_sample < 64)) + method=ReadGenericMethod; + if (image->compression == JPEGCompression) + method=GetJPEGMethod(image,tiff,photometric,bits_per_sample, + samples_per_pixel); + if (compress_tag == COMPRESSION_JBIG) + method=ReadStripMethod; + if (TIFFIsTiled(tiff) != MagickFalse) + method=ReadTileMethod; + quantum_info->endian=LSBEndian; + quantum_type=RGBQuantum; + pixels=GetQuantumPixels(quantum_info); + switch (method) + { + case ReadSingleSampleMethod: + { + /* + Convert TIFF image to PseudoClass MIFF image. + */ + quantum_type=IndexQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-1,0); + if (image->matte != MagickFalse) + { + if (image->storage_class != PseudoClass) + { + quantum_type=samples_per_pixel == 1 ? AlphaQuantum : + GrayAlphaQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-2,0); + } + else + { + quantum_type=IndexAlphaQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-2,0); + } + } + else + if (image->storage_class != PseudoClass) + { + quantum_type=GrayQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-1,0); + } + status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3)); + if (status == MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + int + status; + + register PixelPacket + *magick_restrict q; + + status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels); + if (status == -1) + break; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadRGBAMethod: + { + /* + Convert TIFF image to DirectClass MIFF image. + */ + pad=(size_t) MagickMax((size_t) samples_per_pixel-3,0); + quantum_type=RGBQuantum; + if (image->matte != MagickFalse) + { + quantum_type=RGBAQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0); + } + if (image->colorspace == CMYKColorspace) + { + pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0); + quantum_type=CMYKQuantum; + if (image->matte != MagickFalse) + { + quantum_type=CMYKAQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-5,0); + } + } + status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3)); + if (status == MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + int + status; + + register PixelPacket + *magick_restrict q; + + status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels); + if (status == -1) + break; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadCMYKAMethod: + { + /* + Convert TIFF image to DirectClass MIFF image. + */ + for (i=0; i < (ssize_t) samples_per_pixel; i++) + { + for (y=0; y < (ssize_t) image->rows; y++) + { + register PixelPacket + *magick_restrict q; + + int + status; + + status=TIFFReadPixels(tiff,bits_per_sample,(tsample_t) i,y,(char *) + pixels); + if (status == -1) + break; + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + if (image->colorspace != CMYKColorspace) + switch (i) + { + case 0: quantum_type=RedQuantum; break; + case 1: quantum_type=GreenQuantum; break; + case 2: quantum_type=BlueQuantum; break; + case 3: quantum_type=AlphaQuantum; break; + default: quantum_type=UndefinedQuantum; break; + } + else + switch (i) + { + case 0: quantum_type=CyanQuantum; break; + case 1: quantum_type=MagentaQuantum; break; + case 2: quantum_type=YellowQuantum; break; + case 3: quantum_type=BlackQuantum; break; + case 4: quantum_type=AlphaQuantum; break; + default: quantum_type=UndefinedQuantum; break; + } + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadYCCKMethod: + { + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + int + status; + + register IndexPacket + *indexes; + + register PixelPacket + *magick_restrict q; + + register ssize_t + x; + + unsigned char + *p; + + status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels); + if (status == -1) + break; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + p=pixels; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelCyan(q,ScaleCharToQuantum(ClampYCC((double) *p+ + (1.402*(double) *(p+2))-179.456))); + SetPixelMagenta(q,ScaleCharToQuantum(ClampYCC((double) *p- + (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+ + 135.45984))); + SetPixelYellow(q,ScaleCharToQuantum(ClampYCC((double) *p+ + (1.772*(double) *(p+1))-226.816))); + SetPixelBlack(indexes+x,ScaleCharToQuantum((unsigned char)*(p+3))); + q++; + p+=4; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadStripMethod: + { + register uint32 + *p; + + /* + Convert stripped TIFF image to DirectClass MIFF image. + */ + i=0; + p=(uint32 *) NULL; + for (y=0; y < (ssize_t) image->rows; y++) + { + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + if (i == 0) + { + if (TIFFReadRGBAStrip(tiff,(tstrip_t) y,(uint32 *) pixels) == 0) + break; + i=(ssize_t) MagickMin((ssize_t) rows_per_strip,(ssize_t) + image->rows-y); + } + i--; + p=((uint32 *) pixels)+image->columns*i; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + (TIFFGetR(*p)))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + (TIFFGetG(*p)))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + (TIFFGetB(*p)))); + if (image->matte != MagickFalse) + SetPixelOpacity(q,ScaleCharToQuantum((unsigned char) + (TIFFGetA(*p)))); + p++; + q++; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadTileMethod: + { + register uint32 + *p; + + uint32 + *tile_pixels, + columns, + rows; + + /* + Convert tiled TIFF image to DirectClass MIFF image. + */ + if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) || + (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1)) + { + TIFFClose(tiff); + ThrowReaderException(CoderError,""ImageIsNotTiled""); + } + (void) SetImageStorageClass(image,DirectClass); + number_pixels=(MagickSizeType) columns*rows; + if ((number_pixels*sizeof(uint32)) != (MagickSizeType) ((size_t) + (number_pixels*sizeof(uint32)))) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + tile_pixels=(uint32 *) AcquireQuantumMemory(number_pixels, + sizeof(*tile_pixels)); + if (tile_pixels == (uint32 *) NULL) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + for (y=0; y < (ssize_t) image->rows; y+=rows) + { + PixelPacket + *tile; + + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + size_t + columns_remaining, + rows_remaining; + + rows_remaining=image->rows-y; + if ((ssize_t) (y+rows) < (ssize_t) image->rows) + rows_remaining=rows; + tile=QueueAuthenticPixels(image,0,y,image->columns,rows_remaining, + exception); + if (tile == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x+=columns) + { + size_t + column, + row; + + if (TIFFReadRGBATile(tiff,(uint32) x,(uint32) y,tile_pixels) == 0) + break; + columns_remaining=image->columns-x; + if ((ssize_t) (x+columns) < (ssize_t) image->columns) + columns_remaining=columns; + p=tile_pixels+(rows-rows_remaining)*columns; + q=tile+(image->columns*(rows_remaining-1)+x); + for (row=rows_remaining; row > 0; row--) + { + if (image->matte != MagickFalse) + for (column=columns_remaining; column > 0; column--) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + TIFFGetR(*p))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + TIFFGetG(*p))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + TIFFGetB(*p))); + SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) + TIFFGetA(*p))); + q++; + p++; + } + else + for (column=columns_remaining; column > 0; column--) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + TIFFGetR(*p))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + TIFFGetG(*p))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + TIFFGetB(*p))); + q++; + p++; + } + p+=columns-columns_remaining; + q-=(image->columns+columns_remaining); + } + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + tile_pixels=(uint32 *) RelinquishMagickMemory(tile_pixels); + break; + } + case ReadGenericMethod: + default: + { + MemoryInfo + *pixel_info; + + register uint32 + *p; + + uint32 + *pixels; + + /* + Convert TIFF image to DirectClass MIFF image. + */ + number_pixels=(MagickSizeType) image->columns*image->rows; + if ((number_pixels*sizeof(uint32)) != (MagickSizeType) ((size_t) + (number_pixels*sizeof(uint32)))) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixel_info=AcquireVirtualMemory(image->columns,image->rows* + sizeof(uint32)); + if (pixel_info == (MemoryInfo *) NULL) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=(uint32 *) GetVirtualMemoryBlob(pixel_info); + (void) TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32) + image->rows,(uint32 *) pixels,0); + /* + Convert image to DirectClass pixel packets. + */ + p=pixels+number_pixels-1; + for (y=0; y < (ssize_t) image->rows; y++) + { + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + q+=image->columns-1; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) TIFFGetR(*p))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) TIFFGetG(*p))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) TIFFGetB(*p))); + if (image->matte != MagickFalse) + SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) TIFFGetA(*p))); + p--; + q--; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + pixel_info=RelinquishVirtualMemory(pixel_info); + break; + } + } + SetQuantumImageType(image,quantum_type); + next_tiff_frame: + quantum_info=DestroyQuantumInfo(quantum_info); + if (photometric == PHOTOMETRIC_CIELAB) + DecodeLabImage(image,exception); + if ((photometric == PHOTOMETRIC_LOGL) || + (photometric == PHOTOMETRIC_MINISBLACK) || + (photometric == PHOTOMETRIC_MINISWHITE)) + { + image->type=GrayscaleType; + if (bits_per_sample == 1) + image->type=BilevelType; + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse; + if (status != MagickFalse) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,image->scene-1, + image->scene); + if (status == MagickFalse) + break; + } + } while (status != MagickFalse); + TIFFClose(tiff); + TIFFReadPhotoshopLayers(image,image_info,exception); + if (image_info->number_scenes != 0) + { + if (image_info->scene >= GetImageListLength(image)) + { + /* Subimage was not found in the Photoshop layer */ + image = DestroyImageList(image); + return((Image *)NULL); + } + } + return(GetFirstImageInList(image)); +} +",1,"static Image *ReadTIFFImage(const ImageInfo *image_info, + ExceptionInfo *exception) +{ + const char + *option; + + float + *chromaticity, + x_position, + y_position, + x_resolution, + y_resolution; + + Image + *image; + + int + tiff_status; + + MagickBooleanType + status; + + MagickSizeType + number_pixels; + + QuantumInfo + *quantum_info; + + QuantumType + quantum_type; + + register ssize_t + i; + + size_t + pad; + + ssize_t + y; + + TIFF + *tiff; + + TIFFMethodType + method; + + uint16 + compress_tag, + bits_per_sample, + endian, + extra_samples, + interlace, + max_sample_value, + min_sample_value, + orientation, + pages, + photometric, + *sample_info, + sample_format, + samples_per_pixel, + units, + value; + + uint32 + height, + rows_per_strip, + width; + + unsigned char + *pixels; + + /* + Open image. + */ + assert(image_info != (const ImageInfo *) NULL); + assert(image_info->signature == MagickSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),""%s"", + image_info->filename); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickSignature); + image=AcquireImage(image_info); + status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); + if (status == MagickFalse) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + (void) SetMagickThreadValue(tiff_exception,exception); + tiff=TIFFClientOpen(image->filename,""rb"",(thandle_t) image,TIFFReadBlob, + TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob, + TIFFUnmapBlob); + if (tiff == (TIFF *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + if (image_info->number_scenes != 0) + { + /* + Generate blank images for subimage specification (e.g. image.tif[4]. + We need to check the number of directores because it is possible that + the subimage(s) are stored in the photoshop profile. + */ + if (image_info->scene < (size_t)TIFFNumberOfDirectories(tiff)) + { + for (i=0; i < (ssize_t) image_info->scene; i++) + { + status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse; + if (status == MagickFalse) + { + TIFFClose(tiff); + image=DestroyImageList(image); + return((Image *) NULL); + } + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + TIFFClose(tiff); + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + } + } + } + do + { +DisableMSCWarning(4127) + if (0 && (image_info->verbose != MagickFalse)) + TIFFPrintDirectory(tiff,stdout,MagickFalse); +RestoreMSCWarning + if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) || + (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value) != 1) || + (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric) != 1)) + { + TIFFClose(tiff); + ThrowReaderException(CorruptImageError,""ImproperImageHeader""); + } + if (sample_format == SAMPLEFORMAT_IEEEFP) + (void) SetImageProperty(image,""quantum:format"",""floating-point""); + switch (photometric) + { + case PHOTOMETRIC_MINISBLACK: + { + (void) SetImageProperty(image,""tiff:photometric"",""min-is-black""); + break; + } + case PHOTOMETRIC_MINISWHITE: + { + (void) SetImageProperty(image,""tiff:photometric"",""min-is-white""); + break; + } + case PHOTOMETRIC_PALETTE: + { + (void) SetImageProperty(image,""tiff:photometric"",""palette""); + break; + } + case PHOTOMETRIC_RGB: + { + (void) SetImageProperty(image,""tiff:photometric"",""RGB""); + break; + } + case PHOTOMETRIC_CIELAB: + { + (void) SetImageProperty(image,""tiff:photometric"",""CIELAB""); + break; + } + case PHOTOMETRIC_LOGL: + { + (void) SetImageProperty(image,""tiff:photometric"",""CIE Log2(L)""); + break; + } + case PHOTOMETRIC_LOGLUV: + { + (void) SetImageProperty(image,""tiff:photometric"",""LOGLUV""); + break; + } +#if defined(PHOTOMETRIC_MASK) + case PHOTOMETRIC_MASK: + { + (void) SetImageProperty(image,""tiff:photometric"",""MASK""); + break; + } +#endif + case PHOTOMETRIC_SEPARATED: + { + (void) SetImageProperty(image,""tiff:photometric"",""separated""); + break; + } + case PHOTOMETRIC_YCBCR: + { + (void) SetImageProperty(image,""tiff:photometric"",""YCBCR""); + break; + } + default: + { + (void) SetImageProperty(image,""tiff:photometric"",""unknown""); + break; + } + } + if (image->debug != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Geometry: %ux%u"", + (unsigned int) width,(unsigned int) height); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Interlace: %u"", + interlace); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Bits per sample: %u"",bits_per_sample); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Min sample value: %u"",min_sample_value); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Max sample value: %u"",max_sample_value); + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Photometric "" + ""interpretation: %s"",GetImageProperty(image,""tiff:photometric"")); + } + image->columns=(size_t) width; + image->rows=(size_t) height; + image->depth=(size_t) bits_per_sample; + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(),""Image depth: %.20g"", + (double) image->depth); + image->endian=MSBEndian; + if (endian == FILLORDER_LSB2MSB) + image->endian=LSBEndian; +#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN) + if (TIFFIsBigEndian(tiff) == 0) + { + (void) SetImageProperty(image,""tiff:endian"",""lsb""); + image->endian=LSBEndian; + } + else + { + (void) SetImageProperty(image,""tiff:endian"",""msb""); + image->endian=MSBEndian; + } +#endif + if ((photometric == PHOTOMETRIC_MINISBLACK) || + (photometric == PHOTOMETRIC_MINISWHITE)) + SetImageColorspace(image,GRAYColorspace); + if (photometric == PHOTOMETRIC_SEPARATED) + SetImageColorspace(image,CMYKColorspace); + if (photometric == PHOTOMETRIC_CIELAB) + SetImageColorspace(image,LabColorspace); + TIFFGetProfiles(tiff,image,image_info->ping); + TIFFGetProperties(tiff,image); + option=GetImageOption(image_info,""tiff:exif-properties""); + if ((option == (const char *) NULL) || + (IsMagickTrue(option) != MagickFalse)) + TIFFGetEXIFProperties(tiff,image); + if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution) == 1) && + (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution) == 1)) + { + image->x_resolution=x_resolution; + image->y_resolution=y_resolution; + } + if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units) == 1) + { + if (units == RESUNIT_INCH) + image->units=PixelsPerInchResolution; + if (units == RESUNIT_CENTIMETER) + image->units=PixelsPerCentimeterResolution; + } + if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position) == 1) && + (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position) == 1)) + { + image->page.x=(ssize_t) ceil(x_position*image->x_resolution-0.5); + image->page.y=(ssize_t) ceil(y_position*image->y_resolution-0.5); + } + if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation) == 1) + image->orientation=(OrientationType) orientation; + if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1) + { + if (chromaticity != (float *) NULL) + { + image->chromaticity.white_point.x=chromaticity[0]; + image->chromaticity.white_point.y=chromaticity[1]; + } + } + if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1) + { + if (chromaticity != (float *) NULL) + { + image->chromaticity.red_primary.x=chromaticity[0]; + image->chromaticity.red_primary.y=chromaticity[1]; + image->chromaticity.green_primary.x=chromaticity[2]; + image->chromaticity.green_primary.y=chromaticity[3]; + image->chromaticity.blue_primary.x=chromaticity[4]; + image->chromaticity.blue_primary.y=chromaticity[5]; + } + } +#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919) + if ((compress_tag != COMPRESSION_NONE) && + (TIFFIsCODECConfigured(compress_tag) == 0)) + { + TIFFClose(tiff); + ThrowReaderException(CoderError,""CompressNotSupported""); + } +#endif + switch (compress_tag) + { + case COMPRESSION_NONE: image->compression=NoCompression; break; + case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break; + case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break; + case COMPRESSION_JPEG: + { + image->compression=JPEGCompression; +#if defined(JPEG_SUPPORT) + { + char + sampling_factor[MaxTextExtent]; + + int + tiff_status; + + uint16 + horizontal, + vertical; + + tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING, + &horizontal,&vertical); + if (tiff_status == 1) + { + (void) FormatLocaleString(sampling_factor,MaxTextExtent,""%dx%d"", + horizontal,vertical); + (void) SetImageProperty(image,""jpeg:sampling-factor"", + sampling_factor); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + ""Sampling Factors: %s"",sampling_factor); + } + } +#endif + break; + } + case COMPRESSION_OJPEG: image->compression=JPEGCompression; break; +#if defined(COMPRESSION_LZMA) + case COMPRESSION_LZMA: image->compression=LZMACompression; break; +#endif + case COMPRESSION_LZW: image->compression=LZWCompression; break; + case COMPRESSION_DEFLATE: image->compression=ZipCompression; break; + case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break; + default: image->compression=RLECompression; break; + } + /* + Allocate memory for the image and pixel buffer. + */ + quantum_info=AcquireQuantumInfo(image_info,image); + if (quantum_info == (QuantumInfo *) NULL) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + if (sample_format == SAMPLEFORMAT_UINT) + status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat); + if (sample_format == SAMPLEFORMAT_INT) + status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat); + if (sample_format == SAMPLEFORMAT_IEEEFP) + status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat); + if (status == MagickFalse) + { + TIFFClose(tiff); + quantum_info=DestroyQuantumInfo(quantum_info); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + status=MagickTrue; + switch (photometric) + { + case PHOTOMETRIC_MINISBLACK: + { + quantum_info->min_is_white=MagickFalse; + break; + } + case PHOTOMETRIC_MINISWHITE: + { + quantum_info->min_is_white=MagickTrue; + break; + } + default: + break; + } + tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples, + &sample_info); + if (tiff_status == 1) + { + (void) SetImageProperty(image,""tiff:alpha"",""unspecified""); + if (extra_samples == 0) + { + if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB)) + image->matte=MagickTrue; + } + else + for (i=0; i < extra_samples; i++) + { + image->matte=MagickTrue; + if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA) + { + SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha); + (void) SetImageProperty(image,""tiff:alpha"",""associated""); + } + else + if (sample_info[i] == EXTRASAMPLE_UNASSALPHA) + (void) SetImageProperty(image,""tiff:alpha"",""unassociated""); + } + } + if ((photometric == PHOTOMETRIC_PALETTE) && + (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize)) + { + size_t + colors; + + colors=(size_t) GetQuantumRange(bits_per_sample)+1; + if (AcquireImageColormap(image,colors) == MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + } + if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages) == 1) + image->scene=value; + if (image->storage_class == PseudoClass) + { + int + tiff_status; + + size_t + range; + + uint16 + *blue_colormap, + *green_colormap, + *red_colormap; + + /* + Initialize colormap. + */ + tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap, + &green_colormap,&blue_colormap); + if (tiff_status == 1) + { + if ((red_colormap != (uint16 *) NULL) && + (green_colormap != (uint16 *) NULL) && + (blue_colormap != (uint16 *) NULL)) + { + range=255; /* might be old style 8-bit colormap */ + for (i=0; i < (ssize_t) image->colors; i++) + if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) || + (blue_colormap[i] >= 256)) + { + range=65535; + break; + } + for (i=0; i < (ssize_t) image->colors; i++) + { + image->colormap[i].red=ClampToQuantum(((double) + QuantumRange*red_colormap[i])/range); + image->colormap[i].green=ClampToQuantum(((double) + QuantumRange*green_colormap[i])/range); + image->colormap[i].blue=ClampToQuantum(((double) + QuantumRange*blue_colormap[i])/range); + } + } + } + if (image->matte == MagickFalse) + image->depth=GetImageDepth(image,exception); + } + if (image_info->ping != MagickFalse) + { + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + { + quantum_info=DestroyQuantumInfo(quantum_info); + break; + } + goto next_tiff_frame; + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + { + InheritException(exception,&image->exception); + return(DestroyImageList(image)); + } + method=ReadGenericMethod; + if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1) + { + char + value[MaxTextExtent]; + + method=ReadStripMethod; + (void) FormatLocaleString(value,MaxTextExtent,""%u"",(unsigned int) + rows_per_strip); + (void) SetImageProperty(image,""tiff:rows-per-strip"",value); + } + if ((samples_per_pixel >= 2) && (interlace == PLANARCONFIG_CONTIG)) + method=ReadRGBAMethod; + if ((samples_per_pixel >= 2) && (interlace == PLANARCONFIG_SEPARATE)) + method=ReadCMYKAMethod; + if ((photometric != PHOTOMETRIC_RGB) && + (photometric != PHOTOMETRIC_CIELAB) && + (photometric != PHOTOMETRIC_SEPARATED)) + method=ReadGenericMethod; + if (image->storage_class == PseudoClass) + method=ReadSingleSampleMethod; + if ((photometric == PHOTOMETRIC_MINISBLACK) || + (photometric == PHOTOMETRIC_MINISWHITE)) + method=ReadSingleSampleMethod; + if ((photometric != PHOTOMETRIC_SEPARATED) && + (interlace == PLANARCONFIG_SEPARATE) && (bits_per_sample < 64)) + method=ReadGenericMethod; + if (image->compression == JPEGCompression) + method=GetJPEGMethod(image,tiff,photometric,bits_per_sample, + samples_per_pixel); + if (compress_tag == COMPRESSION_JBIG) + method=ReadStripMethod; + if (TIFFIsTiled(tiff) != MagickFalse) + method=ReadTileMethod; + quantum_info->endian=LSBEndian; + quantum_type=RGBQuantum; + pixels=GetQuantumPixels(quantum_info); + switch (method) + { + case ReadSingleSampleMethod: + { + /* + Convert TIFF image to PseudoClass MIFF image. + */ + quantum_type=IndexQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-1,0); + if (image->matte != MagickFalse) + { + if (image->storage_class != PseudoClass) + { + quantum_type=samples_per_pixel == 1 ? AlphaQuantum : + GrayAlphaQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-2,0); + } + else + { + quantum_type=IndexAlphaQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-2,0); + } + } + else + if (image->storage_class != PseudoClass) + { + quantum_type=GrayQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-1,0); + } + status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3)); + if (status == MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + int + status; + + register PixelPacket + *magick_restrict q; + + status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels); + if (status == -1) + break; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadRGBAMethod: + { + /* + Convert TIFF image to DirectClass MIFF image. + */ + pad=(size_t) MagickMax((size_t) samples_per_pixel-3,0); + quantum_type=RGBQuantum; + if (image->matte != MagickFalse) + { + quantum_type=RGBAQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0); + } + if (image->colorspace == CMYKColorspace) + { + pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0); + quantum_type=CMYKQuantum; + if (image->matte != MagickFalse) + { + quantum_type=CMYKAQuantum; + pad=(size_t) MagickMax((size_t) samples_per_pixel-5,0); + } + } + status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3)); + if (status == MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + int + status; + + register PixelPacket + *magick_restrict q; + + status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels); + if (status == -1) + break; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadCMYKAMethod: + { + /* + Convert TIFF image to DirectClass MIFF image. + */ + for (i=0; i < (ssize_t) samples_per_pixel; i++) + { + for (y=0; y < (ssize_t) image->rows; y++) + { + register PixelPacket + *magick_restrict q; + + int + status; + + status=TIFFReadPixels(tiff,bits_per_sample,(tsample_t) i,y,(char *) + pixels); + if (status == -1) + break; + q=GetAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + if (image->colorspace != CMYKColorspace) + switch (i) + { + case 0: quantum_type=RedQuantum; break; + case 1: quantum_type=GreenQuantum; break; + case 2: quantum_type=BlueQuantum; break; + case 3: quantum_type=AlphaQuantum; break; + default: quantum_type=UndefinedQuantum; break; + } + else + switch (i) + { + case 0: quantum_type=CyanQuantum; break; + case 1: quantum_type=MagentaQuantum; break; + case 2: quantum_type=YellowQuantum; break; + case 3: quantum_type=BlackQuantum; break; + case 4: quantum_type=AlphaQuantum; break; + default: quantum_type=UndefinedQuantum; break; + } + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,pixels,exception); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadYCCKMethod: + { + pixels=GetQuantumPixels(quantum_info); + for (y=0; y < (ssize_t) image->rows; y++) + { + int + status; + + register IndexPacket + *indexes; + + register PixelPacket + *magick_restrict q; + + register ssize_t + x; + + unsigned char + *p; + + status=TIFFReadPixels(tiff,bits_per_sample,0,y,(char *) pixels); + if (status == -1) + break; + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + indexes=GetAuthenticIndexQueue(image); + p=pixels; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelCyan(q,ScaleCharToQuantum(ClampYCC((double) *p+ + (1.402*(double) *(p+2))-179.456))); + SetPixelMagenta(q,ScaleCharToQuantum(ClampYCC((double) *p- + (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+ + 135.45984))); + SetPixelYellow(q,ScaleCharToQuantum(ClampYCC((double) *p+ + (1.772*(double) *(p+1))-226.816))); + SetPixelBlack(indexes+x,ScaleCharToQuantum((unsigned char)*(p+3))); + q++; + p+=4; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadStripMethod: + { + register uint32 + *p; + + /* + Convert stripped TIFF image to DirectClass MIFF image. + */ + i=0; + p=(uint32 *) NULL; + for (y=0; y < (ssize_t) image->rows; y++) + { + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + if (i == 0) + { + if (TIFFReadRGBAStrip(tiff,(tstrip_t) y,(uint32 *) pixels) == 0) + break; + i=(ssize_t) MagickMin((ssize_t) rows_per_strip,(ssize_t) + image->rows-y); + } + i--; + p=((uint32 *) pixels)+image->columns*i; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + (TIFFGetR(*p)))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + (TIFFGetG(*p)))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + (TIFFGetB(*p)))); + if (image->matte != MagickFalse) + SetPixelOpacity(q,ScaleCharToQuantum((unsigned char) + (TIFFGetA(*p)))); + p++; + q++; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + break; + } + case ReadTileMethod: + { + register uint32 + *p; + + uint32 + *tile_pixels, + columns, + rows; + + /* + Convert tiled TIFF image to DirectClass MIFF image. + */ + if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) || + (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1)) + { + TIFFClose(tiff); + ThrowReaderException(CoderError,""ImageIsNotTiled""); + } + (void) SetImageStorageClass(image,DirectClass); + number_pixels=(MagickSizeType) columns*rows; + if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + tile_pixels=(uint32 *) AcquireQuantumMemory(columns, + rows*sizeof(*tile_pixels)); + if (tile_pixels == (uint32 *) NULL) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + for (y=0; y < (ssize_t) image->rows; y+=rows) + { + PixelPacket + *tile; + + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + size_t + columns_remaining, + rows_remaining; + + rows_remaining=image->rows-y; + if ((ssize_t) (y+rows) < (ssize_t) image->rows) + rows_remaining=rows; + tile=QueueAuthenticPixels(image,0,y,image->columns,rows_remaining, + exception); + if (tile == (PixelPacket *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x+=columns) + { + size_t + column, + row; + + if (TIFFReadRGBATile(tiff,(uint32) x,(uint32) y,tile_pixels) == 0) + break; + columns_remaining=image->columns-x; + if ((ssize_t) (x+columns) < (ssize_t) image->columns) + columns_remaining=columns; + p=tile_pixels+(rows-rows_remaining)*columns; + q=tile+(image->columns*(rows_remaining-1)+x); + for (row=rows_remaining; row > 0; row--) + { + if (image->matte != MagickFalse) + for (column=columns_remaining; column > 0; column--) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + TIFFGetR(*p))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + TIFFGetG(*p))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + TIFFGetB(*p))); + SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) + TIFFGetA(*p))); + q++; + p++; + } + else + for (column=columns_remaining; column > 0; column--) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) + TIFFGetR(*p))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) + TIFFGetG(*p))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) + TIFFGetB(*p))); + q++; + p++; + } + p+=columns-columns_remaining; + q-=(image->columns+columns_remaining); + } + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + tile_pixels=(uint32 *) RelinquishMagickMemory(tile_pixels); + break; + } + case ReadGenericMethod: + default: + { + MemoryInfo + *pixel_info; + + register uint32 + *p; + + uint32 + *pixels; + + /* + Convert TIFF image to DirectClass MIFF image. + */ + number_pixels=(MagickSizeType) image->columns*image->rows; + if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixel_info=AcquireVirtualMemory(image->columns,image->rows* + sizeof(*pixels)); + if (pixel_info == (MemoryInfo *) NULL) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixels=(uint32 *) GetVirtualMemoryBlob(pixel_info); + (void) TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32) + image->rows,(uint32 *) pixels,0); + /* + Convert image to DirectClass pixel packets. + */ + p=pixels+number_pixels-1; + for (y=0; y < (ssize_t) image->rows; y++) + { + register ssize_t + x; + + register PixelPacket + *magick_restrict q; + + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + break; + q+=image->columns-1; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(q,ScaleCharToQuantum((unsigned char) TIFFGetR(*p))); + SetPixelGreen(q,ScaleCharToQuantum((unsigned char) TIFFGetG(*p))); + SetPixelBlue(q,ScaleCharToQuantum((unsigned char) TIFFGetB(*p))); + if (image->matte != MagickFalse) + SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) TIFFGetA(*p))); + p--; + q--; + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + pixel_info=RelinquishVirtualMemory(pixel_info); + break; + } + } + SetQuantumImageType(image,quantum_type); + next_tiff_frame: + quantum_info=DestroyQuantumInfo(quantum_info); + if (photometric == PHOTOMETRIC_CIELAB) + DecodeLabImage(image,exception); + if ((photometric == PHOTOMETRIC_LOGL) || + (photometric == PHOTOMETRIC_MINISBLACK) || + (photometric == PHOTOMETRIC_MINISWHITE)) + { + image->type=GrayscaleType; + if (bits_per_sample == 1) + image->type=BilevelType; + } + /* + Proceed to next image. + */ + if (image_info->number_scenes != 0) + if (image->scene >= (image_info->scene+image_info->number_scenes-1)) + break; + status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse; + if (status != MagickFalse) + { + /* + Allocate next image structure. + */ + AcquireNextImage(image_info,image); + if (GetNextImageInList(image) == (Image *) NULL) + { + image=DestroyImageList(image); + return((Image *) NULL); + } + image=SyncNextImageInList(image); + status=SetImageProgress(image,LoadImagesTag,image->scene-1, + image->scene); + if (status == MagickFalse) + break; + } + } while (status != MagickFalse); + TIFFClose(tiff); + TIFFReadPhotoshopLayers(image,image_info,exception); + if (image_info->number_scenes != 0) + { + if (image_info->scene >= GetImageListLength(image)) + { + /* Subimage was not found in the Photoshop layer */ + image = DestroyImageList(image); + return((Image *)NULL); + } + } + return(GetFirstImageInList(image)); +} +","@@ -62,6 +62,7 @@ + #include ""magick/log.h"" + #include ""magick/magick.h"" + #include ""magick/memory_.h"" ++#include ""magick/memory-private.h"" + #include ""magick/module.h"" + #include ""magick/monitor.h"" + #include ""magick/monitor-private.h"" +@@ -1903,14 +1904,13 @@ RestoreMSCWarning + } + (void) SetImageStorageClass(image,DirectClass); + number_pixels=(MagickSizeType) columns*rows; +- if ((number_pixels*sizeof(uint32)) != (MagickSizeType) ((size_t) +- (number_pixels*sizeof(uint32)))) ++ if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } +- tile_pixels=(uint32 *) AcquireQuantumMemory(number_pixels, +- sizeof(*tile_pixels)); ++ tile_pixels=(uint32 *) AcquireQuantumMemory(columns, ++ rows*sizeof(*tile_pixels)); + if (tile_pixels == (uint32 *) NULL) + { + TIFFClose(tiff); +@@ -2012,14 +2012,13 @@ RestoreMSCWarning + Convert TIFF image to DirectClass MIFF image. + */ + number_pixels=(MagickSizeType) image->columns*image->rows; +- if ((number_pixels*sizeof(uint32)) != (MagickSizeType) ((size_t) +- (number_pixels*sizeof(uint32)))) ++ if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse) + { + TIFFClose(tiff); + ThrowReaderException(ResourceLimitError,""MemoryAllocationFailed""); + } + pixel_info=AcquireVirtualMemory(image->columns,image->rows* +- sizeof(uint32)); ++ sizeof(*pixels)); + if (pixel_info == (MemoryInfo *) NULL) + { + TIFFClose(tiff);",8575,8811,11000 +18727,"status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { + ALOGV(""entering parseChunk %lld/%d"", *offset, depth); + uint32_t hdr[2]; + if (mDataSource->readAt(*offset, hdr, 8) < 8) { + return ERROR_IO; + } + uint64_t chunk_size = ntohl(hdr[0]); + uint32_t chunk_type = ntohl(hdr[1]); + off64_t data_offset = *offset + 8; + + if (chunk_size == 1) { + if (mDataSource->readAt(*offset + 8, &chunk_size, 8) < 8) { + return ERROR_IO; + } + chunk_size = ntoh64(chunk_size); + data_offset += 8; + + if (chunk_size < 16) { + return ERROR_MALFORMED; + } + } else if (chunk_size == 0) { + if (depth == 0) { + off64_t sourceSize; + if (mDataSource->getSize(&sourceSize) == OK) { + chunk_size = (sourceSize - *offset); + } else { + ALOGE(""atom size is 0, and data source has no size""); + return ERROR_MALFORMED; + } + } else { + *offset += 4; + return OK; + } + } else if (chunk_size < 8) { + ALOGE(""invalid chunk size: %"" PRIu64, chunk_size); + return ERROR_MALFORMED; + } + + char chunk[5]; + MakeFourCCString(chunk_type, chunk); + ALOGV(""chunk: %s @ %lld, %d"", chunk, *offset, depth); + +#if 0 + static const char kWhitespace[] = "" ""; + const char *indent = &kWhitespace[sizeof(kWhitespace) - 1 - 2 * depth]; + printf(""%sfound chunk '%s' of size %"" PRIu64 ""\n"", indent, chunk, chunk_size); + + char buffer[256]; + size_t n = chunk_size; + if (n > sizeof(buffer)) { + n = sizeof(buffer); + } + if (mDataSource->readAt(*offset, buffer, n) + < (ssize_t)n) { + return ERROR_IO; + } + + hexdump(buffer, n); +#endif + + PathAdder autoAdder(&mPath, chunk_type); + + off64_t chunk_data_size = *offset + chunk_size - data_offset; + + if (chunk_type != FOURCC('c', 'p', 'r', 't') + && chunk_type != FOURCC('c', 'o', 'v', 'r') + && mPath.size() == 5 && underMetaDataPath(mPath)) { + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset; + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + + return OK; + } + + switch(chunk_type) { + case FOURCC('m', 'o', 'o', 'v'): + case FOURCC('t', 'r', 'a', 'k'): + case FOURCC('m', 'd', 'i', 'a'): + case FOURCC('m', 'i', 'n', 'f'): + case FOURCC('d', 'i', 'n', 'f'): + case FOURCC('s', 't', 'b', 'l'): + case FOURCC('m', 'v', 'e', 'x'): + case FOURCC('m', 'o', 'o', 'f'): + case FOURCC('t', 'r', 'a', 'f'): + case FOURCC('m', 'f', 'r', 'a'): + case FOURCC('u', 'd', 't', 'a'): + case FOURCC('i', 'l', 's', 't'): + case FOURCC('s', 'i', 'n', 'f'): + case FOURCC('s', 'c', 'h', 'i'): + case FOURCC('e', 'd', 't', 's'): + { + if (chunk_type == FOURCC('s', 't', 'b', 'l')) { + ALOGV(""sampleTable chunk is %"" PRIu64 "" bytes long."", chunk_size); + + if (mDataSource->flags() + & (DataSource::kWantsPrefetching + | DataSource::kIsCachingDataSource)) { + sp cachedSource = + new MPEG4DataSource(mDataSource); + + if (cachedSource->setCachedRange(*offset, chunk_size) == OK) { + mDataSource = cachedSource; + } + } + + mLastTrack->sampleTable = new SampleTable(mDataSource); + } + + bool isTrack = false; + if (chunk_type == FOURCC('t', 'r', 'a', 'k')) { + isTrack = true; + + Track *track = new Track; + track->next = NULL; + if (mLastTrack) { + mLastTrack->next = track; + } else { + mFirstTrack = track; + } + mLastTrack = track; + + track->meta = new MetaData; + track->includes_expensive_metadata = false; + track->skipTrack = false; + track->timescale = 0; + track->meta->setCString(kKeyMIMEType, ""application/octet-stream""); + } + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset; + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + + if (isTrack) { + if (mLastTrack->skipTrack) { + Track *cur = mFirstTrack; + + if (cur == mLastTrack) { + delete cur; + mFirstTrack = mLastTrack = NULL; + } else { + while (cur && cur->next != mLastTrack) { + cur = cur->next; + } + cur->next = NULL; + delete mLastTrack; + mLastTrack = cur; + } + + return OK; + } + + status_t err = verifyTrack(mLastTrack); + + if (err != OK) { + return err; + } + } else if (chunk_type == FOURCC('m', 'o', 'o', 'v')) { + mInitCheck = OK; + + if (!mIsDrm) { + return UNKNOWN_ERROR; // Return a dummy error. + } else { + return OK; + } + } + break; + } + + case FOURCC('e', 'l', 's', 't'): + { + *offset += chunk_size; + + uint8_t version; + if (mDataSource->readAt(data_offset, &version, 1) < 1) { + return ERROR_IO; + } + + uint32_t entry_count; + if (!mDataSource->getUInt32(data_offset + 4, &entry_count)) { + return ERROR_IO; + } + + if (entry_count != 1) { + ALOGW(""ignoring edit list with %d entries"", entry_count); + } else if (mHeaderTimescale == 0) { + ALOGW(""ignoring edit list because timescale is 0""); + } else { + off64_t entriesoffset = data_offset + 8; + uint64_t segment_duration; + int64_t media_time; + + if (version == 1) { + if (!mDataSource->getUInt64(entriesoffset, &segment_duration) || + !mDataSource->getUInt64(entriesoffset + 8, (uint64_t*)&media_time)) { + return ERROR_IO; + } + } else if (version == 0) { + uint32_t sd; + int32_t mt; + if (!mDataSource->getUInt32(entriesoffset, &sd) || + !mDataSource->getUInt32(entriesoffset + 4, (uint32_t*)&mt)) { + return ERROR_IO; + } + segment_duration = sd; + media_time = mt; + } else { + return ERROR_IO; + } + + uint64_t halfscale = mHeaderTimescale / 2; + segment_duration = (segment_duration * 1000000 + halfscale)/ mHeaderTimescale; + media_time = (media_time * 1000000 + halfscale) / mHeaderTimescale; + + int64_t duration; + int32_t samplerate; + if (!mLastTrack) { + return ERROR_MALFORMED; + } + if (mLastTrack->meta->findInt64(kKeyDuration, &duration) && + mLastTrack->meta->findInt32(kKeySampleRate, &samplerate)) { + + int64_t delay = (media_time * samplerate + 500000) / 1000000; + mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); + + int64_t paddingus = duration - (segment_duration + media_time); + if (paddingus < 0) { + paddingus = 0; + } + int64_t paddingsamples = (paddingus * samplerate + 500000) / 1000000; + mLastTrack->meta->setInt32(kKeyEncoderPadding, paddingsamples); + } + } + break; + } + + case FOURCC('f', 'r', 'm', 'a'): + { + *offset += chunk_size; + + uint32_t original_fourcc; + if (mDataSource->readAt(data_offset, &original_fourcc, 4) < 4) { + return ERROR_IO; + } + original_fourcc = ntohl(original_fourcc); + ALOGV(""read original format: %d"", original_fourcc); + mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); + uint32_t num_channels = 0; + uint32_t sample_rate = 0; + if (AdjustChannelsAndRate(original_fourcc, &num_channels, &sample_rate)) { + mLastTrack->meta->setInt32(kKeyChannelCount, num_channels); + mLastTrack->meta->setInt32(kKeySampleRate, sample_rate); + } + break; + } + + case FOURCC('t', 'e', 'n', 'c'): + { + *offset += chunk_size; + + if (chunk_size < 32) { + return ERROR_MALFORMED; + } + + char buf[4]; + memset(buf, 0, 4); + if (mDataSource->readAt(data_offset + 4, buf + 1, 3) < 3) { + return ERROR_IO; + } + uint32_t defaultAlgorithmId = ntohl(*((int32_t*)buf)); + if (defaultAlgorithmId > 1) { + return ERROR_MALFORMED; + } + + memset(buf, 0, 4); + if (mDataSource->readAt(data_offset + 7, buf + 3, 1) < 1) { + return ERROR_IO; + } + uint32_t defaultIVSize = ntohl(*((int32_t*)buf)); + + if ((defaultAlgorithmId == 0 && defaultIVSize != 0) || + (defaultAlgorithmId != 0 && defaultIVSize == 0)) { + return ERROR_MALFORMED; + } else if (defaultIVSize != 0 && + defaultIVSize != 8 && + defaultIVSize != 16) { + return ERROR_MALFORMED; + } + + uint8_t defaultKeyId[16]; + + if (mDataSource->readAt(data_offset + 8, &defaultKeyId, 16) < 16) { + return ERROR_IO; + } + + mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); + mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); + mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); + break; + } + + case FOURCC('t', 'k', 'h', 'd'): + { + *offset += chunk_size; + + status_t err; + if ((err = parseTrackHeader(data_offset, chunk_data_size)) != OK) { + return err; + } + + break; + } + + case FOURCC('p', 's', 's', 'h'): + { + *offset += chunk_size; + + PsshInfo pssh; + + if (mDataSource->readAt(data_offset + 4, &pssh.uuid, 16) < 16) { + return ERROR_IO; + } + + uint32_t psshdatalen = 0; + if (mDataSource->readAt(data_offset + 20, &psshdatalen, 4) < 4) { + return ERROR_IO; + } + pssh.datalen = ntohl(psshdatalen); + ALOGV(""pssh data size: %d"", pssh.datalen); + if (pssh.datalen + 20 > chunk_size) { + return ERROR_MALFORMED; + } + + pssh.data = new (std::nothrow) uint8_t[pssh.datalen]; + if (pssh.data == NULL) { + return ERROR_MALFORMED; + } + ALOGV(""allocated pssh @ %p"", pssh.data); + ssize_t requested = (ssize_t) pssh.datalen; + if (mDataSource->readAt(data_offset + 24, pssh.data, requested) < requested) { + return ERROR_IO; + } + mPssh.push_back(pssh); + + break; + } + + case FOURCC('m', 'd', 'h', 'd'): + { + *offset += chunk_size; + + if (chunk_data_size < 4 || mLastTrack == NULL) { + return ERROR_MALFORMED; + } + + uint8_t version; + if (mDataSource->readAt( + data_offset, &version, sizeof(version)) + < (ssize_t)sizeof(version)) { + return ERROR_IO; + } + + off64_t timescale_offset; + + if (version == 1) { + timescale_offset = data_offset + 4 + 16; + } else if (version == 0) { + timescale_offset = data_offset + 4 + 8; + } else { + return ERROR_IO; + } + + uint32_t timescale; + if (mDataSource->readAt( + timescale_offset, ×cale, sizeof(timescale)) + < (ssize_t)sizeof(timescale)) { + return ERROR_IO; + } + + mLastTrack->timescale = ntohl(timescale); + + int64_t duration = 0; + if (version == 1) { + if (mDataSource->readAt( + timescale_offset + 4, &duration, sizeof(duration)) + < (ssize_t)sizeof(duration)) { + return ERROR_IO; + } + if (duration != -1) { + duration = ntoh64(duration); + } + } else { + uint32_t duration32; + if (mDataSource->readAt( + timescale_offset + 4, &duration32, sizeof(duration32)) + < (ssize_t)sizeof(duration32)) { + return ERROR_IO; + } + if (duration32 != 0xffffffff) { + duration = ntohl(duration32); + } + } + if (duration != 0) { + mLastTrack->meta->setInt64( + kKeyDuration, (duration * 1000000) / mLastTrack->timescale); + } + + uint8_t lang[2]; + off64_t lang_offset; + if (version == 1) { + lang_offset = timescale_offset + 4 + 8; + } else if (version == 0) { + lang_offset = timescale_offset + 4 + 4; + } else { + return ERROR_IO; + } + + if (mDataSource->readAt(lang_offset, &lang, sizeof(lang)) + < (ssize_t)sizeof(lang)) { + return ERROR_IO; + } + + char lang_code[4]; + lang_code[0] = ((lang[0] >> 2) & 0x1f) + 0x60; + lang_code[1] = ((lang[0] & 0x3) << 3 | (lang[1] >> 5)) + 0x60; + lang_code[2] = (lang[1] & 0x1f) + 0x60; + lang_code[3] = '\0'; + + mLastTrack->meta->setCString( + kKeyMediaLanguage, lang_code); + + break; + } + + case FOURCC('s', 't', 's', 'd'): + { + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + uint8_t buffer[8]; + if (chunk_data_size < (off64_t)sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, 8) < 8) { + return ERROR_IO; + } + + if (U32_AT(buffer) != 0) { + return ERROR_MALFORMED; + } + + uint32_t entry_count = U32_AT(&buffer[4]); + + if (entry_count > 1) { + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && + strcasecmp(mime, ""application/octet-stream"")) { + mLastTrack->skipTrack = true; + *offset += chunk_size; + break; + } + } + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + 8; + for (uint32_t i = 0; i < entry_count; ++i) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('m', 'p', '4', 'a'): + case FOURCC('e', 'n', 'c', 'a'): + case FOURCC('s', 'a', 'm', 'r'): + case FOURCC('s', 'a', 'w', 'b'): + { + uint8_t buffer[8 + 20]; + if (chunk_data_size < (ssize_t)sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) { + return ERROR_IO; + } + + uint16_t data_ref_index = U16_AT(&buffer[6]); + uint32_t num_channels = U16_AT(&buffer[16]); + + uint16_t sample_size = U16_AT(&buffer[18]); + uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; + + if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { + mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); + AdjustChannelsAndRate(chunk_type, &num_channels, &sample_rate); + } + ALOGV(""*** coding='%s' %d channels, size %d, rate %d\n"", + chunk, num_channels, sample_size, sample_rate); + mLastTrack->meta->setInt32(kKeyChannelCount, num_channels); + mLastTrack->meta->setInt32(kKeySampleRate, sample_rate); + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + sizeof(buffer); + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('m', 'p', '4', 'v'): + case FOURCC('e', 'n', 'c', 'v'): + case FOURCC('s', '2', '6', '3'): + case FOURCC('H', '2', '6', '3'): + case FOURCC('h', '2', '6', '3'): + case FOURCC('a', 'v', 'c', '1'): + case FOURCC('h', 'v', 'c', '1'): + case FOURCC('h', 'e', 'v', '1'): + { + mHasVideo = true; + + uint8_t buffer[78]; + if (chunk_data_size < (ssize_t)sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) { + return ERROR_IO; + } + + uint16_t data_ref_index = U16_AT(&buffer[6]); + uint16_t width = U16_AT(&buffer[6 + 18]); + uint16_t height = U16_AT(&buffer[6 + 20]); + + if (width == 0) width = 352; + if (height == 0) height = 288; + + + if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { + mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); + } + mLastTrack->meta->setInt32(kKeyWidth, width); + mLastTrack->meta->setInt32(kKeyHeight, height); + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + sizeof(buffer); + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('s', 't', 'c', 'o'): + case FOURCC('c', 'o', '6', '4'): + { + status_t err = + mLastTrack->sampleTable->setChunkOffsetParams( + chunk_type, data_offset, chunk_data_size); + + *offset += chunk_size; + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('s', 't', 's', 'c'): + { + status_t err = + mLastTrack->sampleTable->setSampleToChunkParams( + data_offset, chunk_data_size); + + *offset += chunk_size; + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('s', 't', 's', 'z'): + case FOURCC('s', 't', 'z', '2'): + { + status_t err = + mLastTrack->sampleTable->setSampleSizeParams( + chunk_type, data_offset, chunk_data_size); + + *offset += chunk_size; + + if (err != OK) { + return err; + } + + size_t max_size; + err = mLastTrack->sampleTable->getMaxSampleSize(&max_size); + + if (err != OK) { + return err; + } + + if (max_size != 0) { + mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size + 10 * 2); + } else { + int32_t width, height; + if (!mLastTrack->meta->findInt32(kKeyWidth, &width) || + !mLastTrack->meta->findInt32(kKeyHeight, &height)) { + ALOGE(""No width or height, assuming worst case 1080p""); + width = 1920; + height = 1080; + } + + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) { + max_size = ((width + 15) / 16) * ((height + 15) / 16) * 192; + } else { + max_size = width * height * 3 / 2; + } + mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size); + } + + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (!strncasecmp(""video/"", mime, 6)) { + size_t nSamples = mLastTrack->sampleTable->countSamples(); + int64_t durationUs; + if (mLastTrack->meta->findInt64(kKeyDuration, &durationUs)) { + if (durationUs > 0) { + int32_t frameRate = (nSamples * 1000000LL + + (durationUs >> 1)) / durationUs; + mLastTrack->meta->setInt32(kKeyFrameRate, frameRate); + } + } + } + + break; + } + + case FOURCC('s', 't', 't', 's'): + { + *offset += chunk_size; + + status_t err = + mLastTrack->sampleTable->setTimeToSampleParams( + data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('c', 't', 't', 's'): + { + *offset += chunk_size; + + status_t err = + mLastTrack->sampleTable->setCompositionTimeToSampleParams( + data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('s', 't', 's', 's'): + { + *offset += chunk_size; + + status_t err = + mLastTrack->sampleTable->setSyncSampleParams( + data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('\xA9', 'x', 'y', 'z'): + { + *offset += chunk_size; + + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + char buffer[18]; + + off64_t location_length = chunk_data_size - 5; + if (location_length >= (off64_t) sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset + 4, buffer, location_length) < location_length) { + return ERROR_IO; + } + + buffer[location_length] = '\0'; + mFileMetaData->setCString(kKeyLocation, buffer); + break; + } + + case FOURCC('e', 's', 'd', 's'): + { + *offset += chunk_size; + + if (chunk_data_size < 4) { + return ERROR_MALFORMED; + } + + uint8_t buffer[256]; + if (chunk_data_size > (off64_t)sizeof(buffer)) { + return ERROR_BUFFER_TOO_SMALL; + } + + if (mDataSource->readAt( + data_offset, buffer, chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + if (U32_AT(buffer) != 0) { + return ERROR_MALFORMED; + } + + mLastTrack->meta->setData( + kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); + + if (mPath.size() >= 2 + && mPath[mPath.size() - 2] == FOURCC('m', 'p', '4', 'a')) { + + status_t err = updateAudioTrackInfoFromESDS_MPEG4Audio( + &buffer[4], chunk_data_size - 4); + + if (err != OK) { + return err; + } + } + + break; + } + + case FOURCC('a', 'v', 'c', 'C'): + { + *offset += chunk_size; + + sp buffer = new ABuffer(chunk_data_size); + + if (mDataSource->readAt( + data_offset, buffer->data(), chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + mLastTrack->meta->setData( + kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); + + break; + } + case FOURCC('h', 'v', 'c', 'C'): + { + sp buffer = new ABuffer(chunk_data_size); + + if (mDataSource->readAt( + data_offset, buffer->data(), chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + mLastTrack->meta->setData( + kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); + + *offset += chunk_size; + break; + } + + case FOURCC('d', '2', '6', '3'): + { + *offset += chunk_size; + /* + * d263 contains a fixed 7 bytes part: + * vendor - 4 bytes + * version - 1 byte + * level - 1 byte + * profile - 1 byte + * optionally, ""d263"" box itself may contain a 16-byte + * bit rate box (bitr) + * average bit rate - 4 bytes + * max bit rate - 4 bytes + */ + char buffer[23]; + if (chunk_data_size != 7 && + chunk_data_size != 23) { + ALOGE(""Incorrect D263 box size %lld"", chunk_data_size); + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); + + break; + } + + case FOURCC('m', 'e', 't', 'a'): + { + uint8_t buffer[4]; + if (chunk_data_size < (off64_t)sizeof(buffer)) { + *offset += chunk_size; + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, 4) < 4) { + *offset += chunk_size; + return ERROR_IO; + } + + if (U32_AT(buffer) != 0) { + + *offset += chunk_size; + return OK; + } + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + sizeof(buffer); + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('m', 'e', 'a', 'n'): + case FOURCC('n', 'a', 'm', 'e'): + case FOURCC('d', 'a', 't', 'a'): + { + *offset += chunk_size; + + if (mPath.size() == 6 && underMetaDataPath(mPath)) { + status_t err = parseITunesMetaData(data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + } + + break; + } + + case FOURCC('m', 'v', 'h', 'd'): + { + *offset += chunk_size; + + if (chunk_data_size < 32) { + return ERROR_MALFORMED; + } + + uint8_t header[32]; + if (mDataSource->readAt( + data_offset, header, sizeof(header)) + < (ssize_t)sizeof(header)) { + return ERROR_IO; + } + + uint64_t creationTime; + uint64_t duration = 0; + if (header[0] == 1) { + creationTime = U64_AT(&header[4]); + mHeaderTimescale = U32_AT(&header[20]); + duration = U64_AT(&header[24]); + if (duration == 0xffffffffffffffff) { + duration = 0; + } + } else if (header[0] != 0) { + return ERROR_MALFORMED; + } else { + creationTime = U32_AT(&header[4]); + mHeaderTimescale = U32_AT(&header[12]); + uint32_t d32 = U32_AT(&header[16]); + if (d32 == 0xffffffff) { + d32 = 0; + } + duration = d32; + } + if (duration != 0) { + mFileMetaData->setInt64(kKeyDuration, duration * 1000000 / mHeaderTimescale); + } + + String8 s; + convertTimeToDate(creationTime, &s); + + mFileMetaData->setCString(kKeyDate, s.string()); + + break; + } + + case FOURCC('m', 'e', 'h', 'd'): + { + *offset += chunk_size; + + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + uint8_t flags[4]; + if (mDataSource->readAt( + data_offset, flags, sizeof(flags)) + < (ssize_t)sizeof(flags)) { + return ERROR_IO; + } + + uint64_t duration = 0; + if (flags[0] == 1) { + if (chunk_data_size < 12) { + return ERROR_MALFORMED; + } + mDataSource->getUInt64(data_offset + 4, &duration); + if (duration == 0xffffffffffffffff) { + duration = 0; + } + } else if (flags[0] == 0) { + uint32_t d32; + mDataSource->getUInt32(data_offset + 4, &d32); + if (d32 == 0xffffffff) { + d32 = 0; + } + duration = d32; + } else { + return ERROR_MALFORMED; + } + + if (duration != 0) { + mFileMetaData->setInt64(kKeyDuration, duration * 1000000 / mHeaderTimescale); + } + + break; + } + + case FOURCC('m', 'd', 'a', 't'): + { + ALOGV(""mdat chunk, drm: %d"", mIsDrm); + if (!mIsDrm) { + *offset += chunk_size; + break; + } + + if (chunk_size < 8) { + return ERROR_MALFORMED; + } + + return parseDrmSINF(offset, data_offset); + } + + case FOURCC('h', 'd', 'l', 'r'): + { + *offset += chunk_size; + + uint32_t buffer; + if (mDataSource->readAt( + data_offset + 8, &buffer, 4) < 4) { + return ERROR_IO; + } + + uint32_t type = ntohl(buffer); + if (type == FOURCC('t', 'e', 'x', 't') || type == FOURCC('s', 'b', 't', 'l')) { + mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_TEXT_3GPP); + } + + break; + } + + case FOURCC('t', 'r', 'e', 'x'): + { + *offset += chunk_size; + + if (chunk_data_size < 24) { + return ERROR_IO; + } + uint32_t duration; + Trex trex; + if (!mDataSource->getUInt32(data_offset + 4, &trex.track_ID) || + !mDataSource->getUInt32(data_offset + 8, &trex.default_sample_description_index) || + !mDataSource->getUInt32(data_offset + 12, &trex.default_sample_duration) || + !mDataSource->getUInt32(data_offset + 16, &trex.default_sample_size) || + !mDataSource->getUInt32(data_offset + 20, &trex.default_sample_flags)) { + return ERROR_IO; + } + mTrex.add(trex); + break; + } + + case FOURCC('t', 'x', '3', 'g'): + { + uint32_t type; + const void *data; + size_t size = 0; + if (!mLastTrack->meta->findData( + kKeyTextFormatData, &type, &data, &size)) { + size = 0; + } + + uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size]; + if (buffer == NULL) { + return ERROR_MALFORMED; + } + + if (size > 0) { + memcpy(buffer, data, size); + } + + if ((size_t)(mDataSource->readAt(*offset, buffer + size, chunk_size)) + < chunk_size) { + delete[] buffer; + buffer = NULL; + + *offset += chunk_size; + return ERROR_IO; + } + + mLastTrack->meta->setData( + kKeyTextFormatData, 0, buffer, size + chunk_size); + + delete[] buffer; + + *offset += chunk_size; + break; + } + + case FOURCC('c', 'o', 'v', 'r'): + { + *offset += chunk_size; + + if (mFileMetaData != NULL) { + ALOGV(""chunk_data_size = %lld and data_offset = %lld"", + chunk_data_size, data_offset); + sp buffer = new ABuffer(chunk_data_size + 1); + if (mDataSource->readAt( + data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) { + + return ERROR_IO; + } + const int kSkipBytesOfDataBox = 16; + mFileMetaData->setData( + kKeyAlbumArt, MetaData::TYPE_NONE, + buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox); + } + + break; + } + + case FOURCC('t', 'i', 't', 'l'): + case FOURCC('p', 'e', 'r', 'f'): + case FOURCC('a', 'u', 't', 'h'): + case FOURCC('g', 'n', 'r', 'e'): + case FOURCC('a', 'l', 'b', 'm'): + case FOURCC('y', 'r', 'r', 'c'): + { + *offset += chunk_size; + + status_t err = parse3GPPMetaData(data_offset, chunk_data_size, depth); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('I', 'D', '3', '2'): + { + *offset += chunk_size; + + if (chunk_data_size < 6) { + return ERROR_MALFORMED; + } + + parseID3v2MetaData(data_offset + 6); + + break; + } + + case FOURCC('-', '-', '-', '-'): + { + mLastCommentMean.clear(); + mLastCommentName.clear(); + mLastCommentData.clear(); + *offset += chunk_size; + break; + } + + case FOURCC('s', 'i', 'd', 'x'): + { + parseSegmentIndex(data_offset, chunk_data_size); + *offset += chunk_size; + return UNKNOWN_ERROR; // stop parsing after sidx + } + + default: + { + *offset += chunk_size; + break; + } + } + + return OK; +} +",1,"status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { + ALOGV(""entering parseChunk %lld/%d"", *offset, depth); + uint32_t hdr[2]; + if (mDataSource->readAt(*offset, hdr, 8) < 8) { + return ERROR_IO; + } + uint64_t chunk_size = ntohl(hdr[0]); + uint32_t chunk_type = ntohl(hdr[1]); + off64_t data_offset = *offset + 8; + + if (chunk_size == 1) { + if (mDataSource->readAt(*offset + 8, &chunk_size, 8) < 8) { + return ERROR_IO; + } + chunk_size = ntoh64(chunk_size); + data_offset += 8; + + if (chunk_size < 16) { + return ERROR_MALFORMED; + } + } else if (chunk_size == 0) { + if (depth == 0) { + off64_t sourceSize; + if (mDataSource->getSize(&sourceSize) == OK) { + chunk_size = (sourceSize - *offset); + } else { + ALOGE(""atom size is 0, and data source has no size""); + return ERROR_MALFORMED; + } + } else { + *offset += 4; + return OK; + } + } else if (chunk_size < 8) { + ALOGE(""invalid chunk size: %"" PRIu64, chunk_size); + return ERROR_MALFORMED; + } + + char chunk[5]; + MakeFourCCString(chunk_type, chunk); + ALOGV(""chunk: %s @ %lld, %d"", chunk, *offset, depth); + +#if 0 + static const char kWhitespace[] = "" ""; + const char *indent = &kWhitespace[sizeof(kWhitespace) - 1 - 2 * depth]; + printf(""%sfound chunk '%s' of size %"" PRIu64 ""\n"", indent, chunk, chunk_size); + + char buffer[256]; + size_t n = chunk_size; + if (n > sizeof(buffer)) { + n = sizeof(buffer); + } + if (mDataSource->readAt(*offset, buffer, n) + < (ssize_t)n) { + return ERROR_IO; + } + + hexdump(buffer, n); +#endif + + PathAdder autoAdder(&mPath, chunk_type); + + off64_t chunk_data_size = *offset + chunk_size - data_offset; + + if (chunk_type != FOURCC('c', 'p', 'r', 't') + && chunk_type != FOURCC('c', 'o', 'v', 'r') + && mPath.size() == 5 && underMetaDataPath(mPath)) { + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset; + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + + return OK; + } + + switch(chunk_type) { + case FOURCC('m', 'o', 'o', 'v'): + case FOURCC('t', 'r', 'a', 'k'): + case FOURCC('m', 'd', 'i', 'a'): + case FOURCC('m', 'i', 'n', 'f'): + case FOURCC('d', 'i', 'n', 'f'): + case FOURCC('s', 't', 'b', 'l'): + case FOURCC('m', 'v', 'e', 'x'): + case FOURCC('m', 'o', 'o', 'f'): + case FOURCC('t', 'r', 'a', 'f'): + case FOURCC('m', 'f', 'r', 'a'): + case FOURCC('u', 'd', 't', 'a'): + case FOURCC('i', 'l', 's', 't'): + case FOURCC('s', 'i', 'n', 'f'): + case FOURCC('s', 'c', 'h', 'i'): + case FOURCC('e', 'd', 't', 's'): + { + if (chunk_type == FOURCC('s', 't', 'b', 'l')) { + ALOGV(""sampleTable chunk is %"" PRIu64 "" bytes long."", chunk_size); + + if (mDataSource->flags() + & (DataSource::kWantsPrefetching + | DataSource::kIsCachingDataSource)) { + sp cachedSource = + new MPEG4DataSource(mDataSource); + + if (cachedSource->setCachedRange(*offset, chunk_size) == OK) { + mDataSource = cachedSource; + } + } + + mLastTrack->sampleTable = new SampleTable(mDataSource); + } + + bool isTrack = false; + if (chunk_type == FOURCC('t', 'r', 'a', 'k')) { + isTrack = true; + + Track *track = new Track; + track->next = NULL; + if (mLastTrack) { + mLastTrack->next = track; + } else { + mFirstTrack = track; + } + mLastTrack = track; + + track->meta = new MetaData; + track->includes_expensive_metadata = false; + track->skipTrack = false; + track->timescale = 0; + track->meta->setCString(kKeyMIMEType, ""application/octet-stream""); + } + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset; + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + + if (isTrack) { + if (mLastTrack->skipTrack) { + Track *cur = mFirstTrack; + + if (cur == mLastTrack) { + delete cur; + mFirstTrack = mLastTrack = NULL; + } else { + while (cur && cur->next != mLastTrack) { + cur = cur->next; + } + cur->next = NULL; + delete mLastTrack; + mLastTrack = cur; + } + + return OK; + } + + status_t err = verifyTrack(mLastTrack); + + if (err != OK) { + return err; + } + } else if (chunk_type == FOURCC('m', 'o', 'o', 'v')) { + mInitCheck = OK; + + if (!mIsDrm) { + return UNKNOWN_ERROR; // Return a dummy error. + } else { + return OK; + } + } + break; + } + + case FOURCC('e', 'l', 's', 't'): + { + *offset += chunk_size; + + uint8_t version; + if (mDataSource->readAt(data_offset, &version, 1) < 1) { + return ERROR_IO; + } + + uint32_t entry_count; + if (!mDataSource->getUInt32(data_offset + 4, &entry_count)) { + return ERROR_IO; + } + + if (entry_count != 1) { + ALOGW(""ignoring edit list with %d entries"", entry_count); + } else if (mHeaderTimescale == 0) { + ALOGW(""ignoring edit list because timescale is 0""); + } else { + off64_t entriesoffset = data_offset + 8; + uint64_t segment_duration; + int64_t media_time; + + if (version == 1) { + if (!mDataSource->getUInt64(entriesoffset, &segment_duration) || + !mDataSource->getUInt64(entriesoffset + 8, (uint64_t*)&media_time)) { + return ERROR_IO; + } + } else if (version == 0) { + uint32_t sd; + int32_t mt; + if (!mDataSource->getUInt32(entriesoffset, &sd) || + !mDataSource->getUInt32(entriesoffset + 4, (uint32_t*)&mt)) { + return ERROR_IO; + } + segment_duration = sd; + media_time = mt; + } else { + return ERROR_IO; + } + + uint64_t halfscale = mHeaderTimescale / 2; + segment_duration = (segment_duration * 1000000 + halfscale)/ mHeaderTimescale; + media_time = (media_time * 1000000 + halfscale) / mHeaderTimescale; + + int64_t duration; + int32_t samplerate; + if (!mLastTrack) { + return ERROR_MALFORMED; + } + if (mLastTrack->meta->findInt64(kKeyDuration, &duration) && + mLastTrack->meta->findInt32(kKeySampleRate, &samplerate)) { + + int64_t delay = (media_time * samplerate + 500000) / 1000000; + mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); + + int64_t paddingus = duration - (segment_duration + media_time); + if (paddingus < 0) { + paddingus = 0; + } + int64_t paddingsamples = (paddingus * samplerate + 500000) / 1000000; + mLastTrack->meta->setInt32(kKeyEncoderPadding, paddingsamples); + } + } + break; + } + + case FOURCC('f', 'r', 'm', 'a'): + { + *offset += chunk_size; + + uint32_t original_fourcc; + if (mDataSource->readAt(data_offset, &original_fourcc, 4) < 4) { + return ERROR_IO; + } + original_fourcc = ntohl(original_fourcc); + ALOGV(""read original format: %d"", original_fourcc); + mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); + uint32_t num_channels = 0; + uint32_t sample_rate = 0; + if (AdjustChannelsAndRate(original_fourcc, &num_channels, &sample_rate)) { + mLastTrack->meta->setInt32(kKeyChannelCount, num_channels); + mLastTrack->meta->setInt32(kKeySampleRate, sample_rate); + } + break; + } + + case FOURCC('t', 'e', 'n', 'c'): + { + *offset += chunk_size; + + if (chunk_size < 32) { + return ERROR_MALFORMED; + } + + char buf[4]; + memset(buf, 0, 4); + if (mDataSource->readAt(data_offset + 4, buf + 1, 3) < 3) { + return ERROR_IO; + } + uint32_t defaultAlgorithmId = ntohl(*((int32_t*)buf)); + if (defaultAlgorithmId > 1) { + return ERROR_MALFORMED; + } + + memset(buf, 0, 4); + if (mDataSource->readAt(data_offset + 7, buf + 3, 1) < 1) { + return ERROR_IO; + } + uint32_t defaultIVSize = ntohl(*((int32_t*)buf)); + + if ((defaultAlgorithmId == 0 && defaultIVSize != 0) || + (defaultAlgorithmId != 0 && defaultIVSize == 0)) { + return ERROR_MALFORMED; + } else if (defaultIVSize != 0 && + defaultIVSize != 8 && + defaultIVSize != 16) { + return ERROR_MALFORMED; + } + + uint8_t defaultKeyId[16]; + + if (mDataSource->readAt(data_offset + 8, &defaultKeyId, 16) < 16) { + return ERROR_IO; + } + + mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); + mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); + mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); + break; + } + + case FOURCC('t', 'k', 'h', 'd'): + { + *offset += chunk_size; + + status_t err; + if ((err = parseTrackHeader(data_offset, chunk_data_size)) != OK) { + return err; + } + + break; + } + + case FOURCC('p', 's', 's', 'h'): + { + *offset += chunk_size; + + PsshInfo pssh; + + if (mDataSource->readAt(data_offset + 4, &pssh.uuid, 16) < 16) { + return ERROR_IO; + } + + uint32_t psshdatalen = 0; + if (mDataSource->readAt(data_offset + 20, &psshdatalen, 4) < 4) { + return ERROR_IO; + } + pssh.datalen = ntohl(psshdatalen); + ALOGV(""pssh data size: %d"", pssh.datalen); + if (pssh.datalen + 20 > chunk_size) { + return ERROR_MALFORMED; + } + + pssh.data = new (std::nothrow) uint8_t[pssh.datalen]; + if (pssh.data == NULL) { + return ERROR_MALFORMED; + } + ALOGV(""allocated pssh @ %p"", pssh.data); + ssize_t requested = (ssize_t) pssh.datalen; + if (mDataSource->readAt(data_offset + 24, pssh.data, requested) < requested) { + return ERROR_IO; + } + mPssh.push_back(pssh); + + break; + } + + case FOURCC('m', 'd', 'h', 'd'): + { + *offset += chunk_size; + + if (chunk_data_size < 4 || mLastTrack == NULL) { + return ERROR_MALFORMED; + } + + uint8_t version; + if (mDataSource->readAt( + data_offset, &version, sizeof(version)) + < (ssize_t)sizeof(version)) { + return ERROR_IO; + } + + off64_t timescale_offset; + + if (version == 1) { + timescale_offset = data_offset + 4 + 16; + } else if (version == 0) { + timescale_offset = data_offset + 4 + 8; + } else { + return ERROR_IO; + } + + uint32_t timescale; + if (mDataSource->readAt( + timescale_offset, ×cale, sizeof(timescale)) + < (ssize_t)sizeof(timescale)) { + return ERROR_IO; + } + + mLastTrack->timescale = ntohl(timescale); + + int64_t duration = 0; + if (version == 1) { + if (mDataSource->readAt( + timescale_offset + 4, &duration, sizeof(duration)) + < (ssize_t)sizeof(duration)) { + return ERROR_IO; + } + if (duration != -1) { + duration = ntoh64(duration); + } + } else { + uint32_t duration32; + if (mDataSource->readAt( + timescale_offset + 4, &duration32, sizeof(duration32)) + < (ssize_t)sizeof(duration32)) { + return ERROR_IO; + } + if (duration32 != 0xffffffff) { + duration = ntohl(duration32); + } + } + if (duration != 0) { + mLastTrack->meta->setInt64( + kKeyDuration, (duration * 1000000) / mLastTrack->timescale); + } + + uint8_t lang[2]; + off64_t lang_offset; + if (version == 1) { + lang_offset = timescale_offset + 4 + 8; + } else if (version == 0) { + lang_offset = timescale_offset + 4 + 4; + } else { + return ERROR_IO; + } + + if (mDataSource->readAt(lang_offset, &lang, sizeof(lang)) + < (ssize_t)sizeof(lang)) { + return ERROR_IO; + } + + char lang_code[4]; + lang_code[0] = ((lang[0] >> 2) & 0x1f) + 0x60; + lang_code[1] = ((lang[0] & 0x3) << 3 | (lang[1] >> 5)) + 0x60; + lang_code[2] = (lang[1] & 0x1f) + 0x60; + lang_code[3] = '\0'; + + mLastTrack->meta->setCString( + kKeyMediaLanguage, lang_code); + + break; + } + + case FOURCC('s', 't', 's', 'd'): + { + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + uint8_t buffer[8]; + if (chunk_data_size < (off64_t)sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, 8) < 8) { + return ERROR_IO; + } + + if (U32_AT(buffer) != 0) { + return ERROR_MALFORMED; + } + + uint32_t entry_count = U32_AT(&buffer[4]); + + if (entry_count > 1) { + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && + strcasecmp(mime, ""application/octet-stream"")) { + mLastTrack->skipTrack = true; + *offset += chunk_size; + break; + } + } + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + 8; + for (uint32_t i = 0; i < entry_count; ++i) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('m', 'p', '4', 'a'): + case FOURCC('e', 'n', 'c', 'a'): + case FOURCC('s', 'a', 'm', 'r'): + case FOURCC('s', 'a', 'w', 'b'): + { + uint8_t buffer[8 + 20]; + if (chunk_data_size < (ssize_t)sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) { + return ERROR_IO; + } + + uint16_t data_ref_index = U16_AT(&buffer[6]); + uint32_t num_channels = U16_AT(&buffer[16]); + + uint16_t sample_size = U16_AT(&buffer[18]); + uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; + + if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { + mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); + AdjustChannelsAndRate(chunk_type, &num_channels, &sample_rate); + } + ALOGV(""*** coding='%s' %d channels, size %d, rate %d\n"", + chunk, num_channels, sample_size, sample_rate); + mLastTrack->meta->setInt32(kKeyChannelCount, num_channels); + mLastTrack->meta->setInt32(kKeySampleRate, sample_rate); + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + sizeof(buffer); + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('m', 'p', '4', 'v'): + case FOURCC('e', 'n', 'c', 'v'): + case FOURCC('s', '2', '6', '3'): + case FOURCC('H', '2', '6', '3'): + case FOURCC('h', '2', '6', '3'): + case FOURCC('a', 'v', 'c', '1'): + case FOURCC('h', 'v', 'c', '1'): + case FOURCC('h', 'e', 'v', '1'): + { + mHasVideo = true; + + uint8_t buffer[78]; + if (chunk_data_size < (ssize_t)sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) { + return ERROR_IO; + } + + uint16_t data_ref_index = U16_AT(&buffer[6]); + uint16_t width = U16_AT(&buffer[6 + 18]); + uint16_t height = U16_AT(&buffer[6 + 20]); + + if (width == 0) width = 352; + if (height == 0) height = 288; + + + if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { + mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); + } + mLastTrack->meta->setInt32(kKeyWidth, width); + mLastTrack->meta->setInt32(kKeyHeight, height); + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + sizeof(buffer); + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('s', 't', 'c', 'o'): + case FOURCC('c', 'o', '6', '4'): + { + status_t err = + mLastTrack->sampleTable->setChunkOffsetParams( + chunk_type, data_offset, chunk_data_size); + + *offset += chunk_size; + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('s', 't', 's', 'c'): + { + status_t err = + mLastTrack->sampleTable->setSampleToChunkParams( + data_offset, chunk_data_size); + + *offset += chunk_size; + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('s', 't', 's', 'z'): + case FOURCC('s', 't', 'z', '2'): + { + status_t err = + mLastTrack->sampleTable->setSampleSizeParams( + chunk_type, data_offset, chunk_data_size); + + *offset += chunk_size; + + if (err != OK) { + return err; + } + + size_t max_size; + err = mLastTrack->sampleTable->getMaxSampleSize(&max_size); + + if (err != OK) { + return err; + } + + if (max_size != 0) { + mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size + 10 * 2); + } else { + int32_t width, height; + if (!mLastTrack->meta->findInt32(kKeyWidth, &width) || + !mLastTrack->meta->findInt32(kKeyHeight, &height)) { + ALOGE(""No width or height, assuming worst case 1080p""); + width = 1920; + height = 1080; + } + + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) { + max_size = ((width + 15) / 16) * ((height + 15) / 16) * 192; + } else { + max_size = width * height * 3 / 2; + } + mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size); + } + + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (!strncasecmp(""video/"", mime, 6)) { + size_t nSamples = mLastTrack->sampleTable->countSamples(); + int64_t durationUs; + if (mLastTrack->meta->findInt64(kKeyDuration, &durationUs)) { + if (durationUs > 0) { + int32_t frameRate = (nSamples * 1000000LL + + (durationUs >> 1)) / durationUs; + mLastTrack->meta->setInt32(kKeyFrameRate, frameRate); + } + } + } + + break; + } + + case FOURCC('s', 't', 't', 's'): + { + *offset += chunk_size; + + status_t err = + mLastTrack->sampleTable->setTimeToSampleParams( + data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('c', 't', 't', 's'): + { + *offset += chunk_size; + + status_t err = + mLastTrack->sampleTable->setCompositionTimeToSampleParams( + data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('s', 't', 's', 's'): + { + *offset += chunk_size; + + status_t err = + mLastTrack->sampleTable->setSyncSampleParams( + data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('\xA9', 'x', 'y', 'z'): + { + *offset += chunk_size; + + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + char buffer[18]; + + off64_t location_length = chunk_data_size - 5; + if (location_length >= (off64_t) sizeof(buffer)) { + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset + 4, buffer, location_length) < location_length) { + return ERROR_IO; + } + + buffer[location_length] = '\0'; + mFileMetaData->setCString(kKeyLocation, buffer); + break; + } + + case FOURCC('e', 's', 'd', 's'): + { + *offset += chunk_size; + + if (chunk_data_size < 4) { + return ERROR_MALFORMED; + } + + uint8_t buffer[256]; + if (chunk_data_size > (off64_t)sizeof(buffer)) { + return ERROR_BUFFER_TOO_SMALL; + } + + if (mDataSource->readAt( + data_offset, buffer, chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + if (U32_AT(buffer) != 0) { + return ERROR_MALFORMED; + } + + mLastTrack->meta->setData( + kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); + + if (mPath.size() >= 2 + && mPath[mPath.size() - 2] == FOURCC('m', 'p', '4', 'a')) { + + status_t err = updateAudioTrackInfoFromESDS_MPEG4Audio( + &buffer[4], chunk_data_size - 4); + + if (err != OK) { + return err; + } + } + + break; + } + + case FOURCC('a', 'v', 'c', 'C'): + { + *offset += chunk_size; + + sp buffer = new ABuffer(chunk_data_size); + + if (mDataSource->readAt( + data_offset, buffer->data(), chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + mLastTrack->meta->setData( + kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); + + break; + } + case FOURCC('h', 'v', 'c', 'C'): + { + sp buffer = new ABuffer(chunk_data_size); + + if (mDataSource->readAt( + data_offset, buffer->data(), chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + mLastTrack->meta->setData( + kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); + + *offset += chunk_size; + break; + } + + case FOURCC('d', '2', '6', '3'): + { + *offset += chunk_size; + /* + * d263 contains a fixed 7 bytes part: + * vendor - 4 bytes + * version - 1 byte + * level - 1 byte + * profile - 1 byte + * optionally, ""d263"" box itself may contain a 16-byte + * bit rate box (bitr) + * average bit rate - 4 bytes + * max bit rate - 4 bytes + */ + char buffer[23]; + if (chunk_data_size != 7 && + chunk_data_size != 23) { + ALOGE(""Incorrect D263 box size %lld"", chunk_data_size); + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, chunk_data_size) < chunk_data_size) { + return ERROR_IO; + } + + mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); + + break; + } + + case FOURCC('m', 'e', 't', 'a'): + { + uint8_t buffer[4]; + if (chunk_data_size < (off64_t)sizeof(buffer)) { + *offset += chunk_size; + return ERROR_MALFORMED; + } + + if (mDataSource->readAt( + data_offset, buffer, 4) < 4) { + *offset += chunk_size; + return ERROR_IO; + } + + if (U32_AT(buffer) != 0) { + + *offset += chunk_size; + return OK; + } + + off64_t stop_offset = *offset + chunk_size; + *offset = data_offset + sizeof(buffer); + while (*offset < stop_offset) { + status_t err = parseChunk(offset, depth + 1); + if (err != OK) { + return err; + } + } + + if (*offset != stop_offset) { + return ERROR_MALFORMED; + } + break; + } + + case FOURCC('m', 'e', 'a', 'n'): + case FOURCC('n', 'a', 'm', 'e'): + case FOURCC('d', 'a', 't', 'a'): + { + *offset += chunk_size; + + if (mPath.size() == 6 && underMetaDataPath(mPath)) { + status_t err = parseITunesMetaData(data_offset, chunk_data_size); + + if (err != OK) { + return err; + } + } + + break; + } + + case FOURCC('m', 'v', 'h', 'd'): + { + *offset += chunk_size; + + if (chunk_data_size < 32) { + return ERROR_MALFORMED; + } + + uint8_t header[32]; + if (mDataSource->readAt( + data_offset, header, sizeof(header)) + < (ssize_t)sizeof(header)) { + return ERROR_IO; + } + + uint64_t creationTime; + uint64_t duration = 0; + if (header[0] == 1) { + creationTime = U64_AT(&header[4]); + mHeaderTimescale = U32_AT(&header[20]); + duration = U64_AT(&header[24]); + if (duration == 0xffffffffffffffff) { + duration = 0; + } + } else if (header[0] != 0) { + return ERROR_MALFORMED; + } else { + creationTime = U32_AT(&header[4]); + mHeaderTimescale = U32_AT(&header[12]); + uint32_t d32 = U32_AT(&header[16]); + if (d32 == 0xffffffff) { + d32 = 0; + } + duration = d32; + } + if (duration != 0) { + mFileMetaData->setInt64(kKeyDuration, duration * 1000000 / mHeaderTimescale); + } + + String8 s; + convertTimeToDate(creationTime, &s); + + mFileMetaData->setCString(kKeyDate, s.string()); + + break; + } + + case FOURCC('m', 'e', 'h', 'd'): + { + *offset += chunk_size; + + if (chunk_data_size < 8) { + return ERROR_MALFORMED; + } + + uint8_t flags[4]; + if (mDataSource->readAt( + data_offset, flags, sizeof(flags)) + < (ssize_t)sizeof(flags)) { + return ERROR_IO; + } + + uint64_t duration = 0; + if (flags[0] == 1) { + if (chunk_data_size < 12) { + return ERROR_MALFORMED; + } + mDataSource->getUInt64(data_offset + 4, &duration); + if (duration == 0xffffffffffffffff) { + duration = 0; + } + } else if (flags[0] == 0) { + uint32_t d32; + mDataSource->getUInt32(data_offset + 4, &d32); + if (d32 == 0xffffffff) { + d32 = 0; + } + duration = d32; + } else { + return ERROR_MALFORMED; + } + + if (duration != 0) { + mFileMetaData->setInt64(kKeyDuration, duration * 1000000 / mHeaderTimescale); + } + + break; + } + + case FOURCC('m', 'd', 'a', 't'): + { + ALOGV(""mdat chunk, drm: %d"", mIsDrm); + if (!mIsDrm) { + *offset += chunk_size; + break; + } + + if (chunk_size < 8) { + return ERROR_MALFORMED; + } + + return parseDrmSINF(offset, data_offset); + } + + case FOURCC('h', 'd', 'l', 'r'): + { + *offset += chunk_size; + + uint32_t buffer; + if (mDataSource->readAt( + data_offset + 8, &buffer, 4) < 4) { + return ERROR_IO; + } + + uint32_t type = ntohl(buffer); + if (type == FOURCC('t', 'e', 'x', 't') || type == FOURCC('s', 'b', 't', 'l')) { + mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_TEXT_3GPP); + } + + break; + } + + case FOURCC('t', 'r', 'e', 'x'): + { + *offset += chunk_size; + + if (chunk_data_size < 24) { + return ERROR_IO; + } + uint32_t duration; + Trex trex; + if (!mDataSource->getUInt32(data_offset + 4, &trex.track_ID) || + !mDataSource->getUInt32(data_offset + 8, &trex.default_sample_description_index) || + !mDataSource->getUInt32(data_offset + 12, &trex.default_sample_duration) || + !mDataSource->getUInt32(data_offset + 16, &trex.default_sample_size) || + !mDataSource->getUInt32(data_offset + 20, &trex.default_sample_flags)) { + return ERROR_IO; + } + mTrex.add(trex); + break; + } + + case FOURCC('t', 'x', '3', 'g'): + { + uint32_t type; + const void *data; + size_t size = 0; + if (!mLastTrack->meta->findData( + kKeyTextFormatData, &type, &data, &size)) { + size = 0; + } + + uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size]; + if (buffer == NULL) { + return ERROR_MALFORMED; + } + + if (size > 0) { + memcpy(buffer, data, size); + } + + if ((size_t)(mDataSource->readAt(*offset, buffer + size, chunk_size)) + < chunk_size) { + delete[] buffer; + buffer = NULL; + + *offset += chunk_size; + return ERROR_IO; + } + + mLastTrack->meta->setData( + kKeyTextFormatData, 0, buffer, size + chunk_size); + + delete[] buffer; + + *offset += chunk_size; + break; + } + + case FOURCC('c', 'o', 'v', 'r'): + { + *offset += chunk_size; + + if (mFileMetaData != NULL) { + ALOGV(""chunk_data_size = %lld and data_offset = %lld"", + chunk_data_size, data_offset); + sp buffer = new ABuffer(chunk_data_size + 1); + if (mDataSource->readAt( + data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) { + + return ERROR_IO; + } + const int kSkipBytesOfDataBox = 16; + if (chunk_data_size <= kSkipBytesOfDataBox) { + return ERROR_MALFORMED; + } + + mFileMetaData->setData( + kKeyAlbumArt, MetaData::TYPE_NONE, + buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox); + } + + break; + } + + case FOURCC('t', 'i', 't', 'l'): + case FOURCC('p', 'e', 'r', 'f'): + case FOURCC('a', 'u', 't', 'h'): + case FOURCC('g', 'n', 'r', 'e'): + case FOURCC('a', 'l', 'b', 'm'): + case FOURCC('y', 'r', 'r', 'c'): + { + *offset += chunk_size; + + status_t err = parse3GPPMetaData(data_offset, chunk_data_size, depth); + + if (err != OK) { + return err; + } + + break; + } + + case FOURCC('I', 'D', '3', '2'): + { + *offset += chunk_size; + + if (chunk_data_size < 6) { + return ERROR_MALFORMED; + } + + parseID3v2MetaData(data_offset + 6); + + break; + } + + case FOURCC('-', '-', '-', '-'): + { + mLastCommentMean.clear(); + mLastCommentName.clear(); + mLastCommentData.clear(); + *offset += chunk_size; + break; + } + + case FOURCC('s', 'i', 'd', 'x'): + { + parseSegmentIndex(data_offset, chunk_data_size); + *offset += chunk_size; + return UNKNOWN_ERROR; // stop parsing after sidx + } + + default: + { + *offset += chunk_size; + break; + } + } + + return OK; +} +","@@ -1934,6 +1934,10 @@ + + return ERROR_IO; + } + const int kSkipBytesOfDataBox = 16; ++ if (chunk_data_size <= kSkipBytesOfDataBox) { ++ return ERROR_MALFORMED; ++ } ++ + mFileMetaData->setData( + kKeyAlbumArt, MetaData::TYPE_NONE, + buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox); +",8151,8387,11000 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.pkl new file mode 100644 index 0000000000000000000000000000000000000000..3b3f3a2fc8b248f324bfbdcec0c0d71a848c1655 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1fcbc7d1f41fc4afdbd71180a592da365f459ff7f5cb6a67b570a48dfea26a3 +size 493982 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_stats.json b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_stats.json new file mode 100644 index 0000000000000000000000000000000000000000..70ecf345b826f6a87d6048fd7c182d458168abae --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_stats.json @@ -0,0 +1,47 @@ +{ + "total": 10000, + "processed": 9999, + "skipped": 1, + "categories": { + "under_512": { + "count": 7588, + "percentage": 75.88, + "max_tokens_setting": 512 + }, + "512_to_1024": { + "count": 1727, + "percentage": 17.27, + "max_tokens_setting": 1024 + }, + "1024_to_2048": { + "count": 490, + "percentage": 4.9, + "max_tokens_setting": 2048 + }, + "2048_to_4096": { + "count": 134, + "percentage": 1.34, + "max_tokens_setting": 4096 + }, + "4096_to_6144": { + "count": 40, + "percentage": 0.4, + "max_tokens_setting": 6144 + }, + "6144_to_8192": { + "count": 10, + "percentage": 0.1, + "max_tokens_setting": 8192 + }, + "8192_to_11000": { + "count": 7, + "percentage": 0.07, + "max_tokens_setting": 11000 + }, + "11000_to_28000": { + "count": 3, + "percentage": 0.03, + "max_tokens_setting": 28000 + } + } +} \ No newline at end of file diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv new file mode 100644 index 0000000000000000000000000000000000000000..2bcd24b9ed3ca6d364e4d44378941cd34df6d00b --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:379805959f0f16fa614e67a8fc49b92bfac28583a4fe0d2305b561e61b8c7587 +size 29846636 diff --git a/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.pkl b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.pkl new file mode 100644 index 0000000000000000000000000000000000000000..164308f6d51d584c441d2a89e8b219b19dce6165 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0dc83f6dff8f668ab750a811a3c3010a11e0dd541484d8ace7a04d3ede72f58 +size 12476666 diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..e2bee0c42196238424d2730cf937e9449a08a8be --- /dev/null +++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.jsonl @@ -0,0 +1,639 @@ +{"idx":315835,"func":"static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) \/* {{{ *\/\n{\n\tHashTable *_SERVER;\n\tzval **stuff;\n\tchar *path_info;\n\tint basename_len = strlen(basename);\n\tint code;\n\tzval *temp;\n\n\t\/* \"tweak\" $_SERVER variables requested in earlier call to Phar::mungServer() *\/\n\tif (!PG(http_globals)[TRACK_VARS_SERVER]) {\n\t\treturn;\n\t}\n\n\t_SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);\n\n\t\/* PATH_INFO and PATH_TRANSLATED should always be munged *\/\n\tif (SUCCESS == zend_hash_find(_SERVER, \"PATH_INFO\", sizeof(\"PATH_INFO\"), (void **) &stuff)) {\n\t\tpath_info = Z_STRVAL_PP(stuff);\n\t\tcode = Z_STRLEN_PP(stuff);\n\n\t\tif (Z_STRLEN_PP(stuff) > entry_len && !memcmp(Z_STRVAL_PP(stuff), entry, entry_len)) {\n\t\t\tZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + entry_len, request_uri_len, 1);\n\n\t\t\tMAKE_STD_ZVAL(temp);\n\t\t\tZVAL_STRINGL(temp, path_info, code, 0);\n\n\t\t\tzend_hash_update(_SERVER, \"PHAR_PATH_INFO\", sizeof(\"PHAR_PATH_INFO\"), &temp, sizeof(zval **), NULL);\n\t\t}\n\t}\n\n\tif (SUCCESS == zend_hash_find(_SERVER, \"PATH_TRANSLATED\", sizeof(\"PATH_TRANSLATED\"), (void **) &stuff)) {\n\t\tpath_info = Z_STRVAL_PP(stuff);\n\t\tcode = Z_STRLEN_PP(stuff);\n\t\tZ_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, \"phar:\/\/%s%s\", fname, entry);\n\n\t\tMAKE_STD_ZVAL(temp);\n\t\tZVAL_STRINGL(temp, path_info, code, 0);\n\n\t\tzend_hash_update(_SERVER, \"PHAR_PATH_TRANSLATED\", sizeof(\"PHAR_PATH_TRANSLATED\"), (void *) &temp, sizeof(zval **), NULL);\n\t}\n\n\tif (!PHAR_GLOBALS->phar_SERVER_mung_list) {\n\t\treturn;\n\t}\n\n\tif (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) {\n\t\tif (SUCCESS == zend_hash_find(_SERVER, \"REQUEST_URI\", sizeof(\"REQUEST_URI\"), (void **) &stuff)) {\n\t\t\tpath_info = Z_STRVAL_PP(stuff);\n\t\t\tcode = Z_STRLEN_PP(stuff);\n\n\t\t\tif (Z_STRLEN_PP(stuff) > basename_len && !memcmp(Z_STRVAL_PP(stuff), basename, basename_len)) {\n\t\t\t\tZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + basename_len, Z_STRLEN_PP(stuff) - basename_len, 1);\n\n\t\t\t\tMAKE_STD_ZVAL(temp);\n\t\t\t\tZVAL_STRINGL(temp, path_info, code, 0);\n\n\t\t\t\tzend_hash_update(_SERVER, \"PHAR_REQUEST_URI\", sizeof(\"PHAR_REQUEST_URI\"), (void *) &temp, sizeof(zval **), NULL);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) {\n\t\tif (SUCCESS == zend_hash_find(_SERVER, \"PHP_SELF\", sizeof(\"PHP_SELF\"), (void **) &stuff)) {\n\t\t\tpath_info = Z_STRVAL_PP(stuff);\n\t\t\tcode = Z_STRLEN_PP(stuff);\n\n\t\t\tif (Z_STRLEN_PP(stuff) > basename_len && !memcmp(Z_STRVAL_PP(stuff), basename, basename_len)) {\n\t\t\t\tZVAL_STRINGL(*stuff, Z_STRVAL_PP(stuff) + basename_len, Z_STRLEN_PP(stuff) - basename_len, 1);\n\n\t\t\t\tMAKE_STD_ZVAL(temp);\n\t\t\t\tZVAL_STRINGL(temp, path_info, code, 0);\n\n\t\t\t\tzend_hash_update(_SERVER, \"PHAR_PHP_SELF\", sizeof(\"PHAR_PHP_SELF\"), (void *) &temp, sizeof(zval **), NULL);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) {\n\t\tif (SUCCESS == zend_hash_find(_SERVER, \"SCRIPT_NAME\", sizeof(\"SCRIPT_NAME\"), (void **) &stuff)) {\n\t\t\tpath_info = Z_STRVAL_PP(stuff);\n\t\t\tcode = Z_STRLEN_PP(stuff);\n\t\t\tZVAL_STRINGL(*stuff, entry, entry_len, 1);\n\n\t\t\tMAKE_STD_ZVAL(temp);\n\t\t\tZVAL_STRINGL(temp, path_info, code, 0);\n\n\t\t\tzend_hash_update(_SERVER, \"PHAR_SCRIPT_NAME\", sizeof(\"PHAR_SCRIPT_NAME\"), (void *) &temp, sizeof(zval **), NULL);\n\t\t}\n\t}\n\n\tif (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) {\n\t\tif (SUCCESS == zend_hash_find(_SERVER, \"SCRIPT_FILENAME\", sizeof(\"SCRIPT_FILENAME\"), (void **) &stuff)) {\n\t\t\tpath_info = Z_STRVAL_PP(stuff);\n\t\t\tcode = Z_STRLEN_PP(stuff);\n\t\t\tZ_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, \"phar:\/\/%s%s\", fname, entry);\n\n\t\t\tMAKE_STD_ZVAL(temp);\n\t\t\tZVAL_STRINGL(temp, path_info, code, 0);\n\n\t\t\tzend_hash_update(_SERVER, \"PHAR_SCRIPT_FILENAME\", sizeof(\"PHAR_SCRIPT_FILENAME\"), (void *) &temp, sizeof(zval **), NULL);\n\t\t}\n\t}\n}\n\/* }}} *\/\n","target":0,"code_token_length":1177,"total_token_length":1413,"max_tokens_setting":2048} +{"idx":338003,"func":"static int dts_probe(AVProbeData *p)\n\n{\n\n const uint8_t *buf, *bufp;\n\n uint32_t state = -1;\n\n int markers[4*16] = {0};\n\n int exss_markers = 0, exss_nextpos = 0;\n\n int sum, max, pos, i;\n\n int64_t diff = 0;\n\n uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };\n\n\n\n for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {\n\n int marker, sample_blocks, sample_rate, sr_code, framesize;\n\n int lfe, wide_hdr, hdr_size;\n\n GetBitContext gb;\n\n\n\n bufp = buf = p->buf + pos;\n\n state = (state << 16) | bytestream_get_be16(&bufp);\n\n\n\n if (pos >= 4)\n\n diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));\n\n\n\n \/* extension substream (EXSS) *\/\n\n if (state == DCA_SYNCWORD_SUBSTREAM) {\n\n if (pos < exss_nextpos)\n\n continue;\n\n\n\n init_get_bits(&gb, buf - 2, 96);\n\n skip_bits_long(&gb, 42);\n\n\n\n wide_hdr = get_bits1(&gb);\n\n hdr_size = get_bits(&gb, 8 + 4 * wide_hdr) + 1;\n\n framesize = get_bits(&gb, 16 + 4 * wide_hdr) + 1;\n\n if (hdr_size & 3 || framesize & 3)\n\n continue;\n\n if (hdr_size < 16 || framesize < hdr_size)\n\n continue;\n\n if (pos - 2 + hdr_size > p->buf_size)\n\n continue;\n\n if (av_crc(av_crc_get_table(AV_CRC_16_CCITT), 0xffff, buf + 3, hdr_size - 5))\n\n continue;\n\n\n\n if (pos == exss_nextpos)\n\n exss_markers++;\n\n else\n\n exss_markers = FFMAX(1, exss_markers - 1);\n\n exss_nextpos = pos + framesize;\n\n continue;\n\n }\n\n\n\n \/* regular bitstream *\/\n\n if (state == DCA_SYNCWORD_CORE_BE &&\n\n (bytestream_get_be16(&bufp) & 0xFC00) == 0xFC00)\n\n marker = 0;\n\n else if (state == DCA_SYNCWORD_CORE_LE &&\n\n (bytestream_get_be16(&bufp) & 0x00FC) == 0x00FC)\n\n marker = 1;\n\n\n\n \/* 14 bits big-endian bitstream *\/\n\n else if (state == DCA_SYNCWORD_CORE_14B_BE &&\n\n (bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)\n\n marker = 2;\n\n\n\n \/* 14 bits little-endian bitstream *\/\n\n else if (state == DCA_SYNCWORD_CORE_14B_LE &&\n\n (bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)\n\n marker = 3;\n\n else\n\n continue;\n\n\n\n if (avpriv_dca_convert_bitstream(buf-2, 12, hdr, 12) < 0)\n\n continue;\n\n\n\n init_get_bits(&gb, hdr, 96);\n\n skip_bits_long(&gb, 39);\n\n\n\n sample_blocks = get_bits(&gb, 7) + 1;\n\n if (sample_blocks < 8)\n\n continue;\n\n\n\n framesize = get_bits(&gb, 14) + 1;\n\n if (framesize < 95)\n\n continue;\n\n\n\n skip_bits(&gb, 6);\n\n sr_code = get_bits(&gb, 4);\n\n sample_rate = avpriv_dca_sample_rates[sr_code];\n\n if (sample_rate == 0)\n\n continue;\n\n\n\n get_bits(&gb, 5);\n\n if (get_bits(&gb, 1))\n\n continue;\n\n\n\n skip_bits_long(&gb, 9);\n\n lfe = get_bits(&gb, 2);\n\n if (lfe > 2)\n\n continue;\n\n\n\n marker += 4* sr_code;\n\n\n\n markers[marker] ++;\n\n }\n\n\n\n if (exss_markers > 3)\n\n return AVPROBE_SCORE_EXTENSION + 1;\n\n\n\n sum = max = 0;\n\n for (i=0; i 3 && p->buf_size \/ markers[max] < 32*1024 &&\n\n markers[max] * 4 > sum * 3 &&\n\n diff \/ p->buf_size > 200)\n\n return AVPROBE_SCORE_EXTENSION + 1;\n\n\n\n return 0;\n\n}\n","target":0,"code_token_length":1129,"total_token_length":1365,"max_tokens_setting":2048} +{"idx":288589,"func":"IN_PROC_BROWSER_TEST_F ( SitePerProcessInteractiveBrowserTest , SequentialFocusNavigation ) {\n GURL main_url ( embedded_test_server ( ) -> GetURL ( \"a.com\" , \"\/cross_site_iframe_factory.html?a(b,c)\" ) ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , main_url ) ;\n content : : WebContents * web_contents = browser ( ) -> tab_strip_model ( ) -> GetActiveWebContents ( ) ;\n content : : RenderFrameHost * main_frame = web_contents -> GetMainFrame ( ) ;\n content : : RenderFrameHost * child1 = ChildFrameAt ( main_frame , 0 ) ;\n ASSERT_NE ( nullptr , child1 ) ;\n content : : RenderFrameHost * child2 = ChildFrameAt ( main_frame , 1 ) ;\n ASSERT_NE ( nullptr , child2 ) ;\n EXPECT_TRUE ( ExecuteScript ( main_frame , \"window.name = 'root';\n\" ) ) ;\n EXPECT_TRUE ( ExecuteScript ( child1 , \"window.name = 'child1';\n\" ) ) ;\n EXPECT_TRUE ( ExecuteScript ( child2 , \"window.name = 'child2';\n\" ) ) ;\n std : : string script = \"function onFocus(e) {\n\" \" domAutomationController.setAutomationId(0);\n\" \" domAutomationController.send(window.name + '-focused-' + e.target.id);\n\" \"}\n\" \"var input1 = document.createElement('input');\n\" \"input1.id = 'input1';\n\" \"var input2 = document.createElement('input');\n\" \"input2.id = 'input2';\n\" \"document.body.insertBefore(input1, document.body.firstChild);\n\" \"document.body.appendChild(input2);\n\" \"input1.addEventListener('focus', onFocus, false);\n\" \"input2.addEventListener('focus', onFocus, false);\n\" ;\n EXPECT_TRUE ( ExecuteScript ( main_frame , script ) ) ;\n EXPECT_TRUE ( ExecuteScript ( child1 , script ) ) ;\n EXPECT_TRUE ( ExecuteScript ( child2 , script ) ) ;\n auto press_tab_and_wait_for_message = [ web_contents ] ( bool reverse ) {\n content : : DOMMessageQueue msg_queue ;\n std : : string reply ;\n SimulateKeyPress ( web_contents , ui : : DomKey : : TAB , ui : : DomCode : : TAB , ui : : VKEY_TAB , false , reverse , false , false ) ;\n EXPECT_TRUE ( msg_queue . WaitForMessage ( & reply ) ) ;\n return reply ;\n }\n ;\n EXPECT_EQ ( \"\\\"root-focused-input1\\\"\" , press_tab_and_wait_for_message ( false ) ) ;\n EXPECT_EQ ( main_frame , web_contents -> GetFocusedFrame ( ) ) ;\n EXPECT_EQ ( \"\\\"child1-focused-input1\\\"\" , press_tab_and_wait_for_message ( false ) ) ;\n EXPECT_EQ ( child1 , web_contents -> GetFocusedFrame ( ) ) ;\n EXPECT_EQ ( \"\\\"child1-focused-input2\\\"\" , press_tab_and_wait_for_message ( false ) ) ;\n EXPECT_EQ ( \"\\\"child2-focused-input1\\\"\" , press_tab_and_wait_for_message ( false ) ) ;\n EXPECT_EQ ( child2 , web_contents -> GetFocusedFrame ( ) ) ;\n EXPECT_EQ ( \"\\\"child2-focused-input2\\\"\" , press_tab_and_wait_for_message ( false ) ) ;\n EXPECT_EQ ( \"\\\"root-focused-input2\\\"\" , press_tab_and_wait_for_message ( false ) ) ;\n EXPECT_EQ ( main_frame , web_contents -> GetFocusedFrame ( ) ) ;\n EXPECT_EQ ( \"\\\"child2-focused-input2\\\"\" , press_tab_and_wait_for_message ( true ) ) ;\n EXPECT_EQ ( child2 , web_contents -> GetFocusedFrame ( ) ) ;\n EXPECT_EQ ( \"\\\"child2-focused-input1\\\"\" , press_tab_and_wait_for_message ( true ) ) ;\n EXPECT_EQ ( \"\\\"child1-focused-input2\\\"\" , press_tab_and_wait_for_message ( true ) ) ;\n EXPECT_EQ ( child1 , web_contents -> GetFocusedFrame ( ) ) ;\n EXPECT_EQ ( \"\\\"child1-focused-input1\\\"\" , press_tab_and_wait_for_message ( true ) ) ;\n EXPECT_EQ ( \"\\\"root-focused-input1\\\"\" , press_tab_and_wait_for_message ( true ) ) ;\n EXPECT_EQ ( main_frame , web_contents -> GetFocusedFrame ( ) ) ;\n }","target":0,"code_token_length":846,"total_token_length":1082,"max_tokens_setting":2048} +{"idx":476798,"func":"static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)\n{\n\tstruct mkiss *ax = netdev_priv(dev);\n\tunsigned char *p;\n\tint actual, count;\n\n\tif (ax->mtu != ax->dev->mtu + 73)\t\/* Someone has been ifconfigging *\/\n\t\tax_changedmtu(ax);\n\n\tif (len > ax->mtu) {\t\t\/* Sigh, shouldn't occur BUT ... *\/\n\t\tprintk(KERN_ERR \"mkiss: %s: truncating oversized transmit packet!\\n\", ax->dev->name);\n\t\tdev->stats.tx_dropped++;\n\t\tnetif_start_queue(dev);\n\t\treturn;\n\t}\n\n\tp = icp;\n\n\tspin_lock_bh(&ax->buflock);\n\tif ((*p & 0x0f) != 0) {\n\t\t\/* Configuration Command (kissparms(1).\n\t\t * Protocol spec says: never append CRC.\n\t\t * This fixes a very old bug in the linux\n\t\t * kiss driver. -- dl9sau *\/\n\t\tswitch (*p & 0xff) {\n\t\tcase 0x85:\n\t\t\t\/* command from userspace especially for us,\n\t\t\t * not for delivery to the tnc *\/\n\t\t\tif (len > 1) {\n\t\t\t\tint cmd = (p[1] & 0xff);\n\t\t\t\tswitch(cmd) {\n\t\t\t\tcase 3:\n\t\t\t\t ax->crcmode = CRC_MODE_SMACK;\n\t\t\t\t break;\n\t\t\t\tcase 2:\n\t\t\t\t ax->crcmode = CRC_MODE_FLEX;\n\t\t\t\t break;\n\t\t\t\tcase 1:\n\t\t\t\t ax->crcmode = CRC_MODE_NONE;\n\t\t\t\t break;\n\t\t\t\tcase 0:\n\t\t\t\tdefault:\n\t\t\t\t ax->crcmode = CRC_MODE_SMACK_TEST;\n\t\t\t\t cmd = 0;\n\t\t\t\t}\n\t\t\t\tax->crcauto = (cmd ? 0 : 1);\n\t\t\t\tprintk(KERN_INFO \"mkiss: %s: crc mode set to %d\\n\",\n\t\t\t\t ax->dev->name, cmd);\n\t\t\t}\n\t\t\tspin_unlock_bh(&ax->buflock);\n\t\t\tnetif_start_queue(dev);\n\n\t\t\treturn;\n\t\tdefault:\n\t\t\tcount = kiss_esc(p, ax->xbuff, len);\n\t\t}\n\t} else {\n\t\tunsigned short crc;\n\t\tswitch (ax->crcmode) {\n\t\tcase CRC_MODE_SMACK_TEST:\n\t\t\tax->crcmode = CRC_MODE_FLEX_TEST;\n\t\t\tprintk(KERN_INFO \"mkiss: %s: Trying crc-smack\\n\", ax->dev->name);\n\t\t\tfallthrough;\n\t\tcase CRC_MODE_SMACK:\n\t\t\t*p |= 0x80;\n\t\t\tcrc = swab16(crc16(0, p, len));\n\t\t\tcount = kiss_esc_crc(p, ax->xbuff, crc, len+2);\n\t\t\tbreak;\n\t\tcase CRC_MODE_FLEX_TEST:\n\t\t\tax->crcmode = CRC_MODE_NONE;\n\t\t\tprintk(KERN_INFO \"mkiss: %s: Trying crc-flexnet\\n\", ax->dev->name);\n\t\t\tfallthrough;\n\t\tcase CRC_MODE_FLEX:\n\t\t\t*p |= 0x20;\n\t\t\tcrc = calc_crc_flex(p, len);\n\t\t\tcount = kiss_esc_crc(p, ax->xbuff, crc, len+2);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tcount = kiss_esc(p, ax->xbuff, len);\n\t\t}\n\t}\n\tspin_unlock_bh(&ax->buflock);\n\n\tset_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);\n\tactual = ax->tty->ops->write(ax->tty, ax->xbuff, count);\n\tdev->stats.tx_packets++;\n\tdev->stats.tx_bytes += actual;\n\n\tnetif_trans_update(ax->dev);\n\tax->xleft = count - actual;\n\tax->xhead = ax->xbuff + actual;\n}","target":0,"code_token_length":789,"total_token_length":1025,"max_tokens_setting":2048} +{"idx":122896,"func":"inline void LstmCell(\n const LstmCellParams& params, const RuntimeShape& unextended_input_shape,\n const float* input_data, const RuntimeShape& unextended_prev_activ_shape,\n const float* prev_activ_data, const RuntimeShape& weights_shape,\n const float* weights_data, const RuntimeShape& unextended_bias_shape,\n const float* bias_data, const RuntimeShape& unextended_prev_state_shape,\n const float* prev_state_data,\n const RuntimeShape& unextended_output_state_shape, float* output_state_data,\n const RuntimeShape& unextended_output_activ_shape, float* output_activ_data,\n const RuntimeShape& unextended_concat_temp_shape, float* concat_temp_data,\n const RuntimeShape& unextended_activ_temp_shape, float* activ_temp_data,\n CpuBackendContext* cpu_backend_context) {\n ruy::profiler::ScopeLabel label(\"LstmCell\");\n TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_prev_activ_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_bias_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_prev_state_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_output_state_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_output_activ_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_concat_temp_shape.DimensionsCount(), 4);\n TFLITE_DCHECK_LE(unextended_activ_temp_shape.DimensionsCount(), 4);\n const RuntimeShape input_shape =\n RuntimeShape::ExtendedShape(4, unextended_input_shape);\n const RuntimeShape prev_activ_shape =\n RuntimeShape::ExtendedShape(4, unextended_prev_activ_shape);\n const RuntimeShape bias_shape =\n RuntimeShape::ExtendedShape(4, unextended_bias_shape);\n const RuntimeShape prev_state_shape =\n RuntimeShape::ExtendedShape(4, unextended_prev_state_shape);\n const RuntimeShape output_state_shape =\n RuntimeShape::ExtendedShape(4, unextended_output_state_shape);\n const RuntimeShape output_activ_shape =\n RuntimeShape::ExtendedShape(4, unextended_output_activ_shape);\n const RuntimeShape concat_temp_shape =\n RuntimeShape::ExtendedShape(4, unextended_concat_temp_shape);\n const RuntimeShape activ_temp_shape =\n RuntimeShape::ExtendedShape(4, unextended_activ_temp_shape);\n TFLITE_DCHECK_GE(weights_shape.DimensionsCount(), 2);\n\n const int weights_dim_count = weights_shape.DimensionsCount();\n MatchingDim( \/\/ batches\n input_shape, 0, prev_activ_shape, 0, prev_state_shape, 0,\n output_state_shape, 0, output_activ_shape, 0);\n MatchingDim( \/\/ height\n input_shape, 1, prev_activ_shape, 1, prev_state_shape, 1,\n output_state_shape, 1, output_activ_shape, 1);\n MatchingDim( \/\/ width\n input_shape, 2, prev_activ_shape, 2, prev_state_shape, 2,\n output_state_shape, 2, output_activ_shape, 2);\n const int input_depth = input_shape.Dims(3);\n const int prev_activ_depth = prev_activ_shape.Dims(3);\n const int total_input_depth = prev_activ_depth + input_depth;\n TFLITE_DCHECK_EQ(weights_shape.Dims(weights_dim_count - 1),\n total_input_depth);\n TFLITE_DCHECK_EQ(FlatSizeSkipDim(bias_shape, 3), 1);\n const int intern_activ_depth =\n MatchingDim(weights_shape, weights_dim_count - 2, bias_shape, 3);\n TFLITE_DCHECK_EQ(weights_shape.FlatSize(),\n intern_activ_depth * total_input_depth);\n TFLITE_DCHECK_EQ(intern_activ_depth % 4, 0);\n const int output_depth =\n MatchingDim(prev_state_shape, 3, prev_activ_shape, 3, output_state_shape,\n 3, output_activ_shape, 3);\n TFLITE_DCHECK_EQ(output_depth, intern_activ_depth \/ 4);\n\n \/\/ Concatenate prev_activ and input data together\n std::vector concat_input_arrays_data;\n std::vector concat_input_arrays_shapes;\n concat_input_arrays_data.push_back(input_data);\n concat_input_arrays_data.push_back(prev_activ_data);\n concat_input_arrays_shapes.push_back(&input_shape);\n concat_input_arrays_shapes.push_back(&prev_activ_shape);\n tflite::ConcatenationParams concat_params;\n concat_params.axis = 3;\n concat_params.inputs_count = concat_input_arrays_data.size();\n Concatenation(concat_params, &(concat_input_arrays_shapes[0]),\n &(concat_input_arrays_data[0]), concat_temp_shape,\n concat_temp_data);\n\n \/\/ Fully connected\n tflite::FullyConnectedParams fc_params;\n fc_params.float_activation_min = std::numeric_limits::lowest();\n fc_params.float_activation_max = std::numeric_limits::max();\n fc_params.lhs_cacheable = false;\n fc_params.rhs_cacheable = false;\n FullyConnected(fc_params, concat_temp_shape, concat_temp_data, weights_shape,\n weights_data, bias_shape, bias_data, activ_temp_shape,\n activ_temp_data, cpu_backend_context);\n\n \/\/ Map raw arrays to Eigen arrays so we can use Eigen's optimized array\n \/\/ operations.\n ArrayMap activ_temp_map =\n MapAsArrayWithLastDimAsRows(activ_temp_data, activ_temp_shape);\n auto input_gate_sm = activ_temp_map.block(0 * output_depth, 0, output_depth,\n activ_temp_map.cols());\n auto new_input_sm = activ_temp_map.block(1 * output_depth, 0, output_depth,\n activ_temp_map.cols());\n auto forget_gate_sm = activ_temp_map.block(2 * output_depth, 0, output_depth,\n activ_temp_map.cols());\n auto output_gate_sm = activ_temp_map.block(3 * output_depth, 0, output_depth,\n activ_temp_map.cols());\n ArrayMap prev_state_map =\n MapAsArrayWithLastDimAsRows(prev_state_data, prev_state_shape);\n ArrayMap output_state_map =\n MapAsArrayWithLastDimAsRows(output_state_data, output_state_shape);\n ArrayMap output_activ_map =\n MapAsArrayWithLastDimAsRows(output_activ_data, output_activ_shape);\n\n \/\/ Combined memory state and final output calculation\n ruy::profiler::ScopeLabel label2(\"MemoryStateAndFinalOutput\");\n output_state_map =\n input_gate_sm.unaryExpr(Eigen::internal::scalar_logistic_op()) *\n new_input_sm.tanh() +\n forget_gate_sm.unaryExpr(Eigen::internal::scalar_logistic_op()) *\n prev_state_map;\n output_activ_map =\n output_gate_sm.unaryExpr(Eigen::internal::scalar_logistic_op()) *\n output_state_map.tanh();\n}","target":0,"code_token_length":1506,"total_token_length":1742,"max_tokens_setting":2048} +{"idx":494496,"func":"static CURLcode gzip_unencode_write(struct Curl_easy *data,\n struct contenc_writer *writer,\n const char *buf, size_t nbytes)\n{\n struct zlib_params *zp = (struct zlib_params *) &writer->params;\n z_stream *z = &zp->z; \/* zlib state structure *\/\n\n if(zp->zlib_init == ZLIB_INIT_GZIP) {\n \/* Let zlib handle the gzip decompression entirely *\/\n z->next_in = (Bytef *) buf;\n z->avail_in = (uInt) nbytes;\n \/* Now uncompress the data *\/\n return inflate_stream(data, writer, ZLIB_INIT_GZIP);\n }\n\n#ifndef OLD_ZLIB_SUPPORT\n \/* Support for old zlib versions is compiled away and we are running with\n an old version, so return an error. *\/\n return exit_zlib(data, z, &zp->zlib_init, CURLE_WRITE_ERROR);\n\n#else\n \/* This next mess is to get around the potential case where there isn't\n * enough data passed in to skip over the gzip header. If that happens, we\n * malloc a block and copy what we have then wait for the next call. If\n * there still isn't enough (this is definitely a worst-case scenario), we\n * make the block bigger, copy the next part in and keep waiting.\n *\n * This is only required with zlib versions < 1.2.0.4 as newer versions\n * can handle the gzip header themselves.\n *\/\n\n switch(zp->zlib_init) {\n \/* Skip over gzip header? *\/\n case ZLIB_INIT:\n {\n \/* Initial call state *\/\n ssize_t hlen;\n\n switch(check_gzip_header((unsigned char *) buf, nbytes, &hlen)) {\n case GZIP_OK:\n z->next_in = (Bytef *) buf + hlen;\n z->avail_in = (uInt) (nbytes - hlen);\n zp->zlib_init = ZLIB_GZIP_INFLATING; \/* Inflating stream state *\/\n break;\n\n case GZIP_UNDERFLOW:\n \/* We need more data so we can find the end of the gzip header. It's\n * possible that the memory block we malloc here will never be freed if\n * the transfer abruptly aborts after this point. Since it's unlikely\n * that circumstances will be right for this code path to be followed in\n * the first place, and it's even more unlikely for a transfer to fail\n * immediately afterwards, it should seldom be a problem.\n *\/\n z->avail_in = (uInt) nbytes;\n z->next_in = malloc(z->avail_in);\n if(!z->next_in) {\n return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);\n }\n memcpy(z->next_in, buf, z->avail_in);\n zp->zlib_init = ZLIB_GZIP_HEADER; \/* Need more gzip header data state *\/\n \/* We don't have any data to inflate yet *\/\n return CURLE_OK;\n\n case GZIP_BAD:\n default:\n return exit_zlib(data, z, &zp->zlib_init, process_zlib_error(data, z));\n }\n\n }\n break;\n\n case ZLIB_GZIP_HEADER:\n {\n \/* Need more gzip header data state *\/\n ssize_t hlen;\n z->avail_in += (uInt) nbytes;\n z->next_in = Curl_saferealloc(z->next_in, z->avail_in);\n if(!z->next_in) {\n return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);\n }\n \/* Append the new block of data to the previous one *\/\n memcpy(z->next_in + z->avail_in - nbytes, buf, nbytes);\n\n switch(check_gzip_header(z->next_in, z->avail_in, &hlen)) {\n case GZIP_OK:\n \/* This is the zlib stream data *\/\n free(z->next_in);\n \/* Don't point into the malloced block since we just freed it *\/\n z->next_in = (Bytef *) buf + hlen + nbytes - z->avail_in;\n z->avail_in = (uInt) (z->avail_in - hlen);\n zp->zlib_init = ZLIB_GZIP_INFLATING; \/* Inflating stream state *\/\n break;\n\n case GZIP_UNDERFLOW:\n \/* We still don't have any data to inflate! *\/\n return CURLE_OK;\n\n case GZIP_BAD:\n default:\n return exit_zlib(data, z, &zp->zlib_init, process_zlib_error(data, z));\n }\n\n }\n break;\n\n case ZLIB_EXTERNAL_TRAILER:\n z->next_in = (Bytef *) buf;\n z->avail_in = (uInt) nbytes;\n return process_trailer(data, zp);\n\n case ZLIB_GZIP_INFLATING:\n default:\n \/* Inflating stream state *\/\n z->next_in = (Bytef *) buf;\n z->avail_in = (uInt) nbytes;\n break;\n }\n\n if(z->avail_in == 0) {\n \/* We don't have any data to inflate; wait until next time *\/\n return CURLE_OK;\n }\n\n \/* We've parsed the header, now uncompress the data *\/\n return inflate_stream(data, writer, ZLIB_GZIP_INFLATING);\n#endif\n}","target":0,"code_token_length":1178,"total_token_length":1414,"max_tokens_setting":2048} +{"idx":271893,"func":"Status DepthwiseConv2DNativeShapeImpl(shape_inference::InferenceContext* c,\n bool supports_explicit_padding) {\n ShapeHandle input_shape;\n TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 4, &input_shape));\n ShapeHandle filter_shape;\n TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 4, &filter_shape));\n\n std::vector strides;\n TF_RETURN_IF_ERROR(c->GetAttr(\"strides\", &strides));\n\n if (strides.size() != 4) {\n return errors::InvalidArgument(\n \"DepthwiseConv2D requires the stride attribute to contain 4 values, \"\n \"but got: \",\n strides.size());\n }\n\n std::vector dilations;\n if (!c->GetAttr(\"dilations\", &dilations).ok()) {\n dilations.resize(4, 1);\n }\n\n if (dilations.size() != 4) {\n return errors::InvalidArgument(\n \"DepthwiseConv2D requires the dilations attribute to contain 4 values, \"\n \"but got: \",\n dilations.size());\n }\n\n string data_format_str;\n Status s = c->GetAttr(\"data_format\", &data_format_str);\n TensorFormat data_format;\n if (!s.ok() || !FormatFromString(data_format_str, &data_format)) {\n data_format = FORMAT_NHWC;\n }\n int32_t stride_rows;\n int32_t stride_cols;\n int32_t dilation_rows;\n int32_t dilation_cols;\n if (data_format == FORMAT_NCHW) {\n \/\/ Canonicalize input shape to NHWC so the shape inference code below can\n \/\/ process it.\n input_shape =\n c->MakeShape({{c->Dim(input_shape, 0), c->Dim(input_shape, 2),\n c->Dim(input_shape, 3), c->Dim(input_shape, 1)}});\n stride_rows = strides[2];\n stride_cols = strides[3];\n dilation_rows = dilations[2];\n dilation_cols = dilations[3];\n } else {\n stride_rows = strides[1];\n stride_cols = strides[2];\n dilation_rows = dilations[1];\n dilation_cols = dilations[2];\n }\n\n DimensionHandle batch_size_dim = c->Dim(input_shape, 0);\n DimensionHandle in_rows_dim = c->Dim(input_shape, 1);\n DimensionHandle in_cols_dim = c->Dim(input_shape, 2);\n\n DimensionHandle filter_rows_dim = c->Dim(filter_shape, 0);\n DimensionHandle filter_cols_dim = c->Dim(filter_shape, 1);\n DimensionHandle input_depth = c->Dim(filter_shape, 2);\n DimensionHandle depth_multiplier = c->Dim(filter_shape, 3);\n\n \/\/ Check that the input depths are compatible.\n TF_RETURN_IF_ERROR(\n c->Merge(c->Dim(input_shape, 3), input_depth, &input_depth));\n\n DimensionHandle output_depth;\n TF_RETURN_IF_ERROR(c->Multiply(input_depth, depth_multiplier, &output_depth));\n\n Padding padding;\n TF_RETURN_IF_ERROR(c->GetAttr(\"padding\", &padding));\n\n std::vector explicit_paddings;\n if (supports_explicit_padding) {\n Status status = c->GetAttr(\"explicit_paddings\", &explicit_paddings);\n \/\/ Use the default value, which is an empty list, if the attribute is not\n \/\/ found. Otherwise return the error to the caller.\n if (!status.ok() && !errors::IsNotFound(status)) {\n return status;\n }\n TF_RETURN_IF_ERROR(CheckValidPadding(padding, explicit_paddings,\n \/*num_dims=*\/4, data_format));\n } else {\n DCHECK(padding != Padding::EXPLICIT);\n }\n\n \/\/ TODO(mrry,shlens): Raise an error if the stride would cause\n \/\/ information in the input to be ignored. This will require a change\n \/\/ in the kernel implementation.\n DimensionHandle output_rows, output_cols;\n int64_t pad_rows_before = -1, pad_rows_after = -1;\n int64_t pad_cols_before = -1, pad_cols_after = -1;\n if (padding == Padding::EXPLICIT) {\n GetExplicitPaddingForDim(explicit_paddings, data_format, 'H',\n &pad_rows_before, &pad_rows_after);\n GetExplicitPaddingForDim(explicit_paddings, data_format, 'W',\n &pad_cols_before, &pad_cols_after);\n }\n TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n c, in_rows_dim, filter_rows_dim, dilation_rows, stride_rows, padding,\n pad_rows_before, pad_rows_after, &output_rows));\n TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n c, in_cols_dim, filter_cols_dim, dilation_cols, stride_cols, padding,\n pad_cols_before, pad_cols_after, &output_cols));\n\n ShapeHandle output_shape;\n if (data_format == FORMAT_NCHW) {\n output_shape =\n c->MakeShape({batch_size_dim, output_depth, output_rows, output_cols});\n } else {\n output_shape =\n c->MakeShape({batch_size_dim, output_rows, output_cols, output_depth});\n }\n c->set_output(0, output_shape);\n return Status::OK();\n}","target":0,"code_token_length":1170,"total_token_length":1406,"max_tokens_setting":2048} +{"idx":382351,"func":"StreamConnection(pgsocket server_fd, Port *port)\n{\n\t\/* accept connection and fill in the client (remote) address *\/\n\tport->raddr.salen = sizeof(port->raddr.addr);\n\tif ((port->sock = accept(server_fd,\n\t\t\t\t\t\t\t (struct sockaddr *) & port->raddr.addr,\n\t\t\t\t\t\t\t &port->raddr.salen)) == PGINVALID_SOCKET)\n\t{\n\t\tereport(LOG,\n\t\t\t\t(errcode_for_socket_access(),\n\t\t\t\t errmsg(\"could not accept new connection: %m\")));\n\n\t\t\/*\n\t\t * If accept() fails then postmaster.c will still see the server\n\t\t * socket as read-ready, and will immediately try again. To avoid\n\t\t * uselessly sucking lots of CPU, delay a bit before trying again.\n\t\t * (The most likely reason for failure is being out of kernel file\n\t\t * table slots; we can do little except hope some will get freed up.)\n\t\t *\/\n\t\tpg_usleep(100000L);\t\t\/* wait 0.1 sec *\/\n\t\treturn STATUS_ERROR;\n\t}\n\n#ifdef SCO_ACCEPT_BUG\n\n\t\/*\n\t * UnixWare 7+ and OpenServer 5.0.4 are known to have this bug, but it\n\t * shouldn't hurt to catch it for all versions of those platforms.\n\t *\/\n\tif (port->raddr.addr.ss_family == 0)\n\t\tport->raddr.addr.ss_family = AF_UNIX;\n#endif\n\n\t\/* fill in the server (local) address *\/\n\tport->laddr.salen = sizeof(port->laddr.addr);\n\tif (getsockname(port->sock,\n\t\t\t\t\t(struct sockaddr *) & port->laddr.addr,\n\t\t\t\t\t&port->laddr.salen) < 0)\n\t{\n\t\telog(LOG, \"getsockname() failed: %m\");\n\t\treturn STATUS_ERROR;\n\t}\n\n\t\/* select NODELAY and KEEPALIVE options if it's a TCP connection *\/\n\tif (!IS_AF_UNIX(port->laddr.addr.ss_family))\n\t{\n\t\tint\t\t\ton;\n\n#ifdef\tTCP_NODELAY\n\t\ton = 1;\n\t\tif (setsockopt(port->sock, IPPROTO_TCP, TCP_NODELAY,\n\t\t\t\t\t (char *) &on, sizeof(on)) < 0)\n\t\t{\n\t\t\telog(LOG, \"setsockopt(TCP_NODELAY) failed: %m\");\n\t\t\treturn STATUS_ERROR;\n\t\t}\n#endif\n\t\ton = 1;\n\t\tif (setsockopt(port->sock, SOL_SOCKET, SO_KEEPALIVE,\n\t\t\t\t\t (char *) &on, sizeof(on)) < 0)\n\t\t{\n\t\t\telog(LOG, \"setsockopt(SO_KEEPALIVE) failed: %m\");\n\t\t\treturn STATUS_ERROR;\n\t\t}\n\n#ifdef WIN32\n\n\t\t\/*\n\t\t * This is a Win32 socket optimization. The ideal size is 32k.\n\t\t * http:\/\/support.microsoft.com\/kb\/823764\/EN-US\/\n\t\t *\/\n\t\ton = PQ_SEND_BUFFER_SIZE * 4;\n\t\tif (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &on,\n\t\t\t\t\t sizeof(on)) < 0)\n\t\t{\n\t\t\telog(LOG, \"setsockopt(SO_SNDBUF) failed: %m\");\n\t\t\treturn STATUS_ERROR;\n\t\t}\n#endif\n\n\t\t\/*\n\t\t * Also apply the current keepalive parameters. If we fail to set a\n\t\t * parameter, don't error out, because these aren't universally\n\t\t * supported. (Note: you might think we need to reset the GUC\n\t\t * variables to 0 in such a case, but it's not necessary because the\n\t\t * show hooks for these variables report the truth anyway.)\n\t\t *\/\n\t\t(void) pq_setkeepalivesidle(tcp_keepalives_idle, port);\n\t\t(void) pq_setkeepalivesinterval(tcp_keepalives_interval, port);\n\t\t(void) pq_setkeepalivescount(tcp_keepalives_count, port);\n\t}\n\n\treturn STATUS_OK;\n}","target":0,"code_token_length":836,"total_token_length":1072,"max_tokens_setting":2048} +{"idx":393100,"func":"xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,\n\t\t\t int type, const xmlChar *targetNamespace)\n{\n xmlSchemaBucketPtr ret;\n int size;\n xmlSchemaPtr mainSchema;\n\n if (WXS_CONSTRUCTOR(pctxt)->mainSchema == NULL) {\n\tPERROR_INT(\"xmlSchemaBucketCreate\",\n\t \"no main schema on constructor\");\n\treturn(NULL);\n }\n mainSchema = WXS_CONSTRUCTOR(pctxt)->mainSchema;\n \/* Create the schema bucket. *\/\n if (WXS_IS_BUCKET_INCREDEF(type))\n\tsize = sizeof(xmlSchemaInclude);\n else\n\tsize = sizeof(xmlSchemaImport);\n ret = (xmlSchemaBucketPtr) xmlMalloc(size);\n if (ret == NULL) {\n\txmlSchemaPErrMemory(NULL, \"allocating schema bucket\", NULL);\n\treturn(NULL);\n }\n memset(ret, 0, size);\n ret->targetNamespace = targetNamespace;\n ret->type = type;\n ret->globals = xmlSchemaItemListCreate();\n if (ret->globals == NULL) {\n\txmlFree(ret);\n\treturn(NULL);\n }\n ret->locals = xmlSchemaItemListCreate();\n if (ret->locals == NULL) {\n\txmlFree(ret);\n\treturn(NULL);\n }\n \/*\n * The following will assure that only the first bucket is marked as\n * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema.\n * For each following import buckets an xmlSchema will be created.\n * An xmlSchema will be created for every distinct targetNamespace.\n * We assign the targetNamespace to the schemata here.\n *\/\n if (! WXS_HAS_BUCKETS(pctxt)) {\n\tif (WXS_IS_BUCKET_INCREDEF(type)) {\n\t PERROR_INT(\"xmlSchemaBucketCreate\",\n\t\t\"first bucket but it's an include or redefine\");\n\t xmlSchemaBucketFree(ret);\n\t return(NULL);\n\t}\n\t\/* Force the type to be XML_SCHEMA_SCHEMA_MAIN. *\/\n\tret->type = XML_SCHEMA_SCHEMA_MAIN;\n\t\/* Point to the *main* schema. *\/\n\tWXS_CONSTRUCTOR(pctxt)->mainBucket = ret;\n\tWXS_IMPBUCKET(ret)->schema = mainSchema;\n\t\/*\n\t* Ensure that the main schema gets a targetNamespace.\n\t*\/\n\tmainSchema->targetNamespace = targetNamespace;\n } else {\n\tif (type == XML_SCHEMA_SCHEMA_MAIN) {\n\t PERROR_INT(\"xmlSchemaBucketCreate\",\n\t\t\"main bucket but it's not the first one\");\n\t xmlSchemaBucketFree(ret);\n\t return(NULL);\n\t} else if (type == XML_SCHEMA_SCHEMA_IMPORT) {\n\t \/*\n\t * Create a schema for imports and assign the\n\t * targetNamespace.\n\t *\/\n\t WXS_IMPBUCKET(ret)->schema = xmlSchemaNewSchema(pctxt);\n\t if (WXS_IMPBUCKET(ret)->schema == NULL) {\n\t\txmlSchemaBucketFree(ret);\n\t\treturn(NULL);\n\t }\n\t WXS_IMPBUCKET(ret)->schema->targetNamespace = targetNamespace;\n\t}\n }\n if (WXS_IS_BUCKET_IMPMAIN(type)) {\n\tint res;\n\t\/*\n\t* Imports go into the \"schemasImports\" slot of the main *schema*.\n\t* Note that we create an import entry for the main schema as well; i.e.,\n\t* even if there's only one schema, we'll get an import.\n\t*\/\n\tif (mainSchema->schemasImports == NULL) {\n\t mainSchema->schemasImports = xmlHashCreateDict(5,\n\t\tWXS_CONSTRUCTOR(pctxt)->dict);\n\t if (mainSchema->schemasImports == NULL) {\n\t\txmlSchemaBucketFree(ret);\n\t\treturn(NULL);\n\t }\n\t}\n\tif (targetNamespace == NULL)\n\t res = xmlHashAddEntry(mainSchema->schemasImports,\n\t\tXML_SCHEMAS_NO_NAMESPACE, ret);\n\telse\n\t res = xmlHashAddEntry(mainSchema->schemasImports,\n\t\ttargetNamespace, ret);\n\tif (res != 0) {\n\t PERROR_INT(\"xmlSchemaBucketCreate\",\n\t\t\"failed to add the schema bucket to the hash\");\n\t xmlSchemaBucketFree(ret);\n\t return(NULL);\n\t}\n } else {\n\t\/* Set the @ownerImport of an include bucket. *\/\n\tif (WXS_IS_BUCKET_IMPMAIN(WXS_CONSTRUCTOR(pctxt)->bucket->type))\n\t WXS_INCBUCKET(ret)->ownerImport =\n\t\tWXS_IMPBUCKET(WXS_CONSTRUCTOR(pctxt)->bucket);\n\telse\n\t WXS_INCBUCKET(ret)->ownerImport =\n\t\tWXS_INCBUCKET(WXS_CONSTRUCTOR(pctxt)->bucket)->ownerImport;\n\n\t\/* Includes got into the \"includes\" slot of the *main* schema. *\/\n\tif (mainSchema->includes == NULL) {\n\t mainSchema->includes = xmlSchemaItemListCreate();\n\t if (mainSchema->includes == NULL) {\n\t\txmlSchemaBucketFree(ret);\n\t\treturn(NULL);\n\t }\n\t}\n\txmlSchemaItemListAdd(mainSchema->includes, ret);\n }\n \/*\n * Add to list of all buckets; this is used for lookup\n * during schema construction time only.\n *\/\n if (xmlSchemaItemListAdd(WXS_CONSTRUCTOR(pctxt)->buckets, ret) == -1)\n\treturn(NULL);\n return(ret);\n}","target":0,"code_token_length":1079,"total_token_length":1315,"max_tokens_setting":2048} +{"idx":156649,"func":"static int process_block(struct archive_read* a) {\n\tconst uint8_t* p;\n\tstruct rar5* rar = get_context(a);\n\tint ret;\n\n\t\/* If we don't have any data to be processed, this most probably means\n\t * we need to switch to the next volume. *\/\n\tif(rar->main.volume && rar->file.bytes_remaining == 0) {\n\t\tret = advance_multivolume(a);\n\t\tif(ret != ARCHIVE_OK)\n\t\t\treturn ret;\n\t}\n\n\tif(rar->cstate.block_parsing_finished) {\n\t\tssize_t block_size;\n\t\tssize_t to_skip;\n\t\tssize_t cur_block_size;\n\n\t\t\/* The header size won't be bigger than 6 bytes. *\/\n\t\tif(!read_ahead(a, 6, &p)) {\n\t\t\t\/* Failed to prefetch data block header. *\/\n\t\t\treturn ARCHIVE_EOF;\n\t\t}\n\n\t\t\/*\n\t\t * Read block_size by parsing block header. Validate the header\n\t\t * by calculating CRC byte stored inside the header. Size of\n\t\t * the header is not constant (block size can be stored either\n\t\t * in 1 or 2 bytes), that's why block size is left out from the\n\t\t * `compressed_block_header` structure and returned by\n\t\t * `parse_block_header` as the second argument. *\/\n\n\t\tret = parse_block_header(a, p, &block_size,\n\t\t &rar->last_block_hdr);\n\t\tif(ret != ARCHIVE_OK) {\n\t\t\treturn ret;\n\t\t}\n\n\t\t\/* Skip block header. Next data is huffman tables,\n\t\t * if present. *\/\n\t\tto_skip = sizeof(struct compressed_block_header) +\n\t\t\tbf_byte_count(&rar->last_block_hdr) + 1;\n\n\t\tif(ARCHIVE_OK != consume(a, to_skip))\n\t\t\treturn ARCHIVE_EOF;\n\n\t\trar->file.bytes_remaining -= to_skip;\n\n\t\t\/* The block size gives information about the whole block size,\n\t\t * but the block could be stored in split form when using\n\t\t * multi-volume archives. In this case, the block size will be\n\t\t * bigger than the actual data stored in this file. Remaining\n\t\t * part of the data will be in another file. *\/\n\n\t\tcur_block_size =\n\t\t\trar5_min(rar->file.bytes_remaining, block_size);\n\n\t\tif(block_size > rar->file.bytes_remaining) {\n\t\t\t\/* If current blocks' size is bigger than our data\n\t\t\t * size, this means we have a multivolume archive.\n\t\t\t * In this case, skip all base headers until the end\n\t\t\t * of the file, proceed to next \"partXXX.rar\" volume,\n\t\t\t * find its signature, skip all headers up to the first\n\t\t\t * FILE base header, and continue from there.\n\t\t\t *\n\t\t\t * Note that `merge_block` will update the `rar`\n\t\t\t * context structure quite extensively. *\/\n\n\t\t\tret = merge_block(a, block_size, &p);\n\t\t\tif(ret != ARCHIVE_OK) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\tcur_block_size = block_size;\n\n\t\t\t\/* Current stream pointer should be now directly\n\t\t\t * *after* the block that spanned through multiple\n\t\t\t * archive files. `p` pointer should have the data of\n\t\t\t * the *whole* block (merged from partial blocks\n\t\t\t * stored in multiple archives files). *\/\n\t\t} else {\n\t\t\trar->cstate.switch_multivolume = 0;\n\n\t\t\t\/* Read the whole block size into memory. This can take\n\t\t\t * up to 8 megabytes of memory in theoretical cases.\n\t\t\t * Might be worth to optimize this and use a standard\n\t\t\t * chunk of 4kb's. *\/\n\t\t\tif(!read_ahead(a, 4 + cur_block_size, &p)) {\n\t\t\t\t\/* Failed to prefetch block data. *\/\n\t\t\t\treturn ARCHIVE_EOF;\n\t\t\t}\n\t\t}\n\n\t\trar->cstate.block_buf = p;\n\t\trar->cstate.cur_block_size = cur_block_size;\n\t\trar->cstate.block_parsing_finished = 0;\n\n\t\trar->bits.in_addr = 0;\n\t\trar->bits.bit_addr = 0;\n\n\t\tif(bf_is_table_present(&rar->last_block_hdr)) {\n\t\t\t\/* Load Huffman tables. *\/\n\t\t\tret = parse_tables(a, rar, p);\n\t\t\tif(ret != ARCHIVE_OK) {\n\t\t\t\t\/* Error during decompression of Huffman\n\t\t\t\t * tables. *\/\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t\/* Block parsing not finished, reuse previous memory buffer. *\/\n\t\tp = rar->cstate.block_buf;\n\t}\n\n\t\/* Uncompress the block, or a part of it, depending on how many bytes\n\t * will be generated by uncompressing the block.\n\t *\n\t * In case too many bytes will be generated, calling this function\n\t * again will resume the uncompression operation. *\/\n\tret = do_uncompress_block(a, p);\n\tif(ret != ARCHIVE_OK) {\n\t\treturn ret;\n\t}\n\n\tif(rar->cstate.block_parsing_finished &&\n\t rar->cstate.switch_multivolume == 0 &&\n\t rar->cstate.cur_block_size > 0)\n\t{\n\t\t\/* If we're processing a normal block, consume the whole\n\t\t * block. We can do this because we've already read the whole\n\t\t * block to memory. *\/\n\t\tif(ARCHIVE_OK != consume(a, rar->cstate.cur_block_size))\n\t\t\treturn ARCHIVE_FATAL;\n\n\t\trar->file.bytes_remaining -= rar->cstate.cur_block_size;\n\t} else if(rar->cstate.switch_multivolume) {\n\t\t\/* Don't consume the block if we're doing multivolume\n\t\t * processing. The volume switching function will consume\n\t\t * the proper count of bytes instead. *\/\n\t\trar->cstate.switch_multivolume = 0;\n\t}\n\n\treturn ARCHIVE_OK;\n}","target":0,"code_token_length":1246,"total_token_length":1482,"max_tokens_setting":2048} +{"idx":64203,"func":"RawTile TileManager::getTile( int resolution, int tile, int xangle, int yangle, int layers, CompressionType ctype ){\n\n RawTile* rawtile = NULL;\n string tileCompression;\n string compName;\n\n\n \/\/ Time the tile retrieval\n if( loglevel >= 3 ) tile_timer.start();\n\n\n \/* Try to get the encoded tile directly from our cache first.\n Otherwise decode one from the source image and add it to the cache\n *\/\n switch( ctype )\n {\n\n case JPEG:\n if( (rawtile = tileCache->getTile( image->getImagePath(), resolution, tile,\n\t\t\t\t\t xangle, yangle, JPEG, compressor->getQuality() )) ) break;\n if( (rawtile = tileCache->getTile( image->getImagePath(), resolution, tile,\n\t\t\t\t\t xangle, yangle, UNCOMPRESSED, 0 )) ) break;\n break;\n\n\n case PNG:\n if( (rawtile = tileCache->getTile( image->getImagePath(), resolution, tile,\n\t\t\t\t\t xangle, yangle, PNG, compressor->getQuality() )) ) break;\n if( (rawtile = tileCache->getTile( image->getImagePath(), resolution, tile,\n\t\t\t\t\t xangle, yangle, UNCOMPRESSED, 0 )) ) break;\n break;\n\n\n case UNCOMPRESSED:\n if( (rawtile = tileCache->getTile( image->getImagePath(), resolution, tile,\n\t\t\t\t\t xangle, yangle, UNCOMPRESSED, 0 )) ) break;\n break;\n\n\n default: \n break;\n\n }\n\n\n\n if( loglevel >= 3 ){\n \/\/ Define our compression names for logging purposes\n switch( ctype ){\n case JPEG: compName = \"JPEG\"; break;\n case PNG: compName = \"PNG\"; break;\n case DEFLATE: compName = \"DEFLATE\"; break;\n case UNCOMPRESSED: compName = \"UNCOMPRESSED\"; break;\n default: break;\n }\n }\n\n\n \/\/ If we haven't been able to get a tile, get a raw one\n if( !rawtile || (rawtile && (rawtile->timestamp < image->timestamp)) ){\n\n if( rawtile && (rawtile->timestamp < image->timestamp) ){\n if( loglevel >= 3 ) *logfile << \"TileManager :: Tile has old timestamp \"\n\t\t\t << rawtile->timestamp << \" - \" << image->timestamp\n << \" ... updating\" << endl;\n }\n\n if( loglevel >= 4 ) *logfile << \"TileManager :: Cache Miss for resolution: \" << resolution\n\t\t\t\t << \", tile: \" << tile\n\t\t\t\t << \", compression: \" << compName\n\t\t\t\t << \", quality: \" << compressor->getQuality() << endl\n\t\t\t\t << \"TileManager :: Cache Size: \" << tileCache->getNumElements()\n\t\t\t\t << \" tiles, \" << tileCache->getMemorySize() << \" MB\" << endl;\n\n \n RawTile newtile = this->getNewTile( resolution, tile, xangle, yangle, layers, ctype );\n\n if( loglevel >= 3 ) *logfile << \"TileManager :: Total Tile Access Time: \"\n\t\t\t\t << tile_timer.getTime() << \" microseconds\" << endl;\n return newtile;\n }\n\n\n\n\n if( loglevel >= 3 ) *logfile << \"TileManager :: Cache Hit for resolution: \" << resolution\n\t\t\t << \", tile: \" << tile\n\t\t\t << \", compression: \" << compName\n\t\t\t << \", quality: \" << compressor->getQuality() << endl\n\t\t\t << \"TileManager :: Cache Size: \"\n\t\t\t << tileCache->getNumElements() << \" tiles, \"\n\t\t\t << tileCache->getMemorySize() << \" MB\" << endl;\n\n\n \/\/ Check whether the compression used for out tile matches our requested compression type. If not, we must convert\n \/\/ Perform JPEG compression iff we have an 8 bit per channel image and either 1 or 3 bands\n \/\/ PNG compression can have 8 or 16 bits and alpha channels\n if( (rawtile->compressionType == UNCOMPRESSED) &&\n ( ( ctype==JPEG && rawtile->bpc==8 && (rawtile->channels==1 || rawtile->channels==3) ) || ctype==PNG ) ){\n\n \/\/ Rawtile is a pointer to the cache data, so we need to create a copy of it in case we compress it\n RawTile ttt( *rawtile );\n\n \/\/ Crop if this is an edge tile\n if( ( (ttt.width != image->getTileWidth()) || (ttt.height != image->getTileHeight()) ) && ttt.padded ){\n if( loglevel >= 5 ) * logfile << \"TileManager :: Cropping tile\" << endl;\n this->crop( &ttt );\n }\n\n if( loglevel >=2 ) compression_timer.start();\n unsigned int oldlen = rawtile->dataLength;\n unsigned int newlen = compressor->Compress( ttt );\n if( loglevel >= 3 ) *logfile << \"TileManager :: \" << compName << \" requested, but UNCOMPRESSED compression found in cache.\" << endl\n\t\t\t\t << \"TileManager :: \" << compName << \" Compression Time: \"\n\t\t\t\t << compression_timer.getTime() << \" microseconds\" << endl\n\t\t\t\t << \"TileManager :: Compression Ratio: \" << newlen << \"\/\" << oldlen << \" = \"\n\t\t\t\t << ( (float)newlen\/(float)oldlen ) << endl;\n\n \/\/ Add our compressed tile to the cache\n if( loglevel >= 3 ) insert_timer.start();\n tileCache->insert( ttt );\n if( loglevel >= 3 ) *logfile << \"TileManager :: Tile cache insertion time: \" << insert_timer.getTime()\n\t\t\t\t << \" microseconds\" << endl;\n\n if( loglevel >= 3 ) *logfile << \"TileManager :: Total Tile Access Time: \"\n\t\t\t\t << tile_timer.getTime() << \" microseconds\" << endl;\n return RawTile( ttt );\n }\n\n if( loglevel >= 3 ) *logfile << \"TileManager :: Total Tile Access Time: \"\n\t\t\t << tile_timer.getTime() << \" microseconds\" << endl;\n\n return RawTile( *rawtile );\n\n\n}","target":0,"code_token_length":1322,"total_token_length":1558,"max_tokens_setting":2048} +{"idx":221680,"func":"WORD32 ih264d_delete_gap_frm_sliding(dpb_manager_t *ps_dpb_mgr,\n WORD32 i4_frame_num,\n UWORD8 *pu1_del_node)\n{\n WORD8 i1_gap_idx, i, j, j_min;\n WORD32 *pi4_gaps_start_frm_num, *pi4_gaps_end_frm_num, i4_gap_frame_num;\n WORD32 i4_start_frm_num, i4_end_frm_num;\n WORD32 i4_max_frm_num;\n WORD32 i4_frm_num, i4_gap_frm_num_min;\n\n \/* find the least frame num from gaps and current DPB node *\/\n \/* Delete the least one *\/\n *pu1_del_node = 1;\n if(0 == ps_dpb_mgr->u1_num_gaps)\n return OK;\n pi4_gaps_start_frm_num = ps_dpb_mgr->ai4_gaps_start_frm_num;\n pi4_gaps_end_frm_num = ps_dpb_mgr->ai4_gaps_end_frm_num;\n i4_gap_frame_num = INVALID_FRAME_NUM;\n i4_max_frm_num = ps_dpb_mgr->i4_max_frm_num;\n\n i1_gap_idx = -1;\n if(INVALID_FRAME_NUM != i4_frame_num)\n {\n i4_gap_frame_num = i4_frame_num;\n for(i = 0; i < MAX_FRAMES; i++)\n {\n i4_start_frm_num = pi4_gaps_start_frm_num[i];\n if(INVALID_FRAME_NUM != i4_start_frm_num)\n {\n i4_end_frm_num = pi4_gaps_end_frm_num[i];\n if(i4_end_frm_num < i4_max_frm_num)\n {\n if(i4_start_frm_num <= i4_gap_frame_num)\n {\n i4_gap_frame_num = i4_start_frm_num;\n i1_gap_idx = i;\n }\n }\n else\n {\n if(((i4_start_frm_num <= i4_gap_frame_num)\n && (i4_gap_frame_num <= i4_max_frm_num))\n || ((i4_start_frm_num >= i4_gap_frame_num)\n && ((i4_gap_frame_num\n + i4_max_frm_num)\n >= i4_end_frm_num)))\n {\n i4_gap_frame_num = i4_start_frm_num;\n i1_gap_idx = i;\n }\n }\n }\n }\n }\n else\n {\n \/* no valid short term buffers, delete one gap from the least start *\/\n \/* of gap sequence *\/\n i4_gap_frame_num = pi4_gaps_start_frm_num[0];\n i1_gap_idx = 0;\n for(i = 1; i < MAX_FRAMES; i++)\n {\n if(INVALID_FRAME_NUM != pi4_gaps_start_frm_num[i])\n {\n if(pi4_gaps_start_frm_num[i] < i4_gap_frame_num)\n {\n i4_gap_frame_num = pi4_gaps_start_frm_num[i];\n i1_gap_idx = i;\n }\n }\n }\n if(INVALID_FRAME_NUM == i4_gap_frame_num)\n {\n UWORD32 i4_error_code;\n i4_error_code = ERROR_DBP_MANAGER_T;\n return i4_error_code;\n }\n }\n\n if(-1 != i1_gap_idx)\n {\n \/* find least frame_num in the poc_map, which is in this range *\/\n i4_start_frm_num = pi4_gaps_start_frm_num[i1_gap_idx];\n if(i4_start_frm_num < 0)\n i4_start_frm_num += i4_max_frm_num;\n i4_end_frm_num = pi4_gaps_end_frm_num[i1_gap_idx];\n if(i4_end_frm_num < 0)\n i4_end_frm_num += i4_max_frm_num;\n\n i4_gap_frm_num_min = 0xfffffff;\n j_min = MAX_FRAMES;\n for(j = 0; j < MAX_FRAMES; j++)\n {\n i4_frm_num = ps_dpb_mgr->ai4_poc_buf_id_map[j][2];\n if((i4_start_frm_num <= i4_frm_num)\n && (i4_end_frm_num >= i4_frm_num))\n {\n if(i4_frm_num < i4_gap_frm_num_min)\n {\n j_min = j;\n i4_gap_frm_num_min = i4_frm_num;\n }\n }\n }\n\n if(j_min != MAX_FRAMES)\n {\n\n ps_dpb_mgr->ai4_poc_buf_id_map[j_min][0] = -1;\n ps_dpb_mgr->ai4_poc_buf_id_map[j_min][1] = 0x7fffffff;\n ps_dpb_mgr->ai4_poc_buf_id_map[j_min][2] = GAP_FRAME_NUM;\n ps_dpb_mgr->i1_gaps_deleted++;\n\n ps_dpb_mgr->ai1_gaps_per_seq[i1_gap_idx]--;\n ps_dpb_mgr->u1_num_gaps--;\n *pu1_del_node = 0;\n if(0 == ps_dpb_mgr->ai1_gaps_per_seq[i1_gap_idx])\n {\n ps_dpb_mgr->ai4_gaps_start_frm_num[i1_gap_idx] =\n INVALID_FRAME_NUM;\n ps_dpb_mgr->ai4_gaps_end_frm_num[i1_gap_idx] = 0;\n }\n }\n }\n\n return OK;\n}\n","target":0,"code_token_length":1091,"total_token_length":1327,"max_tokens_setting":2048} +{"idx":6061,"func":"static void merge_param(HashTable *params, zval *zdata, zval ***current_param, zval ***current_args TSRMLS_DC)\n{\n\tzval **ptr, **zdata_ptr;\n\tphp_http_array_hashkey_t hkey = php_http_array_hashkey_init(0);\n\n#if 0\n\t{\n\t\tzval tmp;\n\t\tINIT_PZVAL_ARRAY(&tmp, params);\n\t\tfprintf(stderr, \"params = \");\n\t\tzend_print_zval_r(&tmp, 1 TSRMLS_CC);\n\t\tfprintf(stderr, \"\\n\");\n\t}\n#endif\n\n\thkey.type = zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata), &hkey.str, &hkey.len, &hkey.num, hkey.dup, NULL);\n\n\tif ((hkey.type == HASH_KEY_IS_STRING && !zend_hash_exists(params, hkey.str, hkey.len))\n\t||\t(hkey.type == HASH_KEY_IS_LONG && !zend_hash_index_exists(params, hkey.num))\n\t) {\n\t\tzval *tmp, *arg, **args;\n\n\t\t\/* create the entry if it doesn't exist *\/\n\t\tzend_hash_get_current_data(Z_ARRVAL_P(zdata), (void *) &ptr);\n\t\tZ_ADDREF_PP(ptr);\n\t\tMAKE_STD_ZVAL(tmp);\n\t\tarray_init(tmp);\n\t\tadd_assoc_zval_ex(tmp, ZEND_STRS(\"value\"), *ptr);\n\n\t\tMAKE_STD_ZVAL(arg);\n\t\tarray_init(arg);\n\t\tzend_hash_update(Z_ARRVAL_P(tmp), \"arguments\", sizeof(\"arguments\"), (void *) &arg, sizeof(zval *), (void *) &args);\n\t\t*current_args = args;\n\n\t\tif (hkey.type == HASH_KEY_IS_STRING) {\n\t\t\tzend_hash_update(params, hkey.str, hkey.len, (void *) &tmp, sizeof(zval *), (void *) &ptr);\n\t\t} else {\n\t\t\tzend_hash_index_update(params, hkey.num, (void *) &tmp, sizeof(zval *), (void *) &ptr);\n\t\t}\n\t} else {\n\t\t\/* merge *\/\n\t\tif (hkey.type == HASH_KEY_IS_STRING) {\n\t\t\tzend_hash_find(params, hkey.str, hkey.len, (void *) &ptr);\n\t\t} else {\n\t\t\tzend_hash_index_find(params, hkey.num, (void *) &ptr);\n\t\t}\n\n\t\tzdata_ptr = &zdata;\n\n\t\tif (Z_TYPE_PP(ptr) == IS_ARRAY\n\t\t&&\tSUCCESS == zend_hash_find(Z_ARRVAL_PP(ptr), \"value\", sizeof(\"value\"), (void *) &ptr)\n\t\t&&\tSUCCESS == zend_hash_get_current_data(Z_ARRVAL_PP(zdata_ptr), (void *) &zdata_ptr)\n\t\t) {\n\t\t\t\/*\n\t\t\t * params = [arr => [value => [0 => 1]]]\n\t\t\t * ^- ptr\n\t\t\t * zdata = [arr => [0 => NULL]]\n\t\t\t * ^- zdata_ptr\n\t\t\t *\/\n\t\t\tzval **test_ptr;\n\n\t\t\twhile (Z_TYPE_PP(zdata_ptr) == IS_ARRAY\n\t\t\t&&\tSUCCESS == zend_hash_get_current_data(Z_ARRVAL_PP(zdata_ptr), (void *) &test_ptr)\n\t\t\t) {\n\t\t\t\tif (Z_TYPE_PP(test_ptr) == IS_ARRAY) {\n\n\t\t\t\t\t\/* now find key in ptr *\/\n\t\t\t\t\tif (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_PP(zdata_ptr), &hkey.str, &hkey.len, &hkey.num, hkey.dup, NULL)) {\n\t\t\t\t\t\tif (SUCCESS == zend_hash_find(Z_ARRVAL_PP(ptr), hkey.str, hkey.len, (void *) &ptr)) {\n\t\t\t\t\t\t\tzdata_ptr = test_ptr;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tZ_ADDREF_PP(test_ptr);\n\t\t\t\t\t\t\tzend_hash_update(Z_ARRVAL_PP(ptr), hkey.str, hkey.len, (void *) test_ptr, sizeof(zval *), (void *) &ptr);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(ptr), hkey.num, (void *) &ptr)) {\n\t\t\t\t\t\t\tzdata_ptr = test_ptr;\n\t\t\t\t\t\t} else if (hkey.num) {\n\t\t\t\t\t\t\tZ_ADDREF_PP(test_ptr);\n\t\t\t\t\t\t\tzend_hash_index_update(Z_ARRVAL_PP(ptr), hkey.num, (void *) test_ptr, sizeof(zval *), (void *) &ptr);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tZ_ADDREF_PP(test_ptr);\n\t\t\t\t\t\t\tzend_hash_next_index_insert(Z_ARRVAL_PP(ptr), (void *) test_ptr, sizeof(zval *), (void *) &ptr);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t\/* this is the leaf *\/\n\t\t\t\t\tZ_ADDREF_PP(test_ptr);\n\t\t\t\t\tif (Z_TYPE_PP(ptr) != IS_ARRAY) {\n\t\t\t\t\t\tzval_dtor(*ptr);\n\t\t\t\t\t\tarray_init(*ptr);\n\t\t\t\t\t}\n\t\t\t\t\tif (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_PP(zdata_ptr), &hkey.str, &hkey.len, &hkey.num, hkey.dup, NULL)) {\n\t\t\t\t\t\tzend_hash_update(Z_ARRVAL_PP(ptr), hkey.str, hkey.len, (void *) test_ptr, sizeof(zval *), (void *) &ptr);\n\t\t\t\t\t} else if (hkey.num) {\n\t\t\t\t\t\tzend_hash_index_update(Z_ARRVAL_PP(ptr), hkey.num, (void *) test_ptr, sizeof(zval *), (void *) &ptr);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_hash_next_index_insert(Z_ARRVAL_PP(ptr), (void *) test_ptr, sizeof(zval *), (void *) &ptr);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n\n\t\/* bubble up *\/\n\twhile (Z_TYPE_PP(ptr) == IS_ARRAY && SUCCESS == zend_hash_get_current_data(Z_ARRVAL_PP(ptr), (void *) &ptr));\n\t*current_param = ptr;\n}","target":1,"code_token_length":1251,"total_token_length":1487,"max_tokens_setting":2048} +{"idx":9907,"func":"static void JNI_WebApkUpdateManager_StoreWebApkUpdateRequestToFile(\n JNIEnv* env,\n const JavaParamRef& java_update_request_path,\n const JavaParamRef& java_start_url,\n const JavaParamRef& java_scope,\n const JavaParamRef& java_name,\n const JavaParamRef& java_short_name,\n const JavaParamRef& java_primary_icon_url,\n const JavaParamRef& java_primary_icon_bitmap,\n const JavaParamRef& java_badge_icon_url,\n const JavaParamRef& java_badge_icon_bitmap,\n const JavaParamRef& java_icon_urls,\n const JavaParamRef& java_icon_hashes,\n jint java_display_mode,\n jint java_orientation,\n jlong java_theme_color,\n jlong java_background_color,\n const JavaParamRef& java_web_manifest_url,\n const JavaParamRef& java_webapk_package,\n jint java_webapk_version,\n jboolean java_is_manifest_stale,\n jint java_update_reason,\n const JavaParamRef& java_callback) {\n DCHECK_CURRENTLY_ON(content::BrowserThread::UI);\n\n std::string update_request_path =\n ConvertJavaStringToUTF8(env, java_update_request_path);\n\n ShortcutInfo info(GURL(ConvertJavaStringToUTF8(env, java_start_url)));\n info.scope = GURL(ConvertJavaStringToUTF8(env, java_scope));\n info.name = ConvertJavaStringToUTF16(env, java_name);\n info.short_name = ConvertJavaStringToUTF16(env, java_short_name);\n info.user_title = info.short_name;\n info.display = static_cast(java_display_mode);\n info.orientation =\n static_cast(java_orientation);\n info.theme_color = (int64_t)java_theme_color;\n info.background_color = (int64_t)java_background_color;\n info.best_primary_icon_url =\n GURL(ConvertJavaStringToUTF8(env, java_primary_icon_url));\n info.best_badge_icon_url =\n GURL(ConvertJavaStringToUTF8(env, java_badge_icon_url));\n info.manifest_url = GURL(ConvertJavaStringToUTF8(env, java_web_manifest_url));\n \n base::android::AppendJavaStringArrayToStringVector(env, java_icon_urls,\n &info.icon_urls);\n \n std::vector icon_hashes;\n base::android::AppendJavaStringArrayToStringVector(env, java_icon_hashes,\n &icon_hashes);\n\n std::map icon_url_to_murmur2_hash;\n for (size_t i = 0; i < info.icon_urls.size(); ++i)\n icon_url_to_murmur2_hash[info.icon_urls[i]] = icon_hashes[i];\n\n gfx::JavaBitmap java_primary_icon_bitmap_lock(java_primary_icon_bitmap);\n SkBitmap primary_icon =\n gfx::CreateSkBitmapFromJavaBitmap(java_primary_icon_bitmap_lock);\n primary_icon.setImmutable();\n\n SkBitmap badge_icon;\n if (!java_badge_icon_bitmap.is_null()) {\n gfx::JavaBitmap java_badge_icon_bitmap_lock(java_badge_icon_bitmap);\n gfx::CreateSkBitmapFromJavaBitmap(java_badge_icon_bitmap_lock);\n badge_icon.setImmutable();\n }\n\n std::string webapk_package;\n ConvertJavaStringToUTF8(env, java_webapk_package, &webapk_package);\n\n WebApkUpdateReason update_reason =\n static_cast(java_update_reason);\n\n WebApkInstaller::StoreUpdateRequestToFile(\n base::FilePath(update_request_path), info, primary_icon, badge_icon,\n webapk_package, std::to_string(java_webapk_version),\n icon_url_to_murmur2_hash, java_is_manifest_stale, update_reason,\n base::BindOnce(&base::android::RunBooleanCallbackAndroid,\n ScopedJavaGlobalRef(java_callback)));\n}\n","target":1,"code_token_length":844,"total_token_length":1080,"max_tokens_setting":2048} +{"idx":496378,"func":"CURLcode Curl_ossl_verifyhost(struct Curl_easy *data, struct connectdata *conn,\n X509 *server_cert)\n{\n bool matched = FALSE;\n int target = GEN_DNS; \/* target type, GEN_DNS or GEN_IPADD *\/\n size_t addrlen = 0;\n STACK_OF(GENERAL_NAME) *altnames;\n#ifdef ENABLE_IPV6\n struct in6_addr addr;\n#else\n struct in_addr addr;\n#endif\n CURLcode result = CURLE_OK;\n bool dNSName = FALSE; \/* if a dNSName field exists in the cert *\/\n bool iPAddress = FALSE; \/* if a iPAddress field exists in the cert *\/\n const char * const hostname = SSL_HOST_NAME();\n const char * const dispname = SSL_HOST_DISPNAME();\n size_t hostlen = strlen(hostname);\n\n#ifdef ENABLE_IPV6\n if(conn->bits.ipv6_ip &&\n Curl_inet_pton(AF_INET6, hostname, &addr)) {\n target = GEN_IPADD;\n addrlen = sizeof(struct in6_addr);\n }\n else\n#endif\n if(Curl_inet_pton(AF_INET, hostname, &addr)) {\n target = GEN_IPADD;\n addrlen = sizeof(struct in_addr);\n }\n\n \/* get a \"list\" of alternative names *\/\n altnames = X509_get_ext_d2i(server_cert, NID_subject_alt_name, NULL, NULL);\n\n if(altnames) {\n#ifdef OPENSSL_IS_BORINGSSL\n size_t numalts;\n size_t i;\n#else\n int numalts;\n int i;\n#endif\n bool dnsmatched = FALSE;\n bool ipmatched = FALSE;\n\n \/* get amount of alternatives, RFC2459 claims there MUST be at least\n one, but we don't depend on it... *\/\n numalts = sk_GENERAL_NAME_num(altnames);\n\n \/* loop through all alternatives - until a dnsmatch *\/\n for(i = 0; (i < numalts) && !dnsmatched; i++) {\n \/* get a handle to alternative name number i *\/\n const GENERAL_NAME *check = sk_GENERAL_NAME_value(altnames, i);\n\n if(check->type == GEN_DNS)\n dNSName = TRUE;\n else if(check->type == GEN_IPADD)\n iPAddress = TRUE;\n\n \/* only check alternatives of the same type the target is *\/\n if(check->type == target) {\n \/* get data and length *\/\n const char *altptr = (char *)ASN1_STRING_get0_data(check->d.ia5);\n size_t altlen = (size_t) ASN1_STRING_length(check->d.ia5);\n\n switch(target) {\n case GEN_DNS: \/* name\/pattern comparison *\/\n \/* The OpenSSL man page explicitly says: \"In general it cannot be\n assumed that the data returned by ASN1_STRING_data() is null\n terminated or does not contain embedded nulls.\" But also that\n \"The actual format of the data will depend on the actual string\n type itself: for example for an IA5String the data will be ASCII\"\n\n It has been however verified that in 0.9.6 and 0.9.7, IA5String\n is always null-terminated.\n *\/\n if((altlen == strlen(altptr)) &&\n \/* if this isn't true, there was an embedded zero in the name\n string and we cannot match it. *\/\n subj_alt_hostcheck(data,\n altptr,\n altlen, hostname, hostlen, dispname)) {\n dnsmatched = TRUE;\n }\n break;\n\n case GEN_IPADD: \/* IP address comparison *\/\n \/* compare alternative IP address if the data chunk is the same size\n our server IP address is *\/\n if((altlen == addrlen) && !memcmp(altptr, &addr, altlen)) {\n ipmatched = TRUE;\n infof(data,\n \" subjectAltName: host \\\"%s\\\" matched cert's IP address!\",\n dispname);\n }\n break;\n }\n }\n }\n GENERAL_NAMES_free(altnames);\n\n if(dnsmatched || ipmatched)\n matched = TRUE;\n }\n\n if(matched)\n \/* an alternative name matched *\/\n ;\n else if(dNSName || iPAddress) {\n infof(data, \" subjectAltName does not match %s\", dispname);\n failf(data, \"SSL: no alternative certificate subject name matches \"\n \"target host name '%s'\", dispname);\n result = CURLE_PEER_FAILED_VERIFICATION;\n }\n else {\n \/* we have to look to the last occurrence of a commonName in the\n distinguished one to get the most significant one. *\/\n int i = -1;\n unsigned char *peer_CN = NULL;\n int peerlen = 0;\n\n \/* The following is done because of a bug in 0.9.6b *\/\n X509_NAME *name = X509_get_subject_name(server_cert);\n if(name) {\n int j;\n while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i)) >= 0)\n i = j;\n }\n\n \/* we have the name entry and we will now convert this to a string\n that we can use for comparison. Doing this we support BMPstring,\n UTF8, etc. *\/\n\n if(i >= 0) {\n ASN1_STRING *tmp =\n X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i));\n\n \/* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input\n is already UTF-8 encoded. We check for this case and copy the raw\n string manually to avoid the problem. This code can be made\n conditional in the future when OpenSSL has been fixed. *\/\n if(tmp) {\n if(ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {\n peerlen = ASN1_STRING_length(tmp);\n if(peerlen >= 0) {\n peer_CN = OPENSSL_malloc(peerlen + 1);\n if(peer_CN) {\n memcpy(peer_CN, ASN1_STRING_get0_data(tmp), peerlen);\n peer_CN[peerlen] = '\\0';\n }\n else\n result = CURLE_OUT_OF_MEMORY;\n }\n }\n else \/* not a UTF8 name *\/\n peerlen = ASN1_STRING_to_UTF8(&peer_CN, tmp);\n\n if(peer_CN && (curlx_uztosi(strlen((char *)peer_CN)) != peerlen)) {\n \/* there was a terminating zero before the end of string, this\n cannot match and we return failure! *\/\n failf(data, \"SSL: illegal cert name field\");\n result = CURLE_PEER_FAILED_VERIFICATION;\n }\n }\n }\n\n if(result)\n \/* error already detected, pass through *\/\n ;\n else if(!peer_CN) {\n failf(data,\n \"SSL: unable to obtain common name from peer certificate\");\n result = CURLE_PEER_FAILED_VERIFICATION;\n }\n else if(!Curl_cert_hostcheck((const char *)peer_CN,\n peerlen, hostname, hostlen)) {\n failf(data, \"SSL: certificate subject name '%s' does not match \"\n \"target host name '%s'\", peer_CN, dispname);\n result = CURLE_PEER_FAILED_VERIFICATION;\n }\n else {\n infof(data, \" common name: %s (matched)\", peer_CN);\n }\n if(peer_CN)\n OPENSSL_free(peer_CN);\n }\n\n return result;\n}","target":0,"code_token_length":1641,"total_token_length":1877,"max_tokens_setting":2048} +{"idx":490852,"func":"static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, int remote_argc,\n\t\t int *f_in_p, int *f_out_p)\n{\n\tint i, argc = 0;\n\tchar *args[MAX_ARGS], *need_to_free = NULL;\n\tpid_t pid;\n\tint dash_l_set = 0;\n\n\tif (!read_batch && !local_server) {\n\t\tchar *t, *f, in_quote = '\\0';\n\t\tchar *rsh_env = getenv(RSYNC_RSH_ENV);\n\t\tif (!cmd)\n\t\t\tcmd = rsh_env;\n\t\tif (!cmd)\n\t\t\tcmd = RSYNC_RSH;\n\t\tcmd = need_to_free = strdup(cmd);\n\n\t\tfor (t = f = cmd; *f; f++) {\n\t\t\tif (*f == ' ')\n\t\t\t\tcontinue;\n\t\t\t\/* Comparison leaves rooms for server_options(). *\/\n\t\t\tif (argc >= MAX_ARGS - MAX_SERVER_ARGS)\n\t\t\t\tgoto arg_overflow;\n\t\t\targs[argc++] = t;\n\t\t\twhile (*f != ' ' || in_quote) {\n\t\t\t\tif (!*f) {\n\t\t\t\t\tif (in_quote) {\n\t\t\t\t\t\trprintf(FERROR,\n\t\t\t\t\t\t\t\"Missing trailing-%c in remote-shell command.\\n\",\n\t\t\t\t\t\t\tin_quote);\n\t\t\t\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t\t\t\t}\n\t\t\t\t\tf--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (*f == '\\'' || *f == '\"') {\n\t\t\t\t\tif (!in_quote) {\n\t\t\t\t\t\tin_quote = *f++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (*f == in_quote && *++f != in_quote) {\n\t\t\t\t\t\tin_quote = '\\0';\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t*t++ = *f++;\n\t\t\t}\n\t\t\t*t++ = '\\0';\n\t\t}\n\n\t\t\/* NOTE: must preserve t == start of command name until the end of the args handling! *\/\n\t\tif ((t = strrchr(cmd, '\/')) != NULL)\n\t\t\tt++;\n\t\telse\n\t\t\tt = cmd;\n\n\t\t\/* Check to see if we've already been given '-l user' in the remote-shell command. *\/\n\t\tfor (i = 0; i < argc-1; i++) {\n\t\t\tif (!strcmp(args[i], \"-l\") && args[i+1][0] != '-')\n\t\t\t\tdash_l_set = 1;\n\t\t}\n\n#ifdef HAVE_REMSH\n\t\t\/* remsh (on HPUX) takes the arguments the other way around *\/\n\t\targs[argc++] = machine;\n\t\tif (user && !(daemon_connection && dash_l_set)) {\n\t\t\targs[argc++] = \"-l\";\n\t\t\targs[argc++] = user;\n\t\t}\n#else\n\t\tif (user && !(daemon_connection && dash_l_set)) {\n\t\t\targs[argc++] = \"-l\";\n\t\t\targs[argc++] = user;\n\t\t}\n#ifdef AF_INET\n\t\tif (default_af_hint == AF_INET && strcmp(t, \"ssh\") == 0)\n\t\t\targs[argc++] = \"-4\"; \/* we're using ssh so we can add a -4 option *\/\n#endif\n#ifdef AF_INET6\n\t\tif (default_af_hint == AF_INET6 && strcmp(t, \"ssh\") == 0)\n\t\t\targs[argc++] = \"-6\"; \/* we're using ssh so we can add a -6 option *\/\n#endif\n\t\targs[argc++] = machine;\n#endif\n\n\t\targs[argc++] = rsync_path;\n\n\t\tif (blocking_io < 0 && (strcmp(t, \"rsh\") == 0 || strcmp(t, \"remsh\") == 0))\n\t\t\tblocking_io = 1;\n\n\t\tif (daemon_connection > 0) {\n\t\t\targs[argc++] = \"--server\";\n\t\t\targs[argc++] = \"--daemon\";\n\t\t} else\n\t\t\tserver_options(args, &argc);\n\n\t\tif (argc >= MAX_ARGS - 2)\n\t\t\tgoto arg_overflow;\n\t}\n\n\targs[argc++] = \".\";\n\n\tif (!daemon_connection) {\n\t\twhile (remote_argc > 0) {\n\t\t\tif (argc >= MAX_ARGS - 1) {\n\t\t\t arg_overflow:\n\t\t\t\trprintf(FERROR, \"internal: args[] overflowed in do_cmd()\\n\");\n\t\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t\t}\n\t\t\targs[argc++] = safe_arg(NULL, *remote_argv++);\n\t\t\tremote_argc--;\n\t\t}\n\t}\n\n\targs[argc] = NULL;\n\n\tif (DEBUG_GTE(CMD, 2)) {\n\t\tfor (i = 0; i < argc; i++)\n\t\t\trprintf(FCLIENT, \"cmd[%d]=%s \", i, args[i]);\n\t\trprintf(FCLIENT, \"\\n\");\n\t}\n\n\tif (read_batch) {\n\t\tint from_gen_pipe[2];\n\t\tset_allow_inc_recurse();\n\t\tif (fd_pair(from_gen_pipe) < 0) {\n\t\t\trsyserr(FERROR, errno, \"pipe\");\n\t\t\texit_cleanup(RERR_IPC);\n\t\t}\n\t\tbatch_gen_fd = from_gen_pipe[0];\n\t\t*f_out_p = from_gen_pipe[1];\n\t\t*f_in_p = batch_fd;\n\t\tpid = (pid_t)-1; \/* no child pid *\/\n#ifdef ICONV_CONST\n\t\tsetup_iconv();\n#endif\n\t\ttrust_sender_filter = 1;\n\t} else if (local_server) {\n\t\t\/* If the user didn't request --[no-]whole-file, force\n\t\t * it on, but only if we're not batch processing. *\/\n\t\tif (whole_file < 0 && !write_batch)\n\t\t\twhole_file = 1;\n\t\tset_allow_inc_recurse();\n\t\tpid = local_child(argc, args, f_in_p, f_out_p, child_main);\n#ifdef ICONV_CONST\n\t\tsetup_iconv();\n#endif\n\t} else {\n\t\tpid = piped_child(args, f_in_p, f_out_p);\n#ifdef ICONV_CONST\n\t\tsetup_iconv();\n#endif\n\t\tif (protect_args && !daemon_connection)\n\t\t\tsend_protected_args(*f_out_p, args);\n\t}\n\n\tif (need_to_free)\n\t\tfree(need_to_free);\n\n\treturn pid;\n}","target":0,"code_token_length":1268,"total_token_length":1504,"max_tokens_setting":2048} +{"idx":376759,"func":"void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) {\n ASSERT(!HasStackOverflow());\n ASSERT(current_block() != NULL);\n ASSERT(current_block()->HasPredecessor());\n if (IsClassOfTest(expr)) {\n CallRuntime* call = expr->left()->AsCallRuntime();\n ASSERT(call->arguments()->length() == 1);\n CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));\n HValue* value = Pop();\n Literal* literal = expr->right()->AsLiteral();\n Handle rhs = Handle::cast(literal->handle());\n HClassOfTestAndBranch* instr =\n new(zone()) HClassOfTestAndBranch(value, rhs);\n instr->set_position(expr->position());\n return ast_context()->ReturnControl(instr, expr->id());\n }\n\n TypeInfo type_info = oracle()->CompareType(expr);\n \/\/ Check if this expression was ever executed according to type feedback.\n \/\/ Note that for the special typeof\/null\/undefined cases we get unknown here.\n if (type_info.IsUninitialized()) {\n AddInstruction(new(zone()) HSoftDeoptimize);\n current_block()->MarkAsDeoptimizing();\n type_info = TypeInfo::Unknown();\n }\n\n CHECK_ALIVE(VisitForValue(expr->left()));\n CHECK_ALIVE(VisitForValue(expr->right()));\n\n HValue* context = environment()->LookupContext();\n HValue* right = Pop();\n HValue* left = Pop();\n Token::Value op = expr->op();\n\n HTypeof* typeof_expr = NULL;\n Handle check;\n if (IsLiteralCompareTypeof(left, op, right, &typeof_expr, &check)) {\n return HandleLiteralCompareTypeof(expr, typeof_expr, check);\n }\n HValue* sub_expr = NULL;\n Factory* f = graph()->isolate()->factory();\n if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) {\n return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);\n }\n if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) {\n return HandleLiteralCompareNil(expr, sub_expr, kNullValue);\n }\n if (IsLiteralCompareBool(left, op, right)) {\n HCompareObjectEqAndBranch* result =\n new(zone()) HCompareObjectEqAndBranch(left, right);\n result->set_position(expr->position());\n return ast_context()->ReturnControl(result, expr->id());\n }\n\n if (op == Token::INSTANCEOF) {\n \/\/ Check to see if the rhs of the instanceof is a global function not\n \/\/ residing in new space. If it is we assume that the function will stay the\n \/\/ same.\n Handle target = Handle::null();\n VariableProxy* proxy = expr->right()->AsVariableProxy();\n bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated();\n if (global_function &&\n info()->has_global_object() &&\n !info()->global_object()->IsAccessCheckNeeded()) {\n Handle name = proxy->name();\n Handle global(info()->global_object());\n LookupResult lookup(isolate());\n global->Lookup(*name, &lookup);\n if (lookup.IsNormal() && lookup.GetValue()->IsJSFunction()) {\n Handle candidate(JSFunction::cast(lookup.GetValue()));\n \/\/ If the function is in new space we assume it's more likely to\n \/\/ change and thus prefer the general IC code.\n if (!isolate()->heap()->InNewSpace(*candidate)) {\n target = candidate;\n }\n }\n }\n\n \/\/ If the target is not null we have found a known global function that is\n \/\/ assumed to stay the same for this instanceof.\n if (target.is_null()) {\n HInstanceOf* result = new(zone()) HInstanceOf(context, left, right);\n result->set_position(expr->position());\n return ast_context()->ReturnInstruction(result, expr->id());\n } else {\n AddInstruction(new(zone()) HCheckFunction(right, target));\n HInstanceOfKnownGlobal* result =\n new(zone()) HInstanceOfKnownGlobal(context, left, target);\n result->set_position(expr->position());\n return ast_context()->ReturnInstruction(result, expr->id());\n }\n } else if (op == Token::IN) {\n HIn* result = new(zone()) HIn(context, left, right);\n result->set_position(expr->position());\n return ast_context()->ReturnInstruction(result, expr->id());\n } else if (type_info.IsNonPrimitive()) {\n switch (op) {\n case Token::EQ:\n case Token::EQ_STRICT: {\n \/\/ Can we get away with map check and not instance type check?\n Handle map = oracle()->GetCompareMap(expr);\n if (!map.is_null()) {\n AddInstruction(new(zone()) HCheckNonSmi(left));\n AddInstruction(HCheckMaps::NewWithTransitions(left, map, zone()));\n AddInstruction(new(zone()) HCheckNonSmi(right));\n AddInstruction(HCheckMaps::NewWithTransitions(right, map, zone()));\n HCompareObjectEqAndBranch* result =\n new(zone()) HCompareObjectEqAndBranch(left, right);\n result->set_position(expr->position());\n return ast_context()->ReturnControl(result, expr->id());\n } else {\n AddInstruction(new(zone()) HCheckNonSmi(left));\n AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone()));\n AddInstruction(new(zone()) HCheckNonSmi(right));\n AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone()));\n HCompareObjectEqAndBranch* result =\n new(zone()) HCompareObjectEqAndBranch(left, right);\n result->set_position(expr->position());\n return ast_context()->ReturnControl(result, expr->id());\n }\n }\n default:\n return Bailout(\"Unsupported non-primitive compare\");\n }\n } else if (type_info.IsString() && oracle()->IsSymbolCompare(expr) &&\n (op == Token::EQ || op == Token::EQ_STRICT)) {\n AddInstruction(new(zone()) HCheckNonSmi(left));\n AddInstruction(HCheckInstanceType::NewIsSymbol(left, zone()));\n AddInstruction(new(zone()) HCheckNonSmi(right));\n AddInstruction(HCheckInstanceType::NewIsSymbol(right, zone()));\n HCompareObjectEqAndBranch* result =\n new(zone()) HCompareObjectEqAndBranch(left, right);\n result->set_position(expr->position());\n return ast_context()->ReturnControl(result, expr->id());\n } else {\n Representation r = ToRepresentation(type_info);\n if (r.IsTagged()) {\n HCompareGeneric* result =\n new(zone()) HCompareGeneric(context, left, right, op);\n result->set_position(expr->position());\n return ast_context()->ReturnInstruction(result, expr->id());\n } else {\n HCompareIDAndBranch* result =\n new(zone()) HCompareIDAndBranch(left, right, op);\n result->set_position(expr->position());\n result->SetInputRepresentation(r);\n return ast_context()->ReturnControl(result, expr->id());\n }\n }\n}","target":0,"code_token_length":1545,"total_token_length":1781,"max_tokens_setting":2048} +{"idx":416616,"func":"int gx_device_unsubclass(gx_device *dev)\n{\n generic_subclass_data *psubclass_data;\n gx_device *parent, *child;\n gs_memory_struct_type_t *a_std = 0, *b_std = 0;\n int dynamic, ref_count;\n\n \/* This should not happen... *\/\n if (!dev)\n return 0;\n\n ref_count = dev->rc.ref_count;\n child = dev->child;\n psubclass_data = (generic_subclass_data *)dev->subclass_data;\n parent = dev->parent;\n dynamic = dev->stype_is_dynamic;\n\n \/* We need to account for the fact that we are removing ourselves from\n * the device chain after a clist device has been pushed, due to a\n * compositor action. Since we patched the clist 'create_compositor'\n * method (and target device) when it was pushed.\n * A point to note; we *don't* want to change the forwarding device's\n * 'target', because when we copy the child up to replace 'this' device\n * we do still want the forwarding device to point here. NB its the *child*\n * device that goes away.\n *\/\n if (psubclass_data != NULL && psubclass_data->forwarding_dev != NULL && psubclass_data->saved_compositor_method)\n psubclass_data->forwarding_dev->procs.create_compositor = psubclass_data->saved_compositor_method;\n\n \/* If ths device's stype is dynamically allocated, keep a copy of it\n * in case we might need it.\n *\/\n if (dynamic) {\n a_std = (gs_memory_struct_type_t *)dev->stype;\n if (child)\n *a_std = *child->stype;\n }\n\n \/* If ths device has any private storage, free it now *\/\n if (psubclass_data)\n gs_free_object(dev->memory->non_gc_memory, psubclass_data, \"subclass memory for first-last page\");\n\n \/* Copy the child device into ths device's memory *\/\n if (child) {\n b_std = (gs_memory_struct_type_t *)dev->stype;\n rc_decrement(dev->icc_struct, \"unsubclass device\");\n rc_increment(child->icc_struct);\n memcpy(dev, child, child->stype->ssize);\n \/* Patch back the 'stype' in the memory manager *\/\n gs_set_object_type(child->memory, dev, b_std);\n\n dev->stype = b_std;\n \/* The reference count of the subclassing device may have been changed\n * (eg graphics states pointing to it) after we subclassed the device. We\n * need to ensure that we do not overwrite this when we copy back the subclassed\n * device.\n *\/\n dev->rc.ref_count = ref_count;\n\n \/* If we have a chain of devices, make sure the chain beond the device we're unsubclassing\n * doesn't get broken, we needd to detach the lower chain and reattach it at the new\n * highest level\n *\/\n if (child->child)\n child->child->parent = dev;\n child->parent->child = child->child;\n }\n\n \/* How can we have a subclass device with no child ? Simples; when we hit the end of job\n * restore, the devices are not freed in device chain order. To make sure we don't end up\n * following stale pointers, when a device is freed we remove it from the chain and update\n * any danlging poitners to NULL. When we later free the remaining devices its possible that\n * their child pointer can then be NULL.\n *\/\n if (child) {\n if (child->icc_struct)\n rc_decrement(child->icc_struct, \"gx_unsubclass_device, icc_struct\");\n if (child->PageList)\n rc_decrement(child->PageList, \"gx_unsubclass_device, PageList\");\n \/* we cannot afford to free the child device if its stype is not dynamic because\n * we can't 'null' the finalise routine, and we cannot permit the device to be finalised\n * because we have copied it up one level, not discarded it.\n * (this shouldn't happen! Child devices are always created with a dynamic stype)\n * If this ever happens garbage collecton will eventually clean up the memory.\n *\/\n if (child->stype_is_dynamic) {\n \/* Make sure that nothing will tyr to follow the device chain, just security here *\/\n child->parent = NULL;\n child->child = NULL;\n \/* Make certainthe memory will be freed, zap the reference count *\/\n child->rc.ref_count = 0;\n \/* We *don't* want to run the finalize routine. This would free the stype and\n * properly handle the icc_struct and PageList, but for devices with a custom\n * finalize (eg psdcmyk) it might also free memory it had allocated, and we're\n * still pointing at that memory in the parent.\n * The indirection through a variable is just to get rid of const warnings.\n *\/\n b_std = (gs_memory_struct_type_t *)child->stype;\n b_std->finalize = NULL;\n \/* Having patched the stype, we need to make sure the memory manager uses it.\n * It keeps a copy in its own data structure, and would use that copy, which would\n * mean it would call the finalize routine that we just patched out.\n *\/\n gs_set_object_type(dev->memory->stable_memory, child, b_std);\n \/* Now (finally) free the child memory *\/\n gs_free_object(dev->memory->stable_memory, child, \"gx_unsubclass_device(device)\");\n \/* And the stype for it *\/\n gs_free_const_object(dev->memory->non_gc_memory, b_std, \"gs_device_unsubclass(stype)\");\n child = 0;\n }\n }\n if(child)\n child->parent = dev;\n dev->parent = parent;\n\n \/* If this device has a dynamic stype, we wnt to keep using it, but we copied\n * the stype pointer from the child when we copied the rest of the device. So\n * we update the stype pointer with the saved pointer to this device's stype.\n *\/\n if (dynamic) {\n dev->stype = a_std;\n dev->stype_is_dynamic = 1;\n } else {\n dev->stype_is_dynamic = 0;\n }\n\n return 0;\n}","target":0,"code_token_length":1396,"total_token_length":1632,"max_tokens_setting":2048} +{"idx":5664,"func":"static int read_data(void *opaque, uint8_t *buf, int buf_size)\n{\n struct playlist *v = opaque;\n HLSContext *c = v->parent->priv_data;\n int ret, i;\n int just_opened = 0;\n\nrestart:\n if (!v->needed)\n return AVERROR_EOF;\n\n if (!v->input) {\n int64_t reload_interval;\n struct segment *seg;\n\n \/* Check that the playlist is still needed before opening a new\n * segment. *\/\n if (v->ctx && v->ctx->nb_streams) {\n v->needed = 0;\n for (i = 0; i < v->n_main_streams; i++) {\n if (v->main_streams[i]->discard < AVDISCARD_ALL) {\n v->needed = 1;\n break;\n }\n }\n }\n if (!v->needed) {\n av_log(v->parent, AV_LOG_INFO, \"No longer receiving playlist %d\\n\",\n v->index);\n return AVERROR_EOF;\n }\n\n \/* If this is a live stream and the reload interval has elapsed since\n * the last playlist reload, reload the playlists now. *\/\n reload_interval = default_reload_interval(v);\n\nreload:\n if (!v->finished &&\n av_gettime_relative() - v->last_load_time >= reload_interval) {\n if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) {\n av_log(v->parent, AV_LOG_WARNING, \"Failed to reload playlist %d\\n\",\n v->index);\n return ret;\n }\n \/* If we need to reload the playlist again below (if\n * there's still no more segments), switch to a reload\n * interval of half the target duration. *\/\n reload_interval = v->target_duration \/ 2;\n }\n if (v->cur_seq_no < v->start_seq_no) {\n av_log(NULL, AV_LOG_WARNING,\n \"skipping %d segments ahead, expired from playlists\\n\",\n v->start_seq_no - v->cur_seq_no);\n v->cur_seq_no = v->start_seq_no;\n }\n if (v->cur_seq_no >= v->start_seq_no + v->n_segments) {\n if (v->finished)\n return AVERROR_EOF;\n while (av_gettime_relative() - v->last_load_time < reload_interval) {\n if (ff_check_interrupt(c->interrupt_callback))\n return AVERROR_EXIT;\n av_usleep(100*1000);\n }\n \/* Enough time has elapsed since the last reload *\/\n goto reload;\n }\n\n seg = current_segment(v);\n\n \/* load\/update Media Initialization Section, if any *\/\n ret = update_init_section(v, seg);\n if (ret)\n return ret;\n\n ret = open_input(c, v, seg);\n if (ret < 0) {\n if (ff_check_interrupt(c->interrupt_callback))\n return AVERROR_EXIT;\n av_log(v->parent, AV_LOG_WARNING, \"Failed to open segment of playlist %d\\n\",\n v->index);\n v->cur_seq_no += 1;\n goto reload;\n }\n just_opened = 1;\n }\n\n if (v->init_sec_buf_read_offset < v->init_sec_data_len) {\n \/* Push init section out first before first actual segment *\/\n int copy_size = FFMIN(v->init_sec_data_len - v->init_sec_buf_read_offset, buf_size);\n memcpy(buf, v->init_sec_buf, copy_size);\n v->init_sec_buf_read_offset += copy_size;\n return copy_size;\n }\n\n ret = read_from_url(v, current_segment(v), buf, buf_size, READ_NORMAL);\n if (ret > 0) {\n if (just_opened && v->is_id3_timestamped != 0) {\n \/* Intercept ID3 tags here, elementary audio streams are required\n * to convey timestamps using them in the beginning of each segment. *\/\n intercept_id3(v, buf, buf_size, &ret);\n }\n\n return ret;\n }\n ff_format_io_close(v->parent, &v->input);\n v->cur_seq_no++;\n\n c->cur_seq_no = v->cur_seq_no;\n\n goto restart;\n}","target":1,"code_token_length":918,"total_token_length":1154,"max_tokens_setting":2048} +{"idx":68088,"func":"sampled_guards_update_from_consensus(guard_selection_t *gs)\n{\n tor_assert(gs);\n const int REMOVE_UNLISTED_GUARDS_AFTER =\n (get_remove_unlisted_guards_after_days() * 86400);\n const int unlisted_since_slop = REMOVE_UNLISTED_GUARDS_AFTER \/ 5;\n\n \/\/ It's important to use only a live consensus here; we don't want to\n \/\/ make changes based on anything expired or old.\n if (live_consensus_is_missing(gs)) {\n log_info(LD_GUARD, \"Not updating the sample guard set; we have \"\n \"no live consensus.\");\n return;\n }\n log_info(LD_GUARD, \"Updating sampled guard status based on received \"\n \"consensus.\");\n\n int n_changes = 0;\n\n \/* First: Update listed\/unlisted. *\/\n SMARTLIST_FOREACH_BEGIN(gs->sampled_entry_guards, entry_guard_t *, guard) {\n \/* XXXX #20827 check ed ID too *\/\n const int is_listed = entry_guard_is_listed(gs, guard);\n\n if (is_listed && ! guard->currently_listed) {\n ++n_changes;\n guard->currently_listed = 1;\n guard->unlisted_since_date = 0;\n log_info(LD_GUARD, \"Sampled guard %s is now listed again.\",\n entry_guard_describe(guard));\n } else if (!is_listed && guard->currently_listed) {\n ++n_changes;\n guard->currently_listed = 0;\n guard->unlisted_since_date = randomize_time(approx_time(),\n unlisted_since_slop);\n log_info(LD_GUARD, \"Sampled guard %s is now unlisted.\",\n entry_guard_describe(guard));\n } else if (is_listed && guard->currently_listed) {\n log_debug(LD_GUARD, \"Sampled guard %s is still listed.\",\n entry_guard_describe(guard));\n } else {\n tor_assert(! is_listed && ! guard->currently_listed);\n log_debug(LD_GUARD, \"Sampled guard %s is still unlisted.\",\n entry_guard_describe(guard));\n }\n\n \/* Clean up unlisted_since_date, just in case. *\/\n if (guard->currently_listed && guard->unlisted_since_date) {\n ++n_changes;\n guard->unlisted_since_date = 0;\n log_warn(LD_BUG, \"Sampled guard %s was listed, but with \"\n \"unlisted_since_date set. Fixing.\",\n entry_guard_describe(guard));\n } else if (!guard->currently_listed && ! guard->unlisted_since_date) {\n ++n_changes;\n guard->unlisted_since_date = randomize_time(approx_time(),\n unlisted_since_slop);\n log_warn(LD_BUG, \"Sampled guard %s was unlisted, but with \"\n \"unlisted_since_date unset. Fixing.\",\n entry_guard_describe(guard));\n }\n } SMARTLIST_FOREACH_END(guard);\n\n const time_t remove_if_unlisted_since =\n approx_time() - REMOVE_UNLISTED_GUARDS_AFTER;\n const time_t maybe_remove_if_sampled_before =\n approx_time() - get_guard_lifetime();\n const time_t remove_if_confirmed_before =\n approx_time() - get_guard_confirmed_min_lifetime();\n\n \/* Then: remove the ones that have been junk for too long *\/\n SMARTLIST_FOREACH_BEGIN(gs->sampled_entry_guards, entry_guard_t *, guard) {\n int rmv = 0;\n\n if (guard->currently_listed == 0 &&\n guard->unlisted_since_date < remove_if_unlisted_since) {\n \/*\n \"We have a live consensus, and {IS_LISTED} is false, and\n {FIRST_UNLISTED_AT} is over {REMOVE_UNLISTED_GUARDS_AFTER}\n days in the past.\"\n *\/\n log_info(LD_GUARD, \"Removing sampled guard %s: it has been unlisted \"\n \"for over %d days\", entry_guard_describe(guard),\n get_remove_unlisted_guards_after_days());\n rmv = 1;\n } else if (guard->sampled_on_date < maybe_remove_if_sampled_before) {\n \/* We have a live consensus, and {ADDED_ON_DATE} is over\n {GUARD_LIFETIME} ago, *and* {CONFIRMED_ON_DATE} is either\n \"never\", or over {GUARD_CONFIRMED_MIN_LIFETIME} ago.\n *\/\n if (guard->confirmed_on_date == 0) {\n rmv = 1;\n log_info(LD_GUARD, \"Removing sampled guard %s: it was sampled \"\n \"over %d days ago, but never confirmed.\",\n entry_guard_describe(guard),\n get_guard_lifetime() \/ 86400);\n } else if (guard->confirmed_on_date < remove_if_confirmed_before) {\n rmv = 1;\n log_info(LD_GUARD, \"Removing sampled guard %s: it was sampled \"\n \"over %d days ago, and confirmed over %d days ago.\",\n entry_guard_describe(guard),\n get_guard_lifetime() \/ 86400,\n get_guard_confirmed_min_lifetime() \/ 86400);\n }\n }\n\n if (rmv) {\n ++n_changes;\n SMARTLIST_DEL_CURRENT(gs->sampled_entry_guards, guard);\n remove_guard_from_confirmed_and_primary_lists(gs, guard);\n entry_guard_free(guard);\n }\n } SMARTLIST_FOREACH_END(guard);\n\n if (n_changes) {\n gs->primary_guards_up_to_date = 0;\n entry_guards_update_filtered_sets(gs);\n \/* We don't need to rebuild the confirmed list right here -- we may have\n * removed confirmed guards above, but we can't have added any new\n * confirmed guards.\n *\/\n entry_guards_changed_for_guard_selection(gs);\n }\n}","target":0,"code_token_length":1286,"total_token_length":1522,"max_tokens_setting":2048} +{"idx":69009,"func":"static int i40e_config_netdev(struct i40e_vsi *vsi)\n{\n\tstruct i40e_pf *pf = vsi->back;\n\tstruct i40e_hw *hw = &pf->hw;\n\tstruct i40e_netdev_priv *np;\n\tstruct net_device *netdev;\n\tu8 broadcast[ETH_ALEN];\n\tu8 mac_addr[ETH_ALEN];\n\tint etherdev_size;\n\tnetdev_features_t hw_enc_features;\n\tnetdev_features_t hw_features;\n\n\tetherdev_size = sizeof(struct i40e_netdev_priv);\n\tnetdev = alloc_etherdev_mq(etherdev_size, vsi->alloc_queue_pairs);\n\tif (!netdev)\n\t\treturn -ENOMEM;\n\n\tvsi->netdev = netdev;\n\tnp = netdev_priv(netdev);\n\tnp->vsi = vsi;\n\n\thw_enc_features = NETIF_F_SG\t\t\t|\n\t\t\t NETIF_F_IP_CSUM\t\t|\n\t\t\t NETIF_F_IPV6_CSUM\t\t|\n\t\t\t NETIF_F_HIGHDMA\t\t|\n\t\t\t NETIF_F_SOFT_FEATURES\t\t|\n\t\t\t NETIF_F_TSO\t\t\t|\n\t\t\t NETIF_F_TSO_ECN\t\t|\n\t\t\t NETIF_F_TSO6\t\t\t|\n\t\t\t NETIF_F_GSO_GRE\t\t|\n\t\t\t NETIF_F_GSO_GRE_CSUM\t\t|\n\t\t\t NETIF_F_GSO_PARTIAL\t\t|\n\t\t\t NETIF_F_GSO_IPXIP4\t\t|\n\t\t\t NETIF_F_GSO_IPXIP6\t\t|\n\t\t\t NETIF_F_GSO_UDP_TUNNEL\t|\n\t\t\t NETIF_F_GSO_UDP_TUNNEL_CSUM\t|\n\t\t\t NETIF_F_SCTP_CRC\t\t|\n\t\t\t NETIF_F_RXHASH\t\t|\n\t\t\t NETIF_F_RXCSUM\t\t|\n\t\t\t 0;\n\n\tif (!(pf->hw_features & I40E_HW_OUTER_UDP_CSUM_CAPABLE))\n\t\tnetdev->gso_partial_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;\n\n\tnetdev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;\n\n\tnetdev->hw_enc_features |= hw_enc_features;\n\n\t\/* record features VLANs can make use of *\/\n\tnetdev->vlan_features |= hw_enc_features | NETIF_F_TSO_MANGLEID;\n\n\t\/* enable macvlan offloads *\/\n\tnetdev->hw_features |= NETIF_F_HW_L2FW_DOFFLOAD;\n\n\thw_features = hw_enc_features\t\t|\n\t\t NETIF_F_HW_VLAN_CTAG_TX\t|\n\t\t NETIF_F_HW_VLAN_CTAG_RX;\n\n\tif (!(pf->flags & I40E_FLAG_MFP_ENABLED))\n\t\thw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC;\n\n\tnetdev->hw_features |= hw_features;\n\n\tnetdev->features |= hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;\n\tnetdev->hw_enc_features |= NETIF_F_TSO_MANGLEID;\n\n\tif (vsi->type == I40E_VSI_MAIN) {\n\t\tSET_NETDEV_DEV(netdev, &pf->pdev->dev);\n\t\tether_addr_copy(mac_addr, hw->mac.perm_addr);\n\t\t\/* The following steps are necessary for two reasons. First,\n\t\t * some older NVM configurations load a default MAC-VLAN\n\t\t * filter that will accept any tagged packet, and we want to\n\t\t * replace this with a normal filter. Additionally, it is\n\t\t * possible our MAC address was provided by the platform using\n\t\t * Open Firmware or similar.\n\t\t *\n\t\t * Thus, we need to remove the default filter and install one\n\t\t * specific to the MAC address.\n\t\t *\/\n\t\ti40e_rm_default_mac_filter(vsi, mac_addr);\n\t\tspin_lock_bh(&vsi->mac_filter_hash_lock);\n\t\ti40e_add_mac_filter(vsi, mac_addr);\n\t\tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n\t} else {\n\t\t\/* Relate the VSI_VMDQ name to the VSI_MAIN name. Note that we\n\t\t * are still limited by IFNAMSIZ, but we're adding 'v%d\\0' to\n\t\t * the end, which is 4 bytes long, so force truncation of the\n\t\t * original name by IFNAMSIZ - 4\n\t\t *\/\n\t\tsnprintf(netdev->name, IFNAMSIZ, \"%.*sv%%d\",\n\t\t\t IFNAMSIZ - 4,\n\t\t\t pf->vsi[pf->lan_vsi]->netdev->name);\n\t\teth_random_addr(mac_addr);\n\n\t\tspin_lock_bh(&vsi->mac_filter_hash_lock);\n\t\ti40e_add_mac_filter(vsi, mac_addr);\n\t\tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n\t}\n\n\t\/* Add the broadcast filter so that we initially will receive\n\t * broadcast packets. Note that when a new VLAN is first added the\n\t * driver will convert all filters marked I40E_VLAN_ANY into VLAN\n\t * specific filters as part of transitioning into \"vlan\" operation.\n\t * When more VLANs are added, the driver will copy each existing MAC\n\t * filter and add it for the new VLAN.\n\t *\n\t * Broadcast filters are handled specially by\n\t * i40e_sync_filters_subtask, as the driver must to set the broadcast\n\t * promiscuous bit instead of adding this directly as a MAC\/VLAN\n\t * filter. The subtask will update the correct broadcast promiscuous\n\t * bits as VLANs become active or inactive.\n\t *\/\n\teth_broadcast_addr(broadcast);\n\tspin_lock_bh(&vsi->mac_filter_hash_lock);\n\ti40e_add_mac_filter(vsi, broadcast);\n\tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n\n\tether_addr_copy(netdev->dev_addr, mac_addr);\n\tether_addr_copy(netdev->perm_addr, mac_addr);\n\n\t\/* i40iw_net_event() reads 16 bytes from neigh->primary_key *\/\n\tnetdev->neigh_priv_len = sizeof(u32) * 4;\n\n\tnetdev->priv_flags |= IFF_UNICAST_FLT;\n\tnetdev->priv_flags |= IFF_SUPP_NOFCS;\n\t\/* Setup netdev TC information *\/\n\ti40e_vsi_config_netdev_tc(vsi, vsi->tc_config.enabled_tc);\n\n\tnetdev->netdev_ops = &i40e_netdev_ops;\n\tnetdev->watchdog_timeo = 5 * HZ;\n\ti40e_set_ethtool_ops(netdev);\n\n\t\/* MTU range: 68 - 9706 *\/\n\tnetdev->min_mtu = ETH_MIN_MTU;\n\tnetdev->max_mtu = I40E_MAX_RXBUFFER - I40E_PACKET_HDR_PAD;\n\n\treturn 0;\n}","target":0,"code_token_length":1412,"total_token_length":1648,"max_tokens_setting":2048} +{"idx":429792,"func":"static BOOL check_opcode_types(compiler_common *common, PCRE2_SPTR cc, PCRE2_SPTR ccend)\n{\nint count;\nPCRE2_SPTR slot;\nPCRE2_SPTR assert_back_end = cc - 1;\n\n\/* Calculate important variables (like stack size) and checks whether all opcodes are supported. *\/\nwhile (cc < ccend)\n {\n switch(*cc)\n {\n case OP_SET_SOM:\n common->has_set_som = TRUE;\n common->might_be_empty = TRUE;\n cc += 1;\n break;\n\n case OP_REF:\n case OP_REFI:\n common->optimized_cbracket[GET2(cc, 1)] = 0;\n cc += 1 + IMM2_SIZE;\n break;\n\n case OP_CBRAPOS:\n case OP_SCBRAPOS:\n common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;\n cc += 1 + LINK_SIZE + IMM2_SIZE;\n break;\n\n case OP_COND:\n case OP_SCOND:\n \/* Only AUTO_CALLOUT can insert this opcode. We do\n not intend to support this case. *\/\n if (cc[1 + LINK_SIZE] == OP_CALLOUT || cc[1 + LINK_SIZE] == OP_CALLOUT_STR)\n return FALSE;\n cc += 1 + LINK_SIZE;\n break;\n\n case OP_CREF:\n common->optimized_cbracket[GET2(cc, 1)] = 0;\n cc += 1 + IMM2_SIZE;\n break;\n\n case OP_DNREF:\n case OP_DNREFI:\n case OP_DNCREF:\n count = GET2(cc, 1 + IMM2_SIZE);\n slot = common->name_table + GET2(cc, 1) * common->name_entry_size;\n while (count-- > 0)\n {\n common->optimized_cbracket[GET2(slot, 0)] = 0;\n slot += common->name_entry_size;\n }\n cc += 1 + 2 * IMM2_SIZE;\n break;\n\n case OP_RECURSE:\n \/* Set its value only once. *\/\n if (common->recursive_head_ptr == 0)\n {\n common->recursive_head_ptr = common->ovector_start;\n common->ovector_start += sizeof(sljit_sw);\n }\n cc += 1 + LINK_SIZE;\n break;\n\n case OP_CALLOUT:\n case OP_CALLOUT_STR:\n if (common->capture_last_ptr == 0)\n {\n common->capture_last_ptr = common->ovector_start;\n common->ovector_start += sizeof(sljit_sw);\n }\n cc += (*cc == OP_CALLOUT) ? PRIV(OP_lengths)[OP_CALLOUT] : GET(cc, 1 + 2*LINK_SIZE);\n break;\n\n case OP_ASSERTBACK:\n slot = bracketend(cc);\n if (slot > assert_back_end)\n assert_back_end = slot;\n cc += 1 + LINK_SIZE;\n break;\n\n case OP_THEN_ARG:\n common->has_then = TRUE;\n common->control_head_ptr = 1;\n \/* Fall through. *\/\n\n case OP_COMMIT_ARG:\n case OP_PRUNE_ARG:\n case OP_MARK:\n if (common->mark_ptr == 0)\n {\n common->mark_ptr = common->ovector_start;\n common->ovector_start += sizeof(sljit_sw);\n }\n cc += 1 + 2 + cc[1];\n break;\n\n case OP_THEN:\n common->has_then = TRUE;\n common->control_head_ptr = 1;\n cc += 1;\n break;\n\n case OP_SKIP:\n if (cc < assert_back_end)\n common->has_skip_in_assert_back = TRUE;\n cc += 1;\n break;\n\n case OP_SKIP_ARG:\n common->control_head_ptr = 1;\n common->has_skip_arg = TRUE;\n if (cc < assert_back_end)\n common->has_skip_in_assert_back = TRUE;\n cc += 1 + 2 + cc[1];\n break;\n\n default:\n cc = next_opcode(common, cc);\n if (cc == NULL)\n return FALSE;\n break;\n }\n }\nreturn TRUE;\n}","target":0,"code_token_length":923,"total_token_length":1159,"max_tokens_setting":2048} +{"idx":44181,"func":"static RectangleInfo CompareImagesBounds(const Image *image1,\n const Image *image2,const LayerMethod method,ExceptionInfo *exception)\n{\n RectangleInfo\n bounds;\n\n PixelInfo\n pixel1,\n pixel2;\n\n register const Quantum\n *p,\n *q;\n\n register ssize_t\n x;\n\n ssize_t\n y;\n\n \/*\n Set bounding box of the differences between images.\n *\/\n GetPixelInfo(image1,&pixel1);\n GetPixelInfo(image2,&pixel2);\n for (x=0; x < (ssize_t) image1->columns; x++)\n {\n p=GetVirtualPixels(image1,x,0,1,image1->rows,exception);\n q=GetVirtualPixels(image2,x,0,1,image2->rows,exception);\n if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))\n break;\n for (y=0; y < (ssize_t) image1->rows; y++)\n {\n GetPixelInfoPixel(image1,p,&pixel1);\n GetPixelInfoPixel(image2,q,&pixel2);\n if (ComparePixels(method,&pixel1,&pixel2) != MagickFalse)\n break;\n p+=GetPixelChannels(image1);\n q+=GetPixelChannels(image2);\n }\n if (y < (ssize_t) image1->rows)\n break;\n }\n if (x >= (ssize_t) image1->columns)\n {\n \/*\n Images are identical, return a null image.\n *\/\n bounds.x=-1;\n bounds.y=-1;\n bounds.width=1;\n bounds.height=1;\n return(bounds);\n }\n bounds.x=x;\n for (x=(ssize_t) image1->columns-1; x >= 0; x--)\n {\n p=GetVirtualPixels(image1,x,0,1,image1->rows,exception);\n q=GetVirtualPixels(image2,x,0,1,image2->rows,exception);\n if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))\n break;\n for (y=0; y < (ssize_t) image1->rows; y++)\n {\n GetPixelInfoPixel(image1,p,&pixel1);\n GetPixelInfoPixel(image2,q,&pixel2);\n if (ComparePixels(method,&pixel1,&pixel2) != MagickFalse)\n break;\n p+=GetPixelChannels(image1);\n q+=GetPixelChannels(image2);\n }\n if (y < (ssize_t) image1->rows)\n break;\n }\n bounds.width=(size_t) (x-bounds.x+1);\n for (y=0; y < (ssize_t) image1->rows; y++)\n {\n p=GetVirtualPixels(image1,0,y,image1->columns,1,exception);\n q=GetVirtualPixels(image2,0,y,image2->columns,1,exception);\n if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))\n break;\n for (x=0; x < (ssize_t) image1->columns; x++)\n {\n GetPixelInfoPixel(image1,p,&pixel1);\n GetPixelInfoPixel(image2,q,&pixel2);\n if (ComparePixels(method,&pixel1,&pixel2) != MagickFalse)\n break;\n p+=GetPixelChannels(image1);\n q+=GetPixelChannels(image2);\n }\n if (x < (ssize_t) image1->columns)\n break;\n }\n bounds.y=y;\n for (y=(ssize_t) image1->rows-1; y >= 0; y--)\n {\n p=GetVirtualPixels(image1,0,y,image1->columns,1,exception);\n q=GetVirtualPixels(image2,0,y,image2->columns,1,exception);\n if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))\n break;\n for (x=0; x < (ssize_t) image1->columns; x++)\n {\n GetPixelInfoPixel(image1,p,&pixel1);\n GetPixelInfoPixel(image2,q,&pixel2);\n if (ComparePixels(method,&pixel1,&pixel2) != MagickFalse)\n break;\n p+=GetPixelChannels(image1);\n q+=GetPixelChannels(image2);\n }\n if (x < (ssize_t) image1->columns)\n break;\n }\n bounds.height=(size_t) (y-bounds.y+1);\n return(bounds);\n}","target":0,"code_token_length":983,"total_token_length":1219,"max_tokens_setting":2048} +{"idx":400942,"func":"innodb_switch_mapping(\n\/*==================*\/\n\tENGINE_HANDLE*\t\thandle,\t\t\/*!< in: Engine handle *\/\n\tconst void*\t\tcookie,\t\t\/*!< in: connection cookie *\/\n\tconst char*\t\tname,\t\t\/*!< in: full name contains\n\t\t\t\t\t\ttable map name, and possible\n\t\t\t\t\t\tkey value *\/\n\tsize_t*\t\t\tname_len,\t\/*!< in\/out: name length,\n\t\t\t\t\t\tout with length excludes\n\t\t\t\t\t\tthe table map name *\/\n\tbool\t\t\thas_prefix)\t\/*!< in: whether the name has\n\t\t\t\t\t\t\"@@\" prefix *\/\n{\n\tstruct innodb_engine*\tinnodb_eng = innodb_handle(handle);\n\tinnodb_conn_data_t*\tconn_data;\n\tchar\t\t\tnew_name[KEY_MAX_LENGTH];\n\tmeta_cfg_info_t*\tmeta_info = innodb_eng->meta_info;\n\tchar*\t\t\tnew_map_name;\n\tunsigned int\t\tnew_map_name_len = 0;\n\tchar*\t\t\tlast;\n\tmeta_cfg_info_t*\tnew_meta_info;\n\tint\t\t\tsep_len = 0;\n\n\tif (has_prefix) {\n\t\tchar*\t\tsep = NULL;\n\n\t\tassert(*name_len > 2 && name[0] == '@' && name[1] == '@');\n\t\tassert(*name_len < KEY_MAX_LENGTH);\n\n\t\tmemcpy(new_name, &name[2], (*name_len) - 2);\n\n\t\tnew_name[*name_len - 2] = 0;\n\n\t\tGET_OPTION(meta_info, OPTION_ID_TBL_MAP_SEP, sep, sep_len);\n\n\t\tassert(sep_len > 0);\n\n\t\tnew_map_name = strtok_r(new_name, sep, &last);\n\n\t\tif (new_map_name == NULL) {\n\t\t\treturn(ENGINE_KEY_ENOENT);\n\t\t}\n\n\t\tnew_map_name_len = strlen(new_map_name);\n\t} else {\n\t\t\/* This is used in the \"bind\" command, and without the\n\t\t\"@@\" prefix. *\/\n\t\tif (name == NULL) {\n\t\t\treturn(ENGINE_KEY_ENOENT);\n\t\t}\n\n\t\tnew_map_name = (char*) name;\n\t\tnew_map_name_len = *name_len;\n\t}\n\n\tconn_data = innodb_eng->server.cookie->get_engine_specific(cookie);\n\n\t\/* Check if we are getting the same configure setting as existing one *\/\n\tif (conn_data && conn_data->conn_meta\n\t && (new_map_name_len\n\t\t== conn_data->conn_meta->col_info[CONTAINER_NAME].col_name_len)\n\t && (strcmp(\n\t\tnew_map_name,\n\t\tconn_data->conn_meta->col_info[CONTAINER_NAME].col_name) == 0)) {\n\t\tgoto get_key_name;\n\t}\n\n\tnew_meta_info = innodb_config(\n\t\tnew_map_name, new_map_name_len, &innodb_eng->meta_hash);\n\n\tif (!new_meta_info) {\n\t\treturn(ENGINE_KEY_ENOENT);\n\t}\n\n\t\/* Clean up the existing connection metadata if exists *\/\n\tif (conn_data) {\n\t\tinnodb_conn_clean_data(conn_data, false, false);\n\n\t\t\/* Point to the new metadata *\/\n\t\tconn_data->conn_meta = new_meta_info;\n\t}\n\n\tconn_data = innodb_conn_init(innodb_eng, cookie,\n\t\t\t\t CONN_MODE_NONE, 0, false,\n\t\t\t\t new_meta_info);\n\n\tassert(conn_data->conn_meta == new_meta_info);\n\nget_key_name:\n\t\/* Now calculate name length exclude the table mapping name,\n\tthis is the length for the remaining key portion *\/\n\tif (has_prefix) {\n\t\tassert(*name_len >= strlen(new_map_name) + 2);\n\n\t\tif (*name_len >= strlen(new_map_name) + 2 + sep_len) {\n\t\t\t*name_len -= strlen(new_map_name) + 2 + sep_len;\n\t\t} else {\n\t\t\t\/* the name does not even contain a delimiter,\n\t\t\tso there will be no keys either *\/\n\t\t\t*name_len = 0;\n\t\t}\n\t}\n\n\treturn(ENGINE_SUCCESS);\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048} +{"idx":446269,"func":"virDomainFSDefFormat(virBufferPtr buf,\n virDomainFSDefPtr def,\n unsigned int flags)\n{\n const char *type = virDomainFSTypeToString(def->type);\n const char *accessmode = virDomainFSAccessModeTypeToString(def->accessmode);\n const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver);\n const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);\n const char *multidevs = virDomainFSMultidevsTypeToString(def->multidevs);\n const char *src = def->src->path;\n g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;\n g_auto(virBuffer) driverBuf = VIR_BUFFER_INIT_CHILD(buf);\n g_auto(virBuffer) binaryAttrBuf = VIR_BUFFER_INITIALIZER;\n g_auto(virBuffer) binaryBuf = VIR_BUFFER_INIT_CHILD(buf);\n\n if (!type) {\n virReportError(VIR_ERR_INTERNAL_ERROR,\n _(\"unexpected filesystem type %d\"), def->type);\n return -1;\n }\n\n if (!accessmode) {\n virReportError(VIR_ERR_INTERNAL_ERROR,\n _(\"unexpected accessmode %d\"), def->accessmode);\n return -1;\n }\n\n if (!multidevs) {\n virReportError(VIR_ERR_INTERNAL_ERROR,\n _(\"unexpected multidevs %d\"), def->multidevs);\n return -1;\n }\n\n virBufferAsprintf(buf,\n \"model) {\n virBufferAsprintf(buf, \" model='%s'\",\n virDomainFSModelTypeToString(def->model));\n }\n if (def->multidevs)\n virBufferAsprintf(buf, \" multidevs='%s'\", multidevs);\n virBufferAddLit(buf, \">\\n\");\n\n virBufferAdjustIndent(buf, 2);\n virBufferAdjustIndent(&driverBuf, 2);\n virBufferAdjustIndent(&binaryBuf, 2);\n if (def->fsdriver) {\n virBufferAsprintf(&driverAttrBuf, \" type='%s'\", fsdriver);\n\n if (def->format)\n virBufferAsprintf(&driverAttrBuf, \" format='%s'\",\n virStorageFileFormatTypeToString(def->format));\n\n \/* Don't generate anything if wrpolicy is set to default *\/\n if (def->wrpolicy)\n virBufferAsprintf(&driverAttrBuf, \" wrpolicy='%s'\", wrpolicy);\n\n if (def->queue_size)\n virBufferAsprintf(&driverAttrBuf, \" queue='%llu'\", def->queue_size);\n\n }\n\n if (def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {\n g_auto(virBuffer) lockAttrBuf = VIR_BUFFER_INITIALIZER;\n virBufferEscapeString(&binaryAttrBuf, \" path='%s'\", def->binary);\n\n if (def->xattr != VIR_TRISTATE_SWITCH_ABSENT) {\n virBufferAsprintf(&binaryAttrBuf, \" xattr='%s'\",\n virTristateSwitchTypeToString(def->xattr));\n }\n\n if (def->cache != VIR_DOMAIN_FS_CACHE_MODE_DEFAULT) {\n virBufferAsprintf(&binaryBuf, \"\\n\",\n virDomainFSCacheModeTypeToString(def->cache));\n }\n\n if (def->posix_lock != VIR_TRISTATE_SWITCH_ABSENT) {\n virBufferAsprintf(&lockAttrBuf, \" posix='%s'\",\n virTristateSwitchTypeToString(def->posix_lock));\n }\n\n if (def->flock != VIR_TRISTATE_SWITCH_ABSENT) {\n virBufferAsprintf(&lockAttrBuf, \" flock='%s'\",\n virTristateSwitchTypeToString(def->flock));\n }\n\n virXMLFormatElement(&binaryBuf, \"lock\", &lockAttrBuf, NULL);\n }\n\n virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);\n\n virXMLFormatElement(buf, \"driver\", &driverAttrBuf, &driverBuf);\n virXMLFormatElement(buf, \"binary\", &binaryAttrBuf, &binaryBuf);\n\n switch (def->type) {\n case VIR_DOMAIN_FS_TYPE_MOUNT:\n case VIR_DOMAIN_FS_TYPE_BIND:\n virBufferEscapeString(buf, \"\\n\",\n src);\n break;\n\n case VIR_DOMAIN_FS_TYPE_BLOCK:\n virBufferEscapeString(buf, \"\\n\",\n src);\n break;\n\n case VIR_DOMAIN_FS_TYPE_FILE:\n virBufferEscapeString(buf, \"\\n\",\n src);\n break;\n\n case VIR_DOMAIN_FS_TYPE_TEMPLATE:\n virBufferEscapeString(buf, \"\\n\",\n src);\n break;\n\n case VIR_DOMAIN_FS_TYPE_RAM:\n virBufferAsprintf(buf, \"\\n\",\n def->usage \/ 1024);\n break;\n\n case VIR_DOMAIN_FS_TYPE_VOLUME:\n virBufferAddLit(buf, \"src->srcpool->pool);\n virBufferEscapeString(buf, \" volume='%s'\", def->src->srcpool->volume);\n virBufferAddLit(buf, \"\/>\\n\");\n break;\n }\n\n virBufferEscapeString(buf, \"\\n\",\n def->dst);\n\n if (def->readonly)\n virBufferAddLit(buf, \"\\n\");\n\n if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)\n return -1;\n\n if (def->space_hard_limit)\n virBufferAsprintf(buf, \"\"\n \"%llu<\/space_hard_limit>\\n\", def->space_hard_limit);\n if (def->space_soft_limit) {\n virBufferAsprintf(buf, \"\"\n \"%llu<\/space_soft_limit>\\n\", def->space_soft_limit);\n }\n virBufferAdjustIndent(buf, -2);\n virBufferAddLit(buf, \"<\/filesystem>\\n\");\n\n return 0;\n}","target":0,"code_token_length":1321,"total_token_length":1557,"max_tokens_setting":2048} +{"idx":506294,"func":"int ssl3_get_certificate_request(SSL *s)\n\t{\n\tint ok,ret=0;\n\tunsigned long n,nc,l;\n\tunsigned int llen,ctype_num,i;\n\tX509_NAME *xn=NULL;\n\tconst unsigned char *p,*q;\n\tunsigned char *d;\n\tSTACK_OF(X509_NAME) *ca_sk=NULL;\n\n\tn=s->method->ssl_get_message(s,\n\t\tSSL3_ST_CR_CERT_REQ_A,\n\t\tSSL3_ST_CR_CERT_REQ_B,\n\t\t-1,\n\t\ts->max_cert_list,\n\t\t&ok);\n\n\tif (!ok) return((int)n);\n\n\ts->s3->tmp.cert_req=0;\n\n\tif (s->s3->tmp.message_type == SSL3_MT_SERVER_DONE)\n\t\t{\n\t\ts->s3->tmp.reuse_message=1;\n\t\treturn(1);\n\t\t}\n\n\tif (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_REQUEST)\n\t\t{\n\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);\n\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_WRONG_MESSAGE_TYPE);\n\t\tgoto err;\n\t\t}\n\n\t\/* TLS does not like anon-DH with client cert *\/\n\tif (s->version > SSL3_VERSION)\n\t\t{\n\t\tl=s->s3->tmp.new_cipher->algorithms;\n\t\tif (l & SSL_aNULL)\n\t\t\t{\n\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);\n\t\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\n\tp=d=(unsigned char *)s->init_msg;\n\n\tif ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\n\t\/* get the certificate types *\/\n\tctype_num= *(p++);\n\tif (ctype_num > SSL3_CT_NUMBER)\n\t\tctype_num=SSL3_CT_NUMBER;\n\tfor (i=0; is3->tmp.ctype[i]= p[i];\n\tp+=ctype_num;\n\n\t\/* get the CA RDNs *\/\n\tn2s(p,llen);\n#if 0\n{\nFILE *out;\nout=fopen(\"\/tmp\/vsign.der\",\"w\");\nfwrite(p,1,llen,out);\nfclose(out);\n}\n#endif\n\n\tif ((llen+ctype_num+2+1) != n)\n\t\t{\n\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR);\n\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_LENGTH_MISMATCH);\n\t\tgoto err;\n\t\t}\n\n\tfor (nc=0; nc llen)\n\t\t\t{\n\t\t\tif ((s->options & SSL_OP_NETSCAPE_CA_DN_BUG))\n\t\t\t\tgoto cont; \/* netscape bugs *\/\n\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR);\n\t\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_CA_DN_TOO_LONG);\n\t\t\tgoto err;\n\t\t\t}\n\n\t\tq=p;\n\n\t\tif ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL)\n\t\t\t{\n\t\t\t\/* If netscape tolerance is on, ignore errors *\/\n\t\t\tif (s->options & SSL_OP_NETSCAPE_CA_DN_BUG)\n\t\t\t\tgoto cont;\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR);\n\t\t\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_ASN1_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\n\t\tif (q != (p+l))\n\t\t\t{\n\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR);\n\t\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_CA_DN_LENGTH_MISMATCH);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (!sk_X509_NAME_push(ca_sk,xn))\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\n\t\tp+=l;\n\t\tnc+=l+2;\n\t\t}\n\n\tif (0)\n\t\t{\ncont:\n\t\tERR_clear_error();\n\t\t}\n\n\t\/* we should setup a certificate to return.... *\/\n\ts->s3->tmp.cert_req=1;\n\ts->s3->tmp.ctype_num=ctype_num;\n\tif (s->s3->tmp.ca_names != NULL)\n\t\tsk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);\n\ts->s3->tmp.ca_names=ca_sk;\n\tca_sk=NULL;\n\n\tret=1;\nerr:\n\tif (ca_sk != NULL) sk_X509_NAME_pop_free(ca_sk,X509_NAME_free);\n\treturn(ret);\n\t}","target":0,"code_token_length":1081,"total_token_length":1317,"max_tokens_setting":2048} +{"idx":83514,"func":"static Jsi_RC jsi_csSetupStruct(Jsi_Interp *interp, Jsi_StructSpec *sl, Jsi_FieldSpec *sf, \n Jsi_StructSpec* recs, int flen, Jsi_OptionTypedef** stPtr, int arrCnt) {\n bool isNew;\n int i, cnt = 0, boffset = 0;\n Jsi_HashEntry *entry, *hPtr;\n if (!(hPtr=Jsi_HashEntryNew(interp->CTypeHash, sl->name, &isNew)) || !isNew)\n return Jsi_LogError(\"struct is c-type: %s\", sl->name);\n entry = Jsi_HashEntryNew(interp->StructHash, sl->name, &isNew);\n if (!isNew)\n return Jsi_LogError(\"duplicate struct: %s\", sl->name);\n Jsi_FieldSpec *asf = NULL, *osf = sf;\n while (sf && sf->id != JSI_OPTION_END) {\n if (!sf->type)\n sf->type = Jsi_OptionTypeInfo(sf->id);\n if (!sf->type && sf->tname)\n sf->type = Jsi_TypeLookup(interp, sf->tname);\n int isbitset = ((sf->flags&JSI_OPT_BITSET_ENUM)!=0);\n if (sf->type && sf->type->extData && (sf->type->flags&(jsi_CTYP_ENUM|jsi_CTYP_STRUCT))) {\n \/\/ A struct sub-field or a bit field mapped to an ENUM.\n Jsi_OptionSpec *es = (typeof(es))sf->type->extData;\n es->value++;\n if ((sf->type->flags&jsi_CTYP_ENUM)) {\n if (sf->bits)\n return Jsi_LogError(\"enum of bits unsupported: %s\", sl->name); \/\/TODO: get working again...\n sf->custom = (isbitset ? Jsi_Opt_SwitchBitset : Jsi_Opt_SwitchEnum);\n sf->data = (void*)es->data;\n sf->id = JSI_OPTION_CUSTOM;\n }\n else if (sf->type->flags & jsi_CTYP_STRUCT) {\n sf->custom = Jsi_Opt_SwitchSuboption;\n sf->data = es->extData;\n sf->id = JSI_OPTION_CUSTOM;\n }\n }\n if (recs) {\n if (!sf->type)\n return Jsi_LogError(\"unknown id\");\n sf->tname = sf->type->cName;\n sf->size = (isbitset?(int)sizeof(int):sf->type->size);\n if (sf->arrSize)\n sf->size *= sf->arrSize;\n sf->idx = cnt;\n sf->boffset = boffset;\n if (sf->bits) {\n if (sf->bits>=64)\n return Jsi_LogError(\"bits too large\");\n boffset += sf->bits;\n sf->id = JSI_OPTION_CUSTOM;\n sf->custom=Jsi_Opt_SwitchBitfield;\n sf->init.OPT_BITS=&jsi_csBitGetSet;\n } else {\n sf->offset = (boffset+7)\/8;\n boffset += sf->size*8;\n }\n } else {\n boffset += sf->size*8;\n }\n sf->extData = (uchar*)sl;\n sf++, cnt++;\n }\n sl->idx = cnt;\n if (!sl->size) \n sl->size = (boffset+7)\/8;\n if (sl->ssig)\n Jsi_HashSet(interp->SigHash, (void*)(uintptr_t)sl->ssig, sl);\n int extra = 0;\n if (flen)\n extra = sl->size + ((flen+2+arrCnt*2)*sizeof(Jsi_StructSpec));\n Jsi_OptionTypedef *st = (typeof(st))Jsi_Calloc(1, sizeof(*st) + extra);\n SIGINIT(st, TYPEDEF);\n if (!recs) \n sf = osf;\n else {\n st->extra = (uchar*)(st+1); \/\/ Space for struct initializer.\n sf = (typeof(sf))(st->extra + sl->size);\n memcpy(sf, recs, sizeof(*sf)*(flen+1));\n sl = sf+flen+1;\n if (arrCnt)\n asf = sl+1;\n memcpy(sl, recs+flen+1, sizeof(*sl));\n for (i=0; iid;\n if (sf[i].arrSize) {\n asf[0] = sf[i];\n asf[1] = sf[flen];\n asf->arrSize = asf->offset = 0;\n \/\/asf->size = asf->type->size;\n sf[i].id = JSI_OPTION_CUSTOM;\n sf[i].custom=Jsi_Opt_SwitchCArray;\n sf[i].init.OPT_CARRAY = asf;\n asf += 2;\n \/\/sf[i].extData = \n \/\/ {.sig=JSI_SIG_OPTS_FIELD, .name=sf[i].name, \n \/\/ JSI_OPT_CARRAY_ITEM_(JSI_SIG_OPTS_FIELD,'+otype+', '+name+', sf[i].name, .help=sf[i].help, .flags='+fflags+rest+'),\\n'\n \/\/ JSI_OPT_END_(JSI_SIG_OPTS_FIELD,'+name+', .help=\"Options for array field '+name+'.'+fname+'\")\\n };\\n\\n';\n \/\/ JSI_OPT_CARRAY_(JSI_SIG_OPTS_FIELD,'+name+', '+fname+', \"'+fdescr+'\", '+fflags+', '+arnam+', '+f.asize+', \"'+type+'\", '+csinit+'),\\n';\n }\n }\n }\n st->extData = (uchar*)sl;\n sl->extData = (uchar*)sf;\n sl->type = st;\n st->cName = sl->name;\n st->idName = \"CUSTOM\";\n st->id = JSI_OPTION_CUSTOM;\n st->size = sl->size;\n st->flags = jsi_CTYP_DYN_MEMORY|jsi_CTYP_STRUCT;\n Jsi_HashValueSet(entry, sl);\n Jsi_HashValueSet(hPtr, st);\n st->hPtr = hPtr;\n if (stPtr)\n *stPtr = st;\n return JSI_OK;\n}","target":0,"code_token_length":1448,"total_token_length":1684,"max_tokens_setting":2048} +{"idx":506941,"func":"int n_ssl3_mac(SSL *ssl, unsigned char *md, int send)\n\t{\n\tSSL3_RECORD *rec;\n\tunsigned char *mac_sec,*seq;\n\tEVP_MD_CTX md_ctx;\n\tconst EVP_MD_CTX *hash;\n\tunsigned char *p,rec_char;\n\tsize_t md_size, orig_len;\n\tint npad;\n\tint t;\n\n\tif (send)\n\t\t{\n\t\trec= &(ssl->s3->wrec);\n\t\tmac_sec= &(ssl->s3->write_mac_secret[0]);\n\t\tseq= &(ssl->s3->write_sequence[0]);\n\t\thash=ssl->write_hash;\n\t\t}\n\telse\n\t\t{\n\t\trec= &(ssl->s3->rrec);\n\t\tmac_sec= &(ssl->s3->read_mac_secret[0]);\n\t\tseq= &(ssl->s3->read_sequence[0]);\n\t\thash=ssl->read_hash;\n\t\t}\n\n\tt=EVP_MD_CTX_size(hash);\n\tif (t < 0)\n\t\treturn -1;\n\tmd_size=t;\n\tnpad=(48\/md_size)*md_size;\n\n\t\/* kludge: ssl3_cbc_remove_padding passes padding length in rec->type *\/\n\torig_len = rec->length+md_size+((unsigned int)rec->type>>8);\n\trec->type &= 0xff;\n\n\tif (!send &&\n\t EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE &&\n\t ssl3_cbc_record_digest_supported(hash))\n\t\t{\n\t\t\/* This is a CBC-encrypted record. We must avoid leaking any\n\t\t * timing-side channel information about how many blocks of\n\t\t * data we are hashing because that gives an attacker a\n\t\t * timing-oracle. *\/\n\n\t\t\/* npad is, at most, 48 bytes and that's with MD5:\n\t\t * 16 + 48 + 8 (sequence bytes) + 1 + 2 = 75.\n\t\t *\n\t\t * With SHA-1 (the largest hash speced for SSLv3) the hash size\n\t\t * goes up 4, but npad goes down by 8, resulting in a smaller\n\t\t * total size. *\/\n\t\tunsigned char header[75];\n\t\tunsigned j = 0;\n\t\tmemcpy(header+j, mac_sec, md_size);\n\t\tj += md_size;\n\t\tmemcpy(header+j, ssl3_pad_1, npad);\n\t\tj += npad;\n\t\tmemcpy(header+j, seq, 8);\n\t\tj += 8;\n\t\theader[j++] = rec->type;\n\t\theader[j++] = rec->length >> 8;\n\t\theader[j++] = rec->length & 0xff;\n\n\t\tssl3_cbc_digest_record(\n\t\t\thash,\n\t\t\tmd, &md_size,\n\t\t\theader, rec->input,\n\t\t\trec->length + md_size, orig_len,\n\t\t\tmac_sec, md_size,\n\t\t\t1 \/* is SSLv3 *\/);\n\t\t}\n\telse\n\t\t{\n\t\tunsigned int md_size_u;\n\t\t\/* Chop the digest off the end :-) *\/\n\t\tEVP_MD_CTX_init(&md_ctx);\n\n\t\tEVP_MD_CTX_copy_ex( &md_ctx,hash);\n\t\tEVP_DigestUpdate(&md_ctx,mac_sec,md_size);\n\t\tEVP_DigestUpdate(&md_ctx,ssl3_pad_1,npad);\n\t\tEVP_DigestUpdate(&md_ctx,seq,8);\n\t\trec_char=rec->type;\n\t\tEVP_DigestUpdate(&md_ctx,&rec_char,1);\n\t\tp=md;\n\t\ts2n(rec->length,p);\n\t\tEVP_DigestUpdate(&md_ctx,md,2);\n\t\tEVP_DigestUpdate(&md_ctx,rec->input,rec->length);\n\t\tEVP_DigestFinal_ex( &md_ctx,md,NULL);\n\n\t\tEVP_MD_CTX_copy_ex( &md_ctx,hash);\n\t\tEVP_DigestUpdate(&md_ctx,mac_sec,md_size);\n\t\tEVP_DigestUpdate(&md_ctx,ssl3_pad_2,npad);\n\t\tEVP_DigestUpdate(&md_ctx,md,md_size);\n\t\tEVP_DigestFinal_ex( &md_ctx,md,&md_size_u);\n\t\tmd_size = md_size_u;\n\n\t\tEVP_MD_CTX_cleanup(&md_ctx);\n\t}\n\n\tssl3_record_sequence_update(seq);\n\treturn(md_size);\n\t}","target":0,"code_token_length":914,"total_token_length":1150,"max_tokens_setting":2048} +{"idx":111463,"func":"static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit(\n TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize,\n void** value, uint64 maxcount)\n{\n\tint typesize;\n\tuint32 datasize;\n\tvoid* data;\n uint64 target_count64;\n\ttypesize=TIFFDataWidth(direntry->tdir_type);\n\n target_count64 = (direntry->tdir_count > maxcount) ?\n maxcount : direntry->tdir_count;\n\n\tif ((target_count64==0)||(typesize==0))\n\t{\n\t\t*value=0;\n\t\treturn(TIFFReadDirEntryErrOk);\n\t}\n (void) desttypesize;\n\n \/* \n * As a sanity check, make sure we have no more than a 2GB tag array \n * in either the current data type or the dest data type. This also\n * avoids problems with overflow of tmsize_t on 32bit systems.\n *\/\n\tif ((uint64)(2147483647\/typesize)0);\n\n\tif( isMapped(tif) && datasize > (uint32)tif->tif_size )\n\t\treturn TIFFReadDirEntryErrIo;\n\n\tif( !isMapped(tif) &&\n\t\t(((tif->tif_flags&TIFF_BIGTIFF) && datasize > 8) ||\n\t\t(!(tif->tif_flags&TIFF_BIGTIFF) && datasize > 4)) )\n\t{\n\t\tdata = NULL;\n\t}\n\telse\n\t{\n\t\tdata=_TIFFCheckMalloc(tif, *count, typesize, \"ReadDirEntryArray\");\n\t\tif (data==0)\n\t\t\treturn(TIFFReadDirEntryErrAlloc);\n\t}\n\tif (!(tif->tif_flags&TIFF_BIGTIFF))\n\t{\n\t\tif (datasize<=4)\n\t\t\t_TIFFmemcpy(data,&direntry->tdir_offset,datasize);\n\t\telse\n\t\t{\n\t\t\tenum TIFFReadDirEntryErr err;\n\t\t\tuint32 offset = direntry->tdir_offset.toff_long;\n\t\t\tif (tif->tif_flags&TIFF_SWAB)\n\t\t\t\tTIFFSwabLong(&offset);\n\t\t\tif( isMapped(tif) )\n\t\t\t\terr=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);\n\t\t\telse\n\t\t\t\terr=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data);\n\t\t\tif (err!=TIFFReadDirEntryErrOk)\n\t\t\t{\n\t\t\t\t_TIFFfree(data);\n\t\t\t\treturn(err);\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (datasize<=8)\n\t\t\t_TIFFmemcpy(data,&direntry->tdir_offset,datasize);\n\t\telse\n\t\t{\n\t\t\tenum TIFFReadDirEntryErr err;\n\t\t\tuint64 offset = direntry->tdir_offset.toff_long8;\n\t\t\tif (tif->tif_flags&TIFF_SWAB)\n\t\t\t\tTIFFSwabLong8(&offset);\n\t\t\tif( isMapped(tif) )\n\t\t\t\terr=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);\n\t\t\telse\n\t\t\t\terr=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data);\n\t\t\tif (err!=TIFFReadDirEntryErrOk)\n\t\t\t{\n\t\t\t\t_TIFFfree(data);\n\t\t\t\treturn(err);\n\t\t\t}\n\t\t}\n\t}\n\t*value=data;\n\treturn(TIFFReadDirEntryErrOk);\n}","target":0,"code_token_length":878,"total_token_length":1114,"max_tokens_setting":2048} +{"idx":463317,"func":"autoar_extractor_step_scan_toplevel (AutoarExtractor *self)\n{\n \/* Step 0: Scan all file names in the archive\n * We have to check whether the archive contains a top-level directory\n * before performing the extraction. We emit the \"scanned\" signal when\n * the checking is completed. *\/\n\n struct archive *a;\n struct archive_entry *entry;\n\n int r;\n\n g_debug (\"autoar_extractor_step_scan_toplevel: called\");\n\n r = libarchive_create_read_object (FALSE, self, &a);\n if (r != ARCHIVE_OK) {\n archive_read_free (a);\n r = libarchive_create_read_object (TRUE, self, &a);\n if (r != ARCHIVE_OK) {\n if (self->error == NULL)\n self->error = autoar_common_g_error_new_a (a, self->source_basename);\n return;\n } else if (archive_filter_count (a) <= 1){\n \/* If we only use raw format and filter count is one, libarchive will\n * not do anything except for just copying the source file. We do not\n * want this thing to happen because it does unnecesssary copying. *\/\n if (self->error == NULL)\n self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,\n NOT_AN_ARCHIVE_ERRNO,\n \"\\'%s\\': %s\",\n self->source_basename,\n \"not an archive\");\n return;\n }\n self->use_raw_format = TRUE;\n }\n\n while ((r = archive_read_next_header (a, &entry)) == ARCHIVE_OK) {\n const char *pathname;\n g_autofree char *utf8_pathname = NULL;\n\n if (g_cancellable_is_cancelled (self->cancellable)) {\n archive_read_free (a);\n return;\n }\n\n if (archive_entry_is_encrypted (entry)) {\n autoar_extractor_request_passphrase (self);\n }\n\n if (self->use_raw_format) {\n pathname = autoar_common_get_basename_remove_extension (g_file_peek_path (self->source_file));\n g_debug (\"autoar_extractor_step_scan_toplevel: %d: raw pathname = %s\",\n self->total_files, pathname);\n } else {\n const char *symlink_pathname;\n const char *hardlink_pathname;\n\n pathname = archive_entry_pathname (entry);\n utf8_pathname = autoar_common_get_utf8_pathname (pathname);\n symlink_pathname = archive_entry_symlink (entry);\n hardlink_pathname = archive_entry_hardlink (entry);\n\n g_debug (\"autoar_extractor_step_scan_toplevel: %d: pathname = %s%s%s%s%s%s%s\",\n self->total_files, pathname,\n utf8_pathname ? \" utf8 pathname = \" : \"\",\n utf8_pathname ? utf8_pathname : \"\",\n symlink_pathname ? \" symlink = \" : \"\",\n symlink_pathname ? symlink_pathname : \"\",\n hardlink_pathname ? \" hardlink = \" : \"\",\n hardlink_pathname ? hardlink_pathname : \"\");\n }\n self->files_list =\n g_list_prepend (self->files_list,\n g_file_get_child (self->output_file,\n utf8_pathname ? utf8_pathname : pathname));\n self->total_files++;\n self->total_size += archive_entry_size (entry);\n archive_read_data_skip (a);\n }\n\n if (self->files_list == NULL) {\n if (self->error == NULL) {\n self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,\n EMPTY_ARCHIVE_ERRNO,\n \"\\'%s\\': %s\",\n self->source_basename,\n \"empty archive\");\n }\n archive_read_free (a);\n return;\n }\n\n if (r != ARCHIVE_EOF) {\n if (self->error == NULL) {\n self->error =\n autoar_common_g_error_new_a (a, self->source_basename);\n }\n archive_read_free (a);\n return;\n }\n\n \/* If we are unable to determine the total size, set it to a positive\n * number to prevent strange percentage. *\/\n if (self->total_size <= 0)\n self->total_size = G_MAXUINT64;\n\n archive_read_free (a);\n\n g_debug (\"autoar_extractor_step_scan_toplevel: files = %d\",\n self->total_files);\n\n self->files_list = g_list_reverse (self->files_list);\n\n autoar_extractor_signal_scanned (self);\n}","target":0,"code_token_length":970,"total_token_length":1206,"max_tokens_setting":2048} +{"idx":423620,"func":"got_transfer_quota(isc_task_t *task, isc_event_t *event) {\n\tisc_result_t result = ISC_R_SUCCESS;\n\tdns_peer_t *peer = NULL;\n\tchar master[ISC_SOCKADDR_FORMATSIZE];\n\tchar source[ISC_SOCKADDR_FORMATSIZE];\n\tdns_rdatatype_t xfrtype;\n\tdns_zone_t *zone = event->ev_arg;\n\tisc_netaddr_t masterip;\n\tisc_sockaddr_t sourceaddr;\n\tisc_sockaddr_t masteraddr;\n\tisc_time_t now;\n\tconst char *soa_before = \"\";\n\tisc_dscp_t dscp = -1;\n\tbool loaded;\n\n\tUNUSED(task);\n\n\tINSIST(task == zone->task);\n\n\tif (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {\n\t\tresult = ISC_R_CANCELED;\n\t\tgoto cleanup;\n\t}\n\n\tTIME_NOW(&now);\n\n\tisc_sockaddr_format(&zone->masteraddr, master, sizeof(master));\n\tif (dns_zonemgr_unreachable(zone->zmgr, &zone->masteraddr,\n\t\t\t\t &zone->sourceaddr, &now))\n\t{\n\t\tisc_sockaddr_format(&zone->sourceaddr, source, sizeof(source));\n\t\tdns_zone_log(zone, ISC_LOG_INFO,\n\t\t\t \"got_transfer_quota: skipping zone transfer as \"\n\t\t\t \"master %s (source %s) is unreachable (cached)\",\n\t\t\t master, source);\n\t\tresult = ISC_R_CANCELED;\n\t\tgoto cleanup;\n\t}\n\n\tisc_netaddr_fromsockaddr(&masterip, &zone->masteraddr);\n\t(void)dns_peerlist_peerbyaddr(zone->view->peers, &masterip, &peer);\n\n\tif (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_SOABEFOREAXFR))\n\t\tsoa_before = \"SOA before \";\n\t\/*\n\t * Decide whether we should request IXFR or AXFR.\n\t *\/\n\tZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);\n\tloaded = (zone->db != NULL);\n\tZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);\n\n\tif (!loaded) {\n\t\tdns_zone_log(zone, ISC_LOG_DEBUG(1),\n\t\t\t \"no database exists yet, requesting AXFR of \"\n\t\t\t \"initial version from %s\", master);\n\t\txfrtype = dns_rdatatype_axfr;\n\t} else if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FORCEXFER)) {\n\t\tdns_zone_log(zone, ISC_LOG_DEBUG(1),\n\t\t\t \"forced reload, requesting AXFR of \"\n\t\t\t \"initial version from %s\", master);\n\t\txfrtype = dns_rdatatype_axfr;\n\t} else if (DNS_ZONE_FLAG(zone, DNS_ZONEFLAG_NOIXFR)) {\n\t\tdns_zone_log(zone, ISC_LOG_DEBUG(1),\n\t\t\t \"retrying with AXFR from %s due to \"\n\t\t\t \"previous IXFR failure\", master);\n\t\txfrtype = dns_rdatatype_axfr;\n\t\tLOCK_ZONE(zone);\n\t\tDNS_ZONE_CLRFLAG(zone, DNS_ZONEFLAG_NOIXFR);\n\t\tUNLOCK_ZONE(zone);\n\t} else {\n\t\tbool use_ixfr = true;\n\t\tif (peer != NULL)\n\t\t\tresult = dns_peer_getrequestixfr(peer, &use_ixfr);\n\t\tif (peer == NULL || result != ISC_R_SUCCESS)\n\t\t\tuse_ixfr = zone->requestixfr;\n\t\tif (use_ixfr == false) {\n\t\t\tdns_zone_log(zone, ISC_LOG_DEBUG(1),\n\t\t\t\t \"IXFR disabled, requesting %sAXFR from %s\",\n\t\t\t\t soa_before, master);\n\t\t\tif (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_SOABEFOREAXFR))\n\t\t\t\txfrtype = dns_rdatatype_soa;\n\t\t\telse\n\t\t\t\txfrtype = dns_rdatatype_axfr;\n\t\t} else {\n\t\t\tdns_zone_log(zone, ISC_LOG_DEBUG(1),\n\t\t\t\t \"requesting IXFR from %s\", master);\n\t\t\txfrtype = dns_rdatatype_ixfr;\n\t\t}\n\t}\n\n\t\/*\n\t * Determine if we should attempt to sign the request with TSIG.\n\t *\/\n\tresult = ISC_R_NOTFOUND;\n\n\t\/*\n\t * First, look for a tsig key in the master statement, then\n\t * try for a server key.\n\t *\/\n\tif ((zone->masterkeynames != NULL) &&\n\t (zone->masterkeynames[zone->curmaster] != NULL)) {\n\t\tdns_view_t *view = dns_zone_getview(zone);\n\t\tdns_name_t *keyname = zone->masterkeynames[zone->curmaster];\n\t\tresult = dns_view_gettsig(view, keyname, &zone->tsigkey);\n\t}\n\tif (zone->tsigkey == NULL)\n\t\tresult = dns_view_getpeertsig(zone->view, &masterip,\n\t\t\t\t\t &zone->tsigkey);\n\n\tif (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {\n\t\tdns_zone_log(zone, ISC_LOG_ERROR,\n\t\t\t \"could not get TSIG key for zone transfer: %s\",\n\t\t\t isc_result_totext(result));\n\t}\n\n\tif (zone->masterdscps != NULL)\n\t dscp = zone->masterdscps[zone->curmaster];\n\n\tLOCK_ZONE(zone);\n\tmasteraddr = zone->masteraddr;\n\tsourceaddr = zone->sourceaddr;\n\tswitch (isc_sockaddr_pf(&masteraddr)) {\n\tcase PF_INET:\n\t\tif (dscp == -1)\n\t\t\tdscp = zone->xfrsource4dscp;\n\t\tbreak;\n\tcase PF_INET6:\n\t\tif (dscp == -1)\n\t\t\tdscp = zone->xfrsource6dscp;\n\t\tbreak;\n\tdefault:\n\t\tINSIST(0);\n\t\tISC_UNREACHABLE();\n\t}\n\tUNLOCK_ZONE(zone);\n\tINSIST(isc_sockaddr_pf(&masteraddr) == isc_sockaddr_pf(&sourceaddr));\n\tresult = dns_xfrin_create(zone, xfrtype, &masteraddr, &sourceaddr,\n\t\t\t\t dscp, zone->tsigkey, zone->mctx,\n\t\t\t\t zone->zmgr->timermgr, zone->zmgr->socketmgr,\n\t\t\t\t zone->task, zone_xfrdone, &zone->xfr);\n\tif (result == ISC_R_SUCCESS) {\n\t\tLOCK_ZONE(zone);\n\t\tif (xfrtype == dns_rdatatype_axfr) {\n\t\t\tif (isc_sockaddr_pf(&masteraddr) == PF_INET)\n\t\t\t\tinc_stats(zone, dns_zonestatscounter_axfrreqv4);\n\t\t\telse\n\t\t\t\tinc_stats(zone, dns_zonestatscounter_axfrreqv6);\n\t\t} else if (xfrtype == dns_rdatatype_ixfr) {\n\t\t\tif (isc_sockaddr_pf(&masteraddr) == PF_INET)\n\t\t\t\tinc_stats(zone, dns_zonestatscounter_ixfrreqv4);\n\t\t\telse\n\t\t\t\tinc_stats(zone, dns_zonestatscounter_ixfrreqv6);\n\t\t}\n\t\tUNLOCK_ZONE(zone);\n\t}\n cleanup:\n\t\/*\n\t * Any failure in this function is handled like a failed\n\t * zone transfer. This ensures that we get removed from\n\t * zmgr->xfrin_in_progress.\n\t *\/\n\tif (result != ISC_R_SUCCESS)\n\t\tzone_xfrdone(zone, result);\n\n\tisc_event_free(&event);\n}","target":0,"code_token_length":1514,"total_token_length":1750,"max_tokens_setting":2048} +{"idx":159404,"func":"static int addrconf_notify(struct notifier_block *this, unsigned long event,\n\t\t\t void *ptr)\n{\n\tstruct net_device *dev = netdev_notifier_info_to_dev(ptr);\n\tstruct inet6_dev *idev = __in6_dev_get(dev);\n\tint run_pending = 0;\n\tint err;\n\n\tswitch (event) {\n\tcase NETDEV_REGISTER:\n\t\tif (!idev && dev->mtu >= IPV6_MIN_MTU) {\n\t\t\tidev = ipv6_add_dev(dev);\n\t\t\tif (IS_ERR(idev))\n\t\t\t\treturn notifier_from_errno(PTR_ERR(idev));\n\t\t}\n\t\tbreak;\n\n\tcase NETDEV_UP:\n\tcase NETDEV_CHANGE:\n\t\tif (dev->flags & IFF_SLAVE)\n\t\t\tbreak;\n\n\t\tif (idev && idev->cnf.disable_ipv6)\n\t\t\tbreak;\n\n\t\tif (event == NETDEV_UP) {\n\t\t\tif (!addrconf_qdisc_ok(dev)) {\n\t\t\t\t\/* device is not ready yet. *\/\n\t\t\t\tpr_info(\"ADDRCONF(NETDEV_UP): %s: link is not ready\\n\",\n\t\t\t\t\tdev->name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!idev && dev->mtu >= IPV6_MIN_MTU)\n\t\t\t\tidev = ipv6_add_dev(dev);\n\n\t\t\tif (!IS_ERR_OR_NULL(idev)) {\n\t\t\t\tidev->if_flags |= IF_READY;\n\t\t\t\trun_pending = 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!addrconf_qdisc_ok(dev)) {\n\t\t\t\t\/* device is still not ready. *\/\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (idev) {\n\t\t\t\tif (idev->if_flags & IF_READY)\n\t\t\t\t\t\/* device is already configured. *\/\n\t\t\t\t\tbreak;\n\t\t\t\tidev->if_flags |= IF_READY;\n\t\t\t}\n\n\t\t\tpr_info(\"ADDRCONF(NETDEV_CHANGE): %s: link becomes ready\\n\",\n\t\t\t\tdev->name);\n\n\t\t\trun_pending = 1;\n\t\t}\n\n\t\tswitch (dev->type) {\n#if IS_ENABLED(CONFIG_IPV6_SIT)\n\t\tcase ARPHRD_SIT:\n\t\t\taddrconf_sit_config(dev);\n\t\t\tbreak;\n#endif\n#if IS_ENABLED(CONFIG_NET_IPGRE)\n\t\tcase ARPHRD_IPGRE:\n\t\t\taddrconf_gre_config(dev);\n\t\t\tbreak;\n#endif\n\t\tcase ARPHRD_LOOPBACK:\n\t\t\tinit_loopback(dev);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\taddrconf_dev_config(dev);\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!IS_ERR_OR_NULL(idev)) {\n\t\t\tif (run_pending)\n\t\t\t\taddrconf_dad_run(idev);\n\n\t\t\t\/*\n\t\t\t * If the MTU changed during the interface down,\n\t\t\t * when the interface up, the changed MTU must be\n\t\t\t * reflected in the idev as well as routers.\n\t\t\t *\/\n\t\t\tif (idev->cnf.mtu6 != dev->mtu &&\n\t\t\t dev->mtu >= IPV6_MIN_MTU) {\n\t\t\t\trt6_mtu_change(dev, dev->mtu);\n\t\t\t\tidev->cnf.mtu6 = dev->mtu;\n\t\t\t}\n\t\t\tidev->tstamp = jiffies;\n\t\t\tinet6_ifinfo_notify(RTM_NEWLINK, idev);\n\n\t\t\t\/*\n\t\t\t * If the changed mtu during down is lower than\n\t\t\t * IPV6_MIN_MTU stop IPv6 on this interface.\n\t\t\t *\/\n\t\t\tif (dev->mtu < IPV6_MIN_MTU)\n\t\t\t\taddrconf_ifdown(dev, 1);\n\t\t}\n\t\tbreak;\n\n\tcase NETDEV_CHANGEMTU:\n\t\tif (idev && dev->mtu >= IPV6_MIN_MTU) {\n\t\t\trt6_mtu_change(dev, dev->mtu);\n\t\t\tidev->cnf.mtu6 = dev->mtu;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!idev && dev->mtu >= IPV6_MIN_MTU) {\n\t\t\tidev = ipv6_add_dev(dev);\n\t\t\tif (!IS_ERR(idev))\n\t\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * if MTU under IPV6_MIN_MTU.\n\t\t * Stop IPv6 on this interface.\n\t\t *\/\n\n\tcase NETDEV_DOWN:\n\tcase NETDEV_UNREGISTER:\n\t\t\/*\n\t\t *\tRemove all addresses from this interface.\n\t\t *\/\n\t\taddrconf_ifdown(dev, event != NETDEV_DOWN);\n\t\tbreak;\n\n\tcase NETDEV_CHANGENAME:\n\t\tif (idev) {\n\t\t\tsnmp6_unregister_dev(idev);\n\t\t\taddrconf_sysctl_unregister(idev);\n\t\t\terr = addrconf_sysctl_register(idev);\n\t\t\tif (err)\n\t\t\t\treturn notifier_from_errno(err);\n\t\t\terr = snmp6_register_dev(idev);\n\t\t\tif (err) {\n\t\t\t\taddrconf_sysctl_unregister(idev);\n\t\t\t\treturn notifier_from_errno(err);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase NETDEV_PRE_TYPE_CHANGE:\n\tcase NETDEV_POST_TYPE_CHANGE:\n\t\taddrconf_type_change(dev, event);\n\t\tbreak;\n\t}\n\n\treturn NOTIFY_OK;\n}","target":0,"code_token_length":1031,"total_token_length":1267,"max_tokens_setting":2048} +{"idx":341363,"func":"static coroutine_fn int qcow_co_readv(BlockDriverState *bs, int64_t sector_num,\n\n int nb_sectors, QEMUIOVector *qiov)\n\n{\n\n BDRVQcowState *s = bs->opaque;\n\n int index_in_cluster;\n\n int ret = 0, n;\n\n uint64_t cluster_offset;\n\n struct iovec hd_iov;\n\n QEMUIOVector hd_qiov;\n\n uint8_t *buf;\n\n void *orig_buf;\n\n Error *err = NULL;\n\n\n\n if (qiov->niov > 1) {\n\n buf = orig_buf = qemu_try_blockalign(bs, qiov->size);\n\n if (buf == NULL) {\n\n return -ENOMEM;\n\n }\n\n } else {\n\n orig_buf = NULL;\n\n buf = (uint8_t *)qiov->iov->iov_base;\n\n }\n\n\n\n qemu_co_mutex_lock(&s->lock);\n\n\n\n while (nb_sectors != 0) {\n\n \/* prepare next request *\/\n\n cluster_offset = get_cluster_offset(bs, sector_num << 9,\n\n 0, 0, 0, 0);\n\n index_in_cluster = sector_num & (s->cluster_sectors - 1);\n\n n = s->cluster_sectors - index_in_cluster;\n\n if (n > nb_sectors) {\n\n n = nb_sectors;\n\n }\n\n\n\n if (!cluster_offset) {\n\n if (bs->backing) {\n\n \/* read from the base image *\/\n\n hd_iov.iov_base = (void *)buf;\n\n hd_iov.iov_len = n * 512;\n\n qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);\n\n qemu_co_mutex_unlock(&s->lock);\n\n ret = bdrv_co_readv(bs->backing, sector_num, n, &hd_qiov);\n\n qemu_co_mutex_lock(&s->lock);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n } else {\n\n \/* Note: in this case, no need to wait *\/\n\n memset(buf, 0, 512 * n);\n\n }\n\n } else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {\n\n \/* add AIO support for compressed blocks ? *\/\n\n if (decompress_cluster(bs, cluster_offset) < 0) {\n\n goto fail;\n\n }\n\n memcpy(buf,\n\n s->cluster_cache + index_in_cluster * 512, 512 * n);\n\n } else {\n\n if ((cluster_offset & 511) != 0) {\n\n goto fail;\n\n }\n\n hd_iov.iov_base = (void *)buf;\n\n hd_iov.iov_len = n * 512;\n\n qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);\n\n qemu_co_mutex_unlock(&s->lock);\n\n ret = bdrv_co_readv(bs->file,\n\n (cluster_offset >> 9) + index_in_cluster,\n\n n, &hd_qiov);\n\n qemu_co_mutex_lock(&s->lock);\n\n if (ret < 0) {\n\n break;\n\n }\n\n if (bs->encrypted) {\n\n assert(s->cipher);\n\n if (encrypt_sectors(s, sector_num, buf,\n\n n, false, &err) < 0) {\n\n goto fail;\n\n }\n\n }\n\n }\n\n ret = 0;\n\n\n\n nb_sectors -= n;\n\n sector_num += n;\n\n buf += n * 512;\n\n }\n\n\n\ndone:\n\n qemu_co_mutex_unlock(&s->lock);\n\n\n\n if (qiov->niov > 1) {\n\n qemu_iovec_from_buf(qiov, 0, orig_buf, qiov->size);\n\n qemu_vfree(orig_buf);\n\n }\n\n\n\n return ret;\n\n\n\nfail:\n\n error_free(err);\n\n ret = -EIO;\n\n goto done;\n\n}\n","target":0,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048} +{"idx":49438,"func":"static int snd_timer_user_params(struct file *file,\n\t\t\t\t struct snd_timer_params __user *_params)\n{\n\tstruct snd_timer_user *tu;\n\tstruct snd_timer_params params;\n\tstruct snd_timer *t;\n\tint err;\n\n\ttu = file->private_data;\n\tif (!tu->timeri)\n\t\treturn -EBADFD;\n\tt = tu->timeri->timer;\n\tif (!t)\n\t\treturn -EBADFD;\n\tif (copy_from_user(¶ms, _params, sizeof(params)))\n\t\treturn -EFAULT;\n\tif (!(t->hw.flags & SNDRV_TIMER_HW_SLAVE)) {\n\t\tu64 resolution;\n\n\t\tif (params.ticks < 1) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto _end;\n\t\t}\n\n\t\t\/* Don't allow resolution less than 1ms *\/\n\t\tresolution = snd_timer_resolution(tu->timeri);\n\t\tresolution *= params.ticks;\n\t\tif (resolution < 1000000) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto _end;\n\t\t}\n\t}\n\tif (params.queue_size > 0 &&\n\t (params.queue_size < 32 || params.queue_size > 1024)) {\n\t\terr = -EINVAL;\n\t\tgoto _end;\n\t}\n\tif (params.filter & ~((1<timeri);\n\tspin_lock_irq(&t->lock);\n\ttu->timeri->flags &= ~(SNDRV_TIMER_IFLG_AUTO|\n\t\t\t SNDRV_TIMER_IFLG_EXCLUSIVE|\n\t\t\t SNDRV_TIMER_IFLG_EARLY_EVENT);\n\tif (params.flags & SNDRV_TIMER_PSFLG_AUTO)\n\t\ttu->timeri->flags |= SNDRV_TIMER_IFLG_AUTO;\n\tif (params.flags & SNDRV_TIMER_PSFLG_EXCLUSIVE)\n\t\ttu->timeri->flags |= SNDRV_TIMER_IFLG_EXCLUSIVE;\n\tif (params.flags & SNDRV_TIMER_PSFLG_EARLY_EVENT)\n\t\ttu->timeri->flags |= SNDRV_TIMER_IFLG_EARLY_EVENT;\n\tspin_unlock_irq(&t->lock);\n\tif (params.queue_size > 0 &&\n\t (unsigned int)tu->queue_size != params.queue_size) {\n\t\terr = realloc_user_queue(tu, params.queue_size);\n\t\tif (err < 0)\n\t\t\tgoto _end;\n\t}\n\tspin_lock_irq(&tu->qlock);\n\ttu->qhead = tu->qtail = tu->qused = 0;\n\tif (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) {\n\t\tif (tu->tread) {\n\t\t\tstruct snd_timer_tread tread;\n\t\t\tmemset(&tread, 0, sizeof(tread));\n\t\t\ttread.event = SNDRV_TIMER_EVENT_EARLY;\n\t\t\ttread.tstamp.tv_sec = 0;\n\t\t\ttread.tstamp.tv_nsec = 0;\n\t\t\ttread.val = 0;\n\t\t\tsnd_timer_user_append_to_tqueue(tu, &tread);\n\t\t} else {\n\t\t\tstruct snd_timer_read *r = &tu->queue[0];\n\t\t\tr->resolution = 0;\n\t\t\tr->ticks = 0;\n\t\t\ttu->qused++;\n\t\t\ttu->qtail++;\n\t\t}\n\t}\n\ttu->filter = params.filter;\n\ttu->ticks = params.ticks;\n\tspin_unlock_irq(&tu->qlock);\n\terr = 0;\n _end:\n\tif (copy_to_user(_params, ¶ms, sizeof(params)))\n\t\treturn -EFAULT;\n\treturn err;\n}","target":0,"code_token_length":900,"total_token_length":1136,"max_tokens_setting":2048} +{"idx":304421,"func":" Status TrySimplify(NodeDef* node, string* simplified_node_name) override {\n Tensor pow;\n if (!GetTensorFromConstNode(node->input(1), &pow)) return Status::OK();\n complex128 prev, curr;\n for (int i = 0; i < pow.NumElements(); ++i) {\n if (!GetElementUnexhaustive(pow, i, {pow.dtype()}, &curr)) {\n \/\/ input data type is not supported by Pow. Skip.\n return Status::OK();\n }\n if (i != 0 && curr != prev) {\n \/\/ pow has different values on different elements. Skip.\n return Status::OK();\n }\n prev = curr;\n }\n NodeDef *x, *y;\n TF_RETURN_IF_ERROR(GetInputNode(node->input(0), &x));\n TF_RETURN_IF_ERROR(GetInputNode(node->input(1), &y));\n const auto& value_props =\n ctx().graph_properties->GetInputProperties(node->name())[0];\n const TensorShapeProto& output_shape =\n ctx().graph_properties->GetOutputProperties(node->name())[0].shape();\n if (curr == complex128(2, 0)) {\n node->set_op(\"Square\");\n node->set_input(1, AsControlDependency(y->name()));\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(y);\n } else if (curr == complex128(3, 0)) {\n \/\/ TODO(courbet): Use 'Cube' when it's added to TF ops.\n if (NodeIsOnCpu(*node)) {\n \/\/ We create an inner square node: inner_square = square(x)\n const NodeScopeAndName scope_and_name =\n ParseNodeScopeAndName(node->name());\n const string inner_square_name =\n OptimizedNodeName(scope_and_name, \"_inner\");\n NodeDef* inner_square_node = ctx().node_map->GetNode(inner_square_name);\n if (inner_square_node == nullptr) {\n inner_square_node = AddCopyNode(inner_square_name, node);\n inner_square_node->set_op(\"Square\");\n inner_square_node->mutable_input()->RemoveLast();\n }\n ctx().node_map->AddOutput(x->name(), inner_square_node->name());\n \/\/ We modify `node`: node = mul(x, inner_square);\n node->set_op(\"Mul\");\n node->set_input(1, inner_square_node->name());\n node->add_input(AsControlDependency(y->name()));\n\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(inner_square_node);\n AddToOptimizationQueue(y);\n }\n } else if (curr == complex128(1, 0) &&\n ShapesSymbolicallyEqual(value_props.shape(), output_shape)) {\n \/\/ Pow could be used to broadcast, so make sure the shapes of the two\n \/\/ arguments are identical before replacing Pow with Identity.\n node->set_op(\"Identity\");\n node->set_input(1, AsControlDependency(y->name()));\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(y);\n } else if (curr == complex128(0.5, 0)) {\n node->set_op(\"Sqrt\");\n node->set_input(1, AsControlDependency(y->name()));\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(y);\n } else if (curr == complex128(0, 0) &&\n ShapesSymbolicallyEqual(value_props.shape(), output_shape) &&\n PartialTensorShape(output_shape).IsFullyDefined()) {\n const auto dtype = node->attr().at(\"T\").type();\n Tensor ones(dtype, output_shape);\n for (int i = 0; i < ones.NumElements(); ++i) {\n TF_RETURN_IF_ERROR(SetElementToOne(i, &ones));\n }\n node->set_op(\"Const\");\n (*node->mutable_attr())[\"dtype\"].set_type(dtype);\n node->mutable_attr()->erase(\"T\");\n ones.AsProtoTensorContent(\n (*node->mutable_attr())[\"value\"].mutable_tensor());\n node->set_input(0, AsControlDependency(x->name()));\n node->set_input(1, AsControlDependency(y->name()));\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(x);\n AddToOptimizationQueue(y);\n } else if (curr == complex128(-0.5, 0)) {\n node->set_op(\"Rsqrt\");\n node->set_input(1, AsControlDependency(y->name()));\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(y);\n } else if (curr == complex128(-1, 0)) {\n node->set_op(\"Reciprocal\");\n node->set_input(1, AsControlDependency(y->name()));\n AddToOptimizationQueue(node);\n AddToOptimizationQueue(y);\n }\n return Status::OK();\n }","target":0,"code_token_length":1059,"total_token_length":1295,"max_tokens_setting":2048} +{"idx":211671,"func":"static int parseOptions(int argc, char **argv) {\n int i;\n\n for (i = 1; i < argc; i++) {\n int lastarg = i==argc-1;\n\n if (!strcmp(argv[i],\"-h\") && !lastarg) {\n sdsfree(config.hostip);\n config.hostip = sdsnew(argv[++i]);\n } else if (!strcmp(argv[i],\"-h\") && lastarg) {\n usage();\n } else if (!strcmp(argv[i],\"--help\")) {\n usage();\n } else if (!strcmp(argv[i],\"-x\")) {\n config.stdinarg = 1;\n } else if (!strcmp(argv[i],\"-p\") && !lastarg) {\n config.hostport = atoi(argv[++i]);\n } else if (!strcmp(argv[i],\"-s\") && !lastarg) {\n config.hostsocket = argv[++i];\n } else if (!strcmp(argv[i],\"-r\") && !lastarg) {\n config.repeat = strtoll(argv[++i],NULL,10);\n } else if (!strcmp(argv[i],\"-i\") && !lastarg) {\n double seconds = atof(argv[++i]);\n config.interval = seconds*1000000;\n } else if (!strcmp(argv[i],\"-n\") && !lastarg) {\n config.dbnum = atoi(argv[++i]);\n } else if (!strcmp(argv[i],\"-a\") && !lastarg) {\n fputs(\"Warning: Using a password with '-a' option on the command line interface may not be safe.\\n\", stderr);\n config.auth = argv[++i];\n } else if (!strcmp(argv[i],\"-u\") && !lastarg) {\n parseRedisUri(argv[++i]);\n } else if (!strcmp(argv[i],\"--raw\")) {\n config.output = OUTPUT_RAW;\n } else if (!strcmp(argv[i],\"--no-raw\")) {\n config.output = OUTPUT_STANDARD;\n } else if (!strcmp(argv[i],\"--csv\")) {\n config.output = OUTPUT_CSV;\n } else if (!strcmp(argv[i],\"--latency\")) {\n config.latency_mode = 1;\n } else if (!strcmp(argv[i],\"--latency-dist\")) {\n config.latency_dist_mode = 1;\n } else if (!strcmp(argv[i],\"--mono\")) {\n spectrum_palette = spectrum_palette_mono;\n spectrum_palette_size = spectrum_palette_mono_size;\n } else if (!strcmp(argv[i],\"--latency-history\")) {\n config.latency_mode = 1;\n config.latency_history = 1;\n } else if (!strcmp(argv[i],\"--lru-test\") && !lastarg) {\n config.lru_test_mode = 1;\n config.lru_test_sample_size = strtoll(argv[++i],NULL,10);\n } else if (!strcmp(argv[i],\"--slave\")) {\n config.slave_mode = 1;\n } else if (!strcmp(argv[i],\"--stat\")) {\n config.stat_mode = 1;\n } else if (!strcmp(argv[i],\"--scan\")) {\n config.scan_mode = 1;\n } else if (!strcmp(argv[i],\"--pattern\") && !lastarg) {\n config.pattern = argv[++i];\n } else if (!strcmp(argv[i],\"--intrinsic-latency\") && !lastarg) {\n config.intrinsic_latency_mode = 1;\n config.intrinsic_latency_duration = atoi(argv[++i]);\n } else if (!strcmp(argv[i],\"--rdb\") && !lastarg) {\n config.getrdb_mode = 1;\n config.rdb_filename = argv[++i];\n } else if (!strcmp(argv[i],\"--pipe\")) {\n config.pipe_mode = 1;\n } else if (!strcmp(argv[i],\"--pipe-timeout\") && !lastarg) {\n config.pipe_timeout = atoi(argv[++i]);\n } else if (!strcmp(argv[i],\"--bigkeys\")) {\n config.bigkeys = 1;\n } else if (!strcmp(argv[i],\"--hotkeys\")) {\n config.hotkeys = 1;\n } else if (!strcmp(argv[i],\"--eval\") && !lastarg) {\n config.eval = argv[++i];\n } else if (!strcmp(argv[i],\"--ldb\")) {\n config.eval_ldb = 1;\n config.output = OUTPUT_RAW;\n } else if (!strcmp(argv[i],\"--ldb-sync-mode\")) {\n config.eval_ldb = 1;\n config.eval_ldb_sync = 1;\n config.output = OUTPUT_RAW;\n } else if (!strcmp(argv[i],\"-c\")) {\n config.cluster_mode = 1;\n } else if (!strcmp(argv[i],\"-d\") && !lastarg) {\n sdsfree(config.mb_delim);\n config.mb_delim = sdsnew(argv[++i]);\n } else if (!strcmp(argv[i],\"-v\") || !strcmp(argv[i], \"--version\")) {\n sds version = cliVersion();\n printf(\"redis-cli %s\\n\", version);\n sdsfree(version);\n exit(0);\n } else {\n if (argv[i][0] == '-') {\n fprintf(stderr,\n \"Unrecognized option or bad number of args for: '%s'\\n\",\n argv[i]);\n exit(1);\n } else {\n \/* Likely the command name, stop here. *\/\n break;\n }\n }\n }\n\n \/* --ldb requires --eval. *\/\n if (config.eval_ldb && config.eval == NULL) {\n fprintf(stderr,\"Options --ldb and --ldb-sync-mode require --eval.\\n\");\n fprintf(stderr,\"Try %s --help for more information.\\n\", argv[0]);\n exit(1);\n }\n return i;\n}\n","target":0,"code_token_length":1211,"total_token_length":1447,"max_tokens_setting":2048} +{"idx":331603,"func":"static int vb_decode_framedata(VBDecContext *c, const uint8_t *buf, int offset)\n\n{\n\n uint8_t *prev, *cur;\n\n int blk, blocks, t, blk2;\n\n int blocktypes = 0;\n\n int x, y, a, b;\n\n int pattype, pattern;\n\n const int width = c->avctx->width;\n\n uint8_t *pstart = c->prev_frame;\n\n uint8_t *pend = c->prev_frame + width*c->avctx->height;\n\n\n\n prev = c->prev_frame + offset;\n\n cur = c->frame;\n\n\n\n blocks = (c->avctx->width >> 2) * (c->avctx->height >> 2);\n\n blk2 = 0;\n\n for(blk = 0; blk < blocks; blk++){\n\n if(!(blk & 3))\n\n blocktypes = bytestream_get_byte(&buf);\n\n switch(blocktypes & 0xC0){\n\n case 0x00: \/\/skip\n\n for(y = 0; y < 4; y++)\n\n if(check_line(prev + y*width, pstart, pend))\n\n memcpy(cur + y*width, prev + y*width, 4);\n\n else\n\n memset(cur + y*width, 0, 4);\n\n break;\n\n case 0x40:\n\n t = bytestream_get_byte(&buf);\n\n if(!t){ \/\/raw block\n\n for(y = 0; y < 4; y++)\n\n memcpy(cur + y*width, buf + y*4, 4);\n\n buf += 16;\n\n }else{ \/\/ motion compensation\n\n x = ((t & 0xF)^8) - 8;\n\n y = ((t >> 4) ^8) - 8;\n\n t = x + y*width;\n\n for(y = 0; y < 4; y++)\n\n if(check_line(prev + t + y*width, pstart, pend))\n\n memcpy(cur + y*width, prev + t + y*width, 4);\n\n else\n\n memset(cur + y*width, 0, 4);\n\n }\n\n break;\n\n case 0x80: \/\/ fill\n\n t = bytestream_get_byte(&buf);\n\n for(y = 0; y < 4; y++)\n\n memset(cur + y*width, t, 4);\n\n break;\n\n case 0xC0: \/\/ pattern fill\n\n t = bytestream_get_byte(&buf);\n\n pattype = t >> 6;\n\n pattern = vb_patterns[t & 0x3F];\n\n switch(pattype){\n\n case 0:\n\n a = bytestream_get_byte(&buf);\n\n b = bytestream_get_byte(&buf);\n\n for(y = 0; y < 4; y++)\n\n for(x = 0; x < 4; x++, pattern >>= 1)\n\n cur[x + y*width] = (pattern & 1) ? b : a;\n\n break;\n\n case 1:\n\n pattern = ~pattern;\n\n case 2:\n\n a = bytestream_get_byte(&buf);\n\n for(y = 0; y < 4; y++)\n\n for(x = 0; x < 4; x++, pattern >>= 1)\n\n if(pattern & 1 && check_pixel(prev + x + y*width, pstart, pend))\n\n cur[x + y*width] = prev[x + y*width];\n\n else\n\n cur[x + y*width] = a;\n\n break;\n\n case 3:\n\n av_log(c->avctx, AV_LOG_ERROR, \"Invalid opcode seen @%d\\n\",blk);\n\n return -1;\n\n }\n\n break;\n\n }\n\n blocktypes <<= 2;\n\n cur += 4;\n\n prev += 4;\n\n blk2++;\n\n if(blk2 == (width >> 2)){\n\n blk2 = 0;\n\n cur += width * 3;\n\n prev += width * 3;\n\n }\n\n }\n\n return 0;\n\n}\n","target":0,"code_token_length":873,"total_token_length":1109,"max_tokens_setting":2048} +{"idx":87089,"func":"static int init_shdr(ELFOBJ *bin) {\n\tut32 shdr_size;\n\tut8 shdr[sizeof (Elf_(Shdr))] = {0};\n\tint i, j, len;\n\n\tif (!bin || bin->shdr) {\n\t\treturn true;\n\t}\n\tif (!UT32_MUL (&shdr_size, bin->ehdr.e_shnum, sizeof (Elf_(Shdr)))) {\n\t\treturn false;\n\t}\n\tif (shdr_size < 1) {\n\t\treturn false;\n\t}\n\tif (shdr_size > bin->size) {\n\t\treturn false;\n\t}\n\tif (bin->ehdr.e_shoff > bin->size) {\n\t\treturn false;\n\t}\n\tif (bin->ehdr.e_shoff + shdr_size > bin->size) {\n\t\treturn false;\n\t}\n\tif (!(bin->shdr = calloc (1, shdr_size + 1))) {\n\t\tperror (\"malloc (shdr)\");\n\t\treturn false;\n\t}\n\tsdb_num_set (bin->kv, \"elf_shdr.offset\", bin->ehdr.e_shoff, 0);\n\tsdb_num_set (bin->kv, \"elf_shdr.size\", sizeof (Elf_(Shdr)), 0);\n\tsdb_set (bin->kv, \"elf_s_type.cparse\", \"enum elf_s_type {SHT_NULL=0,SHT_PROGBITS=1,\"\n\t\t\t\"SHT_SYMTAB=2,SHT_STRTAB=3,SHT_RELA=4,SHT_HASH=5,SHT_DYNAMIC=6,SHT_NOTE=7,\"\n\t\t\t\"SHT_NOBITS=8,SHT_REL=9,SHT_SHLIB=10,SHT_DYNSYM=11,SHT_LOOS=0x60000000,\"\n\t\t\t\"SHT_HIOS=0x6fffffff,SHT_LOPROC=0x70000000,SHT_HIPROC=0x7fffffff};\", 0);\n\n\tfor (i = 0; i < bin->ehdr.e_shnum; i++) {\n\t\tj = 0;\n\t\tlen = r_buf_read_at (bin->b, bin->ehdr.e_shoff + i * sizeof (Elf_(Shdr)), shdr, sizeof (Elf_(Shdr)));\n\t\tif (len < 1) {\n\t\t\tbprintf (\"Warning: read (shdr) at 0x%\"PFMT64x\"\\n\", (ut64) bin->ehdr.e_shoff);\n\t\t\tR_FREE (bin->shdr);\n\t\t\treturn false;\n\t\t}\n\t\tbin->shdr[i].sh_name = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_type = READ32 (shdr, j)\n#if R_BIN_ELF64\n\t\tbin->shdr[i].sh_flags = READ64 (shdr, j)\n\t\tbin->shdr[i].sh_addr = READ64 (shdr, j)\n\t\tbin->shdr[i].sh_offset = READ64 (shdr, j)\n\t\tbin->shdr[i].sh_size = READ64 (shdr, j)\n\t\tbin->shdr[i].sh_link = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_info = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_addralign = READ64 (shdr, j)\n\t\tbin->shdr[i].sh_entsize = READ64 (shdr, j)\n#else\n\t\tbin->shdr[i].sh_flags = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_addr = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_offset = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_size = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_link = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_info = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_addralign = READ32 (shdr, j)\n\t\tbin->shdr[i].sh_entsize = READ32 (shdr, j)\n#endif\n\t}\n\n#if R_BIN_ELF64\n\tsdb_set (bin->kv, \"elf_s_flags_64.cparse\", \"enum elf_s_flags_64 {SF64_None=0,SF64_Exec=1,\"\n\t\t\t\"SF64_Alloc=2,SF64_Alloc_Exec=3,SF64_Write=4,SF64_Write_Exec=5,\"\n\t\t\t\"SF64_Write_Alloc=6,SF64_Write_Alloc_Exec=7};\", 0);\n\tsdb_set (bin->kv, \"elf_shdr.format\", \"x[4]E[8]Eqqqxxqq name (elf_s_type)type\"\n\t\t\t\" (elf_s_flags_64)flags addr offset size link info addralign entsize\", 0);\n#else\n\tsdb_set (bin->kv, \"elf_s_flags_32.cparse\", \"enum elf_s_flags_32 {SF32_None=0,SF32_Exec=1,\"\n\t\t\t\"SF32_Alloc=2,SF32_Alloc_Exec=3,SF32_Write=4,SF32_Write_Exec=5,\"\n\t\t\t\"SF32_Write_Alloc=6,SF32_Write_Alloc_Exec=7};\", 0);\n\tsdb_set (bin->kv, \"elf_shdr.format\", \"x[4]E[4]Exxxxxxx name (elf_s_type)type\"\n\t\t\t\" (elf_s_flags_32)flags addr offset size link info addralign entsize\", 0);\n#endif\n\treturn true;\n\t\/\/ Usage example:\n\t\/\/ > td `k bin\/cur\/info\/elf_s_type.cparse`; td `k bin\/cur\/info\/elf_s_flags_64.cparse`\n\t\/\/ > pf `k bin\/cur\/info\/elf_shdr.format` @ `k bin\/cur\/info\/elf_shdr.offset`\n}","target":0,"code_token_length":1340,"total_token_length":1576,"max_tokens_setting":2048} +{"idx":499784,"func":"QPDFWriter::writeTrailer(trailer_e which, int size, bool xref_stream,\n qpdf_offset_t prev, int linearization_pass)\n{\n QPDFObjectHandle trailer = getTrimmedTrailer();\n if (! xref_stream)\n {\n\twriteString(\"trailer <<\");\n }\n writeStringQDF(\"\\n\");\n if (which == t_lin_second)\n {\n\twriteString(\" \/Size \");\n\twriteString(QUtil::int_to_string(size));\n }\n else\n {\n\tstd::set keys = trailer.getKeys();\n\tfor (std::set::iterator iter = keys.begin();\n\t iter != keys.end(); ++iter)\n\t{\n\t std::string const& key = *iter;\n\t writeStringQDF(\" \");\n\t writeStringNoQDF(\" \");\n\t writeString(QPDF_Name::normalizeName(key));\n\t writeString(\" \");\n\t if (key == \"\/Size\")\n\t {\n\t\twriteString(QUtil::int_to_string(size));\n\t\tif (which == t_lin_first)\n\t\t{\n\t\t writeString(\" \/Prev \");\n\t\t qpdf_offset_t pos = this->m->pipeline->getCount();\n\t\t writeString(QUtil::int_to_string(prev));\n\t\t int nspaces =\n QIntC::to_int(pos - this->m->pipeline->getCount() + 21);\n\t\t if (nspaces < 0)\n {\n throw std::logic_error(\n \"QPDFWriter: no padding required in trailer\");\n }\n\t\t writePad(nspaces);\n\t\t}\n\t }\n\t else\n\t {\n\t\tunparseChild(trailer.getKey(key), 1, 0);\n\t }\n\t writeStringQDF(\"\\n\");\n\t}\n }\n\n \/\/ Write ID\n writeStringQDF(\" \");\n writeString(\" \/ID [\");\n if (linearization_pass == 1)\n {\n\tstd::string original_id1 = getOriginalID1();\n if (original_id1.empty())\n {\n writeString(\"<00000000000000000000000000000000>\");\n }\n else\n {\n \/\/ Write a string of zeroes equal in length to the\n \/\/ representation of the original ID. While writing the\n \/\/ original ID would have the same number of bytes, it\n \/\/ would cause a change to the deterministic ID generated\n \/\/ by older versions of the software that hard-coded the\n \/\/ length of the ID to 16 bytes.\n writeString(\"<\");\n size_t len = QPDF_String(original_id1).unparse(true).length() - 2;\n for (size_t i = 0; i < len; ++i)\n {\n writeString(\"0\");\n }\n writeString(\">\");\n }\n writeString(\"<00000000000000000000000000000000>\");\n }\n else\n {\n if ((linearization_pass == 0) && (this->m->deterministic_id))\n {\n computeDeterministicIDData();\n }\n generateID();\n writeString(QPDF_String(this->m->id1).unparse(true));\n writeString(QPDF_String(this->m->id2).unparse(true));\n }\n writeString(\"]\");\n\n if (which != t_lin_second)\n {\n\t\/\/ Write reference to encryption dictionary\n\tif (this->m->encrypted)\n\t{\n\t writeString(\" \/Encrypt \");\n\t writeString(QUtil::int_to_string(this->m->encryption_dict_objid));\n\t writeString(\" 0 R\");\n\t}\n }\n\n writeStringQDF(\"\\n\");\n writeStringNoQDF(\" \");\n writeString(\">>\");\n}","target":0,"code_token_length":806,"total_token_length":1042,"max_tokens_setting":2048} +{"idx":293526,"func":"i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,\n\t\t\t\t struct eb_objects *eb,\n\t\t\t\t struct drm_i915_gem_relocation_entry *reloc)\n{\n\tstruct drm_device *dev = obj->base.dev;\n\tstruct drm_gem_object *target_obj;\n\tuint32_t target_offset;\n\tint ret = -EINVAL;\n\n\t\/* we've already hold a reference to all valid objects *\/\n\ttarget_obj = &eb_get_object(eb, reloc->target_handle)->base;\n\tif (unlikely(target_obj == NULL))\n\t\treturn -ENOENT;\n\n\ttarget_offset = to_intel_bo(target_obj)->gtt_offset;\n\n\t\/* The target buffer should have appeared before us in the\n\t * exec_object list, so it should have a GTT space bound by now.\n\t *\/\n\tif (unlikely(target_offset == 0)) {\n\t\tDRM_DEBUG(\"No GTT space found for object %d\\n\",\n\t\t\t reloc->target_handle);\n\t\treturn ret;\n\t}\n\n\t\/* Validate that the target is in a valid r\/w GPU domain *\/\n\tif (unlikely(reloc->write_domain & (reloc->write_domain - 1))) {\n\t\tDRM_DEBUG(\"reloc with multiple write domains: \"\n\t\t\t \"obj %p target %d offset %d \"\n\t\t\t \"read %08x write %08x\",\n\t\t\t obj, reloc->target_handle,\n\t\t\t (int) reloc->offset,\n\t\t\t reloc->read_domains,\n\t\t\t reloc->write_domain);\n\t\treturn ret;\n\t}\n\tif (unlikely((reloc->write_domain | reloc->read_domains)\n\t\t & ~I915_GEM_GPU_DOMAINS)) {\n\t\tDRM_DEBUG(\"reloc with read\/write non-GPU domains: \"\n\t\t\t \"obj %p target %d offset %d \"\n\t\t\t \"read %08x write %08x\",\n\t\t\t obj, reloc->target_handle,\n\t\t\t (int) reloc->offset,\n\t\t\t reloc->read_domains,\n\t\t\t reloc->write_domain);\n\t\treturn ret;\n\t}\n\tif (unlikely(reloc->write_domain && target_obj->pending_write_domain &&\n\t\t reloc->write_domain != target_obj->pending_write_domain)) {\n\t\tDRM_DEBUG(\"Write domain conflict: \"\n\t\t\t \"obj %p target %d offset %d \"\n\t\t\t \"new %08x old %08x\\n\",\n\t\t\t obj, reloc->target_handle,\n\t\t\t (int) reloc->offset,\n\t\t\t reloc->write_domain,\n\t\t\t target_obj->pending_write_domain);\n\t\treturn ret;\n\t}\n\n\ttarget_obj->pending_read_domains |= reloc->read_domains;\n\ttarget_obj->pending_write_domain |= reloc->write_domain;\n\n\t\/* If the relocation already has the right value in it, no\n\t * more work needs to be done.\n\t *\/\n\tif (target_offset == reloc->presumed_offset)\n\t\treturn 0;\n\n\t\/* Check that the relocation address is valid... *\/\n\tif (unlikely(reloc->offset > obj->base.size - 4)) {\n\t\tDRM_DEBUG(\"Relocation beyond object bounds: \"\n\t\t\t \"obj %p target %d offset %d size %d.\\n\",\n\t\t\t obj, reloc->target_handle,\n\t\t\t (int) reloc->offset,\n\t\t\t (int) obj->base.size);\n\t\treturn ret;\n\t}\n\tif (unlikely(reloc->offset & 3)) {\n\t\tDRM_DEBUG(\"Relocation not 4-byte aligned: \"\n\t\t\t \"obj %p target %d offset %d.\\n\",\n\t\t\t obj, reloc->target_handle,\n\t\t\t (int) reloc->offset);\n\t\treturn ret;\n\t}\n\n\treloc->delta += target_offset;\n\tif (obj->base.write_domain == I915_GEM_DOMAIN_CPU) {\n\t\tuint32_t page_offset = reloc->offset & ~PAGE_MASK;\n\t\tchar *vaddr;\n\n\t\tvaddr = kmap_atomic(obj->pages[reloc->offset >> PAGE_SHIFT]);\n\t\t*(uint32_t *)(vaddr + page_offset) = reloc->delta;\n\t\tkunmap_atomic(vaddr);\n\t} else {\n\t\tstruct drm_i915_private *dev_priv = dev->dev_private;\n\t\tuint32_t __iomem *reloc_entry;\n\t\tvoid __iomem *reloc_page;\n\n\t\t\/* We can't wait for rendering with pagefaults disabled *\/\n\t\tif (obj->active && in_atomic())\n\t\t\treturn -EFAULT;\n\n\t\tret = i915_gem_object_set_to_gtt_domain(obj, 1);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/* Map the page containing the relocation we're going to perform. *\/\n\t\treloc->offset += obj->gtt_offset;\n\t\treloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,\n\t\t\t\t\t\t reloc->offset & PAGE_MASK);\n\t\treloc_entry = (uint32_t __iomem *)\n\t\t\t(reloc_page + (reloc->offset & ~PAGE_MASK));\n\t\tiowrite32(reloc->delta, reloc_entry);\n\t\tio_mapping_unmap_atomic(reloc_page);\n\t}\n\n\t\/* and update the user's relocation entry *\/\n\treloc->presumed_offset = target_offset;\n\n\treturn 0;\n}","target":0,"code_token_length":1073,"total_token_length":1309,"max_tokens_setting":2048} +{"idx":348946,"func":"static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev)\n{\n\tstruct device_node *np = dev->of_node;\n\tstruct device_node *pp;\n\tstruct ad5755_platform_data *pdata;\n\tunsigned int tmp;\n\tunsigned int tmparray[3];\n\tint devnr, i;\n\n\tpdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);\n\tif (!pdata)\n\t\treturn NULL;\n\n\tpdata->ext_dc_dc_compenstation_resistor =\n\t of_property_read_bool(np, \"adi,ext-dc-dc-compenstation-resistor\");\n\n\tif (!of_property_read_u32(np, \"adi,dc-dc-phase\", &tmp))\n\t\tpdata->dc_dc_phase = tmp;\n\telse\n\t\tpdata->dc_dc_phase = AD5755_DC_DC_PHASE_ALL_SAME_EDGE;\n\n\tpdata->dc_dc_freq = AD5755_DC_DC_FREQ_410kHZ;\n\tif (!of_property_read_u32(np, \"adi,dc-dc-freq-hz\", &tmp)) {\n\t\tfor (i = 0; i < ARRAY_SIZE(ad5755_dcdc_freq_table); i++) {\n\t\t\tif (tmp == ad5755_dcdc_freq_table[i][0]) {\n\t\t\t\tpdata->dc_dc_freq = ad5755_dcdc_freq_table[i][1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (i == ARRAY_SIZE(ad5755_dcdc_freq_table)) {\n\t\t\tdev_err(dev,\n\t\t\t\t\"adi,dc-dc-freq out of range selecting 410kHz\");\n\t\t}\n\t}\n\n\tpdata->dc_dc_maxv = AD5755_DC_DC_MAXV_23V;\n\tif (!of_property_read_u32(np, \"adi,dc-dc-max-microvolt\", &tmp)) {\n\t\tfor (i = 0; i < ARRAY_SIZE(ad5755_dcdc_maxv_table); i++) {\n\t\t\tif (tmp == ad5755_dcdc_maxv_table[i][0]) {\n\t\t\t\tpdata->dc_dc_maxv = ad5755_dcdc_maxv_table[i][1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i == ARRAY_SIZE(ad5755_dcdc_maxv_table)) {\n\t\t\t\tdev_err(dev,\n\t\t\t\t\t\"adi,dc-dc-maxv out of range selecting 23V\");\n\t\t}\n\t}\n\n\tdevnr = 0;\n\tfor_each_child_of_node(np, pp) {\n\t\tif (devnr > AD5755_NUM_CHANNELS) {\n\t\t\tdev_err(dev,\n\t\t\t\t\"There is to many channels defined in DT\\n\");\n\t\t\tgoto error_out;\n\t\t}\n\n\t\tif (!of_property_read_u32(pp, \"adi,mode\", &tmp))\n\t\t\tpdata->dac[devnr].mode = tmp;\n\t\telse\n\t\t\tpdata->dac[devnr].mode = AD5755_MODE_CURRENT_4mA_20mA;\n\n\t\tpdata->dac[devnr].ext_current_sense_resistor =\n\t\t of_property_read_bool(pp, \"adi,ext-current-sense-resistor\");\n\n\t\tpdata->dac[devnr].enable_voltage_overrange =\n\t\t of_property_read_bool(pp, \"adi,enable-voltage-overrange\");\n\n\t\tif (!of_property_read_u32_array(pp, \"adi,slew\", tmparray, 3)) {\n\t\t\tpdata->dac[devnr].slew.enable = tmparray[0];\n\n\t\t\tpdata->dac[devnr].slew.rate = AD5755_SLEW_RATE_64k;\n\t\t\tfor (i = 0; i < ARRAY_SIZE(ad5755_slew_rate_table); i++) {\n\t\t\t\tif (tmparray[1] == ad5755_slew_rate_table[i][0]) {\n\t\t\t\t\tpdata->dac[devnr].slew.rate =\n\t\t\t\t\t\tad5755_slew_rate_table[i][1];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i == ARRAY_SIZE(ad5755_slew_rate_table)) {\n\t\t\t\tdev_err(dev,\n\t\t\t\t\t\"channel %d slew rate out of range selecting 64kHz\",\n\t\t\t\t\tdevnr);\n\t\t\t}\n\n\t\t\tpdata->dac[devnr].slew.step_size = AD5755_SLEW_STEP_SIZE_1;\n\t\t\tfor (i = 0; i < ARRAY_SIZE(ad5755_slew_step_table); i++) {\n\t\t\t\tif (tmparray[2] == ad5755_slew_step_table[i][0]) {\n\t\t\t\t\tpdata->dac[devnr].slew.step_size =\n\t\t\t\t\t\tad5755_slew_step_table[i][1];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i == ARRAY_SIZE(ad5755_slew_step_table)) {\n\t\t\t\tdev_err(dev,\n\t\t\t\t\t\"channel %d slew step size out of range selecting 1 LSB\",\n\t\t\t\t\tdevnr);\n\t\t\t}\n\t\t} else {\n\t\t\tpdata->dac[devnr].slew.enable = false;\n\t\t\tpdata->dac[devnr].slew.rate = AD5755_SLEW_RATE_64k;\n\t\t\tpdata->dac[devnr].slew.step_size =\n\t\t\t AD5755_SLEW_STEP_SIZE_1;\n\t\t}\n\t\tdevnr++;\n\t}\n\n\treturn pdata;\n\n error_out:\n\tdevm_kfree(dev, pdata);\n\treturn NULL;\n}","target":1,"code_token_length":1163,"total_token_length":1399,"max_tokens_setting":2048} +{"idx":266793,"func":"FUNC_DECODER(dissector_postgresql)\n{\n DECLARE_DISP_PTR(ptr);\n struct ec_session *s = NULL;\n void *ident = NULL;\n char tmp[MAX_ASCII_ADDR_LEN];\n struct postgresql_status *conn_status;\n\n \/* don't complain about unused var *\/\n (void) DECODE_DATA; \n (void) DECODE_DATALEN;\n (void) DECODED_LEN;\n \n if (FROM_CLIENT(\"postgresql\", PACKET)) {\n if (PACKET->DATA.len < 4)\n return NULL;\n\n dissect_create_ident(&ident, PACKET, DISSECT_CODE(dissector_postgresql));\n\n \/* if the session does not exist... *\/\n if (session_get(&s, ident, DISSECT_IDENT_LEN) == -ENOTFOUND) {\n \/* search for user and database strings, look for StartupMessage *\/\n unsigned char *u = memmem(ptr, PACKET->DATA.len, \"user\", 4);\n unsigned char *d = memmem(ptr, PACKET->DATA.len, \"database\", 8);\n if (!memcmp(ptr + 4, \"\\x00\\x03\\x00\\x00\", 4) && u && d) {\n \/* create the new session *\/\n dissect_create_session(&s, PACKET, DISSECT_CODE(dissector_postgresql));\n\n \/* remember the state (used later) *\/\n SAFE_CALLOC(s->data, 1, sizeof(struct postgresql_status));\n\n conn_status = (struct postgresql_status *) s->data;\n conn_status->status = WAIT_AUTH;\n\n \/* user is always null-terminated *\/\n strncpy((char*)conn_status->user, (char*)(u + 5), 65);\n conn_status->user[64] = 0;\n\n \/* database is always null-terminated *\/\n strncpy((char*)conn_status->database, (char*)(d + 9), 65);\n conn_status->database[64] = 0;\n\n \/* save the session *\/\n session_put(s);\n }\n } else {\n conn_status = (struct postgresql_status *) s->data;\n if (conn_status->status == WAIT_RESPONSE) {\n\n \/* check for PasswordMessage packet *\/\n if (ptr[0] == 'p' && conn_status->type == MD5) {\n DEBUG_MSG(\"\\tDissector_postgresql RESPONSE type is MD5\");\n if(memcmp(ptr + 1, \"\\x00\\x00\\x00\\x28\", 4)) {\n DEBUG_MSG(\"\\tDissector_postgresql BUG, expected length is 40\");\n return NULL;\n }\n if (PACKET->DATA.len < 40) {\n DEBUG_MSG(\"\\tDissector_postgresql BUG, expected length is 40\");\n return NULL;\n }\n memcpy(conn_status->hash, ptr + 5 + 3, 32);\n conn_status->hash[32] = 0;\n DISSECT_MSG(\"%s:$postgres$%s*%s*%s:%s:%d\\n\", conn_status->user, conn_status->user, conn_status->salt, conn_status->hash, ip_addr_ntoa(&PACKET->L3.dst, tmp), ntohs(PACKET->L4.dst));\n dissect_wipe_session(PACKET, DISSECT_CODE(dissector_postgresql));\n }\n else if (ptr[0] == 'p' && conn_status->type == CT) {\n int length;\n DEBUG_MSG(\"\\tDissector_postgresql RESPONSE type is clear-text!\");\n GET_ULONG_BE(length, ptr, 1);\n length -= 4;\n if (length < 0 || length > 65 || PACKET->DATA.len < length+5) {\n dissect_wipe_session(PACKET, DISSECT_CODE(dissector_postgresql));\n return NULL;\n }\n snprintf((char*)conn_status->password, length+1, \"%s\", (char*)(ptr + 5));\n DISSECT_MSG(\"PostgreSQL credentials:%s-%d:%s:%s\\n\", ip_addr_ntoa(&PACKET->L3.dst, tmp), ntohs(PACKET->L4.dst), conn_status->user, conn_status->password);\n dissect_wipe_session(PACKET, DISSECT_CODE(dissector_postgresql));\n }\n }\n }\n } else { \/* Packets coming from the server *\/\n if (PACKET->DATA.len < 9)\n return NULL;\n dissect_create_ident(&ident, PACKET, DISSECT_CODE(dissector_postgresql));\n\n if (session_get(&s, ident, DISSECT_IDENT_LEN) == ESUCCESS) {\n conn_status = (struct postgresql_status *) s->data;\n if (conn_status->status == WAIT_AUTH &&\n ptr[0] == 'R' && !memcmp(ptr + 1, \"\\x00\\x00\\x00\\x0c\", 4) &&\n !memcmp(ptr + 5, \"\\x00\\x00\\x00\\x05\", 4)) {\n\n conn_status->status = WAIT_RESPONSE;\n\n conn_status->type = MD5;\n DEBUG_MSG(\"\\tDissector_postgresql AUTH type is MD5\");\n hex_encode(ptr + 9, 4, conn_status->salt); \/* save salt *\/\n }\n else if (conn_status->status == WAIT_AUTH &&\n ptr[0] == 'R' && !memcmp(ptr + 1, \"\\x00\\x00\\x00\\x08\", 4) &&\n !memcmp(ptr + 5, \"\\x00\\x00\\x00\\x03\", 4)) {\n conn_status->status = WAIT_RESPONSE;\n conn_status->type = CT;\n DEBUG_MSG(\"\\tDissector_postgresql AUTH type is clear-text!\");\n }\n }\n }\n\n SAFE_FREE(ident);\n return NULL;\n}","target":0,"code_token_length":1251,"total_token_length":1487,"max_tokens_setting":2048} +{"idx":183031,"func":"static MagickBooleanType EncodeImage(const ImageInfo *image_info,Image *image,\n const size_t data_size)\n{\n#define MaxCode(number_bits) ((one << (number_bits))-1)\n#define MaxHashTable 5003\n#define MaxGIFBits 12UL\n#define MaxGIFTable (1UL << MaxGIFBits)\n#define GIFOutputCode(code) \\\n{ \\\n \/* \\\n Emit a code. \\\n *\/ \\\n if (bits > 0) \\\n datum|=(code) << bits; \\\n else \\\n datum=code; \\\n bits+=number_bits; \\\n while (bits >= 8) \\\n { \\\n \/* \\\n Add a character to current packet. \\\n *\/ \\\n packet[length++]=(unsigned char) (datum & 0xff); \\\n if (length >= 254) \\\n { \\\n (void) WriteBlobByte(image,(unsigned char) length); \\\n (void) WriteBlob(image,length,packet); \\\n length=0; \\\n } \\\n datum>>=8; \\\n bits-=8; \\\n } \\\n if (free_code > max_code) \\\n { \\\n number_bits++; \\\n if (number_bits == MaxGIFBits) \\\n max_code=MaxGIFTable; \\\n else \\\n max_code=MaxCode(number_bits); \\\n } \\\n}\n\n IndexPacket\n index;\n\n register ssize_t\n i;\n\n short\n *hash_code,\n *hash_prefix,\n waiting_code;\n\n size_t\n bits,\n clear_code,\n datum,\n end_of_information_code,\n free_code,\n length,\n max_code,\n next_pixel,\n number_bits,\n one,\n pass;\n\n ssize_t\n displacement,\n offset,\n k,\n y;\n\n unsigned char\n *packet,\n *hash_suffix;\n\n \/*\n Allocate encoder tables.\n *\/\n assert(image != (Image *) NULL);\n one=1;\n packet=(unsigned char *) AcquireQuantumMemory(256,sizeof(*packet));\n hash_code=(short *) AcquireQuantumMemory(MaxHashTable,sizeof(*hash_code));\n hash_prefix=(short *) AcquireQuantumMemory(MaxHashTable,sizeof(*hash_prefix));\n hash_suffix=(unsigned char *) AcquireQuantumMemory(MaxHashTable,\n sizeof(*hash_suffix));\n if ((packet == (unsigned char *) NULL) || (hash_code == (short *) NULL) ||\n (hash_prefix == (short *) NULL) ||\n (hash_suffix == (unsigned char *) NULL))\n {\n if (packet != (unsigned char *) NULL)\n packet=(unsigned char *) RelinquishMagickMemory(packet);\n if (hash_code != (short *) NULL)\n hash_code=(short *) RelinquishMagickMemory(hash_code);\n if (hash_prefix != (short *) NULL)\n hash_prefix=(short *) RelinquishMagickMemory(hash_prefix);\n if (hash_suffix != (unsigned char *) NULL)\n hash_suffix=(unsigned char *) RelinquishMagickMemory(hash_suffix);\n return(MagickFalse);\n }\n \/*\n Initialize GIF encoder.\n *\/\n number_bits=data_size;\n max_code=MaxCode(number_bits);\n clear_code=((short) one << (data_size-1));\n end_of_information_code=clear_code+1;\n free_code=clear_code+2;\n length=0;\n datum=0;\n bits=0;\n for (i=0; i < MaxHashTable; i++)\n hash_code[i]=0;\n GIFOutputCode(clear_code);\n \/*\n Encode pixels.\n *\/\n offset=0;\n pass=0;\n waiting_code=0;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n register const IndexPacket\n *restrict indexes;\n\n register const PixelPacket\n *restrict p;\n\n register ssize_t\n x;\n\n p=GetVirtualPixels(image,0,offset,image->columns,1,&image->exception);\n if (p == (const PixelPacket *) NULL)\n break;\n indexes=GetVirtualIndexQueue(image);\n if (y == 0)\n waiting_code=(short) (*indexes);\n for (x=(ssize_t) (y == 0 ? 1 : 0); x < (ssize_t) image->columns; x++)\n {\n \/*\n Probe hash table.\n *\/\n index=(IndexPacket) ((size_t) GetPixelIndex(indexes+x) & 0xff);\n p++;\n k=(ssize_t) (((size_t) index << (MaxGIFBits-8))+waiting_code);\n if (k >= MaxHashTable)\n k-=MaxHashTable;\n next_pixel=MagickFalse;\n displacement=1;\n if (hash_code[k] > 0)\n {\n if ((hash_prefix[k] == waiting_code) &&\n (hash_suffix[k] == (unsigned char) index))\n {\n waiting_code=hash_code[k];\n continue;\n }\n if (k != 0)\n displacement=MaxHashTable-k;\n for ( ; ; )\n {\n k-=displacement;\n if (k < 0)\n k+=MaxHashTable;\n if (hash_code[k] == 0)\n break;\n if ((hash_prefix[k] == waiting_code) &&\n (hash_suffix[k] == (unsigned char) index))\n {\n waiting_code=hash_code[k];\n next_pixel=MagickTrue;\n break;\n }\n }\n if (next_pixel != MagickFalse)\n continue;\n }\n GIFOutputCode((size_t) waiting_code);\n if (free_code < MaxGIFTable)\n {\n hash_code[k]=(short) free_code++;\n hash_prefix[k]=waiting_code;\n hash_suffix[k]=(unsigned char) index;\n }\n else\n {\n \/*\n Fill the hash table with empty entries.\n *\/\n for (k=0; k < MaxHashTable; k++)\n hash_code[k]=0;\n \/*\n Reset compressor and issue a clear code.\n *\/\n free_code=clear_code+2;\n GIFOutputCode(clear_code);\n number_bits=data_size;\n max_code=MaxCode(number_bits);\n }\n waiting_code=(short) index;\n }\n if (image_info->interlace == NoInterlace)\n offset++;\n else\n switch (pass)\n {\n case 0:\n default:\n {\n offset+=8;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=4;\n }\n break;\n }\n case 1:\n {\n offset+=8;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=2;\n }\n break;\n }\n case 2:\n {\n offset+=4;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=1;\n }\n break;\n }\n case 3:\n {\n offset+=2;\n break;\n }\n }\n }\n \/*\n Flush out the buffered code.\n *\/\n GIFOutputCode((size_t) waiting_code);\n GIFOutputCode(end_of_information_code);\n if (bits > 0)\n {\n \/*\n Add a character to current packet.\n *\/\n packet[length++]=(unsigned char) (datum & 0xff);\n if (length >= 254)\n {\n (void) WriteBlobByte(image,(unsigned char) length);\n (void) WriteBlob(image,length,packet);\n length=0;\n }\n }\n \/*\n Flush accumulated data.\n *\/\n if (length > 0)\n {\n (void) WriteBlobByte(image,(unsigned char) length);\n (void) WriteBlob(image,length,packet);\n }\n \/*\n Free encoder memory.\n *\/\n hash_suffix=(unsigned char *) RelinquishMagickMemory(hash_suffix);\n hash_prefix=(short *) RelinquishMagickMemory(hash_prefix);\n hash_code=(short *) RelinquishMagickMemory(hash_code);\n packet=(unsigned char *) RelinquishMagickMemory(packet);\n return(MagickTrue);\n}\n","target":0,"code_token_length":1761,"total_token_length":1997,"max_tokens_setting":2048} +{"idx":348152,"func":"ks_http_fetch (ctrl_t ctrl, const char *url, unsigned int flags,\n estream_t *r_fp)\n{\n gpg_error_t err;\n http_session_t session = NULL;\n unsigned int session_flags;\n http_t http = NULL;\n int redirects_left = MAX_REDIRECTS;\n estream_t fp = NULL;\n char *request_buffer = NULL;\n parsed_uri_t uri = NULL;\n int is_onion, is_https;\n\n err = http_parse_uri (&uri, url, 0);\n if (err)\n goto leave;\n is_onion = uri->onion;\n is_https = uri->use_tls;\n\n \/* By default we only use the system provided certificates with this\n * fetch command. *\/\n session_flags = HTTP_FLAG_TRUST_SYS;\n if ((flags & KS_HTTP_FETCH_NO_CRL) || ctrl->http_no_crl)\n session_flags |= HTTP_FLAG_NO_CRL;\n if ((flags & KS_HTTP_FETCH_TRUST_CFG))\n session_flags |= HTTP_FLAG_TRUST_CFG;\n\n once_more:\n err = http_session_new (&session, NULL, session_flags,\n gnupg_http_tls_verify_cb, ctrl);\n if (err)\n goto leave;\n http_session_set_log_cb (session, cert_log_cb);\n http_session_set_timeout (session, ctrl->timeout);\n\n *r_fp = NULL;\n err = http_open (&http,\n HTTP_REQ_GET,\n url,\n \/* httphost *\/ NULL,\n \/* fixme: AUTH *\/ NULL,\n ((opt.honor_http_proxy? HTTP_FLAG_TRY_PROXY:0)\n | (DBG_LOOKUP? HTTP_FLAG_LOG_RESP:0)\n | (dirmngr_use_tor ()? HTTP_FLAG_FORCE_TOR:0)\n | (opt.disable_ipv4? HTTP_FLAG_IGNORE_IPv4 : 0)\n | (opt.disable_ipv6? HTTP_FLAG_IGNORE_IPv6 : 0)),\n ctrl->http_proxy,\n session,\n NULL,\n \/*FIXME curl->srvtag*\/NULL);\n if (!err)\n {\n fp = http_get_write_ptr (http);\n \/* Avoid caches to get the most recent copy of the key. We set\n * both the Pragma and Cache-Control versions of the header, so\n * we're good with both HTTP 1.0 and 1.1. *\/\n if ((flags & KS_HTTP_FETCH_NOCACHE))\n es_fputs (\"Pragma: no-cache\\r\\n\"\n \"Cache-Control: no-cache\\r\\n\", fp);\n http_start_data (http);\n if (es_ferror (fp))\n err = gpg_error_from_syserror ();\n }\n if (err)\n {\n \/* Fixme: After a redirection we show the old host name. *\/\n log_error (_(\"error connecting to '%s': %s\\n\"),\n url, gpg_strerror (err));\n goto leave;\n }\n\n \/* Wait for the response. *\/\n dirmngr_tick (ctrl);\n err = http_wait_response (http);\n if (err)\n {\n log_error (_(\"error reading HTTP response for '%s': %s\\n\"),\n url, gpg_strerror (err));\n goto leave;\n }\n\n switch (http_get_status_code (http))\n {\n case 200:\n err = 0;\n break; \/* Success. *\/\n\n case 301:\n case 302:\n case 307:\n {\n const char *s = http_get_header (http, \"Location\");\n\n log_info (_(\"URL '%s' redirected to '%s' (%u)\\n\"),\n url, s?s:\"[none]\", http_get_status_code (http));\n if (s && *s && redirects_left-- )\n {\n if (is_onion || is_https)\n {\n \/* Make sure that an onion address only redirects to\n * another onion address, or that a https address\n * only redirects to a https address. *\/\n http_release_parsed_uri (uri);\n uri = NULL;\n err = http_parse_uri (&uri, s, 0);\n if (err)\n goto leave;\n\n if (is_onion && !uri->onion)\n {\n err = gpg_error (GPG_ERR_FORBIDDEN);\n goto leave;\n }\n if (!(flags & KS_HTTP_FETCH_ALLOW_DOWNGRADE)\n && is_https && !uri->use_tls)\n {\n err = gpg_error (GPG_ERR_FORBIDDEN);\n goto leave;\n }\n }\n\n xfree (request_buffer);\n request_buffer = xtrystrdup (s);\n if (request_buffer)\n {\n url = request_buffer;\n http_close (http, 0);\n http = NULL;\n http_session_release (session);\n goto once_more;\n }\n err = gpg_error_from_syserror ();\n }\n else\n err = gpg_error (GPG_ERR_NO_DATA);\n log_error (_(\"too many redirections\\n\"));\n }\n goto leave;\n\n default:\n log_error (_(\"error accessing '%s': http status %u\\n\"),\n url, http_get_status_code (http));\n err = gpg_error (GPG_ERR_NO_DATA);\n goto leave;\n }\n\n fp = http_get_read_ptr (http);\n if (!fp)\n {\n err = gpg_error (GPG_ERR_BUG);\n goto leave;\n }\n\n \/* Return the read stream and close the HTTP context. *\/\n *r_fp = fp;\n http_close (http, 1);\n http = NULL;\n\n leave:\n http_close (http, 0);\n http_session_release (session);\n xfree (request_buffer);\n http_release_parsed_uri (uri);\n return err;\n}","target":1,"code_token_length":1231,"total_token_length":1467,"max_tokens_setting":2048} +{"idx":63838,"func":"static int jit_subprogs(struct bpf_verifier_env *env)\n{\n\tstruct bpf_prog *prog = env->prog, **func, *tmp;\n\tint i, j, subprog_start, subprog_end = 0, len, subprog;\n\tstruct bpf_insn *insn;\n\tvoid *old_bpf_func;\n\tint err = -ENOMEM;\n\n\tif (env->subprog_cnt <= 1)\n\t\treturn 0;\n\n\tfor (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) {\n\t\tif (insn->code != (BPF_JMP | BPF_CALL) ||\n\t\t insn->src_reg != BPF_PSEUDO_CALL)\n\t\t\tcontinue;\n\t\t\/* Upon error here we cannot fall back to interpreter but\n\t\t * need a hard reject of the program. Thus -EFAULT is\n\t\t * propagated in any case.\n\t\t *\/\n\t\tsubprog = find_subprog(env, i + insn->imm + 1);\n\t\tif (subprog < 0) {\n\t\t\tWARN_ONCE(1, \"verifier bug. No program starts at insn %d\\n\",\n\t\t\t\t i + insn->imm + 1);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\t\/* temporarily remember subprog id inside insn instead of\n\t\t * aux_data, since next loop will split up all insns into funcs\n\t\t *\/\n\t\tinsn->off = subprog;\n\t\t\/* remember original imm in case JIT fails and fallback\n\t\t * to interpreter will be needed\n\t\t *\/\n\t\tenv->insn_aux_data[i].call_imm = insn->imm;\n\t\t\/* point imm to __bpf_call_base+1 from JITs point of view *\/\n\t\tinsn->imm = 1;\n\t}\n\n\tfunc = kcalloc(env->subprog_cnt, sizeof(prog), GFP_KERNEL);\n\tif (!func)\n\t\tgoto out_undo_insn;\n\n\tfor (i = 0; i < env->subprog_cnt; i++) {\n\t\tsubprog_start = subprog_end;\n\t\tsubprog_end = env->subprog_info[i + 1].start;\n\n\t\tlen = subprog_end - subprog_start;\n\t\tfunc[i] = bpf_prog_alloc(bpf_prog_size(len), GFP_USER);\n\t\tif (!func[i])\n\t\t\tgoto out_free;\n\t\tmemcpy(func[i]->insnsi, &prog->insnsi[subprog_start],\n\t\t len * sizeof(struct bpf_insn));\n\t\tfunc[i]->type = prog->type;\n\t\tfunc[i]->len = len;\n\t\tif (bpf_prog_calc_tag(func[i]))\n\t\t\tgoto out_free;\n\t\tfunc[i]->is_func = 1;\n\t\t\/* Use bpf_prog_F_tag to indicate functions in stack traces.\n\t\t * Long term would need debug info to populate names\n\t\t *\/\n\t\tfunc[i]->aux->name[0] = 'F';\n\t\tfunc[i]->aux->stack_depth = env->subprog_info[i].stack_depth;\n\t\tfunc[i]->jit_requested = 1;\n\t\tfunc[i] = bpf_int_jit_compile(func[i]);\n\t\tif (!func[i]->jited) {\n\t\t\terr = -ENOTSUPP;\n\t\t\tgoto out_free;\n\t\t}\n\t\tcond_resched();\n\t}\n\t\/* at this point all bpf functions were successfully JITed\n\t * now populate all bpf_calls with correct addresses and\n\t * run last pass of JIT\n\t *\/\n\tfor (i = 0; i < env->subprog_cnt; i++) {\n\t\tinsn = func[i]->insnsi;\n\t\tfor (j = 0; j < func[i]->len; j++, insn++) {\n\t\t\tif (insn->code != (BPF_JMP | BPF_CALL) ||\n\t\t\t insn->src_reg != BPF_PSEUDO_CALL)\n\t\t\t\tcontinue;\n\t\t\tsubprog = insn->off;\n\t\t\tinsn->imm = (u64 (*)(u64, u64, u64, u64, u64))\n\t\t\t\tfunc[subprog]->bpf_func -\n\t\t\t\t__bpf_call_base;\n\t\t}\n\n\t\t\/* we use the aux data to keep a list of the start addresses\n\t\t * of the JITed images for each function in the program\n\t\t *\n\t\t * for some architectures, such as powerpc64, the imm field\n\t\t * might not be large enough to hold the offset of the start\n\t\t * address of the callee's JITed image from __bpf_call_base\n\t\t *\n\t\t * in such cases, we can lookup the start address of a callee\n\t\t * by using its subprog id, available from the off field of\n\t\t * the call instruction, as an index for this list\n\t\t *\/\n\t\tfunc[i]->aux->func = func;\n\t\tfunc[i]->aux->func_cnt = env->subprog_cnt;\n\t}\n\tfor (i = 0; i < env->subprog_cnt; i++) {\n\t\told_bpf_func = func[i]->bpf_func;\n\t\ttmp = bpf_int_jit_compile(func[i]);\n\t\tif (tmp != func[i] || func[i]->bpf_func != old_bpf_func) {\n\t\t\tverbose(env, \"JIT doesn't support bpf-to-bpf calls\\n\");\n\t\t\terr = -ENOTSUPP;\n\t\t\tgoto out_free;\n\t\t}\n\t\tcond_resched();\n\t}\n\n\t\/* finally lock prog and jit images for all functions and\n\t * populate kallsysm\n\t *\/\n\tfor (i = 0; i < env->subprog_cnt; i++) {\n\t\tbpf_prog_lock_ro(func[i]);\n\t\tbpf_prog_kallsyms_add(func[i]);\n\t}\n\n\t\/* Last step: make now unused interpreter insns from main\n\t * prog consistent for later dump requests, so they can\n\t * later look the same as if they were interpreted only.\n\t *\/\n\tfor (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) {\n\t\tif (insn->code != (BPF_JMP | BPF_CALL) ||\n\t\t insn->src_reg != BPF_PSEUDO_CALL)\n\t\t\tcontinue;\n\t\tinsn->off = env->insn_aux_data[i].call_imm;\n\t\tsubprog = find_subprog(env, i + insn->off + 1);\n\t\tinsn->imm = subprog;\n\t}\n\n\tprog->jited = 1;\n\tprog->bpf_func = func[0]->bpf_func;\n\tprog->aux->func = func;\n\tprog->aux->func_cnt = env->subprog_cnt;\n\treturn 0;\nout_free:\n\tfor (i = 0; i < env->subprog_cnt; i++)\n\t\tif (func[i])\n\t\t\tbpf_jit_free(func[i]);\n\tkfree(func);\nout_undo_insn:\n\t\/* cleanup main prog to be interpreted *\/\n\tprog->jit_requested = 0;\n\tfor (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) {\n\t\tif (insn->code != (BPF_JMP | BPF_CALL) ||\n\t\t insn->src_reg != BPF_PSEUDO_CALL)\n\t\t\tcontinue;\n\t\tinsn->off = 0;\n\t\tinsn->imm = env->insn_aux_data[i].call_imm;\n\t}\n\treturn err;\n}","target":0,"code_token_length":1527,"total_token_length":1763,"max_tokens_setting":2048} +{"idx":440225,"func":"add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)\n{\n#define ASCII_LIMIT 127\n\n int c, r;\n int ascii_mode;\n int is_single;\n const OnigCodePoint *ranges;\n OnigCodePoint limit;\n OnigCodePoint sb_out;\n OnigEncoding enc = env->enc;\n\n ascii_mode = IS_ASCII_MODE_CTYPE_OPTION(ctype, env->options);\n\n r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &sb_out, &ranges);\n if (r == 0) {\n if (ascii_mode == 0)\n r = add_ctype_to_cc_by_range(cc, ctype, not, env->enc, sb_out, ranges);\n else\n r = add_ctype_to_cc_by_range_limit(cc, ctype, not, env->enc, sb_out,\n ranges, ASCII_LIMIT);\n return r;\n }\n else if (r != ONIG_NO_SUPPORT_CONFIG) {\n return r;\n }\n\n r = 0;\n is_single = ONIGENC_IS_SINGLEBYTE(enc);\n limit = ascii_mode ? ASCII_LIMIT : SINGLE_BYTE_SIZE;\n\n switch (ctype) {\n case ONIGENC_CTYPE_ALPHA:\n case ONIGENC_CTYPE_BLANK:\n case ONIGENC_CTYPE_CNTRL:\n case ONIGENC_CTYPE_DIGIT:\n case ONIGENC_CTYPE_LOWER:\n case ONIGENC_CTYPE_PUNCT:\n case ONIGENC_CTYPE_SPACE:\n case ONIGENC_CTYPE_UPPER:\n case ONIGENC_CTYPE_XDIGIT:\n case ONIGENC_CTYPE_ASCII:\n case ONIGENC_CTYPE_ALNUM:\n if (not != 0) {\n for (c = 0; c < (int )limit; c++) {\n if (is_single != 0 || ONIGENC_CODE_TO_MBCLEN(enc, c) == 1) {\n if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))\n BITSET_SET_BIT(cc->bs, c);\n }\n }\n for (c = limit; c < SINGLE_BYTE_SIZE; c++) {\n if (is_single != 0 || ONIGENC_CODE_TO_MBCLEN(enc, c) == 1)\n BITSET_SET_BIT(cc->bs, c);\n }\n\n if (is_single == 0)\n ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);\n }\n else {\n for (c = 0; c < (int )limit; c++) {\n if (is_single != 0 || ONIGENC_CODE_TO_MBCLEN(enc, c) == 1) {\n if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))\n BITSET_SET_BIT(cc->bs, c);\n }\n }\n }\n break;\n\n case ONIGENC_CTYPE_GRAPH:\n case ONIGENC_CTYPE_PRINT:\n case ONIGENC_CTYPE_WORD:\n if (not != 0) {\n for (c = 0; c < (int )limit; c++) {\n \/* check invalid code point *\/\n if ((is_single != 0 || ONIGENC_CODE_TO_MBCLEN(enc, c) == 1)\n && ! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))\n BITSET_SET_BIT(cc->bs, c);\n }\n for (c = limit; c < SINGLE_BYTE_SIZE; c++) {\n if (is_single != 0 || ONIGENC_CODE_TO_MBCLEN(enc, c) == 1)\n BITSET_SET_BIT(cc->bs, c);\n }\n if (ascii_mode != 0 && is_single == 0)\n ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);\n }\n else {\n for (c = 0; c < (int )limit; c++) {\n if ((is_single != 0 || ONIGENC_CODE_TO_MBCLEN(enc, c) == 1)\n && ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))\n BITSET_SET_BIT(cc->bs, c);\n }\n if (ascii_mode == 0 && is_single == 0)\n ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);\n }\n break;\n\n default:\n return ONIGERR_PARSER_BUG;\n break;\n }\n\n return r;\n}","target":0,"code_token_length":962,"total_token_length":1198,"max_tokens_setting":2048} +{"idx":413579,"func":"static void _rpc_prolog(slurm_msg_t *msg)\n{\n\tint rc = SLURM_SUCCESS;\n\tprolog_launch_msg_t *req = (prolog_launch_msg_t *)msg->data;\n\tjob_env_t job_env;\n\tbool first_job_run;\n\tuid_t req_uid;\n\n\tif (req == NULL)\n\t\treturn;\n\n\treq_uid = g_slurm_auth_get_uid(msg->auth_cred, conf->auth_info);\n\tif (!_slurm_authorized_user(req_uid)) {\n\t\terror(\"REQUEST_LAUNCH_PROLOG request from uid %u\",\n\t\t (unsigned int) req_uid);\n\t\treturn;\n\t}\n\n\tif (!req->user_name)\n\t\treq->user_name = uid_to_string(req->uid);\n\n\tif (slurm_send_rc_msg(msg, rc) < 0) {\n\t\terror(\"Error starting prolog: %m\");\n\t}\n\tif (rc) {\n\t\tint term_sig, exit_status;\n\t\tif (WIFSIGNALED(rc)) {\n\t\t\texit_status = 0;\n\t\t\tterm_sig = WTERMSIG(rc);\n\t\t} else {\n\t\t\texit_status = WEXITSTATUS(rc);\n\t\t\tterm_sig = 0;\n\t\t}\n\t\terror(\"[job %u] prolog start failed status=%d:%d\",\n\t\t req->job_id, exit_status, term_sig);\n\t\trc = ESLURMD_PROLOG_FAILED;\n\t}\n\n\tslurm_mutex_lock(&prolog_mutex);\n\tfirst_job_run = !slurm_cred_jobid_cached(conf->vctx, req->job_id);\n\tif (first_job_run) {\n\t\tif (slurmctld_conf.prolog_flags & PROLOG_FLAG_CONTAIN)\n\t\t\t_make_prolog_mem_container(msg);\n\n\t\tif (container_g_create(req->job_id))\n\t\t\terror(\"container_g_create(%u): %m\", req->job_id);\n\n\t\tslurm_cred_insert_jobid(conf->vctx, req->job_id);\n\t\t_add_job_running_prolog(req->job_id);\n\t\tslurm_mutex_unlock(&prolog_mutex);\n\n\t\tmemset(&job_env, 0, sizeof(job_env_t));\n\n\t\tjob_env.jobid = req->job_id;\n\t\tjob_env.step_id = 0;\t\/* not available *\/\n\t\tjob_env.node_list = req->nodes;\n\t\tjob_env.partition = req->partition;\n\t\tjob_env.spank_job_env = req->spank_job_env;\n\t\tjob_env.spank_job_env_size = req->spank_job_env_size;\n\t\tjob_env.uid = req->uid;\n\t\tjob_env.user_name = req->user_name;\n#if defined(HAVE_BG)\n\t\tselect_g_select_jobinfo_get(req->select_jobinfo,\n\t\t\t\t\t SELECT_JOBDATA_BLOCK_ID,\n\t\t\t\t\t &job_env.resv_id);\n#elif defined(HAVE_ALPS_CRAY)\n\t\tjob_env.resv_id = select_g_select_jobinfo_xstrdup(\n\t\t\treq->select_jobinfo, SELECT_PRINT_RESV_ID);\n#endif\n\t\trc = _run_prolog(&job_env, req->cred);\n\n\t\tif (rc) {\n\t\t\tint term_sig, exit_status;\n\t\t\tif (WIFSIGNALED(rc)) {\n\t\t\t\texit_status = 0;\n\t\t\t\tterm_sig = WTERMSIG(rc);\n\t\t\t} else {\n\t\t\t\texit_status = WEXITSTATUS(rc);\n\t\t\t\tterm_sig = 0;\n\t\t\t}\n\t\t\terror(\"[job %u] prolog failed status=%d:%d\",\n\t\t\t req->job_id, exit_status, term_sig);\n\t\t\trc = ESLURMD_PROLOG_FAILED;\n\t\t}\n\t} else\n\t\tslurm_mutex_unlock(&prolog_mutex);\n\n\tif (!(slurmctld_conf.prolog_flags & PROLOG_FLAG_NOHOLD))\n\t\t_notify_slurmctld_prolog_fini(req->job_id, rc);\n\n\tif (rc == SLURM_SUCCESS) {\n\t\tif (slurmctld_conf.prolog_flags & PROLOG_FLAG_CONTAIN)\n\t\t\t_spawn_prolog_stepd(msg);\n\t} else {\n\t\t_launch_job_fail(req->job_id, rc);\n\t\tsend_registration_msg(rc, false);\n\t}\n}","target":0,"code_token_length":842,"total_token_length":1078,"max_tokens_setting":2048} +{"idx":10246,"func":" tt_cmap14_validate( FT_Byte* table,\n FT_Validator valid )\n {\n FT_Byte* p;\n FT_ULong length;\n FT_ULong num_selectors;\n\n\n if ( table + 2 + 4 + 4 > valid->limit )\n FT_INVALID_TOO_SHORT;\n\n p = table + 2;\n length = TT_NEXT_ULONG( p );\n num_selectors = TT_NEXT_ULONG( p );\n\n if ( length > (FT_ULong)( valid->limit - table ) ||\n \/* length < 10 + 11 * num_selectors ? *\/\n length < 10 ||\n ( length - 10 ) \/ 11 < num_selectors )\n FT_INVALID_TOO_SHORT;\n\n \/* check selectors, they must be in increasing order *\/\n {\n \/* we start lastVarSel at 1 because a variant selector value of 0\n * isn't valid.\n *\/\n FT_ULong n, lastVarSel = 1;\n\n\n for ( n = 0; n < num_selectors; n++ )\n {\n FT_ULong varSel = TT_NEXT_UINT24( p );\n FT_ULong defOff = TT_NEXT_ULONG( p );\n FT_ULong nondefOff = TT_NEXT_ULONG( p );\n\n\n if ( defOff >= length || nondefOff >= length )\n FT_INVALID_TOO_SHORT;\n\n if ( varSel < lastVarSel )\n FT_INVALID_DATA;\n\n lastVarSel = varSel + 1;\n\n \/* check the default table (these glyphs should be reached *\/\n \/* through the normal Unicode cmap, no GIDs, just check order) *\/\n if ( defOff != 0 )\n {\n FT_Byte* defp = table + defOff;\n FT_ULong numRanges = TT_NEXT_ULONG( defp );\n FT_ULong i;\n FT_ULong lastBase = 0;\n \n \n \/* defp + numRanges * 4 > valid->limit ? *\/\n if ( numRanges > (FT_ULong)( valid->limit - defp ) \/ 4 )\n FT_INVALID_TOO_SHORT;\n\n\n if ( base + cnt >= 0x110000UL ) \/* end of Unicode *\/\n FT_INVALID_DATA;\n\n if ( base < lastBase )\n FT_INVALID_DATA;\n\n lastBase = base + cnt + 1U;\n }\n }\n\n \/* and the non-default table (these glyphs are specified here) *\/\n if ( nondefOff != 0 )\n {\n FT_Byte* ndp = table + nondefOff;\n FT_ULong numMappings = TT_NEXT_ULONG( ndp );\n \/* and the non-default table (these glyphs are specified here) *\/\n if ( nondefOff != 0 )\n {\n FT_Byte* ndp = table + nondefOff;\n FT_ULong numMappings = TT_NEXT_ULONG( ndp );\n FT_ULong i, lastUni = 0;\n \n \n \/* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? *\/\n if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) \/ 4 )\n FT_INVALID_TOO_SHORT;\n \n for ( i = 0; i < numMappings; ++i )\n\n lastUni = uni + 1U;\n\n if ( valid->level >= FT_VALIDATE_TIGHT &&\n gid >= TT_VALID_GLYPH_COUNT( valid ) )\n FT_INVALID_GLYPH_ID;\n }\n }\n }\n }\n","target":1,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048} +{"idx":365332,"func":"str_gsub(argc, argv, str, bang)\n int argc;\n VALUE *argv;\n VALUE str;\n int bang;\n{\n VALUE pat, val, repl, match, dest;\n struct re_registers *regs;\n long beg, n;\n long offset, blen, slen, len;\n int iter = 0;\n char *buf, *bp, *sp, *cp;\n int tainted = 0;\n\n if (argc == 1) {\n RETURN_ENUMERATOR(str, argc, argv);\n\titer = 1;\n }\n else if (argc == 2) {\n\trepl = argv[1];\n\tStringValue(repl);\n\tif (OBJ_TAINTED(repl)) tainted = 1;\n }\n else {\n\trb_raise(rb_eArgError, \"wrong number of arguments (%d for 2)\", argc);\n }\n\n pat = get_pat(argv[0], 1);\n offset=0; n=0;\n beg = rb_reg_search(pat, str, 0, 0);\n if (beg < 0) {\n\tif (bang) return Qnil;\t\/* no match, no substitution *\/\n\treturn rb_str_dup(str);\n }\n\n blen = RSTRING(str)->len + 30; \/* len + margin *\/\n dest = str_new(0, 0, blen);\n buf = RSTRING(dest)->ptr;\n bp = buf;\n sp = cp = RSTRING(str)->ptr;\n slen = RSTRING(str)->len;\n\n rb_str_locktmp(dest);\n while (beg >= 0) {\n\tn++;\n\tmatch = rb_backref_get();\n\tregs = RMATCH(match)->regs;\n\tif (iter) {\n\t rb_match_busy(match);\n\t val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));\n\t str_mod_check(str, sp, slen);\n\t if (bang) str_frozen_check(str);\n\t if (val == dest) { \/* paranoid chack [ruby-dev:24827] *\/\n\t\trb_raise(rb_eRuntimeError, \"block should not cheat\");\n\t }\n\t rb_backref_set(match);\n\t}\n\telse {\n\t val = rb_reg_regsub(repl, str, regs);\n\t}\n\tif (OBJ_TAINTED(val)) tainted = 1;\n\tlen = (bp - buf) + (beg - offset) + RSTRING(val)->len + 3;\n\tif (blen < len) {\n\t while (blen < len) blen *= 2;\n\t len = bp - buf;\n\t RESIZE_CAPA(dest, blen);\n\t RSTRING(dest)->len = blen;\n\t buf = RSTRING(dest)->ptr;\n\t bp = buf + len;\n\t}\n\tlen = beg - offset;\t\/* copy pre-match substr *\/\n\tmemcpy(bp, cp, len);\n\tbp += len;\n\tmemcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);\n\tbp += RSTRING(val)->len;\n\toffset = END(0);\n\tif (BEG(0) == END(0)) {\n\t \/*\n\t * Always consume at least one character of the input string\n\t * in order to prevent infinite loops.\n\t *\/\n\t if (RSTRING(str)->len <= END(0)) break;\n\t len = mbclen2(RSTRING(str)->ptr[END(0)], pat);\n\t memcpy(bp, RSTRING(str)->ptr+END(0), len);\n\t bp += len;\n\t offset = END(0) + len;\n\t}\n\tcp = RSTRING(str)->ptr + offset;\n\tif (offset > RSTRING(str)->len) break;\n\tbeg = rb_reg_search(pat, str, offset, 0);\n }\n if (RSTRING(str)->len > offset) {\n\tlen = bp - buf;\n\tif (blen - len < RSTRING(str)->len - offset) {\n\t blen = len + RSTRING(str)->len - offset;\n\t RESIZE_CAPA(dest, blen);\n\t buf = RSTRING(dest)->ptr;\n\t bp = buf + len;\n\t}\n\tmemcpy(bp, cp, RSTRING(str)->len - offset);\n\tbp += RSTRING(str)->len - offset;\n }\n rb_backref_set(match);\n *bp = '\\0';\n rb_str_unlocktmp(dest);\n if (bang) {\n\tif (str_independent(str)) {\n\t free(RSTRING(str)->ptr);\n\t}\n\tFL_UNSET(str, STR_NOCAPA);\n\tRSTRING(str)->ptr = buf;\n\tRSTRING(str)->aux.capa = blen;\n\tRSTRING(dest)->ptr = 0;\n\tRSTRING(dest)->len = 0;\n }\n else {\n\tRBASIC(dest)->klass = rb_obj_class(str);\n\tOBJ_INFECT(dest, str);\n\tstr = dest;\n }\n RSTRING(str)->len = bp - buf;\n\n if (tainted) OBJ_TAINT(str);\n return str;\n}","target":0,"code_token_length":1030,"total_token_length":1266,"max_tokens_setting":2048} +{"idx":87898,"func":"int __kvm_set_memory_region(struct kvm *kvm,\n\t\t\t const struct kvm_userspace_memory_region *mem)\n{\n\tint r;\n\tgfn_t base_gfn;\n\tunsigned long npages;\n\tstruct kvm_memory_slot *slot;\n\tstruct kvm_memory_slot old, new;\n\tstruct kvm_memslots *slots = NULL, *old_memslots;\n\tint as_id, id;\n\tenum kvm_mr_change change;\n\n\tr = check_memory_region_flags(mem);\n\tif (r)\n\t\tgoto out;\n\n\tr = -EINVAL;\n\tas_id = mem->slot >> 16;\n\tid = (u16)mem->slot;\n\n\t\/* General sanity checks *\/\n\tif (mem->memory_size & (PAGE_SIZE - 1))\n\t\tgoto out;\n\tif (mem->guest_phys_addr & (PAGE_SIZE - 1))\n\t\tgoto out;\n\t\/* We can read the guest memory with __xxx_user() later on. *\/\n\tif ((id < KVM_USER_MEM_SLOTS) &&\n\t ((mem->userspace_addr & (PAGE_SIZE - 1)) ||\n\t !access_ok((void __user *)(unsigned long)mem->userspace_addr,\n\t\t\tmem->memory_size)))\n\t\tgoto out;\n\tif (as_id >= KVM_ADDRESS_SPACE_NUM || id >= KVM_MEM_SLOTS_NUM)\n\t\tgoto out;\n\tif (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr)\n\t\tgoto out;\n\n\tslot = id_to_memslot(__kvm_memslots(kvm, as_id), id);\n\tbase_gfn = mem->guest_phys_addr >> PAGE_SHIFT;\n\tnpages = mem->memory_size >> PAGE_SHIFT;\n\n\tif (npages > KVM_MEM_MAX_NR_PAGES)\n\t\tgoto out;\n\n\tnew = old = *slot;\n\n\tnew.id = id;\n\tnew.base_gfn = base_gfn;\n\tnew.npages = npages;\n\tnew.flags = mem->flags;\n\n\tif (npages) {\n\t\tif (!old.npages)\n\t\t\tchange = KVM_MR_CREATE;\n\t\telse { \/* Modify an existing slot. *\/\n\t\t\tif ((mem->userspace_addr != old.userspace_addr) ||\n\t\t\t (npages != old.npages) ||\n\t\t\t ((new.flags ^ old.flags) & KVM_MEM_READONLY))\n\t\t\t\tgoto out;\n\n\t\t\tif (base_gfn != old.base_gfn)\n\t\t\t\tchange = KVM_MR_MOVE;\n\t\t\telse if (new.flags != old.flags)\n\t\t\t\tchange = KVM_MR_FLAGS_ONLY;\n\t\t\telse { \/* Nothing to change. *\/\n\t\t\t\tr = 0;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (!old.npages)\n\t\t\tgoto out;\n\n\t\tchange = KVM_MR_DELETE;\n\t\tnew.base_gfn = 0;\n\t\tnew.flags = 0;\n\t}\n\n\tif ((change == KVM_MR_CREATE) || (change == KVM_MR_MOVE)) {\n\t\t\/* Check for overlaps *\/\n\t\tr = -EEXIST;\n\t\tkvm_for_each_memslot(slot, __kvm_memslots(kvm, as_id)) {\n\t\t\tif (slot->id == id)\n\t\t\t\tcontinue;\n\t\t\tif (!((base_gfn + npages <= slot->base_gfn) ||\n\t\t\t (base_gfn >= slot->base_gfn + slot->npages)))\n\t\t\t\tgoto out;\n\t\t}\n\t}\n\n\t\/* Free page dirty bitmap if unneeded *\/\n\tif (!(new.flags & KVM_MEM_LOG_DIRTY_PAGES))\n\t\tnew.dirty_bitmap = NULL;\n\n\tr = -ENOMEM;\n\tif (change == KVM_MR_CREATE) {\n\t\tnew.userspace_addr = mem->userspace_addr;\n\n\t\tif (kvm_arch_create_memslot(kvm, &new, npages))\n\t\t\tgoto out_free;\n\t}\n\n\t\/* Allocate page dirty bitmap if needed *\/\n\tif ((new.flags & KVM_MEM_LOG_DIRTY_PAGES) && !new.dirty_bitmap) {\n\t\tif (kvm_create_dirty_bitmap(&new) < 0)\n\t\t\tgoto out_free;\n\t}\n\n\tslots = kvzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);\n\tif (!slots)\n\t\tgoto out_free;\n\tmemcpy(slots, __kvm_memslots(kvm, as_id), sizeof(struct kvm_memslots));\n\n\tif ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) {\n\t\tslot = id_to_memslot(slots, id);\n\t\tslot->flags |= KVM_MEMSLOT_INVALID;\n\n\t\told_memslots = install_new_memslots(kvm, as_id, slots);\n\n\t\t\/* From this point no new shadow pages pointing to a deleted,\n\t\t * or moved, memslot will be created.\n\t\t *\n\t\t * validation of sp->gfn happens in:\n\t\t *\t- gfn_to_hva (kvm_read_guest, gfn_to_pfn)\n\t\t *\t- kvm_is_visible_gfn (mmu_check_roots)\n\t\t *\/\n\t\tkvm_arch_flush_shadow_memslot(kvm, slot);\n\n\t\t\/*\n\t\t * We can re-use the old_memslots from above, the only difference\n\t\t * from the currently installed memslots is the invalid flag. This\n\t\t * will get overwritten by update_memslots anyway.\n\t\t *\/\n\t\tslots = old_memslots;\n\t}\n\n\tr = kvm_arch_prepare_memory_region(kvm, &new, mem, change);\n\tif (r)\n\t\tgoto out_slots;\n\n\t\/* actual memory is freed via old in kvm_free_memslot below *\/\n\tif (change == KVM_MR_DELETE) {\n\t\tnew.dirty_bitmap = NULL;\n\t\tmemset(&new.arch, 0, sizeof(new.arch));\n\t}\n\n\tupdate_memslots(slots, &new, change);\n\told_memslots = install_new_memslots(kvm, as_id, slots);\n\n\tkvm_arch_commit_memory_region(kvm, mem, &old, &new, change);\n\n\tkvm_free_memslot(kvm, &old, &new);\n\tkvfree(old_memslots);\n\treturn 0;\n\nout_slots:\n\tkvfree(slots);\nout_free:\n\tkvm_free_memslot(kvm, &new, &old);\nout:\n\treturn r;\n}","target":0,"code_token_length":1234,"total_token_length":1470,"max_tokens_setting":2048} +{"idx":445873,"func":"exif_data_load_data_content (ExifData *data, ExifIfd ifd,\n\t\t\t const unsigned char *d,\n\t\t\t unsigned int ds, unsigned int offset, unsigned int recursion_cost)\n{\n\tExifLong o, thumbnail_offset = 0, thumbnail_length = 0;\n\tExifShort n;\n\tExifEntry *entry;\n\tunsigned int i;\n\tExifTag tag;\n\n\tif (!data || !data->priv) \n\t\treturn;\n\n\t\/* check for valid ExifIfd enum range *\/\n\tif ((((int)ifd) < 0) || ( ((int)ifd) >= EXIF_IFD_COUNT))\n\t return;\n\n\tif (recursion_cost > 170) {\n\t\t\/*\n\t\t * recursion_cost is a logarithmic-scale indicator of how expensive this\n\t\t * recursive call might end up being. It is an indicator of the depth of\n\t\t * recursion as well as the potential for worst-case future recursive\n\t\t * calls. Since it's difficult to tell ahead of time how often recursion\n\t\t * will occur, this assumes the worst by assuming every tag could end up\n\t\t * causing recursion.\n\t\t * The value of 170 was chosen to limit typical EXIF structures to a\n\t\t * recursive depth of about 6, but pathological ones (those with very\n\t\t * many tags) to only 2.\n\t\t *\/\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, \"ExifData\",\n\t\t\t \"Deep\/expensive recursion detected!\");\n\t\treturn;\n\t}\n\n\t\/* Read the number of entries *\/\n\tif (CHECKOVERFLOW(offset, ds, 2)) {\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, \"ExifData\",\n\t\t\t \"Tag data past end of buffer (%u+2 > %u)\", offset, ds);\n\t\treturn;\n\t}\n\tn = exif_get_short (d + offset, data->priv->order);\n\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t \"Loading %hu entries...\", n);\n\toffset += 2;\n\n\t\/* Check if we have enough data. *\/\n\tif (CHECKOVERFLOW(offset, ds, 12*n)) {\n\t\tn = (ds - offset) \/ 12;\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t\t \"Short data; only loading %hu entries...\", n);\n\t}\n\n\tfor (i = 0; i < n; i++) {\n\n\t\ttag = exif_get_short (d + offset + 12 * i, data->priv->order);\n\t\tswitch (tag) {\n\t\tcase EXIF_TAG_EXIF_IFD_POINTER:\n\t\tcase EXIF_TAG_GPS_INFO_IFD_POINTER:\n\t\tcase EXIF_TAG_INTEROPERABILITY_IFD_POINTER:\n\t\tcase EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:\n\t\tcase EXIF_TAG_JPEG_INTERCHANGE_FORMAT:\n\t\t\to = exif_get_long (d + offset + 12 * i + 8,\n\t\t\t\t\t data->priv->order);\n\t\t\tif (o >= ds) {\n\t\t\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, \"ExifData\",\n\t\t\t\t\t \"Tag data past end of buffer (%u > %u)\", offset+2, ds);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\/* FIXME: IFD_POINTER tags aren't marked as being in a\n\t\t\t * specific IFD, so exif_tag_get_name_in_ifd won't work\n\t\t\t *\/\n\t\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t\t \"Sub-IFD entry 0x%x ('%s') at %u.\", tag,\n\t\t\t\t exif_tag_get_name(tag), o);\n\t\t\tswitch (tag) {\n\t\t\tcase EXIF_TAG_EXIF_IFD_POINTER:\n\t\t\t\tCHECK_REC (EXIF_IFD_EXIF);\n\t\t\t\texif_data_load_data_content (data, EXIF_IFD_EXIF, d, ds, o,\n\t\t\t\t\trecursion_cost + level_cost(n));\n\t\t\t\tbreak;\n\t\t\tcase EXIF_TAG_GPS_INFO_IFD_POINTER:\n\t\t\t\tCHECK_REC (EXIF_IFD_GPS);\n\t\t\t\texif_data_load_data_content (data, EXIF_IFD_GPS, d, ds, o,\n\t\t\t\t\trecursion_cost + level_cost(n));\n\t\t\t\tbreak;\n\t\t\tcase EXIF_TAG_INTEROPERABILITY_IFD_POINTER:\n\t\t\t\tCHECK_REC (EXIF_IFD_INTEROPERABILITY);\n\t\t\t\texif_data_load_data_content (data, EXIF_IFD_INTEROPERABILITY, d, ds, o,\n\t\t\t\t\trecursion_cost + level_cost(n));\n\t\t\t\tbreak;\n\t\t\tcase EXIF_TAG_JPEG_INTERCHANGE_FORMAT:\n\t\t\t\tthumbnail_offset = o;\n\t\t\t\tif (thumbnail_offset && thumbnail_length)\n\t\t\t\t\texif_data_load_data_thumbnail (data, d,\n\t\t\t\t\t\t\t\t ds, thumbnail_offset,\n\t\t\t\t\t\t\t\t thumbnail_length);\n\t\t\t\tbreak;\n\t\t\tcase EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:\n\t\t\t\tthumbnail_length = o;\n\t\t\t\tif (thumbnail_offset && thumbnail_length)\n\t\t\t\t\texif_data_load_data_thumbnail (data, d,\n\t\t\t\t\t\t\t\t ds, thumbnail_offset,\n\t\t\t\t\t\t\t\t thumbnail_length);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\n\t\t\t\/*\n\t\t\t * If we don't know the tag, don't fail. It could be that new \n\t\t\t * versions of the standard have defined additional tags. Note that\n\t\t\t * 0 is a valid tag in the GPS IFD.\n\t\t\t *\/\n\t\t\tif (!exif_tag_get_name_in_ifd (tag, ifd)) {\n\n\t\t\t\t\/*\n\t\t\t\t * Special case: Tag and format 0. That's against specification\n\t\t\t\t * (at least up to 2.2). But Photoshop writes it anyways.\n\t\t\t\t *\/\n\t\t\t\tif (!memcmp (d + offset + 12 * i, \"\\0\\0\\0\\0\", 4)) {\n\t\t\t\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t\t\t\t \"Skipping empty entry at position %u in '%s'.\", i, \n\t\t\t\t\t\t exif_ifd_get_name (ifd));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t\t\t \"Unknown tag 0x%04x (entry %u in '%s'). Please report this tag \"\n\t\t\t\t\t \"to .\", tag, i,\n\t\t\t\t\t exif_ifd_get_name (ifd));\n\t\t\t\tif (data->priv->options & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tentry = exif_entry_new_mem (data->priv->mem);\n\t\t\tif (!entry) {\n\t\t\t\t exif_log (data->priv->log, EXIF_LOG_CODE_NO_MEMORY, \"ExifData\",\n \"Could not allocate memory\");\n\t\t\t\t return;\n\t\t\t}\n\t\t\tif (exif_data_load_data_entry (data, entry, d, ds,\n\t\t\t\t\t\t offset + 12 * i))\n\t\t\t\texif_content_add_entry (data->ifd[ifd], entry);\n\t\t\texif_entry_unref (entry);\n\t\t\tbreak;\n\t\t}\n\t}\n}","target":0,"code_token_length":1514,"total_token_length":1750,"max_tokens_setting":2048} +{"idx":264354,"func":"int libevt_record_values_read_end_of_file(\n libevt_record_values_t *record_values,\n uint8_t *record_data,\n size_t record_data_size,\n libcerror_error_t **error )\n{\n\tstatic char *function = \"libevt_record_values_read_end_of_file\";\n\tuint32_t size = 0;\n\tuint32_t size_copy = 0;\n\n#if defined( HAVE_DEBUG_OUTPUT )\n\tuint32_t value_32bit = 0;\n#endif\n\n\tif( record_values == NULL )\n\t{\n\t\tlibcerror_error_set(\n\t\t error,\n\t\t LIBCERROR_ERROR_DOMAIN_ARGUMENTS,\n\t\t LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,\n\t\t \"%s: invalid record values.\",\n\t\t function );\n\n\t\treturn( -1 );\n\t}\n\tif( record_data == NULL )\n\t{\n\t\tlibcerror_error_set(\n\t\t error,\n\t\t LIBCERROR_ERROR_DOMAIN_ARGUMENTS,\n\t\t LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,\n\t\t \"%s: invalid record data.\",\n\t\t function );\n\n\t\treturn( -1 );\n\t}\n\tif( record_data_size > (size_t) SSIZE_MAX )\n\t{\n\t\tlibcerror_error_set(\n\t\t error,\n\t\t LIBCERROR_ERROR_DOMAIN_ARGUMENTS,\n\t\t LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,\n\t\t \"%s: invalid record data size value exceeds maximum.\",\n\t\t function );\n\n\t\treturn( -1 );\n\t}\n\tif( record_data_size < sizeof( evt_record_end_of_file_t ) )\n\t{\n\t\tlibcerror_error_set(\n\t\t error,\n\t\t LIBCERROR_ERROR_DOMAIN_RUNTIME,\n\t\t LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,\n\t\t \"%s: record data size value out of bounds.\",\n\t\t function );\n\n\t\treturn( -1 );\n\t}\n\tbyte_stream_copy_to_uint32_little_endian(\n\t ( (evt_record_end_of_file_t *) record_data )->size,\n\t size );\n\n\tbyte_stream_copy_to_uint32_little_endian(\n\t ( (evt_record_end_of_file_t *) record_data )->size_copy,\n\t size_copy );\n\n#if defined( HAVE_DEBUG_OUTPUT )\n\tif( libcnotify_verbose != 0 )\n\t{\n\t\tlibcnotify_printf(\n\t\t \"%s: size\\t\\t\\t\\t: %\" PRIu32 \"\\n\",\n\t\t function,\n\t\t size );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->signature1,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: signature1\\t\\t\\t: 0x%08\" PRIx32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->signature2,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: signature2\\t\\t\\t: 0x%08\" PRIx32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->signature3,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: signature3\\t\\t\\t: 0x%08\" PRIx32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->signature4,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: signature4\\t\\t\\t: 0x%08\" PRIx32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->first_record_offset,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: first record offset\\t\\t: 0x%08\" PRIx32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->end_of_file_record_offset,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: end of file record offset\\t: 0x%08\" PRIx32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->last_record_number,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: last record number\\t\\t: %\" PRIu32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tbyte_stream_copy_to_uint32_little_endian(\n\t\t ( (evt_record_end_of_file_t *) record_data )->first_record_number,\n\t\t value_32bit );\n\t\tlibcnotify_printf(\n\t\t \"%s: first record number\\t\\t: %\" PRIu32 \"\\n\",\n\t\t function,\n\t\t value_32bit );\n\n\t\tlibcnotify_printf(\n\t\t \"%s: size copy\\t\\t\\t: %\" PRIu32 \"\\n\",\n\t\t function,\n\t\t size_copy );\n\n\t\tlibcnotify_printf(\n\t\t \"\\n\" );\n\t}\n#endif\n\tif( size != size_copy )\n\t{\n\t\tlibcerror_error_set(\n\t\t error,\n\t\t LIBCERROR_ERROR_DOMAIN_INPUT,\n\t\t LIBCERROR_INPUT_ERROR_VALUE_MISMATCH,\n\t\t \"%s: value mismatch for size and size copy.\",\n\t\t function );\n\n\t\treturn( -1 );\n\t}\n\tif( record_data_size != (size_t) size )\n\t{\n\t\tlibcerror_error_set(\n\t\t error,\n\t\t LIBCERROR_ERROR_DOMAIN_INPUT,\n\t\t LIBCERROR_INPUT_ERROR_VALUE_MISMATCH,\n\t\t \"%s: value mismatch for record data size and size.\",\n\t\t function );\n\n\t\treturn( -1 );\n\t}\n\/* TODO correct values in IO handle if necessary *\/\n\n\treturn( 1 );\n}","target":0,"code_token_length":1246,"total_token_length":1482,"max_tokens_setting":2048} +{"idx":271143,"func":"int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)\n{\n int i;\n cmsFloat32Number Inf[4], Outf[4];\n cmsFloat32Number LabK[4];\n cmsFloat64Number SumCMY, SumCMYK, Error, Ratio;\n cmsCIELab ColorimetricLab, BlackPreservingLab;\n PreserveKPlaneParams* bp = (PreserveKPlaneParams*) Cargo;\n\n \/\/ Convert from 16 bits to floating point\n for (i=0; i < 4; i++)\n Inf[i] = (cmsFloat32Number) (In[i] \/ 65535.0);\n\n \/\/ Get the K across Tone curve\n LabK[3] = cmsEvalToneCurveFloat(bp ->KTone, Inf[3]);\n\n \/\/ If going across black only, keep black only\n if (In[0] == 0 && In[1] == 0 && In[2] == 0) {\n\n Out[0] = Out[1] = Out[2] = 0;\n Out[3] = _cmsQuickSaturateWord(LabK[3] * 65535.0);\n return TRUE;\n }\n\n \/\/ Try the original transform,\n cmsPipelineEvalFloat( Inf, Outf, bp ->cmyk2cmyk);\n\n \/\/ Store a copy of the floating point result into 16-bit\n for (i=0; i < 4; i++)\n Out[i] = _cmsQuickSaturateWord(Outf[i] * 65535.0);\n\n \/\/ Maybe K is already ok (mostly on K=0)\n if ( fabs(Outf[3] - LabK[3]) < (3.0 \/ 65535.0) ) {\n return TRUE;\n }\n\n \/\/ K differ, mesure and keep Lab measurement for further usage\n \/\/ this is done in relative colorimetric intent\n cmsDoTransform(bp->hProofOutput, Out, &ColorimetricLab, 1);\n\n \/\/ Is not black only and the transform doesn't keep black.\n \/\/ Obtain the Lab of output CMYK. After that we have Lab + K\n cmsDoTransform(bp ->cmyk2Lab, Outf, LabK, 1);\n\n \/\/ Obtain the corresponding CMY using reverse interpolation\n \/\/ (K is fixed in LabK[3])\n if (!cmsPipelineEvalReverseFloat(LabK, Outf, Outf, bp ->LabK2cmyk)) {\n\n \/\/ Cannot find a suitable value, so use colorimetric xform\n \/\/ which is already stored in Out[]\n return TRUE;\n }\n\n \/\/ Make sure to pass thru K (which now is fixed)\n Outf[3] = LabK[3];\n\n \/\/ Apply TAC if needed\n SumCMY = Outf[0] + Outf[1] + Outf[2];\n SumCMYK = SumCMY + Outf[3];\n\n if (SumCMYK > bp ->MaxTAC) {\n\n Ratio = 1 - ((SumCMYK - bp->MaxTAC) \/ SumCMY);\n if (Ratio < 0)\n Ratio = 0;\n }\n else\n Ratio = 1.0;\n\n Out[0] = _cmsQuickSaturateWord(Outf[0] * Ratio * 65535.0); \/\/ C\n Out[1] = _cmsQuickSaturateWord(Outf[1] * Ratio * 65535.0); \/\/ M\n Out[2] = _cmsQuickSaturateWord(Outf[2] * Ratio * 65535.0); \/\/ Y\n Out[3] = _cmsQuickSaturateWord(Outf[3] * 65535.0);\n\n \/\/ Estimate the error (this goes 16 bits to Lab DBL)\n cmsDoTransform(bp->hProofOutput, Out, &BlackPreservingLab, 1);\n Error = cmsDeltaE(&ColorimetricLab, &BlackPreservingLab);\n if (Error > bp -> MaxError)\n bp->MaxError = Error;\n\n return TRUE;\n}","target":0,"code_token_length":959,"total_token_length":1195,"max_tokens_setting":2048} +{"idx":381539,"func":"HttpTransact::HandleCacheOpenReadHitFreshness(State* s)\n{\n CacheHTTPInfo *&obj = s->cache_info.object_read;\n\n ink_release_assert((s->request_sent_time == UNDEFINED_TIME) && (s->response_received_time == UNDEFINED_TIME));\n DebugTxn(\"http_seq\", \"[HttpTransact::HandleCacheOpenReadHitFreshness] Hit in cache\");\n\n if (delete_all_document_alternates_and_return(s, true)) {\n DebugTxn(\"http_trans\", \"[HandleCacheOpenReadHitFreshness] Delete and return\");\n s->cache_info.action = CACHE_DO_DELETE;\n s->next_action = HttpTransact::SM_ACTION_INTERNAL_CACHE_DELETE;\n return;\n }\n\n s->request_sent_time = obj->request_sent_time_get();\n s->response_received_time = obj->response_received_time_get();\n\n \/\/ There may be clock skew if one of the machines\n \/\/ went down and we do not have the correct delta\n \/\/ for it. this is just to deal with the effects\n \/\/ of the skew by setting minimum and maximum times\n \/\/ so that ages are not negative, etc.\n s->request_sent_time = min(s->client_request_time, s->request_sent_time);\n s->response_received_time = min(s->client_request_time, s->response_received_time);\n\n ink_assert(s->request_sent_time <= s->response_received_time);\n\n DebugTxn(\"http_trans\", \"[HandleCacheOpenReadHitFreshness] request_sent_time : %\" PRId64,\n (int64_t)s->request_sent_time);\n DebugTxn(\"http_trans\", \"[HandleCacheOpenReadHitFreshness] response_received_time : %\" PRId64,\n (int64_t)s->response_received_time);\n \/\/ if the plugin has already decided the freshness, we don't need to\n \/\/ do it again\n if (s->cache_lookup_result == HttpTransact::CACHE_LOOKUP_NONE) {\n \/\/ is the document still fresh enough to be served back to\n \/\/ the client without revalidation?\n Freshness_t freshness = what_is_document_freshness(s, &s->hdr_info.client_request, obj->response_get());\n switch (freshness) {\n case FRESHNESS_FRESH:\n DebugTxn(\"http_seq\", \"[HttpTransact::HandleCacheOpenReadHitFreshness] \" \"Fresh copy\");\n s->cache_lookup_result = HttpTransact::CACHE_LOOKUP_HIT_FRESH;\n break;\n case FRESHNESS_WARNING:\n DebugTxn(\"http_seq\", \"[HttpTransact::HandleCacheOpenReadHitFreshness] \" \"Heuristic-based Fresh copy\");\n s->cache_lookup_result = HttpTransact::CACHE_LOOKUP_HIT_WARNING;\n break;\n case FRESHNESS_STALE:\n DebugTxn(\"http_seq\", \"[HttpTransact::HandleCacheOpenReadHitFreshness] \" \"Stale in cache\");\n s->cache_lookup_result = HttpTransact::CACHE_LOOKUP_HIT_STALE;\n s->is_revalidation_necessary = true; \/\/ to identify a revalidation occurrence\n break;\n default:\n ink_assert(!(\"what_is_document_freshness has returned unsupported code.\"));\n break;\n }\n }\n\n ink_assert(s->cache_lookup_result != HttpTransact::CACHE_LOOKUP_MISS);\n if (s->cache_lookup_result == HttpTransact::CACHE_LOOKUP_HIT_STALE)\n SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_EXPIRED);\n\n if (!s->force_dns) { \/\/ If DNS is not performed before\n if (need_to_revalidate(s)) {\n TRANSACT_RETURN(SM_ACTION_API_CACHE_LOOKUP_COMPLETE, CallOSDNSLookup); \/\/ content needs to be revalidated and we did not perform a dns ....calling DNS lookup\n } else { \/\/ document can be served can cache\n TRANSACT_RETURN(SM_ACTION_API_CACHE_LOOKUP_COMPLETE, HttpTransact::HandleCacheOpenReadHit);\n }\n } else { \/\/ we have done dns . Its up to HandleCacheOpenReadHit to decide to go OS or serve from cache\n TRANSACT_RETURN(SM_ACTION_API_CACHE_LOOKUP_COMPLETE, HttpTransact::HandleCacheOpenReadHit);\n }\n}","target":0,"code_token_length":891,"total_token_length":1127,"max_tokens_setting":2048} +{"idx":84644,"func":"xfs_inode_from_disk(\n\tstruct xfs_inode\t*ip,\n\tstruct xfs_dinode\t*from)\n{\n\tstruct xfs_icdinode\t*to = &ip->i_d;\n\tstruct inode\t\t*inode = VFS_I(ip);\n\n\n\t\/*\n\t * Convert v1 inodes immediately to v2 inode format as this is the\n\t * minimum inode version format we support in the rest of the code.\n\t *\/\n\tto->di_version = from->di_version;\n\tif (to->di_version == 1) {\n\t\tset_nlink(inode, be16_to_cpu(from->di_onlink));\n\t\tto->di_projid_lo = 0;\n\t\tto->di_projid_hi = 0;\n\t\tto->di_version = 2;\n\t} else {\n\t\tset_nlink(inode, be32_to_cpu(from->di_nlink));\n\t\tto->di_projid_lo = be16_to_cpu(from->di_projid_lo);\n\t\tto->di_projid_hi = be16_to_cpu(from->di_projid_hi);\n\t}\n\n\tto->di_format = from->di_format;\n\tto->di_uid = be32_to_cpu(from->di_uid);\n\tto->di_gid = be32_to_cpu(from->di_gid);\n\tto->di_flushiter = be16_to_cpu(from->di_flushiter);\n\n\t\/*\n\t * Time is signed, so need to convert to signed 32 bit before\n\t * storing in inode timestamp which may be 64 bit. Otherwise\n\t * a time before epoch is converted to a time long after epoch\n\t * on 64 bit systems.\n\t *\/\n\tinode->i_atime.tv_sec = (int)be32_to_cpu(from->di_atime.t_sec);\n\tinode->i_atime.tv_nsec = (int)be32_to_cpu(from->di_atime.t_nsec);\n\tinode->i_mtime.tv_sec = (int)be32_to_cpu(from->di_mtime.t_sec);\n\tinode->i_mtime.tv_nsec = (int)be32_to_cpu(from->di_mtime.t_nsec);\n\tinode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec);\n\tinode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);\n\tinode->i_generation = be32_to_cpu(from->di_gen);\n\tinode->i_mode = be16_to_cpu(from->di_mode);\n\n\tto->di_size = be64_to_cpu(from->di_size);\n\tto->di_nblocks = be64_to_cpu(from->di_nblocks);\n\tto->di_extsize = be32_to_cpu(from->di_extsize);\n\tto->di_nextents = be32_to_cpu(from->di_nextents);\n\tto->di_anextents = be16_to_cpu(from->di_anextents);\n\tto->di_forkoff = from->di_forkoff;\n\tto->di_aformat\t= from->di_aformat;\n\tto->di_dmevmask\t= be32_to_cpu(from->di_dmevmask);\n\tto->di_dmstate\t= be16_to_cpu(from->di_dmstate);\n\tto->di_flags\t= be16_to_cpu(from->di_flags);\n\n\tif (to->di_version == 3) {\n\t\tinode_set_iversion_queried(inode,\n\t\t\t\t\t be64_to_cpu(from->di_changecount));\n\t\tto->di_crtime.t_sec = be32_to_cpu(from->di_crtime.t_sec);\n\t\tto->di_crtime.t_nsec = be32_to_cpu(from->di_crtime.t_nsec);\n\t\tto->di_flags2 = be64_to_cpu(from->di_flags2);\n\t\tto->di_cowextsize = be32_to_cpu(from->di_cowextsize);\n\t}\n}","target":0,"code_token_length":809,"total_token_length":1045,"max_tokens_setting":2048} +{"idx":386913,"func":"do_move (GVfsBackend *backend,\n GVfsJobMove *job,\n const char *source,\n const char *destination,\n GFileCopyFlags flags,\n GFileProgressCallback progress_callback,\n gpointer progress_callback_data)\n{\n SoupMessage *msg;\n SoupURI *source_uri;\n SoupURI *target_uri;\n guint status;\n GFileType source_ft, target_ft;\n GError *error = NULL;\n gboolean res;\n\n if (flags & G_FILE_COPY_BACKUP)\n {\n if (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE)\n {\n g_vfs_job_failed_literal (G_VFS_JOB (job),\n G_IO_ERROR,\n G_IO_ERROR_CANT_CREATE_BACKUP,\n _(\"Backups not supported\"));\n }\n else\n {\n \/* Return G_IO_ERROR_NOT_SUPPORTED instead of G_IO_ERROR_CANT_CREATE_BACKUP\n * to be proceeded with copy and delete fallback (see g_file_move). *\/\n g_vfs_job_failed_literal (G_VFS_JOB (job),\n G_IO_ERROR,\n G_IO_ERROR_NOT_SUPPORTED,\n \"Operation not supported\");\n }\n\n return;\n }\n\n source_uri = g_vfs_backend_dav_uri_for_path (backend, source, FALSE);\n msg = soup_message_new_from_uri (SOUP_METHOD_MOVE, source_uri);\n target_uri = g_vfs_backend_dav_uri_for_path (backend, destination, FALSE);\n\n res = stat_location (backend, target_uri, &target_ft, NULL, &error);\n if (!res && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))\n {\n g_vfs_job_failed_from_error (G_VFS_JOB (job), error);\n g_error_free (error);\n return;\n }\n\n if (res)\n {\n if (flags & G_FILE_COPY_OVERWRITE)\n {\n res = stat_location (backend, source_uri, &source_ft, NULL, &error);\n if (res)\n {\n if (target_ft == G_FILE_TYPE_DIRECTORY)\n {\n if (source_ft == G_FILE_TYPE_DIRECTORY)\n g_vfs_job_failed_literal (G_VFS_JOB(job),\n G_IO_ERROR,\n G_IO_ERROR_WOULD_MERGE,\n _(\"Can't move directory over directory\"));\n else\n g_vfs_job_failed_literal (G_VFS_JOB(job),\n G_IO_ERROR,\n G_IO_ERROR_IS_DIRECTORY,\n _(\"Can't move over directory\"));\n return;\n }\n else if (source_ft == G_FILE_TYPE_DIRECTORY)\n {\n \/* Overwriting a file with a directory, first remove the\n * file *\/\n SoupMessage *msg;\n\n msg = soup_message_new_from_uri (SOUP_METHOD_DELETE,\n target_uri);\n status = g_vfs_backend_dav_send_message (backend, msg);\n\n if (!SOUP_STATUS_IS_SUCCESSFUL (status))\n {\n http_job_failed (G_VFS_JOB (job), msg);\n g_object_unref (msg);\n return;\n }\n g_object_unref (msg);\n }\n }\n else\n {\n g_vfs_job_failed_from_error (G_VFS_JOB (job), error);\n g_error_free (error);\n return;\n }\n }\n else\n {\n g_vfs_job_failed_literal (G_VFS_JOB(job),\n G_IO_ERROR,\n G_IO_ERROR_EXISTS,\n _(\"Target file exists\"));\n }\n }\n\n message_add_destination_header (msg, target_uri);\n message_add_overwrite_header (msg, flags & G_FILE_COPY_OVERWRITE);\n\n status = g_vfs_backend_dav_send_message (backend, msg);\n\n \/*\n * The precondition of SOUP_STATUS_PRECONDITION_FAILED (412) in\n * this case was triggered by the \"Overwrite: F\" header which\n * means that the target already exists.\n * Also if we get a REDIRECTION it means that there was no\n * \"Location\" header, since otherwise that would have triggered\n * our redirection handler. This probably means we are dealing\n * with an web dav implementation (like mod_dav) that also sends\n * redirects for the destionaion (i.e. \"Destination: \/foo\" header)\n * which very likely means that the target also exists (and is a\n * directory). That or the webdav server is broken.\n * We could find out by doing another stat and but I think this is\n * such a corner case that we are totally fine with returning\n * G_IO_ERROR_EXISTS.\n * *\/\n\n if (SOUP_STATUS_IS_SUCCESSFUL (status))\n {\n g_vfs_job_succeeded (G_VFS_JOB (job));\n }\n else if (status == SOUP_STATUS_PRECONDITION_FAILED ||\n SOUP_STATUS_IS_REDIRECTION (status))\n g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,\n G_IO_ERROR_EXISTS,\n _(\"Target file already exists\"));\n else\n http_job_failed (G_VFS_JOB (job), msg);\n\n g_object_unref (msg);\n soup_uri_free (source_uri);\n soup_uri_free (target_uri);\n}","target":0,"code_token_length":1093,"total_token_length":1329,"max_tokens_setting":2048} +{"idx":344374,"func":"add_account (GoaProvider *provider,\n GoaClient *client,\n GtkDialog *dialog,\n GtkBox *vbox,\n GError **error)\n{\n AddAccountData data;\n GVariantBuilder credentials;\n GVariantBuilder details;\n GoaEwsClient *ews_client;\n GoaObject *ret;\n const gchar *email_address;\n const gchar *server;\n const gchar *password;\n const gchar *username;\n const gchar *provider_type;\n gint response;\n\n ews_client = NULL;\n ret = NULL;\n\n memset (&data, 0, sizeof (AddAccountData));\n data.loop = g_main_loop_new (NULL, FALSE);\n data.dialog = dialog;\n data.error = NULL;\n\n create_account_details_ui (provider, dialog, vbox, TRUE, &data);\n gtk_widget_show_all (GTK_WIDGET (vbox));\n\n ews_client = goa_ews_client_new ();\n\n ews_again:\n response = gtk_dialog_run (dialog);\n if (response != GTK_RESPONSE_OK)\n {\n g_set_error (&data.error,\n GOA_ERROR,\n GOA_ERROR_DIALOG_DISMISSED,\n _(\"Dialog was dismissed\"));\n goto out;\n }\n\n email_address = gtk_entry_get_text (GTK_ENTRY (data.email_address));\n password = gtk_entry_get_text (GTK_ENTRY (data.password));\n username = gtk_entry_get_text (GTK_ENTRY (data.username));\n server = gtk_entry_get_text (GTK_ENTRY (data.server));\n\n \/* See if there's already an account of this type with the\n * given identity\n *\/\n provider_type = goa_provider_get_provider_type (provider);\n if (!goa_utils_check_duplicate (client,\n username,\n provider_type,\n (GoaPeekInterfaceFunc) goa_object_peek_password_based,\n &data.error))\n goto out;\n\n goa_ews_client_autodiscover (ews_client,\n email_address,\n password,\n username,\n server,\n NULL,\n autodiscover_cb,\n &data);\n goa_spinner_button_start (GOA_SPINNER_BUTTON (data.spinner_button));\n g_main_loop_run (data.loop);\n\n if (data.error != NULL)\n {\n gchar *markup;\n\n markup = g_strdup_printf (\"%s:<\/b> %s\",\n _(\"Error connecting to Microsoft Exchange server\"),\n data.error->message);\n g_clear_error (&data.error);\n\n gtk_label_set_markup (GTK_LABEL (data.cluebar_label), markup);\n g_free (markup);\n\n goa_spinner_button_set_label (GOA_SPINNER_BUTTON (data.spinner_button), _(\"_Try Again\"));\n gtk_expander_set_expanded (GTK_EXPANDER (data.expander), TRUE);\n gtk_widget_set_no_show_all (data.cluebar, FALSE);\n gtk_widget_show_all (data.cluebar);\n goto ews_again;\n }\n\n gtk_widget_hide (GTK_WIDGET (dialog));\n\n g_variant_builder_init (&credentials, G_VARIANT_TYPE_VARDICT);\n g_variant_builder_add (&credentials, \"{sv}\", \"password\", g_variant_new_string (password));\n\n g_variant_builder_init (&details, G_VARIANT_TYPE (\"a{ss}\"));\n g_variant_builder_add (&details, \"{ss}\", \"MailEnabled\", \"true\");\n g_variant_builder_add (&details, \"{ss}\", \"CalendarEnabled\", \"true\");\n g_variant_builder_add (&details, \"{ss}\", \"ContactsEnabled\", \"true\");\n g_variant_builder_add (&details, \"{ss}\", \"Host\", server);\n\n \/* OK, everything is dandy, add the account *\/\n \/* we want the GoaClient to update before this method returns (so it\n * can create a proxy for the new object) so run the mainloop while\n * waiting for this to complete\n *\/\n goa_manager_call_add_account (goa_client_get_manager (client),\n goa_provider_get_provider_type (provider),\n username,\n email_address,\n g_variant_builder_end (&credentials),\n g_variant_builder_end (&details),\n NULL, \/* GCancellable* *\/\n (GAsyncReadyCallback) add_account_cb,\n &data);\n g_main_loop_run (data.loop);\n if (data.error != NULL)\n goto out;\n\n ret = GOA_OBJECT (g_dbus_object_manager_get_object (goa_client_get_object_manager (client),\n data.account_object_path));\n\n out:\n \/* We might have an object even when data.error is set.\n * eg., if we failed to store the credentials in the keyring.\n *\/\n if (data.error != NULL)\n g_propagate_error (error, data.error);\n else\n g_assert (ret != NULL);\n\n g_free (data.account_object_path);\n if (data.loop != NULL)\n g_main_loop_unref (data.loop);\n if (ews_client != NULL)\n g_object_unref (ews_client);\n return ret;\n}","target":1,"code_token_length":1044,"total_token_length":1280,"max_tokens_setting":2048} +{"idx":298258,"func":"void CreateStatusBar(void)\n{\n\tSIZE sz = {0, 0};\n\tRECT rect;\n\tLONG x, y, width, height;\n\tint edge[3];\n\tTBBUTTON tbbStatusToolbarButtons[1];\n\tTBBUTTONINFO tbi;\n\tHFONT hFont;\n\tHDC hDC;\n\n\t\/\/ Create the status bar (WS_CLIPSIBLINGS since we have an overlapping button)\n\thStatus = CreateWindowExW(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_TOOLTIPS | WS_CLIPSIBLINGS,\n\t\tCW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hMainDialog,\n\t\t(HMENU)IDC_STATUS, hMainInstance, NULL);\n\n\t\/\/ Keep track of the status bar height\n\tGetClientRect(hStatus, &rect);\n\theight = rect.bottom;\n\n\t\/\/ Set the font we'll use to display the '#' sign in the toolbar button\n\thFont = CreateFontA(-MulDiv(10, GetDeviceCaps(GetDC(hMainDialog), LOGPIXELSY), 72),\n\t\t0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, DEFAULT_CHARSET,\n\t\t0, 0, PROOF_QUALITY, 0, (nWindowsVersion >= WINDOWS_VISTA)?\"Segoe UI\":\"Arial Unicode MS\");\n\n\t\/\/ Find the width of our hash sign\n\thDC = GetDC(hMainDialog);\n\tSelectObject(hDC, hFont);\n\tGetTextExtentPoint32W(hDC, L\"#\", 1, &sz);\n\tif (hDC != NULL)\n\t\tReleaseDC(hMainDialog, hDC);\n\n\t\/\/ Create 3 status areas\n\tGetClientRect(hMainDialog, &rect);\n\tedge[1] = rect.right - (int)(SB_TIMER_SECTION_SIZE * fScale);\n\tedge[0] = edge[1] - (8 + sz.cx + 8 + 1); \/\/ There's 8 absolute pixels on right and left of the text\n\tedge[2] = rect.right;\n\tSendMessage(hStatus, SB_SETPARTS, (WPARAM)ARRAYSIZE(edge), (LPARAM)&edge);\n\n\t\/\/ NB: To add an icon on the status bar, you can use something like this:\n\t\/\/\tSendMessage(hStatus, SB_SETICON, (WPARAM) 1, (LPARAM)LoadImage(GetLibraryHandle(\"rasdlg\"),\n\t\/\/\t\tMAKEINTRESOURCE(50), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR | LR_SHARED));\n\n\t\/\/ This is supposed to create a toolips for a statusbar section (when SBARS_TOOLTIPS is in use)... but doesn't :(\n\t\/\/\tSendMessageLU(hStatus, SB_SETTIPTEXT, (WPARAM)2, (LPARAM)\"HELLO\");\n\n\t\/\/ Compute the dimensions for the hash button\n\tx = edge[0];\n\tif (nWindowsVersion <= WINDOWS_XP) {\n\t\tx -= 1;\n\t\theight -= 2;\n\t}\n\ty = rect.bottom - height + 1;\n\twidth = edge[1] - edge[0] - 1;\n\t\/\/ How I wish there was a way to figure out how to make Windows controls look good\n\t\/\/ at all scales, without adding all these crappy empirical adjustments...\n\tif ((fScale > 1.20f) && (fScale <2.40f))\n\t\theight -= 1;\n\tif (nWindowsVersion <= WINDOWS_7)\n\t\theight += 1;\n\n\t\/\/ Create the status toolbar\n\thStatusToolbar = CreateWindowExW(WS_EX_TRANSPARENT, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_TABSTOP | WS_DISABLED |\n\t\tTBSTYLE_LIST | CCS_NOPARENTALIGN | CCS_NODIVIDER | CCS_NORESIZE,\n\t\tx, y, width, height, hMainDialog, (HMENU)IDC_STATUS_TOOLBAR, hMainInstance, NULL);\n\n\t\/\/ Set the button properties\n\tSendMessage(hStatusToolbar, WM_SETFONT, (WPARAM)hFont, TRUE);\n\tSendMessage(hStatusToolbar, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_MIXEDBUTTONS);\n\tSendMessage(hStatusToolbar, TB_SETIMAGELIST, 0, (LPARAM)NULL);\n\tSendMessage(hStatusToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)NULL);\n\tSendMessage(hStatusToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0,0));\n\n\t\/\/ Set our text\n\tmemset(tbbStatusToolbarButtons, 0, sizeof(TBBUTTON));\n\ttbbStatusToolbarButtons[0].idCommand = IDC_HASH;\n\ttbbStatusToolbarButtons[0].fsStyle = BTNS_SHOWTEXT;\n\ttbbStatusToolbarButtons[0].fsState = TBSTATE_ENABLED;\n\ttbbStatusToolbarButtons[0].iString = (INT_PTR)L\"#\";\n\tSendMessage(hStatusToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);\n\tSendMessage(hStatusToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&tbbStatusToolbarButtons);\n\n\tSendMessage(hStatusToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(width, height - 1));\n\t\/\/ Yeah, you'd think that TB_SETBUTTONSIZE would work for the width... but you'd be wrong.\n\t\/\/ The only working method that actually enforces the requested width is TB_SETBUTTONINFO\n\ttbi.cbSize = sizeof(tbi);\n\ttbi.dwMask = TBIF_SIZE | TBIF_COMMAND;\n\ttbi.cx = (WORD)width;\n\ttbi.idCommand = IDC_HASH;\n\tSendMessage(hStatusToolbar, TB_SETBUTTONINFO, (WPARAM)IDC_HASH, (LPARAM)&tbi);\n\n\t\/\/ Need to resend the positioning for the toolbar to become active... One of Windows' mysteries\n\t\/\/ Also use this opportunity to set our Z-order for tab stop\n\tSetWindowPos(hStatusToolbar, GetDlgItem(hMainDialog, IDCANCEL), x, y, width, height, 0);\n\tShowWindow(hStatusToolbar, SW_SHOWNORMAL);\n}","target":0,"code_token_length":1291,"total_token_length":1527,"max_tokens_setting":2048} +{"idx":328086,"func":"static void x86_cpu_realizefn(DeviceState *dev, Error **errp)\n\n{\n\n CPUState *cs = CPU(dev);\n\n X86CPU *cpu = X86_CPU(dev);\n\n X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);\n\n CPUX86State *env = &cpu->env;\n\n Error *local_err = NULL;\n\n static bool ht_warned;\n\n\n\n if (xcc->kvm_required && !kvm_enabled()) {\n\n char *name = x86_cpu_class_get_model_name(xcc);\n\n error_setg(&local_err, \"CPU model '%s' requires KVM\", name);\n\n g_free(name);\n\n goto out;\n\n }\n\n\n\n if (cpu->apic_id == UNASSIGNED_APIC_ID) {\n\n error_setg(errp, \"apic-id property was not initialized properly\");\n\n return;\n\n }\n\n\n\n x86_cpu_expand_features(cpu, &local_err);\n\n if (local_err) {\n\n goto out;\n\n }\n\n\n\n if (x86_cpu_filter_features(cpu) &&\n\n (cpu->check_cpuid || cpu->enforce_cpuid)) {\n\n x86_cpu_report_filtered_features(cpu);\n\n if (cpu->enforce_cpuid) {\n\n error_setg(&local_err,\n\n kvm_enabled() ?\n\n \"Host doesn't support requested features\" :\n\n \"TCG doesn't support requested features\");\n\n goto out;\n\n }\n\n }\n\n\n\n \/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on\n\n * CPUID[1].EDX.\n\n *\/\n\n if (IS_AMD_CPU(env)) {\n\n env->features[FEAT_8000_0001_EDX] &= ~CPUID_EXT2_AMD_ALIASES;\n\n env->features[FEAT_8000_0001_EDX] |= (env->features[FEAT_1_EDX]\n\n & CPUID_EXT2_AMD_ALIASES);\n\n }\n\n\n\n \/* For 64bit systems think about the number of physical bits to present.\n\n * ideally this should be the same as the host; anything other than matching\n\n * the host can cause incorrect guest behaviour.\n\n * QEMU used to pick the magic value of 40 bits that corresponds to\n\n * consumer AMD devices but nothing else.\n\n *\/\n\n if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) {\n\n if (kvm_enabled()) {\n\n uint32_t host_phys_bits = x86_host_phys_bits();\n\n static bool warned;\n\n\n\n if (cpu->host_phys_bits) {\n\n \/* The user asked for us to use the host physical bits *\/\n\n cpu->phys_bits = host_phys_bits;\n\n }\n\n\n\n \/* Print a warning if the user set it to a value that's not the\n\n * host value.\n\n *\/\n\n if (cpu->phys_bits != host_phys_bits && cpu->phys_bits != 0 &&\n\n !warned) {\n\n error_report(\"Warning: Host physical bits (%u)\"\n\n \" does not match phys-bits property (%u)\",\n\n host_phys_bits, cpu->phys_bits);\n\n warned = true;\n\n }\n\n\n\n if (cpu->phys_bits &&\n\n (cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS ||\n\n cpu->phys_bits < 32)) {\n\n error_setg(errp, \"phys-bits should be between 32 and %u \"\n\n \" (but is %u)\",\n\n TARGET_PHYS_ADDR_SPACE_BITS, cpu->phys_bits);\n\n return;\n\n }\n\n } else {\n\n if (cpu->phys_bits && cpu->phys_bits != TCG_PHYS_ADDR_BITS) {\n\n error_setg(errp, \"TCG only supports phys-bits=%u\",\n\n TCG_PHYS_ADDR_BITS);\n\n return;\n\n }\n\n }\n\n \/* 0 means it was not explicitly set by the user (or by machine\n\n * compat_props or by the host code above). In this case, the default\n\n * is the value used by TCG (40).\n\n *\/\n\n if (cpu->phys_bits == 0) {\n\n cpu->phys_bits = TCG_PHYS_ADDR_BITS;\n\n }\n\n } else {\n\n \/* For 32 bit systems don't use the user set value, but keep\n\n * phys_bits consistent with what we tell the guest.\n\n *\/\n\n if (cpu->phys_bits != 0) {\n\n error_setg(errp, \"phys-bits is not user-configurable in 32 bit\");\n\n return;\n\n }\n\n\n\n if (env->features[FEAT_1_EDX] & CPUID_PSE36) {\n\n cpu->phys_bits = 36;\n\n } else {\n\n cpu->phys_bits = 32;\n\n }\n\n }\n\n cpu_exec_realizefn(cs, &local_err);\n\n if (local_err != NULL) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n if (tcg_enabled()) {\n\n tcg_x86_init();\n\n }\n\n\n\n#ifndef CONFIG_USER_ONLY\n\n qemu_register_reset(x86_cpu_machine_reset_cb, cpu);\n\n\n\n if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || smp_cpus > 1) {\n\n x86_cpu_apic_create(cpu, &local_err);\n\n if (local_err != NULL) {\n\n goto out;\n\n }\n\n }\n\n#endif\n\n\n\n mce_init(cpu);\n\n\n\n#ifndef CONFIG_USER_ONLY\n\n if (tcg_enabled()) {\n\n AddressSpace *as_normal = address_space_init_shareable(cs->memory,\n\n \"cpu-memory\");\n\n AddressSpace *as_smm = g_new(AddressSpace, 1);\n\n\n\n cpu->cpu_as_mem = g_new(MemoryRegion, 1);\n\n cpu->cpu_as_root = g_new(MemoryRegion, 1);\n\n\n\n \/* Outer container... *\/\n\n memory_region_init(cpu->cpu_as_root, OBJECT(cpu), \"memory\", ~0ull);\n\n memory_region_set_enabled(cpu->cpu_as_root, true);\n\n\n\n \/* ... with two regions inside: normal system memory with low\n\n * priority, and...\n\n *\/\n\n memory_region_init_alias(cpu->cpu_as_mem, OBJECT(cpu), \"memory\",\n\n get_system_memory(), 0, ~0ull);\n\n memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0);\n\n memory_region_set_enabled(cpu->cpu_as_mem, true);\n\n address_space_init(as_smm, cpu->cpu_as_root, \"CPU\");\n\n\n\n cs->num_ases = 2;\n\n cpu_address_space_init(cs, as_normal, 0);\n\n cpu_address_space_init(cs, as_smm, 1);\n\n\n\n \/* ... SMRAM with higher priority, linked from \/machine\/smram. *\/\n\n cpu->machine_done.notify = x86_cpu_machine_done;\n\n qemu_add_machine_init_done_notifier(&cpu->machine_done);\n\n }\n\n#endif\n\n\n\n qemu_init_vcpu(cs);\n\n\n\n \/* Only Intel CPUs support hyperthreading. Even though QEMU fixes this\n\n * issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX\n\n * based on inputs (sockets,cores,threads), it is still better to gives\n\n * users a warning.\n\n *\n\n * NOTE: the following code has to follow qemu_init_vcpu(). Otherwise\n\n * cs->nr_threads hasn't be populated yet and the checking is incorrect.\n\n *\/\n\n if (!IS_INTEL_CPU(env) && cs->nr_threads > 1 && !ht_warned) {\n\n error_report(\"AMD CPU doesn't support hyperthreading. Please configure\"\n\n \" -smp options properly.\");\n\n ht_warned = true;\n\n }\n\n\n\n x86_cpu_apic_realize(cpu, &local_err);\n\n if (local_err != NULL) {\n\n goto out;\n\n }\n\n cpu_reset(cs);\n\n\n\n xcc->parent_realize(dev, &local_err);\n\n\n\nout:\n\n if (local_err != NULL) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n}\n","target":0,"code_token_length":1751,"total_token_length":1987,"max_tokens_setting":2048} +{"idx":36873,"func":"static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,\n\t\t\t const struct xfrm_migrate *m, int num_bundles,\n\t\t\t const struct xfrm_kmaddress *k)\n{\n\tint i;\n\tint sasize_sel;\n\tint size = 0;\n\tint size_pol = 0;\n\tstruct sk_buff *skb;\n\tstruct sadb_msg *hdr;\n\tstruct sadb_x_policy *pol;\n\tconst struct xfrm_migrate *mp;\n\n\tif (type != XFRM_POLICY_TYPE_MAIN)\n\t\treturn 0;\n\n\tif (num_bundles <= 0 || num_bundles > XFRM_MAX_DEPTH)\n\t\treturn -EINVAL;\n\n\tif (k != NULL) {\n\t\t\/* addresses for KM *\/\n\t\tsize += PFKEY_ALIGN8(sizeof(struct sadb_x_kmaddress) +\n\t\t\t\t pfkey_sockaddr_pair_size(k->family));\n\t}\n\n\t\/* selector *\/\n\tsasize_sel = pfkey_sockaddr_size(sel->family);\n\tif (!sasize_sel)\n\t\treturn -EINVAL;\n\tsize += (sizeof(struct sadb_address) + sasize_sel) * 2;\n\n\t\/* policy info *\/\n\tsize_pol += sizeof(struct sadb_x_policy);\n\n\t\/* ipsecrequests *\/\n\tfor (i = 0, mp = m; i < num_bundles; i++, mp++) {\n\t\t\/* old locator pair *\/\n\t\tsize_pol += sizeof(struct sadb_x_ipsecrequest) +\n\t\t\t pfkey_sockaddr_pair_size(mp->old_family);\n\t\t\/* new locator pair *\/\n\t\tsize_pol += sizeof(struct sadb_x_ipsecrequest) +\n\t\t\t pfkey_sockaddr_pair_size(mp->new_family);\n\t}\n\n\tsize += sizeof(struct sadb_msg) + size_pol;\n\n\t\/* alloc buffer *\/\n\tskb = alloc_skb(size, GFP_ATOMIC);\n\tif (skb == NULL)\n\t\treturn -ENOMEM;\n\n\thdr = (struct sadb_msg *)skb_put(skb, sizeof(struct sadb_msg));\n\thdr->sadb_msg_version = PF_KEY_V2;\n\thdr->sadb_msg_type = SADB_X_MIGRATE;\n\thdr->sadb_msg_satype = pfkey_proto2satype(m->proto);\n\thdr->sadb_msg_len = size \/ 8;\n\thdr->sadb_msg_errno = 0;\n\thdr->sadb_msg_reserved = 0;\n\thdr->sadb_msg_seq = 0;\n\thdr->sadb_msg_pid = 0;\n\n\t\/* Addresses to be used by KM for negotiation, if ext is available *\/\n\tif (k != NULL && (set_sadb_kmaddress(skb, k) < 0))\n\t\tgoto err;\n\n\t\/* selector src *\/\n\tset_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_SRC, sel);\n\n\t\/* selector dst *\/\n\tset_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_DST, sel);\n\n\t\/* policy information *\/\n\tpol = (struct sadb_x_policy *)skb_put(skb, sizeof(struct sadb_x_policy));\n\tpol->sadb_x_policy_len = size_pol \/ 8;\n\tpol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;\n\tpol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;\n\tpol->sadb_x_policy_dir = dir + 1;\n\tpol->sadb_x_policy_id = 0;\n\tpol->sadb_x_policy_priority = 0;\n\n\tfor (i = 0, mp = m; i < num_bundles; i++, mp++) {\n\t\t\/* old ipsecrequest *\/\n\t\tint mode = pfkey_mode_from_xfrm(mp->mode);\n\t\tif (mode < 0)\n\t\t\tgoto err;\n\t\tif (set_ipsecrequest(skb, mp->proto, mode,\n\t\t\t\t (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),\n\t\t\t\t mp->reqid, mp->old_family,\n\t\t\t\t &mp->old_saddr, &mp->old_daddr) < 0)\n\t\t\tgoto err;\n\n\t\t\/* new ipsecrequest *\/\n\t\tif (set_ipsecrequest(skb, mp->proto, mode,\n\t\t\t\t (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),\n\t\t\t\t mp->reqid, mp->new_family,\n\t\t\t\t &mp->new_saddr, &mp->new_daddr) < 0)\n\t\t\tgoto err;\n\t}\n\n\t\/* broadcast migrate message to sockets *\/\n\tpfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net);\n\n\treturn 0;\n\nerr:\n\tkfree_skb(skb);\n\treturn -EINVAL;\n}","target":0,"code_token_length":951,"total_token_length":1187,"max_tokens_setting":2048} +{"idx":30164,"func":"void bn_sqr_comba8 ( BN_ULONG * r , const BN_ULONG * a ) {\n BN_ULONG c1 , c2 , c3 ;\n c1 = 0 ;\n c2 = 0 ;\n c3 = 0 ;\n sqr_add_c ( a , 0 , c1 , c2 , c3 ) ;\n r [ 0 ] = c1 ;\n c1 = 0 ;\n sqr_add_c2 ( a , 1 , 0 , c2 , c3 , c1 ) ;\n r [ 1 ] = c2 ;\n c2 = 0 ;\n sqr_add_c ( a , 1 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 2 , 0 , c3 , c1 , c2 ) ;\n r [ 2 ] = c3 ;\n c3 = 0 ;\n sqr_add_c2 ( a , 3 , 0 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 2 , 1 , c1 , c2 , c3 ) ;\n r [ 3 ] = c1 ;\n c1 = 0 ;\n sqr_add_c ( a , 2 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 3 , 1 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 4 , 0 , c2 , c3 , c1 ) ;\n r [ 4 ] = c2 ;\n c2 = 0 ;\n sqr_add_c2 ( a , 5 , 0 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 4 , 1 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 3 , 2 , c3 , c1 , c2 ) ;\n r [ 5 ] = c3 ;\n c3 = 0 ;\n sqr_add_c ( a , 3 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 4 , 2 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 5 , 1 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 6 , 0 , c1 , c2 , c3 ) ;\n r [ 6 ] = c1 ;\n c1 = 0 ;\n sqr_add_c2 ( a , 7 , 0 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 6 , 1 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 5 , 2 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 4 , 3 , c2 , c3 , c1 ) ;\n r [ 7 ] = c2 ;\n c2 = 0 ;\n sqr_add_c ( a , 4 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 5 , 3 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 6 , 2 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 7 , 1 , c3 , c1 , c2 ) ;\n r [ 8 ] = c3 ;\n c3 = 0 ;\n sqr_add_c2 ( a , 7 , 2 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 6 , 3 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 5 , 4 , c1 , c2 , c3 ) ;\n r [ 9 ] = c1 ;\n c1 = 0 ;\n sqr_add_c ( a , 5 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 6 , 4 , c2 , c3 , c1 ) ;\n sqr_add_c2 ( a , 7 , 3 , c2 , c3 , c1 ) ;\n r [ 10 ] = c2 ;\n c2 = 0 ;\n sqr_add_c2 ( a , 7 , 4 , c3 , c1 , c2 ) ;\n sqr_add_c2 ( a , 6 , 5 , c3 , c1 , c2 ) ;\n r [ 11 ] = c3 ;\n c3 = 0 ;\n sqr_add_c ( a , 6 , c1 , c2 , c3 ) ;\n sqr_add_c2 ( a , 7 , 5 , c1 , c2 , c3 ) ;\n r [ 12 ] = c1 ;\n c1 = 0 ;\n sqr_add_c2 ( a , 7 , 6 , c2 , c3 , c1 ) ;\n r [ 13 ] = c2 ;\n c2 = 0 ;\n sqr_add_c ( a , 7 , c3 , c1 , c2 ) ;\n r [ 14 ] = c3 ;\n r [ 15 ] = c1 ;\n }","target":0,"code_token_length":1083,"total_token_length":1319,"max_tokens_setting":2048} +{"idx":392389,"func":"xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,\n xmlAttrPtr attr, const xmlChar * string)\n{\n xmlChar *base, *cur;\n\n if (string == NULL)\n return;\n base = cur = (xmlChar *) string;\n while (*cur != 0) {\n if (*cur == '\\n') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \" \", 5);\n cur++;\n base = cur;\n } else if (*cur == '\\r') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \" \", 5);\n cur++;\n base = cur;\n } else if (*cur == '\\t') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \" \", 4);\n cur++;\n base = cur;\n } else if (*cur == '\"') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \""\", 6);\n cur++;\n base = cur;\n } else if (*cur == '<') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \"<\", 4);\n cur++;\n base = cur;\n } else if (*cur == '>') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \">\", 4);\n cur++;\n base = cur;\n } else if (*cur == '&') {\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n xmlBufAdd(buf, BAD_CAST \"&\", 5);\n cur++;\n base = cur;\n } else if ((*cur >= 0x80) && (cur[1] != 0) &&\n\t ((doc == NULL) || (doc->encoding == NULL))) {\n \/*\n * We assume we have UTF-8 content.\n *\/\n unsigned char tmp[12];\n int val = 0, l = 1;\n\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n if (*cur < 0xC0) {\n xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr, NULL);\n if (doc != NULL)\n doc->encoding = xmlStrdup(BAD_CAST \"ISO-8859-1\");\n\t\txmlSerializeHexCharRef(tmp, *cur);\n xmlBufAdd(buf, (xmlChar *) tmp, -1);\n cur++;\n base = cur;\n continue;\n } else if (*cur < 0xE0) {\n val = (cur[0]) & 0x1F;\n val <<= 6;\n val |= (cur[1]) & 0x3F;\n l = 2;\n } else if ((*cur < 0xF0) && (cur [2] != 0)) {\n val = (cur[0]) & 0x0F;\n val <<= 6;\n val |= (cur[1]) & 0x3F;\n val <<= 6;\n val |= (cur[2]) & 0x3F;\n l = 3;\n } else if ((*cur < 0xF8) && (cur [2] != 0) && (cur[3] != 0)) {\n val = (cur[0]) & 0x07;\n val <<= 6;\n val |= (cur[1]) & 0x3F;\n val <<= 6;\n val |= (cur[2]) & 0x3F;\n val <<= 6;\n val |= (cur[3]) & 0x3F;\n l = 4;\n }\n if ((l == 1) || (!IS_CHAR(val))) {\n xmlSaveErr(XML_SAVE_CHAR_INVALID, (xmlNodePtr) attr, NULL);\n if (doc != NULL)\n doc->encoding = xmlStrdup(BAD_CAST \"ISO-8859-1\");\n\n\t\txmlSerializeHexCharRef(tmp, *cur);\n xmlBufAdd(buf, (xmlChar *) tmp, -1);\n cur++;\n base = cur;\n continue;\n }\n \/*\n * We could do multiple things here. Just save\n * as a char ref\n *\/\n\t xmlSerializeHexCharRef(tmp, val);\n xmlBufAdd(buf, (xmlChar *) tmp, -1);\n cur += l;\n base = cur;\n } else {\n cur++;\n }\n }\n if (base != cur)\n xmlBufAdd(buf, base, cur - base);\n}","target":0,"code_token_length":1064,"total_token_length":1300,"max_tokens_setting":2048} +{"idx":3185,"func":"static void get_over(struct SYMBOL *s)\n{\n\tstruct VOICE_S *p_voice, *p_voice2, *p_voice3;\n\tint range, voice, voice2, voice3;\nstatic char tx_wrong_dur[] = \"Wrong duration in voice overlay\";\nstatic char txt_no_note[] = \"No note in voice overlay\";\n\n\t\/* treat the end of overlay *\/\n\tp_voice = curvoice;\n\tif (p_voice->ignore)\n\t\treturn;\n\tif (s->abc_type == ABC_T_BAR\n\t || s->u.v_over.type == V_OVER_E) {\n\t\tif (!p_voice->last_sym) {\n\t\t\terror(1, s, txt_no_note);\n\t\t\treturn;\n\t\t}\n\t\tp_voice->last_sym->sflags |= S_BEAM_END;\n\t\tover_bar = 0;\n\t\tif (over_time < 0) {\n\t\t\terror(1, s, \"Erroneous end of voice overlap\");\n\t\t\treturn;\n\t\t}\n\t\tif (p_voice->time != over_mxtime)\n\t\t\terror(1, s, tx_wrong_dur);\n\t\tcurvoice = &voice_tb[over_voice];\n\t\tover_mxtime = 0;\n\t\tover_voice = -1;\n\t\tover_time = -1;\n\t\treturn;\n\t}\n\n\t\/* treat the full overlay start *\/\n\tif (s->u.v_over.type == V_OVER_S) {\n\t\tover_voice = p_voice - voice_tb;\n\t\tover_time = p_voice->time;\n\t\treturn;\n\t}\n\n\t\/* (here is treated a new overlay - '&') *\/\n\t\/* create the extra voice if not done yet *\/\n\tif (!p_voice->last_sym) {\n\t\terror(1, s, txt_no_note);\n\t\treturn;\n\t}\n\tp_voice->last_sym->sflags |= S_BEAM_END;\n\tvoice2 = s->u.v_over.voice;\n\tp_voice2 = &voice_tb[voice2];\n\tif (parsys->voice[voice2].range < 0) {\n\t\tint clone;\n\n\t\tif (cfmt.abc2pscompat) {\n\t\t\terror(1, s, \"Cannot have %%%%abc2pscompat\");\n\t\t\tcfmt.abc2pscompat = 0;\n\t\t}\n\t\tclone = p_voice->clone >= 0;\n\t\tp_voice2->id[0] = '&';\n\t\tp_voice2->id[1] = '\\0';\n\t\tp_voice2->second = 1;\n\t\tparsys->voice[voice2].second = 1;\n\t\tp_voice2->scale = p_voice->scale;\n\t\tp_voice2->octave = p_voice->octave;\n\t\tp_voice2->transpose = p_voice->transpose;\n\t\tmemcpy(&p_voice2->key, &p_voice->key,\n\t\t\t\t\tsizeof p_voice2->key);\n\t\tmemcpy(&p_voice2->ckey, &p_voice->ckey,\n\t\t\t\t\tsizeof p_voice2->ckey);\n\t\tmemcpy(&p_voice2->okey, &p_voice->okey,\n\t\t\t\t\tsizeof p_voice2->okey);\n\t\tp_voice2->posit = p_voice->posit;\n\t\tp_voice2->staff = p_voice->staff;\n\t\tp_voice2->cstaff = p_voice->cstaff;\n\t\tp_voice2->color = p_voice->color;\n\t\tp_voice2->map_name = p_voice->map_name;\n\t\trange = parsys->voice[p_voice - voice_tb].range;\n\t\tfor (voice = 0; voice < MAXVOICE; voice++) {\n\t\t\tif (parsys->voice[voice].range > range)\n\t\t\t\tparsys->voice[voice].range += clone + 1;\n\t\t}\n\t\tparsys->voice[voice2].range = range + 1;\n\t\tvoice_link(p_voice2);\n\t\tif (clone) {\n\t\t\tfor (voice3 = MAXVOICE; --voice3 >= 0; ) {\n\t\t\t\tif (parsys->voice[voice3].range < 0)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (voice3 > 0) {\n\t\t\t\tp_voice3 = &voice_tb[voice3];\n\t\t\t\tstrcpy(p_voice3->id, p_voice2->id);\n\t\t\t\tp_voice3->second = 1;\n\t\t\t\tparsys->voice[voice3].second = 1;\n\t\t\t\tp_voice3->scale = voice_tb[p_voice->clone].scale;\n\t\t\t\tparsys->voice[voice3].range = range + 2;\n\t\t\t\tvoice_link(p_voice3);\n\t\t\t\tp_voice2->clone = voice3;\n\t\t\t} else {\n\t\t\t\terror(1, s,\n\t\t\t\t \"Too many voices for overlay cloning\");\n\t\t\t}\n\t\t}\n\t}\n\tvoice = p_voice - voice_tb;\n\/\/\tp_voice2->cstaff = p_voice2->staff = parsys->voice[voice2].staff\n\/\/\t\t\t= parsys->voice[voice].staff;\n\/\/\tif ((voice3 = p_voice2->clone) >= 0) {\n\/\/\t\tp_voice3 = &voice_tb[voice3];\n\/\/\t\tp_voice3->cstaff = p_voice3->staff\n\/\/\t\t\t\t= parsys->voice[voice3].staff\n\/\/\t\t\t\t= parsys->voice[p_voice->clone].staff;\n\/\/\t}\n\n\tif (over_time < 0) {\t\t\t\/* first '&' in a measure *\/\n\t\tint time;\n\n\t\tover_bar = 1;\n\t\tover_mxtime = p_voice->time;\n\t\tover_voice = voice;\n\t\ttime = p_voice2->time;\n\t\tfor (s = p_voice->last_sym; \/*s*\/; s = s->prev) {\n\t\t\tif (s->type == BAR\n\t\t\t || s->time <= time)\t\/* (if start of tune) *\/\n\t\t\t\tbreak;\n\t\t}\n\t\tover_time = s->time;\n\t} else {\n\t\tif (over_mxtime == 0)\n\t\t\tover_mxtime = p_voice->time;\n\t\telse if (p_voice->time != over_mxtime)\n\t\t\terror(1, s, tx_wrong_dur);\n\t}\n\tp_voice2->time = over_time;\n\tcurvoice = p_voice2;\n}","target":1,"code_token_length":1286,"total_token_length":1522,"max_tokens_setting":2048} +{"idx":81835,"func":"MagickExport MagickBooleanType LevelImage(Image *image,const double black_point,\n const double white_point,const double gamma,ExceptionInfo *exception)\n{\n#define LevelImageTag \"Level\/Image\"\n\n CacheView\n *image_view;\n\n MagickBooleanType\n status;\n\n MagickOffsetType\n progress;\n\n register ssize_t\n i;\n\n ssize_t\n y;\n\n \/*\n Allocate and initialize levels map.\n *\/\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->storage_class == PseudoClass)\n for (i=0; i < (ssize_t) image->colors; i++)\n {\n \/*\n Level colormap.\n *\/\n if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)\n image->colormap[i].red=(double) ClampToQuantum(LevelPixel(black_point,\n white_point,gamma,image->colormap[i].red));\n if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)\n image->colormap[i].green=(double) ClampToQuantum(LevelPixel(black_point,\n white_point,gamma,image->colormap[i].green));\n if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)\n image->colormap[i].blue=(double) ClampToQuantum(LevelPixel(black_point,\n white_point,gamma,image->colormap[i].blue));\n if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)\n image->colormap[i].alpha=(double) ClampToQuantum(LevelPixel(black_point,\n white_point,gamma,image->colormap[i].alpha));\n }\n \/*\n Level image.\n *\/\n status=MagickTrue;\n progress=0;\n image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static,4) shared(progress,status) \\\n magick_threads(image,image,image->rows,1)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n register Quantum\n *magick_restrict q;\n\n register ssize_t\n x;\n\n if (status == MagickFalse)\n continue;\n q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n {\n status=MagickFalse;\n continue;\n }\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n register ssize_t\n j;\n\n if (GetPixelReadMask(image,q) == 0)\n {\n q+=GetPixelChannels(image);\n continue;\n }\n for (j=0; j < (ssize_t) GetPixelChannels(image); j++)\n {\n PixelChannel channel=GetPixelChannelChannel(image,j);\n PixelTrait traits=GetPixelChannelTraits(image,channel);\n if ((traits & UpdatePixelTrait) == 0)\n continue;\n q[j]=ClampToQuantum(LevelPixel(black_point,white_point,gamma,\n (double) q[j]));\n }\n q+=GetPixelChannels(image);\n }\n if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n status=MagickFalse;\n if (image->progress_monitor != (MagickProgressMonitor) NULL)\n {\n MagickBooleanType\n proceed;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp critical (MagickCore_LevelImage)\n#endif\n proceed=SetImageProgress(image,LevelImageTag,progress++,image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n image_view=DestroyCacheView(image_view);\n (void) ClampImage(image,exception);\n return(status);\n}","target":0,"code_token_length":865,"total_token_length":1101,"max_tokens_setting":2048} +{"idx":484980,"func":"static Image *ReadGROUP4Image(const ImageInfo *image_info,\n ExceptionInfo *exception)\n{\n char\n filename[MagickPathExtent];\n\n FILE\n *file;\n\n Image\n *image;\n\n ImageInfo\n *read_info;\n\n int\n c,\n unique_file;\n\n MagickBooleanType\n status;\n\n size_t\n length;\n\n ssize_t\n offset,\n strip_offset;\n\n \/*\n Open image file.\n *\/\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickCoreSignature);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n if (IsEventLogging() != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n image=AcquireImage(image_info,exception);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n \/*\n Write raw CCITT Group 4 wrapped as a TIFF image file.\n *\/\n file=(FILE *) NULL;\n unique_file=AcquireUniqueFileResource(filename);\n if (unique_file != -1)\n file=fdopen(unique_file,\"wb\");\n if ((unique_file == -1) || (file == (FILE *) NULL))\n ThrowImageException(FileOpenError,\"UnableToCreateTemporaryFile\");\n length=fwrite(\"\\111\\111\\052\\000\\010\\000\\000\\000\\016\\000\",1,10,file);\n if (length != 10)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n length=fwrite(\"\\376\\000\\003\\000\\001\\000\\000\\000\\000\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\000\\001\\004\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image->columns);\n length=fwrite(\"\\001\\001\\004\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image->rows);\n length=fwrite(\"\\002\\001\\003\\000\\001\\000\\000\\000\\001\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\003\\001\\003\\000\\001\\000\\000\\000\\004\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\006\\001\\003\\000\\001\\000\\000\\000\\000\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\021\\001\\003\\000\\001\\000\\000\\000\",1,8,file);\n strip_offset=10+(12*14)+4+8;\n length=WriteLSBLong(file,(unsigned int) strip_offset);\n length=fwrite(\"\\022\\001\\003\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image_info->orientation);\n length=fwrite(\"\\025\\001\\003\\000\\001\\000\\000\\000\\001\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\026\\001\\004\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image->rows);\n length=fwrite(\"\\027\\001\\004\\000\\001\\000\\000\\000\\000\\000\\000\\000\",1,12,file);\n offset=(ssize_t) ftell(file)-4;\n length=fwrite(\"\\032\\001\\005\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) (strip_offset-8));\n length=fwrite(\"\\033\\001\\005\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) (strip_offset-8));\n length=fwrite(\"\\050\\001\\003\\000\\001\\000\\000\\000\\002\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\000\\000\\000\\000\",1,4,file);\n length=WriteLSBLong(file,(unsigned int) image->resolution.x);\n length=WriteLSBLong(file,1);\n status=MagickTrue;\n for (length=0; (c=ReadBlobByte(image)) != EOF; length++)\n if (fputc(c,file) != c)\n status=MagickFalse;\n offset=(ssize_t) fseek(file,(off_t) offset,SEEK_SET);\n length=WriteLSBLong(file,(unsigned int) length);\n if (ferror(file) != 0)\n {\n (void) fclose(file);\n ThrowImageException(FileOpenError,\"UnableToCreateTemporaryFile\");\n }\n (void) fclose(file);\n (void) CloseBlob(image);\n image=DestroyImage(image);\n \/*\n Read TIFF image.\n *\/\n read_info=CloneImageInfo((ImageInfo *) NULL);\n (void) FormatLocaleString(read_info->filename,MagickPathExtent,\"%s\",filename);\n image=ReadTIFFImage(read_info,exception);\n read_info=DestroyImageInfo(read_info);\n if (image != (Image *) NULL)\n {\n (void) CopyMagickString(image->filename,image_info->filename,\n MagickPathExtent);\n (void) CopyMagickString(image->magick_filename,image_info->filename,\n MagickPathExtent);\n (void) CopyMagickString(image->magick,\"GROUP4\",MagickPathExtent);\n }\n (void) RelinquishUniqueFileResource(filename);\n if (status == MagickFalse)\n image=DestroyImage(image);\n return(image);\n}","target":0,"code_token_length":1613,"total_token_length":1849,"max_tokens_setting":2048} +{"idx":383858,"func":"PHP_METHOD(Phar, extractTo)\n{\n\tchar *error = NULL;\n\tphp_stream *fp;\n\tphp_stream_statbuf ssb;\n\tphar_entry_info *entry;\n\tchar *pathto, *filename, *actual;\n\tint pathto_len, filename_len;\n\tint ret, i;\n\tint nelems;\n\tzval *zval_files = NULL;\n\tzend_bool overwrite = 0;\n\n\tPHAR_ARCHIVE_OBJECT();\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s|z!b\", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {\n\t\treturn;\n\t}\n\n\tfp = php_stream_open_wrapper(phar_obj->arc.archive->fname, \"rb\", IGNORE_URL|STREAM_MUST_SEEK, &actual);\n\n\tif (!fp) {\n\t\tzend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,\n\t\t\t\"Invalid argument, %s cannot be found\", phar_obj->arc.archive->fname);\n\t\treturn;\n\t}\n\n\tefree(actual);\n\tphp_stream_close(fp);\n\n\tif (pathto_len < 1) {\n\t\tzend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,\n\t\t\t\"Invalid argument, extraction path must be non-zero length\");\n\t\treturn;\n\t}\n\n\tif (pathto_len >= MAXPATHLEN) {\n\t\tchar *tmp = estrndup(pathto, 50);\n\t\t\/* truncate for error message *\/\n\t\tzend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, \"Cannot extract to \\\"%s...\\\", destination directory is too long for filesystem\", tmp);\n\t\tefree(tmp);\n\t\treturn;\n\t}\n\n\tif (php_stream_stat_path(pathto, &ssb) < 0) {\n\t\tret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL);\n\t\tif (!ret) {\n\t\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,\n\t\t\t\t\"Unable to create path \\\"%s\\\" for extraction\", pathto);\n\t\t\treturn;\n\t\t}\n\t} else if (!(ssb.sb.st_mode & S_IFDIR)) {\n\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,\n\t\t\t\"Unable to use path \\\"%s\\\" for extraction, it is a file, must be a directory\", pathto);\n\t\treturn;\n\t}\n\n\tif (zval_files) {\n\t\tswitch (Z_TYPE_P(zval_files)) {\n\t\t\tcase IS_NULL:\n\t\t\t\tgoto all_files;\n\t\t\tcase IS_STRING:\n\t\t\t\tfilename = Z_STRVAL_P(zval_files);\n\t\t\t\tfilename_len = Z_STRLEN_P(zval_files);\n\t\t\t\tbreak;\n\t\t\tcase IS_ARRAY:\n\t\t\t\tnelems = zend_hash_num_elements(Z_ARRVAL_P(zval_files));\n\t\t\t\tif (nelems == 0 ) {\n\t\t\t\t\tRETURN_FALSE;\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < nelems; i++) {\n\t\t\t\t\tzval **zval_file;\n\t\t\t\t\tif (zend_hash_index_find(Z_ARRVAL_P(zval_files), i, (void **) &zval_file) == SUCCESS) {\n\t\t\t\t\t\tswitch (Z_TYPE_PP(zval_file)) {\n\t\t\t\t\t\t\tcase IS_STRING:\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tzend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,\n\t\t\t\t\t\t\t\t\t\"Invalid argument, array of filenames to extract contains non-string value\");\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (FAILURE == zend_hash_find(&phar_obj->arc.archive->manifest, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), (void **)&entry)) {\n\t\t\t\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,\n\t\t\t\t\t\t\t\t\"Phar Error: attempted to extract non-existent file \\\"%s\\\" from phar \\\"%s\\\"\", Z_STRVAL_PP(zval_file), phar_obj->arc.archive->fname);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {\n\t\t\t\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,\n\t\t\t\t\t\t\t\t\"Extraction from phar \\\"%s\\\" failed: %s\", phar_obj->arc.archive->fname, error);\n\t\t\t\t\t\t\tefree(error);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tRETURN_TRUE;\n\t\t\tdefault:\n\t\t\t\tzend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,\n\t\t\t\t\t\"Invalid argument, expected a filename (string) or array of filenames\");\n\t\t\t\treturn;\n\t\t}\n\n\t\tif (FAILURE == zend_hash_find(&phar_obj->arc.archive->manifest, filename, filename_len, (void **)&entry)) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,\n\t\t\t\t\"Phar Error: attempted to extract non-existent file \\\"%s\\\" from phar \\\"%s\\\"\", filename, phar_obj->arc.archive->fname);\n\t\t\treturn;\n\t\t}\n\n\t\tif (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,\n\t\t\t\t\"Extraction from phar \\\"%s\\\" failed: %s\", phar_obj->arc.archive->fname, error);\n\t\t\tefree(error);\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tphar_archive_data *phar;\nall_files:\n\t\tphar = phar_obj->arc.archive;\n\t\t\/* Extract all files *\/\n\t\tif (!zend_hash_num_elements(&(phar->manifest))) {\n\t\t\tRETURN_TRUE;\n\t\t}\n\n\t\tfor (zend_hash_internal_pointer_reset(&phar->manifest);\n\t\tzend_hash_has_more_elements(&phar->manifest) == SUCCESS;\n\t\tzend_hash_move_forward(&phar->manifest)) {\n\n\t\t\tif (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {\n\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,\n\t\t\t\t\t\"Extraction from phar \\\"%s\\\" failed: %s\", phar->fname, error);\n\t\t\t\tefree(error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tRETURN_TRUE;\n}","target":0,"code_token_length":1360,"total_token_length":1596,"max_tokens_setting":2048} +{"idx":509560,"func":"static int tls_construct_cke_gost(SSL *s, unsigned char **p, int *len, int *al)\n{\n#ifndef OPENSSL_NO_GOST\n \/* GOST key exchange message creation *\/\n EVP_PKEY_CTX *pkey_ctx = NULL;\n X509 *peer_cert;\n size_t msglen;\n unsigned int md_len;\n unsigned char shared_ukm[32], tmp[256];\n EVP_MD_CTX *ukm_hash = NULL;\n int dgst_nid = NID_id_GostR3411_94;\n unsigned char *pms = NULL;\n size_t pmslen = 0;\n\n if ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aGOST12) != 0)\n dgst_nid = NID_id_GostR3411_2012_256;\n\n \/*\n * Get server sertificate PKEY and create ctx from it\n *\/\n peer_cert = s->session->peer;\n if (!peer_cert) {\n *al = SSL_AD_HANDSHAKE_FAILURE;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST,\n SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER);\n return 0;\n }\n\n pkey_ctx = EVP_PKEY_CTX_new(X509_get0_pubkey(peer_cert), NULL);\n if (pkey_ctx == NULL) {\n *al = SSL_AD_INTERNAL_ERROR;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, ERR_R_MALLOC_FAILURE);\n return 0;\n }\n \/*\n * If we have send a certificate, and certificate key\n * parameters match those of server certificate, use\n * certificate key for key exchange\n *\/\n\n \/* Otherwise, generate ephemeral key pair *\/\n pmslen = 32;\n pms = OPENSSL_malloc(pmslen);\n if (pms == NULL) {\n *al = SSL_AD_INTERNAL_ERROR;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, ERR_R_MALLOC_FAILURE);\n goto err;\n }\n\n if (EVP_PKEY_encrypt_init(pkey_ctx) <= 0\n \/* Generate session key *\/\n || RAND_bytes(pms, pmslen) <= 0) {\n *al = SSL_AD_INTERNAL_ERROR;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, ERR_R_INTERNAL_ERROR);\n goto err;\n };\n \/*\n * Compute shared IV and store it in algorithm-specific context\n * data\n *\/\n ukm_hash = EVP_MD_CTX_new();\n if (ukm_hash == NULL\n || EVP_DigestInit(ukm_hash, EVP_get_digestbynid(dgst_nid)) <= 0\n || EVP_DigestUpdate(ukm_hash, s->s3->client_random,\n SSL3_RANDOM_SIZE) <= 0\n || EVP_DigestUpdate(ukm_hash, s->s3->server_random,\n SSL3_RANDOM_SIZE) <= 0\n || EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len) <= 0) {\n *al = SSL_AD_INTERNAL_ERROR;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, ERR_R_INTERNAL_ERROR);\n goto err;\n }\n EVP_MD_CTX_free(ukm_hash);\n ukm_hash = NULL;\n if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT,\n EVP_PKEY_CTRL_SET_IV, 8, shared_ukm) < 0) {\n *al = SSL_AD_INTERNAL_ERROR;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, SSL_R_LIBRARY_BUG);\n goto err;\n }\n \/* Make GOST keytransport blob message *\/\n \/*\n * Encapsulate it into sequence\n *\/\n *((*p)++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED;\n msglen = 255;\n if (EVP_PKEY_encrypt(pkey_ctx, tmp, &msglen, pms, pmslen) <= 0) {\n *al = SSL_AD_INTERNAL_ERROR;\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, SSL_R_LIBRARY_BUG);\n goto err;\n }\n if (msglen >= 0x80) {\n *((*p)++) = 0x81;\n *((*p)++) = msglen & 0xff;\n *len = msglen + 3;\n } else {\n *((*p)++) = msglen & 0xff;\n *len = msglen + 2;\n }\n memcpy(*p, tmp, msglen);\n\n EVP_PKEY_CTX_free(pkey_ctx);\n s->s3->tmp.pms = pms;\n s->s3->tmp.pmslen = pmslen;\n\n return 1;\n err:\n EVP_PKEY_CTX_free(pkey_ctx);\n OPENSSL_clear_free(pms, pmslen);\n EVP_MD_CTX_free(ukm_hash);\n return 0;\n#else\n SSLerr(SSL_F_TLS_CONSTRUCT_CKE_GOST, ERR_R_INTERNAL_ERROR);\n *al = SSL_AD_INTERNAL_ERROR;\n return 0;\n#endif\n}","target":0,"code_token_length":1132,"total_token_length":1368,"max_tokens_setting":2048} +{"idx":376904,"func":"static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,\n uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset,\n int flags)\n{\n BDRVQcowState *s = bs->opaque;\n uint64_t *l2_table, l2_entry;\n uint64_t next_contiguous_offset = 0;\n int i, l2_size, nb_csectors;\n\n \/* Read L2 table from disk *\/\n l2_size = s->l2_size * sizeof(uint64_t);\n l2_table = g_malloc(l2_size);\n\n if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)\n goto fail;\n\n \/* Do the actual checks *\/\n for(i = 0; i < s->l2_size; i++) {\n l2_entry = be64_to_cpu(l2_table[i]);\n\n switch (qcow2_get_cluster_type(l2_entry)) {\n case QCOW2_CLUSTER_COMPRESSED:\n \/* Compressed clusters don't have QCOW_OFLAG_COPIED *\/\n if (l2_entry & QCOW_OFLAG_COPIED) {\n fprintf(stderr, \"ERROR: cluster %\" PRId64 \": \"\n \"copied flag must never be set for compressed \"\n \"clusters\\n\", l2_entry >> s->cluster_bits);\n l2_entry &= ~QCOW_OFLAG_COPIED;\n res->corruptions++;\n }\n\n \/* Mark cluster as used *\/\n nb_csectors = ((l2_entry >> s->csize_shift) &\n s->csize_mask) + 1;\n l2_entry &= s->cluster_offset_mask;\n inc_refcounts(bs, res, refcount_table, refcount_table_size,\n l2_entry & ~511, nb_csectors * 512);\n\n if (flags & CHECK_FRAG_INFO) {\n res->bfi.allocated_clusters++;\n res->bfi.compressed_clusters++;\n\n \/* Compressed clusters are fragmented by nature. Since they\n * take up sub-sector space but we only have sector granularity\n * I\/O we need to re-read the same sectors even for adjacent\n * compressed clusters.\n *\/\n res->bfi.fragmented_clusters++;\n }\n break;\n\n case QCOW2_CLUSTER_ZERO:\n if ((l2_entry & L2E_OFFSET_MASK) == 0) {\n break;\n }\n \/* fall through *\/\n\n case QCOW2_CLUSTER_NORMAL:\n {\n uint64_t offset = l2_entry & L2E_OFFSET_MASK;\n\n if (flags & CHECK_FRAG_INFO) {\n res->bfi.allocated_clusters++;\n if (next_contiguous_offset &&\n offset != next_contiguous_offset) {\n res->bfi.fragmented_clusters++;\n }\n next_contiguous_offset = offset + s->cluster_size;\n }\n\n \/* Mark cluster as used *\/\n inc_refcounts(bs, res, refcount_table,refcount_table_size,\n offset, s->cluster_size);\n\n \/* Correct offsets are cluster aligned *\/\n if (offset_into_cluster(s, offset)) {\n fprintf(stderr, \"ERROR offset=%\" PRIx64 \": Cluster is not \"\n \"properly aligned; L2 entry corrupted.\\n\", offset);\n res->corruptions++;\n }\n break;\n }\n\n case QCOW2_CLUSTER_UNALLOCATED:\n break;\n\n default:\n abort();\n }\n }\n\n g_free(l2_table);\n return 0;\n\nfail:\n fprintf(stderr, \"ERROR: I\/O error in check_refcounts_l2\\n\");\n g_free(l2_table);\n return -EIO;\n}","target":0,"code_token_length":799,"total_token_length":1035,"max_tokens_setting":2048} +{"idx":336788,"func":"static av_cold int alac_encode_init(AVCodecContext *avctx)\n\n{\n\n AlacEncodeContext *s = avctx->priv_data;\n\n int ret;\n\n uint8_t *alac_extradata;\n\n\n\n avctx->frame_size = s->frame_size = DEFAULT_FRAME_SIZE;\n\n\n\n if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) {\n\n av_log(avctx, AV_LOG_ERROR, \"only pcm_s16 input samples are supported\\n\");\n\n return -1;\n\n }\n\n\n\n \/* TODO: Correctly implement multi-channel ALAC.\n\n It is similar to multi-channel AAC, in that it has a series of\n\n single-channel (SCE), channel-pair (CPE), and LFE elements. *\/\n\n if (avctx->channels > 2) {\n\n av_log(avctx, AV_LOG_ERROR, \"only mono or stereo input is currently supported\\n\");\n\n return AVERROR_PATCHWELCOME;\n\n }\n\n\n\n \/\/ Set default compression level\n\n if (avctx->compression_level == FF_COMPRESSION_DEFAULT)\n\n s->compression_level = 2;\n\n else\n\n s->compression_level = av_clip(avctx->compression_level, 0, 2);\n\n\n\n \/\/ Initialize default Rice parameters\n\n s->rc.history_mult = 40;\n\n s->rc.initial_history = 10;\n\n s->rc.k_modifier = 14;\n\n s->rc.rice_modifier = 4;\n\n\n\n s->max_coded_frame_size = get_max_frame_size(avctx->frame_size,\n\n avctx->channels,\n\n DEFAULT_SAMPLE_SIZE);\n\n\n\n \/\/ FIXME: consider wasted_bytes\n\n s->write_sample_size = DEFAULT_SAMPLE_SIZE + avctx->channels - 1;\n\n\n\n avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);\n\n if (!avctx->extradata) {\n\n ret = AVERROR(ENOMEM);\n\n goto error;\n\n }\n\n avctx->extradata_size = ALAC_EXTRADATA_SIZE;\n\n\n\n alac_extradata = avctx->extradata;\n\n AV_WB32(alac_extradata, ALAC_EXTRADATA_SIZE);\n\n AV_WB32(alac_extradata+4, MKBETAG('a','l','a','c'));\n\n AV_WB32(alac_extradata+12, avctx->frame_size);\n\n AV_WB8 (alac_extradata+17, DEFAULT_SAMPLE_SIZE);\n\n AV_WB8 (alac_extradata+21, avctx->channels);\n\n AV_WB32(alac_extradata+24, s->max_coded_frame_size);\n\n AV_WB32(alac_extradata+28,\n\n avctx->sample_rate * avctx->channels * DEFAULT_SAMPLE_SIZE); \/\/ average bitrate\n\n AV_WB32(alac_extradata+32, avctx->sample_rate);\n\n\n\n \/\/ Set relevant extradata fields\n\n if (s->compression_level > 0) {\n\n AV_WB8(alac_extradata+18, s->rc.history_mult);\n\n AV_WB8(alac_extradata+19, s->rc.initial_history);\n\n AV_WB8(alac_extradata+20, s->rc.k_modifier);\n\n }\n\n\n\n s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;\n\n if (avctx->min_prediction_order >= 0) {\n\n if (avctx->min_prediction_order < MIN_LPC_ORDER ||\n\n avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {\n\n av_log(avctx, AV_LOG_ERROR, \"invalid min prediction order: %d\\n\",\n\n avctx->min_prediction_order);\n\n ret = AVERROR(EINVAL);\n\n goto error;\n\n }\n\n\n\n s->min_prediction_order = avctx->min_prediction_order;\n\n }\n\n\n\n s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;\n\n if (avctx->max_prediction_order >= 0) {\n\n if (avctx->max_prediction_order < MIN_LPC_ORDER ||\n\n avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {\n\n av_log(avctx, AV_LOG_ERROR, \"invalid max prediction order: %d\\n\",\n\n avctx->max_prediction_order);\n\n ret = AVERROR(EINVAL);\n\n goto error;\n\n }\n\n\n\n s->max_prediction_order = avctx->max_prediction_order;\n\n }\n\n\n\n if (s->max_prediction_order < s->min_prediction_order) {\n\n av_log(avctx, AV_LOG_ERROR,\n\n \"invalid prediction orders: min=%d max=%d\\n\",\n\n s->min_prediction_order, s->max_prediction_order);\n\n ret = AVERROR(EINVAL);\n\n goto error;\n\n }\n\n\n\n avctx->coded_frame = avcodec_alloc_frame();\n\n if (!avctx->coded_frame) {\n\n ret = AVERROR(ENOMEM);\n\n goto error;\n\n }\n\n\n\n s->avctx = avctx;\n\n\n\n if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,\n\n s->max_prediction_order,\n\n FF_LPC_TYPE_LEVINSON)) < 0) {\n\n goto error;\n\n }\n\n\n\n return 0;\n\nerror:\n\n alac_encode_close(avctx);\n\n return ret;\n\n}\n","target":0,"code_token_length":1123,"total_token_length":1359,"max_tokens_setting":2048} +{"idx":335003,"func":"static void rpza_decode_stream(RpzaContext *s)\n\n{\n\n int width = s->avctx->width;\n\n int stride = s->frame.linesize[0] \/ 2;\n\n int row_inc = stride - 4;\n\n int stream_ptr = 0;\n\n int chunk_size;\n\n unsigned char opcode;\n\n int n_blocks;\n\n unsigned short colorA = 0, colorB;\n\n unsigned short color4[4];\n\n unsigned char index, idx;\n\n unsigned short ta, tb;\n\n unsigned short *pixels = (unsigned short *)s->frame.data[0];\n\n\n\n int row_ptr = 0;\n\n int pixel_ptr = 0;\n\n int block_ptr;\n\n int pixel_x, pixel_y;\n\n int total_blocks;\n\n\n\n \/* First byte is always 0xe1. Warn if it's different *\/\n\n if (s->buf[stream_ptr] != 0xe1)\n\n av_log(s->avctx, AV_LOG_ERROR, \"First chunk byte is 0x%02x instead of 0xe1\\n\",\n\n s->buf[stream_ptr]);\n\n\n\n \/* Get chunk size, ingnoring first byte *\/\n\n chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;\n\n stream_ptr += 4;\n\n\n\n \/* If length mismatch use size from MOV file and try to decode anyway *\/\n\n if (chunk_size != s->size)\n\n av_log(s->avctx, AV_LOG_ERROR, \"MOV chunk size != encoded chunk size; using MOV chunk size\\n\");\n\n\n\n chunk_size = s->size;\n\n\n\n \/* Number of 4x4 blocks in frame. *\/\n\n total_blocks = ((s->avctx->width + 3) \/ 4) * ((s->avctx->height + 3) \/ 4);\n\n\n\n \/* Process chunk data *\/\n\n while (stream_ptr < chunk_size) {\n\n opcode = s->buf[stream_ptr++]; \/* Get opcode *\/\n\n\n\n n_blocks = (opcode & 0x1f) + 1; \/* Extract block counter from opcode *\/\n\n\n\n \/* If opcode MSbit is 0, we need more data to decide what to do *\/\n\n if ((opcode & 0x80) == 0) {\n\n colorA = (opcode << 8) | (s->buf[stream_ptr++]);\n\n opcode = 0;\n\n if ((s->buf[stream_ptr] & 0x80) != 0) {\n\n \/* Must behave as opcode 110xxxxx, using colorA computed\n\n * above. Use fake opcode 0x20 to enter switch block at\n\n * the right place *\/\n\n opcode = 0x20;\n\n n_blocks = 1;\n\n }\n\n }\n\n\n\n switch (opcode & 0xe0) {\n\n\n\n \/* Skip blocks *\/\n\n case 0x80:\n\n while (n_blocks--) {\n\n ADVANCE_BLOCK();\n\n }\n\n break;\n\n\n\n \/* Fill blocks with one color *\/\n\n case 0xa0:\n\n colorA = AV_RB16 (&s->buf[stream_ptr]);\n\n stream_ptr += 2;\n\n while (n_blocks--) {\n\n block_ptr = row_ptr + pixel_ptr;\n\n for (pixel_y = 0; pixel_y < 4; pixel_y++) {\n\n for (pixel_x = 0; pixel_x < 4; pixel_x++){\n\n pixels[block_ptr] = colorA;\n\n block_ptr++;\n\n }\n\n block_ptr += row_inc;\n\n }\n\n ADVANCE_BLOCK();\n\n }\n\n break;\n\n\n\n \/* Fill blocks with 4 colors *\/\n\n case 0xc0:\n\n colorA = AV_RB16 (&s->buf[stream_ptr]);\n\n stream_ptr += 2;\n\n case 0x20:\n\n colorB = AV_RB16 (&s->buf[stream_ptr]);\n\n stream_ptr += 2;\n\n\n\n \/* sort out the colors *\/\n\n color4[0] = colorB;\n\n color4[1] = 0;\n\n color4[2] = 0;\n\n color4[3] = colorA;\n\n\n\n \/* red components *\/\n\n ta = (colorA >> 10) & 0x1F;\n\n tb = (colorB >> 10) & 0x1F;\n\n color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;\n\n color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;\n\n\n\n \/* green components *\/\n\n ta = (colorA >> 5) & 0x1F;\n\n tb = (colorB >> 5) & 0x1F;\n\n color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;\n\n color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;\n\n\n\n \/* blue components *\/\n\n ta = colorA & 0x1F;\n\n tb = colorB & 0x1F;\n\n color4[1] |= ((11 * ta + 21 * tb) >> 5);\n\n color4[2] |= ((21 * ta + 11 * tb) >> 5);\n\n\n\n\n\n while (n_blocks--) {\n\n block_ptr = row_ptr + pixel_ptr;\n\n for (pixel_y = 0; pixel_y < 4; pixel_y++) {\n\n index = s->buf[stream_ptr++];\n\n for (pixel_x = 0; pixel_x < 4; pixel_x++){\n\n idx = (index >> (2 * (3 - pixel_x))) & 0x03;\n\n pixels[block_ptr] = color4[idx];\n\n block_ptr++;\n\n }\n\n block_ptr += row_inc;\n\n }\n\n ADVANCE_BLOCK();\n\n }\n\n break;\n\n\n\n \/* Fill block with 16 colors *\/\n\n case 0x00:\n\n if (s->size - stream_ptr < 16)\n\n\n block_ptr = row_ptr + pixel_ptr;\n\n for (pixel_y = 0; pixel_y < 4; pixel_y++) {\n\n for (pixel_x = 0; pixel_x < 4; pixel_x++){\n\n \/* We already have color of upper left pixel *\/\n\n if ((pixel_y != 0) || (pixel_x !=0)) {\n\n colorA = AV_RB16 (&s->buf[stream_ptr]);\n\n stream_ptr += 2;\n\n }\n\n pixels[block_ptr] = colorA;\n\n block_ptr++;\n\n }\n\n block_ptr += row_inc;\n\n }\n\n ADVANCE_BLOCK();\n\n break;\n\n\n\n \/* Unknown opcode *\/\n\n default:\n\n av_log(s->avctx, AV_LOG_ERROR, \"Unknown opcode %d in rpza chunk.\"\n\n \" Skip remaining %d bytes of chunk data.\\n\", opcode,\n\n chunk_size - stream_ptr);\n\n\n } \/* Opcode switch *\/\n\n }\n\n}","target":1,"code_token_length":1485,"total_token_length":1721,"max_tokens_setting":2048} +{"idx":271205,"func":"int mainloop(CLIENT *client) {\n\tstruct nbd_request request;\n\tstruct nbd_reply reply;\n\tgboolean go_on=TRUE;\n#ifdef DODBG\n\tint i = 0;\n#endif\n\tnegotiate(client->net, client, NULL, client->modern ? NEG_MODERN : (NEG_OLD | NEG_INIT));\n\tDEBUG(\"Entering request loop!\\n\");\n\treply.magic = htonl(NBD_REPLY_MAGIC);\n\treply.error = 0;\n\twhile (go_on) {\n\t\tchar buf[BUFSIZE];\n\t\tchar* p;\n\t\tsize_t len;\n\t\tsize_t currlen;\n\t\tsize_t writelen;\n\t\tuint16_t command;\n#ifdef DODBG\n\t\ti++;\n\t\tprintf(\"%d: \", i);\n#endif\n\t\treadit(client->net, &request, sizeof(request));\n\t\tif (client->transactionlogfd != -1)\n\t\t\twriteit(client->transactionlogfd, &request, sizeof(request));\n\n\t\trequest.from = ntohll(request.from);\n\t\trequest.type = ntohl(request.type);\n\t\tcommand = request.type & NBD_CMD_MASK_COMMAND;\n\t\tlen = ntohl(request.len);\n\n\t\tDEBUG(\"%s from %llu (%llu) len %u, \", getcommandname(command),\n\t\t\t\t(unsigned long long)request.from,\n\t\t\t\t(unsigned long long)request.from \/ 512, len);\n\n\t\tif (request.magic != htonl(NBD_REQUEST_MAGIC))\n\t\t\terr(\"Not enough magic.\");\n\n\t\tmemcpy(reply.handle, request.handle, sizeof(reply.handle));\n\n\t\tif ((command==NBD_CMD_WRITE) || (command==NBD_CMD_READ)) {\n\t\t\tif (request.from + len < request.from) { \/\/ 64 bit overflow!!\n\t\t\t\tDEBUG(\"[Number too large!]\");\n\t\t\t\tERROR(client, reply, EINVAL);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (((off_t)request.from + len) > client->exportsize) {\n\t\t\t\tDEBUG(\"[RANGE!]\");\n\t\t\t\tERROR(client, reply, EINVAL);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tcurrlen = len;\n\t\t\tif (currlen > BUFSIZE - sizeof(struct nbd_reply)) {\n\t\t\t\tcurrlen = BUFSIZE - sizeof(struct nbd_reply);\n\t\t\t\tif(!logged_oversized) {\n\t\t\t\t\tmsg(LOG_DEBUG, \"oversized request (this is not a problem)\");\n\t\t\t\t\tlogged_oversized = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tswitch (command) {\n\n\t\tcase NBD_CMD_DISC:\n\t\t\tmsg(LOG_INFO, \"Disconnect request received.\");\n \tif (client->server->flags & F_COPYONWRITE) { \n\t\t\t\tif (client->difmap) g_free(client->difmap) ;\n \t\tclose(client->difffile);\n\t\t\t\tunlink(client->difffilename);\n\t\t\t\tfree(client->difffilename);\n\t\t\t}\n\t\t\tgo_on=FALSE;\n\t\t\tcontinue;\n\n\t\tcase NBD_CMD_WRITE:\n\t\t\tDEBUG(\"wr: net->buf, \");\n\t\t\twhile(len > 0) {\n\t\t\t\treadit(client->net, buf, currlen);\n\t\t\t\tDEBUG(\"buf->exp, \");\n\t\t\t\tif ((client->server->flags & F_READONLY) ||\n\t\t\t\t (client->server->flags & F_AUTOREADONLY)) {\n\t\t\t\t\tDEBUG(\"[WRITE to READONLY!]\");\n\t\t\t\t\tERROR(client, reply, EPERM);\n\t\t\t\t\tconsume(client->net, buf, len-currlen, BUFSIZE);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (expwrite(request.from, buf, currlen, client,\n\t\t\t\t\t request.type & NBD_CMD_FLAG_FUA)) {\n\t\t\t\t\tDEBUG(\"Write failed: %m\" );\n\t\t\t\t\tERROR(client, reply, errno);\n\t\t\t\t\tconsume(client->net, buf, len-currlen, BUFSIZE);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlen -= currlen;\n\t\t\t\trequest.from += currlen;\n\t\t\t\tcurrlen = (len < BUFSIZE) ? len : BUFSIZE;\n\t\t\t}\n\t\t\tSEND(client->net, reply);\n\t\t\tDEBUG(\"OK!\\n\");\n\t\t\tcontinue;\n\n\t\tcase NBD_CMD_FLUSH:\n\t\t\tDEBUG(\"fl: \");\n\t\t\tif (expflush(client)) {\n\t\t\t\tDEBUG(\"Flush failed: %m\");\n\t\t\t\tERROR(client, reply, errno);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tSEND(client->net, reply);\n\t\t\tDEBUG(\"OK!\\n\");\n\t\t\tcontinue;\n\n\t\tcase NBD_CMD_READ:\n\t\t\tDEBUG(\"exp->buf, \");\n\t\t\tif (client->transactionlogfd != -1)\n\t\t\t\twriteit(client->transactionlogfd, &reply, sizeof(reply));\n\t\t\twriteit(client->net, &reply, sizeof(reply));\n\t\t\tp = buf;\n\t\t\twritelen = currlen;\n\t\t\twhile(len > 0) {\n\t\t\t\tif (expread(request.from, p, currlen, client)) {\n\t\t\t\t\tDEBUG(\"Read failed: %m\");\n\t\t\t\t\tERROR(client, reply, errno);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tDEBUG(\"buf->net, \");\n\t\t\t\twriteit(client->net, buf, writelen);\n\t\t\t\tlen -= currlen;\n\t\t\t\trequest.from += currlen;\n\t\t\t\tcurrlen = (len < BUFSIZE) ? len : BUFSIZE;\n\t\t\t\tp = buf;\n\t\t\t\twritelen = currlen;\n\t\t\t}\n\t\t\tDEBUG(\"OK!\\n\");\n\t\t\tcontinue;\n\n\t\tcase NBD_CMD_TRIM:\n\t\t\t\/* The kernel module sets discard_zeroes_data == 0,\n\t\t\t * so it is okay to do nothing. *\/\n\t\t\tif (exptrim(&request, client)) {\n\t\t\t\tDEBUG(\"Trim failed: %m\");\n\t\t\t\tERROR(client, reply, errno);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tSEND(client->net, reply);\n\t\t\tcontinue;\n\n\t\tdefault:\n\t\t\tDEBUG (\"Ignoring unknown command\\n\");\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":1168,"total_token_length":1404,"max_tokens_setting":2048} +{"idx":164220,"func":"static void pcnet_transmit(PCNetState *s)\n{\n hwaddr xmit_cxda = 0;\n int count = CSR_XMTRL(s)-1;\n int add_crc = 0;\n int bcnt;\n s->xmit_pos = -1;\n\n if (!CSR_TXON(s)) {\n s->csr[0] &= ~0x0008;\n return;\n }\n\n s->tx_busy = 1;\n\n txagain:\n if (pcnet_tdte_poll(s)) {\n struct pcnet_TMD tmd;\n\n TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s)));\n\n#ifdef PCNET_DEBUG_TMD\n printf(\" TMDLOAD 0x%08x\\n\", PHYSADDR(s,CSR_CXDA(s)));\n PRINT_TMD(&tmd);\n#endif\n if (GET_FIELD(tmd.status, TMDS, STP)) {\n s->xmit_pos = 0;\n xmit_cxda = PHYSADDR(s,CSR_CXDA(s));\n if (BCR_SWSTYLE(s) != 1)\n add_crc = GET_FIELD(tmd.status, TMDS, ADDFCS);\n }\n if (s->lnkst == 0 &&\n (!CSR_LOOP(s) || (!CSR_INTL(s) && !BCR_TMAULOOP(s)))) {\n SET_FIELD(&tmd.misc, TMDM, LCAR, 1);\n SET_FIELD(&tmd.status, TMDS, ERR, 1);\n SET_FIELD(&tmd.status, TMDS, OWN, 0);\n s->csr[0] |= 0xa000; \/* ERR | CERR *\/\n s->xmit_pos = -1;\n goto txdone;\n }\n\n if (s->xmit_pos < 0) {\n goto txdone;\n }\n\n bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);\n\n \/* if multi-tmd packet outsizes s->buffer then skip it silently.\n * Note: this is not what real hw does.\n * Last four bytes of s->buffer are used to store CRC FCS code.\n *\/\n if (s->xmit_pos + bcnt > sizeof(s->buffer) - 4) {\n s->xmit_pos = -1;\n goto txdone;\n }\n\n s->phys_mem_read(s->dma_opaque, PHYSADDR(s, tmd.tbadr),\n s->buffer + s->xmit_pos, bcnt, CSR_BSWP(s));\n s->xmit_pos += bcnt;\n \n if (!GET_FIELD(tmd.status, TMDS, ENP)) {\n goto txdone;\n }\n\n#ifdef PCNET_DEBUG\n printf(\"pcnet_transmit size=%d\\n\", s->xmit_pos);\n#endif\n if (CSR_LOOP(s)) {\n if (BCR_SWSTYLE(s) == 1)\n add_crc = !GET_FIELD(tmd.status, TMDS, NOFCS);\n s->looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;\n pcnet_receive(qemu_get_queue(s->nic), s->buffer, s->xmit_pos);\n s->looptest = 0;\n } else {\n if (s->nic) {\n qemu_send_packet(qemu_get_queue(s->nic), s->buffer,\n s->xmit_pos);\n }\n }\n\n s->csr[0] &= ~0x0008; \/* clear TDMD *\/\n s->csr[4] |= 0x0004; \/* set TXSTRT *\/\n s->xmit_pos = -1;\n\n txdone:\n SET_FIELD(&tmd.status, TMDS, OWN, 0);\n TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));\n if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT)))\n s->csr[0] |= 0x0200; \/* set TINT *\/\n\n if (CSR_XMTRC(s)<=1)\n CSR_XMTRC(s) = CSR_XMTRL(s);\n else\n CSR_XMTRC(s)--;\n if (count--)\n goto txagain;\n\n } else\n if (s->xmit_pos >= 0) {\n struct pcnet_TMD tmd;\n TMDLOAD(&tmd, xmit_cxda);\n SET_FIELD(&tmd.misc, TMDM, BUFF, 1);\n SET_FIELD(&tmd.misc, TMDM, UFLO, 1);\n SET_FIELD(&tmd.status, TMDS, ERR, 1);\n SET_FIELD(&tmd.status, TMDS, OWN, 0);\n TMDSTORE(&tmd, xmit_cxda);\n s->csr[0] |= 0x0200; \/* set TINT *\/\n if (!CSR_DXSUFLO(s)) {\n s->csr[0] &= ~0x0010;\n } else\n if (count--)\n goto txagain;\n }\n\n s->tx_busy = 0;\n}\n","target":0,"code_token_length":1141,"total_token_length":1377,"max_tokens_setting":2048} +{"idx":385553,"func":"PHP_METHOD(SoapServer, addFunction)\n{\n\tsoapServicePtr service;\n\tzval *function_name, *function_copy;\n\tHashPosition pos;\n\n\tSOAP_SERVER_BEGIN_CODE();\n\n\tFETCH_THIS_SERVICE(service);\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"z\", &function_name) == FAILURE) {\n\t\treturn;\n\t}\n\n\t\/* TODO: could use zend_is_callable here *\/\n\n\tif (function_name->type == IS_ARRAY) {\n\t\tif (service->type == SOAP_FUNCTIONS) {\n\t\t\tzval **tmp_function, *function_copy;\n\n\t\t\tif (service->soap_functions.ft == NULL) {\n\t\t\t\tservice->soap_functions.functions_all = FALSE;\n\t\t\t\tservice->soap_functions.ft = emalloc(sizeof(HashTable));\n\t\t\t\tzend_hash_init(service->soap_functions.ft, zend_hash_num_elements(Z_ARRVAL_P(function_name)), NULL, ZVAL_PTR_DTOR, 0);\n\t\t\t}\n\n\t\t\tzend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(function_name), &pos);\n\t\t\twhile (zend_hash_get_current_data_ex(Z_ARRVAL_P(function_name), (void **)&tmp_function, &pos) != FAILURE) {\n\t\t\t\tchar *key;\n\t\t\t\tint key_len;\n\t\t\t\tzend_function *f;\n\n\t\t\t\tif (Z_TYPE_PP(tmp_function) != IS_STRING) {\n\t\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Tried to add a function that isn't a string\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tkey_len = Z_STRLEN_PP(tmp_function);\n\t\t\t\tkey = emalloc(key_len + 1);\n\t\t\t\tzend_str_tolower_copy(key, Z_STRVAL_PP(tmp_function), key_len);\n\n\t\t\t\tif (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {\n\t\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Tried to add a non existent function '%s'\", Z_STRVAL_PP(tmp_function));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tMAKE_STD_ZVAL(function_copy);\n\t\t\t\tZVAL_STRING(function_copy, f->common.function_name, 1);\n\t\t\t\tzend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);\n\n\t\t\t\tefree(key);\n\t\t\t\tzend_hash_move_forward_ex(Z_ARRVAL_P(function_name), &pos);\n\t\t\t}\n\t\t}\n\t} else if (function_name->type == IS_STRING) {\n\t\tchar *key;\n\t\tint key_len;\n\t\tzend_function *f;\n\n\t\tkey_len = Z_STRLEN_P(function_name);\n\t\tkey = emalloc(key_len + 1);\n\t\tzend_str_tolower_copy(key, Z_STRVAL_P(function_name), key_len);\n\n\t\tif (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Tried to add a non existent function '%s'\", Z_STRVAL_P(function_name));\n\t\t\treturn;\n\t\t}\n\t\tif (service->soap_functions.ft == NULL) {\n\t\t\tservice->soap_functions.functions_all = FALSE;\n\t\t\tservice->soap_functions.ft = emalloc(sizeof(HashTable));\n\t\t\tzend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);\n\t\t}\n\n\t\tMAKE_STD_ZVAL(function_copy);\n\t\tZVAL_STRING(function_copy, f->common.function_name, 1);\n\t\tzend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);\n\t\tefree(key);\n\t} else if (function_name->type == IS_LONG) {\n\t\tif (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {\n\t\t\tif (service->soap_functions.ft != NULL) {\n\t\t\t\tzend_hash_destroy(service->soap_functions.ft);\n\t\t\t\tefree(service->soap_functions.ft);\n\t\t\t\tservice->soap_functions.ft = NULL;\n\t\t\t}\n\t\t\tservice->soap_functions.functions_all = TRUE;\n\t\t} else {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid value passed\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tSOAP_SERVER_END_CODE();\n}","target":0,"code_token_length":876,"total_token_length":1112,"max_tokens_setting":2048} +{"idx":128454,"func":"static int net_slirp_init(NetClientState *peer, const char *model,\n\n const char *name, int restricted,\n\n const char *vnetwork, const char *vhost,\n\n const char *vhostname, const char *tftp_export,\n\n const char *bootfile, const char *vdhcp_start,\n\n const char *vnameserver, const char *smb_export,\n\n const char *vsmbserver, const char **dnssearch)\n\n{\n\n \/* default settings according to historic slirp *\/\n\n struct in_addr net = { .s_addr = htonl(0x0a000200) }; \/* 10.0.2.0 *\/\n\n struct in_addr mask = { .s_addr = htonl(0xffffff00) }; \/* 255.255.255.0 *\/\n\n struct in_addr host = { .s_addr = htonl(0x0a000202) }; \/* 10.0.2.2 *\/\n\n struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; \/* 10.0.2.15 *\/\n\n struct in_addr dns = { .s_addr = htonl(0x0a000203) }; \/* 10.0.2.3 *\/\n\n#ifndef _WIN32\n\n struct in_addr smbsrv = { .s_addr = 0 };\n\n#endif\n\n NetClientState *nc;\n\n SlirpState *s;\n\n char buf[20];\n\n uint32_t addr;\n\n int shift;\n\n char *end;\n\n struct slirp_config_str *config;\n\n\n\n if (!tftp_export) {\n\n tftp_export = legacy_tftp_prefix;\n\n }\n\n if (!bootfile) {\n\n bootfile = legacy_bootp_filename;\n\n }\n\n\n\n if (vnetwork) {\n\n if (get_str_sep(buf, sizeof(buf), &vnetwork, '\/') < 0) {\n\n if (!inet_aton(vnetwork, &net)) {\n\n return -1;\n\n }\n\n addr = ntohl(net.s_addr);\n\n if (!(addr & 0x80000000)) {\n\n mask.s_addr = htonl(0xff000000); \/* class A *\/\n\n } else if ((addr & 0xfff00000) == 0xac100000) {\n\n mask.s_addr = htonl(0xfff00000); \/* priv. 172.16.0.0\/12 *\/\n\n } else if ((addr & 0xc0000000) == 0x80000000) {\n\n mask.s_addr = htonl(0xffff0000); \/* class B *\/\n\n } else if ((addr & 0xffff0000) == 0xc0a80000) {\n\n mask.s_addr = htonl(0xffff0000); \/* priv. 192.168.0.0\/16 *\/\n\n } else if ((addr & 0xffff0000) == 0xc6120000) {\n\n mask.s_addr = htonl(0xfffe0000); \/* tests 198.18.0.0\/15 *\/\n\n } else if ((addr & 0xe0000000) == 0xe0000000) {\n\n mask.s_addr = htonl(0xffffff00); \/* class C *\/\n\n } else {\n\n mask.s_addr = htonl(0xfffffff0); \/* multicast\/reserved *\/\n\n }\n\n } else {\n\n if (!inet_aton(buf, &net)) {\n\n return -1;\n\n }\n\n shift = strtol(vnetwork, &end, 10);\n\n if (*end != '\\0') {\n\n if (!inet_aton(vnetwork, &mask)) {\n\n return -1;\n\n }\n\n } else if (shift < 4 || shift > 32) {\n\n return -1;\n\n } else {\n\n mask.s_addr = htonl(0xffffffff << (32 - shift));\n\n }\n\n }\n\n net.s_addr &= mask.s_addr;\n\n host.s_addr = net.s_addr | (htonl(0x0202) & ~mask.s_addr);\n\n dhcp.s_addr = net.s_addr | (htonl(0x020f) & ~mask.s_addr);\n\n dns.s_addr = net.s_addr | (htonl(0x0203) & ~mask.s_addr);\n\n }\n\n\n\n if (vhost && !inet_aton(vhost, &host)) {\n\n return -1;\n\n }\n\n if ((host.s_addr & mask.s_addr) != net.s_addr) {\n\n return -1;\n\n }\n\n\n\n if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {\n\n return -1;\n\n }\n\n if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||\n\n dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {\n\n return -1;\n\n }\n\n\n\n if (vnameserver && !inet_aton(vnameserver, &dns)) {\n\n return -1;\n\n }\n\n if ((dns.s_addr & mask.s_addr) != net.s_addr ||\n\n dns.s_addr == host.s_addr) {\n\n return -1;\n\n }\n\n\n\n#ifndef _WIN32\n\n if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {\n\n return -1;\n\n }\n\n#endif\n\n\n\n nc = qemu_new_net_client(&net_slirp_info, peer, model, name);\n\n\n\n snprintf(nc->info_str, sizeof(nc->info_str),\n\n \"net=%s,restrict=%s\", inet_ntoa(net),\n\n restricted ? \"on\" : \"off\");\n\n\n\n s = DO_UPCAST(SlirpState, nc, nc);\n\n\n\n s->slirp = slirp_init(restricted, net, mask, host, vhostname,\n\n tftp_export, bootfile, dhcp, dns, dnssearch, s);\n\n QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);\n\n\n\n for (config = slirp_configs; config; config = config->next) {\n\n if (config->flags & SLIRP_CFG_HOSTFWD) {\n\n if (slirp_hostfwd(s, config->str,\n\n config->flags & SLIRP_CFG_LEGACY) < 0)\n\n goto error;\n\n } else {\n\n if (slirp_guestfwd(s, config->str,\n\n config->flags & SLIRP_CFG_LEGACY) < 0)\n\n goto error;\n\n }\n\n }\n\n#ifndef _WIN32\n\n if (!smb_export) {\n\n smb_export = legacy_smb_export;\n\n }\n\n if (smb_export) {\n\n if (slirp_smb(s, smb_export, smbsrv) < 0)\n\n goto error;\n\n }\n\n#endif\n\n\n\n return 0;\n\n\n\nerror:\n\n qemu_del_net_client(nc);\n\n return -1;\n\n}\n","target":0,"code_token_length":1541,"total_token_length":1777,"max_tokens_setting":2048} +{"idx":428001,"func":"static int imip_send(icalcomponent *ical)\n{\n icalcomponent *comp;\n icalproperty *prop;\n icalproperty_method meth;\n icalcomponent_kind kind;\n const char *argv[8], *originator, *subject;\n FILE *sm;\n pid_t pid;\n int r;\n time_t t = time(NULL);\n char datestr[80];\n static unsigned send_count = 0;\n icalproperty_kind recip_kind;\n const char *(*get_recipient)(const icalproperty *);\n\n meth = icalcomponent_get_method(ical);\n comp = icalcomponent_get_first_real_component(ical);\n kind = icalcomponent_isa(comp);\n\n \/* Determine Originator and Recipient(s) based on methond and component *\/\n if (meth == ICAL_METHOD_REPLY) {\n\trecip_kind = ICAL_ORGANIZER_PROPERTY;\n\tget_recipient = &icalproperty_get_organizer;\n\n\tif (kind == ICAL_VPOLL_COMPONENT) {\n\t prop = icalcomponent_get_first_property(comp, ICAL_VOTER_PROPERTY);\n\t originator = icalproperty_get_voter(prop) + 7;\n\t}\n\telse {\n\t prop =\n\t\ticalcomponent_get_first_property(comp, ICAL_ATTENDEE_PROPERTY);\n\t originator = icalproperty_get_attendee(prop) + 7;\n\t}\n }\n else {\n\tprop = icalcomponent_get_first_property(comp, ICAL_ORGANIZER_PROPERTY);\n\toriginator = icalproperty_get_organizer(prop) + 7;\n\n\tif (kind == ICAL_VPOLL_COMPONENT) {\n\t recip_kind = ICAL_VOTER_PROPERTY;\n\t get_recipient = &icalproperty_get_voter;\n\t}\n\telse {\n\t recip_kind = ICAL_ATTENDEE_PROPERTY;\n\t get_recipient = &icalproperty_get_attendee;\n\t}\n }\n\n argv[0] = \"sendmail\";\n argv[1] = \"-f\";\n argv[2] = originator;\n argv[3] = \"-i\";\n argv[4] = \"-N\";\n argv[5] = \"failure,delay\";\n argv[6] = \"-t\";\n argv[7] = NULL;\n pid = open_sendmail(argv, &sm);\n\n if (sm == NULL) return HTTP_UNAVAILABLE;\n\n \/* Create iMIP message *\/\n fprintf(sm, \"From: %s\\r\\n\", originator);\n\n for (prop = icalcomponent_get_first_property(comp, recip_kind);\n\t prop;\n\t prop = icalcomponent_get_next_property(comp, recip_kind)) {\n\tfprintf(sm, \"To: %s\\r\\n\", get_recipient(prop) + 7);\n }\n\n subject = icalcomponent_get_summary(comp);\n if (!subject) {\n\tfprintf(sm, \"Subject: %s %s\\r\\n\", icalcomponent_kind_to_string(kind),\n\t\ticalproperty_method_to_string(meth));\n }\n else fprintf(sm, \"Subject: %s\\r\\n\", subject);\n\n time_to_rfc822(t, datestr, sizeof(datestr));\n fprintf(sm, \"Date: %s\\r\\n\", datestr);\n\n fprintf(sm, \"Message-ID: \\r\\n\",\n\t getpid(), t, send_count++, config_servername);\n\n fprintf(sm, \"Content-Type: text\/calendar; charset=utf-8\");\n fprintf(sm, \"; method=%s; component=%s \\r\\n\",\n\t icalproperty_method_to_string(meth),\n\t icalcomponent_kind_to_string(kind));\n\n fputs(\"Content-Disposition: inline\\r\\n\", sm);\n\n fputs(\"MIME-Version: 1.0\\r\\n\", sm);\n fputs(\"\\r\\n\", sm);\n\n fputs(icalcomponent_as_ical_string(ical), sm);\n\n fclose(sm);\n\n while (waitpid(pid, &r, 0) < 0);\n\n return r;\n}","target":0,"code_token_length":833,"total_token_length":1069,"max_tokens_setting":2048} +{"idx":52009,"func":"int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,\n\t\t\t unsigned char *out, size_t *out_len)\n{\n\tunsigned char *op;\n\tconst unsigned char *ip;\n\tsize_t t, next;\n\tsize_t state = 0;\n\tconst unsigned char *m_pos;\n\tconst unsigned char * const ip_end = in + in_len;\n\tunsigned char * const op_end = out + *out_len;\n\n\top = out;\n\tip = in;\n\n\tif (unlikely(in_len < 3))\n\t\tgoto input_overrun;\n\tif (*ip > 17) {\n\t\tt = *ip++ - 17;\n\t\tif (t < 4) {\n\t\t\tnext = t;\n\t\t\tgoto match_next;\n\t\t}\n\t\tgoto copy_literal_run;\n\t}\n\n\tfor (;;) {\n\t\tt = *ip++;\n\t\tif (t < 16) {\n\t\t\tif (likely(state == 0)) {\n\t\t\t\tif (unlikely(t == 0)) {\n\t\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\t\tt += 255;\n\t\t\t\t\t\tip++;\n\t\t\t\t\t\tNEED_IP(1, 0);\n\t\t\t\t\t}\n\t\t\t\t\tt += 15 + *ip++;\n\t\t\t\t}\n\t\t\t\tt += 3;\ncopy_literal_run:\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\t\t\tif (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) {\n\t\t\t\t\tconst unsigned char *ie = ip + t;\n\t\t\t\t\tunsigned char *oe = op + t;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tCOPY8(op, ip);\n\t\t\t\t\t\top += 8;\n\t\t\t\t\t\tip += 8;\n\t\t\t\t\t\tCOPY8(op, ip);\n\t\t\t\t\t\top += 8;\n\t\t\t\t\t\tip += 8;\n\t\t\t\t\t} while (ip < ie);\n\t\t\t\t\tip = ie;\n\t\t\t\t\top = oe;\n\t\t\t\t} else\n#endif\n\t\t\t\t{\n\t\t\t\t\tNEED_OP(t, 0);\n\t\t\t\t\tNEED_IP(t, 3);\n\t\t\t\t\tdo {\n\t\t\t\t\t\t*op++ = *ip++;\n\t\t\t\t\t} while (--t > 0);\n\t\t\t\t}\n\t\t\t\tstate = 4;\n\t\t\t\tcontinue;\n\t\t\t} else if (state != 4) {\n\t\t\t\tnext = t & 3;\n\t\t\t\tm_pos = op - 1;\n\t\t\t\tm_pos -= t >> 2;\n\t\t\t\tm_pos -= *ip++ << 2;\n\t\t\t\tTEST_LB(m_pos);\n\t\t\t\tNEED_OP(2, 0);\n\t\t\t\top[0] = m_pos[0];\n\t\t\t\top[1] = m_pos[1];\n\t\t\t\top += 2;\n\t\t\t\tgoto match_next;\n\t\t\t} else {\n\t\t\t\tnext = t & 3;\n\t\t\t\tm_pos = op - (1 + M2_MAX_OFFSET);\n\t\t\t\tm_pos -= t >> 2;\n\t\t\t\tm_pos -= *ip++ << 2;\n\t\t\t\tt = 3;\n\t\t\t}\n\t\t} else if (t >= 64) {\n\t\t\tnext = t & 3;\n\t\t\tm_pos = op - 1;\n\t\t\tm_pos -= (t >> 2) & 7;\n\t\t\tm_pos -= *ip++ << 3;\n\t\t\tt = (t >> 5) - 1 + (3 - 1);\n\t\t} else if (t >= 32) {\n\t\t\tt = (t & 31) + (3 - 1);\n\t\t\tif (unlikely(t == 2)) {\n\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\tt += 255;\n\t\t\t\t\tip++;\n\t\t\t\t\tNEED_IP(1, 0);\n\t\t\t\t}\n\t\t\t\tt += 31 + *ip++;\n\t\t\t\tNEED_IP(2, 0);\n\t\t\t}\n\t\t\tm_pos = op - 1;\n\t\t\tnext = get_unaligned_le16(ip);\n\t\t\tip += 2;\n\t\t\tm_pos -= next >> 2;\n\t\t\tnext &= 3;\n\t\t} else {\n\t\t\tm_pos = op;\n\t\t\tm_pos -= (t & 8) << 11;\n\t\t\tt = (t & 7) + (3 - 1);\n\t\t\tif (unlikely(t == 2)) {\n\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\tt += 255;\n\t\t\t\t\tip++;\n\t\t\t\t\tNEED_IP(1, 0);\n\t\t\t\t}\n\t\t\t\tt += 7 + *ip++;\n\t\t\t\tNEED_IP(2, 0);\n\t\t\t}\n\t\t\tnext = get_unaligned_le16(ip);\n\t\t\tip += 2;\n\t\t\tm_pos -= next >> 2;\n\t\t\tnext &= 3;\n\t\t\tif (m_pos == op)\n\t\t\t\tgoto eof_found;\n\t\t\tm_pos -= 0x4000;\n\t\t}\n\t\tTEST_LB(m_pos);\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\tif (op - m_pos >= 8) {\n\t\t\tunsigned char *oe = op + t;\n\t\t\tif (likely(HAVE_OP(t, 15))) {\n\t\t\t\tdo {\n\t\t\t\t\tCOPY8(op, m_pos);\n\t\t\t\t\top += 8;\n\t\t\t\t\tm_pos += 8;\n\t\t\t\t\tCOPY8(op, m_pos);\n\t\t\t\t\top += 8;\n\t\t\t\t\tm_pos += 8;\n\t\t\t\t} while (op < oe);\n\t\t\t\top = oe;\n\t\t\t\tif (HAVE_IP(6, 0)) {\n\t\t\t\t\tstate = next;\n\t\t\t\t\tCOPY4(op, ip);\n\t\t\t\t\top += next;\n\t\t\t\t\tip += next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tNEED_OP(t, 0);\n\t\t\t\tdo {\n\t\t\t\t\t*op++ = *m_pos++;\n\t\t\t\t} while (op < oe);\n\t\t\t}\n\t\t} else\n#endif\n\t\t{\n\t\t\tunsigned char *oe = op + t;\n\t\t\tNEED_OP(t, 0);\n\t\t\top[0] = m_pos[0];\n\t\t\top[1] = m_pos[1];\n\t\t\top += 2;\n\t\t\tm_pos += 2;\n\t\t\tdo {\n\t\t\t\t*op++ = *m_pos++;\n\t\t\t} while (op < oe);\n\t\t}\nmatch_next:\n\t\tstate = next;\n\t\tt = next;\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\tif (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) {\n\t\t\tCOPY4(op, ip);\n\t\t\top += t;\n\t\t\tip += t;\n\t\t} else\n#endif\n\t\t{\n\t\t\tNEED_IP(t, 3);\n\t\t\tNEED_OP(t, 0);\n\t\t\twhile (t > 0) {\n\t\t\t\t*op++ = *ip++;\n\t\t\t\tt--;\n\t\t\t}\n\t\t}\n\t}\n\neof_found:\n\t*out_len = op - out;\n\treturn (t != 3 ? LZO_E_ERROR :\n\t\tip == ip_end ? LZO_E_OK :\n\t\tip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN);\n\ninput_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_INPUT_OVERRUN;\n\noutput_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_OUTPUT_OVERRUN;\n\nlookbehind_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_LOOKBEHIND_OVERRUN;\n}","target":0,"code_token_length":1524,"total_token_length":1760,"max_tokens_setting":2048} +{"idx":275387,"func":"static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, int flags TSRMLS_DC) \/* {{{ *\/\n{\n\tconst char *spec_walk;\n\tint c, i;\n\tint min_num_args = -1;\n\tint max_num_args = 0;\n\tint post_varargs = 0;\n\tzval **arg;\n\tint arg_count;\n\tint quiet = flags & ZEND_PARSE_PARAMS_QUIET;\n\tzend_bool have_varargs = 0;\n\tzval ****varargs = NULL;\n\tint *n_varargs = NULL;\n\n\tfor (spec_walk = type_spec; *spec_walk; spec_walk++) {\n\t\tc = *spec_walk;\n\t\tswitch (c) {\n\t\t\tcase 'l': case 'd':\n\t\t\tcase 's': case 'b':\n\t\t\tcase 'r': case 'a':\n\t\t\tcase 'o': case 'O':\n\t\t\tcase 'z': case 'Z':\n\t\t\tcase 'C': case 'h':\n\t\t\tcase 'f': case 'A':\n\t\t\tcase 'H': case 'p':\n\t\t\t\tmax_num_args++;\n\t\t\t\tbreak;\n\n\t\t\tcase '|':\n\t\t\t\tmin_num_args = max_num_args;\n\t\t\t\tbreak;\n\n\t\t\tcase '\/':\n\t\t\tcase '!':\n\t\t\t\t\/* Pass *\/\n\t\t\t\tbreak;\n\n\t\t\tcase '*':\n\t\t\tcase '+':\n\t\t\t\tif (have_varargs) {\n\t\t\t\t\tif (!quiet) {\n\t\t\t\t\t\tzend_function *active_function = EG(current_execute_data)->function_state.function;\n\t\t\t\t\t\tconst char *class_name = active_function->common.scope ? active_function->common.scope->name : \"\";\n\t\t\t\t\t\tzend_error(E_WARNING, \"%s%s%s(): only one varargs specifier (* or +) is permitted\",\n\t\t\t\t\t\t\t\tclass_name,\n\t\t\t\t\t\t\t\tclass_name[0] ? \"::\" : \"\",\n\t\t\t\t\t\t\t\tactive_function->common.function_name);\n\t\t\t\t\t}\n\t\t\t\t\treturn FAILURE;\n\t\t\t\t}\n\t\t\t\thave_varargs = 1;\n\t\t\t\t\/* we expect at least one parameter in varargs *\/\n\t\t\t\tif (c == '+') {\n\t\t\t\t\tmax_num_args++;\n\t\t\t\t}\n\t\t\t\t\/* mark the beginning of varargs *\/\n\t\t\t\tpost_varargs = max_num_args;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tif (!quiet) {\n\t\t\t\t\tzend_function *active_function = EG(current_execute_data)->function_state.function;\n\t\t\t\t\tconst char *class_name = active_function->common.scope ? active_function->common.scope->name : \"\";\n\t\t\t\t\tzend_error(E_WARNING, \"%s%s%s(): bad type specifier while parsing parameters\",\n\t\t\t\t\t\t\tclass_name,\n\t\t\t\t\t\t\tclass_name[0] ? \"::\" : \"\",\n\t\t\t\t\t\t\tactive_function->common.function_name);\n\t\t\t\t}\n\t\t\t\treturn FAILURE;\n\t\t}\n\t}\n\n\tif (min_num_args < 0) {\n\t\tmin_num_args = max_num_args;\n\t}\n\n\tif (have_varargs) {\n\t\t\/* calculate how many required args are at the end of the specifier list *\/\n\t\tpost_varargs = max_num_args - post_varargs;\n\t\tmax_num_args = -1;\n\t}\n\n\tif (num_args < min_num_args || (num_args > max_num_args && max_num_args > 0)) {\n\t\tif (!quiet) {\n\t\t\tzend_function *active_function = EG(current_execute_data)->function_state.function;\n\t\t\tconst char *class_name = active_function->common.scope ? active_function->common.scope->name : \"\";\n\t\t\tzend_error(E_WARNING, \"%s%s%s() expects %s %d parameter%s, %d given\",\n\t\t\t\t\tclass_name,\n\t\t\t\t\tclass_name[0] ? \"::\" : \"\",\n\t\t\t\t\tactive_function->common.function_name,\n\t\t\t\t\tmin_num_args == max_num_args ? \"exactly\" : num_args < min_num_args ? \"at least\" : \"at most\",\n\t\t\t\t\tnum_args < min_num_args ? min_num_args : max_num_args,\n\t\t\t\t\t(num_args < min_num_args ? min_num_args : max_num_args) == 1 ? \"\" : \"s\",\n\t\t\t\t\tnum_args);\n\t\t}\n\t\treturn FAILURE;\n\t}\n\n\targ_count = (int)(zend_uintptr_t) *(zend_vm_stack_top(TSRMLS_C) - 1);\n\n\tif (num_args > arg_count) {\n\t\tzend_error(E_WARNING, \"%s(): could not obtain parameters for parsing\",\n\t\t\tget_active_function_name(TSRMLS_C));\n\t\treturn FAILURE;\n\t}\n\n\ti = 0;\n\twhile (num_args-- > 0) {\n\t\tif (*type_spec == '|') {\n\t\t\ttype_spec++;\n\t\t}\n\n\t\tif (*type_spec == '*' || *type_spec == '+') {\n\t\t\tint num_varargs = num_args + 1 - post_varargs;\n\n\t\t\t\/* eat up the passed in storage even if it won't be filled in with varargs *\/\n\t\t\tvarargs = va_arg(*va, zval ****);\n\t\t\tn_varargs = va_arg(*va, int *);\n\t\t\ttype_spec++;\n\n\t\t\tif (num_varargs > 0) {\n\t\t\t\tint iv = 0;\n\t\t\t\tzval **p = (zval **) (zend_vm_stack_top(TSRMLS_C) - 1 - (arg_count - i));\n\n\t\t\t\t*n_varargs = num_varargs;\n\n\t\t\t\t\/* allocate space for array and store args *\/\n\t\t\t\t*varargs = safe_emalloc(num_varargs, sizeof(zval **), 0);\n\t\t\t\twhile (num_varargs-- > 0) {\n\t\t\t\t\t(*varargs)[iv++] = p++;\n\t\t\t\t}\n\n\t\t\t\t\/* adjust how many args we have left and restart loop *\/\n\t\t\t\tnum_args = num_args + 1 - iv;\n\t\t\t\ti += iv;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\t*varargs = NULL;\n\t\t\t\t*n_varargs = 0;\n\t\t\t}\n\t\t}\n\n\t\targ = (zval **) (zend_vm_stack_top(TSRMLS_C) - 1 - (arg_count-i));\n\n\t\tif (zend_parse_arg(i+1, arg, va, &type_spec, quiet TSRMLS_CC) == FAILURE) {\n\t\t\t\/* clean up varargs array if it was used *\/\n\t\t\tif (varargs && *varargs) {\n\t\t\t\tefree(*varargs);\n\t\t\t\t*varargs = NULL;\n\t\t\t}\n\t\t\treturn FAILURE;\n\t\t}\n\t\ti++;\n\t}\n\n\treturn SUCCESS;\n}\n\/* }}} *\/\n","target":0,"code_token_length":1275,"total_token_length":1511,"max_tokens_setting":2048} +{"idx":341462,"func":"static int parse_presentation_segment(AVCodecContext *avctx,\n const uint8_t *buf, int buf_size,\n int64_t pts)\n{\n PGSSubContext *ctx = avctx->priv_data;\n int i, state, ret;\n const uint8_t *buf_end = buf + buf_size;\n \/\/ Video descriptor\n int w = bytestream_get_be16(&buf);\n int h = bytestream_get_be16(&buf);\n uint16_t object_index;\n ctx->presentation.pts = pts;\n av_dlog(avctx, \"Video Dimensions %dx%d\\n\",\n w, h);\n ret = ff_set_dimensions(avctx, w, h);\n if (ret < 0)\n return ret;\n \/* Skip 1 bytes of unknown, frame rate *\/\n buf++;\n \/\/ Composition descriptor\n ctx->presentation.id_number = bytestream_get_be16(&buf);\n \/*\n * state is a 2 bit field that defines pgs epoch boundaries\n * 00 - Normal, previously defined objects and palettes are still valid\n * 01 - Acquisition point, previous objects and palettes can be released\n * 10 - Epoch start, previous objects and palettes can be released\n * 11 - Epoch continue, previous objects and palettes can be released\n *\n * reserved 6 bits discarded\n *\/\n state = bytestream_get_byte(&buf) >> 6;\n if (state != 0) {\n flush_cache(avctx);\n \/*\n * skip palette_update_flag (0x80),\n *\/\n buf += 1;\n ctx->presentation.palette_id = bytestream_get_byte(&buf);\n ctx->presentation.object_count = bytestream_get_byte(&buf);\n if (ctx->presentation.object_count > MAX_OBJECT_REFS) {\n av_log(avctx, AV_LOG_ERROR,\n \"Invalid number of presentation objects %d\\n\",\n ctx->presentation.object_count);\n ctx->presentation.object_count = 2;\n if (avctx->err_recognition & AV_EF_EXPLODE) {\n for (i = 0; i < ctx->presentation.object_count; i++)\n {\n ctx->presentation.objects[i].id = bytestream_get_be16(&buf);\n ctx->presentation.objects[i].window_id = bytestream_get_byte(&buf);\n ctx->presentation.objects[i].composition_flag = bytestream_get_byte(&buf);\n ctx->presentation.objects[i].x = bytestream_get_be16(&buf);\n ctx->presentation.objects[i].y = bytestream_get_be16(&buf);\n \/\/ If cropping\n if (ctx->presentation.objects[i].composition_flag & 0x80) {\n ctx->presentation.objects[i].crop_x = bytestream_get_be16(&buf);\n ctx->presentation.objects[i].crop_y = bytestream_get_be16(&buf);\n ctx->presentation.objects[i].crop_w = bytestream_get_be16(&buf);\n ctx->presentation.objects[i].crop_h = bytestream_get_be16(&buf);\n av_dlog(avctx, \"Subtitle Placement x=%d, y=%d\\n\",\n ctx->presentation.objects[i].x, ctx->presentation.objects[i].y);\n if (ctx->presentation.objects[i].x > avctx->width ||\n ctx->presentation.objects[i].y > avctx->height) {\n av_log(avctx, AV_LOG_ERROR, \"Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\\n\",\n ctx->presentation.objects[i].x,\n ctx->presentation.objects[i].y,\n avctx->width, avctx->height);\n ctx->presentation.objects[i].x = 0;\n ctx->presentation.objects[i].y = 0;\n if (avctx->err_recognition & AV_EF_EXPLODE) {\n return 0;","target":1,"code_token_length":858,"total_token_length":1094,"max_tokens_setting":2048} +{"idx":438169,"func":"long long Segment::CreateInstance(IMkvReader* pReader, long long pos,\n Segment*& pSegment) {\n if (pReader == NULL || pos < 0)\n return E_PARSE_FAILED;\n\n pSegment = NULL;\n\n long long total, available;\n\n const long status = pReader->Length(&total, &available);\n\n if (status < 0) \/\/ error\n return status;\n\n if (available < 0)\n return -1;\n\n if ((total >= 0) && (available > total))\n return -1;\n\n \/\/ I would assume that in practice this loop would execute\n \/\/ exactly once, but we allow for other elements (e.g. Void)\n \/\/ to immediately follow the EBML header. This is fine for\n \/\/ the source filter case (since the entire file is available),\n \/\/ but in the splitter case over a network we should probably\n \/\/ just give up early. We could for example decide only to\n \/\/ execute this loop a maximum of, say, 10 times.\n \/\/ TODO:\n \/\/ There is an implied \"give up early\" by only parsing up\n \/\/ to the available limit. We do do that, but only if the\n \/\/ total file size is unknown. We could decide to always\n \/\/ use what's available as our limit (irrespective of whether\n \/\/ we happen to know the total file length). This would have\n \/\/ as its sense \"parse this much of the file before giving up\",\n \/\/ which a slightly different sense from \"try to parse up to\n \/\/ 10 EMBL elements before giving up\".\n\n for (;;) {\n if ((total >= 0) && (pos >= total))\n return E_FILE_FORMAT_INVALID;\n\n \/\/ Read ID\n long len;\n long long result = GetUIntLength(pReader, pos, len);\n\n if (result) \/\/ error, or too few available bytes\n return result;\n\n if ((total >= 0) && ((pos + len) > total))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > available)\n return pos + len;\n\n const long long idpos = pos;\n const long long id = ReadID(pReader, pos, len);\n\n if (id < 0)\n return E_FILE_FORMAT_INVALID;\n\n pos += len; \/\/ consume ID\n\n \/\/ Read Size\n\n result = GetUIntLength(pReader, pos, len);\n\n if (result) \/\/ error, or too few available bytes\n return result;\n\n if ((total >= 0) && ((pos + len) > total))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > available)\n return pos + len;\n\n long long size = ReadUInt(pReader, pos, len);\n\n if (size < 0) \/\/ error\n return size;\n\n pos += len; \/\/ consume length of size of element\n\n \/\/ Pos now points to start of payload\n\n \/\/ Handle \"unknown size\" for live streaming of webm files.\n const long long unknown_size = (1LL << (7 * len)) - 1;\n\n if (id == libwebm::kMkvSegment) {\n if (size == unknown_size)\n size = -1;\n\n else if (total < 0)\n size = -1;\n\n else if ((pos + size) > total)\n size = -1;\n\n pSegment = new (std::nothrow) Segment(pReader, idpos, pos, size);\n if (pSegment == NULL)\n return E_PARSE_FAILED;\n\n return 0; \/\/ success\n }\n\n if (size == unknown_size)\n return E_FILE_FORMAT_INVALID;\n\n if ((total >= 0) && ((pos + size) > total))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + size) > available)\n return pos + size;\n\n pos += size; \/\/ consume payload\n }\n}","target":0,"code_token_length":852,"total_token_length":1088,"max_tokens_setting":2048} +{"idx":496535,"func":" bool operator() (SFace_handle sf1, SFace_handle sf2) const {\n CGAL_NEF_TRACEN(\"sort sfaces\");\n if(&*sf1 == &*sf2) return false;\n\n sort_vertices SORT(*this->sncp());\n\n CGAL_NEF_TRACEN(\" vertices \" << sf1->center_vertex()->point() << \" , \" << sf2->center_vertex()->point());\n if(sf1->center_vertex() != sf2->center_vertex())\n return SORT(sf1->center_vertex(), sf2->center_vertex());\n\n \/\/ sort_sface_cycle_entries sort_cycles((Base) *this);\n \/\/ return sort_cycles(*sf1->sface_cycles_begin(), *sf2->sface_cycles_begin());\n\n SM_decorator SD(&*sf1->center_vertex());\n moreLeft ml((Base) *this);\n Vector_3 plus(1,0,0);\n\n SFace_cycle_iterator fc;\n\n CGAL_NEF_TRACEN(\" sface 1\");\n\n SHalfedge_handle se1;\n SHalfloop_handle sl1;\n CGAL_forall_sface_cycles_of(fc,sf1) {\n if(fc.is_shalfedge()) {\n SHalfedge_handle se(fc);\n SHalfedge_around_sface_circulator ec(se),ee(se);\n CGAL_For_all(ec,ee) {\n CGAL_NEF_TRACEN(\" \" << ec->source()->point() <<\n \" | \" << ec->circle().orthogonal_vector());\n if(ml(ec, se1) == -1)\n se1 = ec;\n }\n }\n else if(fc.is_shalfloop())\n sl1 = SHalfloop_handle(fc);\n else\n CGAL_assertion(fc.is_svertex());\n }\n\n CGAL_NEF_TRACEN(\" sface 2\");\n\n SHalfedge_handle se2;\n SHalfloop_handle sl2;\n CGAL_forall_sface_cycles_of(fc,sf2) {\n if(fc.is_shalfedge()) {\n SHalfedge_handle se(fc);\n SHalfedge_around_sface_circulator ec(se),ee(se);\n CGAL_For_all(ec,ee) {\n CGAL_NEF_TRACEN(\" \" << ec->source()->point() <<\n \" | \" << ec->circle().orthogonal_vector());\n if(ml(ec, se2) == -1)\n se2 = ec;\n }\n }\n else if(fc.is_shalfloop())\n sl2 = SHalfloop_handle(fc);\n else\n CGAL_assertion(fc.is_svertex());\n }\n\n CGAL_NEF_TRACEN(\" sedge cycles existing? \" << (se1 != SHalfedge_handle())\n << \" , \" << (se2 != SHalfedge_handle()));\n\n if(se1 != SHalfedge_handle() && se2 == SHalfedge_handle())\n return true;\n if(se1 == SHalfedge_handle() && se2 != SHalfedge_handle())\n return false;\n\n if(se1 == SHalfedge_handle() && se2 == SHalfedge_handle()) {\n Vector_3 vec1 = sl1->circle().orthogonal_vector();\n Vector_3 vec2 = sl2->circle().orthogonal_vector();\n CGAL_NEF_TRACEN(\" sloops \" << vec1 << \" , \" << vec2);\n if(vec1.x() != vec2.x())\n return vec1.x() < vec2.x();\n else if(vec1.y() != vec2.y())\n return vec1.y() < vec2.y();\n else if(vec1.z() != vec2.z())\n return vec1.z() < vec2.z();\n }\n\n CGAL_assertion(se1 != SHalfedge_handle() && se2 != SHalfedge_handle());\n\n CGAL_NEF_TRACEN(\" minimal sedge in sface 1:\" << se1->source()->point() <<\n \" , \" << se1->circle().orthogonal_vector());\n CGAL_NEF_TRACEN(\" minimal sedge in sface 2:\" << se2->source()->point() <<\n \" , \" << se2->circle().orthogonal_vector());\n CGAL_NEF_TRACEN(\"result \" << ml(se1,se2));\n switch(ml(se1, se2)) {\n case -1: return true;\n case 1: return false;\n }\n sort_sface_cycle_entries SORTSFC(*this->sncp());\n return SORTSFC(*sf1->sface_cycles_begin(), *sf2->sface_cycles_begin());\n }","target":0,"code_token_length":995,"total_token_length":1231,"max_tokens_setting":2048} +{"idx":259543,"func":"static int setup_netdev(struct lxc_netdev *netdev)\n{\n\tchar ifname[IFNAMSIZ];\n\tchar *current_ifname = ifname;\n\tint err;\n\n\t\/* empty network namespace *\/\n\tif (!netdev->ifindex) {\n\t\tif (netdev->flags & IFF_UP) {\n\t\t\terr = lxc_netdev_up(\"lo\");\n\t\t\tif (err) {\n\t\t\t\tERROR(\"failed to set the loopback up : %s\",\n\t\t\t\t strerror(-err));\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tif (netdev->type != LXC_NET_VETH)\n\t\t\treturn 0;\n\t\tnetdev->ifindex = if_nametoindex(netdev->name);\n\t}\n\n\t\/* get the new ifindex in case of physical netdev *\/\n\tif (netdev->type == LXC_NET_PHYS) {\n\t\tif (!(netdev->ifindex = if_nametoindex(netdev->link))) {\n\t\t\tERROR(\"failed to get ifindex for %s\",\n\t\t\t\tnetdev->link);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t\/* retrieve the name of the interface *\/\n\tif (!if_indextoname(netdev->ifindex, current_ifname)) {\n\t\tERROR(\"no interface corresponding to index '%d'\",\n\t\t netdev->ifindex);\n\t\treturn -1;\n\t}\n\n\t\/* default: let the system to choose one interface name *\/\n\tif (!netdev->name)\n\t\tnetdev->name = netdev->type == LXC_NET_PHYS ?\n\t\t\tnetdev->link : \"eth%d\";\n\n\t\/* rename the interface name *\/\n\tif (strcmp(ifname, netdev->name) != 0) {\n\t\terr = lxc_netdev_rename_by_name(ifname, netdev->name);\n\t\tif (err) {\n\t\t\tERROR(\"failed to rename %s->%s : %s\", ifname, netdev->name,\n\t\t\t strerror(-err));\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t\/* Re-read the name of the interface because its name has changed\n\t * and would be automatically allocated by the system\n\t *\/\n\tif (!if_indextoname(netdev->ifindex, current_ifname)) {\n\t\tERROR(\"no interface corresponding to index '%d'\",\n\t\t netdev->ifindex);\n\t\treturn -1;\n\t}\n\n\t\/* set a mac address *\/\n\tif (netdev->hwaddr) {\n\t\tif (setup_hw_addr(netdev->hwaddr, current_ifname)) {\n\t\t\tERROR(\"failed to setup hw address for '%s'\",\n\t\t\t current_ifname);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t\/* setup ipv4 addresses on the interface *\/\n\tif (setup_ipv4_addr(&netdev->ipv4, netdev->ifindex)) {\n\t\tERROR(\"failed to setup ip addresses for '%s'\",\n\t\t\t ifname);\n\t\treturn -1;\n\t}\n\n\t\/* setup ipv6 addresses on the interface *\/\n\tif (setup_ipv6_addr(&netdev->ipv6, netdev->ifindex)) {\n\t\tERROR(\"failed to setup ipv6 addresses for '%s'\",\n\t\t\t ifname);\n\t\treturn -1;\n\t}\n\n\t\/* set the network device up *\/\n\tif (netdev->flags & IFF_UP) {\n\t\tint err;\n\n\t\terr = lxc_netdev_up(current_ifname);\n\t\tif (err) {\n\t\t\tERROR(\"failed to set '%s' up : %s\", current_ifname,\n\t\t\t strerror(-err));\n\t\t\treturn -1;\n\t\t}\n\n\t\t\/* the network is up, make the loopback up too *\/\n\t\terr = lxc_netdev_up(\"lo\");\n\t\tif (err) {\n\t\t\tERROR(\"failed to set the loopback up : %s\",\n\t\t\t strerror(-err));\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t\/* We can only set up the default routes after bringing\n\t * up the interface, sine bringing up the interface adds\n\t * the link-local routes and we can't add a default\n\t * route if the gateway is not reachable. *\/\n\n\t\/* setup ipv4 gateway on the interface *\/\n\tif (netdev->ipv4_gateway) {\n\t\tif (!(netdev->flags & IFF_UP)) {\n\t\t\tERROR(\"Cannot add ipv4 gateway for %s when not bringing up the interface\", ifname);\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (lxc_list_empty(&netdev->ipv4)) {\n\t\t\tERROR(\"Cannot add ipv4 gateway for %s when not assigning an address\", ifname);\n\t\t\treturn -1;\n\t\t}\n\n\t\terr = lxc_ipv4_gateway_add(netdev->ifindex, netdev->ipv4_gateway);\n\t\tif (err) {\n\t\t\terr = lxc_ipv4_dest_add(netdev->ifindex, netdev->ipv4_gateway);\n\t\t\tif (err) {\n\t\t\t\tERROR(\"failed to add ipv4 dest for '%s': %s\",\n\t\t\t\t\t ifname, strerror(-err));\n\t\t\t}\n\n\t\t\terr = lxc_ipv4_gateway_add(netdev->ifindex, netdev->ipv4_gateway);\n\t\t\tif (err) {\n\t\t\t\tERROR(\"failed to setup ipv4 gateway for '%s': %s\",\n\t\t\t\t\t ifname, strerror(-err));\n\t\t\t\tif (netdev->ipv4_gateway_auto) {\n\t\t\t\t\tchar buf[INET_ADDRSTRLEN];\n\t\t\t\t\tinet_ntop(AF_INET, netdev->ipv4_gateway, buf, sizeof(buf));\n\t\t\t\t\tERROR(\"tried to set autodetected ipv4 gateway '%s'\", buf);\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* setup ipv6 gateway on the interface *\/\n\tif (netdev->ipv6_gateway) {\n\t\tif (!(netdev->flags & IFF_UP)) {\n\t\t\tERROR(\"Cannot add ipv6 gateway for %s when not bringing up the interface\", ifname);\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (lxc_list_empty(&netdev->ipv6) && !IN6_IS_ADDR_LINKLOCAL(netdev->ipv6_gateway)) {\n\t\t\tERROR(\"Cannot add ipv6 gateway for %s when not assigning an address\", ifname);\n\t\t\treturn -1;\n\t\t}\n\n\t\terr = lxc_ipv6_gateway_add(netdev->ifindex, netdev->ipv6_gateway);\n\t\tif (err) {\n\t\t\terr = lxc_ipv6_dest_add(netdev->ifindex, netdev->ipv6_gateway);\n\t\t\tif (err) {\n\t\t\t\tERROR(\"failed to add ipv6 dest for '%s': %s\",\n\t\t\t\t ifname, strerror(-err));\n\t\t\t}\n\n\t\t\terr = lxc_ipv6_gateway_add(netdev->ifindex, netdev->ipv6_gateway);\n\t\t\tif (err) {\n\t\t\t\tERROR(\"failed to setup ipv6 gateway for '%s': %s\",\n\t\t\t\t\t ifname, strerror(-err));\n\t\t\t\tif (netdev->ipv6_gateway_auto) {\n\t\t\t\t\tchar buf[INET6_ADDRSTRLEN];\n\t\t\t\t\tinet_ntop(AF_INET6, netdev->ipv6_gateway, buf, sizeof(buf));\n\t\t\t\t\tERROR(\"tried to set autodetected ipv6 gateway '%s'\", buf);\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\tDEBUG(\"'%s' has been setup\", current_ifname);\n\n\treturn 0;\n}","target":0,"code_token_length":1497,"total_token_length":1733,"max_tokens_setting":2048} +{"idx":43294,"func":"do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_open *open, struct svc_fh **resfh)\n{\n\tstruct svc_fh *current_fh = &cstate->current_fh;\n\tint accmode;\n\t__be32 status;\n\n\t*resfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);\n\tif (!*resfh)\n\t\treturn nfserr_jukebox;\n\tfh_init(*resfh, NFS4_FHSIZE);\n\topen->op_truncate = 0;\n\n\tif (open->op_create) {\n\t\t\/* FIXME: check session persistence and pnfs flags.\n\t\t * The nfsv4.1 spec requires the following semantics:\n\t\t *\n\t\t * Persistent | pNFS | Server REQUIRED | Client Allowed\n\t\t * Reply Cache | server | |\n\t\t * -------------+--------+-----------------+--------------------\n\t\t * no | no | EXCLUSIVE4_1 | EXCLUSIVE4_1\n\t\t * | | | (SHOULD)\n\t\t * | | and EXCLUSIVE4 | or EXCLUSIVE4\n\t\t * | | | (SHOULD NOT)\n\t\t * no | yes | EXCLUSIVE4_1 | EXCLUSIVE4_1\n\t\t * yes | no | GUARDED4 | GUARDED4\n\t\t * yes | yes | GUARDED4 | GUARDED4\n\t\t *\/\n\n\t\t\/*\n\t\t * Note: create modes (UNCHECKED,GUARDED...) are the same\n\t\t * in NFSv4 as in v3 except EXCLUSIVE4_1.\n\t\t *\/\n\t\tstatus = do_nfsd_create(rqstp, current_fh, open->op_fname.data,\n\t\t\t\t\topen->op_fname.len, &open->op_iattr,\n\t\t\t\t\t*resfh, open->op_createmode,\n\t\t\t\t\t(u32 *)open->op_verf.data,\n\t\t\t\t\t&open->op_truncate, &open->op_created);\n\n\t\tif (!status && open->op_label.len)\n\t\t\tnfsd4_security_inode_setsecctx(*resfh, &open->op_label, open->op_bmval);\n\n\t\t\/*\n\t\t * Following rfc 3530 14.2.16, and rfc 5661 18.16.4\n\t\t * use the returned bitmask to indicate which attributes\n\t\t * we used to store the verifier:\n\t\t *\/\n\t\tif (nfsd_create_is_exclusive(open->op_createmode) && status == 0)\n\t\t\topen->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS |\n\t\t\t\t\t\tFATTR4_WORD1_TIME_MODIFY);\n\t} else\n\t\t\/*\n\t\t * Note this may exit with the parent still locked.\n\t\t * We will hold the lock until nfsd4_open's final\n\t\t * lookup, to prevent renames or unlinks until we've had\n\t\t * a chance to an acquire a delegation if appropriate.\n\t\t *\/\n\t\tstatus = nfsd_lookup(rqstp, current_fh,\n\t\t\t\t open->op_fname.data, open->op_fname.len, *resfh);\n\tif (status)\n\t\tgoto out;\n\tstatus = nfsd_check_obj_isreg(*resfh);\n\tif (status)\n\t\tgoto out;\n\n\tif (is_create_with_attrs(open) && open->op_acl != NULL)\n\t\tdo_set_nfs4_acl(rqstp, *resfh, open->op_acl, open->op_bmval);\n\n\tnfsd4_set_open_owner_reply_cache(cstate, open, *resfh);\n\taccmode = NFSD_MAY_NOP;\n\tif (open->op_created ||\n\t\t\topen->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR)\n\t\taccmode |= NFSD_MAY_OWNER_OVERRIDE;\n\tstatus = do_open_permission(rqstp, *resfh, open, accmode);\n\tset_change_info(&open->op_cinfo, current_fh);\nout:\n\treturn status;\n}","target":0,"code_token_length":842,"total_token_length":1078,"max_tokens_setting":2048} +{"idx":440910,"func":"vnc_display_setup_auth(int *auth,\n int *subauth,\n QCryptoTLSCreds *tlscreds,\n bool password,\n bool sasl,\n bool websocket,\n Error **errp)\n{\n \/*\n * We have a choice of 3 authentication options\n *\n * 1. none\n * 2. vnc\n * 3. sasl\n *\n * The channel can be run in 2 modes\n *\n * 1. clear\n * 2. tls\n *\n * And TLS can use 2 types of credentials\n *\n * 1. anon\n * 2. x509\n *\n * We thus have 9 possible logical combinations\n *\n * 1. clear + none\n * 2. clear + vnc\n * 3. clear + sasl\n * 4. tls + anon + none\n * 5. tls + anon + vnc\n * 6. tls + anon + sasl\n * 7. tls + x509 + none\n * 8. tls + x509 + vnc\n * 9. tls + x509 + sasl\n *\n * These need to be mapped into the VNC auth schemes\n * in an appropriate manner. In regular VNC, all the\n * TLS options get mapped into VNC_AUTH_VENCRYPT\n * sub-auth types.\n *\n * In websockets, the https:\/\/ protocol already provides\n * TLS support, so there is no need to make use of the\n * VeNCrypt extension. Furthermore, websockets browser\n * clients could not use VeNCrypt even if they wanted to,\n * as they cannot control when the TLS handshake takes\n * place. Thus there is no option but to rely on https:\/\/,\n * meaning combinations 4->6 and 7->9 will be mapped to\n * VNC auth schemes in the same way as combos 1->3.\n *\n * Regardless of fact that we have a different mapping to\n * VNC auth mechs for plain VNC vs websockets VNC, the end\n * result has the same security characteristics.\n *\/\n if (websocket || !tlscreds) {\n if (password) {\n VNC_DEBUG(\"Initializing VNC server with password auth\\n\");\n *auth = VNC_AUTH_VNC;\n } else if (sasl) {\n VNC_DEBUG(\"Initializing VNC server with SASL auth\\n\");\n *auth = VNC_AUTH_SASL;\n } else {\n VNC_DEBUG(\"Initializing VNC server with no auth\\n\");\n *auth = VNC_AUTH_NONE;\n }\n *subauth = VNC_AUTH_INVALID;\n } else {\n bool is_x509 = object_dynamic_cast(OBJECT(tlscreds),\n TYPE_QCRYPTO_TLS_CREDS_X509) != NULL;\n bool is_anon = object_dynamic_cast(OBJECT(tlscreds),\n TYPE_QCRYPTO_TLS_CREDS_ANON) != NULL;\n\n if (!is_x509 && !is_anon) {\n error_setg(errp,\n \"Unsupported TLS cred type %s\",\n object_get_typename(OBJECT(tlscreds)));\n return -1;\n }\n *auth = VNC_AUTH_VENCRYPT;\n if (password) {\n if (is_x509) {\n VNC_DEBUG(\"Initializing VNC server with x509 password auth\\n\");\n *subauth = VNC_AUTH_VENCRYPT_X509VNC;\n } else {\n VNC_DEBUG(\"Initializing VNC server with TLS password auth\\n\");\n *subauth = VNC_AUTH_VENCRYPT_TLSVNC;\n }\n\n } else if (sasl) {\n if (is_x509) {\n VNC_DEBUG(\"Initializing VNC server with x509 SASL auth\\n\");\n *subauth = VNC_AUTH_VENCRYPT_X509SASL;\n } else {\n VNC_DEBUG(\"Initializing VNC server with TLS SASL auth\\n\");\n *subauth = VNC_AUTH_VENCRYPT_TLSSASL;\n }\n } else {\n if (is_x509) {\n VNC_DEBUG(\"Initializing VNC server with x509 no auth\\n\");\n *subauth = VNC_AUTH_VENCRYPT_X509NONE;\n } else {\n VNC_DEBUG(\"Initializing VNC server with TLS no auth\\n\");\n *subauth = VNC_AUTH_VENCRYPT_TLSNONE;\n }\n }\n }\n return 0;\n}","target":0,"code_token_length":1023,"total_token_length":1259,"max_tokens_setting":2048} +{"idx":114919,"func":"Status ConstantFolding::MaterializeBroadcastGradientArgs(\n const NodeDef& node, const GraphProperties& properties) {\n const NodeDef* shape_node1 = node_map_->GetNode(node.input(0));\n const NodeDef* shape_node2 = node_map_->GetNode(node.input(1));\n if (shape_node1 == nullptr ||\n (shape_node1->op() != \"Shape\" && !IsReallyConstant(*shape_node1)) ||\n shape_node2 == nullptr ||\n (shape_node2->op() != \"Shape\" && !IsReallyConstant(*shape_node2))) {\n return Status::OK();\n }\n\n \/\/ Don't optimize this again if it was already optimized and folded.\n if (OptimizedNodeExists(node, \"-folded-1\") ||\n OptimizedNodeExists(node, \"-folded-2\")) {\n return Status::OK();\n }\n int64_t min_id = 0;\n BCast::Vec shape1;\n if (!ExtractShape(*shape_node1, properties, &shape1, &min_id)) {\n return Status::OK();\n }\n BCast::Vec shape2;\n if (!ExtractShape(*shape_node2, properties, &shape2, &min_id)) {\n return Status::OK();\n }\n \/\/ A value of -1 means we don't known anything about the dimension. Replace\n \/\/ the -1 values with unique dimension ids since we don't want two '-1'\n \/\/ dimensions to be considered equal.\n for (auto& id : shape1) {\n if (id == -1) {\n id = --min_id;\n }\n }\n for (auto& id : shape2) {\n if (id == -1) {\n id = --min_id;\n }\n }\n\n \/\/ Beware: the reduction dimensions computed by the BCast class are valid iff\n \/\/ we assume that two distinct symbolic dimensions can't be equal and a\n \/\/ symbolic dimension can't be equal to 1. This is often but not always true,\n \/\/ so to make this optimization safe we filter out these cases.\n const int common_dims = std::min(shape1.size(), shape2.size());\n for (int i = 0; i < common_dims; ++i) {\n if (shape1[i] >= 0 && shape2[i] >= 0) {\n continue;\n }\n if (shape1[i] != shape2[i]) {\n \/\/ We're either dealing with 2 different symbolic dimensions or a symbolic\n \/\/ and a know dimensions. We can't be sure whether both are equal or not,\n \/\/ so we can't be sure whether we'll be broadcasting or not.\n return Status::OK();\n }\n }\n \/\/ These extra dims could be equal to 1, in which case there is no\n \/\/ broadcasting. It could also be greater than 1, in which case there would\n \/\/ be broadcasting. Since we don't know, we'll just punt.\n for (int i = common_dims, end = shape1.size(); i < end; ++i) {\n if (shape1[i] < 0) {\n return Status::OK();\n }\n }\n for (int i = common_dims, end = shape2.size(); i < end; ++i) {\n if (shape2[i] < 0) {\n return Status::OK();\n }\n }\n\n BCast bcast(shape1, shape2);\n if (!bcast.IsValid()) {\n return Status::OK();\n }\n\n BCast::Vec reduce_dims[2];\n reduce_dims[0] = bcast.grad_x_reduce_idx();\n reduce_dims[1] = bcast.grad_y_reduce_idx();\n\n TF_RETURN_IF_ERROR(CheckAttrExists(node, \"T\"));\n const DataType type = node.attr().at(\"T\").type();\n NodeDef* out[2];\n for (int j = 0; j < 2; ++j) {\n int reduction_indices = reduce_dims[j].size();\n Tensor value(type, TensorShape({reduction_indices}));\n for (int i = 0; i < reduction_indices; ++i) {\n if (type == DT_INT32) {\n value.vec()(i) = reduce_dims[j][i];\n } else {\n value.vec()(i) = reduce_dims[j][i];\n }\n }\n string const_name =\n OptimizedNodeName(node, strings::StrCat(\"-bcastargs-\", j));\n out[j] = node_map_->GetNode(const_name);\n if (out[j] == nullptr) {\n out[j] = graph_->add_node();\n TF_RETURN_IF_ERROR(\n CreateNodeDef(const_name, TensorValue(&value), out[j]));\n out[j]->set_device(node.device());\n node_map_->AddNode(const_name, out[j]);\n string ctrl_dep =\n AddControlDependency(node.name(), graph_, node_map_.get());\n *out[j]->add_input() = ctrl_dep;\n node_map_->AddOutput(NodeName(ctrl_dep), const_name);\n }\n }\n\n \/\/ We make a copy here since we might mutate the set.\n const auto outputs = node_map_->GetOutputs(node.name());\n for (NodeDef* output : outputs) {\n for (int k = 0; k < output->input_size(); ++k) {\n int port;\n string node_name = ParseNodeName(output->input(k), &port);\n if (node_name == node.name() && port >= 0 && port < 2 && out[port]) {\n *output->mutable_input(k) = out[port]->name();\n node_map_->UpdateInput(output->name(), node_name, out[port]->name());\n }\n }\n }\n\n return Status::OK();\n}","target":0,"code_token_length":1233,"total_token_length":1469,"max_tokens_setting":2048} +{"idx":123886,"func":"static void ov518_configure(struct gspca_dev *gspca_dev)\n{\n\tstruct sd *sd = (struct sd *) gspca_dev;\n\n\t\/* For 518 and 518+ *\/\n\tstatic const struct ov_regvals init_518[] = {\n\t\t{ R51x_SYS_RESET,\t0x40 },\n\t\t{ R51x_SYS_INIT,\t0xe1 },\n\t\t{ R51x_SYS_RESET,\t0x3e },\n\t\t{ R51x_SYS_INIT,\t0xe1 },\n\t\t{ R51x_SYS_RESET,\t0x00 },\n\t\t{ R51x_SYS_INIT,\t0xe1 },\n\t\t{ 0x46,\t\t\t0x00 },\n\t\t{ 0x5d,\t\t\t0x03 },\n\t};\n\n\tstatic const struct ov_regvals norm_518[] = {\n\t\t{ R51x_SYS_SNAP,\t0x02 }, \/* Reset *\/\n\t\t{ R51x_SYS_SNAP,\t0x01 }, \/* Enable *\/\n\t\t{ 0x31,\t\t\t0x0f },\n\t\t{ 0x5d,\t\t\t0x03 },\n\t\t{ 0x24,\t\t\t0x9f },\n\t\t{ 0x25,\t\t\t0x90 },\n\t\t{ 0x20,\t\t\t0x00 },\n\t\t{ 0x51,\t\t\t0x04 },\n\t\t{ 0x71,\t\t\t0x19 },\n\t\t{ 0x2f,\t\t\t0x80 },\n\t};\n\n\tstatic const struct ov_regvals norm_518_p[] = {\n\t\t{ R51x_SYS_SNAP,\t0x02 }, \/* Reset *\/\n\t\t{ R51x_SYS_SNAP,\t0x01 }, \/* Enable *\/\n\t\t{ 0x31,\t\t\t0x0f },\n\t\t{ 0x5d,\t\t\t0x03 },\n\t\t{ 0x24,\t\t\t0x9f },\n\t\t{ 0x25,\t\t\t0x90 },\n\t\t{ 0x20,\t\t\t0x60 },\n\t\t{ 0x51,\t\t\t0x02 },\n\t\t{ 0x71,\t\t\t0x19 },\n\t\t{ 0x40,\t\t\t0xff },\n\t\t{ 0x41,\t\t\t0x42 },\n\t\t{ 0x46,\t\t\t0x00 },\n\t\t{ 0x33,\t\t\t0x04 },\n\t\t{ 0x21,\t\t\t0x19 },\n\t\t{ 0x3f,\t\t\t0x10 },\n\t\t{ 0x2f,\t\t\t0x80 },\n\t};\n\n\t\/* First 5 bits of custom ID reg are a revision ID on OV518 *\/\n\tsd->revision = reg_r(sd, R51x_SYS_CUST_ID) & 0x1f;\n\tgspca_dbg(gspca_dev, D_PROBE, \"Device revision %d\\n\", sd->revision);\n\n\twrite_regvals(sd, init_518, ARRAY_SIZE(init_518));\n\n\t\/* Set LED GPIO pin to output mode *\/\n\treg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02);\n\n\tswitch (sd->bridge) {\n\tcase BRIDGE_OV518:\n\t\twrite_regvals(sd, norm_518, ARRAY_SIZE(norm_518));\n\t\tbreak;\n\tcase BRIDGE_OV518PLUS:\n\t\twrite_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p));\n\t\tbreak;\n\t}\n\n\tov51x_upload_quan_tables(sd);\n\n\treg_w(sd, 0x2f, 0x80);\n}","target":0,"code_token_length":876,"total_token_length":1112,"max_tokens_setting":2048} +{"idx":301874,"func":"static int dn_accept(struct socket *sock, struct socket *newsock, int flags)\n{\n\tstruct sock *sk = sock->sk, *newsk;\n\tstruct sk_buff *skb = NULL;\n\tstruct dn_skb_cb *cb;\n\tunsigned char menuver;\n\tint err = 0;\n\tunsigned char type;\n\tlong timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);\n\tstruct dst_entry *dst;\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) {\n\t\trelease_sock(sk);\n\t\treturn -EINVAL;\n\t}\n\n\tskb = skb_dequeue(&sk->sk_receive_queue);\n\tif (skb == NULL) {\n\t\tskb = dn_wait_for_connect(sk, &timeo);\n\t\tif (IS_ERR(skb)) {\n\t\t\trelease_sock(sk);\n\t\t\treturn PTR_ERR(skb);\n\t\t}\n\t}\n\n\tcb = DN_SKB_CB(skb);\n\tsk->sk_ack_backlog--;\n\tnewsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, 0);\n\tif (newsk == NULL) {\n\t\trelease_sock(sk);\n\t\tkfree_skb(skb);\n\t\treturn -ENOBUFS;\n\t}\n\trelease_sock(sk);\n\n\tdst = skb_dst(skb);\n\tsk_dst_set(newsk, dst);\n\tskb_dst_set(skb, NULL);\n\n\tDN_SK(newsk)->state = DN_CR;\n\tDN_SK(newsk)->addrrem = cb->src_port;\n\tDN_SK(newsk)->services_rem = cb->services;\n\tDN_SK(newsk)->info_rem = cb->info;\n\tDN_SK(newsk)->segsize_rem = cb->segsize;\n\tDN_SK(newsk)->accept_mode = DN_SK(sk)->accept_mode;\n\n\tif (DN_SK(newsk)->segsize_rem < 230)\n\t\tDN_SK(newsk)->segsize_rem = 230;\n\n\tif ((DN_SK(newsk)->services_rem & NSP_FC_MASK) == NSP_FC_NONE)\n\t\tDN_SK(newsk)->max_window = decnet_no_fc_max_cwnd;\n\n\tnewsk->sk_state = TCP_LISTEN;\n\tmemcpy(&(DN_SK(newsk)->addr), &(DN_SK(sk)->addr), sizeof(struct sockaddr_dn));\n\n\t\/*\n\t * If we are listening on a wild socket, we don't want\n\t * the newly created socket on the wrong hash queue.\n\t *\/\n\tDN_SK(newsk)->addr.sdn_flags &= ~SDF_WILD;\n\n\tskb_pull(skb, dn_username2sockaddr(skb->data, skb->len, &(DN_SK(newsk)->addr), &type));\n\tskb_pull(skb, dn_username2sockaddr(skb->data, skb->len, &(DN_SK(newsk)->peer), &type));\n\t*(__le16 *)(DN_SK(newsk)->peer.sdn_add.a_addr) = cb->src;\n\t*(__le16 *)(DN_SK(newsk)->addr.sdn_add.a_addr) = cb->dst;\n\n\tmenuver = *skb->data;\n\tskb_pull(skb, 1);\n\n\tif (menuver & DN_MENUVER_ACC)\n\t\tdn_access_copy(skb, &(DN_SK(newsk)->accessdata));\n\n\tif (menuver & DN_MENUVER_USR)\n\t\tdn_user_copy(skb, &(DN_SK(newsk)->conndata_in));\n\n\tif (menuver & DN_MENUVER_PRX)\n\t\tDN_SK(newsk)->peer.sdn_flags |= SDF_PROXY;\n\n\tif (menuver & DN_MENUVER_UIC)\n\t\tDN_SK(newsk)->peer.sdn_flags |= SDF_UICPROXY;\n\n\tkfree_skb(skb);\n\n\tmemcpy(&(DN_SK(newsk)->conndata_out), &(DN_SK(sk)->conndata_out),\n\t\tsizeof(struct optdata_dn));\n\tmemcpy(&(DN_SK(newsk)->discdata_out), &(DN_SK(sk)->discdata_out),\n\t\tsizeof(struct optdata_dn));\n\n\tlock_sock(newsk);\n\terr = dn_hash_sock(newsk);\n\tif (err == 0) {\n\t\tsock_reset_flag(newsk, SOCK_ZAPPED);\n\t\tdn_send_conn_ack(newsk);\n\n\t\t\/*\n\t\t * Here we use sk->sk_allocation since although the conn conf is\n\t\t * for the newsk, the context is the old socket.\n\t\t *\/\n\t\tif (DN_SK(newsk)->accept_mode == ACC_IMMED)\n\t\t\terr = dn_confirm_accept(newsk, &timeo,\n\t\t\t\t\t\tsk->sk_allocation);\n\t}\n\trelease_sock(newsk);\n\treturn err;\n}","target":0,"code_token_length":928,"total_token_length":1164,"max_tokens_setting":2048} +{"idx":344376,"func":"goa_ews_client_autodiscover (GoaEwsClient *client,\n const gchar *email,\n const gchar *password,\n const gchar *username,\n const gchar *server,\n gboolean accept_ssl_errors,\n GCancellable *cancellable,\n GAsyncReadyCallback callback,\n gpointer user_data)\n{\n AutodiscoverData *data;\n AutodiscoverAuthData *auth;\n gchar *url1;\n gchar *url2;\n xmlDoc *doc;\n xmlOutputBuffer *buf;\n\n g_return_if_fail (GOA_IS_EWS_CLIENT (client));\n g_return_if_fail (email != NULL || email[0] != '\\0');\n g_return_if_fail (password != NULL || password[0] != '\\0');\n g_return_if_fail (username != NULL || username[0] != '\\0');\n g_return_if_fail (server != NULL || server[0] != '\\0');\n g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));\n\n doc = ews_client_create_autodiscover_xml (email);\n buf = xmlAllocOutputBuffer (NULL);\n xmlNodeDumpOutput (buf, doc, xmlDocGetRootElement (doc), 0, 1, NULL);\n xmlOutputBufferFlush (buf);\n\n url1 = g_strdup_printf (\"https:\/\/%s\/autodiscover\/autodiscover.xml\", server);\n url2 = g_strdup_printf (\"https:\/\/autodiscover.%s\/autodiscover\/autodiscover.xml\", server);\n\n \/* http:\/\/msdn.microsoft.com\/en-us\/library\/ee332364.aspx says we are\n * supposed to try $domain and then autodiscover.$domain. But some\n * people have broken firewalls on the former which drop packets\n * instead of rejecting connections, and make the request take ages\n * to time out. So run both queries in parallel and let the fastest\n * (successful) one win.\n *\/\n data = g_slice_new0 (AutodiscoverData);\n data->buf = buf;\n data->res = g_simple_async_result_new (G_OBJECT (client), callback, user_data, goa_ews_client_autodiscover);\n data->msgs[0] = ews_client_create_msg_for_url (url1, buf);\n data->msgs[1] = ews_client_create_msg_for_url (url2, buf);\n data->session = soup_session_async_new_with_options (SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,\n SOUP_SESSION_SSL_STRICT, FALSE,\n SOUP_SESSION_USE_NTLM, TRUE,\n SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,\n NULL);\n data->accept_ssl_errors = accept_ssl_errors;\n\n if (cancellable != NULL)\n {\n data->cancellable = g_object_ref (cancellable);\n data->cancellable_id = g_cancellable_connect (data->cancellable,\n G_CALLBACK (ews_client_autodiscover_cancelled_cb),\n data,\n NULL);\n g_simple_async_result_set_check_cancellable (data->res, data->cancellable);\n }\n\n auth = g_slice_new0 (AutodiscoverAuthData);\n auth->username = g_strdup (username);\n auth->password = g_strdup (password);\n g_signal_connect_data (data->session,\n \"authenticate\",\n G_CALLBACK (ews_client_authenticate),\n auth,\n ews_client_autodiscover_auth_data_free,\n 0);\n\n soup_session_queue_message (data->session, data->msgs[0], ews_client_autodiscover_response_cb, data);\n soup_session_queue_message (data->session, data->msgs[1], ews_client_autodiscover_response_cb, data);\n\n g_free (url2);\n g_free (url1);\n xmlFreeDoc (doc);\n}","target":1,"code_token_length":835,"total_token_length":1071,"max_tokens_setting":2048} +{"idx":126373,"func":"static int fr_ioctl(struct net_device *dev, struct ifreq *ifr)\n{\n\tfr_proto __user *fr_s = ifr->ifr_settings.ifs_ifsu.fr;\n\tconst size_t size = sizeof(fr_proto);\n\tfr_proto new_settings;\n\thdlc_device *hdlc = dev_to_hdlc(dev);\n\tfr_proto_pvc pvc;\n\tint result;\n\n\tswitch (ifr->ifr_settings.type) {\n\tcase IF_GET_PROTO:\n\t\tif (dev_to_hdlc(dev)->proto != &proto) \/* Different proto *\/\n\t\t\treturn -EINVAL;\n\t\tifr->ifr_settings.type = IF_PROTO_FR;\n\t\tif (ifr->ifr_settings.size < size) {\n\t\t\tifr->ifr_settings.size = size; \/* data size wanted *\/\n\t\t\treturn -ENOBUFS;\n\t\t}\n\t\tif (copy_to_user(fr_s, &state(hdlc)->settings, size))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\n\tcase IF_PROTO_FR:\n\t\tif (!capable(CAP_NET_ADMIN))\n\t\t\treturn -EPERM;\n\n\t\tif (dev->flags & IFF_UP)\n\t\t\treturn -EBUSY;\n\n\t\tif (copy_from_user(&new_settings, fr_s, size))\n\t\t\treturn -EFAULT;\n\n\t\tif (new_settings.lmi == LMI_DEFAULT)\n\t\t\tnew_settings.lmi = LMI_ANSI;\n\n\t\tif ((new_settings.lmi != LMI_NONE &&\n\t\t new_settings.lmi != LMI_ANSI &&\n\t\t new_settings.lmi != LMI_CCITT &&\n\t\t new_settings.lmi != LMI_CISCO) ||\n\t\t new_settings.t391 < 1 ||\n\t\t new_settings.t392 < 2 ||\n\t\t new_settings.n391 < 1 ||\n\t\t new_settings.n392 < 1 ||\n\t\t new_settings.n393 < new_settings.n392 ||\n\t\t new_settings.n393 > 32 ||\n\t\t (new_settings.dce != 0 &&\n\t\t new_settings.dce != 1))\n\t\t\treturn -EINVAL;\n\n\t\tresult=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT);\n\t\tif (result)\n\t\t\treturn result;\n\n\t\tif (dev_to_hdlc(dev)->proto != &proto) { \/* Different proto *\/\n\t\t\tresult = attach_hdlc_protocol(dev, &proto,\n\t\t\t\t\t\t sizeof(struct frad_state));\n\t\t\tif (result)\n\t\t\t\treturn result;\n\t\t\tstate(hdlc)->first_pvc = NULL;\n\t\t\tstate(hdlc)->dce_pvc_count = 0;\n\t\t}\n\t\tmemcpy(&state(hdlc)->settings, &new_settings, size);\n\t\tdev->type = ARPHRD_FRAD;\n\t\treturn 0;\n\n\tcase IF_PROTO_FR_ADD_PVC:\n\tcase IF_PROTO_FR_DEL_PVC:\n\tcase IF_PROTO_FR_ADD_ETH_PVC:\n\tcase IF_PROTO_FR_DEL_ETH_PVC:\n\t\tif (dev_to_hdlc(dev)->proto != &proto) \/* Different proto *\/\n\t\t\treturn -EINVAL;\n\n\t\tif (!capable(CAP_NET_ADMIN))\n\t\t\treturn -EPERM;\n\n\t\tif (copy_from_user(&pvc, ifr->ifr_settings.ifs_ifsu.fr_pvc,\n\t\t\t\t sizeof(fr_proto_pvc)))\n\t\t\treturn -EFAULT;\n\n\t\tif (pvc.dlci <= 0 || pvc.dlci >= 1024)\n\t\t\treturn -EINVAL;\t\/* Only 10 bits, DLCI 0 reserved *\/\n\n\t\tif (ifr->ifr_settings.type == IF_PROTO_FR_ADD_ETH_PVC ||\n\t\t ifr->ifr_settings.type == IF_PROTO_FR_DEL_ETH_PVC)\n\t\t\tresult = ARPHRD_ETHER; \/* bridged Ethernet device *\/\n\t\telse\n\t\t\tresult = ARPHRD_DLCI;\n\n\t\tif (ifr->ifr_settings.type == IF_PROTO_FR_ADD_PVC ||\n\t\t ifr->ifr_settings.type == IF_PROTO_FR_ADD_ETH_PVC)\n\t\t\treturn fr_add_pvc(dev, pvc.dlci, result);\n\t\telse\n\t\t\treturn fr_del_pvc(hdlc, pvc.dlci, result);\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":844,"total_token_length":1080,"max_tokens_setting":2048} +{"idx":345969,"func":"SMBC_attr_server(TALLOC_CTX *ctx,\n SMBCCTX *context,\n const char *server,\n uint16_t port,\n const char *share,\n char **pp_workgroup,\n char **pp_username,\n char **pp_password)\n{\n int flags;\n\tstruct cli_state *ipc_cli = NULL;\n\tstruct rpc_pipe_client *pipe_hnd = NULL;\n NTSTATUS nt_status;\n\tSMBCSRV *srv=NULL;\n\tSMBCSRV *ipc_srv=NULL;\n\n\t\/*\n\t * Use srv->cli->desthost and srv->cli->share instead of\n\t * server and share below to connect to the actual share,\n\t * i.e., a normal share or a referred share from\n\t * 'msdfs proxy' share.\n\t *\/\n\tsrv = SMBC_server(ctx, context, true, server, port, share,\n\t\t\tpp_workgroup, pp_username, pp_password);\n\tif (!srv) {\n\t\treturn NULL;\n\t}\n\tserver = smbXcli_conn_remote_name(srv->cli->conn);\n\tshare = srv->cli->share;\n\n \/*\n * See if we've already created this special connection. Reference\n * our \"special\" share name '*IPC$', which is an impossible real share\n * name due to the leading asterisk.\n *\/\n ipc_srv = SMBC_find_server(ctx, context, server, \"*IPC$\",\n pp_workgroup, pp_username, pp_password);\n if (!ipc_srv) {\n\n \/* We didn't find a cached connection. Get the password *\/\n\t\tif (!*pp_password || (*pp_password)[0] == '\\0') {\n \/* ... then retrieve it now. *\/\n\t\t\tSMBC_call_auth_fn(ctx, context, server, share,\n pp_workgroup,\n pp_username,\n pp_password);\n\t\t\tif (!*pp_workgroup || !*pp_username || !*pp_password) {\n\t\t\t\terrno = ENOMEM;\n\t\t\t\treturn NULL;\n\t\t\t}\n }\n\n flags = 0;\n if (smbc_getOptionUseKerberos(context)) {\n flags |= CLI_FULL_CONNECTION_USE_KERBEROS;\n }\n if (smbc_getOptionUseCCache(context)) {\n flags |= CLI_FULL_CONNECTION_USE_CCACHE;\n }\n\n nt_status = cli_full_connection(&ipc_cli,\n\t\t\t\t\t\tlp_netbios_name(), server,\n\t\t\t\t\t\tNULL, 0, \"IPC$\", \"?????\",\n\t\t\t\t\t\t*pp_username,\n\t\t\t\t\t\t*pp_workgroup,\n\t\t\t\t\t\t*pp_password,\n\t\t\t\t\t\tflags,\n\t\t\t\t\t\tSMB_SIGNING_DEFAULT);\n if (! NT_STATUS_IS_OK(nt_status)) {\n DEBUG(1,(\"cli_full_connection failed! (%s)\\n\",\n nt_errstr(nt_status)));\n errno = ENOTSUP;\n return NULL;\n }\n\n\t\tif (context->internal->smb_encryption_level) {\n\t\t\t\/* Attempt UNIX smb encryption. *\/\n\t\t\tif (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli,\n *pp_username,\n *pp_password,\n *pp_workgroup))) {\n\n\t\t\t\t\/*\n\t\t\t\t * context->smb_encryption_level ==\n\t\t\t\t * 1 means don't fail if encryption can't be\n\t\t\t\t * negotiated, == 2 means fail if encryption\n\t\t\t\t * can't be negotiated.\n\t\t\t\t *\/\n\n\t\t\t\tDEBUG(4,(\" SMB encrypt failed on IPC$\\n\"));\n\n\t\t\t\tif (context->internal->smb_encryption_level == 2) {\n\t\t cli_shutdown(ipc_cli);\n\t\t\t\t\terrno = EPERM;\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t\tDEBUG(4,(\" SMB encrypt ok on IPC$\\n\"));\n\t\t}\n\n ipc_srv = SMB_MALLOC_P(SMBCSRV);\n if (!ipc_srv) {\n errno = ENOMEM;\n cli_shutdown(ipc_cli);\n return NULL;\n }\n\n ZERO_STRUCTP(ipc_srv);\n ipc_srv->cli = ipc_cli;\n\n nt_status = cli_rpc_pipe_open_noauth(\n\t\t\tipc_srv->cli, &ndr_table_lsarpc, &pipe_hnd);\n if (!NT_STATUS_IS_OK(nt_status)) {\n DEBUG(1, (\"cli_nt_session_open fail!\\n\"));\n errno = ENOTSUP;\n cli_shutdown(ipc_srv->cli);\n free(ipc_srv);\n return NULL;\n }\n\n \/*\n * Some systems don't support\n * SEC_FLAG_MAXIMUM_ALLOWED, but NT sends 0x2000000\n * so we might as well do it too.\n *\/\n\n nt_status = rpccli_lsa_open_policy(\n pipe_hnd,\n talloc_tos(),\n True,\n GENERIC_EXECUTE_ACCESS,\n &ipc_srv->pol);\n\n if (!NT_STATUS_IS_OK(nt_status)) {\n errno = SMBC_errno(context, ipc_srv->cli);\n cli_shutdown(ipc_srv->cli);\n free(ipc_srv);\n return NULL;\n }\n\n \/* now add it to the cache (internal or external) *\/\n\n errno = 0; \/* let cache function set errno if it likes *\/\n if (smbc_getFunctionAddCachedServer(context)(context, ipc_srv,\n server,\n \"*IPC$\",\n *pp_workgroup,\n *pp_username)) {\n DEBUG(3, (\" Failed to add server to cache\\n\"));\n if (errno == 0) {\n errno = ENOMEM;\n }\n cli_shutdown(ipc_srv->cli);\n free(ipc_srv);\n return NULL;\n }\n\n DLIST_ADD(context->internal->servers, ipc_srv);\n }\n\n return ipc_srv;\n}","target":1,"code_token_length":1167,"total_token_length":1403,"max_tokens_setting":2048} +{"idx":514190,"func":"span_renderer_init (cairo_abstract_span_renderer_t\t*_r,\n\t\t const cairo_composite_rectangles_t *composite,\n\t\t cairo_antialias_t\t\t\t antialias,\n\t\t cairo_bool_t\t\t\t needs_clip)\n{\n cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *)_r;\n cairo_image_surface_t *dst = (cairo_image_surface_t *)composite->surface;\n const cairo_pattern_t *source = &composite->source_pattern.base;\n cairo_operator_t op = composite->op;\n cairo_int_status_t status;\n\n TRACE ((stderr, \"%s: antialias=%d, needs_clip=%d\\n\", __FUNCTION__,\n\t antialias, needs_clip));\n\n if (needs_clip)\n\treturn CAIRO_INT_STATUS_UNSUPPORTED;\n\n r->composite = composite;\n r->mask = NULL;\n r->src = NULL;\n r->base.finish = NULL;\n\n status = mono_renderer_init (r, composite, antialias, needs_clip);\n if (status != CAIRO_INT_STATUS_UNSUPPORTED)\n\treturn status;\n\n status = inplace_renderer_init (r, composite, antialias, needs_clip);\n if (status != CAIRO_INT_STATUS_UNSUPPORTED)\n\treturn status;\n\n r->bpp = 0;\n\n if (op == CAIRO_OPERATOR_CLEAR) {\n#if PIXMAN_HAS_OP_LERP\n\top = PIXMAN_OP_LERP_CLEAR;\n#else\n\tsource = &_cairo_pattern_white.base;\n\top = PIXMAN_OP_OUT_REVERSE;\n#endif\n } else if (dst->base.is_clear &&\n\t (op == CAIRO_OPERATOR_SOURCE ||\n\t\top == CAIRO_OPERATOR_OVER ||\n\t\top == CAIRO_OPERATOR_ADD)) {\n\top = PIXMAN_OP_SRC;\n } else if (op == CAIRO_OPERATOR_SOURCE) {\n\tif (_cairo_pattern_is_opaque (&composite->source_pattern.base,\n\t\t\t\t &composite->source_sample_area))\n\t{\n\t op = PIXMAN_OP_OVER;\n\t}\n\telse\n\t{\n#if PIXMAN_HAS_OP_LERP\n\t op = PIXMAN_OP_LERP_SRC;\n#else\n\t return CAIRO_INT_STATUS_UNSUPPORTED;\n#endif\n\t}\n } else {\n\top = _pixman_operator (op);\n }\n r->op = op;\n\n r->src = _pixman_image_for_pattern (dst, source, FALSE,\n\t\t\t\t\t&composite->unbounded,\n\t\t\t\t\t&composite->source_sample_area,\n\t\t\t\t\t&r->u.mask.src_x, &r->u.mask.src_y);\n if (unlikely (r->src == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n r->opacity = 1.0;\n if (composite->mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID) {\n\tr->opacity = composite->mask_pattern.solid.color.alpha;\n } else {\n\tpixman_image_t *mask;\n\tint mask_x, mask_y;\n\n\tmask = _pixman_image_for_pattern (dst,\n\t\t\t\t\t &composite->mask_pattern.base,\n\t\t\t\t\t TRUE,\n\t\t\t\t\t &composite->unbounded,\n\t\t\t\t\t &composite->mask_sample_area,\n\t\t\t\t\t &mask_x, &mask_y);\n\tif (unlikely (mask == NULL))\n\t return _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n\t\/* XXX Component-alpha? *\/\n\tif ((dst->base.content & CAIRO_CONTENT_COLOR) == 0 &&\n\t _cairo_pattern_is_opaque (source, &composite->source_sample_area))\n\t{\n\t pixman_image_unref (r->src);\n\t r->src = mask;\n\t r->u.mask.src_x = mask_x;\n\t r->u.mask.src_y = mask_y;\n\t mask = NULL;\n\t}\n\n\tif (mask) {\n\t pixman_image_unref (mask);\n\t return CAIRO_INT_STATUS_UNSUPPORTED;\n\t}\n }\n\n r->u.mask.extents = composite->unbounded;\n r->u.mask.stride = (r->u.mask.extents.width + 3) & ~3;\n if (r->u.mask.extents.height * r->u.mask.stride > SZ_BUF) {\n\tr->mask = pixman_image_create_bits (PIXMAN_a8,\n\t\t\t\t\t r->u.mask.extents.width,\n\t\t\t\t\t r->u.mask.extents.height,\n\t\t\t\t\t NULL, 0);\n\n\tr->base.render_rows = _cairo_image_spans;\n\tr->base.finish = NULL;\n } else {\n\tr->mask = pixman_image_create_bits (PIXMAN_a8,\n\t\t\t\t\t r->u.mask.extents.width,\n\t\t\t\t\t r->u.mask.extents.height,\n\t\t\t\t\t (uint32_t *)r->_buf, r->u.mask.stride);\n\n\tr->base.render_rows = _cairo_image_spans_and_zero;\n\tr->base.finish = _cairo_image_finish_spans_and_zero;\n }\n if (unlikely (r->mask == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n r->u.mask.data = (uint8_t *) pixman_image_get_data (r->mask);\n r->u.mask.stride = pixman_image_get_stride (r->mask);\n\n r->u.mask.extents.height += r->u.mask.extents.y;\n return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":1048,"total_token_length":1284,"max_tokens_setting":2048} +{"idx":94283,"func":"SYSCALL_DEFINE5(keyctl, int, option, unsigned long, arg2, unsigned long, arg3,\n\t\tunsigned long, arg4, unsigned long, arg5)\n{\n\tswitch (option) {\n\tcase KEYCTL_GET_KEYRING_ID:\n\t\treturn keyctl_get_keyring_ID((key_serial_t) arg2,\n\t\t\t\t\t (int) arg3);\n\n\tcase KEYCTL_JOIN_SESSION_KEYRING:\n\t\treturn keyctl_join_session_keyring((const char __user *) arg2);\n\n\tcase KEYCTL_UPDATE:\n\t\treturn keyctl_update_key((key_serial_t) arg2,\n\t\t\t\t\t (const void __user *) arg3,\n\t\t\t\t\t (size_t) arg4);\n\n\tcase KEYCTL_REVOKE:\n\t\treturn keyctl_revoke_key((key_serial_t) arg2);\n\n\tcase KEYCTL_DESCRIBE:\n\t\treturn keyctl_describe_key((key_serial_t) arg2,\n\t\t\t\t\t (char __user *) arg3,\n\t\t\t\t\t (unsigned) arg4);\n\n\tcase KEYCTL_CLEAR:\n\t\treturn keyctl_keyring_clear((key_serial_t) arg2);\n\n\tcase KEYCTL_LINK:\n\t\treturn keyctl_keyring_link((key_serial_t) arg2,\n\t\t\t\t\t (key_serial_t) arg3);\n\n\tcase KEYCTL_UNLINK:\n\t\treturn keyctl_keyring_unlink((key_serial_t) arg2,\n\t\t\t\t\t (key_serial_t) arg3);\n\n\tcase KEYCTL_SEARCH:\n\t\treturn keyctl_keyring_search((key_serial_t) arg2,\n\t\t\t\t\t (const char __user *) arg3,\n\t\t\t\t\t (const char __user *) arg4,\n\t\t\t\t\t (key_serial_t) arg5);\n\n\tcase KEYCTL_READ:\n\t\treturn keyctl_read_key((key_serial_t) arg2,\n\t\t\t\t (char __user *) arg3,\n\t\t\t\t (size_t) arg4);\n\n\tcase KEYCTL_CHOWN:\n\t\treturn keyctl_chown_key((key_serial_t) arg2,\n\t\t\t\t\t(uid_t) arg3,\n\t\t\t\t\t(gid_t) arg4);\n\n\tcase KEYCTL_SETPERM:\n\t\treturn keyctl_setperm_key((key_serial_t) arg2,\n\t\t\t\t\t (key_perm_t) arg3);\n\n\tcase KEYCTL_INSTANTIATE:\n\t\treturn keyctl_instantiate_key((key_serial_t) arg2,\n\t\t\t\t\t (const void __user *) arg3,\n\t\t\t\t\t (size_t) arg4,\n\t\t\t\t\t (key_serial_t) arg5);\n\n\tcase KEYCTL_NEGATE:\n\t\treturn keyctl_negate_key((key_serial_t) arg2,\n\t\t\t\t\t (unsigned) arg3,\n\t\t\t\t\t (key_serial_t) arg4);\n\n\tcase KEYCTL_SET_REQKEY_KEYRING:\n\t\treturn keyctl_set_reqkey_keyring(arg2);\n\n\tcase KEYCTL_SET_TIMEOUT:\n\t\treturn keyctl_set_timeout((key_serial_t) arg2,\n\t\t\t\t\t (unsigned) arg3);\n\n\tcase KEYCTL_ASSUME_AUTHORITY:\n\t\treturn keyctl_assume_authority((key_serial_t) arg2);\n\n\tcase KEYCTL_GET_SECURITY:\n\t\treturn keyctl_get_security((key_serial_t) arg2,\n\t\t\t\t\t (char __user *) arg3,\n\t\t\t\t\t (size_t) arg4);\n\n\tcase KEYCTL_SESSION_TO_PARENT:\n\t\treturn keyctl_session_to_parent();\n\n\tcase KEYCTL_REJECT:\n\t\treturn keyctl_reject_key((key_serial_t) arg2,\n\t\t\t\t\t (unsigned) arg3,\n\t\t\t\t\t (unsigned) arg4,\n\t\t\t\t\t (key_serial_t) arg5);\n\n\tcase KEYCTL_INSTANTIATE_IOV:\n\t\treturn keyctl_instantiate_key_iov(\n\t\t\t(key_serial_t) arg2,\n\t\t\t(const struct iovec __user *) arg3,\n\t\t\t(unsigned) arg4,\n\t\t\t(key_serial_t) arg5);\n\n\tcase KEYCTL_INVALIDATE:\n\t\treturn keyctl_invalidate_key((key_serial_t) arg2);\n\n\tcase KEYCTL_GET_PERSISTENT:\n\t\treturn keyctl_get_persistent((uid_t)arg2, (key_serial_t)arg3);\n\n\tcase KEYCTL_DH_COMPUTE:\n\t\treturn keyctl_dh_compute((struct keyctl_dh_params __user *) arg2,\n\t\t\t\t\t (char __user *) arg3, (size_t) arg4,\n\t\t\t\t\t (void __user *) arg5);\n\n\tdefault:\n\t\treturn -EOPNOTSUPP;\n\t}\n}","target":0,"code_token_length":853,"total_token_length":1089,"max_tokens_setting":2048} +{"idx":160948,"func":"node_char_len1(Node* node, regex_t* reg, MinMaxCharLen* ci, ScanEnv* env,\n int level)\n{\n MinMaxCharLen tci;\n int r = CHAR_LEN_NORMAL;\n\n level++;\n\n switch (NODE_TYPE(node)) {\n case NODE_LIST:\n {\n int first = TRUE;\n do {\n r = node_char_len1(NODE_CAR(node), reg, &tci, env, level);\n if (r < 0) break;\n if (first == TRUE) {\n *ci = tci;\n first = FALSE;\n }\n else\n mmcl_add(ci, &tci);\n } while (IS_NOT_NULL(node = NODE_CDR(node)));\n }\n break;\n\n case NODE_ALT:\n {\n int fixed;\n\n r = node_char_len1(NODE_CAR(node), reg, ci, env, level);\n if (r < 0) break;\n\n fixed = TRUE;\n while (IS_NOT_NULL(node = NODE_CDR(node))) {\n r = node_char_len1(NODE_CAR(node), reg, &tci, env, level);\n if (r < 0) break;\n if (! mmcl_fixed(&tci))\n fixed = FALSE;\n mmcl_alt_merge(ci, &tci);\n }\n if (r < 0) break;\n\n r = CHAR_LEN_NORMAL;\n if (mmcl_fixed(ci)) break;\n\n if (fixed == TRUE && level == 1) {\n r = CHAR_LEN_TOP_ALT_FIXED;\n }\n }\n break;\n\n case NODE_STRING:\n {\n OnigLen clen;\n StrNode* sn = STR_(node);\n UChar *s = sn->s;\n\n if (NODE_IS_IGNORECASE(node) && ! NODE_STRING_IS_CRUDE(node)) {\n \/* Such a case is possible.\n ex. \/(?i)(?<=\\1)(a)\/\n Backref node refer to capture group, but it doesn't tune yet.\n *\/\n r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN;\n break;\n }\n\n clen = 0;\n while (s < sn->end) {\n s += enclen(reg->enc, s);\n clen = distance_add(clen, 1);\n }\n mmcl_set(ci, clen);\n }\n break;\n\n case NODE_QUANT:\n {\n QuantNode* qn = QUANT_(node);\n\n if (qn->lower == qn->upper) {\n if (qn->upper == 0) {\n mmcl_set(ci, 0);\n }\n else {\n r = node_char_len1(NODE_BODY(node), reg, ci, env, level);\n if (r < 0) break;\n mmcl_multiply(ci, qn->lower);\n }\n }\n else {\n r = node_char_len1(NODE_BODY(node), reg, ci, env, level);\n if (r < 0) break;\n mmcl_repeat_range_multiply(ci, qn->lower, qn->upper);\n }\n }\n break;\n\n#ifdef USE_CALL\n case NODE_CALL:\n if (NODE_IS_RECURSION(node))\n mmcl_set_min_max(ci, 0, INFINITE_LEN, FALSE);\n else\n r = node_char_len1(NODE_BODY(node), reg, ci, env, level);\n break;\n#endif\n\n case NODE_CTYPE:\n case NODE_CCLASS:\n mmcl_set(ci, 1);\n break;\n\n case NODE_BAG:\n {\n BagNode* en = BAG_(node);\n\n switch (en->type) {\n case BAG_MEMORY:\n if (NODE_IS_FIXED_CLEN(node)) {\n mmcl_set_min_max(ci, en->min_char_len, en->max_char_len,\n NODE_IS_FIXED_CLEN_MIN_SURE(node));\n }\n else {\n if (NODE_IS_MARK1(node)) {\n mmcl_set_min_max(ci, 0, INFINITE_LEN, FALSE);\n }\n else {\n NODE_STATUS_ADD(node, MARK1);\n r = node_char_len1(NODE_BODY(node), reg, ci, env, level);\n NODE_STATUS_REMOVE(node, MARK1);\n if (r < 0) break;\n\n en->min_char_len = ci->min;\n en->max_char_len = ci->max;\n NODE_STATUS_ADD(node, FIXED_CLEN);\n if (ci->min_is_sure != FALSE)\n NODE_STATUS_ADD(node, FIXED_CLEN_MIN_SURE);\n }\n }\n \/* can't optimize look-behind if capture exists. *\/\n ci->min_is_sure = FALSE;\n break;\n case BAG_OPTION:\n case BAG_STOP_BACKTRACK:\n r = node_char_len1(NODE_BODY(node), reg, ci, env, level);\n break;\n case BAG_IF_ELSE:\n {\n MinMaxCharLen eci;\n\n r = node_char_len1(NODE_BODY(node), reg, ci, env, level);\n if (r < 0) break;\n\n if (IS_NOT_NULL(en->te.Then)) {\n r = node_char_len1(en->te.Then, reg, &tci, env, level);\n if (r < 0) break;\n mmcl_add(ci, &tci);\n }\n\n if (IS_NOT_NULL(en->te.Else)) {\n r = node_char_len1(en->te.Else, reg, &eci, env, level);\n if (r < 0) break;\n }\n else {\n mmcl_set(&eci, 0);\n }\n\n mmcl_alt_merge(ci, &eci);\n }\n break;\n default: \/* never come here *\/\n r = ONIGERR_PARSER_BUG;\n break;\n }\n }\n break;\n\n case NODE_GIMMICK:\n mmcl_set(ci, 0);\n break;\n\n case NODE_ANCHOR:\n zero:\n mmcl_set(ci, 0);\n \/* can't optimize look-behind if anchor exists. *\/\n ci->min_is_sure = FALSE;\n break;\n\n case NODE_BACKREF:\n if (NODE_IS_CHECKER(node))\n goto zero;\n\n if (NODE_IS_RECURSION(node)) {\n#ifdef USE_BACKREF_WITH_LEVEL\n if (NODE_IS_NEST_LEVEL(node)) {\n mmcl_set_min_max(ci, 0, INFINITE_LEN, FALSE);\n break;\n }\n#endif\n\n mmcl_set_min_max(ci, 0, 0, FALSE);\n break;\n }\n\n {\n int i;\n int* backs;\n MemEnv* mem_env = SCANENV_MEMENV(env);\n BackRefNode* br = BACKREF_(node);\n\n backs = BACKREFS_P(br);\n r = node_char_len1(mem_env[backs[0]].mem_node, reg, ci, env, level);\n if (r < 0) break;\n if (! mmcl_fixed(ci)) ci->min_is_sure = FALSE;\n\n for (i = 1; i < br->back_num; i++) {\n r = node_char_len1(mem_env[backs[i]].mem_node, reg, &tci, env, level);\n if (r < 0) break;\n if (! mmcl_fixed(&tci)) tci.min_is_sure = FALSE;\n mmcl_alt_merge(ci, &tci);\n }\n }\n break;\n\n default: \/* never come here *\/\n r = ONIGERR_PARSER_BUG;\n break;\n }\n\n return r;\n}","target":0,"code_token_length":1617,"total_token_length":1853,"max_tokens_setting":2048} +{"idx":294354,"func":"decompress_R2004_section (Bit_Chain *restrict dat, BITCODE_RC *restrict decomp,\n uint32_t decomp_data_size, uint32_t comp_data_size)\n{\n unsigned int i, lit_length;\n uint32_t comp_offset, comp_bytes, bytes_left;\n unsigned char opcode1 = 0, opcode2;\n long unsigned int start_byte = dat->byte;\n BITCODE_RC *src, *dst = decomp;\n BITCODE_RC *maxdst = decomp + decomp_data_size;\n\n bytes_left = decomp_data_size; \/\/ to write to\n if (comp_data_size > dat->size - start_byte) \/\/ bytes left to read from\n {\n LOG_WARN (\"Invalid comp_data_size %lu > %lu bytes left\",\n (unsigned long)bytes_left, dat->size - dat->byte)\n return DWG_ERR_VALUEOUTOFBOUNDS;\n }\n \/\/ length of the first sequence of uncompressed or literal data.\n lit_length = read_literal_length (dat, &opcode1);\n if (lit_length > bytes_left)\n {\n LOG_ERROR (\"Invalid literal_length %u > %u bytes left\",\n lit_length, (unsigned)decomp_data_size)\n return DWG_ERR_VALUEOUTOFBOUNDS;\n }\n bit_read_fixed (dat, decomp, lit_length);\n dst += lit_length;\n bytes_left -= lit_length;\n\n opcode1 = 0x00;\n while (dat->byte - start_byte < comp_data_size)\n {\n LOG_INSANE (\"-O %x \", opcode1)\n if (opcode1 == 0x00)\n {\n opcode1 = bit_read_RC (dat);\n LOG_INSANE (\"= 0x40)\n {\n comp_bytes = ((opcode1 & 0xF0) >> 4) - 1;\n opcode2 = bit_read_RC (dat);\n LOG_INSANE (\"> 2);\n\n if (opcode1 & 0x03)\n {\n lit_length = (opcode1 & 0x03);\n opcode1 = 0x00;\n }\n else\n lit_length = read_literal_length (dat, &opcode1);\n }\n else if (opcode1 >= 0x21\n && opcode1 <= 0x3F) \/\/ lgtm [cpp\/constant-comparison]\n {\n comp_bytes = opcode1 - 0x1E;\n comp_offset = read_two_byte_offset (dat, &lit_length);\n\n if (lit_length != 0)\n opcode1 = 0x00;\n else\n lit_length = read_literal_length (dat, &opcode1);\n }\n else if (opcode1 == 0x20)\n {\n comp_bytes = read_long_compression_offset (dat) + 0x21;\n comp_offset = read_two_byte_offset (dat, &lit_length);\n\n if (lit_length != 0)\n opcode1 = 0x00;\n else\n lit_length = read_literal_length (dat, &opcode1);\n }\n else if (opcode1 >= 0x12 && opcode1 <= 0x1F)\n {\n comp_bytes = (opcode1 & 0x0F) + 2;\n comp_offset = read_two_byte_offset (dat, &lit_length) + 0x3FFF;\n\n if (lit_length != 0)\n opcode1 = 0x00;\n else\n lit_length = read_literal_length (dat, &opcode1);\n }\n else if (opcode1 == 0x10)\n {\n comp_bytes = read_long_compression_offset (dat) + 9;\n comp_offset = read_two_byte_offset (dat, &lit_length) + 0x3FFF;\n\n if (lit_length != 0)\n opcode1 = 0x00;\n else\n lit_length = read_literal_length (dat, &opcode1);\n }\n else if (opcode1 == 0x11)\n break; \/\/ Terminates the input stream, everything is ok\n else\n {\n LOG_ERROR (\"Invalid opcode 0x%x in input stream at pos %lu\", opcode1,\n dat->byte);\n return DWG_ERR_INTERNALERROR; \/\/ error in input stream\n }\n\n src = dst - comp_offset - 1;\n if (src < decomp) \/\/ was assert (src >= decomp);\n {\n LOG_ERROR (\"decompress_R2004_section: src offset underflow\");\n return DWG_ERR_INTERNALERROR;\n }\n if (comp_bytes)\n {\n LOG_INSANE (\" bytes_left || \/\/ bytes left to write\n dst + comp_bytes > maxdst)\n {\n LOG_ERROR (\"Invalid comp_bytes %lu > %lu bytes left\",\n (unsigned long)comp_bytes, (unsigned long)bytes_left)\n return DWG_ERR_VALUEOUTOFBOUNDS;\n }\n for (i = 0; i < comp_bytes; ++i)\n *dst++ = *src++;\n bytes_left -= comp_bytes;\n }\n \/\/ copy \"literal data\"\n LOG_INSANE (\" bytes_left) \/\/ bytes left to write\n || dst + lit_length > maxdst) \/\/ dst overflow\n {\n LOG_ERROR (\"Invalid lit_length %u > %lu bytes left\",\n lit_length, (unsigned long)bytes_left)\n return DWG_ERR_VALUEOUTOFBOUNDS;\n }\n for (i = 0; i < lit_length; ++i)\n *dst++ = bit_read_RC (dat);\n }\n }\n\n return 0; \/\/ Success\n}","target":0,"code_token_length":1314,"total_token_length":1550,"max_tokens_setting":2048} +{"idx":502448,"func":"struct winsdb_addr **winsdb_addr_list_add(struct winsdb_handle *h, const struct winsdb_record *rec,\n\t\t\t\t\t struct winsdb_addr **addresses, const char *address,\n\t\t\t\t\t const char *wins_owner, time_t expire_time,\n\t\t\t\t\t bool is_name_registration)\n{\n\tstruct winsdb_addr *old_addr = NULL;\n\tsize_t len = 0;\n\tsize_t i;\n\tbool found_old_replica = false;\n\n\t\/*\n\t * count the addresses and maybe\n\t * find an old entry for the new address\n\t *\/\n\tfor (i=0; addresses[i]; i++) {\n\t\tif (old_addr) continue;\n\t\tif (strcmp(addresses[i]->address, address) == 0) {\n\t\t\told_addr = addresses[i];\n\t\t}\n\t}\n\tlen = i;\n\n\t\/*\n\t * the address is already there\n\t * and we can replace it\n\t *\/\n\tif (old_addr) {\n\t\tgoto remove_old_addr;\n\t}\n\n\t\/*\n\t * if we don't have 25 addresses already,\n\t * we can just add the new address\n\t *\/\n\tif (len < 25) {\n\t\tgoto add_new_addr;\n\t}\n\n\t\/*\n\t * if we haven't found the address,\n\t * and we have already have 25 addresses\n\t * if so then we need to do the following:\n\t * - if it isn't a name registration, then just ignore the new address\n\t * - if it is a name registration, then first search for \n\t * the oldest replica and if there's no replica address\n\t * search the oldest owned address\n\t *\/\n\tif (!is_name_registration) {\n\t\treturn addresses;\n\t}\n\n\t\/*\n\t * find the oldest replica address, if there's no replica\n\t * record at all, find the oldest owned address\n\t *\/\n\tfor (i=0; addresses[i]; i++) {\n\t\tbool cur_is_replica = false;\n\t\t\/* find out if the current address is a replica *\/\n\t\tif (strcmp(addresses[i]->wins_owner, h->local_owner) != 0) {\n\t\t\tcur_is_replica = true;\n\t\t}\n\n\t\t\/*\n\t\t * if we already found a replica address and the current address\n\t\t * is not a replica, then skip it\n\t\t *\/\n\t\tif (found_old_replica && !cur_is_replica) continue;\n\n\t\t\/*\n\t\t * if we found the first replica address, reset the address\n\t\t * that would be replaced\n\t\t *\/\n\t\tif (!found_old_replica && cur_is_replica) {\n\t\t\tfound_old_replica = true;\n\t\t\told_addr = addresses[i];\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/*\n\t\t * if the first address isn't a replica, just start with \n\t\t * the first one\n\t\t *\/\n\t\tif (!old_addr) {\n\t\t\told_addr = addresses[i];\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/*\n\t\t * see if we find an older address\n\t\t *\/\n\t\tif (addresses[i]->expire_time < old_addr->expire_time) {\n\t\t\told_addr = addresses[i];\n\t\t\tcontinue;\n\t\t}\n\t}\n\nremove_old_addr:\n\twinsdb_addr_list_remove(addresses, old_addr->address);\n\tlen --;\n\nadd_new_addr:\n\taddresses = talloc_realloc(addresses, addresses, struct winsdb_addr *, len + 2);\n\tif (!addresses) return NULL;\n\n\taddresses[len] = talloc(addresses, struct winsdb_addr);\n\tif (!addresses[len]) {\n\t\ttalloc_free(addresses);\n\t\treturn NULL;\n\t}\n\n\taddresses[len]->address = talloc_strdup(addresses[len], address);\n\tif (!addresses[len]->address) {\n\t\ttalloc_free(addresses);\n\t\treturn NULL;\n\t}\n\n\taddresses[len]->wins_owner = talloc_strdup(addresses[len], wins_owner);\n\tif (!addresses[len]->wins_owner) {\n\t\ttalloc_free(addresses);\n\t\treturn NULL;\n\t}\n\n\taddresses[len]->expire_time = expire_time;\n\n\taddresses[len+1] = NULL;\n\n\tLDB_TYPESAFE_QSORT(addresses, len+1, h, winsdb_addr_sort_list);\n\n\treturn addresses;\n}","target":0,"code_token_length":849,"total_token_length":1085,"max_tokens_setting":2048} +{"idx":290325,"func":"int main ( int argc , char * * argv ) {\n int option_idx = 0 ;\n int result ;\n const char * adb_server_ip = NULL ;\n unsigned short * adb_server_tcp_port = NULL ;\n unsigned int logcat_text = 0 ;\n const char * default_adb_server_ip = \"127.0.0.1\" ;\n unsigned short default_adb_server_tcp_port = 5037 ;\n unsigned short local_adb_server_tcp_port ;\n unsigned short local_bt_server_tcp_port ;\n unsigned short local_bt_local_tcp_port ;\n unsigned short * bt_server_tcp_port = NULL ;\n unsigned int bt_forward_socket = 0 ;\n const char * bt_local_ip = NULL ;\n unsigned short * bt_local_tcp_port = NULL ;\n unsigned short default_bt_server_tcp_port = 4330 ;\n const char * default_bt_local_ip = \"127.0.0.1\" ;\n unsigned short default_bt_local_tcp_port = 4330 ;\n extcap_parameters * extcap_conf = NULL ;\n # ifdef _WIN32 WSADATA wsaData ;\n attach_parent_console ( ) ;\n # endif opterr = 0 ;\n optind = 0 ;\n if ( argc == 1 ) {\n help ( ) ;\n return EXIT_CODE_SUCCESS ;\n }\n extcap_conf = g_new0 ( extcap_parameters , 1 ) ;\n extcap_base_set_util_info ( extcap_conf , ANDROIDDUMP_VERSION_MAJOR , ANDROIDDUMP_VERSION_MINOR , ANDROIDDUMP_VERSION_RELEASE , NULL ) ;\n while ( ( result = getopt_long ( argc , argv , \"\" , longopts , & option_idx ) ) != - 1 ) {\n switch ( result ) {\n case OPT_VERSION : printf ( \"%s.%s.%s\\n\" , ANDROIDDUMP_VERSION_MAJOR , ANDROIDDUMP_VERSION_MINOR , ANDROIDDUMP_VERSION_RELEASE ) ;\n return EXIT_CODE_SUCCESS ;\n case OPT_VERBOSE : if ( optarg ) verbose = ( g_ascii_strncasecmp ( optarg , \"TRUE\" , 4 ) == 0 ) ;\n else verbose = 1 ;\n {\n int j = 0 ;\n verbose_print ( \"VERBOSE: Command line: \" ) ;\n while ( j < argc ) {\n verbose_print ( \"%s \" , argv [ j ] ) ;\n j += 1 ;\n }\n verbose_print ( \"\\n\" ) ;\n }\n break ;\n case OPT_HELP : help ( ) ;\n return EXIT_CODE_SUCCESS ;\n case OPT_CONFIG_ADB_SERVER_IP : adb_server_ip = optarg ;\n break ;\n case OPT_CONFIG_ADB_SERVER_TCP_PORT : adb_server_tcp_port = & local_adb_server_tcp_port ;\n if ( ! optarg ) {\n errmsg_print ( \"ERROR: Impossible exception. Parameter required argument, but there is no it right now.\" ) ;\n return EXIT_CODE_GENERIC ;\n }\n * adb_server_tcp_port = ( unsigned short ) g_ascii_strtoull ( optarg , NULL , 10 ) ;\n break ;\n case OPT_CONFIG_LOGCAT_TEXT : logcat_text = ( g_ascii_strncasecmp ( optarg , \"TRUE\" , 4 ) == 0 ) ;\n break ;\n case OPT_CONFIG_BT_SERVER_TCP_PORT : bt_server_tcp_port = & local_bt_server_tcp_port ;\n if ( ! optarg ) {\n errmsg_print ( \"ERROR: Impossible exception. Parameter required argument, but there is no it right now.\" ) ;\n return EXIT_CODE_GENERIC ;\n }\n * bt_server_tcp_port = ( unsigned short ) g_ascii_strtoull ( optarg , NULL , 10 ) ;\n break ;\n case OPT_CONFIG_BT_FORWARD_SOCKET : bt_forward_socket = ( g_ascii_strncasecmp ( optarg , \"TRUE\" , 4 ) == 0 ) ;\n break ;\n case OPT_CONFIG_BT_LOCAL_IP : bt_local_ip = optarg ;\n break ;\n case OPT_CONFIG_BT_LOCAL_TCP_PORT : bt_local_tcp_port = & local_bt_local_tcp_port ;\n if ( ! optarg ) {\n errmsg_print ( \"ERROR: Impossible exception. Parameter required argument, but there is no it right now.\" ) ;\n return EXIT_CODE_GENERIC ;\n }\n * bt_local_tcp_port = ( unsigned short ) g_ascii_strtoull ( optarg , NULL , 10 ) ;\n break ;\n default : if ( ! extcap_base_parse_options ( extcap_conf , result - EXTCAP_OPT_LIST_INTERFACES , optarg ) ) {\n printf ( \"Invalid argument <%s>. Try --help.\\n\" , argv [ optind - 1 ] ) ;\n return EXIT_CODE_GENERIC ;\n }\n }\n }\n if ( ! adb_server_ip ) adb_server_ip = default_adb_server_ip ;\n if ( ! adb_server_tcp_port ) adb_server_tcp_port = & default_adb_server_tcp_port ;\n if ( ! bt_server_tcp_port ) bt_server_tcp_port = & default_bt_server_tcp_port ;\n if ( ! bt_local_ip ) bt_local_ip = default_bt_local_ip ;\n if ( ! bt_local_tcp_port ) bt_local_tcp_port = & default_bt_local_tcp_port ;\n # ifdef _WIN32 result = WSAStartup ( MAKEWORD ( 1 , 1 ) , & wsaData ) ;\n if ( result != 0 ) {\n errmsg_print ( \"ERROR: WSAStartup failed with error: %d\" , result ) ;\n return EXIT_CODE_GENERIC ;\n }\n # endif if ( extcap_conf -> do_list_interfaces ) register_interfaces ( extcap_conf , adb_server_ip , adb_server_tcp_port ) ;\n if ( extcap_base_handle_interface ( extcap_conf ) ) return EXIT_CODE_SUCCESS ;\n if ( extcap_conf -> show_config ) return list_config ( extcap_conf -> interface ) ;\n if ( extcap_conf -> capture ) {\n if ( extcap_conf -> interface && ( is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_MAIN ) || is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_SYSTEM ) || is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_RADIO ) || is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_EVENTS ) ) ) if ( logcat_text ) return capture_android_logcat_text ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port ) ;\n else return capture_android_logcat ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port ) ;\n else if ( extcap_conf -> interface && ( is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_TEXT_MAIN ) || is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_TEXT_SYSTEM ) || is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_TEXT_RADIO ) || is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_TEXT_EVENTS ) || ( is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_LOGCAT_TEXT_CRASH ) ) ) ) return capture_android_logcat_text ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port ) ;\n else if ( extcap_conf -> interface && is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_BLUETOOTH_HCIDUMP ) ) return capture_android_bluetooth_hcidump ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port ) ;\n else if ( extcap_conf -> interface && is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_BLUETOOTH_EXTERNAL_PARSER ) ) return capture_android_bluetooth_external_parser ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port , bt_server_tcp_port , bt_forward_socket , bt_local_ip , bt_local_tcp_port ) ;\n else if ( extcap_conf -> interface && ( is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_BLUETOOTH_BTSNOOP_NET ) ) ) return capture_android_bluetooth_btsnoop_net ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port ) ;\n else if ( extcap_conf -> interface && ( is_specified_interface ( extcap_conf -> interface , INTERFACE_ANDROID_WIFI_TCPDUMP ) ) ) return capture_android_wifi_tcpdump ( extcap_conf -> interface , extcap_conf -> fifo , adb_server_ip , adb_server_tcp_port ) ;\n else return EXIT_CODE_GENERIC ;\n }\n extcap_base_cleanup ( & extcap_conf ) ;\n return EXIT_CODE_SUCCESS ;\n }","target":0,"code_token_length":1711,"total_token_length":1947,"max_tokens_setting":2048} +{"idx":382560,"func":"my_regcomp(preg, pattern, cflags, charset)\nmy_regex_t *preg;\nconst char *pattern;\nint cflags;\nCHARSET_INFO *charset;\n{\n\tstruct parse pa;\n\tregister struct re_guts *g;\n\tregister struct parse *p = &pa;\n\tregister int i;\n\tregister size_t len;\n#ifdef REDEBUG\n#\tdefine\tGOODFLAGS(f)\t(f)\n#else\n#\tdefine\tGOODFLAGS(f)\t((f)&~REG_DUMP)\n#endif\n\n\tmy_regex_init(charset, NULL);\t\/* Init cclass if neaded *\/\n\tpreg->charset=charset;\n\tcflags = GOODFLAGS(cflags);\n\tif ((cflags®_EXTENDED) && (cflags®_NOSPEC))\n\t\treturn(REG_INVARG);\n\n\tif (cflags®_PEND) {\n\t\tif (preg->re_endp < pattern)\n\t\t\treturn(REG_INVARG);\n\t\tlen = preg->re_endp - pattern;\n\t} else\n\t\tlen = strlen((char *)pattern);\n\n\t\/*\n\t Find the maximum len we can safely process\n\t without a rollover and a mis-malloc.\n\t p->ssize is a sopno is a long (32+ bit signed);\n\t size_t is 16+ bit unsigned.\n\t*\/\n\t{\n\t size_t new_ssize = len \/ (size_t)2 * (size_t)3 + (size_t)1; \/* ugh *\/\n\t if ((new_ssize < len) ||\t\/* size_t rolled over *\/\n\t ((SIZE_T_MAX \/ sizeof(sop)) < new_ssize) ||\t\/* malloc arg *\/\n\t (new_ssize > LONG_MAX))\t\/* won't fit in ssize *\/\n\t\treturn(REG_ESPACE);\t\/* MY_REG_ESPACE or MY_REG_INVARG *\/\n\t p->ssize = new_ssize;\n\t}\n\n\t\/* do the mallocs early so failure handling is easy *\/\n\tg = (struct re_guts *)malloc(sizeof(struct re_guts) +\n\t\t\t\t\t\t\t(NC-1)*sizeof(cat_t));\n\tif (g == NULL)\n\t\treturn(REG_ESPACE);\n\tp->strip = (sop *)malloc(p->ssize * sizeof(sop));\n\tp->slen = 0;\n\tif (p->strip == NULL) {\n\t\tfree((char *)g);\n\t\treturn(REG_ESPACE);\n\t}\n\n\t\/* set things up *\/\n\tp->g = g;\n\tp->next = (char *)pattern;\t\/* convenience; we do not modify it *\/\n\tp->end = p->next + len;\n\tp->error = 0;\n\tp->ncsalloc = 0;\n\tp->charset = preg->charset;\n\tfor (i = 0; i < NPAREN; i++) {\n\t\tp->pbegin[i] = 0;\n\t\tp->pend[i] = 0;\n\t}\n\tg->csetsize = NC;\n\tg->sets = NULL;\n\tg->setbits = NULL;\n\tg->ncsets = 0;\n\tg->cflags = cflags;\n\tg->iflags = 0;\n\tg->nbol = 0;\n\tg->neol = 0;\n\tg->must = NULL;\n\tg->mlen = 0;\n\tg->nsub = 0;\n\tg->ncategories = 1;\t\/* category 0 is \"everything else\" *\/\n\tg->categories = &g->catspace[-(CHAR_MIN)];\n\t(void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));\n\tg->backrefs = 0;\n\n\t\/* do it *\/\n\tEMIT(OEND, 0);\n\tg->firststate = THERE();\n\tif (cflags®_EXTENDED)\n\t\tp_ere(p, OUT);\n\telse if (cflags®_NOSPEC)\n\t\tp_str(p);\n\telse\n\t\tp_bre(p, OUT, OUT);\n\tEMIT(OEND, 0);\n\tg->laststate = THERE();\n\n\t\/* tidy up loose ends and fill things in *\/\n\tcategorize(p, g);\n\tstripsnug(p, g);\n\tfindmust(p, g);\n\tg->nplus = pluscount(p, g);\n\tg->magic = MAGIC2;\n\tpreg->re_nsub = g->nsub;\n\tpreg->re_g = g;\n\tpreg->re_magic = MAGIC1;\n#ifndef REDEBUG\n\t\/* not debugging, so can't rely on the assert() in regexec() *\/\n\tif (g->iflags&BAD)\n\t\tSETERROR(REG_ASSERT);\n#endif\n\n\t\/* win or lose, we're done *\/\n\tif (p->error != 0)\t\/* lose *\/\n\t\tmy_regfree(preg);\n\treturn(p->error);\n}","target":0,"code_token_length":957,"total_token_length":1193,"max_tokens_setting":2048} +{"idx":88854,"func":"decode(message *m, const char *in, unsigned char *out, unsigned char (*decoder)(char), bool isFast)\n{\n\tunsigned char b1, b2, b3, b4;\n\tunsigned char cb1, cb2, cb3;\t\/* carried over from last line *\/\n\n\t\/*cli_dbgmsg(\"decode %s (len %d isFast %d base64chars %d)\\n\", in,\n\t\tin ? strlen(in) : 0,\n\t\tisFast, m->base64chars);*\/\n\n\tcb1 = cb2 = cb3 = '\\0';\n\n\tswitch(m->base64chars) {\n\t\tcase 3:\n\t\t\tcb3 = m->base64_3;\n\t\t\t\/* FALLTHROUGH *\/\n\t\tcase 2:\n\t\t\tcb2 = m->base64_2;\n\t\t\t\/* FALLTHROUGH *\/\n\t\tcase 1:\n\t\t\tcb1 = m->base64_1;\n\t\t\tisFast = FALSE;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(m->base64chars <= 3);\n\t}\n\n\tif(isFast)\n\t\t\/* Fast decoding if not last line *\/\n\t\twhile(*in) {\n\t\t\tb1 = (*decoder)(*in++);\n\t\t\tb2 = (*decoder)(*in++);\n\t\t\tb3 = (*decoder)(*in++);\n\t\t\t\/*\n\t\t\t * Put this line here to help on some compilers which\n\t\t\t * can make use of some architecure's ability to\n\t\t\t * multiprocess when different variables can be\n\t\t\t * updated at the same time - here b3 is used in\n\t\t\t * one line, b1\/b2 in the next and b4 in the next after\n\t\t\t * that, b3 and b4 rely on in but b1\/b2 don't\n\t\t\t *\/\n\t\t\t*out++ = (b1 << 2) | ((b2 >> 4) & 0x3);\n\t\t\tb4 = (*decoder)(*in++);\n\t\t\t*out++ = (b2 << 4) | ((b3 >> 2) & 0xF);\n\t\t\t*out++ = (b3 << 6) | (b4 & 0x3F);\n\t\t}\n\telse if(in == NULL) {\t\/* flush *\/\n\t\tint nbytes;\n\n\t\tif(m->base64chars == 0)\n\t\t\treturn out;\n\n\t\tcli_dbgmsg(\"base64chars = %d (%c %c %c)\\n\", m->base64chars,\n\t\t\tisalnum(cb1) ? cb1 : '@',\n\t\t\tisalnum(cb2) ? cb2 : '@',\n\t\t\tisalnum(cb3) ? cb3 : '@');\n\n\t\tm->base64chars--;\n\t\tb1 = cb1;\n\t\tnbytes = 1;\n\n\t\tif(m->base64chars) {\n\t\t\tm->base64chars--;\n\t\t\tb2 = cb2;\n\n\t\t\tif(m->base64chars) {\n\t\t\t\tnbytes = 2;\n\t\t\t\tm->base64chars--;\n\t\t\t\tb3 = cb3;\n\t\t\t\tnbytes = 3;\n\t\t\t} else if(b2)\n\t\t\t\tnbytes = 2;\n\t\t}\n\n\t\tswitch(nbytes) {\n\t\t\tcase 3:\n\t\t\t\tb4 = '\\0';\n\t\t\t\t\/* fall through *\/\n\t\t\tcase 4:\n\t\t\t\t*out++ = (b1 << 2) | ((b2 >> 4) & 0x3);\n\t\t\t\t*out++ = (b2 << 4) | ((b3 >> 2) & 0xF);\n\t\t\t\tif((nbytes == 4) || (b3&0x3))\n\t\t\t\t\t*out++ = (b3 << 6) | (b4 & 0x3F);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\t*out++ = (b1 << 2) | ((b2 >> 4) & 0x3);\n\t\t\t\tif((b2 << 4) & 0xFF)\n\t\t\t\t\t*out++ = b2 << 4;\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\t*out++ = b1 << 2;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tassert(0);\n\t\t}\n\t} else while(*in) {\n\t\tint nbytes;\n\n\t\tif(m->base64chars) {\n\t\t\tm->base64chars--;\n\t\t\tb1 = cb1;\n\t\t} else\n\t\t\tb1 = (*decoder)(*in++);\n\n\t\tif(*in == '\\0') {\n\t\t\tb2 = '\\0';\n\t\t\tnbytes = 1;\n\t\t} else {\n\t\t\tif(m->base64chars) {\n\t\t\t\tm->base64chars--;\n\t\t\t\tb2 = cb2;\n\t\t\t} else\n\t\t\t\tb2 = (*decoder)(*in++);\n\n\t\t\tif(*in == '\\0') {\n\t\t\t\tb3 = '\\0';\n\t\t\t\tnbytes = 2;\n\t\t\t} else {\n\t\t\t\tif(m->base64chars) {\n\t\t\t\t\tm->base64chars--;\n\t\t\t\t\tb3 = cb3;\n\t\t\t\t} else\n\t\t\t\t\tb3 = (*decoder)(*in++);\n\n\t\t\t\tif(*in == '\\0') {\n\t\t\t\t\tb4 = '\\0';\n\t\t\t\t\tnbytes = 3;\n\t\t\t\t} else {\n\t\t\t\t\tb4 = (*decoder)(*in++);\n\t\t\t\t\tnbytes = 4;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tswitch(nbytes) {\n\t\t\tcase 4:\n\t\t\t\t*out++ = (b1 << 2) | ((b2 >> 4) & 0x3);\n\t\t\t\t*out++ = (b2 << 4) | ((b3 >> 2) & 0xF);\n\t\t\t\t*out++ = (b3 << 6) | (b4 & 0x3F);\n\t\t\t\tcontinue;\n\t\t\tcase 3:\n\t\t\t\tm->base64_3 = b3;\n\t\t\tcase 2:\n\t\t\t\tm->base64_2 = b2;\n\t\t\tcase 1:\n\t\t\t\tm->base64_1 = b1;\n\t\t\t\tm->base64chars = nbytes;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tassert(0);\n\t\t}\n\t\tbreak;\t\/* nbytes != 4 => EOL *\/\n\t}\n\treturn out;\n}","target":0,"code_token_length":1288,"total_token_length":1524,"max_tokens_setting":2048} +{"idx":238561,"func":"void UiSceneCreator::CreateBackground() {\n auto background =\n Create(k2dBrowsingTexturedBackground, kPhaseBackground);\n background->SetVisible(false);\n background->AddBinding(base::MakeUnique>(\n base::BindRepeating(\n [](Model* m) {\n return m->background_available && m->background_loaded;\n },\n base::Unretained(model_)),\n base::BindRepeating([](UiElement* e, const bool& v) { e->SetVisible(v); },\n base::Unretained(background.get()))));\n scene_->AddUiElement(k2dBrowsingBackground, std::move(background));\n\n auto element = Create(k2dBrowsingDefaultBackground, kPhaseNone);\n element->set_hit_testable(false);\n element->AddBinding(base::MakeUnique>(\n base::BindRepeating([](Model* m) { return !m->background_available; },\n base::Unretained(model_)),\n base::BindRepeating([](UiElement* e, const bool& v) { e->SetVisible(v); },\n base::Unretained(element.get()))));\n scene_->AddUiElement(k2dBrowsingBackground, std::move(element));\n\n struct Panel {\n UiElementName name;\n int x_offset;\n int y_offset;\n int z_offset;\n int x_rotation;\n int y_rotation;\n int angle;\n };\n const std::vector panels = {\n {kBackgroundFront, 0, 0, -1, 0, 1, 0},\n {kBackgroundLeft, -1, 0, 0, 0, 1, 1},\n {kBackgroundBack, 0, 0, 1, 0, 1, 2},\n {kBackgroundRight, 1, 0, 0, 0, 1, 3},\n {kBackgroundTop, 0, 1, 0, 1, 0, 1},\n {kBackgroundBottom, 0, -1, 0, 1, 0, -1},\n };\n for (auto& panel : panels) {\n auto panel_element = Create(panel.name, kPhaseBackground);\n panel_element->SetSize(kSceneSize, kSceneSize);\n panel_element->SetTranslate(panel.x_offset * kSceneSize \/ 2,\n panel.y_offset * kSceneSize \/ 2,\n panel.z_offset * kSceneSize \/ 2);\n panel_element->SetRotate(panel.x_rotation, panel.y_rotation, 0,\n base::kPiFloat \/ 2 * panel.angle);\n panel_element->set_hit_testable(false);\n BindColor(model_, panel_element.get(), &ColorScheme::world_background,\n &Rect::SetColor);\n panel_element->AddBinding(\n VR_BIND_FUNC(bool, Model, model_, should_render_web_vr() == false,\n UiElement, panel_element.get(), SetVisible));\n scene_->AddUiElement(k2dBrowsingDefaultBackground,\n std::move(panel_element));\n }\n\n auto floor = Create(kFloor, kPhaseFloorCeiling);\n floor->SetSize(kSceneSize, kSceneSize);\n floor->SetTranslate(0.0, -kSceneHeight \/ 2, 0.0);\n floor->SetRotate(1, 0, 0, -base::kPiFloat \/ 2);\n floor->set_gridline_count(kFloorGridlineCount);\n floor->set_focusable(false);\n BindColor(model_, floor.get(), &ColorScheme::floor, &Grid::SetCenterColor);\n BindColor(model_, floor.get(), &ColorScheme::world_background,\n &Grid::SetEdgeColor);\n BindColor(model_, floor.get(), &ColorScheme::floor_grid, &Grid::SetGridColor);\n scene_->AddUiElement(k2dBrowsingDefaultBackground, std::move(floor));\n\n auto ceiling = Create(kCeiling, kPhaseFloorCeiling);\n ceiling->set_focusable(false);\n ceiling->SetSize(kSceneSize, kSceneSize);\n ceiling->SetTranslate(0.0, kSceneHeight \/ 2, 0.0);\n ceiling->SetRotate(1, 0, 0, base::kPiFloat \/ 2);\n BindColor(model_, ceiling.get(), &ColorScheme::ceiling,\n &Rect::SetCenterColor);\n BindColor(model_, ceiling.get(), &ColorScheme::world_background,\n &Rect::SetEdgeColor);\n scene_->AddUiElement(k2dBrowsingDefaultBackground, std::move(ceiling));\n}\n","target":0,"code_token_length":998,"total_token_length":1234,"max_tokens_setting":2048} +{"idx":289098,"func":"TEST_F ( ExtensionServiceSyncTest , ProcessSyncDataSettings ) {\n InitializeEmptyExtensionService ( ) ;\n extension_sync_service ( ) -> MergeDataAndStartSyncing ( syncer : : EXTENSIONS , syncer : : SyncDataList ( ) , base : : MakeUnique < syncer : : FakeSyncChangeProcessor > ( ) , base : : MakeUnique < syncer : : SyncErrorFactoryMock > ( ) ) ;\n InstallCRX ( data_dir ( ) . AppendASCII ( \"good.crx\" ) , INSTALL_NEW ) ;\n EXPECT_TRUE ( service ( ) -> IsExtensionEnabled ( good_crx ) ) ;\n EXPECT_FALSE ( extensions : : util : : IsIncognitoEnabled ( good_crx , profile ( ) ) ) ;\n auto get_permissions_modifier = [ this ] ( ) {\n const Extension * extension = registry ( ) -> GetExtensionById ( good_crx , extensions : : ExtensionRegistry : : EVERYTHING ) ;\n return base : : MakeUnique < ScriptingPermissionsModifier > ( profile ( ) , extension ) ;\n }\n ;\n EXPECT_FALSE ( get_permissions_modifier ( ) -> HasSetAllowedOnAllUrls ( ) ) ;\n const bool kDefaultAllowedScripting = ScriptingPermissionsModifier : : DefaultAllowedOnAllUrls ( ) ;\n EXPECT_EQ ( kDefaultAllowedScripting , get_permissions_modifier ( ) -> IsAllowedOnAllUrls ( ) ) ;\n sync_pb : : EntitySpecifics specifics ;\n sync_pb : : ExtensionSpecifics * ext_specifics = specifics . mutable_extension ( ) ;\n ext_specifics -> set_id ( good_crx ) ;\n ext_specifics -> set_version ( service ( ) -> GetInstalledExtension ( good_crx ) -> version ( ) -> GetString ( ) ) ;\n ext_specifics -> set_enabled ( false ) ;\n {\n SyncChangeList list = MakeSyncChangeList ( good_crx , specifics , SyncChange : : ACTION_UPDATE ) ;\n extension_sync_service ( ) -> ProcessSyncChanges ( FROM_HERE , list ) ;\n EXPECT_FALSE ( service ( ) -> IsExtensionEnabled ( good_crx ) ) ;\n EXPECT_FALSE ( extensions : : util : : IsIncognitoEnabled ( good_crx , profile ( ) ) ) ;\n EXPECT_FALSE ( get_permissions_modifier ( ) -> HasSetAllowedOnAllUrls ( ) ) ;\n EXPECT_EQ ( kDefaultAllowedScripting , get_permissions_modifier ( ) -> IsAllowedOnAllUrls ( ) ) ;\n }\n {\n ext_specifics -> set_enabled ( true ) ;\n ext_specifics -> set_incognito_enabled ( true ) ;\n SyncChangeList list = MakeSyncChangeList ( good_crx , specifics , SyncChange : : ACTION_UPDATE ) ;\n extension_sync_service ( ) -> ProcessSyncChanges ( FROM_HERE , list ) ;\n EXPECT_TRUE ( service ( ) -> IsExtensionEnabled ( good_crx ) ) ;\n EXPECT_TRUE ( extensions : : util : : IsIncognitoEnabled ( good_crx , profile ( ) ) ) ;\n }\n {\n ext_specifics -> set_enabled ( false ) ;\n ext_specifics -> set_incognito_enabled ( true ) ;\n SyncChangeList list = MakeSyncChangeList ( good_crx , specifics , SyncChange : : ACTION_UPDATE ) ;\n extension_sync_service ( ) -> ProcessSyncChanges ( FROM_HERE , list ) ;\n EXPECT_FALSE ( service ( ) -> IsExtensionEnabled ( good_crx ) ) ;\n EXPECT_TRUE ( extensions : : util : : IsIncognitoEnabled ( good_crx , profile ( ) ) ) ;\n }\n {\n ext_specifics -> set_enabled ( true ) ;\n ext_specifics -> set_all_urls_enabled ( ! kDefaultAllowedScripting ) ;\n SyncChangeList list = MakeSyncChangeList ( good_crx , specifics , SyncChange : : ACTION_UPDATE ) ;\n extension_sync_service ( ) -> ProcessSyncChanges ( FROM_HERE , list ) ;\n EXPECT_TRUE ( service ( ) -> IsExtensionEnabled ( good_crx ) ) ;\n EXPECT_TRUE ( get_permissions_modifier ( ) -> HasSetAllowedOnAllUrls ( ) ) ;\n EXPECT_EQ ( ! kDefaultAllowedScripting , get_permissions_modifier ( ) -> IsAllowedOnAllUrls ( ) ) ;\n }\n {\n ext_specifics -> set_all_urls_enabled ( kDefaultAllowedScripting ) ;\n SyncChangeList list = MakeSyncChangeList ( good_crx , specifics , SyncChange : : ACTION_UPDATE ) ;\n extension_sync_service ( ) -> ProcessSyncChanges ( FROM_HERE , list ) ;\n EXPECT_TRUE ( service ( ) -> IsExtensionEnabled ( good_crx ) ) ;\n EXPECT_TRUE ( get_permissions_modifier ( ) -> HasSetAllowedOnAllUrls ( ) ) ;\n EXPECT_EQ ( kDefaultAllowedScripting , get_permissions_modifier ( ) -> IsAllowedOnAllUrls ( ) ) ;\n }\n EXPECT_FALSE ( service ( ) -> pending_extension_manager ( ) -> IsIdPending ( good_crx ) ) ;\n }","target":0,"code_token_length":965,"total_token_length":1201,"max_tokens_setting":2048} +{"idx":392563,"func":"static void pcpu_balance_workfn(struct work_struct *work)\n{\n\tLIST_HEAD(to_free);\n\tstruct list_head *free_head = &pcpu_slot[pcpu_nr_slots - 1];\n\tstruct pcpu_chunk *chunk, *next;\n\tint slot, nr_to_pop, ret;\n\n\t\/*\n\t * There's no reason to keep around multiple unused chunks and VM\n\t * areas can be scarce. Destroy all free chunks except for one.\n\t *\/\n\tmutex_lock(&pcpu_alloc_mutex);\n\tspin_lock_irq(&pcpu_lock);\n\n\tlist_for_each_entry_safe(chunk, next, free_head, list) {\n\t\tWARN_ON(chunk->immutable);\n\n\t\t\/* spare the first one *\/\n\t\tif (chunk == list_first_entry(free_head, struct pcpu_chunk, list))\n\t\t\tcontinue;\n\n\t\tlist_del_init(&chunk->map_extend_list);\n\t\tlist_move(&chunk->list, &to_free);\n\t}\n\n\tspin_unlock_irq(&pcpu_lock);\n\n\tlist_for_each_entry_safe(chunk, next, &to_free, list) {\n\t\tint rs, re;\n\n\t\tpcpu_for_each_pop_region(chunk, rs, re, 0, pcpu_unit_pages) {\n\t\t\tpcpu_depopulate_chunk(chunk, rs, re);\n\t\t\tspin_lock_irq(&pcpu_lock);\n\t\t\tpcpu_chunk_depopulated(chunk, rs, re);\n\t\t\tspin_unlock_irq(&pcpu_lock);\n\t\t}\n\t\tpcpu_destroy_chunk(chunk);\n\t}\n\n\t\/* service chunks which requested async area map extension *\/\n\tdo {\n\t\tint new_alloc = 0;\n\n\t\tspin_lock_irq(&pcpu_lock);\n\n\t\tchunk = list_first_entry_or_null(&pcpu_map_extend_chunks,\n\t\t\t\t\tstruct pcpu_chunk, map_extend_list);\n\t\tif (chunk) {\n\t\t\tlist_del_init(&chunk->map_extend_list);\n\t\t\tnew_alloc = pcpu_need_to_extend(chunk, false);\n\t\t}\n\n\t\tspin_unlock_irq(&pcpu_lock);\n\n\t\tif (new_alloc)\n\t\t\tpcpu_extend_area_map(chunk, new_alloc);\n\t} while (chunk);\n\n\t\/*\n\t * Ensure there are certain number of free populated pages for\n\t * atomic allocs. Fill up from the most packed so that atomic\n\t * allocs don't increase fragmentation. If atomic allocation\n\t * failed previously, always populate the maximum amount. This\n\t * should prevent atomic allocs larger than PAGE_SIZE from keeping\n\t * failing indefinitely; however, large atomic allocs are not\n\t * something we support properly and can be highly unreliable and\n\t * inefficient.\n\t *\/\nretry_pop:\n\tif (pcpu_atomic_alloc_failed) {\n\t\tnr_to_pop = PCPU_EMPTY_POP_PAGES_HIGH;\n\t\t\/* best effort anyway, don't worry about synchronization *\/\n\t\tpcpu_atomic_alloc_failed = false;\n\t} else {\n\t\tnr_to_pop = clamp(PCPU_EMPTY_POP_PAGES_HIGH -\n\t\t\t\t pcpu_nr_empty_pop_pages,\n\t\t\t\t 0, PCPU_EMPTY_POP_PAGES_HIGH);\n\t}\n\n\tfor (slot = pcpu_size_to_slot(PAGE_SIZE); slot < pcpu_nr_slots; slot++) {\n\t\tint nr_unpop = 0, rs, re;\n\n\t\tif (!nr_to_pop)\n\t\t\tbreak;\n\n\t\tspin_lock_irq(&pcpu_lock);\n\t\tlist_for_each_entry(chunk, &pcpu_slot[slot], list) {\n\t\t\tnr_unpop = pcpu_unit_pages - chunk->nr_populated;\n\t\t\tif (nr_unpop)\n\t\t\t\tbreak;\n\t\t}\n\t\tspin_unlock_irq(&pcpu_lock);\n\n\t\tif (!nr_unpop)\n\t\t\tcontinue;\n\n\t\t\/* @chunk can't go away while pcpu_alloc_mutex is held *\/\n\t\tpcpu_for_each_unpop_region(chunk, rs, re, 0, pcpu_unit_pages) {\n\t\t\tint nr = min(re - rs, nr_to_pop);\n\n\t\t\tret = pcpu_populate_chunk(chunk, rs, rs + nr);\n\t\t\tif (!ret) {\n\t\t\t\tnr_to_pop -= nr;\n\t\t\t\tspin_lock_irq(&pcpu_lock);\n\t\t\t\tpcpu_chunk_populated(chunk, rs, rs + nr);\n\t\t\t\tspin_unlock_irq(&pcpu_lock);\n\t\t\t} else {\n\t\t\t\tnr_to_pop = 0;\n\t\t\t}\n\n\t\t\tif (!nr_to_pop)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (nr_to_pop) {\n\t\t\/* ran out of chunks to populate, create a new one and retry *\/\n\t\tchunk = pcpu_create_chunk();\n\t\tif (chunk) {\n\t\t\tspin_lock_irq(&pcpu_lock);\n\t\t\tpcpu_chunk_relocate(chunk, -1);\n\t\t\tspin_unlock_irq(&pcpu_lock);\n\t\t\tgoto retry_pop;\n\t\t}\n\t}\n\n\tmutex_unlock(&pcpu_alloc_mutex);\n}","target":0,"code_token_length":963,"total_token_length":1199,"max_tokens_setting":2048} +{"idx":419826,"func":"void server_process_syslog_message(\n Server *s,\n const char *buf,\n size_t raw_len,\n const struct ucred *ucred,\n const struct timeval *tv,\n const char *label,\n size_t label_len) {\n\n char *t, syslog_priority[sizeof(\"PRIORITY=\") + DECIMAL_STR_MAX(int)],\n syslog_facility[sizeof(\"SYSLOG_FACILITY=\") + DECIMAL_STR_MAX(int)];\n const char *msg, *syslog_ts, *a;\n _cleanup_free_ char *identifier = NULL, *pid = NULL,\n *dummy = NULL, *msg_msg = NULL, *msg_raw = NULL;\n int priority = LOG_USER | LOG_INFO, r;\n ClientContext *context = NULL;\n struct iovec *iovec;\n size_t n = 0, m, i, leading_ws, syslog_ts_len;\n bool store_raw;\n\n assert(s);\n assert(buf);\n \/* The message cannot be empty. *\/\n assert(raw_len > 0);\n \/* The buffer NUL-terminated and can be used a string. raw_len is the length\n * without the terminating NUL byte, the buffer is actually one bigger. *\/\n assert(buf[raw_len] == '\\0');\n\n if (ucred && pid_is_valid(ucred->pid)) {\n r = client_context_get(s, ucred->pid, ucred, label, label_len, NULL, &context);\n if (r < 0)\n log_warning_errno(r, \"Failed to retrieve credentials for PID \" PID_FMT \", ignoring: %m\", ucred->pid);\n }\n\n \/* We are creating a copy of the message because we want to forward the original message\n verbatim to the legacy syslog implementation *\/\n for (i = raw_len; i > 0; i--)\n if (!strchr(WHITESPACE, buf[i-1]))\n break;\n\n leading_ws = strspn(buf, WHITESPACE);\n\n if (i == 0)\n \/* The message contains only whitespaces *\/\n msg = buf + raw_len;\n else if (i == raw_len)\n \/* Nice! No need to strip anything on the end, let's optimize this a bit *\/\n msg = buf + leading_ws;\n else {\n msg = dummy = new(char, i - leading_ws + 1);\n if (!dummy) {\n log_oom();\n return;\n }\n\n memcpy(dummy, buf + leading_ws, i - leading_ws);\n dummy[i - leading_ws] = 0;\n }\n\n \/* We will add the SYSLOG_RAW= field when we stripped anything\n * _or_ if the input message contained NUL bytes. *\/\n store_raw = msg != buf || strlen(msg) != raw_len;\n\n syslog_parse_priority(&msg, &priority, true);\n\n if (!client_context_test_priority(context, priority))\n return;\n\n syslog_ts = msg;\n syslog_ts_len = syslog_skip_timestamp(&msg);\n if (syslog_ts_len == 0)\n \/* We failed to parse the full timestamp, store the raw message too *\/\n store_raw = true;\n\n syslog_parse_identifier(&msg, &identifier, &pid);\n\n if (s->forward_to_syslog)\n forward_syslog_raw(s, priority, buf, raw_len, ucred, tv);\n\n if (s->forward_to_kmsg)\n server_forward_kmsg(s, priority, identifier, msg, ucred);\n\n if (s->forward_to_console)\n server_forward_console(s, priority, identifier, msg, ucred);\n\n if (s->forward_to_wall)\n server_forward_wall(s, priority, identifier, msg, ucred);\n\n m = N_IOVEC_META_FIELDS + 8 + client_context_extra_fields_n_iovec(context);\n iovec = newa(struct iovec, m);\n\n iovec[n++] = IOVEC_MAKE_STRING(\"_TRANSPORT=syslog\");\n\n xsprintf(syslog_priority, \"PRIORITY=%i\", priority & LOG_PRIMASK);\n iovec[n++] = IOVEC_MAKE_STRING(syslog_priority);\n\n if (priority & LOG_FACMASK) {\n xsprintf(syslog_facility, \"SYSLOG_FACILITY=%i\", LOG_FAC(priority));\n iovec[n++] = IOVEC_MAKE_STRING(syslog_facility);\n }\n\n if (identifier) {\n a = strjoina(\"SYSLOG_IDENTIFIER=\", identifier);\n iovec[n++] = IOVEC_MAKE_STRING(a);\n }\n\n if (pid) {\n a = strjoina(\"SYSLOG_PID=\", pid);\n iovec[n++] = IOVEC_MAKE_STRING(a);\n }\n\n if (syslog_ts_len > 0) {\n const size_t hlen = strlen(\"SYSLOG_TIMESTAMP=\");\n\n t = newa(char, hlen + syslog_ts_len);\n memcpy(t, \"SYSLOG_TIMESTAMP=\", hlen);\n memcpy(t + hlen, syslog_ts, syslog_ts_len);\n\n iovec[n++] = IOVEC_MAKE(t, hlen + syslog_ts_len);\n }\n\n msg_msg = strjoin(\"MESSAGE=\", msg);\n if (!msg_msg) {\n log_oom();\n return;\n }\n iovec[n++] = IOVEC_MAKE_STRING(msg_msg);\n\n if (store_raw) {\n const size_t hlen = strlen(\"SYSLOG_RAW=\");\n\n msg_raw = new(char, hlen + raw_len);\n if (!msg_raw) {\n log_oom();\n return;\n }\n\n memcpy(msg_raw, \"SYSLOG_RAW=\", hlen);\n memcpy(msg_raw + hlen, buf, raw_len);\n\n iovec[n++] = IOVEC_MAKE(msg_raw, hlen + raw_len);\n }\n\n server_dispatch_message(s, iovec, n, m, context, tv, priority, 0);\n}","target":0,"code_token_length":1239,"total_token_length":1475,"max_tokens_setting":2048} +{"idx":414217,"func":"contact_list_uids_handler (LDAPOp *op,\n LDAPMessage *res)\n{\n\tLDAPGetContactListUIDsOp *contact_list_uids_op = (LDAPGetContactListUIDsOp *) op;\n\tEBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (op->backend);\n\tLDAPMessage *e;\n\tgint msg_type;\n\tGTimeVal start, end;\n\tgulong diff;\n\n\tif (enable_debug) {\n\t\tprintf (\"contact_list_uids_handler ...\\n\");\n\t\tg_get_current_time (&start);\n\t}\n\n\tg_rec_mutex_lock (&eds_ldap_handler_lock);\n\tif (!bl->priv->ldap) {\n\t\tg_rec_mutex_unlock (&eds_ldap_handler_lock);\n\t\te_data_book_respond_get_contact_list_uids (op->book, op->opid, EDB_ERROR_NOT_CONNECTED (), NULL);\n\t\tldap_op_finished (op);\n\t\tif (enable_debug)\n\t\t\tprintf (\"contact_list_uids_handler ... ldap handler is NULL \\n\");\n\t\treturn;\n\t}\n\tg_rec_mutex_unlock (&eds_ldap_handler_lock);\n\n\tmsg_type = ldap_msgtype (res);\n\tif (msg_type == LDAP_RES_SEARCH_ENTRY) {\n\t\tg_rec_mutex_lock (&eds_ldap_handler_lock);\n\t\tif (bl->priv->ldap)\n\t\t\te = ldap_first_entry (bl->priv->ldap, res);\n\t\telse\n\t\t\te = NULL;\n\t\tg_rec_mutex_unlock (&eds_ldap_handler_lock);\n\n\t\twhile (NULL != e) {\n\t\t\tEContact *contact;\n\t\t\tgchar *uid = NULL;\n\n\t\t\tcontact = build_contact_from_entry (bl, e, NULL, &uid);\n\t\t\tg_clear_object (&contact);\n\n\t\t\tif (enable_debug)\n\t\t\t\tprintf (\"uid = %s\\n\", uid ? uid : \"(null)\");\n\n\t\t\tif (uid)\n\t\t\t\tcontact_list_uids_op->uids = g_slist_append (contact_list_uids_op->uids, uid);\n\n\t\t\tg_rec_mutex_lock (&eds_ldap_handler_lock);\n\t\t\tif (bl->priv->ldap)\n\t\t\t\te = ldap_next_entry (bl->priv->ldap, e);\n\t\t\telse\n\t\t\t\te = NULL;\n\t\t\tg_rec_mutex_unlock (&eds_ldap_handler_lock);\n\t\t}\n\t} else if (msg_type == LDAP_RES_SEARCH_REFERENCE) {\n\t\t\/* ignore references *\/\n\t} else if (msg_type == LDAP_RES_SEARCH_RESULT) {\n\t\tgchar *ldap_error_msg = NULL;\n\t\tgint ldap_error;\n\n\t\tg_rec_mutex_lock (&eds_ldap_handler_lock);\n\t\tif (bl->priv->ldap) {\n\t\t\tldap_parse_result (\n\t\t\t\tbl->priv->ldap, res, &ldap_error,\n\t\t\t\tNULL, &ldap_error_msg, NULL, NULL, 0);\n\t\t} else {\n\t\t\tldap_error = LDAP_SERVER_DOWN;\n\t\t}\n\t\tg_rec_mutex_unlock (&eds_ldap_handler_lock);\n\t\tif (ldap_error != LDAP_SUCCESS) {\n\t\t\tg_warning (\n\t\t\t\t\"contact_list_uids_handler: %02X (%s), additional info: %s\",\n\t\t\t\tldap_error,\n\t\t\t\tldap_err2string (ldap_error), ldap_error_msg);\n\t\t}\n\t\tif (ldap_error_msg)\n\t\t\tldap_memfree (ldap_error_msg);\n\n\t\tg_warning (\"search returned %d\\n\", ldap_error);\n\n\t\tif (ldap_error == LDAP_TIMELIMIT_EXCEEDED)\n\t\t\te_data_book_respond_get_contact_list_uids (\n\t\t\t\top->book, op->opid,\n\t\t\t\tEDB_ERROR (SEARCH_TIME_LIMIT_EXCEEDED),\n\t\t\t\tcontact_list_uids_op->uids);\n\t\telse if (ldap_error == LDAP_SIZELIMIT_EXCEEDED)\n\t\t\te_data_book_respond_get_contact_list_uids (\n\t\t\t\top->book, op->opid,\n\t\t\t\tEDB_ERROR (SEARCH_SIZE_LIMIT_EXCEEDED),\n\t\t\t\tcontact_list_uids_op->uids);\n\t\telse if (ldap_error == LDAP_SUCCESS)\n\t\t\te_data_book_respond_get_contact_list_uids (\n\t\t\t\top->book, op->opid,\n\t\t\t\tEDB_ERROR (SUCCESS),\n\t\t\t\tcontact_list_uids_op->uids);\n\t\telse\n\t\t\te_data_book_respond_get_contact_list_uids (\n\t\t\t\top->book, op->opid,\n\t\t\t\tldap_error_to_response (ldap_error),\n\t\t\t\tcontact_list_uids_op->uids);\n\n\t\tldap_op_finished (op);\n\t\tif (enable_debug) {\n\t\t\tprintf (\"contact_list_uids_handler success \");\n\t\t\tg_get_current_time (&end);\n\t\t\tdiff = end.tv_sec * 1000 + end.tv_usec \/ 1000;\n\t\t\tdiff -= start.tv_sec * 1000 + start.tv_usec \/ 1000;\n\t\t\tprintf (\"and took %ld.%03ld seconds\\n\", diff \/ 1000, diff % 1000);\n\t\t}\n\t}\n\telse {\n\t\tg_warning (\"unhandled search result type %d returned\", msg_type);\n\t\te_data_book_respond_get_contact_list_uids (\n\t\t\top->book, op->opid,\n\t\t\te_data_book_create_error_fmt (E_DATA_BOOK_STATUS_OTHER_ERROR,\n\t\t\t_(\"%s: Unhandled search result type %d returned\"), G_STRFUNC, msg_type),\n\t\t\tNULL);\n\t\tldap_op_finished (op);\n\t}\n}","target":0,"code_token_length":1092,"total_token_length":1328,"max_tokens_setting":2048} +{"idx":151709,"func":"CConfig CUser::ToConfig() const {\n CConfig config;\n CConfig passConfig;\n\n CString sHash;\n switch (m_eHashType) {\n case HASH_NONE:\n sHash = \"Plain\";\n break;\n case HASH_MD5:\n sHash = \"MD5\";\n break;\n case HASH_SHA256:\n sHash = \"SHA256\";\n break;\n }\n passConfig.AddKeyValuePair(\"Salt\", m_sPassSalt);\n passConfig.AddKeyValuePair(\"Method\", sHash);\n passConfig.AddKeyValuePair(\"Hash\", GetPass());\n config.AddSubConfig(\"Pass\", \"password\", passConfig);\n\n config.AddKeyValuePair(\"Nick\", GetNick());\n config.AddKeyValuePair(\"AltNick\", GetAltNick());\n config.AddKeyValuePair(\"Ident\", GetIdent());\n config.AddKeyValuePair(\"RealName\", GetRealName());\n config.AddKeyValuePair(\"BindHost\", GetBindHost());\n config.AddKeyValuePair(\"DCCBindHost\", GetDCCBindHost());\n config.AddKeyValuePair(\"QuitMsg\", GetQuitMsg());\n if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix())\n config.AddKeyValuePair(\"StatusPrefix\", GetStatusPrefix());\n config.AddKeyValuePair(\"Skin\", GetSkinName());\n config.AddKeyValuePair(\"ChanModes\", GetDefaultChanModes());\n config.AddKeyValuePair(\"ChanBufferSize\", CString(GetChanBufferSize()));\n config.AddKeyValuePair(\"QueryBufferSize\", CString(GetQueryBufferSize()));\n config.AddKeyValuePair(\"AutoClearChanBuffer\",\n CString(AutoClearChanBuffer()));\n config.AddKeyValuePair(\"AutoClearQueryBuffer\",\n CString(AutoClearQueryBuffer()));\n config.AddKeyValuePair(\"MultiClients\", CString(MultiClients()));\n config.AddKeyValuePair(\"DenyLoadMod\", CString(DenyLoadMod()));\n config.AddKeyValuePair(\"Admin\", CString(IsAdmin()));\n config.AddKeyValuePair(\"DenySetBindHost\", CString(DenySetBindHost()));\n config.AddKeyValuePair(\"TimestampFormat\", GetTimestampFormat());\n config.AddKeyValuePair(\"AppendTimestamp\", CString(GetTimestampAppend()));\n config.AddKeyValuePair(\"PrependTimestamp\", CString(GetTimestampPrepend()));\n config.AddKeyValuePair(\"AuthOnlyViaModule\", CString(AuthOnlyViaModule()));\n config.AddKeyValuePair(\"Timezone\", m_sTimezone);\n config.AddKeyValuePair(\"JoinTries\", CString(m_uMaxJoinTries));\n config.AddKeyValuePair(\"MaxNetworks\", CString(m_uMaxNetworks));\n config.AddKeyValuePair(\"MaxQueryBuffers\", CString(m_uMaxQueryBuffers));\n config.AddKeyValuePair(\"MaxJoins\", CString(m_uMaxJoins));\n config.AddKeyValuePair(\"ClientEncoding\", GetClientEncoding());\n config.AddKeyValuePair(\"Language\", GetLanguage());\n config.AddKeyValuePair(\"NoTrafficTimeout\", CString(GetNoTrafficTimeout()));\n\n \/\/ Allow Hosts\n if (!m_ssAllowedHosts.empty()) {\n for (const CString& sHost : m_ssAllowedHosts) {\n config.AddKeyValuePair(\"Allow\", sHost);\n }\n }\n\n \/\/ CTCP Replies\n if (!m_mssCTCPReplies.empty()) {\n for (const auto& itb : m_mssCTCPReplies) {\n config.AddKeyValuePair(\"CTCPReply\",\n itb.first.AsUpper() + \" \" + itb.second);\n }\n }\n\n \/\/ Modules\n const CModules& Mods = GetModules();\n\n if (!Mods.empty()) {\n for (CModule* pMod : Mods) {\n CString sArgs = pMod->GetArgs();\n\n if (!sArgs.empty()) {\n sArgs = \" \" + sArgs;\n }\n\n config.AddKeyValuePair(\"LoadModule\", pMod->GetModName() + sArgs);\n }\n }\n\n \/\/ Networks\n for (CIRCNetwork* pNetwork : m_vIRCNetworks) {\n config.AddSubConfig(\"Network\", pNetwork->GetName(),\n pNetwork->ToConfig());\n }\n\n return config;\n}","target":0,"code_token_length":815,"total_token_length":1051,"max_tokens_setting":2048} +{"idx":18464,"func":"static int mpeg_decode_postinit ( AVCodecContext * avctx ) {\n Mpeg1Context * s1 = avctx -> priv_data ;\n MpegEncContext * s = & s1 -> mpeg_enc_ctx ;\n uint8_t old_permutation [ 64 ] ;\n if ( ( s1 -> mpeg_enc_ctx_allocated == 0 ) || avctx -> coded_width != s -> width || avctx -> coded_height != s -> height || s1 -> save_width != s -> width || s1 -> save_height != s -> height || s1 -> save_aspect_info != s -> aspect_ratio_info || s1 -> save_progressive_seq != s -> progressive_sequence || 0 ) {\n if ( s1 -> mpeg_enc_ctx_allocated ) {\n ParseContext pc = s -> parse_context ;\n s -> parse_context . buffer = 0 ;\n ff_MPV_common_end ( s ) ;\n s -> parse_context = pc ;\n }\n if ( ( s -> width == 0 ) || ( s -> height == 0 ) ) return - 2 ;\n avcodec_set_dimensions ( avctx , s -> width , s -> height ) ;\n avctx -> bit_rate = s -> bit_rate ;\n s1 -> save_aspect_info = s -> aspect_ratio_info ;\n s1 -> save_width = s -> width ;\n s1 -> save_height = s -> height ;\n s1 -> save_progressive_seq = s -> progressive_sequence ;\n avctx -> has_b_frames = ! s -> low_delay ;\n if ( avctx -> codec_id == AV_CODEC_ID_MPEG1VIDEO ) {\n avctx -> time_base . den = ff_mpeg12_frame_rate_tab [ s -> frame_rate_index ] . num ;\n avctx -> time_base . num = ff_mpeg12_frame_rate_tab [ s -> frame_rate_index ] . den ;\n avctx -> sample_aspect_ratio = av_d2q ( 1.0 \/ ff_mpeg1_aspect [ s -> aspect_ratio_info ] , 255 ) ;\n avctx -> ticks_per_frame = 1 ;\n }\n else {\n av_reduce ( & s -> avctx -> time_base . den , & s -> avctx -> time_base . num , ff_mpeg12_frame_rate_tab [ s -> frame_rate_index ] . num * s1 -> frame_rate_ext . num * 2 , ff_mpeg12_frame_rate_tab [ s -> frame_rate_index ] . den * s1 -> frame_rate_ext . den , 1 << 30 ) ;\n avctx -> ticks_per_frame = 2 ;\n if ( s -> aspect_ratio_info > 1 ) {\n AVRational dar = av_mul_q ( av_div_q ( ff_mpeg2_aspect [ s -> aspect_ratio_info ] , ( AVRational ) {\n s1 -> pan_scan . width , s1 -> pan_scan . height }\n ) , ( AVRational ) {\n s -> width , s -> height }\n ) ;\n if ( ( s1 -> pan_scan . width == 0 ) || ( s1 -> pan_scan . height == 0 ) || ( av_cmp_q ( dar , ( AVRational ) {\n 4 , 3 }\n ) && av_cmp_q ( dar , ( AVRational ) {\n 16 , 9 }\n ) ) ) {\n s -> avctx -> sample_aspect_ratio = av_div_q ( ff_mpeg2_aspect [ s -> aspect_ratio_info ] , ( AVRational ) {\n s -> width , s -> height }\n ) ;\n }\n else {\n s -> avctx -> sample_aspect_ratio = av_div_q ( ff_mpeg2_aspect [ s -> aspect_ratio_info ] , ( AVRational ) {\n s1 -> pan_scan . width , s1 -> pan_scan . height }\n ) ;\n av_dlog ( avctx , \"A %d\/%d\\n\" , ff_mpeg2_aspect [ s -> aspect_ratio_info ] . num , ff_mpeg2_aspect [ s -> aspect_ratio_info ] . den ) ;\n av_dlog ( avctx , \"B %d\/%d\\n\" , s -> avctx -> sample_aspect_ratio . num , s -> avctx -> sample_aspect_ratio . den ) ;\n }\n }\n else {\n s -> avctx -> sample_aspect_ratio = ff_mpeg2_aspect [ s -> aspect_ratio_info ] ;\n }\n }\n avctx -> pix_fmt = mpeg_get_pixelformat ( avctx ) ;\n avctx -> hwaccel = ff_find_hwaccel ( avctx -> codec -> id , avctx -> pix_fmt ) ;\n if ( avctx -> pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx -> hwaccel || s -> avctx -> codec -> capabilities & CODEC_CAP_HWACCEL_VDPAU ) if ( avctx -> idct_algo == FF_IDCT_AUTO ) avctx -> idct_algo = FF_IDCT_SIMPLE ;\n memcpy ( old_permutation , s -> dsp . idct_permutation , 64 * sizeof ( uint8_t ) ) ;\n if ( ff_MPV_common_init ( s ) < 0 ) return - 2 ;\n quant_matrix_rebuild ( s -> intra_matrix , old_permutation , s -> dsp . idct_permutation ) ;\n quant_matrix_rebuild ( s -> inter_matrix , old_permutation , s -> dsp . idct_permutation ) ;\n quant_matrix_rebuild ( s -> chroma_intra_matrix , old_permutation , s -> dsp . idct_permutation ) ;\n quant_matrix_rebuild ( s -> chroma_inter_matrix , old_permutation , s -> dsp . idct_permutation ) ;\n s1 -> mpeg_enc_ctx_allocated = 1 ;\n }\n return 0 ;\n }","target":0,"code_token_length":1154,"total_token_length":1390,"max_tokens_setting":2048} +{"idx":414613,"func":"static int __mb_check_buddy(struct ext4_buddy *e4b, char *file,\n\t\t\t\tconst char *function, int line)\n{\n\tstruct super_block *sb = e4b->bd_sb;\n\tint order = e4b->bd_blkbits + 1;\n\tint max;\n\tint max2;\n\tint i;\n\tint j;\n\tint k;\n\tint count;\n\tstruct ext4_group_info *grp;\n\tint fragments = 0;\n\tint fstart;\n\tstruct list_head *cur;\n\tvoid *buddy;\n\tvoid *buddy2;\n\n\t{\n\t\tstatic int mb_check_counter;\n\t\tif (mb_check_counter++ % 100 != 0)\n\t\t\treturn 0;\n\t}\n\n\twhile (order > 1) {\n\t\tbuddy = mb_find_buddy(e4b, order, &max);\n\t\tMB_CHECK_ASSERT(buddy);\n\t\tbuddy2 = mb_find_buddy(e4b, order - 1, &max2);\n\t\tMB_CHECK_ASSERT(buddy2);\n\t\tMB_CHECK_ASSERT(buddy != buddy2);\n\t\tMB_CHECK_ASSERT(max * 2 == max2);\n\n\t\tcount = 0;\n\t\tfor (i = 0; i < max; i++) {\n\n\t\t\tif (mb_test_bit(i, buddy)) {\n\t\t\t\t\/* only single bit in buddy2 may be 1 *\/\n\t\t\t\tif (!mb_test_bit(i << 1, buddy2)) {\n\t\t\t\t\tMB_CHECK_ASSERT(\n\t\t\t\t\t\tmb_test_bit((i<<1)+1, buddy2));\n\t\t\t\t} else if (!mb_test_bit((i << 1) + 1, buddy2)) {\n\t\t\t\t\tMB_CHECK_ASSERT(\n\t\t\t\t\t\tmb_test_bit(i << 1, buddy2));\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/* both bits in buddy2 must be 1 *\/\n\t\t\tMB_CHECK_ASSERT(mb_test_bit(i << 1, buddy2));\n\t\t\tMB_CHECK_ASSERT(mb_test_bit((i << 1) + 1, buddy2));\n\n\t\t\tfor (j = 0; j < (1 << order); j++) {\n\t\t\t\tk = (i * (1 << order)) + j;\n\t\t\t\tMB_CHECK_ASSERT(\n\t\t\t\t\t!mb_test_bit(k, e4b->bd_bitmap));\n\t\t\t}\n\t\t\tcount++;\n\t\t}\n\t\tMB_CHECK_ASSERT(e4b->bd_info->bb_counters[order] == count);\n\t\torder--;\n\t}\n\n\tfstart = -1;\n\tbuddy = mb_find_buddy(e4b, 0, &max);\n\tfor (i = 0; i < max; i++) {\n\t\tif (!mb_test_bit(i, buddy)) {\n\t\t\tMB_CHECK_ASSERT(i >= e4b->bd_info->bb_first_free);\n\t\t\tif (fstart == -1) {\n\t\t\t\tfragments++;\n\t\t\t\tfstart = i;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tfstart = -1;\n\t\t\/* check used bits only *\/\n\t\tfor (j = 0; j < e4b->bd_blkbits + 1; j++) {\n\t\t\tbuddy2 = mb_find_buddy(e4b, j, &max2);\n\t\t\tk = i >> j;\n\t\t\tMB_CHECK_ASSERT(k < max2);\n\t\t\tMB_CHECK_ASSERT(mb_test_bit(k, buddy2));\n\t\t}\n\t}\n\tMB_CHECK_ASSERT(!EXT4_MB_GRP_NEED_INIT(e4b->bd_info));\n\tMB_CHECK_ASSERT(e4b->bd_info->bb_fragments == fragments);\n\n\tgrp = ext4_get_group_info(sb, e4b->bd_group);\n\tlist_for_each(cur, &grp->bb_prealloc_list) {\n\t\text4_group_t groupnr;\n\t\tstruct ext4_prealloc_space *pa;\n\t\tpa = list_entry(cur, struct ext4_prealloc_space, pa_group_list);\n\t\text4_get_group_no_and_offset(sb, pa->pa_pstart, &groupnr, &k);\n\t\tMB_CHECK_ASSERT(groupnr == e4b->bd_group);\n\t\tfor (i = 0; i < pa->pa_len; i++)\n\t\t\tMB_CHECK_ASSERT(mb_test_bit(k + i, buddy));\n\t}\n\treturn 0;\n}","target":0,"code_token_length":869,"total_token_length":1105,"max_tokens_setting":2048} +{"idx":340773,"func":"static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n MOVContext *mov = s->priv_data;\n\n ByteIOContext *pb = s->pb;\n\n MOVTrack *trk = &mov->tracks[pkt->stream_index];\n\n AVCodecContext *enc = trk->enc;\n\n unsigned int samplesInChunk = 0;\n\n int size= pkt->size;\n\n\n\n if (url_is_streamed(s->pb)) return 0; \/* Can't handle that *\/\n\n if (!size) return 0; \/* Discard 0 sized packets *\/\n\n\n\n if (enc->codec_id == CODEC_ID_AMR_NB) {\n\n \/* We must find out how many AMR blocks there are in one packet *\/\n\n static uint16_t packed_size[16] =\n\n {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0};\n\n int len = 0;\n\n\n\n while (len < size && samplesInChunk < 100) {\n\n len += packed_size[(pkt->data[len] >> 3) & 0x0F];\n\n samplesInChunk++;\n\n }\n\n if(samplesInChunk > 1){\n\n av_log(s, AV_LOG_ERROR, \"fatal error, input is not a single packet, implement a AVParser for it\\n\");\n\n return -1;\n\n }\n\n } else if (trk->sampleSize)\n\n samplesInChunk = size\/trk->sampleSize;\n\n else\n\n samplesInChunk = 1;\n\n\n\n \/* copy extradata if it exists *\/\n\n if (trk->vosLen == 0 && enc->extradata_size > 0) {\n\n trk->vosLen = enc->extradata_size;\n\n trk->vosData = av_malloc(trk->vosLen);\n\n memcpy(trk->vosData, enc->extradata, trk->vosLen);\n\n }\n\n\n\n if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) {\n\n \/* from x264 or from bytestream h264 *\/\n\n \/* nal reformating needed *\/\n\n int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);\n\n if (ret < 0)\n\n return ret;\n\n assert(pkt->size);\n\n size = pkt->size;\n\n } else if (enc->codec_id == CODEC_ID_DNXHD && !trk->vosLen) {\n\n \/* copy frame header to create needed atoms *\/\n\n if (size < 640)\n\n return -1;\n\n trk->vosLen = 640;\n\n trk->vosData = av_malloc(trk->vosLen);\n\n memcpy(trk->vosData, pkt->data, 640);\n\n }\n\n\n\n if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) {\n\n trk->cluster = av_realloc(trk->cluster, (trk->entry + MOV_INDEX_CLUSTER_SIZE) * sizeof(*trk->cluster));\n\n if (!trk->cluster)\n\n return -1;\n\n }\n\n\n\n trk->cluster[trk->entry].pos = url_ftell(pb);\n\n trk->cluster[trk->entry].samplesInChunk = samplesInChunk;\n\n trk->cluster[trk->entry].size = size;\n\n trk->cluster[trk->entry].entries = samplesInChunk;\n\n trk->cluster[trk->entry].dts = pkt->dts;\n\n trk->trackDuration = pkt->dts - trk->cluster[0].dts + pkt->duration;\n\n\n\n if(enc->codec_type == CODEC_TYPE_VIDEO) {\n\n if (pkt->dts != pkt->pts)\n\n trk->hasBframes = 1;\n\n trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;\n\n trk->cluster[trk->entry].key_frame = !!(pkt->flags & PKT_FLAG_KEY);\n\n if(trk->cluster[trk->entry].key_frame)\n\n trk->hasKeyframes++;\n\n }\n\n trk->entry++;\n\n trk->sampleCount += samplesInChunk;\n\n mov->mdat_size += size;\n\n\n\n put_buffer(pb, pkt->data, size);\n\n\n\n put_flush_packet(pb);\n\n return 0;\n\n}\n","target":0,"code_token_length":981,"total_token_length":1217,"max_tokens_setting":2048} +{"idx":288646,"func":"int SRP_VBASE_init ( SRP_VBASE * vb , char * verifier_file ) {\n int error_code ;\n STACK_OF ( SRP_gN ) * SRP_gN_tab = sk_SRP_gN_new_null ( ) ;\n char * last_index = NULL ;\n int i ;\n char * * pp ;\n SRP_gN * gN = NULL ;\n SRP_user_pwd * user_pwd = NULL ;\n TXT_DB * tmpdb = NULL ;\n BIO * in = BIO_new ( BIO_s_file ( ) ) ;\n error_code = SRP_ERR_OPEN_FILE ;\n if ( in == NULL || BIO_read_filename ( in , verifier_file ) <= 0 ) goto err ;\n error_code = SRP_ERR_VBASE_INCOMPLETE_FILE ;\n if ( ( tmpdb = TXT_DB_read ( in , DB_NUMBER ) ) == NULL ) goto err ;\n error_code = SRP_ERR_MEMORY ;\n if ( vb -> seed_key ) {\n last_index = SRP_get_default_gN ( NULL ) -> id ;\n }\n for ( i = 0 ;\n i < sk_OPENSSL_PSTRING_num ( tmpdb -> data ) ;\n i ++ ) {\n pp = sk_OPENSSL_PSTRING_value ( tmpdb -> data , i ) ;\n if ( pp [ DB_srptype ] [ 0 ] == DB_SRP_INDEX ) {\n if ( ( gN = ( SRP_gN * ) OPENSSL_malloc ( sizeof ( SRP_gN ) ) ) == NULL ) goto err ;\n if ( ! ( gN -> id = BUF_strdup ( pp [ DB_srpid ] ) ) || ! ( gN -> N = SRP_gN_place_bn ( vb -> gN_cache , pp [ DB_srpverifier ] ) ) || ! ( gN -> g = SRP_gN_place_bn ( vb -> gN_cache , pp [ DB_srpsalt ] ) ) || sk_SRP_gN_insert ( SRP_gN_tab , gN , 0 ) == 0 ) goto err ;\n gN = NULL ;\n if ( vb -> seed_key != NULL ) {\n last_index = pp [ DB_srpid ] ;\n }\n }\n else if ( pp [ DB_srptype ] [ 0 ] == DB_SRP_VALID ) {\n SRP_gN * lgN ;\n if ( ( lgN = SRP_get_gN_by_id ( pp [ DB_srpgN ] , SRP_gN_tab ) ) != NULL ) {\n error_code = SRP_ERR_MEMORY ;\n if ( ( user_pwd = SRP_user_pwd_new ( ) ) == NULL ) goto err ;\n SRP_user_pwd_set_gN ( user_pwd , lgN -> g , lgN -> N ) ;\n if ( ! SRP_user_pwd_set_ids ( user_pwd , pp [ DB_srpid ] , pp [ DB_srpinfo ] ) ) goto err ;\n error_code = SRP_ERR_VBASE_BN_LIB ;\n if ( ! SRP_user_pwd_set_sv ( user_pwd , pp [ DB_srpsalt ] , pp [ DB_srpverifier ] ) ) goto err ;\n if ( sk_SRP_user_pwd_insert ( vb -> users_pwd , user_pwd , 0 ) == 0 ) goto err ;\n user_pwd = NULL ;\n }\n }\n }\n if ( last_index != NULL ) {\n if ( ( ( gN = SRP_get_gN_by_id ( last_index , SRP_gN_tab ) ) == NULL ) ) {\n error_code = SRP_ERR_VBASE_BN_LIB ;\n goto err ;\n }\n vb -> default_g = gN -> g ;\n vb -> default_N = gN -> N ;\n gN = NULL ;\n }\n error_code = SRP_NO_ERROR ;\n err : if ( gN != NULL ) {\n OPENSSL_free ( gN -> id ) ;\n OPENSSL_free ( gN ) ;\n }\n SRP_user_pwd_free ( user_pwd ) ;\n if ( tmpdb ) TXT_DB_free ( tmpdb ) ;\n if ( in ) BIO_free_all ( in ) ;\n sk_SRP_gN_free ( SRP_gN_tab ) ;\n return error_code ;\n }","target":0,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048} +{"idx":446548,"func":"virDomainVcpuParse(virDomainDefPtr def,\n xmlXPathContextPtr ctxt,\n virDomainXMLOptionPtr xmlopt)\n{\n int n;\n xmlNodePtr vcpuNode;\n size_t i;\n unsigned int maxvcpus;\n unsigned int vcpus;\n g_autofree char *tmp = NULL;\n g_autofree xmlNodePtr *nodes = NULL;\n\n vcpus = maxvcpus = 1;\n\n if ((vcpuNode = virXPathNode(\".\/vcpu[1]\", ctxt))) {\n if ((tmp = virXMLNodeContentString(vcpuNode))) {\n if (virStrToLong_ui(tmp, NULL, 10, &maxvcpus) < 0) {\n virReportError(VIR_ERR_XML_ERROR, \"%s\",\n _(\"maximum vcpus count must be an integer\"));\n return -1;\n }\n VIR_FREE(tmp);\n }\n\n if ((tmp = virXMLPropString(vcpuNode, \"current\"))) {\n if (virStrToLong_ui(tmp, NULL, 10, &vcpus) < 0) {\n virReportError(VIR_ERR_XML_ERROR, \"%s\",\n _(\"current vcpus count must be an integer\"));\n return -1;\n }\n VIR_FREE(tmp);\n } else {\n vcpus = maxvcpus;\n }\n\n tmp = virXMLPropString(vcpuNode, \"placement\");\n if (tmp) {\n if ((def->placement_mode =\n virDomainCpuPlacementModeTypeFromString(tmp)) < 0) {\n virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n _(\"Unsupported CPU placement mode '%s'\"),\n tmp);\n return -1;\n }\n VIR_FREE(tmp);\n } else {\n def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;\n }\n\n if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {\n tmp = virXMLPropString(vcpuNode, \"cpuset\");\n if (tmp) {\n if (virBitmapParse(tmp, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)\n return -1;\n\n if (virBitmapIsAllClear(def->cpumask)) {\n virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n _(\"Invalid value of 'cpuset': %s\"), tmp);\n return -1;\n }\n\n VIR_FREE(tmp);\n }\n }\n }\n\n if (virDomainDefSetVcpusMax(def, maxvcpus, xmlopt) < 0)\n return -1;\n\n if ((n = virXPathNodeSet(\".\/vcpus\/vcpu\", ctxt, &nodes)) < 0)\n return -1;\n\n if (n) {\n \/* if individual vcpu states are provided take them as master *\/\n def->individualvcpus = true;\n\n for (i = 0; i < n; i++) {\n virDomainVcpuDefPtr vcpu;\n int state;\n unsigned int id;\n unsigned int order;\n\n if (!(tmp = virXMLPropString(nodes[i], \"id\")) ||\n virStrToLong_uip(tmp, NULL, 10, &id) < 0) {\n virReportError(VIR_ERR_XML_ERROR, \"%s\",\n _(\"missing or invalid vcpu id\"));\n return -1;\n }\n\n VIR_FREE(tmp);\n\n if (id >= def->maxvcpus) {\n virReportError(VIR_ERR_XML_ERROR,\n _(\"vcpu id '%u' is out of range of maximum \"\n \"vcpu count\"), id);\n return -1;\n }\n\n vcpu = virDomainDefGetVcpu(def, id);\n\n if (!(tmp = virXMLPropString(nodes[i], \"enabled\"))) {\n virReportError(VIR_ERR_XML_ERROR, \"%s\",\n _(\"missing vcpu enabled state\"));\n return -1;\n }\n\n if ((state = virTristateBoolTypeFromString(tmp)) < 0) {\n virReportError(VIR_ERR_XML_ERROR,\n _(\"invalid vcpu 'enabled' value '%s'\"), tmp);\n return -1;\n }\n VIR_FREE(tmp);\n\n vcpu->online = state == VIR_TRISTATE_BOOL_YES;\n\n if ((tmp = virXMLPropString(nodes[i], \"hotpluggable\"))) {\n int hotpluggable;\n if ((hotpluggable = virTristateBoolTypeFromString(tmp)) < 0) {\n virReportError(VIR_ERR_XML_ERROR,\n _(\"invalid vcpu 'hotpluggable' value '%s'\"), tmp);\n return -1;\n }\n vcpu->hotpluggable = hotpluggable;\n VIR_FREE(tmp);\n }\n\n if ((tmp = virXMLPropString(nodes[i], \"order\"))) {\n if (virStrToLong_uip(tmp, NULL, 10, &order) < 0) {\n virReportError(VIR_ERR_XML_ERROR, \"%s\",\n _(\"invalid vcpu order\"));\n return -1;\n }\n vcpu->order = order;\n VIR_FREE(tmp);\n }\n }\n } else {\n if (virDomainDefSetVcpus(def, vcpus) < 0)\n return -1;\n }\n\n return 0;\n}","target":0,"code_token_length":1132,"total_token_length":1368,"max_tokens_setting":2048} +{"idx":63037,"func":"WriteCompressedType(mat_t *mat,matvar_t *matvar,z_streamp z)\n{\n int err;\n mat_uint32_t comp_buf[512];\n mat_uint32_t uncomp_buf[512] = {0,};\n size_t byteswritten = 0, nelems = 1;\n\n if ( MAT_C_EMPTY == matvar->class_type ) {\n \/* exit early if this is an empty data *\/\n return byteswritten;\n }\n\n err = SafeMulDims(matvar, &nelems);\n if ( err ) {\n Mat_Critical(\"Integer multiplication overflow\");\n return byteswritten;\n }\n\n switch ( matvar->class_type ) {\n case MAT_C_DOUBLE:\n case MAT_C_SINGLE:\n case MAT_C_INT64:\n case MAT_C_UINT64:\n case MAT_C_INT32:\n case MAT_C_UINT32:\n case MAT_C_INT16:\n case MAT_C_UINT16:\n case MAT_C_INT8:\n case MAT_C_UINT8:\n {\n \/* WriteCompressedData makes sure uncompressed data is aligned\n * on an 8-byte boundary *\/\n if ( matvar->isComplex ) {\n mat_complex_split_t *complex_data = (mat_complex_split_t*)matvar->data;\n\n if ( NULL == matvar->data )\n complex_data = &null_complex_data;\n\n byteswritten += WriteCompressedData(mat,z,\n complex_data->Re,nelems,matvar->data_type);\n byteswritten += WriteCompressedData(mat,z,\n complex_data->Im,nelems,matvar->data_type);\n } else {\n byteswritten += WriteCompressedData(mat,z,\n matvar->data,nelems,matvar->data_type);\n }\n break;\n }\n case MAT_C_CHAR:\n {\n byteswritten += WriteCompressedCharData(mat,z,matvar->data,\n nelems,matvar->data_type);\n break;\n }\n case MAT_C_CELL:\n {\n size_t i;\n matvar_t **cells = (matvar_t **)matvar->data;\n\n \/* Check for an empty cell array *\/\n if ( matvar->nbytes == 0 || matvar->data_size == 0 ||\n matvar->data == NULL )\n break;\n nelems = matvar->nbytes \/ matvar->data_size;\n for ( i = 0; i < nelems; i++ )\n WriteCompressedCellArrayField(mat,cells[i],z);\n break;\n }\n case MAT_C_STRUCT:\n {\n int buf_size = 512;\n mat_int16_t fieldname_type = MAT_T_INT32;\n mat_int16_t fieldname_data_size = 4;\n unsigned char *padzero;\n int fieldname_size;\n size_t maxlen = 0, nfields, i, nelems_x_nfields;\n mat_int32_t array_name_type = MAT_T_INT8;\n matvar_t **fields = (matvar_t **)matvar->data;\n\n nfields = matvar->internal->num_fields;\n \/* Check for a structure with no fields *\/\n if ( nfields < 1 ) {\n fieldname_size = 1;\n uncomp_buf[0] = (fieldname_data_size << 16) | fieldname_type;\n uncomp_buf[1] = fieldname_size;\n uncomp_buf[2] = array_name_type;\n uncomp_buf[3] = 0;\n z->next_in = ZLIB_BYTE_PTR(uncomp_buf);\n z->avail_in = 16;\n do {\n z->next_out = ZLIB_BYTE_PTR(comp_buf);\n z->avail_out = buf_size*sizeof(*comp_buf);\n deflate(z,Z_NO_FLUSH);\n byteswritten += fwrite(comp_buf,1,buf_size*\n sizeof(*comp_buf)-z->avail_out,(FILE*)mat->fp);\n } while ( z->avail_out == 0 );\n break;\n }\n\n for ( i = 0; i < nfields; i++ ) {\n size_t len = strlen(matvar->internal->fieldnames[i]);\n if ( len > maxlen )\n maxlen = len;\n }\n maxlen++;\n fieldname_size = maxlen;\n while ( nfields*fieldname_size % 8 != 0 )\n fieldname_size++;\n uncomp_buf[0] = (fieldname_data_size << 16) | fieldname_type;\n uncomp_buf[1] = fieldname_size;\n uncomp_buf[2] = array_name_type;\n uncomp_buf[3] = nfields*fieldname_size;\n\n padzero = (unsigned char*)calloc(fieldname_size,1);\n z->next_in = ZLIB_BYTE_PTR(uncomp_buf);\n z->avail_in = 16;\n do {\n z->next_out = ZLIB_BYTE_PTR(comp_buf);\n z->avail_out = buf_size*sizeof(*comp_buf);\n deflate(z,Z_NO_FLUSH);\n byteswritten += fwrite(comp_buf,1,\n buf_size*sizeof(*comp_buf)-z->avail_out,(FILE*)mat->fp);\n } while ( z->avail_out == 0 );\n for ( i = 0; i < nfields; i++ ) {\n size_t len = strlen(matvar->internal->fieldnames[i]);\n memset(padzero,'\\0',fieldname_size);\n memcpy(padzero,matvar->internal->fieldnames[i],len);\n z->next_in = ZLIB_BYTE_PTR(padzero);\n z->avail_in = fieldname_size;\n do {\n z->next_out = ZLIB_BYTE_PTR(comp_buf);\n z->avail_out = buf_size*sizeof(*comp_buf);\n deflate(z,Z_NO_FLUSH);\n byteswritten += fwrite(comp_buf,1,\n buf_size*sizeof(*comp_buf)-z->avail_out,(FILE*)mat->fp);\n } while ( z->avail_out == 0 );\n }\n free(padzero);\n err = SafeMul(&nelems_x_nfields, nelems, nfields);\n if ( err ) {\n Mat_Critical(\"Integer multiplication overflow\");\n return byteswritten;\n }\n for ( i = 0; i < nelems_x_nfields; i++ )\n byteswritten += WriteCompressedStructField(mat,fields[i],z);\n break;\n }\n case MAT_C_SPARSE:\n {\n mat_sparse_t *sparse = (mat_sparse_t*)matvar->data;\n\n byteswritten += WriteCompressedData(mat,z,sparse->ir,\n sparse->nir,MAT_T_INT32);\n byteswritten += WriteCompressedData(mat,z,sparse->jc,\n sparse->njc,MAT_T_INT32);\n if ( matvar->isComplex ) {\n mat_complex_split_t *complex_data = (mat_complex_split_t*)sparse->data;\n byteswritten += WriteCompressedData(mat,z,\n complex_data->Re,sparse->ndata,matvar->data_type);\n byteswritten += WriteCompressedData(mat,z,\n complex_data->Im,sparse->ndata,matvar->data_type);\n } else {\n byteswritten += WriteCompressedData(mat,z,\n sparse->data,sparse->ndata,matvar->data_type);\n }\n break;\n }\n case MAT_C_FUNCTION:\n case MAT_C_OBJECT:\n case MAT_C_EMPTY:\n case MAT_C_OPAQUE:\n break;\n }\n\n return byteswritten;\n}","target":0,"code_token_length":1595,"total_token_length":1831,"max_tokens_setting":2048} +{"idx":497128,"func":"static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,\n GetBitContext *gb)\n{\n int aot = ac->oc[1].m4ac.object_type;\n if (aot != AOT_ER_AAC_ELD) {\n if (get_bits1(gb)) {\n av_log(ac->avctx, AV_LOG_ERROR, \"Reserved bit set.\\n\");\n return AVERROR_INVALIDDATA;\n }\n ics->window_sequence[1] = ics->window_sequence[0];\n ics->window_sequence[0] = get_bits(gb, 2);\n if (aot == AOT_ER_AAC_LD &&\n ics->window_sequence[0] != ONLY_LONG_SEQUENCE) {\n av_log(ac->avctx, AV_LOG_ERROR,\n \"AAC LD is only defined for ONLY_LONG_SEQUENCE but \"\n \"window sequence %d found.\\n\", ics->window_sequence[0]);\n ics->window_sequence[0] = ONLY_LONG_SEQUENCE;\n return AVERROR_INVALIDDATA;\n }\n ics->use_kb_window[1] = ics->use_kb_window[0];\n ics->use_kb_window[0] = get_bits1(gb);\n }\n ics->num_window_groups = 1;\n ics->group_len[0] = 1;\n if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {\n int i;\n ics->max_sfb = get_bits(gb, 4);\n for (i = 0; i < 7; i++) {\n if (get_bits1(gb)) {\n ics->group_len[ics->num_window_groups - 1]++;\n } else {\n ics->num_window_groups++;\n ics->group_len[ics->num_window_groups - 1] = 1;\n }\n }\n ics->num_windows = 8;\n ics->swb_offset = ff_swb_offset_128[ac->oc[1].m4ac.sampling_index];\n ics->num_swb = ff_aac_num_swb_128[ac->oc[1].m4ac.sampling_index];\n ics->tns_max_bands = ff_tns_max_bands_128[ac->oc[1].m4ac.sampling_index];\n ics->predictor_present = 0;\n } else {\n ics->max_sfb = get_bits(gb, 6);\n ics->num_windows = 1;\n if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {\n ics->swb_offset = ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];\n ics->num_swb = ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];\n ics->tns_max_bands = ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index];\n if (!ics->num_swb || !ics->swb_offset)\n return AVERROR_BUG;\n } else {\n ics->swb_offset = ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];\n ics->num_swb = ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];\n ics->tns_max_bands = ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];\n }\n if (aot != AOT_ER_AAC_ELD) {\n ics->predictor_present = get_bits1(gb);\n ics->predictor_reset_group = 0;\n }\n if (ics->predictor_present) {\n if (aot == AOT_AAC_MAIN) {\n if (decode_prediction(ac, ics, gb)) {\n goto fail;\n }\n } else if (aot == AOT_AAC_LC ||\n aot == AOT_ER_AAC_LC) {\n av_log(ac->avctx, AV_LOG_ERROR,\n \"Prediction is not allowed in AAC-LC.\\n\");\n goto fail;\n } else {\n if (aot == AOT_ER_AAC_LD) {\n av_log(ac->avctx, AV_LOG_ERROR,\n \"LTP in ER AAC LD not yet implemented.\\n\");\n return AVERROR_PATCHWELCOME;\n }\n if ((ics->ltp.present = get_bits(gb, 1)))\n decode_ltp(&ics->ltp, gb, ics->max_sfb);\n }\n }\n }\n\n if (ics->max_sfb > ics->num_swb) {\n av_log(ac->avctx, AV_LOG_ERROR,\n \"Number of scalefactor bands in group (%d) \"\n \"exceeds limit (%d).\\n\",\n ics->max_sfb, ics->num_swb);\n goto fail;\n }\n\n return 0;\nfail:\n ics->max_sfb = 0;\n return AVERROR_INVALIDDATA;\n}","target":0,"code_token_length":1162,"total_token_length":1398,"max_tokens_setting":2048} +{"idx":117013,"func":"void CLASS phase_one_load_raw_c()\n{\n static const int length[] = {8, 7, 6, 9, 11, 10, 5, 12, 14, 13};\n int *offset, len[2], pred[2], row, col, i, j;\n ushort *pixel;\n short(*c_black)[2], (*r_black)[2];\n#ifdef LIBRAW_LIBRARY_BUILD\n if (ph1.format == 6)\n throw LIBRAW_EXCEPTION_IO_CORRUPT;\n#endif\n\n pixel = (ushort *)calloc(raw_width * 3 + raw_height * 4, 2);\n merror(pixel, \"phase_one_load_raw_c()\");\n offset = (int *)(pixel + raw_width);\n fseek(ifp, strip_offset, SEEK_SET);\n for (row = 0; row < raw_height; row++)\n offset[row] = get4();\n c_black = (short(*)[2])(offset + raw_height);\n fseek(ifp, ph1.black_col, SEEK_SET);\n if (ph1.black_col)\n read_shorts((ushort *)c_black[0], raw_height * 2);\n r_black = c_black + raw_height;\n fseek(ifp, ph1.black_row, SEEK_SET);\n if (ph1.black_row)\n read_shorts((ushort *)r_black[0], raw_width * 2);\n\n#ifdef LIBRAW_LIBRARY_BUILD\n \/\/ Copy data to internal copy (ever if not read)\n if (ph1.black_col || ph1.black_row)\n {\n imgdata.rawdata.ph1_cblack = (short(*)[2])calloc(raw_height * 2, sizeof(ushort));\n merror(imgdata.rawdata.ph1_cblack, \"phase_one_load_raw_c()\");\n memmove(imgdata.rawdata.ph1_cblack, (ushort *)c_black[0], raw_height * 2 * sizeof(ushort));\n imgdata.rawdata.ph1_rblack = (short(*)[2])calloc(raw_width * 2, sizeof(ushort));\n merror(imgdata.rawdata.ph1_rblack, \"phase_one_load_raw_c()\");\n memmove(imgdata.rawdata.ph1_rblack, (ushort *)r_black[0], raw_width * 2 * sizeof(ushort));\n }\n#endif\n\n for (i = 0; i < 256; i++)\n curve[i] = i * i \/ 3.969 + 0.5;\n#ifdef LIBRAW_LIBRARY_BUILD\n try\n {\n#endif\n for (row = 0; row < raw_height; row++)\n {\n#ifdef LIBRAW_LIBRARY_BUILD\n checkCancel();\n#endif\n fseek(ifp, data_offset + offset[row], SEEK_SET);\n ph1_bits(-1);\n pred[0] = pred[1] = 0;\n for (col = 0; col < raw_width; col++)\n {\n if (col >= (raw_width & -8))\n len[0] = len[1] = 14;\n else if ((col & 7) == 0)\n for (i = 0; i < 2; i++)\n {\n for (j = 0; j < 5 && !ph1_bits(1); j++)\n ;\n if (j--)\n len[i] = length[j * 2 + ph1_bits(1)];\n }\n if ((i = len[col & 1]) == 14)\n pixel[col] = pred[col & 1] = ph1_bits(16);\n else\n pixel[col] = pred[col & 1] += ph1_bits(i) + 1 - (1 << (i - 1));\n if (pred[col & 1] >> 16)\n derror();\n if (ph1.format == 5 && pixel[col] < 256)\n pixel[col] = curve[pixel[col]];\n }\n#ifndef LIBRAW_LIBRARY_BUILD\n for (col = 0; col < raw_width; col++)\n {\n int shift = ph1.format == 8 ? 0 : 2;\n i = (pixel[col] << shift) - ph1.t_black + c_black[row][col >= ph1.split_col] +\n r_black[col][row >= ph1.split_row];\n if (i > 0)\n RAW(row, col) = i;\n }\n#else\n if (ph1.format == 8)\n memmove(&RAW(row, 0), &pixel[0], raw_width * 2);\n else\n for (col = 0; col < raw_width; col++)\n RAW(row, col) = pixel[col] << 2;\n#endif\n }\n#ifdef LIBRAW_LIBRARY_BUILD\n }\n catch (...)\n {\n free(pixel);\n throw;\n }\n#endif\n free(pixel);\n maximum = 0xfffc - ph1.t_black;\n}","target":0,"code_token_length":1056,"total_token_length":1292,"max_tokens_setting":2048} +{"idx":8020,"func":"static int xar_get_toc_data_values(xmlTextReaderPtr reader, long *length, long *offset, long *size, int *encoding,\n unsigned char ** a_cksum, int * a_hash, unsigned char ** e_cksum, int * e_hash)\n{\n const xmlChar *name;\n int indata = 0, inea = 0;\n int rc, gotoffset=0, gotlength=0, gotsize=0;\n\n *a_cksum = NULL;\n *a_hash = XAR_CKSUM_NONE;\n *e_cksum = NULL;\n *e_hash = XAR_CKSUM_NONE;\n *encoding = CL_TYPE_ANY;\n\n rc = xmlTextReaderRead(reader);\n while (rc == 1) {\n name = xmlTextReaderConstLocalName(reader);\n if (indata || inea) {\n \/* cli_dbgmsg(\"cli_scanxar: xmlTextReaderRead read %s\\n\", name); *\/\n if (xmlStrEqual(name, (const xmlChar *)\"offset\") && \n xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n if (CL_SUCCESS == xar_get_numeric_from_xml_element(reader, offset))\n gotoffset=1;\n\n } else if (xmlStrEqual(name, (const xmlChar *)\"length\") &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n if (CL_SUCCESS == xar_get_numeric_from_xml_element(reader, length))\n gotlength=1;\n\n } else if (xmlStrEqual(name, (const xmlChar *)\"size\") &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n if (CL_SUCCESS == xar_get_numeric_from_xml_element(reader, size))\n gotsize=1;\n\n } else if (xmlStrEqual(name, (const xmlChar *)\"archived-checksum\") &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n cli_dbgmsg(\"cli_scanxar: :\\n\");\n xar_get_checksum_values(reader, a_cksum, a_hash);\n \n } else if ((xmlStrEqual(name, (const xmlChar *)\"extracted-checksum\") ||\n xmlStrEqual(name, (const xmlChar *)\"unarchived-checksum\")) &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n cli_dbgmsg(\"cli_scanxar: :\\n\");\n xar_get_checksum_values(reader, e_cksum, e_hash);\n\n } else if (xmlStrEqual(name, (const xmlChar *)\"encoding\") &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n xmlChar * style = xmlTextReaderGetAttribute(reader, (const xmlChar *)\"style\");\n if (style == NULL) {\n cli_dbgmsg(\"cli_scaxar: xmlTextReaderGetAttribute no style attribute \"\n \"for encoding element\\n\");\n *encoding = CL_TYPE_ANY;\n } else if (xmlStrEqual(style, (const xmlChar *)\"application\/x-gzip\")) {\n cli_dbgmsg(\"cli_scanxar: encoding = application\/x-gzip.\\n\");\n *encoding = CL_TYPE_GZ; \n } else if (xmlStrEqual(style, (const xmlChar *)\"application\/octet-stream\")) {\n cli_dbgmsg(\"cli_scanxar: encoding = application\/octet-stream.\\n\");\n *encoding = CL_TYPE_ANY; \n } else if (xmlStrEqual(style, (const xmlChar *)\"application\/x-bzip2\")) {\n cli_dbgmsg(\"cli_scanxar: encoding = application\/x-bzip2.\\n\");\n *encoding = CL_TYPE_BZ;\n } else if (xmlStrEqual(style, (const xmlChar *)\"application\/x-lzma\")) {\n cli_dbgmsg(\"cli_scanxar: encoding = application\/x-lzma.\\n\");\n *encoding = CL_TYPE_7Z;\n } else if (xmlStrEqual(style, (const xmlChar *)\"application\/x-xz\")) {\n cli_dbgmsg(\"cli_scanxar: encoding = application\/x-xz.\\n\");\n *encoding = CL_TYPE_XZ;\n } else {\n cli_dbgmsg(\"cli_scaxar: unknown style value=%s for encoding element\\n\", style);\n *encoding = CL_TYPE_ANY;\n }\n if (style != NULL)\n xmlFree(style);\n\n } else if (indata && xmlStrEqual(name, (const xmlChar *)\"data\") &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {\n break;\n\n } else if (inea && xmlStrEqual(name, (const xmlChar *)\"ea\") &&\n xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {\n break;\n }\n \n } else {\n if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {\n if (xmlStrEqual(name, (const xmlChar *)\"data\")) {\n cli_dbgmsg(\"cli_scanxar: xmlTextReaderRead read \\n\");\n indata = 1;\n } else if (xmlStrEqual(name, (const xmlChar *)\"ea\")) {\n cli_dbgmsg(\"cli_scanxar: xmlTextReaderRead read \\n\");\n inea = 1;\n }\n } else if ((xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) &&\n xmlStrEqual(name, (const xmlChar *)\"xar\")) {\n cli_dbgmsg(\"cli_scanxar: finished parsing xar TOC.\\n\"); \n break;\n }\n }\n rc = xmlTextReaderRead(reader);\n }\n \n if (gotoffset && gotlength && gotsize) {\n rc = CL_SUCCESS;\n }\n else if (0 == gotoffset + gotlength + gotsize)\n rc = CL_BREAK;\n else\n rc = CL_EFORMAT;\n\n return rc;\n}","target":1,"code_token_length":1250,"total_token_length":1486,"max_tokens_setting":2048} +{"idx":162455,"func":"void WebGLRenderingContextBase::TexImageHelperHTMLVideoElement(\n const SecurityOrigin* security_origin,\n TexImageFunctionID function_id,\n GLenum target,\n GLint level,\n GLint internalformat,\n GLenum format,\n GLenum type,\n GLint xoffset,\n GLint yoffset,\n GLint zoffset,\n HTMLVideoElement* video,\n const IntRect& source_image_rect,\n GLsizei depth,\n GLint unpack_image_height,\n ExceptionState& exception_state) {\n const char* func_name = GetTexImageFunctionName(function_id);\n if (isContextLost())\n return;\n\n if (!ValidateHTMLVideoElement(security_origin, func_name, video,\n exception_state))\n return;\n WebGLTexture* texture =\n ValidateTexImageBinding(func_name, function_id, target);\n if (!texture)\n return;\n TexImageFunctionType function_type;\n if (function_id == kTexImage2D || function_id == kTexImage3D)\n function_type = kTexImage;\n else\n function_type = kTexSubImage;\n if (!ValidateTexFunc(func_name, function_type, kSourceHTMLVideoElement,\n target, level, internalformat, video->videoWidth(),\n video->videoHeight(), 1, 0, format, type, xoffset,\n yoffset, zoffset))\n return;\n\n WebMediaPlayer::VideoFrameUploadMetadata frame_metadata = {};\n int already_uploaded_id = -1;\n WebMediaPlayer::VideoFrameUploadMetadata* frame_metadata_ptr = nullptr;\n if (RuntimeEnabledFeatures::ExperimentalCanvasFeaturesEnabled()) {\n already_uploaded_id = texture->GetLastUploadedVideoFrameId();\n frame_metadata_ptr = &frame_metadata;\n }\n \n if (!source_image_rect.IsValid()) {\n SynthesizeGLError(GL_INVALID_OPERATION, func_name,\n \"source sub-rectangle specified via pixel unpack \"\n \"parameters is invalid\");\n return;\n }\n bool source_image_rect_is_default =\n source_image_rect == SentinelEmptyRect() ||\n source_image_rect ==\n IntRect(0, 0, video->videoWidth(), video->videoHeight());\n const bool use_copyTextureCHROMIUM = function_id == kTexImage2D &&\n source_image_rect_is_default &&\n depth == 1 && GL_TEXTURE_2D == target &&\n CanUseTexImageByGPU(format, type);\n if (use_copyTextureCHROMIUM) {\n DCHECK_EQ(xoffset, 0);\n DCHECK_EQ(yoffset, 0);\n DCHECK_EQ(zoffset, 0);\n\n if (video->CopyVideoTextureToPlatformTexture(\n ContextGL(), target, texture->Object(), internalformat, format,\n type, level, unpack_premultiply_alpha_, unpack_flip_y_,\n already_uploaded_id, frame_metadata_ptr)) {\n texture->UpdateLastUploadedFrame(frame_metadata);\n return;\n }\n }\n\n if (source_image_rect_is_default) {\n ScopedUnpackParametersResetRestore(\n this, unpack_flip_y_ || unpack_premultiply_alpha_);\n if (video->TexImageImpl(\n static_cast(function_id),\n target, ContextGL(), texture->Object(), level,\n ConvertTexInternalFormat(internalformat, type), format, type,\n xoffset, yoffset, zoffset, unpack_flip_y_,\n unpack_premultiply_alpha_ &&\n unpack_colorspace_conversion_ == GL_NONE)) {\n texture->ClearLastUploadedFrame();\n return;\n }\n }\n\n if (use_copyTextureCHROMIUM) {\n std::unique_ptr surface =\n WTF::WrapUnique(new AcceleratedImageBufferSurface(\n IntSize(video->videoWidth(), video->videoHeight())));\n if (surface->IsValid()) {\n std::unique_ptr image_buffer(\n ImageBuffer::Create(std::move(surface)));\n if (image_buffer) {\n video->PaintCurrentFrame(\n image_buffer->Canvas(),\n IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr,\n already_uploaded_id, frame_metadata_ptr);\n\n\n TexImage2DBase(target, level, internalformat, video->videoWidth(),\n video->videoHeight(), 0, format, type, nullptr);\n\n if (image_buffer->CopyToPlatformTexture(\n FunctionIDToSnapshotReason(function_id), ContextGL(), target,\n texture->Object(), unpack_premultiply_alpha_, unpack_flip_y_,\n IntPoint(0, 0),\n IntRect(0, 0, video->videoWidth(), video->videoHeight()))) {\n texture->UpdateLastUploadedFrame(frame_metadata);\n return;\n }\n }\n }\n }\n\n scoped_refptr image =\n VideoFrameToImage(video, already_uploaded_id, frame_metadata_ptr);\n if (!image)\n return;\n TexImageImpl(function_id, target, level, internalformat, xoffset, yoffset,\n zoffset, format, type, image.get(),\n WebGLImageConversion::kHtmlDomVideo, unpack_flip_y_,\n unpack_premultiply_alpha_, source_image_rect, depth,\n unpack_image_height);\n texture->UpdateLastUploadedFrame(frame_metadata);\n}\n","target":0,"code_token_length":1076,"total_token_length":1312,"max_tokens_setting":2048} +{"idx":109276,"func":"static int ext2_remount (struct super_block * sb, int * flags, char * data)\n{\n\tstruct ext2_sb_info * sbi = EXT2_SB(sb);\n\tstruct ext2_super_block * es;\n\tstruct ext2_mount_options old_opts;\n\tunsigned long old_sb_flags;\n\tint err;\n\n\tsync_filesystem(sb);\n\tspin_lock(&sbi->s_lock);\n\n\t\/* Store the old options *\/\n\told_sb_flags = sb->s_flags;\n\told_opts.s_mount_opt = sbi->s_mount_opt;\n\told_opts.s_resuid = sbi->s_resuid;\n\told_opts.s_resgid = sbi->s_resgid;\n\n\t\/*\n\t * Allow the \"check\" option to be passed as a remount option.\n\t *\/\n\tif (!parse_options(data, sb)) {\n\t\terr = -EINVAL;\n\t\tgoto restore_opts;\n\t}\n\n\tsb->s_flags = (sb->s_flags & ~MS_POSIXACL) |\n\t\t((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);\n\n\tes = sbi->s_es;\n\tif ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT2_MOUNT_DAX) {\n\t\text2_msg(sb, KERN_WARNING, \"warning: refusing change of \"\n\t\t\t \"dax flag with busy inodes while remounting\");\n\t\tsbi->s_mount_opt ^= EXT2_MOUNT_DAX;\n\t}\n\tif ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {\n\t\tspin_unlock(&sbi->s_lock);\n\t\treturn 0;\n\t}\n\tif (*flags & MS_RDONLY) {\n\t\tif (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||\n\t\t !(sbi->s_mount_state & EXT2_VALID_FS)) {\n\t\t\tspin_unlock(&sbi->s_lock);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/*\n\t\t * OK, we are remounting a valid rw partition rdonly, so set\n\t\t * the rdonly flag and then mark the partition as valid again.\n\t\t *\/\n\t\tes->s_state = cpu_to_le16(sbi->s_mount_state);\n\t\tes->s_mtime = cpu_to_le32(get_seconds());\n\t\tspin_unlock(&sbi->s_lock);\n\n\t\terr = dquot_suspend(sb, -1);\n\t\tif (err < 0) {\n\t\t\tspin_lock(&sbi->s_lock);\n\t\t\tgoto restore_opts;\n\t\t}\n\n\t\text2_sync_super(sb, es, 1);\n\t} else {\n\t\t__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,\n\t\t\t\t\t ~EXT2_FEATURE_RO_COMPAT_SUPP);\n\t\tif (ret) {\n\t\t\text2_msg(sb, KERN_WARNING,\n\t\t\t\t\"warning: couldn't remount RDWR because of \"\n\t\t\t\t\"unsupported optional features (%x).\",\n\t\t\t\tle32_to_cpu(ret));\n\t\t\terr = -EROFS;\n\t\t\tgoto restore_opts;\n\t\t}\n\t\t\/*\n\t\t * Mounting a RDONLY partition read-write, so reread and\n\t\t * store the current valid flag. (It may have been changed\n\t\t * by e2fsck since we originally mounted the partition.)\n\t\t *\/\n\t\tsbi->s_mount_state = le16_to_cpu(es->s_state);\n\t\tif (!ext2_setup_super (sb, es, 0))\n\t\t\tsb->s_flags &= ~MS_RDONLY;\n\t\tspin_unlock(&sbi->s_lock);\n\n\t\text2_write_super(sb);\n\n\t\tdquot_resume(sb, -1);\n\t}\n\n\treturn 0;\nrestore_opts:\n\tsbi->s_mount_opt = old_opts.s_mount_opt;\n\tsbi->s_resuid = old_opts.s_resuid;\n\tsbi->s_resgid = old_opts.s_resgid;\n\tsb->s_flags = old_sb_flags;\n\tspin_unlock(&sbi->s_lock);\n\treturn err;\n}","target":0,"code_token_length":807,"total_token_length":1043,"max_tokens_setting":2048} +{"idx":378387,"func":"static void sdap_get_initgr_done(struct tevent_req *subreq)\n{\n struct tevent_req *req = tevent_req_callback_data(subreq,\n struct tevent_req);\n struct sdap_get_initgr_state *state = tevent_req_data(req,\n struct sdap_get_initgr_state);\n int ret;\n TALLOC_CTX *tmp_ctx;\n gid_t primary_gid;\n char *gid;\n char *sid_str;\n char *dom_sid_str;\n char *group_sid_str;\n struct sdap_options *opts = state->opts;\n\n DEBUG(SSSDBG_TRACE_ALL, \"Initgroups done\\n\");\n\n tmp_ctx = talloc_new(NULL);\n if (!tmp_ctx) {\n tevent_req_error(req, ENOMEM);\n return;\n }\n\n switch (state->opts->schema_type) {\n case SDAP_SCHEMA_RFC2307:\n ret = sdap_initgr_rfc2307_recv(subreq);\n break;\n\n case SDAP_SCHEMA_RFC2307BIS:\n case SDAP_SCHEMA_AD:\n if (state->opts->dc_functional_level >= DS_BEHAVIOR_WIN2003\n && dp_opt_get_bool(state->opts->basic, SDAP_AD_USE_TOKENGROUPS)) {\n\n ret = sdap_ad_tokengroups_initgroups_recv(subreq);\n }\n else if (state->opts->support_matching_rule\n && dp_opt_get_bool(state->opts->basic,\n SDAP_AD_MATCHING_RULE_INITGROUPS)) {\n ret = sdap_get_ad_match_rule_initgroups_recv(subreq);\n } else {\n ret = sdap_initgr_rfc2307bis_recv(subreq);\n }\n break;\n\n case SDAP_SCHEMA_IPA_V1:\n ret = sdap_initgr_nested_recv(subreq);\n break;\n\n default:\n\n ret = EINVAL;\n break;\n }\n\n talloc_zfree(subreq);\n if (ret) {\n DEBUG(SSSDBG_TRACE_ALL, \"Error in initgroups: [%d][%s]\\n\",\n ret, strerror(ret));\n goto fail;\n }\n\n \/* We also need to update the user's primary group, since\n * the user may not be an explicit member of that group\n *\/\n\n if (state->use_id_mapping) {\n DEBUG(SSSDBG_TRACE_LIBS,\n \"Mapping primary group to unix ID\\n\");\n\n \/* The primary group ID is just the RID part of the objectSID\n * of the group. Generate the GID by adding this to the domain\n * SID value.\n *\/\n\n \/* Get the user SID so we can extract the domain SID\n * from it.\n *\/\n ret = sdap_attrs_get_sid_str(\n tmp_ctx, opts->idmap_ctx, state->orig_user,\n opts->user_map[SDAP_AT_USER_OBJECTSID].sys_name,\n &sid_str);\n if (ret != EOK) goto fail;\n\n \/* Get the domain SID from the user SID *\/\n ret = sdap_idmap_get_dom_sid_from_object(tmp_ctx, sid_str,\n &dom_sid_str);\n if (ret != EOK) {\n DEBUG(SSSDBG_MINOR_FAILURE,\n \"Could not parse domain SID from [%s]\\n\", sid_str);\n goto fail;\n }\n\n ret = sysdb_attrs_get_uint32_t(\n state->orig_user,\n opts->user_map[SDAP_AT_USER_PRIMARY_GROUP].sys_name,\n &primary_gid);\n if (ret != EOK) {\n DEBUG(SSSDBG_MINOR_FAILURE,\n \"no primary group ID provided\\n\");\n ret = EINVAL;\n goto fail;\n }\n\n \/* Add the RID to the end *\/\n group_sid_str = talloc_asprintf(tmp_ctx, \"%s-%lu\",\n dom_sid_str,\n (unsigned long)primary_gid);\n if (!group_sid_str) {\n ret = ENOMEM;\n goto fail;\n }\n\n \/* Convert the SID into a UNIX group ID *\/\n ret = sdap_idmap_sid_to_unix(opts->idmap_ctx, group_sid_str,\n &primary_gid);\n if (ret != EOK) goto fail;\n } else {\n ret = sysdb_attrs_get_uint32_t(state->orig_user, SYSDB_GIDNUM,\n &primary_gid);\n if (ret != EOK) {\n DEBUG(SSSDBG_TRACE_FUNC, \"Could not find user's primary GID\\n\");\n goto fail;\n }\n }\n\n gid = talloc_asprintf(state, \"%lu\", (unsigned long)primary_gid);\n if (gid == NULL) {\n ret = ENOMEM;\n goto fail;\n }\n\n subreq = groups_get_send(req, state->ev, state->id_ctx,\n state->id_ctx->opts->sdom, state->conn,\n gid, BE_FILTER_IDNUM, BE_ATTR_ALL, NULL);\n if (!subreq) {\n ret = ENOMEM;\n goto fail;\n }\n tevent_req_set_callback(subreq, sdap_get_initgr_pgid, req);\n\n talloc_free(tmp_ctx);\n return;\n\nfail:\n talloc_free(tmp_ctx);\n tevent_req_error(req, ret);\n return;\n}","target":0,"code_token_length":1110,"total_token_length":1346,"max_tokens_setting":2048} +{"idx":509694,"func":"static void test_store_result()\n{\n MYSQL_STMT *stmt;\n int rc;\n int32 nData;\n char szData[100];\n MYSQL_BIND my_bind[2];\n ulong length, length1;\n my_bool is_null[2];\n\n myheader(\"test_store_result\");\n\n rc= mysql_query(mysql, \"DROP TABLE IF EXISTS test_store_result\");\n myquery(rc);\n\n rc= mysql_query(mysql, \"CREATE TABLE test_store_result(col1 int , col2 varchar(50))\");\n myquery(rc);\n\n rc= mysql_query(mysql, \"INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')\");\n myquery(rc);\n\n rc= mysql_query(mysql, \"INSERT INTO test_store_result(col2) VALUES('monty')\");\n myquery(rc);\n\n rc= mysql_commit(mysql);\n myquery(rc);\n\n \/* fetch *\/\n bzero((char*) my_bind, sizeof(my_bind));\n my_bind[0].buffer_type= MYSQL_TYPE_LONG;\n my_bind[0].buffer= (void *) &nData; \/* integer data *\/\n my_bind[0].length= &length;\n my_bind[0].is_null= &is_null[0];\n\n length= 0;\n my_bind[1].buffer_type= MYSQL_TYPE_STRING;\n my_bind[1].buffer= szData; \/* string data *\/\n my_bind[1].buffer_length= sizeof(szData);\n my_bind[1].length= &length1;\n my_bind[1].is_null= &is_null[1];\n length1= 0;\n\n stmt= mysql_simple_prepare(mysql, \"SELECT * FROM test_store_result\");\n check_stmt(stmt);\n\n rc= mysql_stmt_bind_result(stmt, my_bind);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_execute(stmt);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_store_result(stmt);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent)\n fprintf(stdout, \"\\n row 1: %ld, %s(%lu)\", (long) nData, szData, length1);\n DIE_UNLESS(nData == 10);\n DIE_UNLESS(strcmp(szData, \"venu\") == 0);\n DIE_UNLESS(length1 == 4);\n\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent)\n fprintf(stdout, \"\\n row 2: %ld, %s(%lu)\", (long) nData, szData, length1);\n DIE_UNLESS(nData == 20);\n DIE_UNLESS(strcmp(szData, \"mysql\") == 0);\n DIE_UNLESS(length1 == 5);\n\n length= 99;\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent && is_null[0])\n fprintf(stdout, \"\\n row 3: NULL, %s(%lu)\", szData, length1);\n DIE_UNLESS(is_null[0]);\n DIE_UNLESS(strcmp(szData, \"monty\") == 0);\n DIE_UNLESS(length1 == 5);\n\n rc= mysql_stmt_fetch(stmt);\n DIE_UNLESS(rc == MYSQL_NO_DATA);\n\n rc= mysql_stmt_execute(stmt);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_store_result(stmt);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent)\n fprintf(stdout, \"\\n row 1: %ld, %s(%lu)\", (long) nData, szData, length1);\n DIE_UNLESS(nData == 10);\n DIE_UNLESS(strcmp(szData, \"venu\") == 0);\n DIE_UNLESS(length1 == 4);\n\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent)\n fprintf(stdout, \"\\n row 2: %ld, %s(%lu)\", (long) nData, szData, length1);\n DIE_UNLESS(nData == 20);\n DIE_UNLESS(strcmp(szData, \"mysql\") == 0);\n DIE_UNLESS(length1 == 5);\n\n length= 99;\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent && is_null[0])\n fprintf(stdout, \"\\n row 3: NULL, %s(%lu)\", szData, length1);\n DIE_UNLESS(is_null[0]);\n DIE_UNLESS(strcmp(szData, \"monty\") == 0);\n DIE_UNLESS(length1 == 5);\n\n rc= mysql_stmt_fetch(stmt);\n DIE_UNLESS(rc == MYSQL_NO_DATA);\n\n mysql_stmt_close(stmt);\n}","target":0,"code_token_length":1033,"total_token_length":1269,"max_tokens_setting":2048} +{"idx":119337,"func":"static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)\n{\n\tstruct bpf_insn *insn = env->prog->insnsi;\n\tint insn_cnt = env->prog->len;\n\tint i, j, err;\n\n\terr = bpf_prog_calc_tag(env->prog);\n\tif (err)\n\t\treturn err;\n\n\tfor (i = 0; i < insn_cnt; i++, insn++) {\n\t\tif (BPF_CLASS(insn->code) == BPF_LDX &&\n\t\t (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) {\n\t\t\tverbose(\"BPF_LDX uses reserved fields\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (BPF_CLASS(insn->code) == BPF_STX &&\n\t\t ((BPF_MODE(insn->code) != BPF_MEM &&\n\t\t BPF_MODE(insn->code) != BPF_XADD) || insn->imm != 0)) {\n\t\t\tverbose(\"BPF_STX uses reserved fields\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {\n\t\t\tstruct bpf_map *map;\n\t\t\tstruct fd f;\n\n\t\t\tif (i == insn_cnt - 1 || insn[1].code != 0 ||\n\t\t\t insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||\n\t\t\t insn[1].off != 0) {\n\t\t\t\tverbose(\"invalid bpf_ld_imm64 insn\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\tif (insn->src_reg == 0)\n\t\t\t\t\/* valid generic load 64-bit imm *\/\n\t\t\t\tgoto next_insn;\n\n\t\t\tif (insn->src_reg != BPF_PSEUDO_MAP_FD) {\n\t\t\t\tverbose(\"unrecognized bpf_ld_imm64 insn\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\tf = fdget(insn->imm);\n\t\t\tmap = __bpf_map_get(f);\n\t\t\tif (IS_ERR(map)) {\n\t\t\t\tverbose(\"fd %d is not pointing to valid bpf_map\\n\",\n\t\t\t\t\tinsn->imm);\n\t\t\t\treturn PTR_ERR(map);\n\t\t\t}\n\n\t\t\terr = check_map_prog_compatibility(map, env->prog);\n\t\t\tif (err) {\n\t\t\t\tfdput(f);\n\t\t\t\treturn err;\n\t\t\t}\n\n\t\t\t\/* store map pointer inside BPF_LD_IMM64 instruction *\/\n\t\t\tinsn[0].imm = (u32) (unsigned long) map;\n\t\t\tinsn[1].imm = ((u64) (unsigned long) map) >> 32;\n\n\t\t\t\/* check whether we recorded this map already *\/\n\t\t\tfor (j = 0; j < env->used_map_cnt; j++)\n\t\t\t\tif (env->used_maps[j] == map) {\n\t\t\t\t\tfdput(f);\n\t\t\t\t\tgoto next_insn;\n\t\t\t\t}\n\n\t\t\tif (env->used_map_cnt >= MAX_USED_MAPS) {\n\t\t\t\tfdput(f);\n\t\t\t\treturn -E2BIG;\n\t\t\t}\n\n\t\t\t\/* hold the map. If the program is rejected by verifier,\n\t\t\t * the map will be released by release_maps() or it\n\t\t\t * will be used by the valid program until it's unloaded\n\t\t\t * and all maps are released in free_bpf_prog_info()\n\t\t\t *\/\n\t\t\tmap = bpf_map_inc(map, false);\n\t\t\tif (IS_ERR(map)) {\n\t\t\t\tfdput(f);\n\t\t\t\treturn PTR_ERR(map);\n\t\t\t}\n\t\t\tenv->used_maps[env->used_map_cnt++] = map;\n\n\t\t\tfdput(f);\nnext_insn:\n\t\t\tinsn++;\n\t\t\ti++;\n\t\t}\n\t}\n\n\t\/* now all pseudo BPF_LD_IMM64 instructions load valid\n\t * 'struct bpf_map *' into a register instead of user map_fd.\n\t * These pointers will be used later by verifier to validate map access.\n\t *\/\n\treturn 0;\n}","target":0,"code_token_length":820,"total_token_length":1056,"max_tokens_setting":2048} +{"idx":18315,"func":"static ossl_inline t2 * sk_ ## t1 ## _shift ( STACK_OF ( t1 ) * sk ) {\n return ( t2 * ) OPENSSL_sk_shift ( ( OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) {\n OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ;\n }\n static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) {\n return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ;\n }\n static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) {\n return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ;\n }\n static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) {\n return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;\n }\n static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) {\n return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;\n }\n static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) {\n OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) {\n return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) {\n return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) {\n return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ;\n }\n static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) {\n return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ;\n }\n # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ;\n typedef const char * OPENSSL_CSTRING ;\n DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char )","target":0,"code_token_length":790,"total_token_length":1026,"max_tokens_setting":2048} +{"idx":292726,"func":"Variant HHVM_FUNCTION(imageloadfont, const String& \/*file*\/) {\n \/\/ TODO: ind = 5 + zend_list_insert(font, le_gd_font);\n throw_not_supported(__func__, \"NYI\");\n#ifdef NEVER\n Variant stream;\n zval **file;\n int hdr_size = sizeof(gdFont) - sizeof(char *);\n int ind, body_size, n = 0, b, i, body_size_check;\n gdFontPtr font;\n php_stream *stream;\n\n\n stream = File::Open(file, \"rb\");\n if (!stream) {\n raise_warning(\"failed to open file: %s\", file.c_str());\n return false;\n }\n\n \/* Only supports a architecture-dependent binary dump format\n * at the moment.\n * The file format is like this on machines with 32-byte integers:\n *\n * byte 0-3: (int) number of characters in the font\n * byte 4-7: (int) value of first character in the font (often 32, space)\n * byte 8-11: (int) pixel width of each character\n * byte 12-15: (int) pixel height of each character\n * bytes 16-: (char) array with character data, one byte per pixel\n * in each character, for a total of\n * (nchars*width*height) bytes.\n *\/\n font = (gdFontPtr) IM_MALLOC(sizeof(gdFont));\n CHECK_ALLOC_R(font, sizeof(gdFont), false);\n b = 0;\n String hdr = stream->read(hdr_size);\n if (hdr.length() < hdr_size) {\n IM_FREE(font);\n if (stream->eof()) {\n raise_warning(\"End of file while reading header\");\n } else {\n raise_warning(\"Error while reading header\");\n }\n stream->close();\n return false;\n }\n memcpy((void*)font, hdr.c_str(), hdr.length());\n i = int64_t(f_tell(stream));\n stream->seek(0, SEEK_END);\n body_size_check = int64_t(f_tell(stream)) - hdr_size;\n stream->seek(i, SEEK_SET);\n\n body_size = font->w * font->h * font->nchars;\n if (body_size != body_size_check) {\n font->w = FLIPWORD(font->w);\n font->h = FLIPWORD(font->h);\n font->nchars = FLIPWORD(font->nchars);\n body_size = font->w * font->h * font->nchars;\n }\n\n if (font->nchars <= 0 ||\n font->h <= 0 ||\n font->nchars >= INT_MAX || font->h >= INT_MAX) {\n raise_warning(\"Error reading font, invalid font header\");\n IM_FREE(font);\n stream->close();\n return false;\n }\n\n if ((font->nchars * font->h) <= 0 ||\n font->w <= 0 ||\n (font->nchars * font->h) >= INT_MAX || font->w >= INT_MAX) {\n raise_warning(\"Error reading font, invalid font header\");\n IM_FREE(font);\n stream->close();\n return false;\n }\n\n if (body_size != body_size_check) {\n raise_warning(\"Error reading font\");\n IM_FREE(font);\n stream->close();\n return false;\n }\n\n String body = stream->read(body_size);\n if (body.length() < body_size) {\n IM_FREE(font);\n if (stream->eof()) {\n raise_warning(\"End of file while reading body\");\n } else {\n raise_warning(\"Error while reading body\");\n }\n stream->close();\n return false;\n }\n font->data = IM_MALLOC(body_size);\n CHECK_ALLOC_R(font->data, body_size, false);\n memcpy((void*)font->data, body.c_str(), body.length());\n stream->close();\n\n \/* Adding 5 to the font index so we will never have font indices\n * that overlap with the old fonts (with indices 1-5). The first\n * list index given out is always 1.\n *\/\n \/\/ ind = 5 + zend_list_insert(font, le_gd_font);\n\n return ind;\n#endif\n}","target":0,"code_token_length":928,"total_token_length":1164,"max_tokens_setting":2048} +{"idx":7875,"func":"static char *create_output_name(unsigned char *fname, unsigned char *dir,\n\t\t\t int lower, int isunix, int utf8)\n{\n unsigned char *p, *name, c, *fe, sep, slash;\n unsigned int x;\n\n sep = (isunix) ? '\/' : '\\\\'; \/* the path-seperator *\/\n slash = (isunix) ? '\\\\' : '\/'; \/* the other slash *\/\n\n \/* length of filename *\/\n x = strlen((char *) fname);\n \/* UTF8 worst case scenario: tolower() expands all chars from 1 to 3 bytes *\/\n if (utf8) x *= 3;\n \/* length of output directory *\/\n if (dir) x += strlen((char *) dir);\n\n if (!(name = (unsigned char *) malloc(x + 2))) {\n fprintf(stderr, \"out of memory!\\n\");\n return NULL;\n }\n \n \/* start with blank name *\/\n *name = '\\0';\n\n \/* add output directory if needed *\/\n if (dir) {\n strcpy((char *) name, (char *) dir);\n strcat((char *) name, \"\/\");\n }\n\n \/* remove leading slashes *\/\n while (*fname == sep) fname++;\n\n \/* copy from fi->filename to new name, converting MS-DOS slashes to UNIX\n * slashes as we go. Also lowercases characters if needed.\n *\/\n p = &name[strlen((char *)name)];\n fe = &fname[strlen((char *)fname)];\n\n if (utf8) {\n \/* UTF8 translates two-byte unicode characters into 1, 2 or 3 bytes.\n * %000000000xxxxxxx -> %0xxxxxxx\n * %00000xxxxxyyyyyy -> %110xxxxx %10yyyyyy\n * %xxxxyyyyyyzzzzzz -> %1110xxxx %10yyyyyy %10zzzzzz\n *\n * Therefore, the inverse is as follows:\n * First char:\n * 0x00 - 0x7F = one byte char\n * 0x80 - 0xBF = invalid\n * 0xC0 - 0xDF = 2 byte char (next char only 0x80-0xBF is valid)\n * 0xE0 - 0xEF = 3 byte char (next 2 chars only 0x80-0xBF is valid)\n * 0xF0 - 0xFF = invalid\n *\/\n do {\n if (fname >= fe) {\n\tfree(name);\n\treturn NULL;\n }\n\n \/* get next UTF8 char *\/\n if ((c = *fname++) < 0x80) x = c;\n else {\n\tif ((c >= 0xC0) && (c < 0xE0)) {\n\t x = (c & 0x1F) << 6;\n\t x |= *fname++ & 0x3F;\n\t}\n\telse if ((c >= 0xE0) && (c < 0xF0)) {\n\t x = (c & 0xF) << 12;\n\t x |= (*fname++ & 0x3F) << 6;\n\t x |= *fname++ & 0x3F;\n\t}\n\telse x = '?';\n }\n\n \/* whatever is the path seperator -> '\/'\n * whatever is the other slash -> '\\\\'\n * otherwise, if lower is set, the lowercase version *\/\n if (x == sep) x = '\/';\n else if (x == slash) x = '\\\\';\n else if (lower) x = (unsigned int) tolower((int) x);\n\n \/* integer back to UTF8 *\/\n if (x < 0x80) {\n\t*p++ = (unsigned char) x;\n }\n else if (x < 0x800) {\n\t*p++ = 0xC0 | (x >> 6); \n\t*p++ = 0x80 | (x & 0x3F);\n }\n else {\n\t*p++ = 0xE0 | (x >> 12);\n\t*p++ = 0x80 | ((x >> 6) & 0x3F);\n\t*p++ = 0x80 | (x & 0x3F);\n }\n } while (x);\n }\n else {\n \/* regular non-utf8 version *\/\n do {\n c = *fname++;\n if (c == sep) c = '\/';\n else if (c == slash) c = '\\\\';\n else if (lower) c = (unsigned char) tolower((int) c);\n } while ((*p++ = c));\n }\n return (char *) name;\n}","target":1,"code_token_length":1035,"total_token_length":1271,"max_tokens_setting":2048} +{"idx":411329,"func":" }\n\n \/\/! Unserialize a CImg serialized buffer into a CImgList list.\n template\n static CImgList get_unserialize(const CImg& buffer) {\n#ifdef cimg_use_zlib\n#define _cimgz_unserialize_case(Tss) { \\\n Bytef *cbuf = 0; \\\n if (sizeof(t)!=1 || cimg::type::string()==cimg::type::string()) { \\\n cbuf = new Bytef[csiz]; Bytef *_cbuf = cbuf; \\\n for (ulongT i = 0; i::get_unserialize(): Unable to unserialize compressed data \" \\\n \"unless zlib is enabled.\", \\\n pixel_type());\n#endif\n\n#define _cimg_unserialize_case(Ts,Tss) \\\n if (!loaded && !cimg::strcasecmp(Ts,str_pixeltype)) { \\\n for (unsigned int l = 0; l::unserialize(): Invalid specified size (%u,%u,%u,%u) for \" \\\n \"image #%u in serialized buffer.\", \\\n pixel_type(),W,H,D,C,l); \\\n if (W*H*D*C>0) { \\\n CImg raw; \\\n CImg &img = res._data[l]; \\\n if (err==5) _cimgz_unserialize_case(Tss) \\\n else if (sizeof(Tss)==sizeof(t) && cimg::type::is_float()==cimg::type::is_float()) { \\\n raw.assign((Tss*)stream,W,H,D,C,true); \\\n stream+=raw.size(); \\\n } else { \\\n raw.assign(W,H,D,C); \\\n CImg _raw((unsigned char*)raw._data,W*sizeof(Tss),H,D,C,true); \\\n cimg_for(_raw,p,unsigned char) *p = (unsigned char)*(stream++); \\\n } \\\n if (endian!=cimg::endianness()) cimg::invert_endianness(raw._data,raw.size()); \\\n raw.move_to(img); \\\n } \\\n } \\\n loaded = true; \\\n }\n\n if (buffer.is_empty())\n throw CImgArgumentException(\"CImgList<%s>::get_unserialize(): Specified serialized buffer is (null).\",\n pixel_type());\n CImgList res;\n const t *stream = buffer._data, *const estream = buffer._data + buffer.size();\n bool loaded = false, endian = cimg::endianness(), is_bytef = false;\n CImg tmp(256), str_pixeltype(256), str_endian(256);\n *tmp = *str_pixeltype = *str_endian = 0;\n unsigned int j, N = 0, W, H, D, C;\n uint64T csiz;\n int i, err;\n cimg::unused(is_bytef);\n do {\n j = 0; while ((i=(int)*stream)!='\\n' && stream::get_unserialize(): CImg header not found in serialized buffer.\",\n pixel_type());\n if (!cimg::strncasecmp(\"little\",str_endian,6)) endian = false;\n else if (!cimg::strncasecmp(\"big\",str_endian,3)) endian = true;\n res.assign(N);\n _cimg_unserialize_case(\"bool\",bool);\n _cimg_unserialize_case(\"unsigned_char\",unsigned char);\n _cimg_unserialize_case(\"uchar\",unsigned char);\n _cimg_unserialize_case(\"char\",char);\n _cimg_unserialize_case(\"unsigned_short\",unsigned short);\n _cimg_unserialize_case(\"ushort\",unsigned short);\n _cimg_unserialize_case(\"short\",short);\n _cimg_unserialize_case(\"unsigned_int\",unsigned int);\n _cimg_unserialize_case(\"uint\",unsigned int);\n _cimg_unserialize_case(\"int\",int);\n _cimg_unserialize_case(\"unsigned_int64\",uint64T);\n _cimg_unserialize_case(\"uint64\",uint64T);\n _cimg_unserialize_case(\"int64\",int64T);\n _cimg_unserialize_case(\"float\",float);\n _cimg_unserialize_case(\"double\",double);\n if (!loaded)\n throw CImgArgumentException(\"CImgList<%s>::get_unserialize(): Unsupported pixel type '%s' defined \"","target":0,"code_token_length":1353,"total_token_length":1589,"max_tokens_setting":2048} +{"idx":266102,"func":"void shutdown_executor(void) \/* {{{ *\/\n{\n\tzend_function *func;\n\tzend_class_entry *ce;\n\n\tzend_try {\n\n\/* Removed because this can not be safely done, e.g. in this situation:\n Object 1 creates object 2\n Object 3 holds reference to object 2.\n Now when 1 and 2 are destroyed, 3 can still access 2 in its destructor, with\n very problematic results *\/\n\/* \t\tzend_objects_store_call_destructors(&EG(objects_store)); *\/\n\n\/* Moved after symbol table cleaners, because some of the cleaners can call\n destructors, which would use EG(symtable_cache_ptr) and thus leave leaks *\/\n\/*\t\twhile (EG(symtable_cache_ptr)>=EG(symtable_cache)) {\n\t\t\tzend_hash_destroy(*EG(symtable_cache_ptr));\n\t\t\tefree(*EG(symtable_cache_ptr));\n\t\t\tEG(symtable_cache_ptr)--;\n\t\t}\n*\/\n\t\tzend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator);\n\n\t\tif (CG(unclean_shutdown)) {\n\t\t\tEG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor;\n\t\t}\n\t\tzend_hash_graceful_reverse_destroy(&EG(symbol_table));\n\t} zend_end_try();\n\tEG(valid_symbol_table) = 0;\n\n\tzend_try {\n\t\tzval *zeh;\n\t\t\/* remove error handlers before destroying classes and functions,\n\t\t * so that if handler used some class, crash would not happen *\/\n\t\tif (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {\n\t\t\tzeh = &EG(user_error_handler);\n\t\t\tzval_ptr_dtor(zeh);\n\t\t\tZVAL_UNDEF(&EG(user_error_handler));\n\t\t}\n\n\t\tif (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {\n\t\t\tzeh = &EG(user_exception_handler);\n\t\t\tzval_ptr_dtor(zeh);\n\t\t\tZVAL_UNDEF(&EG(user_exception_handler));\n\t\t}\n\n\t\tzend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);\n\t\tzend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_DESTRUCTOR, 1);\n\t\tzend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_DESTRUCTOR, 1);\n\t} zend_end_try();\n\n\tzend_try {\n\t\t\/* Cleanup static data for functions and arrays.\n\t\t * We need a separate cleanup stage because of the following problem:\n\t\t * Suppose we destroy class X, which destroys the class's function table,\n\t\t * and in the function table we have function foo() that has static $bar.\n\t\t * Now if an object of class X is assigned to $bar, its destructor will be\n\t\t * called and will fail since X's function table is in mid-destruction.\n\t\t * So we want first of all to clean up all data and then move to tables destruction.\n\t\t * Note that only run-time accessed data need to be cleaned up, pre-defined data can\n\t\t * not contain objects and thus are not probelmatic *\/\n\t\tif (EG(full_tables_cleanup)) {\n\t\t\tZEND_HASH_FOREACH_PTR(EG(function_table), func) {\n\t\t\t\tif (func->type == ZEND_USER_FUNCTION) {\n\t\t\t\t\tzend_cleanup_op_array_data((zend_op_array *) func);\n\t\t\t\t}\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t\tZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {\n\t\t\t\tif (ce->type == ZEND_USER_CLASS) {\n\t\t\t\t\tzend_cleanup_user_class_data(ce);\n\t\t\t\t} else {\n\t\t\t\t\tzend_cleanup_internal_class_data(ce);\n\t\t\t\t}\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t} else {\n\t\t\tZEND_HASH_REVERSE_FOREACH_PTR(EG(function_table), func) {\n\t\t\t\tif (func->type != ZEND_USER_FUNCTION) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tzend_cleanup_op_array_data((zend_op_array *) func);\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t\tZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {\n\t\t\t\tif (ce->type != ZEND_USER_CLASS) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tzend_cleanup_user_class_data(ce);\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t\tzend_cleanup_internal_classes();\n\t\t}\n\t} zend_end_try();\n\n\tzend_try {\n\t\tzend_llist_destroy(&CG(open_files));\n\t} zend_end_try();\n\n\tzend_try {\n\t\tzend_close_rsrc_list(&EG(regular_list));\n\t} zend_end_try();\n\n#if ZEND_DEBUG\n\tif (GC_G(gc_enabled) && !CG(unclean_shutdown)) {\n\t\tgc_collect_cycles();\n\t}\n#endif\n\n\tzend_try {\n\t\tzend_objects_store_free_object_storage(&EG(objects_store));\n\n\t\tzend_vm_stack_destroy();\n\n\t\t\/* Destroy all op arrays *\/\n\t\tif (EG(full_tables_cleanup)) {\n\t\t\tzend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full);\n\t\t\tzend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full);\n\t\t} else {\n\t\t\tzend_hash_reverse_apply(EG(function_table), clean_non_persistent_function);\n\t\t\tzend_hash_reverse_apply(EG(class_table), clean_non_persistent_class);\n\t\t}\n\n\t\twhile (EG(symtable_cache_ptr)>=EG(symtable_cache)) {\n\t\t\tzend_hash_destroy(*EG(symtable_cache_ptr));\n\t\t\tFREE_HASHTABLE(*EG(symtable_cache_ptr));\n\t\t\tEG(symtable_cache_ptr)--;\n\t\t}\n\t} zend_end_try();\n\n\tzend_try {\n\t\tclean_non_persistent_constants();\n\t} zend_end_try();\n\n\tzend_try {\n#if 0&&ZEND_DEBUG\n\tsignal(SIGSEGV, original_sigsegv_handler);\n#endif\n\n\t\tzend_hash_destroy(&EG(included_files));\n\n\t\tzend_stack_destroy(&EG(user_error_handlers_error_reporting));\n\t\tzend_stack_destroy(&EG(user_error_handlers));\n\t\tzend_stack_destroy(&EG(user_exception_handlers));\n\t\tzend_objects_store_destroy(&EG(objects_store));\n\t\tif (EG(in_autoload)) {\n\t\t\tzend_hash_destroy(EG(in_autoload));\n\t\t\tFREE_HASHTABLE(EG(in_autoload));\n\t\t}\n\t} zend_end_try();\n\n\tzend_shutdown_fpu();\n\n\tEG(ht_iterators_used) = 0;\n\tif (EG(ht_iterators) != EG(ht_iterators_slots)) {\n\t\tefree(EG(ht_iterators));\n\t}\n\n\tEG(active) = 0;\n}","target":0,"code_token_length":1334,"total_token_length":1570,"max_tokens_setting":2048} +{"idx":468612,"func":"ClientRequestContext::clientRedirectDone(const Helper::Reply &reply)\n{\n HttpRequest *old_request = http->request;\n debugs(85, 5, HERE << \"'\" << http->uri << \"' result=\" << reply);\n assert(redirect_state == REDIRECT_PENDING);\n redirect_state = REDIRECT_DONE;\n\n \/\/ Put helper response Notes into the transaction state record (ALE) eventually\n \/\/ do it early to ensure that no matter what the outcome the notes are present.\n if (http->al)\n http->al->syncNotes(old_request);\n\n UpdateRequestNotes(http->getConn(), *old_request, reply.notes);\n\n switch (reply.result) {\n case Helper::TimedOut:\n if (Config.onUrlRewriteTimeout.action != toutActBypass) {\n static const auto d = MakeNamedErrorDetail(\"REDIRECTOR_TIMEDOUT\");\n http->calloutsError(ERR_GATEWAY_FAILURE, d);\n debugs(85, DBG_IMPORTANT, \"ERROR: URL rewrite helper: Timedout\");\n }\n break;\n\n case Helper::Unknown:\n case Helper::TT:\n \/\/ Handler in redirect.cc should have already mapped Unknown\n \/\/ IF it contained valid entry for the old URL-rewrite helper protocol\n debugs(85, DBG_IMPORTANT, \"ERROR: URL rewrite helper returned invalid result code. Wrong helper? \" << reply);\n break;\n\n case Helper::BrokenHelper:\n debugs(85, DBG_IMPORTANT, \"ERROR: URL rewrite helper: \" << reply);\n break;\n\n case Helper::Error:\n \/\/ no change to be done.\n break;\n\n case Helper::Okay: {\n \/\/ #1: redirect with a specific status code OK status=NNN url=\"...\"\n \/\/ #2: redirect with a default status code OK url=\"...\"\n \/\/ #3: re-write the URL OK rewrite-url=\"...\"\n\n const char *statusNote = reply.notes.findFirst(\"status\");\n const char *urlNote = reply.notes.findFirst(\"url\");\n\n if (urlNote != NULL) {\n \/\/ HTTP protocol redirect to be done.\n\n \/\/ TODO: change default redirect status for appropriate requests\n \/\/ Squid defaults to 302 status for now for better compatibility with old clients.\n \/\/ HTTP\/1.0 client should get 302 (Http::scFound)\n \/\/ HTTP\/1.1 client contacting reverse-proxy should get 307 (Http::scTemporaryRedirect)\n \/\/ HTTP\/1.1 client being diverted by forward-proxy should get 303 (Http::scSeeOther)\n Http::StatusCode status = Http::scFound;\n if (statusNote != NULL) {\n const char * result = statusNote;\n status = static_cast(atoi(result));\n }\n\n if (status == Http::scMovedPermanently\n || status == Http::scFound\n || status == Http::scSeeOther\n || status == Http::scPermanentRedirect\n || status == Http::scTemporaryRedirect) {\n http->redirect.status = status;\n http->redirect.location = xstrdup(urlNote);\n \/\/ TODO: validate the URL produced here is RFC 2616 compliant absolute URI\n } else {\n debugs(85, DBG_CRITICAL, \"ERROR: URL-rewrite produces invalid \" << status << \" redirect Location: \" << urlNote);\n }\n } else {\n \/\/ URL-rewrite wanted. Ew.\n urlNote = reply.notes.findFirst(\"rewrite-url\");\n\n \/\/ prevent broken helpers causing too much damage. If old URL == new URL skip the re-write.\n if (urlNote != NULL && strcmp(urlNote, http->uri)) {\n AnyP::Uri tmpUrl;\n if (tmpUrl.parse(old_request->method, SBuf(urlNote))) {\n HttpRequest *new_request = old_request->clone();\n new_request->url = tmpUrl;\n debugs(61, 2, \"URL-rewriter diverts URL from \" << old_request->effectiveRequestUri() << \" to \" << new_request->effectiveRequestUri());\n\n \/\/ update the new request to flag the re-writing was done on it\n new_request->flags.redirected = true;\n\n \/\/ unlink bodypipe from the old request. Not needed there any longer.\n if (old_request->body_pipe != NULL) {\n old_request->body_pipe = NULL;\n debugs(61,2, HERE << \"URL-rewriter diverts body_pipe \" << new_request->body_pipe <<\n \" from request \" << old_request << \" to \" << new_request);\n }\n\n http->resetRequest(new_request);\n old_request = nullptr;\n } else {\n debugs(85, DBG_CRITICAL, \"ERROR: URL-rewrite produces invalid request: \" <<\n old_request->method << \" \" << urlNote << \" \" << old_request->http_ver);\n }\n }\n }\n }\n break;\n }\n\n \/* XXX PIPELINE: This is inaccurate during pipelining *\/\n\n if (http->getConn() != NULL && Comm::IsConnOpen(http->getConn()->clientConnection))\n fd_note(http->getConn()->clientConnection->fd, http->uri);\n\n assert(http->uri);\n\n http->doCallouts();\n}","target":0,"code_token_length":1126,"total_token_length":1362,"max_tokens_setting":2048} +{"idx":324753,"func":"static void bamboo_init(MachineState *machine)\n\n{\n\n ram_addr_t ram_size = machine->ram_size;\n\n const char *kernel_filename = machine->kernel_filename;\n\n const char *kernel_cmdline = machine->kernel_cmdline;\n\n const char *initrd_filename = machine->initrd_filename;\n\n unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 };\n\n MemoryRegion *address_space_mem = get_system_memory();\n\n MemoryRegion *isa = g_new(MemoryRegion, 1);\n\n MemoryRegion *ram_memories\n\n = g_malloc(PPC440EP_SDRAM_NR_BANKS * sizeof(*ram_memories));\n\n hwaddr ram_bases[PPC440EP_SDRAM_NR_BANKS];\n\n hwaddr ram_sizes[PPC440EP_SDRAM_NR_BANKS];\n\n qemu_irq *pic;\n\n qemu_irq *irqs;\n\n PCIBus *pcibus;\n\n PowerPCCPU *cpu;\n\n CPUPPCState *env;\n\n uint64_t elf_entry;\n\n uint64_t elf_lowaddr;\n\n hwaddr loadaddr = 0;\n\n target_long initrd_size = 0;\n\n DeviceState *dev;\n\n int success;\n\n int i;\n\n\n\n \/* Setup CPU. *\/\n\n if (machine->cpu_model == NULL) {\n\n machine->cpu_model = \"440EP\";\n\n }\n\n cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model));\n\n if (cpu == NULL) {\n\n fprintf(stderr, \"Unable to initialize CPU!\\n\");\n\n exit(1);\n\n }\n\n env = &cpu->env;\n\n\n\n if (env->mmu_model != POWERPC_MMU_BOOKE) {\n\n fprintf(stderr, \"MMU model %i not supported by this machine.\\n\",\n\n env->mmu_model);\n\n exit(1);\n\n }\n\n\n\n qemu_register_reset(main_cpu_reset, cpu);\n\n ppc_booke_timers_init(cpu, 400000000, 0);\n\n ppc_dcr_init(env, NULL, NULL);\n\n\n\n \/* interrupt controller *\/\n\n irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);\n\n irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];\n\n irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];\n\n pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);\n\n\n\n \/* SDRAM controller *\/\n\n memset(ram_bases, 0, sizeof(ram_bases));\n\n memset(ram_sizes, 0, sizeof(ram_sizes));\n\n ram_size = ppc4xx_sdram_adjust(ram_size, PPC440EP_SDRAM_NR_BANKS,\n\n ram_memories,\n\n ram_bases, ram_sizes,\n\n ppc440ep_sdram_bank_sizes);\n\n \/* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. *\/\n\n ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories,\n\n ram_bases, ram_sizes, 1);\n\n\n\n \/* PCI *\/\n\n dev = sysbus_create_varargs(TYPE_PPC4xx_PCI_HOST_BRIDGE,\n\n PPC440EP_PCI_CONFIG,\n\n pic[pci_irq_nrs[0]], pic[pci_irq_nrs[1]],\n\n pic[pci_irq_nrs[2]], pic[pci_irq_nrs[3]],\n\n NULL);\n\n pcibus = (PCIBus *)qdev_get_child_bus(dev, \"pci.0\");\n\n if (!pcibus) {\n\n fprintf(stderr, \"couldn't create PCI controller!\\n\");\n\n exit(1);\n\n }\n\n\n\n memory_region_init_alias(isa, NULL, \"isa_mmio\",\n\n get_system_io(), 0, PPC440EP_PCI_IOLEN);\n\n memory_region_add_subregion(get_system_memory(), PPC440EP_PCI_IO, isa);\n\n\n\n if (serial_hds[0] != NULL) {\n\n serial_mm_init(address_space_mem, 0xef600300, 0, pic[0],\n\n PPC_SERIAL_MM_BAUDBASE, serial_hds[0],\n\n DEVICE_BIG_ENDIAN);\n\n }\n\n if (serial_hds[1] != NULL) {\n\n serial_mm_init(address_space_mem, 0xef600400, 0, pic[1],\n\n PPC_SERIAL_MM_BAUDBASE, serial_hds[1],\n\n DEVICE_BIG_ENDIAN);\n\n }\n\n\n\n if (pcibus) {\n\n \/* Register network interfaces. *\/\n\n for (i = 0; i < nb_nics; i++) {\n\n \/* There are no PCI NICs on the Bamboo board, but there are\n\n * PCI slots, so we can pick whatever default model we want. *\/\n\n pci_nic_init_nofail(&nd_table[i], pcibus, \"e1000\", NULL);\n\n }\n\n }\n\n\n\n \/* Load kernel. *\/\n\n if (kernel_filename) {\n\n success = load_uimage(kernel_filename, &entry, &loadaddr, NULL,\n\n NULL, NULL);\n\n if (success < 0) {\n\n success = load_elf(kernel_filename, NULL, NULL, &elf_entry,\n\n &elf_lowaddr, NULL, 1, PPC_ELF_MACHINE,\n\n 0, 0);\n\n entry = elf_entry;\n\n loadaddr = elf_lowaddr;\n\n }\n\n \/* XXX try again as binary *\/\n\n if (success < 0) {\n\n fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\n\n kernel_filename);\n\n exit(1);\n\n }\n\n }\n\n\n\n \/* Load initrd. *\/\n\n if (initrd_filename) {\n\n initrd_size = load_image_targphys(initrd_filename, RAMDISK_ADDR,\n\n ram_size - RAMDISK_ADDR);\n\n\n\n if (initrd_size < 0) {\n\n fprintf(stderr, \"qemu: could not load ram disk '%s' at %x\\n\",\n\n initrd_filename, RAMDISK_ADDR);\n\n exit(1);\n\n }\n\n }\n\n\n\n \/* If we're loading a kernel directly, we must load the device tree too. *\/\n\n if (kernel_filename) {\n\n if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR,\n\n initrd_size, kernel_cmdline) < 0) {\n\n fprintf(stderr, \"couldn't load device tree\\n\");\n\n exit(1);\n\n }\n\n }\n\n}\n","target":1,"code_token_length":1425,"total_token_length":1661,"max_tokens_setting":2048} +{"idx":322157,"func":"static void dec_bit(DisasContext *dc)\n\n{\n\n TCGv t0, t1;\n\n unsigned int op;\n\n int mem_index = cpu_mmu_index(dc->env);\n\n\n\n op = dc->ir & ((1 << 9) - 1);\n\n switch (op) {\n\n case 0x21:\n\n \/* src. *\/\n\n t0 = tcg_temp_new();\n\n\n\n LOG_DIS(\"src r%d r%d\\n\", dc->rd, dc->ra);\n\n tcg_gen_andi_tl(t0, cpu_R[dc->ra], 1);\n\n if (dc->rd) {\n\n t1 = tcg_temp_new();\n\n read_carry(dc, t1);\n\n tcg_gen_shli_tl(t1, t1, 31);\n\n\n\n tcg_gen_shri_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);\n\n tcg_gen_or_tl(cpu_R[dc->rd], cpu_R[dc->rd], t1);\n\n tcg_temp_free(t1);\n\n }\n\n\n\n \/* Update carry. *\/\n\n write_carry(dc, t0);\n\n tcg_temp_free(t0);\n\n break;\n\n\n\n case 0x1:\n\n case 0x41:\n\n \/* srl. *\/\n\n t0 = tcg_temp_new();\n\n LOG_DIS(\"srl r%d r%d\\n\", dc->rd, dc->ra);\n\n\n\n \/* Update carry. *\/\n\n tcg_gen_andi_tl(t0, cpu_R[dc->ra], 1);\n\n write_carry(dc, t0);\n\n tcg_temp_free(t0);\n\n if (dc->rd) {\n\n if (op == 0x41)\n\n tcg_gen_shri_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);\n\n else\n\n tcg_gen_sari_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);\n\n }\n\n break;\n\n case 0x60:\n\n LOG_DIS(\"ext8s r%d r%d\\n\", dc->rd, dc->ra);\n\n tcg_gen_ext8s_i32(cpu_R[dc->rd], cpu_R[dc->ra]);\n\n break;\n\n case 0x61:\n\n LOG_DIS(\"ext16s r%d r%d\\n\", dc->rd, dc->ra);\n\n tcg_gen_ext16s_i32(cpu_R[dc->rd], cpu_R[dc->ra]);\n\n break;\n\n case 0x64:\n\n case 0x66:\n\n case 0x74:\n\n case 0x76:\n\n \/* wdc. *\/\n\n LOG_DIS(\"wdc r%d\\n\", dc->ra);\n\n if ((dc->tb_flags & MSR_EE_FLAG)\n\n && mem_index == MMU_USER_IDX) {\n\n tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_PRIVINSN);\n\n t_gen_raise_exception(dc, EXCP_HW_EXCP);\n\n return;\n\n }\n\n break;\n\n case 0x68:\n\n \/* wic. *\/\n\n LOG_DIS(\"wic r%d\\n\", dc->ra);\n\n if ((dc->tb_flags & MSR_EE_FLAG)\n\n && mem_index == MMU_USER_IDX) {\n\n tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_PRIVINSN);\n\n t_gen_raise_exception(dc, EXCP_HW_EXCP);\n\n return;\n\n }\n\n break;\n\n case 0xe0:\n\n if ((dc->tb_flags & MSR_EE_FLAG)\n\n && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)\n\n && !((dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR))) {\n\n tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);\n\n t_gen_raise_exception(dc, EXCP_HW_EXCP);\n\n }\n\n if (dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR) {\n\n gen_helper_clz(cpu_R[dc->rd], cpu_R[dc->ra]);\n\n }\n\n break;\n\n case 0x1e0:\n\n \/* swapb *\/\n\n LOG_DIS(\"swapb r%d r%d\\n\", dc->rd, dc->ra);\n\n tcg_gen_bswap32_i32(cpu_R[dc->rd], cpu_R[dc->ra]);\n\n break;\n\n case 0x1e2:\n\n \/*swaph *\/\n\n LOG_DIS(\"swaph r%d r%d\\n\", dc->rd, dc->ra);\n\n tcg_gen_rotri_i32(cpu_R[dc->rd], cpu_R[dc->ra], 16);\n\n break;\n\n default:\n\n cpu_abort(dc->env, \"unknown bit oc=%x op=%x rd=%d ra=%d rb=%d\\n\",\n\n dc->pc, op, dc->rd, dc->ra, dc->rb);\n\n break;\n\n }\n\n}\n","target":0,"code_token_length":1087,"total_token_length":1323,"max_tokens_setting":2048} +{"idx":488986,"func":"static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord *rr) {\n int r;\n\n assert(t);\n assert(rr);\n\n \/* Checks if the RR we are looking for must be signed with an\n * RRSIG. This is used for positive responses. *\/\n\n if (t->scope->dnssec_mode == DNSSEC_NO)\n return false;\n\n if (dns_type_is_pseudo(rr->key->type))\n return -EINVAL;\n\n r = dns_transaction_negative_trust_anchor_lookup(t, dns_resource_key_name(rr->key));\n if (r < 0)\n return r;\n if (r > 0)\n return false;\n\n switch (rr->key->type) {\n\n case DNS_TYPE_RRSIG:\n \/* RRSIGs are the signatures themselves, they need no signing. *\/\n return false;\n\n case DNS_TYPE_SOA:\n case DNS_TYPE_NS: {\n DnsTransaction *dt;\n Iterator i;\n\n \/* For SOA or NS RRs we look for a matching DS transaction *\/\n\n SET_FOREACH(dt, t->dnssec_transactions, i) {\n\n if (dt->key->class != rr->key->class)\n continue;\n if (dt->key->type != DNS_TYPE_DS)\n continue;\n\n r = dns_name_equal(dns_resource_key_name(dt->key), dns_resource_key_name(rr->key));\n if (r < 0)\n return r;\n if (r == 0)\n continue;\n\n \/* We found a DS transactions for the SOA\/NS\n * RRs we are looking at. If it discovered signed DS\n * RRs, then we need to be signed, too. *\/\n\n if (!dt->answer_authenticated)\n return false;\n\n return dns_answer_match_key(dt->answer, dt->key, NULL);\n }\n\n \/* We found nothing that proves this is safe to leave\n * this unauthenticated, hence ask inist on\n * authentication. *\/\n return true;\n }\n\n case DNS_TYPE_DS:\n case DNS_TYPE_CNAME:\n case DNS_TYPE_DNAME: {\n const char *parent = NULL;\n DnsTransaction *dt;\n Iterator i;\n\n \/*\n * CNAME\/DNAME RRs cannot be located at a zone apex, hence look directly for the parent SOA.\n *\n * DS RRs are signed if the parent is signed, hence also look at the parent SOA\n *\/\n\n SET_FOREACH(dt, t->dnssec_transactions, i) {\n\n if (dt->key->class != rr->key->class)\n continue;\n if (dt->key->type != DNS_TYPE_SOA)\n continue;\n\n if (!parent) {\n parent = dns_resource_key_name(rr->key);\n r = dns_name_parent(&parent);\n if (r < 0)\n return r;\n if (r == 0) {\n if (rr->key->type == DNS_TYPE_DS)\n return true;\n\n \/* A CNAME\/DNAME without a parent? That's sooo weird. *\/\n return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),\n \"Transaction %\" PRIu16 \" claims CNAME\/DNAME at root. Refusing.\", t->id);\n }\n }\n\n r = dns_name_equal(dns_resource_key_name(dt->key), parent);\n if (r < 0)\n return r;\n if (r == 0)\n continue;\n\n return t->answer_authenticated;\n }\n\n return true;\n }\n\n default: {\n DnsTransaction *dt;\n Iterator i;\n\n \/* Any other kind of RR (including DNSKEY\/NSEC\/NSEC3). Let's see if our SOA lookup was authenticated *\/\n\n SET_FOREACH(dt, t->dnssec_transactions, i) {\n\n if (dt->key->class != rr->key->class)\n continue;\n if (dt->key->type != DNS_TYPE_SOA)\n continue;\n\n r = dns_name_equal(dns_resource_key_name(dt->key), dns_resource_key_name(rr->key));\n if (r < 0)\n return r;\n if (r == 0)\n continue;\n\n \/* We found the transaction that was supposed to find\n * the SOA RR for us. It was successful, but found no\n * RR for us. This means we are not at a zone cut. In\n * this case, we require authentication if the SOA\n * lookup was authenticated too. *\/\n return t->answer_authenticated;\n }\n\n return true;\n }}\n}","target":0,"code_token_length":976,"total_token_length":1212,"max_tokens_setting":2048} +{"idx":11224,"func":"long Cluster::ParseBlockGroup(long long payload_size, long long& pos,\n long& len) {\n const long long payload_start = pos;\n const long long payload_stop = pos + payload_size;\n\n IMkvReader* const pReader = m_pSegment->m_pReader;\n\n long long total, avail;\n\n long status = pReader->Length(&total, &avail);\n\n if (status < 0) \/\/ error\n return status;\n\n assert((total < 0) || (avail <= total));\n\n if ((total >= 0) && (payload_stop > total))\n return E_FILE_FORMAT_INVALID;\n\n if (payload_stop > avail) {\n len = static_cast(payload_size);\n return E_BUFFER_NOT_FULL;\n }\n\n long long discard_padding = 0;\n\n while (pos < payload_stop) {\n\n if ((pos + 1) > avail) {\n len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n long long result = GetUIntLength(pReader, pos, len);\n\n if (result < 0) \/\/ error\n return static_cast(result);\n\n if (result > 0) \/\/ weird\n return E_BUFFER_NOT_FULL;\n\n if ((pos + len) > payload_stop)\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long id = ReadUInt(pReader, pos, len);\n\n if (id < 0) \/\/ error\n return static_cast(id);\n\n if (id == 0) \/\/ not a value ID\n return E_FILE_FORMAT_INVALID;\n\n pos += len; \/\/ consume ID field\n\n\n if ((pos + 1) > avail) {\n len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n result = GetUIntLength(pReader, pos, len);\n\n if (result < 0) \/\/ error\n return static_cast(result);\n\n if (result > 0) \/\/ weird\n return E_BUFFER_NOT_FULL;\n\n if ((pos + len) > payload_stop)\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long size = ReadUInt(pReader, pos, len);\n\n if (size < 0) \/\/ error\n return static_cast(size);\n\n pos += len; \/\/ consume size field\n\n\n if (pos > payload_stop)\n return E_FILE_FORMAT_INVALID;\n\n if (size == 0) \/\/ weird\n continue;\n\n const long long unknown_size = (1LL << (7 * len)) - 1;\n\n if (size == unknown_size)\n return E_FILE_FORMAT_INVALID;\n\n if (id == 0x35A2) { \/\/ DiscardPadding\n status = UnserializeInt(pReader, pos, size, discard_padding);\n\n if (status < 0) \/\/ error\n return status;\n }\n\n if (id != 0x21) { \/\/ sub-part of BlockGroup is not a Block\n pos += size; \/\/ consume sub-part of block group\n\n if (pos > payload_stop)\n return E_FILE_FORMAT_INVALID;\n\n continue;\n }\n\n const long long block_stop = pos + size;\n\n if (block_stop > payload_stop)\n return E_FILE_FORMAT_INVALID;\n\n\n if ((pos + 1) > avail) {\n len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n result = GetUIntLength(pReader, pos, len);\n\n if (result < 0) \/\/ error\n return static_cast(result);\n\n if (result > 0) \/\/ weird\n return E_BUFFER_NOT_FULL;\n\n if ((pos + len) > block_stop)\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long track = ReadUInt(pReader, pos, len);\n\n if (track < 0) \/\/ error\n return static_cast(track);\n\n\n if (track == 0)\n return E_FILE_FORMAT_INVALID;\n \n#if 0\n const Tracks* const pTracks = m_pSegment->GetTracks();\n assert(pTracks);\n const long tn = static_cast(track);\n const Track* const pTrack = pTracks->GetTrackByNumber(tn);\n if (pTrack == NULL)\n return E_FILE_FORMAT_INVALID;\n#endif\n pos += len; \/\/ consume track number\n \n if ((pos + 2) > block_stop)\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + 2) > avail) {\n len = 2;\n return E_BUFFER_NOT_FULL;\n }\n\n pos += 2; \/\/ consume timecode\n\n if ((pos + 1) > block_stop)\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + 1) > avail) {\n len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n unsigned char flags;\n\n status = pReader->Read(pos, 1, &flags);\n\n if (status < 0) { \/\/ error or underflow\n len = 1;\n return status;\n }\n\n ++pos; \/\/ consume flags byte\n assert(pos <= avail);\n\n if (pos >= block_stop)\n return E_FILE_FORMAT_INVALID;\n\n const int lacing = int(flags & 0x06) >> 1;\n\n if ((lacing != 0) && (block_stop > avail)) {\n len = static_cast(block_stop - pos);\n return E_BUFFER_NOT_FULL;\n\n }\n \n pos = block_stop; \/\/ consume block-part of block group\n assert(pos <= payload_stop);\n }\n \n assert(pos == payload_stop);\n \n status = CreateBlock(0x20, \/\/ BlockGroup ID\n payload_start, payload_size, discard_padding);\n if (status != 0)\n return status;\n\n m_pos = payload_stop;\n\n return 0; \/\/ success\n}\n","target":1,"code_token_length":1180,"total_token_length":1416,"max_tokens_setting":2048} +{"idx":347054,"func":"_krb5_extract_ticket(krb5_context context,\n\t\t krb5_kdc_rep *rep,\n\t\t krb5_creds *creds,\n\t\t krb5_keyblock *key,\n\t\t krb5_const_pointer keyseed,\n\t\t krb5_key_usage key_usage,\n\t\t krb5_addresses *addrs,\n\t\t unsigned nonce,\n\t\t unsigned flags,\n\t\t krb5_data *request,\n\t\t krb5_decrypt_proc decrypt_proc,\n\t\t krb5_const_pointer decryptarg)\n{\n krb5_error_code ret;\n krb5_principal tmp_principal;\n size_t len = 0;\n time_t tmp_time;\n krb5_timestamp sec_now;\n\n \/* decrypt *\/\n\n if (decrypt_proc == NULL)\n\tdecrypt_proc = decrypt_tkt;\n\n ret = (*decrypt_proc)(context, key, key_usage, decryptarg, rep);\n if (ret)\n\tgoto out;\n\n if (rep->enc_part.flags.enc_pa_rep && request) {\n\tkrb5_crypto crypto = NULL;\n\tChecksum cksum;\n\tPA_DATA *pa = NULL;\n\tint idx = 0;\n\n\t_krb5_debug(context, 5, \"processing enc-ap-rep\");\n\n\tif (rep->enc_part.encrypted_pa_data == NULL ||\n\t (pa = krb5_find_padata(rep->enc_part.encrypted_pa_data->val,\n\t\t\t\t rep->enc_part.encrypted_pa_data->len,\n\t\t\t\t KRB5_PADATA_REQ_ENC_PA_REP,\n\t\t\t\t &idx)) == NULL)\n\t{\n\t _krb5_debug(context, 5, \"KRB5_PADATA_REQ_ENC_PA_REP missing\");\n\t ret = KRB5KRB_AP_ERR_MODIFIED;\n\t goto out;\n\t}\n\t\n\tret = krb5_crypto_init(context, key, 0, &crypto);\n\tif (ret)\n\t goto out;\n\t\n\tret = decode_Checksum(pa->padata_value.data,\n\t\t\t pa->padata_value.length,\n\t\t\t &cksum, NULL);\n\tif (ret) {\n\t krb5_crypto_destroy(context, crypto);\n\t goto out;\n\t}\n\t\n\tret = krb5_verify_checksum(context, crypto,\n\t\t\t\t KRB5_KU_AS_REQ,\n\t\t\t\t request->data, request->length,\n\t\t\t\t &cksum);\n\tkrb5_crypto_destroy(context, crypto);\n\tfree_Checksum(&cksum);\n\t_krb5_debug(context, 5, \"enc-ap-rep: %svalid\", (ret == 0) ? \"\" : \"in\");\n\tif (ret)\n\t goto out;\n }\n\n \/* save session key *\/\n\n creds->session.keyvalue.length = 0;\n creds->session.keyvalue.data = NULL;\n creds->session.keytype = rep->enc_part.key.keytype;\n ret = krb5_data_copy (&creds->session.keyvalue,\n\t\t\t rep->enc_part.key.keyvalue.data,\n\t\t\t rep->enc_part.key.keyvalue.length);\n if (ret) {\n\tkrb5_clear_error_message(context);\n\tgoto out;\n }\n\n \/* compare client and save *\/\n ret = _krb5_principalname2krb5_principal(context,\n\t\t\t\t\t &tmp_principal,\n\t\t\t\t\t rep->kdc_rep.cname,\n\t\t\t\t\t rep->kdc_rep.crealm);\n if (ret)\n\tgoto out;\n\n \/* check client referral and save principal *\/\n \/* anonymous here ? *\/\n if((flags & EXTRACT_TICKET_ALLOW_CNAME_MISMATCH) == 0) {\n\tret = check_client_referral(context, rep,\n\t\t\t\t creds->client,\n\t\t\t\t tmp_principal,\n\t\t\t\t &creds->session);\n\tif (ret) {\n\t krb5_free_principal (context, tmp_principal);\n\t goto out;\n\t}\n }\n krb5_free_principal (context, creds->client);\n creds->client = tmp_principal;\n\n \/* check server referral and save principal *\/\n ret = _krb5_principalname2krb5_principal (context,\n\t\t\t\t\t &tmp_principal,\n\t\t\t\t\t rep->kdc_rep.ticket.sname,\n\t\t\t\t\t rep->kdc_rep.ticket.realm);\n if (ret)\n\tgoto out;\n if((flags & EXTRACT_TICKET_ALLOW_SERVER_MISMATCH) == 0){\n\tret = check_server_referral(context,\n\t\t\t\t rep,\n\t\t\t\t flags,\n\t\t\t\t creds->server,\n\t\t\t\t tmp_principal,\n\t\t\t\t &creds->session);\n\tif (ret) {\n\t krb5_free_principal (context, tmp_principal);\n\t goto out;\n\t}\n }\n krb5_free_principal(context, creds->server);\n creds->server = tmp_principal;\n\n \/* verify names *\/\n if(flags & EXTRACT_TICKET_MATCH_REALM){\n\tconst char *srealm = krb5_principal_get_realm(context, creds->server);\n\tconst char *crealm = krb5_principal_get_realm(context, creds->client);\n\n\tif (strcmp(rep->enc_part.srealm, srealm) != 0 ||\n\t strcmp(rep->enc_part.srealm, crealm) != 0)\n\t{\n\t ret = KRB5KRB_AP_ERR_MODIFIED;\n\t krb5_clear_error_message(context);\n\t goto out;\n\t}\n }\n\n \/* compare nonces *\/\n\n if (nonce != (unsigned)rep->enc_part.nonce) {\n\tret = KRB5KRB_AP_ERR_MODIFIED;\n\tkrb5_set_error_message(context, ret, N_(\"malloc: out of memory\", \"\"));\n\tgoto out;\n }\n\n \/* set kdc-offset *\/\n\n krb5_timeofday (context, &sec_now);\n if (rep->enc_part.flags.initial\n\t&& (flags & EXTRACT_TICKET_TIMESYNC)\n\t&& context->kdc_sec_offset == 0\n\t&& krb5_config_get_bool (context, NULL,\n\t\t\t\t \"libdefaults\",\n\t\t\t\t \"kdc_timesync\",\n\t\t\t\t NULL)) {\n\tcontext->kdc_sec_offset = rep->enc_part.authtime - sec_now;\n\tkrb5_timeofday (context, &sec_now);\n }\n\n \/* check all times *\/\n\n if (rep->enc_part.starttime) {\n\ttmp_time = *rep->enc_part.starttime;\n } else\n\ttmp_time = rep->enc_part.authtime;\n\n if (creds->times.starttime == 0\n\t&& labs(tmp_time - sec_now) > context->max_skew) {\n\tret = KRB5KRB_AP_ERR_SKEW;\n\tkrb5_set_error_message (context, ret,\n\t\t\t\tN_(\"time skew (%ld) larger than max (%ld)\", \"\"),\n\t\t\t labs(tmp_time - sec_now),\n\t\t\t (long)context->max_skew);\n\tgoto out;\n }\n\n if (creds->times.starttime != 0\n\t&& tmp_time != creds->times.starttime) {\n\tkrb5_clear_error_message (context);\n\tret = KRB5KRB_AP_ERR_MODIFIED;\n\tgoto out;\n }\n\n creds->times.starttime = tmp_time;\n\n if (rep->enc_part.renew_till) {\n\ttmp_time = *rep->enc_part.renew_till;\n } else\n\ttmp_time = 0;\n\n if (creds->times.renew_till != 0\n\t&& tmp_time > creds->times.renew_till) {\n\tkrb5_clear_error_message (context);\n\tret = KRB5KRB_AP_ERR_MODIFIED;\n\tgoto out;\n }\n\n creds->times.renew_till = tmp_time;\n\n creds->times.authtime = rep->enc_part.authtime;\n\n if (creds->times.endtime != 0\n\t&& rep->enc_part.endtime > creds->times.endtime) {\n\tkrb5_clear_error_message (context);\n\tret = KRB5KRB_AP_ERR_MODIFIED;\n\tgoto out;\n }\n\n creds->times.endtime = rep->enc_part.endtime;\n\n if(rep->enc_part.caddr)\n\tkrb5_copy_addresses (context, rep->enc_part.caddr, &creds->addresses);\n else if(addrs)\n\tkrb5_copy_addresses (context, addrs, &creds->addresses);\n else {\n\tcreds->addresses.len = 0;\n\tcreds->addresses.val = NULL;\n }\n creds->flags.b = rep->enc_part.flags;\n\n creds->authdata.len = 0;\n creds->authdata.val = NULL;\n\n \/* extract ticket *\/\n ASN1_MALLOC_ENCODE(Ticket, creds->ticket.data, creds->ticket.length,\n\t\t &rep->kdc_rep.ticket, &len, ret);\n if(ret)\n\tgoto out;\n if (creds->ticket.length != len)\n\tkrb5_abortx(context, \"internal error in ASN.1 encoder\");\n creds->second_ticket.length = 0;\n creds->second_ticket.data = NULL;\n\n\nout:\n memset (rep->enc_part.key.keyvalue.data, 0,\n\t rep->enc_part.key.keyvalue.length);\n return ret;\n}","target":1,"code_token_length":1810,"total_token_length":2046,"max_tokens_setting":2048} +{"idx":143,"func":"guint16 de_mid ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo , guint32 offset , guint len , gchar * add_string , int string_len ) {\n guint8 oct ;\n guint32 curr_offset ;\n guint32 value ;\n gboolean odd ;\n const gchar * digit_str ;\n proto_item * ti ;\n curr_offset = offset ;\n oct = tvb_get_guint8 ( tvb , curr_offset ) ;\n switch ( oct & 0x07 ) {\n case 0 : proto_tree_add_item ( tree , hf_gsm_a_unused , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_odd_even_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_mobile_identity_type , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n if ( add_string ) g_snprintf ( add_string , string_len , \" - No Identity Code\" ) ;\n curr_offset ++ ;\n if ( len > 1 ) {\n expert_add_info ( pinfo , tree , & ei_gsm_a_format_not_supported ) ;\n }\n curr_offset += len - 1 ;\n break ;\n case 3 : case 1 : odd = oct & 0x08 ;\n proto_tree_add_item ( tree , hf_gsm_a_id_dig_1 , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_odd_even_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_mobile_identity_type , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n if ( ( oct & 0x07 ) == 3 ) {\n digit_str = tvb_bcd_dig_to_wmem_packet_str ( tvb , curr_offset , len - ( curr_offset - offset ) , NULL , TRUE ) ;\n proto_tree_add_string_format ( tree , hf_gsm_a_imeisv , tvb , curr_offset , len - ( curr_offset - offset ) , digit_str , \"BCD Digits: %s\" , digit_str ) ;\n }\n else {\n digit_str = dissect_e212_imsi ( tvb , pinfo , tree , curr_offset , len - ( curr_offset - offset ) , TRUE ) ;\n }\n if ( sccp_assoc && ! sccp_assoc -> calling_party ) {\n sccp_assoc -> calling_party = wmem_strdup_printf ( wmem_file_scope ( ) , ( ( oct & 0x07 ) == 3 ) ? \"IMEISV: %s\" : \"IMSI: %s\" , digit_str ) ;\n }\n if ( add_string ) g_snprintf ( add_string , string_len , \" - %s (%s)\" , ( ( oct & 0x07 ) == 3 ) ? \"IMEISV\" : \"IMSI\" , digit_str ) ;\n curr_offset += len - ( curr_offset - offset ) ;\n if ( ! odd ) {\n proto_tree_add_item ( tree , hf_gsm_a_filler , tvb , curr_offset - 1 , 1 , ENC_NA ) ;\n }\n break ;\n case 2 : proto_tree_add_uint_format_value ( tree , hf_gsm_a_identity_digit1 , tvb , curr_offset , 1 , oct , \"%c\" , Dgt1_9_bcd . out [ ( oct & 0xf0 ) >> 4 ] ) ;\n proto_tree_add_item ( tree , hf_gsm_a_odd_even_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_mobile_identity_type , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n curr_offset ++ ;\n if ( curr_offset - offset >= len ) return ( curr_offset - offset ) ;\n digit_str = tvb_bcd_dig_to_wmem_packet_str ( tvb , curr_offset , len - ( curr_offset - offset ) , NULL , FALSE ) ;\n proto_tree_add_string_format ( tree , hf_gsm_a_imei , tvb , curr_offset , len - ( curr_offset - offset ) , digit_str , \"BCD Digits: %s\" , digit_str ) ;\n if ( add_string ) g_snprintf ( add_string , string_len , \" - IMEI (%s)\" , digit_str ) ;\n curr_offset += len - ( curr_offset - offset ) ;\n break ;\n case 4 : proto_tree_add_item ( tree , hf_gsm_a_unused , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_odd_even_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_mobile_identity_type , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n curr_offset ++ ;\n value = tvb_get_ntohl ( tvb , curr_offset ) ;\n proto_tree_add_uint ( tree , hf_gsm_a_tmsi , tvb , curr_offset , 4 , value ) ;\n if ( add_string ) g_snprintf ( add_string , string_len , \" - TMSI\/P-TMSI (0x%04x)\" , value ) ;\n curr_offset += 4 ;\n break ;\n case 5 : proto_tree_add_bits_item ( tree , hf_gsm_a_spare_bits , tvb , curr_offset << 3 , 2 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_mbs_ses_id_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_tmgi_mcc_mnc_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_odd_even_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_gsm_a_mobile_identity_type , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n curr_offset ++ ;\n proto_tree_add_item ( tree , hf_gsm_a_mbs_service_id , tvb , curr_offset , 3 , ENC_BIG_ENDIAN ) ;\n curr_offset += 3 ;\n if ( ( oct & 0x10 ) == 0x10 ) {\n curr_offset = dissect_e212_mcc_mnc ( tvb , pinfo , tree , curr_offset , E212_NONE , TRUE ) ;\n }\n if ( ( oct & 0x20 ) == 0x20 ) {\n proto_tree_add_item ( tree , hf_gsm_a_mbs_session_id , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n curr_offset ++ ;\n }\n break ;\n default : proto_tree_add_item ( tree , hf_gsm_a_odd_even_ind , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n ti = proto_tree_add_item ( tree , hf_gsm_a_mobile_identity_type , tvb , curr_offset , 1 , ENC_BIG_ENDIAN ) ;\n expert_add_info_format ( pinfo , ti , & ei_gsm_a_mobile_identity_type , \"Unknown format %u\" , ( oct & 0x07 ) ) ;\n if ( add_string ) g_snprintf ( add_string , string_len , \" - Format Unknown\" ) ;\n curr_offset += len ;\n break ;\n }\n EXTRANEOUS_DATA_CHECK ( len , curr_offset - offset , pinfo , & ei_gsm_a_extraneous_data ) ;\n return ( curr_offset - offset ) ;\n }","target":1,"code_token_length":1563,"total_token_length":1799,"max_tokens_setting":2048} +{"idx":447668,"func":"static bool net_tx_pkt_parse_headers(struct NetTxPkt *pkt)\n{\n struct iovec *l2_hdr, *l3_hdr;\n size_t bytes_read;\n size_t full_ip6hdr_len;\n uint16_t l3_proto;\n\n assert(pkt);\n\n l2_hdr = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];\n l3_hdr = &pkt->vec[NET_TX_PKT_L3HDR_FRAG];\n\n bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, 0, l2_hdr->iov_base,\n ETH_MAX_L2_HDR_LEN);\n if (bytes_read < sizeof(struct eth_header)) {\n l2_hdr->iov_len = 0;\n return false;\n }\n\n l2_hdr->iov_len = sizeof(struct eth_header);\n switch (be16_to_cpu(PKT_GET_ETH_HDR(l2_hdr->iov_base)->h_proto)) {\n case ETH_P_VLAN:\n l2_hdr->iov_len += sizeof(struct vlan_header);\n break;\n case ETH_P_DVLAN:\n l2_hdr->iov_len += 2 * sizeof(struct vlan_header);\n break;\n }\n\n if (bytes_read < l2_hdr->iov_len) {\n l2_hdr->iov_len = 0;\n l3_hdr->iov_len = 0;\n pkt->packet_type = ETH_PKT_UCAST;\n return false;\n } else {\n l2_hdr->iov_len = ETH_MAX_L2_HDR_LEN;\n l2_hdr->iov_len = eth_get_l2_hdr_length(l2_hdr->iov_base);\n pkt->packet_type = get_eth_packet_type(l2_hdr->iov_base);\n }\n\n l3_proto = eth_get_l3_proto(l2_hdr, 1, l2_hdr->iov_len);\n\n switch (l3_proto) {\n case ETH_P_IP:\n bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,\n l3_hdr->iov_base, sizeof(struct ip_header));\n\n if (bytes_read < sizeof(struct ip_header)) {\n l3_hdr->iov_len = 0;\n return false;\n }\n\n l3_hdr->iov_len = IP_HDR_GET_LEN(l3_hdr->iov_base);\n\n if (l3_hdr->iov_len < sizeof(struct ip_header)) {\n l3_hdr->iov_len = 0;\n return false;\n }\n\n pkt->l4proto = IP_HDR_GET_P(l3_hdr->iov_base);\n\n if (IP_HDR_GET_LEN(l3_hdr->iov_base) != sizeof(struct ip_header)) {\n \/* copy optional IPv4 header data if any*\/\n bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags,\n l2_hdr->iov_len + sizeof(struct ip_header),\n l3_hdr->iov_base + sizeof(struct ip_header),\n l3_hdr->iov_len - sizeof(struct ip_header));\n if (bytes_read < l3_hdr->iov_len - sizeof(struct ip_header)) {\n l3_hdr->iov_len = 0;\n return false;\n }\n }\n\n break;\n\n case ETH_P_IPV6:\n {\n eth_ip6_hdr_info hdrinfo;\n\n if (!eth_parse_ipv6_hdr(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,\n &hdrinfo)) {\n l3_hdr->iov_len = 0;\n return false;\n }\n\n pkt->l4proto = hdrinfo.l4proto;\n full_ip6hdr_len = hdrinfo.full_hdr_len;\n\n if (full_ip6hdr_len > ETH_MAX_IP_DGRAM_LEN) {\n l3_hdr->iov_len = 0;\n return false;\n }\n\n bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,\n l3_hdr->iov_base, full_ip6hdr_len);\n\n if (bytes_read < full_ip6hdr_len) {\n l3_hdr->iov_len = 0;\n return false;\n } else {\n l3_hdr->iov_len = full_ip6hdr_len;\n }\n break;\n }\n default:\n l3_hdr->iov_len = 0;\n break;\n }\n\n net_tx_pkt_calculate_hdr_len(pkt);\n return true;\n}","target":0,"code_token_length":912,"total_token_length":1148,"max_tokens_setting":2048} +{"idx":192978,"func":"_dbus_strerror (int error_number)\n{\n#ifdef DBUS_WINCE\n return \"unknown\";\n#else\n const char *msg;\n\n switch (error_number)\n {\n case WSAEINTR:\n return \"Interrupted function call\";\n case WSAEACCES:\n return \"Permission denied\";\n case WSAEFAULT:\n return \"Bad address\";\n case WSAEINVAL:\n return \"Invalid argument\";\n case WSAEMFILE:\n return \"Too many open files\";\n case WSAEWOULDBLOCK:\n return \"Resource temporarily unavailable\";\n case WSAEINPROGRESS:\n return \"Operation now in progress\";\n case WSAEALREADY:\n return \"Operation already in progress\";\n case WSAENOTSOCK:\n return \"Socket operation on nonsocket\";\n case WSAEDESTADDRREQ:\n return \"Destination address required\";\n case WSAEMSGSIZE:\n return \"Message too long\";\n case WSAEPROTOTYPE:\n return \"Protocol wrong type for socket\";\n case WSAENOPROTOOPT:\n return \"Bad protocol option\";\n case WSAEPROTONOSUPPORT:\n return \"Protocol not supported\";\n case WSAESOCKTNOSUPPORT:\n return \"Socket type not supported\";\n case WSAEOPNOTSUPP:\n return \"Operation not supported\";\n case WSAEPFNOSUPPORT:\n return \"Protocol family not supported\";\n case WSAEAFNOSUPPORT:\n return \"Address family not supported by protocol family\";\n case WSAEADDRINUSE:\n return \"Address already in use\";\n case WSAEADDRNOTAVAIL:\n return \"Cannot assign requested address\";\n case WSAENETDOWN:\n return \"Network is down\";\n case WSAENETUNREACH:\n return \"Network is unreachable\";\n case WSAENETRESET:\n return \"Network dropped connection on reset\";\n case WSAECONNABORTED:\n return \"Software caused connection abort\";\n case WSAECONNRESET:\n return \"Connection reset by peer\";\n case WSAENOBUFS:\n return \"No buffer space available\";\n case WSAEISCONN:\n return \"Socket is already connected\";\n case WSAENOTCONN:\n return \"Socket is not connected\";\n case WSAESHUTDOWN:\n return \"Cannot send after socket shutdown\";\n case WSAETIMEDOUT:\n return \"Connection timed out\";\n case WSAECONNREFUSED:\n return \"Connection refused\";\n case WSAEHOSTDOWN:\n return \"Host is down\";\n case WSAEHOSTUNREACH:\n return \"No route to host\";\n case WSAEPROCLIM:\n return \"Too many processes\";\n case WSAEDISCON:\n return \"Graceful shutdown in progress\";\n case WSATYPE_NOT_FOUND:\n return \"Class type not found\";\n case WSAHOST_NOT_FOUND:\n return \"Host not found\";\n case WSATRY_AGAIN:\n return \"Nonauthoritative host not found\";\n case WSANO_RECOVERY:\n return \"This is a nonrecoverable error\";\n case WSANO_DATA:\n return \"Valid name, no data record of requested type\";\n case WSA_INVALID_HANDLE:\n return \"Specified event object handle is invalid\";\n case WSA_INVALID_PARAMETER:\n return \"One or more parameters are invalid\";\n case WSA_IO_INCOMPLETE:\n return \"Overlapped I\/O event object not in signaled state\";\n case WSA_IO_PENDING:\n return \"Overlapped operations will complete later\";\n case WSA_NOT_ENOUGH_MEMORY:\n return \"Insufficient memory available\";\n case WSA_OPERATION_ABORTED:\n return \"Overlapped operation aborted\";\n#ifdef WSAINVALIDPROCTABLE\n\n case WSAINVALIDPROCTABLE:\n return \"Invalid procedure table from service provider\";\n#endif\n#ifdef WSAINVALIDPROVIDER\n\n case WSAINVALIDPROVIDER:\n return \"Invalid service provider version number\";\n#endif\n#ifdef WSAPROVIDERFAILEDINIT\n\n case WSAPROVIDERFAILEDINIT:\n return \"Unable to initialize a service provider\";\n#endif\n\n case WSASYSCALLFAILURE:\n return \"System call failure\";\n }\n msg = strerror (error_number);\n if (msg == NULL)\n msg = \"unknown\";\n\n return msg;\n#endif \/\/DBUS_WINCE\n}\n","target":0,"code_token_length":937,"total_token_length":1173,"max_tokens_setting":2048} +{"idx":407959,"func":"static int setcharset(unsigned char **p, unsigned char *charset)\n{\n setcharset_state state = CURLFNM_SCHS_DEFAULT;\n unsigned char rangestart = 0;\n unsigned char lastchar = 0;\n bool something_found = FALSE;\n unsigned char c;\n for(;;) {\n c = **p;\n if(!c)\n return SETCHARSET_FAIL;\n\n switch(state) {\n case CURLFNM_SCHS_DEFAULT:\n if(ISALNUM(c)) { \/* ASCII value *\/\n rangestart = c;\n charset[c] = 1;\n (*p)++;\n state = CURLFNM_SCHS_MAYRANGE;\n something_found = TRUE;\n }\n else if(c == ']') {\n if(something_found)\n return SETCHARSET_OK;\n something_found = TRUE;\n state = CURLFNM_SCHS_RIGHTBR;\n charset[c] = 1;\n (*p)++;\n }\n else if(c == '[') {\n char c2 = *((*p) + 1);\n if(c2 == ':') { \/* there has to be a keyword *\/\n (*p) += 2;\n if(parsekeyword(p, charset)) {\n state = CURLFNM_SCHS_DEFAULT;\n }\n else\n return SETCHARSET_FAIL;\n }\n else {\n charset[c] = 1;\n (*p)++;\n }\n something_found = TRUE;\n }\n else if(c == '?' || c == '*') {\n something_found = TRUE;\n charset[c] = 1;\n (*p)++;\n }\n else if(c == '^' || c == '!') {\n if(!something_found) {\n if(charset[CURLFNM_NEGATE]) {\n charset[c] = 1;\n something_found = TRUE;\n }\n else\n charset[CURLFNM_NEGATE] = 1; \/* negate charset *\/\n }\n else\n charset[c] = 1;\n (*p)++;\n }\n else if(c == '\\\\') {\n c = *(++(*p));\n if(ISPRINT((c))) {\n something_found = TRUE;\n state = CURLFNM_SCHS_MAYRANGE;\n charset[c] = 1;\n rangestart = c;\n (*p)++;\n }\n else\n return SETCHARSET_FAIL;\n }\n else {\n charset[c] = 1;\n (*p)++;\n something_found = TRUE;\n }\n break;\n case CURLFNM_SCHS_MAYRANGE:\n if(c == '-') {\n charset[c] = 1;\n (*p)++;\n lastchar = '-';\n state = CURLFNM_SCHS_MAYRANGE2;\n }\n else if(c == '[') {\n state = CURLFNM_SCHS_DEFAULT;\n }\n else if(ISALNUM(c)) {\n charset[c] = 1;\n (*p)++;\n }\n else if(c == '\\\\') {\n c = *(++(*p));\n if(ISPRINT(c)) {\n charset[c] = 1;\n (*p)++;\n }\n else\n return SETCHARSET_FAIL;\n }\n else if(c == ']') {\n return SETCHARSET_OK;\n }\n else\n return SETCHARSET_FAIL;\n break;\n case CURLFNM_SCHS_MAYRANGE2:\n if(c == ']') {\n return SETCHARSET_OK;\n }\n else if(c == '\\\\') {\n c = *(++(*p));\n if(ISPRINT(c)) {\n charset[c] = 1;\n state = CURLFNM_SCHS_DEFAULT;\n (*p)++;\n }\n else\n return SETCHARSET_FAIL;\n }\n else if(c >= rangestart) {\n if((ISLOWER(c) && ISLOWER(rangestart)) ||\n (ISDIGIT(c) && ISDIGIT(rangestart)) ||\n (ISUPPER(c) && ISUPPER(rangestart))) {\n charset[lastchar] = 0;\n rangestart++;\n while(rangestart++ <= c)\n charset[rangestart-1] = 1;\n (*p)++;\n state = CURLFNM_SCHS_DEFAULT;\n }\n else\n return SETCHARSET_FAIL;\n }\n else\n return SETCHARSET_FAIL;\n break;\n case CURLFNM_SCHS_RIGHTBR:\n if(c == '[') {\n state = CURLFNM_SCHS_RIGHTBRLEFTBR;\n charset[c] = 1;\n (*p)++;\n }\n else if(c == ']') {\n return SETCHARSET_OK;\n }\n else if(ISPRINT(c)) {\n charset[c] = 1;\n (*p)++;\n state = CURLFNM_SCHS_DEFAULT;\n }\n else\n \/* used 'goto fail' instead of 'return SETCHARSET_FAIL' to avoid a\n * nonsense warning 'statement not reached' at end of the fnc when\n * compiling on Solaris *\/\n goto fail;\n break;\n case CURLFNM_SCHS_RIGHTBRLEFTBR:\n if(c == ']') {\n return SETCHARSET_OK;\n }\n else {\n state = CURLFNM_SCHS_DEFAULT;\n charset[c] = 1;\n (*p)++;\n }\n break;\n }\n }\nfail:\n return SETCHARSET_FAIL;\n}","target":0,"code_token_length":1157,"total_token_length":1393,"max_tokens_setting":2048} +{"idx":25764,"func":"static void std_conv_pixmap ( fz_context * ctx , fz_pixmap * dst , fz_pixmap * src , fz_colorspace * prf , const fz_default_colorspaces * default_cs , const fz_color_params * color_params , int copy_spots ) {\n float srcv [ FZ_MAX_COLORS ] ;\n float dstv [ FZ_MAX_COLORS ] ;\n int srcn , dstn ;\n int k , i ;\n size_t w = src -> w ;\n int h = src -> h ;\n ptrdiff_t d_line_inc = dst -> stride - w * dst -> n ;\n ptrdiff_t s_line_inc = src -> stride - w * src -> n ;\n int da = dst -> alpha ;\n int sa = src -> alpha ;\n fz_colorspace * ss = src -> colorspace ;\n fz_colorspace * ds = dst -> colorspace ;\n unsigned char * s = src -> samples ;\n unsigned char * d = dst -> samples ;\n if ( ( int ) w < 0 || h < 0 ) return ;\n if ( color_params == NULL ) color_params = fz_default_color_params ( ctx ) ;\n srcn = ss -> n ;\n dstn = ds -> n ;\n assert ( src -> w == dst -> w && src -> h == dst -> h ) ;\n assert ( src -> n == srcn + sa ) ;\n assert ( dst -> n == dstn + da ) ;\n if ( d_line_inc == 0 && s_line_inc == 0 ) {\n w *= h ;\n h = 1 ;\n }\n if ( ( fz_colorspace_is_lab ( ctx , ss ) || fz_colorspace_is_lab_icc ( ctx , ss ) ) && srcn == 3 ) {\n fz_color_converter cc ;\n fz_find_color_converter ( ctx , & cc , NULL , ds , ss , color_params ) ;\n while ( h -- ) {\n size_t ww = w ;\n while ( ww -- ) {\n srcv [ 0 ] = * s ++ \/ 255.0f * 100 ;\n srcv [ 1 ] = * s ++ - 128 ;\n srcv [ 2 ] = * s ++ - 128 ;\n cc . convert ( ctx , & cc , dstv , srcv ) ;\n for ( k = 0 ;\n k < dstn ;\n k ++ ) * d ++ = dstv [ k ] * 255 ;\n if ( da ) * d ++ = ( sa ? * s : 255 ) ;\n s += sa ;\n }\n d += d_line_inc ;\n s += s_line_inc ;\n }\n fz_drop_color_converter ( ctx , & cc ) ;\n }\n else if ( w * h < 256 ) {\n fz_color_converter cc ;\n fz_find_color_converter ( ctx , & cc , NULL , ds , ss , color_params ) ;\n while ( h -- ) {\n size_t ww = w ;\n while ( ww -- ) {\n for ( k = 0 ;\n k < srcn ;\n k ++ ) srcv [ k ] = * s ++ \/ 255.0f ;\n cc . convert ( ctx , & cc , dstv , srcv ) ;\n for ( k = 0 ;\n k < dstn ;\n k ++ ) * d ++ = dstv [ k ] * 255 ;\n if ( da ) * d ++ = ( sa ? * s : 255 ) ;\n s += sa ;\n }\n d += d_line_inc ;\n s += s_line_inc ;\n }\n fz_drop_color_converter ( ctx , & cc ) ;\n }\n else if ( srcn == 1 ) {\n unsigned char lookup [ FZ_MAX_COLORS * 256 ] ;\n fz_color_converter cc ;\n fz_find_color_converter ( ctx , & cc , NULL , ds , ss , color_params ) ;\n for ( i = 0 ;\n i < 256 ;\n i ++ ) {\n srcv [ 0 ] = i \/ 255.0f ;\n cc . convert ( ctx , & cc , dstv , srcv ) ;\n for ( k = 0 ;\n k < dstn ;\n k ++ ) lookup [ i * dstn + k ] = dstv [ k ] * 255 ;\n }\n fz_drop_color_converter ( ctx , & cc ) ;\n while ( h -- ) {\n size_t ww = w ;\n while ( ww -- ) {\n i = * s ++ ;\n for ( k = 0 ;\n k < dstn ;\n k ++ ) * d ++ = lookup [ i * dstn + k ] ;\n if ( da ) * d ++ = ( sa ? * s : 255 ) ;\n s += sa ;\n }\n d += d_line_inc ;\n s += s_line_inc ;\n }\n }\n else {\n fz_hash_table * lookup ;\n unsigned char * color ;\n unsigned char dummy = s [ 0 ] ^ 255 ;\n unsigned char * sold = & dummy ;\n unsigned char * dold ;\n fz_color_converter cc ;\n lookup = fz_new_hash_table ( ctx , 509 , srcn , - 1 , NULL ) ;\n fz_find_color_converter ( ctx , & cc , NULL , ds , ss , color_params ) ;\n fz_try ( ctx ) {\n while ( h -- ) {\n size_t ww = w ;\n while ( ww -- ) {\n if ( * s == * sold && memcmp ( sold , s , srcn ) == 0 ) {\n sold = s ;\n memcpy ( d , dold , dstn ) ;\n d += dstn ;\n s += srcn ;\n if ( da ) * d ++ = ( sa ? * s : 255 ) ;\n s += sa ;\n }\n else {\n sold = s ;\n dold = d ;\n color = fz_hash_find ( ctx , lookup , s ) ;\n if ( color ) {\n memcpy ( d , color , dstn ) ;\n s += srcn ;\n d += dstn ;\n if ( da ) * d ++ = ( sa ? * s : 255 ) ;\n s += sa ;\n }\n else {\n for ( k = 0 ;\n k < srcn ;\n k ++ ) srcv [ k ] = * s ++ \/ 255.0f ;\n cc . convert ( ctx , & cc , dstv , srcv ) ;\n for ( k = 0 ;\n k < dstn ;\n k ++ ) * d ++ = dstv [ k ] * 255 ;\n fz_hash_insert ( ctx , lookup , s - srcn , d - dstn ) ;\n if ( da ) * d ++ = ( sa ? * s : 255 ) ;\n s += sa ;\n }\n }\n }\n d += d_line_inc ;\n s += s_line_inc ;\n }\n }\n fz_always ( ctx ) fz_drop_color_converter ( ctx , & cc ) ;\n fz_catch ( ctx ) fz_rethrow ( ctx ) ;\n fz_drop_hash_table ( ctx , lookup ) ;\n }\n }","target":0,"code_token_length":1408,"total_token_length":1644,"max_tokens_setting":2048} +{"idx":136573,"func":"PHP_FUNCTION(imageloadfont)\n{\n\tchar *file;\n\tint file_name, hdr_size = sizeof(gdFont) - sizeof(char *);\n\tint ind, body_size, n = 0, b, i, body_size_check;\n\tgdFontPtr font;\n\tphp_stream *stream;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"p\", &file, &file_name) == FAILURE) {\n\t\treturn;\n\t}\n\n\tstream = php_stream_open_wrapper(file, \"rb\", IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL);\n\tif (stream == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* Only supports a architecture-dependent binary dump format\n\t * at the moment.\n\t * The file format is like this on machines with 32-byte integers:\n\t *\n\t * byte 0-3: (int) number of characters in the font\n\t * byte 4-7: (int) value of first character in the font (often 32, space)\n\t * byte 8-11: (int) pixel width of each character\n\t * byte 12-15: (int) pixel height of each character\n\t * bytes 16-: (char) array with character data, one byte per pixel\n\t * in each character, for a total of\n\t * (nchars*width*height) bytes.\n\t *\/\n\tfont = (gdFontPtr) emalloc(sizeof(gdFont));\n\tb = 0;\n\twhile (b < hdr_size && (n = php_stream_read(stream, (char*)&font[b], hdr_size - b))) {\n\t\tb += n;\n\t}\n\n\tif (!n) {\n\t\tefree(font);\n\t\tif (php_stream_eof(stream)) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"End of file while reading header\");\n\t\t} else {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Error while reading header\");\n\t\t}\n\t\tphp_stream_close(stream);\n\t\tRETURN_FALSE;\n\t}\n\ti = php_stream_tell(stream);\n\tphp_stream_seek(stream, 0, SEEK_END);\n\tbody_size_check = php_stream_tell(stream) - hdr_size;\n\tphp_stream_seek(stream, i, SEEK_SET);\n\n\tbody_size = font->w * font->h * font->nchars;\n\tif (body_size != body_size_check) {\n\t\tfont->w = FLIPWORD(font->w);\n\t\tfont->h = FLIPWORD(font->h);\n\t\tfont->nchars = FLIPWORD(font->nchars);\n\t\tbody_size = font->w * font->h * font->nchars;\n\t}\n\n\tif (overflow2(font->nchars, font->h) || overflow2(font->nchars * font->h, font->w )) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Error reading font, invalid font header\");\n\t\tefree(font);\n\t\tphp_stream_close(stream);\n\t\tRETURN_FALSE;\n\t}\n\n\tif (body_size != body_size_check) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Error reading font\");\n\t\tefree(font);\n\t\tphp_stream_close(stream);\n\t\tRETURN_FALSE;\n\t}\n\n\tfont->data = emalloc(body_size);\n\tb = 0;\n\twhile (b < body_size && (n = php_stream_read(stream, &font->data[b], body_size - b))) {\n\t\tb += n;\n\t}\n\n\tif (!n) {\n\t\tefree(font->data);\n\t\tefree(font);\n\t\tif (php_stream_eof(stream)) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"End of file while reading body\");\n\t\t} else {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Error while reading body\");\n\t\t}\n\t\tphp_stream_close(stream);\n\t\tRETURN_FALSE;\n\t}\n\tphp_stream_close(stream);\n\n\t\/* Adding 5 to the font index so we will never have font indices\n\t * that overlap with the old fonts (with indices 1-5). The first\n\t * list index given out is always 1.\n\t *\/\n\tind = 5 + zend_list_insert(font, le_gd_font TSRMLS_CC);\n\n\tRETURN_LONG(ind);\n}","target":0,"code_token_length":891,"total_token_length":1127,"max_tokens_setting":2048} +{"idx":71040,"func":"rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,\n\t\t\t struct ieee80211_bss_conf *bss_conf, u32 changed)\n{\n\tstruct rtl8xxxu_priv *priv = hw->priv;\n\tstruct device *dev = &priv->udev->dev;\n\tstruct ieee80211_sta *sta;\n\tu32 val32;\n\tu8 val8;\n\n\tif (changed & BSS_CHANGED_ASSOC) {\n\t\tdev_dbg(dev, \"Changed ASSOC: %i!\\n\", bss_conf->assoc);\n\n\t\trtl8xxxu_set_linktype(priv, vif->type);\n\n\t\tif (bss_conf->assoc) {\n\t\t\tu32 ramask;\n\t\t\tint sgi = 0;\n\n\t\t\trcu_read_lock();\n\t\t\tsta = ieee80211_find_sta(vif, bss_conf->bssid);\n\t\t\tif (!sta) {\n\t\t\t\tdev_info(dev, \"%s: ASSOC no sta found\\n\",\n\t\t\t\t\t __func__);\n\t\t\t\trcu_read_unlock();\n\t\t\t\tgoto error;\n\t\t\t}\n\n\t\t\tif (sta->ht_cap.ht_supported)\n\t\t\t\tdev_info(dev, \"%s: HT supported\\n\", __func__);\n\t\t\tif (sta->vht_cap.vht_supported)\n\t\t\t\tdev_info(dev, \"%s: VHT supported\\n\", __func__);\n\n\t\t\t\/* TODO: Set bits 28-31 for rate adaptive id *\/\n\t\t\tramask = (sta->supp_rates[0] & 0xfff) |\n\t\t\t\tsta->ht_cap.mcs.rx_mask[0] << 12 |\n\t\t\t\tsta->ht_cap.mcs.rx_mask[1] << 20;\n\t\t\tif (sta->ht_cap.cap &\n\t\t\t (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))\n\t\t\t\tsgi = 1;\n\t\t\trcu_read_unlock();\n\n\t\t\tpriv->fops->update_rate_mask(priv, ramask, sgi);\n\n\t\t\trtl8xxxu_write8(priv, REG_BCN_MAX_ERR, 0xff);\n\n\t\t\trtl8xxxu_stop_tx_beacon(priv);\n\n\t\t\t\/* joinbss sequence *\/\n\t\t\trtl8xxxu_write16(priv, REG_BCN_PSR_RPT,\n\t\t\t\t\t 0xc000 | bss_conf->aid);\n\n\t\t\tpriv->fops->report_connect(priv, 0, true);\n\t\t} else {\n\t\t\tval8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL);\n\t\t\tval8 |= BEACON_DISABLE_TSF_UPDATE;\n\t\t\trtl8xxxu_write8(priv, REG_BEACON_CTRL, val8);\n\n\t\t\tpriv->fops->report_connect(priv, 0, false);\n\t\t}\n\t}\n\n\tif (changed & BSS_CHANGED_ERP_PREAMBLE) {\n\t\tdev_dbg(dev, \"Changed ERP_PREAMBLE: Use short preamble %i\\n\",\n\t\t\tbss_conf->use_short_preamble);\n\t\tval32 = rtl8xxxu_read32(priv, REG_RESPONSE_RATE_SET);\n\t\tif (bss_conf->use_short_preamble)\n\t\t\tval32 |= RSR_ACK_SHORT_PREAMBLE;\n\t\telse\n\t\t\tval32 &= ~RSR_ACK_SHORT_PREAMBLE;\n\t\trtl8xxxu_write32(priv, REG_RESPONSE_RATE_SET, val32);\n\t}\n\n\tif (changed & BSS_CHANGED_ERP_SLOT) {\n\t\tdev_dbg(dev, \"Changed ERP_SLOT: short_slot_time %i\\n\",\n\t\t\tbss_conf->use_short_slot);\n\n\t\tif (bss_conf->use_short_slot)\n\t\t\tval8 = 9;\n\t\telse\n\t\t\tval8 = 20;\n\t\trtl8xxxu_write8(priv, REG_SLOT, val8);\n\t}\n\n\tif (changed & BSS_CHANGED_BSSID) {\n\t\tdev_dbg(dev, \"Changed BSSID!\\n\");\n\t\trtl8xxxu_set_bssid(priv, bss_conf->bssid);\n\t}\n\n\tif (changed & BSS_CHANGED_BASIC_RATES) {\n\t\tdev_dbg(dev, \"Changed BASIC_RATES!\\n\");\n\t\trtl8xxxu_set_basic_rates(priv, bss_conf->basic_rates);\n\t}\nerror:\n\treturn;\n}","target":0,"code_token_length":903,"total_token_length":1139,"max_tokens_setting":2048} +{"idx":70160,"func":"bool Unpack::UnpackLargeBlock(UnpackThreadData &D)\n{\n if (!D.TableRead)\n {\n D.TableRead=true;\n if (!ReadTables(D.Inp,D.BlockHeader,D.BlockTables))\n {\n D.DamagedData=true;\n return false;\n }\n }\n\n if (D.Inp.InAddr>D.BlockHeader.HeaderSize+D.BlockHeader.BlockSize)\n {\n D.DamagedData=true;\n return false;\n }\n \n int BlockBorder=D.BlockHeader.BlockStart+D.BlockHeader.BlockSize-1;\n\n \/\/ Reserve enough space even for filter entry.\n int DataBorder=D.DataSize-16;\n int ReadBorder=Min(BlockBorder,DataBorder);\n\n while (true)\n {\n UnpPtr&=MaxWinMask;\n if (D.Inp.InAddr>=ReadBorder)\n {\n if (D.Inp.InAddr>BlockBorder || D.Inp.InAddr==BlockBorder && \n D.Inp.InBit>=D.BlockHeader.BlockBitSize)\n break;\n\n \/\/ If we do not have any more data in file to read, we must process\n \/\/ what we have until last byte. Otherwise we can return and append\n \/\/ more data to unprocessed few bytes.\n if ((D.Inp.InAddr>=DataBorder) && !D.NoDataLeft || D.Inp.InAddr>=D.DataSize)\n {\n D.Incomplete=true;\n break;\n }\n }\n if (((WriteBorder-UnpPtr) & MaxWinMask)DestUnpSize)\n return false;\n }\n\n uint MainSlot=DecodeNumber(D.Inp,&D.BlockTables.LD);\n if (MainSlot<256)\n {\n Window[UnpPtr++]=(byte)MainSlot;\n continue;\n }\n if (MainSlot>=262)\n {\n uint Length=SlotToLength(D.Inp,MainSlot-262);\n\n uint DBits,Distance=1,DistSlot=DecodeNumber(D.Inp,&D.BlockTables.DD);\n if (DistSlot<4)\n {\n DBits=0;\n Distance+=DistSlot;\n }\n else\n {\n DBits=DistSlot\/2 - 1;\n Distance+=(2 | (DistSlot & 1)) << DBits;\n }\n\n if (DBits>0)\n {\n if (DBits>=4)\n {\n if (DBits>4)\n {\n Distance+=((D.Inp.getbits32()>>(36-DBits))<<4);\n D.Inp.addbits(DBits-4);\n }\n uint LowDist=DecodeNumber(D.Inp,&D.BlockTables.LDD);\n Distance+=LowDist;\n }\n else\n {\n Distance+=D.Inp.getbits32()>>(32-DBits);\n D.Inp.addbits(DBits);\n }\n }\n\n if (Distance>0x100)\n {\n Length++;\n if (Distance>0x2000)\n {\n Length++;\n if (Distance>0x40000)\n Length++;\n }\n }\n\n InsertOldDist(Distance);\n LastLength=Length;\n CopyString(Length,Distance);\n continue;\n }\n if (MainSlot==256)\n {\n UnpackFilter Filter;\n if (!ReadFilter(D.Inp,Filter) || !AddFilter(Filter))\n break;\n continue;\n }\n if (MainSlot==257)\n {\n if (LastLength!=0)\n CopyString(LastLength,OldDist[0]);\n continue;\n }\n if (MainSlot<262)\n {\n uint DistNum=MainSlot-258;\n uint Distance=OldDist[DistNum];\n for (uint I=DistNum;I>0;I--)\n OldDist[I]=OldDist[I-1];\n OldDist[0]=Distance;\n\n uint LengthSlot=DecodeNumber(D.Inp,&D.BlockTables.RD);\n uint Length=SlotToLength(D.Inp,LengthSlot);\n LastLength=Length;\n CopyString(Length,Distance);\n continue;\n }\n }\n return true;\n}","target":0,"code_token_length":931,"total_token_length":1167,"max_tokens_setting":2048} +{"idx":68224,"func":"int nntp_open_connection(struct NntpAccountData *adata)\n{\n struct Connection *conn = adata->conn;\n char buf[256];\n int cap;\n bool posting = false, auth = true;\n\n if (adata->status == NNTP_OK)\n return 0;\n if (adata->status == NNTP_BYE)\n return -1;\n adata->status = NNTP_NONE;\n\n if (mutt_socket_open(conn) < 0)\n return -1;\n\n if (mutt_socket_readln(buf, sizeof(buf), conn) < 0)\n return nntp_connect_error(adata);\n\n if (mutt_str_startswith(buf, \"200\", CASE_MATCH))\n posting = true;\n else if (!mutt_str_startswith(buf, \"201\", CASE_MATCH))\n {\n mutt_socket_close(conn);\n mutt_str_remove_trailing_ws(buf);\n mutt_error(\"%s\", buf);\n return -1;\n }\n\n \/* get initial capabilities *\/\n cap = nntp_capabilities(adata);\n if (cap < 0)\n return -1;\n\n \/* tell news server to switch to mode reader if it isn't so *\/\n if (cap > 0)\n {\n if ((mutt_socket_send(conn, \"MODE READER\\r\\n\") < 0) ||\n (mutt_socket_readln(buf, sizeof(buf), conn) < 0))\n {\n return nntp_connect_error(adata);\n }\n\n if (mutt_str_startswith(buf, \"200\", CASE_MATCH))\n posting = true;\n else if (mutt_str_startswith(buf, \"201\", CASE_MATCH))\n posting = false;\n \/* error if has capabilities, ignore result if no capabilities *\/\n else if (adata->hasCAPABILITIES)\n {\n mutt_socket_close(conn);\n mutt_error(_(\"Could not switch to reader mode\"));\n return -1;\n }\n\n \/* recheck capabilities after MODE READER *\/\n if (adata->hasCAPABILITIES)\n {\n cap = nntp_capabilities(adata);\n if (cap < 0)\n return -1;\n }\n }\n\n mutt_message(_(\"Connected to %s. %s\"), conn->account.host,\n posting ? _(\"Posting is ok\") : _(\"Posting is NOT ok\"));\n mutt_sleep(1);\n\n#ifdef USE_SSL\n \/* Attempt STARTTLS if available and desired. *\/\n if ((adata->use_tls != 1) && (adata->hasSTARTTLS || C_SslForceTls))\n {\n if (adata->use_tls == 0)\n {\n adata->use_tls =\n C_SslForceTls || query_quadoption(C_SslStarttls,\n _(\"Secure connection with TLS?\")) == MUTT_YES ?\n 2 :\n 1;\n }\n if (adata->use_tls == 2)\n {\n if ((mutt_socket_send(conn, \"STARTTLS\\r\\n\") < 0) ||\n (mutt_socket_readln(buf, sizeof(buf), conn) < 0))\n {\n return nntp_connect_error(adata);\n }\n \/\/ Clear any data after the STARTTLS acknowledgement\n mutt_socket_empty(conn);\n if (!mutt_str_startswith(buf, \"382\", CASE_MATCH))\n {\n adata->use_tls = 0;\n mutt_error(\"STARTTLS: %s\", buf);\n }\n else if (mutt_ssl_starttls(conn))\n {\n adata->use_tls = 0;\n adata->status = NNTP_NONE;\n mutt_socket_close(adata->conn);\n mutt_error(_(\"Could not negotiate TLS connection\"));\n return -1;\n }\n else\n {\n \/* recheck capabilities after STARTTLS *\/\n cap = nntp_capabilities(adata);\n if (cap < 0)\n return -1;\n }\n }\n }\n#endif\n\n \/* authentication required? *\/\n if (conn->account.flags & MUTT_ACCT_USER)\n {\n if (!conn->account.user[0])\n auth = false;\n }\n else\n {\n if ((mutt_socket_send(conn, \"STAT\\r\\n\") < 0) ||\n (mutt_socket_readln(buf, sizeof(buf), conn) < 0))\n {\n return nntp_connect_error(adata);\n }\n if (!mutt_str_startswith(buf, \"480\", CASE_MATCH))\n auth = false;\n }\n\n \/* authenticate *\/\n if (auth && (nntp_auth(adata) < 0))\n return -1;\n\n \/* get final capabilities after authentication *\/\n if (adata->hasCAPABILITIES && (auth || (cap > 0)))\n {\n cap = nntp_capabilities(adata);\n if (cap < 0)\n return -1;\n if (cap > 0)\n {\n mutt_socket_close(conn);\n mutt_error(_(\"Could not switch to reader mode\"));\n return -1;\n }\n }\n\n \/* attempt features *\/\n if (nntp_attempt_features(adata) < 0)\n return -1;\n\n adata->status = NNTP_OK;\n return 0;\n}","target":0,"code_token_length":1114,"total_token_length":1350,"max_tokens_setting":2048} +{"idx":382400,"func":"pg_stat_get_wal_senders(PG_FUNCTION_ARGS)\n{\n#define PG_STAT_GET_WAL_SENDERS_COLS\t8\n\tReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;\n\tTupleDesc\ttupdesc;\n\tTuplestorestate *tupstore;\n\tMemoryContext per_query_ctx;\n\tMemoryContext oldcontext;\n\tWalSnd\t *sync_standby;\n\tint\t\t\ti;\n\n\t\/* check to see if caller supports us returning a tuplestore *\/\n\tif (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"set-valued function called in context that cannot accept a set\")));\n\tif (!(rsinfo->allowedModes & SFRM_Materialize))\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"materialize mode required, but it is not \" \\\n\t\t\t\t\t\t\"allowed in this context\")));\n\n\t\/* Build a tuple descriptor for our result type *\/\n\tif (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)\n\t\telog(ERROR, \"return type must be a row type\");\n\n\tper_query_ctx = rsinfo->econtext->ecxt_per_query_memory;\n\toldcontext = MemoryContextSwitchTo(per_query_ctx);\n\n\ttupstore = tuplestore_begin_heap(true, false, work_mem);\n\trsinfo->returnMode = SFRM_Materialize;\n\trsinfo->setResult = tupstore;\n\trsinfo->setDesc = tupdesc;\n\n\tMemoryContextSwitchTo(oldcontext);\n\n\t\/*\n\t * Get the currently active synchronous standby.\n\t *\/\n\tLWLockAcquire(SyncRepLock, LW_SHARED);\n\tsync_standby = SyncRepGetSynchronousStandby();\n\tLWLockRelease(SyncRepLock);\n\n\tfor (i = 0; i < max_wal_senders; i++)\n\t{\n\t\t\/* use volatile pointer to prevent code rearrangement *\/\n\t\tvolatile WalSnd *walsnd = &WalSndCtl->walsnds[i];\n\t\tXLogRecPtr\tsentPtr;\n\t\tXLogRecPtr\twrite;\n\t\tXLogRecPtr\tflush;\n\t\tXLogRecPtr\tapply;\n\t\tint\t\t\tpriority;\n\t\tWalSndState state;\n\t\tDatum\t\tvalues[PG_STAT_GET_WAL_SENDERS_COLS];\n\t\tbool\t\tnulls[PG_STAT_GET_WAL_SENDERS_COLS];\n\n\t\tif (walsnd->pid == 0)\n\t\t\tcontinue;\n\n\t\tSpinLockAcquire(&walsnd->mutex);\n\t\tsentPtr = walsnd->sentPtr;\n\t\tstate = walsnd->state;\n\t\twrite = walsnd->write;\n\t\tflush = walsnd->flush;\n\t\tapply = walsnd->apply;\n\t\tpriority = walsnd->sync_standby_priority;\n\t\tSpinLockRelease(&walsnd->mutex);\n\n\t\tmemset(nulls, 0, sizeof(nulls));\n\t\tvalues[0] = Int32GetDatum(walsnd->pid);\n\n\t\tif (!superuser())\n\t\t{\n\t\t\t\/*\n\t\t\t * Only superusers can see details. Other users only get the pid\n\t\t\t * value to know it's a walsender, but no details.\n\t\t\t *\/\n\t\t\tMemSet(&nulls[1], true, PG_STAT_GET_WAL_SENDERS_COLS - 1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvalues[1] = CStringGetTextDatum(WalSndGetStateString(state));\n\t\t\tvalues[2] = LSNGetDatum(sentPtr);\n\n\t\t\tif (write == 0)\n\t\t\t\tnulls[3] = true;\n\t\t\tvalues[3] = LSNGetDatum(write);\n\n\t\t\tif (flush == 0)\n\t\t\t\tnulls[4] = true;\n\t\t\tvalues[4] = LSNGetDatum(flush);\n\n\t\t\tif (apply == 0)\n\t\t\t\tnulls[5] = true;\n\t\t\tvalues[5] = LSNGetDatum(apply);\n\n\t\t\t\/*\n\t\t\t * Treat a standby such as a pg_basebackup background process\n\t\t\t * which always returns an invalid flush location, as an\n\t\t\t * asynchronous standby.\n\t\t\t *\/\n\t\t\tpriority = XLogRecPtrIsInvalid(walsnd->flush) ? 0 : priority;\n\n\t\t\tvalues[6] = Int32GetDatum(priority);\n\n\t\t\t\/*\n\t\t\t * More easily understood version of standby state. This is purely\n\t\t\t * informational, not different from priority.\n\t\t\t *\/\n\t\t\tif (priority == 0)\n\t\t\t\tvalues[7] = CStringGetTextDatum(\"async\");\n\t\t\telse if (walsnd == sync_standby)\n\t\t\t\tvalues[7] = CStringGetTextDatum(\"sync\");\n\t\t\telse\n\t\t\t\tvalues[7] = CStringGetTextDatum(\"potential\");\n\t\t}\n\n\t\ttuplestore_putvalues(tupstore, tupdesc, values, nulls);\n\t}\n\n\t\/* clean up and return the tuplestore *\/\n\ttuplestore_donestoring(tupstore);\n\n\treturn (Datum) 0;\n}","target":0,"code_token_length":1052,"total_token_length":1288,"max_tokens_setting":2048} +{"idx":17081,"func":"TEST_F ( ShortcutsBackendTest , DeleteShortcuts ) {\n InitBackend ( ) ;\n ShortcutsDatabase : : Shortcut shortcut1 ( \"BD85DBA2-8C29-49F9-84AE-48E1E90880DF\" , base : : ASCIIToUTF16 ( \"goog\" ) , MatchCoreForTesting ( \"http:\/\/www.google.com\" ) , base : : Time : : Now ( ) , 100 ) ;\n EXPECT_TRUE ( AddShortcut ( shortcut1 ) ) ;\n ShortcutsDatabase : : Shortcut shortcut2 ( \"BD85DBA2-8C29-49F9-84AE-48E1E90880E0\" , base : : ASCIIToUTF16 ( \"gle\" ) , MatchCoreForTesting ( \"http:\/\/www.google.com\" ) , base : : Time : : Now ( ) , 100 ) ;\n EXPECT_TRUE ( AddShortcut ( shortcut2 ) ) ;\n ShortcutsDatabase : : Shortcut shortcut3 ( \"BD85DBA2-8C29-49F9-84AE-48E1E90880E1\" , base : : ASCIIToUTF16 ( \"sp\" ) , MatchCoreForTesting ( \"http:\/\/www.sport.com\" ) , base : : Time : : Now ( ) , 10 ) ;\n EXPECT_TRUE ( AddShortcut ( shortcut3 ) ) ;\n ShortcutsDatabase : : Shortcut shortcut4 ( \"BD85DBA2-8C29-49F9-84AE-48E1E90880E2\" , base : : ASCIIToUTF16 ( \"mov\" ) , MatchCoreForTesting ( \"http:\/\/www.film.com\" ) , base : : Time : : Now ( ) , 10 ) ;\n EXPECT_TRUE ( AddShortcut ( shortcut4 ) ) ;\n ASSERT_EQ ( 4U , shortcuts_map ( ) . size ( ) ) ;\n EXPECT_EQ ( shortcut1 . id , shortcuts_map ( ) . find ( shortcut1 . text ) -> second . id ) ;\n EXPECT_EQ ( shortcut2 . id , shortcuts_map ( ) . find ( shortcut2 . text ) -> second . id ) ;\n EXPECT_EQ ( shortcut3 . id , shortcuts_map ( ) . find ( shortcut3 . text ) -> second . id ) ;\n EXPECT_EQ ( shortcut4 . id , shortcuts_map ( ) . find ( shortcut4 . text ) -> second . id ) ;\n EXPECT_TRUE ( DeleteShortcutsWithURL ( shortcut1 . match_core . destination_url ) ) ;\n ASSERT_EQ ( 2U , shortcuts_map ( ) . size ( ) ) ;\n EXPECT_EQ ( 0U , shortcuts_map ( ) . count ( shortcut1 . text ) ) ;\n EXPECT_EQ ( 0U , shortcuts_map ( ) . count ( shortcut2 . text ) ) ;\n const ShortcutsBackend : : ShortcutMap : : const_iterator shortcut3_iter ( shortcuts_map ( ) . find ( shortcut3 . text ) ) ;\n ASSERT_TRUE ( shortcut3_iter != shortcuts_map ( ) . end ( ) ) ;\n EXPECT_EQ ( shortcut3 . id , shortcut3_iter -> second . id ) ;\n const ShortcutsBackend : : ShortcutMap : : const_iterator shortcut4_iter ( shortcuts_map ( ) . find ( shortcut4 . text ) ) ;\n ASSERT_TRUE ( shortcut4_iter != shortcuts_map ( ) . end ( ) ) ;\n EXPECT_EQ ( shortcut4 . id , shortcut4_iter -> second . id ) ;\n ShortcutsDatabase : : ShortcutIDs deleted_ids ;\n deleted_ids . push_back ( shortcut3 . id ) ;\n deleted_ids . push_back ( shortcut4 . id ) ;\n EXPECT_TRUE ( DeleteShortcutsWithIDs ( deleted_ids ) ) ;\n ASSERT_EQ ( 0U , shortcuts_map ( ) . size ( ) ) ;\n }","target":0,"code_token_length":818,"total_token_length":1054,"max_tokens_setting":2048} +{"idx":143691,"func":"static void WritePixels(struct ngiflib_img * i, struct ngiflib_decode_context * context, const u8 * pixels, u16 n) {\n\tu16 tocopy;\t\n\tstruct ngiflib_gif * p = i->parent;\n\n\twhile(n > 0) {\n\t\ttocopy = (context->Xtogo < n) ? context->Xtogo : n;\n\t\tif(!i->gce.transparent_flag) {\n#ifndef NGIFLIB_INDEXED_ONLY\n\t\t\tif(p->mode & NGIFLIB_MODE_INDEXED) {\n#endif \/* NGIFLIB_INDEXED_ONLY *\/\n\t\t\t\tngiflib_memcpy(context->frbuff_p.p8, pixels, tocopy);\n\t\t\t\tpixels += tocopy;\n\t\t\t\tcontext->frbuff_p.p8 += tocopy;\n#ifndef NGIFLIB_INDEXED_ONLY\n\t\t\t} else {\n\t\t\t\tint j;\n\t\t\t\tfor(j = (int)tocopy; j > 0; j--) {\n\t\t\t\t\t*(context->frbuff_p.p32++) =\n\t\t\t\t\t GifIndexToTrueColor(i->palette, *pixels++);\n\t\t\t\t}\n\t\t\t}\n#endif \/* NGIFLIB_INDEXED_ONLY *\/\n\t\t} else {\n\t\t\tint j;\n#ifndef NGIFLIB_INDEXED_ONLY\n\t\t\tif(p->mode & NGIFLIB_MODE_INDEXED) {\n#endif \/* NGIFLIB_INDEXED_ONLY *\/\n\t\t\t\tfor(j = (int)tocopy; j > 0; j--) {\n\t\t\t\t\tif(*pixels != i->gce.transparent_color) *context->frbuff_p.p8 = *pixels;\n\t\t\t\t\tpixels++;\n\t\t\t\t\tcontext->frbuff_p.p8++;\n\t\t\t\t}\n#ifndef NGIFLIB_INDEXED_ONLY\n\t\t\t} else {\n\t\t\t\tfor(j = (int)tocopy; j > 0; j--) {\n\t\t\t\t\tif(*pixels != i->gce.transparent_color) {\n\t\t\t\t\t\t*context->frbuff_p.p32 = GifIndexToTrueColor(i->palette, *pixels);\n\t\t\t\t\t}\n\t\t\t\t\tpixels++;\n\t\t\t\t\tcontext->frbuff_p.p32++;\n\t\t\t\t}\n\t\t\t}\n#endif \/* NGIFLIB_INDEXED_ONLY *\/\n\t\t}\n\t\tcontext->Xtogo -= tocopy;\n\t\tif(context->Xtogo == 0) {\n\t\t\t#ifdef NGIFLIB_ENABLE_CALLBACKS\n\t\t\tif(p->line_cb) p->line_cb(p, context->line_p, context->curY);\n\t\t\t#endif \/* NGIFLIB_ENABLE_CALLBACKS *\/\n\t\t\tcontext->Xtogo = i->width;\n\t\t\tswitch(context->pass) {\n\t\t\tcase 0:\n\t\t\t\tcontext->curY++;\n\t\t\t\tbreak;\n\t\t\tcase 1:\t\/* 1st pass : every eighth row starting from 0 *\/\n\t\t\t\tcontext->curY += 8;\n\t\t\t\tbreak;\n\t\t\tcase 2:\t\/* 2nd pass : every eighth row starting from 4 *\/\n\t\t\t\tcontext->curY += 8;\n\t\t\t\tbreak;\n\t\t\tcase 3:\t\/* 3rd pass : every fourth row starting from 2 *\/\n\t\t\t\tcontext->curY += 4;\n\t\t\t\tbreak;\n\t\t\tcase 4:\t\/* 4th pass : every odd row *\/\n\t\t\t\tcontext->curY += 2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\twhile(context->pass > 0 && context->pass < 4 &&\n\t\t\t context->curY >= p->height) {\n\t\t\t\tswitch(++context->pass) {\n\t\t\t\tcase 2:\t\/* 2nd pass : every eighth row starting from 4 *\/\n\t\t\t\t\tcontext->curY = i->posY + 4;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\t\/* 3rd pass : every fourth row starting from 2 *\/\n\t\t\t\t\tcontext->curY = i->posY + 2;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\t\/* 4th pass : every odd row *\/\n\t\t\t\t\tcontext->curY = i->posY + 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n#ifndef NGIFLIB_INDEXED_ONLY\n\t\t\tif(p->mode & NGIFLIB_MODE_INDEXED) {\n#endif \/* NGIFLIB_INDEXED_ONLY *\/\n\t\t\t\t#ifdef NGIFLIB_ENABLE_CALLBACKS\n\t\t\t\tcontext->line_p.p8 = p->frbuff.p8 + (u32)context->curY*p->width;\n\t\t\t\tcontext->frbuff_p.p8 = context->line_p.p8 + i->posX;\n\t\t\t\t#else\n\t\t\t\tcontext->frbuff_p.p8 = p->frbuff.p8 + (u32)context->curY*p->width + i->posX;\n\t\t\t\t#endif \/* NGIFLIB_ENABLE_CALLBACKS *\/\n#ifndef NGIFLIB_INDEXED_ONLY\n\t\t\t} else {\n\t\t\t\t#ifdef NGIFLIB_ENABLE_CALLBACKS\n\t\t\t\tcontext->line_p.p32 = p->frbuff.p32 + (u32)context->curY*p->width;\n\t\t\t\tcontext->frbuff_p.p32 = context->line_p.p32 + i->posX;\n\t\t\t\t#else\n\t\t\t\tcontext->frbuff_p.p32 = p->frbuff.p32 + (u32)context->curY*p->width + i->posX;\n\t\t\t\t#endif \/* NGIFLIB_ENABLE_CALLBACKS *\/\n\t\t\t}\n#endif \/* NGIFLIB_INDEXED_ONLY *\/\n\t\t}\n\t\tn -= tocopy;\n\t}\n}","target":0,"code_token_length":1105,"total_token_length":1341,"max_tokens_setting":2048} +{"idx":145,"func":"static void _UTF16LEFromUnicodeWithOffsets ( UConverterFromUnicodeArgs * pArgs , UErrorCode * pErrorCode ) {\n UConverter * cnv ;\n const UChar * source ;\n char * target ;\n int32_t * offsets ;\n uint32_t targetCapacity , length , sourceIndex ;\n UChar c , trail ;\n char overflow [ 4 ] ;\n source = pArgs -> source ;\n length = ( int32_t ) ( pArgs -> sourceLimit - source ) ;\n if ( length <= 0 ) {\n return ;\n }\n cnv = pArgs -> converter ;\n if ( cnv -> fromUnicodeStatus == UCNV_NEED_TO_WRITE_BOM ) {\n static const char bom [ ] = {\n ( char ) 0xff , ( char ) 0xfe }\n ;\n ucnv_fromUWriteBytes ( cnv , bom , 2 , & pArgs -> target , pArgs -> targetLimit , & pArgs -> offsets , - 1 , pErrorCode ) ;\n cnv -> fromUnicodeStatus = 0 ;\n }\n target = pArgs -> target ;\n if ( target >= pArgs -> targetLimit ) {\n * pErrorCode = U_BUFFER_OVERFLOW_ERROR ;\n return ;\n }\n targetCapacity = ( uint32_t ) ( pArgs -> targetLimit - pArgs -> target ) ;\n offsets = pArgs -> offsets ;\n sourceIndex = 0 ;\n if ( ( c = ( UChar ) cnv -> fromUChar32 ) != 0 && U16_IS_TRAIL ( trail = * source ) && targetCapacity >= 4 ) {\n ++ source ;\n -- length ;\n target [ 0 ] = ( uint8_t ) c ;\n target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;\n target [ 2 ] = ( uint8_t ) trail ;\n target [ 3 ] = ( uint8_t ) ( trail >> 8 ) ;\n target += 4 ;\n targetCapacity -= 4 ;\n if ( offsets != NULL ) {\n * offsets ++ = - 1 ;\n * offsets ++ = - 1 ;\n * offsets ++ = - 1 ;\n * offsets ++ = - 1 ;\n }\n sourceIndex = 1 ;\n cnv -> fromUChar32 = c = 0 ;\n }\n if ( c == 0 ) {\n uint32_t count = 2 * length ;\n if ( count > targetCapacity ) {\n count = targetCapacity & ~ 1 ;\n }\n targetCapacity -= count ;\n count >>= 1 ;\n length -= count ;\n if ( offsets == NULL ) {\n while ( count > 0 ) {\n c = * source ++ ;\n if ( U16_IS_SINGLE ( c ) ) {\n target [ 0 ] = ( uint8_t ) c ;\n target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;\n target += 2 ;\n }\n else if ( U16_IS_SURROGATE_LEAD ( c ) && count >= 2 && U16_IS_TRAIL ( trail = * source ) ) {\n ++ source ;\n -- count ;\n target [ 0 ] = ( uint8_t ) c ;\n target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;\n target [ 2 ] = ( uint8_t ) trail ;\n target [ 3 ] = ( uint8_t ) ( trail >> 8 ) ;\n target += 4 ;\n }\n else {\n break ;\n }\n -- count ;\n }\n }\n else {\n while ( count > 0 ) {\n c = * source ++ ;\n if ( U16_IS_SINGLE ( c ) ) {\n target [ 0 ] = ( uint8_t ) c ;\n target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;\n target += 2 ;\n * offsets ++ = sourceIndex ;\n * offsets ++ = sourceIndex ++ ;\n }\n else if ( U16_IS_SURROGATE_LEAD ( c ) && count >= 2 && U16_IS_TRAIL ( trail = * source ) ) {\n ++ source ;\n -- count ;\n target [ 0 ] = ( uint8_t ) c ;\n target [ 1 ] = ( uint8_t ) ( c >> 8 ) ;\n target [ 2 ] = ( uint8_t ) trail ;\n target [ 3 ] = ( uint8_t ) ( trail >> 8 ) ;\n target += 4 ;\n * offsets ++ = sourceIndex ;\n * offsets ++ = sourceIndex ;\n * offsets ++ = sourceIndex ;\n * offsets ++ = sourceIndex ;\n sourceIndex += 2 ;\n }\n else {\n break ;\n }\n -- count ;\n }\n }\n if ( count == 0 ) {\n if ( length > 0 && targetCapacity > 0 ) {\n if ( U16_IS_SINGLE ( c = * source ++ ) ) {\n overflow [ 0 ] = ( char ) c ;\n overflow [ 1 ] = ( char ) ( c >> 8 ) ;\n length = 2 ;\n c = 0 ;\n }\n }\n else {\n length = 0 ;\n c = 0 ;\n }\n }\n else {\n targetCapacity += 2 * count ;\n }\n }\n else {\n length = 0 ;\n }\n if ( c != 0 ) {\n length = 0 ;\n if ( U16_IS_SURROGATE_LEAD ( c ) ) {\n if ( source < pArgs -> sourceLimit ) {\n if ( U16_IS_TRAIL ( trail = * source ) ) {\n ++ source ;\n overflow [ 0 ] = ( char ) c ;\n overflow [ 1 ] = ( char ) ( c >> 8 ) ;\n overflow [ 2 ] = ( char ) trail ;\n overflow [ 3 ] = ( char ) ( trail >> 8 ) ;\n length = 4 ;\n c = 0 ;\n }\n else {\n * pErrorCode = U_ILLEGAL_CHAR_FOUND ;\n }\n }\n else {\n }\n }\n else {\n * pErrorCode = U_ILLEGAL_CHAR_FOUND ;\n }\n cnv -> fromUChar32 = c ;\n }\n if ( length > 0 ) {\n ucnv_fromUWriteBytes ( cnv , overflow , length , & target , pArgs -> targetLimit , & offsets , sourceIndex , pErrorCode ) ;\n targetCapacity = ( uint32_t ) ( pArgs -> targetLimit - ( char * ) target ) ;\n }\n if ( U_SUCCESS ( * pErrorCode ) && source < pArgs -> sourceLimit && targetCapacity == 0 ) {\n * pErrorCode = U_BUFFER_OVERFLOW_ERROR ;\n }\n pArgs -> source = source ;\n pArgs -> target = target ;\n pArgs -> offsets = offsets ;\n }","target":1,"code_token_length":1339,"total_token_length":1575,"max_tokens_setting":2048} +{"idx":381396,"func":"static struct connectdata *allocate_conn(struct SessionHandle *data)\n{\n struct connectdata *conn = calloc(1, sizeof(struct connectdata));\n if(!conn)\n return NULL;\n\n conn->handler = &Curl_handler_dummy; \/* Be sure we have a handler defined\n already from start to avoid NULL\n situations and checks *\/\n\n \/* and we setup a few fields in case we end up actually using this struct *\/\n\n conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; \/* no file descriptor *\/\n conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; \/* no file descriptor *\/\n conn->tempsock[0] = CURL_SOCKET_BAD; \/* no file descriptor *\/\n conn->tempsock[1] = CURL_SOCKET_BAD; \/* no file descriptor *\/\n conn->connection_id = -1; \/* no ID *\/\n conn->port = -1; \/* unknown at this point *\/\n conn->remote_port = -1; \/* unknown *\/\n\n \/* Default protocol-independent behavior doesn't support persistent\n connections, so we set this to force-close. Protocols that support\n this need to set this to FALSE in their \"curl_do\" functions. *\/\n connclose(conn, \"Default to force-close\");\n\n \/* Store creation time to help future close decision making *\/\n conn->created = Curl_tvnow();\n\n conn->data = data; \/* Setup the association between this connection\n and the SessionHandle *\/\n\n conn->proxytype = data->set.proxytype; \/* type *\/\n\n#ifdef CURL_DISABLE_PROXY\n\n conn->bits.proxy = FALSE;\n conn->bits.httpproxy = FALSE;\n conn->bits.proxy_user_passwd = FALSE;\n conn->bits.tunnel_proxy = FALSE;\n\n#else \/* CURL_DISABLE_PROXY *\/\n\n \/* note that these two proxy bits are now just on what looks to be\n requested, they may be altered down the road *\/\n conn->bits.proxy = (data->set.str[STRING_PROXY] &&\n *data->set.str[STRING_PROXY])?TRUE:FALSE;\n conn->bits.httpproxy = (conn->bits.proxy &&\n (conn->proxytype == CURLPROXY_HTTP ||\n conn->proxytype == CURLPROXY_HTTP_1_0))?TRUE:FALSE;\n conn->bits.proxy_user_passwd =\n (NULL != data->set.str[STRING_PROXYUSERNAME])?TRUE:FALSE;\n conn->bits.tunnel_proxy = data->set.tunnel_thru_httpproxy;\n\n#endif \/* CURL_DISABLE_PROXY *\/\n\n conn->bits.user_passwd = (NULL != data->set.str[STRING_USERNAME])?TRUE:FALSE;\n conn->bits.ftp_use_epsv = data->set.ftp_use_epsv;\n conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;\n\n conn->verifypeer = data->set.ssl.verifypeer;\n conn->verifyhost = data->set.ssl.verifyhost;\n\n conn->ip_version = data->set.ipver;\n\n#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \\\n defined(NTLM_WB_ENABLED)\n conn->ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;\n conn->ntlm_auth_hlpr_pid = 0;\n conn->challenge_header = NULL;\n conn->response_header = NULL;\n#endif\n\n if(Curl_multi_pipeline_enabled(data->multi) &&\n !conn->master_buffer) {\n \/* Allocate master_buffer to be used for pipelining *\/\n conn->master_buffer = calloc(BUFSIZE, sizeof (char));\n if(!conn->master_buffer)\n goto error;\n }\n\n \/* Initialize the pipeline lists *\/\n conn->send_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);\n conn->recv_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);\n if(!conn->send_pipe || !conn->recv_pipe)\n goto error;\n\n#ifdef HAVE_GSSAPI\n conn->data_prot = PROT_CLEAR;\n#endif\n\n \/* Store the local bind parameters that will be used for this connection *\/\n if(data->set.str[STRING_DEVICE]) {\n conn->localdev = strdup(data->set.str[STRING_DEVICE]);\n if(!conn->localdev)\n goto error;\n }\n conn->localportrange = data->set.localportrange;\n conn->localport = data->set.localport;\n\n \/* the close socket stuff needs to be copied to the connection struct as\n it may live on without (this specific) SessionHandle *\/\n conn->fclosesocket = data->set.fclosesocket;\n conn->closesocket_client = data->set.closesocket_client;\n\n return conn;\n error:\n\n Curl_llist_destroy(conn->send_pipe, NULL);\n Curl_llist_destroy(conn->recv_pipe, NULL);\n\n conn->send_pipe = NULL;\n conn->recv_pipe = NULL;\n\n Curl_safefree(conn->master_buffer);\n Curl_safefree(conn->localdev);\n Curl_safefree(conn);\n return NULL;\n}","target":0,"code_token_length":1076,"total_token_length":1312,"max_tokens_setting":2048} +{"idx":470288,"func":"static void textview_write_line(TextView *textview, const gchar *str,\n\t\t\t\tCodeConverter *conv, gboolean do_quote_folding)\n{\n\tGtkTextView *text;\n\tGtkTextBuffer *buffer;\n\tGtkTextIter iter;\n\tgchar buf[BUFFSIZE];\n\tgchar *fg_color;\n\tgint quotelevel = -1, real_quotelevel = -1;\n\tgchar quote_tag_str[10];\n\n\ttext = GTK_TEXT_VIEW(textview->text);\n\tbuffer = gtk_text_view_get_buffer(text);\n\tgtk_text_buffer_get_end_iter(buffer, &iter);\n\n\tif (!conv)\n\t\tstrncpy2(buf, str, sizeof(buf));\n\telse if (conv_convert(conv, buf, sizeof(buf), str) < 0)\n\t\tconv_localetodisp(buf, sizeof(buf), str);\n\t\t\n\tstrcrchomp(buf);\n\tfg_color = NULL;\n\n\t\/* change color of quotation\n\t >, foo>, _> ... ok, , foo bar>, foo-> ... ng\n\t Up to 3 levels of quotations are detected, and each\n\t level is colored using a different color. *\/\n\tif (prefs_common.enable_color\n\t && !textview->is_attachment\n\t && line_has_quote_char(buf, prefs_common.quote_chars)) {\n\t\treal_quotelevel = get_quote_level(buf, prefs_common.quote_chars);\n\t\tquotelevel = real_quotelevel;\n\t\t\/* set up the correct foreground color *\/\n\t\tif (quotelevel > 2) {\n\t\t\t\/* recycle colors *\/\n\t\t\tif (prefs_common.recycle_quote_colors)\n\t\t\t\tquotelevel %= 3;\n\t\t\telse\n\t\t\t\tquotelevel = 2;\n\t\t}\n\t}\n\n\tif (quotelevel == -1)\n\t\tfg_color = NULL;\n\telse {\n\t\tg_snprintf(quote_tag_str, sizeof(quote_tag_str),\n\t\t\t \"quote%d\", quotelevel);\n\t\tfg_color = quote_tag_str;\n\t}\n\n\tif (prefs_common.enable_color) {\n\t\tif (textview->is_diff || textview->is_in_git_patch) {\n\t\t\tif (strncmp(buf, \"+++ \", 4) == 0)\n\t\t\t\tfg_color = \"diff-add-file\";\n\t\t\telse if (buf[0] == '+')\n\t\t\t\tfg_color = \"diff-add\";\n\t\t\telse if (strncmp(buf, \"--- \", 4) == 0)\n\t\t\t\tfg_color = \"diff-del-file\";\n\t\t\telse if (buf[0] == '-')\n\t\t\t\tfg_color = \"diff-del\";\n\t\t\telse if (strncmp(buf, \"@@ \", 3) == 0 &&\n\t\t\t\t strstr(&buf[3], \" @@\"))\n\t\t\t\tfg_color = \"diff-hunk\";\n\n\t\t\tif (account_sigsep_matchlist_nchar_found(buf, \"%s\\n\")) {\n\t\t\t\ttextview->is_in_git_patch = FALSE;\n\t\t\t\ttextview->is_in_signature = TRUE;\n\t\t\t\tfg_color = \"signature\";\n\t\t\t}\n\t\t} else if (account_sigsep_matchlist_str_found(buf, \"%s\\n\")\n\t\t\t\t|| account_sigsep_matchlist_str_found(buf, \"- %s\\n\")\n\t\t\t\t|| textview->is_in_signature) {\n\t\t\tfg_color = \"signature\";\n\t\t\ttextview->is_in_signature = TRUE;\n\t\t} else if (strncmp(buf, \"diff --git \", 11) == 0) {\n\t\t\ttextview->is_in_git_patch = TRUE;\n\t\t}\n\t}\n\n\tif (!textview->is_attachment && real_quotelevel > -1 && do_quote_folding) {\n\t\tif (!g_utf8_validate(buf, -1, NULL)) {\n\t\t\tgchar *utf8buf = NULL;\n\t\t\tutf8buf = g_malloc(BUFFSIZE);\n\t\t\tconv_localetodisp(utf8buf, BUFFSIZE, buf);\n\t\t\tstrncpy2(buf, utf8buf, BUFFSIZE-1);\n\t\t\tg_free(utf8buf);\n\t\t}\ndo_quote:\n\t\tif ( textview->prev_quote_level != real_quotelevel ) {\n\t\t\tClickableText *uri;\n\t\t\turi = g_new0(ClickableText, 1);\n\t\t\turi->uri = g_strdup(\"\");\n\t\t\turi->data = g_strdup(buf);\n\t\t\turi->data_len = strlen(uri->data);\n\t\t\turi->start = gtk_text_iter_get_offset(&iter);\n\t\t\turi->is_quote = TRUE;\n\t\t\turi->quote_level = real_quotelevel;\n\t\t\turi->fg_color = g_strdup(fg_color);\n\n\t\t\tgtk_text_buffer_insert_with_tags_by_name\n\t\t\t\t\t(buffer, &iter, \" [...]\", -1,\n\t\t\t\t\t \"qlink\", fg_color, NULL);\n\t\t\turi->end = gtk_text_iter_get_offset(&iter);\n\t\t\tgtk_text_buffer_insert(buffer, &iter, \" \\n\", -1);\n\t\t\t\n\t\t\turi->filename = NULL;\n\t\t\ttextview->uri_list =\n\t\t\t\tg_slist_prepend(textview->uri_list, uri);\n\t\t\n\t\t\ttextview->prev_quote_level = real_quotelevel;\n\t\t} else {\n\t\t\tGSList *last = textview->uri_list;\n\t\t\tClickableText *lasturi = NULL;\n\t\t\tgint e_len = 0, n_len = 0;\n\t\t\t\n\t\t\tif (textview->uri_list) {\n\t\t\t\tlasturi = (ClickableText *)last->data;\n\t\t\t} else {\n\t\t\t\tg_print(\"oops (%d %d)\\n\",\n\t\t\t\t\treal_quotelevel, textview->prev_quote_level);\n\t\t\t}\t\n\t\t\tif (lasturi) {\t\n\t\t\t\tif (lasturi->is_quote == FALSE) {\n\t\t\t\t\ttextview->prev_quote_level = -1;\n\t\t\t\t\tgoto do_quote;\n\t\t\t\t}\n\t\t\t\te_len = lasturi->data ? lasturi->data_len:0;\n\t\t\t\tn_len = strlen(buf);\n\t\t\t\tlasturi->data = g_realloc((gchar *)lasturi->data, e_len + n_len + 1);\n\t\t\t\tstrcpy((gchar *)lasturi->data + e_len, buf);\n\t\t\t\t*((gchar *)lasturi->data + e_len + n_len) = '\\0';\n\t\t\t\tlasturi->data_len += n_len;\n\t\t\t}\n\t\t}\n\t} else {\n\t\ttextview_make_clickable_parts(textview, fg_color, \"link\", buf, FALSE);\n\t\ttextview->prev_quote_level = -1;\n\t}\n}","target":0,"code_token_length":1301,"total_token_length":1537,"max_tokens_setting":2048} +{"idx":494453,"func":"flushupdates(struct interface *ifp)\n{\n babel_interface_nfo *babel_ifp = NULL;\n struct xroute *xroute;\n struct babel_route *route;\n const unsigned char *last_prefix = NULL;\n unsigned char last_plen = 0xFF;\n int i;\n\n if(ifp == NULL) {\n\tstruct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);\n struct interface *ifp_aux;\n FOR_ALL_INTERFACES(vrf, ifp_aux)\n flushupdates(ifp_aux);\n return;\n }\n\n babel_ifp = babel_get_if_nfo(ifp);\n if(babel_ifp->num_buffered_updates > 0) {\n struct buffered_update *b = babel_ifp->buffered_updates;\n int n = babel_ifp->num_buffered_updates;\n\n babel_ifp->buffered_updates = NULL;\n babel_ifp->update_bufsize = 0;\n babel_ifp->num_buffered_updates = 0;\n\n if(!if_up(ifp))\n goto done;\n\n debugf(BABEL_DEBUG_COMMON,\" (flushing %d buffered updates on %s (%d))\",\n n, ifp->name, ifp->ifindex);\n\n \/* In order to send fewer update messages, we want to send updates\n with the same router-id together, with IPv6 going out before IPv4. *\/\n\n for(i = 0; i < n; i++) {\n route = find_installed_route(b[i].prefix, b[i].plen);\n if(route)\n memcpy(b[i].id, route->src->id, 8);\n else\n memcpy(b[i].id, myid, 8);\n }\n\n qsort(b, n, sizeof(struct buffered_update), compare_buffered_updates);\n\n for(i = 0; i < n; i++) {\n \/* The same update may be scheduled multiple times before it is\n sent out. Since our buffer is now sorted, it is enough to\n compare with the previous update. *\/\n\n if(last_prefix) {\n if(b[i].plen == last_plen &&\n memcmp(b[i].prefix, last_prefix, 16) == 0)\n continue;\n }\n\n xroute = find_xroute(b[i].prefix, b[i].plen);\n route = find_installed_route(b[i].prefix, b[i].plen);\n\n if(xroute && (!route || xroute->metric <= kernel_metric)) {\n really_send_update(ifp, myid,\n xroute->prefix, xroute->plen,\n myseqno, xroute->metric,\n NULL, 0);\n last_prefix = xroute->prefix;\n last_plen = xroute->plen;\n } else if(route) {\n unsigned char channels[DIVERSITY_HOPS];\n int chlen;\n struct interface *route_ifp = route->neigh->ifp;\n struct babel_interface *babel_route_ifp = NULL;\n unsigned short metric;\n unsigned short seqno;\n\n seqno = route->seqno;\n metric =\n route_interferes(route, ifp) ?\n route_metric(route) :\n route_metric_noninterfering(route);\n\n if(metric < INFINITY)\n satisfy_request(route->src->prefix, route->src->plen,\n seqno, route->src->id, ifp);\n if((babel_ifp->flags & BABEL_IF_SPLIT_HORIZON) &&\n route->neigh->ifp == ifp)\n continue;\n\n babel_route_ifp = babel_get_if_nfo(route_ifp);\n if(babel_route_ifp->channel ==BABEL_IF_CHANNEL_NONINTERFERING) {\n memcpy(channels, route->channels, DIVERSITY_HOPS);\n } else {\n if(babel_route_ifp->channel == BABEL_IF_CHANNEL_UNKNOWN)\n channels[0] = BABEL_IF_CHANNEL_INTERFERING;\n else {\n assert(babel_route_ifp->channel > 0 &&\n babel_route_ifp->channel <= 255);\n channels[0] = babel_route_ifp->channel;\n }\n memcpy(channels + 1, route->channels, DIVERSITY_HOPS - 1);\n }\n\n chlen = channels_len(channels);\n really_send_update(ifp, route->src->id,\n route->src->prefix,\n route->src->plen,\n seqno, metric,\n channels, chlen);\n update_source(route->src, seqno, metric);\n last_prefix = route->src->prefix;\n last_plen = route->src->plen;\n } else {\n \/* There's no route for this prefix. This can happen shortly\n after an xroute has been retracted, so send a retraction. *\/\n really_send_update(ifp, myid, b[i].prefix, b[i].plen,\n myseqno, INFINITY, NULL, -1);\n }\n }\n schedule_flush_now(ifp);\n done:\n free(b);\n }\n babel_ifp->update_flush_timeout.tv_sec = 0;\n babel_ifp->update_flush_timeout.tv_usec = 0;\n}","target":0,"code_token_length":1096,"total_token_length":1332,"max_tokens_setting":2048} +{"idx":328202,"func":"static int vpc_create(const char *filename, QEMUOptionParameter *options)\n\n{\n\n uint8_t buf[1024];\n\n struct vhd_footer *footer = (struct vhd_footer *) buf;\n\n QEMUOptionParameter *disk_type_param;\n\n int fd, i;\n\n uint16_t cyls = 0;\n\n uint8_t heads = 0;\n\n uint8_t secs_per_cyl = 0;\n\n int64_t total_sectors;\n\n int64_t total_size;\n\n int disk_type;\n\n int ret = -EIO;\n\n\n\n \/* Read out options *\/\n\n total_size = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n;\n\n\n\n disk_type_param = get_option_parameter(options, BLOCK_OPT_SUBFMT);\n\n if (disk_type_param && disk_type_param->value.s) {\n\n if (!strcmp(disk_type_param->value.s, \"dynamic\")) {\n\n disk_type = VHD_DYNAMIC;\n\n } else if (!strcmp(disk_type_param->value.s, \"fixed\")) {\n\n disk_type = VHD_FIXED;\n\n } else {\n\n return -EINVAL;\n\n }\n\n } else {\n\n disk_type = VHD_DYNAMIC;\n\n }\n\n\n\n \/* Create the file *\/\n\n fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);\n\n if (fd < 0) {\n\n return -EIO;\n\n }\n\n\n\n \/*\n\n * Calculate matching total_size and geometry. Increase the number of\n\n * sectors requested until we get enough (or fail). This ensures that\n\n * qemu-img convert doesn't truncate images, but rather rounds up.\n\n *\/\n\n total_sectors = total_size \/ BDRV_SECTOR_SIZE;\n\n for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) {\n\n if (calculate_geometry(total_sectors + i, &cyls, &heads,\n\n &secs_per_cyl))\n\n {\n\n ret = -EFBIG;\n\n goto fail;\n\n }\n\n }\n\n\n\n total_sectors = (int64_t) cyls * heads * secs_per_cyl;\n\n\n\n \/* Prepare the Hard Disk Footer *\/\n\n memset(buf, 0, 1024);\n\n\n\n memcpy(footer->creator, \"conectix\", 8);\n\n \/* TODO Check if \"qemu\" creator_app is ok for VPC *\/\n\n memcpy(footer->creator_app, \"qemu\", 4);\n\n memcpy(footer->creator_os, \"Wi2k\", 4);\n\n\n\n footer->features = be32_to_cpu(0x02);\n\n footer->version = be32_to_cpu(0x00010000);\n\n if (disk_type == VHD_DYNAMIC) {\n\n footer->data_offset = be64_to_cpu(HEADER_SIZE);\n\n } else {\n\n footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL);\n\n }\n\n footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE);\n\n\n\n \/* Version of Virtual PC 2007 *\/\n\n footer->major = be16_to_cpu(0x0005);\n\n footer->minor = be16_to_cpu(0x0003);\n\n if (disk_type == VHD_DYNAMIC) {\n\n footer->orig_size = be64_to_cpu(total_sectors * 512);\n\n footer->size = be64_to_cpu(total_sectors * 512);\n\n } else {\n\n footer->orig_size = be64_to_cpu(total_size);\n\n footer->size = be64_to_cpu(total_size);\n\n }\n\n footer->cyls = be16_to_cpu(cyls);\n\n footer->heads = heads;\n\n footer->secs_per_cyl = secs_per_cyl;\n\n\n\n footer->type = be32_to_cpu(disk_type);\n\n\n\n \/* TODO uuid is missing *\/\n\n\n\n footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE));\n\n\n\n if (disk_type == VHD_DYNAMIC) {\n\n ret = create_dynamic_disk(fd, buf, total_sectors);\n\n } else {\n\n ret = create_fixed_disk(fd, buf, total_size);\n\n }\n\n\n\n fail:\n\n qemu_close(fd);\n\n return ret;\n\n}\n","target":0,"code_token_length":911,"total_token_length":1147,"max_tokens_setting":2048} +{"idx":118845,"func":"GF_Err video_sample_entry_on_child_box(GF_Box *s, GF_Box *a)\n{\n\tGF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_ESDS:\n\t\tif (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->esd = (GF_ESDBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_RINF:\n\t\tif (ptr->rinf) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->rinf = (GF_RestrictedSchemeInfoBox *) a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_AVCC:\n\t\tif (ptr->avc_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->avc_config = (GF_AVCConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_HVCC:\n\t\tif (ptr->hevc_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->hevc_config = (GF_HEVCConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_SVCC:\n\t\tif (ptr->svc_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->svc_config = (GF_AVCConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MVCC:\n\t\tif (ptr->mvc_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->mvc_config = (GF_AVCConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_LHVC:\n\t\tif (ptr->lhvc_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->lhvc_config = (GF_HEVCConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_AV1C:\n\t\tif (ptr->av1_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->av1_config = (GF_AV1ConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_VPCC:\n\t\tif (ptr->vp_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->vp_config = (GF_VPConfigurationBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_DVCC:\n\t\tif (ptr->dovi_config) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->dovi_config = (GF_DOVIConfigurationBox*)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_UUID:\n\t\tif (! memcmp(((GF_UnknownUUIDBox*)a)->uuid, GF_ISOM_IPOD_EXT, 16)) {\n\t\t\tif (ptr->ipod_ext) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\t\tptr->ipod_ext = (GF_UnknownUUIDBox *)a;\n\t\t} else {\n\t\t\treturn GF_OK;\n\t\t}\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_D263:\n\t\tif (ptr->cfg_3gpp) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_3gpp = (GF_3GPPConfigBox *)a;\n\t\t\/*for 3GP config, remember sample entry type in config*\/\n\t\tptr->cfg_3gpp->cfg.type = ptr->type;\n\t\tbreak;\n\n\tcase GF_ISOM_BOX_TYPE_JP2H:\n\t\tif (ptr->jp2h) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->jp2h = (GF_J2KHeaderBox *)a;\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_PASP:\n\tcase GF_ISOM_BOX_TYPE_CLAP:\n\tcase GF_ISOM_BOX_TYPE_COLR:\n\tcase GF_ISOM_BOX_TYPE_MDCV:\n\tcase GF_ISOM_BOX_TYPE_CLLI:\n\tcase GF_ISOM_BOX_TYPE_CCST:\n\tcase GF_ISOM_BOX_TYPE_AUXI:\n\tcase GF_ISOM_BOX_TYPE_RVCC:\n\tcase GF_ISOM_BOX_TYPE_M4DS:\n\t\tif (!gf_isom_box_check_unique(s->child_boxes, a)) {\n\t\t\tERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\t}\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":871,"total_token_length":1107,"max_tokens_setting":2048} +{"idx":486069,"func":"check_special_mountprog(const char *spec, const char *node, const char *type, int flags,\n\t\t\tchar *extra_opts, int *status) {\n\tchar search_path[] = FS_SEARCH_PATH;\n\tchar *path, mountprog[150];\n\tstruct stat statbuf;\n\tint res;\n\n\tif (!external_allowed)\n\t\treturn 0;\n\n\tif (type == NULL || strcmp(type, \"none\") == 0)\n\t\treturn 0;\n\n\tpath = strtok(search_path, \":\");\n\twhile (path) {\n\t\tint type_opt = 0;\n\n\t\tres = snprintf(mountprog, sizeof(mountprog), \"%s\/mount.%s\",\n\t\t\t path, type);\n\t\tpath = strtok(NULL, \":\");\n\t\tif (res >= sizeof(mountprog) || res < 0)\n\t\t\tcontinue;\n\n\t\tres = stat(mountprog, &statbuf);\n\t\tif (res == -1 && errno == ENOENT && strchr(type, '.')) {\n\t\t\t\/* If type ends with \".subtype\" try without it *\/\n\t\t\t*strrchr(mountprog, '.') = '\\0';\n\t\t\ttype_opt = 1;\n\t\t\tres = stat(mountprog, &statbuf);\n\t\t}\n\t\tif (res)\n\t\t\tcontinue;\n\n\t\tif (verbose)\n\t\t\tfflush(stdout);\n\n\t\tswitch (fork()) {\n\t\tcase 0: { \/* child *\/\n\t\t\tchar *oo, *mountargs[12];\n\t\t\tint i = 0;\n\n\t\t\tif (setgid(getgid()) < 0)\n\t\t\t\tdie(EX_FAIL, _(\"mount: cannot set group id: %s\"), strerror(errno));\n\n\t\t\tif (setuid(getuid()) < 0)\n\t\t\t\tdie(EX_FAIL, _(\"mount: cannot set user id: %s\"), strerror(errno));\n\n\t\t\too = fix_opts_string (flags, extra_opts, NULL);\n\t\t\tmountargs[i++] = mountprog;\t\t\t\/* 1 *\/\n\t\t\tmountargs[i++] = (char *) spec;\t\t\t\/* 2 *\/\n\t\t\tmountargs[i++] = (char *) node;\t\t\t\/* 3 *\/\n\t\t\tif (sloppy && strncmp(type, \"nfs\", 3) == 0)\n\t\t\t\tmountargs[i++] = \"-s\";\t\t\t\/* 4 *\/\n\t\t\tif (fake)\n\t\t\t\tmountargs[i++] = \"-f\";\t\t\t\/* 5 *\/\n\t\t\tif (nomtab)\n\t\t\t\tmountargs[i++] = \"-n\";\t\t\t\/* 6 *\/\n\t\t\tif (verbose)\n\t\t\t\tmountargs[i++] = \"-v\";\t\t\t\/* 7 *\/\n\t\t\tif (oo && *oo) {\n\t\t\t\tmountargs[i++] = \"-o\";\t\t\t\/* 8 *\/\n\t\t\t\tmountargs[i++] = oo;\t\t\t\/* 9 *\/\n\t\t\t}\n\t\t\tif (type_opt) {\n\t\t\t\tmountargs[i++] = \"-t\";\t\t\t\/* 10 *\/\n\t\t\t\tmountargs[i++] = (char *) type;\t\t\/* 11 *\/\n\t\t\t}\n\t\t\tmountargs[i] = NULL;\t\t\t\t\/* 12 *\/\n\n\t\t\tif (verbose > 2) {\n\t\t\t\ti = 0;\n\t\t\t\twhile (mountargs[i]) {\n\t\t\t\t\tprintf(\"mount: external mount: argv[%d] = \\\"%s\\\"\\n\",\n\t\t\t\t\t\ti, mountargs[i]);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tfflush(stdout);\n\t\t\t}\n\n\t\t\texecv(mountprog, mountargs);\n\t\t\texit(1);\t\/* exec failed *\/\n\t\t}\n\n\t\tdefault: { \/* parent *\/\n\t\t\tint st;\n\t\t\twait(&st);\n\t\t\t*status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR);\n\t\t\treturn 1;\n\t\t}\n\n\t\tcase -1: { \/* error *\/\n\t\t\tint errsv = errno;\n\t\t\terror(_(\"mount: cannot fork: %s\"), strerror(errsv));\n\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":809,"total_token_length":1045,"max_tokens_setting":2048} +{"idx":30309,"func":"static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n HLSContext *c = s->priv_data;\n\n int ret, i, minvariant = -1;\n\n\n\n if (c->first_packet) {\n\n recheck_discard_flags(s, 1);\n\n c->first_packet = 0;\n\n }\n\n\n\nstart:\n\n c->end_of_segment = 0;\n\n for (i = 0; i < c->n_variants; i++) {\n\n struct variant *var = c->variants[i];\n\n \/* Make sure we've got one buffered packet from each open variant\n\n * stream *\/\n\n if (var->needed && !var->pkt.data) {\n\n while (1) {\n\n int64_t ts_diff;\n\n AVStream *st;\n\n ret = av_read_frame(var->ctx, &var->pkt);\n\n if (ret < 0) {\n\n if (!var->pb.eof_reached)\n\n return ret;\n\n\n break;\n\n } else {\n\n if (c->first_timestamp == AV_NOPTS_VALUE &&\n\n var->pkt.dts != AV_NOPTS_VALUE)\n\n c->first_timestamp = av_rescale_q(var->pkt.dts,\n\n var->ctx->streams[var->pkt.stream_index]->time_base,\n\n AV_TIME_BASE_Q);\n\n }\n\n\n\n if (c->seek_timestamp == AV_NOPTS_VALUE)\n\n break;\n\n\n\n if (var->pkt.dts == AV_NOPTS_VALUE) {\n\n c->seek_timestamp = AV_NOPTS_VALUE;\n\n break;\n\n }\n\n\n\n st = var->ctx->streams[var->pkt.stream_index];\n\n ts_diff = av_rescale_rnd(var->pkt.dts, AV_TIME_BASE,\n\n st->time_base.den, AV_ROUND_DOWN) -\n\n c->seek_timestamp;\n\n if (ts_diff >= 0 && (c->seek_flags & AVSEEK_FLAG_ANY ||\n\n var->pkt.flags & AV_PKT_FLAG_KEY)) {\n\n c->seek_timestamp = AV_NOPTS_VALUE;\n\n break;\n\n }\n\n\n\n }\n\n }\n\n \/* Check if this stream still is on an earlier segment number, or\n\n * has the packet with the lowest dts *\/\n\n if (var->pkt.data) {\n\n struct variant *minvar = c->variants[minvariant];\n\n if (minvariant < 0 || var->cur_seq_no < minvar->cur_seq_no) {\n\n minvariant = i;\n\n } else if (var->cur_seq_no == minvar->cur_seq_no) {\n\n int64_t dts = var->pkt.dts;\n\n int64_t mindts = minvar->pkt.dts;\n\n AVStream *st = var->ctx->streams[var->pkt.stream_index];\n\n AVStream *minst = minvar->ctx->streams[minvar->pkt.stream_index];\n\n\n\n if (dts == AV_NOPTS_VALUE) {\n\n minvariant = i;\n\n } else if (mindts != AV_NOPTS_VALUE) {\n\n if (st->start_time != AV_NOPTS_VALUE)\n\n dts -= st->start_time;\n\n if (minst->start_time != AV_NOPTS_VALUE)\n\n mindts -= minst->start_time;\n\n\n\n if (av_compare_ts(dts, st->time_base,\n\n mindts, minst->time_base) < 0)\n\n minvariant = i;\n\n }\n\n }\n\n }\n\n }\n\n if (c->end_of_segment) {\n\n if (recheck_discard_flags(s, 0))\n\n goto start;\n\n }\n\n \/* If we got a packet, return it *\/\n\n if (minvariant >= 0) {\n\n *pkt = c->variants[minvariant]->pkt;\n\n pkt->stream_index += c->variants[minvariant]->stream_offset;\n\n reset_packet(&c->variants[minvariant]->pkt);\n\n return 0;\n\n }\n\n return AVERROR_EOF;\n\n}","target":1,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048} +{"idx":155813,"func":"pixOctcubeQuantMixedWithGray(PIX *pixs,\n l_int32 depth,\n l_int32 graylevels,\n l_int32 delta)\n{\nl_int32 w, h, wpls, wpld, i, j, size, octlevels;\nl_int32 rval, gval, bval, del, val, midval;\nl_int32 *carray, *rarray, *garray, *barray;\nl_int32 *tabval;\nl_uint32 octindex;\nl_uint32 *rtab, *gtab, *btab;\nl_uint32 *lines, *lined, *datas, *datad;\nPIX *pixd;\nPIXCMAP *cmap;\n\n PROCNAME(\"pixOctcubeQuantMixedWithGray\");\n\n if (!pixs)\n return (PIX *)ERROR_PTR(\"pixs not defined\", procName, NULL);\n if (pixGetDepth(pixs) != 32)\n return (PIX *)ERROR_PTR(\"pixs not 32 bpp\", procName, NULL);\n if (graylevels < 2)\n return (PIX *)ERROR_PTR(\"invalid graylevels\", procName, NULL);\n if (depth == 4) {\n octlevels = 1;\n size = 8; \/* 2 ** 3 *\/\n if (graylevels > 8)\n return (PIX *)ERROR_PTR(\"max 8 gray levels\", procName, NULL);\n } else if (depth == 8) {\n octlevels = 2;\n size = 64; \/* 2 ** 6 *\/\n if (graylevels > 192)\n return (PIX *)ERROR_PTR(\"max 192 gray levels\", procName, NULL);\n } else {\n return (PIX *)ERROR_PTR(\"output depth not 4 or 8 bpp\", procName, NULL);\n }\n\n pixd = NULL;\n\n \/* Make octcube index tables *\/\n rtab = gtab = btab = NULL;\n makeRGBToIndexTables(octlevels, &rtab, >ab, &btab);\n\n \/* Make octcube arrays for storing points in each cube *\/\n carray = (l_int32 *)LEPT_CALLOC(size, sizeof(l_int32));\n rarray = (l_int32 *)LEPT_CALLOC(size, sizeof(l_int32));\n garray = (l_int32 *)LEPT_CALLOC(size, sizeof(l_int32));\n barray = (l_int32 *)LEPT_CALLOC(size, sizeof(l_int32));\n\n \/* Make lookup table, using computed thresholds *\/\n tabval = makeGrayQuantIndexTable(graylevels);\n if (!rtab || !gtab || !btab ||\n !carray || !rarray || !garray || !barray || !tabval) {\n L_ERROR(\"calloc fail for an array\\n\", procName);\n goto array_cleanup;\n }\n\n \/* Make colormapped output pixd *\/\n pixGetDimensions(pixs, &w, &h, NULL);\n if ((pixd = pixCreate(w, h, depth)) == NULL) {\n L_ERROR(\"pixd not made\\n\", procName);\n goto array_cleanup;\n }\n pixCopyResolution(pixd, pixs);\n pixCopyInputFormat(pixd, pixs);\n cmap = pixcmapCreate(depth);\n for (j = 0; j < size; j++) \/* reserve octcube colors *\/\n pixcmapAddColor(cmap, 1, 1, 1); \/* a color that won't be used *\/\n for (j = 0; j < graylevels; j++) { \/* set grayscale colors *\/\n val = (255 * j) \/ (graylevels - 1);\n pixcmapAddColor(cmap, val, val, val);\n }\n pixSetColormap(pixd, cmap);\n wpld = pixGetWpl(pixd);\n datad = pixGetData(pixd);\n\n \/* Go through src image: assign dest pixels to colormap values\n * and compute average colors in each occupied octcube *\/\n datas = pixGetData(pixs);\n wpls = pixGetWpl(pixs);\n for (i = 0; i < h; i++) {\n lines = datas + i * wpls;\n lined = datad + i * wpld;\n for (j = 0; j < w; j++) {\n extractRGBValues(lines[j], &rval, &gval, &bval);\n if (rval > gval) {\n if (gval > bval) { \/* r > g > b *\/\n del = rval - bval;\n midval = gval;\n } else if (rval > bval) { \/* r > b > g *\/\n del = rval - gval;\n midval = bval;\n } else { \/* b > r > g *\/\n del = bval - gval;\n midval = rval;\n }\n } else { \/* gval >= rval *\/\n if (rval > bval) { \/* g > r > b *\/\n del = gval - bval;\n midval = rval;\n } else if (gval > bval) { \/* g > b > r *\/\n del = gval - rval;\n midval = bval;\n } else { \/* b > g > r *\/\n del = bval - rval;\n midval = gval;\n }\n }\n if (del > delta) { \/* assign to color *\/\n octindex = rtab[rval] | gtab[gval] | btab[bval];\n carray[octindex]++;\n rarray[octindex] += rval;\n garray[octindex] += gval;\n barray[octindex] += bval;\n if (depth == 4)\n SET_DATA_QBIT(lined, j, octindex);\n else \/* depth == 8 *\/\n SET_DATA_BYTE(lined, j, octindex);\n } else { \/* assign to grayscale *\/\n val = size + tabval[midval];\n if (depth == 4)\n SET_DATA_QBIT(lined, j, val);\n else \/* depth == 8 *\/\n SET_DATA_BYTE(lined, j, val);\n }\n }\n }\n\n \/* Average the colors in each bin and reset the colormap *\/\n for (i = 0; i < size; i++) {\n if (carray[i] > 0) {\n rarray[i] \/= carray[i];\n garray[i] \/= carray[i];\n barray[i] \/= carray[i];\n pixcmapResetColor(cmap, i, rarray[i], garray[i], barray[i]);\n }\n }\n\narray_cleanup:\n LEPT_FREE(carray);\n LEPT_FREE(rarray);\n LEPT_FREE(garray);\n LEPT_FREE(barray);\n LEPT_FREE(rtab);\n LEPT_FREE(gtab);\n LEPT_FREE(btab);\n LEPT_FREE(tabval);\n\n return pixd;\n}","target":0,"code_token_length":1566,"total_token_length":1802,"max_tokens_setting":2048} +{"idx":522816,"func":"static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,\n COND *cond,\n COND_EQUAL *cond_equal,\n void *table_join_idx,\n bool do_substitution)\n{\n Item_equal *item_equal;\n COND *org_cond= cond; \/\/ Return this in case of fatal error\n\n if (cond->type() == Item::COND_ITEM)\n {\n List *cond_list= ((Item_cond*) cond)->argument_list();\n\n bool and_level= ((Item_cond*) cond)->functype() ==\n Item_func::COND_AND_FUNC;\n if (and_level)\n {\n cond_equal= &((Item_cond_and *) cond)->m_cond_equal;\n cond_list->disjoin((List *) &cond_equal->current_level);\/* remove Item_equal objects from the AND. *\/\n\n List_iterator_fast it(cond_equal->current_level); \n while ((item_equal= it++))\n {\n item_equal->sort(&compare_fields_by_table_order, table_join_idx);\n }\n }\n \n List_iterator li(*cond_list);\n Item *item;\n while ((item= li++))\n {\n Item *new_item= substitute_for_best_equal_field(thd, context_tab,\n item, cond_equal,\n table_join_idx,\n do_substitution);\n \/*\n This works OK with PS\/SP re-execution as changes are made to\n the arguments of AND\/OR items only\n *\/\n if (new_item && new_item != item)\n li.replace(new_item);\n }\n\n if (and_level)\n {\n COND *eq_cond= 0;\n List_iterator_fast it(cond_equal->current_level);\n bool false_eq_cond= FALSE;\n bool all_deleted= true;\n while ((item_equal= it++))\n {\n if (item_equal->get_extraction_flag() == DELETION_FL)\n continue;\n all_deleted= false;\n eq_cond= eliminate_item_equal(thd, eq_cond, cond_equal->upper_levels,\n item_equal);\n if (!eq_cond)\n\t{\n eq_cond= 0;\n break;\n }\n else if (eq_cond->is_bool_literal() && !eq_cond->val_bool())\n\t{\n \/*\n This occurs when eliminate_item_equal() founds that cond is\n always false and substitutes it with Item_int 0.\n Due to this, value of item_equal will be 0, so just return it.\n\t *\/\n cond= eq_cond;\n false_eq_cond= TRUE;\n break;\n }\n }\n if (eq_cond && !false_eq_cond)\n {\n \/* Insert the generated equalities before all other conditions *\/\n if (eq_cond->type() == Item::COND_ITEM)\n ((Item_cond *) cond)->add_at_head(\n ((Item_cond *) eq_cond)->argument_list());\n else\n\t{\n if (cond_list->is_empty())\n cond= eq_cond;\n else\n\t {\n \/* Do not add an equality condition if it's always true *\/ \n if (!eq_cond->is_bool_literal() &&\n cond_list->push_front(eq_cond, thd->mem_root))\n eq_cond= 0;\n }\n\t}\n }\n if (!eq_cond && !all_deleted)\n {\n \/* \n We are out of memory doing the transformation.\n This is a fatal error now. However we bail out by returning the\n original condition that we had before we started the transformation. \n\t*\/\n\tcond_list->append((List *) &cond_equal->current_level);\n }\n }\t \n }\n else if (cond->type() == Item::FUNC_ITEM && \n ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)\n {\n item_equal= (Item_equal *) cond;\n item_equal->sort(&compare_fields_by_table_order, table_join_idx);\n cond_equal= item_equal->upper_levels;\n if (cond_equal && cond_equal->current_level.head() == item_equal)\n cond_equal= cond_equal->upper_levels;\n if (item_equal->get_extraction_flag() == DELETION_FL)\n return 0;\n cond= eliminate_item_equal(thd, 0, cond_equal, item_equal);\n return cond ? cond : org_cond;\n }\n else if (do_substitution)\n {\n while (cond_equal)\n {\n List_iterator_fast it(cond_equal->current_level);\n while((item_equal= it++))\n {\n REPLACE_EQUAL_FIELD_ARG arg= {item_equal, context_tab};\n if (!(cond= cond->transform(thd, &Item::replace_equal_field,\n (uchar *) &arg)))\n return 0;\n }\n cond_equal= cond_equal->upper_levels;\n }\n }\n return cond;\n}","target":0,"code_token_length":1029,"total_token_length":1265,"max_tokens_setting":2048} +{"idx":360703,"func":"int do_print(const char *path_p, const struct stat *st, int walk_flags, void *unused)\n{\n\tconst char *default_prefix = NULL;\n\tacl_t acl = NULL, default_acl = NULL;\n\tint error = 0;\n\n\tif (walk_flags & WALK_TREE_FAILED) {\n\t\tfprintf(stderr, \"%s: %s: %s\\n\", progname, xquote(path_p, \"\\n\\r\"),\n\t\t\tstrerror(errno));\n\t\treturn 1;\n\t}\n\n\t\/*\n\t * Symlinks can never have ACLs, so when doing a physical walk, we\n\t * skip symlinks altogether, and when doing a half-logical walk, we\n\t * skip all non-toplevel symlinks. \n\t *\/\n\tif ((walk_flags & WALK_TREE_SYMLINK) &&\n\t ((walk_flags & WALK_TREE_PHYSICAL) ||\n\t !(walk_flags & (WALK_TREE_TOPLEVEL | WALK_TREE_LOGICAL))))\n\t\treturn 0;\n\n\tif (opt_print_acl) {\n\t\tacl = acl_get_file(path_p, ACL_TYPE_ACCESS);\n\t\tif (acl == NULL && (errno == ENOSYS || errno == ENOTSUP))\n\t\t\tacl = acl_get_file_mode(path_p);\n\t\tif (acl == NULL)\n\t\t\tgoto fail;\n\t}\n\n\tif (opt_print_default_acl && S_ISDIR(st->st_mode)) {\n\t\tdefault_acl = acl_get_file(path_p, ACL_TYPE_DEFAULT);\n\t\tif (default_acl == NULL) {\n\t\t\tif (errno != ENOSYS && errno != ENOTSUP)\n\t\t\t\tgoto fail;\n\t\t} else if (acl_entries(default_acl) == 0) {\n\t\t\tacl_free(default_acl);\n\t\t\tdefault_acl = NULL;\n\t\t}\n\t}\n\n\tif (opt_skip_base &&\n\t (!acl || acl_equiv_mode(acl, NULL) == 0) && !default_acl)\n\t\treturn 0;\n\n\tif (opt_print_acl && opt_print_default_acl)\n\t\tdefault_prefix = \"default:\";\n\n\tif (opt_strip_leading_slash) {\n\t\tif (*path_p == '\/') {\n\t\t\tif (!absolute_warning) {\n\t\t\t\tfprintf(stderr, _(\"%s: Removing leading \"\n\t\t\t\t\t\"'\/' from absolute path names\\n\"),\n\t\t\t\t progname);\n\t\t\t\tabsolute_warning = 1;\n\t\t\t}\n\t\t\twhile (*path_p == '\/')\n\t\t\t\tpath_p++;\n\t\t} else if (*path_p == '.' && *(path_p+1) == '\/')\n\t\t\twhile (*++path_p == '\/')\n\t\t\t\t\/* nothing *\/ ;\n\t\tif (*path_p == '\\0')\n\t\t\tpath_p = \".\";\n\t}\n\n\tif (opt_tabular) {\n\t\tif (do_show(stdout, path_p, st, acl, default_acl) != 0)\n\t\t\tgoto fail;\n\t} else {\n\t\tif (opt_comments) {\n\t\t\tprintf(\"# file: %s\\n\", xquote(path_p, \"\\n\\r\"));\n\t\t\tprintf(\"# owner: %s\\n\",\n\t\t\t xquote(user_name(st->st_uid, opt_numeric), \" \\t\\n\\r\"));\n\t\t\tprintf(\"# group: %s\\n\",\n\t\t\t xquote(group_name(st->st_gid, opt_numeric), \" \\t\\n\\r\"));\n\t\t}\n\t\tif (acl != NULL) {\n\t\t\tchar *acl_text = acl_to_any_text(acl, NULL, '\\n',\n\t\t\t\t\t\t\t print_options);\n\t\t\tif (!acl_text)\n\t\t\t\tgoto fail;\n\t\t\tif (puts(acl_text) < 0) {\n\t\t\t\tacl_free(acl_text);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tacl_free(acl_text);\n\t\t}\n\t\tif (default_acl != NULL) {\n\t\t\tchar *acl_text = acl_to_any_text(default_acl, \n\t\t\t\t\t\t\t default_prefix, '\\n',\n\t\t\t\t\t\t\t print_options);\n\t\t\tif (!acl_text)\n\t\t\t\tgoto fail;\n\t\t\tif (puts(acl_text) < 0) {\n\t\t\t\tacl_free(acl_text);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tacl_free(acl_text);\n\t\t}\n\t}\n\tif (acl || default_acl || opt_comments)\n\t\tprintf(\"\\n\");\n\ncleanup:\n\tif (acl)\n\t\tacl_free(acl);\n\tif (default_acl)\n\t\tacl_free(default_acl);\n\treturn error;\n\nfail:\n\tfprintf(stderr, \"%s: %s: %s\\n\", progname, xquote(path_p, \"\\n\\r\"),\n\t\tstrerror(errno));\n\terror = -1;\n\tgoto cleanup;\n}","target":0,"code_token_length":900,"total_token_length":1136,"max_tokens_setting":2048} +{"idx":323642,"func":"static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)\n\n{\n\n int i;\n\n register int t1,t2,t3,t4,t5,t6,t7,t8;\n\n DCTELEM *src, *dst;\n\n const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n src = block;\n\n dst = block;\n\n for(i = 0; i < 8; i++){\n\n t1 = 17 * (src[0] + src[2]) + 4;\n\n t2 = 17 * (src[0] - src[2]) + 4;\n\n t3 = 22 * src[1] + 10 * src[3];\n\n t4 = 22 * src[3] - 10 * src[1];\n\n\n\n dst[0] = (t1 + t3) >> 3;\n\n dst[1] = (t2 - t4) >> 3;\n\n dst[2] = (t2 + t4) >> 3;\n\n dst[3] = (t1 - t3) >> 3;\n\n\n\n src += 8;\n\n dst += 8;\n\n }\n\n\n\n src = block;\n\n for(i = 0; i < 4; i++){\n\n t1 = 12 * (src[ 0] + src[32]) + 64;\n\n t2 = 12 * (src[ 0] - src[32]) + 64;\n\n t3 = 16 * src[16] + 6 * src[48];\n\n t4 = 6 * src[16] - 16 * src[48];\n\n\n\n t5 = t1 + t3;\n\n t6 = t2 + t4;\n\n t7 = t2 - t4;\n\n t8 = t1 - t3;\n\n\n\n t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];\n\n t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];\n\n t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];\n\n t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];\n\n\n\n dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)];\n\n dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)];\n\n dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)];\n\n dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)];\n\n dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)];\n\n dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)];\n\n dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)];\n\n dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)];\n\n\n\n src ++;\n\n dest++;\n\n }\n\n}\n","target":0,"code_token_length":866,"total_token_length":1102,"max_tokens_setting":2048} +{"idx":68942,"func":"int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,\n\t\t int noblock, int flags, int *addr_len)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct sk_buff *skb;\n\tunsigned int ulen, copied;\n\tint peeked, off = 0;\n\tint err;\n\tint is_udplite = IS_UDPLITE(sk);\n\tbool checksum_valid = false;\n\tint is_udp4;\n\tbool slow;\n\n\tif (flags & MSG_ERRQUEUE)\n\t\treturn ipv6_recv_error(sk, msg, len, addr_len);\n\n\tif (np->rxpmtu && np->rxopt.bits.rxpmtu)\n\t\treturn ipv6_recv_rxpmtu(sk, msg, len, addr_len);\n\ntry_again:\n\tskb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),\n\t\t\t\t &peeked, &off, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tulen = skb->len - sizeof(struct udphdr);\n\tcopied = len;\n\tif (copied > ulen)\n\t\tcopied = ulen;\n\telse if (copied < ulen)\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\n\tis_udp4 = (skb->protocol == htons(ETH_P_IP));\n\n\t\/*\n\t * If checksum is needed at all, try to do it while copying the\n\t * data. If the data is truncated, or if we only want a partial\n\t * coverage checksum (UDP-Lite), do it before the copy.\n\t *\/\n\n\tif (copied < ulen || UDP_SKB_CB(skb)->partial_cov) {\n\t\tchecksum_valid = !udp_lib_checksum_complete(skb);\n\t\tif (!checksum_valid)\n\t\t\tgoto csum_copy_err;\n\t}\n\n\tif (checksum_valid || skb_csum_unnecessary(skb))\n\t\terr = skb_copy_datagram_msg(skb, sizeof(struct udphdr),\n\t\t\t\t\t msg, copied);\n\telse {\n\t\terr = skb_copy_and_csum_datagram_msg(skb, sizeof(struct udphdr), msg);\n\t\tif (err == -EINVAL)\n\t\t\tgoto csum_copy_err;\n\t}\n\tif (unlikely(err)) {\n\t\ttrace_kfree_skb(skb, udpv6_recvmsg);\n\t\tif (!peeked) {\n\t\t\tatomic_inc(&sk->sk_drops);\n\t\t\tif (is_udp4)\n\t\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\t\t UDP_MIB_INERRORS,\n\t\t\t\t\t\t is_udplite);\n\t\t\telse\n\t\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\t\t UDP_MIB_INERRORS,\n\t\t\t\t\t\t is_udplite);\n\t\t}\n\t\tgoto out_free;\n\t}\n\tif (!peeked) {\n\t\tif (is_udp4)\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INDATAGRAMS, is_udplite);\n\t\telse\n\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INDATAGRAMS, is_udplite);\n\t}\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t\/* Copy the address. *\/\n\tif (msg->msg_name) {\n\t\tDECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name);\n\t\tsin6->sin6_family = AF_INET6;\n\t\tsin6->sin6_port = udp_hdr(skb)->source;\n\t\tsin6->sin6_flowinfo = 0;\n\n\t\tif (is_udp4) {\n\t\t\tipv6_addr_set_v4mapped(ip_hdr(skb)->saddr,\n\t\t\t\t\t &sin6->sin6_addr);\n\t\t\tsin6->sin6_scope_id = 0;\n\t\t} else {\n\t\t\tsin6->sin6_addr = ipv6_hdr(skb)->saddr;\n\t\t\tsin6->sin6_scope_id =\n\t\t\t\tipv6_iface_scope_id(&sin6->sin6_addr,\n\t\t\t\t\t\t inet6_iif(skb));\n\t\t}\n\t\t*addr_len = sizeof(*sin6);\n\t}\n\n\tif (np->rxopt.all)\n\t\tip6_datagram_recv_common_ctl(sk, msg, skb);\n\n\tif (is_udp4) {\n\t\tif (inet->cmsg_flags)\n\t\t\tip_cmsg_recv(msg, skb);\n\t} else {\n\t\tif (np->rxopt.all)\n\t\t\tip6_datagram_recv_specific_ctl(sk, msg, skb);\n\t}\n\n\terr = copied;\n\tif (flags & MSG_TRUNC)\n\t\terr = ulen;\n\nout_free:\n\tskb_free_datagram_locked(sk, skb);\nout:\n\treturn err;\n\ncsum_copy_err:\n\tslow = lock_sock_fast(sk);\n\tif (!skb_kill_datagram(sk, skb, flags)) {\n\t\tif (is_udp4) {\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_CSUMERRORS, is_udplite);\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INERRORS, is_udplite);\n\t\t} else {\n\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_CSUMERRORS, is_udplite);\n\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INERRORS, is_udplite);\n\t\t}\n\t}\n\tunlock_sock_fast(sk, slow);\n\n\t\/* starting over for a new packet, but check if we need to yield *\/\n\tcond_resched();\n\tmsg->msg_flags &= ~MSG_TRUNC;\n\tgoto try_again;\n}","target":0,"code_token_length":1134,"total_token_length":1370,"max_tokens_setting":2048} +{"idx":217910,"func":"gst_qtdemux_do_seek (GstQTDemux * qtdemux, GstPad * pad, GstEvent * event)\n{\n gdouble rate;\n GstFormat format;\n GstSeekFlags flags;\n GstSeekType cur_type, stop_type;\n gint64 cur, stop;\n gboolean flush;\n gboolean res;\n gboolean update;\n GstSegment seeksegment;\n int i;\n\n if (event) {\n GST_DEBUG_OBJECT (qtdemux, \"doing seek with event\");\n\n gst_event_parse_seek (event, &rate, &format, &flags,\n &cur_type, &cur, &stop_type, &stop);\n\n \/* we have to have a format as the segment format. Try to convert\n * if not. *\/\n if (format != GST_FORMAT_TIME) {\n GstFormat fmt;\n\n fmt = GST_FORMAT_TIME;\n res = TRUE;\n if (cur_type != GST_SEEK_TYPE_NONE)\n res = gst_pad_query_convert (pad, format, cur, &fmt, &cur);\n if (res && stop_type != GST_SEEK_TYPE_NONE)\n res = gst_pad_query_convert (pad, format, stop, &fmt, &stop);\n if (!res)\n goto no_format;\n\n format = fmt;\n }\n } else {\n GST_DEBUG_OBJECT (qtdemux, \"doing seek without event\");\n flags = 0;\n }\n\n flush = flags & GST_SEEK_FLAG_FLUSH;\n\n GST_DEBUG_OBJECT (qtdemux, \"seek format %d\", format);\n\n \/* stop streaming, either by flushing or by pausing the task *\/\n if (flush) {\n \/* unlock upstream pull_range *\/\n gst_pad_push_event (qtdemux->sinkpad, gst_event_new_flush_start ());\n \/* make sure out loop function exits *\/\n gst_qtdemux_push_event (qtdemux, gst_event_new_flush_start ());\n } else {\n \/* non flushing seek, pause the task *\/\n gst_pad_pause_task (qtdemux->sinkpad);\n }\n\n \/* wait for streaming to finish *\/\n GST_PAD_STREAM_LOCK (qtdemux->sinkpad);\n\n \/* copy segment, we need this because we still need the old\n * segment when we close the current segment. *\/\n memcpy (&seeksegment, &qtdemux->segment, sizeof (GstSegment));\n\n if (event) {\n \/* configure the segment with the seek variables *\/\n GST_DEBUG_OBJECT (qtdemux, \"configuring seek\");\n gst_segment_set_seek (&seeksegment, rate, format, flags,\n cur_type, cur, stop_type, stop, &update);\n }\n\n \/* now do the seek, this actually never returns FALSE *\/\n res = gst_qtdemux_perform_seek (qtdemux, &seeksegment);\n\n \/* prepare for streaming again *\/\n if (flush) {\n gst_pad_push_event (qtdemux->sinkpad, gst_event_new_flush_stop ());\n gst_qtdemux_push_event (qtdemux, gst_event_new_flush_stop ());\n } else if (qtdemux->segment_running) {\n \/* we are running the current segment and doing a non-flushing seek,\n * close the segment first based on the last_stop. *\/\n GST_DEBUG_OBJECT (qtdemux, \"closing running segment %\" G_GINT64_FORMAT\n \" to %\" G_GINT64_FORMAT, qtdemux->segment.start,\n qtdemux->segment.last_stop);\n\n if (qtdemux->segment.rate >= 0) {\n \/* FIXME, rate is the product of the global rate and the (quicktime)\n * segment rate. *\/\n qtdemux->pending_newsegment = gst_event_new_new_segment (TRUE,\n qtdemux->segment.rate, qtdemux->segment.format,\n qtdemux->segment.start, qtdemux->segment.last_stop,\n qtdemux->segment.time);\n } else { \/* For Reverse Playback *\/\n guint64 stop;\n\n if ((stop = qtdemux->segment.stop) == -1)\n stop = qtdemux->segment.duration;\n \/* for reverse playback, we played from stop to last_stop. *\/\n qtdemux->pending_newsegment = gst_event_new_new_segment (TRUE,\n qtdemux->segment.rate, qtdemux->segment.format,\n qtdemux->segment.last_stop, stop, qtdemux->segment.last_stop);\n }\n }\n\n \/* commit the new segment *\/\n memcpy (&qtdemux->segment, &seeksegment, sizeof (GstSegment));\n\n if (qtdemux->segment.flags & GST_SEEK_FLAG_SEGMENT) {\n gst_element_post_message (GST_ELEMENT_CAST (qtdemux),\n gst_message_new_segment_start (GST_OBJECT_CAST (qtdemux),\n qtdemux->segment.format, qtdemux->segment.last_stop));\n }\n\n \/* restart streaming, NEWSEGMENT will be sent from the streaming\n * thread. *\/\n qtdemux->segment_running = TRUE;\n for (i = 0; i < qtdemux->n_streams; i++)\n qtdemux->streams[i]->last_ret = GST_FLOW_OK;\n\n gst_pad_start_task (qtdemux->sinkpad, (GstTaskFunction) gst_qtdemux_loop,\n qtdemux->sinkpad);\n\n GST_PAD_STREAM_UNLOCK (qtdemux->sinkpad);\n\n return TRUE;\n\n \/* ERRORS *\/\nno_format:\n {\n GST_DEBUG_OBJECT (qtdemux, \"unsupported format given, seek aborted.\");\n return FALSE;\n }\n}\n","target":0,"code_token_length":1221,"total_token_length":1457,"max_tokens_setting":2048} +{"idx":347885,"func":"nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_device *dev)\n{\n\tstruct sk_buff *fp, *head = fq->q.fragments;\n\tint payload_len;\n\tu8 ecn;\n\n\tinet_frag_kill(&fq->q);\n\n\tWARN_ON(head == NULL);\n\tWARN_ON(head->ip_defrag_offset != 0);\n\n\tecn = ip_frag_ecn_table[fq->ecn];\n\tif (unlikely(ecn == 0xff))\n\t\treturn false;\n\n\t\/* Unfragmented part is taken from the first segment. *\/\n\tpayload_len = ((head->data - skb_network_header(head)) -\n\t\t sizeof(struct ipv6hdr) + fq->q.len -\n\t\t sizeof(struct frag_hdr));\n\tif (payload_len > IPV6_MAXPLEN) {\n\t\tnet_dbg_ratelimited(\"nf_ct_frag6_reasm: payload len = %d\\n\",\n\t\t\t\t payload_len);\n\t\treturn false;\n\t}\n\n\t\/* Head of list must not be cloned. *\/\n\tif (skb_unclone(head, GFP_ATOMIC))\n\t\treturn false;\n\n\t\/* If the first fragment is fragmented itself, we split\n\t * it to two chunks: the first with data and paged part\n\t * and the second, holding only fragments. *\/\n\tif (skb_has_frag_list(head)) {\n\t\tstruct sk_buff *clone;\n\t\tint i, plen = 0;\n\n\t\tclone = alloc_skb(0, GFP_ATOMIC);\n\t\tif (clone == NULL)\n\t\t\treturn false;\n\n\t\tclone->next = head->next;\n\t\thead->next = clone;\n\t\tskb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list;\n\t\tskb_frag_list_init(head);\n\t\tfor (i = 0; i < skb_shinfo(head)->nr_frags; i++)\n\t\t\tplen += skb_frag_size(&skb_shinfo(head)->frags[i]);\n\t\tclone->len = clone->data_len = head->data_len - plen;\n\t\thead->data_len -= clone->len;\n\t\thead->len -= clone->len;\n\t\tclone->csum = 0;\n\t\tclone->ip_summed = head->ip_summed;\n\n\t\tadd_frag_mem_limit(fq->q.net, clone->truesize);\n\t}\n\n\t\/* morph head into last received skb: prev.\n\t *\n\t * This allows callers of ipv6 conntrack defrag to continue\n\t * to use the last skb(frag) passed into the reasm engine.\n\t * The last skb frag 'silently' turns into the full reassembled skb.\n\t *\n\t * Since prev is also part of q->fragments we have to clone it first.\n\t *\/\n\tif (head != prev) {\n\t\tstruct sk_buff *iter;\n\n\t\tfp = skb_clone(prev, GFP_ATOMIC);\n\t\tif (!fp)\n\t\t\treturn false;\n\n\t\tfp->next = prev->next;\n\n\t\titer = head;\n\t\twhile (iter) {\n\t\t\tif (iter->next == prev) {\n\t\t\t\titer->next = fp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\titer = iter->next;\n\t\t}\n\n\t\tskb_morph(prev, head);\n\t\tprev->next = head->next;\n\t\tconsume_skb(head);\n\t\thead = prev;\n\t}\n\n\t\/* We have to remove fragment header from datagram and to relocate\n\t * header in order to calculate ICV correctly. *\/\n\tskb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0];\n\tmemmove(head->head + sizeof(struct frag_hdr), head->head,\n\t\t(head->data - head->head) - sizeof(struct frag_hdr));\n\thead->mac_header += sizeof(struct frag_hdr);\n\thead->network_header += sizeof(struct frag_hdr);\n\n\tskb_shinfo(head)->frag_list = head->next;\n\tskb_reset_transport_header(head);\n\tskb_push(head, head->data - skb_network_header(head));\n\n\tfor (fp = head->next; fp; fp = fp->next) {\n\t\thead->data_len += fp->len;\n\t\thead->len += fp->len;\n\t\tif (head->ip_summed != fp->ip_summed)\n\t\t\thead->ip_summed = CHECKSUM_NONE;\n\t\telse if (head->ip_summed == CHECKSUM_COMPLETE)\n\t\t\thead->csum = csum_add(head->csum, fp->csum);\n\t\thead->truesize += fp->truesize;\n\t}\n\tsub_frag_mem_limit(fq->q.net, head->truesize);\n\n\thead->ignore_df = 1;\n\thead->next = NULL;\n\thead->dev = dev;\n\thead->tstamp = fq->q.stamp;\n\tipv6_hdr(head)->payload_len = htons(payload_len);\n\tipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn);\n\tIP6CB(head)->frag_max_size = sizeof(struct ipv6hdr) + fq->q.max_size;\n\n\t\/* Yes, and fold redundant checksum back. 8) *\/\n\tif (head->ip_summed == CHECKSUM_COMPLETE)\n\t\thead->csum = csum_partial(skb_network_header(head),\n\t\t\t\t\t skb_network_header_len(head),\n\t\t\t\t\t head->csum);\n\n\tfq->q.fragments = NULL;\n\tfq->q.rb_fragments = RB_ROOT;\n\tfq->q.fragments_tail = NULL;\n\n\treturn true;\n}","target":1,"code_token_length":1103,"total_token_length":1339,"max_tokens_setting":2048} +{"idx":218844,"func":"AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const {\n if (!getNode())\n return UnknownRole;\n\n if (getNode()->isLink())\n return LinkRole;\n\n if (isHTMLAnchorElement(*getNode())) {\n if (isClickable())\n return LinkRole;\n return AnchorRole;\n }\n\n if (isHTMLButtonElement(*getNode()))\n return buttonRoleType();\n\n if (isHTMLDetailsElement(*getNode()))\n return DetailsRole;\n\n if (isHTMLSummaryElement(*getNode())) {\n ContainerNode* parent = FlatTreeTraversal::parent(*getNode());\n if (parent && isHTMLDetailsElement(parent))\n return DisclosureTriangleRole;\n return UnknownRole;\n }\n\n if (isHTMLInputElement(*getNode())) {\n HTMLInputElement& input = toHTMLInputElement(*getNode());\n const AtomicString& type = input.type();\n if (input.dataList())\n return ComboBoxRole;\n if (type == InputTypeNames::button) {\n if ((getNode()->parentNode() &&\n isHTMLMenuElement(getNode()->parentNode())) ||\n (parentObject() && parentObject()->roleValue() == MenuRole))\n return MenuItemRole;\n return buttonRoleType();\n }\n if (type == InputTypeNames::checkbox) {\n if ((getNode()->parentNode() &&\n isHTMLMenuElement(getNode()->parentNode())) ||\n (parentObject() && parentObject()->roleValue() == MenuRole))\n return MenuItemCheckBoxRole;\n return CheckBoxRole;\n }\n if (type == InputTypeNames::date)\n return DateRole;\n if (type == InputTypeNames::datetime ||\n type == InputTypeNames::datetime_local ||\n type == InputTypeNames::month || type == InputTypeNames::week)\n return DateTimeRole;\n if (type == InputTypeNames::file)\n return ButtonRole;\n if (type == InputTypeNames::radio) {\n if ((getNode()->parentNode() &&\n isHTMLMenuElement(getNode()->parentNode())) ||\n (parentObject() && parentObject()->roleValue() == MenuRole))\n return MenuItemRadioRole;\n return RadioButtonRole;\n }\n if (type == InputTypeNames::number)\n return SpinButtonRole;\n if (input.isTextButton())\n return buttonRoleType();\n if (type == InputTypeNames::range)\n return SliderRole;\n if (type == InputTypeNames::color)\n return ColorWellRole;\n if (type == InputTypeNames::time)\n return InputTimeRole;\n return TextFieldRole;\n }\n\n if (isHTMLSelectElement(*getNode())) {\n HTMLSelectElement& selectElement = toHTMLSelectElement(*getNode());\n return selectElement.isMultiple() ? ListBoxRole : PopUpButtonRole;\n }\n\n if (isHTMLTextAreaElement(*getNode()))\n return TextFieldRole;\n\n if (headingLevel())\n return HeadingRole;\n\n if (isHTMLDivElement(*getNode()))\n return DivRole;\n\n if (isHTMLMeterElement(*getNode()))\n return MeterRole;\n\n if (isHTMLOutputElement(*getNode()))\n return StatusRole;\n\n if (isHTMLParagraphElement(*getNode()))\n return ParagraphRole;\n\n if (isHTMLLabelElement(*getNode()))\n return LabelRole;\n\n if (isHTMLLegendElement(*getNode()))\n return LegendRole;\n\n if (isHTMLRubyElement(*getNode()))\n return RubyRole;\n\n if (isHTMLDListElement(*getNode()))\n return DescriptionListRole;\n\n if (isHTMLAudioElement(*getNode()))\n return AudioRole;\n if (isHTMLVideoElement(*getNode()))\n return VideoRole;\n\n if (getNode()->hasTagName(ddTag))\n return DescriptionListDetailRole;\n\n if (getNode()->hasTagName(dtTag))\n return DescriptionListTermRole;\n\n if (getNode()->nodeName() == \"math\")\n return MathRole;\n\n if (getNode()->hasTagName(rpTag) || getNode()->hasTagName(rtTag))\n return AnnotationRole;\n\n if (isHTMLFormElement(*getNode()))\n return FormRole;\n\n if (getNode()->hasTagName(abbrTag))\n return AbbrRole;\n\n if (getNode()->hasTagName(articleTag))\n return ArticleRole;\n\n if (getNode()->hasTagName(mainTag))\n return MainRole;\n\n if (getNode()->hasTagName(markTag))\n return MarkRole;\n\n if (getNode()->hasTagName(navTag))\n return NavigationRole;\n\n if (getNode()->hasTagName(asideTag))\n return ComplementaryRole;\n\n if (getNode()->hasTagName(preTag))\n return PreRole;\n\n if (getNode()->hasTagName(sectionTag))\n return RegionRole;\n\n if (getNode()->hasTagName(addressTag))\n return ContentInfoRole;\n\n if (isHTMLDialogElement(*getNode()))\n return DialogRole;\n\n if (isHTMLHtmlElement(*getNode()))\n return IgnoredRole;\n\n if (isHTMLIFrameElement(*getNode())) {\n const AtomicString& ariaRole =\n getAOMPropertyOrARIAAttribute(AOMStringProperty::kRole);\n if (ariaRole == \"none\" || ariaRole == \"presentation\")\n return IframePresentationalRole;\n return IframeRole;\n }\n\n if (getNode()->hasTagName(headerTag)) {\n if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))\n return GroupRole;\n return BannerRole;\n }\n\n if (getNode()->hasTagName(footerTag)) {\n if (isDescendantOfElementType(getLandmarkRolesNotAllowed()))\n return GroupRole;\n return FooterRole;\n }\n\n if (getNode()->hasTagName(blockquoteTag))\n return BlockquoteRole;\n\n if (getNode()->hasTagName(captionTag))\n return CaptionRole;\n\n if (getNode()->hasTagName(figcaptionTag))\n return FigcaptionRole;\n\n if (getNode()->hasTagName(figureTag))\n return FigureRole;\n\n if (getNode()->nodeName() == \"TIME\")\n return TimeRole;\n\n if (isEmbeddedObject())\n return EmbeddedObjectRole;\n\n if (isHTMLHRElement(*getNode()))\n return SplitterRole;\n\n if (isFieldset())\n return GroupRole;\n\n return UnknownRole;\n}\n","target":0,"code_token_length":1291,"total_token_length":1527,"max_tokens_setting":2048} +{"idx":236987,"func":"void RenderFrameHostManager::CommitPending() {\n TRACE_EVENT1(\"navigation\", \"RenderFrameHostManager::CommitPending\",\n \"FrameTreeNode id\", frame_tree_node_->frame_tree_node_id());\n DCHECK(pending_render_frame_host_ || speculative_render_frame_host_);\n\n bool is_main_frame = frame_tree_node_->IsMainFrame();\n\n bool will_focus_location_bar =\n is_main_frame && delegate_->FocusLocationBarByDefault();\n\n bool focus_render_view = !will_focus_location_bar &&\n render_frame_host_->GetView() &&\n render_frame_host_->GetView()->HasFocus();\n\n frame_tree_node_->ResetForNewProcess();\n\n std::unique_ptr old_render_frame_host;\n if (!IsBrowserSideNavigationEnabled()) {\n DCHECK(!speculative_render_frame_host_);\n old_render_frame_host =\n SetRenderFrameHost(std::move(pending_render_frame_host_));\n } else {\n DCHECK(speculative_render_frame_host_);\n old_render_frame_host =\n SetRenderFrameHost(std::move(speculative_render_frame_host_));\n }\n\n SkColor old_background_color = SK_ColorWHITE;\n bool has_old_background_color = false;\n if (old_render_frame_host->GetView()) {\n has_old_background_color = true;\n old_background_color = old_render_frame_host->GetView()->background_color();\n }\n\n bool new_rfh_has_view = !!render_frame_host_->GetView();\n if (!delegate_->IsHidden() && new_rfh_has_view) {\n render_frame_host_->GetView()->Show();\n }\n render_frame_host_->GetProcess()->RemovePendingView();\n\n if (!new_rfh_has_view) {\n DCHECK(!render_frame_host_->IsRenderFrameLive());\n DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive());\n render_frame_host_->ResetLoadingState();\n delegate_->RenderProcessGoneFromRenderManager(\n render_frame_host_->render_view_host());\n }\n\n if (is_main_frame &&\n old_render_frame_host->render_view_host()->GetWidget()->GetView()) {\n old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide();\n }\n\n delegate_->UpdateRenderViewSizeForRenderManager();\n\n if (will_focus_location_bar) {\n delegate_->SetFocusToLocationBar(false);\n } else if (focus_render_view && render_frame_host_->GetView()) {\n if (is_main_frame) {\n render_frame_host_->GetView()->Focus();\n } else {\n frame_tree_node_->frame_tree()->SetPageFocus(\n render_frame_host_->GetSiteInstance(), true);\n }\n }\n\n delegate_->NotifySwappedFromRenderManager(\n old_render_frame_host.get(), render_frame_host_.get(), is_main_frame);\n\n if (has_old_background_color && render_frame_host_->GetView())\n render_frame_host_->GetView()->SetBackgroundColor(old_background_color);\n\n if (is_main_frame) {\n RenderViewHostImpl* rvh = render_frame_host_->render_view_host();\n rvh->set_main_frame_routing_id(render_frame_host_->routing_id());\n\n if (!rvh->is_active())\n rvh->PostRenderViewReady();\n\n rvh->set_is_active(true);\n rvh->set_is_swapped_out(false);\n old_render_frame_host->render_view_host()->set_main_frame_routing_id(\n MSG_ROUTING_NONE);\n }\n\n SwapOutOldFrame(std::move(old_render_frame_host));\n\n DeleteRenderFrameProxyHost(render_frame_host_->GetSiteInstance());\n\n RenderFrameProxyHost* proxy_to_parent = GetProxyToParent();\n if (proxy_to_parent) {\n CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());\n proxy_to_parent->SetChildRWHView(render_frame_host_->GetView());\n }\n\n CHECK(!GetRenderFrameProxyHost(render_frame_host_->GetSiteInstance()));\n}\n","target":0,"code_token_length":801,"total_token_length":1037,"max_tokens_setting":2048} +{"idx":516180,"func":"int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk)\n{\n X509 *x;\n int i = 0;\n X509_STORE *verify_store;\n X509_STORE_CTX *ctx = NULL;\n X509_VERIFY_PARAM *param;\n\n if ((sk == NULL) || (sk_X509_num(sk) == 0))\n return 0;\n\n if (s->cert->verify_store)\n verify_store = s->cert->verify_store;\n else\n verify_store = s->ctx->cert_store;\n\n ctx = X509_STORE_CTX_new_ex(s->ctx->libctx, s->ctx->propq);\n if (ctx == NULL) {\n ERR_raise(ERR_LIB_SSL, ERR_R_MALLOC_FAILURE);\n return 0;\n }\n\n x = sk_X509_value(sk, 0);\n if (!X509_STORE_CTX_init(ctx, verify_store, x, sk)) {\n ERR_raise(ERR_LIB_SSL, ERR_R_X509_LIB);\n goto end;\n }\n param = X509_STORE_CTX_get0_param(ctx);\n \/*\n * XXX: Separate @AUTHSECLEVEL and @TLSSECLEVEL would be useful at some\n * point, for now a single @SECLEVEL sets the same policy for TLS crypto\n * and PKI authentication.\n *\/\n X509_VERIFY_PARAM_set_auth_level(param, SSL_get_security_level(s));\n\n \/* Set suite B flags if needed *\/\n X509_STORE_CTX_set_flags(ctx, tls1_suiteb(s));\n if (!X509_STORE_CTX_set_ex_data\n (ctx, SSL_get_ex_data_X509_STORE_CTX_idx(), s)) {\n goto end;\n }\n\n \/* Verify via DANE if enabled *\/\n if (DANETLS_ENABLED(&s->dane))\n X509_STORE_CTX_set0_dane(ctx, &s->dane);\n\n \/*\n * We need to inherit the verify parameters. These can be determined by\n * the context: if its a server it will verify SSL client certificates or\n * vice versa.\n *\/\n\n X509_STORE_CTX_set_default(ctx, s->server ? \"ssl_client\" : \"ssl_server\");\n \/*\n * Anything non-default in \"s->param\" should overwrite anything in the ctx.\n *\/\n X509_VERIFY_PARAM_set1(param, s->param);\n\n if (s->verify_callback)\n X509_STORE_CTX_set_verify_cb(ctx, s->verify_callback);\n\n if (s->ctx->app_verify_callback != NULL) {\n i = s->ctx->app_verify_callback(ctx, s->ctx->app_verify_arg);\n } else {\n i = X509_verify_cert(ctx);\n \/* We treat an error in the same way as a failure to verify *\/\n if (i < 0)\n i = 0;\n }\n\n s->verify_result = X509_STORE_CTX_get_error(ctx);\n sk_X509_pop_free(s->verified_chain, X509_free);\n s->verified_chain = NULL;\n if (X509_STORE_CTX_get0_chain(ctx) != NULL) {\n s->verified_chain = X509_STORE_CTX_get1_chain(ctx);\n if (s->verified_chain == NULL) {\n ERR_raise(ERR_LIB_SSL, ERR_R_MALLOC_FAILURE);\n i = 0;\n }\n }\n\n \/* Move peername from the store context params to the SSL handle's *\/\n X509_VERIFY_PARAM_move_peername(s->param, param);\n\n end:\n X509_STORE_CTX_free(ctx);\n return i;\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048} +{"idx":57987,"func":"_rdpdr_check_fds(fd_set * rfds, fd_set * wfds, RD_BOOL timed_out)\n{\n\tRD_NTSTATUS status;\n\tuint32 result = 0;\n\tDEVICE_FNS *fns;\n\tstruct async_iorequest *iorq;\n\tstruct async_iorequest *prev;\n\tuint32 req_size = 0;\n\tuint32 buffer_len;\n\tstruct stream out;\n\tuint8 *buffer = NULL;\n\n\n\tif (timed_out)\n\t{\n\t\t\/* check serial iv_timeout *\/\n\n\t\tiorq = g_iorequest;\n\t\tprev = NULL;\n\t\twhile (iorq != NULL)\n\t\t{\n\t\t\tif (iorq->fd == g_min_timeout_fd)\n\t\t\t{\n\t\t\t\tif ((iorq->partial_len > 0) &&\n\t\t\t\t (g_rdpdr_device[iorq->device].device_type ==\n\t\t\t\t DEVICE_TYPE_SERIAL))\n\t\t\t\t{\n\n\t\t\t\t\t\/* iv_timeout between 2 chars, send partial_len *\/\n\t\t\t\t\t\/*printf(\"RDPDR: IVT total %u bytes read of %u\\n\", iorq->partial_len, iorq->length); *\/\n\t\t\t\t\trdpdr_send_completion(iorq->device,\n\t\t\t\t\t\t\t iorq->id, RD_STATUS_SUCCESS,\n\t\t\t\t\t\t\t iorq->partial_len,\n\t\t\t\t\t\t\t iorq->buffer, iorq->partial_len);\n\t\t\t\t\tiorq = rdpdr_remove_iorequest(prev, iorq);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\n\n\t\t\tprev = iorq;\n\t\t\tif (iorq)\n\t\t\t\tiorq = iorq->next;\n\n\t\t}\n\n\t\trdpdr_abort_io(g_min_timeout_fd, 0, RD_STATUS_TIMEOUT);\n\t\treturn;\n\t}\n\n\tiorq = g_iorequest;\n\tprev = NULL;\n\twhile (iorq != NULL)\n\t{\n\t\tif (iorq->fd != 0)\n\t\t{\n\t\t\tswitch (iorq->major)\n\t\t\t{\n\t\t\t\tcase IRP_MJ_READ:\n\t\t\t\t\tif (FD_ISSET(iorq->fd, rfds))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Read the data *\/\n\t\t\t\t\t\tfns = iorq->fns;\n\n\t\t\t\t\t\treq_size =\n\t\t\t\t\t\t\t(iorq->length - iorq->partial_len) >\n\t\t\t\t\t\t\t8192 ? 8192 : (iorq->length -\n\t\t\t\t\t\t\t\t iorq->partial_len);\n\t\t\t\t\t\t\/* never read larger chunks than 8k - chances are that it will block *\/\n\t\t\t\t\t\tstatus = fns->read(iorq->fd,\n\t\t\t\t\t\t\t\t iorq->buffer + iorq->partial_len,\n\t\t\t\t\t\t\t\t req_size, iorq->offset, &result);\n\n\t\t\t\t\t\tif ((long) result > 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tiorq->partial_len += result;\n\t\t\t\t\t\t\tiorq->offset += result;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogger(Protocol, Debug,\n\t\t\t\t\t\t \"_rdpdr_check_fds(), %d bytes of data read\",\n\t\t\t\t\t\t result);\n\n\t\t\t\t\t\t\/* only delete link if all data has been transfered *\/\n\t\t\t\t\t\t\/* or if result was 0 and status success - EOF *\/\n\t\t\t\t\t\tif ((iorq->partial_len == iorq->length) ||\n\t\t\t\t\t\t (result == 0))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlogger(Protocol, Debug,\n\t\t\t\t\t\t\t \"_rdpdr_check_fds(), AIO total %u bytes read of %u\",\n\t\t\t\t\t\t\t iorq->partial_len, iorq->length);\n\t\t\t\t\t\t\trdpdr_send_completion(iorq->device,\n\t\t\t\t\t\t\t\t\t iorq->id, status,\n\t\t\t\t\t\t\t\t\t iorq->partial_len,\n\t\t\t\t\t\t\t\t\t iorq->buffer,\n\t\t\t\t\t\t\t\t\t iorq->partial_len);\n\t\t\t\t\t\t\tiorq = rdpdr_remove_iorequest(prev, iorq);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase IRP_MJ_WRITE:\n\t\t\t\t\tif (FD_ISSET(iorq->fd, wfds))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Write data. *\/\n\t\t\t\t\t\tfns = iorq->fns;\n\n\t\t\t\t\t\treq_size =\n\t\t\t\t\t\t\t(iorq->length - iorq->partial_len) >\n\t\t\t\t\t\t\t8192 ? 8192 : (iorq->length -\n\t\t\t\t\t\t\t\t iorq->partial_len);\n\n\t\t\t\t\t\t\/* never write larger chunks than 8k - chances are that it will block *\/\n\t\t\t\t\t\tstatus = fns->write(iorq->fd,\n\t\t\t\t\t\t\t\t iorq->buffer +\n\t\t\t\t\t\t\t\t iorq->partial_len, req_size,\n\t\t\t\t\t\t\t\t iorq->offset, &result);\n\n\t\t\t\t\t\tif ((long) result > 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tiorq->partial_len += result;\n\t\t\t\t\t\t\tiorq->offset += result;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogger(Protocol, Debug,\n\t\t\t\t\t\t \"_rdpdr_check_fds(), %d bytes of data written\",\n\t\t\t\t\t\t result);\n\n\t\t\t\t\t\t\/* only delete link if all data has been transfered *\/\n\t\t\t\t\t\t\/* or we couldn't write *\/\n\t\t\t\t\t\tif ((iorq->partial_len == iorq->length)\n\t\t\t\t\t\t || (result == 0))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlogger(Protocol, Debug,\n\t\t\t\t\t\t\t \"_rdpdr_check_fds(), AIO total %u bytes written of %u\",\n\t\t\t\t\t\t\t iorq->partial_len, iorq->length);\n\t\t\t\t\t\t\trdpdr_send_completion(iorq->device,\n\t\t\t\t\t\t\t\t\t iorq->id, status,\n\t\t\t\t\t\t\t\t\t iorq->partial_len,\n\t\t\t\t\t\t\t\t\t (uint8 *) \"\", 1);\n\n\t\t\t\t\t\t\tiorq = rdpdr_remove_iorequest(prev, iorq);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase IRP_MJ_DEVICE_CONTROL:\n\t\t\t\t\tif (serial_get_event(iorq->fd, &result))\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer = (uint8 *) xrealloc((void *) buffer, 0x14);\n\t\t\t\t\t\tout.data = out.p = buffer;\n\t\t\t\t\t\tout.size = sizeof(buffer);\n\t\t\t\t\t\tout_uint32_le(&out, result);\n\t\t\t\t\t\tresult = buffer_len = out.p - out.data;\n\t\t\t\t\t\tstatus = RD_STATUS_SUCCESS;\n\t\t\t\t\t\trdpdr_send_completion(iorq->device, iorq->id,\n\t\t\t\t\t\t\t\t status, result, buffer,\n\t\t\t\t\t\t\t\t buffer_len);\n\t\t\t\t\t\txfree(buffer);\n\t\t\t\t\t\tiorq = rdpdr_remove_iorequest(prev, iorq);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\t\tprev = iorq;\n\t\tif (iorq)\n\t\t\tiorq = iorq->next;\n\t}\n\n\t\/* Check notify *\/\n\tiorq = g_iorequest;\n\tprev = NULL;\n\twhile (iorq != NULL)\n\t{\n\t\tif (iorq->fd != 0)\n\t\t{\n\t\t\tswitch (iorq->major)\n\t\t\t{\n\n\t\t\t\tcase IRP_MJ_DIRECTORY_CONTROL:\n\t\t\t\t\tif (g_rdpdr_device[iorq->device].device_type ==\n\t\t\t\t\t DEVICE_TYPE_DISK)\n\t\t\t\t\t{\n\n\t\t\t\t\t\tif (g_notify_stamp)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tg_notify_stamp = False;\n\t\t\t\t\t\t\tstatus = disk_check_notify(iorq->fd);\n\t\t\t\t\t\t\tif (status != RD_STATUS_PENDING)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trdpdr_send_completion(iorq->device,\n\t\t\t\t\t\t\t\t\t\t iorq->id,\n\t\t\t\t\t\t\t\t\t\t status, 0,\n\t\t\t\t\t\t\t\t\t\t NULL, 0);\n\t\t\t\t\t\t\t\tiorq = rdpdr_remove_iorequest(prev,\n\t\t\t\t\t\t\t\t\t\t\t iorq);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\n\n\t\t\t}\n\t\t}\n\n\t\tprev = iorq;\n\t\tif (iorq)\n\t\t\tiorq = iorq->next;\n\t}\n\n}","target":0,"code_token_length":1602,"total_token_length":1838,"max_tokens_setting":2048} +{"idx":347162,"func":"static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)\n{\n\tjpc_siz_t *siz = &ms->parms.siz;\n\tint compno;\n\tint tileno;\n\tjpc_dec_tile_t *tile;\n\tjpc_dec_tcomp_t *tcomp;\n\tint htileno;\n\tint vtileno;\n\tjpc_dec_cmpt_t *cmpt;\n\tsize_t size;\n\tsize_t num_samples;\n\tsize_t num_samples_delta;\n\n\tsize_t tile_samples;\n\tif (!jas_safe_size_mul(siz->tilewidth, siz->tileheight, &tile_samples) ||\n\t (dec->max_samples > 0 && tile_samples > dec->max_samples)) {\n\t\tjas_eprintf(\"tile too large\\n\");\n\t\treturn -1;\n\t}\n\n\tdec->xstart = siz->xoff;\n\tdec->ystart = siz->yoff;\n\tdec->xend = siz->width;\n\tdec->yend = siz->height;\n\tdec->tilewidth = siz->tilewidth;\n\tdec->tileheight = siz->tileheight;\n\tdec->tilexoff = siz->tilexoff;\n\tdec->tileyoff = siz->tileyoff;\n\tdec->numcomps = siz->numcomps;\n\n\tif (!(dec->cp = jpc_dec_cp_create(dec->numcomps))) {\n\t\treturn -1;\n\t}\n\n\tif (!(dec->cmpts = jas_alloc2(dec->numcomps, sizeof(jpc_dec_cmpt_t)))) {\n\t\treturn -1;\n\t}\n\n\tnum_samples = 0;\n\tfor (compno = 0, cmpt = dec->cmpts; compno < dec->numcomps; ++compno,\n\t ++cmpt) {\n\t\tcmpt->prec = siz->comps[compno].prec;\n\t\tcmpt->sgnd = siz->comps[compno].sgnd;\n\t\tcmpt->hstep = siz->comps[compno].hsamp;\n\t\tcmpt->vstep = siz->comps[compno].vsamp;\n\t\tcmpt->width = JPC_CEILDIV(dec->xend, cmpt->hstep) -\n\t\t JPC_CEILDIV(dec->xstart, cmpt->hstep);\n\t\tcmpt->height = JPC_CEILDIV(dec->yend, cmpt->vstep) -\n\t\t JPC_CEILDIV(dec->ystart, cmpt->vstep);\n\t\tcmpt->hsubstep = 0;\n\t\tcmpt->vsubstep = 0;\n\n\t\tif (!jas_safe_size_mul(cmpt->width, cmpt->height, &num_samples_delta)) {\n\t\t\tjas_eprintf(\"image too large\\n\");\n\t\t\treturn -1;\n\t\t}\n\t\tif (!jas_safe_size_add(num_samples, num_samples_delta, &num_samples)) {\n\t\t\tjas_eprintf(\"image too large\\n\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (dec->max_samples > 0 && num_samples > dec->max_samples) {\n\t\tjas_eprintf(\"maximum number of samples exceeded (%zu > %zu)\\n\",\n\t\t num_samples, dec->max_samples);\n\t\treturn -1;\n\t}\n\n\tdec->image = 0;\n\n\tdec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);\n\tdec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);\n\tassert(dec->numhtiles >= 0);\n\tassert(dec->numvtiles >= 0);\n\tif (!jas_safe_size_mul(dec->numhtiles, dec->numvtiles, &size) ||\n\t size > INT_MAX) {\n\t\treturn -1;\n\t}\n\tif (dec->max_samples > 0 && size > dec->max_samples \/ 16 \/ 16) {\n\t\t\/* avoid Denial of Service by a malicious input file\n\t\t with millions of tiny tiles; if max_samples is\n\t\t configured, then assume the tiles are at least\n\t\t 16x16, and don't allow more than this number of\n\t\t tiles *\/\n\t\treturn -1;\n\t}\n\tif (dec->max_samples > 0 && size > dec->max_samples \/ dec->numcomps \/ 16) {\n\t\t\/* another DoS check: since each tile allocates an\n\t\t array of components, this check attempts to catch\n\t\t excessive tile*component numbers *\/\n\t\treturn -1;\n\t}\n\tdec->numtiles = size;\n\tJAS_DBGLOG(10, (\"numtiles = %d; numhtiles = %d; numvtiles = %d;\\n\",\n\t dec->numtiles, dec->numhtiles, dec->numvtiles));\n\tif (!(dec->tiles = jas_alloc2(dec->numtiles, sizeof(jpc_dec_tile_t)))) {\n\t\treturn -1;\n\t}\n\n\tfor (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,\n\t ++tile) {\n\t\t\/* initialize all tiles with JPC_TILE_DONE so\n\t\t jpc_dec_destroy() knows which ones need a\n\t\t jpc_dec_tilefini() call; they are not actually\n\t\t \"done\", of course *\/\n\t\ttile->state = JPC_TILE_DONE;\n\t}\n\n\tfor (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,\n\t ++tile) {\n\t\thtileno = tileno % dec->numhtiles;\n\t\tvtileno = tileno \/ dec->numhtiles;\n\t\ttile->realmode = 0;\n\t\ttile->state = JPC_TILE_INIT;\n\t\ttile->xstart = JAS_MAX(dec->tilexoff + htileno * dec->tilewidth,\n\t\t dec->xstart);\n\t\ttile->ystart = JAS_MAX(dec->tileyoff + vtileno * dec->tileheight,\n\t\t dec->ystart);\n\t\ttile->xend = JAS_MIN(dec->tilexoff + (htileno + 1) *\n\t\t dec->tilewidth, dec->xend);\n\t\ttile->yend = JAS_MIN(dec->tileyoff + (vtileno + 1) *\n\t\t dec->tileheight, dec->yend);\n\t\ttile->numparts = 0;\n\t\ttile->partno = 0;\n\t\ttile->pkthdrstream = 0;\n\t\ttile->pkthdrstreampos = 0;\n\t\ttile->pptstab = 0;\n\t\ttile->cp = 0;\n\t\ttile->pi = 0;\n\t\tif (!(tile->tcomps = jas_alloc2(dec->numcomps,\n\t\t sizeof(jpc_dec_tcomp_t)))) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (compno = 0, cmpt = dec->cmpts, tcomp = tile->tcomps;\n\t\t compno < dec->numcomps; ++compno, ++cmpt, ++tcomp) {\n\t\t\ttcomp->rlvls = 0;\n\t\t\ttcomp->numrlvls = 0;\n\t\t\ttcomp->data = 0;\n\t\t\ttcomp->xstart = JPC_CEILDIV(tile->xstart, cmpt->hstep);\n\t\t\ttcomp->ystart = JPC_CEILDIV(tile->ystart, cmpt->vstep);\n\t\t\ttcomp->xend = JPC_CEILDIV(tile->xend, cmpt->hstep);\n\t\t\ttcomp->yend = JPC_CEILDIV(tile->yend, cmpt->vstep);\n\t\t\ttcomp->tsfb = 0;\n\t\t}\n\t}\n\n\tdec->pkthdrstreams = 0;\n\n\t\/* We should expect to encounter other main header marker segments\n\t or an SOT marker segment next. *\/\n\tdec->state = JPC_MH;\n\n\treturn 0;\n}","target":1,"code_token_length":1680,"total_token_length":1916,"max_tokens_setting":2048} +{"idx":30750,"func":"static void write_crash_report ( const char * err ) {\n char * loc = git_pathdup ( \"fast_import_crash_%\" PRIuMAX , ( uintmax_t ) getpid ( ) ) ;\n FILE * rpt = fopen ( loc , \"w\" ) ;\n struct branch * b ;\n unsigned long lu ;\n struct recent_command * rc ;\n if ( ! rpt ) {\n error ( \"can't write crash report %s: %s\" , loc , strerror ( errno ) ) ;\n free ( loc ) ;\n return ;\n }\n fprintf ( stderr , \"fast-import: dumping crash report to %s\\n\" , loc ) ;\n fprintf ( rpt , \"fast-import crash report:\\n\" ) ;\n fprintf ( rpt , \" fast-import process: %\" PRIuMAX \"\\n\" , ( uintmax_t ) getpid ( ) ) ;\n fprintf ( rpt , \" parent process : %\" PRIuMAX \"\\n\" , ( uintmax_t ) getppid ( ) ) ;\n fprintf ( rpt , \" at %s\\n\" , show_date ( time ( NULL ) , 0 , DATE_MODE ( LOCAL ) ) ) ;\n fputc ( '\\n' , rpt ) ;\n fputs ( \"fatal: \" , rpt ) ;\n fputs ( err , rpt ) ;\n fputc ( '\\n' , rpt ) ;\n fputc ( '\\n' , rpt ) ;\n fputs ( \"Most Recent Commands Before Crash\\n\" , rpt ) ;\n fputs ( \"---------------------------------\\n\" , rpt ) ;\n for ( rc = cmd_hist . next ;\n rc != & cmd_hist ;\n rc = rc -> next ) {\n if ( rc -> next == & cmd_hist ) fputs ( \"* \" , rpt ) ;\n else fputs ( \" \" , rpt ) ;\n fputs ( rc -> buf , rpt ) ;\n fputc ( '\\n' , rpt ) ;\n }\n fputc ( '\\n' , rpt ) ;\n fputs ( \"Active Branch LRU\\n\" , rpt ) ;\n fputs ( \"-----------------\\n\" , rpt ) ;\n fprintf ( rpt , \" active_branches = %lu cur, %lu max\\n\" , cur_active_branches , max_active_branches ) ;\n fputc ( '\\n' , rpt ) ;\n fputs ( \" pos clock name\\n\" , rpt ) ;\n fputs ( \" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n\" , rpt ) ;\n for ( b = active_branches , lu = 0 ;\n b ;\n b = b -> active_next_branch ) fprintf ( rpt , \" %2lu) %6\" PRIuMAX \" %s\\n\" , ++ lu , b -> last_commit , b -> name ) ;\n fputc ( '\\n' , rpt ) ;\n fputs ( \"Inactive Branches\\n\" , rpt ) ;\n fputs ( \"-----------------\\n\" , rpt ) ;\n for ( lu = 0 ;\n lu < branch_table_sz ;\n lu ++ ) {\n for ( b = branch_table [ lu ] ;\n b ;\n b = b -> table_next_branch ) write_branch_report ( rpt , b ) ;\n }\n if ( first_tag ) {\n struct tag * tg ;\n fputc ( '\\n' , rpt ) ;\n fputs ( \"Annotated Tags\\n\" , rpt ) ;\n fputs ( \"--------------\\n\" , rpt ) ;\n for ( tg = first_tag ;\n tg ;\n tg = tg -> next_tag ) {\n fputs ( sha1_to_hex ( tg -> sha1 ) , rpt ) ;\n fputc ( ' ' , rpt ) ;\n fputs ( tg -> name , rpt ) ;\n fputc ( '\\n' , rpt ) ;\n }\n }\n fputc ( '\\n' , rpt ) ;\n fputs ( \"Marks\\n\" , rpt ) ;\n fputs ( \"-----\\n\" , rpt ) ;\n if ( export_marks_file ) fprintf ( rpt , \" exported to %s\\n\" , export_marks_file ) ;\n else dump_marks_helper ( rpt , 0 , marks ) ;\n fputc ( '\\n' , rpt ) ;\n fputs ( \"-------------------\\n\" , rpt ) ;\n fputs ( \"END OF CRASH REPORT\\n\" , rpt ) ;\n fclose ( rpt ) ;\n free ( loc ) ;\n }","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048} +{"idx":321575,"func":"void do_interrupt(CPUARMState *env)\n\n{\n\n uint32_t addr;\n\n uint32_t mask;\n\n int new_mode;\n\n uint32_t offset;\n\n\n\n if (IS_M(env)) {\n\n do_interrupt_v7m(env);\n\n return;\n\n }\n\n \/* TODO: Vectored interrupt controller. *\/\n\n switch (env->exception_index) {\n\n case EXCP_UDEF:\n\n new_mode = ARM_CPU_MODE_UND;\n\n addr = 0x04;\n\n mask = CPSR_I;\n\n if (env->thumb)\n\n offset = 2;\n\n else\n\n offset = 4;\n\n break;\n\n case EXCP_SWI:\n\n if (semihosting_enabled) {\n\n \/* Check for semihosting interrupt. *\/\n\n if (env->thumb) {\n\n mask = lduw_code(env->regs[15] - 2) & 0xff;\n\n } else {\n\n mask = ldl_code(env->regs[15] - 4) & 0xffffff;\n\n }\n\n \/* Only intercept calls from privileged modes, to provide some\n\n semblance of security. *\/\n\n if (((mask == 0x123456 && !env->thumb)\n\n || (mask == 0xab && env->thumb))\n\n && (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {\n\n env->regs[0] = do_arm_semihosting(env);\n\n return;\n\n }\n\n }\n\n new_mode = ARM_CPU_MODE_SVC;\n\n addr = 0x08;\n\n mask = CPSR_I;\n\n \/* The PC already points to the next instruction. *\/\n\n offset = 0;\n\n break;\n\n case EXCP_BKPT:\n\n \/* See if this is a semihosting syscall. *\/\n\n if (env->thumb && semihosting_enabled) {\n\n mask = lduw_code(env->regs[15]) & 0xff;\n\n if (mask == 0xab\n\n && (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {\n\n env->regs[15] += 2;\n\n env->regs[0] = do_arm_semihosting(env);\n\n return;\n\n }\n\n }\n\n env->cp15.c5_insn = 2;\n\n \/* Fall through to prefetch abort. *\/\n\n case EXCP_PREFETCH_ABORT:\n\n new_mode = ARM_CPU_MODE_ABT;\n\n addr = 0x0c;\n\n mask = CPSR_A | CPSR_I;\n\n offset = 4;\n\n break;\n\n case EXCP_DATA_ABORT:\n\n new_mode = ARM_CPU_MODE_ABT;\n\n addr = 0x10;\n\n mask = CPSR_A | CPSR_I;\n\n offset = 8;\n\n break;\n\n case EXCP_IRQ:\n\n new_mode = ARM_CPU_MODE_IRQ;\n\n addr = 0x18;\n\n \/* Disable IRQ and imprecise data aborts. *\/\n\n mask = CPSR_A | CPSR_I;\n\n offset = 4;\n\n break;\n\n case EXCP_FIQ:\n\n new_mode = ARM_CPU_MODE_FIQ;\n\n addr = 0x1c;\n\n \/* Disable FIQ, IRQ and imprecise data aborts. *\/\n\n mask = CPSR_A | CPSR_I | CPSR_F;\n\n offset = 4;\n\n break;\n\n default:\n\n cpu_abort(env, \"Unhandled exception 0x%x\\n\", env->exception_index);\n\n return; \/* Never happens. Keep compiler happy. *\/\n\n }\n\n \/* High vectors. *\/\n\n if (env->cp15.c1_sys & (1 << 13)) {\n\n addr += 0xffff0000;\n\n }\n\n switch_mode (env, new_mode);\n\n env->spsr = cpsr_read(env);\n\n \/* Clear IT bits. *\/\n\n env->condexec_bits = 0;\n\n \/* Switch to the new mode, and to the correct instruction set. *\/\n\n env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;\n\n env->uncached_cpsr |= mask;\n\n \/* this is a lie, as the was no c1_sys on V4T\/V5, but who cares\n\n * and we should just guard the thumb mode on V4 *\/\n\n if (arm_feature(env, ARM_FEATURE_V4T)) {\n\n env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;\n\n }\n\n env->regs[14] = env->regs[15] + offset;\n\n env->regs[15] = addr;\n\n env->interrupt_request |= CPU_INTERRUPT_EXITTB;\n\n}\n","target":1,"code_token_length":1028,"total_token_length":1264,"max_tokens_setting":2048} +{"idx":346260,"func":"static inline void Process_ipfix_option_templates(exporter_ipfix_domain_t *exporter, void *option_template_flowset, FlowSource_t *fs) {\nvoid\t\t*DataPtr;\nuint32_t\tsize_left, size_required, i;\n\/\/ uint32_t nr_scopes, nr_options;\nuint16_t\tid, field_count, scope_field_count, offset, sampler_id_length;\nuint16_t\toffset_sampler_id, offset_sampler_mode, offset_sampler_interval, found_sampler;\nuint16_t\toffset_std_sampler_interval, offset_std_sampler_algorithm, found_std_sampling;\n\n\ti = 0;\t\/\/ keep compiler happy\n\tsize_left \t\t = GET_FLOWSET_LENGTH(option_template_flowset) - 4; \/\/ -4 for flowset header -> id and length\n\tif ( size_left < 6 ) {\n\t\tsyslog(LOG_ERR, \"Process_ipfix: [%u] option template length error: size left %u too small for an options template\", \n\t\t\texporter->info.id, size_left);\n\t\treturn;\n\t}\n\n\tDataPtr \t\t = option_template_flowset + 4;\n\tid \t \t\t\t = GET_OPTION_TEMPLATE_ID(DataPtr); \n\tfield_count \t = GET_OPTION_TEMPLATE_FIELD_COUNT(DataPtr);\n\tscope_field_count = GET_OPTION_TEMPLATE_SCOPE_FIELD_COUNT(DataPtr);\n\tDataPtr += 6;\n\tsize_left -= 6;\n\n\tif ( scope_field_count == 0 ) {\n\t\tsyslog(LOG_ERR, \"Process_ipfx: [%u] scope field count error: length must not be zero\", \n\t\t\texporter->info.id);\n\t\tdbg_printf(\"scope field count error: length must not be zero\\n\");\n\t\treturn;\n\t}\n\n\tsize_required = field_count * 2 * sizeof(uint16_t);\n\tdbg_printf(\"Size left: %u, size required: %u\\n\", size_left, size_required);\n\tif ( size_left < size_required ) {\n\t\tsyslog(LOG_ERR, \"Process_ipfix: [%u] option template length error: size left %u too small for %u scopes length and %u options length\", \n\t\t\texporter->info.id, size_left, field_count, scope_field_count);\n\t\tdbg_printf(\"option template length error: size left %u too small for field_count %u\\n\", \n\t\t\tsize_left, field_count);\n\t\treturn;\n\t}\n\n\tdbg_printf(\"Decode Option Template. id: %u, field count: %u, scope field count: %u\\n\",\n\t\tid, field_count, scope_field_count);\n\n\tif ( scope_field_count == 0 ) {\n\t\tsyslog(LOG_ERR, \"Process_ipfxi: [%u] scope field count error: length must not be zero\", \n\t\t\texporter->info.id);\n\t\treturn;\n\t}\n\n\tfor ( i=0; iinfo.id, size_left, field_count, scope_field_count);\n\t\t\t\tdbg_printf(\"option template length error: size left %u too small for field_count %u\\n\", \n\t\t\t\t\tsize_left, field_count);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tenterprise_value = Get_val32(DataPtr);\n\t\t\tDataPtr += 4;\n\t\t\tdbg_printf(\" [%i] Enterprise: 1, scope id: %u, scope length %u enterprise value: %u\\n\", \n\t\t\t\ti, id, length, enterprise_value);\n\t\t} else {\n\t\t\tdbg_printf(\" [%i] Enterprise: 0, scope id: %u, scope length %u\\n\", i, id, length);\n\t\t}\n\t}\n\tfor ( ;iinfo.id, size_left, field_count, scope_field_count);\n\t\t\t\tdbg_printf(\"option template length error: size left %u too small for field_count %u\\n\", \n\t\t\t\t\tsize_left, field_count);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tenterprise_value = Get_val32(DataPtr);\n\t\t\tDataPtr += 4;\n\t\t\tdbg_printf(\" [%i] Enterprise: 1, option id: %u, option length %u enterprise value: %u\\n\", \n\t\t\t\ti, id, length, enterprise_value);\n\t\t} else {\n\t\t\tdbg_printf(\" [%i] Enterprise: 0, option id: %u, option length %u\\n\", i, id, length);\n\t\t}\n\t}\n\n\tsampler_id_length\t\t\t = 0;\n\toffset_sampler_id \t\t\t = 0;\n\toffset_sampler_mode \t\t = 0;\n\toffset_sampler_interval \t = 0;\n\toffset_std_sampler_interval = 0;\n\toffset_std_sampler_algorithm = 0;\n\tfound_sampler\t\t\t\t = 0;\n\tfound_std_sampling\t\t\t = 0;\n\toffset = 0;\n\n\/* XXX\n XXX Sampling for IPFIX not yet implemented due to lack of data and information\n\t\tswitch (type) {\n\t\t\t\/\/ general sampling\n\t\t\tcase NF9_SAMPLING_INTERVAL:\n\t\t\t\toffset_std_sampler_interval = offset;\n\t\t\t\tfound_std_sampling++;\n\t\t\t\tbreak;\n\t\t\tcase NF9_SAMPLING_ALGORITHM:\n\t\t\t\toffset_std_sampler_algorithm = offset;\n\t\t\t\tfound_std_sampling++;\n\t\t\t\tbreak;\n\n\t\t\t\/\/ individual samplers\n\t\t\tcase NF9_FLOW_SAMPLER_ID:\n\t\t\t\toffset_sampler_id = offset;\n\t\t\t\tsampler_id_length = length;\n\t\t\t\tfound_sampler++;\n\t\t\t\tbreak;\n\t\t\tcase FLOW_SAMPLER_MODE:\n\t\t\t\toffset_sampler_mode = offset;\n\t\t\t\tfound_sampler++;\n\t\t\t\tbreak;\n\t\t\tcase NF9_FLOW_SAMPLER_RANDOM_INTERVAL:\n\t\t\t\toffset_sampler_interval = offset;\n\t\t\t\tfound_sampler++;\n\t\t\t\tbreak;\n\t\t}\n\t\toffset += length;\n\tif ( found_sampler == 3 ) { \/\/ need all three tags\n\t\tdbg_printf(\"[%u] Sampling information found\\n\", exporter->info.id);\n\t\tInsertSamplerOffset(fs, id, offset_sampler_id, sampler_id_length, offset_sampler_mode, offset_sampler_interval);\n\t} else if ( found_std_sampling == 2 ) { \/\/ need all two tags\n\t\tdbg_printf(\"[%u] Std sampling information found\\n\", exporter->info.id);\n\t\tInsertStdSamplerOffset(fs, id, offset_std_sampler_interval, offset_std_sampler_algorithm);\n\t} else {\n\t\tdbg_printf(\"[%u] No Sampling information found\\n\", exporter->info.id);\n\t}\n*\/\n\tdbg_printf(\"\\n\");\n\tprocessed_records++;\n\n} \/\/ End of Process_ipfix_option_templates","target":1,"code_token_length":1631,"total_token_length":1867,"max_tokens_setting":2048} +{"idx":458124,"func":"static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,\n OPJ_BYTE * p_data,\n OPJ_UINT32 * p_data_written,\n OPJ_UINT32 total_data_size,\n opj_stream_private_t *p_stream,\n struct opj_event_mgr * p_manager\n )\n{\n OPJ_UINT32 tilepartno = 0;\n OPJ_UINT32 l_nb_bytes_written = 0;\n OPJ_UINT32 l_current_nb_bytes_written;\n OPJ_UINT32 l_part_tile_size;\n OPJ_UINT32 tot_num_tp;\n OPJ_UINT32 pino;\n\n OPJ_BYTE * l_begin_data;\n opj_tcp_t *l_tcp = 00;\n opj_tcd_t * l_tcd = 00;\n opj_cp_t * l_cp = 00;\n\n l_tcd = p_j2k->m_tcd;\n l_cp = &(p_j2k->m_cp);\n l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;\n\n \/*Get number of tile parts*\/\n tot_num_tp = opj_j2k_get_num_tp(l_cp, 0, p_j2k->m_current_tile_number);\n\n \/* start writing remaining tile parts *\/\n ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;\n for (tilepartno = 1; tilepartno < tot_num_tp ; ++tilepartno) {\n p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;\n l_current_nb_bytes_written = 0;\n l_part_tile_size = 0;\n l_begin_data = p_data;\n\n if (! opj_j2k_write_sot(p_j2k, p_data,\n total_data_size,\n &l_current_nb_bytes_written,\n p_stream,\n p_manager)) {\n return OPJ_FALSE;\n }\n\n l_nb_bytes_written += l_current_nb_bytes_written;\n p_data += l_current_nb_bytes_written;\n total_data_size -= l_current_nb_bytes_written;\n l_part_tile_size += l_current_nb_bytes_written;\n\n l_current_nb_bytes_written = 0;\n if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,\n total_data_size, p_stream, p_manager)) {\n return OPJ_FALSE;\n }\n\n p_data += l_current_nb_bytes_written;\n l_nb_bytes_written += l_current_nb_bytes_written;\n total_data_size -= l_current_nb_bytes_written;\n l_part_tile_size += l_current_nb_bytes_written;\n\n \/* Writing Psot in SOT marker *\/\n opj_write_bytes(l_begin_data + 6, l_part_tile_size,\n 4); \/* PSOT *\/\n\n if (OPJ_IS_CINEMA(l_cp->rsiz) || OPJ_IS_IMF(l_cp->rsiz)) {\n opj_j2k_update_tlm(p_j2k, l_part_tile_size);\n }\n\n ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;\n }\n\n for (pino = 1; pino <= l_tcp->numpocs; ++pino) {\n l_tcd->cur_pino = pino;\n\n \/*Get number of tile parts*\/\n tot_num_tp = opj_j2k_get_num_tp(l_cp, pino, p_j2k->m_current_tile_number);\n for (tilepartno = 0; tilepartno < tot_num_tp ; ++tilepartno) {\n p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;\n l_current_nb_bytes_written = 0;\n l_part_tile_size = 0;\n l_begin_data = p_data;\n\n if (! opj_j2k_write_sot(p_j2k, p_data,\n total_data_size,\n &l_current_nb_bytes_written, p_stream,\n p_manager)) {\n return OPJ_FALSE;\n }\n\n l_nb_bytes_written += l_current_nb_bytes_written;\n p_data += l_current_nb_bytes_written;\n total_data_size -= l_current_nb_bytes_written;\n l_part_tile_size += l_current_nb_bytes_written;\n\n l_current_nb_bytes_written = 0;\n\n if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,\n total_data_size, p_stream, p_manager)) {\n return OPJ_FALSE;\n }\n\n l_nb_bytes_written += l_current_nb_bytes_written;\n p_data += l_current_nb_bytes_written;\n total_data_size -= l_current_nb_bytes_written;\n l_part_tile_size += l_current_nb_bytes_written;\n\n \/* Writing Psot in SOT marker *\/\n opj_write_bytes(l_begin_data + 6, l_part_tile_size,\n 4); \/* PSOT *\/\n\n if (OPJ_IS_CINEMA(l_cp->rsiz) || OPJ_IS_IMF(l_cp->rsiz)) {\n opj_j2k_update_tlm(p_j2k, l_part_tile_size);\n }\n\n ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;\n }\n }\n\n *p_data_written = l_nb_bytes_written;\n\n return OPJ_TRUE;\n}","target":0,"code_token_length":1154,"total_token_length":1390,"max_tokens_setting":2048} +{"idx":43352,"func":"static pj_status_t parse_rr(pj_dns_parsed_rr *rr, pj_pool_t *pool,\n\t\t\t const pj_uint8_t *pkt,\n\t\t\t const pj_uint8_t *start, const pj_uint8_t *max,\n\t\t\t int *parsed_len)\n{\n const pj_uint8_t *p = start;\n int name_len, name_part_len;\n pj_status_t status;\n\n \/* Get the length of the name *\/\n status = get_name_len(0, pkt, start, max, &name_part_len, &name_len);\n if (status != PJ_SUCCESS)\n\treturn status;\n\n \/* Allocate memory for the name *\/\n rr->name.ptr = (char*) pj_pool_alloc(pool, name_len+4);\n rr->name.slen = 0;\n\n \/* Get the name *\/\n status = get_name(0, pkt, start, max, &rr->name);\n if (status != PJ_SUCCESS)\n\treturn status;\n\n p = (start + name_part_len);\n\n \/* Check the size can accomodate next few fields. *\/\n if (p+10 > max)\n\treturn PJLIB_UTIL_EDNSINSIZE;\n\n \/* Get the type *\/\n pj_memcpy(&rr->type, p, 2);\n rr->type = pj_ntohs(rr->type);\n p += 2;\n \n \/* Get the class *\/\n pj_memcpy(&rr->dnsclass, p, 2);\n rr->dnsclass = pj_ntohs(rr->dnsclass);\n p += 2;\n\n \/* Class MUST be IN *\/\n if (rr->dnsclass != 1) {\n\t\/* Class is not IN, return error only if type is known (see #1889) *\/\n\tif (rr->type == PJ_DNS_TYPE_A || rr->type == PJ_DNS_TYPE_AAAA ||\n\t rr->type == PJ_DNS_TYPE_CNAME || rr->type == PJ_DNS_TYPE_NS ||\n\t rr->type == PJ_DNS_TYPE_PTR || rr->type == PJ_DNS_TYPE_SRV)\n\t{\n\t return PJLIB_UTIL_EDNSINCLASS;\n\t}\n }\n\n \/* Get TTL *\/\n pj_memcpy(&rr->ttl, p, 4);\n rr->ttl = pj_ntohl(rr->ttl);\n p += 4;\n\n \/* Get rdlength *\/\n pj_memcpy(&rr->rdlength, p, 2);\n rr->rdlength = pj_ntohs(rr->rdlength);\n p += 2;\n\n \/* Check that length is valid *\/\n if (p + rr->rdlength > max)\n\treturn PJLIB_UTIL_EDNSINSIZE;\n\n \/* Parse some well known records *\/\n if (rr->type == PJ_DNS_TYPE_A) {\n\tpj_memcpy(&rr->rdata.a.ip_addr, p, 4);\n\tp += 4;\n\n } else if (rr->type == PJ_DNS_TYPE_AAAA) {\n\tpj_memcpy(&rr->rdata.aaaa.ip_addr, p, 16);\n\tp += 16;\n\n } else if (rr->type == PJ_DNS_TYPE_CNAME ||\n\t rr->type == PJ_DNS_TYPE_NS ||\n\t rr->type == PJ_DNS_TYPE_PTR) \n {\n\n\t\/* Get the length of the target name *\/\n\tstatus = get_name_len(0, pkt, p, max, &name_part_len, &name_len);\n\tif (status != PJ_SUCCESS)\n\t return status;\n\n\t\/* Allocate memory for the name *\/\n\trr->rdata.cname.name.ptr = (char*) pj_pool_alloc(pool, name_len);\n\trr->rdata.cname.name.slen = 0;\n\n\t\/* Get the name *\/\n\tstatus = get_name(0, pkt, p, max, &rr->rdata.cname.name);\n\tif (status != PJ_SUCCESS)\n\t return status;\n\n\tp += name_part_len;\n\n } else if (rr->type == PJ_DNS_TYPE_SRV) {\n\n\t\/* Priority *\/\n\tpj_memcpy(&rr->rdata.srv.prio, p, 2);\n\trr->rdata.srv.prio = pj_ntohs(rr->rdata.srv.prio);\n\tp += 2;\n\n\t\/* Weight *\/\n\tpj_memcpy(&rr->rdata.srv.weight, p, 2);\n\trr->rdata.srv.weight = pj_ntohs(rr->rdata.srv.weight);\n\tp += 2;\n\n\t\/* Port *\/\n\tpj_memcpy(&rr->rdata.srv.port, p, 2);\n\trr->rdata.srv.port = pj_ntohs(rr->rdata.srv.port);\n\tp += 2;\n\t\n\t\/* Get the length of the target name *\/\n\tstatus = get_name_len(0, pkt, p, max, &name_part_len, &name_len);\n\tif (status != PJ_SUCCESS)\n\t return status;\n\n\t\/* Allocate memory for the name *\/\n\trr->rdata.srv.target.ptr = (char*) pj_pool_alloc(pool, name_len);\n\trr->rdata.srv.target.slen = 0;\n\n\t\/* Get the name *\/\n\tstatus = get_name(0, pkt, p, max, &rr->rdata.srv.target);\n\tif (status != PJ_SUCCESS)\n\t return status;\n\tp += name_part_len;\n\n } else {\n\t\/* Copy the raw data *\/\n\trr->data = pj_pool_alloc(pool, rr->rdlength);\n\tpj_memcpy(rr->data, p, rr->rdlength);\n\n\tp += rr->rdlength;\n }\n\n *parsed_len = (int)(p - start);\n return PJ_SUCCESS;\n}","target":0,"code_token_length":1171,"total_token_length":1407,"max_tokens_setting":2048} +{"idx":23667,"func":"err_status_t srtp_unprotect_rtcp ( srtp_t ctx , void * srtcp_hdr , int * pkt_octet_len ) {\n srtcp_hdr_t * hdr = ( srtcp_hdr_t * ) srtcp_hdr ;\n uint32_t * enc_start ;\n uint32_t * auth_start ;\n uint32_t * trailer ;\n unsigned int enc_octet_len = 0 ;\n uint8_t * auth_tag = NULL ;\n uint8_t tmp_tag [ SRTP_MAX_TAG_LEN ] ;\n uint8_t tag_copy [ SRTP_MAX_TAG_LEN ] ;\n err_status_t status ;\n unsigned int auth_len ;\n int tag_len ;\n srtp_stream_ctx_t * stream ;\n int prefix_len ;\n uint32_t seq_num ;\n int e_bit_in_packet ;\n int sec_serv_confidentiality ;\n if ( * pkt_octet_len < octets_in_rtcp_header + sizeof ( srtcp_trailer_t ) ) return err_status_bad_param ;\n stream = srtp_get_stream ( ctx , hdr -> ssrc ) ;\n if ( stream == NULL ) {\n if ( ctx -> stream_template != NULL ) {\n stream = ctx -> stream_template ;\n if ( stream -> ekt != NULL ) {\n status = srtp_stream_init_from_ekt ( stream , srtcp_hdr , * pkt_octet_len ) ;\n if ( status ) return status ;\n }\n debug_print ( mod_srtp , \"srtcp using provisional stream (SSRC: 0x%08x)\" , hdr -> ssrc ) ;\n }\n else {\n return err_status_no_ctx ;\n }\n }\n tag_len = auth_get_tag_length ( stream -> rtcp_auth ) ;\n if ( * pkt_octet_len < ( int ) ( octets_in_rtcp_header + tag_len + sizeof ( srtcp_trailer_t ) ) ) {\n return err_status_bad_param ;\n }\n if ( stream -> rtp_cipher -> algorithm == AES_128_GCM || stream -> rtp_cipher -> algorithm == AES_256_GCM ) {\n return srtp_unprotect_rtcp_aead ( ctx , stream , srtcp_hdr , ( unsigned int * ) pkt_octet_len ) ;\n }\n sec_serv_confidentiality = stream -> rtcp_services == sec_serv_conf || stream -> rtcp_services == sec_serv_conf_and_auth ;\n enc_octet_len = * pkt_octet_len - ( octets_in_rtcp_header + tag_len + sizeof ( srtcp_trailer_t ) ) ;\n trailer = ( uint32_t * ) ( ( char * ) hdr + * pkt_octet_len - ( tag_len + sizeof ( srtcp_trailer_t ) ) ) ;\n e_bit_in_packet = ( * ( ( unsigned char * ) trailer ) & SRTCP_E_BYTE_BIT ) == SRTCP_E_BYTE_BIT ;\n if ( e_bit_in_packet != sec_serv_confidentiality ) {\n return err_status_cant_check ;\n }\n if ( sec_serv_confidentiality ) {\n enc_start = ( uint32_t * ) hdr + uint32s_in_rtcp_header ;\n }\n else {\n enc_octet_len = 0 ;\n enc_start = NULL ;\n }\n auth_start = ( uint32_t * ) hdr ;\n auth_len = * pkt_octet_len - tag_len ;\n auth_tag = ( uint8_t * ) hdr + auth_len ;\n if ( stream -> ekt ) {\n auth_tag -= ekt_octets_after_base_tag ( stream -> ekt ) ;\n memcpy ( tag_copy , auth_tag , tag_len ) ;\n octet_string_set_to_zero ( auth_tag , tag_len ) ;\n auth_tag = tag_copy ;\n auth_len += tag_len ;\n }\n seq_num = ntohl ( * trailer ) & SRTCP_INDEX_MASK ;\n debug_print ( mod_srtp , \"srtcp index: %x\" , seq_num ) ;\n status = rdb_check ( & stream -> rtcp_rdb , seq_num ) ;\n if ( status ) return status ;\n if ( stream -> rtcp_cipher -> type -> id == AES_ICM ) {\n v128_t iv ;\n iv . v32 [ 0 ] = 0 ;\n iv . v32 [ 1 ] = hdr -> ssrc ;\n iv . v32 [ 2 ] = htonl ( seq_num >> 16 ) ;\n iv . v32 [ 3 ] = htonl ( seq_num << 16 ) ;\n status = cipher_set_iv ( stream -> rtcp_cipher , & iv , direction_decrypt ) ;\n }\n else {\n v128_t iv ;\n iv . v32 [ 0 ] = 0 ;\n iv . v32 [ 1 ] = 0 ;\n iv . v32 [ 2 ] = 0 ;\n iv . v32 [ 3 ] = htonl ( seq_num ) ;\n status = cipher_set_iv ( stream -> rtcp_cipher , & iv , direction_decrypt ) ;\n }\n if ( status ) return err_status_cipher_fail ;\n auth_start ( stream -> rtcp_auth ) ;\n status = auth_compute ( stream -> rtcp_auth , ( uint8_t * ) auth_start , auth_len , tmp_tag ) ;\n debug_print ( mod_srtp , \"srtcp computed tag: %s\" , octet_string_hex_string ( tmp_tag , tag_len ) ) ;\n if ( status ) return err_status_auth_fail ;\n debug_print ( mod_srtp , \"srtcp tag from packet: %s\" , octet_string_hex_string ( auth_tag , tag_len ) ) ;\n if ( octet_string_is_eq ( tmp_tag , auth_tag , tag_len ) ) return err_status_auth_fail ;\n prefix_len = auth_get_prefix_length ( stream -> rtcp_auth ) ;\n if ( prefix_len ) {\n status = cipher_output ( stream -> rtcp_cipher , auth_tag , prefix_len ) ;\n debug_print ( mod_srtp , \"keystream prefix: %s\" , octet_string_hex_string ( auth_tag , prefix_len ) ) ;\n if ( status ) return err_status_cipher_fail ;\n }\n if ( enc_start ) {\n status = cipher_decrypt ( stream -> rtcp_cipher , ( uint8_t * ) enc_start , & enc_octet_len ) ;\n if ( status ) return err_status_cipher_fail ;\n }\n * pkt_octet_len -= ( tag_len + sizeof ( srtcp_trailer_t ) ) ;\n * pkt_octet_len -= ekt_octets_after_base_tag ( stream -> ekt ) ;\n if ( stream -> direction != dir_srtp_receiver ) {\n if ( stream -> direction == dir_unknown ) {\n stream -> direction = dir_srtp_receiver ;\n }\n else {\n srtp_handle_event ( ctx , stream , event_ssrc_collision ) ;\n }\n }\n if ( stream == ctx -> stream_template ) {\n srtp_stream_ctx_t * new_stream ;\n status = srtp_stream_clone ( ctx -> stream_template , hdr -> ssrc , & new_stream ) ;\n if ( status ) return status ;\n new_stream -> next = ctx -> stream_list ;\n ctx -> stream_list = new_stream ;\n stream = new_stream ;\n }\n rdb_add_index ( & stream -> rtcp_rdb , seq_num ) ;\n return err_status_ok ;\n }","target":0,"code_token_length":1460,"total_token_length":1696,"max_tokens_setting":2048} +{"idx":129982,"func":"static ssize_t _hostsock_recvmsg(\n oe_fd_t* sock_,\n struct oe_msghdr* msg,\n int flags)\n{\n ssize_t ret = -1;\n sock_t* sock = _cast_sock(sock_);\n oe_errno = 0;\n void* buf = NULL;\n size_t buf_size = 0;\n size_t data_size = 0;\n oe_socklen_t namelen_out = 0;\n size_t controllen_out = 0;\n\n \/* Check the parameters. *\/\n if (!sock || !msg || (msg->msg_iovlen && !msg->msg_iov))\n OE_RAISE_ERRNO(OE_EINVAL);\n\n \/* Flatten the IO vector into contiguous heap memory. *\/\n if (oe_iov_pack(\n msg->msg_iov, (int)msg->msg_iovlen, &buf, &buf_size, &data_size) !=\n 0)\n OE_RAISE_ERRNO(OE_ENOMEM);\n\n \/*\n * According to the POSIX specification, when the data_size is greater\n * than SSIZE_MAX, the result is implementation-defined. OE raises an\n * error in this case.\n * Refer to\n * https:\/\/pubs.opengroup.org\/onlinepubs\/9699919799\/functions\/recvmsg.html\n * for more detail.\n *\/\n if (data_size > OE_SSIZE_MAX)\n OE_RAISE_ERRNO(OE_EINVAL);\n\n \/* Call the host. *\/\n {\n if (oe_syscall_recvmsg_ocall(\n &ret,\n sock->host_fd,\n msg->msg_name,\n msg->msg_namelen,\n &namelen_out,\n buf,\n msg->msg_iovlen,\n buf_size,\n msg->msg_control,\n msg->msg_controllen,\n &controllen_out,\n flags) != OE_OK)\n {\n OE_RAISE_ERRNO(OE_EINVAL);\n }\n\n if (ret == -1)\n OE_RAISE_ERRNO(oe_errno);\n }\n\n if (!msg->msg_name)\n msg->msg_namelen = 0;\n else\n {\n \/*\n * Error out the case if the namelen_out is greater than the size\n * of sockaddr_storage.\n *\/\n if (namelen_out > sizeof(struct oe_sockaddr_storage))\n OE_RAISE_ERRNO(OE_EINVAL);\n\n \/*\n * Note that the returned value can still exceed the supplied one,\n * which indicates a truncation.\n *\/\n if (msg->msg_namelen >= namelen_out)\n msg->msg_namelen = namelen_out;\n }\n\n if (!msg->msg_control)\n msg->msg_controllen = 0;\n else\n {\n \/*\n * Update the msg_controllen only if the supplied value is greater than\n * or equal to the returned value. Otherwise, keep the msg_controllen\n * unchanged, which indicates a truncation. In addition, explicitly\n * setting the MSG_CTRUNC flag when the truncation occurs.\n *\/\n if (msg->msg_controllen >= controllen_out)\n msg->msg_controllen = controllen_out;\n else\n msg->msg_flags |= OE_MSG_CTRUNC;\n }\n\n \/*\n * Guard the special case that a host sets an arbitrarily large value.\n * The return value should not exceed data_size.\n *\/\n if (ret > (ssize_t)data_size)\n {\n ret = -1;\n OE_RAISE_ERRNO(OE_EINVAL);\n }\n\n \/* Synchronize data read with IO vector. *\/\n if (oe_iov_sync(msg->msg_iov, (int)msg->msg_iovlen, buf, buf_size) != 0)\n OE_RAISE_ERRNO(OE_EINVAL);\n\ndone:\n\n if (buf)\n oe_free(buf);\n\n return ret;\n}","target":0,"code_token_length":844,"total_token_length":1080,"max_tokens_setting":2048} +{"idx":88241,"func":"int openssl_push_general_name(lua_State*L, const GENERAL_NAME* general_name)\n{\n if (general_name == NULL)\n {\n lua_pushnil(L);\n return 1;\n }\n lua_newtable(L);\n\n switch (general_name->type)\n {\n case GEN_OTHERNAME:\n {\n OTHERNAME *otherName = general_name->d.otherName;\n lua_newtable(L);\n openssl_push_asn1object(L, otherName->type_id);\n PUSH_ASN1_STRING(L, otherName->value->value.asn1_string);\n lua_settable(L, -3);\n lua_setfield(L, -2, \"otherName\");\n\n lua_pushstring(L, \"otherName\");\n lua_setfield(L, -2, \"type\");\n break;\n }\n case GEN_EMAIL:\n PUSH_ASN1_STRING(L, general_name->d.rfc822Name);\n lua_setfield(L, -2, \"rfc822Name\");\n\n lua_pushstring(L, \"rfc822Name\");\n lua_setfield(L, -2, \"type\");\n break;\n case GEN_DNS:\n PUSH_ASN1_STRING(L, general_name->d.dNSName);\n lua_setfield(L, -2, \"dNSName\");\n lua_pushstring(L, \"dNSName\");\n lua_setfield(L, -2, \"type\");\n break;\n case GEN_X400:\n openssl_push_asn1type(L, general_name->d.x400Address);\n lua_setfield(L, -2, \"x400Address\");\n lua_pushstring(L, \"x400Address\");\n lua_setfield(L, -2, \"type\");\n break;\n case GEN_DIRNAME:\n {\n X509_NAME* xn = general_name->d.directoryName;\n openssl_push_xname_asobject(L, xn);\n lua_setfield(L, -2, \"directoryName\");\n lua_pushstring(L, \"directoryName\");\n lua_setfield(L, -2, \"type\");\n }\n break;\n case GEN_URI:\n PUSH_ASN1_STRING(L, general_name->d.uniformResourceIdentifier);\n lua_setfield(L, -2, \"uniformResourceIdentifier\");\n lua_pushstring(L, \"uniformResourceIdentifier\");\n lua_setfield(L, -2, \"type\");\n break;\n case GEN_IPADD:\n lua_newtable(L);\n PUSH_ASN1_OCTET_STRING(L, general_name->d.iPAddress);\n lua_setfield(L, -2, \"iPAddress\");\n lua_pushstring(L, \"iPAddress\");\n lua_setfield(L, -2, \"type\");\n break;\n case GEN_EDIPARTY:\n lua_newtable(L);\n PUSH_ASN1_STRING(L, general_name->d.ediPartyName->nameAssigner);\n lua_setfield(L, -2, \"nameAssigner\");\n PUSH_ASN1_STRING(L, general_name->d.ediPartyName->partyName);\n lua_setfield(L, -2, \"partyName\");\n lua_setfield(L, -2, \"ediPartyName\");\n\n lua_pushstring(L, \"ediPartyName\");\n lua_setfield(L, -2, \"type\");\n break;\n case GEN_RID:\n lua_newtable(L);\n openssl_push_asn1object(L, general_name->d.registeredID);\n lua_setfield(L, -2, \"registeredID\");\n lua_pushstring(L, \"registeredID\");\n lua_setfield(L, -2, \"type\");\n break;\n default:\n lua_pushstring(L, \"unsupport\");\n lua_setfield(L, -2, \"type\");\n }\n return 1;\n};","target":0,"code_token_length":799,"total_token_length":1035,"max_tokens_setting":2048} +{"idx":483915,"func":"static int really_probe(struct device *dev, struct device_driver *drv)\n{\n\tint ret = -EPROBE_DEFER;\n\tint local_trigger_count = atomic_read(&deferred_trigger_count);\n\tbool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&\n\t\t\t !drv->suppress_bind_attrs;\n\n\tif (defer_all_probes) {\n\t\t\/*\n\t\t * Value of defer_all_probes can be set only by\n\t\t * device_block_probing() which, in turn, will call\n\t\t * wait_for_device_probe() right after that to avoid any races.\n\t\t *\/\n\t\tdev_dbg(dev, \"Driver %s force probe deferral\\n\", drv->name);\n\t\tdriver_deferred_probe_add(dev);\n\t\treturn ret;\n\t}\n\n\tret = device_links_check_suppliers(dev);\n\tif (ret == -EPROBE_DEFER)\n\t\tdriver_deferred_probe_add_trigger(dev, local_trigger_count);\n\tif (ret)\n\t\treturn ret;\n\n\tatomic_inc(&probe_count);\n\tpr_debug(\"bus: '%s': %s: probing driver %s with device %s\\n\",\n\t\t drv->bus->name, __func__, drv->name, dev_name(dev));\n\tif (!list_empty(&dev->devres_head)) {\n\t\tdev_crit(dev, \"Resources present before probing\\n\");\n\t\tret = -EBUSY;\n\t\tgoto done;\n\t}\n\nre_probe:\n\tdev->driver = drv;\n\n\t\/* If using pinctrl, bind pins now before probing *\/\n\tret = pinctrl_bind_pins(dev);\n\tif (ret)\n\t\tgoto pinctrl_bind_failed;\n\n\tif (dev->bus->dma_configure) {\n\t\tret = dev->bus->dma_configure(dev);\n\t\tif (ret)\n\t\t\tgoto probe_failed;\n\t}\n\n\tif (driver_sysfs_add(dev)) {\n\t\tpr_err(\"%s: driver_sysfs_add(%s) failed\\n\",\n\t\t __func__, dev_name(dev));\n\t\tgoto probe_failed;\n\t}\n\n\tif (dev->pm_domain && dev->pm_domain->activate) {\n\t\tret = dev->pm_domain->activate(dev);\n\t\tif (ret)\n\t\t\tgoto probe_failed;\n\t}\n\n\tif (dev->bus->probe) {\n\t\tret = dev->bus->probe(dev);\n\t\tif (ret)\n\t\t\tgoto probe_failed;\n\t} else if (drv->probe) {\n\t\tret = drv->probe(dev);\n\t\tif (ret)\n\t\t\tgoto probe_failed;\n\t}\n\n\tif (device_add_groups(dev, drv->dev_groups)) {\n\t\tdev_err(dev, \"device_add_groups() failed\\n\");\n\t\tgoto dev_groups_failed;\n\t}\n\n\tif (dev_has_sync_state(dev) &&\n\t device_create_file(dev, &dev_attr_state_synced)) {\n\t\tdev_err(dev, \"state_synced sysfs add failed\\n\");\n\t\tgoto dev_sysfs_state_synced_failed;\n\t}\n\n\tif (test_remove) {\n\t\ttest_remove = false;\n\n\t\tdevice_remove_file(dev, &dev_attr_state_synced);\n\t\tdevice_remove_groups(dev, drv->dev_groups);\n\n\t\tif (dev->bus->remove)\n\t\t\tdev->bus->remove(dev);\n\t\telse if (drv->remove)\n\t\t\tdrv->remove(dev);\n\n\t\tdevres_release_all(dev);\n\t\tdriver_sysfs_remove(dev);\n\t\tdev->driver = NULL;\n\t\tdev_set_drvdata(dev, NULL);\n\t\tif (dev->pm_domain && dev->pm_domain->dismiss)\n\t\t\tdev->pm_domain->dismiss(dev);\n\t\tpm_runtime_reinit(dev);\n\n\t\tgoto re_probe;\n\t}\n\n\tpinctrl_init_done(dev);\n\n\tif (dev->pm_domain && dev->pm_domain->sync)\n\t\tdev->pm_domain->sync(dev);\n\n\tdriver_bound(dev);\n\tret = 1;\n\tpr_debug(\"bus: '%s': %s: bound device %s to driver %s\\n\",\n\t\t drv->bus->name, __func__, dev_name(dev), drv->name);\n\tgoto done;\n\ndev_sysfs_state_synced_failed:\n\tdevice_remove_groups(dev, drv->dev_groups);\ndev_groups_failed:\n\tif (dev->bus->remove)\n\t\tdev->bus->remove(dev);\n\telse if (drv->remove)\n\t\tdrv->remove(dev);\nprobe_failed:\n\tif (dev->bus)\n\t\tblocking_notifier_call_chain(&dev->bus->p->bus_notifier,\n\t\t\t\t\t BUS_NOTIFY_DRIVER_NOT_BOUND, dev);\npinctrl_bind_failed:\n\tdevice_links_no_driver(dev);\n\tdevres_release_all(dev);\n\tarch_teardown_dma_ops(dev);\n\tdriver_sysfs_remove(dev);\n\tdev->driver = NULL;\n\tdev_set_drvdata(dev, NULL);\n\tif (dev->pm_domain && dev->pm_domain->dismiss)\n\t\tdev->pm_domain->dismiss(dev);\n\tpm_runtime_reinit(dev);\n\tdev_pm_set_driver_flags(dev, 0);\n\n\tswitch (ret) {\n\tcase -EPROBE_DEFER:\n\t\t\/* Driver requested deferred probing *\/\n\t\tdev_dbg(dev, \"Driver %s requests probe deferral\\n\", drv->name);\n\t\tdriver_deferred_probe_add_trigger(dev, local_trigger_count);\n\t\tbreak;\n\tcase -ENODEV:\n\tcase -ENXIO:\n\t\tpr_debug(\"%s: probe of %s rejects match %d\\n\",\n\t\t\t drv->name, dev_name(dev), ret);\n\t\tbreak;\n\tdefault:\n\t\t\/* driver matched but the probe failed *\/\n\t\tpr_warn(\"%s: probe of %s failed with error %d\\n\",\n\t\t\tdrv->name, dev_name(dev), ret);\n\t}\n\t\/*\n\t * Ignore errors returned by ->probe so that the next driver can try\n\t * its luck.\n\t *\/\n\tret = 0;\ndone:\n\tatomic_dec(&probe_count);\n\twake_up_all(&probe_waitqueue);\n\treturn ret;\n}","target":0,"code_token_length":1152,"total_token_length":1388,"max_tokens_setting":2048} +{"idx":346847,"func":"int main(int argc, char **argv)\n{\n MYSQL mysql;\n option_string *eptr;\n\n MY_INIT(argv[0]);\n\n if (load_defaults(\"my\",load_default_groups,&argc,&argv))\n {\n my_end(0);\n exit(1);\n }\n defaults_argv=argv;\n if (get_options(&argc,&argv))\n {\n free_defaults(defaults_argv);\n my_end(0);\n exit(1);\n }\n\n \/* Seed the random number generator if we will be using it. *\/\n if (auto_generate_sql)\n srandom((uint)time(NULL));\n\n \/* globals? Yes, so we only have to run strlen once *\/\n delimiter_length= strlen(delimiter);\n\n if (argc > 2)\n {\n fprintf(stderr,\"%s: Too many arguments\\n\",my_progname);\n free_defaults(defaults_argv);\n my_end(0);\n exit(1);\n }\n mysql_init(&mysql);\n if (opt_compress)\n mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);\n#ifdef HAVE_OPENSSL\n if (opt_use_ssl)\n mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,\n opt_ssl_capath, opt_ssl_cipher);\n#endif\n if (opt_protocol)\n mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);\n#ifdef HAVE_SMEM\n if (shared_memory_base_name)\n mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);\n#endif\n mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);\n\n if (opt_plugin_dir && *opt_plugin_dir)\n mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);\n\n if (opt_default_auth && *opt_default_auth)\n mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);\n\n if (using_opt_enable_cleartext_plugin)\n mysql_options(&mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN, \n (char*) &opt_enable_cleartext_plugin);\n if (!opt_only_print) \n {\n if (!(mysql_connect_ssl_check(&mysql, host, user, opt_password,\n NULL, opt_mysql_port, opt_mysql_unix_port,\n connect_flags, opt_ssl_required)))\n {\n fprintf(stderr,\"%s: Error when connecting to server: %s\\n\",\n my_progname,mysql_error(&mysql));\n free_defaults(defaults_argv);\n my_end(0);\n exit(1);\n }\n }\n\n pthread_mutex_init(&counter_mutex, NULL);\n pthread_cond_init(&count_threshhold, NULL);\n pthread_mutex_init(&sleeper_mutex, NULL);\n pthread_cond_init(&sleep_threshhold, NULL);\n\n \/* Main iterations loop *\/\n eptr= engine_options;\n do\n {\n \/* For the final stage we run whatever queries we were asked to run *\/\n uint *current;\n\n if (verbose >= 2)\n printf(\"Starting Concurrency Test\\n\");\n\n if (*concurrency)\n {\n for (current= concurrency; current && *current; current++)\n concurrency_loop(&mysql, *current, eptr);\n }\n else\n {\n uint infinite= 1;\n do {\n concurrency_loop(&mysql, infinite, eptr);\n }\n while (infinite++);\n }\n\n if (!opt_preserve)\n drop_schema(&mysql, create_schema_string);\n\n } while (eptr ? (eptr= eptr->next) : 0);\n\n pthread_mutex_destroy(&counter_mutex);\n pthread_cond_destroy(&count_threshhold);\n pthread_mutex_destroy(&sleeper_mutex);\n pthread_cond_destroy(&sleep_threshhold);\n\n if (!opt_only_print) \n mysql_close(&mysql); \/* Close & free connection *\/\n\n \/* now free all the strings we created *\/\n my_free(opt_password);\n my_free(concurrency);\n\n statement_cleanup(create_statements);\n statement_cleanup(query_statements);\n statement_cleanup(pre_statements);\n statement_cleanup(post_statements);\n option_cleanup(engine_options);\n\n#ifdef HAVE_SMEM\n my_free(shared_memory_base_name);\n#endif\n free_defaults(defaults_argv);\n my_end(my_end_arg);\n\n return 0;\n}","target":1,"code_token_length":875,"total_token_length":1111,"max_tokens_setting":2048} +{"idx":519747,"func":"void prepare_frm_header(THD *thd, uint reclength, uchar *fileinfo,\n HA_CREATE_INFO *create_info, uint keys, KEY *key_info)\n{\n ulong key_comment_total_bytes= 0;\n uint i;\n DBUG_ENTER(\"prepare_frm_header\");\n\n \/* Fix this when we have new .frm files; Current limit is 4G rows (TODO) *\/\n if (create_info->max_rows > UINT_MAX32)\n create_info->max_rows= UINT_MAX32;\n if (create_info->min_rows > UINT_MAX32)\n create_info->min_rows= UINT_MAX32;\n\n uint key_length, tmp_key_length, tmp, csid;\n bzero((char*) fileinfo, FRM_HEADER_SIZE);\n \/* header *\/\n fileinfo[0]=(uchar) 254;\n fileinfo[1]= 1;\n fileinfo[2]= (create_info->expression_length == 0 ? FRM_VER_TRUE_VARCHAR :\n FRM_VER_EXPRESSSIONS);\n\n DBUG_ASSERT(ha_storage_engine_is_enabled(create_info->db_type));\n fileinfo[3]= (uchar) ha_legacy_type(create_info->db_type);\n\n \/*\n Keep in sync with pack_keys() in unireg.cc\n For each key:\n 8 bytes for the key header\n 9 bytes for each key-part (MAX_REF_PARTS)\n NAME_LEN bytes for the name\n 1 byte for the NAMES_SEP_CHAR (before the name)\n For all keys:\n 6 bytes for the header\n 1 byte for the NAMES_SEP_CHAR (after the last name)\n 9 extra bytes (padding for safety? alignment?)\n *\/\n for (i= 0; i < keys; i++)\n {\n DBUG_ASSERT(MY_TEST(key_info[i].flags & HA_USES_COMMENT) ==\n (key_info[i].comment.length > 0));\n if (key_info[i].flags & HA_USES_COMMENT)\n key_comment_total_bytes += 2 + key_info[i].comment.length;\n }\n\n key_length= keys * (8 + MAX_REF_PARTS * 9 + NAME_LEN + 1) + 16\n + key_comment_total_bytes;\n\n int2store(fileinfo+8,1);\n tmp_key_length= (key_length < 0xffff) ? key_length : 0xffff;\n int2store(fileinfo+14,tmp_key_length);\n int2store(fileinfo+16,reclength);\n int4store(fileinfo+18,create_info->max_rows);\n int4store(fileinfo+22,create_info->min_rows);\n \/* fileinfo[26] is set in mysql_create_frm() *\/\n fileinfo[27]=2;\t\t\t\t\/\/ Use long pack-fields\n \/* fileinfo[28 & 29] is set to key_info_length in mysql_create_frm() *\/\n create_info->table_options|=HA_OPTION_LONG_BLOB_PTR; \/\/ Use portable blob pointers\n int2store(fileinfo+30,create_info->table_options);\n fileinfo[32]=0;\t\t\t\t\/\/ No filename anymore\n fileinfo[33]=5; \/\/ Mark for 5.0 frm file\n int4store(fileinfo+34,create_info->avg_row_length);\n csid= (create_info->default_table_charset ?\n create_info->default_table_charset->number : 0);\n fileinfo[38]= (uchar) csid;\n fileinfo[39]= (uchar) ((uint) create_info->transactional |\n ((uint) create_info->page_checksum << 2));\n fileinfo[40]= (uchar) create_info->row_type;\n \/* Bytes 41-46 were for RAID support; now reused for other purposes *\/\n fileinfo[41]= (uchar) (csid >> 8);\n int2store(fileinfo+42, create_info->stats_sample_pages & 0xffff);\n fileinfo[44]= (uchar) create_info->stats_auto_recalc;\n int2store(fileinfo+45, (create_info->check_constraint_list->elements+\n create_info->field_check_constraints));\n int4store(fileinfo+47, key_length);\n tmp= MYSQL_VERSION_ID; \/\/ Store to avoid warning from int4store\n int4store(fileinfo+51, tmp);\n int4store(fileinfo+55, create_info->extra_size);\n \/*\n 59-60 is unused since 10.2.4\n 61 for default_part_db_type\n *\/\n int2store(fileinfo+62, create_info->key_block_size);\n DBUG_VOID_RETURN;\n} \/* prepare_fileinfo *\/","target":0,"code_token_length":1025,"total_token_length":1261,"max_tokens_setting":2048} +{"idx":318491,"func":"static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\n\n long width, long height,\n\n long lumStride, long chromStride, long dstStride, long vertLumPerChroma)\n\n{\n\n long y;\n\n const x86_reg chromWidth= width>>1;\n\n for (y=0; yyuy2\n\n\n\n#if HAVE_FAST_64BIT\n\n int i;\n\n uint64_t *ldst = (uint64_t *) dst;\n\n const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;\n\n for (i = 0; i < chromWidth; i += 2) {\n\n uint64_t k, l;\n\n k = uc[0] + (yc[0] << 8) +\n\n (vc[0] << 16) + (yc[1] << 24);\n\n l = uc[1] + (yc[2] << 8) +\n\n (vc[1] << 16) + (yc[3] << 24);\n\n *ldst++ = k + (l << 32);\n\n yc += 4;\n\n uc += 2;\n\n vc += 2;\n\n }\n\n\n\n#else\n\n int i, *idst = (int32_t *) dst;\n\n const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;\n\n for (i = 0; i < chromWidth; i++) {\n\n#if HAVE_BIGENDIAN\n\n *idst++ = (uc[0] << 24)+ (yc[0] << 16) +\n\n (vc[0] << 8) + (yc[1] << 0);\n\n#else\n\n *idst++ = uc[0] + (yc[0] << 8) +\n\n (vc[0] << 16) + (yc[1] << 24);\n\n#endif\n\n yc += 2;\n\n uc++;\n\n vc++;\n\n }\n\n#endif\n\n#endif\n\n if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {\n\n usrc += chromStride;\n\n vsrc += chromStride;\n\n }\n\n ysrc += lumStride;\n\n dst += dstStride;\n\n }\n\n#if COMPILE_TEMPLATE_MMX\n\n __asm__(EMMS\" \\n\\t\"\n\n SFENCE\" \\n\\t\"\n\n :::\"memory\");\n\n#endif\n\n}\n","target":0,"code_token_length":1285,"total_token_length":1521,"max_tokens_setting":2048} +{"idx":8065,"func":"static int jpc_pi_nextpcrl(register jpc_pi_t *pi)\n{\n\tint rlvlno;\n\tjpc_pirlvl_t *pirlvl;\n\tjpc_pchg_t *pchg;\n\tint prchind;\n\tint prcvind;\n\tint *prclyrno;\n\tint compno;\n\tjpc_picomp_t *picomp;\n\tint xstep;\n\tint ystep;\n\tuint_fast32_t trx0;\n\tuint_fast32_t try0;\n\tuint_fast32_t r;\n\tuint_fast32_t rpx;\n\tuint_fast32_t rpy;\n\n\tpchg = pi->pchg;\n\tif (!pi->prgvolfirst) {\n\t\tgoto skip;\n\t} else {\n\t\tpi->xstep = 0;\n\t\tpi->ystep = 0;\n\t\tfor (compno = 0, picomp = pi->picomps; compno < pi->numcomps;\n\t\t ++compno, ++picomp) {\n\t\t\tfor (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno <\n\t\t\t picomp->numrlvls; ++rlvlno, ++pirlvl) {\n\t\t\t\txstep = picomp->hsamp * (1 <<\n\t\t\t\t (pirlvl->prcwidthexpn + picomp->numrlvls -\n\t\t\t\t rlvlno - 1));\n\t\t\t\tystep = picomp->vsamp * (1 <<\n\t\t\t\t (pirlvl->prcheightexpn + picomp->numrlvls -\n\t\t\t\t rlvlno - 1));\n\t\t\t\tpi->xstep = (!pi->xstep) ? xstep :\n\t\t\t\t JAS_MIN(pi->xstep, xstep);\n\t\t\t\tpi->ystep = (!pi->ystep) ? ystep :\n\t\t\t\t JAS_MIN(pi->ystep, ystep);\n\t\t\t}\n\t\t}\n\t\tpi->prgvolfirst = 0;\n\t}\n\n\tfor (pi->y = pi->ystart; pi->y < pi->yend; pi->y += pi->ystep -\n\t (pi->y % pi->ystep)) {\n\t\tfor (pi->x = pi->xstart; pi->x < pi->xend; pi->x += pi->xstep -\n\t\t (pi->x % pi->xstep)) {\n\t\t\tfor (pi->compno = pchg->compnostart, pi->picomp =\n\t\t\t &pi->picomps[pi->compno]; pi->compno < pi->numcomps\n\t\t\t && pi->compno < JAS_CAST(int, pchg->compnoend); ++pi->compno,\n\t\t\t ++pi->picomp) {\n\t\t\t\tfor (pi->rlvlno = pchg->rlvlnostart,\n\t\t\t\t pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno];\n\t\t\t\t pi->rlvlno < pi->picomp->numrlvls &&\n\t\t\t\t pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno,\n\t\t\t\t ++pi->pirlvl) {\n\t\t\t\t\tif (pi->pirlvl->numprcs == 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tr = pi->picomp->numrlvls - 1 - pi->rlvlno;\n\t\t\t\t\ttrx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r);\n\t\t\t\t\ttry0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);\n\t\t\t\t\trpx = r + pi->pirlvl->prcwidthexpn;\n\t\t\t\t\trpy = r + pi->pirlvl->prcheightexpn;\n\t\t\t\t\tif (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) ||\n\t\t\t\t\t !(pi->x % (pi->picomp->hsamp << rpx))) &&\n\t\t\t\t\t ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) ||\n\t\t\t\t\t !(pi->y % (pi->picomp->vsamp << rpy)))) {\n\t\t\t\t\t\tprchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp\n\t\t\t\t\t\t << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0,\n\t\t\t\t\t\t pi->pirlvl->prcwidthexpn);\n\t\t\t\t\t\tprcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp\n\t\t\t\t\t\t << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0,\n\t\t\t\t\t\t pi->pirlvl->prcheightexpn);\n\t\t\t\t\t\tpi->prcno = prcvind * pi->pirlvl->numhprcs + prchind;\n\t\t\t\t\t\tassert(pi->prcno < pi->pirlvl->numprcs);\n\t\t\t\t\t\tfor (pi->lyrno = 0; pi->lyrno < pi->numlyrs &&\n\t\t\t\t\t\t pi->lyrno < JAS_CAST(int, pchg->lyrnoend); ++pi->lyrno) {\n\t\t\t\t\t\t\tprclyrno = &pi->pirlvl->prclyrnos[pi->prcno];\n\t\t\t\t\t\t\tif (pi->lyrno >= *prclyrno) {\n\t\t\t\t\t\t\t\t++(*prclyrno);\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\nskip:\n\t\t\t\t\t\t\t;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}","target":1,"code_token_length":1207,"total_token_length":1443,"max_tokens_setting":2048} +{"idx":350397,"func":"int cancel_extop( Operation *op, SlapReply *rs )\n{\n\tOperation *o;\n\tint rc;\n\tint opid;\n\tBerElementBuffer berbuf;\n\tBerElement *ber = (BerElement *)&berbuf;\n\n\tassert( ber_bvcmp( &slap_EXOP_CANCEL, &op->ore_reqoid ) == 0 );\n\n\tif ( op->ore_reqdata == NULL ) {\n\t\trs->sr_text = \"no message ID supplied\";\n\t\treturn LDAP_PROTOCOL_ERROR;\n\t}\n\n\tif ( op->ore_reqdata->bv_len == 0 ) {\n\t\trs->sr_text = \"empty request data field\";\n\t\treturn LDAP_PROTOCOL_ERROR;\n\t}\n\n\t\/* ber_init2 uses reqdata directly, doesn't allocate new buffers *\/\n\tber_init2( ber, op->ore_reqdata, 0 );\n\n\tif ( ber_scanf( ber, \"{i}\", &opid ) == LBER_ERROR ) {\n\t\trs->sr_text = \"message ID parse failed\";\n\t\treturn LDAP_PROTOCOL_ERROR;\n\t}\n\n\tStatslog( LDAP_DEBUG_STATS, \"%s CANCEL msg=%d\\n\",\n\t\top->o_log_prefix, opid, 0, 0, 0 );\n\n\tif ( opid < 0 ) {\n\t\trs->sr_text = \"message ID invalid\";\n\t\treturn LDAP_PROTOCOL_ERROR;\n\t}\n\n\tldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );\n\n\tif ( op->o_abandon ) {\n\t\t\/* FIXME: Should instead reject the cancel\/abandon of this op, but\n\t\t * it seems unsafe to reset op->o_abandon once it is set. ITS#6138.\n\t\t *\/\n\t\trc = LDAP_OPERATIONS_ERROR;\n\t\trs->sr_text = \"tried to abandon or cancel this operation\";\n\t\tgoto out;\n\t}\n\n\tLDAP_STAILQ_FOREACH( o, &op->o_conn->c_pending_ops, o_next ) {\n\t\tif ( o->o_msgid == opid ) {\n\t\t\t\/* TODO: We could instead remove the cancelled operation\n\t\t\t * from c_pending_ops like Abandon does, and send its\n\t\t\t * response here. Not if it is pending because of a\n\t\t\t * congested connection though.\n\t\t\t *\/\n\t\t\trc = LDAP_CANNOT_CANCEL;\n\t\t\trs->sr_text = \"too busy for Cancel, try Abandon instead\";\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tLDAP_STAILQ_FOREACH( o, &op->o_conn->c_ops, o_next ) {\n\t\tif ( o->o_msgid == opid ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( o == NULL ) {\n\t \trc = LDAP_NO_SUCH_OPERATION;\n\t\trs->sr_text = \"message ID not found\";\n\n\t} else if ( o->o_tag == LDAP_REQ_BIND\n\t\t\t|| o->o_tag == LDAP_REQ_UNBIND\n\t\t\t|| o->o_tag == LDAP_REQ_ABANDON ) {\n\t\trc = LDAP_CANNOT_CANCEL;\n\n\t} else if ( o->o_cancel != SLAP_CANCEL_NONE ) {\n\t\trc = LDAP_OPERATIONS_ERROR;\n\t\trs->sr_text = \"message ID already being cancelled\";\n\n#if 0\n\t} else if ( o->o_abandon ) {\n\t\t\/* TODO: Would this break something when\n\t\t * o_abandon=\"suppress response\"? (ITS#6138)\n\t\t *\/\n\t\trc = LDAP_TOO_LATE;\n#endif\n\n\t} else {\n\t\trc = LDAP_SUCCESS;\n\t\to->o_cancel = SLAP_CANCEL_REQ;\n\t\to->o_abandon = 1;\n\t}\n\n out:\n\tldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );\n\n\tif ( rc == LDAP_SUCCESS ) {\n\t\tLDAP_STAILQ_FOREACH( op->o_bd, &backendDB, be_next ) {\n\t\t\tif( !op->o_bd->be_cancel ) continue;\n\n\t\t\top->oq_cancel.rs_msgid = opid;\n\t\t\tif ( op->o_bd->be_cancel( op, rs ) == LDAP_SUCCESS ) {\n\t\t\t\treturn LDAP_SUCCESS;\n\t\t\t}\n\t\t}\n\n\t\tdo {\n\t\t\t\/* Fake a cond_wait with thread_yield, then\n\t\t\t * verify the result properly mutex-protected.\n\t\t\t *\/\n\t\t\twhile ( o->o_cancel == SLAP_CANCEL_REQ )\n\t\t\t\tldap_pvt_thread_yield();\n\t\t\tldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );\n\t\t\trc = o->o_cancel;\n\t\t\tldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );\n\t\t} while ( rc == SLAP_CANCEL_REQ );\n\n\t\tif ( rc == SLAP_CANCEL_ACK ) {\n\t\t\trc = LDAP_SUCCESS;\n\t\t}\n\n\t\to->o_cancel = SLAP_CANCEL_DONE;\n\t}\n\n\treturn rc;\n}","target":1,"code_token_length":992,"total_token_length":1228,"max_tokens_setting":2048} +{"idx":438904,"func":"static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,\n\t\t\t\t struct cfg80211_csa_settings *params,\n\t\t\t\t u32 *changed)\n{\n\tstruct ieee80211_csa_settings csa = {};\n\tint err;\n\n\tswitch (sdata->vif.type) {\n\tcase NL80211_IFTYPE_AP:\n\t\tsdata->u.ap.next_beacon =\n\t\t\tcfg80211_beacon_dup(¶ms->beacon_after);\n\t\tif (!sdata->u.ap.next_beacon)\n\t\t\treturn -ENOMEM;\n\n\t\t\/*\n\t\t * With a count of 0, we don't have to wait for any\n\t\t * TBTT before switching, so complete the CSA\n\t\t * immediately. In theory, with a count == 1 we\n\t\t * should delay the switch until just before the next\n\t\t * TBTT, but that would complicate things so we switch\n\t\t * immediately too. If we would delay the switch\n\t\t * until the next TBTT, we would have to set the probe\n\t\t * response here.\n\t\t *\n\t\t * TODO: A channel switch with count <= 1 without\n\t\t * sending a CSA action frame is kind of useless,\n\t\t * because the clients won't know we're changing\n\t\t * channels. The action frame must be implemented\n\t\t * either here or in the userspace.\n\t\t *\/\n\t\tif (params->count <= 1)\n\t\t\tbreak;\n\n\t\tif ((params->n_counter_offsets_beacon >\n\t\t IEEE80211_MAX_CSA_COUNTERS_NUM) ||\n\t\t (params->n_counter_offsets_presp >\n\t\t IEEE80211_MAX_CSA_COUNTERS_NUM))\n\t\t\treturn -EINVAL;\n\n\t\tcsa.counter_offsets_beacon = params->counter_offsets_beacon;\n\t\tcsa.counter_offsets_presp = params->counter_offsets_presp;\n\t\tcsa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;\n\t\tcsa.n_counter_offsets_presp = params->n_counter_offsets_presp;\n\t\tcsa.count = params->count;\n\n\t\terr = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa);\n\t\tif (err < 0) {\n\t\t\tkfree(sdata->u.ap.next_beacon);\n\t\t\treturn err;\n\t\t}\n\t\t*changed |= err;\n\n\t\tbreak;\n\tcase NL80211_IFTYPE_ADHOC:\n\t\tif (!sdata->vif.bss_conf.ibss_joined)\n\t\t\treturn -EINVAL;\n\n\t\tif (params->chandef.width != sdata->u.ibss.chandef.width)\n\t\t\treturn -EINVAL;\n\n\t\tswitch (params->chandef.width) {\n\t\tcase NL80211_CHAN_WIDTH_40:\n\t\t\tif (cfg80211_get_chandef_type(¶ms->chandef) !=\n\t\t\t cfg80211_get_chandef_type(&sdata->u.ibss.chandef))\n\t\t\t\treturn -EINVAL;\n\t\tcase NL80211_CHAN_WIDTH_5:\n\t\tcase NL80211_CHAN_WIDTH_10:\n\t\tcase NL80211_CHAN_WIDTH_20_NOHT:\n\t\tcase NL80211_CHAN_WIDTH_20:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\t\/* changes into another band are not supported *\/\n\t\tif (sdata->u.ibss.chandef.chan->band !=\n\t\t params->chandef.chan->band)\n\t\t\treturn -EINVAL;\n\n\t\t\/* see comments in the NL80211_IFTYPE_AP block *\/\n\t\tif (params->count > 1) {\n\t\t\terr = ieee80211_ibss_csa_beacon(sdata, params);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t\t*changed |= err;\n\t\t}\n\n\t\tieee80211_send_action_csa(sdata, params);\n\n\t\tbreak;\n#ifdef CONFIG_MAC80211_MESH\n\tcase NL80211_IFTYPE_MESH_POINT: {\n\t\tstruct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;\n\n\t\tif (params->chandef.width != sdata->vif.bss_conf.chandef.width)\n\t\t\treturn -EINVAL;\n\n\t\t\/* changes into another band are not supported *\/\n\t\tif (sdata->vif.bss_conf.chandef.chan->band !=\n\t\t params->chandef.chan->band)\n\t\t\treturn -EINVAL;\n\n\t\tif (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {\n\t\t\tifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;\n\t\t\tif (!ifmsh->pre_value)\n\t\t\t\tifmsh->pre_value = 1;\n\t\t\telse\n\t\t\t\tifmsh->pre_value++;\n\t\t}\n\n\t\t\/* see comments in the NL80211_IFTYPE_AP block *\/\n\t\tif (params->count > 1) {\n\t\t\terr = ieee80211_mesh_csa_beacon(sdata, params);\n\t\t\tif (err < 0) {\n\t\t\t\tifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;\n\t\t\t\treturn err;\n\t\t\t}\n\t\t\t*changed |= err;\n\t\t}\n\n\t\tif (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)\n\t\t\tieee80211_send_action_csa(sdata, params);\n\n\t\tbreak;\n\t\t}\n#endif\n\tdefault:\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":1224,"total_token_length":1460,"max_tokens_setting":2048} +{"idx":353738,"func":"static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)\n{\n EVP_AES_GCM_CTX *gctx = c->cipher_data;\n switch (type) {\n case EVP_CTRL_INIT:\n gctx->key_set = 0;\n gctx->iv_set = 0;\n gctx->ivlen = c->cipher->iv_len;\n gctx->iv = c->iv;\n gctx->taglen = -1;\n gctx->iv_gen = 0;\n gctx->tls_aad_len = -1;\n return 1;\n\n case EVP_CTRL_GCM_SET_IVLEN:\n if (arg <= 0)\n return 0;\n \/* Allocate memory for IV if needed *\/\n if ((arg > EVP_MAX_IV_LENGTH) && (arg > gctx->ivlen)) {\n if (gctx->iv != c->iv)\n OPENSSL_free(gctx->iv);\n gctx->iv = OPENSSL_malloc(arg);\n if (!gctx->iv)\n return 0;\n }\n gctx->ivlen = arg;\n return 1;\n\n case EVP_CTRL_GCM_SET_TAG:\n if (arg <= 0 || arg > 16 || c->encrypt)\n return 0;\n memcpy(c->buf, ptr, arg);\n gctx->taglen = arg;\n return 1;\n\n case EVP_CTRL_GCM_GET_TAG:\n if (arg <= 0 || arg > 16 || !c->encrypt || gctx->taglen < 0)\n return 0;\n memcpy(ptr, c->buf, arg);\n return 1;\n\n case EVP_CTRL_GCM_SET_IV_FIXED:\n \/* Special case: -1 length restores whole IV *\/\n if (arg == -1) {\n memcpy(gctx->iv, ptr, gctx->ivlen);\n gctx->iv_gen = 1;\n return 1;\n }\n \/*\n * Fixed field must be at least 4 bytes and invocation field at least\n * 8.\n *\/\n if ((arg < 4) || (gctx->ivlen - arg) < 8)\n return 0;\n if (arg)\n memcpy(gctx->iv, ptr, arg);\n if (c->encrypt && RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0)\n return 0;\n gctx->iv_gen = 1;\n return 1;\n\n case EVP_CTRL_GCM_IV_GEN:\n if (gctx->iv_gen == 0 || gctx->key_set == 0)\n return 0;\n CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen);\n if (arg <= 0 || arg > gctx->ivlen)\n arg = gctx->ivlen;\n memcpy(ptr, gctx->iv + gctx->ivlen - arg, arg);\n \/*\n * Invocation field will be at least 8 bytes in size and so no need\n * to check wrap around or increment more than last 8 bytes.\n *\/\n ctr64_inc(gctx->iv + gctx->ivlen - 8);\n gctx->iv_set = 1;\n return 1;\n\n case EVP_CTRL_GCM_SET_IV_INV:\n if (gctx->iv_gen == 0 || gctx->key_set == 0 || c->encrypt)\n return 0;\n memcpy(gctx->iv + gctx->ivlen - arg, ptr, arg);\n CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen);\n gctx->iv_set = 1;\n return 1;\n\n case EVP_CTRL_AEAD_TLS1_AAD:\n \/* Save the AAD for later use *\/\n if (arg != 13)\n return 0;\n memcpy(c->buf, ptr, arg);\n gctx->tls_aad_len = arg;\n {\n unsigned int len = c->buf[arg - 2] << 8 | c->buf[arg - 1];\n \/* Correct length for explicit IV *\/\n len -= EVP_GCM_TLS_EXPLICIT_IV_LEN;\n \/* If decrypting correct for tag too *\/\n if (!c->encrypt)\n len -= EVP_GCM_TLS_TAG_LEN;\n c->buf[arg - 2] = len >> 8;\n c->buf[arg - 1] = len & 0xff;\n }\n \/* Extra padding: tag appended to record *\/\n return EVP_GCM_TLS_TAG_LEN;\n\n case EVP_CTRL_COPY:\n {\n EVP_CIPHER_CTX *out = ptr;\n EVP_AES_GCM_CTX *gctx_out = out->cipher_data;\n if (gctx->gcm.key) {\n if (gctx->gcm.key != &gctx->ks)\n return 0;\n gctx_out->gcm.key = &gctx_out->ks;\n }\n if (gctx->iv == c->iv)\n gctx_out->iv = out->iv;\n else {\n gctx_out->iv = OPENSSL_malloc(gctx->ivlen);\n if (!gctx_out->iv)\n return 0;\n memcpy(gctx_out->iv, gctx->iv, gctx->ivlen);\n }\n return 1;\n }\n\n default:\n return -1;\n\n }\n}","target":1,"code_token_length":1180,"total_token_length":1416,"max_tokens_setting":2048} +{"idx":468655,"func":"ClientRequestContext::clientAccessCheckDone(const Acl::Answer &answer)\n{\n acl_checklist = NULL;\n err_type page_id;\n Http::StatusCode status;\n debugs(85, 2, \"The request \" << http->request->method << ' ' <<\n http->uri << \" is \" << answer <<\n \"; last ACL checked: \" << (AclMatchedName ? AclMatchedName : \"[none]\"));\n\n#if USE_AUTH\n char const *proxy_auth_msg = \"\";\n if (http->getConn() != NULL && http->getConn()->getAuth() != NULL)\n proxy_auth_msg = http->getConn()->getAuth()->denyMessage(\"\");\n else if (http->request->auth_user_request != NULL)\n proxy_auth_msg = http->request->auth_user_request->denyMessage(\"\");\n#endif\n\n if (!answer.allowed()) {\n \/\/ auth has a grace period where credentials can be expired but okay not to challenge.\n\n \/* Send an auth challenge or error *\/\n \/\/ XXX: do we still need aclIsProxyAuth() ?\n bool auth_challenge = (answer == ACCESS_AUTH_REQUIRED || aclIsProxyAuth(AclMatchedName));\n debugs(85, 5, \"Access Denied: \" << http->uri);\n debugs(85, 5, \"AclMatchedName = \" << (AclMatchedName ? AclMatchedName : \"\"));\n#if USE_AUTH\n if (auth_challenge)\n debugs(33, 5, \"Proxy Auth Message = \" << (proxy_auth_msg ? proxy_auth_msg : \"\"));\n#endif\n\n \/*\n * NOTE: get page_id here, based on AclMatchedName because if\n * USE_DELAY_POOLS is enabled, then AclMatchedName gets clobbered in\n * the clientCreateStoreEntry() call just below. Pedro Ribeiro\n * \n *\/\n page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName, answer != ACCESS_AUTH_REQUIRED);\n\n http->logType.update(LOG_TCP_DENIED);\n\n if (auth_challenge) {\n#if USE_AUTH\n if (http->request->flags.sslBumped) {\n \/*SSL Bumped request, authentication is not possible*\/\n status = Http::scForbidden;\n } else if (!http->flags.accel) {\n \/* Proxy authorisation needed *\/\n status = Http::scProxyAuthenticationRequired;\n } else {\n \/* WWW authorisation needed *\/\n status = Http::scUnauthorized;\n }\n#else\n \/\/ need auth, but not possible to do.\n status = Http::scForbidden;\n#endif\n if (page_id == ERR_NONE)\n page_id = ERR_CACHE_ACCESS_DENIED;\n } else {\n status = Http::scForbidden;\n\n if (page_id == ERR_NONE)\n page_id = ERR_ACCESS_DENIED;\n }\n\n Ip::Address tmpnoaddr;\n tmpnoaddr.setNoAddr();\n error = clientBuildError(page_id, status,\n NULL,\n http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmpnoaddr,\n http->request, http->al\n );\n\n#if USE_AUTH\n error->auth_user_request =\n http->getConn() != NULL && http->getConn()->getAuth() != NULL ?\n http->getConn()->getAuth() : http->request->auth_user_request;\n#endif\n\n readNextRequest = true;\n }\n\n \/* ACCESS_ALLOWED continues here ... *\/\n xfree(http->uri);\n http->uri = SBufToCstring(http->request->effectiveRequestUri());\n http->doCallouts();\n}","target":0,"code_token_length":794,"total_token_length":1030,"max_tokens_setting":2048} +{"idx":201642,"func":"status_t BnHDCP::onTransact(\n uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {\n switch (code) {\n case HDCP_SET_OBSERVER:\n {\n CHECK_INTERFACE(IHDCP, data, reply);\n\n sp observer =\n interface_cast(data.readStrongBinder());\n\n reply->writeInt32(setObserver(observer));\n return OK;\n }\n\n case HDCP_INIT_ASYNC:\n {\n CHECK_INTERFACE(IHDCP, data, reply);\n\n const char *host = data.readCString();\n unsigned port = data.readInt32();\n\n reply->writeInt32(initAsync(host, port));\n return OK;\n }\n\n case HDCP_SHUTDOWN_ASYNC:\n {\n CHECK_INTERFACE(IHDCP, data, reply);\n\n reply->writeInt32(shutdownAsync());\n return OK;\n }\n\n case HDCP_GET_CAPS:\n {\n CHECK_INTERFACE(IHDCP, data, reply);\n\n reply->writeInt32(getCaps());\n return OK;\n }\n\n\n case HDCP_ENCRYPT:\n {\n size_t size = data.readInt32();\n \/\/ watch out for overflow\n if (size <= SIZE_MAX \/ 2) {\n inData = malloc(2 * size);\n }\n if (inData == NULL) {\n reply->writeInt32(ERROR_OUT_OF_RANGE);\n return OK;\n }\n\n \n void *outData = (uint8_t *)inData + size;\n \n status_t err = data.read(inData, size);\n if (err != OK) {\n free(inData);\n reply->writeInt32(err);\n return OK;\n }\n \n uint32_t streamCTR = data.readInt32();\n uint64_t inputCTR;\n err = encrypt(inData, size, streamCTR, &inputCTR, outData);\n \n reply->writeInt32(err);\n \n if (err == OK) {\n reply->writeInt64(inputCTR);\n reply->write(outData, size);\n }\n\n free(inData);\n inData = outData = NULL;\n\n return OK;\n }\n\n case HDCP_ENCRYPT_NATIVE:\n {\n CHECK_INTERFACE(IHDCP, data, reply);\n\n sp graphicBuffer = new GraphicBuffer();\n data.read(*graphicBuffer);\n size_t offset = data.readInt32();\n size_t size = data.readInt32();\n uint32_t streamCTR = data.readInt32();\n void *outData = malloc(size);\n uint64_t inputCTR;\n\n status_t err = encryptNative(graphicBuffer, offset, size,\n streamCTR, &inputCTR, outData);\n\n reply->writeInt32(err);\n\n if (err == OK) {\n reply->writeInt64(inputCTR);\n reply->write(outData, size);\n }\n\n free(outData);\n outData = NULL;\n\n return OK;\n }\n\n case HDCP_DECRYPT:\n {\n size_t size = data.readInt32();\n size_t bufSize = 2 * size;\n\n void *inData = NULL;\n if (bufSize > size) {\n inData = malloc(bufSize);\n }\n\n if (inData == NULL) {\n reply->writeInt32(ERROR_OUT_OF_RANGE);\n return OK;\n }\n\n void *outData = (uint8_t *)inData + size;\n\n data.read(inData, size);\n\n uint32_t streamCTR = data.readInt32();\n uint64_t inputCTR = data.readInt64();\n status_t err = decrypt(inData, size, streamCTR, inputCTR, outData);\n\n reply->writeInt32(err);\n\n if (err == OK) {\n reply->write(outData, size);\n }\n\n free(inData);\n inData = outData = NULL;\n\n return OK;\n }\n\n default:\n return BBinder::onTransact(code, data, reply, flags);\n }\n}\n","target":0,"code_token_length":817,"total_token_length":1053,"max_tokens_setting":2048} +{"idx":505484,"func":"int tls1_mac(SSL *ssl, unsigned char *md, int send)\n\t{\n\tSSL3_RECORD *rec;\n\tunsigned char *mac_sec,*seq;\n\tconst EVP_MD *hash;\n\tsize_t md_size;\n\tint i;\n\tHMAC_CTX hmac;\n\tunsigned char header[13];\n\n\tif (send)\n\t\t{\n\t\trec= &(ssl->s3->wrec);\n\t\tmac_sec= &(ssl->s3->write_mac_secret[0]);\n\t\tseq= &(ssl->s3->write_sequence[0]);\n\t\thash=ssl->write_hash;\n\t\t}\n\telse\n\t\t{\n\t\trec= &(ssl->s3->rrec);\n\t\tmac_sec= &(ssl->s3->read_mac_secret[0]);\n\t\tseq= &(ssl->s3->read_sequence[0]);\n\t\thash=ssl->read_hash;\n\t\t}\n\n\tmd_size=EVP_MD_size(hash);\n\n\t\/* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX *\/\n\tHMAC_CTX_init(&hmac);\n\tHMAC_Init_ex(&hmac,mac_sec,EVP_MD_size(hash),hash,NULL);\n\n\tif (ssl->version == DTLS1_BAD_VER ||\n\t (ssl->version == DTLS1_VERSION && ssl->client_version != DTLS1_BAD_VER))\n\t\t{\n\t\tunsigned char dtlsseq[8],*p=dtlsseq;\n\t\ts2n(send?ssl->d1->w_epoch:ssl->d1->r_epoch, p);\n\t\tmemcpy (p,&seq[2],6);\n\n\t\tmemcpy(header, dtlsseq, 8);\n\t\t}\n\telse\n\t\tmemcpy(header, seq, 8);\n\n\theader[8]=rec->type;\n\theader[9]=(unsigned char)(ssl->version>>8);\n\theader[10]=(unsigned char)(ssl->version);\n\theader[11]=(rec->length)>>8;\n\theader[12]=(rec->length)&0xff;\n\n\tif (!send &&\n\t EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE &&\n\t ssl3_cbc_record_digest_supported(hash))\n\t\t{\n\t\t\/* This is a CBC-encrypted record. We must avoid leaking any\n\t\t * timing-side channel information about how many blocks of\n\t\t * data we are hashing because that gives an attacker a\n\t\t * timing-oracle. *\/\n\t\tssl3_cbc_digest_record(\n\t\t hash,\n\t\t\tmd, &md_size,\n\t\t\theader, rec->input,\n\t\t\trec->length + md_size, rec->orig_len,\n\t\t\tssl->s3->read_mac_secret,\n\t\t\tEVP_MD_size(ssl->read_hash),\n\t\t\t0 \/* not SSLv3 *\/);\n\t\t}\n\telse\n\t\t{\n\t\tunsigned mds;\n\n\t\tHMAC_Update(&hmac,header,sizeof(header));\n\t\tHMAC_Update(&hmac,rec->input,rec->length);\n\t\tHMAC_Final(&hmac,md,&mds);\n\t\tmd_size = mds;\n#ifdef OPENSSL_FIPS\n\t\tif (!send && FIPS_mode())\n\t\t\ttls_fips_digest_extra(\n\t \t\t\t\tssl->enc_read_ctx,\n\t\t\t\t\thash,\n\t\t\t\t\t&hmac, rec->input,\n\t\t\t\t\trec->length, rec->orig_len);\n#endif\n\t\t}\n\t\t\n\tHMAC_CTX_cleanup(&hmac);\n#ifdef TLS_DEBUG\nprintf(\"sec=\");\n{unsigned int z; for (z=0; zlength; z++) printf(\"%02X \",buf[z]); printf(\"\\n\"); }\n#endif\n\n\tif ( SSL_version(ssl) != DTLS1_VERSION && SSL_version(ssl) != DTLS1_BAD_VER)\n\t\t{\n\t\tfor (i=7; i>=0; i--)\n\t\t\t{\n\t\t\t++seq[i];\n\t\t\tif (seq[i] != 0) break; \n\t\t\t}\n\t\t}\n\n#ifdef TLS_DEBUG\n{unsigned int z; for (z=0; z404 Not Found<\/body><\/html>\\n\");\n http_response_send(res);\n exit(0);\n }\n\n if (!strcmp(page, \"Changes\"))\n {\n wiki_show_changes_page(res);\n }\n else if (!strcmp(page, \"ChangesRss\"))\n {\n wiki_show_changes_page_rss(res);\n }\n else if (!strcmp(page, \"Search\"))\n {\n wiki_show_search_results_page(res, http_request_param_get(req, \"expr\"));\n }\n else if (!strcmp(page, \"Create\"))\n {\n if ( (wikitext = http_request_param_get(req, \"title\")) != NULL)\n\t{\n\t \/* create page and redirect *\/\n\t wiki_redirect(res, http_request_param_get(req, \"title\"));\n\t}\n else\n\t{\n\t \/* show create page form *\/\n\t wiki_show_create_page(res);\n\t}\n }\n else\n {\n \/* TODO: dont blindly write wikitext data to disk *\/\n if ( (wikitext = http_request_param_get(req, \"wikitext\")) != NULL)\n\t{\n\t file_write(page, wikitext);\t \n\t}\n\n if (access(page, R_OK) == 0) \t\/* page exists *\/\n\t{\n\t wikitext = file_read(page);\n\t \n\t if (!strcmp(command, \"edit\"))\n\t {\n\t \/* print edit page *\/\n\t wiki_show_edit_page(res, wikitext, page);\n\t }\n\t else\n\t {\n\t wiki_show_page(res, wikitext, page);\n\t }\n\t}\n else\n\t{\n\t if (!strcmp(command, \"create\"))\n\t {\n\t wiki_show_edit_page(res, NULL, page);\n\t }\n\t else\n\t {\n\t char buf[1024];\n\t snprintf(buf, 1024, \"%s?create\", page);\n\t wiki_redirect(res, buf);\n\t }\n\t}\n }\n\n}","target":0,"code_token_length":795,"total_token_length":1031,"max_tokens_setting":2048} +{"idx":471827,"func":"int zsetAdd(robj *zobj, double score, sds ele, int *flags, double *newscore) {\n \/* Turn options into simple to check vars. *\/\n int incr = (*flags & ZADD_INCR) != 0;\n int nx = (*flags & ZADD_NX) != 0;\n int xx = (*flags & ZADD_XX) != 0;\n *flags = 0; \/* We'll return our response flags. *\/\n double curscore;\n\n \/* NaN as input is an error regardless of all the other parameters. *\/\n if (isnan(score)) {\n *flags = ZADD_NAN;\n return 0;\n }\n\n \/* Update the sorted set according to its encoding. *\/\n if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {\n unsigned char *eptr;\n\n if ((eptr = zzlFind(zobj->ptr,ele,&curscore)) != NULL) {\n \/* NX? Return, same element already exists. *\/\n if (nx) {\n *flags |= ZADD_NOP;\n return 1;\n }\n\n \/* Prepare the score for the increment if needed. *\/\n if (incr) {\n score += curscore;\n if (isnan(score)) {\n *flags |= ZADD_NAN;\n return 0;\n }\n if (newscore) *newscore = score;\n }\n\n \/* Remove and re-insert when score changed. *\/\n if (score != curscore) {\n zobj->ptr = zzlDelete(zobj->ptr,eptr);\n zobj->ptr = zzlInsert(zobj->ptr,ele,score);\n *flags |= ZADD_UPDATED;\n }\n return 1;\n } else if (!xx) {\n \/* check if the element is too large or the list\n * becomes too long *before* executing zzlInsert. *\/\n if (zzlLength(zobj->ptr)+1 > server.zset_max_ziplist_entries ||\n sdslen(ele) > server.zset_max_ziplist_value ||\n !ziplistSafeToAdd(zobj->ptr, sdslen(ele)))\n {\n zsetConvert(zobj,OBJ_ENCODING_SKIPLIST);\n } else {\n zobj->ptr = zzlInsert(zobj->ptr,ele,score);\n if (newscore) *newscore = score;\n *flags |= ZADD_ADDED;\n return 1;\n }\n } else {\n *flags |= ZADD_NOP;\n return 1;\n }\n }\n\n \/* Note that the above block handling ziplist would have either returned or\n * converted the key to skiplist. *\/\n if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {\n zset *zs = zobj->ptr;\n zskiplistNode *znode;\n dictEntry *de;\n\n de = dictFind(zs->dict,ele);\n if (de != NULL) {\n \/* NX? Return, same element already exists. *\/\n if (nx) {\n *flags |= ZADD_NOP;\n return 1;\n }\n curscore = *(double*)dictGetVal(de);\n\n \/* Prepare the score for the increment if needed. *\/\n if (incr) {\n score += curscore;\n if (isnan(score)) {\n *flags |= ZADD_NAN;\n return 0;\n }\n if (newscore) *newscore = score;\n }\n\n \/* Remove and re-insert when score changes. *\/\n if (score != curscore) {\n znode = zslUpdateScore(zs->zsl,curscore,ele,score);\n \/* Note that we did not removed the original element from\n * the hash table representing the sorted set, so we just\n * update the score. *\/\n dictGetVal(de) = &znode->score; \/* Update score ptr. *\/\n *flags |= ZADD_UPDATED;\n }\n return 1;\n } else if (!xx) {\n ele = sdsdup(ele);\n znode = zslInsert(zs->zsl,score,ele);\n serverAssert(dictAdd(zs->dict,ele,&znode->score) == DICT_OK);\n *flags |= ZADD_ADDED;\n if (newscore) *newscore = score;\n return 1;\n } else {\n *flags |= ZADD_NOP;\n return 1;\n }\n } else {\n serverPanic(\"Unknown sorted set encoding\");\n }\n return 0; \/* Never reached. *\/\n}","target":0,"code_token_length":978,"total_token_length":1214,"max_tokens_setting":2048} +{"idx":499900,"func":"unsigned int rijndaelSetupEncrypt(u32 *rk, const u8 *key, size_t keybits)\n{\n int i = 0;\n u32 temp;\n\n rk[0] = GETU32(key );\n rk[1] = GETU32(key + 4);\n rk[2] = GETU32(key + 8);\n rk[3] = GETU32(key + 12);\n if (keybits == 128)\n {\n for (;;)\n {\n temp = rk[3];\n rk[4] = rk[0] ^\n (Te4[(temp >> 16) & 0xff] & 0xff000000) ^\n (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^\n (Te4[(temp ) & 0xff] & 0x0000ff00) ^\n (Te4[(temp >> 24) ] & 0x000000ff) ^\n rcon[i];\n rk[5] = rk[1] ^ rk[4];\n rk[6] = rk[2] ^ rk[5];\n rk[7] = rk[3] ^ rk[6];\n if (++i == 10)\n return 10;\n rk += 4;\n }\n }\n rk[4] = GETU32(key + 16);\n rk[5] = GETU32(key + 20);\n if (keybits == 192)\n {\n for (;;)\n {\n temp = rk[ 5];\n rk[ 6] = rk[ 0] ^\n (Te4[(temp >> 16) & 0xff] & 0xff000000) ^\n (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^\n (Te4[(temp ) & 0xff] & 0x0000ff00) ^\n (Te4[(temp >> 24) ] & 0x000000ff) ^\n rcon[i];\n rk[ 7] = rk[ 1] ^ rk[ 6];\n rk[ 8] = rk[ 2] ^ rk[ 7];\n rk[ 9] = rk[ 3] ^ rk[ 8];\n if (++i == 8)\n return 12;\n rk[10] = rk[ 4] ^ rk[ 9];\n rk[11] = rk[ 5] ^ rk[10];\n rk += 6;\n }\n }\n rk[6] = GETU32(key + 24);\n rk[7] = GETU32(key + 28);\n if (keybits == 256)\n {\n for (;;)\n {\n temp = rk[ 7];\n rk[ 8] = rk[ 0] ^\n (Te4[(temp >> 16) & 0xff] & 0xff000000) ^\n (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^\n (Te4[(temp ) & 0xff] & 0x0000ff00) ^\n (Te4[(temp >> 24) ] & 0x000000ff) ^\n rcon[i];\n rk[ 9] = rk[ 1] ^ rk[ 8];\n rk[10] = rk[ 2] ^ rk[ 9];\n rk[11] = rk[ 3] ^ rk[10];\n if (++i == 7)\n return 14;\n temp = rk[11];\n rk[12] = rk[ 4] ^\n (Te4[(temp >> 24) ] & 0xff000000) ^\n (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^\n (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^\n (Te4[(temp ) & 0xff] & 0x000000ff);\n rk[13] = rk[ 5] ^ rk[12];\n rk[14] = rk[ 6] ^ rk[13];\n rk[15] = rk[ 7] ^ rk[14];\n rk += 8;\n }\n }\n return 0;\n}","target":0,"code_token_length":1074,"total_token_length":1310,"max_tokens_setting":2048} +{"idx":340895,"func":"static int mov_text_decode_frame(AVCodecContext *avctx,\n\n void *data, int *got_sub_ptr, AVPacket *avpkt)\n\n{\n\n AVSubtitle *sub = data;\n\n int ret, ts_start, ts_end;\n\n AVBPrint buf;\n\n char *ptr = avpkt->data;\n\n char *end;\n\n \/\/char *ptr_temp;\n\n int text_length, tsmb_type, style_entries, tsmb_size;\n\n int **style_start = {0,};\n\n int **style_end = {0,};\n\n int **style_flags = {0,};\n\n const uint8_t *tsmb;\n\n int index, i;\n\n int *flag;\n\n int *style_pos;\n\n\n\n if (!ptr || avpkt->size < 2)\n\n return AVERROR_INVALIDDATA;\n\n\n\n \/*\n\n * A packet of size two with value zero is an empty subtitle\n\n * used to mark the end of the previous non-empty subtitle.\n\n * We can just drop them here as we have duration information\n\n * already. If the value is non-zero, then it's technically a\n\n * bad packet.\n\n *\/\n\n if (avpkt->size == 2)\n\n return AV_RB16(ptr) == 0 ? 0 : AVERROR_INVALIDDATA;\n\n\n\n \/*\n\n * The first two bytes of the packet are the length of the text string\n\n * In complex cases, there are style descriptors appended to the string\n\n * so we can't just assume the packet size is the string size.\n\n *\/\n\n text_length = AV_RB16(ptr);\n\n end = ptr + FFMIN(2 + text_length, avpkt->size);\n\n ptr += 2;\n\n\n\n ts_start = av_rescale_q(avpkt->pts,\n\n avctx->time_base,\n\n (AVRational){1,100});\n\n ts_end = av_rescale_q(avpkt->pts + avpkt->duration,\n\n avctx->time_base,\n\n (AVRational){1,100});\n\n\n\n tsmb_size = 0;\n\n \/\/ Note that the spec recommends lines be no longer than 2048 characters.\n\n av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);\n\n if (text_length + 2 != avpkt->size) {\n\n while (text_length + 2 + tsmb_size < avpkt->size) {\n\n tsmb = ptr + text_length + tsmb_size;\n\n tsmb_size = AV_RB32(tsmb);\n\n tsmb += 4;\n\n tsmb_type = AV_RB32(tsmb);\n\n tsmb += 4;\n\n\n\n if (tsmb_type == MKBETAG('s','t','y','l')) {\n\n style_entries = AV_RB16(tsmb);\n\n tsmb += 2;\n\n\n\n for(i = 0; i < style_entries; i++) {\n\n style_pos = av_malloc(4);\n\n *style_pos = AV_RB16(tsmb);\n\n index = i;\n\n av_dynarray_add(&style_start, &index, style_pos);\n\n tsmb += 2;\n\n style_pos = av_malloc(4);\n\n *style_pos = AV_RB16(tsmb);\n\n index = i;\n\n av_dynarray_add(&style_end, &index, style_pos);\n\n tsmb += 2;\n\n \/\/ fontID = AV_RB16(tsmb);\n\n tsmb += 2;\n\n flag = av_malloc(4);\n\n *flag = AV_RB8(tsmb);\n\n index = i;\n\n av_dynarray_add(&style_flags, &index, flag);\n\n \/\/fontsize=AV_RB8(tsmb);\n\n tsmb += 2;\n\n \/\/ text-color-rgba\n\n tsmb += 4;\n\n }\n\n text_to_ass(&buf, ptr, end, style_start, style_end, style_flags, style_entries);\n\n av_freep(&style_start);\n\n av_freep(&style_end);\n\n av_freep(&style_flags);\n\n }\n\n }\n\n } else\n\n text_to_ass(&buf, ptr, end, NULL, NULL, 0, 0);\n\n\n\n ret = ff_ass_add_rect_bprint(sub, &buf, ts_start, ts_end - ts_start);\n\n av_bprint_finalize(&buf, NULL);\n\n if (ret < 0)\n\n return ret;\n\n *got_sub_ptr = sub->num_rects > 0;\n\n return avpkt->size;\n\n}\n","target":1,"code_token_length":943,"total_token_length":1179,"max_tokens_setting":2048} +{"idx":38603,"func":"static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,\n\t\t\t\t\t int initial)\n{\n\tstruct megasas_cmd *cmd;\n\tstruct megasas_dcmd_frame *dcmd;\n\tstruct MR_LD_VF_AFFILIATION *new_affiliation = NULL;\n\tstruct MR_LD_VF_MAP *newmap = NULL, *savedmap = NULL;\n\tdma_addr_t new_affiliation_h;\n\tint i, j, retval = 0, found = 0, doscan = 0;\n\tu8 thisVf;\n\n\tcmd = megasas_get_cmd(instance);\n\n\tif (!cmd) {\n\t\tdev_printk(KERN_DEBUG, &instance->pdev->dev, \"megasas_get_ld_vf_affiliation12: \"\n\t\t \"Failed to get cmd for scsi%d\\n\",\n\t\t instance->host->host_no);\n\t\treturn -ENOMEM;\n\t}\n\n\tdcmd = &cmd->frame->dcmd;\n\n\tif (!instance->vf_affiliation) {\n\t\tdev_warn(&instance->pdev->dev, \"SR-IOV: Couldn't get LD\/VF \"\n\t\t \"affiliation for scsi%d\\n\", instance->host->host_no);\n\t\tmegasas_return_cmd(instance, cmd);\n\t\treturn -ENOMEM;\n\t}\n\n\tif (initial)\n\t\tmemset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) *\n\t\t sizeof(struct MR_LD_VF_AFFILIATION));\n\telse {\n\t\tnew_affiliation =\n\t\t\tdma_zalloc_coherent(&instance->pdev->dev,\n\t\t\t\t\t (MAX_LOGICAL_DRIVES + 1) *\n\t\t\t\t\t sizeof(struct MR_LD_VF_AFFILIATION),\n\t\t\t\t\t &new_affiliation_h, GFP_KERNEL);\n\t\tif (!new_affiliation) {\n\t\t\tdev_printk(KERN_DEBUG, &instance->pdev->dev, \"SR-IOV: Couldn't allocate \"\n\t\t\t \"memory for new affiliation for scsi%d\\n\",\n\t\t\t instance->host->host_no);\n\t\t\tmegasas_return_cmd(instance, cmd);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\n\tmemset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);\n\n\tdcmd->cmd = MFI_CMD_DCMD;\n\tdcmd->cmd_status = MFI_STAT_INVALID_STATUS;\n\tdcmd->sge_count = 1;\n\tdcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);\n\tdcmd->timeout = 0;\n\tdcmd->pad_0 = 0;\n\tdcmd->data_xfer_len = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *\n\t\tsizeof(struct MR_LD_VF_AFFILIATION));\n\tdcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS);\n\n\tif (initial)\n\t\tdcmd->sgl.sge32[0].phys_addr =\n\t\t\tcpu_to_le32(instance->vf_affiliation_h);\n\telse\n\t\tdcmd->sgl.sge32[0].phys_addr =\n\t\t\tcpu_to_le32(new_affiliation_h);\n\n\tdcmd->sgl.sge32[0].length = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *\n\t\tsizeof(struct MR_LD_VF_AFFILIATION));\n\n\tdev_warn(&instance->pdev->dev, \"SR-IOV: Getting LD\/VF affiliation for \"\n\t \"scsi%d\\n\", instance->host->host_no);\n\n\n\tif (megasas_issue_blocked_cmd(instance, cmd, 0) != DCMD_SUCCESS) {\n\t\tdev_warn(&instance->pdev->dev, \"SR-IOV: LD\/VF affiliation DCMD\"\n\t\t \" failed with status 0x%x for scsi%d\\n\",\n\t\t dcmd->cmd_status, instance->host->host_no);\n\t\tretval = 1; \/* Do a scan if we couldn't get affiliation *\/\n\t\tgoto out;\n\t}\n\n\tif (!initial) {\n\t\tif (!new_affiliation->ldCount) {\n\t\t\tdev_warn(&instance->pdev->dev, \"SR-IOV: Got new LD\/VF \"\n\t\t\t \"affiliation for passive path for scsi%d\\n\",\n\t\t\t instance->host->host_no);\n\t\t\tretval = 1;\n\t\t\tgoto out;\n\t\t}\n\t\tnewmap = new_affiliation->map;\n\t\tsavedmap = instance->vf_affiliation->map;\n\t\tthisVf = new_affiliation->thisVf;\n\t\tfor (i = 0 ; i < new_affiliation->ldCount; i++) {\n\t\t\tfound = 0;\n\t\t\tfor (j = 0; j < instance->vf_affiliation->ldCount;\n\t\t\t j++) {\n\t\t\t\tif (newmap->ref.targetId ==\n\t\t\t\t savedmap->ref.targetId) {\n\t\t\t\t\tfound = 1;\n\t\t\t\t\tif (newmap->policy[thisVf] !=\n\t\t\t\t\t savedmap->policy[thisVf]) {\n\t\t\t\t\t\tdoscan = 1;\n\t\t\t\t\t\tgoto out;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsavedmap = (struct MR_LD_VF_MAP *)\n\t\t\t\t\t((unsigned char *)savedmap +\n\t\t\t\t\t savedmap->size);\n\t\t\t}\n\t\t\tif (!found && newmap->policy[thisVf] !=\n\t\t\t MR_LD_ACCESS_HIDDEN) {\n\t\t\t\tdoscan = 1;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tnewmap = (struct MR_LD_VF_MAP *)\n\t\t\t\t((unsigned char *)newmap + newmap->size);\n\t\t}\n\n\t\tnewmap = new_affiliation->map;\n\t\tsavedmap = instance->vf_affiliation->map;\n\n\t\tfor (i = 0 ; i < instance->vf_affiliation->ldCount; i++) {\n\t\t\tfound = 0;\n\t\t\tfor (j = 0 ; j < new_affiliation->ldCount; j++) {\n\t\t\t\tif (savedmap->ref.targetId ==\n\t\t\t\t newmap->ref.targetId) {\n\t\t\t\t\tfound = 1;\n\t\t\t\t\tif (savedmap->policy[thisVf] !=\n\t\t\t\t\t newmap->policy[thisVf]) {\n\t\t\t\t\t\tdoscan = 1;\n\t\t\t\t\t\tgoto out;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnewmap = (struct MR_LD_VF_MAP *)\n\t\t\t\t\t((unsigned char *)newmap +\n\t\t\t\t\t newmap->size);\n\t\t\t}\n\t\t\tif (!found && savedmap->policy[thisVf] !=\n\t\t\t MR_LD_ACCESS_HIDDEN) {\n\t\t\t\tdoscan = 1;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tsavedmap = (struct MR_LD_VF_MAP *)\n\t\t\t\t((unsigned char *)savedmap +\n\t\t\t\t savedmap->size);\n\t\t}\n\t}\nout:\n\tif (doscan) {\n\t\tdev_warn(&instance->pdev->dev, \"SR-IOV: Got new LD\/VF \"\n\t\t \"affiliation for scsi%d\\n\", instance->host->host_no);\n\t\tmemcpy(instance->vf_affiliation, new_affiliation,\n\t\t new_affiliation->size);\n\t\tretval = 1;\n\t}\n\n\tif (new_affiliation)\n\t\tdma_free_coherent(&instance->pdev->dev,\n\t\t\t\t (MAX_LOGICAL_DRIVES + 1) *\n\t\t\t\t sizeof(struct MR_LD_VF_AFFILIATION),\n\t\t\t\t new_affiliation, new_affiliation_h);\n\tmegasas_return_cmd(instance, cmd);\n\n\treturn retval;\n}","target":0,"code_token_length":1487,"total_token_length":1723,"max_tokens_setting":2048} +{"idx":287216,"func":"static void parse_class(RBinFile *binfile, RBinDexObj *bin, RBinDexClass *c,\n\t\t\t int class_index, int *methods, int *sym_count) {\n\tstruct r_bin_t *rbin = binfile->rbin;\n\n\tchar *class_name;\n\tint z;\n\tconst ut8 *p, *p_end;\n\n\tif (!c) {\n\t\treturn;\n\t}\n\n\tclass_name = dex_class_name (bin, c);\n\tclass_name = r_str_replace (class_name, \";\", \"\", 0); \/\/TODO: move to func\n\n\tif (!class_name || !*class_name) {\n\t\treturn;\n\t}\n\n\tRBinClass *cls = R_NEW0 (RBinClass);\n\tif (!cls) {\n\t\treturn;\n\t}\n\tcls->name = class_name;\n\tcls->index = class_index;\n\tcls->addr = bin->header.class_offset + class_index * DEX_CLASS_SIZE;\n\tcls->methods = r_list_new ();\n\tif (!cls->methods) {\n\t\tfree (cls);\n\t\treturn;\n\t}\n\tcls->fields = r_list_new ();\n\tif (!cls->fields) {\n\t\tr_list_free (cls->methods);\n\t\tfree (cls);\n\t\treturn;\n\t}\n\tr_list_append (bin->classes_list, cls);\n\tif (dexdump) {\n\t\trbin->cb_printf (\" Class descriptor : '%s;'\\n\", class_name);\n\t\trbin->cb_printf (\n\t\t\t\" Access flags : 0x%04x (%s)\\n\", c->access_flags,\n\t\t\tcreateAccessFlagStr (c->access_flags, kAccessForClass));\n\t\trbin->cb_printf (\" Superclass : '%s'\\n\",\n\t\t\t\t dex_class_super_name (bin, c));\n\t\trbin->cb_printf (\" Interfaces -\\n\");\n\t}\n\n\tif (c->interfaces_offset > 0 &&\n\t bin->header.data_offset < c->interfaces_offset &&\n\t c->interfaces_offset <\n\t\t bin->header.data_offset + bin->header.data_size) {\n\t\tp = r_buf_get_at (binfile->buf, c->interfaces_offset, NULL);\n\t\tint types_list_size = r_read_le32(p);\n\t\tif (types_list_size < 0 || types_list_size >= bin->header.types_size ) {\n\t\t\treturn;\n\t\t}\n\t\tfor (z = 0; z < types_list_size; z++) {\n\t\t\tint t = r_read_le16 (p + 4 + z * 2);\n\t\t\tif (t > 0 && t < bin->header.types_size ) {\n\t\t\t\tint tid = bin->types[t].descriptor_id;\n\t\t\t\tif (dexdump) {\n\t\t\t\t\trbin->cb_printf (\n\t\t\t\t\t\t\" #%d : '%s'\\n\",\n\t\t\t\t\t\tz, getstr (bin, tid));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t\/\/ TODO: this is quite ugly\n\tif (!c || !c->class_data_offset) {\n\t\tif (dexdump) {\n\t\t\trbin->cb_printf (\n\t\t\t\t\" Static fields -\\n Instance fields \"\n\t\t\t\t\"-\\n Direct methods -\\n Virtual methods \"\n\t\t\t\t\"-\\n\");\n\t\t}\n\t} else {\n\t\t\/\/ TODO: move to func, def or inline\n\t\t\/\/ class_data_offset => [class_offset, class_defs_off+class_defs_size*32]\n\t\tif (bin->header.class_offset > c->class_data_offset ||\n\t\t c->class_data_offset <\n\t\t\t bin->header.class_offset +\n\t\t\t\t bin->header.class_size * DEX_CLASS_SIZE) {\n\t\t\treturn;\n\t\t}\n\n\t\tp = r_buf_get_at (binfile->buf, c->class_data_offset, NULL);\n\t\tp_end = p + binfile->buf->length - c->class_data_offset;\n\t\t\/\/XXX check for NULL!!\n\t\tc->class_data = (struct dex_class_data_item_t *)malloc (\n\t\t\tsizeof (struct dex_class_data_item_t));\n\t\tp = r_uleb128 (p, p_end - p, &c->class_data->static_fields_size);\n\t\tp = r_uleb128 (p, p_end - p, &c->class_data->instance_fields_size);\n\t\tp = r_uleb128 (p, p_end - p, &c->class_data->direct_methods_size);\n\t\tp = r_uleb128 (p, p_end - p, &c->class_data->virtual_methods_size);\n\n\t\tif (dexdump) { \n\t\t\trbin->cb_printf (\" Static fields -\\n\"); \n\t\t}\n\t\tp = parse_dex_class_fields (\n\t\t\tbinfile, bin, c, cls, p, p_end, sym_count,\n\t\t\tc->class_data->static_fields_size, true);\n\n\t\tif (dexdump) { \n\t\t\trbin->cb_printf (\" Instance fields -\\n\");\n\t\t}\n\t\tp = parse_dex_class_fields (\n\t\t\tbinfile, bin, c, cls, p, p_end, sym_count,\n\t\t\tc->class_data->instance_fields_size, false);\n\n\t\tif (dexdump) { \n\t\t\trbin->cb_printf (\" Direct methods -\\n\");\n\t\t}\n\t\tp = parse_dex_class_method (\n\t\t\tbinfile, bin, c, cls, p, p_end, sym_count,\n\t\t\tc->class_data->direct_methods_size, methods, true);\n\n\t\tif (dexdump) { \n\t\t\trbin->cb_printf (\" Virtual methods -\\n\");\n\t\t}\n\t\tp = parse_dex_class_method (\n\t\t\tbinfile, bin, c, cls, p, p_end, sym_count,\n\t\t\tc->class_data->virtual_methods_size, methods, false);\n\t}\n\n\tif (dexdump) { \n\t\tchar *source_file = getstr (bin, c->source_file);\n\t\tif (!source_file) {\n\t\t\trbin->cb_printf (\n\t\t\t\t\" source_file_idx : %d (unknown)\\n\\n\",\n\t\t\t\tc->source_file);\n\t\t} else {\n\t\t\trbin->cb_printf (\" source_file_idx : %d (%s)\\n\\n\",\n\t\t\t\t\t c->source_file, source_file);\n\t\t}\n\t}\n\t\/\/ TODO:!!!!\n\t\/\/ FIX: FREE BEFORE ALLOCATE!!!\n\t\/\/free (class_name);\n}","target":1,"code_token_length":1339,"total_token_length":1575,"max_tokens_setting":2048} +{"idx":507108,"func":"int ssl3_client_hello(SSL *s)\n\t{\n\tunsigned char *buf;\n\tunsigned char *p,*d;\n\tint i;\n\tunsigned long l;\n#ifndef OPENSSL_NO_COMP\n\tint j;\n\tSSL_COMP *comp;\n#endif\n\n\tbuf=(unsigned char *)s->init_buf->data;\n\tif (s->state == SSL3_ST_CW_CLNT_HELLO_A)\n\t\t{\n\t\tSSL_SESSION *sess = s->session;\n\t\tif ((sess == NULL) ||\n\t\t\t(sess->ssl_version != s->version) ||\n\t\t\t!sess->session_id_length ||\n\t\t\t(sess->not_resumable))\n\t\t\t{\n\t\t\tif (!ssl_get_new_session(s,0))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\/* else use the pre-loaded session *\/\n\n\t\tp=s->s3->client_random;\n\n\t\tif (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0)\n\t\t\tgoto err;\n\n\t\t\/* Do the message type and length last *\/\n\t\td=p= &(buf[4]);\n\n\t\t\/* version indicates the negotiated version: for example from\n\t\t * an SSLv2\/v3 compatible client hello). The client_version\n\t\t * field is the maximum version we permit and it is also\n\t\t * used in RSA encrypted premaster secrets. Some servers can\n\t\t * choke if we initially report a higher version then\n\t\t * renegotiate to a lower one in the premaster secret. This\n\t\t * didn't happen with TLS 1.0 as most servers supported it\n\t\t * but it can with TLS 1.1 or later if the server only supports\n\t\t * 1.0.\n\t\t *\n\t\t * Possible scenario with previous logic:\n\t\t * \t1. Client hello indicates TLS 1.2\n\t\t * \t2. Server hello says TLS 1.0\n\t\t *\t3. RSA encrypted premaster secret uses 1.2.\n\t\t * \t4. Handhaked proceeds using TLS 1.0.\n\t\t *\t5. Server sends hello request to renegotiate.\n\t\t *\t6. Client hello indicates TLS v1.0 as we now\n\t\t *\t know that is maximum server supports.\n\t\t *\t7. Server chokes on RSA encrypted premaster secret\n\t\t *\t containing version 1.0.\n\t\t *\n\t\t * For interoperability it should be OK to always use the\n\t\t * maximum version we support in client hello and then rely\n\t\t * on the checking of version to ensure the servers isn't\n\t\t * being inconsistent: for example initially negotiating with\n\t\t * TLS 1.0 and renegotiating with TLS 1.2. We do this by using\n\t\t * client_version in client hello and not resetting it to\n\t\t * the negotiated version.\n\t\t *\/\n#if 0\n\t\t*(p++)=s->version>>8;\n\t\t*(p++)=s->version&0xff;\n\t\ts->client_version=s->version;\n#else\n\t\t*(p++)=s->client_version>>8;\n\t\t*(p++)=s->client_version&0xff;\n#endif\n\n\t\t\/* Random stuff *\/\n\t\tmemcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE);\n\t\tp+=SSL3_RANDOM_SIZE;\n\n\t\t\/* Session ID *\/\n\t\tif (s->new_session)\n\t\t\ti=0;\n\t\telse\n\t\t\ti=s->session->session_id_length;\n\t\t*(p++)=i;\n\t\tif (i != 0)\n\t\t\t{\n\t\t\tif (i > (int)sizeof(s->session->session_id))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tmemcpy(p,s->session->session_id,i);\n\t\t\tp+=i;\n\t\t\t}\n\t\t\n\t\t\/* Ciphers supported *\/\n\t\ti=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),&(p[2]),0);\n\t\tif (i == 0)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);\n\t\t\tgoto err;\n\t\t\t}\n#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH\n\t\t\t\/* Some servers hang if client hello > 256 bytes\n\t\t\t * as hack workaround chop number of supported ciphers\n\t\t\t * to keep it well below this if we use TLS v1.2\n\t\t\t *\/\n\t\t\tif (TLS1_get_version(s) >= TLS1_2_VERSION\n\t\t\t\t&& i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH)\n\t\t\t\ti = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1;\n#endif\n\t\ts2n(i,p);\n\t\tp+=i;\n\n\t\t\/* COMPRESSION *\/\n#ifdef OPENSSL_NO_COMP\n\t\t*(p++)=1;\n#else\n\n\t\tif ((s->options & SSL_OP_NO_COMPRESSION)\n\t\t\t\t\t|| !s->ctx->comp_methods)\n\t\t\tj=0;\n\t\telse\n\t\t\tj=sk_SSL_COMP_num(s->ctx->comp_methods);\n\t\t*(p++)=1+j;\n\t\tfor (i=0; ictx->comp_methods,i);\n\t\t\t*(p++)=comp->id;\n\t\t\t}\n#endif\n\t\t*(p++)=0; \/* Add the NULL method *\/\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\/* TLS extensions*\/\n\t\tif (ssl_prepare_clienthello_tlsext(s) <= 0)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif ((p = ssl_add_clienthello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH)) == NULL)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_CLIENT_HELLO,ERR_R_INTERNAL_ERROR);\n\t\t\tgoto err;\n\t\t\t}\n#endif\n\t\t\n\t\tl=(p-d);\n\t\td=buf;\n\t\t*(d++)=SSL3_MT_CLIENT_HELLO;\n\t\tl2n3(l,d);\n\n\t\ts->state=SSL3_ST_CW_CLNT_HELLO_B;\n\t\t\/* number of bytes to write *\/\n\t\ts->init_num=p-buf;\n\t\ts->init_off=0;\n\t\t}\n\n\t\/* SSL3_ST_CW_CLNT_HELLO_B *\/\n\treturn(ssl3_do_write(s,SSL3_RT_HANDSHAKE));\nerr:\n\treturn(-1);\n\t}","target":0,"code_token_length":1355,"total_token_length":1591,"max_tokens_setting":2048} +{"idx":108635,"func":"GF_Err audio_sample_entry_on_child_box(GF_Box *s, GF_Box *a)\n{\n\tGF_UnknownBox *wave = NULL;\n\tBool drop_wave=GF_FALSE;\n\tGF_MPEGAudioSampleEntryBox *ptr = (GF_MPEGAudioSampleEntryBox *)s;\n\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_ESDS:\n\t\tif (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->esd = (GF_ESDBox *)a;\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\tbreak;\n\n\tcase GF_ISOM_BOX_TYPE_DAMR:\n\tcase GF_ISOM_BOX_TYPE_DEVC:\n\tcase GF_ISOM_BOX_TYPE_DQCP:\n\tcase GF_ISOM_BOX_TYPE_DSMV:\n\t\tif (ptr->cfg_3gpp) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_3gpp = (GF_3GPPConfigBox *) a;\n\t\t\/*for 3GP config, remember sample entry type in config*\/\n\t\tptr->cfg_3gpp->cfg.type = ptr->type;\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\tbreak;\n\n\tcase GF_ISOM_BOX_TYPE_DOPS:\n\t\tif (ptr->cfg_opus) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_opus = (GF_OpusSpecificBox *)a;\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_DAC3:\n\t\tif (ptr->cfg_ac3) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_ac3 = (GF_AC3ConfigBox *) a;\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_DEC3:\n\t\tif (ptr->cfg_ac3) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_ac3 = (GF_AC3ConfigBox *) a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MHAC:\n\t\tif (ptr->cfg_mha) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_mha = (GF_MHAConfigBox *) a;\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_DFLA:\n\t\tif (ptr->cfg_flac) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->cfg_flac = (GF_FLACConfigBox *) a;\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\tbreak;\n\n\tcase GF_ISOM_BOX_TYPE_UNKNOWN:\n\t\twave = (GF_UnknownBox *)a;\n\t\t\/*HACK for QT files: get the esds box from the track*\/\n\t\tif (s->type == GF_ISOM_BOX_TYPE_MP4A) {\n\t\t\tif (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\n\t\t\t\/\/wave subboxes may have been properly parsed\n \t\t\tif ((wave->original_4cc == GF_QT_BOX_TYPE_WAVE) && gf_list_count(wave->child_boxes)) {\n \t\t\t\tu32 i;\n for (i =0; ichild_boxes); i++) {\n GF_Box *inner_box = (GF_Box *)gf_list_get(wave->child_boxes, i);\n if (inner_box->type == GF_ISOM_BOX_TYPE_ESDS) {\n ptr->esd = (GF_ESDBox *)inner_box;\n \t\t\t\t\t\tif (ptr->qtff_mode & GF_ISOM_AUDIO_QTFF_CONVERT_FLAG) {\n \tgf_list_rem(a->child_boxes, i);\n \tdrop_wave=GF_TRUE;\n \tptr->compression_id = 0;\n \tgf_list_add(ptr->child_boxes, inner_box);\n\t\t\t\t\t\t}\n }\n }\n\t\t\t\tif (drop_wave) {\n\t\t\t\t\tgf_isom_box_del_parent(&ptr->child_boxes, a);\n \tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\t\t\t\tptr->version = 0;\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t}\n ptr->qtff_mode = GF_ISOM_AUDIO_QTFF_ON_EXT_VALID;\n return GF_OK;\n }\n gf_isom_box_del_parent(&ptr->child_boxes, a);\n return GF_ISOM_INVALID_MEDIA;\n\n\t\t}\n \t\tptr->qtff_mode &= ~GF_ISOM_AUDIO_QTFF_CONVERT_FLAG;\n\n \t\tif ((wave->original_4cc == GF_QT_BOX_TYPE_WAVE) && gf_list_count(wave->child_boxes)) {\n\t\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_ON_NOEXT;\n\t\t}\n\t\treturn GF_OK;\n\tcase GF_QT_BOX_TYPE_WAVE:\n\t{\n\t\tu32 subtype = 0;\n\t\tGF_Box **cfg_ptr = NULL;\n\t\tif (s->type == GF_ISOM_BOX_TYPE_MP4A) {\n\t\t\tcfg_ptr = (GF_Box **) &ptr->esd;\n\t\t\tsubtype = GF_ISOM_BOX_TYPE_ESDS;\n\t\t}\n\t\telse if (s->type == GF_ISOM_BOX_TYPE_AC3) {\n\t\t\tcfg_ptr = (GF_Box **) &ptr->cfg_ac3;\n\t\t\tsubtype = GF_ISOM_BOX_TYPE_DAC3;\n\t\t}\n\t\telse if (s->type == GF_ISOM_BOX_TYPE_EC3) {\n\t\t\tcfg_ptr = (GF_Box **) &ptr->cfg_ac3;\n\t\t\tsubtype = GF_ISOM_BOX_TYPE_DEC3;\n\t\t}\n\t\telse if (s->type == GF_ISOM_BOX_TYPE_OPUS) {\n\t\t\tcfg_ptr = (GF_Box **) &ptr->cfg_opus;\n\t\t\tsubtype = GF_ISOM_BOX_TYPE_DOPS;\n\t\t}\n\t\telse if ((s->type == GF_ISOM_BOX_TYPE_MHA1)\n\t\t\t|| (s->type == GF_ISOM_BOX_TYPE_MHA2)\n\t\t\t|| (s->type == GF_ISOM_BOX_TYPE_MHM1)\n\t\t\t|| (s->type == GF_ISOM_BOX_TYPE_MHM2)\n\t\t) {\n\t\t\tcfg_ptr = (GF_Box **) &ptr->cfg_mha;\n\t\t\tsubtype = GF_ISOM_BOX_TYPE_MHAC;\n\t\t}\n\n\t\tif (cfg_ptr) {\n\t\t\tif (*cfg_ptr) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\n\t\t\t\/\/wave subboxes may have been properly parsed\n \t\t\tif (gf_list_count(a->child_boxes)) {\n \t\t\t\tu32 i;\n for (i =0; ichild_boxes); i++) {\n GF_Box *inner_box = (GF_Box *)gf_list_get(a->child_boxes, i);\n if (inner_box->type == subtype) {\n *cfg_ptr = inner_box;\n \t\t\t\t\t\tif (ptr->qtff_mode & GF_ISOM_AUDIO_QTFF_CONVERT_FLAG) {\n \tgf_list_rem(a->child_boxes, i);\n \tdrop_wave=GF_TRUE;\n \tgf_list_add(ptr->child_boxes, inner_box);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\tif (drop_wave) {\n\t\t\t\t\tgf_isom_box_del_parent(&ptr->child_boxes, a);\n \tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t\t\t\t\tptr->compression_id = 0;\n\t\t\t\t\tptr->version = 0;\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t}\n ptr->qtff_mode = GF_ISOM_AUDIO_QTFF_ON_EXT_VALID;\n return GF_OK;\n }\n\t\t}\n\t}\n \t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_ON_EXT_VALID;\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":1622,"total_token_length":1858,"max_tokens_setting":2048} +{"idx":325684,"func":"POWERPC_FAMILY(POWER8E)(ObjectClass *oc, void *data)\n\n{\n\n DeviceClass *dc = DEVICE_CLASS(oc);\n\n PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);\n\n\n\n dc->fw_name = \"PowerPC,POWER8\";\n\n dc->desc = \"POWER8E\";\n\n dc->props = powerpc_servercpu_properties;\n\n pcc->pvr_match = ppc_pvr_match_power8;\n\n pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;\n\n pcc->init_proc = init_proc_POWER8;\n\n pcc->check_pow = check_pow_nocheck;\n\n pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |\n\n PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |\n\n PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |\n\n PPC_FLOAT_FRSQRTES |\n\n PPC_FLOAT_STFIWX |\n\n PPC_FLOAT_EXT |\n\n PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |\n\n PPC_MEM_SYNC | PPC_MEM_EIEIO |\n\n PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |\n\n PPC_64B | PPC_64BX | PPC_ALTIVEC |\n\n PPC_SEGMENT_64B | PPC_SLBI |\n\n PPC_POPCNTB | PPC_POPCNTWD;\n\n pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |\n\n PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |\n\n PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |\n\n PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |\n\n PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |\n\n PPC2_ISA205 | PPC2_ISA207S;\n\n pcc->msr_mask = (1ull << MSR_SF) |\n\n (1ull << MSR_TM) |\n\n (1ull << MSR_VR) |\n\n (1ull << MSR_VSX) |\n\n (1ull << MSR_EE) |\n\n (1ull << MSR_PR) |\n\n (1ull << MSR_FP) |\n\n (1ull << MSR_ME) |\n\n (1ull << MSR_FE0) |\n\n (1ull << MSR_SE) |\n\n (1ull << MSR_DE) |\n\n (1ull << MSR_FE1) |\n\n (1ull << MSR_IR) |\n\n (1ull << MSR_DR) |\n\n (1ull << MSR_PMM) |\n\n (1ull << MSR_RI) |\n\n (1ull << MSR_LE);\n\n pcc->mmu_model = POWERPC_MMU_2_06;\n\n#if defined(CONFIG_SOFTMMU)\n\n pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;\n\n#endif\n\n pcc->excp_model = POWERPC_EXCP_POWER7;\n\n pcc->bus_model = PPC_FLAGS_INPUT_POWER7;\n\n pcc->bfd_mach = bfd_mach_ppc64;\n\n pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |\n\n POWERPC_FLAG_BE | POWERPC_FLAG_PMM |\n\n POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |\n\n POWERPC_FLAG_VSX;\n\n pcc->l1_dcache_size = 0x8000;\n\n pcc->l1_icache_size = 0x8000;\n\n pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;\n\n}\n","target":0,"code_token_length":798,"total_token_length":1034,"max_tokens_setting":2048} +{"idx":153986,"func":"su_main (int argc, char **argv, int mode)\n{\n int optc;\n const char *new_user = DEFAULT_USER, *runuser_user = NULL;\n char *command = NULL;\n int request_same_session = 0;\n char *shell = NULL;\n struct passwd *pw;\n struct passwd pw_copy;\n\n gid_t *groups = NULL;\n size_t ngroups = 0;\n bool use_supp = false;\n bool use_gid = false;\n gid_t gid = 0;\n\n static const struct option longopts[] = {\n {\"command\", required_argument, NULL, 'c'},\n {\"session-command\", required_argument, NULL, 'C'},\n {\"fast\", no_argument, NULL, 'f'},\n {\"login\", no_argument, NULL, 'l'},\n {\"preserve-environment\", no_argument, NULL, 'p'},\n {\"shell\", required_argument, NULL, 's'},\n {\"group\", required_argument, NULL, 'g'},\n {\"supp-group\", required_argument, NULL, 'G'},\n {\"user\", required_argument, NULL, 'u'},\t\t\/* runuser only *\/\n {\"help\", no_argument, 0, 'h'},\n {\"version\", no_argument, 0, 'V'},\n {NULL, 0, NULL, 0}\n };\n\n setlocale (LC_ALL, \"\");\n bindtextdomain (PACKAGE, LOCALEDIR);\n textdomain (PACKAGE);\n atexit(close_stdout);\n\n su_mode = mode;\n fast_startup = false;\n simulate_login = false;\n change_environment = true;\n\n while ((optc = getopt_long (argc, argv, \"c:fg:G:lmps:u:hV\", longopts, NULL)) != -1)\n {\n switch (optc)\n\t{\n\tcase 'c':\n\t command = optarg;\n\t break;\n\n case 'C':\n command = optarg;\n request_same_session = 1;\n break;\n\n\tcase 'f':\n\t fast_startup = true;\n\t break;\n\n\tcase 'g':\n\t use_gid = true;\n\t gid = add_supp_group(optarg, &groups, &ngroups);\n\t break;\n\n\tcase 'G':\n\t use_supp = true;\n\t add_supp_group(optarg, &groups, &ngroups);\n\t break;\n\n\tcase 'l':\n\t simulate_login = true;\n\t break;\n\n\tcase 'm':\n\tcase 'p':\n\t change_environment = false;\n\t break;\n\n\tcase 's':\n\t shell = optarg;\n\t break;\n\n\tcase 'u':\n\t if (su_mode != RUNUSER_MODE)\n\t usage (EXIT_FAILURE);\n\t runuser_user = optarg;\n\t break;\n\n\tcase 'h':\n\t usage(0);\n\n\tcase 'V':\n\t printf(UTIL_LINUX_VERSION);\n\t exit(EXIT_SUCCESS);\n\n\tdefault:\n\t errtryhelp(EXIT_FAILURE);\n\t}\n }\n\n restricted = evaluate_uid ();\n\n if (optind < argc && !strcmp (argv[optind], \"-\"))\n {\n simulate_login = true;\n ++optind;\n }\n\n if (simulate_login && !change_environment) {\n warnx(_(\"ignoring --preserve-environment, it's mutually exclusive with --login\"));\n change_environment = true;\n }\n\n switch (su_mode) {\n case RUNUSER_MODE:\n if (runuser_user) {\n \/* runuser -u *\/\n new_user = runuser_user;\n if (shell || fast_startup || command || simulate_login) {\n errx(EXIT_FAILURE,\n\t _(\"options --{shell,fast,command,session-command,login} and \"\n\t \"--user are mutually exclusive\"));\n }\n if (optind == argc)\n errx(EXIT_FAILURE, _(\"no command was specified\"));\n\n break;\n }\n \/* fallthrough if -u is not specified, then follow\n * traditional su(1) behavior\n *\/\n case SU_MODE:\n if (optind < argc)\n new_user = argv[optind++];\n break;\n }\n\n if ((use_supp || use_gid) && restricted)\n errx(EXIT_FAILURE, _(\"only root can specify alternative groups\"));\n\n logindefs_load_defaults = load_config;\n\n pw = getpwnam (new_user);\n if (! (pw && pw->pw_name && pw->pw_name[0] && pw->pw_dir && pw->pw_dir[0]\n\t && pw->pw_passwd))\n errx (EXIT_FAILURE, _(\"user %s does not exist\"), new_user);\n\n \/* Make a copy of the password information and point pw at the local\n copy instead. Otherwise, some systems (e.g. Linux) would clobber\n the static data through the getlogin call from log_su.\n Also, make sure pw->pw_shell is a nonempty string.\n It may be NULL when NEW_USER is a username that is retrieved via NIS (YP),\n but that doesn't have a default shell listed. *\/\n pw_copy = *pw;\n pw = &pw_copy;\n pw->pw_name = xstrdup (pw->pw_name);\n pw->pw_passwd = xstrdup (pw->pw_passwd);\n pw->pw_dir = xstrdup (pw->pw_dir);\n pw->pw_shell = xstrdup (pw->pw_shell && pw->pw_shell[0]\n\t\t\t ? pw->pw_shell\n\t\t\t : DEFAULT_SHELL);\n endpwent ();\n\n if (use_supp && !use_gid)\n pw->pw_gid = groups[0];\n else if (use_gid)\n pw->pw_gid = gid;\n\n authenticate (pw);\n\n if (request_same_session || !command || !pw->pw_uid)\n same_session = 1;\n\n \/* initialize shell variable only if \"-u \" not specified *\/\n if (runuser_user) {\n shell = NULL;\n } else {\n if (!shell && !change_environment)\n shell = getenv (\"SHELL\");\n if (shell && getuid () != 0 && restricted_shell (pw->pw_shell))\n {\n\t\/* The user being su'd to has a nonstandard shell, and so is\n\t probably a uucp account or has restricted access. Don't\n\t compromise the account by allowing access with a standard\n\t shell. *\/\n\twarnx (_(\"using restricted shell %s\"), pw->pw_shell);\n\tshell = NULL;\n }\n shell = xstrdup (shell ? shell : pw->pw_shell);\n }\n\n init_groups (pw, groups, ngroups);\n\n if (!simulate_login || command)\n suppress_pam_info = 1;\t\t\/* don't print PAM info messages *\/\n\n create_watching_parent ();\n \/* Now we're in the child. *\/\n\n change_identity (pw);\n if (!same_session)\n setsid ();\n\n \/* Set environment after pam_open_session, which may put KRB5CCNAME\n into the pam_env, etc. *\/\n\n modify_environment (pw, shell);\n\n if (simulate_login && chdir (pw->pw_dir) != 0)\n warn (_(\"warning: cannot change directory to %s\"), pw->pw_dir);\n\n if (shell)\n run_shell (shell, command, argv + optind, max (0, argc - optind));\n else {\n execvp(argv[optind], &argv[optind]);\n err(EXIT_FAILURE, _(\"failed to execute %s\"), argv[optind]);\n }\n}","target":0,"code_token_length":1561,"total_token_length":1797,"max_tokens_setting":2048} +{"idx":302366,"func":"EditorButton(XtermWidget xw, XButtonEvent *event)\n{\n TScreen *screen = TScreenOf(xw);\n int pty = screen->respond;\n int mouse_limit = MouseLimit(screen);\n Char line[32];\n Char final = 'M';\n int row, col;\n int button;\n unsigned count = 0;\n Boolean changed = True;\n\n \/* If button event, get button # adjusted for DEC compatibility *\/\n button = (int) (event->button - 1);\n if (button >= 3)\n\tbutton++;\n\n \/* Ignore buttons that cannot be encoded *\/\n if (screen->send_mouse_pos == X10_MOUSE) {\n\tif (button > 3)\n\t return;\n } else if (screen->extend_coords == SET_SGR_EXT_MODE_MOUSE\n\t || screen->extend_coords == SET_URXVT_EXT_MODE_MOUSE\n\t || screen->extend_coords == SET_PIXEL_POSITION_MOUSE) {\n\tif (button > 15) {\n\t return;\n\t}\n } else {\n\tif (button > 11) {\n\t return;\n\t}\n }\n\n if (screen->extend_coords == SET_PIXEL_POSITION_MOUSE) {\n\trow = event->y - OriginY(screen);\n\tcol = event->x - OriginX(screen);\n } else {\n\t\/* Compute character position of mouse pointer *\/\n\trow = (event->y - screen->border) \/ FontHeight(screen);\n\tcol = (event->x - OriginX(screen)) \/ FontWidth(screen);\n\n\t\/* Limit to screen dimensions *\/\n\tif (row < 0)\n\t row = 0;\n\telse if (row > screen->max_row)\n\t row = screen->max_row;\n\n\tif (col < 0)\n\t col = 0;\n\telse if (col > screen->max_col)\n\t col = screen->max_col;\n\n\tif (mouse_limit > 0) {\n\t \/* Limit to representable mouse dimensions *\/\n\t if (row > mouse_limit)\n\t\trow = mouse_limit;\n\t if (col > mouse_limit)\n\t\tcol = mouse_limit;\n\t}\n }\n\n \/* Build key sequence starting with \\E[M *\/\n if (screen->control_eight_bits) {\n\tline[count++] = ANSI_CSI;\n } else {\n\tline[count++] = ANSI_ESC;\n\tline[count++] = '[';\n }\n switch (screen->extend_coords) {\n case 0:\n case SET_EXT_MODE_MOUSE:\n#if OPT_SCO_FUNC_KEYS\n\tif (xw->keyboard.type == keyboardIsSCO) {\n\t \/*\n\t * SCO function key F1 is \\E[M, which would conflict with xterm's\n\t * normal kmous.\n\t *\/\n\t line[count++] = '>';\n\t}\n#endif\n\tline[count++] = final;\n\tbreak;\n case SET_SGR_EXT_MODE_MOUSE:\n case SET_PIXEL_POSITION_MOUSE:\n\tline[count++] = '<';\n\tbreak;\n }\n\n \/* Add event code to key sequence *\/\n if (okSendMousePos(xw) == X10_MOUSE) {\n\tcount = EMIT_BUTTON(button);\n } else {\n\t\/* Button-Motion events *\/\n\tswitch (event->type) {\n\tcase ButtonPress:\n\t screen->mouse_button |= ButtonBit(button);\n\t count = EMIT_BUTTON(button);\n\t break;\n\tcase ButtonRelease:\n\t \/*\n\t * The (vertical) wheel mouse interface generates release-events\n\t * for buttons 4 and 5.\n\t *\n\t * The X10\/X11 xterm protocol maps the release for buttons 1..3 to\n\t * a -1, which will be later mapped into a \"0\" (some button was\n\t * released), At this point, buttons 1..3 are encoded 0..2 (the\n\t * code 3 is unused).\n\t *\n\t * The SGR (extended) xterm mouse protocol keeps the button number\n\t * and uses a \"m\" to indicate button release.\n\t *\n\t * The behavior for mice with more buttons is unclear, and may be\n\t * revised -TD\n\t *\/\n\t screen->mouse_button &= ~ButtonBit(button);\n\t if (button < 3 || button > 5) {\n\t\tswitch (screen->extend_coords) {\n\t\tcase SET_SGR_EXT_MODE_MOUSE:\n\t\tcase SET_PIXEL_POSITION_MOUSE:\n\t\t final = 'm';\n\t\t break;\n\t\tdefault:\n\t\t button = -1;\n\t\t break;\n\t\t}\n\t }\n\t count = EMIT_BUTTON(button);\n\t break;\n\tcase MotionNotify:\n\t \/* BTN_EVENT_MOUSE and ANY_EVENT_MOUSE modes send motion\n\t * events only if character cell has changed.\n\t *\/\n\t if ((row == screen->mouse_row)\n\t\t&& (col == screen->mouse_col)) {\n\t\tchanged = False;\n\t } else {\n\t\tcount = EMIT_BUTTON(FirstBitN(screen->mouse_button));\n\t }\n\t break;\n\tdefault:\n\t changed = False;\n\t break;\n\t}\n }\n\n if (changed) {\n\tscreen->mouse_row = row;\n\tscreen->mouse_col = col;\n\n\tTRACE((\"mouse at %d,%d button+mask = %#x\\n\", row, col, line[count - 1]));\n\n\t\/* Add pointer position to key sequence *\/\n\tcount = EmitMousePositionSeparator(screen, line, count);\n\tcount = EmitMousePosition(screen, line, count, col);\n\tcount = EmitMousePositionSeparator(screen, line, count);\n\tcount = EmitMousePosition(screen, line, count, row);\n\n\tswitch (screen->extend_coords) {\n\tcase SET_SGR_EXT_MODE_MOUSE:\n\tcase SET_URXVT_EXT_MODE_MOUSE:\n\tcase SET_PIXEL_POSITION_MOUSE:\n\t line[count++] = final;\n\t break;\n\t}\n\n\t\/* Transmit key sequence to process running under xterm *\/\n\tTRACE((\"EditorButton -> %s\\n\", visibleChars(line, count)));\n\tv_write(pty, line, count);\n }\n return;\n}","target":0,"code_token_length":1211,"total_token_length":1447,"max_tokens_setting":2048} +{"idx":327170,"func":"int qcow2_update_header(BlockDriverState *bs)\n\n\n BDRVQcowState *s = bs->opaque;\n\n QCowHeader *header;\n\n char *buf;\n\n size_t buflen = s->cluster_size;\n\n int ret;\n\n uint64_t total_size;\n\n uint32_t refcount_table_clusters;\n\n size_t header_length;\n\n Qcow2UnknownHeaderExtension *uext;\n\n\n\n buf = qemu_blockalign(bs, buflen);\n\n\n\n \/* Header structure *\/\n\n header = (QCowHeader*) buf;\n\n\n\n if (buflen < sizeof(*header)) {\n\n ret = -ENOSPC;\n\n goto fail;\n\n }\n\n\n\n header_length = sizeof(*header) + s->unknown_header_fields_size;\n\n total_size = bs->total_sectors * BDRV_SECTOR_SIZE;\n\n refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3);\n\n\n\n *header = (QCowHeader) {\n\n \/* Version 2 fields *\/\n\n .magic = cpu_to_be32(QCOW_MAGIC),\n\n .version = cpu_to_be32(s->qcow_version),\n\n .backing_file_offset = 0,\n\n .backing_file_size = 0,\n\n .cluster_bits = cpu_to_be32(s->cluster_bits),\n\n .size = cpu_to_be64(total_size),\n\n .crypt_method = cpu_to_be32(s->crypt_method_header),\n\n .l1_size = cpu_to_be32(s->l1_size),\n\n .l1_table_offset = cpu_to_be64(s->l1_table_offset),\n\n .refcount_table_offset = cpu_to_be64(s->refcount_table_offset),\n\n .refcount_table_clusters = cpu_to_be32(refcount_table_clusters),\n\n .nb_snapshots = cpu_to_be32(s->nb_snapshots),\n\n .snapshots_offset = cpu_to_be64(s->snapshots_offset),\n\n\n\n \/* Version 3 fields *\/\n\n .incompatible_features = cpu_to_be64(s->incompatible_features),\n\n .compatible_features = cpu_to_be64(s->compatible_features),\n\n .autoclear_features = cpu_to_be64(s->autoclear_features),\n\n .refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT),\n\n .header_length = cpu_to_be32(header_length),\n\n };\n\n\n\n \/* For older versions, write a shorter header *\/\n\n switch (s->qcow_version) {\n\n case 2:\n\n ret = offsetof(QCowHeader, incompatible_features);\n\n break;\n\n case 3:\n\n ret = sizeof(*header);\n\n break;\n\n default:\n\n ret = -EINVAL;\n\n goto fail;\n\n }\n\n\n\n buf += ret;\n\n buflen -= ret;\n\n memset(buf, 0, buflen);\n\n\n\n \/* Preserve any unknown field in the header *\/\n\n if (s->unknown_header_fields_size) {\n\n if (buflen < s->unknown_header_fields_size) {\n\n ret = -ENOSPC;\n\n goto fail;\n\n }\n\n\n\n memcpy(buf, s->unknown_header_fields, s->unknown_header_fields_size);\n\n buf += s->unknown_header_fields_size;\n\n buflen -= s->unknown_header_fields_size;\n\n }\n\n\n\n \/* Backing file format header extension *\/\n\n if (*bs->backing_format) {\n\n ret = header_ext_add(buf, QCOW2_EXT_MAGIC_BACKING_FORMAT,\n\n bs->backing_format, strlen(bs->backing_format),\n\n buflen);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n buf += ret;\n\n buflen -= ret;\n\n }\n\n\n\n \/* Feature table *\/\n\n Qcow2Feature features[] = {\n\n\n\n .bit = QCOW2_INCOMPAT_DIRTY_BITNR,\n\n .name = \"dirty bit\",\n\n\n\n\n\n\n\n\n .type = QCOW2_FEAT_TYPE_COMPATIBLE,\n\n .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR,\n\n .name = \"lazy refcounts\",\n\n\n };\n\n\n\n ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE,\n\n features, sizeof(features), buflen);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n buf += ret;\n\n buflen -= ret;\n\n\n\n \/* Keep unknown header extensions *\/\n\n QLIST_FOREACH(uext, &s->unknown_header_ext, next) {\n\n ret = header_ext_add(buf, uext->magic, uext->data, uext->len, buflen);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n buf += ret;\n\n buflen -= ret;\n\n }\n\n\n\n \/* End of header extensions *\/\n\n ret = header_ext_add(buf, QCOW2_EXT_MAGIC_END, NULL, 0, buflen);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n buf += ret;\n\n buflen -= ret;\n\n\n\n \/* Backing file name *\/\n\n if (*bs->backing_file) {\n\n size_t backing_file_len = strlen(bs->backing_file);\n\n\n\n if (buflen < backing_file_len) {\n\n ret = -ENOSPC;\n\n goto fail;\n\n }\n\n\n\n \/* Using strncpy is ok here, since buf is not NUL-terminated. *\/\n\n strncpy(buf, bs->backing_file, buflen);\n\n\n\n header->backing_file_offset = cpu_to_be64(buf - ((char*) header));\n\n header->backing_file_size = cpu_to_be32(backing_file_len);\n\n }\n\n\n\n \/* Write the new header *\/\n\n ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size);\n\n if (ret < 0) {\n\n goto fail;\n\n }\n\n\n\n ret = 0;\n\nfail:\n\n qemu_vfree(header);\n\n return ret;\n\n}","target":1,"code_token_length":1224,"total_token_length":1460,"max_tokens_setting":2048} +{"idx":509880,"func":"com_status(String *buffer __attribute__((unused)),\n\t char *line __attribute__((unused)))\n{\n const char *status_str;\n char buff[40];\n ulonglong id;\n MYSQL_RES *result;\n LINT_INIT(result);\n\n if (mysql_real_query_for_lazy(\n C_STRING_WITH_LEN(\"select DATABASE(), USER() limit 1\")))\n return 0;\n\n tee_puts(\"--------------\", stdout);\n usage(1);\t\t\t\t\t\/* Print version *\/\n tee_fprintf(stdout, \"\\nConnection id:\\t\\t%lu\\n\",mysql_thread_id(&mysql));\n \/*\n Don't remove \"limit 1\",\n it is protection againts SQL_SELECT_LIMIT=0\n *\/\n if (!mysql_store_result_for_lazy(&result))\n {\n MYSQL_ROW cur=mysql_fetch_row(result);\n if (cur)\n {\n tee_fprintf(stdout, \"Current database:\\t%s\\n\", cur[0] ? cur[0] : \"\");\n tee_fprintf(stdout, \"Current user:\\t\\t%s\\n\", cur[1]);\n }\n mysql_free_result(result);\n }\n\n#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)\n if ((status_str= mysql_get_ssl_cipher(&mysql)))\n tee_fprintf(stdout, \"SSL:\\t\\t\\tCipher in use is %s\\n\",\n status_str);\n else\n#endif \/* HAVE_OPENSSL && !EMBEDDED_LIBRARY *\/\n tee_puts(\"SSL:\\t\\t\\tNot in use\", stdout);\n\n if (skip_updates)\n {\n my_vidattr(A_BOLD);\n tee_fprintf(stdout, \"\\nAll updates ignored to this database\\n\");\n my_vidattr(A_NORMAL);\n }\n#ifdef USE_POPEN\n tee_fprintf(stdout, \"Current pager:\\t\\t%s\\n\", pager);\n tee_fprintf(stdout, \"Using outfile:\\t\\t'%s'\\n\", opt_outfile ? outfile : \"\");\n#endif\n tee_fprintf(stdout, \"Using delimiter:\\t%s\\n\", delimiter);\n tee_fprintf(stdout, \"Server:\\t\\t\\t%s\\n\", mysql_get_server_name(&mysql));\n tee_fprintf(stdout, \"Server version:\\t\\t%s\\n\", server_version_string(&mysql));\n tee_fprintf(stdout, \"Protocol version:\\t%d\\n\", mysql_get_proto_info(&mysql));\n tee_fprintf(stdout, \"Connection:\\t\\t%s\\n\", mysql_get_host_info(&mysql));\n if ((id= mysql_insert_id(&mysql)))\n tee_fprintf(stdout, \"Insert id:\\t\\t%s\\n\", llstr(id, buff));\n\n \/* \"limit 1\" is protection against SQL_SELECT_LIMIT=0 *\/\n if (mysql_real_query_for_lazy(C_STRING_WITH_LEN(\n \"select @@character_set_client, @@character_set_connection, \"\n \"@@character_set_server, @@character_set_database limit 1\")))\n {\n if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)\n return 0;\n }\n if (!mysql_store_result_for_lazy(&result))\n {\n MYSQL_ROW cur=mysql_fetch_row(result);\n if (cur)\n {\n tee_fprintf(stdout, \"Server characterset:\\t%s\\n\", cur[2] ? cur[2] : \"\");\n tee_fprintf(stdout, \"Db characterset:\\t%s\\n\", cur[3] ? cur[3] : \"\");\n tee_fprintf(stdout, \"Client characterset:\\t%s\\n\", cur[0] ? cur[0] : \"\");\n tee_fprintf(stdout, \"Conn. characterset:\\t%s\\n\", cur[1] ? cur[1] : \"\");\n }\n mysql_free_result(result);\n }\n else\n {\n \/* Probably pre-4.1 server *\/\n tee_fprintf(stdout, \"Client characterset:\\t%s\\n\", charset_info->csname);\n tee_fprintf(stdout, \"Server characterset:\\t%s\\n\", mysql.charset->csname);\n }\n\n#ifndef EMBEDDED_LIBRARY\n if (strstr(mysql_get_host_info(&mysql),\"TCP\/IP\") || ! mysql.unix_socket)\n tee_fprintf(stdout, \"TCP port:\\t\\t%d\\n\", mysql.port);\n else\n tee_fprintf(stdout, \"UNIX socket:\\t\\t%s\\n\", mysql.unix_socket);\n if (mysql.net.compress)\n tee_fprintf(stdout, \"Protocol:\\t\\tCompressed\\n\");\n#endif\n\n if ((status_str= mysql_stat(&mysql)) && !mysql_error(&mysql)[0])\n {\n ulong sec;\n const char *pos= strchr(status_str,' ');\n \/* print label *\/\n tee_fprintf(stdout, \"%.*s\\t\\t\\t\", (int) (pos-status_str), status_str);\n if ((status_str= str2int(pos,10,0,LONG_MAX,(long*) &sec)))\n {\n nice_time((double) sec,buff,0);\n tee_puts(buff, stdout);\t\t\t\/* print nice time *\/\n while (*status_str == ' ')\n status_str++; \/* to next info *\/\n tee_putc('\\n', stdout);\n tee_puts(status_str, stdout);\n }\n }\n if (safe_updates)\n {\n my_vidattr(A_BOLD);\n tee_fprintf(stdout, \"\\nNote that you are running in safe_update_mode:\\n\");\n my_vidattr(A_NORMAL);\n tee_fprintf(stdout, \"\\\nUPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\\n\\\n(One can force an UPDATE\/DELETE by adding LIMIT # at the end of the command.)\\n\\\nSELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\\n\\\nMax number of examined row combination in a join is set to: %lu\\n\\n\",\nselect_limit, max_join_size);\n }\n tee_puts(\"--------------\\n\", stdout);\n return 0;\n}","target":0,"code_token_length":1223,"total_token_length":1459,"max_tokens_setting":2048} +{"idx":226139,"func":"void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer)\n{\n TRACE_EVENT2(\"blink,benchmark\", \"DisplayItemList::commitNewDisplayItems\", \"current_display_list_size\", (int)m_currentDisplayItems.size(),\n \"num_non_cached_new_items\", (int)m_newDisplayItems.size() - m_numCachedItems);\n\n if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {\n for (const auto& invalidation : m_invalidations)\n graphicsLayer->setNeedsDisplayInRect(invalidation.rect, invalidation.invalidationReason);\n m_invalidations.clear();\n }\n\n ASSERT(m_scopeStack.isEmpty());\n m_scopeStack.clear();\n m_nextScope = 1;\n ASSERT(!skippingCache());\n#if ENABLE(ASSERT)\n m_newDisplayItemIndicesByClient.clear();\n#endif\n\n if (m_currentDisplayItems.isEmpty()) {\n#if ENABLE(ASSERT)\n for (const auto& item : m_newDisplayItems)\n ASSERT(!item.isCached());\n #endif\n m_currentDisplayItems.swap(m_newDisplayItems);\n m_currentPaintChunks = m_newPaintChunks.releasePaintChunks();\n m_validlyCachedClientsDirty = true;\n m_numCachedItems = 0;\n return;\n }\n\n updateValidlyCachedClientsIfNeeded();\n\n OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin());\n \n DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes()));\n Vector updatedPaintChunks;\n DisplayItems::iterator currentIt = m_currentDisplayItems.begin();\n DisplayItems::iterator currentEnd = m_currentDisplayItems.end();\n for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) {\n const DisplayItem& newDisplayItem = *newIt;\n const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId();\n bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayItemId.type;\n\n bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matches(*currentIt);\n\n if (newDisplayItemHasCachedType) {\n ASSERT(newDisplayItem.isCached());\n ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !paintOffsetWasInvalidated(newDisplayItem.client())));\n if (!isSynchronized) {\n currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrderIndexContext);\n\n if (currentIt == currentEnd) {\n#ifndef NDEBUG\n showDebugData();\n WTFLogAlways(\"%s not found in m_currentDisplayItems\\n\", newDisplayItem.asDebugString().utf8().data());\n#endif\n ASSERT_NOT_REACHED();\n continue;\n }\n }\n#if ENABLE(ASSERT)\n if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) {\n DisplayItems::iterator temp = currentIt;\n checkUnderInvalidation(newIt, temp);\n }\n#endif\n if (newDisplayItem.isCachedDrawing()) {\n updatedList.appendByMoving(*currentIt);\n ++currentIt;\n } else {\n ASSERT(newDisplayItem.isCachedSubsequence());\n copyCachedSubsequence(currentIt, updatedList);\n ASSERT(updatedList.last().isEndSubsequence());\n }\n } else {\n ASSERT(!newDisplayItem.isDrawing()\n || newDisplayItem.skippedCache()\n || !clientCacheIsValid(newDisplayItem.client())\n || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && paintOffsetWasInvalidated(newDisplayItem.client())));\n\n updatedList.appendByMoving(*newIt);\n\n if (isSynchronized)\n ++currentIt;\n }\n if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0)\n outOfOrderIndexContext.nextItemToIndex = currentIt;\n }\n\n#if ENABLE(ASSERT)\n if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())\n checkNoRemainingCachedDisplayItems();\n #endif \/\/ ENABLE(ASSERT)\n \n \/\/ TODO(jbroman): When subsequence caching applies to SPv2, we'll need to\n \/\/ merge the paint chunks as well.\n m_currentPaintChunks = m_newPaintChunks.releasePaintChunks();\n\n m_newDisplayItems.clear();\n m_validlyCachedClientsDirty = true;\n m_currentDisplayItems.swap(updatedList);\n m_numCachedItems = 0;\n\n#if ENABLE(ASSERT)\n m_clientsWithPaintOffsetInvalidations.clear();\n#endif\n}\n","target":0,"code_token_length":954,"total_token_length":1190,"max_tokens_setting":2048} +{"idx":13309,"func":"int main(int argc, char **argv)\n{\n\n u8 *byteStrmStart;\n u8 *byteStrm;\n u32 strmLen;\n u32 picSize;\n H264SwDecInst decInst;\n H264SwDecRet ret;\n H264SwDecInput decInput;\n H264SwDecOutput decOutput;\n H264SwDecPicture decPicture;\n H264SwDecInfo decInfo;\n u32 picNumber;\n\n FILE *finput;\n FILE *foutput;\n\n \/* Check that enough command line arguments given, if not -> print usage\n * information out *\/\n if (argc < 2)\n {\n printf( \"Usage: %s file.h264\\n\", argv[0]);\n return -1;\n }\n\n \/* open output file for writing, output file named out.yuv. If file open\n * fails -> exit *\/\n foutput = fopen(\"out.yuv\", \"wb\");\n if (foutput == NULL)\n {\n printf(\"UNABLE TO OPEN OUTPUT FILE\\n\");\n return -1;\n }\n\n \/* open input file for reading, file name given by user. If file open\n * fails -> exit *\/\n finput = fopen(argv[argc-1], \"rb\");\n if (finput == NULL)\n {\n printf(\"UNABLE TO OPEN INPUT FILE\\n\");\n return -1;\n }\n\n \/* check size of the input file -> length of the stream in bytes *\/\n fseek(finput, 0L, SEEK_END);\n strmLen = (u32)ftell(finput);\n\n rewind(finput);\n \n \/* allocate memory for stream buffer, exit if unsuccessful *\/\n byteStrm = byteStrmStart = (u8 *)H264SwDecMalloc(sizeof(u8)*strmLen);\n if (byteStrm == NULL)\n {\n printf(\"UNABLE TO ALLOCATE MEMORY\\n\");\n return -1;\n }\n\n \/* read input stream from file to buffer and close input file *\/\n fread(byteStrm, sizeof(u8), strmLen, finput);\n fclose(finput);\n\n \/* initialize decoder. If unsuccessful -> exit *\/\n ret = H264SwDecInit(&decInst, 0);\n if (ret != H264SWDEC_OK)\n {\n printf(\"DECODER INITIALIZATION FAILED\\n\");\n return -1;\n }\n\n \/* initialize H264SwDecDecode() input structure *\/\n decInput.pStream = byteStrmStart;\n decInput.dataLen = strmLen;\n decInput.intraConcealmentMethod = 0;\n\n picNumber = 0;\n\n \/* For performance measurements, read the start time (in seconds) here.\n * The decoding time should be measured over several frames and after\n * that average fps (frames\/second) can be calculated.\n *\n * startTime = GetTime();\n *\n * To prevent calculating file I\/O latensies as a decoding time,\n * comment out WriteOutput function call. Also prints to stdout might\n * consume considerable amount of cycles during measurement *\/\n\n \/* main decoding loop *\/\n do\n {\n \/* call API function to perform decoding *\/\n ret = H264SwDecDecode(decInst, &decInput, &decOutput);\n\n switch(ret)\n {\n\n case H264SWDEC_HDRS_RDY_BUFF_NOT_EMPTY:\n\n \/* picture dimensions are available for query now *\/\n ret = H264SwDecGetInfo(decInst, &decInfo);\n if (ret != H264SWDEC_OK)\n return -1;\n\n \/* picture size in pixels *\/\n picSize = decInfo.picWidth * decInfo.picHeight;\n \/* memory needed for YCbCr 4:2:0 picture in bytes *\/\n picSize = (3 * picSize)\/2;\n \/* memory needed for 16-bit RGB picture in bytes\n * picSize = (decInfo.picWidth * decInfo.picHeight) * 2; *\/\n\n printf(\"Width %d Height %d\\n\",\n decInfo.picWidth, decInfo.picHeight);\n\n \/* update H264SwDecDecode() input structure, number of bytes\n * \"consumed\" is computed as difference between the new stream\n * pointer and old stream pointer *\/\n decInput.dataLen -=\n (u32)(decOutput.pStrmCurrPos - decInput.pStream);\n decInput.pStream = decOutput.pStrmCurrPos;\n break;\n\n case H264SWDEC_PIC_RDY_BUFF_NOT_EMPTY:\n case H264SWDEC_PIC_RDY:\n\n \/* update H264SwDecDecode() input structure, number of bytes\n * \"consumed\" is computed as difference between the new stream\n * pointer and old stream pointer *\/\n decInput.dataLen -=\n (u32)(decOutput.pStrmCurrPos - decInput.pStream);\n decInput.pStream = decOutput.pStrmCurrPos;\n\n \/* use function H264SwDecNextPicture() to obtain next picture\n * in display order. Function is called until no more images\n * are ready for display *\/\n while (H264SwDecNextPicture(decInst, &decPicture, 0) ==\n H264SWDEC_PIC_RDY) { picNumber++;\n\n printf(\"PIC %d, type %s, concealed %d\\n\", picNumber,\n decPicture.isIdrPicture ? \"IDR\" : \"NON-IDR\",\n decPicture.nbrOfErrMBs);\n fflush(stdout);\n\n \/* Do color conversion if needed to get display image\n * in RGB-format\n *\n * YuvToRgb( decPicture.pOutputPicture, pRgbPicture ); *\/\n\n \/* write next display image to output file *\/\n WriteOutput(foutput, (u8*)decPicture.pOutputPicture,\n picSize);\n }\n\n break;\n\n case H264SWDEC_EVALUATION_LIMIT_EXCEEDED:\n \/* evaluation version of the decoder has limited decoding\n * capabilities *\/\n printf(\"EVALUATION LIMIT REACHED\\n\");\n goto end;\n\n default:\n printf(\"UNRECOVERABLE ERROR\\n\");\n return -1;\n }\n \/* keep decoding until all data from input stream buffer consumed *\/\n } while (decInput.dataLen > 0);\n\nend:\n\n \/* if output in display order is preferred, the decoder shall be forced\n * to output pictures remaining in decoded picture buffer. Use function\n * H264SwDecNextPicture() to obtain next picture in display order. Function\n * is called until no more images are ready for display. Second parameter\n * for the function is set to '1' to indicate that this is end of the\n * stream and all pictures shall be output *\/\n while (H264SwDecNextPicture(decInst, &decPicture, 1) ==\n H264SWDEC_PIC_RDY) {\n\n picNumber++;\n\n printf(\"PIC %d, type %s, concealed %d\\n\", picNumber,\n decPicture.isIdrPicture ? \"IDR\" : \"NON-IDR\",\n decPicture.nbrOfErrMBs);\n fflush(stdout);\n\n \/* Do color conversion if needed to get display image\n * in RGB-format\n *\n * YuvToRgb( decPicture.pOutputPicture, pRgbPicture ); *\/\n\n \/* write next display image to output file *\/\n WriteOutput(foutput, (u8*)decPicture.pOutputPicture, picSize);\n }\n\n \/* For performance measurements, read the end time (in seconds) here.\n *\n * endTime = GetTime();\n *\n * Now the performance can be calculated as frames per second:\n * fps = picNumber \/ (endTime - startTime); *\/\n\n\n \/* release decoder instance *\/\n H264SwDecRelease(decInst);\n\n \/* close output file *\/\n fclose(foutput);\n\n \/* free byte stream buffer *\/\n free(byteStrmStart);\n\n return 0;\n\n}\n","target":1,"code_token_length":1668,"total_token_length":1904,"max_tokens_setting":2048} +{"idx":274799,"func":"void WebContents::Print(gin_helper::Arguments* args) {\n gin_helper::Dictionary options =\n gin::Dictionary::CreateEmpty(args->isolate());\n base::Value settings(base::Value::Type::DICTIONARY);\n\n if (args->Length() >= 1 && !args->GetNext(&options)) {\n args->ThrowError(\"webContents.print(): Invalid print settings specified.\");\n return;\n }\n\n printing::CompletionCallback callback;\n if (args->Length() == 2 && !args->GetNext(&callback)) {\n args->ThrowError(\n \"webContents.print(): Invalid optional callback provided.\");\n return;\n }\n\n \/\/ Set optional silent printing\n bool silent = false;\n options.Get(\"silent\", &silent);\n\n bool print_background = false;\n options.Get(\"printBackground\", &print_background);\n settings.SetBoolKey(printing::kSettingShouldPrintBackgrounds,\n print_background);\n\n \/\/ Set custom margin settings\n gin_helper::Dictionary margins =\n gin::Dictionary::CreateEmpty(args->isolate());\n if (options.Get(\"margins\", &margins)) {\n printing::MarginType margin_type = printing::DEFAULT_MARGINS;\n margins.Get(\"marginType\", &margin_type);\n settings.SetIntKey(printing::kSettingMarginsType, margin_type);\n\n if (margin_type == printing::CUSTOM_MARGINS) {\n base::Value custom_margins(base::Value::Type::DICTIONARY);\n int top = 0;\n margins.Get(\"top\", &top);\n custom_margins.SetIntKey(printing::kSettingMarginTop, top);\n int bottom = 0;\n margins.Get(\"bottom\", &bottom);\n custom_margins.SetIntKey(printing::kSettingMarginBottom, bottom);\n int left = 0;\n margins.Get(\"left\", &left);\n custom_margins.SetIntKey(printing::kSettingMarginLeft, left);\n int right = 0;\n margins.Get(\"right\", &right);\n custom_margins.SetIntKey(printing::kSettingMarginRight, right);\n settings.SetPath(printing::kSettingMarginsCustom,\n std::move(custom_margins));\n }\n } else {\n settings.SetIntKey(printing::kSettingMarginsType,\n printing::DEFAULT_MARGINS);\n }\n\n \/\/ Set whether to print color or greyscale\n bool print_color = true;\n options.Get(\"color\", &print_color);\n int color_setting = print_color ? printing::COLOR : printing::GRAY;\n settings.SetIntKey(printing::kSettingColor, color_setting);\n\n \/\/ Is the orientation landscape or portrait.\n bool landscape = false;\n options.Get(\"landscape\", &landscape);\n settings.SetBoolKey(printing::kSettingLandscape, landscape);\n\n \/\/ We set the default to the system's default printer and only update\n \/\/ if at the Chromium level if the user overrides.\n \/\/ Printer device name as opened by the OS.\n base::string16 device_name;\n options.Get(\"deviceName\", &device_name);\n if (!device_name.empty() && !IsDeviceNameValid(device_name)) {\n args->ThrowError(\"webContents.print(): Invalid deviceName provided.\");\n return;\n }\n\n int scale_factor = 100;\n options.Get(\"scaleFactor\", &scale_factor);\n settings.SetIntKey(printing::kSettingScaleFactor, scale_factor);\n\n int pages_per_sheet = 1;\n options.Get(\"pagesPerSheet\", &pages_per_sheet);\n settings.SetIntKey(printing::kSettingPagesPerSheet, pages_per_sheet);\n\n \/\/ True if the user wants to print with collate.\n bool collate = true;\n options.Get(\"collate\", &collate);\n settings.SetBoolKey(printing::kSettingCollate, collate);\n\n \/\/ The number of individual copies to print\n int copies = 1;\n options.Get(\"copies\", &copies);\n settings.SetIntKey(printing::kSettingCopies, copies);\n\n \/\/ Strings to be printed as headers and footers if requested by the user.\n std::string header;\n options.Get(\"header\", &header);\n std::string footer;\n options.Get(\"footer\", &footer);\n\n if (!(header.empty() && footer.empty())) {\n settings.SetBoolKey(printing::kSettingHeaderFooterEnabled, true);\n\n settings.SetStringKey(printing::kSettingHeaderFooterTitle, header);\n settings.SetStringKey(printing::kSettingHeaderFooterURL, footer);\n } else {\n settings.SetBoolKey(printing::kSettingHeaderFooterEnabled, false);\n }\n\n \/\/ We don't want to allow the user to enable these settings\n \/\/ but we need to set them or a CHECK is hit.\n settings.SetIntKey(printing::kSettingPrinterType,\n static_cast(printing::PrinterType::kLocal));\n settings.SetBoolKey(printing::kSettingShouldPrintSelectionOnly, false);\n settings.SetBoolKey(printing::kSettingRasterizePdf, false);\n\n \/\/ Set custom page ranges to print\n std::vector page_ranges;\n if (options.Get(\"pageRanges\", &page_ranges)) {\n base::Value page_range_list(base::Value::Type::LIST);\n for (auto& range : page_ranges) {\n int from, to;\n if (range.Get(\"from\", &from) && range.Get(\"to\", &to)) {\n base::Value range(base::Value::Type::DICTIONARY);\n range.SetIntKey(printing::kSettingPageRangeFrom, from);\n range.SetIntKey(printing::kSettingPageRangeTo, to);\n page_range_list.Append(std::move(range));\n } else {\n continue;\n }\n }\n if (page_range_list.GetList().size() > 0)\n settings.SetPath(printing::kSettingPageRange, std::move(page_range_list));\n }\n\n \/\/ Duplex type user wants to use.\n printing::mojom::DuplexMode duplex_mode =\n printing::mojom::DuplexMode::kSimplex;\n options.Get(\"duplexMode\", &duplex_mode);\n settings.SetIntKey(printing::kSettingDuplexMode,\n static_cast(duplex_mode));\n\n \/\/ We've already done necessary parameter sanitization at the\n \/\/ JS level, so we can simply pass this through.\n base::Value media_size(base::Value::Type::DICTIONARY);\n if (options.Get(\"mediaSize\", &media_size))\n settings.SetKey(printing::kSettingMediaSize, std::move(media_size));\n\n \/\/ Set custom dots per inch (dpi)\n gin_helper::Dictionary dpi_settings;\n int dpi = 72;\n if (options.Get(\"dpi\", &dpi_settings)) {\n int horizontal = 72;\n dpi_settings.Get(\"horizontal\", &horizontal);\n settings.SetIntKey(printing::kSettingDpiHorizontal, horizontal);\n int vertical = 72;\n dpi_settings.Get(\"vertical\", &vertical);\n settings.SetIntKey(printing::kSettingDpiVertical, vertical);\n } else {\n settings.SetIntKey(printing::kSettingDpiHorizontal, dpi);\n settings.SetIntKey(printing::kSettingDpiVertical, dpi);\n }\n\n base::ThreadPool::PostTaskAndReplyWithResult(\n FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},\n base::BindOnce(&GetDefaultPrinterAsync),\n base::BindOnce(&WebContents::OnGetDefaultPrinter,\n weak_factory_.GetWeakPtr(), std::move(settings),\n std::move(callback), device_name, silent));\n}","target":0,"code_token_length":1600,"total_token_length":1836,"max_tokens_setting":2048} +{"idx":237457,"func":"gs_main_finit(gs_main_instance * minst, int exit_status, int code)\n{\n i_ctx_t *i_ctx_p = minst->i_ctx_p;\n gs_dual_memory_t dmem = {0};\n int exit_code;\n ref error_object;\n char *tempnames;\n\n \/* NB: need to free gs_name_table\n *\/\n\n \/*\n * Previous versions of this code closed the devices in the\n * device list here. Since these devices are now prototypes,\n * they cannot be opened, so they do not need to be closed;\n * alloc_restore_all will close dynamically allocated devices.\n *\/\n tempnames = gs_main_tempnames(minst);\n\n \/* by the time we get here, we *must* avoid any random redefinitions of\n * operators etc, so we push systemdict onto the top of the dict stack.\n * We do this in C to avoid running into any other re-defininitions in the\n * Postscript world.\n *\/\n gs_finit_push_systemdict(i_ctx_p);\n\n \/* We have to disable BGPrint before we call interp_reclaim() to prevent the\n * parent rendering thread initialising for the next page, whilst we are\n * removing objects it may want to access - for example, the I\/O device table.\n * We also have to mess with the BeginPage\/EndPage procs so that we don't\n * trigger a spurious extra page to be emitted.\n *\/\n if (minst->init_done >= 2) {\n gs_main_run_string(minst,\n \"\/BGPrint \/GetDeviceParam .special_op \\\n {{ <<\/BeginPage {pop} \/EndPage {pop pop \/\/false } \\\n \/BGPrint false \/NumRenderingThreads 0>> setpagedevice} if} if \\\n serverdict \/.jobsavelevel get 0 eq {\/quit} {\/stop} ifelse \\\n .systemvar exec\",\n 0 , &exit_code, &error_object);\n }\n\n \/*\n * Close the \"main\" device, because it may need to write out\n * data before destruction. pdfwrite needs so.\n *\/\n if (minst->init_done >= 2) {\n int code = 0;\n\n if (idmemory->reclaim != 0) {\n code = interp_reclaim(&minst->i_ctx_p, avm_global);\n\n if (code < 0) {\n ref error_name;\n if (tempnames)\n free(tempnames);\n\n if (gs_errorname(i_ctx_p, code, &error_name) >= 0) {\n char err_str[32] = {0};\n name_string_ref(imemory, &error_name, &error_name);\n memcpy(err_str, error_name.value.const_bytes, r_size(&error_name));\n emprintf2(imemory, \"ERROR: %s (%d) reclaiming the memory while the interpreter finalization.\\n\", err_str, code);\n }\n else {\n emprintf1(imemory, \"UNKNOWN ERROR %d reclaiming the memory while the interpreter finalization.\\n\", code);\n }\n#ifdef MEMENTO_SQUEEZE_BUILD\n if (code != gs_error_VMerror ) return gs_error_Fatal;\n#else\n return gs_error_Fatal;\n#endif\n }\n i_ctx_p = minst->i_ctx_p; \/* interp_reclaim could change it. *\/\n }\n \n if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&\n gx_device_is_null(i_ctx_p->pgs->device)) {\n \/* if the job replaced the device with the nulldevice, we we need to grestore\n away that device, so the block below can properly dispense\n with the default device.\n *\/\n int code = gs_grestoreall(i_ctx_p->pgs);\n if (code < 0) return_error(gs_error_Fatal);\n }\n\n if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {\n gx_device *pdev = i_ctx_p->pgs->device;\n const char * dname = pdev->dname;\n if (code < 0) {\n ref error_name;\n if (gs_errorname(i_ctx_p, code, &error_name) >= 0) {\n char err_str[32] = {0};\n name_string_ref(imemory, &error_name, &error_name);\n memcpy(err_str, error_name.value.const_bytes, r_size(&error_name));\n emprintf3(imemory, \"ERROR: %s (%d) on closing %s device.\\n\", err_str, code, dname);\n }\n else {\n emprintf2(imemory, \"UNKNOWN ERROR %d closing %s device.\\n\", code, dname);\n }\n }\n rc_decrement(pdev, \"gs_main_finit\"); \/* device might be freed *\/\n if (exit_status == 0 || exit_status == gs_error_Quit)\n exit_status = code;\n }\n\n \/* Flush stdout and stderr *\/\n gs_main_run_string(minst,\n \"(%stdout) (w) file closefile (%stderr) (w) file closefile \\\n serverdict \/.jobsavelevel get 0 eq {\/quit} {\/stop} ifelse .systemexec \\\n systemdict \/savedinitialgstate .forceundef\",\n 0 , &exit_code, &error_object);\n }\n gp_readline_finit(minst->readline_data);\n i_ctx_p = minst->i_ctx_p;\t\t\/* get current interp context *\/\n if (gs_debug_c(':')) {\n print_resource_usage(minst, &gs_imemory, \"Final\");\n dmprintf1(minst->heap, \"%% Exiting instance 0x%p\\n\", minst);\n }\n \/* Do the equivalent of a restore \"past the bottom\". *\/\n \/* This will release all memory, close all open files, etc. *\/\n if (minst->init_done >= 1) {\n gs_memory_t *mem_raw = i_ctx_p->memory.current->non_gc_memory;\n i_plugin_holder *h = i_ctx_p->plugin_list;\n\n dmem = *idmemory;\n code = alloc_restore_all(i_ctx_p);\n if (code < 0)\n emprintf1(mem_raw,\n \"ERROR %d while the final restore. See gs\/psi\/ierrors.h for code explanation.\\n\",\n code);\n i_iodev_finit(&dmem);\n i_plugin_finit(mem_raw, h);\n }\n\n \/* clean up redirected stdout *\/\n if (minst->heap->gs_lib_ctx->fstdout2\n && (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstdout)\n && (minst->heap->gs_lib_ctx->fstdout2 != minst->heap->gs_lib_ctx->fstderr)) {\n fclose(minst->heap->gs_lib_ctx->fstdout2);\n minst->heap->gs_lib_ctx->fstdout2 = (FILE *)NULL;\n }\n\n minst->heap->gs_lib_ctx->stdout_is_redirected = 0;\n minst->heap->gs_lib_ctx->stdout_to_stderr = 0;\n \/* remove any temporary files, after ghostscript has closed files *\/\n if (tempnames) {\n char *p = tempnames;\n while (*p) {\n unlink(p);\n p += strlen(p) + 1;\n }\n free(tempnames);\n }\n gs_lib_finit(exit_status, code, minst->heap);\n\n gs_free_object(minst->heap, minst->lib_path.container.value.refs, \"lib_path array\");\n ialloc_finit(&dmem);\n return exit_status;\n}\n","target":0,"code_token_length":1666,"total_token_length":1902,"max_tokens_setting":2048} +{"idx":140675,"func":"psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)\n{\tva_list\t\t\targptr ;\n\tsf_count_t\t\t*countptr, countdata ;\n\tunsigned char\t*ucptr, sixteen_bytes [16] ;\n\tunsigned int \t*intptr, intdata ;\n\tunsigned short\t*shortptr ;\n\tchar\t\t\t*charptr ;\n\tfloat\t\t\t*floatptr ;\n\tdouble\t\t\t*doubleptr ;\n\tchar\t\t\tc ;\n\tint\t\t\t\tbyte_count = 0, count = 0 ;\n\n\tif (! format)\n\t\treturn psf_ftell (psf) ;\n\n\tva_start (argptr, format) ;\n\n\twhile ((c = *format++))\n\t{\n\t\tif (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))\n\t\t\treturn count ;\n\n\t\tswitch (c)\n\t\t{\tcase 'e' : \/* All conversions are now from LE to host. *\/\n\t\t\t\t\tpsf->rwf_endian = SF_ENDIAN_LITTLE ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'E' : \/* All conversions are now from BE to host. *\/\n\t\t\t\t\tpsf->rwf_endian = SF_ENDIAN_BIG ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'm' : \/* 4 byte marker value eg 'RIFF' *\/\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (int)) ;\n\t\t\t\t\t*intptr = GET_MARKER (ucptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'h' :\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;\n\t\t\t\t\t{\tint k ;\n\t\t\t\t\t\tintdata = 0 ;\n\t\t\t\t\t\tfor (k = 0 ; k < 16 ; k++)\n\t\t\t\t\t\t\tintdata ^= sixteen_bytes [k] << k ;\n\t\t\t\t\t\t}\n\t\t\t\t\t*intptr = intdata ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '1' :\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\t*charptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, charptr, sizeof (char)) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '2' : \/* 2 byte value with the current endian-ness *\/\n\t\t\t\t\tshortptr = va_arg (argptr, unsigned short*) ;\n\t\t\t\t\t*shortptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) shortptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (short)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*shortptr = GET_BE_SHORT (ucptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*shortptr = GET_LE_SHORT (ucptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '3' : \/* 3 byte value with the current endian-ness *\/\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, 3) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*intptr = GET_BE_3BYTE (sixteen_bytes) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*intptr = GET_LE_3BYTE (sixteen_bytes) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '4' : \/* 4 byte value with the current endian-ness *\/\n\t\t\t\t\tintptr = va_arg (argptr, unsigned int*) ;\n\t\t\t\t\t*intptr = 0 ;\n\t\t\t\t\tucptr = (unsigned char*) intptr ;\n\t\t\t\t\tbyte_count += header_read (psf, ucptr, sizeof (int)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*intptr = psf_get_be32 (ucptr, 0) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*intptr = psf_get_le32 (ucptr, 0) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase '8' : \/* 8 byte value with the current endian-ness *\/\n\t\t\t\t\tcountptr = va_arg (argptr, sf_count_t *) ;\n\t\t\t\t\t*countptr = 0 ;\n\t\t\t\t\tbyte_count += header_read (psf, sixteen_bytes, 8) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\tcountdata = psf_get_be64 (sixteen_bytes, 0) ;\n\t\t\t\t\telse\n\t\t\t\t\t\tcountdata = psf_get_le64 (sixteen_bytes, 0) ;\n\t\t\t\t\t*countptr = countdata ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'f' : \/* Float conversion *\/\n\t\t\t\t\tfloatptr = va_arg (argptr, float *) ;\n\t\t\t\t\t*floatptr = 0.0 ;\n\t\t\t\t\tbyte_count += header_read (psf, floatptr, sizeof (float)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*floatptr = float32_be_read ((unsigned char*) floatptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*floatptr = float32_le_read ((unsigned char*) floatptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'd' : \/* double conversion *\/\n\t\t\t\t\tdoubleptr = va_arg (argptr, double *) ;\n\t\t\t\t\t*doubleptr = 0.0 ;\n\t\t\t\t\tbyte_count += header_read (psf, doubleptr, sizeof (double)) ;\n\t\t\t\t\tif (psf->rwf_endian == SF_ENDIAN_BIG)\n\t\t\t\t\t\t*doubleptr = double64_be_read ((unsigned char*) doubleptr) ;\n\t\t\t\t\telse\n\t\t\t\t\t\t*doubleptr = double64_le_read ((unsigned char*) doubleptr) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 's' :\n\t\t\t\t\tpsf_log_printf (psf, \"Format conversion 's' not implemented yet.\\n\") ;\n\t\t\t\t\t\/*\n\t\t\t\t\tstrptr = va_arg (argptr, char *) ;\n\t\t\t\t\tsize = strlen (strptr) + 1 ;\n\t\t\t\t\tsize += (size & 1) ;\n\t\t\t\t\tlongdata = H2LE_32 (size) ;\n\t\t\t\t\tget_int (psf, longdata) ;\n\t\t\t\t\tmemcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;\n\t\t\t\t\tpsf->header.indx += size ;\n\t\t\t\t\t*\/\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'b' : \/* Raw bytes *\/\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tmemset (charptr, 0, count) ;\n\t\t\t\t\tbyte_count += header_read (psf, charptr, count) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'G' :\n\t\t\t\t\tcharptr = va_arg (argptr, char*) ;\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\tmemset (charptr, 0, count) ;\n\n\t\t\t\t\tif (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))\n\t\t\t\t\t\treturn 0 ;\n\n\t\t\t\t\tbyte_count += header_gets (psf, charptr, count) ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'z' :\n\t\t\t\t\tpsf_log_printf (psf, \"Format conversion 'z' not implemented yet.\\n\") ;\n\t\t\t\t\t\/*\n\t\t\t\t\tsize = va_arg (argptr, size_t) ;\n\t\t\t\t\twhile (size)\n\t\t\t\t\t{\tpsf->header.ptr [psf->header.indx] = 0 ;\n\t\t\t\t\t\tpsf->header.indx ++ ;\n\t\t\t\t\t\tsize -- ;\n\t\t\t\t\t\t} ;\n\t\t\t\t\t*\/\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'p' :\t\/* Seek to position from start. *\/\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\theader_seek (psf, count, SEEK_SET) ;\n\t\t\t\t\tbyte_count = count ;\n\t\t\t\t\tbreak ;\n\n\t\t\tcase 'j' :\t\/* Seek to position from current position. *\/\n\t\t\t\t\tcount = va_arg (argptr, size_t) ;\n\t\t\t\t\theader_seek (psf, count, SEEK_CUR) ;\n\t\t\t\t\tbyte_count += count ;\n\t\t\t\t\tbreak ;\n\n\t\t\tdefault :\n\t\t\t\tpsf_log_printf (psf, \"*** Invalid format specifier `%c'\\n\", c) ;\n\t\t\t\tpsf->error = SFE_INTERNAL ;\n\t\t\t\tbreak ;\n\t\t\t} ;\n\t\t} ;\n\n\tva_end (argptr) ;\n\n\treturn byte_count ;\n} \/* psf_binheader_readf *\/","target":0,"code_token_length":1756,"total_token_length":1992,"max_tokens_setting":2048} +{"idx":324094,"func":"static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,\n\n int width, int height, int bpno, int bandno,\n\n int seg_symbols, int vert_causal_ctx_csty_symbol)\n\n{\n\n int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;\n\n\n\n for (y0 = 0; y0 < height; y0 += 4) {\n\n for (x = 0; x < width; x++) {\n\n int flags_mask = -1;\n\n if (vert_causal_ctx_csty_symbol)\n\n flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);\n\n if (y0 + 3 < height &&\n\n !((t1->flags[y0 + 1][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||\n\n (t1->flags[y0 + 2][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||\n\n (t1->flags[y0 + 3][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||\n\n (t1->flags[y0 + 4][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG) & flags_mask))) {\n\n if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL))\n\n continue;\n\n runlen = ff_mqc_decode(&t1->mqc,\n\n t1->mqc.cx_states + MQC_CX_UNI);\n\n runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc,\n\n t1->mqc.cx_states +\n\n MQC_CX_UNI);\n\n dec = 1;\n\n } else {\n\n runlen = 0;\n\n dec = 0;\n\n }\n\n\n\n for (y = y0 + runlen; y < y0 + 4 && y < height; y++) {\n\n int flags_mask = -1;\n\n if (vert_causal_ctx_csty_symbol && y == y0 + 3)\n\n flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);\n\n if (!dec) {\n\n if (!(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {\n\n dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask,\n\n bandno));\n\n }\n\n }\n\n if (dec) {\n\n int xorbit;\n\n int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y + 1][x + 1] & flags_mask,\n\n &xorbit);\n\n t1->data[y][x] = (ff_mqc_decode(&t1->mqc,\n\n t1->mqc.cx_states + ctxno) ^\n\n xorbit)\n\n ? -mask : mask;\n\n ff_jpeg2000_set_significance(t1, x, y, t1->data[y][x] < 0);\n\n }\n\n dec = 0;\n\n t1->flags[y + 1][x + 1] &= ~JPEG2000_T1_VIS;\n\n }\n\n }\n\n }\n\n if (seg_symbols) {\n\n int val;\n\n val = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);\n\n val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);\n\n val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);\n\n val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);\n\n if (val != 0xa)\n\n av_log(s->avctx, AV_LOG_ERROR,\n\n \"Segmentation symbol value incorrect\\n\");\n\n }\n\n}\n","target":0,"code_token_length":1076,"total_token_length":1312,"max_tokens_setting":2048} +{"idx":489902,"func":"static int asepcos_build_pin_apdu(sc_card_t *card, sc_apdu_t *apdu,\n\tstruct sc_pin_cmd_data *data, u8 *buf, size_t buf_len,\n\tunsigned int cmd, int is_puk)\n{\n\tint r, fileid;\n\tu8 *p = buf;\n\tsc_cardctl_asepcos_akn2fileid_t st;\n\n\tswitch (cmd) {\n\tcase SC_PIN_CMD_VERIFY:\n\t\tst.akn = data->pin_reference;\n\t\tr = asepcos_akn_to_fileid(card, &st);\n\t\tif (r != SC_SUCCESS)\n\t\t\treturn r;\n\t\tfileid = st.fileid;\n\t\t\/* the fileid of the puk is the fileid of the pin + 1 *\/\n\t\tif (is_puk != 0)\n\t\t\tfileid++;\n\t\tsc_format_apdu(card, apdu, SC_APDU_CASE_3_SHORT, 0x20, 0x02, 0x80);\n\t\t*p++ = (fileid >> 24) & 0xff;\n\t\t*p++ = (fileid >> 16) & 0xff;\n\t\t*p++ = (fileid >> 8 ) & 0xff;\n\t\t*p++ = fileid & 0xff;\n\t\tmemcpy(p, data->pin1.data, data->pin1.len);\n\t\tp += data->pin1.len;\n\t\tapdu->lc = p - buf;\n\t\tapdu->datalen = p - buf;\n\t\tapdu->data = buf;\n\t\tbreak;\n\tcase SC_PIN_CMD_CHANGE:\n\t\t\/* build the CHANGE KEY apdu. Note: the PIN file is implicitly\n\t\t * selected by its SFID *\/\n\t\t*p++ = 0x81;\n\t\t*p++ = data->pin2.len & 0xff;\n\t\tmemcpy(p, data->pin2.data, data->pin2.len);\n\t\tp += data->pin2.len;\n\t\tst.akn = data->pin_reference;\n\t\tr = asepcos_akn_to_fileid(card, &st);\n\t\tif (r != SC_SUCCESS)\n\t\t\treturn r;\n\t\tfileid = 0x80 | (st.fileid & 0x1f);\n\t\tsc_format_apdu(card, apdu, SC_APDU_CASE_3_SHORT, 0x24, 0x01, fileid);\n\t\tapdu->lc = p - buf;\n\t\tapdu->datalen = p - buf;\n\t\tapdu->data = buf;\n\t\tbreak;\n\tcase SC_PIN_CMD_UNBLOCK:\n\t\t\/* build the UNBLOCK KEY apdu. The PIN file is implicitly \n\t\t * selected by its SFID. The new PIN is provided in the\n\t\t * data field of the UNBLOCK KEY command. *\/\n\t\t*p++ = 0x81;\n\t\t*p++ = data->pin2.len & 0xff;\n\t\tmemcpy(p, data->pin2.data, data->pin2.len);\n\t\tp += data->pin2.len;\n\t\tst.akn = data->pin_reference;\n\t\tr = asepcos_akn_to_fileid(card, &st);\n\t\tif (r != SC_SUCCESS)\n\t\t\treturn r;\n\t\tfileid = 0x80 | (st.fileid & 0x1f);\n\t\tsc_format_apdu(card, apdu, SC_APDU_CASE_3_SHORT, 0x2C, 0x02, fileid);\n\t\tapdu->lc = p - buf;\n\t\tapdu->datalen = p - buf;\n\t\tapdu->data = buf;\n\t\tbreak;\n\tdefault:\n\t\treturn SC_ERROR_NOT_SUPPORTED;\n\t}\n\treturn SC_SUCCESS;\n}","target":0,"code_token_length":795,"total_token_length":1031,"max_tokens_setting":2048} +{"idx":137848,"func":"hybiReadHeader(ws_ctx_t *wsctx, int *sockRet, int *nPayload)\n{\n int ret;\n char *headerDst = wsctx->codeBufDecode + wsctx->header.nRead;\n int n = ((uint64_t)WSHLENMAX) - wsctx->header.nRead;\n\n\n ws_dbg(\"header_read to %p with len=%d\\n\", headerDst, n);\n ret = wsctx->ctxInfo.readFunc(wsctx->ctxInfo.ctxPtr, headerDst, n);\n ws_dbg(\"read %d bytes from socket\\n\", ret);\n if (ret <= 0) {\n if (-1 == ret) {\n \/* save errno because rfbErr() will tamper it *\/\n int olderrno = errno;\n rfbErr(\"%s: read; %s\\n\", __func__, strerror(errno));\n errno = olderrno;\n goto err_cleanup_state;\n } else {\n *sockRet = 0;\n goto err_cleanup_state_sock_closed;\n }\n }\n\n wsctx->header.nRead += ret;\n if (wsctx->header.nRead < 2) {\n \/* cannot decode header with less than two bytes *\/\n goto ret_header_pending;\n }\n\n \/* first two header bytes received; interpret header data and get rest *\/\n wsctx->header.data = (ws_header_t *)wsctx->codeBufDecode;\n\n wsctx->header.opcode = wsctx->header.data->b0 & 0x0f;\n wsctx->header.fin = (wsctx->header.data->b0 & 0x80) >> 7;\n if (isControlFrame(wsctx)) {\n ws_dbg(\"is control frame\\n\");\n \/* is a control frame, leave remembered continuation opcode unchanged;\n * just check if there is a wrong fragmentation *\/\n if (wsctx->header.fin == 0) {\n\n \/* we only accept text\/binary continuation frames; RFC6455:\n * Control frames (see Section 5.5) MAY be injected in the middle of\n * a fragmented message. Control frames themselves MUST NOT be\n * fragmented. *\/\n rfbErr(\"control frame with FIN bit cleared received, aborting\\n\");\n errno = EPROTO;\n goto err_cleanup_state;\n }\n } else {\n ws_dbg(\"not a control frame\\n\");\n \/* not a control frame, check for continuation opcode *\/\n if (wsctx->header.opcode == WS_OPCODE_CONTINUATION) {\n ws_dbg(\"cont_frame\\n\");\n \/* do we have state (i.e., opcode) for continuation frame? *\/\n if (wsctx->continuation_opcode == WS_OPCODE_INVALID) {\n rfbErr(\"no continuation state\\n\");\n errno = EPROTO;\n goto err_cleanup_state;\n }\n\n \/* otherwise, set opcode = continuation_opcode *\/\n wsctx->header.opcode = wsctx->continuation_opcode;\n ws_dbg(\"set opcode to continuation_opcode: %d\\n\", wsctx->header.opcode);\n } else {\n if (wsctx->header.fin == 0) {\n wsctx->continuation_opcode = wsctx->header.opcode;\n } else {\n wsctx->continuation_opcode = WS_OPCODE_INVALID;\n }\n ws_dbg(\"set continuation_opcode to %d\\n\", wsctx->continuation_opcode);\n }\n }\n\n wsctx->header.payloadLen = (uint64_t)(wsctx->header.data->b1 & 0x7f);\n ws_dbg(\"first header bytes received; opcode=%d lenbyte=%d fin=%d\\n\", wsctx->header.opcode, wsctx->header.payloadLen, wsctx->header.fin);\n\n \/*\n * 4.3. Client-to-Server Masking\n *\n * The client MUST mask all frames sent to the server. A server MUST\n * close the connection upon receiving a frame with the MASK bit set to 0.\n **\/\n if (!(wsctx->header.data->b1 & 0x80)) {\n rfbErr(\"%s: got frame without mask; ret=%d\\n\", __func__, ret);\n errno = EPROTO;\n goto err_cleanup_state;\n }\n\n\n if (wsctx->header.payloadLen < 126 && wsctx->header.nRead >= 6) {\n wsctx->header.headerLen = WS_HYBI_HEADER_LEN_SHORT;\n wsctx->header.mask = wsctx->header.data->u.m;\n } else if (wsctx->header.payloadLen == 126 && 8 <= wsctx->header.nRead) {\n wsctx->header.headerLen = WS_HYBI_HEADER_LEN_EXTENDED;\n wsctx->header.payloadLen = WS_NTOH16(wsctx->header.data->u.s16.l16);\n wsctx->header.mask = wsctx->header.data->u.s16.m16;\n } else if (wsctx->header.payloadLen == 127 && 14 <= wsctx->header.nRead) {\n wsctx->header.headerLen = WS_HYBI_HEADER_LEN_LONG;\n wsctx->header.payloadLen = WS_NTOH64(wsctx->header.data->u.s64.l64);\n wsctx->header.mask = wsctx->header.data->u.s64.m64;\n } else {\n \/* Incomplete frame header, try again *\/\n rfbErr(\"%s: incomplete frame header; ret=%d\\n\", __func__, ret);\n goto ret_header_pending;\n }\n\n char *h = wsctx->codeBufDecode;\n int i;\n ws_dbg(\"Header:\\n\");\n for (i=0; i <10; i++) {\n ws_dbg(\"0x%02X\\n\", (unsigned char)h[i]);\n }\n ws_dbg(\"\\n\");\n\n \/* while RFC 6455 mandates that lengths MUST be encoded with the minimum\n * number of bytes, it does not specify for the server how to react on\n * 'wrongly' encoded frames --- this implementation rejects them*\/\n if ((wsctx->header.headerLen > WS_HYBI_HEADER_LEN_SHORT\n && wsctx->header.payloadLen < (uint64_t)126)\n || (wsctx->header.headerLen > WS_HYBI_HEADER_LEN_EXTENDED\n && wsctx->header.payloadLen < (uint64_t)65536)) {\n rfbErr(\"%s: invalid length field; headerLen=%d payloadLen=%llu\\n\", __func__, wsctx->header.headerLen, wsctx->header.payloadLen);\n errno = EPROTO;\n goto err_cleanup_state;\n }\n\n \/* update write position for next bytes *\/\n wsctx->writePos = wsctx->codeBufDecode + wsctx->header.nRead;\n\n \/* set payload pointer just after header *\/\n wsctx->readPos = (unsigned char *)(wsctx->codeBufDecode + wsctx->header.headerLen);\n\n *nPayload = wsctx->header.nRead - wsctx->header.headerLen;\n wsctx->nReadPayload = *nPayload;\n\n ws_dbg(\"header complete: state=%d headerlen=%d payloadlen=%llu writeTo=%p nPayload=%d\\n\", wsctx->hybiDecodeState, wsctx->header.headerLen, wsctx->header.payloadLen, wsctx->writePos, *nPayload);\n\n return WS_HYBI_STATE_DATA_NEEDED;\n\nret_header_pending:\n errno = EAGAIN;\n *sockRet = -1;\n return WS_HYBI_STATE_HEADER_PENDING;\n\nerr_cleanup_state:\n *sockRet = -1;\nerr_cleanup_state_sock_closed:\n hybiDecodeCleanupComplete(wsctx);\n return WS_HYBI_STATE_ERR;\n}","target":0,"code_token_length":1660,"total_token_length":1896,"max_tokens_setting":2048} +{"idx":109570,"func":"static int create_uaxx_quirk(struct snd_usb_audio *chip,\n\t\t\t struct usb_interface *iface,\n\t\t\t struct usb_driver *driver,\n\t\t\t const struct snd_usb_audio_quirk *quirk)\n{\n\tstatic const struct audioformat ua_format = {\n\t\t.formats = SNDRV_PCM_FMTBIT_S24_3LE,\n\t\t.channels = 2,\n\t\t.fmt_type = UAC_FORMAT_TYPE_I,\n\t\t.altsetting = 1,\n\t\t.altset_idx = 1,\n\t\t.rates = SNDRV_PCM_RATE_CONTINUOUS,\n\t};\n\tstruct usb_host_interface *alts;\n\tstruct usb_interface_descriptor *altsd;\n\tstruct audioformat *fp;\n\tint stream, err;\n\n\t\/* both PCM and MIDI interfaces have 2 or more altsettings *\/\n\tif (iface->num_altsetting < 2)\n\t\treturn -ENXIO;\n\talts = &iface->altsetting[1];\n\taltsd = get_iface_desc(alts);\n\n\tif (altsd->bNumEndpoints == 2) {\n\t\tstatic const struct snd_usb_midi_endpoint_info ua700_ep = {\n\t\t\t.out_cables = 0x0003,\n\t\t\t.in_cables = 0x0003\n\t\t};\n\t\tstatic const struct snd_usb_audio_quirk ua700_quirk = {\n\t\t\t.type = QUIRK_MIDI_FIXED_ENDPOINT,\n\t\t\t.data = &ua700_ep\n\t\t};\n\t\tstatic const struct snd_usb_midi_endpoint_info uaxx_ep = {\n\t\t\t.out_cables = 0x0001,\n\t\t\t.in_cables = 0x0001\n\t\t};\n\t\tstatic const struct snd_usb_audio_quirk uaxx_quirk = {\n\t\t\t.type = QUIRK_MIDI_FIXED_ENDPOINT,\n\t\t\t.data = &uaxx_ep\n\t\t};\n\t\tconst struct snd_usb_audio_quirk *quirk =\n\t\t\tchip->usb_id == USB_ID(0x0582, 0x002b)\n\t\t\t? &ua700_quirk : &uaxx_quirk;\n\t\treturn __snd_usbmidi_create(chip->card, iface,\n\t\t\t\t\t &chip->midi_list, quirk,\n\t\t\t\t\t chip->usb_id);\n\t}\n\n\tif (altsd->bNumEndpoints != 1)\n\t\treturn -ENXIO;\n\n\tfp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL);\n\tif (!fp)\n\t\treturn -ENOMEM;\n\n\tfp->iface = altsd->bInterfaceNumber;\n\tfp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;\n\tfp->ep_attr = get_endpoint(alts, 0)->bmAttributes;\n\tfp->datainterval = 0;\n\tfp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);\n\n\tswitch (fp->maxpacksize) {\n\tcase 0x120:\n\t\tfp->rate_max = fp->rate_min = 44100;\n\t\tbreak;\n\tcase 0x138:\n\tcase 0x140:\n\t\tfp->rate_max = fp->rate_min = 48000;\n\t\tbreak;\n\tcase 0x258:\n\tcase 0x260:\n\t\tfp->rate_max = fp->rate_min = 96000;\n\t\tbreak;\n\tdefault:\n\t\tusb_audio_err(chip, \"unknown sample rate\\n\");\n\t\tkfree(fp);\n\t\treturn -ENXIO;\n\t}\n\n\tstream = (fp->endpoint & USB_DIR_IN)\n\t\t? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;\n\terr = snd_usb_add_audio_stream(chip, stream, fp);\n\tif (err < 0) {\n\t\tkfree(fp);\n\t\treturn err;\n\t}\n\tusb_set_interface(chip->dev, fp->iface, 0);\n\treturn 0;\n}","target":0,"code_token_length":820,"total_token_length":1056,"max_tokens_setting":2048} +{"idx":92507,"func":"njs_generate_try_left(njs_vm_t *vm, njs_generator_t *generator,\n njs_parser_node_t *node)\n{\n njs_int_t ret;\n njs_index_t exit_index, catch_index;\n njs_jump_off_t try_end_offset;\n njs_variable_t *var;\n njs_vmcode_catch_t *catch;\n njs_vmcode_try_end_t *try_end;\n njs_generator_block_t *try_block;\n njs_generator_try_ctx_t *ctx;\n njs_vmcode_try_trampoline_t *try_break, *try_continue;\n\n ctx = generator->context;\n\n try_block = ctx->try_block;\n exit_index = try_block->index;\n\n njs_generate_code(generator, njs_vmcode_try_end_t, try_end,\n NJS_VMCODE_TRY_END, 0, NULL);\n try_end_offset = njs_code_offset(generator, try_end);\n\n if (try_block->exit != NULL) {\n ctx->try_exit_label = try_block->exit->label;\n\n njs_debug_generator(vm, \"TRY CTX %p EXIT LABEL %V\", ctx,\n &ctx->try_exit_label);\n\n njs_generate_patch_block(vm, generator, try_block,\n NJS_GENERATOR_EXIT);\n\n njs_generate_code(generator, njs_vmcode_try_trampoline_t, try_break,\n NJS_VMCODE_TRY_BREAK, 1, NULL);\n try_break->exit_value = exit_index;\n\n try_break->offset = -sizeof(njs_vmcode_try_end_t);\n\n } else {\n try_break = NULL;\n }\n\n if (try_block->continuation != NULL) {\n ctx->try_cont_label = try_block->continuation->label;\n\n njs_generate_patch_block(vm, generator, try_block,\n NJS_GENERATOR_CONTINUATION);\n\n njs_generate_code(generator, njs_vmcode_try_trampoline_t, try_continue,\n NJS_VMCODE_TRY_CONTINUE, 1, NULL);\n try_continue->exit_value = exit_index;\n\n try_continue->offset = -sizeof(njs_vmcode_try_end_t);\n\n if (try_break != NULL) {\n try_continue->offset -= sizeof(njs_vmcode_try_trampoline_t);\n }\n }\n\n njs_debug_generator(vm, \"EXIT %s %p\",\n njs_block_type(generator->block->type),\n generator->block);\n\n generator->block = try_block->next;\n\n njs_code_set_jump_offset(generator, njs_vmcode_try_start_t,\n ctx->try_offset);\n ctx->try_offset = try_end_offset;\n\n node = node->right;\n\n if (node->token_type == NJS_TOKEN_CATCH) {\n \/* A \"try\/catch\" case. *\/\n\n var = njs_variable_reference(vm, node->left);\n if (njs_slow_path(var == NULL)) {\n return NJS_ERROR;\n }\n\n catch_index = node->left->index;\n\n njs_generate_code_catch(generator, catch, catch_index, node);\n\n njs_generator_next(generator, njs_generate, node->right);\n\n return njs_generator_after(vm, generator,\n njs_queue_first(&generator->stack), node,\n njs_generate_try_catch, ctx, 0);\n }\n\n if (node->left != NULL) {\n \/* A try\/catch\/finally case. *\/\n\n var = njs_variable_reference(vm, node->left->left);\n if (njs_slow_path(var == NULL)) {\n return NJS_ERROR;\n }\n\n catch_index = node->left->left->index;\n\n njs_generate_code_catch(generator, catch, catch_index, node);\n ctx->catch_offset = njs_code_offset(generator, catch);\n\n ret = njs_generate_start_block(vm, generator, NJS_GENERATOR_TRY,\n &no_label);\n if (njs_slow_path(ret != NJS_OK)) {\n return ret;\n }\n\n ctx->catch_block = generator->block;\n ctx->catch_block->index = exit_index;\n\n njs_generator_next(generator, njs_generate, node->left->right);\n\n return njs_generator_after(vm, generator,\n njs_queue_first(&generator->stack), node,\n njs_generate_try_finally, ctx, 0);\n }\n\n \/* A try\/finally case. *\/\n\n njs_generate_code_catch(generator, catch, ctx->exception_index, NULL);\n\n ctx->catch_block = NULL;\n\n njs_code_set_jump_offset(generator, njs_vmcode_try_end_t,\n ctx->try_offset);\n\n njs_generator_next(generator, njs_generate, node->right);\n\n return njs_generator_after(vm, generator,\n njs_queue_first(&generator->stack), node,\n njs_generate_try_end, ctx, 0);\n}","target":0,"code_token_length":1026,"total_token_length":1262,"max_tokens_setting":2048} +{"idx":289081,"func":"static struct remote_lock * lock_remote ( const char * path , long timeout ) {\n struct active_request_slot * slot ;\n struct slot_results results ;\n struct buffer out_buffer = {\n STRBUF_INIT , 0 }\n ;\n struct strbuf in_buffer = STRBUF_INIT ;\n char * url ;\n char * ep ;\n char timeout_header [ 25 ] ;\n struct remote_lock * lock = NULL ;\n struct curl_slist * dav_headers = NULL ;\n struct xml_ctx ctx ;\n char * escaped ;\n url = xstrfmt ( \"%s%s\" , repo -> url , path ) ;\n ep = strchr ( url + strlen ( repo -> url ) + 1 , '\/' ) ;\n while ( ep ) {\n char saved_character = ep [ 1 ] ;\n ep [ 1 ] = '\\0' ;\n slot = get_active_slot ( ) ;\n slot -> results = & results ;\n curl_setup_http_get ( slot -> curl , url , DAV_MKCOL ) ;\n if ( start_active_slot ( slot ) ) {\n run_active_slot ( slot ) ;\n if ( results . curl_result != CURLE_OK && results . http_code != 405 ) {\n fprintf ( stderr , \"Unable to create branch path %s\\n\" , url ) ;\n free ( url ) ;\n return NULL ;\n }\n }\n else {\n fprintf ( stderr , \"Unable to start MKCOL request\\n\" ) ;\n free ( url ) ;\n return NULL ;\n }\n ep [ 1 ] = saved_character ;\n ep = strchr ( ep + 1 , '\/' ) ;\n }\n escaped = xml_entities ( ident_default_email ( ) ) ;\n strbuf_addf ( & out_buffer . buf , LOCK_REQUEST , escaped ) ;\n free ( escaped ) ;\n xsnprintf ( timeout_header , sizeof ( timeout_header ) , \"Timeout: Second-%ld\" , timeout ) ;\n dav_headers = curl_slist_append ( dav_headers , timeout_header ) ;\n dav_headers = curl_slist_append ( dav_headers , \"Content-Type: text\/xml\" ) ;\n slot = get_active_slot ( ) ;\n slot -> results = & results ;\n curl_setup_http ( slot -> curl , url , DAV_LOCK , & out_buffer , fwrite_buffer ) ;\n curl_easy_setopt ( slot -> curl , CURLOPT_HTTPHEADER , dav_headers ) ;\n curl_easy_setopt ( slot -> curl , CURLOPT_FILE , & in_buffer ) ;\n lock = xcalloc ( 1 , sizeof ( * lock ) ) ;\n lock -> timeout = - 1 ;\n if ( start_active_slot ( slot ) ) {\n run_active_slot ( slot ) ;\n if ( results . curl_result == CURLE_OK ) {\n XML_Parser parser = XML_ParserCreate ( NULL ) ;\n enum XML_Status result ;\n ctx . name = xcalloc ( 10 , 1 ) ;\n ctx . len = 0 ;\n ctx . cdata = NULL ;\n ctx . userFunc = handle_new_lock_ctx ;\n ctx . userData = lock ;\n XML_SetUserData ( parser , & ctx ) ;\n XML_SetElementHandler ( parser , xml_start_tag , xml_end_tag ) ;\n XML_SetCharacterDataHandler ( parser , xml_cdata ) ;\n result = XML_Parse ( parser , in_buffer . buf , in_buffer . len , 1 ) ;\n free ( ctx . name ) ;\n if ( result != XML_STATUS_OK ) {\n fprintf ( stderr , \"XML error: %s\\n\" , XML_ErrorString ( XML_GetErrorCode ( parser ) ) ) ;\n lock -> timeout = - 1 ;\n }\n XML_ParserFree ( parser ) ;\n }\n }\n else {\n fprintf ( stderr , \"Unable to start LOCK request\\n\" ) ;\n }\n curl_slist_free_all ( dav_headers ) ;\n strbuf_release ( & out_buffer . buf ) ;\n strbuf_release ( & in_buffer ) ;\n if ( lock -> token == NULL || lock -> timeout <= 0 ) {\n free ( lock -> token ) ;\n free ( lock -> owner ) ;\n free ( url ) ;\n free ( lock ) ;\n lock = NULL ;\n }\n else {\n lock -> url = url ;\n lock -> start_time = time ( NULL ) ;\n lock -> next = repo -> locks ;\n repo -> locks = lock ;\n }\n return lock ;\n }","target":0,"code_token_length":834,"total_token_length":1070,"max_tokens_setting":2048} +{"idx":496303,"func":"static bool ad_convert_xattr(vfs_handle_struct *handle,\n\t\t\t struct adouble *ad,\n\t\t\t const struct smb_filename *smb_fname,\n\t\t\t const char *catia_mappings,\n\t\t\t bool *converted_xattr)\n{\n\tstatic struct char_mappings **string_replace_cmaps = NULL;\n\tuint16_t i;\n\tint saved_errno = 0;\n\tNTSTATUS status;\n\tint rc;\n\tbool ok;\n\n\t*converted_xattr = false;\n\n\tif (ad_getentrylen(ad, ADEID_FINDERI) == ADEDLEN_FINDERI) {\n\t\treturn true;\n\t}\n\n\tif (string_replace_cmaps == NULL) {\n\t\tconst char **mappings = NULL;\n\n\t\tmappings = str_list_make_v3_const(\n\t\t\ttalloc_tos(), catia_mappings, NULL);\n\t\tif (mappings == NULL) {\n\t\t\treturn false;\n\t\t}\n\t\tstring_replace_cmaps = string_replace_init_map(\n\t\t\thandle->conn->sconn, mappings);\n\t\tTALLOC_FREE(mappings);\n\t}\n\n\tfor (i = 0; i < ad->adx_header.adx_num_attrs; i++) {\n\t\tstruct ad_xattr_entry *e = &ad->adx_entries[i];\n\t\tchar *mapped_name = NULL;\n\t\tchar *tmp = NULL;\n\t\tstruct smb_filename *stream_name = NULL;\n\t\tfiles_struct *fsp = NULL;\n\t\tssize_t nwritten;\n\n\t\tstatus = string_replace_allocate(handle->conn,\n\t\t\t\t\t\t e->adx_name,\n\t\t\t\t\t\t string_replace_cmaps,\n\t\t\t\t\t\t talloc_tos(),\n\t\t\t\t\t\t &mapped_name,\n\t\t\t\t\t\t vfs_translate_to_windows);\n\t\tif (!NT_STATUS_IS_OK(status) &&\n\t\t !NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED))\n\t\t{\n\t\t\tDBG_ERR(\"string_replace_allocate failed\\n\");\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\ttmp = mapped_name;\n\t\tmapped_name = talloc_asprintf(talloc_tos(), \":%s\", tmp);\n\t\tTALLOC_FREE(tmp);\n\t\tif (mapped_name == NULL) {\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tstream_name = synthetic_smb_fname(talloc_tos(),\n\t\t\t\t\t\t smb_fname->base_name,\n\t\t\t\t\t\t mapped_name,\n\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t smb_fname->twrp,\n\t\t\t\t\t\t smb_fname->flags);\n\t\tTALLOC_FREE(mapped_name);\n\t\tif (stream_name == NULL) {\n\t\t\tDBG_ERR(\"synthetic_smb_fname failed\\n\");\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tDBG_DEBUG(\"stream_name: %s\\n\", smb_fname_str_dbg(stream_name));\n\n\t\trc = vfs_stat(handle->conn, stream_name);\n\t\tif (rc == -1 && errno != ENOENT) {\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tstatus = openat_pathref_fsp(handle->conn->cwd_fsp, stream_name);\n\t\tif (!NT_STATUS_IS_OK(status) &&\n\t\t !NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND))\n\t\t{\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tstatus = SMB_VFS_CREATE_FILE(\n\t\t\thandle->conn,\t\t\t\/* conn *\/\n\t\t\tNULL,\t\t\t\t\/* req *\/\n\t\t\tstream_name,\t\t\t\/* fname *\/\n\t\t\tFILE_GENERIC_WRITE,\t\t\/* access_mask *\/\n\t\t\tFILE_SHARE_READ | FILE_SHARE_WRITE, \/* share_access *\/\n\t\t\tFILE_OPEN_IF,\t\t\t\/* create_disposition *\/\n\t\t\t0,\t\t\t\t\/* create_options *\/\n\t\t\t0,\t\t\t\t\/* file_attributes *\/\n\t\t\tINTERNAL_OPEN_ONLY,\t\t\/* oplock_request *\/\n\t\t\tNULL,\t\t\t\t\/* lease *\/\n\t\t\t0,\t\t\t\t\/* allocation_size *\/\n\t\t\t0,\t\t\t\t\/* private_flags *\/\n\t\t\tNULL,\t\t\t\t\/* sd *\/\n\t\t\tNULL,\t\t\t\t\/* ea_list *\/\n\t\t\t&fsp,\t\t\t\t\/* result *\/\n\t\t\tNULL,\t\t\t\t\/* psbuf *\/\n\t\t\tNULL, NULL);\t\t\t\/* create context *\/\n\t\tTALLOC_FREE(stream_name);\n\t\tif (!NT_STATUS_IS_OK(status)) {\n\t\t\tDBG_ERR(\"SMB_VFS_CREATE_FILE failed\\n\");\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tnwritten = SMB_VFS_PWRITE(fsp,\n\t\t\t\t\t ad->ad_data + e->adx_offset,\n\t\t\t\t\t e->adx_length,\n\t\t\t\t\t 0);\n\t\tif (nwritten == -1) {\n\t\t\tDBG_ERR(\"SMB_VFS_PWRITE failed\\n\");\n\t\t\tsaved_errno = errno;\n\t\t\tclose_file(NULL, fsp, ERROR_CLOSE);\n\t\t\terrno = saved_errno;\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tstatus = close_file(NULL, fsp, NORMAL_CLOSE);\n\t\tif (!NT_STATUS_IS_OK(status)) {\n\t\t\tok = false;\n\t\t\tgoto fail;\n\t\t}\n\t\tfsp = NULL;\n\t}\n\n\tad->adx_header.adx_num_attrs = 0;\n\tTALLOC_FREE(ad->adx_entries);\n\n\tad_setentrylen(ad, ADEID_FINDERI, ADEDLEN_FINDERI);\n\n\trc = ad_fset(handle, ad, ad->ad_fsp);\n\tif (rc != 0) {\n\t\tDBG_ERR(\"ad_fset on [%s] failed: %s\\n\",\n\t\t\tfsp_str_dbg(ad->ad_fsp), strerror(errno));\n\t\tok = false;\n\t\tgoto fail;\n\t}\n\n\tok = ad_convert_move_reso(handle, ad, smb_fname);\n\tif (!ok) {\n\t\tgoto fail;\n\t}\n\n\t*converted_xattr = true;\n\tok = true;\n\nfail:\n\treturn ok;\n}","target":0,"code_token_length":1126,"total_token_length":1362,"max_tokens_setting":2048} +{"idx":72988,"func":"static OPJ_BOOL opj_tcd_mct_decode(opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager)\n{\n opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;\n opj_tcp_t * l_tcp = p_tcd->tcp;\n opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;\n OPJ_UINT32 l_samples, i;\n\n if (! l_tcp->mct) {\n return OPJ_TRUE;\n }\n\n l_samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) *\n (l_tile_comp->y1 - l_tile_comp->y0));\n\n if (l_tile->numcomps >= 3) {\n \/* testcase 1336.pdf.asan.47.376 *\/\n if ((l_tile->comps[0].x1 - l_tile->comps[0].x0) * (l_tile->comps[0].y1 -\n l_tile->comps[0].y0) < (OPJ_INT32)l_samples ||\n (l_tile->comps[1].x1 - l_tile->comps[1].x0) * (l_tile->comps[1].y1 -\n l_tile->comps[1].y0) < (OPJ_INT32)l_samples ||\n (l_tile->comps[2].x1 - l_tile->comps[2].x0) * (l_tile->comps[2].y1 -\n l_tile->comps[2].y0) < (OPJ_INT32)l_samples) {\n opj_event_msg(p_manager, EVT_ERROR,\n \"Tiles don't all have the same dimension. Skip the MCT step.\\n\");\n return OPJ_FALSE;\n } else if (l_tcp->mct == 2) {\n OPJ_BYTE ** l_data;\n\n if (! l_tcp->m_mct_decoding_matrix) {\n return OPJ_TRUE;\n }\n\n l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps * sizeof(OPJ_BYTE*));\n if (! l_data) {\n return OPJ_FALSE;\n }\n\n for (i = 0; i < l_tile->numcomps; ++i) {\n l_data[i] = (OPJ_BYTE*) l_tile_comp->data;\n ++l_tile_comp;\n }\n\n if (! opj_mct_decode_custom(\/* MCT data *\/\n (OPJ_BYTE*) l_tcp->m_mct_decoding_matrix,\n \/* size of components *\/\n l_samples,\n \/* components *\/\n l_data,\n \/* nb of components (i.e. size of pData) *\/\n l_tile->numcomps,\n \/* tells if the data is signed *\/\n p_tcd->image->comps->sgnd)) {\n opj_free(l_data);\n return OPJ_FALSE;\n }\n\n opj_free(l_data);\n } else {\n if (l_tcp->tccps->qmfbid == 1) {\n opj_mct_decode(l_tile->comps[0].data,\n l_tile->comps[1].data,\n l_tile->comps[2].data,\n l_samples);\n } else {\n opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].data,\n (OPJ_FLOAT32*)l_tile->comps[1].data,\n (OPJ_FLOAT32*)l_tile->comps[2].data,\n l_samples);\n }\n }\n } else {\n opj_event_msg(p_manager, EVT_ERROR,\n \"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\\n\",\n l_tile->numcomps);\n }\n\n return OPJ_TRUE;\n}","target":0,"code_token_length":845,"total_token_length":1081,"max_tokens_setting":2048} +{"idx":361559,"func":"static connection_struct *switch_message(uint8 type, struct smb_request *req, int size)\n{\n\tint flags;\n\tuint16 session_tag;\n\tconnection_struct *conn = NULL;\n\tstruct smbd_server_connection *sconn = smbd_server_conn;\n\n\terrno = 0;\n\n\t\/* Make sure this is an SMB packet. smb_size contains NetBIOS header\n\t * so subtract 4 from it. *\/\n\tif (!valid_smb_header(req->inbuf)\n\t || (size < (smb_size - 4))) {\n\t\tDEBUG(2,(\"Non-SMB packet of length %d. Terminating server\\n\",\n\t\t\t smb_len(req->inbuf)));\n\t\texit_server_cleanly(\"Non-SMB packet\");\n\t}\n\n\tif (smb_messages[type].fn == NULL) {\n\t\tDEBUG(0,(\"Unknown message type %d!\\n\",type));\n\t\tsmb_dump(\"Unknown\", 1, (char *)req->inbuf, size);\n\t\treply_unknown_new(req, type);\n\t\treturn NULL;\n\t}\n\n\tflags = smb_messages[type].flags;\n\n\t\/* In share mode security we must ignore the vuid. *\/\n\tsession_tag = (lp_security() == SEC_SHARE)\n\t\t? UID_FIELD_INVALID : req->vuid;\n\tconn = req->conn;\n\n\tDEBUG(3,(\"switch message %s (pid %d) conn 0x%lx\\n\", smb_fn_name(type),\n\t\t (int)sys_getpid(), (unsigned long)conn));\n\n\tsmb_dump(smb_fn_name(type), 1, (char *)req->inbuf, size);\n\n\t\/* Ensure this value is replaced in the incoming packet. *\/\n\tSSVAL(req->inbuf,smb_uid,session_tag);\n\n\t\/*\n\t * Ensure the correct username is in current_user_info. This is a\n\t * really ugly bugfix for problems with multiple session_setup_and_X's\n\t * being done and allowing %U and %G substitutions to work correctly.\n\t * There is a reason this code is done here, don't move it unless you\n\t * know what you're doing... :-).\n\t * JRA.\n\t *\/\n\n\tif (session_tag != sconn->smb1.sessions.last_session_tag) {\n\t\tuser_struct *vuser = NULL;\n\n\t\tsconn->smb1.sessions.last_session_tag = session_tag;\n\t\tif(session_tag != UID_FIELD_INVALID) {\n\t\t\tvuser = get_valid_user_struct(sconn, session_tag);\n\t\t\tif (vuser) {\n\t\t\t\tset_current_user_info(\n\t\t\t\t\tvuser->server_info->sanitized_username,\n\t\t\t\t\tvuser->server_info->unix_name,\n\t\t\t\t\tpdb_get_domain(vuser->server_info\n\t\t\t\t\t\t ->sam_account));\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Does this call need to be run as the connected user? *\/\n\tif (flags & AS_USER) {\n\n\t\t\/* Does this call need a valid tree connection? *\/\n\t\tif (!conn) {\n\t\t\t\/*\n\t\t\t * Amazingly, the error code depends on the command\n\t\t\t * (from Samba4).\n\t\t\t *\/\n\t\t\tif (type == SMBntcreateX) {\n\t\t\t\treply_nterror(req, NT_STATUS_INVALID_HANDLE);\n\t\t\t} else {\n\t\t\t\treply_nterror(req, NT_STATUS_NETWORK_NAME_DELETED);\n\t\t\t}\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (!change_to_user(conn,session_tag)) {\n\t\t\tDEBUG(0, (\"Error: Could not change to user. Removing \"\n\t\t\t \"deferred open, mid=%d.\\n\", req->mid));\n\t\t\treply_force_doserror(req, ERRSRV, ERRbaduid);\n\t\t\treturn conn;\n\t\t}\n\n\t\t\/* All NEED_WRITE and CAN_IPC flags must also have AS_USER. *\/\n\n\t\t\/* Does it need write permission? *\/\n\t\tif ((flags & NEED_WRITE) && !CAN_WRITE(conn)) {\n\t\t\treply_nterror(req, NT_STATUS_MEDIA_WRITE_PROTECTED);\n\t\t\treturn conn;\n\t\t}\n\n\t\t\/* IPC services are limited *\/\n\t\tif (IS_IPC(conn) && !(flags & CAN_IPC)) {\n\t\t\treply_nterror(req, NT_STATUS_ACCESS_DENIED);\n\t\t\treturn conn;\n\t\t}\n\t} else {\n\t\t\/* This call needs to be run as root *\/\n\t\tchange_to_root_user();\n\t}\n\n\t\/* load service specific parameters *\/\n\tif (conn) {\n\t\tif (req->encrypted) {\n\t\t\tconn->encrypted_tid = true;\n\t\t\t\/* encrypted required from now on. *\/\n\t\t\tconn->encrypt_level = Required;\n\t\t} else if (ENCRYPTION_REQUIRED(conn)) {\n\t\t\tif (req->cmd != SMBtrans2 && req->cmd != SMBtranss2) {\n\t\t\t\texit_server_cleanly(\"encryption required \"\n\t\t\t\t\t\"on connection\");\n\t\t\t\treturn conn;\n\t\t\t}\n\t\t}\n\n\t\tif (!set_current_service(conn,SVAL(req->inbuf,smb_flg),\n\t\t\t\t\t (flags & (AS_USER|DO_CHDIR)\n\t\t\t\t\t ?True:False))) {\n\t\t\treply_nterror(req, NT_STATUS_ACCESS_DENIED);\n\t\t\treturn conn;\n\t\t}\n\t\tconn->num_smb_operations++;\n\t}\n\n\t\/* does this protocol need to be run as guest? *\/\n\tif ((flags & AS_GUEST)\n\t && (!change_to_guest() ||\n\t\t!check_access(smbd_server_fd(), lp_hostsallow(-1),\n\t\t\t lp_hostsdeny(-1)))) {\n\t\treply_nterror(req, NT_STATUS_ACCESS_DENIED);\n\t\treturn conn;\n\t}\n\n\tsmb_messages[type].fn(req);\n\treturn req->conn;\n}","target":0,"code_token_length":1132,"total_token_length":1368,"max_tokens_setting":2048} +{"idx":298237,"func":"void sctp_assoc_update(struct sctp_association *asoc,\n\t\t struct sctp_association *new)\n{\n\tstruct sctp_transport *trans;\n\tstruct list_head *pos, *temp;\n\n\t\/* Copy in new parameters of peer. *\/\n\tasoc->c = new->c;\n\tasoc->peer.rwnd = new->peer.rwnd;\n\tasoc->peer.sack_needed = new->peer.sack_needed;\n\tasoc->peer.auth_capable = new->peer.auth_capable;\n\tasoc->peer.i = new->peer.i;\n\tsctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL,\n\t\t\t asoc->peer.i.initial_tsn, GFP_ATOMIC);\n\n\t\/* Remove any peer addresses not present in the new association. *\/\n\tlist_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {\n\t\ttrans = list_entry(pos, struct sctp_transport, transports);\n\t\tif (!sctp_assoc_lookup_paddr(new, &trans->ipaddr)) {\n\t\t\tsctp_assoc_rm_peer(asoc, trans);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (asoc->state >= SCTP_STATE_ESTABLISHED)\n\t\t\tsctp_transport_reset(trans);\n\t}\n\n\t\/* If the case is A (association restart), use\n\t * initial_tsn as next_tsn. If the case is B, use\n\t * current next_tsn in case data sent to peer\n\t * has been discarded and needs retransmission.\n\t *\/\n\tif (asoc->state >= SCTP_STATE_ESTABLISHED) {\n\t\tasoc->next_tsn = new->next_tsn;\n\t\tasoc->ctsn_ack_point = new->ctsn_ack_point;\n\t\tasoc->adv_peer_ack_point = new->adv_peer_ack_point;\n\n\t\t\/* Reinitialize SSN for both local streams\n\t\t * and peer's streams.\n\t\t *\/\n\t\tsctp_ssnmap_clear(asoc->ssnmap);\n\n\t\t\/* Flush the ULP reassembly and ordered queue.\n\t\t * Any data there will now be stale and will\n\t\t * cause problems.\n\t\t *\/\n\t\tsctp_ulpq_flush(&asoc->ulpq);\n\n\t\t\/* reset the overall association error count so\n\t\t * that the restarted association doesn't get torn\n\t\t * down on the next retransmission timer.\n\t\t *\/\n\t\tasoc->overall_error_count = 0;\n\n\t} else {\n\t\t\/* Add any peer addresses from the new association. *\/\n\t\tlist_for_each_entry(trans, &new->peer.transport_addr_list,\n\t\t\t\ttransports) {\n\t\t\tif (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))\n\t\t\t\tsctp_assoc_add_peer(asoc, &trans->ipaddr,\n\t\t\t\t\t\t GFP_ATOMIC, trans->state);\n\t\t}\n\n\t\tasoc->ctsn_ack_point = asoc->next_tsn - 1;\n\t\tasoc->adv_peer_ack_point = asoc->ctsn_ack_point;\n\t\tif (!asoc->ssnmap) {\n\t\t\t\/* Move the ssnmap. *\/\n\t\t\tasoc->ssnmap = new->ssnmap;\n\t\t\tnew->ssnmap = NULL;\n\t\t}\n\n\t\tif (!asoc->assoc_id) {\n\t\t\t\/* get a new association id since we don't have one\n\t\t\t * yet.\n\t\t\t *\/\n\t\t\tsctp_assoc_set_id(asoc, GFP_ATOMIC);\n\t\t}\n\t}\n\n\t\/* SCTP-AUTH: Save the peer parameters from the new associations\n\t * and also move the association shared keys over\n\t *\/\n\tkfree(asoc->peer.peer_random);\n\tasoc->peer.peer_random = new->peer.peer_random;\n\tnew->peer.peer_random = NULL;\n\n\tkfree(asoc->peer.peer_chunks);\n\tasoc->peer.peer_chunks = new->peer.peer_chunks;\n\tnew->peer.peer_chunks = NULL;\n\n\tkfree(asoc->peer.peer_hmacs);\n\tasoc->peer.peer_hmacs = new->peer.peer_hmacs;\n\tnew->peer.peer_hmacs = NULL;\n\n\tsctp_auth_asoc_init_active_key(asoc, GFP_ATOMIC);\n}","target":0,"code_token_length":849,"total_token_length":1085,"max_tokens_setting":2048} +{"idx":447571,"func":"static cl_error_t egg_parse_archive_headers(egg_handle* handle)\n{\n cl_error_t status = CL_EPARSE;\n cl_error_t retval;\n\n egg_header* eggHeader = NULL;\n uint32_t magic = 0;\n const uint8_t* index = 0;\n\n if (!handle) {\n cli_errmsg(\"egg_parse_archive_headers: Invalid args!\\n\");\n return CL_EARG;\n }\n\n if (CL_SUCCESS != EGG_VALIDATE_HANDLE(handle)) {\n cli_errmsg(\"egg_parse_archive_headers: Invalid handle values!\\n\");\n status = CL_EARG;\n goto done;\n }\n\n \/*\n * 1st:\n * Archive headers begins with the egg_header.\n *\/\n\n index = (const uint8_t*)fmap_need_off_once(handle->map, handle->offset, sizeof(egg_header));\n if (!index) {\n cli_dbgmsg(\"egg_parse_archive_headers: File buffer too small to contain egg_header.\\n\");\n goto done;\n }\n\n eggHeader = (egg_header*)index;\n\n if (EGG_HEADER_MAGIC != le32_to_host(eggHeader->magic)) {\n cli_dbgmsg(\"egg_parse_archive_headers: Invalid egg header magic: %08x.\\n\", le32_to_host(eggHeader->magic));\n goto done;\n }\n\n cli_dbgmsg(\"egg_parse_archive_headers: egg_header->magic: %08x (%s)\\n\", le32_to_host(eggHeader->magic), getMagicHeaderName(le32_to_host(eggHeader->magic)));\n cli_dbgmsg(\"egg_parse_archive_headers: egg_header->version: %04x\\n\", le16_to_host(eggHeader->version));\n cli_dbgmsg(\"egg_parse_archive_headers: egg_header->header_id: %08x\\n\", le32_to_host(eggHeader->header_id));\n cli_dbgmsg(\"egg_parse_archive_headers: egg_header->reserved: %08x\\n\", le32_to_host(eggHeader->reserved));\n\n if (EGG_HEADER_VERSION != le16_to_host(eggHeader->version)) {\n cli_dbgmsg(\"egg_parse_archive_headers: Unexpected EGG archive version #: %04x.\\n\",\n le16_to_host(eggHeader->version));\n }\n\n handle->offset += sizeof(egg_header);\n\n \/*\n * 2nd:\n * Egg Header may be followed by:\n * a) split_compression header and\/or\n * b) solid_compression\n * c) global encryption header\n * d) EOFARC\n *\/\n\n while (handle->map->len > handle->offset) {\n\n \/* Get the next magic32_t *\/\n index = (const uint8_t*)fmap_need_off_once(handle->map, handle->offset, sizeof(magic32_t));\n if (!index) {\n cli_dbgmsg(\"egg_parse_archive_headers: File buffer too small to contain end of archive magic bytes.\\n\");\n goto done;\n }\n\n magic = le32_to_host(*((uint32_t*)index));\n\n if (EOFARC == magic) {\n \/*\n * Archive headers should conclude with EOFARC magic bytes.\n *\/\n handle->offset += sizeof(magic32_t);\n\n cli_dbgmsg(\"egg_parse_archive_headers: End of archive headers.\\n\");\n break; \/* Break out of the loop *\/\n } else {\n \/*\n * Parse extra fields.\n *\/\n retval = egg_parse_archive_extra_field(handle);\n if (CL_SUCCESS != retval) {\n cli_dbgmsg(\"egg_parse_archive_headers: Failed to parse archive header, magic: %08x (%s)\\n\", magic, getMagicHeaderName(magic));\n break; \/* Break out of the loop *\/\n }\n }\n }\n\n status = CL_SUCCESS;\n\ndone:\n return status;\n}","target":0,"code_token_length":829,"total_token_length":1065,"max_tokens_setting":2048} +{"idx":6872,"func":"static int string_scan_range(RList *list, const ut8 *buf, int min,\n\t\t\t const ut64 from, const ut64 to, int type) {\n\tut8 tmp[R_STRING_SCAN_BUFFER_SIZE];\n\tut64 str_start, needle = from;\n\tint count = 0, i, rc, runes;\n\tint str_type = R_STRING_TYPE_DETECT;\n\n\tif (type == -1) {\n\t\ttype = R_STRING_TYPE_DETECT;\n\t}\n\tif (!buf || !min) {\n\t\treturn -1;\n\t}\n\twhile (needle < to) {\n\t\trc = r_utf8_decode (buf + needle, to - needle, NULL);\n\t\tif (!rc) {\n\t\t\tneedle++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (type == R_STRING_TYPE_DETECT) {\n\t\t\tchar *w = (char *)buf + needle + rc;\n\t\t\tif ((to - needle) > 4) {\n\t\t\t\tbool is_wide32 = needle + rc + 2 < to && !w[0] && !w[1] && !w[2] && w[3] && !w[4];\n\t\t\t\tif (is_wide32) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_WIDE32;\n\t\t\t\t} else {\n\t\t\t\t\tbool is_wide = needle + rc + 2 < to && !w[0] && w[1] && !w[2];\n\t\t\t\t\tstr_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr_type = R_STRING_TYPE_ASCII;\n\t\t\t}\n\t\t} else {\n\t\t\tstr_type = type;\n\t\t}\n\n\n\t\trunes = 0;\n\t\tstr_start = needle;\n\n\t\t\/* Eat a whole C string *\/\n\t\tfor (rc = i = 0; i < sizeof (tmp) - 3 && needle < to; i += rc) {\n\t\t\tRRune r = {0};\n\n\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\trc = r_utf32le_decode (buf + needle, to - needle, &r);\n\t\t\t\tif (rc) {\n\t\t\t\t\trc = 4;\n\t\t\t\t}\n\t\t\t} else if (str_type == R_STRING_TYPE_WIDE) {\n\t\t\t\trc = r_utf16le_decode (buf + needle, to - needle, &r);\n\t\t\t\tif (rc == 1) {\n\t\t\t\t\trc = 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trc = r_utf8_decode (buf + needle, to - needle, &r);\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/* Invalid sequence detected *\/\n\t\t\tif (!rc) {\n\t\t\t\tneedle++;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tneedle += rc;\n\n\t\t\tif (r_isprint (r)) {\n\t\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\t\tif (r == 0xff) {\n\t\t\t\t\t\tr = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trc = r_utf8_encode (&tmp[i], r);\n\t\t\t\trunes++;\n\t\t\t\t\/* Print the escape code *\/\n\t\t\t} else if (r && r < 0x100 && strchr (\"\\b\\v\\f\\n\\r\\t\\a\\e\", (char)r)) {\n\t\t\t\tif ((i + 32) < sizeof (tmp) && r < 28) {\n\t\t\t\t\ttmp[i + 0] = '\\\\';\n\t\t\t\t\ttmp[i + 1] = \" abtnvfr e\"[r];\n\t\t\t\t} else {\n\t\t\t\t\t\/\/ string too long\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\trc = 2;\n\t\t\t\trunes++;\n\t\t\t} else {\n\t\t\t\t\/* \\0 marks the end of C-strings *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\ttmp[i++] = '\\0';\n\n\t\tif (runes >= min) {\n\t\t\tif (str_type == R_STRING_TYPE_ASCII) {\n\t\t\t\t\/\/ reduce false positives\n\t\t\t\tint j;\n\t\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\t\tchar ch = tmp[j];\n\t\t\t\t\tif (ch != '\\n' && ch != '\\r' && ch != '\\t') {\n\t\t\t\t\t\tif (!IS_PRINTABLE (tmp[j])) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (list) {\n\t\t\t\tRBinString *new = R_NEW0 (RBinString);\n\t\t\t\tif (!new) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tnew->type = str_type;\n\t\t\t\tnew->length = runes;\n\t\t\t\tnew->size = needle - str_start;\n\t\t\t\tnew->ordinal = count++;\n\t\t\t\t\/\/ TODO: move into adjust_offset\n\t\t\t\tswitch (str_type) {\n\t\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst ut8 *p = buf + str_start - 2;\n\t\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\t\tstr_start -= 2; \/\/ \\xff\\xfe\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst ut8 *p = buf + str_start - 4;\n\t\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\t\tstr_start -= 4; \/\/ \\xff\\xfe\\x00\\x00\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tnew->paddr = new->vaddr = str_start;\n\t\t\t\tnew->string = r_str_ndup ((const char *)tmp, i);\n\t\t\t\tr_list_append (list, new);\n\t\t\t} else {\n\t\t\t\t\/\/ DUMP TO STDOUT. raw dumping for rabin2 -zzz\n\t\t\t\tprintf (\"0x%08\" PFMT64x \" %s\\n\", str_start, tmp);\n\t\t\t}\n\t\t}\n\t}\n\treturn count;\n}","target":1,"code_token_length":1243,"total_token_length":1479,"max_tokens_setting":2048} +{"idx":19814,"func":"IN_PROC_BROWSER_TEST_F ( SiteDetailsBrowserTest , IsolateExtensionsHostedApps ) {\n GURL app_with_web_iframe_url = embedded_test_server ( ) -> GetURL ( \"app.org\" , \"\/cross_site_iframe_factory.html?app.org(b.com)\" ) ;\n GURL app_in_web_iframe_url = embedded_test_server ( ) -> GetURL ( \"b.com\" , \"\/cross_site_iframe_factory.html?b.com(app.org)\" ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , app_with_web_iframe_url ) ;\n scoped_refptr < TestMemoryDetails > details = new TestMemoryDetails ( ) ;\n details -> StartFetchAndWait ( ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.CurrentRendererProcessCount\" ) , HasOneSample ( GetRenderProcessCount ( ) ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateNothingProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountLowerBound\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountNoLimit\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountEstimate\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountLowerBound\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountNoLimit\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> GetOutOfProcessIframeCount ( ) , DependingOnPolicy ( 0 , 0 , 1 ) ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , app_in_web_iframe_url ) ;\n details = new TestMemoryDetails ( ) ;\n details -> StartFetchAndWait ( ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.CurrentRendererProcessCount\" ) , HasOneSample ( GetRenderProcessCount ( ) ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateNothingProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountLowerBound\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountNoLimit\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountEstimate\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountLowerBound\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountNoLimit\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> GetOutOfProcessIframeCount ( ) , DependingOnPolicy ( 0 , 0 , 1 ) ) ;\n CreateHostedApp ( \"App\" , GURL ( \"http:\/\/app.org\" ) ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , app_with_web_iframe_url ) ;\n details = new TestMemoryDetails ( ) ;\n details -> StartFetchAndWait ( ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.CurrentRendererProcessCount\" ) , HasOneSample ( GetRenderProcessCount ( ) ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateNothingProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountLowerBound\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountNoLimit\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountEstimate\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountLowerBound\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountNoLimit\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> GetOutOfProcessIframeCount ( ) , DependingOnPolicy ( 0 , 0 , 1 ) ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , app_in_web_iframe_url ) ;\n details = new TestMemoryDetails ( ) ;\n details -> StartFetchAndWait ( ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.CurrentRendererProcessCount\" ) , HasOneSample ( GetRenderProcessCount ( ) ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateNothingProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountEstimate\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountLowerBound\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateExtensionsProcessCountNoLimit\" ) , HasOneSample ( 1 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountEstimate\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountLowerBound\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( details -> uma ( ) -> GetAllSamples ( \"SiteIsolation.IsolateAllSitesProcessCountNoLimit\" ) , HasOneSample ( 2 ) ) ;\n EXPECT_THAT ( GetRenderProcessCount ( ) , DependingOnPolicy ( 1 , 1 , 2 ) ) ;\n EXPECT_THAT ( details -> GetOutOfProcessIframeCount ( ) , DependingOnPolicy ( 0 , 0 , 1 ) ) ;\n }","target":0,"code_token_length":1725,"total_token_length":1961,"max_tokens_setting":2048} +{"idx":331286,"func":"static int local_symlink(FsContext *fs_ctx, const char *oldpath,\n\n V9fsPath *dir_path, const char *name, FsCred *credp)\n\n{\n\n int err = -1;\n\n int serrno = 0;\n\n char *newpath;\n\n V9fsString fullname;\n\n char *buffer;\n\n\n\n v9fs_string_init(&fullname);\n\n v9fs_string_sprintf(&fullname, \"%s\/%s\", dir_path->data, name);\n\n newpath = fullname.data;\n\n\n\n \/* Determine the security model *\/\n\n if (fs_ctx->export_flags & V9FS_SM_MAPPED) {\n\n int fd;\n\n ssize_t oldpath_size, write_size;\n\n buffer = rpath(fs_ctx, newpath);\n\n fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);\n\n if (fd == -1) {\n\n g_free(buffer);\n\n err = fd;\n\n goto out;\n\n }\n\n \/* Write the oldpath (target) to the file. *\/\n\n oldpath_size = strlen(oldpath);\n\n do {\n\n write_size = write(fd, (void *)oldpath, oldpath_size);\n\n } while (write_size == -1 && errno == EINTR);\n\n\n\n if (write_size != oldpath_size) {\n\n serrno = errno;\n\n close(fd);\n\n err = -1;\n\n goto err_end;\n\n }\n\n close(fd);\n\n \/* Set cleint credentials in symlink's xattr *\/\n\n credp->fc_mode = credp->fc_mode|S_IFLNK;\n\n err = local_set_xattr(buffer, credp);\n\n if (err == -1) {\n\n serrno = errno;\n\n goto err_end;\n\n }\n\n } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n\n int fd;\n\n ssize_t oldpath_size, write_size;\n\n buffer = rpath(fs_ctx, newpath);\n\n fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);\n\n if (fd == -1) {\n\n g_free(buffer);\n\n err = fd;\n\n goto out;\n\n }\n\n \/* Write the oldpath (target) to the file. *\/\n\n oldpath_size = strlen(oldpath);\n\n do {\n\n write_size = write(fd, (void *)oldpath, oldpath_size);\n\n } while (write_size == -1 && errno == EINTR);\n\n\n\n if (write_size != oldpath_size) {\n\n serrno = errno;\n\n close(fd);\n\n err = -1;\n\n goto err_end;\n\n }\n\n close(fd);\n\n \/* Set cleint credentials in symlink's xattr *\/\n\n credp->fc_mode = credp->fc_mode|S_IFLNK;\n\n err = local_set_mapped_file_attr(fs_ctx, newpath, credp);\n\n if (err == -1) {\n\n serrno = errno;\n\n goto err_end;\n\n }\n\n } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||\n\n (fs_ctx->export_flags & V9FS_SM_NONE)) {\n\n buffer = rpath(fs_ctx, newpath);\n\n err = symlink(oldpath, buffer);\n\n if (err) {\n\n g_free(buffer);\n\n goto out;\n\n }\n\n err = lchown(buffer, credp->fc_uid, credp->fc_gid);\n\n if (err == -1) {\n\n \/*\n\n * If we fail to change ownership and if we are\n\n * using security model none. Ignore the error\n\n *\/\n\n if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {\n\n serrno = errno;\n\n goto err_end;\n\n } else\n\n err = 0;\n\n }\n\n }\n\n goto out;\n\n\n\nerr_end:\n\n remove(buffer);\n\n errno = serrno;\n\n g_free(buffer);\n\nout:\n\n v9fs_string_free(&fullname);\n\n return err;\n\n}\n","target":1,"code_token_length":851,"total_token_length":1087,"max_tokens_setting":2048} +{"idx":298120,"func":"static void resolve_stun_entry(pjsua_stun_resolve *sess)\n{\n pj_status_t status = PJ_EUNKNOWN;\n\n \/* Loop while we have entry to try *\/\n for (; sess->idx < sess->count;\n \t (pjsua_var.ua_cfg.stun_try_ipv6 && sess->af == pj_AF_INET())?\n\t sess->af = pj_AF_INET6(): (++sess->idx, sess->af = pj_AF_INET()))\n {\n\tint af;\n\tchar target[64];\n\tpj_str_t hostpart;\n\tpj_uint16_t port;\n\tpj_stun_sock_cb stun_sock_cb;\n\t\n\tpj_assert(sess->idx < sess->count);\n\n\tif (pjsua_var.ua_cfg.stun_try_ipv6 &&\n\t pjsua_var.stun_opt != PJSUA_NAT64_DISABLED &&\n\t sess->af == pj_AF_INET())\n\t{\n\t \/* Skip IPv4 STUN resolution if NAT64 is not disabled. *\/\n\t PJ_LOG(4,(THIS_FILE, \"Skipping IPv4 resolution of STUN server \"\n\t \t\t\t \"%s (%d of %d)\", target,\n\t \t\t\t sess->idx+1, sess->count));\t \n\t continue;\n\t}\n\n\tpj_ansi_snprintf(target, sizeof(target), \"%.*s\",\n\t\t\t (int)sess->srv[sess->idx].slen,\n\t\t\t sess->srv[sess->idx].ptr);\n\n\t\/* Parse the server entry into host:port *\/\n\tstatus = pj_sockaddr_parse2(pj_AF_UNSPEC(), 0, &sess->srv[sess->idx],\n\t\t\t\t &hostpart, &port, &af);\n\tif (status != PJ_SUCCESS) {\n \t PJ_LOG(2,(THIS_FILE, \"Invalid STUN server entry %s\", target));\n\t continue;\n\t}\n\t\n\t\/* Use default port if not specified *\/\n\tif (port == 0)\n\t port = PJ_STUN_PORT;\n\n\tpj_assert(sess->stun_sock == NULL);\n\n\tPJ_LOG(4,(THIS_FILE, \"Trying STUN server %s %s (%d of %d)..\",\n\t\t target, (sess->af == pj_AF_INET()? \"IPv4\": \"IPv6\"),\n\t\t sess->idx+1, sess->count));\n\n\t\/* Use STUN_sock to test this entry *\/\n\tpj_bzero(&stun_sock_cb, sizeof(stun_sock_cb));\n\tstun_sock_cb.on_status = &test_stun_on_status;\n\tsess->async_wait = PJ_FALSE;\n\tstatus = pj_stun_sock_create(&pjsua_var.stun_cfg, \"stunresolve\",\n\t\t\t\t sess->af, &stun_sock_cb,\n\t\t\t\t NULL, sess, &sess->stun_sock);\n\tif (status != PJ_SUCCESS) {\n\t char errmsg[PJ_ERR_MSG_SIZE];\n\t pj_strerror(status, errmsg, sizeof(errmsg));\n\t PJ_LOG(4,(THIS_FILE, \n\t\t \"Error creating STUN socket for %s: %s\",\n\t\t target, errmsg));\n\n\t continue;\n\t}\n\n\tstatus = pj_stun_sock_start(sess->stun_sock, &hostpart, port,\n\t\t\t\t pjsua_var.resolver);\n\tif (status != PJ_SUCCESS) {\n\t char errmsg[PJ_ERR_MSG_SIZE];\n\t pj_strerror(status, errmsg, sizeof(errmsg));\n\t PJ_LOG(4,(THIS_FILE, \n\t\t \"Error starting STUN socket for %s: %s\",\n\t\t target, errmsg));\n\n\t if (sess->stun_sock) {\n\t\tpj_stun_sock_destroy(sess->stun_sock);\n\t\tsess->stun_sock = NULL;\n\t }\n\t continue;\n\t}\n\n\t\/* Done for now, testing will resume\/complete asynchronously in\n\t * stun_sock_cb()\n\t *\/\n\tsess->async_wait = PJ_TRUE;\n\treturn;\n }\n\n if (sess->idx >= sess->count) {\n\t\/* No more entries to try *\/\n\tstun_resolve_add_ref(sess);\n\tpj_assert(status != PJ_SUCCESS || sess->status != PJ_EPENDING);\n if (sess->status == PJ_EPENDING)\n sess->status = status;\n\tstun_resolve_complete(sess);\n\tstun_resolve_dec_ref(sess);\n }\n}","target":0,"code_token_length":853,"total_token_length":1089,"max_tokens_setting":2048} +{"idx":277832,"func":"static Image *ReadWEBPImage(const ImageInfo *image_info,\n ExceptionInfo *exception)\n{\n Image\n *image;\n\n int\n webp_status;\n\n MagickBooleanType\n status;\n\n register unsigned char\n *p;\n\n size_t\n length;\n\n ssize_t\n count,\n y;\n\n unsigned char\n header[12],\n *stream;\n\n WebPDecoderConfig\n configure;\n\n WebPDecBuffer\n *restrict webp_image = &configure.output;\n\n WebPBitstreamFeatures\n *restrict features = &configure.input;\n\n \/*\n Open image file.\n *\/\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickSignature);\n if (image_info->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickSignature);\n image=AcquireImage(image_info);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n if (WebPInitDecoderConfig(&configure) == 0)\n ThrowReaderException(ResourceLimitError,\"UnableToDecodeImageFile\");\n webp_image->colorspace=MODE_RGBA;\n count=ReadBlob(image,12,header);\n if (count != 12)\n ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n status=IsWEBP(header,count);\n if (status == MagickFalse)\n ThrowReaderException(CorruptImageError,\"CorruptImage\");\n length=(size_t) (ReadWebPLSBWord(header+4)+8);\n if (length < 12)\n ThrowReaderException(CorruptImageError,\"CorruptImage\");\n stream=(unsigned char *) AcquireQuantumMemory(length,sizeof(*stream));\n if (stream == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n (void) memcpy(stream,header,12);\n count=ReadBlob(image,length-12,stream+12);\n if (count != (ssize_t) (length-12))\n ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n webp_status=WebPGetFeatures(stream,length,features);\n if (webp_status == VP8_STATUS_OK)\n {\n image->columns=(size_t) features->width;\n image->rows=(size_t) features->height;\n image->depth=8;\n image->matte=features->has_alpha != 0 ? MagickTrue : MagickFalse;\n if (IsWEBPImageLossless(stream,length) != MagickFalse)\n image->quality=100;\n if (image_info->ping != MagickFalse)\n {\n stream=(unsigned char*) RelinquishMagickMemory(stream);\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n }\n status=SetImageExtent(image,image->columns,image->rows);\n if (status == MagickFalse)\n {\n InheritException(exception,&image->exception);\n return(DestroyImageList(image));\n }\n webp_status=WebPDecode(stream,length,&configure);\n }\n if (webp_status != VP8_STATUS_OK)\n {\n stream=(unsigned char*) RelinquishMagickMemory(stream);\n switch (webp_status)\n {\n case VP8_STATUS_OUT_OF_MEMORY:\n {\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n break;\n }\n case VP8_STATUS_INVALID_PARAM:\n {\n ThrowReaderException(CorruptImageError,\"invalid parameter\");\n break;\n }\n case VP8_STATUS_BITSTREAM_ERROR:\n {\n ThrowReaderException(CorruptImageError,\"CorruptImage\");\n break;\n }\n case VP8_STATUS_UNSUPPORTED_FEATURE:\n {\n ThrowReaderException(CoderError,\"DataEncodingSchemeIsNotSupported\");\n break;\n }\n case VP8_STATUS_SUSPENDED:\n {\n ThrowReaderException(CorruptImageError,\"decoder suspended\");\n break;\n }\n case VP8_STATUS_USER_ABORT:\n {\n ThrowReaderException(CorruptImageError,\"user abort\");\n break;\n }\n case VP8_STATUS_NOT_ENOUGH_DATA:\n {\n ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n break;\n }\n default:\n ThrowReaderException(CorruptImageError,\"CorruptImage\");\n }\n }\n p=(unsigned char *) webp_image->u.RGBA.rgba;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n register PixelPacket\n *q;\n\n register ssize_t\n x;\n\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (PixelPacket *) NULL)\n break;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n SetPixelRed(q,ScaleCharToQuantum(*p++));\n SetPixelGreen(q,ScaleCharToQuantum(*p++));\n SetPixelBlue(q,ScaleCharToQuantum(*p++));\n SetPixelAlpha(q,ScaleCharToQuantum(*p++));\n q++;\n }\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n WebPFreeDecBuffer(webp_image);\n stream=(unsigned char*) RelinquishMagickMemory(stream);\n return(image);\n}\n","target":0,"code_token_length":1242,"total_token_length":1478,"max_tokens_setting":2048} +{"idx":37997,"func":"static int h264_decode_frame(AVCodecContext *avctx, void *data,\n int *got_frame, AVPacket *avpkt)\n{\n const uint8_t *buf = avpkt->data;\n int buf_size = avpkt->size;\n H264Context *h = avctx->priv_data;\n AVFrame *pict = data;\n int buf_index = 0;\n H264Picture *out;\n int i, out_idx;\n int ret;\n\n h->flags = avctx->flags;\n \/* reset data partitioning here, to ensure GetBitContexts from previous\n * packets do not get used. *\/\n h->data_partitioning = 0;\n\n \/* end of stream, output what is still in the buffers *\/\n if (buf_size == 0) {\n out:\n\n h->cur_pic_ptr = NULL;\n h->first_field = 0;\n\n \/\/ FIXME factorize this with the output code below\n out = h->delayed_pic[0];\n out_idx = 0;\n for (i = 1;\n h->delayed_pic[i] &&\n !h->delayed_pic[i]->f.key_frame &&\n !h->delayed_pic[i]->mmco_reset;\n i++)\n if (h->delayed_pic[i]->poc < out->poc) {\n out = h->delayed_pic[i];\n out_idx = i;\n }\n\n for (i = out_idx; h->delayed_pic[i]; i++)\n h->delayed_pic[i] = h->delayed_pic[i + 1];\n\n if (out) {\n out->reference &= ~DELAYED_PIC_REF;\n ret = output_frame(h, pict, out);\n if (ret < 0)\n return ret;\n *got_frame = 1;\n }\n\n return buf_index;\n }\n if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {\n int side_size;\n uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);\n if (is_extra(side, side_size))\n ff_h264_decode_extradata(h, side, side_size);\n }\n if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){\n if (is_extra(buf, buf_size))\n return ff_h264_decode_extradata(h, buf, buf_size);\n }\n\n buf_index = decode_nal_units(h, buf, buf_size, 0);\n if (buf_index < 0)\n return AVERROR_INVALIDDATA;\n\n if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {\n av_assert0(buf_index <= buf_size);\n goto out;\n }\n\n if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {\n if (avctx->skip_frame >= AVDISCARD_NONREF ||\n buf_size >= 4 && !memcmp(\"Q264\", buf, 4))\n return buf_size;\n av_log(avctx, AV_LOG_ERROR, \"no frame!\\n\");\n return AVERROR_INVALIDDATA;\n }\n\n if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) ||\n (h->mb_y >= h->mb_height && h->mb_height)) {\n if (avctx->flags2 & CODEC_FLAG2_CHUNKS)\n decode_postinit(h, 1);\n\n ff_h264_field_end(h, 0);\n\n \/* Wait for second field. *\/\n *got_frame = 0;\n if (h->next_output_pic && (\n h->next_output_pic->recovered)) {\n if (!h->next_output_pic->recovered)\n h->next_output_pic->f.flags |= AV_FRAME_FLAG_CORRUPT;\n\n ret = output_frame(h, pict, h->next_output_pic);\n if (ret < 0)\n return ret;\n *got_frame = 1;\n if (CONFIG_MPEGVIDEO) {\n ff_print_debug_info2(h->avctx, pict, h->er.mbskip_table,\n h->next_output_pic->mb_type,\n h->next_output_pic->qscale_table,\n h->next_output_pic->motion_val,\n &h->low_delay,\n h->mb_width, h->mb_height, h->mb_stride, 1);\n }\n }\n }\n\n assert(pict->buf[0] || !*got_frame);\n\n return get_consumed_bytes(buf_index, buf_size);\n}","target":0,"code_token_length":1043,"total_token_length":1279,"max_tokens_setting":2048} +{"idx":371706,"func":"_archive_entry_copy_file_info (struct archive_entry *entry,\n\t\t\t GFileInfo *info,\n\t\t\t SaveData *save_data)\n{\n\tint filetype;\n\tchar *username;\n\tchar *groupname;\n\tgint64 id;\n\n\tswitch (g_file_info_get_file_type (info)) {\n\tcase G_FILE_TYPE_REGULAR:\n\t\tfiletype = AE_IFREG;\n\t\tbreak;\n\tcase G_FILE_TYPE_DIRECTORY:\n\t\tfiletype = AE_IFDIR;\n\t\tbreak;\n\tcase G_FILE_TYPE_SYMBOLIC_LINK:\n\t\tfiletype = AE_IFLNK;\n\t\tbreak;\n\tdefault:\n\t\treturn FALSE;\n\t\tbreak;\n\t}\n\tarchive_entry_set_filetype (entry, filetype);\n\n\tarchive_entry_set_atime (entry,\n\t\t\t\t g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS),\n\t\t\t\t g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) * 1000);\n\tarchive_entry_set_ctime (entry,\n\t\t\t\t g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CREATED),\n\t\t\t\t g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_CREATED_USEC) * 1000);\n\tarchive_entry_set_mtime (entry,\n\t\t\t\t g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED),\n\t\t\t\t g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) * 1000);\n\tarchive_entry_unset_birthtime (entry);\n\tarchive_entry_set_dev (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_DEVICE));\n\tarchive_entry_set_gid (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID));\n\tarchive_entry_set_uid (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID));\n\tarchive_entry_set_ino64 (entry, g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE));\n\tarchive_entry_set_mode (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE));\n\tarchive_entry_set_nlink (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_NLINK));\n\tarchive_entry_set_rdev (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_RDEV));\n\tarchive_entry_set_size (entry, g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE));\n\tif (filetype == AE_IFLNK)\n\t\tarchive_entry_set_symlink (entry, g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET));\n\n\t\/* username *\/\n\n\tid = archive_entry_uid (entry);\n\tusername = g_hash_table_lookup (save_data->usernames, &id);\n\tif (username == NULL) {\n\t\tstruct passwd *pwd = getpwuid (id);\n\t\tif (pwd != NULL) {\n\t\t\tusername = g_strdup (pwd->pw_name);\n\t\t\tg_hash_table_insert (save_data->usernames, _g_int64_pointer_new (id), username);\n\t\t}\n\t}\n\tif (username != NULL)\n\t\tarchive_entry_set_uname (entry, username);\n\n\t\/* groupname *\/\n\n\tid = archive_entry_gid (entry);\n\tgroupname = g_hash_table_lookup (save_data->groupnames, &id);\n\tif (groupname == NULL) {\n\t\tstruct group *grp = getgrgid (id);\n\t\tif (grp != NULL) {\n\t\t\tgroupname = g_strdup (grp->gr_name);\n\t\t\tg_hash_table_insert (save_data->groupnames, _g_int64_pointer_new (id), groupname);\n\t\t}\n\t}\n\tif (groupname != NULL)\n\t\tarchive_entry_set_gname (entry, groupname);\n\n\treturn TRUE;\n}","target":0,"code_token_length":794,"total_token_length":1030,"max_tokens_setting":2048} +{"idx":419550,"func":"int sa_open_read_magic(int *fd, char *dfile, struct file_magic *file_magic,\n\t\t int ignore, int *endian_mismatch, int do_swap)\n{\n\tint n;\n\tunsigned int fm_types_nr[] = {FILE_MAGIC_ULL_NR, FILE_MAGIC_UL_NR, FILE_MAGIC_U_NR};\n\n\t\/* Open sa data file *\/\n\tif ((*fd = open(dfile, O_RDONLY)) < 0) {\n\t\tint saved_errno = errno;\n\n\t\tfprintf(stderr, _(\"Cannot open %s: %s\\n\"), dfile, strerror(errno));\n\n\t\tif ((saved_errno == ENOENT) && default_file_used) {\n\t\t\tfprintf(stderr, _(\"Please check if data collecting is enabled\\n\"));\n\t\t}\n\t\texit(2);\n\t}\n\n\t\/* Read file magic data *\/\n\tn = read(*fd, file_magic, FILE_MAGIC_SIZE);\n\n\tif ((n != FILE_MAGIC_SIZE) ||\n\t ((file_magic->sysstat_magic != SYSSTAT_MAGIC) && (file_magic->sysstat_magic != SYSSTAT_MAGIC_SWAPPED)) ||\n\t ((file_magic->format_magic != FORMAT_MAGIC) && (file_magic->format_magic != FORMAT_MAGIC_SWAPPED) && !ignore)) {\n#ifdef DEBUG\n\t\tfprintf(stderr, \"%s: Bytes read=%d sysstat_magic=%x format_magic=%x\\n\",\n\t\t\t__FUNCTION__, n, file_magic->sysstat_magic, file_magic->format_magic);\n#endif\n\t\t\/* Display error message and exit *\/\n\t\thandle_invalid_sa_file(*fd, file_magic, dfile, n);\n\t}\n\n\t*endian_mismatch = (file_magic->sysstat_magic != SYSSTAT_MAGIC);\n\tif (*endian_mismatch) {\n\t\tif (do_swap) {\n\t\t\t\/* Swap bytes for file_magic fields *\/\n\t\t\tfile_magic->sysstat_magic = SYSSTAT_MAGIC;\n\t\t\tfile_magic->format_magic = __builtin_bswap16(file_magic->format_magic);\n\t\t}\n\t\t\/*\n\t\t * Start swapping at field \"header_size\" position.\n\t\t * May not exist for older versions but in this case, it won't be used.\n\t\t *\/\n\t\tswap_struct(fm_types_nr, &file_magic->header_size, 0);\n\t}\n\n\tif ((file_magic->sysstat_version > 10) ||\n\t ((file_magic->sysstat_version == 10) && (file_magic->sysstat_patchlevel >= 3))) {\n\t\t\/* header_size field exists only for sysstat versions 10.3.1 and later *\/\n\t\tif ((file_magic->header_size <= MIN_FILE_HEADER_SIZE) ||\n\t\t (file_magic->header_size > MAX_FILE_HEADER_SIZE) ||\n\t\t ((file_magic->header_size < FILE_HEADER_SIZE) && !ignore)) {\n#ifdef DEBUG\n\t\t\tfprintf(stderr, \"%s: header_size=%u\\n\",\n\t\t\t\t__FUNCTION__, file_magic->header_size);\n#endif\n\t\t\t\/* Display error message and exit *\/\n\t\t\thandle_invalid_sa_file(*fd, file_magic, dfile, n);\n\t\t}\n\t}\n\tif ((file_magic->sysstat_version > 11) ||\n\t ((file_magic->sysstat_version == 11) && (file_magic->sysstat_patchlevel >= 7))) {\n\t\t\/* hdr_types_nr field exists only for sysstat versions 11.7.1 and later *\/\n\t\tif (MAP_SIZE(file_magic->hdr_types_nr) > file_magic->header_size) {\n#ifdef DEBUG\n\t\t\tfprintf(stderr, \"%s: map_size=%u header_size=%u\\n\",\n\t\t\t\t__FUNCTION__, MAP_SIZE(file_magic->hdr_types_nr), file_magic->header_size);\n#endif\n\t\t\thandle_invalid_sa_file(*fd, file_magic, dfile, n);\n\t\t}\n\t}\n\n\tif ((file_magic->format_magic != FORMAT_MAGIC) &&\n\t (file_magic->format_magic != FORMAT_MAGIC_SWAPPED))\n\t\t\/*\n\t\t * This is an old (or new) sa datafile format to\n\t\t * be read by sadf (since @ignore was set to TRUE).\n\t\t *\/\n\t\treturn -1;\n\n\treturn 0;\n}","target":0,"code_token_length":836,"total_token_length":1072,"max_tokens_setting":2048} +{"idx":7914,"func":"static PyObject *__pyx_pw_17clickhouse_driver_6varint_1write_varint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n Py_ssize_t __pyx_v_number;\n PyObject *__pyx_v_buf = 0;\n PyObject *__pyx_r = 0;\n __Pyx_RefNannyDeclarations\n __Pyx_RefNannySetupContext(\"write_varint (wrapper)\", 0);\n {\n static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_number,&__pyx_n_s_buf,0};\n PyObject* values[2] = {0,0};\n if (unlikely(__pyx_kwds)) {\n Py_ssize_t kw_args;\n const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);\n switch (pos_args) {\n case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);\n CYTHON_FALLTHROUGH;\n case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);\n CYTHON_FALLTHROUGH;\n case 0: break;\n default: goto __pyx_L5_argtuple_error;\n }\n kw_args = PyDict_Size(__pyx_kwds);\n switch (pos_args) {\n case 0:\n if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_number)) != 0)) kw_args--;\n else goto __pyx_L5_argtuple_error;\n CYTHON_FALLTHROUGH;\n case 1:\n if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;\n else {\n __Pyx_RaiseArgtupleInvalid(\"write_varint\", 1, 2, 2, 1); __PYX_ERR(0, 4, __pyx_L3_error)\n }\n }\n if (unlikely(kw_args > 0)) {\n if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, \"write_varint\") < 0)) __PYX_ERR(0, 4, __pyx_L3_error)\n }\n } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {\n goto __pyx_L5_argtuple_error;\n } else {\n values[0] = PyTuple_GET_ITEM(__pyx_args, 0);\n values[1] = PyTuple_GET_ITEM(__pyx_args, 1);\n }\n __pyx_v_number = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_number == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 4, __pyx_L3_error)\n __pyx_v_buf = values[1];\n }\n goto __pyx_L4_argument_unpacking_done;\n __pyx_L5_argtuple_error:;\n __Pyx_RaiseArgtupleInvalid(\"write_varint\", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4, __pyx_L3_error)\n __pyx_L3_error:;\n __Pyx_AddTraceback(\"clickhouse_driver.varint.write_varint\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n __Pyx_RefNannyFinishContext();\n return NULL;\n __pyx_L4_argument_unpacking_done:;\n __pyx_r = __pyx_pf_17clickhouse_driver_6varint_write_varint(__pyx_self, __pyx_v_number, __pyx_v_buf);\n\n \/* function exit code *\/\n __Pyx_RefNannyFinishContext();\n return __pyx_r;\n}","target":1,"code_token_length":818,"total_token_length":1054,"max_tokens_setting":2048} +{"idx":331308,"func":"static void rtsp_cmd_setup(HTTPContext *c, const char *url,\n\n RTSPHeader *h)\n\n{\n\n FFStream *stream;\n\n int stream_index, port;\n\n char buf[1024];\n\n char path1[1024];\n\n const char *path;\n\n HTTPContext *rtp_c;\n\n RTSPTransportField *th;\n\n struct sockaddr_in dest_addr;\n\n RTSPActionServerSetup setup;\n\n\n\n \/* find which url is asked *\/\n\n url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);\n\n path = path1;\n\n if (*path == '\/')\n\n path++;\n\n\n\n \/* now check each stream *\/\n\n for(stream = first_stream; stream != NULL; stream = stream->next) {\n\n if (!stream->is_feed && !strcmp(stream->fmt->name, \"rtp\")) {\n\n \/* accept aggregate filenames only if single stream *\/\n\n if (!strcmp(path, stream->filename)) {\n\n if (stream->nb_streams != 1) {\n\n rtsp_reply_error(c, RTSP_STATUS_AGGREGATE);\n\n return;\n\n }\n\n stream_index = 0;\n\n goto found;\n\n }\n\n\n\n for(stream_index = 0; stream_index < stream->nb_streams;\n\n stream_index++) {\n\n snprintf(buf, sizeof(buf), \"%s\/streamid=%d\",\n\n stream->filename, stream_index);\n\n if (!strcmp(path, buf))\n\n goto found;\n\n }\n\n }\n\n }\n\n \/* no stream found *\/\n\n rtsp_reply_error(c, RTSP_STATUS_SERVICE); \/* XXX: right error ? *\/\n\n return;\n\n found:\n\n\n\n \/* generate session id if needed *\/\n\n if (h->session_id[0] == '\\0')\n\n snprintf(h->session_id, sizeof(h->session_id), \"%08x%08x\",\n\n av_random(&random_state), av_random(&random_state));\n\n\n\n \/* find rtp session, and create it if none found *\/\n\n rtp_c = find_rtp_session(h->session_id);\n\n if (!rtp_c) {\n\n \/* always prefer UDP *\/\n\n th = find_transport(h, RTSP_PROTOCOL_RTP_UDP);\n\n if (!th) {\n\n th = find_transport(h, RTSP_PROTOCOL_RTP_TCP);\n\n if (!th) {\n\n rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);\n\n return;\n\n }\n\n }\n\n\n\n rtp_c = rtp_new_connection(&c->from_addr, stream, h->session_id,\n\n th->protocol);\n\n if (!rtp_c) {\n\n rtsp_reply_error(c, RTSP_STATUS_BANDWIDTH);\n\n return;\n\n }\n\n\n\n \/* open input stream *\/\n\n if (open_input_stream(rtp_c, \"\") < 0) {\n\n rtsp_reply_error(c, RTSP_STATUS_INTERNAL);\n\n return;\n\n }\n\n }\n\n\n\n \/* test if stream is OK (test needed because several SETUP needs\n\n to be done for a given file) *\/\n\n if (rtp_c->stream != stream) {\n\n rtsp_reply_error(c, RTSP_STATUS_SERVICE);\n\n return;\n\n }\n\n\n\n \/* test if stream is already set up *\/\n\n if (rtp_c->rtp_ctx[stream_index]) {\n\n rtsp_reply_error(c, RTSP_STATUS_STATE);\n\n return;\n\n }\n\n\n\n \/* check transport *\/\n\n th = find_transport(h, rtp_c->rtp_protocol);\n\n if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&\n\n th->client_port_min <= 0)) {\n\n rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);\n\n return;\n\n }\n\n\n\n \/* setup default options *\/\n\n setup.transport_option[0] = '\\0';\n\n dest_addr = rtp_c->from_addr;\n\n dest_addr.sin_port = htons(th->client_port_min);\n\n\n\n \/* setup stream *\/\n\n if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, c) < 0) {\n\n rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);\n\n return;\n\n }\n\n\n\n \/* now everything is OK, so we can send the connection parameters *\/\n\n rtsp_reply_header(c, RTSP_STATUS_OK);\n\n \/* session ID *\/\n\n url_fprintf(c->pb, \"Session: %s\\r\\n\", rtp_c->session_id);\n\n\n\n switch(rtp_c->rtp_protocol) {\n\n case RTSP_PROTOCOL_RTP_UDP:\n\n port = rtp_get_local_port(rtp_c->rtp_handles[stream_index]);\n\n url_fprintf(c->pb, \"Transport: RTP\/AVP\/UDP;unicast;\"\n\n \"client_port=%d-%d;server_port=%d-%d\",\n\n th->client_port_min, th->client_port_min + 1,\n\n port, port + 1);\n\n break;\n\n case RTSP_PROTOCOL_RTP_TCP:\n\n url_fprintf(c->pb, \"Transport: RTP\/AVP\/TCP;interleaved=%d-%d\",\n\n stream_index * 2, stream_index * 2 + 1);\n\n break;\n\n default:\n\n break;\n\n }\n\n if (setup.transport_option[0] != '\\0')\n\n url_fprintf(c->pb, \";%s\", setup.transport_option);\n\n url_fprintf(c->pb, \"\\r\\n\");\n\n\n\n\n\n url_fprintf(c->pb, \"\\r\\n\");\n\n}\n","target":1,"code_token_length":1133,"total_token_length":1369,"max_tokens_setting":2048} +{"idx":338151,"func":"static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)\n\n{\n\n int i;\n\n int repeating = 0;\n\n AVPacket avpkt;\n\n\n\n if (ist->next_dts == AV_NOPTS_VALUE)\n\n ist->next_dts = ist->last_dts;\n\n\n\n if (!pkt) {\n\n \/* EOF handling *\/\n\n av_init_packet(&avpkt);\n\n avpkt.data = NULL;\n\n avpkt.size = 0;\n\n } else {\n\n avpkt = *pkt;\n\n }\n\n\n\n if (pkt && pkt->dts != AV_NOPTS_VALUE)\n\n ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);\n\n\n\n \/\/ while we have more to decode or while the decoder did output something on EOF\n\n while (ist->decoding_needed && (!pkt || avpkt.size > 0)) {\n\n int ret = 0;\n\n int got_output = 0;\n\n\n\n if (!repeating)\n\n ist->last_dts = ist->next_dts;\n\n\n\n switch (ist->dec_ctx->codec_type) {\n\n case AVMEDIA_TYPE_AUDIO:\n\n ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output);\n\n break;\n\n case AVMEDIA_TYPE_VIDEO:\n\n ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output);\n\n if (repeating && !got_output)\n\n ;\n\n else if (pkt && pkt->duration)\n\n ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);\n\n else if (ist->st->avg_frame_rate.num)\n\n ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),\n\n AV_TIME_BASE_Q);\n\n else if (ist->dec_ctx->framerate.num != 0) {\n\n int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 :\n\n ist->dec_ctx->ticks_per_frame;\n\n ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q);\n\n }\n\n break;\n\n case AVMEDIA_TYPE_SUBTITLE:\n\n if (repeating)\n\n break;\n\n ret = transcode_subtitles(ist, &avpkt, &got_output);\n\n break;\n\n default:\n\n return;\n\n }\n\n\n\n if (ret < 0) {\n\n av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d\\n\",\n\n ist->file_index, ist->st->index);\n\n if (exit_on_error)\n\n exit_program(1);\n\n break;\n\n }\n\n\n\n if (!got_output)\n\n break;\n\n\n\n repeating = 1;\n\n }\n\n\n\n \/* after flushing, send an EOF on all the filter inputs attached to the stream *\/\n\n \/* except when looping we need to flush but not to send an EOF *\/\n\n if (!pkt && ist->decoding_needed && !no_eof) {\n\n int ret = send_filter_eof(ist);\n\n if (ret < 0) {\n\n av_log(NULL, AV_LOG_FATAL, \"Error marking filters as finished\\n\");\n\n exit_program(1);\n\n }\n\n }\n\n\n\n \/* handle stream copy *\/\n\n if (!ist->decoding_needed) {\n\n ist->last_dts = ist->next_dts;\n\n switch (ist->dec_ctx->codec_type) {\n\n case AVMEDIA_TYPE_AUDIO:\n\n ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) \/\n\n ist->dec_ctx->sample_rate;\n\n break;\n\n case AVMEDIA_TYPE_VIDEO:\n\n if (ist->dec_ctx->framerate.num != 0) {\n\n int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;\n\n ist->next_dts += ((int64_t)AV_TIME_BASE *\n\n ist->dec_ctx->framerate.den * ticks) \/\n\n ist->dec_ctx->framerate.num;\n\n }\n\n break;\n\n }\n\n }\n\n for (i = 0; pkt && i < nb_output_streams; i++) {\n\n OutputStream *ost = output_streams[i];\n\n\n\n if (!check_output_constraints(ist, ost) || ost->encoding_needed)\n\n continue;\n\n\n\n do_streamcopy(ist, ost, pkt);\n\n }\n\n\n\n return;\n\n}\n","target":1,"code_token_length":959,"total_token_length":1195,"max_tokens_setting":2048} +{"idx":362880,"func":"int sock_getsockopt(struct socket *sock, int level, int optname,\n\t\t char __user *optval, int __user *optlen)\n{\n\tstruct sock *sk = sock->sk;\n\n\tunion {\n\t\tint val;\n\t\tstruct linger ling;\n\t\tstruct timeval tm;\n\t} v;\n\n\tint lv = sizeof(int);\n\tint len;\n\n\tif (get_user(len, optlen))\n\t\treturn -EFAULT;\n\tif (len < 0)\n\t\treturn -EINVAL;\n\n\tmemset(&v, 0, sizeof(v));\n\n\tswitch (optname) {\n\tcase SO_DEBUG:\n\t\tv.val = sock_flag(sk, SOCK_DBG);\n\t\tbreak;\n\n\tcase SO_DONTROUTE:\n\t\tv.val = sock_flag(sk, SOCK_LOCALROUTE);\n\t\tbreak;\n\n\tcase SO_BROADCAST:\n\t\tv.val = !!sock_flag(sk, SOCK_BROADCAST);\n\t\tbreak;\n\n\tcase SO_SNDBUF:\n\t\tv.val = sk->sk_sndbuf;\n\t\tbreak;\n\n\tcase SO_RCVBUF:\n\t\tv.val = sk->sk_rcvbuf;\n\t\tbreak;\n\n\tcase SO_REUSEADDR:\n\t\tv.val = sk->sk_reuse;\n\t\tbreak;\n\n\tcase SO_KEEPALIVE:\n\t\tv.val = !!sock_flag(sk, SOCK_KEEPOPEN);\n\t\tbreak;\n\n\tcase SO_TYPE:\n\t\tv.val = sk->sk_type;\n\t\tbreak;\n\n\tcase SO_PROTOCOL:\n\t\tv.val = sk->sk_protocol;\n\t\tbreak;\n\n\tcase SO_DOMAIN:\n\t\tv.val = sk->sk_family;\n\t\tbreak;\n\n\tcase SO_ERROR:\n\t\tv.val = -sock_error(sk);\n\t\tif (v.val == 0)\n\t\t\tv.val = xchg(&sk->sk_err_soft, 0);\n\t\tbreak;\n\n\tcase SO_OOBINLINE:\n\t\tv.val = !!sock_flag(sk, SOCK_URGINLINE);\n\t\tbreak;\n\n\tcase SO_NO_CHECK:\n\t\tv.val = sk->sk_no_check;\n\t\tbreak;\n\n\tcase SO_PRIORITY:\n\t\tv.val = sk->sk_priority;\n\t\tbreak;\n\n\tcase SO_LINGER:\n\t\tlv\t\t= sizeof(v.ling);\n\t\tv.ling.l_onoff\t= !!sock_flag(sk, SOCK_LINGER);\n\t\tv.ling.l_linger\t= sk->sk_lingertime \/ HZ;\n\t\tbreak;\n\n\tcase SO_BSDCOMPAT:\n\t\tsock_warn_obsolete_bsdism(\"getsockopt\");\n\t\tbreak;\n\n\tcase SO_TIMESTAMP:\n\t\tv.val = sock_flag(sk, SOCK_RCVTSTAMP) &&\n\t\t\t\t!sock_flag(sk, SOCK_RCVTSTAMPNS);\n\t\tbreak;\n\n\tcase SO_TIMESTAMPNS:\n\t\tv.val = sock_flag(sk, SOCK_RCVTSTAMPNS);\n\t\tbreak;\n\n\tcase SO_TIMESTAMPING:\n\t\tv.val = 0;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_TX_HARDWARE;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_TX_SOFTWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_TX_SOFTWARE;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_RX_HARDWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_RX_HARDWARE;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_RX_SOFTWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_RX_SOFTWARE;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_SOFTWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_SOFTWARE;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_SYS_HARDWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_SYS_HARDWARE;\n\t\tif (sock_flag(sk, SOCK_TIMESTAMPING_RAW_HARDWARE))\n\t\t\tv.val |= SOF_TIMESTAMPING_RAW_HARDWARE;\n\t\tbreak;\n\n\tcase SO_RCVTIMEO:\n\t\tlv = sizeof(struct timeval);\n\t\tif (sk->sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT) {\n\t\t\tv.tm.tv_sec = 0;\n\t\t\tv.tm.tv_usec = 0;\n\t\t} else {\n\t\t\tv.tm.tv_sec = sk->sk_rcvtimeo \/ HZ;\n\t\t\tv.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * 1000000) \/ HZ;\n\t\t}\n\t\tbreak;\n\n\tcase SO_SNDTIMEO:\n\t\tlv = sizeof(struct timeval);\n\t\tif (sk->sk_sndtimeo == MAX_SCHEDULE_TIMEOUT) {\n\t\t\tv.tm.tv_sec = 0;\n\t\t\tv.tm.tv_usec = 0;\n\t\t} else {\n\t\t\tv.tm.tv_sec = sk->sk_sndtimeo \/ HZ;\n\t\t\tv.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * 1000000) \/ HZ;\n\t\t}\n\t\tbreak;\n\n\tcase SO_RCVLOWAT:\n\t\tv.val = sk->sk_rcvlowat;\n\t\tbreak;\n\n\tcase SO_SNDLOWAT:\n\t\tv.val = 1;\n\t\tbreak;\n\n\tcase SO_PASSCRED:\n\t\tv.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0;\n\t\tbreak;\n\n\tcase SO_PEERCRED:\n\t\tif (len > sizeof(sk->sk_peercred))\n\t\t\tlen = sizeof(sk->sk_peercred);\n\t\tif (copy_to_user(optval, &sk->sk_peercred, len))\n\t\t\treturn -EFAULT;\n\t\tgoto lenout;\n\n\tcase SO_PEERNAME:\n\t{\n\t\tchar address[128];\n\n\t\tif (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))\n\t\t\treturn -ENOTCONN;\n\t\tif (lv < len)\n\t\t\treturn -EINVAL;\n\t\tif (copy_to_user(optval, address, len))\n\t\t\treturn -EFAULT;\n\t\tgoto lenout;\n\t}\n\n\t\/* Dubious BSD thing... Probably nobody even uses it, but\n\t * the UNIX standard wants it for whatever reason... -DaveM\n\t *\/\n\tcase SO_ACCEPTCONN:\n\t\tv.val = sk->sk_state == TCP_LISTEN;\n\t\tbreak;\n\n\tcase SO_PASSSEC:\n\t\tv.val = test_bit(SOCK_PASSSEC, &sock->flags) ? 1 : 0;\n\t\tbreak;\n\n\tcase SO_PEERSEC:\n\t\treturn security_socket_getpeersec_stream(sock, optval, optlen, len);\n\n\tcase SO_MARK:\n\t\tv.val = sk->sk_mark;\n\t\tbreak;\n\n\tcase SO_RXQ_OVFL:\n\t\tv.val = !!sock_flag(sk, SOCK_RXQ_OVFL);\n\t\tbreak;\n\n\tdefault:\n\t\treturn -ENOPROTOOPT;\n\t}\n\n\tif (len > lv)\n\t\tlen = lv;\n\tif (copy_to_user(optval, &v, len))\n\t\treturn -EFAULT;\nlenout:\n\tif (put_user(len, optlen))\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":1374,"total_token_length":1610,"max_tokens_setting":2048} +{"idx":516195,"func":"MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt)\n{\n size_t i;\n\n \/* Clear certificate validity flags *\/\n for (i = 0; i < SSL_PKEY_NUM; i++)\n s->s3.tmp.valid_flags[i] = 0;\n\n if (SSL_IS_TLS13(s)) {\n PACKET reqctx, extensions;\n RAW_EXTENSION *rawexts = NULL;\n\n if ((s->shutdown & SSL_SENT_SHUTDOWN) != 0) {\n \/*\n * We already sent close_notify. This can only happen in TLSv1.3\n * post-handshake messages. We can't reasonably respond to this, so\n * we just ignore it\n *\/\n return MSG_PROCESS_FINISHED_READING;\n }\n\n \/* Free and zero certificate types: it is not present in TLS 1.3 *\/\n OPENSSL_free(s->s3.tmp.ctype);\n s->s3.tmp.ctype = NULL;\n s->s3.tmp.ctype_len = 0;\n OPENSSL_free(s->pha_context);\n s->pha_context = NULL;\n s->pha_context_len = 0;\n\n if (!PACKET_get_length_prefixed_1(pkt, &reqctx) ||\n !PACKET_memdup(&reqctx, &s->pha_context, &s->pha_context_len)) {\n SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_LENGTH_MISMATCH);\n return MSG_PROCESS_ERROR;\n }\n\n if (!PACKET_get_length_prefixed_2(pkt, &extensions)) {\n SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_BAD_LENGTH);\n return MSG_PROCESS_ERROR;\n }\n if (!tls_collect_extensions(s, &extensions,\n SSL_EXT_TLS1_3_CERTIFICATE_REQUEST,\n &rawexts, NULL, 1)\n || !tls_parse_all_extensions(s, SSL_EXT_TLS1_3_CERTIFICATE_REQUEST,\n rawexts, NULL, 0, 1)) {\n \/* SSLfatal() already called *\/\n OPENSSL_free(rawexts);\n return MSG_PROCESS_ERROR;\n }\n OPENSSL_free(rawexts);\n if (!tls1_process_sigalgs(s)) {\n SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_BAD_LENGTH);\n return MSG_PROCESS_ERROR;\n }\n } else {\n PACKET ctypes;\n\n \/* get the certificate types *\/\n if (!PACKET_get_length_prefixed_1(pkt, &ctypes)) {\n SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_LENGTH_MISMATCH);\n return MSG_PROCESS_ERROR;\n }\n\n if (!PACKET_memdup(&ctypes, &s->s3.tmp.ctype, &s->s3.tmp.ctype_len)) {\n SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);\n return MSG_PROCESS_ERROR;\n }\n\n if (SSL_USE_SIGALGS(s)) {\n PACKET sigalgs;\n\n if (!PACKET_get_length_prefixed_2(pkt, &sigalgs)) {\n SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_LENGTH_MISMATCH);\n return MSG_PROCESS_ERROR;\n }\n\n \/*\n * Despite this being for certificates, preserve compatibility\n * with pre-TLS 1.3 and use the regular sigalgs field.\n *\/\n if (!tls1_save_sigalgs(s, &sigalgs, 0)) {\n SSLfatal(s, SSL_AD_INTERNAL_ERROR,\n SSL_R_SIGNATURE_ALGORITHMS_ERROR);\n return MSG_PROCESS_ERROR;\n }\n if (!tls1_process_sigalgs(s)) {\n SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE);\n return MSG_PROCESS_ERROR;\n }\n }\n\n \/* get the CA RDNs *\/\n if (!parse_ca_names(s, pkt)) {\n \/* SSLfatal() already called *\/\n return MSG_PROCESS_ERROR;\n }\n }\n\n if (PACKET_remaining(pkt) != 0) {\n SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_LENGTH_MISMATCH);\n return MSG_PROCESS_ERROR;\n }\n\n \/* we should setup a certificate to return.... *\/\n s->s3.tmp.cert_req = 1;\n\n \/*\n * In TLSv1.3 we don't prepare the client certificate yet. We wait until\n * after the CertificateVerify message has been received. This is because\n * in TLSv1.3 the CertificateRequest arrives before the Certificate message\n * but in TLSv1.2 it is the other way around. We want to make sure that\n * SSL_get1_peer_certificate() returns something sensible in\n * client_cert_cb.\n *\/\n if (SSL_IS_TLS13(s) && s->post_handshake_auth != SSL_PHA_REQUESTED)\n return MSG_PROCESS_CONTINUE_READING;\n\n return MSG_PROCESS_CONTINUE_PROCESSING;\n}","target":0,"code_token_length":1016,"total_token_length":1252,"max_tokens_setting":2048} +{"idx":63891,"func":"bool sql_slave_killed(THD* thd, Relay_log_info* rli)\n{\n bool ret= FALSE;\n bool is_parallel_warn= FALSE;\n\n DBUG_ENTER(\"sql_slave_killed\");\n\n DBUG_ASSERT(rli->info_thd == thd);\n DBUG_ASSERT(rli->slave_running == 1);\n if (abort_loop || thd->killed || rli->abort_slave)\n {\n is_parallel_warn= (rli->is_parallel_exec() && \n (rli->is_mts_in_group() || thd->killed));\n \/*\n Slave can execute stop being in one of two MTS or Single-Threaded mode.\n The modes define different criteria to accept the stop.\n In particular that relates to the concept of groupping.\n Killed Coordinator thread expects the worst so it warns on\n possible consistency issue.\n *\/\n if (is_parallel_warn ||\n (!rli->is_parallel_exec() &&\n thd->transaction.all.cannot_safely_rollback() && rli->is_in_group()))\n {\n char msg_stopped[]=\n \"... Slave SQL Thread stopped with incomplete event group \"\n \"having non-transactional changes. \"\n \"If the group consists solely of row-based events, you can try \"\n \"to restart the slave with --slave-exec-mode=IDEMPOTENT, which \"\n \"ignores duplicate key, key not found, and similar errors (see \"\n \"documentation for details).\";\n char msg_stopped_mts[]=\n \"... The slave coordinator and worker threads are stopped, possibly \"\n \"leaving data in inconsistent state. A restart should \"\n \"restore consistency automatically, although using non-transactional \"\n \"storage for data or info tables or DDL queries could lead to problems. \"\n \"In such cases you have to examine your data (see documentation for \"\n \"details).\";\n\n ret= TRUE;\n if (rli->abort_slave)\n {\n DBUG_PRINT(\"info\", (\"Request to stop slave SQL Thread received while \"\n \"applying an MTS group or a group that \"\n \"has non-transactional \"\n \"changes; waiting for completion of the group ... \"));\n\n \/*\n Slave sql thread shutdown in face of unfinished group modified \n Non-trans table is handled via a timer. The slave may eventually\n give out to complete the current group and in that case there\n might be issues at consequent slave restart, see the error message.\n WL#2975 offers a robust solution requiring to store the last exectuted\n event's coordinates along with the group's coordianates\n instead of waiting with @c last_event_start_time the timer.\n *\/\n\n if (rli->last_event_start_time == 0)\n rli->last_event_start_time= my_time(0);\n ret= difftime(my_time(0), rli->last_event_start_time) <=\n SLAVE_WAIT_GROUP_DONE ? FALSE : TRUE;\n\n DBUG_EXECUTE_IF(\"stop_slave_middle_group\", \n DBUG_EXECUTE_IF(\"incomplete_group_in_relay_log\",\n ret= TRUE;);); \/\/ time is over\n\n if (!ret && !rli->reported_unsafe_warning)\n {\n rli->report(WARNING_LEVEL, 0,\n !is_parallel_warn ?\n \"Request to stop slave SQL Thread received while \"\n \"applying a group that has non-transactional \"\n \"changes; waiting for completion of the group ... \"\n :\n \"Coordinator thread of multi-threaded slave is being \"\n \"stopped in the middle of assigning a group of events; \"\n \"deferring to exit until the group completion ... \");\n rli->reported_unsafe_warning= true;\n }\n }\n if (ret)\n {\n if (is_parallel_warn)\n rli->report(!rli->is_error() ? ERROR_LEVEL :\n WARNING_LEVEL, \/\/ an error was reported by Worker\n ER_MTS_INCONSISTENT_DATA,\n ER(ER_MTS_INCONSISTENT_DATA),\n msg_stopped_mts);\n else\n rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,\n ER(ER_SLAVE_FATAL_ERROR), msg_stopped);\n }\n }\n else\n {\n ret= TRUE;\n }\n }\n if (ret)\n {\n rli->last_event_start_time= 0;\n if (rli->mts_group_status == Relay_log_info::MTS_IN_GROUP)\n {\n rli->mts_group_status= Relay_log_info::MTS_KILLED_GROUP;\n }\n }\n \n DBUG_RETURN(ret);\n}","target":0,"code_token_length":986,"total_token_length":1222,"max_tokens_setting":2048} +{"idx":301178,"func":"do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,\n int swap, uint32_t namesz, uint32_t descsz,\n size_t noff, size_t doff, int *flags, size_t size, int clazz)\n{\n#ifdef ELFCORE\n\tint os_style = -1;\n\t\/*\n\t * Sigh. The 2.0.36 kernel in Debian 2.1, at\n\t * least, doesn't correctly implement name\n\t * sections, in core dumps, as specified by\n\t * the \"Program Linking\" section of \"UNIX(R) System\n\t * V Release 4 Programmer's Guide: ANSI C and\n\t * Programming Support Tools\", because my copy\n\t * clearly says \"The first 'namesz' bytes in 'name'\n\t * contain a *null-terminated* [emphasis mine]\n\t * character representation of the entry's owner\n\t * or originator\", but the 2.0.36 kernel code\n\t * doesn't include the terminating null in the\n\t * name....\n\t *\/\n\tif ((namesz == 4 && strncmp((char *)&nbuf[noff], \"CORE\", 4) == 0) ||\n\t (namesz == 5 && strcmp((char *)&nbuf[noff], \"CORE\") == 0)) {\n\t\tos_style = OS_STYLE_SVR4;\n\t} \n\n\tif ((namesz == 8 && strcmp((char *)&nbuf[noff], \"FreeBSD\") == 0)) {\n\t\tos_style = OS_STYLE_FREEBSD;\n\t}\n\n\tif ((namesz >= 11 && strncmp((char *)&nbuf[noff], \"NetBSD-CORE\", 11)\n\t == 0)) {\n\t\tos_style = OS_STYLE_NETBSD;\n\t}\n\n\tif (os_style != -1 && (*flags & FLAGS_DID_CORE_STYLE) == 0) {\n\t\tif (file_printf(ms, \", %s-style\", os_style_names[os_style])\n\t\t == -1)\n\t\t\treturn 1;\n\t\t*flags |= FLAGS_DID_CORE_STYLE;\n\t\t*flags |= os_style;\n\t}\n\n\tswitch (os_style) {\n\tcase OS_STYLE_NETBSD:\n\t\tif (type == NT_NETBSD_CORE_PROCINFO) {\n\t\t\tchar sbuf[512];\n\t\t\tstruct NetBSD_elfcore_procinfo pi;\n\t\t\tmemset(&pi, 0, sizeof(pi));\n\t\t\tmemcpy(&pi, nbuf + doff, descsz);\n\n\t\t\tif (file_printf(ms, \", from '%.31s', pid=%u, uid=%u, \"\n\t\t\t \"gid=%u, nlwps=%u, lwp=%u (signal %u\/code %u)\",\n\t\t\t file_printable(sbuf, sizeof(sbuf),\n\t\t\t CAST(char *, pi.cpi_name)),\n\t\t\t elf_getu32(swap, pi.cpi_pid),\n\t\t\t elf_getu32(swap, pi.cpi_euid),\n\t\t\t elf_getu32(swap, pi.cpi_egid),\n\t\t\t elf_getu32(swap, pi.cpi_nlwps),\n\t\t\t elf_getu32(swap, pi.cpi_siglwp),\n\t\t\t elf_getu32(swap, pi.cpi_signo),\n\t\t\t elf_getu32(swap, pi.cpi_sigcode)) == -1)\n\t\t\t\treturn 1;\n\n\t\t\t*flags |= FLAGS_DID_CORE;\n\t\t\treturn 1;\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tif (type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {\n\t\t\tsize_t i, j;\n\t\t\tunsigned char c;\n\t\t\t\/*\n\t\t\t * Extract the program name. We assume\n\t\t\t * it to be 16 characters (that's what it\n\t\t\t * is in SunOS 5.x and Linux).\n\t\t\t *\n\t\t\t * Unfortunately, it's at a different offset\n\t\t\t * in various OSes, so try multiple offsets.\n\t\t\t * If the characters aren't all printable,\n\t\t\t * reject it.\n\t\t\t *\/\n\t\t\tfor (i = 0; i < NOFFSETS; i++) {\n\t\t\t\tunsigned char *cname, *cp;\n\t\t\t\tsize_t reloffset = prpsoffsets(i);\n\t\t\t\tsize_t noffset = doff + reloffset;\n\t\t\t\tsize_t k;\n\t\t\t\tfor (j = 0; j < 16; j++, noffset++,\n\t\t\t\t reloffset++) {\n\t\t\t\t\t\/*\n\t\t\t\t\t * Make sure we're not past\n\t\t\t\t\t * the end of the buffer; if\n\t\t\t\t\t * we are, just give up.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (noffset >= size)\n\t\t\t\t\t\tgoto tryanother;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Make sure we're not past\n\t\t\t\t\t * the end of the contents;\n\t\t\t\t\t * if we are, this obviously\n\t\t\t\t\t * isn't the right offset.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (reloffset >= descsz)\n\t\t\t\t\t\tgoto tryanother;\n\n\t\t\t\t\tc = nbuf[noffset];\n\t\t\t\t\tif (c == '\\0') {\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * A '\\0' at the\n\t\t\t\t\t\t * beginning is\n\t\t\t\t\t\t * obviously wrong.\n\t\t\t\t\t\t * Any other '\\0'\n\t\t\t\t\t\t * means we're done.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (j == 0)\n\t\t\t\t\t\t\tgoto tryanother;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * A nonprintable\n\t\t\t\t\t\t * character is also\n\t\t\t\t\t\t * wrong.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (!isprint(c) || isquote(c))\n\t\t\t\t\t\t\tgoto tryanother;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\/*\n\t\t\t\t * Well, that worked.\n\t\t\t\t *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Try next offsets, in case this match is\n\t\t\t\t * in the middle of a string.\n\t\t\t\t *\/\n\t\t\t\tfor (k = i + 1 ; k < NOFFSETS; k++) {\n\t\t\t\t\tsize_t no;\n\t\t\t\t\tint adjust = 1;\n\t\t\t\t\tif (prpsoffsets(k) >= prpsoffsets(i))\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfor (no = doff + prpsoffsets(k);\n\t\t\t\t\t no < doff + prpsoffsets(i); no++)\n\t\t\t\t\t\tadjust = adjust\n\t\t\t\t\t\t && isprint(nbuf[no]);\n\t\t\t\t\tif (adjust)\n\t\t\t\t\t\ti = k;\n\t\t\t\t}\n\n\t\t\t\tcname = (unsigned char *)\n\t\t\t\t &nbuf[doff + prpsoffsets(i)];\n\t\t\t\tfor (cp = cname; *cp && isprint(*cp); cp++)\n\t\t\t\t\tcontinue;\n\t\t\t\t\/*\n\t\t\t\t * Linux apparently appends a space at the end\n\t\t\t\t * of the command line: remove it.\n\t\t\t\t *\/\n\t\t\t\twhile (cp > cname && isspace(cp[-1]))\n\t\t\t\t\tcp--;\n\t\t\t\tif (file_printf(ms, \", from '%.*s'\",\n\t\t\t\t (int)(cp - cname), cname) == -1)\n\t\t\t\t\treturn 1;\n\t\t\t\t*flags |= FLAGS_DID_CORE;\n\t\t\t\treturn 1;\n\n\t\t\ttryanother:\n\t\t\t\t;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\t}\n#endif\n\treturn 0;\n}","target":0,"code_token_length":1462,"total_token_length":1698,"max_tokens_setting":2048} +{"idx":339429,"func":"MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)\n\n\n\nint ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,\n\n int level)\n\n{\n\n VDPAUHWContext *hwctx = avctx->hwaccel_context;\n\n VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;\n\n VdpVideoSurfaceQueryCapabilities *surface_query_caps;\n\n VdpDecoderQueryCapabilities *decoder_query_caps;\n\n VdpDecoderCreate *create;\n\n void *func;\n\n VdpStatus status;\n\n VdpBool supported;\n\n uint32_t max_level, max_mb, max_width, max_height;\n\n \/* See vdpau\/vdpau.h for alignment constraints. *\/\n\n uint32_t width = (avctx->coded_width + 1) & ~1;\n\n uint32_t height = (avctx->coded_height + 3) & ~3;\n\n\n\n vdctx->width = UINT32_MAX;\n\n vdctx->height = UINT32_MAX;\n\n hwctx->reset = 0;\n\n\n\n if (!hwctx) {\n\n vdctx->device = VDP_INVALID_HANDLE;\n\n av_log(avctx, AV_LOG_WARNING, \"hwaccel_context has not been setup by the user application, cannot initialize\\n\");\n\n return 0;\n\n }\n\n\n\n if (hwctx->context.decoder != VDP_INVALID_HANDLE) {\n\n vdctx->decoder = hwctx->context.decoder;\n\n vdctx->render = hwctx->context.render;\n\n vdctx->device = VDP_INVALID_HANDLE;\n\n return 0; \/* Decoder created by user *\/\n\n }\n\n\n\n vdctx->device = hwctx->device;\n\n vdctx->get_proc_address = hwctx->get_proc_address;\n\n\n\n if (level < 0)\n\n return AVERROR(ENOTSUP);\n\n\n\n status = vdctx->get_proc_address(vdctx->device,\n\n VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,\n\n &func);\n\n if (status != VDP_STATUS_OK)\n\n return vdpau_error(status);\n\n else\n\n surface_query_caps = func;\n\n\n\n status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,\n\n &max_width, &max_height);\n\n if (status != VDP_STATUS_OK)\n\n return vdpau_error(status);\n\n if (supported != VDP_TRUE ||\n\n max_width < width || max_height < height)\n\n return AVERROR(ENOTSUP);\n\n\n\n status = vdctx->get_proc_address(vdctx->device,\n\n VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,\n\n &func);\n\n if (status != VDP_STATUS_OK)\n\n return vdpau_error(status);\n\n else\n\n decoder_query_caps = func;\n\n\n\n status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,\n\n &max_mb, &max_width, &max_height);\n\n if (status != VDP_STATUS_OK)\n\n return vdpau_error(status);\n\n\n\n if (supported != VDP_TRUE || max_level < level ||\n\n max_width < width || max_height < height)\n\n return AVERROR(ENOTSUP);\n\n\n\n status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,\n\n &func);\n\n if (status != VDP_STATUS_OK)\n\n return vdpau_error(status);\n\n else\n\n create = func;\n\n\n\n status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,\n\n &func);\n\n if (status != VDP_STATUS_OK)\n\n return vdpau_error(status);\n\n else\n\n vdctx->render = func;\n\n\n\n status = create(vdctx->device, profile, width, height, avctx->refs,\n\n &vdctx->decoder);\n\n if (status == VDP_STATUS_OK) {\n\n vdctx->width = avctx->coded_width;\n\n vdctx->height = avctx->coded_height;\n\n }\n\n\n\n return vdpau_error(status);\n\n}\n","target":0,"code_token_length":884,"total_token_length":1120,"max_tokens_setting":2048} +{"idx":428018,"func":"EXPORTED void write_body(long code, struct transaction_t *txn,\n\t\tconst char *buf, unsigned len)\n{\n unsigned is_dynamic = code ? (txn->flags.te & TE_CHUNKED) : 1;\n unsigned outlen = len, offset = 0;\n int do_md5 = config_getswitch(IMAPOPT_HTTPCONTENTMD5);\n static MD5_CTX ctx;\n static unsigned char md5[MD5_DIGEST_LENGTH];\n\n if (!is_dynamic && len < GZIP_MIN_LEN) {\n\t\/* Don't compress small static content *\/\n\ttxn->resp_body.enc = CE_IDENTITY;\n\ttxn->flags.te = TE_NONE;\n }\n\n \/* Compress data *\/\n if (txn->resp_body.enc || txn->flags.te & ~TE_CHUNKED) {\n#ifdef HAVE_ZLIB\n\t\/* Only flush for static content or on last (zero-length) chunk *\/\n\tunsigned flush = (is_dynamic && len) ? Z_NO_FLUSH : Z_FINISH;\n\n\tif (code) deflateReset(&txn->zstrm);\n\n\ttxn->zstrm.next_in = (Bytef *) buf;\n\ttxn->zstrm.avail_in = len;\n\tbuf_reset(&txn->zbuf);\n\n\tdo {\n\t buf_ensure(&txn->zbuf,\n\t\t deflateBound(&txn->zstrm, txn->zstrm.avail_in));\n\n\t txn->zstrm.next_out = (Bytef *) txn->zbuf.s + txn->zbuf.len;\n\t txn->zstrm.avail_out = txn->zbuf.alloc - txn->zbuf.len;\n\n\t deflate(&txn->zstrm, flush);\n\t txn->zbuf.len = txn->zbuf.alloc - txn->zstrm.avail_out;\n\n\t} while (!txn->zstrm.avail_out);\n\n\tbuf = txn->zbuf.s;\n\toutlen = txn->zbuf.len;\n#else\n\t\/* XXX should never get here *\/\n\tfatal(\"Compression requested, but no zlib\", EC_SOFTWARE);\n#endif \/* HAVE_ZLIB *\/\n }\n\n if (code) {\n\t\/* Initial call - prepare response header based on CE, TE and version *\/\n\tif (do_md5) MD5Init(&ctx);\n\n\tif (txn->flags.te & ~TE_CHUNKED) {\n\t \/* Transfer-Encoded content MUST be chunked *\/\n\t txn->flags.te |= TE_CHUNKED;\n\n\t if (!is_dynamic) {\n\t\t\/* Handle static content as last chunk *\/\n\t\tlen = 0;\n\t }\n\t}\n\n\tif (!(txn->flags.te & TE_CHUNKED)) {\n\t \/* Full\/partial body (no encoding).\n\t *\n\t * In all cases, 'resp_body.len' is used to specify complete-length\n\t * In the case of a 206 or 416 response, Content-Length will be\n\t * set accordingly in response_header().\n\t *\/\n\t txn->resp_body.len = outlen;\n\n\t if (code == HTTP_PARTIAL) {\n\t\t\/* check_precond() tells us that this is a range request *\/\n\t\tcode = parse_ranges(*spool_getheader(txn->req_hdrs, \"Range\"),\n\t\t\t\t outlen, &txn->resp_body.range);\n\n\t\tswitch (code) {\n\t\tcase HTTP_OK:\n\t\t \/* Full body (unknown range-unit) *\/\n\t\t break;\n\n\t\tcase HTTP_PARTIAL:\n\t\t \/* One or more range request(s) *\/\n\t\t txn->resp_body.len = outlen;\n\n\t\t if (txn->resp_body.range->next) {\n\t\t\t\/* Multiple ranges *\/\n\t\t\tmultipart_byteranges(txn, buf);\n\t\t\treturn;\n\t\t }\n\t\t else {\n\t\t\t\/* Single range - set data parameters accordingly *\/\n\t\t\toffset += txn->resp_body.range->first;\n\t\t\toutlen = txn->resp_body.range->last -\n\t\t\t txn->resp_body.range->first + 1;\n\t\t }\n\t\t break;\n\n\t\tcase HTTP_UNSAT_RANGE:\n\t\t \/* No valid ranges *\/\n\t\t outlen = 0;\n\t\t break;\n\t\t}\n\t }\n\n\t if (outlen && do_md5) {\n\t\tMD5Update(&ctx, buf+offset, outlen);\n\t\tMD5Final(md5, &ctx);\n\t\ttxn->resp_body.md5 = md5;\n\t }\n\t}\n\telse if (txn->flags.ver1_0) {\n\t \/* HTTP\/1.0 doesn't support chunked - close-delimit the body *\/\n\t txn->flags.conn = CONN_CLOSE;\n\t}\n\telse if (do_md5) txn->flags.trailer = TRAILER_CMD5;\n\n\tresponse_header(code, txn);\n\n\t\/* MUST NOT send a body for 1xx\/204\/304 response or any HEAD response *\/\n\tswitch (code) {\n\tcase HTTP_CONTINUE:\n\tcase HTTP_SWITCH_PROT:\n\tcase HTTP_PROCESSING:\n\tcase HTTP_NO_CONTENT:\n\tcase HTTP_NOT_MODIFIED:\n\t return;\n\n\tdefault:\n\t if (txn->meth == METH_HEAD) return;\n\t}\n }\n\n \/* Output data *\/\n if ((txn->flags.te & TE_CHUNKED) && !txn->flags.ver1_0) {\n\t\/* HTTP\/1.1 chunk *\/\n\tif (outlen) {\n\t prot_printf(httpd_out, \"%x\\r\\n\", outlen);\n\t prot_write(httpd_out, buf, outlen);\n\t prot_puts(httpd_out, \"\\r\\n\");\n\n\t if (do_md5) MD5Update(&ctx, buf, outlen);\t \n\t}\n\tif (!len) {\n\t \/* Terminate the HTTP\/1.1 body with a zero-length chunk *\/\n\t prot_puts(httpd_out, \"0\\r\\n\");\n\n\t \/* Trailer *\/\n\t if (do_md5) {\n\t\tMD5Final(md5, &ctx);\n\t\tContent_MD5(md5);\n\t }\n\n\t prot_puts(httpd_out, \"\\r\\n\");\n\t}\n }\n else {\n\t\/* Full body or HTTP\/1.0 close-delimited body *\/\n\tprot_write(httpd_out, buf + offset, outlen);\n }\n}","target":0,"code_token_length":1238,"total_token_length":1474,"max_tokens_setting":2048} +{"idx":393872,"func":"dissect_80211n_mac(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int data_len, gboolean add_subtree, guint32 *n_mac_flags, guint32 *ampdu_id, struct ieee_802_11_phdr *phdr)\n{\n proto_tree *ftree = tree;\n ptvcursor_t *csr;\n int subtree_off = add_subtree ? 4 : 0;\n guint32 flags;\n\n phdr->phy = PHDR_802_11_PHY_11N;\n\n *n_mac_flags = tvb_get_letohl(tvb, offset + subtree_off);\n *ampdu_id = tvb_get_letohl(tvb, offset + 4 + subtree_off);\n\n if (add_subtree) {\n ftree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_dot11n_mac, NULL, \"802.11n MAC\");\n add_ppi_field_header(tvb, ftree, &offset);\n data_len -= 4; \/* Subtract field header length *\/\n }\n\n if (data_len != PPI_80211N_MAC_LEN) {\n proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, \"Invalid length: %u\", data_len);\n THROW(ReportedBoundsError);\n }\n\n csr = ptvcursor_new(ftree, tvb, offset);\n\n flags = tvb_get_letohl(tvb, ptvcursor_current_offset(csr));\n phdr->phy_info.info_11n.presence_flags = PHDR_802_11N_HAS_SHORT_GI|PHDR_802_11N_HAS_GREENFIELD;\n phdr->phy_info.info_11n.short_gi = ((flags & DOT11N_FLAG_SHORT_GI) != 0);\n phdr->phy_info.info_11n.greenfield = ((flags & DOT11N_FLAG_GREENFIELD) != 0);\n ptvcursor_add_with_subtree(csr, hf_80211n_mac_flags, 4, ENC_LITTLE_ENDIAN,\n ett_dot11n_mac_flags);\n ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_greenfield, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_ht20_40, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_rx_guard_interval, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_duplicate_rx, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_aggregate, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_more_aggregates, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add(csr, hf_80211n_mac_flags_delimiter_crc_after, 4, ENC_LITTLE_ENDIAN); \/* Last *\/\n ptvcursor_pop_subtree(csr);\n\n ptvcursor_add(csr, hf_80211n_mac_ampdu_id, 4, ENC_LITTLE_ENDIAN);\n ptvcursor_add(csr, hf_80211n_mac_num_delimiters, 1, ENC_LITTLE_ENDIAN);\n\n if (add_subtree) {\n ptvcursor_add(csr, hf_80211n_mac_reserved, 3, ENC_LITTLE_ENDIAN);\n }\n\n ptvcursor_free(csr);\n}","target":0,"code_token_length":836,"total_token_length":1072,"max_tokens_setting":2048} +{"idx":398569,"func":"static plist_t parse_bin_node(struct bplist_data *bplist, const char** object)\n{\n uint16_t type = 0;\n uint64_t size = 0;\n\n if (!object)\n return NULL;\n\n type = (**object) & BPLIST_MASK;\n size = (**object) & BPLIST_FILL;\n (*object)++;\n\n switch (type)\n {\n\n case BPLIST_NULL:\n switch (size)\n {\n\n case BPLIST_TRUE:\n {\n plist_data_t data = plist_new_plist_data();\n data->type = PLIST_BOOLEAN;\n data->boolval = TRUE;\n data->length = 1;\n return node_create(NULL, data);\n }\n\n case BPLIST_FALSE:\n {\n plist_data_t data = plist_new_plist_data();\n data->type = PLIST_BOOLEAN;\n data->boolval = FALSE;\n data->length = 1;\n return node_create(NULL, data);\n }\n\n case BPLIST_NULL:\n default:\n return NULL;\n }\n\n case BPLIST_UINT:\n if (*object - bplist->data + (uint64_t)(1 << size) >= bplist->size)\n return NULL;\n return parse_uint_node(object, size);\n\n case BPLIST_REAL:\n if (*object - bplist->data + (uint64_t)(1 << size) >= bplist->size)\n return NULL;\n return parse_real_node(object, size);\n\n case BPLIST_DATE:\n if (3 != size)\n return NULL;\n if (*object - bplist->data + (uint64_t)(1 << size) >= bplist->size)\n return NULL;\n return parse_date_node(object, size);\n\n case BPLIST_DATA:\n if (BPLIST_FILL == size) {\n uint8_t next_size = **object & BPLIST_FILL;\n if ((**object & BPLIST_MASK) != BPLIST_UINT)\n return NULL;\n (*object)++;\n size = UINT_TO_HOST(*object, (1 << next_size));\n (*object) += (1 << next_size);\n }\n\n if (*object - bplist->data + size >= bplist->size)\n return NULL;\n return parse_data_node(object, size);\n\n case BPLIST_STRING:\n if (BPLIST_FILL == size) {\n uint8_t next_size = **object & BPLIST_FILL;\n if ((**object & BPLIST_MASK) != BPLIST_UINT)\n return NULL;\n (*object)++;\n size = UINT_TO_HOST(*object, (1 << next_size));\n (*object) += (1 << next_size);\n }\n\n if (*object - bplist->data + size >= bplist->size)\n return NULL;\n return parse_string_node(object, size);\n\n case BPLIST_UNICODE:\n if (BPLIST_FILL == size) {\n uint8_t next_size = **object & BPLIST_FILL;\n if ((**object & BPLIST_MASK) != BPLIST_UINT)\n return NULL;\n (*object)++;\n size = UINT_TO_HOST(*object, (1 << next_size));\n (*object) += (1 << next_size);\n }\n\n if (*object - bplist->data + size * 2 >= bplist->size)\n return NULL;\n return parse_unicode_node(object, size);\n\n case BPLIST_SET:\n case BPLIST_ARRAY:\n if (BPLIST_FILL == size) {\n uint8_t next_size = **object & BPLIST_FILL;\n if ((**object & BPLIST_MASK) != BPLIST_UINT)\n return NULL;\n (*object)++;\n size = UINT_TO_HOST(*object, (1 << next_size));\n (*object) += (1 << next_size);\n }\n\n if (*object - bplist->data + size >= bplist->size)\n return NULL;\n return parse_array_node(bplist, object, size);\n\n case BPLIST_UID:\n return parse_uid_node(object, size);\n\n case BPLIST_DICT:\n if (BPLIST_FILL == size) {\n\t uint8_t next_size = **object & BPLIST_FILL;\n if ((**object & BPLIST_MASK) != BPLIST_UINT)\n return NULL;\n (*object)++;\n size = UINT_TO_HOST(*object, (1 << next_size));\n (*object) += (1 << next_size);\n }\n\n if (*object - bplist->data + size >= bplist->size)\n return NULL;\n return parse_dict_node(bplist, object, size);\n default:\n return NULL;\n }\n return NULL;\n}","target":0,"code_token_length":1002,"total_token_length":1238,"max_tokens_setting":2048} +{"idx":509588,"func":"static void test_fetch_column()\n{\n MYSQL_STMT *stmt;\n MYSQL_BIND my_bind[2];\n char c2[20], bc2[20];\n ulong l1, l2, bl1, bl2;\n int rc, c1, bc1;\n\n myheader(\"test_fetch_column\");\n\n rc= mysql_query(mysql, \"drop table if exists t1\");\n myquery(rc);\n\n rc= mysql_query(mysql, \"create table t1(c1 int primary key auto_increment, c2 char(10))\");\n myquery(rc);\n\n rc= mysql_query(mysql, \"insert into t1(c2) values('venu'), ('mysql')\");\n myquery(rc);\n\n stmt= mysql_simple_prepare(mysql, \"select * from t1 order by c2 desc\");\n check_stmt(stmt);\n\n bzero((char*) my_bind, sizeof(my_bind));\n my_bind[0].buffer_type= MYSQL_TYPE_LONG;\n my_bind[0].buffer= (void *)&bc1;\n my_bind[0].buffer_length= 0;\n my_bind[0].is_null= 0;\n my_bind[0].length= &bl1;\n my_bind[1].buffer_type= MYSQL_TYPE_STRING;\n my_bind[1].buffer= (void *)bc2;\n my_bind[1].buffer_length= 7;\n my_bind[1].is_null= 0;\n my_bind[1].length= &bl2;\n\n rc= mysql_stmt_execute(stmt);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_bind_result(stmt, my_bind);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_store_result(stmt);\n check_execute(stmt, rc);\n\n rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0); \/* No-op at this point *\/\n check_execute_r(stmt, rc);\n\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent)\n fprintf(stdout, \"\\n row 0: %d, %s\", bc1, bc2);\n\n c2[0]= '\\0'; l2= 0;\n my_bind[0].buffer_type= MYSQL_TYPE_STRING;\n my_bind[0].buffer= (void *)c2;\n my_bind[0].buffer_length= 7;\n my_bind[0].is_null= 0;\n my_bind[0].length= &l2;\n\n rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0);\n check_execute(stmt, rc);\n if (!opt_silent)\n fprintf(stdout, \"\\n col 1: %s(%ld)\", c2, l2);\n DIE_UNLESS(strncmp(c2, \"venu\", 4) == 0 && l2 == 4);\n\n c2[0]= '\\0'; l2= 0;\n rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0);\n check_execute(stmt, rc);\n if (!opt_silent)\n fprintf(stdout, \"\\n col 1: %s(%ld)\", c2, l2);\n DIE_UNLESS(strcmp(c2, \"venu\") == 0 && l2 == 4);\n\n c1= 0;\n my_bind[0].buffer_type= MYSQL_TYPE_LONG;\n my_bind[0].buffer= (void *)&c1;\n my_bind[0].buffer_length= 0;\n my_bind[0].is_null= 0;\n my_bind[0].length= &l1;\n\n rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);\n check_execute(stmt, rc);\n if (!opt_silent)\n fprintf(stdout, \"\\n col 0: %d(%ld)\", c1, l1);\n DIE_UNLESS(c1 == 1 && l1 == 4);\n\n rc= mysql_stmt_fetch(stmt);\n check_execute(stmt, rc);\n\n if (!opt_silent)\n fprintf(stdout, \"\\n row 1: %d, %s\", bc1, bc2);\n\n c2[0]= '\\0'; l2= 0;\n my_bind[0].buffer_type= MYSQL_TYPE_STRING;\n my_bind[0].buffer= (void *)c2;\n my_bind[0].buffer_length= 7;\n my_bind[0].is_null= 0;\n my_bind[0].length= &l2;\n\n rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0);\n check_execute(stmt, rc);\n if (!opt_silent)\n fprintf(stdout, \"\\n col 1: %s(%ld)\", c2, l2);\n DIE_UNLESS(strncmp(c2, \"mysq\", 4) == 0 && l2 == 5);\n\n c2[0]= '\\0'; l2= 0;\n rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0);\n check_execute(stmt, rc);\n if (!opt_silent)\n fprintf(stdout, \"\\n col 1: %si(%ld)\", c2, l2);\n DIE_UNLESS(strcmp(c2, \"mysql\") == 0 && l2 == 5);\n\n c1= 0;\n my_bind[0].buffer_type= MYSQL_TYPE_LONG;\n my_bind[0].buffer= (void *)&c1;\n my_bind[0].buffer_length= 0;\n my_bind[0].is_null= 0;\n my_bind[0].length= &l1;\n\n rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);\n check_execute(stmt, rc);\n if (!opt_silent)\n fprintf(stdout, \"\\n col 0: %d(%ld)\", c1, l1);\n DIE_UNLESS(c1 == 2 && l1 == 4);\n\n rc= mysql_stmt_fetch(stmt);\n DIE_UNLESS(rc == MYSQL_NO_DATA);\n\n rc= mysql_stmt_fetch_column(stmt, my_bind, 1, 0);\n check_execute_r(stmt, rc);\n\n mysql_stmt_close(stmt);\n myquery(mysql_query(mysql, \"drop table t1\"));\n}","target":0,"code_token_length":1321,"total_token_length":1557,"max_tokens_setting":2048} +{"idx":72081,"func":"static int _sx_sasl_gsasl_callback(Gsasl *gsasl_ctx, Gsasl_session *sd, Gsasl_property prop) {\n _sx_sasl_sess_t sctx = gsasl_session_hook_get(sd);\n _sx_sasl_t ctx = NULL;\n struct sx_sasl_creds_st creds = {NULL, NULL, NULL, NULL};\n char *value, *node, *host;\n int len, i;\n\n \/*\n * session hook data is not always available while its being set up,\n * also not needed in many of the cases below.\n *\/\n if(sctx != NULL) {\n ctx = sctx->ctx;\n }\n\n _sx_debug(ZONE, \"in _sx_sasl_gsasl_callback, property: %d\", prop);\n\n switch(prop) {\n case GSASL_PASSWORD:\n \/* GSASL_AUTHID, GSASL_AUTHZID, GSASL_REALM *\/\n assert(ctx);\n assert(ctx->cb);\n creds.authnid = gsasl_property_fast(sd, GSASL_AUTHID);\n creds.realm = gsasl_property_fast(sd, GSASL_REALM);\n if(!creds.authnid) return GSASL_NO_AUTHID;\n if(!creds.realm) return GSASL_NO_AUTHZID;\n if((ctx->cb)(sx_sasl_cb_GET_PASS, &creds, (void **)&value, sctx->s, ctx->cbarg) == sx_sasl_ret_OK) {\n gsasl_property_set(sd, GSASL_PASSWORD, value);\n }\n return GSASL_NEEDS_MORE;\n\n case GSASL_SERVICE:\n gsasl_property_set(sd, GSASL_SERVICE, \"xmpp\");\n return GSASL_OK;\n\n case GSASL_HOSTNAME:\n {\n char hostname[256];\n \/* get hostname *\/\n hostname[0] = '\\0';\n gethostname(hostname, 256);\n hostname[255] = '\\0';\n\n gsasl_property_set(sd, GSASL_HOSTNAME, hostname);\n }\n return GSASL_OK;\n\n case GSASL_VALIDATE_SIMPLE:\n \/* GSASL_AUTHID, GSASL_AUTHZID, GSASL_PASSWORD *\/\n assert(ctx);\n assert(ctx->cb);\n creds.authnid = gsasl_property_fast(sd, GSASL_AUTHID);\n creds.realm = gsasl_property_fast(sd, GSASL_REALM);\n creds.pass = gsasl_property_fast(sd, GSASL_PASSWORD);\n if(!creds.authnid) return GSASL_NO_AUTHID;\n if(!creds.realm) return GSASL_NO_AUTHZID;\n if(!creds.pass) return GSASL_NO_PASSWORD;\n if((ctx->cb)(sx_sasl_cb_CHECK_PASS, &creds, NULL, sctx->s, ctx->cbarg) == sx_sasl_ret_OK)\n return GSASL_OK;\n else\n return GSASL_AUTHENTICATION_ERROR;\n\n case GSASL_VALIDATE_GSSAPI:\n \/* GSASL_AUTHZID, GSASL_GSSAPI_DISPLAY_NAME *\/\n creds.authnid = gsasl_property_fast(sd, GSASL_GSSAPI_DISPLAY_NAME);\n if(!creds.authnid) return GSASL_NO_AUTHID;\n creds.authzid = gsasl_property_fast(sd, GSASL_AUTHZID);\n if(!creds.authzid) return GSASL_NO_AUTHZID;\n gsasl_property_set(sd, GSASL_AUTHID, creds.authnid);\n return GSASL_OK;\n\n case GSASL_VALIDATE_ANONYMOUS:\n \/* GSASL_ANONYMOUS_TOKEN *\/\n creds.authnid = gsasl_property_fast(sd, GSASL_ANONYMOUS_TOKEN);\n if(!creds.authnid) return GSASL_NO_ANONYMOUS_TOKEN;\n \/* set token as authid for later use *\/\n gsasl_property_set(sd, GSASL_AUTHID, creds.authnid);\n return GSASL_OK;\n\n case GSASL_VALIDATE_EXTERNAL:\n \/* GSASL_AUTHID *\/\n assert(ctx);\n assert(ctx->ext_id);\n creds.authzid = gsasl_property_fast(sd, GSASL_AUTHZID);\n _sx_debug(ZONE, \"sasl external\");\n _sx_debug(ZONE, \"sasl creds.authzid is '%s'\", creds.authzid);\n\n for (i = 0; i < SX_CONN_EXTERNAL_ID_MAX_COUNT; i++) {\n if (ctx->ext_id[i] == NULL)\n break;\n _sx_debug(ZONE, \"sasl ext_id(%d) is '%s'\", i, ctx->ext_id[i]);\n \/* XXX hackish.. detect c2s by existance of @ *\/\n value = strstr(ctx->ext_id[i], \"@\");\n\n if(value == NULL && creds.authzid != NULL && strcmp(ctx->ext_id[i], creds.authzid) == 0) {\n \/\/ s2s connection and it's valid\n \/* TODO Handle wildcards and other thigs from XEP-0178 *\/\n _sx_debug(ZONE, \"sasl ctx->ext_id doesn't have '@' in it. Assuming s2s\");\n return GSASL_OK;\n }\n if(value != NULL &&\n ((creds.authzid != NULL && strcmp(ctx->ext_id[i], creds.authzid) == 0) ||\n (creds.authzid == NULL)) ) {\n \/\/ c2s connection\n \/\/ creds.authzid == NULL condition is from XEP-0178 '=' auth reply\n\n \/\/ This should be freed by gsasl_finish() but I'm not sure\n \/\/ node = authnid\n len = value - ctx->ext_id[i];\n node = (char *) malloc(sizeof(char) * (len + 1)); \/\/ + null termination\n strncpy(node, ctx->ext_id[i], len);\n node[len] = '\\0'; \/\/ null terminate the string\n \/\/ host = realm\n len = strlen(value) - 1 + 1; \/\/ - the @ + null termination\n host = (char *) malloc(sizeof(char) * (len));\n strcpy(host, value + 1); \/\/ skip the @\n gsasl_property_set(sd, GSASL_AUTHID, node);\n gsasl_property_set(sd, GSASL_REALM, host);\n return GSASL_OK;\n }\n\n }\n return GSASL_AUTHENTICATION_ERROR;\n\n default:\n break;\n }\n\n return GSASL_NO_CALLBACK;\n}","target":0,"code_token_length":1395,"total_token_length":1631,"max_tokens_setting":2048} +{"idx":70633,"func":"static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,\n int uncompressed_size, EXRThreadData *td) {\n const int8_t *sr = src;\n int stay_to_uncompress = compressed_size;\n int nb_b44_block_w, nb_b44_block_h;\n int index_tl_x, index_tl_y, index_out, index_tmp;\n uint16_t tmp_buffer[16]; \/* B44 use 4x4 half float pixel *\/\n int c, iY, iX, y, x;\n int target_channel_offset = 0;\n\n \/* calc B44 block count *\/\n nb_b44_block_w = td->xsize \/ 4;\n if ((td->xsize % 4) != 0)\n nb_b44_block_w++;\n\n nb_b44_block_h = td->ysize \/ 4;\n if ((td->ysize % 4) != 0)\n nb_b44_block_h++;\n\n for (c = 0; c < s->nb_channels; c++) {\n if (s->channels[c].pixel_type == EXR_HALF) {\/* B44 only compress half float data *\/\n for (iY = 0; iY < nb_b44_block_h; iY++) {\n for (iX = 0; iX < nb_b44_block_w; iX++) {\/* For each B44 block *\/\n if (stay_to_uncompress < 3) {\n av_log(s, AV_LOG_ERROR, \"Not enough data for B44A block: %d\", stay_to_uncompress);\n return AVERROR_INVALIDDATA;\n }\n\n if (src[compressed_size - stay_to_uncompress + 2] == 0xfc) { \/* B44A block *\/\n unpack_3(sr, tmp_buffer);\n sr += 3;\n stay_to_uncompress -= 3;\n } else {\/* B44 Block *\/\n if (stay_to_uncompress < 14) {\n av_log(s, AV_LOG_ERROR, \"Not enough data for B44 block: %d\", stay_to_uncompress);\n return AVERROR_INVALIDDATA;\n }\n unpack_14(sr, tmp_buffer);\n sr += 14;\n stay_to_uncompress -= 14;\n }\n\n \/* copy data to uncompress buffer (B44 block can exceed target resolution)*\/\n index_tl_x = iX * 4;\n index_tl_y = iY * 4;\n\n for (y = index_tl_y; y < FFMIN(index_tl_y + 4, td->ysize); y++) {\n for (x = index_tl_x; x < FFMIN(index_tl_x + 4, td->xsize); x++) {\n index_out = target_channel_offset * td->xsize + y * td->channel_line_size + 2 * x;\n index_tmp = (y-index_tl_y) * 4 + (x-index_tl_x);\n td->uncompressed_data[index_out] = tmp_buffer[index_tmp] & 0xff;\n td->uncompressed_data[index_out + 1] = tmp_buffer[index_tmp] >> 8;\n }\n }\n }\n }\n target_channel_offset += 2;\n } else {\/* Float or UINT 32 channel *\/\n if (stay_to_uncompress < td->ysize * td->xsize * 4) {\n av_log(s, AV_LOG_ERROR, \"Not enough data for uncompress channel: %d\", stay_to_uncompress);\n return AVERROR_INVALIDDATA;\n }\n\n for (y = 0; y < td->ysize; y++) {\n index_out = target_channel_offset * td->xsize + y * td->channel_line_size;\n memcpy(&td->uncompressed_data[index_out], sr, td->xsize * 4);\n sr += td->xsize * 4;\n }\n target_channel_offset += 4;\n\n stay_to_uncompress -= td->ysize * td->xsize * 4;\n }\n }\n\n return 0;\n}","target":0,"code_token_length":882,"total_token_length":1118,"max_tokens_setting":2048} +{"idx":103065,"func":"void xmc4400EthInitGpio(NetInterface *interface)\n{\n uint32_t temp;\n\n \/\/Configure ETH0.TX_EN (P0.4)\n temp = PORT0->IOCR4;\n temp &= ~PORT0_IOCR4_PC4_Msk;\n temp |= (17UL << PORT0_IOCR4_PC4_Pos);\n PORT0->IOCR4 = temp;\n\n \/\/Configure ETH0.MDIO (P2.0), ETH0.RXD0A (P2.2) and ETH0.RXD1A (P2.3)\n temp = PORT2->IOCR0;\n temp &= ~(PORT2_IOCR0_PC0_Msk | PORT2_IOCR0_PC2_Msk | PORT2_IOCR0_PC3_Msk);\n temp |= (0UL << PORT2_IOCR0_PC0_Pos) | (0UL << PORT2_IOCR0_PC2_Pos) | (0UL << PORT2_IOCR0_PC3_Pos);\n PORT2->IOCR0 = temp;\n\n \/\/Configure ETH0.RXERA (P2.4)and ETH0.MDC (P2.7)\n temp = PORT2->IOCR4;\n temp &= ~(PORT2_IOCR4_PC4_Msk | PORT2_IOCR4_PC7_Msk);\n temp |= (0UL << PORT2_IOCR4_PC4_Pos) | (17UL << PORT2_IOCR4_PC7_Pos);\n PORT2->IOCR4 = temp;\n\n \/\/Configure ETH0.TXD0 (P2.8) and ETH0.TXD1 (P2.9)\n temp = PORT2->IOCR8;\n temp &= ~(PORT2_IOCR8_PC8_Msk | PORT2_IOCR8_PC9_Msk);\n temp |= (17UL << PORT2_IOCR8_PC8_Pos) | (17UL << PORT2_IOCR8_PC9_Pos);\n PORT2->IOCR8 = temp;\n\n \/\/Configure ETH0.CLK_RMIIC (P15.8) and ETH0.CRS_DVC (P15.9)\n temp = PORT15->IOCR8;\n temp &= ~(PORT15_IOCR8_PC8_Msk | PORT15_IOCR8_PC9_Msk);\n temp |= (0UL << PORT15_IOCR8_PC8_Pos) | (0UL << PORT15_IOCR8_PC9_Pos);\n PORT15->IOCR8 = temp;\n\n \/\/Assign ETH_MDIO (P2.0) to HW0\n temp = PORT2->HWSEL & ~PORT2_HWSEL_HW0_Msk;\n PORT2->HWSEL = temp | (1UL << PORT2_HWSEL_HW0_Pos);\n\n \/\/Select output driver strength for ETH0.TX_EN (P2.5)\n temp = PORT2->PDR0;\n temp &= ~PORT2_PDR0_PD5_Msk;\n temp |= (0UL << PORT2_PDR0_PD5_Pos);\n PORT2->PDR0 = temp;\n\n \/\/Select output driver strength for ETH0.TXD0 (P2.8) and ETH0.TXD1 (P2.9)\n temp = PORT2->PDR1;\n temp &= ~(PORT2_PDR1_PD8_Msk | PORT2_PDR1_PD9_Msk);\n temp |= (0UL << PORT2_PDR1_PD8_Pos) | (0UL << PORT2_PDR1_PD9_Pos);\n PORT2->PDR1 = temp;\n\n \/\/Use ETH0.CLK_RMIIC (P15.8) and ETH0.CRS_DVC (P15.9) as digital inputs\n PORT15->PDISC &= ~(PORT15_PDISC_PDIS8_Msk | PORT15_PDISC_PDIS9_Msk);\n\n \/\/Select RMII operation mode\n ETH0_CON->CON = ETH_CON_INFSEL_Msk | ETH_CON_MDIO_B | ETH_CON_RXER_A |\n ETH_CON_CRS_DV_C | ETH_CON_CLK_RMII_C | ETH_CON_RXD1_A | ETH_CON_RXD0_A;\n}","target":0,"code_token_length":885,"total_token_length":1121,"max_tokens_setting":2048} +{"idx":352943,"func":"static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, IDWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){\n const int b_width = s->b_width << s->block_max_depth;\n const int b_height= s->b_height << s->block_max_depth;\n const int b_stride= b_width;\n BlockNode *lt= &s->block[b_x + b_y*b_stride];\n BlockNode *rt= lt+1;\n BlockNode *lb= lt+b_stride;\n BlockNode *rb= lb+1;\n uint8_t *block[4];\n int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;\n uint8_t *tmp = s->scratchbuf;\n uint8_t *ptmp;\n int x,y;\n\n if(b_x<0){\n lt= rt;\n lb= rb;\n }else if(b_x + 1 >= b_width){\n rt= lt;\n rb= lb;\n }\n if(b_y<0){\n lt= lb;\n rt= rb;\n }else if(b_y + 1 >= b_height){\n lb= lt;\n rb= rt;\n }\n\n if(src_x<0){ \/\/FIXME merge with prev & always round internal width up to *16\n obmc -= src_x;\n b_w += src_x;\n if(!sliced && !offset_dst)\n dst -= src_x;\n src_x=0;\n }else if(src_x + b_w > w){\n b_w = w - src_x;\n }\n if(src_y<0){\n obmc -= src_y*obmc_stride;\n b_h += src_y;\n if(!sliced && !offset_dst)\n dst -= src_y*dst_stride;\n src_y=0;\n }else if(src_y + b_h> h){\n b_h = h - src_y;\n }\n\n if(b_w<=0 || b_h<=0) return;\n\n av_assert2(src_stride > 2*MB_SIZE + 5);\n\n if(!sliced && offset_dst)\n dst += src_x + src_y*dst_stride;\n dst8+= src_x + src_y*src_stride;\n\/\/ src += src_x + src_y*src_stride;\n\n ptmp= tmp + 3*tmp_step;\n block[0]= ptmp;\n ptmp+=tmp_step;\n ff_snow_pred_block(s, block[0], tmp, src_stride, src_x, src_y, b_w, b_h, lt, plane_index, w, h);\n\n if(same_block(lt, rt)){\n block[1]= block[0];\n }else{\n block[1]= ptmp;\n ptmp+=tmp_step;\n ff_snow_pred_block(s, block[1], tmp, src_stride, src_x, src_y, b_w, b_h, rt, plane_index, w, h);\n }\n\n if(same_block(lt, lb)){\n block[2]= block[0];\n }else if(same_block(rt, lb)){\n block[2]= block[1];\n }else{\n block[2]= ptmp;\n ptmp+=tmp_step;\n ff_snow_pred_block(s, block[2], tmp, src_stride, src_x, src_y, b_w, b_h, lb, plane_index, w, h);\n }\n\n if(same_block(lt, rb) ){\n block[3]= block[0];\n }else if(same_block(rt, rb)){\n block[3]= block[1];\n }else if(same_block(lb, rb)){\n block[3]= block[2];\n }else{\n block[3]= ptmp;\n ff_snow_pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h);\n }\n if(sliced){\n s->dwt.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);\n }else{\n for(y=0; y>1);\n const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);\n const uint8_t *obmc4= obmc3+ (obmc_stride>>1);\n for(x=0; x>= 8 - FRAC_BITS;\n }\n if(add){\n v += dst[x + y*dst_stride];\n v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS;\n if(v&(~255)) v= ~(v>>31);\n dst8[x + y*src_stride] = v;\n }else{\n dst[x + y*dst_stride] -= v;\n }\n }\n }\n }\n}","target":1,"code_token_length":1290,"total_token_length":1526,"max_tokens_setting":2048} +{"idx":80526,"func":"static pj_bool_t ssock_on_accept_complete (pj_ssl_sock_t *ssock_parent,\n\t\t\t\t\t pj_sock_t newsock,\n\t\t\t\t\t void *newconn,\n\t\t\t\t\t const pj_sockaddr_t *src_addr,\n\t\t\t\t\t int src_addr_len,\n\t\t\t\t\t pj_status_t accept_status)\n{\n pj_ssl_sock_t *ssock;\n#ifndef SSL_SOCK_IMP_USE_OWN_NETWORK\n pj_activesock_cb asock_cb;\n#endif\n pj_activesock_cfg asock_cfg;\n unsigned i;\n pj_status_t status;\n\n#ifndef SSL_SOCK_IMP_USE_OWN_NETWORK\n PJ_UNUSED_ARG(newconn);\n#endif\n\n if (accept_status != PJ_SUCCESS) {\n\tif (ssock_parent->param.cb.on_accept_complete2) {\n\t (*ssock_parent->param.cb.on_accept_complete2)(ssock_parent, NULL,\n\t\t\t\t\t\t \t src_addr,\n\t\t\t\t\t\t \t src_addr_len,\n\t\t\t\t\t\t \t accept_status);\n\t}\n\treturn PJ_TRUE;\n }\n\n \/* Create new SSL socket instance *\/\n status = pj_ssl_sock_create(ssock_parent->pool,\n\t\t\t\t&ssock_parent->newsock_param, &ssock);\n if (status != PJ_SUCCESS)\n\tgoto on_return;\n\n \/* Set parent and add ref count (avoid parent destroy during handshake) *\/\n ssock->parent = ssock_parent;\n if (ssock->parent->param.grp_lock)\n\tpj_grp_lock_add_ref(ssock->parent->param.grp_lock);\n\n \/* Update new SSL socket attributes *\/\n ssock->sock = newsock;\n ssock->is_server = PJ_TRUE;\n if (ssock_parent->cert) {\n\tstatus = pj_ssl_sock_set_certificate(ssock, ssock->pool, \n\t\t\t\t\t ssock_parent->cert);\n\tif (status != PJ_SUCCESS)\n\t goto on_return;\n }\n\n \/* Set local address *\/\n ssock->addr_len = src_addr_len;\n pj_sockaddr_cp(&ssock->local_addr, &ssock_parent->local_addr);\n\n \/* Set remote address *\/\n pj_sockaddr_cp(&ssock->rem_addr, src_addr);\n\n \/* Create SSL context *\/\n status = ssl_create(ssock);\n if (status != PJ_SUCCESS)\n\tgoto on_return;\n\n \/* Prepare read buffer *\/\n ssock->asock_rbuf = (void**)pj_pool_calloc(ssock->pool, \n\t\t\t\t\t ssock->param.async_cnt,\n\t\t\t\t\t sizeof(void*));\n if (!ssock->asock_rbuf) {\n\tstatus = PJ_ENOMEM;\n\tgoto on_return;\n }\n\n for (i = 0; iparam.async_cnt; ++i) {\n\tssock->asock_rbuf[i] = (void*) pj_pool_alloc(\n\t\t\t\t\t ssock->pool, \n\t\t\t\t\t ssock->param.read_buffer_size + \n\t\t\t\t\t sizeof(read_data_t*));\n\tif (!ssock->asock_rbuf[i]) {\n\t status = PJ_ENOMEM;\n\t goto on_return;\n\t}\n }\n\n \/* If listener socket has group lock, automatically create group lock\n * for the new socket.\n *\/\n if (ssock_parent->param.grp_lock) {\n\tpj_grp_lock_t *glock;\n\n\tstatus = pj_grp_lock_create(ssock->pool, NULL, &glock);\n\tif (status != PJ_SUCCESS)\n\t goto on_return;\n\n\tpj_grp_lock_add_ref(glock);\n\tssock->param.grp_lock = glock;\n\tpj_grp_lock_add_handler(ssock->param.grp_lock, ssock->pool, ssock,\n\t\t\t\tssl_on_destroy);\n }\n\n#ifdef SSL_SOCK_IMP_USE_OWN_NETWORK\n status = network_setup_connection(ssock, newconn);\n if (status != PJ_SUCCESS)\n\tgoto on_return;\n\n#else\n \/* Apply QoS, if specified *\/\n status = pj_sock_apply_qos2(ssock->sock, ssock->param.qos_type,\n\t\t\t\t&ssock->param.qos_params, 1, \n\t\t\t\tssock->pool->obj_name, NULL);\n if (status != PJ_SUCCESS && !ssock->param.qos_ignore_error)\n\tgoto on_return;\n\n \/* Apply socket options, if specified *\/\n if (ssock->param.sockopt_params.cnt) {\n\tstatus = pj_sock_setsockopt_params(ssock->sock, \n\t\t\t\t\t &ssock->param.sockopt_params);\n\tif (status != PJ_SUCCESS && !ssock->param.sockopt_ignore_error)\n\t goto on_return;\n }\n\n \/* Create active socket *\/\n pj_activesock_cfg_default(&asock_cfg);\n asock_cfg.grp_lock = ssock->param.grp_lock;\n asock_cfg.async_cnt = ssock->param.async_cnt;\n asock_cfg.concurrency = ssock->param.concurrency;\n asock_cfg.whole_data = PJ_TRUE;\n\n pj_bzero(&asock_cb, sizeof(asock_cb));\n asock_cb.on_data_read = asock_on_data_read;\n asock_cb.on_data_sent = asock_on_data_sent;\n\n status = pj_activesock_create(ssock->pool,\n\t\t\t\t ssock->sock, \n\t\t\t\t ssock->param.sock_type,\n\t\t\t\t &asock_cfg,\n\t\t\t\t ssock->param.ioqueue, \n\t\t\t\t &asock_cb,\n\t\t\t\t ssock,\n\t\t\t\t &ssock->asock);\n\n if (status != PJ_SUCCESS)\n\tgoto on_return;\n\n \/* Start read *\/\n status = pj_activesock_start_read2(ssock->asock, ssock->pool, \n\t\t\t\t (unsigned)ssock->param.read_buffer_size,\n\t\t\t\t ssock->asock_rbuf,\n\t\t\t\t PJ_IOQUEUE_ALWAYS_ASYNC);\n if (status != PJ_SUCCESS)\n\tgoto on_return;\n#endif\n\n \/* Update local address *\/\n status = get_localaddr(ssock, &ssock->local_addr, &ssock->addr_len);\n if (status != PJ_SUCCESS) {\n\t\/* This fails on few envs, e.g: win IOCP, just tolerate this and\n\t * use parent local address instead.\n\t *\/\n\tpj_sockaddr_cp(&ssock->local_addr, &ssock_parent->local_addr);\n }\n\n \/* Prepare write\/send state *\/\n pj_assert(ssock->send_buf.max_len == 0);\n ssock->send_buf.buf = (char*)\n\t\t\t pj_pool_alloc(ssock->pool, \n\t\t\t\t\tssock->param.send_buffer_size);\n if (!ssock->send_buf.buf)\n return PJ_ENOMEM;\n\n ssock->send_buf.max_len = ssock->param.send_buffer_size;\n ssock->send_buf.start = ssock->send_buf.buf;\n ssock->send_buf.len = 0;\n\n \/* Start handshake timer *\/\n if (ssock->param.timer_heap && (ssock->param.timeout.sec != 0 ||\n\tssock->param.timeout.msec != 0))\n {\n\tpj_assert(ssock->timer.id == TIMER_NONE);\n\tstatus = pj_timer_heap_schedule_w_grp_lock(ssock->param.timer_heap, \n\t\t\t\t\t\t &ssock->timer,\n\t\t\t\t\t\t &ssock->param.timeout,\n\t\t\t\t\t\t TIMER_HANDSHAKE_TIMEOUT,\n\t\t\t\t\t\t ssock->param.grp_lock);\n\tif (status != PJ_SUCCESS) {\n\t ssock->timer.id = TIMER_NONE;\n\t status = PJ_SUCCESS;\n\t}\n }\n\n \/* Start SSL handshake *\/\n ssock->ssl_state = SSL_STATE_HANDSHAKING;\n ssl_set_state(ssock, PJ_TRUE);\n status = ssl_do_handshake(ssock);\n\non_return:\n if (ssock && status != PJ_EPENDING) {\n\ton_handshake_complete(ssock, status);\n }\n\n \/* Must return PJ_TRUE whatever happened, as we must continue listening *\/\n return PJ_TRUE;\n}","target":0,"code_token_length":1579,"total_token_length":1815,"max_tokens_setting":2048} +{"idx":265300,"func":"rfbBool rfbSendFileTransferChunk(rfbClientPtr cl)\n{\n \/* Allocate buffer for compression *\/\n char readBuf[sz_rfbBlockSize];\n int bytesRead=0;\n int retval=0;\n fd_set wfds;\n struct timeval tv;\n int n;\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n unsigned char compBuf[sz_rfbBlockSize + 1024];\n unsigned long nMaxCompSize = sizeof(compBuf);\n int nRetC = 0;\n#endif\n\n \/*\n * Don't close the client if we get into this one because \n * it is called from many places to service file transfers.\n * Note that permitFileTransfer is checked first.\n *\/\n if (cl->screen->permitFileTransfer != TRUE ||\n (cl->screen->getFileTransferPermission != NULL\n && cl->screen->getFileTransferPermission(cl) != TRUE)) { \n\t\treturn TRUE;\n }\n\n \/* If not sending, or no file open... Return as if we sent something! *\/\n if ((cl->fileTransfer.fd!=-1) && (cl->fileTransfer.sending==1))\n {\n\tFD_ZERO(&wfds);\n FD_SET(cl->sock, &wfds);\n\n \/* return immediately *\/\n\ttv.tv_sec = 0; \n\ttv.tv_usec = 0;\n\tn = select(cl->sock + 1, NULL, &wfds, NULL, &tv);\n\n\tif (n<0) {\n#ifdef WIN32\n\t errno=WSAGetLastError();\n#endif\n rfbLog(\"rfbSendFileTransferChunk() select failed: %s\\n\", strerror(errno));\n\t}\n \/* We have space on the transmit queue *\/\n\tif (n > 0)\n\t{\n bytesRead = read(cl->fileTransfer.fd, readBuf, sz_rfbBlockSize);\n switch (bytesRead) {\n case 0:\n \/*\n rfbLog(\"rfbSendFileTransferChunk(): End-Of-File Encountered\\n\");\n *\/\n retval = rfbSendFileTransferMessage(cl, rfbEndOfFile, 0, 0, 0, NULL);\n close(cl->fileTransfer.fd);\n cl->fileTransfer.fd = -1;\n cl->fileTransfer.sending = 0;\n cl->fileTransfer.receiving = 0;\n return retval;\n case -1:\n \/* TODO : send an error msg to the client... *\/\n#ifdef WIN32\n\t errno=WSAGetLastError();\n#endif\n rfbLog(\"rfbSendFileTransferChunk(): %s\\n\",strerror(errno));\n retval = rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, 0, 0, NULL);\n close(cl->fileTransfer.fd);\n cl->fileTransfer.fd = -1;\n cl->fileTransfer.sending = 0;\n cl->fileTransfer.receiving = 0;\n return retval;\n default:\n \/*\n rfbLog(\"rfbSendFileTransferChunk(): Read %d bytes\\n\", bytesRead);\n *\/\n if (!cl->fileTransfer.compressionEnabled)\n return rfbSendFileTransferMessage(cl, rfbFilePacket, 0, 0, bytesRead, readBuf);\n else\n {\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n nRetC = compress(compBuf, &nMaxCompSize, (unsigned char *)readBuf, bytesRead);\n \/*\n rfbLog(\"Compressed the packet from %d -> %d bytes\\n\", nMaxCompSize, bytesRead);\n *\/\n \n if ((nRetC==0) && (nMaxCompSize 5 && is_dir_sep(end[-5]) &&\n\t !strncmp(end - 4, \".git\", 4)) {\n\t\tend -= 5;\n\t\twhile (start < end && is_dir_sep(end[-1]))\n\t\t\tend--;\n\t}\n\n\t\/*\n\t * Strip trailing port number if we've got only a\n\t * hostname (that is, there is no dir separator but a\n\t * colon). This check is required such that we do not\n\t * strip URI's like '\/foo\/bar:2222.git', which should\n\t * result in a dir '2222' being guessed due to backwards\n\t * compatibility.\n\t *\/\n\tif (memchr(start, '\/', end - start) == NULL\n\t && memchr(start, ':', end - start) != NULL) {\n\t\tptr = end;\n\t\twhile (start < ptr && isdigit(ptr[-1]) && ptr[-1] != ':')\n\t\t\tptr--;\n\t\tif (start < ptr && ptr[-1] == ':')\n\t\t\tend = ptr - 1;\n\t}\n\n\t\/*\n\t * Find last component. To remain backwards compatible we\n\t * also regard colons as path separators, such that\n\t * cloning a repository 'foo:bar.git' would result in a\n\t * directory 'bar' being guessed.\n\t *\/\n\tptr = end;\n\twhile (start < ptr && !is_dir_sep(ptr[-1]) && ptr[-1] != ':')\n\t\tptr--;\n\tstart = ptr;\n\n\t\/*\n\t * Strip .{bundle,git}.\n\t *\/\n\tlen = end - start;\n\tstrip_suffix_mem(start, &len, is_bundle ? \".bundle\" : \".git\");\n\n\tif (!len || (len == 1 && *start == '\/'))\n\t\tdie(_(\"No directory name could be guessed.\\n\"\n\t\t \"Please specify a directory on the command line\"));\n\n\tif (is_bare)\n\t\tdir = xstrfmt(\"%.*s.git\", (int)len, start);\n\telse\n\t\tdir = xstrndup(start, len);\n\t\/*\n\t * Replace sequences of 'control' characters and whitespace\n\t * with one ascii space, remove leading and trailing spaces.\n\t *\/\n\tif (*dir) {\n\t\tchar *out = dir;\n\t\tint prev_space = 1 \/* strip leading whitespace *\/;\n\t\tfor (end = dir; *end; ++end) {\n\t\t\tchar ch = *end;\n\t\t\tif ((unsigned char)ch < '\\x20')\n\t\t\t\tch = '\\x20';\n\t\t\tif (isspace(ch)) {\n\t\t\t\tif (prev_space)\n\t\t\t\t\tcontinue;\n\t\t\t\tprev_space = 1;\n\t\t\t} else\n\t\t\t\tprev_space = 0;\n\t\t\t*out++ = ch;\n\t\t}\n\t\t*out = '\\0';\n\t\tif (out > dir && prev_space)\n\t\t\tout[-1] = '\\0';\n\t}\n\treturn dir;\n}","target":0,"code_token_length":794,"total_token_length":1030,"max_tokens_setting":2048} +{"idx":35420,"func":"static int cdxl_decode_frame(AVCodecContext *avctx, void *data,\n int *got_frame, AVPacket *pkt)\n{\n CDXLVideoContext *c = avctx->priv_data;\n AVFrame * const p = data;\n int ret, w, h, encoding, aligned_width, buf_size = pkt->size;\n const uint8_t *buf = pkt->data;\n\n if (buf_size < 32)\n return AVERROR_INVALIDDATA;\n encoding = buf[1] & 7;\n c->format = buf[1] & 0xE0;\n w = AV_RB16(&buf[14]);\n h = AV_RB16(&buf[16]);\n c->bpp = buf[19];\n c->palette_size = AV_RB16(&buf[20]);\n c->palette = buf + 32;\n c->video = c->palette + c->palette_size;\n c->video_size = buf_size - c->palette_size - 32;\n\n if (c->palette_size > 512)\n return AVERROR_INVALIDDATA;\n if (buf_size < c->palette_size + 32)\n return AVERROR_INVALIDDATA;\n if (c->bpp < 1)\n return AVERROR_INVALIDDATA;\n if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) {\n avpriv_request_sample(avctx, \"Pixel format 0x%0x\", c->format);\n return AVERROR_PATCHWELCOME;\n }\n\n if ((ret = ff_set_dimensions(avctx, w, h)) < 0)\n return ret;\n\n if (c->format == CHUNKY)\n aligned_width = avctx->width;\n else\n aligned_width = FFALIGN(c->avctx->width, 16);\n c->padded_bits = aligned_width - c->avctx->width;\n if (c->video_size < aligned_width * avctx->height * (int64_t)c->bpp \/ 8)\n return AVERROR_INVALIDDATA;\n if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) {\n avctx->pix_fmt = AV_PIX_FMT_PAL8;\n } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8) && c->format != CHUNKY) {\n if (c->palette_size != (1 << (c->bpp - 1)))\n return AVERROR_INVALIDDATA;\n avctx->pix_fmt = AV_PIX_FMT_BGR24;\n } else if (!encoding && c->bpp == 24 && c->format == CHUNKY &&\n !c->palette_size) {\n avctx->pix_fmt = AV_PIX_FMT_RGB24;\n } else {\n avpriv_request_sample(avctx, \"Encoding %d, bpp %d and format 0x%x\",\n encoding, c->bpp, c->format);\n return AVERROR_PATCHWELCOME;\n }\n\n if ((ret = ff_get_buffer(avctx, p, 0)) < 0)\n return ret;\n p->pict_type = AV_PICTURE_TYPE_I;\n\n if (encoding) {\n av_fast_padded_malloc(&c->new_video, &c->new_video_size,\n h * w + AV_INPUT_BUFFER_PADDING_SIZE);\n if (!c->new_video)\n return AVERROR(ENOMEM);\n if (c->bpp == 8)\n cdxl_decode_ham8(c, p);\n else\n cdxl_decode_ham6(c, p);\n } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {\n cdxl_decode_rgb(c, p);\n } else {\n cdxl_decode_raw(c, p);\n }\n *got_frame = 1;\n\n return buf_size;\n}","target":0,"code_token_length":852,"total_token_length":1088,"max_tokens_setting":2048} +{"idx":55720,"func":"flatpak_pull_from_bundle (OstreeRepo *repo,\n GFile *file,\n const char *remote,\n const char *ref,\n gboolean require_gpg_signature,\n GCancellable *cancellable,\n GError **error)\n{\n gsize metadata_size = 0;\n g_autofree char *metadata_contents = NULL;\n g_autofree char *to_checksum = NULL;\n g_autoptr(GFile) root = NULL;\n g_autoptr(GFile) metadata_file = NULL;\n g_autoptr(GInputStream) in = NULL;\n g_autoptr(OstreeGpgVerifyResult) gpg_result = NULL;\n g_autoptr(GError) my_error = NULL;\n g_autoptr(GVariant) metadata = NULL;\n gboolean metadata_valid;\n g_autofree char *remote_collection_id = NULL;\n g_autofree char *collection_id = NULL;\n\n metadata = flatpak_bundle_load (file, &to_checksum, NULL, NULL, NULL, &metadata_contents, NULL, NULL, &collection_id, error);\n if (metadata == NULL)\n return FALSE;\n\n metadata_size = strlen (metadata_contents);\n\n if (!ostree_repo_get_remote_option (repo, remote, \"collection-id\", NULL,\n &remote_collection_id, NULL))\n remote_collection_id = NULL;\n\n if (remote_collection_id != NULL && collection_id != NULL &&\n strcmp (remote_collection_id, collection_id) != 0)\n return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _(\"Collection \u2018%s\u2019 of bundle doesn\u2019t match collection \u2018%s\u2019 of remote\"),\n collection_id, remote_collection_id);\n\n if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error))\n return FALSE;\n\n \/* Don\u2019t need to set the collection ID here, since the remote binds this ref to the collection. *\/\n ostree_repo_transaction_set_ref (repo, remote, ref, to_checksum);\n\n if (!ostree_repo_static_delta_execute_offline (repo,\n file,\n FALSE,\n cancellable,\n error))\n return FALSE;\n\n gpg_result = ostree_repo_verify_commit_ext (repo, to_checksum,\n NULL, NULL, cancellable, &my_error);\n if (gpg_result == NULL)\n {\n \/* no gpg signature, we ignore this *if* there is no gpg key\n * specified in the bundle or by the user *\/\n if (g_error_matches (my_error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE) &&\n !require_gpg_signature)\n {\n g_clear_error (&my_error);\n }\n else\n {\n g_propagate_error (error, g_steal_pointer (&my_error));\n return FALSE;\n }\n }\n else\n {\n \/* If there is no valid gpg signature we fail, unless there is no gpg\n key specified (on the command line or in the file) because then we\n trust the source bundle. *\/\n if (ostree_gpg_verify_result_count_valid (gpg_result) == 0 &&\n require_gpg_signature)\n return flatpak_fail_error (error, FLATPAK_ERROR_UNTRUSTED, _(\"GPG signatures found, but none are in trusted keyring\"));\n }\n\n if (!ostree_repo_read_commit (repo, to_checksum, &root, NULL, NULL, error))\n return FALSE;\n\n if (!ostree_repo_commit_transaction (repo, NULL, cancellable, error))\n return FALSE;\n\n \/* We ensure that the actual installed metadata matches the one in the\n header, because you may have made decisions on whether to install it or not\n based on that data. *\/\n metadata_file = g_file_resolve_relative_path (root, \"metadata\");\n in = (GInputStream *) g_file_read (metadata_file, cancellable, NULL);\n if (in != NULL)\n {\n g_autoptr(GMemoryOutputStream) data_stream = (GMemoryOutputStream *) g_memory_output_stream_new_resizable ();\n\n if (g_output_stream_splice (G_OUTPUT_STREAM (data_stream), in,\n G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,\n cancellable, error) < 0)\n return FALSE;\n\n metadata_valid =\n metadata_contents != NULL &&\n metadata_size == g_memory_output_stream_get_data_size (data_stream) &&\n memcmp (metadata_contents, g_memory_output_stream_get_data (data_stream), metadata_size) == 0;\n }\n else\n {\n metadata_valid = (metadata_contents == NULL);\n }\n\n if (!metadata_valid)\n {\n \/* Immediately remove this broken commit *\/\n ostree_repo_set_ref_immediate (repo, remote, ref, NULL, cancellable, error);\n return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _(\"Metadata in header and app are inconsistent\"));\n }\n\n return TRUE;\n}","target":0,"code_token_length":1048,"total_token_length":1284,"max_tokens_setting":2048} +{"idx":251496,"func":"ssh_set_newkeys(struct ssh *ssh, int mode)\n{\n\tstruct session_state *state = ssh->state;\n\tstruct sshenc *enc;\n\tstruct sshmac *mac;\n\tstruct sshcomp *comp;\n\tstruct sshcipher_ctx *cc;\n\tu_int64_t *max_blocks;\n\tconst char *wmsg;\n\tint r, crypt_type;\n\n\tdebug2(\"set_newkeys: mode %d\", mode);\n\n\tif (mode == MODE_OUT) {\n\t\tcc = &state->send_context;\n\t\tcrypt_type = CIPHER_ENCRYPT;\n\t\tstate->p_send.packets = state->p_send.blocks = 0;\n\t\tmax_blocks = &state->max_blocks_out;\n\t} else {\n\t\tcc = &state->receive_context;\n\t\tcrypt_type = CIPHER_DECRYPT;\n\t\tstate->p_read.packets = state->p_read.blocks = 0;\n\t\tmax_blocks = &state->max_blocks_in;\n\t}\n\tif (state->newkeys[mode] != NULL) {\n\t\tdebug(\"set_newkeys: rekeying\");\n\t\tif ((r = cipher_cleanup(cc)) != 0)\n\t\t\treturn r;\n\t\tenc = &state->newkeys[mode]->enc;\n\t\tmac = &state->newkeys[mode]->mac;\n\t\tcomp = &state->newkeys[mode]->comp;\n\t\tmac_clear(mac);\n\t\texplicit_bzero(enc->iv, enc->iv_len);\n\t\texplicit_bzero(enc->key, enc->key_len);\n\t\texplicit_bzero(mac->key, mac->key_len);\n\t\tfree(enc->name);\n\t\tfree(enc->iv);\n\t\tfree(enc->key);\n\t\tfree(mac->name);\n\t\tfree(mac->key);\n\t\tfree(comp->name);\n\t\tfree(state->newkeys[mode]);\n\t}\n\t\/* move newkeys from kex to state *\/\n\tif ((state->newkeys[mode] = ssh->kex->newkeys[mode]) == NULL)\n\t\treturn SSH_ERR_INTERNAL_ERROR;\n\tssh->kex->newkeys[mode] = NULL;\n\tenc = &state->newkeys[mode]->enc;\n\tmac = &state->newkeys[mode]->mac;\n\tcomp = &state->newkeys[mode]->comp;\n\tif (cipher_authlen(enc->cipher) == 0) {\n\t\tif ((r = mac_init(mac)) != 0)\n\t\t\treturn r;\n\t}\n\tmac->enabled = 1;\n\tDBG(debug(\"cipher_init_context: %d\", mode));\n\tif ((r = cipher_init(cc, enc->cipher, enc->key, enc->key_len,\n\t enc->iv, enc->iv_len, crypt_type)) != 0)\n\t\treturn r;\n\tif (!state->cipher_warning_done &&\n\t (wmsg = cipher_warning_message(cc)) != NULL) {\n\t\terror(\"Warning: %s\", wmsg);\n\t\tstate->cipher_warning_done = 1;\n\t}\n\t\/* Deleting the keys does not gain extra security *\/\n\t\/* explicit_bzero(enc->iv, enc->block_size);\n\t explicit_bzero(enc->key, enc->key_len);\n\t explicit_bzero(mac->key, mac->key_len); *\/\n\tif ((comp->type == COMP_ZLIB ||\n\t (comp->type == COMP_DELAYED &&\n\t state->after_authentication)) && comp->enabled == 0) {\n\t\tif ((r = ssh_packet_init_compression(ssh)) < 0)\n\t\t\treturn r;\n\t\tif (mode == MODE_OUT) {\n\t\t\tif ((r = start_compression_out(ssh, 6)) != 0)\n\t\t\t\treturn r;\n\t\t} else {\n\t\t\tif ((r = start_compression_in(ssh)) != 0)\n\t\t\t\treturn r;\n\t\t}\n\t\tcomp->enabled = 1;\n\t}\n\t\/*\n\t * The 2^(blocksize*2) limit is too expensive for 3DES,\n\t * blowfish, etc, so enforce a 1GB limit for small blocksizes.\n\t *\/\n\tif (enc->block_size >= 16)\n\t\t*max_blocks = (u_int64_t)1 << (enc->block_size*2);\n\telse\n\t\t*max_blocks = ((u_int64_t)1 << 30) \/ enc->block_size;\n\tif (state->rekey_limit)\n\t\t*max_blocks = MIN(*max_blocks,\n\t\t state->rekey_limit \/ enc->block_size);\n\treturn 0;\n}\n","target":0,"code_token_length":924,"total_token_length":1160,"max_tokens_setting":2048} +{"idx":427369,"func":"static void init_qxl_rom(PCIQXLDevice *d)\n{\n QXLRom *rom = memory_region_get_ram_ptr(&d->rom_bar);\n QXLModes *modes = (QXLModes *)(rom + 1);\n uint32_t ram_header_size;\n uint32_t surface0_area_size;\n uint32_t num_pages;\n uint32_t fb;\n int i, n;\n\n memset(rom, 0, d->rom_size);\n\n rom->magic = cpu_to_le32(QXL_ROM_MAGIC);\n rom->id = cpu_to_le32(d->id);\n rom->log_level = cpu_to_le32(d->guestdebug);\n rom->modes_offset = cpu_to_le32(sizeof(QXLRom));\n\n rom->slot_gen_bits = MEMSLOT_GENERATION_BITS;\n rom->slot_id_bits = MEMSLOT_SLOT_BITS;\n rom->slots_start = 1;\n rom->slots_end = NUM_MEMSLOTS - 1;\n rom->n_surfaces = cpu_to_le32(d->ssd.num_surfaces);\n\n for (i = 0, n = 0; i < ARRAY_SIZE(qxl_modes); i++) {\n fb = qxl_modes[i].y_res * qxl_modes[i].stride;\n if (fb > d->vgamem_size) {\n continue;\n }\n modes->modes[n].id = cpu_to_le32(i);\n modes->modes[n].x_res = cpu_to_le32(qxl_modes[i].x_res);\n modes->modes[n].y_res = cpu_to_le32(qxl_modes[i].y_res);\n modes->modes[n].bits = cpu_to_le32(qxl_modes[i].bits);\n modes->modes[n].stride = cpu_to_le32(qxl_modes[i].stride);\n modes->modes[n].x_mili = cpu_to_le32(qxl_modes[i].x_mili);\n modes->modes[n].y_mili = cpu_to_le32(qxl_modes[i].y_mili);\n modes->modes[n].orientation = cpu_to_le32(qxl_modes[i].orientation);\n n++;\n }\n modes->n_modes = cpu_to_le32(n);\n\n ram_header_size = ALIGN(sizeof(QXLRam), 4096);\n surface0_area_size = ALIGN(d->vgamem_size, 4096);\n num_pages = d->vga.vram_size;\n num_pages -= ram_header_size;\n num_pages -= surface0_area_size;\n num_pages = num_pages \/ QXL_PAGE_SIZE;\n\n assert(ram_header_size + surface0_area_size <= d->vga.vram_size);\n\n rom->draw_area_offset = cpu_to_le32(0);\n rom->surface0_area_size = cpu_to_le32(surface0_area_size);\n rom->pages_offset = cpu_to_le32(surface0_area_size);\n rom->num_pages = cpu_to_le32(num_pages);\n rom->ram_header_offset = cpu_to_le32(d->vga.vram_size - ram_header_size);\n\n if (d->xres && d->yres) {\n \/* needs linux kernel 4.12+ to work *\/\n rom->client_monitors_config.count = 1;\n rom->client_monitors_config.heads[0].left = 0;\n rom->client_monitors_config.heads[0].top = 0;\n rom->client_monitors_config.heads[0].right = cpu_to_le32(d->xres);\n rom->client_monitors_config.heads[0].bottom = cpu_to_le32(d->yres);\n rom->client_monitors_config_crc = qxl_crc32(\n (const uint8_t *)&rom->client_monitors_config,\n sizeof(rom->client_monitors_config));\n }\n\n d->shadow_rom = *rom;\n d->rom = rom;\n d->modes = modes;\n}","target":0,"code_token_length":883,"total_token_length":1119,"max_tokens_setting":2048} +{"idx":513514,"func":"reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_read, int outputfd)\n{\n int ret;\n pid_t pid;\n char b;\n pid_t ppid = getpid ();\n char **argv;\n char uid[16];\n char gid[16];\n char *listen_fds = NULL;\n char *listen_pid = NULL;\n bool do_socket_activation = false;\n char *cwd = getcwd (NULL, 0);\n sigset_t sigset, oldsigset;\n\n if (cwd == NULL)\n {\n fprintf (stderr, \"error getting current working directory: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n listen_pid = getenv(\"LISTEN_PID\");\n listen_fds = getenv(\"LISTEN_FDS\");\n\n if (listen_pid != NULL && listen_fds != NULL)\n {\n if (strtol(listen_pid, NULL, 10) == getpid())\n do_socket_activation = true;\n }\n\n sprintf (uid, \"%d\", geteuid ());\n sprintf (gid, \"%d\", getegid ());\n\n pid = syscall_clone (CLONE_NEWUSER|CLONE_NEWNS|SIGCHLD, NULL);\n if (pid < 0)\n {\n fprintf (stderr, \"cannot clone: %s\\n\", strerror (errno));\n check_proc_sys_userns_file (_max_user_namespaces);\n check_proc_sys_userns_file (_unprivileged_user_namespaces);\n }\n if (pid)\n {\n if (do_socket_activation)\n {\n long num_fds;\n num_fds = strtol (listen_fds, NULL, 10);\n if (num_fds != LONG_MIN && num_fds != LONG_MAX)\n {\n int f;\n\n for (f = 3; f < num_fds + 3; f++)\n if (open_files_set == NULL || FD_ISSET (f % FD_SETSIZE, &(open_files_set[f \/ FD_SETSIZE])))\n close (f);\n }\n unsetenv (\"LISTEN_PID\");\n unsetenv (\"LISTEN_FDS\");\n unsetenv (\"LISTEN_FDNAMES\");\n }\n return pid;\n }\n\n if (sigfillset (&sigset) < 0)\n {\n fprintf (stderr, \"cannot fill sigset: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (sigdelset (&sigset, SIGCHLD) < 0)\n {\n fprintf (stderr, \"cannot sigdelset(SIGCHLD): %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (sigdelset (&sigset, SIGTERM) < 0)\n {\n fprintf (stderr, \"cannot sigdelset(SIGTERM): %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (sigprocmask (SIG_BLOCK, &sigset, &oldsigset) < 0)\n {\n fprintf (stderr, \"cannot block signals: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n argv = get_cmd_line_args (ppid);\n if (argv == NULL)\n {\n fprintf (stderr, \"cannot read argv: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n if (do_socket_activation)\n {\n char s[32];\n sprintf (s, \"%d\", getpid());\n setenv (\"LISTEN_PID\", s, true);\n }\n\n setenv (\"_CONTAINERS_USERNS_CONFIGURED\", \"init\", 1);\n setenv (\"_CONTAINERS_ROOTLESS_UID\", uid, 1);\n setenv (\"_CONTAINERS_ROOTLESS_GID\", gid, 1);\n\n ret = TEMP_FAILURE_RETRY (read (ready, &b, 1));\n if (ret < 0)\n {\n fprintf (stderr, \"cannot read from sync pipe: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (b != '0')\n _exit (EXIT_FAILURE);\n\n if (syscall_setresgid (0, 0, 0) < 0)\n {\n fprintf (stderr, \"cannot setresgid: %s\\n\", strerror (errno));\n TEMP_FAILURE_RETRY (write (ready, \"1\", 1));\n _exit (EXIT_FAILURE);\n }\n\n if (syscall_setresuid (0, 0, 0) < 0)\n {\n fprintf (stderr, \"cannot setresuid: %s\\n\", strerror (errno));\n TEMP_FAILURE_RETRY (write (ready, \"1\", 1));\n _exit (EXIT_FAILURE);\n }\n\n if (chdir (cwd) < 0)\n {\n fprintf (stderr, \"cannot chdir: %s\\n\", strerror (errno));\n TEMP_FAILURE_RETRY (write (ready, \"1\", 1));\n _exit (EXIT_FAILURE);\n }\n free (cwd);\n\n if (pause_pid_file_path && pause_pid_file_path[0] != '\\0')\n {\n if (create_pause_process (pause_pid_file_path, argv) < 0)\n {\n TEMP_FAILURE_RETRY (write (ready, \"2\", 1));\n _exit (EXIT_FAILURE);\n }\n }\n\n ret = TEMP_FAILURE_RETRY (write (ready, \"0\", 1));\n if (ret < 0)\n {\n\t fprintf (stderr, \"cannot write to ready pipe: %s\\n\", strerror (errno));\n\t _exit (EXIT_FAILURE);\n }\n close (ready);\n\n if (sigprocmask (SIG_SETMASK, &oldsigset, NULL) < 0)\n {\n fprintf (stderr, \"cannot block signals: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n if (file_to_read && file_to_read[0])\n {\n ret = copy_file_to_fd (file_to_read, outputfd);\n close (outputfd);\n _exit (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);\n }\n\n execvp (argv[0], argv);\n\n _exit (EXIT_FAILURE);\n}","target":0,"code_token_length":1315,"total_token_length":1551,"max_tokens_setting":2048} +{"idx":398773,"func":"gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)\n{\n GstQTDemux *demux;\n\n demux = GST_QTDEMUX (parent);\n\n GST_DEBUG_OBJECT (demux,\n \"Received buffer pts:%\" GST_TIME_FORMAT \" dts:%\" GST_TIME_FORMAT\n \" offset:%\" G_GUINT64_FORMAT \" size:%\" G_GSIZE_FORMAT \" demux offset:%\"\n G_GUINT64_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (inbuf)),\n GST_TIME_ARGS (GST_BUFFER_DTS (inbuf)), GST_BUFFER_OFFSET (inbuf),\n gst_buffer_get_size (inbuf), demux->offset);\n\n if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DISCONT)) {\n gboolean is_gap_input = FALSE;\n gint i;\n\n GST_DEBUG_OBJECT (demux, \"Got DISCONT, marking all streams as DISCONT\");\n\n for (i = 0; i < demux->n_streams; i++) {\n demux->streams[i]->discont = TRUE;\n }\n\n \/* Check if we can land back on our feet in the case where upstream is\n * handling the seeking\/pushing of samples with gaps in between (like\n * in the case of trick-mode DASH for example) *\/\n if (demux->upstream_format_is_time\n && GST_BUFFER_OFFSET (inbuf) != GST_BUFFER_OFFSET_NONE) {\n gint i;\n for (i = 0; i < demux->n_streams; i++) {\n guint32 res;\n GST_LOG_OBJECT (demux,\n \"Stream #%d , checking if offset %\" G_GUINT64_FORMAT\n \" is a sample start\", i, GST_BUFFER_OFFSET (inbuf));\n res =\n gst_qtdemux_find_index_for_given_media_offset_linear (demux,\n demux->streams[i], GST_BUFFER_OFFSET (inbuf));\n if (res != -1) {\n QtDemuxSample *sample = &demux->streams[i]->samples[res];\n GST_LOG_OBJECT (demux,\n \"Checking if sample %d from stream %d is valid (offset:%\"\n G_GUINT64_FORMAT \" size:%\" G_GUINT32_FORMAT \")\", res, i,\n sample->offset, sample->size);\n if (sample->offset == GST_BUFFER_OFFSET (inbuf)) {\n GST_LOG_OBJECT (demux,\n \"new buffer corresponds to a valid sample : %\" G_GUINT32_FORMAT,\n res);\n is_gap_input = TRUE;\n \/* We can go back to standard playback mode *\/\n demux->state = QTDEMUX_STATE_MOVIE;\n \/* Remember which sample this stream is at *\/\n demux->streams[i]->sample_index = res;\n \/* Finally update all push-based values to the expected values *\/\n demux->neededbytes = demux->streams[i]->samples[res].size;\n demux->todrop = 0;\n demux->offset = GST_BUFFER_OFFSET (inbuf);\n }\n }\n }\n if (!is_gap_input) {\n \/* Reset state if it's a real discont *\/\n demux->neededbytes = 16;\n demux->state = QTDEMUX_STATE_INITIAL;\n demux->offset = GST_BUFFER_OFFSET (inbuf);\n }\n }\n \/* Reverse fragmented playback, need to flush all we have before\n * consuming a new fragment.\n * The samples array have the timestamps calculated by accumulating the\n * durations but this won't work for reverse playback of fragments as\n * the timestamps of a subsequent fragment should be smaller than the\n * previously received one. *\/\n if (!is_gap_input && demux->fragmented && demux->segment.rate < 0) {\n gst_qtdemux_process_adapter (demux, TRUE);\n for (i = 0; i < demux->n_streams; i++)\n gst_qtdemux_stream_flush_samples_data (demux, demux->streams[i]);\n }\n }\n\n gst_adapter_push (demux->adapter, inbuf);\n\n GST_DEBUG_OBJECT (demux,\n \"pushing in inbuf %p, neededbytes:%u, available:%\" G_GSIZE_FORMAT, inbuf,\n demux->neededbytes, gst_adapter_available (demux->adapter));\n\n return gst_qtdemux_process_adapter (demux, FALSE);\n}","target":0,"code_token_length":947,"total_token_length":1183,"max_tokens_setting":2048} +{"idx":1121,"func":"static ossl_inline t2 * sk_ ## t1 ## _pop ( STACK_OF ( t1 ) * sk ) {\n return ( t2 * ) OPENSSL_sk_pop ( ( OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline t2 * sk_ ## t1 ## _shift ( STACK_OF ( t1 ) * sk ) {\n return ( t2 * ) OPENSSL_sk_shift ( ( OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) {\n OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ;\n }\n static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) {\n return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ;\n }\n static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) {\n return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ;\n }\n static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) {\n return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;\n }\n static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) {\n return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;\n }\n static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) {\n OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) {\n return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) {\n return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) {\n return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ;\n }\n static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) {\n return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ;\n }\n # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ;\n typedef const char * OPENSSL_CSTRING ;\n DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char )","target":1,"code_token_length":837,"total_token_length":1073,"max_tokens_setting":2048} +{"idx":381470,"func":"build_key_sequence (gcry_mpi_t *kparms, int mode, size_t *r_length)\n{\n int rc, i;\n size_t needed, n;\n unsigned char *plain, *p;\n size_t plainlen;\n size_t outseqlen, oidseqlen, octstrlen, inseqlen;\n\n needed = 3; \/* The version integer with value 0. *\/\n for (i=0; kparms[i]; i++)\n {\n n = 0;\n rc = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &n, kparms[i]);\n if (rc)\n {\n log_error (\"error formatting parameter: %s\\n\", gpg_strerror (rc));\n return NULL;\n }\n needed += n;\n n = compute_tag_length (n);\n if (!n)\n return NULL;\n needed += n;\n }\n if (i != 8)\n {\n log_error (\"invalid parameters for p12_build\\n\");\n return NULL;\n }\n \/* Now this all goes into a sequence. *\/\n inseqlen = needed;\n n = compute_tag_length (needed);\n if (!n)\n return NULL;\n needed += n;\n\n if (mode != 2)\n {\n \/* Encapsulate all into an octet string. *\/\n octstrlen = needed;\n n = compute_tag_length (needed);\n if (!n)\n return NULL;\n needed += n;\n \/* Prepend the object identifier sequence. *\/\n oidseqlen = 2 + DIM (oid_rsaEncryption) + 2;\n needed += 2 + oidseqlen;\n \/* The version number. *\/\n needed += 3;\n \/* And finally put the whole thing into a sequence. *\/\n outseqlen = needed;\n n = compute_tag_length (needed);\n if (!n)\n return NULL;\n needed += n;\n }\n\n \/* allocate 8 extra bytes for padding *\/\n plain = gcry_malloc_secure (needed+8);\n if (!plain)\n {\n log_error (\"error allocating encryption buffer\\n\");\n return NULL;\n }\n\n \/* And now fill the plaintext buffer. *\/\n p = plain;\n if (mode != 2)\n {\n p = store_tag_length (p, TAG_SEQUENCE, outseqlen);\n \/* Store version. *\/\n *p++ = TAG_INTEGER;\n *p++ = 1;\n *p++ = 0;\n \/* Store object identifier sequence. *\/\n p = store_tag_length (p, TAG_SEQUENCE, oidseqlen);\n p = store_tag_length (p, TAG_OBJECT_ID, DIM (oid_rsaEncryption));\n memcpy (p, oid_rsaEncryption, DIM (oid_rsaEncryption));\n p += DIM (oid_rsaEncryption);\n *p++ = TAG_NULL;\n *p++ = 0;\n \/* Start with the octet string. *\/\n p = store_tag_length (p, TAG_OCTET_STRING, octstrlen);\n }\n\n p = store_tag_length (p, TAG_SEQUENCE, inseqlen);\n \/* Store the key parameters. *\/\n *p++ = TAG_INTEGER;\n *p++ = 1;\n *p++ = 0;\n for (i=0; kparms[i]; i++)\n {\n n = 0;\n rc = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &n, kparms[i]);\n if (rc)\n {\n log_error (\"oops: error formatting parameter: %s\\n\",\n gpg_strerror (rc));\n gcry_free (plain);\n return NULL;\n }\n p = store_tag_length (p, TAG_INTEGER, n);\n\n n = plain + needed - p;\n rc = gcry_mpi_print (GCRYMPI_FMT_STD, p, n, &n, kparms[i]);\n if (rc)\n {\n log_error (\"oops: error storing parameter: %s\\n\",\n gpg_strerror (rc));\n gcry_free (plain);\n return NULL;\n }\n p += n;\n }\n\n plainlen = p - plain;\n assert (needed == plainlen);\n\n if (!mode)\n {\n \/* Append some pad characters; we already allocated extra space. *\/\n n = 8 - plainlen % 8;\n for (i=0; i < n; i++, plainlen++)\n *p++ = n;\n }\n\n *r_length = plainlen;\n return plain;\n}","target":0,"code_token_length":965,"total_token_length":1201,"max_tokens_setting":2048} +{"idx":492978,"func":"static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id,\n const mbedtls_ssl_ciphersuite_t **ciphersuite_info )\n{\n const mbedtls_ssl_ciphersuite_t *suite_info;\n\n#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \\\n defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)\n mbedtls_pk_type_t sig_type;\n#endif\n\n suite_info = mbedtls_ssl_ciphersuite_from_id( suite_id );\n if( suite_info == NULL )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"should never happen\" ) );\n return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n }\n\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"trying ciphersuite: %#04x (%s)\",\n (unsigned int) suite_id, suite_info->name ) );\n\n if( suite_info->min_minor_ver > ssl->minor_ver ||\n suite_info->max_minor_ver < ssl->minor_ver )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: version\" ) );\n return( 0 );\n }\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&\n ( suite_info->flags & MBEDTLS_CIPHERSUITE_NODTLS ) )\n return( 0 );\n#endif\n\n#if defined(MBEDTLS_ARC4_C)\n if( ssl->conf->arc4_disabled == MBEDTLS_SSL_ARC4_DISABLED &&\n suite_info->cipher == MBEDTLS_CIPHER_ARC4_128 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: rc4\" ) );\n return( 0 );\n }\n#endif\n\n#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)\n if( suite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE &&\n ( ssl->handshake->cli_exts & MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK ) == 0 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: ecjpake \"\n \"not configured or ext missing\" ) );\n return( 0 );\n }\n#endif\n\n\n#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)\n if( mbedtls_ssl_ciphersuite_uses_ec( suite_info ) &&\n ( ssl->handshake->curves == NULL ||\n ssl->handshake->curves[0] == NULL ) )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: \"\n \"no common elliptic curve\" ) );\n return( 0 );\n }\n#endif\n\n#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)\n \/* If the ciphersuite requires a pre-shared key and we don't\n * have one, skip it now rather than failing later *\/\n if( mbedtls_ssl_ciphersuite_uses_psk( suite_info ) &&\n ssl_conf_has_psk_or_cb( ssl->conf ) == 0 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: no pre-shared key\" ) );\n return( 0 );\n }\n#endif\n\n#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \\\n defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)\n \/* If the ciphersuite requires signing, check whether\n * a suitable hash algorithm is present. *\/\n if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )\n {\n sig_type = mbedtls_ssl_get_ciphersuite_sig_alg( suite_info );\n if( sig_type != MBEDTLS_PK_NONE &&\n mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, sig_type ) == MBEDTLS_MD_NONE )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: no suitable hash algorithm \"\n \"for signature algorithm %u\", (unsigned) sig_type ) );\n return( 0 );\n }\n }\n\n#endif \/* MBEDTLS_SSL_PROTO_TLS1_2 &&\n MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED *\/\n\n#if defined(MBEDTLS_X509_CRT_PARSE_C)\n \/*\n * Final check: if ciphersuite requires us to have a\n * certificate\/key of a particular type:\n * - select the appropriate certificate if we have one, or\n * - try the next ciphersuite if we don't\n * This must be done last since we modify the key_cert list.\n *\/\n if( ssl_pick_cert( ssl, suite_info ) != 0 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ciphersuite mismatch: \"\n \"no suitable certificate\" ) );\n return( 0 );\n }\n#endif\n\n *ciphersuite_info = suite_info;\n return( 0 );\n}","target":0,"code_token_length":1054,"total_token_length":1290,"max_tokens_setting":2048} +{"idx":433764,"func":"read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)\n{\n\tstruct pcap_ng_sf *ps;\n\tint status;\n\tstruct block_header bhdr;\n\tstruct block_trailer *btrlr;\n\tu_char *bdata;\n\tsize_t data_remaining;\n\n\tps = p->priv;\n\n\tstatus = read_bytes(fp, &bhdr, sizeof(bhdr), 0, errbuf);\n\tif (status <= 0)\n\t\treturn (status);\t\/* error or EOF *\/\n\n\tif (p->swapped) {\n\t\tbhdr.block_type = SWAPLONG(bhdr.block_type);\n\t\tbhdr.total_length = SWAPLONG(bhdr.total_length);\n\t}\n\n\t\/*\n\t * Is this block \"too small\" - i.e., is it shorter than a block\n\t * header plus a block trailer?\n\t *\/\n\tif (bhdr.total_length < sizeof(struct block_header) +\n\t sizeof(struct block_trailer)) {\n\t\tpcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,\n\t\t \"block in pcapng dump file has a length of %u < %\" PRIsize,\n\t\t bhdr.total_length,\n\t\t sizeof(struct block_header) + sizeof(struct block_trailer));\n\t\treturn (-1);\n\t}\n\n\t\/*\n\t * Is the block total length a multiple of 4?\n\t *\/\n\tif ((bhdr.total_length % 4) != 0) {\n\t\t\/*\n\t\t * No. Report that as an error.\n\t\t *\/\n\t\tpcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,\n\t\t \"block in pcapng dump file has a length of %u that is not a multiple of 4\" PRIsize,\n\t\t bhdr.total_length);\n\t\treturn (-1);\n\t}\n\n\t\/*\n\t * Is the buffer big enough?\n\t *\/\n\tif (p->bufsize < bhdr.total_length) {\n\t\t\/*\n\t\t * No - make it big enough, unless it's too big, in\n\t\t * which case we fail.\n\t\t *\/\n\t\tvoid *bigger_buffer;\n\n\t\tif (bhdr.total_length > ps->max_blocksize) {\n\t\t\tpcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, \"pcapng block size %u > maximum %u\", bhdr.total_length,\n\t\t\t ps->max_blocksize);\n\t\t\treturn (-1);\n\t\t}\n\t\tbigger_buffer = realloc(p->buffer, bhdr.total_length);\n\t\tif (bigger_buffer == NULL) {\n\t\t\tpcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, \"out of memory\");\n\t\t\treturn (-1);\n\t\t}\n\t\tp->buffer = bigger_buffer;\n\t}\n\n\t\/*\n\t * Copy the stuff we've read to the buffer, and read the rest\n\t * of the block.\n\t *\/\n\tmemcpy(p->buffer, &bhdr, sizeof(bhdr));\n\tbdata = (u_char *)p->buffer + sizeof(bhdr);\n\tdata_remaining = bhdr.total_length - sizeof(bhdr);\n\tif (read_bytes(fp, bdata, data_remaining, 1, errbuf) == -1)\n\t\treturn (-1);\n\n\t\/*\n\t * Get the block size from the trailer.\n\t *\/\n\tbtrlr = (struct block_trailer *)(bdata + data_remaining - sizeof (struct block_trailer));\n\tif (p->swapped)\n\t\tbtrlr->total_length = SWAPLONG(btrlr->total_length);\n\n\t\/*\n\t * Is the total length from the trailer the same as the total\n\t * length from the header?\n\t *\/\n\tif (bhdr.total_length != btrlr->total_length) {\n\t\t\/*\n\t\t * No.\n\t\t *\/\n\t\tpcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,\n\t\t \"block total length in header and trailer don't match\");\n\t\treturn (-1);\n\t}\n\n\t\/*\n\t * Initialize the cursor.\n\t *\/\n\tcursor->data = bdata;\n\tcursor->data_remaining = data_remaining - sizeof(struct block_trailer);\n\tcursor->block_type = bhdr.block_type;\n\treturn (1);\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048} +{"idx":255898,"func":"void PrintPreviewDataSource::Init() {\n AddLocalizedString(\"title\", IDS_PRINT_PREVIEW_TITLE);\n AddLocalizedString(\"loading\", IDS_PRINT_PREVIEW_LOADING);\n AddLocalizedString(\"noPlugin\", IDS_PRINT_PREVIEW_NO_PLUGIN);\n AddLocalizedString(\"launchNativeDialog\", IDS_PRINT_PREVIEW_NATIVE_DIALOG);\n AddLocalizedString(\"previewFailed\", IDS_PRINT_PREVIEW_FAILED);\n AddLocalizedString(\"invalidPrinterSettings\",\n IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS);\n AddLocalizedString(\"printButton\", IDS_PRINT_PREVIEW_PRINT_BUTTON);\n AddLocalizedString(\"saveButton\", IDS_PRINT_PREVIEW_SAVE_BUTTON);\n AddLocalizedString(\"cancelButton\", IDS_PRINT_PREVIEW_CANCEL_BUTTON);\n AddLocalizedString(\"printing\", IDS_PRINT_PREVIEW_PRINTING);\n AddLocalizedString(\"printingToPDFInProgress\",\n IDS_PRINT_PREVIEW_PRINTING_TO_PDF_IN_PROGRESS);\n#if defined(OS_MACOSX)\n AddLocalizedString(\"openingPDFInPreview\",\n IDS_PRINT_PREVIEW_OPENING_PDF_IN_PREVIEW);\n#endif\n AddLocalizedString(\"destinationLabel\", IDS_PRINT_PREVIEW_DESTINATION_LABEL);\n AddLocalizedString(\"copiesLabel\", IDS_PRINT_PREVIEW_COPIES_LABEL);\n AddLocalizedString(\"examplePageRangeText\",\n IDS_PRINT_PREVIEW_EXAMPLE_PAGE_RANGE_TEXT);\n AddLocalizedString(\"layoutLabel\", IDS_PRINT_PREVIEW_LAYOUT_LABEL);\n AddLocalizedString(\"optionAllPages\", IDS_PRINT_PREVIEW_OPTION_ALL_PAGES);\n AddLocalizedString(\"optionBw\", IDS_PRINT_PREVIEW_OPTION_BW);\n AddLocalizedString(\"optionCollate\", IDS_PRINT_PREVIEW_OPTION_COLLATE);\n AddLocalizedString(\"optionColor\", IDS_PRINT_PREVIEW_OPTION_COLOR);\n AddLocalizedString(\"optionLandscape\", IDS_PRINT_PREVIEW_OPTION_LANDSCAPE);\n AddLocalizedString(\"optionPortrait\", IDS_PRINT_PREVIEW_OPTION_PORTRAIT);\n AddLocalizedString(\"optionTwoSided\", IDS_PRINT_PREVIEW_OPTION_TWO_SIDED);\n AddLocalizedString(\"pagesLabel\", IDS_PRINT_PREVIEW_PAGES_LABEL);\n AddLocalizedString(\"pageRangeTextBox\", IDS_PRINT_PREVIEW_PAGE_RANGE_TEXT);\n AddLocalizedString(\"pageRangeRadio\", IDS_PRINT_PREVIEW_PAGE_RANGE_RADIO);\n AddLocalizedString(\"printToPDF\", IDS_PRINT_PREVIEW_PRINT_TO_PDF);\n AddLocalizedString(\"printPreviewTitleFormat\", IDS_PRINT_PREVIEW_TITLE_FORMAT);\n AddLocalizedString(\"printPreviewSummaryFormatShort\",\n IDS_PRINT_PREVIEW_SUMMARY_FORMAT_SHORT);\n AddLocalizedString(\"printPreviewSummaryFormatLong\",\n IDS_PRINT_PREVIEW_SUMMARY_FORMAT_LONG);\n AddLocalizedString(\"printPreviewSheetsLabelSingular\",\n IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR);\n AddLocalizedString(\"printPreviewSheetsLabelPlural\",\n IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL);\n AddLocalizedString(\"printPreviewPageLabelSingular\",\n IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR);\n AddLocalizedString(\"printPreviewPageLabelPlural\",\n IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL);\n const string16 shortcut_text(UTF8ToUTF16(kAdvancedPrintShortcut));\n#if defined(OS_CHROMEOS)\n AddString(\"cloudPrintDialogOption\", l10n_util::GetStringFUTF16(\n IDS_PRINT_PREVIEW_CLOUD_DIALOG_OPTION,\n l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT),\n shortcut_text));\n AddLocalizedString(\"printWithCloudPrint\",\n IDS_PRINT_PREVIEW_MORE_PRINTERS);\n#else\n AddString(\"systemDialogOption\", l10n_util::GetStringFUTF16(\n IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION,\n shortcut_text));\n AddString(\"printWithCloudPrint\", l10n_util::GetStringFUTF16(\n IDS_PRINT_PREVIEW_PRINT_WITH_CLOUD_PRINT,\n l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)));\n#endif\n#if defined(OS_MACOSX)\n AddLocalizedString(\"openPdfInPreviewOption\",\n IDS_PRINT_PREVIEW_OPEN_PDF_IN_PREVIEW_APP);\n#endif\n AddString(\"printWithCloudPrintWait\", l10n_util::GetStringFUTF16(\n IDS_PRINT_PREVIEW_PRINT_WITH_CLOUD_PRINT_WAIT,\n l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)));\n AddLocalizedString(\"pageRangeInstruction\",\n IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION);\n AddLocalizedString(\"copiesInstruction\", IDS_PRINT_PREVIEW_COPIES_INSTRUCTION);\n AddLocalizedString(\"signIn\", IDS_PRINT_PREVIEW_SIGN_IN);\n AddLocalizedString(\"managePrinters\", IDS_PRINT_PREVIEW_MANAGE_PRINTERS);\n AddLocalizedString(\"incrementTitle\", IDS_PRINT_PREVIEW_INCREMENT_TITLE);\n AddLocalizedString(\"decrementTitle\", IDS_PRINT_PREVIEW_DECREMENT_TITLE);\n AddLocalizedString(\"printPagesLabel\", IDS_PRINT_PREVIEW_PRINT_PAGES_LABEL);\n AddLocalizedString(\"optionsLabel\", IDS_PRINT_PREVIEW_OPTIONS_LABEL);\n AddLocalizedString(\"optionHeaderFooter\",\n IDS_PRINT_PREVIEW_OPTION_HEADER_FOOTER);\n AddLocalizedString(\"marginsLabel\", IDS_PRINT_PREVIEW_MARGINS_LABEL);\n AddLocalizedString(\"defaultMargins\", IDS_PRINT_PREVIEW_DEFAULT_MARGINS);\n AddLocalizedString(\"noMargins\", IDS_PRINT_PREVIEW_NO_MARGINS);\n AddLocalizedString(\"customMargins\", IDS_PRINT_PREVIEW_CUSTOM_MARGINS);\n AddLocalizedString(\"minimumMargins\", IDS_PRINT_PREVIEW_MINIMUM_MARGINS);\n AddLocalizedString(\"top\", IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL);\n AddLocalizedString(\"bottom\", IDS_PRINT_PREVIEW_BOTTOM_MARGIN_LABEL);\n AddLocalizedString(\"left\", IDS_PRINT_PREVIEW_LEFT_MARGIN_LABEL);\n AddLocalizedString(\"right\", IDS_PRINT_PREVIEW_RIGHT_MARGIN_LABEL);\n\n set_json_path(\"strings.js\");\n add_resource_path(\"print_preview.js\", IDR_PRINT_PREVIEW_JS);\n set_default_resource(IDR_PRINT_PREVIEW_HTML);\n}\n","target":1,"code_token_length":1117,"total_token_length":1353,"max_tokens_setting":2048} +{"idx":23655,"func":"const char * http_hdr_reason_lookup ( unsigned status ) {\n # define HTTP_STATUS_ENTRY ( value , reason ) case value : return # reason switch ( status ) {\n HTTP_STATUS_ENTRY ( 0 , None ) ;\n HTTP_STATUS_ENTRY ( 100 , Continue ) ;\n HTTP_STATUS_ENTRY ( 101 , Switching Protocols ) ;\n HTTP_STATUS_ENTRY ( 102 , Processing ) ;\n HTTP_STATUS_ENTRY ( 103 , Early Hints ) ;\n HTTP_STATUS_ENTRY ( 200 , OK ) ;\n HTTP_STATUS_ENTRY ( 201 , Created ) ;\n HTTP_STATUS_ENTRY ( 202 , Accepted ) ;\n HTTP_STATUS_ENTRY ( 203 , Non - Authoritative Information ) ;\n HTTP_STATUS_ENTRY ( 204 , No Content ) ;\n HTTP_STATUS_ENTRY ( 205 , Reset Content ) ;\n HTTP_STATUS_ENTRY ( 206 , Partial Content ) ;\n HTTP_STATUS_ENTRY ( 207 , Multi - Status ) ;\n HTTP_STATUS_ENTRY ( 208 , Already Reported ) ;\n HTTP_STATUS_ENTRY ( 226 , IM Used ) ;\n HTTP_STATUS_ENTRY ( 300 , Multiple Choices ) ;\n HTTP_STATUS_ENTRY ( 301 , Moved Permanently ) ;\n HTTP_STATUS_ENTRY ( 302 , Found ) ;\n HTTP_STATUS_ENTRY ( 303 , See Other ) ;\n HTTP_STATUS_ENTRY ( 304 , Not Modified ) ;\n HTTP_STATUS_ENTRY ( 305 , Use Proxy ) ;\n HTTP_STATUS_ENTRY ( 307 , Temporary Redirect ) ;\n HTTP_STATUS_ENTRY ( 308 , Permanent Redirect ) ;\n HTTP_STATUS_ENTRY ( 400 , Bad Request ) ;\n HTTP_STATUS_ENTRY ( 401 , Unauthorized ) ;\n HTTP_STATUS_ENTRY ( 402 , Payment Required ) ;\n HTTP_STATUS_ENTRY ( 403 , Forbidden ) ;\n HTTP_STATUS_ENTRY ( 404 , Not Found ) ;\n HTTP_STATUS_ENTRY ( 405 , Method Not Allowed ) ;\n HTTP_STATUS_ENTRY ( 406 , Not Acceptable ) ;\n HTTP_STATUS_ENTRY ( 407 , Proxy Authentication Required ) ;\n HTTP_STATUS_ENTRY ( 408 , Request Timeout ) ;\n HTTP_STATUS_ENTRY ( 409 , Conflict ) ;\n HTTP_STATUS_ENTRY ( 410 , Gone ) ;\n HTTP_STATUS_ENTRY ( 411 , Length Required ) ;\n HTTP_STATUS_ENTRY ( 412 , Precondition Failed ) ;\n HTTP_STATUS_ENTRY ( 413 , Request Entity Too Large ) ;\n HTTP_STATUS_ENTRY ( 414 , Request - URI Too Long ) ;\n HTTP_STATUS_ENTRY ( 415 , Unsupported Media Type ) ;\n HTTP_STATUS_ENTRY ( 416 , Requested Range Not Satisfiable ) ;\n HTTP_STATUS_ENTRY ( 417 , Expectation Failed ) ;\n HTTP_STATUS_ENTRY ( 422 , Unprocessable Entity ) ;\n HTTP_STATUS_ENTRY ( 423 , Locked ) ;\n HTTP_STATUS_ENTRY ( 424 , Failed Dependency ) ;\n HTTP_STATUS_ENTRY ( 426 , Upgrade Required ) ;\n HTTP_STATUS_ENTRY ( 428 , Precondition Required ) ;\n HTTP_STATUS_ENTRY ( 429 , Too Many Requests ) ;\n HTTP_STATUS_ENTRY ( 431 , Request Header Fields Too Large ) ;\n HTTP_STATUS_ENTRY ( 500 , Internal Server Error ) ;\n HTTP_STATUS_ENTRY ( 501 , Not Implemented ) ;\n HTTP_STATUS_ENTRY ( 502 , Bad Gateway ) ;\n HTTP_STATUS_ENTRY ( 503 , Service Unavailable ) ;\n HTTP_STATUS_ENTRY ( 504 , Gateway Timeout ) ;\n HTTP_STATUS_ENTRY ( 505 , HTTP Version Not Supported ) ;\n HTTP_STATUS_ENTRY ( 506 , Variant Also Negotiates ) ;\n HTTP_STATUS_ENTRY ( 507 , Insufficient Storage ) ;\n HTTP_STATUS_ENTRY ( 508 , Loop Detected ) ;\n HTTP_STATUS_ENTRY ( 510 , Not Extended ) ;\n HTTP_STATUS_ENTRY ( 511 , Network Authentication Required ) ;\n }\n # undef HTTP_STATUS_ENTRY return nullptr ;\n }","target":0,"code_token_length":835,"total_token_length":1071,"max_tokens_setting":2048} +{"idx":195511,"func":"static void ipa_device_begin(wmfAPI * API)\n{\n char\n comment[MaxTextExtent];\n\n wmf_magick_t\n *ddata = WMF_MAGICK_GetData(API);\n\n \/* Make SVG output happy *\/\n (void) PushDrawingWand(WmfDrawingWand);\n\n DrawSetViewbox(WmfDrawingWand, 0, 0, ddata->image->columns, ddata->image->rows );\n\n (void) FormatLocaleString(comment,MaxTextExtent,\"Created by ImageMagick %s\",\n GetMagickVersion((size_t *) NULL));\n DrawComment(WmfDrawingWand,comment);\n\n \/* Scale width and height to image *\/\n DrawScale(WmfDrawingWand, ddata->scale_x, ddata->scale_y);\n\n \/* Translate to TL corner of bounding box *\/\n DrawTranslate(WmfDrawingWand, ddata->translate_x, ddata->translate_y);\n\n \/* Apply rotation *\/\n DrawRotate(WmfDrawingWand, ddata->rotate);\n\n if (ddata->image_info->texture == NULL)\n {\n PixelWand\n *background_color;\n\n \/* Draw rectangle in background color *\/\n background_color=NewPixelWand();\n PixelSetQuantumColor(background_color,&ddata->image->background_color);\n DrawSetFillColor(WmfDrawingWand,background_color);\n background_color=DestroyPixelWand(background_color);\n DrawRectangle(WmfDrawingWand,\n XC(ddata->bbox.TL.x),YC(ddata->bbox.TL.y),\n XC(ddata->bbox.BR.x),YC(ddata->bbox.BR.y));\n }\n else\n {\n \/* Draw rectangle with texture image the SVG way *\/\n Image\n *image;\n\n ImageInfo\n *image_info;\n\n ExceptionInfo\n *exception;\n\n exception=AcquireExceptionInfo();\n\n image_info = CloneImageInfo((ImageInfo *) 0);\n (void) CopyMagickString(image_info->filename,ddata->image_info->texture,\n MaxTextExtent);\n if ( ddata->image_info->size )\n CloneString(&image_info->size,ddata->image_info->size);\n\n image = ReadImage(image_info,exception);\n image_info=DestroyImageInfo(image_info);\n if (image)\n {\n char\n pattern_id[30];\n\n MagickWand\n *magick_wand;\n\n (void) CopyMagickString(image->magick,\"MIFF\",MaxTextExtent);\n DrawPushDefs(WmfDrawingWand);\n draw_pattern_push(API,ddata->pattern_id,image->columns,image->rows);\n magick_wand=NewMagickWandFromImage(image);\n (void) DrawComposite(WmfDrawingWand,CopyCompositeOp,0,0,\n image->columns,image->rows,magick_wand);\n magick_wand=DestroyMagickWand(magick_wand);\n (void) DrawPopPattern(WmfDrawingWand);\n DrawPopDefs(WmfDrawingWand);\n (void) FormatLocaleString(pattern_id,MaxTextExtent,\"#brush_%lu\",\n ddata->pattern_id);\n (void) DrawSetFillPatternURL(WmfDrawingWand,pattern_id);\n ++ddata->pattern_id;\n\n DrawRectangle(WmfDrawingWand,\n XC(ddata->bbox.TL.x),YC(ddata->bbox.TL.y),\n XC(ddata->bbox.BR.x),YC(ddata->bbox.BR.y));\n image=DestroyImageList(image);\n }\n else\n {\n LogMagickEvent(CoderEvent,GetMagickModule(),\n \"reading texture image failed!\");\n InheritException(&ddata->image->exception,exception);\n }\n (void) DestroyExceptionInfo(exception);\n }\n\n DrawSetClipRule(WmfDrawingWand,EvenOddRule); \/* Default for WMF is ALTERNATE polygon fill mode *\/\n draw_fill_color_string(WmfDrawingWand,\"none\"); \/* Default brush is WHITE_BRUSH *\/\n draw_stroke_color_string(WmfDrawingWand,\"none\"); \/* Default pen is BLACK_PEN *\/\n DrawSetStrokeLineCap(WmfDrawingWand,ButtCap); \/* Default linecap is PS_ENDCAP_FLAT *\/\n DrawSetStrokeLineJoin(WmfDrawingWand,MiterJoin); \/* Default linejoin is PS_JOIN_MITER *\/\n draw_under_color_string(WmfDrawingWand,\"white\"); \/* Default text box is white *\/\n}\n","target":0,"code_token_length":957,"total_token_length":1193,"max_tokens_setting":2048} +{"idx":123442,"func":"void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *to ) {\n\tint\t\t\ti, lc;\n\tint\t\t\tbits;\n\tnetField_t\t*field;\n\tint\t\t\tnumFields;\n\tint\t\t\tstartBit, endBit;\n\tint\t\t\tprint;\n\tint\t\t\t*fromF, *toF;\n\tint\t\t\ttrunc;\n\tplayerState_t\tdummy;\n\n\tif ( !from ) {\n\t\tfrom = &dummy;\n\t\tCom_Memset( &dummy, 0, sizeof( dummy ) );\n\t}\n\t*to = *from;\n\n\tif ( msg->bit == 0 ) {\n\t\tstartBit = msg->readcount * 8 - GENTITYNUM_BITS;\n\t} else {\n\t\tstartBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;\n\t}\n\n\t\/\/ shownet 2\/3 will interleave with other printed info, -2 will\n\t\/\/ just print the delta records\n\tif ( cl_shownet && ( cl_shownet->integer >= 2 || cl_shownet->integer == -2 ) ) {\n\t\tprint = 1;\n\t\tCom_Printf( \"%3i: playerstate \", msg->readcount );\n\t} else {\n\t\tprint = 0;\n\t}\n\n\tnumFields = ARRAY_LEN( playerStateFields );\n\tlc = MSG_ReadByte(msg);\n\n\tif ( lc > numFields || lc < 0 ) {\n\t\tCom_Error( ERR_DROP, \"invalid playerState field count\" );\n\t}\n\n\tfor ( i = 0, field = playerStateFields ; i < lc ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\n\t\tif ( ! MSG_ReadBits( msg, 1 ) ) {\n\t\t\t\/\/ no change\n\t\t\t*toF = *fromF;\n\t\t} else {\n\t\t\tif ( field->bits == 0 ) {\n\t\t\t\t\/\/ float\n\t\t\t\tif ( MSG_ReadBits( msg, 1 ) == 0 ) {\n\t\t\t\t\t\/\/ integral float\n\t\t\t\t\ttrunc = MSG_ReadBits( msg, FLOAT_INT_BITS );\n\t\t\t\t\t\/\/ bias to allow equal parts positive and negative\n\t\t\t\t\ttrunc -= FLOAT_INT_BIAS;\n\t\t\t\t\t*(float *)toF = trunc; \n\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\tCom_Printf( \"%s:%i \", field->name, trunc );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t\/\/ full floating point value\n\t\t\t\t\t*toF = MSG_ReadBits( msg, 32 );\n\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\tCom_Printf( \"%s:%f \", field->name, *(float *)toF );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t\/\/ integer\n\t\t\t\t*toF = MSG_ReadBits( msg, field->bits );\n\t\t\t\tif ( print ) {\n\t\t\t\t\tCom_Printf( \"%s:%i \", field->name, *toF );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor ( i=lc,field = &playerStateFields[lc];ioffset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\t\t\/\/ no change\n\t\t*toF = *fromF;\n\t}\n\n\n\t\/\/ read the arrays\n\tif (MSG_ReadBits( msg, 1 ) ) {\n\t\t\/\/ parse stats\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_STATS\");\n\t\t\tbits = MSG_ReadBits (msg, MAX_STATS);\n\t\t\tfor (i=0 ; istats[i] = MSG_ReadShort(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/\/ parse persistant stats\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_PERSISTANT\");\n\t\t\tbits = MSG_ReadBits (msg, MAX_PERSISTANT);\n\t\t\tfor (i=0 ; ipersistant[i] = MSG_ReadShort(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/\/ parse ammo\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_AMMO\");\n\t\t\tbits = MSG_ReadBits (msg, MAX_WEAPONS);\n\t\t\tfor (i=0 ; iammo[i] = MSG_ReadShort(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/\/ parse powerups\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_POWERUPS\");\n\t\t\tbits = MSG_ReadBits (msg, MAX_POWERUPS);\n\t\t\tfor (i=0 ; ipowerups[i] = MSG_ReadLong(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( print ) {\n\t\tif ( msg->bit == 0 ) {\n\t\t\tendBit = msg->readcount * 8 - GENTITYNUM_BITS;\n\t\t} else {\n\t\t\tendBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;\n\t\t}\n\t\tCom_Printf( \" (%i bits)\\n\", endBit - startBit );\n\t}\n}","target":0,"code_token_length":1196,"total_token_length":1432,"max_tokens_setting":2048} +{"idx":412887,"func":"static void exif_iif_add_value(image_info_type *image_info, int section_index, char *name, int tag, int format, int length, void* value, int motorola_intel TSRMLS_DC)\n{\n\tsize_t idex;\n\tvoid *vptr;\n\timage_info_value *info_value;\n\timage_info_data *info_data;\n\timage_info_data *list;\n\n\tif (length < 0) {\n\t\treturn;\n\t}\n\n\tlist = safe_erealloc(image_info->info_list[section_index].list, (image_info->info_list[section_index].count+1), sizeof(image_info_data), 0);\n\timage_info->info_list[section_index].list = list;\n\n\tinfo_data = &image_info->info_list[section_index].list[image_info->info_list[section_index].count];\n\tmemset(info_data, 0, sizeof(image_info_data));\n\tinfo_data->tag = tag;\n\tinfo_data->format = format;\n\tinfo_data->length = length;\n\tinfo_data->name = estrdup(name);\n\tinfo_value = &info_data->value;\n\n\tswitch (format) {\n\t\tcase TAG_FMT_STRING:\n\t\t\tif (value) {\n\t\t\t\tlength = php_strnlen(value, length);\n\t\t\t\tinfo_value->s = estrndup(value, length);\n\t\t\t\tinfo_data->length = length;\n\t\t\t} else {\n\t\t\t\tinfo_data->length = 0;\n\t\t\t\tinfo_value->s = estrdup(\"\");\n\t\t\t}\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\t\/* Standard says more types possible but skip them...\n\t\t\t * but allow users to handle data if they know how to\n\t\t\t * So not return but use type UNDEFINED\n\t\t\t * return;\n\t\t\t *\/\n\t\t\tinfo_data->tag = TAG_FMT_UNDEFINED;\/* otherwise not freed from memory *\/\n\t\tcase TAG_FMT_SBYTE:\n\t\tcase TAG_FMT_BYTE:\n\t\t\/* in contrast to strings bytes do not need to allocate buffer for NULL if length==0 *\/\n\t\t\tif (!length)\n\t\t\t\tbreak;\n\t\tcase TAG_FMT_UNDEFINED:\n\t\t\tif (value) {\n\t\t\t\tif (tag == TAG_MAKER_NOTE) {\n\t\t\t\t\tlength = (int) php_strnlen(value, length);\n\t\t\t\t}\n\n\t\t\t\t\/* do not recompute length here *\/\n\t\t\t\tinfo_value->s = estrndup(value, length);\n\t\t\t\tinfo_data->length = length;\n\t\t\t} else {\n\t\t\t\tinfo_data->length = 0;\n\t\t\t\tinfo_value->s = estrdup(\"\");\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase TAG_FMT_USHORT:\n\t\tcase TAG_FMT_ULONG:\n\t\tcase TAG_FMT_URATIONAL:\n\t\tcase TAG_FMT_SSHORT:\n\t\tcase TAG_FMT_SLONG:\n\t\tcase TAG_FMT_SRATIONAL:\n\t\tcase TAG_FMT_SINGLE:\n\t\tcase TAG_FMT_DOUBLE:\n\t\t\tif (length==0) {\n\t\t\t\tbreak;\n\t\t\t} else\n\t\t\tif (length>1) {\n\t\t\t\tinfo_value->list = safe_emalloc(length, sizeof(image_info_value), 0);\n\t\t\t} else {\n\t\t\t\tinfo_value = &info_data->value;\n\t\t\t}\n\t\t\tfor (idex=0,vptr=value; idex<(size_t)length; idex++,vptr=(char *) vptr + php_tiff_bytes_per_format[format]) {\n\t\t\t\tif (length>1) {\n\t\t\t\t\tinfo_value = &info_data->value.list[idex];\n\t\t\t\t}\n\t\t\t\tswitch (format) {\n\t\t\t\t\tcase TAG_FMT_USHORT:\n\t\t\t\t\t\tinfo_value->u = php_ifd_get16u(vptr, motorola_intel);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase TAG_FMT_ULONG:\n\t\t\t\t\t\tinfo_value->u = php_ifd_get32u(vptr, motorola_intel);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase TAG_FMT_URATIONAL:\n\t\t\t\t\t\tinfo_value->ur.num = php_ifd_get32u(vptr, motorola_intel);\n\t\t\t\t\t\tinfo_value->ur.den = php_ifd_get32u(4+(char *)vptr, motorola_intel);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase TAG_FMT_SSHORT:\n\t\t\t\t\t\tinfo_value->i = php_ifd_get16s(vptr, motorola_intel);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase TAG_FMT_SLONG:\n\t\t\t\t\t\tinfo_value->i = php_ifd_get32s(vptr, motorola_intel);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase TAG_FMT_SRATIONAL:\n\t\t\t\t\t\tinfo_value->sr.num = php_ifd_get32u(vptr, motorola_intel);\n\t\t\t\t\t\tinfo_value->sr.den = php_ifd_get32u(4+(char *)vptr, motorola_intel);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase TAG_FMT_SINGLE:\n#ifdef EXIF_DEBUG\n\t\t\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Found value of type single\");\n#endif\n\t\t\t\t\t\tinfo_value->f = *(float *)value;\n\n\t\t\t\t\tcase TAG_FMT_DOUBLE:\n#ifdef EXIF_DEBUG\n\t\t\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Found value of type double\");\n#endif\n\t\t\t\t\t\tinfo_value->d = *(double *)value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t}\n\timage_info->sections_found |= 1<info_list[section_index].count++;\n}","target":0,"code_token_length":1050,"total_token_length":1286,"max_tokens_setting":2048} +{"idx":354131,"func":"find_field_in_tables(THD *thd, Item_ident *item,\n TABLE_LIST *first_table, TABLE_LIST *last_table,\n\t\t Item **ref, find_item_error_report_type report_error,\n bool check_privileges, bool register_tree_change)\n{\n Field *found=0;\n const char *db= item->db_name;\n const char *table_name= item->table_name;\n const char *name= item->field_name;\n uint length=(uint) strlen(name);\n char name_buff[SAFE_NAME_LEN+1];\n TABLE_LIST *cur_table= first_table;\n TABLE_LIST *actual_table;\n bool allow_rowid;\n\n if (!table_name || !table_name[0])\n {\n table_name= 0; \/\/ For easier test\n db= 0;\n }\n\n allow_rowid= table_name || (cur_table && !cur_table->next_local);\n\n if (item->cached_table)\n {\n DBUG_PRINT(\"info\", (\"using cached table\"));\n \/*\n This shortcut is used by prepared statements. We assume that\n TABLE_LIST *first_table is not changed during query execution (which\n is true for all queries except RENAME but luckily RENAME doesn't\n use fields...) so we can rely on reusing pointer to its member.\n With this optimization we also miss case when addition of one more\n field makes some prepared query ambiguous and so erroneous, but we\n accept this trade off.\n *\/\n TABLE_LIST *table_ref= item->cached_table;\n \/*\n The condition (table_ref->view == NULL) ensures that we will call\n find_field_in_table even in the case of information schema tables\n when table_ref->field_translation != NULL.\n *\/\n if (table_ref->table && !table_ref->view &&\n (!table_ref->is_merged_derived() ||\n (!table_ref->is_multitable() && table_ref->merged_for_insert)))\n {\n\n found= find_field_in_table(thd, table_ref->table, name, length,\n TRUE, &(item->cached_field_index));\n#ifndef NO_EMBEDDED_ACCESS_CHECKS\n \/* Check if there are sufficient access rights to the found field. *\/\n if (found && check_privileges && !is_temporary_table(table_ref) &&\n check_column_grant_in_table_ref(thd, table_ref, name, length))\n found= WRONG_GRANT;\n#endif\n }\n else\n found= find_field_in_table_ref(thd, table_ref, name, length, item->name,\n NULL, NULL, ref, check_privileges,\n TRUE, &(item->cached_field_index),\n register_tree_change,\n &actual_table);\n if (found)\n {\n if (found == WRONG_GRANT)\n\treturn (Field*) 0;\n\n \/*\n Only views fields should be marked as dependent, not an underlying\n fields.\n *\/\n if (!table_ref->belong_to_view &&\n !table_ref->belong_to_derived)\n {\n SELECT_LEX *current_sel= item->context->select_lex;\n SELECT_LEX *last_select= table_ref->select_lex;\n bool all_merged= TRUE;\n for (SELECT_LEX *sl= current_sel; sl && sl!=last_select;\n sl=sl->outer_select())\n {\n Item *subs= sl->master_unit()->item;\n if (subs->type() == Item::SUBSELECT_ITEM && \n ((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS &&\n ((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN))\n {\n continue;\n }\n all_merged= FALSE;\n break;\n }\n \/*\n If the field was an outer referencee, mark all selects using this\n sub query as dependent on the outer query\n *\/\n if (!all_merged && current_sel != last_select)\n {\n mark_select_range_as_dependent(thd, last_select, current_sel,\n found, *ref, item, true);\n }\n }\n return found;\n }\n }\n else\n item->can_be_depended= TRUE;\n\n if (db && lower_case_table_names)\n {\n \/*\n convert database to lower case for comparison.\n We can't do this in Item_field as this would change the\n 'name' of the item which may be used in the select list\n *\/\n strmake_buf(name_buff, db);\n my_casedn_str(files_charset_info, name_buff);\n db= name_buff;\n }\n\n if (last_table)\n last_table= last_table->next_name_resolution_table;\n\n for (; cur_table != last_table ;\n cur_table= cur_table->next_name_resolution_table)\n {\n Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length,\n item->name, db, table_name, ref,\n (thd->lex->sql_command ==\n SQLCOM_SHOW_FIELDS)\n ? false : check_privileges,\n allow_rowid,\n &(item->cached_field_index),\n register_tree_change,\n &actual_table);\n if (cur_field)\n {\n if (cur_field == WRONG_GRANT)\n {\n if (thd->lex->sql_command != SQLCOM_SHOW_FIELDS)\n return (Field*) 0;\n\n thd->clear_error();\n cur_field= find_field_in_table_ref(thd, cur_table, name, length,\n item->name, db, table_name, ref,\n false,\n allow_rowid,\n &(item->cached_field_index),\n register_tree_change,\n &actual_table);\n if (cur_field)\n {\n Field *nf=new Field_null(NULL,0,Field::NONE,\n cur_field->field_name,\n &my_charset_bin);\n nf->init(cur_table->table);\n cur_field= nf;\n }\n }\n\n \/*\n Store the original table of the field, which may be different from\n cur_table in the case of NATURAL\/USING join.\n *\/\n item->cached_table= (!actual_table->cacheable_table || found) ?\n 0 : actual_table;\n\n DBUG_ASSERT(thd->where);\n \/*\n If we found a fully qualified field we return it directly as it can't\n have duplicates.\n *\/\n if (db)\n return cur_field;\n \n if (found)\n {\n if (report_error == REPORT_ALL_ERRORS ||\n report_error == IGNORE_EXCEPT_NON_UNIQUE)\n my_error(ER_NON_UNIQ_ERROR, MYF(0),\n table_name ? item->full_name() : name, thd->where);\n return (Field*) 0;\n }\n found= cur_field;\n }\n }\n\n if (found)\n return found;\n \n \/*\n If the field was qualified and there were no tables to search, issue\n an error that an unknown table was given. The situation is detected\n as follows: if there were no tables we wouldn't go through the loop\n and cur_table wouldn't be updated by the loop increment part, so it\n will be equal to the first table.\n *\/\n if (table_name && (cur_table == first_table) &&\n (report_error == REPORT_ALL_ERRORS ||\n report_error == REPORT_EXCEPT_NON_UNIQUE))\n {\n char buff[SAFE_NAME_LEN*2 + 2];\n if (db && db[0])\n {\n strxnmov(buff,sizeof(buff)-1,db,\".\",table_name,NullS);\n table_name=buff;\n }\n my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where);\n }\n else\n {\n if (report_error == REPORT_ALL_ERRORS ||\n report_error == REPORT_EXCEPT_NON_UNIQUE)\n my_error(ER_BAD_FIELD_ERROR, MYF(0), item->full_name(), thd->where);\n else\n found= not_found_field;\n }\n return found;\n}","target":1,"code_token_length":1695,"total_token_length":1931,"max_tokens_setting":2048} +{"idx":94289,"func":"static int decode_modrm(struct x86_emulate_ctxt *ctxt,\n\t\t\tstruct operand *op)\n{\n\tu8 sib;\n\tint index_reg = 0, base_reg = 0, scale;\n\tint rc = X86EMUL_CONTINUE;\n\tulong modrm_ea = 0;\n\n\tif (ctxt->rex_prefix) {\n\t\tctxt->modrm_reg = (ctxt->rex_prefix & 4) << 1;\t\/* REX.R *\/\n\t\tindex_reg = (ctxt->rex_prefix & 2) << 2; \/* REX.X *\/\n\t\tctxt->modrm_rm = base_reg = (ctxt->rex_prefix & 1) << 3; \/* REG.B *\/\n\t}\n\n\tctxt->modrm = insn_fetch(u8, ctxt);\n\tctxt->modrm_mod |= (ctxt->modrm & 0xc0) >> 6;\n\tctxt->modrm_reg |= (ctxt->modrm & 0x38) >> 3;\n\tctxt->modrm_rm |= (ctxt->modrm & 0x07);\n\tctxt->modrm_seg = VCPU_SREG_DS;\n\n\tif (ctxt->modrm_mod == 3) {\n\t\top->type = OP_REG;\n\t\top->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;\n\t\top->addr.reg = decode_register(ctxt->modrm_rm,\n\t\t\t\t\t ctxt->regs, ctxt->d & ByteOp);\n\t\tif (ctxt->d & Sse) {\n\t\t\top->type = OP_XMM;\n\t\t\top->bytes = 16;\n\t\t\top->addr.xmm = ctxt->modrm_rm;\n\t\t\tread_sse_reg(ctxt, &op->vec_val, ctxt->modrm_rm);\n\t\t\treturn rc;\n\t\t}\n\t\tfetch_register_operand(op);\n\t\treturn rc;\n\t}\n\n\top->type = OP_MEM;\n\n\tif (ctxt->ad_bytes == 2) {\n\t\tunsigned bx = ctxt->regs[VCPU_REGS_RBX];\n\t\tunsigned bp = ctxt->regs[VCPU_REGS_RBP];\n\t\tunsigned si = ctxt->regs[VCPU_REGS_RSI];\n\t\tunsigned di = ctxt->regs[VCPU_REGS_RDI];\n\n\t\t\/* 16-bit ModR\/M decode. *\/\n\t\tswitch (ctxt->modrm_mod) {\n\t\tcase 0:\n\t\t\tif (ctxt->modrm_rm == 6)\n\t\t\t\tmodrm_ea += insn_fetch(u16, ctxt);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tmodrm_ea += insn_fetch(s8, ctxt);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmodrm_ea += insn_fetch(u16, ctxt);\n\t\t\tbreak;\n\t\t}\n\t\tswitch (ctxt->modrm_rm) {\n\t\tcase 0:\n\t\t\tmodrm_ea += bx + si;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tmodrm_ea += bx + di;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmodrm_ea += bp + si;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmodrm_ea += bp + di;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tmodrm_ea += si;\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tmodrm_ea += di;\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tif (ctxt->modrm_mod != 0)\n\t\t\t\tmodrm_ea += bp;\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tmodrm_ea += bx;\n\t\t\tbreak;\n\t\t}\n\t\tif (ctxt->modrm_rm == 2 || ctxt->modrm_rm == 3 ||\n\t\t (ctxt->modrm_rm == 6 && ctxt->modrm_mod != 0))\n\t\t\tctxt->modrm_seg = VCPU_SREG_SS;\n\t\tmodrm_ea = (u16)modrm_ea;\n\t} else {\n\t\t\/* 32\/64-bit ModR\/M decode. *\/\n\t\tif ((ctxt->modrm_rm & 7) == 4) {\n\t\t\tsib = insn_fetch(u8, ctxt);\n\t\t\tindex_reg |= (sib >> 3) & 7;\n\t\t\tbase_reg |= sib & 7;\n\t\t\tscale = sib >> 6;\n\n\t\t\tif ((base_reg & 7) == 5 && ctxt->modrm_mod == 0)\n\t\t\t\tmodrm_ea += insn_fetch(s32, ctxt);\n\t\t\telse\n\t\t\t\tmodrm_ea += ctxt->regs[base_reg];\n\t\t\tif (index_reg != 4)\n\t\t\t\tmodrm_ea += ctxt->regs[index_reg] << scale;\n\t\t} else if ((ctxt->modrm_rm & 7) == 5 && ctxt->modrm_mod == 0) {\n\t\t\tif (ctxt->mode == X86EMUL_MODE_PROT64)\n\t\t\t\tctxt->rip_relative = 1;\n\t\t} else\n\t\t\tmodrm_ea += ctxt->regs[ctxt->modrm_rm];\n\t\tswitch (ctxt->modrm_mod) {\n\t\tcase 0:\n\t\t\tif (ctxt->modrm_rm == 5)\n\t\t\t\tmodrm_ea += insn_fetch(s32, ctxt);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tmodrm_ea += insn_fetch(s8, ctxt);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmodrm_ea += insn_fetch(s32, ctxt);\n\t\t\tbreak;\n\t\t}\n\t}\n\top->addr.mem.ea = modrm_ea;\ndone:\n\treturn rc;\n}","target":0,"code_token_length":1145,"total_token_length":1381,"max_tokens_setting":2048} +{"idx":6866,"func":"rename_principal_2_svc(rprinc_arg *arg, struct svc_req *rqstp)\n{\n static generic_ret ret;\n char *prime_arg1,\n *prime_arg2;\n gss_buffer_desc client_name,\n service_name;\n OM_uint32 minor_stat;\n kadm5_server_handle_t handle;\n restriction_t *rp;\n const char *errmsg = NULL;\n size_t tlen1, tlen2, clen, slen;\n char *tdots1, *tdots2, *cdots, *sdots;\n\n xdr_free(xdr_generic_ret, &ret);\n\n if ((ret.code = new_server_handle(arg->api_version, rqstp, &handle)))\n goto exit_func;\n\n if ((ret.code = check_handle((void *)handle)))\n goto exit_func;\n\n if (setup_gss_names(rqstp, &client_name, &service_name) < 0) {\n ret.code = KADM5_FAILURE;\n goto exit_func;\n }\n if (krb5_unparse_name(handle->context, arg->src, &prime_arg1) ||\n krb5_unparse_name(handle->context, arg->dest, &prime_arg2)) {\n ret.code = KADM5_BAD_PRINCIPAL;\n goto exit_func;\n }\n tlen1 = strlen(prime_arg1);\n trunc_name(&tlen1, &tdots1);\n tlen2 = strlen(prime_arg2);\n trunc_name(&tlen2, &tdots2);\n clen = client_name.length;\n trunc_name(&clen, &cdots);\n slen = service_name.length;\n trunc_name(&slen, &sdots);\n\n ret.code = KADM5_OK;\n if (! CHANGEPW_SERVICE(rqstp)) {\n if (!kadm5int_acl_check(handle->context, rqst2name(rqstp),\n ACL_DELETE, arg->src, NULL))\n ret.code = KADM5_AUTH_DELETE;\n \/* any restrictions at all on the ADD kills the RENAME *\/\n if (!kadm5int_acl_check(handle->context, rqst2name(rqstp),\n ACL_ADD, arg->dest, &rp) || rp) {\n if (ret.code == KADM5_AUTH_DELETE)\n ret.code = KADM5_AUTH_INSUFFICIENT;\n else\n ret.code = KADM5_AUTH_ADD;\n }\n } else\n ret.code = KADM5_AUTH_INSUFFICIENT;\n if (ret.code != KADM5_OK) {\n \/* okay to cast lengths to int because trunc_name limits max value *\/\n krb5_klog_syslog(LOG_NOTICE,\n _(\"Unauthorized request: kadm5_rename_principal, \"\n \"%.*s%s to %.*s%s, \"\n \"client=%.*s%s, service=%.*s%s, addr=%s\"),\n (int)tlen1, prime_arg1, tdots1,\n (int)tlen2, prime_arg2, tdots2,\n (int)clen, (char *)client_name.value, cdots,\n (int)slen, (char *)service_name.value, sdots,\n client_addr(rqstp->rq_xprt));\n } else {\n ret.code = kadm5_rename_principal((void *)handle, arg->src,\n arg->dest);\n if( ret.code != 0 )\n errmsg = krb5_get_error_message(handle->context, ret.code);\n\n \/* okay to cast lengths to int because trunc_name limits max value *\/\n krb5_klog_syslog(LOG_NOTICE,\n _(\"Request: kadm5_rename_principal, \"\n \"%.*s%s to %.*s%s, %s, \"\n \"client=%.*s%s, service=%.*s%s, addr=%s\"),\n (int)tlen1, prime_arg1, tdots1,\n (int)tlen2, prime_arg2, tdots2,\n errmsg ? errmsg : _(\"success\"),\n (int)clen, (char *)client_name.value, cdots,\n (int)slen, (char *)service_name.value, sdots,\n client_addr(rqstp->rq_xprt));\n\n if (errmsg != NULL)\n krb5_free_error_message(handle->context, errmsg);\n\n }\n free(prime_arg1);\n free(prime_arg2);\n gss_release_buffer(&minor_stat, &client_name);\n gss_release_buffer(&minor_stat, &service_name);\nexit_func:\n free_server_handle(handle);\n return &ret;\n}","target":1,"code_token_length":969,"total_token_length":1205,"max_tokens_setting":2048} +{"idx":39876,"func":"got_buffer_from_bus (FlatpakProxyClient *client, ProxySide *side, Buffer *buffer)\n{\n if (client->authenticated && client->proxy->filter)\n {\n g_autoptr(Header) header = NULL;;\n GDBusMessage *rewritten;\n FlatpakPolicy policy;\n ExpectedReplyType expected_reply;\n\n \/* Filter and rewrite incoming messages as needed *\/\n\n header = parse_header (buffer, 0, client->serial_offset, client->hello_serial);\n if (header == NULL)\n {\n g_warning (\"Invalid message header format\");\n buffer_unref (buffer);\n side_closed (side);\n return;\n }\n\n if (!update_socket_messages (side, buffer, header))\n return;\n\n if (client->proxy->log_messages)\n print_incoming_header (header);\n\n if (header->has_reply_serial)\n {\n expected_reply = steal_expected_reply (get_other_side (side), header->reply_serial);\n\n \/* We only allow replies we expect *\/\n if (expected_reply == EXPECTED_REPLY_NONE)\n {\n if (client->proxy->log_messages)\n g_print (\"*Unexpected reply*\\n\");\n buffer_unref (buffer);\n return;\n }\n\n switch (expected_reply)\n {\n case EXPECTED_REPLY_HELLO:\n \/* When we get the initial reply to Hello, allow all\n further communications to our own unique id. *\/\n if (header->type == G_DBUS_MESSAGE_TYPE_METHOD_RETURN)\n {\n g_autofree char *my_id = get_arg0_string (buffer);\n flatpak_proxy_client_update_unique_id_policy (client, my_id, FLATPAK_POLICY_TALK);\n break;\n }\n\n case EXPECTED_REPLY_REWRITE:\n \/* Replace a roundtrip ping with the rewritten message *\/\n\n rewritten = g_hash_table_lookup (client->rewrite_reply,\n GINT_TO_POINTER (header->reply_serial));\n\n if (client->proxy->log_messages)\n g_print (\"*REWRITTEN*\\n\");\n\n g_dbus_message_set_serial (rewritten, header->serial);\n g_clear_pointer (&buffer, buffer_unref);\n buffer = message_to_buffer (rewritten);\n\n g_hash_table_remove (client->rewrite_reply,\n GINT_TO_POINTER (header->reply_serial));\n break;\n\n case EXPECTED_REPLY_FAKE_LIST_NAMES:\n \/* This is a reply from the bus to a fake ListNames\n request, request ownership of any name matching a\n wildcard policy *\/\n\n queue_wildcard_initial_name_ops (client, header, buffer);\n\n \/* Don't forward fake replies to the app *\/\n if (client->proxy->log_messages)\n g_print (\"*SKIPPED*\\n\");\n g_clear_pointer (&buffer, buffer_unref);\n\n \/* Start reading the clients requests now that we are done with the names *\/\n start_reading (&client->client_side);\n break;\n\n case EXPECTED_REPLY_FAKE_GET_NAME_OWNER:\n \/* This is a reply from the bus to a fake GetNameOwner\n request, update the policy for this unique name based on\n the policy *\/\n {\n char *requested_name = g_hash_table_lookup (client->get_owner_reply, GINT_TO_POINTER (header->reply_serial));\n\n if (header->type == G_DBUS_MESSAGE_TYPE_METHOD_RETURN)\n {\n g_autofree char *owner = get_arg0_string (buffer);\n flatpak_proxy_client_update_unique_id_policy_from_name (client, owner, requested_name);\n }\n\n g_hash_table_remove (client->get_owner_reply, GINT_TO_POINTER (header->reply_serial));\n\n \/* Don't forward fake replies to the app *\/\n if (client->proxy->log_messages)\n g_print (\"*SKIPPED*\\n\");\n g_clear_pointer (&buffer, buffer_unref);\n break;\n }\n\n case EXPECTED_REPLY_FILTER:\n if (client->proxy->log_messages)\n g_print (\"*SKIPPED*\\n\");\n g_clear_pointer (&buffer, buffer_unref);\n break;\n\n case EXPECTED_REPLY_LIST_NAMES:\n \/* This is a reply from the bus to a ListNames request, filter\n it according to the policy *\/\n if (header->type == G_DBUS_MESSAGE_TYPE_METHOD_RETURN)\n {\n Buffer *filtered_buffer;\n\n filtered_buffer = filter_names_list (client, buffer);\n g_clear_pointer (&buffer, buffer_unref);\n buffer = filtered_buffer;\n }\n\n break;\n\n case EXPECTED_REPLY_NORMAL:\n break;\n\n default:\n g_warning (\"Unexpected expected reply type %d\", expected_reply);\n }\n }\n else \/* Not reply *\/\n {\n\n \/* Don't allow reply types with no reply_serial *\/\n if (header->type == G_DBUS_MESSAGE_TYPE_METHOD_RETURN ||\n header->type == G_DBUS_MESSAGE_TYPE_ERROR)\n {\n if (client->proxy->log_messages)\n g_print (\"*Invalid reply*\\n\");\n g_clear_pointer (&buffer, buffer_unref);\n }\n\n \/* We filter all NameOwnerChanged signal according to the policy *\/\n if (message_is_name_owner_changed (client, header))\n {\n if (should_filter_name_owner_changed (client, buffer))\n g_clear_pointer (&buffer, buffer_unref);\n }\n }\n\n \/* All incoming broadcast signals are filtered according to policy *\/\n if (header->type == G_DBUS_MESSAGE_TYPE_SIGNAL && header->destination == NULL)\n {\n policy = flatpak_proxy_client_get_policy (client, header->sender);\n if (policy < FLATPAK_POLICY_TALK)\n {\n if (client->proxy->log_messages)\n g_print (\"*FILTERED IN*\\n\");\n g_clear_pointer (&buffer, buffer_unref);\n }\n }\n\n \/* We received and forwarded a message from a trusted peer. Make the policy for\n this unique id SEE so that the client can track its lifetime. *\/\n if (buffer && header->sender && header->sender[0] == ':')\n flatpak_proxy_client_update_unique_id_policy (client, header->sender, FLATPAK_POLICY_SEE);\n\n if (buffer && client_message_generates_reply (header))\n queue_expected_reply (side, header->serial, EXPECTED_REPLY_NORMAL);\n }\n\n if (buffer)\n queue_outgoing_buffer (&client->client_side, buffer);\n}","target":0,"code_token_length":1323,"total_token_length":1559,"max_tokens_setting":2048} +{"idx":106460,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_neg_modify_local_offer2(\n pj_pool_t *pool,\n\t\t\t\t pjmedia_sdp_neg *neg,\n unsigned flags,\n\t\t\t\t const pjmedia_sdp_session *local)\n{\n pjmedia_sdp_session *new_offer;\n pjmedia_sdp_session *old_offer;\n unsigned oi; \/* old offer media index *\/\n pj_status_t status;\n\n \/* Check arguments are valid. *\/\n PJ_ASSERT_RETURN(pool && neg && local, PJ_EINVAL);\n\n \/* Can only do this in STATE_DONE. *\/\n PJ_ASSERT_RETURN(neg->state == PJMEDIA_SDP_NEG_STATE_DONE, \n\t\t PJMEDIA_SDPNEG_EINSTATE);\n\n \/* Validate the new offer *\/\n status = pjmedia_sdp_validate(local);\n if (status != PJ_SUCCESS)\n\treturn status;\n\n \/* Change state to STATE_LOCAL_OFFER *\/\n neg->state = PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER;\n\n \/* When there is no active local SDP in state PJMEDIA_SDP_NEG_STATE_DONE,\n * it means that the previous initial SDP nego must have been failed,\n * so we'll just set the local SDP offer here.\n *\/\n if (!neg->active_local_sdp) {\n\tneg->initial_sdp_tmp = NULL;\n\tneg->initial_sdp = pjmedia_sdp_session_clone(pool, local);\n\tneg->neg_local_sdp = pjmedia_sdp_session_clone(pool, local);\n\n\treturn PJ_SUCCESS;\n }\n\n \/* Init vars *\/\n old_offer = neg->active_local_sdp;\n new_offer = pjmedia_sdp_session_clone(pool, local);\n\n \/* RFC 3264 Section 8: When issuing an offer that modifies the session,\n * the \"o=\" line of the new SDP MUST be identical to that in the\n * previous SDP, except that the version in the origin field MUST\n * increment by one from the previous SDP.\n *\/\n pj_strdup(pool, &new_offer->origin.user, &old_offer->origin.user);\n new_offer->origin.id = old_offer->origin.id;\n\n pj_strdup(pool, &new_offer->origin.net_type, &old_offer->origin.net_type);\n pj_strdup(pool, &new_offer->origin.addr_type,&old_offer->origin.addr_type);\n pj_strdup(pool, &new_offer->origin.addr, &old_offer->origin.addr);\n\n if ((flags & PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE) == 0) {\n \/* Generating the new offer, in the case media lines doesn't match the\n * active SDP (e.g. current\/active SDP's have m=audio and m=video lines,\n * and the new offer only has m=audio line), the negotiator will fix \n * the new offer by reordering and adding the missing media line with \n * port number set to zero.\n *\/\n for (oi = 0; oi < old_offer->media_count; ++oi) {\n\t pjmedia_sdp_media *om;\n\t pjmedia_sdp_media *nm;\n\t unsigned ni; \/* new offer media index *\/\n\t pj_bool_t found = PJ_FALSE;\n\n\t om = old_offer->media[oi];\n\t for (ni = oi; ni < new_offer->media_count; ++ni) {\n\t nm = new_offer->media[ni];\n\t if (pj_strcmp(&nm->desc.media, &om->desc.media) == 0) {\n\t\t if (ni != oi) {\n\t\t \/* The same media found but the position unmatched to\n * the old offer, so let's put this media in the right\n * place, and keep the order of the rest.\n\t\t *\/\n\t\t pj_array_insert(\n new_offer->media,\t\t \/* array *\/\n\t\t\t sizeof(new_offer->media[0]), \/* elmt size*\/\n\t\t\t ni,\t\t\t\t \/* count *\/\n\t\t oi,\t\t\t\t \/* pos *\/\n\t\t\t &nm);\t\t\t \/* new elmt *\/\n\t\t }\n\t\t found = PJ_TRUE;\n\t\t break;\n\t }\n\t }\n\t if (!found) {\n\t pjmedia_sdp_media *m;\n\n\t m = sdp_media_clone_deactivate(pool, om, om, local);\n\n\t pj_array_insert(new_offer->media, sizeof(new_offer->media[0]),\n\t\t\t new_offer->media_count++, oi, &m);\n\t }\n }\n } else {\n \/* If media type change is allowed, the negotiator only needs to fix \n * the new offer by adding the missing media line(s) with port number\n * set to zero.\n *\/\n for (oi = new_offer->media_count; oi < old_offer->media_count; ++oi) {\n pjmedia_sdp_media *m;\n\n\t m = sdp_media_clone_deactivate(pool, old_offer->media[oi],\n old_offer->media[oi], local);\n\n\t pj_array_insert(new_offer->media, sizeof(new_offer->media[0]),\n\t new_offer->media_count++, oi, &m);\n\n }\n }\n\n \/* New_offer fixed *\/\n#if PJMEDIA_SDP_NEG_COMPARE_BEFORE_INC_VERSION\n new_offer->origin.version = old_offer->origin.version;\n\n if (pjmedia_sdp_session_cmp(new_offer, neg->initial_sdp, 0) != PJ_SUCCESS)\n {\n\t++new_offer->origin.version;\n } \n#else\n new_offer->origin.version = old_offer->origin.version + 1;\n#endif\n \n neg->initial_sdp_tmp = neg->initial_sdp;\n neg->initial_sdp = new_offer;\n neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, new_offer);\n\n return PJ_SUCCESS;\n}","target":0,"code_token_length":1191,"total_token_length":1427,"max_tokens_setting":2048} +{"idx":27748,"func":"static int decode_bmv_frame ( const uint8_t * source , int src_len , uint8_t * frame , int frame_off ) {\n unsigned val , saved_val = 0 ;\n int tmplen = src_len ;\n const uint8_t * src , * source_end = source + src_len ;\n uint8_t * frame_end = frame + SCREEN_WIDE * SCREEN_HIGH ;\n uint8_t * dst , * dst_end ;\n int len , mask ;\n int forward = ( frame_off <= - SCREEN_WIDE ) || ( frame_off >= 0 ) ;\n int read_two_nibbles , flag ;\n int advance_mode ;\n int mode = 0 ;\n int i ;\n if ( src_len <= 0 ) return AVERROR_INVALIDDATA ;\n if ( forward ) {\n src = source ;\n dst = frame ;\n dst_end = frame_end ;\n }\n else {\n src = source + src_len - 1 ;\n dst = frame_end - 1 ;\n dst_end = frame - 1 ;\n }\n for ( ;\n ;\n ) {\n int shift = 0 ;\n flag = 0 ;\n if ( ! mode || ( tmplen == 4 ) ) {\n if ( src < source || src >= source_end ) return AVERROR_INVALIDDATA ;\n val = * src ;\n read_two_nibbles = 1 ;\n }\n else {\n val = saved_val ;\n read_two_nibbles = 0 ;\n }\n if ( ! ( val & 0xC ) ) {\n for ( ;\n ;\n ) {\n if ( ! read_two_nibbles ) {\n if ( src < source || src >= source_end ) return AVERROR_INVALIDDATA ;\n shift += 2 ;\n val |= * src << shift ;\n if ( * src & 0xC ) break ;\n }\n read_two_nibbles = 0 ;\n shift += 2 ;\n mask = ( 1 << shift ) - 1 ;\n val = ( ( val >> 2 ) & ~ mask ) | ( val & mask ) ;\n NEXT_BYTE ( src ) ;\n if ( ( val & ( 0xC << shift ) ) ) {\n flag = 1 ;\n break ;\n }\n }\n }\n else if ( mode ) {\n flag = tmplen != 4 ;\n }\n if ( flag ) {\n tmplen = 4 ;\n }\n else {\n saved_val = val >> ( 4 + shift ) ;\n tmplen = 0 ;\n val &= ( 1 << ( shift + 4 ) ) - 1 ;\n NEXT_BYTE ( src ) ;\n }\n advance_mode = val & 1 ;\n len = ( val >> 1 ) - 1 ;\n mode += 1 + advance_mode ;\n if ( mode >= 4 ) mode -= 3 ;\n if ( FFABS ( dst_end - dst ) < len ) return AVERROR_INVALIDDATA ;\n switch ( mode ) {\n case 1 : if ( forward ) {\n if ( dst - frame + SCREEN_WIDE < frame_off || dst - frame + SCREEN_WIDE + frame_off < 0 || frame_end - dst < frame_off + len || frame_end - dst < len ) return AVERROR_INVALIDDATA ;\n for ( i = 0 ;\n i < len ;\n i ++ ) dst [ i ] = dst [ frame_off + i ] ;\n dst += len ;\n }\n else {\n dst -= len ;\n if ( dst - frame + SCREEN_WIDE < frame_off || dst - frame + SCREEN_WIDE + frame_off < 0 || frame_end - dst < frame_off + len || frame_end - dst < len ) return AVERROR_INVALIDDATA ;\n for ( i = len - 1 ;\n i >= 0 ;\n i -- ) dst [ i ] = dst [ frame_off + i ] ;\n }\n break ;\n case 2 : if ( forward ) {\n if ( source + src_len - src < len ) return AVERROR_INVALIDDATA ;\n memcpy ( dst , src , len ) ;\n dst += len ;\n src += len ;\n }\n else {\n if ( src - source < len ) return AVERROR_INVALIDDATA ;\n dst -= len ;\n src -= len ;\n memcpy ( dst , src , len ) ;\n }\n break ;\n case 3 : val = forward ? dst [ - 1 ] : dst [ 1 ] ;\n if ( forward ) {\n memset ( dst , val , len ) ;\n dst += len ;\n }\n else {\n dst -= len ;\n memset ( dst , val , len ) ;\n }\n break ;\n default : break ;\n }\n if ( dst == dst_end ) return 0 ;\n }\n return 0 ;\n }","target":0,"code_token_length":899,"total_token_length":1135,"max_tokens_setting":2048} +{"idx":352150,"func":"ecma_date_to_string_format (ecma_number_t datetime_number, \/**< datetime *\/\n const char *format_p) \/**< format buffer *\/\n{\n const uint32_t date_buffer_length = 37;\n JERRY_VLA (lit_utf8_byte_t, date_buffer, date_buffer_length);\n\n lit_utf8_byte_t *dest_p = date_buffer;\n\n while (*format_p != LIT_CHAR_NULL)\n {\n if (*format_p != LIT_CHAR_DOLLAR_SIGN)\n {\n *dest_p++ = (lit_utf8_byte_t) *format_p++;\n continue;\n }\n\n format_p++;\n\n const char *str_p = NULL;\n int32_t number = 0;\n int32_t number_length = 0;\n\n switch (*format_p)\n {\n case LIT_CHAR_UPPERCASE_Y: \/* Year. *\/\n {\n number = ecma_date_year_from_time (datetime_number);\n\n if (number >= 100000 || number <= -100000)\n {\n number_length = 6;\n }\n else if (number >= 10000 || number <= -10000)\n {\n number_length = 5;\n }\n else\n {\n number_length = 4;\n }\n break;\n }\n case LIT_CHAR_LOWERCASE_Y: \/* ISO Year: -000001, 0000, 0001, 9999, +012345 *\/\n {\n number = ecma_date_year_from_time (datetime_number);\n if (0 <= number && number <= 9999)\n {\n number_length = 4;\n }\n else\n {\n number_length = 6;\n }\n break;\n }\n case LIT_CHAR_UPPERCASE_M: \/* Month. *\/\n {\n int32_t month = ecma_date_month_from_time (datetime_number);\n\n JERRY_ASSERT (month >= 0 && month <= 11);\n\n str_p = month_names_p[month];\n break;\n }\n case LIT_CHAR_UPPERCASE_O: \/* Month as number. *\/\n {\n \/* The 'ecma_date_month_from_time' (ECMA 262 v5, 15.9.1.4) returns a\n * number from 0 to 11, but we have to print the month from 1 to 12\n * for ISO 8601 standard (ECMA 262 v5, 15.9.1.15). *\/\n number = ecma_date_month_from_time (datetime_number) + 1;\n number_length = 2;\n break;\n }\n case LIT_CHAR_UPPERCASE_D: \/* Day. *\/\n {\n number = ecma_date_date_from_time (datetime_number);\n number_length = 2;\n break;\n }\n case LIT_CHAR_UPPERCASE_W: \/* Day of week. *\/\n {\n int32_t day = ecma_date_week_day (datetime_number);\n\n JERRY_ASSERT (day >= 0 && day <= 6);\n\n str_p = day_names_p[day];\n break;\n }\n case LIT_CHAR_LOWERCASE_H: \/* Hour. *\/\n {\n number = ecma_date_hour_from_time (datetime_number);\n number_length = 2;\n break;\n }\n case LIT_CHAR_LOWERCASE_M: \/* Minutes. *\/\n {\n number = ecma_date_min_from_time (datetime_number);\n number_length = 2;\n break;\n }\n case LIT_CHAR_LOWERCASE_S: \/* Seconds. *\/\n {\n number = ecma_date_sec_from_time (datetime_number);\n number_length = 2;\n break;\n }\n case LIT_CHAR_LOWERCASE_I: \/* Milliseconds. *\/\n {\n number = ecma_date_ms_from_time (datetime_number);\n number_length = 3;\n break;\n }\n case LIT_CHAR_LOWERCASE_Z: \/* Time zone hours part. *\/\n {\n int32_t time_zone = (int32_t) ecma_date_local_time_zone_adjustment (datetime_number);\n\n if (time_zone >= 0)\n {\n *dest_p++ = LIT_CHAR_PLUS;\n }\n else\n {\n *dest_p++ = LIT_CHAR_MINUS;\n time_zone = -time_zone;\n }\n\n number = time_zone \/ ECMA_DATE_MS_PER_HOUR;\n number_length = 2;\n break;\n }\n default:\n {\n JERRY_ASSERT (*format_p == LIT_CHAR_UPPERCASE_Z); \/* Time zone minutes part. *\/\n\n int32_t time_zone = (int32_t) ecma_date_local_time_zone_adjustment (datetime_number);\n\n if (time_zone < 0)\n {\n time_zone = -time_zone;\n }\n\n number = (time_zone % ECMA_DATE_MS_PER_HOUR) \/ ECMA_DATE_MS_PER_MINUTE;\n number_length = 2;\n break;\n }\n }\n\n format_p++;\n\n if (str_p != NULL)\n {\n \/* Print string values: month or day name which is always 3 characters *\/\n memcpy (dest_p, str_p, 3);\n dest_p += 3;\n continue;\n }\n\n \/* Print right aligned number values. *\/\n JERRY_ASSERT (number_length > 0);\n\n if (number < 0)\n {\n number = -number;\n *dest_p++ = '-';\n }\n else if (*(format_p - 1) == LIT_CHAR_LOWERCASE_Y && number_length == 6)\n {\n \/* positive sign is compulsory for extended years *\/\n *dest_p++ = '+';\n }\n\n dest_p += number_length;\n lit_utf8_byte_t *buffer_p = dest_p;\n\n do\n {\n buffer_p--;\n *buffer_p = (lit_utf8_byte_t) ((number % 10) + (int32_t) LIT_CHAR_0);\n number \/= 10;\n }\n while (--number_length);\n }\n\n JERRY_ASSERT (dest_p <= date_buffer + date_buffer_length);\n\n return ecma_make_string_value (ecma_new_ecma_string_from_utf8 (date_buffer,\n (lit_utf8_size_t) (dest_p - date_buffer)));\n} \/* ecma_date_to_string_format *\/","target":1,"code_token_length":1375,"total_token_length":1611,"max_tokens_setting":2048} +{"idx":224357,"func":"ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* script_state,\n GLenum pname) {\n if (isContextLost())\n return ScriptValue::CreateNull(script_state);\n switch (pname) {\n case GL_SHADING_LANGUAGE_VERSION: {\n return WebGLAny(\n script_state,\n \"WebGL GLSL ES 3.00 (\" +\n String(ContextGL()->GetString(GL_SHADING_LANGUAGE_VERSION)) +\n \")\");\n }\n case GL_VERSION:\n return WebGLAny(\n script_state,\n \"WebGL 2.0 (\" + String(ContextGL()->GetString(GL_VERSION)) + \")\");\n\n case GL_COPY_READ_BUFFER_BINDING:\n return WebGLAny(script_state, bound_copy_read_buffer_.Get());\n case GL_COPY_WRITE_BUFFER_BINDING:\n return WebGLAny(script_state, bound_copy_write_buffer_.Get());\n case GL_DRAW_FRAMEBUFFER_BINDING:\n return WebGLAny(script_state, framebuffer_binding_.Get());\n case GL_FRAGMENT_SHADER_DERIVATIVE_HINT:\n return GetUnsignedIntParameter(script_state, pname);\n case GL_MAX_3D_TEXTURE_SIZE:\n return GetIntParameter(script_state, pname);\n case GL_MAX_ARRAY_TEXTURE_LAYERS:\n return GetIntParameter(script_state, pname);\n case GC3D_MAX_CLIENT_WAIT_TIMEOUT_WEBGL:\n return WebGLAny(script_state, kMaxClientWaitTimeout);\n case GL_MAX_COLOR_ATTACHMENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:\n return GetInt64Parameter(script_state, pname);\n case GL_MAX_COMBINED_UNIFORM_BLOCKS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:\n return GetInt64Parameter(script_state, pname);\n case GL_MAX_DRAW_BUFFERS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_ELEMENT_INDEX:\n return GetInt64Parameter(script_state, pname);\n case GL_MAX_ELEMENTS_INDICES:\n return GetIntParameter(script_state, pname);\n case GL_MAX_ELEMENTS_VERTICES:\n return GetIntParameter(script_state, pname);\n case GL_MAX_FRAGMENT_INPUT_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_FRAGMENT_UNIFORM_BLOCKS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_PROGRAM_TEXEL_OFFSET:\n return GetIntParameter(script_state, pname);\n case GL_MAX_SAMPLES:\n return GetIntParameter(script_state, pname);\n case GL_MAX_SERVER_WAIT_TIMEOUT:\n return GetInt64Parameter(script_state, pname);\n case GL_MAX_TEXTURE_LOD_BIAS:\n return GetFloatParameter(script_state, pname);\n case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_UNIFORM_BLOCK_SIZE:\n return GetInt64Parameter(script_state, pname);\n case GL_MAX_UNIFORM_BUFFER_BINDINGS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_VARYING_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_VERTEX_OUTPUT_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_VERTEX_UNIFORM_BLOCKS:\n return GetIntParameter(script_state, pname);\n case GL_MAX_VERTEX_UNIFORM_COMPONENTS:\n return GetIntParameter(script_state, pname);\n case GL_MIN_PROGRAM_TEXEL_OFFSET:\n return GetIntParameter(script_state, pname);\n case GL_PACK_ROW_LENGTH:\n return GetIntParameter(script_state, pname);\n case GL_PACK_SKIP_PIXELS:\n return GetIntParameter(script_state, pname);\n case GL_PACK_SKIP_ROWS:\n return GetIntParameter(script_state, pname);\n case GL_PIXEL_PACK_BUFFER_BINDING:\n return WebGLAny(script_state, bound_pixel_pack_buffer_.Get());\n case GL_PIXEL_UNPACK_BUFFER_BINDING:\n return WebGLAny(script_state, bound_pixel_unpack_buffer_.Get());\n case GL_RASTERIZER_DISCARD:\n return GetBooleanParameter(script_state, pname);\n case GL_READ_BUFFER: {\n GLenum value = 0;\n if (!isContextLost()) {\n WebGLFramebuffer* read_framebuffer_binding =\n GetFramebufferBinding(GL_READ_FRAMEBUFFER);\n if (!read_framebuffer_binding)\n value = read_buffer_of_default_framebuffer_;\n else\n value = read_framebuffer_binding->GetReadBuffer();\n }\n return WebGLAny(script_state, value);\n }\n case GL_READ_FRAMEBUFFER_BINDING:\n return WebGLAny(script_state, read_framebuffer_binding_.Get());\n case GL_SAMPLER_BINDING:\n return WebGLAny(script_state, sampler_units_[active_texture_unit_].Get());\n case GL_TEXTURE_BINDING_2D_ARRAY:\n return WebGLAny(\n script_state,\n texture_units_[active_texture_unit_].texture2d_array_binding_.Get());\n case GL_TEXTURE_BINDING_3D:\n return WebGLAny(\n script_state,\n texture_units_[active_texture_unit_].texture3d_binding_.Get());\n case GL_TRANSFORM_FEEDBACK_ACTIVE:\n return GetBooleanParameter(script_state, pname);\n case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:\n return WebGLAny(\n script_state,\n transform_feedback_binding_->GetBoundTransformFeedbackBuffer());\n case GL_TRANSFORM_FEEDBACK_BINDING:\n if (!transform_feedback_binding_->IsDefaultObject()) {\n return WebGLAny(script_state, transform_feedback_binding_.Get());\n }\n return ScriptValue::CreateNull(script_state);\n case GL_TRANSFORM_FEEDBACK_PAUSED:\n return GetBooleanParameter(script_state, pname);\n case GL_UNIFORM_BUFFER_BINDING:\n return WebGLAny(script_state, bound_uniform_buffer_.Get());\n case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:\n return GetIntParameter(script_state, pname);\n case GL_UNPACK_IMAGE_HEIGHT:\n return GetIntParameter(script_state, pname);\n case GL_UNPACK_ROW_LENGTH:\n return GetIntParameter(script_state, pname);\n case GL_UNPACK_SKIP_IMAGES:\n return GetIntParameter(script_state, pname);\n case GL_UNPACK_SKIP_PIXELS:\n return GetIntParameter(script_state, pname);\n case GL_UNPACK_SKIP_ROWS:\n return GetIntParameter(script_state, pname);\n case GL_TIMESTAMP_EXT:\n if (ExtensionEnabled(kEXTDisjointTimerQueryWebGL2Name)) {\n return WebGLAny(script_state, 0);\n }\n SynthesizeGLError(GL_INVALID_ENUM, \"getParameter\",\n \"invalid parameter name, \"\n \"EXT_disjoint_timer_query_webgl2 not enabled\");\n return ScriptValue::CreateNull(script_state);\n case GL_GPU_DISJOINT_EXT:\n if (ExtensionEnabled(kEXTDisjointTimerQueryWebGL2Name)) {\n return GetBooleanParameter(script_state, GL_GPU_DISJOINT_EXT);\n }\n SynthesizeGLError(GL_INVALID_ENUM, \"getParameter\",\n \"invalid parameter name, \"\n \"EXT_disjoint_timer_query_webgl2 not enabled\");\n return ScriptValue::CreateNull(script_state);\n\n default:\n return WebGLRenderingContextBase::getParameter(script_state, pname);\n }\n}\n","target":0,"code_token_length":1506,"total_token_length":1742,"max_tokens_setting":2048} +{"idx":340039,"func":"static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,\n\n AVCodecContext *avctx, const char *args,\n\n uint8_t **poutbuf, int *poutbuf_size,\n\n const uint8_t *buf, int buf_size,\n\n int keyframe) {\n\n H264BSFContext *ctx = bsfc->priv_data;\n\n uint8_t unit_type;\n\n uint32_t nal_size, cumul_size = 0;\n\n\n\n \/* nothing to filter *\/\n\n if (!avctx->extradata || avctx->extradata_size < 6) {\n\n *poutbuf = (uint8_t*) buf;\n\n *poutbuf_size = buf_size;\n\n return 0;\n\n }\n\n\n\n \/* retrieve sps and pps NAL units from extradata *\/\n\n if (!ctx->sps_pps_data) {\n\n uint16_t unit_size;\n\n uint32_t total_size = 0;\n\n uint8_t *out = NULL, unit_nb, sps_done = 0;\n\n const uint8_t *extradata = avctx->extradata+4;\n\n static const uint8_t nalu_header[4] = {0, 0, 0, 1};\n\n\n\n \/* retrieve length coded size *\/\n\n ctx->length_size = (*extradata++ & 0x3) + 1;\n\n if (ctx->length_size == 3)\n\n return AVERROR(EINVAL);\n\n\n\n \/* retrieve sps and pps unit(s) *\/\n\n unit_nb = *extradata++ & 0x1f; \/* number of sps unit(s) *\/\n\n if (!unit_nb) {\n\n unit_nb = *extradata++; \/* number of pps unit(s) *\/\n\n sps_done++;\n\n }\n\n while (unit_nb--) {\n\n unit_size = AV_RB16(extradata);\n\n total_size += unit_size+4;\n\n if (extradata+2+unit_size > avctx->extradata+avctx->extradata_size) {\n\n av_free(out);\n\n return AVERROR(EINVAL);\n\n }\n\n out = av_realloc(out, total_size);\n\n if (!out)\n\n return AVERROR(ENOMEM);\n\n memcpy(out+total_size-unit_size-4, nalu_header, 4);\n\n memcpy(out+total_size-unit_size, extradata+2, unit_size);\n\n extradata += 2+unit_size;\n\n\n\n if (!unit_nb && !sps_done++)\n\n unit_nb = *extradata++; \/* number of pps unit(s) *\/\n\n }\n\n\n\n ctx->sps_pps_data = out;\n\n ctx->size = total_size;\n\n ctx->first_idr = 1;\n\n }\n\n\n\n *poutbuf_size = 0;\n\n *poutbuf = NULL;\n\n do {\n\n if (ctx->length_size == 1)\n\n nal_size = buf[0];\n\n else if (ctx->length_size == 2)\n\n nal_size = AV_RB16(buf);\n\n else\n\n nal_size = AV_RB32(buf);\n\n\n\n buf += ctx->length_size;\n\n unit_type = *buf & 0x1f;\n\n\n\n \/* prepend only to the first type 5 NAL unit of an IDR picture *\/\n\n if (ctx->first_idr && unit_type == 5) {\n\n alloc_and_copy(poutbuf, poutbuf_size,\n\n ctx->sps_pps_data, ctx->size,\n\n buf, nal_size);\n\n ctx->first_idr = 0;\n\n }\n\n else {\n\n alloc_and_copy(poutbuf, poutbuf_size,\n\n NULL, 0,\n\n buf, nal_size);\n\n if (!ctx->first_idr && unit_type == 1)\n\n ctx->first_idr = 1;\n\n }\n\n\n\n buf += nal_size;\n\n cumul_size += nal_size + ctx->length_size;\n\n } while (cumul_size < buf_size);\n\n\n\n return 1;\n\n}\n","target":0,"code_token_length":849,"total_token_length":1085,"max_tokens_setting":2048} +{"idx":111509,"func":"static int initialize_context_compression(\n blosc2_context* context, const void* src, int32_t srcsize, void* dest,\n int32_t destsize, int clevel, uint8_t const *filters,\n uint8_t const *filters_meta, int32_t typesize, int compressor,\n int32_t blocksize, int new_nthreads, int nthreads, blosc2_schunk* schunk) {\n\n \/* Set parameters *\/\n context->do_compress = 1;\n context->src = (const uint8_t*)src;\n context->srcsize = srcsize;\n context->dest = (uint8_t*)dest;\n context->output_bytes = 0;\n context->destsize = destsize;\n context->sourcesize = srcsize;\n context->typesize = (int32_t)typesize;\n context->filter_flags = filters_to_flags(filters);\n for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {\n context->filters[i] = filters[i];\n context->filters_meta[i] = filters_meta[i];\n }\n context->compcode = compressor;\n context->nthreads = nthreads;\n context->new_nthreads = new_nthreads;\n context->end_threads = 0;\n context->clevel = clevel;\n context->schunk = schunk;\n\n \/* Tune some compression parameters *\/\n context->blocksize = (int32_t)blocksize;\n if (context->btune != NULL) {\n btune_next_cparams(context);\n } else {\n btune_next_blocksize(context);\n }\n\n char* envvar = getenv(\"BLOSC_WARN\");\n int warnlvl = 0;\n if (envvar != NULL) {\n warnlvl = strtol(envvar, NULL, 10);\n }\n\n \/* Check buffer size limits *\/\n if (srcsize > BLOSC_MAX_BUFFERSIZE) {\n if (warnlvl > 0) {\n fprintf(stderr, \"Input buffer size cannot exceed %d bytes\\n\",\n BLOSC_MAX_BUFFERSIZE);\n }\n return 0;\n }\n\n if (destsize < BLOSC_MAX_OVERHEAD) {\n if (warnlvl > 0) {\n fprintf(stderr, \"Output buffer size should be larger than %d bytes\\n\",\n BLOSC_MAX_OVERHEAD);\n }\n return 0;\n }\n\n if (destsize < BLOSC_MAX_OVERHEAD) {\n if (warnlvl > 0) {\n fprintf(stderr, \"Output buffer size should be larger than %d bytes\\n\",\n BLOSC_MAX_OVERHEAD);\n }\n return -2;\n }\n if (destsize < BLOSC_MAX_OVERHEAD) {\n fprintf(stderr, \"Output buffer size should be larger than %d bytes\\n\",\n BLOSC_MAX_OVERHEAD);\n return -1;\n }\n\n \/* Compression level *\/\n if (clevel < 0 || clevel > 9) {\n \/* If clevel not in 0..9, print an error *\/\n fprintf(stderr, \"`clevel` parameter must be between 0 and 9!\\n\");\n return -10;\n }\n\n \/* Check typesize limits *\/\n if (context->typesize > BLOSC_MAX_TYPESIZE) {\n \/* If typesize is too large, treat buffer as an 1-byte stream. *\/\n context->typesize = 1;\n }\n\n \/* Compute number of blocks in buffer *\/\n context->nblocks = context->sourcesize \/ context->blocksize;\n context->leftover = context->sourcesize % context->blocksize;\n context->nblocks = (context->leftover > 0) ?\n (context->nblocks + 1) : context->nblocks;\n\n return 1;\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048} +{"idx":272626,"func":"static void move_back(compiler_common *common, jump_list **backtracks, BOOL must_be_valid)\n{\n\/* Goes one character back. Affects STR_PTR and TMP1. If must_be_valid is TRUE,\nTMP2 is not used. Otherwise TMP2 must contain the start of the subject buffer,\nand it is destroyed. Does not modify STR_PTR for invalid character sequences. *\/\nDEFINE_COMPILER;\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\nstruct sljit_jump *jump;\n#endif\n\n#ifdef SUPPORT_UNICODE\n#if PCRE2_CODE_UNIT_WIDTH == 8\nstruct sljit_label *label;\n\nif (common->utf)\n {\n if (!must_be_valid && common->invalid_utf)\n {\n OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));\n OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0x80);\n add_jump(compiler, &common->utfmoveback_invalid, JUMP(SLJIT_FAST_CALL));\n if (backtracks != NULL)\n add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0));\n JUMPHERE(jump);\n return;\n }\n\n label = LABEL();\n OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));\n OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0);\n CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, label);\n return;\n }\n#elif PCRE2_CODE_UNIT_WIDTH == 16\nif (common->utf)\n {\n OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));\n OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n if (!must_be_valid && common->invalid_utf)\n {\n OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xd800);\n jump = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xe000 - 0xd800);\n add_jump(compiler, &common->utfmoveback_invalid, JUMP(SLJIT_FAST_CALL));\n if (backtracks != NULL)\n add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0));\n JUMPHERE(jump);\n return;\n }\n\n \/* Skip low surrogate if necessary. *\/\n OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);\n OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0xdc00);\n OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_EQUAL);\n OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);\n OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);\n return;\n }\n#elif PCRE2_CODE_UNIT_WIDTH == 32\nif (common->invalid_utf && !must_be_valid)\n {\n OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));\n if (backtracks != NULL)\n {\n add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x110000));\n OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n return;\n }\n\n OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP1, 0, SLJIT_IMM, 0x110000);\n OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_LESS);\n OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);\n OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);\n return;\n }\n#endif \/* PCRE2_CODE_UNIT_WIDTH == [8|16|32] *\/\n#endif \/* SUPPORT_UNICODE *\/\n\nSLJIT_UNUSED_ARG(backtracks);\nSLJIT_UNUSED_ARG(must_be_valid);\n\nOP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n}","target":0,"code_token_length":1183,"total_token_length":1419,"max_tokens_setting":2048} +{"idx":318425,"func":"static int config_props(AVFilterLink *inlink)\n\n{\n\n AVFilterContext *ctx = inlink->dst;\n\n LutContext *lut = ctx->priv;\n\n const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format];\n\n int min[4], max[4];\n\n int val, comp, ret;\n\n\n\n lut->hsub = desc->log2_chroma_w;\n\n lut->vsub = desc->log2_chroma_h;\n\n\n\n lut->var_values[VAR_W] = inlink->w;\n\n lut->var_values[VAR_H] = inlink->h;\n\n\n\n switch (inlink->format) {\n\n case PIX_FMT_YUV410P:\n\n case PIX_FMT_YUV411P:\n\n case PIX_FMT_YUV420P:\n\n case PIX_FMT_YUV422P:\n\n case PIX_FMT_YUV440P:\n\n case PIX_FMT_YUV444P:\n\n case PIX_FMT_YUVA420P:\n\n min[Y] = min[U] = min[V] = 16;\n\n max[Y] = 235;\n\n max[U] = max[V] = 240;\n\n min[A] = 0; max[A] = 255;\n\n break;\n\n default:\n\n min[0] = min[1] = min[2] = min[3] = 0;\n\n max[0] = max[1] = max[2] = max[3] = 255;\n\n }\n\n\n\n lut->is_yuv = lut->is_rgb = 0;\n\n if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;\n\n else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;\n\n\n\n if (lut->is_rgb) {\n\n switch (inlink->format) {\n\n case PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break;\n\n case PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break;\n\n case PIX_FMT_RGBA:\n\n case PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break;\n\n case PIX_FMT_BGRA:\n\n case PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break;\n\n }\n\n lut->step = av_get_bits_per_pixel(desc) >> 3;\n\n }\n\n\n\n for (comp = 0; comp < desc->nb_components; comp++) {\n\n double res;\n\n\n\n \/* create the parsed expression *\/\n\n ret = av_expr_parse(&lut->comp_expr[comp], lut->comp_expr_str[comp],\n\n var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx);\n\n if (ret < 0) {\n\n av_log(ctx, AV_LOG_ERROR,\n\n \"Error when parsing the expression '%s' for the component %d.\\n\",\n\n lut->comp_expr_str[comp], comp);\n\n return AVERROR(EINVAL);\n\n }\n\n\n\n \/* compute the lut *\/\n\n lut->var_values[VAR_MAXVAL] = max[comp];\n\n lut->var_values[VAR_MINVAL] = min[comp];\n\n\n\n for (val = 0; val < 256; val++) {\n\n lut->var_values[VAR_VAL] = val;\n\n lut->var_values[VAR_CLIPVAL] = av_clip(val, min[comp], max[comp]);\n\n lut->var_values[VAR_NEGVAL] =\n\n av_clip(min[comp] + max[comp] - lut->var_values[VAR_VAL],\n\n min[comp], max[comp]);\n\n\n\n res = av_expr_eval(lut->comp_expr[comp], lut->var_values, lut);\n\n if (isnan(res)) {\n\n av_log(ctx, AV_LOG_ERROR,\n\n \"Error when evaluating the expression '%s' for the value %d for the component #%d.\\n\",\n\n lut->comp_expr_str[comp], val, comp);\n\n return AVERROR(EINVAL);\n\n }\n\n lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]);\n\n av_log(ctx, AV_LOG_DEBUG, \"val[%d][%d] = %d\\n\", comp, val, lut->lut[comp][val]);\n\n }\n\n }\n\n\n\n return 0;\n\n}\n","target":0,"code_token_length":1059,"total_token_length":1295,"max_tokens_setting":2048} +{"idx":285048,"func":"static int __mem_cgroup_try_charge(struct mm_struct *mm,\n\t\t\t\t gfp_t gfp_mask,\n\t\t\t\t unsigned int nr_pages,\n\t\t\t\t struct mem_cgroup **ptr,\n\t\t\t\t bool oom)\n{\n\tunsigned int batch = max(CHARGE_BATCH, nr_pages);\n\tint nr_oom_retries = MEM_CGROUP_RECLAIM_RETRIES;\n\tstruct mem_cgroup *memcg = NULL;\n\tint ret;\n\n\t\/*\n\t * Unlike gloval-vm's OOM-kill, we're not in memory shortage\n\t * in system level. So, allow to go ahead dying process in addition to\n\t * MEMDIE process.\n\t *\/\n\tif (unlikely(test_thread_flag(TIF_MEMDIE)\n\t\t || fatal_signal_pending(current)))\n\t\tgoto bypass;\n\n\t\/*\n\t * We always charge the cgroup the mm_struct belongs to.\n\t * The mm_struct's mem_cgroup changes on task migration if the\n\t * thread group leader migrates. It's possible that mm is not\n\t * set, if so charge the init_mm (happens for pagecache usage).\n\t *\/\n\tif (!*ptr && !mm)\n\t\t*ptr = root_mem_cgroup;\nagain:\n\tif (*ptr) { \/* css should be a valid one *\/\n\t\tmemcg = *ptr;\n\t\tVM_BUG_ON(css_is_removed(&memcg->css));\n\t\tif (mem_cgroup_is_root(memcg))\n\t\t\tgoto done;\n\t\tif (nr_pages == 1 && consume_stock(memcg))\n\t\t\tgoto done;\n\t\tcss_get(&memcg->css);\n\t} else {\n\t\tstruct task_struct *p;\n\n\t\trcu_read_lock();\n\t\tp = rcu_dereference(mm->owner);\n\t\t\/*\n\t\t * Because we don't have task_lock(), \"p\" can exit.\n\t\t * In that case, \"memcg\" can point to root or p can be NULL with\n\t\t * race with swapoff. Then, we have small risk of mis-accouning.\n\t\t * But such kind of mis-account by race always happens because\n\t\t * we don't have cgroup_mutex(). It's overkill and we allo that\n\t\t * small race, here.\n\t\t * (*) swapoff at el will charge against mm-struct not against\n\t\t * task-struct. So, mm->owner can be NULL.\n\t\t *\/\n\t\tmemcg = mem_cgroup_from_task(p);\n\t\tif (!memcg)\n\t\t\tmemcg = root_mem_cgroup;\n\t\tif (mem_cgroup_is_root(memcg)) {\n\t\t\trcu_read_unlock();\n\t\t\tgoto done;\n\t\t}\n\t\tif (nr_pages == 1 && consume_stock(memcg)) {\n\t\t\t\/*\n\t\t\t * It seems dagerous to access memcg without css_get().\n\t\t\t * But considering how consume_stok works, it's not\n\t\t\t * necessary. If consume_stock success, some charges\n\t\t\t * from this memcg are cached on this cpu. So, we\n\t\t\t * don't need to call css_get()\/css_tryget() before\n\t\t\t * calling consume_stock().\n\t\t\t *\/\n\t\t\trcu_read_unlock();\n\t\t\tgoto done;\n\t\t}\n\t\t\/* after here, we may be blocked. we need to get refcnt *\/\n\t\tif (!css_tryget(&memcg->css)) {\n\t\t\trcu_read_unlock();\n\t\t\tgoto again;\n\t\t}\n\t\trcu_read_unlock();\n\t}\n\n\tdo {\n\t\tbool oom_check;\n\n\t\t\/* If killed, bypass charge *\/\n\t\tif (fatal_signal_pending(current)) {\n\t\t\tcss_put(&memcg->css);\n\t\t\tgoto bypass;\n\t\t}\n\n\t\toom_check = false;\n\t\tif (oom && !nr_oom_retries) {\n\t\t\toom_check = true;\n\t\t\tnr_oom_retries = MEM_CGROUP_RECLAIM_RETRIES;\n\t\t}\n\n\t\tret = mem_cgroup_do_charge(memcg, gfp_mask, batch, oom_check);\n\t\tswitch (ret) {\n\t\tcase CHARGE_OK:\n\t\t\tbreak;\n\t\tcase CHARGE_RETRY: \/* not in OOM situation but retry *\/\n\t\t\tbatch = nr_pages;\n\t\t\tcss_put(&memcg->css);\n\t\t\tmemcg = NULL;\n\t\t\tgoto again;\n\t\tcase CHARGE_WOULDBLOCK: \/* !__GFP_WAIT *\/\n\t\t\tcss_put(&memcg->css);\n\t\t\tgoto nomem;\n\t\tcase CHARGE_NOMEM: \/* OOM routine works *\/\n\t\t\tif (!oom) {\n\t\t\t\tcss_put(&memcg->css);\n\t\t\t\tgoto nomem;\n\t\t\t}\n\t\t\t\/* If oom, we never return -ENOMEM *\/\n\t\t\tnr_oom_retries--;\n\t\t\tbreak;\n\t\tcase CHARGE_OOM_DIE: \/* Killed by OOM Killer *\/\n\t\t\tcss_put(&memcg->css);\n\t\t\tgoto bypass;\n\t\t}\n\t} while (ret != CHARGE_OK);\n\n\tif (batch > nr_pages)\n\t\trefill_stock(memcg, batch - nr_pages);\n\tcss_put(&memcg->css);\ndone:\n\t*ptr = memcg;\n\treturn 0;\nnomem:\n\t*ptr = NULL;\n\treturn -ENOMEM;\nbypass:\n\t*ptr = root_mem_cgroup;\n\treturn -EINTR;\n}\n","target":0,"code_token_length":1073,"total_token_length":1309,"max_tokens_setting":2048} +{"idx":286167,"func":"int Reverb_getParameter(ReverbContext *pContext,\n void *pParam,\n uint32_t *pValueSize,\n void *pValue){\n int status = 0;\n int32_t *pParamTemp = (int32_t *)pParam;\n int32_t param = *pParamTemp++;\n char *name;\n t_reverb_settings *pProperties;\n\n if (pContext->preset) {\n if (param != REVERB_PARAM_PRESET || *pValueSize < sizeof(uint16_t)) {\n return -EINVAL;\n }\n\n *(uint16_t *)pValue = pContext->nextPreset;\n ALOGV(\"get REVERB_PARAM_PRESET, preset %d\", pContext->nextPreset);\n return 0;\n }\n\n switch (param){\n case REVERB_PARAM_ROOM_LEVEL:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize1 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_ROOM_HF_LEVEL:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize12 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_DECAY_TIME:\n if (*pValueSize != sizeof(uint32_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize3 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(uint32_t);\n break;\n case REVERB_PARAM_DECAY_HF_RATIO:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize4 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_REFLECTIONS_LEVEL:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize5 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_REFLECTIONS_DELAY:\n if (*pValueSize != sizeof(uint32_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize6 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(uint32_t);\n break;\n case REVERB_PARAM_REVERB_LEVEL:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize7 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_REVERB_DELAY:\n if (*pValueSize != sizeof(uint32_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize8 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(uint32_t);\n break;\n case REVERB_PARAM_DIFFUSION:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize9 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_DENSITY:\n if (*pValueSize != sizeof(int16_t)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize10 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(int16_t);\n break;\n case REVERB_PARAM_PROPERTIES:\n if (*pValueSize != sizeof(t_reverb_settings)){\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid pValueSize11 %d\", *pValueSize);\n return -EINVAL;\n }\n *pValueSize = sizeof(t_reverb_settings);\n break;\n\n default:\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid param %d\", param);\n return -EINVAL;\n }\n\n pProperties = (t_reverb_settings *) pValue;\n\n switch (param){\n case REVERB_PARAM_PROPERTIES:\n pProperties->roomLevel = ReverbGetRoomLevel(pContext);\n pProperties->roomHFLevel = ReverbGetRoomHfLevel(pContext);\n pProperties->decayTime = ReverbGetDecayTime(pContext);\n pProperties->decayHFRatio = ReverbGetDecayHfRatio(pContext);\n pProperties->reflectionsLevel = 0;\n pProperties->reflectionsDelay = 0;\n pProperties->reverbDelay = 0;\n pProperties->reverbLevel = ReverbGetReverbLevel(pContext);\n pProperties->diffusion = ReverbGetDiffusion(pContext);\n pProperties->density = ReverbGetDensity(pContext);\n\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomLevel %d\",\n pProperties->roomLevel);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomHFLevel %d\",\n pProperties->roomHFLevel);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayTime %d\",\n pProperties->decayTime);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayHFRatio %d\",\n pProperties->decayHFRatio);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsLevel %d\",\n pProperties->reflectionsLevel);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsDelay %d\",\n pProperties->reflectionsDelay);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbDelay %d\",\n pProperties->reverbDelay);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbLevel %d\",\n pProperties->reverbLevel);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is diffusion %d\",\n pProperties->diffusion);\n ALOGV(\"\\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is density %d\",\n pProperties->density);\n break;\n\n case REVERB_PARAM_ROOM_LEVEL:\n *(int16_t *)pValue = ReverbGetRoomLevel(pContext);\n\n break;\n case REVERB_PARAM_ROOM_HF_LEVEL:\n *(int16_t *)pValue = ReverbGetRoomHfLevel(pContext);\n\n break;\n case REVERB_PARAM_DECAY_TIME:\n *(uint32_t *)pValue = ReverbGetDecayTime(pContext);\n\n break;\n case REVERB_PARAM_DECAY_HF_RATIO:\n *(int16_t *)pValue = ReverbGetDecayHfRatio(pContext);\n\n break;\n case REVERB_PARAM_REVERB_LEVEL:\n *(int16_t *)pValue = ReverbGetReverbLevel(pContext);\n\n break;\n case REVERB_PARAM_DIFFUSION:\n *(int16_t *)pValue = ReverbGetDiffusion(pContext);\n\n break;\n case REVERB_PARAM_DENSITY:\n *(uint16_t *)pValue = 0;\n *(int16_t *)pValue = ReverbGetDensity(pContext);\n break;\n case REVERB_PARAM_REFLECTIONS_LEVEL:\n *(uint16_t *)pValue = 0;\n case REVERB_PARAM_REFLECTIONS_DELAY:\n *(uint32_t *)pValue = 0;\n case REVERB_PARAM_REVERB_DELAY:\n *(uint32_t *)pValue = 0;\n break;\n\n default:\n ALOGV(\"\\tLVM_ERROR : Reverb_getParameter() invalid param %d\", param);\n status = -EINVAL;\n break;\n }\n\n return status;\n} \/* end Reverb_getParameter *\/\n","target":0,"code_token_length":1731,"total_token_length":1967,"max_tokens_setting":2048} +{"idx":154986,"func":"static int core_anal_graph_construct_edges(RCore *core, RAnalFunction *fcn, int opts, PJ *pj, Sdb *DB) {\n\tRAnalBlock *bbi;\n\tRListIter *iter;\n\tint is_keva = opts & R_CORE_ANAL_KEYVALUE;\n\tint is_star = opts & R_CORE_ANAL_STAR;\n\tint is_json = opts & R_CORE_ANAL_JSON;\n\tint is_html = r_cons_context ()->is_html;\n\tchar *pal_jump = palColorFor (\"graph.true\");\n\tchar *pal_fail = palColorFor (\"graph.false\");\n\tchar *pal_trfa = palColorFor (\"graph.trufae\");\n\tint nodes = 0;\n\tr_list_foreach (fcn->bbs, iter, bbi) {\n\t\tif (bbi->jump != UT64_MAX) {\n\t\t\tnodes++;\n\t\t\tif (is_keva) {\n\t\t\t\tchar key[128];\n\t\t\t\tchar val[128];\n\t\t\t\tsnprintf (key, sizeof (key), \"bb.0x%08\"PFMT64x\".to\", bbi->addr);\n\t\t\t\tif (bbi->fail != UT64_MAX) {\n\t\t\t\t\tsnprintf (val, sizeof (val), \"0x%08\"PFMT64x, bbi->jump);\n\t\t\t\t} else {\n\t\t\t\t\tsnprintf (val, sizeof (val), \"0x%08\"PFMT64x \",0x%08\"PFMT64x,\n\t\t\t\t\t\t\tbbi->jump, bbi->fail);\n\t\t\t\t}\n\t\t\t\t\/\/ bb..to=,\n\t\t\t\tsdb_set (DB, key, val, 0);\n\t\t\t} else if (is_html) {\n\t\t\t\tr_cons_printf (\"
\\n\"\n\t\t\t\t\t\t\" <\/div>\\n\",\n\t\t\t\t\t\tbbi->addr, bbi->jump);\n\t\t\t} else if (!is_json && !is_keva) {\n\t\t\t\tif (is_star) {\n\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\tchar *to = get_title (bbi->jump);\n\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from, to);\n\t\t\t\t\tfree (from);\n\t\t\t\t\tfree (to);\n\t\t\t\t} else {\n\t\t\t\t\tr_strf_buffer (128);\n\t\t\t\t\tconst char* edge_color = bbi->fail != -1 ? pal_jump : pal_trfa;\n\t\t\t\t\tif (sdb_const_get (core->sdb, r_strf (\"agraph.edge.0x%\"PFMT64x\"_0x%\"PFMT64x\".highlight\", bbi->addr, bbi->jump), 0)) {\n\t\t\t\t\t\tedge_color = \"cyan\";\n\t\t\t\t\t}\n\t\t\t\t\tr_cons_printf (\" \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\", bbi->addr, bbi->jump, edge_color);\n\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (bbi->fail != -1) {\n\t\t\tnodes++;\n\t\t\tif (is_html) {\n\t\t\t\tr_cons_printf (\"
\\n\"\n\t\t\t\t\t\t\" <\/div>\\n\",\n\t\t\t\t\t\tbbi->addr, bbi->fail);\n\t\t\t} else if (!is_keva && !is_json) {\n\t\t\t\tif (is_star) {\n\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\tchar *to = get_title (bbi->fail);\n\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from, to);\n\t\t\t\t\tfree(from);\n\t\t\t\t\tfree(to);\n\t\t\t\t} else {\n\t\t\t\t\tr_cons_printf (\" \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\", bbi->addr, bbi->fail, pal_fail);\n\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (bbi->switch_op) {\n\t\t\tRAnalCaseOp *caseop;\n\t\t\tRListIter *iter;\n\n\t\t\tif (bbi->fail != UT64_MAX) {\n\t\t\t\tif (is_html) {\n\t\t\t\t\tr_cons_printf (\"
\\n\"\n\t\t\t\t\t\t\t\" <\/div>\\n\",\n\t\t\t\t\t\t\tbbi->addr, bbi->fail);\n\t\t\t\t} else if (!is_keva && !is_json) {\n\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\t\tchar *to = get_title (bbi->fail);\n\t\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from, to);\n\t\t\t\t\t\tfree(from);\n\t\t\t\t\t\tfree(to);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr_cons_printf (\" \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\", bbi->addr, bbi->fail, pal_fail);\n\t\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tr_list_foreach (bbi->switch_op->cases, iter, caseop) {\n\t\t\t\tnodes++;\n\t\t\t\tif (is_keva) {\n\t\t\t\t\tchar key[128];\n\t\t\t\t\tsnprintf (key, sizeof (key),\n\t\t\t\t\t\t\t\"bb.0x%08\"PFMT64x\".switch.%\"PFMT64d,\n\t\t\t\t\t\t\tbbi->addr, caseop->value);\n\t\t\t\t\tsdb_num_set (DB, key, caseop->jump, 0);\n\t\t\t\t\tsnprintf (key, sizeof (key),\n\t\t\t\t\t\t\t\"bb.0x%08\"PFMT64x\".switch\", bbi->addr);\n\t\t\t\t\t\t\tsdb_array_add_num (DB, key, caseop->value, 0);\n\t\t\t\t} else if (is_html) {\n\t\t\t\t\tr_cons_printf (\"
\\n\"\n\t\t\t\t\t\t\t\" <\/div>\\n\",\n\t\t\t\t\t\t\tbbi->addr, caseop->addr);\n\t\t\t\t} else if (!is_json && !is_keva) {\n\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\t\tchar *to = get_title (caseop->addr);\n\t\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from ,to);\n\t\t\t\t\t\tfree (from);\n\t\t\t\t\t\tfree (to);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr_cons_printf (\" \\\"0x%08\" PFMT64x \"\\\" -> \\\"0x%08\" PFMT64x \"\\\" \"\n\t\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\",\n\t\t\t\t\t\t\t\tbbi->addr, caseop->addr, pal_trfa);\n\t\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfree(pal_jump);\n\tfree(pal_fail);\n\tfree(pal_trfa);\n\treturn nodes;\n}","target":0,"code_token_length":1636,"total_token_length":1872,"max_tokens_setting":2048} +{"idx":337206,"func":"static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,\n\n TCGReg dest, TCGReg c1, TCGArg c2, int c2const)\n\n{\n\n int cc;\n\n\n\n switch (cond) {\n\n case TCG_COND_GTU:\n\n case TCG_COND_GT:\n\n do_greater:\n\n \/* The result of a compare has CC=2 for GT and CC=3 unused.\n\n ADD LOGICAL WITH CARRY considers (CC & 2) the carry bit. *\/\n\n tgen_cmp(s, type, cond, c1, c2, c2const, true);\n\n tcg_out_movi(s, type, dest, 0);\n\n tcg_out_insn(s, RRE, ALCGR, dest, dest);\n\n return;\n\n\n\n case TCG_COND_GEU:\n\n do_geu:\n\n \/* We need \"real\" carry semantics, so use SUBTRACT LOGICAL\n\n instead of COMPARE LOGICAL. This needs an extra move. *\/\n\n tcg_out_mov(s, type, TCG_TMP0, c1);\n\n if (c2const) {\n\n tcg_out_movi(s, TCG_TYPE_I64, dest, 0);\n\n if (type == TCG_TYPE_I32) {\n\n tcg_out_insn(s, RIL, SLFI, TCG_TMP0, c2);\n\n } else {\n\n tcg_out_insn(s, RIL, SLGFI, TCG_TMP0, c2);\n\n }\n\n } else {\n\n if (type == TCG_TYPE_I32) {\n\n tcg_out_insn(s, RR, SLR, TCG_TMP0, c2);\n\n } else {\n\n tcg_out_insn(s, RRE, SLGR, TCG_TMP0, c2);\n\n }\n\n tcg_out_movi(s, TCG_TYPE_I64, dest, 0);\n\n }\n\n tcg_out_insn(s, RRE, ALCGR, dest, dest);\n\n return;\n\n\n\n case TCG_COND_LEU:\n\n case TCG_COND_LTU:\n\n case TCG_COND_LT:\n\n \/* Swap operands so that we can use GEU\/GTU\/GT. *\/\n\n if (c2const) {\n\n tcg_out_movi(s, type, TCG_TMP0, c2);\n\n c2 = c1;\n\n c2const = 0;\n\n c1 = TCG_TMP0;\n\n } else {\n\n TCGReg t = c1;\n\n c1 = c2;\n\n c2 = t;\n\n }\n\n if (cond == TCG_COND_LEU) {\n\n goto do_geu;\n\n }\n\n cond = tcg_swap_cond(cond);\n\n goto do_greater;\n\n\n\n case TCG_COND_NE:\n\n \/* X != 0 is X > 0. *\/\n\n if (c2const && c2 == 0) {\n\n cond = TCG_COND_GTU;\n\n goto do_greater;\n\n }\n\n break;\n\n\n\n case TCG_COND_EQ:\n\n \/* X == 0 is X <= 0 is 0 >= X. *\/\n\n if (c2const && c2 == 0) {\n\n tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0);\n\n c2 = c1;\n\n c2const = 0;\n\n c1 = TCG_TMP0;\n\n goto do_geu;\n\n }\n\n break;\n\n\n\n default:\n\n break;\n\n }\n\n\n\n cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);\n\n if (facilities & FACILITY_LOAD_ON_COND) {\n\n \/* Emit: d = 0, t = 1, d = (cc ? t : d). *\/\n\n tcg_out_movi(s, TCG_TYPE_I64, dest, 0);\n\n tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1);\n\n tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc);\n\n } else {\n\n \/* Emit: d = 1; if (cc) goto over; d = 0; over: *\/\n\n tcg_out_movi(s, type, dest, 1);\n\n tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1);\n\n tcg_out_movi(s, type, dest, 0);\n\n }\n\n}\n","target":0,"code_token_length":959,"total_token_length":1195,"max_tokens_setting":2048} +{"idx":141100,"func":"void Transform::cmap( RawTile& in, enum cmap_type cmap ){\n\n float value;\n unsigned in_chan = in.channels;\n unsigned out_chan = 3;\n unsigned int ndata = in.dataLength * 8 \/ in.bpc;\n\n const float max3 = 1.0\/3.0;\n const float max8 = 1.0\/8.0;\n\n float *fptr = (float*)in.data;\n float *outptr = new float[ndata*out_chan];\n float *outv = outptr;\n\n switch(cmap){\n\n case HOT:\n#if defined(__ICC) || defined(__INTEL_COMPILER)\n#pragma ivdep\n#endif\n for( int unsigned n=0; n1.)\n { outv[0]=outv[1]=outv[2]=1.; }\n else if(value<=0.)\n { outv[0]=outv[1]=outv[2]=0.; }\n else if(value1.)\n { outv[0]=outv[1]=outv[2]=1.; }\n else if(value<=0.)\n { outv[0]=outv[1]=outv[2]=0.; }\n else if(value= SIZE_MAX - sizeof(psheader) - 1025) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"IPTC data too large\");\n\t\tRETURN_FALSE;\n\t}\n\n\tif ((fp = VCWD_FOPEN(jpeg_file, \"rb\")) == 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unable to open %s\", jpeg_file);\n\t\tRETURN_FALSE;\n\t}\n\n\tif (spool < 2) {\n\t\tfstat(fileno(fp), &sb);\n\n\t\tpoi = spoolbuf = safe_emalloc(1, (size_t)iptcdata_len + sizeof(psheader) + 1024 + 1, sb.st_size);\n\t\tmemset(poi, 0, iptcdata_len + sizeof(psheader) + sb.st_size + 1024 + 1);\n\t} \n\n\tif (php_iptc_get1(fp, spool, poi?&poi:0 TSRMLS_CC) != 0xFF) {\n\t\tfclose(fp);\n\t\tif (spoolbuf) {\n\t\t\tefree(spoolbuf);\n\t\t}\n\t\tRETURN_FALSE;\n\t}\n\n\tif (php_iptc_get1(fp, spool, poi?&poi:0 TSRMLS_CC) != 0xD8) {\n\t\tfclose(fp);\n\t\tif (spoolbuf) {\n\t\t\tefree(spoolbuf);\n\t\t}\n\t\tRETURN_FALSE;\n\t}\n\n\twhile (!done) {\n\t\tmarker = php_iptc_next_marker(fp, spool, poi?&poi:0 TSRMLS_CC);\n\n\t\tif (marker == M_EOI) { \/* EOF *\/\n\t\t\tbreak;\n\t\t} else if (marker != M_APP13) { \n\t\t\tphp_iptc_put1(fp, spool, (unsigned char)marker, poi?&poi:0 TSRMLS_CC);\n\t\t}\n\n\t\tswitch (marker) {\n\t\t\tcase M_APP13:\n\t\t\t\t\/* we are going to write a new APP13 marker, so don't output the old one *\/\n\t\t\t\tphp_iptc_skip_variable(fp, 0, 0 TSRMLS_CC); \n\t\t\t\tphp_iptc_read_remaining(fp, spool, poi?&poi:0 TSRMLS_CC);\n\t\t\t\tdone = 1;\n\t\t\t\tbreak;\n\n\t\t\tcase M_APP0:\n\t\t\t\t\/* APP0 is in each and every JPEG, so when we hit APP0 we insert our new APP13! *\/\n\t\t\tcase M_APP1:\n\t\t\t\tif (written) {\n\t\t\t\t\t\/* don't try to write the data twice *\/\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\twritten = 1;\n\n\t\t\t\tphp_iptc_skip_variable(fp, spool, poi?&poi:0 TSRMLS_CC);\n\n\t\t\t\tif (iptcdata_len & 1) {\n\t\t\t\t\tiptcdata_len++; \/* make the length even *\/\n\t\t\t\t}\n\n\t\t\t\tpsheader[ 2 ] = (iptcdata_len+28)>>8;\n\t\t\t\tpsheader[ 3 ] = (iptcdata_len+28)&0xff;\n\n\t\t\t\tfor (inx = 0; inx < 28; inx++) {\n\t\t\t\t\tphp_iptc_put1(fp, spool, psheader[inx], poi?&poi:0 TSRMLS_CC);\n\t\t\t\t}\n\n\t\t\t\tphp_iptc_put1(fp, spool, (unsigned char)(iptcdata_len>>8), poi?&poi:0 TSRMLS_CC);\n\t\t\t\tphp_iptc_put1(fp, spool, (unsigned char)(iptcdata_len&0xff), poi?&poi:0 TSRMLS_CC);\n\n\t\t\t\tfor (inx = 0; inx < iptcdata_len; inx++) {\n\t\t\t\t\tphp_iptc_put1(fp, spool, iptcdata[inx], poi?&poi:0 TSRMLS_CC);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase M_SOS:\t\t\t\t\t\t\t\t\n\t\t\t\t\/* we hit data, no more marker-inserting can be done! *\/\n\t\t\t\tphp_iptc_read_remaining(fp, spool, poi?&poi:0 TSRMLS_CC);\n\t\t\t\tdone = 1;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tphp_iptc_skip_variable(fp, spool, poi?&poi:0 TSRMLS_CC);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tfclose(fp);\n\n\tif (spool < 2) {\n\t\tRETVAL_STRINGL(spoolbuf, poi - spoolbuf, 0);\n\t} else {\n\t\tRETURN_TRUE;\n\t}\n}","target":0,"code_token_length":1095,"total_token_length":1331,"max_tokens_setting":2048} +{"idx":157136,"func":"mono_image_emit_manifest (MonoReflectionModuleBuilder *moduleb)\n{\n\tMonoDynamicTable *table;\n\tMonoDynamicImage *assembly;\n\tMonoReflectionAssemblyBuilder *assemblyb;\n\tMonoDomain *domain;\n\tguint32 *values;\n\tint i;\n\tguint32 module_index;\n\n\tassemblyb = moduleb->assemblyb;\n\tassembly = moduleb->dynamic_image;\n\tdomain = mono_object_domain (assemblyb);\n\n\t\/* Emit ASSEMBLY table *\/\n\ttable = &assembly->tables [MONO_TABLE_ASSEMBLY];\n\talloc_table (table, 1);\n\tvalues = table->values + MONO_ASSEMBLY_SIZE;\n\tvalues [MONO_ASSEMBLY_HASH_ALG] = assemblyb->algid? assemblyb->algid: ASSEMBLY_HASH_SHA1;\n\tvalues [MONO_ASSEMBLY_NAME] = string_heap_insert_mstring (&assembly->sheap, assemblyb->name);\n\tif (assemblyb->culture) {\n\t\tvalues [MONO_ASSEMBLY_CULTURE] = string_heap_insert_mstring (&assembly->sheap, assemblyb->culture);\n\t} else {\n\t\tvalues [MONO_ASSEMBLY_CULTURE] = string_heap_insert (&assembly->sheap, \"\");\n\t}\n\tvalues [MONO_ASSEMBLY_PUBLIC_KEY] = load_public_key (assemblyb->public_key, assembly);\n\tvalues [MONO_ASSEMBLY_FLAGS] = assemblyb->flags;\n\tset_version_from_string (assemblyb->version, values);\n\n\t\/* Emit FILE + EXPORTED_TYPE table *\/\n\tmodule_index = 0;\n\tfor (i = 0; i < mono_array_length (assemblyb->modules); ++i) {\n\t\tint j;\n\t\tMonoReflectionModuleBuilder *file_module = \n\t\t\tmono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i);\n\t\tif (file_module != moduleb) {\n\t\t\tmono_image_fill_file_table (domain, (MonoReflectionModule*)file_module, assembly);\n\t\t\tmodule_index ++;\n\t\t\tif (file_module->types) {\n\t\t\t\tfor (j = 0; j < file_module->num_types; ++j) {\n\t\t\t\t\tMonoReflectionTypeBuilder *tb = mono_array_get (file_module->types, MonoReflectionTypeBuilder*, j);\n\t\t\t\t\tmono_image_fill_export_table (domain, tb, module_index, 0, assembly);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (assemblyb->loaded_modules) {\n\t\tfor (i = 0; i < mono_array_length (assemblyb->loaded_modules); ++i) {\n\t\t\tMonoReflectionModule *file_module = \n\t\t\t\tmono_array_get (assemblyb->loaded_modules, MonoReflectionModule*, i);\n\t\t\tmono_image_fill_file_table (domain, file_module, assembly);\n\t\t\tmodule_index ++;\n\t\t\tmono_image_fill_export_table_from_module (domain, file_module, module_index, assembly);\n\t\t}\n\t}\n\tif (assemblyb->type_forwarders)\n\t\tmono_image_fill_export_table_from_type_forwarders (assemblyb, assembly);\n\n\t\/* Emit MANIFESTRESOURCE table *\/\n\tmodule_index = 0;\n\tfor (i = 0; i < mono_array_length (assemblyb->modules); ++i) {\n\t\tint j;\n\t\tMonoReflectionModuleBuilder *file_module = \n\t\t\tmono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i);\n\t\t\/* The table for the main module is emitted later *\/\n\t\tif (file_module != moduleb) {\n\t\t\tmodule_index ++;\n\t\t\tif (file_module->resources) {\n\t\t\t\tint len = mono_array_length (file_module->resources);\n\t\t\t\tfor (j = 0; j < len; ++j) {\n\t\t\t\t\tMonoReflectionResource* res = (MonoReflectionResource*)mono_array_addr (file_module->resources, MonoReflectionResource, j);\n\t\t\t\t\tassembly_add_resource_manifest (file_module, assembly, res, MONO_IMPLEMENTATION_FILE | (module_index << MONO_IMPLEMENTATION_BITS));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\t\t\n}","target":0,"code_token_length":823,"total_token_length":1059,"max_tokens_setting":2048} +{"idx":484409,"func":"static RzList *create_cache_bins(RzDyldCache *cache) {\n\tRzList *bins = rz_list_newf((RzListFree)free_bin);\n\tif (!bins) {\n\t\treturn NULL;\n\t}\n\n\tchar *target_libs = NULL;\n\tRzList *target_lib_names = NULL;\n\tint *deps = NULL;\n\ttarget_libs = rz_sys_getenv(\"RZ_DYLDCACHE_FILTER\");\n\tif (target_libs) {\n\t\ttarget_lib_names = rz_str_split_list(target_libs, \":\", 0);\n\t\tif (!target_lib_names) {\n\t\t\trz_list_free(bins);\n\t\t\treturn NULL;\n\t\t}\n\t\tdeps = RZ_NEWS0(int, cache->hdr->imagesCount);\n\t\tif (!deps) {\n\t\t\trz_list_free(bins);\n\t\t\trz_list_free(target_lib_names);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tut32 i;\n\tfor (i = 0; i < cache->n_hdr; i++) {\n\t\tcache_hdr_t *hdr = &cache->hdr[i];\n\t\tut64 hdr_offset = cache->hdr_offset[i];\n\t\tut64 symbols_off = cache->symbols_off_base - hdr_offset;\n\t\tut32 maps_index = cache->maps_index[i];\n\t\tcache_img_t *img = read_cache_images(cache->buf, hdr, hdr_offset);\n\t\tif (!img) {\n\t\t\tgoto next;\n\t\t}\n\n\t\tut32 j;\n\t\tut16 *depArray = NULL;\n\t\tcache_imgxtr_t *extras = NULL;\n\t\tif (target_libs) {\n\t\t\tHtPU *path_to_idx = NULL;\n\t\t\tif (cache->accel) {\n\t\t\t\tdepArray = RZ_NEWS0(ut16, cache->accel->depListCount);\n\t\t\t\tif (!depArray) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\n\t\t\t\tif (rz_buf_fread_at(cache->buf, cache->accel->depListOffset, (ut8 *)depArray, \"s\", cache->accel->depListCount) != cache->accel->depListCount * 2) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\n\t\t\t\textras = read_cache_imgextra(cache->buf, hdr, cache->accel);\n\t\t\t\tif (!extras) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpath_to_idx = create_path_to_index(cache->buf, img, hdr);\n\t\t\t}\n\n\t\t\tfor (j = 0; j < hdr->imagesCount; j++) {\n\t\t\t\tbool printing = !deps[j];\n\t\t\t\tchar *lib_name = get_lib_name(cache->buf, &img[j]);\n\t\t\t\tif (!lib_name) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (strstr(lib_name, \"libobjc.A.dylib\")) {\n\t\t\t\t\tdeps[j]++;\n\t\t\t\t}\n\t\t\t\tif (!rz_list_find(target_lib_names, lib_name, string_contains)) {\n\t\t\t\t\tRZ_FREE(lib_name);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (printing) {\n\t\t\t\t\tRZ_LOG_INFO(\"FILTER: %s\\n\", lib_name);\n\t\t\t\t}\n\t\t\t\tRZ_FREE(lib_name);\n\t\t\t\tdeps[j]++;\n\n\t\t\t\tif (extras && depArray) {\n\t\t\t\t\tut32 k;\n\t\t\t\t\tfor (k = extras[j].dependentsStartArrayIndex; depArray[k] != 0xffff; k++) {\n\t\t\t\t\t\tut16 dep_index = depArray[k] & 0x7fff;\n\t\t\t\t\t\tdeps[dep_index]++;\n\n\t\t\t\t\t\tchar *dep_name = get_lib_name(cache->buf, &img[dep_index]);\n\t\t\t\t\t\tif (!dep_name) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (printing) {\n\t\t\t\t\t\t\tRZ_LOG_INFO(\"-> %s\\n\", dep_name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfree(dep_name);\n\t\t\t\t\t}\n\t\t\t\t} else if (path_to_idx) {\n\t\t\t\t\tcarve_deps_at_address(cache, img, path_to_idx, img[j].address, deps, printing);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tht_pu_free(path_to_idx);\n\t\t\tRZ_FREE(depArray);\n\t\t\tRZ_FREE(extras);\n\t\t}\n\n\t\tfor (j = 0; j < hdr->imagesCount; j++) {\n\t\t\tif (deps && !deps[j]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tut64 pa = va2pa(img[j].address, hdr->mappingCount, &cache->maps[maps_index], cache->buf, 0, NULL, NULL);\n\t\t\tif (pa == UT64_MAX) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tut8 magicbytes[4];\n\t\t\trz_buf_read_at(cache->buf, pa, magicbytes, 4);\n\t\t\tint magic = rz_read_le32(magicbytes);\n\t\t\tswitch (magic) {\n\t\t\tcase MH_MAGIC_64: {\n\t\t\t\tchar file[256];\n\t\t\t\tRzDyldBinImage *bin = RZ_NEW0(RzDyldBinImage);\n\t\t\t\tif (!bin) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\t\t\t\tbin->header_at = pa;\n\t\t\t\tbin->hdr_offset = hdr_offset;\n\t\t\t\tbin->symbols_off = symbols_off;\n\t\t\t\tbin->va = img[j].address;\n\t\t\t\tif (rz_buf_read_at(cache->buf, img[j].pathFileOffset, (ut8 *)&file, sizeof(file)) == sizeof(file)) {\n\t\t\t\t\tfile[255] = 0;\n\t\t\t\t\tchar *last_slash = strrchr(file, '\/');\n\t\t\t\t\tif (last_slash && *last_slash) {\n\t\t\t\t\t\tif (last_slash > file) {\n\t\t\t\t\t\t\tchar *scan = last_slash - 1;\n\t\t\t\t\t\t\twhile (scan > file && *scan != '\/') {\n\t\t\t\t\t\t\t\tscan--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (*scan == '\/') {\n\t\t\t\t\t\t\t\tbin->file = strdup(scan + 1);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tbin->file = strdup(last_slash + 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbin->file = strdup(last_slash + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbin->file = strdup(file);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trz_list_append(bins, bin);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tRZ_LOG_WARN(\"Unknown sub-bin\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\tnext:\n\t\tRZ_FREE(depArray);\n\t\tRZ_FREE(extras);\n\t\tRZ_FREE(img);\n\t}\n\tif (rz_list_empty(bins)) {\n\t\trz_list_free(bins);\n\t\tbins = NULL;\n\t}\n\tRZ_FREE(deps);\n\tRZ_FREE(target_libs);\n\trz_list_free(target_lib_names);\n\treturn bins;\n}","target":0,"code_token_length":1386,"total_token_length":1622,"max_tokens_setting":2048} +{"idx":268907,"func":"static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport)\n{\n\tstruct sk_buff *skb;\n\tstruct sadb_msg *hdr;\n\tstruct sadb_sa *sa;\n\tstruct sadb_address *addr;\n\tstruct sadb_x_nat_t_port *n_port;\n\tint sockaddr_size;\n\tint size;\n\t__u8 satype = (x->id.proto == IPPROTO_ESP ? SADB_SATYPE_ESP : 0);\n\tstruct xfrm_encap_tmpl *natt = NULL;\n\n\tsockaddr_size = pfkey_sockaddr_size(x->props.family);\n\tif (!sockaddr_size)\n\t\treturn -EINVAL;\n\n\tif (!satype)\n\t\treturn -EINVAL;\n\n\tif (!x->encap)\n\t\treturn -EINVAL;\n\n\tnatt = x->encap;\n\n\t\/* Build an SADB_X_NAT_T_NEW_MAPPING message:\n\t *\n\t * HDR | SA | ADDRESS_SRC (old addr) | NAT_T_SPORT (old port) |\n\t * ADDRESS_DST (new addr) | NAT_T_DPORT (new port)\n\t *\/\n\n\tsize = sizeof(struct sadb_msg) +\n\t\tsizeof(struct sadb_sa) +\n\t\t(sizeof(struct sadb_address) * 2) +\n\t\t(sockaddr_size * 2) +\n\t\t(sizeof(struct sadb_x_nat_t_port) * 2);\n\n\tskb = alloc_skb(size + 16, GFP_ATOMIC);\n\tif (skb == NULL)\n\t\treturn -ENOMEM;\n\n\thdr = skb_put(skb, sizeof(struct sadb_msg));\n\thdr->sadb_msg_version = PF_KEY_V2;\n\thdr->sadb_msg_type = SADB_X_NAT_T_NEW_MAPPING;\n\thdr->sadb_msg_satype = satype;\n\thdr->sadb_msg_len = size \/ sizeof(uint64_t);\n\thdr->sadb_msg_errno = 0;\n\thdr->sadb_msg_reserved = 0;\n\thdr->sadb_msg_seq = x->km.seq = get_acqseq();\n\thdr->sadb_msg_pid = 0;\n\n\t\/* SA *\/\n\tsa = skb_put(skb, sizeof(struct sadb_sa));\n\tsa->sadb_sa_len = sizeof(struct sadb_sa)\/sizeof(uint64_t);\n\tsa->sadb_sa_exttype = SADB_EXT_SA;\n\tsa->sadb_sa_spi = x->id.spi;\n\tsa->sadb_sa_replay = 0;\n\tsa->sadb_sa_state = 0;\n\tsa->sadb_sa_auth = 0;\n\tsa->sadb_sa_encrypt = 0;\n\tsa->sadb_sa_flags = 0;\n\n\t\/* ADDRESS_SRC (old addr) *\/\n\taddr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);\n\taddr->sadb_address_len =\n\t\t(sizeof(struct sadb_address)+sockaddr_size)\/\n\t\t\tsizeof(uint64_t);\n\taddr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;\n\taddr->sadb_address_proto = 0;\n\taddr->sadb_address_reserved = 0;\n\taddr->sadb_address_prefixlen =\n\t\tpfkey_sockaddr_fill(&x->props.saddr, 0,\n\t\t\t\t (struct sockaddr *) (addr + 1),\n\t\t\t\t x->props.family);\n\tif (!addr->sadb_address_prefixlen)\n\t\tBUG();\n\n\t\/* NAT_T_SPORT (old port) *\/\n\tn_port = skb_put(skb, sizeof(*n_port));\n\tn_port->sadb_x_nat_t_port_len = sizeof(*n_port)\/sizeof(uint64_t);\n\tn_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT;\n\tn_port->sadb_x_nat_t_port_port = natt->encap_sport;\n\tn_port->sadb_x_nat_t_port_reserved = 0;\n\n\t\/* ADDRESS_DST (new addr) *\/\n\taddr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);\n\taddr->sadb_address_len =\n\t\t(sizeof(struct sadb_address)+sockaddr_size)\/\n\t\t\tsizeof(uint64_t);\n\taddr->sadb_address_exttype = SADB_EXT_ADDRESS_DST;\n\taddr->sadb_address_proto = 0;\n\taddr->sadb_address_reserved = 0;\n\taddr->sadb_address_prefixlen =\n\t\tpfkey_sockaddr_fill(ipaddr, 0,\n\t\t\t\t (struct sockaddr *) (addr + 1),\n\t\t\t\t x->props.family);\n\tif (!addr->sadb_address_prefixlen)\n\t\tBUG();\n\n\t\/* NAT_T_DPORT (new port) *\/\n\tn_port = skb_put(skb, sizeof(*n_port));\n\tn_port->sadb_x_nat_t_port_len = sizeof(*n_port)\/sizeof(uint64_t);\n\tn_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT;\n\tn_port->sadb_x_nat_t_port_port = sport;\n\tn_port->sadb_x_nat_t_port_reserved = 0;\n\n\treturn pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,\n\t\t\t xs_net(x));\n}","target":0,"code_token_length":1045,"total_token_length":1281,"max_tokens_setting":2048} +{"idx":275034,"func":"GBool StreamPredictor::getNextLine() {\n int curPred;\n Guchar upLeftBuf[gfxColorMaxComps * 2 + 1];\n int left, up, upLeft, p, pa, pb, pc;\n int c;\n Gulong inBuf, outBuf, bitMask;\n int inBits, outBits;\n int i, j, k, kk;\n\n if (predictor >= 10) {\n if ((curPred = str->getRawChar()) == EOF) {\n return gFalse;\n }\n curPred += 10;\n } else {\n curPred = predictor;\n }\n\n int *rawCharLine = new int[rowBytes - pixBytes];\n str->getRawChars(rowBytes - pixBytes, rawCharLine);\n memset(upLeftBuf, 0, pixBytes + 1);\n for (i = pixBytes; i < rowBytes; ++i) {\n for (j = pixBytes; j > 0; --j) {\n upLeftBuf[j] = upLeftBuf[j-1];\n }\n upLeftBuf[0] = predLine[i];\n if ((c = rawCharLine[i - pixBytes]) == EOF) {\n if (i > pixBytes) {\n\tbreak;\n }\n delete[] rawCharLine;\n return gFalse;\n }\n switch (curPred) {\n case 11:\t\t\t\/\/ PNG sub\n predLine[i] = predLine[i - pixBytes] + (Guchar)c;\n break;\n case 12:\t\t\t\/\/ PNG up\n predLine[i] = predLine[i] + (Guchar)c;\n break;\n case 13:\t\t\t\/\/ PNG average\n predLine[i] = ((predLine[i - pixBytes] + predLine[i]) >> 1) +\n\t (Guchar)c;\n break;\n case 14:\t\t\t\/\/ PNG Paeth\n left = predLine[i - pixBytes];\n up = predLine[i];\n upLeft = upLeftBuf[pixBytes];\n p = left + up - upLeft;\n if ((pa = p - left) < 0)\n\tpa = -pa;\n if ((pb = p - up) < 0)\n\tpb = -pb;\n if ((pc = p - upLeft) < 0)\n\tpc = -pc;\n if (pa <= pb && pa <= pc)\n\tpredLine[i] = left + (Guchar)c;\n else if (pb <= pc)\n\tpredLine[i] = up + (Guchar)c;\n else\n\tpredLine[i] = upLeft + (Guchar)c;\n break;\n case 10:\t\t\t\/\/ PNG none\n default:\t\t\t\/\/ no predictor or TIFF predictor\n predLine[i] = (Guchar)c;\n break;\n }\n }\n delete[] rawCharLine;\n\n if (predictor == 2) {\n if (nBits == 1) {\n inBuf = predLine[pixBytes - 1];\n for (i = pixBytes; i < rowBytes; i += 8) {\n\tinBuf = (inBuf << 8) | predLine[i];\n\tpredLine[i] ^= inBuf >> nComps;\n }\n } else if (nBits == 8) {\n for (i = pixBytes; i < rowBytes; ++i) {\n\tpredLine[i] += predLine[i - nComps];\n }\n } else {\n memset(upLeftBuf, 0, nComps + 1);\n bitMask = (1 << nBits) - 1;\n inBuf = outBuf = 0;\n inBits = outBits = 0;\n j = k = pixBytes;\n for (i = 0; i < width; ++i) {\n\tfor (kk = 0; kk < nComps; ++kk) {\n\t if (inBits < nBits) {\n\t inBuf = (inBuf << 8) | (predLine[j++] & 0xff);\n\t inBits += 8;\n\t }\n\t upLeftBuf[kk] = (Guchar)((upLeftBuf[kk] +\n\t\t\t\t (inBuf >> (inBits - nBits))) & bitMask);\n\t inBits -= nBits;\n\t outBuf = (outBuf << nBits) | upLeftBuf[kk];\n\t outBits += nBits;\n\t if (outBits >= 8) {\n\t predLine[k++] = (Guchar)(outBuf >> (outBits - 8));\n\t outBits -= 8;\n\t }\n\t}\n }\n if (outBits > 0) {\n\tpredLine[k++] = (Guchar)((outBuf << (8 - outBits)) +\n\t\t\t\t (inBuf & ((1 << (8 - outBits)) - 1)));\n }\n }\n }\n\n predIdx = pixBytes;\n\n return gTrue;\n}\n","target":0,"code_token_length":1070,"total_token_length":1306,"max_tokens_setting":2048} +{"idx":345977,"func":"int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr,\n\t\t char *buf, int *len_ptr)\n{\n\tint len, iflags = 0;\n\tstruct file_list *flist;\n\tuchar fnamecmp_type = FNAMECMP_FNAME;\n\tint ndx;\n\n read_loop:\n\twhile (1) {\n\t\tndx = read_ndx(f_in);\n\n\t\tif (ndx >= 0)\n\t\t\tbreak;\n\t\tif (ndx == NDX_DONE)\n\t\t\treturn ndx;\n\t\tif (ndx == NDX_DEL_STATS) {\n\t\t\tread_del_stats(f_in);\n\t\t\tif (am_sender && am_server)\n\t\t\t\twrite_del_stats(f_out);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!inc_recurse || am_sender) {\n\t\t\tint last;\n\t\t\tif (first_flist)\n\t\t\t\tlast = first_flist->prev->ndx_start + first_flist->prev->used - 1;\n\t\t\telse\n\t\t\t\tlast = -1;\n\t\t\trprintf(FERROR,\n\t\t\t\t\"Invalid file index: %d (%d - %d) [%s]\\n\",\n\t\t\t\tndx, NDX_DONE, last, who_am_i());\n\t\t\texit_cleanup(RERR_PROTOCOL);\n\t\t}\n\t\tif (ndx == NDX_FLIST_EOF) {\n\t\t\tflist_eof = 1;\n\t\t\tif (DEBUG_GTE(FLIST, 3))\n\t\t\t\trprintf(FINFO, \"[%s] flist_eof=1\\n\", who_am_i());\n\t\t\twrite_int(f_out, NDX_FLIST_EOF);\n\t\t\tcontinue;\n\t\t}\n\t\tndx = NDX_FLIST_OFFSET - ndx;\n\t\tif (ndx < 0 || ndx >= dir_flist->used) {\n\t\t\tndx = NDX_FLIST_OFFSET - ndx;\n\t\t\trprintf(FERROR,\n\t\t\t\t\"Invalid dir index: %d (%d - %d) [%s]\\n\",\n\t\t\t\tndx, NDX_FLIST_OFFSET,\n\t\t\t\tNDX_FLIST_OFFSET - dir_flist->used + 1,\n\t\t\t\twho_am_i());\n\t\t\texit_cleanup(RERR_PROTOCOL);\n\t\t}\n\n\t\tif (DEBUG_GTE(FLIST, 2)) {\n\t\t\trprintf(FINFO, \"[%s] receiving flist for dir %d\\n\",\n\t\t\t\twho_am_i(), ndx);\n\t\t}\n\t\t\/* Send all the data we read for this flist to the generator. *\/\n\t\tstart_flist_forward(ndx);\n\t\tflist = recv_file_list(f_in);\n\t\tflist->parent_ndx = ndx;\n\t\tstop_flist_forward();\n\t}\n\n\tiflags = protocol_version >= 29 ? read_shortint(f_in)\n\t\t : ITEM_TRANSFER | ITEM_MISSING_DATA;\n\n\t\/* Support the protocol-29 keep-alive style. *\/\n\tif (protocol_version < 30 && ndx == cur_flist->used && iflags == ITEM_IS_NEW) {\n\t\tif (am_sender)\n\t\t\tmaybe_send_keepalive(time(NULL), MSK_ALLOW_FLUSH);\n\t\tgoto read_loop;\n\t}\n\n\tflist = flist_for_ndx(ndx, \"read_ndx_and_attrs\");\n\tif (flist != cur_flist) {\n\t\tcur_flist = flist;\n\t\tif (am_sender) {\n\t\t\tfile_old_total = cur_flist->used;\n\t\t\tfor (flist = first_flist; flist != cur_flist; flist = flist->next)\n\t\t\t\tfile_old_total += flist->used;\n\t\t}\n\t}\n\n\tif (iflags & ITEM_BASIS_TYPE_FOLLOWS)\n\t\tfnamecmp_type = read_byte(f_in);\n\t*type_ptr = fnamecmp_type;\n\n\tif (iflags & ITEM_XNAME_FOLLOWS) {\n\t\tif ((len = read_vstring(f_in, buf, MAXPATHLEN)) < 0)\n\t\t\texit_cleanup(RERR_PROTOCOL);\n\t} else {\n\t\t*buf = '\\0';\n\t\tlen = -1;\n\t}\n\t*len_ptr = len;\n\n\tif (iflags & ITEM_TRANSFER) {\n\t\tint i = ndx - cur_flist->ndx_start;\n\t\tif (i < 0 || !S_ISREG(cur_flist->files[i]->mode)) {\n\t\t\trprintf(FERROR,\n\t\t\t\t\"received request to transfer non-regular file: %d [%s]\\n\",\n\t\t\t\tndx, who_am_i());\n\t\t\texit_cleanup(RERR_PROTOCOL);\n\t\t}\n\t}\n\n\t*iflag_ptr = iflags;\n\treturn ndx;\n}","target":1,"code_token_length":934,"total_token_length":1170,"max_tokens_setting":2048} +{"idx":333302,"func":"static void rv30_loop_filter(RV34DecContext *r, int row)\n\n{\n\n MpegEncContext *s = &r->s;\n\n int mb_pos, mb_x;\n\n int i, j, k;\n\n uint8_t *Y, *C;\n\n int loc_lim, cur_lim, left_lim = 0, top_lim = 0;\n\n\n\n mb_pos = row * s->mb_stride;\n\n for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){\n\n int mbtype = s->current_picture_ptr->mb_type[mb_pos];\n\n if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype))\n\n r->deblock_coefs[mb_pos] = 0xFFFF;\n\n if(IS_INTRA(mbtype))\n\n r->cbp_chroma[mb_pos] = 0xFF;\n\n }\n\n\n\n \/* all vertical edges are filtered first\n\n * and horizontal edges are filtered on the next iteration\n\n *\/\n\n mb_pos = row * s->mb_stride;\n\n for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){\n\n cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]];\n\n if(mb_x)\n\n left_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - 1]];\n\n for(j = 0; j < 16; j += 4){\n\n Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x;\n\n for(i = !mb_x; i < 4; i++, Y += 4){\n\n int ij = i + j;\n\n loc_lim = 0;\n\n if(r->deblock_coefs[mb_pos] & (1 << ij))\n\n loc_lim = cur_lim;\n\n else if(!i && r->deblock_coefs[mb_pos - 1] & (1 << (ij + 3)))\n\n loc_lim = left_lim;\n\n else if( i && r->deblock_coefs[mb_pos] & (1 << (ij - 1)))\n\n loc_lim = cur_lim;\n\n if(loc_lim)\n\n rv30_weak_loop_filter(Y, 1, s->linesize, loc_lim);\n\n }\n\n }\n\n for(k = 0; k < 2; k++){\n\n int cur_cbp, left_cbp = 0;\n\n cur_cbp = (r->cbp_chroma[mb_pos] >> (k*4)) & 0xF;\n\n if(mb_x)\n\n left_cbp = (r->cbp_chroma[mb_pos - 1] >> (k*4)) & 0xF;\n\n for(j = 0; j < 8; j += 4){\n\n C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x;\n\n for(i = !mb_x; i < 2; i++, C += 4){\n\n int ij = i + (j >> 1);\n\n loc_lim = 0;\n\n if (cur_cbp & (1 << ij))\n\n loc_lim = cur_lim;\n\n else if(!i && left_cbp & (1 << (ij + 1)))\n\n loc_lim = left_lim;\n\n else if( i && cur_cbp & (1 << (ij - 1)))\n\n loc_lim = cur_lim;\n\n if(loc_lim)\n\n rv30_weak_loop_filter(C, 1, s->uvlinesize, loc_lim);\n\n }\n\n }\n\n }\n\n }\n\n mb_pos = row * s->mb_stride;\n\n for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){\n\n cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]];\n\n if(row)\n\n top_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - s->mb_stride]];\n\n for(j = 4*!row; j < 16; j += 4){\n\n Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize;\n\n for(i = 0; i < 4; i++, Y += 4){\n\n int ij = i + j;\n\n loc_lim = 0;\n\n if(r->deblock_coefs[mb_pos] & (1 << ij))\n\n loc_lim = cur_lim;\n\n else if(!j && r->deblock_coefs[mb_pos - s->mb_stride] & (1 << (ij + 12)))\n\n loc_lim = top_lim;\n\n else if( j && r->deblock_coefs[mb_pos] & (1 << (ij - 4)))\n\n loc_lim = cur_lim;\n\n if(loc_lim)\n\n rv30_weak_loop_filter(Y, s->linesize, 1, loc_lim);\n\n }\n\n }\n\n for(k = 0; k < 2; k++){\n\n int cur_cbp, top_cbp = 0;\n\n cur_cbp = (r->cbp_chroma[mb_pos] >> (k*4)) & 0xF;\n\n if(row)\n\n top_cbp = (r->cbp_chroma[mb_pos - s->mb_stride] >> (k*4)) & 0xF;\n\n for(j = 4*!row; j < 8; j += 4){\n\n C = s->current_picture_ptr->f.data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize;\n\n for(i = 0; i < 2; i++, C += 4){\n\n int ij = i + (j >> 1);\n\n loc_lim = 0;\n\n if (r->cbp_chroma[mb_pos] & (1 << ij))\n\n loc_lim = cur_lim;\n\n else if(!j && top_cbp & (1 << (ij + 2)))\n\n loc_lim = top_lim;\n\n else if( j && cur_cbp & (1 << (ij - 2)))\n\n loc_lim = cur_lim;\n\n if(loc_lim)\n\n rv30_weak_loop_filter(C, s->uvlinesize, 1, loc_lim);\n\n }\n\n }\n\n }\n\n }\n\n}\n","target":1,"code_token_length":1412,"total_token_length":1648,"max_tokens_setting":2048} +{"idx":464805,"func":"static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,\n\t\t\t\tstruct file *file, void *fh, void *arg)\n{\n\tstruct v4l2_format *p = arg;\n\tstruct video_device *vfd = video_devdata(file);\n\tint ret = check_fmt(file, p->type);\n\tunsigned int i;\n\n\tif (ret)\n\t\treturn ret;\n\n\tv4l_sanitize_format(p);\n\n\tswitch (p->type) {\n\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vid_cap))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.pix);\n\t\tret = ops->vidioc_try_fmt_vid_cap(file, fh, arg);\n\t\t\/* just in case the driver zeroed it again *\/\n\t\tp->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;\n\t\tif (vfd->vfl_type == VFL_TYPE_TOUCH)\n\t\t\tv4l_pix_format_touch(&p->fmt.pix);\n\t\treturn ret;\n\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func);\n\t\tfor (i = 0; i < p->fmt.pix_mp.num_planes; i++)\n\t\t\tCLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i],\n\t\t\t\t\t bytesperline);\n\t\treturn ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg);\n\tcase V4L2_BUF_TYPE_VIDEO_OVERLAY:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vid_overlay))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.win);\n\t\treturn ops->vidioc_try_fmt_vid_overlay(file, fh, arg);\n\tcase V4L2_BUF_TYPE_VBI_CAPTURE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vbi_cap))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.vbi.flags);\n\t\treturn ops->vidioc_try_fmt_vbi_cap(file, fh, arg);\n\tcase V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_sliced_vbi_cap))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.sliced.io_size);\n\t\treturn ops->vidioc_try_fmt_sliced_vbi_cap(file, fh, arg);\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vid_out))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.pix);\n\t\tret = ops->vidioc_try_fmt_vid_out(file, fh, arg);\n\t\t\/* just in case the driver zeroed it again *\/\n\t\tp->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;\n\t\treturn ret;\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vid_out_mplane))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func);\n\t\tfor (i = 0; i < p->fmt.pix_mp.num_planes; i++)\n\t\t\tCLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i],\n\t\t\t\t\t bytesperline);\n\t\treturn ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg);\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vid_out_overlay))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.win);\n\t\treturn ops->vidioc_try_fmt_vid_out_overlay(file, fh, arg);\n\tcase V4L2_BUF_TYPE_VBI_OUTPUT:\n\t\tif (unlikely(!ops->vidioc_try_fmt_vbi_out))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.vbi.flags);\n\t\treturn ops->vidioc_try_fmt_vbi_out(file, fh, arg);\n\tcase V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:\n\t\tif (unlikely(!ops->vidioc_try_fmt_sliced_vbi_out))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.sliced.io_size);\n\t\treturn ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg);\n\tcase V4L2_BUF_TYPE_SDR_CAPTURE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_sdr_cap))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.sdr.buffersize);\n\t\treturn ops->vidioc_try_fmt_sdr_cap(file, fh, arg);\n\tcase V4L2_BUF_TYPE_SDR_OUTPUT:\n\t\tif (unlikely(!ops->vidioc_try_fmt_sdr_out))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.sdr.buffersize);\n\t\treturn ops->vidioc_try_fmt_sdr_out(file, fh, arg);\n\tcase V4L2_BUF_TYPE_META_CAPTURE:\n\t\tif (unlikely(!ops->vidioc_try_fmt_meta_cap))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.meta);\n\t\treturn ops->vidioc_try_fmt_meta_cap(file, fh, arg);\n\tcase V4L2_BUF_TYPE_META_OUTPUT:\n\t\tif (unlikely(!ops->vidioc_try_fmt_meta_out))\n\t\t\tbreak;\n\t\tCLEAR_AFTER_FIELD(p, fmt.meta);\n\t\treturn ops->vidioc_try_fmt_meta_out(file, fh, arg);\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":1098,"total_token_length":1334,"max_tokens_setting":2048} +{"idx":355899,"func":"static int __init vdso_init(void)\n{\n\tint i;\n\n#ifdef CONFIG_PPC64\n\t\/*\n\t * Fill up the \"systemcfg\" stuff for backward compatiblity\n\t *\/\n\tstrcpy((char *)vdso_data->eye_catcher, \"SYSTEMCFG:PPC64\");\n\tvdso_data->version.major = SYSTEMCFG_MAJOR;\n\tvdso_data->version.minor = SYSTEMCFG_MINOR;\n\tvdso_data->processor = mfspr(SPRN_PVR);\n\t\/*\n\t * Fake the old platform number for pSeries and iSeries and add\n\t * in LPAR bit if necessary\n\t *\/\n\tvdso_data->platform = machine_is(iseries) ? 0x200 : 0x100;\n\tif (firmware_has_feature(FW_FEATURE_LPAR))\n\t\tvdso_data->platform |= 1;\n\tvdso_data->physicalMemorySize = lmb_phys_mem_size();\n\tvdso_data->dcache_size = ppc64_caches.dsize;\n\tvdso_data->dcache_line_size = ppc64_caches.dline_size;\n\tvdso_data->icache_size = ppc64_caches.isize;\n\tvdso_data->icache_line_size = ppc64_caches.iline_size;\n\n\t\/* XXXOJN: Blocks should be added to ppc64_caches and used instead *\/\n\tvdso_data->dcache_block_size = ppc64_caches.dline_size;\n\tvdso_data->icache_block_size = ppc64_caches.iline_size;\n\tvdso_data->dcache_log_block_size = ppc64_caches.log_dline_size;\n\tvdso_data->icache_log_block_size = ppc64_caches.log_iline_size;\n\n\t\/*\n\t * Calculate the size of the 64 bits vDSO\n\t *\/\n\tvdso64_pages = (&vdso64_end - &vdso64_start) >> PAGE_SHIFT;\n\tDBG(\"vdso64_kbase: %p, 0x%x pages\\n\", vdso64_kbase, vdso64_pages);\n#else\n\tvdso_data->dcache_block_size = L1_CACHE_BYTES;\n\tvdso_data->dcache_log_block_size = L1_CACHE_SHIFT;\n\tvdso_data->icache_block_size = L1_CACHE_BYTES;\n\tvdso_data->icache_log_block_size = L1_CACHE_SHIFT;\n#endif \/* CONFIG_PPC64 *\/\n\n\n\t\/*\n\t * Calculate the size of the 32 bits vDSO\n\t *\/\n\tvdso32_pages = (&vdso32_end - &vdso32_start) >> PAGE_SHIFT;\n\tDBG(\"vdso32_kbase: %p, 0x%x pages\\n\", vdso32_kbase, vdso32_pages);\n\n\n\t\/*\n\t * Setup the syscall map in the vDOS\n\t *\/\n\tvdso_setup_syscall_map();\n\n\t\/*\n\t * Initialize the vDSO images in memory, that is do necessary\n\t * fixups of vDSO symbols, locate trampolines, etc...\n\t *\/\n\tif (vdso_setup()) {\n\t\tprintk(KERN_ERR \"vDSO setup failure, not enabled !\\n\");\n\t\tvdso32_pages = 0;\n#ifdef CONFIG_PPC64\n\t\tvdso64_pages = 0;\n#endif\n\t\treturn 0;\n\t}\n\n\t\/* Make sure pages are in the correct state *\/\n\tvdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2),\n\t\t\t\t GFP_KERNEL);\n\tBUG_ON(vdso32_pagelist == NULL);\n\tfor (i = 0; i < vdso32_pages; i++) {\n\t\tstruct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);\n\t\tClearPageReserved(pg);\n\t\tget_page(pg);\n\t\tvdso32_pagelist[i] = pg;\n\t}\n\tvdso32_pagelist[i++] = virt_to_page(vdso_data);\n\tvdso32_pagelist[i] = NULL;\n\n#ifdef CONFIG_PPC64\n\tvdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2),\n\t\t\t\t GFP_KERNEL);\n\tBUG_ON(vdso64_pagelist == NULL);\n\tfor (i = 0; i < vdso64_pages; i++) {\n\t\tstruct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);\n\t\tClearPageReserved(pg);\n\t\tget_page(pg);\n\t\tvdso64_pagelist[i] = pg;\n\t}\n\tvdso64_pagelist[i++] = virt_to_page(vdso_data);\n\tvdso64_pagelist[i] = NULL;\n#endif \/* CONFIG_PPC64 *\/\n\n\tget_page(virt_to_page(vdso_data));\n\n\tsmp_wmb();\n\tvdso_ready = 1;\n\n\treturn 0;\n}","target":0,"code_token_length":1060,"total_token_length":1296,"max_tokens_setting":2048} +{"idx":340700,"func":"static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride)\n\n{\n\n\tint x,y;\n\n\t\n\n\tdst[0]= src[0];\n\n \n\n\t\/\/ first line\n\n\tfor(x=0; x>2;\n\n\t\tdst[2*x+2]= ( src[x] + 3*src[x+1])>>2;\n\n\t}\n\n\tdst[2*srcWidth-1]= src[srcWidth-1];\n\n\t\n\n dst+= dstStride;\n\n\n\n\tfor(y=1; y>2;\n\n\t\tdst[dstStride]= ( src[0] + 3*src[srcStride])>>2;\n\n\n\n\t\tfor(x=mmxSize-1; x>2;\n\n\t\t\tdst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2;\n\n\t\t\tdst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2;\n\n\t\t\tdst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;\n\n\t\t}\n\n\t\tdst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2;\n\n\t\tdst[srcWidth*2 -1 + dstStride]= ( src[srcWidth-1] + 3*src[srcWidth-1 + srcStride])>>2;\n\n\n\n\t\tdst+=dstStride*2;\n\n\t\tsrc+=srcStride;\n\n\t}\n\n\t\n\n\t\/\/ last line\n\n#if 1\n\n\tdst[0]= src[0];\n\n \n\n\tfor(x=0; x>2;\n\n\t\tdst[2*x+2]= ( src[x] + 3*src[x+1])>>2;\n\n\t}\n\n\tdst[2*srcWidth-1]= src[srcWidth-1];\n\n#else\n\n\tfor(x=0; x rwhva,\n scoped_refptr subscriber_texture,\n scoped_refptr video_frame,\n const base::Callback& callback,\n scoped_ptr result) {\n base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));\n base::ScopedClosureRunner scoped_return_subscriber_texture(\n base::Bind(&ReturnSubscriberTexture, rwhva, subscriber_texture, 0));\n\n if (!rwhva)\n return;\n if (result->IsEmpty())\n return;\n if (result->size().IsEmpty())\n return;\n\n gfx::Rect region_in_frame =\n media::ComputeLetterboxRegion(gfx::Rect(video_frame->coded_size()),\n result->size());\n region_in_frame = gfx::Rect(region_in_frame.x() & ~1,\n region_in_frame.y() & ~1,\n region_in_frame.width() & ~1,\n region_in_frame.height() & ~1);\n if (region_in_frame.IsEmpty())\n return;\n\n if (!result->HasTexture()) {\n DCHECK(result->HasBitmap());\n scoped_ptr bitmap = result->TakeBitmap();\n SkBitmap scaled_bitmap;\n if (result->size().width() != region_in_frame.width() ||\n result->size().height() != region_in_frame.height()) {\n skia::ImageOperations::ResizeMethod method =\n skia::ImageOperations::RESIZE_GOOD;\n scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), method,\n region_in_frame.width(),\n region_in_frame.height());\n } else {\n scaled_bitmap = *bitmap.get();\n }\n\n {\n SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap);\n\n media::CopyRGBToVideoFrame(\n reinterpret_cast(scaled_bitmap.getPixels()),\n scaled_bitmap.rowBytes(),\n region_in_frame,\n video_frame.get());\n }\n ignore_result(scoped_callback_runner.Release());\n callback.Run(true);\n return;\n }\n\n ImageTransportFactory* factory = ImageTransportFactory::GetInstance();\n GLHelper* gl_helper = factory->GetGLHelper();\n if (!gl_helper)\n return;\n if (subscriber_texture.get() && !subscriber_texture->texture_id())\n return;\n\n cc::TextureMailbox texture_mailbox;\n scoped_ptr release_callback;\n result->TakeTexture(&texture_mailbox, &release_callback);\n DCHECK(texture_mailbox.IsTexture());\n if (!texture_mailbox.IsTexture())\n return;\n\n gfx::Rect result_rect(result->size());\n\n content::ReadbackYUVInterface* yuv_readback_pipeline =\n rwhva->yuv_readback_pipeline_.get();\n if (yuv_readback_pipeline == NULL ||\n yuv_readback_pipeline->scaler()->SrcSize() != result_rect.size() ||\n yuv_readback_pipeline->scaler()->SrcSubrect() != result_rect ||\n yuv_readback_pipeline->scaler()->DstSize() != region_in_frame.size()) {\n GLHelper::ScalerQuality quality = GLHelper::SCALER_QUALITY_FAST;\n std::string quality_switch = switches::kTabCaptureDownscaleQuality;\n if (result_rect.size().width() < region_in_frame.size().width() &&\n result_rect.size().height() < region_in_frame.size().height())\n quality_switch = switches::kTabCaptureUpscaleQuality;\n\n std::string switch_value =\n CommandLine::ForCurrentProcess()->GetSwitchValueASCII(quality_switch);\n if (switch_value == \"fast\")\n quality = GLHelper::SCALER_QUALITY_FAST;\n else if (switch_value == \"good\")\n quality = GLHelper::SCALER_QUALITY_GOOD;\n else if (switch_value == \"best\")\n quality = GLHelper::SCALER_QUALITY_BEST;\n\n rwhva->yuv_readback_pipeline_.reset(\n gl_helper->CreateReadbackPipelineYUV(quality,\n result_rect.size(),\n result_rect,\n video_frame->coded_size(),\n region_in_frame,\n true,\n true));\n yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get();\n }\n\n ignore_result(scoped_callback_runner.Release());\n ignore_result(scoped_return_subscriber_texture.Release());\n base::Callback finished_callback = base::Bind(\n &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo,\n rwhva->AsWeakPtr(),\n callback,\n subscriber_texture,\n base::Passed(&release_callback));\n yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),\n texture_mailbox.sync_point(),\n video_frame.get(),\n finished_callback);\n}\n","target":0,"code_token_length":1019,"total_token_length":1255,"max_tokens_setting":2048} +{"idx":499177,"func":"static void gf_isom_write_tx3g(GF_Tx3gSampleEntryBox *_a, GF_BitStream *bs, u32 sidx, u32 sidx_offset)\n{\n\tu32 size, j, fount_count;\n\tconst char *qt_fontname = NULL;\n\tvoid gpp_write_rgba(GF_BitStream *bs, u32 col);\n\tvoid gpp_write_box(GF_BitStream *bs, GF_BoxRecord *rec);\n\tvoid gpp_write_style(GF_BitStream *bs, GF_StyleRecord *rec);\n\n\tGF_TextSampleEntryBox *qt = (_a->type==GF_ISOM_BOX_TYPE_TEXT) ? (GF_TextSampleEntryBox *)_a : NULL;\n\tGF_Tx3gSampleEntryBox *ttxt = (_a->type!=GF_ISOM_BOX_TYPE_TEXT) ? (GF_Tx3gSampleEntryBox *)_a : NULL;\n\n\tif (sidx_offset) gf_bs_write_u8(bs, sidx + sidx_offset);\n\n\t\/*SINCE WINCE HAS A READONLY VERSION OF MP4 WE MUST DO IT BY HAND*\/\n\tsize = 8 + 18 + 8 + 12;\n\tsize += 8 + 2;\n\tfount_count = 0;\n\tif (qt && qt->textName) {\n\t\tqt_fontname = qt->textName;\n\t\tfount_count = 1;\n\t} else if (ttxt && ttxt->font_table) {\n\t\tfount_count = ttxt->font_table->entry_count;\n\t\tfor (j=0; jfont_table->fonts[j].fontName)\n\t\t\t\tsize += (u32) strlen(ttxt->font_table->fonts[j].fontName);\n\t\t}\n\t}\n\t\/*write TextSampleEntry box*\/\n\tgf_bs_write_u32(bs, size);\n\tgf_bs_write_u32(bs, GF_ISOM_BOX_TYPE_TX3G);\n\tgf_bs_write_data(bs, _a->reserved, 6);\n\tgf_bs_write_u16(bs, _a->dataReferenceIndex);\n\tgf_bs_write_u32(bs, _a->displayFlags);\n\tif (qt) {\n\t\tGF_StyleRecord sr;\n\t\tmemset(&sr, 0, sizeof(GF_StyleRecord));\n\t\tgf_bs_write_u8(bs, qt->textJustification);\n\t\tgf_bs_write_u8(bs, (u8) -1);\n\t\tgpp_write_rgba(bs, rgb_48_to_32(qt->background_color) );\n\t\tgpp_write_box(bs, &qt->default_box);\n\t\tsr.text_color = rgb_48_to_32(qt->foreground_color);\n\t\tsr.style_flags = 0; \/\/todo expose qt->fontFace;\n\t\tgpp_write_style(bs, &sr);\n\t} else {\n\t\tgf_bs_write_u8(bs, ttxt->horizontal_justification);\n\t\tgf_bs_write_u8(bs, ttxt->vertical_justification);\n\t\tgpp_write_rgba(bs, ttxt->back_color);\n\t\tgpp_write_box(bs, &ttxt->default_box);\n\t\tgpp_write_style(bs, &ttxt->default_style);\n\t}\n\t\/*write font table box*\/\n\tsize -= (8 + 18 + 8 + 12);\n\tgf_bs_write_u32(bs, size);\n\tgf_bs_write_u32(bs, GF_ISOM_BOX_TYPE_FTAB);\n\n\tgf_bs_write_u16(bs, fount_count);\n\tfor (j=0; jfont_table->fonts[j].fontID);\n\t\t\tif (ttxt->font_table->fonts[j].fontName) {\n\t\t\t\tu32 len = (u32) strlen(ttxt->font_table->fonts[j].fontName);\n\t\t\t\tgf_bs_write_u8(bs, len);\n\t\t\t\tgf_bs_write_data(bs, ttxt->font_table->fonts[j].fontName, len);\n\t\t\t} else {\n\t\t\t\tgf_bs_write_u8(bs, 0);\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":977,"total_token_length":1213,"max_tokens_setting":2048} +{"idx":243130,"func":"static int __mkroute_input(struct sk_buff *skb,\n\t\t\t const struct fib_result *res,\n\t\t\t struct in_device *in_dev,\n\t\t\t __be32 daddr, __be32 saddr, u32 tos)\n{\n\tstruct fib_nh_exception *fnhe;\n\tstruct rtable *rth;\n\tint err;\n\tstruct in_device *out_dev;\n\tunsigned int flags = 0;\n\tbool do_cache;\n\tu32 itag = 0;\n\n\t\/* get a working reference to the output device *\/\n\tout_dev = __in_dev_get_rcu(FIB_RES_DEV(*res));\n\tif (out_dev == NULL) {\n\t\tnet_crit_ratelimited(\"Bug in ip_route_input_slow(). Please report.\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\terr = fib_validate_source(skb, saddr, daddr, tos, FIB_RES_OIF(*res),\n\t\t\t\t in_dev->dev, in_dev, &itag);\n\tif (err < 0) {\n\t\tip_handle_martian_source(in_dev->dev, in_dev, skb, daddr,\n\t\t\t\t\t saddr);\n\n\t\tgoto cleanup;\n\t}\n\n\tdo_cache = res->fi && !itag;\n\tif (out_dev == in_dev && err && IN_DEV_TX_REDIRECTS(out_dev) &&\n\t skb->protocol == htons(ETH_P_IP) &&\n\t (IN_DEV_SHARED_MEDIA(out_dev) ||\n\t inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res))))\n\t\tIPCB(skb)->flags |= IPSKB_DOREDIRECT;\n\n\tif (skb->protocol != htons(ETH_P_IP)) {\n\t\t\/* Not IP (i.e. ARP). Do not create route, if it is\n\t\t * invalid for proxy arp. DNAT routes are always valid.\n\t\t *\n\t\t * Proxy arp feature have been extended to allow, ARP\n\t\t * replies back to the same interface, to support\n\t\t * Private VLAN switch technologies. See arp.c.\n\t\t *\/\n\t\tif (out_dev == in_dev &&\n\t\t IN_DEV_PROXY_ARP_PVLAN(in_dev) == 0) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto cleanup;\n\t\t}\n\t}\n\n\tfnhe = find_exception(&FIB_RES_NH(*res), daddr);\n\tif (do_cache) {\n\t\tif (fnhe != NULL)\n\t\t\trth = rcu_dereference(fnhe->fnhe_rth_input);\n\t\telse\n\t\t\trth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);\n\n\t\tif (rt_cache_valid(rth)) {\n\t\t\tskb_dst_set_noref(skb, &rth->dst);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\trth = rt_dst_alloc(out_dev->dev,\n\t\t\t IN_DEV_CONF_GET(in_dev, NOPOLICY),\n\t\t\t IN_DEV_CONF_GET(out_dev, NOXFRM), do_cache);\n\tif (!rth) {\n\t\terr = -ENOBUFS;\n\t\tgoto cleanup;\n\t}\n\n\trth->rt_genid = rt_genid_ipv4(dev_net(rth->dst.dev));\n\trth->rt_flags = flags;\n\trth->rt_type = res->type;\n\trth->rt_is_input = 1;\n\trth->rt_iif \t= 0;\n\trth->rt_pmtu\t= 0;\n\trth->rt_gateway\t= 0;\n\trth->rt_uses_gateway = 0;\n\tINIT_LIST_HEAD(&rth->rt_uncached);\n\tRT_CACHE_STAT_INC(in_slow_tot);\n\n\trth->dst.input = ip_forward;\n\trth->dst.output = ip_output;\n\n\trt_set_nexthop(rth, daddr, res, fnhe, res->fi, res->type, itag);\n\tskb_dst_set(skb, &rth->dst);\nout:\n\terr = 0;\n cleanup:\n\treturn err;\n}\n","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048} +{"idx":443808,"func":"static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,\n\t\tunsigned long old_addr, unsigned long old_end,\n\t\tstruct vm_area_struct *new_vma, pmd_t *new_pmd,\n\t\tunsigned long new_addr, bool need_rmap_locks)\n{\n\tstruct mm_struct *mm = vma->vm_mm;\n\tpte_t *old_pte, *new_pte, pte;\n\tspinlock_t *old_ptl, *new_ptl;\n\tbool force_flush = false;\n\tunsigned long len = old_end - old_addr;\n\n\t\/*\n\t * When need_rmap_locks is true, we take the i_mmap_rwsem and anon_vma\n\t * locks to ensure that rmap will always observe either the old or the\n\t * new ptes. This is the easiest way to avoid races with\n\t * truncate_pagecache(), page migration, etc...\n\t *\n\t * When need_rmap_locks is false, we use other ways to avoid\n\t * such races:\n\t *\n\t * - During exec() shift_arg_pages(), we use a specially tagged vma\n\t * which rmap call sites look for using vma_is_temporary_stack().\n\t *\n\t * - During mremap(), new_vma is often known to be placed after vma\n\t * in rmap traversal order. This ensures rmap will always observe\n\t * either the old pte, or the new pte, or both (the page table locks\n\t * serialize access to individual ptes, but only rmap traversal\n\t * order guarantees that we won't miss both the old and new ptes).\n\t *\/\n\tif (need_rmap_locks)\n\t\ttake_rmap_locks(vma);\n\n\t\/*\n\t * We don't have to worry about the ordering of src and dst\n\t * pte locks because exclusive mmap_sem prevents deadlock.\n\t *\/\n\told_pte = pte_offset_map_lock(mm, old_pmd, old_addr, &old_ptl);\n\tnew_pte = pte_offset_map(new_pmd, new_addr);\n\tnew_ptl = pte_lockptr(mm, new_pmd);\n\tif (new_ptl != old_ptl)\n\t\tspin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);\n\tflush_tlb_batched_pending(vma->vm_mm);\n\tarch_enter_lazy_mmu_mode();\n\n\tfor (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,\n\t\t\t\t new_pte++, new_addr += PAGE_SIZE) {\n\t\tif (pte_none(*old_pte))\n\t\t\tcontinue;\n\n\t\tpte = ptep_get_and_clear(mm, old_addr, old_pte);\n\t\t\/*\n\t\t * If we are remapping a valid PTE, make sure\n\t\t * to flush TLB before we drop the PTL for the\n\t\t * PTE.\n\t\t *\n\t\t * NOTE! Both old and new PTL matter: the old one\n\t\t * for racing with page_mkclean(), the new one to\n\t\t * make sure the physical page stays valid until\n\t\t * the TLB entry for the old mapping has been\n\t\t * flushed.\n\t\t *\/\n\t\tif (pte_present(pte))\n\t\t\tforce_flush = true;\n\t\tpte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);\n\t\tpte = move_soft_dirty_pte(pte);\n\t\tset_pte_at(mm, new_addr, new_pte, pte);\n\t}\n\n\tarch_leave_lazy_mmu_mode();\n\tif (force_flush)\n\t\tflush_tlb_range(vma, old_end - len, old_end);\n\tif (new_ptl != old_ptl)\n\t\tspin_unlock(new_ptl);\n\tpte_unmap(new_pte - 1);\n\tpte_unmap_unlock(old_pte - 1, old_ptl);\n\tif (need_rmap_locks)\n\t\tdrop_rmap_locks(vma);\n}","target":0,"code_token_length":824,"total_token_length":1060,"max_tokens_setting":2048} +{"idx":151456,"func":"static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)\n{\n struct sgpd_entry {\n int count;\n int16_t roll_distance;\n int group_description_index;\n };\n\n struct sgpd_entry *sgpd_entries = NULL;\n int entries = -1;\n int group = 0;\n int i, j;\n\n const int OPUS_SEEK_PREROLL_MS = 80;\n int roll_samples = av_rescale_q(OPUS_SEEK_PREROLL_MS,\n (AVRational){1, 1000},\n (AVRational){1, 48000});\n\n if (!track->entry)\n return 0;\n\n sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));\n if (!sgpd_entries)\n return AVERROR(ENOMEM);\n\n av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC);\n\n if (track->par->codec_id == AV_CODEC_ID_OPUS) {\n for (i = 0; i < track->entry; i++) {\n int roll_samples_remaining = roll_samples;\n int distance = 0;\n for (j = i - 1; j >= 0; j--) {\n roll_samples_remaining -= get_cluster_duration(track, j);\n distance++;\n if (roll_samples_remaining <= 0)\n break;\n }\n \/* We don't have enough preceeding samples to compute a valid\n roll_distance here, so this sample can't be independently\n decoded. *\/\n if (roll_samples_remaining > 0)\n distance = 0;\n \/* Verify distance is a minimum of 2 (60ms) packets and a maximum of\n 32 (2.5ms) packets. *\/\n av_assert0(distance == 0 || (distance >= 2 && distance <= 32));\n if (i && distance == sgpd_entries[entries].roll_distance) {\n sgpd_entries[entries].count++;\n } else {\n entries++;\n sgpd_entries[entries].count = 1;\n sgpd_entries[entries].roll_distance = distance;\n sgpd_entries[entries].group_description_index = distance ? ++group : 0;\n }\n }\n } else {\n entries++;\n sgpd_entries[entries].count = track->sample_count;\n sgpd_entries[entries].roll_distance = 1;\n sgpd_entries[entries].group_description_index = ++group;\n }\n entries++;\n\n if (!group) {\n av_free(sgpd_entries);\n return 0;\n }\n\n \/* Write sgpd tag *\/\n avio_wb32(pb, 24 + (group * 2)); \/* size *\/\n ffio_wfourcc(pb, \"sgpd\");\n avio_wb32(pb, 1 << 24); \/* fullbox *\/\n ffio_wfourcc(pb, \"roll\");\n avio_wb32(pb, 2); \/* default_length *\/\n avio_wb32(pb, group); \/* entry_count *\/\n for (i = 0; i < entries; i++) {\n if (sgpd_entries[i].group_description_index) {\n avio_wb16(pb, -sgpd_entries[i].roll_distance); \/* roll_distance *\/\n }\n }\n\n \/* Write sbgp tag *\/\n avio_wb32(pb, 20 + (entries * 8)); \/* size *\/\n ffio_wfourcc(pb, \"sbgp\");\n avio_wb32(pb, 0); \/* fullbox *\/\n ffio_wfourcc(pb, \"roll\");\n avio_wb32(pb, entries); \/* entry_count *\/\n for (i = 0; i < entries; i++) {\n avio_wb32(pb, sgpd_entries[i].count); \/* sample_count *\/\n avio_wb32(pb, sgpd_entries[i].group_description_index); \/* group_description_index *\/\n }\n\n av_free(sgpd_entries);\n return 0;\n}","target":0,"code_token_length":889,"total_token_length":1125,"max_tokens_setting":2048} +{"idx":424991,"func":"static int channel_setenv(LIBSSH2_CHANNEL *channel,\n const char *varname, unsigned int varname_len,\n const char *value, unsigned int value_len)\n{\n LIBSSH2_SESSION *session = channel->session;\n unsigned char *s, *data;\n static const unsigned char reply_codes[3] =\n { SSH_MSG_CHANNEL_SUCCESS, SSH_MSG_CHANNEL_FAILURE, 0 };\n size_t data_len;\n int rc;\n\n if(channel->setenv_state == libssh2_NB_state_idle) {\n \/* 21 = packet_type(1) + channel_id(4) + request_len(4) +\n * request(3)\"env\" + want_reply(1) + varname_len(4) + value_len(4) *\/\n channel->setenv_packet_len = varname_len + value_len + 21;\n\n \/* Zero the whole thing out *\/\n memset(&channel->setenv_packet_requirev_state, 0,\n sizeof(channel->setenv_packet_requirev_state));\n\n _libssh2_debug(session, LIBSSH2_TRACE_CONN,\n \"Setting remote environment variable: %s=%s on \"\n \"channel %lu\/%lu\",\n varname, value, channel->local.id, channel->remote.id);\n\n s = channel->setenv_packet =\n LIBSSH2_ALLOC(session, channel->setenv_packet_len);\n if(!channel->setenv_packet) {\n return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,\n \"Unable to allocate memory \"\n \"for setenv packet\");\n }\n\n *(s++) = SSH_MSG_CHANNEL_REQUEST;\n _libssh2_store_u32(&s, channel->remote.id);\n _libssh2_store_str(&s, \"env\", sizeof(\"env\") - 1);\n *(s++) = 0x01;\n _libssh2_store_str(&s, varname, varname_len);\n _libssh2_store_str(&s, value, value_len);\n\n channel->setenv_state = libssh2_NB_state_created;\n }\n\n if(channel->setenv_state == libssh2_NB_state_created) {\n rc = _libssh2_transport_send(session,\n channel->setenv_packet,\n channel->setenv_packet_len,\n NULL, 0);\n if(rc == LIBSSH2_ERROR_EAGAIN) {\n _libssh2_error(session, rc,\n \"Would block sending setenv request\");\n return rc;\n }\n else if(rc) {\n LIBSSH2_FREE(session, channel->setenv_packet);\n channel->setenv_packet = NULL;\n channel->setenv_state = libssh2_NB_state_idle;\n return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,\n \"Unable to send channel-request packet for \"\n \"setenv request\");\n }\n LIBSSH2_FREE(session, channel->setenv_packet);\n channel->setenv_packet = NULL;\n\n _libssh2_htonu32(channel->setenv_local_channel, channel->local.id);\n\n channel->setenv_state = libssh2_NB_state_sent;\n }\n\n if(channel->setenv_state == libssh2_NB_state_sent) {\n rc = _libssh2_packet_requirev(session, reply_codes, &data, &data_len,\n 1, channel->setenv_local_channel, 4,\n &channel->\n setenv_packet_requirev_state);\n if(rc == LIBSSH2_ERROR_EAGAIN) {\n return rc;\n }\n if(rc) {\n channel->setenv_state = libssh2_NB_state_idle;\n return rc;\n } \n else if(data_len < 1) {\n channel->setenv_state = libssh2_NB_state_idle;\n return _libssh2_error(session, LIBSSH2_ERROR_PROTO,\n \"Unexpected packet size\");\n }\n\n if(data[0] == SSH_MSG_CHANNEL_SUCCESS) {\n LIBSSH2_FREE(session, data);\n channel->setenv_state = libssh2_NB_state_idle;\n return 0;\n }\n\n LIBSSH2_FREE(session, data);\n }\n\n channel->setenv_state = libssh2_NB_state_idle;\n return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,\n \"Unable to complete request for channel-setenv\");\n}","target":0,"code_token_length":911,"total_token_length":1147,"max_tokens_setting":2048} +{"idx":344538,"func":"xmlParseElement(xmlParserCtxtPtr ctxt) {\n const xmlChar *name;\n const xmlChar *prefix = NULL;\n const xmlChar *URI = NULL;\n xmlParserNodeInfo node_info;\n int line, tlen = 0;\n xmlNodePtr ret;\n int nsNr = ctxt->nsNr;\n\n if (((unsigned int) ctxt->nameNr > xmlParserMaxDepth) &&\n ((ctxt->options & XML_PARSE_HUGE) == 0)) {\n\txmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,\n\t\t \"Excessive depth in document: %d use XML_PARSE_HUGE option\\n\",\n\t\t\t xmlParserMaxDepth);\n\tctxt->instate = XML_PARSER_EOF;\n\treturn;\n }\n\n \/* Capture start position *\/\n if (ctxt->record_info) {\n node_info.begin_pos = ctxt->input->consumed +\n (CUR_PTR - ctxt->input->base);\n\tnode_info.begin_line = ctxt->input->line;\n }\n\n if (ctxt->spaceNr == 0)\n\tspacePush(ctxt, -1);\n else if (*ctxt->space == -2)\n\tspacePush(ctxt, -1);\n else\n\tspacePush(ctxt, *ctxt->space);\n\n line = ctxt->input->line;\n#ifdef LIBXML_SAX1_ENABLED\n if (ctxt->sax2)\n#endif \/* LIBXML_SAX1_ENABLED *\/\n name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen);\n#ifdef LIBXML_SAX1_ENABLED\n else\n\tname = xmlParseStartTag(ctxt);\n#endif \/* LIBXML_SAX1_ENABLED *\/\n if (ctxt->instate == XML_PARSER_EOF)\n\treturn;\n if (name == NULL) {\n\tspacePop(ctxt);\n return;\n }\n namePush(ctxt, name);\n ret = ctxt->node;\n\n#ifdef LIBXML_VALID_ENABLED\n \/*\n * [ VC: Root Element Type ]\n * The Name in the document type declaration must match the element\n * type of the root element.\n *\/\n if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc &&\n ctxt->node && (ctxt->node == ctxt->myDoc->children))\n ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);\n#endif \/* LIBXML_VALID_ENABLED *\/\n\n \/*\n * Check for an Empty Element.\n *\/\n if ((RAW == '\/') && (NXT(1) == '>')) {\n SKIP(2);\n\tif (ctxt->sax2) {\n\t if ((ctxt->sax != NULL) && (ctxt->sax->endElementNs != NULL) &&\n\t\t(!ctxt->disableSAX))\n\t\tctxt->sax->endElementNs(ctxt->userData, name, prefix, URI);\n#ifdef LIBXML_SAX1_ENABLED\n\t} else {\n\t if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL) &&\n\t\t(!ctxt->disableSAX))\n\t\tctxt->sax->endElement(ctxt->userData, name);\n#endif \/* LIBXML_SAX1_ENABLED *\/\n\t}\n\tnamePop(ctxt);\n\tspacePop(ctxt);\n\tif (nsNr != ctxt->nsNr)\n\t nsPop(ctxt, ctxt->nsNr - nsNr);\n\tif ( ret != NULL && ctxt->record_info ) {\n\t node_info.end_pos = ctxt->input->consumed +\n\t\t\t (CUR_PTR - ctxt->input->base);\n\t node_info.end_line = ctxt->input->line;\n\t node_info.node = ret;\n\t xmlParserAddNodeInfo(ctxt, &node_info);\n\t}\n\treturn;\n }\n if (RAW == '>') {\n NEXT1;\n } else {\n xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_GT_REQUIRED,\n\t\t \"Couldn't find end of Start Tag %s line %d\\n\",\n\t\t name, line, NULL);\n\n\t\/*\n\t * end of parsing of this node.\n\t *\/\n\tnodePop(ctxt);\n\tnamePop(ctxt);\n\tspacePop(ctxt);\n\tif (nsNr != ctxt->nsNr)\n\t nsPop(ctxt, ctxt->nsNr - nsNr);\n\n\t\/*\n\t * Capture end position and add node\n\t *\/\n\tif ( ret != NULL && ctxt->record_info ) {\n\t node_info.end_pos = ctxt->input->consumed +\n\t\t\t (CUR_PTR - ctxt->input->base);\n\t node_info.end_line = ctxt->input->line;\n\t node_info.node = ret;\n\t xmlParserAddNodeInfo(ctxt, &node_info);\n\t}\n\treturn;\n }\n\n \/*\n * Parse the content of the element:\n *\/\n xmlParseContent(ctxt);\n if (!IS_BYTE_CHAR(RAW)) {\n xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,\n\t \"Premature end of data in tag %s line %d\\n\",\n\t\t name, line, NULL);\n\n\t\/*\n\t * end of parsing of this node.\n\t *\/\n\tnodePop(ctxt);\n\tnamePop(ctxt);\n\tspacePop(ctxt);\n\tif (nsNr != ctxt->nsNr)\n\t nsPop(ctxt, ctxt->nsNr - nsNr);\n\treturn;\n }\n\n \/*\n * parse the end of tag: '<\/' should be here.\n *\/\n if (ctxt->sax2) {\n\txmlParseEndTag2(ctxt, prefix, URI, line, ctxt->nsNr - nsNr, tlen);\n\tnamePop(ctxt);\n }\n#ifdef LIBXML_SAX1_ENABLED\n else\n\txmlParseEndTag1(ctxt, line);\n#endif \/* LIBXML_SAX1_ENABLED *\/\n\n \/*\n * Capture end position and add node\n *\/\n if ( ret != NULL && ctxt->record_info ) {\n node_info.end_pos = ctxt->input->consumed +\n (CUR_PTR - ctxt->input->base);\n node_info.end_line = ctxt->input->line;\n node_info.node = ret;\n xmlParserAddNodeInfo(ctxt, &node_info);\n }\n}","target":1,"code_token_length":1267,"total_token_length":1503,"max_tokens_setting":2048} +{"idx":125526,"func":"nv_replace(cmdarg_T *cap)\n{\n char_u\t*ptr;\n int\t\thad_ctrl_v;\n long\tn;\n\n if (checkclearop(cap->oap))\n\treturn;\n#ifdef FEAT_JOB_CHANNEL\n if (bt_prompt(curbuf) && !prompt_curpos_editable())\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n#endif\n\n \/\/ get another character\n if (cap->nchar == Ctrl_V)\n {\n\thad_ctrl_v = Ctrl_V;\n\tcap->nchar = get_literal(FALSE);\n\t\/\/ Don't redo a multibyte character with CTRL-V.\n\tif (cap->nchar > DEL)\n\t had_ctrl_v = NUL;\n }\n else\n\thad_ctrl_v = NUL;\n\n \/\/ Abort if the character is a special key.\n if (IS_SPECIAL(cap->nchar))\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n\n \/\/ Visual mode \"r\"\n if (VIsual_active)\n {\n\tif (got_int)\n\t reset_VIsual();\n\tif (had_ctrl_v)\n\t{\n\t \/\/ Use a special (negative) number to make a difference between a\n\t \/\/ literal CR or NL and a line break.\n\t if (cap->nchar == CAR)\n\t\tcap->nchar = REPLACE_CR_NCHAR;\n\t else if (cap->nchar == NL)\n\t\tcap->nchar = REPLACE_NL_NCHAR;\n\t}\n\tnv_operator(cap);\n\treturn;\n }\n\n \/\/ Break tabs, etc.\n if (virtual_active())\n {\n\tif (u_save_cursor() == FAIL)\n\t return;\n\tif (gchar_cursor() == NUL)\n\t{\n\t \/\/ Add extra space and put the cursor on the first one.\n\t coladvance_force((colnr_T)(getviscol() + cap->count1));\n\t curwin->w_cursor.col -= cap->count1;\n\t}\n\telse if (gchar_cursor() == TAB)\n\t coladvance_force(getviscol());\n }\n\n \/\/ Abort if not enough characters to replace.\n ptr = ml_get_cursor();\n if (STRLEN(ptr) < (unsigned)cap->count1\n\t || (has_mbyte && mb_charlen(ptr) < cap->count1))\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n\n \/\/ Replacing with a TAB is done by edit() when it is complicated because\n \/\/ 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB.\n \/\/ Other characters are done below to avoid problems with things like\n \/\/ CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC).\n if (had_ctrl_v != Ctrl_V && cap->nchar == '\\t' && (curbuf->b_p_et || p_sta))\n {\n\tstuffnumReadbuff(cap->count1);\n\tstuffcharReadbuff('R');\n\tstuffcharReadbuff('\\t');\n\tstuffcharReadbuff(ESC);\n\treturn;\n }\n\n \/\/ save line for undo\n if (u_save_cursor() == FAIL)\n\treturn;\n\n if (had_ctrl_v != Ctrl_V && (cap->nchar == '\\r' || cap->nchar == '\\n'))\n {\n\t\/\/ Replace character(s) by a single newline.\n\t\/\/ Strange vi behaviour: Only one newline is inserted.\n\t\/\/ Delete the characters here.\n\t\/\/ Insert the newline with an insert command, takes care of\n\t\/\/ autoindent.\tThe insert command depends on being on the last\n\t\/\/ character of a line or not.\n\t(void)del_chars(cap->count1, FALSE);\t\/\/ delete the characters\n\tstuffcharReadbuff('\\r');\n\tstuffcharReadbuff(ESC);\n\n\t\/\/ Give 'r' to edit(), to get the redo command right.\n\tinvoke_edit(cap, TRUE, 'r', FALSE);\n }\n else\n {\n\tprep_redo(cap->oap->regname, cap->count1,\n\t\t\t\t NUL, 'r', NUL, had_ctrl_v, cap->nchar);\n\n\tcurbuf->b_op_start = curwin->w_cursor;\n\tif (has_mbyte)\n\t{\n\t int\t\told_State = State;\n\n\t if (cap->ncharC1 != 0)\n\t\tAppendCharToRedobuff(cap->ncharC1);\n\t if (cap->ncharC2 != 0)\n\t\tAppendCharToRedobuff(cap->ncharC2);\n\n\t \/\/ This is slow, but it handles replacing a single-byte with a\n\t \/\/ multi-byte and the other way around. Also handles adding\n\t \/\/ composing characters for utf-8.\n\t for (n = cap->count1; n > 0; --n)\n\t {\n\t\tState = MODE_REPLACE;\n\t\tif (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)\n\t\t{\n\t\t int c = ins_copychar(curwin->w_cursor.lnum\n\t\t\t\t\t + (cap->nchar == Ctrl_Y ? -1 : 1));\n\t\t if (c != NUL)\n\t\t\tins_char(c);\n\t\t else\n\t\t\t\/\/ will be decremented further down\n\t\t\t++curwin->w_cursor.col;\n\t\t}\n\t\telse\n\t\t ins_char(cap->nchar);\n\t\tState = old_State;\n\t\tif (cap->ncharC1 != 0)\n\t\t ins_char(cap->ncharC1);\n\t\tif (cap->ncharC2 != 0)\n\t\t ins_char(cap->ncharC2);\n\t }\n\t}\n\telse\n\t{\n\t \/\/ Replace the characters within one line.\n\t for (n = cap->count1; n > 0; --n)\n\t {\n\t\t\/\/ Get ptr again, because u_save and\/or showmatch() will have\n\t\t\/\/ released the line. This may also happen in ins_copychar().\n\t\t\/\/ At the same time we let know that the line will be changed.\n\t\tif (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)\n\t\t{\n\t\t int c = ins_copychar(curwin->w_cursor.lnum\n\t\t\t\t\t + (cap->nchar == Ctrl_Y ? -1 : 1));\n\n\t\t ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);\n\t\t if (c != NUL)\n\t\t ptr[curwin->w_cursor.col] = c;\n\t\t}\n\t\telse\n\t\t{\n\t\t ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);\n\t\t ptr[curwin->w_cursor.col] = cap->nchar;\n\t\t}\n\t\tif (p_sm && msg_silent == 0)\n\t\t showmatch(cap->nchar);\n\t\t++curwin->w_cursor.col;\n\t }\n#ifdef FEAT_NETBEANS_INTG\n\t if (netbeans_active())\n\t {\n\t\tcolnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);\n\n\t\tnetbeans_removed(curbuf, curwin->w_cursor.lnum, start,\n\t\t\t\t\t\t\t cap->count1);\n\t\tnetbeans_inserted(curbuf, curwin->w_cursor.lnum, start,\n\t\t\t\t\t &ptr[start], (int)cap->count1);\n\t }\n#endif\n\n\t \/\/ mark the buffer as changed and prepare for displaying\n\t changed_bytes(curwin->w_cursor.lnum,\n\t\t\t (colnr_T)(curwin->w_cursor.col - cap->count1));\n\t}\n\t--curwin->w_cursor.col;\t \/\/ cursor on the last replaced char\n\t\/\/ if the character on the left of the current cursor is a multi-byte\n\t\/\/ character, move two characters left\n\tif (has_mbyte)\n\t mb_adjust_cursor();\n\tcurbuf->b_op_end = curwin->w_cursor;\n\tcurwin->w_set_curswant = TRUE;\n\tset_last_insert(cap->nchar);\n }\n}","target":0,"code_token_length":1661,"total_token_length":1897,"max_tokens_setting":2048} +{"idx":195591,"func":"void OMXCodec::on_message(const omx_message &msg) {\n if (mState == ERROR) {\n \/*\n * only drop EVENT messages, EBD and FBD are still\n * processed for bookkeeping purposes\n *\/\n if (msg.type == omx_message::EVENT) {\n ALOGW(\"Dropping OMX EVENT message - we're in ERROR state.\");\n return;\n }\n }\n\n switch (msg.type) {\n case omx_message::EVENT:\n {\n onEvent(\n msg.u.event_data.event, msg.u.event_data.data1,\n msg.u.event_data.data2);\n\n break;\n }\n\n case omx_message::EMPTY_BUFFER_DONE:\n {\n IOMX::buffer_id buffer = msg.u.extended_buffer_data.buffer;\n\n CODEC_LOGV(\"EMPTY_BUFFER_DONE(buffer: %u)\", buffer);\n\n Vector *buffers = &mPortBuffers[kPortIndexInput];\n size_t i = 0;\n while (i < buffers->size() && (*buffers)[i].mBuffer != buffer) {\n ++i;\n }\n\n CHECK(i < buffers->size());\n if ((*buffers)[i].mStatus != OWNED_BY_COMPONENT) {\n ALOGW(\"We already own input buffer %u, yet received \"\n \"an EMPTY_BUFFER_DONE.\", buffer);\n }\n\n BufferInfo* info = &buffers->editItemAt(i);\n info->mStatus = OWNED_BY_US;\n\n if (info->mMediaBuffer != NULL) {\n info->mMediaBuffer->release();\n info->mMediaBuffer = NULL;\n }\n\n if (mPortStatus[kPortIndexInput] == DISABLING) {\n CODEC_LOGV(\"Port is disabled, freeing buffer %u\", buffer);\n\n status_t err = freeBuffer(kPortIndexInput, i);\n CHECK_EQ(err, (status_t)OK);\n } else if (mState != ERROR\n && mPortStatus[kPortIndexInput] != SHUTTING_DOWN) {\n CHECK_EQ((int)mPortStatus[kPortIndexInput], (int)ENABLED);\n\n if (mFlags & kUseSecureInputBuffers) {\n drainAnyInputBuffer();\n } else {\n drainInputBuffer(&buffers->editItemAt(i));\n }\n }\n break;\n }\n\n case omx_message::FILL_BUFFER_DONE:\n {\n IOMX::buffer_id buffer = msg.u.extended_buffer_data.buffer;\n OMX_U32 flags = msg.u.extended_buffer_data.flags;\n\n CODEC_LOGV(\"FILL_BUFFER_DONE(buffer: %u, size: %u, flags: 0x%08x, timestamp: %lld us (%.2f secs))\",\n buffer,\n msg.u.extended_buffer_data.range_length,\n flags,\n msg.u.extended_buffer_data.timestamp,\n msg.u.extended_buffer_data.timestamp \/ 1E6);\n\n Vector *buffers = &mPortBuffers[kPortIndexOutput];\n size_t i = 0;\n while (i < buffers->size() && (*buffers)[i].mBuffer != buffer) {\n ++i;\n }\n\n CHECK(i < buffers->size());\n BufferInfo *info = &buffers->editItemAt(i);\n\n if (info->mStatus != OWNED_BY_COMPONENT) {\n ALOGW(\"We already own output buffer %u, yet received \"\n \"a FILL_BUFFER_DONE.\", buffer);\n }\n\n info->mStatus = OWNED_BY_US;\n\n if (mPortStatus[kPortIndexOutput] == DISABLING) {\n CODEC_LOGV(\"Port is disabled, freeing buffer %u\", buffer);\n\n status_t err = freeBuffer(kPortIndexOutput, i);\n CHECK_EQ(err, (status_t)OK);\n\n#if 0\n } else if (mPortStatus[kPortIndexOutput] == ENABLED\n && (flags & OMX_BUFFERFLAG_EOS)) {\n CODEC_LOGV(\"No more output data.\");\n mNoMoreOutputData = true;\n mBufferFilled.signal();\n#endif\n } else if (mPortStatus[kPortIndexOutput] != SHUTTING_DOWN) {\n CHECK_EQ((int)mPortStatus[kPortIndexOutput], (int)ENABLED);\n\n MediaBuffer *buffer = info->mMediaBuffer;\n bool isGraphicBuffer = buffer->graphicBuffer() != NULL;\n\n if (!isGraphicBuffer\n && msg.u.extended_buffer_data.range_offset\n + msg.u.extended_buffer_data.range_length\n > buffer->size()) {\n CODEC_LOGE(\n \"Codec lied about its buffer size requirements, \"\n \"sending a buffer larger than the originally \"\n \"advertised size in FILL_BUFFER_DONE!\");\n }\n buffer->set_range(\n msg.u.extended_buffer_data.range_offset,\n msg.u.extended_buffer_data.range_length);\n\n buffer->meta_data()->clear();\n\n buffer->meta_data()->setInt64(\n kKeyTime, msg.u.extended_buffer_data.timestamp);\n\n if (msg.u.extended_buffer_data.flags & OMX_BUFFERFLAG_SYNCFRAME) {\n buffer->meta_data()->setInt32(kKeyIsSyncFrame, true);\n }\n bool isCodecSpecific = false;\n if (msg.u.extended_buffer_data.flags & OMX_BUFFERFLAG_CODECCONFIG) {\n buffer->meta_data()->setInt32(kKeyIsCodecConfig, true);\n isCodecSpecific = true;\n }\n\n if (isGraphicBuffer || mQuirks & kOutputBuffersAreUnreadable) {\n buffer->meta_data()->setInt32(kKeyIsUnreadable, true);\n }\n\n buffer->meta_data()->setInt32(\n kKeyBufferID,\n msg.u.extended_buffer_data.buffer);\n\n if (msg.u.extended_buffer_data.flags & OMX_BUFFERFLAG_EOS) {\n CODEC_LOGV(\"No more output data.\");\n mNoMoreOutputData = true;\n }\n\n if (mIsEncoder && mIsVideo) {\n int64_t decodingTimeUs = isCodecSpecific? 0: getDecodingTimeUs();\n buffer->meta_data()->setInt64(kKeyDecodingTime, decodingTimeUs);\n }\n\n if (mTargetTimeUs >= 0) {\n CHECK(msg.u.extended_buffer_data.timestamp <= mTargetTimeUs);\n\n if (msg.u.extended_buffer_data.timestamp < mTargetTimeUs) {\n CODEC_LOGV(\n \"skipping output buffer at timestamp %lld us\",\n msg.u.extended_buffer_data.timestamp);\n\n fillOutputBuffer(info);\n break;\n }\n\n CODEC_LOGV(\n \"returning output buffer at target timestamp \"\n \"%lld us\",\n msg.u.extended_buffer_data.timestamp);\n\n mTargetTimeUs = -1;\n }\n\n mFilledBuffers.push_back(i);\n mBufferFilled.signal();\n if (mIsEncoder) {\n sched_yield();\n }\n }\n\n break;\n }\n\n default:\n {\n CHECK(!\"should not be here.\");\n break;\n }\n }\n}\n","target":0,"code_token_length":1406,"total_token_length":1642,"max_tokens_setting":2048} +{"idx":352639,"func":"Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const\n{\n if (hashtab && dynsym && dynstr) {\n unsigned const nbucket = get_te32(&hashtab[0]);\n unsigned const *const buckets = &hashtab[2];\n unsigned const *const chains = &buckets[nbucket];\n unsigned const m = elf_hash(name) % nbucket;\n if (!nbucket\n || (unsigned)(file_size - ((char const *)buckets - (char const *)(void const *)file_image))\n <= sizeof(unsigned)*nbucket ) {\n char msg[80]; snprintf(msg, sizeof(msg),\n \"bad nbucket %#x\\n\", nbucket);\n throwCantPack(msg);\n }\n unsigned si;\n for (si= get_te32(&buckets[m]); 0!=si; si= get_te32(&chains[si])) {\n char const *const p= get_dynsym_name(si, (unsigned)-1);\n if (0==strcmp(name, p)) {\n return &dynsym[si];\n }\n }\n }\n if (gashtab && dynsym && dynstr) {\n unsigned const n_bucket = get_te32(&gashtab[0]);\n unsigned const symbias = get_te32(&gashtab[1]);\n unsigned const n_bitmask = get_te32(&gashtab[2]);\n unsigned const gnu_shift = get_te32(&gashtab[3]);\n upx_uint64_t const *const bitmask = (upx_uint64_t const *)(void const *)&gashtab[4];\n unsigned const *const buckets = (unsigned const *)&bitmask[n_bitmask];\n unsigned const *const hasharr = &buckets[n_bucket];\n if (!n_bucket\n || (void const *)&file_image[file_size] <= (void const *)hasharr) {\n char msg[80]; snprintf(msg, sizeof(msg),\n \"bad n_bucket %#x\\n\", n_bucket);\n throwCantPack(msg);\n }\n if (!n_bitmask\n || (unsigned)(file_size - ((char const *)bitmask - (char const *)(void const *)file_image))\n <= sizeof(unsigned)*n_bitmask ) {\n char msg[80]; snprintf(msg, sizeof(msg),\n \"bad n_bitmask %#x\\n\", n_bitmask);\n throwCantPack(msg);\n }\n\n unsigned const h = gnu_hash(name);\n unsigned const hbit1 = 077& h;\n unsigned const hbit2 = 077& (h>>gnu_shift);\n upx_uint64_t const w = get_te64(&bitmask[(n_bitmask -1) & (h>>6)]);\n\n if (1& (w>>hbit1) & (w>>hbit2)) {\n unsigned bucket = get_te32(&buckets[h % n_bucket]);\n if (n_bucket <= bucket) {\n char msg[80]; snprintf(msg, sizeof(msg),\n \"bad DT_GNU_HASH n_bucket{%#x} <= buckets[%d]{%#x}\\n\",\n n_bucket, h % n_bucket, bucket);\n throwCantPack(msg);\n }\n if (0!=bucket) {\n Elf64_Sym const *dsp = &dynsym[bucket];\n unsigned const *hp = &hasharr[bucket - symbias];\n\n do if (0==((h ^ get_te32(hp))>>1)) {\n unsigned st_name = get_te32(&dsp->st_name);\n char const *const p = get_str_name(st_name, (unsigned)-1);\n if (0==strcmp(name, p)) {\n return dsp;\n }\n } while (++dsp,\n (char const *)hp < (char const *)&file_image[file_size]\n && 0==(1u& get_te32(hp++)));\n }\n }\n }\n return 0;\n\n}","target":1,"code_token_length":864,"total_token_length":1100,"max_tokens_setting":2048} +{"idx":379395,"func":"static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op_data2, free_op_data1;\n\tzval **var_ptr;\n\tzval *value;\n\n\tswitch (opline->extended_value) {\n\t\tcase ZEND_ASSIGN_OBJ:\n\t\t\treturn zend_binary_assign_op_obj_helper_SPEC_CV_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\t\t\tbreak;\n\t\tcase ZEND_ASSIGN_DIM: {\n\t\t\t\tzval **container = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_RW TSRMLS_CC);\n\n\t\t\t\tif (IS_CV == IS_VAR && !container) {\n\t\t\t\t\tzend_error_noreturn(E_ERROR, \"Cannot use string offset as an array\");\n\t\t\t\t} else if (Z_TYPE_PP(container) == IS_OBJECT) {\n\t\t\t\t\tif (IS_CV == IS_VAR && !0) {\n\t\t\t\t\t\tZ_ADDREF_PP(container); \/* undo the effect of get_obj_zval_ptr_ptr() *\/\n\t\t\t\t\t}\n\t\t\t\t\treturn zend_binary_assign_op_obj_helper_SPEC_CV_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\t\t\t\t} else {\n\t\t\t\t\tzend_op *op_data = opline+1;\n\t\t\t\t\tzval *dim = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);\n\n\t\t\t\t\tzend_fetch_dimension_address(&EX_T(op_data->op2.u.var), container, dim, 0, BP_VAR_RW TSRMLS_CC);\n\t\t\t\t\tvalue = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R);\n\t\t\t\t\tvar_ptr = _get_zval_ptr_ptr_var(&op_data->op2, EX(Ts), &free_op_data2 TSRMLS_CC);\n\t\t\t\t\tZEND_VM_INC_OPCODE();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tvalue = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);\n\t\t\tvar_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_RW TSRMLS_CC);\n\t\t\t\/* do nothing *\/\n\t\t\tbreak;\n\t}\n\n\tif (!var_ptr) {\n\t\tzend_error_noreturn(E_ERROR, \"Cannot use assign-op operators with overloaded objects nor string offsets\");\n\t}\n\n\tif (*var_ptr == EG(error_zval_ptr)) {\n\t\tif (!RETURN_VALUE_UNUSED(&opline->result)) {\n\t\t\tAI_SET_PTR(EX_T(opline->result.u.var).var, EG(uninitialized_zval_ptr));\n\t\t\tPZVAL_LOCK(EG(uninitialized_zval_ptr));\n\t\t}\n\n\n\t\tZEND_VM_NEXT_OPCODE();\n\t}\n\n\tSEPARATE_ZVAL_IF_NOT_REF(var_ptr);\n\n\tif(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get)\n\t && Z_OBJ_HANDLER_PP(var_ptr, set)) {\n\t\t\/* proxy object *\/\n\t\tzval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC);\n\t\tZ_ADDREF_P(objval);\n\t\tbinary_op(objval, objval, value TSRMLS_CC);\n\t\tZ_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);\n\t\tzval_ptr_dtor(&objval);\n\t} else {\n\t\tbinary_op(*var_ptr, *var_ptr, value TSRMLS_CC);\n\t}\n\n\tif (!RETURN_VALUE_UNUSED(&opline->result)) {\n\t\tAI_SET_PTR(EX_T(opline->result.u.var).var, *var_ptr);\n\t\tPZVAL_LOCK(*var_ptr);\n\t}\n\n\tif (opline->extended_value == ZEND_ASSIGN_DIM) {\n\t\tFREE_OP(free_op_data1);\n\t\tFREE_OP_VAR_PTR(free_op_data2);\n\t}\n\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":828,"total_token_length":1064,"max_tokens_setting":2048} +{"idx":129724,"func":"dwg_decode_entity (Bit_Chain *dat, Bit_Chain *hdl_dat, Bit_Chain *str_dat,\n Dwg_Object_Entity *restrict ent)\n{\n unsigned int i;\n int error = 0;\n Dwg_Data *dwg = ent->dwg;\n Dwg_Object *obj = &dwg->object[ent->objid];\n Dwg_Object_Entity *_obj = ent;\n unsigned long objectpos = bit_position (dat);\n\n \/\/ obj->dat_address = dat->byte; \/\/ the data stream offset\n obj->bitsize_pos = objectpos; \/\/ absolute. needed for encode\n PRE (R_13)\n {\n if (FIELD_VALUE (flag_r11) & 4 && FIELD_VALUE (kind_r11) > 2\n && FIELD_VALUE (kind_r11) != 22)\n FIELD_RD (elevation_r11, 30);\n if (FIELD_VALUE (flag_r11) & 8)\n FIELD_RD (thickness_r11, 39);\n if (FIELD_VALUE (flag_r11) & 0x20)\n {\n Dwg_Object_Ref *hdl\n = dwg_decode_handleref_with_code (dat, obj, dwg, 0);\n if (hdl)\n obj->handle = hdl->handleref;\n }\n if (FIELD_VALUE (extra_r11) & 4)\n FIELD_RS (paper_r11, 0);\n }\n\n VERSIONS (R_2000, R_2007)\n {\n obj->bitsize = bit_read_RL (dat); \/\/ until the handles\n LOG_TRACE (\"bitsize: \" FORMAT_RL \" [RL] @%lu.%u\\n\", obj->bitsize,\n dat->byte-2, dat->bit);\n if (obj->bitsize > obj->size * 8)\n {\n LOG_ERROR (\"Invalid bitsize \" FORMAT_RL \" => \" FORMAT_RL, obj->bitsize,\n obj->size * 8);\n obj->bitsize = obj->size * 8;\n error |= DWG_ERR_VALUEOUTOFBOUNDS;\n }\n }\n SINCE (R_2007)\n {\n SINCE (R_2010)\n LOG_HANDLE (\" bitsize: \" FORMAT_RL \",\", obj->bitsize);\n \/\/ restrict the hdl_dat stream\n error |= obj_handle_stream (dat, obj, hdl_dat);\n \/\/ and set the string stream (restricted to size)\n \/\/ skip for all types without strings\n if (obj->type >= 500 || obj_has_strings (obj->type))\n error |= obj_string_stream (dat, obj, str_dat);\n else\n {\n str_dat->chain += str_dat->byte;\n str_dat->byte = 0;\n str_dat->bit = 0;\n str_dat->size = 0;\n bit_advance_position (str_dat, obj->bitsize - 1 - 8);\n }\n }\n\n error |= bit_read_H (dat, &(obj->handle));\n if (error & DWG_ERR_INVALIDHANDLE)\n {\n LOG_WARN (\"dwg_decode_entity handle @%lu.%u\", dat->byte, dat->bit);\n obj->bitsize = 0;\n ent->num_eed = 0;\n ent->preview_exists = 0;\n return error;\n }\n LOG_TRACE (\"handle: \" FORMAT_H \" [H 5]\\n\", ARGS_H (obj->handle))\n\n PRE (R_13) { return DWG_ERR_NOTYETSUPPORTED; }\n\n error |= dwg_decode_eed (dat, (Dwg_Object_Object *)ent);\n if (error & (DWG_ERR_INVALIDEED | DWG_ERR_VALUEOUTOFBOUNDS))\n return error;\n\n \/\/ clang-format off\n #include \"common_entity_data.spec\"\n \/\/ clang-format on\n\n SINCE (R_2007) {\n dwg_decode_common_entity_handle_data (dat, hdl_dat, obj);\n }\n\n \/\/ elsewhere: object data, handles, padding bits, crc\n obj->common_size = bit_position (dat) - objectpos;\n LOG_HANDLE (\"--common_size: %lu\\n\", obj->common_size); \/\/ needed for unknown\n\n return error;\n}","target":0,"code_token_length":945,"total_token_length":1181,"max_tokens_setting":2048} +{"idx":161466,"func":"void vertical_grid(\n image_desc_t *im)\n{\n int xlab_sel; \/* which sort of label and grid ? *\/\n time_t ti, tilab, timajor;\n long factor;\n char graph_label[100];\n double X0, Y0, Y1; \/* points for filled graph and more *\/\n struct tm tm;\n\n \/* the type of time grid is determined by finding\n the number of seconds per pixel in the graph *\/\n if (im->xlab_user.minsec == -1) {\n factor = (im->end - im->start) \/ im->xsize;\n xlab_sel = 0;\n while (xlab[xlab_sel + 1].minsec !=\n -1 && xlab[xlab_sel + 1].minsec <= factor) {\n xlab_sel++;\n } \/* pick the last one *\/\n while (xlab[xlab_sel - 1].minsec ==\n xlab[xlab_sel].minsec\n && xlab[xlab_sel].length > (im->end - im->start)) {\n xlab_sel--;\n } \/* go back to the smallest size *\/\n im->xlab_user.gridtm = xlab[xlab_sel].gridtm;\n im->xlab_user.gridst = xlab[xlab_sel].gridst;\n im->xlab_user.mgridtm = xlab[xlab_sel].mgridtm;\n im->xlab_user.mgridst = xlab[xlab_sel].mgridst;\n im->xlab_user.labtm = xlab[xlab_sel].labtm;\n im->xlab_user.labst = xlab[xlab_sel].labst;\n im->xlab_user.precis = xlab[xlab_sel].precis;\n im->xlab_user.stst = xlab[xlab_sel].stst;\n }\n\n \/* y coords are the same for every line ... *\/\n Y0 = im->yorigin;\n Y1 = im->yorigin - im->ysize;\n \/* paint the minor grid *\/\n if (!(im->extra_flags & NOMINOR)) {\n for (ti = find_first_time(im->start,\n im->\n xlab_user.\n gridtm,\n im->\n xlab_user.\n gridst),\n timajor =\n find_first_time(im->start,\n im->xlab_user.\n mgridtm,\n im->xlab_user.\n mgridst);\n ti < im->end && ti != -1;\n ti =\n find_next_time(ti, im->xlab_user.gridtm, im->xlab_user.gridst)\n ) {\n \/* are we inside the graph ? *\/\n if (ti < im->start || ti > im->end)\n continue;\n while (timajor < ti && timajor != -1) {\n timajor = find_next_time(timajor,\n im->\n xlab_user.\n mgridtm, im->xlab_user.mgridst);\n }\n if (timajor == -1) break; \/* fail in case of problems with time increments *\/\n if (ti == timajor)\n continue; \/* skip as falls on major grid line *\/\n X0 = xtr(im, ti);\n gfx_line(im, X0, Y1 - 2, X0, Y1,\n GRIDWIDTH, im->graph_col[GRC_GRID]);\n gfx_line(im, X0, Y0, X0, Y0 + 2,\n GRIDWIDTH, im->graph_col[GRC_GRID]);\n gfx_dashed_line(im, X0, Y0 + 1, X0,\n Y1 - 1, GRIDWIDTH,\n im->\n graph_col[GRC_GRID],\n im->grid_dash_on, im->grid_dash_off);\n }\n }\n\n \/* paint the major grid *\/\n for (ti = find_first_time(im->start,\n im->\n xlab_user.\n mgridtm,\n im->\n xlab_user.\n mgridst);\n ti < im->end && ti != -1;\n ti = find_next_time(ti, im->xlab_user.mgridtm, im->xlab_user.mgridst)\n ) {\n \/* are we inside the graph ? *\/\n if (ti < im->start || ti > im->end)\n continue;\n X0 = xtr(im, ti);\n gfx_line(im, X0, Y1 - 2, X0, Y1,\n MGRIDWIDTH, im->graph_col[GRC_MGRID]);\n gfx_line(im, X0, Y0, X0, Y0 + 3,\n MGRIDWIDTH, im->graph_col[GRC_MGRID]);\n gfx_dashed_line(im, X0, Y0 + 3, X0,\n Y1 - 2, MGRIDWIDTH,\n im->\n graph_col\n [GRC_MGRID], im->grid_dash_on, im->grid_dash_off);\n }\n \/* paint the labels below the graph *\/\n for (ti =\n find_first_time(im->start -\n im->xlab_user.\n precis \/ 2,\n im->xlab_user.\n labtm,\n im->xlab_user.\n labst);\n (ti <=\n im->end -\n im->xlab_user.precis \/ 2) && ti != -1;\n ti = find_next_time(ti, im->xlab_user.labtm, im->xlab_user.labst)\n ) {\n tilab = ti + im->xlab_user.precis \/ 2; \/* correct time for the label *\/\n \/* are we inside the graph ? *\/\n if (tilab < im->start || tilab > im->end)\n continue;\n#if HAVE_STRFTIME\n localtime_r(&tilab, &tm);\n strftime(graph_label, 99, im->xlab_user.stst, &tm);\n#else\n# error \"your libc has no strftime I guess we'll abort the exercise here.\"\n#endif\n gfx_text(im,\n xtr(im, tilab),\n Y0 + 3,\n im->graph_col[GRC_FONT],\n im->\n text_prop[TEXT_PROP_AXIS].\n font_desc,\n im->tabwidth, 0.0,\n GFX_H_CENTER, GFX_V_TOP, graph_label);\n }\n\n}","target":0,"code_token_length":1364,"total_token_length":1600,"max_tokens_setting":2048} +{"idx":328224,"func":"static int cllc_decode_frame(AVCodecContext *avctx, void *data,\n\n int *got_picture_ptr, AVPacket *avpkt)\n\n{\n\n CLLCContext *ctx = avctx->priv_data;\n\n AVFrame *pic = avctx->coded_frame;\n\n uint8_t *src = avpkt->data;\n\n uint8_t *swapped_buf_new;\n\n uint32_t info_tag, info_offset;\n\n GetBitContext gb;\n\n int coding_type, ret;\n\n\n\n if (pic->data[0])\n\n avctx->release_buffer(avctx, pic);\n\n\n\n pic->reference = 0;\n\n\n\n \/* Make sure our bswap16'd buffer is big enough *\/\n\n swapped_buf_new = av_fast_realloc(ctx->swapped_buf,\n\n &ctx->swapped_buf_size, avpkt->size);\n\n if (!swapped_buf_new) {\n\n av_log(avctx, AV_LOG_ERROR, \"Could not realloc swapped buffer.\\n\");\n\n return AVERROR(ENOMEM);\n\n }\n\n ctx->swapped_buf = swapped_buf_new;\n\n\n\n \/* Skip the INFO header if present *\/\n\n info_offset = 0;\n\n info_tag = AV_RL32(src);\n\n if (info_tag == MKTAG('I', 'N', 'F', 'O')) {\n\n info_offset = AV_RL32(src + 4);\n\n if (info_offset > UINT32_MAX - 8 || info_offset + 8 > avpkt->size) {\n\n av_log(avctx, AV_LOG_ERROR,\n\n \"Invalid INFO header offset: 0x%08X is too large.\\n\",\n\n info_offset);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n info_offset += 8;\n\n src += info_offset;\n\n\n\n av_log(avctx, AV_LOG_DEBUG, \"Skipping INFO chunk.\\n\");\n\n }\n\n\n\n \/* bswap16 the buffer since CLLC's bitreader works in 16-bit words *\/\n\n ctx->dsp.bswap16_buf((uint16_t *) ctx->swapped_buf, (uint16_t *) src,\n\n (avpkt->size - info_offset) \/ 2);\n\n\n\n init_get_bits(&gb, ctx->swapped_buf, (avpkt->size - info_offset) * 8);\n\n\n\n \/*\n\n * Read in coding type. The types are as follows:\n\n *\n\n * 0 - YUY2\n\n * 1 - BGR24 (Triples)\n\n * 2 - BGR24 (Quads)\n\n * 3 - BGRA\n\n *\/\n\n coding_type = (AV_RL32(src) >> 8) & 0xFF;\n\n av_log(avctx, AV_LOG_DEBUG, \"Frame coding type: %d\\n\", coding_type);\n\n\n\n switch (coding_type) {\n\n case 1:\n\n case 2:\n\n avctx->pix_fmt = PIX_FMT_RGB24;\n\n avctx->bits_per_raw_sample = 8;\n\n\n\n ret = avctx->get_buffer(avctx, pic);\n\n if (ret < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Could not allocate buffer.\\n\");\n\n return ret;\n\n }\n\n\n\n ret = decode_rgb24_frame(ctx, &gb, pic);\n\n if (ret < 0)\n\n return ret;\n\n\n\n break;\n\n case 3:\n\n avctx->pix_fmt = PIX_FMT_ARGB;\n\n avctx->bits_per_raw_sample = 8;\n\n\n\n ret = avctx->get_buffer(avctx, pic);\n\n if (ret < 0) {\n\n av_log(avctx, AV_LOG_ERROR, \"Could not allocate buffer.\\n\");\n\n return ret;\n\n }\n\n\n\n ret = decode_argb_frame(ctx, &gb, pic);\n\n if (ret < 0)\n\n return ret;\n\n\n\n break;\n\n default:\n\n av_log(avctx, AV_LOG_ERROR, \"Unknown coding type: %d.\\n\", coding_type);\n\n return AVERROR_INVALIDDATA;\n\n }\n\n\n\n pic->key_frame = 1;\n\n pic->pict_type = AV_PICTURE_TYPE_I;\n\n\n\n *got_picture_ptr = 1;\n\n *(AVFrame *)data = *pic;\n\n\n\n return avpkt->size;\n\n}\n","target":1,"code_token_length":893,"total_token_length":1129,"max_tokens_setting":2048} +{"idx":459355,"func":"set_cmnd(void)\n{\n struct sudo_nss *nss;\n int ret = FOUND;\n debug_decl(set_cmnd, SUDOERS_DEBUG_PLUGIN);\n\n \/* Allocate user_stat for find_path() and match functions. *\/\n user_stat = calloc(1, sizeof(struct stat));\n if (user_stat == NULL) {\n\tsudo_warnx(U_(\"%s: %s\"), __func__, U_(\"unable to allocate memory\"));\n\tdebug_return_int(NOT_FOUND_ERROR);\n }\n\n \/* Default value for cmnd, overridden below. *\/\n if (user_cmnd == NULL)\n\tuser_cmnd = NewArgv[0];\n\n if (ISSET(sudo_mode, MODE_RUN|MODE_EDIT|MODE_CHECK)) {\n\tif (!ISSET(sudo_mode, MODE_EDIT)) {\n\t const char *runchroot = user_runchroot;\n\t if (runchroot == NULL && def_runchroot != NULL &&\n\t\t strcmp(def_runchroot, \"*\") != 0)\n\t\trunchroot = def_runchroot;\n\n\t ret = set_cmnd_path(runchroot);\n\t if (ret == NOT_FOUND_ERROR) {\n\t\tif (errno == ENAMETOOLONG) {\n\t\t audit_failure(NewArgv, N_(\"command too long\"));\n\t\t}\n\t\tlog_warning(0, \"%s\", NewArgv[0]);\n\t\tdebug_return_int(ret);\n\t }\n\t}\n\n\t\/* set user_args *\/\n\tif (NewArgc > 1) {\n\t char *to, *from, **av;\n\t size_t size, n;\n\n\t \/* Alloc and build up user_args. *\/\n\t for (size = 0, av = NewArgv + 1; *av; av++)\n\t\tsize += strlen(*av) + 1;\n\t if (size == 0 || (user_args = malloc(size)) == NULL) {\n\t\tsudo_warnx(U_(\"%s: %s\"), __func__, U_(\"unable to allocate memory\"));\n\t\tdebug_return_int(NOT_FOUND_ERROR);\n\t }\n\t if (ISSET(sudo_mode, MODE_SHELL|MODE_LOGIN_SHELL) &&\n\t\t ISSET(sudo_mode, MODE_RUN)) {\n\t\t\/*\n\t\t * When running a command via a shell, the sudo front-end\n\t\t * escapes potential meta chars. We unescape non-spaces\n\t\t * for sudoers matching and logging purposes.\n\t\t *\/\n\t\tfor (to = user_args, av = NewArgv + 1; (from = *av); av++) {\n\t\t while (*from) {\n\t\t\tif (from[0] == '\\\\' && from[1] != '\\0' &&\n\t\t\t\t!isspace((unsigned char)from[1])) {\n\t\t\t from++;\n\t\t\t}\n\t\t\tif (size - (to - user_args) < 1) {\n\t\t\t sudo_warnx(U_(\"internal error, %s overflow\"),\n\t\t\t\t__func__);\n\t\t\t debug_return_int(NOT_FOUND_ERROR);\n\t\t\t}\n\t\t\t*to++ = *from++;\n\t\t }\n\t\t if (size - (to - user_args) < 1) {\n\t\t\tsudo_warnx(U_(\"internal error, %s overflow\"),\n\t\t\t __func__);\n\t\t\tdebug_return_int(NOT_FOUND_ERROR);\n\t\t }\n\t\t *to++ = ' ';\n\t\t}\n\t\t*--to = '\\0';\n\t } else {\n\t\tfor (to = user_args, av = NewArgv + 1; *av; av++) {\n\t\t n = strlcpy(to, *av, size - (to - user_args));\n\t\t if (n >= size - (to - user_args)) {\n\t\t\tsudo_warnx(U_(\"internal error, %s overflow\"), __func__);\n\t\t\tdebug_return_int(NOT_FOUND_ERROR);\n\t\t }\n\t\t to += n;\n\t\t *to++ = ' ';\n\t\t}\n\t\t*--to = '\\0';\n\t }\n\t}\n }\n\n if ((user_base = strrchr(user_cmnd, '\/')) != NULL)\n\tuser_base++;\n else\n\tuser_base = user_cmnd;\n\n \/* Convert \"sudo sudoedit\" -> \"sudoedit\" *\/\n if (ISSET(sudo_mode, MODE_RUN) && strcmp(user_base, \"sudoedit\") == 0) {\n\tCLR(sudo_mode, MODE_RUN);\n\tSET(sudo_mode, MODE_EDIT);\n\tsudo_warnx(\"%s\", U_(\"sudoedit doesn't need to be run via sudo\"));\n\tuser_base = user_cmnd = \"sudoedit\";\n }\n\n TAILQ_FOREACH(nss, snl, entries) {\n\tif (!update_defaults(nss->parse_tree, NULL, SETDEF_CMND, false)) {\n\t log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,\n\t\tN_(\"problem with defaults entries\"));\n\t}\n }\n\n debug_return_int(ret);\n}","target":0,"code_token_length":991,"total_token_length":1227,"max_tokens_setting":2048} +{"idx":12414,"func":"static int entersafe_gen_key(sc_card_t *card, sc_entersafe_gen_key_data *data)\n{\n\tint\tr;\n\tsize_t len = data->key_length >> 3;\n\tsc_apdu_t apdu;\n\tu8 rbuf[300];\n\tu8 sbuf[4],*p;\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);\n\n\t\/* MSE *\/\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x01, 0xB8);\n\tapdu.lc=0x04;\n\tsbuf[0]=0x83;\n\tsbuf[1]=0x02;\n\tsbuf[2]=data->key_id;\n\tsbuf[3]=0x2A;\n\tapdu.data = sbuf;\n\tapdu.datalen=4;\n\tapdu.lc=4;\n\tapdu.le=0;\n\n\tr=entersafe_transmit_apdu(card, &apdu, 0,0,0,0);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card,apdu.sw1,apdu.sw2),\"EnterSafe set MSE failed\");\n\n\t\/* generate key *\/\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);\n\tapdu.le = 0;\n\tsbuf[0] = (u8)(data->key_length >> 8);\n\tsbuf[1] = (u8)(data->key_length);\n\tapdu.data = sbuf;\n\tapdu.lc = 2;\n\tapdu.datalen = 2;\n\n\tr = entersafe_transmit_apdu(card, &apdu,0,0,0,0);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card,apdu.sw1,apdu.sw2),\"EnterSafe generate keypair failed\");\n\n\t\/* read public key via READ PUBLIC KEY *\/\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xE6, 0x2A, data->key_id);\n\tapdu.cla = 0x80;\n\tapdu.resp = rbuf;\n\tapdu.resplen = sizeof(rbuf);\n\tapdu.le = 256;\n\tr = entersafe_transmit_apdu(card, &apdu,0,0,0,0);\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\tSC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card,apdu.sw1,apdu.sw2),\"EnterSafe get pukey failed\");\n \n \tdata->modulus = malloc(len);\n \tif (!data->modulus)\n\t\t SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_OUT_OF_MEMORY);\n \n \tp=rbuf;\n\tassert(*p=='E');\n \tp+=2+p[1];\n \t\/* N *\/\n\tassert(*p=='N');\n \t++p;\n \tif(*p++>0x80)\n \t{\n\t\t u8 len_bytes=(*(p-1))&0x0f;\n\t\t size_t module_len=0;\n\t\t while(len_bytes!=0)\n\t\t {\n\t\t\t module_len=module_len<<8;\n\t\t\t module_len+=*p++;\n\t\t\t --len_bytes;\n\t\t }\n\t}\n\n\tentersafe_reverse_buffer(p,len);\n\tmemcpy(data->modulus,p,len);\n\n\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);\n}\n","target":1,"code_token_length":794,"total_token_length":1030,"max_tokens_setting":2048} +{"idx":468743,"func":"read_yin_grouping(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,\n struct unres_schema *unres)\n{\n struct ly_ctx *ctx = module->ctx;\n struct lyxml_elem *sub, *next, root;\n struct lys_node *node = NULL;\n struct lys_node *retval;\n struct lys_node_grp *grp;\n int r;\n int c_tpdf = 0, c_ext = 0;\n void *reallocated;\n\n \/* init *\/\n memset(&root, 0, sizeof root);\n\n grp = calloc(1, sizeof *grp);\n LY_CHECK_ERR_RETURN(!grp, LOGMEM(ctx), NULL);\n\n grp->nodetype = LYS_GROUPING;\n grp->prev = (struct lys_node *)grp;\n retval = (struct lys_node *)grp;\n\n if (read_yin_common(module, parent, retval, LYEXT_PAR_NODE, yin, OPT_IDENT | OPT_MODULE , unres)) {\n goto error;\n }\n\n LOGDBG(LY_LDGYIN, \"parsing %s statement \\\"%s\\\"\", yin->name, retval->name);\n\n \/* insert the node into the schema tree *\/\n if (lys_node_addchild(parent, lys_main_module(module), retval, options)) {\n goto error;\n }\n\n LY_TREE_FOR_SAFE(yin->child, next, sub) {\n if (strcmp(sub->ns->value, LY_NSYIN)) {\n \/* extension *\/\n YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, \"extensions\", \"grouping\", error);\n c_ext++;\n\n \/* data statements *\/\n } else if (!strcmp(sub->name, \"container\") ||\n !strcmp(sub->name, \"leaf-list\") ||\n !strcmp(sub->name, \"leaf\") ||\n !strcmp(sub->name, \"list\") ||\n !strcmp(sub->name, \"choice\") ||\n !strcmp(sub->name, \"uses\") ||\n !strcmp(sub->name, \"grouping\") ||\n !strcmp(sub->name, \"anyxml\") ||\n !strcmp(sub->name, \"anydata\") ||\n !strcmp(sub->name, \"action\") ||\n !strcmp(sub->name, \"notification\")) {\n lyxml_unlink_elem(ctx, sub, 2);\n lyxml_add_child(ctx, &root, sub);\n\n \/* array counters *\/\n } else if (!strcmp(sub->name, \"typedef\")) {\n YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, grp->tpdf_size, \"typedefs\", \"grouping\", error);\n c_tpdf++;\n } else {\n LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);\n goto error;\n }\n }\n\n \/* middle part - process nodes with cardinality of 0..n except the data nodes *\/\n if (c_tpdf) {\n grp->tpdf = calloc(c_tpdf, sizeof *grp->tpdf);\n LY_CHECK_ERR_GOTO(!grp->tpdf, LOGMEM(ctx), error);\n }\n if (c_ext) {\n \/* some extensions may be already present from the substatements *\/\n reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);\n LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);\n retval->ext = reallocated;\n\n \/* init memory *\/\n memset(&retval->ext[retval->ext_size], 0, c_ext * sizeof *retval->ext);\n }\n LY_TREE_FOR_SAFE(yin->child, next, sub) {\n if (strcmp(sub->ns->value, LY_NSYIN)) {\n \/* extension *\/\n r = lyp_yin_fill_ext(retval, LYEXT_PAR_NODE, 0, 0, module, sub, &retval->ext, &retval->ext_size, unres);\n if (r) {\n goto error;\n }\n } else {\n \/* typedef *\/\n r = fill_yin_typedef(module, retval, sub, &grp->tpdf[grp->tpdf_size], unres);\n grp->tpdf_size++;\n if (r) {\n goto error;\n }\n }\n }\n\n lyp_reduce_ext_list(&retval->ext, retval->ext_size, c_ext + retval->ext_size);\n\n \/* last part - process data nodes *\/\n if (!root.child) {\n LOGWRN(ctx, \"Grouping \\\"%s\\\" without children.\", retval->name);\n }\n options |= LYS_PARSE_OPT_INGRP;\n LY_TREE_FOR_SAFE(root.child, next, sub) {\n if (!strcmp(sub->name, \"container\")) {\n node = read_yin_container(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"leaf-list\")) {\n node = read_yin_leaflist(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"leaf\")) {\n node = read_yin_leaf(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"list\")) {\n node = read_yin_list(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"choice\")) {\n node = read_yin_choice(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"uses\")) {\n node = read_yin_uses(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"grouping\")) {\n node = read_yin_grouping(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"anyxml\")) {\n node = read_yin_anydata(module, retval, sub, LYS_ANYXML, options, unres);\n } else if (!strcmp(sub->name, \"anydata\")) {\n node = read_yin_anydata(module, retval, sub, LYS_ANYDATA, options, unres);\n } else if (!strcmp(sub->name, \"action\")) {\n node = read_yin_rpc_action(module, retval, sub, options, unres);\n } else if (!strcmp(sub->name, \"notification\")) {\n node = read_yin_notif(module, retval, sub, options, unres);\n }\n if (!node) {\n goto error;\n }\n\n lyxml_free(ctx, sub);\n }\n\n return retval;\n\nerror:\n lys_node_free(ctx, retval, NULL, 0);\n while (root.child) {\n lyxml_free(ctx, root.child);\n }\n return NULL;\n}","target":0,"code_token_length":1431,"total_token_length":1667,"max_tokens_setting":2048} +{"idx":98205,"func":"TfLiteStatus EvalHybridPerChannel(TfLiteContext* context, TfLiteNode* node,\n TfLiteConvParams* params, OpData* data,\n const TfLiteTensor* input,\n const TfLiteTensor* filter,\n const TfLiteTensor* bias,\n TfLiteTensor* im2col, TfLiteTensor* output) {\n float output_activation_min, output_activation_max;\n CalculateActivationRange(params->activation, &output_activation_min,\n &output_activation_max);\n\n const int input_size = NumElements(input) \/ SizeOfDimension(input, 0);\n const int batch_size = SizeOfDimension(input, 0);\n TfLiteTensor* quantized_input_tensor;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, data->input_quantized_index,\n &quantized_input_tensor));\n int8_t* quantized_input_ptr_batch =\n GetTensorData(quantized_input_tensor);\n TfLiteTensor* scaling_factors_tensor;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, data->scaling_factors_index,\n &scaling_factors_tensor));\n float* scaling_factors_ptr = GetTensorData(scaling_factors_tensor);\n TfLiteTensor* input_offset_tensor;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, data->input_offset_index,\n &input_offset_tensor));\n int32_t* input_offset_ptr = GetTensorData(input_offset_tensor);\n\n for (int b = 0; b < batch_size; ++b) {\n const int offset = b * input_size;\n tensor_utils::AsymmetricQuantizeFloats(\n GetTensorData(input) + offset, input_size,\n quantized_input_ptr_batch + offset, &scaling_factors_ptr[b],\n &input_offset_ptr[b]);\n }\n\n int8_t* im2col_ptr = nullptr;\n int8_t* filter_ptr = nullptr;\n if (im2col != nullptr) {\n im2col_ptr = im2col->data.int8;\n }\n filter_ptr = filter->data.int8;\n const auto* affine_quantization =\n reinterpret_cast(filter->quantization.params);\n ConvParams op_params;\n op_params.padding_type = PaddingType::kSame;\n op_params.padding_values.width = data->padding.width;\n op_params.padding_values.height = data->padding.height;\n op_params.stride_width = params->stride_width;\n op_params.stride_height = params->stride_height;\n op_params.dilation_width_factor = 1;\n op_params.dilation_height_factor = 1;\n op_params.float_activation_min = output_activation_min;\n op_params.float_activation_max = output_activation_max;\n switch (kernel_type) {\n case kReference:\n reference_ops::HybridConvPerChannel(\n op_params, scaling_factors_ptr, GetTensorShape(input),\n quantized_input_ptr_batch, GetTensorShape(filter), filter_ptr,\n GetTensorShape(bias), GetTensorData(bias),\n GetTensorShape(output), GetTensorData(output),\n GetTensorShape(im2col), im2col_ptr, affine_quantization->scale->data,\n input_offset_ptr);\n break;\n case kGenericOptimized:\n case kMultithreadOptimized:\n case kCblasOptimized: {\n TfLiteTensor* row_sums;\n TF_LITE_ENSURE_OK(\n context,\n GetTemporarySafe(context, node, data->row_sums_index, &row_sums));\n TfLiteTensor* scratch;\n TF_LITE_ENSURE_OK(\n context,\n GetTemporarySafe(context, node, data->accum_scratch_index, &scratch));\n optimized_ops::HybridConvPerChannel(\n op_params, scaling_factors_ptr, GetTensorShape(input),\n quantized_input_ptr_batch, GetTensorShape(filter), filter_ptr,\n GetTensorShape(bias), GetTensorData(bias),\n GetTensorShape(output), GetTensorData(output),\n GetTensorShape(im2col), im2col_ptr, affine_quantization->scale->data,\n input_offset_ptr, GetTensorShape(scratch),\n GetTensorData(scratch), GetTensorData(row_sums),\n &data->compute_hybrid_row_sums,\n CpuBackendContext::GetFromContext(context));\n data->compute_hybrid_row_sums = false;\n break;\n }\n }\n\n return kTfLiteOk;\n}","target":0,"code_token_length":955,"total_token_length":1191,"max_tokens_setting":2048} +{"idx":459295,"func":"static void cmd_inquiry(IDEState *s, uint8_t *buf)\n{\n uint8_t page_code = buf[2];\n int max_len = buf[4];\n\n unsigned idx = 0;\n unsigned size_idx;\n unsigned preamble_len;\n\n \/* If the EVPD (Enable Vital Product Data) bit is set in byte 1,\n * we are being asked for a specific page of info indicated by byte 2. *\/\n if (buf[1] & 0x01) {\n preamble_len = 4;\n size_idx = 3;\n\n buf[idx++] = 0x05; \/* CD-ROM *\/\n buf[idx++] = page_code; \/* Page Code *\/\n buf[idx++] = 0x00; \/* reserved *\/\n idx++; \/* length (set later) *\/\n\n switch (page_code) {\n case 0x00:\n \/* Supported Pages: List of supported VPD responses. *\/\n buf[idx++] = 0x00; \/* 0x00: Supported Pages, and: *\/\n buf[idx++] = 0x83; \/* 0x83: Device Identification. *\/\n break;\n\n case 0x83:\n \/* Device Identification. Each entry is optional, but the entries\n * included here are modeled after libata's VPD responses.\n * If the response is given, at least one entry must be present. *\/\n\n \/* Entry 1: Serial *\/\n if (idx + 24 > max_len) {\n \/* Not enough room for even the first entry: *\/\n \/* 4 byte header + 20 byte string *\/\n ide_atapi_cmd_error(s, ILLEGAL_REQUEST,\n ASC_DATA_PHASE_ERROR);\n return;\n }\n buf[idx++] = 0x02; \/* Ascii *\/\n buf[idx++] = 0x00; \/* Vendor Specific *\/\n buf[idx++] = 0x00;\n buf[idx++] = 20; \/* Remaining length *\/\n padstr8(buf + idx, 20, s->drive_serial_str);\n idx += 20;\n\n \/* Entry 2: Drive Model and Serial *\/\n if (idx + 72 > max_len) {\n \/* 4 (header) + 8 (vendor) + 60 (model & serial) *\/\n goto out;\n }\n buf[idx++] = 0x02; \/* Ascii *\/\n buf[idx++] = 0x01; \/* T10 Vendor *\/\n buf[idx++] = 0x00;\n buf[idx++] = 68;\n padstr8(buf + idx, 8, \"ATA\"); \/* Generic T10 vendor *\/\n idx += 8;\n padstr8(buf + idx, 40, s->drive_model_str);\n idx += 40;\n padstr8(buf + idx, 20, s->drive_serial_str);\n idx += 20;\n\n \/* Entry 3: WWN *\/\n if (s->wwn && (idx + 12 <= max_len)) {\n \/* 4 byte header + 8 byte wwn *\/\n buf[idx++] = 0x01; \/* Binary *\/\n buf[idx++] = 0x03; \/* NAA *\/\n buf[idx++] = 0x00;\n buf[idx++] = 0x08;\n stq_be_p(&buf[idx], s->wwn);\n idx += 8;\n }\n break;\n\n default:\n \/* SPC-3, revision 23 sec. 6.4 *\/\n ide_atapi_cmd_error(s, ILLEGAL_REQUEST,\n ASC_INV_FIELD_IN_CMD_PACKET);\n return;\n }\n } else {\n preamble_len = 5;\n size_idx = 4;\n\n buf[0] = 0x05; \/* CD-ROM *\/\n buf[1] = 0x80; \/* removable *\/\n buf[2] = 0x00; \/* ISO *\/\n buf[3] = 0x21; \/* ATAPI-2 (XXX: put ATAPI-4 ?) *\/\n \/* buf[size_idx] set below. *\/\n buf[5] = 0; \/* reserved *\/\n buf[6] = 0; \/* reserved *\/\n buf[7] = 0; \/* reserved *\/\n padstr8(buf + 8, 8, \"QEMU\");\n padstr8(buf + 16, 16, \"QEMU DVD-ROM\");\n padstr8(buf + 32, 4, s->version);\n idx = 36;\n }\n\n out:\n buf[size_idx] = idx - preamble_len;\n ide_atapi_cmd_reply(s, idx, max_len);\n}","target":0,"code_token_length":1031,"total_token_length":1267,"max_tokens_setting":2048} +{"idx":296664,"func":"authenticate_job(cupsd_client_t *con,\t\/* I - Client connection *\/\n\t ipp_attribute_t *uri)\t\/* I - Job URI *\/\n{\n ipp_attribute_t\t*attr,\t\t\/* job-id attribute *\/\n\t\t\t*auth_info;\t\/* auth-info attribute *\/\n int\t\t\tjobid;\t\t\/* Job ID *\/\n cupsd_job_t\t\t*job;\t\t\/* Current job *\/\n char\t\t\tscheme[HTTP_MAX_URI],\n\t\t\t\t\t\/* Method portion of URI *\/\n\t\t\tusername[HTTP_MAX_URI],\n\t\t\t\t\t\/* Username portion of URI *\/\n\t\t\thost[HTTP_MAX_URI],\n\t\t\t\t\t\/* Host portion of URI *\/\n\t\t\tresource[HTTP_MAX_URI];\n\t\t\t\t\t\/* Resource portion of URI *\/\n int\t\t\tport;\t\t\/* Port portion of URI *\/\n\n\n cupsdLogMessage(CUPSD_LOG_DEBUG2, \"authenticate_job(%p[%d], %s)\",\n con, con->number, uri->values[0].string.text);\n\n \/*\n * Start with \"everything is OK\" status...\n *\/\n\n con->response->request.status.status_code = IPP_OK;\n\n \/*\n * See if we have a job URI or a printer URI...\n *\/\n\n if (!strcmp(uri->name, \"printer-uri\"))\n {\n \/*\n * Got a printer URI; see if we also have a job-id attribute...\n *\/\n\n if ((attr = ippFindAttribute(con->request, \"job-id\",\n IPP_TAG_INTEGER)) == NULL)\n {\n send_ipp_status(con, IPP_BAD_REQUEST,\n _(\"Got a printer-uri attribute but no job-id.\"));\n return;\n }\n\n jobid = attr->values[0].integer;\n }\n else\n {\n \/*\n * Got a job URI; parse it to get the job ID...\n *\/\n\n httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,\n sizeof(scheme), username, sizeof(username), host,\n\t\t sizeof(host), &port, resource, sizeof(resource));\n\n if (strncmp(resource, \"\/jobs\/\", 6))\n {\n \/*\n * Not a valid URI!\n *\/\n\n send_ipp_status(con, IPP_BAD_REQUEST, _(\"Bad job-uri \\\"%s\\\".\"),\n uri->values[0].string.text);\n return;\n }\n\n jobid = atoi(resource + 6);\n }\n\n \/*\n * See if the job exists...\n *\/\n\n if ((job = cupsdFindJob(jobid)) == NULL)\n {\n \/*\n * Nope - return a \"not found\" error...\n *\/\n\n send_ipp_status(con, IPP_NOT_FOUND, _(\"Job #%d does not exist.\"), jobid);\n return;\n }\n\n \/*\n * See if the job has been completed...\n *\/\n\n if (job->state_value != IPP_JOB_HELD)\n {\n \/*\n * Return a \"not-possible\" error...\n *\/\n\n send_ipp_status(con, IPP_NOT_POSSIBLE,\n _(\"Job #%d is not held for authentication.\"),\n\t\t jobid);\n return;\n }\n\n \/*\n * See if we have already authenticated...\n *\/\n\n auth_info = ippFindAttribute(con->request, \"auth-info\", IPP_TAG_TEXT);\n\n if (!con->username[0] && !auth_info)\n {\n cupsd_printer_t\t*printer;\t\/* Job destination *\/\n\n \/*\n * No auth data. If we need to authenticate via Kerberos, send a\n * HTTP auth challenge, otherwise just return an IPP error...\n *\/\n\n printer = cupsdFindDest(job->dest);\n\n if (printer && printer->num_auth_info_required > 0 &&\n !strcmp(printer->auth_info_required[0], \"negotiate\"))\n send_http_error(con, HTTP_UNAUTHORIZED, printer);\n else\n send_ipp_status(con, IPP_NOT_AUTHORIZED,\n\t\t _(\"No authentication information provided.\"));\n return;\n }\n\n \/*\n * See if the job is owned by the requesting user...\n *\/\n\n if (!validate_user(job, con, job->username, username, sizeof(username)))\n {\n send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,\n cupsdFindDest(job->dest));\n return;\n }\n\n \/*\n * Save the authentication information for this job...\n *\/\n\n save_auth_info(con, job, auth_info);\n\n \/*\n * Reset the job-hold-until value to \"no-hold\"...\n *\/\n\n if ((attr = ippFindAttribute(job->attrs, \"job-hold-until\",\n IPP_TAG_KEYWORD)) == NULL)\n attr = ippFindAttribute(job->attrs, \"job-hold-until\", IPP_TAG_NAME);\n\n if (attr)\n {\n ippSetValueTag(job->attrs, &attr, IPP_TAG_KEYWORD);\n ippSetString(job->attrs, &attr, 0, \"no-hold\");\n }\n\n \/*\n * Release the job and return...\n *\/\n\n cupsdReleaseJob(job);\n\n cupsdAddEvent(CUPSD_EVENT_JOB_STATE, NULL, job, \"Job authenticated by user\");\n\n cupsdLogJob(job, CUPSD_LOG_INFO, \"Authenticated by \\\"%s\\\".\", con->username);\n\n cupsdCheckJobs();\n}","target":0,"code_token_length":1103,"total_token_length":1339,"max_tokens_setting":2048} +{"idx":452493,"func":"static void kbd_keycode(unsigned int keycode, int down, int hw_raw)\n{\n\tstruct vc_data *vc = vc_cons[fg_console].d;\n\tunsigned short keysym, *key_map;\n\tunsigned char type;\n\tbool raw_mode;\n\tstruct tty_struct *tty;\n\tint shift_final;\n\tstruct keyboard_notifier_param param = { .vc = vc, .value = keycode, .down = down };\n\tint rc;\n\n\ttty = vc->port.tty;\n\n\tif (tty && (!tty->driver_data)) {\n\t\t\/* No driver data? Strange. Okay we fix it then. *\/\n\t\ttty->driver_data = vc;\n\t}\n\n\tkbd = kbd_table + vc->vc_num;\n\n#ifdef CONFIG_SPARC\n\tif (keycode == KEY_STOP)\n\t\tsparc_l1_a_state = down;\n#endif\n\n\trep = (down == 2);\n\n\traw_mode = (kbd->kbdmode == VC_RAW);\n\tif (raw_mode && !hw_raw)\n\t\tif (emulate_raw(vc, keycode, !down << 7))\n\t\t\tif (keycode < BTN_MISC && printk_ratelimit())\n\t\t\t\tpr_warn(\"can't emulate rawmode for keycode %d\\n\",\n\t\t\t\t\tkeycode);\n\n#ifdef CONFIG_SPARC\n\tif (keycode == KEY_A && sparc_l1_a_state) {\n\t\tsparc_l1_a_state = false;\n\t\tsun_do_break();\n\t}\n#endif\n\n\tif (kbd->kbdmode == VC_MEDIUMRAW) {\n\t\t\/*\n\t\t * This is extended medium raw mode, with keys above 127\n\t\t * encoded as 0, high 7 bits, low 7 bits, with the 0 bearing\n\t\t * the 'up' flag if needed. 0 is reserved, so this shouldn't\n\t\t * interfere with anything else. The two bytes after 0 will\n\t\t * always have the up flag set not to interfere with older\n\t\t * applications. This allows for 16384 different keycodes,\n\t\t * which should be enough.\n\t\t *\/\n\t\tif (keycode < 128) {\n\t\t\tput_queue(vc, keycode | (!down << 7));\n\t\t} else {\n\t\t\tput_queue(vc, !down << 7);\n\t\t\tput_queue(vc, (keycode >> 7) | 0x80);\n\t\t\tput_queue(vc, keycode | 0x80);\n\t\t}\n\t\traw_mode = true;\n\t}\n\n\tif (down)\n\t\tset_bit(keycode, key_down);\n\telse\n\t\tclear_bit(keycode, key_down);\n\n\tif (rep &&\n\t (!vc_kbd_mode(kbd, VC_REPEAT) ||\n\t (tty && !L_ECHO(tty) && tty_chars_in_buffer(tty)))) {\n\t\t\/*\n\t\t * Don't repeat a key if the input buffers are not empty and the\n\t\t * characters get aren't echoed locally. This makes key repeat\n\t\t * usable with slow applications and under heavy loads.\n\t\t *\/\n\t\treturn;\n\t}\n\n\tparam.shift = shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate;\n\tparam.ledstate = kbd->ledflagstate;\n\tkey_map = key_maps[shift_final];\n\n\trc = atomic_notifier_call_chain(&keyboard_notifier_list,\n\t\t\t\t\tKBD_KEYCODE, ¶m);\n\tif (rc == NOTIFY_STOP || !key_map) {\n\t\tatomic_notifier_call_chain(&keyboard_notifier_list,\n\t\t\t\t\t KBD_UNBOUND_KEYCODE, ¶m);\n\t\tdo_compute_shiftstate();\n\t\tkbd->slockstate = 0;\n\t\treturn;\n\t}\n\n\tif (keycode < NR_KEYS)\n\t\tkeysym = key_map[keycode];\n\telse if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)\n\t\tkeysym = U(K(KT_BRL, keycode - KEY_BRL_DOT1 + 1));\n\telse\n\t\treturn;\n\n\ttype = KTYP(keysym);\n\n\tif (type < 0xf0) {\n\t\tparam.value = keysym;\n\t\trc = atomic_notifier_call_chain(&keyboard_notifier_list,\n\t\t\t\t\t\tKBD_UNICODE, ¶m);\n\t\tif (rc != NOTIFY_STOP)\n\t\t\tif (down && !raw_mode)\n\t\t\t\tk_unicode(vc, keysym, !down);\n\t\treturn;\n\t}\n\n\ttype -= 0xf0;\n\n\tif (type == KT_LETTER) {\n\t\ttype = KT_LATIN;\n\t\tif (vc_kbd_led(kbd, VC_CAPSLOCK)) {\n\t\t\tkey_map = key_maps[shift_final ^ (1 << KG_SHIFT)];\n\t\t\tif (key_map)\n\t\t\t\tkeysym = key_map[keycode];\n\t\t}\n\t}\n\n\tparam.value = keysym;\n\trc = atomic_notifier_call_chain(&keyboard_notifier_list,\n\t\t\t\t\tKBD_KEYSYM, ¶m);\n\tif (rc == NOTIFY_STOP)\n\t\treturn;\n\n\tif ((raw_mode || kbd->kbdmode == VC_OFF) && type != KT_SPEC && type != KT_SHIFT)\n\t\treturn;\n\n\t(*k_handler[type])(vc, keysym & 0xff, !down);\n\n\tparam.ledstate = kbd->ledflagstate;\n\tatomic_notifier_call_chain(&keyboard_notifier_list, KBD_POST_KEYSYM, ¶m);\n\n\tif (type != KT_SLOCK)\n\t\tkbd->slockstate = 0;\n}","target":0,"code_token_length":1087,"total_token_length":1323,"max_tokens_setting":2048} +{"idx":346288,"func":"xmlNextChar(xmlParserCtxtPtr ctxt)\n{\n if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||\n (ctxt->input == NULL))\n return;\n\n if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {\n if ((*ctxt->input->cur == 0) &&\n (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0) &&\n (ctxt->instate != XML_PARSER_COMMENT)) {\n \/*\n * If we are at the end of the current entity and\n * the context allows it, we pop consumed entities\n * automatically.\n * the auto closing should be blocked in other cases\n *\/\n xmlPopInput(ctxt);\n } else {\n const unsigned char *cur;\n unsigned char c;\n\n \/*\n * 2.11 End-of-Line Handling\n * the literal two-character sequence \"#xD#xA\" or a standalone\n * literal #xD, an XML processor must pass to the application\n * the single character #xA.\n *\/\n if (*(ctxt->input->cur) == '\\n') {\n ctxt->input->line++; ctxt->input->col = 1;\n } else\n ctxt->input->col++;\n\n \/*\n * We are supposed to handle UTF8, check it's valid\n * From rfc2044: encoding of the Unicode values on UTF-8:\n *\n * UCS-4 range (hex.) UTF-8 octet sequence (binary)\n * 0000 0000-0000 007F 0xxxxxxx\n * 0000 0080-0000 07FF 110xxxxx 10xxxxxx\n * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx\n *\n * Check for the 0x110000 limit too\n *\/\n cur = ctxt->input->cur;\n\n c = *cur;\n if (c & 0x80) {\n\t if (c == 0xC0)\n\t\t goto encoding_error;\n if (cur[1] == 0) {\n xmlParserInputGrow(ctxt->input, INPUT_CHUNK);\n cur = ctxt->input->cur;\n }\n if ((cur[1] & 0xc0) != 0x80)\n goto encoding_error;\n if ((c & 0xe0) == 0xe0) {\n unsigned int val;\n\n if (cur[2] == 0) {\n xmlParserInputGrow(ctxt->input, INPUT_CHUNK);\n cur = ctxt->input->cur;\n }\n if ((cur[2] & 0xc0) != 0x80)\n goto encoding_error;\n if ((c & 0xf0) == 0xf0) {\n if (cur[3] == 0) {\n xmlParserInputGrow(ctxt->input, INPUT_CHUNK);\n cur = ctxt->input->cur;\n }\n if (((c & 0xf8) != 0xf0) ||\n ((cur[3] & 0xc0) != 0x80))\n goto encoding_error;\n \/* 4-byte code *\/\n ctxt->input->cur += 4;\n val = (cur[0] & 0x7) << 18;\n val |= (cur[1] & 0x3f) << 12;\n val |= (cur[2] & 0x3f) << 6;\n val |= cur[3] & 0x3f;\n } else {\n \/* 3-byte code *\/\n ctxt->input->cur += 3;\n val = (cur[0] & 0xf) << 12;\n val |= (cur[1] & 0x3f) << 6;\n val |= cur[2] & 0x3f;\n }\n if (((val > 0xd7ff) && (val < 0xe000)) ||\n ((val > 0xfffd) && (val < 0x10000)) ||\n (val >= 0x110000)) {\n\t\t\txmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,\n\t\t\t\t\t \"Char 0x%X out of allowed range\\n\",\n\t\t\t\t\t val);\n }\n } else\n \/* 2-byte code *\/\n ctxt->input->cur += 2;\n } else\n \/* 1-byte code *\/\n ctxt->input->cur++;\n\n ctxt->nbChars++;\n if (*ctxt->input->cur == 0)\n xmlParserInputGrow(ctxt->input, INPUT_CHUNK);\n }\n } else {\n \/*\n * Assume it's a fixed length encoding (1) with\n * a compatible encoding for the ASCII set, since\n * XML constructs only use < 128 chars\n *\/\n\n if (*(ctxt->input->cur) == '\\n') {\n ctxt->input->line++; ctxt->input->col = 1;\n } else\n ctxt->input->col++;\n ctxt->input->cur++;\n ctxt->nbChars++;\n if (*ctxt->input->cur == 0)\n xmlParserInputGrow(ctxt->input, INPUT_CHUNK);\n }\n if ((*ctxt->input->cur == '%') && (!ctxt->html))\n xmlParserHandlePEReference(ctxt);\n if ((*ctxt->input->cur == 0) &&\n (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))\n xmlPopInput(ctxt);\n return;\nencoding_error:\n \/*\n * If we detect an UTF8 error that probably mean that the\n * input encoding didn't get properly advertised in the\n * declaration header. Report the error and switch the encoding\n * to ISO-Latin-1 (if you don't like this policy, just declare the\n * encoding !)\n *\/\n if ((ctxt == NULL) || (ctxt->input == NULL) ||\n (ctxt->input->end - ctxt->input->cur < 4)) {\n\t__xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,\n\t\t \"Input is not proper UTF-8, indicate encoding !\\n\",\n\t\t NULL, NULL);\n } else {\n char buffer[150];\n\n\tsnprintf(buffer, 149, \"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\\n\",\n\t\t\tctxt->input->cur[0], ctxt->input->cur[1],\n\t\t\tctxt->input->cur[2], ctxt->input->cur[3]);\n\t__xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,\n\t\t \"Input is not proper UTF-8, indicate encoding !\\n%s\",\n\t\t BAD_CAST buffer, NULL);\n }\n ctxt->charset = XML_CHAR_ENCODING_8859_1;\n ctxt->input->cur++;\n return;\n}","target":1,"code_token_length":1545,"total_token_length":1781,"max_tokens_setting":2048} +{"idx":177861,"func":"static int tcos_select_file(sc_card_t *card,\n\t\t\t const sc_path_t *in_path,\n\t\t\t sc_file_t **file_out)\n{\n\tsc_context_t *ctx;\n\tsc_apdu_t apdu;\n\tsc_file_t *file=NULL;\n\tu8 buf[SC_MAX_APDU_BUFFER_SIZE], pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;\n\tunsigned int i;\n\tint r, pathlen;\n\n\tassert(card != NULL && in_path != NULL);\n\tctx=card->ctx;\n\tmemcpy(path, in_path->value, in_path->len);\n\tpathlen = in_path->len;\n\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0x04);\n\t\n\tswitch (in_path->type) {\n\tcase SC_PATH_TYPE_FILE_ID:\n\t\tif (pathlen != 2) return SC_ERROR_INVALID_ARGUMENTS;\n\t\t\/* fall through *\/\n\tcase SC_PATH_TYPE_FROM_CURRENT:\n\t\tapdu.p1 = 9;\n\t\tbreak;\n\tcase SC_PATH_TYPE_DF_NAME:\n\t\tapdu.p1 = 4;\n\t\tbreak;\n\tcase SC_PATH_TYPE_PATH:\n\t\tapdu.p1 = 8;\n\t\tif (pathlen >= 2 && memcmp(path, \"\\x3F\\x00\", 2) == 0) path += 2, pathlen -= 2;\n\t\tif (pathlen == 0) apdu.p1 = 0;\n\t\tbreak;\n\tcase SC_PATH_TYPE_PARENT:\n\t\tapdu.p1 = 3;\n\t\tpathlen = 0;\n\t\tbreak;\n\tdefault:\n\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);\n\t}\n\tif( pathlen == 0 ) apdu.cse = SC_APDU_CASE_2_SHORT;\n\n\tapdu.lc = pathlen;\n\tapdu.data = path;\n\tapdu.datalen = pathlen;\n\n\tif (file_out != NULL) {\n\t\tapdu.resp = buf;\n\t\tapdu.resplen = sizeof(buf);\n\t\tapdu.le = 256;\n\t} else {\n\t\tapdu.resplen = 0;\n\t\tapdu.le = 0; \n\t\tapdu.p2 = 0x0C; \n\t\tapdu.cse = (pathlen == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;\n\t}\n\n\tr = sc_transmit_apdu(card, &apdu);\n\tSC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\tif (r || file_out == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);\n\n\tif (apdu.resplen < 1 || apdu.resp[0] != 0x62){\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"received invalid template %02X\\n\", apdu.resp[0]);\n\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t}\n\n\tfile = sc_file_new();\n\tif (file == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY);\n\t*file_out = file;\n \tfile->path = *in_path;\n \n \tfor(i=2; i+1size=0;\n\t\t\tfor(j=0; jsize = (file->size<<8) | d[j];\n\t\t\tbreak;\n\t\tcase 0x82:\n\t\t\tfile->shareable = (d[0] & 0x40) ? 1 : 0;\n\t\t\tfile->ef_structure = d[0] & 7;\n\t\t\tswitch ((d[0]>>3) & 7) {\n\t\t\tcase 0: file->type = SC_FILE_TYPE_WORKING_EF; break;\n\t\t\tcase 7: file->type = SC_FILE_TYPE_DF; break;\n\t\t\tdefault:\n\t\t\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"invalid file type %02X in file descriptor\\n\", d[0]);\n\t\t\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 0x83:\n \t\t\tfile->id = (d[0]<<8) | d[1];\n \t\t\tbreak;\n \t\tcase 0x84:\n\t\t\tfile->namelen = MIN(sizeof file->name, len);\n\t\t\tmemcpy(file->name, d, file->namelen);\n \t\t\tbreak;\n \t\tcase 0x86:\n \t\t\tsc_file_set_sec_attr(file, d, len); \n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (len>0) sc_file_set_prop_attr(file, d, len); \n\t\t}\n\t}\n\tfile->magic = SC_FILE_MAGIC;\n\n\tparse_sec_attr(card, file, file->sec_attr, file->sec_attr_len);\n\n\treturn 0;\n}\n","target":0,"code_token_length":1109,"total_token_length":1345,"max_tokens_setting":2048} +{"idx":146303,"func":"static void test_http_parse(void) {\n struct mg_str *v;\n struct mg_http_message req;\n\n {\n const char *s = \"GET \/ HTTP\/1.0\\n\\n\";\n ASSERT(mg_http_parse(\"\\b23\", 3, &req) == -1);\n ASSERT(mg_http_parse(\"get\\n\\n\", 5, &req) == -1);\n ASSERT(mg_http_parse(s, strlen(s) - 1, &req) == 0);\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT(req.message.len == strlen(s));\n ASSERT(req.body.len == 0);\n }\n\n {\n const char *s = \"GET \/blah HTTP\/1.0\\r\\nFoo: bar \\r\\n\\r\\n\";\n size_t idx, len = strlen(s);\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) len);\n ASSERT(mg_vcmp(&req.headers[0].name, \"Foo\") == 0);\n ASSERT(mg_vcmp(&req.headers[0].value, \"bar\") == 0);\n ASSERT(req.headers[1].name.len == 0);\n ASSERT(req.headers[1].name.ptr == NULL);\n ASSERT(req.query.len == 0);\n ASSERT(req.message.len == len);\n ASSERT(req.body.len == 0);\n for (idx = 0; idx < len; idx++) ASSERT(mg_http_parse(s, idx, &req) == 0);\n }\n\n {\n static const char *s = \"get b c\\nz : k \\nb: t\\nvvv\\n\\n xx\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s) - 3);\n ASSERT(req.headers[2].name.len == 0);\n ASSERT(mg_vcmp(&req.headers[0].value, \"k\") == 0);\n ASSERT(mg_vcmp(&req.headers[1].value, \"t\") == 0);\n ASSERT(req.body.len == 0);\n }\n\n {\n const char *s = \"a b c\\r\\nContent-Length: 21 \\r\\nb: t\\r\\nvvv\\r\\n\\r\\nabc\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s) - 3);\n ASSERT(req.body.len == 21);\n ASSERT(req.message.len == 21 - 3 + strlen(s));\n ASSERT(mg_http_get_header(&req, \"foo\") == NULL);\n ASSERT((v = mg_http_get_header(&req, \"contENT-Length\")) != NULL);\n ASSERT(mg_vcmp(v, \"21\") == 0);\n ASSERT((v = mg_http_get_header(&req, \"B\")) != NULL);\n ASSERT(mg_vcmp(v, \"t\") == 0);\n }\n\n {\n const char *s = \"GET \/foo?a=b&c=d HTTP\/1.0\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT(mg_vcmp(&req.uri, \"\/foo\") == 0);\n ASSERT(mg_vcmp(&req.query, \"a=b&c=d\") == 0);\n }\n\n {\n const char *s = \"POST \/x HTTP\/1.0\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT(req.body.len == (size_t) ~0);\n }\n\n {\n const char *s = \"WOHOO \/x HTTP\/1.0\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT(req.body.len == 0);\n }\n\n {\n const char *s = \"HTTP\/1.0 200 OK\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT(mg_vcmp(&req.method, \"HTTP\/1.0\") == 0);\n ASSERT(mg_vcmp(&req.uri, \"200\") == 0);\n ASSERT(mg_vcmp(&req.proto, \"OK\") == 0);\n ASSERT(req.body.len == (size_t) ~0);\n }\n\n {\n static const char *s = \"HTTP\/1.0 999 OMGWTFBBQ\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n }\n\n {\n const char *s =\n \"GET \/ HTTP\/1.0\\r\\nhost:127.0.0.1:18888\\r\\nCookie:\\r\\nX-PlayID: \"\n \"45455\\r\\nRange: 0-1 \\r\\n\\r\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT((v = mg_http_get_header(&req, \"Host\")) != NULL);\n ASSERT(mg_vcmp(v, \"127.0.0.1:18888\") == 0);\n ASSERT((v = mg_http_get_header(&req, \"Cookie\")) != NULL);\n ASSERT(v->len == 0);\n ASSERT((v = mg_http_get_header(&req, \"X-PlayID\")) != NULL);\n ASSERT(mg_vcmp(v, \"45455\") == 0);\n ASSERT((v = mg_http_get_header(&req, \"Range\")) != NULL);\n ASSERT(mg_vcmp(v, \"0-1\") == 0);\n }\n\n {\n static const char *s = \"a b c\\na:1\\nb:2\\nc:3\\nd:4\\ne:5\\nf:6\\ng:7\\nh:8\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &req) == (int) strlen(s));\n ASSERT((v = mg_http_get_header(&req, \"e\")) != NULL);\n ASSERT(mg_vcmp(v, \"5\") == 0);\n ASSERT((v = mg_http_get_header(&req, \"h\")) == NULL);\n }\n\n {\n struct mg_connection c;\n struct mg_str s,\n res = mg_str(\"GET \/\\r\\nAuthorization: Basic Zm9vOmJhcg==\\r\\n\\r\\n\");\n memset(&c, 0, sizeof(c));\n mg_printf(&c, \"%s\", \"GET \/\\r\\n\");\n mg_http_bauth(&c, \"foo\", \"bar\");\n mg_printf(&c, \"%s\", \"\\r\\n\");\n s = mg_str_n((char *) c.send.buf, c.send.len);\n ASSERT(mg_strcmp(s, res) == 0);\n mg_iobuf_free(&c.send);\n }\n\n {\n struct mg_http_message hm;\n const char *s = \"GET \/foo?bar=baz HTTP\/1.0\\n\\n \";\n ASSERT(mg_http_parse(s, strlen(s), &hm) == (int) strlen(s) - 1);\n ASSERT(mg_strcmp(hm.uri, mg_str(\"\/foo\")) == 0);\n ASSERT(mg_strcmp(hm.query, mg_str(\"bar=baz\")) == 0);\n }\n\n {\n struct mg_http_message hm;\n const char *s = \"a b c\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &hm) == (int) strlen(s));\n s = \"a b\\nc\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &hm) == (int) strlen(s));\n s = \"a\\nb\\nc\\n\\n\";\n ASSERT(mg_http_parse(s, strlen(s), &hm) < 0);\n }\n}","target":0,"code_token_length":1690,"total_token_length":1926,"max_tokens_setting":2048} +{"idx":142176,"func":"static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)\n{\n\tstruct inode *inode = ordered_extent->inode;\n\tstruct btrfs_root *root = BTRFS_I(inode)->root;\n\tstruct btrfs_trans_handle *trans = NULL;\n\tstruct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;\n\tstruct extent_state *cached_state = NULL;\n\tstruct new_sa_defrag_extent *new = NULL;\n\tint compress_type = 0;\n\tint ret = 0;\n\tu64 logical_len = ordered_extent->len;\n\tbool nolock;\n\tbool truncated = false;\n\n\tnolock = btrfs_is_free_space_inode(inode);\n\n\tif (test_bit(BTRFS_ORDERED_IOERR, &ordered_extent->flags)) {\n\t\tret = -EIO;\n\t\tgoto out;\n\t}\n\n\tbtrfs_free_io_failure_record(inode, ordered_extent->file_offset,\n\t\t\t\t ordered_extent->file_offset +\n\t\t\t\t ordered_extent->len - 1);\n\n\tif (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) {\n\t\ttruncated = true;\n\t\tlogical_len = ordered_extent->truncated_len;\n\t\t\/* Truncated the entire extent, don't bother adding *\/\n\t\tif (!logical_len)\n\t\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {\n\t\tBUG_ON(!list_empty(&ordered_extent->list)); \/* Logic error *\/\n\t\tbtrfs_ordered_update_i_size(inode, 0, ordered_extent);\n\t\tif (nolock)\n\t\t\ttrans = btrfs_join_transaction_nolock(root);\n\t\telse\n\t\t\ttrans = btrfs_join_transaction(root);\n\t\tif (IS_ERR(trans)) {\n\t\t\tret = PTR_ERR(trans);\n\t\t\ttrans = NULL;\n\t\t\tgoto out;\n\t\t}\n\t\ttrans->block_rsv = &root->fs_info->delalloc_block_rsv;\n\t\tret = btrfs_update_inode_fallback(trans, root, inode);\n\t\tif (ret) \/* -ENOMEM or corruption *\/\n\t\t\tbtrfs_abort_transaction(trans, root, ret);\n\t\tgoto out;\n\t}\n\n\tlock_extent_bits(io_tree, ordered_extent->file_offset,\n\t\t\t ordered_extent->file_offset + ordered_extent->len - 1,\n\t\t\t 0, &cached_state);\n\n\tret = test_range_bit(io_tree, ordered_extent->file_offset,\n\t\t\tordered_extent->file_offset + ordered_extent->len - 1,\n\t\t\tEXTENT_DEFRAG, 1, cached_state);\n\tif (ret) {\n\t\tu64 last_snapshot = btrfs_root_last_snapshot(&root->root_item);\n\t\tif (0 && last_snapshot >= BTRFS_I(inode)->generation)\n\t\t\t\/* the inode is shared *\/\n\t\t\tnew = record_old_file_extents(inode, ordered_extent);\n\n\t\tclear_extent_bit(io_tree, ordered_extent->file_offset,\n\t\t\tordered_extent->file_offset + ordered_extent->len - 1,\n\t\t\tEXTENT_DEFRAG, 0, 0, &cached_state, GFP_NOFS);\n\t}\n\n\tif (nolock)\n\t\ttrans = btrfs_join_transaction_nolock(root);\n\telse\n\t\ttrans = btrfs_join_transaction(root);\n\tif (IS_ERR(trans)) {\n\t\tret = PTR_ERR(trans);\n\t\ttrans = NULL;\n\t\tgoto out_unlock;\n\t}\n\n\ttrans->block_rsv = &root->fs_info->delalloc_block_rsv;\n\n\tif (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags))\n\t\tcompress_type = ordered_extent->compress_type;\n\tif (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) {\n\t\tBUG_ON(compress_type);\n\t\tret = btrfs_mark_extent_written(trans, inode,\n\t\t\t\t\t\tordered_extent->file_offset,\n\t\t\t\t\t\tordered_extent->file_offset +\n\t\t\t\t\t\tlogical_len);\n\t} else {\n\t\tBUG_ON(root == root->fs_info->tree_root);\n\t\tret = insert_reserved_file_extent(trans, inode,\n\t\t\t\t\t\tordered_extent->file_offset,\n\t\t\t\t\t\tordered_extent->start,\n\t\t\t\t\t\tordered_extent->disk_len,\n\t\t\t\t\t\tlogical_len, logical_len,\n\t\t\t\t\t\tcompress_type, 0, 0,\n\t\t\t\t\t\tBTRFS_FILE_EXTENT_REG);\n\t\tif (!ret)\n\t\t\tbtrfs_release_delalloc_bytes(root,\n\t\t\t\t\t\t ordered_extent->start,\n\t\t\t\t\t\t ordered_extent->disk_len);\n\t}\n\tunpin_extent_cache(&BTRFS_I(inode)->extent_tree,\n\t\t\t ordered_extent->file_offset, ordered_extent->len,\n\t\t\t trans->transid);\n\tif (ret < 0) {\n\t\tbtrfs_abort_transaction(trans, root, ret);\n\t\tgoto out_unlock;\n\t}\n\n\tadd_pending_csums(trans, inode, ordered_extent->file_offset,\n\t\t\t &ordered_extent->list);\n\n\tbtrfs_ordered_update_i_size(inode, 0, ordered_extent);\n\tret = btrfs_update_inode_fallback(trans, root, inode);\n\tif (ret) { \/* -ENOMEM or corruption *\/\n\t\tbtrfs_abort_transaction(trans, root, ret);\n\t\tgoto out_unlock;\n\t}\n\tret = 0;\nout_unlock:\n\tunlock_extent_cached(io_tree, ordered_extent->file_offset,\n\t\t\t ordered_extent->file_offset +\n\t\t\t ordered_extent->len - 1, &cached_state, GFP_NOFS);\nout:\n\tif (root != root->fs_info->tree_root)\n\t\tbtrfs_delalloc_release_metadata(inode, ordered_extent->len);\n\tif (trans)\n\t\tbtrfs_end_transaction(trans, root);\n\n\tif (ret || truncated) {\n\t\tu64 start, end;\n\n\t\tif (truncated)\n\t\t\tstart = ordered_extent->file_offset + logical_len;\n\t\telse\n\t\t\tstart = ordered_extent->file_offset;\n\t\tend = ordered_extent->file_offset + ordered_extent->len - 1;\n\t\tclear_extent_uptodate(io_tree, start, end, NULL, GFP_NOFS);\n\n\t\t\/* Drop the cache for the part of the extent we didn't write. *\/\n\t\tbtrfs_drop_extent_cache(inode, start, end, 0);\n\n\t\t\/*\n\t\t * If the ordered extent had an IOERR or something else went\n\t\t * wrong we need to return the space for this ordered extent\n\t\t * back to the allocator. We only free the extent in the\n\t\t * truncated case if we didn't write out the extent at all.\n\t\t *\/\n\t\tif ((ret || !logical_len) &&\n\t\t !test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) &&\n\t\t !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags))\n\t\t\tbtrfs_free_reserved_extent(root, ordered_extent->start,\n\t\t\t\t\t\t ordered_extent->disk_len, 1);\n\t}\n\n\n\t\/*\n\t * This needs to be done to make sure anybody waiting knows we are done\n\t * updating everything for this ordered extent.\n\t *\/\n\tbtrfs_remove_ordered_extent(inode, ordered_extent);\n\n\t\/* for snapshot-aware defrag *\/\n\tif (new) {\n\t\tif (ret) {\n\t\t\tfree_sa_defrag_extent(new);\n\t\t\tatomic_dec(&root->fs_info->defrag_running);\n\t\t} else {\n\t\t\trelink_file_extents(new);\n\t\t}\n\t}\n\n\t\/* once for us *\/\n\tbtrfs_put_ordered_extent(ordered_extent);\n\t\/* once for the tree *\/\n\tbtrfs_put_ordered_extent(ordered_extent);\n\n\treturn ret;\n}","target":0,"code_token_length":1504,"total_token_length":1740,"max_tokens_setting":2048} +{"idx":64391,"func":"NO_INLINE bool jspeFunctionDefinitionInternal(JsVar *funcVar, bool expressionOnly) {\n bool forcePretokenise = false;\n\n if (expressionOnly) {\n if (funcVar)\n funcVar->flags = (funcVar->flags & ~JSV_VARTYPEMASK) | JSV_FUNCTION_RETURN;\n } else {\n JSP_MATCH('{');\n #ifndef SAVE_ON_FLASH\n if (lex->tk==LEX_STR) {\n if (!strcmp(jslGetTokenValueAsString(), \"compiled\"))\n jsWarn(\"Function marked with \\\"compiled\\\" uploaded in source form\");\n if (lex->tk==LEX_STR && !strcmp(jslGetTokenValueAsString(), \"ram\")) {\n JSP_ASSERT_MATCH(LEX_STR);\n forcePretokenise = true;\n }\n }\n #endif\n\n \/* If the function starts with return, treat it specially -\n * we don't want to store the 'return' part of it\n *\/\n if (funcVar && lex->tk==LEX_R_RETURN) {\n funcVar->flags = (funcVar->flags & ~JSV_VARTYPEMASK) | JSV_FUNCTION_RETURN;\n JSP_ASSERT_MATCH(LEX_R_RETURN);\n }\n }\n#ifndef ESPR_NO_LINE_NUMBERS\n \/\/ Get the line number (if needed)\n JsVarInt lineNumber = 0;\n if (funcVar && lex->lineNumberOffset && !(forcePretokenise||jsfGetFlag(JSF_PRETOKENISE))) {\n \/\/ jslGetLineNumber is slow, so we only do it if we have debug info\n lineNumber = (JsVarInt)jslGetLineNumber() + (JsVarInt)lex->lineNumberOffset - 1;\n }\n#endif\n \/\/ Get the code - parse it and figure out where it stops\n JslCharPos funcBegin;\n jslSkipWhiteSpace();\n jslCharPosNew(&funcBegin, lex->sourceVar, lex->tokenStart);\n int lastTokenEnd = -1;\n lex->hadThisKeyword = lex->tk == LEX_R_THIS;\n if (!expressionOnly) {\n int brackets = 0;\n while (lex->tk && (brackets || lex->tk != '}')) {\n if (lex->tk == '{') brackets++;\n if (lex->tk == '}') brackets--;\n lastTokenEnd = (int)jsvStringIteratorGetIndex(&lex->it)-1;\n JSP_ASSERT_MATCH(lex->tk);\n }\n \/\/ FIXME: we might be including whitespace after the last token\n } else {\n JsExecFlags oldExec = execInfo.execute;\n execInfo.execute = EXEC_NO;\n jsvUnLock(jspeAssignmentExpression());\n execInfo.execute = oldExec;\n lastTokenEnd = (int)lex->tokenStart;\n }\n bool hadThisKeyword = lex->hadThisKeyword;\n \/\/ Then create var and set (if there was any code!)\n if (funcVar && lastTokenEnd>0) {\n \/\/ code var\n JsVar *funcCodeVar;\n if (!forcePretokenise && jsvIsNativeString(lex->sourceVar)) {\n \/* If we're parsing from a Native String (eg. E.memoryArea, E.setBootCode) then\n use another Native String to load function code straight from flash *\/\n int s = (int)jsvStringIteratorGetIndex(&funcBegin.it) - 1;\n funcCodeVar = jsvNewNativeString(lex->sourceVar->varData.nativeStr.ptr + s, (unsigned int)(lastTokenEnd - s));\n#ifdef SPIFLASH_BASE\n } else if (!forcePretokenise && jsvIsFlashString(lex->sourceVar)) {\n \/* If we're parsing from a Flash String (eg. loaded from Storage on Bangle.js) then\n use another Flash String to load function code straight from flash*\/\n int s = (int)jsvStringIteratorGetIndex(&funcBegin.it) - 1;\n funcCodeVar = jsvNewFlashString(lex->sourceVar->varData.nativeStr.ptr + s, (unsigned int)(lastTokenEnd - s));\n#endif\n } else {\n if (jsfGetFlag(JSF_PRETOKENISE) || forcePretokenise) {\n funcCodeVar = jslNewTokenisedStringFromLexer(&funcBegin, (size_t)lastTokenEnd);\n } else {\n funcCodeVar = jslNewStringFromLexer(&funcBegin, (size_t)lastTokenEnd);\n }\n }\n jsvUnLock2(jsvAddNamedChild(funcVar, funcCodeVar, JSPARSE_FUNCTION_CODE_NAME), funcCodeVar);\n \/\/ scope var\n JsVar *funcScopeVar = jspeiGetScopesAsVar();\n if (funcScopeVar) {\n jsvUnLock2(jsvAddNamedChild(funcVar, funcScopeVar, JSPARSE_FUNCTION_SCOPE_NAME), funcScopeVar);\n }\n#ifndef ESPR_NO_LINE_NUMBERS\n \/\/ If we've got a line number, add a var for it\n if (lineNumber) {\n JsVar *funcLineNumber = jsvNewFromInteger(lineNumber);\n if (funcLineNumber) {\n jsvUnLock2(jsvAddNamedChild(funcVar, funcLineNumber, JSPARSE_FUNCTION_LINENUMBER_NAME), funcLineNumber);\n }\n }\n#endif\n }\n\n jslCharPosFree(&funcBegin);\n if (!expressionOnly) JSP_MATCH('}');\n return hadThisKeyword;\n}","target":0,"code_token_length":1178,"total_token_length":1414,"max_tokens_setting":2048} +{"idx":15194,"func":"int vp9_bigdia_search ( const MACROBLOCK * x , MV * ref_mv , int search_param , int sad_per_bit , int do_init_search , int * sad_list , const vp9_variance_fn_ptr_t * vfp , int use_mvcost , const MV * center_mv , MV * best_mv ) {\n static const int bigdia_num_candidates [ MAX_PATTERN_SCALES ] = {\n 4 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , }\n ;\n static const MV bigdia_candidates [ MAX_PATTERN_SCALES ] [ MAX_PATTERN_CANDIDATES ] = {\n {\n {\n 0 , - 1 }\n , {\n 1 , 0 }\n , {\n 0 , 1 }\n , {\n - 1 , 0 }\n }\n , {\n {\n - 1 , - 1 }\n , {\n 0 , - 2 }\n , {\n 1 , - 1 }\n , {\n 2 , 0 }\n , {\n 1 , 1 }\n , {\n 0 , 2 }\n , {\n - 1 , 1 }\n , {\n - 2 , 0 }\n }\n , {\n {\n - 2 , - 2 }\n , {\n 0 , - 4 }\n , {\n 2 , - 2 }\n , {\n 4 , 0 }\n , {\n 2 , 2 }\n , {\n 0 , 4 }\n , {\n - 2 , 2 }\n , {\n - 4 , 0 }\n }\n , {\n {\n - 4 , - 4 }\n , {\n 0 , - 8 }\n , {\n 4 , - 4 }\n , {\n 8 , 0 }\n , {\n 4 , 4 }\n , {\n 0 , 8 }\n , {\n - 4 , 4 }\n , {\n - 8 , 0 }\n }\n , {\n {\n - 8 , - 8 }\n , {\n 0 , - 16 }\n , {\n 8 , - 8 }\n , {\n 16 , 0 }\n , {\n 8 , 8 }\n , {\n 0 , 16 }\n , {\n - 8 , 8 }\n , {\n - 16 , 0 }\n }\n , {\n {\n - 16 , - 16 }\n , {\n 0 , - 32 }\n , {\n 16 , - 16 }\n , {\n 32 , 0 }\n , {\n 16 , 16 }\n , {\n 0 , 32 }\n , {\n - 16 , 16 }\n , {\n - 32 , 0 }\n }\n , {\n {\n - 32 , - 32 }\n , {\n 0 , - 64 }\n , {\n 32 , - 32 }\n , {\n 64 , 0 }\n , {\n 32 , 32 }\n , {\n 0 , 64 }\n , {\n - 32 , 32 }\n , {\n - 64 , 0 }\n }\n , {\n {\n - 64 , - 64 }\n , {\n 0 , - 128 }\n , {\n 64 , - 64 }\n , {\n 128 , 0 }\n , {\n 64 , 64 }\n , {\n 0 , 128 }\n , {\n - 64 , 64 }\n , {\n - 128 , 0 }\n }\n , {\n {\n - 128 , - 128 }\n , {\n 0 , - 256 }\n , {\n 128 , - 128 }\n , {\n 256 , 0 }\n , {\n 128 , 128 }\n , {\n 0 , 256 }\n , {\n - 128 , 128 }\n , {\n - 256 , 0 }\n }\n , {\n {\n - 256 , - 256 }\n , {\n 0 , - 512 }\n , {\n 256 , - 256 }\n , {\n 512 , 0 }\n , {\n 256 , 256 }\n , {\n 0 , 512 }\n , {\n - 256 , 256 }\n , {\n - 512 , 0 }\n }\n , {\n {\n - 512 , - 512 }\n , {\n 0 , - 1024 }\n , {\n 512 , - 512 }\n , {\n 1024 , 0 }\n , {\n 512 , 512 }\n , {\n 0 , 1024 }\n , {\n - 512 , 512 }\n , {\n - 1024 , 0 }\n }\n , }\n ;\n return vp9_pattern_search_sad ( x , ref_mv , search_param , sad_per_bit , do_init_search , sad_list , vfp , use_mvcost , center_mv , best_mv , bigdia_num_candidates , bigdia_candidates ) ;\n }","target":0,"code_token_length":1071,"total_token_length":1307,"max_tokens_setting":2048} +{"idx":63415,"func":"static int load_module(struct load_info *info, const char __user *uargs,\n\t\t int flags)\n{\n\tstruct module *mod;\n\tlong err = 0;\n\tchar *after_dashes;\n\n\t\/*\n\t * Do the signature check (if any) first. All that\n\t * the signature check needs is info->len, it does\n\t * not need any of the section info. That can be\n\t * set up later. This will minimize the chances\n\t * of a corrupt module causing problems before\n\t * we even get to the signature check.\n\t *\n\t * The check will also adjust info->len by stripping\n\t * off the sig length at the end of the module, making\n\t * checks against info->len more correct.\n\t *\/\n\terr = module_sig_check(info, flags);\n\tif (err)\n\t\tgoto free_copy;\n\n\t\/*\n\t * Do basic sanity checks against the ELF header and\n\t * sections.\n\t *\/\n\terr = elf_validity_check(info);\n\tif (err) {\n\t\tpr_err(\"Module has invalid ELF structures\\n\");\n\t\tgoto free_copy;\n\t}\n\n\t\/*\n\t * Everything checks out, so set up the section info\n\t * in the info structure.\n\t *\/\n\terr = setup_load_info(info, flags);\n\tif (err)\n\t\tgoto free_copy;\n\n\t\/*\n\t * Now that we know we have the correct module name, check\n\t * if it's blacklisted.\n\t *\/\n\tif (blacklisted(info->name)) {\n\t\terr = -EPERM;\n\t\tpr_err(\"Module %s is blacklisted\\n\", info->name);\n\t\tgoto free_copy;\n\t}\n\n\terr = rewrite_section_headers(info, flags);\n\tif (err)\n\t\tgoto free_copy;\n\n\t\/* Check module struct version now, before we try to use module. *\/\n\tif (!check_modstruct_version(info, info->mod)) {\n\t\terr = -ENOEXEC;\n\t\tgoto free_copy;\n\t}\n\n\t\/* Figure out module layout, and allocate all the memory. *\/\n\tmod = layout_and_allocate(info, flags);\n\tif (IS_ERR(mod)) {\n\t\terr = PTR_ERR(mod);\n\t\tgoto free_copy;\n\t}\n\n\taudit_log_kern_module(mod->name);\n\n\t\/* Reserve our place in the list. *\/\n\terr = add_unformed_module(mod);\n\tif (err)\n\t\tgoto free_module;\n\n#ifdef CONFIG_MODULE_SIG\n\tmod->sig_ok = info->sig_ok;\n\tif (!mod->sig_ok) {\n\t\tpr_notice_once(\"%s: module verification failed: signature \"\n\t\t\t \"and\/or required key missing - tainting \"\n\t\t\t \"kernel\\n\", mod->name);\n\t\tadd_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);\n\t}\n#endif\n\n\t\/* To avoid stressing percpu allocator, do this once we're unique. *\/\n\terr = percpu_modalloc(mod, info);\n\tif (err)\n\t\tgoto unlink_mod;\n\n\t\/* Now module is in final location, initialize linked lists, etc. *\/\n\terr = module_unload_init(mod);\n\tif (err)\n\t\tgoto unlink_mod;\n\n\tinit_param_lock(mod);\n\n\t\/*\n\t * Now we've got everything in the final locations, we can\n\t * find optional sections.\n\t *\/\n\terr = find_module_sections(mod, info);\n\tif (err)\n\t\tgoto free_unload;\n\n\terr = check_module_license_and_versions(mod);\n\tif (err)\n\t\tgoto free_unload;\n\n\t\/* Set up MODINFO_ATTR fields *\/\n\tsetup_modinfo(mod, info);\n\n\t\/* Fix up syms, so that st_value is a pointer to location. *\/\n\terr = simplify_symbols(mod, info);\n\tif (err < 0)\n\t\tgoto free_modinfo;\n\n\terr = apply_relocations(mod, info);\n\tif (err < 0)\n\t\tgoto free_modinfo;\n\n\terr = post_relocation(mod, info);\n\tif (err < 0)\n\t\tgoto free_modinfo;\n\n\tflush_module_icache(mod);\n\n\t\/* Setup CFI for the module. *\/\n\tcfi_init(mod);\n\n\t\/* Now copy in args *\/\n\tmod->args = strndup_user(uargs, ~0UL >> 1);\n\tif (IS_ERR(mod->args)) {\n\t\terr = PTR_ERR(mod->args);\n\t\tgoto free_arch_cleanup;\n\t}\n\n\tdynamic_debug_setup(mod, info->debug, info->num_debug);\n\n\t\/* Ftrace init must be called in the MODULE_STATE_UNFORMED state *\/\n\tftrace_module_init(mod);\n\n\t\/* Finally it's fully formed, ready to start executing. *\/\n\terr = complete_formation(mod, info);\n\tif (err)\n\t\tgoto ddebug_cleanup;\n\n\terr = prepare_coming_module(mod);\n\tif (err)\n\t\tgoto bug_cleanup;\n\n\t\/* Module is ready to execute: parsing args may do that. *\/\n\tafter_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp,\n\t\t\t\t -32768, 32767, mod,\n\t\t\t\t unknown_module_param_cb);\n\tif (IS_ERR(after_dashes)) {\n\t\terr = PTR_ERR(after_dashes);\n\t\tgoto coming_cleanup;\n\t} else if (after_dashes) {\n\t\tpr_warn(\"%s: parameters '%s' after `--' ignored\\n\",\n\t\t mod->name, after_dashes);\n\t}\n\n\t\/* Link in to sysfs. *\/\n\terr = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp);\n\tif (err < 0)\n\t\tgoto coming_cleanup;\n\n\tif (is_livepatch_module(mod)) {\n\t\terr = copy_module_elf(mod, info);\n\t\tif (err < 0)\n\t\t\tgoto sysfs_cleanup;\n\t}\n\n\t\/* Get rid of temporary copy. *\/\n\tfree_copy(info);\n\n\t\/* Done! *\/\n\ttrace_module_load(mod);\n\n\treturn do_init_module(mod);\n\n sysfs_cleanup:\n\tmod_sysfs_teardown(mod);\n coming_cleanup:\n\tmod->state = MODULE_STATE_GOING;\n\tdestroy_params(mod->kp, mod->num_kp);\n\tblocking_notifier_call_chain(&module_notify_list,\n\t\t\t\t MODULE_STATE_GOING, mod);\n\tklp_module_going(mod);\n bug_cleanup:\n\tmod->state = MODULE_STATE_GOING;\n\t\/* module_bug_cleanup needs module_mutex protection *\/\n\tmutex_lock(&module_mutex);\n\tmodule_bug_cleanup(mod);\n\tmutex_unlock(&module_mutex);\n\n ddebug_cleanup:\n\tftrace_release_mod(mod);\n\tdynamic_debug_remove(mod, info->debug);\n\tsynchronize_rcu();\n\tkfree(mod->args);\n free_arch_cleanup:\n\tcfi_cleanup(mod);\n\tmodule_arch_cleanup(mod);\n free_modinfo:\n\tfree_modinfo(mod);\n free_unload:\n\tmodule_unload_free(mod);\n unlink_mod:\n\tmutex_lock(&module_mutex);\n\t\/* Unlink carefully: kallsyms could be walking list. *\/\n\tlist_del_rcu(&mod->list);\n\tmod_tree_remove(mod);\n\twake_up_all(&module_wq);\n\t\/* Wait for RCU-sched synchronizing before releasing mod->list. *\/\n\tsynchronize_rcu();\n\tmutex_unlock(&module_mutex);\n free_module:\n\t\/* Free lock-classes; relies on the preceding sync_rcu() *\/\n\tlockdep_free_key_range(mod->core_layout.base, mod->core_layout.size);\n\n\tmodule_deallocate(mod, info);\n free_copy:\n\tfree_copy(info);\n\treturn err;\n}","target":0,"code_token_length":1477,"total_token_length":1713,"max_tokens_setting":2048} +{"idx":426648,"func":"static ssize_t process_output_ssl( pn_transport_t *transport, unsigned int layer, char *buffer, size_t max_len)\n{\n pni_ssl_t *ssl = transport->ssl;\n if (!ssl) return PN_EOS;\n if (ssl->ssl == NULL && init_ssl_socket(transport, ssl)) return PN_EOS;\n\n ssize_t written = 0;\n bool work_pending;\n\n do {\n work_pending = false;\n ERR_clear_error();\n\n \/\/ first, get any pending application output, if possible\n\n if (!ssl->app_output_closed && ssl->out_count < ssl->out_size) {\n ssize_t app_bytes = transport->io_layers[layer+1]->process_output(transport, layer+1, &ssl->outbuf[ssl->out_count], ssl->out_size - ssl->out_count);\n if (app_bytes > 0) {\n ssl->out_count += app_bytes;\n work_pending = true;\n ssl_log(transport, \"Gathered %d bytes from app to send to peer\", app_bytes );\n } else {\n if (app_bytes < 0) {\n ssl_log(transport, \"Application layer closed its output, error=%d (%d bytes pending send)\",\n (int) app_bytes, (int) ssl->out_count);\n ssl->app_output_closed = app_bytes;\n }\n }\n }\n\n \/\/ now push any pending app data into the socket\n\n if (!ssl->ssl_closed) {\n char *data = ssl->outbuf;\n if (ssl->out_count > 0) {\n int wrote = BIO_write( ssl->bio_ssl, data, ssl->out_count );\n if (wrote > 0) {\n data += wrote;\n ssl->out_count -= wrote;\n work_pending = true;\n ssl_log( transport, \"Wrote %d bytes from app to socket\", wrote );\n } else {\n if (!BIO_should_retry(ssl->bio_ssl)) {\n int reason = SSL_get_error( ssl->ssl, wrote );\n switch (reason) {\n case SSL_ERROR_ZERO_RETURN:\n \/\/ SSL closed cleanly\n ssl_log(transport, \"SSL connection has closed\");\n start_ssl_shutdown(transport); \/\/ KAG: not sure - this may not be necessary\n ssl->out_count = 0; \/\/ can no longer write to socket, so erase app output data\n ssl->ssl_closed = true;\n break;\n default:\n \/\/ unexpected error\n return (ssize_t)ssl_failed(transport);\n }\n } else {\n if (BIO_should_read( ssl->bio_ssl )) {\n ssl->read_blocked = true;\n ssl_log(transport, \"Detected read-blocked\");\n }\n if (BIO_should_write( ssl->bio_ssl )) {\n ssl->write_blocked = true;\n ssl_log(transport, \"Detected write-blocked\");\n }\n }\n }\n }\n\n if (ssl->out_count == 0) {\n if (ssl->app_input_closed && ssl->app_output_closed) {\n \/\/ application is done sending\/receiving data, and all buffered output data has\n \/\/ been written to the SSL socket\n start_ssl_shutdown(transport);\n }\n } else if (data != ssl->outbuf) {\n memmove( ssl->outbuf, data, ssl->out_count );\n }\n }\n\n \/\/ read from the network bio as much as possible, filling the buffer\n if (max_len) {\n int available = BIO_read( ssl->bio_net_io, buffer, max_len );\n if (available > 0) {\n max_len -= available;\n buffer += available;\n written += available;\n ssl->write_blocked = false;\n work_pending = work_pending || max_len > 0;\n ssl_log(transport, \"Read %d bytes from BIO Layer\", available );\n }\n }\n\n } while (work_pending);\n\n \/\/_log(ssl, \"written=%d ssl_closed=%d in_count=%d app_input_closed=%d app_output_closed=%d bio_pend=%d\",\n \/\/ written, ssl->ssl_closed, ssl->in_count, ssl->app_input_closed, ssl->app_output_closed, BIO_pending(ssl->bio_net_io) );\n\n \/\/ PROTON-82: close the output side as soon as we've sent the SSL close_notify.\n \/\/ We're not requiring the response, as some implementations never reply.\n \/\/ ----\n \/\/ Once no more data is available \"below\" the SSL socket, tell the transport we are\n \/\/ done.\n \/\/if (written == 0 && ssl->ssl_closed && BIO_pending(ssl->bio_net_io) == 0) {\n \/\/ written = ssl->app_output_closed ? ssl->app_output_closed : PN_EOS;\n \/\/}\n if (written == 0 && (SSL_get_shutdown(ssl->ssl) & SSL_SENT_SHUTDOWN) && BIO_pending(ssl->bio_net_io) == 0) {\n written = ssl->app_output_closed ? ssl->app_output_closed : PN_EOS;\n if (transport->io_layers[layer]==&ssl_input_closed_layer) {\n transport->io_layers[layer] = &ssl_closed_layer;\n } else {\n transport->io_layers[layer] = &ssl_output_closed_layer;\n }\n }\n ssl_log(transport, \"process_output_ssl() returning %d\", (int) written);\n return written;\n}","target":0,"code_token_length":1156,"total_token_length":1392,"max_tokens_setting":2048} +{"idx":347093,"func":"QPDFObjectHandle::parseInternal(PointerHolder input,\n std::string const& object_description,\n QPDFTokenizer& tokenizer, bool& empty,\n StringDecrypter* decrypter, QPDF* context,\n bool in_array, bool in_dictionary,\n bool content_stream)\n{\n empty = false;\n if (in_dictionary && in_array)\n {\n\t\/\/ Although dictionaries and arrays arbitrarily nest, these\n\t\/\/ variables indicate what is at the top of the stack right\n\t\/\/ now, so they can, by definition, never both be true.\n\tthrow std::logic_error(\n\t \"INTERNAL ERROR: parseInternal: in_dict && in_array\");\n }\n\n QPDFObjectHandle object;\n\n qpdf_offset_t offset = input->tell();\n std::vector olist;\n bool done = false;\n while (! done)\n {\n\tobject = QPDFObjectHandle();\n\n\tQPDFTokenizer::Token token =\n tokenizer.readToken(input, object_description);\n\n\tswitch (token.getType())\n\t{\n case QPDFTokenizer::tt_eof:\n if (content_stream)\n {\n \/\/ Return uninitialized object to indicate EOF\n return object;\n }\n else\n {\n \/\/ When not in content stream mode, EOF is tt_bad and\n \/\/ throws an exception before we get here.\n throw std::logic_error(\n \"EOF received while not in content stream mode\");\n }\n break;\n\n\t case QPDFTokenizer::tt_brace_open:\n\t case QPDFTokenizer::tt_brace_close:\n\t \/\/ Don't know what to do with these for now\n\t QTC::TC(\"qpdf\", \"QPDFObjectHandle bad brace\");\n\t throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),\n\t\t\t object_description,\n\t\t\t input->getLastOffset(),\n\t\t\t \"unexpected brace token\");\n\t break;\n\n\t case QPDFTokenizer::tt_array_close:\n\t if (in_array)\n\t {\n\t\tdone = true;\n\t }\n\t else\n\t {\n\t\tQTC::TC(\"qpdf\", \"QPDFObjectHandle bad array close\");\n\t\tthrow QPDFExc(qpdf_e_damaged_pdf, input->getName(),\n\t\t\t object_description,\n\t\t\t input->getLastOffset(),\n\t\t\t \"unexpected array close token\");\n\t }\n\t break;\n\n\t case QPDFTokenizer::tt_dict_close:\n\t if (in_dictionary)\n\t {\n\t\tdone = true;\n\t }\n\t else\n\t {\n\t\tQTC::TC(\"qpdf\", \"QPDFObjectHandle bad dictionary close\");\n\t\tthrow QPDFExc(qpdf_e_damaged_pdf, input->getName(),\n\t\t\t object_description,\n\t\t\t input->getLastOffset(),\n\t\t\t \"unexpected dictionary close token\");\n\t }\n\t break;\n\n\t case QPDFTokenizer::tt_array_open:\n\t object = parseInternal(\n\t\tinput, object_description, tokenizer, empty,\n decrypter, context, true, false, content_stream);\n\t break;\n\n\t case QPDFTokenizer::tt_dict_open:\n\t object = parseInternal(\n\t\tinput, object_description, tokenizer, empty,\n decrypter, context, false, true, content_stream);\n\t break;\n\n\t case QPDFTokenizer::tt_bool:\n\t object = newBool((token.getValue() == \"true\"));\n\t break;\n\n\t case QPDFTokenizer::tt_null:\n\t object = newNull();\n\t break;\n\n\t case QPDFTokenizer::tt_integer:\n\t object = newInteger(QUtil::string_to_ll(token.getValue().c_str()));\n\t break;\n\n\t case QPDFTokenizer::tt_real:\n\t object = newReal(token.getValue());\n\t break;\n\n\t case QPDFTokenizer::tt_name:\n\t object = newName(token.getValue());\n\t break;\n\n\t case QPDFTokenizer::tt_word:\n\t {\n\t\tstd::string const& value = token.getValue();\n\t\tif ((value == \"R\") && (in_array || in_dictionary) &&\n\t\t (olist.size() >= 2) &&\n (! olist.at(olist.size() - 1).isIndirect()) &&\n\t\t (olist.at(olist.size() - 1).isInteger()) &&\n (! olist.at(olist.size() - 2).isIndirect()) &&\n\t\t (olist.at(olist.size() - 2).isInteger()))\n\t\t{\n if (context == 0)\n {\n QTC::TC(\"qpdf\", \"QPDFObjectHandle indirect without context\");\n throw std::logic_error(\n \"QPDFObjectHandle::parse called without context\"\n \" on an object with indirect references\");\n }\n\t\t \/\/ Try to resolve indirect objects\n\t\t object = newIndirect(\n\t\t\tcontext,\n\t\t\tolist.at(olist.size() - 2).getIntValue(),\n\t\t\tolist.at(olist.size() - 1).getIntValue());\n\t\t olist.pop_back();\n\t\t olist.pop_back();\n\t\t}\n\t\telse if ((value == \"endobj\") &&\n\t\t\t (! (in_array || in_dictionary)))\n\t\t{\n\t\t \/\/ We just saw endobj without having read\n\t\t \/\/ anything. Treat this as a null and do not move\n\t\t \/\/ the input source's offset.\n\t\t object = newNull();\n\t\t input->seek(input->getLastOffset(), SEEK_SET);\n empty = true;\n\t\t}\n\t\telse if (content_stream)\n {\n object = QPDFObjectHandle::newOperator(token.getValue());\n }\n\t\telse\n\t\t{\n\t\t throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),\n\t\t\t\t object_description,\n\t\t\t\t input->getLastOffset(),\n\t\t\t\t \"unknown token while reading object (\" +\n\t\t\t\t value + \")\");\n\t\t}\n\t }\n\t break;\n\n\t case QPDFTokenizer::tt_string:\n\t {\n\t\tstd::string val = token.getValue();\n if (decrypter)\n {\n decrypter->decryptString(val);\n }\n\t\tobject = QPDFObjectHandle::newString(val);\n\t }\n\n\t break;\n\n\t default:\n\t throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),\n\t\t\t object_description,\n\t\t\t input->getLastOffset(),\n\t\t\t \"unknown token type while reading object\");\n\t break;\n\t}\n\n\tif (in_dictionary || in_array)\n\t{\n\t if (! done)\n\t {\n\t\tolist.push_back(object);\n\t }\n\t}\n\telse if (! object.isInitialized())\n\t{\n\t throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),\n\t\t\t object_description,\n\t\t\t input->getLastOffset(),\n\t\t\t \"parse error while reading object\");\n\t}\n\telse\n\t{\n\t done = true;\n\t}\n }\n\n if (in_array)\n {\n\tobject = newArray(olist);\n }\n else if (in_dictionary)\n {\n\t\/\/ Convert list to map. Alternating elements are keys.\n\tstd::map dict;\n\tif (olist.size() % 2)\n\t{\n\t QTC::TC(\"qpdf\", \"QPDFObjectHandle dictionary odd number of elements\");\n\t throw QPDFExc(\n\t\tqpdf_e_damaged_pdf, input->getName(),\n\t\tobject_description, input->getLastOffset(),\n\t\t\"dictionary ending here has an odd number of elements\");\n\t}\n\tfor (unsigned int i = 0; i < olist.size(); i += 2)\n\t{\n\t QPDFObjectHandle key_obj = olist.at(i);\n\t QPDFObjectHandle val = olist.at(i + 1);\n\t if (! key_obj.isName())\n\t {\n\t\tthrow QPDFExc(\n\t\t qpdf_e_damaged_pdf,\n\t\t input->getName(), object_description, offset,\n\t\t std::string(\"dictionary key not name (\") +\n\t\t key_obj.unparse() + \")\");\n\t }\n\t dict[key_obj.getName()] = val;\n\t}\n\tobject = newDictionary(dict);\n }\n\n return object;\n}","target":1,"code_token_length":1593,"total_token_length":1829,"max_tokens_setting":2048} +{"idx":135089,"func":"static Image *ReadGROUP4Image(const ImageInfo *image_info,\n ExceptionInfo *exception)\n{\n char\n filename[MaxTextExtent];\n\n FILE\n *file;\n\n Image\n *image;\n\n ImageInfo\n *read_info;\n\n int\n c,\n unique_file;\n\n MagickBooleanType\n status;\n\n size_t\n length;\n\n ssize_t\n offset,\n strip_offset;\n\n \/*\n Open image file.\n *\/\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickCoreSignature);\n if (image_info->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n image=AcquireImage(image_info);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n \/*\n Write raw CCITT Group 4 wrapped as a TIFF image file.\n *\/\n file=(FILE *) NULL;\n unique_file=AcquireUniqueFileResource(filename);\n if (unique_file != -1)\n file=fdopen(unique_file,\"wb\");\n if ((unique_file == -1) || (file == (FILE *) NULL))\n ThrowImageException(FileOpenError,\"UnableToCreateTemporaryFile\");\n length=fwrite(\"\\111\\111\\052\\000\\010\\000\\000\\000\\016\\000\",1,10,file);\n if (length != 10)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n length=fwrite(\"\\376\\000\\003\\000\\001\\000\\000\\000\\000\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\000\\001\\004\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image->columns);\n length=fwrite(\"\\001\\001\\004\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image->rows);\n length=fwrite(\"\\002\\001\\003\\000\\001\\000\\000\\000\\001\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\003\\001\\003\\000\\001\\000\\000\\000\\004\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\006\\001\\003\\000\\001\\000\\000\\000\\000\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\021\\001\\003\\000\\001\\000\\000\\000\",1,8,file);\n strip_offset=10+(12*14)+4+8;\n length=WriteLSBLong(file,(unsigned int) strip_offset);\n length=fwrite(\"\\022\\001\\003\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image_info->orientation);\n length=fwrite(\"\\025\\001\\003\\000\\001\\000\\000\\000\\001\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\026\\001\\004\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) image->rows);\n length=fwrite(\"\\027\\001\\004\\000\\001\\000\\000\\000\\000\\000\\000\\000\",1,12,file);\n offset=(ssize_t) ftell(file)-4;\n length=fwrite(\"\\032\\001\\005\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) (strip_offset-8));\n length=fwrite(\"\\033\\001\\005\\000\\001\\000\\000\\000\",1,8,file);\n length=WriteLSBLong(file,(unsigned int) (strip_offset-8));\n length=fwrite(\"\\050\\001\\003\\000\\001\\000\\000\\000\\002\\000\\000\\000\",1,12,file);\n length=fwrite(\"\\000\\000\\000\\000\",1,4,file);\n length=WriteLSBLong(file,(unsigned int) image->x_resolution);\n length=WriteLSBLong(file,1);\n status=MagickTrue;\n for (length=0; (c=ReadBlobByte(image)) != EOF; length++)\n if (fputc(c,file) != c)\n status=MagickFalse;\n offset=(ssize_t) fseek(file,(ssize_t) offset,SEEK_SET);\n length=WriteLSBLong(file,(unsigned int) length);\n if (ferror(file) != 0)\n {\n (void) fclose(file);\n ThrowImageException(FileOpenError,\"UnableToCreateTemporaryFile\");\n }\n (void) fclose(file);\n (void) CloseBlob(image);\n image=DestroyImage(image);\n \/*\n Read TIFF image.\n *\/\n read_info=CloneImageInfo((ImageInfo *) NULL);\n (void) FormatLocaleString(read_info->filename,MaxTextExtent,\"%s\",filename);\n image=ReadTIFFImage(read_info,exception);\n read_info=DestroyImageInfo(read_info);\n if (image != (Image *) NULL)\n {\n (void) CopyMagickString(image->filename,image_info->filename,\n MaxTextExtent);\n (void) CopyMagickString(image->magick_filename,image_info->filename,\n MaxTextExtent);\n (void) CopyMagickString(image->magick,\"GROUP4\",MaxTextExtent);\n }\n (void) RelinquishUniqueFileResource(filename);\n if (status == MagickFalse)\n image=DestroyImage(image);\n return(image);\n}","target":0,"code_token_length":1608,"total_token_length":1844,"max_tokens_setting":2048} +{"idx":378384,"func":"sdap_initgr_store_user_memberships(struct sdap_initgr_nested_state *state)\n{\n errno_t ret;\n int tret;\n const char *orig_dn;\n\n char **sysdb_parent_name_list = NULL;\n char **ldap_parent_name_list = NULL;\n\n int nparents;\n struct sysdb_attrs **ldap_parentlist;\n struct ldb_message_element *el;\n int i, mi;\n char **add_groups;\n char **del_groups;\n TALLOC_CTX *tmp_ctx;\n bool in_transaction = false;\n\n tmp_ctx = talloc_new(NULL);\n if (!tmp_ctx) {\n ret = ENOMEM;\n goto done;\n }\n\n \/* Get direct LDAP parents *\/\n ret = sysdb_attrs_get_string(state->user, SYSDB_ORIG_DN, &orig_dn);\n if (ret != EOK) {\n DEBUG(SSSDBG_OP_FAILURE, \"The user has no original DN\\n\");\n goto done;\n }\n\n ldap_parentlist = talloc_zero_array(tmp_ctx, struct sysdb_attrs *,\n state->groups_cur + 1);\n if (!ldap_parentlist) {\n ret = ENOMEM;\n goto done;\n }\n nparents = 0;\n\n for (i=0; i < state->groups_cur ; i++) {\n ret = sysdb_attrs_get_el(state->groups[i], SYSDB_MEMBER, &el);\n if (ret) {\n DEBUG(SSSDBG_MINOR_FAILURE,\n \"A group with no members during initgroups?\\n\");\n goto done;\n }\n\n for (mi = 0; mi < el->num_values; mi++) {\n if (strcasecmp((const char *) el->values[mi].data, orig_dn) != 0) {\n continue;\n }\n\n ldap_parentlist[nparents] = state->groups[i];\n nparents++;\n }\n }\n\n DEBUG(SSSDBG_TRACE_LIBS,\n \"The user %s is a direct member of %d LDAP groups\\n\",\n state->username, nparents);\n\n if (nparents == 0) {\n ldap_parent_name_list = NULL;\n } else {\n ret = sysdb_attrs_primary_name_list(state->sysdb, tmp_ctx,\n ldap_parentlist,\n nparents,\n state->opts->group_map[SDAP_AT_GROUP_NAME].name,\n &ldap_parent_name_list);\n if (ret != EOK) {\n DEBUG(SSSDBG_CRIT_FAILURE,\n \"sysdb_attrs_primary_name_list failed [%d]: %s\\n\",\n ret, strerror(ret));\n goto done;\n }\n }\n\n ret = sysdb_get_direct_parents(tmp_ctx, state->sysdb, state->dom,\n SYSDB_MEMBER_USER,\n state->username, &sysdb_parent_name_list);\n if (ret) {\n DEBUG(SSSDBG_CRIT_FAILURE,\n \"Could not get direct sysdb parents for %s: %d [%s]\\n\",\n state->username, ret, strerror(ret));\n goto done;\n }\n\n ret = diff_string_lists(tmp_ctx,\n ldap_parent_name_list, sysdb_parent_name_list,\n &add_groups, &del_groups, NULL);\n if (ret != EOK) {\n goto done;\n }\n\n ret = sysdb_transaction_start(state->sysdb);\n if (ret != EOK) {\n DEBUG(SSSDBG_CRIT_FAILURE, \"Failed to start transaction\\n\");\n goto done;\n }\n in_transaction = true;\n\n DEBUG(SSSDBG_TRACE_INTERNAL,\n \"Updating memberships for %s\\n\", state->username);\n ret = sysdb_update_members(state->sysdb, state->dom,\n state->username, SYSDB_MEMBER_USER,\n (const char *const *) add_groups,\n (const char *const *) del_groups);\n if (ret != EOK) {\n DEBUG(SSSDBG_CRIT_FAILURE,\n \"Could not update sysdb memberships for %s: %d [%s]\\n\",\n state->username, ret, strerror(ret));\n goto done;\n }\n\n ret = sysdb_transaction_commit(state->sysdb);\n if (ret != EOK) {\n goto done;\n }\n in_transaction = false;\n\n ret = EOK;\ndone:\n if (in_transaction) {\n tret = sysdb_transaction_cancel(state->sysdb);\n if (tret != EOK) {\n DEBUG(SSSDBG_CRIT_FAILURE, \"Failed to cancel transaction\\n\");\n }\n }\n talloc_zfree(tmp_ctx);\n return ret;\n}","target":0,"code_token_length":961,"total_token_length":1197,"max_tokens_setting":2048} +{"idx":3290,"func":"static plist_t parse_bin_node(struct bplist_data *bplist, const char** object)\n{\n uint16_t type = 0;\n uint64_t size = 0;\n\n if (!object)\n return NULL;\n\n type = (**object) & BPLIST_MASK;\n size = (**object) & BPLIST_FILL;\n (*object)++;\n\n if (size == BPLIST_FILL) {\n switch (type) {\n case BPLIST_DATA:\n case BPLIST_STRING:\n case BPLIST_UNICODE:\n case BPLIST_ARRAY:\n case BPLIST_SET:\n case BPLIST_DICT:\n {\n uint16_t next_size = **object & BPLIST_FILL;\n if ((**object & BPLIST_MASK) != BPLIST_UINT) {\n PLIST_BIN_ERR(\"%s: invalid size node type for node type 0x%02x: found 0x%02x, expected 0x%02x\\n\", __func__, type, **object & BPLIST_MASK, BPLIST_UINT);\n return NULL;\n }\n (*object)++;\n next_size = 1 << next_size;\n if (*object + next_size > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: size node data bytes for node type 0x%02x point outside of valid range\\n\", __func__, type);\n return NULL;\n }\n size = UINT_TO_HOST(*object, next_size);\n (*object) += next_size;\n break;\n }\n default:\n break;\n }\n }\n\n switch (type)\n {\n\n case BPLIST_NULL:\n switch (size)\n {\n\n case BPLIST_TRUE:\n {\n plist_data_t data = plist_new_plist_data();\n data->type = PLIST_BOOLEAN;\n data->boolval = TRUE;\n data->length = 1;\n return node_create(NULL, data);\n }\n\n case BPLIST_FALSE:\n {\n plist_data_t data = plist_new_plist_data();\n data->type = PLIST_BOOLEAN;\n data->boolval = FALSE;\n data->length = 1;\n return node_create(NULL, data);\n }\n\n case BPLIST_NULL:\n default:\n return NULL;\n }\n\n case BPLIST_UINT:\n if (*object + (uint64_t)(1 << size) > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_UINT data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_uint_node(object, size);\n\n case BPLIST_REAL:\n if (*object + (uint64_t)(1 << size) > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_REAL data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_real_node(object, size);\n\n case BPLIST_DATE:\n if (3 != size) {\n PLIST_BIN_ERR(\"%s: invalid data size for BPLIST_DATE node\\n\", __func__);\n return NULL;\n }\n if (*object + (uint64_t)(1 << size) > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_DATE data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_date_node(object, size);\n\n case BPLIST_DATA:\n if (*object + size > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_DATA data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_data_node(object, size);\n\n case BPLIST_STRING:\n if (*object + size > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_STRING data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_string_node(object, size);\n\n case BPLIST_UNICODE:\n if (size*2 < size) {\n PLIST_BIN_ERR(\"%s: Integer overflow when calculating BPLIST_UNICODE data size.\\n\", __func__);\n return NULL;\n }\n if (*object + size*2 > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_UNICODE data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_unicode_node(object, size);\n\n case BPLIST_SET:\n case BPLIST_ARRAY:\n if (*object + size > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_ARRAY data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_array_node(bplist, object, size);\n\n case BPLIST_UID:\n if (*object + size+1 > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_UID data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_uid_node(object, size);\n\n case BPLIST_DICT:\n if (*object + size > bplist->offset_table) {\n PLIST_BIN_ERR(\"%s: BPLIST_REAL data bytes point outside of valid range\\n\", __func__);\n return NULL;\n }\n return parse_dict_node(bplist, object, size);\n\n default:\n PLIST_BIN_ERR(\"%s: unexpected node type 0x%02x\\n\", __func__, type);\n return NULL;\n }\n return NULL;\n}","target":1,"code_token_length":1191,"total_token_length":1427,"max_tokens_setting":2048} +{"idx":499292,"func":"static int acl_check_spn(TALLOC_CTX *mem_ctx,\n\t\t\t struct ldb_module *module,\n\t\t\t struct ldb_request *req,\n\t\t\t const struct ldb_message_element *el,\n\t\t\t struct security_descriptor *sd,\n\t\t\t struct dom_sid *sid,\n\t\t\t const struct dsdb_attribute *attr,\n\t\t\t const struct dsdb_class *objectclass)\n{\n\tint ret;\n\tunsigned int i;\n\tTALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);\n\tstruct ldb_context *ldb = ldb_module_get_ctx(module);\n\tstruct ldb_result *acl_res;\n\tstruct ldb_result *netbios_res;\n\tstruct ldb_dn *partitions_dn = samdb_partitions_dn(ldb, tmp_ctx);\n\tuint32_t userAccountControl;\n\tconst char *samAccountName;\n\tconst char *dnsHostName;\n\tconst char *netbios_name;\n\tstruct GUID ntds;\n\tchar *ntds_guid = NULL;\n\n\tstatic const char *acl_attrs[] = {\n\t\t\"samAccountName\",\n\t\t\"dnsHostName\",\n\t\t\"userAccountControl\",\n\t\tNULL\n\t};\n\tstatic const char *netbios_attrs[] = {\n\t\t\"nETBIOSName\",\n\t\tNULL\n\t};\n\n\t\/* if we have wp, we can do whatever we like *\/\n\tif (acl_check_access_on_attribute(module,\n\t\t\t\t\t tmp_ctx,\n\t\t\t\t\t sd,\n\t\t\t\t\t sid,\n\t\t\t\t\t SEC_ADS_WRITE_PROP,\n\t\t\t\t\t attr, objectclass) == LDB_SUCCESS) {\n\t\ttalloc_free(tmp_ctx);\n\t\treturn LDB_SUCCESS;\n\t}\n\n\tret = acl_check_extended_right(tmp_ctx,\n\t\t\t\t module,\n\t\t\t\t req,\n\t\t\t\t objectclass,\n\t\t\t\t sd,\n\t\t\t\t acl_user_token(module),\n\t\t\t\t GUID_DRS_VALIDATE_SPN,\n\t\t\t\t SEC_ADS_SELF_WRITE,\n\t\t\t\t sid);\n\n\tif (ret != LDB_SUCCESS) {\n\t\tdsdb_acl_debug(sd, acl_user_token(module),\n\t\t\t req->op.mod.message->dn,\n\t\t\t true,\n\t\t\t 10);\n\t\ttalloc_free(tmp_ctx);\n\t\treturn ret;\n\t}\n\n\t\/*\n\t * If we have \"validated write spn\", allow delete of any\n\t * existing value (this keeps constrained delete to the same\n\t * rules as unconstrained)\n\t *\/\n\tif (req->operation == LDB_MODIFY) {\n\t\t\/*\n\t\t * If not add or replace (eg delete),\n\t\t * return success\n\t\t *\/\n\t\tif (LDB_FLAG_MOD_TYPE(el->flags) != LDB_FLAG_MOD_ADD &&\n\t\t LDB_FLAG_MOD_TYPE(el->flags) != LDB_FLAG_MOD_REPLACE)\n\t\t{\n\t\t\ttalloc_free(tmp_ctx);\n\t\t\treturn LDB_SUCCESS;\n\t\t}\n\t}\n\n\tret = dsdb_module_search_dn(module, tmp_ctx,\n\t\t\t\t &acl_res, req->op.mod.message->dn,\n\t\t\t\t acl_attrs,\n\t\t\t\t DSDB_FLAG_NEXT_MODULE |\n\t\t\t\t DSDB_FLAG_AS_SYSTEM |\n\t\t\t\t DSDB_SEARCH_SHOW_RECYCLED,\n\t\t\t\t req);\n\tif (ret != LDB_SUCCESS) {\n\t\ttalloc_free(tmp_ctx);\n\t\treturn ret;\n\t}\n\n\tuserAccountControl = ldb_msg_find_attr_as_uint(acl_res->msgs[0], \"userAccountControl\", 0);\n\tdnsHostName = ldb_msg_find_attr_as_string(acl_res->msgs[0], \"dnsHostName\", NULL);\n\tsamAccountName = ldb_msg_find_attr_as_string(acl_res->msgs[0], \"samAccountName\", NULL);\n\n\tret = dsdb_module_search(module, tmp_ctx,\n\t\t\t\t &netbios_res, partitions_dn,\n\t\t\t\t LDB_SCOPE_ONELEVEL,\n\t\t\t\t netbios_attrs,\n\t\t\t\t DSDB_FLAG_NEXT_MODULE |\n\t\t\t\t DSDB_FLAG_AS_SYSTEM,\n\t\t\t\t req,\n\t\t\t\t \"(ncName=%s)\",\n\t\t\t\t ldb_dn_get_linearized(ldb_get_default_basedn(ldb)));\n\n\tnetbios_name = ldb_msg_find_attr_as_string(netbios_res->msgs[0], \"nETBIOSName\", NULL);\n\n\t\/* NTDSDSA objectGuid of object we are checking SPN for *\/\n\tif (userAccountControl & (UF_SERVER_TRUST_ACCOUNT | UF_PARTIAL_SECRETS_ACCOUNT)) {\n\t\tret = dsdb_module_find_ntdsguid_for_computer(module, tmp_ctx,\n\t\t\t\t\t\t\t req->op.mod.message->dn, &ntds, req);\n\t\tif (ret != LDB_SUCCESS) {\n\t\t\tldb_asprintf_errstring(ldb, \"Failed to find NTDSDSA objectGuid for %s: %s\",\n\t\t\t\t\t ldb_dn_get_linearized(req->op.mod.message->dn),\n\t\t\t\t\t ldb_strerror(ret));\n\t\t\ttalloc_free(tmp_ctx);\n\t\t\treturn LDB_ERR_OPERATIONS_ERROR;\n\t\t}\n\t\tntds_guid = GUID_string(tmp_ctx, &ntds);\n\t}\n\n\tfor (i=0; i < el->num_values; i++) {\n\t\tret = acl_validate_spn_value(tmp_ctx,\n\t\t\t\t\t ldb,\n\t\t\t\t\t (char *)el->values[i].data,\n\t\t\t\t\t userAccountControl,\n\t\t\t\t\t samAccountName,\n\t\t\t\t\t dnsHostName,\n\t\t\t\t\t netbios_name,\n\t\t\t\t\t ntds_guid);\n\t\tif (ret != LDB_SUCCESS) {\n\t\t\ttalloc_free(tmp_ctx);\n\t\t\treturn ret;\n\t\t}\n\t}\n\ttalloc_free(tmp_ctx);\n\treturn LDB_SUCCESS;\n}","target":0,"code_token_length":1050,"total_token_length":1286,"max_tokens_setting":2048} +{"idx":371403,"func":"ZrtpPacketCommit* ZRtp::prepareCommit(ZrtpPacketHello *hello, uint32_t* errMsg) {\n\n \/\/ Save data before detailed checks - may aid in analysing problems\n peerClientId.assign((char*)hello->getClientId(), ZRTP_WORD_SIZE * 4);\n memcpy(peerHelloVersion, hello->getVersion(), ZRTP_WORD_SIZE);\n peerHelloVersion[ZRTP_WORD_SIZE] = 0;\n\n \/\/ Save our peer's (presumably the Responder) ZRTP id\n memcpy(peerZid, hello->getZid(), ZID_SIZE);\n if (memcmp(peerZid, ownZid, ZID_SIZE) == 0) { \/\/ peers have same ZID????\n *errMsg = EqualZIDHello;\n return NULL;\n }\n memcpy(peerH3, hello->getH3(), HASH_IMAGE_SIZE);\n\n int32_t helloLen = hello->getLength() * ZRTP_WORD_SIZE;\n\n \/\/ calculate hash over the received Hello packet - is peer's hello hash.\n \/\/ Use implicit hash algorithm\n hashFunctionImpl((unsigned char*)hello->getHeaderBase(), helloLen, peerHelloHash);\n\n sendInfo(Info, InfoHelloReceived);\n\n \/*\n * The Following section extracts the algorithm from the peer's Hello\n * packet. Always the preferend offered algorithms are\n * used. If the received Hello does not contain algo specifiers\n * or offers only unsupported optional algos then replace\n * these with mandatory algos and put them into the Commit packet.\n * Refer to the findBest*() functions.\n * If this is a MultiStream ZRTP object then do not get the cipher,\n * authentication from hello packet but use the pre-initialized values\n * as proposed by the standard. If we switch to responder mode the\n * commit packet may contain other algos - see function\n * prepareConfirm2MultiStream(...).\n *\/\n sasType = findBestSASType(hello);\n\n if (!multiStream) {\n pubKey = findBestPubkey(hello); \/\/ Check for public key algorithm first, sets 'hash' as well\n if (hash == NULL) {\n *errMsg = UnsuppHashType;\n return NULL;\n }\n if (cipher == NULL) \/\/ public key selection may have set the cipher already\n cipher = findBestCipher(hello, pubKey);\n authLength = findBestAuthLen(hello);\n multiStreamAvailable = checkMultiStream(hello);\n }\n else {\n if (checkMultiStream(hello)) {\n return prepareCommitMultiStream(hello);\n }\n else {\n \/\/ we are in multi-stream but peer does not offer multi-stream\n \/\/ return error code to other party - unsupported PK, must be Mult\n *errMsg = UnsuppPKExchange;\n return NULL;\n }\n }\n setNegotiatedHash(hash);\n\n \/\/ Modify here when introducing new DH key agreement, for example\n \/\/ elliptic curves.\n dhContext = new ZrtpDH(pubKey->getName());\n dhContext->generatePublicKey();\n\n dhContext->getPubKeyBytes(pubKeyBytes);\n sendInfo(Info, InfoCommitDHGenerated);\n\n \/\/ Prepare IV data that we will use during confirm packet encryption.\n randomZRTP(randomIV, sizeof(randomIV));\n\n \/*\n * Prepare our DHPart2 packet here. Required to compute HVI. If we stay\n * in Initiator role then we reuse this packet later in prepareDHPart2().\n * To create this DH packet we have to compute the retained secret ids,\n * thus get our peer's retained secret data first.\n *\/\n zidRec = getZidCacheInstance()->getRecord(peerZid);\n\n \/\/Compute the Initator's and Responder's retained secret ids.\n computeSharedSecretSet(zidRec);\n\n \/\/ Check if a PBX application set the MitM flag.\n mitmSeen = hello->isMitmMode();\n\n signSasSeen = hello->isSasSign();\n \/\/ Construct a DHPart2 message (Initiator's DH message). This packet\n \/\/ is required to compute the HVI (Hash Value Initiator), refer to\n \/\/ chapter 5.4.1.1.\n\n \/\/ Fill the values in the DHPart2 packet\n zrtpDH2.setPubKeyType(pubKey->getName());\n zrtpDH2.setMessageType((uint8_t*)DHPart2Msg);\n zrtpDH2.setRs1Id(rs1IDi);\n zrtpDH2.setRs2Id(rs2IDi);\n zrtpDH2.setAuxSecretId(auxSecretIDi);\n zrtpDH2.setPbxSecretId(pbxSecretIDi);\n zrtpDH2.setPv(pubKeyBytes);\n zrtpDH2.setH1(H1);\n\n int32_t len = zrtpDH2.getLength() * ZRTP_WORD_SIZE;\n\n \/\/ Compute HMAC over DH2, excluding the HMAC field (HMAC_SIZE)\n \/\/ and store in DH2. Key to HMAC is H0, use HASH_IMAGE_SIZE bytes only.\n \/\/ Must use implicit HMAC functions.\n uint8_t hmac[IMPL_MAX_DIGEST_LENGTH];\n uint32_t macLen;\n hmacFunctionImpl(H0, HASH_IMAGE_SIZE, (uint8_t*)zrtpDH2.getHeaderBase(), len-(HMAC_SIZE), hmac, &macLen);\n zrtpDH2.setHMAC(hmac);\n\n \/\/ Compute the HVI, refer to chapter 5.4.1.1 of the specification\n computeHvi(&zrtpDH2, hello);\n\n zrtpCommit.setZid(ownZid);\n zrtpCommit.setHashType((uint8_t*)hash->getName());\n zrtpCommit.setCipherType((uint8_t*)cipher->getName());\n zrtpCommit.setAuthLen((uint8_t*)authLength->getName());\n zrtpCommit.setPubKeyType((uint8_t*)pubKey->getName());\n zrtpCommit.setSasType((uint8_t*)sasType->getName());\n zrtpCommit.setHvi(hvi);\n zrtpCommit.setH2(H2);\n\n len = zrtpCommit.getLength() * ZRTP_WORD_SIZE;\n\n \/\/ Compute HMAC over Commit, excluding the HMAC field (HMAC_SIZE)\n \/\/ and store in Hello. Key to HMAC is H1, use HASH_IMAGE_SIZE bytes only.\n \/\/ Must use implicit HMAC functions.\n hmacFunctionImpl(H1, HASH_IMAGE_SIZE, (uint8_t*)zrtpCommit.getHeaderBase(), len-(HMAC_SIZE), hmac, &macLen);\n zrtpCommit.setHMAC(hmac);\n\n \/\/ hash first messages to produce overall message hash\n \/\/ First the Responder's Hello message, second the Commit (always Initator's).\n \/\/ Must use negotiated hash.\n msgShaContext = createHashCtx();\n hashCtxFunction(msgShaContext, (unsigned char*)hello->getHeaderBase(), helloLen);\n hashCtxFunction(msgShaContext, (unsigned char*)zrtpCommit.getHeaderBase(), len);\n\n \/\/ store Hello data temporarily until we can check HMAC after receiving Commit as\n \/\/ Responder or DHPart1 as Initiator\n storeMsgTemp(hello);\n\n return &zrtpCommit;\n}","target":0,"code_token_length":1580,"total_token_length":1816,"max_tokens_setting":2048} +{"idx":66492,"func":" template\n CImg& solve(const CImg& A) {\n if (_depth!=1 || _spectrum!=1 || _height!=A._height || A._depth!=1 || A._spectrum!=1)\n throw CImgArgumentException(_cimg_instance\n \"solve(): Instance and specified matrix (%u,%u,%u,%u,%p) have \"\n \"incompatible dimensions.\",\n cimg_instance,\n A._width,A._height,A._depth,A._spectrum,A._data);\n typedef _cimg_Ttfloat Ttfloat;\n\n if (A.size()==1) return (*this)\/=A[0];\n if (A._width==2 && A._height==2 && _height==2) {\n const double a = (double)A[0], b = (double)A[1], c = (double)A[2], d = (double)A[3],\n fa = std::fabs(a), fb = std::fabs(b), fc = std::fabs(c), fd = std::fabs(d),\n det = a*d - b*c, fM = cimg::max(fa,fb,fc,fd);\n if (fM==fa) cimg_forX(*this,k) {\n const double u = (double)(*this)(k,0), v = (double)(*this)(k,1), y = (a*v - c*u)\/det;\n (*this)(k,0) = (T)((u - b*y)\/a); (*this)(k,1) = (T)y;\n } else if (fM==fc) cimg_forX(*this,k) {\n const double u = (double)(*this)(k,0), v = (double)(*this)(k,1), y = (a*v - c*u)\/det;\n (*this)(k,0) = (T)((v - d*y)\/c); (*this)(k,1) = (T)y;\n } else if (fM==fb) cimg_forX(*this,k) {\n const double u = (double)(*this)(k,0), v = (double)(*this)(k,1), x = (d*u - b*v)\/det;\n (*this)(k,0) = (T)x; (*this)(k,1) = (T)((u - a*x)\/b);\n } else cimg_forX(*this,k) {\n const double u = (double)(*this)(k,0), v = (double)(*this)(k,1), x = (d*u - b*v)\/det;\n (*this)(k,0) = (T)x; (*this)(k,1) = (T)((v - c*x)\/d);\n }\n return *this;\n }\n if (_width!=1) { \/\/ Process column-by-column\n CImg res(_width,A._width);\n cimg_forX(*this,i) res.draw_image(i,get_column(i).solve(A));\n return res.move_to(*this);\n }\n\n if (A._width==A._height) { \/\/ Square linear system\n\n#ifdef cimg_use_lapack\n char TRANS = 'N';\n int INFO, N = _height, LWORK = 4*N, *const IPIV = new int[N];\n Ttfloat\n *const lapA = new Ttfloat[N*N],\n *const lapB = new Ttfloat[N],\n *const WORK = new Ttfloat[LWORK];\n cimg_forXY(A,k,l) lapA[k*N + l] = (Ttfloat)(A(k,l));\n cimg_forY(*this,i) lapB[i] = (Ttfloat)((*this)(i));\n cimg::getrf(N,lapA,IPIV,INFO);\n if (INFO)\n cimg::warn(_cimg_instance\n \"solve(): LAPACK library function dgetrf_() returned error code %d.\",\n cimg_instance,\n INFO);\n\n if (!INFO) {\n cimg::getrs(TRANS,N,lapA,IPIV,lapB,INFO);\n if (INFO)\n cimg::warn(_cimg_instance\n \"solve(): LAPACK library function dgetrs_() returned error code %d.\",\n cimg_instance,\n INFO);\n }\n if (!INFO) cimg_forY(*this,i) (*this)(i) = (T)(lapB[i]); else fill(0);\n delete[] IPIV; delete[] lapA; delete[] lapB; delete[] WORK;\n#else\n CImg lu(A,false);\n CImg indx;\n bool d;\n lu._LU(indx,d);\n _solve(lu,indx);\n#endif\n } else { \/\/ Least-square solution for non-square systems\n\n#ifdef cimg_use_lapack\n\tchar TRANS = 'N';\n int INFO, N = A._width, M = A._height, LWORK = -1, LDA = M, LDB = M, NRHS = _width;\n\tTtfloat WORK_QUERY;\n\tTtfloat\n\t * const lapA = new Ttfloat[M*N],\n\t * const lapB = new Ttfloat[M*NRHS];\n\tcimg::sgels(TRANS, M, N, NRHS, lapA, LDA, lapB, LDB, &WORK_QUERY, LWORK, INFO);\n\tLWORK = (int) WORK_QUERY;\n\tTtfloat *const WORK = new Ttfloat[LWORK];\n cimg_forXY(A,k,l) lapA[k*M + l] = (Ttfloat)(A(k,l));\n cimg_forXY(*this,k,l) lapB[k*M + l] = (Ttfloat)((*this)(k,l));\n\tcimg::sgels(TRANS, M, N, NRHS, lapA, LDA, lapB, LDB, WORK, LWORK, INFO);\n if (INFO != 0)\n cimg::warn(_cimg_instance\n \"solve(): LAPACK library function sgels() returned error code %d.\",\n cimg_instance,\n INFO);\n\tassign(NRHS, N);\n if (!INFO)\n cimg_forXY(*this,k,l) (*this)(k,l) = (T)lapB[k*M + l];\n else\n assign(A.get_pseudoinvert()*(*this));\n delete[] lapA; delete[] lapB; delete[] WORK;\n#else\n\tassign(A.get_pseudoinvert()*(*this));\n#endif\n }\n return *this;","target":0,"code_token_length":1417,"total_token_length":1653,"max_tokens_setting":2048} +{"idx":62471,"func":"eexec_line(unsigned char *line, int line_len)\n{\n int cs_start_len = strlen(cs_start);\n int pos;\n int first_space;\n int digits;\n int cut_newline = 0;\n\n \/* append this data to the end of `save' if necessary *\/\n if (save_len) {\n\tappend_save(line, line_len);\n\tline = save;\n\tline_len = save_len;\n save_len = 0;\n }\n\n if (!line_len)\n\treturn 0;\n\n \/* Look for charstring start *\/\n\n \/* skip first word *\/\n for (pos = 0; pos < line_len && isspace(line[pos]); pos++)\n\t;\n while (pos < line_len && !isspace(line[pos]))\n\tpos++;\n if (pos >= line_len)\n\tgoto not_charstring;\n\n \/* skip spaces *\/\n first_space = pos;\n while (pos < line_len && isspace(line[pos]))\n\tpos++;\n if (pos >= line_len || !isdigit(line[pos]))\n\tgoto not_charstring;\n\n \/* skip number *\/\n digits = pos;\n while (pos < line_len && isdigit(line[pos]))\n\tpos++;\n\n \/* check for subr (another number) *\/\n if (pos < line_len - 1 && isspace(line[pos]) && isdigit(line[pos+1])) {\n\tfirst_space = pos;\n\tdigits = pos + 1;\n\tfor (pos = digits; pos < line_len && isdigit(line[pos]); pos++)\n\t ;\n }\n\n \/* check for charstring start *\/\n if (pos + 2 + cs_start_len < line_len\n\t&& pos > digits\n\t&& line[pos] == ' '\n\t&& strncmp((const char *)(line + pos + 1), cs_start, cs_start_len) == 0\n\t&& line[pos + 1 + cs_start_len] == ' ') {\n\t\/* check if charstring is long enough *\/\n\tint cs_len = atoi((const char *)(line + digits));\n\tif (pos + 2 + cs_start_len + cs_len < line_len) {\n\t \/* long enough! *\/\n\t if (line[line_len - 1] == '\\r') {\n\t\tline[line_len - 1] = '\\n';\n\t\tcut_newline = 1;\n\t }\n\t fprintf(ofp, \"%.*s {\\n\", first_space, line);\n\t decrypt_charstring(line + pos + 2 + cs_start_len, cs_len);\n\t pos += 2 + cs_start_len + cs_len;\n\t fprintf(ofp, \"\\t}%.*s\", line_len - pos, line + pos);\n\t return cut_newline;\n\t} else {\n\t \/* not long enough! *\/\n append_save(line, line_len);\n\t return 0;\n\t}\n }\n\n \/* otherwise, just output the line *\/\n not_charstring:\n \/* 6.Oct.2003 - Werner Lemberg reports a stupid Omega font that behaves\n badly: a charstring definition follows \"\/Charstrings ... begin\", ON THE\n SAME LINE. *\/\n {\n\tconst char *CharStrings = (const char *)\n\t oog_memstr(line, line_len, \"\/CharStrings \", 13);\n\tint crap, n;\n\tchar should_be_slash = 0;\n\tif (CharStrings\n\t && sscanf(CharStrings + 12, \" %d dict dup begin %c%n\", &crap, &should_be_slash, &n) >= 2\n\t && should_be_slash == '\/') {\n\t int len = (CharStrings + 12 + n - 1) - (char *) line;\n\t fprintf(ofp, \"%.*s\\n\", len, line);\n\t return eexec_line((unsigned char *) (CharStrings + 12 + n - 1), line_len - len);\n\t}\n }\n\n if (line[line_len - 1] == '\\r') {\n\tline[line_len - 1] = '\\n';\n\tcut_newline = 1;\n }\n set_lenIV((char *)line);\n set_cs_start((char *)line);\n fprintf(ofp, \"%.*s\", line_len, line);\n\n \/* look for `currentfile closefile' to see if we should stop decrypting *\/\n if (oog_memstr(line, line_len, \"currentfile closefile\", 21) != 0)\n\tin_eexec = -1;\n\n return cut_newline;\n}","target":0,"code_token_length":920,"total_token_length":1156,"max_tokens_setting":2048} +{"idx":5965,"func":"void ACSequentialScan::DecodeBlock(LONG *block,\n LONG &prevdc,LONG &prevdiff,\n UBYTE small,UBYTE large,UBYTE kx,UBYTE dc,UBYTE ac)\n{\n \/\/ DC coding\n if (m_ucScanStart == 0 && m_bResidual == false) {\n LONG diff;\n struct QMContextSet::DCContextZeroSet &cz = m_Context[dc].Classify(prevdiff,small,large);\n \/\/ Check whether the difference is nonzero.\n if (m_Coder.Get(cz.S0)) {\n LONG sz;\n bool sign = m_Coder.Get(cz.SS); \/\/ sign coding, is true for negative.\n \/\/\n \/\/\n \/\/ Positive and negative are encoded in different contexts.\n \/\/ Decode the magnitude cathegory.\n if (m_Coder.Get((sign)?(cz.SN):(cz.SP))) {\n int i = 0;\n LONG m = 2;\n \n while(m_Coder.Get(m_Context[dc].DCMagnitude.X[i])) {\n m <<= 1;\n i++;\n if (m == 0) \n JPG_THROW(MALFORMED_STREAM,\"ACSequentialScan::DecodeBlock\",\n \"QMDecoder is out of sync\");\n }\n \/\/\n \/\/ Get the MSB to decode.\n m >>= 1;\n sz = m;\n \/\/\n \/\/ Refinement coding of remaining bits.\n while((m >>= 1)) {\n if (m_Coder.Get(m_Context[dc].DCMagnitude.M[i])) {\n sz |= m;\n }\n }\n } else {\n sz = 0;\n }\n \/\/\n \/\/ Done, finally, include the sign and the offset.\n if (sign) {\n diff = -sz - 1;\n } else {\n diff = sz + 1;\n }\n } else {\n \/\/ Difference is zero.\n diff = 0;\n }\n\n prevdiff = diff;\n if (m_bDifferential) {\n prevdc = diff;\n } else {\n prevdc += diff;\n }\n block[0] = prevdc << m_ucLowBit; \/\/ point transformation\n }\n\n if (m_ucScanStop) {\n \/\/ AC coding. No block skipping used here.\n int k = (m_ucScanStart)?(m_ucScanStart):((m_bResidual)?0:1);\n \/\/\n \/\/ EOB decoding.\n while(k <= m_ucScanStop && !m_Coder.Get(m_Context[ac].ACZero[k-1].SE)) {\n LONG sz;\n bool sign;\n \/\/\n \/\/ Not yet EOB. Run coding in S0: Skip over zeros.\n while(!m_Coder.Get(m_Context[ac].ACZero[k-1].S0)) {\n k++;\n if (k > m_ucScanStop)\n JPG_THROW(MALFORMED_STREAM,\"ACSequentialScan::DecodeBlock\",\n \"QMDecoder is out of sync\");\n }\n \/\/\n \/\/ Now decode the sign of the coefficient.\n \/\/ This happens in the uniform context.\n sign = m_Coder.Get(m_Context[ac].Uniform);\n \/\/\n \/\/ Decode the magnitude.\n if (m_Coder.Get(m_Context[ac].ACZero[k-1].SP)) {\n \/\/ X1 coding, identical to SN and SP.\n if (m_Coder.Get(m_Context[ac].ACZero[k-1].SP)) {\n int i = 0;\n LONG m = 4;\n struct QMContextSet::ACContextMagnitudeSet &acm = (k > kx)?(m_Context[ac].ACMagnitudeHigh):(m_Context[ac].ACMagnitudeLow);\n \n while(m_Coder.Get(acm.X[i])) {\n m <<= 1;\n i++;\n if (m == 0)\n JPG_THROW(MALFORMED_STREAM,\"ACSequentialScan::DecodeBlock\",\n \"QMDecoder is out of sync\");\n }\n \/\/\n \/\/ Get the MSB to decode\n m >>= 1;\n sz = m;\n \/\/\n \/\/ Proceed to refinement.\n while((m >>= 1)) {\n if (m_Coder.Get(acm.M[i])) {\n sz |= m;\n }\n }\n } else {\n sz = 1;\n }\n } else {\n sz = 0;\n }\n \/\/\n \/\/ Done. Finally, include sign and offset.\n sz++;\n if (sign) \n sz = -sz;\n block[DCT::ScanOrder[k]] = sz << m_ucLowBit;\n \/\/\n \/\/ Proceed to the next block.\n k++;\n }\n }\n}","target":1,"code_token_length":1000,"total_token_length":1236,"max_tokens_setting":2048} +{"idx":300288,"func":"one_function_arg(\n\tchar_u\t *arg,\n\tgarray_T *newargs,\n\tgarray_T *argtypes,\n\tint\t types_optional,\n\tevalarg_T *evalarg,\n\tint\t is_vararg,\n\tint\t skip)\n{\n char_u\t*p = arg;\n char_u\t*arg_copy = NULL;\n int\t\tis_underscore = FALSE;\n\n while (ASCII_ISALNUM(*p) || *p == '_')\n\t++p;\n if (arg == p || isdigit(*arg)\n\t || (argtypes == NULL\n\t\t&& ((p - arg == 9 && STRNCMP(arg, \"firstline\", 9) == 0)\n\t\t || (p - arg == 8 && STRNCMP(arg, \"lastline\", 8) == 0))))\n {\n\tif (!skip)\n\t semsg(_(e_illegal_argument_str), arg);\n\treturn arg;\n }\n\n \/\/ Vim9 script: cannot use script var name for argument. In function: also\n \/\/ check local vars and arguments.\n if (!skip && argtypes != NULL && check_defined(arg, p - arg,\n\t\t evalarg == NULL ? NULL : evalarg->eval_cctx, TRUE) == FAIL)\n\treturn arg;\n\n if (newargs != NULL && ga_grow(newargs, 1) == FAIL)\n\treturn arg;\n if (newargs != NULL)\n {\n\tint\tc;\n\tint\ti;\n\n\tc = *p;\n\t*p = NUL;\n\targ_copy = vim_strsave(arg);\n\tif (arg_copy == NULL)\n\t{\n\t *p = c;\n\t return arg;\n\t}\n\tis_underscore = arg_copy[0] == '_' && arg_copy[1] == NUL;\n\tif (argtypes == NULL || !is_underscore)\n\t \/\/ Check for duplicate argument name.\n\t for (i = 0; i < newargs->ga_len; ++i)\n\t\tif (STRCMP(((char_u **)(newargs->ga_data))[i], arg_copy) == 0)\n\t\t{\n\t\t semsg(_(e_duplicate_argument_name_str), arg_copy);\n\t\t vim_free(arg_copy);\n\t\t return arg;\n\t\t}\n\t((char_u **)(newargs->ga_data))[newargs->ga_len] = arg_copy;\n\tnewargs->ga_len++;\n\n\t*p = c;\n }\n\n \/\/ get any type from \"arg: type\"\n if (argtypes != NULL && (skip || ga_grow(argtypes, 1) == OK))\n {\n\tchar_u *type = NULL;\n\n\tif (VIM_ISWHITE(*p) && *skipwhite(p) == ':')\n\t{\n\t semsg(_(e_no_white_space_allowed_before_colon_str),\n\t\t\t\t\t arg_copy == NULL ? arg : arg_copy);\n\t p = skipwhite(p);\n\t}\n\tif (*p == ':')\n\t{\n\t ++p;\n\t if (!skip && !VIM_ISWHITE(*p))\n\t {\n\t\tsemsg(_(e_white_space_required_after_str_str), \":\", p - 1);\n\t\treturn arg;\n\t }\n\t type = skipwhite(p);\n\t p = skip_type(type, TRUE);\n\t if (!skip)\n\t\ttype = vim_strnsave(type, p - type);\n\t}\n\telse if (*skipwhite(p) != '=' && !types_optional && !is_underscore)\n\t{\n\t semsg(_(e_missing_argument_type_for_str),\n\t\t\t\t\t arg_copy == NULL ? arg : arg_copy);\n\t return arg;\n\t}\n\tif (!skip)\n\t{\n\t if (type == NULL && types_optional)\n\t\t\/\/ lambda arguments default to \"any\" type\n\t\ttype = vim_strsave((char_u *)\n\t\t\t\t\t (is_vararg ? \"list\" : \"any\"));\n\t ((char_u **)argtypes->ga_data)[argtypes->ga_len++] = type;\n\t}\n }\n\n return p;\n}","target":0,"code_token_length":809,"total_token_length":1045,"max_tokens_setting":2048} +{"idx":161562,"func":"STATIC void\nS_reginsert(pTHX_ RExC_state_t *pRExC_state, const U8 op,\n const regnode_offset operand, const U32 depth)\n{\n regnode *src;\n regnode *dst;\n regnode *place;\n const int offset = regarglen[(U8)op];\n const int size = NODE_STEP_REGNODE + offset;\n GET_RE_DEBUG_FLAGS_DECL;\n\n PERL_ARGS_ASSERT_REGINSERT;\n PERL_UNUSED_CONTEXT;\n PERL_UNUSED_ARG(depth);\n\/* (PL_regkind[(U8)op] == CURLY ? EXTRA_STEP_2ARGS : 0); *\/\n DEBUG_PARSE_FMT(\"inst\",\" - %s\", PL_reg_name[op]);\n assert(!RExC_study_started); \/* I believe we should never use reginsert once we have started\n studying. If this is wrong then we need to adjust RExC_recurse\n below like we do with RExC_open_parens\/RExC_close_parens. *\/\n change_engine_size(pRExC_state, (Ptrdiff_t) size);\n src = REGNODE_p(RExC_emit);\n RExC_emit += size;\n dst = REGNODE_p(RExC_emit);\n\n \/* If we are in a \"count the parentheses\" pass, the numbers are unreliable,\n * and [perl #133871] shows this can lead to problems, so skip this\n * realignment of parens until a later pass when they are reliable *\/\n if (! IN_PARENS_PASS && RExC_open_parens) {\n int paren;\n \/*DEBUG_PARSE_FMT(\"inst\",\" - %\" IVdf, (IV)RExC_npar);*\/\n \/* remember that RExC_npar is rex->nparens + 1,\n * iow it is 1 more than the number of parens seen in\n * the pattern so far. *\/\n for ( paren=0 ; paren < RExC_npar ; paren++ ) {\n \/* note, RExC_open_parens[0] is the start of the\n * regex, it can't move. RExC_close_parens[0] is the end\n * of the regex, it *can* move. *\/\n if ( paren && RExC_open_parens[paren] >= operand ) {\n \/*DEBUG_PARSE_FMT(\"open\",\" - %d\", size);*\/\n RExC_open_parens[paren] += size;\n } else {\n \/*DEBUG_PARSE_FMT(\"open\",\" - %s\",\"ok\");*\/\n }\n if ( RExC_close_parens[paren] >= operand ) {\n \/*DEBUG_PARSE_FMT(\"close\",\" - %d\", size);*\/\n RExC_close_parens[paren] += size;\n } else {\n \/*DEBUG_PARSE_FMT(\"close\",\" - %s\",\"ok\");*\/\n }\n }\n }\n if (RExC_end_op)\n RExC_end_op += size;\n\n while (src > REGNODE_p(operand)) {\n\tStructCopy(--src, --dst, regnode);\n#ifdef RE_TRACK_PATTERN_OFFSETS\n if (RExC_offsets) { \/* MJD 20010112 *\/\n\t MJD_OFFSET_DEBUG(\n (\"%s(%d): (op %s) %s copy %\" UVuf \" -> %\" UVuf \" (max %\" UVuf \").\\n\",\n \"reginsert\",\n\t\t __LINE__,\n\t\t PL_reg_name[op],\n (UV)(REGNODE_OFFSET(dst)) > RExC_offsets[0]\n\t\t ? \"Overwriting end of array!\\n\" : \"OK\",\n (UV)REGNODE_OFFSET(src),\n (UV)REGNODE_OFFSET(dst),\n (UV)RExC_offsets[0]));\n\t Set_Node_Offset_To_R(REGNODE_OFFSET(dst), Node_Offset(src));\n\t Set_Node_Length_To_R(REGNODE_OFFSET(dst), Node_Length(src));\n }\n#endif\n }\n\n place = REGNODE_p(operand);\t\/* Op node, where operand used to be. *\/\n#ifdef RE_TRACK_PATTERN_OFFSETS\n if (RExC_offsets) { \/* MJD *\/\n\tMJD_OFFSET_DEBUG(\n (\"%s(%d): (op %s) %s %\" UVuf \" <- %\" UVuf \" (max %\" UVuf \").\\n\",\n \"reginsert\",\n\t __LINE__,\n\t PL_reg_name[op],\n (UV)REGNODE_OFFSET(place) > RExC_offsets[0]\n ? \"Overwriting end of array!\\n\" : \"OK\",\n (UV)REGNODE_OFFSET(place),\n (UV)(RExC_parse - RExC_start),\n (UV)RExC_offsets[0]));\n\tSet_Node_Offset(place, RExC_parse);\n\tSet_Node_Length(place, 1);\n }\n#endif\n src = NEXTOPER(place);\n FLAGS(place) = 0;\n FILL_NODE(operand, op);\n\n \/* Zero out any arguments in the new node *\/\n Zero(src, offset, regnode);","target":0,"code_token_length":1061,"total_token_length":1297,"max_tokens_setting":2048} +{"idx":91849,"func":"int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){\n Table *pSelTab; \/* A fake table from which we get the result set *\/\n Select *pSel; \/* Copy of the SELECT that implements the view *\/\n int nErr = 0; \/* Number of errors encountered *\/\n int n; \/* Temporarily holds the number of cursors assigned *\/\n sqlite3 *db = pParse->db; \/* Database connection for malloc errors *\/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n int rc;\n#endif\n#ifndef SQLITE_OMIT_AUTHORIZATION\n sqlite3_xauth xAuth; \/* Saved xAuth pointer *\/\n#endif\n\n assert( pTable );\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n db->nSchemaLock++;\n rc = sqlite3VtabCallConnect(pParse, pTable);\n db->nSchemaLock--;\n if( rc ){\n return 1;\n }\n if( IsVirtual(pTable) ) return 0;\n#endif\n\n#ifndef SQLITE_OMIT_VIEW\n \/* A positive nCol means the columns names for this view are\n ** already known.\n *\/\n if( pTable->nCol>0 ) return 0;\n\n \/* A negative nCol is a special marker meaning that we are currently\n ** trying to compute the column names. If we enter this routine with\n ** a negative nCol, it means two or more views form a loop, like this:\n **\n ** CREATE VIEW one AS SELECT * FROM two;\n ** CREATE VIEW two AS SELECT * FROM one;\n **\n ** Actually, the error above is now caught prior to reaching this point.\n ** But the following test is still important as it does come up\n ** in the following:\n ** \n ** CREATE TABLE main.ex1(a);\n ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;\n ** SELECT * FROM temp.ex1;\n *\/\n if( pTable->nCol<0 ){\n sqlite3ErrorMsg(pParse, \"view %s is circularly defined\", pTable->zName);\n return 1;\n }\n assert( pTable->nCol>=0 );\n\n \/* If we get this far, it means we need to compute the table names.\n ** Note that the call to sqlite3ResultSetOfSelect() will expand any\n ** \"*\" elements in the results set of the view and will assign cursors\n ** to the elements of the FROM clause. But we do not want these changes\n ** to be permanent. So the computation is done on a copy of the SELECT\n ** statement that defines the view.\n *\/\n assert( pTable->pSelect );\n pSel = sqlite3SelectDup(db, pTable->pSelect, 0);\n if( pSel ){\n#ifndef SQLITE_OMIT_ALTERTABLE\n u8 eParseMode = pParse->eParseMode;\n pParse->eParseMode = PARSE_MODE_NORMAL;\n#endif\n n = pParse->nTab;\n sqlite3SrcListAssignCursors(pParse, pSel->pSrc);\n pTable->nCol = -1;\n DisableLookaside;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n xAuth = db->xAuth;\n db->xAuth = 0;\n pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);\n db->xAuth = xAuth;\n#else\n pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE);\n#endif\n pParse->nTab = n;\n if( pTable->pCheck ){\n \/* CREATE VIEW name(arglist) AS ...\n ** The names of the columns in the table are taken from\n ** arglist which is stored in pTable->pCheck. The pCheck field\n ** normally holds CHECK constraints on an ordinary table, but for\n ** a VIEW it holds the list of column names.\n *\/\n sqlite3ColumnsFromExprList(pParse, pTable->pCheck, \n &pTable->nCol, &pTable->aCol);\n if( db->mallocFailed==0 \n && pParse->nErr==0\n && pTable->nCol==pSel->pEList->nExpr\n ){\n sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,\n SQLITE_AFF_NONE);\n }\n }else if( pSelTab ){\n \/* CREATE VIEW name AS... without an argument list. Construct\n ** the column names from the SELECT statement that defines the view.\n *\/\n assert( pTable->aCol==0 );\n pTable->nCol = pSelTab->nCol;\n pTable->aCol = pSelTab->aCol;\n pSelTab->nCol = 0;\n pSelTab->aCol = 0;\n assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );\n }else{\n pTable->nCol = 0;\n nErr++;\n }\n pTable->nNVCol = pTable->nCol;\n sqlite3DeleteTable(db, pSelTab);\n sqlite3SelectDelete(db, pSel);\n EnableLookaside;\n#ifndef SQLITE_OMIT_ALTERTABLE\n pParse->eParseMode = eParseMode;\n#endif\n } else {\n nErr++;\n }\n pTable->pSchema->schemaFlags |= DB_UnresetViews;\n if( db->mallocFailed ){\n sqlite3DeleteColumnNames(db, pTable);\n pTable->aCol = 0;\n pTable->nCol = 0;\n }\n#endif \/* SQLITE_OMIT_VIEW *\/\n return nErr; \n}","target":0,"code_token_length":1227,"total_token_length":1463,"max_tokens_setting":2048} +{"idx":364176,"func":"rfbSendRectEncodingTight(rfbClientPtr cl,\n int x,\n int y,\n int w,\n int h)\n{\n int nMaxRows;\n uint32_t colorValue;\n int dx, dy, dw, dh;\n int x_best, y_best, w_best, h_best;\n char *fbptr;\n\n rfbSendUpdateBuf(cl);\n\n compressLevel = cl->tightCompressLevel;\n qualityLevel = cl->tightQualityLevel;\n\n if ( cl->format.depth == 24 && cl->format.redMax == 0xFF &&\n cl->format.greenMax == 0xFF && cl->format.blueMax == 0xFF ) {\n usePixelFormat24 = TRUE;\n } else {\n usePixelFormat24 = FALSE;\n }\n\n if (!cl->enableLastRectEncoding || w * h < MIN_SPLIT_RECT_SIZE)\n return SendRectSimple(cl, x, y, w, h);\n\n \/* Make sure we can write at least one pixel into tightBeforeBuf. *\/\n\n if (tightBeforeBufSize < 4) {\n tightBeforeBufSize = 4;\n if (tightBeforeBuf == NULL)\n tightBeforeBuf = (char *)malloc(tightBeforeBufSize);\n else\n tightBeforeBuf = (char *)realloc(tightBeforeBuf,\n tightBeforeBufSize);\n }\n\n \/* Calculate maximum number of rows in one non-solid rectangle. *\/\n\n {\n int maxRectSize, maxRectWidth, nMaxWidth;\n\n maxRectSize = tightConf[compressLevel].maxRectSize;\n maxRectWidth = tightConf[compressLevel].maxRectWidth;\n nMaxWidth = (w > maxRectWidth) ? maxRectWidth : w;\n nMaxRows = maxRectSize \/ nMaxWidth;\n }\n\n \/* Try to find large solid-color areas and send them separately. *\/\n\n for (dy = y; dy < y + h; dy += MAX_SPLIT_TILE_SIZE) {\n\n \/* If a rectangle becomes too large, send its upper part now. *\/\n\n if (dy - y >= nMaxRows) {\n if (!SendRectSimple(cl, x, y, w, nMaxRows))\n return 0;\n y += nMaxRows;\n h -= nMaxRows;\n }\n\n dh = (dy + MAX_SPLIT_TILE_SIZE <= y + h) ?\n MAX_SPLIT_TILE_SIZE : (y + h - dy);\n\n for (dx = x; dx < x + w; dx += MAX_SPLIT_TILE_SIZE) {\n\n dw = (dx + MAX_SPLIT_TILE_SIZE <= x + w) ?\n MAX_SPLIT_TILE_SIZE : (x + w - dx);\n\n if (CheckSolidTile(cl, dx, dy, dw, dh, &colorValue, FALSE)) {\n\n \/* Get dimensions of solid-color area. *\/\n\n FindBestSolidArea(cl, dx, dy, w - (dx - x), h - (dy - y),\n\t\t\t\t colorValue, &w_best, &h_best);\n\n \/* Make sure a solid rectangle is large enough\n (or the whole rectangle is of the same color). *\/\n\n if ( w_best * h_best != w * h &&\n w_best * h_best < MIN_SOLID_SUBRECT_SIZE )\n continue;\n\n \/* Try to extend solid rectangle to maximum size. *\/\n\n x_best = dx; y_best = dy;\n ExtendSolidArea(cl, x, y, w, h, colorValue,\n &x_best, &y_best, &w_best, &h_best);\n\n \/* Send rectangles at top and left to solid-color area. *\/\n\n if ( y_best != y &&\n !SendRectSimple(cl, x, y, w, y_best-y) )\n return FALSE;\n if ( x_best != x &&\n !rfbSendRectEncodingTight(cl, x, y_best,\n x_best-x, h_best) )\n return FALSE;\n\n \/* Send solid-color rectangle. *\/\n\n if (!SendTightHeader(cl, x_best, y_best, w_best, h_best))\n return FALSE;\n\n fbptr = (cl->scaledScreen->frameBuffer +\n (cl->scaledScreen->paddedWidthInBytes * y_best) +\n (x_best * (cl->scaledScreen->bitsPerPixel \/ 8)));\n\n (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,\n &cl->format, fbptr, tightBeforeBuf,\n cl->scaledScreen->paddedWidthInBytes, 1, 1);\n\n if (!SendSolidRect(cl))\n return FALSE;\n\n \/* Send remaining rectangles (at right and bottom). *\/\n\n if ( x_best + w_best != x + w &&\n !rfbSendRectEncodingTight(cl, x_best+w_best, y_best,\n w-(x_best-x)-w_best, h_best) )\n return FALSE;\n if ( y_best + h_best != y + h &&\n !rfbSendRectEncodingTight(cl, x, y_best+h_best,\n w, h-(y_best-y)-h_best) )\n return FALSE;\n\n \/* Return after all recursive calls are done. *\/\n\n return TRUE;\n }\n\n }\n\n }\n\n \/* No suitable solid-color rectangles found. *\/\n\n return SendRectSimple(cl, x, y, w, h);\n}","target":0,"code_token_length":1129,"total_token_length":1365,"max_tokens_setting":2048} +{"idx":111184,"func":"extend_parse_config(const char *token, char *cptr)\n{\n netsnmp_extend *extension;\n char exec_name[STRMAX];\n char exec_name2[STRMAX]; \/* For use with UCD execFix directive *\/\n char exec_command[STRMAX];\n oid oid_buf[MAX_OID_LEN];\n size_t oid_len;\n extend_registration_block *eptr;\n int flags;\n int cache_timeout = 0;\n int exec_type = NS_EXTEND_ETYPE_EXEC;\n\n cptr = copy_nword(cptr, exec_name, sizeof(exec_name));\n if (strcmp(exec_name, \"-cacheTime\") == 0) {\n char cache_timeout_str[32];\n\n cptr = copy_nword(cptr, cache_timeout_str, sizeof(cache_timeout_str));\n \/* If atoi can't do the conversion, it returns 0 *\/\n cache_timeout = atoi(cache_timeout_str);\n cptr = copy_nword(cptr, exec_name, sizeof(exec_name));\n }\n if (strcmp(exec_name, \"-execType\") == 0) {\n char exec_type_str[16];\n\n cptr = copy_nword(cptr, exec_type_str, sizeof(exec_type_str));\n if (strcmp(exec_type_str, \"sh\") == 0)\n exec_type = NS_EXTEND_ETYPE_SHELL;\n else\n exec_type = NS_EXTEND_ETYPE_EXEC;\n cptr = copy_nword(cptr, exec_name, sizeof(exec_name));\n }\n if ( *exec_name == '.' ) {\n oid_len = MAX_OID_LEN - 2;\n if (0 == read_objid( exec_name, oid_buf, &oid_len )) {\n config_perror(\"ERROR: Unrecognised OID\" );\n return;\n }\n cptr = copy_nword(cptr, exec_name, sizeof(exec_name));\n if (!strcmp( token, \"sh\" ) ||\n !strcmp( token, \"exec\" )) {\n config_perror(\"ERROR: This output format has been deprecated - Please use the 'extend' directive instead\" );\n return;\n }\n } else {\n memcpy( oid_buf, ns_extend_oid, sizeof(ns_extend_oid));\n oid_len = OID_LENGTH(ns_extend_oid);\n }\n cptr = copy_nword(cptr, exec_command, sizeof(exec_command));\n \/* XXX - check 'exec_command' exists & is executable *\/\n flags = (NS_EXTEND_FLAGS_ACTIVE | NS_EXTEND_FLAGS_CONFIG);\n if (!strcmp( token, \"sh\" ) ||\n !strcmp( token, \"extend-sh\" ) ||\n !strcmp( token, \"sh2\") ||\n exec_type == NS_EXTEND_ETYPE_SHELL)\n flags |= NS_EXTEND_FLAGS_SHELL;\n if (!strcmp( token, \"execFix\" ) ||\n !strcmp( token, \"extendfix\" ) ||\n !strcmp( token, \"execFix2\" )) {\n strcpy( exec_name2, exec_name );\n strcat( exec_name, \"Fix\" );\n flags |= NS_EXTEND_FLAGS_WRITEABLE;\n \/* XXX - Check for shell... *\/\n }\n\n eptr = _register_extend( oid_buf, oid_len );\n if (!eptr) {\n snmp_log(LOG_ERR, \"Failed to register extend entry '%s' - possibly duplicate name.\\n\", exec_name );\n return;\n }\n extension = _new_extension( exec_name, flags, eptr );\n if (extension) {\n extension->command = strdup( exec_command );\n if (cptr)\n extension->args = strdup( cptr );\n if (cache_timeout != 0)\n extension->cache->timeout = cache_timeout;\n } else {\n snmp_log(LOG_ERR, \"Failed to register extend entry '%s' - possibly duplicate name.\\n\", exec_name );\n return;\n }\n\n#ifndef USING_UCD_SNMP_EXTENSIBLE_MODULE\n \/*\n * Compatability with the UCD extTable\n *\/\n if (!strcmp( token, \"execFix\" )) {\n int i;\n for ( i=0; i < num_compatability_entries; i++ ) {\n if (!strcmp( exec_name2,\n compatability_entries[i].exec_entry->token))\n break;\n }\n if ( i == num_compatability_entries )\n config_perror(\"No matching exec entry\" );\n else\n compatability_entries[ i ].efix_entry = extension;\n \n } else if (!strcmp( token, \"sh\" ) ||\n !strcmp( token, \"exec\" )) {\n if ( num_compatability_entries == max_compatability_entries ) {\n \/* XXX - should really use dynamic allocation *\/\n netsnmp_old_extend *new_compatability_entries;\n new_compatability_entries = realloc(compatability_entries,\n max_compatability_entries*2*sizeof(netsnmp_old_extend));\n if (!new_compatability_entries)\n config_perror(\"No further UCD-compatible entries\" );\n else {\n memset(new_compatability_entries+num_compatability_entries, 0,\n sizeof(netsnmp_old_extend)*max_compatability_entries);\n max_compatability_entries *= 2;\n compatability_entries = new_compatability_entries;\n }\n }\n if (num_compatability_entries != max_compatability_entries)\n compatability_entries[\n num_compatability_entries++ ].exec_entry = extension;\n }\n#endif\n}","target":0,"code_token_length":1163,"total_token_length":1399,"max_tokens_setting":2048} +{"idx":488227,"func":"static inline void ok_jpg_idct_1d_col_16(const int16_t *in, int *out) {\n static const int out_shift = 8;\n\n int t0, t1, t2;\n int p0, p1, p2, p3, p4, p5, p6, p7;\n int q0, q1, q2, q3, q4, q5, q6, q7;\n\n for (int x = 0; x < 8; x++) {\n \/\/ Quick check to avoid mults\n if (in[1] == 0 && in[2] == 0 && in[3] == 0 && in[4] == 0 &&\n in[5] == 0 && in[6] == 0 && in[7] == 0) {\n t0 = in[0] << (12 - out_shift);\n out[ 0 * 8] = t0;\n out[ 1 * 8] = t0;\n out[ 2 * 8] = t0;\n out[ 3 * 8] = t0;\n out[ 4 * 8] = t0;\n out[ 5 * 8] = t0;\n out[ 6 * 8] = t0;\n out[ 7 * 8] = t0;\n out[ 8 * 8] = t0;\n out[ 9 * 8] = t0;\n out[10 * 8] = t0;\n out[11 * 8] = t0;\n out[12 * 8] = t0;\n out[13 * 8] = t0;\n out[14 * 8] = t0;\n out[15 * 8] = t0;\n } else {\n ok_jpg_idct_1d_16(in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]);\n out[ 0 * 8] = (p0 + q0) >> out_shift;\n out[ 1 * 8] = (p1 + q1) >> out_shift;\n out[ 2 * 8] = (p2 + q2) >> out_shift;\n out[ 3 * 8] = (p3 + q3) >> out_shift;\n out[ 4 * 8] = (p4 + q4) >> out_shift;\n out[ 5 * 8] = (p5 + q5) >> out_shift;\n out[ 6 * 8] = (p6 + q6) >> out_shift;\n out[ 7 * 8] = (p7 + q7) >> out_shift;\n out[ 8 * 8] = (p7 - q7) >> out_shift;\n out[ 9 * 8] = (p6 - q6) >> out_shift;\n out[10 * 8] = (p5 - q5) >> out_shift;\n out[11 * 8] = (p4 - q4) >> out_shift;\n out[12 * 8] = (p3 - q3) >> out_shift;\n out[13 * 8] = (p2 - q2) >> out_shift;\n out[14 * 8] = (p1 - q1) >> out_shift;\n out[15 * 8] = (p0 - q0) >> out_shift;\n }\n\n in += 8;\n out++;\n }\n}","target":0,"code_token_length":810,"total_token_length":1046,"max_tokens_setting":2048} +{"idx":345623,"func":"static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int extended)\n{\n\tzval *IM, *EXT = NULL;\n\tgdImagePtr im=NULL;\n\tlong col = -1, x = -1, y = -1;\n\tint str_len, fontname_len, i, brect[8];\n\tdouble ptsize, angle;\n\tchar *str = NULL, *fontname = NULL;\n\tchar *error = NULL;\n\tint argc = ZEND_NUM_ARGS();\n#if HAVE_GD_STRINGFTEX\n\tgdFTStringExtra strex = {0};\n#endif\n\n#if !HAVE_GD_STRINGFTEX\n\tassert(!extended);\n#endif\n\n\tif (mode == TTFTEXT_BBOX) {\n\t\tif (argc < 4 || argc > ((extended) ? 5 : 4)) {\n\t\t\tZEND_WRONG_PARAM_COUNT();\n\t\t} else if (zend_parse_parameters(argc TSRMLS_CC, \"ddss|a\", &ptsize, &angle, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) {\n\t\t\tRETURN_FALSE;\n\t\t}\n\t} else {\n\t\tif (argc < 8 || argc > ((extended) ? 9 : 8)) {\n\t\t\tZEND_WRONG_PARAM_COUNT();\n\t\t} else if (zend_parse_parameters(argc TSRMLS_CC, \"rddlllss|a\", &IM, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) {\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\t}\n\n\t\/* convert angle to radians *\/\n\tangle = angle * (M_PI\/180);\n\n#if HAVE_GD_STRINGFTEX\n\tif (extended && EXT) {\t\/* parse extended info *\/\n\t\tHashPosition pos;\n\n\t\t\/* walk the assoc array *\/\n\t\tzend_hash_internal_pointer_reset_ex(HASH_OF(EXT), &pos);\n\t\tdo {\n\t\t\tzval ** item;\n\t\t\tchar * key;\n\t\t\tulong num_key;\n\n\t\t\tif (zend_hash_get_current_key_ex(HASH_OF(EXT), &key, NULL, &num_key, 0, &pos) != HASH_KEY_IS_STRING) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (zend_hash_get_current_data_ex(HASH_OF(EXT), (void **) &item, &pos) == FAILURE) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\n\t\t\tif (strcmp(\"linespacing\", key) == 0) {\n\t\t\t\tconvert_to_double_ex(item);\n\t\t\t\tstrex.flags |= gdFTEX_LINESPACE;\n\t\t\t\tstrex.linespacing = Z_DVAL_PP(item);\n\t\t\t}\n\n\t\t} while (zend_hash_move_forward_ex(HASH_OF(EXT), &pos) == SUCCESS);\n\t}\n#endif\n\n#ifdef VIRTUAL_DIR\n\t{\n\t\tchar tmp_font_path[MAXPATHLEN];\n\n\t\tif (!VCWD_REALPATH(fontname, tmp_font_path)) {\n\t\t\tfontname = NULL;\n\t\t}\n\t}\n#endif\n\n\tPHP_GD_CHECK_OPEN_BASEDIR(fontname, \"Invalid font filename\");\n\t\n#ifdef USE_GD_IMGSTRTTF\n# if HAVE_GD_STRINGFTEX\n\tif (extended) {\n\t\terror = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex);\n\t}\n\telse\n# endif\n\n# if HAVE_GD_STRINGFT\n\terror = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str);\n# elif HAVE_GD_STRINGTTF\n\terror = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y, str);\n# endif\n\n#endif\n\n\tif (error) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"%s\", error);\n\t\tRETURN_FALSE;\n\t}\n\n\tarray_init(return_value);\n\n\t\/* return array with the text's bounding box *\/\n\tfor (i = 0; i < 8; i++) {\n\t\tadd_next_index_long(return_value, brect[i]);\n\t}\n}","target":1,"code_token_length":881,"total_token_length":1117,"max_tokens_setting":2048} +{"idx":49253,"func":"TEST(FormatterTest, RuntimePrecision) {\n char format_str[BUFFER_SIZE];\n safe_sprintf(format_str, \"{0:.{%u\", UINT_MAX);\n increment(format_str + 5);\n EXPECT_THROW_MSG(format(format_str, 0), FormatError, \"number is too big\");\n std::size_t size = std::strlen(format_str);\n format_str[size] = '}';\n format_str[size + 1] = 0;\n EXPECT_THROW_MSG(format(format_str, 0), FormatError, \"number is too big\");\n format_str[size + 1] = '}';\n format_str[size + 2] = 0;\n EXPECT_THROW_MSG(format(format_str, 0), FormatError, \"number is too big\");\n\n EXPECT_THROW_MSG(format(\"{0:.{\", 0),\n FormatError, \"invalid format string\");\n EXPECT_THROW_MSG(format(\"{0:.{}\", 0),\n FormatError, \"cannot switch from manual to automatic argument indexing\");\n EXPECT_THROW_MSG(format(\"{0:.{?}}\", 0),\n FormatError, \"invalid format string\");\n EXPECT_THROW_MSG(format(\"{0:.{1}\", 0, 0),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0),\n FormatError, \"argument index out of range\");\n\n EXPECT_THROW_MSG(format(\"{0:.{0:}}\", 0),\n FormatError, \"invalid format string\");\n\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, -1),\n FormatError, \"negative precision\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, (INT_MAX + 1u)),\n FormatError, \"number is too big\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, -1l),\n FormatError, \"negative precision\");\n if (fmt::internal::const_check(sizeof(long) > sizeof(int))) {\n long value = INT_MAX;\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, (value + 1)),\n FormatError, \"number is too big\");\n }\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, (INT_MAX + 1ul)),\n FormatError, \"number is too big\");\n\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, '0'),\n FormatError, \"precision is not integer\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 0, 0.0),\n FormatError, \"precision is not integer\");\n\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 42, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", 42, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 42u, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", 42u, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 42l, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", 42l, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 42ul, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", 42ul, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 42ll, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", 42ll, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", 42ull, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", 42ull, 2),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:3.{1}}\", 'x', 0),\n FormatError, \"precision not allowed in integer format specifier\");\n EXPECT_EQ(\"1.2\", format(\"{0:.{1}}\", 1.2345, 2));\n EXPECT_EQ(\"1.2\", format(\"{1:.{0}}\", 2, 1.2345l));\n\n EXPECT_THROW_MSG(format(\"{0:.{1}}\", reinterpret_cast(0xcafe), 2),\n FormatError, \"precision not allowed in pointer format specifier\");\n EXPECT_THROW_MSG(format(\"{0:.{1}f}\", reinterpret_cast(0xcafe), 2),\n FormatError, \"precision not allowed in pointer format specifier\");\n\n EXPECT_EQ(\"st\", format(\"{0:.{1}}\", \"str\", 2));\n}","target":0,"code_token_length":1123,"total_token_length":1359,"max_tokens_setting":2048} +{"idx":387982,"func":"png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,\n png_uint_32 length, int keep)\n{\n int handled = 0; \/* the chunk was handled *\/\n\n png_debug(1, \"in png_handle_unknown\");\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n \/* NOTE: this code is based on the code in libpng-1.4.12 except for fixing\n * the bug which meant that setting a non-default behavior for a specific\n * chunk would be ignored (the default was always used unless a user\n * callback was installed).\n *\n * 'keep' is the value from the png_chunk_unknown_handling, the setting for\n * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it\n * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here.\n * This is just an optimization to avoid multiple calls to the lookup\n * function.\n *\/\n# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);\n# endif\n# endif\n\n \/* One of the following methods will read the chunk or skip it (at least one\n * of these is always defined because this is the only way to switch on\n * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)\n *\/\n# ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n \/* The user callback takes precedence over the chunk keep value, but the\n * keep value is still required to validate a save of a critical chunk.\n *\/\n if (png_ptr->read_user_chunk_fn != NULL)\n {\n if (png_cache_unknown_chunk(png_ptr, length) != 0)\n {\n \/* Callback to user unknown chunk handler *\/\n int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,\n &png_ptr->unknown_chunk);\n\n \/* ret is:\n * negative: An error occurred; png_chunk_error will be called.\n * zero: The chunk was not handled, the chunk will be discarded\n * unless png_set_keep_unknown_chunks has been used to set\n * a 'keep' behavior for this particular chunk, in which\n * case that will be used. A critical chunk will cause an\n * error at this point unless it is to be saved.\n * positive: The chunk was handled, libpng will ignore\/discard it.\n *\/\n if (ret < 0)\n png_chunk_error(png_ptr, \"error in user chunk\");\n\n else if (ret == 0)\n {\n \/* If the keep value is 'default' or 'never' override it, but\n * still error out on critical chunks unless the keep value is\n * 'always' While this is weird it is the behavior in 1.4.12.\n * A possible improvement would be to obey the value set for the\n * chunk, but this would be an API change that would probably\n * damage some applications.\n *\n * The png_app_warning below catches the case that matters, where\n * the application has not set specific save or ignore for this\n * chunk or global save or ignore.\n *\/\n if (keep < PNG_HANDLE_CHUNK_IF_SAFE)\n {\n# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)\n {\n png_chunk_warning(png_ptr, \"Saving unknown chunk:\");\n png_app_warning(png_ptr,\n \"forcing save of an unhandled chunk;\"\n \" please call png_set_keep_unknown_chunks\");\n \/* with keep = PNG_HANDLE_CHUNK_IF_SAFE *\/\n }\n# endif\n keep = PNG_HANDLE_CHUNK_IF_SAFE;\n }\n }\n\n else \/* chunk was handled *\/\n {\n handled = 1;\n \/* Critical chunks can be safely discarded at this point. *\/\n keep = PNG_HANDLE_CHUNK_NEVER;\n }\n }\n\n else\n keep = PNG_HANDLE_CHUNK_NEVER; \/* insufficient memory *\/\n }\n\n else\n \/* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk *\/\n# endif \/* READ_USER_CHUNKS *\/\n\n# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n {\n \/* keep is currently just the per-chunk setting, if there was no\n * setting change it to the global default now (not that this may\n * still be AS_DEFAULT) then obtain the cache of the chunk if required,\n * if not simply skip the chunk.\n *\/\n if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)\n keep = png_ptr->unknown_default;\n\n if (keep == PNG_HANDLE_CHUNK_ALWAYS ||\n (keep == PNG_HANDLE_CHUNK_IF_SAFE &&\n PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))\n {\n if (png_cache_unknown_chunk(png_ptr, length) == 0)\n keep = PNG_HANDLE_CHUNK_NEVER;\n }\n\n else\n png_crc_finish(png_ptr, length);\n }\n# else\n# ifndef PNG_READ_USER_CHUNKS_SUPPORTED\n# error no method to support READ_UNKNOWN_CHUNKS\n# endif\n\n {\n \/* If here there is no read callback pointer set and no support is\n * compiled in to just save the unknown chunks, so simply skip this\n * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then\n * the app has erroneously asked for unknown chunk saving when there\n * is no support.\n *\/\n if (keep > PNG_HANDLE_CHUNK_NEVER)\n png_app_error(png_ptr, \"no unknown chunk support available\");\n\n png_crc_finish(png_ptr, length);\n }\n# endif\n\n# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n \/* Now store the chunk in the chunk list if appropriate, and if the limits\n * permit it.\n *\/\n if (keep == PNG_HANDLE_CHUNK_ALWAYS ||\n (keep == PNG_HANDLE_CHUNK_IF_SAFE &&\n PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))\n {\n# ifdef PNG_USER_LIMITS_SUPPORTED\n switch (png_ptr->user_chunk_cache_max)\n {\n case 2:\n png_ptr->user_chunk_cache_max = 1;\n png_chunk_benign_error(png_ptr, \"no space in chunk cache\");\n \/* FALL THROUGH *\/\n case 1:\n \/* NOTE: prior to 1.6.0 this case resulted in an unknown critical\n * chunk being skipped, now there will be a hard error below.\n *\/\n break;\n\n default: \/* not at limit *\/\n --(png_ptr->user_chunk_cache_max);\n \/* FALL THROUGH *\/\n case 0: \/* no limit *\/\n# endif \/* USER_LIMITS *\/\n \/* Here when the limit isn't reached or when limits are compiled\n * out; store the chunk.\n *\/\n png_set_unknown_chunks(png_ptr, info_ptr,\n &png_ptr->unknown_chunk, 1);\n handled = 1;\n# ifdef PNG_USER_LIMITS_SUPPORTED\n break;\n }\n# endif\n }\n# else \/* no store support: the chunk must be handled by the user callback *\/\n PNG_UNUSED(info_ptr)\n# endif\n\n \/* Regardless of the error handling below the cached data (if any) can be\n * freed now. Notice that the data is not freed if there is a png_error, but\n * it will be freed by destroy_read_struct.\n *\/\n if (png_ptr->unknown_chunk.data != NULL)\n png_free(png_ptr, png_ptr->unknown_chunk.data);\n png_ptr->unknown_chunk.data = NULL;\n\n#else \/* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED *\/\n \/* There is no support to read an unknown chunk, so just skip it. *\/\n png_crc_finish(png_ptr, length);\n PNG_UNUSED(info_ptr)\n PNG_UNUSED(keep)\n#endif \/* !READ_UNKNOWN_CHUNKS *\/\n\n \/* Check for unhandled critical chunks *\/\n if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))\n png_chunk_error(png_ptr, \"unhandled critical chunk\");\n}","target":0,"code_token_length":1698,"total_token_length":1934,"max_tokens_setting":2048} +{"idx":14509,"func":"int _dbus_printf_string_upper_bound (const char *format,\n va_list args)\n{\n \/* MSVCRT's vsnprintf semantics are a bit different *\/\n char buf[1024];\n int bufsize;\n int len;\n \n bufsize = sizeof (buf);\n len = _vsnprintf (buf, bufsize - 1, format, args);\n \n while (len == -1) \/* try again *\/\n {\n\n p = malloc (bufsize);\n\n if (p == NULL)\n return -1;\n\n if (p == NULL)\n return -1;\n \n len = _vsnprintf (p, bufsize - 1, format, args);\n free (p);\n }\n * Returns the UTF-16 form of a UTF-8 string. The result should be\n * freed with dbus_free() when no longer needed.\n *\n * @param str the UTF-8 string\n * @param error return location for error code\n *\/\nwchar_t *\n_dbus_win_utf8_to_utf16 (const char *str,\n DBusError *error)\n{\n DBusString s;\n int n;\n wchar_t *retval;\n\n _dbus_string_init_const (&s, str);\n\n if (!_dbus_string_validate_utf8 (&s, 0, _dbus_string_get_length (&s)))\n {\n dbus_set_error_const (error, DBUS_ERROR_FAILED, \"Invalid UTF-8\");\n return NULL;\n }\n\n n = MultiByteToWideChar (CP_UTF8, 0, str, -1, NULL, 0);\n\n if (n == 0)\n {\n _dbus_win_set_error_from_win_error (error, GetLastError ());\n return NULL;\n }\n\n retval = dbus_new (wchar_t, n);\n\n if (!retval)\n {\n _DBUS_SET_OOM (error);\n return NULL;\n }\n\n if (MultiByteToWideChar (CP_UTF8, 0, str, -1, retval, n) != n)\n {\n dbus_free (retval);\n dbus_set_error_const (error, DBUS_ERROR_FAILED, \"MultiByteToWideChar inconsistency\");\n return NULL;\n }\n\n return retval;\n}\n\n\/**\n * Returns the UTF-8 form of a UTF-16 string. The result should be\n * freed with dbus_free() when no longer needed.\n *\n * @param str the UTF-16 string\n * @param error return location for error code\n *\/\nchar *\n_dbus_win_utf16_to_utf8 (const wchar_t *str,\n DBusError *error)\n{\n int n;\n char *retval;\n\n n = WideCharToMultiByte (CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);\n\n if (n == 0)\n {\n _dbus_win_set_error_from_win_error (error, GetLastError ());\n return NULL;\n }\n\n retval = dbus_malloc (n);\n\n if (!retval)\n {\n _DBUS_SET_OOM (error);\n return NULL;\n }\n\n if (WideCharToMultiByte (CP_UTF8, 0, str, -1, retval, n, NULL, NULL) != n)\n {\n dbus_free (retval);\n dbus_set_error_const (error, DBUS_ERROR_FAILED, \"WideCharToMultiByte inconsistency\");\n return NULL;\n }\n\n return retval;\n}\n\n\n\n\n\n\n\/************************************************************************\n \n \n ************************************************************************\/\n\ndbus_bool_t\n_dbus_win_account_to_sid (const wchar_t *waccount,\n void \t **ppsid,\n DBusError \t *error)\n{\n dbus_bool_t retval = FALSE;\n DWORD sid_length, wdomain_length;\n SID_NAME_USE use;\n wchar_t *wdomain;\n\n *ppsid = NULL;\n\n sid_length = 0;\n wdomain_length = 0;\n if (!LookupAccountNameW (NULL, waccount, NULL, &sid_length,\n NULL, &wdomain_length, &use) &&\n GetLastError () != ERROR_INSUFFICIENT_BUFFER)\n {\n _dbus_win_set_error_from_win_error (error, GetLastError ());\n return FALSE;\n }\n\n *ppsid = dbus_malloc (sid_length);\n if (!*ppsid)\n {\n _DBUS_SET_OOM (error);\n return FALSE;\n }\n\n wdomain = dbus_new (wchar_t, wdomain_length);\n if (!wdomain)\n {\n _DBUS_SET_OOM (error);\n goto out1;\n }\n\n if (!LookupAccountNameW (NULL, waccount, (PSID) *ppsid, &sid_length,\n wdomain, &wdomain_length, &use))\n {\n _dbus_win_set_error_from_win_error (error, GetLastError ());\n goto out2;\n }\n\n if (!IsValidSid ((PSID) *ppsid))\n {\n dbus_set_error_const (error, DBUS_ERROR_FAILED, \"Invalid SID\");\n goto out2;\n }\n\n retval = TRUE;\n\nout2:\n dbus_free (wdomain);\nout1:\n if (!retval)\n {\n dbus_free (*ppsid);\n *ppsid = NULL;\n }\n\n return retval;\n}\n\n\/** @} end of sysdeps-win *\/\n","target":1,"code_token_length":1103,"total_token_length":1339,"max_tokens_setting":2048} +{"idx":492709,"func":"create_user_authz(authz_full_t *authz,\n const char *repository,\n const char *user,\n apr_pool_t *result_pool,\n apr_pool_t *scratch_pool)\n{\n int i;\n node_t *root = create_node(NULL, result_pool);\n construction_context_t *ctx = create_construction_context(scratch_pool);\n\n \/* Use a separate sub-pool to keep memory usage tight. *\/\n apr_pool_t *subpool = svn_pool_create(scratch_pool);\n\n \/* Find all ACLs for REPOSITORY. *\/\n apr_array_header_t *acls = apr_array_make(subpool, authz->acls->nelts,\n sizeof(authz_acl_t *));\n for (i = 0; i < authz->acls->nelts; ++i)\n {\n const authz_acl_t *acl = &APR_ARRAY_IDX(authz->acls, i, authz_acl_t);\n if (svn_authz__acl_applies_to_repo(acl, repository))\n {\n \/* ACLs in the AUTHZ are sorted by path and repository.\n * So, if there is a rule for the repo and a global rule for the\n * same path, we will detect them here. *\/\n if (acls->nelts)\n {\n const authz_acl_t *prev_acl\n = APR_ARRAY_IDX(acls, acls->nelts - 1, const authz_acl_t *);\n if (svn_authz__compare_paths(&prev_acl->rule, &acl->rule) == 0)\n {\n svn_boolean_t global_acl_applies;\n svn_boolean_t repos_acl_applies;\n\n \/* Previous ACL is a global rule. *\/\n SVN_ERR_ASSERT_NO_RETURN(!strcmp(prev_acl->rule.repos,\n AUTHZ_ANY_REPOSITORY));\n \/* Current ACL is a per-repository rule. *\/\n SVN_ERR_ASSERT_NO_RETURN(strcmp(acl->rule.repos,\n AUTHZ_ANY_REPOSITORY));\n\n global_acl_applies =\n svn_authz__get_acl_access(NULL, prev_acl, user, repository);\n repos_acl_applies =\n svn_authz__get_acl_access(NULL, acl, user, repository);\n\n \/* Prefer rules which apply to both this user and this path\n * over rules which apply only to the path. In cases where\n * both rules apply to user and path, always prefer the\n * repository-specific rule. *\/\n if (!global_acl_applies || repos_acl_applies)\n {\n apr_array_pop(acls);\n APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl;\n }\n }\n else\n APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl;\n }\n else\n APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl;\n }\n }\n\n \/* Filtering and tree construction. *\/\n for (i = 0; i < acls->nelts; ++i)\n process_acl(ctx, APR_ARRAY_IDX(acls, i, const authz_acl_t *),\n root, repository, user, result_pool, subpool);\n\n \/* If there is no relevant rule at the root node, the \"no access\" default\n * applies. Give it a SEQUENCE_NUMBER that will never overrule others. *\/\n if (!has_local_rule(&root->rights))\n {\n root->rights.access.sequence_number = 0;\n root->rights.access.rights = authz_access_none;\n }\n\n \/* Trim the tree.\n *\n * We can't do pattern comparison, so for most pattern rules we cannot\n * say that a set of rules \"eclipses\" \/ overrides a given other set of\n * rules for all possible paths. That limits the accuracy of our check\n * for recursive access in similar ways than for non-pattern rules.\n *\n * However, the user expects a rule ending with \"**\" to eclipse any older\n * rule in that sub-tree recursively. So, this trim function removes\n * eclipsed nodes from the tree.\n *\/\n svn_pool_clear(subpool);\n trim_tree(root, NO_SEQUENCE_NUMBER, subpool);\n\n \/* Calculate recursive rights.\n *\n * This is a bottom-up calculation of the range of access rights\n * specified anywhere in the respective sub-tree, including the base\n * node itself.\n *\n * To prevent additional finalization passes, we piggy-back the addition\n * of the ordering links of the prefix and suffix sub-node rules.\n *\/\n svn_pool_clear(subpool);\n finalize_tree(root, &root->rights, subpool);\n\n \/* Done. *\/\n svn_pool_destroy(subpool);\n return root;\n}","target":0,"code_token_length":992,"total_token_length":1228,"max_tokens_setting":2048} +{"idx":352887,"func":"__libc_res_nquery(res_state statp,\n\t\t const char *name,\t\/* domain name *\/\n\t\t int class, int type,\t\/* class and type of query *\/\n\t\t u_char *answer,\t\/* buffer to put answer *\/\n\t\t int anslen,\t\t\/* size of answer buffer *\/\n\t\t u_char **answerp,\t\/* if buffer needs to be enlarged *\/\n\t\t u_char **answerp2,\n\t\t int *nanswerp2,\n\t\t int *resplen2,\n\t\t int *answerp2_malloced)\n{\n\tHEADER *hp = (HEADER *) answer;\n\tHEADER *hp2;\n\tint n, use_malloc = 0;\n\tu_int oflags = statp->_flags;\n\n\tsize_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;\n\tu_char *buf = alloca (bufsize);\n\tu_char *query1 = buf;\n\tint nquery1 = -1;\n\tu_char *query2 = NULL;\n\tint nquery2 = 0;\n\n again:\n\thp->rcode = NOERROR;\t\/* default *\/\n\n#ifdef DEBUG\n\tif (statp->options & RES_DEBUG)\n\t\tprintf(\";; res_query(%s, %d, %d)\\n\", name, class, type);\n#endif\n\n\tif (type == T_UNSPEC)\n\t {\n\t n = res_nmkquery(statp, QUERY, name, class, T_A, NULL, 0, NULL,\n\t\t\t query1, bufsize);\n\t if (n > 0)\n\t {\n\t\tif ((oflags & RES_F_EDNS0ERR) == 0\n\t\t && (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0)\n\t\t {\n\t\t n = __res_nopt(statp, n, query1, bufsize, anslen \/ 2);\n\t\t if (n < 0)\n\t\t goto unspec_nomem;\n\t\t }\n\n\t\tnquery1 = n;\n\t\t\/* Align the buffer. *\/\n\t\tint npad = ((nquery1 + __alignof__ (HEADER) - 1)\n\t\t\t & ~(__alignof__ (HEADER) - 1)) - nquery1;\n\t\tif (n > bufsize - npad)\n\t\t {\n\t\t n = -1;\n\t\t goto unspec_nomem;\n\t\t }\n\t\tint nused = n + npad;\n\t\tquery2 = buf + nused;\n\t\tn = res_nmkquery(statp, QUERY, name, class, T_AAAA, NULL, 0,\n\t\t\t\t NULL, query2, bufsize - nused);\n\t\tif (n > 0\n\t\t && (oflags & RES_F_EDNS0ERR) == 0\n\t\t && (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0)\n\t\t n = __res_nopt(statp, n, query2, bufsize - nused - n,\n\t\t\t\t anslen \/ 2);\n\t\tnquery2 = n;\n\t }\n\n\t unspec_nomem:;\n\t }\n\telse\n\t {\n\t n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,\n\t\t\t query1, bufsize);\n\n\t if (n > 0\n\t\t&& (oflags & RES_F_EDNS0ERR) == 0\n\t\t&& (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0)\n\t n = __res_nopt(statp, n, query1, bufsize, anslen);\n\n\t nquery1 = n;\n\t }\n\n\tif (__builtin_expect (n <= 0, 0) && !use_malloc) {\n\t\t\/* Retry just in case res_nmkquery failed because of too\n\t\t short buffer. Shouldn't happen. *\/\n\t\tbufsize = (type == T_UNSPEC ? 2 : 1) * MAXPACKET;\n\t\tbuf = malloc (bufsize);\n\t\tif (buf != NULL) {\n\t\t\tquery1 = buf;\n\t\t\tuse_malloc = 1;\n\t\t\tgoto again;\n\t\t}\n\t}\n\tif (__glibc_unlikely (n <= 0)) {\n\t\t\/* If the query choked with EDNS0, retry without EDNS0. *\/\n\t\tif ((statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC)) != 0\n\t\t && ((oflags ^ statp->_flags) & RES_F_EDNS0ERR) != 0) {\n\t\t\tstatp->_flags |= RES_F_EDNS0ERR;\n#ifdef DEBUG\n\t\t\tif (statp->options & RES_DEBUG)\n\t\t\t\tprintf(\";; res_nquery: retry without EDNS0\\n\");\n#endif\n\t\t\tgoto again;\n\t\t}\n#ifdef DEBUG\n\t\tif (statp->options & RES_DEBUG)\n\t\t\tprintf(\";; res_query: mkquery failed\\n\");\n#endif\n\t\tRES_SET_H_ERRNO(statp, NO_RECOVERY);\n\t\tif (use_malloc)\n\t\t\tfree (buf);\n\t\treturn (n);\n\t}\n\tassert (answerp == NULL || (void *) *answerp == (void *) answer);\n\tn = __libc_res_nsend(statp, query1, nquery1, query2, nquery2, answer,\n\t\t\t anslen, answerp, answerp2, nanswerp2, resplen2,\n\t\t\t answerp2_malloced);\n\tif (use_malloc)\n\t\tfree (buf);\n\tif (n < 0) {\n#ifdef DEBUG\n\t\tif (statp->options & RES_DEBUG)\n\t\t\tprintf(\";; res_query: send error\\n\");\n#endif\n\t\tRES_SET_H_ERRNO(statp, TRY_AGAIN);\n\t\treturn (n);\n\t}\n\n\tif (answerp != NULL)\n\t \/* __libc_res_nsend might have reallocated the buffer. *\/\n\t hp = (HEADER *) *answerp;\n\n\t\/* We simplify the following tests by assigning HP to HP2 or\n\t vice versa. It is easy to verify that this is the same as\n\t ignoring all tests of HP or HP2. *\/\n\tif (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER))\n\t {\n\t hp2 = hp;\n\t }\n\telse\n\t {\n\t hp2 = (HEADER *) *answerp2;\n\t if (n < (int) sizeof (HEADER))\n\t {\n\t hp = hp2;\n\t }\n\t }\n\n\t\/* Make sure both hp and hp2 are defined *\/\n\tassert((hp != NULL) && (hp2 != NULL));\n\n\tif ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0)\n\t && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) {\n#ifdef DEBUG\n\t\tif (statp->options & RES_DEBUG) {\n\t\t\tprintf(\";; rcode = %d, ancount=%d\\n\", hp->rcode,\n\t\t\t ntohs(hp->ancount));\n\t\t\tif (hp != hp2)\n\t\t\t printf(\";; rcode2 = %d, ancount2=%d\\n\", hp2->rcode,\n\t\t\t\t ntohs(hp2->ancount));\n\t\t}\n#endif\n\t\tswitch (hp->rcode == NOERROR ? hp2->rcode : hp->rcode) {\n\t\tcase NXDOMAIN:\n\t\t\tif ((hp->rcode == NOERROR && ntohs (hp->ancount) != 0)\n\t\t\t || (hp2->rcode == NOERROR\n\t\t\t\t&& ntohs (hp2->ancount) != 0))\n\t\t\t\tgoto success;\n\t\t\tRES_SET_H_ERRNO(statp, HOST_NOT_FOUND);\n\t\t\tbreak;\n\t\tcase SERVFAIL:\n\t\t\tRES_SET_H_ERRNO(statp, TRY_AGAIN);\n\t\t\tbreak;\n\t\tcase NOERROR:\n\t\t\tif (ntohs (hp->ancount) != 0\n\t\t\t || ntohs (hp2->ancount) != 0)\n\t\t\t\tgoto success;\n\t\t\tRES_SET_H_ERRNO(statp, NO_DATA);\n\t\t\tbreak;\n\t\tcase FORMERR:\n\t\tcase NOTIMP:\n\t\t\t\/* Servers must not reply to AAAA queries with\n\t\t\t NOTIMP etc but some of them do. *\/\n\t\t\tif ((hp->rcode == NOERROR && ntohs (hp->ancount) != 0)\n\t\t\t || (hp2->rcode == NOERROR\n\t\t\t\t&& ntohs (hp2->ancount) != 0))\n\t\t\t\tgoto success;\n\t\t\t\/* FALLTHROUGH *\/\n\t\tcase REFUSED:\n\t\tdefault:\n\t\t\tRES_SET_H_ERRNO(statp, NO_RECOVERY);\n\t\t\tbreak;\n\t\t}\n\t\treturn (-1);\n\t}\n success:\n\treturn (n);\n}","target":1,"code_token_length":1799,"total_token_length":2035,"max_tokens_setting":2048} +{"idx":42543,"func":"add_bwrap_wrapper (FlatpakBwrap *bwrap,\n const char *app_info_path,\n GError **error)\n{\n glnx_autofd int app_info_fd = -1;\n g_auto(GLnxDirFdIterator) dir_iter = { 0 };\n struct dirent *dent;\n g_autofree char *user_runtime_dir = flatpak_get_real_xdg_runtime_dir ();\n g_autofree char *proxy_socket_dir = g_build_filename (user_runtime_dir, \".dbus-proxy\/\", NULL);\n\n app_info_fd = open (app_info_path, O_RDONLY | O_CLOEXEC);\n if (app_info_fd == -1)\n return glnx_throw_errno_prefix (error, _(\"Failed to open app info file\"));\n\n if (!glnx_dirfd_iterator_init_at (AT_FDCWD, \"\/\", FALSE, &dir_iter, error))\n return FALSE;\n\n flatpak_bwrap_add_arg (bwrap, flatpak_get_bwrap ());\n\n while (TRUE)\n {\n glnx_autofd int o_path_fd = -1;\n struct statfs stfs;\n\n if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dir_iter, &dent, NULL, error))\n return FALSE;\n\n if (dent == NULL)\n break;\n\n if (strcmp (dent->d_name, \".flatpak-info\") == 0)\n continue;\n\n \/* O_PATH + fstatfs is the magic that we need to statfs without automounting the target *\/\n o_path_fd = openat (dir_iter.fd, dent->d_name, O_PATH | O_NOFOLLOW | O_CLOEXEC);\n if (o_path_fd == -1 || fstatfs (o_path_fd, &stfs) != 0 || stfs.f_type == AUTOFS_SUPER_MAGIC)\n continue; \/* AUTOFS mounts are risky and can cause us to block (see issue #1633), so ignore it. Its unlikely the proxy needs such a directory. *\/\n\n if (dent->d_type == DT_DIR)\n {\n if (strcmp (dent->d_name, \"tmp\") == 0 ||\n strcmp (dent->d_name, \"var\") == 0 ||\n strcmp (dent->d_name, \"run\") == 0)\n flatpak_bwrap_add_arg (bwrap, \"--bind\");\n else\n flatpak_bwrap_add_arg (bwrap, \"--ro-bind\");\n\n flatpak_bwrap_add_arg_printf (bwrap, \"\/%s\", dent->d_name);\n flatpak_bwrap_add_arg_printf (bwrap, \"\/%s\", dent->d_name);\n }\n else if (dent->d_type == DT_LNK)\n {\n g_autofree gchar *target = NULL;\n\n target = glnx_readlinkat_malloc (dir_iter.fd, dent->d_name,\n NULL, error);\n if (target == NULL)\n return FALSE;\n flatpak_bwrap_add_args (bwrap, \"--symlink\", target, NULL);\n flatpak_bwrap_add_arg_printf (bwrap, \"\/%s\", dent->d_name);\n }\n }\n\n flatpak_bwrap_add_args (bwrap, \"--bind\", proxy_socket_dir, proxy_socket_dir, NULL);\n\n \/* This is a file rather than a bind mount, because it will then\n not be unmounted from the namespace when the namespace dies. *\/\n flatpak_bwrap_add_args_data_fd (bwrap, \"--file\", glnx_steal_fd (&app_info_fd), \"\/.flatpak-info\");\n\n if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error))\n return FALSE;\n\n return TRUE;\n}","target":0,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048} +{"idx":347385,"func":"static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, void *userdata) {\n _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;\n union autofs_v5_packet_union packet;\n Automount *a = AUTOMOUNT(userdata);\n struct stat st;\n Unit *trigger;\n int r;\n\n assert(a);\n assert(fd == a->pipe_fd);\n\n if (events != EPOLLIN) {\n log_unit_error(UNIT(a), \"Got invalid poll event %\"PRIu32\" on pipe (fd=%d)\", events, fd);\n goto fail;\n }\n\n r = loop_read_exact(a->pipe_fd, &packet, sizeof(packet), true);\n if (r < 0) {\n log_unit_error_errno(UNIT(a), r, \"Invalid read from pipe: %m\");\n goto fail;\n }\n\n switch (packet.hdr.type) {\n\n case autofs_ptype_missing_direct:\n\n if (packet.v5_packet.pid > 0) {\n _cleanup_free_ char *p = NULL;\n\n get_process_comm(packet.v5_packet.pid, &p);\n log_unit_info(UNIT(a), \"Got automount request for %s, triggered by %\"PRIu32\" (%s)\", a->where, packet.v5_packet.pid, strna(p));\n } else\n log_unit_debug(UNIT(a), \"Got direct mount request on %s\", a->where);\n\n r = set_ensure_allocated(&a->tokens, NULL);\n if (r < 0) {\n log_unit_error(UNIT(a), \"Failed to allocate token set.\");\n goto fail;\n }\n\n r = set_put(a->tokens, UINT_TO_PTR(packet.v5_packet.wait_queue_token));\n if (r < 0) {\n log_unit_error_errno(UNIT(a), r, \"Failed to remember token: %m\");\n goto fail;\n }\n\n automount_enter_runnning(a);\n break;\n\n case autofs_ptype_expire_direct:\n log_unit_debug(UNIT(a), \"Got direct umount request on %s\", a->where);\n\n automount_stop_expire(a);\n\n r = set_ensure_allocated(&a->expire_tokens, NULL);\n if (r < 0) {\n log_unit_error(UNIT(a), \"Failed to allocate token set.\");\n goto fail;\n }\n\n r = set_put(a->expire_tokens, UINT_TO_PTR(packet.v5_packet.wait_queue_token));\n if (r < 0) {\n log_unit_error_errno(UNIT(a), r, \"Failed to remember token: %m\");\n goto fail;\n }\n\n \/* Before we do anything, let's see if somebody is playing games with us? *\/\n if (lstat(a->where, &st) < 0) {\n log_unit_warning_errno(UNIT(a), errno, \"Failed to stat automount point: %m\");\n goto fail;\n }\n\n if (!S_ISDIR(st.st_mode) || st.st_dev == a->dev_id) {\n log_unit_info(UNIT(a), \"Automount point already unmounted?\");\n automount_send_ready(a, a->expire_tokens, 0);\n break;\n }\n\n trigger = UNIT_TRIGGER(UNIT(a));\n if (!trigger) {\n log_unit_error(UNIT(a), \"Unit to trigger vanished.\");\n goto fail;\n }\n\n r = manager_add_job(UNIT(a)->manager, JOB_STOP, trigger, JOB_REPLACE, &error, NULL);\n if (r < 0) {\n log_unit_warning(UNIT(a), \"Failed to queue umount startup job: %s\", bus_error_message(&error, r));\n goto fail;\n }\n break;\n\n default:\n log_unit_error(UNIT(a), \"Received unknown automount request %i\", packet.hdr.type);\n break;\n }\n\n return 0;\n\nfail:\n automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);\n return 0;\n}","target":1,"code_token_length":849,"total_token_length":1085,"max_tokens_setting":2048} +{"idx":302450,"func":"GPMF_ERR GPMF_Validate(GPMF_stream *ms, GPMF_LEVELS recurse)\n{\n\tif (ms)\n\t{\n\t\tuint32_t currpos = ms->pos;\n\t\tint32_t nestsize = (int32_t)ms->nest_size[ms->nest_level];\n\t\tif (nestsize == 0 && ms->nest_level == 0)\n\t\t\tnestsize = ms->buffer_size_longs;\n\t\t\n\t\twhile (ms->pos+1 < ms->buffer_size_longs && nestsize > 0)\n\t\t{\n\t\t\tuint32_t key = ms->buffer[ms->pos];\n\n\t\t\tif (ms->nest_level == 0 && key != GPMF_KEY_DEVICE && ms->device_count == 0 && ms->pos == 0)\n\t\t\t{\n\t\t\t\tDBG_MSG(\"ERROR: uninitized -- GPMF_ERROR_BAD_STRUCTURE\\n\");\n\t\t\t\treturn GPMF_ERROR_BAD_STRUCTURE;\n\t\t\t}\n\n\t\t\tif (GPMF_VALID_FOURCC(key))\n\t\t\t{\n\t\t\t\tuint32_t type_size_repeat = ms->buffer[ms->pos + 1];\n\t\t\t\tint32_t size = GPMF_DATA_SIZE(type_size_repeat) >> 2;\n\t\t\t\tuint8_t type = GPMF_SAMPLE_TYPE(type_size_repeat);\n\t\t\t\tif (size + 2 > nestsize)\n\t\t\t\t{\n\t\t\t\t\tDBG_MSG(\"ERROR: nest size too small within %c%c%c%c-- GPMF_ERROR_BAD_STRUCTURE\\n\", PRINTF_4CC(key));\n\t\t\t\t\treturn GPMF_ERROR_BAD_STRUCTURE;\n\t\t\t\t}\n\n\t\t\t\tif (!GPMF_VALID_FOURCC(key))\n\t\t\t\t{\n\t\t\t\t\tDBG_MSG(\"ERROR: invalid 4CC -- GPMF_ERROR_BAD_STRUCTURE\\n\");\n\t\t\t\t\treturn GPMF_ERROR_BAD_STRUCTURE;\n\t\t\t\t}\n\n\t\t\t\tif (type == GPMF_TYPE_NEST && recurse == GPMF_RECURSE_LEVELS)\n\t\t\t\t{\n\t\t\t\t\tuint32_t validnest;\n\t\t\t\t\tms->pos += 2;\n\t\t\t\t\tms->nest_level++;\n\t\t\t\t\tif (ms->nest_level > GPMF_NEST_LIMIT)\n\t\t\t\t\t{\n\t\t\t\t\t\tDBG_MSG(\"ERROR: nest level within %c%c%c%c too deep -- GPMF_ERROR_BAD_STRUCTURE\\n\", PRINTF_4CC(key));\n\t\t\t\t\t\treturn GPMF_ERROR_BAD_STRUCTURE;\n\t\t\t\t\t}\n\t\t\t\t\tms->nest_size[ms->nest_level] = size;\n\t\t\t\t\tvalidnest = GPMF_Validate(ms, recurse);\n\t\t\t\t\tms->nest_level--;\n\t\t\t\t\tif (GPMF_OK != validnest)\n\t\t\t\t\t{\n\t\t\t\t\t\tDBG_MSG(\"ERROR: invalid nest within %c%c%c%c -- GPMF_ERROR_BAD_STRUCTURE\\n\", PRINTF_4CC(key));\n\t\t\t\t\t\treturn GPMF_ERROR_BAD_STRUCTURE;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (ms->nest_level == 0)\n\t\t\t\t\t\t\tms->device_count++;\n\t\t\t\t\t}\n\n\t\t\t\t\tms->pos += size;\n\t\t\t\t\tnestsize -= 2 + size;\n\n\t\t\t\t\twhile (ms->pos < ms->buffer_size_longs && nestsize > 0 && ms->buffer[ms->pos] == GPMF_KEY_END)\n\t\t\t\t\t{\n\t\t\t\t\t\tms->pos++;\n\t\t\t\t\t\tnestsize--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tms->pos += 2 + size;\n\t\t\t\t\tnestsize -= 2 + size;\n\t\t\t\t}\n\n\t\t\t\tif (ms->pos == ms->buffer_size_longs)\n\t\t\t\t{\n\t\t\t\t\tms->pos = currpos;\n\t\t\t\t\treturn GPMF_OK;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (key == GPMF_KEY_END)\n\t\t\t\t{\n\t\t\t\t\tdo\n\t\t\t\t\t{\n\t\t\t\t\t\tms->pos++;\n\t\t\t\t\t\tnestsize--;\n\t\t\t\t\t} while (ms->pos < ms->buffer_size_longs && nestsize > 0 && ms->buffer[ms->pos] == 0);\n\t\t\t\t}\n\t\t\t\telse if (ms->nest_level == 0 && ms->device_count > 0)\n\t\t\t\t{\n\t\t\t\t\tms->pos = currpos;\n\t\t\t\t\treturn GPMF_OK;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tDBG_MSG(\"ERROR: bad struct within %c%c%c%c -- GPMF_ERROR_BAD_STRUCTURE\\n\", PRINTF_4CC(key));\n\t\t\t\t\treturn GPMF_ERROR_BAD_STRUCTURE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tms->pos = currpos;\n\t\treturn GPMF_OK;\n\t}\n\telse\n\t{\n\t\tDBG_MSG(\"ERROR: Invalid handle -- GPMF_ERROR_MEMORY\\n\");\n\t\treturn GPMF_ERROR_MEMORY;\n\t}\n}","target":0,"code_token_length":956,"total_token_length":1192,"max_tokens_setting":2048} +{"idx":320047,"func":"static float quantize_band_cost(struct AACEncContext *s, const float *in,\n\n const float *scaled, int size, int scale_idx,\n\n int cb, const float lambda, const float uplim,\n\n int *bits)\n\n{\n\n const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];\n\n const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];\n\n const float CLIPPED_ESCAPE = 165140.0f*IQ;\n\n int i, j, k;\n\n float cost = 0;\n\n const int dim = cb < FIRST_PAIR_BT ? 4 : 2;\n\n int resbits = 0;\n\n#ifndef USE_REALLY_FULL_SEARCH\n\n const float Q34 = sqrtf(Q * sqrtf(Q));\n\n const int range = aac_cb_range[cb];\n\n const int maxval = aac_cb_maxval[cb];\n\n int offs[4];\n\n#endif \/* USE_REALLY_FULL_SEARCH *\/\n\n\n\n if (!cb) {\n\n for (i = 0; i < size; i++)\n\n cost += in[i]*in[i]*lambda;\n\n if (bits)\n\n *bits = 0;\n\n return cost;\n\n }\n\n#ifndef USE_REALLY_FULL_SEARCH\n\n offs[0] = 1;\n\n for (i = 1; i < dim; i++)\n\n offs[i] = offs[i-1]*range;\n\n quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);\n\n#endif \/* USE_REALLY_FULL_SEARCH *\/\n\n for (i = 0; i < size; i += dim) {\n\n float mincost;\n\n int minidx = 0;\n\n int minbits = 0;\n\n const float *vec;\n\n#ifndef USE_REALLY_FULL_SEARCH\n\n int (*quants)[2] = &s->qcoefs[i];\n\n mincost = 0.0f;\n\n for (j = 0; j < dim; j++)\n\n mincost += in[i+j]*in[i+j]*lambda;\n\n minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;\n\n minbits = ff_aac_spectral_bits[cb-1][minidx];\n\n mincost += minbits;\n\n for (j = 0; j < (1<= CLIPPED_ESCAPE) {\n\n di = t - CLIPPED_ESCAPE;\n\n curbits += 21;\n\n } else {\n\n int c = av_clip(quant(t, Q), 0, 8191);\n\n di = t - c*cbrt(c)*IQ;\n\n curbits += av_log2(c)*2 - 4 + 1;\n\n }\n\n } else {\n\n di = t - vec[k]*IQ;\n\n }\n\n if (vec[k] != 0.0f)\n\n curbits++;\n\n rd += di*di*lambda;\n\n }\n\n } else {\n\n for (k = 0; k < dim; k++) {\n\n float di = in[i+k] - vec[k]*IQ;\n\n rd += di*di*lambda;\n\n }\n\n }\n\n rd += curbits;\n\n if (rd < mincost) {\n\n mincost = rd;\n\n minidx = j;\n\n minbits = curbits;\n\n }\n\n }\n\n cost += mincost;\n\n resbits += minbits;\n\n if (cost >= uplim)\n\n return uplim;\n\n }\n\n\n\n if (bits)\n\n *bits = resbits;\n\n return cost;\n\n}\n","target":0,"code_token_length":1179,"total_token_length":1415,"max_tokens_setting":2048} +{"idx":184373,"func":"RendererSchedulerImpl::RendererSchedulerImpl(\n std::unique_ptr task_queue_manager)\n : helper_(std::move(task_queue_manager), this),\n idle_helper_(\n &helper_,\n this,\n \"RendererSchedulerIdlePeriod\",\n base::TimeDelta(),\n helper_.NewTaskQueue(MainThreadTaskQueue::QueueCreationParams(\n MainThreadTaskQueue::QueueType::kIdle))),\n idle_canceled_delayed_task_sweeper_(&helper_,\n idle_helper_.IdleTaskRunner()),\n render_widget_scheduler_signals_(this),\n control_task_queue_(helper_.ControlMainThreadTaskQueue()),\n compositor_task_queue_(\n helper_.NewTaskQueue(MainThreadTaskQueue::QueueCreationParams(\n MainThreadTaskQueue::QueueType::kCompositor)\n .SetShouldMonitorQuiescence(true))),\n input_task_queue_(\n helper_.NewTaskQueue(MainThreadTaskQueue::QueueCreationParams(\n MainThreadTaskQueue::QueueType::kInput)\n .SetShouldMonitorQuiescence(true))),\n compositor_task_queue_enabled_voter_(\n compositor_task_queue_->CreateQueueEnabledVoter()),\n input_task_queue_enabled_voter_(\n input_task_queue_->CreateQueueEnabledVoter()),\n delayed_update_policy_runner_(\n base::Bind(&RendererSchedulerImpl::UpdatePolicy,\n base::Unretained(this)),\n helper_.ControlMainThreadTaskQueue()),\n seqlock_queueing_time_estimator_(\n QueueingTimeEstimator(this, kQueueingTimeWindowDuration, 20)),\n main_thread_only_(this,\n compositor_task_queue_,\n helper_.GetClock(),\n helper_.NowTicks()),\n any_thread_(this),\n policy_may_need_update_(&any_thread_lock_),\n weak_factory_(this) {\n task_queue_throttler_.reset(\n new TaskQueueThrottler(this, &tracing_controller_));\n update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy,\n weak_factory_.GetWeakPtr());\n end_renderer_hidden_idle_period_closure_.Reset(base::Bind(\n &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr()));\n\n task_runners_.insert(\n std::make_pair(helper_.DefaultMainThreadTaskQueue(), nullptr));\n task_runners_.insert(\n std::make_pair(compositor_task_queue_,\n compositor_task_queue_->CreateQueueEnabledVoter()));\n task_runners_.insert(std::make_pair(\n input_task_queue_, input_task_queue_->CreateQueueEnabledVoter()));\n\n default_timer_task_queue_ =\n NewTimerTaskQueue(MainThreadTaskQueue::QueueType::kDefaultTimer);\n v8_task_queue_ = NewTaskQueue(MainThreadTaskQueue::QueueCreationParams(\n MainThreadTaskQueue::QueueType::kV8));\n ipc_task_queue_ = NewTaskQueue(MainThreadTaskQueue::QueueCreationParams(\n MainThreadTaskQueue::QueueType::kIPC));\n\n TRACE_EVENT_OBJECT_CREATED_WITH_ID(\n TRACE_DISABLED_BY_DEFAULT(\"renderer.scheduler\"), \"RendererScheduler\",\n this);\n\n helper_.SetObserver(this);\n\n if (base::ThreadTaskRunnerHandle::IsSet()) {\n base::trace_event::TraceLog::GetInstance()->AddAsyncEnabledStateObserver(\n weak_factory_.GetWeakPtr());\n }\n\n int32_t delay_for_background_tab_stopping_millis;\n if (!base::StringToInt(\n base::GetFieldTrialParamValue(\"BackgroundTabStopping\",\n \"DelayForBackgroundTabStoppingMills\"),\n &delay_for_background_tab_stopping_millis)) {\n delay_for_background_tab_stopping_millis =\n kDelayForBackgroundTabStoppingMillis;\n }\n delay_for_background_tab_stopping_ = base::TimeDelta::FromMilliseconds(\n delay_for_background_tab_stopping_millis);\n\n internal::ProcessState::Get()->is_process_backgrounded =\n main_thread_only().renderer_backgrounded;\n}\n","target":0,"code_token_length":812,"total_token_length":1048,"max_tokens_setting":2048} +{"idx":56939,"func":"TRIO_PUBLIC_STRING trio_long_double_t trio_to_long_double TRIO_ARGS2((source, endp),\n TRIO_CONST char* source,\n char** endp)\n{\n#if defined(USE_STRTOLD)\n\treturn strtold(source, endp);\n#else\n\tint isNegative = FALSE;\n\tint isExponentNegative = FALSE;\n\ttrio_long_double_t integer = 0.0;\n\ttrio_long_double_t fraction = 0.0;\n\tunsigned long exponent = 0;\n\ttrio_long_double_t base;\n\ttrio_long_double_t fracdiv = 1.0;\n\ttrio_long_double_t value = 0.0;\n\n\t\/* First try hex-floats *\/\n\tif ((source[0] == '0') && ((source[1] == 'x') || (source[1] == 'X')))\n\t{\n\t\tbase = 16.0;\n\t\tsource += 2;\n\t\twhile (isxdigit((int)*source))\n\t\t{\n\t\t\tinteger *= base;\n\t\t\tinteger += (isdigit((int)*source) ? (*source - '0')\n\t\t\t : 10 + (internal_to_upper((int)*source) - 'A'));\n\t\t\tsource++;\n\t\t}\n\t\tif (*source == '.')\n\t\t{\n\t\t\tsource++;\n\t\t\twhile (isxdigit((int)*source))\n\t\t\t{\n\t\t\t\tfracdiv \/= base;\n\t\t\t\tfraction += fracdiv * (isdigit((int)*source)\n\t\t\t\t ? (*source - '0')\n\t\t\t\t : 10 + (internal_to_upper((int)*source) - 'A'));\n\t\t\t\tsource++;\n\t\t\t}\n\t\t\tif ((*source == 'p') || (*source == 'P'))\n\t\t\t{\n\t\t\t\tsource++;\n\t\t\t\tif ((*source == '+') || (*source == '-'))\n\t\t\t\t{\n\t\t\t\t\tisExponentNegative = (*source == '-');\n\t\t\t\t\tsource++;\n\t\t\t\t}\n\t\t\t\twhile (isdigit((int)*source))\n\t\t\t\t{\n\t\t\t\t\texponent *= 10;\n\t\t\t\t\texponent += (*source - '0');\n\t\t\t\t\tsource++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\/* For later use with exponent *\/\n\t\tbase = 2.0;\n\t}\n\telse \/* Then try normal decimal floats *\/\n\t{\n\t\tbase = 10.0;\n\t\tisNegative = (*source == '-');\n\t\t\/* Skip sign *\/\n\t\tif ((*source == '+') || (*source == '-'))\n\t\t\tsource++;\n\n\t\t\/* Integer part *\/\n\t\twhile (isdigit((int)*source))\n\t\t{\n\t\t\tinteger *= base;\n\t\t\tinteger += (*source - '0');\n\t\t\tsource++;\n\t\t}\n\n\t\tif (*source == '.')\n\t\t{\n\t\t\tsource++; \/* skip decimal point *\/\n\t\t\twhile (isdigit((int)*source))\n\t\t\t{\n\t\t\t\tfracdiv \/= base;\n\t\t\t\tfraction += (*source - '0') * fracdiv;\n\t\t\t\tsource++;\n\t\t\t}\n\t\t}\n\t\tif ((*source == 'e') || (*source == 'E')\n#if TRIO_MICROSOFT\n\t\t || (*source == 'd') || (*source == 'D')\n#endif\n\t\t)\n\t\t{\n\t\t\tsource++; \/* Skip exponential indicator *\/\n\t\t\tisExponentNegative = (*source == '-');\n\t\t\tif ((*source == '+') || (*source == '-'))\n\t\t\t\tsource++;\n\t\t\twhile (isdigit((int)*source))\n\t\t\t{\n\t\t\t\texponent *= (int)base;\n\t\t\t\texponent += (*source - '0');\n\t\t\t\tsource++;\n\t\t\t}\n\t\t}\n\t}\n\n\tvalue = integer + fraction;\n\tif (exponent != 0)\n\t{\n\t\tif (isExponentNegative)\n\t\t\tvalue \/= trio_powl(base, (trio_long_double_t)exponent);\n\t\telse\n\t\t\tvalue *= trio_powl(base, (trio_long_double_t)exponent);\n\t}\n\tif (isNegative)\n\t\tvalue = -value;\n\n\tif (endp)\n\t\t*endp = (char*)source;\n\treturn value;\n#endif\n}","target":0,"code_token_length":821,"total_token_length":1057,"max_tokens_setting":2048} +{"idx":318020,"func":"error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM(\n uint32 immediate_data_size, const cmds::AsyncTexImage2DCHROMIUM& c) {\n TRACE_EVENT0(\"gpu\", \"GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM\");\n GLenum target = static_cast(c.target);\n GLint level = static_cast(c.level);\n GLenum internal_format = static_cast(c.internalformat);\n GLsizei width = static_cast(c.width);\n GLsizei height = static_cast(c.height);\n GLint border = static_cast(c.border);\n GLenum format = static_cast(c.format);\n GLenum type = static_cast(c.type);\n uint32 pixels_shm_id = static_cast(c.pixels_shm_id);\n uint32 pixels_shm_offset = static_cast(c.pixels_shm_offset);\n uint32 pixels_size;\n uint32 async_upload_token = static_cast(c.async_upload_token);\n uint32 sync_data_shm_id = static_cast(c.sync_data_shm_id);\n uint32 sync_data_shm_offset = static_cast(c.sync_data_shm_offset);\n\n base::ScopedClosureRunner scoped_completion_callback;\n if (async_upload_token) {\n base::Closure completion_closure =\n AsyncUploadTokenCompletionClosure(async_upload_token,\n sync_data_shm_id,\n sync_data_shm_offset);\n if (completion_closure.is_null())\n return error::kInvalidArguments;\n\n scoped_completion_callback.Reset(completion_closure);\n }\n\n if (!GLES2Util::ComputeImageDataSizes(\n width, height, format, type, state_.unpack_alignment, &pixels_size, NULL,\n NULL)) {\n return error::kOutOfBounds;\n }\n const void* pixels = NULL;\n if (pixels_shm_id != 0 || pixels_shm_offset != 0) {\n pixels = GetSharedMemoryAs(\n pixels_shm_id, pixels_shm_offset, pixels_size);\n if (!pixels) {\n return error::kOutOfBounds;\n }\n }\n\n TextureManager::DoTextImage2DArguments args = {\n target, level, internal_format, width, height, border, format, type,\n pixels, pixels_size};\n TextureRef* texture_ref;\n if (!texture_manager()->ValidateTexImage2D(\n &state_, \"glAsyncTexImage2DCHROMIUM\", args, &texture_ref)) {\n return error::kNoError;\n }\n\n Texture* texture = texture_ref->texture();\n if (!ValidateAsyncTransfer(\n \"glAsyncTexImage2DCHROMIUM\", texture_ref, target, level, pixels))\n return error::kNoError;\n\n if (texture->IsDefined()) {\n LOCAL_SET_GL_ERROR(\n GL_INVALID_OPERATION,\n \"glAsyncTexImage2DCHROMIUM\", \"already defined\");\n return error::kNoError;\n }\n\n if (!EnsureGPUMemoryAvailable(pixels_size)) {\n LOCAL_SET_GL_ERROR(\n GL_OUT_OF_MEMORY, \"glAsyncTexImage2DCHROMIUM\", \"out of memory\");\n return error::kNoError;\n }\n\n AsyncTexImage2DParams tex_params = {\n target, level, static_cast(internal_format),\n width, height, border, format, type};\n AsyncMemoryParams mem_params(\n GetSharedMemoryBuffer(c.pixels_shm_id), c.pixels_shm_offset, pixels_size);\n\n AsyncPixelTransferDelegate* delegate =\n async_pixel_transfer_manager_->CreatePixelTransferDelegate(texture_ref,\n tex_params);\n texture->SetImmutable(true);\n\n delegate->AsyncTexImage2D(\n tex_params,\n mem_params,\n base::Bind(&TextureManager::SetLevelInfoFromParams,\n base::Unretained(texture_manager()),\n base::Unretained(texture_ref),\n tex_params));\n return error::kNoError;\n}\n","target":0,"code_token_length":859,"total_token_length":1095,"max_tokens_setting":2048} +{"idx":426355,"func":"static MagickBooleanType TraceSVGImage(Image *image,ExceptionInfo *exception)\n{\n#if defined(MAGICKCORE_AUTOTRACE_DELEGATE)\n {\n at_bitmap_type\n *trace;\n\n at_fitting_opts_type\n *fitting_options;\n\n at_output_opts_type\n *output_options;\n\n at_splines_type\n *splines;\n\n ImageType\n type;\n\n register const PixelPacket\n *p;\n\n register ssize_t\n i,\n x;\n\n size_t\n number_planes;\n\n ssize_t\n y;\n\n \/*\n Trace image and write as SVG.\n *\/\n fitting_options=at_fitting_opts_new();\n output_options=at_output_opts_new();\n type=GetImageType(image,exception);\n number_planes=3;\n if ((type == BilevelType) || (type == GrayscaleType))\n number_planes=1;\n trace=at_bitmap_new(image->columns,image->rows,number_planes);\n i=0;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n if (p == (const PixelPacket *) NULL)\n break;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n trace->bitmap[i++]=GetPixelRed(p);\n if (number_planes == 3)\n {\n trace->bitmap[i++]=GetPixelGreen(p);\n trace->bitmap[i++]=GetPixelBlue(p);\n }\n p++;\n }\n }\n splines=at_splines_new_full(trace,fitting_options,NULL,NULL,NULL,NULL,NULL,\n NULL);\n at_splines_write(at_output_get_handler_by_suffix((char *) \"svg\"),\n GetBlobFileHandle(image),image->filename,output_options,splines,NULL,\n NULL);\n \/*\n Free resources.\n *\/\n at_splines_free(splines);\n at_bitmap_free(trace);\n at_output_opts_free(output_options);\n at_fitting_opts_free(fitting_options);\n }\n#else\n {\n char\n *base64,\n message[MaxTextExtent];\n\n Image\n *clone_image;\n\n ImageInfo\n *image_info;\n\n register char\n *p;\n\n size_t\n blob_length,\n encode_length;\n\n ssize_t\n i;\n\n unsigned char\n *blob;\n\n (void) WriteBlobString(image,\n \"\\n\");\n (void) WriteBlobString(image,\n \"\\n\");\n (void) FormatLocaleString(message,MaxTextExtent,\n \"\",\n (double) image->columns,(double) image->rows,\n (double) image->columns,(double) image->rows,\n (double) image->columns,(double) image->rows);\n (void) WriteBlobString(image,message);\n clone_image=CloneImage(image,0,0,MagickTrue,exception);\n if (clone_image == (Image *) NULL)\n return(MagickFalse);\n image_info=AcquireImageInfo();\n (void) CopyMagickString(image_info->magick,\"PNG\",MaxTextExtent);\n blob_length=2048;\n blob=(unsigned char *) ImageToBlob(image_info,clone_image,&blob_length,\n exception);\n clone_image=DestroyImage(clone_image);\n image_info=DestroyImageInfo(image_info);\n if (blob == (unsigned char *) NULL)\n return(MagickFalse);\n encode_length=0;\n base64=Base64Encode(blob,blob_length,&encode_length);\n blob=(unsigned char *) RelinquishMagickMemory(blob);\n (void) FormatLocaleString(message,MaxTextExtent,\n \" scene,(double) image->columns,(double) image->rows,\n (double) image->page.x,(double) image->page.y);\n (void) WriteBlobString(image,message);\n p=base64;\n for (i=(ssize_t) encode_length; i > 0; i-=76)\n {\n (void) FormatLocaleString(message,MaxTextExtent,\"%.76s\",p);\n (void) WriteBlobString(image,message);\n p+=76;\n if (i > 76)\n (void) WriteBlobString(image,\"\\n\");\n }\n base64=DestroyString(base64);\n (void) WriteBlobString(image,\"\\\" \/>\\n\");\n (void) WriteBlobString(image,\"<\/svg>\\n\");\n }\n#endif\n (void) CloseBlob(image);\n return(MagickTrue);\n}","target":0,"code_token_length":1233,"total_token_length":1469,"max_tokens_setting":2048} +{"idx":323947,"func":"void arm_gen_test_cc(int cc, int label)\n\n{\n\n TCGv_i32 tmp;\n\n int inv;\n\n\n\n switch (cc) {\n\n case 0: \/* eq: Z *\/\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ZF, 0, label);\n\n break;\n\n case 1: \/* ne: !Z *\/\n\n tcg_gen_brcondi_i32(TCG_COND_NE, cpu_ZF, 0, label);\n\n break;\n\n case 2: \/* cs: C *\/\n\n tcg_gen_brcondi_i32(TCG_COND_NE, cpu_CF, 0, label);\n\n break;\n\n case 3: \/* cc: !C *\/\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_CF, 0, label);\n\n break;\n\n case 4: \/* mi: N *\/\n\n tcg_gen_brcondi_i32(TCG_COND_LT, cpu_NF, 0, label);\n\n break;\n\n case 5: \/* pl: !N *\/\n\n tcg_gen_brcondi_i32(TCG_COND_GE, cpu_NF, 0, label);\n\n break;\n\n case 6: \/* vs: V *\/\n\n tcg_gen_brcondi_i32(TCG_COND_LT, cpu_VF, 0, label);\n\n break;\n\n case 7: \/* vc: !V *\/\n\n tcg_gen_brcondi_i32(TCG_COND_GE, cpu_VF, 0, label);\n\n break;\n\n case 8: \/* hi: C && !Z *\/\n\n inv = gen_new_label();\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_CF, 0, inv);\n\n tcg_gen_brcondi_i32(TCG_COND_NE, cpu_ZF, 0, label);\n\n gen_set_label(inv);\n\n break;\n\n case 9: \/* ls: !C || Z *\/\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_CF, 0, label);\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ZF, 0, label);\n\n break;\n\n case 10: \/* ge: N == V -> N ^ V == 0 *\/\n\n tmp = tcg_temp_new_i32();\n\n tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF);\n\n tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label);\n\n tcg_temp_free_i32(tmp);\n\n break;\n\n case 11: \/* lt: N != V -> N ^ V != 0 *\/\n\n tmp = tcg_temp_new_i32();\n\n tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF);\n\n tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label);\n\n tcg_temp_free_i32(tmp);\n\n break;\n\n case 12: \/* gt: !Z && N == V *\/\n\n inv = gen_new_label();\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ZF, 0, inv);\n\n tmp = tcg_temp_new_i32();\n\n tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF);\n\n tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label);\n\n tcg_temp_free_i32(tmp);\n\n gen_set_label(inv);\n\n break;\n\n case 13: \/* le: Z || N != V *\/\n\n tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ZF, 0, label);\n\n tmp = tcg_temp_new_i32();\n\n tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF);\n\n tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label);\n\n tcg_temp_free_i32(tmp);\n\n break;\n\n default:\n\n fprintf(stderr, \"Bad condition code 0x%x\\n\", cc);\n\n abort();\n\n }\n\n}\n","target":0,"code_token_length":875,"total_token_length":1111,"max_tokens_setting":2048} +{"idx":170984,"func":"xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,\n\t const xmlChar *ID, xmlNodePtr *lst) {\n xmlParserCtxtPtr ctxt;\n xmlDocPtr newDoc;\n xmlNodePtr newRoot;\n xmlSAXHandlerPtr oldsax = NULL;\n int ret = 0;\n xmlChar start[4];\n xmlCharEncoding enc;\n\n if (ctx == NULL) return(-1);\n\n if (((ctx->depth > 40) && ((ctx->options & XML_PARSE_HUGE) == 0)) ||\n (ctx->depth > 1024)) {\n\treturn(XML_ERR_ENTITY_LOOP);\n }\n\n if (lst != NULL)\n *lst = NULL;\n if ((URL == NULL) && (ID == NULL))\n\treturn(-1);\n if (ctx->myDoc == NULL) \/* @@ relax but check for dereferences *\/\n\treturn(-1);\n\n ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, ctx);\n if (ctxt == NULL) {\n\treturn(-1);\n }\n\n oldsax = ctxt->sax;\n ctxt->sax = ctx->sax;\n xmlDetectSAX2(ctxt);\n newDoc = xmlNewDoc(BAD_CAST \"1.0\");\n if (newDoc == NULL) {\n\txmlFreeParserCtxt(ctxt);\n\treturn(-1);\n }\n newDoc->properties = XML_DOC_INTERNAL;\n if (ctx->myDoc->dict) {\n\tnewDoc->dict = ctx->myDoc->dict;\n\txmlDictReference(newDoc->dict);\n }\n if (ctx->myDoc != NULL) {\n\tnewDoc->intSubset = ctx->myDoc->intSubset;\n\tnewDoc->extSubset = ctx->myDoc->extSubset;\n }\n if (ctx->myDoc->URL != NULL) {\n\tnewDoc->URL = xmlStrdup(ctx->myDoc->URL);\n }\n newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST \"pseudoroot\", NULL);\n if (newRoot == NULL) {\n\tctxt->sax = oldsax;\n\txmlFreeParserCtxt(ctxt);\n\tnewDoc->intSubset = NULL;\n\tnewDoc->extSubset = NULL;\n xmlFreeDoc(newDoc);\n\treturn(-1);\n }\n xmlAddChild((xmlNodePtr) newDoc, newRoot);\n nodePush(ctxt, newDoc->children);\n if (ctx->myDoc == NULL) {\n\tctxt->myDoc = newDoc;\n } else {\n\tctxt->myDoc = ctx->myDoc;\n\tnewDoc->children->doc = ctx->myDoc;\n }\n\n \/*\n * Get the 4 first bytes and decode the charset\n * if enc != XML_CHAR_ENCODING_NONE\n * plug some encoding conversion routines.\n *\/\n GROW\n if ((ctxt->input->end - ctxt->input->cur) >= 4) {\n\tstart[0] = RAW;\n\tstart[1] = NXT(1);\n\tstart[2] = NXT(2);\n\tstart[3] = NXT(3);\n\tenc = xmlDetectCharEncoding(start, 4);\n\tif (enc != XML_CHAR_ENCODING_NONE) {\n\t xmlSwitchEncoding(ctxt, enc);\n\t}\n }\n\n \/*\n * Parse a possible text declaration first\n *\/\n if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {\n\txmlParseTextDecl(ctxt);\n\t\/*\n\t * An XML-1.0 document can't reference an entity not XML-1.0\n\t *\/\n\tif ((xmlStrEqual(ctx->version, BAD_CAST \"1.0\")) &&\n\t (!xmlStrEqual(ctxt->input->version, BAD_CAST \"1.0\"))) {\n\t xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH, \n\t \"Version mismatch between document and entity\\n\");\n\t}\n }\n\n \/*\n * Doing validity checking on chunk doesn't make sense\n *\/\n ctxt->instate = XML_PARSER_CONTENT;\n ctxt->validate = ctx->validate;\n ctxt->valid = ctx->valid;\n ctxt->loadsubset = ctx->loadsubset;\n ctxt->depth = ctx->depth + 1;\n ctxt->replaceEntities = ctx->replaceEntities;\n if (ctxt->validate) {\n\tctxt->vctxt.error = ctx->vctxt.error;\n\tctxt->vctxt.warning = ctx->vctxt.warning;\n } else {\n\tctxt->vctxt.error = NULL;\n\tctxt->vctxt.warning = NULL;\n }\n ctxt->vctxt.nodeTab = NULL;\n ctxt->vctxt.nodeNr = 0;\n ctxt->vctxt.nodeMax = 0;\n ctxt->vctxt.node = NULL;\n if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);\n ctxt->dict = ctx->dict;\n ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST \"xml\", 3);\n ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST \"xmlns\", 5);\n ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);\n ctxt->dictNames = ctx->dictNames;\n ctxt->attsDefault = ctx->attsDefault;\n ctxt->attsSpecial = ctx->attsSpecial;\n ctxt->linenumbers = ctx->linenumbers;\n\n xmlParseContent(ctxt);\n\n ctx->validate = ctxt->validate;\n ctx->valid = ctxt->valid;\n if ((RAW == '<') && (NXT(1) == '\/')) {\n\txmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);\n } else if (RAW != 0) {\n\txmlFatalErr(ctxt, XML_ERR_EXTRA_CONTENT, NULL);\n }\n if (ctxt->node != newDoc->children) {\n\txmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);\n }\n\n if (!ctxt->wellFormed) {\n if (ctxt->errNo == 0)\n\t ret = 1;\n\telse\n\t ret = ctxt->errNo;\n } else {\n\tif (lst != NULL) {\n\t xmlNodePtr cur;\n\n\t \/*\n\t * Return the newly created nodeset after unlinking it from\n\t * they pseudo parent.\n\t *\/\n\t cur = newDoc->children->children;\n\t *lst = cur;\n\t while (cur != NULL) {\n\t\tcur->parent = NULL;\n\t\tcur = cur->next;\n\t }\n newDoc->children->children = NULL;\n\t}\n\tret = 0;\n }\n ctxt->sax = oldsax;\n ctxt->dict = NULL;\n ctxt->attsDefault = NULL;\n ctxt->attsSpecial = NULL;\n xmlFreeParserCtxt(ctxt);\n newDoc->intSubset = NULL;\n newDoc->extSubset = NULL;\n xmlFreeDoc(newDoc);\n\n return(ret);\n}\n","target":0,"code_token_length":1477,"total_token_length":1713,"max_tokens_setting":2048} +{"idx":459055,"func":"coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,\n int bytes, BdrvRequestFlags flags)\n{\n IscsiLun *iscsilun = bs->opaque;\n struct IscsiTask iTask;\n uint64_t lba;\n uint32_t nb_blocks;\n bool use_16_for_ws = iscsilun->use_16_for_rw;\n int r = 0;\n\n if (!is_byte_request_lun_aligned(offset, bytes, iscsilun)) {\n return -ENOTSUP;\n }\n\n if (flags & BDRV_REQ_MAY_UNMAP) {\n if (!use_16_for_ws && !iscsilun->lbp.lbpws10) {\n \/* WRITESAME10 with UNMAP is unsupported try WRITESAME16 *\/\n use_16_for_ws = true;\n }\n if (use_16_for_ws && !iscsilun->lbp.lbpws) {\n \/* WRITESAME16 with UNMAP is not supported by the target,\n * fall back and try WRITESAME10\/16 without UNMAP *\/\n flags &= ~BDRV_REQ_MAY_UNMAP;\n use_16_for_ws = iscsilun->use_16_for_rw;\n }\n }\n\n if (!(flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->has_write_same) {\n \/* WRITESAME without UNMAP is not supported by the target *\/\n return -ENOTSUP;\n }\n\n lba = offset \/ iscsilun->block_size;\n nb_blocks = bytes \/ iscsilun->block_size;\n\n if (iscsilun->zeroblock == NULL) {\n iscsilun->zeroblock = g_try_malloc0(iscsilun->block_size);\n if (iscsilun->zeroblock == NULL) {\n return -ENOMEM;\n }\n }\n\n qemu_mutex_lock(&iscsilun->mutex);\n iscsi_co_init_iscsitask(iscsilun, &iTask);\nretry:\n if (use_16_for_ws) {\n iTask.task = iscsi_writesame16_task(iscsilun->iscsi, iscsilun->lun, lba,\n iscsilun->zeroblock, iscsilun->block_size,\n nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP),\n 0, 0, iscsi_co_generic_cb, &iTask);\n } else {\n iTask.task = iscsi_writesame10_task(iscsilun->iscsi, iscsilun->lun, lba,\n iscsilun->zeroblock, iscsilun->block_size,\n nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP),\n 0, 0, iscsi_co_generic_cb, &iTask);\n }\n if (iTask.task == NULL) {\n qemu_mutex_unlock(&iscsilun->mutex);\n return -ENOMEM;\n }\n\n iscsi_co_wait_for_task(&iTask, iscsilun);\n\n if (iTask.status == SCSI_STATUS_CHECK_CONDITION &&\n iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&\n (iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE ||\n iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB)) {\n \/* WRITE SAME is not supported by the target *\/\n iscsilun->has_write_same = false;\n scsi_free_scsi_task(iTask.task);\n r = -ENOTSUP;\n goto out_unlock;\n }\n\n if (iTask.task != NULL) {\n scsi_free_scsi_task(iTask.task);\n iTask.task = NULL;\n }\n\n if (iTask.do_retry) {\n iTask.complete = 0;\n goto retry;\n }\n\n if (iTask.status != SCSI_STATUS_GOOD) {\n iscsi_allocmap_set_invalid(iscsilun, offset, bytes);\n error_report(\"iSCSI WRITESAME10\/16 failed at lba %\" PRIu64 \": %s\",\n lba, iTask.err_str);\n r = iTask.err_code;\n goto out_unlock;\n }\n\n if (flags & BDRV_REQ_MAY_UNMAP) {\n iscsi_allocmap_set_invalid(iscsilun, offset, bytes);\n } else {\n iscsi_allocmap_set_allocated(iscsilun, offset, bytes);\n }\n\nout_unlock:\n qemu_mutex_unlock(&iscsilun->mutex);\n g_free(iTask.err_str);\n return r;\n}","target":0,"code_token_length":1010,"total_token_length":1246,"max_tokens_setting":2048} +{"idx":370499,"func":"void check_response_for_cacheability(struct session *t, struct channel *rtr)\n{\n\tstruct http_txn *txn = &t->txn;\n\tchar *p1, *p2;\n\n\tchar *cur_ptr, *cur_end, *cur_next;\n\tint cur_idx;\n\n\tif (!(txn->flags & TX_CACHEABLE))\n\t\treturn;\n\n\t\/* Iterate through the headers.\n\t * we start with the start line.\n\t *\/\n\tcur_idx = 0;\n\tcur_next = rtr->buf->p + hdr_idx_first_pos(&txn->hdr_idx);\n\n\twhile ((cur_idx = txn->hdr_idx.v[cur_idx].next)) {\n\t\tstruct hdr_idx_elem *cur_hdr;\n\t\tint val;\n\n\t\tcur_hdr = &txn->hdr_idx.v[cur_idx];\n\t\tcur_ptr = cur_next;\n\t\tcur_end = cur_ptr + cur_hdr->len;\n\t\tcur_next = cur_end + cur_hdr->cr + 1;\n\n\t\t\/* We have one full header between cur_ptr and cur_end, and the\n\t\t * next header starts at cur_next. We're only interested in\n\t\t * \"Cookie:\" headers.\n\t\t *\/\n\n\t\tval = http_header_match2(cur_ptr, cur_end, \"Pragma\", 6);\n\t\tif (val) {\n\t\t\tif ((cur_end - (cur_ptr + val) >= 8) &&\n\t\t\t strncasecmp(cur_ptr + val, \"no-cache\", 8) == 0) {\n\t\t\t\ttxn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tval = http_header_match2(cur_ptr, cur_end, \"Cache-control\", 13);\n\t\tif (!val)\n\t\t\tcontinue;\n\n\t\t\/* OK, right now we know we have a cache-control header at cur_ptr *\/\n\n\t\tp1 = cur_ptr + val; \/* first non-space char after 'cache-control:' *\/\n\n\t\tif (p1 >= cur_end)\t\/* no more info *\/\n\t\t\tcontinue;\n\n\t\t\/* p1 is at the beginning of the value *\/\n\t\tp2 = p1;\n\n\t\twhile (p2 < cur_end && *p2 != '=' && *p2 != ',' && !isspace((unsigned char)*p2))\n\t\t\tp2++;\n\n\t\t\/* we have a complete value between p1 and p2 *\/\n\t\tif (p2 < cur_end && *p2 == '=') {\n\t\t\t\/* we have something of the form no-cache=\"set-cookie\" *\/\n\t\t\tif ((cur_end - p1 >= 21) &&\n\t\t\t strncasecmp(p1, \"no-cache=\\\"set-cookie\", 20) == 0\n\t\t\t && (p1[20] == '\"' || p1[20] == ','))\n\t\t\t\ttxn->flags &= ~TX_CACHE_COOK;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* OK, so we know that either p2 points to the end of string or to a comma *\/\n\t\tif (((p2 - p1 == 7) && strncasecmp(p1, \"private\", 7) == 0) ||\n\t\t ((p2 - p1 == 8) && strncasecmp(p1, \"no-store\", 8) == 0) ||\n\t\t ((p2 - p1 == 9) && strncasecmp(p1, \"max-age=0\", 9) == 0) ||\n\t\t ((p2 - p1 == 10) && strncasecmp(p1, \"s-maxage=0\", 10) == 0)) {\n\t\t\ttxn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK;\n\t\t\treturn;\n\t\t}\n\n\t\tif ((p2 - p1 == 6) && strncasecmp(p1, \"public\", 6) == 0) {\n\t\t\ttxn->flags |= TX_CACHEABLE | TX_CACHE_COOK;\n\t\t\tcontinue;\n\t\t}\n\t}\n}","target":0,"code_token_length":822,"total_token_length":1058,"max_tokens_setting":2048} +{"idx":393329,"func":"xmlRelaxNGValidateAttribute(xmlRelaxNGValidCtxtPtr ctxt,\n xmlRelaxNGDefinePtr define)\n{\n int ret = 0, i;\n xmlChar *value, *oldvalue;\n xmlAttrPtr prop = NULL, tmp;\n xmlNodePtr oldseq;\n\n if (ctxt->state->nbAttrLeft <= 0)\n return (-1);\n if (define->name != NULL) {\n for (i = 0; i < ctxt->state->nbAttrs; i++) {\n tmp = ctxt->state->attrs[i];\n if ((tmp != NULL) && (xmlStrEqual(define->name, tmp->name))) {\n if ((((define->ns == NULL) || (define->ns[0] == 0)) &&\n (tmp->ns == NULL)) ||\n ((tmp->ns != NULL) &&\n (xmlStrEqual(define->ns, tmp->ns->href)))) {\n prop = tmp;\n break;\n }\n }\n }\n if (prop != NULL) {\n value = xmlNodeListGetString(prop->doc, prop->children, 1);\n oldvalue = ctxt->state->value;\n oldseq = ctxt->state->seq;\n ctxt->state->seq = (xmlNodePtr) prop;\n ctxt->state->value = value;\n ctxt->state->endvalue = NULL;\n ret = xmlRelaxNGValidateValueContent(ctxt, define->content);\n if (ctxt->state->value != NULL)\n value = ctxt->state->value;\n if (value != NULL)\n xmlFree(value);\n ctxt->state->value = oldvalue;\n ctxt->state->seq = oldseq;\n if (ret == 0) {\n \/*\n * flag the attribute as processed\n *\/\n ctxt->state->attrs[i] = NULL;\n ctxt->state->nbAttrLeft--;\n }\n } else {\n ret = -1;\n }\n#ifdef DEBUG\n xmlGenericError(xmlGenericErrorContext,\n \"xmlRelaxNGValidateAttribute(%s): %d\\n\",\n define->name, ret);\n#endif\n } else {\n for (i = 0; i < ctxt->state->nbAttrs; i++) {\n tmp = ctxt->state->attrs[i];\n if ((tmp != NULL) &&\n (xmlRelaxNGAttributeMatch(ctxt, define, tmp) == 1)) {\n prop = tmp;\n break;\n }\n }\n if (prop != NULL) {\n value = xmlNodeListGetString(prop->doc, prop->children, 1);\n oldvalue = ctxt->state->value;\n oldseq = ctxt->state->seq;\n ctxt->state->seq = (xmlNodePtr) prop;\n ctxt->state->value = value;\n ret = xmlRelaxNGValidateValueContent(ctxt, define->content);\n if (ctxt->state->value != NULL)\n value = ctxt->state->value;\n if (value != NULL)\n xmlFree(value);\n ctxt->state->value = oldvalue;\n ctxt->state->seq = oldseq;\n if (ret == 0) {\n \/*\n * flag the attribute as processed\n *\/\n ctxt->state->attrs[i] = NULL;\n ctxt->state->nbAttrLeft--;\n }\n } else {\n ret = -1;\n }\n#ifdef DEBUG\n if (define->ns != NULL) {\n xmlGenericError(xmlGenericErrorContext,\n \"xmlRelaxNGValidateAttribute(nsName ns = %s): %d\\n\",\n define->ns, ret);\n } else {\n xmlGenericError(xmlGenericErrorContext,\n \"xmlRelaxNGValidateAttribute(anyName): %d\\n\",\n ret);\n }\n#endif\n }\n\n return (ret);\n}","target":0,"code_token_length":809,"total_token_length":1045,"max_tokens_setting":2048} +{"idx":494490,"func":"static CURLcode inflate_stream(struct Curl_easy *data,\n struct contenc_writer *writer,\n zlibInitState started)\n{\n struct zlib_params *zp = (struct zlib_params *) &writer->params;\n z_stream *z = &zp->z; \/* zlib state structure *\/\n uInt nread = z->avail_in;\n Bytef *orig_in = z->next_in;\n bool done = FALSE;\n CURLcode result = CURLE_OK; \/* Curl_client_write status *\/\n char *decomp; \/* Put the decompressed data here. *\/\n\n \/* Check state. *\/\n if(zp->zlib_init != ZLIB_INIT &&\n zp->zlib_init != ZLIB_INFLATING &&\n zp->zlib_init != ZLIB_INIT_GZIP &&\n zp->zlib_init != ZLIB_GZIP_INFLATING)\n return exit_zlib(data, z, &zp->zlib_init, CURLE_WRITE_ERROR);\n\n \/* Dynamically allocate a buffer for decompression because it's uncommonly\n large to hold on the stack *\/\n decomp = malloc(DSIZ);\n if(!decomp)\n return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);\n\n \/* because the buffer size is fixed, iteratively decompress and transfer to\n the client via downstream_write function. *\/\n while(!done) {\n int status; \/* zlib status *\/\n done = TRUE;\n\n \/* (re)set buffer for decompressed output for every iteration *\/\n z->next_out = (Bytef *) decomp;\n z->avail_out = DSIZ;\n\n#ifdef Z_BLOCK\n \/* Z_BLOCK is only available in zlib ver. >= 1.2.0.5 *\/\n status = inflate(z, Z_BLOCK);\n#else\n \/* fallback for zlib ver. < 1.2.0.5 *\/\n status = inflate(z, Z_SYNC_FLUSH);\n#endif\n\n \/* Flush output data if some. *\/\n if(z->avail_out != DSIZ) {\n if(status == Z_OK || status == Z_STREAM_END) {\n zp->zlib_init = started; \/* Data started. *\/\n result = Curl_unencode_write(data, writer->downstream, decomp,\n DSIZ - z->avail_out);\n if(result) {\n exit_zlib(data, z, &zp->zlib_init, result);\n break;\n }\n }\n }\n\n \/* Dispatch by inflate() status. *\/\n switch(status) {\n case Z_OK:\n \/* Always loop: there may be unflushed latched data in zlib state. *\/\n done = FALSE;\n break;\n case Z_BUF_ERROR:\n \/* No more data to flush: just exit loop. *\/\n break;\n case Z_STREAM_END:\n result = process_trailer(data, zp);\n break;\n case Z_DATA_ERROR:\n \/* some servers seem to not generate zlib headers, so this is an attempt\n to fix and continue anyway *\/\n if(zp->zlib_init == ZLIB_INIT) {\n \/* Do not use inflateReset2(): only available since zlib 1.2.3.4. *\/\n (void) inflateEnd(z); \/* don't care about the return code *\/\n if(inflateInit2(z, -MAX_WBITS) == Z_OK) {\n z->next_in = orig_in;\n z->avail_in = nread;\n zp->zlib_init = ZLIB_INFLATING;\n zp->trailerlen = 4; \/* Tolerate up to 4 unknown trailer bytes. *\/\n done = FALSE;\n break;\n }\n zp->zlib_init = ZLIB_UNINIT; \/* inflateEnd() already called. *\/\n }\n result = exit_zlib(data, z, &zp->zlib_init, process_zlib_error(data, z));\n break;\n default:\n result = exit_zlib(data, z, &zp->zlib_init, process_zlib_error(data, z));\n break;\n }\n }\n free(decomp);\n\n \/* We're about to leave this call so the `nread' data bytes won't be seen\n again. If we are in a state that would wrongly allow restart in raw mode\n at the next call, assume output has already started. *\/\n if(nread && zp->zlib_init == ZLIB_INIT)\n zp->zlib_init = started; \/* Cannot restart anymore. *\/\n\n return result;\n}","target":0,"code_token_length":960,"total_token_length":1196,"max_tokens_setting":2048} +{"idx":304165,"func":"xar_read_header(struct archive_read *a, struct archive_entry *entry)\n{\n\tstruct xar *xar;\n\tstruct xar_file *file;\n\tstruct xattr *xattr;\n\tint r;\n\n\txar = (struct xar *)(a->format->data);\n\tr = ARCHIVE_OK;\n\n\tif (xar->offset == 0) {\n\t\t\/* Create a character conversion object. *\/\n\t\tif (xar->sconv == NULL) {\n\t\t\txar->sconv = archive_string_conversion_from_charset(\n\t\t\t &(a->archive), \"UTF-8\", 1);\n\t\t\tif (xar->sconv == NULL)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\n\t\t\/* Read TOC. *\/\n\t\tr = read_toc(a);\n\t\tif (r != ARCHIVE_OK)\n\t\t\treturn (r);\n\t}\n\n\tfor (;;) {\n\t\tfile = xar->file = heap_get_entry(&(xar->file_queue));\n\t\tif (file == NULL) {\n\t\t\txar->end_of_file = 1;\n\t\t\treturn (ARCHIVE_EOF);\n\t\t}\n\t\tif ((file->mode & AE_IFMT) != AE_IFDIR)\n\t\t\tbreak;\n\t\tif (file->has != (HAS_PATHNAME | HAS_TYPE))\n\t\t\tbreak;\n\t\t\/*\n\t\t * If a file type is a directory and it does not have\n\t\t * any metadata, do not export.\n\t\t *\/\n\t\tfile_free(file);\n\t}\n\tarchive_entry_set_atime(entry, file->atime, 0);\n\tarchive_entry_set_ctime(entry, file->ctime, 0);\n\tarchive_entry_set_mtime(entry, file->mtime, 0);\n\tarchive_entry_set_gid(entry, file->gid);\n\tif (file->gname.length > 0 &&\n\t archive_entry_copy_gname_l(entry, file->gname.s,\n\t\tarchive_strlen(&(file->gname)), xar->sconv) != 0) {\n\t\tif (errno == ENOMEM) {\n\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t \"Can't allocate memory for Gname\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tarchive_set_error(&a->archive,\n\t\t ARCHIVE_ERRNO_FILE_FORMAT,\n\t\t \"Gname cannot be converted from %s to current locale.\",\n\t\t archive_string_conversion_charset_name(xar->sconv));\n\t\tr = ARCHIVE_WARN;\n\t}\n\tarchive_entry_set_uid(entry, file->uid);\n\tif (file->uname.length > 0 &&\n\t archive_entry_copy_uname_l(entry, file->uname.s,\n\t\tarchive_strlen(&(file->uname)), xar->sconv) != 0) {\n\t\tif (errno == ENOMEM) {\n\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t \"Can't allocate memory for Uname\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tarchive_set_error(&a->archive,\n\t\t ARCHIVE_ERRNO_FILE_FORMAT,\n\t\t \"Uname cannot be converted from %s to current locale.\",\n\t\t archive_string_conversion_charset_name(xar->sconv));\n\t\tr = ARCHIVE_WARN;\n\t}\n\tarchive_entry_set_mode(entry, file->mode);\n\tif (archive_entry_copy_pathname_l(entry, file->pathname.s,\n\t archive_strlen(&(file->pathname)), xar->sconv) != 0) {\n\t\tif (errno == ENOMEM) {\n\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t \"Can't allocate memory for Pathname\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tarchive_set_error(&a->archive,\n\t\t ARCHIVE_ERRNO_FILE_FORMAT,\n\t\t \"Pathname cannot be converted from %s to current locale.\",\n\t\t archive_string_conversion_charset_name(xar->sconv));\n\t\tr = ARCHIVE_WARN;\n\t}\n\n\n\tif (file->symlink.length > 0 &&\n\t archive_entry_copy_symlink_l(entry, file->symlink.s,\n\t\tarchive_strlen(&(file->symlink)), xar->sconv) != 0) {\n\t\tif (errno == ENOMEM) {\n\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t \"Can't allocate memory for Linkname\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tarchive_set_error(&a->archive,\n\t\t ARCHIVE_ERRNO_FILE_FORMAT,\n\t\t \"Linkname cannot be converted from %s to current locale.\",\n\t\t archive_string_conversion_charset_name(xar->sconv));\n\t\tr = ARCHIVE_WARN;\n\t}\n\t\/* Set proper nlink. *\/\n\tif ((file->mode & AE_IFMT) == AE_IFDIR)\n\t\tarchive_entry_set_nlink(entry, file->subdirs + 2);\n\telse\n\t\tarchive_entry_set_nlink(entry, file->nlink);\n\tarchive_entry_set_size(entry, file->size);\n\tif (archive_strlen(&(file->hardlink)) > 0)\n\t\tarchive_entry_set_hardlink(entry, file->hardlink.s);\n\tarchive_entry_set_ino64(entry, file->ino64);\n\tif (file->has & HAS_DEV)\n\t\tarchive_entry_set_dev(entry, file->dev);\n\tif (file->has & HAS_DEVMAJOR)\n\t\tarchive_entry_set_devmajor(entry, file->devmajor);\n\tif (file->has & HAS_DEVMINOR)\n\t\tarchive_entry_set_devminor(entry, file->devminor);\n\tif (archive_strlen(&(file->fflags_text)) > 0)\n\t\tarchive_entry_copy_fflags_text(entry, file->fflags_text.s);\n\n\txar->entry_init = 1;\n\txar->entry_total = 0;\n\txar->entry_remaining = file->length;\n\txar->entry_size = file->size;\n\txar->entry_encoding = file->encoding;\n\txar->entry_a_sum = file->a_sum;\n\txar->entry_e_sum = file->e_sum;\n\t\/*\n\t * Read extended attributes.\n\t *\/\n\txattr = file->xattr_list;\n\twhile (xattr != NULL) {\n\t\tconst void *d;\n\t\tsize_t outbytes, used;\n\n\t\tr = move_reading_point(a, xattr->offset);\n\t\tif (r != ARCHIVE_OK)\n\t\t\tbreak;\n\t\tr = rd_contents_init(a, xattr->encoding,\n\t\t xattr->a_sum.alg, xattr->e_sum.alg);\n\t\tif (r != ARCHIVE_OK)\n\t\t\tbreak;\n\t\td = NULL;\n\t\tr = rd_contents(a, &d, &outbytes, &used, xattr->length);\n\t\tif (r != ARCHIVE_OK)\n\t\t\tbreak;\n\t\tif (outbytes != xattr->size) {\n\t\t\tarchive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,\n\t\t\t \"Decompressed size error\");\n\t\t\tr = ARCHIVE_FATAL;\n\t\t\tbreak;\n\t\t}\n\t\tr = checksum_final(a,\n\t\t xattr->a_sum.val, xattr->a_sum.len,\n\t\t xattr->e_sum.val, xattr->e_sum.len);\n\t\tif (r != ARCHIVE_OK)\n\t\t\tbreak;\n\t\tarchive_entry_xattr_add_entry(entry,\n\t\t xattr->name.s, d, outbytes);\n\t\txattr = xattr->next;\n\t}\n\tif (r != ARCHIVE_OK) {\n\t\tfile_free(file);\n\t\treturn (r);\n\t}\n\n\tif (xar->entry_remaining > 0)\n\t\t\/* Move reading point to the beginning of current\n\t\t * file contents. *\/\n\t\tr = move_reading_point(a, file->offset);\n\telse\n\t\tr = ARCHIVE_OK;\n\n\tfile_free(file);\n\treturn (r);\n}","target":0,"code_token_length":1574,"total_token_length":1810,"max_tokens_setting":2048} +{"idx":57164,"func":"void CSteamNetworkConnectionBase::SNP_GatherAckBlocks( SNPAckSerializerHelper &helper, SteamNetworkingMicroseconds usecNow )\n{\n\thelper.m_nBlocks = 0;\n\thelper.m_nBlocksNeedToAck = 0;\n\n\t\/\/ Fast case for no packet loss we need to ack, which will (hopefully!) be a common case\n\tint n = len( m_receiverState.m_mapPacketGaps ) - 1;\n\tif ( n <= 0 )\n\t\treturn;\n\n\t\/\/ Let's not just flush the acks that are due right now. Let's flush all of them\n\t\/\/ that will be due any time before we have the bandwidth to send the next packet.\n\t\/\/ (Assuming that we send the max packet size here.)\n\tSteamNetworkingMicroseconds usecSendAcksDueBefore = usecNow;\n\tSteamNetworkingMicroseconds usecTimeUntilNextPacket = SteamNetworkingMicroseconds( ( m_senderState.m_flTokenBucket - (float)m_cbMTUPacketSize ) \/ (float)m_senderState.m_n_x * -1e6 );\n\tif ( usecTimeUntilNextPacket > 0 )\n\t\tusecSendAcksDueBefore += usecTimeUntilNextPacket;\n\n\tm_receiverState.DebugCheckPackGapMap();\n\n\tn = std::min( (int)helper.k_nMaxBlocks, n );\n\tauto itNext = m_receiverState.m_mapPacketGaps.begin();\n\n\tint cbEncodedSize = helper.k_cbHeaderSize;\n\twhile ( n > 0 )\n\t{\n\t\t--n;\n\t\tauto itCur = itNext;\n\t\t++itNext;\n\n\t\tAssert( itCur->first < itCur->second.m_nEnd );\n\n\t\t\/\/ Do we need to report on this block now?\n\t\tbool bNeedToReport = ( itNext->second.m_usecWhenAckPrior <= usecSendAcksDueBefore );\n\n\t\t\/\/ Should we wait to NACK this?\n\t\tif ( itCur == m_receiverState.m_itPendingNack )\n\t\t{\n\n\t\t\t\/\/ Wait to NACK this?\n\t\t\tif ( !bNeedToReport )\n\t\t\t{\n\t\t\t\tif ( usecNow < itCur->second.m_usecWhenOKToNack )\n\t\t\t\t\tbreak;\n\t\t\t\tbNeedToReport = true;\n\t\t\t}\n\n\t\t\t\/\/ Go ahead and NACK it. If the packet arrives, we will use it.\n\t\t\t\/\/ But our NACK may cause the sender to retransmit.\n\t\t\t++m_receiverState.m_itPendingNack;\n\t\t}\n\n\t\tSNPAckSerializerHelper::Block &block = helper.m_arBlocks[ helper.m_nBlocks ];\n\t\tblock.m_nNack = uint32( itCur->second.m_nEnd - itCur->first );\n\n\t\tint64 nAckEnd;\n\t\tSteamNetworkingMicroseconds usecWhenSentLast;\n\t\tif ( n == 0 )\n\t\t{\n\t\t\t\/\/ itNext should be the sentinel\n\t\t\tAssert( itNext->first == INT64_MAX );\n\t\t\tnAckEnd = m_statsEndToEnd.m_nMaxRecvPktNum+1;\n\t\t\tusecWhenSentLast = m_statsEndToEnd.m_usecTimeLastRecvSeq;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnAckEnd = itNext->first;\n\t\t\tusecWhenSentLast = itNext->second.m_usecWhenReceivedPktBefore;\n\t\t}\n\t\tAssert( itCur->second.m_nEnd < nAckEnd );\n\t\tblock.m_nAck = uint32( nAckEnd - itCur->second.m_nEnd );\n\n\t\tblock.m_nLatestPktNum = uint32( nAckEnd-1 );\n\t\tblock.m_nEncodedTimeSinceLatestPktNum = SNPAckSerializerHelper::EncodeTimeSince( usecNow, usecWhenSentLast );\n\n\t\t\/\/ When we encode 7+ blocks, the header grows by one byte\n\t\t\/\/ to store an explicit count\n\t\tif ( helper.m_nBlocks == 6 )\n\t\t\t++cbEncodedSize;\n\n\t\t\/\/ This block\n\t\t++cbEncodedSize;\n\t\tif ( block.m_nAck > 7 )\n\t\t\tcbEncodedSize += VarIntSerializedSize( block.m_nAck>>3 );\n\t\tif ( block.m_nNack > 7 )\n\t\t\tcbEncodedSize += VarIntSerializedSize( block.m_nNack>>3 );\n\t\tblock.m_cbTotalEncodedSize = cbEncodedSize;\n\n\t\t\/\/ FIXME Here if the caller knows they are working with limited space,\n\t\t\/\/ they could tell us how much space they have and we could bail\n\t\t\/\/ if we already know we're over\n\n\t\t++helper.m_nBlocks;\n\n\t\t\/\/ Do we really need to try to flush the ack\/nack for that block out now?\n\t\tif ( bNeedToReport )\n\t\t\thelper.m_nBlocksNeedToAck = helper.m_nBlocks;\n\t}\n}","target":0,"code_token_length":1017,"total_token_length":1253,"max_tokens_setting":2048} +{"idx":509890,"func":"TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop_on_error )\n{\n char \temsg[1024] = \"\";\n TIFFRGBAImage img;\n int \tok;\n uint32\ttile_xsize, tile_ysize;\n uint32\tread_xsize, read_ysize;\n uint32\ti_row;\n\n \/*\n * Verify that our request is legal - on a tile file, and on a\n * tile boundary.\n *\/\n \n if( !TIFFIsTiled( tif ) )\n {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif),\n\t\t\t\t \"Can't use TIFFReadRGBATile() with stripped file.\");\n\t\treturn (0);\n }\n \n TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize);\n TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize);\n if( (col % tile_xsize) != 0 || (row % tile_ysize) != 0 )\n {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif),\n \"Row\/col passed to TIFFReadRGBATile() must be top\"\n \"left corner of a tile.\");\n\treturn (0);\n }\n\n \/*\n * Setup the RGBA reader.\n *\/\n \n if (!TIFFRGBAImageOK(tif, emsg) \n\t|| !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) {\n\t TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"%s\", emsg);\n\t return( 0 );\n }\n\n \/*\n * The TIFFRGBAImageGet() function doesn't allow us to get off the\n * edge of the image, even to fill an otherwise valid tile. So we\n * figure out how much we can read, and fix up the tile buffer to\n * a full tile configuration afterwards.\n *\/\n\n if( row + tile_ysize > img.height )\n read_ysize = img.height - row;\n else\n read_ysize = tile_ysize;\n \n if( col + tile_xsize > img.width )\n read_xsize = img.width - col;\n else\n read_xsize = tile_xsize;\n\n \/*\n * Read the chunk of imagery.\n *\/\n \n img.row_offset = row;\n img.col_offset = col;\n\n ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize );\n \n TIFFRGBAImageEnd(&img);\n\n \/*\n * If our read was incomplete we will need to fix up the tile by\n * shifting the data around as if a full tile of data is being returned.\n *\n * This is all the more complicated because the image is organized in\n * bottom to top format. \n *\/\n\n if( read_xsize == tile_xsize && read_ysize == tile_ysize )\n return( ok );\n\n for( i_row = 0; i_row < read_ysize; i_row++ ) {\n memmove( raster + (tile_ysize - i_row - 1) * tile_xsize,\n raster + (read_ysize - i_row - 1) * read_xsize,\n read_xsize * sizeof(uint32) );\n _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize,\n 0, sizeof(uint32) * (tile_xsize - read_xsize) );\n }\n\n for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) {\n _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize,\n 0, sizeof(uint32) * tile_xsize );\n }\n\n return (ok);\n}","target":0,"code_token_length":836,"total_token_length":1072,"max_tokens_setting":2048} +{"idx":468994,"func":"static int initialize_tables(server_rec *s, apr_pool_t *ctx)\n{\n unsigned long idx;\n apr_status_t sts;\n\n \/* set up client list *\/\n\n \/* Create the shared memory segment *\/\n\n client_shm = NULL;\n client_rmm = NULL;\n client_lock = NULL;\n opaque_lock = NULL;\n client_list = NULL;\n\n \/*\n * Create a unique filename using our pid. This information is\n * stashed in the global variable so the children inherit it.\n *\/\n client_shm_filename = ap_runtime_dir_relative(ctx, \"authdigest_shm\");\n client_shm_filename = ap_append_pid(ctx, client_shm_filename, \".\");\n\n \/* Use anonymous shm by default, fall back on name-based. *\/\n sts = apr_shm_create(&client_shm, shmem_size, NULL, ctx);\n if (APR_STATUS_IS_ENOTIMPL(sts)) {\n \/* For a name-based segment, remove it first in case of a\n * previous unclean shutdown. *\/\n apr_shm_remove(client_shm_filename, ctx);\n\n \/* Now create that segment *\/\n sts = apr_shm_create(&client_shm, shmem_size,\n client_shm_filename, ctx);\n }\n\n if (APR_SUCCESS != sts) {\n ap_log_error(APLOG_MARK, APLOG_ERR, sts, s, APLOGNO(01762)\n \"Failed to create shared memory segment on file %s\",\n client_shm_filename);\n log_error_and_cleanup(\"failed to initialize shm\", sts, s);\n return HTTP_INTERNAL_SERVER_ERROR;\n }\n\n sts = apr_rmm_init(&client_rmm,\n NULL, \/* no lock, we'll do the locking ourselves *\/\n apr_shm_baseaddr_get(client_shm),\n shmem_size, ctx);\n if (sts != APR_SUCCESS) {\n log_error_and_cleanup(\"failed to initialize rmm\", sts, s);\n return !OK;\n }\n\n client_list = rmm_malloc(client_rmm, sizeof(*client_list) +\n sizeof(client_entry *) * num_buckets);\n if (!client_list) {\n log_error_and_cleanup(\"failed to allocate shared memory\", -1, s);\n return !OK;\n }\n client_list->table = (client_entry**) (client_list + 1);\n for (idx = 0; idx < num_buckets; idx++) {\n client_list->table[idx] = NULL;\n }\n client_list->tbl_len = num_buckets;\n client_list->num_entries = 0;\n\n sts = ap_global_mutex_create(&client_lock, NULL, client_mutex_type, NULL,\n s, ctx, 0);\n if (sts != APR_SUCCESS) {\n log_error_and_cleanup(\"failed to create lock (client_lock)\", sts, s);\n return !OK;\n }\n\n\n \/* setup opaque *\/\n\n opaque_cntr = rmm_malloc(client_rmm, sizeof(*opaque_cntr));\n if (opaque_cntr == NULL) {\n log_error_and_cleanup(\"failed to allocate shared memory\", -1, s);\n return !OK;\n }\n *opaque_cntr = 1UL;\n\n sts = ap_global_mutex_create(&opaque_lock, NULL, opaque_mutex_type, NULL,\n s, ctx, 0);\n if (sts != APR_SUCCESS) {\n log_error_and_cleanup(\"failed to create lock (opaque_lock)\", sts, s);\n return !OK;\n }\n\n\n \/* setup one-time-nonce counter *\/\n\n otn_counter = rmm_malloc(client_rmm, sizeof(*otn_counter));\n if (otn_counter == NULL) {\n log_error_and_cleanup(\"failed to allocate shared memory\", -1, s);\n return !OK;\n }\n *otn_counter = 0;\n \/* no lock here *\/\n\n\n \/* success *\/\n return OK;\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048} +{"idx":327109,"func":"static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3,\n\n int ra, int rb, int rt, int Rc)\n\n{\n\n TCGv t0, t1;\n\n\n\n t0 = tcg_temp_local_new();\n\n t1 = tcg_temp_local_new();\n\n\n\n switch (opc3 & 0x0D) {\n\n case 0x05:\n\n \/* macchw - macchw. - macchwo - macchwo. *\/\n\n \/* macchws - macchws. - macchwso - macchwso. *\/\n\n \/* nmacchw - nmacchw. - nmacchwo - nmacchwo. *\/\n\n \/* nmacchws - nmacchws. - nmacchwso - nmacchwso. *\/\n\n \/* mulchw - mulchw. *\/\n\n tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);\n\n tcg_gen_sari_tl(t1, cpu_gpr[rb], 16);\n\n tcg_gen_ext16s_tl(t1, t1);\n\n break;\n\n case 0x04:\n\n \/* macchwu - macchwu. - macchwuo - macchwuo. *\/\n\n \/* macchwsu - macchwsu. - macchwsuo - macchwsuo. *\/\n\n \/* mulchwu - mulchwu. *\/\n\n tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);\n\n tcg_gen_shri_tl(t1, cpu_gpr[rb], 16);\n\n tcg_gen_ext16u_tl(t1, t1);\n\n break;\n\n case 0x01:\n\n \/* machhw - machhw. - machhwo - machhwo. *\/\n\n \/* machhws - machhws. - machhwso - machhwso. *\/\n\n \/* nmachhw - nmachhw. - nmachhwo - nmachhwo. *\/\n\n \/* nmachhws - nmachhws. - nmachhwso - nmachhwso. *\/\n\n \/* mulhhw - mulhhw. *\/\n\n tcg_gen_sari_tl(t0, cpu_gpr[ra], 16);\n\n tcg_gen_ext16s_tl(t0, t0);\n\n tcg_gen_sari_tl(t1, cpu_gpr[rb], 16);\n\n tcg_gen_ext16s_tl(t1, t1);\n\n break;\n\n case 0x00:\n\n \/* machhwu - machhwu. - machhwuo - machhwuo. *\/\n\n \/* machhwsu - machhwsu. - machhwsuo - machhwsuo. *\/\n\n \/* mulhhwu - mulhhwu. *\/\n\n tcg_gen_shri_tl(t0, cpu_gpr[ra], 16);\n\n tcg_gen_ext16u_tl(t0, t0);\n\n tcg_gen_shri_tl(t1, cpu_gpr[rb], 16);\n\n tcg_gen_ext16u_tl(t1, t1);\n\n break;\n\n case 0x0D:\n\n \/* maclhw - maclhw. - maclhwo - maclhwo. *\/\n\n \/* maclhws - maclhws. - maclhwso - maclhwso. *\/\n\n \/* nmaclhw - nmaclhw. - nmaclhwo - nmaclhwo. *\/\n\n \/* nmaclhws - nmaclhws. - nmaclhwso - nmaclhwso. *\/\n\n \/* mullhw - mullhw. *\/\n\n tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);\n\n tcg_gen_ext16s_tl(t1, cpu_gpr[rb]);\n\n break;\n\n case 0x0C:\n\n \/* maclhwu - maclhwu. - maclhwuo - maclhwuo. *\/\n\n \/* maclhwsu - maclhwsu. - maclhwsuo - maclhwsuo. *\/\n\n \/* mullhwu - mullhwu. *\/\n\n tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);\n\n tcg_gen_ext16u_tl(t1, cpu_gpr[rb]);\n\n break;\n\n }\n\n if (opc2 & 0x04) {\n\n \/* (n)multiply-and-accumulate (0x0C \/ 0x0E) *\/\n\n tcg_gen_mul_tl(t1, t0, t1);\n\n if (opc2 & 0x02) {\n\n \/* nmultiply-and-accumulate (0x0E) *\/\n\n tcg_gen_sub_tl(t0, cpu_gpr[rt], t1);\n\n } else {\n\n \/* multiply-and-accumulate (0x0C) *\/\n\n tcg_gen_add_tl(t0, cpu_gpr[rt], t1);\n\n }\n\n\n\n if (opc3 & 0x12) {\n\n \/* Check overflow and\/or saturate *\/\n\n int l1 = gen_new_label();\n\n\n\n if (opc3 & 0x10) {\n\n \/* Start with XER OV disabled, the most likely case *\/\n\n tcg_gen_movi_tl(cpu_ov, 0);\n\n }\n\n if (opc3 & 0x01) {\n\n \/* Signed *\/\n\n tcg_gen_xor_tl(t1, cpu_gpr[rt], t1);\n\n tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);\n\n tcg_gen_xor_tl(t1, cpu_gpr[rt], t0);\n\n tcg_gen_brcondi_tl(TCG_COND_LT, t1, 0, l1);\n\n if (opc3 & 0x02) {\n\n \/* Saturate *\/\n\n tcg_gen_sari_tl(t0, cpu_gpr[rt], 31);\n\n tcg_gen_xori_tl(t0, t0, 0x7fffffff);\n\n }\n\n } else {\n\n \/* Unsigned *\/\n\n tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, l1);\n\n if (opc3 & 0x02) {\n\n \/* Saturate *\/\n\n tcg_gen_movi_tl(t0, UINT32_MAX);\n\n }\n\n }\n\n if (opc3 & 0x10) {\n\n \/* Check overflow *\/\n\n tcg_gen_movi_tl(cpu_ov, 1);\n\n tcg_gen_movi_tl(cpu_so, 1);\n\n }\n\n gen_set_label(l1);\n\n tcg_gen_mov_tl(cpu_gpr[rt], t0);\n\n }\n\n } else {\n\n tcg_gen_mul_tl(cpu_gpr[rt], t0, t1);\n\n }\n\n tcg_temp_free(t0);\n\n tcg_temp_free(t1);\n\n if (unlikely(Rc) != 0) {\n\n \/* Update Rc0 *\/\n\n gen_set_Rc0(ctx, cpu_gpr[rt]);\n\n }\n\n}\n","target":0,"code_token_length":1579,"total_token_length":1815,"max_tokens_setting":2048} +{"idx":343244,"func":"static int ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary *conf, AVDictionary **opts)\n\n{\n\n AVDictionaryEntry *e;\n\n int ret = 0;\n\n\n\n \/* Return values from ffserver_set_*_param are ignored.\n\n Values are initially parsed and checked before inserting to AVDictionary. *\/\n\n\n\n \/\/video params\n\n if ((e = av_dict_get(conf, \"VideoBitRateRangeMin\", NULL, 0)))\n\n ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoBitRateRangeMax\", NULL, 0)))\n\n ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"Debug\", NULL, 0)))\n\n ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"Strict\", NULL, 0)))\n\n ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoBufferSize\", NULL, 0)))\n\n ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoBitRateTolerance\", NULL, 0)))\n\n ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoBitRate\", NULL, 0)))\n\n ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoSizeWidth\", NULL, 0)))\n\n ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoSizeHeight\", NULL, 0)))\n\n ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"PixelFormat\", NULL, 0))) {\n\n int val;\n\n ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n enc->pix_fmt = val;\n\n }\n\n if ((e = av_dict_get(conf, \"VideoGopSize\", NULL, 0)))\n\n ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoFrameRateNum\", NULL, 0)))\n\n ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoFrameRateDen\", NULL, 0)))\n\n ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoQDiff\", NULL, 0)))\n\n ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoQMax\", NULL, 0)))\n\n ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"VideoQMin\", NULL, 0)))\n\n ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"LumiMask\", NULL, 0)))\n\n ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX, FLT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"DarkMask\", NULL, 0)))\n\n ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX, FLT_MAX, NULL, 0, NULL);\n\n if (av_dict_get(conf, \"BitExact\", NULL, 0))\n\n enc->flags |= CODEC_FLAG_BITEXACT;\n\n if (av_dict_get(conf, \"DctFastint\", NULL, 0))\n\n enc->dct_algo = FF_DCT_FASTINT;\n\n if (av_dict_get(conf, \"IdctSimple\", NULL, 0))\n\n enc->idct_algo = FF_IDCT_SIMPLE;\n\n if (av_dict_get(conf, \"VideoHighQuality\", NULL, 0))\n\n enc->mb_decision = FF_MB_DECISION_BITS;\n\n if ((e = av_dict_get(conf, \"VideoTag\", NULL, 0)))\n\n enc->codec_tag = MKTAG(e->value[0], e->value[1], e->value[2], e->value[3]);\n\n if (av_dict_get(conf, \"Qscale\", NULL, 0)) {\n\n enc->flags |= CODEC_FLAG_QSCALE;\n\n ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n }\n\n if (av_dict_get(conf, \"Video4MotionVector\", NULL, 0)) {\n\n enc->mb_decision = FF_MB_DECISION_BITS; \/\/FIXME remove\n\n enc->flags |= CODEC_FLAG_4MV;\n\n }\n\n \/\/audio params\n\n if ((e = av_dict_get(conf, \"AudioChannels\", NULL, 0)))\n\n ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"AudioSampleRate\", NULL, 0)))\n\n ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n if ((e = av_dict_get(conf, \"AudioBitRate\", NULL, 0)))\n\n ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL);\n\n\n\n av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN);\n\n e = NULL;\n\n while (e = av_dict_get(*opts, \"\", e, AV_DICT_IGNORE_SUFFIX)) {\n\n av_log(NULL, AV_LOG_ERROR, \"Provided AVOption '%s' doesn't match any existing option.\\n\", e->key);\n\n ret = AVERROR(EINVAL);\n\n }\n\n\n\n return ret;\n\n}\n","target":0,"code_token_length":1587,"total_token_length":1823,"max_tokens_setting":2048} +{"idx":262794,"func":"static void ImportBlackQuantum(const Image *image,QuantumInfo *quantum_info,\n const MagickSizeType number_pixels,const unsigned char *magick_restrict p,\n Quantum *magick_restrict q,ExceptionInfo *exception)\n{\n QuantumAny\n range;\n\n register ssize_t\n x;\n\n unsigned int\n pixel;\n\n if (image->colorspace != CMYKColorspace)\n {\n (void) ThrowMagickException(exception,GetMagickModule(),ImageError,\n \"ColorSeparatedImageRequired\",\"`%s'\",image->filename);\n return;\n }\n switch (quantum_info->depth)\n {\n case 8:\n {\n unsigned char\n pixel;\n\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushCharPixel(p,&pixel);\n SetPixelBlack(image,ScaleCharToQuantum(pixel),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n case 16:\n {\n unsigned short\n pixel;\n\n if (quantum_info->format == FloatingPointQuantumFormat)\n {\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushShortPixel(quantum_info->endian,p,&pixel);\n SetPixelBlack(image,ClampToQuantum(QuantumRange*\n HalfToSinglePrecision(pixel)),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushShortPixel(quantum_info->endian,p,&pixel);\n SetPixelBlack(image,ScaleShortToQuantum(pixel),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n case 32:\n {\n unsigned int\n pixel;\n\n if (quantum_info->format == FloatingPointQuantumFormat)\n {\n float\n pixel;\n\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushFloatPixel(quantum_info,p,&pixel);\n SetPixelBlack(image,ClampToQuantum(pixel),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushLongPixel(quantum_info->endian,p,&pixel);\n SetPixelBlack(image,ScaleLongToQuantum(pixel),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n case 64:\n {\n if (quantum_info->format == FloatingPointQuantumFormat)\n {\n double\n pixel;\n\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushDoublePixel(quantum_info,p,&pixel);\n SetPixelBlack(image,ClampToQuantum(pixel),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n }\n default:\n {\n range=GetQuantumRange(quantum_info->depth);\n for (x=0; x < (ssize_t) number_pixels; x++)\n {\n p=PushQuantumPixel(quantum_info,p,&pixel);\n SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);\n p+=quantum_info->pad;\n q+=GetPixelChannels(image);\n }\n break;\n }\n }\n}","target":0,"code_token_length":804,"total_token_length":1040,"max_tokens_setting":2048} +{"idx":501294,"func":"static size_t ZSTD_compressLiterals (ZSTD_hufCTables_t const* prevHuf,\n ZSTD_hufCTables_t* nextHuf,\n ZSTD_strategy strategy, int disableLiteralCompression,\n void* dst, size_t dstCapacity,\n const void* src, size_t srcSize,\n void* workspace, size_t wkspSize,\n const int bmi2)\n{\n size_t const minGain = ZSTD_minGain(srcSize, strategy);\n size_t const lhSize = 3 + (srcSize >= 1 KB) + (srcSize >= 16 KB);\n BYTE* const ostart = (BYTE*)dst;\n U32 singleStream = srcSize < 256;\n symbolEncodingType_e hType = set_compressed;\n size_t cLitSize;\n\n DEBUGLOG(5,\"ZSTD_compressLiterals (disableLiteralCompression=%i)\",\n disableLiteralCompression);\n\n \/* Prepare nextEntropy assuming reusing the existing table *\/\n memcpy(nextHuf, prevHuf, sizeof(*prevHuf));\n\n if (disableLiteralCompression)\n return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);\n\n \/* small ? don't even attempt compression (speed opt) *\/\n# define COMPRESS_LITERALS_SIZE_MIN 63\n { size_t const minLitSize = (prevHuf->repeatMode == HUF_repeat_valid) ? 6 : COMPRESS_LITERALS_SIZE_MIN;\n if (srcSize <= minLitSize) return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);\n }\n\n if (dstCapacity < lhSize+1) return ERROR(dstSize_tooSmall); \/* not enough space for compression *\/\n { HUF_repeat repeat = prevHuf->repeatMode;\n int const preferRepeat = strategy < ZSTD_lazy ? srcSize <= 1024 : 0;\n if (repeat == HUF_repeat_valid && lhSize == 3) singleStream = 1;\n cLitSize = singleStream ? HUF_compress1X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11,\n workspace, wkspSize, (HUF_CElt*)nextHuf->CTable, &repeat, preferRepeat, bmi2)\n : HUF_compress4X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11,\n workspace, wkspSize, (HUF_CElt*)nextHuf->CTable, &repeat, preferRepeat, bmi2);\n if (repeat != HUF_repeat_none) {\n \/* reused the existing table *\/\n hType = set_repeat;\n }\n }\n\n if ((cLitSize==0) | (cLitSize >= srcSize - minGain) | ERR_isError(cLitSize)) {\n memcpy(nextHuf, prevHuf, sizeof(*prevHuf));\n return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);\n }\n if (cLitSize==1) {\n memcpy(nextHuf, prevHuf, sizeof(*prevHuf));\n return ZSTD_compressRleLiteralsBlock(dst, dstCapacity, src, srcSize);\n }\n\n if (hType == set_compressed) {\n \/* using a newly constructed table *\/\n nextHuf->repeatMode = HUF_repeat_check;\n }\n\n \/* Build header *\/\n switch(lhSize)\n {\n case 3: \/* 2 - 2 - 10 - 10 *\/\n { U32 const lhc = hType + ((!singleStream) << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<14);\n MEM_writeLE24(ostart, lhc);\n break;\n }\n case 4: \/* 2 - 2 - 14 - 14 *\/\n { U32 const lhc = hType + (2 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<18);\n MEM_writeLE32(ostart, lhc);\n break;\n }\n case 5: \/* 2 - 2 - 18 - 18 *\/\n { U32 const lhc = hType + (3 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<22);\n MEM_writeLE32(ostart, lhc);\n ostart[4] = (BYTE)(cLitSize >> 10);\n break;\n }\n default: \/* not possible : lhSize is {3,4,5} *\/\n assert(0);\n }\n return lhSize+cLitSize;\n}","target":0,"code_token_length":1054,"total_token_length":1290,"max_tokens_setting":2048} +{"idx":224480,"func":"WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(\n PrefService* prefs, bool is_dom_ui) {\n\n WebPreferences web_prefs;\n\n web_prefs.fixed_font_family =\n prefs->GetString(prefs::kWebKitFixedFontFamily);\n web_prefs.serif_font_family =\n prefs->GetString(prefs::kWebKitSerifFontFamily);\n web_prefs.sans_serif_font_family =\n prefs->GetString(prefs::kWebKitSansSerifFontFamily);\n if (prefs->GetBoolean(prefs::kWebKitStandardFontIsSerif))\n web_prefs.standard_font_family = web_prefs.serif_font_family;\n else\n web_prefs.standard_font_family = web_prefs.sans_serif_font_family;\n web_prefs.cursive_font_family =\n prefs->GetString(prefs::kWebKitCursiveFontFamily);\n web_prefs.fantasy_font_family =\n prefs->GetString(prefs::kWebKitFantasyFontFamily);\n\n web_prefs.default_font_size =\n prefs->GetInteger(prefs::kWebKitDefaultFontSize);\n web_prefs.default_fixed_font_size =\n prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize);\n web_prefs.minimum_font_size =\n prefs->GetInteger(prefs::kWebKitMinimumFontSize);\n web_prefs.minimum_logical_font_size =\n prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize);\n\n web_prefs.default_encoding =\n WideToASCII(prefs->GetString(prefs::kDefaultCharset));\n\n web_prefs.javascript_can_open_windows_automatically =\n prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically);\n web_prefs.dom_paste_enabled =\n prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);\n web_prefs.shrinks_standalone_images_to_fit =\n prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);\n web_prefs.inspector_settings = WideToUTF8(\n prefs->GetString(prefs::kWebKitInspectorSettings));\n\n { \/\/ Command line switches are used for preferences with no user interface.\n const CommandLine& command_line = *CommandLine::ForCurrentProcess();\n web_prefs.developer_extras_enabled =\n !command_line.HasSwitch(switches::kDisableDevTools);\n web_prefs.javascript_enabled =\n !command_line.HasSwitch(switches::kDisableJavaScript) &&\n prefs->GetBoolean(prefs::kWebKitJavascriptEnabled);\n web_prefs.web_security_enabled =\n !command_line.HasSwitch(switches::kDisableWebSecurity) &&\n prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled);\n web_prefs.plugins_enabled =\n !command_line.HasSwitch(switches::kDisablePlugins) &&\n prefs->GetBoolean(prefs::kWebKitPluginsEnabled);\n web_prefs.java_enabled =\n !command_line.HasSwitch(switches::kDisableJava) &&\n prefs->GetBoolean(prefs::kWebKitJavaEnabled);\n web_prefs.loads_images_automatically =\n !command_line.HasSwitch(switches::kDisableImages) &&\n prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically);\n web_prefs.uses_page_cache =\n command_line.HasSwitch(switches::kEnableFastback);\n web_prefs.remote_fonts_enabled =\n command_line.HasSwitch(switches::kEnableRemoteFonts);\n web_prefs.xss_auditor_enabled =\n !command_line.HasSwitch(switches::kDisableXSSAuditor);\n web_prefs.application_cache_enabled =\n command_line.HasSwitch(switches::kEnableApplicationCache);\n\n web_prefs.local_storage_enabled =\n command_line.HasSwitch(switches::kEnableLocalStorage);\n web_prefs.databases_enabled =\n command_line.HasSwitch(switches::kEnableDatabases);\n web_prefs.session_storage_enabled =\n command_line.HasSwitch(switches::kEnableSessionStorage);\n web_prefs.experimental_webgl_enabled =\n command_line.HasSwitch(switches::kEnableExperimentalWebGL);\n }\n \n web_prefs.uses_universal_detector =\n prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector);\n web_prefs.text_areas_are_resizable =\n prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable);\n\n\n web_prefs.default_encoding =\n CharacterEncoding::GetCanonicalEncodingNameByAliasName(\n web_prefs.default_encoding);\n if (web_prefs.default_encoding.empty()) {\n prefs->ClearPref(prefs::kDefaultCharset);\n web_prefs.default_encoding = WideToASCII(\n prefs->GetString(prefs::kDefaultCharset));\n }\n DCHECK(!web_prefs.default_encoding.empty());\n\n if (is_dom_ui) {\n web_prefs.loads_images_automatically = true;\n web_prefs.javascript_enabled = true;\n }\n\n return web_prefs;\n}\n","target":0,"code_token_length":976,"total_token_length":1212,"max_tokens_setting":2048} +{"idx":302494,"func":"userauth_pubkey(struct ssh *ssh)\n{\n\tAuthctxt *authctxt = ssh->authctxt;\n\tstruct passwd *pw = authctxt->pw;\n\tstruct sshbuf *b = NULL;\n\tstruct sshkey *key = NULL;\n\tchar *pkalg = NULL, *userstyle = NULL, *key_s = NULL, *ca_s = NULL;\n\tu_char *pkblob = NULL, *sig = NULL, have_sig;\n\tsize_t blen, slen;\n\tint r, pktype;\n\tint authenticated = 0;\n\tstruct sshauthopt *authopts = NULL;\n\n\tif ((r = sshpkt_get_u8(ssh, &have_sig)) != 0 ||\n\t (r = sshpkt_get_cstring(ssh, &pkalg, NULL)) != 0 ||\n\t (r = sshpkt_get_string(ssh, &pkblob, &blen)) != 0)\n\t\tfatal(\"%s: parse request failed: %s\", __func__, ssh_err(r));\n\tpktype = sshkey_type_from_name(pkalg);\n\tif (pktype == KEY_UNSPEC) {\n\t\t\/* this is perfectly legal *\/\n\t\tverbose(\"%s: unsupported public key algorithm: %s\",\n\t\t __func__, pkalg);\n\t\tgoto done;\n\t}\n\tif ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {\n\t\terror(\"%s: could not parse key: %s\", __func__, ssh_err(r));\n\t\tgoto done;\n\t}\n\tif (key == NULL) {\n\t\terror(\"%s: cannot decode key: %s\", __func__, pkalg);\n\t\tgoto done;\n\t}\n\tif (key->type != pktype) {\n\t\terror(\"%s: type mismatch for decoded key \"\n\t\t \"(received %d, expected %d)\", __func__, key->type, pktype);\n\t\tgoto done;\n\t}\n\tif (sshkey_type_plain(key->type) == KEY_RSA &&\n\t (ssh->compat & SSH_BUG_RSASIGMD5) != 0) {\n\t\tlogit(\"Refusing RSA key because client uses unsafe \"\n\t\t \"signature scheme\");\n\t\tgoto done;\n\t}\n\tif (auth2_key_already_used(authctxt, key)) {\n\t\tlogit(\"refusing previously-used %s key\", sshkey_type(key));\n\t\tgoto done;\n\t}\n\tif (match_pattern_list(pkalg, options.pubkey_key_types, 0) != 1) {\n\t\tlogit(\"%s: key type %s not in PubkeyAcceptedKeyTypes\",\n\t\t __func__, sshkey_ssh_name(key));\n\t\tgoto done;\n\t}\n\n\tkey_s = format_key(key);\n\tif (sshkey_is_cert(key))\n\t\tca_s = format_key(key->cert->signature_key);\n\n\tif (have_sig) {\n\t\tdebug3(\"%s: have %s signature for %s%s%s\",\n\t\t __func__, pkalg, key_s,\n\t\t ca_s == NULL ? \"\" : \" CA \",\n\t\t ca_s == NULL ? \"\" : ca_s);\n\t\tif ((r = sshpkt_get_string(ssh, &sig, &slen)) != 0 ||\n\t\t (r = sshpkt_get_end(ssh)) != 0)\n\t\t\tfatal(\"%s: %s\", __func__, ssh_err(r));\n\t\tif ((b = sshbuf_new()) == NULL)\n\t\t\tfatal(\"%s: sshbuf_new failed\", __func__);\n\t\tif (ssh->compat & SSH_OLD_SESSIONID) {\n\t\t\tif ((r = sshbuf_put(b, session_id2,\n\t\t\t session_id2_len)) != 0)\n\t\t\t\tfatal(\"%s: sshbuf_put session id: %s\",\n\t\t\t\t __func__, ssh_err(r));\n\t\t} else {\n\t\t\tif ((r = sshbuf_put_string(b, session_id2,\n\t\t\t session_id2_len)) != 0)\n\t\t\t\tfatal(\"%s: sshbuf_put_string session id: %s\",\n\t\t\t\t __func__, ssh_err(r));\n\t\t}\n\t\tif (!authctxt->valid || authctxt->user == NULL) {\n\t\t\tdebug2(\"%s: disabled because of invalid user\",\n\t\t\t __func__);\n\t\t\tgoto done;\n\t\t}\n\t\t\/* reconstruct packet *\/\n\t\txasprintf(&userstyle, \"%s%s%s\", authctxt->user,\n\t\t authctxt->style ? \":\" : \"\",\n\t\t authctxt->style ? authctxt->style : \"\");\n\t\tif ((r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||\n\t\t (r = sshbuf_put_cstring(b, userstyle)) != 0 ||\n\t\t (r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||\n\t\t (r = sshbuf_put_cstring(b, \"publickey\")) != 0 ||\n\t\t (r = sshbuf_put_u8(b, have_sig)) != 0 ||\n\t\t (r = sshbuf_put_cstring(b, pkalg) != 0) ||\n\t\t (r = sshbuf_put_string(b, pkblob, blen)) != 0)\n\t\t\tfatal(\"%s: build packet failed: %s\",\n\t\t\t __func__, ssh_err(r));\n#ifdef DEBUG_PK\n\t\tsshbuf_dump(b, stderr);\n#endif\n\t\t\/* test for correct signature *\/\n\t\tauthenticated = 0;\n\t\tif (PRIVSEP(user_key_allowed(ssh, pw, key, 1, &authopts)) &&\n\t\t PRIVSEP(sshkey_verify(key, sig, slen,\n\t\t sshbuf_ptr(b), sshbuf_len(b),\n\t\t (ssh->compat & SSH_BUG_SIGTYPE) == 0 ? pkalg : NULL,\n\t\t ssh->compat)) == 0) {\n\t\t\tauthenticated = 1;\n\t\t}\n\t\tsshbuf_free(b);\n\t\tauth2_record_key(authctxt, authenticated, key);\n\t} else {\n\t\tdebug(\"%s: test pkalg %s pkblob %s%s%s\",\n\t\t __func__, pkalg, key_s,\n\t\t ca_s == NULL ? \"\" : \" CA \",\n\t\t ca_s == NULL ? \"\" : ca_s);\n\n\t\tif ((r = sshpkt_get_end(ssh)) != 0)\n\t\t\tfatal(\"%s: %s\", __func__, ssh_err(r));\n\n\t\tif (!authctxt->valid || authctxt->user == NULL) {\n\t\t\tdebug2(\"%s: disabled because of invalid user\",\n\t\t\t __func__);\n\t\t\tgoto done;\n\t\t}\n\t\t\/* XXX fake reply and always send PK_OK ? *\/\n\t\t\/*\n\t\t * XXX this allows testing whether a user is allowed\n\t\t * to login: if you happen to have a valid pubkey this\n\t\t * message is sent. the message is NEVER sent at all\n\t\t * if a user is not allowed to login. is this an\n\t\t * issue? -markus\n\t\t *\/\n\t\tif (PRIVSEP(user_key_allowed(ssh, pw, key, 0, NULL))) {\n\t\t\tif ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_PK_OK))\n\t\t\t != 0 ||\n\t\t\t (r = sshpkt_put_cstring(ssh, pkalg)) != 0 ||\n\t\t\t (r = sshpkt_put_string(ssh, pkblob, blen)) != 0 ||\n\t\t\t (r = sshpkt_send(ssh)) != 0 ||\n\t\t\t (r = ssh_packet_write_wait(ssh)) != 0)\n\t\t\t\tfatal(\"%s: %s\", __func__, ssh_err(r));\n\t\t\tauthctxt->postponed = 1;\n\t\t}\n\t}\ndone:\n\tif (authenticated == 1 && auth_activate_options(ssh, authopts) != 0) {\n\t\tdebug(\"%s: key options inconsistent with existing\", __func__);\n\t\tauthenticated = 0;\n\t}\n\tdebug2(\"%s: authenticated %d pkalg %s\", __func__, authenticated, pkalg);\n\n\tsshauthopt_free(authopts);\n\tsshkey_free(key);\n\tfree(userstyle);\n\tfree(pkalg);\n\tfree(pkblob);\n\tfree(key_s);\n\tfree(ca_s);\n\tfree(sig);\n\treturn authenticated;\n}","target":0,"code_token_length":1664,"total_token_length":1900,"max_tokens_setting":2048} +{"idx":343632,"func":"int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max)\n{\n\tstruct page *page;\n\tstruct address_space *mapping;\n\t__be32 *pptr, *curr, *end;\n\tu32 mask, start, len, n;\n\t__be32 val;\n\tint i;\n\n\tlen = *max;\n\tif (!len)\n\t\treturn size;\n\n\tdprint(DBG_BITMAP, \"block_allocate: %u,%u,%u\\n\", size, offset, len);\n\tmutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);\n\tmapping = HFSPLUS_SB(sb).alloc_file->i_mapping;\n\tpage = read_mapping_page(mapping, offset \/ PAGE_CACHE_BITS, NULL);\n\tpptr = kmap(page);\n\tcurr = pptr + (offset & (PAGE_CACHE_BITS - 1)) \/ 32;\n\ti = offset % 32;\n\toffset &= ~(PAGE_CACHE_BITS - 1);\n\tif ((size ^ offset) \/ PAGE_CACHE_BITS)\n\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\telse\n\t\tend = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) \/ 32;\n\n\t\/* scan the first partial u32 for zero bits *\/\n\tval = *curr;\n\tif (~val) {\n\t\tn = be32_to_cpu(val);\n\t\tmask = (1U << 31) >> i;\n\t\tfor (; i < 32; mask >>= 1, i++) {\n\t\t\tif (!(n & mask))\n\t\t\t\tgoto found;\n\t\t}\n\t}\n\tcurr++;\n\n\t\/* scan complete u32s for the first zero bit *\/\n\twhile (1) {\n\t\twhile (curr < end) {\n\t\t\tval = *curr;\n\t\t\tif (~val) {\n\t\t\t\tn = be32_to_cpu(val);\n\t\t\t\tmask = 1 << 31;\n\t\t\t\tfor (i = 0; i < 32; mask >>= 1, i++) {\n\t\t\t\t\tif (!(n & mask))\n\t\t\t\t\t\tgoto found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurr++;\n\t\t}\n\t\tkunmap(page);\n\t\toffset += PAGE_CACHE_BITS;\n\t\tif (offset >= size)\n\t\t\tbreak;\n\t\tpage = read_mapping_page(mapping, offset \/ PAGE_CACHE_BITS,\n\t\t\t\t\t NULL);\n\t\tcurr = pptr = kmap(page);\n\t\tif ((size ^ offset) \/ PAGE_CACHE_BITS)\n\t\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\t\telse\n\t\t\tend = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) \/ 32;\n\t}\n\tdprint(DBG_BITMAP, \"bitmap full\\n\");\n\tstart = size;\n\tgoto out;\n\nfound:\n\tstart = offset + (curr - pptr) * 32 + i;\n\tif (start >= size) {\n\t\tdprint(DBG_BITMAP, \"bitmap full\\n\");\n\t\tgoto out;\n\t}\n\t\/* do any partial u32 at the start *\/\n\tlen = min(size - start, len);\n\twhile (1) {\n\t\tn |= mask;\n\t\tif (++i >= 32)\n\t\t\tbreak;\n\t\tmask >>= 1;\n\t\tif (!--len || n & mask)\n\t\t\tgoto done;\n\t}\n\tif (!--len)\n\t\tgoto done;\n\t*curr++ = cpu_to_be32(n);\n\t\/* do full u32s *\/\n\twhile (1) {\n\t\twhile (curr < end) {\n\t\t\tn = be32_to_cpu(*curr);\n\t\t\tif (len < 32)\n\t\t\t\tgoto last;\n\t\t\tif (n) {\n\t\t\t\tlen = 32;\n\t\t\t\tgoto last;\n\t\t\t}\n\t\t\t*curr++ = cpu_to_be32(0xffffffff);\n\t\t\tlen -= 32;\n\t\t}\n\t\tset_page_dirty(page);\n\t\tkunmap(page);\n\t\toffset += PAGE_CACHE_BITS;\n\t\tpage = read_mapping_page(mapping, offset \/ PAGE_CACHE_BITS,\n\t\t\t\t\t NULL);\n\t\tpptr = kmap(page);\n\t\tcurr = pptr;\n\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\t}\nlast:\n\t\/* do any partial u32 at end *\/\n\tmask = 1U << 31;\n\tfor (i = 0; i < len; i++) {\n\t\tif (n & mask)\n\t\t\tbreak;\n\t\tn |= mask;\n\t\tmask >>= 1;\n\t}\ndone:\n\t*curr = cpu_to_be32(n);\n\tset_page_dirty(page);\n\tkunmap(page);\n\t*max = offset + (curr - pptr) * 32 + i - start;\n\tHFSPLUS_SB(sb).free_blocks -= *max;\n\tsb->s_dirt = 1;\n\tdprint(DBG_BITMAP, \"-> %u,%u\\n\", start, *max);\nout:\n\tmutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);\n\treturn start;\n}","target":1,"code_token_length":1017,"total_token_length":1253,"max_tokens_setting":2048} +{"idx":398672,"func":"gst_qtdemux_adjust_seek (GstQTDemux * qtdemux, gint64 desired_time,\n gboolean use_sparse, gint64 * key_time, gint64 * key_offset)\n{\n guint64 min_offset;\n gint64 min_byte_offset = -1;\n gint n;\n\n min_offset = desired_time;\n\n \/* for each stream, find the index of the sample in the segment\n * and move back to the previous keyframe. *\/\n for (n = 0; n < qtdemux->n_streams; n++) {\n QtDemuxStream *str;\n guint32 index, kindex;\n guint32 seg_idx;\n GstClockTime media_start;\n GstClockTime media_time;\n GstClockTime seg_time;\n QtDemuxSegment *seg;\n gboolean empty_segment = FALSE;\n\n str = qtdemux->streams[n];\n\n if (str->sparse && !use_sparse)\n continue;\n\n seg_idx = gst_qtdemux_find_segment (qtdemux, str, desired_time);\n GST_DEBUG_OBJECT (qtdemux, \"align segment %d\", seg_idx);\n\n \/* get segment and time in the segment *\/\n seg = &str->segments[seg_idx];\n seg_time = (desired_time - seg->time) * seg->rate;\n\n while (QTSEGMENT_IS_EMPTY (seg)) {\n seg_time = 0;\n empty_segment = TRUE;\n GST_DEBUG_OBJECT (str->pad, \"Segment %d is empty, moving to next one\",\n seg_idx);\n seg_idx++;\n if (seg_idx == str->n_segments)\n break;\n seg = &str->segments[seg_idx];\n }\n\n if (seg_idx == str->n_segments) {\n \/* FIXME track shouldn't have the last segment as empty, but if it\n * happens we better handle it *\/\n continue;\n }\n\n \/* get the media time in the segment *\/\n media_start = seg->media_start + seg_time;\n\n \/* get the index of the sample with media time *\/\n index = gst_qtdemux_find_index_linear (qtdemux, str, media_start);\n GST_DEBUG_OBJECT (qtdemux, \"sample for %\" GST_TIME_FORMAT \" at %u\"\n \" at offset %\" G_GUINT64_FORMAT \" (empty segment: %d)\",\n GST_TIME_ARGS (media_start), index, str->samples[index].offset,\n empty_segment);\n\n if (!empty_segment) {\n \/* find previous keyframe *\/\n kindex = gst_qtdemux_find_keyframe (qtdemux, str, index);\n\n \/* if the keyframe is at a different position, we need to update the\n * requested seek time *\/\n if (index != kindex) {\n index = kindex;\n\n \/* get timestamp of keyframe *\/\n media_time = QTSAMPLE_DTS (str, &str->samples[kindex]);\n GST_DEBUG_OBJECT (qtdemux,\n \"keyframe at %u with time %\" GST_TIME_FORMAT \" at offset %\"\n G_GUINT64_FORMAT, kindex, GST_TIME_ARGS (media_time),\n str->samples[kindex].offset);\n\n \/* keyframes in the segment get a chance to change the\n * desired_offset. keyframes out of the segment are\n * ignored. *\/\n if (media_time >= seg->media_start) {\n GstClockTime seg_time;\n\n \/* this keyframe is inside the segment, convert back to\n * segment time *\/\n seg_time = (media_time - seg->media_start) + seg->time;\n if (seg_time < min_offset)\n min_offset = seg_time;\n }\n }\n }\n\n if (min_byte_offset < 0 || str->samples[index].offset < min_byte_offset)\n min_byte_offset = str->samples[index].offset;\n }\n\n if (key_time)\n *key_time = min_offset;\n if (key_offset)\n *key_offset = min_byte_offset;\n}","target":0,"code_token_length":861,"total_token_length":1097,"max_tokens_setting":2048} +{"idx":396155,"func":"static int lru_pull_tail(const int orig_id, const int cur_lru,\n const uint64_t total_bytes, uint8_t flags) {\n item *it = NULL;\n int id = orig_id;\n int removed = 0;\n if (id == 0)\n return 0;\n\n int tries = 5;\n item *search;\n item *next_it;\n void *hold_lock = NULL;\n unsigned int move_to_lru = 0;\n uint64_t limit = 0;\n\n id |= cur_lru;\n pthread_mutex_lock(&lru_locks[id]);\n search = tails[id];\n \/* We walk up *only* for locked items, and if bottom is expired. *\/\n for (; tries > 0 && search != NULL; tries--, search=next_it) {\n \/* we might relink search mid-loop, so search->prev isn't reliable *\/\n next_it = search->prev;\n if (search->nbytes == 0 && search->nkey == 0 && search->it_flags == 1) {\n \/* We are a crawler, ignore it. *\/\n if (flags & LRU_PULL_CRAWL_BLOCKS) {\n pthread_mutex_unlock(&lru_locks[id]);\n return 0;\n }\n tries++;\n continue;\n }\n uint32_t hv = hash(ITEM_key(search), search->nkey);\n \/* Attempt to hash item lock the \"search\" item. If locked, no\n * other callers can incr the refcount. Also skip ourselves. *\/\n if ((hold_lock = item_trylock(hv)) == NULL)\n continue;\n \/* Now see if the item is refcount locked *\/\n if (refcount_incr(&search->refcount) != 2) {\n \/* Note pathological case with ref'ed items in tail.\n * Can still unlink the item, but it won't be reusable yet *\/\n itemstats[id].lrutail_reflocked++;\n \/* In case of refcount leaks, enable for quick workaround. *\/\n \/* WARNING: This can cause terrible corruption *\/\n if (settings.tail_repair_time &&\n search->time + settings.tail_repair_time < current_time) {\n itemstats[id].tailrepairs++;\n search->refcount = 1;\n \/* This will call item_remove -> item_free since refcnt is 1 *\/\n do_item_unlink_nolock(search, hv);\n item_trylock_unlock(hold_lock);\n continue;\n }\n }\n\n \/* Expired or flushed *\/\n if ((search->exptime != 0 && search->exptime < current_time)\n || item_is_flushed(search)) {\n itemstats[id].reclaimed++;\n if ((search->it_flags & ITEM_FETCHED) == 0) {\n itemstats[id].expired_unfetched++;\n }\n \/* refcnt 2 -> 1 *\/\n do_item_unlink_nolock(search, hv);\n \/* refcnt 1 -> 0 -> item_free *\/\n do_item_remove(search);\n item_trylock_unlock(hold_lock);\n removed++;\n\n \/* If all we're finding are expired, can keep going *\/\n continue;\n }\n\n \/* If we're HOT_LRU or WARM_LRU and over size limit, send to COLD_LRU.\n * If we're COLD_LRU, send to WARM_LRU unless we need to evict\n *\/\n switch (cur_lru) {\n case HOT_LRU:\n limit = total_bytes * settings.hot_lru_pct \/ 100;\n case WARM_LRU:\n if (limit == 0)\n limit = total_bytes * settings.warm_lru_pct \/ 100;\n if (sizes_bytes[id] > limit) {\n itemstats[id].moves_to_cold++;\n move_to_lru = COLD_LRU;\n do_item_unlink_q(search);\n it = search;\n removed++;\n break;\n } else if ((search->it_flags & ITEM_ACTIVE) != 0) {\n \/* Only allow ACTIVE relinking if we're not too large. *\/\n itemstats[id].moves_within_lru++;\n search->it_flags &= ~ITEM_ACTIVE;\n do_item_update_nolock(search);\n do_item_remove(search);\n item_trylock_unlock(hold_lock);\n } else {\n \/* Don't want to move to COLD, not active, bail out *\/\n it = search;\n }\n break;\n case COLD_LRU:\n it = search; \/* No matter what, we're stopping *\/\n if (flags & LRU_PULL_EVICT) {\n if (settings.evict_to_free == 0) {\n \/* Don't think we need a counter for this. It'll OOM. *\/\n break;\n }\n itemstats[id].evicted++;\n itemstats[id].evicted_time = current_time - search->time;\n if (search->exptime != 0)\n itemstats[id].evicted_nonzero++;\n if ((search->it_flags & ITEM_FETCHED) == 0) {\n itemstats[id].evicted_unfetched++;\n }\n LOGGER_LOG(NULL, LOG_EVICTIONS, LOGGER_EVICTION, search);\n do_item_unlink_nolock(search, hv);\n removed++;\n if (settings.slab_automove == 2) {\n slabs_reassign(-1, orig_id);\n }\n } else if ((search->it_flags & ITEM_ACTIVE) != 0\n && settings.lru_maintainer_thread) {\n itemstats[id].moves_to_warm++;\n search->it_flags &= ~ITEM_ACTIVE;\n move_to_lru = WARM_LRU;\n do_item_unlink_q(search);\n removed++;\n }\n break;\n }\n if (it != NULL)\n break;\n }\n\n pthread_mutex_unlock(&lru_locks[id]);\n\n if (it != NULL) {\n if (move_to_lru) {\n it->slabs_clsid = ITEM_clsid(it);\n it->slabs_clsid |= move_to_lru;\n item_link_q(it);\n }\n do_item_remove(it);\n item_trylock_unlock(hold_lock);\n }\n\n return removed;\n}","target":0,"code_token_length":1326,"total_token_length":1562,"max_tokens_setting":2048} +{"idx":489791,"func":"\n\t\tds->tile_dep_id_merged = GF_TRUE;\n\t\tif (ds->rep->dependency_id) gf_free(ds->rep->dependency_id);\n\t\tds->rep->dependency_id = gf_strdup(base_ds->merged_tile_dep->rep->id);\n\t}\n}\n\nstatic void dasher_check_bitstream_swicthing(GF_DasherCtx *ctx, GF_MPD_AdaptationSet *set)\n{\n\tu32 i, j, count;\n\tBool use_inband = ((ctx->bs_switch==DASHER_BS_SWITCH_INBAND) || (ctx->bs_switch==DASHER_BS_SWITCH_INBAND_PPS)) ? GF_TRUE : GF_FALSE;\n\tBool use_multi = (ctx->bs_switch==DASHER_BS_SWITCH_MULTI) ? GF_TRUE : GF_FALSE;\n\tGF_MPD_Representation *base_rep = gf_list_get(set->representations, 0);\n\tGF_DashStream *base_ds;\n\n\tswitch (ctx->muxtype) {\n\tcase DASHER_MUX_TS:\n\tcase DASHER_MUX_OGG:\n\tcase DASHER_MUX_RAW:\n\t\tset->bitstream_switching = GF_TRUE;\n\t\treturn;\n\t\/\/other formats use an init segment\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (ctx->bs_switch==DASHER_BS_SWITCH_OFF) return;\n\tif (!base_rep) return;\n\tbase_ds = base_rep->playback.udta;\n\n\tcount = gf_list_count(set->representations);\n\tif (count==1) {\n\t\tif (ctx->bs_switch==DASHER_BS_SWITCH_FORCE) set->bitstream_switching=GF_TRUE;\n\t\telse if (use_inband) {\n\t\t\tif (base_ds->codec_id==GF_CODECID_VVC) {\n\t\t\t\tbase_ds->inband_params = (ctx->bs_switch==DASHER_BS_SWITCH_INBAND_PPS) ? 2 : 1;\n\t\t\t} else {\n\t\t\t\tbase_ds->inband_params = 1;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tfor (i=1; irepresentations, i);\n\t\tGF_DashStream *ds = rep->playback.udta;\n\t\t\/\/same codec ID\n\t\tif (ds->codec_id == base_ds->codec_id) {\n\t\t\t\/\/we will use inband params, so bs switching is OK\n\t\t\tif (use_inband || use_multi) continue;\n\t\t\t\/\/we have deps, cannot use bitstream switching except for merged tile base\n\t\t\tif (ds->dep_id) {\n\t\t\t\tif (ds->codec_id==GF_CODECID_HEVC_TILES) {\n\t\t\t\t\tu32 id;\n\t\t\t\t\tGF_DashStream *tile_base = get_base_ds(ctx, ds);\n\t\t\t\t\tif (!tile_base) return;\n\t\t\t\t\tid = tile_base->merged_tile_dep ? tile_base->merged_tile_dep->id : tile_base->id;\n\t\t\t\t\tif (base_ds->dep_id==id) continue;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\/\/we consider we can switch in non-inband only if we have same CRC for the decoder config\n\t\t\tif (base_ds->dsi_crc == ds->dsi_crc) continue;\n\t\t\t\/\/not the same config, no BS switching\n\t\t\treturn;\n\t\t}\n\t\t\/\/dependencies \/ different codec IDs, cannot use bitstream switching\n\t\treturn;\n\t}\n\t\/\/ok we can use BS switching, ensure we use the same timescale for every stream\n\tset->bitstream_switching = GF_TRUE;\n\n\tfor (i=0; irepresentations, i);\n\t\tGF_DashStream *ds = rep->playback.udta;\n\t\tif (base_ds->tile_base && ds->tile_base && (base_ds != ds) ) {\n\t\t\tds->merged_tile_dep = base_ds;\n\t\t\tif (ds->rep) {\n\t\t\t\tgf_list_rem(set->representations, i);\n\t\t\t\ti--;\n\t\t\t\tcount--;\n\t\t\t\tgf_mpd_representation_free(ds->rep);\n\t\t\t\tds->rep = NULL;\n\t\t\t\t\/\/switch dependencyID of all reps depending on this one to the new base\n\t\t\t\trewrite_dep_ids(ctx, ds);\n\t\t\t\t\/\/and ignore this rep while flushing segments\n\t\t\t\tbase_ds->nb_rep--;\n\t\t\t}\n\t\t}\n\t\tfor (j=i+1; jrepresentations, j);","target":0,"code_token_length":954,"total_token_length":1190,"max_tokens_setting":2048} +{"idx":361048,"func":"int find_service(fstring service)\n{\n\tint iService;\n\tstruct smbd_server_connection *sconn = smbd_server_conn;\n\n\tall_string_sub(service,\"\\\\\",\"\/\",0);\n\n\tiService = lp_servicenumber(service);\n\n\t\/* now handle the special case of a home directory *\/\n\tif (iService < 0) {\n\t\tchar *phome_dir = get_user_home_dir(talloc_tos(), service);\n\n\t\tif(!phome_dir) {\n\t\t\t\/*\n\t\t\t * Try mapping the servicename, it may\n\t\t\t * be a Windows to unix mapped user name.\n\t\t\t *\/\n\t\t\tif(map_username(sconn, service))\n\t\t\t\tphome_dir = get_user_home_dir(\n\t\t\t\t\ttalloc_tos(), service);\n\t\t}\n\n\t\tDEBUG(3,(\"checking for home directory %s gave %s\\n\",service,\n\t\t\tphome_dir?phome_dir:\"(NULL)\"));\n\n\t\tiService = add_home_service(service,service \/* 'username' *\/, phome_dir);\n\t}\n\n\t\/* If we still don't have a service, attempt to add it as a printer. *\/\n\tif (iService < 0) {\n\t\tint iPrinterService;\n\n\t\tif ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) < 0) {\n\t\t\tiPrinterService = load_registry_service(PRINTERS_NAME);\n\t\t}\n\t\tif (iPrinterService) {\n\t\t\tDEBUG(3,(\"checking whether %s is a valid printer name...\\n\", service));\n\t\t\tif (pcap_printername_ok(service)) {\n\t\t\t\tDEBUG(3,(\"%s is a valid printer name\\n\", service));\n\t\t\t\tDEBUG(3,(\"adding %s as a printer service\\n\", service));\n\t\t\t\tlp_add_printer(service, iPrinterService);\n\t\t\t\tiService = lp_servicenumber(service);\n\t\t\t\tif (iService < 0) {\n\t\t\t\t\tDEBUG(0,(\"failed to add %s as a printer service!\\n\", service));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDEBUG(3,(\"%s is not a valid printer name\\n\", service));\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Check for default vfs service? Unsure whether to implement this *\/\n\tif (iService < 0) {\n\t}\n\n\tif (iService < 0) {\n\t\tiService = load_registry_service(service);\n\t}\n\n\t\/* Is it a usershare service ? *\/\n\tif (iService < 0 && *lp_usershare_path()) {\n\t\t\/* Ensure the name is canonicalized. *\/\n\t\tstrlower_m(service);\n\t\tiService = load_usershare_service(service);\n\t}\n\n\t\/* just possibly it's a default service? *\/\n\tif (iService < 0) {\n\t\tchar *pdefservice = lp_defaultservice();\n\t\tif (pdefservice && *pdefservice && !strequal(pdefservice,service) && !strstr_m(service,\"..\")) {\n\t\t\t\/*\n\t\t\t * We need to do a local copy here as lp_defaultservice() \n\t\t\t * returns one of the rotating lp_string buffers that\n\t\t\t * could get overwritten by the recursive find_service() call\n\t\t\t * below. Fix from Josef Hinteregger .\n\t\t\t *\/\n\t\t\tchar *defservice = SMB_STRDUP(pdefservice);\n\n\t\t\tif (!defservice) {\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\t\/* Disallow anything except explicit share names. *\/\n\t\t\tif (strequal(defservice,HOMES_NAME) ||\n\t\t\t\t\tstrequal(defservice, PRINTERS_NAME) ||\n\t\t\t\t\tstrequal(defservice, \"IPC$\")) {\n\t\t\t\tSAFE_FREE(defservice);\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tiService = find_service(defservice);\n\t\t\tif (iService >= 0) {\n\t\t\t\tall_string_sub(service, \"_\",\"\/\",0);\n\t\t\t\tiService = lp_add_service(service, iService);\n\t\t\t}\n\t\t\tSAFE_FREE(defservice);\n\t\t}\n\t}\n\n\tif (iService >= 0) {\n\t\tif (!VALID_SNUM(iService)) {\n\t\t\tDEBUG(0,(\"Invalid snum %d for %s\\n\",iService, service));\n\t\t\tiService = -1;\n\t\t}\n\t}\n\n fail:\n\n\tif (iService < 0)\n\t\tDEBUG(3,(\"find_service() failed to find service %s\\n\", service));\n\n\treturn (iService);\n}","target":0,"code_token_length":900,"total_token_length":1136,"max_tokens_setting":2048} +{"idx":444079,"func":"TEST_F(HttpConnectionManagerImplTest, StartAndFinishSpanNormalFlowEgressDecoratorPropagateFalse) {\n setup(false, \"\");\n envoy::type::v3::FractionalPercent percent1;\n percent1.set_numerator(100);\n envoy::type::v3::FractionalPercent percent2;\n percent2.set_numerator(10000);\n percent2.set_denominator(envoy::type::v3::FractionalPercent::TEN_THOUSAND);\n tracing_config_ = std::make_unique(\n TracingConnectionManagerConfig{Tracing::OperationName::Egress,\n {{\":method\", requestHeaderCustomTag(\":method\")}},\n percent1,\n percent2,\n percent1,\n false,\n 256});\n\n auto* span = new NiceMock();\n EXPECT_CALL(*tracer_, startSpan_(_, _, _, _))\n .WillOnce(\n Invoke([&](const Tracing::Config& config, const HeaderMap&, const StreamInfo::StreamInfo&,\n const Tracing::Decision) -> Tracing::Span* {\n EXPECT_EQ(Tracing::OperationName::Egress, config.operationName());\n\n return span;\n }));\n route_config_provider_.route_config_->route_->decorator_.operation_ = \"testOp\";\n ON_CALL(route_config_provider_.route_config_->route_->decorator_, propagate())\n .WillByDefault(Return(false));\n EXPECT_CALL(*route_config_provider_.route_config_->route_, decorator()).Times(2);\n EXPECT_CALL(route_config_provider_.route_config_->route_->decorator_, apply(_))\n .WillOnce(Invoke(\n [&](const Tracing::Span& apply_to_span) -> void { EXPECT_EQ(span, &apply_to_span); }));\n EXPECT_CALL(*span, finishSpan());\n EXPECT_CALL(*span, setTag(_, _)).Times(testing::AnyNumber());\n EXPECT_CALL(\n runtime_.snapshot_,\n featureEnabled(\"tracing.global_enabled\", An(), _))\n .WillOnce(Return(true));\n EXPECT_CALL(*span, setOperation(_)).Times(0);\n\n std::shared_ptr filter(new NiceMock());\n\n EXPECT_CALL(filter_factory_, createFilterChain(_))\n .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void {\n callbacks.addStreamDecoderFilter(filter);\n }));\n\n \/\/ Treat request as internal, otherwise x-request-id header will be overwritten.\n use_remote_address_ = false;\n EXPECT_CALL(random_, uuid()).Times(0);\n\n NiceMock encoder;\n EXPECT_CALL(*codec_, dispatch(_))\n .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> Http::Status {\n RequestDecoder* decoder = &conn_manager_->newStream(encoder);\n\n RequestHeaderMapPtr headers{\n new TestRequestHeaderMapImpl{{\":method\", \"GET\"},\n {\":authority\", \"host\"},\n {\":path\", \"\/\"},\n {\"x-request-id\", \"125a4afb-6f55-a4ba-ad80-413f09f48a28\"}}};\n decoder->decodeHeaders(std::move(headers), true);\n\n ResponseHeaderMapPtr response_headers{new TestResponseHeaderMapImpl{{\":status\", \"200\"}}};\n filter->callbacks_->encodeHeaders(std::move(response_headers), true);\n filter->callbacks_->activeSpan().setTag(\"service-cluster\", \"scoobydoo\");\n\n data.drain(4);\n return Http::okStatus();\n }));\n\n \/\/ Verify that decorator operation has NOT been set as request header (propagate is false)\n EXPECT_CALL(*filter, decodeHeaders(_, true))\n .WillOnce(Invoke([](RequestHeaderMap& headers, bool) -> FilterHeadersStatus {\n EXPECT_EQ(nullptr, headers.EnvoyDecoratorOperation());\n return FilterHeadersStatus::StopIteration;\n }));\n\n Buffer::OwnedImpl fake_input(\"1234\");\n conn_manager_->onData(fake_input, false);\n}","target":0,"code_token_length":870,"total_token_length":1106,"max_tokens_setting":2048} +{"idx":338650,"func":"dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,\n\n enum dshowDeviceType devtype, enum dshowSourceFilterType sourcetype, IBaseFilter **pfilter)\n\n{\n\n struct dshow_ctx *ctx = avctx->priv_data;\n\n IBaseFilter *device_filter = NULL;\n\n IEnumMoniker *classenum = NULL;\n\n IMoniker *m = NULL;\n\n const char *device_name = ctx->device_name[devtype];\n\n int skip = (devtype == VideoDevice) ? ctx->video_device_number\n\n : ctx->audio_device_number;\n\n int r;\n\n\n\n const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,\n\n &CLSID_AudioInputDeviceCategory };\n\n const char *devtypename = (devtype == VideoDevice) ? \"video\" : \"audio only\";\n\n const char *sourcetypename = (sourcetype == VideoSourceDevice) ? \"video\" : \"audio\";\n\n\n\n r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[sourcetype],\n\n (IEnumMoniker **) &classenum, 0);\n\n if (r != S_OK) {\n\n av_log(avctx, AV_LOG_ERROR, \"Could not enumerate %s devices (or none found).\\n\",\n\n devtypename);\n\n return AVERROR(EIO);\n\n }\n\n\n\n while (!device_filter && IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK) {\n\n IPropertyBag *bag = NULL;\n\n char *friendly_name = NULL;\n\n char *unique_name = NULL;\n\n VARIANT var;\n\n IBindCtx *bind_ctx = NULL;\n\n LPOLESTR olestr = NULL;\n\n LPMALLOC co_malloc = NULL;\n\n int i;\n\n\n\n r = CoGetMalloc(1, &co_malloc);\n\n if (r = S_OK)\n\n goto fail1;\n\n r = CreateBindCtx(0, &bind_ctx);\n\n if (r != S_OK)\n\n goto fail1;\n\n \/* GetDisplayname works for both video and audio, DevicePath doesn't *\/\n\n r = IMoniker_GetDisplayName(m, bind_ctx, NULL, &olestr);\n\n if (r != S_OK)\n\n goto fail1;\n\n unique_name = dup_wchar_to_utf8(olestr);\n\n \/* replace ':' with '_' since we use : to delineate between sources *\/\n\n for (i = 0; i < strlen(unique_name); i++) {\n\n if (unique_name[i] == ':')\n\n unique_name[i] = '_';\n\n }\n\n\n\n r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag);\n\n if (r != S_OK)\n\n goto fail1;\n\n\n\n var.vt = VT_BSTR;\n\n r = IPropertyBag_Read(bag, L\"FriendlyName\", &var, NULL);\n\n if (r != S_OK)\n\n goto fail1;\n\n friendly_name = dup_wchar_to_utf8(var.bstrVal);\n\n\n\n if (pfilter) {\n\n if (strcmp(device_name, friendly_name) && strcmp(device_name, unique_name))\n\n goto fail1;\n\n\n\n if (!skip--) {\n\n r = IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);\n\n if (r != S_OK) {\n\n av_log(avctx, AV_LOG_ERROR, \"Unable to BindToObject for %s\\n\", device_name);\n\n goto fail1;\n\n }\n\n }\n\n } else {\n\n av_log(avctx, AV_LOG_INFO, \" \\\"%s\\\"\\n\", friendly_name);\n\n av_log(avctx, AV_LOG_INFO, \" Alternative name \\\"%s\\\"\\n\", unique_name);\n\n }\n\n\n\nfail1:\n\n if (olestr && co_malloc)\n\n IMalloc_Free(co_malloc, olestr);\n\n if (bind_ctx)\n\n IBindCtx_Release(bind_ctx);\n\n av_free(friendly_name);\n\n av_free(unique_name);\n\n if (bag)\n\n IPropertyBag_Release(bag);\n\n IMoniker_Release(m);\n\n }\n\n\n\n IEnumMoniker_Release(classenum);\n\n\n\n if (pfilter) {\n\n if (!device_filter) {\n\n av_log(avctx, AV_LOG_ERROR, \"Could not find %s device with name [%s] among source devices of type %s.\\n\",\n\n devtypename, device_name, sourcetypename);\n\n return AVERROR(EIO);\n\n }\n\n *pfilter = device_filter;\n\n }\n\n\n\n return 0;\n\n}\n","target":0,"code_token_length":977,"total_token_length":1213,"max_tokens_setting":2048} +{"idx":8113,"func":" void Compute(OpKernelContext* ctx) override {\n const Tensor& input_0 = ctx->input(0);\n const Tensor& input_1 = ctx->input(1);\n const Device& eigen_device = ctx->eigen_device();\n bool error = false;\n bool* const error_ptr = Functor::has_errors ? &error : nullptr;\n\n \/\/ NOTE: Handle three simple cases before building the BinaryOpState, which\n \/\/ is relatively expensive for small operations.\n if (input_0.shape() == input_1.shape()) {\n \/\/ tensor op tensor with no broadcasting.\n Tensor* out;\n OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n {0, 1}, 0, input_0.shape(), &out));\n functor::BinaryFunctor()(\n eigen_device, out->template flat(),\n input_0.template flat(), input_1.template flat(),\n error_ptr);\n if (Functor::has_errors && error) {\n SetComputeError(ctx);\n }\n return;\n } else if (input_0.shape().dims() == 0) {\n \/\/ scalar op tensor.\n Tensor* out;\n OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n {1}, 0, input_1.shape(), &out));\n\n functor::BinaryFunctor().Left(\n eigen_device, out->template flat(),\n input_0.template scalar(), input_1.template flat(),\n error_ptr);\n if (Functor::has_errors && error) {\n SetComputeError(ctx);\n }\n return;\n } else if (input_1.shape().dims() == 0) {\n \/\/ tensor op scalar.\n Tensor* out;\n OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n {0}, 0, input_0.shape(), &out));\n functor::BinaryFunctor().Right(\n eigen_device, out->template flat(),\n input_0.template flat(), input_1.template scalar(),\n error_ptr);\n if (Functor::has_errors && error) {\n SetComputeError(ctx);\n }\n return;\n }\n\n \/\/ 'state': Shared helper not dependent on T to reduce code size\n BinaryOpState state(ctx);\n if (ctx->status().code() == error::RESOURCE_EXHAUSTED) {\n \/\/ Stop when BinaryOpState's constructor failed due to OOM.\n return;\n }\n auto& bcast = state.bcast;\n Tensor* out = state.out;\n if (!bcast.IsValid()) {\n if (ctx->status().ok()) {\n if (state.result) {\n functor::SetOneFunctor()(eigen_device,\n out->flat());\n } else {\n functor::SetZeroFunctor()(eigen_device,\n out->flat());\n }\n }\n return;\n }\n\n auto& in0 = state.in0;\n auto& in1 = state.in1;\n if (state.out_num_elements == 0) {\n return;\n }\n\n const int ndims = state.ndims;\n if (ndims <= 1) {\n auto out_flat = out->flat();\n if (state.in1_num_elements == 1) {\n \/\/ tensor op scalar\n functor::BinaryFunctor().Right(\n eigen_device, out_flat, in0.template flat(),\n in1.template scalar(), error_ptr);\n } else if (state.in0_num_elements == 1) {\n \/\/ scalar op tensor\n functor::BinaryFunctor().Left(\n eigen_device, out_flat, in0.template scalar(),\n in1.template flat(), error_ptr);\n } else {\n functor::BinaryFunctor()(\n eigen_device, out_flat, in0.template flat(),\n in1.template flat(), error_ptr);\n }\n } else if (ndims == 2) {\n functor::BinaryFunctor().BCast(\n eigen_device, out->shaped(bcast.result_shape()),\n in0.template shaped(bcast.x_reshape()),\n BCast::ToIndexArray<2>(bcast.x_bcast()),\n in1.template shaped(bcast.y_reshape()),\n BCast::ToIndexArray<2>(bcast.y_bcast()), error_ptr);\n } else if (ndims == 3) {\n functor::BinaryFunctor().BCast(\n eigen_device, out->shaped(bcast.result_shape()),\n in0.template shaped(bcast.x_reshape()),\n BCast::ToIndexArray<3>(bcast.x_bcast()),\n in1.template shaped(bcast.y_reshape()),\n BCast::ToIndexArray<3>(bcast.y_bcast()), error_ptr);\n } else if (ndims == 4) {\n functor::BinaryFunctor().BCast(\n eigen_device, out->shaped(bcast.result_shape()),\n in0.template shaped(bcast.x_reshape()),\n BCast::ToIndexArray<4>(bcast.x_bcast()),\n in1.template shaped(bcast.y_reshape()),\n BCast::ToIndexArray<4>(bcast.y_bcast()), error_ptr);\n } else if (ndims == 5) {\n functor::BinaryFunctor().BCast(\n eigen_device, out->shaped(bcast.result_shape()),\n in0.template shaped(bcast.x_reshape()),\n BCast::ToIndexArray<5>(bcast.x_bcast()),\n in1.template shaped(bcast.y_reshape()),\n BCast::ToIndexArray<5>(bcast.y_bcast()), error_ptr);\n } else {\n SetUnimplementedError(ctx);\n }\n if (Functor::has_errors && error) {\n SetComputeError(ctx);\n }\n }","target":1,"code_token_length":1398,"total_token_length":1634,"max_tokens_setting":2048} +{"idx":339789,"func":"int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,\n\n unsigned int *bytes, uint64_t *cluster_offset)\n\n{\n\n BDRVQcow2State *s = bs->opaque;\n\n unsigned int l2_index;\n\n uint64_t l1_index, l2_offset, *l2_table;\n\n int l1_bits, c;\n\n unsigned int offset_in_cluster;\n\n uint64_t bytes_available, bytes_needed, nb_clusters;\n\n int ret;\n\n\n\n offset_in_cluster = offset_into_cluster(s, offset);\n\n bytes_needed = (uint64_t) *bytes + offset_in_cluster;\n\n\n\n l1_bits = s->l2_bits + s->cluster_bits;\n\n\n\n \/* compute how many bytes there are between the start of the cluster\n\n * containing offset and the end of the l1 entry *\/\n\n bytes_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1))\n\n + offset_in_cluster;\n\n\n\n if (bytes_needed > bytes_available) {\n\n bytes_needed = bytes_available;\n\n }\n\n\n\n *cluster_offset = 0;\n\n\n\n \/* seek to the l2 offset in the l1 table *\/\n\n\n\n l1_index = offset >> l1_bits;\n\n if (l1_index >= s->l1_size) {\n\n ret = QCOW2_CLUSTER_UNALLOCATED;\n\n goto out;\n\n }\n\n\n\n l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;\n\n if (!l2_offset) {\n\n ret = QCOW2_CLUSTER_UNALLOCATED;\n\n goto out;\n\n }\n\n\n\n if (offset_into_cluster(s, l2_offset)) {\n\n qcow2_signal_corruption(bs, true, -1, -1, \"L2 table offset %#\" PRIx64\n\n \" unaligned (L1 index: %#\" PRIx64 \")\",\n\n l2_offset, l1_index);\n\n return -EIO;\n\n }\n\n\n\n \/* load the l2 table in memory *\/\n\n\n\n ret = l2_load(bs, l2_offset, &l2_table);\n\n if (ret < 0) {\n\n return ret;\n\n }\n\n\n\n \/* find the cluster offset for the given disk offset *\/\n\n\n\n l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);\n\n *cluster_offset = be64_to_cpu(l2_table[l2_index]);\n\n\n\n nb_clusters = size_to_clusters(s, bytes_needed);\n\n \/* bytes_needed <= *bytes + offset_in_cluster, both of which are unsigned\n\n * integers; the minimum cluster size is 512, so this assertion is always\n\n * true *\/\n\n assert(nb_clusters <= INT_MAX);\n\n\n\n ret = qcow2_get_cluster_type(*cluster_offset);\n\n switch (ret) {\n\n case QCOW2_CLUSTER_COMPRESSED:\n\n \/* Compressed clusters can only be processed one by one *\/\n\n c = 1;\n\n *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK;\n\n break;\n\n case QCOW2_CLUSTER_ZERO:\n\n if (s->qcow_version < 3) {\n\n qcow2_signal_corruption(bs, true, -1, -1, \"Zero cluster entry found\"\n\n \" in pre-v3 image (L2 offset: %#\" PRIx64\n\n \", L2 index: %#x)\", l2_offset, l2_index);\n\n ret = -EIO;\n\n goto fail;\n\n }\n\n c = count_contiguous_clusters_by_type(nb_clusters, &l2_table[l2_index],\n\n QCOW2_CLUSTER_ZERO);\n\n *cluster_offset = 0;\n\n break;\n\n case QCOW2_CLUSTER_UNALLOCATED:\n\n \/* how many empty clusters ? *\/\n\n c = count_contiguous_clusters_by_type(nb_clusters, &l2_table[l2_index],\n\n QCOW2_CLUSTER_UNALLOCATED);\n\n *cluster_offset = 0;\n\n break;\n\n case QCOW2_CLUSTER_NORMAL:\n\n \/* how many allocated clusters ? *\/\n\n c = count_contiguous_clusters(nb_clusters, s->cluster_size,\n\n &l2_table[l2_index], QCOW_OFLAG_ZERO);\n\n *cluster_offset &= L2E_OFFSET_MASK;\n\n if (offset_into_cluster(s, *cluster_offset)) {\n\n qcow2_signal_corruption(bs, true, -1, -1, \"Data cluster offset %#\"\n\n PRIx64 \" unaligned (L2 offset: %#\" PRIx64\n\n \", L2 index: %#x)\", *cluster_offset,\n\n l2_offset, l2_index);\n\n ret = -EIO;\n\n goto fail;\n\n }\n\n break;\n\n default:\n\n abort();\n\n }\n\n\n\n qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);\n\n\n\n bytes_available = (int64_t)c * s->cluster_size;\n\n\n\nout:\n\n if (bytes_available > bytes_needed) {\n\n bytes_available = bytes_needed;\n\n }\n\n\n\n \/* bytes_available <= bytes_needed <= *bytes + offset_in_cluster;\n\n * subtracting offset_in_cluster will therefore definitely yield something\n\n * not exceeding UINT_MAX *\/\n\n assert(bytes_available - offset_in_cluster <= UINT_MAX);\n\n *bytes = bytes_available - offset_in_cluster;\n\n\n\n return ret;\n\n\n\nfail:\n\n qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table);\n\n return ret;\n\n}\n","target":0,"code_token_length":1140,"total_token_length":1376,"max_tokens_setting":2048} +{"idx":261616,"func":"void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)\n{\n\tgdPoint pts[363];\n\tint i, pti;\n\tint lx = 0, ly = 0;\n\tint fx = 0, fy = 0;\n\n\n if ((s % 360) == (e % 360)) {\n\t\ts = 0; e = 360;\n\t} else {\n\t\tif (s > 360) {\n\t\t\ts = s % 360;\n\t\t}\n\n\t\tif (e > 360) {\n\t\t\te = e % 360;\n\t\t}\n\n\t\twhile (s < 0) {\n\t\t\ts += 360;\n\t\t}\n\n\t\twhile (e < s) {\n\t\t\te += 360;\n\t\t}\n\t\tif (s == e) {\n\t\t\ts = 0; e = 360;\n\t\t}\n\t}\n\n\tfor (i = s, pti = 1; i <= e; i++, pti++) {\n\t\tint x, y;\n\t\tx = ((long) gdCosT[i % 360] * (long) w \/ (2 * 1024)) + cx;\n\t\ty = ((long) gdSinT[i % 360] * (long) h \/ (2 * 1024)) + cy;\n\t\tif (i != s) {\n\t\t\tif (!(style & gdChord)) {\n\t\t\t\tif (style & gdNoFill) {\n\t\t\t\t\tgdImageLine(im, lx, ly, x, y, color);\n\t\t\t\t} else {\n\t\t\t\t\tif (y == ly) {\n\t\t\t\t\t\tpti--; \/* don't add this point *\/\n\t\t\t\t\t\tif (((i > 270 || i < 90) && x > lx) || ((i > 90 && i < 270) && x < lx)) {\n\t\t\t\t\t\t\t\/* replace the old x coord, if increasing on the\n\t\t\t\t\t\t\t right side or decreasing on the left side *\/\n\t\t\t\t\t\t\tpts[pti].x = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpts[pti].x = x;\n\t\t\t\t\t\tpts[pti].y = y;\n\t\t\t\t\t}\n \t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfx = x;\n\t\t\tfy = y;\n\t\t\tif (!(style & (gdChord | gdNoFill))) {\n\t\t\t\tpts[0].x = cx;\n\t\t\t\tpts[0].y = cy;\n\t\t\t\tpts[pti].x = x;\n\t\t\t\tpts[pti].y = y;\n\t\t\t}\n\t\t}\n\t\tlx = x;\n\t\tly = y;\n\t}\n\tif (style & gdChord) {\n\t\tif (style & gdNoFill) {\n\t\t\tif (style & gdEdged) {\n\t\t\t\tgdImageLine(im, cx, cy, lx, ly, color);\n\t\t\t\tgdImageLine(im, cx, cy, fx, fy, color);\n\t\t\t}\n\t\t\tgdImageLine(im, fx, fy, lx, ly, color);\n\t\t} else {\n\t\t\tpts[0].x = fx;\n\t\t\tpts[0].y = fy;\n\t\t\tpts[1].x = lx;\n\t\t\tpts[1].y = ly;\n\t\t\tpts[2].x = cx;\n\t\t\tpts[2].y = cy;\n\t\t\tgdImageFilledPolygon(im, pts, 3, color);\n\t\t}\n\t} else {\n\t\tif (style & gdNoFill) {\n\t\t\tif (style & gdEdged) {\n\t\t\t\tgdImageLine(im, cx, cy, lx, ly, color);\n\t\t\t\tgdImageLine(im, cx, cy, fx, fy, color);\n\t\t\t}\n\t\t} else {\n\t\t\tpts[pti].x = cx;\n\t\t\tpts[pti].y = cy;\n\t\t\tgdImageFilledPolygon(im, pts, pti+1, color);\n\t\t}\n\t}\n}","target":0,"code_token_length":877,"total_token_length":1113,"max_tokens_setting":2048} +{"idx":453830,"func":"int imap_reconnect (IMAP_DATA **p_idata)\n{\n CONTEXT *orig_ctx, new_ctx;\n int rc = -1, i;\n IMAP_DATA *idata = *p_idata;\n HEADER *old_hdr, *new_hdr;\n\n \/* L10N:\n Message displayed when IMAP connection is lost and Mutt\n tries to reconnect.\n *\/\n mutt_message _(\"Trying to reconnect...\");\n mutt_sleep (0);\n\n orig_ctx = idata->ctx;\n if (!orig_ctx)\n goto cleanup;\n\n if (mx_open_mailbox (orig_ctx->path,\n orig_ctx->readonly ? MUTT_READONLY : 0,\n &new_ctx) == NULL)\n goto cleanup;\n\n new_ctx.dontwrite = orig_ctx->dontwrite;\n new_ctx.pattern = orig_ctx->pattern;\n new_ctx.limit_pattern = orig_ctx->limit_pattern;\n\n orig_ctx->pattern = NULL;\n orig_ctx->limit_pattern = NULL;\n\n if (idata->uid_validity == ((IMAP_DATA *) new_ctx.data)->uid_validity)\n {\n for (i = 0; i < new_ctx.msgcount; i++)\n {\n new_hdr = new_ctx.hdrs[i];\n old_hdr = (HEADER *) int_hash_find (idata->uid_hash,\n HEADER_DATA(new_hdr)->uid);\n if (!old_hdr)\n continue;\n\n \/* this logic is in part from mbox.c. *\/\n if (old_hdr->changed)\n {\n mutt_set_flag (&new_ctx, new_hdr, MUTT_FLAG, old_hdr->flagged);\n mutt_set_flag (&new_ctx, new_hdr, MUTT_REPLIED, old_hdr->replied);\n mutt_set_flag (&new_ctx, new_hdr, MUTT_OLD, old_hdr->old);\n mutt_set_flag (&new_ctx, new_hdr, MUTT_READ, old_hdr->read);\n\n \/* TODO: the ->env check is unfortunately voodoo that I\n * haven't taken the time to track down yet. It's in other\n * parts of the code but I don't know why yet. *\/\n if (old_hdr->env && old_hdr->env->changed)\n {\n new_hdr->env->changed = old_hdr->env->changed;\n new_hdr->changed = 1;\n new_ctx.changed = 1;\n\n if (old_hdr->env->changed & MUTT_ENV_CHANGED_IRT)\n {\n mutt_free_list (&new_hdr->env->in_reply_to);\n new_hdr->env->in_reply_to = old_hdr->env->in_reply_to;\n old_hdr->env->in_reply_to = NULL;\n }\n if (old_hdr->env->changed & MUTT_ENV_CHANGED_REFS)\n {\n mutt_free_list (&new_hdr->env->references);\n new_hdr->env->references = old_hdr->env->references;\n old_hdr->env->references = NULL;\n }\n if (old_hdr->env->changed & MUTT_ENV_CHANGED_XLABEL)\n {\n FREE (&new_hdr->env->x_label);\n new_hdr->env->x_label = old_hdr->env->x_label;\n old_hdr->env->x_label = NULL;\n }\n if (old_hdr->env->changed & MUTT_ENV_CHANGED_SUBJECT)\n {\n FREE (&new_hdr->env->subject);\n new_hdr->env->subject = old_hdr->env->subject;\n new_hdr->env->real_subj = old_hdr->env->real_subj;\n old_hdr->env->subject = old_hdr->env->real_subj = NULL;\n }\n }\n\n if (old_hdr->attach_del)\n {\n if (old_hdr->content->parts && !new_hdr->content->parts)\n {\n new_hdr->attach_del = 1;\n new_hdr->changed = 1;\n new_ctx.changed = 1;\n new_hdr->content->parts = old_hdr->content->parts;\n old_hdr->content->parts = NULL;\n }\n }\n }\n\n mutt_set_flag (&new_ctx, new_hdr, MUTT_DELETE, old_hdr->deleted);\n mutt_set_flag (&new_ctx, new_hdr, MUTT_PURGE, old_hdr->purge);\n mutt_set_flag (&new_ctx, new_hdr, MUTT_TAG, old_hdr->tagged);\n }\n }\n\n rc = 0;\n\ncleanup:\n idata->status = IMAP_FATAL;\n mx_fastclose_mailbox (orig_ctx);\n imap_close_connection (idata);\n\n if (rc != 0)\n {\n \/* L10N:\n Message when Mutt tries to reconnect to an IMAP mailbox but is\n unable to.\n *\/\n mutt_error _(\"Reconnect failed. Mailbox closed.\");\n }\n else\n {\n memcpy (orig_ctx, &new_ctx, sizeof(CONTEXT));\n idata = (IMAP_DATA *)orig_ctx->data;\n idata->ctx = orig_ctx;\n *p_idata = idata;\n \/* L10N:\n Message when Mutt reconnects to an IMAP mailbox after a fatal error.\n *\/\n mutt_error _(\"Reconnect succeeded.\");\n }\n mutt_sleep (0);\n\n return rc;\n}","target":0,"code_token_length":1118,"total_token_length":1354,"max_tokens_setting":2048} +{"idx":413610,"func":"_send_slurmstepd_init(int fd, int type, void *req,\n\t\t slurm_addr_t *cli, slurm_addr_t *self,\n\t\t hostset_t step_hset, uint16_t protocol_version)\n{\n\tint len = 0;\n\tBuf buffer = NULL;\n\tslurm_msg_t msg;\n\tgid_t gid = (uid_t)-1;\n\tgids_t *gids = NULL;\n\n\tint rank, proto;\n\tint parent_rank, children, depth, max_depth;\n\tchar *parent_alias = NULL;\n\tchar *user_name = NULL;\n\tslurm_addr_t parent_addr = {0};\n\n\tslurm_msg_t_init(&msg);\n\t\/* send type over to slurmstepd *\/\n\tsafe_write(fd, &type, sizeof(int));\n\n\t\/* step_hset can be NULL for batch scripts OR if the job was submitted\n\t * by SlurmUser or root using the --no-allocate\/-Z option and the job\n\t * job credential validation by _check_job_credential() failed. If the\n\t * job credential did not validate, then it did not come from slurmctld\n\t * and there is no reason to send step completion messages to slurmctld.\n\t *\/\n\tif (step_hset == NULL) {\n\t\tbool send_error = false;\n\t\tif (type == LAUNCH_TASKS) {\n\t\t\tlaunch_tasks_request_msg_t *launch_req;\n\t\t\tlaunch_req = (launch_tasks_request_msg_t *) req;\n\t\t\tif (launch_req->job_step_id != SLURM_EXTERN_CONT)\n\t\t\t\tsend_error = true;\n\t\t}\n\t\tif (send_error) {\n\t\t\tinfo(\"task rank unavailable due to invalid job \"\n\t\t\t \"credential, step completion RPC impossible\");\n\t\t}\n\t\trank = -1;\n\t\tparent_rank = -1;\n\t\tchildren = 0;\n\t\tdepth = 0;\n\t\tmax_depth = 0;\n\t} else if ((type == LAUNCH_TASKS) &&\n\t\t (((launch_tasks_request_msg_t *)req)->alias_list)) {\n\t\t\/* In the cloud, each task talks directly to the slurmctld\n\t\t * since node addressing is abnormal *\/\n\t\trank = 0;\n\t\tparent_rank = -1;\n\t\tchildren = 0;\n\t\tdepth = 0;\n\t\tmax_depth = 0;\n\t} else {\n#ifndef HAVE_FRONT_END\n\t\tint count;\n\t\tcount = hostset_count(step_hset);\n\t\trank = hostset_find(step_hset, conf->node_name);\n\t\treverse_tree_info(rank, count, REVERSE_TREE_WIDTH,\n\t\t\t\t &parent_rank, &children,\n\t\t\t\t &depth, &max_depth);\n\t\tif (rank > 0) { \/* rank 0 talks directly to the slurmctld *\/\n\t\t\tint rc;\n\t\t\t\/* Find the slurm_addr_t of this node's parent slurmd\n\t\t\t * in the step host list *\/\n\t\t\tparent_alias = hostset_nth(step_hset, parent_rank);\n\t\t\trc = slurm_conf_get_addr(parent_alias, &parent_addr);\n\t\t\tif (rc != SLURM_SUCCESS) {\n\t\t\t\terror(\"Failed looking up address for \"\n\t\t\t\t \"NodeName %s\", parent_alias);\n\t\t\t\t\/* parent_rank = -1; *\/\n\t\t\t}\n\t\t}\n#else\n\t\t\/* In FRONT_END mode, one slurmd pretends to be all\n\t\t * NodeNames, so we can't compare conf->node_name\n\t\t * to the NodeNames in step_hset. Just send step complete\n\t\t * RPC directly to the controller.\n\t\t *\/\n\t\trank = 0;\n\t\tparent_rank = -1;\n\t\tchildren = 0;\n\t\tdepth = 0;\n\t\tmax_depth = 0;\n#endif\n\t}\n\tdebug3(\"slurmstepd rank %d (%s), parent rank %d (%s), \"\n\t \"children %d, depth %d, max_depth %d\",\n\t rank, conf->node_name,\n\t parent_rank, parent_alias ? parent_alias : \"NONE\",\n\t children, depth, max_depth);\n\tif (parent_alias)\n\t\tfree(parent_alias);\n\n\t\/* send reverse-tree info to the slurmstepd *\/\n\tsafe_write(fd, &rank, sizeof(int));\n\tsafe_write(fd, &parent_rank, sizeof(int));\n\tsafe_write(fd, &children, sizeof(int));\n\tsafe_write(fd, &depth, sizeof(int));\n\tsafe_write(fd, &max_depth, sizeof(int));\n\tsafe_write(fd, &parent_addr, sizeof(slurm_addr_t));\n\n\t\/* send conf over to slurmstepd *\/\n\tif (_send_slurmd_conf_lite(fd, conf) < 0)\n\t\tgoto rwfail;\n\n\t\/* send cli address over to slurmstepd *\/\n\tbuffer = init_buf(0);\n\tslurm_pack_slurm_addr(cli, buffer);\n\tlen = get_buf_offset(buffer);\n\tsafe_write(fd, &len, sizeof(int));\n\tsafe_write(fd, get_buf_data(buffer), len);\n\tfree_buf(buffer);\n\tbuffer = NULL;\n\n\t\/* send self address over to slurmstepd *\/\n\tif (self) {\n\t\tbuffer = init_buf(0);\n\t\tslurm_pack_slurm_addr(self, buffer);\n\t\tlen = get_buf_offset(buffer);\n\t\tsafe_write(fd, &len, sizeof(int));\n\t\tsafe_write(fd, get_buf_data(buffer), len);\n\t\tfree_buf(buffer);\n\t\tbuffer = NULL;\n\n\t} else {\n\t\tlen = 0;\n\t\tsafe_write(fd, &len, sizeof(int));\n\t}\n\n\t\/* Send GRES information to slurmstepd *\/\n\tgres_plugin_send_stepd(fd);\n\n\t\/* send cpu_frequency info to slurmstepd *\/\n\tcpu_freq_send_info(fd);\n\n\t\/* send req over to slurmstepd *\/\n\tswitch(type) {\n\tcase LAUNCH_BATCH_JOB:\n\t\tgid = (uid_t)((batch_job_launch_msg_t *)req)->gid;\n\t\tuser_name = ((batch_job_launch_msg_t *)req)->user_name;\n\t\tmsg.msg_type = REQUEST_BATCH_JOB_LAUNCH;\n\t\tbreak;\n\tcase LAUNCH_TASKS:\n\t\tgid = (uid_t)((launch_tasks_request_msg_t *)req)->gid;\n\t\tuser_name = ((launch_tasks_request_msg_t *)req)->user_name;\n\t\tmsg.msg_type = REQUEST_LAUNCH_TASKS;\n\t\tbreak;\n\tdefault:\n\t\terror(\"Was sent a task I didn't understand\");\n\t\tbreak;\n\t}\n\tbuffer = init_buf(0);\n\tmsg.data = req;\n\n\tif (protocol_version == (uint16_t)NO_VAL)\n\t\tproto = SLURM_PROTOCOL_VERSION;\n\telse\n\t\tproto = protocol_version;\n\n\tmsg.protocol_version = (uint16_t)proto;\n\tpack_msg(&msg, buffer);\n\tlen = get_buf_offset(buffer);\n\n\tsafe_write(fd, &proto, sizeof(int));\n\n\tsafe_write(fd, &len, sizeof(int));\n\tsafe_write(fd, get_buf_data(buffer), len);\n\tfree_buf(buffer);\n\tbuffer = NULL;\n\n\tif ((gids = _gids_cache_lookup(user_name, gid))) {\n\t\tint i;\n\t\tuint32_t tmp32;\n\t\tsafe_write(fd, &gids->ngids, sizeof(int));\n\t\tfor (i = 0; i < gids->ngids; i++) {\n\t\t\ttmp32 = (uint32_t)gids->gids[i];\n\t\t\tsafe_write(fd, &tmp32, sizeof(uint32_t));\n\t\t}\n\t\t_dealloc_gids(gids);\n\t} else {\n\t\tlen = 0;\n\t\tsafe_write(fd, &len, sizeof(int));\n\t}\n\treturn 0;\n\nrwfail:\n\tif (buffer)\n\t\tfree_buf(buffer);\n\terror(\"_send_slurmstepd_init failed\");\n\treturn errno;\n}","target":0,"code_token_length":1593,"total_token_length":1829,"max_tokens_setting":2048} +{"idx":61429,"func":"static int svm_check_intercept(struct kvm_vcpu *vcpu,\n\t\t\t struct x86_instruction_info *info,\n\t\t\t enum x86_intercept_stage stage)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tint vmexit, ret = X86EMUL_CONTINUE;\n\tstruct __x86_intercept icpt_info;\n\tstruct vmcb *vmcb = svm->vmcb;\n\n\tif (info->intercept >= ARRAY_SIZE(x86_intercept_map))\n\t\tgoto out;\n\n\ticpt_info = x86_intercept_map[info->intercept];\n\n\tif (stage != icpt_info.stage)\n\t\tgoto out;\n\n\tswitch (icpt_info.exit_code) {\n\tcase SVM_EXIT_READ_CR0:\n\t\tif (info->intercept == x86_intercept_cr_read)\n\t\t\ticpt_info.exit_code += info->modrm_reg;\n\t\tbreak;\n\tcase SVM_EXIT_WRITE_CR0: {\n\t\tunsigned long cr0, val;\n\t\tu64 intercept;\n\n\t\tif (info->intercept == x86_intercept_cr_write)\n\t\t\ticpt_info.exit_code += info->modrm_reg;\n\n\t\tif (icpt_info.exit_code != SVM_EXIT_WRITE_CR0 ||\n\t\t info->intercept == x86_intercept_clts)\n\t\t\tbreak;\n\n\t\tintercept = svm->nested.intercept;\n\n\t\tif (!(intercept & (1ULL << INTERCEPT_SELECTIVE_CR0)))\n\t\t\tbreak;\n\n\t\tcr0 = vcpu->arch.cr0 & ~SVM_CR0_SELECTIVE_MASK;\n\t\tval = info->src_val & ~SVM_CR0_SELECTIVE_MASK;\n\n\t\tif (info->intercept == x86_intercept_lmsw) {\n\t\t\tcr0 &= 0xfUL;\n\t\t\tval &= 0xfUL;\n\t\t\t\/* lmsw can't clear PE - catch this here *\/\n\t\t\tif (cr0 & X86_CR0_PE)\n\t\t\t\tval |= X86_CR0_PE;\n\t\t}\n\n\t\tif (cr0 ^ val)\n\t\t\ticpt_info.exit_code = SVM_EXIT_CR0_SEL_WRITE;\n\n\t\tbreak;\n\t}\n\tcase SVM_EXIT_READ_DR0:\n\tcase SVM_EXIT_WRITE_DR0:\n\t\ticpt_info.exit_code += info->modrm_reg;\n\t\tbreak;\n\tcase SVM_EXIT_MSR:\n\t\tif (info->intercept == x86_intercept_wrmsr)\n\t\t\tvmcb->control.exit_info_1 = 1;\n\t\telse\n\t\t\tvmcb->control.exit_info_1 = 0;\n\t\tbreak;\n\tcase SVM_EXIT_PAUSE:\n\t\t\/*\n\t\t * We get this for NOP only, but pause\n\t\t * is rep not, check this here\n\t\t *\/\n\t\tif (info->rep_prefix != REPE_PREFIX)\n\t\t\tgoto out;\n\tcase SVM_EXIT_IOIO: {\n\t\tu64 exit_info;\n\t\tu32 bytes;\n\n\t\tif (info->intercept == x86_intercept_in ||\n\t\t info->intercept == x86_intercept_ins) {\n\t\t\texit_info = ((info->src_val & 0xffff) << 16) |\n\t\t\t\tSVM_IOIO_TYPE_MASK;\n\t\t\tbytes = info->dst_bytes;\n\t\t} else {\n\t\t\texit_info = (info->dst_val & 0xffff) << 16;\n\t\t\tbytes = info->src_bytes;\n\t\t}\n\n\t\tif (info->intercept == x86_intercept_outs ||\n\t\t info->intercept == x86_intercept_ins)\n\t\t\texit_info |= SVM_IOIO_STR_MASK;\n\n\t\tif (info->rep_prefix)\n\t\t\texit_info |= SVM_IOIO_REP_MASK;\n\n\t\tbytes = min(bytes, 4u);\n\n\t\texit_info |= bytes << SVM_IOIO_SIZE_SHIFT;\n\n\t\texit_info |= (u32)info->ad_bytes << (SVM_IOIO_ASIZE_SHIFT - 1);\n\n\t\tvmcb->control.exit_info_1 = exit_info;\n\t\tvmcb->control.exit_info_2 = info->next_rip;\n\n\t\tbreak;\n\t}\n\tdefault:\n\t\tbreak;\n\t}\n\n\t\/* TODO: Advertise NRIPS to guest hypervisor unconditionally *\/\n\tif (static_cpu_has(X86_FEATURE_NRIPS))\n\t\tvmcb->control.next_rip = info->next_rip;\n\tvmcb->control.exit_code = icpt_info.exit_code;\n\tvmexit = nested_svm_exit_handled(svm);\n\n\tret = (vmexit == NESTED_EXIT_DONE) ? X86EMUL_INTERCEPTED\n\t\t\t\t\t : X86EMUL_CONTINUE;\n\nout:\n\treturn ret;\n}","target":0,"code_token_length":946,"total_token_length":1182,"max_tokens_setting":2048} +{"idx":61184,"func":"ModuleExport size_t RegisterTIFFImage(void)\n{\n#define TIFFDescription \"Tagged Image File Format\"\n\n char\n version[MaxTextExtent];\n\n MagickInfo\n *entry;\n\n#if defined(MAGICKCORE_TIFF_DELEGATE)\n if (tiff_semaphore == (SemaphoreInfo *) NULL)\n ActivateSemaphoreInfo(&tiff_semaphore);\n LockSemaphoreInfo(tiff_semaphore);\n if (instantiate_key == MagickFalse)\n {\n if (CreateMagickThreadKey(&tiff_exception,NULL) == MagickFalse)\n ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n error_handler=TIFFSetErrorHandler(TIFFErrors);\n warning_handler=TIFFSetWarningHandler(TIFFWarnings);\n#if defined(MAGICKCORE_HAVE_TIFFMERGEFIELDINFO) && defined(MAGICKCORE_HAVE_TIFFSETTAGEXTENDER)\n if (tag_extender == (TIFFExtendProc) NULL)\n tag_extender=TIFFSetTagExtender(TIFFTagExtender);\n#endif\n instantiate_key=MagickTrue;\n }\n UnlockSemaphoreInfo(tiff_semaphore);\n#endif\n *version='\\0';\n#if defined(TIFF_VERSION)\n (void) FormatLocaleString(version,MaxTextExtent,\"%d\",TIFF_VERSION);\n#endif\n#if defined(MAGICKCORE_TIFF_DELEGATE)\n {\n const char\n *p;\n\n register ssize_t\n i;\n\n p=TIFFGetVersion();\n for (i=0; (i < (MaxTextExtent-1)) && (*p != 0) && (*p != '\\n'); i++)\n version[i]=(*p++);\n version[i]='\\0';\n }\n#endif\n\n entry=SetMagickInfo(\"GROUP4\");\n#if defined(MAGICKCORE_TIFF_DELEGATE)\n entry->decoder=(DecodeImageHandler *) ReadGROUP4Image;\n entry->encoder=(EncodeImageHandler *) WriteGROUP4Image;\n#endif\n entry->raw=MagickTrue;\n entry->endian_support=MagickTrue;\n entry->adjoin=MagickFalse;\n entry->format_type=ImplicitFormatType;\n entry->seekable_stream=MagickTrue;\n entry->description=ConstantString(\"Raw CCITT Group4\");\n entry->mime_type=ConstantString(\"image\/tiff\");\n entry->module=ConstantString(\"TIFF\");\n (void) RegisterMagickInfo(entry);\n entry=SetMagickInfo(\"PTIF\");\n#if defined(MAGICKCORE_TIFF_DELEGATE)\n entry->decoder=(DecodeImageHandler *) ReadTIFFImage;\n entry->encoder=(EncodeImageHandler *) WritePTIFImage;\n#endif\n entry->endian_support=MagickTrue;\n entry->seekable_stream=MagickTrue;\n entry->description=ConstantString(\"Pyramid encoded TIFF\");\n entry->mime_type=ConstantString(\"image\/tiff\");\n entry->module=ConstantString(\"TIFF\");\n (void) RegisterMagickInfo(entry);\n entry=SetMagickInfo(\"TIF\");\n#if defined(MAGICKCORE_TIFF_DELEGATE)\n entry->decoder=(DecodeImageHandler *) ReadTIFFImage;\n entry->encoder=(EncodeImageHandler *) WriteTIFFImage;\n#endif\n entry->endian_support=MagickTrue;\n entry->seekable_stream=MagickTrue;\n entry->stealth=MagickTrue;\n entry->description=ConstantString(TIFFDescription);\n if (*version != '\\0')\n entry->version=ConstantString(version);\n entry->mime_type=ConstantString(\"image\/tiff\");\n entry->module=ConstantString(\"TIFF\");\n (void) RegisterMagickInfo(entry);\n entry=SetMagickInfo(\"TIFF\");\n#if defined(MAGICKCORE_TIFF_DELEGATE)\n entry->decoder=(DecodeImageHandler *) ReadTIFFImage;\n entry->encoder=(EncodeImageHandler *) WriteTIFFImage;\n#endif\n entry->magick=(IsImageFormatHandler *) IsTIFF;\n entry->endian_support=MagickTrue;\n entry->seekable_stream=MagickTrue;\n entry->description=ConstantString(TIFFDescription);\n if (*version != '\\0')\n entry->version=ConstantString(version);\n entry->mime_type=ConstantString(\"image\/tiff\");\n entry->module=ConstantString(\"TIFF\");\n (void) RegisterMagickInfo(entry);\n entry=SetMagickInfo(\"TIFF64\");\n#if defined(TIFF_VERSION_BIG)\n entry->decoder=(DecodeImageHandler *) ReadTIFFImage;\n entry->encoder=(EncodeImageHandler *) WriteTIFFImage;\n#endif\n entry->adjoin=MagickFalse;\n entry->endian_support=MagickTrue;\n entry->seekable_stream=MagickTrue;\n entry->description=ConstantString(\"Tagged Image File Format (64-bit)\");\n if (*version != '\\0')\n entry->version=ConstantString(version);\n entry->mime_type=ConstantString(\"image\/tiff\");\n entry->module=ConstantString(\"TIFF\");\n (void) RegisterMagickInfo(entry);\n return(MagickImageCoderSignature);\n}","target":0,"code_token_length":1087,"total_token_length":1323,"max_tokens_setting":2048} +{"idx":320030,"func":"static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,\n\n AVPacket *avpkt)\n\n{\n\n const uint8_t *buf = avpkt->data;\n\n int buf_size = avpkt->size;\n\n AC3DecodeContext *s = avctx->priv_data;\n\n int16_t *out_samples = (int16_t *)data;\n\n int blk, ch, err;\n\n const uint8_t *channel_map;\n\n const float *output[AC3_MAX_CHANNELS];\n\n\n\n \/* initialize the GetBitContext with the start of valid AC-3 Frame *\/\n\n if (s->input_buffer) {\n\n \/* copy input buffer to decoder context to avoid reading past the end\n\n of the buffer, which can be caused by a damaged input stream. *\/\n\n memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));\n\n init_get_bits(&s->gbc, s->input_buffer, buf_size * 8);\n\n } else {\n\n init_get_bits(&s->gbc, buf, buf_size * 8);\n\n }\n\n\n\n \/* parse the syncinfo *\/\n\n *data_size = 0;\n\n err = parse_frame_header(s);\n\n\n\n if (err) {\n\n switch(err) {\n\n case AAC_AC3_PARSE_ERROR_SYNC:\n\n av_log(avctx, AV_LOG_ERROR, \"frame sync error\\n\");\n\n return -1;\n\n case AAC_AC3_PARSE_ERROR_BSID:\n\n av_log(avctx, AV_LOG_ERROR, \"invalid bitstream id\\n\");\n\n break;\n\n case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:\n\n av_log(avctx, AV_LOG_ERROR, \"invalid sample rate\\n\");\n\n break;\n\n case AAC_AC3_PARSE_ERROR_FRAME_SIZE:\n\n av_log(avctx, AV_LOG_ERROR, \"invalid frame size\\n\");\n\n break;\n\n case AAC_AC3_PARSE_ERROR_FRAME_TYPE:\n\n \/* skip frame if CRC is ok. otherwise use error concealment. *\/\n\n \/* TODO: add support for substreams and dependent frames *\/\n\n if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {\n\n av_log(avctx, AV_LOG_ERROR, \"unsupported frame type : skipping frame\\n\");\n\n return s->frame_size;\n\n } else {\n\n av_log(avctx, AV_LOG_ERROR, \"invalid frame type\\n\");\n\n }\n\n break;\n\n default:\n\n av_log(avctx, AV_LOG_ERROR, \"invalid header\\n\");\n\n break;\n\n }\n\n } else {\n\n \/* check that reported frame size fits in input buffer *\/\n\n if (s->frame_size > buf_size) {\n\n av_log(avctx, AV_LOG_ERROR, \"incomplete frame\\n\");\n\n err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;\n\n } else if (avctx->error_recognition >= FF_ER_CAREFUL) {\n\n \/* check for crc mismatch *\/\n\n if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {\n\n av_log(avctx, AV_LOG_ERROR, \"frame CRC mismatch\\n\");\n\n err = AAC_AC3_PARSE_ERROR_CRC;\n\n }\n\n }\n\n }\n\n\n\n \/* if frame is ok, set audio parameters *\/\n\n if (!err) {\n\n avctx->sample_rate = s->sample_rate;\n\n avctx->bit_rate = s->bit_rate;\n\n\n\n \/* channel config *\/\n\n s->out_channels = s->channels;\n\n s->output_mode = s->channel_mode;\n\n if(s->lfe_on)\n\n s->output_mode |= AC3_OUTPUT_LFEON;\n\n if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&\n\n avctx->request_channels < s->channels) {\n\n s->out_channels = avctx->request_channels;\n\n s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;\n\n s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode];\n\n }\n\n avctx->channels = s->out_channels;\n\n avctx->channel_layout = s->channel_layout;\n\n\n\n \/* set downmixing coefficients if needed *\/\n\n if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&\n\n s->fbw_channels == s->out_channels)) {\n\n set_downmix_coeffs(s);\n\n }\n\n } else if (!s->out_channels) {\n\n s->out_channels = avctx->channels;\n\n if(s->out_channels < s->channels)\n\n s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;\n\n }\n\n\n\n \/* decode the audio blocks *\/\n\n channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];\n\n for (ch = 0; ch < s->out_channels; ch++)\n\n output[ch] = s->output[channel_map[ch]];\n\n for (blk = 0; blk < s->num_blocks; blk++) {\n\n if (!err && decode_audio_block(s, blk)) {\n\n av_log(avctx, AV_LOG_ERROR, \"error decoding the audio block\\n\");\n\n err = 1;\n\n }\n\n s->fmt_conv.float_to_int16_interleave(out_samples, output, 256, s->out_channels);\n\n out_samples += 256 * s->out_channels;\n\n }\n\n *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);\n\n return FFMIN(buf_size, s->frame_size);\n\n}\n","target":1,"code_token_length":1207,"total_token_length":1443,"max_tokens_setting":2048} +{"idx":490475,"func":"void gf_fs_print_all_connections(GF_FilterSession *session, char *filter_name, void (*print_fn)(FILE *output, GF_SysPrintArgFlags flags, const char *fmt, ...) )\n{\n\tBool found = GF_FALSE;\n\tGF_List *done;\n\tu32 i, j, count;\n\tu32 llev = gf_log_get_tool_level(GF_LOG_FILTER);\n\n\tgf_log_set_tool_level(GF_LOG_FILTER, GF_LOG_INFO);\n\t\/\/load JS to inspect its connections\n\tif (filter_name && strstr(filter_name, \".js\")) {\n\t\tgf_fs_print_jsf_connection(session, filter_name, NULL, print_fn);\n\t\tgf_log_set_tool_level(GF_LOG_FILTER, llev);\n\t\treturn;\n\t}\n\tdone = gf_list_new();\n\tcount = gf_list_count(session->links);\n\n\tfor (i=0; ilinks, i);\n\t\tif (filter_name && strcmp(src->freg->name, filter_name))\n\t\t\tcontinue;\n\n\t\tif (!src->nb_edges) {\n\t\t\tif (print_fn)\n\t\t\t\tprint_fn(stderr, 1, \"%s: no sources\\n\", src->freg->name);\n\t\t\telse {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s: no sources\\n\", src->freg->name));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tfound = GF_TRUE;\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s sources:\", src->freg->name);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s sources:\", src->freg->name));\n\t\t}\n\n\t\tfor (j=0; jnb_edges; j++) {\n\t\t\tif (gf_list_find(done, (void *) src->edges[j].src_reg->freg->name)<0) {\n\t\t\t\tif (print_fn)\n\t\t\t\t\tprint_fn(stderr, 0, \" %s\", src->edges[j].src_reg->freg->name);\n\t\t\t\telse {\n\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" %s\", src->edges[j].src_reg->freg->name));\n\t\t\t\t}\n\t\t\t\tgf_list_add(done, (void *) src->edges[j].src_reg->freg->name);\n\t\t\t}\n\t\t}\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 0, \"\\n\");\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\n\"));\n\t\t}\n\t\tgf_list_reset(done);\n\t}\n\n\tif (found && filter_name) {\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s sinks:\", filter_name);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s sinks:\", filter_name));\n\t\t}\n\t\tcount = gf_list_count(session->links);\n\t\tfor (i=0; ilinks, i);\n\t\t\tif (!strcmp(src->freg->name, filter_name)) {\n\t\t\t\tif (!(src->freg->flags & GF_FS_REG_EXPLICIT_ONLY) || !(src->freg->flags & GF_FS_REG_ALLOW_CYCLIC))\n\t\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (j=0; jnb_edges; j++) {\n\t\t\t\tif (strcmp(src->edges[j].src_reg->freg->name, filter_name)) continue;\n\n\t\t\t\tif (gf_list_find(done, (void *) src->freg->name)<0) {\n\t\t\t\t\tif (print_fn)\n\t\t\t\t\t\tprint_fn(stderr, 0, \" %s\", src->freg->name);\n\t\t\t\t\telse {\n\t\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" %s\", src->freg->name));\n\t\t\t\t\t}\n\t\t\t\t\tgf_list_add(done, (void *) src->freg->name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_list_reset(done);\n\t\t}\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \" \\n\");\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" \\n\"));\n\t\t}\n\t}\n\n\tif (!found && filter_name) {\n\t\tGF_Err e = GF_OK;\n\t\tGF_Filter *f = gf_fs_load_filter(session, filter_name, &e);\n\t\tif (f) {\n\t\t\tgf_fs_print_jsf_connection(session, filter_name, f, print_fn);\n\t\t}\n\t\telse if (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s filter not found\\n\", filter_name);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_APP, (\"%s filter not found\\n\", filter_name));\n\t\t}\n\t}\n\tgf_list_del(done);\n\tgf_log_set_tool_level(GF_LOG_FILTER, llev);\n}","target":0,"code_token_length":1023,"total_token_length":1259,"max_tokens_setting":2048} +{"idx":475113,"func":"static struct vrend_linked_shader_program *add_shader_program(struct vrend_sub_context *sub_ctx,\n struct vrend_shader *vs,\n struct vrend_shader *fs,\n struct vrend_shader *gs,\n struct vrend_shader *tcs,\n struct vrend_shader *tes)\n{\n struct vrend_linked_shader_program *sprog = CALLOC_STRUCT(vrend_linked_shader_program);\n char name[64];\n int i;\n GLuint prog_id;\n GLint lret;\n int last_shader;\n if (!sprog)\n return NULL;\n\n prog_id = glCreateProgram();\n glAttachShader(prog_id, vs->id);\n if (tcs && tcs->id > 0)\n glAttachShader(prog_id, tcs->id);\n if (tes && tes->id > 0)\n glAttachShader(prog_id, tes->id);\n\n if (gs) {\n if (gs->id > 0)\n glAttachShader(prog_id, gs->id);\n set_stream_out_varyings(sub_ctx, prog_id, &gs->sel->sinfo);\n } else if (tes)\n set_stream_out_varyings(sub_ctx, prog_id, &tes->sel->sinfo);\n else\n set_stream_out_varyings(sub_ctx, prog_id, &vs->sel->sinfo);\n glAttachShader(prog_id, fs->id);\n\n if (fs->sel->sinfo.num_outputs > 1) {\n sprog->dual_src_linked = util_blend_state_is_dual(&sub_ctx->blend_state, 0);\n if (sprog->dual_src_linked) {\n if (has_feature(feat_dual_src_blend)) {\n if (!vrend_state.use_gles) {\n glBindFragDataLocationIndexed(prog_id, 0, 0, \"fsout_c0\");\n glBindFragDataLocationIndexed(prog_id, 0, 1, \"fsout_c1\");\n } else {\n glBindFragDataLocationIndexedEXT(prog_id, 0, 0, \"fsout_c0\");\n glBindFragDataLocationIndexedEXT(prog_id, 0, 1, \"fsout_c1\");\n }\n } else {\n vrend_report_context_error(sub_ctx->parent, VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND, 0);\n }\n } else if (has_feature(feat_dual_src_blend)) {\n for (int i = 0; i < fs->sel->sinfo.num_outputs; ++i) {\n if (fs->sel->sinfo.fs_output_layout[i] >= 0) {\n char buf[64];\n snprintf(buf, sizeof(buf), \"fsout_c%d\", fs->sel->sinfo.fs_output_layout[i]);\n if (!vrend_state.use_gles)\n glBindFragDataLocationIndexed(prog_id, fs->sel->sinfo.fs_output_layout[i], 0, buf);\n else\n glBindFragDataLocationIndexedEXT(prog_id, fs->sel->sinfo.fs_output_layout[i], 0, buf);\n }\n }\n } else {\n vrend_report_context_error(sub_ctx->parent, VIRGL_ERROR_CTX_UNSUPPORTED_FUNCTION, 0);\n }\n } else\n sprog->dual_src_linked = false;\n\n if (has_feature(feat_gles31_vertex_attrib_binding)) {\n uint32_t mask = vs->sel->sinfo.attrib_input_mask;\n while (mask) {\n i = u_bit_scan(&mask);\n snprintf(name, 32, \"in_%d\", i);\n glBindAttribLocation(prog_id, i, name);\n }\n }\n\n glLinkProgram(prog_id);\n\n glGetProgramiv(prog_id, GL_LINK_STATUS, &lret);\n if (lret == GL_FALSE) {\n char infolog[65536];\n int len;\n glGetProgramInfoLog(prog_id, 65536, &len, infolog);\n vrend_printf(\"got error linking\\n%s\\n\", infolog);\n \/* dump shaders *\/\n vrend_report_context_error(sub_ctx->parent, VIRGL_ERROR_CTX_ILLEGAL_SHADER, 0);\n vrend_shader_dump(vs);\n if (tcs)\n vrend_shader_dump(tcs);\n if (tes)\n vrend_shader_dump(tes);\n if (gs)\n vrend_shader_dump(gs);\n vrend_shader_dump(fs);\n glDeleteProgram(prog_id);\n free(sprog);\n return NULL;\n }\n\n sprog->ss[PIPE_SHADER_VERTEX] = vs;\n sprog->ss[PIPE_SHADER_FRAGMENT] = fs;\n sprog->vs_fs_key = (((uint64_t)fs->id) << 32) | (vs->id & ~VREND_PROGRAM_NQUEUE_MASK) |\n (sprog->dual_src_linked ? 1 : 0);\n\n sprog->ss[PIPE_SHADER_GEOMETRY] = gs;\n sprog->ss[PIPE_SHADER_TESS_CTRL] = tcs;\n sprog->ss[PIPE_SHADER_TESS_EVAL] = tes;\n\n list_add(&sprog->sl[PIPE_SHADER_VERTEX], &vs->programs);\n list_add(&sprog->sl[PIPE_SHADER_FRAGMENT], &fs->programs);\n if (gs)\n list_add(&sprog->sl[PIPE_SHADER_GEOMETRY], &gs->programs);\n if (tcs)\n list_add(&sprog->sl[PIPE_SHADER_TESS_CTRL], &tcs->programs);\n if (tes)\n list_add(&sprog->sl[PIPE_SHADER_TESS_EVAL], &tes->programs);\n\n last_shader = tes ? PIPE_SHADER_TESS_EVAL : (gs ? PIPE_SHADER_GEOMETRY : PIPE_SHADER_FRAGMENT);\n sprog->id = prog_id;\n\n list_addtail(&sprog->head, &sub_ctx->gl_programs[vs->id & VREND_PROGRAM_NQUEUE_MASK]);\n\n if (fs->key.pstipple_tex)\n sprog->fs_stipple_loc = glGetUniformLocation(prog_id, \"pstipple_sampler\");\n else\n sprog->fs_stipple_loc = -1;\n\n if (vrend_state.use_core_profile) {\n sprog->fs_alpha_ref_val_loc = glGetUniformLocation(prog_id, \"alpha_ref_val\");\n sprog->fs_alpha_func_loc = glGetUniformLocation(prog_id, \"alpha_func\");\n } else {\n sprog->fs_alpha_ref_val_loc = -1;\n sprog->fs_alpha_func_loc = -1;\n }\n\n sprog->vs_ws_adjust_loc = glGetUniformLocation(prog_id, \"winsys_adjust_y\");\n\n vrend_use_program(sub_ctx, prog_id);\n\n int next_ubo_id = 0, next_sampler_id = 0;\n for (int shader_type = PIPE_SHADER_VERTEX; shader_type <= last_shader; shader_type++) {\n if (!sprog->ss[shader_type])\n continue;\n\n next_sampler_id = bind_sampler_locs(sprog, shader_type, next_sampler_id);\n bind_const_locs(sprog, shader_type);\n next_ubo_id = bind_ubo_locs(sprog, shader_type, next_ubo_id);\n bind_image_locs(sprog, shader_type);\n bind_ssbo_locs(sprog, shader_type);\n }\n\n if (!has_feature(feat_gles31_vertex_attrib_binding)) {\n if (vs->sel->sinfo.num_inputs) {\n sprog->attrib_locs = calloc(vs->sel->sinfo.num_inputs, sizeof(uint32_t));\n if (sprog->attrib_locs) {\n for (i = 0; i < vs->sel->sinfo.num_inputs; i++) {\n snprintf(name, 32, \"in_%d\", i);\n sprog->attrib_locs[i] = glGetAttribLocation(prog_id, name);\n }\n }\n } else\n sprog->attrib_locs = NULL;\n }\n\n sprog->clip_enabled_loc = glGetUniformLocation(prog_id, \"clip_plane_enabled\");\n for (i = 0; i < VIRGL_NUM_CLIP_PLANES; i++) {\n snprintf(name, 32, \"clipp[%d]\", i);\n sprog->clip_locs[i] = glGetUniformLocation(prog_id, name);\n }\n return sprog;\n}","target":0,"code_token_length":1746,"total_token_length":1982,"max_tokens_setting":2048} +{"idx":6149,"func":"tok_nextc(struct tok_state *tok)\n{\n for (;;) {\n if (tok->cur != tok->inp) {\n return Py_CHARMASK(*tok->cur++); \/* Fast path *\/\n }\n if (tok->done != E_OK)\n return EOF;\n if (tok->fp == NULL) {\n char *end = strchr(tok->inp, '\\n');\n if (end != NULL)\n end++;\n else {\n end = strchr(tok->inp, '\\0');\n if (end == tok->inp) {\n tok->done = E_EOF;\n return EOF;\n }\n }\n if (tok->start == NULL)\n tok->buf = tok->cur;\n tok->line_start = tok->cur;\n tok->lineno++;\n tok->inp = end;\n return Py_CHARMASK(*tok->cur++);\n }\n if (tok->prompt != NULL) {\n char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);\n#ifndef PGEN\n if (newtok != NULL) {\n char *translated = translate_newlines(newtok, 0, tok);\n PyMem_FREE(newtok);\n if (translated == NULL)\n return EOF;\n newtok = translated;\n }\n if (tok->encoding && newtok && *newtok) {\n \/* Recode to UTF-8 *\/\n Py_ssize_t buflen;\n const char* buf;\n PyObject *u = translate_into_utf8(newtok, tok->encoding);\n PyMem_FREE(newtok);\n if (!u) {\n tok->done = E_DECODE;\n return EOF;\n }\n buflen = PyBytes_GET_SIZE(u);\n buf = PyBytes_AS_STRING(u);\n newtok = PyMem_MALLOC(buflen+1);\n strcpy(newtok, buf);\n Py_DECREF(u);\n }\n#endif\n if (tok->nextprompt != NULL)\n tok->prompt = tok->nextprompt;\n if (newtok == NULL)\n tok->done = E_INTR;\n else if (*newtok == '\\0') {\n PyMem_FREE(newtok);\n tok->done = E_EOF;\n }\n else if (tok->start != NULL) {\n size_t start = tok->start - tok->buf;\n size_t oldlen = tok->cur - tok->buf;\n size_t newlen = oldlen + strlen(newtok);\n char *buf = tok->buf;\n buf = (char *)PyMem_REALLOC(buf, newlen+1);\n tok->lineno++;\n if (buf == NULL) {\n PyMem_FREE(tok->buf);\n tok->buf = NULL;\n PyMem_FREE(newtok);\n tok->done = E_NOMEM;\n return EOF;\n }\n tok->buf = buf;\n tok->cur = tok->buf + oldlen;\n tok->line_start = tok->cur;\n strcpy(tok->buf + oldlen, newtok);\n PyMem_FREE(newtok);\n tok->inp = tok->buf + newlen;\n tok->end = tok->inp + 1;\n tok->start = tok->buf + start;\n }\n else {\n tok->lineno++;\n if (tok->buf != NULL)\n PyMem_FREE(tok->buf);\n tok->buf = newtok;\n tok->cur = tok->buf;\n tok->line_start = tok->buf;\n tok->inp = strchr(tok->buf, '\\0');\n tok->end = tok->inp + 1;\n }\n }\n else {\n int done = 0;\n Py_ssize_t cur = 0;\n char *pt;\n if (tok->start == NULL) {\n if (tok->buf == NULL) {\n tok->buf = (char *)\n PyMem_MALLOC(BUFSIZ);\n if (tok->buf == NULL) {\n tok->done = E_NOMEM;\n return EOF;\n }\n tok->end = tok->buf + BUFSIZ;\n }\n if (decoding_fgets(tok->buf, (int)(tok->end - tok->buf),\n tok) == NULL) {\n if (!tok->decoding_erred)\n tok->done = E_EOF;\n done = 1;\n }\n else {\n tok->done = E_OK;\n tok->inp = strchr(tok->buf, '\\0');\n done = tok->inp == tok->buf || tok->inp[-1] == '\\n';\n }\n }\n else {\n cur = tok->cur - tok->buf;\n if (decoding_feof(tok)) {\n tok->done = E_EOF;\n done = 1;\n }\n else\n tok->done = E_OK;\n }\n tok->lineno++;\n \/* Read until '\\n' or EOF *\/\n while (!done) {\n Py_ssize_t curstart = tok->start == NULL ? -1 :\n tok->start - tok->buf;\n Py_ssize_t curvalid = tok->inp - tok->buf;\n Py_ssize_t newsize = curvalid + BUFSIZ;\n char *newbuf = tok->buf;\n newbuf = (char *)PyMem_REALLOC(newbuf,\n newsize);\n if (newbuf == NULL) {\n tok->done = E_NOMEM;\n tok->cur = tok->inp;\n return EOF;\n }\n tok->buf = newbuf;\n tok->cur = tok->buf + cur;\n tok->line_start = tok->cur;\n tok->inp = tok->buf + curvalid;\n tok->end = tok->buf + newsize;\n tok->start = curstart < 0 ? NULL :\n tok->buf + curstart;\n if (decoding_fgets(tok->inp,\n (int)(tok->end - tok->inp),\n tok) == NULL) {\n \/* Break out early on decoding\n errors, as tok->buf will be NULL\n *\/\n if (tok->decoding_erred)\n return EOF;\n \/* Last line does not end in \\n,\n fake one *\/\n strcpy(tok->inp, \"\\n\");\n }\n tok->inp = strchr(tok->inp, '\\0');\n done = tok->inp[-1] == '\\n';\n }\n if (tok->buf != NULL) {\n tok->cur = tok->buf + cur;\n tok->line_start = tok->cur;\n \/* replace \"\\r\\n\" with \"\\n\" *\/\n \/* For Mac leave the \\r, giving a syntax error *\/\n pt = tok->inp - 2;\n if (pt >= tok->buf && *pt == '\\r') {\n *pt++ = '\\n';\n *pt = '\\0';\n tok->inp = pt;\n }\n }\n }\n if (tok->done != E_OK) {\n if (tok->prompt != NULL)\n PySys_WriteStderr(\"\\n\");\n tok->cur = tok->inp;\n return EOF;\n }\n }\n \/*NOTREACHED*\/\n}","target":1,"code_token_length":1507,"total_token_length":1743,"max_tokens_setting":2048} +{"idx":358959,"func":"static int rsvp_change(struct tcf_proto *tp, unsigned long base,\n\t\t u32 handle,\n\t\t struct rtattr **tca,\n\t\t unsigned long *arg)\n{\n\tstruct rsvp_head *data = tp->root;\n\tstruct rsvp_filter *f, **fp;\n\tstruct rsvp_session *s, **sp;\n\tstruct tc_rsvp_pinfo *pinfo = NULL;\n\tstruct rtattr *opt = tca[TCA_OPTIONS-1];\n\tstruct rtattr *tb[TCA_RSVP_MAX];\n\tstruct tcf_exts e;\n\tunsigned h1, h2;\n\tu32 *dst;\n\tint err;\n\n\tif (opt == NULL)\n\t\treturn handle ? -EINVAL : 0;\n\n\tif (rtattr_parse_nested(tb, TCA_RSVP_MAX, opt) < 0)\n\t\treturn -EINVAL;\n\n\terr = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &rsvp_ext_map);\n\tif (err < 0)\n\t\treturn err;\n\n\tif ((f = (struct rsvp_filter*)*arg) != NULL) {\n\t\t\/* Node exists: adjust only classid *\/\n\n\t\tif (f->handle != handle && handle)\n\t\t\tgoto errout2;\n\t\tif (tb[TCA_RSVP_CLASSID-1]) {\n\t\t\tf->res.classid = *(u32*)RTA_DATA(tb[TCA_RSVP_CLASSID-1]);\n\t\t\ttcf_bind_filter(tp, &f->res, base);\n\t\t}\n\n\t\ttcf_exts_change(tp, &f->exts, &e);\n\t\treturn 0;\n\t}\n\n\t\/* Now more serious part... *\/\n\terr = -EINVAL;\n\tif (handle)\n\t\tgoto errout2;\n\tif (tb[TCA_RSVP_DST-1] == NULL)\n\t\tgoto errout2;\n\n\terr = -ENOBUFS;\n\tf = kmalloc(sizeof(struct rsvp_filter), GFP_KERNEL);\n\tif (f == NULL)\n\t\tgoto errout2;\n\n\tmemset(f, 0, sizeof(*f));\n\th2 = 16;\n\tif (tb[TCA_RSVP_SRC-1]) {\n\t\terr = -EINVAL;\n\t\tif (RTA_PAYLOAD(tb[TCA_RSVP_SRC-1]) != sizeof(f->src))\n\t\t\tgoto errout;\n\t\tmemcpy(f->src, RTA_DATA(tb[TCA_RSVP_SRC-1]), sizeof(f->src));\n\t\th2 = hash_src(f->src);\n\t}\n\tif (tb[TCA_RSVP_PINFO-1]) {\n\t\terr = -EINVAL;\n\t\tif (RTA_PAYLOAD(tb[TCA_RSVP_PINFO-1]) < sizeof(struct tc_rsvp_pinfo))\n\t\t\tgoto errout;\n\t\tpinfo = RTA_DATA(tb[TCA_RSVP_PINFO-1]);\n\t\tf->spi = pinfo->spi;\n\t\tf->tunnelhdr = pinfo->tunnelhdr;\n\t}\n\tif (tb[TCA_RSVP_CLASSID-1]) {\n\t\terr = -EINVAL;\n\t\tif (RTA_PAYLOAD(tb[TCA_RSVP_CLASSID-1]) != 4)\n\t\t\tgoto errout;\n\t\tf->res.classid = *(u32*)RTA_DATA(tb[TCA_RSVP_CLASSID-1]);\n\t}\n\n\terr = -EINVAL;\n\tif (RTA_PAYLOAD(tb[TCA_RSVP_DST-1]) != sizeof(f->src))\n\t\tgoto errout;\n\tdst = RTA_DATA(tb[TCA_RSVP_DST-1]);\n\th1 = hash_dst(dst, pinfo ? pinfo->protocol : 0, pinfo ? pinfo->tunnelid : 0);\n\n\terr = -ENOMEM;\n\tif ((f->handle = gen_handle(tp, h1 | (h2<<8))) == 0)\n\t\tgoto errout;\n\n\tif (f->tunnelhdr) {\n\t\terr = -EINVAL;\n\t\tif (f->res.classid > 255)\n\t\t\tgoto errout;\n\n\t\terr = -ENOMEM;\n\t\tif (f->res.classid == 0 &&\n\t\t (f->res.classid = gen_tunnel(data)) == 0)\n\t\t\tgoto errout;\n\t}\n\n\tfor (sp = &data->ht[h1]; (s=*sp) != NULL; sp = &s->next) {\n\t\tif (dst[RSVP_DST_LEN-1] == s->dst[RSVP_DST_LEN-1] &&\n\t\t pinfo && pinfo->protocol == s->protocol &&\n\t\t memcmp(&pinfo->dpi, &s->dpi, sizeof(s->dpi)) == 0\n#if RSVP_DST_LEN == 4\n\t\t && dst[0] == s->dst[0]\n\t\t && dst[1] == s->dst[1]\n\t\t && dst[2] == s->dst[2]\n#endif\n\t\t && pinfo->tunnelid == s->tunnelid) {\n\ninsert:\n\t\t\t\/* OK, we found appropriate session *\/\n\n\t\t\tfp = &s->ht[h2];\n\n\t\t\tf->sess = s;\n\t\t\tif (f->tunnelhdr == 0)\n\t\t\t\ttcf_bind_filter(tp, &f->res, base);\n\n\t\t\ttcf_exts_change(tp, &f->exts, &e);\n\n\t\t\tfor (fp = &s->ht[h2]; *fp; fp = &(*fp)->next)\n\t\t\t\tif (((*fp)->spi.mask&f->spi.mask) != f->spi.mask)\n\t\t\t\t\tbreak;\n\t\t\tf->next = *fp;\n\t\t\twmb();\n\t\t\t*fp = f;\n\n\t\t\t*arg = (unsigned long)f;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t\/* No session found. Create new one. *\/\n\n\terr = -ENOBUFS;\n\ts = kmalloc(sizeof(struct rsvp_session), GFP_KERNEL);\n\tif (s == NULL)\n\t\tgoto errout;\n\tmemset(s, 0, sizeof(*s));\n\tmemcpy(s->dst, dst, sizeof(s->dst));\n\n\tif (pinfo) {\n\t\ts->dpi = pinfo->dpi;\n\t\ts->protocol = pinfo->protocol;\n\t\ts->tunnelid = pinfo->tunnelid;\n\t}\n\tfor (sp = &data->ht[h1]; *sp; sp = &(*sp)->next) {\n\t\tif (((*sp)->dpi.mask&s->dpi.mask) != s->dpi.mask)\n\t\t\tbreak;\n\t}\n\ts->next = *sp;\n\twmb();\n\t*sp = s;\n\t\n\tgoto insert;\n\nerrout:\n\tif (f)\n\t\tkfree(f);\nerrout2:\n\ttcf_exts_destroy(tp, &e);\n\treturn err;\n}","target":0,"code_token_length":1360,"total_token_length":1596,"max_tokens_setting":2048} +{"idx":284627,"func":"static inline int unicode_cp_is_allowed(unsigned uni_cp, int document_type)\n{\n\t\/* XML 1.0\t\t\t\tHTML 4.01\t\t\tHTML 5\n\t * 0x09..0x0A\t\t\t0x09..0x0A\t\t\t0x09..0x0A\n\t * 0x0D\t\t\t\t\t0x0D\t\t\t\t0x0C..0x0D\n\t * 0x0020..0xD7FF\t\t0x20..0x7E\t\t\t0x20..0x7E\n\t *\t\t\t\t\t\t0x00A0..0xD7FF\t\t0x00A0..0xD7FF\n\t * 0xE000..0xFFFD\t\t0xE000..0x10FFFF\t0xE000..0xFDCF\n\t * 0x010000..0x10FFFF\t\t\t\t\t\t0xFDF0..0x10FFFF (*)\n\t *\n\t * (*) exclude code points where ((code & 0xFFFF) >= 0xFFFE)\n\t *\n\t * References:\n\t * XML 1.0: \n\t * HTML 4.01: \n\t * HTML 5: \n\t *\n \t * Not sure this is the relevant part for HTML 5, though. I opted to\n \t * disallow the characters that would result in a parse error when\n \t * preprocessing of the input stream. See also section 8.1.3.\n\t *\n \t * It's unclear if XHTML 1.0 allows C1 characters. I'll opt to apply to\n \t * XHTML 1.0 the same rules as for XML 1.0.\n \t * See .\n\t *\/\n\n\tswitch (document_type) {\n\tcase ENT_HTML_DOC_HTML401:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0x7E) ||\n\t\t\t(uni_cp == 0x0A || uni_cp == 0x09 || uni_cp == 0x0D) ||\n\t\t\t(uni_cp >= 0xA0 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF);\n\tcase ENT_HTML_DOC_HTML5:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0x7E) ||\n\t\t\t(uni_cp >= 0x09 && uni_cp <= 0x0D && uni_cp != 0x0B) || \/* form feed U+0C allowed *\/\n\t\t\t(uni_cp >= 0xA0 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF &&\n\t\t\t\t((uni_cp & 0xFFFF) < 0xFFFE) && \/* last two of each plane (nonchars) disallowed *\/\n\t\t\t\t(uni_cp < 0xFDD0 || uni_cp > 0xFDEF)); \/* U+FDD0-U+FDEF (nonchars) disallowed *\/\n\tcase ENT_HTML_DOC_XHTML:\n\tcase ENT_HTML_DOC_XML1:\n\t\treturn (uni_cp >= 0x20 && uni_cp <= 0xD7FF) ||\n\t\t\t(uni_cp == 0x0A || uni_cp == 0x09 || uni_cp == 0x0D) ||\n\t\t\t(uni_cp >= 0xE000 && uni_cp <= 0x10FFFF && uni_cp != 0xFFFE && uni_cp != 0xFFFF);\n\tdefault:\n\t\treturn 1;\n\t}\n}\n","target":0,"code_token_length":879,"total_token_length":1115,"max_tokens_setting":2048} +{"idx":362145,"func":" Process_Event( grEvent* event )\n {\n int ret = 0;\n\n\n if ( event->key >= '1' && event->key < '1' + N_RENDER_MODES )\n {\n status.render_mode = event->key - '1';\n event_render_mode_change( 0 );\n\n return ret;\n }\n\n switch ( event->key )\n {\n case grKeyEsc:\n case grKEY( 'q' ):\n ret = 1;\n break;\n\n case grKeyF1:\n case grKEY( '?' ):\n event_help();\n break;\n\n case grKEY( 'a' ):\n handle->antialias = !handle->antialias;\n status.header = handle->antialias\n ? (char *)\"anti-aliasing is now on\"\n : (char *)\"anti-aliasing is now off\";\n\n FTDemo_Update_Current_Flags( handle );\n break;\n\n case grKEY( 'b' ):\n handle->use_sbits = !handle->use_sbits;\n status.header = handle->use_sbits\n ? (char *)\"now using embedded bitmaps (if available)\"\n : (char *)\"now ignoring embedded bitmaps\";\n\n FTDemo_Update_Current_Flags( handle );\n break;\n\n case grKEY( 'c' ):\n handle->use_sbits_cache = !handle->use_sbits_cache;\n status.header = handle->use_sbits_cache\n ? (char *)\"now using sbits cache\"\n : (char *)\"now using normal cache\";\n break;\n\n case grKEY( 'f' ):\n handle->autohint = !handle->autohint;\n status.header = handle->autohint\n ? (char *)\"forced auto-hinting is now on\"\n : (char *)\"forced auto-hinting is now off\";\n\n FTDemo_Update_Current_Flags( handle );\n break;\n\n case grKEY( 'h' ):\n handle->hinted = !handle->hinted;\n status.header = handle->hinted\n ? (char *)\"glyph hinting is now active\"\n : (char *)\"glyph hinting is now ignored\";\n\n FTDemo_Update_Current_Flags( handle );\n break;\n\n case grKEY( 'l' ):\n handle->low_prec = !handle->low_prec;\n status.header = handle->low_prec\n ? (char *)\"rendering precision is now forced to low\"\n : (char *)\"rendering precision is now normal\";\n\n FTDemo_Update_Current_Flags( handle );\n break;\n\n case grKEY( 'L' ):\n handle->lcd_mode = ( handle->lcd_mode + 1 ) % N_LCD_MODES;\n\n switch ( handle->lcd_mode )\n {\n case LCD_MODE_AA:\n status.header = (char *)\"use normal anti-aliased rendering\";\n break;\n case LCD_MODE_LIGHT:\n status.header = (char *)\"use light anti-aliased rendering\";\n break;\n case LCD_MODE_RGB:\n status.header = (char *)\"use horizontal LCD-optimized rendering (RGB)\";\n break;\n case LCD_MODE_BGR:\n status.header = (char *)\"use horizontal LCD-optimized rendering (BGR)\";\n break;\n case LCD_MODE_VRGB:\n status.header = (char *)\"use vertical LCD-optimized rendering (RGB)\";\n break;\n case LCD_MODE_VBGR:\n status.header = (char *)\"use vertical LCD-optimized rendering (BGR)\";\n break;\n }\n\n FTDemo_Update_Current_Flags( handle );\n break;\n\n case grKEY( ' ' ):\n event_render_mode_change( 1 );\n break;\n\n case grKEY( 'G' ):\n event_gamma_grid();\n break;\n\n case grKEY( 's' ):\n event_slant_change( 0.02 );\n break;\n\n case grKEY( 'S' ):\n event_slant_change( -0.02 );\n break;\n\n case grKEY( 'e' ):\n event_bold_change( 0.002 );\n break;\n\n case grKEY( 'E' ):\n event_bold_change( -0.002 );\n break;\n\n case grKEY( 'g' ):\n event_gamma_change( 0.1 );\n break;\n\n case grKEY( 'v' ):\n event_gamma_change( -0.1 );\n break;\n\n case grKEY( 'n' ):\n event_font_change( 1 );\n break;\n\n case grKEY( 'p' ):\n event_font_change( -1 );\n break;\n\n case grKeyUp: event_size_change( 64 ); break;\n case grKeyDown: event_size_change( -64 ); break;\n case grKeyPageUp: event_size_change( 640 ); break;\n case grKeyPageDown: event_size_change( -640 ); break;\n\n case grKeyLeft: event_index_change( -1 ); break;\n case grKeyRight: event_index_change( 1 ); break;\n case grKeyF7: event_index_change( -10 ); break;\n case grKeyF8: event_index_change( 10 ); break;\n case grKeyF9: event_index_change( -100 ); break;\n case grKeyF10: event_index_change( 100 ); break;\n case grKeyF11: event_index_change( -1000 ); break;\n case grKeyF12: event_index_change( 1000 ); break;\n\n case grKEY( 'F' ):\n FTC_Manager_RemoveFaceID( handle->cache_manager,\n handle->scaler.face_id );\n\n status.use_custom_lcd_filter = !status.use_custom_lcd_filter;\n if ( status.use_custom_lcd_filter )\n FT_Library_SetLcdFilterWeights( handle->library,\n status.filter_weights );\n else\n FT_Library_SetLcdFilterWeights( handle->library,\n (unsigned char*)\"\\x10\\x40\\x70\\x40\\x10\" );\n status.header = status.use_custom_lcd_filter\n ? (char *)\"using custom LCD filter weights\"\n : (char *)\"using default LCD filter\";\n break;\n\n case grKEY( '[' ):\n if ( !status.use_custom_lcd_filter )\n break;\n\n status.fw_index--;\n if ( status.fw_index < 0 )\n status.fw_index = 4;\n break;\n\n case grKEY( ']' ):\n if ( !status.use_custom_lcd_filter )\n break;\n\n status.fw_index++;\n if ( status.fw_index > 4 )\n status.fw_index = 0;\n break;\n\n case grKEY( '-' ):\n if ( !status.use_custom_lcd_filter )\n break;\n\n FTC_Manager_RemoveFaceID( handle->cache_manager,\n handle->scaler.face_id );\n\n status.filter_weights[status.fw_index]--;\n FT_Library_SetLcdFilterWeights( handle->library,\n status.filter_weights );\n break;\n\n case grKEY( '+' ):\n case grKEY( '=' ):\n if ( !status.use_custom_lcd_filter )\n break;\n\n FTC_Manager_RemoveFaceID( handle->cache_manager,\n handle->scaler.face_id );\n\n status.filter_weights[status.fw_index]++;\n FT_Library_SetLcdFilterWeights( handle->library,\n status.filter_weights );\n break;\n\n default:\n break;\n }\n\n return ret;\n }","target":0,"code_token_length":1607,"total_token_length":1843,"max_tokens_setting":2048} +{"idx":85095,"func":"xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {\n int id = ctxt->input->id;\n\n SKIP(3);\n SKIP_BLANKS;\n if (CMP7(CUR_PTR, 'I', 'N', 'C', 'L', 'U', 'D', 'E')) {\n\tSKIP(7);\n\tSKIP_BLANKS;\n\tif (RAW != '[') {\n\t xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);\n\t xmlHaltParser(ctxt);\n\t return;\n\t} else {\n\t if (ctxt->input->id != id) {\n\t\txmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,\n\t \"All markup of the conditional section is not\"\n \" in the same entity\\n\");\n\t }\n\t NEXT;\n\t}\n\tif (xmlParserDebugEntities) {\n\t if ((ctxt->input != NULL) && (ctxt->input->filename))\n\t\txmlGenericError(xmlGenericErrorContext,\n\t\t\t\"%s(%d): \", ctxt->input->filename,\n\t\t\tctxt->input->line);\n\t xmlGenericError(xmlGenericErrorContext,\n\t\t \"Entering INCLUDE Conditional Section\\n\");\n\t}\n\n SKIP_BLANKS;\n GROW;\n\twhile (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||\n\t (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) {\n\t const xmlChar *check = CUR_PTR;\n\t unsigned int cons = ctxt->input->consumed;\n\n\t if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {\n\t\txmlParseConditionalSections(ctxt);\n\t } else\n\t\txmlParseMarkupDecl(ctxt);\n\n SKIP_BLANKS;\n GROW;\n\n\t if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {\n\t\txmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);\n\t\txmlHaltParser(ctxt);\n\t\tbreak;\n\t }\n\t}\n\tif (xmlParserDebugEntities) {\n\t if ((ctxt->input != NULL) && (ctxt->input->filename))\n\t\txmlGenericError(xmlGenericErrorContext,\n\t\t\t\"%s(%d): \", ctxt->input->filename,\n\t\t\tctxt->input->line);\n\t xmlGenericError(xmlGenericErrorContext,\n\t\t \"Leaving INCLUDE Conditional Section\\n\");\n\t}\n\n } else if (CMP6(CUR_PTR, 'I', 'G', 'N', 'O', 'R', 'E')) {\n\tint state;\n\txmlParserInputState instate;\n\tint depth = 0;\n\n\tSKIP(6);\n\tSKIP_BLANKS;\n\tif (RAW != '[') {\n\t xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);\n\t xmlHaltParser(ctxt);\n\t return;\n\t} else {\n\t if (ctxt->input->id != id) {\n\t\txmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,\n\t \"All markup of the conditional section is not\"\n \" in the same entity\\n\");\n\t }\n\t NEXT;\n\t}\n\tif (xmlParserDebugEntities) {\n\t if ((ctxt->input != NULL) && (ctxt->input->filename))\n\t\txmlGenericError(xmlGenericErrorContext,\n\t\t\t\"%s(%d): \", ctxt->input->filename,\n\t\t\tctxt->input->line);\n\t xmlGenericError(xmlGenericErrorContext,\n\t\t \"Entering IGNORE Conditional Section\\n\");\n\t}\n\n\t\/*\n\t * Parse up to the end of the conditional section\n\t * But disable SAX event generating DTD building in the meantime\n\t *\/\n\tstate = ctxt->disableSAX;\n\tinstate = ctxt->instate;\n\tif (ctxt->recovery == 0) ctxt->disableSAX = 1;\n\tctxt->instate = XML_PARSER_IGNORE;\n\n\twhile (((depth >= 0) && (RAW != 0)) &&\n (ctxt->instate != XML_PARSER_EOF)) {\n\t if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {\n\t depth++;\n\t SKIP(3);\n\t continue;\n\t }\n\t if ((RAW == ']') && (NXT(1) == ']') && (NXT(2) == '>')) {\n\t if (--depth >= 0) SKIP(3);\n\t continue;\n\t }\n\t NEXT;\n\t continue;\n\t}\n\n\tctxt->disableSAX = state;\n\tctxt->instate = instate;\n\n\tif (xmlParserDebugEntities) {\n\t if ((ctxt->input != NULL) && (ctxt->input->filename))\n\t\txmlGenericError(xmlGenericErrorContext,\n\t\t\t\"%s(%d): \", ctxt->input->filename,\n\t\t\tctxt->input->line);\n\t xmlGenericError(xmlGenericErrorContext,\n\t\t \"Leaving IGNORE Conditional Section\\n\");\n\t}\n\n } else {\n\txmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);\n\txmlHaltParser(ctxt);\n\treturn;\n }\n\n if (RAW == 0)\n SHRINK;\n\n if (RAW == 0) {\n\txmlFatalErr(ctxt, XML_ERR_CONDSEC_NOT_FINISHED, NULL);\n } else {\n\tif (ctxt->input->id != id) {\n\t xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,\n\t \"All markup of the conditional section is not in\"\n \" the same entity\\n\");\n\t}\n\tif ((ctxt-> instate != XML_PARSER_EOF) &&\n\t ((ctxt->input->cur + 3) <= ctxt->input->end))\n\t SKIP(3);\n }\n}","target":0,"code_token_length":1174,"total_token_length":1410,"max_tokens_setting":2048} +{"idx":326093,"func":"vnc_display_setup_auth(VncDisplay *vs,\n\n bool password,\n\n bool sasl,\n\n bool tls,\n\n bool x509,\n\n bool websocket)\n\n{\n\n \/*\n\n * We have a choice of 3 authentication options\n\n *\n\n * 1. none\n\n * 2. vnc\n\n * 3. sasl\n\n *\n\n * The channel can be run in 2 modes\n\n *\n\n * 1. clear\n\n * 2. tls\n\n *\n\n * And TLS can use 2 types of credentials\n\n *\n\n * 1. anon\n\n * 2. x509\n\n *\n\n * We thus have 9 possible logical combinations\n\n *\n\n * 1. clear + none\n\n * 2. clear + vnc\n\n * 3. clear + sasl\n\n * 4. tls + anon + none\n\n * 5. tls + anon + vnc\n\n * 6. tls + anon + sasl\n\n * 7. tls + x509 + none\n\n * 8. tls + x509 + vnc\n\n * 9. tls + x509 + sasl\n\n *\n\n * These need to be mapped into the VNC auth schemes\n\n * in an appropriate manner. In regular VNC, all the\n\n * TLS options get mapped into VNC_AUTH_VENCRYPT\n\n * sub-auth types.\n\n *\n\n * In websockets, the https:\/\/ protocol already provides\n\n * TLS support, so there is no need to make use of the\n\n * VeNCrypt extension. Furthermore, websockets browser\n\n * clients could not use VeNCrypt even if they wanted to,\n\n * as they cannot control when the TLS handshake takes\n\n * place. Thus there is no option but to rely on https:\/\/,\n\n * meaning combinations 4->6 and 7->9 will be mapped to\n\n * VNC auth schemes in the same way as combos 1->3.\n\n *\n\n * Regardless of fact that we have a different mapping to\n\n * VNC auth mechs for plain VNC vs websockets VNC, the end\n\n * result has the same security characteristics.\n\n *\/\n\n if (password) {\n\n if (tls) {\n\n vs->auth = VNC_AUTH_VENCRYPT;\n\n if (websocket) {\n\n vs->ws_tls = true;\n\n }\n\n if (x509) {\n\n VNC_DEBUG(\"Initializing VNC server with x509 password auth\\n\");\n\n vs->subauth = VNC_AUTH_VENCRYPT_X509VNC;\n\n } else {\n\n VNC_DEBUG(\"Initializing VNC server with TLS password auth\\n\");\n\n vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC;\n\n }\n\n } else {\n\n VNC_DEBUG(\"Initializing VNC server with password auth\\n\");\n\n vs->auth = VNC_AUTH_VNC;\n\n vs->subauth = VNC_AUTH_INVALID;\n\n }\n\n if (websocket) {\n\n vs->ws_auth = VNC_AUTH_VNC;\n\n } else {\n\n vs->ws_auth = VNC_AUTH_INVALID;\n\n }\n\n } else if (sasl) {\n\n if (tls) {\n\n vs->auth = VNC_AUTH_VENCRYPT;\n\n if (websocket) {\n\n vs->ws_tls = true;\n\n }\n\n if (x509) {\n\n VNC_DEBUG(\"Initializing VNC server with x509 SASL auth\\n\");\n\n vs->subauth = VNC_AUTH_VENCRYPT_X509SASL;\n\n } else {\n\n VNC_DEBUG(\"Initializing VNC server with TLS SASL auth\\n\");\n\n vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL;\n\n }\n\n } else {\n\n VNC_DEBUG(\"Initializing VNC server with SASL auth\\n\");\n\n vs->auth = VNC_AUTH_SASL;\n\n vs->subauth = VNC_AUTH_INVALID;\n\n }\n\n if (websocket) {\n\n vs->ws_auth = VNC_AUTH_SASL;\n\n } else {\n\n vs->ws_auth = VNC_AUTH_INVALID;\n\n }\n\n } else {\n\n if (tls) {\n\n vs->auth = VNC_AUTH_VENCRYPT;\n\n if (websocket) {\n\n vs->ws_tls = true;\n\n }\n\n if (x509) {\n\n VNC_DEBUG(\"Initializing VNC server with x509 no auth\\n\");\n\n vs->subauth = VNC_AUTH_VENCRYPT_X509NONE;\n\n } else {\n\n VNC_DEBUG(\"Initializing VNC server with TLS no auth\\n\");\n\n vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE;\n\n }\n\n } else {\n\n VNC_DEBUG(\"Initializing VNC server with no auth\\n\");\n\n vs->auth = VNC_AUTH_NONE;\n\n vs->subauth = VNC_AUTH_INVALID;\n\n }\n\n if (websocket) {\n\n vs->ws_auth = VNC_AUTH_NONE;\n\n } else {\n\n vs->ws_auth = VNC_AUTH_INVALID;\n\n }\n\n }\n\n}\n","target":1,"code_token_length":1105,"total_token_length":1341,"max_tokens_setting":2048} +{"idx":88222,"func":"bool Archive::IsArchive(bool EnableBroken)\n{\n Encrypted=false;\n BrokenHeader=false; \/\/ Might be left from previous volume.\n \n#ifndef SFX_MODULE\n if (IsDevice())\n {\n uiMsg(UIERROR_INVALIDNAME,FileName,FileName);\n return false;\n }\n#endif\n if (Read(MarkHead.Mark,SIZEOF_MARKHEAD3)!=SIZEOF_MARKHEAD3)\n return false;\n SFXSize=0;\n \n RARFORMAT Type;\n if ((Type=IsSignature(MarkHead.Mark,SIZEOF_MARKHEAD3))!=RARFMT_NONE)\n {\n Format=Type;\n if (Format==RARFMT14)\n Seek(Tell()-SIZEOF_MARKHEAD3,SEEK_SET);\n }\n else\n {\n Array Buffer(MAXSFXSIZE);\n long CurPos=(long)Tell();\n int ReadSize=Read(&Buffer[0],Buffer.Size()-16);\n for (int I=0;I0 && CurPos<28 && ReadSize>31)\n {\n char *D=&Buffer[28-CurPos];\n if (D[0]!=0x52 || D[1]!=0x53 || D[2]!=0x46 || D[3]!=0x58)\n continue;\n }\n SFXSize=CurPos+I;\n Seek(SFXSize,SEEK_SET);\n if (Format==RARFMT15 || Format==RARFMT50)\n Read(MarkHead.Mark,SIZEOF_MARKHEAD3);\n break;\n }\n if (SFXSize==0)\n return false;\n }\n if (Format==RARFMT_FUTURE)\n {\n uiMsg(UIERROR_NEWRARFORMAT,FileName);\n return false;\n }\n if (Format==RARFMT50) \/\/ RAR 5.0 signature is by one byte longer.\n {\n if (Read(MarkHead.Mark+SIZEOF_MARKHEAD3,1)!=1 || MarkHead.Mark[SIZEOF_MARKHEAD3]!=0)\n return false;\n MarkHead.HeadSize=SIZEOF_MARKHEAD5;\n }\n else\n MarkHead.HeadSize=SIZEOF_MARKHEAD3;\n\n#ifdef RARDLL\n \/\/ If callback function is not set, we cannot get the password,\n \/\/ so we skip the initial header processing for encrypted header archive.\n \/\/ It leads to skipped archive comment, but the rest of archive data\n \/\/ is processed correctly.\n if (Cmd->Callback==NULL)\n SilentOpen=true;\n#endif\n\n bool HeadersLeft; \/\/ Any headers left to read.\n \/\/ Skip the archive encryption header if any and read the main header.\n while ((HeadersLeft=(ReadHeader()!=0))==true) \/\/ Additional parentheses to silence Clang.\n {\n SeekToNext();\n\n HEADER_TYPE Type=GetHeaderType();\n \/\/ In RAR 5.0 we need to quit after reading HEAD_CRYPT if we wish to\n \/\/ avoid the password prompt.\n if (Type==HEAD_MAIN || SilentOpen && Type==HEAD_CRYPT)\n break;\n }\n\n \/\/ This check allows to make RS based recovery even if password is incorrect.\n \/\/ But we should not do it for EnableBroken or we'll get 'not RAR archive'\n \/\/ messages when extracting encrypted archives with wrong password.\n if (FailedHeaderDecryption && !EnableBroken)\n return false;\n\n if (BrokenHeader) \/\/ Main archive header is corrupt.\n {\n uiMsg(UIERROR_MHEADERBROKEN,FileName);\n if (!EnableBroken)\n return false;\n }\n\n MainComment=MainHead.CommentInHeader;\n\n \/\/ If we process non-encrypted archive or can request a password,\n \/\/ we set 'first volume' flag based on file attributes below.\n \/\/ It is necessary for RAR 2.x archives, which did not have 'first volume'\n \/\/ flag in main header. Also for all RAR formats we need to scan until\n \/\/ first file header to set \"comment\" flag when reading service header.\n \/\/ Unless we are in silent mode, we need to know about presence of comment\n \/\/ immediately after IsArchive call.\n if (HeadersLeft && (!SilentOpen || !Encrypted))\n {\n SaveFilePos SavePos(*this);\n int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;\n HEADER_TYPE SaveCurHeaderType=CurHeaderType;\n\n while (ReadHeader()!=0)\n {\n HEADER_TYPE HeaderType=GetHeaderType();\n if (HeaderType==HEAD_SERVICE)\n {\n \/\/ If we have a split service headers, it surely indicates non-first\n \/\/ volume. But not split service header does not guarantee the first\n \/\/ volume, because we can have split file after non-split archive\n \/\/ comment. So we do not quit from loop here.\n FirstVolume=Volume && !SubHead.SplitBefore;\n }\n else\n if (HeaderType==HEAD_FILE)\n {\n FirstVolume=Volume && !FileHead.SplitBefore;\n break;\n }\n else\n if (HeaderType==HEAD_ENDARC) \/\/ Might happen if archive contains only a split service header.\n break;\n SeekToNext();\n }\n CurBlockPos=SaveCurBlockPos;\n NextBlockPos=SaveNextBlockPos;\n CurHeaderType=SaveCurHeaderType;\n }\n if (!Volume || FirstVolume)\n wcsncpyz(FirstVolumeName,FileName,ASIZE(FirstVolumeName));\n\n return true;\n}","target":0,"code_token_length":1242,"total_token_length":1478,"max_tokens_setting":2048} +{"idx":350456,"func":"int iscsi_session_get_param(struct iscsi_cls_session *cls_session,\n\t\t\t enum iscsi_param param, char *buf)\n{\n\tstruct iscsi_session *session = cls_session->dd_data;\n\tint len;\n\n\tswitch(param) {\n\tcase ISCSI_PARAM_FAST_ABORT:\n\t\tlen = sprintf(buf, \"%d\\n\", session->fast_abort);\n\t\tbreak;\n\tcase ISCSI_PARAM_ABORT_TMO:\n\t\tlen = sprintf(buf, \"%d\\n\", session->abort_timeout);\n\t\tbreak;\n\tcase ISCSI_PARAM_LU_RESET_TMO:\n\t\tlen = sprintf(buf, \"%d\\n\", session->lu_reset_timeout);\n\t\tbreak;\n\tcase ISCSI_PARAM_TGT_RESET_TMO:\n\t\tlen = sprintf(buf, \"%d\\n\", session->tgt_reset_timeout);\n\t\tbreak;\n\tcase ISCSI_PARAM_INITIAL_R2T_EN:\n\t\tlen = sprintf(buf, \"%d\\n\", session->initial_r2t_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_MAX_R2T:\n\t\tlen = sprintf(buf, \"%hu\\n\", session->max_r2t);\n\t\tbreak;\n\tcase ISCSI_PARAM_IMM_DATA_EN:\n\t\tlen = sprintf(buf, \"%d\\n\", session->imm_data_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_FIRST_BURST:\n\t\tlen = sprintf(buf, \"%u\\n\", session->first_burst);\n\t\tbreak;\n\tcase ISCSI_PARAM_MAX_BURST:\n\t\tlen = sprintf(buf, \"%u\\n\", session->max_burst);\n\t\tbreak;\n\tcase ISCSI_PARAM_PDU_INORDER_EN:\n\t\tlen = sprintf(buf, \"%d\\n\", session->pdu_inorder_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_DATASEQ_INORDER_EN:\n\t\tlen = sprintf(buf, \"%d\\n\", session->dataseq_inorder_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_DEF_TASKMGMT_TMO:\n\t\tlen = sprintf(buf, \"%d\\n\", session->def_taskmgmt_tmo);\n\t\tbreak;\n\tcase ISCSI_PARAM_ERL:\n\t\tlen = sprintf(buf, \"%d\\n\", session->erl);\n\t\tbreak;\n\tcase ISCSI_PARAM_TARGET_NAME:\n\t\tlen = sprintf(buf, \"%s\\n\", session->targetname);\n\t\tbreak;\n\tcase ISCSI_PARAM_TARGET_ALIAS:\n\t\tlen = sprintf(buf, \"%s\\n\", session->targetalias);\n\t\tbreak;\n\tcase ISCSI_PARAM_TPGT:\n\t\tlen = sprintf(buf, \"%d\\n\", session->tpgt);\n\t\tbreak;\n\tcase ISCSI_PARAM_USERNAME:\n\t\tlen = sprintf(buf, \"%s\\n\", session->username);\n\t\tbreak;\n\tcase ISCSI_PARAM_USERNAME_IN:\n\t\tlen = sprintf(buf, \"%s\\n\", session->username_in);\n\t\tbreak;\n\tcase ISCSI_PARAM_PASSWORD:\n\t\tlen = sprintf(buf, \"%s\\n\", session->password);\n\t\tbreak;\n\tcase ISCSI_PARAM_PASSWORD_IN:\n\t\tlen = sprintf(buf, \"%s\\n\", session->password_in);\n\t\tbreak;\n\tcase ISCSI_PARAM_IFACE_NAME:\n\t\tlen = sprintf(buf, \"%s\\n\", session->ifacename);\n\t\tbreak;\n\tcase ISCSI_PARAM_INITIATOR_NAME:\n\t\tlen = sprintf(buf, \"%s\\n\", session->initiatorname);\n\t\tbreak;\n\tcase ISCSI_PARAM_BOOT_ROOT:\n\t\tlen = sprintf(buf, \"%s\\n\", session->boot_root);\n\t\tbreak;\n\tcase ISCSI_PARAM_BOOT_NIC:\n\t\tlen = sprintf(buf, \"%s\\n\", session->boot_nic);\n\t\tbreak;\n\tcase ISCSI_PARAM_BOOT_TARGET:\n\t\tlen = sprintf(buf, \"%s\\n\", session->boot_target);\n\t\tbreak;\n\tcase ISCSI_PARAM_AUTO_SND_TGT_DISABLE:\n\t\tlen = sprintf(buf, \"%u\\n\", session->auto_snd_tgt_disable);\n\t\tbreak;\n\tcase ISCSI_PARAM_DISCOVERY_SESS:\n\t\tlen = sprintf(buf, \"%u\\n\", session->discovery_sess);\n\t\tbreak;\n\tcase ISCSI_PARAM_PORTAL_TYPE:\n\t\tlen = sprintf(buf, \"%s\\n\", session->portal_type);\n\t\tbreak;\n\tcase ISCSI_PARAM_CHAP_AUTH_EN:\n\t\tlen = sprintf(buf, \"%u\\n\", session->chap_auth_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_DISCOVERY_LOGOUT_EN:\n\t\tlen = sprintf(buf, \"%u\\n\", session->discovery_logout_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_BIDI_CHAP_EN:\n\t\tlen = sprintf(buf, \"%u\\n\", session->bidi_chap_en);\n\t\tbreak;\n\tcase ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL:\n\t\tlen = sprintf(buf, \"%u\\n\", session->discovery_auth_optional);\n\t\tbreak;\n\tcase ISCSI_PARAM_DEF_TIME2WAIT:\n\t\tlen = sprintf(buf, \"%d\\n\", session->time2wait);\n\t\tbreak;\n\tcase ISCSI_PARAM_DEF_TIME2RETAIN:\n\t\tlen = sprintf(buf, \"%d\\n\", session->time2retain);\n\t\tbreak;\n\tcase ISCSI_PARAM_TSID:\n\t\tlen = sprintf(buf, \"%u\\n\", session->tsid);\n\t\tbreak;\n\tcase ISCSI_PARAM_ISID:\n\t\tlen = sprintf(buf, \"%02x%02x%02x%02x%02x%02x\\n\",\n\t\t\t session->isid[0], session->isid[1],\n\t\t\t session->isid[2], session->isid[3],\n\t\t\t session->isid[4], session->isid[5]);\n\t\tbreak;\n\tcase ISCSI_PARAM_DISCOVERY_PARENT_IDX:\n\t\tlen = sprintf(buf, \"%u\\n\", session->discovery_parent_idx);\n\t\tbreak;\n\tcase ISCSI_PARAM_DISCOVERY_PARENT_TYPE:\n\t\tif (session->discovery_parent_type)\n\t\t\tlen = sprintf(buf, \"%s\\n\",\n\t\t\t\t session->discovery_parent_type);\n\t\telse\n\t\t\tlen = sprintf(buf, \"\\n\");\n\t\tbreak;\n\tdefault:\n\t\treturn -ENOSYS;\n\t}\n\n\treturn len;\n}","target":1,"code_token_length":1194,"total_token_length":1430,"max_tokens_setting":2048} +{"idx":386652,"func":"static void pcnet_update_irq(PCNetState *s)\n{\n int isr = 0;\n s->csr[0] &= ~0x0080;\n\n#if 1\n if (((s->csr[0] & ~s->csr[3]) & 0x5f00) ||\n (((s->csr[4]>>1) & ~s->csr[4]) & 0x0115) ||\n (((s->csr[5]>>1) & s->csr[5]) & 0x0048))\n#else\n if ((!(s->csr[3] & 0x4000) && !!(s->csr[0] & 0x4000)) \/* BABL *\/ ||\n (!(s->csr[3] & 0x1000) && !!(s->csr[0] & 0x1000)) \/* MISS *\/ ||\n (!(s->csr[3] & 0x0100) && !!(s->csr[0] & 0x0100)) \/* IDON *\/ ||\n (!(s->csr[3] & 0x0200) && !!(s->csr[0] & 0x0200)) \/* TINT *\/ ||\n (!(s->csr[3] & 0x0400) && !!(s->csr[0] & 0x0400)) \/* RINT *\/ ||\n (!(s->csr[3] & 0x0800) && !!(s->csr[0] & 0x0800)) \/* MERR *\/ ||\n (!(s->csr[4] & 0x0001) && !!(s->csr[4] & 0x0002)) \/* JAB *\/ ||\n (!(s->csr[4] & 0x0004) && !!(s->csr[4] & 0x0008)) \/* TXSTRT *\/ ||\n (!(s->csr[4] & 0x0010) && !!(s->csr[4] & 0x0020)) \/* RCVO *\/ ||\n (!(s->csr[4] & 0x0100) && !!(s->csr[4] & 0x0200)) \/* MFCO *\/ ||\n (!!(s->csr[5] & 0x0040) && !!(s->csr[5] & 0x0080)) \/* EXDINT *\/ ||\n (!!(s->csr[5] & 0x0008) && !!(s->csr[5] & 0x0010)) \/* MPINT *\/)\n#endif\n {\n\n isr = CSR_INEA(s);\n s->csr[0] |= 0x0080;\n }\n\n if (!!(s->csr[4] & 0x0080) && CSR_INEA(s)) { \/* UINT *\/\n s->csr[4] &= ~0x0080;\n s->csr[4] |= 0x0040;\n s->csr[0] |= 0x0080;\n isr = 1;\n trace_pcnet_user_int(s);\n }\n\n#if 1\n if (((s->csr[5]>>1) & s->csr[5]) & 0x0500)\n#else\n if ((!!(s->csr[5] & 0x0400) && !!(s->csr[5] & 0x0800)) \/* SINT *\/ ||\n (!!(s->csr[5] & 0x0100) && !!(s->csr[5] & 0x0200)) \/* SLPINT *\/ )\n#endif\n {\n isr = 1;\n s->csr[0] |= 0x0080;\n }\n\n if (isr != s->isr) {\n trace_pcnet_isr_change(s, isr, s->isr);\n }\n qemu_set_irq(s->irq, isr);\n s->isr = isr;\n}","target":0,"code_token_length":929,"total_token_length":1165,"max_tokens_setting":2048} +{"idx":498165,"func":"static enum PartMode decode_part_mode(thread_context* tctx,\n\t\t\t\t enum PredMode pred_mode, int cLog2CbSize)\n{\n de265_image* img = tctx->img;\n\n if (pred_mode == MODE_INTRA) {\n logtrace(LogSlice,\"# part_mode (INTRA)\\n\");\n\n int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE]);\n\n logtrace(LogSlice,\"> %s\\n\",bit ? \"2Nx2N\" : \"NxN\");\n\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",bit ? PART_2Nx2N : PART_NxN);\n\n return bit ? PART_2Nx2N : PART_NxN;\n }\n else {\n const seq_parameter_set& sps = img->get_sps();\n\n int bit0 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+0]);\n if (bit0) { logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2Nx2N); return PART_2Nx2N; }\n\n \/\/ CHECK_ME: I optimize code and fix bug here, need more VERIFY!\n int bit1 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+1]);\n if (cLog2CbSize > sps.Log2MinCbSizeY) {\n if (!sps.amp_enabled_flag) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",bit1 ? PART_2NxN : PART_Nx2N);\n return bit1 ? PART_2NxN : PART_Nx2N;\n }\n else {\n int bit3 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+3]);\n if (bit3) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",bit1 ? PART_2NxN : PART_Nx2N);\n return bit1 ? PART_2NxN : PART_Nx2N;\n }\n\n int bit4 = decode_CABAC_bypass(&tctx->cabac_decoder);\n if ( bit1 && bit4) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2NxnD);\n return PART_2NxnD;\n }\n if ( bit1 && !bit4) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2NxnU);\n return PART_2NxnU;\n }\n if (!bit1 && !bit4) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_nLx2N);\n return PART_nLx2N;\n }\n if (!bit1 && bit4) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_nRx2N);\n return PART_nRx2N;\n }\n }\n }\n else {\n \/\/ TODO, we could save one if here when first decoding the next bin and then\n \/\/ checkcLog2CbSize==3 when it is '0'\n\n if (bit1) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2NxN);\n return PART_2NxN;\n }\n\n if (cLog2CbSize==3) {\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_Nx2N);\n return PART_Nx2N;\n }\n else {\n int bit2 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+2]);\n logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_NxN-bit2);\n return (enum PartMode)((int)PART_NxN - bit2)\/*bit2 ? PART_Nx2N : PART_NxN*\/;\n }\n }\n }\n\n assert(false); \/\/ should never be reached\n return PART_2Nx2N;\n}","target":0,"code_token_length":895,"total_token_length":1131,"max_tokens_setting":2048} +{"idx":491816,"func":"parser_parse_continue_statement (parser_context_t *context_p) \/**< context *\/\n{\n parser_stack_iterator_t iterator;\n cbc_opcode_t opcode = CBC_JUMP_FORWARD;\n\n lexer_next_token (context_p);\n parser_stack_iterator_init (context_p, &iterator);\n\n if (!(context_p->token.flags & LEXER_WAS_NEWLINE)\n && context_p->token.type == LEXER_LITERAL\n && context_p->token.lit_location.type == LEXER_IDENT_LITERAL)\n {\n parser_stack_iterator_t loop_iterator;\n\n loop_iterator.current_p = NULL;\n\n \/* The label with the same name is searched on the stack. *\/\n while (true)\n {\n uint8_t type = parser_stack_iterator_read_uint8 (&iterator);\n\n if (type == PARSER_STATEMENT_START)\n {\n parser_raise_error (context_p, PARSER_ERR_INVALID_CONTINUE_LABEL);\n }\n\n \/* Only those labels are checked, whose are label of a loop. *\/\n if (loop_iterator.current_p != NULL && type == PARSER_STATEMENT_LABEL)\n {\n parser_label_statement_t label_statement;\n\n parser_stack_iterator_skip (&iterator, 1);\n parser_stack_iterator_read (&iterator, &label_statement, sizeof (parser_label_statement_t));\n\n if (lexer_current_is_literal (context_p, &label_statement.label_ident))\n {\n parser_loop_statement_t loop;\n\n parser_stack_iterator_skip (&loop_iterator, 1);\n parser_stack_iterator_read (&loop_iterator, &loop, sizeof (parser_loop_statement_t));\n loop.branch_list_p = parser_emit_cbc_forward_branch_item (context_p,\n (uint16_t) opcode,\n loop.branch_list_p);\n loop.branch_list_p->branch.offset |= CBC_HIGHEST_BIT_MASK;\n parser_stack_iterator_write (&loop_iterator, &loop, sizeof (parser_loop_statement_t));\n lexer_next_token (context_p);\n return;\n }\n parser_stack_iterator_skip (&iterator, sizeof (parser_label_statement_t));\n continue;\n }\n\n if (parser_statement_flags[type] & PARSER_STATM_CONTEXT_BREAK)\n {\n opcode = CBC_JUMP_FORWARD_EXIT_CONTEXT;\n }\n\n#if JERRY_ESNEXT\n const bool is_private_scope = (type == PARSER_STATEMENT_PRIVATE_SCOPE\n || type == PARSER_STATEMENT_PRIVATE_CONTEXT);\n#else \/* !JERRY_ESNEXT *\/\n const bool is_private_scope = false;\n#endif \/* !JERRY_ESNEXT *\/\n\n if (parser_statement_flags[type] & PARSER_STATM_CONTINUE_TARGET)\n {\n loop_iterator = iterator;\n }\n else if (!is_private_scope)\n {\n loop_iterator.current_p = NULL;\n }\n\n parser_stack_iterator_skip (&iterator, parser_statement_length (type));\n }\n }\n\n \/* The first loop statement is searched. *\/\n while (true)\n {\n uint8_t type = parser_stack_iterator_read_uint8 (&iterator);\n if (type == PARSER_STATEMENT_START)\n {\n parser_raise_error (context_p, PARSER_ERR_INVALID_CONTINUE);\n }\n\n if (parser_statement_flags[type] & PARSER_STATM_CONTINUE_TARGET)\n {\n parser_loop_statement_t loop;\n\n parser_stack_iterator_skip (&iterator, 1);\n parser_stack_iterator_read (&iterator, &loop, sizeof (parser_loop_statement_t));\n loop.branch_list_p = parser_emit_cbc_forward_branch_item (context_p,\n (uint16_t) opcode,\n loop.branch_list_p);\n loop.branch_list_p->branch.offset |= CBC_HIGHEST_BIT_MASK;\n parser_stack_iterator_write (&iterator, &loop, sizeof (parser_loop_statement_t));\n return;\n }\n\n if (parser_statement_flags[type] & PARSER_STATM_CONTEXT_BREAK)\n {\n opcode = CBC_JUMP_FORWARD_EXIT_CONTEXT;\n }\n\n parser_stack_iterator_skip (&iterator, parser_statement_length (type));\n }\n} \/* parser_parse_continue_statement *\/","target":0,"code_token_length":807,"total_token_length":1043,"max_tokens_setting":2048} +{"idx":124722,"func":"FilterUtility::finalTimeout(const RouteEntry& route, Http::HeaderMap& request_headers,\n bool insert_envoy_expected_request_timeout_ms, bool grpc_request,\n bool per_try_timeout_hedging_enabled,\n bool respect_expected_rq_timeout) {\n \/\/ See if there is a user supplied timeout in a request header. If there is we take that.\n \/\/ Otherwise if the request is gRPC and a maximum gRPC timeout is configured we use the timeout\n \/\/ in the gRPC headers (or infinity when gRPC headers have no timeout), but cap that timeout to\n \/\/ the configured maximum gRPC timeout (which may also be infinity, represented by a 0 value),\n \/\/ or the default from the route config otherwise.\n TimeoutData timeout;\n if (grpc_request && route.maxGrpcTimeout()) {\n const std::chrono::milliseconds max_grpc_timeout = route.maxGrpcTimeout().value();\n std::chrono::milliseconds grpc_timeout = Grpc::Common::getGrpcTimeout(request_headers);\n if (route.grpcTimeoutOffset()) {\n \/\/ We only apply the offset if it won't result in grpc_timeout hitting 0 or below, as\n \/\/ setting it to 0 means infinity and a negative timeout makes no sense.\n const auto offset = *route.grpcTimeoutOffset();\n if (offset < grpc_timeout) {\n grpc_timeout -= offset;\n }\n }\n\n \/\/ Cap gRPC timeout to the configured maximum considering that 0 means infinity.\n if (max_grpc_timeout != std::chrono::milliseconds(0) &&\n (grpc_timeout == std::chrono::milliseconds(0) || grpc_timeout > max_grpc_timeout)) {\n grpc_timeout = max_grpc_timeout;\n }\n timeout.global_timeout_ = grpc_timeout;\n } else {\n timeout.global_timeout_ = route.timeout();\n }\n timeout.per_try_timeout_ = route.retryPolicy().perTryTimeout();\n\n uint64_t header_timeout;\n\n if (respect_expected_rq_timeout) {\n \/\/ Check if there is timeout set by egress Envoy.\n \/\/ If present, use that value as route timeout and don't override\n \/\/ *x-envoy-expected-rq-timeout-ms* header. At this point *x-envoy-upstream-rq-timeout-ms*\n \/\/ header should have been sanitized by egress Envoy.\n Http::HeaderEntry* header_expected_timeout_entry =\n request_headers.EnvoyExpectedRequestTimeoutMs();\n if (header_expected_timeout_entry) {\n trySetGlobalTimeout(header_expected_timeout_entry, timeout);\n } else {\n Http::HeaderEntry* header_timeout_entry = request_headers.EnvoyUpstreamRequestTimeoutMs();\n\n if (trySetGlobalTimeout(header_timeout_entry, timeout)) {\n request_headers.removeEnvoyUpstreamRequestTimeoutMs();\n }\n }\n } else {\n Http::HeaderEntry* header_timeout_entry = request_headers.EnvoyUpstreamRequestTimeoutMs();\n if (trySetGlobalTimeout(header_timeout_entry, timeout)) {\n request_headers.removeEnvoyUpstreamRequestTimeoutMs();\n }\n }\n\n \/\/ See if there is a per try\/retry timeout. If it's >= global we just ignore it.\n Http::HeaderEntry* per_try_timeout_entry = request_headers.EnvoyUpstreamRequestPerTryTimeoutMs();\n if (per_try_timeout_entry) {\n if (absl::SimpleAtoi(per_try_timeout_entry->value().getStringView(), &header_timeout)) {\n timeout.per_try_timeout_ = std::chrono::milliseconds(header_timeout);\n }\n request_headers.removeEnvoyUpstreamRequestPerTryTimeoutMs();\n }\n\n if (timeout.per_try_timeout_ >= timeout.global_timeout_) {\n timeout.per_try_timeout_ = std::chrono::milliseconds(0);\n }\n\n \/\/ See if there is any timeout to write in the expected timeout header.\n uint64_t expected_timeout = timeout.per_try_timeout_.count();\n \/\/ Use the global timeout if no per try timeout was specified or if we're\n \/\/ doing hedging when there are per try timeouts. Either of these scenarios\n \/\/ mean that the upstream server can use the full global timeout.\n if (per_try_timeout_hedging_enabled || expected_timeout == 0) {\n expected_timeout = timeout.global_timeout_.count();\n }\n\n if (insert_envoy_expected_request_timeout_ms && expected_timeout > 0) {\n request_headers.insertEnvoyExpectedRequestTimeoutMs().value(expected_timeout);\n }\n\n \/\/ If we've configured max_grpc_timeout, override the grpc-timeout header with\n \/\/ the expected timeout. This ensures that the optional per try timeout is reflected\n \/\/ in grpc-timeout, ensuring that the upstream gRPC server is aware of the actual timeout.\n \/\/ If the expected timeout is 0 set no timeout, as Envoy treats 0 as infinite timeout.\n if (grpc_request && route.maxGrpcTimeout() && expected_timeout != 0) {\n Grpc::Common::toGrpcTimeout(std::chrono::milliseconds(expected_timeout),\n request_headers.insertGrpcTimeout().value());\n }\n\n return timeout;\n}","target":0,"code_token_length":1061,"total_token_length":1297,"max_tokens_setting":2048} +{"idx":501925,"func":"static struct security_descriptor *descr_handle_sd_flags(TALLOC_CTX *mem_ctx,\n\t\t\t\t\t\t\t struct security_descriptor *new_sd,\n\t\t\t\t\t\t\t struct security_descriptor *old_sd,\n\t\t\t\t\t\t\t uint32_t sd_flags)\n{\n\tstruct security_descriptor *final_sd; \n\t\/* if there is no control or control == 0 modify everything *\/\n\tif (!sd_flags) {\n\t\treturn new_sd;\n\t}\n\n\tfinal_sd = talloc_zero(mem_ctx, struct security_descriptor);\n\tfinal_sd->revision = SECURITY_DESCRIPTOR_REVISION_1;\n\tfinal_sd->type = SEC_DESC_SELF_RELATIVE;\n\n\tif (sd_flags & (SECINFO_OWNER)) {\n\t\tif (new_sd->owner_sid) {\n\t\t\tfinal_sd->owner_sid = talloc_memdup(mem_ctx, new_sd->owner_sid, sizeof(struct dom_sid));\n\t\t}\n\t\tfinal_sd->type |= new_sd->type & SEC_DESC_OWNER_DEFAULTED;\n\t}\n\telse if (old_sd) {\n\t\tif (old_sd->owner_sid) {\n\t\t\tfinal_sd->owner_sid = talloc_memdup(mem_ctx, old_sd->owner_sid, sizeof(struct dom_sid));\n\t\t}\n\t\tfinal_sd->type |= old_sd->type & SEC_DESC_OWNER_DEFAULTED;\n\t}\n\n\tif (sd_flags & (SECINFO_GROUP)) {\n\t\tif (new_sd->group_sid) {\n\t\t\tfinal_sd->group_sid = talloc_memdup(mem_ctx, new_sd->group_sid, sizeof(struct dom_sid));\n\t\t}\n\t\tfinal_sd->type |= new_sd->type & SEC_DESC_GROUP_DEFAULTED;\n\t} \n\telse if (old_sd) {\n\t\tif (old_sd->group_sid) {\n\t\t\tfinal_sd->group_sid = talloc_memdup(mem_ctx, old_sd->group_sid, sizeof(struct dom_sid));\n\t\t}\n\t\tfinal_sd->type |= old_sd->type & SEC_DESC_GROUP_DEFAULTED;\n\t}\n\n\tif (sd_flags & (SECINFO_SACL)) {\n\t\tfinal_sd->sacl = security_acl_dup(mem_ctx,new_sd->sacl);\n\t\tfinal_sd->type |= new_sd->type & (SEC_DESC_SACL_PRESENT |\n\t\t\tSEC_DESC_SACL_DEFAULTED|SEC_DESC_SACL_AUTO_INHERIT_REQ |\n\t\t\tSEC_DESC_SACL_AUTO_INHERITED|SEC_DESC_SACL_PROTECTED |\n\t\t\tSEC_DESC_SERVER_SECURITY);\n\t} \n\telse if (old_sd && old_sd->sacl) {\n\t\tfinal_sd->sacl = security_acl_dup(mem_ctx,old_sd->sacl);\n\t\tfinal_sd->type |= old_sd->type & (SEC_DESC_SACL_PRESENT |\n\t\t\tSEC_DESC_SACL_DEFAULTED|SEC_DESC_SACL_AUTO_INHERIT_REQ |\n\t\t\tSEC_DESC_SACL_AUTO_INHERITED|SEC_DESC_SACL_PROTECTED |\n\t\t\tSEC_DESC_SERVER_SECURITY);\n\t}\n\n\tif (sd_flags & (SECINFO_DACL)) {\n\t\tfinal_sd->dacl = security_acl_dup(mem_ctx,new_sd->dacl);\n\t\tfinal_sd->type |= new_sd->type & (SEC_DESC_DACL_PRESENT |\n\t\t\tSEC_DESC_DACL_DEFAULTED|SEC_DESC_DACL_AUTO_INHERIT_REQ |\n\t\t\tSEC_DESC_DACL_AUTO_INHERITED|SEC_DESC_DACL_PROTECTED |\n\t\t\tSEC_DESC_DACL_TRUSTED);\n\t} \n\telse if (old_sd && old_sd->dacl) {\n\t\tfinal_sd->dacl = security_acl_dup(mem_ctx,old_sd->dacl);\n\t\tfinal_sd->type |= old_sd->type & (SEC_DESC_DACL_PRESENT |\n\t\t\tSEC_DESC_DACL_DEFAULTED|SEC_DESC_DACL_AUTO_INHERIT_REQ |\n\t\t\tSEC_DESC_DACL_AUTO_INHERITED|SEC_DESC_DACL_PROTECTED |\n\t\t\tSEC_DESC_DACL_TRUSTED);\n\t}\n\t\/* not so sure about this *\/\n\tfinal_sd->type |= new_sd->type & SEC_DESC_RM_CONTROL_VALID;\n\treturn final_sd;\n}","target":0,"code_token_length":795,"total_token_length":1031,"max_tokens_setting":2048} +{"idx":162947,"func":"long VideoTrack::Seek(\n if (status < 0)\n return status;\n \n if (rate <= 0)\n return E_FILE_FORMAT_INVALID;\n }\n \n pos += size; \/\/ consume payload\n assert(pos <= stop);\n }\n \n assert(pos == stop);\n\n VideoTrack* const pTrack =\n new (std::nothrow) VideoTrack(pSegment, element_start, element_size);\n\n if (pTrack == NULL)\n return -1; \/\/ generic error\n\n const int status = info.Copy(pTrack->m_info);\n\n if (status) { \/\/ error\n delete pTrack;\n return status;\n }\n\n pTrack->m_width = width;\n pTrack->m_height = height;\n pTrack->m_rate = rate;\n\n pResult = pTrack;\n return 0; \/\/ success\n}\n\nbool VideoTrack::VetEntry(const BlockEntry* pBlockEntry) const {\n return Track::VetEntry(pBlockEntry) && pBlockEntry->GetBlock()->IsKey();\n}\n\nlong VideoTrack::Seek(long long time_ns, const BlockEntry*& pResult) const {\n const long status = GetFirst(pResult);\n\n if (status < 0) \/\/ buffer underflow, etc\n return status;\n\n assert(pResult);\n\n if (pResult->EOS())\n return 0;\n\n const Cluster* pCluster = pResult->GetCluster();\n assert(pCluster);\n assert(pCluster->GetIndex() >= 0);\n\n if (time_ns <= pResult->GetBlock()->GetTime(pCluster))\n return 0;\n\n Cluster** const clusters = m_pSegment->m_clusters;\n assert(clusters);\n\n const long count = m_pSegment->GetCount(); \/\/ loaded only, not pre-loaded\n assert(count > 0);\n\n Cluster** const i = clusters + pCluster->GetIndex();\n assert(i);\n assert(*i == pCluster);\n assert(pCluster->GetTime() <= time_ns);\n\n Cluster** const j = clusters + count;\n\n Cluster** lo = i;\n Cluster** hi = j;\n\n while (lo < hi) {\n \/\/ INVARIANT:\n \/\/[i, lo) <= time_ns\n \/\/[lo, hi) ?\n \/\/[hi, j) > time_ns\n\n Cluster** const mid = lo + (hi - lo) \/ 2;\n assert(mid < hi);\n\n pCluster = *mid;\n assert(pCluster);\n assert(pCluster->GetIndex() >= 0);\n assert(pCluster->GetIndex() == long(mid - m_pSegment->m_clusters));\n \n const long long t = pCluster->GetTime();\n \n if (t <= time_ns)\n lo = mid + 1;\n else\n hi = mid;\n \n assert(lo <= hi);\n }\n \n assert(lo == hi);\n assert(lo > i);\n assert(lo <= j);\n \n pCluster = *--lo;\n assert(pCluster);\n assert(pCluster->GetTime() <= time_ns);\n \n pResult = pCluster->GetEntry(this, time_ns);\n \n if ((pResult != 0) && !pResult->EOS()) \/\/ found a keyframe\n return 0;\n \n while (lo != i) {\n pCluster = *--lo;\n assert(pCluster);\n assert(pCluster->GetTime() <= time_ns);\n \n #if 0\n\n pResult = pCluster->GetMaxKey(this);\n #else\n pResult = pCluster->GetEntry(this, time_ns);\n #endif\n \n if ((pResult != 0) && !pResult->EOS())\n return 0;\n }\n\n \/\/ weird: we're on the first cluster, but no keyframe found\n \/\/ should never happen but we must return something anyway\n\n pResult = GetEOS();\n return 0;\n}\n\nlong long VideoTrack::GetWidth() const { return m_width; }\n\nlong long VideoTrack::GetHeight() const { return m_height; }\n\ndouble VideoTrack::GetFrameRate() const { return m_rate; }\n\nAudioTrack::AudioTrack(Segment* pSegment, long long element_start,\n long long element_size)\n : Track(pSegment, element_start, element_size) {}\n\nlong AudioTrack::Parse(Segment* pSegment, const Info& info,\n long long element_start, long long element_size,\n AudioTrack*& pResult) {\n if (pResult)\n return -1;\n\n if (info.type != Track::kAudio)\n return -1;\n\n IMkvReader* const pReader = pSegment->m_pReader;\n\n const Settings& s = info.settings;\n assert(s.start >= 0);\n assert(s.size >= 0);\n\n long long pos = s.start;\n assert(pos >= 0);\n\n const long long stop = pos + s.size;\n\n double rate = 8000.0; \/\/ MKV default\n long long channels = 1;\n long long bit_depth = 0;\n\n while (pos < stop) {\n long long id, size;\n\n long status = ParseElementHeader(pReader, pos, stop, id, size);\n\n if (status < 0) \/\/ error\n return status;\n\n if (id == 0x35) { \/\/ Sample Rate\n status = UnserializeFloat(pReader, pos, size, rate);\n\n if (status < 0)\n return status;\n\n if (rate <= 0)\n return E_FILE_FORMAT_INVALID;\n } else if (id == 0x1F) { \/\/ Channel Count\n channels = UnserializeUInt(pReader, pos, size);\n\n if (channels <= 0)\n return E_FILE_FORMAT_INVALID;\n } else if (id == 0x2264) { \/\/ Bit Depth\n bit_depth = UnserializeUInt(pReader, pos, size);\n\n if (bit_depth <= 0)\n return E_FILE_FORMAT_INVALID;\n }\n \n pos += size; \/\/ consume payload\n assert(pos <= stop);\n }\n \n assert(pos == stop);\n\n AudioTrack* const pTrack =\n new (std::nothrow) AudioTrack(pSegment, element_start, element_size);\n\n if (pTrack == NULL)\n return -1; \/\/ generic error\n\n const int status = info.Copy(pTrack->m_info);\n\n if (status) {\n delete pTrack;\n return status;\n }\n\n pTrack->m_rate = rate;\n pTrack->m_channels = channels;\n pTrack->m_bitDepth = bit_depth;\n\n pResult = pTrack;\n return 0; \/\/ success\n }\n","target":0,"code_token_length":1428,"total_token_length":1664,"max_tokens_setting":2048} +{"idx":88226,"func":"e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)\n{\n E1000State *s = qemu_get_nic_opaque(nc);\n PCIDevice *d = PCI_DEVICE(s);\n struct e1000_rx_desc desc;\n dma_addr_t base;\n unsigned int n, rdt;\n uint32_t rdh_start;\n uint16_t vlan_special = 0;\n uint8_t vlan_status = 0;\n uint8_t min_buf[MIN_BUF_SIZE];\n struct iovec min_iov;\n uint8_t *filter_buf = iov->iov_base;\n size_t size = iov_size(iov, iovcnt);\n size_t iov_ofs = 0;\n size_t desc_offset;\n size_t desc_size;\n size_t total_size;\n\n if (!e1000x_hw_rx_enabled(s->mac_reg)) {\n return -1;\n }\n\n if (timer_pending(s->flush_queue_timer)) {\n return 0;\n }\n\n \/* Pad to minimum Ethernet frame length *\/\n if (size < sizeof(min_buf)) {\n iov_to_buf(iov, iovcnt, 0, min_buf, size);\n memset(&min_buf[size], 0, sizeof(min_buf) - size);\n min_iov.iov_base = filter_buf = min_buf;\n min_iov.iov_len = size = sizeof(min_buf);\n iovcnt = 1;\n iov = &min_iov;\n } else if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) {\n \/* This is very unlikely, but may happen. *\/\n iov_to_buf(iov, iovcnt, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN);\n filter_buf = min_buf;\n }\n\n \/* Discard oversized packets if !LPE and !SBP. *\/\n if (e1000x_is_oversized(s->mac_reg, size)) {\n return size;\n }\n\n if (!receive_filter(s, filter_buf, size)) {\n return size;\n }\n\n if (e1000x_vlan_enabled(s->mac_reg) &&\n e1000x_is_vlan_packet(filter_buf, le16_to_cpu(s->mac_reg[VET]))) {\n vlan_special = cpu_to_le16(lduw_be_p(filter_buf + 14));\n iov_ofs = 4;\n if (filter_buf == iov->iov_base) {\n memmove(filter_buf + 4, filter_buf, 12);\n } else {\n iov_from_buf(iov, iovcnt, 4, filter_buf, 12);\n while (iov->iov_len <= iov_ofs) {\n iov_ofs -= iov->iov_len;\n iov++;\n }\n }\n vlan_status = E1000_RXD_STAT_VP;\n size -= 4;\n }\n\n rdh_start = s->mac_reg[RDH];\n desc_offset = 0;\n total_size = size + e1000x_fcs_len(s->mac_reg);\n if (!e1000_has_rxbufs(s, total_size)) {\n e1000_receiver_overrun(s, total_size);\n return -1;\n }\n do {\n desc_size = total_size - desc_offset;\n if (desc_size > s->rxbuf_size) {\n desc_size = s->rxbuf_size;\n }\n base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];\n pci_dma_read(d, base, &desc, sizeof(desc));\n desc.special = vlan_special;\n desc.status |= (vlan_status | E1000_RXD_STAT_DD);\n if (desc.buffer_addr) {\n if (desc_offset < size) {\n size_t iov_copy;\n hwaddr ba = le64_to_cpu(desc.buffer_addr);\n size_t copy_size = size - desc_offset;\n if (copy_size > s->rxbuf_size) {\n copy_size = s->rxbuf_size;\n }\n do {\n iov_copy = MIN(copy_size, iov->iov_len - iov_ofs);\n pci_dma_write(d, ba, iov->iov_base + iov_ofs, iov_copy);\n copy_size -= iov_copy;\n ba += iov_copy;\n iov_ofs += iov_copy;\n if (iov_ofs == iov->iov_len) {\n iov++;\n iov_ofs = 0;\n }\n } while (copy_size);\n }\n desc_offset += desc_size;\n desc.length = cpu_to_le16(desc_size);\n if (desc_offset >= total_size) {\n desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;\n } else {\n \/* Guest zeroing out status is not a hardware requirement.\n Clear EOP in case guest didn't do it. *\/\n desc.status &= ~E1000_RXD_STAT_EOP;\n }\n } else { \/\/ as per intel docs; skip descriptors with null buf addr\n DBGOUT(RX, \"Null RX descriptor!!\\n\");\n }\n pci_dma_write(d, base, &desc, sizeof(desc));\n\n if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])\n s->mac_reg[RDH] = 0;\n \/* see comment in start_xmit; same here *\/\n if (s->mac_reg[RDH] == rdh_start ||\n rdh_start >= s->mac_reg[RDLEN] \/ sizeof(desc)) {\n DBGOUT(RXERR, \"RDH wraparound @%x, RDT %x, RDLEN %x\\n\",\n rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);\n e1000_receiver_overrun(s, total_size);\n return -1;\n }\n } while (desc_offset < total_size);\n\n e1000x_update_rx_total_stats(s->mac_reg, size, total_size);\n\n n = E1000_ICS_RXT0;\n if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])\n rdt += s->mac_reg[RDLEN] \/ sizeof(desc);\n if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>\n s->rxbuf_min_shift)\n n |= E1000_ICS_RXDMT0;\n\n set_ics(s, 0, n);\n\n return size;\n}","target":0,"code_token_length":1428,"total_token_length":1664,"max_tokens_setting":2048} +{"idx":379033,"func":" *\/\nPHPAPI char *php_get_uname(char mode)\n{\n\tchar *php_uname;\n\tchar tmp_uname[256];\n#ifdef PHP_WIN32\n\tDWORD dwBuild=0;\n\tDWORD dwVersion = GetVersion();\n\tDWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));\n\tDWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));\n\tDWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;\n\tchar ComputerName[MAX_COMPUTERNAME_LENGTH + 1];\n\n\tGetComputerName(ComputerName, &dwSize);\n\n\tif (mode == 's') {\n\t\tphp_uname = \"Windows NT\";\n\t} else if (mode == 'r') {\n\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"%d.%d\", dwWindowsMajorVersion, dwWindowsMinorVersion);\n\t\tphp_uname = tmp_uname;\n\t} else if (mode == 'n') {\n\t\tphp_uname = ComputerName;\n\t} else if (mode == 'v') {\n\t\tchar *winver = php_get_windows_name();\n\t\tdwBuild = (DWORD)(HIWORD(dwVersion));\n\t\tif(winver == NULL) {\n\t\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"build %d\", dwBuild);\n\t\t} else {\n\t\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"build %d (%s)\", dwBuild, winver);\n\t\t}\n\t\tphp_uname = tmp_uname;\n\t\tif(winver) {\n\t\t\tefree(winver);\n\t\t}\n\t} else if (mode == 'm') {\n\t\tphp_get_windows_cpu(tmp_uname, sizeof(tmp_uname));\n\t\tphp_uname = tmp_uname;\n\t} else { \/* assume mode == 'a' *\/\n\t\tchar *winver = php_get_windows_name();\n\t\tchar wincpu[20];\n\n\t\tphp_get_windows_cpu(wincpu, sizeof(wincpu));\n\t\tdwBuild = (DWORD)(HIWORD(dwVersion));\n\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"%s %s %d.%d build %d (%s) %s\",\n\t\t\t\t \"Windows NT\", ComputerName,\n\t\t\t\t dwWindowsMajorVersion, dwWindowsMinorVersion, dwBuild, winver?winver:\"unknown\", wincpu);\n\t\tif(winver) {\n\t\t\tefree(winver);\n\t\t}\n\t\tphp_uname = tmp_uname;\n\t}\n#else\n#ifdef HAVE_SYS_UTSNAME_H\n\tstruct utsname buf;\n\tif (uname((struct utsname *)&buf) == -1) {\n\t\tphp_uname = PHP_UNAME;\n\t} else {\n#ifdef NETWARE\n\t\tif (mode == 's') {\n\t\t\tphp_uname = buf.sysname;\n\t\t} else if (mode == 'r') {\n\t\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"%d.%d.%d\",\n\t\t\t\t\t buf.netware_major, buf.netware_minor, buf.netware_revision);\n\t\t\tphp_uname = tmp_uname;\n\t\t} else if (mode == 'n') {\n\t\t\tphp_uname = buf.servername;\n\t\t} else if (mode == 'v') {\n\t\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"libc-%d.%d.%d #%d\",\n\t\t\t\t\t buf.libmajor, buf.libminor, buf.librevision, buf.libthreshold);\n\t\t\tphp_uname = tmp_uname;\n\t\t} else if (mode == 'm') {\n\t\t\tphp_uname = buf.machine;\n\t\t} else { \/* assume mode == 'a' *\/\n\t\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"%s %s %d.%d.%d libc-%d.%d.%d #%d %s\",\n\t\t\t\t\t buf.sysname, buf.servername,\n\t\t\t\t\t buf.netware_major, buf.netware_minor, buf.netware_revision,\n\t\t\t\t\t buf.libmajor, buf.libminor, buf.librevision, buf.libthreshold,\n\t\t\t\t\t buf.machine);\n\t\t\tphp_uname = tmp_uname;\n\t\t}\n#else\n\t\tif (mode == 's') {\n\t\t\tphp_uname = buf.sysname;\n\t\t} else if (mode == 'r') {\n\t\t\tphp_uname = buf.release;\n\t\t} else if (mode == 'n') {\n\t\t\tphp_uname = buf.nodename;\n\t\t} else if (mode == 'v') {\n\t\t\tphp_uname = buf.version;\n\t\t} else if (mode == 'm') {\n\t\t\tphp_uname = buf.machine;\n\t\t} else { \/* assume mode == 'a' *\/\n\t\t\tsnprintf(tmp_uname, sizeof(tmp_uname), \"%s %s %s %s %s\",\n\t\t\t\t\t buf.sysname, buf.nodename, buf.release, buf.version,\n\t\t\t\t\t buf.machine);\n\t\t\tphp_uname = tmp_uname;\n\t\t}\n#endif \/* NETWARE *\/\n\t}\n#else\n\tphp_uname = PHP_UNAME;\n#endif\n#endif\n\treturn estrdup(php_uname);","target":0,"code_token_length":1052,"total_token_length":1288,"max_tokens_setting":2048} +{"idx":197558,"func":"PHP_METHOD(Phar, convertToExecutable)\n{\n\tchar *ext = NULL;\n\tint is_data, ext_len = 0;\n\tphp_uint32 flags;\n\tzval *ret;\n\t\/* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) *\/\n\tlong format = 9021976, method = 9021976;\n\tPHAR_ARCHIVE_OBJECT();\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"|lls\", &format, &method, &ext, &ext_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (PHAR_G(readonly)) {\n\t\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,\n\t\t\t\"Cannot write out executable phar archive, phar is read-only\");\n\t\treturn;\n\t}\n\n\tswitch (format) {\n\t\tcase 9021976:\n\t\tcase PHAR_FORMAT_SAME: \/* null is converted to 0 *\/\n\t\t\t\/* by default, use the existing format *\/\n\t\t\tif (phar_obj->arc.archive->is_tar) {\n\t\t\t\tformat = PHAR_FORMAT_TAR;\n\t\t\t} else if (phar_obj->arc.archive->is_zip) {\n\t\t\t\tformat = PHAR_FORMAT_ZIP;\n\t\t\t} else {\n\t\t\t\tformat = PHAR_FORMAT_PHAR;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase PHAR_FORMAT_PHAR:\n\t\tcase PHAR_FORMAT_TAR:\n\t\tcase PHAR_FORMAT_ZIP:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,\n\t\t\t\t\"Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP\");\n\t\t\treturn;\n\t}\n\n\tswitch (method) {\n\t\tcase 9021976:\n\t\t\tflags = phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSION_MASK;\n\t\t\tbreak;\n\t\tcase 0:\n\t\t\tflags = PHAR_FILE_COMPRESSED_NONE;\n\t\t\tbreak;\n\t\tcase PHAR_ENT_COMPRESSED_GZ:\n\t\t\tif (format == PHAR_FORMAT_ZIP) {\n\t\t\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,\n\t\t\t\t\t\"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!PHAR_G(has_zlib)) {\n\t\t\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,\n\t\t\t\t\t\"Cannot compress entire archive with gzip, enable ext\/zlib in php.ini\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tflags = PHAR_FILE_COMPRESSED_GZ;\n\t\t\tbreak;\n\t\tcase PHAR_ENT_COMPRESSED_BZ2:\n\t\t\tif (format == PHAR_FORMAT_ZIP) {\n\t\t\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,\n\t\t\t\t\t\"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!PHAR_G(has_bz2)) {\n\t\t\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,\n\t\t\t\t\t\"Cannot compress entire archive with bz2, enable ext\/bz2 in php.ini\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tflags = PHAR_FILE_COMPRESSED_BZ2;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,\n\t\t\t\t\"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2\");\n\t\t\treturn;\n\t}\n\n\tis_data = phar_obj->arc.archive->is_data;\n\tphar_obj->arc.archive->is_data = 0;\n\tret = phar_convert_to_other(phar_obj->arc.archive, format, ext, flags TSRMLS_CC);\n\tphar_obj->arc.archive->is_data = is_data;\n\n\tif (ret) {\n\t\tRETURN_ZVAL(ret, 1, 1);\n\t} else {\n\t\tRETURN_NULL();\n\t}\n}\n","target":0,"code_token_length":852,"total_token_length":1088,"max_tokens_setting":2048} +{"idx":447390,"func":"int sldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len)\n{\n\tsize_t gwlen = 0, keylen = 0;\n\tint s;\n\tuint8_t gwtype;\n\tchar token[512];\n\tsldns_buffer strbuf;\n\tsldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str));\n\n\tif(*len < 3)\n\t\treturn LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;\n\t\/* precedence *\/\n\tif(sldns_bget_token(&strbuf, token, \"\\t\\n \", sizeof(token)) <= 0)\n\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,\n\t\t\tsldns_buffer_position(&strbuf));\n\trd[0] = (uint8_t)atoi(token);\n\t\/* gateway_type *\/\n\tif(sldns_bget_token(&strbuf, token, \"\\t\\n \", sizeof(token)) <= 0)\n\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,\n\t\t\tsldns_buffer_position(&strbuf));\n\trd[1] = (uint8_t)atoi(token);\n\tgwtype = rd[1];\n\t\/* algorithm *\/\n\tif(sldns_bget_token(&strbuf, token, \"\\t\\n \", sizeof(token)) <= 0)\n\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,\n\t\t\tsldns_buffer_position(&strbuf));\n\trd[2] = (uint8_t)atoi(token);\n\n\t\/* gateway *\/\n\tif(sldns_bget_token(&strbuf, token, \"\\t\\n \", sizeof(token)) <= 0)\n\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,\n\t\t\tsldns_buffer_position(&strbuf));\n\tif(gwtype == 0) {\n\t\t\/* NOGATEWAY *\/\n\t\tif(strcmp(token, \".\") != 0)\n\t\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,\n\t\t\t\tsldns_buffer_position(&strbuf));\n\t\tgwlen = 0;\n\t} else if(gwtype == 1) {\n\t\t\/* IP4 *\/\n\t\tgwlen = *len - 3;\n\t\ts = sldns_str2wire_a_buf(token, rd+3, &gwlen);\n\t\tif(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));\n\t} else if(gwtype == 2) {\n\t\t\/* IP6 *\/\n\t\tgwlen = *len - 3;\n\t\ts = sldns_str2wire_aaaa_buf(token, rd+3, &gwlen);\n\t\tif(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));\n\t} else if(gwtype == 3) {\n\t\t\/* DNAME *\/\n\t\tgwlen = *len - 3;\n\t\ts = sldns_str2wire_dname_buf(token, rd+3, &gwlen);\n\t\tif(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));\n\t} else {\n\t\t\/* unknown gateway type *\/\n\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,\n\t\t\tsldns_buffer_position(&strbuf));\n\t}\n\t\/* double check for size *\/\n\tif(*len < 3 + gwlen)\n\t\treturn RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,\n\t\t\tsldns_buffer_position(&strbuf));\n\n\t\/* publickey in remainder of strbuf *\/\n\tkeylen = *len - 3 - gwlen;\n\ts = sldns_str2wire_b64_buf((const char*)sldns_buffer_current(&strbuf),\n\t\trd+3+gwlen, &keylen);\n\tif(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));\n\n\t*len = 3 + gwlen + keylen;\n\treturn LDNS_WIREPARSE_ERR_OK;\n}","target":0,"code_token_length":803,"total_token_length":1039,"max_tokens_setting":2048} +{"idx":77211,"func":"kdc_make_s4u2self_rep(krb5_context context,\n krb5_keyblock *tgs_subkey,\n krb5_keyblock *tgs_session,\n krb5_pa_s4u_x509_user *req_s4u_user,\n krb5_kdc_rep *reply,\n krb5_enc_kdc_rep_part *reply_encpart)\n{\n krb5_error_code code;\n krb5_data *der_user_id = NULL, *der_s4u_x509_user = NULL;\n krb5_pa_s4u_x509_user rep_s4u_user;\n krb5_pa_data *pa;\n krb5_enctype enctype;\n krb5_keyusage usage;\n\n memset(&rep_s4u_user, 0, sizeof(rep_s4u_user));\n\n rep_s4u_user.user_id.nonce = req_s4u_user->user_id.nonce;\n rep_s4u_user.user_id.user = req_s4u_user->user_id.user;\n rep_s4u_user.user_id.options =\n req_s4u_user->user_id.options & KRB5_S4U_OPTS_USE_REPLY_KEY_USAGE;\n\n code = encode_krb5_s4u_userid(&rep_s4u_user.user_id, &der_user_id);\n if (code != 0)\n goto cleanup;\n\n if (req_s4u_user->user_id.options & KRB5_S4U_OPTS_USE_REPLY_KEY_USAGE)\n usage = KRB5_KEYUSAGE_PA_S4U_X509_USER_REPLY;\n else\n usage = KRB5_KEYUSAGE_PA_S4U_X509_USER_REQUEST;\n\n code = krb5_c_make_checksum(context, req_s4u_user->cksum.checksum_type,\n tgs_subkey != NULL ? tgs_subkey : tgs_session,\n usage, der_user_id, &rep_s4u_user.cksum);\n if (code != 0)\n goto cleanup;\n\n code = encode_krb5_pa_s4u_x509_user(&rep_s4u_user, &der_s4u_x509_user);\n if (code != 0)\n goto cleanup;\n\n \/* Add a padata element, stealing memory from der_s4u_x509_user. *\/\n code = alloc_pa_data(KRB5_PADATA_S4U_X509_USER, 0, &pa);\n if (code != 0)\n goto cleanup;\n pa->length = der_s4u_x509_user->length;\n pa->contents = (uint8_t *)der_s4u_x509_user->data;\n der_s4u_x509_user->data = NULL;\n \/* add_pa_data_element() claims pa on success or failure. *\/\n code = add_pa_data_element(&reply->padata, pa);\n if (code != 0)\n goto cleanup;\n\n if (tgs_subkey != NULL)\n enctype = tgs_subkey->enctype;\n else\n enctype = tgs_session->enctype;\n\n \/*\n * Owing to a bug in Windows, unkeyed checksums were used for older\n * enctypes, including rc4-hmac. A forthcoming workaround for this\n * includes the checksum bytes in the encrypted padata.\n *\/\n if ((req_s4u_user->user_id.options & KRB5_S4U_OPTS_USE_REPLY_KEY_USAGE) &&\n enctype_requires_etype_info_2(enctype) == FALSE) {\n code = alloc_pa_data(KRB5_PADATA_S4U_X509_USER,\n req_s4u_user->cksum.length +\n rep_s4u_user.cksum.length, &pa);\n if (code != 0)\n goto cleanup;\n memcpy(pa->contents,\n req_s4u_user->cksum.contents, req_s4u_user->cksum.length);\n memcpy(&pa->contents[req_s4u_user->cksum.length],\n rep_s4u_user.cksum.contents, rep_s4u_user.cksum.length);\n\n \/* add_pa_data_element() claims pa on success or failure. *\/\n code = add_pa_data_element(&reply_encpart->enc_padata, pa);\n if (code != 0)\n goto cleanup;\n }\n\ncleanup:\n if (rep_s4u_user.cksum.contents != NULL)\n krb5_free_checksum_contents(context, &rep_s4u_user.cksum);\n krb5_free_data(context, der_user_id);\n krb5_free_data(context, der_s4u_x509_user);\n\n return code;\n}","target":0,"code_token_length":990,"total_token_length":1226,"max_tokens_setting":2048} +{"idx":327611,"func":"static void mcf5208evb_init(MachineState *machine)\n\n{\n\n ram_addr_t ram_size = machine->ram_size;\n\n const char *cpu_model = machine->cpu_model;\n\n const char *kernel_filename = machine->kernel_filename;\n\n M68kCPU *cpu;\n\n CPUM68KState *env;\n\n int kernel_size;\n\n uint64_t elf_entry;\n\n hwaddr entry;\n\n qemu_irq *pic;\n\n MemoryRegion *address_space_mem = get_system_memory();\n\n MemoryRegion *ram = g_new(MemoryRegion, 1);\n\n MemoryRegion *sram = g_new(MemoryRegion, 1);\n\n\n\n if (!cpu_model) {\n\n cpu_model = \"m5208\";\n\n }\n\n cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));\n\n env = &cpu->env;\n\n\n\n \/* Initialize CPU registers. *\/\n\n env->vbr = 0;\n\n \/* TODO: Configure BARs. *\/\n\n\n\n \/* DRAM at 0x40000000 *\/\n\n memory_region_allocate_system_memory(ram, NULL, \"mcf5208.ram\", ram_size);\n\n memory_region_add_subregion(address_space_mem, 0x40000000, ram);\n\n\n\n \/* Internal SRAM. *\/\n\n memory_region_init_ram(sram, NULL, \"mcf5208.sram\", 16384, &error_fatal);\n\n memory_region_add_subregion(address_space_mem, 0x80000000, sram);\n\n\n\n \/* Internal peripherals. *\/\n\n pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu);\n\n\n\n mcf_uart_mm_init(0xfc060000, pic[26], serial_hds[0]);\n\n mcf_uart_mm_init(0xfc064000, pic[27], serial_hds[1]);\n\n mcf_uart_mm_init(0xfc068000, pic[28], serial_hds[2]);\n\n\n\n mcf5208_sys_init(address_space_mem, pic);\n\n\n\n if (nb_nics > 1) {\n\n fprintf(stderr, \"Too many NICs\\n\");\n\n exit(1);\n\n }\n\n if (nd_table[0].used) {\n\n mcf_fec_init(address_space_mem, &nd_table[0],\n\n 0xfc030000, pic + 36);\n\n }\n\n\n\n \/* 0xfc000000 SCM. *\/\n\n \/* 0xfc004000 XBS. *\/\n\n \/* 0xfc008000 FlexBus CS. *\/\n\n \/* 0xfc030000 FEC. *\/\n\n \/* 0xfc040000 SCM + Power management. *\/\n\n \/* 0xfc044000 eDMA. *\/\n\n \/* 0xfc048000 INTC. *\/\n\n \/* 0xfc058000 I2C. *\/\n\n \/* 0xfc05c000 QSPI. *\/\n\n \/* 0xfc060000 UART0. *\/\n\n \/* 0xfc064000 UART0. *\/\n\n \/* 0xfc068000 UART0. *\/\n\n \/* 0xfc070000 DMA timers. *\/\n\n \/* 0xfc080000 PIT0. *\/\n\n \/* 0xfc084000 PIT1. *\/\n\n \/* 0xfc088000 EPORT. *\/\n\n \/* 0xfc08c000 Watchdog. *\/\n\n \/* 0xfc090000 clock module. *\/\n\n \/* 0xfc0a0000 CCM + reset. *\/\n\n \/* 0xfc0a4000 GPIO. *\/\n\n \/* 0xfc0a8000 SDRAM controller. *\/\n\n\n\n \/* Load kernel. *\/\n\n if (!kernel_filename) {\n\n if (qtest_enabled()) {\n\n return;\n\n }\n\n fprintf(stderr, \"Kernel image must be specified\\n\");\n\n exit(1);\n\n }\n\n\n\n kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,\n\n NULL, NULL, 1, EM_68K, 0, 0);\n\n entry = elf_entry;\n\n if (kernel_size < 0) {\n\n kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,\n\n NULL, NULL);\n\n }\n\n if (kernel_size < 0) {\n\n kernel_size = load_image_targphys(kernel_filename, 0x40000000,\n\n ram_size);\n\n entry = 0x40000000;\n\n }\n\n if (kernel_size < 0) {\n\n fprintf(stderr, \"qemu: could not load kernel '%s'\\n\", kernel_filename);\n\n exit(1);\n\n }\n\n\n\n env->pc = entry;\n\n}\n","target":0,"code_token_length":1125,"total_token_length":1361,"max_tokens_setting":2048} +{"idx":407079,"func":"static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,\n imapstate instate)\n{\n CURLcode result = CURLE_OK;\n struct Curl_easy *data = conn->data;\n struct imap_conn *imapc = &conn->proto.imapc;\n struct pingpong *pp = &imapc->pp;\n const char *ptr = data->state.buffer;\n bool parsed = FALSE;\n curl_off_t size = 0;\n\n (void)instate; \/* no use for this yet *\/\n\n if(imapcode != '*') {\n Curl_pgrsSetDownloadSize(data, -1);\n state(conn, IMAP_STOP);\n return CURLE_REMOTE_FILE_NOT_FOUND; \/* TODO: Fix error code *\/\n }\n\n \/* Something like this is received \"* 1 FETCH (BODY[TEXT] {2021}\\r\" so parse\n the continuation data contained within the curly brackets *\/\n while(*ptr && (*ptr != '{'))\n ptr++;\n\n if(*ptr == '{') {\n char *endptr;\n if(!curlx_strtoofft(ptr + 1, &endptr, 10, &size)) {\n if(endptr - ptr > 1 && endptr[0] == '}' &&\n endptr[1] == '\\r' && endptr[2] == '\\0')\n parsed = TRUE;\n }\n }\n\n if(parsed) {\n infof(data, \"Found %\" CURL_FORMAT_CURL_OFF_TU \" bytes to download\\n\",\n size);\n Curl_pgrsSetDownloadSize(data, size);\n\n if(pp->cache) {\n \/* At this point there is a bunch of data in the header \"cache\" that is\n actually body content, send it as body and then skip it. Do note\n that there may even be additional \"headers\" after the body. *\/\n size_t chunk = pp->cache_size;\n\n if(chunk > (size_t)size)\n \/* The conversion from curl_off_t to size_t is always fine here *\/\n chunk = (size_t)size;\n\n if(!chunk) {\n \/* no size, we're done with the data *\/\n state(conn, IMAP_STOP);\n return CURLE_OK;\n }\n result = Curl_client_write(conn, CLIENTWRITE_BODY, pp->cache, chunk);\n if(result)\n return result;\n\n data->req.bytecount += chunk;\n\n infof(data, \"Written %\" CURL_FORMAT_CURL_OFF_TU\n \" bytes, %\" CURL_FORMAT_CURL_OFF_TU\n \" bytes are left for transfer\\n\", (curl_off_t)chunk,\n size - chunk);\n\n \/* Have we used the entire cache or just part of it?*\/\n if(pp->cache_size > chunk) {\n \/* Only part of it so shrink the cache to fit the trailing data *\/\n memmove(pp->cache, pp->cache + chunk, pp->cache_size - chunk);\n pp->cache_size -= chunk;\n }\n else {\n \/* Free the cache *\/\n Curl_safefree(pp->cache);\n\n \/* Reset the cache size *\/\n pp->cache_size = 0;\n }\n }\n\n if(data->req.bytecount == size)\n \/* The entire data is already transferred! *\/\n Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);\n else {\n \/* IMAP download *\/\n data->req.maxdownload = size;\n Curl_setup_transfer(conn, FIRSTSOCKET, size, FALSE, NULL, -1, NULL);\n }\n }\n else {\n \/* We don't know how to parse this line *\/\n failf(pp->conn->data, \"Failed to parse FETCH response.\");\n result = CURLE_WEIRD_SERVER_REPLY;\n }\n\n \/* End of DO phase *\/\n state(conn, IMAP_STOP);\n\n return result;\n}","target":0,"code_token_length":818,"total_token_length":1054,"max_tokens_setting":2048} +{"idx":69801,"func":"packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct packet_sock *po = pkt_sk(sk);\n\tint ret;\n\n\tif (level != SOL_PACKET)\n\t\treturn -ENOPROTOOPT;\n\n\tswitch (optname) {\n\tcase PACKET_ADD_MEMBERSHIP:\n\tcase PACKET_DROP_MEMBERSHIP:\n\t{\n\t\tstruct packet_mreq_max mreq;\n\t\tint len = optlen;\n\t\tmemset(&mreq, 0, sizeof(mreq));\n\t\tif (len < sizeof(struct packet_mreq))\n\t\t\treturn -EINVAL;\n\t\tif (len > sizeof(mreq))\n\t\t\tlen = sizeof(mreq);\n\t\tif (copy_from_user(&mreq, optval, len))\n\t\t\treturn -EFAULT;\n\t\tif (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address)))\n\t\t\treturn -EINVAL;\n\t\tif (optname == PACKET_ADD_MEMBERSHIP)\n\t\t\tret = packet_mc_add(sk, &mreq);\n\t\telse\n\t\t\tret = packet_mc_drop(sk, &mreq);\n\t\treturn ret;\n\t}\n\n\tcase PACKET_RX_RING:\n\tcase PACKET_TX_RING:\n\t{\n\t\tstruct tpacket_req req;\n\n\t\tif (optlen < sizeof(req))\n\t\t\treturn -EINVAL;\n\t\tif (pkt_sk(sk)->has_vnet_hdr)\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_user(&req, optval, sizeof(req)))\n\t\t\treturn -EFAULT;\n\t\treturn packet_set_ring(sk, &req, 0, optname == PACKET_TX_RING);\n\t}\n\tcase PACKET_COPY_THRESH:\n\t{\n\t\tint val;\n\n\t\tif (optlen != sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\n\t\tpkt_sk(sk)->copy_thresh = val;\n\t\treturn 0;\n\t}\n\tcase PACKET_VERSION:\n\t{\n\t\tint val;\n\n\t\tif (optlen != sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (po->rx_ring.pg_vec || po->tx_ring.pg_vec)\n\t\t\treturn -EBUSY;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\t\tswitch (val) {\n\t\tcase TPACKET_V1:\n\t\tcase TPACKET_V2:\n\t\t\tpo->tp_version = val;\n\t\t\treturn 0;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\tcase PACKET_RESERVE:\n\t{\n\t\tunsigned int val;\n\n\t\tif (optlen != sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (po->rx_ring.pg_vec || po->tx_ring.pg_vec)\n\t\t\treturn -EBUSY;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\t\tpo->tp_reserve = val;\n\t\treturn 0;\n\t}\n\tcase PACKET_LOSS:\n\t{\n\t\tunsigned int val;\n\n\t\tif (optlen != sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (po->rx_ring.pg_vec || po->tx_ring.pg_vec)\n\t\t\treturn -EBUSY;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\t\tpo->tp_loss = !!val;\n\t\treturn 0;\n\t}\n\tcase PACKET_AUXDATA:\n\t{\n\t\tint val;\n\n\t\tif (optlen < sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\n\t\tpo->auxdata = !!val;\n\t\treturn 0;\n\t}\n\tcase PACKET_ORIGDEV:\n\t{\n\t\tint val;\n\n\t\tif (optlen < sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\n\t\tpo->origdev = !!val;\n\t\treturn 0;\n\t}\n\tcase PACKET_VNET_HDR:\n\t{\n\t\tint val;\n\n\t\tif (sock->type != SOCK_RAW)\n\t\t\treturn -EINVAL;\n\t\tif (po->rx_ring.pg_vec || po->tx_ring.pg_vec)\n\t\t\treturn -EBUSY;\n\t\tif (optlen < sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\n\t\tpo->has_vnet_hdr = !!val;\n\t\treturn 0;\n\t}\n\tcase PACKET_TIMESTAMP:\n\t{\n\t\tint val;\n\n\t\tif (optlen != sizeof(val))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_user(&val, optval, sizeof(val)))\n\t\t\treturn -EFAULT;\n\n\t\tpo->tp_tstamp = val;\n\t\treturn 0;\n\t}\n\tdefault:\n\t\treturn -ENOPROTOOPT;\n\t}\n}","target":0,"code_token_length":985,"total_token_length":1221,"max_tokens_setting":2048} +{"idx":141007,"func":"static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur,\n\t\t struct idpair *idmap)\n{\n\tbool equal;\n\n\tif (!(rold->live & REG_LIVE_READ))\n\t\t\/* explored state didn't use this *\/\n\t\treturn true;\n\n\tequal = memcmp(rold, rcur, offsetof(struct bpf_reg_state, frameno)) == 0;\n\n\tif (rold->type == PTR_TO_STACK)\n\t\t\/* two stack pointers are equal only if they're pointing to\n\t\t * the same stack frame, since fp-8 in foo != fp-8 in bar\n\t\t *\/\n\t\treturn equal && rold->frameno == rcur->frameno;\n\n\tif (equal)\n\t\treturn true;\n\n\tif (rold->type == NOT_INIT)\n\t\t\/* explored state can't have used this *\/\n\t\treturn true;\n\tif (rcur->type == NOT_INIT)\n\t\treturn false;\n\tswitch (rold->type) {\n\tcase SCALAR_VALUE:\n\t\tif (rcur->type == SCALAR_VALUE) {\n\t\t\t\/* new val must satisfy old val knowledge *\/\n\t\t\treturn range_within(rold, rcur) &&\n\t\t\t tnum_in(rold->var_off, rcur->var_off);\n\t\t} else {\n\t\t\t\/* We're trying to use a pointer in place of a scalar.\n\t\t\t * Even if the scalar was unbounded, this could lead to\n\t\t\t * pointer leaks because scalars are allowed to leak\n\t\t\t * while pointers are not. We could make this safe in\n\t\t\t * special cases if root is calling us, but it's\n\t\t\t * probably not worth the hassle.\n\t\t\t *\/\n\t\t\treturn false;\n\t\t}\n\tcase PTR_TO_MAP_VALUE:\n\t\t\/* If the new min\/max\/var_off satisfy the old ones and\n\t\t * everything else matches, we are OK.\n\t\t * We don't care about the 'id' value, because nothing\n\t\t * uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL)\n\t\t *\/\n\t\treturn memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 &&\n\t\t range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_MAP_VALUE_OR_NULL:\n\t\t\/* a PTR_TO_MAP_VALUE could be safe to use as a\n\t\t * PTR_TO_MAP_VALUE_OR_NULL into the same map.\n\t\t * However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL-\n\t\t * checked, doing so could have affected others with the same\n\t\t * id, and we can't check for that because we lost the id when\n\t\t * we converted to a PTR_TO_MAP_VALUE.\n\t\t *\/\n\t\tif (rcur->type != PTR_TO_MAP_VALUE_OR_NULL)\n\t\t\treturn false;\n\t\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)))\n\t\t\treturn false;\n\t\t\/* Check our ids match any regs they're supposed to *\/\n\t\treturn check_ids(rold->id, rcur->id, idmap);\n\tcase PTR_TO_PACKET_META:\n\tcase PTR_TO_PACKET:\n\t\tif (rcur->type != rold->type)\n\t\t\treturn false;\n\t\t\/* We must have at least as much range as the old ptr\n\t\t * did, so that any accesses which were safe before are\n\t\t * still safe. This is true even if old range < old off,\n\t\t * since someone could have accessed through (ptr - k), or\n\t\t * even done ptr -= k in a register, to get a safe access.\n\t\t *\/\n\t\tif (rold->range > rcur->range)\n\t\t\treturn false;\n\t\t\/* If the offsets don't match, we can't trust our alignment;\n\t\t * nor can we be sure that we won't fall out of range.\n\t\t *\/\n\t\tif (rold->off != rcur->off)\n\t\t\treturn false;\n\t\t\/* id relations must be preserved *\/\n\t\tif (rold->id && !check_ids(rold->id, rcur->id, idmap))\n\t\t\treturn false;\n\t\t\/* new val must satisfy old val knowledge *\/\n\t\treturn range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_CTX:\n\tcase CONST_PTR_TO_MAP:\n\tcase PTR_TO_PACKET_END:\n\t\t\/* Only valid matches are exact, which memcmp() above\n\t\t * would have accepted\n\t\t *\/\n\tdefault:\n\t\t\/* Don't know what's going on, just say it's not safe *\/\n\t\treturn false;\n\t}\n\n\t\/* Shouldn't get here; if we do, say it's not safe *\/\n\tWARN_ON_ONCE(1);\n\treturn false;\n}","target":0,"code_token_length":986,"total_token_length":1222,"max_tokens_setting":2048} +{"idx":125781,"func":"kvp_get_ip_info(int family, char *if_name, int op,\n\t\t void *out_buffer, int length)\n{\n\tstruct ifaddrs *ifap;\n\tstruct ifaddrs *curp;\n\tint offset = 0;\n\tint sn_offset = 0;\n\tint error = 0;\n\tchar *buffer;\n\tstruct hv_kvp_ipaddr_value *ip_buffer;\n\tchar cidr_mask[5]; \/* \/xyz *\/\n\tint weight;\n\tint i;\n\tunsigned int *w;\n\tchar *sn_str;\n\tstruct sockaddr_in6 *addr6;\n\n\tif (op == KVP_OP_ENUMERATE) {\n\t\tbuffer = out_buffer;\n\t} else {\n\t\tip_buffer = out_buffer;\n\t\tbuffer = (char *)ip_buffer->ip_addr;\n\t\tip_buffer->addr_family = 0;\n\t}\n\t\/*\n\t * On entry into this function, the buffer is capable of holding the\n\t * maximum key value.\n\t *\/\n\n\tif (getifaddrs(&ifap)) {\n\t\tstrcpy(buffer, \"getifaddrs failed\\n\");\n\t\treturn HV_E_FAIL;\n\t}\n\n\tcurp = ifap;\n\twhile (curp != NULL) {\n\t\tif (curp->ifa_addr == NULL) {\n\t\t\tcurp = curp->ifa_next;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((if_name != NULL) &&\n\t\t\t(strncmp(curp->ifa_name, if_name, strlen(if_name)))) {\n\t\t\t\/*\n\t\t\t * We want info about a specific interface;\n\t\t\t * just continue.\n\t\t\t *\/\n\t\t\tcurp = curp->ifa_next;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/*\n\t\t * We only support two address families: AF_INET and AF_INET6.\n\t\t * If a family value of 0 is specified, we collect both\n\t\t * supported address families; if not we gather info on\n\t\t * the specified address family.\n\t\t *\/\n\t\tif ((((family != 0) &&\n\t\t\t (curp->ifa_addr->sa_family != family))) ||\n\t\t\t (curp->ifa_flags & IFF_LOOPBACK)) {\n\t\t\tcurp = curp->ifa_next;\n\t\t\tcontinue;\n\t\t}\n\t\tif ((curp->ifa_addr->sa_family != AF_INET) &&\n\t\t\t(curp->ifa_addr->sa_family != AF_INET6)) {\n\t\t\tcurp = curp->ifa_next;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (op == KVP_OP_GET_IP_INFO) {\n\t\t\t\/*\n\t\t\t * Gather info other than the IP address.\n\t\t\t * IP address info will be gathered later.\n\t\t\t *\/\n\t\t\tif (curp->ifa_addr->sa_family == AF_INET) {\n\t\t\t\tip_buffer->addr_family |= ADDR_FAMILY_IPV4;\n\t\t\t\t\/*\n\t\t\t\t * Get subnet info.\n\t\t\t\t *\/\n\t\t\t\terror = kvp_process_ip_address(\n\t\t\t\t\t\t\t curp->ifa_netmask,\n\t\t\t\t\t\t\t AF_INET,\n\t\t\t\t\t\t\t (char *)\n\t\t\t\t\t\t\t ip_buffer->sub_net,\n\t\t\t\t\t\t\t length,\n\t\t\t\t\t\t\t &sn_offset);\n\t\t\t\tif (error)\n\t\t\t\t\tgoto gather_ipaddr;\n\t\t\t} else {\n\t\t\t\tip_buffer->addr_family |= ADDR_FAMILY_IPV6;\n\n\t\t\t\t\/*\n\t\t\t\t * Get subnet info in CIDR format.\n\t\t\t\t *\/\n\t\t\t\tweight = 0;\n\t\t\t\tsn_str = (char *)ip_buffer->sub_net;\n\t\t\t\taddr6 = (struct sockaddr_in6 *)\n\t\t\t\t\tcurp->ifa_netmask;\n\t\t\t\tw = addr6->sin6_addr.s6_addr32;\n\n\t\t\t\tfor (i = 0; i < 4; i++)\n\t\t\t\t\tweight += hweight32(&w[i]);\n\n\t\t\t\tsprintf(cidr_mask, \"\/%d\", weight);\n\t\t\t\tif ((length - sn_offset) <\n\t\t\t\t\t(strlen(cidr_mask) + 1))\n\t\t\t\t\tgoto gather_ipaddr;\n\n\t\t\t\tif (sn_offset == 0)\n\t\t\t\t\tstrcpy(sn_str, cidr_mask);\n\t\t\t\telse\n\t\t\t\t\tstrcat(sn_str, cidr_mask);\n\t\t\t\tstrcat((char *)ip_buffer->sub_net, \";\");\n\t\t\t\tsn_offset += strlen(sn_str) + 1;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Collect other ip related configuration info.\n\t\t\t *\/\n\n\t\t\tkvp_get_ipconfig_info(if_name, ip_buffer);\n\t\t}\n\ngather_ipaddr:\n\t\terror = kvp_process_ip_address(curp->ifa_addr,\n\t\t\t\t\t\tcurp->ifa_addr->sa_family,\n\t\t\t\t\t\tbuffer,\n\t\t\t\t\t\tlength, &offset);\n\t\tif (error)\n\t\t\tgoto getaddr_done;\n\n\t\tcurp = curp->ifa_next;\n\t}\n\ngetaddr_done:\n\tfreeifaddrs(ifap);\n\treturn error;\n}","target":0,"code_token_length":930,"total_token_length":1166,"max_tokens_setting":2048} +{"idx":188298,"func":"static int state_machine(SSL *s, int server)\n{\n BUF_MEM *buf = NULL;\n unsigned long Time = (unsigned long)time(NULL);\n void (*cb) (const SSL *ssl, int type, int val) = NULL;\n OSSL_STATEM *st = &s->statem;\n int ret = -1;\n int ssret;\n\n if (st->state == MSG_FLOW_ERROR) {\n \/* Shouldn't have been called if we're already in the error state *\/\n return -1;\n }\n\n RAND_add(&Time, sizeof(Time), 0);\n ERR_clear_error();\n clear_sys_error();\n\n cb = get_callback(s);\n\n st->in_handshake++;\n if (!SSL_in_init(s) || SSL_in_before(s)) {\n if (!SSL_clear(s))\n return -1;\n }\n#ifndef OPENSSL_NO_SCTP\n if (SSL_IS_DTLS(s)) {\n \/*\n * Notify SCTP BIO socket to enter handshake mode and prevent stream\n * identifier other than 0. Will be ignored if no SCTP is used.\n *\/\n BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,\n st->in_handshake, NULL);\n }\n#endif\n\n#ifndef OPENSSL_NO_HEARTBEATS\n \/*\n * If we're awaiting a HeartbeatResponse, pretend we already got and\n * don't await it anymore, because Heartbeats don't make sense during\n * handshakes anyway.\n *\/\n if (s->tlsext_hb_pending) {\n if (SSL_IS_DTLS(s))\n dtls1_stop_timer(s);\n s->tlsext_hb_pending = 0;\n s->tlsext_hb_seq++;\n }\n#endif\n\n \/* Initialise state machine *\/\n\n if (st->state == MSG_FLOW_RENEGOTIATE) {\n s->renegotiate = 1;\n if (!server)\n s->ctx->stats.sess_connect_renegotiate++;\n }\n\n if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE) {\n if (st->state == MSG_FLOW_UNINITED) {\n st->hand_state = TLS_ST_BEFORE;\n }\n\n s->server = server;\n if (cb != NULL)\n cb(s, SSL_CB_HANDSHAKE_START, 1);\n\n if (SSL_IS_DTLS(s)) {\n if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00) &&\n (server || (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00))) {\n SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n goto end;\n }\n } else {\n if ((s->version >> 8) != SSL3_VERSION_MAJOR) {\n SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n goto end;\n }\n }\n\n if (!ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) {\n SSLerr(SSL_F_STATE_MACHINE, SSL_R_VERSION_TOO_LOW);\n goto end;\n }\n\n if (s->init_buf == NULL) {\n if ((buf = BUF_MEM_new()) == NULL) {\n goto end;\n }\n if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {\n goto end;\n }\n s->init_buf = buf;\n buf = NULL;\n }\n\n if (!ssl3_setup_buffers(s)) {\n goto end;\n }\n s->init_num = 0;\n\n \/*\n * Should have been reset by tls_process_finished, too.\n *\/\n s->s3->change_cipher_spec = 0;\n\n \/*\n * Ok, we now need to push on a buffering BIO ...but not with\n * SCTP\n *\/\n#ifndef OPENSSL_NO_SCTP\n if (!SSL_IS_DTLS(s) || !BIO_dgram_is_sctp(SSL_get_wbio(s)))\n#endif\n if (!ssl_init_wbio_buffer(s)) {\n goto end;\n }\n\n if (!server || st->state != MSG_FLOW_RENEGOTIATE) {\n if (!ssl3_init_finished_mac(s)) {\n ossl_statem_set_error(s);\n goto end;\n }\n }\n\n if (server) {\n if (st->state != MSG_FLOW_RENEGOTIATE) {\n s->ctx->stats.sess_accept++;\n } else if (!s->s3->send_connection_binding &&\n !(s->options &\n SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {\n \/*\n * Server attempting to renegotiate with client that doesn't\n * support secure renegotiation.\n *\/\n SSLerr(SSL_F_STATE_MACHINE,\n SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);\n ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n ossl_statem_set_error(s);\n goto end;\n } else {\n \/*\n * st->state == MSG_FLOW_RENEGOTIATE, we will just send a\n * HelloRequest\n *\/\n s->ctx->stats.sess_accept_renegotiate++;\n }\n } else {\n s->ctx->stats.sess_connect++;\n\n \/* mark client_random uninitialized *\/\n memset(s->s3->client_random, 0, sizeof(s->s3->client_random));\n s->hit = 0;\n\n s->s3->tmp.cert_request = 0;\n\n if (SSL_IS_DTLS(s)) {\n st->use_timer = 1;\n }\n }\n\n st->state = MSG_FLOW_WRITING;\n init_write_state_machine(s);\n st->read_state_first_init = 1;\n }\n\n while (st->state != MSG_FLOW_FINISHED) {\n if (st->state == MSG_FLOW_READING) {\n ssret = read_state_machine(s);\n if (ssret == SUB_STATE_FINISHED) {\n st->state = MSG_FLOW_WRITING;\n init_write_state_machine(s);\n } else {\n \/* NBIO or error *\/\n goto end;\n }\n } else if (st->state == MSG_FLOW_WRITING) {\n ssret = write_state_machine(s);\n if (ssret == SUB_STATE_FINISHED) {\n st->state = MSG_FLOW_READING;\n init_read_state_machine(s);\n } else if (ssret == SUB_STATE_END_HANDSHAKE) {\n st->state = MSG_FLOW_FINISHED;\n } else {\n \/* NBIO or error *\/\n goto end;\n }\n } else {\n \/* Error *\/\n ossl_statem_set_error(s);\n goto end;\n }\n }\n\n st->state = MSG_FLOW_UNINITED;\n ret = 1;\n\n end:\n st->in_handshake--;\n\n#ifndef OPENSSL_NO_SCTP\n if (SSL_IS_DTLS(s)) {\n \/*\n * Notify SCTP BIO socket to leave handshake mode and allow stream\n * identifier other than 0. Will be ignored if no SCTP is used.\n *\/\n BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,\n st->in_handshake, NULL);\n }\n#endif\n\n BUF_MEM_free(buf);\n if (cb != NULL) {\n if (server)\n cb(s, SSL_CB_ACCEPT_EXIT, ret);\n else\n cb(s, SSL_CB_CONNECT_EXIT, ret);\n }\n return ret;\n}\n","target":0,"code_token_length":1617,"total_token_length":1853,"max_tokens_setting":2048} +{"idx":276821,"func":"Document::Document(const DocumentInit& initializer, DocumentClassFlags documentClasses)\n : ContainerNode(0, CreateDocument)\n , TreeScope(*this)\n , m_hasNodesWithPlaceholderStyle(false)\n , m_evaluateMediaQueriesOnStyleRecalc(false)\n , m_pendingSheetLayout(NoLayoutWithPendingSheets)\n , m_frame(initializer.frame())\n , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0)\n , m_importsController(initializer.importsController())\n , m_contextFeatures(ContextFeatures::defaultSwitch())\n , m_wellFormed(false)\n , m_printing(false)\n , m_wasPrinting(false)\n , m_paginatedForScreen(false)\n , m_compatibilityMode(NoQuirksMode)\n , m_compatibilityModeLocked(false)\n , m_executeScriptsWaitingForResourcesTask(CancellableTaskFactory::create(this, &Document::executeScriptsWaitingForResources))\n , m_hasAutofocused(false)\n , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired)\n , m_domTreeVersion(++s_globalTreeVersion)\n , m_styleVersion(0)\n , m_listenerTypes(0)\n , m_mutationObserverTypes(0)\n , m_visitedLinkState(VisitedLinkState::create(*this))\n , m_visuallyOrdered(false)\n , m_readyState(Complete)\n , m_parsingState(FinishedParsing)\n , m_gotoAnchorNeededAfterStylesheetsLoad(false)\n , m_containsValidityStyleRules(false)\n , m_containsPlugins(false)\n , m_updateFocusAppearanceSelectionBahavior(SelectionBehaviorOnFocus::Reset)\n , m_ignoreDestructiveWriteCount(0)\n , m_markers(new DocumentMarkerController(*this))\n , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)\n , m_cssTarget(nullptr)\n , m_loadEventProgress(LoadEventNotRun)\n , m_startTime(currentTime())\n , m_scriptRunner(ScriptRunner::create(this))\n , m_xmlVersion(\"1.0\")\n , m_xmlStandalone(StandaloneUnspecified)\n , m_hasXMLDeclaration(0)\n , m_designMode(false)\n , m_isRunningExecCommand(false)\n , m_hasAnnotatedRegions(false)\n , m_annotatedRegionsDirty(false)\n , m_useSecureKeyboardEntryWhenActive(false)\n , m_documentClasses(documentClasses)\n , m_isViewSource(false)\n , m_sawElementsInKnownNamespaces(false)\n , m_isSrcdocDocument(false)\n , m_isMobileDocument(false)\n , m_layoutView(0)\n , m_contextDocument(initializer.contextDocument())\n , m_hasFullscreenSupplement(false)\n , m_loadEventDelayCount(0)\n , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)\n , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired)\n , m_documentTiming(*this)\n , m_writeRecursionIsTooDeep(false)\n , m_writeRecursionDepth(0)\n , m_taskRunner(MainThreadTaskRunner::create(this))\n , m_registrationContext(initializer.registrationContext(this))\n , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFired)\n , m_timeline(AnimationTimeline::create(this))\n , m_compositorPendingAnimations(new CompositorPendingAnimations())\n , m_templateDocumentHost(nullptr)\n , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsTimerFired)\n , m_timers(timerTaskRunner()->adoptClone())\n , m_hasViewportUnits(false)\n , m_parserSyncPolicy(AllowAsynchronousParsing)\n , m_nodeCount(0)\n{\n if (m_frame) {\n DCHECK(m_frame->page());\n provideContextFeaturesToDocumentFrom(*this, *m_frame->page());\n\n m_fetcher = m_frame->loader().documentLoader()->fetcher();\n FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);\n } else if (m_importsController) {\n m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr, this);\n } else {\n m_fetcher = ResourceFetcher::create(nullptr);\n }\n\n ViewportScrollCallback* applyScroll = nullptr;\n if (isInMainFrame()) {\n applyScroll = RootScrollerController::createViewportApplyScroll(\n frameHost()->topControls(), frameHost()->overscrollController());\n }\n m_rootScrollerController =\n RootScrollerController::create(*this, applyScroll);\n\n if (initializer.shouldSetURL())\n setURL(initializer.url());\n\n initSecurityContext(initializer);\n initDNSPrefetch();\n\n InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter);\n\n m_lifecycle.advanceTo(DocumentLifecycle::Inactive);\n\n m_styleEngine = StyleEngine::create(*this);\n\n DCHECK(!parentDocument() || !parentDocument()->activeDOMObjectsAreSuspended());\n\n#ifndef NDEBUG\n liveDocumentSet().add(this);\n#endif\n}\n","target":0,"code_token_length":1071,"total_token_length":1307,"max_tokens_setting":2048} +{"idx":178071,"func":"static unsigned inflateHuffmanBlock(ucvector* out, const unsigned char* in, size_t* bp,\n size_t* pos, size_t inlength, unsigned btype)\n{\n unsigned error = 0;\n HuffmanTree tree_ll; \/*the huffman tree for literal and length codes*\/\n HuffmanTree tree_d; \/*the huffman tree for distance codes*\/\n size_t inbitlength = inlength * 8;\n\n HuffmanTree_init(&tree_ll);\n HuffmanTree_init(&tree_d);\n\n if(btype == 1)\n {\n error = getTreeInflateFixed(&tree_ll, &tree_d);\n if (error)\n {\n HuffmanTree_cleanup(&tree_ll);\n HuffmanTree_cleanup(&tree_d);\n return error;\n }\n }\n else if(btype == 2) error = getTreeInflateDynamic(&tree_ll, &tree_d, in, bp, inlength);\n\n while(!error) \/*decode all symbols until end reached, breaks at end code*\/\n {\n \/*code_ll is literal, length or end code*\/\n unsigned code_ll = huffmanDecodeSymbol(in, bp, &tree_ll, inbitlength);\n if(code_ll <= 255) \/*literal symbol*\/\n {\n \/*ucvector_push_back would do the same, but for some reason the two lines below run 10% faster*\/\n if(!ucvector_resize(out, (*pos) + 1)) ERROR_BREAK(83 \/*alloc fail*\/);\n out->data[*pos] = (unsigned char)code_ll;\n (*pos)++;\n }\n else if(code_ll >= FIRST_LENGTH_CODE_INDEX && code_ll <= LAST_LENGTH_CODE_INDEX) \/*length code*\/\n {\n unsigned code_d, distance;\n unsigned numextrabits_l, numextrabits_d; \/*extra bits for length and distance*\/\n size_t start, forward, backward, length;\n\n \/*part 1: get length base*\/\n length = LENGTHBASE[code_ll - FIRST_LENGTH_CODE_INDEX];\n\n \/*part 2: get extra bits and add the value of that to length*\/\n numextrabits_l = LENGTHEXTRA[code_ll - FIRST_LENGTH_CODE_INDEX];\n if(*bp >= inbitlength) ERROR_BREAK(51); \/*error, bit pointer will jump past memory*\/\n length += readBitsFromStream(bp, in, numextrabits_l);\n\n \/*part 3: get distance code*\/\n code_d = huffmanDecodeSymbol(in, bp, &tree_d, inbitlength);\n if(code_d > 29)\n {\n if(code_ll == (unsigned)(-1)) \/*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*\/\n {\n \/*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol\n (10=no endcode, 11=wrong jump outside of tree)*\/\n error = (*bp) > inlength * 8 ? 10 : 11;\n }\n else error = 18; \/*error: invalid distance code (30-31 are never used)*\/\n break;\n }\n distance = DISTANCEBASE[code_d];\n\n \/*part 4: get extra bits from distance*\/\n numextrabits_d = DISTANCEEXTRA[code_d];\n if(*bp >= inbitlength) ERROR_BREAK(51); \/*error, bit pointer will jump past memory*\/\n\n distance += readBitsFromStream(bp, in, numextrabits_d);\n\n \/*part 5: fill in all the out[n] values based on the length and dist*\/\n start = (*pos);\n if(distance > start) ERROR_BREAK(52); \/*too long backward distance*\/\n backward = start - distance;\n\n if(!ucvector_resize(out, (*pos) + length)) ERROR_BREAK(83 \/*alloc fail*\/);\n for(forward = 0; forward < length; forward++)\n {\n out->data[(*pos)] = out->data[backward];\n (*pos)++;\n backward++;\n if(backward >= start) backward = start - distance;\n }\n }\n else if(code_ll == 256)\n {\n break; \/*end code, break the loop*\/\n }\n else \/*if(code == (unsigned)(-1))*\/ \/*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*\/\n {\n \/*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol\n (10=no endcode, 11=wrong jump outside of tree)*\/\n error = (*bp) > inlength * 8 ? 10 : 11;\n break;\n }\n }\n\n HuffmanTree_cleanup(&tree_ll);\n HuffmanTree_cleanup(&tree_d);\n\n return error;\n}\n","target":0,"code_token_length":1025,"total_token_length":1261,"max_tokens_setting":2048} +{"idx":4166,"func":"static void tw5864_handle_frame(struct tw5864_h264_frame *frame)\n{\n#define SKIP_VLCBUF_BYTES 3\n\tstruct tw5864_input *input = frame->input;\n\tstruct tw5864_dev *dev = input->root;\n\tstruct tw5864_buf *vb;\n\tstruct vb2_v4l2_buffer *v4l2_buf;\n\tint frame_len = frame->vlc_len - SKIP_VLCBUF_BYTES;\n\tu8 *dst = input->buf_cur_ptr;\n\tu8 tail_mask, vlc_mask = 0;\n\tint i;\n\tu8 vlc_first_byte = ((u8 *)(frame->vlc.addr + SKIP_VLCBUF_BYTES))[0];\n\tunsigned long flags;\n\tint zero_run;\n\tu8 *src;\n\tu8 *src_end;\n\n#ifdef DEBUG\n\tif (frame->checksum !=\n\t tw5864_vlc_checksum((u32 *)frame->vlc.addr, frame_len))\n\t\tdev_err(&dev->pci->dev,\n\t\t\t\"Checksum of encoded frame doesn't match!\\n\");\n#endif\n\n\tspin_lock_irqsave(&input->slock, flags);\n\tvb = input->vb;\n\tinput->vb = NULL;\n\tspin_unlock_irqrestore(&input->slock, flags);\n\n\tv4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);\n\n\tif (!vb) { \/* Gone because of disabling *\/\n\t\tdev_dbg(&dev->pci->dev, \"vb is empty, dropping frame\\n\");\n\t\treturn;\n\t}\n\n\t\/*\n\t * Check for space.\n\t * Mind the overhead of startcode emulation prevention.\n\t *\/\n\tif (input->buf_cur_space_left < frame_len * 5 \/ 4) {\n\t\tdev_err_once(&dev->pci->dev,\n\t\t\t \"Left space in vb2 buffer, %d bytes, is less than considered safely enough to put frame of length %d. Dropping this frame.\\n\",\n\t\t\t input->buf_cur_space_left, frame_len);\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < 8 - input->tail_nb_bits; i++)\n\t\tvlc_mask |= 1 << i;\n\ttail_mask = (~vlc_mask) & 0xff;\n\n\tdst[0] = (input->tail & tail_mask) | (vlc_first_byte & vlc_mask);\n\tframe_len--;\n\tdst++;\n\n\t\/* H.264 startcode emulation prevention *\/\n\tsrc = frame->vlc.addr + SKIP_VLCBUF_BYTES + 1;\n\tsrc_end = src + frame_len;\n\tzero_run = 0;\n\tfor (; src < src_end; src++) {\n\t\tif (zero_run < 2) {\n\t\t\tif (*src == 0)\n\t\t\t\t++zero_run;\n\t\t\telse\n\t\t\t\tzero_run = 0;\n\t\t} else {\n\t\t\tif ((*src & ~0x03) == 0)\n\t\t\t\t*dst++ = 0x03;\n\t\t\tzero_run = *src == 0;\n\t\t}\n\t\t*dst++ = *src;\n\t}\n\n\tvb2_set_plane_payload(&vb->vb.vb2_buf, 0,\n\t\t\t dst - (u8 *)vb2_plane_vaddr(&vb->vb.vb2_buf, 0));\n\n\tvb->vb.vb2_buf.timestamp = frame->timestamp;\n\tv4l2_buf->field = V4L2_FIELD_INTERLACED;\n\tv4l2_buf->sequence = frame->seqno;\n\n\t\/* Check for motion flags *\/\n\tif (frame->gop_seqno \/* P-frame *\/ &&\n\t tw5864_is_motion_triggered(frame)) {\n\t\tstruct v4l2_event ev = {\n\t\t\t.type = V4L2_EVENT_MOTION_DET,\n\t\t\t.u.motion_det = {\n\t\t\t\t.flags = V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ,\n\t\t\t\t.frame_sequence = v4l2_buf->sequence,\n\t\t\t},\n\t\t};\n\n\t\tv4l2_event_queue(&input->vdev, &ev);\n\t}\n\n\tvb2_buffer_done(&vb->vb.vb2_buf, VB2_BUF_STATE_DONE);\n}","target":1,"code_token_length":861,"total_token_length":1097,"max_tokens_setting":2048} +{"idx":344036,"func":"static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name)\n{\n\tunsigned upper_length;\n\tint len, type, optlen;\n\tchar *dest, *ret;\n\n\t\/* option points to OPT_DATA, need to go back to get OPT_LEN *\/\n\tlen = option[-OPT_DATA + OPT_LEN];\n\n\ttype = optflag->flags & OPTION_TYPE_MASK;\n\toptlen = dhcp_option_lengths[type];\n\tupper_length = len_of_option_as_string[type]\n\t\t* ((unsigned)(len + optlen - 1) \/ (unsigned)optlen);\n\n\tdest = ret = xmalloc(upper_length + strlen(opt_name) + 2);\n\tdest += sprintf(ret, \"%s=\", opt_name);\n\n\twhile (len >= optlen) {\n\t\tswitch (type) {\n\t\tcase OPTION_IP:\n\t\tcase OPTION_IP_PAIR:\n\t\t\tdest += sprint_nip(dest, \"\", option);\n\t\t\tif (type == OPTION_IP)\n\t\t\t\tbreak;\n\t\t\tdest += sprint_nip(dest, \"\/\", option + 4);\n\t\t\tbreak;\n\/\/\t\tcase OPTION_BOOLEAN:\n\/\/\t\t\tdest += sprintf(dest, *option ? \"yes\" : \"no\");\n\/\/\t\t\tbreak;\n\t\tcase OPTION_U8:\n\t\t\tdest += sprintf(dest, \"%u\", *option);\n\t\t\tbreak;\n\/\/\t\tcase OPTION_S16:\n\t\tcase OPTION_U16: {\n\t\t\tuint16_t val_u16;\n\t\t\tmove_from_unaligned16(val_u16, option);\n\t\t\tdest += sprintf(dest, \"%u\", ntohs(val_u16));\n\t\t\tbreak;\n\t\t}\n\t\tcase OPTION_S32:\n\t\tcase OPTION_U32: {\n\t\t\tuint32_t val_u32;\n\t\t\tmove_from_unaligned32(val_u32, option);\n\t\t\tdest += sprintf(dest, type == OPTION_U32 ? \"%lu\" : \"%ld\", (unsigned long) ntohl(val_u32));\n\t\t\tbreak;\n\t\t}\n\t\t\/* Note: options which use 'return' instead of 'break'\n\t\t * (for example, OPTION_STRING) skip the code which handles\n\t\t * the case of list of options.\n\t\t *\/\n\t\tcase OPTION_STRING:\n\t\t\tmemcpy(dest, option, len);\n\t\t\tdest[len] = '\\0';\n\t\t\treturn ret;\n\t\tcase OPTION_STATIC_ROUTES: {\n\t\t\t\/* Option binary format:\n\t\t\t * mask [one byte, 0..32]\n\t\t\t * ip [big endian, 0..4 bytes depending on mask]\n\t\t\t * router [big endian, 4 bytes]\n\t\t\t * may be repeated\n\t\t\t *\n\t\t\t * We convert it to a string \"IP\/MASK ROUTER IP2\/MASK2 ROUTER2\"\n\t\t\t *\/\n\t\t\tconst char *pfx = \"\";\n\n\t\t\twhile (len >= 1 + 4) { \/* mask + 0-byte ip + router *\/\n\t\t\t\tuint32_t nip;\n\t\t\t\tuint8_t *p;\n\t\t\t\tunsigned mask;\n\t\t\t\tint bytes;\n\n\t\t\t\tmask = *option++;\n\t\t\t\tif (mask > 32)\n\t\t\t\t\tbreak;\n\t\t\t\tlen--;\n\n\t\t\t\tnip = 0;\n\t\t\t\tp = (void*) &nip;\n\t\t\t\tbytes = (mask + 7) \/ 8; \/* 0 -> 0, 1..8 -> 1, 9..16 -> 2 etc *\/\n\t\t\t\twhile (--bytes >= 0) {\n\t\t\t\t\t*p++ = *option++;\n\t\t\t\t\tlen--;\n\t\t\t\t}\n\t\t\t\tif (len < 4)\n\t\t\t\t\tbreak;\n\n\t\t\t\t\/* print ip\/mask *\/\n\t\t\t\tdest += sprint_nip(dest, pfx, (void*) &nip);\n\t\t\t\tpfx = \" \";\n\t\t\t\tdest += sprintf(dest, \"\/%u \", mask);\n\t\t\t\t\/* print router *\/\n\t\t\t\tdest += sprint_nip(dest, \"\", option);\n\t\t\t\toption += 4;\n\t\t\t\tlen -= 4;\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}\n\t\tcase OPTION_6RD:\n\t\t\t\/* Option binary format (see RFC 5969):\n\t\t\t * 0 1 2 3\n\t\t\t * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n\t\t\t * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\t\t\t * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |\n\t\t\t * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\t\t\t * | 6rdPrefix |\n\t\t\t * ... (16 octets) ...\n\t\t\t * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\t\t\t * ... 6rdBRIPv4Address(es) ...\n\t\t\t * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\t\t\t * We convert it to a string\n\t\t\t * \"IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address...\"\n\t\t\t *\n\t\t\t * Sanity check: ensure that our length is at least 22 bytes, that\n\t\t\t * IPv4MaskLen <= 32,\n\t\t\t * 6rdPrefixLen <= 128,\n\t\t\t * 6rdPrefixLen + (32 - IPv4MaskLen) <= 128\n\t\t\t * (2nd condition need no check - it follows from 1st and 3rd).\n\t\t\t * Else, return envvar with empty value (\"optname=\")\n\t\t\t *\/\n\t\t\tif (len >= (1 + 1 + 16 + 4)\n\t\t\t && option[0] <= 32\n\t\t\t && (option[1] + 32 - option[0]) <= 128\n\t\t\t) {\n\t\t\t\t\/* IPv4MaskLen *\/\n\t\t\t\tdest += sprintf(dest, \"%u \", *option++);\n\t\t\t\t\/* 6rdPrefixLen *\/\n\t\t\t\tdest += sprintf(dest, \"%u \", *option++);\n\t\t\t\t\/* 6rdPrefix *\/\n\t\t\t\tdest += sprint_nip6(dest, \/* \"\", *\/ option);\n\t\t\t\toption += 16;\n\t\t\t\tlen -= 1 + 1 + 16 + 4;\n\t\t\t\t\/* \"+ 4\" above corresponds to the length of IPv4 addr\n\t\t\t\t * we consume in the loop below *\/\n\t\t\t\twhile (1) {\n\t\t\t\t\t\/* 6rdBRIPv4Address(es) *\/\n\t\t\t\t\tdest += sprint_nip(dest, \" \", option);\n\t\t\t\t\toption += 4;\n\t\t\t\t\tlen -= 4; \/* do we have yet another 4+ bytes? *\/\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tbreak; \/* no *\/\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn ret;\n#if ENABLE_FEATURE_UDHCP_RFC3397\n\t\tcase OPTION_DNS_STRING:\n\t\t\t\/* unpack option into dest; use ret for prefix (i.e., \"optname=\") *\/\n\t\t\tdest = dname_dec(option, len, ret);\n\t\t\tif (dest) {\n\t\t\t\tfree(ret);\n\t\t\t\treturn dest;\n\t\t\t}\n\t\t\t\/* error. return \"optname=\" string *\/\n\t\t\treturn ret;\n\t\tcase OPTION_SIP_SERVERS:\n\t\t\t\/* Option binary format:\n\t\t\t * type: byte\n\t\t\t * type=0: domain names, dns-compressed\n\t\t\t * type=1: IP addrs\n\t\t\t *\/\n\t\t\toption++;\n\t\t\tlen--;\n\t\t\tif (option[-1] == 0) {\n\t\t\t\tdest = dname_dec(option, len, ret);\n\t\t\t\tif (dest) {\n\t\t\t\t\tfree(ret);\n\t\t\t\t\treturn dest;\n\t\t\t\t}\n\t\t\t} else\n\t\t\tif (option[-1] == 1) {\n\t\t\t\tconst char *pfx = \"\";\n\t\t\t\twhile (1) {\n\t\t\t\t\tlen -= 4;\n\t\t\t\t\tif (len < 0)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdest += sprint_nip(dest, pfx, option);\n\t\t\t\t\tpfx = \" \";\n\t\t\t\t\toption += 4;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n#endif\n\t\t} \/* switch *\/\n\n\t\t\/* If we are here, try to format any remaining data\n\t\t * in the option as another, similarly-formatted option\n\t\t *\/\n\t\toption += optlen;\n\t\tlen -= optlen;\n\/\/ TODO: it can be a list only if (optflag->flags & OPTION_LIST).\n\/\/ Should we bail out\/warn if we see multi-ip option which is\n\/\/ not allowed to be such (for example, DHCP_BROADCAST)? -\n\t\tif (len < optlen \/* || !(optflag->flags & OPTION_LIST) *\/)\n\t\t\tbreak;\n\t\t*dest++ = ' ';\n\t\t*dest = '\\0';\n\t} \/* while *\/\n\n\treturn ret;\n}","target":1,"code_token_length":1811,"total_token_length":2047,"max_tokens_setting":2048} +{"idx":242498,"func":"int ChromeBrowserMainParts::PreCreateThreadsImpl() {\n TRACE_EVENT0(\"startup\", \"ChromeBrowserMainParts::PreCreateThreadsImpl\")\n run_message_loop_ = false;\n#if !defined(OS_ANDROID)\n chrome::MaybeShowInvalidUserDataDirWarningDialog();\n#endif \/\/ !defined(OS_ANDROID)\n if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_))\n return chrome::RESULT_CODE_MISSING_DATA;\n\n MediaCaptureDevicesDispatcher::GetInstance();\n\n#if !defined(OS_ANDROID)\n process_singleton_.reset(new ChromeProcessSingleton(\n user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback)));\n\n first_run::IsChromeFirstRun();\n#endif \/\/ !defined(OS_ANDROID)\n\n scoped_refptr local_state_task_runner =\n JsonPrefStore::GetTaskRunnerForFile(\n base::FilePath(chrome::kLocalStorePoolName),\n BrowserThread::GetBlockingPool());\n\n {\n TRACE_EVENT0(\"startup\",\n \"ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl\");\n browser_process_.reset(new BrowserProcessImpl(local_state_task_runner.get(),\n parsed_command_line()));\n }\n\n if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) {\n TRACE_EVENT0(\"startup\",\n \"ChromeBrowserMainParts::PreCreateThreadsImpl:InitProfiling\");\n std::string flag =\n parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling);\n tracked_objects::ThreadData::Status status =\n tracked_objects::ThreadData::PROFILING_ACTIVE;\n if (flag.compare(\"0\") != 0)\n status = tracked_objects::ThreadData::DEACTIVATED;\n tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);\n }\n\n local_state_ = InitializeLocalState(\n local_state_task_runner.get(), parsed_command_line());\n\n#if !defined(OS_ANDROID)\n master_prefs_.reset(new first_run::MasterPrefs);\n browser_creator_.reset(new StartupBrowserCreator);\n chrome::UMABrowsingActivityObserver::Init();\n#endif \/\/ !defined(OS_ANDROID)\n\n#if !defined(OS_CHROMEOS)\n {\n TRACE_EVENT0(\"startup\",\n \"ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags\");\n about_flags::PrefServiceFlagsStorage flags_storage_(\n g_browser_process->local_state());\n about_flags::ConvertFlagsToSwitches(&flags_storage_,\n base::CommandLine::ForCurrentProcess(),\n about_flags::kAddSentinels);\n }\n#endif \/\/ !defined(OS_CHROMEOS)\n\n local_state_->UpdateCommandLinePrefStore(\n new CommandLinePrefStore(base::CommandLine::ForCurrentProcess()));\n\n crash_keys::SetSwitchesFromCommandLine(\n base::CommandLine::ForCurrentProcess());\n\n#if defined(OS_MACOSX)\n std::string locale =\n parameters().ui_task ? \"en-US\" : l10n_util::GetLocaleOverride();\n browser_process_->SetApplicationLocale(locale);\n#else\n const std::string locale =\n local_state_->GetString(prefs::kApplicationLocale);\n\n\n TRACE_EVENT_BEGIN0(\"startup\",\n \"ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle\");\n const std::string loaded_locale =\n ui::ResourceBundle::InitSharedInstanceWithLocale(\n locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);\n TRACE_EVENT_END0(\"startup\",\n \"ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle\");\n\n if (loaded_locale.empty() &&\n !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) {\n ShowMissingLocaleMessageBox();\n return chrome::RESULT_CODE_MISSING_DATA;\n }\n CHECK(!loaded_locale.empty()) << \"Locale could not be found for \" << locale;\n browser_process_->SetApplicationLocale(loaded_locale);\n\n {\n TRACE_EVENT0(\"startup\",\n \"ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack\");\n base::FilePath resources_pack_path;\n PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);\n#if defined(OS_ANDROID)\n ui::LoadMainAndroidPackFile(\"assets\/resources.pak\", resources_pack_path);\n#else\n ResourceBundle::GetSharedInstance().AddDataPackFromPath(\n resources_pack_path, ui::SCALE_FACTOR_NONE);\n#endif \/\/ defined(OS_ANDROID)\n }\n#endif \/\/ defined(OS_MACOSX)\n\n#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)\n if (first_run::IsChromeFirstRun()) {\n first_run::ProcessMasterPreferencesResult pmp_result =\n first_run::ProcessMasterPreferences(user_data_dir_,\n master_prefs_.get());\n if (pmp_result == first_run::EULA_EXIT_NOW)\n return chrome::RESULT_CODE_EULA_REFUSED;\n\n if (!parsed_command_line().HasSwitch(switches::kApp) &&\n !parsed_command_line().HasSwitch(switches::kAppId) &&\n !parsed_command_line().HasSwitch(switches::kShowAppList)) {\n AddFirstRunNewTabs(browser_creator_.get(), master_prefs_->new_tabs);\n }\n\n\n if (!master_prefs_->variations_seed.empty() ||\n !master_prefs_->compressed_variations_seed.empty()) {\n if (!master_prefs_->variations_seed.empty()) {\n local_state_->SetString(chrome_variations::prefs::kVariationsSeed,\n master_prefs_->variations_seed);\n }\n if (!master_prefs_->compressed_variations_seed.empty()) {\n local_state_->SetString(\n chrome_variations::prefs::kVariationsCompressedSeed,\n master_prefs_->compressed_variations_seed);\n }\n if (!master_prefs_->variations_seed_signature.empty()) {\n local_state_->SetString(\n chrome_variations::prefs::kVariationsSeedSignature,\n master_prefs_->variations_seed_signature);\n }\n local_state_->SetInt64(chrome_variations::prefs::kVariationsSeedDate,\n base::Time::Now().ToInternalValue());\n }\n \n if (!master_prefs_->suppress_default_browser_prompt_for_version.empty()) {\n local_state_->SetString(\n prefs::kBrowserSuppressDefaultBrowserPrompt,\n master_prefs_->suppress_default_browser_prompt_for_version);\n }\n\n#if defined(OS_WIN)\n if (!master_prefs_->welcome_page_on_os_upgrade_enabled)\n local_state_->SetBoolean(prefs::kWelcomePageOnOSUpgradeEnabled, false);\n#endif\n }\n#endif \/\/ !defined(OS_ANDROID) && !defined(OS_CHROMEOS)\n\n#if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX)\n base::debug::SetCrashKeyValue(crash_keys::kChannel,\n chrome::GetChannelString());\n#endif \/\/ defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX)\n\n tracking_synchronizer_ = new metrics::TrackingSynchronizer(\n make_scoped_ptr(new base::DefaultTickClock()));\n\n#if defined(OS_MACOSX)\n SecKeychainAddCallback(&KeychainCallback, 0, NULL);\n#endif \/\/ defined(OS_MACOSX)\n\n#if defined(OS_CHROMEOS)\n chromeos::CrosSettings::Initialize();\n#endif \/\/ defined(OS_CHROMEOS)\n\n SetupMetricsAndFieldTrials();\n\n browser_process_->PreCreateThreads();\n\n return content::RESULT_CODE_NORMAL_EXIT;\n}\n","target":0,"code_token_length":1530,"total_token_length":1766,"max_tokens_setting":2048} +{"idx":38093,"func":"cifs_iovec_read(struct file *file, const struct iovec *iov,\n\t\t unsigned long nr_segs, loff_t *poffset)\n{\n\tssize_t rc;\n\tsize_t len, cur_len;\n\tssize_t total_read = 0;\n\tloff_t offset = *poffset;\n\tunsigned int npages;\n\tstruct cifs_sb_info *cifs_sb;\n\tstruct cifs_tcon *tcon;\n\tstruct cifsFileInfo *open_file;\n\tstruct cifs_readdata *rdata, *tmp;\n\tstruct list_head rdata_list;\n\tpid_t pid;\n\n\tif (!nr_segs)\n\t\treturn 0;\n\n\tlen = iov_length(iov, nr_segs);\n\tif (!len)\n\t\treturn 0;\n\n\tINIT_LIST_HEAD(&rdata_list);\n\tcifs_sb = CIFS_SB(file->f_path.dentry->d_sb);\n\topen_file = file->private_data;\n\ttcon = tlink_tcon(open_file->tlink);\n\n\tif (!tcon->ses->server->ops->async_readv)\n\t\treturn -ENOSYS;\n\n\tif (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)\n\t\tpid = open_file->pid;\n\telse\n\t\tpid = current->tgid;\n\n\tif ((file->f_flags & O_ACCMODE) == O_WRONLY)\n\t\tcifs_dbg(FYI, \"attempting read on write only file instance\\n\");\n\n\tdo {\n\t\tcur_len = min_t(const size_t, len - total_read, cifs_sb->rsize);\n\t\tnpages = DIV_ROUND_UP(cur_len, PAGE_SIZE);\n\n\t\t\/* allocate a readdata struct *\/\n\t\trdata = cifs_readdata_alloc(npages,\n\t\t\t\t\t cifs_uncached_readv_complete);\n\t\tif (!rdata) {\n\t\t\trc = -ENOMEM;\n\t\t\tgoto error;\n\t\t}\n\n\t\trc = cifs_read_allocate_pages(rdata, npages);\n\t\tif (rc)\n\t\t\tgoto error;\n\n\t\trdata->cfile = cifsFileInfo_get(open_file);\n\t\trdata->nr_pages = npages;\n\t\trdata->offset = offset;\n\t\trdata->bytes = cur_len;\n\t\trdata->pid = pid;\n\t\trdata->pagesz = PAGE_SIZE;\n\t\trdata->read_into_pages = cifs_uncached_read_into_pages;\n\n\t\trc = cifs_retry_async_readv(rdata);\nerror:\n\t\tif (rc) {\n\t\t\tkref_put(&rdata->refcount,\n\t\t\t\t cifs_uncached_readdata_release);\n\t\t\tbreak;\n\t\t}\n\n\t\tlist_add_tail(&rdata->list, &rdata_list);\n\t\toffset += cur_len;\n\t\tlen -= cur_len;\n\t} while (len > 0);\n\n\t\/* if at least one read request send succeeded, then reset rc *\/\n\tif (!list_empty(&rdata_list))\n\t\trc = 0;\n\n\t\/* the loop below should proceed in the order of increasing offsets *\/\nrestart_loop:\n\tlist_for_each_entry_safe(rdata, tmp, &rdata_list, list) {\n\t\tif (!rc) {\n\t\t\tssize_t copied;\n\n\t\t\t\/* FIXME: freezable sleep too? *\/\n\t\t\trc = wait_for_completion_killable(&rdata->done);\n\t\t\tif (rc)\n\t\t\t\trc = -EINTR;\n\t\t\telse if (rdata->result)\n\t\t\t\trc = rdata->result;\n\t\t\telse {\n\t\t\t\trc = cifs_readdata_to_iov(rdata, iov,\n\t\t\t\t\t\t\tnr_segs, *poffset,\n\t\t\t\t\t\t\t&copied);\n\t\t\t\ttotal_read += copied;\n\t\t\t}\n\n\t\t\t\/* resend call if it's a retryable error *\/\n\t\t\tif (rc == -EAGAIN) {\n\t\t\t\trc = cifs_retry_async_readv(rdata);\n\t\t\t\tgoto restart_loop;\n\t\t\t}\n\t\t}\n\t\tlist_del_init(&rdata->list);\n\t\tkref_put(&rdata->refcount, cifs_uncached_readdata_release);\n\t}\n\n\tcifs_stats_bytes_read(tcon, total_read);\n\t*poffset += total_read;\n\n\t\/* mask nodata case *\/\n\tif (rc == -ENODATA)\n\t\trc = 0;\n\n\treturn total_read ? total_read : rc;\n}","target":0,"code_token_length":860,"total_token_length":1096,"max_tokens_setting":2048} +{"idx":399731,"func":"static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,\n int x, int y, int w, int h,\n void *last_bg_,\n void *last_fg_,\n int *has_bg, int *has_fg)\n{\n VncDisplay *vd = vs->vd;\n uint8_t *row = vnc_server_fb_ptr(vd, x, y);\n pixel_t *irow = (pixel_t *)row;\n int j, i;\n pixel_t *last_bg = (pixel_t *)last_bg_;\n pixel_t *last_fg = (pixel_t *)last_fg_;\n pixel_t bg = 0;\n pixel_t fg = 0;\n int n_colors = 0;\n int bg_count = 0;\n int fg_count = 0;\n int flags = 0;\n uint8_t data[(vs->client_pf.bytes_per_pixel + 2) * 16 * 16];\n int n_data = 0;\n int n_subtiles = 0;\n\n for (j = 0; j < h; j++) {\n\tfor (i = 0; i < w; i++) {\n\t switch (n_colors) {\n\t case 0:\n\t\tbg = irow[i];\n\t\tn_colors = 1;\n\t\tbreak;\n\t case 1:\n\t\tif (irow[i] != bg) {\n\t\t fg = irow[i];\n\t\t n_colors = 2;\n\t\t}\n\t\tbreak;\n\t case 2:\n\t\tif (irow[i] != bg && irow[i] != fg) {\n\t\t n_colors = 3;\n\t\t} else {\n\t\t if (irow[i] == bg)\n\t\t\tbg_count++;\n\t\t else if (irow[i] == fg)\n\t\t\tfg_count++;\n\t\t}\n\t\tbreak;\n\t default:\n\t\tbreak;\n\t }\n\t}\n\tif (n_colors > 2)\n\t break;\n\tirow += vnc_server_fb_stride(vd) \/ sizeof(pixel_t);\n }\n\n if (n_colors > 1 && fg_count > bg_count) {\n\tpixel_t tmp = fg;\n\tfg = bg;\n\tbg = tmp;\n }\n\n if (!*has_bg || *last_bg != bg) {\n\tflags |= 0x02;\n\t*has_bg = 1;\n\t*last_bg = bg;\n }\n\n if (n_colors < 3 && (!*has_fg || *last_fg != fg)) {\n\tflags |= 0x04;\n\t*has_fg = 1;\n\t*last_fg = fg;\n }\n\n switch (n_colors) {\n case 1:\n\tn_data = 0;\n\tbreak;\n case 2:\n\tflags |= 0x08;\n\n\tirow = (pixel_t *)row;\n\n\tfor (j = 0; j < h; j++) {\n\t int min_x = -1;\n\t for (i = 0; i < w; i++) {\n\t\tif (irow[i] == fg) {\n\t\t if (min_x == -1)\n\t\t\tmin_x = i;\n\t\t} else if (min_x != -1) {\n\t\t hextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);\n\t\t n_data += 2;\n\t\t n_subtiles++;\n\t\t min_x = -1;\n\t\t}\n\t }\n\t if (min_x != -1) {\n\t\thextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);\n\t\tn_data += 2;\n\t\tn_subtiles++;\n\t }\n\t irow += vnc_server_fb_stride(vd) \/ sizeof(pixel_t);\n\t}\n\tbreak;\n case 3:\n\tflags |= 0x18;\n\n\tirow = (pixel_t *)row;\n\n\tif (!*has_bg || *last_bg != bg)\n\t flags |= 0x02;\n\n\tfor (j = 0; j < h; j++) {\n\t int has_color = 0;\n\t int min_x = -1;\n\t pixel_t color = 0; \/* shut up gcc *\/\n\n\t for (i = 0; i < w; i++) {\n\t\tif (!has_color) {\n\t\t if (irow[i] == bg)\n\t\t\tcontinue;\n\t\t color = irow[i];\n\t\t min_x = i;\n\t\t has_color = 1;\n\t\t} else if (irow[i] != color) {\n\t\t has_color = 0;\n#ifdef GENERIC\n vnc_convert_pixel(vs, data + n_data, color);\n n_data += vs->client_pf.bytes_per_pixel;\n#else\n\t\t memcpy(data + n_data, &color, sizeof(color));\n n_data += sizeof(pixel_t);\n#endif\n\t\t hextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);\n\t\t n_data += 2;\n\t\t n_subtiles++;\n\n\t\t min_x = -1;\n\t\t if (irow[i] != bg) {\n\t\t\tcolor = irow[i];\n\t\t\tmin_x = i;\n\t\t\thas_color = 1;\n\t\t }\n\t\t}\n\t }\n\t if (has_color) {\n#ifdef GENERIC\n vnc_convert_pixel(vs, data + n_data, color);\n n_data += vs->client_pf.bytes_per_pixel;\n#else\n memcpy(data + n_data, &color, sizeof(color));\n n_data += sizeof(pixel_t);\n#endif\n\t\thextile_enc_cord(data + n_data, min_x, j, i - min_x, 1);\n\t\tn_data += 2;\n\t\tn_subtiles++;\n\t }\n\t irow += vnc_server_fb_stride(vd) \/ sizeof(pixel_t);\n\t}\n\n\t\/* A SubrectsColoured subtile invalidates the foreground color *\/\n\t*has_fg = 0;\n\tif (n_data > (w * h * sizeof(pixel_t))) {\n\t n_colors = 4;\n\t flags = 0x01;\n\t *has_bg = 0;\n\n\t \/* we really don't have to invalidate either the bg or fg\n\t but we've lost the old values. oh well. *\/\n\t}\n break;\n default:\n\tbreak;\n }\n\n if (n_colors > 3) {\n\tflags = 0x01;\n\t*has_fg = 0;\n\t*has_bg = 0;\n\tn_colors = 4;\n }\n\n vnc_write_u8(vs, flags);\n if (n_colors < 4) {\n\tif (flags & 0x02)\n\t vs->write_pixels(vs, last_bg, sizeof(pixel_t));\n\tif (flags & 0x04)\n\t vs->write_pixels(vs, last_fg, sizeof(pixel_t));\n\tif (n_subtiles) {\n\t vnc_write_u8(vs, n_subtiles);\n\t vnc_write(vs, data, n_data);\n\t}\n } else {\n\tfor (j = 0; j < h; j++) {\n\t vs->write_pixels(vs, row, w * 4);\n\t row += vnc_server_fb_stride(vd);\n\t}\n }\n}","target":0,"code_token_length":1492,"total_token_length":1728,"max_tokens_setting":2048} +{"idx":107586,"func":"void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)\n{\n\tconst struct iphdr *iph = (const struct iphdr *)icmp_skb->data;\n\tstruct tcphdr *th = (struct tcphdr *)(icmp_skb->data + (iph->ihl << 2));\n\tstruct inet_connection_sock *icsk;\n\tstruct tcp_sock *tp;\n\tstruct inet_sock *inet;\n\tconst int type = icmp_hdr(icmp_skb)->type;\n\tconst int code = icmp_hdr(icmp_skb)->code;\n\tstruct sock *sk;\n\tstruct sk_buff *skb;\n\tstruct request_sock *fastopen;\n\t__u32 seq, snd_una;\n\t__u32 remaining;\n\tint err;\n\tstruct net *net = dev_net(icmp_skb->dev);\n\n\tsk = __inet_lookup_established(net, &tcp_hashinfo, iph->daddr,\n\t\t\t\t th->dest, iph->saddr, ntohs(th->source),\n\t\t\t\t inet_iif(icmp_skb));\n\tif (!sk) {\n\t\t__ICMP_INC_STATS(net, ICMP_MIB_INERRORS);\n\t\treturn;\n\t}\n\tif (sk->sk_state == TCP_TIME_WAIT) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\treturn;\n\t}\n\tseq = ntohl(th->seq);\n\tif (sk->sk_state == TCP_NEW_SYN_RECV)\n\t\treturn tcp_req_err(sk, seq,\n\t\t\t\t type == ICMP_PARAMETERPROB ||\n\t\t\t\t type == ICMP_TIME_EXCEEDED ||\n\t\t\t\t (type == ICMP_DEST_UNREACH &&\n\t\t\t\t (code == ICMP_NET_UNREACH ||\n\t\t\t\t code == ICMP_HOST_UNREACH)));\n\n\tbh_lock_sock(sk);\n\t\/* If too many ICMPs get dropped on busy\n\t * servers this needs to be solved differently.\n\t * We do take care of PMTU discovery (RFC1191) special case :\n\t * we can receive locally generated ICMP messages while socket is held.\n\t *\/\n\tif (sock_owned_by_user(sk)) {\n\t\tif (!(type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED))\n\t\t\t__NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);\n\t}\n\tif (sk->sk_state == TCP_CLOSE)\n\t\tgoto out;\n\n\tif (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);\n\t\tgoto out;\n\t}\n\n\ticsk = inet_csk(sk);\n\ttp = tcp_sk(sk);\n\t\/* XXX (TFO) - tp->snd_una should be ISN (tcp_create_openreq_child() *\/\n\tfastopen = tp->fastopen_rsk;\n\tsnd_una = fastopen ? tcp_rsk(fastopen)->snt_isn : tp->snd_una;\n\tif (sk->sk_state != TCP_LISTEN &&\n\t !between(seq, snd_una, tp->snd_nxt)) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);\n\t\tgoto out;\n\t}\n\n\tswitch (type) {\n\tcase ICMP_REDIRECT:\n\t\tdo_redirect(icmp_skb, sk);\n\t\tgoto out;\n\tcase ICMP_SOURCE_QUENCH:\n\t\t\/* Just silently ignore these. *\/\n\t\tgoto out;\n\tcase ICMP_PARAMETERPROB:\n\t\terr = EPROTO;\n\t\tbreak;\n\tcase ICMP_DEST_UNREACH:\n\t\tif (code > NR_ICMP_UNREACH)\n\t\t\tgoto out;\n\n\t\tif (code == ICMP_FRAG_NEEDED) { \/* PMTU discovery (RFC1191) *\/\n\t\t\t\/* We are not interested in TCP_LISTEN and open_requests\n\t\t\t * (SYN-ACKs send out by Linux are always <576bytes so\n\t\t\t * they should go through unfragmented).\n\t\t\t *\/\n\t\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\t\tgoto out;\n\n\t\t\ttp->mtu_info = info;\n\t\t\tif (!sock_owned_by_user(sk)) {\n\t\t\t\ttcp_v4_mtu_reduced(sk);\n\t\t\t} else {\n\t\t\t\tif (!test_and_set_bit(TCP_MTU_REDUCED_DEFERRED, &tp->tsq_flags))\n\t\t\t\t\tsock_hold(sk);\n\t\t\t}\n\t\t\tgoto out;\n\t\t}\n\n\t\terr = icmp_err_convert[code].errno;\n\t\t\/* check if icmp_skb allows revert of backoff\n\t\t * (see draft-zimmermann-tcp-lcd) *\/\n\t\tif (code != ICMP_NET_UNREACH && code != ICMP_HOST_UNREACH)\n\t\t\tbreak;\n\t\tif (seq != tp->snd_una || !icsk->icsk_retransmits ||\n\t\t !icsk->icsk_backoff || fastopen)\n\t\t\tbreak;\n\n\t\tif (sock_owned_by_user(sk))\n\t\t\tbreak;\n\n\t\ticsk->icsk_backoff--;\n\t\ticsk->icsk_rto = tp->srtt_us ? __tcp_set_rto(tp) :\n\t\t\t\t\t TCP_TIMEOUT_INIT;\n\t\ticsk->icsk_rto = inet_csk_rto_backoff(icsk, TCP_RTO_MAX);\n\n\t\tskb = tcp_write_queue_head(sk);\n\t\tBUG_ON(!skb);\n\n\t\tremaining = icsk->icsk_rto -\n\t\t\t min(icsk->icsk_rto,\n\t\t\t\ttcp_time_stamp - tcp_skb_timestamp(skb));\n\n\t\tif (remaining) {\n\t\t\tinet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,\n\t\t\t\t\t\t remaining, TCP_RTO_MAX);\n\t\t} else {\n\t\t\t\/* RTO revert clocked out retransmission.\n\t\t\t * Will retransmit now *\/\n\t\t\ttcp_retransmit_timer(sk);\n\t\t}\n\n\t\tbreak;\n\tcase ICMP_TIME_EXCEEDED:\n\t\terr = EHOSTUNREACH;\n\t\tbreak;\n\tdefault:\n\t\tgoto out;\n\t}\n\n\tswitch (sk->sk_state) {\n\tcase TCP_SYN_SENT:\n\tcase TCP_SYN_RECV:\n\t\t\/* Only in fast or simultaneous open. If a fast open socket is\n\t\t * is already accepted it is treated as a connected one below.\n\t\t *\/\n\t\tif (fastopen && !fastopen->sk)\n\t\t\tbreak;\n\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tsk->sk_err = err;\n\n\t\t\tsk->sk_error_report(sk);\n\n\t\t\ttcp_done(sk);\n\t\t} else {\n\t\t\tsk->sk_err_soft = err;\n\t\t}\n\t\tgoto out;\n\t}\n\n\t\/* If we've already connected we will keep trying\n\t * until we time out, or the user gives up.\n\t *\n\t * rfc1122 4.2.3.9 allows to consider as hard errors\n\t * only PROTO_UNREACH and PORT_UNREACH (well, FRAG_FAILED too,\n\t * but it is obsoleted by pmtu discovery).\n\t *\n\t * Note, that in modern internet, where routing is unreliable\n\t * and in each dark corner broken firewalls sit, sending random\n\t * errors ordered by their masters even this two messages finally lose\n\t * their original sense (even Linux sends invalid PORT_UNREACHs)\n\t *\n\t * Now we are in compliance with RFCs.\n\t *\t\t\t\t\t\t\t--ANK (980905)\n\t *\/\n\n\tinet = inet_sk(sk);\n\tif (!sock_owned_by_user(sk) && inet->recverr) {\n\t\tsk->sk_err = err;\n\t\tsk->sk_error_report(sk);\n\t} else\t{ \/* Only an error on timeout *\/\n\t\tsk->sk_err_soft = err;\n\t}\n\nout:\n\tbh_unlock_sock(sk);\n\tsock_put(sk);\n}","target":0,"code_token_length":1575,"total_token_length":1811,"max_tokens_setting":2048} +{"idx":423774,"func":"zone_shutdown(isc_task_t *task, isc_event_t *event) {\n\tdns_zone_t *zone = (dns_zone_t *) event->ev_arg;\n\tbool free_needed, linked = false;\n\tdns_zone_t *raw = NULL, *secure = NULL;\n\n\tUNUSED(task);\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\tINSIST(event->ev_type == DNS_EVENT_ZONECONTROL);\n\tINSIST(isc_refcount_current(&zone->erefs) == 0);\n\n\tzone_debuglog(zone, \"zone_shutdown\", 3, \"shutting down\");\n\n\t\/*\n\t * Stop things being restarted after we cancel them below.\n\t *\/\n\tLOCK_ZONE(zone);\n\tDNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_EXITING);\n\tUNLOCK_ZONE(zone);\n\n\t\/*\n\t * If we were waiting for xfrin quota, step out of\n\t * the queue.\n\t * If there's no zone manager, we can't be waiting for the\n\t * xfrin quota\n\t *\/\n\tif (zone->zmgr != NULL) {\n\t\tRWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);\n\t\tif (zone->statelist == &zone->zmgr->waiting_for_xfrin) {\n\t\t\tISC_LIST_UNLINK(zone->zmgr->waiting_for_xfrin, zone,\n\t\t\t\t\tstatelink);\n\t\t\tlinked = true;\n\t\t\tzone->statelist = NULL;\n\t\t}\n\t\tif (zone->statelist == &zone->zmgr->xfrin_in_progress) {\n\t\t\tISC_LIST_UNLINK(zone->zmgr->xfrin_in_progress, zone,\n\t\t\t\t\tstatelink);\n\t\t\tzone->statelist = NULL;\n\t\t\tzmgr_resume_xfrs(zone->zmgr, false);\n\t\t}\n\t\tRWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);\n\t}\n\n\t\/*\n\t * In task context, no locking required. See zone_xfrdone().\n\t *\/\n\tif (zone->xfr != NULL)\n\t\tdns_xfrin_shutdown(zone->xfr);\n\n\t\/* Safe to release the zone now *\/\n\tif (zone->zmgr != NULL)\n\t\tdns_zonemgr_releasezone(zone->zmgr, zone);\n\n\tLOCK_ZONE(zone);\n\tINSIST(zone != zone->raw);\n\tif (linked) {\n\t\tINSIST(zone->irefs > 0);\n\t\tzone->irefs--;\n\t}\n\tif (zone->request != NULL) {\n\t\tdns_request_cancel(zone->request);\n\t}\n\n\tif (zone->readio != NULL)\n\t\tzonemgr_cancelio(zone->readio);\n\n\tif (zone->lctx != NULL)\n\t\tdns_loadctx_cancel(zone->lctx);\n\n\tif (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FLUSH) ||\n\t !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING)) {\n\t\tif (zone->writeio != NULL)\n\t\t\tzonemgr_cancelio(zone->writeio);\n\n\t\tif (zone->dctx != NULL)\n\t\t\tdns_dumpctx_cancel(zone->dctx);\n\t}\n\n\tnotify_cancel(zone);\n\n\tforward_cancel(zone);\n\n\tif (zone->timer != NULL) {\n\t\tisc_timer_detach(&zone->timer);\n\t\tINSIST(zone->irefs > 0);\n\t\tzone->irefs--;\n\t}\n\n\t\/*\n\t * We have now canceled everything set the flag to allow exit_check()\n\t * to succeed.\tWe must not unlock between setting this flag and\n\t * calling exit_check().\n\t *\/\n\tDNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_SHUTDOWN);\n\tfree_needed = exit_check(zone);\n\tif (inline_secure(zone)) {\n\t\traw = zone->raw;\n\t\tzone->raw = NULL;\n\t}\n\tif (inline_raw(zone)) {\n\t\tsecure = zone->secure;\n\t\tzone->secure = NULL;\n\t}\n\tUNLOCK_ZONE(zone);\n\tif (raw != NULL)\n\t\tdns_zone_detach(&raw);\n\tif (secure != NULL)\n\t\tdns_zone_idetach(&secure);\n\tif (free_needed)\n\t\tzone_free(zone);\n}","target":0,"code_token_length":846,"total_token_length":1082,"max_tokens_setting":2048} +{"idx":347270,"func":"void receive_xattr(int f, struct file_struct *file)\n{\n\tstatic item_list temp_xattr = EMPTY_ITEM_LIST;\n\tint count, num;\n#ifdef HAVE_LINUX_XATTRS\n\tint need_sort = 0;\n#else\n\tint need_sort = 1;\n#endif\n\tint ndx = read_varint(f);\n\n\tif (ndx < 0 || (size_t)ndx > rsync_xal_l.count) {\n\t\trprintf(FERROR, \"receive_xattr: xa index %d out of\"\n\t\t\t\" range for %s\\n\", ndx, f_name(file, NULL));\n\t\texit_cleanup(RERR_STREAMIO);\n\t}\n\n\tif (ndx != 0) {\n\t\tF_XATTR(file) = ndx - 1;\n\t\treturn;\n\t}\n\n\tif ((count = read_varint(f)) != 0) {\n\t\t(void)EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count);\n\t\ttemp_xattr.count = 0;\n\t}\n\n\tfor (num = 1; num <= count; num++) {\n\t\tchar *ptr, *name;\n\t\trsync_xa *rxa;\n\t\tsize_t name_len = read_varint(f);\n\t\tsize_t datum_len = read_varint(f);\n\t\tsize_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len;\n\t\tsize_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0;\n\t\tif ((dget_len + extra_len < dget_len)\n\t\t || (dget_len + extra_len + name_len < dget_len + extra_len))\n\t\t\toverflow_exit(\"receive_xattr\");\n\t\tptr = new_array(char, dget_len + extra_len + name_len);\n\t\tif (!ptr)\n\t\t\tout_of_memory(\"receive_xattr\");\n\t\tname = ptr + dget_len + extra_len;\n\t\tread_buf(f, name, name_len);\n\t\tif (dget_len == datum_len)\n\t\t\tread_buf(f, ptr, dget_len);\n\t\telse {\n\t\t\t*ptr = XSTATE_ABBREV;\n\t\t\tread_buf(f, ptr + 1, MAX_DIGEST_LEN);\n\t\t}\n\n\t\tif (saw_xattr_filter) {\n\t\t\tif (name_is_excluded(name, NAME_IS_XATTR, ALL_FILTERS)) {\n\t\t\t\tfree(ptr);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n#ifdef HAVE_LINUX_XATTRS\n\t\t\/* Non-root can only save the user namespace. *\/\n\t\tif (am_root <= 0 && !HAS_PREFIX(name, USER_PREFIX)) {\n\t\t\tif (!am_root && !saw_xattr_filter) {\n\t\t\t\tfree(ptr);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tname -= RPRE_LEN;\n\t\t\tname_len += RPRE_LEN;\n\t\t\tmemcpy(name, RSYNC_PREFIX, RPRE_LEN);\n\t\t\tneed_sort = 1;\n\t\t}\n#else\n\t\t\/* This OS only has a user namespace, so we either\n\t\t * strip the user prefix, or we put a non-user\n\t\t * namespace inside our rsync hierarchy. *\/\n\t\tif (HAS_PREFIX(name, USER_PREFIX)) {\n\t\t\tname += UPRE_LEN;\n\t\t\tname_len -= UPRE_LEN;\n\t\t} else if (am_root) {\n\t\t\tname -= RPRE_LEN;\n\t\t\tname_len += RPRE_LEN;\n\t\t\tmemcpy(name, RSYNC_PREFIX, RPRE_LEN);\n\t\t} else {\n\t\t\tfree(ptr);\n\t\t\tcontinue;\n\t\t}\n#endif\n\t\t\/* No rsync.%FOO attributes are copied w\/o 2 -X options. *\/\n\t\tif (preserve_xattrs < 2 && name_len > RPRE_LEN\n\t\t && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX)) {\n\t\t\tfree(ptr);\n\t\t\tcontinue;\n\t\t}\n\n\t\trxa = EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, 1);\n\t\trxa->name = name;\n\t\trxa->datum = ptr;\n\t\trxa->name_len = name_len;\n\t\trxa->datum_len = datum_len;\n\t\trxa->num = num;\n\t}\n\n\tif (need_sort && count > 1)\n\t\tqsort(temp_xattr.items, count, sizeof (rsync_xa), rsync_xal_compare_names);\n\n\tndx = rsync_xal_store(&temp_xattr); \/* adds item to rsync_xal_l *\/\n\n\tF_XATTR(file) = ndx;\n}","target":1,"code_token_length":911,"total_token_length":1147,"max_tokens_setting":2048} +{"idx":463251,"func":"TileBufferTask::execute ()\n{\n try\n {\n \/\/\n \/\/ Calculate information about the tile\n \/\/\n\n Box2i tileRange = OPENEXR_IMF_INTERNAL_NAMESPACE::dataWindowForTile (\n _ifd->tileDesc,\n _ifd->minX, _ifd->maxX,\n _ifd->minY, _ifd->maxY,\n _tileBuffer->dx,\n _tileBuffer->dy,\n _tileBuffer->lx,\n _tileBuffer->ly);\n\n \/\/\n \/\/ Get the size of the tile.\n \/\/\n\n Array numPixelsPerScanLine;\n numPixelsPerScanLine.resizeErase(tileRange.max.y - tileRange.min.y + 1);\n\n int sizeOfTile = 0;\n int maxBytesPerTileLine = 0;\n\n for (int y = tileRange.min.y; y <= tileRange.max.y; y++)\n {\n numPixelsPerScanLine[y - tileRange.min.y] = 0;\n\n int bytesPerLine = 0;\n\n for (int x = tileRange.min.x; x <= tileRange.max.x; x++)\n {\n int xOffset = _ifd->sampleCountXTileCoords * tileRange.min.x;\n int yOffset = _ifd->sampleCountYTileCoords * tileRange.min.y;\n\n int count = _ifd->getSampleCount(x - xOffset, y - yOffset);\n for (unsigned int c = 0; c < _ifd->slices.size(); ++c)\n {\n \/\/ This slice does not exist in the file.\n if ( !_ifd->slices[c]->fill)\n {\n sizeOfTile += count * pixelTypeSize(_ifd->slices[c]->typeInFile);\n bytesPerLine += count * pixelTypeSize(_ifd->slices[c]->typeInFile); \n }\n }\n numPixelsPerScanLine[y - tileRange.min.y] += count;\n }\n\n if (bytesPerLine > maxBytesPerTileLine)\n maxBytesPerTileLine = bytesPerLine;\n }\n\n \/\/ (TODO) don't do this every time.\n if (_tileBuffer->compressor != 0)\n delete _tileBuffer->compressor;\n _tileBuffer->compressor = newTileCompressor\n (_ifd->header.compression(),\n maxBytesPerTileLine,\n _ifd->tileDesc.ySize,\n _ifd->header);\n\n \/\/\n \/\/ Uncompress the data, if necessary\n \/\/\n\n if (_tileBuffer->compressor && _tileBuffer->dataSize < static_cast(sizeOfTile))\n {\n _tileBuffer->format = _tileBuffer->compressor->format();\n\n _tileBuffer->dataSize = _tileBuffer->compressor->uncompressTile\n (_tileBuffer->buffer, _tileBuffer->dataSize,\n tileRange, _tileBuffer->uncompressedData);\n }\n else\n {\n \/\/\n \/\/ If the line is uncompressed, it's in XDR format,\n \/\/ regardless of the compressor's output format.\n \/\/\n\n _tileBuffer->format = Compressor::XDR;\n _tileBuffer->uncompressedData = _tileBuffer->buffer;\n }\n\n\t\/\/\n\t\/\/ sanity check data size: the uncompressed data should be exactly \n\t\/\/ 'sizeOfTile' (if it's less, the file is corrupt and there'll be a buffer overrun)\n\t\/\/\n if (_tileBuffer->dataSize != static_cast(sizeOfTile))\n\t{\n\t\tTHROW (IEX_NAMESPACE::InputExc, \"size mismatch when reading deep tile: expected \" << sizeOfTile << \"bytes of uncompressed data but got \" << _tileBuffer->dataSize);\n\t}\n\n \/\/\n \/\/ Convert the tile of pixel data back from the machine-independent\n \/\/ representation, and store the result in the frame buffer.\n \/\/\n\n const char *readPtr = _tileBuffer->uncompressedData;\n \/\/ points to where we\n \/\/ read from in the\n \/\/ tile block\n\n \/\/\n \/\/ Iterate over the scan lines in the tile.\n \/\/\n\n for (int y = tileRange.min.y; y <= tileRange.max.y; ++y)\n {\n \/\/\n \/\/ Iterate over all image channels.\n \/\/\n\n for (unsigned int i = 0; i < _ifd->slices.size(); ++i)\n {\n TInSliceInfo &slice = *_ifd->slices[i];\n\n \/\/\n \/\/ These offsets are used to facilitate both\n \/\/ absolute and tile-relative pixel coordinates.\n \/\/\n\n int xOffsetForData = (slice.xTileCoords == 0) ? 0 : tileRange.min.x;\n int yOffsetForData = (slice.yTileCoords == 0) ? 0 : tileRange.min.y;\n int xOffsetForSampleCount =\n (_ifd->sampleCountXTileCoords == 0) ? 0 : tileRange.min.x;\n int yOffsetForSampleCount =\n (_ifd->sampleCountYTileCoords == 0) ? 0 : tileRange.min.y;\n\n \/\/\n \/\/ Fill the frame buffer with pixel data.\n \/\/\n\n if (slice.skip)\n {\n \/\/\n \/\/ The file contains data for this channel, but\n \/\/ the frame buffer contains no slice for this channel.\n \/\/\n\n skipChannel (readPtr, slice.typeInFile,\n numPixelsPerScanLine[y - tileRange.min.y]);\n }\n else\n {\n \/\/\n \/\/ The frame buffer contains a slice for this channel.\n \/\/\n\n copyIntoDeepFrameBuffer (readPtr, slice.pointerArrayBase,\n _ifd->sampleCountSliceBase,\n _ifd->sampleCountXStride,\n _ifd->sampleCountYStride,\n y,\n tileRange.min.x,\n tileRange.max.x,\n xOffsetForSampleCount, yOffsetForSampleCount,\n xOffsetForData, yOffsetForData,\n slice.sampleStride, \n slice.xStride,\n slice.yStride,\n slice.fill,\n slice.fillValue, _tileBuffer->format,\n slice.typeInFrameBuffer,\n slice.typeInFile);\n }\n }\n }\n }\n catch (std::exception &e)\n {\n if (!_tileBuffer->hasException)\n {\n _tileBuffer->exception = e.what ();\n _tileBuffer->hasException = true;\n }\n }\n catch (...)\n {\n if (!_tileBuffer->hasException)\n {\n _tileBuffer->exception = \"unrecognized exception\";\n _tileBuffer->hasException = true;\n }\n }\n}","target":0,"code_token_length":1411,"total_token_length":1647,"max_tokens_setting":2048} +{"idx":411325,"func":" template\n CImg get_object3dtoCImg3d(const CImgList& primitives,\n const CImgList& colors,\n const to& opacities,\n const bool full_check=true) const {\n CImg error_message(1024);\n if (!is_object3d(primitives,colors,opacities,full_check,error_message))\n throw CImgInstanceException(_cimg_instance\n \"object3dtoCImg3d(): Invalid specified 3d object (%u,%u) (%s).\",\n cimg_instance,_width,primitives._width,error_message.data());\n CImg res(1,_size_object3dtoCImg3d(primitives,colors,opacities));\n float *ptrd = res._data;\n\n \/\/ Put magick number.\n *(ptrd++) = 'C' + 0.5f; *(ptrd++) = 'I' + 0.5f; *(ptrd++) = 'm' + 0.5f;\n *(ptrd++) = 'g' + 0.5f; *(ptrd++) = '3' + 0.5f; *(ptrd++) = 'd' + 0.5f;\n\n \/\/ Put number of vertices and primitives.\n *(ptrd++) = cimg::uint2float(_width);\n *(ptrd++) = cimg::uint2float(primitives._width);\n\n \/\/ Put vertex data.\n if (is_empty() || !primitives) return res;\n const T *ptrx = data(0,0), *ptry = data(0,1), *ptrz = data(0,2);\n cimg_forX(*this,p) {\n *(ptrd++) = (float)*(ptrx++);\n *(ptrd++) = (float)*(ptry++);\n *(ptrd++) = (float)*(ptrz++);\n }\n\n \/\/ Put primitive data.\n cimglist_for(primitives,p) {\n *(ptrd++) = (float)primitives[p].size();\n const tp *ptrp = primitives[p]._data;\n cimg_foroff(primitives[p],i) *(ptrd++) = cimg::uint2float((unsigned int)*(ptrp++));\n }\n\n \/\/ Put color\/texture data.\n const unsigned int csiz = std::min(colors._width,primitives._width);\n for (int c = 0; c<(int)csiz; ++c) {\n const CImg& color = colors[c];\n const tc *ptrc = color._data;\n if (color.size()==3) { *(ptrd++) = (float)*(ptrc++); *(ptrd++) = (float)*(ptrc++); *(ptrd++) = (float)*ptrc; }\n else {\n *(ptrd++) = -128.0f;\n int shared_ind = -1;\n if (color.is_shared()) for (int i = 0; iWithRank(c->input(0), 4, &input_shape));\n ShapeHandle filter_shape;\n TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 4, &filter_shape));\n\n std::vector strides;\n TF_RETURN_IF_ERROR(c->GetAttr(\"strides\", &strides));\n\n if (strides.size() != 4) {\n return errors::InvalidArgument(\n \"DepthwiseConv2D requires the stride attribute to contain 4 values, \"\n \"but got: \",\n strides.size());\n }\n\n std::vector dilations;\n if (!c->GetAttr(\"dilations\", &dilations).ok()) {\n dilations.resize(4, 1);\n }\n\n if (dilations.size() != 4) {\n return errors::InvalidArgument(\n \"DepthwiseConv2D requires the dilations attribute to contain 4 values, \"\n \"but got: \",\n dilations.size());\n }\n\n string data_format_str;\n Status s = c->GetAttr(\"data_format\", &data_format_str);\n TensorFormat data_format;\n if (!s.ok() || !FormatFromString(data_format_str, &data_format)) {\n data_format = FORMAT_NHWC;\n }\n int32_t stride_rows;\n int32_t stride_cols;\n int32_t dilation_rows;\n int32_t dilation_cols;\n if (data_format == FORMAT_NCHW) {\n \/\/ Canonicalize input shape to NHWC so the shape inference code below can\n \/\/ process it.\n input_shape =\n c->MakeShape({{c->Dim(input_shape, 0), c->Dim(input_shape, 2),\n c->Dim(input_shape, 3), c->Dim(input_shape, 1)}});\n stride_rows = strides[2];\n stride_cols = strides[3];\n dilation_rows = dilations[2];\n dilation_cols = dilations[3];\n } else {\n stride_rows = strides[1];\n stride_cols = strides[2];\n dilation_rows = dilations[1];\n dilation_cols = dilations[2];\n }\n\n DimensionHandle batch_size_dim = c->Dim(input_shape, 0);\n DimensionHandle in_rows_dim = c->Dim(input_shape, 1);\n DimensionHandle in_cols_dim = c->Dim(input_shape, 2);\n\n DimensionHandle filter_rows_dim = c->Dim(filter_shape, 0);\n DimensionHandle filter_cols_dim = c->Dim(filter_shape, 1);\n DimensionHandle input_depth = c->Dim(filter_shape, 2);\n DimensionHandle depth_multiplier = c->Dim(filter_shape, 3);\n\n \/\/ Check that the input depths are compatible.\n TF_RETURN_IF_ERROR(\n c->Merge(c->Dim(input_shape, 3), input_depth, &input_depth));\n\n DimensionHandle output_depth;\n TF_RETURN_IF_ERROR(c->Multiply(input_depth, depth_multiplier, &output_depth));\n\n Padding padding;\n TF_RETURN_IF_ERROR(c->GetAttr(\"padding\", &padding));\n\n std::vector explicit_paddings;\n if (supports_explicit_padding) {\n Status status = c->GetAttr(\"explicit_paddings\", &explicit_paddings);\n \/\/ Use the default value, which is an empty list, if the attribute is not\n \/\/ found. Otherwise return the error to the caller.\n if (!status.ok() && !errors::IsNotFound(status)) {\n return status;\n }\n TF_RETURN_IF_ERROR(CheckValidPadding(padding, explicit_paddings,\n \/*num_dims=*\/4, data_format));\n } else {\n DCHECK(padding != Padding::EXPLICIT);\n }\n\n \/\/ TODO(mrry,shlens): Raise an error if the stride would cause\n \/\/ information in the input to be ignored. This will require a change\n \/\/ in the kernel implementation.\n DimensionHandle output_rows, output_cols;\n int64_t pad_rows_before = -1, pad_rows_after = -1;\n int64_t pad_cols_before = -1, pad_cols_after = -1;\n if (padding == Padding::EXPLICIT) {\n GetExplicitPaddingForDim(explicit_paddings, data_format, 'H',\n &pad_rows_before, &pad_rows_after);\n GetExplicitPaddingForDim(explicit_paddings, data_format, 'W',\n &pad_cols_before, &pad_cols_after);\n }\n TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n c, in_rows_dim, filter_rows_dim, dilation_rows, stride_rows, padding,\n pad_rows_before, pad_rows_after, &output_rows));\n TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n c, in_cols_dim, filter_cols_dim, dilation_cols, stride_cols, padding,\n pad_cols_before, pad_cols_after, &output_cols));\n\n ShapeHandle output_shape;\n if (data_format == FORMAT_NCHW) {\n output_shape =\n c->MakeShape({batch_size_dim, output_depth, output_rows, output_cols});\n } else {\n output_shape =\n c->MakeShape({batch_size_dim, output_rows, output_cols, output_depth});\n }\n c->set_output(0, output_shape);\n return Status::OK();\n}","target":0,"code_token_length":1169,"total_token_length":1405,"max_tokens_setting":2048} +{"idx":167476,"func":"int test_kron(BIO *bp, BN_CTX *ctx)\n\t{\n\tBN_GENCB cb;\n\tBIGNUM *a,*b,*r,*t;\n\tint i;\n\tint legendre, kronecker;\n\tint ret = 0;\n\n\ta = BN_new();\n\tb = BN_new();\n\tr = BN_new();\n\tt = BN_new();\n\tif (a == NULL || b == NULL || r == NULL || t == NULL) goto err;\n\n\tBN_GENCB_set(&cb, genprime_cb, NULL);\n\t\n\t\/* We test BN_kronecker(a, b, ctx) just for b odd (Jacobi symbol).\n\t * In this case we know that if b is prime, then BN_kronecker(a, b, ctx)\n\t * is congruent to $a^{(b-1)\/2}$, modulo $b$ (Legendre symbol).\n\t * So we generate a random prime b and compare these values\n\t * for a number of random a's. (That is, we run the Solovay-Strassen\n\t * primality test to confirm that b is prime, except that we\n\t * don't want to test whether b is prime but whether BN_kronecker\n\t * works.) *\/\n\n\tif (!BN_generate_prime_ex(b, 512, 0, NULL, NULL, &cb)) goto err;\n\tb->neg = rand_neg();\n\tputc('\\n', stderr);\n\n\tfor (i = 0; i < num0; i++)\n\t\t{\n\t\tif (!BN_bntest_rand(a, 512, 0, 0)) goto err;\n\t\ta->neg = rand_neg();\n\n\t\t\/* t := (|b|-1)\/2 (note that b is odd) *\/\n\t\tif (!BN_copy(t, b)) goto err;\n\t\tt->neg = 0;\n\t\tif (!BN_sub_word(t, 1)) goto err;\n\t\tif (!BN_rshift1(t, t)) goto err;\n\t\t\/* r := a^t mod b *\/\n\t\tb->neg=0;\n\t\t\n\t\tif (!BN_mod_exp_recp(r, a, t, b, ctx)) goto err;\n\t\tb->neg=1;\n\n\t\tif (BN_is_word(r, 1))\n\t\t\tlegendre = 1;\n\t\telse if (BN_is_zero(r))\n\t\t\tlegendre = 0;\n\t\telse\n\t\t\t{\n\t\t\tif (!BN_add_word(r, 1)) goto err;\n\t\t\tif (0 != BN_ucmp(r, b))\n\t\t\t\t{\n\t\t\t\tfprintf(stderr, \"Legendre symbol computation failed\\n\");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tlegendre = -1;\n\t\t\t}\n\t\t\n\t\tkronecker = BN_kronecker(a, b, ctx);\n\t\tif (kronecker < -1) goto err;\n\t\t\/* we actually need BN_kronecker(a, |b|) *\/\n\t\tif (a->neg && b->neg)\n\t\t\tkronecker = -kronecker;\n\t\t\n\t\tif (legendre != kronecker)\n\t\t\t{\n\t\t\tfprintf(stderr, \"legendre != kronecker; a = \");\n\t\t\tBN_print_fp(stderr, a);\n\t\t\tfprintf(stderr, \", b = \");\n\t\t\tBN_print_fp(stderr, b);\n\t\t\tfprintf(stderr, \"\\n\");\n\t\t\tgoto err;\n\t\t\t}\n\n\t\tputc('.', stderr);\n\t\tfflush(stderr);\n\t\t}\n\n\tputc('\\n', stderr);\n\tfflush(stderr);\n\tret = 1;\n err:\n\tif (a != NULL) BN_free(a);\n\tif (b != NULL) BN_free(b);\n\tif (r != NULL) BN_free(r);\n\tif (t != NULL) BN_free(t);\n\treturn ret;\n\t}\n","target":0,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048} +{"idx":304181,"func":"static struct sk_buff **inet_gro_receive(struct sk_buff **head,\n\t\t\t\t\t struct sk_buff *skb)\n{\n\tconst struct net_offload *ops;\n\tstruct sk_buff **pp = NULL;\n\tstruct sk_buff *p;\n\tconst struct iphdr *iph;\n\tunsigned int hlen;\n\tunsigned int off;\n\tunsigned int id;\n\tint flush = 1;\n\tint proto;\n\n\toff = skb_gro_offset(skb);\n\thlen = off + sizeof(*iph);\n\tiph = skb_gro_header_fast(skb, off);\n\tif (skb_gro_header_hard(skb, hlen)) {\n\t\tiph = skb_gro_header_slow(skb, hlen, off);\n\t\tif (unlikely(!iph))\n\t\t\tgoto out;\n\t}\n\n\tproto = iph->protocol;\n\n\trcu_read_lock();\n\tops = rcu_dereference(inet_offloads[proto]);\n\tif (!ops || !ops->callbacks.gro_receive)\n\t\tgoto out_unlock;\n\n\tif (*(u8 *)iph != 0x45)\n\t\tgoto out_unlock;\n\n\tif (unlikely(ip_fast_csum((u8 *)iph, 5)))\n\t\tgoto out_unlock;\n\n\tid = ntohl(*(__be32 *)&iph->id);\n\tflush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF));\n\tid >>= 16;\n\n\tfor (p = *head; p; p = p->next) {\n\t\tstruct iphdr *iph2;\n\n\t\tif (!NAPI_GRO_CB(p)->same_flow)\n\t\t\tcontinue;\n\n\t\tiph2 = (struct iphdr *)(p->data + off);\n\t\t\/* The above works because, with the exception of the top\n\t\t * (inner most) layer, we only aggregate pkts with the same\n\t\t * hdr length so all the hdrs we'll need to verify will start\n\t\t * at the same offset.\n\t\t *\/\n\t\tif ((iph->protocol ^ iph2->protocol) |\n\t\t ((__force u32)iph->saddr ^ (__force u32)iph2->saddr) |\n\t\t ((__force u32)iph->daddr ^ (__force u32)iph2->daddr)) {\n\t\t\tNAPI_GRO_CB(p)->same_flow = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* All fields must match except length and checksum. *\/\n\t\tNAPI_GRO_CB(p)->flush |=\n\t\t\t(iph->ttl ^ iph2->ttl) |\n\t\t\t(iph->tos ^ iph2->tos) |\n\t\t\t((iph->frag_off ^ iph2->frag_off) & htons(IP_DF));\n\n\t\t\/* Save the IP ID check to be included later when we get to\n\t\t * the transport layer so only the inner most IP ID is checked.\n\t\t * This is because some GSO\/TSO implementations do not\n\t\t * correctly increment the IP ID for the outer hdrs.\n\t\t *\/\n\t\tNAPI_GRO_CB(p)->flush_id =\n\t\t\t ((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);\n\t\tNAPI_GRO_CB(p)->flush |= flush;\n\t}\n\n\tNAPI_GRO_CB(skb)->flush |= flush;\n\tskb_set_network_header(skb, off);\n\t\/* The above will be needed by the transport layer if there is one\n\t * immediately following this IP hdr.\n\t *\/\n\n\t\/* Note : No need to call skb_gro_postpull_rcsum() here,\n\t * as we already checked checksum over ipv4 header was 0\n\t *\/\n\tskb_gro_pull(skb, sizeof(*iph));\n\tskb_set_transport_header(skb, skb_gro_offset(skb));\n\n\tpp = ops->callbacks.gro_receive(head, skb);\n\nout_unlock:\n\trcu_read_unlock();\n\nout:\n\tNAPI_GRO_CB(skb)->flush |= flush;\n\n\treturn pp;\n}","target":0,"code_token_length":810,"total_token_length":1046,"max_tokens_setting":2048} +{"idx":8089,"func":"void ZRLE_DECODE (const Rect& r, rdr::InStream* is,\n rdr::ZlibInStream* zis,\n const PixelFormat& pf, ModifiablePixelBuffer* pb)\n{\n int length = is->readU32();\n zis->setUnderlying(is, length);\n Rect t;\n PIXEL_T buf[64 * 64];\n\n for (t.tl.y = r.tl.y; t.tl.y < r.br.y; t.tl.y += 64) {\n\n t.br.y = __rfbmin(r.br.y, t.tl.y + 64);\n\n for (t.tl.x = r.tl.x; t.tl.x < r.br.x; t.tl.x += 64) {\n\n t.br.x = __rfbmin(r.br.x, t.tl.x + 64);\n\n int mode = zis->readU8();\n bool rle = mode & 128;\n int palSize = mode & 127;\n PIXEL_T palette[128];\n\n for (int i = 0; i < palSize; i++) {\n palette[i] = READ_PIXEL(zis);\n }\n\n if (palSize == 1) {\n PIXEL_T pix = palette[0];\n pb->fillRect(pf, t, &pix);\n continue;\n }\n\n if (!rle) {\n if (palSize == 0) {\n\n \/\/ raw\n\n#ifdef CPIXEL\n for (PIXEL_T* ptr = buf; ptr < buf+t.area(); ptr++) {\n *ptr = READ_PIXEL(zis);\n }\n#else\n zis->readBytes(buf, t.area() * (BPP \/ 8));\n#endif\n\n } else {\n\n \/\/ packed pixels\n int bppp = ((palSize > 16) ? 8 :\n ((palSize > 4) ? 4 : ((palSize > 2) ? 2 : 1)));\n\n PIXEL_T* ptr = buf;\n\n for (int i = 0; i < t.height(); i++) {\n PIXEL_T* eol = ptr + t.width();\n rdr::U8 byte = 0;\n rdr::U8 nbits = 0;\n\n while (ptr < eol) {\n if (nbits == 0) {\n byte = zis->readU8();\n nbits = 8;\n }\n nbits -= bppp;\n rdr::U8 index = (byte >> nbits) & ((1 << bppp) - 1) & 127;\n *ptr++ = palette[index];\n }\n }\n }\n\n } else {\n\n if (palSize == 0) {\n\n \/\/ plain RLE\n\n PIXEL_T* ptr = buf;\n PIXEL_T* end = ptr + t.area();\n while (ptr < end) {\n PIXEL_T pix = READ_PIXEL(zis);\n int len = 1;\n int b;\n do {\n b = zis->readU8();\n len += b;\n } while (b == 255);\n\n if (end - ptr < len) {\n throw Exception (\"ZRLE decode error\");\n }\n\n while (len-- > 0) *ptr++ = pix;\n\n }\n } else {\n\n \/\/ palette RLE\n\n PIXEL_T* ptr = buf;\n PIXEL_T* end = ptr + t.area();\n while (ptr < end) {\n int index = zis->readU8();\n int len = 1;\n if (index & 128) {\n int b;\n do {\n b = zis->readU8();\n len += b;\n } while (b == 255);\n\n if (end - ptr < len) {\n throw Exception (\"ZRLE decode error\");\n }\n }\n\n index &= 127;\n\n PIXEL_T pix = palette[index];\n\n while (len-- > 0) *ptr++ = pix;\n }\n }\n }\n\n pb->imageRect(pf, t, buf);\n }\n }\n\n zis->removeUnderlying();\n}","target":1,"code_token_length":897,"total_token_length":1133,"max_tokens_setting":2048} +{"idx":349007,"func":"_gcry_ecc_ecdsa_sign (gcry_mpi_t input, ECC_secret_key *skey,\n gcry_mpi_t r, gcry_mpi_t s,\n int flags, int hashalgo)\n{\n gpg_err_code_t rc = 0;\n int extraloops = 0;\n gcry_mpi_t k, dr, sum, k_1, x;\n mpi_point_struct I;\n gcry_mpi_t hash;\n const void *abuf;\n unsigned int abits, qbits;\n mpi_ec_t ctx;\n gcry_mpi_t b; \/* Random number needed for blinding. *\/\n gcry_mpi_t bi; \/* multiplicative inverse of B. *\/\n\n if (DBG_CIPHER)\n log_mpidump (\"ecdsa sign hash \", input );\n\n qbits = mpi_get_nbits (skey->E.n);\n\n \/* Convert the INPUT into an MPI if needed. *\/\n rc = _gcry_dsa_normalize_hash (input, &hash, qbits);\n if (rc)\n return rc;\n\n b = mpi_snew (qbits);\n bi = mpi_snew (qbits);\n do\n {\n _gcry_mpi_randomize (b, qbits, GCRY_WEAK_RANDOM);\n mpi_mod (b, b, skey->E.n);\n }\n while (!mpi_invm (bi, b, skey->E.n));\n\n k = NULL;\n dr = mpi_alloc (0);\n sum = mpi_alloc (0);\n k_1 = mpi_alloc (0);\n x = mpi_alloc (0);\n point_init (&I);\n\n ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0,\n skey->E.p, skey->E.a, skey->E.b);\n\n \/* Two loops to avoid R or S are zero. This is more of a joke than\n a real demand because the probability of them being zero is less\n than any hardware failure. Some specs however require it. *\/\n do\n {\n do\n {\n mpi_free (k);\n k = NULL;\n if ((flags & PUBKEY_FLAG_RFC6979) && hashalgo)\n {\n \/* Use Pornin's method for deterministic DSA. If this\n flag is set, it is expected that HASH is an opaque\n MPI with the to be signed hash. That hash is also\n used as h1 from 3.2.a. *\/\n if (!mpi_is_opaque (input))\n {\n rc = GPG_ERR_CONFLICT;\n goto leave;\n }\n\n abuf = mpi_get_opaque (input, &abits);\n rc = _gcry_dsa_gen_rfc6979_k (&k, skey->E.n, skey->d,\n abuf, (abits+7)\/8,\n hashalgo, extraloops);\n if (rc)\n goto leave;\n extraloops++;\n }\n else\n k = _gcry_dsa_gen_k (skey->E.n, GCRY_STRONG_RANDOM);\n\n _gcry_mpi_ec_mul_point (&I, k, &skey->E.G, ctx);\n if (_gcry_mpi_ec_get_affine (x, NULL, &I, ctx))\n {\n if (DBG_CIPHER)\n log_debug (\"ecc sign: Failed to get affine coordinates\\n\");\n rc = GPG_ERR_BAD_SIGNATURE;\n goto leave;\n }\n mpi_mod (r, x, skey->E.n); \/* r = x mod n *\/\n }\n while (!mpi_cmp_ui (r, 0));\n\n mpi_mulm (dr, b, skey->d, skey->E.n);\n mpi_mulm (dr, dr, r, skey->E.n); \/* dr = d*r mod n (blinded with b) *\/\n mpi_mulm (sum, b, hash, skey->E.n);\n mpi_addm (sum, sum, dr, skey->E.n); \/* sum = hash + (d*r) mod n (blinded with b) *\/\n mpi_mulm (sum, bi, sum, skey->E.n); \/* undo blinding by b^-1 *\/\n mpi_invm (k_1, k, skey->E.n); \/* k_1 = k^(-1) mod n *\/\n mpi_mulm (s, k_1, sum, skey->E.n); \/* s = k^(-1)*(hash+(d*r)) mod n *\/\n }\n while (!mpi_cmp_ui (s, 0));\n\n if (DBG_CIPHER)\n {\n log_mpidump (\"ecdsa sign result r \", r);\n log_mpidump (\"ecdsa sign result s \", s);\n }\n\n leave:\n mpi_free (b);\n mpi_free (bi);\n _gcry_mpi_ec_free (ctx);\n point_free (&I);\n mpi_free (x);\n mpi_free (k_1);\n mpi_free (sum);\n mpi_free (dr);\n mpi_free (k);\n\n if (hash != input)\n mpi_free (hash);\n\n return rc;\n}","target":1,"code_token_length":1129,"total_token_length":1365,"max_tokens_setting":2048} +{"idx":402902,"func":"void t_cpp_generator::generate_service_skeleton(t_service* tservice) {\n string svcname = tservice->get_name();\n\n \/\/ Service implementation file includes\n string f_skeleton_name = get_out_dir() + svcname + \"_server.skeleton.cpp\";\n\n string ns = namespace_prefix(tservice->get_program()->get_namespace(\"cpp\"));\n\n ofstream f_skeleton;\n f_skeleton.open(f_skeleton_name.c_str());\n f_skeleton << \"\/\/ This autogenerated skeleton file illustrates how to build a server.\" << endl\n << \"\/\/ You should copy it to another filename to avoid overwriting it.\" << endl << endl\n << \"#include \\\"\" << get_include_prefix(*get_program()) << svcname << \".h\\\"\" << endl\n << \"#include \" << endl\n << \"#include \" << endl\n << \"#include \" << endl\n << \"#include \" << endl << endl\n << \"using namespace ::apache::thrift;\" << endl\n << \"using namespace ::apache::thrift::protocol;\" << endl\n << \"using namespace ::apache::thrift::transport;\" << endl\n << \"using namespace ::apache::thrift::server;\" << endl << endl\n << \"using boost::shared_ptr;\" << endl << endl;\n\n \/\/ the following code would not compile:\n \/\/ using namespace ;\n \/\/ using namespace ::;\n if ((!ns.empty()) && (ns.compare(\" ::\") != 0)) {\n f_skeleton << \"using namespace \" << string(ns, 0, ns.size() - 2) << \";\" << endl << endl;\n }\n\n f_skeleton << \"class \" << svcname << \"Handler : virtual public \" << svcname << \"If {\" << endl\n << \" public:\" << endl;\n indent_up();\n f_skeleton << indent() << svcname << \"Handler() {\" << endl << indent()\n << \" \/\/ Your initialization goes here\" << endl << indent() << \"}\" << endl << endl;\n\n vector functions = tservice->get_functions();\n vector::iterator f_iter;\n for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {\n generate_java_doc(f_skeleton, *f_iter);\n f_skeleton << indent() << function_signature(*f_iter, \"\") << \" {\" << endl << indent()\n << \" \/\/ Your implementation goes here\" << endl << indent() << \" printf(\\\"\"\n << (*f_iter)->get_name() << \"\\\\n\\\");\" << endl << indent() << \"}\" << endl << endl;\n }\n\n indent_down();\n f_skeleton << \"};\" << endl << endl;\n\n f_skeleton << indent() << \"int main(int argc, char **argv) {\" << endl;\n indent_up();\n f_skeleton\n << indent() << \"int port = 9090;\" << endl << indent() << \"shared_ptr<\" << svcname\n << \"Handler> handler(new \" << svcname << \"Handler());\" << endl << indent()\n << \"shared_ptr processor(new \" << svcname << \"Processor(handler));\" << endl\n << indent() << \"shared_ptr serverTransport(new TServerSocket(port));\"\n << endl << indent()\n << \"shared_ptr transportFactory(new TBufferedTransportFactory());\" << endl\n << indent() << \"shared_ptr protocolFactory(new TBinaryProtocolFactory());\"\n << endl << endl << indent()\n << \"TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);\"\n << endl << indent() << \"server.serve();\" << endl << indent() << \"return 0;\" << endl;\n indent_down();\n f_skeleton << \"}\" << endl << endl;\n\n \/\/ Close the files\n f_skeleton.close();\n}","target":0,"code_token_length":857,"total_token_length":1093,"max_tokens_setting":2048} +{"idx":66456,"func":"static int kvm_guest_time_update(struct kvm_vcpu *v)\n{\n\tunsigned long flags;\n\tstruct kvm_vcpu_arch *vcpu = &v->arch;\n\tvoid *shared_kaddr;\n\tunsigned long this_tsc_khz;\n\ts64 kernel_ns, max_kernel_ns;\n\tu64 tsc_timestamp;\n\n\t\/* Keep irq disabled to prevent changes to the clock *\/\n\tlocal_irq_save(flags);\n\tkvm_get_msr(v, MSR_IA32_TSC, &tsc_timestamp);\n\tkernel_ns = get_kernel_ns();\n\tthis_tsc_khz = __get_cpu_var(cpu_tsc_khz);\n\n\tif (unlikely(this_tsc_khz == 0)) {\n\t\tlocal_irq_restore(flags);\n\t\tkvm_make_request(KVM_REQ_CLOCK_UPDATE, v);\n\t\treturn 1;\n\t}\n\n\t\/*\n\t * We may have to catch up the TSC to match elapsed wall clock\n\t * time for two reasons, even if kvmclock is used.\n\t * 1) CPU could have been running below the maximum TSC rate\n\t * 2) Broken TSC compensation resets the base at each VCPU\n\t * entry to avoid unknown leaps of TSC even when running\n\t * again on the same CPU. This may cause apparent elapsed\n\t * time to disappear, and the guest to stand still or run\n\t *\tvery slowly.\n\t *\/\n\tif (vcpu->tsc_catchup) {\n\t\tu64 tsc = compute_guest_tsc(v, kernel_ns);\n\t\tif (tsc > tsc_timestamp) {\n\t\t\tkvm_x86_ops->adjust_tsc_offset(v, tsc - tsc_timestamp);\n\t\t\ttsc_timestamp = tsc;\n\t\t}\n\t}\n\n\tlocal_irq_restore(flags);\n\n\tif (!vcpu->time_page)\n\t\treturn 0;\n\n\t\/*\n\t * Time as measured by the TSC may go backwards when resetting the base\n\t * tsc_timestamp. The reason for this is that the TSC resolution is\n\t * higher than the resolution of the other clock scales. Thus, many\n\t * possible measurments of the TSC correspond to one measurement of any\n\t * other clock, and so a spread of values is possible. This is not a\n\t * problem for the computation of the nanosecond clock; with TSC rates\n\t * around 1GHZ, there can only be a few cycles which correspond to one\n\t * nanosecond value, and any path through this code will inevitably\n\t * take longer than that. However, with the kernel_ns value itself,\n\t * the precision may be much lower, down to HZ granularity. If the\n\t * first sampling of TSC against kernel_ns ends in the low part of the\n\t * range, and the second in the high end of the range, we can get:\n\t *\n\t * (TSC - offset_low) * S + kns_old > (TSC - offset_high) * S + kns_new\n\t *\n\t * As the sampling errors potentially range in the thousands of cycles,\n\t * it is possible such a time value has already been observed by the\n\t * guest. To protect against this, we must compute the system time as\n\t * observed by the guest and ensure the new system time is greater.\n\t *\/\n\tmax_kernel_ns = 0;\n\tif (vcpu->hv_clock.tsc_timestamp && vcpu->last_guest_tsc) {\n\t\tmax_kernel_ns = vcpu->last_guest_tsc -\n\t\t\t\tvcpu->hv_clock.tsc_timestamp;\n\t\tmax_kernel_ns = pvclock_scale_delta(max_kernel_ns,\n\t\t\t\t vcpu->hv_clock.tsc_to_system_mul,\n\t\t\t\t vcpu->hv_clock.tsc_shift);\n\t\tmax_kernel_ns += vcpu->last_kernel_ns;\n\t}\n\n\tif (unlikely(vcpu->hw_tsc_khz != this_tsc_khz)) {\n\t\tkvm_get_time_scale(NSEC_PER_SEC \/ 1000, this_tsc_khz,\n\t\t\t\t &vcpu->hv_clock.tsc_shift,\n\t\t\t\t &vcpu->hv_clock.tsc_to_system_mul);\n\t\tvcpu->hw_tsc_khz = this_tsc_khz;\n\t}\n\n\tif (max_kernel_ns > kernel_ns)\n\t\tkernel_ns = max_kernel_ns;\n\n\t\/* With all the info we got, fill in the values *\/\n\tvcpu->hv_clock.tsc_timestamp = tsc_timestamp;\n\tvcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset;\n\tvcpu->last_kernel_ns = kernel_ns;\n\tvcpu->last_guest_tsc = tsc_timestamp;\n\tvcpu->hv_clock.flags = 0;\n\n\t\/*\n\t * The interface expects us to write an even number signaling that the\n\t * update is finished. Since the guest won't see the intermediate\n\t * state, we just increase by 2 at the end.\n\t *\/\n\tvcpu->hv_clock.version += 2;\n\n\tshared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0);\n\n\tmemcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,\n\t sizeof(vcpu->hv_clock));\n\n\tkunmap_atomic(shared_kaddr, KM_USER0);\n\n\tmark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);\n\treturn 0;\n}","target":0,"code_token_length":1114,"total_token_length":1350,"max_tokens_setting":2048} +{"idx":420758,"func":"http_session_new (http_session_t *r_session,\n const char *intended_hostname, unsigned int flags,\n http_verify_cb_t verify_cb, void *verify_cb_value)\n{\n gpg_error_t err;\n http_session_t sess;\n\n *r_session = NULL;\n\n sess = xtrycalloc (1, sizeof *sess);\n if (!sess)\n return gpg_error_from_syserror ();\n sess->magic = HTTP_SESSION_MAGIC;\n sess->refcount = 1;\n sess->flags = flags;\n sess->verify_cb = verify_cb;\n sess->verify_cb_value = verify_cb_value;\n sess->connect_timeout = 0;\n\n#if HTTP_USE_NTBTLS\n {\n (void)intended_hostname; \/* Not needed because we do not preload\n * certificates. *\/\n\n err = ntbtls_new (&sess->tls_session, NTBTLS_CLIENT);\n if (err)\n {\n log_error (\"ntbtls_new failed: %s\\n\", gpg_strerror (err));\n goto leave;\n }\n\n }\n#elif HTTP_USE_GNUTLS\n {\n const char *errpos;\n int rc;\n strlist_t sl;\n int add_system_cas = !!(flags & HTTP_FLAG_TRUST_SYS);\n int is_hkps_pool;\n\n rc = gnutls_certificate_allocate_credentials (&sess->certcred);\n if (rc < 0)\n {\n log_error (\"gnutls_certificate_allocate_credentials failed: %s\\n\",\n gnutls_strerror (rc));\n err = gpg_error (GPG_ERR_GENERAL);\n goto leave;\n }\n\n is_hkps_pool = (intended_hostname\n && !ascii_strcasecmp (intended_hostname,\n get_default_keyserver (1)));\n\n \/* If the user has not specified a CA list, and they are looking\n * for the hkps pool from sks-keyservers.net, then default to\n * Kristian's certificate authority: *\/\n if (!tls_ca_certlist && is_hkps_pool)\n {\n char *pemname = make_filename_try (gnupg_datadir (),\n \"sks-keyservers.netCA.pem\", NULL);\n if (!pemname)\n {\n err = gpg_error_from_syserror ();\n log_error (\"setting CA from file '%s' failed: %s\\n\",\n pemname, gpg_strerror (err));\n }\n else\n {\n rc = gnutls_certificate_set_x509_trust_file\n (sess->certcred, pemname, GNUTLS_X509_FMT_PEM);\n if (rc < 0)\n log_info (\"setting CA from file '%s' failed: %s\\n\",\n pemname, gnutls_strerror (rc));\n xfree (pemname);\n }\n }\n\n \/* Add configured certificates to the session. *\/\n if ((flags & HTTP_FLAG_TRUST_DEF))\n {\n for (sl = tls_ca_certlist; sl; sl = sl->next)\n {\n rc = gnutls_certificate_set_x509_trust_file\n (sess->certcred, sl->d,\n (sl->flags & 1)? GNUTLS_X509_FMT_PEM : GNUTLS_X509_FMT_DER);\n if (rc < 0)\n log_info (\"setting CA from file '%s' failed: %s\\n\",\n sl->d, gnutls_strerror (rc));\n }\n if (!tls_ca_certlist && !is_hkps_pool)\n add_system_cas = 1;\n }\n\n \/* Add system certificates to the session. *\/\n if (add_system_cas)\n {\n#if GNUTLS_VERSION_NUMBER >= 0x030014\n static int shown;\n\n rc = gnutls_certificate_set_x509_system_trust (sess->certcred);\n if (rc < 0)\n log_info (\"setting system CAs failed: %s\\n\", gnutls_strerror (rc));\n else if (!shown)\n {\n shown = 1;\n log_info (\"number of system provided CAs: %d\\n\", rc);\n }\n#endif \/* gnutls >= 3.0.20 *\/\n }\n\n \/* Add other configured certificates to the session. *\/\n if ((flags & HTTP_FLAG_TRUST_CFG))\n {\n for (sl = cfg_ca_certlist; sl; sl = sl->next)\n {\n rc = gnutls_certificate_set_x509_trust_file\n (sess->certcred, sl->d,\n (sl->flags & 1)? GNUTLS_X509_FMT_PEM : GNUTLS_X509_FMT_DER);\n if (rc < 0)\n log_info (\"setting extra CA from file '%s' failed: %s\\n\",\n sl->d, gnutls_strerror (rc));\n }\n }\n\n\n rc = gnutls_init (&sess->tls_session, GNUTLS_CLIENT);\n if (rc < 0)\n {\n log_error (\"gnutls_init failed: %s\\n\", gnutls_strerror (rc));\n err = gpg_error (GPG_ERR_GENERAL);\n goto leave;\n }\n \/* A new session has the transport ptr set to (void*(-1), we need\n it to be NULL. *\/\n gnutls_transport_set_ptr (sess->tls_session, NULL);\n\n rc = gnutls_priority_set_direct (sess->tls_session,\n \"NORMAL\",\n &errpos);\n if (rc < 0)\n {\n log_error (\"gnutls_priority_set_direct failed at '%s': %s\\n\",\n errpos, gnutls_strerror (rc));\n err = gpg_error (GPG_ERR_GENERAL);\n goto leave;\n }\n\n rc = gnutls_credentials_set (sess->tls_session,\n GNUTLS_CRD_CERTIFICATE, sess->certcred);\n if (rc < 0)\n {\n log_error (\"gnutls_credentials_set failed: %s\\n\", gnutls_strerror (rc));\n err = gpg_error (GPG_ERR_GENERAL);\n goto leave;\n }\n }\n#else \/*!HTTP_USE_GNUTLS && !HTTP_USE_NTBTLS*\/\n {\n (void)intended_hostname;\n (void)flags;\n }\n#endif \/*!HTTP_USE_GNUTLS && !HTTP_USE_NTBTLS*\/\n\n if (opt_debug > 1)\n log_debug (\"http.c:session_new: sess %p created\\n\", sess);\n err = 0;\n\n#if USE_TLS\n leave:\n#endif \/*USE_TLS*\/\n if (err)\n http_session_unref (sess);\n else\n *r_session = sess;\n\n return err;\n}","target":0,"code_token_length":1446,"total_token_length":1682,"max_tokens_setting":2048} +{"idx":59648,"func":"void test_nghttp2_session_stream_attach_item(void) {\n nghttp2_session *session;\n nghttp2_session_callbacks callbacks;\n nghttp2_stream *a, *b, *c, *d, *e;\n nghttp2_outbound_item *da, *db, *dc, *dd;\n nghttp2_mem *mem;\n\n mem = nghttp2_mem_default();\n\n memset(&callbacks, 0, sizeof(callbacks));\n\n nghttp2_session_server_new(&session, &callbacks, NULL);\n\n a = open_stream(session, 1);\n b = open_stream_with_dep(session, 3, a);\n c = open_stream_with_dep(session, 5, a);\n d = open_stream_with_dep(session, 7, c);\n\n \/* a\n * |\n * c--b\n * |\n * d\n *\/\n\n db = create_data_ob_item(mem);\n\n nghttp2_stream_attach_item(b, db);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(!c->queued);\n CU_ASSERT(!d->queued);\n\n CU_ASSERT(1 == nghttp2_pq_size(&a->obq));\n\n \/* Attach item to c *\/\n dc = create_data_ob_item(mem);\n\n nghttp2_stream_attach_item(c, dc);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(!d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n\n \/* Attach item to a *\/\n da = create_data_ob_item(mem);\n\n nghttp2_stream_attach_item(a, da);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(!d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n\n \/* Detach item from a *\/\n nghttp2_stream_detach_item(a);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(!d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n\n \/* Attach item to d *\/\n dd = create_data_ob_item(mem);\n\n nghttp2_stream_attach_item(d, dd);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n CU_ASSERT(1 == nghttp2_pq_size(&c->obq));\n\n \/* Detach item from c *\/\n nghttp2_stream_detach_item(c);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n CU_ASSERT(1 == nghttp2_pq_size(&c->obq));\n\n \/* Detach item from b *\/\n nghttp2_stream_detach_item(b);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(!b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(d->queued);\n\n CU_ASSERT(1 == nghttp2_pq_size(&a->obq));\n\n \/* exercises insertion *\/\n e = open_stream_with_dep_excl(session, 9, a);\n\n \/* a\n * |\n * e\n * |\n * c--b\n * |\n * d\n *\/\n\n CU_ASSERT(a->queued);\n CU_ASSERT(e->queued);\n CU_ASSERT(!b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(d->queued);\n\n CU_ASSERT(1 == nghttp2_pq_size(&a->obq));\n CU_ASSERT(1 == nghttp2_pq_size(&e->obq));\n CU_ASSERT(nghttp2_pq_empty(&b->obq));\n CU_ASSERT(1 == nghttp2_pq_size(&c->obq));\n CU_ASSERT(nghttp2_pq_empty(&d->obq));\n\n \/* exercises deletion *\/\n nghttp2_stream_dep_remove(e);\n\n \/* a\n * |\n * c--b\n * |\n * d\n *\/\n\n CU_ASSERT(a->queued);\n CU_ASSERT(!b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(d->queued);\n\n CU_ASSERT(1 == nghttp2_pq_size(&a->obq));\n CU_ASSERT(nghttp2_pq_empty(&b->obq));\n CU_ASSERT(1 == nghttp2_pq_size(&c->obq));\n CU_ASSERT(nghttp2_pq_empty(&d->obq));\n\n \/* e's weight 16 is distributed equally among c and b, both now have\n weight 8 each. *\/\n CU_ASSERT(8 == b->weight);\n CU_ASSERT(8 == c->weight);\n\n \/* da, db, dc have been detached *\/\n nghttp2_outbound_item_free(da, mem);\n nghttp2_outbound_item_free(db, mem);\n nghttp2_outbound_item_free(dc, mem);\n free(da);\n free(db);\n free(dc);\n\n nghttp2_session_del(session);\n\n nghttp2_session_server_new(&session, &callbacks, NULL);\n\n a = open_stream(session, 1);\n b = open_stream_with_dep(session, 3, a);\n c = open_stream_with_dep(session, 5, a);\n d = open_stream_with_dep(session, 7, c);\n\n \/* a\n * |\n * c--b\n * |\n * d\n *\/\n\n da = create_data_ob_item(mem);\n db = create_data_ob_item(mem);\n dc = create_data_ob_item(mem);\n\n nghttp2_stream_attach_item(a, da);\n nghttp2_stream_attach_item(b, db);\n nghttp2_stream_attach_item(c, dc);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(!d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n CU_ASSERT(nghttp2_pq_empty(&b->obq));\n CU_ASSERT(nghttp2_pq_empty(&c->obq));\n CU_ASSERT(nghttp2_pq_empty(&d->obq));\n\n \/* Detach item from a *\/\n nghttp2_stream_detach_item(a);\n\n CU_ASSERT(a->queued);\n CU_ASSERT(b->queued);\n CU_ASSERT(c->queued);\n CU_ASSERT(!d->queued);\n\n CU_ASSERT(2 == nghttp2_pq_size(&a->obq));\n CU_ASSERT(nghttp2_pq_empty(&b->obq));\n CU_ASSERT(nghttp2_pq_empty(&c->obq));\n CU_ASSERT(nghttp2_pq_empty(&d->obq));\n\n \/* da has been detached *\/\n nghttp2_outbound_item_free(da, mem);\n free(da);\n\n nghttp2_session_del(session);\n}","target":0,"code_token_length":1508,"total_token_length":1744,"max_tokens_setting":2048} +{"idx":211563,"func":"PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, zend_ulong opt, zend_string **sql)\n{\n\tzval *val, converted;\n\tchar buf[256];\n\tchar *tmp;\n\tsmart_str querystr = {0};\n\tint ret = FAILURE;\n\tzend_ulong num_idx;\n\tzend_string *fld;\n\n\tassert(pg_link != NULL);\n\tassert(table != NULL);\n\tassert(Z_TYPE_P(var_array) == IS_ARRAY);\n\n\tZVAL_UNDEF(&converted);\n\tif (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) {\n\t\tsmart_str_appends(&querystr, \"INSERT INTO \");\n\t\tbuild_tablename(&querystr, pg_link, table);\n\t\tsmart_str_appends(&querystr, \" DEFAULT VALUES\");\n\n\t\tgoto no_values;\n\t}\n\n\t\/* convert input array if needed *\/\n\tif (!(opt & (PGSQL_DML_NO_CONV|PGSQL_DML_ESCAPE))) {\n\t\tarray_init(&converted);\n\t\tif (php_pgsql_convert(pg_link, table, var_array, &converted, (opt & PGSQL_CONV_OPTS)) == FAILURE) {\n\t\t\tgoto cleanup;\n\t\t}\n\t\tvar_array = &converted;\n\t}\n\n\tsmart_str_appends(&querystr, \"INSERT INTO \");\n\tbuild_tablename(&querystr, pg_link, table);\n\tsmart_str_appends(&querystr, \" (\");\n\n\tZEND_HASH_FOREACH_KEY(Z_ARRVAL_P(var_array), num_idx, fld) {\n\t\tif (fld == NULL) {\n\t\t\tphp_error_docref(NULL, E_NOTICE, \"Expects associative array for values to be inserted\");\n\t\t\tgoto cleanup;\n\t\t}\n\t\tif (opt & PGSQL_DML_ESCAPE) {\n\t\t\ttmp = PGSQLescapeIdentifier(pg_link, fld->val, fld->len + 1);\n\t\t\tsmart_str_appends(&querystr, tmp);\n\t\t\tPGSQLfree(tmp);\n\t\t} else {\n\t\t\tsmart_str_appendl(&querystr, fld->val, fld->len);\n\t\t}\n\t\tsmart_str_appendc(&querystr, ',');\n\t} ZEND_HASH_FOREACH_END();\n\tquerystr.s->len--;\n\tsmart_str_appends(&querystr, \") VALUES (\");\n\t\n\t\/* make values string *\/\n\tZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(var_array), val) {\n\t\t\/* we can avoid the key_type check here, because we tested it in the other loop *\/\n\t\tswitch (Z_TYPE_P(val)) {\n\t\t\tcase IS_STRING:\n\t\t\t\tif (opt & PGSQL_DML_ESCAPE) {\n\t\t\t\t\tsize_t new_len;\n\t\t\t\t\tchar *tmp;\n\t\t\t\t\ttmp = (char *)safe_emalloc(Z_STRLEN_P(val), 2, 1);\n\t\t\t\t\tnew_len = PQescapeStringConn(pg_link, tmp, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL);\n\t\t\t\t\tsmart_str_appendc(&querystr, '\\'');\n\t\t\t\t\tsmart_str_appendl(&querystr, tmp, new_len);\n\t\t\t\t\tsmart_str_appendc(&querystr, '\\'');\n\t\t\t\t\tefree(tmp);\n\t\t\t\t} else {\n\t\t\t\t\tsmart_str_appendl(&querystr, Z_STRVAL_P(val), Z_STRLEN_P(val));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase IS_LONG:\n\t\t\t\tsmart_str_append_long(&querystr, Z_LVAL_P(val));\n\t\t\t\tbreak;\n\t\t\tcase IS_DOUBLE:\n\t\t\t\tsmart_str_appendl(&querystr, buf, snprintf(buf, sizeof(buf), \"%F\", Z_DVAL_P(val)));\n\t\t\t\tbreak;\n\t\t\tcase IS_NULL:\n\t\t\t\tsmart_str_appendl(&querystr, \"NULL\", sizeof(\"NULL\")-1);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tphp_error_docref(NULL, E_WARNING, \"Expects scaler values. type = %d\", Z_TYPE_P(val));\n\t\t\t\tgoto cleanup;\n\t\t\t\tbreak;\n\t\t}\n\t\tsmart_str_appendc(&querystr, ',');\n\t} ZEND_HASH_FOREACH_END();\n\t\/* Remove the trailing \",\" *\/\n\tquerystr.s->len--;\n\tsmart_str_appends(&querystr, \");\");\n\nno_values:\n\n\tsmart_str_0(&querystr);\n\n\tif ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&\n\t\tdo_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS)) == 0) {\n\t\tret = SUCCESS;\n\t}\n\telse if (opt & PGSQL_DML_STRING) {\n\t\tret = SUCCESS;\n\t}\n\t\ncleanup:\n\tzval_ptr_dtor(&converted);\n\tif (ret == SUCCESS && (opt & PGSQL_DML_STRING)) {\n\t\t*sql = querystr.s;\n\t}\n\telse {\n\t\tsmart_str_free(&querystr);\n\t}\n\treturn ret;\n}\n","target":0,"code_token_length":977,"total_token_length":1213,"max_tokens_setting":2048} +{"idx":288301,"func":"int MapOpenSSLErrorSSL() {\n unsigned long error_code;\n do {\n error_code = ERR_get_error();\n if (error_code == 0)\n return ERR_SSL_PROTOCOL_ERROR;\n } while (ERR_GET_LIB(error_code) != ERR_LIB_SSL);\n\n DVLOG(1) << \"OpenSSL SSL error, reason: \" << ERR_GET_REASON(error_code)\n << \", name: \" << ERR_error_string(error_code, NULL);\n switch (ERR_GET_REASON(error_code)) {\n case SSL_R_READ_TIMEOUT_EXPIRED:\n return ERR_TIMED_OUT;\n case SSL_R_BAD_RESPONSE_ARGUMENT:\n return ERR_INVALID_ARGUMENT;\n case SSL_R_UNKNOWN_CERTIFICATE_TYPE:\n case SSL_R_UNKNOWN_CIPHER_TYPE:\n case SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE:\n case SSL_R_UNKNOWN_PKEY_TYPE:\n case SSL_R_UNKNOWN_REMOTE_ERROR_TYPE:\n case SSL_R_UNKNOWN_SSL_VERSION:\n return ERR_NOT_IMPLEMENTED;\n case SSL_R_UNSUPPORTED_SSL_VERSION:\n case SSL_R_NO_CIPHER_MATCH:\n case SSL_R_NO_SHARED_CIPHER:\n case SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY:\n case SSL_R_TLSV1_ALERT_PROTOCOL_VERSION:\n case SSL_R_UNSUPPORTED_PROTOCOL:\n return ERR_SSL_VERSION_OR_CIPHER_MISMATCH;\n case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE:\n case SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE:\n case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED:\n case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED:\n case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN:\n case SSL_R_TLSV1_ALERT_ACCESS_DENIED:\n case SSL_R_TLSV1_ALERT_UNKNOWN_CA:\n return ERR_BAD_SSL_CLIENT_AUTH_CERT;\n case SSL_R_BAD_DECOMPRESSION:\n case SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE:\n return ERR_SSL_DECOMPRESSION_FAILURE_ALERT;\n case SSL_R_SSLV3_ALERT_BAD_RECORD_MAC:\n return ERR_SSL_BAD_RECORD_MAC_ALERT;\n case SSL_R_TLSV1_ALERT_DECRYPT_ERROR:\n return ERR_SSL_DECRYPT_ERROR_ALERT;\n case SSL_R_TLSV1_UNRECOGNIZED_NAME:\n return ERR_SSL_UNRECOGNIZED_NAME_ALERT;\n case SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED:\n return ERR_SSL_UNSAFE_NEGOTIATION;\n case SSL_R_WRONG_NUMBER_OF_KEY_BITS:\n return ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY;\n case SSL_R_UNKNOWN_PROTOCOL:\n case SSL_R_SSL_HANDSHAKE_FAILURE:\n case SSL_R_DECRYPTION_FAILED:\n case SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC:\n case SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG:\n case SSL_R_DIGEST_CHECK_FAILED:\n case SSL_R_DUPLICATE_COMPRESSION_ID:\n case SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER:\n case SSL_R_ENCRYPTED_LENGTH_TOO_LONG:\n case SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST:\n case SSL_R_EXCESSIVE_MESSAGE_SIZE:\n case SSL_R_EXTRA_DATA_IN_MESSAGE:\n case SSL_R_GOT_A_FIN_BEFORE_A_CCS:\n case SSL_R_ILLEGAL_PADDING:\n case SSL_R_INVALID_CHALLENGE_LENGTH:\n case SSL_R_INVALID_COMMAND:\n case SSL_R_INVALID_PURPOSE:\n case SSL_R_INVALID_STATUS_RESPONSE:\n case SSL_R_INVALID_TICKET_KEYS_LENGTH:\n case SSL_R_KEY_ARG_TOO_LONG:\n case SSL_R_READ_WRONG_PACKET_TYPE:\n case SSL_AD_REASON_OFFSET + SSL_AD_CLOSE_NOTIFY:\n case SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE:\n case SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE:\n case SSL_R_SSLV3_ALERT_NO_CERTIFICATE:\n case SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER:\n case SSL_R_TLSV1_ALERT_DECODE_ERROR:\n case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED:\n case SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION:\n case SSL_R_TLSV1_ALERT_INTERNAL_ERROR:\n case SSL_R_TLSV1_ALERT_NO_RENEGOTIATION:\n case SSL_R_TLSV1_ALERT_RECORD_OVERFLOW:\n case SSL_R_TLSV1_ALERT_USER_CANCELLED:\n return ERR_SSL_PROTOCOL_ERROR;\n default:\n LOG(WARNING) << \"Unmapped error reason: \" << ERR_GET_REASON(error_code);\n return ERR_FAILED;\n }\n}\n","target":1,"code_token_length":891,"total_token_length":1127,"max_tokens_setting":2048} +{"idx":178005,"func":"status_t OMXCodec::configureCodec(const sp &meta) {\n ALOGV(\"configureCodec protected=%d\",\n (mFlags & kEnableGrallocUsageProtected) ? 1 : 0);\n\n if (!(mFlags & kIgnoreCodecSpecificData)) {\n uint32_t type;\n const void *data;\n size_t size;\n if (meta->findData(kKeyESDS, &type, &data, &size)) {\n ESDS esds((const char *)data, size);\n CHECK_EQ(esds.InitCheck(), (status_t)OK);\n\n const void *codec_specific_data;\n size_t codec_specific_data_size;\n esds.getCodecSpecificInfo(\n &codec_specific_data, &codec_specific_data_size);\n\n addCodecSpecificData(\n codec_specific_data, codec_specific_data_size);\n } else if (meta->findData(kKeyAVCC, &type, &data, &size)) {\n\n unsigned profile, level;\n status_t err;\n if ((err = parseAVCCodecSpecificData(\n data, size, &profile, &level)) != OK) {\n ALOGE(\"Malformed AVC codec specific data.\");\n return err;\n }\n\n CODEC_LOGI(\n \"AVC profile = %u (%s), level = %u\",\n profile, AVCProfileToString(profile), level);\n } else if (meta->findData(kKeyHVCC, &type, &data, &size)) {\n\n unsigned profile, level;\n status_t err;\n if ((err = parseHEVCCodecSpecificData(\n data, size, &profile, &level)) != OK) {\n ALOGE(\"Malformed HEVC codec specific data.\");\n return err;\n }\n\n CODEC_LOGI(\n \"HEVC profile = %u , level = %u\",\n profile, level);\n } else if (meta->findData(kKeyVorbisInfo, &type, &data, &size)) {\n addCodecSpecificData(data, size);\n\n CHECK(meta->findData(kKeyVorbisBooks, &type, &data, &size));\n addCodecSpecificData(data, size);\n } else if (meta->findData(kKeyOpusHeader, &type, &data, &size)) {\n addCodecSpecificData(data, size);\n\n CHECK(meta->findData(kKeyOpusCodecDelay, &type, &data, &size));\n addCodecSpecificData(data, size);\n CHECK(meta->findData(kKeyOpusSeekPreRoll, &type, &data, &size));\n addCodecSpecificData(data, size);\n }\n }\n\n int32_t bitRate = 0;\n if (mIsEncoder) {\n CHECK(meta->findInt32(kKeyBitRate, &bitRate));\n }\n if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB, mMIME)) {\n setAMRFormat(false \/* isWAMR *\/, bitRate);\n } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB, mMIME)) {\n setAMRFormat(true \/* isWAMR *\/, bitRate);\n } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AAC, mMIME)) {\n int32_t numChannels, sampleRate, aacProfile;\n CHECK(meta->findInt32(kKeyChannelCount, &numChannels));\n CHECK(meta->findInt32(kKeySampleRate, &sampleRate));\n\n if (!meta->findInt32(kKeyAACProfile, &aacProfile)) {\n aacProfile = OMX_AUDIO_AACObjectNull;\n }\n\n int32_t isADTS;\n if (!meta->findInt32(kKeyIsADTS, &isADTS)) {\n isADTS = false;\n }\n\n status_t err = setAACFormat(numChannels, sampleRate, bitRate, aacProfile, isADTS);\n if (err != OK) {\n CODEC_LOGE(\"setAACFormat() failed (err = %d)\", err);\n return err;\n }\n } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_MPEG, mMIME)) {\n int32_t numChannels, sampleRate;\n if (meta->findInt32(kKeyChannelCount, &numChannels)\n && meta->findInt32(kKeySampleRate, &sampleRate)) {\n setRawAudioFormat(\n mIsEncoder ? kPortIndexInput : kPortIndexOutput,\n sampleRate,\n numChannels);\n }\n } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AC3, mMIME)) {\n int32_t numChannels;\n int32_t sampleRate;\n CHECK(meta->findInt32(kKeyChannelCount, &numChannels));\n CHECK(meta->findInt32(kKeySampleRate, &sampleRate));\n\n status_t err = setAC3Format(numChannels, sampleRate);\n if (err != OK) {\n CODEC_LOGE(\"setAC3Format() failed (err = %d)\", err);\n return err;\n }\n } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_G711_ALAW, mMIME)\n || !strcasecmp(MEDIA_MIMETYPE_AUDIO_G711_MLAW, mMIME)) {\n\n int32_t sampleRate;\n int32_t numChannels;\n CHECK(meta->findInt32(kKeyChannelCount, &numChannels));\n if (!meta->findInt32(kKeySampleRate, &sampleRate)) {\n sampleRate = 8000;\n }\n\n setG711Format(sampleRate, numChannels);\n } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_RAW, mMIME)) {\n CHECK(!mIsEncoder);\n\n int32_t numChannels, sampleRate;\n CHECK(meta->findInt32(kKeyChannelCount, &numChannels));\n CHECK(meta->findInt32(kKeySampleRate, &sampleRate));\n\n setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);\n }\n\n if (!strncasecmp(mMIME, \"video\/\", 6)) {\n\n if (mIsEncoder) {\n setVideoInputFormat(mMIME, meta);\n } else {\n status_t err = setVideoOutputFormat(\n mMIME, meta);\n\n if (err != OK) {\n return err;\n }\n }\n }\n\n int32_t maxInputSize;\n if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {\n setMinBufferSize(kPortIndexInput, (OMX_U32)maxInputSize);\n }\n\n initOutputFormat(meta);\n\n if (mNativeWindow != NULL\n && !mIsEncoder\n && !strncasecmp(mMIME, \"video\/\", 6)\n && !strncmp(mComponentName, \"OMX.\", 4)) {\n status_t err = initNativeWindow();\n if (err != OK) {\n return err;\n }\n }\n\n return OK;\n}\n","target":0,"code_token_length":1417,"total_token_length":1653,"max_tokens_setting":2048} +{"idx":392364,"func":"xmlEscapeEntities(unsigned char* out, int *outlen,\n const xmlChar* in, int *inlen) {\n unsigned char* outstart = out;\n const unsigned char* base = in;\n unsigned char* outend = out + *outlen;\n const unsigned char* inend;\n int val;\n\n inend = in + (*inlen);\n\n while ((in < inend) && (out < outend)) {\n\tif (*in == '<') {\n\t if (outend - out < 4) break;\n\t *out++ = '&';\n\t *out++ = 'l';\n\t *out++ = 't';\n\t *out++ = ';';\n\t in++;\n\t continue;\n\t} else if (*in == '>') {\n\t if (outend - out < 4) break;\n\t *out++ = '&';\n\t *out++ = 'g';\n\t *out++ = 't';\n\t *out++ = ';';\n\t in++;\n\t continue;\n\t} else if (*in == '&') {\n\t if (outend - out < 5) break;\n\t *out++ = '&';\n\t *out++ = 'a';\n\t *out++ = 'm';\n\t *out++ = 'p';\n\t *out++ = ';';\n\t in++;\n\t continue;\n\t} else if (((*in >= 0x20) && (*in < 0x80)) ||\n\t (*in == '\\n') || (*in == '\\t')) {\n\t \/*\n\t * default case, just copy !\n\t *\/\n\t *out++ = *in++;\n\t continue;\n\t} else if (*in >= 0x80) {\n\t \/*\n\t * We assume we have UTF-8 input.\n\t *\/\n\t if (outend - out < 11) break;\n\n\t if (*in < 0xC0) {\n\t\txmlSaveErr(XML_SAVE_NOT_UTF8, NULL, NULL);\n\t\tin++;\n\t\tgoto error;\n\t } else if (*in < 0xE0) {\n\t\tif (inend - in < 2) break;\n\t\tval = (in[0]) & 0x1F;\n\t\tval <<= 6;\n\t\tval |= (in[1]) & 0x3F;\n\t\tin += 2;\n\t } else if (*in < 0xF0) {\n\t\tif (inend - in < 3) break;\n\t\tval = (in[0]) & 0x0F;\n\t\tval <<= 6;\n\t\tval |= (in[1]) & 0x3F;\n\t\tval <<= 6;\n\t\tval |= (in[2]) & 0x3F;\n\t\tin += 3;\n\t } else if (*in < 0xF8) {\n\t\tif (inend - in < 4) break;\n\t\tval = (in[0]) & 0x07;\n\t\tval <<= 6;\n\t\tval |= (in[1]) & 0x3F;\n\t\tval <<= 6;\n\t\tval |= (in[2]) & 0x3F;\n\t\tval <<= 6;\n\t\tval |= (in[3]) & 0x3F;\n\t\tin += 4;\n\t } else {\n\t\txmlSaveErr(XML_SAVE_CHAR_INVALID, NULL, NULL);\n\t\tin++;\n\t\tgoto error;\n\t }\n\t if (!IS_CHAR(val)) {\n\t\txmlSaveErr(XML_SAVE_CHAR_INVALID, NULL, NULL);\n\t\tin++;\n\t\tgoto error;\n\t }\n\n\t \/*\n\t * We could do multiple things here. Just save as a char ref\n\t *\/\n\t out = xmlSerializeHexCharRef(out, val);\n\t} else if (IS_BYTE_CHAR(*in)) {\n\t if (outend - out < 6) break;\n\t out = xmlSerializeHexCharRef(out, *in++);\n\t} else {\n\t xmlGenericError(xmlGenericErrorContext,\n\t\t\"xmlEscapeEntities : char out of range\\n\");\n\t in++;\n\t goto error;\n\t}\n }\n *outlen = out - outstart;\n *inlen = in - base;\n return(0);\nerror:\n *outlen = out - outstart;\n *inlen = in - base;\n return(-1);\n}","target":0,"code_token_length":896,"total_token_length":1132,"max_tokens_setting":2048} +{"idx":4597,"func":"static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_1read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_self = 0;\n Py_ssize_t __pyx_v_n_items;\n PyObject *__pyx_v_buf = 0;\n PyObject *__pyx_r = 0;\n __Pyx_RefNannyDeclarations\n __Pyx_RefNannySetupContext(\"read_items (wrapper)\", 0);\n {\n static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_n_items,&__pyx_n_s_buf,0};\n PyObject* values[3] = {0,0,0};\n if (unlikely(__pyx_kwds)) {\n Py_ssize_t kw_args;\n const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);\n switch (pos_args) {\n case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);\n CYTHON_FALLTHROUGH;\n case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);\n CYTHON_FALLTHROUGH;\n case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);\n CYTHON_FALLTHROUGH;\n case 0: break;\n default: goto __pyx_L5_argtuple_error;\n }\n kw_args = PyDict_Size(__pyx_kwds);\n switch (pos_args) {\n case 0:\n if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;\n else goto __pyx_L5_argtuple_error;\n CYTHON_FALLTHROUGH;\n case 1:\n if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;\n else {\n __Pyx_RaiseArgtupleInvalid(\"read_items\", 1, 3, 3, 1); __PYX_ERR(0, 118, __pyx_L3_error)\n }\n CYTHON_FALLTHROUGH;\n case 2:\n if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;\n else {\n __Pyx_RaiseArgtupleInvalid(\"read_items\", 1, 3, 3, 2); __PYX_ERR(0, 118, __pyx_L3_error)\n }\n }\n if (unlikely(kw_args > 0)) {\n if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, \"read_items\") < 0)) __PYX_ERR(0, 118, __pyx_L3_error)\n }\n } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {\n goto __pyx_L5_argtuple_error;\n } else {\n values[0] = PyTuple_GET_ITEM(__pyx_args, 0);\n values[1] = PyTuple_GET_ITEM(__pyx_args, 1);\n values[2] = PyTuple_GET_ITEM(__pyx_args, 2);\n }\n __pyx_v_self = values[0];\n __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error)\n __pyx_v_buf = values[2];\n }\n goto __pyx_L4_argument_unpacking_done;\n __pyx_L5_argtuple_error:;\n __Pyx_RaiseArgtupleInvalid(\"read_items\", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 118, __pyx_L3_error)\n __pyx_L3_error:;\n __Pyx_AddTraceback(\"clickhouse_driver.columns.stringcolumn.ByteFixedString.read_items\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n __Pyx_RefNannyFinishContext();\n return NULL;\n __pyx_L4_argument_unpacking_done:;\n __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_read_items(__pyx_self, __pyx_v_self, __pyx_v_n_items, __pyx_v_buf);\n\n \/* function exit code *\/\n __Pyx_RefNannyFinishContext();\n return __pyx_r;\n}","target":1,"code_token_length":1024,"total_token_length":1260,"max_tokens_setting":2048} +{"idx":25619,"func":"static bool get_actual_variable_range ( PlannerInfo * root , VariableStatData * vardata , Oid sortop , Datum * min , Datum * max ) {\n bool have_data = false ;\n RelOptInfo * rel = vardata -> rel ;\n RangeTblEntry * rte ;\n ListCell * lc ;\n if ( rel == NULL || rel -> indexlist == NIL ) return false ;\n rte = root -> simple_rte_array [ rel -> relid ] ;\n Assert ( rte -> rtekind == RTE_RELATION ) ;\n foreach ( lc , rel -> indexlist ) {\n IndexOptInfo * index = ( IndexOptInfo * ) lfirst ( lc ) ;\n ScanDirection indexscandir ;\n if ( index -> relam != BTREE_AM_OID ) continue ;\n if ( index -> indpred != NIL ) continue ;\n if ( index -> hypothetical ) continue ;\n if ( ! match_index_to_operand ( vardata -> var , 0 , index ) ) continue ;\n switch ( get_op_opfamily_strategy ( sortop , index -> sortopfamily [ 0 ] ) ) {\n case BTLessStrategyNumber : if ( index -> reverse_sort [ 0 ] ) indexscandir = BackwardScanDirection ;\n else indexscandir = ForwardScanDirection ;\n break ;\n case BTGreaterStrategyNumber : if ( index -> reverse_sort [ 0 ] ) indexscandir = ForwardScanDirection ;\n else indexscandir = BackwardScanDirection ;\n break ;\n default : continue ;\n }\n {\n EState * estate ;\n ExprContext * econtext ;\n MemoryContext tmpcontext ;\n MemoryContext oldcontext ;\n Relation heapRel ;\n Relation indexRel ;\n IndexInfo * indexInfo ;\n TupleTableSlot * slot ;\n int16 typLen ;\n bool typByVal ;\n ScanKeyData scankeys [ 1 ] ;\n IndexScanDesc index_scan ;\n HeapTuple tup ;\n Datum values [ INDEX_MAX_KEYS ] ;\n bool isnull [ INDEX_MAX_KEYS ] ;\n SnapshotData SnapshotDirty ;\n estate = CreateExecutorState ( ) ;\n econtext = GetPerTupleExprContext ( estate ) ;\n tmpcontext = econtext -> ecxt_per_tuple_memory ;\n oldcontext = MemoryContextSwitchTo ( tmpcontext ) ;\n heapRel = heap_open ( rte -> relid , NoLock ) ;\n indexRel = index_open ( index -> indexoid , AccessShareLock ) ;\n indexInfo = BuildIndexInfo ( indexRel ) ;\n slot = MakeSingleTupleTableSlot ( RelationGetDescr ( heapRel ) ) ;\n econtext -> ecxt_scantuple = slot ;\n get_typlenbyval ( vardata -> atttype , & typLen , & typByVal ) ;\n InitDirtySnapshot ( SnapshotDirty ) ;\n ScanKeyEntryInitialize ( & scankeys [ 0 ] , SK_ISNULL | SK_SEARCHNOTNULL , 1 , InvalidStrategy , InvalidOid , InvalidOid , InvalidOid , ( Datum ) 0 ) ;\n have_data = true ;\n if ( min ) {\n index_scan = index_beginscan ( heapRel , indexRel , & SnapshotDirty , 1 , 0 ) ;\n index_rescan ( index_scan , scankeys , 1 , NULL , 0 ) ;\n if ( ( tup = index_getnext ( index_scan , indexscandir ) ) != NULL ) {\n ExecStoreTuple ( tup , slot , InvalidBuffer , false ) ;\n FormIndexDatum ( indexInfo , slot , estate , values , isnull ) ;\n if ( isnull [ 0 ] ) elog ( ERROR , \"found unexpected null value in index \\\"%s\\\"\" , RelationGetRelationName ( indexRel ) ) ;\n MemoryContextSwitchTo ( oldcontext ) ;\n * min = datumCopy ( values [ 0 ] , typByVal , typLen ) ;\n MemoryContextSwitchTo ( tmpcontext ) ;\n }\n else have_data = false ;\n index_endscan ( index_scan ) ;\n }\n if ( max && have_data ) {\n index_scan = index_beginscan ( heapRel , indexRel , & SnapshotDirty , 1 , 0 ) ;\n index_rescan ( index_scan , scankeys , 1 , NULL , 0 ) ;\n if ( ( tup = index_getnext ( index_scan , - indexscandir ) ) != NULL ) {\n ExecStoreTuple ( tup , slot , InvalidBuffer , false ) ;\n FormIndexDatum ( indexInfo , slot , estate , values , isnull ) ;\n if ( isnull [ 0 ] ) elog ( ERROR , \"found unexpected null value in index \\\"%s\\\"\" , RelationGetRelationName ( indexRel ) ) ;\n MemoryContextSwitchTo ( oldcontext ) ;\n * max = datumCopy ( values [ 0 ] , typByVal , typLen ) ;\n MemoryContextSwitchTo ( tmpcontext ) ;\n }\n else have_data = false ;\n index_endscan ( index_scan ) ;\n }\n ExecDropSingleTupleTableSlot ( slot ) ;\n index_close ( indexRel , AccessShareLock ) ;\n heap_close ( heapRel , NoLock ) ;\n MemoryContextSwitchTo ( oldcontext ) ;\n FreeExecutorState ( estate ) ;\n break ;\n }\n }\n return have_data ;\n }","target":0,"code_token_length":1034,"total_token_length":1270,"max_tokens_setting":2048} +{"idx":374268,"func":"aclparse(const char *s, AclItem *aip)\n{\n\tAclMode\t\tprivs,\n\t\t\t\tgoption,\n\t\t\t\tread;\n\tchar\t\tname[NAMEDATALEN];\n\tchar\t\tname2[NAMEDATALEN];\n\n\tAssert(s && aip);\n\n#ifdef ACLDEBUG\n\telog(LOG, \"aclparse: input = \\\"%s\\\"\", s);\n#endif\n\ts = getid(s, name);\n\tif (*s != '=')\n\t{\n\t\t\/* we just read a keyword, not a name *\/\n\t\tif (strcmp(name, \"group\") != 0 && strcmp(name, \"user\") != 0)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t\t errmsg(\"unrecognized key word: \\\"%s\\\"\", name),\n\t\t\t\t\t errhint(\"ACL key word must be \\\"group\\\" or \\\"user\\\".\")));\n\t\ts = getid(s, name);\t\t\/* move s to the name beyond the keyword *\/\n\t\tif (name[0] == '\\0')\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t\t errmsg(\"missing name\"),\n\t\t\t\t\t errhint(\"A name must follow the \\\"group\\\" or \\\"user\\\" key word.\")));\n\t}\n\n\tif (*s != '=')\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t errmsg(\"missing \\\"=\\\" sign\")));\n\n\tprivs = goption = ACL_NO_RIGHTS;\n\n\tfor (++s, read = 0; isalpha((unsigned char) *s) || *s == '*'; s++)\n\t{\n\t\tswitch (*s)\n\t\t{\n\t\t\tcase '*':\n\t\t\t\tgoption |= read;\n\t\t\t\tbreak;\n\t\t\tcase ACL_INSERT_CHR:\n\t\t\t\tread = ACL_INSERT;\n\t\t\t\tbreak;\n\t\t\tcase ACL_SELECT_CHR:\n\t\t\t\tread = ACL_SELECT;\n\t\t\t\tbreak;\n\t\t\tcase ACL_UPDATE_CHR:\n\t\t\t\tread = ACL_UPDATE;\n\t\t\t\tbreak;\n\t\t\tcase ACL_DELETE_CHR:\n\t\t\t\tread = ACL_DELETE;\n\t\t\t\tbreak;\n\t\t\tcase ACL_TRUNCATE_CHR:\n\t\t\t\tread = ACL_TRUNCATE;\n\t\t\t\tbreak;\n\t\t\tcase ACL_REFERENCES_CHR:\n\t\t\t\tread = ACL_REFERENCES;\n\t\t\t\tbreak;\n\t\t\tcase ACL_TRIGGER_CHR:\n\t\t\t\tread = ACL_TRIGGER;\n\t\t\t\tbreak;\n\t\t\tcase ACL_EXECUTE_CHR:\n\t\t\t\tread = ACL_EXECUTE;\n\t\t\t\tbreak;\n\t\t\tcase ACL_USAGE_CHR:\n\t\t\t\tread = ACL_USAGE;\n\t\t\t\tbreak;\n\t\t\tcase ACL_CREATE_CHR:\n\t\t\t\tread = ACL_CREATE;\n\t\t\t\tbreak;\n\t\t\tcase ACL_CREATE_TEMP_CHR:\n\t\t\t\tread = ACL_CREATE_TEMP;\n\t\t\t\tbreak;\n\t\t\tcase ACL_CONNECT_CHR:\n\t\t\t\tread = ACL_CONNECT;\n\t\t\t\tbreak;\n\t\t\tcase 'R':\t\t\t\/* ignore old RULE privileges *\/\n\t\t\t\tread = 0;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t\t errmsg(\"invalid mode character: must be one of \\\"%s\\\"\",\n\t\t\t\t\t\t\t ACL_ALL_RIGHTS_STR)));\n\t\t}\n\n\t\tprivs |= read;\n\t}\n\n\tif (name[0] == '\\0')\n\t\taip->ai_grantee = ACL_ID_PUBLIC;\n\telse\n\t\taip->ai_grantee = get_role_oid(name, false);\n\n\t\/*\n\t * XXX Allow a degree of backward compatibility by defaulting the grantor\n\t * to the superuser.\n\t *\/\n\tif (*s == '\/')\n\t{\n\t\ts = getid(s + 1, name2);\n\t\tif (name2[0] == '\\0')\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t\t errmsg(\"a name must follow the \\\"\/\\\" sign\")));\n\t\taip->ai_grantor = get_role_oid(name2, false);\n\t}\n\telse\n\t{\n\t\taip->ai_grantor = BOOTSTRAP_SUPERUSERID;\n\t\tereport(WARNING,\n\t\t\t\t(errcode(ERRCODE_INVALID_GRANTOR),\n\t\t\t\t errmsg(\"defaulting grantor to user ID %u\",\n\t\t\t\t\t\tBOOTSTRAP_SUPERUSERID)));\n\t}\n\n\tACLITEM_SET_PRIVS_GOPTIONS(*aip, privs, goption);\n\n#ifdef ACLDEBUG\n\telog(LOG, \"aclparse: correctly read [%u %x %x]\",\n\t\t aip->ai_grantee, privs, goption);\n#endif\n\n\treturn s;\n}","target":0,"code_token_length":884,"total_token_length":1120,"max_tokens_setting":2048} +{"idx":321419,"func":"static unsigned int dec10_quick_imm(DisasContext *dc)\n\n{\n\n int32_t imm, simm;\n\n int op;\n\n\n\n \/* sign extend. *\/\n\n imm = dc->ir & ((1 << 6) - 1);\n\n simm = (int8_t) (imm << 2);\n\n simm >>= 2;\n\n switch (dc->opcode) {\n\n case CRISV10_QIMM_BDAP_R0:\n\n case CRISV10_QIMM_BDAP_R1:\n\n case CRISV10_QIMM_BDAP_R2:\n\n case CRISV10_QIMM_BDAP_R3:\n\n simm = (int8_t)dc->ir;\n\n LOG_DIS(\"bdap %d $r%d\\n\", simm, dc->dst);\n\n LOG_DIS(\"pc=%x mode=%x quickimm %d r%d r%d\\n\",\n\n dc->pc, dc->mode, dc->opcode, dc->src, dc->dst);\n\n cris_set_prefix(dc);\n\n if (dc->dst == 15) {\n\n tcg_gen_movi_tl(cpu_PR[PR_PREFIX], dc->pc + 2 + simm);\n\n } else {\n\n tcg_gen_addi_tl(cpu_PR[PR_PREFIX], cpu_R[dc->dst], simm);\n\n }\n\n break;\n\n\n\n case CRISV10_QIMM_MOVEQ:\n\n LOG_DIS(\"moveq %d, $r%d\\n\", simm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, CC_OP_MOVE, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(simm), 4);\n\n break;\n\n case CRISV10_QIMM_CMPQ:\n\n LOG_DIS(\"cmpq %d, $r%d\\n\", simm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, CC_OP_CMP, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(simm), 4);\n\n break;\n\n case CRISV10_QIMM_ADDQ:\n\n LOG_DIS(\"addq %d, $r%d\\n\", imm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, CC_OP_ADD, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(imm), 4);\n\n break;\n\n case CRISV10_QIMM_ANDQ:\n\n LOG_DIS(\"andq %d, $r%d\\n\", simm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, CC_OP_AND, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(simm), 4);\n\n break;\n\n case CRISV10_QIMM_ASHQ:\n\n LOG_DIS(\"ashq %d, $r%d\\n\", simm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n op = imm & (1 << 5);\n\n imm &= 0x1f;\n\n if (op) {\n\n cris_alu(dc, CC_OP_ASR, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(imm), 4);\n\n } else {\n\n \/* BTST *\/\n\n cris_update_cc_op(dc, CC_OP_FLAGS, 4);\n\n gen_helper_btst(cpu_PR[PR_CCS], cpu_R[dc->dst],\n\n tcg_const_tl(imm), cpu_PR[PR_CCS]);\n\n }\n\n break;\n\n case CRISV10_QIMM_LSHQ:\n\n LOG_DIS(\"lshq %d, $r%d\\n\", simm, dc->dst);\n\n\n\n op = CC_OP_LSL;\n\n if (imm & (1 << 5)) {\n\n op = CC_OP_LSR; \n\n }\n\n imm &= 0x1f;\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, op, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(imm), 4);\n\n break;\n\n case CRISV10_QIMM_SUBQ:\n\n LOG_DIS(\"subq %d, $r%d\\n\", imm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, CC_OP_SUB, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(imm), 4);\n\n break;\n\n case CRISV10_QIMM_ORQ:\n\n LOG_DIS(\"andq %d, $r%d\\n\", simm, dc->dst);\n\n\n\n cris_cc_mask(dc, CC_MASK_NZVC);\n\n cris_alu(dc, CC_OP_OR, cpu_R[dc->dst],\n\n cpu_R[dc->dst], tcg_const_tl(simm), 4);\n\n break;\n\n\n\n case CRISV10_QIMM_BCC_R0:\n\n if (!dc->ir) {\n\n cpu_abort(dc->env, \"opcode zero\\n\");\n\n }\n\n case CRISV10_QIMM_BCC_R1:\n\n case CRISV10_QIMM_BCC_R2:\n\n case CRISV10_QIMM_BCC_R3:\n\n imm = dc->ir & 0xff;\n\n \/* bit 0 is a sign bit. *\/\n\n if (imm & 1) {\n\n imm |= 0xffffff00; \/* sign extend. *\/\n\n imm &= ~1; \/* get rid of the sign bit. *\/\n\n }\n\n imm += 2;\n\n LOG_DIS(\"b%s %d\\n\", cc_name(dc->cond), imm);\n\n\n\n cris_cc_mask(dc, 0);\n\n cris_prepare_cc_branch(dc, imm, dc->cond); \n\n break;\n\n\n\n default:\n\n LOG_DIS(\"pc=%x mode=%x quickimm %d r%d r%d\\n\",\n\n dc->pc, dc->mode, dc->opcode, dc->src, dc->dst);\n\n cpu_abort(dc->env, \"Unhandled quickimm\\n\");\n\n break;\n\n }\n\n return 2;\n\n}\n","target":0,"code_token_length":1359,"total_token_length":1595,"max_tokens_setting":2048} +{"idx":423942,"func":"UdfOpen (\r\n IN EFI_FILE_PROTOCOL *This,\r\n OUT EFI_FILE_PROTOCOL **NewHandle,\r\n IN CHAR16 *FileName,\r\n IN UINT64 OpenMode,\r\n IN UINT64 Attributes\r\n )\r\n{\r\n EFI_TPL OldTpl;\r\n EFI_STATUS Status;\r\n PRIVATE_UDF_FILE_DATA *PrivFileData;\r\n PRIVATE_UDF_SIMPLE_FS_DATA *PrivFsData;\r\n CHAR16 FilePath[UDF_PATH_LENGTH];\r\n UDF_FILE_INFO File;\r\n PRIVATE_UDF_FILE_DATA *NewPrivFileData;\r\n CHAR16 *TempFileName;\r\n\r\n ZeroMem (FilePath, sizeof FilePath);\r\n OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r\n\r\n if (This == NULL || NewHandle == NULL || FileName == NULL) {\r\n Status = EFI_INVALID_PARAMETER;\r\n goto Error_Invalid_Params;\r\n }\r\n\r\n if (OpenMode != EFI_FILE_MODE_READ) {\r\n Status = EFI_WRITE_PROTECTED;\r\n goto Error_Invalid_Params;\r\n }\r\n\r\n PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);\r\n\r\n PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (PrivFileData->SimpleFs);\r\n\r\n \/\/\r\n \/\/ Build full path\r\n \/\/\r\n if (*FileName == L'\\\\') {\r\n StrCpyS (FilePath, UDF_PATH_LENGTH, FileName);\r\n } else {\r\n StrCpyS (FilePath, UDF_PATH_LENGTH, PrivFileData->AbsoluteFileName);\r\n StrCatS (FilePath, UDF_PATH_LENGTH, L\"\\\\\");\r\n StrCatS (FilePath, UDF_PATH_LENGTH, FileName);\r\n }\r\n\r\n MangleFileName (FilePath);\r\n if (FilePath[0] == L'\\0') {\r\n Status = EFI_NOT_FOUND;\r\n goto Error_Bad_FileName;\r\n }\r\n\r\n Status = FindFile (\r\n PrivFsData->BlockIo,\r\n PrivFsData->DiskIo,\r\n &PrivFsData->Volume,\r\n FilePath,\r\n _ROOT_FILE (PrivFileData),\r\n _PARENT_FILE (PrivFileData),\r\n &_PARENT_FILE(PrivFileData)->FileIdentifierDesc->Icb,\r\n &File\r\n );\r\n if (EFI_ERROR (Status)) {\r\n goto Error_Find_File;\r\n }\r\n\r\n NewPrivFileData =\r\n (PRIVATE_UDF_FILE_DATA *)AllocateZeroPool (sizeof (PRIVATE_UDF_FILE_DATA));\r\n if (NewPrivFileData == NULL) {\r\n Status = EFI_OUT_OF_RESOURCES;\r\n goto Error_Alloc_New_Priv_File_Data;\r\n }\r\n\r\n CopyMem ((VOID *)NewPrivFileData, (VOID *)PrivFileData,\r\n sizeof (PRIVATE_UDF_FILE_DATA));\r\n CopyMem ((VOID *)&NewPrivFileData->File, &File, sizeof (UDF_FILE_INFO));\r\n\r\n NewPrivFileData->IsRootDirectory = FALSE;\r\n\r\n StrCpyS (NewPrivFileData->AbsoluteFileName, UDF_PATH_LENGTH, FilePath);\r\n FileName = NewPrivFileData->AbsoluteFileName;\r\n\r\n while ((TempFileName = StrStr (FileName, L\"\\\\\")) != NULL) {\r\n FileName = TempFileName + 1;\r\n }\r\n\r\n StrCpyS (NewPrivFileData->FileName, UDF_FILENAME_LENGTH, FileName);\r\n\r\n Status = GetFileSize (\r\n PrivFsData->BlockIo,\r\n PrivFsData->DiskIo,\r\n &PrivFsData->Volume,\r\n &NewPrivFileData->File,\r\n &NewPrivFileData->FileSize\r\n );\r\n if (EFI_ERROR (Status)) {\r\n DEBUG ((\r\n DEBUG_ERROR,\r\n \"%a: GetFileSize() fails with status - %r.\\n\",\r\n __FUNCTION__, Status\r\n ));\r\n goto Error_Get_File_Size;\r\n }\r\n\r\n NewPrivFileData->FilePosition = 0;\r\n ZeroMem ((VOID *)&NewPrivFileData->ReadDirInfo,\r\n sizeof (UDF_READ_DIRECTORY_INFO));\r\n\r\n *NewHandle = &NewPrivFileData->FileIo;\r\n\r\n PrivFsData->OpenFiles++;\r\n\r\n gBS->RestoreTPL (OldTpl);\r\n\r\n return Status;\r\n\r\nError_Get_File_Size:\r\n FreePool ((VOID *)NewPrivFileData);\r\n\r\nError_Alloc_New_Priv_File_Data:\r\n CleanupFileInformation (&File);\r\n\r\nError_Find_File:\r\nError_Bad_FileName:\r\nError_Invalid_Params:\r\n gBS->RestoreTPL (OldTpl);\r\n\r\n return Status;\r\n}\r","target":0,"code_token_length":915,"total_token_length":1151,"max_tokens_setting":2048} +{"idx":407931,"func":"int FAST_FUNC read_bunzip(bunzip_data *bd, char *outbuf, int len)\n{\n\tconst uint32_t *dbuf;\n\tint pos, current, previous;\n\tuint32_t CRC;\n\n\t\/* If we already have error\/end indicator, return it *\/\n\tif (bd->writeCount < 0)\n\t\treturn bd->writeCount;\n\n\tdbuf = bd->dbuf;\n\n\t\/* Register-cached state (hopefully): *\/\n\tpos = bd->writePos;\n\tcurrent = bd->writeCurrent;\n\tCRC = bd->writeCRC; \/* small loss on x86-32 (not enough regs), win on x86-64 *\/\n\n\t\/* We will always have pending decoded data to write into the output\n\t buffer unless this is the very first call (in which case we haven't\n\t Huffman-decoded a block into the intermediate buffer yet). *\/\n\tif (bd->writeCopies) {\n\n dec_writeCopies:\n\t\t\/* Inside the loop, writeCopies means extra copies (beyond 1) *\/\n\t\t--bd->writeCopies;\n\n\t\t\/* Loop outputting bytes *\/\n\t\tfor (;;) {\n\n\t\t\t\/* If the output buffer is full, save cached state and return *\/\n\t\t\tif (--len < 0) {\n\t\t\t\t\/* Unlikely branch.\n\t\t\t\t * Use of \"goto\" instead of keeping code here\n\t\t\t\t * helps compiler to realize this. *\/\n\t\t\t\tgoto outbuf_full;\n\t\t\t}\n\n\t\t\t\/* Write next byte into output buffer, updating CRC *\/\n\t\t\t*outbuf++ = current;\n\t\t\tCRC = (CRC << 8) ^ bd->crc32Table[(CRC >> 24) ^ current];\n\n\t\t\t\/* Loop now if we're outputting multiple copies of this byte *\/\n\t\t\tif (bd->writeCopies) {\n\t\t\t\t\/* Unlikely branch *\/\n\t\t\t\t\/*--bd->writeCopies;*\/\n\t\t\t\t\/*continue;*\/\n\t\t\t\t\/* Same, but (ab)using other existing --writeCopies operation\n\t\t\t\t * (and this if() compiles into just test+branch pair): *\/\n\t\t\t\tgoto dec_writeCopies;\n\t\t\t}\n decode_next_byte:\n\t\t\tif (--bd->writeCount < 0)\n\t\t\t\tbreak; \/* input block is fully consumed, need next one *\/\n\n\t\t\t\/* Follow sequence vector to undo Burrows-Wheeler transform *\/\n\t\t\tprevious = current;\n\t\t\tpos = dbuf[pos];\n\t\t\tcurrent = (uint8_t)pos;\n\t\t\tpos >>= 8;\n\n\t\t\t\/* After 3 consecutive copies of the same byte, the 4th\n\t\t\t * is a repeat count. We count down from 4 instead\n\t\t\t * of counting up because testing for non-zero is faster *\/\n\t\t\tif (--bd->writeRunCountdown != 0) {\n\t\t\t\tif (current != previous)\n\t\t\t\t\tbd->writeRunCountdown = 4;\n\t\t\t} else {\n\t\t\t\t\/* Unlikely branch *\/\n\t\t\t\t\/* We have a repeated run, this byte indicates the count *\/\n\t\t\t\tbd->writeCopies = current;\n\t\t\t\tcurrent = previous;\n\t\t\t\tbd->writeRunCountdown = 5;\n\n\t\t\t\t\/* Sometimes there are just 3 bytes (run length 0) *\/\n\t\t\t\tif (!bd->writeCopies) goto decode_next_byte;\n\n\t\t\t\t\/* Subtract the 1 copy we'd output anyway to get extras *\/\n\t\t\t\t--bd->writeCopies;\n\t\t\t}\n\t\t} \/* for(;;) *\/\n\n\t\t\/* Decompression of this input block completed successfully *\/\n\t\tbd->writeCRC = CRC = ~CRC;\n\t\tbd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ CRC;\n\n\t\t\/* If this block had a CRC error, force file level CRC error *\/\n\t\tif (CRC != bd->headerCRC) {\n\t\t\tbd->totalCRC = bd->headerCRC + 1;\n\t\t\treturn RETVAL_LAST_BLOCK;\n\t\t}\n\t}\n\n\t\/* Refill the intermediate buffer by Huffman-decoding next block of input *\/\n\t{\n\t\tint r = get_next_block(bd);\n\t\tif (r) { \/* error\/end *\/\n\t\t\tbd->writeCount = r;\n\t\t\treturn (r != RETVAL_LAST_BLOCK) ? r : len;\n\t\t}\n\t}\n\n\tCRC = ~0;\n\tpos = bd->writePos;\n\tcurrent = bd->writeCurrent;\n\tgoto decode_next_byte;\n\n outbuf_full:\n\t\/* Output buffer is full, save cached state and return *\/\n\tbd->writePos = pos;\n\tbd->writeCurrent = current;\n\tbd->writeCRC = CRC;\n\n\tbd->writeCopies++;\n\n\treturn 0;\n}","target":0,"code_token_length":970,"total_token_length":1206,"max_tokens_setting":2048} +{"idx":3570,"func":"void gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)\n{\n\tstruct jpeg_compress_struct cinfo;\n\tstruct jpeg_error_mgr jerr;\n\tint i, j, jidx;\n\t\/* volatile so we can gdFree it on return from longjmp *\/\n\tvolatile JSAMPROW row = 0;\n\tJSAMPROW rowptr[1];\n\tjmpbuf_wrapper jmpbufw;\n\tJDIMENSION nlines;\n\tchar comment[255];\n\n\tmemset (&cinfo, 0, sizeof (cinfo));\n\tmemset (&jerr, 0, sizeof (jerr));\n\n\tcinfo.err = jpeg_std_error (&jerr);\n\tcinfo.client_data = &jmpbufw;\n\tif (setjmp (jmpbufw.jmpbuf) != 0) {\n\t\t\/* we're here courtesy of longjmp *\/\n\t\tif (row) {\n\t\t\tgdFree (row);\n\t\t}\n\t\treturn;\n\t}\n\n\tcinfo.err->error_exit = fatal_jpeg_error;\n\n\tjpeg_create_compress (&cinfo);\n\n\tcinfo.image_width = im->sx;\n\tcinfo.image_height = im->sy;\n\tcinfo.input_components = 3;\t\/* # of color components per pixel *\/\n\tcinfo.in_color_space = JCS_RGB;\t\/* colorspace of input image *\/\n\tjpeg_set_defaults (&cinfo);\n\n\tcinfo.density_unit = 1;\n\tcinfo.X_density = im->res_x;\n\tcinfo.Y_density = im->res_y;\n\n\tif (quality >= 0) {\n\t\tjpeg_set_quality (&cinfo, quality, TRUE);\n\t}\n\n\t\/* If user requests interlace, translate that to progressive JPEG *\/\n\tif (gdImageGetInterlaced (im)) {\n\t\tjpeg_simple_progression (&cinfo);\n\t}\n\n\tjpeg_gdIOCtx_dest (&cinfo, outfile);\n\n\trow = (JSAMPROW) safe_emalloc(cinfo.image_width * cinfo.input_components, sizeof(JSAMPLE), 0);\n\tmemset(row, 0, cinfo.image_width * cinfo.input_components * sizeof(JSAMPLE));\n\trowptr[0] = row;\n\n\tjpeg_start_compress (&cinfo, TRUE);\n\n\tif (quality >= 0) {\n\t\tsnprintf(comment, sizeof(comment)-1, \"CREATOR: gd-jpeg v%s (using IJG JPEG v%d), quality = %d\\n\", GD_JPEG_VERSION, JPEG_LIB_VERSION, quality);\n\t} else {\n\t\tsnprintf(comment, sizeof(comment)-1, \"CREATOR: gd-jpeg v%s (using IJG JPEG v%d), default quality\\n\", GD_JPEG_VERSION, JPEG_LIB_VERSION);\n\t}\n\tjpeg_write_marker (&cinfo, JPEG_COM, (unsigned char *) comment, (unsigned int) strlen (comment));\n\tif (im->trueColor) {\n\n#if BITS_IN_JSAMPLE == 12\n\t\tgd_error(\"gd-jpeg: error: jpeg library was compiled for 12-bit precision. This is mostly useless, because JPEGs on the web are 8-bit and such versions of the jpeg library won't read or write them. GD doesn't support these unusual images. Edit your jmorecfg.h file to specify the correct precision and completely 'make clean' and 'make install' libjpeg again. Sorry\");\n\t\tgoto error;\n#endif \/* BITS_IN_JSAMPLE == 12 *\/\n\n\t\tfor (i = 0; i < im->sy; i++) {\n\t\t\tfor (jidx = 0, j = 0; j < im->sx; j++) {\n\t\t\t\tint val = im->tpixels[i][j];\n\n\t\t\t\trow[jidx++] = gdTrueColorGetRed (val);\n\t\t\t\trow[jidx++] = gdTrueColorGetGreen (val);\n\t\t\t\trow[jidx++] = gdTrueColorGetBlue (val);\n\t\t\t}\n\n\t\t\tnlines = jpeg_write_scanlines (&cinfo, rowptr, 1);\n\t\t\tif (nlines != 1) {\n\t\t\t\tgd_error_ex(GD_WARNING, \"gd_jpeg: warning: jpeg_write_scanlines returns %u -- expected 1\", nlines);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (i = 0; i < im->sy; i++) {\n\t\t\tfor (jidx = 0, j = 0; j < im->sx; j++) {\n\t\t\t\tint idx = im->pixels[i][j];\n\n\t\t\t\t\/* NB: Although gd RGB values are ints, their max value is\n\t\t\t\t * 255 (see the documentation for gdImageColorAllocate())\n\t\t\t\t * -- perfect for 8-bit JPEG encoding (which is the norm)\n\t\t\t\t *\/\n#if BITS_IN_JSAMPLE == 8\n\t\t\t\trow[jidx++] = im->red[idx];\n\t\t\t\trow[jidx++] = im->green[idx];\n\t\t\t\trow[jidx++] = im->blue[idx];\n#elif BITS_IN_JSAMPLE == 12\n\t\t\t\trow[jidx++] = im->red[idx] << 4;\n\t\t\t\trow[jidx++] = im->green[idx] << 4;\n\t\t\t\trow[jidx++] = im->blue[idx] << 4;\n#else\n#error IJG JPEG library BITS_IN_JSAMPLE value must be 8 or 12\n#endif\n\t\t\t}\n\n\t\t\tnlines = jpeg_write_scanlines (&cinfo, rowptr, 1);\n\t\t\tif (nlines != 1) {\n\t\t\t\tgd_error_ex(GD_WARNING, \"gd_jpeg: warning: jpeg_write_scanlines returns %u -- expected 1\", nlines);\n\t\t\t}\n\t\t}\n\t}\n\n\tjpeg_finish_compress (&cinfo);\n\tjpeg_destroy_compress (&cinfo);\n\tgdFree (row);\n}","target":1,"code_token_length":1172,"total_token_length":1408,"max_tokens_setting":2048} +{"idx":11036,"func":"xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {\n xmlChar *name;\n const xmlChar *ptr;\n xmlChar cur;\n xmlEntityPtr ent = NULL;\n\n if ((str == NULL) || (*str == NULL))\n return(NULL);\n ptr = *str;\n cur = *ptr;\n if (cur != '&')\n\treturn(NULL);\n\n ptr++;\n name = xmlParseStringName(ctxt, &ptr);\n if (name == NULL) {\n\txmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,\n\t\t \"xmlParseStringEntityRef: no name\\n\");\n\t*str = ptr;\n\treturn(NULL);\n }\n if (*ptr != ';') {\n\txmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);\n xmlFree(name);\n\t*str = ptr;\n\treturn(NULL);\n }\n ptr++;\n\n\n \/*\n * Predefined entites override any extra definition\n *\/\n if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {\n ent = xmlGetPredefinedEntity(name);\n if (ent != NULL) {\n xmlFree(name);\n *str = ptr;\n return(ent);\n }\n }\n\n \/*\n * Increate the number of entity references parsed\n *\/\n ctxt->nbentities++;\n\n \/*\n * Ask first SAX for entity resolution, otherwise try the\n * entities which may have stored in the parser context.\n *\/\n if (ctxt->sax != NULL) {\n\tif (ctxt->sax->getEntity != NULL)\n\t ent = ctxt->sax->getEntity(ctxt->userData, name);\n\tif ((ent == NULL) && (ctxt->options & XML_PARSE_OLDSAX))\n\t ent = xmlGetPredefinedEntity(name);\n\tif ((ent == NULL) && (ctxt->userData==ctxt)) {\n \t ent = xmlSAX2GetEntity(ctxt, name);\n \t}\n }\n \n \/*\n * [ WFC: Entity Declared ]\n * In a document without any DTD, a document with only an\n * internal DTD subset which contains no parameter entity\n * references, or a document with \"standalone='yes'\", the\n * Name given in the entity reference must match that in an\n * entity declaration, except that well-formed documents\n * need not declare any of the following entities: amp, lt,\n * gt, apos, quot.\n * The declaration of a parameter entity must precede any\n * reference to it.\n * Similarly, the declaration of a general entity must\n * precede any reference to it which appears in a default\n * value in an attribute-list declaration. Note that if\n * entities are declared in the external subset or in\n * external parameter entities, a non-validating processor\n * is not obligated to read and process their declarations;\n * for such documents, the rule that an entity must be\n * declared is a well-formedness constraint only if\n * standalone='yes'. \n *\/\n if (ent == NULL) {\n\tif ((ctxt->standalone == 1) ||\n\t ((ctxt->hasExternalSubset == 0) &&\n\t (ctxt->hasPErefs == 0))) {\n\t xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,\n\t\t \"Entity '%s' not defined\\n\", name);\n\t} else {\n\t xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,\n\t\t\t \"Entity '%s' not defined\\n\",\n\t\t\t name);\n\t}\n\t\/* TODO ? check regressions ctxt->valid = 0; *\/\n }\n\n \/*\n * [ WFC: Parsed Entity ]\n * An entity reference must not contain the name of an\n * unparsed entity\n *\/\n else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {\n\txmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,\n\t\t \"Entity reference to unparsed entity %s\\n\", name);\n }\n\n \/*\n * [ WFC: No External Entity References ]\n * Attribute values cannot contain direct or indirect\n * entity references to external entities.\n *\/\n else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&\n\t (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {\n\txmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,\n\t \"Attribute references external entity '%s'\\n\", name);\n }\n \/*\n * [ WFC: No < in Attribute Values ]\n * The replacement text of any entity referred to directly or\n * indirectly in an attribute value (other than \"<\") must\n * not contain a <.\n *\/\n else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&\n\t (ent != NULL) && (ent->content != NULL) &&\n\t (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&\n\t (xmlStrchr(ent->content, '<'))) {\n\txmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,\n \"'<' in entity '%s' is not allowed in attributes values\\n\",\n\t\t\t name);\n }\n\n \/*\n * Internal check, no parameter entities here ...\n *\/\n else {\n\tswitch (ent->etype) {\n\t case XML_INTERNAL_PARAMETER_ENTITY:\n\t case XML_EXTERNAL_PARAMETER_ENTITY:\n\t\txmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,\n\t \"Attempt to reference the parameter entity '%s'\\n\",\n\t\t\t\t name);\n\t break;\n\t default:\n\t break;\n\t}\n }\n\n \/*\n * [ WFC: No Recursion ]\n * A parsed entity must not contain a recursive reference\n * to itself, either directly or indirectly.\n * Done somewhere else\n *\/\n\n xmlFree(name);\n *str = ptr;\n return(ent);\n}\n","target":1,"code_token_length":1217,"total_token_length":1453,"max_tokens_setting":2048} +{"idx":10052,"func":"xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {\n xmlChar limit = 0;\n xmlChar *buf = NULL;\n xmlChar *rep = NULL;\n int len = 0;\n int buf_size = 0;\n int c, l, in_space = 0;\n xmlChar *current = NULL;\n xmlEntityPtr ent;\n\n if (NXT(0) == '\"') {\n\tctxt->instate = XML_PARSER_ATTRIBUTE_VALUE;\n\tlimit = '\"';\n NEXT;\n } else if (NXT(0) == '\\'') {\n\tlimit = '\\'';\n\tctxt->instate = XML_PARSER_ATTRIBUTE_VALUE;\n NEXT;\n } else {\n\txmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);\n\treturn(NULL);\n }\n\n \/*\n * allocate a translation buffer.\n *\/\n buf_size = XML_PARSER_BUFFER_SIZE;\n buf = (xmlChar *) xmlMallocAtomic(buf_size * sizeof(xmlChar));\n if (buf == NULL) goto mem_error;\n\n \/*\n * OK loop until we reach one of the ending char or a size limit.\n *\/\n c = CUR_CHAR(l);\n while ((NXT(0) != limit) && \/* checked *\/\n (IS_CHAR(c)) && (c != '<')) {\n\tif (c == 0) break;\n\tif (c == '&') {\n\t in_space = 0;\n\t if (NXT(1) == '#') {\n\t\tint val = xmlParseCharRef(ctxt);\n\n\t\tif (val == '&') {\n\t\t if (ctxt->replaceEntities) {\n\t\t\tif (len > buf_size - 10) {\n\t\t\t growBuffer(buf, 10);\n\t\t\t}\n\t\t\tbuf[len++] = '&';\n\t\t } else {\n\t\t\t\/*\n\t\t\t * The reparsing will be done in xmlStringGetNodeList()\n\t\t\t * called by the attribute() function in SAX.c\n\t\t\t *\/\n\t\t\tif (len > buf_size - 10) {\n\t\t\t growBuffer(buf, 10);\n\t\t\t}\n\t\t\tbuf[len++] = '&';\n\t\t\tbuf[len++] = '#';\n\t\t\tbuf[len++] = '3';\n\t\t\tbuf[len++] = '8';\n\t\t\tbuf[len++] = ';';\n\t\t }\n\t\t} else if (val != 0) {\n\t\t if (len > buf_size - 10) {\n\t\t\tgrowBuffer(buf, 10);\n\t\t }\n\t\t len += xmlCopyChar(0, &buf[len], val);\n\t\t}\n\t } else {\n\t\tent = xmlParseEntityRef(ctxt);\n\t\tctxt->nbentities++;\n\t\tif (ent != NULL)\n\t\t ctxt->nbentities += ent->owner;\n\t\tif ((ent != NULL) &&\n\t\t (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {\n\t\t if (len > buf_size - 10) {\n\t\t\tgrowBuffer(buf, 10);\n\t\t }\n\t\t if ((ctxt->replaceEntities == 0) &&\n\t\t (ent->content[0] == '&')) {\n\t\t\tbuf[len++] = '&';\n\t\t\tbuf[len++] = '#';\n\t\t\tbuf[len++] = '3';\n\t\t\tbuf[len++] = '8';\n\t\t\tbuf[len++] = ';';\n\t\t } else {\n\t\t\tbuf[len++] = ent->content[0];\n\t\t }\n\t\t} else if ((ent != NULL) && \n\t\t (ctxt->replaceEntities != 0)) {\n\t\t if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {\n\t\t\trep = xmlStringDecodeEntities(ctxt, ent->content,\n\t\t\t\t\t\t XML_SUBSTITUTE_REF,\n\t\t\t\t\t\t 0, 0, 0);\n\t\t\tif (rep != NULL) {\n\t\t\t current = rep;\n\t\t\t while (*current != 0) { \/* non input consuming *\/\n if ((*current == 0xD) || (*current == 0xA) ||\n (*current == 0x9)) {\n buf[len++] = 0x20;\n current++;\n } else\n buf[len++] = *current++;\n\t\t\t\tif (len > buf_size - 10) {\n\t\t\t\t growBuffer(buf, 10);\n\t\t\t\t}\n\t\t\t }\n\t\t\t xmlFree(rep);\n\t\t\t rep = NULL;\n\t\t\t}\n\t\t } else {\n\t\t\tif (len > buf_size - 10) {\n\t\t\t growBuffer(buf, 10);\n\t\t\t}\n\t\t\tif (ent->content != NULL)\n\t\t\t buf[len++] = ent->content[0];\n\t\t }\n\t\t} else if (ent != NULL) {\n\t\t int i = xmlStrlen(ent->name);\n\t\t const xmlChar *cur = ent->name;\n\n\t\t \/*\n\t\t * This may look absurd but is needed to detect\n\t\t * entities problems\n\t\t *\/\n\t\t if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&\n\t\t\t(ent->content != NULL)) {\n\t\t\trep = xmlStringDecodeEntities(ctxt, ent->content,\n\t\t\t\t\t\t XML_SUBSTITUTE_REF, 0, 0, 0);\n\t\t\tif (rep != NULL) {\n\t\t\t xmlFree(rep);\n\t\t\t rep = NULL;\n\t\t\t}\n\t\t }\n\n\t\t \/*\n\t\t * Just output the reference\n\t\t *\/\n\t\t buf[len++] = '&';\n\t\t while (len > buf_size - i - 10) {\n\t\t\tgrowBuffer(buf, i + 10);\n\t\t }\n\t\t for (;i > 0;i--)\n\t\t\tbuf[len++] = *cur++;\n\t\t buf[len++] = ';';\n\t\t}\n\t }\n\t} else {\n\t if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {\n\t if ((len != 0) || (!normalize)) {\n\t\t if ((!normalize) || (!in_space)) {\n\t\t\tCOPY_BUF(l,buf,len,0x20);\n\t\t\twhile (len > buf_size - 10) {\n\t\t\t growBuffer(buf, 10);\n\t\t\t}\n\t\t }\n\t\t in_space = 1;\n\t\t}\n\t } else {\n\t in_space = 0;\n\t\tCOPY_BUF(l,buf,len,c);\n\t\tif (len > buf_size - 10) {\n\t\t growBuffer(buf, 10);\n\t\t}\n\t }\n\t NEXTL(l);\n\t}\n\tGROW;\n \tc = CUR_CHAR(l);\n }\n if ((in_space) && (normalize)) {\n while (buf[len - 1] == 0x20) len--;\n }\n buf[len] = 0;\n if (RAW == '<') {\n\txmlFatalErr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, NULL);\n } else if (RAW != limit) {\n\tif ((c != 0) && (!IS_CHAR(c))) {\n\t xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,\n\t\t\t \"invalid character in attribute value\\n\");\n\t} else {\n\t xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,\n\t\t\t \"AttValue: ' expected\\n\");\n }\n } else\n\tNEXT;\n if (attlen != NULL) *attlen = len;\n return(buf);\n\nmem_error:\n xmlErrMemory(ctxt, NULL);\n if (buf != NULL)\n xmlFree(buf);\n if (rep != NULL)\n xmlFree(rep);\n return(NULL);\n}\n","target":1,"code_token_length":1517,"total_token_length":1753,"max_tokens_setting":2048} +{"idx":7951,"func":"static int pop_fetch_message (CONTEXT* ctx, MESSAGE* msg, int msgno)\n{\n int ret;\n void *uidl;\n char buf[LONG_STRING];\n char path[_POSIX_PATH_MAX];\n progress_t progressbar;\n POP_DATA *pop_data = (POP_DATA *)ctx->data;\n POP_CACHE *cache;\n HEADER *h = ctx->hdrs[msgno];\n unsigned short bcache = 1;\n\n \/* see if we already have the message in body cache *\/\n if ((msg->fp = mutt_bcache_get (pop_data->bcache, h->data)))\n return 0;\n\n \/*\n * see if we already have the message in our cache in\n * case $message_cachedir is unset\n *\/\n cache = &pop_data->cache[h->index % POP_CACHE_LEN];\n\n if (cache->path)\n {\n if (cache->index == h->index)\n {\n \/* yes, so just return a pointer to the message *\/\n msg->fp = fopen (cache->path, \"r\");\n if (msg->fp)\n\treturn 0;\n \n mutt_perror (cache->path);\n mutt_sleep (2);\n return -1;\n }\n else\n {\n \/* clear the previous entry *\/\n unlink (cache->path);\n FREE (&cache->path);\n }\n }\n\n FOREVER\n {\n if (pop_reconnect (ctx) < 0)\n return -1;\n\n \/* verify that massage index is correct *\/\n if (h->refno < 0)\n {\n mutt_error _(\"The message index is incorrect. Try reopening the mailbox.\");\n mutt_sleep (2);\n return -1;\n }\n\n mutt_progress_init (&progressbar, _(\"Fetching message...\"),\n\t\t\tMUTT_PROGRESS_SIZE, NetInc, h->content->length + h->content->offset - 1);\n\n \/* see if we can put in body cache; use our cache as fallback *\/\n if (!(msg->fp = mutt_bcache_put (pop_data->bcache, h->data, 1)))\n {\n \/* no *\/\n bcache = 0;\n mutt_mktemp (path, sizeof (path));\n if (!(msg->fp = safe_fopen (path, \"w+\")))\n {\n\tmutt_perror (path);\n\tmutt_sleep (2);\n\treturn -1;\n }\n }\n\n snprintf (buf, sizeof (buf), \"RETR %d\\r\\n\", h->refno);\n\n ret = pop_fetch_data (pop_data, buf, &progressbar, fetch_message, msg->fp);\n if (ret == 0)\n break;\n\n safe_fclose (&msg->fp);\n\n \/* if RETR failed (e.g. connection closed), be sure to remove either\n * the file in bcache or from POP's own cache since the next iteration\n * of the loop will re-attempt to put() the message *\/\n if (!bcache)\n unlink (path);\n\n if (ret == -2)\n {\n mutt_error (\"%s\", pop_data->err_msg);\n mutt_sleep (2);\n return -1;\n }\n\n if (ret == -3)\n {\n mutt_error _(\"Can't write message to temporary file!\");\n mutt_sleep (2);\n return -1;\n }\n }\n\n \/* Update the header information. Previously, we only downloaded a\n * portion of the headers, those required for the main display.\n *\/\n if (bcache)\n mutt_bcache_commit (pop_data->bcache, h->data);\n else\n {\n cache->index = h->index;\n cache->path = safe_strdup (path);\n }\n rewind (msg->fp);\n uidl = h->data;\n\n \/* we replace envelop, key in subj_hash has to be updated as well *\/\n if (ctx->subj_hash && h->env->real_subj)\n hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);\n mutt_label_hash_remove (ctx, h);\n mutt_free_envelope (&h->env);\n h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);\n if (ctx->subj_hash && h->env->real_subj)\n hash_insert (ctx->subj_hash, h->env->real_subj, h);\n mutt_label_hash_add (ctx, h);\n\n h->data = uidl;\n h->lines = 0;\n fgets (buf, sizeof (buf), msg->fp);\n while (!feof (msg->fp))\n {\n ctx->hdrs[msgno]->lines++;\n fgets (buf, sizeof (buf), msg->fp);\n }\n\n h->content->length = ftello (msg->fp) - h->content->offset;\n\n \/* This needs to be done in case this is a multipart message *\/\n if (!WithCrypto)\n h->security = crypt_query (h->content);\n\n mutt_clear_error();\n rewind (msg->fp);\n\n return 0;\n}","target":1,"code_token_length":1100,"total_token_length":1336,"max_tokens_setting":2048} +{"idx":17290,"func":"static int dissect_usb_video_frame ( proto_tree * tree , tvbuff_t * tvb , int offset , guint8 subtype ) {\n static const int * capability_bits [ ] = {\n & hf_usb_vid_frame_stills_supported , & hf_usb_vid_frame_fixed_frame_rate , NULL }\n ;\n proto_item * desc_item ;\n guint8 bFrameIntervalType ;\n guint8 frame_index ;\n guint16 frame_width ;\n guint16 frame_height ;\n frame_index = tvb_get_guint8 ( tvb , offset ) ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_index , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ;\n offset ++ ;\n proto_tree_add_bitmask ( tree , tvb , offset , hf_usb_vid_frame_capabilities , ett_frame_capability_flags , capability_bits , ENC_NA ) ;\n offset ++ ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_width , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_height , tvb , offset + 2 , 2 , ENC_LITTLE_ENDIAN ) ;\n frame_width = tvb_get_letohs ( tvb , offset ) ;\n frame_height = tvb_get_letohs ( tvb , offset + 2 ) ;\n desc_item = proto_tree_get_parent ( tree ) ;\n proto_item_append_text ( desc_item , \" (Index %2u): %4u x %4u\" , frame_index , frame_width , frame_height ) ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_min_bit_rate , tvb , offset + 4 , 4 , ENC_LITTLE_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_max_bit_rate , tvb , offset + 8 , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 12 ;\n if ( subtype != VS_FRAME_FRAME_BASED ) {\n proto_tree_add_item ( tree , hf_usb_vid_frame_max_frame_sz , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 4 ;\n }\n proto_tree_add_item ( tree , hf_usb_vid_frame_default_interval , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 4 ;\n bFrameIntervalType = tvb_get_guint8 ( tvb , offset ) ;\n if ( bFrameIntervalType == 0 ) {\n proto_tree_add_uint_format_value ( tree , hf_usb_vid_frame_interval_type , tvb , offset , 1 , bFrameIntervalType , \"Continuous (0)\" ) ;\n offset ++ ;\n if ( subtype == VS_FRAME_FRAME_BASED ) {\n proto_tree_add_item ( tree , hf_usb_vid_frame_bytes_per_line , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 4 ;\n }\n proto_tree_add_item ( tree , hf_usb_vid_frame_min_interval , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_max_interval , tvb , offset + 4 , 4 , ENC_LITTLE_ENDIAN ) ;\n proto_tree_add_item ( tree , hf_usb_vid_frame_step_interval , tvb , offset + 8 , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 12 ;\n }\n else {\n guint8 i ;\n proto_tree_add_uint_format_value ( tree , hf_usb_vid_frame_interval_type , tvb , offset , 1 , bFrameIntervalType , \"Discrete (%u choice%s)\" , bFrameIntervalType , ( bFrameIntervalType > 1 ) ? \"s\" : \"\" ) ;\n offset ++ ;\n if ( subtype == VS_FRAME_FRAME_BASED ) {\n proto_tree_add_item ( tree , hf_usb_vid_frame_bytes_per_line , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 4 ;\n }\n for ( i = 0 ;\n i < bFrameIntervalType ;\n ++ i ) {\n proto_tree_add_item ( tree , hf_usb_vid_frame_interval , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;\n offset += 4 ;\n }\n }\n return offset ;\n }","target":0,"code_token_length":812,"total_token_length":1048,"max_tokens_setting":2048} +{"idx":22060,"func":"extern int main ( int argc , char * argv [ ] ) {\n # if ! UCONFIG_NO_IDNA char * filename = NULL ;\n # endif const char * srcDir = NULL , * destDir = NULL , * icuUniDataDir = NULL ;\n const char * bundleName = NULL , * inputFileName = NULL ;\n char * basename = NULL ;\n int32_t sprepOptions = 0 ;\n UErrorCode errorCode = U_ZERO_ERROR ;\n U_MAIN_INIT_ARGS ( argc , argv ) ;\n options [ DESTDIR ] . value = u_getDataDirectory ( ) ;\n options [ SOURCEDIR ] . value = \"\" ;\n options [ UNICODE_VERSION ] . value = \"0\" ;\n options [ BUNDLE_NAME ] . value = DATA_NAME ;\n options [ NORMALIZE ] . value = \"\" ;\n argc = u_parseArgs ( argc , argv , UPRV_LENGTHOF ( options ) , options ) ;\n if ( argc < 0 ) {\n fprintf ( stderr , \"error in command line argument \\\"%s\\\"\\n\" , argv [ - argc ] ) ;\n }\n if ( argc < 0 || options [ HELP ] . doesOccur || options [ HELP_QUESTION_MARK ] . doesOccur ) {\n return printHelp ( argc , argv ) ;\n }\n beVerbose = options [ VERBOSE ] . doesOccur ;\n haveCopyright = options [ COPYRIGHT ] . doesOccur ;\n srcDir = options [ SOURCEDIR ] . value ;\n destDir = options [ DESTDIR ] . value ;\n bundleName = options [ BUNDLE_NAME ] . value ;\n if ( options [ NORMALIZE ] . doesOccur ) {\n icuUniDataDir = options [ NORMALIZE ] . value ;\n }\n else {\n icuUniDataDir = options [ NORM_CORRECTION_DIR ] . value ;\n }\n if ( argc < 2 ) {\n return printHelp ( argc , argv ) ;\n }\n else {\n inputFileName = argv [ 1 ] ;\n }\n if ( ! options [ UNICODE_VERSION ] . doesOccur ) {\n return printHelp ( argc , argv ) ;\n }\n if ( options [ ICUDATADIR ] . doesOccur ) {\n u_setDataDirectory ( options [ ICUDATADIR ] . value ) ;\n }\n # if UCONFIG_NO_IDNA fprintf ( stderr , \"gensprep writes dummy \" U_ICUDATA_NAME \"_\" DATA_NAME \".\" DATA_TYPE \" because UCONFIG_NO_IDNA is set, \\n\" \"see icu\/source\/common\/unicode\/uconfig.h\\n\" ) ;\n generateData ( destDir , bundleName ) ;\n # else setUnicodeVersion ( options [ UNICODE_VERSION ] . value ) ;\n filename = ( char * ) uprv_malloc ( uprv_strlen ( srcDir ) + uprv_strlen ( inputFileName ) + ( icuUniDataDir == NULL ? 0 : uprv_strlen ( icuUniDataDir ) ) + 40 ) ;\n if ( uprv_strchr ( srcDir , U_FILE_SEP_CHAR ) == NULL && uprv_strchr ( srcDir , U_FILE_ALT_SEP_CHAR ) == NULL ) {\n filename [ 0 ] = '.' ;\n filename [ 1 ] = U_FILE_SEP_CHAR ;\n uprv_strcpy ( filename + 2 , srcDir ) ;\n }\n else {\n uprv_strcpy ( filename , srcDir ) ;\n }\n basename = filename + uprv_strlen ( filename ) ;\n if ( basename > filename && * ( basename - 1 ) != U_FILE_SEP_CHAR ) {\n * basename ++ = U_FILE_SEP_CHAR ;\n }\n init ( ) ;\n uprv_strcpy ( basename , inputFileName ) ;\n parseMappings ( filename , FALSE , & errorCode ) ;\n if ( U_FAILURE ( errorCode ) ) {\n fprintf ( stderr , \"Could not open file %s for reading. Error: %s \\n\" , filename , u_errorName ( errorCode ) ) ;\n return errorCode ;\n }\n if ( options [ NORMALIZE ] . doesOccur ) {\n uprv_strcpy ( filename , icuUniDataDir ) ;\n basename = filename + uprv_strlen ( filename ) ;\n if ( basename > filename && * ( basename - 1 ) != U_FILE_SEP_CHAR ) {\n * basename ++ = U_FILE_SEP_CHAR ;\n }\n * basename ++ = U_FILE_SEP_CHAR ;\n uprv_strcpy ( basename , NORM_CORRECTIONS_FILE_NAME ) ;\n parseNormalizationCorrections ( filename , & errorCode ) ;\n if ( U_FAILURE ( errorCode ) ) {\n fprintf ( stderr , \"Could not open file %s for reading \\n\" , filename ) ;\n return errorCode ;\n }\n sprepOptions |= _SPREP_NORMALIZATION_ON ;\n }\n if ( options [ CHECK_BIDI ] . doesOccur ) {\n sprepOptions |= _SPREP_CHECK_BIDI_ON ;\n }\n setOptions ( sprepOptions ) ;\n if ( U_SUCCESS ( errorCode ) ) {\n generateData ( destDir , bundleName ) ;\n cleanUpData ( ) ;\n }\n uprv_free ( filename ) ;\n u_cleanup ( ) ;\n # endif return errorCode ;\n }","target":0,"code_token_length":1010,"total_token_length":1246,"max_tokens_setting":2048} +{"idx":219989,"func":"void ID3::Iterator::getstring(String8 *id, bool otherdata) const {\n id->setTo(\"\");\n\n const uint8_t *frameData = mFrameData;\n if (frameData == NULL) {\n return;\n }\n\n uint8_t encoding = *frameData;\n\n if (mParent.mVersion == ID3_V1 || mParent.mVersion == ID3_V1_1) {\n if (mOffset == 126 || mOffset == 127) {\n char tmp[16];\n sprintf(tmp, \"%d\", (int)*frameData);\n\n id->setTo(tmp);\n return;\n }\n\n id->setTo((const char*)frameData, mFrameSize);\n return;\n }\n\n if (mFrameSize < getHeaderLength() + 1) {\n return;\n }\n size_t n = mFrameSize - getHeaderLength() - 1;\n if (otherdata) {\n frameData += 4;\n int32_t i = n - 4;\n while(--i >= 0 && *++frameData != 0) ;\n int skipped = (frameData - mFrameData);\n if (skipped >= (int)n) {\n return;\n }\n n -= skipped;\n }\n\n if (n <= 0) {\n return;\n }\n\n if (encoding == 0x00) {\n id->setTo((const char*)frameData + 1, n);\n } else if (encoding == 0x03) {\n id->setTo((const char *)(frameData + 1), n);\n } else if (encoding == 0x02) {\n int len = n \/ 2;\n const char16_t *framedata = (const char16_t *) (frameData + 1);\n char16_t *framedatacopy = NULL;\n#if BYTE_ORDER == LITTLE_ENDIAN\n if (len > 0) {\n framedatacopy = new (std::nothrow) char16_t[len];\n if (framedatacopy == NULL) {\n return;\n }\n for (int i = 0; i < len; i++) {\n framedatacopy[i] = bswap_16(framedata[i]);\n }\n framedata = framedatacopy;\n }\n#endif\n id->setTo(framedata, len);\n if (framedatacopy != NULL) {\n delete[] framedatacopy;\n }\n } else if (encoding == 0x01) {\n int len = n \/ 2;\n const char16_t *framedata = (const char16_t *) (frameData + 1);\n char16_t *framedatacopy = NULL;\n if (*framedata == 0xfffe) {\n if (len <= 1) {\n return; \/\/ nothing after the marker\n }\n framedatacopy = new (std::nothrow) char16_t[len];\n if (framedatacopy == NULL) {\n return;\n }\n for (int i = 0; i < len; i++) {\n framedatacopy[i] = bswap_16(framedata[i]);\n }\n framedata = framedatacopy;\n framedata++;\n len--;\n } else if (*framedata == 0xfeff) {\n if (len <= 1) {\n return; \/\/ nothing after the marker\n }\n framedata++;\n len--;\n }\n\n bool eightBit = true;\n for (int i = 0; i < len; i++) {\n if (framedata[i] > 0xff) {\n eightBit = false;\n break;\n }\n }\n if (eightBit) {\n char *frame8 = new (std::nothrow) char[len];\n if (frame8 != NULL) {\n for (int i = 0; i < len; i++) {\n frame8[i] = framedata[i];\n }\n id->setTo(frame8, len);\n delete [] frame8;\n } else {\n id->setTo(framedata, len);\n }\n } else {\n id->setTo(framedata, len);\n }\n\n if (framedatacopy != NULL) {\n delete[] framedatacopy;\n }\n }\n}\n","target":0,"code_token_length":862,"total_token_length":1098,"max_tokens_setting":2048} +{"idx":439845,"func":"ipmi_sdr_read_sensor_value(struct ipmi_intf *intf,\n\t\t struct sdr_record_common_sensor *sensor,\n\t\t uint8_t sdr_record_type, int precision)\n{\n\tstatic struct sensor_reading sr;\n\n\tif (!sensor)\n\t\treturn NULL;\n\n\t\/* Initialize to reading valid value of zero *\/\n\tmemset(&sr, 0, sizeof(sr));\n\n\tswitch (sdr_record_type) {\n\t\tunsigned int idlen;\n\t\tcase (SDR_RECORD_TYPE_FULL_SENSOR):\n\t\t\tsr.full = (struct sdr_record_full_sensor *)sensor;\n\t\t\tidlen = sr.full->id_code & 0x1f;\n\t\t\tidlen = idlen < sizeof(sr.s_id) ?\n\t\t\t\t\t\tidlen : sizeof(sr.s_id) - 1;\n\t\t\tmemcpy(sr.s_id, sr.full->id_string, idlen);\n\t\t\tbreak;\n\t\tcase SDR_RECORD_TYPE_COMPACT_SENSOR:\n\t\t\tsr.compact = (struct sdr_record_compact_sensor *)sensor;\n\t\t\tidlen = sr.compact->id_code & 0x1f;\n\t\t\tidlen = idlen < sizeof(sr.s_id) ?\n\t\t\t\t\t\tidlen : sizeof(sr.s_id) - 1;\n\t\t\tmemcpy(sr.s_id, sr.compact->id_string, idlen);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn NULL;\n\t}\n\n\t\/*\n\t * Get current reading via IPMI interface\n\t *\/\n\tstruct ipmi_rs *rsp;\n\trsp = ipmi_sdr_get_sensor_reading_ipmb(intf,\n\t\t\t\t\t sensor->keys.sensor_num,\n\t\t\t\t\t sensor->keys.owner_id,\n\t\t\t\t\t sensor->keys.lun,\n\t\t\t\t\t sensor->keys.channel);\n\tsr.s_a_val = 0.0;\t\/* init analog value to a floating point 0 *\/\n\tsr.s_a_str[0] = '\\0';\t\/* no converted analog value string *\/\n\tsr.s_a_units = \"\";\t\/* no converted analog units units *\/\n\n\n\tif (!rsp) {\n\t\tlprintf(LOG_DEBUG, \"Error reading sensor %s (#%02x)\",\n\t\t\tsr.s_id, sensor->keys.sensor_num);\n\t\treturn &sr;\n\t}\n\n\tif (rsp->ccode) {\n\t\tif ( !((sr.full && rsp->ccode == 0xcb) ||\n\t\t (sr.compact && rsp->ccode == 0xcd)) ) {\n\t\t\tlprintf(LOG_DEBUG,\n\t\t\t\t\"Error reading sensor %s (#%02x): %s\", sr.s_id,\n\t\t\t\tsensor->keys.sensor_num,\n\t\t\t\tval2str(rsp->ccode, completion_code_vals));\n\t\t}\n\t\treturn &sr;\n\t}\n\n\tif (rsp->data_len < 2) {\n\t\t\/*\n\t\t * We must be returned both a value (data[0]), and the validity\n\t\t * of the value (data[1]), in order to correctly interpret\n\t\t * the reading. If we don't have both of these we can't have\n\t\t * a valid sensor reading.\n\t\t *\/\n\t\tlprintf(LOG_DEBUG, \"Error reading sensor %s invalid len %d\",\n\t\t\tsr.s_id, rsp->data_len);\n\t\treturn &sr;\n\t}\n\n\n\tif (IS_READING_UNAVAILABLE(rsp->data[1]))\n\t\tsr.s_reading_unavailable = 1;\n\n\tif (IS_SCANNING_DISABLED(rsp->data[1])) {\n\t\tsr.s_scanning_disabled = 1;\n\t\tlprintf(LOG_DEBUG, \"Sensor %s (#%02x) scanning disabled\",\n\t\t\tsr.s_id, sensor->keys.sensor_num);\n\t\treturn &sr;\n\t}\n\tif ( !sr.s_reading_unavailable ) {\n\t\tsr.s_reading_valid = 1;\n\t\tsr.s_reading = rsp->data[0];\n\t}\n\tif (rsp->data_len > 2)\n\t\tsr.s_data2 = rsp->data[2];\n\tif (rsp->data_len > 3)\n\t\tsr.s_data3 = rsp->data[3];\n\tif (sdr_sensor_has_analog_reading(intf, &sr)) {\n\t\tsr.s_has_analog_value = 1;\n\t\tif (sr.s_reading_valid) {\n\t\t\tsr.s_a_val = sdr_convert_sensor_reading(sr.full, sr.s_reading);\n\t\t}\n\t\t\/* determine units string with possible modifiers *\/\n\t\tsr.s_a_units = ipmi_sdr_get_unit_string(sr.full->cmn.unit.pct,\n\t\t\t\t\t sr.full->cmn.unit.modifier,\n\t\t\t\t\t sr.full->cmn.unit.type.base,\n\t\t\t\t\t sr.full->cmn.unit.type.modifier);\n\t\tsnprintf(sr.s_a_str, sizeof(sr.s_a_str), \"%.*f\",\n\t\t\t(sr.s_a_val == (int) sr.s_a_val) ? 0 :\n\t\t\tprecision, sr.s_a_val);\n\t}\n\treturn &sr;\n}","target":0,"code_token_length":993,"total_token_length":1229,"max_tokens_setting":2048} +{"idx":340035,"func":"int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,\n\n int64_t pos_min, int64_t pos_max, int64_t pos_limit,\n\n int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret,\n\n int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))\n\n{\n\n int64_t pos, ts;\n\n int64_t start_pos, filesize;\n\n int no_change;\n\n\n\n av_dlog(s, \"gen_seek: %d %s\\n\", stream_index, av_ts2str(target_ts));\n\n\n\n if(ts_min == AV_NOPTS_VALUE){\n\n pos_min = s->data_offset;\n\n ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);\n\n if (ts_min == AV_NOPTS_VALUE)\n\n return -1;\n\n }\n\n\n\n if(ts_min >= target_ts){\n\n *ts_ret= ts_min;\n\n return pos_min;\n\n }\n\n\n\n if(ts_max == AV_NOPTS_VALUE){\n\n int64_t step= 1024;\n\n int64_t limit;\n\n filesize = avio_size(s->pb);\n\n pos_max = filesize - 1;\n\n do{\n\n limit = pos_max;\n\n pos_max = FFMAX(0, pos_max - step);\n\n ts_max = ff_read_timestamp(s, stream_index, &pos_max, limit, read_timestamp);\n\n step += step;\n\n }while(ts_max == AV_NOPTS_VALUE && pos_max > 0);\n\n if (ts_max == AV_NOPTS_VALUE)\n\n return -1;\n\n\n\n for(;;){\n\n int64_t tmp_pos= pos_max + 1;\n\n int64_t tmp_ts= ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp);\n\n if(tmp_ts == AV_NOPTS_VALUE)\n\n break;\n\n ts_max= tmp_ts;\n\n pos_max= tmp_pos;\n\n if(tmp_pos >= filesize)\n\n break;\n\n }\n\n pos_limit= pos_max;\n\n }\n\n\n\n if(ts_max <= target_ts){\n\n *ts_ret= ts_max;\n\n return pos_max;\n\n }\n\n\n\n if(ts_min > ts_max){\n\n return -1;\n\n }else if(ts_min == ts_max){\n\n pos_limit= pos_min;\n\n }\n\n\n\n no_change=0;\n\n while (pos_min < pos_limit) {\n\n av_dlog(s, \"pos_min=0x%\"PRIx64\" pos_max=0x%\"PRIx64\" dts_min=%s dts_max=%s\\n\",\n\n pos_min, pos_max, av_ts2str(ts_min), av_ts2str(ts_max));\n\n assert(pos_limit <= pos_max);\n\n\n\n if(no_change==0){\n\n int64_t approximate_keyframe_distance= pos_max - pos_limit;\n\n \/\/ interpolate position (better than dichotomy)\n\n pos = av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min)\n\n + pos_min - approximate_keyframe_distance;\n\n }else if(no_change==1){\n\n \/\/ bisection, if interpolation failed to change min or max pos last time\n\n pos = (pos_min + pos_limit)>>1;\n\n }else{\n\n \/* linear search if bisection failed, can only happen if there\n\n are very few or no keyframes between min\/max *\/\n\n pos=pos_min;\n\n }\n\n if(pos <= pos_min)\n\n pos= pos_min + 1;\n\n else if(pos > pos_limit)\n\n pos= pos_limit;\n\n start_pos= pos;\n\n\n\n ts = ff_read_timestamp(s, stream_index, &pos, INT64_MAX, read_timestamp); \/\/may pass pos_limit instead of -1\n\n if(pos == pos_max)\n\n no_change++;\n\n else\n\n no_change=0;\n\n av_dlog(s, \"%\"PRId64\" %\"PRId64\" %\"PRId64\" \/ %s %s %s target:%s limit:%\"PRId64\" start:%\"PRId64\" noc:%d\\n\",\n\n pos_min, pos, pos_max,\n\n av_ts2str(ts_min), av_ts2str(ts), av_ts2str(ts_max), av_ts2str(target_ts),\n\n pos_limit, start_pos, no_change);\n\n if(ts == AV_NOPTS_VALUE){\n\n av_log(s, AV_LOG_ERROR, \"read_timestamp() failed in the middle\\n\");\n\n return -1;\n\n }\n\n assert(ts != AV_NOPTS_VALUE);\n\n if (target_ts <= ts) {\n\n pos_limit = start_pos - 1;\n\n pos_max = pos;\n\n ts_max = ts;\n\n }\n\n if (target_ts >= ts) {\n\n pos_min = pos;\n\n ts_min = ts;\n\n }\n\n }\n\n\n\n pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;\n\n ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max;\n\n#if 0\n\n pos_min = pos;\n\n ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);\n\n pos_min++;\n\n ts_max = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);\n\n av_dlog(s, \"pos=0x%\"PRIx64\" %s<=%s<=%s\\n\",\n\n pos, av_ts2str(ts_min), av_ts2str(target_ts), av_ts2str(ts_max));\n\n#endif\n\n *ts_ret= ts;\n\n return pos;\n\n}\n","target":0,"code_token_length":1209,"total_token_length":1445,"max_tokens_setting":2048} +{"idx":339667,"func":"static int configure_video_filters(FilterGraph *fg)\n\n{\n\n InputStream *ist = fg->inputs[0]->ist;\n\n OutputStream *ost = fg->outputs[0]->ost;\n\n AVFilterContext *in_filter, *out_filter, *filter;\n\n AVCodecContext *codec = ost->st->codec;\n\n AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();\n\n char *pix_fmts;\n\n AVRational sample_aspect_ratio;\n\n char args[255];\n\n int ret;\n\n\n\n avfilter_graph_free(&fg->graph);\n\n fg->graph = avfilter_graph_alloc();\n\n if (!fg->graph)\n\n return AVERROR(ENOMEM);\n\n\n\n if (ist->st->sample_aspect_ratio.num) {\n\n sample_aspect_ratio = ist->st->sample_aspect_ratio;\n\n } else\n\n sample_aspect_ratio = ist->st->codec->sample_aspect_ratio;\n\n\n\n snprintf(args, 255, \"%d:%d:%d:%d:%d:%d:%d:flags=%d\", ist->st->codec->width,\n\n ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,\n\n sample_aspect_ratio.num, sample_aspect_ratio.den, SWS_BILINEAR + ((ist->st->codec->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));\n\n\n\n ret = avfilter_graph_create_filter(&fg->inputs[0]->filter,\n\n avfilter_get_by_name(\"buffer\"),\n\n \"src\", args, NULL, fg->graph);\n\n if (ret < 0)\n\n return ret;\n\n\n\n#if FF_API_OLD_VSINK_API\n\n ret = avfilter_graph_create_filter(&fg->outputs[0]->filter,\n\n avfilter_get_by_name(\"buffersink\"),\n\n \"out\", NULL, NULL, fg->graph);\n\n#else\n\n ret = avfilter_graph_create_filter(&fg->outputs[0]->filter,\n\n avfilter_get_by_name(\"buffersink\"),\n\n \"out\", NULL, buffersink_params, fg->graph);\n\n#endif\n\n av_freep(&buffersink_params);\n\n\n\n if (ret < 0)\n\n return ret;\n\n in_filter = fg->inputs[0]->filter;\n\n out_filter = fg->outputs[0]->filter;\n\n\n\n if (codec->width || codec->height) {\n\n snprintf(args, 255, \"%d:%d:flags=0x%X\",\n\n codec->width,\n\n codec->height,\n\n (unsigned)ost->sws_flags);\n\n if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name(\"scale\"),\n\n NULL, args, NULL, fg->graph)) < 0)\n\n return ret;\n\n if ((ret = avfilter_link(in_filter, 0, filter, 0)) < 0)\n\n return ret;\n\n in_filter = filter;\n\n }\n\n\n\n if ((pix_fmts = choose_pixel_fmts(ost))) {\n\n if ((ret = avfilter_graph_create_filter(&filter,\n\n avfilter_get_by_name(\"format\"),\n\n \"format\", pix_fmts, NULL,\n\n fg->graph)) < 0)\n\n return ret;\n\n if ((ret = avfilter_link(filter, 0, out_filter, 0)) < 0)\n\n return ret;\n\n\n\n out_filter = filter;\n\n av_freep(&pix_fmts);\n\n }\n\n\n\n snprintf(args, sizeof(args), \"flags=0x%X\", (unsigned)ost->sws_flags);\n\n fg->graph->scale_sws_opts = av_strdup(args);\n\n\n\n if (ost->avfilter) {\n\n AVFilterInOut *outputs = avfilter_inout_alloc();\n\n AVFilterInOut *inputs = avfilter_inout_alloc();\n\n\n\n outputs->name = av_strdup(\"in\");\n\n outputs->filter_ctx = in_filter;\n\n outputs->pad_idx = 0;\n\n outputs->next = NULL;\n\n\n\n inputs->name = av_strdup(\"out\");\n\n inputs->filter_ctx = out_filter;\n\n inputs->pad_idx = 0;\n\n inputs->next = NULL;\n\n\n\n if ((ret = avfilter_graph_parse(fg->graph, ost->avfilter, &inputs, &outputs, NULL)) < 0)\n\n return ret;\n\n av_freep(&ost->avfilter);\n\n } else {\n\n if ((ret = avfilter_link(in_filter, 0, out_filter, 0)) < 0)\n\n return ret;\n\n }\n\n\n\n if (ost->keep_pix_fmt)\n\n avfilter_graph_set_auto_convert(fg->graph,\n\n AVFILTER_AUTO_CONVERT_NONE);\n\n\n\n if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)\n\n return ret;\n\n\n\n ost->filter = fg->outputs[0];\n\n\n\n return 0;\n\n}\n","target":1,"code_token_length":1007,"total_token_length":1243,"max_tokens_setting":2048} +{"idx":10522,"func":"void impeg2d_dec_hdr(void *pv_dec,impeg2d_video_decode_ip_t *ps_ip,\n impeg2d_video_decode_op_t *ps_op)\n{\n\n UWORD32 u4_bits_read;\n dec_state_t *ps_dec;\n UWORD32 u4_size = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes;\n\n ps_dec = (dec_state_t *)pv_dec;\n ps_op->s_ivd_video_decode_op_t.u4_error_code = 0;\n if (u4_size > MAX_BITSTREAM_BUFFER_SIZE)\n {\n u4_size = MAX_BITSTREAM_BUFFER_SIZE;\n }\n\n memcpy(ps_dec->pu1_input_buffer, ps_ip->s_ivd_video_decode_ip_t.pv_stream_buffer, u4_size);\n\n impeg2d_bit_stream_init(&(ps_dec->s_bit_stream), ps_dec->pu1_input_buffer,\n u4_size);\n\n {\n {\n IMPEG2D_ERROR_CODES_T e_error;\n e_error = impeg2d_process_video_header(ps_dec);\n if ((IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE != e_error)\n {\n ps_op->s_ivd_video_decode_op_t.u4_error_code = e_error;\n\n u4_bits_read = impeg2d_bit_stream_num_bits_read(&ps_dec->s_bit_stream);\n\n ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = u4_bits_read>> 3;\n if(ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed > ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes)\n {\n ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes;\n }\n if(ps_op->s_ivd_video_decode_op_t.u4_error_code == 0)\n ps_op->s_ivd_video_decode_op_t.u4_error_code = e_error;\n\n if (IMPEG2D_UNSUPPORTED_DIMENSIONS == e_error)\n {\n ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = 0;\n ps_dec->u2_header_done = 0;\n\n ps_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec->u2_reinit_max_height;\n ps_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec->u2_reinit_max_width;\n }\n impeg2d_next_code(ps_dec, SEQUENCE_HEADER_CODE);\n return;\n }\n }\n ps_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec->u2_vertical_size;\n ps_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec->u2_horizontal_size;\n\n ps_op->s_ivd_video_decode_op_t.e_pic_type = IV_NA_FRAME;\n ps_op->s_ivd_video_decode_op_t.u4_error_code = IV_SUCCESS;\n\n u4_bits_read = impeg2d_bit_stream_num_bits_read(&ps_dec->s_bit_stream);\n ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = u4_bits_read>> 3;\n if(ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed > ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes)\n {\n\n ps_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_ip->s_ivd_video_decode_ip_t.u4_num_Bytes;\n }\n ps_op->s_ivd_video_decode_op_t.u4_frame_decoded_flag = 0;\n \/* MOD *\/\n ps_dec->u2_header_done = 1;\n \n }\n}\n","target":1,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048} +{"idx":995,"func":"static int truemotion1_decode_header ( TrueMotion1Context * s ) {\n int i , ret ;\n int width_shift = 0 ;\n int new_pix_fmt ;\n struct frame_header header ;\n uint8_t header_buffer [ 128 ] = {\n 0 }\n ;\n const uint8_t * sel_vector_table ;\n header . header_size = ( ( s -> buf [ 0 ] >> 5 ) | ( s -> buf [ 0 ] << 3 ) ) & 0x7f ;\n if ( s -> buf [ 0 ] < 0x10 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"invalid header size (%d)\\n\" , s -> buf [ 0 ] ) ;\n return AVERROR_INVALIDDATA ;\n }\n for ( i = 1 ;\n i < header . header_size ;\n i ++ ) header_buffer [ i - 1 ] = s -> buf [ i ] ^ s -> buf [ i + 1 ] ;\n header . compression = header_buffer [ 0 ] ;\n header . deltaset = header_buffer [ 1 ] ;\n header . vectable = header_buffer [ 2 ] ;\n header . ysize = AV_RL16 ( & header_buffer [ 3 ] ) ;\n header . xsize = AV_RL16 ( & header_buffer [ 5 ] ) ;\n header . checksum = AV_RL16 ( & header_buffer [ 7 ] ) ;\n header . version = header_buffer [ 9 ] ;\n header . header_type = header_buffer [ 10 ] ;\n header . flags = header_buffer [ 11 ] ;\n header . control = header_buffer [ 12 ] ;\n if ( header . version >= 2 ) {\n if ( header . header_type > 3 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"invalid header type (%d)\\n\" , header . header_type ) ;\n return AVERROR_INVALIDDATA ;\n }\n else if ( ( header . header_type == 2 ) || ( header . header_type == 3 ) ) {\n s -> flags = header . flags ;\n if ( ! ( s -> flags & FLAG_INTERFRAME ) ) s -> flags |= FLAG_KEYFRAME ;\n }\n else s -> flags = FLAG_KEYFRAME ;\n }\n else s -> flags = FLAG_KEYFRAME ;\n if ( s -> flags & FLAG_SPRITE ) {\n av_log_ask_for_sample ( s -> avctx , \"SPRITE frame found.\\n\" ) ;\n return AVERROR_PATCHWELCOME ;\n }\n else {\n s -> w = header . xsize ;\n s -> h = header . ysize ;\n if ( header . header_type < 2 ) {\n if ( ( s -> w < 213 ) && ( s -> h >= 176 ) ) {\n s -> flags |= FLAG_INTERPOLATED ;\n av_log_ask_for_sample ( s -> avctx , \"INTERPOLATION selected.\\n\" ) ;\n }\n }\n }\n if ( header . compression >= 17 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"invalid compression type (%d)\\n\" , header . compression ) ;\n return AVERROR_INVALIDDATA ;\n }\n if ( ( header . deltaset != s -> last_deltaset ) || ( header . vectable != s -> last_vectable ) ) select_delta_tables ( s , header . deltaset ) ;\n if ( ( header . compression & 1 ) && header . header_type ) sel_vector_table = pc_tbl2 ;\n else {\n if ( header . vectable > 0 && header . vectable < 4 ) sel_vector_table = tables [ header . vectable - 1 ] ;\n else {\n av_log ( s -> avctx , AV_LOG_ERROR , \"invalid vector table id (%d)\\n\" , header . vectable ) ;\n return AVERROR_INVALIDDATA ;\n }\n }\n if ( compression_types [ header . compression ] . algorithm == ALGO_RGB24H ) {\n new_pix_fmt = AV_PIX_FMT_RGB32 ;\n width_shift = 1 ;\n }\n else new_pix_fmt = AV_PIX_FMT_RGB555 ;\n s -> w >>= width_shift ;\n if ( ( ret = av_image_check_size ( s -> w , s -> h , 0 , s -> avctx ) ) < 0 ) return ret ;\n if ( s -> w != s -> avctx -> width || s -> h != s -> avctx -> height || new_pix_fmt != s -> avctx -> pix_fmt ) {\n if ( s -> frame . data [ 0 ] ) s -> avctx -> release_buffer ( s -> avctx , & s -> frame ) ;\n s -> avctx -> sample_aspect_ratio = ( AVRational ) {\n 1 << width_shift , 1 }\n ;\n s -> avctx -> pix_fmt = new_pix_fmt ;\n avcodec_set_dimensions ( s -> avctx , s -> w , s -> h ) ;\n av_fast_malloc ( & s -> vert_pred , & s -> vert_pred_size , s -> avctx -> width * sizeof ( unsigned int ) ) ;\n }\n s -> mb_change_bits_row_size = ( ( s -> avctx -> width >> ( 2 - width_shift ) ) + 7 ) >> 3 ;\n if ( ( header . deltaset != s -> last_deltaset ) || ( header . vectable != s -> last_vectable ) ) {\n if ( compression_types [ header . compression ] . algorithm == ALGO_RGB24H ) gen_vector_table24 ( s , sel_vector_table ) ;\n else if ( s -> avctx -> pix_fmt == AV_PIX_FMT_RGB555 ) gen_vector_table15 ( s , sel_vector_table ) ;\n else gen_vector_table16 ( s , sel_vector_table ) ;\n }\n s -> mb_change_bits = s -> buf + header . header_size ;\n if ( s -> flags & FLAG_KEYFRAME ) {\n s -> index_stream = s -> mb_change_bits ;\n }\n else {\n s -> index_stream = s -> mb_change_bits + ( s -> mb_change_bits_row_size * ( s -> avctx -> height >> 2 ) ) ;\n }\n s -> index_stream_size = s -> size - ( s -> index_stream - s -> buf ) ;\n s -> last_deltaset = header . deltaset ;\n s -> last_vectable = header . vectable ;\n s -> compression = header . compression ;\n s -> block_width = compression_types [ header . compression ] . block_width ;\n s -> block_height = compression_types [ header . compression ] . block_height ;\n s -> block_type = compression_types [ header . compression ] . block_type ;\n if ( s -> avctx -> debug & FF_DEBUG_PICT_INFO ) av_log ( s -> avctx , AV_LOG_INFO , \"tables: %d \/ %d c:%d %dx%d t:%d %s%s%s%s\\n\" , s -> last_deltaset , s -> last_vectable , s -> compression , s -> block_width , s -> block_height , s -> block_type , s -> flags & FLAG_KEYFRAME ? \" KEY\" : \"\" , s -> flags & FLAG_INTERFRAME ? \" INTER\" : \"\" , s -> flags & FLAG_SPRITE ? \" SPRITE\" : \"\" , s -> flags & FLAG_INTERPOLATED ? \" INTERPOL\" : \"\" ) ;\n return header . header_size ;\n }","target":1,"code_token_length":1500,"total_token_length":1736,"max_tokens_setting":2048} +{"idx":347389,"func":"gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) \/* {{{ *\/\n{\n\tint BitPixel;\n#if 0\n\tint ColorResolution;\n\tint Background;\n\tint AspectRatio;\n#endif\n\tint Transparent = (-1);\n\tunsigned char buf[16];\n\tunsigned char c;\n\tunsigned char ColorMap[3][MAXCOLORMAPSIZE];\n\tunsigned char localColorMap[3][MAXCOLORMAPSIZE];\n\tint imw, imh, screen_width, screen_height;\n\tint gif87a, useGlobalColormap;\n\tint bitPixel;\n\tint\t i;\n\t\/*1.4\/\/int imageCount = 0; *\/\n\n\tint ZeroDataBlock = FALSE;\n\tint haveGlobalColormap;\n\tgdImagePtr im = 0;\n\n\tmemset(ColorMap, 0, 3 * MAXCOLORMAPSIZE);\n\tmemset(localColorMap, 0, 3 * MAXCOLORMAPSIZE);\n\n\t\/*1.4\/\/imageNumber = 1; *\/\n\tif (! ReadOK(fd,buf,6)) {\n\t\treturn 0;\n\t}\n\tif (strncmp((char *)buf,\"GIF\",3) != 0) {\n\t\treturn 0;\n\t}\n\n\tif (memcmp((char *)buf+3, \"87a\", 3) == 0) {\n\t\tgif87a = 1;\n\t} else if (memcmp((char *)buf+3, \"89a\", 3) == 0) {\n\t\tgif87a = 0;\n\t} else {\n\t\treturn 0;\n\t}\n\n\tif (! ReadOK(fd,buf,7)) {\n\t\treturn 0;\n\t}\n\n\tBitPixel = 2<<(buf[4]&0x07);\n#if 0\n\tColorResolution = (int) (((buf[4]&0x70)>>3)+1);\n\tBackground = buf[5];\n\tAspectRatio = buf[6];\n#endif\n\tscreen_width = imw = LM_to_uint(buf[0],buf[1]);\n\tscreen_height = imh = LM_to_uint(buf[2],buf[3]);\n\n\thaveGlobalColormap = BitSet(buf[4], LOCALCOLORMAP); \/* Global Colormap *\/\n\tif (haveGlobalColormap) {\n\t\tif (ReadColorMap(fd, BitPixel, ColorMap)) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tfor (;;) {\n\t\tint top, left;\n\t\tint width, height;\n\n\t\tif (! ReadOK(fd,&c,1)) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (c == ';') { \/* GIF terminator *\/\n\t\t\tgoto terminated;\n\t\t}\n\n\t\tif (c == '!') { \/* Extension *\/\n\t\t\tif (! ReadOK(fd,&c,1)) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tDoExtension(fd, c, &Transparent, &ZeroDataBlock);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (c != ',') { \/* Not a valid start character *\/\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/*1.4\/\/++imageCount; *\/\n\n\t\tif (! ReadOK(fd,buf,9)) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tuseGlobalColormap = ! BitSet(buf[8], LOCALCOLORMAP);\n\n\t\tbitPixel = 1<<((buf[8]&0x07)+1);\n\t\tleft = LM_to_uint(buf[0], buf[1]);\n\t\ttop = LM_to_uint(buf[2], buf[3]);\n\t\twidth = LM_to_uint(buf[4], buf[5]);\n\t\theight = LM_to_uint(buf[6], buf[7]);\n\n\t\tif (left + width > screen_width || top + height > screen_height) {\n\t\t\tif (VERBOSE) {\n\t\t\t\tprintf(\"Frame is not confined to screen dimension.\\n\");\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (!(im = gdImageCreate(width, height))) {\n\t\t\treturn 0;\n\t\t}\n\t\tim->interlace = BitSet(buf[8], INTERLACE);\n\t\tif (!useGlobalColormap) {\n\t\t\tif (ReadColorMap(fd, bitPixel, localColorMap)) { \n\t\t\t\tgdImageDestroy(im);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tReadImage(im, fd, width, height, localColorMap, \n\t\t\t\t\tBitSet(buf[8], INTERLACE), &ZeroDataBlock);\n\t\t} else {\n\t\t\tif (!haveGlobalColormap) {\n\t\t\t\tgdImageDestroy(im);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tReadImage(im, fd, width, height,\n\t\t\t\t\t\tColorMap, \n\t\t\t\t\t\tBitSet(buf[8], INTERLACE), &ZeroDataBlock);\n\t\t}\n\t\tif (Transparent != (-1)) {\n\t\t\tgdImageColorTransparent(im, Transparent);\n\t\t}\n\t\tgoto terminated;\n\t}\n\nterminated:\n\t\/* Terminator before any image was declared! *\/\n\tif (!im) {\n\t\treturn 0;\n\t}\n\tif (!im->colorsTotal) {\n\t\tgdImageDestroy(im);\n\t\treturn 0;\n\t}\n\t\/* Check for open colors at the end, so\n\t we can reduce colorsTotal and ultimately\n\t BitsPerPixel *\/\n\tfor (i=((im->colorsTotal-1)); (i>=0); i--) {\n\t\tif (im->open[i]) {\n\t\t\tim->colorsTotal--;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn im;\n}","target":1,"code_token_length":1122,"total_token_length":1358,"max_tokens_setting":2048} +{"idx":278492,"func":"static MagickBooleanType sixel_encode_impl(unsigned char *pixels, size_t width,size_t height,\n unsigned char *palette, size_t ncolors, int keycolor,\n sixel_output_t *context)\n{\n#define RelinquishNodesAndMap \\\n while ((np = context->node_free) != NULL) { \\\n context->node_free = np->next; \\\n np=(sixel_node_t *) RelinquishMagickMemory(np); \\\n } \\\n map = (unsigned char *) RelinquishMagickMemory(map)\n\n int x, y, i, n, c;\n int left, right;\n int pix;\n size_t len;\n unsigned char *map;\n sixel_node_t *np, *tp, top;\n int nwrite;\n\n context->pos = 0;\n\n if (ncolors < 1) {\n return (MagickFalse);\n }\n len = ncolors * width;\n context->active_palette = (-1);\n\n if ((map = (unsigned char *)AcquireQuantumMemory(len, sizeof(unsigned char))) == NULL) {\n return (MagickFalse);\n }\n (void) ResetMagickMemory(map, 0, len);\n\n if (context->has_8bit_control) {\n nwrite = sprintf((char *)context->buffer, \"\\x90\" \"0;0;0\" \"q\");\n } else {\n nwrite = sprintf((char *)context->buffer, \"\\x1bP\" \"0;0;0\" \"q\");\n }\n if (nwrite <= 0) {\n return (MagickFalse);\n }\n sixel_advance(context, nwrite);\n nwrite = sprintf((char *)context->buffer + context->pos, \"\\\"1;1;%d;%d\", (int) width, (int) height);\n if (nwrite <= 0) {\n RelinquishNodesAndMap;\n return (MagickFalse);\n }\n sixel_advance(context, nwrite);\n\n if (ncolors != 2 || keycolor == -1) {\n for (n = 0; n < (ssize_t) ncolors; n++) {\n \/* DECGCI Graphics Color Introducer # Pc ; Pu; Px; Py; Pz *\/\n nwrite = sprintf((char *)context->buffer + context->pos, \"#%d;2;%d;%d;%d\",\n n,\n (palette[n * 3 + 0] * 100 + 127) \/ 255,\n (palette[n * 3 + 1] * 100 + 127) \/ 255,\n (palette[n * 3 + 2] * 100 + 127) \/ 255);\n if (nwrite <= 0) {\n RelinquishNodesAndMap;\n return (MagickFalse);\n }\n sixel_advance(context, nwrite);\n if (nwrite <= 0) {\n RelinquishNodesAndMap;\n return (MagickFalse);\n }\n }\n }\n\n for (y = i = 0; y < (ssize_t) height; y++) {\n for (x = 0; x < (ssize_t) width; x++) {\n pix = pixels[y * width + x];\n if (pix >= 0 && pix < (ssize_t) ncolors && pix != keycolor) {\n map[pix * width + x] |= (1 << i);\n }\n }\n\n if (++i < 6 && (y + 1) < (ssize_t) height) {\n continue;\n }\n\n for (c = 0; c < (ssize_t) ncolors; c++) {\n for (left = 0; left < (ssize_t) width; left++) {\n if (*(map + c * width + left) == 0) {\n continue;\n }\n\n for (right = left + 1; right < (ssize_t) width; right++) {\n if (*(map + c * width + right) != 0) {\n continue;\n }\n\n for (n = 1; (right + n) < (ssize_t) width; n++) {\n if (*(map + c * width + right + n) != 0) {\n break;\n }\n }\n\n if (n >= 10 || right + n >= (ssize_t) width) {\n break;\n }\n right = right + n - 1;\n }\n\n if ((np = context->node_free) != NULL) {\n context->node_free = np->next;\n } else if ((np = (sixel_node_t *)AcquireMagickMemory(sizeof(sixel_node_t))) == NULL) {\n RelinquishNodesAndMap;\n return (MagickFalse);\n }\n\n np->color = c;\n np->left = left;\n np->right = right;\n np->map = map + c * width;\n\n top.next = context->node_top;\n tp = ⊤\n\n while (tp->next != NULL) {\n if (np->left < tp->next->left) {\n break;\n }\n if (np->left == tp->next->left && np->right > tp->next->right) {\n break;\n }\n tp = tp->next;\n }\n\n np->next = tp->next;\n tp->next = np;\n context->node_top = top.next;\n\n left = right - 1;\n }\n\n }\n\n for (x = 0; (np = context->node_top) != NULL;) {\n if (x > np->left) {\n \/* DECGCR Graphics Carriage Return *\/\n context->buffer[context->pos] = '$';\n sixel_advance(context, 1);\n x = 0;\n }\n\n x = sixel_put_node(context, x, np, (int) ncolors, keycolor);\n sixel_node_del(context, np);\n np = context->node_top;\n\n while (np != NULL) {\n if (np->left < x) {\n np = np->next;\n continue;\n }\n\n x = sixel_put_node(context, x, np, (int) ncolors, keycolor);\n sixel_node_del(context, np);\n np = context->node_top;\n }\n }\n\n \/* DECGNL Graphics Next Line *\/\n context->buffer[context->pos] = '-';\n sixel_advance(context, 1);\n if (nwrite <= 0) {\n RelinquishNodesAndMap;\n return (MagickFalse);\n }\n\n i = 0;\n (void) ResetMagickMemory(map, 0, len);\n }\n\n if (context->has_8bit_control) {\n context->buffer[context->pos] = 0x9c;\n sixel_advance(context, 1);\n } else {\n context->buffer[context->pos] = 0x1b;\n context->buffer[context->pos + 1] = '\\\\';\n sixel_advance(context, 2);\n }\n if (nwrite <= 0) {\n RelinquishNodesAndMap;\n return (MagickFalse);\n }\n\n \/* flush buffer *\/\n if (context->pos > 0) {\n (void) WriteBlob(context->image,context->pos,context->buffer);\n }\n\n RelinquishNodesAndMap;\n\n return(MagickTrue);\n}\n","target":0,"code_token_length":1619,"total_token_length":1855,"max_tokens_setting":2048} +{"idx":8742,"func":"exif_data_load_data (ExifData *data, const unsigned char *d_orig,\n\t\t unsigned int ds)\n{\n\tunsigned int l;\n\tExifLong offset;\n\tExifShort n;\n\tconst unsigned char *d = d_orig;\n\tunsigned int len, fullds;\n\n\tif (!data || !data->priv || !d || !ds)\n\t\treturn;\n\n\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t \"Parsing %i byte(s) EXIF data...\\n\", ds);\n\n\t\/*\n\t * It can be that the data starts with the EXIF header. If it does\n\t * not, search the EXIF marker.\n\t *\/\n\tif (ds < 6) {\n\t\tLOG_TOO_SMALL;\n\t\treturn;\n\t}\n\tif (!memcmp (d, ExifHeader, 6)) {\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t \"Found EXIF header at start.\");\n\t} else {\n\t\twhile (ds >= 3) {\n\t\t\twhile (ds && (d[0] == 0xff)) {\n\t\t\t\td++;\n\t\t\t\tds--;\n\t\t\t}\n\n\t\t\t\/* JPEG_MARKER_SOI *\/\n\t\t\tif (ds && d[0] == JPEG_MARKER_SOI) {\n\t\t\t\td++;\n\t\t\t\tds--;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/* JPEG_MARKER_APP1 *\/\n\t\t\tif (ds && d[0] == JPEG_MARKER_APP1)\n\t\t\t\tbreak;\n\n\t\t\t\/* Skip irrelevant APP markers. The branch for APP1 must come before this,\n\t\t\t otherwise this code block will cause APP1 to be skipped. This code path\n\t\t\t is only relevant for files that are nonconformant to the EXIF\n\t\t\t specification. For conformant files, the APP1 code path above will be\n\t\t\t taken. *\/\n\t\t\tif (ds >= 3 && d[0] >= 0xe0 && d[0] <= 0xef) { \/* JPEG_MARKER_APPn *\/\n\t\t\t\td++;\n\t\t\t\tds--;\n\t\t\t\tl = (d[0] << 8) | d[1];\n\t\t\t\tif (l > ds)\n\t\t\t\t\treturn;\n\t\t\t\td += l;\n\t\t\t\tds -= l;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/* Unknown marker or data. Give up. *\/\n\t\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t \"ExifData\", _(\"EXIF marker not found.\"));\n\t\t\treturn;\n\t\t}\n\t\tif (ds < 3) {\n\t\t\tLOG_TOO_SMALL;\n\t\t\treturn;\n\t\t}\n\t\td++;\n\t\tds--;\n\t\tlen = (d[0] << 8) | d[1];\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t \"We have to deal with %i byte(s) of EXIF data.\",\n\t\t\t len);\n\t\td += 2;\n\t\tds -= 2;\n\t}\n\n\t\/*\n\t * Verify the exif header\n\t * (offset 2, length 6).\n\t *\/\n\tif (ds < 6) {\n\t\tLOG_TOO_SMALL;\n\t\treturn;\n\t}\n\tif (memcmp (d, ExifHeader, 6)) {\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifData\", _(\"EXIF header not found.\"));\n\t\treturn;\n\t}\n\n\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t \"Found EXIF header.\");\n\n\t\/* Sanity check the data length *\/\n\tif (ds < 14)\n\t\treturn;\n\n\t\/* The JPEG APP1 section can be no longer than 64 KiB (including a\n\t 16-bit length), so cap the data length to protect against overflow\n\t in future offset calculations *\/\n\tfullds = ds;\n\tif (ds > 0xfffe)\n\t\tds = 0xfffe;\n\n\t\/* Byte order (offset 6, length 2) *\/\n\tif (!memcmp (d + 6, \"II\", 2))\n\t\tdata->priv->order = EXIF_BYTE_ORDER_INTEL;\n\telse if (!memcmp (d + 6, \"MM\", 2))\n\t\tdata->priv->order = EXIF_BYTE_ORDER_MOTOROLA;\n\telse {\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t \"ExifData\", _(\"Unknown encoding.\"));\n\t\treturn;\n\t}\n\n\t\/* Fixed value *\/\n\tif (exif_get_short (d + 8, data->priv->order) != 0x002a)\n\t\treturn;\n\n\t\/* IFD 0 offset *\/\n\toffset = exif_get_long (d + 10, data->priv->order);\n\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\", \n\t\t \"IFD 0 at %i.\", (int) offset);\n\n\t\/* Sanity check the offset, being careful about overflow *\/\n\tif (offset > ds || offset + 6 + 2 > ds)\n\t\treturn;\n\n\t\/* Parse the actual exif data (usually offset 14 from start) *\/\n\texif_data_load_data_content (data, EXIF_IFD_0, d + 6, ds - 6, offset, 0);\n\n\t\/* IFD 1 offset *\/\n\tn = exif_get_short (d + 6 + offset, data->priv->order);\n\tif (offset + 6 + 2 + 12 * n + 4 > ds)\n\t\treturn;\n\n\toffset = exif_get_long (d + 6 + offset + 2 + 12 * n, data->priv->order);\n\tif (offset) {\n\t\texif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \"ExifData\",\n\t\t\t \"IFD 1 at %i.\", (int) offset);\n\n\t\t\/* Sanity check. *\/\n\t\tif (offset > ds || offset + 6 > ds) {\n\t\t\texif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,\n\t\t\t\t \"ExifData\", \"Bogus offset of IFD1.\");\n\t\t} else {\n\t\t exif_data_load_data_content (data, EXIF_IFD_1, d + 6, ds - 6, offset, 0);\n\t\t}\n\t}\n\n\t\/*\n\t * If we got an EXIF_TAG_MAKER_NOTE, try to interpret it. Some\n\t * cameras use pointers in the maker note tag that point to the\n\t * space between IFDs. Here is the only place where we have access\n\t * to that data.\n\t *\/\n\tinterpret_maker_note(data, d, fullds);\n\n\t\/* Fixup tags if requested *\/\n\tif (data->priv->options & EXIF_DATA_OPTION_FOLLOW_SPECIFICATION)\n\t\texif_data_fix (data);\n}","target":1,"code_token_length":1441,"total_token_length":1677,"max_tokens_setting":2048} +{"idx":235669,"func":"void HTMLInputElement::UpdateType() {\n DCHECK(input_type_);\n DCHECK(input_type_view_);\n\n const AtomicString& new_type_name =\n InputType::NormalizeTypeName(FastGetAttribute(typeAttr));\n if (input_type_->FormControlType() == new_type_name)\n return;\n\n InputType* new_type = InputType::Create(*this, new_type_name);\n RemoveFromRadioButtonGroup();\n\n ValueMode old_value_mode = input_type_->GetValueMode();\n bool did_respect_height_and_width =\n input_type_->ShouldRespectHeightAndWidthAttributes();\n bool could_be_successful_submit_button = CanBeSuccessfulSubmitButton();\n\n input_type_view_->DestroyShadowSubtree();\n DropInnerEditorElement();\n LazyReattachIfAttached();\n\n if (input_type_->SupportsRequired() != new_type->SupportsRequired() &&\n IsRequired()) {\n PseudoStateChanged(CSSSelector::kPseudoRequired);\n PseudoStateChanged(CSSSelector::kPseudoOptional);\n }\n if (input_type_->SupportsReadOnly() != new_type->SupportsReadOnly()) {\n PseudoStateChanged(CSSSelector::kPseudoReadOnly);\n PseudoStateChanged(CSSSelector::kPseudoReadWrite);\n }\n if (input_type_->IsCheckable() != new_type->IsCheckable()) {\n PseudoStateChanged(CSSSelector::kPseudoChecked);\n }\n PseudoStateChanged(CSSSelector::kPseudoIndeterminate);\n if (input_type_->IsSteppable() || new_type->IsSteppable()) {\n PseudoStateChanged(CSSSelector::kPseudoInRange);\n PseudoStateChanged(CSSSelector::kPseudoOutOfRange);\n }\n\n bool placeholder_changed =\n input_type_->SupportsPlaceholder() != new_type->SupportsPlaceholder();\n\n has_been_password_field_ |= new_type_name == InputTypeNames::password;\n\n input_type_ = new_type;\n input_type_view_ = input_type_->CreateView();\n if (input_type_view_->NeedsShadowSubtree()) {\n EnsureUserAgentShadowRoot();\n CreateShadowSubtree();\n }\n\n SetNeedsWillValidateCheck();\n\n if (placeholder_changed) {\n UpdatePlaceholderText();\n UpdatePlaceholderVisibility();\n PseudoStateChanged(CSSSelector::kPseudoPlaceholderShown);\n }\n\n ValueMode new_value_mode = input_type_->GetValueMode();\n\n if (old_value_mode == ValueMode::kValue &&\n (new_value_mode == ValueMode::kDefault ||\n new_value_mode == ValueMode::kDefaultOn)) {\n if (HasDirtyValue())\n setAttribute(valueAttr, AtomicString(non_attribute_value_));\n non_attribute_value_ = String();\n has_dirty_value_ = false;\n }\n else if (old_value_mode != ValueMode::kValue &&\n new_value_mode == ValueMode::kValue) {\n AtomicString value_string = FastGetAttribute(valueAttr);\n input_type_->WarnIfValueIsInvalid(value_string);\n non_attribute_value_ = SanitizeValue(value_string);\n has_dirty_value_ = false;\n }\n else if (old_value_mode != ValueMode::kFilename &&\n new_value_mode == ValueMode::kFilename) {\n non_attribute_value_ = String();\n has_dirty_value_ = false;\n\n } else {\n if (!HasDirtyValue()) {\n String default_value = FastGetAttribute(valueAttr);\n if (!default_value.IsNull())\n input_type_->WarnIfValueIsInvalid(default_value);\n }\n\n if (new_value_mode == ValueMode::kValue) {\n String new_value = SanitizeValue(non_attribute_value_);\n if (!EqualIgnoringNullity(new_value, non_attribute_value_)) {\n if (HasDirtyValue())\n setValue(new_value);\n else\n SetNonDirtyValue(new_value);\n }\n }\n }\n\n needs_to_update_view_value_ = true;\n input_type_view_->UpdateView();\n\n if (did_respect_height_and_width !=\n input_type_->ShouldRespectHeightAndWidthAttributes()) {\n DCHECK(GetElementData());\n AttributeCollection attributes = AttributesWithoutUpdate();\n if (const Attribute* height = attributes.Find(heightAttr)) {\n TextControlElement::AttributeChanged(AttributeModificationParams(\n heightAttr, height->Value(), height->Value(),\n AttributeModificationReason::kDirectly));\n }\n if (const Attribute* width = attributes.Find(widthAttr)) {\n TextControlElement::AttributeChanged(\n AttributeModificationParams(widthAttr, width->Value(), width->Value(),\n AttributeModificationReason::kDirectly));\n }\n if (const Attribute* align = attributes.Find(alignAttr)) {\n TextControlElement::AttributeChanged(\n AttributeModificationParams(alignAttr, align->Value(), align->Value(),\n AttributeModificationReason::kDirectly));\n }\n }\n\n if (GetDocument().FocusedElement() == this)\n GetDocument().UpdateFocusAppearanceLater();\n\n ClearValueBeforeFirstUserEdit();\n\n AddToRadioButtonGroup();\n\n SetNeedsValidityCheck();\n if ((could_be_successful_submit_button || CanBeSuccessfulSubmitButton()) &&\n formOwner() && isConnected())\n formOwner()->InvalidateDefaultButtonStyle();\n NotifyFormStateChanged();\n}\n","target":0,"code_token_length":1077,"total_token_length":1313,"max_tokens_setting":2048} +{"idx":326026,"func":"static int dvbsub_parse_region_segment(AVCodecContext *avctx,\n const uint8_t *buf, int buf_size)\n{\n DVBSubContext *ctx = avctx->priv_data;\n const uint8_t *buf_end = buf + buf_size;\n int region_id, object_id;\n int av_unused version;\n DVBSubRegion *region;\n DVBSubObject *object;\n DVBSubObjectDisplay *display;\n int fill;\n int ret;\n if (buf_size < 10)\n return AVERROR_INVALIDDATA;\n region_id = *buf++;\n region = get_region(ctx, region_id);\n if (!region) {\n region = av_mallocz(sizeof(DVBSubRegion));\n if (!region)\n return AVERROR(ENOMEM);\n region->id = region_id;\n region->version = -1;\n region->next = ctx->region_list;\n ctx->region_list = region;\n version = ((*buf)>>4) & 15;\n fill = ((*buf++) >> 3) & 1;\n region->width = AV_RB16(buf);\n buf += 2;\n region->height = AV_RB16(buf);\n buf += 2;\n if (region->width * region->height != region->buf_size) {\n av_free(region->pbuf);\n region->buf_size = region->width * region->height;\n region->pbuf = av_malloc(region->buf_size);\n if (!region->pbuf) {\n region->buf_size =\n region->width =\n region->height = 0;\n return AVERROR(ENOMEM);\n fill = 1;\n region->dirty = 0;\n region->depth = 1 << (((*buf++) >> 2) & 7);\n if(region->depth<2 || region->depth>8){\n av_log(avctx, AV_LOG_ERROR, \"region depth %d is invalid\\n\", region->depth);\n region->depth= 4;\n region->clut = *buf++;\n if (region->depth == 8) {\n region->bgcolor = *buf++;\n buf += 1;\n } else {\n buf += 1;\n if (region->depth == 4)\n region->bgcolor = (((*buf++) >> 4) & 15);\n else\n region->bgcolor = (((*buf++) >> 2) & 3);\n ff_dlog(avctx, \"Region %d, (%dx%d)\\n\", region_id, region->width, region->height);\n if (fill) {\n memset(region->pbuf, region->bgcolor, region->buf_size);\n ff_dlog(avctx, \"Fill region (%d)\\n\", region->bgcolor);\n delete_region_display_list(ctx, region);\n while (buf + 5 < buf_end) {\n object_id = AV_RB16(buf);\n buf += 2;\n object = get_object(ctx, object_id);\n if (!object) {\n object = av_mallocz(sizeof(DVBSubObject));\n if (!object)\n return AVERROR(ENOMEM);\n object->id = object_id;\n object->next = ctx->object_list;\n ctx->object_list = object;\n object->type = (*buf) >> 6;\n display = av_mallocz(sizeof(DVBSubObjectDisplay));\n if (!display)\n return AVERROR(ENOMEM);\n display->object_id = object_id;\n display->region_id = region_id;\n display->x_pos = AV_RB16(buf) & 0xfff;\n buf += 2;\n display->y_pos = AV_RB16(buf) & 0xfff;\n buf += 2;\n if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {\n display->fgcolor = *buf++;\n display->bgcolor = *buf++;\n display->region_list_next = region->display_list;\n region->display_list = display;\n display->object_list_next = object->display_list;\n object->display_list = display;\n return 0;","target":1,"code_token_length":882,"total_token_length":1118,"max_tokens_setting":2048} +{"idx":299104,"func":"void HuffmanDecoder::Initialize(const unsigned int *codeBits, unsigned int nCodes)\r\n{\r\n\t\/\/ the Huffman codes are represented in 3 ways in this code:\r\n\t\/\/\r\n\t\/\/ 1. most significant code bit (i.e. top of code tree) in the least significant bit position\r\n\t\/\/ 2. most significant code bit (i.e. top of code tree) in the most significant bit position\r\n\t\/\/ 3. most significant code bit (i.e. top of code tree) in n-th least significant bit position,\r\n\t\/\/ where n is the maximum code length for this code tree\r\n\t\/\/\r\n\t\/\/ (1) is the way the codes come in from the deflate stream\r\n\t\/\/ (2) is used to sort codes so they can be binary searched\r\n\t\/\/ (3) is used in this function to compute codes from code lengths\r\n\t\/\/\r\n\t\/\/ a code in representation (2) is called \"normalized\" here\r\n\t\/\/ The BitReverse() function is used to convert between (1) and (2)\r\n\t\/\/ The NormalizeCode() function is used to convert from (3) to (2)\r\n\r\n\tif (nCodes == 0)\r\n\t\tthrow Err(\"null code\");\r\n\r\n\tm_maxCodeBits = *std::max_element(codeBits, codeBits+nCodes);\r\n\r\n\tif (m_maxCodeBits > MAX_CODE_BITS)\r\n\t\tthrow Err(\"code length exceeds maximum\");\r\n\r\n\tif (m_maxCodeBits == 0)\r\n\t\tthrow Err(\"null code\");\r\n\r\n\t\/\/ count number of codes of each length\r\n\tSecBlockWithHint blCount(m_maxCodeBits+1);\r\n\tstd::fill(blCount.begin(), blCount.end(), 0);\r\n\tunsigned int i;\r\n\tfor (i=0; i nextCode(m_maxCodeBits+1);\r\n\tnextCode[1] = 0;\r\n\tfor (i=2; i<=m_maxCodeBits; i++)\r\n\t{\r\n\t\t\/\/ compute this while checking for overflow: code = (code + blCount[i-1]) << 1\r\n\t\tif (code > code + blCount[i-1])\r\n\t\t\tthrow Err(\"codes oversubscribed\");\r\n\t\tcode += blCount[i-1];\r\n\t\tif (code > (code << 1))\r\n\t\t\tthrow Err(\"codes oversubscribed\");\r\n\t\tcode <<= 1;\r\n\t\tnextCode[i] = code;\r\n\t}\r\n\r\n\t\/\/ MAX_CODE_BITS is 32, m_maxCodeBits may be smaller.\r\n\tconst word64 shiftedMaxCode = ((word64)1 << m_maxCodeBits);\r\n\tif (code > shiftedMaxCode - blCount[m_maxCodeBits])\r\n\t\tthrow Err(\"codes oversubscribed\");\r\n\telse if (m_maxCodeBits != 1 && code < shiftedMaxCode - blCount[m_maxCodeBits])\r\n\t\tthrow Err(\"codes incomplete\");\r\n\r\n\t\/\/ compute a vector of triples sorted by code\r\n\tm_codeToValue.resize(nCodes - blCount[0]);\r\n\tunsigned int j=0;\r\n\tfor (i=0; iRegisterPrintCallback(g_Config.m_ConsoleOutputLevel, SendRconLineAuthed, this);\n\n\t\/\/ load map\n\tif(!LoadMap(g_Config.m_SvMap))\n\t{\n\t\tdbg_msg(\"server\", \"failed to load map. mapname='%s'\", g_Config.m_SvMap);\n\t\treturn -1;\n\t}\n\n\t\/\/ start server\n\tNETADDR BindAddr;\n\tif(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)\n\t{\n\t\t\/\/ sweet!\n\t\tBindAddr.type = NETTYPE_ALL;\n\t\tBindAddr.port = g_Config.m_SvPort;\n\t}\n\telse\n\t{\n\t\tmem_zero(&BindAddr, sizeof(BindAddr));\n\t\tBindAddr.type = NETTYPE_ALL;\n\t\tBindAddr.port = g_Config.m_SvPort;\n\t}\n\n\tif(!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))\n\t{\n\t\tdbg_msg(\"server\", \"couldn't open socket. port %d might already be in use\", g_Config.m_SvPort);\n\t\treturn -1;\n\t}\n\n\tm_NetServer.SetCallbacks(NewClientCallback, DelClientCallback, this);\n\n\tm_Econ.Init(Console(), &m_ServerBan);\n\n\tchar aBuf[256];\n\tstr_format(aBuf, sizeof(aBuf), \"server name is '%s'\", g_Config.m_SvName);\n\tConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, \"server\", aBuf);\n\n\tGameServer()->OnInit();\n\tstr_format(aBuf, sizeof(aBuf), \"version %s\", GameServer()->NetVersion());\n\tConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, \"server\", aBuf);\n\n\t\/\/ process pending commands\n\tm_pConsole->StoreCommands(false);\n\n\t\/\/ start game\n\t{\n\t\tint64 ReportTime = time_get();\n\t\tint ReportInterval = 3;\n\n\t\tm_Lastheartbeat = 0;\n\t\tm_GameStartTime = time_get();\n\n\t\tif(g_Config.m_Debug)\n\t\t{\n\t\t\tstr_format(aBuf, sizeof(aBuf), \"baseline memory usage %dk\", mem_stats()->allocated\/1024);\n\t\t\tConsole()->Print(IConsole::OUTPUT_LEVEL_DEBUG, \"server\", aBuf);\n\t\t}\n\n\t\twhile(m_RunServer)\n\t\t{\n\t\t\tint64 t = time_get();\n\t\t\tint NewTicks = 0;\n\n\t\t\t\/\/ load new map TODO: don't poll this\n\t\t\tif(str_comp(g_Config.m_SvMap, m_aCurrentMap) != 0 || m_MapReload)\n\t\t\t{\n\t\t\t\tm_MapReload = 0;\n\n\t\t\t\t\/\/ load map\n\t\t\t\tif(LoadMap(g_Config.m_SvMap))\n\t\t\t\t{\n\t\t\t\t\t\/\/ new map loaded\n\t\t\t\t\tGameServer()->OnShutdown();\n\n\t\t\t\t\tfor(int c = 0; c < MAX_CLIENTS; c++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(m_aClients[c].m_State <= CClient::STATE_AUTH)\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\tSendMap(c);\n\t\t\t\t\t\tm_aClients[c].Reset();\n\t\t\t\t\t\tm_aClients[c].m_State = CClient::STATE_CONNECTING;\n\t\t\t\t\t}\n\n\t\t\t\t\tm_GameStartTime = time_get();\n\t\t\t\t\tm_CurrentGameTick = 0;\n\t\t\t\t\tKernel()->ReregisterInterface(GameServer());\n\t\t\t\t\tGameServer()->OnInit();\n\t\t\t\t\tUpdateServerInfo();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr_format(aBuf, sizeof(aBuf), \"failed to load map. mapname='%s'\", g_Config.m_SvMap);\n\t\t\t\t\tConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, \"server\", aBuf);\n\t\t\t\t\tstr_copy(g_Config.m_SvMap, m_aCurrentMap, sizeof(g_Config.m_SvMap));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(t > TickStartTime(m_CurrentGameTick+1))\n\t\t\t{\n\t\t\t\tm_CurrentGameTick++;\n\t\t\t\tNewTicks++;\n\n\t\t\t\t\/\/ apply new input\n\t\t\t\tfor(int c = 0; c < MAX_CLIENTS; c++)\n\t\t\t\t{\n\t\t\t\t\tif(m_aClients[c].m_State == CClient::STATE_EMPTY)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfor(int i = 0; i < 200; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(m_aClients[c].m_aInputs[i].m_GameTick == Tick())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(m_aClients[c].m_State == CClient::STATE_INGAME)\n\t\t\t\t\t\t\t\tGameServer()->OnClientPredictedInput(c, m_aClients[c].m_aInputs[i].m_aData);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tGameServer()->OnTick();\n\t\t\t}\n\n\t\t\t\/\/ snap game\n\t\t\tif(NewTicks)\n\t\t\t{\n\t\t\t\tif(g_Config.m_SvHighBandwidth || (m_CurrentGameTick%2) == 0)\n\t\t\t\t\tDoSnapshot();\n\n\t\t\t\tUpdateClientRconCommands();\n\t\t\t}\n\n\t\t\t\/\/ master server stuff\n\t\t\tm_Register.RegisterUpdate(m_NetServer.NetType());\n\n\t\t\tPumpNetwork();\n\n\t\t\tif(ReportTime < time_get())\n\t\t\t{\n\t\t\t\tif(g_Config.m_Debug)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\tstatic NETSTATS prev_stats;\n\t\t\t\t\tNETSTATS stats;\n\t\t\t\t\tnetserver_stats(net, &stats);\n\n\t\t\t\t\tperf_next();\n\n\t\t\t\t\tif(config.dbg_pref)\n\t\t\t\t\t\tperf_dump(&rootscope);\n\n\t\t\t\t\tdbg_msg(\"server\", \"send=%8d recv=%8d\",\n\t\t\t\t\t\t(stats.send_bytes - prev_stats.send_bytes)\/reportinterval,\n\t\t\t\t\t\t(stats.recv_bytes - prev_stats.recv_bytes)\/reportinterval);\n\n\t\t\t\t\tprev_stats = stats;\n\t\t\t\t\t*\/\n\t\t\t\t}\n\n\t\t\t\tReportTime += time_freq()*ReportInterval;\n\t\t\t}\n\n\t\t\t\/\/ wait for incomming data\n\t\t\tnet_socket_read_wait(m_NetServer.Socket(), 5);\n\t\t}\n\t}\n\t\/\/ disconnect all clients on shutdown\n\tfor(int i = 0; i < MAX_CLIENTS; ++i)\n\t{\n\t\tif(m_aClients[i].m_State != CClient::STATE_EMPTY)\n\t\t\tm_NetServer.Drop(i, \"Server shutdown\");\n\n\t\tm_Econ.Shutdown();\n\t}\n\n\tGameServer()->OnShutdown();\n\tm_pMap->Unload();\n\n\tif(m_pCurrentMapData)\n\t\tmem_free(m_pCurrentMapData);\n\treturn 0;\n}","target":0,"code_token_length":1324,"total_token_length":1560,"max_tokens_setting":2048} +{"idx":7566,"func":"static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,\n OcspResponse* resp, word32 size, void* cm, void* heap, int noVerify)\n{\n int length;\n word32 idx = *ioIndex;\n word32 end_index;\n int ret;\n int sigLength;\n\n WOLFSSL_ENTER(\"DecodeBasicOcspResponse\");\n (void)heap;\n\n if (GetSequence(source, &idx, &length, size) < 0)\n return ASN_PARSE_E;\n\n if (idx + length > size)\n return ASN_INPUT_E;\n end_index = idx + length;\n\n if ((ret = DecodeResponseData(source, &idx, resp, size)) < 0)\n return ret; \/* ASN_PARSE_E, ASN_BEFORE_DATE_E, ASN_AFTER_DATE_E *\/\n\n \/* Get the signature algorithm *\/\n if (GetAlgoId(source, &idx, &resp->sigOID, oidSigType, size) < 0)\n return ASN_PARSE_E;\n\n ret = CheckBitString(source, &idx, &sigLength, size, 1, NULL);\n if (ret != 0)\n return ret;\n\n resp->sigSz = sigLength;\n resp->sig = source + idx;\n idx += sigLength;\n\n \/*\n * Check the length of the BasicOcspResponse against the current index to\n * see if there are certificates, they are optional.\n *\/\n#ifndef WOLFSSL_NO_OCSP_OPTIONAL_CERTS\n if (idx < end_index)\n {\n DecodedCert cert;\n\n if (DecodeCerts(source, &idx, resp, size) < 0)\n return ASN_PARSE_E;\n\n InitDecodedCert(&cert, resp->cert, resp->certSz, heap);\n\n \/* Don't verify if we don't have access to Cert Manager. *\/\n ret = ParseCertRelative(&cert, CERT_TYPE,\n noVerify ? NO_VERIFY : VERIFY_OCSP, cm);\n if (ret < 0) {\n WOLFSSL_MSG(\"\\tOCSP Responder certificate parsing failed\");\n FreeDecodedCert(&cert);\n return ret;\n }\n\n#ifndef WOLFSSL_NO_OCSP_ISSUER_CHECK\n if ((cert.extExtKeyUsage & EXTKEYUSE_OCSP_SIGN) == 0) {\n if (XMEMCMP(cert.subjectHash,\n resp->single->issuerHash, OCSP_DIGEST_SIZE) == 0) {\n WOLFSSL_MSG(\"\\tOCSP Response signed by issuer\");\n }\n else {\n WOLFSSL_MSG(\"\\tOCSP Responder key usage check failed\");\n #ifdef OPENSSL_EXTRA\n resp->verifyError = OCSP_BAD_ISSUER;\n #else\n FreeDecodedCert(&cert);\n return BAD_OCSP_RESPONDER;\n #endif\n }\n }\n#endif\n\n \/* ConfirmSignature is blocking here *\/\n ret = ConfirmSignature(&cert.sigCtx,\n resp->response, resp->responseSz,\n cert.publicKey, cert.pubKeySize, cert.keyOID,\n resp->sig, resp->sigSz, resp->sigOID, NULL);\n\n FreeDecodedCert(&cert);\n\n if (ret != 0) {\n WOLFSSL_MSG(\"\\tOCSP Confirm signature failed\");\n return ASN_OCSP_CONFIRM_E;\n }\n }\n else\n#endif \/* WOLFSSL_NO_OCSP_OPTIONAL_CERTS *\/\n {\n Signer* ca;\n int sigValid = -1;\n\n #ifndef NO_SKID\n ca = GetCA(cm, resp->single->issuerKeyHash);\n #else\n ca = GetCA(cm, resp->single->issuerHash);\n #endif\n\n if (ca) {\n SignatureCtx sigCtx;\n InitSignatureCtx(&sigCtx, heap, INVALID_DEVID);\n\n \/* ConfirmSignature is blocking here *\/\n sigValid = ConfirmSignature(&sigCtx, resp->response,\n resp->responseSz, ca->publicKey, ca->pubKeySize, ca->keyOID,\n resp->sig, resp->sigSz, resp->sigOID, NULL);\n }\n if (ca == NULL || sigValid != 0) {\n WOLFSSL_MSG(\"\\tOCSP Confirm signature failed\");\n return ASN_OCSP_CONFIRM_E;\n }\n\n (void)noVerify;\n }\n\n *ioIndex = idx;\n return 0;\n}","target":1,"code_token_length":940,"total_token_length":1176,"max_tokens_setting":2048} +{"idx":56867,"func":"int __read_etc_hosts_r(\n\t\tparser_t * parser,\n\t\tconst char *name,\n\t\tint type,\n\t\tenum etc_hosts_action action,\n\t\tstruct hostent *result_buf,\n\t\tchar *buf, size_t buflen,\n\t\tstruct hostent **result,\n\t\tint *h_errnop)\n{\n\tchar **tok = NULL;\n\tstruct in_addr *h_addr0 = NULL;\n\tconst size_t aliaslen = INADDROFF +\n#ifdef __UCLIBC_HAS_IPV6__\n\t\t\t\t\t\t\tsizeof(struct in6_addr)\n#else\n\t\t\t\t\t\t\tsizeof(struct in_addr)\n#endif\n\t\t\t\t\t\t\t;\n\tint ret = HOST_NOT_FOUND;\n\t\/* make sure pointer is aligned *\/\n\tint i = ALIGN_BUFFER_OFFSET(buf);\n\tbuf += i;\n\tbuflen -= i;\n\n\t*h_errnop = NETDB_INTERNAL;\n\tif (\/* (ssize_t)buflen < 0 || *\/ buflen < aliaslen\n\t\t|| (buflen - aliaslen) < BUFSZ + 1)\n\t\treturn ERANGE;\n\tif (parser == NULL)\n\t\tparser = __open_etc_hosts();\n\tif (parser == NULL) {\n\t\t*result = NULL;\n\t\treturn errno;\n\t}\n\t\/* Layout in buf:\n\t * char *alias[MAXTOKENS] = {address, name, aliases...}\n\t * char **h_addr_list[1] = {*in[6]_addr, NULL}\n\t * struct in[6]_addr\n\t * char line_buffer[BUFSZ+];\n\t *\/\n\tparser->data = buf;\n\tparser->data_len = aliaslen;\n\tparser->line_len = buflen - aliaslen;\n\t*h_errnop = HOST_NOT_FOUND;\n\t\/* [[:space:]][] *\/\n\twhile (config_read(parser, &tok, MAXTOKENS, MINTOKENS, \"# \\t\", PARSE_NORMAL)) {\n\t\tresult_buf->h_aliases = tok+1;\n\t\tif (action == GETHOSTENT) {\n\t\t\t\/* Return whatever the next entry happens to be. *\/\n\t\t\t;\n\t\t} else if (action == GET_HOSTS_BYADDR) {\n\t\t\tif (strcmp(name, *tok) != 0)\n\t\t\t\tcontinue;\n\t\t} else { \/* GET_HOSTS_BYNAME *\/\n\t\t\tint aliases = 0;\n\t\t\tchar **alias = tok + 1;\n\t\t\twhile (aliases < MAXALIASES) {\n\t\t\t\tchar *tmp = *(alias+aliases++);\n\t\t\t\tif (tmp && strcasecmp(name, tmp) == 0)\n\t\t\t\t\tgoto found;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\nfound:\n\t\tresult_buf->h_name = *(result_buf->h_aliases++);\n\t\tresult_buf->h_addr_list = (char**)(buf + HALISTOFF);\n\t\t*(result_buf->h_addr_list + 1) = '\\0';\n\t\th_addr0 = (struct in_addr*)(buf + INADDROFF);\n\t\tresult_buf->h_addr = (char*)h_addr0;\n\t\tif (0) \/* nothing *\/;\n#ifdef __UCLIBC_HAS_IPV4__\n\t\telse if (type == AF_INET\n\t\t\t\t&& inet_pton(AF_INET, *tok, h_addr0) > 0) {\n\t\t\tDPRINTF(\"Found INET\\n\");\n\t\t\tresult_buf->h_addrtype = AF_INET;\n\t\t\tresult_buf->h_length = sizeof(struct in_addr);\n\t\t\t*result = result_buf;\n\t\t\tret = NETDB_SUCCESS;\n\t\t}\n#endif\n#ifdef __UCLIBC_HAS_IPV6__\n#define in6 ((struct in6_addr *)buf)\n\t\telse if (type == AF_INET6\n\t\t\t\t&& inet_pton(AF_INET6, *tok, h_addr0) > 0) {\n\t\t\tDPRINTF(\"Found INET6\\n\");\n\t\t\tresult_buf->h_addrtype = AF_INET6;\n\t\t\tresult_buf->h_length = sizeof(struct in6_addr);\n\t\t\t*result = result_buf;\n\t\t\tret = NETDB_SUCCESS;\n\t\t}\n#endif\n\t\telse {\n\t\t\t\/* continue parsing in the hope the user has multiple\n\t\t\t * host types listed in the database like so:\n\t\t\t * host\n\t\t\t * host\n\t\t\t * If looking for an IPv6 addr, don't bail when we got the IPv4\n\t\t\t *\/\n\t\t\tDPRINTF(\"Error: Found host but different address family\\n\");\n\t\t\t\/* NB: gethostbyname2_r depends on this feature\n\t\t\t * to avoid looking for IPv6 addr of \"localhost\" etc *\/\n\t\t\tret = TRY_AGAIN;\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\tif (action != GETHOSTENT)\n\t\tconfig_close(parser);\n\treturn ret;\n#undef in6\n}","target":0,"code_token_length":968,"total_token_length":1204,"max_tokens_setting":2048} +{"idx":416533,"func":"gx_update_pdf14_compositor(gx_device * pdev, gs_gstate * pgs,\n const gs_pdf14trans_t * pdf14pct, gs_memory_t * mem )\n{\n pdf14_device *p14dev = (pdf14_device *)pdev;\n gs_pdf14trans_params_t params = pdf14pct->params;\n int code = 0;\n\n params.idle = pdf14pct->idle;\n switch (params.pdf14_op) {\n default:\t\t\t\/* Should not occur. *\/\n break;\n case PDF14_PUSH_DEVICE:\n if (!(params.is_pattern)) {\n p14dev->blend_mode = 0;\n p14dev->opacity = p14dev->shape = 0.0;\n pdf14_recreate_device(mem, pgs, pdev, pdf14pct);\n }\n break;\n case PDF14_ABORT_DEVICE:\n \/* Something has gone very wrong. Let transparency device clean up\n what ever it has allocated and then we are shutting it down *\/\n code = gx_abort_trans_device(pgs, pdev);\n if (p14dev->free_devicen) {\n devn_free_params(pdev);\n }\n pdf14_disable_device(pdev);\n pdf14_close(pdev);\n break;\n case PDF14_POP_DEVICE:\n if (!(params.is_pattern)) {\n if_debug0m('v', pdev->memory,\n \"[v]gx_update_pdf14_compositor(PDF14_POP_DEVICE)\\n\");\n pgs->get_cmap_procs = p14dev->save_get_cmap_procs;\n gx_set_cmap_procs(pgs, p14dev->target);\n \/* Send image out raster data to output device *\/\n {\n \/* Make a copy so we can change the ROP *\/\n gs_gstate new_pgs = *pgs;\n\n \/* We don't use the gs_gstate log_op since this is for the *\/\n \/* clist playback. Putting the image (band in the case of the *\/\n \/* clist) only needs to use the default ROP to copy the data *\/\n new_pgs.log_op = rop3_default;\n code = p14dev->pdf14_procs->put_image(pdev, &new_pgs, p14dev->target);\n }\n \/* Before we disable the device release any deviceN structures.\n free_devicen is set if the pdf14 device had inherited its\n deviceN parameters from the target clist device. In this\n case they should not be freed *\/\n if (p14dev->free_devicen) {\n devn_free_params(pdev);\n }\n pdf14_disable_device(pdev);\n pdf14_close(pdev);\n }\n break;\n case PDF14_BEGIN_TRANS_GROUP:\n code = gx_begin_transparency_group(pgs, pdev, ¶ms);\n break;\n case PDF14_END_TRANS_GROUP:\n code = gx_end_transparency_group(pgs, pdev);\n break;\n case PDF14_BEGIN_TRANS_TEXT_GROUP:\n p14dev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;\n break;\n case PDF14_END_TRANS_TEXT_GROUP:\n if (p14dev->text_group == PDF14_TEXTGROUP_BT_PUSHED)\n code = gx_end_transparency_group(pgs, pdev);\n p14dev->text_group = PDF14_TEXTGROUP_NO_BT; \/* Hit ET *\/\n break;\n case PDF14_BEGIN_TRANS_MASK:\n code = gx_begin_transparency_mask(pgs, pdev, ¶ms);\n break;\n case PDF14_END_TRANS_MASK:\n code = gx_end_transparency_mask(pgs, pdev, ¶ms);\n break;\n case PDF14_SET_BLEND_PARAMS:\n pdf14_set_params(pgs, pdev, &pdf14pct->params);\n break;\n case PDF14_PUSH_TRANS_STATE:\n code = gx_push_transparency_state(pgs, pdev);\n break;\n case PDF14_POP_TRANS_STATE:\n code = gx_pop_transparency_state(pgs, pdev);\n break;\n case PDF14_PUSH_SMASK_COLOR:\n code = pdf14_increment_smask_color(pgs, pdev);\n break;\n case PDF14_POP_SMASK_COLOR:\n code = pdf14_decrement_smask_color(pgs, pdev);\n break;\n }\n return code;\n}","target":0,"code_token_length":968,"total_token_length":1204,"max_tokens_setting":2048} +{"idx":286871,"func":"int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,\n\t\t\t\tstruct drm_file *file_priv)\n{\n\tstruct vmw_private *dev_priv = vmw_priv(dev);\n\tstruct vmw_user_surface *user_srf;\n\tstruct vmw_surface *srf;\n\tstruct vmw_resource *res;\n\tstruct vmw_resource *tmp;\n\tunion drm_vmw_gb_surface_create_arg *arg =\n\t (union drm_vmw_gb_surface_create_arg *)data;\n\tstruct drm_vmw_gb_surface_create_req *req = &arg->req;\n\tstruct drm_vmw_gb_surface_create_rep *rep = &arg->rep;\n\tstruct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;\n\tint ret;\n\tuint32_t size;\n\tuint32_t backup_handle;\n\n\tif (req->multisample_count != 0)\n\t\treturn -EINVAL;\n\n\tif (req->mip_levels > DRM_VMW_MAX_MIP_LEVELS)\n\t\treturn -EINVAL;\n\n\tif (unlikely(vmw_user_surface_size == 0))\n\t\tvmw_user_surface_size = ttm_round_pot(sizeof(*user_srf)) +\n\t\t\t128;\n\n\tsize = vmw_user_surface_size + 128;\n\n\t\/* Define a surface based on the parameters. *\/\n\tret = vmw_surface_gb_priv_define(dev,\n\t\t\tsize,\n\t\t\treq->svga3d_flags,\n\t\t\treq->format,\n\t\t\treq->drm_surface_flags & drm_vmw_surface_flag_scanout,\n\t\t\treq->mip_levels,\n\t\t\treq->multisample_count,\n\t\t\treq->array_size,\n\t\t\treq->base_size,\n\t\t\t&srf);\n\tif (unlikely(ret != 0))\n\t\treturn ret;\n\n\tuser_srf = container_of(srf, struct vmw_user_surface, srf);\n\tif (drm_is_primary_client(file_priv))\n\t\tuser_srf->master = drm_master_get(file_priv->master);\n\n\tret = ttm_read_lock(&dev_priv->reservation_sem, true);\n\tif (unlikely(ret != 0))\n\t\treturn ret;\n\n\tres = &user_srf->srf.res;\n\n\n\tif (req->buffer_handle != SVGA3D_INVALID_ID) {\n\t\tret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle,\n\t\t\t\t\t &res->backup,\n\t\t\t\t\t &user_srf->backup_base);\n\t\tif (ret == 0 && res->backup->base.num_pages * PAGE_SIZE <\n\t\t res->backup_size) {\n\t\t\tDRM_ERROR(\"Surface backup buffer is too small.\\n\");\n\t\t\tvmw_dmabuf_unreference(&res->backup);\n\t\t\tret = -EINVAL;\n\t\t\tgoto out_unlock;\n\t\t}\n\t} else if (req->drm_surface_flags & drm_vmw_surface_flag_create_buffer)\n\t\tret = vmw_user_dmabuf_alloc(dev_priv, tfile,\n\t\t\t\t\t res->backup_size,\n\t\t\t\t\t req->drm_surface_flags &\n\t\t\t\t\t drm_vmw_surface_flag_shareable,\n\t\t\t\t\t &backup_handle,\n\t\t\t\t\t &res->backup,\n\t\t\t\t\t &user_srf->backup_base);\n\n\tif (unlikely(ret != 0)) {\n\t\tvmw_resource_unreference(&res);\n\t\tgoto out_unlock;\n\t}\n\n\ttmp = vmw_resource_reference(res);\n\tret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime,\n\t\t\t\t req->drm_surface_flags &\n\t\t\t\t drm_vmw_surface_flag_shareable,\n\t\t\t\t VMW_RES_SURFACE,\n\t\t\t\t &vmw_user_surface_base_release, NULL);\n\n\tif (unlikely(ret != 0)) {\n\t\tvmw_resource_unreference(&tmp);\n\t\tvmw_resource_unreference(&res);\n\t\tgoto out_unlock;\n\t}\n\n\trep->handle = user_srf->prime.base.hash.key;\n\trep->backup_size = res->backup_size;\n\tif (res->backup) {\n\t\trep->buffer_map_handle =\n\t\t\tdrm_vma_node_offset_addr(&res->backup->base.vma_node);\n\t\trep->buffer_size = res->backup->base.num_pages * PAGE_SIZE;\n\t\trep->buffer_handle = backup_handle;\n\t} else {\n\t\trep->buffer_map_handle = 0;\n\t\trep->buffer_size = 0;\n\t\trep->buffer_handle = SVGA3D_INVALID_ID;\n\t}\n\n\tvmw_resource_unreference(&res);\n\nout_unlock:\n\tttm_read_unlock(&dev_priv->reservation_sem);\n\treturn ret;\n}","target":1,"code_token_length":888,"total_token_length":1124,"max_tokens_setting":2048} +{"idx":107957,"func":"static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)\n{\n\tstruct vm_area_struct *mpnt, *tmp, *prev, **pprev;\n\tstruct rb_node **rb_link, *rb_parent;\n\tint retval;\n\tunsigned long charge;\n\tstruct mempolicy *pol;\n\n\tuprobe_start_dup_mmap();\n\tdown_write(&oldmm->mmap_sem);\n\tflush_cache_dup_mm(oldmm);\n\tuprobe_dup_mmap(oldmm, mm);\n\t\/*\n\t * Not linked in yet - no deadlock potential:\n\t *\/\n\tdown_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);\n\n\tmm->locked_vm = 0;\n\tmm->mmap = NULL;\n\tmm->mmap_cache = NULL;\n\tmm->free_area_cache = oldmm->mmap_base;\n\tmm->cached_hole_size = ~0UL;\n\tmm->map_count = 0;\n\tcpumask_clear(mm_cpumask(mm));\n\tmm->mm_rb = RB_ROOT;\n\trb_link = &mm->mm_rb.rb_node;\n\trb_parent = NULL;\n\tpprev = &mm->mmap;\n\tretval = ksm_fork(mm, oldmm);\n\tif (retval)\n\t\tgoto out;\n\tretval = khugepaged_fork(mm, oldmm);\n\tif (retval)\n\t\tgoto out;\n\n\tprev = NULL;\n\tfor (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {\n\t\tstruct file *file;\n\n\t\tif (mpnt->vm_flags & VM_DONTCOPY) {\n\t\t\tvm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,\n\t\t\t\t\t\t\t-vma_pages(mpnt));\n\t\t\tcontinue;\n\t\t}\n\t\tcharge = 0;\n\t\tif (mpnt->vm_flags & VM_ACCOUNT) {\n\t\t\tunsigned long len = vma_pages(mpnt);\n\n\t\t\tif (security_vm_enough_memory_mm(oldmm, len)) \/* sic *\/\n\t\t\t\tgoto fail_nomem;\n\t\t\tcharge = len;\n\t\t}\n\t\ttmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);\n\t\tif (!tmp)\n\t\t\tgoto fail_nomem;\n\t\t*tmp = *mpnt;\n\t\tINIT_LIST_HEAD(&tmp->anon_vma_chain);\n\t\tpol = mpol_dup(vma_policy(mpnt));\n\t\tretval = PTR_ERR(pol);\n\t\tif (IS_ERR(pol))\n\t\t\tgoto fail_nomem_policy;\n\t\tvma_set_policy(tmp, pol);\n\t\ttmp->vm_mm = mm;\n\t\tif (anon_vma_fork(tmp, mpnt))\n\t\t\tgoto fail_nomem_anon_vma_fork;\n\t\ttmp->vm_flags &= ~VM_LOCKED;\n\t\ttmp->vm_next = tmp->vm_prev = NULL;\n\t\tfile = tmp->vm_file;\n\t\tif (file) {\n\t\t\tstruct inode *inode = file_inode(file);\n\t\t\tstruct address_space *mapping = file->f_mapping;\n\n\t\t\tget_file(file);\n\t\t\tif (tmp->vm_flags & VM_DENYWRITE)\n\t\t\t\tatomic_dec(&inode->i_writecount);\n\t\t\tmutex_lock(&mapping->i_mmap_mutex);\n\t\t\tif (tmp->vm_flags & VM_SHARED)\n\t\t\t\tmapping->i_mmap_writable++;\n\t\t\tflush_dcache_mmap_lock(mapping);\n\t\t\t\/* insert tmp into the share list, just after mpnt *\/\n\t\t\tif (unlikely(tmp->vm_flags & VM_NONLINEAR))\n\t\t\t\tvma_nonlinear_insert(tmp,\n\t\t\t\t\t\t&mapping->i_mmap_nonlinear);\n\t\t\telse\n\t\t\t\tvma_interval_tree_insert_after(tmp, mpnt,\n\t\t\t\t\t\t\t&mapping->i_mmap);\n\t\t\tflush_dcache_mmap_unlock(mapping);\n\t\t\tmutex_unlock(&mapping->i_mmap_mutex);\n\t\t}\n\n\t\t\/*\n\t\t * Clear hugetlb-related page reserves for children. This only\n\t\t * affects MAP_PRIVATE mappings. Faults generated by the child\n\t\t * are not guaranteed to succeed, even if read-only\n\t\t *\/\n\t\tif (is_vm_hugetlb_page(tmp))\n\t\t\treset_vma_resv_huge_pages(tmp);\n\n\t\t\/*\n\t\t * Link in the new vma and copy the page table entries.\n\t\t *\/\n\t\t*pprev = tmp;\n\t\tpprev = &tmp->vm_next;\n\t\ttmp->vm_prev = prev;\n\t\tprev = tmp;\n\n\t\t__vma_link_rb(mm, tmp, rb_link, rb_parent);\n\t\trb_link = &tmp->vm_rb.rb_right;\n\t\trb_parent = &tmp->vm_rb;\n\n\t\tmm->map_count++;\n\t\tretval = copy_page_range(mm, oldmm, mpnt);\n\n\t\tif (tmp->vm_ops && tmp->vm_ops->open)\n\t\t\ttmp->vm_ops->open(tmp);\n\n\t\tif (retval)\n\t\t\tgoto out;\n\t}\n\t\/* a new mm has just been created *\/\n\tarch_dup_mmap(oldmm, mm);\n\tretval = 0;\nout:\n\tup_write(&mm->mmap_sem);\n\tflush_tlb_mm(oldmm);\n\tup_write(&oldmm->mmap_sem);\n\tuprobe_end_dup_mmap();\n\treturn retval;\nfail_nomem_anon_vma_fork:\n\tmpol_put(pol);\nfail_nomem_policy:\n\tkmem_cache_free(vm_area_cachep, tmp);\nfail_nomem:\n\tretval = -ENOMEM;\n\tvm_unacct_memory(charge);\n\tgoto out;\n}","target":0,"code_token_length":1101,"total_token_length":1337,"max_tokens_setting":2048} +{"idx":271844,"func":" \/\/! Compute Haar multiscale wavelet transform \\newinstance.\n CImg get_haar(const bool invert=false, const unsigned int nb_scales=1) const {\n CImg res;\n if (nb_scales==1) { \/\/ Single scale transform\n if (_width>1) get_haar('x',invert,1).move_to(res);\n if (_height>1) { if (res) res.haar('y',invert,1); else get_haar('y',invert,1).move_to(res); }\n if (_depth>1) { if (res) res.haar('z',invert,1); else get_haar('z',invert,1).move_to(res); }\n if (res) return res;\n } else { \/\/ Multi-scale transform\n if (invert) { \/\/ Inverse transform\n res.assign(*this,false);\n if (_width>1) {\n if (_height>1) {\n if (_depth>1) {\n unsigned int w = _width, h = _height, d = _depth;\n for (unsigned int s = 1; w && h && d && s1) {\n unsigned int w = _width, d = _depth;\n for (unsigned int s = 1; w && d && s1) {\n if (_depth>1) {\n unsigned int h = _height, d = _depth;\n for (unsigned int s = 1; h && d && s1) {\n unsigned int d = _depth;\n for (unsigned int s = 1; d && s1) {\n if (_height>1) {\n if (_depth>1)\n for (unsigned int s = 1, w = _width\/2, h = _height\/2, d = _depth\/2; w && h && d && s1) for (unsigned int s = 1, w = _width\/2, d = _depth\/2; w && d && s1) {\n if (_depth>1)\n for (unsigned int s = 1, h = _height\/2, d = _depth\/2; h && d && s1) for (unsigned int s = 1, d = _depth\/2; d && ssequence = PyEval_CallObject(object, args);\n\n if (self->sequence != NULL) {\n if (!Adapter_process_file_wrapper(self)) {\n int aborted = 0;\n\n iterator = PyObject_GetIter(self->sequence);\n\n if (iterator != NULL) {\n PyObject *item = NULL;\n\n while ((item = PyIter_Next(iterator))) {\n#if PY_MAJOR_VERSION >= 3\n if (PyUnicode_Check(item)) {\n PyObject *latin_item;\n latin_item = PyUnicode_AsLatin1String(item);\n if (!latin_item) {\n PyErr_Format(PyExc_TypeError, \"sequence of \"\n \"byte string values expected, value \"\n \"containing non 'latin-1' characters \"\n \"found\");\n Py_DECREF(item);\n break;\n }\n\n Py_DECREF(item);\n item = latin_item;\n }\n#endif\n\n if (!PyString_Check(item)) {\n PyErr_Format(PyExc_TypeError, \"sequence of byte \"\n \"string values expected, value of \"\n \"type %.200s found\",\n item->ob_type->tp_name);\n Py_DECREF(item);\n break;\n }\n\n msg = PyString_AsString(item);\n length = PyString_Size(item);\n\n if (!msg) {\n Py_DECREF(item);\n break;\n }\n\n if (length && !Adapter_output(self, msg, length, 0)) {\n if (!PyErr_Occurred())\n aborted = 1;\n Py_DECREF(item);\n break;\n }\n\n Py_DECREF(item);\n }\n }\n\n if (!PyErr_Occurred() && !aborted) {\n if (Adapter_output(self, \"\", 0, 0))\n self->result = OK;\n }\n\n Py_XDECREF(iterator);\n }\n\n \/*\n * Log warning if more response content generated than was\n * indicated, or less if there was no errors generated by\n * the application.\n *\/\n\n if (self->content_length_set && ((!PyErr_Occurred() &&\n self->output_length != self->content_length) ||\n (self->output_length > self->content_length))) {\n ap_log_rerror(APLOG_MARK, WSGI_LOG_DEBUG(0), self->r,\n \"mod_wsgi (pid=%d): Content length mismatch, \"\n \"expected %s, response generated %s: %s\", getpid(),\n apr_off_t_toa(self->r->pool, self->content_length),\n apr_off_t_toa(self->r->pool, self->output_length),\n self->r->filename);\n }\n\n if (PyErr_Occurred()) {\n \/*\n * Response content has already been sent, so cannot\n * return an internal server error as Apache will\n * append its own error page. Thus need to return OK\n * and just truncate the response.\n *\/\n\n if (self->status_line && !self->headers)\n self->result = OK;\n\n wsgi_log_python_error(self->r, self->log, self->r->filename);\n }\n\n if (PyObject_HasAttrString(self->sequence, \"close\")) {\n PyObject *args = NULL;\n PyObject *data = NULL;\n\n close = PyObject_GetAttrString(self->sequence, \"close\");\n\n args = Py_BuildValue(\"()\");\n data = PyEval_CallObject(close, args);\n\n Py_DECREF(args);\n Py_XDECREF(data);\n Py_DECREF(close);\n }\n\n if (PyErr_Occurred())\n wsgi_log_python_error(self->r, self->log, self->r->filename);\n\n Py_DECREF(self->sequence);\n\n self->sequence = NULL;\n }\n\n Py_DECREF(args);\n Py_DECREF(start);\n Py_DECREF(vars);\n\n \/* Log details of any final Python exceptions. *\/\n\n if (PyErr_Occurred())\n wsgi_log_python_error(self->r, self->log, self->r->filename);\n\n \/*\n * If result indicates an internal server error, then\n * replace the status line in the request object else\n * that provided by the application will be what is used\n * in any error page automatically generated by Apache.\n *\/\n\n if (self->result == HTTP_INTERNAL_SERVER_ERROR)\n self->r->status_line = \"500 Internal Server Error\";\n\n return self->result;\n}","target":0,"code_token_length":1084,"total_token_length":1320,"max_tokens_setting":2048} +{"idx":349635,"func":"main (int argc,\n char *argv[])\n{\n int ret;\n\n g_test_init (&argc, &argv, NULL);\n g_test_bug_base (\"http:\/\/bugzilla.gnome.org\/\");\n\n g_setenv (\"GSETTINGS_BACKEND\", \"memory\", TRUE);\n g_setenv (\"GIO_USE_TLS\", BACKEND, TRUE);\n\n g_assert_true (g_ascii_strcasecmp (G_OBJECT_TYPE_NAME (g_tls_backend_get_default ()), \"GTlsBackend\" BACKEND) == 0);\n\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/basic\", TestConnection, NULL,\n setup_connection, test_basic_connection, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/verified\", TestConnection, NULL,\n setup_connection, test_verified_connection, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/verified-chain\", TestConnection, NULL,\n setup_connection, test_verified_chain, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/verified-chain-with-redundant-root-cert\", TestConnection, NULL,\n setup_connection, test_verified_chain_with_redundant_root_cert, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/verified-chain-with-duplicate-server-cert\", TestConnection, NULL,\n setup_connection, test_verified_chain_with_duplicate_server_cert, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/verified-unordered-chain\", TestConnection, NULL,\n setup_connection, test_verified_unordered_chain, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/verified-chain-with-alternative-ca-cert\", TestConnection, NULL,\n setup_connection, test_verified_chain_with_alternative_ca_cert, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/invalid-chain-with-alternative-ca-cert\", TestConnection, NULL,\n setup_connection, test_invalid_chain_with_alternative_ca_cert, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth\", TestConnection, NULL,\n setup_connection, test_client_auth_connection, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth-rehandshake\", TestConnection, NULL,\n setup_connection, test_client_auth_rehandshake, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth-failure\", TestConnection, NULL,\n setup_connection, test_client_auth_failure, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth-fail-missing-client-private-key\", TestConnection, NULL,\n setup_connection, test_client_auth_fail_missing_client_private_key, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth-request-cert\", TestConnection, NULL,\n setup_connection, test_client_auth_request_cert, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth-request-fail\", TestConnection, NULL,\n setup_connection, test_client_auth_request_fail, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/client-auth-request-none\", TestConnection, NULL,\n setup_connection, test_client_auth_request_none, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/no-database\", TestConnection, NULL,\n setup_connection, test_connection_no_database, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/failed\", TestConnection, NULL,\n setup_connection, test_failed_connection, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/socket-client\", TestConnection, NULL,\n setup_connection, test_connection_socket_client, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/socket-client-failed\", TestConnection, NULL,\n setup_connection, test_connection_socket_client_failed, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/read-time-out-then-write\", TestConnection, NULL,\n setup_connection, test_connection_read_time_out_write, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/simultaneous-async\", TestConnection, NULL,\n setup_connection, test_simultaneous_async, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/simultaneous-sync\", TestConnection, NULL,\n setup_connection, test_simultaneous_sync, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/simultaneous-async-rehandshake\", TestConnection, NULL,\n setup_connection, test_simultaneous_async_rehandshake, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/simultaneous-sync-rehandshake\", TestConnection, NULL,\n setup_connection, test_simultaneous_sync_rehandshake, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/close-immediately\", TestConnection, NULL,\n setup_connection, test_close_immediately, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/unclean-close-by-server\", TestConnection, NULL,\n setup_connection, test_unclean_close_by_server, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/async-implicit-handshake\", TestConnection, NULL,\n setup_connection, test_async_implicit_handshake, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/output-stream-close\", TestConnection, NULL,\n setup_connection, test_output_stream_close, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/fallback\", TestConnection, NULL,\n setup_connection, test_fallback, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/garbage-database\", TestConnection, NULL,\n setup_connection, test_garbage_database, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/readwrite-after-connection-destroyed\", TestConnection, NULL,\n setup_connection, test_readwrite_after_connection_destroyed, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/alpn\/match\", TestConnection, NULL,\n setup_connection, test_alpn_match, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/alpn\/no-match\", TestConnection, NULL,\n setup_connection, test_alpn_no_match, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/alpn\/client-only\", TestConnection, NULL,\n setup_connection, test_alpn_client_only, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/alpn\/server-only\", TestConnection, NULL,\n setup_connection, test_alpn_server_only, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/sync-op-during-handshake\", TestConnection, NULL,\n setup_connection, test_sync_op_during_handshake, teardown_connection);\n g_test_add (\"\/tls\/\" BACKEND \"\/connection\/socket-timeout\", TestConnection, NULL,\n setup_connection, test_socket_timeout, teardown_connection);\n\n ret = g_test_run ();\n\n \/* for valgrinding *\/\n g_main_context_unref (g_main_context_default ());\n\n return ret;\n}","target":1,"code_token_length":1441,"total_token_length":1677,"max_tokens_setting":2048} +{"idx":160071,"func":"int MDSDaemon::_handle_command(\n const cmdmap_t &cmdmap,\n MCommand *m,\n bufferlist *outbl,\n std::string *outs,\n Context **run_later,\n bool *need_reply)\n{\n assert(outbl != NULL);\n assert(outs != NULL);\n\n class SuicideLater : public Context\n {\n MDSDaemon *mds;\n\n public:\n explicit SuicideLater(MDSDaemon *mds_) : mds(mds_) {}\n void finish(int r) override {\n \/\/ Wait a little to improve chances of caller getting\n \/\/ our response before seeing us disappear from mdsmap\n sleep(1);\n\n mds->suicide();\n }\n };\n\n\n class RespawnLater : public Context\n {\n MDSDaemon *mds;\n\n public:\n\n explicit RespawnLater(MDSDaemon *mds_) : mds(mds_) {}\n void finish(int r) override {\n \/\/ Wait a little to improve chances of caller getting\n \/\/ our response before seeing us disappear from mdsmap\n sleep(1);\n\n mds->respawn();\n }\n };\n\n std::stringstream ds;\n std::stringstream ss;\n std::string prefix;\n std::string format;\n std::unique_ptr f(Formatter::create(format));\n cmd_getval(cct, cmdmap, \"prefix\", prefix);\n\n int r = 0;\n\n if (prefix == \"get_command_descriptions\") {\n int cmdnum = 0;\n std::unique_ptr f(ceph::make_unique());\n f->open_object_section(\"command_descriptions\");\n for (MDSCommand *cp = mds_commands;\n\t cp < &mds_commands[ARRAY_SIZE(mds_commands)]; cp++) {\n\n ostringstream secname;\n secname << \"cmd\" << setfill('0') << std::setw(3) << cmdnum;\n dump_cmddesc_to_json(f.get(), secname.str(), cp->cmdstring, cp->helpstring,\n\t\t\t cp->module, cp->perm, cp->availability, 0);\n cmdnum++;\n }\n f->close_section();\t\/\/ command_descriptions\n\n f->flush(ds);\n goto out; \n }\n\n cmd_getval(cct, cmdmap, \"format\", format);\n if (prefix == \"version\") {\n if (f) {\n f->open_object_section(\"version\");\n f->dump_string(\"version\", pretty_version_to_str());\n f->close_section();\n f->flush(ds);\n } else {\n ds << pretty_version_to_str();\n }\n } else if (prefix == \"injectargs\") {\n vector argsvec;\n cmd_getval(cct, cmdmap, \"injected_args\", argsvec);\n\n if (argsvec.empty()) {\n r = -EINVAL;\n ss << \"ignoring empty injectargs\";\n goto out;\n }\n string args = argsvec.front();\n for (vector::iterator a = ++argsvec.begin(); a != argsvec.end(); ++a)\n args += \" \" + *a;\n r = cct->_conf->injectargs(args, &ss);\n } else if (prefix == \"config set\") {\n std::string key;\n cmd_getval(cct, cmdmap, \"key\", key);\n std::string val;\n cmd_getval(cct, cmdmap, \"value\", val);\n r = cct->_conf->set_val(key, val, true, &ss);\n if (r == 0) {\n cct->_conf->apply_changes(nullptr);\n }\n } else if (prefix == \"exit\") {\n \/\/ We will send response before executing\n ss << \"Exiting...\";\n *run_later = new SuicideLater(this);\n } else if (prefix == \"respawn\") {\n \/\/ We will send response before executing\n ss << \"Respawning...\";\n *run_later = new RespawnLater(this);\n } else if (prefix == \"session kill\") {\n if (mds_rank == NULL) {\n r = -EINVAL;\n ss << \"MDS not active\";\n goto out;\n }\n \/\/ FIXME harmonize `session kill` with admin socket session evict\n int64_t session_id = 0;\n bool got = cmd_getval(cct, cmdmap, \"session_id\", session_id);\n assert(got);\n bool killed = mds_rank->evict_client(session_id, false,\n g_conf->mds_session_blacklist_on_evict,\n ss);\n if (!killed)\n r = -ENOENT;\n } else if (prefix == \"heap\") {\n if (!ceph_using_tcmalloc()) {\n r = -EOPNOTSUPP;\n ss << \"could not issue heap profiler command -- not using tcmalloc!\";\n } else {\n string heapcmd;\n cmd_getval(cct, cmdmap, \"heapcmd\", heapcmd);\n vector heapcmd_vec;\n get_str_vec(heapcmd, heapcmd_vec);\n ceph_heap_profiler_handle_command(heapcmd_vec, ds);\n }\n } else if (prefix == \"cpu_profiler\") {\n string arg;\n cmd_getval(cct, cmdmap, \"arg\", arg);\n vector argvec;\n get_str_vec(arg, argvec);\n cpu_profiler_handle_command(argvec, ds);\n } else {\n \/\/ Give MDSRank a shot at the command\n if (!mds_rank) {\n ss << \"MDS not active\";\n r = -EINVAL;\n }\n else {\n bool handled = mds_rank->handle_command(cmdmap, m, &r, &ds, &ss,\n\t\t\t\t\t need_reply);\n if (!handled) {\n \/\/ MDSDaemon doesn't know this command\n ss << \"unrecognized command! \" << prefix;\n r = -EINVAL;\n }\n }\n }\n\nout:\n *outs = ss.str();\n outbl->append(ds);\n return r;\n}","target":0,"code_token_length":1306,"total_token_length":1542,"max_tokens_setting":2048} +{"idx":405573,"func":"read_children(struct archive_read *a, struct file_info *parent)\n{\n\tstruct iso9660 *iso9660;\n\tconst unsigned char *b, *p;\n\tstruct file_info *multi;\n\tsize_t step, skip_size;\n\n\tiso9660 = (struct iso9660 *)(a->format->data);\n\t\/* flush any remaining bytes from the last round to ensure\n\t * we're positioned *\/\n\tif (iso9660->entry_bytes_unconsumed) {\n\t\t__archive_read_consume(a, iso9660->entry_bytes_unconsumed);\n\t\tiso9660->entry_bytes_unconsumed = 0;\n\t}\n\tif (iso9660->current_position > parent->offset) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"Ignoring out-of-order directory (%s) %jd > %jd\",\n\t\t parent->name.s,\n\t\t (intmax_t)iso9660->current_position,\n\t\t (intmax_t)parent->offset);\n\t\treturn (ARCHIVE_WARN);\n\t}\n\tif (parent->offset + parent->size > iso9660->volume_size) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"Directory is beyond end-of-media: %s\",\n\t\t parent->name.s);\n\t\treturn (ARCHIVE_WARN);\n\t}\n\tif (iso9660->current_position < parent->offset) {\n\t\tint64_t skipsize;\n\n\t\tskipsize = parent->offset - iso9660->current_position;\n\t\tskipsize = __archive_read_consume(a, skipsize);\n\t\tif (skipsize < 0)\n\t\t\treturn ((int)skipsize);\n\t\tiso9660->current_position = parent->offset;\n\t}\n\n\tstep = (size_t)(((parent->size + iso9660->logical_block_size -1) \/\n\t iso9660->logical_block_size) * iso9660->logical_block_size);\n\tb = __archive_read_ahead(a, step, NULL);\n\tif (b == NULL) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"Failed to read full block when scanning \"\n\t\t \"ISO9660 directory list\");\n\t\treturn (ARCHIVE_FATAL);\n\t}\n\tiso9660->current_position += step;\n\tmulti = NULL;\n\tskip_size = step;\n\twhile (step) {\n\t\tp = b;\n\t\tb += iso9660->logical_block_size;\n\t\tstep -= iso9660->logical_block_size;\n\t\tfor (; *p != 0 && p < b && p + *p <= b; p += *p) {\n\t\t\tstruct file_info *child;\n\n\t\t\t\/* N.B.: these special directory identifiers\n\t\t\t * are 8 bit \"values\" even on a\n\t\t\t * Joliet CD with UCS-2 (16bit) encoding.\n\t\t\t *\/\n\n\t\t\t\/* Skip '.' entry. *\/\n\t\t\tif (*(p + DR_name_len_offset) == 1\n\t\t\t && *(p + DR_name_offset) == '\\0')\n\t\t\t\tcontinue;\n\t\t\t\/* Skip '..' entry. *\/\n\t\t\tif (*(p + DR_name_len_offset) == 1\n\t\t\t && *(p + DR_name_offset) == '\\001')\n\t\t\t\tcontinue;\n\t\t\tchild = parse_file_info(a, parent, p, b - p);\n\t\t\tif (child == NULL) {\n\t\t\t\t__archive_read_consume(a, skip_size);\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\tif (child->cl_offset == 0 &&\n\t\t\t (child->multi_extent || multi != NULL)) {\n\t\t\t\tstruct content *con;\n\n\t\t\t\tif (multi == NULL) {\n\t\t\t\t\tmulti = child;\n\t\t\t\t\tmulti->contents.first = NULL;\n\t\t\t\t\tmulti->contents.last =\n\t\t\t\t\t &(multi->contents.first);\n\t\t\t\t}\n\t\t\t\tcon = malloc(sizeof(struct content));\n\t\t\t\tif (con == NULL) {\n\t\t\t\t\tarchive_set_error(\n\t\t\t\t\t &a->archive, ENOMEM,\n\t\t\t\t\t \"No memory for multi extent\");\n\t\t\t\t\t__archive_read_consume(a, skip_size);\n\t\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t\t}\n\t\t\t\tcon->offset = child->offset;\n\t\t\t\tcon->size = child->size;\n\t\t\t\tcon->next = NULL;\n\t\t\t\t*multi->contents.last = con;\n\t\t\t\tmulti->contents.last = &(con->next);\n\t\t\t\tif (multi == child) {\n\t\t\t\t\tif (add_entry(a, iso9660, child)\n\t\t\t\t\t != ARCHIVE_OK)\n\t\t\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t\t} else {\n\t\t\t\t\tmulti->size += child->size;\n\t\t\t\t\tif (!child->multi_extent)\n\t\t\t\t\t\tmulti = NULL;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\tif (add_entry(a, iso9660, child) != ARCHIVE_OK)\n\t\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t}\n\n\t__archive_read_consume(a, skip_size);\n\n\t\/* Read data which recorded by RRIP \"CE\" extension. *\/\n\tif (read_CE(a, iso9660) != ARCHIVE_OK)\n\t\treturn (ARCHIVE_FATAL);\n\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":1096,"total_token_length":1332,"max_tokens_setting":2048} +{"idx":332998,"func":"static int xwma_read_header(AVFormatContext *s, AVFormatParameters *ap)\n\n{\n\n int64_t size, av_uninit(data_size);\n\n uint32_t dpds_table_size = 0;\n\n uint32_t *dpds_table = 0;\n\n unsigned int tag;\n\n AVIOContext *pb = s->pb;\n\n AVStream *st;\n\n XWMAContext *xwma = s->priv_data;\n\n int i;\n\n\n\n \/* The following code is mostly copied from wav.c, with some\n\n * minor alterations.\n\n *\/\n\n\n\n \/* check RIFF header *\/\n\n tag = avio_rl32(pb);\n\n if (tag != MKTAG('R', 'I', 'F', 'F'))\n\n return -1;\n\n avio_rl32(pb); \/* file size *\/\n\n tag = avio_rl32(pb);\n\n if (tag != MKTAG('X', 'W', 'M', 'A'))\n\n return -1;\n\n\n\n \/* parse fmt header *\/\n\n tag = avio_rl32(pb);\n\n if (tag != MKTAG('f', 'm', 't', ' '))\n\n return -1;\n\n size = avio_rl32(pb);\n\n st = av_new_stream(s, 0);\n\n if (!st)\n\n return AVERROR(ENOMEM);\n\n\n\n ff_get_wav_header(pb, st->codec, size);\n\n st->need_parsing = AVSTREAM_PARSE_NONE;\n\n\n\n \/* All xWMA files I have seen contained WMAv2 data. If there are files\n\n * using WMA Pro or some other codec, then we need to figure out the right\n\n * extradata for that. Thus, ask the user for feedback, but try to go on\n\n * anyway.\n\n *\/\n\n if (st->codec->codec_id != CODEC_ID_WMAV2) {\n\n av_log(s, AV_LOG_WARNING, \"unexpected codec (tag 0x04%x; id %d)\\n\",\n\n st->codec->codec_tag, st->codec->codec_id);\n\n av_log_ask_for_sample(s, NULL);\n\n } else {\n\n \/* In all xWMA files I have seen, there is no extradata. But the WMA\n\n * codecs require extradata, so we provide our own fake extradata.\n\n *\n\n * First, check that there really was no extradata in the header. If\n\n * there was, then try to use, after asking the the user to provide a\n\n * sample of this unusual file.\n\n *\/\n\n if (st->codec->extradata_size != 0) {\n\n \/* Surprise, surprise: We *did* get some extradata. No idea\n\n * if it will work, but just go on and try it, after asking\n\n * the user for a sample.\n\n *\/\n\n av_log(s, AV_LOG_WARNING, \"unexpected extradata (%d bytes)\\n\",\n\n st->codec->extradata_size);\n\n av_log_ask_for_sample(s, NULL);\n\n } else {\n\n st->codec->extradata_size = 6;\n\n st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);\n\n if (!st->codec->extradata)\n\n return AVERROR(ENOMEM);\n\n\n\n \/* setup extradata with our experimentally obtained value *\/\n\n st->codec->extradata[4] = 31;\n\n }\n\n }\n\n\n\n \/* set the sample rate *\/\n\n av_set_pts_info(st, 64, 1, st->codec->sample_rate);\n\n\n\n \/* parse the remaining RIFF chunks *\/\n\n for (;;) {\n\n if (pb->eof_reached)\n\n return -1;\n\n \/* read next chunk tag *\/\n\n tag = avio_rl32(pb);\n\n size = avio_rl32(pb);\n\n if (tag == MKTAG('d', 'a', 't', 'a')) {\n\n \/* We assume that the data chunk comes last. *\/\n\n break;\n\n } else if (tag == MKTAG('d','p','d','s')) {\n\n \/* Quoting the MSDN xWMA docs on the dpds chunk: \"Contains the\n\n * decoded packet cumulative data size array, each element is the\n\n * number of bytes accumulated after the corresponding xWMA packet\n\n * is decoded in order\"\n\n *\n\n * Each packet has size equal to st->codec->block_align, which in\n\n * all cases I saw so far was always 2230. Thus, we can use the\n\n * dpds data to compute a seeking index.\n\n *\/\n\n\n\n \/* Error out if there is more than one dpds chunk. *\/\n\n if (dpds_table) {\n\n av_log(s, AV_LOG_ERROR, \"two dpds chunks present\\n\");\n\n return -1;\n\n }\n\n\n\n \/* Compute the number of entries in the dpds chunk. *\/\n\n if (size & 3) { \/* Size should be divisible by four *\/\n\n av_log(s, AV_LOG_WARNING, \"dpds chunk size \"PRId64\" not divisible by 4\\n\", size);\n\n }\n\n dpds_table_size = size \/ 4;\n\n if (dpds_table_size == 0 || dpds_table_size >= INT_MAX \/ 4) {\n\n av_log(s, AV_LOG_ERROR, \"dpds chunk size \"PRId64\" invalid\\n\", size);\n\n return -1;\n\n }\n\n\n\n \/* Allocate some temporary storage to keep the dpds data around.\n\n * for processing later on.\n\n *\/\n\n dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));\n\n if (!dpds_table) {\n\n return AVERROR(ENOMEM);\n\n }\n\n\n\n for (i = 0; i < dpds_table_size; ++i) {\n\n dpds_table[i] = avio_rl32(pb);\n\n size -= 4;\n\n }\n\n }\n\n avio_skip(pb, size);\n\n }\n\n\n\n \/* Determine overall data length *\/\n\n if (size < 0)\n\n return -1;\n\n if (!size) {\n\n xwma->data_end = INT64_MAX;\n\n } else\n\n xwma->data_end = avio_tell(pb) + size;\n\n\n\n\n\n if (dpds_table && dpds_table_size) {\n\n int64_t cur_pos;\n\n const uint32_t bytes_per_sample\n\n = (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;\n\n\n\n \/* Estimate the duration from the total number of output bytes. *\/\n\n const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];\n\n st->duration = total_decoded_bytes \/ bytes_per_sample;\n\n\n\n \/* Use the dpds data to build a seek table. We can only do this after\n\n * we know the offset to the data chunk, as we need that to determine\n\n * the actual offset to each input block.\n\n * Note: If we allowed ourselves to assume that the data chunk always\n\n * follows immediately after the dpds block, we could of course guess\n\n * the data block's start offset already while reading the dpds chunk.\n\n * I decided against that, just in case other chunks ever are\n\n * discovered.\n\n *\/\n\n cur_pos = avio_tell(pb);\n\n for (i = 0; i < dpds_table_size; ++i) {\n\n \/* From the number of output bytes that would accumulate in the\n\n * output buffer after decoding the first (i+1) packets, we compute\n\n * an offset \/ timestamp pair.\n\n *\/\n\n av_add_index_entry(st,\n\n cur_pos + (i+1) * st->codec->block_align, \/* pos *\/\n\n dpds_table[i] \/ bytes_per_sample, \/* timestamp *\/\n\n st->codec->block_align, \/* size *\/\n\n 0, \/* duration *\/\n\n AVINDEX_KEYFRAME);\n\n }\n\n } else if (st->codec->bit_rate) {\n\n \/* No dpds chunk was present (or only an empty one), so estimate\n\n * the total duration using the average bits per sample and the\n\n * total data length.\n\n *\/\n\n st->duration = (size<<3) * st->codec->sample_rate \/ st->codec->bit_rate;\n\n }\n\n\n\n av_free(dpds_table);\n\n\n\n return 0;\n\n}\n","target":1,"code_token_length":1778,"total_token_length":2014,"max_tokens_setting":2048} +{"idx":384472,"func":"_asn1_check_identifier (asn1_node node)\n{\n asn1_node p, p2;\n char name2[ASN1_MAX_NAME_SIZE * 2 + 2];\n\n if (node == NULL)\n return ASN1_ELEMENT_NOT_FOUND;\n\n p = node;\n while (p)\n {\n if (p->value && type_field (p->type) == ASN1_ETYPE_IDENTIFIER)\n\t{\n\t _asn1_str_cpy (name2, sizeof (name2), node->name);\n\t _asn1_str_cat (name2, sizeof (name2), \".\");\n\t _asn1_str_cat (name2, sizeof (name2), (char *) p->value);\n\t p2 = asn1_find_node (node, name2);\n\t if (p2 == NULL)\n\t {\n\t if (p->value)\n\t\t_asn1_strcpy (_asn1_identifierMissing, p->value);\n\t else\n\t\t_asn1_strcpy (_asn1_identifierMissing, \"(null)\");\n\t return ASN1_IDENTIFIER_NOT_FOUND;\n\t }\n\t}\n else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&\n\t (p->type & CONST_DEFAULT))\n\t{\n\t p2 = p->down;\n\t if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))\n\t {\n\t _asn1_str_cpy (name2, sizeof (name2), node->name);\n\t _asn1_str_cat (name2, sizeof (name2), \".\");\n\t _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);\n\t _asn1_strcpy (_asn1_identifierMissing, p2->value);\n\t p2 = asn1_find_node (node, name2);\n\t if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) ||\n\t\t !(p2->type & CONST_ASSIGN))\n\t\treturn ASN1_IDENTIFIER_NOT_FOUND;\n\t else\n\t\t_asn1_identifierMissing[0] = 0;\n\t }\n\t}\n else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&\n\t (p->type & CONST_ASSIGN))\n\t{\n\t p2 = p->down;\n\t if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))\n\t {\n\t if (p2->value && !isdigit (p2->value[0]))\n\t\t{\n\t\t _asn1_str_cpy (name2, sizeof (name2), node->name);\n\t\t _asn1_str_cat (name2, sizeof (name2), \".\");\n\t\t _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);\n\t\t _asn1_strcpy (_asn1_identifierMissing, p2->value);\n\t\t p2 = asn1_find_node (node, name2);\n\t\t if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID)\n\t\t || !(p2->type & CONST_ASSIGN))\n\t\t return ASN1_IDENTIFIER_NOT_FOUND;\n\t\t else\n\t\t _asn1_identifierMissing[0] = 0;\n\t\t}\n\t }\n\t}\n\n if (p->down)\n\t{\n\t p = p->down;\n\t}\n else if (p->right)\n\tp = p->right;\n else\n\t{\n\t while (1)\n\t {\n\t p = _asn1_get_up (p);\n\t if (p == node)\n\t\t{\n\t\t p = NULL;\n\t\t break;\n\t\t}\n\t if (p->right)\n\t\t{\n\t\t p = p->right;\n\t\t break;\n\t\t}\n\t }\n\t}\n }\n\n return ASN1_SUCCESS;\n}","target":0,"code_token_length":792,"total_token_length":1028,"max_tokens_setting":2048} +{"idx":344806,"func":"xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node,\n\tstruct stop *stops, int maxcount)\n{\n\tfz_colorspace *colorspace;\n\tfloat sample[8];\n\tfloat rgb[3];\n\tint before, after;\n\tint count;\n\tint i;\n\n\t\/* We may have to insert 2 extra stops when postprocessing *\/\n\tmaxcount -= 2;\n\n\tcount = 0;\n\twhile (node && count < maxcount)\n\t{\n\t\tif (!strcmp(fz_xml_tag(node), \"GradientStop\"))\n\t\t{\n\t\t\tchar *offset = fz_xml_att(node, \"Offset\");\n\t\t\tchar *color = fz_xml_att(node, \"Color\");\n\t\t\tif (offset && color)\n\t\t\t{\n\t\t\t\tstops[count].offset = fz_atof(offset);\n\t\t\t\tstops[count].index = count;\n\n\t\t\t\txps_parse_color(doc, base_uri, color, &colorspace, sample);\n\n\t\t\t\tfz_convert_color(doc->ctx, fz_device_rgb(doc->ctx), rgb, colorspace, sample + 1);\n\n\t\t\t\tstops[count].r = rgb[0];\n\t\t\t\tstops[count].g = rgb[1];\n\t\t\t\tstops[count].b = rgb[2];\n\t\t\t\tstops[count].a = sample[0];\n\n\t\t\t\tcount ++;\n\t\t\t}\n\t\t}\n\t\tnode = fz_xml_next(node);\n\t}\n\n\tif (count == 0)\n\t{\n\t\tfz_warn(doc->ctx, \"gradient brush has no gradient stops\");\n\t\tstops[0].offset = 0;\n\t\tstops[0].r = 0;\n\t\tstops[0].g = 0;\n\t\tstops[0].b = 0;\n\t\tstops[0].a = 1;\n\t\tstops[1].offset = 1;\n\t\tstops[1].r = 1;\n\t\tstops[1].g = 1;\n\t\tstops[1].b = 1;\n\t\tstops[1].a = 1;\n\t\treturn 2;\n\t}\n\n\tif (count == maxcount)\n\t\tfz_warn(doc->ctx, \"gradient brush exceeded maximum number of gradient stops\");\n\n\t\/* Postprocess to make sure the range of offsets is 0.0 to 1.0 *\/\n\n\tqsort(stops, count, sizeof(struct stop), cmp_stop);\n\n\tbefore = -1;\n\tafter = -1;\n\n\tfor (i = 0; i < count; i++)\n\t{\n\t\tif (stops[i].offset < 0)\n\t\t\tbefore = i;\n\t\tif (stops[i].offset > 1)\n\t\t{\n\t\t\tafter = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* Remove all stops < 0 except the largest one *\/\n\tif (before > 0)\n\t{\n\t\tmemmove(stops, stops + before, (count - before) * sizeof(struct stop));\n\t\tcount -= before;\n\t}\n\n\t\/* Remove all stops > 1 except the smallest one *\/\n\tif (after >= 0)\n\t\tcount = after + 1;\n\n\t\/* Expand single stop to 0 .. 1 *\/\n\tif (count == 1)\n\t{\n\t\tstops[1] = stops[0];\n\t\tstops[0].offset = 0;\n\t\tstops[1].offset = 1;\n\t\treturn 2;\n\t}\n\n\t\/* First stop < 0 -- interpolate value to 0 *\/\n\tif (stops[0].offset < 0)\n\t{\n\t\tfloat d = -stops[0].offset \/ (stops[1].offset - stops[0].offset);\n\t\tstops[0].offset = 0;\n\t\tstops[0].r = lerp(stops[0].r, stops[1].r, d);\n\t\tstops[0].g = lerp(stops[0].g, stops[1].g, d);\n\t\tstops[0].b = lerp(stops[0].b, stops[1].b, d);\n\t\tstops[0].a = lerp(stops[0].a, stops[1].a, d);\n\t}\n\n\t\/* Last stop > 1 -- interpolate value to 1 *\/\n\tif (stops[count-1].offset > 1)\n\t{\n\t\tfloat d = (1 - stops[count-2].offset) \/ (stops[count-1].offset - stops[count-2].offset);\n\t\tstops[count-1].offset = 1;\n\t\tstops[count-1].r = lerp(stops[count-2].r, stops[count-1].r, d);\n\t\tstops[count-1].g = lerp(stops[count-2].g, stops[count-1].g, d);\n\t\tstops[count-1].b = lerp(stops[count-2].b, stops[count-1].b, d);\n\t\tstops[count-1].a = lerp(stops[count-2].a, stops[count-1].a, d);\n\t}\n\n\t\/* First stop > 0 -- insert a duplicate at 0 *\/\n\tif (stops[0].offset > 0)\n\t{\n\t\tmemmove(stops + 1, stops, count * sizeof(struct stop));\n\t\tstops[0] = stops[1];\n\t\tstops[0].offset = 0;\n\t\tcount++;\n\t}\n\n\t\/* Last stop < 1 -- insert a duplicate at 1 *\/\n\tif (stops[count-1].offset < 1)\n\t{\n\t\tstops[count] = stops[count-1];\n\t\tstops[count].offset = 1;\n\t\tcount++;\n\t}\n\n\treturn count;\n}","target":1,"code_token_length":1169,"total_token_length":1405,"max_tokens_setting":2048} +{"idx":340558,"func":"static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)\n{\n MOVContext *mov = s->priv_data;\n MOVStreamContext *sc;\n AVIndexEntry *sample;\n AVStream *st = NULL;\n int ret;\n mov->fc = s;\n retry:\n sample = mov_find_next_sample(s, &st);\n if (!sample) {\n mov->found_mdat = 0;\n if (!mov->next_root_atom)\n return AVERROR_EOF;\n avio_seek(s->pb, mov->next_root_atom, SEEK_SET);\n mov->next_root_atom = 0;\n if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32(\"root\"), INT64_MAX }) < 0 ||\n url_feof(s->pb))\n return AVERROR_EOF;\n av_dlog(s, \"read fragments, offset 0x%\"PRIx64\"\\n\", avio_tell(s->pb));\n goto retry;\n sc = st->priv_data;\n \/* must be done just before reading, to avoid infinite loop on sample *\/\n sc->current_sample++;\n if (st->discard != AVDISCARD_ALL) {\n if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {\n av_log(mov->fc, AV_LOG_ERROR, \"stream %d, offset 0x%\"PRIx64\": partial file\\n\",\n sc->ffindex, sample->pos);\n return AVERROR_INVALIDDATA;\n ret = av_get_packet(sc->pb, pkt, sample->size);\n if (ret < 0)\n return ret;\n if (sc->has_palette) {\n uint8_t *pal;\n pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);\n if (!pal) {\n av_log(mov->fc, AV_LOG_ERROR, \"Cannot append palette to packet\\n\");\n } else {\n memcpy(pal, sc->palette, AVPALETTE_SIZE);\n sc->has_palette = 0;\n#if CONFIG_DV_DEMUXER\n if (mov->dv_demux && sc->dv_audio_container) {\n avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);\n av_free(pkt->data);\n pkt->size = 0;\n ret = avpriv_dv_get_packet(mov->dv_demux, pkt);\n if (ret < 0)\n return ret;\n#endif\n pkt->stream_index = sc->ffindex;\n pkt->dts = sample->timestamp;\n if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {\n pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;\n \/* update ctts context *\/\n sc->ctts_sample++;\n if (sc->ctts_index < sc->ctts_count &&\n sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {\n sc->ctts_index++;\n sc->ctts_sample = 0;\n if (sc->wrong_dts)\n pkt->dts = AV_NOPTS_VALUE;\n } else {\n int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?\n st->index_entries[sc->current_sample].timestamp : st->duration;\n pkt->duration = next_dts - pkt->dts;\n pkt->pts = pkt->dts;\n if (st->discard == AVDISCARD_ALL)\n goto retry;\n pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;\n pkt->pos = sample->pos;\n av_dlog(s, \"stream %d, pts %\"PRId64\", dts %\"PRId64\", pos 0x%\"PRIx64\", duration %d\\n\",\n pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);\n return 0;","target":1,"code_token_length":892,"total_token_length":1128,"max_tokens_setting":2048} +{"idx":353757,"func":"static int dump_tablespaces(char* ts_where)\n{\n MYSQL_ROW row;\n MYSQL_RES *tableres;\n char buf[FN_REFLEN];\n DYNAMIC_STRING sqlbuf;\n int first= 0;\n \/*\n The following are used for parsing the EXTRA field\n *\/\n char extra_format[]= \"UNDO_BUFFER_SIZE=\";\n char *ubs;\n char *endsemi;\n DBUG_ENTER(\"dump_tablespaces\");\n \n \/*\n Try to turn off semi-join optimization (if that fails, this is a\n pre-optimizer_switch server, and the old query plan is ok for us.\n *\/\n mysql_query(mysql, \"set optimizer_switch='semijoin=off'\");\n \n init_dynamic_string_checked(&sqlbuf,\n \"SELECT LOGFILE_GROUP_NAME,\"\n \" FILE_NAME,\"\n \" TOTAL_EXTENTS,\"\n \" INITIAL_SIZE,\"\n \" ENGINE,\"\n \" EXTRA\"\n \" FROM INFORMATION_SCHEMA.FILES\"\n \" WHERE FILE_TYPE = 'UNDO LOG'\"\n \" AND FILE_NAME IS NOT NULL\",\n 256, 1024);\n if(ts_where)\n {\n dynstr_append_checked(&sqlbuf,\n \" AND LOGFILE_GROUP_NAME IN (\"\n \"SELECT DISTINCT LOGFILE_GROUP_NAME\"\n \" FROM INFORMATION_SCHEMA.FILES\"\n \" WHERE FILE_TYPE = 'DATAFILE'\"\n );\n dynstr_append_checked(&sqlbuf, ts_where);\n dynstr_append_checked(&sqlbuf, \")\");\n }\n dynstr_append_checked(&sqlbuf,\n \" GROUP BY LOGFILE_GROUP_NAME, FILE_NAME\"\n \", ENGINE\"\n \" ORDER BY LOGFILE_GROUP_NAME\");\n\n if (mysql_query(mysql, sqlbuf.str) ||\n !(tableres = mysql_store_result(mysql)))\n {\n dynstr_free(&sqlbuf);\n if (mysql_errno(mysql) == ER_BAD_TABLE_ERROR ||\n mysql_errno(mysql) == ER_BAD_DB_ERROR ||\n mysql_errno(mysql) == ER_UNKNOWN_TABLE)\n {\n fprintf(md_result_file,\n \"\\n--\\n-- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES\"\n \" table on this server\\n--\\n\");\n check_io(md_result_file);\n DBUG_RETURN(0);\n }\n\n fprintf(stderr, \"%s: Error: '%s' when trying to dump tablespaces\\n\",\n my_progname_short, mysql_error(mysql));\n DBUG_RETURN(1);\n }\n\n buf[0]= 0;\n while ((row= mysql_fetch_row(tableres)))\n {\n if (strcmp(buf, row[0]) != 0)\n first= 1;\n if (first)\n {\n print_comment(md_result_file, 0, \"\\n--\\n-- Logfile group: %s\\n--\\n\",\n row[0]);\n\n fprintf(md_result_file, \"\\nCREATE\");\n }\n else\n {\n fprintf(md_result_file, \"\\nALTER\");\n }\n fprintf(md_result_file,\n \" LOGFILE GROUP %s\\n\"\n \" ADD UNDOFILE '%s'\\n\",\n row[0],\n row[1]);\n if (first)\n {\n ubs= strstr(row[5],extra_format);\n if(!ubs)\n break;\n ubs+= strlen(extra_format);\n endsemi= strstr(ubs,\";\");\n if(endsemi)\n endsemi[0]= '\\0';\n fprintf(md_result_file,\n \" UNDO_BUFFER_SIZE %s\\n\",\n ubs);\n }\n fprintf(md_result_file,\n \" INITIAL_SIZE %s\\n\"\n \" ENGINE=%s;\\n\",\n row[3],\n row[4]);\n check_io(md_result_file);\n if (first)\n {\n first= 0;\n strxmov(buf, row[0], NullS);\n }\n }\n dynstr_free(&sqlbuf);\n mysql_free_result(tableres);\n init_dynamic_string_checked(&sqlbuf,\n \"SELECT DISTINCT TABLESPACE_NAME,\"\n \" FILE_NAME,\"\n \" LOGFILE_GROUP_NAME,\"\n \" EXTENT_SIZE,\"\n \" INITIAL_SIZE,\"\n \" ENGINE\"\n \" FROM INFORMATION_SCHEMA.FILES\"\n \" WHERE FILE_TYPE = 'DATAFILE'\",\n 256, 1024);\n\n if(ts_where)\n dynstr_append_checked(&sqlbuf, ts_where);\n\n dynstr_append_checked(&sqlbuf, \" ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME\");\n\n if (mysql_query_with_error_report(mysql, &tableres, sqlbuf.str))\n {\n dynstr_free(&sqlbuf);\n DBUG_RETURN(1);\n }\n\n buf[0]= 0;\n while ((row= mysql_fetch_row(tableres)))\n {\n if (strcmp(buf, row[0]) != 0)\n first= 1;\n if (first)\n {\n print_comment(md_result_file, 0, \"\\n--\\n-- Tablespace: %s\\n--\\n\", row[0]);\n fprintf(md_result_file, \"\\nCREATE\");\n }\n else\n {\n fprintf(md_result_file, \"\\nALTER\");\n }\n fprintf(md_result_file,\n \" TABLESPACE %s\\n\"\n \" ADD DATAFILE '%s'\\n\",\n row[0],\n row[1]);\n if (first)\n {\n fprintf(md_result_file,\n \" USE LOGFILE GROUP %s\\n\"\n \" EXTENT_SIZE %s\\n\",\n row[2],\n row[3]);\n }\n fprintf(md_result_file,\n \" INITIAL_SIZE %s\\n\"\n \" ENGINE=%s;\\n\",\n row[4],\n row[5]);\n check_io(md_result_file);\n if (first)\n {\n first= 0;\n strxmov(buf, row[0], NullS);\n }\n }\n\n mysql_free_result(tableres);\n dynstr_free(&sqlbuf);\n mysql_query(mysql, \"set optimizer_switch=default\");\n\n DBUG_RETURN(0);\n}","target":1,"code_token_length":1258,"total_token_length":1494,"max_tokens_setting":2048} +{"idx":439535,"func":"skb_flow_dissect_tunnel_info(const struct sk_buff *skb,\n\t\t\t struct flow_dissector *flow_dissector,\n\t\t\t void *target_container)\n{\n\tstruct ip_tunnel_info *info;\n\tstruct ip_tunnel_key *key;\n\n\t\/* A quick check to see if there might be something to do. *\/\n\tif (!dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_KEYID) &&\n\t !dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) &&\n\t !dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS) &&\n\t !dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_CONTROL) &&\n\t !dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_PORTS) &&\n\t !dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_IP) &&\n\t !dissector_uses_key(flow_dissector,\n\t\t\t\tFLOW_DISSECTOR_KEY_ENC_OPTS))\n\t\treturn;\n\n\tinfo = skb_tunnel_info(skb);\n\tif (!info)\n\t\treturn;\n\n\tkey = &info->key;\n\n\tswitch (ip_tunnel_info_af(info)) {\n\tcase AF_INET:\n\t\tskb_flow_dissect_set_enc_addr_type(FLOW_DISSECTOR_KEY_IPV4_ADDRS,\n\t\t\t\t\t\t flow_dissector,\n\t\t\t\t\t\t target_container);\n\t\tif (dissector_uses_key(flow_dissector,\n\t\t\t\t FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) {\n\t\t\tstruct flow_dissector_key_ipv4_addrs *ipv4;\n\n\t\t\tipv4 = skb_flow_dissector_target(flow_dissector,\n\t\t\t\t\t\t\t FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS,\n\t\t\t\t\t\t\t target_container);\n\t\t\tipv4->src = key->u.ipv4.src;\n\t\t\tipv4->dst = key->u.ipv4.dst;\n\t\t}\n\t\tbreak;\n\tcase AF_INET6:\n\t\tskb_flow_dissect_set_enc_addr_type(FLOW_DISSECTOR_KEY_IPV6_ADDRS,\n\t\t\t\t\t\t flow_dissector,\n\t\t\t\t\t\t target_container);\n\t\tif (dissector_uses_key(flow_dissector,\n\t\t\t\t FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS)) {\n\t\t\tstruct flow_dissector_key_ipv6_addrs *ipv6;\n\n\t\t\tipv6 = skb_flow_dissector_target(flow_dissector,\n\t\t\t\t\t\t\t FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS,\n\t\t\t\t\t\t\t target_container);\n\t\t\tipv6->src = key->u.ipv6.src;\n\t\t\tipv6->dst = key->u.ipv6.dst;\n\t\t}\n\t\tbreak;\n\t}\n\n\tif (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_KEYID)) {\n\t\tstruct flow_dissector_key_keyid *keyid;\n\n\t\tkeyid = skb_flow_dissector_target(flow_dissector,\n\t\t\t\t\t\t FLOW_DISSECTOR_KEY_ENC_KEYID,\n\t\t\t\t\t\t target_container);\n\t\tkeyid->keyid = tunnel_id_to_key32(key->tun_id);\n\t}\n\n\tif (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_PORTS)) {\n\t\tstruct flow_dissector_key_ports *tp;\n\n\t\ttp = skb_flow_dissector_target(flow_dissector,\n\t\t\t\t\t FLOW_DISSECTOR_KEY_ENC_PORTS,\n\t\t\t\t\t target_container);\n\t\ttp->src = key->tp_src;\n\t\ttp->dst = key->tp_dst;\n\t}\n\n\tif (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IP)) {\n\t\tstruct flow_dissector_key_ip *ip;\n\n\t\tip = skb_flow_dissector_target(flow_dissector,\n\t\t\t\t\t FLOW_DISSECTOR_KEY_ENC_IP,\n\t\t\t\t\t target_container);\n\t\tip->tos = key->tos;\n\t\tip->ttl = key->ttl;\n\t}\n\n\tif (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_OPTS)) {\n\t\tstruct flow_dissector_key_enc_opts *enc_opt;\n\n\t\tenc_opt = skb_flow_dissector_target(flow_dissector,\n\t\t\t\t\t\t FLOW_DISSECTOR_KEY_ENC_OPTS,\n\t\t\t\t\t\t target_container);\n\n\t\tif (info->options_len) {\n\t\t\tenc_opt->len = info->options_len;\n\t\t\tip_tunnel_info_opts_get(enc_opt->data, info);\n\t\t\tenc_opt->dst_opt_type = info->key.tun_flags &\n\t\t\t\t\t\tTUNNEL_OPTIONS_PRESENT;\n\t\t}\n\t}\n}","target":0,"code_token_length":897,"total_token_length":1133,"max_tokens_setting":2048} +{"idx":480484,"func":"gif_initialise_frame_extensions(gif_animation *gif, const int frame)\n{\n const unsigned char *gif_data, *gif_end;\n ssize_t gif_bytes;\n ssize_t block_size;\n\n \/* Get our buffer position etc.\t*\/\n gif_data = (const unsigned char *)(gif->gif_data + gif->buffer_position);\n gif_end = (const unsigned char *)(gif->gif_data + gif->buffer_size);\n\n \/* Initialise the extensions *\/\n while (gif_data < gif_end && gif_data[0] == GIF_EXTENSION_INTRODUCER) {\n ++gif_data;\n if ((gif_bytes = (gif_end - gif_data)) < 1) {\n return GIF_INSUFFICIENT_FRAME_DATA;\n }\n\n \/* Switch on extension label *\/\n switch (gif_data[0]) {\n case GIF_EXTENSION_GRAPHIC_CONTROL:\n \/* 6-byte Graphic Control Extension is:\n *\n *\t+0\tCHAR\tGraphic Control Label\n *\t+1\tCHAR\tBlock Size\n *\t+2\tCHAR\t__Packed Fields__\n *\t\t\t3BITS\tReserved\n *\t\t\t3BITS\tDisposal Method\n *\t\t\t1BIT\tUser Input Flag\n *\t\t\t1BIT\tTransparent Color Flag\n *\t+3\tSHORT\tDelay Time\n *\t+5\tCHAR\tTransparent Color Index\n *\/\n if (gif_bytes < 6) {\n return GIF_INSUFFICIENT_FRAME_DATA;\n }\n\n gif->frames[frame].frame_delay = gif_data[3] | (gif_data[4] << 8);\n if (gif_data[2] & GIF_TRANSPARENCY_MASK) {\n gif->frames[frame].transparency = true;\n gif->frames[frame].transparency_index = gif_data[5];\n }\n gif->frames[frame].disposal_method = ((gif_data[2] & GIF_DISPOSAL_MASK) >> 2);\n \/* I have encountered documentation and GIFs in the\n * wild that use 0x04 to restore the previous frame,\n * rather than the officially documented 0x03. I\n * believe some (older?) software may even actually\n * export this way. We handle this as a type of\n * \"quirks\" mode.\n *\/\n if (gif->frames[frame].disposal_method == GIF_FRAME_QUIRKS_RESTORE) {\n gif->frames[frame].disposal_method = GIF_FRAME_RESTORE;\n }\n gif_data += (2 + gif_data[1]);\n break;\n\n case GIF_EXTENSION_APPLICATION:\n \/* 14-byte+ Application Extension is:\n *\n *\t+0 CHAR Application Extension Label\n *\t+1 CHAR Block Size\n *\t+2 8CHARS Application Identifier\n *\t+10 3CHARS Appl. Authentication Code\n *\t+13 1-256 Application Data (Data sub-blocks)\n *\/\n if (gif_bytes < 17) {\n return GIF_INSUFFICIENT_FRAME_DATA;\n }\n if ((gif_data[1] == 0x0b) &&\n (strncmp((const char *) gif_data + 2,\n \"NETSCAPE2.0\", 11) == 0) &&\n (gif_data[13] == 0x03) &&\n (gif_data[14] == 0x01)) {\n gif->loop_count = gif_data[15] | (gif_data[16] << 8);\n }\n gif_data += (2 + gif_data[1]);\n break;\n\n case GIF_EXTENSION_COMMENT:\n \/* Move the pointer to the first data sub-block Skip 1\n * byte for the extension label\n *\/\n ++gif_data;\n break;\n\n default:\n \/* Move the pointer to the first data sub-block Skip 2\n * bytes for the extension label and size fields Skip\n * the extension size itself\n *\/\n if (gif_bytes < 2) {\n return GIF_INSUFFICIENT_FRAME_DATA;\n }\n gif_data += (2 + gif_data[1]);\n }\n\n \/* Repeatedly skip blocks until we get a zero block or run out\n * of data This data is ignored by this gif decoder\n *\/\n gif_bytes = (gif_end - gif_data);\n block_size = 0;\n while (gif_data < gif_end && gif_data[0] != GIF_BLOCK_TERMINATOR) {\n block_size = gif_data[0] + 1;\n if ((gif_bytes -= block_size) < 0) {\n return GIF_INSUFFICIENT_FRAME_DATA;\n }\n gif_data += block_size;\n }\n ++gif_data;\n }\n\n \/* Set buffer position and return *\/\n gif->buffer_position = (gif_data - gif->gif_data);\n return GIF_OK;\n}","target":0,"code_token_length":1049,"total_token_length":1285,"max_tokens_setting":2048} +{"idx":41184,"func":"do_string_sub(\n char_u\t*str,\n char_u\t*pat,\n char_u\t*sub,\n typval_T\t*expr,\n char_u\t*flags)\n{\n int\t\tsublen;\n regmatch_T\tregmatch;\n int\t\ti;\n int\t\tdo_all;\n char_u\t*tail;\n char_u\t*end;\n garray_T\tga;\n char_u\t*ret;\n char_u\t*save_cpo;\n char_u\t*zero_width = NULL;\n\n \/\/ Make 'cpoptions' empty, so that the 'l' flag doesn't work here\n save_cpo = p_cpo;\n p_cpo = empty_option;\n\n ga_init2(&ga, 1, 200);\n\n do_all = (flags[0] == 'g');\n\n regmatch.rm_ic = p_ic;\n regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);\n if (regmatch.regprog != NULL)\n {\n\ttail = str;\n\tend = str + STRLEN(str);\n\twhile (vim_regexec_nl(®match, str, (colnr_T)(tail - str)))\n\t{\n\t \/\/ Skip empty match except for first match.\n\t if (regmatch.startp[0] == regmatch.endp[0])\n\t {\n\t\tif (zero_width == regmatch.startp[0])\n\t\t{\n\t\t \/\/ avoid getting stuck on a match with an empty string\n\t\t i = mb_ptr2len(tail);\n\t\t mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail,\n\t\t\t\t\t\t\t\t (size_t)i);\n\t\t ga.ga_len += i;\n\t\t tail += i;\n\t\t continue;\n\t\t}\n\t\tzero_width = regmatch.startp[0];\n\t }\n\n\t \/*\n\t * Get some space for a temporary buffer to do the substitution\n\t * into. It will contain:\n\t * - The text up to where the match is.\n\t * - The substituted text.\n\t * - The text after the match.\n\t *\/\n\t sublen = vim_regsub(®match, sub, expr, tail, FALSE, TRUE, FALSE);\n\t if (ga_grow(&ga, (int)((end - tail) + sublen -\n\t\t\t (regmatch.endp[0] - regmatch.startp[0]))) == FAIL)\n\t {\n\t\tga_clear(&ga);\n\t\tbreak;\n\t }\n\n\t \/\/ copy the text up to where the match is\n\t i = (int)(regmatch.startp[0] - tail);\n\t mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i);\n\t \/\/ add the substituted text\n\t (void)vim_regsub(®match, sub, expr, (char_u *)ga.ga_data\n\t\t\t\t\t + ga.ga_len + i, TRUE, TRUE, FALSE);\n\t ga.ga_len += i + sublen - 1;\n\t tail = regmatch.endp[0];\n\t if (*tail == NUL)\n\t\tbreak;\n\t if (!do_all)\n\t\tbreak;\n\t}\n\n\tif (ga.ga_data != NULL)\n\t STRCPY((char *)ga.ga_data + ga.ga_len, tail);\n\n\tvim_regfree(regmatch.regprog);\n }\n\n ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data);\n ga_clear(&ga);\n if (p_cpo == empty_option)\n\tp_cpo = save_cpo;\n else\n {\n\t\/\/ Darn, evaluating {sub} expression or {expr} changed the value.\n\t\/\/ If it's still empty it was changed and restored, need to restore in\n\t\/\/ the complicated way.\n\tif (*p_cpo == NUL)\n\t set_option_value((char_u *)\"cpo\", 0L, save_cpo, 0);\n\tfree_string_option(save_cpo);\n }\n\n return ret;\n}","target":0,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048} +{"idx":334695,"func":"static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)\n\n{\n\n BDRVDMGState *s = bs->opaque;\n\n\n\n if (!is_sector_in_chunk(s, s->current_chunk, sector_num)) {\n\n int ret;\n\n uint32_t chunk = search_chunk(s, sector_num);\n\n#ifdef CONFIG_BZIP2\n\n uint64_t total_out;\n\n#endif\n\n\n\n if (chunk >= s->n_chunks) {\n\n return -1;\n\n }\n\n\n\n s->current_chunk = s->n_chunks;\n\n switch (s->types[chunk]) { \/* block entry type *\/\n\n case 0x80000005: { \/* zlib compressed *\/\n\n \/* we need to buffer, because only the chunk as whole can be\n\n * inflated. *\/\n\n ret = bdrv_pread(bs->file, s->offsets[chunk],\n\n s->compressed_chunk, s->lengths[chunk]);\n\n if (ret != s->lengths[chunk]) {\n\n return -1;\n\n }\n\n\n\n s->zstream.next_in = s->compressed_chunk;\n\n s->zstream.avail_in = s->lengths[chunk];\n\n s->zstream.next_out = s->uncompressed_chunk;\n\n s->zstream.avail_out = 512 * s->sectorcounts[chunk];\n\n ret = inflateReset(&s->zstream);\n\n if (ret != Z_OK) {\n\n return -1;\n\n }\n\n ret = inflate(&s->zstream, Z_FINISH);\n\n if (ret != Z_STREAM_END ||\n\n s->zstream.total_out != 512 * s->sectorcounts[chunk]) {\n\n return -1;\n\n }\n\n break; }\n\n#ifdef CONFIG_BZIP2\n\n case 0x80000006: \/* bzip2 compressed *\/\n\n \/* we need to buffer, because only the chunk as whole can be\n\n * inflated. *\/\n\n ret = bdrv_pread(bs->file, s->offsets[chunk],\n\n s->compressed_chunk, s->lengths[chunk]);\n\n if (ret != s->lengths[chunk]) {\n\n return -1;\n\n }\n\n\n\n ret = BZ2_bzDecompressInit(&s->bzstream, 0, 0);\n\n if (ret != BZ_OK) {\n\n return -1;\n\n }\n\n s->bzstream.next_in = (char *)s->compressed_chunk;\n\n s->bzstream.avail_in = (unsigned int) s->lengths[chunk];\n\n s->bzstream.next_out = (char *)s->uncompressed_chunk;\n\n s->bzstream.avail_out = (unsigned int) 512 * s->sectorcounts[chunk];\n\n ret = BZ2_bzDecompress(&s->bzstream);\n\n total_out = ((uint64_t)s->bzstream.total_out_hi32 << 32) +\n\n s->bzstream.total_out_lo32;\n\n BZ2_bzDecompressEnd(&s->bzstream);\n\n if (ret != BZ_STREAM_END ||\n\n total_out != 512 * s->sectorcounts[chunk]) {\n\n return -1;\n\n }\n\n break;\n\n#endif \/* CONFIG_BZIP2 *\/\n\n case 1: \/* copy *\/\n\n ret = bdrv_pread(bs->file, s->offsets[chunk],\n\n s->uncompressed_chunk, s->lengths[chunk]);\n\n if (ret != s->lengths[chunk]) {\n\n return -1;\n\n }\n\n break;\n\n case 2: \/* zero *\/\n\n memset(s->uncompressed_chunk, 0, 512 * s->sectorcounts[chunk]);\n\n break;\n\n }\n\n s->current_chunk = chunk;\n\n }\n\n return 0;\n\n}\n","target":0,"code_token_length":811,"total_token_length":1047,"max_tokens_setting":2048} +{"idx":239390,"func":"int ssl3_send_client_verify(SSL *s)\n\t{\n\tunsigned char *p,*d;\n\tunsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];\n\tEVP_PKEY *pkey;\n\tEVP_PKEY_CTX *pctx=NULL;\n\tEVP_MD_CTX mctx;\n\tunsigned u=0;\n\tunsigned long n;\n\tint j;\n\n\tEVP_MD_CTX_init(&mctx);\n\n\tif (s->state == SSL3_ST_CW_CERT_VRFY_A)\n\t\t{\n\t\td=(unsigned char *)s->init_buf->data;\n\t\tp= &(d[4]);\n\t\tpkey=s->cert->key->privatekey;\n\/* Create context from key and test if sha1 is allowed as digest *\/\n\t\tpctx = EVP_PKEY_CTX_new(pkey,NULL);\n\t\tEVP_PKEY_sign_init(pctx);\n\t\tif (EVP_PKEY_CTX_set_signature_md(pctx, EVP_sha1())>0)\n\t\t\t{\n\t\t\tif (TLS1_get_version(s) < TLS1_2_VERSION)\n\t\t\t\ts->method->ssl3_enc->cert_verify_mac(s,\n\t\t\t\t\t\tNID_sha1,\n\t\t\t\t\t\t&(data[MD5_DIGEST_LENGTH]));\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tERR_clear_error();\n\t\t\t}\n\t\t\/* For TLS v1.2 send signature algorithm and signature\n\t\t * using agreed digest and cached handshake records.\n\t\t *\/\n\t\tif (TLS1_get_version(s) >= TLS1_2_VERSION)\n\t\t\t{\n\t\t\tlong hdatalen = 0;\n\t\t\tvoid *hdata;\n\t\t\tconst EVP_MD *md = s->cert->key->digest;\n\t\t\thdatalen = BIO_get_mem_data(s->s3->handshake_buffer,\n\t\t\t\t\t\t\t\t&hdata);\n\t\t\tif (hdatalen <= 0 || !tls12_get_sigandhash(p, pkey, md))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,\n\t\t\t\t\t\tERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tp += 2;\n#ifdef SSL_DEBUG\n\t\t\tfprintf(stderr, \"Using TLS 1.2 with client alg %s\\n\",\n\t\t\t\t\t\t\tEVP_MD_name(md));\n#endif\n\t\t\tif (!EVP_SignInit_ex(&mctx, md, NULL)\n\t\t\t\t|| !EVP_SignUpdate(&mctx, hdata, hdatalen)\n\t\t\t\t|| !EVP_SignFinal(&mctx, p + 2, &u, pkey))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,\n\t\t\t\t\t\tERR_R_EVP_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\ts2n(u,p);\n\t\t\tn = u + 4;\n\t\t\tif (!ssl3_digest_cached_records(s))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\telse\n#ifndef OPENSSL_NO_RSA\n\t\tif (pkey->type == EVP_PKEY_RSA)\n\t\t\t{\n\t\t\ts->method->ssl3_enc->cert_verify_mac(s,\n\t\t\t\tNID_md5,\n\t\t\t \t&(data[0]));\n\t\t\tif (RSA_sign(NID_md5_sha1, data,\n\t\t\t\t\t MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,\n\t\t\t\t\t&(p[2]), &u, pkey->pkey.rsa) <= 0 )\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\ts2n(u,p);\n\t\t\tn=u+2;\n\t\t\t}\n\t\telse\n#endif\n#ifndef OPENSSL_NO_DSA\n\t\t\tif (pkey->type == EVP_PKEY_DSA)\n\t\t\t{\n\t\t\tif (!DSA_sign(pkey->save_type,\n\t\t\t\t&(data[MD5_DIGEST_LENGTH]),\n\t\t\t\tSHA_DIGEST_LENGTH,&(p[2]),\n\t\t\t\t(unsigned int *)&j,pkey->pkey.dsa))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_DSA_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\ts2n(j,p);\n\t\t\tn=j+2;\n\t\t\t}\n\t\telse\n#endif\n#ifndef OPENSSL_NO_ECDSA\n\t\t\tif (pkey->type == EVP_PKEY_EC)\n\t\t\t{\n\t\t\tif (!ECDSA_sign(pkey->save_type,\n\t\t\t\t&(data[MD5_DIGEST_LENGTH]),\n\t\t\t\tSHA_DIGEST_LENGTH,&(p[2]),\n\t\t\t\t(unsigned int *)&j,pkey->pkey.ec))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,\n\t\t\t\t ERR_R_ECDSA_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\ts2n(j,p);\n\t\t\tn=j+2;\n\t\t\t}\n\t\telse\n#endif\n\t\tif (pkey->type == NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) \n\t\t{\n\t\tunsigned char signbuf[64];\n\t\tint i;\n\t\tsize_t sigsize=64;\n\t\ts->method->ssl3_enc->cert_verify_mac(s,\n\t\t\tNID_id_GostR3411_94,\n\t\t\tdata);\n\t\tif (EVP_PKEY_sign(pctx, signbuf, &sigsize, data, 32) <= 0) {\n\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,\n\t\t\tERR_R_INTERNAL_ERROR);\n\t\t\tgoto err;\n\t\t}\n\t\tfor (i=63,j=0; i>=0; j++, i--) {\n\t\t\tp[2+j]=signbuf[i];\n\t\t}\t\n\t\ts2n(j,p);\n\t\tn=j+2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_INTERNAL_ERROR);\n\t\t\tgoto err;\n\t\t}\n\t\t*(d++)=SSL3_MT_CERTIFICATE_VERIFY;\n\t\tl2n3(n,d);\n\n\t\ts->state=SSL3_ST_CW_CERT_VRFY_B;\n\t\ts->init_num=(int)n+4;\n\t\ts->init_off=0;\n\t\t}\n\tEVP_MD_CTX_cleanup(&mctx);\n\tEVP_PKEY_CTX_free(pctx);\n\treturn(ssl3_do_write(s,SSL3_RT_HANDSHAKE));\nerr:\n\tEVP_MD_CTX_cleanup(&mctx);\n\tEVP_PKEY_CTX_free(pctx);\n\treturn(-1);\n\t}\n","target":0,"code_token_length":1313,"total_token_length":1549,"max_tokens_setting":2048} +{"idx":425297,"func":"static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,\n\t\t\t struct scatterlist *sg, unsigned long phys_pfn,\n\t\t\t unsigned long nr_pages, int prot)\n{\n\tstruct dma_pte *first_pte = NULL, *pte = NULL;\n\tphys_addr_t uninitialized_var(pteval);\n\tunsigned long sg_res = 0;\n\tunsigned int largepage_lvl = 0;\n\tunsigned long lvl_pages = 0;\n\n\tBUG_ON(!domain_pfn_supported(domain, iov_pfn + nr_pages - 1));\n\n\tif ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)\n\t\treturn -EINVAL;\n\n\tprot &= DMA_PTE_READ | DMA_PTE_WRITE | DMA_PTE_SNP;\n\n\tif (!sg) {\n\t\tsg_res = nr_pages;\n\t\tpteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot;\n\t}\n\n\twhile (nr_pages > 0) {\n\t\tuint64_t tmp;\n\n\t\tif (!sg_res) {\n\t\t\tunsigned int pgoff = sg->offset & ~PAGE_MASK;\n\n\t\t\tsg_res = aligned_nrpages(sg->offset, sg->length);\n\t\t\tsg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + pgoff;\n\t\t\tsg->dma_length = sg->length;\n\t\t\tpteval = (sg_phys(sg) - pgoff) | prot;\n\t\t\tphys_pfn = pteval >> VTD_PAGE_SHIFT;\n\t\t}\n\n\t\tif (!pte) {\n\t\t\tlargepage_lvl = hardware_largepage_caps(domain, iov_pfn, phys_pfn, sg_res);\n\n\t\t\tfirst_pte = pte = pfn_to_dma_pte(domain, iov_pfn, &largepage_lvl);\n\t\t\tif (!pte)\n\t\t\t\treturn -ENOMEM;\n\t\t\t\/* It is large page*\/\n\t\t\tif (largepage_lvl > 1) {\n\t\t\t\tunsigned long nr_superpages, end_pfn;\n\n\t\t\t\tpteval |= DMA_PTE_LARGE_PAGE;\n\t\t\t\tlvl_pages = lvl_to_nr_pages(largepage_lvl);\n\n\t\t\t\tnr_superpages = sg_res \/ lvl_pages;\n\t\t\t\tend_pfn = iov_pfn + nr_superpages * lvl_pages - 1;\n\n\t\t\t\t\/*\n\t\t\t\t * Ensure that old small page tables are\n\t\t\t\t * removed to make room for superpage(s).\n\t\t\t\t * We're adding new large pages, so make sure\n\t\t\t\t * we don't remove their parent tables.\n\t\t\t\t *\/\n\t\t\t\tdma_pte_free_pagetable(domain, iov_pfn, end_pfn,\n\t\t\t\t\t\t largepage_lvl + 1);\n\t\t\t} else {\n\t\t\t\tpteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE;\n\t\t\t}\n\n\t\t}\n\t\t\/* We don't need lock here, nobody else\n\t\t * touches the iova range\n\t\t *\/\n\t\ttmp = cmpxchg64_local(&pte->val, 0ULL, pteval);\n\t\tif (tmp) {\n\t\t\tstatic int dumps = 5;\n\t\t\tpr_crit(\"ERROR: DMA PTE for vPFN 0x%lx already set (to %llx not %llx)\\n\",\n\t\t\t\tiov_pfn, tmp, (unsigned long long)pteval);\n\t\t\tif (dumps) {\n\t\t\t\tdumps--;\n\t\t\t\tdebug_dma_dump_mappings(NULL);\n\t\t\t}\n\t\t\tWARN_ON(1);\n\t\t}\n\n\t\tlvl_pages = lvl_to_nr_pages(largepage_lvl);\n\n\t\tBUG_ON(nr_pages < lvl_pages);\n\t\tBUG_ON(sg_res < lvl_pages);\n\n\t\tnr_pages -= lvl_pages;\n\t\tiov_pfn += lvl_pages;\n\t\tphys_pfn += lvl_pages;\n\t\tpteval += lvl_pages * VTD_PAGE_SIZE;\n\t\tsg_res -= lvl_pages;\n\n\t\t\/* If the next PTE would be the first in a new page, then we\n\t\t need to flush the cache on the entries we've just written.\n\t\t And then we'll need to recalculate 'pte', so clear it and\n\t\t let it get set again in the if (!pte) block above.\n\n\t\t If we're done (!nr_pages) we need to flush the cache too.\n\n\t\t Also if we've been setting superpages, we may need to\n\t\t recalculate 'pte' and switch back to smaller pages for the\n\t\t end of the mapping, if the trailing size is not enough to\n\t\t use another superpage (i.e. sg_res < lvl_pages). *\/\n\t\tpte++;\n\t\tif (!nr_pages || first_pte_in_page(pte) ||\n\t\t (largepage_lvl > 1 && sg_res < lvl_pages)) {\n\t\t\tdomain_flush_cache(domain, first_pte,\n\t\t\t\t\t (void *)pte - (void *)first_pte);\n\t\t\tpte = NULL;\n\t\t}\n\n\t\tif (!sg_res && nr_pages)\n\t\t\tsg = sg_next(sg);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":1020,"total_token_length":1256,"max_tokens_setting":2048} +{"idx":470923,"func":"gs_lib_ctx_stash_sanitized_arg(gs_lib_ctx_t *ctx, const char *arg)\n{\n gs_lib_ctx_core_t *core;\n size_t len;\n const char *p;\n int elide = 0;\n\n if (ctx == NULL || ctx->core == NULL || arg == NULL)\n return 0;\n\n \/* Sanitize arg *\/\n switch(*arg)\n {\n case '-':\n switch (arg[1])\n {\n case 0: \/* We can let - through unchanged *\/\n case '-': \/* Need to check for permitted file lists *\/\n \/* By default, we want to keep the key, but lose the value *\/\n p = arg+2;\n while (*p && *p != '=')\n p++;\n if (*p == '=')\n p++;\n if (*p == 0)\n break; \/* No value to elide *\/\n \/* Check for our blocked values here *\/\n#define ARG_MATCHES(STR, ARG, LEN) \\\n (strlen(STR) == LEN && !memcmp(STR, ARG, LEN))\n if (ARG_MATCHES(\"permit-file-read\", arg+2, p-arg-3))\n elide=1;\n if (ARG_MATCHES(\"permit-file-write\", arg+2, p-arg-3))\n elide=1;\n if (ARG_MATCHES(\"permit-file-control\", arg+2, p-arg-3))\n elide=1;\n if (ARG_MATCHES(\"permit-file-all\", arg+2, p-arg-3))\n elide=1;\n#undef ARG_MATCHES\n \/* Didn't match a blocked value, so allow it. *\/\n break;\n case 'd': \/* We can let -dFoo= through unchanged *\/\n case 'D': \/* We can let -DFoo= through unchanged *\/\n case 'r': \/* We can let -r through unchanged *\/\n case 'Z': \/* We can let -Z through unchanged *\/\n case 'g': \/* We can let -g through unchanged *\/\n case 'P': \/* We can let -P through unchanged *\/\n case '+': \/* We can let -+ through unchanged *\/\n case '_': \/* We can let -_ through unchanged *\/\n case 'u': \/* We can let -u through unchanged *\/\n case 'q': \/* We can let -q through unchanged *\/\n break;\n case 'I': \/* Let through the I, but hide anything else *\/\n case 'f': \/* Let through the I, but hide anything else *\/\n if (arg[2] == 0)\n break;\n p = arg+2;\n while (*p == 32)\n p++;\n elide = 1;\n break;\n case 's':\n case 'S':\n \/* By default, we want to keep the key, but lose the value *\/\n p = arg+2;\n while (*p && *p != '=')\n p++;\n if (*p == '=')\n p++;\n if (*p == 0)\n break; \/* No value to elide *\/\n \/* Check for our whitelisted values here *\/\n#define ARG_MATCHES(STR, ARG, LEN) \\\n (strlen(STR) == LEN && !memcmp(STR, ARG, LEN))\n if (ARG_MATCHES(\"DEFAULTPAPERSIZE\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"DEVICE\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"PAPERSIZE\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"SUBSTFONT\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"ColorConversionStrategy\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"NupControl\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"PageList\", arg+2, p-arg-3))\n break;\n if (ARG_MATCHES(\"ProcessColorModel\", arg+2, p-arg-3))\n break;\n#undef ARG_MATCHES\n \/* Didn't match a whitelisted value, so elide it. *\/\n elide = 1;\n break;\n default:\n \/* Shouldn't happen, but elide it just in case *\/\n arg = \"?\";\n break;\n }\n break;\n case '@':\n \/* Shouldn't happen *\/\n default:\n \/* Anything else should be elided *\/\n arg = \"?\";\n break;\n }\n\n core = ctx->core;\n if (elide)\n len = p-arg;\n else\n len = strlen(arg);\n\n if (core->arg_max == core->argc) {\n char **argv;\n int newlen = core->arg_max * 2;\n if (newlen == 0)\n newlen = 4;\n argv = (char **)gs_alloc_bytes(ctx->core->memory, sizeof(char *) * newlen,\n \"gs_lib_ctx_args\");\n if (argv == NULL)\n return gs_error_VMerror;\n if (core->argc > 0) {\n memcpy(argv, core->argv, sizeof(char *) * core->argc);\n gs_free_object(ctx->memory, core->argv, \"gs_lib_ctx_args\");\n }\n core->argv = argv;\n core->arg_max = newlen;\n }\n\n core->argv[core->argc] = (char *)gs_alloc_bytes(ctx->core->memory, len+1+elide,\n \"gs_lib_ctx_arg\");\n if (core->argv[core->argc] == NULL)\n return gs_error_VMerror;\n memcpy(core->argv[core->argc], arg, len);\n if (elide) {\n core->argv[core->argc][len] = '?';\n }\n core->argv[core->argc][len+elide] = 0;\n core->argc++;\n\n return 0;\n}","target":0,"code_token_length":1293,"total_token_length":1529,"max_tokens_setting":2048} +{"idx":338746,"func":"static void pmac_dma_write(BlockBackend *blk,\n\n int64_t sector_num, int nb_sectors,\n\n void (*cb)(void *opaque, int ret), void *opaque)\n\n{\n\n DBDMA_io *io = opaque;\n\n MACIOIDEState *m = io->opaque;\n\n IDEState *s = idebus_active_if(&m->bus);\n\n dma_addr_t dma_addr, dma_len;\n\n void *mem;\n\n int nsector, remainder;\n\n int extra = 0;\n\n\n\n qemu_iovec_destroy(&io->iov);\n\n qemu_iovec_init(&io->iov, io->len \/ MACIO_PAGE_SIZE + 1);\n\n\n\n if (io->remainder_len > 0) {\n\n \/* Return remainder of request *\/\n\n int transfer = MIN(io->remainder_len, io->len);\n\n\n\n MACIO_DPRINTF(\"--- processing write remainder %x\\n\", transfer);\n\n cpu_physical_memory_read(io->addr,\n\n &io->remainder + (0x200 - transfer),\n\n transfer);\n\n\n\n io->remainder_len -= transfer;\n\n io->len -= transfer;\n\n io->addr += transfer;\n\n\n\n s->io_buffer_index += transfer;\n\n s->io_buffer_size -= transfer;\n\n\n\n if (io->remainder_len != 0) {\n\n \/* Still waiting for remainder *\/\n\n return;\n\n }\n\n\n\n MACIO_DPRINTF(\"--> prepending bounce buffer with size 0x200\\n\");\n\n\n\n \/* Sector transfer complete - prepend to request *\/\n\n qemu_iovec_add(&io->iov, &io->remainder, 0x200);\n\n extra = 1;\n\n }\n\n\n\n if (s->drive_kind == IDE_CD) {\n\n sector_num = (int64_t)(s->lba << 2) + (s->io_buffer_index >> 9);\n\n } else {\n\n sector_num = ide_get_sector(s) + (s->io_buffer_index >> 9);\n\n }\n\n\n\n nsector = (io->len >> 9);\n\n remainder = io->len - (nsector << 9);\n\n\n\n MACIO_DPRINTF(\"--- DMA write transfer - addr: %\" HWADDR_PRIx \" len: %x\\n\",\n\n io->addr, io->len);\n\n MACIO_DPRINTF(\"xxx remainder: %x\\n\", remainder);\n\n MACIO_DPRINTF(\"xxx sector_num: %\"PRIx64\" nsector: %x\\n\",\n\n sector_num, nsector);\n\n\n\n dma_addr = io->addr;\n\n dma_len = io->len;\n\n mem = dma_memory_map(&address_space_memory, dma_addr, &dma_len,\n\n DMA_DIRECTION_TO_DEVICE);\n\n\n\n if (!remainder) {\n\n MACIO_DPRINTF(\"--- DMA write aligned - addr: %\" HWADDR_PRIx\n\n \" len: %x\\n\", io->addr, io->len);\n\n qemu_iovec_add(&io->iov, mem, io->len);\n\n } else {\n\n \/* Write up to last complete sector *\/\n\n MACIO_DPRINTF(\"--- DMA write unaligned - addr: %\" HWADDR_PRIx\n\n \" len: %x\\n\", io->addr, (nsector << 9));\n\n qemu_iovec_add(&io->iov, mem, (nsector << 9));\n\n\n\n MACIO_DPRINTF(\"--- DMA write read - bounce addr: %p \"\n\n \"remainder_len: %x\\n\", &io->remainder, remainder);\n\n cpu_physical_memory_read(io->addr + (nsector << 9), &io->remainder,\n\n remainder);\n\n\n\n io->remainder_len = 0x200 - remainder;\n\n\n\n MACIO_DPRINTF(\"xxx remainder_len: %x\\n\", io->remainder_len);\n\n }\n\n\n\n s->io_buffer_size -= ((nsector + extra) << 9);\n\n s->io_buffer_index += ((nsector + extra) << 9);\n\n\n\n io->len = 0;\n\n\n\n MACIO_DPRINTF(\"--- Block write transfer - sector_num: %\"PRIx64\" \"\n\n \"nsector: %x\\n\", sector_num, nsector + extra);\n\n\n\n m->aiocb = blk_aio_writev(blk, sector_num, &io->iov, nsector + extra, cb,\n\n io);\n\n}\n","target":1,"code_token_length":886,"total_token_length":1122,"max_tokens_setting":2048} +{"idx":446171,"func":"virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,\n unsigned int flags)\n{\n char *p;\n virSecurityLabelDefPtr seclabel = NULL;\n\n p = virXMLPropStringLimit(ctxt->node, \"model\",\n VIR_SECURITY_MODEL_BUFLEN - 1);\n\n if (!(seclabel = virSecurityLabelDefNew(p)))\n goto error;\n VIR_FREE(p);\n\n \/* set default value *\/\n seclabel->type = VIR_DOMAIN_SECLABEL_DYNAMIC;\n\n p = virXMLPropStringLimit(ctxt->node, \"type\",\n VIR_SECURITY_LABEL_BUFLEN - 1);\n if (p) {\n seclabel->type = virDomainSeclabelTypeFromString(p);\n if (seclabel->type <= 0) {\n virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n _(\"invalid security type '%s'\"), p);\n goto error;\n }\n }\n\n if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||\n seclabel->type == VIR_DOMAIN_SECLABEL_NONE)\n seclabel->relabel = false;\n\n VIR_FREE(p);\n p = virXMLPropStringLimit(ctxt->node, \"relabel\",\n VIR_SECURITY_LABEL_BUFLEN-1);\n if (p) {\n if (virStringParseYesNo(p, &seclabel->relabel) < 0) {\n virReportError(VIR_ERR_XML_ERROR,\n _(\"invalid security relabel value %s\"), p);\n goto error;\n }\n }\n VIR_FREE(p);\n\n if (seclabel->type == VIR_DOMAIN_SECLABEL_DYNAMIC &&\n !seclabel->relabel) {\n virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n \"%s\", _(\"dynamic label type must use resource relabeling\"));\n goto error;\n }\n if (seclabel->type == VIR_DOMAIN_SECLABEL_NONE &&\n seclabel->relabel) {\n virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n \"%s\", _(\"resource relabeling is not compatible with 'none' label type\"));\n goto error;\n }\n\n \/* For the model 'none' none of the following labels is going to be\n * present. Hence, return now. *\/\n\n if (STREQ_NULLABLE(seclabel->model, \"none\")) {\n if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {\n \/* Fix older configurations *\/\n seclabel->type = VIR_DOMAIN_SECLABEL_NONE;\n seclabel->relabel = false;\n } else {\n if (seclabel->type != VIR_DOMAIN_SECLABEL_NONE) {\n virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n _(\"unsupported type='%s' to model 'none'\"),\n virDomainSeclabelTypeToString(seclabel->type));\n goto error;\n }\n \/* combination of relabel='yes' and type='static'\n * is checked a few lines above. *\/\n }\n return seclabel;\n }\n\n \/* Only parse label, if using static labels, or\n * if the 'live' VM XML is requested\n *\/\n if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||\n (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&\n seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {\n p = virXPathStringLimit(\"string(.\/label[1])\",\n VIR_SECURITY_LABEL_BUFLEN-1, ctxt);\n if (p == NULL) {\n virReportError(VIR_ERR_XML_ERROR,\n \"%s\", _(\"security label is missing\"));\n goto error;\n }\n\n seclabel->label = g_steal_pointer(&p);\n }\n\n \/* Only parse imagelabel, if requested live XML with relabeling *\/\n if (seclabel->relabel &&\n (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&\n seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {\n p = virXPathStringLimit(\"string(.\/imagelabel[1])\",\n VIR_SECURITY_LABEL_BUFLEN-1, ctxt);\n if (p == NULL) {\n virReportError(VIR_ERR_XML_ERROR,\n \"%s\", _(\"security imagelabel is missing\"));\n goto error;\n }\n seclabel->imagelabel = g_steal_pointer(&p);\n }\n\n \/* Only parse baselabel for dynamic label type *\/\n if (seclabel->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {\n p = virXPathStringLimit(\"string(.\/baselabel[1])\",\n VIR_SECURITY_LABEL_BUFLEN-1, ctxt);\n seclabel->baselabel = g_steal_pointer(&p);\n }\n\n return seclabel;\n\n error:\n VIR_FREE(p);\n virSecurityLabelDefFree(seclabel);\n return NULL;\n}","target":0,"code_token_length":1020,"total_token_length":1256,"max_tokens_setting":2048} +{"idx":364059,"func":"uschar *dkim_exim_expand_query(int what) {\n\n if (!dkim_verify_ctx ||\n dkim_disable_verify ||\n !dkim_cur_sig) return dkim_exim_expand_defaults(what);\n\n switch(what) {\n case DKIM_ALGO:\n switch(dkim_cur_sig->algo) {\n case PDKIM_ALGO_RSA_SHA1:\n return US\"rsa-sha1\";\n case PDKIM_ALGO_RSA_SHA256:\n default:\n return US\"rsa-sha256\";\n }\n case DKIM_BODYLENGTH:\n return (dkim_cur_sig->bodylength >= 0)?\n (uschar *)string_sprintf(OFF_T_FMT,(LONGLONG_T)dkim_cur_sig->bodylength)\n :dkim_exim_expand_defaults(what);\n case DKIM_CANON_BODY:\n switch(dkim_cur_sig->canon_body) {\n case PDKIM_CANON_RELAXED:\n return US\"relaxed\";\n case PDKIM_CANON_SIMPLE:\n default:\n return US\"simple\";\n }\n case DKIM_CANON_HEADERS:\n switch(dkim_cur_sig->canon_headers) {\n case PDKIM_CANON_RELAXED:\n return US\"relaxed\";\n case PDKIM_CANON_SIMPLE:\n default:\n return US\"simple\";\n }\n case DKIM_COPIEDHEADERS:\n return dkim_cur_sig->copiedheaders?\n (uschar *)(dkim_cur_sig->copiedheaders)\n :dkim_exim_expand_defaults(what);\n case DKIM_CREATED:\n return (dkim_cur_sig->created > 0)?\n (uschar *)string_sprintf(\"%llu\",dkim_cur_sig->created)\n :dkim_exim_expand_defaults(what);\n case DKIM_EXPIRES:\n return (dkim_cur_sig->expires > 0)?\n (uschar *)string_sprintf(\"%llu\",dkim_cur_sig->expires)\n :dkim_exim_expand_defaults(what);\n case DKIM_HEADERNAMES:\n return dkim_cur_sig->headernames?\n (uschar *)(dkim_cur_sig->headernames)\n :dkim_exim_expand_defaults(what);\n case DKIM_IDENTITY:\n return dkim_cur_sig->identity?\n (uschar *)(dkim_cur_sig->identity)\n :dkim_exim_expand_defaults(what);\n case DKIM_KEY_GRANULARITY:\n return dkim_cur_sig->pubkey?\n (dkim_cur_sig->pubkey->granularity?\n (uschar *)(dkim_cur_sig->pubkey->granularity)\n :dkim_exim_expand_defaults(what)\n )\n :dkim_exim_expand_defaults(what);\n case DKIM_KEY_SRVTYPE:\n return dkim_cur_sig->pubkey?\n (dkim_cur_sig->pubkey->srvtype?\n (uschar *)(dkim_cur_sig->pubkey->srvtype)\n :dkim_exim_expand_defaults(what)\n )\n :dkim_exim_expand_defaults(what);\n case DKIM_KEY_NOTES:\n return dkim_cur_sig->pubkey?\n (dkim_cur_sig->pubkey->notes?\n (uschar *)(dkim_cur_sig->pubkey->notes)\n :dkim_exim_expand_defaults(what)\n )\n :dkim_exim_expand_defaults(what);\n case DKIM_KEY_TESTING:\n return dkim_cur_sig->pubkey?\n (dkim_cur_sig->pubkey->testing?\n US\"1\"\n :dkim_exim_expand_defaults(what)\n )\n :dkim_exim_expand_defaults(what);\n case DKIM_NOSUBDOMAINS:\n return dkim_cur_sig->pubkey?\n (dkim_cur_sig->pubkey->no_subdomaining?\n US\"1\"\n :dkim_exim_expand_defaults(what)\n )\n :dkim_exim_expand_defaults(what);\n case DKIM_VERIFY_STATUS:\n switch(dkim_cur_sig->verify_status) {\n case PDKIM_VERIFY_INVALID:\n return US\"invalid\";\n case PDKIM_VERIFY_FAIL:\n return US\"fail\";\n case PDKIM_VERIFY_PASS:\n return US\"pass\";\n case PDKIM_VERIFY_NONE:\n default:\n return US\"none\";\n }\n case DKIM_VERIFY_REASON:\n switch (dkim_cur_sig->verify_ext_status) {\n case PDKIM_VERIFY_INVALID_PUBKEY_UNAVAILABLE:\n return US\"pubkey_unavailable\";\n case PDKIM_VERIFY_INVALID_PUBKEY_PARSING:\n return US\"pubkey_syntax\";\n case PDKIM_VERIFY_FAIL_BODY:\n return US\"bodyhash_mismatch\";\n case PDKIM_VERIFY_FAIL_MESSAGE:\n return US\"signature_incorrect\";\n }\n default:\n return US\"\";\n }\n}","target":0,"code_token_length":1042,"total_token_length":1278,"max_tokens_setting":2048} +{"idx":461584,"func":"static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags)\n{\n rpm_count_t count = entry->info.count;\n int rc = 1;\t\t\/* XXX 1 on success. *\/\n \/* ALLOC overrides MINMEM *\/\n int allocMem = flags & HEADERGET_ALLOC;\n int minMem = allocMem ? 0 : flags & HEADERGET_MINMEM;\n int argvArray = (flags & HEADERGET_ARGV) ? 1 : 0;\n\n assert(td != NULL);\n td->flags = RPMTD_IMMUTABLE;\n switch (entry->info.type) {\n case RPM_BIN_TYPE:\n\t\/*\n\t * XXX This only works for\n\t * XXX \t\"sealed\" HEADER_IMMUTABLE\/HEADER_SIGNATURES\/HEADER_IMAGE.\n\t * XXX This will *not* work for unsealed legacy HEADER_IMAGE (i.e.\n\t * XXX a legacy header freshly read, but not yet unloaded to the rpmdb).\n\t *\/\n\tif (ENTRY_IS_REGION(entry)) {\n\t int32_t * ei = ((int32_t *)entry->data) - 2;\n\t entryInfo pe = (entryInfo) (ei + 2);\n\t unsigned char * dataStart = (unsigned char *) (pe + ntohl(ei[0]));\n\t int32_t rdl = -entry->info.offset;\t\/* negative offset *\/\n\t int32_t ril = rdl\/sizeof(*pe);\n\n\t rdl = entry->rdlen;\n\t count = 2 * sizeof(*ei) + (ril * sizeof(*pe)) + rdl;\n\t if (entry->info.tag == RPMTAG_HEADERIMAGE) {\n\t\tril -= 1;\n\t\tpe += 1;\n\t } else {\n\t\tcount += REGION_TAG_COUNT;\n\t\trdl += REGION_TAG_COUNT;\n\t }\n\n\t td->data = xmalloc(count);\n\t ei = (int32_t *) td->data;\n\t ei[0] = htonl(ril);\n\t ei[1] = htonl(rdl);\n\n\t pe = (entryInfo) memcpy(ei + 2, pe, (ril * sizeof(*pe)));\n\n\t dataStart = (unsigned char *) memcpy(pe + ril, dataStart, rdl);\n\n\t rc = regionSwab(NULL, ril, 0, pe, dataStart, dataStart + rdl, 0, 0);\n\t \/* don't return data on failure *\/\n\t if (rc < 0) {\n\t\ttd->data = _free(td->data);\n\t }\n\t \/* XXX 1 on success. *\/\n\t rc = (rc < 0) ? 0 : 1;\n\t} else {\n\t td->data = (!minMem\n\t\t? memcpy(xmalloc(count), entry->data, count)\n\t\t: entry->data);\n\t}\n\tbreak;\n case RPM_STRING_TYPE:\n\t\/* simple string, but fallthrough if its actually an array *\/\n\tif (count == 1 && !argvArray) {\n\t td->data = allocMem ? xstrdup(entry->data) : entry->data;\n\t break;\n\t}\n case RPM_STRING_ARRAY_TYPE:\n case RPM_I18NSTRING_TYPE:\n {\tconst char ** ptrEntry;\n\tint tableSize = (count + argvArray) * sizeof(char *);\n\tchar * t;\n\tint i;\n\n\tif (minMem) {\n\t td->data = xmalloc(tableSize);\n\t ptrEntry = (const char **) td->data;\n\t t = entry->data;\n\t} else {\n\t t = xmalloc(tableSize + entry->length);\n\t td->data = (void *)t;\n\t ptrEntry = (const char **) td->data;\n\t t += tableSize;\n\t memcpy(t, entry->data, entry->length);\n\t}\n\tfor (i = 0; i < count; i++) {\n\t *ptrEntry++ = t;\n\t t = strchr(t, 0);\n\t t++;\n\t}\n\tif (argvArray) {\n\t *ptrEntry = NULL;\n\t td->flags |= RPMTD_ARGV;\n\t}\n }\tbreak;\n case RPM_CHAR_TYPE:\n case RPM_INT8_TYPE:\n case RPM_INT16_TYPE:\n case RPM_INT32_TYPE:\n case RPM_INT64_TYPE:\n\tif (allocMem) {\n\t td->data = xmalloc(entry->length);\n\t memcpy(td->data, entry->data, entry->length);\n\t} else {\n\t td->data = entry->data;\n\t}\n\tbreak;\n default:\n\t\/* WTH? Don't mess with unknown data types... *\/\n\trc = 0;\n\ttd->data = NULL;\n\tbreak;\n }\n td->type = entry->info.type;\n td->count = count;\n td->size = entry->length;\n\n if (td->data && entry->data != td->data) {\n\ttd->flags |= RPMTD_ALLOCED;\n }\n\n return rc;\n}","target":0,"code_token_length":1036,"total_token_length":1272,"max_tokens_setting":2048} +{"idx":346033,"func":"PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)\n{\n ImagingEncoderObject* encoder;\n\n char* mode;\n char* rawmode;\n char* compname;\n char* filename;\n int compression;\n int fp;\n\n PyObject *dir;\n PyObject *key, *value;\n Py_ssize_t pos = 0;\n int status;\n\n Py_ssize_t d_size;\n PyObject *keys, *values;\n\n\n if (! PyArg_ParseTuple(args, \"sssisO\", &mode, &rawmode, &compname, &fp, &filename, &dir)) {\n return NULL;\n }\n\n if (!PyDict_Check(dir)) {\n PyErr_SetString(PyExc_ValueError, \"Invalid Dictionary\");\n return NULL;\n } else {\n d_size = PyDict_Size(dir);\n TRACE((\"dict size: %d\\n\", (int)d_size));\n keys = PyDict_Keys(dir);\n values = PyDict_Values(dir);\n for (pos=0;posstate, filename, fp)) {\n Py_DECREF(encoder);\n PyErr_SetString(PyExc_RuntimeError, \"tiff codec initialization failed\");\n return NULL;\n }\n\n\t\/\/ While failes on 64 bit machines, complains that pos is an int instead of a Py_ssize_t\n\t\/\/ while (PyDict_Next(dir, &pos, &key, &value)) {\n\tfor (pos=0;posstate,\n (ttag_t) PyInt_AsLong(key),\n PyInt_AsLong(value));\n } else if(PyBytes_Check(value)) {\n TRACE((\"Setting from String: %d, %s \\n\", (int)PyInt_AsLong(key),PyBytes_AsString(value)));\n status = ImagingLibTiffSetField(&encoder->state,\n (ttag_t) PyInt_AsLong(key),\n PyBytes_AsString(value));\n\n } else if(PyList_Check(value)) {\n int len,i;\n float *floatav;\n TRACE((\"Setting from List: %d \\n\", (int)PyInt_AsLong(key)));\n len = (int)PyList_Size(value);\n TRACE((\" %d elements, setting as floats \\n\", len));\n floatav = malloc(sizeof(float)*len);\n if (floatav) {\n for (i=0;istate,\n (ttag_t) PyInt_AsLong(key),\n floatav);\n free(floatav);\n }\n } else if (PyFloat_Check(value)) {\n TRACE((\"Setting from String: %d, %f \\n\", (int)PyInt_AsLong(key),PyFloat_AsDouble(value)));\n status = ImagingLibTiffSetField(&encoder->state,\n (ttag_t) PyInt_AsLong(key),\n (float)PyFloat_AsDouble(value));\n } else {\n TRACE((\"Unhandled type for key %d : %s \",\n (int)PyInt_AsLong(key),\n PyBytes_AsString(PyObject_Str(value))));\n }\n if (!status) {\n TRACE((\"Error setting Field\\n\"));\n Py_DECREF(encoder);\n PyErr_SetString(PyExc_RuntimeError, \"Error setting from dictionary\");\n return NULL;\n }\n }\n\n encoder->encode = ImagingLibTiffEncode;\n\n return (PyObject*) encoder;\n}","target":1,"code_token_length":1150,"total_token_length":1386,"max_tokens_setting":2048} +{"idx":83798,"func":"static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVFrame *ref0, AVFrame *ref1,\n int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int cidx)\n{\n HEVCLocalContext *lc = s->HEVClc;\n uint8_t *src1 = ref0->data[cidx+1];\n uint8_t *src2 = ref1->data[cidx+1];\n ptrdiff_t src1stride = ref0->linesize[cidx+1];\n ptrdiff_t src2stride = ref1->linesize[cidx+1];\n int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||\n (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag);\n int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1];\n int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1];\n Mv *mv0 = ¤t_mv->mv[0];\n Mv *mv1 = ¤t_mv->mv[1];\n int hshift = s->ps.sps->hshift[1];\n int vshift = s->ps.sps->vshift[1];\n\n intptr_t mx0 = av_mod_uintp2(mv0->x, 2 + hshift);\n intptr_t my0 = av_mod_uintp2(mv0->y, 2 + vshift);\n intptr_t mx1 = av_mod_uintp2(mv1->x, 2 + hshift);\n intptr_t my1 = av_mod_uintp2(mv1->y, 2 + vshift);\n intptr_t _mx0 = mx0 << (1 - hshift);\n intptr_t _my0 = my0 << (1 - vshift);\n intptr_t _mx1 = mx1 << (1 - hshift);\n intptr_t _my1 = my1 << (1 - vshift);\n\n int x_off0 = x_off + (mv0->x >> (2 + hshift));\n int y_off0 = y_off + (mv0->y >> (2 + vshift));\n int x_off1 = x_off + (mv1->x >> (2 + hshift));\n int y_off1 = y_off + (mv1->y >> (2 + vshift));\n int idx = ff_hevc_pel_weight[block_w];\n src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift);\n src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift);\n\n if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER ||\n x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER ||\n y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) {\n const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;\n int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->ps.sps->pixel_shift));\n int buf_offset1 = EPEL_EXTRA_BEFORE *\n (edge_emu_stride + (1 << s->ps.sps->pixel_shift));\n\n s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1,\n edge_emu_stride, src1stride,\n block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,\n x_off0 - EPEL_EXTRA_BEFORE,\n y_off0 - EPEL_EXTRA_BEFORE,\n pic_width, pic_height);\n\n src1 = lc->edge_emu_buffer + buf_offset1;\n src1stride = edge_emu_stride;\n }\n\n if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER ||\n x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER ||\n y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) {\n const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;\n int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->ps.sps->pixel_shift));\n int buf_offset1 = EPEL_EXTRA_BEFORE *\n (edge_emu_stride + (1 << s->ps.sps->pixel_shift));\n\n s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1,\n edge_emu_stride, src2stride,\n block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,\n x_off1 - EPEL_EXTRA_BEFORE,\n y_off1 - EPEL_EXTRA_BEFORE,\n pic_width, pic_height);\n\n src2 = lc->edge_emu_buffer2 + buf_offset1;\n src2stride = edge_emu_stride;\n }\n\n s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->tmp, src1, src1stride,\n block_h, _mx0, _my0, block_w);\n if (!weight_flag)\n s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1],\n src2, src2stride, lc->tmp,\n block_h, _mx1, _my1, block_w);\n else\n s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0, s->frame->linesize[cidx+1],\n src2, src2stride, lc->tmp,\n block_h,\n s->sh.chroma_log2_weight_denom,\n s->sh.chroma_weight_l0[current_mv->ref_idx[0]][cidx],\n s->sh.chroma_weight_l1[current_mv->ref_idx[1]][cidx],\n s->sh.chroma_offset_l0[current_mv->ref_idx[0]][cidx],\n s->sh.chroma_offset_l1[current_mv->ref_idx[1]][cidx],\n _mx1, _my1, block_w);\n}","target":0,"code_token_length":1411,"total_token_length":1647,"max_tokens_setting":2048} +{"idx":166936,"func":"xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) {\n const xmlChar *in;\n int nbchar = 0;\n int line = ctxt->input->line;\n int col = ctxt->input->col;\n int ccol;\n\n SHRINK;\n GROW;\n \/*\n * Accelerated common case where input don't need to be\n * modified before passing it to the handler.\n *\/\n if (!cdata) {\n\tin = ctxt->input->cur;\n do {\nget_more_space:\n while (*in == 0x20) { in++; ctxt->input->col++; }\n if (*in == 0xA) {\n do {\n\t\t ctxt->input->line++; ctxt->input->col = 1;\n\t\t in++;\n } while (*in == 0xA);\n goto get_more_space;\n }\n if (*in == '<') {\n\t\tnbchar = in - ctxt->input->cur;\n if (nbchar > 0) {\n const xmlChar *tmp = ctxt->input->cur;\n\t\t ctxt->input->cur = in;\n\n if ((ctxt->sax != NULL) &&\n (ctxt->sax->ignorableWhitespace !=\n\t\t ctxt->sax->characters)) {\n if (areBlanks(ctxt, tmp, nbchar, 1)) {\n if (ctxt->sax->ignorableWhitespace != NULL)\n\t\t\t\tctxt->sax->ignorableWhitespace(ctxt->userData,\n\t\t\t\t\t\t tmp, nbchar);\n } else {\n if (ctxt->sax->characters != NULL)\n\t\t\t\tctxt->sax->characters(ctxt->userData,\n\t\t\t\t\t\t tmp, nbchar);\n if (*ctxt->space == -1)\n *ctxt->space = -2;\n }\n } else if ((ctxt->sax != NULL) &&\n (ctxt->sax->characters != NULL)) {\n\t\t\tctxt->sax->characters(ctxt->userData,\n\t\t\t\t\t tmp, nbchar);\n }\n }\n return;\n }\n\nget_more:\n ccol = ctxt->input->col;\n while (test_char_data[*in]) {\n\t\tin++;\n\t\tccol++;\n }\n\t ctxt->input->col = ccol;\n if (*in == 0xA) {\n do {\n\t\t ctxt->input->line++; ctxt->input->col = 1;\n\t\t in++;\n } while (*in == 0xA);\n goto get_more;\n }\n if (*in == ']') {\n if ((in[1] == ']') && (in[2] == '>')) {\n\t\t xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);\n\t\t ctxt->input->cur = in;\n return;\n }\n\t\tin++;\n\t\tctxt->input->col++;\n goto get_more;\n }\n\t nbchar = in - ctxt->input->cur;\n if (nbchar > 0) {\n if ((ctxt->sax != NULL) &&\n (ctxt->sax->ignorableWhitespace !=\n\t\t ctxt->sax->characters) &&\n (IS_BLANK_CH(*ctxt->input->cur))) {\n const xmlChar *tmp = ctxt->input->cur;\n\t\t ctxt->input->cur = in;\n\n if (areBlanks(ctxt, tmp, nbchar, 0)) {\n if (ctxt->sax->ignorableWhitespace != NULL)\n\t\t\t ctxt->sax->ignorableWhitespace(ctxt->userData,\n\t\t\t\t\t\t\t tmp, nbchar);\n } else {\n if (ctxt->sax->characters != NULL)\n\t\t\t ctxt->sax->characters(ctxt->userData,\n\t\t\t\t\t\t tmp, nbchar);\n if (*ctxt->space == -1)\n *ctxt->space = -2;\n }\n line = ctxt->input->line;\n col = ctxt->input->col;\n } else if (ctxt->sax != NULL) {\n if (ctxt->sax->characters != NULL)\n\t\t\tctxt->sax->characters(ctxt->userData,\n\t\t\t\t\t ctxt->input->cur, nbchar);\n line = ctxt->input->line;\n col = ctxt->input->col;\n }\n \/* something really bad happened in the SAX callback *\/\n if (ctxt->instate != XML_PARSER_CONTENT)\n return;\n }\n\t ctxt->input->cur = in;\n if (*in == 0xD) {\n\t\tin++;\n if (*in == 0xA) {\n\t\t ctxt->input->cur = in;\n\t\t in++;\n\t\t ctxt->input->line++; ctxt->input->col = 1;\n continue; \/* while *\/\n }\n\t\tin--;\n }\n if (*in == '<') {\n return;\n }\n if (*in == '&') {\n return;\n }\n\t SHRINK;\n\t GROW;\n if (ctxt->instate == XML_PARSER_EOF)\n return;\n\t in = ctxt->input->cur;\n } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));\n\tnbchar = 0;\n }\n ctxt->input->line = line;\n ctxt->input->col = col;\n xmlParseCharDataComplex(ctxt, cdata);\n}\n","target":0,"code_token_length":1039,"total_token_length":1275,"max_tokens_setting":2048} +{"idx":476275,"func":"void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {\n\n \/\/ Orphan the mirror first, CMS thinks it's still live.\n if (java_mirror() != NULL) {\n java_lang_Class::set_klass(java_mirror(), NULL);\n }\n\n \/\/ Also remove mirror from handles\n loader_data->remove_handle(_java_mirror);\n\n \/\/ Need to take this class off the class loader data list.\n loader_data->remove_class(this);\n\n \/\/ The array_klass for this class is created later, after error handling.\n \/\/ For class redefinition, we keep the original class so this scratch class\n \/\/ doesn't have an array class. Either way, assert that there is nothing\n \/\/ to deallocate.\n assert(array_klasses() == NULL, \"array classes shouldn't be created for this class yet\");\n\n \/\/ Release C heap allocated data that this might point to, which includes\n \/\/ reference counting symbol names.\n release_C_heap_structures();\n\n deallocate_methods(loader_data, methods());\n set_methods(NULL);\n\n if (method_ordering() != NULL &&\n method_ordering() != Universe::the_empty_int_array() &&\n !method_ordering()->is_shared()) {\n MetadataFactory::free_array(loader_data, method_ordering());\n }\n set_method_ordering(NULL);\n\n \/\/ default methods can be empty\n if (default_methods() != NULL &&\n default_methods() != Universe::the_empty_method_array() &&\n !default_methods()->is_shared()) {\n MetadataFactory::free_array(loader_data, default_methods());\n }\n \/\/ Do NOT deallocate the default methods, they are owned by superinterfaces.\n set_default_methods(NULL);\n\n \/\/ default methods vtable indices can be empty\n if (default_vtable_indices() != NULL &&\n !default_vtable_indices()->is_shared()) {\n MetadataFactory::free_array(loader_data, default_vtable_indices());\n }\n set_default_vtable_indices(NULL);\n\n\n \/\/ This array is in Klass, but remove it with the InstanceKlass since\n \/\/ this place would be the only caller and it can share memory with transitive\n \/\/ interfaces.\n if (secondary_supers() != NULL &&\n secondary_supers() != Universe::the_empty_klass_array() &&\n secondary_supers() != transitive_interfaces() &&\n !secondary_supers()->is_shared()) {\n MetadataFactory::free_array(loader_data, secondary_supers());\n }\n set_secondary_supers(NULL);\n\n deallocate_interfaces(loader_data, super(), local_interfaces(), transitive_interfaces());\n set_transitive_interfaces(NULL);\n set_local_interfaces(NULL);\n\n if (fields() != NULL && !fields()->is_shared()) {\n MetadataFactory::free_array(loader_data, fields());\n }\n set_fields(NULL, 0);\n\n \/\/ If a method from a redefined class is using this constant pool, don't\n \/\/ delete it, yet. The new class's previous version will point to this.\n if (constants() != NULL) {\n assert (!constants()->on_stack(), \"shouldn't be called if anything is onstack\");\n if (!constants()->is_shared()) {\n MetadataFactory::free_metadata(loader_data, constants());\n }\n \/\/ Delete any cached resolution errors for the constant pool\n SystemDictionary::delete_resolution_error(constants());\n\n set_constants(NULL);\n }\n\n if (inner_classes() != NULL &&\n inner_classes() != Universe::the_empty_short_array() &&\n !inner_classes()->is_shared()) {\n MetadataFactory::free_array(loader_data, inner_classes());\n }\n set_inner_classes(NULL);\n\n if (nest_members() != NULL &&\n nest_members() != Universe::the_empty_short_array() &&\n !nest_members()->is_shared()) {\n MetadataFactory::free_array(loader_data, nest_members());\n }\n set_nest_members(NULL);\n\n \/\/ We should deallocate the Annotations instance if it's not in shared spaces.\n if (annotations() != NULL && !annotations()->is_shared()) {\n MetadataFactory::free_metadata(loader_data, annotations());\n }\n set_annotations(NULL);\n}","target":0,"code_token_length":873,"total_token_length":1109,"max_tokens_setting":2048} +{"idx":325425,"func":"static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,\n\n\tlong width, long height,\n\n\tlong lumStride, long chromStride, long dstStride, long vertLumPerChroma)\n\n{\n\n\tlong y;\n\n\tconst long chromWidth= width>>1;\n\n\tfor(y=0; yyuy2\n\n\n\n#if __WORDSIZE >= 64\n\n\t\tint i;\n\n\t\tuint64_t *ldst = (uint64_t *) dst;\n\n\t\tconst uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;\n\n\t\tfor(i = 0; i < chromWidth; i += 2){\n\n\t\t\tuint64_t k, l;\n\n\t\t\tk = uc[0] + (yc[0] << 8) +\n\n\t\t\t (vc[0] << 16) + (yc[1] << 24);\n\n\t\t\tl = uc[1] + (yc[2] << 8) +\n\n\t\t\t (vc[1] << 16) + (yc[3] << 24);\n\n\t\t\t*ldst++ = k + (l << 32);\n\n\t\t\tyc += 4;\n\n\t\t\tuc += 2;\n\n\t\t\tvc += 2;\n\n\t\t}\n\n\n\n#else\n\n\t\tint i, *idst = (int32_t *) dst;\n\n\t\tconst uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;\n\n\t\tfor(i = 0; i < chromWidth; i++){\n\n#ifdef WORDS_BIGENDIAN\n\n\t\t\t*idst++ = (uc[0] << 24)+ (yc[0] << 16) +\n\n\t\t\t (vc[0] << 8) + (yc[1] << 0);\n\n#else\n\n\t\t\t*idst++ = uc[0] + (yc[0] << 8) +\n\n\t\t\t (vc[0] << 16) + (yc[1] << 24);\n\n#endif\n\n\t\t\tyc += 2;\n\n\t\t\tuc++;\n\n\t\t\tvc++;\n\n\t\t}\n\n#endif\n\n#endif\n\n\t\tif((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) )\n\n\t\t{\n\n\t\t\tusrc += chromStride;\n\n\t\t\tvsrc += chromStride;\n\n\t\t}\n\n\t\tysrc += lumStride;\n\n\t\tdst += dstStride;\n\n\t}\n\n#ifdef HAVE_MMX\n\nasm( EMMS\" \\n\\t\"\n\n SFENCE\" \\n\\t\"\n\n :::\"memory\");\n\n#endif\n\n}\n","target":0,"code_token_length":1261,"total_token_length":1497,"max_tokens_setting":2048} +{"idx":155421,"func":"recvauth_common(krb5_context context,\n krb5_auth_context * auth_context,\n \/* IN *\/\n krb5_pointer fd,\n char *appl_version,\n krb5_principal server,\n krb5_int32 flags,\n krb5_keytab keytab,\n \/* OUT *\/\n krb5_ticket ** ticket,\n krb5_data *version)\n{\n krb5_auth_context new_auth_context;\n krb5_flags ap_option = 0;\n krb5_error_code retval, problem;\n krb5_data inbuf;\n krb5_data outbuf;\n krb5_rcache rcache = 0;\n krb5_octet response;\n krb5_data null_server;\n krb5_data d;\n int need_error_free = 0;\n int local_rcache = 0, local_authcon = 0;\n\n \/*\n * Zero out problem variable. If problem is set at the end of\n * the intial version negotiation section, it means that we\n * need to send an error code back to the client application\n * and exit.\n *\/\n problem = 0;\n response = 0;\n\n if (!(flags & KRB5_RECVAUTH_SKIP_VERSION)) {\n \/*\n * First read the sendauth version string and check it.\n *\/\n if ((retval = krb5_read_message(context, fd, &inbuf)))\n return(retval);\n d = make_data((char *)sendauth_version, strlen(sendauth_version) + 1);\n if (!data_eq(inbuf, d)) {\n problem = KRB5_SENDAUTH_BADAUTHVERS;\n response = 1;\n }\n free(inbuf.data);\n }\n if (flags & KRB5_RECVAUTH_BADAUTHVERS) {\n problem = KRB5_SENDAUTH_BADAUTHVERS;\n response = 1;\n }\n\n \/*\n * Do the same thing for the application version string.\n *\/\n if ((retval = krb5_read_message(context, fd, &inbuf)))\n return(retval);\n if (appl_version != NULL && !problem) {\n d = make_data(appl_version, strlen(appl_version) + 1);\n if (!data_eq(inbuf, d)) {\n problem = KRB5_SENDAUTH_BADAPPLVERS;\n response = 2;\n }\n }\n if (version && !problem)\n *version = inbuf;\n else\n free(inbuf.data);\n\n \/*\n * Now we actually write the response. If the response is non-zero,\n * exit with a return value of problem\n *\/\n if ((krb5_net_write(context, *((int *)fd), (char *)&response, 1)) < 0) {\n return(problem); \/* We'll return the top-level problem *\/\n }\n if (problem)\n return(problem);\n\n \/* We are clear of errors here *\/\n\n \/*\n * Now, let's read the AP_REQ message and decode it\n *\/\n if ((retval = krb5_read_message(context, fd, &inbuf)))\n return retval;\n\n if (*auth_context == NULL) {\n problem = krb5_auth_con_init(context, &new_auth_context);\n *auth_context = new_auth_context;\n local_authcon = 1;\n }\n krb5_auth_con_getrcache(context, *auth_context, &rcache);\n if ((!problem) && rcache == NULL) {\n \/*\n * Setup the replay cache.\n *\/\n if (server != NULL && server->length > 0) {\n problem = krb5_get_server_rcache(context, &server->data[0],\n &rcache);\n } else {\n null_server.length = 7;\n null_server.data = \"default\";\n problem = krb5_get_server_rcache(context, &null_server, &rcache);\n }\n if (!problem)\n problem = krb5_auth_con_setrcache(context, *auth_context, rcache);\n local_rcache = 1;\n }\n if (!problem) {\n problem = krb5_rd_req(context, auth_context, &inbuf, server,\n keytab, &ap_option, ticket);\n free(inbuf.data);\n }\n\n \/*\n * If there was a problem, send back a krb5_error message,\n * preceeded by the length of the krb5_error message. If\n * everything's ok, send back 0 for the length.\n *\/\n if (problem) {\n krb5_error error;\n const char *message;\n\n memset(&error, 0, sizeof(error));\n krb5_us_timeofday(context, &error.stime, &error.susec);\n if(server)\n error.server = server;\n else {\n \/* If this fails - ie. ENOMEM we are hosed\n we cannot even send the error if we wanted to... *\/\n (void) krb5_parse_name(context, \"????\", &error.server);\n need_error_free = 1;\n }\n\n error.error = problem - ERROR_TABLE_BASE_krb5;\n if (error.error > 127)\n error.error = KRB_ERR_GENERIC;\n message = error_message(problem);\n error.text.length = strlen(message) + 1;\n error.text.data = strdup(message);\n if (!error.text.data) {\n retval = ENOMEM;\n goto cleanup;\n }\n if ((retval = krb5_mk_error(context, &error, &outbuf))) {\n free(error.text.data);\n goto cleanup;\n }\n free(error.text.data);\n if(need_error_free)\n krb5_free_principal(context, error.server);\n\n } else {\n outbuf.length = 0;\n outbuf.data = 0;\n }\n\n retval = krb5_write_message(context, fd, &outbuf);\n if (outbuf.data) {\n free(outbuf.data);\n \/* We sent back an error, we need cleanup then return *\/\n retval = problem;\n goto cleanup;\n }\n if (retval)\n goto cleanup;\n\n \/* Here lies the mutual authentication stuff... *\/\n if ((ap_option & AP_OPTS_MUTUAL_REQUIRED)) {\n if ((retval = krb5_mk_rep(context, *auth_context, &outbuf))) {\n return(retval);\n }\n retval = krb5_write_message(context, fd, &outbuf);\n free(outbuf.data);\n }\n\ncleanup:;\n if (retval) {\n if (local_authcon) {\n krb5_auth_con_free(context, *auth_context);\n } else if (local_rcache && rcache != NULL) {\n krb5_rc_close(context, rcache);\n krb5_auth_con_setrcache(context, *auth_context, NULL);\n }\n }\n return retval;\n}","target":0,"code_token_length":1440,"total_token_length":1676,"max_tokens_setting":2048} +{"idx":257334,"func":"static void pdf_process_stream ( fz_context * ctx , pdf_processor * proc , pdf_csi * csi , fz_stream * stm ) {\n pdf_document * doc = csi -> doc ;\n pdf_lexbuf * buf = csi -> buf ;\n fz_cookie * cookie = csi -> cookie ;\n pdf_token tok = PDF_TOK_ERROR ;\n int in_text_array = 0 ;\n int syntax_errors = 0 ;\n pdf_clear_stack ( ctx , csi ) ;\n fz_var ( in_text_array ) ;\n fz_var ( tok ) ;\n if ( cookie ) {\n cookie -> progress_max = - 1 ;\n cookie -> progress = 0 ;\n }\n do {\n fz_try ( ctx ) {\n do {\n if ( cookie ) {\n if ( cookie -> abort ) {\n tok = PDF_TOK_EOF ;\n break ;\n }\n cookie -> progress ++ ;\n }\n tok = pdf_lex ( ctx , stm , buf ) ;\n if ( in_text_array ) {\n switch ( tok ) {\n case PDF_TOK_CLOSE_ARRAY : in_text_array = 0 ;\n break ;\n case PDF_TOK_REAL : pdf_array_push_drop ( ctx , csi -> obj , pdf_new_real ( ctx , doc , buf -> f ) ) ;\n break ;\n case PDF_TOK_INT : pdf_array_push_drop ( ctx , csi -> obj , pdf_new_int ( ctx , doc , buf -> i ) ) ;\n break ;\n case PDF_TOK_STRING : pdf_array_push_drop ( ctx , csi -> obj , pdf_new_string ( ctx , doc , buf -> scratch , buf -> len ) ) ;\n break ;\n case PDF_TOK_EOF : break ;\n case PDF_TOK_KEYWORD : if ( buf -> scratch [ 0 ] == 'T' && ( buf -> scratch [ 1 ] == 'w' || buf -> scratch [ 1 ] == 'c' ) && buf -> scratch [ 2 ] == 0 ) {\n int n = pdf_array_len ( ctx , csi -> obj ) ;\n if ( n > 0 ) {\n pdf_obj * o = pdf_array_get ( ctx , csi -> obj , n - 1 ) ;\n if ( pdf_is_number ( ctx , o ) ) {\n csi -> stack [ 0 ] = pdf_to_real ( ctx , o ) ;\n pdf_array_delete ( ctx , csi -> obj , n - 1 ) ;\n pdf_process_keyword ( ctx , proc , csi , stm , buf -> scratch ) ;\n }\n }\n }\n default : fz_throw ( ctx , FZ_ERROR_SYNTAX , \"syntax error in array\" ) ;\n }\n }\n else switch ( tok ) {\n case PDF_TOK_ENDSTREAM : case PDF_TOK_EOF : tok = PDF_TOK_EOF ;\n break ;\n case PDF_TOK_OPEN_ARRAY : if ( csi -> obj ) {\n pdf_drop_obj ( ctx , csi -> obj ) ;\n csi -> obj = NULL ;\n }\n if ( csi -> in_text ) {\n in_text_array = 1 ;\n csi -> obj = pdf_new_array ( ctx , doc , 4 ) ;\n }\n else {\n csi -> obj = pdf_parse_array ( ctx , doc , stm , buf ) ;\n }\n break ;\n case PDF_TOK_OPEN_DICT : if ( csi -> obj ) {\n pdf_drop_obj ( ctx , csi -> obj ) ;\n csi -> obj = NULL ;\n }\n csi -> obj = pdf_parse_dict ( ctx , doc , stm , buf ) ;\n break ;\n case PDF_TOK_NAME : if ( csi -> name [ 0 ] ) {\n pdf_drop_obj ( ctx , csi -> obj ) ;\n csi -> obj = NULL ;\n csi -> obj = pdf_new_name ( ctx , doc , buf -> scratch ) ;\n }\n else fz_strlcpy ( csi -> name , buf -> scratch , sizeof ( csi -> name ) ) ;\n break ;\n case PDF_TOK_INT : if ( csi -> top < nelem ( csi -> stack ) ) {\n csi -> stack [ csi -> top ] = buf -> i ;\n csi -> top ++ ;\n }\n else fz_throw ( ctx , FZ_ERROR_SYNTAX , \"stack overflow\" ) ;\n break ;\n case PDF_TOK_REAL : if ( csi -> top < nelem ( csi -> stack ) ) {\n csi -> stack [ csi -> top ] = buf -> f ;\n csi -> top ++ ;\n }\n else fz_throw ( ctx , FZ_ERROR_SYNTAX , \"stack overflow\" ) ;\n break ;\n case PDF_TOK_STRING : if ( buf -> len <= sizeof ( csi -> string ) ) {\n memcpy ( csi -> string , buf -> scratch , buf -> len ) ;\n csi -> string_len = buf -> len ;\n }\n else {\n if ( csi -> obj ) {\n pdf_drop_obj ( ctx , csi -> obj ) ;\n csi -> obj = NULL ;\n }\n csi -> obj = pdf_new_string ( ctx , doc , buf -> scratch , buf -> len ) ;\n }\n break ;\n case PDF_TOK_KEYWORD : pdf_process_keyword ( ctx , proc , csi , stm , buf -> scratch ) ;\n pdf_clear_stack ( ctx , csi ) ;\n break ;\n default : fz_throw ( ctx , FZ_ERROR_SYNTAX , \"syntax error in content stream\" ) ;\n }\n }\n while ( tok != PDF_TOK_EOF ) ;\n }\n fz_always ( ctx ) {\n pdf_clear_stack ( ctx , csi ) ;\n }\n fz_catch ( ctx ) {\n int caught = fz_caught ( ctx ) ;\n if ( cookie ) {\n if ( caught == FZ_ERROR_TRYLATER ) {\n if ( cookie -> incomplete_ok ) cookie -> incomplete ++ ;\n else fz_rethrow ( ctx ) ;\n }\n else if ( caught == FZ_ERROR_ABORT ) {\n fz_rethrow ( ctx ) ;\n }\n else if ( caught == FZ_ERROR_SYNTAX ) {\n cookie -> errors ++ ;\n if ( ++ syntax_errors >= MAX_SYNTAX_ERRORS ) {\n fz_warn ( ctx , \"too many syntax errors;\n ignoring rest of page\" ) ;\n tok = PDF_TOK_EOF ;\n }\n }\n else {\n cookie -> errors ++ ;\n fz_warn ( ctx , \"unrecoverable error;\n ignoring rest of page\" ) ;\n tok = PDF_TOK_EOF ;\n }\n }\n else {\n if ( caught == FZ_ERROR_TRYLATER ) fz_rethrow ( ctx ) ;\n else if ( caught == FZ_ERROR_ABORT ) fz_rethrow ( ctx ) ;\n else if ( caught == FZ_ERROR_SYNTAX ) {\n if ( ++ syntax_errors >= MAX_SYNTAX_ERRORS ) {\n fz_warn ( ctx , \"too many syntax errors;\n ignoring rest of page\" ) ;\n tok = PDF_TOK_EOF ;\n }\n }\n else {\n fz_warn ( ctx , \"unrecoverable error;\n ignoring rest of page\" ) ;\n tok = PDF_TOK_EOF ;\n }\n }\n in_text_array = 0 ;\n }\n }\n while ( tok != PDF_TOK_EOF ) ;\n }","target":0,"code_token_length":1396,"total_token_length":1632,"max_tokens_setting":2048} +{"idx":344577,"func":"cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)\n{\n cmsPipeline* Src;\n cmsPipeline* Dest;\n cmsStage* mpe;\n cmsStage* CLUT;\n cmsStage *KeepPreLin = NULL, *KeepPostLin = NULL;\n int nGridPoints;\n cmsColorSpaceSignature ColorSpace, OutputColorSpace;\n cmsStage *NewPreLin = NULL;\n cmsStage *NewPostLin = NULL;\n _cmsStageCLutData* DataCLUT;\n cmsToneCurve** DataSetIn;\n cmsToneCurve** DataSetOut;\n Prelin16Data* p16;\n\n\n \/\/ This is a loosy optimization! does not apply in floating-point cases\n if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;\n\n ColorSpace = _cmsICCcolorSpace(T_COLORSPACE(*InputFormat));\n OutputColorSpace = _cmsICCcolorSpace(T_COLORSPACE(*OutputFormat));\n nGridPoints = _cmsReasonableGridpointsByColorspace(ColorSpace, *dwFlags);\n\n \/\/ For empty LUTs, 2 points are enough\n if (cmsPipelineStageCount(*Lut) == 0)\n nGridPoints = 2;\n\n Src = *Lut;\n\n \/\/ Named color pipelines cannot be optimized either\n for (mpe = cmsPipelineGetPtrToFirstStage(Src);\n mpe != NULL;\n mpe = cmsStageNext(mpe)) {\n if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;\n }\n\n \/\/ Allocate an empty LUT\n Dest = cmsPipelineAlloc(Src ->ContextID, Src ->InputChannels, Src ->OutputChannels);\n if (!Dest) return FALSE;\n\n \/\/ Prelinearization tables are kept unless indicated by flags\n if (*dwFlags & cmsFLAGS_CLUT_PRE_LINEARIZATION) {\n\n \/\/ Get a pointer to the prelinearization element\n cmsStage* PreLin = cmsPipelineGetPtrToFirstStage(Src);\n\n \/\/ Check if suitable\n if (PreLin ->Type == cmsSigCurveSetElemType) {\n\n \/\/ Maybe this is a linear tram, so we can avoid the whole stuff\n if (!AllCurvesAreLinear(PreLin)) {\n\n \/\/ All seems ok, proceed.\n NewPreLin = cmsStageDup(PreLin);\n cmsPipelineInsertStage(Dest, cmsAT_BEGIN, NewPreLin);\n\n \/\/ Remove prelinearization. Since we have duplicated the curve\n \/\/ in destination LUT, the sampling shoud be applied after this stage.\n cmsPipelineUnlinkStage(Src, cmsAT_BEGIN, &KeepPreLin);\n }\n }\n }\n\n \/\/ Allocate the CLUT\n CLUT = cmsStageAllocCLut16bit(Src ->ContextID, nGridPoints, Src ->InputChannels, Src->OutputChannels, NULL);\n if (CLUT == NULL) return FALSE;\n\n \/\/ Add the CLUT to the destination LUT\n cmsPipelineInsertStage(Dest, cmsAT_END, CLUT);\n\n \/\/ Postlinearization tables are kept unless indicated by flags\n if (*dwFlags & cmsFLAGS_CLUT_POST_LINEARIZATION) {\n\n \/\/ Get a pointer to the postlinearization if present\n cmsStage* PostLin = cmsPipelineGetPtrToLastStage(Src);\n\n \/\/ Check if suitable\n if (cmsStageType(PostLin) == cmsSigCurveSetElemType) {\n\n \/\/ Maybe this is a linear tram, so we can avoid the whole stuff\n if (!AllCurvesAreLinear(PostLin)) {\n\n \/\/ All seems ok, proceed.\n NewPostLin = cmsStageDup(PostLin);\n cmsPipelineInsertStage(Dest, cmsAT_END, NewPostLin);\n\n \/\/ In destination LUT, the sampling shoud be applied after this stage.\n cmsPipelineUnlinkStage(Src, cmsAT_END, &KeepPostLin);\n }\n }\n }\n\n \/\/ Now its time to do the sampling. We have to ignore pre\/post linearization\n \/\/ The source LUT whithout pre\/post curves is passed as parameter.\n if (!cmsStageSampleCLut16bit(CLUT, XFormSampler16, (void*) Src, 0)) {\n\n \/\/ Ops, something went wrong, Restore stages\n if (KeepPreLin != NULL) cmsPipelineInsertStage(Src, cmsAT_BEGIN, KeepPreLin);\n if (KeepPostLin != NULL) cmsPipelineInsertStage(Src, cmsAT_END, KeepPostLin);\n cmsPipelineFree(Dest);\n return FALSE;\n }\n\n \/\/ Done.\n\n if (KeepPreLin != NULL) cmsStageFree(KeepPreLin);\n if (KeepPostLin != NULL) cmsStageFree(KeepPostLin);\n cmsPipelineFree(Src);\n\n DataCLUT = (_cmsStageCLutData*) CLUT ->Data;\n\n if (NewPreLin == NULL) DataSetIn = NULL;\n else DataSetIn = ((_cmsStageToneCurvesData*) NewPreLin ->Data) ->TheCurves;\n\n if (NewPostLin == NULL) DataSetOut = NULL;\n else DataSetOut = ((_cmsStageToneCurvesData*) NewPostLin ->Data) ->TheCurves;\n\n\n if (DataSetIn == NULL && DataSetOut == NULL) {\n\n _cmsPipelineSetOptimizationParameters(Dest, (_cmsOPTeval16Fn) DataCLUT->Params->Interpolation.Lerp16, DataCLUT->Params, NULL, NULL);\n }\n else {\n\n p16 = PrelinOpt16alloc(Dest ->ContextID,\n DataCLUT ->Params,\n Dest ->InputChannels,\n DataSetIn,\n Dest ->OutputChannels,\n DataSetOut);\n\n\n _cmsPipelineSetOptimizationParameters(Dest, PrelinEval16, (void*) p16, PrelinOpt16free, Prelin16dup);\n }\n\n\n \/\/ Don't fix white on absolute colorimetric\n if (Intent == INTENT_ABSOLUTE_COLORIMETRIC)\n *dwFlags |= cmsFLAGS_NOWHITEONWHITEFIXUP;\n\n if (!(*dwFlags & cmsFLAGS_NOWHITEONWHITEFIXUP)) {\n\n FixWhiteMisalignment(Dest, ColorSpace, OutputColorSpace);\n }\n\n *Lut = Dest;\n return TRUE;\n\n cmsUNUSED_PARAMETER(Intent);\n}","target":1,"code_token_length":1397,"total_token_length":1633,"max_tokens_setting":2048} +{"idx":337697,"func":"static int rm_assemble_video_frame(AVFormatContext *s, ByteIOContext *pb,\n\n RMDemuxContext *rm, RMStream *vst,\n\n AVPacket *pkt, int len, int *pseq)\n\n{\n\n int hdr, seq, pic_num, len2, pos;\n\n int type;\n\n\n\n hdr = get_byte(pb); len--;\n\n type = hdr >> 6;\n\n\n\n if(type != 3){ \/\/ not frame as a part of packet\n\n seq = get_byte(pb); len--;\n\n }\n\n if(type != 1){ \/\/ not whole frame\n\n len2 = get_num(pb, &len);\n\n pos = get_num(pb, &len);\n\n pic_num = get_byte(pb); len--;\n\n }\n\n if(len<0)\n\n return -1;\n\n rm->remaining_len = len;\n\n if(type&1){ \/\/ frame, not slice\n\n if(type == 3) \/\/ frame as a part of packet\n\n len= len2;\n\n if(rm->remaining_len < len)\n\n return -1;\n\n rm->remaining_len -= len;\n\n if(av_new_packet(pkt, len + 9) < 0)\n\n return AVERROR(EIO);\n\n pkt->data[0] = 0;\n\n AV_WL32(pkt->data + 1, 1);\n\n AV_WL32(pkt->data + 5, 0);\n\n get_buffer(pb, pkt->data + 9, len);\n\n return 0;\n\n }\n\n \/\/now we have to deal with single slice\n\n\n\n *pseq = seq;\n\n if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){\n\n vst->slices = ((hdr & 0x3F) << 1) + 1;\n\n vst->videobufsize = len2 + 8*vst->slices + 1;\n\n av_free_packet(&vst->pkt); \/\/FIXME this should be output.\n\n if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)\n\n return AVERROR(ENOMEM);\n\n vst->videobufpos = 8*vst->slices + 1;\n\n vst->cur_slice = 0;\n\n vst->curpic_num = pic_num;\n\n vst->pktpos = url_ftell(pb);\n\n }\n\n if(type == 2)\n\n len = FFMIN(len, pos);\n\n\n\n if(++vst->cur_slice > vst->slices)\n\n return 1;\n\n AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1);\n\n AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1);\n\n if(vst->videobufpos + len > vst->videobufsize)\n\n return 1;\n\n if (get_buffer(pb, vst->pkt.data + vst->videobufpos, len) != len)\n\n return AVERROR(EIO);\n\n vst->videobufpos += len;\n\n rm->remaining_len-= len;\n\n\n\n if(type == 2 || (vst->videobufpos) == vst->videobufsize){\n\n vst->pkt.data[0] = vst->cur_slice-1;\n\n *pkt= vst->pkt;\n\n vst->pkt.data= NULL;\n\n vst->pkt.size= 0;\n\n if(vst->slices != vst->cur_slice) \/\/FIXME find out how to set slices correct from the begin\n\n memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices,\n\n vst->videobufpos - 1 - 8*vst->slices);\n\n pkt->size = vst->videobufpos + 8*(vst->cur_slice - vst->slices);\n\n pkt->pts = AV_NOPTS_VALUE;\n\n pkt->pos = vst->pktpos;\n\n\n return 0;\n\n }\n\n\n\n return 1;\n\n}","target":1,"code_token_length":900,"total_token_length":1136,"max_tokens_setting":2048} +{"idx":105093,"func":"ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,\n AVStream *st, RMStream *ast, int len, AVPacket *pkt,\n int *seq, int flags, int64_t timestamp)\n{\n RMDemuxContext *rm = s->priv_data;\n int ret;\n\n if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {\n rm->current_stream= st->id;\n ret = rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq, ×tamp);\n if(ret)\n return ret < 0 ? ret : -1; \/\/got partial frame or error\n } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {\n if ((ast->deint_id == DEINT_ID_GENR) ||\n (ast->deint_id == DEINT_ID_INT4) ||\n (ast->deint_id == DEINT_ID_SIPR)) {\n int x;\n int sps = ast->sub_packet_size;\n int cfs = ast->coded_framesize;\n int h = ast->sub_packet_h;\n int y = ast->sub_packet_cnt;\n int w = ast->audio_framesize;\n\n if (flags & 2)\n y = ast->sub_packet_cnt = 0;\n if (!y)\n ast->audiotimestamp = timestamp;\n\n switch (ast->deint_id) {\n case DEINT_ID_INT4:\n for (x = 0; x < h\/2; x++)\n readfull(s, pb, ast->pkt.data+x*2*w+y*cfs, cfs);\n break;\n case DEINT_ID_GENR:\n for (x = 0; x < w\/sps; x++)\n readfull(s, pb, ast->pkt.data+sps*(h*x+((h+1)\/2)*(y&1)+(y>>1)), sps);\n break;\n case DEINT_ID_SIPR:\n readfull(s, pb, ast->pkt.data + y * w, w);\n break;\n }\n\n if (++(ast->sub_packet_cnt) < h)\n return -1;\n if (ast->deint_id == DEINT_ID_SIPR)\n ff_rm_reorder_sipr_data(ast->pkt.data, h, w);\n\n ast->sub_packet_cnt = 0;\n rm->audio_stream_num = st->index;\n if (st->codecpar->block_align <= 0) {\n av_log(s, AV_LOG_ERROR, \"Invalid block alignment %d\\n\", st->codecpar->block_align);\n return AVERROR_INVALIDDATA;\n }\n rm->audio_pkt_cnt = h * w \/ st->codecpar->block_align;\n } else if ((ast->deint_id == DEINT_ID_VBRF) ||\n (ast->deint_id == DEINT_ID_VBRS)) {\n int x;\n rm->audio_stream_num = st->index;\n ast->sub_packet_cnt = (avio_rb16(pb) & 0xf0) >> 4;\n if (ast->sub_packet_cnt) {\n for (x = 0; x < ast->sub_packet_cnt; x++)\n ast->sub_packet_lengths[x] = avio_rb16(pb);\n rm->audio_pkt_cnt = ast->sub_packet_cnt;\n ast->audiotimestamp = timestamp;\n } else\n return -1;\n } else {\n ret = av_get_packet(pb, pkt, len);\n if (ret < 0)\n return ret;\n rm_ac3_swap_bytes(st, pkt);\n }\n } else {\n ret = av_get_packet(pb, pkt, len);\n if (ret < 0)\n return ret;\n }\n\n pkt->stream_index = st->index;\n\n pkt->pts = timestamp;\n if (flags & 2)\n pkt->flags |= AV_PKT_FLAG_KEY;\n\n return st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;\n}","target":0,"code_token_length":877,"total_token_length":1113,"max_tokens_setting":2048} +{"idx":357583,"func":"AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig *sc, AvahiServerCallback callback, void* userdata, int *error) {\n AvahiServer *s;\n int e;\n\n if (sc && (e = valid_server_config(sc)) < 0) {\n if (error)\n *error = e;\n return NULL;\n }\n\n if (!(s = avahi_new(AvahiServer, 1))) {\n if (error)\n *error = AVAHI_ERR_NO_MEMORY;\n\n return NULL;\n }\n\n s->poll_api = poll_api;\n\n if (sc)\n avahi_server_config_copy(&s->config, sc);\n else\n avahi_server_config_init(&s->config);\n\n if ((e = setup_sockets(s)) < 0) {\n if (error)\n *error = e;\n\n avahi_server_config_free(&s->config);\n avahi_free(s);\n\n return NULL;\n }\n\n s->n_host_rr_pending = 0;\n s->need_entry_cleanup = 0;\n s->need_group_cleanup = 0;\n s->need_browser_cleanup = 0;\n s->hinfo_entry_group = NULL;\n s->browse_domain_entry_group = NULL;\n s->error = AVAHI_OK;\n s->state = AVAHI_SERVER_INVALID;\n\n s->callback = callback;\n s->userdata = userdata;\n\n s->time_event_queue = avahi_time_event_queue_new(poll_api);\n\n s->entries_by_key = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL);\n AVAHI_LLIST_HEAD_INIT(AvahiEntry, s->entries);\n AVAHI_LLIST_HEAD_INIT(AvahiGroup, s->groups);\n\n s->record_browser_hashmap = avahi_hashmap_new((AvahiHashFunc) avahi_key_hash, (AvahiEqualFunc) avahi_key_equal, NULL, NULL);\n AVAHI_LLIST_HEAD_INIT(AvahiSRecordBrowser, s->record_browsers);\n AVAHI_LLIST_HEAD_INIT(AvahiSHostNameResolver, s->host_name_resolvers);\n AVAHI_LLIST_HEAD_INIT(AvahiSAddressResolver, s->address_resolvers);\n AVAHI_LLIST_HEAD_INIT(AvahiSDomainBrowser, s->domain_browsers);\n AVAHI_LLIST_HEAD_INIT(AvahiSServiceTypeBrowser, s->service_type_browsers);\n AVAHI_LLIST_HEAD_INIT(AvahiSServiceBrowser, s->service_browsers);\n AVAHI_LLIST_HEAD_INIT(AvahiSServiceResolver, s->service_resolvers);\n AVAHI_LLIST_HEAD_INIT(AvahiSDNSServerBrowser, s->dns_server_browsers);\n\n s->legacy_unicast_reflect_slots = NULL;\n s->legacy_unicast_reflect_id = 0;\n\n s->record_list = avahi_record_list_new();\n\n \/* Get host name *\/\n s->host_name = s->config.host_name ? avahi_normalize_name_strdup(s->config.host_name) : avahi_get_host_name_strdup();\n s->host_name[strcspn(s->host_name, \".\")] = 0;\n s->domain_name = s->config.domain_name ? avahi_normalize_name_strdup(s->config.domain_name) : avahi_strdup(\"local\");\n s->host_name_fqdn = NULL;\n update_fqdn(s);\n\n do {\n s->local_service_cookie = (uint32_t) rand() * (uint32_t) rand();\n } while (s->local_service_cookie == AVAHI_SERVICE_COOKIE_INVALID);\n\n if (s->config.enable_wide_area) {\n s->wide_area_lookup_engine = avahi_wide_area_engine_new(s);\n avahi_wide_area_set_servers(s->wide_area_lookup_engine, s->config.wide_area_servers, s->config.n_wide_area_servers);\n } else\n s->wide_area_lookup_engine = NULL;\n\n s->multicast_lookup_engine = avahi_multicast_lookup_engine_new(s);\n\n s->monitor = avahi_interface_monitor_new(s);\n avahi_interface_monitor_sync(s->monitor);\n\n register_localhost(s);\n register_stuff(s);\n\n return s;\n}","target":0,"code_token_length":930,"total_token_length":1166,"max_tokens_setting":2048} +{"idx":503611,"func":"void edge_filtering_chroma_internal(de265_image* img, bool vertical,\n int yStart,int yEnd,\n int xStart,int xEnd)\n{\n \/\/printf(\"chroma %d-%d %d-%d\\n\",xStart,xEnd,yStart,yEnd);\n\n const seq_parameter_set& sps = img->get_sps();\n\n const int SubWidthC = sps.SubWidthC;\n const int SubHeightC = sps.SubHeightC;\n\n int xIncr = vertical ? 2 : 1;\n int yIncr = vertical ? 1 : 2;\n\n xIncr *= SubWidthC;\n yIncr *= SubHeightC;\n\n const int stride = img->get_image_stride(1);\n\n xEnd = libde265_min(xEnd,img->get_deblk_width());\n yEnd = libde265_min(yEnd,img->get_deblk_height());\n\n int bitDepth_C = sps.BitDepth_C;\n\n for (int y=yStart;yget_deblk_bS(xDi*SubWidthC,yDi*SubHeightC);\n\n if (bS>1) {\n \/\/ 8.7.2.4.5\n\n for (int cplane=0;cplane<2;cplane++) {\n int cQpPicOffset = (cplane==0 ?\n img->get_pps().pic_cb_qp_offset :\n img->get_pps().pic_cr_qp_offset);\n\n pixel_t* ptr = img->get_image_plane_at_pos_NEW(cplane+1, xDi,yDi);\n\n pixel_t p[2][4];\n pixel_t q[2][4];\n\n logtrace(LogDeblock,\"-%s- %d %d\\n\",cplane==0 ? \"Cb\" : \"Cr\",xDi,yDi);\n\n for (int i=0;i<2;i++)\n for (int k=0;k<4;k++)\n {\n if (vertical) {\n q[i][k] = ptr[ i +k*stride];\n p[i][k] = ptr[-i-1+k*stride];\n }\n else {\n q[i][k] = ptr[k + i *stride];\n p[i][k] = ptr[k -(i+1)*stride];\n }\n }\n\n#if 0\n for (int k=0;k<4;k++)\n {\n for (int i=0;i<2;i++)\n {\n printf(\"%02x \", p[1-i][k]);\n }\n\n printf(\"| \");\n\n for (int i=0;i<2;i++)\n {\n printf(\"%02x \", q[i][k]);\n }\n printf(\"\\n\");\n }\n#endif\n\n int QP_Q = img->get_QPY(SubWidthC*xDi,SubHeightC*yDi);\n int QP_P = (vertical ?\n img->get_QPY(SubWidthC*xDi-1,SubHeightC*yDi) :\n img->get_QPY(SubWidthC*xDi,SubHeightC*yDi-1));\n int qP_i = ((QP_Q+QP_P+1)>>1) + cQpPicOffset;\n int QP_C;\n if (sps.ChromaArrayType == CHROMA_420) {\n QP_C = table8_22(qP_i);\n } else {\n QP_C = libde265_min(qP_i, 51);\n }\n\n\n \/\/printf(\"POC=%d\\n\",ctx->img->PicOrderCntVal);\n logtrace(LogDeblock,\"%d %d: ((%d+%d+1)>>1) + %d = qP_i=%d (QP_C=%d)\\n\",\n SubWidthC*xDi,SubHeightC*yDi, QP_Q,QP_P,cQpPicOffset,qP_i,QP_C);\n\n int sliceIndexQ00 = img->get_SliceHeaderIndex(SubWidthC*xDi,SubHeightC*yDi);\n int tc_offset = img->slices[sliceIndexQ00]->slice_tc_offset;\n\n int Q = Clip3(0,53, QP_C + 2*(bS-1) + tc_offset);\n\n int tcPrime = table_8_23_tc[Q];\n int tc = tcPrime * (1<<(sps.BitDepth_C - 8));\n\n logtrace(LogDeblock,\"tc_offset=%d Q=%d tc'=%d tc=%d\\n\",tc_offset,Q,tcPrime,tc);\n\n if (vertical) {\n bool filterP = true;\n if (sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi-1,SubHeightC*yDi)) filterP=false;\n if (img->get_cu_transquant_bypass(SubWidthC*xDi-1,SubHeightC*yDi)) filterP=false;\n\n bool filterQ = true;\n if (sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;\n if (img->get_cu_transquant_bypass(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;\n\n\n for (int k=0;k<4;k++) {\n int delta = Clip3(-tc,tc, ((((q[0][k]-p[0][k])*4)+p[1][k]-q[1][k]+4)>>3)); \/\/ standard says <<2 in eq. (8-356), but the value can also be negative\n logtrace(LogDeblock,\"delta=%d\\n\",delta);\n if (filterP) { ptr[-1+k*stride] = Clip_BitDepth(p[0][k]+delta, bitDepth_C); }\n if (filterQ) { ptr[ 0+k*stride] = Clip_BitDepth(q[0][k]-delta, bitDepth_C); }\n }\n }\n else {\n bool filterP = true;\n if (sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi,SubHeightC*yDi-1)) filterP=false;\n if (img->get_cu_transquant_bypass(SubWidthC*xDi,SubHeightC*yDi-1)) filterP=false;\n\n bool filterQ = true;\n if (sps.pcm_loop_filter_disable_flag && img->get_pcm_flag(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;\n if (img->get_cu_transquant_bypass(SubWidthC*xDi,SubHeightC*yDi)) filterQ=false;\n\n for (int k=0;k<4;k++) {\n int delta = Clip3(-tc,tc, ((((q[0][k]-p[0][k])*4)+p[1][k]-q[1][k]+4)>>3)); \/\/ standard says <<2, but the value can also be negative\n if (filterP) { ptr[ k-1*stride] = Clip_BitDepth(p[0][k]+delta, bitDepth_C); }\n if (filterQ) { ptr[ k+0*stride] = Clip_BitDepth(q[0][k]-delta, bitDepth_C); }\n }\n }\n }\n }\n }\n}","target":0,"code_token_length":1669,"total_token_length":1905,"max_tokens_setting":2048} +{"idx":415373,"func":"set_policy_defaults(cupsd_policy_t *pol)\/* I - Policy *\/\n{\n cupsd_location_t\t*op;\t\t\/* Policy operation *\/\n\n\n \/*\n * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,\n * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that\n * upgrades do not introduce new security issues...\n *\n * CUPS STR #4659: Allow a lone policy.\n *\/\n\n if (cupsArrayCount(pol->ops) > 1)\n {\n if ((op = cupsdFindPolicyOp(pol, IPP_VALIDATE_JOB)) == NULL ||\n\top->op == IPP_ANY_OPERATION)\n {\n if ((op = cupsdFindPolicyOp(pol, IPP_PRINT_JOB)) != NULL &&\n\t op->op != IPP_ANY_OPERATION)\n {\n \/*\n\t* Add a new limit for Validate-Job using the Print-Job limit as a\n\t* template...\n\t*\/\n\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Validate-Job defined in policy %s - using Print-Job's policy.\", pol->name);\n\n\tcupsdAddPolicyOp(pol, op, IPP_VALIDATE_JOB);\n }\n else\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Validate-Job defined in policy %s and no suitable template found.\", pol->name);\n }\n\n if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_JOBS)) == NULL ||\n\top->op == IPP_ANY_OPERATION)\n {\n if ((op = cupsdFindPolicyOp(pol, IPP_PAUSE_PRINTER)) != NULL &&\n\t op->op != IPP_ANY_OPERATION)\n {\n \/*\n\t* Add a new limit for Cancel-Jobs using the Pause-Printer limit as a\n\t* template...\n\t*\/\n\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Cancel-Jobs defined in policy %s - using Pause-Printer's policy.\", pol->name);\n\n\tcupsdAddPolicyOp(pol, op, IPP_CANCEL_JOBS);\n }\n else\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Cancel-Jobs defined in policy %s and no suitable template found.\", pol->name);\n }\n\n if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_MY_JOBS)) == NULL ||\n\top->op == IPP_ANY_OPERATION)\n {\n if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&\n\t op->op != IPP_ANY_OPERATION)\n {\n \/*\n\t* Add a new limit for Cancel-My-Jobs using the Send-Document limit as\n\t* a template...\n\t*\/\n\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Cancel-My-Jobs defined in policy %s - using Send-Document's policy.\", pol->name);\n\n\tcupsdAddPolicyOp(pol, op, IPP_CANCEL_MY_JOBS);\n }\n else\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Cancel-My-Jobs defined in policy %s and no suitable template found.\", pol->name);\n }\n\n if ((op = cupsdFindPolicyOp(pol, IPP_CLOSE_JOB)) == NULL ||\n\top->op == IPP_ANY_OPERATION)\n {\n if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&\n\t op->op != IPP_ANY_OPERATION)\n {\n \/*\n\t* Add a new limit for Close-Job using the Send-Document limit as a\n\t* template...\n\t*\/\n\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Close-Job defined in policy %s - using Send-Document's policy.\", pol->name);\n\n\tcupsdAddPolicyOp(pol, op, IPP_CLOSE_JOB);\n }\n else\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for Close-Job defined in policy %s and no suitable template found.\", pol->name);\n }\n\n if ((op = cupsdFindPolicyOp(pol, CUPS_GET_DOCUMENT)) == NULL ||\n\top->op == IPP_ANY_OPERATION)\n {\n if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&\n\t op->op != IPP_ANY_OPERATION)\n {\n \/*\n\t* Add a new limit for CUPS-Get-Document using the Send-Document\n\t* limit as a template...\n\t*\/\n\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for CUPS-Get-Document defined in policy %s - using Send-Document's policy.\", pol->name);\n\n\tcupsdAddPolicyOp(pol, op, CUPS_GET_DOCUMENT);\n }\n else\n\tcupsdLogMessage(CUPSD_LOG_WARN, \"No limit for CUPS-Get-Document defined in policy %s and no suitable template found.\", pol->name);\n }\n }\n\n \/*\n * Verify we have JobPrivateAccess, JobPrivateValues,\n * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.\n *\/\n\n if (!pol->job_access)\n {\n cupsdLogMessage(CUPSD_LOG_WARN, \"No JobPrivateAccess defined in policy %s - using defaults.\", pol->name);\n cupsdAddString(&(pol->job_access), \"@OWNER\");\n cupsdAddString(&(pol->job_access), \"@SYSTEM\");\n }\n\n if (!pol->job_attrs)\n {\n cupsdLogMessage(CUPSD_LOG_WARN, \"No JobPrivateValues defined in policy %s - using defaults.\", pol->name);\n cupsdAddString(&(pol->job_attrs), \"job-name\");\n cupsdAddString(&(pol->job_attrs), \"job-originating-host-name\");\n cupsdAddString(&(pol->job_attrs), \"job-originating-user-name\");\n cupsdAddString(&(pol->job_attrs), \"phone\");\n }\n\n if (!pol->sub_access)\n {\n cupsdLogMessage(CUPSD_LOG_WARN, \"No SubscriptionPrivateAccess defined in policy %s - using defaults.\", pol->name);\n cupsdAddString(&(pol->sub_access), \"@OWNER\");\n cupsdAddString(&(pol->sub_access), \"@SYSTEM\");\n }\n\n if (!pol->sub_attrs)\n {\n cupsdLogMessage(CUPSD_LOG_WARN, \"No SubscriptionPrivateValues defined in policy %s - using defaults.\", pol->name);\n cupsdAddString(&(pol->sub_attrs), \"notify-events\");\n cupsdAddString(&(pol->sub_attrs), \"notify-pull-method\");\n cupsdAddString(&(pol->sub_attrs), \"notify-recipient-uri\");\n cupsdAddString(&(pol->sub_attrs), \"notify-subscriber-user-name\");\n cupsdAddString(&(pol->sub_attrs), \"notify-user-data\");\n }\n}","target":0,"code_token_length":1426,"total_token_length":1662,"max_tokens_setting":2048} +{"idx":34500,"func":"ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)\n{\n#undef DEBUG_READ_EXACT\n#ifdef DEBUG_READ_EXACT\n\tchar* oout=out;\n\tint nn=n;\n\trfbClientLog(\"ReadFromRFBServer %d bytes\\n\",n);\n#endif\n\n \/* Handle attempts to write to NULL out buffer that might occur\n when an outside malloc() fails. For instance, memcpy() to NULL\n results in undefined behaviour and probably memory corruption.*\/\n if(!out)\n return FALSE;\n\n if (client->serverPort==-1) {\n \/* vncrec playing *\/\n rfbVNCRec* rec = client->vncRec;\n struct timeval tv;\n\n if (rec->readTimestamp) {\n rec->readTimestamp = FALSE;\n if (!fread(&tv,sizeof(struct timeval),1,rec->file))\n return FALSE;\n\n tv.tv_sec = rfbClientSwap32IfLE (tv.tv_sec);\n tv.tv_usec = rfbClientSwap32IfLE (tv.tv_usec);\n\n if (rec->tv.tv_sec!=0 && !rec->doNotSleep) {\n struct timeval diff;\n diff.tv_sec = tv.tv_sec - rec->tv.tv_sec;\n diff.tv_usec = tv.tv_usec - rec->tv.tv_usec;\n if(diff.tv_usec<0) {\n\t diff.tv_sec--;\n\t diff.tv_usec+=1000000;\n }\n#ifndef WIN32\n sleep (diff.tv_sec);\n usleep (diff.tv_usec);\n#else\n\tSleep (diff.tv_sec * 1000 + diff.tv_usec\/1000);\n#endif\n }\n\n rec->tv=tv;\n }\n \n return (fread(out,1,n,rec->file) != n ? FALSE : TRUE);\n }\n \n if (n <= client->buffered) {\n memcpy(out, client->bufoutptr, n);\n client->bufoutptr += n;\n client->buffered -= n;\n#ifdef DEBUG_READ_EXACT\n goto hexdump;\n#endif\n return TRUE;\n }\n\n memcpy(out, client->bufoutptr, client->buffered);\n\n out += client->buffered;\n n -= client->buffered;\n\n client->bufoutptr = client->buf;\n client->buffered = 0;\n\n if (n <= RFB_BUF_SIZE) {\n\n while (client->buffered < n) {\n int i;\n if (client->tlsSession)\n i = ReadFromTLS(client, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);\n else\n#ifdef LIBVNCSERVER_HAVE_SASL\n if (client->saslconn)\n i = ReadFromSASL(client, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);\n else {\n#endif \/* LIBVNCSERVER_HAVE_SASL *\/\n i = read(client->sock, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);\n#ifdef WIN32\n\tif (i < 0) errno=WSAGetLastError();\n#endif\n#ifdef LIBVNCSERVER_HAVE_SASL\n }\n#endif\n \n if (i <= 0) {\n\tif (i < 0) {\n\t if (errno == EWOULDBLOCK || errno == EAGAIN) {\n\t \/* TODO:\n\t ProcessXtEvents();\n\t *\/\n\t WaitForMessage(client, 100000);\n\t i = 0;\n\t } else {\n\t rfbClientErr(\"read (%d: %s)\\n\",errno,strerror(errno));\n\t return FALSE;\n\t }\n\t} else {\n\t if (errorMessageOnReadFailure) {\n\t rfbClientLog(\"VNC server closed connection\\n\");\n\t }\n\t return FALSE;\n\t}\n }\n client->buffered += i;\n }\n\n memcpy(out, client->bufoutptr, n);\n client->bufoutptr += n;\n client->buffered -= n;\n\n } else {\n\n while (n > 0) {\n int i;\n if (client->tlsSession)\n i = ReadFromTLS(client, out, n);\n else\n#ifdef LIBVNCSERVER_HAVE_SASL\n if (client->saslconn)\n i = ReadFromSASL(client, out, n);\n else\n#endif\n i = read(client->sock, out, n);\n\n if (i <= 0) {\n\tif (i < 0) {\n#ifdef WIN32\n\t errno=WSAGetLastError();\n#endif\n\t if (errno == EWOULDBLOCK || errno == EAGAIN) {\n\t \/* TODO:\n\t ProcessXtEvents();\n\t *\/\n\t WaitForMessage(client, 100000);\n\t i = 0;\n\t } else {\n\t rfbClientErr(\"read (%s)\\n\",strerror(errno));\n\t return FALSE;\n\t }\n\t} else {\n\t if (errorMessageOnReadFailure) {\n\t rfbClientLog(\"VNC server closed connection\\n\");\n\t }\n\t return FALSE;\n\t}\n }\n out += i;\n n -= i;\n }\n }\n\n#ifdef DEBUG_READ_EXACT\nhexdump:\n { int ii;\n for(ii=0;ii= 21\n && ( memcmp(\"Raw profile type exif\", key, 21) == 0\n || memcmp(\"Raw profile type APP1\", key, 21) == 0)\n && pImage->exifData().empty())\n {\n DataBuf exifData = readRawProfile(arr,false);\n long length = exifData.size_;\n\n if (length > 0)\n {\n \/\/ Find the position of Exif header in bytes array.\n\n const byte exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 };\n long pos = -1;\n\n for (long i=0 ; i < length-(long)sizeof(exifHeader) ; i++)\n {\n if (memcmp(exifHeader, &exifData.pData_[i], sizeof(exifHeader)) == 0)\n {\n pos = i;\n break;\n }\n }\n\n \/\/ If found it, store only these data at from this place.\n\n if (pos !=-1)\n {\n#ifdef DEBUG\n std::cout << \"Exiv2::PngChunk::parseChunkContent: Exif header found at position \" << pos << \"\\n\";\n#endif\n pos = pos + sizeof(exifHeader);\n ByteOrder bo = TiffParser::decode(pImage->exifData(),\n pImage->iptcData(),\n pImage->xmpData(),\n exifData.pData_ + pos,\n length - pos);\n pImage->setByteOrder(bo);\n }\n else\n {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Failed to decode Exif metadata.\\n\";\n#endif\n pImage->exifData().clear();\n }\n }\n }\n\n \/\/ We look if an ImageMagick IPTC raw profile exist.\n\n if ( keySize >= 21\n && memcmp(\"Raw profile type iptc\", key, 21) == 0\n && pImage->iptcData().empty()) {\n DataBuf psData = readRawProfile(arr,false);\n if (psData.size_ > 0) {\n Blob iptcBlob;\n const byte *record = 0;\n uint32_t sizeIptc = 0;\n uint32_t sizeHdr = 0;\n\n const byte* pEnd = psData.pData_ + psData.size_;\n const byte* pCur = psData.pData_;\n while ( pCur < pEnd\n && 0 == Photoshop::locateIptcIrb(pCur,\n static_cast(pEnd - pCur),\n &record,\n &sizeHdr,\n &sizeIptc)) {\n if (sizeIptc) {\n#ifdef DEBUG\n std::cerr << \"Found IPTC IRB, size = \" << sizeIptc << \"\\n\";\n#endif\n append(iptcBlob, record + sizeHdr, sizeIptc);\n }\n pCur = record + sizeHdr + sizeIptc;\n pCur += (sizeIptc & 1);\n }\n if ( iptcBlob.size() > 0\n && IptcParser::decode(pImage->iptcData(),\n &iptcBlob[0],\n static_cast(iptcBlob.size()))) {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Failed to decode IPTC metadata.\\n\";\n#endif\n pImage->clearIptcData();\n }\n \/\/ If there is no IRB, try to decode the complete chunk data\n if ( iptcBlob.empty()\n && IptcParser::decode(pImage->iptcData(),\n psData.pData_,\n psData.size_)) {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Failed to decode IPTC metadata.\\n\";\n#endif\n pImage->clearIptcData();\n }\n } \/\/ if (psData.size_ > 0)\n }\n\n \/\/ We look if an ImageMagick XMP raw profile exist.\n\n if ( keySize >= 20\n && memcmp(\"Raw profile type xmp\", key, 20) == 0\n && pImage->xmpData().empty())\n {\n DataBuf xmpBuf = readRawProfile(arr,false);\n long length = xmpBuf.size_;\n\n if (length > 0)\n {\n std::string& xmpPacket = pImage->xmpPacket();\n xmpPacket.assign(reinterpret_cast(xmpBuf.pData_), length);\n std::string::size_type idx = xmpPacket.find_first_of('<');\n if (idx != std::string::npos && idx > 0)\n {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Removing \" << idx\n << \" characters from the beginning of the XMP packet\\n\";\n#endif\n xmpPacket = xmpPacket.substr(idx);\n }\n if (XmpParser::decode(pImage->xmpData(), xmpPacket))\n {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Failed to decode XMP metadata.\\n\";\n#endif\n }\n }\n }\n\n \/\/ We look if an Adobe XMP string exist.\n\n if ( keySize >= 17\n && memcmp(\"XML:com.adobe.xmp\", key, 17) == 0\n && pImage->xmpData().empty())\n {\n if (arr.size_ > 0)\n {\n std::string& xmpPacket = pImage->xmpPacket();\n xmpPacket.assign(reinterpret_cast(arr.pData_), arr.size_);\n std::string::size_type idx = xmpPacket.find_first_of('<');\n if (idx != std::string::npos && idx > 0)\n {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Removing \" << idx << \" characters \"\n << \"from the beginning of the XMP packet\\n\";\n#endif\n xmpPacket = xmpPacket.substr(idx);\n }\n if (XmpParser::decode(pImage->xmpData(), xmpPacket))\n {\n#ifndef SUPPRESS_WARNINGS\n EXV_WARNING << \"Failed to decode XMP metadata.\\n\";\n#endif\n }\n }\n }\n\n \/\/ We look if a comments string exist. Note than we use only 'Description' keyword which\n \/\/ is dedicaced to store long comments. 'Comment' keyword is ignored.\n\n if ( keySize >= 11\n && memcmp(\"Description\", key, 11) == 0\n && pImage->comment().empty())\n {\n pImage->setComment(std::string(reinterpret_cast(arr.pData_), arr.size_));\n }\n\n } \/\/ PngChunk::parseChunkContent","target":0,"code_token_length":1527,"total_token_length":1763,"max_tokens_setting":2048} +{"idx":129617,"func":"int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,\n\t\t u64 end, struct btrfs_scrub_progress *progress,\n\t\t int readonly, int is_dev_replace)\n{\n\tstruct scrub_ctx *sctx;\n\tint ret;\n\tstruct btrfs_device *dev;\n\tunsigned int nofs_flag;\n\n\tif (btrfs_fs_closing(fs_info))\n\t\treturn -EINVAL;\n\n\tif (fs_info->nodesize > BTRFS_STRIPE_LEN) {\n\t\t\/*\n\t\t * in this case scrub is unable to calculate the checksum\n\t\t * the way scrub is implemented. Do not handle this\n\t\t * situation at all because it won't ever happen.\n\t\t *\/\n\t\tbtrfs_err(fs_info,\n\t\t\t \"scrub: size assumption nodesize <= BTRFS_STRIPE_LEN (%d <= %d) fails\",\n\t\t fs_info->nodesize,\n\t\t BTRFS_STRIPE_LEN);\n\t\treturn -EINVAL;\n\t}\n\n\tif (fs_info->sectorsize != PAGE_SIZE) {\n\t\t\/* not supported for data w\/o checksums *\/\n\t\tbtrfs_err_rl(fs_info,\n\t\t\t \"scrub: size assumption sectorsize != PAGE_SIZE (%d != %lu) fails\",\n\t\t fs_info->sectorsize, PAGE_SIZE);\n\t\treturn -EINVAL;\n\t}\n\n\tif (fs_info->nodesize >\n\t PAGE_SIZE * SCRUB_MAX_PAGES_PER_BLOCK ||\n\t fs_info->sectorsize > PAGE_SIZE * SCRUB_MAX_PAGES_PER_BLOCK) {\n\t\t\/*\n\t\t * would exhaust the array bounds of pagev member in\n\t\t * struct scrub_block\n\t\t *\/\n\t\tbtrfs_err(fs_info,\n\t\t\t \"scrub: size assumption nodesize and sectorsize <= SCRUB_MAX_PAGES_PER_BLOCK (%d <= %d && %d <= %d) fails\",\n\t\t fs_info->nodesize,\n\t\t SCRUB_MAX_PAGES_PER_BLOCK,\n\t\t fs_info->sectorsize,\n\t\t SCRUB_MAX_PAGES_PER_BLOCK);\n\t\treturn -EINVAL;\n\t}\n\n\t\/* Allocate outside of device_list_mutex *\/\n\tsctx = scrub_setup_ctx(fs_info, is_dev_replace);\n\tif (IS_ERR(sctx))\n\t\treturn PTR_ERR(sctx);\n\n\tmutex_lock(&fs_info->fs_devices->device_list_mutex);\n\tdev = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL, true);\n\tif (!dev || (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) &&\n\t\t !is_dev_replace)) {\n\t\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\t\tret = -ENODEV;\n\t\tgoto out_free_ctx;\n\t}\n\n\tif (!is_dev_replace && !readonly &&\n\t !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {\n\t\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\t\tbtrfs_err_in_rcu(fs_info, \"scrub: device %s is not writable\",\n\t\t\t\trcu_str_deref(dev->name));\n\t\tret = -EROFS;\n\t\tgoto out_free_ctx;\n\t}\n\n\tmutex_lock(&fs_info->scrub_lock);\n\tif (!test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &dev->dev_state) ||\n\t test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &dev->dev_state)) {\n\t\tmutex_unlock(&fs_info->scrub_lock);\n\t\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\t\tret = -EIO;\n\t\tgoto out_free_ctx;\n\t}\n\n\tdown_read(&fs_info->dev_replace.rwsem);\n\tif (dev->scrub_ctx ||\n\t (!is_dev_replace &&\n\t btrfs_dev_replace_is_ongoing(&fs_info->dev_replace))) {\n\t\tup_read(&fs_info->dev_replace.rwsem);\n\t\tmutex_unlock(&fs_info->scrub_lock);\n\t\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\t\tret = -EINPROGRESS;\n\t\tgoto out_free_ctx;\n\t}\n\tup_read(&fs_info->dev_replace.rwsem);\n\n\tret = scrub_workers_get(fs_info, is_dev_replace);\n\tif (ret) {\n\t\tmutex_unlock(&fs_info->scrub_lock);\n\t\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\t\tgoto out_free_ctx;\n\t}\n\n\tsctx->readonly = readonly;\n\tdev->scrub_ctx = sctx;\n\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\n\t\/*\n\t * checking @scrub_pause_req here, we can avoid\n\t * race between committing transaction and scrubbing.\n\t *\/\n\t__scrub_blocked_if_needed(fs_info);\n\tatomic_inc(&fs_info->scrubs_running);\n\tmutex_unlock(&fs_info->scrub_lock);\n\n\t\/*\n\t * In order to avoid deadlock with reclaim when there is a transaction\n\t * trying to pause scrub, make sure we use GFP_NOFS for all the\n\t * allocations done at btrfs_scrub_pages() and scrub_pages_for_parity()\n\t * invoked by our callees. The pausing request is done when the\n\t * transaction commit starts, and it blocks the transaction until scrub\n\t * is paused (done at specific points at scrub_stripe() or right above\n\t * before incrementing fs_info->scrubs_running).\n\t *\/\n\tnofs_flag = memalloc_nofs_save();\n\tif (!is_dev_replace) {\n\t\t\/*\n\t\t * by holding device list mutex, we can\n\t\t * kick off writing super in log tree sync.\n\t\t *\/\n\t\tmutex_lock(&fs_info->fs_devices->device_list_mutex);\n\t\tret = scrub_supers(sctx, dev);\n\t\tmutex_unlock(&fs_info->fs_devices->device_list_mutex);\n\t}\n\n\tif (!ret)\n\t\tret = scrub_enumerate_chunks(sctx, dev, start, end);\n\tmemalloc_nofs_restore(nofs_flag);\n\n\twait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0);\n\tatomic_dec(&fs_info->scrubs_running);\n\twake_up(&fs_info->scrub_pause_wait);\n\n\twait_event(sctx->list_wait, atomic_read(&sctx->workers_pending) == 0);\n\n\tif (progress)\n\t\tmemcpy(progress, &sctx->stat, sizeof(*progress));\n\n\tmutex_lock(&fs_info->scrub_lock);\n\tdev->scrub_ctx = NULL;\n\tscrub_workers_put(fs_info);\n\tmutex_unlock(&fs_info->scrub_lock);\n\n\tscrub_put_ctx(sctx);\n\n\treturn ret;\n\nout_free_ctx:\n\tscrub_free_ctx(sctx);\n\n\treturn ret;\n}","target":0,"code_token_length":1344,"total_token_length":1580,"max_tokens_setting":2048} +{"idx":330081,"func":"int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)\n\n{\n\n int i, ret;\n\n int32_t config_len;\n\n uint32_t num;\n\n uint32_t features;\n\n BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));\n\n VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n\n\n\n \/*\n\n * We poison the endianness to ensure it does not get used before\n\n * subsections have been loaded.\n\n *\/\n\n vdev->device_endian = VIRTIO_DEVICE_ENDIAN_UNKNOWN;\n\n\n\n if (k->load_config) {\n\n ret = k->load_config(qbus->parent, f);\n\n if (ret)\n\n return ret;\n\n }\n\n\n\n qemu_get_8s(f, &vdev->status);\n\n qemu_get_8s(f, &vdev->isr);\n\n qemu_get_be16s(f, &vdev->queue_sel);\n\n if (vdev->queue_sel >= VIRTIO_QUEUE_MAX) {\n\n return -1;\n\n }\n\n qemu_get_be32s(f, &features);\n\n\n\n \/*\n\n * Temporarily set guest_features low bits - needed by\n\n * virtio net load code testing for VIRTIO_NET_F_CTRL_GUEST_OFFLOADS\n\n * VIRTIO_NET_F_GUEST_ANNOUNCE and VIRTIO_NET_F_CTRL_VQ.\n\n *\n\n * Note: devices should always test host features in future - don't create\n\n * new dependencies like this.\n\n *\/\n\n vdev->guest_features = features;\n\n\n\n config_len = qemu_get_be32(f);\n\n\n\n \/*\n\n * There are cases where the incoming config can be bigger or smaller\n\n * than what we have; so load what we have space for, and skip\n\n * any excess that's in the stream.\n\n *\/\n\n qemu_get_buffer(f, vdev->config, MIN(config_len, vdev->config_len));\n\n\n\n while (config_len > vdev->config_len) {\n\n qemu_get_byte(f);\n\n config_len--;\n\n }\n\n\n\n num = qemu_get_be32(f);\n\n\n\n if (num > VIRTIO_QUEUE_MAX) {\n\n error_report(\"Invalid number of virtqueues: 0x%x\", num);\n\n return -1;\n\n }\n\n\n\n for (i = 0; i < num; i++) {\n\n vdev->vq[i].vring.num = qemu_get_be32(f);\n\n if (k->has_variable_vring_alignment) {\n\n vdev->vq[i].vring.align = qemu_get_be32(f);\n\n }\n\n vdev->vq[i].vring.desc = qemu_get_be64(f);\n\n qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);\n\n vdev->vq[i].signalled_used_valid = false;\n\n vdev->vq[i].notification = true;\n\n\n\n if (vdev->vq[i].vring.desc) {\n\n \/* XXX virtio-1 devices *\/\n\n virtio_queue_update_rings(vdev, i);\n\n } else if (vdev->vq[i].last_avail_idx) {\n\n error_report(\"VQ %d address 0x0 \"\n\n \"inconsistent with Host index 0x%x\",\n\n i, vdev->vq[i].last_avail_idx);\n\n return -1;\n\n }\n\n if (k->load_queue) {\n\n ret = k->load_queue(qbus->parent, i, f);\n\n if (ret)\n\n return ret;\n\n }\n\n }\n\n\n\n virtio_notify_vector(vdev, VIRTIO_NO_VECTOR);\n\n\n\n if (vdc->load != NULL) {\n\n ret = vdc->load(vdev, f, version_id);\n\n if (ret) {\n\n return ret;\n\n }\n\n }\n\n\n\n if (vdc->vmsd) {\n\n ret = vmstate_load_state(f, vdc->vmsd, vdev, version_id);\n\n if (ret) {\n\n return ret;\n\n }\n\n }\n\n\n\n \/* Subsections *\/\n\n ret = vmstate_load_state(f, &vmstate_virtio, vdev, 1);\n\n if (ret) {\n\n return ret;\n\n }\n\n\n\n if (vdev->device_endian == VIRTIO_DEVICE_ENDIAN_UNKNOWN) {\n\n vdev->device_endian = virtio_default_endian();\n\n }\n\n\n\n if (virtio_64bit_features_needed(vdev)) {\n\n \/*\n\n * Subsection load filled vdev->guest_features. Run them\n\n * through virtio_set_features to sanity-check them against\n\n * host_features.\n\n *\/\n\n uint64_t features64 = vdev->guest_features;\n\n if (virtio_set_features_nocheck(vdev, features64) < 0) {\n\n error_report(\"Features 0x%\" PRIx64 \" unsupported. \"\n\n \"Allowed features: 0x%\" PRIx64,\n\n features64, vdev->host_features);\n\n return -1;\n\n }\n\n } else {\n\n if (virtio_set_features_nocheck(vdev, features) < 0) {\n\n error_report(\"Features 0x%x unsupported. \"\n\n \"Allowed features: 0x%\" PRIx64,\n\n features, vdev->host_features);\n\n return -1;\n\n }\n\n }\n\n\n\n rcu_read_lock();\n\n for (i = 0; i < num; i++) {\n\n if (vdev->vq[i].vring.desc) {\n\n uint16_t nheads;\n\n nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;\n\n \/* Check it isn't doing strange things with descriptor numbers. *\/\n\n if (nheads > vdev->vq[i].vring.num) {\n\n error_report(\"VQ %d size 0x%x Guest index 0x%x \"\n\n \"inconsistent with Host index 0x%x: delta 0x%x\",\n\n i, vdev->vq[i].vring.num,\n\n vring_avail_idx(&vdev->vq[i]),\n\n vdev->vq[i].last_avail_idx, nheads);\n\n return -1;\n\n }\n\n vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]);\n\n vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]);\n\n\n\n \/*\n\n * Some devices migrate VirtQueueElements that have been popped\n\n * from the avail ring but not yet returned to the used ring.\n\n * Since max ring size < UINT16_MAX it's safe to use modulo\n\n * UINT16_MAX + 1 subtraction.\n\n *\/\n\n vdev->vq[i].inuse = (uint16_t)(vdev->vq[i].last_avail_idx -\n\n vdev->vq[i].used_idx);\n\n if (vdev->vq[i].inuse > vdev->vq[i].vring.num) {\n\n error_report(\"VQ %d size 0x%x < last_avail_idx 0x%x - \"\n\n \"used_idx 0x%x\",\n\n i, vdev->vq[i].vring.num,\n\n vdev->vq[i].last_avail_idx,\n\n vdev->vq[i].used_idx);\n\n return -1;\n\n }\n\n }\n\n }\n\n rcu_read_unlock();\n\n\n\n return 0;\n\n}\n","target":1,"code_token_length":1615,"total_token_length":1851,"max_tokens_setting":2048} +{"idx":333449,"func":"static int decode_ref_pic_list_reordering(H264Context *h){\n\n MpegEncContext * const s = &h->s;\n\n int list, index;\n\n\n\n print_short_term(h);\n\n print_long_term(h);\n\n if(h->slice_type==I_TYPE || h->slice_type==SI_TYPE) return 0; \/\/FIXME move before func\n\n\n\n for(list=0; list<2; list++){\n\n memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]);\n\n\n\n if(get_bits1(&s->gb)){\n\n int pred= h->curr_pic_num;\n\n\n\n for(index=0; ; index++){\n\n int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb);\n\n int pic_id;\n\n int i;\n\n Picture *ref = NULL;\n\n\n\n if(reordering_of_pic_nums_idc==3)\n\n break;\n\n\n\n if(index >= h->ref_count[list]){\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"reference count overflow\\n\");\n\n return -1;\n\n }\n\n\n\n if(reordering_of_pic_nums_idc<3){\n\n if(reordering_of_pic_nums_idc<2){\n\n const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;\n\n\n\n if(abs_diff_pic_num >= h->max_pic_num){\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"abs_diff_pic_num overflow\\n\");\n\n return -1;\n\n }\n\n\n\n if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;\n\n else pred+= abs_diff_pic_num;\n\n pred &= h->max_pic_num - 1;\n\n\n\n for(i= h->short_ref_count-1; i>=0; i--){\n\n ref = h->short_ref[i];\n\n assert(ref->reference == 3);\n\n assert(!ref->long_ref);\n\n if(ref->data[0] != NULL && ref->frame_num == pred && ref->long_ref == 0) \/\/ ignore non existing pictures by testing data[0] pointer\n\n break;\n\n }\n\n if(i>=0)\n\n ref->pic_id= ref->frame_num;\n\n }else{\n\n pic_id= get_ue_golomb(&s->gb); \/\/long_term_pic_idx\n\n ref = h->long_ref[pic_id];\n\n if(ref){\n\n ref->pic_id= pic_id;\n\n assert(ref->reference == 3);\n\n assert(ref->long_ref);\n\n i=0;\n\n }else{\n\n i=-1;\n\n }\n\n }\n\n\n\n if (i < 0) {\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"reference picture missing during reorder\\n\");\n\n memset(&h->ref_list[list][index], 0, sizeof(Picture)); \/\/FIXME\n\n } else {\n\n for(i=index; i+1ref_count[list]; i++){\n\n if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id)\n\n break;\n\n }\n\n for(; i > index; i--){\n\n h->ref_list[list][i]= h->ref_list[list][i-1];\n\n }\n\n h->ref_list[list][index]= *ref;\n\n }\n\n }else{\n\n av_log(h->s.avctx, AV_LOG_ERROR, \"illegal reordering_of_pic_nums_idc\\n\");\n\n return -1;\n\n }\n\n }\n\n }\n\n\n\n if(h->slice_type!=B_TYPE) break;\n\n }\n\n for(list=0; list<2; list++){\n\n for(index= 0; index < h->ref_count[list]; index++){\n\n if(!h->ref_list[list][index].data[0])\n\n h->ref_list[list][index]= s->current_picture;\n\n }\n\n if(h->slice_type!=B_TYPE) break;\n\n }\n\n\n\n if(h->slice_type==B_TYPE && !h->direct_spatial_mv_pred)\n\n direct_dist_scale_factor(h);\n\n direct_ref_list_init(h);\n\n return 0;\n\n}\n","target":1,"code_token_length":869,"total_token_length":1105,"max_tokens_setting":2048} +{"idx":411715,"func":" template\n CImg& draw_line(const int x0, const int y0, const int z0,\n const int x1, const int y1, const int z1,\n const tc *const color, const float opacity=1,\n const unsigned int pattern=~0U, const bool init_hatch=true) {\n if (is_empty()) return *this;\n if (!color)\n throw CImgArgumentException(_cimg_instance\n \"draw_line(): Specified color is (null).\",\n cimg_instance);\n static unsigned int hatch = ~0U - (~0U>>1);\n if (init_hatch) hatch = ~0U - (~0U>>1);\n int nx0 = x0, ny0 = y0, nz0 = z0, nx1 = x1, ny1 = y1, nz1 = z1;\n if (nx0>nx1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);\n if (nx1<0 || nx0>=width()) return *this;\n if (nx0<0) {\n const float D = 1.0f + nx1 - nx0;\n ny0-=(int)((float)nx0*(1.0f + ny1 - ny0)\/D);\n nz0-=(int)((float)nx0*(1.0f + nz1 - nz0)\/D);\n nx0 = 0;\n }\n if (nx1>=width()) {\n const float d = (float)nx1 - width(), D = 1.0f + nx1 - nx0;\n ny1+=(int)(d*(1.0f + ny0 - ny1)\/D);\n nz1+=(int)(d*(1.0f + nz0 - nz1)\/D);\n nx1 = width() - 1;\n }\n if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);\n if (ny1<0 || ny0>=height()) return *this;\n if (ny0<0) {\n const float D = 1.0f + ny1 - ny0;\n nx0-=(int)((float)ny0*(1.0f + nx1 - nx0)\/D);\n nz0-=(int)((float)ny0*(1.0f + nz1 - nz0)\/D);\n ny0 = 0;\n }\n if (ny1>=height()) {\n const float d = (float)ny1 - height(), D = 1.0f + ny1 - ny0;\n nx1+=(int)(d*(1.0f + nx0 - nx1)\/D);\n nz1+=(int)(d*(1.0f + nz0 - nz1)\/D);\n ny1 = height() - 1;\n }\n if (nz0>nz1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);\n if (nz1<0 || nz0>=depth()) return *this;\n if (nz0<0) {\n const float D = 1.0f + nz1 - nz0;\n nx0-=(int)((float)nz0*(1.0f + nx1 - nx0)\/D);\n ny0-=(int)((float)nz0*(1.0f + ny1 - ny0)\/D);\n nz0 = 0;\n }\n if (nz1>=depth()) {\n const float d = (float)nz1 - depth(), D = 1.0f + nz1 - nz0;\n nx1+=(int)(d*(1.0f + nx0 - nx1)\/D);\n ny1+=(int)(d*(1.0f + ny0 - ny1)\/D);\n nz1 = depth() - 1;\n }\n const unsigned int dmax = (unsigned int)cimg::max(cimg::abs(nx1 - nx0),cimg::abs(ny1 - ny0),nz1 - nz0);\n const ulongT whd = (ulongT)_width*_height*_depth;\n const float px = (nx1 - nx0)\/(float)dmax, py = (ny1 - ny0)\/(float)dmax, pz = (nz1 - nz0)\/(float)dmax;\n float x = (float)nx0, y = (float)ny0, z = (float)nz0;\n if (opacity>=1) for (unsigned int t = 0; t<=dmax; ++t) {\n if (!(~pattern) || (~pattern && pattern&hatch)) {\n T* ptrd = data((unsigned int)x,(unsigned int)y,(unsigned int)z);\n const tc *col = color; cimg_forC(*this,c) { *ptrd = (T)*(col++); ptrd+=whd; }\n }\n x+=px; y+=py; z+=pz; if (pattern) { hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1); }\n } else {\n const float nopacity = cimg::abs(opacity), copacity = 1 - std::max(opacity,0.0f);\n for (unsigned int t = 0; t<=dmax; ++t) {\n if (!(~pattern) || (~pattern && pattern&hatch)) {\n T* ptrd = data((unsigned int)x,(unsigned int)y,(unsigned int)z);\n const tc *col = color; cimg_forC(*this,c) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whd; }\n }\n x+=px; y+=py; z+=pz; if (pattern) { hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1); }\n }\n }\n return *this;","target":0,"code_token_length":1309,"total_token_length":1545,"max_tokens_setting":2048} +{"idx":407605,"func":"ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)\n{\n\tldns_status res = LDNS_STATUS_OK;\n\n\t\/*ldns_buffer_printf(buffer, \"%u:\", ldns_rdf_get_type(rdf));*\/\n\tif (rdf) {\n\t\tswitch(ldns_rdf_get_type(rdf)) {\n\t\tcase LDNS_RDF_TYPE_NONE:\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_DNAME:\n\t\t\tres = ldns_rdf2buffer_str_dname(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_INT8:\n\t\t\tres = ldns_rdf2buffer_str_int8(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_INT16:\n\t\t\tres = ldns_rdf2buffer_str_int16(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_INT32:\n\t\t\tres = ldns_rdf2buffer_str_int32(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_PERIOD:\n\t\t\tres = ldns_rdf2buffer_str_period(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_TSIGTIME:\n\t\t\tres = ldns_rdf2buffer_str_tsigtime(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_A:\n\t\t\tres = ldns_rdf2buffer_str_a(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_AAAA:\n\t\t\tres = ldns_rdf2buffer_str_aaaa(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_STR:\n\t\t\tres = ldns_rdf2buffer_str_str(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_APL:\n\t\t\tres = ldns_rdf2buffer_str_apl(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_B32_EXT:\n\t\t\tres = ldns_rdf2buffer_str_b32_ext(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_B64:\n\t\t\tres = ldns_rdf2buffer_str_b64(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_HEX:\n\t\t\tres = ldns_rdf2buffer_str_hex(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_NSEC:\n\t\t\tres = ldns_rdf2buffer_str_nsec(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_NSEC3_SALT:\n\t\t\tres = ldns_rdf2buffer_str_nsec3_salt(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_TYPE:\n\t\t\tres = ldns_rdf2buffer_str_type(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_CLASS:\n\t\t\tres = ldns_rdf2buffer_str_class(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_CERT_ALG:\n\t\t\tres = ldns_rdf2buffer_str_cert_alg(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_ALG:\n\t\t\tres = ldns_rdf2buffer_str_alg(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_UNKNOWN:\n\t\t\tres = ldns_rdf2buffer_str_unknown(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_TIME:\n\t\t\tres = ldns_rdf2buffer_str_time(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_LOC:\n\t\t\tres = ldns_rdf2buffer_str_loc(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_WKS:\n\t\tcase LDNS_RDF_TYPE_SERVICE:\n\t\t\tres = ldns_rdf2buffer_str_wks(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_NSAP:\n\t\t\tres = ldns_rdf2buffer_str_nsap(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_ATMA:\n\t\t\tres = ldns_rdf2buffer_str_atma(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_IPSECKEY:\n\t\t\tres = ldns_rdf2buffer_str_ipseckey(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_TSIG:\n\t\t\tres = ldns_rdf2buffer_str_tsig(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_INT16_DATA:\n\t\t\tres = ldns_rdf2buffer_str_int16_data(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:\n\t\t\tres = ldns_rdf2buffer_str_b32_ext(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_ILNP64:\n\t\t\tres = ldns_rdf2buffer_str_ilnp64(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_EUI48:\n\t\t\tres = ldns_rdf2buffer_str_eui48(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_EUI64:\n\t\t\tres = ldns_rdf2buffer_str_eui64(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_TAG:\n\t\t\tres = ldns_rdf2buffer_str_tag(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_LONG_STR:\n\t\t\tres = ldns_rdf2buffer_str_long_str(buffer, rdf);\n\t\t\tbreak;\n\t\tcase LDNS_RDF_TYPE_MULTI_STR:\n\t\t\tres = ldns_rdf2buffer_str_multi_str(buffer, rdf);\n\t\t\tbreak;\n\t\t}\n\t} else {\n\t\t\/** This will write mangled RRs *\/\n\t\tldns_buffer_printf(buffer, \"(null) \");\n\t\tres = LDNS_STATUS_ERR;\n\t}\n\treturn res;\n}","target":0,"code_token_length":1172,"total_token_length":1408,"max_tokens_setting":2048} +{"idx":54041,"func":" void Compute(OpKernelContext* ctx) override {\n const Tensor& indices_tensor = ctx->input(0);\n OP_REQUIRES(ctx,\n TensorShapeUtils::IsVector(indices_tensor.shape()) ||\n TensorShapeUtils::IsScalar(indices_tensor.shape()),\n errors::InvalidArgument(\n \"The indices can only be scalar or vector, got \\\"\",\n indices_tensor.shape().DebugString(), \"\\\"\"));\n\n const Tensor& dims_tensor = ctx->input(1);\n OP_REQUIRES(\n ctx, TensorShapeUtils::IsVector(dims_tensor.shape()),\n errors::InvalidArgument(\"The indices can only be 1-D, got \\\"\",\n dims_tensor.shape().DebugString(), \"\\\"\"));\n\n auto dims = dims_tensor.vec();\n \/\/ Make sure dims does not contain a zero\n for (int i = 0; i < dims.size(); i++) {\n OP_REQUIRES(\n ctx, dims(i) != 0,\n errors::InvalidArgument(\"Input dims cannot contain a dim of zero, \"\n \"but dims contains zero at index \",\n i));\n }\n\n \/\/ Chek to make sure indices is not out of boundary\n Eigen::Tensor dims_prod_eigen = dims.prod();\n Tidx dims_prod = dims_prod_eigen();\n const Tidx* indices = indices_tensor.flat().data();\n int64 size = indices_tensor.NumElements();\n bool check = std::all_of(indices, indices + size,\n [&](Tidx index) { return index < dims_prod; });\n OP_REQUIRES(ctx, check,\n errors::InvalidArgument(\"index is out of bound as with dims\"));\n\n Eigen::array reverse({true});\n\n Tensor strides_tensor;\n OP_REQUIRES_OK(ctx,\n ctx->allocate_temp(DataTypeToEnum::value,\n TensorShape({dims_tensor.NumElements()}),\n &strides_tensor));\n\n auto strides = strides_tensor.vec();\n strides = dims.reverse(reverse)\n .scan(0, Eigen::internal::ProdReducer(), false)\n .reverse(reverse);\n\n Tensor strides_shifted_tensor;\n OP_REQUIRES_OK(ctx,\n ctx->allocate_temp(DataTypeToEnum::value,\n TensorShape({dims_tensor.NumElements()}),\n &strides_shifted_tensor));\n\n auto strides_shifted = strides_shifted_tensor.vec();\n strides_shifted = dims.reverse(reverse)\n .scan(0, Eigen::internal::ProdReducer(), true)\n .reverse(reverse);\n\n Tensor* output_tensor = nullptr;\n if (TensorShapeUtils::IsScalar(indices_tensor.shape())) {\n OP_REQUIRES_OK(\n ctx, ctx->allocate_output(0, TensorShape({dims_tensor.NumElements()}),\n &output_tensor));\n\n auto output = output_tensor->vec();\n\n output = output.constant(indices_tensor.scalar()());\n output = output.binaryExpr(strides, mod_op()) \/ strides_shifted;\n } else {\n OP_REQUIRES_OK(\n ctx, ctx->allocate_output(0,\n TensorShape({dims_tensor.NumElements(),\n indices_tensor.NumElements()}),\n &output_tensor));\n\n auto output = output_tensor->matrix();\n\n Eigen::array reshape{\n {static_cast(dims_tensor.NumElements()), 1}};\n Eigen::array bcast(\n {1, static_cast(indices_tensor.NumElements())});\n Eigen::array indices_reshape{\n {1, static_cast(indices_tensor.NumElements())}};\n Eigen::array indices_bcast(\n {static_cast(dims_tensor.NumElements()), 1});\n\n output = indices_tensor.vec()\n .reshape(indices_reshape)\n .broadcast(indices_bcast);\n output = output.binaryExpr(strides.reshape(reshape).broadcast(bcast),\n mod_op()) \/\n strides_shifted.reshape(reshape).broadcast(bcast);\n }\n }","target":0,"code_token_length":871,"total_token_length":1107,"max_tokens_setting":2048} +{"idx":286779,"func":"static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,\n\t\t\t struct flowi *fl, struct sock *sk)\n{\n\tstruct sctp_association *asoc = t->asoc;\n\tstruct dst_entry *dst = NULL;\n\tstruct flowi6 *fl6 = &fl->u.ip6;\n\tstruct sctp_bind_addr *bp;\n\tstruct sctp_sockaddr_entry *laddr;\n\tunion sctp_addr *baddr = NULL;\n\tunion sctp_addr *daddr = &t->ipaddr;\n\tunion sctp_addr dst_saddr;\n\t__u8 matchlen = 0;\n\t__u8 bmatchlen;\n\tsctp_scope_t scope;\n\n\tmemset(fl6, 0, sizeof(struct flowi6));\n\tfl6->daddr = daddr->v6.sin6_addr;\n\tfl6->fl6_dport = daddr->v6.sin6_port;\n\tfl6->flowi6_proto = IPPROTO_SCTP;\n\tif (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)\n\t\tfl6->flowi6_oif = daddr->v6.sin6_scope_id;\n\n\tpr_debug(\"%s: dst=%pI6 \", __func__, &fl6->daddr);\n\n\tif (asoc)\n\t\tfl6->fl6_sport = htons(asoc->base.bind_addr.port);\n\n\tif (saddr) {\n\t\tfl6->saddr = saddr->v6.sin6_addr;\n\t\tfl6->fl6_sport = saddr->v6.sin6_port;\n\n\t\tpr_debug(\"src=%pI6 - \", &fl6->saddr);\n\t}\n\n\tdst = ip6_dst_lookup_flow(sk, fl6, NULL, false);\n\tif (!asoc || saddr)\n\t\tgoto out;\n\n\tbp = &asoc->base.bind_addr;\n\tscope = sctp_scope(daddr);\n\t\/* ip6_dst_lookup has filled in the fl6->saddr for us. Check\n\t * to see if we can use it.\n\t *\/\n\tif (!IS_ERR(dst)) {\n\t\t\/* Walk through the bind address list and look for a bind\n\t\t * address that matches the source address of the returned dst.\n\t\t *\/\n\t\tsctp_v6_to_addr(&dst_saddr, &fl6->saddr, htons(bp->port));\n\t\trcu_read_lock();\n\t\tlist_for_each_entry_rcu(laddr, &bp->address_list, list) {\n\t\t\tif (!laddr->valid || (laddr->state != SCTP_ADDR_SRC))\n\t\t\t\tcontinue;\n\n\t\t\t\/* Do not compare against v4 addrs *\/\n\t\t\tif ((laddr->a.sa.sa_family == AF_INET6) &&\n\t\t\t (sctp_v6_cmp_addr(&dst_saddr, &laddr->a))) {\n\t\t\t\trcu_read_unlock();\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\trcu_read_unlock();\n\t\t\/* None of the bound addresses match the source address of the\n\t\t * dst. So release it.\n\t\t *\/\n\t\tdst_release(dst);\n\t\tdst = NULL;\n\t}\n\n\t\/* Walk through the bind address list and try to get the\n\t * best source address for a given destination.\n\t *\/\n\trcu_read_lock();\n\tlist_for_each_entry_rcu(laddr, &bp->address_list, list) {\n\t\tif (!laddr->valid)\n\t\t\tcontinue;\n\t\tif ((laddr->state == SCTP_ADDR_SRC) &&\n\t\t (laddr->a.sa.sa_family == AF_INET6) &&\n\t\t (scope <= sctp_scope(&laddr->a))) {\n\t\t\tbmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a);\n\t\t\tif (!baddr || (matchlen < bmatchlen)) {\n\t\t\t\tbaddr = &laddr->a;\n\t\t\t\tmatchlen = bmatchlen;\n\t\t\t}\n\t\t}\n\t}\n\trcu_read_unlock();\n\tif (baddr) {\n\t\tfl6->saddr = baddr->v6.sin6_addr;\n\t\tfl6->fl6_sport = baddr->v6.sin6_port;\n\t\tdst = ip6_dst_lookup_flow(sk, fl6, NULL, false);\n\t}\n\nout:\n\tif (!IS_ERR_OR_NULL(dst)) {\n\t\tstruct rt6_info *rt;\n\n\t\trt = (struct rt6_info *)dst;\n\t\tt->dst = dst;\n\t\tt->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;\n\t\tpr_debug(\"rt6_dst:%pI6 rt6_src:%pI6\\n\", &rt->rt6i_dst.addr,\n\t\t\t &fl6->saddr);\n\t} else {\n\t\tt->dst = NULL;\n\n\t\tpr_debug(\"no route\\n\");\n\t}\n}","target":1,"code_token_length":1009,"total_token_length":1245,"max_tokens_setting":2048} +{"idx":195574,"func":"OJPEGReadHeaderInfoSec(TIFF* tif)\n{\n\tstatic const char module[]=\"OJPEGReadHeaderInfoSec\";\n\tOJPEGState* sp=(OJPEGState*)tif->tif_data;\n\tuint8 m;\n\tuint16 n;\n\tuint8 o;\n\tif (sp->file_size==0)\n\t\tsp->file_size=TIFFGetFileSize(tif);\n\tif (sp->jpeg_interchange_format!=0)\n\t{\n\t\tif (sp->jpeg_interchange_format>=sp->file_size)\n\t\t{\n\t\t\tsp->jpeg_interchange_format=0;\n\t\t\tsp->jpeg_interchange_format_length=0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size))\n\t\t\t\tsp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format;\n\t\t}\n\t}\n\tsp->in_buffer_source=osibsNotSetYet;\n\tsp->in_buffer_next_strile=0;\n\tsp->in_buffer_strile_count=tif->tif_dir.td_nstrips;\n\tsp->in_buffer_file_togo=0;\n\tsp->in_buffer_togo=0;\n\tdo\n\t{\n\t\tif (OJPEGReadBytePeek(sp,&m)==0)\n\t\t\treturn(0);\n\t\tif (m!=255)\n\t\t\tbreak;\n\t\tOJPEGReadByteAdvance(sp);\n\t\tdo\n\t\t{\n\t\t\tif (OJPEGReadByte(sp,&m)==0)\n\t\t\t\treturn(0);\n\t\t} while(m==255);\n\t\tswitch(m)\n\t\t{\n\t\t\tcase JPEG_MARKER_SOI:\n\t\t\t\t\/* this type of marker has no data, and should be skipped *\/\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_COM:\n\t\t\tcase JPEG_MARKER_APP0:\n\t\t\tcase JPEG_MARKER_APP0+1:\n\t\t\tcase JPEG_MARKER_APP0+2:\n\t\t\tcase JPEG_MARKER_APP0+3:\n\t\t\tcase JPEG_MARKER_APP0+4:\n\t\t\tcase JPEG_MARKER_APP0+5:\n\t\t\tcase JPEG_MARKER_APP0+6:\n\t\t\tcase JPEG_MARKER_APP0+7:\n\t\t\tcase JPEG_MARKER_APP0+8:\n\t\t\tcase JPEG_MARKER_APP0+9:\n\t\t\tcase JPEG_MARKER_APP0+10:\n\t\t\tcase JPEG_MARKER_APP0+11:\n\t\t\tcase JPEG_MARKER_APP0+12:\n\t\t\tcase JPEG_MARKER_APP0+13:\n\t\t\tcase JPEG_MARKER_APP0+14:\n\t\t\tcase JPEG_MARKER_APP0+15:\n\t\t\t\t\/* this type of marker has data, but it has no use to us (and no place here) and should be skipped *\/\n\t\t\t\tif (OJPEGReadWord(sp,&n)==0)\n\t\t\t\t\treturn(0);\n\t\t\t\tif (n<2)\n\t\t\t\t{\n\t\t\t\t\tif (sp->subsamplingcorrect==0)\n\t\t\t\t\t\tTIFFErrorExt(tif->tif_clientdata,module,\"Corrupt JPEG data\");\n\t\t\t\t\treturn(0);\n\t\t\t\t}\n\t\t\t\tif (n>2)\n\t\t\t\t\tOJPEGReadSkip(sp,n-2);\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_DRI:\n\t\t\t\tif (OJPEGReadHeaderInfoSecStreamDri(tif)==0)\n\t\t\t\t\treturn(0);\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_DQT:\n\t\t\t\tif (OJPEGReadHeaderInfoSecStreamDqt(tif)==0)\n\t\t\t\t\treturn(0);\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_DHT:\n\t\t\t\tif (OJPEGReadHeaderInfoSecStreamDht(tif)==0)\n\t\t\t\t\treturn(0);\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_SOF0:\n\t\t\tcase JPEG_MARKER_SOF1:\n\t\t\tcase JPEG_MARKER_SOF3:\n\t\t\t\tif (OJPEGReadHeaderInfoSecStreamSof(tif,m)==0)\n\t\t\t\t\treturn(0);\n\t\t\t\tif (sp->subsamplingcorrect!=0)\n\t\t\t\t\treturn(1);\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_SOS:\n\t\t\t\tif (sp->subsamplingcorrect!=0)\n\t\t\t\t\treturn(1);\n\t\t\t\tassert(sp->plane_sample_offset==0);\n\t\t\t\tif (OJPEGReadHeaderInfoSecStreamSos(tif)==0)\n\t\t\t\t\treturn(0);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata,module,\"Unknown marker type %d in JPEG data\",m);\n\t\t\t\treturn(0);\n\t\t}\n\t} while(m!=JPEG_MARKER_SOS);\n\tif (sp->subsamplingcorrect)\n\t\treturn(1);\n\tif (sp->sof_log==0)\n\t{\n\t\tif (OJPEGReadHeaderInfoSecTablesQTable(tif)==0)\n\t\t\treturn(0);\n\t\tsp->sof_marker_id=JPEG_MARKER_SOF0;\n\t\tfor (o=0; osamples_per_pixel; o++)\n\t\t\tsp->sof_c[o]=o;\n\t\tsp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver);\n\t\tfor (o=1; osamples_per_pixel; o++)\n\t\t\tsp->sof_hv[o]=17;\n\t\tsp->sof_x=sp->strile_width;\n\t\tsp->sof_y=sp->strile_length_total;\n\t\tsp->sof_log=1;\n\t\tif (OJPEGReadHeaderInfoSecTablesDcTable(tif)==0)\n\t\t\treturn(0);\n\t\tif (OJPEGReadHeaderInfoSecTablesAcTable(tif)==0)\n\t\t\treturn(0);\n\t\tfor (o=1; osamples_per_pixel; o++)\n\t\t\tsp->sos_cs[o]=o;\n\t}\n\treturn(1);\n}\n","target":0,"code_token_length":1155,"total_token_length":1391,"max_tokens_setting":2048} +{"idx":220262,"func":"WORD32 ih264d_get_vui_params(iv_obj_t *dec_hdl,\n void *pv_api_ip,\n void *pv_api_op)\n{\n ih264d_ctl_get_vui_params_ip_t *ps_ip;\n ih264d_ctl_get_vui_params_op_t *ps_op;\n dec_struct_t *ps_dec = dec_hdl->pv_codec_handle;\n dec_seq_params_t *ps_sps;\n vui_t *ps_vui;\n WORD32 i;\n UWORD32 u4_size;\n\n ps_ip = (ih264d_ctl_get_vui_params_ip_t *)pv_api_ip;\n ps_op = (ih264d_ctl_get_vui_params_op_t *)pv_api_op;\n UNUSED(ps_ip);\n\n u4_size = ps_op->u4_size;\n memset(ps_op, 0, sizeof(ih264d_ctl_get_vui_params_op_t));\n ps_op->u4_size = u4_size;\n\n if(NULL == ps_dec->ps_cur_sps)\n {\n ps_op->u4_error_code = ERROR_VUI_PARAMS_NOT_FOUND;\n return IV_FAIL;\n }\n\n ps_sps = ps_dec->ps_cur_sps;\n if((0 == ps_sps->u1_is_valid)\n || (0 == ps_sps->u1_vui_parameters_present_flag))\n {\n ps_op->u4_error_code = ERROR_VUI_PARAMS_NOT_FOUND;\n return IV_FAIL;\n }\n\n ps_vui = &ps_sps->s_vui;\n\n ps_op->u1_aspect_ratio_idc = ps_vui->u1_aspect_ratio_idc;\n ps_op->u2_sar_width = ps_vui->u2_sar_width;\n ps_op->u2_sar_height = ps_vui->u2_sar_height;\n ps_op->u1_overscan_appropriate_flag = ps_vui->u1_overscan_appropriate_flag;\n ps_op->u1_video_format = ps_vui->u1_video_format;\n ps_op->u1_video_full_range_flag = ps_vui->u1_video_full_range_flag;\n ps_op->u1_colour_primaries = ps_vui->u1_colour_primaries;\n ps_op->u1_tfr_chars = ps_vui->u1_tfr_chars;\n ps_op->u1_matrix_coeffs = ps_vui->u1_matrix_coeffs;\n ps_op->u1_cr_top_field = ps_vui->u1_cr_top_field;\n ps_op->u1_cr_bottom_field = ps_vui->u1_cr_bottom_field;\n ps_op->u4_num_units_in_tick = ps_vui->u4_num_units_in_tick;\n ps_op->u4_time_scale = ps_vui->u4_time_scale;\n ps_op->u1_fixed_frame_rate_flag = ps_vui->u1_fixed_frame_rate_flag;\n ps_op->u1_nal_hrd_params_present = ps_vui->u1_nal_hrd_params_present;\n ps_op->u1_vcl_hrd_params_present = ps_vui->u1_vcl_hrd_params_present;\n ps_op->u1_low_delay_hrd_flag = ps_vui->u1_low_delay_hrd_flag;\n ps_op->u1_pic_struct_present_flag = ps_vui->u1_pic_struct_present_flag;\n ps_op->u1_bitstream_restriction_flag = ps_vui->u1_bitstream_restriction_flag;\n ps_op->u1_mv_over_pic_boundaries_flag = ps_vui->u1_mv_over_pic_boundaries_flag;\n ps_op->u4_max_bytes_per_pic_denom = ps_vui->u4_max_bytes_per_pic_denom;\n ps_op->u4_max_bits_per_mb_denom = ps_vui->u4_max_bits_per_mb_denom;\n ps_op->u4_log2_max_mv_length_horz = ps_vui->u4_log2_max_mv_length_horz;\n ps_op->u4_log2_max_mv_length_vert = ps_vui->u4_log2_max_mv_length_vert;\n ps_op->u4_num_reorder_frames = ps_vui->u4_num_reorder_frames;\n ps_op->u4_max_dec_frame_buffering = ps_vui->u4_max_dec_frame_buffering;\n\n return IV_SUCCESS;\n}\n","target":0,"code_token_length":936,"total_token_length":1172,"max_tokens_setting":2048} +{"idx":336193,"func":"static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,\n\n\t\t\t\t int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,\n\n\t\t\t uint8_t *dest, int dstW, int dstY)\n\n{\n\n\tint dummy=0;\n\n\tswitch(c->dstFormat)\n\n\t{\n\n#ifdef HAVE_MMX\n\n\tcase IMGFMT_BGR32:\n\n\t\t{\n\n\t\t\tasm volatile(\n\n\t\t\t\tYSCALEYUV2RGBX\n\n\t\t\t\tWRITEBGR32(%4, %5, %%REGa)\n\n\n\n\t\t\t:: \"r\" (&c->redDither), \n\n\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\n\t\t\t \"r\" (dest), \"m\" (dstW)\n\n\t\t\t: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n\n\t\t\t);\n\n\t\t}\n\n\t\tbreak;\n\n\tcase IMGFMT_BGR24:\n\n\t\t{\n\n\t\t\tasm volatile(\n\n\t\t\t\tYSCALEYUV2RGBX\n\n\t\t\t\t\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_b\"\\n\\t\" \/\/FIXME optimize\n\n\t\t\t\t\"add %4, %%\"REG_b\"\t\t\t\\n\\t\"\n\n\t\t\t\tWRITEBGR24(%%REGb, %5, %%REGa)\n\n\n\n\t\t\t:: \"r\" (&c->redDither), \n\n\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\n\t\t\t \"r\" (dest), \"m\" (dstW)\n\n\t\t\t: \"%\"REG_a, \"%\"REG_b, \"%\"REG_d, \"%\"REG_S \/\/FIXME ebx\n\n\t\t\t);\n\n\t\t}\n\n\t\tbreak;\n\n\tcase IMGFMT_BGR15:\n\n\t\t{\n\n\t\t\tasm volatile(\n\n\t\t\t\tYSCALEYUV2RGBX\n\n\t\t\/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 *\/\n\n#ifdef DITHER1XBPP\n\n\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\n\t\t\t\t\"paddusb \"MANGLE(g5Dither)\", %%mm4\\n\\t\"\n\n\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n\n#endif\n\n\n\n\t\t\t\tWRITEBGR15(%4, %5, %%REGa)\n\n\n\n\t\t\t:: \"r\" (&c->redDither), \n\n\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\n\t\t\t \"r\" (dest), \"m\" (dstW)\n\n\t\t\t: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n\n\t\t\t);\n\n\t\t}\n\n\t\tbreak;\n\n\tcase IMGFMT_BGR16:\n\n\t\t{\n\n\t\t\tasm volatile(\n\n\t\t\t\tYSCALEYUV2RGBX\n\n\t\t\/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 *\/\n\n#ifdef DITHER1XBPP\n\n\t\t\t\t\"paddusb \"MANGLE(b5Dither)\", %%mm2\\n\\t\"\n\n\t\t\t\t\"paddusb \"MANGLE(g6Dither)\", %%mm4\\n\\t\"\n\n\t\t\t\t\"paddusb \"MANGLE(r5Dither)\", %%mm5\\n\\t\"\n\n#endif\n\n\n\n\t\t\t\tWRITEBGR16(%4, %5, %%REGa)\n\n\n\n\t\t\t:: \"r\" (&c->redDither), \n\n\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\n\t\t\t \"r\" (dest), \"m\" (dstW)\n\n\t\t\t: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n\n\t\t\t);\n\n\t\t}\n\n\t\tbreak;\n\n\tcase IMGFMT_YUY2:\n\n\t\t{\n\n\t\t\tasm volatile(\n\n\t\t\t\tYSCALEYUV2PACKEDX\n\n\t\t\/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 *\/\n\n\n\n\t\t\t\t\"psraw $3, %%mm3\t\t\\n\\t\"\n\n\t\t\t\t\"psraw $3, %%mm4\t\t\\n\\t\"\n\n\t\t\t\t\"psraw $3, %%mm1\t\t\\n\\t\"\n\n\t\t\t\t\"psraw $3, %%mm7\t\t\\n\\t\"\n\n\t\t\t\tWRITEYUY2(%4, %5, %%REGa)\n\n\n\n\t\t\t:: \"r\" (&c->redDither), \n\n\t\t\t \"m\" (dummy), \"m\" (dummy), \"m\" (dummy),\n\n\t\t\t \"r\" (dest), \"m\" (dstW)\n\n\t\t\t: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n\n\t\t\t);\n\n\t\t}\n\n\t\tbreak;\n\n#endif\n\n\tdefault:\n\n#ifdef HAVE_ALTIVEC\n\n\t\t\/* The following list of supported dstFormat values should\n\n\t\t match what's found in the body of altivec_yuv2packedX() *\/\n\n\t\tif(c->dstFormat==IMGFMT_ABGR || c->dstFormat==IMGFMT_BGRA ||\n\n\t\t c->dstFormat==IMGFMT_BGR24 || c->dstFormat==IMGFMT_RGB24 ||\n\n\t\t c->dstFormat==IMGFMT_RGBA || c->dstFormat==IMGFMT_ARGB)\n\n\t\t\taltivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,\n\n\t\t\t\t chrFilter, chrSrc, chrFilterSize,\n\n\t\t\t\t dest, dstW, dstY);\n\n\t\telse\n\n#endif\n\n\t\t\tyuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,\n\n\t\t\t\t chrFilter, chrSrc, chrFilterSize,\n\n\t\t\t\t dest, dstW, dstY);\n\n\t\tbreak;\n\n\t}\n\n}\n","target":1,"code_token_length":1198,"total_token_length":1434,"max_tokens_setting":2048} +{"idx":217964,"func":"standard_info_part1(standard_display *dp, png_structp pp, png_infop pi)\n{\n if (png_get_bit_depth(pp, pi) != dp->bit_depth)\n png_error(pp, \"validate: bit depth changed\");\n\n if (png_get_color_type(pp, pi) != dp->colour_type)\n png_error(pp, \"validate: color type changed\");\n\n if (png_get_filter_type(pp, pi) != PNG_FILTER_TYPE_BASE)\n png_error(pp, \"validate: filter type changed\");\n\n if (png_get_interlace_type(pp, pi) != dp->interlace_type)\n png_error(pp, \"validate: interlacing changed\");\n\n if (png_get_compression_type(pp, pi) != PNG_COMPRESSION_TYPE_BASE)\n png_error(pp, \"validate: compression type changed\");\n\n dp->w = png_get_image_width(pp, pi);\n\n if (dp->w != standard_width(pp, dp->id))\n png_error(pp, \"validate: image width changed\");\n\n dp->h = png_get_image_height(pp, pi);\n\n if (dp->h != standard_height(pp, dp->id))\n png_error(pp, \"validate: image height changed\");\n\n \/* Record (but don't check at present) the input sBIT according to the colour\n * type information.\n *\/\n {\n png_color_8p sBIT = 0;\n\n if (png_get_sBIT(pp, pi, &sBIT) & PNG_INFO_sBIT)\n {\n int sBIT_invalid = 0;\n\n if (sBIT == 0)\n png_error(pp, \"validate: unexpected png_get_sBIT result\");\n\n if (dp->colour_type & PNG_COLOR_MASK_COLOR)\n {\n if (sBIT->red == 0 || sBIT->red > dp->bit_depth)\n sBIT_invalid = 1;\n else\n dp->red_sBIT = sBIT->red;\n\n if (sBIT->green == 0 || sBIT->green > dp->bit_depth)\n sBIT_invalid = 1;\n else\n dp->green_sBIT = sBIT->green;\n\n if (sBIT->blue == 0 || sBIT->blue > dp->bit_depth)\n sBIT_invalid = 1;\n else\n dp->blue_sBIT = sBIT->blue;\n }\n\n else \/* !COLOR *\/\n {\n if (sBIT->gray == 0 || sBIT->gray > dp->bit_depth)\n sBIT_invalid = 1;\n else\n dp->blue_sBIT = dp->green_sBIT = dp->red_sBIT = sBIT->gray;\n }\n\n \/* All 8 bits in tRNS for a palette image are significant - see the\n * spec.\n *\/\n if (dp->colour_type & PNG_COLOR_MASK_ALPHA)\n {\n if (sBIT->alpha == 0 || sBIT->alpha > dp->bit_depth)\n sBIT_invalid = 1;\n else\n dp->alpha_sBIT = sBIT->alpha;\n }\n\n if (sBIT_invalid)\n png_error(pp, \"validate: sBIT value out of range\");\n }\n }\n\n \/* Important: this is validating the value *before* any transforms have been\n * put in place. It doesn't matter for the standard tests, where there are\n * no transforms, but it does for other tests where rowbytes may change after\n * png_read_update_info.\n *\/\n if (png_get_rowbytes(pp, pi) != standard_rowsize(pp, dp->id))\n png_error(pp, \"validate: row size changed\");\n\n \/* Validate the colour type 3 palette (this can be present on other color\n * types.)\n *\/\n standard_palette_validate(dp, pp, pi);\n\n \/* In any case always check for a tranparent color (notice that the\n * colour type 3 case must not give a successful return on the get_tRNS call\n * with these arguments!)\n *\/\n {\n png_color_16p trans_color = 0;\n\n if (png_get_tRNS(pp, pi, 0, 0, &trans_color) & PNG_INFO_tRNS)\n {\n if (trans_color == 0)\n png_error(pp, \"validate: unexpected png_get_tRNS (color) result\");\n\n switch (dp->colour_type)\n {\n\n case 0:\n dp->transparent.red = dp->transparent.green = dp->transparent.blue =\n trans_color->gray;\n dp->has_tRNS = 1;\n break;\n \n case 2:\n dp->transparent.red = trans_color->red;\n dp->transparent.green = trans_color->green;\n dp->transparent.blue = trans_color->blue;\n dp->has_tRNS = 1;\n break;\n \n case 3:\n \/* Not expected because it should result in the array case\n * above.\n *\/\n png_error(pp, \"validate: unexpected png_get_tRNS result\");\n break;\n\n default:\n png_error(pp, \"validate: invalid tRNS chunk with alpha image\");\n }\n }\n }\n\n \/* Read the number of passes - expected to match the value used when\n * creating the image (interlaced or not). This has the side effect of\n\n * turning on interlace handling (if do_interlace is not set.)\n *\/\n dp->npasses = npasses_from_interlace_type(pp, dp->interlace_type);\n if (!dp->do_interlace)\n {\n# ifdef PNG_READ_INTERLACING_SUPPORTED\n if (dp->npasses != png_set_interlace_handling(pp))\n png_error(pp, \"validate: file changed interlace type\");\n# else \/* !READ_INTERLACING *\/\n \/* This should never happen: the relevant tests (!do_interlace) should\n * not be run.\n *\/\n if (dp->npasses > 1)\n png_error(pp, \"validate: no libpng interlace support\");\n# endif \/* !READ_INTERLACING *\/\n }\n \n \/* Caller calls png_read_update_info or png_start_read_image now, then calls\n * part2.\n *\/\n}\n","target":0,"code_token_length":1272,"total_token_length":1508,"max_tokens_setting":2048} +{"idx":232460,"func":"MagickExport Image *AdaptiveThresholdImage(const Image *image,\n const size_t width,const size_t height,const ssize_t offset,\n ExceptionInfo *exception)\n{\n#define ThresholdImageTag \"Threshold\/Image\"\n\n CacheView\n *image_view,\n *threshold_view;\n\n Image\n *threshold_image;\n\n MagickBooleanType\n status;\n\n MagickOffsetType\n progress;\n\n MagickPixelPacket\n zero;\n\n MagickRealType\n number_pixels;\n\n ssize_t\n y;\n\n assert(image != (const Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n threshold_image=CloneImage(image,0,0,MagickTrue,exception);\n if (threshold_image == (Image *) NULL)\n return((Image *) NULL);\n if (width == 0)\n return(threshold_image);\n if (SetImageStorageClass(threshold_image,DirectClass) == MagickFalse)\n {\n InheritException(exception,&threshold_image->exception);\n threshold_image=DestroyImage(threshold_image);\n return((Image *) NULL);\n }\n \/*\n Local adaptive threshold.\n *\/\n status=MagickTrue;\n progress=0;\n GetMagickPixelPacket(image,&zero);\n number_pixels=(MagickRealType) (width*height);\n image_view=AcquireVirtualCacheView(image,exception);\n threshold_view=AcquireAuthenticCacheView(threshold_image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static) shared(progress,status) \\\n magick_number_threads(image,threshold_image,image->rows,1)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n MagickBooleanType\n sync;\n\n MagickPixelPacket\n channel_bias,\n channel_sum;\n\n register const IndexPacket\n *magick_restrict indexes;\n\n register const PixelPacket\n *magick_restrict p,\n *magick_restrict r;\n\n register IndexPacket\n *magick_restrict threshold_indexes;\n\n register PixelPacket\n *magick_restrict q;\n\n register ssize_t\n x;\n\n ssize_t\n u,\n v;\n\n if (status == MagickFalse)\n continue;\n p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width\/2L),y-(ssize_t)\n height\/2L,image->columns+width,height,exception);\n q=GetCacheViewAuthenticPixels(threshold_view,0,y,threshold_image->columns,1,\n exception);\n if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))\n {\n status=MagickFalse;\n continue;\n }\n indexes=GetCacheViewVirtualIndexQueue(image_view);\n threshold_indexes=GetCacheViewAuthenticIndexQueue(threshold_view);\n channel_bias=zero;\n channel_sum=zero;\n r=p;\n for (v=0; v < (ssize_t) height; v++)\n {\n for (u=0; u < (ssize_t) width; u++)\n {\n if (u == (ssize_t) (width-1))\n {\n channel_bias.red+=r[u].red;\n channel_bias.green+=r[u].green;\n channel_bias.blue+=r[u].blue;\n channel_bias.opacity+=r[u].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_bias.index=(MagickRealType)\n GetPixelIndex(indexes+(r-p)+u);\n }\n channel_sum.red+=r[u].red;\n channel_sum.green+=r[u].green;\n channel_sum.blue+=r[u].blue;\n channel_sum.opacity+=r[u].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_sum.index=(MagickRealType) GetPixelIndex(indexes+(r-p)+u);\n }\n r+=image->columns+width;\n }\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n MagickPixelPacket\n mean;\n\n mean=zero;\n r=p;\n channel_sum.red-=channel_bias.red;\n channel_sum.green-=channel_bias.green;\n channel_sum.blue-=channel_bias.blue;\n channel_sum.opacity-=channel_bias.opacity;\n channel_sum.index-=channel_bias.index;\n channel_bias=zero;\n for (v=0; v < (ssize_t) height; v++)\n {\n channel_bias.red+=r[0].red;\n channel_bias.green+=r[0].green;\n channel_bias.blue+=r[0].blue;\n channel_bias.opacity+=r[0].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_bias.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+0);\n channel_sum.red+=r[width-1].red;\n channel_sum.green+=r[width-1].green;\n channel_sum.blue+=r[width-1].blue;\n channel_sum.opacity+=r[width-1].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_sum.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+\n width-1);\n r+=image->columns+width;\n }\n mean.red=(MagickRealType) (channel_sum.red\/number_pixels+offset);\n mean.green=(MagickRealType) (channel_sum.green\/number_pixels+offset);\n mean.blue=(MagickRealType) (channel_sum.blue\/number_pixels+offset);\n mean.opacity=(MagickRealType) (channel_sum.opacity\/number_pixels+offset);\n if (image->colorspace == CMYKColorspace)\n mean.index=(MagickRealType) (channel_sum.index\/number_pixels+offset);\n SetPixelRed(q,((MagickRealType) GetPixelRed(q) <= mean.red) ?\n 0 : QuantumRange);\n SetPixelGreen(q,((MagickRealType) GetPixelGreen(q) <= mean.green) ?\n 0 : QuantumRange);\n SetPixelBlue(q,((MagickRealType) GetPixelBlue(q) <= mean.blue) ?\n 0 : QuantumRange);\n SetPixelOpacity(q,((MagickRealType) GetPixelOpacity(q) <= mean.opacity) ?\n 0 : QuantumRange);\n if (image->colorspace == CMYKColorspace)\n SetPixelIndex(threshold_indexes+x,(((MagickRealType) GetPixelIndex(\n threshold_indexes+x) <= mean.index) ? 0 : QuantumRange));\n p++;\n q++;\n }\n sync=SyncCacheViewAuthenticPixels(threshold_view,exception);\n if (sync == MagickFalse)\n status=MagickFalse;\n if (image->progress_monitor != (MagickProgressMonitor) NULL)\n {\n MagickBooleanType\n proceed;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp atomic\n#endif\n progress++;\n proceed=SetImageProgress(image,ThresholdImageTag,progress,image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n threshold_view=DestroyCacheView(threshold_view);\n image_view=DestroyCacheView(image_view);\n if (status == MagickFalse)\n threshold_image=DestroyImage(threshold_image);\n return(threshold_image);\n}\n","target":0,"code_token_length":1615,"total_token_length":1851,"max_tokens_setting":2048} +{"idx":323404,"func":"int qemu_loadvm_state(QEMUFile *f)\n\n{\n\n LIST_HEAD(, LoadStateEntry) loadvm_handlers =\n\n LIST_HEAD_INITIALIZER(loadvm_handlers);\n\n LoadStateEntry *le, *new_le;\n\n uint8_t section_type;\n\n unsigned int v;\n\n int ret;\n\n\n\n v = qemu_get_be32(f);\n\n if (v != QEMU_VM_FILE_MAGIC)\n\n return -EINVAL;\n\n\n\n v = qemu_get_be32(f);\n\n if (v == QEMU_VM_FILE_VERSION_COMPAT) {\n\n fprintf(stderr, \"SaveVM v2 format is obsolete and don't work anymore\\n\");\n\n return -ENOTSUP;\n\n }\n\n if (v != QEMU_VM_FILE_VERSION)\n\n return -ENOTSUP;\n\n\n\n while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {\n\n uint32_t instance_id, version_id, section_id;\n\n SaveStateEntry *se;\n\n char idstr[257];\n\n int len;\n\n\n\n switch (section_type) {\n\n case QEMU_VM_SECTION_START:\n\n case QEMU_VM_SECTION_FULL:\n\n \/* Read section start *\/\n\n section_id = qemu_get_be32(f);\n\n len = qemu_get_byte(f);\n\n qemu_get_buffer(f, (uint8_t *)idstr, len);\n\n idstr[len] = 0;\n\n instance_id = qemu_get_be32(f);\n\n version_id = qemu_get_be32(f);\n\n\n\n \/* Find savevm section *\/\n\n se = find_se(idstr, instance_id);\n\n if (se == NULL) {\n\n fprintf(stderr, \"Unknown savevm section or instance '%s' %d\\n\", idstr, instance_id);\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n\n\n \/* Validate version *\/\n\n if (version_id > se->version_id) {\n\n fprintf(stderr, \"savevm: unsupported version %d for '%s' v%d\\n\",\n\n version_id, idstr, se->version_id);\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n\n\n \/* Add entry *\/\n\n le = qemu_mallocz(sizeof(*le));\n\n\n\n le->se = se;\n\n le->section_id = section_id;\n\n le->version_id = version_id;\n\n LIST_INSERT_HEAD(&loadvm_handlers, le, entry);\n\n\n\n ret = vmstate_load(f, le->se, le->version_id);\n\n if (ret < 0) {\n\n fprintf(stderr, \"qemu: warning: error while loading state for instance 0x%x of device '%s'\\n\",\n\n instance_id, idstr);\n\n goto out;\n\n }\n\n break;\n\n case QEMU_VM_SECTION_PART:\n\n case QEMU_VM_SECTION_END:\n\n section_id = qemu_get_be32(f);\n\n\n\n LIST_FOREACH(le, &loadvm_handlers, entry) {\n\n if (le->section_id == section_id) {\n\n break;\n\n }\n\n }\n\n if (le == NULL) {\n\n fprintf(stderr, \"Unknown savevm section %d\\n\", section_id);\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n\n\n ret = vmstate_load(f, le->se, le->version_id);\n\n if (ret < 0) {\n\n fprintf(stderr, \"qemu: warning: error while loading state section id %d\\n\",\n\n section_id);\n\n goto out;\n\n }\n\n break;\n\n default:\n\n fprintf(stderr, \"Unknown savevm section type %d\\n\", section_type);\n\n ret = -EINVAL;\n\n goto out;\n\n }\n\n }\n\n\n\n ret = 0;\n\n\n\nout:\n\n LIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {\n\n LIST_REMOVE(le, entry);\n\n qemu_free(le);\n\n }\n\n\n\n if (qemu_file_has_error(f))\n\n ret = -EIO;\n\n\n\n return ret;\n\n}\n","target":0,"code_token_length":797,"total_token_length":1033,"max_tokens_setting":2048} +{"idx":292635,"func":"var2fpos(\n typval_T\t*varp,\n int\t\tdollar_lnum,\t\/\/ TRUE when $ is last line\n int\t\t*fnum,\t\t\/\/ set to fnum for '0, 'A, etc.\n int\t\tcharcol)\t\/\/ return character column\n{\n char_u\t\t*name;\n static pos_T\tpos;\n pos_T\t\t*pp;\n\n \/\/ Argument can be [lnum, col, coladd].\n if (varp->v_type == VAR_LIST)\n {\n\tlist_T\t\t*l;\n\tint\t\tlen;\n\tint\t\terror = FALSE;\n\tlistitem_T\t*li;\n\n\tl = varp->vval.v_list;\n\tif (l == NULL)\n\t return NULL;\n\n\t\/\/ Get the line number\n\tpos.lnum = list_find_nr(l, 0L, &error);\n\tif (error || pos.lnum <= 0 || pos.lnum > curbuf->b_ml.ml_line_count)\n\t return NULL;\t\/\/ invalid line number\n\tif (charcol)\n\t len = (long)mb_charlen(ml_get(pos.lnum));\n\telse\n\t len = (long)STRLEN(ml_get(pos.lnum));\n\n\t\/\/ Get the column number\n\t\/\/ We accept \"$\" for the column number: last column.\n\tli = list_find(l, 1L);\n\tif (li != NULL && li->li_tv.v_type == VAR_STRING\n\t\t&& li->li_tv.vval.v_string != NULL\n\t\t&& STRCMP(li->li_tv.vval.v_string, \"$\") == 0)\n\t{\n\t pos.col = len + 1;\n\t}\n\telse\n\t{\n\t pos.col = list_find_nr(l, 1L, &error);\n\t if (error)\n\t\treturn NULL;\n\t}\n\n\t\/\/ Accept a position up to the NUL after the line.\n\tif (pos.col == 0 || (int)pos.col > len + 1)\n\t return NULL;\t\/\/ invalid column number\n\t--pos.col;\n\n\t\/\/ Get the virtual offset. Defaults to zero.\n\tpos.coladd = list_find_nr(l, 2L, &error);\n\tif (error)\n\t pos.coladd = 0;\n\n\treturn &pos;\n }\n\n if (in_vim9script() && check_for_string_arg(varp, 0) == FAIL)\n\treturn NULL;\n\n name = tv_get_string_chk(varp);\n if (name == NULL)\n\treturn NULL;\n if (name[0] == '.')\t\t\t\t\/\/ cursor\n {\n\tpos = curwin->w_cursor;\n\tif (charcol)\n\t pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col);\n\treturn &pos;\n }\n if (name[0] == 'v' && name[1] == NUL)\t\/\/ Visual start\n {\n\tif (VIsual_active)\n\t pos = VIsual;\n\telse\n\t pos = curwin->w_cursor;\n\tif (charcol)\n\t pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col);\n\treturn &pos;\n }\n if (name[0] == '\\'')\t\t\t\/\/ mark\n {\n\tpp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);\n\tif (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)\n\t return NULL;\n\tif (charcol)\n\t pp->col = buf_byteidx_to_charidx(curbuf, pp->lnum, pp->col);\n\treturn pp;\n }\n\n pos.coladd = 0;\n\n if (name[0] == 'w' && dollar_lnum)\n {\n\tpos.col = 0;\n\tif (name[1] == '0')\t\t\/\/ \"w0\": first visible line\n\t{\n\t update_topline();\n\t \/\/ In silent Ex mode topline is zero, but that's not a valid line\n\t \/\/ number; use one instead.\n\t pos.lnum = curwin->w_topline > 0 ? curwin->w_topline : 1;\n\t return &pos;\n\t}\n\telse if (name[1] == '$')\t\/\/ \"w$\": last visible line\n\t{\n\t validate_botline();\n\t \/\/ In silent Ex mode botline is zero, return zero then.\n\t pos.lnum = curwin->w_botline > 0 ? curwin->w_botline - 1 : 0;\n\t return &pos;\n\t}\n }\n else if (name[0] == '$')\t\t\/\/ last column or line\n {\n\tif (dollar_lnum)\n\t{\n\t pos.lnum = curbuf->b_ml.ml_line_count;\n\t pos.col = 0;\n\t}\n\telse\n\t{\n\t pos.lnum = curwin->w_cursor.lnum;\n\t if (charcol)\n\t\tpos.col = (colnr_T)mb_charlen(ml_get_curline());\n\t else\n\t\tpos.col = (colnr_T)STRLEN(ml_get_curline());\n\t}\n\treturn &pos;\n }\n if (in_vim9script())\n\tsemsg(_(e_invalid_value_for_line_number_str), name);\n return NULL;\n}","target":0,"code_token_length":1099,"total_token_length":1335,"max_tokens_setting":2048} +{"idx":36038,"func":" Status UpdateNode(const NodeDef* node, bool* refined) {\n NodeContext* ctx = GetNodeContext(node);\n if (ctx == nullptr) {\n TF_RETURN_IF_ERROR(AddNode(node));\n ctx = CHECK_NOTNULL(GetNodeContext(node));\n *refined = true;\n }\n\n \/\/ Check if the shapes of the nodes in the fan-in of this node have changed,\n \/\/ and if they have, update the node input shapes.\n InferenceContext* ic = ctx->inference_context.get();\n ctx->input_tensors_as_shapes_to_propagate.resize(ic->num_inputs());\n ctx->input_tensor_protos.resize(ic->num_inputs(), nullptr);\n\n for (int dst_input = 0; dst_input < ic->num_inputs(); ++dst_input) {\n const GraphView::InputPort port(node, dst_input);\n const GraphView::OutputPort fanin = graph_.GetRegularFanin(port);\n int src_output = fanin.port_id;\n const NodeDef* src = fanin.node;\n NodeContext* src_ctx = GetNodeContext(src);\n if (src_ctx == nullptr) {\n return errors::FailedPrecondition(\n \"Input \", dst_input, \" for '\", node->name(),\n \"' was not previously added to SymbolicShapeRefiner.\");\n }\n\n InferenceContext* src_ic = src_ctx->inference_context.get();\n if (src_output >= src_ic->num_outputs()) {\n return errors::OutOfRange(\"src_output = \", src_output,\n \", but num_outputs is only \",\n src_ic->num_outputs());\n }\n\n \/\/ Propagate input node's NodeContext info to the current node's\n \/\/ NodeContext:\n \/\/ output_tensor_protos to input_tensor_protos and input_tensors, and\n \/\/ output_tensors_as_shapes to input_tensors_as_shapes.\n if (static_cast(src_ctx->output_tensors_as_shapes.size()) >\n src_output) {\n ctx->input_tensors_as_shapes_to_propagate[dst_input] =\n src_ctx->output_tensors_as_shapes[src_output];\n }\n\n if (static_cast(src_ctx->output_tensor_protos.size()) > src_output) {\n const auto* tensor_proto = src_ctx->output_tensor_protos[src_output];\n if (tensor_proto != nullptr) {\n ctx->input_tensor_protos[dst_input] = tensor_proto;\n }\n }\n\n \/\/ NOTE: we check only shape is refined; we do not (yet) check whether\n \/\/ tensor value is refined.\n if (!*refined &&\n !ic->input(dst_input).SameHandle(src_ic->output(src_output))) {\n *refined = true;\n }\n ic->SetInput(dst_input, src_ic->output(src_output));\n\n if (!*refined && ic->requested_input_tensor_as_partial_shape(dst_input)) {\n \/\/ The input value may have changed. Since we have no way to know if\n \/\/ that's indeed the case, err on the safe side.\n *refined = true;\n }\n\n \/\/ Also propagate handle shape and dtype of edges which are carrying\n \/\/ resource handles.\n if (ctx->input_types[dst_input] == DT_RESOURCE) {\n auto* outputs = src_ic->output_handle_shapes_and_types(src_output);\n if (!outputs) continue;\n auto* inputs = ic->input_handle_shapes_and_types(dst_input);\n\n if (!inputs || !EquivalentShapesAndTypes(*outputs, *inputs))\n *refined = true;\n ic->set_input_handle_shapes_and_types(dst_input, *outputs);\n }\n }\n\n \/\/ Make sure we schedule the fanout of resources (which have no input)\n \/\/ whenever the resources are updated.\n *refined |= ic->num_inputs() == 0;\n\n if (!*refined) {\n \/\/ No input shape has changed, we're done.\n return Status::OK();\n }\n\n \/\/ Convert all kUnknownDimFromConst to -1 for shape inference.\n ic->set_input_tensors_as_shapes(ReplaceUnknownDimFromConstWithUnknownDim(\n ic, ctx->input_tensors_as_shapes_to_propagate));\n \/\/ Note: UpdateFunction uses input_tensors_as_shapes and\n \/\/ input_tensor_protos (not the Tensor object) for input values.\n \/\/ so for function nodes, we don't need to convert TensorProtos\n \/\/ to Tensors here. If the current op is not a function op, we convert\n \/\/ TensorProtos to Tensors before calling InferShapes.\n\n \/\/ Properly handle function nodes.\n if (ctx->op_data && ctx->op_data->is_function_op) {\n \/\/ TODO(jmdecker): Detect if the input shapes have changed for this\n \/\/ function. Note that when we hit a function call node, refined will be\n \/\/ true, as the updates to the call node will have changed, even if it's\n \/\/ the same function being called twice with the same input shapes.\n \/\/ Example: simple_function.pbtxt\n if (aggressive_shape_inference_) {\n \/\/ If output shapes are annotated, use it and skip UpdateFunction();\n \/\/ it can be very expensive when a function node has nested function\n \/\/ nodes internally. One downside with this approach is that we do not\n \/\/ get output values or output shapes as tensor from function node.\n auto s = UpdateOutputShapesUsingAnnotatedInformation(*node, ctx);\n if (s.ok() && AllOutputShapesKnown(ctx)) {\n return Status::OK();\n }\n \/\/ If shape annotation was not available, incomplete, or incompatible,\n \/\/ fall through to call UpdateFunction().\n }\n auto s = UpdateFunction(node);\n if (s.ok()) {\n return Status::OK();\n } else {\n VLOG(1) << \"UpdateFunction failed for \" << node->op()\n << \". Defaulting to ShapeUnknown.\\n\"\n << s.ToString();\n }\n }\n\n \/\/ Construct Tensors for constant inputs used by shape functions.\n std::vector const_values(ic->num_inputs());\n std::vector input_tensors(ic->num_inputs(), nullptr);\n for (int dst_input = 0; dst_input < ic->num_inputs(); ++dst_input) {\n const TensorProto* tensor_proto = ctx->input_tensor_protos[dst_input];\n if (tensor_proto != nullptr &&\n \/\/ Skip if the const tensor is too large.\n NumElementsFromTensorProto(*tensor_proto) <=\n kThresholdToSkipConstTensorInstantiation &&\n const_values[dst_input].FromProto(*tensor_proto)) {\n input_tensors[dst_input] = &const_values[dst_input];\n }\n }\n ic->set_input_tensors(input_tensors);\n\n \/\/ Update the shapes of the outputs.\n return InferShapes(*node, ctx);\n }","target":0,"code_token_length":1432,"total_token_length":1668,"max_tokens_setting":2048} +{"idx":494739,"func":"display_debug_rnglists_list (unsigned char * start,\n\t\t\t unsigned char * finish,\n\t\t\t unsigned int pointer_size,\n\t\t\t dwarf_vma offset,\n\t\t\t dwarf_vma base_address,\n\t\t\t unsigned int offset_size)\n{\n unsigned char *next = start;\n unsigned int debug_addr_section_hdr_len;\n\n if (offset_size == 4)\n debug_addr_section_hdr_len = 8;\n else\n debug_addr_section_hdr_len = 16;\n\n while (1)\n {\n dwarf_vma off = offset + (start - next);\n enum dwarf_range_list_entry rlet;\n \/* Initialize it due to a false compiler warning. *\/\n dwarf_vma begin = -1, length, end = -1;\n\n if (start >= finish)\n\t{\n\t warn (_(\"Range list starting at offset 0x%s is not terminated.\\n\"),\n\t\tdwarf_vmatoa (\"x\", offset));\n\t break;\n\t}\n\n printf (\" \");\n print_dwarf_vma (off, 4);\n\n SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish);\n\n switch (rlet)\n\t{\n\tcase DW_RLE_end_of_list:\n\t printf (_(\"\\n\"));\n\t break;\n\tcase DW_RLE_base_addressx:\n\t READ_ULEB (base_address, start, finish);\n\t print_dwarf_vma (base_address, pointer_size);\n\t printf (_(\"(base address index) \"));\n\t base_address = fetch_indexed_addr ((base_address * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t print_dwarf_vma (base_address, pointer_size);\n\t printf (_(\"(base address)\\n\"));\n\t break;\n\tcase DW_RLE_startx_endx:\n\t READ_ULEB (begin, start, finish);\n\t READ_ULEB (end, start, finish);\n\t begin = fetch_indexed_addr ((begin * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t end = fetch_indexed_addr ((begin * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t break;\n\tcase DW_RLE_startx_length:\n\t READ_ULEB (begin, start, finish);\n\t READ_ULEB (length, start, finish);\n\t begin = fetch_indexed_addr ((begin * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t end = begin + length;\n\t break;\n\tcase DW_RLE_offset_pair:\n\t READ_ULEB (begin, start, finish);\n\t READ_ULEB (end, start, finish);\n\t break;\n\tcase DW_RLE_base_address:\n\t SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish);\n\t print_dwarf_vma (base_address, pointer_size);\n\t printf (_(\"(base address)\\n\"));\n\t break;\n\tcase DW_RLE_start_end:\n\t SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);\n\t SAFE_BYTE_GET_AND_INC (end, start, pointer_size, finish);\n\t break;\n\tcase DW_RLE_start_length:\n\t SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);\n\t READ_ULEB (length, start, finish);\n\t end = begin + length;\n\t break;\n\tdefault:\n\t error (_(\"Invalid range list entry type %d\\n\"), rlet);\n\t rlet = DW_RLE_end_of_list;\n\t break;\n\t}\n\n if (rlet == DW_RLE_end_of_list)\n\tbreak;\n if (rlet == DW_RLE_base_address || rlet == DW_RLE_base_addressx)\n\tcontinue;\n\n \/* Only a DW_RLE_offset_pair needs the base address added. *\/\n if (rlet == DW_RLE_offset_pair)\n\t{\n\t begin += base_address;\n\t end += base_address;\n\t}\n\n print_dwarf_vma (begin, pointer_size);\n print_dwarf_vma (end, pointer_size);\n\n if (begin == end)\n\tfputs (_(\"(start == end)\"), stdout);\n else if (begin > end)\n\tfputs (_(\"(start > end)\"), stdout);\n\n putchar ('\\n');\n }\n}","target":0,"code_token_length":868,"total_token_length":1104,"max_tokens_setting":2048} +{"idx":13461,"func":"_gcry_ecc_eddsa_sign (gcry_mpi_t input, ECC_secret_key *skey,\n gcry_mpi_t r_r, gcry_mpi_t s, int hashalgo, gcry_mpi_t pk)\n{\n int rc;\n mpi_ec_t ctx = NULL;\n int b;\n unsigned int tmp;\n unsigned char *digest = NULL;\n gcry_buffer_t hvec[3];\n const void *mbuf;\n size_t mlen;\n unsigned char *rawmpi = NULL;\n unsigned int rawmpilen;\n unsigned char *encpk = NULL; \/* Encoded public key. *\/\n unsigned int encpklen;\n mpi_point_struct I; \/* Intermediate value. *\/\n mpi_point_struct Q; \/* Public key. *\/\n gcry_mpi_t a, x, y, r;\n\n memset (hvec, 0, sizeof hvec);\n\n if (!mpi_is_opaque (input))\n return GPG_ERR_INV_DATA;\n\n \/* Initialize some helpers. *\/\n point_init (&I);\n point_init (&Q);\n a = mpi_snew (0);\n x = mpi_new (0);\n y = mpi_new (0);\n r = mpi_new (0);\n ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0,\n skey->E.p, skey->E.a, skey->E.b);\n b = (ctx->nbits+7)\/8;\n if (b != 256\/8) {\n rc = GPG_ERR_INTERNAL; \/* We only support 256 bit. *\/\n goto leave;\n }\n\n rc = _gcry_ecc_eddsa_compute_h_d (&digest, skey->d, ctx);\n if (rc)\n goto leave;\n _gcry_mpi_set_buffer (a, digest, 32, 0);\n\n \/* Compute the public key if it has not been supplied as optional\n parameter. *\/\n if (pk)\n {\n rc = _gcry_ecc_eddsa_decodepoint (pk, ctx, &Q, &encpk, &encpklen);\n if (rc)\n goto leave;\n if (DBG_CIPHER)\n log_printhex (\"* e_pk\", encpk, encpklen);\n if (!_gcry_mpi_ec_curve_point (&Q, ctx))\n {\n rc = GPG_ERR_BROKEN_PUBKEY;\n goto leave;\n }\n }\n else\n {\n _gcry_mpi_ec_mul_point (&Q, a, &skey->E.G, ctx);\n rc = _gcry_ecc_eddsa_encodepoint (&Q, ctx, x, y, 0, &encpk, &encpklen);\n if (rc)\n goto leave;\n if (DBG_CIPHER)\n log_printhex (\" e_pk\", encpk, encpklen);\n }\n\n \/* Compute R. *\/\n mbuf = mpi_get_opaque (input, &tmp);\n mlen = (tmp +7)\/8;\n if (DBG_CIPHER)\n log_printhex (\" m\", mbuf, mlen);\n\n hvec[0].data = digest;\n hvec[0].off = 32;\n hvec[0].len = 32;\n hvec[1].data = (char*)mbuf;\n hvec[1].len = mlen;\n rc = _gcry_md_hash_buffers (hashalgo, 0, digest, hvec, 2);\n if (rc)\n goto leave;\n reverse_buffer (digest, 64);\n if (DBG_CIPHER)\n log_printhex (\" r\", digest, 64);\n _gcry_mpi_set_buffer (r, digest, 64, 0);\n _gcry_mpi_ec_mul_point (&I, r, &skey->E.G, ctx);\n if (DBG_CIPHER)\n log_printpnt (\" r\", &I, ctx);\n\n \/* Convert R into affine coordinates and apply encoding. *\/\n rc = _gcry_ecc_eddsa_encodepoint (&I, ctx, x, y, 0, &rawmpi, &rawmpilen);\n if (rc)\n goto leave;\n if (DBG_CIPHER)\n log_printhex (\" e_r\", rawmpi, rawmpilen);\n\n \/* S = r + a * H(encodepoint(R) + encodepoint(pk) + m) mod n *\/\n hvec[0].data = rawmpi; \/* (this is R) *\/\n hvec[0].off = 0;\n hvec[0].len = rawmpilen;\n hvec[1].data = encpk;\n hvec[1].off = 0;\n hvec[1].len = encpklen;\n hvec[2].data = (char*)mbuf;\n hvec[2].off = 0;\n hvec[2].len = mlen;\n rc = _gcry_md_hash_buffers (hashalgo, 0, digest, hvec, 3);\n if (rc)\n goto leave;\n\n \/* No more need for RAWMPI thus we now transfer it to R_R. *\/\n mpi_set_opaque (r_r, rawmpi, rawmpilen*8);\n rawmpi = NULL;\n\n reverse_buffer (digest, 64);\n if (DBG_CIPHER)\n log_printhex (\" H(R+)\", digest, 64);\n _gcry_mpi_set_buffer (s, digest, 64, 0);\n mpi_mulm (s, s, a, skey->E.n);\n mpi_addm (s, s, r, skey->E.n);\n rc = eddsa_encodempi (s, b, &rawmpi, &rawmpilen);\n if (rc)\n goto leave;\n if (DBG_CIPHER)\n log_printhex (\" e_s\", rawmpi, rawmpilen);\n mpi_set_opaque (s, rawmpi, rawmpilen*8);\n rawmpi = NULL;\n\n rc = 0;\n\n leave:\n _gcry_mpi_release (a);\n _gcry_mpi_release (x);\n _gcry_mpi_release (y);\n _gcry_mpi_release (r);\n xfree (digest);\n _gcry_mpi_ec_free (ctx);\n point_free (&I);\n point_free (&Q);\n xfree (encpk);\n xfree (rawmpi);\n return rc;\n}\n","target":1,"code_token_length":1421,"total_token_length":1657,"max_tokens_setting":2048} +{"idx":430505,"func":"httpRead2(http_t *http,\t\t\t\/* I - HTTP connection *\/\n char *buffer,\t\t\/* I - Buffer for data *\/\n\t size_t length)\t\t\/* I - Maximum number of bytes *\/\n{\n ssize_t\tbytes;\t\t\t\/* Bytes read *\/\n\n\n#ifdef HAVE_LIBZ\n DEBUG_printf((\"httpRead2(http=%p, buffer=%p, length=\" CUPS_LLFMT \") coding=%d data_encoding=%d data_remaining=\" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http->coding, http->data_encoding, CUPS_LLCAST http->data_remaining));\n#else\n DEBUG_printf((\"httpRead2(http=%p, buffer=%p, length=\" CUPS_LLFMT \") data_encoding=%d data_remaining=\" CUPS_LLFMT, (void *)http, (void *)buffer, CUPS_LLCAST length, http->data_encoding, CUPS_LLCAST http->data_remaining));\n#endif \/* HAVE_LIBZ *\/\n\n if (http == NULL || buffer == NULL)\n return (-1);\n\n http->activity = time(NULL);\n http->error = 0;\n\n if (length <= 0)\n return (0);\n\n#ifdef HAVE_LIBZ\n if (http->coding >= _HTTP_CODING_GUNZIP)\n {\n do\n {\n if (((z_stream *)http->stream)->avail_in > 0)\n {\n\tint\tzerr;\t\t\t\/* Decompressor error *\/\n\n\tDEBUG_printf((\"2httpRead2: avail_in=%d, avail_out=%d\",\n\t (int)((z_stream *)http->stream)->avail_in, (int)length));\n\n\t((z_stream *)http->stream)->next_out = (Bytef *)buffer;\n\t((z_stream *)http->stream)->avail_out = (uInt)length;\n\n\tif ((zerr = inflate((z_stream *)http->stream, Z_SYNC_FLUSH)) < Z_OK)\n\t{\n\t DEBUG_printf((\"2httpRead2: zerr=%d\", zerr));\n#ifdef DEBUG\n http_debug_hex(\"2httpRead2\", (char *)http->sbuffer, (int)((z_stream *)http->stream)->avail_in);\n#endif \/* DEBUG *\/\n\n\t http->error = EIO;\n\t return (-1);\n\t}\n\n\tbytes = (ssize_t)(length - ((z_stream *)http->stream)->avail_out);\n\n\tDEBUG_printf((\"2httpRead2: avail_in=%d, avail_out=%d, bytes=%d\",\n\t\t ((z_stream *)http->stream)->avail_in, ((z_stream *)http->stream)->avail_out,\n\t\t (int)bytes));\n }\n else\n bytes = 0;\n\n if (bytes == 0)\n {\n ssize_t buflen = HTTP_MAX_BUFFER - (ssize_t)((z_stream *)http->stream)->avail_in;\n\t\t\t\t\t\/* Additional bytes for buffer *\/\n\n if (buflen > 0)\n {\n if (((z_stream *)http->stream)->avail_in > 0 &&\n ((z_stream *)http->stream)->next_in > http->sbuffer)\n memmove(http->sbuffer, ((z_stream *)http->stream)->next_in, ((z_stream *)http->stream)->avail_in);\n\n\t ((z_stream *)http->stream)->next_in = http->sbuffer;\n\n DEBUG_printf((\"1httpRead2: Reading up to %d more bytes of data into \"\n \"decompression buffer.\", (int)buflen));\n\n if (http->data_remaining > 0)\n {\n\t if (buflen > http->data_remaining)\n\t buflen = (ssize_t)http->data_remaining;\n\n\t bytes = http_read_buffered(http, (char *)http->sbuffer + ((z_stream *)http->stream)->avail_in, (size_t)buflen);\n }\n else if (http->data_encoding == HTTP_ENCODING_CHUNKED)\n bytes = http_read_chunk(http, (char *)http->sbuffer + ((z_stream *)http->stream)->avail_in, (size_t)buflen);\n else\n bytes = 0;\n\n if (bytes < 0)\n return (bytes);\n else if (bytes == 0)\n break;\n\n DEBUG_printf((\"1httpRead2: Adding \" CUPS_LLFMT \" bytes to \"\n \"decompression buffer.\", CUPS_LLCAST bytes));\n\n http->data_remaining -= bytes;\n ((z_stream *)http->stream)->avail_in += (uInt)bytes;\n\n\t if (http->data_remaining <= 0 &&\n\t http->data_encoding == HTTP_ENCODING_CHUNKED)\n\t {\n\t \/*\n\t * Read the trailing blank line now...\n\t *\/\n\n\t char\tlen[32];\t\t\/* Length string *\/\n\n\t httpGets(len, sizeof(len), http);\n\t }\n\n bytes = 0;\n }\n else\n return (0);\n }\n }\n while (bytes == 0);\n }\n else\n#endif \/* HAVE_LIBZ *\/\n if (http->data_remaining == 0 && http->data_encoding == HTTP_ENCODING_CHUNKED)\n {\n if ((bytes = http_read_chunk(http, buffer, length)) > 0)\n {\n http->data_remaining -= bytes;\n\n if (http->data_remaining <= 0)\n {\n \/*\n * Read the trailing blank line now...\n *\/\n\n char\tlen[32];\t\t\/* Length string *\/\n\n httpGets(len, sizeof(len), http);\n }\n }\n }\n else if (http->data_remaining <= 0)\n {\n \/*\n * No more data to read...\n *\/\n\n return (0);\n }\n else\n {\n DEBUG_printf((\"1httpRead2: Reading up to %d bytes into buffer.\",\n (int)length));\n\n if (length > (size_t)http->data_remaining)\n length = (size_t)http->data_remaining;\n\n if ((bytes = http_read_buffered(http, buffer, length)) > 0)\n {\n http->data_remaining -= bytes;\n\n if (http->data_remaining <= 0 &&\n http->data_encoding == HTTP_ENCODING_CHUNKED)\n {\n \/*\n * Read the trailing blank line now...\n *\/\n\n char\tlen[32];\t\t\/* Length string *\/\n\n httpGets(len, sizeof(len), http);\n }\n }\n }\n\n if (\n#ifdef HAVE_LIBZ\n (http->coding == _HTTP_CODING_IDENTITY ||\n (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in == 0)) &&\n#endif \/* HAVE_LIBZ *\/\n ((http->data_remaining <= 0 &&\n http->data_encoding == HTTP_ENCODING_LENGTH) ||\n (http->data_encoding == HTTP_ENCODING_CHUNKED && bytes == 0)))\n {\n#ifdef HAVE_LIBZ\n if (http->coding >= _HTTP_CODING_GUNZIP)\n http_content_coding_finish(http);\n#endif \/* HAVE_LIBZ *\/\n\n if (http->state == HTTP_STATE_POST_RECV)\n http->state ++;\n else if (http->state == HTTP_STATE_GET_SEND ||\n http->state == HTTP_STATE_POST_SEND)\n http->state = HTTP_STATE_WAITING;\n else\n http->state = HTTP_STATE_STATUS;\n\n DEBUG_printf((\"1httpRead2: End of content, set state to %s.\",\n\t\t httpStateString(http->state)));\n }\n\n return (bytes);\n}","target":0,"code_token_length":1556,"total_token_length":1792,"max_tokens_setting":2048} +{"idx":328486,"func":"static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int depth, AVFormatContext *s)\n\n{\n\n AVIOContext *pb;\n\n WtvFile *wf;\n\n uint8_t *buffer;\n\n\n\n if (seek_by_sector(s->pb, first_sector, 0) < 0)\n\n return NULL;\n\n\n\n wf = av_mallocz(sizeof(WtvFile));\n\n if (!wf)\n\n return NULL;\n\n\n\n if (depth == 0) {\n\n wf->sectors = av_malloc(sizeof(uint32_t));\n\n if (!wf->sectors) {\n\n av_free(wf);\n\n return NULL;\n\n }\n\n wf->sectors[0] = first_sector;\n\n wf->nb_sectors = 1;\n\n } else if (depth == 1) {\n\n wf->sectors = av_malloc(WTV_SECTOR_SIZE);\n\n if (!wf->sectors) {\n\n av_free(wf);\n\n return NULL;\n\n }\n\n wf->nb_sectors = read_ints(s->pb, wf->sectors, WTV_SECTOR_SIZE \/ 4);\n\n } else if (depth == 2) {\n\n uint32_t sectors1[WTV_SECTOR_SIZE \/ 4];\n\n int nb_sectors1 = read_ints(s->pb, sectors1, WTV_SECTOR_SIZE \/ 4);\n\n int i;\n\n\n\n wf->sectors = av_malloc_array(nb_sectors1, 1 << WTV_SECTOR_BITS);\n\n if (!wf->sectors) {\n\n av_free(wf);\n\n return NULL;\n\n }\n\n wf->nb_sectors = 0;\n\n for (i = 0; i < nb_sectors1; i++) {\n\n if (seek_by_sector(s->pb, sectors1[i], 0) < 0)\n\n break;\n\n wf->nb_sectors += read_ints(s->pb, wf->sectors + i * WTV_SECTOR_SIZE \/ 4, WTV_SECTOR_SIZE \/ 4);\n\n }\n\n } else {\n\n av_log(s, AV_LOG_ERROR, \"unsupported file allocation table depth (0x%x)\\n\", depth);\n\n av_free(wf);\n\n return NULL;\n\n }\n\n wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS;\n\n\n\n if (!wf->nb_sectors) {\n\n av_free(wf->sectors);\n\n av_free(wf);\n\n return NULL;\n\n }\n\n\n\n if ((int64_t)wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > avio_tell(s->pb))\n\n av_log(s, AV_LOG_WARNING, \"truncated file\\n\");\n\n\n\n \/* check length *\/\n\n length &= 0xFFFFFFFFFFFF;\n\n if (length > ((int64_t)wf->nb_sectors << wf->sector_bits)) {\n\n av_log(s, AV_LOG_WARNING, \"reported file length (0x%\"PRIx64\") exceeds number of available sectors (0x%\"PRIx64\")\\n\", length, (int64_t)wf->nb_sectors << wf->sector_bits);\n\n length = (int64_t)wf->nb_sectors << wf->sector_bits;\n\n }\n\n wf->length = length;\n\n\n\n \/* seek to initial sector *\/\n\n wf->position = 0;\n\n if (seek_by_sector(s->pb, wf->sectors[0], 0) < 0) {\n\n av_free(wf->sectors);\n\n av_free(wf);\n\n return NULL;\n\n }\n\n\n\n wf->pb_filesystem = s->pb;\n\n buffer = av_malloc(1 << wf->sector_bits);\n\n if (!buffer) {\n\n av_free(wf->sectors);\n\n av_free(wf);\n\n return NULL;\n\n }\n\n\n\n pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf,\n\n wtvfile_read_packet, NULL, wtvfile_seek);\n\n if (!pb) {\n\n av_free(buffer);\n\n av_free(wf->sectors);\n\n av_free(wf);\n\n }\n\n return pb;\n\n}\n","target":0,"code_token_length":890,"total_token_length":1126,"max_tokens_setting":2048} +{"idx":78645,"func":"static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,\n\t\t\t\t struct vmcs12 *vmcs12)\n{\n\tstruct kvm_segment seg;\n\tu32 entry_failure_code;\n\n\tif (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER)\n\t\tvcpu->arch.efer = vmcs12->host_ia32_efer;\n\telse if (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE)\n\t\tvcpu->arch.efer |= (EFER_LMA | EFER_LME);\n\telse\n\t\tvcpu->arch.efer &= ~(EFER_LMA | EFER_LME);\n\tvmx_set_efer(vcpu, vcpu->arch.efer);\n\n\tkvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->host_rsp);\n\tkvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->host_rip);\n\tvmx_set_rflags(vcpu, X86_EFLAGS_FIXED);\n\t\/*\n\t * Note that calling vmx_set_cr0 is important, even if cr0 hasn't\n\t * actually changed, because vmx_set_cr0 refers to efer set above.\n\t *\n\t * CR0_GUEST_HOST_MASK is already set in the original vmcs01\n\t * (KVM doesn't change it);\n\t *\/\n\tvcpu->arch.cr0_guest_owned_bits = X86_CR0_TS;\n\tvmx_set_cr0(vcpu, vmcs12->host_cr0);\n\n\t\/* Same as above - no reason to call set_cr4_guest_host_mask(). *\/\n\tvcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK);\n\tkvm_set_cr4(vcpu, vmcs12->host_cr4);\n\n\tnested_ept_uninit_mmu_context(vcpu);\n\n\t\/*\n\t * Only PDPTE load can fail as the value of cr3 was checked on entry and\n\t * couldn't have changed.\n\t *\/\n\tif (nested_vmx_load_cr3(vcpu, vmcs12->host_cr3, false, &entry_failure_code))\n\t\tnested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_PDPTE_FAIL);\n\n\tif (!enable_ept)\n\t\tvcpu->arch.walk_mmu->inject_page_fault = kvm_inject_page_fault;\n\n\tif (enable_vpid) {\n\t\t\/*\n\t\t * Trivially support vpid by letting L2s share their parent\n\t\t * L1's vpid. TODO: move to a more elaborate solution, giving\n\t\t * each L2 its own vpid and exposing the vpid feature to L1.\n\t\t *\/\n\t\tvmx_flush_tlb(vcpu);\n\t}\n\t\/* Restore posted intr vector. *\/\n\tif (nested_cpu_has_posted_intr(vmcs12))\n\t\tvmcs_write16(POSTED_INTR_NV, POSTED_INTR_VECTOR);\n\n\tvmcs_write32(GUEST_SYSENTER_CS, vmcs12->host_ia32_sysenter_cs);\n\tvmcs_writel(GUEST_SYSENTER_ESP, vmcs12->host_ia32_sysenter_esp);\n\tvmcs_writel(GUEST_SYSENTER_EIP, vmcs12->host_ia32_sysenter_eip);\n\tvmcs_writel(GUEST_IDTR_BASE, vmcs12->host_idtr_base);\n\tvmcs_writel(GUEST_GDTR_BASE, vmcs12->host_gdtr_base);\n\n\t\/* If not VM_EXIT_CLEAR_BNDCFGS, the L2 value propagates to L1. *\/\n\tif (vmcs12->vm_exit_controls & VM_EXIT_CLEAR_BNDCFGS)\n\t\tvmcs_write64(GUEST_BNDCFGS, 0);\n\n\tif (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PAT) {\n\t\tvmcs_write64(GUEST_IA32_PAT, vmcs12->host_ia32_pat);\n\t\tvcpu->arch.pat = vmcs12->host_ia32_pat;\n\t}\n\tif (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL)\n\t\tvmcs_write64(GUEST_IA32_PERF_GLOBAL_CTRL,\n\t\t\tvmcs12->host_ia32_perf_global_ctrl);\n\n\t\/* Set L1 segment info according to Intel SDM\n\t 27.5.2 Loading Host Segment and Descriptor-Table Registers *\/\n\tseg = (struct kvm_segment) {\n\t\t.base = 0,\n\t\t.limit = 0xFFFFFFFF,\n\t\t.selector = vmcs12->host_cs_selector,\n\t\t.type = 11,\n\t\t.present = 1,\n\t\t.s = 1,\n\t\t.g = 1\n\t};\n\tif (vmcs12->vm_exit_controls & VM_EXIT_HOST_ADDR_SPACE_SIZE)\n\t\tseg.l = 1;\n\telse\n\t\tseg.db = 1;\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_CS);\n\tseg = (struct kvm_segment) {\n\t\t.base = 0,\n\t\t.limit = 0xFFFFFFFF,\n\t\t.type = 3,\n\t\t.present = 1,\n\t\t.s = 1,\n\t\t.db = 1,\n\t\t.g = 1\n\t};\n\tseg.selector = vmcs12->host_ds_selector;\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_DS);\n\tseg.selector = vmcs12->host_es_selector;\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_ES);\n\tseg.selector = vmcs12->host_ss_selector;\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_SS);\n\tseg.selector = vmcs12->host_fs_selector;\n\tseg.base = vmcs12->host_fs_base;\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_FS);\n\tseg.selector = vmcs12->host_gs_selector;\n\tseg.base = vmcs12->host_gs_base;\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_GS);\n\tseg = (struct kvm_segment) {\n\t\t.base = vmcs12->host_tr_base,\n\t\t.limit = 0x67,\n\t\t.selector = vmcs12->host_tr_selector,\n\t\t.type = 11,\n\t\t.present = 1\n\t};\n\tvmx_set_segment(vcpu, &seg, VCPU_SREG_TR);\n\n\tkvm_set_dr(vcpu, 7, 0x400);\n\tvmcs_write64(GUEST_IA32_DEBUGCTL, 0);\n\n\tif (cpu_has_vmx_msr_bitmap())\n\t\tvmx_set_msr_bitmap(vcpu);\n\n\tif (nested_vmx_load_msr(vcpu, vmcs12->vm_exit_msr_load_addr,\n\t\t\t\tvmcs12->vm_exit_msr_load_count))\n\t\tnested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_MSR_FAIL);\n}","target":0,"code_token_length":1485,"total_token_length":1721,"max_tokens_setting":2048} +{"idx":30,"func":"TEST_F ( WebUsbDetectorTest , ThreeUsbDevicesAddedAndRemoved ) {\n base : : string16 product_name_1 = base : : UTF8ToUTF16 ( kProductName_1 ) ;\n GURL landing_page_1 ( kLandingPage_1 ) ;\n scoped_refptr < device : : MockUsbDevice > device_1 ( new device : : MockUsbDevice ( 0 , 1 , \"Google\" , kProductName_1 , \"002\" , landing_page_1 ) ) ;\n std : : string guid_1 = device_1 -> guid ( ) ;\n base : : string16 product_name_2 = base : : UTF8ToUTF16 ( kProductName_2 ) ;\n GURL landing_page_2 ( kLandingPage_2 ) ;\n scoped_refptr < device : : MockUsbDevice > device_2 ( new device : : MockUsbDevice ( 3 , 4 , \"Google\" , kProductName_2 , \"005\" , landing_page_2 ) ) ;\n std : : string guid_2 = device_2 -> guid ( ) ;\n base : : string16 product_name_3 = base : : UTF8ToUTF16 ( kProductName_3 ) ;\n GURL landing_page_3 ( kLandingPage_3 ) ;\n scoped_refptr < device : : MockUsbDevice > device_3 ( new device : : MockUsbDevice ( 6 , 7 , \"Google\" , kProductName_3 , \"008\" , landing_page_3 ) ) ;\n std : : string guid_3 = device_3 -> guid ( ) ;\n Initialize ( ) ;\n device_client_ . usb_service ( ) -> AddDevice ( device_1 ) ;\n message_center : : Notification * notification_1 = message_center_ -> FindVisibleNotificationById ( guid_1 ) ;\n ASSERT_TRUE ( notification_1 != nullptr ) ;\n base : : string16 expected_title_1 = base : : ASCIIToUTF16 ( \"Google Product A detected\" ) ;\n EXPECT_EQ ( expected_title_1 , notification_1 -> title ( ) ) ;\n base : : string16 expected_message_1 = base : : ASCIIToUTF16 ( \"Go to www.google.com\/A to connect.\" ) ;\n EXPECT_EQ ( expected_message_1 , notification_1 -> message ( ) ) ;\n EXPECT_TRUE ( notification_1 -> delegate ( ) != nullptr ) ;\n device_client_ . usb_service ( ) -> RemoveDevice ( device_1 ) ;\n EXPECT_TRUE ( message_center_ -> FindVisibleNotificationById ( guid_1 ) == nullptr ) ;\n device_client_ . usb_service ( ) -> AddDevice ( device_2 ) ;\n message_center : : Notification * notification_2 = message_center_ -> FindVisibleNotificationById ( guid_2 ) ;\n ASSERT_TRUE ( notification_2 != nullptr ) ;\n base : : string16 expected_title_2 = base : : ASCIIToUTF16 ( \"Google Product B detected\" ) ;\n EXPECT_EQ ( expected_title_2 , notification_2 -> title ( ) ) ;\n base : : string16 expected_message_2 = base : : ASCIIToUTF16 ( \"Go to www.google.com\/B to connect.\" ) ;\n EXPECT_EQ ( expected_message_2 , notification_2 -> message ( ) ) ;\n EXPECT_TRUE ( notification_2 -> delegate ( ) != nullptr ) ;\n device_client_ . usb_service ( ) -> RemoveDevice ( device_2 ) ;\n EXPECT_TRUE ( message_center_ -> FindVisibleNotificationById ( guid_2 ) == nullptr ) ;\n device_client_ . usb_service ( ) -> AddDevice ( device_3 ) ;\n message_center : : Notification * notification_3 = message_center_ -> FindVisibleNotificationById ( guid_3 ) ;\n ASSERT_TRUE ( notification_3 != nullptr ) ;\n base : : string16 expected_title_3 = base : : ASCIIToUTF16 ( \"Google Product C detected\" ) ;\n EXPECT_EQ ( expected_title_3 , notification_3 -> title ( ) ) ;\n base : : string16 expected_message_3 = base : : ASCIIToUTF16 ( \"Go to www.google.com\/C to connect.\" ) ;\n EXPECT_EQ ( expected_message_3 , notification_3 -> message ( ) ) ;\n EXPECT_TRUE ( notification_3 -> delegate ( ) != nullptr ) ;\n device_client_ . usb_service ( ) -> RemoveDevice ( device_3 ) ;\n EXPECT_TRUE ( message_center_ -> FindVisibleNotificationById ( guid_3 ) == nullptr ) ;\n }","target":1,"code_token_length":950,"total_token_length":1186,"max_tokens_setting":2048} +{"idx":333418,"func":"static void msvideo1_decode_8bit(Msvideo1Context *s)\n\n{\n\n int block_ptr, pixel_ptr;\n\n int total_blocks;\n\n int pixel_x, pixel_y; \/* pixel width and height iterators *\/\n\n int block_x, block_y; \/* block width and height iterators *\/\n\n int blocks_wide, blocks_high; \/* width and height in 4x4 blocks *\/\n\n int block_inc;\n\n int row_dec;\n\n\n\n \/* decoding parameters *\/\n\n int stream_ptr;\n\n unsigned char byte_a, byte_b;\n\n unsigned short flags;\n\n int skip_blocks;\n\n unsigned char colors[8];\n\n unsigned char *pixels = s->frame.data[0];\n\n unsigned char *prev_pixels = s->prev_frame.data[0];\n\n int stride = s->frame.linesize[0];\n\n\n\n stream_ptr = 0;\n\n skip_blocks = 0;\n\n blocks_wide = s->avctx->width \/ 4;\n\n blocks_high = s->avctx->height \/ 4;\n\n total_blocks = blocks_wide * blocks_high;\n\n block_inc = 4;\n\n row_dec = stride + 4;\n\n\n\n for (block_y = blocks_high; block_y > 0; block_y--) {\n\n block_ptr = ((block_y * 4) - 1) * stride;\n\n for (block_x = blocks_wide; block_x > 0; block_x--) {\n\n \/* check if this block should be skipped *\/\n\n if (skip_blocks) {\n\n COPY_PREV_BLOCK();\n\n block_ptr += block_inc;\n\n skip_blocks--;\n\n total_blocks--;\n\n continue;\n\n }\n\n\n\n pixel_ptr = block_ptr;\n\n\n\n \/* get the next two bytes in the encoded data stream *\/\n\n CHECK_STREAM_PTR(2);\n\n byte_a = s->buf[stream_ptr++];\n\n byte_b = s->buf[stream_ptr++];\n\n\n\n \/* check if the decode is finished *\/\n\n if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))\n\n return;\n\n else if ((byte_b & 0xFC) == 0x84) {\n\n \/* skip code, but don't count the current block *\/\n\n skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;\n\n COPY_PREV_BLOCK();\n\n } else if (byte_b < 0x80) {\n\n \/* 2-color encoding *\/\n\n flags = (byte_b << 8) | byte_a;\n\n\n\n CHECK_STREAM_PTR(2);\n\n colors[0] = s->buf[stream_ptr++];\n\n colors[1] = s->buf[stream_ptr++];\n\n\n\n for (pixel_y = 0; pixel_y < 4; pixel_y++) {\n\n for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)\n\n pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];\n\n pixel_ptr -= row_dec;\n\n }\n\n } else if (byte_b >= 0x90) {\n\n \/* 8-color encoding *\/\n\n flags = (byte_b << 8) | byte_a;\n\n\n\n CHECK_STREAM_PTR(8);\n\n memcpy(colors, &s->buf[stream_ptr], 8);\n\n stream_ptr += 8;\n\n\n\n for (pixel_y = 0; pixel_y < 4; pixel_y++) {\n\n for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)\n\n pixels[pixel_ptr++] = \n\n colors[((pixel_y & 0x2) << 1) + \n\n (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];\n\n pixel_ptr -= row_dec;\n\n }\n\n } else {\n\n \/* 1-color encoding *\/\n\n colors[0] = byte_a;\n\n\n\n for (pixel_y = 0; pixel_y < 4; pixel_y++) {\n\n for (pixel_x = 0; pixel_x < 4; pixel_x++)\n\n pixels[pixel_ptr++] = colors[0];\n\n pixel_ptr -= row_dec;\n\n }\n\n }\n\n\n\n block_ptr += block_inc;\n\n total_blocks--;\n\n }\n\n }\n\n\n\n \/* make the palette available on the way out *\/\n\n if (s->avctx->pix_fmt == PIX_FMT_PAL8)\n\n memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);\n\n}\n","target":0,"code_token_length":945,"total_token_length":1181,"max_tokens_setting":2048} +{"idx":155402,"func":"combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols,\n uint32 rows, uint32 imagewidth, \n uint32 tw, uint16 spp, uint16 bps, \n \t FILE *dumpfile, int format, int level)\n {\n int ready_bits = 0;\n uint32 src_rowsize, dst_rowsize, src_offset; \n uint32 bit_offset;\n uint32 row, col, src_byte = 0, src_bit = 0;\n uint8 maskbits = 0, matchbits = 0;\n uint8 buff1 = 0, buff2 = 0;\n tsample_t s;\n unsigned char *src = in[0];\n unsigned char *dst = out;\n char action[32];\n\n if ((src == NULL) || (dst == NULL))\n {\n TIFFError(\"combineSeparateTileSamples8bits\",\"Invalid input or output buffer\");\n return (1);\n }\n\n src_rowsize = ((bps * tw) + 7) \/ 8;\n dst_rowsize = ((imagewidth * bps * spp) + 7) \/ 8;\n maskbits = (uint8)-1 >> ( 8 - bps);\n\n for (row = 0; row < rows; row++)\n {\n ready_bits = 0;\n buff1 = buff2 = 0;\n dst = out + (row * dst_rowsize);\n src_offset = row * src_rowsize;\n for (col = 0; col < cols; col++)\n {\n \/* Compute src byte(s) and bits within byte(s) *\/\n bit_offset = col * bps;\n src_byte = bit_offset \/ 8;\n src_bit = bit_offset % 8;\n\n matchbits = maskbits << (8 - src_bit - bps); \n \/* load up next sample from each plane *\/\n for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++)\n {\n\tsrc = in[s] + src_offset + src_byte;\n buff1 = ((*src) & matchbits) << (src_bit);\n\n \/* If we have a full buffer's worth, write it out *\/\n if (ready_bits >= 8)\n {\n *dst++ = buff2;\n buff2 = buff1;\n ready_bits -= 8;\n strcpy (action, \"Flush\");\n }\n else\n {\n buff2 = (buff2 | (buff1 >> ready_bits));\n strcpy (action, \"Update\");\n }\n ready_bits += bps;\n \n if ((dumpfile != NULL) && (level == 3))\n {\n dump_info (dumpfile, format, \"\",\n \"Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d\",\n\t\t row + 1, col + 1, s, src_byte, src_bit, dst - out);\n dump_byte (dumpfile, format, \"Match bits\", matchbits);\n dump_byte (dumpfile, format, \"Src bits\", *src);\n dump_byte (dumpfile, format, \"Buff1 bits\", buff1);\n dump_byte (dumpfile, format, \"Buff2 bits\", buff2);\n dump_info (dumpfile, format, \"\",\"%s\", action); \n\t }\n }\n }\n\n if (ready_bits > 0)\n {\n buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits)));\n *dst++ = buff1;\n if ((dumpfile != NULL) && (level == 3))\n {\n dump_info (dumpfile, format, \"\",\n\t \"Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d\",\n\t row + 1, col + 1, src_byte, src_bit, dst - out);\n dump_byte (dumpfile, format, \"Final bits\", buff1);\n }\n }\n\n if ((dumpfile != NULL) && (level >= 2))\n {\n dump_info (dumpfile, format, \"combineSeparateTileSamples8bits\",\"Output data\");\n dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize));\n }\n }\n\n return (0);\n } \/* end combineSeparateTileSamples8bits *\/","target":0,"code_token_length":976,"total_token_length":1212,"max_tokens_setting":2048} +{"idx":287324,"func":"error_t httpClientFormatAuthorizationField(HttpClientContext *context)\n{\n size_t n;\n char_t *p;\n HttpClientAuthParams *authParams;\n\n \/\/Make sure the buffer contains a valid HTTP request\n if(context->bufferLen < 2 || context->bufferLen > HTTP_CLIENT_BUFFER_SIZE)\n return ERROR_INVALID_SYNTAX;\n\n \/\/Point to the HTTP authentication parameters\n authParams = &context->authParams;\n\n#if (HTTP_CLIENT_BASIC_AUTH_SUPPORT == ENABLED)\n \/\/Basic authentication scheme?\n if(authParams->mode == HTTP_AUTH_MODE_BASIC)\n {\n size_t k;\n size_t m;\n\n \/\/Calculate the length of the username and password\n n = osStrlen(authParams->username) + osStrlen(authParams->password);\n\n \/\/Make sure the buffer is large enough\n if((context->bufferLen + n + 22) > HTTP_CLIENT_BUFFER_SIZE)\n return ERROR_BUFFER_OVERFLOW;\n\n \/\/Point to the buffer where to format the Authorization header field\n p = context->buffer + context->bufferLen - 2;\n\n \/\/Format Authorization header field\n n = osSprintf(p, \"Authorization: Basic \");\n\n \/\/The client sends the username and password, separated by a single\n \/\/colon character, within a Base64-encoded string in the credentials\n m = osSprintf(p + n, \"%s:%s\", authParams->username, authParams->password);\n\n \/\/The first pass calculates the length of the Base64-encoded string\n base64Encode(p + n, m, NULL, &k);\n\n \/\/Make sure the buffer is large enough\n if((context->bufferLen + n + k) > HTTP_CLIENT_BUFFER_SIZE)\n return ERROR_BUFFER_OVERFLOW;\n\n \/\/The second pass encodes the string using Base64\n base64Encode(p + n, m, p + n, &k);\n \/\/Update the total length of the header field\n n += k;\n\n \/\/Make sure the buffer is large enough\n if((context->bufferLen + n + 2) > HTTP_CLIENT_BUFFER_SIZE)\n return ERROR_BUFFER_OVERFLOW;\n\n \/\/Terminate the header field with a CRLF sequence\n osSprintf(p + n, \"\\r\\n\\r\\n\");\n\n \/\/Adjust the length of the request header\n context->bufferLen = context->bufferLen + n + 2;\n }\n else\n#endif\n#if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)\n \/\/Digest authentication scheme?\n if(authParams->mode == HTTP_AUTH_MODE_DIGEST)\n {\n error_t error;\n const char_t *q;\n const char_t *uri;\n size_t uriLen;\n char_t response[HTTP_CLIENT_MAX_RESPONSE_LEN + 1];\n\n \/\/Properly terminate the string with a NULL character\n context->buffer[context->bufferLen] = '\\0';\n\n \/\/The Request-Line begins with a method token\n q = strchr(context->buffer, ' ');\n \/\/Any parsing error?\n if(q == NULL)\n return ERROR_INVALID_SYNTAX;\n\n \/\/The method token is followed by the Request-URI\n uri = q + 1;\n\n \/\/Point to the end of the Request-URI\n q = strchr(uri, ' ');\n \/\/Any parsing error?\n if(q == NULL)\n return ERROR_INVALID_SYNTAX;\n\n \/\/Compute the length of the current URI\n uriLen = q - uri;\n\n \/\/Check quality of protection\n if(authParams->qop == HTTP_AUTH_QOP_AUTH ||\n authParams->qop == HTTP_AUTH_QOP_AUTH_INT)\n {\n \/\/Make sure that a valid callback function has been registered\n if(context->randCallback == NULL)\n return ERROR_PRNG_NOT_READY;\n\n \/\/A cryptographically strong random number generator must be used to\n \/\/generate the cnonce\n error = context->randCallback(authParams->cnonce, HTTP_CLIENT_CNONCE_SIZE);\n \/\/Any error to report?\n if(error)\n return error;\n\n \/\/Convert the byte array to hex string\n httpEncodeHexString(authParams->cnonce, HTTP_CLIENT_CNONCE_SIZE,\n authParams->cnonce);\n\n \/\/Count of the number of requests (including the current request)\n \/\/that the client has sent with the nonce value in this request\n authParams->nc++;\n }\n\n \/\/Perform digest operation\n error = httpClientComputeDigest(authParams, context->method,\n osStrlen(context->method), uri, uriLen, response);\n \/\/Any error to report?\n if(error)\n return error;\n\n \/\/Determine the length of the header field\n n = osStrlen(authParams->username) + osStrlen(authParams->realm) +\n uriLen + osStrlen(authParams->nonce) + osStrlen(authParams->cnonce) +\n osStrlen(response) + osStrlen(authParams->opaque);\n\n \/\/Make sure the buffer is large enough\n if((context->bufferLen + n + 121) > HTTP_CLIENT_BUFFER_SIZE)\n return ERROR_BUFFER_OVERFLOW;\n\n \/\/Point to the buffer where to format the Authorization header field\n p = context->buffer + context->bufferLen - 2;\n\n \/\/Format Authorization header field\n n = osSprintf(p, \"Authorization: Digest \");\n\n \/\/Format username and realm parameter\n n += osSprintf(p + n, \"username=\\\"%s\\\", \", authParams->username);\n n += osSprintf(p + n, \"realm=\\\"%s\\\", \", authParams->realm);\n\n \/\/Format uri parameter\n n += osSprintf(p + n, \"uri=\\\"\");\n osStrncpy(p + n, uri, uriLen);\n n += uriLen;\n n += osSprintf(p + n, \"\\\", \");\n\n \/\/Format nonce parameter\n n += osSprintf(p + n, \"nonce=\\\"%s\\\", \", authParams->nonce);\n\n \/\/Check quality of protection\n if(authParams->qop == HTTP_AUTH_QOP_AUTH)\n {\n \/\/Format qop, nc, cnonce parameters\n n += osSprintf(p + n, \"qop=auth, \");\n n += osSprintf(p + n, \"nc=%08x, \", authParams->nc);\n n += osSprintf(p + n, \"cnonce=\\\"%s\\\", \", authParams->cnonce);\n }\n\n \/\/Format response parameter\n n += osSprintf(p + n, \"response=\\\"%s\\\"\", response);\n\n \/\/The opaque parameter should be returned by the client unchanged in\n \/\/the Authorization header field of subsequent requests\n if(authParams->opaque[0] != '\\0')\n {\n \/\/Format opaque parameter\n n += osSprintf(p + n, \", opaque=\\\"%s\\\"\", authParams->opaque);\n }\n\n \/\/Terminate the header field with a CRLF sequence\n osSprintf(p + n, \"\\r\\n\\r\\n\");\n\n \/\/Adjust the length of the request header\n context->bufferLen = context->bufferLen + n + 2;\n }\n else\n#endif\n \/\/Unknown authentication scheme?\n {\n \/\/Just for sanity\n }\n\n \/\/Successful processing\n return NO_ERROR;\n}","target":1,"code_token_length":1529,"total_token_length":1765,"max_tokens_setting":2048} +{"idx":87587,"func":"static int dw2102_probe(struct usb_interface *intf,\n\t\tconst struct usb_device_id *id)\n{\n\tp1100 = kmemdup(&s6x0_properties,\n\t\t\tsizeof(struct dvb_usb_device_properties), GFP_KERNEL);\n\tif (!p1100)\n\t\treturn -ENOMEM;\n\t\/* copy default structure *\/\n\t\/* fill only different fields *\/\n\tp1100->firmware = P1100_FIRMWARE;\n\tp1100->devices[0] = d1100;\n\tp1100->rc.core.rc_query = prof_rc_query;\n\tp1100->rc.core.rc_codes = RC_MAP_TBS_NEC;\n\tp1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;\n\n\ts660 = kmemdup(&s6x0_properties,\n\t\t sizeof(struct dvb_usb_device_properties), GFP_KERNEL);\n\tif (!s660) {\n\t\tkfree(p1100);\n\t\treturn -ENOMEM;\n\t}\n\ts660->firmware = S660_FIRMWARE;\n\ts660->num_device_descs = 3;\n\ts660->devices[0] = d660;\n\ts660->devices[1] = d480_1;\n\ts660->devices[2] = d480_2;\n\ts660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;\n\n\tp7500 = kmemdup(&s6x0_properties,\n\t\t\tsizeof(struct dvb_usb_device_properties), GFP_KERNEL);\n\tif (!p7500) {\n\t\tkfree(p1100);\n\t\tkfree(s660);\n\t\treturn -ENOMEM;\n\t}\n\tp7500->firmware = P7500_FIRMWARE;\n\tp7500->devices[0] = d7500;\n\tp7500->rc.core.rc_query = prof_rc_query;\n\tp7500->rc.core.rc_codes = RC_MAP_TBS_NEC;\n\tp7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;\n\n\n\ts421 = kmemdup(&su3000_properties,\n\t\t sizeof(struct dvb_usb_device_properties), GFP_KERNEL);\n\tif (!s421) {\n\t\tkfree(p1100);\n\t\tkfree(s660);\n\t\tkfree(p7500);\n\t\treturn -ENOMEM;\n\t}\n\ts421->num_device_descs = 2;\n\ts421->devices[0] = d421;\n\ts421->devices[1] = d632;\n\ts421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach;\n\n\tif (0 == dvb_usb_device_init(intf, &dw2102_properties,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, &dw2104_properties,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, &dw3101_properties,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, &s6x0_properties,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, p1100,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, s660,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, p7500,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, s421,\n\t\t\tTHIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, &su3000_properties,\n\t\t\t THIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, &t220_properties,\n\t\t\t THIS_MODULE, NULL, adapter_nr) ||\n\t 0 == dvb_usb_device_init(intf, &tt_s2_4600_properties,\n\t\t\t THIS_MODULE, NULL, adapter_nr))\n\t\treturn 0;\n\n\treturn -ENODEV;\n}","target":0,"code_token_length":942,"total_token_length":1178,"max_tokens_setting":2048} +{"idx":501,"func":"static void e1000e_write_packet_to_guest ( E1000ECore * core , struct NetRxPkt * pkt , const E1000E_RxRing * rxr , const E1000E_RSSInfo * rss_info ) {\n PCIDevice * d = core -> owner ;\n dma_addr_t base ;\n uint8_t desc [ E1000_MAX_RX_DESC_LEN ] ;\n size_t desc_size ;\n size_t desc_offset = 0 ;\n size_t iov_ofs = 0 ;\n struct iovec * iov = net_rx_pkt_get_iovec ( pkt ) ;\n size_t size = net_rx_pkt_get_total_len ( pkt ) ;\n size_t total_size = size + e1000x_fcs_len ( core -> mac ) ;\n const E1000E_RingInfo * rxi ;\n size_t ps_hdr_len = 0 ;\n bool do_ps = e1000e_do_ps ( core , pkt , & ps_hdr_len ) ;\n bool is_first = true ;\n rxi = rxr -> i ;\n do {\n hwaddr ba [ MAX_PS_BUFFERS ] ;\n e1000e_ba_state bastate = {\n {\n 0 }\n }\n ;\n bool is_last = false ;\n desc_size = total_size - desc_offset ;\n if ( desc_size > core -> rx_desc_buf_size ) {\n desc_size = core -> rx_desc_buf_size ;\n }\n base = e1000e_ring_head_descr ( core , rxi ) ;\n pci_dma_read ( d , base , & desc , core -> rx_desc_len ) ;\n trace_e1000e_rx_descr ( rxi -> idx , base , core -> rx_desc_len ) ;\n e1000e_read_rx_descr ( core , desc , & ba ) ;\n if ( ba [ 0 ] ) {\n if ( desc_offset < size ) {\n static const uint32_t fcs_pad ;\n size_t iov_copy ;\n size_t copy_size = size - desc_offset ;\n if ( copy_size > core -> rx_desc_buf_size ) {\n copy_size = core -> rx_desc_buf_size ;\n }\n if ( do_ps ) {\n if ( is_first ) {\n size_t ps_hdr_copied = 0 ;\n do {\n iov_copy = MIN ( ps_hdr_len - ps_hdr_copied , iov -> iov_len - iov_ofs ) ;\n e1000e_write_hdr_to_rx_buffers ( core , & ba , & bastate , iov -> iov_base , iov_copy ) ;\n copy_size -= iov_copy ;\n ps_hdr_copied += iov_copy ;\n iov_ofs += iov_copy ;\n if ( iov_ofs == iov -> iov_len ) {\n iov ++ ;\n iov_ofs = 0 ;\n }\n }\n while ( ps_hdr_copied < ps_hdr_len ) ;\n is_first = false ;\n }\n else {\n e1000e_write_hdr_to_rx_buffers ( core , & ba , & bastate , NULL , 0 ) ;\n }\n }\n while ( copy_size ) {\n iov_copy = MIN ( copy_size , iov -> iov_len - iov_ofs ) ;\n e1000e_write_to_rx_buffers ( core , & ba , & bastate , iov -> iov_base + iov_ofs , iov_copy ) ;\n copy_size -= iov_copy ;\n iov_ofs += iov_copy ;\n if ( iov_ofs == iov -> iov_len ) {\n iov ++ ;\n iov_ofs = 0 ;\n }\n }\n if ( desc_offset + desc_size >= total_size ) {\n e1000e_write_to_rx_buffers ( core , & ba , & bastate , ( const char * ) & fcs_pad , e1000x_fcs_len ( core -> mac ) ) ;\n }\n }\n desc_offset += desc_size ;\n if ( desc_offset >= total_size ) {\n is_last = true ;\n }\n }\n else {\n trace_e1000e_rx_null_descriptor ( ) ;\n }\n e1000e_write_rx_descr ( core , desc , is_last ? core -> rx_pkt : NULL , rss_info , do_ps ? ps_hdr_len : 0 , & bastate . written ) ;\n pci_dma_write ( d , base , & desc , core -> rx_desc_len ) ;\n e1000e_ring_advance ( core , rxi , core -> rx_desc_len \/ E1000_MIN_RX_DESC_LEN ) ;\n }\n while ( desc_offset < total_size ) ;\n e1000e_update_rx_stats ( core , size , total_size ) ;\n }","target":1,"code_token_length":930,"total_token_length":1166,"max_tokens_setting":2048} +{"idx":333376,"func":"int tcg_gen_code(TCGContext *s, tcg_insn_unit *gen_code_buf)\n\n{\n\n int i, oi, oi_next, num_insns;\n\n\n\n#ifdef CONFIG_PROFILER\n\n {\n\n int n;\n\n\n\n n = s->gen_last_op_idx + 1;\n\n s->op_count += n;\n\n if (n > s->op_count_max) {\n\n s->op_count_max = n;\n\n }\n\n\n\n n = s->nb_temps;\n\n s->temp_count += n;\n\n if (n > s->temp_count_max) {\n\n s->temp_count_max = n;\n\n }\n\n }\n\n#endif\n\n\n\n#ifdef DEBUG_DISAS\n\n if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {\n\n qemu_log(\"OP:\\n\");\n\n tcg_dump_ops(s);\n\n qemu_log(\"\\n\");\n\n }\n\n#endif\n\n\n\n#ifdef CONFIG_PROFILER\n\n s->opt_time -= profile_getclock();\n\n#endif\n\n\n\n#ifdef USE_TCG_OPTIMIZATIONS\n\n tcg_optimize(s);\n\n#endif\n\n\n\n#ifdef CONFIG_PROFILER\n\n s->opt_time += profile_getclock();\n\n s->la_time -= profile_getclock();\n\n#endif\n\n\n\n tcg_liveness_analysis(s);\n\n\n\n#ifdef CONFIG_PROFILER\n\n s->la_time += profile_getclock();\n\n#endif\n\n\n\n#ifdef DEBUG_DISAS\n\n if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT))) {\n\n qemu_log(\"OP after optimization and liveness analysis:\\n\");\n\n tcg_dump_ops(s);\n\n qemu_log(\"\\n\");\n\n }\n\n#endif\n\n\n\n tcg_reg_alloc_start(s);\n\n\n\n s->code_buf = gen_code_buf;\n\n s->code_ptr = gen_code_buf;\n\n\n\n tcg_out_tb_init(s);\n\n\n\n num_insns = -1;\n\n for (oi = s->gen_first_op_idx; oi >= 0; oi = oi_next) {\n\n TCGOp * const op = &s->gen_op_buf[oi];\n\n TCGArg * const args = &s->gen_opparam_buf[op->args];\n\n TCGOpcode opc = op->opc;\n\n const TCGOpDef *def = &tcg_op_defs[opc];\n\n uint16_t dead_args = s->op_dead_args[oi];\n\n uint8_t sync_args = s->op_sync_args[oi];\n\n\n\n oi_next = op->next;\n\n#ifdef CONFIG_PROFILER\n\n tcg_table_op_count[opc]++;\n\n#endif\n\n\n\n switch (opc) {\n\n case INDEX_op_mov_i32:\n\n case INDEX_op_mov_i64:\n\n tcg_reg_alloc_mov(s, def, args, dead_args, sync_args);\n\n break;\n\n case INDEX_op_movi_i32:\n\n case INDEX_op_movi_i64:\n\n tcg_reg_alloc_movi(s, args, dead_args, sync_args);\n\n break;\n\n case INDEX_op_insn_start:\n\n if (num_insns >= 0) {\n\n s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);\n\n }\n\n num_insns++;\n\n for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {\n\n target_ulong a;\n\n#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS\n\n a = ((target_ulong)args[i * 2 + 1] << 32) | args[i * 2];\n\n#else\n\n a = args[i];\n\n#endif\n\n s->gen_insn_data[num_insns][i] = a;\n\n }\n\n break;\n\n case INDEX_op_discard:\n\n temp_dead(s, args[0]);\n\n break;\n\n case INDEX_op_set_label:\n\n tcg_reg_alloc_bb_end(s, s->reserved_regs);\n\n tcg_out_label(s, arg_label(args[0]), s->code_ptr);\n\n break;\n\n case INDEX_op_call:\n\n tcg_reg_alloc_call(s, op->callo, op->calli, args,\n\n dead_args, sync_args);\n\n break;\n\n default:\n\n \/* Sanity check that we've not introduced any unhandled opcodes. *\/\n\n if (def->flags & TCG_OPF_NOT_PRESENT) {\n\n tcg_abort();\n\n }\n\n \/* Note: in order to speed up the code, it would be much\n\n faster to have specialized register allocator functions for\n\n some common argument patterns *\/\n\n tcg_reg_alloc_op(s, def, opc, args, dead_args, sync_args);\n\n break;\n\n }\n\n#ifndef NDEBUG\n\n check_regs(s);\n\n#endif\n\n \/* Test for (pending) buffer overflow. The assumption is that any\n\n one operation beginning below the high water mark cannot overrun\n\n the buffer completely. Thus we can test for overflow after\n\n generating code without having to check during generation. *\/\n\n if (unlikely((void *)s->code_ptr > s->code_gen_highwater)) {\n\n return -1;\n\n }\n\n }\n\n tcg_debug_assert(num_insns >= 0);\n\n s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);\n\n\n\n \/* Generate TB finalization at the end of block *\/\n\n tcg_out_tb_finalize(s);\n\n\n\n \/* flush instruction cache *\/\n\n flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr);\n\n\n\n return tcg_current_code_size(s);\n\n}\n","target":0,"code_token_length":1107,"total_token_length":1343,"max_tokens_setting":2048} +{"idx":482029,"func":"static int smtc_blank(int blank_mode, struct fb_info *info)\n{\n\tstruct smtcfb_info *sfb = info->par;\n\n\t\/* clear DPMS setting *\/\n\tswitch (blank_mode) {\n\tcase FB_BLANK_UNBLANK:\n\t\t\/* Screen On: HSync: On, VSync : On *\/\n\n\t\tswitch (sfb->chip_id) {\n\t\tcase 0x710:\n\t\tcase 0x712:\n\t\t\tsmtc_seqw(0x6a, 0x16);\n\t\t\tsmtc_seqw(0x6b, 0x02);\n\t\t\tbreak;\n\t\tcase 0x720:\n\t\t\tsmtc_seqw(0x6a, 0x0d);\n\t\t\tsmtc_seqw(0x6b, 0x02);\n\t\t\tbreak;\n\t\t}\n\n\t\tsmtc_seqw(0x23, (smtc_seqr(0x23) & (~0xc0)));\n\t\tsmtc_seqw(0x01, (smtc_seqr(0x01) & (~0x20)));\n\t\tsmtc_seqw(0x21, (smtc_seqr(0x21) & 0x77));\n\t\tsmtc_seqw(0x22, (smtc_seqr(0x22) & (~0x30)));\n\t\tsmtc_seqw(0x31, (smtc_seqr(0x31) | 0x03));\n\t\tsmtc_seqw(0x24, (smtc_seqr(0x24) | 0x01));\n\t\tbreak;\n\tcase FB_BLANK_NORMAL:\n\t\t\/* Screen Off: HSync: On, VSync : On Soft blank *\/\n\t\tsmtc_seqw(0x24, (smtc_seqr(0x24) | 0x01));\n\t\tsmtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));\n\t\tsmtc_seqw(0x23, (smtc_seqr(0x23) & (~0xc0)));\n\t\tsmtc_seqw(0x01, (smtc_seqr(0x01) & (~0x20)));\n\t\tsmtc_seqw(0x22, (smtc_seqr(0x22) & (~0x30)));\n\t\tsmtc_seqw(0x6a, 0x16);\n\t\tsmtc_seqw(0x6b, 0x02);\n\t\tbreak;\n\tcase FB_BLANK_VSYNC_SUSPEND:\n\t\t\/* Screen On: HSync: On, VSync : Off *\/\n\t\tsmtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));\n\t\tsmtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));\n\t\tsmtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0x20));\n\t\tsmtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));\n\t\tsmtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));\n\t\tsmtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));\n\t\tsmtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x20));\n\t\tsmtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));\n\t\tsmtc_seqw(0x6a, 0x0c);\n\t\tsmtc_seqw(0x6b, 0x02);\n\t\tbreak;\n\tcase FB_BLANK_HSYNC_SUSPEND:\n\t\t\/* Screen On: HSync: Off, VSync : On *\/\n\t\tsmtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));\n\t\tsmtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));\n\t\tsmtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0xD8));\n\t\tsmtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));\n\t\tsmtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));\n\t\tsmtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));\n\t\tsmtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x10));\n\t\tsmtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));\n\t\tsmtc_seqw(0x6a, 0x0c);\n\t\tsmtc_seqw(0x6b, 0x02);\n\t\tbreak;\n\tcase FB_BLANK_POWERDOWN:\n\t\t\/* Screen On: HSync: Off, VSync : Off *\/\n\t\tsmtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));\n\t\tsmtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));\n\t\tsmtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0xD8));\n\t\tsmtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));\n\t\tsmtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));\n\t\tsmtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));\n\t\tsmtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x30));\n\t\tsmtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));\n\t\tsmtc_seqw(0x6a, 0x0c);\n\t\tsmtc_seqw(0x6b, 0x02);\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":1601,"total_token_length":1837,"max_tokens_setting":2048} +{"idx":295102,"func":"static MagickBooleanType WriteMATImage(const ImageInfo *image_info,Image *image,\n ExceptionInfo *exception)\n{\n ssize_t y;\n unsigned z;\n register const Quantum *p;\n\n unsigned int status;\n int logging;\n size_t DataSize;\n char padding;\n char MATLAB_HDR[0x80];\n time_t current_time;\n struct tm local_time;\n unsigned char *pixels;\n int is_gray;\n\n MagickOffsetType\n scene;\n\n QuantumInfo\n *quantum_info;\n\n \/*\n Open output image file.\n *\/\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickCoreSignature);\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n logging=LogMagickEvent(CoderEvent,GetMagickModule(),\"enter MAT\");\n (void) logging;\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n if (status == MagickFalse)\n return(MagickFalse);\n image->depth=8;\n\n current_time=time((time_t *) NULL);\n#if defined(MAGICKCORE_HAVE_LOCALTIME_R)\n (void) localtime_r(¤t_time,&local_time);\n#else\n (void) memcpy(&local_time,localtime(¤t_time),sizeof(local_time));\n#endif\n (void) memset(MATLAB_HDR,' ',MagickMin(sizeof(MATLAB_HDR),124));\n FormatLocaleString(MATLAB_HDR,sizeof(MATLAB_HDR),\n \"MATLAB 5.0 MAT-file, Platform: %s, Created on: %s %s %2d %2d:%2d:%2d %d\",\n OsDesc,DayOfWTab[local_time.tm_wday],MonthsTab[local_time.tm_mon],\n local_time.tm_mday,local_time.tm_hour,local_time.tm_min,\n local_time.tm_sec,local_time.tm_year+1900);\n MATLAB_HDR[0x7C]=0;\n MATLAB_HDR[0x7D]=1;\n MATLAB_HDR[0x7E]='I';\n MATLAB_HDR[0x7F]='M';\n (void) WriteBlob(image,sizeof(MATLAB_HDR),(unsigned char *) MATLAB_HDR);\n scene=0;\n do\n {\n (void) TransformImageColorspace(image,sRGBColorspace,exception);\n is_gray = SetImageGray(image,exception);\n z = is_gray ? 0 : 3;\n\n \/*\n Store MAT header.\n *\/\n DataSize = image->rows \/*Y*\/ * image->columns \/*X*\/;\n if(!is_gray) DataSize *= 3 \/*Z*\/;\n padding=((unsigned char)(DataSize-1) & 0x7) ^ 0x7;\n\n (void) WriteBlobLSBLong(image, miMATRIX);\n (void) WriteBlobLSBLong(image, (unsigned int) DataSize+padding+(is_gray ? 48 : 56));\n (void) WriteBlobLSBLong(image, 0x6); \/* 0x88 *\/\n (void) WriteBlobLSBLong(image, 0x8); \/* 0x8C *\/\n (void) WriteBlobLSBLong(image, 0x6); \/* 0x90 *\/ \n (void) WriteBlobLSBLong(image, 0); \n (void) WriteBlobLSBLong(image, 0x5); \/* 0x98 *\/\n (void) WriteBlobLSBLong(image, is_gray ? 0x8 : 0xC); \/* 0x9C - DimFlag *\/\n (void) WriteBlobLSBLong(image, (unsigned int) image->rows); \/* x: 0xA0 *\/ \n (void) WriteBlobLSBLong(image, (unsigned int) image->columns); \/* y: 0xA4 *\/ \n if(!is_gray)\n {\n (void) WriteBlobLSBLong(image, 3); \/* z: 0xA8 *\/ \n (void) WriteBlobLSBLong(image, 0);\n }\n (void) WriteBlobLSBShort(image, 1); \/* 0xB0 *\/ \n (void) WriteBlobLSBShort(image, 1); \/* 0xB2 *\/\n (void) WriteBlobLSBLong(image, 'M'); \/* 0xB4 *\/\n (void) WriteBlobLSBLong(image, 0x2); \/* 0xB8 *\/ \n (void) WriteBlobLSBLong(image, (unsigned int) DataSize); \/* 0xBC *\/\n\n \/*\n Store image data.\n *\/\n quantum_info=AcquireQuantumInfo(image_info,image);\n if (quantum_info == (QuantumInfo *) NULL)\n ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n pixels=(unsigned char *) GetQuantumPixels(quantum_info);\n do\n {\n for (y=0; y < (ssize_t)image->columns; y++)\n {\n p=GetVirtualPixels(image,y,0,1,image->rows,exception);\n if (p == (const Quantum *) NULL)\n break;\n (void) ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n z2qtype[z],pixels,exception);\n (void) WriteBlob(image,image->rows,pixels);\n } \n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n } while(z-- >= 2);\n while(padding-->0) (void) WriteBlobByte(image,0);\n quantum_info=DestroyQuantumInfo(quantum_info);\n if (GetNextImageInList(image) == (Image *) NULL)\n break;\n image=SyncNextImageInList(image);\n status=SetImageProgress(image,SaveImagesTag,scene++,\n GetImageListLength(image));\n if (status == MagickFalse)\n break;\n } while (image_info->adjoin != MagickFalse);\n (void) CloseBlob(image);\n return(MagickTrue);\n}","target":0,"code_token_length":1325,"total_token_length":1561,"max_tokens_setting":2048} +{"idx":26788,"func":"TEST_F ( TemplateURLTest , URLRefTestImageURLWithPOST ) {\n const char kInvalidPostParamsString [ ] = \"unknown_template={\nUnknownTemplate}\n,bad_value=bad{\nvalue}\n,\" \"{\ngoogle:sbiSource}\n\" ;\n const char kValidPostParamsString [ ] = \"image_content={\ngoogle:imageThumbnail}\n,image_url={\ngoogle:imageURL}\n,\" \"sbisrc={\ngoogle:imageSearchSource}\n,language={\nlanguage}\n,empty_param=,\" \"constant_param=constant,width={\ngoogle:imageOriginalWidth}\n\" ;\n const char KImageSearchURL [ ] = \"http:\/\/foo.com\/sbi\" ;\n TemplateURLData data ;\n data . image_url = KImageSearchURL ;\n data . image_url_post_params = kInvalidPostParamsString ;\n TemplateURL url_bad ( data ) ;\n ASSERT_FALSE ( url_bad . image_url_ref ( ) . IsValid ( search_terms_data_ ) ) ;\n const TemplateURLRef : : PostParams & bad_post_params = url_bad . image_url_ref ( ) . post_params_ ;\n ASSERT_EQ ( 2U , bad_post_params . size ( ) ) ;\n ExpectPostParamIs ( bad_post_params [ 0 ] , \"unknown_template\" , \"{\nUnknownTemplate}\n\" ) ;\n ExpectPostParamIs ( bad_post_params [ 1 ] , \"bad_value\" , \"bad{\nvalue}\n\" ) ;\n data . image_url_post_params = kValidPostParamsString ;\n TemplateURL url ( data ) ;\n ASSERT_TRUE ( url . image_url_ref ( ) . IsValid ( search_terms_data_ ) ) ;\n ASSERT_FALSE ( url . image_url_ref ( ) . SupportsReplacement ( search_terms_data_ ) ) ;\n TemplateURLRef : : SearchTermsArgs search_args ( ASCIIToUTF16 ( \"X\" ) ) ;\n search_args . image_thumbnail_content = \"dummy-image-thumbnail\" ;\n search_args . image_url = GURL ( \"http:\/\/dummyimage.com\/dummy.jpg\" ) ;\n search_args . image_original_size = gfx : : Size ( 10 , 10 ) ;\n TestingSearchTermsData search_terms_data ( \"http:\/\/X\" ) ;\n GURL result ( url . image_url_ref ( ) . ReplaceSearchTerms ( search_args , search_terms_data ) ) ;\n ASSERT_TRUE ( result . is_valid ( ) ) ;\n EXPECT_EQ ( KImageSearchURL , result . spec ( ) ) ;\n TemplateURLRef : : PostContent post_content ;\n result = GURL ( url . image_url_ref ( ) . ReplaceSearchTerms ( search_args , search_terms_data , & post_content ) ) ;\n ASSERT_TRUE ( result . is_valid ( ) ) ;\n EXPECT_EQ ( KImageSearchURL , result . spec ( ) ) ;\n ASSERT_FALSE ( post_content . first . empty ( ) ) ;\n ASSERT_FALSE ( post_content . second . empty ( ) ) ;\n const TemplateURLRef : : Replacements & replacements = url . image_url_ref ( ) . replacements_ ;\n const TemplateURLRef : : PostParams & post_params = url . image_url_ref ( ) . post_params_ ;\n EXPECT_EQ ( 7U , post_params . size ( ) ) ;\n for ( TemplateURLRef : : PostParams : : const_iterator i = post_params . begin ( ) ;\n i != post_params . end ( ) ;\n ++ i ) {\n TemplateURLRef : : Replacements : : const_iterator j = replacements . begin ( ) ;\n for ( ;\n j != replacements . end ( ) ;\n ++ j ) {\n if ( j -> is_post_param && j -> index == static_cast < size_t > ( i - post_params . begin ( ) ) ) {\n switch ( j -> type ) {\n case TemplateURLRef : : GOOGLE_IMAGE_ORIGINAL_WIDTH : ExpectPostParamIs ( * i , \"width\" , base : : IntToString ( search_args . image_original_size . width ( ) ) ) ;\n break ;\n case TemplateURLRef : : GOOGLE_IMAGE_SEARCH_SOURCE : ExpectPostParamIs ( * i , \"sbisrc\" , search_terms_data . GoogleImageSearchSource ( ) ) ;\n break ;\n case TemplateURLRef : : GOOGLE_IMAGE_THUMBNAIL : ExpectPostParamIs ( * i , \"image_content\" , search_args . image_thumbnail_content , \"image\/jpeg\" ) ;\n break ;\n case TemplateURLRef : : GOOGLE_IMAGE_URL : ExpectPostParamIs ( * i , \"image_url\" , search_args . image_url . spec ( ) ) ;\n break ;\n case TemplateURLRef : : LANGUAGE : ExpectPostParamIs ( * i , \"language\" , \"en\" ) ;\n break ;\n default : ADD_FAILURE ( ) ;\n }\n break ;\n }\n }\n if ( j != replacements . end ( ) ) continue ;\n if ( i -> name == \"empty_param\" ) ExpectPostParamIs ( * i , \"empty_param\" , std : : string ( ) ) ;\n else ExpectPostParamIs ( * i , \"constant_param\" , \"constant\" ) ;\n }\n }","target":0,"code_token_length":1008,"total_token_length":1244,"max_tokens_setting":2048} +{"idx":370742,"func":"static void nmea_event_hook(struct gps_device_t *session, event_t event)\n{\n if (session->context->readonly)\n\treturn;\n \/*\n * This is where we try to tickle NMEA devices into revealing their\n * inner natures.\n *\/\n if (event == event_configure) {\n\t\/*\n\t * The reason for splitting these probes up by packet sequence\n\t * number, interleaving them with the first few packet receives,\n\t * is because many generic-NMEA devices get confused if you send\n\t * too much at them in one go.\n\t *\n\t * A fast response to an early probe will change drivers so the\n\t * later ones won't be sent at all. Thus, for best overall\n\t * performance, order these to probe for the most popular types\n\t * soonest.\n\t *\n\t * Note: don't make the trigger strings identical to the probe,\n\t * because some NMEA devices (notably SiRFs) will just echo\n\t * unknown strings right back at you. A useful dodge is to append\n\t * a comma to the trigger, because that won't be in the response\n\t * unless there is actual following data.\n\t *\/\n\tswitch (session->packet.counter) {\n#ifdef NMEA_ENABLE\n\tcase 0:\n\t \/* probe for Garmin serial GPS -- expect $PGRMC followed by data *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for Garmin NMEA\\n\");\n\t (void)nmea_send(session, \"$PGRMCE\");\n\t break;\n#endif \/* NMEA_ENABLE *\/\n#ifdef SIRF_ENABLE\n\tcase 1:\n\t \/*\n\t * We used to try to probe for SiRF by issuing \"$PSRF105,1\"\n\t * and expecting \"$Ack Input105.\". But it turns out this\n\t * only works for SiRF-IIs; SiRF-I and SiRF-III don't respond.\n\t * Thus the only reliable probe is to try to flip the SiRF into\n\t * binary mode, cluing in the library to revert it on close.\n\t *\n\t * SiRFs dominate the GPS-mouse market, so we used to put this test\n\t * first. Unfortunately this causes problems for gpsctl, as it cannot\n\t * select the NMEA driver without switching the device back to\n\t * binary mode! Fix this if we ever find a nondisruptive probe string.\n\t *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for SiRF\\n\");\n\t (void)nmea_send(session,\n\t\t\t \"$PSRF100,0,%d,%d,%d,0\",\n\t\t\t session->gpsdata.dev.baudrate,\n\t\t\t 9 - session->gpsdata.dev.stopbits,\n\t\t\t session->gpsdata.dev.stopbits);\n\t session->back_to_nmea = true;\n\t break;\n#endif \/* SIRF_ENABLE *\/\n#ifdef NMEA_ENABLE\n\tcase 2:\n\t \/* probe for the FV-18 -- expect $PFEC,GPint followed by data *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for FV-18\\n\");\n\t (void)nmea_send(session, \"$PFEC,GPint\");\n\t break;\n\tcase 3:\n\t \/* probe for the Trimble Copernicus *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for Trimble Copernicus\\n\");\n\t (void)nmea_send(session, \"$PTNLSNM,0139,01\");\n\t break;\n#endif \/* NMEA_ENABLE *\/\n#ifdef EVERMORE_ENABLE\n\tcase 4:\n\t gpsd_report(LOG_PROG, \"=> Probing for Evermore\\n\");\n\t \/* Enable checksum and GGA(1s), GLL(0s), GSA(1s), GSV(1s), RMC(1s), VTG(0s), PEMT101(1s) *\/\n\t \/* EverMore will reply with: \\x10\\x02\\x04\\x38\\x8E\\xC6\\x10\\x03 *\/\n\t (void)gpsd_write(session,\n\t\t\t \"\\x10\\x02\\x12\\x8E\\x7F\\x01\\x01\\x00\\x01\\x01\\x01\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x13\\x10\\x03\",\n\t\t\t 22);\n\t break;\n#endif \/* EVERMORE_ENABLE *\/\n#ifdef GPSCLOCK_ENABLE\n\tcase 5:\n\t \/* probe for Furuno Electric GH-79L4-N (GPSClock); expect $PFEC,GPssd *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for GPSClock\\n\");\n\t (void)nmea_send(session, \"$PFEC,GPsrq\");\n\t break;\n#endif \/* GPSCLOCK_ENABLE *\/\n#ifdef ASHTECH_ENABLE\n\tcase 6:\n\t \/* probe for Ashtech -- expect $PASHR,RID *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for Ashtech\\n\");\n\t (void)nmea_send(session, \"$PASHQ,RID\");\n\t break;\n#endif \/* ASHTECH_ENABLE *\/\n#ifdef UBX_ENABLE\n\tcase 7:\n\t \/* probe for UBX -- query software version *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for UBX\\n\");\n\t (void)ubx_write(session, 0x0au, 0x04, NULL, 0);\n\t break;\n#endif \/* UBX_ENABLE *\/\n#ifdef MTK3301_ENABLE\n\tcase 8:\n\t \/* probe for MTK-3301 -- expect $PMTK705 *\/\n\t gpsd_report(LOG_PROG, \"=> Probing for MediaTek\\n\");\n\t (void)nmea_send(session, \"$PMTK605\");\n\t break;\n#endif \/* MTK3301_ENABLE *\/\n\tdefault:\n\t break;\n\t}\n }\n}","target":0,"code_token_length":1263,"total_token_length":1499,"max_tokens_setting":2048} +{"idx":115508,"func":"static void dmar_unit_show_capability(struct dmar_drhd_rt *dmar_unit)\n{\n\tpr_info(\"dmar unit[0x%x]\", dmar_unit->drhd->reg_base_addr);\n\tpr_info(\"\\tNumDomain:%d\", iommu_cap_ndoms(dmar_unit->cap));\n\tpr_info(\"\\tAdvancedFaultLogging:%d\", iommu_cap_afl(dmar_unit->cap));\n\tpr_info(\"\\tRequiredWBFlush:%d\", iommu_cap_rwbf(dmar_unit->cap));\n\tpr_info(\"\\tProtectedLowMemRegion:%d\", iommu_cap_plmr(dmar_unit->cap));\n\tpr_info(\"\\tProtectedHighMemRegion:%d\", iommu_cap_phmr(dmar_unit->cap));\n\tpr_info(\"\\tCachingMode:%d\", iommu_cap_caching_mode(dmar_unit->cap));\n\tpr_info(\"\\tSAGAW:0x%x\", iommu_cap_sagaw(dmar_unit->cap));\n\tpr_info(\"\\tMGAW:%d\", iommu_cap_mgaw(dmar_unit->cap));\n\tpr_info(\"\\tZeroLenRead:%d\", iommu_cap_zlr(dmar_unit->cap));\n\tpr_info(\"\\tLargePageSupport:0x%x\", iommu_cap_super_page_val(dmar_unit->cap));\n\tpr_info(\"\\tPageSelectiveInvalidation:%d\", iommu_cap_pgsel_inv(dmar_unit->cap));\n\tpr_info(\"\\tPageSelectInvalidation:%d\", iommu_cap_pgsel_inv(dmar_unit->cap));\n\tpr_info(\"\\tNumOfFaultRecordingReg:%d\", iommu_cap_num_fault_regs(dmar_unit->cap));\n\tpr_info(\"\\tMAMV:0x%x\", iommu_cap_max_amask_val(dmar_unit->cap));\n\tpr_info(\"\\tWriteDraining:%d\", iommu_cap_write_drain(dmar_unit->cap));\n\tpr_info(\"\\tReadDraining:%d\", iommu_cap_read_drain(dmar_unit->cap));\n\tpr_info(\"\\tPostInterrupts:%d\\n\", iommu_cap_pi(dmar_unit->cap));\n\tpr_info(\"\\tPage-walk Coherency:%d\", iommu_ecap_c(dmar_unit->ecap));\n\tpr_info(\"\\tQueuedInvalidation:%d\", iommu_ecap_qi(dmar_unit->ecap));\n\tpr_info(\"\\tDeviceTLB:%d\", iommu_ecap_dt(dmar_unit->ecap));\n\tpr_info(\"\\tInterruptRemapping:%d\", iommu_ecap_ir(dmar_unit->ecap));\n\tpr_info(\"\\tExtendedInterruptMode:%d\", iommu_ecap_eim(dmar_unit->ecap));\n\tpr_info(\"\\tPassThrough:%d\", iommu_ecap_pt(dmar_unit->ecap));\n\tpr_info(\"\\tSnoopControl:%d\", iommu_ecap_sc(dmar_unit->ecap));\n\tpr_info(\"\\tIOTLB RegOffset:0x%x\", iommu_ecap_iro(dmar_unit->ecap));\n\tpr_info(\"\\tMHMV:0x%x\", iommu_ecap_mhmv(dmar_unit->ecap));\n\tpr_info(\"\\tECS:%d\", iommu_ecap_ecs(dmar_unit->ecap));\n\tpr_info(\"\\tMTS:%d\", iommu_ecap_mts(dmar_unit->ecap));\n\tpr_info(\"\\tNEST:%d\", iommu_ecap_nest(dmar_unit->ecap));\n\tpr_info(\"\\tDIS:%d\", iommu_ecap_dis(dmar_unit->ecap));\n\tpr_info(\"\\tPRS:%d\", iommu_ecap_prs(dmar_unit->ecap));\n\tpr_info(\"\\tERS:%d\", iommu_ecap_ers(dmar_unit->ecap));\n\tpr_info(\"\\tSRS:%d\", iommu_ecap_srs(dmar_unit->ecap));\n\tpr_info(\"\\tNWFS:%d\", iommu_ecap_nwfs(dmar_unit->ecap));\n\tpr_info(\"\\tEAFS:%d\", iommu_ecap_eafs(dmar_unit->ecap));\n\tpr_info(\"\\tPSS:0x%x\", iommu_ecap_pss(dmar_unit->ecap));\n\tpr_info(\"\\tPASID:%d\", iommu_ecap_pasid(dmar_unit->ecap));\n\tpr_info(\"\\tDIT:%d\", iommu_ecap_dit(dmar_unit->ecap));\n\tpr_info(\"\\tPDS:%d\\n\", iommu_ecap_pds(dmar_unit->ecap));\n}","target":0,"code_token_length":960,"total_token_length":1196,"max_tokens_setting":2048} +{"idx":345214,"func":"xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {\n xmlChar *name;\n const xmlChar *ptr;\n xmlChar cur;\n xmlEntityPtr ent = NULL;\n\n if ((str == NULL) || (*str == NULL))\n return(NULL);\n ptr = *str;\n cur = *ptr;\n if (cur != '&')\n\treturn(NULL);\n\n ptr++;\n name = xmlParseStringName(ctxt, &ptr);\n if (name == NULL) {\n\txmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,\n\t\t \"xmlParseStringEntityRef: no name\\n\");\n\t*str = ptr;\n\treturn(NULL);\n }\n if (*ptr != ';') {\n\txmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);\n xmlFree(name);\n\t*str = ptr;\n\treturn(NULL);\n }\n ptr++;\n\n\n \/*\n * Predefined entities override any extra definition\n *\/\n if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {\n ent = xmlGetPredefinedEntity(name);\n if (ent != NULL) {\n xmlFree(name);\n *str = ptr;\n return(ent);\n }\n }\n\n \/*\n * Increate the number of entity references parsed\n *\/\n ctxt->nbentities++;\n\n \/*\n * Ask first SAX for entity resolution, otherwise try the\n * entities which may have stored in the parser context.\n *\/\n if (ctxt->sax != NULL) {\n\tif (ctxt->sax->getEntity != NULL)\n\t ent = ctxt->sax->getEntity(ctxt->userData, name);\n\tif ((ent == NULL) && (ctxt->options & XML_PARSE_OLDSAX))\n\t ent = xmlGetPredefinedEntity(name);\n\tif ((ent == NULL) && (ctxt->userData==ctxt)) {\n\t ent = xmlSAX2GetEntity(ctxt, name);\n\t}\n }\n if (ctxt->instate == XML_PARSER_EOF) {\n\txmlFree(name);\n\treturn(NULL);\n }\n\n \/*\n * [ WFC: Entity Declared ]\n * In a document without any DTD, a document with only an\n * internal DTD subset which contains no parameter entity\n * references, or a document with \"standalone='yes'\", the\n * Name given in the entity reference must match that in an\n * entity declaration, except that well-formed documents\n * need not declare any of the following entities: amp, lt,\n * gt, apos, quot.\n * The declaration of a parameter entity must precede any\n * reference to it.\n * Similarly, the declaration of a general entity must\n * precede any reference to it which appears in a default\n * value in an attribute-list declaration. Note that if\n * entities are declared in the external subset or in\n * external parameter entities, a non-validating processor\n * is not obligated to read and process their declarations;\n * for such documents, the rule that an entity must be\n * declared is a well-formedness constraint only if\n * standalone='yes'.\n *\/\n if (ent == NULL) {\n\tif ((ctxt->standalone == 1) ||\n\t ((ctxt->hasExternalSubset == 0) &&\n\t (ctxt->hasPErefs == 0))) {\n\t xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,\n\t\t \"Entity '%s' not defined\\n\", name);\n\t} else {\n\t xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,\n\t\t\t \"Entity '%s' not defined\\n\",\n\t\t\t name);\n\t}\n\t\/* TODO ? check regressions ctxt->valid = 0; *\/\n }\n\n \/*\n * [ WFC: Parsed Entity ]\n * An entity reference must not contain the name of an\n * unparsed entity\n *\/\n else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {\n\txmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,\n\t\t \"Entity reference to unparsed entity %s\\n\", name);\n }\n\n \/*\n * [ WFC: No External Entity References ]\n * Attribute values cannot contain direct or indirect\n * entity references to external entities.\n *\/\n else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&\n\t (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {\n\txmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,\n\t \"Attribute references external entity '%s'\\n\", name);\n }\n \/*\n * [ WFC: No < in Attribute Values ]\n * The replacement text of any entity referred to directly or\n * indirectly in an attribute value (other than \"<\") must\n * not contain a <.\n *\/\n else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&\n\t (ent != NULL) && (ent->content != NULL) &&\n\t (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&\n\t (xmlStrchr(ent->content, '<'))) {\n\txmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,\n \"'<' in entity '%s' is not allowed in attributes values\\n\",\n\t\t\t name);\n }\n\n \/*\n * Internal check, no parameter entities here ...\n *\/\n else {\n\tswitch (ent->etype) {\n\t case XML_INTERNAL_PARAMETER_ENTITY:\n\t case XML_EXTERNAL_PARAMETER_ENTITY:\n\t\txmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,\n\t \"Attempt to reference the parameter entity '%s'\\n\",\n\t\t\t\t name);\n\t break;\n\t default:\n\t break;\n\t}\n }\n\n \/*\n * [ WFC: No Recursion ]\n * A parsed entity must not contain a recursive reference\n * to itself, either directly or indirectly.\n * Done somewhere else\n *\/\n\n xmlFree(name);\n *str = ptr;\n return(ent);\n}","target":1,"code_token_length":1235,"total_token_length":1471,"max_tokens_setting":2048} +{"idx":484240,"func":"mlx5_select_tx_function(struct rte_eth_dev *dev)\n{\n\tstruct mlx5_priv *priv = dev->data->dev_private;\n\tstruct mlx5_dev_config *config = &priv->config;\n\tuint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;\n\tunsigned int diff = 0, olx = 0, i, m;\n\n\tstatic_assert(MLX5_WQE_SIZE_MAX \/ MLX5_WSEG_SIZE <=\n\t\t MLX5_DSEG_MAX, \"invalid WQE max size\");\n\tstatic_assert(MLX5_WQE_CSEG_SIZE == MLX5_WSEG_SIZE,\n\t\t \"invalid WQE Control Segment size\");\n\tstatic_assert(MLX5_WQE_ESEG_SIZE == MLX5_WSEG_SIZE,\n\t\t \"invalid WQE Ethernet Segment size\");\n\tstatic_assert(MLX5_WQE_DSEG_SIZE == MLX5_WSEG_SIZE,\n\t\t \"invalid WQE Data Segment size\");\n\tstatic_assert(MLX5_WQE_SIZE == 4 * MLX5_WSEG_SIZE,\n\t\t \"invalid WQE size\");\n\tassert(priv);\n\tif (tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS) {\n\t\t\/* We should support Multi-Segment Packets. *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_MULTI;\n\t}\n\tif (tx_offloads & (DEV_TX_OFFLOAD_TCP_TSO |\n\t\t\t DEV_TX_OFFLOAD_VXLAN_TNL_TSO |\n\t\t\t DEV_TX_OFFLOAD_GRE_TNL_TSO |\n\t\t\t DEV_TX_OFFLOAD_IP_TNL_TSO |\n\t\t\t DEV_TX_OFFLOAD_UDP_TNL_TSO)) {\n\t\t\/* We should support TCP Send Offload. *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_TSO;\n\t}\n\tif (tx_offloads & (DEV_TX_OFFLOAD_IP_TNL_TSO |\n\t\t\t DEV_TX_OFFLOAD_UDP_TNL_TSO |\n\t\t\t DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {\n\t\t\/* We should support Software Parser for Tunnels. *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_SWP;\n\t}\n\tif (tx_offloads & (DEV_TX_OFFLOAD_IPV4_CKSUM |\n\t\t\t DEV_TX_OFFLOAD_UDP_CKSUM |\n\t\t\t DEV_TX_OFFLOAD_TCP_CKSUM |\n\t\t\t DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {\n\t\t\/* We should support IP\/TCP\/UDP Checksums. *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_CSUM;\n\t}\n\tif (tx_offloads & DEV_TX_OFFLOAD_VLAN_INSERT) {\n\t\t\/* We should support VLAN insertion. *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_VLAN;\n\t}\n\tif (priv->txqs_n && (*priv->txqs)[0]) {\n\t\tstruct mlx5_txq_data *txd = (*priv->txqs)[0];\n\n\t\tif (txd->inlen_send) {\n\t\t\t\/*\n\t\t\t * Check the data inline requirements. Data inline\n\t\t\t * is enabled on per device basis, we can check\n\t\t\t * the first Tx queue only.\n\t\t\t *\n\t\t\t * If device does not support VLAN insertion in WQE\n\t\t\t * and some queues are requested to perform VLAN\n\t\t\t * insertion offload than inline must be enabled.\n\t\t\t *\/\n\t\t\tolx |= MLX5_TXOFF_CONFIG_INLINE;\n\t\t}\n\t}\n\tif (config->mps == MLX5_MPW_ENHANCED &&\n\t config->txq_inline_min <= 0) {\n\t\t\/*\n\t\t * The NIC supports Enhanced Multi-Packet Write\n\t\t * and does not require minimal inline data.\n\t\t *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_EMPW;\n\t}\n\tif (rte_flow_dynf_metadata_avail()) {\n\t\t\/* We should support Flow metadata. *\/\n\t\tolx |= MLX5_TXOFF_CONFIG_METADATA;\n\t}\n\tif (config->mps == MLX5_MPW) {\n\t\t\/*\n\t\t * The NIC supports Legacy Multi-Packet Write.\n\t\t * The MLX5_TXOFF_CONFIG_MPW controls the\n\t\t * descriptor building method in combination\n\t\t * with MLX5_TXOFF_CONFIG_EMPW.\n\t\t *\/\n\t\tif (!(olx & (MLX5_TXOFF_CONFIG_TSO |\n\t\t\t MLX5_TXOFF_CONFIG_SWP |\n\t\t\t MLX5_TXOFF_CONFIG_VLAN |\n\t\t\t MLX5_TXOFF_CONFIG_METADATA)))\n\t\t\tolx |= MLX5_TXOFF_CONFIG_EMPW |\n\t\t\t MLX5_TXOFF_CONFIG_MPW;\n\t}\n\t\/*\n\t * Scan the routines table to find the minimal\n\t * satisfying routine with requested offloads.\n\t *\/\n\tm = RTE_DIM(txoff_func);\n\tfor (i = 0; i < RTE_DIM(txoff_func); i++) {\n\t\tunsigned int tmp;\n\n\t\ttmp = txoff_func[i].olx;\n\t\tif (tmp == olx) {\n\t\t\t\/* Meets requested offloads exactly.*\/\n\t\t\tm = i;\n\t\t\tbreak;\n\t\t}\n\t\tif ((tmp & olx) != olx) {\n\t\t\t\/* Does not meet requested offloads at all. *\/\n\t\t\tcontinue;\n\t\t}\n\t\tif ((olx ^ tmp) & MLX5_TXOFF_CONFIG_MPW)\n\t\t\t\/* Do not enable legacy MPW if not configured. *\/\n\t\t\tcontinue;\n\t\tif ((olx ^ tmp) & MLX5_TXOFF_CONFIG_EMPW)\n\t\t\t\/* Do not enable eMPW if not configured. *\/\n\t\t\tcontinue;\n\t\tif ((olx ^ tmp) & MLX5_TXOFF_CONFIG_INLINE)\n\t\t\t\/* Do not enable inlining if not configured. *\/\n\t\t\tcontinue;\n\t\t\/*\n\t\t * Some routine meets the requirements.\n\t\t * Check whether it has minimal amount\n\t\t * of not requested offloads.\n\t\t *\/\n\t\ttmp = __builtin_popcountl(tmp & ~olx);\n\t\tif (m >= RTE_DIM(txoff_func) || tmp < diff) {\n\t\t\t\/* First or better match, save and continue. *\/\n\t\t\tm = i;\n\t\t\tdiff = tmp;\n\t\t\tcontinue;\n\t\t}\n\t\tif (tmp == diff) {\n\t\t\ttmp = txoff_func[i].olx ^ txoff_func[m].olx;\n\t\t\tif (__builtin_ffsl(txoff_func[i].olx & ~tmp) <\n\t\t\t __builtin_ffsl(txoff_func[m].olx & ~tmp)) {\n\t\t\t\t\/* Lighter not requested offload. *\/\n\t\t\t\tm = i;\n\t\t\t}\n\t\t}\n\t}\n\tif (m >= RTE_DIM(txoff_func)) {\n\t\tDRV_LOG(DEBUG, \"port %u has no selected Tx function\"\n\t\t\t \" for requested offloads %04X\",\n\t\t\t\tdev->data->port_id, olx);\n\t\treturn NULL;\n\t}\n\tDRV_LOG(DEBUG, \"port %u has selected Tx function\"\n\t\t \" supporting offloads %04X\/%04X\",\n\t\t\tdev->data->port_id, olx, txoff_func[m].olx);\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_MULTI)\n\t\tDRV_LOG(DEBUG, \"\\tMULTI (multi segment)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_TSO)\n\t\tDRV_LOG(DEBUG, \"\\tTSO (TCP send offload)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_SWP)\n\t\tDRV_LOG(DEBUG, \"\\tSWP (software parser)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_CSUM)\n\t\tDRV_LOG(DEBUG, \"\\tCSUM (checksum offload)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_INLINE)\n\t\tDRV_LOG(DEBUG, \"\\tINLIN (inline data)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_VLAN)\n\t\tDRV_LOG(DEBUG, \"\\tVLANI (VLAN insertion)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_METADATA)\n\t\tDRV_LOG(DEBUG, \"\\tMETAD (tx Flow metadata)\");\n\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_EMPW) {\n\t\tif (txoff_func[m].olx & MLX5_TXOFF_CONFIG_MPW)\n\t\t\tDRV_LOG(DEBUG, \"\\tMPW (Legacy MPW)\");\n\t\telse\n\t\t\tDRV_LOG(DEBUG, \"\\tEMPW (Enhanced MPW)\");\n\t}\n\treturn txoff_func[m].func;\n}","target":0,"code_token_length":1760,"total_token_length":1996,"max_tokens_setting":2048} +{"idx":3298,"func":"thunar_transfer_job_copy_node (ThunarTransferJob *job,\n ThunarTransferNode *node,\n GFile *target_file,\n GFile *target_parent_file,\n GList **target_file_list_return,\n GError **error)\n{\n ThunarThumbnailCache *thumbnail_cache;\n ThunarApplication *application;\n ThunarJobResponse response;\n GFileInfo *info;\n GError *err = NULL;\n GFile *real_target_file = NULL;\n gchar *base_name;\n\n _thunar_return_if_fail (THUNAR_IS_TRANSFER_JOB (job));\n _thunar_return_if_fail (node != NULL && G_IS_FILE (node->source_file));\n _thunar_return_if_fail (target_file == NULL || node->next == NULL);\n _thunar_return_if_fail ((target_file == NULL && target_parent_file != NULL) || (target_file != NULL && target_parent_file == NULL));\n _thunar_return_if_fail (error == NULL || *error == NULL);\n\n \/* The caller can either provide a target_file or a target_parent_file, but not both. The toplevel\n * transfer_nodes (for which next is NULL) should be called with target_file, to get proper behavior\n * wrt restoring files from the trash. Other transfer_nodes will be called with target_parent_file.\n *\/\n\n \/* take a reference on the thumbnail cache *\/\n application = thunar_application_get ();\n thumbnail_cache = thunar_application_get_thumbnail_cache (application);\n g_object_unref (application);\n\n for (; err == NULL && node != NULL; node = node->next)\n {\n \/* guess the target file for this node (unless already provided) *\/\n if (G_LIKELY (target_file == NULL))\n {\n base_name = g_file_get_basename (node->source_file);\n target_file = g_file_get_child (target_parent_file, base_name);\n g_free (base_name);\n }\n else\n target_file = g_object_ref (target_file);\n\n \/* query file info *\/\n info = g_file_query_info (node->source_file,\n G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,\n G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,\n exo_job_get_cancellable (EXO_JOB (job)),\n &err);\n\n \/* abort on error or cancellation *\/\n if (info == NULL)\n {\n g_object_unref (target_file);\n break;\n }\n\n \/* update progress information *\/\n exo_job_info_message (EXO_JOB (job), g_file_info_get_display_name (info));\n\nretry_copy:\n \/* copy the item specified by this node (not recursively) *\/\n real_target_file = thunar_transfer_job_copy_file (job, node->source_file, \n target_file, &err);\n if (G_LIKELY (real_target_file != NULL))\n {\n \/* node->source_file == real_target_file means to skip the file *\/\n if (G_LIKELY (node->source_file != real_target_file))\n {\n \/* notify the thumbnail cache of the copy operation *\/\n thunar_thumbnail_cache_copy_file (thumbnail_cache, \n node->source_file, \n real_target_file);\n\n \/* check if we have children to copy *\/\n if (node->children != NULL)\n {\n \/* copy all children of this node *\/\n thunar_transfer_job_copy_node (job, node->children, NULL, real_target_file, NULL, &err);\n\n \/* free resources allocted for the children *\/\n thunar_transfer_node_free (node->children);\n node->children = NULL;\n }\n\n \/* check if the child copy failed *\/\n if (G_UNLIKELY (err != NULL))\n {\n \/* outa here, freeing the target paths *\/\n g_object_unref (real_target_file);\n g_object_unref (target_file);\n break;\n }\n\n \/* add the real target file to the return list *\/\n if (G_LIKELY (target_file_list_return != NULL))\n {\n *target_file_list_return = \n thunar_g_file_list_prepend (*target_file_list_return, \n real_target_file);\n }\n\nretry_remove:\n \/* try to remove the source directory if we are on copy+remove fallback for move *\/\n if (job->type == THUNAR_TRANSFER_JOB_MOVE)\n {\n if (g_file_delete (node->source_file, \n exo_job_get_cancellable (EXO_JOB (job)), \n &err))\n {\n \/* notify the thumbnail cache of the delete operation *\/\n thunar_thumbnail_cache_delete_file (thumbnail_cache, \n node->source_file);\n }\n else\n {\n \/* ask the user to retry *\/\n response = thunar_job_ask_skip (THUNAR_JOB (job), \"%s\", \n err->message);\n\n \/* reset the error *\/\n g_clear_error (&err);\n\n \/* check whether to retry *\/\n if (G_UNLIKELY (response == THUNAR_JOB_RESPONSE_RETRY))\n goto retry_remove;\n }\n }\n }\n\n g_object_unref (real_target_file);\n }\n else if (err != NULL)\n { \n \/* we can only skip if there is space left on the device *\/\n if (err->domain != G_IO_ERROR || err->code != G_IO_ERROR_NO_SPACE) \n {\n \/* ask the user to skip this node and all subnodes *\/\n response = thunar_job_ask_skip (THUNAR_JOB (job), \"%s\", err->message);\n\n \/* reset the error *\/\n g_clear_error (&err);\n\n \/* check whether to retry *\/\n if (G_UNLIKELY (response == THUNAR_JOB_RESPONSE_RETRY))\n goto retry_copy;\n }\n }\n\n \/* release the guessed target file *\/\n g_object_unref (target_file);\n target_file = NULL;\n\n \/* release file info *\/\n g_object_unref (info);\n }\n\n \/* release the thumbnail cache *\/\n g_object_unref (thumbnail_cache);\n\n \/* propagate error if we failed or the job was cancelled *\/\n if (G_UNLIKELY (err != NULL))\n g_propagate_error (error, err);\n}","target":1,"code_token_length":1297,"total_token_length":1533,"max_tokens_setting":2048} +{"idx":156728,"func":"void CLASS parse_minolta (int base)\n{\n int save, tag, len, offset, high=0, wide=0, i, c;\n short sorder=order;\n\n fseek (ifp, base, SEEK_SET);\n if (fgetc(ifp) || fgetc(ifp)-'M' || fgetc(ifp)-'R') return;\n order = fgetc(ifp) * 0x101;\n offset = base + get4() + 8;\n while ((save=ftell(ifp)) < offset) {\n for (tag=i=0; i < 4; i++)\n tag = tag << 8 | fgetc(ifp);\n len = get4();\n switch (tag) {\n case 0x505244:\t\t\t\t\/* PRD *\/\n\tfseek (ifp, 8, SEEK_CUR);\n\thigh = get2();\n\twide = get2();\n\tbreak;\n#ifdef LIBRAW_LIBRARY_BUILD\n case 0x524946:\t\t\t\t\/* RIF *\/\n if (!strncasecmp(model,\"DSLR-A100\", 9))\n {\n fseek(ifp, 8, SEEK_CUR);\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Cloudy][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Cloudy][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_W][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_W][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Flash][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Flash][2] = get2();\n get4();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_D][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_D][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_N][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_N][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_WW][0] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_WW][2] = get2();\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Flash][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Flash][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Cloudy][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Cloudy][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_D][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_D][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_N][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_N][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_W][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_W][3] =\n imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_WW][1] = imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_WW][3] = 0x100;\n }\n\tbreak;\n#endif\n case 0x574247:\t\t\t\t\/* WBG *\/\n\tget4();\n\ti = strcmp(model,\"DiMAGE A200\") ? 0:3;\n\tFORC4 cam_mul[c ^ (c >> 1) ^ i] = get2();\n\tbreak;\n case 0x545457:\t\t\t\t\/* TTW *\/\n\tparse_tiff (ftell(ifp));\n\tdata_offset = offset;\n }\n fseek (ifp, save+len+8, SEEK_SET);\n }\n raw_height = high;\n raw_width = wide;\n order = sorder;\n}","target":0,"code_token_length":1186,"total_token_length":1422,"max_tokens_setting":2048} +{"idx":60453,"func":"void CL_Connect_f( void ) {\n\tchar *server;\n\tconst char\t*serverString;\n\tint argc = Cmd_Argc();\n\tnetadrtype_t family = NA_UNSPEC;\n\n\tif ( argc != 2 && argc != 3 ) {\n\t\tCom_Printf( \"usage: connect [-4|-6] server\\n\");\n\t\treturn;\n\t}\n\n\tif(argc == 2)\n\t\tserver = Cmd_Argv(1);\n\telse\n\t{\n\t\tif(!strcmp(Cmd_Argv(1), \"-4\"))\n\t\t\tfamily = NA_IP;\n\t\telse if(!strcmp(Cmd_Argv(1), \"-6\"))\n\t\t\tfamily = NA_IP6;\n\t\telse\n\t\t\tCom_Printf( \"warning: only -4 or -6 as address type understood.\\n\");\n\t\t\n\t\tserver = Cmd_Argv(2);\n\t}\n\n\t\/\/ save arguments for reconnect\n\tQ_strncpyz( cl_reconnectArgs, Cmd_Args(), sizeof( cl_reconnectArgs ) );\n\n\tCvar_Set(\"ui_singlePlayerActive\", \"0\");\n\n\tS_StopAllSounds(); \/\/ NERVE - SMF\n\n\t\/\/ starting to load a map so we get out of full screen ui mode\n\tCvar_Set( \"r_uiFullScreen\", \"0\" );\n\n\t\/\/ fire a message off to the motd server\n\tCL_RequestMotd();\n\n\t\/\/ clear any previous \"server full\" type messages\n\tclc.serverMessage[0] = 0;\n\n\tif ( com_sv_running->integer && !strcmp( server, \"localhost\" ) ) {\n\t\t\/\/ if running a local server, kill it\n\t\tSV_Shutdown( \"Server quit\" );\n\t}\n\n\t\/\/ make sure a local server is killed\n\tCvar_Set( \"sv_killserver\", \"1\" );\n\tSV_Frame( 0 );\n\n\tnoGameRestart = qtrue;\n\tCL_Disconnect( qtrue );\n\tCon_Close();\n\n\tQ_strncpyz( clc.servername, server, sizeof(clc.servername) );\n\n\tif (!NET_StringToAdr(clc.servername, &clc.serverAddress, family) ) {\n\t\tCom_Printf( \"Bad server address\\n\" );\n\t\tclc.state = CA_DISCONNECTED;\n\t\treturn;\n\t}\n\tif ( clc.serverAddress.port == 0 ) {\n\t\tclc.serverAddress.port = BigShort( PORT_SERVER );\n\t}\n\n\tserverString = NET_AdrToStringwPort(clc.serverAddress);\n\n\tCom_Printf( \"%s resolved to %s\\n\", clc.servername, serverString);\n\n\tif( cl_guidServerUniq->integer )\n\t\tCL_UpdateGUID( serverString, strlen( serverString ) );\n\telse\n\t\tCL_UpdateGUID( NULL, 0 );\n\n\t\/\/ if we aren't playing on a lan, we need to authenticate\n\t\/\/ with the cd key\n\tif(NET_IsLocalAddress(clc.serverAddress))\n\t\tclc.state = CA_CHALLENGING;\n\telse\n\t{\n\t\tclc.state = CA_CONNECTING;\n\t\t\n\t\t\/\/ Set a client challenge number that ideally is mirrored back by the server.\n\t\tclc.challenge = ((rand() << 16) ^ rand()) ^ Com_Milliseconds();\n\t}\n\n\t\/\/ show_bug.cgi?id=507\n\t\/\/ prepare to catch a connection process that would turn bad\n\tCvar_Set( \"com_errorDiagnoseIP\", NET_AdrToString( clc.serverAddress ) );\n\t\/\/ ATVI Wolfenstein Misc #439\n\t\/\/ we need to setup a correct default for this, otherwise the first val we set might reappear\n\tCvar_Set( \"com_errorMessage\", \"\" );\n\n\tKey_SetCatcher( 0 );\n\tclc.connectTime = -99999;\t\/\/ CL_CheckForResend() will fire immediately\n\tclc.connectPacketCount = 0;\n\n\t\/\/ server connection string\n\tCvar_Set( \"cl_currentServerAddress\", server );\n\n\t\/\/ NERVE - SMF - reset some cvars\n\tCvar_Set( \"mp_playerType\", \"0\" );\n\tCvar_Set( \"mp_currentPlayerType\", \"0\" );\n\tCvar_Set( \"mp_weapon\", \"0\" );\n\tCvar_Set( \"mp_team\", \"0\" );\n\tCvar_Set( \"mp_currentTeam\", \"0\" );\n\n\tCvar_Set( \"ui_limboOptions\", \"0\" );\n\tCvar_Set( \"ui_limboPrevOptions\", \"0\" );\n\tCvar_Set( \"ui_limboObjective\", \"0\" );\n\t\/\/ -NERVE - SMF\n\n}","target":0,"code_token_length":934,"total_token_length":1170,"max_tokens_setting":2048} +{"idx":52182,"func":"static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, void __user *user_arg)\n{\n\tstruct hid_device *hid = hiddev->hid;\n\tstruct hiddev_report_info rinfo;\n\tstruct hiddev_usage_ref_multi *uref_multi = NULL;\n\tstruct hiddev_usage_ref *uref;\n\tstruct hid_report *report;\n\tstruct hid_field *field;\n\tint i;\n\n\turef_multi = kmalloc(sizeof(struct hiddev_usage_ref_multi), GFP_KERNEL);\n\tif (!uref_multi)\n\t\treturn -ENOMEM;\n\turef = &uref_multi->uref;\n\tif (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) {\n\t\tif (copy_from_user(uref_multi, user_arg,\n\t\t\t\t sizeof(*uref_multi)))\n\t\t\tgoto fault;\n\t} else {\n\t\tif (copy_from_user(uref, user_arg, sizeof(*uref)))\n\t\t\tgoto fault;\n\t}\n\n\tswitch (cmd) {\n\tcase HIDIOCGUCODE:\n\t\trinfo.report_type = uref->report_type;\n\t\trinfo.report_id = uref->report_id;\n\t\tif ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)\n\t\t\tgoto inval;\n\n\t\tif (uref->field_index >= report->maxfield)\n\t\t\tgoto inval;\n\n\t\tfield = report->field[uref->field_index];\n\t\tif (uref->usage_index >= field->maxusage)\n\t\t\tgoto inval;\n\n\t\turef->usage_code = field->usage[uref->usage_index].hid;\n\n\t\tif (copy_to_user(user_arg, uref, sizeof(*uref)))\n\t\t\tgoto fault;\n\n\t\tgoto goodreturn;\n\n\tdefault:\n\t\tif (cmd != HIDIOCGUSAGE &&\n\t\t cmd != HIDIOCGUSAGES &&\n\t\t uref->report_type == HID_REPORT_TYPE_INPUT)\n\t\t\tgoto inval;\n\n\t\tif (uref->report_id == HID_REPORT_ID_UNKNOWN) {\n\t\t\tfield = hiddev_lookup_usage(hid, uref);\n\t\t\tif (field == NULL)\n\t\t\t\tgoto inval;\n\t\t} else {\n\t\t\trinfo.report_type = uref->report_type;\n\t\t\trinfo.report_id = uref->report_id;\n\t\t\tif ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)\n\t\t\t\tgoto inval;\n\n\t\t\tif (uref->field_index >= report->maxfield)\n\t\t\t\tgoto inval;\n\n\t\t\tfield = report->field[uref->field_index];\n\n\t\t\tif (cmd == HIDIOCGCOLLECTIONINDEX) {\n\t\t\t\tif (uref->usage_index >= field->maxusage)\n\t\t\t\t\tgoto inval;\n\t\t\t} else if (uref->usage_index >= field->report_count)\n\t\t\t\tgoto inval;\n\t\t}\n\n\t\tif ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&\n\t\t (uref_multi->num_values > HID_MAX_MULTI_USAGES ||\n\t\t uref->usage_index + uref_multi->num_values > field->report_count))\n\t\t\tgoto inval;\n\n\t\tswitch (cmd) {\n\t\tcase HIDIOCGUSAGE:\n\t\t\turef->value = field->value[uref->usage_index];\n\t\t\tif (copy_to_user(user_arg, uref, sizeof(*uref)))\n\t\t\t\tgoto fault;\n\t\t\tgoto goodreturn;\n\n\t\tcase HIDIOCSUSAGE:\n\t\t\tfield->value[uref->usage_index] = uref->value;\n\t\t\tgoto goodreturn;\n\n\t\tcase HIDIOCGCOLLECTIONINDEX:\n\t\t\ti = field->usage[uref->usage_index].collection_index;\n\t\t\tkfree(uref_multi);\n\t\t\treturn i;\n\t\tcase HIDIOCGUSAGES:\n\t\t\tfor (i = 0; i < uref_multi->num_values; i++)\n\t\t\t\turef_multi->values[i] =\n\t\t\t\t field->value[uref->usage_index + i];\n\t\t\tif (copy_to_user(user_arg, uref_multi,\n\t\t\t\t\t sizeof(*uref_multi)))\n\t\t\t\tgoto fault;\n\t\t\tgoto goodreturn;\n\t\tcase HIDIOCSUSAGES:\n\t\t\tfor (i = 0; i < uref_multi->num_values; i++)\n\t\t\t\tfield->value[uref->usage_index + i] =\n\t\t\t\t uref_multi->values[i];\n\t\t\tgoto goodreturn;\n\t\t}\n\ngoodreturn:\n\t\tkfree(uref_multi);\n\t\treturn 0;\nfault:\n\t\tkfree(uref_multi);\n\t\treturn -EFAULT;\ninval:\n\t\tkfree(uref_multi);\n\t\treturn -EINVAL;\n\t}\n}","target":0,"code_token_length":926,"total_token_length":1162,"max_tokens_setting":2048} +{"idx":37454,"func":"writeCustomTiffTags(TIFF *tif,\n NUMA *natags,\n SARRAY *savals,\n SARRAY *satypes,\n NUMA *nasizes)\n{\nchar *sval, *type;\nl_int32 i, n, ns, size, tagval, val;\nl_float64 dval;\nl_uint32 uval, uval2;\n\n PROCNAME(\"writeCustomTiffTags\");\n\n if (!tif)\n return ERROR_INT(\"tif stream not defined\", procName, 1);\n if (!natags && !savals && !satypes)\n return 0;\n if (!natags || !savals || !satypes)\n return ERROR_INT(\"not all arrays defined\", procName, 1);\n n = numaGetCount(natags);\n if ((sarrayGetCount(savals) != n) || (sarrayGetCount(satypes) != n))\n return ERROR_INT(\"not all sa the same size\", procName, 1);\n\n \/* The sized arrays (4 args to TIFFSetField) are written first *\/\n if (nasizes) {\n ns = numaGetCount(nasizes);\n if (ns > n)\n return ERROR_INT(\"too many 4-arg tag calls\", procName, 1);\n for (i = 0; i < ns; i++) {\n numaGetIValue(natags, i, &tagval);\n sval = sarrayGetString(savals, i, L_NOCOPY);\n type = sarrayGetString(satypes, i, L_NOCOPY);\n numaGetIValue(nasizes, i, &size);\n if (strcmp(type, \"char*\") && strcmp(type, \"l_uint8*\"))\n L_WARNING(\"array type not char* or l_uint8*; ignore\\n\",\n procName);\n TIFFSetField(tif, tagval, size, sval);\n }\n } else {\n ns = 0;\n }\n\n \/* The typical tags (3 args to TIFFSetField) are now written *\/\n for (i = ns; i < n; i++) {\n numaGetIValue(natags, i, &tagval);\n sval = sarrayGetString(savals, i, L_NOCOPY);\n type = sarrayGetString(satypes, i, L_NOCOPY);\n if (!strcmp(type, \"char*\") || !strcmp(type, \"const char*\")) {\n TIFFSetField(tif, tagval, sval);\n } else if (!strcmp(type, \"l_uint16\")) {\n if (sscanf(sval, \"%u\", &uval) == 1) {\n TIFFSetField(tif, tagval, (l_uint16)uval);\n } else {\n lept_stderr(\"val %s not of type %s\\n\", sval, type);\n return ERROR_INT(\"custom tag(s) not written\", procName, 1);\n }\n } else if (!strcmp(type, \"l_uint32\")) {\n if (sscanf(sval, \"%u\", &uval) == 1) {\n TIFFSetField(tif, tagval, uval);\n } else {\n lept_stderr(\"val %s not of type %s\\n\", sval, type);\n return ERROR_INT(\"custom tag(s) not written\", procName, 1);\n }\n } else if (!strcmp(type, \"l_int32\")) {\n if (sscanf(sval, \"%d\", &val) == 1) {\n TIFFSetField(tif, tagval, val);\n } else {\n lept_stderr(\"val %s not of type %s\\n\", sval, type);\n return ERROR_INT(\"custom tag(s) not written\", procName, 1);\n }\n } else if (!strcmp(type, \"l_float64\")) {\n if (sscanf(sval, \"%lf\", &dval) == 1) {\n TIFFSetField(tif, tagval, dval);\n } else {\n lept_stderr(\"val %s not of type %s\\n\", sval, type);\n return ERROR_INT(\"custom tag(s) not written\", procName, 1);\n }\n } else if (!strcmp(type, \"l_uint16-l_uint16\")) {\n if (sscanf(sval, \"%u-%u\", &uval, &uval2) == 2) {\n TIFFSetField(tif, tagval, (l_uint16)uval, (l_uint16)uval2);\n } else {\n lept_stderr(\"val %s not of type %s\\n\", sval, type);\n return ERROR_INT(\"custom tag(s) not written\", procName, 1);\n }\n } else {\n lept_stderr(\"unknown type %s\\n\",type);\n return ERROR_INT(\"unknown type; tag(s) not written\", procName, 1);\n }\n }\n return 0;\n}","target":0,"code_token_length":1081,"total_token_length":1317,"max_tokens_setting":2048} +{"idx":495074,"func":"piv_cache_internal_data(sc_card_t *card, int enumtag)\n{\n\tpiv_private_data_t * priv = PIV_DATA(card);\n\tconst u8* tag;\n\tconst u8* body;\n\tsize_t taglen;\n\tsize_t bodylen;\n\tint compressed = 0;\n\n\t\/* if already cached *\/\n\tif (priv->obj_cache[enumtag].internal_obj_data && priv->obj_cache[enumtag].internal_obj_len) {\n\t\tsc_log(card->ctx,\n\t\t \"#%d found internal %p:%\"SC_FORMAT_LEN_SIZE_T\"u\",\n\t\t enumtag,\n\t\t priv->obj_cache[enumtag].internal_obj_data,\n\t\t priv->obj_cache[enumtag].internal_obj_len);\n\t\tLOG_FUNC_RETURN(card->ctx, SC_SUCCESS);\n\t}\n\n\tbody = sc_asn1_find_tag(card->ctx,\n\t\t\tpriv->obj_cache[enumtag].obj_data,\n\t\t\tpriv->obj_cache[enumtag].obj_len,\n\t\t\t0x53, &bodylen);\n\n\tif (body == NULL || priv->obj_cache[enumtag].obj_data[0] != 0x53)\n\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);\n\n\t\/* get the certificate out *\/\n\t if (piv_objects[enumtag].flags & PIV_OBJECT_TYPE_CERT) {\n\n\t\ttag = sc_asn1_find_tag(card->ctx, body, bodylen, 0x71, &taglen);\n\t\t\/* 800-72-1 not clear if this is 80 or 01 Sent comment to NIST for 800-72-2 *\/\n\t\t\/* 800-73-3 says it is 01, keep dual test so old cards still work *\/\n\t\tif (tag && taglen > 0 && (((*tag) & 0x80) || ((*tag) & 0x01)))\n\t\t\tcompressed = 1;\n\n\t\ttag = sc_asn1_find_tag(card->ctx, body, bodylen, 0x70, &taglen);\n\t\tif (tag == NULL)\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);\n\n\t\tif (taglen == 0)\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);\n\n\t\tif(compressed) {\n#ifdef ENABLE_ZLIB\n\t\t\tsize_t len;\n\t\t\tu8* newBuf = NULL;\n\n\t\t\tif(SC_SUCCESS != sc_decompress_alloc(&newBuf, &len, tag, taglen, COMPRESSION_AUTO))\n\t\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);\n\n\t\t\tpriv->obj_cache[enumtag].internal_obj_data = newBuf;\n\t\t\tpriv->obj_cache[enumtag].internal_obj_len = len;\n#else\n\t\t\tsc_log(card->ctx, \"PIV compression not supported, no zlib\");\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);\n#endif\n\t\t}\n\t\telse {\n\t\t\tif (!(priv->obj_cache[enumtag].internal_obj_data = malloc(taglen)))\n\t\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);\n\n\t\t\tmemcpy(priv->obj_cache[enumtag].internal_obj_data, tag, taglen);\n\t\t\tpriv->obj_cache[enumtag].internal_obj_len = taglen;\n\t\t}\n\n\t\/* convert pub key to internal *\/\n\/* TODO: -DEE need to fix ... would only be used if we cache the pub key, but we don't today *\/\n\t}\n\telse if (piv_objects[enumtag].flags & PIV_OBJECT_TYPE_PUBKEY) {\n\t\ttag = sc_asn1_find_tag(card->ctx, body, bodylen, *body, &taglen);\n\t\tif (tag == NULL)\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);\n\n\t\tif (taglen == 0)\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);\n\n\t\tif (!(priv->obj_cache[enumtag].internal_obj_data = malloc(taglen)))\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);\n\n\t\tmemcpy(priv->obj_cache[enumtag].internal_obj_data, tag, taglen);\n\t\tpriv->obj_cache[enumtag].internal_obj_len = taglen;\n\t}\n\telse {\n\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);\n\t}\n\n\tsc_log(card->ctx, \"added #%d internal %p:%\"SC_FORMAT_LEN_SIZE_T\"u\",\n\t enumtag,\n\t priv->obj_cache[enumtag].internal_obj_data,\n\t priv->obj_cache[enumtag].internal_obj_len);\n\n\tLOG_FUNC_RETURN(card->ctx, SC_SUCCESS);\n}","target":0,"code_token_length":963,"total_token_length":1199,"max_tokens_setting":2048} +{"idx":152290,"func":"static int uas_use_uas_driver(struct usb_interface *intf,\n\t\t\t const struct usb_device_id *id,\n\t\t\t unsigned long *flags_ret)\n{\n\tstruct usb_host_endpoint *eps[4] = { };\n\tstruct usb_device *udev = interface_to_usbdev(intf);\n\tstruct usb_hcd *hcd = bus_to_hcd(udev->bus);\n\tunsigned long flags = id->driver_info;\n\tstruct usb_host_interface *alt;\n\tint r;\n\n\talt = uas_find_uas_alt_setting(intf);\n\tif (!alt)\n\t\treturn 0;\n\n\tr = uas_find_endpoints(alt, eps);\n\tif (r < 0)\n\t\treturn 0;\n\n\t\/*\n\t * ASMedia has a number of usb3 to sata bridge chips, at the time of\n\t * this writing the following versions exist:\n\t * ASM1051 - no uas support version\n\t * ASM1051 - with broken (*) uas support\n\t * ASM1053 - with working uas support, but problems with large xfers\n\t * ASM1153 - with working uas support\n\t *\n\t * Devices with these chips re-use a number of device-ids over the\n\t * entire line, so the device-id is useless to determine if we're\n\t * dealing with an ASM1051 (which we want to avoid).\n\t *\n\t * The ASM1153 can be identified by config.MaxPower == 0,\n\t * where as the ASM105x models have config.MaxPower == 36.\n\t *\n\t * Differentiating between the ASM1053 and ASM1051 is trickier, when\n\t * connected over USB-3 we can look at the number of streams supported,\n\t * ASM1051 supports 32 streams, where as early ASM1053 versions support\n\t * 16 streams, newer ASM1053-s also support 32 streams, but have a\n\t * different prod-id.\n\t *\n\t * (*) ASM1051 chips do work with UAS with some disks (with the\n\t * US_FL_NO_REPORT_OPCODES quirk), but are broken with other disks\n\t *\/\n\tif (le16_to_cpu(udev->descriptor.idVendor) == 0x174c &&\n\t\t\t(le16_to_cpu(udev->descriptor.idProduct) == 0x5106 ||\n\t\t\t le16_to_cpu(udev->descriptor.idProduct) == 0x55aa)) {\n\t\tif (udev->actconfig->desc.bMaxPower == 0) {\n\t\t\t\/* ASM1153, do nothing *\/\n\t\t} else if (udev->speed < USB_SPEED_SUPER) {\n\t\t\t\/* No streams info, assume ASM1051 *\/\n\t\t\tflags |= US_FL_IGNORE_UAS;\n\t\t} else if (usb_ss_max_streams(&eps[1]->ss_ep_comp) == 32) {\n\t\t\t\/* Possibly an ASM1051, disable uas *\/\n\t\t\tflags |= US_FL_IGNORE_UAS;\n\t\t} else {\n\t\t\t\/* ASM1053, these have issues with large transfers *\/\n\t\t\tflags |= US_FL_MAX_SECTORS_240;\n\t\t}\n\t}\n\n\tusb_stor_adjust_quirks(udev, &flags);\n\n\tif (flags & US_FL_IGNORE_UAS) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"UAS is blacklisted for this device, using usb-storage instead\\n\");\n\t\treturn 0;\n\t}\n\n\tif (udev->bus->sg_tablesize == 0) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"The driver for the USB controller %s does not support scatter-gather which is\\n\",\n\t\t\thcd->driver->description);\n\t\tdev_warn(&udev->dev,\n\t\t\t\"required by the UAS driver. Please try an other USB controller if you wish to use UAS.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (udev->speed >= USB_SPEED_SUPER && !hcd->can_do_streams) {\n\t\tdev_warn(&udev->dev,\n\t\t\t\"USB controller %s does not support streams, which are required by the UAS driver.\\n\",\n\t\t\thcd_to_bus(hcd)->bus_name);\n\t\tdev_warn(&udev->dev,\n\t\t\t\"Please try an other USB controller if you wish to use UAS.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (flags_ret)\n\t\t*flags_ret = flags;\n\n\treturn 1;\n}","target":0,"code_token_length":956,"total_token_length":1192,"max_tokens_setting":2048} +{"idx":223759,"func":"static int lua_websocket_read(lua_State *L) \n {\n apr_socket_t *sock;\n apr_status_t rv;\n int do_read = 1;\n int n = 0;\n apr_size_t len = 1;\n apr_size_t plen = 0;\n unsigned short payload_short = 0;\n apr_uint64_t payload_long = 0;\n unsigned char *mask_bytes;\n char byte;\n int plaintext;\n \n \n request_rec *r = ap_lua_check_request_rec(L, 1);\n plaintext = ap_lua_ssl_is_https(r->connection) ? 0 : 1;\n\n \n mask_bytes = apr_pcalloc(r->pool, 4);\n sock = ap_get_conn_socket(r->connection);\n \n while (do_read) { \n do_read = 0;\n \/* Get opcode and FIN bit *\/\n if (plaintext) {\n rv = apr_socket_recv(sock, &byte, &len);\n }\n else {\n rv = lua_websocket_readbytes(r->connection, &byte, 1);\n }\n if (rv == APR_SUCCESS) {\n unsigned char ubyte, fin, opcode, mask, payload;\n ubyte = (unsigned char)byte;\n \/* fin bit is the first bit *\/\n fin = ubyte >> (CHAR_BIT - 1);\n \/* opcode is the last four bits (there's 3 reserved bits we don't care about) *\/\n opcode = ubyte & 0xf;\n \n \/* Get the payload length and mask bit *\/\n if (plaintext) {\n rv = apr_socket_recv(sock, &byte, &len);\n }\n else {\n rv = lua_websocket_readbytes(r->connection, &byte, 1);\n }\n if (rv == APR_SUCCESS) {\n ubyte = (unsigned char)byte;\n \/* Mask is the first bit *\/\n mask = ubyte >> (CHAR_BIT - 1);\n \/* Payload is the last 7 bits *\/\n payload = ubyte & 0x7f;\n plen = payload;\n \n \/* Extended payload? *\/\n if (payload == 126) {\n len = 2;\n if (plaintext) {\n \/* XXX: apr_socket_recv does not receive len bits, only up to len bits! *\/\n rv = apr_socket_recv(sock, (char*) &payload_short, &len);\n }\n else {\n rv = lua_websocket_readbytes(r->connection, \n (char*) &payload_short, 2);\n }\n payload_short = ntohs(payload_short);\n \n if (rv == APR_SUCCESS) {\n plen = payload_short;\n }\n else {\n return 0;\n }\n }\n \/* Super duper extended payload? *\/\n if (payload == 127) {\n len = 8;\n if (plaintext) {\n rv = apr_socket_recv(sock, (char*) &payload_long, &len);\n }\n else {\n rv = lua_websocket_readbytes(r->connection, \n (char*) &payload_long, 8);\n }\n if (rv == APR_SUCCESS) {\n plen = ap_ntoh64(&payload_long);\n }\n else {\n return 0;\n }\n }\n ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, \n \"Websocket: Reading %\" APR_SIZE_T_FMT \" (%s) bytes, masking is %s. %s\", \n plen,\n (payload >= 126) ? \"extra payload\" : \"no extra payload\", \n mask ? \"on\" : \"off\", \n fin ? \"This is a final frame\" : \"more to follow\");\n if (mask) {\n len = 4;\n if (plaintext) {\n rv = apr_socket_recv(sock, (char*) mask_bytes, &len);\n }\n else {\n rv = lua_websocket_readbytes(r->connection, \n (char*) mask_bytes, 4);\n }\n if (rv != APR_SUCCESS) {\n return 0;\n }\n }\n if (plen < (HUGE_STRING_LEN*1024) && plen > 0) {\n apr_size_t remaining = plen;\n apr_size_t received;\n apr_off_t at = 0;\n char *buffer = apr_palloc(r->pool, plen+1);\n buffer[plen] = 0;\n \n if (plaintext) {\n while (remaining > 0) {\n received = remaining;\n rv = apr_socket_recv(sock, buffer+at, &received);\n if (received > 0 ) {\n remaining -= received;\n at += received;\n }\n }\n ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, \n \"Websocket: Frame contained %\" APR_OFF_T_FMT \" bytes, pushed to Lua stack\", \n at);\n }\n else {\n rv = lua_websocket_readbytes(r->connection, buffer, \n remaining);\n ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, \n \"Websocket: SSL Frame contained %\" APR_SIZE_T_FMT \" bytes, \"\\\n \"pushed to Lua stack\", \n remaining);\n }\n if (mask) {\n for (n = 0; n < plen; n++) {\n buffer[n] ^= mask_bytes[n%4];\n }\n }\n \n lua_pushlstring(L, buffer, (size_t) plen); \/* push to stack *\/\n lua_pushboolean(L, fin); \/* push FIN bit to stack as boolean *\/\n return 2;\n }\n \n \n \/* Decide if we need to react to the opcode or not *\/\n if (opcode == 0x09) { \/* ping *\/\n char frame[2];\n plen = 2;\n frame[0] = 0x8A;\n frame[1] = 0;\n apr_socket_send(sock, frame, &plen); \/* Pong! *\/\n do_read = 1;\n }\n }\n }\n }\n return 0;\n }\n","target":0,"code_token_length":1308,"total_token_length":1544,"max_tokens_setting":2048} +{"idx":119136,"func":"dbd_st_FETCH_internal(\n SV *sth,\n int what,\n MYSQL_RES *res,\n int cacheit\n)\n{\n dTHX;\n D_imp_sth(sth);\n AV *av= Nullav;\n MYSQL_FIELD *curField;\n\n \/* Are we asking for a legal value? *\/\n if (what < 0 || what >= AV_ATTRIB_LAST)\n do_error(sth, JW_ERR_NOT_IMPLEMENTED, \"Not implemented\", NULL);\n\n \/* Return cached value, if possible *\/\n else if (cacheit && imp_sth->av_attr[what])\n av= imp_sth->av_attr[what];\n\n \/* Does this sth really have a result? *\/\n else if (!res)\n do_error(sth, JW_ERR_NOT_ACTIVE,\n\t \"statement contains no result\" ,NULL);\n \/* Do the real work. *\/\n else\n {\n av= newAV();\n mysql_field_seek(res, 0);\n while ((curField= mysql_fetch_field(res)))\n {\n SV *sv;\n\n switch(what) {\n case AV_ATTRIB_NAME:\n sv= newSVpv(curField->name, strlen(curField->name));\n break;\n\n case AV_ATTRIB_TABLE:\n sv= newSVpv(curField->table, strlen(curField->table));\n break;\n\n case AV_ATTRIB_TYPE:\n sv= newSViv((int) curField->type);\n break;\n\n case AV_ATTRIB_SQL_TYPE:\n sv= newSViv((int) native2sql(curField->type)->data_type);\n break;\n case AV_ATTRIB_IS_PRI_KEY:\n sv= boolSV(IS_PRI_KEY(curField->flags));\n break;\n\n case AV_ATTRIB_IS_NOT_NULL:\n sv= boolSV(IS_NOT_NULL(curField->flags));\n break;\n\n case AV_ATTRIB_NULLABLE:\n sv= boolSV(!IS_NOT_NULL(curField->flags));\n break;\n\n case AV_ATTRIB_LENGTH:\n sv= newSViv((int) curField->length);\n break;\n\n case AV_ATTRIB_IS_NUM:\n sv= newSViv((int) native2sql(curField->type)->is_num);\n break;\n\n case AV_ATTRIB_TYPE_NAME:\n sv= newSVpv((char*) native2sql(curField->type)->type_name, 0);\n break;\n\n case AV_ATTRIB_MAX_LENGTH:\n sv= newSViv((int) curField->max_length);\n break;\n\n case AV_ATTRIB_IS_AUTO_INCREMENT:\n#if defined(AUTO_INCREMENT_FLAG)\n sv= boolSV(IS_AUTO_INCREMENT(curField->flags));\n break;\n#else\n croak(\"AUTO_INCREMENT_FLAG is not supported on this machine\");\n#endif\n\n case AV_ATTRIB_IS_KEY:\n sv= boolSV(IS_KEY(curField->flags));\n break;\n\n case AV_ATTRIB_IS_BLOB:\n sv= boolSV(IS_BLOB(curField->flags));\n break;\n\n case AV_ATTRIB_SCALE:\n sv= newSViv((int) curField->decimals);\n break;\n\n case AV_ATTRIB_PRECISION:\n sv= newSViv((int) (curField->length > curField->max_length) ?\n curField->length : curField->max_length);\n break;\n\n default:\n sv= &PL_sv_undef;\n break;\n }\n av_push(av, sv);\n }\n\n \/* Ensure that this value is kept, decremented in\n * dbd_st_destroy and dbd_st_execute. *\/\n if (!cacheit)\n return sv_2mortal(newRV_noinc((SV*)av));\n imp_sth->av_attr[what]= av;\n }\n\n if (av == Nullav)\n return &PL_sv_undef;\n\n return sv_2mortal(newRV_inc((SV*)av));\n}","target":0,"code_token_length":804,"total_token_length":1040,"max_tokens_setting":2048} +{"idx":91518,"func":"void SetOpAttrListDefault(\n TFE_Context* ctx, TFE_Op* op, const tensorflow::OpDef::AttrDef& attr,\n const char* key, TF_AttrType type,\n tensorflow::gtl::FlatMap* attr_list_sizes,\n TF_Status* status) {\n if (type == TF_ATTR_STRING) {\n int num_values = attr.default_value().list().s_size();\n std::unique_ptr values(new const void*[num_values]);\n std::unique_ptr lengths(new size_t[num_values]);\n (*attr_list_sizes)[key] = num_values;\n for (int i = 0; i < num_values; i++) {\n const string& v = attr.default_value().list().s(i);\n values[i] = v.data();\n lengths[i] = v.size();\n }\n TFE_OpSetAttrStringList(op, key, values.get(), lengths.get(), num_values);\n } else if (type == TF_ATTR_INT) {\n int num_values = attr.default_value().list().i_size();\n std::unique_ptr values(new int64_t[num_values]);\n (*attr_list_sizes)[key] = num_values;\n for (int i = 0; i < num_values; i++) {\n values[i] = attr.default_value().list().i(i);\n }\n TFE_OpSetAttrIntList(op, key, values.get(), num_values);\n } else if (type == TF_ATTR_FLOAT) {\n int num_values = attr.default_value().list().f_size();\n std::unique_ptr values(new float[num_values]);\n (*attr_list_sizes)[key] = num_values;\n for (int i = 0; i < num_values; i++) {\n values[i] = attr.default_value().list().f(i);\n }\n TFE_OpSetAttrFloatList(op, key, values.get(), num_values);\n } else if (type == TF_ATTR_BOOL) {\n int num_values = attr.default_value().list().b_size();\n std::unique_ptr values(new unsigned char[num_values]);\n (*attr_list_sizes)[key] = num_values;\n for (int i = 0; i < num_values; i++) {\n values[i] = attr.default_value().list().b(i);\n }\n TFE_OpSetAttrBoolList(op, key, values.get(), num_values);\n } else if (type == TF_ATTR_TYPE) {\n int num_values = attr.default_value().list().type_size();\n std::unique_ptr values(new int[num_values]);\n (*attr_list_sizes)[key] = num_values;\n for (int i = 0; i < num_values; i++) {\n values[i] = attr.default_value().list().type(i);\n }\n TFE_OpSetAttrTypeList(op, key,\n reinterpret_cast(values.get()),\n attr.default_value().list().type_size());\n } else if (type == TF_ATTR_SHAPE) {\n int num_values = attr.default_value().list().shape_size();\n (*attr_list_sizes)[key] = num_values;\n int total_dims = 0;\n for (int i = 0; i < num_values; ++i) {\n if (!attr.default_value().list().shape(i).unknown_rank()) {\n total_dims += attr.default_value().list().shape(i).dim_size();\n }\n }\n \/\/ Allocate a buffer that can fit all of the dims together.\n std::unique_ptr buffer(new int64_t[total_dims]);\n \/\/ Copy the input dims into the buffer and set dims to point to\n \/\/ the start of each list's dims.\n std::unique_ptr dims(new const int64_t*[num_values]);\n std::unique_ptr num_dims(new int[num_values]);\n int64_t* offset = buffer.get();\n for (int i = 0; i < num_values; ++i) {\n const auto& shape = attr.default_value().list().shape(i);\n if (shape.unknown_rank()) {\n dims[i] = nullptr;\n num_dims[i] = -1;\n } else {\n for (int j = 0; j < shape.dim_size(); j++) {\n *offset = shape.dim(j).size();\n ++offset;\n }\n }\n }\n TFE_OpSetAttrShapeList(op, key, dims.get(), num_dims.get(), num_values,\n status);\n } else if (type == TF_ATTR_FUNC) {\n int num_values = attr.default_value().list().func_size();\n (*attr_list_sizes)[key] = num_values;\n std::unique_ptr funcs(new const TFE_Op*[num_values]);\n for (int i = 0; i < num_values; i++) {\n funcs[i] = GetFunc(ctx, attr.default_value().list().func(i), status);\n }\n TFE_OpSetAttrFunctionList(op, key, funcs.get(), num_values);\n } else {\n TF_SetStatus(status, TF_UNIMPLEMENTED,\n \"Lists of tensors are not yet implemented for default valued \"\n \"attributes for an operation.\");\n }\n}","target":0,"code_token_length":1135,"total_token_length":1371,"max_tokens_setting":2048} +{"idx":476662,"func":"struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,\n\t\t\t\t\t udf_pblk_t *block, int *err)\n{\n\tudf_pblk_t newblock;\n\tstruct buffer_head *dbh = NULL;\n\tstruct kernel_lb_addr eloc;\n\tuint8_t alloctype;\n\tstruct extent_position epos;\n\n\tstruct udf_fileident_bh sfibh, dfibh;\n\tloff_t f_pos = udf_ext0_offset(inode);\n\tint size = udf_ext0_offset(inode) + inode->i_size;\n\tstruct fileIdentDesc cfi, *sfi, *dfi;\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\n\tif (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))\n\t\talloctype = ICBTAG_FLAG_AD_SHORT;\n\telse\n\t\talloctype = ICBTAG_FLAG_AD_LONG;\n\n\tif (!inode->i_size) {\n\t\tiinfo->i_alloc_type = alloctype;\n\t\tmark_inode_dirty(inode);\n\t\treturn NULL;\n\t}\n\n\t\/* alloc block, and copy data to it *\/\n\t*block = udf_new_block(inode->i_sb, inode,\n\t\t\t iinfo->i_location.partitionReferenceNum,\n\t\t\t iinfo->i_location.logicalBlockNum, err);\n\tif (!(*block))\n\t\treturn NULL;\n\tnewblock = udf_get_pblock(inode->i_sb, *block,\n\t\t\t\t iinfo->i_location.partitionReferenceNum,\n\t\t\t\t0);\n\tif (!newblock)\n\t\treturn NULL;\n\tdbh = udf_tgetblk(inode->i_sb, newblock);\n\tif (!dbh)\n\t\treturn NULL;\n\tlock_buffer(dbh);\n\tmemset(dbh->b_data, 0x00, inode->i_sb->s_blocksize);\n\tset_buffer_uptodate(dbh);\n\tunlock_buffer(dbh);\n\tmark_buffer_dirty_inode(dbh, inode);\n\n\tsfibh.soffset = sfibh.eoffset =\n\t\t\tf_pos & (inode->i_sb->s_blocksize - 1);\n\tsfibh.sbh = sfibh.ebh = NULL;\n\tdfibh.soffset = dfibh.eoffset = 0;\n\tdfibh.sbh = dfibh.ebh = dbh;\n\twhile (f_pos < size) {\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;\n\t\tsfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL,\n\t\t\t\t\t NULL, NULL, NULL);\n\t\tif (!sfi) {\n\t\t\tbrelse(dbh);\n\t\t\treturn NULL;\n\t\t}\n\t\tiinfo->i_alloc_type = alloctype;\n\t\tsfi->descTag.tagLocation = cpu_to_le32(*block);\n\t\tdfibh.soffset = dfibh.eoffset;\n\t\tdfibh.eoffset += (sfibh.eoffset - sfibh.soffset);\n\t\tdfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset);\n\t\tif (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse,\n\t\t\t\t udf_get_fi_ident(sfi))) {\n\t\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;\n\t\t\tbrelse(dbh);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\tmark_buffer_dirty_inode(dbh, inode);\n\n\tmemset(iinfo->i_data + iinfo->i_lenEAttr, 0, iinfo->i_lenAlloc);\n\tiinfo->i_lenAlloc = 0;\n\teloc.logicalBlockNum = *block;\n\teloc.partitionReferenceNum =\n\t\t\t\tiinfo->i_location.partitionReferenceNum;\n\tiinfo->i_lenExtents = inode->i_size;\n\tepos.bh = NULL;\n\tepos.block = iinfo->i_location;\n\tepos.offset = udf_file_entry_alloc_offset(inode);\n\tudf_add_aext(inode, &epos, &eloc, inode->i_size, 0);\n\t\/* UniqueID stuff *\/\n\n\tbrelse(epos.bh);\n\tmark_inode_dirty(inode);\n\treturn dbh;\n}","target":0,"code_token_length":851,"total_token_length":1087,"max_tokens_setting":2048} +{"idx":7970,"func":"block_insert(\n oparg_T\t\t*oap,\n char_u\t\t*s,\n int\t\t\tb_insert,\n struct block_def\t*bdp)\n{\n int\t\tts_val;\n int\t\tcount = 0;\t\/\/ extra spaces to replace a cut TAB\n int\t\tspaces = 0;\t\/\/ non-zero if cutting a TAB\n colnr_T\toffset;\t\t\/\/ pointer along new line\n colnr_T\tstartcol;\t\/\/ column where insert starts\n unsigned\ts_len;\t\t\/\/ STRLEN(s)\n char_u\t*newp, *oldp;\t\/\/ new, old lines\n linenr_T\tlnum;\t\t\/\/ loop var\n int\t\toldstate = State;\n\n State = INSERT;\t\t\/\/ don't want REPLACE for State\n s_len = (unsigned)STRLEN(s);\n\n for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)\n {\n\tblock_prep(oap, bdp, lnum, TRUE);\n\tif (bdp->is_short && b_insert)\n\t continue;\t\/\/ OP_INSERT, line ends before block start\n\n\toldp = ml_get(lnum);\n\n\tif (b_insert)\n\t{\n\t ts_val = bdp->start_char_vcols;\n\t spaces = bdp->startspaces;\n\t if (spaces != 0)\n\t\tcount = ts_val - 1; \/\/ we're cutting a TAB\n\t offset = bdp->textcol;\n\t}\n\telse \/\/ append\n\t{\n\t ts_val = bdp->end_char_vcols;\n\t if (!bdp->is_short) \/\/ spaces = padding after block\n\t {\n\t\tspaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);\n\t\tif (spaces != 0)\n\t\t count = ts_val - 1; \/\/ we're cutting a TAB\n\t\toffset = bdp->textcol + bdp->textlen - (spaces != 0);\n\t }\n\t else \/\/ spaces = padding to block edge\n\t {\n\t\t\/\/ if $ used, just append to EOL (ie spaces==0)\n\t\tif (!bdp->is_MAX)\n\t\t spaces = (oap->end_vcol - bdp->end_vcol) + 1;\n\t\tcount = spaces;\n\t\toffset = bdp->textcol + bdp->textlen;\n\t }\n\t}\n\n\tif (has_mbyte && spaces > 0)\n\t{\n\t int off;\n\n\t \/\/ Avoid starting halfway a multi-byte character.\n\t if (b_insert)\n\t {\n\t\toff = (*mb_head_off)(oldp, oldp + offset + spaces);\n\t\tspaces -= off;\n\t\tcount -= off;\n\t }\n\t else\n\t {\n\t\t\/\/ spaces fill the gap, the character that's at the edge moves\n\t\t\/\/ right\n\t\toff = (*mb_head_off)(oldp, oldp + offset);\n\t\toffset -= off;\n\t }\n\t}\n\tif (spaces < 0) \/\/ can happen when the cursor was moved\n\t spaces = 0;\n\n\t\/\/ Make sure the allocated size matches what is actually copied below.\n\tnewp = alloc(STRLEN(oldp) + spaces + s_len\n\t\t + (spaces > 0 && !bdp->is_short ? ts_val - spaces : 0)\n\t\t\t\t\t\t\t\t + count + 1);\n\tif (newp == NULL)\n\t continue;\n\n\t\/\/ copy up to shifted part\n\tmch_memmove(newp, oldp, (size_t)offset);\n\toldp += offset;\n\n\t\/\/ insert pre-padding\n\tvim_memset(newp + offset, ' ', (size_t)spaces);\n\tstartcol = offset + spaces;\n\n\t\/\/ copy the new text\n\tmch_memmove(newp + startcol, s, (size_t)s_len);\n\toffset += s_len;\n\n\tif (spaces > 0 && !bdp->is_short)\n\t{\n\t if (*oldp == TAB)\n\t {\n\t\t\/\/ insert post-padding\n\t\tvim_memset(newp + offset + spaces, ' ',\n\t\t\t\t\t\t (size_t)(ts_val - spaces));\n\t\t\/\/ we're splitting a TAB, don't copy it\n\t\toldp++;\n\t\t\/\/ We allowed for that TAB, remember this now\n\t\tcount++;\n\t }\n\t else\n\t\t\/\/ Not a TAB, no extra spaces\n\t\tcount = spaces;\n\t}\n\n\tif (spaces > 0)\n\t offset += count;\n\tSTRMOVE(newp + offset, oldp);\n\n\tml_replace(lnum, newp, FALSE);\n\n\tif (b_insert)\n\t \/\/ correct any text properties\n\t inserted_bytes(lnum, startcol, s_len);\n\n\tif (lnum == oap->end.lnum)\n\t{\n\t \/\/ Set \"']\" mark to the end of the block instead of the end of\n\t \/\/ the insert in the first line.\n\t curbuf->b_op_end.lnum = oap->end.lnum;\n\t curbuf->b_op_end.col = offset;\n\t}\n } \/\/ for all lnum\n\n changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);\n\n State = oldstate;\n}","target":1,"code_token_length":1107,"total_token_length":1343,"max_tokens_setting":2048} +{"idx":145047,"func":"nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session,\n int32_t stream_id, uint8_t flags,\n nghttp2_priority_spec *pri_spec_in,\n nghttp2_stream_state initial_state,\n void *stream_user_data) {\n int rv;\n nghttp2_stream *stream;\n nghttp2_stream *dep_stream = NULL;\n int stream_alloc = 0;\n nghttp2_priority_spec pri_spec_default;\n nghttp2_priority_spec *pri_spec = pri_spec_in;\n nghttp2_mem *mem;\n\n mem = &session->mem;\n stream = nghttp2_session_get_stream_raw(session, stream_id);\n\n if (stream) {\n assert(stream->state == NGHTTP2_STREAM_IDLE);\n assert(nghttp2_stream_in_dep_tree(stream));\n nghttp2_session_detach_idle_stream(session, stream);\n rv = nghttp2_stream_dep_remove(stream);\n if (rv != 0) {\n return NULL;\n }\n } else {\n stream = nghttp2_mem_malloc(mem, sizeof(nghttp2_stream));\n if (stream == NULL) {\n return NULL;\n }\n\n stream_alloc = 1;\n }\n\n if (pri_spec->stream_id != 0) {\n dep_stream = nghttp2_session_get_stream_raw(session, pri_spec->stream_id);\n\n if (!dep_stream &&\n session_detect_idle_stream(session, pri_spec->stream_id)) {\n \/* Depends on idle stream, which does not exist in memory.\n Assign default priority for it. *\/\n nghttp2_priority_spec_default_init(&pri_spec_default);\n\n dep_stream = nghttp2_session_open_stream(\n session, pri_spec->stream_id, NGHTTP2_FLAG_NONE, &pri_spec_default,\n NGHTTP2_STREAM_IDLE, NULL);\n\n if (dep_stream == NULL) {\n if (stream_alloc) {\n nghttp2_mem_free(mem, stream);\n }\n\n return NULL;\n }\n } else if (!dep_stream || !nghttp2_stream_in_dep_tree(dep_stream)) {\n \/* If dep_stream is not part of dependency tree, stream will get\n default priority. This handles the case when\n pri_spec->stream_id == stream_id. This happens because we\n don't check pri_spec->stream_id against new stream ID in\n nghttp2_submit_request. This also handles the case when idle\n stream created by PRIORITY frame was opened. Somehow we\n first remove the idle stream from dependency tree. This is\n done to simplify code base, but ideally we should retain old\n dependency. But I'm not sure this adds values. *\/\n nghttp2_priority_spec_default_init(&pri_spec_default);\n pri_spec = &pri_spec_default;\n }\n }\n\n if (initial_state == NGHTTP2_STREAM_RESERVED) {\n flags |= NGHTTP2_STREAM_FLAG_PUSH;\n }\n\n if (stream_alloc) {\n nghttp2_stream_init(stream, stream_id, flags, initial_state,\n pri_spec->weight,\n (int32_t)session->remote_settings.initial_window_size,\n (int32_t)session->local_settings.initial_window_size,\n stream_user_data, mem);\n\n rv = nghttp2_map_insert(&session->streams, &stream->map_entry);\n if (rv != 0) {\n nghttp2_stream_free(stream);\n nghttp2_mem_free(mem, stream);\n return NULL;\n }\n } else {\n stream->flags = flags;\n stream->state = initial_state;\n stream->weight = pri_spec->weight;\n stream->stream_user_data = stream_user_data;\n }\n\n switch (initial_state) {\n case NGHTTP2_STREAM_RESERVED:\n if (nghttp2_session_is_my_stream_id(session, stream_id)) {\n \/* reserved (local) *\/\n nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);\n } else {\n \/* reserved (remote) *\/\n nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_WR);\n ++session->num_incoming_reserved_streams;\n }\n \/* Reserved stream does not count in the concurrent streams\n limit. That is one of the DOS vector. *\/\n break;\n case NGHTTP2_STREAM_IDLE:\n \/* Idle stream does not count toward the concurrent streams limit.\n This is used as anchor node in dependency tree. *\/\n nghttp2_session_keep_idle_stream(session, stream);\n break;\n default:\n if (nghttp2_session_is_my_stream_id(session, stream_id)) {\n ++session->num_outgoing_streams;\n } else {\n ++session->num_incoming_streams;\n }\n }\n\n if (pri_spec->stream_id == 0) {\n dep_stream = &session->root;\n }\n\n assert(dep_stream);\n\n if (pri_spec->exclusive) {\n rv = nghttp2_stream_dep_insert(dep_stream, stream);\n if (rv != 0) {\n return NULL;\n }\n } else {\n nghttp2_stream_dep_add(dep_stream, stream);\n }\n\n return stream;\n}","target":0,"code_token_length":1083,"total_token_length":1319,"max_tokens_setting":2048} +{"idx":421832,"func":"flatpak_run_setup_base_argv (FlatpakBwrap *bwrap,\n GFile *runtime_files,\n GFile *app_id_dir,\n const char *arch,\n FlatpakRunFlags flags,\n GError **error)\n{\n g_autofree char *run_dir = NULL;\n g_autofree char *passwd_contents = NULL;\n g_autofree char *group_contents = NULL;\n const char *pkcs11_conf_contents = NULL;\n struct group *g;\n gulong pers;\n gid_t gid = getgid ();\n\n g_autoptr(GFile) etc = NULL;\n\n g = getgrgid (gid);\n if (g == NULL)\n return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Invalid group: %d\"), gid);\n\n run_dir = g_strdup_printf (\"\/run\/user\/%d\", getuid ());\n\n passwd_contents = g_strdup_printf (\"%s:x:%d:%d:%s:%s:%s\\n\"\n \"nfsnobody:x:65534:65534:Unmapped user:\/:\/sbin\/nologin\\n\",\n g_get_user_name (),\n getuid (), gid,\n g_get_real_name (),\n g_get_home_dir (),\n DEFAULT_SHELL);\n\n group_contents = g_strdup_printf (\"%s:x:%d:%s\\n\"\n \"nfsnobody:x:65534:\\n\",\n g->gr_name,\n gid, g_get_user_name ());\n\n pkcs11_conf_contents =\n \"# Disable user pkcs11 config, because the host modules don't work in the runtime\\n\"\n \"user-config: none\\n\";\n\n if ((flags & FLATPAK_RUN_FLAG_NO_PROC) == 0)\n flatpak_bwrap_add_args (bwrap,\n \"--proc\", \"\/proc\",\n NULL);\n\n flatpak_bwrap_add_args (bwrap,\n \"--unshare-pid\",\n \"--dir\", \"\/tmp\",\n \"--dir\", \"\/var\/tmp\",\n \"--dir\", \"\/run\/host\",\n \"--dir\", run_dir,\n \"--setenv\", \"XDG_RUNTIME_DIR\", run_dir,\n \"--symlink\", \"..\/run\", \"\/var\/run\",\n \"--ro-bind\", \"\/sys\/block\", \"\/sys\/block\",\n \"--ro-bind\", \"\/sys\/bus\", \"\/sys\/bus\",\n \"--ro-bind\", \"\/sys\/class\", \"\/sys\/class\",\n \"--ro-bind\", \"\/sys\/dev\", \"\/sys\/dev\",\n \"--ro-bind\", \"\/sys\/devices\", \"\/sys\/devices\",\n \/* glib uses this like \/etc\/timezone *\/\n \"--symlink\", \"\/etc\/timezone\", \"\/var\/db\/zoneinfo\",\n NULL);\n\n if (flags & FLATPAK_RUN_FLAG_DIE_WITH_PARENT)\n flatpak_bwrap_add_args (bwrap,\n \"--die-with-parent\",\n NULL);\n\n if (flags & FLATPAK_RUN_FLAG_WRITABLE_ETC)\n flatpak_bwrap_add_args (bwrap,\n \"--dir\", \"\/usr\/etc\",\n \"--symlink\", \"usr\/etc\", \"\/etc\",\n NULL);\n\n if (!flatpak_bwrap_add_args_data (bwrap, \"passwd\", passwd_contents, -1, \"\/etc\/passwd\", error))\n return FALSE;\n\n if (!flatpak_bwrap_add_args_data (bwrap, \"group\", group_contents, -1, \"\/etc\/group\", error))\n return FALSE;\n\n if (!flatpak_bwrap_add_args_data (bwrap, \"pkcs11.conf\", pkcs11_conf_contents, -1, \"\/etc\/pkcs11\/pkcs11.conf\", error))\n return FALSE;\n\n if (g_file_test (\"\/etc\/machine-id\", G_FILE_TEST_EXISTS))\n flatpak_bwrap_add_args (bwrap, \"--ro-bind\", \"\/etc\/machine-id\", \"\/etc\/machine-id\", NULL);\n else if (g_file_test (\"\/var\/lib\/dbus\/machine-id\", G_FILE_TEST_EXISTS))\n flatpak_bwrap_add_args (bwrap, \"--ro-bind\", \"\/var\/lib\/dbus\/machine-id\", \"\/etc\/machine-id\", NULL);\n\n if (runtime_files)\n etc = g_file_get_child (runtime_files, \"etc\");\n if (etc != NULL &&\n (flags & FLATPAK_RUN_FLAG_WRITABLE_ETC) == 0 &&\n g_file_query_exists (etc, NULL))\n {\n g_auto(GLnxDirFdIterator) dfd_iter = { 0, };\n struct dirent *dent;\n char path_buffer[PATH_MAX + 1];\n ssize_t symlink_size;\n gboolean inited;\n\n inited = glnx_dirfd_iterator_init_at (AT_FDCWD, flatpak_file_get_path_cached (etc), FALSE, &dfd_iter, NULL);\n\n while (inited)\n {\n g_autofree char *src = NULL;\n g_autofree char *dest = NULL;\n\n if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, NULL, NULL) || dent == NULL)\n break;\n\n if (strcmp (dent->d_name, \"passwd\") == 0 ||\n strcmp (dent->d_name, \"group\") == 0 ||\n strcmp (dent->d_name, \"machine-id\") == 0 ||\n strcmp (dent->d_name, \"resolv.conf\") == 0 ||\n strcmp (dent->d_name, \"host.conf\") == 0 ||\n strcmp (dent->d_name, \"hosts\") == 0 ||\n strcmp (dent->d_name, \"localtime\") == 0 ||\n strcmp (dent->d_name, \"timezone\") == 0 ||\n strcmp (dent->d_name, \"pkcs11\") == 0)\n continue;\n\n src = g_build_filename (flatpak_file_get_path_cached (etc), dent->d_name, NULL);\n dest = g_build_filename (\"\/etc\", dent->d_name, NULL);\n if (dent->d_type == DT_LNK)\n {\n symlink_size = readlinkat (dfd_iter.fd, dent->d_name, path_buffer, sizeof (path_buffer) - 1);\n if (symlink_size < 0)\n {\n glnx_set_error_from_errno (error);\n return FALSE;\n }\n path_buffer[symlink_size] = 0;\n flatpak_bwrap_add_args (bwrap, \"--symlink\", path_buffer, dest, NULL);\n }\n else\n {\n flatpak_bwrap_add_args (bwrap, \"--ro-bind\", src, dest, NULL);\n }\n }\n }\n\n if (app_id_dir != NULL)\n {\n g_autoptr(GFile) app_cache_dir = g_file_get_child (app_id_dir, \"cache\");\n g_autoptr(GFile) app_tmp_dir = g_file_get_child (app_cache_dir, \"tmp\");\n g_autoptr(GFile) app_data_dir = g_file_get_child (app_id_dir, \"data\");\n g_autoptr(GFile) app_config_dir = g_file_get_child (app_id_dir, \"config\");\n\n flatpak_bwrap_add_args (bwrap,\n \/* These are nice to have as a fixed path *\/\n \"--bind\", flatpak_file_get_path_cached (app_cache_dir), \"\/var\/cache\",\n \"--bind\", flatpak_file_get_path_cached (app_data_dir), \"\/var\/data\",\n \"--bind\", flatpak_file_get_path_cached (app_config_dir), \"\/var\/config\",\n \"--bind\", flatpak_file_get_path_cached (app_tmp_dir), \"\/var\/tmp\",\n NULL);\n }\n\n flatpak_run_setup_usr_links (bwrap, runtime_files);\n\n pers = PER_LINUX;\n\n if ((flags & FLATPAK_RUN_FLAG_SET_PERSONALITY) &&\n flatpak_is_linux32_arch (arch))\n {\n g_debug (\"Setting personality linux32\");\n pers = PER_LINUX32;\n }\n\n \/* Always set the personallity, and clear all weird flags *\/\n personality (pers);\n\n#ifdef ENABLE_SECCOMP\n if (!setup_seccomp (bwrap, arch, pers, flags, error))\n return FALSE;\n#endif\n\n if ((flags & FLATPAK_RUN_FLAG_WRITABLE_ETC) == 0)\n add_monitor_path_args ((flags & FLATPAK_RUN_FLAG_NO_SESSION_HELPER) == 0, bwrap);\n\n return TRUE;\n}","target":0,"code_token_length":1788,"total_token_length":2024,"max_tokens_setting":2048} +{"idx":499700,"func":"QPDFWriter::prepareFileForWrite()\n{\n \/\/ Do a traversal of the entire PDF file structure replacing all\n \/\/ indirect objects that QPDFWriter wants to be direct. This\n \/\/ includes stream lengths, stream filtering parameters, and\n \/\/ document extension level information.\n\n this->m->pdf.fixDanglingReferences(true);\n std::list queue;\n queue.push_back(getTrimmedTrailer());\n std::set visited;\n\n while (! queue.empty())\n {\n\tQPDFObjectHandle node = queue.front();\n\tqueue.pop_front();\n\tif (node.isIndirect())\n\t{\n\t if (visited.count(node.getObjectID()) > 0)\n\t {\n\t\tcontinue;\n\t }\n indicateProgress(false, false);\n\t visited.insert(node.getObjectID());\n\t}\n\n\tif (node.isArray())\n\t{\n\t int nitems = node.getArrayNItems();\n\t for (int i = 0; i < nitems; ++i)\n\t {\n\t\tQPDFObjectHandle oh = node.getArrayItem(i);\n if (oh.isIndirect() && oh.isNull())\n {\n QTC::TC(\"qpdf\", \"QPDFWriter flatten array null\");\n oh.makeDirect();\n node.setArrayItem(i, oh);\n }\n\t\telse if (! oh.isScalar())\n\t\t{\n\t\t queue.push_back(oh);\n\t\t}\n\t }\n\t}\n\telse if (node.isDictionary() || node.isStream())\n\t{\n bool is_stream = false;\n bool is_root = false;\n bool filterable = false;\n\t QPDFObjectHandle dict = node;\n\t if (node.isStream())\n\t {\n is_stream = true;\n\t\tdict = node.getDict();\n \/\/ See whether we are able to filter this stream.\n filterable = node.pipeStreamData(\n 0, 0, this->m->stream_decode_level, true);\n\t }\n else if (this->m->pdf.getRoot().getObjectID() == node.getObjectID())\n {\n is_root = true;\n }\n\n\t std::set keys = dict.getKeys();\n\t for (std::set::iterator iter = keys.begin();\n\t\t iter != keys.end(); ++iter)\n\t {\n\t\tstd::string const& key = *iter;\n\t\tQPDFObjectHandle oh = dict.getKey(key);\n bool add_to_queue = true;\n if (is_stream)\n {\n if (oh.isIndirect() &&\n ((key == \"\/Length\") ||\n (filterable &&\n ((key == \"\/Filter\") ||\n (key == \"\/DecodeParms\")))))\n {\n QTC::TC(\"qpdf\", \"QPDFWriter make stream key direct\");\n add_to_queue = false;\n oh.makeDirect();\n dict.replaceKey(key, oh);\n }\n }\n else if (is_root)\n {\n if ((key == \"\/Extensions\") && (oh.isDictionary()))\n {\n bool extensions_indirect = false;\n if (oh.isIndirect())\n {\n QTC::TC(\"qpdf\", \"QPDFWriter make Extensions direct\");\n extensions_indirect = true;\n add_to_queue = false;\n oh = oh.shallowCopy();\n dict.replaceKey(key, oh);\n }\n if (oh.hasKey(\"\/ADBE\"))\n {\n QPDFObjectHandle adbe = oh.getKey(\"\/ADBE\");\n if (adbe.isIndirect())\n {\n QTC::TC(\"qpdf\", \"QPDFWriter make ADBE direct\",\n extensions_indirect ? 0 : 1);\n adbe.makeDirect();\n oh.replaceKey(\"\/ADBE\", adbe);\n }\n }\n }\n }\n\n if (add_to_queue)\n {\n queue.push_back(oh);\n\t\t}\n\t }\n\t}\n }\n}","target":0,"code_token_length":796,"total_token_length":1032,"max_tokens_setting":2048} +{"idx":183990,"func":" psh_glyph_init( PSH_Glyph glyph,\n FT_Outline* outline,\n PS_Hints ps_hints,\n PSH_Globals globals )\n {\n FT_Error error;\n FT_Memory memory;\n\n\n \/* clear all fields *\/\n FT_MEM_ZERO( glyph, sizeof ( *glyph ) );\n\n memory = glyph->memory = globals->memory;\n\n \/* allocate and setup points + contours arrays *\/\n if ( FT_NEW_ARRAY( glyph->points, outline->n_points ) ||\n FT_NEW_ARRAY( glyph->contours, outline->n_contours ) )\n goto Exit;\n\n glyph->num_points = outline->n_points;\n glyph->num_contours = outline->n_contours;\n\n {\n FT_UInt first = 0, next, n;\n PSH_Point points = glyph->points;\n PSH_Contour contour = glyph->contours;\n\n\n for ( n = 0; n < glyph->num_contours; n++ )\n {\n FT_Int count;\n PSH_Point point;\n\n\n next = outline->contours[n] + 1;\n count = next - first;\n\n contour->start = points + first;\n contour->count = (FT_UInt)count;\n\n if ( count > 0 )\n {\n point = points + first;\n\n point->prev = points + next - 1;\n point->contour = contour;\n\n for ( ; count > 1; count-- )\n {\n point[0].next = point + 1;\n point[1].prev = point;\n point++;\n point->contour = contour;\n }\n point->next = points + first;\n }\n\n contour++;\n first = next;\n }\n }\n\n {\n PSH_Point points = glyph->points;\n PSH_Point point = points;\n FT_Vector* vec = outline->points;\n FT_UInt n;\n\n\n for ( n = 0; n < glyph->num_points; n++, point++ )\n {\n FT_Int n_prev = (FT_Int)( point->prev - points );\n FT_Int n_next = (FT_Int)( point->next - points );\n FT_Pos dxi, dyi, dxo, dyo;\n\n\n if ( !( outline->tags[n] & FT_CURVE_TAG_ON ) )\n point->flags = PSH_POINT_OFF;\n\n dxi = vec[n].x - vec[n_prev].x;\n dyi = vec[n].y - vec[n_prev].y;\n\n point->dir_in = (FT_Char)psh_compute_dir( dxi, dyi );\n\n dxo = vec[n_next].x - vec[n].x;\n dyo = vec[n_next].y - vec[n].y;\n\n point->dir_out = (FT_Char)psh_compute_dir( dxo, dyo );\n\n \/* detect smooth points *\/\n if ( point->flags & PSH_POINT_OFF )\n point->flags |= PSH_POINT_SMOOTH;\n\n else if ( point->dir_in == point->dir_out )\n {\n if ( point->dir_out != PSH_DIR_NONE ||\n psh_corner_is_flat( dxi, dyi, dxo, dyo ) )\n point->flags |= PSH_POINT_SMOOTH;\n }\n }\n }\n\n glyph->outline = outline;\n glyph->globals = globals;\n\n#ifdef COMPUTE_INFLEXS\n psh_glyph_load_points( glyph, 0 );\n psh_glyph_compute_inflections( glyph );\n#endif \/* COMPUTE_INFLEXS *\/\n\n \/* now deal with hints tables *\/\n error = psh_hint_table_init( &glyph->hint_tables [0],\n &ps_hints->dimension[0].hints,\n &ps_hints->dimension[0].masks,\n &ps_hints->dimension[0].counters,\n memory );\n if ( error )\n goto Exit;\n\n error = psh_hint_table_init( &glyph->hint_tables [1],\n &ps_hints->dimension[1].hints,\n &ps_hints->dimension[1].masks,\n &ps_hints->dimension[1].counters,\n memory );\n if ( error )\n goto Exit;\n\n Exit:\n return error;\n }\n","target":0,"code_token_length":924,"total_token_length":1160,"max_tokens_setting":2048} +{"idx":23887,"func":"static void dissect_rsvp_template_filter ( proto_item * ti , proto_tree * rsvp_object_tree , tvbuff_t * tvb , int offset , int obj_length , int rsvp_class _U_ , int type , rsvp_conversation_info * rsvph ) {\n int offset2 = offset + 4 ;\n proto_item_set_text ( ti , \"%s\" , summary_template ( tvb , offset ) ) ;\n switch ( type ) {\n case 1 : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , \"1 - IPv4\" ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_IP ] , tvb , offset2 , 4 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_PORT ] , tvb , offset2 + 6 , 2 , ENC_BIG_ENDIAN ) ;\n set_address_tvb ( & rsvph -> source , AT_IPv4 , 4 , tvb , offset2 ) ;\n rsvph -> udp_source_port = tvb_get_ntohs ( tvb , offset2 + 6 ) ;\n break ;\n case 2 : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , \"2 - IPv6\" ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_template_filter_source_address_ipv6 , tvb , offset2 , 16 , ENC_NA ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_template_filter_source_port , tvb , offset2 + 18 , 2 , ENC_BIG_ENDIAN ) ;\n break ;\n case 7 : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , \"7 - IPv4 LSP\" ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_IP ] , tvb , offset2 , 4 , ENC_BIG_ENDIAN ) ;\n if ( rsvp_class == RSVP_CLASS_SENDER_TEMPLATE ) {\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_SHORT_CALL_ID ] , tvb , offset2 + 4 , 2 , ENC_BIG_ENDIAN ) ;\n }\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_LSP_ID ] , tvb , offset2 + 6 , 2 , ENC_BIG_ENDIAN ) ;\n set_address_tvb ( & rsvph -> source , AT_IPv4 , 4 , tvb , offset2 ) ;\n rsvph -> udp_source_port = tvb_get_ntohs ( tvb , offset2 + 6 ) ;\n break ;\n case 8 : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , \"8 - IPv6 LSP\" ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_IP ] , tvb , offset2 , 16 , ENC_BIG_ENDIAN ) ;\n if ( rsvp_class == RSVP_CLASS_SENDER_TEMPLATE ) {\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_SHORT_CALL_ID ] , tvb , offset2 + 16 , 2 , ENC_BIG_ENDIAN ) ;\n }\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_LSP_ID ] , tvb , offset2 + 18 , 2 , ENC_BIG_ENDIAN ) ;\n set_address_tvb ( & rsvph -> source , AT_IPv6 , 16 , tvb , offset2 ) ;\n rsvph -> udp_source_port = tvb_get_ntohs ( tvb , offset2 + 18 ) ;\n break ;\n case 9 : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , \"9 - IPv4 Aggregate\" ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_filter [ RSVPF_SENDER_IP ] , tvb , offset2 , 4 , ENC_BIG_ENDIAN ) ;\n set_address_tvb ( & rsvph -> source , AT_IPv4 , 4 , tvb , offset2 ) ;\n break ;\n default : proto_tree_add_uint_format_value ( rsvp_object_tree , hf_rsvp_ctype , tvb , offset + 3 , 1 , type , \"Unknown (%u)\" , type ) ;\n proto_tree_add_item ( rsvp_object_tree , hf_rsvp_template_filter_data , tvb , offset2 , obj_length - 4 , ENC_NA ) ;\n break ;\n }\n }","target":0,"code_token_length":1006,"total_token_length":1242,"max_tokens_setting":2048} +{"idx":357868,"func":"dx_probe(const struct qstr *d_name, struct inode *dir,\n\t struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err)\n{\n\tunsigned count, indirect;\n\tstruct dx_entry *at, *entries, *p, *q, *m;\n\tstruct dx_root *root;\n\tstruct buffer_head *bh;\n\tstruct dx_frame *frame = frame_in;\n\tu32 hash;\n\n\tframe->bh = NULL;\n\tif (!(bh = ext4_bread (NULL,dir, 0, 0, err)))\n\t\tgoto fail;\n\troot = (struct dx_root *) bh->b_data;\n\tif (root->info.hash_version != DX_HASH_TEA &&\n\t root->info.hash_version != DX_HASH_HALF_MD4 &&\n\t root->info.hash_version != DX_HASH_LEGACY) {\n\t\text4_warning(dir->i_sb, __func__,\n\t\t\t \"Unrecognised inode hash code %d\",\n\t\t\t root->info.hash_version);\n\t\tbrelse(bh);\n\t\t*err = ERR_BAD_DX_DIR;\n\t\tgoto fail;\n\t}\n\thinfo->hash_version = root->info.hash_version;\n\tif (hinfo->hash_version <= DX_HASH_TEA)\n\t\thinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;\n\thinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed;\n\tif (d_name)\n\t\text4fs_dirhash(d_name->name, d_name->len, hinfo);\n\thash = hinfo->hash;\n\n\tif (root->info.unused_flags & 1) {\n\t\text4_warning(dir->i_sb, __func__,\n\t\t\t \"Unimplemented inode hash flags: %#06x\",\n\t\t\t root->info.unused_flags);\n\t\tbrelse(bh);\n\t\t*err = ERR_BAD_DX_DIR;\n\t\tgoto fail;\n\t}\n\n\tif ((indirect = root->info.indirect_levels) > 1) {\n\t\text4_warning(dir->i_sb, __func__,\n\t\t\t \"Unimplemented inode hash depth: %#06x\",\n\t\t\t root->info.indirect_levels);\n\t\tbrelse(bh);\n\t\t*err = ERR_BAD_DX_DIR;\n\t\tgoto fail;\n\t}\n\n\tentries = (struct dx_entry *) (((char *)&root->info) +\n\t\t\t\t root->info.info_length);\n\n\tif (dx_get_limit(entries) != dx_root_limit(dir,\n\t\t\t\t\t\t root->info.info_length)) {\n\t\text4_warning(dir->i_sb, __func__,\n\t\t\t \"dx entry: limit != root limit\");\n\t\tbrelse(bh);\n\t\t*err = ERR_BAD_DX_DIR;\n\t\tgoto fail;\n\t}\n\n\tdxtrace(printk(\"Look up %x\", hash));\n\twhile (1)\n\t{\n\t\tcount = dx_get_count(entries);\n\t\tif (!count || count > dx_get_limit(entries)) {\n\t\t\text4_warning(dir->i_sb, __func__,\n\t\t\t\t \"dx entry: no count or count > limit\");\n\t\t\tbrelse(bh);\n\t\t\t*err = ERR_BAD_DX_DIR;\n\t\t\tgoto fail2;\n\t\t}\n\n\t\tp = entries + 1;\n\t\tq = entries + count - 1;\n\t\twhile (p <= q)\n\t\t{\n\t\t\tm = p + (q - p)\/2;\n\t\t\tdxtrace(printk(\".\"));\n\t\t\tif (dx_get_hash(m) > hash)\n\t\t\t\tq = m - 1;\n\t\t\telse\n\t\t\t\tp = m + 1;\n\t\t}\n\n\t\tif (0) \/\/ linear search cross check\n\t\t{\n\t\t\tunsigned n = count - 1;\n\t\t\tat = entries;\n\t\t\twhile (n--)\n\t\t\t{\n\t\t\t\tdxtrace(printk(\",\"));\n\t\t\t\tif (dx_get_hash(++at) > hash)\n\t\t\t\t{\n\t\t\t\t\tat--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tassert (at == p - 1);\n\t\t}\n\n\t\tat = p - 1;\n\t\tdxtrace(printk(\" %x->%u\\n\", at == entries? 0: dx_get_hash(at), dx_get_block(at)));\n\t\tframe->bh = bh;\n\t\tframe->entries = entries;\n\t\tframe->at = at;\n\t\tif (!indirect--) return frame;\n\t\tif (!(bh = ext4_bread (NULL,dir, dx_get_block(at), 0, err)))\n\t\t\tgoto fail2;\n\t\tat = entries = ((struct dx_node *) bh->b_data)->entries;\n\t\tif (dx_get_limit(entries) != dx_node_limit (dir)) {\n\t\t\text4_warning(dir->i_sb, __func__,\n\t\t\t\t \"dx entry: limit != node limit\");\n\t\t\tbrelse(bh);\n\t\t\t*err = ERR_BAD_DX_DIR;\n\t\t\tgoto fail2;\n\t\t}\n\t\tframe++;\n\t\tframe->bh = NULL;\n\t}\nfail2:\n\twhile (frame >= frame_in) {\n\t\tbrelse(frame->bh);\n\t\tframe--;\n\t}\nfail:\n\tif (*err == ERR_BAD_DX_DIR)\n\t\text4_warning(dir->i_sb, __func__,\n\t\t\t \"Corrupt dir inode %ld, running e2fsck is \"\n\t\t\t \"recommended.\", dir->i_ino);\n\treturn NULL;\n}","target":0,"code_token_length":1060,"total_token_length":1296,"max_tokens_setting":2048} +{"idx":351141,"func":"static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)\n{\n\tstruct ieee80211_sub_if_data *sdata = rx->sdata;\n\tstruct sk_buff *skb = rx->skb;\n\tstruct ieee80211_hdr *hdr = (void *)skb->data;\n\tstruct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);\n\tu8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type);\n\tbool multicast = is_multicast_ether_addr(hdr->addr1);\n\n\tswitch (sdata->vif.type) {\n\tcase NL80211_IFTYPE_STATION:\n\t\tif (!bssid && !sdata->u.mgd.use_4addr)\n\t\t\treturn false;\n\t\tif (multicast)\n\t\t\treturn true;\n\t\treturn ether_addr_equal(sdata->vif.addr, hdr->addr1);\n\tcase NL80211_IFTYPE_ADHOC:\n\t\tif (!bssid)\n\t\t\treturn false;\n\t\tif (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||\n\t\t ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))\n\t\t\treturn false;\n\t\tif (ieee80211_is_beacon(hdr->frame_control))\n\t\t\treturn true;\n\t\tif (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid))\n\t\t\treturn false;\n\t\tif (!multicast &&\n\t\t !ether_addr_equal(sdata->vif.addr, hdr->addr1))\n\t\t\treturn false;\n\t\tif (!rx->sta) {\n\t\t\tint rate_idx;\n\t\t\tif (status->encoding != RX_ENC_LEGACY)\n\t\t\t\trate_idx = 0; \/* TODO: HT\/VHT rates *\/\n\t\t\telse\n\t\t\t\trate_idx = status->rate_idx;\n\t\t\tieee80211_ibss_rx_no_sta(sdata, bssid, hdr->addr2,\n\t\t\t\t\t\t BIT(rate_idx));\n\t\t}\n\t\treturn true;\n\tcase NL80211_IFTYPE_OCB:\n\t\tif (!bssid)\n\t\t\treturn false;\n\t\tif (!ieee80211_is_data_present(hdr->frame_control))\n\t\t\treturn false;\n\t\tif (!is_broadcast_ether_addr(bssid))\n\t\t\treturn false;\n\t\tif (!multicast &&\n\t\t !ether_addr_equal(sdata->dev->dev_addr, hdr->addr1))\n\t\t\treturn false;\n\t\tif (!rx->sta) {\n\t\t\tint rate_idx;\n\t\t\tif (status->encoding != RX_ENC_LEGACY)\n\t\t\t\trate_idx = 0; \/* TODO: HT rates *\/\n\t\t\telse\n\t\t\t\trate_idx = status->rate_idx;\n\t\t\tieee80211_ocb_rx_no_sta(sdata, bssid, hdr->addr2,\n\t\t\t\t\t\tBIT(rate_idx));\n\t\t}\n\t\treturn true;\n\tcase NL80211_IFTYPE_MESH_POINT:\n\t\tif (ether_addr_equal(sdata->vif.addr, hdr->addr2))\n\t\t\treturn false;\n\t\tif (multicast)\n\t\t\treturn true;\n\t\treturn ether_addr_equal(sdata->vif.addr, hdr->addr1);\n\tcase NL80211_IFTYPE_AP_VLAN:\n\tcase NL80211_IFTYPE_AP:\n\t\tif (!bssid)\n\t\t\treturn ether_addr_equal(sdata->vif.addr, hdr->addr1);\n\n\t\tif (!ieee80211_bssid_match(bssid, sdata->vif.addr)) {\n\t\t\t\/*\n\t\t\t * Accept public action frames even when the\n\t\t\t * BSSID doesn't match, this is used for P2P\n\t\t\t * and location updates. Note that mac80211\n\t\t\t * itself never looks at these frames.\n\t\t\t *\/\n\t\t\tif (!multicast &&\n\t\t\t !ether_addr_equal(sdata->vif.addr, hdr->addr1))\n\t\t\t\treturn false;\n\t\t\tif (ieee80211_is_public_action(hdr, skb->len))\n\t\t\t\treturn true;\n\t\t\treturn ieee80211_is_beacon(hdr->frame_control);\n\t\t}\n\n\t\tif (!ieee80211_has_tods(hdr->frame_control)) {\n\t\t\t\/* ignore data frames to TDLS-peers *\/\n\t\t\tif (ieee80211_is_data(hdr->frame_control))\n\t\t\t\treturn false;\n\t\t\t\/* ignore action frames to TDLS-peers *\/\n\t\t\tif (ieee80211_is_action(hdr->frame_control) &&\n\t\t\t !is_broadcast_ether_addr(bssid) &&\n\t\t\t !ether_addr_equal(bssid, hdr->addr1))\n\t\t\t\treturn false;\n\t\t}\n\n\t\t\/*\n\t\t * 802.11-2016 Table 9-26 says that for data frames, A1 must be\n\t\t * the BSSID - we've checked that already but may have accepted\n\t\t * the wildcard (ff:ff:ff:ff:ff:ff).\n\t\t *\n\t\t * It also says:\n\t\t *\tThe BSSID of the Data frame is determined as follows:\n\t\t *\ta) If the STA is contained within an AP or is associated\n\t\t *\t with an AP, the BSSID is the address currently in use\n\t\t *\t by the STA contained in the AP.\n\t\t *\n\t\t * So we should not accept data frames with an address that's\n\t\t * multicast.\n\t\t *\n\t\t * Accepting it also opens a security problem because stations\n\t\t * could encrypt it with the GTK and inject traffic that way.\n\t\t *\/\n\t\tif (ieee80211_is_data(hdr->frame_control) && multicast)\n\t\t\treturn false;\n\n\t\treturn true;\n\tcase NL80211_IFTYPE_WDS:\n\t\tif (bssid || !ieee80211_is_data(hdr->frame_control))\n\t\t\treturn false;\n\t\treturn ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2);\n\tcase NL80211_IFTYPE_P2P_DEVICE:\n\t\treturn ieee80211_is_public_action(hdr, skb->len) ||\n\t\t ieee80211_is_probe_req(hdr->frame_control) ||\n\t\t ieee80211_is_probe_resp(hdr->frame_control) ||\n\t\t ieee80211_is_beacon(hdr->frame_control);\n\tcase NL80211_IFTYPE_NAN:\n\t\t\/* Currently no frames on NAN interface are allowed *\/\n\t\treturn false;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tWARN_ON_ONCE(1);\n\treturn false;\n}","target":1,"code_token_length":1369,"total_token_length":1605,"max_tokens_setting":2048} +{"idx":387828,"func":"png_set_filter(png_structrp png_ptr, int method, int filters)\n{\n png_debug(1, \"in png_set_filter\");\n\n if (png_ptr == NULL)\n return;\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&\n (method == PNG_INTRAPIXEL_DIFFERENCING))\n method = PNG_FILTER_TYPE_BASE;\n\n#endif\n if (method == PNG_FILTER_TYPE_BASE)\n {\n switch (filters & (PNG_ALL_FILTERS | 0x07))\n {\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n case 5:\n case 6:\n case 7: png_app_error(png_ptr, \"Unknown row filter for method 0\");\n \/* FALL THROUGH *\/\n#endif \/* WRITE_FILTER *\/\n case PNG_FILTER_VALUE_NONE:\n png_ptr->do_filter = PNG_FILTER_NONE; break;\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n case PNG_FILTER_VALUE_SUB:\n png_ptr->do_filter = PNG_FILTER_SUB; break;\n\n case PNG_FILTER_VALUE_UP:\n png_ptr->do_filter = PNG_FILTER_UP; break;\n\n case PNG_FILTER_VALUE_AVG:\n png_ptr->do_filter = PNG_FILTER_AVG; break;\n\n case PNG_FILTER_VALUE_PAETH:\n png_ptr->do_filter = PNG_FILTER_PAETH; break;\n\n default:\n png_ptr->do_filter = (png_byte)filters; break;\n#else\n default:\n png_app_error(png_ptr, \"Unknown row filter for method 0\");\n#endif \/* WRITE_FILTER *\/\n }\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n \/* If we have allocated the row_buf, this means we have already started\n * with the image and we should have allocated all of the filter buffers\n * that have been selected. If prev_row isn't already allocated, then\n * it is too late to start using the filters that need it, since we\n * will be missing the data in the previous row. If an application\n * wants to start and stop using particular filters during compression,\n * it should start out with all of the filters, and then remove them\n * or add them back after the start of compression.\n *\n * NOTE: this is a nasty constraint on the code, because it means that the\n * prev_row buffer must be maintained even if there are currently no\n * 'prev_row' requiring filters active.\n *\/\n if (png_ptr->row_buf != NULL)\n {\n int num_filters;\n png_alloc_size_t buf_size;\n\n \/* Repeat the checks in png_write_start_row; 1 pixel high or wide\n * images cannot benefit from certain filters. If this isn't done here\n * the check below will fire on 1 pixel high images.\n *\/\n if (png_ptr->height == 1)\n filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);\n\n if (png_ptr->width == 1)\n filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);\n\n if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0\n && png_ptr->prev_row == NULL)\n {\n \/* This is the error case, however it is benign - the previous row\n * is not available so the filter can't be used. Just warn here.\n *\/\n png_app_warning(png_ptr,\n \"png_set_filter: UP\/AVG\/PAETH cannot be added after start\");\n filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);\n }\n\n num_filters = 0;\n\n if (filters & PNG_FILTER_SUB)\n num_filters++;\n\n if (filters & PNG_FILTER_UP)\n num_filters++;\n\n if (filters & PNG_FILTER_AVG)\n num_filters++;\n\n if (filters & PNG_FILTER_PAETH)\n num_filters++;\n\n \/* Allocate needed row buffers if they have not already been\n * allocated.\n *\/\n buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,\n png_ptr->width) + 1;\n\n if (png_ptr->try_row == NULL)\n png_ptr->try_row = png_voidcast(png_bytep,\n png_malloc(png_ptr, buf_size));\n\n if (num_filters > 1)\n {\n if (png_ptr->tst_row == NULL)\n png_ptr->tst_row = png_voidcast(png_bytep,\n png_malloc(png_ptr, buf_size));\n }\n }\n png_ptr->do_filter = (png_byte)filters;\n#endif\n }\n else\n png_error(png_ptr, \"Unknown custom filter method\");\n}","target":0,"code_token_length":993,"total_token_length":1229,"max_tokens_setting":2048} +{"idx":358343,"func":"static int vmx_vcpu_setup(struct vcpu_vmx *vmx)\n{\n\tu32 host_sysenter_cs, msr_low, msr_high;\n\tu32 junk;\n\tu64 host_pat, tsc_this, tsc_base;\n\tunsigned long a;\n\tstruct descriptor_table dt;\n\tint i;\n\tunsigned long kvm_vmx_return;\n\tu32 exec_control;\n\n\t\/* I\/O *\/\n\tvmcs_write64(IO_BITMAP_A, page_to_phys(vmx_io_bitmap_a));\n\tvmcs_write64(IO_BITMAP_B, page_to_phys(vmx_io_bitmap_b));\n\n\tif (cpu_has_vmx_msr_bitmap())\n\t\tvmcs_write64(MSR_BITMAP, page_to_phys(vmx_msr_bitmap));\n\n\tvmcs_write64(VMCS_LINK_POINTER, -1ull); \/* 22.3.1.5 *\/\n\n\t\/* Control *\/\n\tvmcs_write32(PIN_BASED_VM_EXEC_CONTROL,\n\t\tvmcs_config.pin_based_exec_ctrl);\n\n\texec_control = vmcs_config.cpu_based_exec_ctrl;\n\tif (!vm_need_tpr_shadow(vmx->vcpu.kvm)) {\n\t\texec_control &= ~CPU_BASED_TPR_SHADOW;\n#ifdef CONFIG_X86_64\n\t\texec_control |= CPU_BASED_CR8_STORE_EXITING |\n\t\t\t\tCPU_BASED_CR8_LOAD_EXITING;\n#endif\n\t}\n\tif (!vm_need_ept())\n\t\texec_control |= CPU_BASED_CR3_STORE_EXITING |\n\t\t\t\tCPU_BASED_CR3_LOAD_EXITING |\n\t\t\t\tCPU_BASED_INVLPG_EXITING;\n\tvmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control);\n\n\tif (cpu_has_secondary_exec_ctrls()) {\n\t\texec_control = vmcs_config.cpu_based_2nd_exec_ctrl;\n\t\tif (!vm_need_virtualize_apic_accesses(vmx->vcpu.kvm))\n\t\t\texec_control &=\n\t\t\t\t~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;\n\t\tif (vmx->vpid == 0)\n\t\t\texec_control &= ~SECONDARY_EXEC_ENABLE_VPID;\n\t\tif (!vm_need_ept())\n\t\t\texec_control &= ~SECONDARY_EXEC_ENABLE_EPT;\n\t\tvmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control);\n\t}\n\n\tvmcs_write32(PAGE_FAULT_ERROR_CODE_MASK, !!bypass_guest_pf);\n\tvmcs_write32(PAGE_FAULT_ERROR_CODE_MATCH, !!bypass_guest_pf);\n\tvmcs_write32(CR3_TARGET_COUNT, 0); \/* 22.2.1 *\/\n\n\tvmcs_writel(HOST_CR0, read_cr0()); \/* 22.2.3 *\/\n\tvmcs_writel(HOST_CR4, read_cr4()); \/* 22.2.3, 22.2.5 *\/\n\tvmcs_writel(HOST_CR3, read_cr3()); \/* 22.2.3 FIXME: shadow tables *\/\n\n\tvmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); \/* 22.2.4 *\/\n\tvmcs_write16(HOST_DS_SELECTOR, __KERNEL_DS); \/* 22.2.4 *\/\n\tvmcs_write16(HOST_ES_SELECTOR, __KERNEL_DS); \/* 22.2.4 *\/\n\tvmcs_write16(HOST_FS_SELECTOR, kvm_read_fs()); \/* 22.2.4 *\/\n\tvmcs_write16(HOST_GS_SELECTOR, kvm_read_gs()); \/* 22.2.4 *\/\n\tvmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); \/* 22.2.4 *\/\n#ifdef CONFIG_X86_64\n\trdmsrl(MSR_FS_BASE, a);\n\tvmcs_writel(HOST_FS_BASE, a); \/* 22.2.4 *\/\n\trdmsrl(MSR_GS_BASE, a);\n\tvmcs_writel(HOST_GS_BASE, a); \/* 22.2.4 *\/\n#else\n\tvmcs_writel(HOST_FS_BASE, 0); \/* 22.2.4 *\/\n\tvmcs_writel(HOST_GS_BASE, 0); \/* 22.2.4 *\/\n#endif\n\n\tvmcs_write16(HOST_TR_SELECTOR, GDT_ENTRY_TSS*8); \/* 22.2.4 *\/\n\n\tkvm_get_idt(&dt);\n\tvmcs_writel(HOST_IDTR_BASE, dt.base); \/* 22.2.4 *\/\n\n\tasm(\"mov $.Lkvm_vmx_return, %0\" : \"=r\"(kvm_vmx_return));\n\tvmcs_writel(HOST_RIP, kvm_vmx_return); \/* 22.2.5 *\/\n\tvmcs_write32(VM_EXIT_MSR_STORE_COUNT, 0);\n\tvmcs_write32(VM_EXIT_MSR_LOAD_COUNT, 0);\n\tvmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, 0);\n\n\trdmsr(MSR_IA32_SYSENTER_CS, host_sysenter_cs, junk);\n\tvmcs_write32(HOST_IA32_SYSENTER_CS, host_sysenter_cs);\n\trdmsrl(MSR_IA32_SYSENTER_ESP, a);\n\tvmcs_writel(HOST_IA32_SYSENTER_ESP, a); \/* 22.2.3 *\/\n\trdmsrl(MSR_IA32_SYSENTER_EIP, a);\n\tvmcs_writel(HOST_IA32_SYSENTER_EIP, a); \/* 22.2.3 *\/\n\n\tif (vmcs_config.vmexit_ctrl & VM_EXIT_LOAD_IA32_PAT) {\n\t\trdmsr(MSR_IA32_CR_PAT, msr_low, msr_high);\n\t\thost_pat = msr_low | ((u64) msr_high << 32);\n\t\tvmcs_write64(HOST_IA32_PAT, host_pat);\n\t}\n\tif (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {\n\t\trdmsr(MSR_IA32_CR_PAT, msr_low, msr_high);\n\t\thost_pat = msr_low | ((u64) msr_high << 32);\n\t\t\/* Write the default value follow host pat *\/\n\t\tvmcs_write64(GUEST_IA32_PAT, host_pat);\n\t\t\/* Keep arch.pat sync with GUEST_IA32_PAT *\/\n\t\tvmx->vcpu.arch.pat = host_pat;\n\t}\n\n\tfor (i = 0; i < NR_VMX_MSR; ++i) {\n\t\tu32 index = vmx_msr_index[i];\n\t\tu32 data_low, data_high;\n\t\tu64 data;\n\t\tint j = vmx->nmsrs;\n\n\t\tif (rdmsr_safe(index, &data_low, &data_high) < 0)\n\t\t\tcontinue;\n\t\tif (wrmsr_safe(index, data_low, data_high) < 0)\n\t\t\tcontinue;\n\t\tdata = data_low | ((u64)data_high << 32);\n\t\tvmx->host_msrs[j].index = index;\n\t\tvmx->host_msrs[j].reserved = 0;\n\t\tvmx->host_msrs[j].data = data;\n\t\tvmx->guest_msrs[j] = vmx->host_msrs[j];\n\t\t++vmx->nmsrs;\n\t}\n\n\tvmcs_write32(VM_EXIT_CONTROLS, vmcs_config.vmexit_ctrl);\n\n\t\/* 22.2.1, 20.8.1 *\/\n\tvmcs_write32(VM_ENTRY_CONTROLS, vmcs_config.vmentry_ctrl);\n\n\tvmcs_writel(CR0_GUEST_HOST_MASK, ~0UL);\n\tvmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK);\n\n\ttsc_base = vmx->vcpu.kvm->arch.vm_init_tsc;\n\trdtscll(tsc_this);\n\tif (tsc_this < vmx->vcpu.kvm->arch.vm_init_tsc)\n\t\ttsc_base = tsc_this;\n\n\tguest_write_tsc(0, tsc_base);\n\n\treturn 0;\n}","target":0,"code_token_length":1700,"total_token_length":1936,"max_tokens_setting":2048} +{"idx":463920,"func":"static CURLcode bearssl_connect_common(struct Curl_easy *data,\n struct connectdata *conn,\n int sockindex,\n bool nonblocking,\n bool *done)\n{\n CURLcode ret;\n struct ssl_connect_data *connssl = &conn->ssl[sockindex];\n curl_socket_t sockfd = conn->sock[sockindex];\n timediff_t timeout_ms;\n int what;\n\n \/* check if the connection has already been established *\/\n if(ssl_connection_complete == connssl->state) {\n *done = TRUE;\n return CURLE_OK;\n }\n\n if(ssl_connect_1 == connssl->connecting_state) {\n ret = bearssl_connect_step1(data, conn, sockindex);\n if(ret)\n return ret;\n }\n\n while(ssl_connect_2 == connssl->connecting_state ||\n ssl_connect_2_reading == connssl->connecting_state ||\n ssl_connect_2_writing == connssl->connecting_state) {\n \/* check allowed time left *\/\n timeout_ms = Curl_timeleft(data, NULL, TRUE);\n\n if(timeout_ms < 0) {\n \/* no need to continue if time already is up *\/\n failf(data, \"SSL connection timeout\");\n return CURLE_OPERATION_TIMEDOUT;\n }\n\n \/* if ssl is expecting something, check if it's available. *\/\n if(ssl_connect_2_reading == connssl->connecting_state ||\n ssl_connect_2_writing == connssl->connecting_state) {\n\n curl_socket_t writefd = ssl_connect_2_writing ==\n connssl->connecting_state?sockfd:CURL_SOCKET_BAD;\n curl_socket_t readfd = ssl_connect_2_reading ==\n connssl->connecting_state?sockfd:CURL_SOCKET_BAD;\n\n what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,\n nonblocking?0:timeout_ms);\n if(what < 0) {\n \/* fatal error *\/\n failf(data, \"select\/poll on SSL socket, errno: %d\", SOCKERRNO);\n return CURLE_SSL_CONNECT_ERROR;\n }\n else if(0 == what) {\n if(nonblocking) {\n *done = FALSE;\n return CURLE_OK;\n }\n else {\n \/* timeout *\/\n failf(data, \"SSL connection timeout\");\n return CURLE_OPERATION_TIMEDOUT;\n }\n }\n \/* socket is readable or writable *\/\n }\n\n \/* Run transaction, and return to the caller if it failed or if this\n * connection is done nonblocking and this loop would execute again. This\n * permits the owner of a multi handle to abort a connection attempt\n * before step2 has completed while ensuring that a client using select()\n * or epoll() will always have a valid fdset to wait on.\n *\/\n ret = bearssl_connect_step2(data, conn, sockindex);\n if(ret || (nonblocking &&\n (ssl_connect_2 == connssl->connecting_state ||\n ssl_connect_2_reading == connssl->connecting_state ||\n ssl_connect_2_writing == connssl->connecting_state)))\n return ret;\n }\n\n if(ssl_connect_3 == connssl->connecting_state) {\n ret = bearssl_connect_step3(data, conn, sockindex);\n if(ret)\n return ret;\n }\n\n if(ssl_connect_done == connssl->connecting_state) {\n connssl->state = ssl_connection_complete;\n conn->recv[sockindex] = bearssl_recv;\n conn->send[sockindex] = bearssl_send;\n *done = TRUE;\n }\n else\n *done = FALSE;\n\n \/* Reset our connect state machine *\/\n connssl->connecting_state = ssl_connect_1;\n\n return CURLE_OK;\n}","target":0,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048} +{"idx":501392,"func":"static int FUZ_mallocTests_internal(unsigned seed, double compressibility, unsigned part,\n void* inBuffer, size_t inSize, void* outBuffer, size_t outSize)\n{\n \/* test only played in verbose mode, as they are long *\/\n if (g_displayLevel<3) return 0;\n\n \/* Create compressible noise *\/\n if (!inBuffer || !outBuffer) {\n DISPLAY(\"Not enough memory, aborting\\n\");\n exit(1);\n }\n RDG_genBuffer(inBuffer, inSize, compressibility, 0. \/*auto*\/, seed);\n\n \/* simple compression tests *\/\n if (part <= 1)\n { int compressionLevel;\n for (compressionLevel=1; compressionLevel<=6; compressionLevel++) {\n mallocCounter_t malcount = INIT_MALLOC_COUNTER;\n ZSTD_customMem const cMem = { FUZ_mallocDebug, FUZ_freeDebug, &malcount };\n ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(cMem);\n CHECK_Z( ZSTD_compressCCtx(cctx, outBuffer, outSize, inBuffer, inSize, compressionLevel) );\n ZSTD_freeCCtx(cctx);\n DISPLAYLEVEL(3, \"compressCCtx level %i : \", compressionLevel);\n FUZ_displayMallocStats(malcount);\n } }\n\n \/* streaming compression tests *\/\n if (part <= 2)\n { int compressionLevel;\n for (compressionLevel=1; compressionLevel<=6; compressionLevel++) {\n mallocCounter_t malcount = INIT_MALLOC_COUNTER;\n ZSTD_customMem const cMem = { FUZ_mallocDebug, FUZ_freeDebug, &malcount };\n ZSTD_CCtx* const cstream = ZSTD_createCStream_advanced(cMem);\n ZSTD_outBuffer out = { outBuffer, outSize, 0 };\n ZSTD_inBuffer in = { inBuffer, inSize, 0 };\n CHECK_Z( ZSTD_initCStream(cstream, compressionLevel) );\n CHECK_Z( ZSTD_compressStream(cstream, &out, &in) );\n CHECK_Z( ZSTD_endStream(cstream, &out) );\n ZSTD_freeCStream(cstream);\n DISPLAYLEVEL(3, \"compressStream level %i : \", compressionLevel);\n FUZ_displayMallocStats(malcount);\n } }\n\n \/* advanced MT API test *\/\n if (part <= 3)\n { U32 nbThreads;\n for (nbThreads=1; nbThreads<=4; nbThreads++) {\n int compressionLevel;\n for (compressionLevel=1; compressionLevel<=6; compressionLevel++) {\n mallocCounter_t malcount = INIT_MALLOC_COUNTER;\n ZSTD_customMem const cMem = { FUZ_mallocDebug, FUZ_freeDebug, &malcount };\n ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(cMem);\n ZSTD_outBuffer out = { outBuffer, outSize, 0 };\n ZSTD_inBuffer in = { inBuffer, inSize, 0 };\n CHECK_Z( ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, (U32)compressionLevel) );\n CHECK_Z( ZSTD_CCtx_setParameter(cctx, ZSTD_p_nbWorkers, nbThreads) );\n while ( ZSTD_compress_generic(cctx, &out, &in, ZSTD_e_end) ) {}\n ZSTD_freeCCtx(cctx);\n DISPLAYLEVEL(3, \"compress_generic,-T%u,end level %i : \",\n nbThreads, compressionLevel);\n FUZ_displayMallocStats(malcount);\n } } }\n\n \/* advanced MT streaming API test *\/\n if (part <= 4)\n { U32 nbThreads;\n for (nbThreads=1; nbThreads<=4; nbThreads++) {\n int compressionLevel;\n for (compressionLevel=1; compressionLevel<=6; compressionLevel++) {\n mallocCounter_t malcount = INIT_MALLOC_COUNTER;\n ZSTD_customMem const cMem = { FUZ_mallocDebug, FUZ_freeDebug, &malcount };\n ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(cMem);\n ZSTD_outBuffer out = { outBuffer, outSize, 0 };\n ZSTD_inBuffer in = { inBuffer, inSize, 0 };\n CHECK_Z( ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, (U32)compressionLevel) );\n CHECK_Z( ZSTD_CCtx_setParameter(cctx, ZSTD_p_nbWorkers, nbThreads) );\n CHECK_Z( ZSTD_compress_generic(cctx, &out, &in, ZSTD_e_continue) );\n while ( ZSTD_compress_generic(cctx, &out, &in, ZSTD_e_end) ) {}\n ZSTD_freeCCtx(cctx);\n DISPLAYLEVEL(3, \"compress_generic,-T%u,continue level %i : \",\n nbThreads, compressionLevel);\n FUZ_displayMallocStats(malcount);\n } } }\n\n return 0;\n}","target":0,"code_token_length":1085,"total_token_length":1321,"max_tokens_setting":2048} +{"idx":474484,"func":"static int hdr_validate_segments(struct crypt_device *cd, json_object *hdr_jobj)\n{\n\tjson_object *jobj_segments, *jobj_digests, *jobj_offset, *jobj_size, *jobj_type, *jobj_flags, *jobj;\n\tuint64_t offset, size;\n\tint i, r, count, first_backup = -1;\n\tstruct interval *intervals = NULL;\n\n\tif (!json_object_object_get_ex(hdr_jobj, \"segments\", &jobj_segments)) {\n\t\tlog_dbg(cd, \"Missing segments section.\");\n\t\treturn 1;\n\t}\n\n\tcount = json_object_object_length(jobj_segments);\n\tif (count < 1) {\n\t\tlog_dbg(cd, \"Empty segments section.\");\n\t\treturn 1;\n\t}\n\n\t\/* digests should already be validated *\/\n\tif (!json_object_object_get_ex(hdr_jobj, \"digests\", &jobj_digests))\n\t\treturn 1;\n\n\tjson_object_object_foreach(jobj_segments, key, val) {\n\t\tif (!numbered(cd, \"Segment\", key))\n\t\t\treturn 1;\n\n\t\t\/* those fields are mandatory for all segment types *\/\n\t\tif (!(jobj_type = json_contains(cd, val, key, \"Segment\", \"type\", json_type_string)) ||\n\t\t !(jobj_offset = json_contains(cd, val, key, \"Segment\", \"offset\", json_type_string)) ||\n\t\t !(jobj_size = json_contains(cd, val, key, \"Segment\", \"size\", json_type_string)))\n\t\t\treturn 1;\n\n\t\tif (!numbered(cd, \"offset\", json_object_get_string(jobj_offset)) ||\n\t\t !json_str_to_uint64(jobj_offset, &offset))\n\t\t\treturn 1;\n\n\t\t\/* size \"dynamic\" means whole device starting at 'offset' *\/\n\t\tif (strcmp(json_object_get_string(jobj_size), \"dynamic\")) {\n\t\t\tif (!numbered(cd, \"size\", json_object_get_string(jobj_size)) ||\n\t\t\t !json_str_to_uint64(jobj_size, &size) || !size)\n\t\t\t\treturn 1;\n\t\t} else\n\t\t\tsize = 0;\n\n\t\t\/* all device-mapper devices are aligned to 512 sector size *\/\n\t\tif (MISALIGNED_512(offset)) {\n\t\t\tlog_dbg(cd, \"Offset field has to be aligned to sector size: %\" PRIu32, SECTOR_SIZE);\n\t\t\treturn 1;\n\t\t}\n\t\tif (MISALIGNED_512(size)) {\n\t\t\tlog_dbg(cd, \"Size field has to be aligned to sector size: %\" PRIu32, SECTOR_SIZE);\n\t\t\treturn 1;\n\t\t}\n\n\t\t\/* flags array is optional and must contain strings *\/\n\t\tif (json_object_object_get_ex(val, \"flags\", NULL)) {\n\t\t\tif (!(jobj_flags = json_contains(cd, val, key, \"Segment\", \"flags\", json_type_array)))\n\t\t\t\treturn 1;\n\t\t\tfor (i = 0; i < (int) json_object_array_length(jobj_flags); i++)\n\t\t\t\tif (!json_object_is_type(json_object_array_get_idx(jobj_flags, i), json_type_string))\n\t\t\t\t\treturn 1;\n\t\t}\n\n\t\ti = atoi(key);\n\t\tif (json_segment_is_backup(val)) {\n\t\t\tif (first_backup < 0 || i < first_backup)\n\t\t\t\tfirst_backup = i;\n\t\t} else {\n\t\t\tif ((first_backup >= 0) && i >= first_backup) {\n\t\t\t\tlog_dbg(cd, \"Regular segment at %d is behind backup segment at %d\", i, first_backup);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\t\/* crypt *\/\n\t\tif (!strcmp(json_object_get_string(jobj_type), \"crypt\") &&\n\t\t hdr_validate_crypt_segment(cd, val, key, jobj_digests, offset, size))\n\t\t\treturn 1;\n\t}\n\n\tif (first_backup == 0) {\n\t\tlog_dbg(cd, \"No regular segment.\");\n\t\treturn 1;\n\t}\n\n\t\/* avoid needlessly large allocation when first backup segment is invalid *\/\n\tif (first_backup >= count) {\n\t\tlog_dbg(cd, \"Gap between last regular segment and backup segment at key %d.\", first_backup);\n\t\treturn 1;\n\t}\n\n\tif (first_backup < 0)\n\t\tfirst_backup = count;\n\n\tif ((size_t)first_backup < SIZE_MAX \/ sizeof(*intervals))\n\t\tintervals = malloc(first_backup * sizeof(*intervals));\n\n\tif (!intervals) {\n\t\tlog_dbg(cd, \"Not enough memory.\");\n\t\treturn 1;\n\t}\n\n\tfor (i = 0; i < first_backup; i++) {\n\t\tjobj = json_segments_get_segment(jobj_segments, i);\n\t\tif (!jobj) {\n\t\t\tlog_dbg(cd, \"Gap at key %d in segments object.\", i);\n\t\t\tfree(intervals);\n\t\t\treturn 1;\n\t\t}\n\t\tintervals[i].offset = json_segment_get_offset(jobj, 0);\n\t\tintervals[i].length = json_segment_get_size(jobj, 0) ?: UINT64_MAX;\n\t}\n\n\tr = !validate_segment_intervals(cd, first_backup, intervals);\n\tfree(intervals);\n\n\tif (r)\n\t\treturn 1;\n\n\tfor (; i < count; i++) {\n\t\tif (!json_segments_get_segment(jobj_segments, i)) {\n\t\t\tlog_dbg(cd, \"Gap at key %d in segments object.\", i);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":1142,"total_token_length":1378,"max_tokens_setting":2048} +{"idx":489917,"func":"static int piv_find_aid(sc_card_t * card, sc_file_t *aid_file)\n{\n\tsc_apdu_t apdu;\n\tu8 rbuf[SC_MAX_APDU_BUFFER_SIZE];\n\tint r,i;\n\tconst u8 *tag;\n\tsize_t taglen;\n\tconst u8 *pix;\n\tsize_t pixlen;\n\tsize_t resplen = sizeof(rbuf);\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);\n\n\t\/* first see if the default application will return a template\n\t * that we know about.\n\t *\/\n\n\tr = piv_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, rbuf, &resplen);\n\tif (r >= 0 && resplen > 2 ) {\n\t\ttag = sc_asn1_find_tag(card->ctx, rbuf, resplen, 0x61, &taglen);\n\t\tif (tag != NULL) {\n\t\t\tpix = sc_asn1_find_tag(card->ctx, tag, taglen, 0x4F, &pixlen);\n\t\t\tif (pix != NULL ) {\n\t\t\t\tsc_log(card->ctx, \"found PIX\");\n\n\t\t\t\t\/* early cards returned full AID, rather then just the pix *\/\n\t\t\t\tfor (i = 0; piv_aids[i].len_long != 0; i++) {\n\t\t\t\t\tif ((pixlen >= 6 && memcmp(pix, piv_aids[i].value + 5,\n\t\t\t\t\t\t\t\t\tpiv_aids[i].len_long - 5 ) == 0)\n\t\t\t\t\t\t || ((pixlen >= piv_aids[i].len_short &&\n\t\t\t\t\t\t\tmemcmp(pix, piv_aids[i].value,\n\t\t\t\t\t\t\tpiv_aids[i].len_short) == 0))) {\n\t\t\t\t\t\tif (card->type > SC_CARD_TYPE_PIV_II_BASE &&\n\t\t\t\t\t\t\tcard->type < SC_CARD_TYPE_PIV_II_BASE+1000 &&\n\t\t\t\t\t\t\tcard->type == piv_aids[i].enumtag) {\n\t\t\t\t\t\t\tLOG_FUNC_RETURN(card->ctx, i);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tLOG_FUNC_RETURN(card->ctx, i);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* for testing, we can force the use of a specific AID\n\t * by using the card= parameter in conf file\n\t *\/\n\tfor (i = 0; piv_aids[i].len_long != 0; i++) {\n\t\tif (card->type > SC_CARD_TYPE_PIV_II_BASE &&\n\t\t\tcard->type < SC_CARD_TYPE_PIV_II_BASE+1000 &&\n\t\t\tcard->type != piv_aids[i].enumtag) {\n\t\t\t\tcontinue;\n\t\t}\n\t\tsc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x04, 0x00);\n\t\tapdu.lc = piv_aids[i].len_long;\n\t\tapdu.data = piv_aids[i].value;\n\n\t\tapdu.datalen = apdu.lc;\n\t\tapdu.resp = rbuf;\n\t\tapdu.resplen = sizeof(rbuf);\n\t\tapdu.le = 256;\n\n\t\tr = sc_transmit_apdu(card, &apdu);\n\t\tLOG_TEST_RET(card->ctx, r, \"APDU transmit failed\");\n\n\t\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\t\tif (r) {\n\t\t\tif (card->type != 0 && card->type == piv_aids[i].enumtag)\n\t\t\t\tLOG_FUNC_RETURN(card->ctx, (r < 0)? r: i);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( apdu.resplen == 0 && r == 0) {\n\t\t\t\/* could be the MSU card *\/\n\t\t\tcontinue; \/* other cards will return a FCI *\/\n\t\t}\n\n\t\tif (apdu.resp[0] != 0x6f || apdu.resp[1] > apdu.resplen - 2 )\n\t\t\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NO_CARD_SUPPORT);\n\n\t\tcard->ops->process_fci(card, aid_file, apdu.resp+2, apdu.resp[1]);\n\n\t\tLOG_FUNC_RETURN(card->ctx, i);\n\t}\n\n\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT);\n}","target":0,"code_token_length":906,"total_token_length":1142,"max_tokens_setting":2048} +{"idx":342070,"func":"static void pflash_cfi02_realize(DeviceState *dev, Error **errp)\n\n{\n\n pflash_t *pfl = CFI_PFLASH02(dev);\n\n uint32_t chip_len;\n\n int ret;\n\n Error *local_err = NULL;\n\n\n\n chip_len = pfl->sector_len * pfl->nb_blocs;\n\n \/* XXX: to be fixed *\/\n\n#if 0\n\n if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) &&\n\n total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024))\n\n return NULL;\n\n#endif\n\n\n\n memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl), pfl->be ?\n\n &pflash_cfi02_ops_be : &pflash_cfi02_ops_le,\n\n pfl, pfl->name, chip_len, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n return;\n\n }\n\n\n\n vmstate_register_ram(&pfl->orig_mem, DEVICE(pfl));\n\n pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem);\n\n pfl->chip_len = chip_len;\n\n if (pfl->bs) {\n\n \/* read the initial flash content *\/\n\n ret = bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);\n\n if (ret < 0) {\n\n vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));\n\n error_setg(errp, \"failed to read the initial flash content\");\n\n return;\n\n }\n\n }\n\n\n\n pflash_setup_mappings(pfl);\n\n pfl->rom_mode = 1;\n\n sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);\n\n\n\n if (pfl->bs) {\n\n pfl->ro = bdrv_is_read_only(pfl->bs);\n\n } else {\n\n pfl->ro = 0;\n\n }\n\n\n\n pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);\n\n pfl->wcycle = 0;\n\n pfl->cmd = 0;\n\n pfl->status = 0;\n\n \/* Hardcoded CFI table (mostly from SG29 Spansion flash) *\/\n\n pfl->cfi_len = 0x52;\n\n \/* Standard \"QRY\" string *\/\n\n pfl->cfi_table[0x10] = 'Q';\n\n pfl->cfi_table[0x11] = 'R';\n\n pfl->cfi_table[0x12] = 'Y';\n\n \/* Command set (AMD\/Fujitsu) *\/\n\n pfl->cfi_table[0x13] = 0x02;\n\n pfl->cfi_table[0x14] = 0x00;\n\n \/* Primary extended table address *\/\n\n pfl->cfi_table[0x15] = 0x31;\n\n pfl->cfi_table[0x16] = 0x00;\n\n \/* Alternate command set (none) *\/\n\n pfl->cfi_table[0x17] = 0x00;\n\n pfl->cfi_table[0x18] = 0x00;\n\n \/* Alternate extended table (none) *\/\n\n pfl->cfi_table[0x19] = 0x00;\n\n pfl->cfi_table[0x1A] = 0x00;\n\n \/* Vcc min *\/\n\n pfl->cfi_table[0x1B] = 0x27;\n\n \/* Vcc max *\/\n\n pfl->cfi_table[0x1C] = 0x36;\n\n \/* Vpp min (no Vpp pin) *\/\n\n pfl->cfi_table[0x1D] = 0x00;\n\n \/* Vpp max (no Vpp pin) *\/\n\n pfl->cfi_table[0x1E] = 0x00;\n\n \/* Reserved *\/\n\n pfl->cfi_table[0x1F] = 0x07;\n\n \/* Timeout for min size buffer write (NA) *\/\n\n pfl->cfi_table[0x20] = 0x00;\n\n \/* Typical timeout for block erase (512 ms) *\/\n\n pfl->cfi_table[0x21] = 0x09;\n\n \/* Typical timeout for full chip erase (4096 ms) *\/\n\n pfl->cfi_table[0x22] = 0x0C;\n\n \/* Reserved *\/\n\n pfl->cfi_table[0x23] = 0x01;\n\n \/* Max timeout for buffer write (NA) *\/\n\n pfl->cfi_table[0x24] = 0x00;\n\n \/* Max timeout for block erase *\/\n\n pfl->cfi_table[0x25] = 0x0A;\n\n \/* Max timeout for chip erase *\/\n\n pfl->cfi_table[0x26] = 0x0D;\n\n \/* Device size *\/\n\n pfl->cfi_table[0x27] = ctz32(chip_len);\n\n \/* Flash device interface (8 & 16 bits) *\/\n\n pfl->cfi_table[0x28] = 0x02;\n\n pfl->cfi_table[0x29] = 0x00;\n\n \/* Max number of bytes in multi-bytes write *\/\n\n \/* XXX: disable buffered write as it's not supported *\/\n\n \/\/ pfl->cfi_table[0x2A] = 0x05;\n\n pfl->cfi_table[0x2A] = 0x00;\n\n pfl->cfi_table[0x2B] = 0x00;\n\n \/* Number of erase block regions (uniform) *\/\n\n pfl->cfi_table[0x2C] = 0x01;\n\n \/* Erase block region 1 *\/\n\n pfl->cfi_table[0x2D] = pfl->nb_blocs - 1;\n\n pfl->cfi_table[0x2E] = (pfl->nb_blocs - 1) >> 8;\n\n pfl->cfi_table[0x2F] = pfl->sector_len >> 8;\n\n pfl->cfi_table[0x30] = pfl->sector_len >> 16;\n\n\n\n \/* Extended *\/\n\n pfl->cfi_table[0x31] = 'P';\n\n pfl->cfi_table[0x32] = 'R';\n\n pfl->cfi_table[0x33] = 'I';\n\n\n\n pfl->cfi_table[0x34] = '1';\n\n pfl->cfi_table[0x35] = '0';\n\n\n\n pfl->cfi_table[0x36] = 0x00;\n\n pfl->cfi_table[0x37] = 0x00;\n\n pfl->cfi_table[0x38] = 0x00;\n\n pfl->cfi_table[0x39] = 0x00;\n\n\n\n pfl->cfi_table[0x3a] = 0x00;\n\n\n\n pfl->cfi_table[0x3b] = 0x00;\n\n pfl->cfi_table[0x3c] = 0x00;\n\n}\n","target":0,"code_token_length":1692,"total_token_length":1928,"max_tokens_setting":2048} +{"idx":378857,"func":"static void wsgi_manage_process(int reason, void *data, apr_wait_t status)\n{\n WSGIDaemonProcess *daemon = data;\n\n switch (reason) {\n\n \/* Child daemon process has died. *\/\n\n case APR_OC_REASON_DEATH: {\n int mpm_state;\n int stopping;\n\n \/*\n * Determine if Apache is being shutdown or not and\n * if it is not being shutdown, we will need to\n * restart the child daemon process that has died.\n * If MPM doesn't support query assume that child\n * daemon process shouldn't be restarted. Both\n * prefork and worker MPMs support this query so\n * should always be okay.\n *\/\n\n stopping = 1;\n\n if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state) == APR_SUCCESS\n && mpm_state != AP_MPMQ_STOPPING) {\n stopping = 0;\n }\n\n if (!stopping) {\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' has died, deregister and \"\n \"restart it.\", daemon->process.pid,\n daemon->group->name);\n\n if (WIFEXITED(status)) {\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' terminated normally, exit code %d\",\n daemon->process.pid, daemon->group->name,\n WEXITSTATUS(status));\n }\n else if (WIFSIGNALED(status)) {\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' terminated by signal %d\",\n daemon->process.pid, daemon->group->name,\n WTERMSIG(status));\n }\n }\n else {\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' has died but server is \"\n \"being stopped, deregister it.\",\n daemon->process.pid, daemon->group->name);\n }\n\n \/* Deregister existing process so we stop watching it. *\/\n\n apr_proc_other_child_unregister(daemon);\n\n \/* Now restart process if not shutting down. *\/\n\n if (!stopping)\n wsgi_start_process(wsgi_parent_pool, daemon);\n\n break;\n }\n\n \/* Apache is being restarted or shutdown. *\/\n\n case APR_OC_REASON_RESTART: {\n\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' to be deregistered, as server is \"\n \"restarting or being shutdown.\",\n daemon->process.pid, daemon->group->name);\n\n \/* Deregister existing process so we stop watching it. *\/\n\n apr_proc_other_child_unregister(daemon);\n\n break;\n }\n\n \/* Child daemon process vanished. *\/\n\n case APR_OC_REASON_LOST: {\n\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' appears to have been lost, \"\n \"deregister and restart it.\",\n daemon->process.pid, daemon->group->name);\n\n \/* Deregister existing process so we stop watching it. *\/\n\n apr_proc_other_child_unregister(daemon);\n\n \/* Restart the child daemon process that has died. *\/\n\n wsgi_start_process(wsgi_parent_pool, daemon);\n\n break;\n }\n\n \/* Call to unregister the process. *\/\n\n case APR_OC_REASON_UNREGISTER: {\n\n \/* Nothing to do at present. *\/\n\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' has been deregistered and will \"\n \"no longer be monitored.\", daemon->process.pid,\n daemon->group->name);\n\n break;\n }\n\n default: {\n ap_log_error(APLOG_MARK, APLOG_INFO, 0,\n wsgi_server, \"mod_wsgi (pid=%d): \"\n \"Process '%s' targeted by unexpected event %d.\",\n daemon->process.pid, daemon->group->name, reason);\n }\n }\n}","target":0,"code_token_length":953,"total_token_length":1189,"max_tokens_setting":2048} +{"idx":25029,"func":"static int decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {\n AVFrame * frame = data ;\n const uint8_t * buf = avpkt -> data ;\n int buf_size = avpkt -> size ;\n DxaDecContext * const c = avctx -> priv_data ;\n uint8_t * outptr , * srcptr , * tmpptr ;\n unsigned long dsize ;\n int i , j , compr , ret ;\n int stride ;\n int orig_buf_size = buf_size ;\n int pc = 0 ;\n if ( buf [ 0 ] == 'C' && buf [ 1 ] == 'M' && buf [ 2 ] == 'A' && buf [ 3 ] == 'P' ) {\n int r , g , b ;\n buf += 4 ;\n for ( i = 0 ;\n i < 256 ;\n i ++ ) {\n r = * buf ++ ;\n g = * buf ++ ;\n b = * buf ++ ;\n c -> pal [ i ] = ( r << 16 ) | ( g << 8 ) | b ;\n }\n pc = 1 ;\n buf_size -= 768 + 4 ;\n }\n if ( ( ret = ff_get_buffer ( avctx , frame , AV_GET_BUFFER_FLAG_REF ) ) < 0 ) {\n av_log ( avctx , AV_LOG_ERROR , \"get_buffer() failed\\n\" ) ;\n return ret ;\n }\n memcpy ( frame -> data [ 1 ] , c -> pal , AVPALETTE_SIZE ) ;\n frame -> palette_has_changed = pc ;\n outptr = frame -> data [ 0 ] ;\n srcptr = c -> decomp_buf ;\n tmpptr = c -> prev . data [ 0 ] ;\n stride = frame -> linesize [ 0 ] ;\n if ( buf [ 0 ] == 'N' && buf [ 1 ] == 'U' && buf [ 2 ] == 'L' && buf [ 3 ] == 'L' ) compr = - 1 ;\n else compr = buf [ 4 ] ;\n dsize = c -> dsize ;\n if ( ( compr != 4 && compr != - 1 ) && uncompress ( c -> decomp_buf , & dsize , buf + 9 , buf_size - 9 ) != Z_OK ) {\n av_log ( avctx , AV_LOG_ERROR , \"Uncompress failed!\\n\" ) ;\n return AVERROR_UNKNOWN ;\n }\n switch ( compr ) {\n case - 1 : frame -> key_frame = 0 ;\n frame -> pict_type = AV_PICTURE_TYPE_P ;\n if ( c -> prev . data [ 0 ] ) memcpy ( frame -> data [ 0 ] , c -> prev . data [ 0 ] , frame -> linesize [ 0 ] * avctx -> height ) ;\n else {\n memset ( frame -> data [ 0 ] , 0 , frame -> linesize [ 0 ] * avctx -> height ) ;\n frame -> key_frame = 1 ;\n frame -> pict_type = AV_PICTURE_TYPE_I ;\n }\n break ;\n case 2 : case 3 : case 4 : case 5 : frame -> key_frame = ! ( compr & 1 ) ;\n frame -> pict_type = ( compr & 1 ) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I ;\n for ( j = 0 ;\n j < avctx -> height ;\n j ++ ) {\n if ( compr & 1 ) {\n for ( i = 0 ;\n i < avctx -> width ;\n i ++ ) outptr [ i ] = srcptr [ i ] ^ tmpptr [ i ] ;\n tmpptr += stride ;\n }\n else memcpy ( outptr , srcptr , avctx -> width ) ;\n outptr += stride ;\n srcptr += avctx -> width ;\n }\n break ;\n case 12 : case 13 : frame -> key_frame = 0 ;\n frame -> pict_type = AV_PICTURE_TYPE_P ;\n decode_13 ( avctx , c , frame -> data [ 0 ] , frame -> linesize [ 0 ] , srcptr , c -> prev . data [ 0 ] ) ;\n break ;\n default : av_log ( avctx , AV_LOG_ERROR , \"Unknown\/unsupported compression type %d\\n\" , buf [ 4 ] ) ;\n return AVERROR_INVALIDDATA ;\n }\n av_frame_unref ( & c -> prev ) ;\n if ( ( ret = av_frame_ref ( & c -> prev , frame ) ) < 0 ) return ret ;\n * got_frame = 1 ;\n return orig_buf_size ;\n }","target":0,"code_token_length":938,"total_token_length":1174,"max_tokens_setting":2048} +{"idx":63151,"func":"TfLiteStatus LessEval(TfLiteContext* context, TfLiteNode* node) {\n TFLITE_DCHECK(node->user_data != nullptr);\n const OpData* data = static_cast(node->user_data);\n\n const TfLiteEvalTensor* input1 =\n tflite::micro::GetEvalInput(context, node, kInputTensor1);\n const TfLiteEvalTensor* input2 =\n tflite::micro::GetEvalInput(context, node, kInputTensor2);\n TfLiteEvalTensor* output =\n tflite::micro::GetEvalOutput(context, node, kOutputTensor);\n\n RuntimeShape input1_shape = tflite::micro::GetTensorShape(input1);\n RuntimeShape input2_shape = tflite::micro::GetTensorShape(input2);\n RuntimeShape output_shape = tflite::micro::GetTensorShape(output);\n bool* output_data = tflite::micro::GetTensorData(output);\n\n bool requires_broadcast = !tflite::micro::HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteFloat32:\n requires_broadcast\n ? reference_ops::Broadcast4DSlowLessNoScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data)\n : reference_ops::LessNoScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data);\n break;\n case kTfLiteInt32:\n requires_broadcast\n ? reference_ops::Broadcast4DSlowLessNoScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data)\n : reference_ops::LessNoScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data);\n break;\n case kTfLiteInt64:\n requires_broadcast\n ? reference_ops::Broadcast4DSlowLessNoScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data)\n : reference_ops::LessNoScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data);\n break;\n case kTfLiteUInt8:\n requires_broadcast\n ? reference_ops::Broadcast4DSlowLessWithScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data)\n : reference_ops::LessWithScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data);\n break;\n case kTfLiteInt8:\n requires_broadcast\n ? reference_ops::Broadcast4DSlowLessWithScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data)\n : reference_ops::LessWithScaling(\n data->params, input1_shape,\n tflite::micro::GetTensorData(input1), input2_shape,\n tflite::micro::GetTensorData(input2), output_shape,\n output_data);\n break;\n default:\n TF_LITE_KERNEL_LOG(context, \"Type %s (%d) not supported.\",\n TfLiteTypeGetName(input1->type), input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}","target":0,"code_token_length":1027,"total_token_length":1263,"max_tokens_setting":2048} +{"idx":137712,"func":"void Transform::interpolate_bilinear( RawTile& in, unsigned int resampled_width, unsigned int resampled_height ){\n\n \/\/ Pointer to input buffer\n unsigned char *input = (unsigned char*) in.data;\n\n int channels = in.channels;\n unsigned int width = in.width;\n unsigned int height = in.height;\n\n \/\/ Define a max index position on the input buffer\n unsigned long max = ( (width*height) - 1 ) * channels;\n\n \/\/ Create new buffer and pointer for our output - make sure we have enough digits via unsigned long long\n unsigned char *output = new unsigned char[(unsigned long long)resampled_width*resampled_height*channels];\n\n \/\/ Calculate our scale\n float xscale = (float)(width) \/ (float)resampled_width;\n float yscale = (float)(height) \/ (float)resampled_height;\n\n\n \/\/ Do not parallelize for small images (256x256 pixels) as this can be slower that single threaded\n#if defined(__ICC) || defined(__INTEL_COMPILER)\n#pragma ivdep\n#elif defined(_OPENMP)\n#pragma omp parallel for if( resampled_width*resampled_height > PARALLEL_THRESHOLD )\n#endif\n for( unsigned int j=0; jgss_init_sec_context == NULL)\n\treturn (GSS_S_UNAVAILABLE);\n\n \/*\n * If target_name is mechanism_specific, then it must match the\n * mech_type that we're about to use. Otherwise, do an import on\n * the external_name form of the target name.\n *\/\n if (union_name->mech_type &&\n\tg_OID_equal(union_name->mech_type, selected_mech)) {\n\tinternal_name = union_name->mech_name;\n } else {\n\tif ((status = gssint_import_internal_name(minor_status, selected_mech,\n\t\t\t\t\t\t union_name,\n\t\t\t\t\t\t &internal_name)) != GSS_S_COMPLETE)\n\t return (status);\n }\n\n \/*\n * if context_handle is GSS_C_NO_CONTEXT, allocate a union context\n * descriptor to hold the mech type information as well as the\n * underlying mechanism context handle. Otherwise, cast the\n * value of *context_handle to the union context variable.\n *\/\n\n if(*context_handle == GSS_C_NO_CONTEXT) {\n\tstatus = GSS_S_FAILURE;\n\tunion_ctx_id = (gss_union_ctx_id_t)\n\t malloc(sizeof(gss_union_ctx_id_desc));\n\tif (union_ctx_id == NULL)\n\t goto end;\n\n\tif (generic_gss_copy_oid(&temp_minor_status, selected_mech,\n\t\t\t\t &union_ctx_id->mech_type) != GSS_S_COMPLETE) {\n\t free(union_ctx_id);\n\t goto end;\n\t}\n\n\t\/* copy the supplied context handle *\/\n\tunion_ctx_id->internal_ctx_id = GSS_C_NO_CONTEXT;\n } else\n\tunion_ctx_id = (gss_union_ctx_id_t)*context_handle;\n\n \/*\n * get the appropriate cred handle from the union cred struct.\n * defaults to GSS_C_NO_CREDENTIAL if there is no cred, which will\n * use the default credential.\n *\/\n union_cred = (gss_union_cred_t) claimant_cred_handle;\n input_cred_handle = gssint_get_mechanism_cred(union_cred, selected_mech);\n\n \/*\n * now call the approprate underlying mechanism routine\n *\/\n\n status = mech->gss_init_sec_context(\n\tminor_status,\n\tinput_cred_handle,\n\t&union_ctx_id->internal_ctx_id,\n\tinternal_name,\n\tgssint_get_public_oid(selected_mech),\n\treq_flags,\n\ttime_req,\n\tinput_chan_bindings,\n\tinput_token,\n\tactual_mech_type,\n\toutput_token,\n\tret_flags,\n\ttime_rec);\n\n if (status != GSS_S_COMPLETE && status != GSS_S_CONTINUE_NEEDED) {\n\t\/*\n\t * The spec says the preferred method is to delete all context info on\n\t * the first call to init, and on all subsequent calls make the caller\n\t * responsible for calling gss_delete_sec_context. However, if the\n\t * mechanism decided to delete the internal context, we should also\n\t * delete the union context.\n\t *\/\n\tmap_error(minor_status, mech);\n\tif (union_ctx_id->internal_ctx_id == GSS_C_NO_CONTEXT)\n\t *context_handle = GSS_C_NO_CONTEXT;\n\tif (*context_handle == GSS_C_NO_CONTEXT) {\n\t free(union_ctx_id->mech_type->elements);\n\t free(union_ctx_id->mech_type);\n\t free(union_ctx_id);\n\t}\n } else if (*context_handle == GSS_C_NO_CONTEXT) {\n\tunion_ctx_id->loopback = union_ctx_id;\n\t*context_handle = (gss_ctx_id_t)union_ctx_id;\n }\n\nend:\n if (union_name->mech_name == NULL ||\n\tunion_name->mech_name != internal_name) {\n\t(void) gssint_release_internal_name(&temp_minor_status,\n\t\t\t\t\t selected_mech, &internal_name);\n }\n\n return(status);\n}","target":1,"code_token_length":1254,"total_token_length":1490,"max_tokens_setting":2048} +{"idx":283365,"func":"static uint8_t avrc_proc_far_msg(uint8_t handle, uint8_t label, uint8_t cr,\n BT_HDR** pp_pkt, tAVRC_MSG_VENDOR* p_msg) {\n BT_HDR* p_pkt = *pp_pkt;\n uint8_t* p_data;\n uint8_t drop_code = 0;\n bool buf_overflow = false;\n BT_HDR* p_rsp = NULL;\n BT_HDR* p_cmd = NULL;\n bool req_continue = false;\n BT_HDR* p_pkt_new = NULL;\n uint8_t pkt_type;\n tAVRC_RASM_CB* p_rcb;\n tAVRC_NEXT_CMD avrc_cmd;\n tAVRC_STS status;\n\n p_data = (uint8_t*)(p_pkt + 1) + p_pkt->offset;\n\n \/* Skip over vendor header (ctype, subunit*, opcode, CO_ID) *\/\n p_data += AVRC_VENDOR_HDR_SIZE;\n\n pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;\n AVRC_TRACE_DEBUG(\"pkt_type %d\", pkt_type);\n p_rcb = &avrc_cb.rcb[handle];\n\n \/* check if the message needs to be re-assembled *\/\n if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START) {\n \/* previous fragments need to be dropped, when received another new message\n *\/\n p_rcb->rasm_offset = 0;\n osi_free_and_reset((void**)&p_rcb->p_rmsg);\n }\n\n if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP) {\n \/* not a single response packet - need to re-assemble metadata messages *\/\n if (pkt_type == AVRC_PKT_START) {\n \/* Allocate buffer for re-assembly *\/\n p_rcb->rasm_pdu = *p_data;\n p_rcb->p_rmsg = (BT_HDR*)osi_malloc(BT_DEFAULT_BUFFER_SIZE);\n \/* Copy START packet to buffer for re-assembling fragments *\/\n memcpy(p_rcb->p_rmsg, p_pkt, sizeof(BT_HDR)); \/* Copy bt hdr *\/\n\n \/* Copy metadata message *\/\n memcpy((uint8_t*)(p_rcb->p_rmsg + 1),\n (uint8_t*)(p_pkt + 1) + p_pkt->offset, p_pkt->len);\n\n \/* offset of start of metadata response in reassembly buffer *\/\n p_rcb->p_rmsg->offset = p_rcb->rasm_offset = 0;\n\n \/*\n * Free original START packet, replace with pointer to\n * reassembly buffer.\n *\/\n osi_free(p_pkt);\n *pp_pkt = p_rcb->p_rmsg;\n\n \/*\n * Set offset to point to where to copy next - use the same\n * reassembly logic as AVCT.\n *\/\n p_rcb->p_rmsg->offset += p_rcb->p_rmsg->len;\n req_continue = true;\n } else if (p_rcb->p_rmsg == NULL) {\n \/* Received a CONTINUE\/END, but no corresponding START\n (or previous fragmented response was dropped) *\/\n AVRC_TRACE_DEBUG(\n \"Received a CONTINUE\/END without no corresponding START \\\n (or previous fragmented response was dropped)\");\n drop_code = 5;\n osi_free(p_pkt);\n *pp_pkt = NULL;\n } else {\n \/* get size of buffer holding assembled message *\/\n \/*\n * NOTE: The buffer is allocated above at the beginning of the\n * reassembly, and is always of size BT_DEFAULT_BUFFER_SIZE.\n *\/\n uint16_t buf_len = BT_DEFAULT_BUFFER_SIZE - sizeof(BT_HDR);\n \/* adjust offset and len of fragment for header byte *\/\n p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);\n p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);\n \/* verify length *\/\n if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len) {\n AVRC_TRACE_WARNING(\n \"Fragmented message too big! - report the partial message\");\n p_pkt->len = buf_len - p_rcb->p_rmsg->offset;\n pkt_type = AVRC_PKT_END;\n buf_overflow = true;\n }\n\n \/* copy contents of p_pkt to p_rx_msg *\/\n memcpy((uint8_t*)(p_rcb->p_rmsg + 1) + p_rcb->p_rmsg->offset,\n (uint8_t*)(p_pkt + 1) + p_pkt->offset, p_pkt->len);\n\n if (pkt_type == AVRC_PKT_END) {\n p_rcb->p_rmsg->offset = p_rcb->rasm_offset;\n p_rcb->p_rmsg->len += p_pkt->len;\n p_pkt_new = p_rcb->p_rmsg;\n p_rcb->rasm_offset = 0;\n p_rcb->p_rmsg = NULL;\n p_msg->p_vendor_data = (uint8_t*)(p_pkt_new + 1) + p_pkt_new->offset;\n p_msg->hdr.ctype = p_msg->p_vendor_data[0] & AVRC_CTYPE_MASK;\n \/* 6 = ctype, subunit*, opcode & CO_ID *\/\n p_msg->p_vendor_data += AVRC_VENDOR_HDR_SIZE;\n p_msg->vendor_len = p_pkt_new->len - AVRC_VENDOR_HDR_SIZE;\n p_data = p_msg->p_vendor_data + 1; \/* skip pdu *\/\n *p_data++ = AVRC_PKT_SINGLE;\n UINT16_TO_BE_STREAM(p_data,\n (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE));\n AVRC_TRACE_DEBUG(\"end frag:%d, total len:%d, offset:%d\", p_pkt->len,\n p_pkt_new->len, p_pkt_new->offset);\n } else {\n p_rcb->p_rmsg->offset += p_pkt->len;\n p_rcb->p_rmsg->len += p_pkt->len;\n p_pkt_new = NULL;\n req_continue = true;\n }\n osi_free(p_pkt);\n *pp_pkt = p_pkt_new;\n }\n }\n\n if (cr == AVCT_CMD) {\n p_rsp = avrc_proc_vendor_command(handle, label, *pp_pkt, p_msg);\n if (p_rsp) {\n AVCT_MsgReq(handle, label, AVCT_RSP, p_rsp);\n osi_free_and_reset((void**)pp_pkt);\n drop_code = 3;\n } else if (p_msg->hdr.opcode == AVRC_OP_DROP) {\n drop_code = 1;\n } else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE)\n drop_code = 4;\n\n } else if (cr == AVCT_RSP) {\n if (req_continue) {\n avrc_cmd.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP;\n drop_code = 2;\n } else if (buf_overflow) {\n \/* Incoming message too big to fit in BT_DEFAULT_BUFFER_SIZE. Send abort\n * to peer *\/\n avrc_cmd.pdu = AVRC_PDU_ABORT_CONTINUATION_RSP;\n drop_code = 4;\n } else {\n return drop_code;\n }\n avrc_cmd.status = AVRC_STS_NO_ERROR;\n avrc_cmd.target_pdu = p_rcb->rasm_pdu;\n\n tAVRC_COMMAND avrc_command;\n avrc_command.continu = avrc_cmd;\n status = AVRC_BldCommand(&avrc_command, &p_cmd);\n if (status == AVRC_STS_NO_ERROR) {\n AVRC_MsgReq(handle, (uint8_t)(label), AVRC_CMD_CTRL, p_cmd);\n }\n }\n\n return drop_code;\n}\n","target":0,"code_token_length":1610,"total_token_length":1846,"max_tokens_setting":2048} +{"idx":297201,"func":"void CLASS wavelet_denoise()\n{\n float *fimg = 0, *temp, thold, mul[2], avg, diff;\n int scale = 1, size, lev, hpass, lpass, row, col, nc, c, i, wlast, blk[2];\n ushort *window[4];\n static const float noise[] = {0.8002, 0.2735, 0.1202, 0.0585, 0.0291, 0.0152, 0.0080, 0.0044};\n\n#ifdef DCRAW_VERBOSE\n if (verbose)\n fprintf(stderr, _(\"Wavelet denoising...\\n\"));\n#endif\n\n while (maximum << scale < 0x10000)\n scale++;\n maximum <<= --scale;\n black <<= scale;\n FORC4 cblack[c] <<= scale;\n if ((size = iheight * iwidth) < 0x15550000)\n fimg = (float *)malloc((size * 3 + iheight + iwidth) * sizeof *fimg);\n merror(fimg, \"wavelet_denoise()\");\n temp = fimg + size * 3;\n if ((nc = colors) == 3 && filters)\n nc++;\n#ifdef LIBRAW_LIBRARY_BUILD\n#pragma omp parallel default(shared) private(i, col, row, thold, lev, lpass, hpass, temp, c) firstprivate(scale, size)\n#endif\n {\n temp = (float *)malloc((iheight + iwidth) * sizeof *fimg);\n FORC(nc)\n { \/* denoise R,G1,B,G3 individually *\/\n#ifdef LIBRAW_LIBRARY_BUILD\n#pragma omp for\n#endif\n for (i = 0; i < size; i++)\n fimg[i] = 256 * sqrt((double)(image[i][c] << scale));\n for (hpass = lev = 0; lev < 5; lev++)\n {\n lpass = size * ((lev & 1) + 1);\n#ifdef LIBRAW_LIBRARY_BUILD\n#pragma omp for\n#endif\n for (row = 0; row < iheight; row++)\n {\n hat_transform(temp, fimg + hpass + row * iwidth, 1, iwidth, 1 << lev);\n for (col = 0; col < iwidth; col++)\n fimg[lpass + row * iwidth + col] = temp[col] * 0.25;\n }\n#ifdef LIBRAW_LIBRARY_BUILD\n#pragma omp for\n#endif\n for (col = 0; col < iwidth; col++)\n {\n hat_transform(temp, fimg + lpass + col, iwidth, iheight, 1 << lev);\n for (row = 0; row < iheight; row++)\n fimg[lpass + row * iwidth + col] = temp[row] * 0.25;\n }\n thold = threshold * noise[lev];\n#ifdef LIBRAW_LIBRARY_BUILD\n#pragma omp for\n#endif\n for (i = 0; i < size; i++)\n {\n fimg[hpass + i] -= fimg[lpass + i];\n if (fimg[hpass + i] < -thold)\n fimg[hpass + i] += thold;\n else if (fimg[hpass + i] > thold)\n fimg[hpass + i] -= thold;\n else\n fimg[hpass + i] = 0;\n if (hpass)\n fimg[i] += fimg[hpass + i];\n }\n hpass = lpass;\n }\n#ifdef LIBRAW_LIBRARY_BUILD\n#pragma omp for\n#endif\n for (i = 0; i < size; i++)\n image[i][c] = CLIP(SQR(fimg[i] + fimg[lpass + i]) \/ 0x10000);\n }\n free(temp);\n } \/* end omp parallel *\/\n \/* the following loops are hard to parallize, no idea yes,\n * problem is wlast which is carrying dependency\n * second part should be easyer, but did not yet get it right.\n *\/\n if (filters && colors == 3)\n { \/* pull G1 and G3 closer together *\/\n for (row = 0; row < 2; row++)\n {\n mul[row] = 0.125 * pre_mul[FC(row + 1, 0) | 1] \/ pre_mul[FC(row, 0) | 1];\n blk[row] = cblack[FC(row, 0) | 1];\n }\n for (i = 0; i < 4; i++)\n window[i] = (ushort *)fimg + width * i;\n for (wlast = -1, row = 1; row < height - 1; row++)\n {\n while (wlast < row + 1)\n {\n for (wlast++, i = 0; i < 4; i++)\n window[(i + 3) & 3] = window[i];\n for (col = FC(wlast, 1) & 1; col < width; col += 2)\n window[2][col] = BAYER(wlast, col);\n }\n thold = threshold \/ 512;\n for (col = (FC(row, 0) & 1) + 1; col < width - 1; col += 2)\n {\n avg = (window[0][col - 1] + window[0][col + 1] + window[2][col - 1] + window[2][col + 1] - blk[~row & 1] * 4) *\n mul[row & 1] +\n (window[1][col] + blk[row & 1]) * 0.5;\n avg = avg < 0 ? 0 : sqrt(avg);\n diff = sqrt((double)BAYER(row, col)) - avg;\n if (diff < -thold)\n diff += thold;\n else if (diff > thold)\n diff -= thold;\n else\n diff = 0;\n BAYER(row, col) = CLIP(SQR(avg + diff) + 0.5);\n }\n }\n }\n free(fimg);\n}","target":0,"code_token_length":1408,"total_token_length":1644,"max_tokens_setting":2048} +{"idx":391661,"func":"xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,\n\t\t\t xmlNodePtr elem,\n\t\t\t int options)\n{\n int depth = -1, adoptns = 0, parnsdone = 0;\n xmlNsPtr ns, prevns;\n xmlDocPtr doc;\n xmlNodePtr cur, curElem = NULL;\n xmlNsMapPtr nsMap = NULL;\n xmlNsMapItemPtr \/* topmi = NULL, *\/ mi;\n \/* @ancestorsOnly should be set by an option flag. *\/\n int ancestorsOnly = 0;\n int optRemoveRedundantNS =\n\t((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0;\n xmlNsPtr *listRedund = NULL;\n int sizeRedund = 0, nbRedund = 0, ret, i, j;\n\n if ((elem == NULL) || (elem->doc == NULL) ||\n\t(elem->type != XML_ELEMENT_NODE))\n\treturn (-1);\n\n doc = elem->doc;\n cur = elem;\n do {\n\tswitch (cur->type) {\n\t case XML_ELEMENT_NODE:\n\t\tadoptns = 1;\n\t\tcurElem = cur;\n\t\tdepth++;\n\t\t\/*\n\t\t* Namespace declarations.\n\t\t*\/\n\t\tif (cur->nsDef != NULL) {\n\t\t prevns = NULL;\n\t\t ns = cur->nsDef;\n\t\t while (ns != NULL) {\n\t\t\tif (! parnsdone) {\n\t\t\t if ((elem->parent) &&\n\t\t\t\t((xmlNodePtr) elem->parent->doc != elem->parent)) {\n\t\t\t\t\/*\n\t\t\t\t* Gather ancestor in-scope ns-decls.\n\t\t\t\t*\/\n\t\t\t\tif (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,\n\t\t\t\t elem->parent) == -1)\n\t\t\t\t goto internal_error;\n\t\t\t }\n\t\t\t parnsdone = 1;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t* Lookup the ns ancestor-axis for equal ns-decls in scope.\n\t\t\t*\/\n\t\t\tif (optRemoveRedundantNS && XML_NSMAP_NOTEMPTY(nsMap)) {\n\t\t\t XML_NSMAP_FOREACH(nsMap, mi) {\n\t\t\t\tif ((mi->depth >= XML_TREE_NSMAP_PARENT) &&\n\t\t\t\t (mi->shadowDepth == -1) &&\n\t\t\t\t ((ns->prefix == mi->newNs->prefix) ||\n\t\t\t\t xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&\n\t\t\t\t ((ns->href == mi->newNs->href) ||\n\t\t\t\t xmlStrEqual(ns->href, mi->newNs->href)))\n\t\t\t\t{\n\t\t\t\t \/*\n\t\t\t\t * A redundant ns-decl was found.\n\t\t\t\t * Add it to the list of redundant ns-decls.\n\t\t\t\t *\/\n\t\t\t\t if (xmlDOMWrapNSNormAddNsMapItem2(&listRedund,\n\t\t\t\t\t&sizeRedund, &nbRedund, ns, mi->newNs) == -1)\n\t\t\t\t\tgoto internal_error;\n\t\t\t\t \/*\n\t\t\t\t * Remove the ns-decl from the element-node.\n\t\t\t\t *\/\n\t\t\t\t if (prevns)\n\t\t\t\t\tprevns->next = ns->next;\n\t\t\t\t else\n\t\t\t\t\tcur->nsDef = ns->next;\n\t\t\t\t goto next_ns_decl;\n\t\t\t\t}\n\t\t\t }\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t* Skip ns-references handling if the referenced\n\t\t\t* ns-decl is declared on the same element.\n\t\t\t*\/\n\t\t\tif ((cur->ns != NULL) && adoptns && (cur->ns == ns))\n\t\t\t adoptns = 0;\n\t\t\t\/*\n\t\t\t* Does it shadow any ns-decl?\n\t\t\t*\/\n\t\t\tif (XML_NSMAP_NOTEMPTY(nsMap)) {\n\t\t\t XML_NSMAP_FOREACH(nsMap, mi) {\n\t\t\t\tif ((mi->depth >= XML_TREE_NSMAP_PARENT) &&\n\t\t\t\t (mi->shadowDepth == -1) &&\n\t\t\t\t ((ns->prefix == mi->newNs->prefix) ||\n\t\t\t\t xmlStrEqual(ns->prefix, mi->newNs->prefix))) {\n\n\t\t\t\t mi->shadowDepth = depth;\n\t\t\t\t}\n\t\t\t }\n\t\t\t}\n\t\t\t\/*\n\t\t\t* Push mapping.\n\t\t\t*\/\n\t\t\tif (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,\n\t\t\t depth) == NULL)\n\t\t\t goto internal_error;\n\n\t\t\tprevns = ns;\nnext_ns_decl:\n\t\t\tns = ns->next;\n\t\t }\n\t\t}\n\t\tif (! adoptns)\n\t\t goto ns_end;\n\t\t\/* No break on purpose. *\/\n\t case XML_ATTRIBUTE_NODE:\n\t\t\/* No ns, no fun. *\/\n\t\tif (cur->ns == NULL)\n\t\t goto ns_end;\n\n\t\tif (! parnsdone) {\n\t\t if ((elem->parent) &&\n\t\t\t((xmlNodePtr) elem->parent->doc != elem->parent)) {\n\t\t\tif (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,\n\t\t\t\telem->parent) == -1)\n\t\t\t goto internal_error;\n\t\t }\n\t\t parnsdone = 1;\n\t\t}\n\t\t\/*\n\t\t* Adjust the reference if this was a redundant ns-decl.\n\t\t*\/\n\t\tif (listRedund) {\n\t\t for (i = 0, j = 0; i < nbRedund; i++, j += 2) {\n\t\t if (cur->ns == listRedund[j]) {\n\t\t\t cur->ns = listRedund[++j];\n\t\t\t break;\n\t\t }\n\t\t }\n\t\t}\n\t\t\/*\n\t\t* Adopt ns-references.\n\t\t*\/\n\t\tif (XML_NSMAP_NOTEMPTY(nsMap)) {\n\t\t \/*\n\t\t * Search for a mapping.\n\t\t *\/\n\t\t XML_NSMAP_FOREACH(nsMap, mi) {\n\t\t\tif ((mi->shadowDepth == -1) &&\n\t\t\t (cur->ns == mi->oldNs)) {\n\n\t\t\t cur->ns = mi->newNs;\n\t\t\t goto ns_end;\n\t\t\t}\n\t\t }\n\t\t}\n\t\t\/*\n\t\t* Aquire a normalized ns-decl and add it to the map.\n\t\t*\/\n\t\tif (xmlDOMWrapNSNormAquireNormalizedNs(doc, curElem,\n\t\t\tcur->ns, &ns,\n\t\t\t&nsMap, depth,\n\t\t\tancestorsOnly,\n\t\t\t(cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1)\n\t\t goto internal_error;\n\t\tcur->ns = ns;\n\nns_end:\n\t\tif ((cur->type == XML_ELEMENT_NODE) &&\n\t\t (cur->properties != NULL)) {\n\t\t \/*\n\t\t * Process attributes.\n\t\t *\/\n\t\t cur = (xmlNodePtr) cur->properties;\n\t\t continue;\n\t\t}\n\t\tbreak;\n\t default:\n\t\tgoto next_sibling;\n\t}\ninto_content:\n\tif ((cur->type == XML_ELEMENT_NODE) &&\n\t (cur->children != NULL)) {\n\t \/*\n\t * Process content of element-nodes only.\n\t *\/\n\t cur = cur->children;\n\t continue;\n\t}\nnext_sibling:\n\tif (cur == elem)\n\t break;\n\tif (cur->type == XML_ELEMENT_NODE) {\n\t if (XML_NSMAP_NOTEMPTY(nsMap)) {\n\t\t\/*\n\t\t* Pop mappings.\n\t\t*\/\n\t\twhile ((nsMap->last != NULL) &&\n\t\t (nsMap->last->depth >= depth))\n\t\t{\n\t\t XML_NSMAP_POP(nsMap, mi)\n\t\t}\n\t\t\/*\n\t\t* Unshadow.\n\t\t*\/\n\t\tXML_NSMAP_FOREACH(nsMap, mi) {\n\t\t if (mi->shadowDepth >= depth)\n\t\t\tmi->shadowDepth = -1;\n\t\t}\n\t }\n\t depth--;\n\t}\n\tif (cur->next != NULL)\n\t cur = cur->next;\n\telse {\n\t if (cur->type == XML_ATTRIBUTE_NODE) {\n\t\tcur = cur->parent;\n\t\tgoto into_content;\n\t }\n\t cur = cur->parent;\n\t goto next_sibling;\n\t}\n } while (cur != NULL);\n\n ret = 0;\n goto exit;\ninternal_error:\n ret = -1;\nexit:\n if (listRedund) {\n\tfor (i = 0, j = 0; i < nbRedund; i++, j += 2) {\n\t xmlFreeNs(listRedund[j]);\n\t}\n\txmlFree(listRedund);\n }\n if (nsMap != NULL)\n\txmlDOMWrapNsMapFree(nsMap);\n return (ret);\n}","target":0,"code_token_length":1751,"total_token_length":1987,"max_tokens_setting":2048} +{"idx":479601,"func":" CImg& noise(const double sigma, const unsigned int noise_type=0) {\n if (is_empty()) return *this;\n const Tfloat vmin = (Tfloat)cimg::type::min(), vmax = (Tfloat)cimg::type::max();\n Tfloat nsigma = (Tfloat)sigma, m = 0, M = 0;\n if (nsigma==0 && noise_type!=3) return *this;\n if (nsigma<0 || noise_type==2) m = (Tfloat)min_max(M);\n if (nsigma<0) nsigma = (Tfloat)(-nsigma*(M-m)\/100.);\n switch (noise_type) {\n case 0 : { \/\/ Gaussian noise\n cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {\n cimg_uint64 rng = (cimg::_rand(),cimg::rng());\n\n#if cimg_use_openmp!=0\n rng+=omp_get_thread_num();\n#endif\n cimg_pragma_openmp(for)\n cimg_rofoff(*this,off) {\n Tfloat val = (Tfloat)(_data[off] + nsigma*cimg::grand(&rng));\n if (val>vmax) val = vmax;\n if (valvmax) val = vmax;\n if (val::is_float()) { --m; ++M; }\n else { m = (Tfloat)cimg::type::min(); M = (Tfloat)cimg::type::max(); }\n }\n cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {\n cimg_uint64 rng = (cimg::_rand(),cimg::rng());\n\n#if cimg_use_openmp!=0\n rng+=omp_get_thread_num();\n#endif\n cimg_pragma_openmp(for)\n cimg_rofoff(*this,off) if (cimg::rand(100,&rng)vmax) val = vmax;\n if (valinit_num = frag_len;\n\t\treturn frag_len;\n\t\t}\n\n\t\/* read handshake message header *\/\n\ti=s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,wire,\n\t\tDTLS1_HM_HEADER_LENGTH, 0);\n\tif (i <= 0) \t\/* nbio, or an error *\/\n\t\t{\n\t\ts->rwstate=SSL_READING;\n\t\t*ok = 0;\n\t\treturn i;\n\t\t}\n\t\/* Handshake fails if message header is incomplete *\/\n\tif (i != DTLS1_HM_HEADER_LENGTH)\n\t\t{\n\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_UNEXPECTED_MESSAGE);\n\t\tgoto f_err;\n\t\t}\n\n\t\/* parse the message fragment header *\/\n\tdtls1_get_message_header(wire, &msg_hdr);\n\n\t\/* \n\t * if this is a future (or stale) message it gets buffered\n\t * (or dropped)--no further processing at this time\n\t * While listening, we accept seq 1 (ClientHello with cookie)\n\t * although we're still expecting seq 0 (ClientHello)\n\t *\/\n\tif (msg_hdr.seq != s->d1->handshake_read_seq && !(s->d1->listen && msg_hdr.seq == 1))\n\t\treturn dtls1_process_out_of_seq_message(s, &msg_hdr, ok);\n\n\tlen = msg_hdr.msg_len;\n\tfrag_off = msg_hdr.frag_off;\n\tfrag_len = msg_hdr.frag_len;\n\n\tif (frag_len && frag_len < len)\n\t\treturn dtls1_reassemble_fragment(s, &msg_hdr, ok);\n\n\tif (!s->server && s->d1->r_msg_hdr.frag_off == 0 &&\n\t\twire[0] == SSL3_MT_HELLO_REQUEST)\n\t\t{\n\t\t\/* The server may always send 'Hello Request' messages --\n\t\t * we are doing a handshake anyway now, so ignore them\n\t\t * if their format is correct. Does not count for\n\t\t * 'Finished' MAC. *\/\n\t\tif (wire[1] == 0 && wire[2] == 0 && wire[3] == 0)\n\t\t\t{\n\t\t\tif (s->msg_callback)\n\t\t\t\ts->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, \n\t\t\t\t\twire, DTLS1_HM_HEADER_LENGTH, s, \n\t\t\t\t\ts->msg_callback_arg);\n\t\t\t\n\t\t\ts->init_num = 0;\n\t\t\treturn dtls1_get_message_fragment(s, st1, stn,\n\t\t\t\tmax, ok);\n\t\t\t}\n\t\telse \/* Incorrectly formated Hello request *\/\n\t\t\t{\n\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_UNEXPECTED_MESSAGE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\n\tif ((al=dtls1_preprocess_fragment(s,&msg_hdr,max)))\n\t\tgoto f_err;\n\n\t\/* XDTLS: ressurect this when restart is in place *\/\n\ts->state=stn;\n\n\tif ( frag_len > 0)\n\t\t{\n\t\tunsigned char *p=(unsigned char *)s->init_buf->data+DTLS1_HM_HEADER_LENGTH;\n\n\t\ti=s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,\n\t\t\t&p[frag_off],frag_len,0);\n\t\t\/* XDTLS: fix this--message fragments cannot span multiple packets *\/\n\t\tif (i <= 0)\n\t\t\t{\n\t\t\ts->rwstate=SSL_READING;\n\t\t\t*ok = 0;\n\t\t\treturn i;\n\t\t\t}\n\t\t}\n\telse\n\t\ti = 0;\n\n\t\/* XDTLS: an incorrectly formatted fragment should cause the \n\t * handshake to fail *\/\n\tif (i != (int)frag_len)\n\t\t{\n\t\tal=SSL3_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL3_AD_ILLEGAL_PARAMETER);\n\t\tgoto f_err;\n\t\t}\n\n\t*ok = 1;\n\n\t\/* Note that s->init_num is *not* used as current offset in\n\t * s->init_buf->data, but as a counter summing up fragments'\n\t * lengths: as soon as they sum up to handshake packet\n\t * length, we assume we have got all the fragments. *\/\n\ts->init_num = frag_len;\n\treturn frag_len;\n\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\n\ts->init_num = 0;\n\n\t*ok=0;\n\treturn(-1);\n\t}","target":1,"code_token_length":1075,"total_token_length":1311,"max_tokens_setting":2048} +{"idx":248029,"func":"static int rgbbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth)\n{\n os_ptr op = osp;\n float RGB[3], CMYK[4], Gray, UCR, BG;\n int i;\n const gs_color_space * pcs = gs_currentcolorspace(igs);\n\n if (pcs->id == cs_DeviceGray_id) {\n \/* UGLY hack. Its possible for the graphics library to change the\n * colour space to DeviceGray (setcachedevice), but this does not\n * change the PostScript space. It can't, because the graphics library\n * doesn't know about the PostScript objects. If we get a current*\n * operation before the space has been restored, the colour space in\n * the graphics library and the PostScript stored space won't match.\n * If that happens then we need to pretend the PS colour space was\n * DeviceGray\n *\/\n return(graybasecolor(i_ctx_p, space, base, stage, cont, stack_depth));\n }\n\n switch (*stage) {\n case 0:\n *cont = 0;\n check_op(3);\n op -= 2;\n for (i=0;i<3;i++) {\n if (!r_has_type(op, t_integer)) {\n if (r_has_type(op, t_real)) {\n RGB[i] = op->value.realval;\n } else\n return_error(gs_error_typecheck);\n } else\n RGB[i] = (float)op->value.intval;\n if (RGB[i] < 0 || RGB[i] > 1)\n return_error(gs_error_rangecheck);\n op++;\n }\n op = osp;\n\n switch (base) {\n case 0:\n pop(2);\n op = osp;\n \/* If R == G == B, then this is gray, so just use it. Avoids\n * rounding errors.\n *\/\n if (RGB[0] == RGB[1] && RGB[1] == RGB[2])\n Gray = RGB[0];\n else\n Gray = (0.3 * RGB[0]) + (0.59 * RGB[1]) + (0.11 * RGB[2]);\n make_real(op, Gray);\n return 0;\n break;\n case 1:\n rgb2hsb((float *)&RGB);\n make_real(&op[-2], RGB[0]);\n make_real(&op[-1], RGB[1]);\n make_real(op, RGB[2]);\n return 0;\n break;\n case 2:\n make_real(&op[-2], RGB[0]);\n make_real(&op[-1], RGB[1]);\n make_real(op, RGB[2]);\n return 0;\n break;\n case 3:\n *stage = 1;\n *cont = 1;\n for (i=0;i<3;i++)\n CMYK[i] = 1 - RGB[i];\n if (CMYK[0] < CMYK[1]) {\n if (CMYK[0] < CMYK[2])\n CMYK[3] = CMYK[0];\n else\n CMYK[3] = CMYK[2];\n } else {\n if (CMYK[1] < CMYK[2])\n CMYK[3] = CMYK[1];\n else\n CMYK[3] = CMYK[2];\n }\n check_estack(1);\n push(2);\n op = osp - 4;\n for (i=0;i<4;i++) {\n make_real(op, CMYK[i]);\n op++;\n }\n make_real(op, CMYK[3]);\n esp++;\n *esp = istate->undercolor_removal;\n return o_push_estack;\n break;\n default:\n return_error(gs_error_undefined);\n break;\n }\n break;\n case 1:\n (*stage)++;\n *cont = 1;\n check_estack(1);\n check_op(5);\n op -= 4;\n for (i=0;i<4;i++) {\n if (!r_has_type(op, t_integer)) {\n if (r_has_type(op, t_real)) {\n CMYK[i] = op->value.realval;\n } else\n return_error(gs_error_typecheck);\n } else\n CMYK[i] = (float)op->value.intval;\n op++;\n }\n if (!r_has_type(op, t_integer)) {\n if (r_has_type(op, t_real)) {\n UCR = op->value.realval;\n } else\n return_error(gs_error_typecheck);\n } else\n UCR = (float)op->value.intval;\n for (i=0;i<3;i++) {\n CMYK[i] = CMYK[i] - UCR;\n if (CMYK[i] < 0)\n CMYK[i] = 0;\n if (CMYK[i] > 1)\n CMYK[i] = 1.0;\n }\n op -= 4;\n for (i=0;i<4;i++) {\n make_real(op, CMYK[i]);\n op++;\n }\n make_real(op, CMYK[3]);\n esp++;\n *esp = istate->black_generation;\n return o_push_estack;\n break;\n case 2:\n *stage = 0;\n *cont = 0;\n check_op(5);\n if (!r_has_type(op, t_integer)) {\n if (r_has_type(op, t_real)) {\n BG = op->value.realval;\n } else\n return_error(gs_error_typecheck);\n } else\n BG = (float)op->value.intval;\n pop(1);\n op = osp;\n if (BG < 0)\n BG = 0;\n if (BG > 1)\n BG = 1;\n make_real(op, BG);\n break;\n }\n return 0;\n}\n","target":0,"code_token_length":1343,"total_token_length":1579,"max_tokens_setting":2048} +{"idx":104517,"func":"static const char *columnTypeImpl(\n NameContext *pNC, \n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n Expr *pExpr\n#else\n Expr *pExpr,\n const char **pzOrigDb,\n const char **pzOrigTab,\n const char **pzOrigCol\n#endif\n){\n char const *zType = 0;\n int j;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n char const *zOrigDb = 0;\n char const *zOrigTab = 0;\n char const *zOrigCol = 0;\n#endif\n\n assert( pExpr!=0 );\n assert( pNC->pSrcList!=0 );\n switch( pExpr->op ){\n case TK_COLUMN: {\n \/* The expression is a column. Locate the table the column is being\n ** extracted from in NameContext.pSrcList. This table may be real\n ** database table or a subquery.\n *\/\n Table *pTab = 0; \/* Table structure column is extracted from *\/\n Select *pS = 0; \/* Select the column is extracted from *\/\n int iCol = pExpr->iColumn; \/* Index of column in pTab *\/\n while( pNC && !pTab ){\n SrcList *pTabList = pNC->pSrcList;\n for(j=0;jnSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);\n if( jnSrc ){\n pTab = pTabList->a[j].pTab;\n pS = pTabList->a[j].pSelect;\n }else{\n pNC = pNC->pNext;\n }\n }\n\n if( pTab==0 ){\n \/* At one time, code such as \"SELECT new.x\" within a trigger would\n ** cause this condition to run. Since then, we have restructured how\n ** trigger code is generated and so this condition is no longer \n ** possible. However, it can still be true for statements like\n ** the following:\n **\n ** CREATE TABLE t1(col INTEGER);\n ** SELECT (SELECT t1.col) FROM FROM t1;\n **\n ** when columnType() is called on the expression \"t1.col\" in the \n ** sub-select. In this case, set the column type to NULL, even\n ** though it should really be \"INTEGER\".\n **\n ** This is not a problem, as the column type of \"t1.col\" is never\n ** used. When columnType() is called on the expression \n ** \"(SELECT t1.col)\", the correct type is returned (see the TK_SELECT\n ** branch below. *\/\n break;\n }\n\n assert( pTab && pExpr->y.pTab==pTab );\n if( pS ){\n \/* The \"table\" is actually a sub-select or a view in the FROM clause\n ** of the SELECT statement. Return the declaration type and origin\n ** data for the result-set column of the sub-select.\n *\/\n if( iCol>=0 && iColpEList->nExpr ){\n \/* If iCol is less than zero, then the expression requests the\n ** rowid of the sub-select or view. This expression is legal (see \n ** test case misc2.2.2) - it always evaluates to NULL.\n *\/\n NameContext sNC;\n Expr *p = pS->pEList->a[iCol].pExpr;\n sNC.pSrcList = pS->pSrc;\n sNC.pNext = pNC;\n sNC.pParse = pNC->pParse;\n zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol); \n }\n }else{\n \/* A real table or a CTE table *\/\n assert( !pS );\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n if( iCol<0 ) iCol = pTab->iPKey;\n assert( iCol==XN_ROWID || (iCol>=0 && iColnCol) );\n if( iCol<0 ){\n zType = \"INTEGER\";\n zOrigCol = \"rowid\";\n }else{\n zOrigCol = pTab->aCol[iCol].zName;\n zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n }\n zOrigTab = pTab->zName;\n if( pNC->pParse && pTab->pSchema ){\n int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);\n zOrigDb = pNC->pParse->db->aDb[iDb].zDbSName;\n }\n#else\n assert( iCol==XN_ROWID || (iCol>=0 && iColnCol) );\n if( iCol<0 ){\n zType = \"INTEGER\";\n }else{\n zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n }\n#endif\n }\n break;\n }\n#ifndef SQLITE_OMIT_SUBQUERY\n case TK_SELECT: {\n \/* The expression is a sub-select. Return the declaration type and\n ** origin info for the single column in the result set of the SELECT\n ** statement.\n *\/\n NameContext sNC;\n Select *pS = pExpr->x.pSelect;\n Expr *p = pS->pEList->a[0].pExpr;\n assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n sNC.pSrcList = pS->pSrc;\n sNC.pNext = pNC;\n sNC.pParse = pNC->pParse;\n zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol); \n break;\n }\n#endif\n }\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA \n if( pzOrigDb ){\n assert( pzOrigTab && pzOrigCol );\n *pzOrigDb = zOrigDb;\n *pzOrigTab = zOrigTab;\n *pzOrigCol = zOrigCol;\n }\n#endif\n return zType;\n}","target":0,"code_token_length":1341,"total_token_length":1577,"max_tokens_setting":2048} +{"idx":32078,"func":"static int opdec(RAsm *a, ut8 *data, const Opcode *op) {\n\tif (op->operands[1].type) {\n\t\teprintf (\"Error: Invalid operands\\n\");\n\t\treturn -1;\n\t}\n\tint l = 0;\n\tint size = op->operands[0].type & ALL_SIZE;\n\tif (op->operands[0].explicit_size) {\n\t\tsize = op->operands[0].dest_size;\n\t}\n\n\tif (size & OT_WORD) {\n\t\tdata[l++] = 0x66;\n\t}\n\n\t\/\/rex prefix\n\tint rex = 1 << 6;\n\tbool use_rex = false;\n\tif (size & OT_QWORD) {\t\t\t\/\/W field\n\t\tuse_rex = true;\n\t\trex |= 1 << 3;\n\t}\n\tif (op->operands[0].extended) {\t\t\/\/B field\n\t\tuse_rex = true;\n\t\trex |= 1;\n\t}\n\n\t\/\/opcode selection\n\tint opcode;\n\tif (size & OT_BYTE) {\n\t\topcode = 0xfe;\n\t} else {\n\t\topcode = 0xff;\n\t}\n\n\tif (!(op->operands[0].type & OT_MEMORY)) {\n\t\tif (use_rex) {\n\t\t\tdata[l++] = rex;\n\t\t}\n\t\tif (a->bits > 32 || size & OT_BYTE) {\n\t\t\tdata[l++] = opcode;\n\t\t}\n\t\tif (a->bits == 32 && size & (OT_DWORD | OT_WORD)) {\n\t\t\tdata[l++] = 0x48 | op->operands[0].reg;\n\t\t} else {\n\t\t\tdata[l++] = 0xc8 | op->operands[0].reg;\n\t\t}\n\t\treturn l;\n\t}\n\n\t\/\/modrm and SIB selection\n\tbool rip_rel = op->operands[0].regs[0] == X86R_RIP;\n\tint offset = op->operands[0].offset * op->operands[0].offset_sign;\n\tint modrm = 0;\n\tint mod;\n\tint reg = 0;\n\tint rm;\n\tbool use_sib = false;\n\tint sib;\n\t\/\/mod\n\tif (offset == 0) {\n\t\tmod = 0;\n\t} else if (offset < 128 && offset > -129) {\n\t\tmod = 1;\n\t} else {\n\t\tmod = 2;\n\t}\n\n\tif (op->operands[0].regs[0] & OT_WORD) {\n\t\tif (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == X86R_SI) {\n\t\t\trm = B0000;\n\t\t} else if (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == X86R_DI) {\n\t\t\trm = B0001;\n\t\t} else if (op->operands[0].regs[0] == X86R_BP && op->operands[0].regs[1] == X86R_SI) {\n\t\t\trm = B0010;\n\t\t} else if (op->operands[0].regs[0] == X86R_BP && op->operands[0].regs[1] == X86R_DI) {\n\t\t\trm = B0011;\n\t\t} else if (op->operands[0].regs[0] == X86R_SI && op->operands[0].regs[1] == -1) {\n\t\t\trm = B0100;\n\t\t} else if (op->operands[0].regs[0] == X86R_DI && op->operands[0].regs[1] == -1) {\n\t\t\trm = B0101;\n\t\t} else if (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == -1) {\n\t\t\trm = B0111;\n\t\t} else {\n\t\t\t\/\/TODO allow for displacement only when parser is reworked\n\t\t\treturn -1;\n\t\t}\n\t\tmodrm = (mod << 6) | (reg << 3) | rm;\n\t} else {\n\t\t\/\/rm\n\t\tif (op->operands[0].extended) {\n\t\t\trm = op->operands[0].reg;\n\t\t} else {\n\t\t\trm = op->operands[0].regs[0];\n\t\t}\n\t\t\/\/[epb] alone is illegal, so we need to fake a [ebp+0]\n\t\tif (rm == 5 && mod == 0) {\n\t\t\tmod = 1;\n\t\t}\n\n\t\t\/\/sib\n\t\tint index = op->operands[0].regs[1];\n\t\tint scale = getsib(op->operands[0].scale[1]);\n\t\tif (index != -1) {\n\t\t\tuse_sib = true;\n\t\t\tsib = (scale << 6) | (index << 3) | rm;\n\t\t} else if (rm == 4) {\n\t\t\tuse_sib = true;\n\t\t\tsib = 0x24;\n\t\t}\n\t\tif (use_sib) {\n\t\t\trm = B0100;\n\t\t}\n\t\tif (rip_rel) {\n\t\t\tmodrm = (B0000 << 6) | (reg << 3) | B0101;\n\t\t\tsib = (scale << 6) | (B0100 << 3) | B0101;\n\t\t} else {\n\t\t\tmodrm = (mod << 6) | (reg << 3) | rm;\n\t\t}\n\t\tmodrm |= 1<<3;\n\t}\n\n\tif (use_rex) {\n\t\tdata[l++] = rex;\n\t}\n\tdata[l++] = opcode;\n\tdata[l++] = modrm;\n\tif (use_sib) {\n\t\tdata[l++] = sib;\n\t}\n\t\/\/offset\n\tif (mod == 1) {\n\t\tdata[l++] = offset;\n\t} else if (op->operands[0].regs[0] & OT_WORD && mod == 2) {\n\t\tdata[l++] = offset;\n\t\tdata[l++] = offset >> 8;\n\t} else if (mod == 2 || rip_rel) {\n\t\tdata[l++] = offset;\n\t\tdata[l++] = offset >> 8;\n\t\tdata[l++] = offset >> 16;\n\t\tdata[l++] = offset >> 24;\n\t}\n\n\treturn l;\n}","target":0,"code_token_length":1405,"total_token_length":1641,"max_tokens_setting":2048} +{"idx":443748,"func":"static unsigned int selinux_ip_postroute(struct sk_buff *skb,\n\t\t\t\t\t const struct net_device *outdev,\n\t\t\t\t\t u16 family)\n{\n\tu32 secmark_perm;\n\tu32 peer_sid;\n\tint ifindex = outdev->ifindex;\n\tstruct sock *sk;\n\tstruct common_audit_data ad;\n\tstruct lsm_network_audit net = {0,};\n\tchar *addrp;\n\tu8 secmark_active;\n\tu8 peerlbl_active;\n\n\t\/* If any sort of compatibility mode is enabled then handoff processing\n\t * to the selinux_ip_postroute_compat() function to deal with the\n\t * special handling. We do this in an attempt to keep this function\n\t * as fast and as clean as possible. *\/\n\tif (!selinux_policycap_netpeer())\n\t\treturn selinux_ip_postroute_compat(skb, ifindex, family);\n\n\tsecmark_active = selinux_secmark_enabled();\n\tpeerlbl_active = selinux_peerlbl_enabled();\n\tif (!secmark_active && !peerlbl_active)\n\t\treturn NF_ACCEPT;\n\n\tsk = skb_to_full_sk(skb);\n\n#ifdef CONFIG_XFRM\n\t\/* If skb->dst->xfrm is non-NULL then the packet is undergoing an IPsec\n\t * packet transformation so allow the packet to pass without any checks\n\t * since we'll have another chance to perform access control checks\n\t * when the packet is on it's final way out.\n\t * NOTE: there appear to be some IPv6 multicast cases where skb->dst\n\t * is NULL, in this case go ahead and apply access control.\n\t * NOTE: if this is a local socket (skb->sk != NULL) that is in the\n\t * TCP listening state we cannot wait until the XFRM processing\n\t * is done as we will miss out on the SA label if we do;\n\t * unfortunately, this means more work, but it is only once per\n\t * connection. *\/\n\tif (skb_dst(skb) != NULL && skb_dst(skb)->xfrm != NULL &&\n\t !(sk && sk_listener(sk)))\n\t\treturn NF_ACCEPT;\n#endif\n\n\tif (sk == NULL) {\n\t\t\/* Without an associated socket the packet is either coming\n\t\t * from the kernel or it is being forwarded; check the packet\n\t\t * to determine which and if the packet is being forwarded\n\t\t * query the packet directly to determine the security label. *\/\n\t\tif (skb->skb_iif) {\n\t\t\tsecmark_perm = PACKET__FORWARD_OUT;\n\t\t\tif (selinux_skb_peerlbl_sid(skb, family, &peer_sid))\n\t\t\t\treturn NF_DROP;\n\t\t} else {\n\t\t\tsecmark_perm = PACKET__SEND;\n\t\t\tpeer_sid = SECINITSID_KERNEL;\n\t\t}\n\t} else if (sk_listener(sk)) {\n\t\t\/* Locally generated packet but the associated socket is in the\n\t\t * listening state which means this is a SYN-ACK packet. In\n\t\t * this particular case the correct security label is assigned\n\t\t * to the connection\/request_sock but unfortunately we can't\n\t\t * query the request_sock as it isn't queued on the parent\n\t\t * socket until after the SYN-ACK packet is sent; the only\n\t\t * viable choice is to regenerate the label like we do in\n\t\t * selinux_inet_conn_request(). See also selinux_ip_output()\n\t\t * for similar problems. *\/\n\t\tu32 skb_sid;\n\t\tstruct sk_security_struct *sksec;\n\n\t\tsksec = sk->sk_security;\n\t\tif (selinux_skb_peerlbl_sid(skb, family, &skb_sid))\n\t\t\treturn NF_DROP;\n\t\t\/* At this point, if the returned skb peerlbl is SECSID_NULL\n\t\t * and the packet has been through at least one XFRM\n\t\t * transformation then we must be dealing with the \"final\"\n\t\t * form of labeled IPsec packet; since we've already applied\n\t\t * all of our access controls on this packet we can safely\n\t\t * pass the packet. *\/\n\t\tif (skb_sid == SECSID_NULL) {\n\t\t\tswitch (family) {\n\t\t\tcase PF_INET:\n\t\t\t\tif (IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED)\n\t\t\t\t\treturn NF_ACCEPT;\n\t\t\t\tbreak;\n\t\t\tcase PF_INET6:\n\t\t\t\tif (IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED)\n\t\t\t\t\treturn NF_ACCEPT;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn NF_DROP_ERR(-ECONNREFUSED);\n\t\t\t}\n\t\t}\n\t\tif (selinux_conn_sid(sksec->sid, skb_sid, &peer_sid))\n\t\t\treturn NF_DROP;\n\t\tsecmark_perm = PACKET__SEND;\n\t} else {\n\t\t\/* Locally generated packet, fetch the security label from the\n\t\t * associated socket. *\/\n\t\tstruct sk_security_struct *sksec = sk->sk_security;\n\t\tpeer_sid = sksec->sid;\n\t\tsecmark_perm = PACKET__SEND;\n\t}\n\n\tad.type = LSM_AUDIT_DATA_NET;\n\tad.u.net = &net;\n\tad.u.net->netif = ifindex;\n\tad.u.net->family = family;\n\tif (selinux_parse_skb(skb, &ad, &addrp, 0, NULL))\n\t\treturn NF_DROP;\n\n\tif (secmark_active)\n\t\tif (avc_has_perm(&selinux_state,\n\t\t\t\t peer_sid, skb->secmark,\n\t\t\t\t SECCLASS_PACKET, secmark_perm, &ad))\n\t\t\treturn NF_DROP_ERR(-ECONNREFUSED);\n\n\tif (peerlbl_active) {\n\t\tu32 if_sid;\n\t\tu32 node_sid;\n\n\t\tif (sel_netif_sid(dev_net(outdev), ifindex, &if_sid))\n\t\t\treturn NF_DROP;\n\t\tif (avc_has_perm(&selinux_state,\n\t\t\t\t peer_sid, if_sid,\n\t\t\t\t SECCLASS_NETIF, NETIF__EGRESS, &ad))\n\t\t\treturn NF_DROP_ERR(-ECONNREFUSED);\n\n\t\tif (sel_netnode_sid(addrp, family, &node_sid))\n\t\t\treturn NF_DROP;\n\t\tif (avc_has_perm(&selinux_state,\n\t\t\t\t peer_sid, node_sid,\n\t\t\t\t SECCLASS_NODE, NODE__SENDTO, &ad))\n\t\t\treturn NF_DROP_ERR(-ECONNREFUSED);\n\t}\n\n\treturn NF_ACCEPT;\n}","target":0,"code_token_length":1309,"total_token_length":1545,"max_tokens_setting":2048} +{"idx":128110,"func":"IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags)\n{\n CONNECTION* conn = NULL;\n ACCOUNT* creds = NULL;\n IMAP_DATA* idata = NULL;\n int new = 0;\n\n while ((conn = mutt_conn_find (conn, account)))\n {\n if (!creds)\n creds = &conn->account;\n else\n memcpy (&conn->account, creds, sizeof (ACCOUNT));\n\n idata = (IMAP_DATA*)conn->data;\n if (flags & MUTT_IMAP_CONN_NONEW)\n {\n if (!idata)\n {\n \/* This should only happen if we've come to the end of the list *\/\n mutt_socket_free (conn);\n return NULL;\n }\n else if (idata->state < IMAP_AUTHENTICATED)\n continue;\n }\n if (flags & MUTT_IMAP_CONN_NOSELECT && idata && idata->state >= IMAP_SELECTED)\n continue;\n if (idata && idata->status == IMAP_FATAL)\n continue;\n break;\n }\n if (!conn)\n return NULL; \/* this happens when the initial connection fails *\/\n\n \/* The current connection is a new connection *\/\n if (!idata)\n {\n idata = imap_new_idata ();\n conn->data = idata;\n idata->conn = conn;\n new = 1;\n }\n\n if (idata->state == IMAP_DISCONNECTED)\n imap_open_connection (idata);\n if (idata->state == IMAP_CONNECTED)\n {\n if (!imap_authenticate (idata))\n {\n idata->state = IMAP_AUTHENTICATED;\n FREE (&idata->capstr);\n new = 1;\n if (idata->conn->ssf)\n\tdprint (2, (debugfile, \"Communication encrypted at %d bits\\n\",\n\t\t idata->conn->ssf));\n }\n else\n mutt_account_unsetpass (&idata->conn->account);\n }\n if (new && idata->state == IMAP_AUTHENTICATED)\n {\n \/* capabilities may have changed *\/\n imap_exec (idata, \"CAPABILITY\", IMAP_CMD_FAIL_OK);\n\n#if defined(USE_ZLIB)\n \/* RFC 4978 *\/\n if (mutt_bit_isset (idata->capabilities, COMPRESS_DEFLATE))\n {\n if (option (OPTIMAPDEFLATE) &&\n\t imap_exec (idata, \"COMPRESS DEFLATE\", IMAP_CMD_FAIL_OK) == 0)\n\tmutt_zstrm_wrap_conn (idata->conn);\n }\n#endif\n\n \/* enable RFC6855, if the server supports that *\/\n if (mutt_bit_isset (idata->capabilities, ENABLE))\n imap_exec (idata, \"ENABLE UTF8=ACCEPT\", IMAP_CMD_QUEUE);\n\n \/* enable QRESYNC. Advertising QRESYNC also means CONDSTORE\n * is supported (even if not advertised), so flip that bit. *\/\n if (mutt_bit_isset (idata->capabilities, QRESYNC))\n {\n mutt_bit_set (idata->capabilities, CONDSTORE);\n if (option (OPTIMAPQRESYNC))\n imap_exec (idata, \"ENABLE QRESYNC\", IMAP_CMD_QUEUE);\n }\n\n \/* get root delimiter, '\/' as default *\/\n idata->delim = '\/';\n imap_exec (idata, \"LIST \\\"\\\" \\\"\\\"\", IMAP_CMD_QUEUE);\n if (option (OPTIMAPCHECKSUBSCRIBED))\n imap_exec (idata, \"LSUB \\\"\\\" \\\"*\\\"\", IMAP_CMD_QUEUE);\n\n \/* we may need the root delimiter before we open a mailbox *\/\n imap_exec (idata, NULL, IMAP_CMD_FAIL_OK);\n }\n\n if (idata->state < IMAP_AUTHENTICATED)\n return NULL;\n\n return idata;\n}","target":0,"code_token_length":817,"total_token_length":1053,"max_tokens_setting":2048} +{"idx":179815,"func":"static rsRetVal createSocket(instanceConf_t* info, void** sock) {\n int rv;\n sublist* sub;\n\n *sock = zsocket_new(s_context, info->type);\n if (!sock) {\n errmsg.LogError(0,\n RS_RET_INVALID_PARAMS,\n \"zsocket_new failed: %s, for type %d\",\n zmq_strerror(errno),info->type);\n \/* DK: invalid params seems right here *\/\n return RS_RET_INVALID_PARAMS;\n }\n DBGPRINTF(\"imzmq3: socket of type %d created successfully\\n\", info->type)\n \/* Set options *before* the connect\/bind. *\/\n if (info->identity) zsocket_set_identity(*sock, info->identity);\n if (info->sndBuf > -1) zsocket_set_sndbuf(*sock, info->sndBuf);\n if (info->rcvBuf > -1) zsocket_set_rcvbuf(*sock, info->rcvBuf);\n if (info->linger > -1) zsocket_set_linger(*sock, info->linger);\n if (info->backlog > -1) zsocket_set_backlog(*sock, info->backlog);\n if (info->sndTimeout > -1) zsocket_set_sndtimeo(*sock, info->sndTimeout);\n if (info->rcvTimeout > -1) zsocket_set_rcvtimeo(*sock, info->rcvTimeout);\n if (info->maxMsgSize > -1) zsocket_set_maxmsgsize(*sock, info->maxMsgSize);\n if (info->rate > -1) zsocket_set_rate(*sock, info->rate);\n if (info->recoveryIVL > -1) zsocket_set_recovery_ivl(*sock, info->recoveryIVL);\n if (info->multicastHops > -1) zsocket_set_multicast_hops(*sock, info->multicastHops);\n if (info->reconnectIVL > -1) zsocket_set_reconnect_ivl(*sock, info->reconnectIVL);\n if (info->reconnectIVLMax > -1) zsocket_set_reconnect_ivl_max(*sock, info->reconnectIVLMax);\n if (info->ipv4Only > -1) zsocket_set_ipv4only(*sock, info->ipv4Only);\n if (info->affinity > -1) zsocket_set_affinity(*sock, info->affinity);\n if (info->sndHWM > -1 ) zsocket_set_sndhwm(*sock, info->sndHWM);\n if (info->rcvHWM > -1 ) zsocket_set_rcvhwm(*sock, info->rcvHWM);\n \/* Set subscriptions.*\/\n if (info->type == ZMQ_SUB) {\n for(sub = info->subscriptions; sub!=NULL; sub=sub->next) {\n zsocket_set_subscribe(*sock, sub->subscribe);\n }\n }\n \n \/* Do the bind\/connect... *\/\n if (info->action==ACTION_CONNECT) {\n rv = zsocket_connect(*sock, \"%s\", info->description);\n if (rv == -1) {\n errmsg.LogError(0,\n RS_RET_INVALID_PARAMS,\n \"zmq_connect using %s failed: %s\",\n info->description, zmq_strerror(errno));\n return RS_RET_INVALID_PARAMS;\n }\n DBGPRINTF(\"imzmq3: connect for %s successful\\n\",info->description);\n } else {\n rv = zsocket_bind(*sock, \"%s\", info->description);\n if (rv == -1) {\n errmsg.LogError(0,\n RS_RET_INVALID_PARAMS,\n \"zmq_bind using %s failed: %s\",\n info->description, zmq_strerror(errno));\n return RS_RET_INVALID_PARAMS;\n }\n DBGPRINTF(\"imzmq3: bind for %s successful\\n\",info->description);\n }\n return RS_RET_OK;\n}\n","target":0,"code_token_length":855,"total_token_length":1091,"max_tokens_setting":2048} +{"idx":225034,"func":"static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char *mime_type, int code, char *entry, int entry_len, char *arch, char *basename, char *ru, int ru_len TSRMLS_DC) \/* {{{ *\/\n{\n\tchar *name = NULL, buf[8192];\n\tconst char *cwd;\n\tzend_syntax_highlighter_ini syntax_highlighter_ini;\n\tsapi_header_line ctr = {0};\n\tsize_t got;\n\tint dummy = 1, name_len;\n\tzend_file_handle file_handle;\n\tzend_op_array *new_op_array;\n\tzval *result = NULL;\n\tphp_stream *fp;\n\toff_t position;\n\n\tswitch (code) {\n\t\tcase PHAR_MIME_PHPS:\n\t\t\tefree(basename);\n\t\t\t\/* highlight source *\/\n\t\t\tif (entry[0] == '\/') {\n\t\t\t\tname_len = spprintf(&name, 4096, \"phar:\/\/%s%s\", arch, entry);\n\t\t\t} else {\n\t\t\t\tname_len = spprintf(&name, 4096, \"phar:\/\/%s\/%s\", arch, entry);\n\t\t\t}\n\t\t\tphp_get_highlight_struct(&syntax_highlighter_ini);\n\n\t\t\thighlight_file(name, &syntax_highlighter_ini TSRMLS_CC);\n\n\t\t\tefree(name);\n#ifdef PHP_WIN32\n\t\t\tefree(arch);\n#endif\n\t\t\tzend_bailout();\n\t\tcase PHAR_MIME_OTHER:\n\t\t\t\/* send headers, output file contents *\/\n\t\t\tefree(basename);\n\t\t\tctr.line_len = spprintf(&(ctr.line), 0, \"Content-type: %s\", mime_type);\n\t\t\tsapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);\n\t\t\tefree(ctr.line);\n\t\t\tctr.line_len = spprintf(&(ctr.line), 0, \"Content-length: %u\", info->uncompressed_filesize);\n\t\t\tsapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);\n\t\t\tefree(ctr.line);\n\n\t\t\tif (FAILURE == sapi_send_headers(TSRMLS_C)) {\n\t\t\t\tzend_bailout();\n\t\t\t}\n\n\t\t\t\/* prepare to output *\/\n\t\t\tfp = phar_get_efp(info, 1 TSRMLS_CC);\n\n\t\t\tif (!fp) {\n\t\t\t\tchar *error;\n\t\t\t\tif (!phar_open_jit(phar, info, &error TSRMLS_CC)) {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, \"%s\", error);\n\t\t\t\t\t\tefree(error);\n\t\t\t\t\t}\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tfp = phar_get_efp(info, 1 TSRMLS_CC);\n\t\t\t}\n\t\t\tposition = 0;\n\t\t\tphar_seek_efp(info, 0, SEEK_SET, 0, 1 TSRMLS_CC);\n\n\t\t\tdo {\n\t\t\t\tgot = php_stream_read(fp, buf, MIN(8192, info->uncompressed_filesize - position));\n\t\t\t\tif (got > 0) {\n\t\t\t\t\tPHPWRITE(buf, got);\n\t\t\t\t\tposition += got;\n\t\t\t\t\tif (position == (off_t) info->uncompressed_filesize) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (1);\n\n\t\t\tzend_bailout();\n\t\tcase PHAR_MIME_PHP:\n\t\t\tif (basename) {\n\t\t\t\tphar_mung_server_vars(arch, entry, entry_len, basename, ru_len TSRMLS_CC);\n\t\t\t\tefree(basename);\n\t\t\t}\n\n\t\t\tif (entry[0] == '\/') {\n\t\t\t\tname_len = spprintf(&name, 4096, \"phar:\/\/%s%s\", arch, entry);\n\t\t\t} else {\n\t\t\t\tname_len = spprintf(&name, 4096, \"phar:\/\/%s\/%s\", arch, entry);\n\t\t\t}\n\n\t\t\tfile_handle.type = ZEND_HANDLE_FILENAME;\n\t\t\tfile_handle.handle.fd = 0;\n\t\t\tfile_handle.filename = name;\n\t\t\tfile_handle.opened_path = NULL;\n\t\t\tfile_handle.free_filename = 0;\n\n\t\t\tPHAR_G(cwd) = NULL;\n\t\t\tPHAR_G(cwd_len) = 0;\n\n\t\t\tif (zend_hash_add(&EG(included_files), name, name_len+1, (void *)&dummy, sizeof(int), NULL) == SUCCESS) {\n\t\t\t\tif ((cwd = zend_memrchr(entry, '\/', entry_len))) {\n\t\t\t\t\tPHAR_G(cwd_init) = 1;\n\t\t\t\t\tif (entry == cwd) {\n\t\t\t\t\t\t\/* root directory *\/\n\t\t\t\t\t\tPHAR_G(cwd_len) = 0;\n\t\t\t\t\t\tPHAR_G(cwd) = NULL;\n\t\t\t\t\t} else if (entry[0] == '\/') {\n\t\t\t\t\t\tPHAR_G(cwd_len) = cwd - (entry + 1);\n\t\t\t\t\t\tPHAR_G(cwd) = estrndup(entry + 1, PHAR_G(cwd_len));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tPHAR_G(cwd_len) = cwd - entry;\n\t\t\t\t\t\tPHAR_G(cwd) = estrndup(entry, PHAR_G(cwd_len));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnew_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);\n\n\t\t\t\tif (!new_op_array) {\n\t\t\t\t\tzend_hash_del(&EG(included_files), name, name_len+1);\n\t\t\t\t}\n\n\t\t\t\tzend_destroy_file_handle(&file_handle TSRMLS_CC);\n\n\t\t\t} else {\n\t\t\t\tefree(name);\n\t\t\t\tnew_op_array = NULL;\n\t\t\t}\n#ifdef PHP_WIN32\n\t\t\tefree(arch);\n#endif\n\t\t\tif (new_op_array) {\n\t\t\t\tEG(return_value_ptr_ptr) = &result;\n\t\t\t\tEG(active_op_array) = new_op_array;\n\n\t\t\t\tzend_try {\n\t\t\t\t\tzend_execute(new_op_array TSRMLS_CC);\n\t\t\t\t\tif (PHAR_G(cwd)) {\n\t\t\t\t\t\tefree(PHAR_G(cwd));\n\t\t\t\t\t\tPHAR_G(cwd) = NULL;\n\t\t\t\t\t\tPHAR_G(cwd_len) = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tPHAR_G(cwd_init) = 0;\n\t\t\t\t\tefree(name);\n\t\t\t\t\tdestroy_op_array(new_op_array TSRMLS_CC);\n\t\t\t\t\tefree(new_op_array);\n\n\n\t\t\t\t\tif (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) {\n\t\t\t\t\t\tzval_ptr_dtor(EG(return_value_ptr_ptr));\n\t\t\t\t\t}\n\t\t\t\t} zend_catch {\n\t\t\t\t\tif (PHAR_G(cwd)) {\n\t\t\t\t\t\tefree(PHAR_G(cwd));\n\t\t\t\t\t\tPHAR_G(cwd) = NULL;\n\t\t\t\t\t\tPHAR_G(cwd_len) = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tPHAR_G(cwd_init) = 0;\n\t\t\t\t\tefree(name);\n\t\t\t\t} zend_end_try();\n\n\t\t\t\tzend_bailout();\n\t\t\t}\n\n\t\t\treturn PHAR_MIME_PHP;\n\t}\n\treturn -1;\n}\n\/* }}} *\/\n","target":0,"code_token_length":1446,"total_token_length":1682,"max_tokens_setting":2048} +{"idx":404566,"func":"ecc_verify (gcry_sexp_t s_sig, gcry_sexp_t s_data, gcry_sexp_t s_keyparms)\n{\n gcry_err_code_t rc;\n struct pk_encoding_ctx ctx;\n gcry_sexp_t l1 = NULL;\n char *curvename = NULL;\n gcry_mpi_t mpi_g = NULL;\n gcry_mpi_t mpi_q = NULL;\n gcry_mpi_t sig_r = NULL;\n gcry_mpi_t sig_s = NULL;\n gcry_mpi_t data = NULL;\n ECC_public_key pk;\n int sigflags;\n\n memset (&pk, 0, sizeof pk);\n _gcry_pk_util_init_encoding_ctx (&ctx, PUBKEY_OP_VERIFY,\n ecc_get_nbits (s_keyparms));\n\n \/* Extract the data. *\/\n rc = _gcry_pk_util_data_to_mpi (s_data, &data, &ctx);\n if (rc)\n goto leave;\n if (DBG_CIPHER)\n log_mpidump (\"ecc_verify data\", data);\n\n \/*\n * Extract the signature value.\n *\/\n rc = _gcry_pk_util_preparse_sigval (s_sig, ecc_names, &l1, &sigflags);\n if (rc)\n goto leave;\n rc = sexp_extract_param (l1, NULL, (sigflags & PUBKEY_FLAG_EDDSA)? \"\/rs\":\"rs\",\n &sig_r, &sig_s, NULL);\n if (rc)\n goto leave;\n if (DBG_CIPHER)\n {\n log_mpidump (\"ecc_verify s_r\", sig_r);\n log_mpidump (\"ecc_verify s_s\", sig_s);\n }\n if ((ctx.flags & PUBKEY_FLAG_EDDSA) ^ (sigflags & PUBKEY_FLAG_EDDSA))\n {\n rc = GPG_ERR_CONFLICT; \/* Inconsistent use of flag\/algoname. *\/\n goto leave;\n }\n\n\n \/*\n * Extract the key.\n *\/\n if ((ctx.flags & PUBKEY_FLAG_PARAM))\n rc = sexp_extract_param (s_keyparms, NULL, \"-p?a?b?g?n?h?\/q\",\n &pk.E.p, &pk.E.a, &pk.E.b, &mpi_g, &pk.E.n,\n &pk.E.h, &mpi_q, NULL);\n else\n rc = sexp_extract_param (s_keyparms, NULL, \"\/q\",\n &mpi_q, NULL);\n if (rc)\n goto leave;\n if (mpi_g)\n {\n point_init (&pk.E.G);\n rc = _gcry_ecc_os2ec (&pk.E.G, mpi_g);\n if (rc)\n goto leave;\n }\n \/* Add missing parameters using the optional curve parameter. *\/\n sexp_release (l1);\n l1 = sexp_find_token (s_keyparms, \"curve\", 5);\n if (l1)\n {\n curvename = sexp_nth_string (l1, 1);\n if (curvename)\n {\n rc = _gcry_ecc_fill_in_curve (0, curvename, &pk.E, NULL);\n if (rc)\n goto leave;\n }\n }\n \/* Guess required fields if a curve parameter has not been given.\n FIXME: This is a crude hacks. We need to fix that. *\/\n if (!curvename)\n {\n pk.E.model = ((sigflags & PUBKEY_FLAG_EDDSA)\n ? MPI_EC_EDWARDS\n : MPI_EC_WEIERSTRASS);\n pk.E.dialect = ((sigflags & PUBKEY_FLAG_EDDSA)\n ? ECC_DIALECT_ED25519\n : ECC_DIALECT_STANDARD);\n if (!pk.E.h)\n\tpk.E.h = mpi_const (MPI_C_ONE);\n }\n\n if (DBG_CIPHER)\n {\n log_debug (\"ecc_verify info: %s\/%s%s\\n\",\n _gcry_ecc_model2str (pk.E.model),\n _gcry_ecc_dialect2str (pk.E.dialect),\n (sigflags & PUBKEY_FLAG_EDDSA)? \"+EdDSA\":\"\");\n if (pk.E.name)\n log_debug (\"ecc_verify name: %s\\n\", pk.E.name);\n log_printmpi (\"ecc_verify p\", pk.E.p);\n log_printmpi (\"ecc_verify a\", pk.E.a);\n log_printmpi (\"ecc_verify b\", pk.E.b);\n log_printpnt (\"ecc_verify g\", &pk.E.G, NULL);\n log_printmpi (\"ecc_verify n\", pk.E.n);\n log_printmpi (\"ecc_verify h\", pk.E.h);\n log_printmpi (\"ecc_verify q\", mpi_q);\n }\n if (!pk.E.p || !pk.E.a || !pk.E.b || !pk.E.G.x || !pk.E.n || !pk.E.h || !mpi_q)\n {\n rc = GPG_ERR_NO_OBJ;\n goto leave;\n }\n\n\n \/*\n * Verify the signature.\n *\/\n if ((sigflags & PUBKEY_FLAG_EDDSA))\n {\n rc = _gcry_ecc_eddsa_verify (data, &pk, sig_r, sig_s,\n ctx.hash_algo, mpi_q);\n }\n else if ((sigflags & PUBKEY_FLAG_GOST))\n {\n point_init (&pk.Q);\n rc = _gcry_ecc_os2ec (&pk.Q, mpi_q);\n if (rc)\n goto leave;\n\n rc = _gcry_ecc_gost_verify (data, &pk, sig_r, sig_s);\n }\n else\n {\n point_init (&pk.Q);\n if (pk.E.dialect == ECC_DIALECT_ED25519)\n {\n mpi_ec_t ec;\n\n \/* Fixme: Factor the curve context setup out of eddsa_verify\n and ecdsa_verify. So that we don't do it twice. *\/\n ec = _gcry_mpi_ec_p_internal_new (pk.E.model, pk.E.dialect, 0,\n pk.E.p, pk.E.a, pk.E.b);\n\n rc = _gcry_ecc_eddsa_decodepoint (mpi_q, ec, &pk.Q, NULL, NULL);\n _gcry_mpi_ec_free (ec);\n }\n else\n {\n rc = _gcry_ecc_os2ec (&pk.Q, mpi_q);\n }\n if (rc)\n goto leave;\n\n if (mpi_is_opaque (data))\n {\n const void *abuf;\n unsigned int abits, qbits;\n gcry_mpi_t a;\n\n qbits = mpi_get_nbits (pk.E.n);\n\n abuf = mpi_get_opaque (data, &abits);\n rc = _gcry_mpi_scan (&a, GCRYMPI_FMT_USG, abuf, (abits+7)\/8, NULL);\n if (!rc)\n {\n if (abits > qbits)\n mpi_rshift (a, a, abits - qbits);\n\n rc = _gcry_ecc_ecdsa_verify (a, &pk, sig_r, sig_s);\n _gcry_mpi_release (a);\n }\n }\n else\n rc = _gcry_ecc_ecdsa_verify (data, &pk, sig_r, sig_s);\n }\n\n leave:\n _gcry_mpi_release (pk.E.p);\n _gcry_mpi_release (pk.E.a);\n _gcry_mpi_release (pk.E.b);\n _gcry_mpi_release (mpi_g);\n point_free (&pk.E.G);\n _gcry_mpi_release (pk.E.n);\n _gcry_mpi_release (pk.E.h);\n _gcry_mpi_release (mpi_q);\n point_free (&pk.Q);\n _gcry_mpi_release (data);\n _gcry_mpi_release (sig_r);\n _gcry_mpi_release (sig_s);\n xfree (curvename);\n sexp_release (l1);\n _gcry_pk_util_free_encoding_ctx (&ctx);\n if (DBG_CIPHER)\n log_debug (\"ecc_verify => %s\\n\", rc?gpg_strerror (rc):\"Good\");\n return rc;\n}","target":0,"code_token_length":1750,"total_token_length":1986,"max_tokens_setting":2048} +{"idx":512685,"func":"int ssh_scp_init(ssh_scp scp)\n{\n int rc;\n char execbuffer[1024] = {0};\n char *quoted_location = NULL;\n size_t quoted_location_len = 0;\n size_t scp_location_len;\n\n if (scp == NULL) {\n return SSH_ERROR;\n }\n\n if (scp->state != SSH_SCP_NEW) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"ssh_scp_init called under invalid state\");\n return SSH_ERROR;\n }\n\n if (scp->location == NULL) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"Invalid scp context: location is NULL\");\n return SSH_ERROR;\n }\n\n SSH_LOG(SSH_LOG_PROTOCOL, \"Initializing scp session %s %son location '%s'\",\n scp->mode == SSH_SCP_WRITE?\"write\":\"read\",\n scp->recursive ? \"recursive \" : \"\",\n scp->location);\n\n scp->channel = ssh_channel_new(scp->session);\n if (scp->channel == NULL) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"Channel creation failed for scp\");\n scp->state = SSH_SCP_ERROR;\n return SSH_ERROR;\n }\n\n rc = ssh_channel_open_session(scp->channel);\n if (rc == SSH_ERROR) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"Failed to open channel for scp\");\n scp->state = SSH_SCP_ERROR;\n return SSH_ERROR;\n }\n\n \/* In the worst case, each character would be replaced by 3 plus the string\n * terminator '\\0' *\/\n scp_location_len = strlen(scp->location);\n quoted_location_len = ((size_t)3 * scp_location_len) + 1;\n \/* Paranoia check *\/\n if (quoted_location_len < scp_location_len) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"Buffer overflow detected\");\n scp->state = SSH_SCP_ERROR;\n return SSH_ERROR;\n }\n\n quoted_location = (char *)calloc(1, quoted_location_len);\n if (quoted_location == NULL) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"Failed to allocate memory for quoted location\");\n scp->state = SSH_SCP_ERROR;\n return SSH_ERROR;\n }\n\n rc = ssh_quote_file_name(scp->location, quoted_location,\n quoted_location_len);\n if (rc <= 0) {\n ssh_set_error(scp->session, SSH_FATAL,\n \"Failed to single quote command location\");\n SAFE_FREE(quoted_location);\n scp->state = SSH_SCP_ERROR;\n return SSH_ERROR;\n }\n\n if (scp->mode == SSH_SCP_WRITE) {\n snprintf(execbuffer, sizeof(execbuffer), \"scp -t %s %s\",\n scp->recursive ? \"-r\" : \"\", quoted_location);\n } else {\n snprintf(execbuffer, sizeof(execbuffer), \"scp -f %s %s\",\n scp->recursive ? \"-r\" : \"\", quoted_location);\n }\n\n SAFE_FREE(quoted_location);\n\n SSH_LOG(SSH_LOG_DEBUG, \"Executing command: %s\", execbuffer);\n\n rc = ssh_channel_request_exec(scp->channel, execbuffer);\n if (rc == SSH_ERROR){\n ssh_set_error(scp->session, SSH_FATAL,\n \"Failed executing command: %s\", execbuffer);\n scp->state = SSH_SCP_ERROR;\n return SSH_ERROR;\n }\n\n if (scp->mode == SSH_SCP_WRITE) {\n rc = ssh_scp_response(scp, NULL);\n if (rc != 0) {\n return SSH_ERROR;\n }\n } else {\n ssh_channel_write(scp->channel, \"\", 1);\n }\n\n if (scp->mode == SSH_SCP_WRITE) {\n scp->state = SSH_SCP_WRITE_INITED;\n } else {\n scp->state = SSH_SCP_READ_INITED;\n }\n\n return SSH_OK;\n}","target":0,"code_token_length":845,"total_token_length":1081,"max_tokens_setting":2048} +{"idx":345771,"func":"static HashTable* soap_create_typemap(sdlPtr sdl, HashTable *ht TSRMLS_DC)\n{\n\tzval **tmp;\n\tHashTable *ht2;\n\tHashPosition pos1, pos2;\n\tHashTable *typemap = NULL;\n\t\n\tzend_hash_internal_pointer_reset_ex(ht, &pos1);\n\twhile (zend_hash_get_current_data_ex(ht, (void**)&tmp, &pos1) == SUCCESS) {\n\t\tchar *type_name = NULL;\n\t\tchar *type_ns = NULL;\n\t\tzval *to_xml = NULL;\n\t\tzval *to_zval = NULL;\n\t\tencodePtr enc, new_enc;\n\n\t\tif (Z_TYPE_PP(tmp) != IS_ARRAY) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Wrong 'typemap' option\");\n\t\t\treturn NULL;\n\t\t}\n\t\tht2 = Z_ARRVAL_PP(tmp);\n\n\t\tzend_hash_internal_pointer_reset_ex(ht2, &pos2);\n\t\twhile (zend_hash_get_current_data_ex(ht2, (void**)&tmp, &pos2) == SUCCESS) {\n\t\t\tchar *name = NULL;\n\t\t\tunsigned int name_len;\n\t\t\tulong index;\n\n\t\t\tzend_hash_get_current_key_ex(ht2, &name, &name_len, &index, 0, &pos2);\n\t\t\tif (name) {\n\t\t\t\tif (name_len == sizeof(\"type_name\") &&\n\t\t\t\t strncmp(name, \"type_name\", sizeof(\"type_name\")-1) == 0) {\n\t\t\t\t\tif (Z_TYPE_PP(tmp) == IS_STRING) {\n\t\t\t\t\t\ttype_name = Z_STRVAL_PP(tmp);\n\t\t\t\t\t} else if (Z_TYPE_PP(tmp) != IS_NULL) {\n\t\t\t\t\t}\n\t\t\t\t} else if (name_len == sizeof(\"type_ns\") &&\n\t\t\t\t strncmp(name, \"type_ns\", sizeof(\"type_ns\")-1) == 0) {\n\t\t\t\t\tif (Z_TYPE_PP(tmp) == IS_STRING) {\n\t\t\t\t\t\ttype_ns = Z_STRVAL_PP(tmp);\n\t\t\t\t\t} else if (Z_TYPE_PP(tmp) != IS_NULL) {\n\t\t\t\t\t}\n\t\t\t\t} else if (name_len == sizeof(\"to_xml\") &&\n\t\t\t\t strncmp(name, \"to_xml\", sizeof(\"to_xml\")-1) == 0) {\n\t\t\t\t\tto_xml = *tmp;\n\t\t\t\t} else if (name_len == sizeof(\"from_xml\") &&\n\t\t\t\t strncmp(name, \"from_xml\", sizeof(\"from_xml\")-1) == 0) {\n\t\t\t\t\tto_zval = *tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t\tzend_hash_move_forward_ex(ht2, &pos2);\n\t\t}\t\t\n\n\t\tif (type_name) {\n\t\t\tsmart_str nscat = {0};\n\n\t\t\tif (type_ns) {\n\t\t\t\tenc = get_encoder(sdl, type_ns, type_name);\n\t\t\t} else {\n\t\t\t\tenc = get_encoder_ex(sdl, type_name, strlen(type_name));\n\t\t\t}\n\n\t\t\tnew_enc = emalloc(sizeof(encode));\n\t\t\tmemset(new_enc, 0, sizeof(encode));\n\n\t\t\tif (enc) {\n\t\t\t\tnew_enc->details.type = enc->details.type;\n\t\t\t\tnew_enc->details.ns = estrdup(enc->details.ns);\n\t\t\t\tnew_enc->details.type_str = estrdup(enc->details.type_str);\n\t\t\t\tnew_enc->details.sdl_type = enc->details.sdl_type;\n\t\t\t} else {\n\t\t\t\tenc = get_conversion(UNKNOWN_TYPE);\n\t\t\t\tnew_enc->details.type = enc->details.type;\n\t\t\t\tif (type_ns) {\n\t\t\t\t\tnew_enc->details.ns = estrdup(type_ns);\n\t\t\t\t}\n\t\t\t\tnew_enc->details.type_str = estrdup(type_name);\n\t\t\t}\n\t\t\tnew_enc->to_xml = enc->to_xml;\n\t\t\tnew_enc->to_zval = enc->to_zval;\n\t\t\tnew_enc->details.map = emalloc(sizeof(soapMapping));\n\t\t\tmemset(new_enc->details.map, 0, sizeof(soapMapping));\t\t\t\n\t\t\tif (to_xml) {\n\t\t\t\tzval_add_ref(&to_xml);\n\t\t\t\tnew_enc->details.map->to_xml = to_xml;\n\t\t\t\tnew_enc->to_xml = to_xml_user;\n\t\t\t} else if (enc->details.map && enc->details.map->to_xml) {\n\t\t\t\tzval_add_ref(&enc->details.map->to_xml);\n\t\t\t\tnew_enc->details.map->to_xml = enc->details.map->to_xml;\n\t\t\t}\n\t\t\tif (to_zval) {\n\t\t\t\tzval_add_ref(&to_zval);\n\t\t\t\tnew_enc->details.map->to_zval = to_zval;\n\t\t\t\tnew_enc->to_zval = to_zval_user;\n\t\t\t} else if (enc->details.map && enc->details.map->to_zval) {\n\t\t\t\tzval_add_ref(&enc->details.map->to_zval);\n\t\t\t\tnew_enc->details.map->to_zval = enc->details.map->to_zval;\n\t\t\t}\n\t\t\tif (!typemap) {\n\t\t\t\ttypemap = emalloc(sizeof(HashTable));\n\t\t\t\tzend_hash_init(typemap, 0, NULL, delete_encoder, 0);\n\t\t\t}\n\n\t\t\tif (type_ns) {\n\t\t\t\tsmart_str_appends(&nscat, type_ns);\n\t\t\t\tsmart_str_appendc(&nscat, ':');\n\t\t\t}\n\t\t\tsmart_str_appends(&nscat, type_name);\n\t\t\tsmart_str_0(&nscat);\n\t\t\tzend_hash_update(typemap, nscat.c, nscat.len + 1, &new_enc, sizeof(encodePtr), NULL);\n\t\t\tsmart_str_free(&nscat);\n\t\t}\n\t\tzend_hash_move_forward_ex(ht, &pos1);\n\t}\n\treturn typemap;\n}","target":1,"code_token_length":1177,"total_token_length":1413,"max_tokens_setting":2048} +{"idx":433742,"func":"print_smb(netdissect_options *ndo,\n const u_char *buf, const u_char *maxbuf)\n{\n uint16_t flags2;\n int nterrcodes;\n int command;\n uint32_t nterror;\n const u_char *words, *maxwords, *data;\n const struct smbfns *fn;\n const char *fmt_smbheader =\n \"[P4]SMB Command = [B]\\nError class = [BP1]\\nError code = [d]\\nFlags1 = [B]\\nFlags2 = [B][P13]\\nTree ID = [d]\\nProc ID = [d]\\nUID = [d]\\nMID = [d]\\nWord Count = [b]\\n\";\n int smboffset;\n\n ND_TCHECK(buf[9]);\n request = (buf[9] & 0x80) ? 0 : 1;\n startbuf = buf;\n\n command = buf[4];\n\n fn = smbfind(command, smb_fns);\n\n if (ndo->ndo_vflag > 1)\n\tND_PRINT((ndo, \"\\n\"));\n\n ND_PRINT((ndo, \"SMB PACKET: %s (%s)\\n\", fn->name, request ? \"REQUEST\" : \"REPLY\"));\n\n if (ndo->ndo_vflag < 2)\n\treturn;\n\n ND_TCHECK_16BITS(&buf[10]);\n flags2 = EXTRACT_LE_16BITS(&buf[10]);\n unicodestr = flags2 & 0x8000;\n nterrcodes = flags2 & 0x4000;\n\n \/* print out the header *\/\n smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr);\n\n if (nterrcodes) {\n \tnterror = EXTRACT_LE_32BITS(&buf[5]);\n\tif (nterror)\n\t ND_PRINT((ndo, \"NTError = %s\\n\", nt_errstr(nterror)));\n } else {\n\tif (buf[5])\n\t ND_PRINT((ndo, \"SMBError = %s\\n\", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))));\n }\n\n smboffset = 32;\n\n for (;;) {\n\tconst char *f1, *f2;\n\tint wct;\n\tu_int bcc;\n\tint newsmboffset;\n\n\twords = buf + smboffset;\n\tND_TCHECK(words[0]);\n\twct = words[0];\n\tdata = words + 1 + wct * 2;\n\tmaxwords = min(data, maxbuf);\n\n\tif (request) {\n\t f1 = fn->descript.req_f1;\n\t f2 = fn->descript.req_f2;\n\t} else {\n\t f1 = fn->descript.rep_f1;\n\t f2 = fn->descript.rep_f2;\n\t}\n\n\tif (fn->descript.fn)\n\t (*fn->descript.fn)(ndo, words, data, buf, maxbuf);\n\telse {\n\t if (wct) {\n\t\tif (f1)\n\t\t smb_fdata(ndo, words + 1, f1, words + 1 + wct * 2, unicodestr);\n\t\telse {\n\t\t int i;\n\t\t int v;\n\n\t\t for (i = 0; &words[1 + 2 * i] < maxwords; i++) {\n\t\t\tND_TCHECK2(words[1 + 2 * i], 2);\n\t\t\tv = EXTRACT_LE_16BITS(words + 1 + 2 * i);\n\t\t\tND_PRINT((ndo, \"smb_vwv[%d]=%d (0x%X)\\n\", i, v, v));\n\t\t }\n\t\t}\n\t }\n\n\t ND_TCHECK2(*data, 2);\n\t bcc = EXTRACT_LE_16BITS(data);\n\t ND_PRINT((ndo, \"smb_bcc=%u\\n\", bcc));\n\t if (f2) {\n\t\tif (bcc > 0)\n\t\t smb_fdata(ndo, data + 2, f2, data + 2 + bcc, unicodestr);\n\t } else {\n\t\tif (bcc > 0) {\n\t\t ND_PRINT((ndo, \"smb_buf[]=\\n\"));\n\t\t smb_print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2)));\n\t\t}\n\t }\n\t}\n\n\tif ((fn->flags & FLG_CHAIN) == 0)\n\t break;\n\tif (wct == 0)\n\t break;\n\tND_TCHECK(words[1]);\n\tcommand = words[1];\n\tif (command == 0xFF)\n\t break;\n\tND_TCHECK2(words[3], 2);\n\tnewsmboffset = EXTRACT_LE_16BITS(words + 3);\n\n\tfn = smbfind(command, smb_fns);\n\n\tND_PRINT((ndo, \"\\nSMB PACKET: %s (%s) (CHAINED)\\n\",\n\t fn->name, request ? \"REQUEST\" : \"REPLY\"));\n\tif (newsmboffset <= smboffset) {\n\t ND_PRINT((ndo, \"Bad andX offset: %u <= %u\\n\", newsmboffset, smboffset));\n\t break;\n\t}\n\tsmboffset = newsmboffset;\n }\n\n ND_PRINT((ndo, \"\\n\"));\n return;\ntrunc:\n ND_PRINT((ndo, \"%s\", tstr));\n}","target":0,"code_token_length":1189,"total_token_length":1425,"max_tokens_setting":2048} +{"idx":504759,"func":"rsvg_filter_primitive_composite_render (RsvgFilterPrimitive * self, RsvgFilterContext * ctx)\n{\n guchar i;\n gint x, y;\n gint rowstride, height, width;\n RsvgIRect boundarys;\n\n guchar *in_pixels;\n guchar *in2_pixels;\n guchar *output_pixels;\n\n RsvgFilterPrimitiveComposite *upself;\n\n GdkPixbuf *output;\n GdkPixbuf *in;\n GdkPixbuf *in2;\n\n upself = (RsvgFilterPrimitiveComposite *) self;\n boundarys = rsvg_filter_primitive_get_bounds (self, ctx);\n\n in = rsvg_filter_get_in (self->in, ctx);\n in_pixels = gdk_pixbuf_get_pixels (in);\n in2 = rsvg_filter_get_in (upself->in2, ctx);\n in2_pixels = gdk_pixbuf_get_pixels (in2);\n\n height = gdk_pixbuf_get_height (in);\n width = gdk_pixbuf_get_width (in);\n\n rowstride = gdk_pixbuf_get_rowstride (in);\n\n output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);\n output_pixels = gdk_pixbuf_get_pixels (output);\n\n if (upself->mode == COMPOSITE_MODE_ARITHMETIC)\n for (y = boundarys.y0; y < boundarys.y1; y++)\n for (x = boundarys.x0; x < boundarys.x1; x++) {\n int qr, qa, qb;\n\n qa = in_pixels[4 * x + y * rowstride + 3];\n qb = in2_pixels[4 * x + y * rowstride + 3];\n qr = (upself->k1 * qa * qb \/ 255 + upself->k2 * qa + upself->k3 * qb) \/ 255;\n\n if (qr > 255)\n qr = 255;\n if (qr < 0)\n qr = 0;\n output_pixels[4 * x + y * rowstride + 3] = qr;\n if (qr)\n for (i = 0; i < 3; i++) {\n int ca, cb, cr;\n ca = in_pixels[4 * x + y * rowstride + i];\n cb = in2_pixels[4 * x + y * rowstride + i];\n\n cr = (ca * cb * upself->k1 \/ 255 + ca * upself->k2 +\n cb * upself->k3 + upself->k4 * qr) \/ 255;\n if (cr > qr)\n cr = qr;\n if (cr < 0)\n cr = 0;\n output_pixels[4 * x + y * rowstride + i] = cr;\n\n }\n }\n\n else\n for (y = boundarys.y0; y < boundarys.y1; y++)\n for (x = boundarys.x0; x < boundarys.x1; x++) {\n int qr, cr, qa, qb, ca, cb, Fa, Fb, Fab, Fo;\n\n qa = in_pixels[4 * x + y * rowstride + 3];\n qb = in2_pixels[4 * x + y * rowstride + 3];\n cr = 0;\n Fa = Fb = Fab = Fo = 0;\n switch (upself->mode) {\n case COMPOSITE_MODE_OVER:\n Fa = 255;\n Fb = 255 - qa;\n break;\n case COMPOSITE_MODE_IN:\n Fa = qb;\n Fb = 0;\n break;\n case COMPOSITE_MODE_OUT:\n Fa = 255 - qb;\n Fb = 0;\n break;\n case COMPOSITE_MODE_ATOP:\n Fa = qb;\n Fb = 255 - qa;\n break;\n case COMPOSITE_MODE_XOR:\n Fa = 255 - qb;\n Fb = 255 - qa;\n break;\n default:\n break;\n }\n\n qr = (Fa * qa + Fb * qb) \/ 255;\n if (qr > 255)\n qr = 255;\n if (qr < 0)\n qr = 0;\n\n for (i = 0; i < 3; i++) {\n ca = in_pixels[4 * x + y * rowstride + i];\n cb = in2_pixels[4 * x + y * rowstride + i];\n\n cr = (ca * Fa + cb * Fb + ca * cb * Fab + Fo) \/ 255;\n if (cr > qr)\n cr = qr;\n if (cr < 0)\n cr = 0;\n output_pixels[4 * x + y * rowstride + i] = cr;\n\n }\n output_pixels[4 * x + y * rowstride + 3] = qr;\n }\n\n rsvg_filter_store_result (self->result, output, ctx);\n\n g_object_unref (in);\n g_object_unref (in2);\n g_object_unref (output);\n}","target":0,"code_token_length":1130,"total_token_length":1366,"max_tokens_setting":2048} +{"idx":496310,"func":"static bool ad_pack_xattrs(struct vfs_handle_struct *handle,\n\t\t\t struct adouble *ad,\n\t\t\t files_struct *fsp)\n{\n\tstruct ad_xattr_header *h = &ad->adx_header;\n\tsize_t oldsize;\n\tuint32_t off;\n\tuint32_t data_off;\n\tuint16_t i;\n\tbool ok;\n\n\tif (ad->adx_entries == NULL) {\n\t\t\/* No xattrs, nothing to pack *\/\n\t\treturn true;\n\t}\n\n\tif (fsp == NULL) {\n\t\tDBG_ERR(\"fsp unexpectedly NULL\\n\");\n\t\treturn false;\n\t}\n\n\toldsize = talloc_get_size(ad->ad_data);\n\tif (oldsize < AD_XATTR_MAX_HDR_SIZE) {\n\t\tad->ad_data = talloc_realloc(ad,\n\t\t\t\t\t ad->ad_data,\n\t\t\t\t\t char,\n\t\t\t\t\t AD_XATTR_MAX_HDR_SIZE);\n\t\tif (ad->ad_data == NULL) {\n\t\t\treturn false;\n\t\t}\n\t\tmemset(ad->ad_data + oldsize,\n\t\t 0,\n\t\t AD_XATTR_MAX_HDR_SIZE - oldsize);\n\t}\n\n\t\/*\n\t * First, let's calculate the start of the xattr data area which will be\n\t * after the xattr header + header entries.\n\t *\/\n\n\tdata_off = ad_getentryoff(ad, ADEID_FINDERI);\n\tdata_off += ADEDLEN_FINDERI + AD_XATTR_HDR_SIZE;\n\t\/* 2 bytes padding *\/\n\tdata_off += 2;\n\n\tfor (i = 0; i < h->adx_num_attrs; i++) {\n\t\tstruct ad_xattr_entry *e = &ad->adx_entries[i];\n\n\t\t\/* Align on 4 byte boundary *\/\n\t\tdata_off = (data_off + 3) & ~3;\n\n\t\tdata_off += e->adx_namelen + ADX_ENTRY_FIXED_SIZE;\n\t\tif (data_off >= AD_XATTR_MAX_HDR_SIZE) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\toff = ad_getentryoff(ad, ADEID_FINDERI);\n\toff += ADEDLEN_FINDERI + AD_XATTR_HDR_SIZE;\n\t\/* 2 bytes padding *\/\n\toff += 2;\n\n\tfor (i = 0; i < h->adx_num_attrs; i++) {\n\t\tstruct ad_xattr_entry *e = &ad->adx_entries[i];\n\n\t\t\/* Align on 4 byte boundary *\/\n\t\toff = (off + 3) & ~3;\n\n\t\te->adx_offset = data_off;\n\t\tdata_off += e->adx_length;\n\n\t\tDBG_DEBUG(\"%zu(%s){%zu}: off [%zu] adx_length [%zu] \"\n\t\t\t \"adx_data_off [%zu]\\n\",\n\t\t\t (size_t)i,\n\t\t\t e->adx_name,\n\t\t\t (size_t)e->adx_namelen,\n\t\t\t (size_t)off,\n\t\t\t (size_t)e->adx_length,\n\t\t\t (size_t)e->adx_offset);\n\n\t\tif (off + 4 >= AD_XATTR_MAX_HDR_SIZE) {\n\t\t\treturn false;\n\t\t}\n\t\tRSIVAL(ad->ad_data, off, e->adx_offset);\n\t\toff += 4;\n\n\t\tif (off + 4 >= AD_XATTR_MAX_HDR_SIZE) {\n\t\t\treturn false;\n\t\t}\n\t\tRSIVAL(ad->ad_data, off, e->adx_length);\n\t\toff += 4;\n\n\t\tif (off + 2 >= AD_XATTR_MAX_HDR_SIZE) {\n\t\t\treturn false;\n\t\t}\n\t\tRSSVAL(ad->ad_data, off, e->adx_flags);\n\t\toff += 2;\n\n\t\tif (off + 1 >= AD_XATTR_MAX_HDR_SIZE) {\n\t\t\treturn false;\n\t\t}\n\t\tSCVAL(ad->ad_data, off, e->adx_namelen);\n\t\toff += 1;\n\n\t\tif (off + e->adx_namelen >= AD_XATTR_MAX_HDR_SIZE) {\n\t\t\treturn false;\n\t\t}\n\t\tmemcpy(ad->ad_data + off, e->adx_name, e->adx_namelen);\n\t\toff += e->adx_namelen;\n\t}\n\n\th->adx_data_start = off;\n\th->adx_data_length = talloc_get_size(ad->adx_data);\n\th->adx_total_size = h->adx_data_start + h->adx_data_length;\n\n\tif (talloc_get_size(ad->ad_data) < h->adx_total_size) {\n\t\tad->ad_data = talloc_realloc(ad,\n\t\t\t\t\t ad->ad_data,\n\t\t\t\t\t char,\n\t\t\t\t\t h->adx_total_size);\n\t\tif (ad->ad_data == NULL) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tmemcpy(ad->ad_data + h->adx_data_start,\n\t ad->adx_data,\n\t h->adx_data_length);\n\n\tad_setentrylen(ad,\n\t\t ADEID_FINDERI,\n\t\t h->adx_total_size - ad_getentryoff(ad, ADEID_FINDERI));\n\n\tad_setentryoff(ad,\n\t\t ADEID_RFORK,\n\t\t ad_getentryoff(ad, ADEID_FINDERI) +\n\t\t ad_getentrylen(ad, ADEID_FINDERI));\n\n\tmemcpy(ad->ad_data + ADEDOFF_FILLER, AD_FILLER_TAG_OSX, ADEDLEN_FILLER);\n\n\t\/*\n\t * Rewind, then update the header fields.\n\t *\/\n\n\toff = ad_getentryoff(ad, ADEID_FINDERI) + ADEDLEN_FINDERI;\n\t\/* 2 bytes padding *\/\n\toff += 2;\n\n\tRSIVAL(ad->ad_data, off, AD_XATTR_HDR_MAGIC);\n\toff += 4;\n\tRSIVAL(ad->ad_data, off, 0);\n\toff += 4;\n\tRSIVAL(ad->ad_data, off, h->adx_total_size);\n\toff += 4;\n\tRSIVAL(ad->ad_data, off, h->adx_data_start);\n\toff += 4;\n\tRSIVAL(ad->ad_data, off, h->adx_data_length);\n\toff += 4;\n\n\t\/* adx_reserved and adx_flags *\/\n\tmemset(ad->ad_data + off, 0, 3 * 4 + 2);\n\toff += 3 * 4 + 2;\n\n\tRSSVAL(ad->ad_data, off, h->adx_num_attrs);\n\toff += 2;\n\n\tok = ad_pack_move_reso(handle, ad, fsp);\n\tif (!ok) {\n\t\tDBG_ERR(\"Moving resourcefork of [%s] failed\\n\",\n\t\t\tfsp_str_dbg(fsp));\n\t\treturn false;\n\t}\n\n\treturn true;\n}","target":0,"code_token_length":1351,"total_token_length":1587,"max_tokens_setting":2048} +{"idx":491413,"func":"display_debug_rnglists_list (unsigned char * start,\n\t\t\t unsigned char * finish,\n\t\t\t unsigned int pointer_size,\n\t\t\t dwarf_vma offset,\n\t\t\t dwarf_vma base_address,\n\t\t\t unsigned int offset_size)\n{\n unsigned char *next = start;\n unsigned int debug_addr_section_hdr_len;\n\n if (offset_size == 4)\n debug_addr_section_hdr_len = 8;\n else\n debug_addr_section_hdr_len = 16;\n\n while (1)\n {\n dwarf_vma off = offset + (start - next);\n enum dwarf_range_list_entry rlet;\n \/* Initialize it due to a false compiler warning. *\/\n dwarf_vma begin = -1, length, end = -1;\n\n if (start >= finish)\n\t{\n\t warn (_(\"Range list starting at offset 0x%s is not terminated.\\n\"),\n\t\tdwarf_vmatoa (\"x\", offset));\n\t break;\n\t}\n\n printf (\" \");\n print_dwarf_vma (off, 4);\n\n SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish);\n\n switch (rlet)\n\t{\n\tcase DW_RLE_end_of_list:\n\t printf (_(\"\\n\"));\n\t break;\n\tcase DW_RLE_base_addressx:\n\t READ_ULEB (base_address, start, finish);\n\t print_dwarf_vma (base_address, pointer_size);\n\t printf (_(\"(base address index) \"));\n\t base_address = fetch_indexed_addr ((base_address * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t print_dwarf_vma (base_address, pointer_size);\n\t printf (_(\"(base address)\\n\"));\n\t break;\n\tcase DW_RLE_startx_endx:\n\t READ_ULEB (begin, start, finish);\n\t READ_ULEB (end, start, finish);\n\t begin = fetch_indexed_addr ((begin * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t end = fetch_indexed_addr ((begin * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t break;\n\tcase DW_RLE_startx_length:\n\t READ_ULEB (begin, start, finish);\n\t READ_ULEB (length, start, finish);\n\t begin = fetch_indexed_addr ((begin * pointer_size)\n\t\t\t + debug_addr_section_hdr_len, pointer_size);\n\t end = begin + length;\n\t break;\n\tcase DW_RLE_offset_pair:\n\t READ_ULEB (begin, start, finish);\n\t READ_ULEB (end, start, finish);\n\t break;\n\tcase DW_RLE_base_address:\n\t SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish);\n\t print_dwarf_vma (base_address, pointer_size);\n\t printf (_(\"(base address)\\n\"));\n\t break;\n\tcase DW_RLE_start_end:\n\t SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);\n\t SAFE_BYTE_GET_AND_INC (end, start, pointer_size, finish);\n\t break;\n\tcase DW_RLE_start_length:\n\t SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);\n\t READ_ULEB (length, start, finish);\n\t end = begin + length;\n\t break;\n\tdefault:\n\t error (_(\"Invalid range list entry type %d\\n\"), rlet);\n\t rlet = DW_RLE_end_of_list;\n\t break;\n\t}\n\n if (rlet == DW_RLE_end_of_list)\n\tbreak;\n if (rlet == DW_RLE_base_address || rlet == DW_RLE_base_addressx)\n\tcontinue;\n\n \/* Only a DW_RLE_offset_pair needs the base address added. *\/\n if (rlet == DW_RLE_offset_pair)\n\t{\n\t begin += base_address;\n\t end += base_address;\n\t}\n\n print_dwarf_vma (begin, pointer_size);\n print_dwarf_vma (end, pointer_size);\n\n if (begin == end)\n\tfputs (_(\"(start == end)\"), stdout);\n else if (begin > end)\n\tfputs (_(\"(start > end)\"), stdout);\n\n putchar ('\\n');\n }\n\n return start;\n}","target":0,"code_token_length":872,"total_token_length":1108,"max_tokens_setting":2048} +{"idx":352427,"func":"static bool ad_unpack(struct adouble *ad, const size_t nentries,\n\t\t size_t filesize)\n{\n\tsize_t bufsize = talloc_get_size(ad->ad_data);\n\tsize_t adentries, i;\n\tuint32_t eid, len, off;\n\tbool ok;\n\n\t\/*\n\t * The size of the buffer ad->ad_data is checked when read, so\n\t * we wouldn't have to check our own offsets, a few extra\n\t * checks won't hurt though. We have to check the offsets we\n\t * read from the buffer anyway.\n\t *\/\n\n\tif (bufsize < (AD_HEADER_LEN + (AD_ENTRY_LEN * nentries))) {\n\t\tDEBUG(1, (\"bad size\\n\"));\n\t\treturn false;\n\t}\n\n\tad->ad_magic = RIVAL(ad->ad_data, 0);\n\tad->ad_version = RIVAL(ad->ad_data, ADEDOFF_VERSION);\n\tif ((ad->ad_magic != AD_MAGIC) || (ad->ad_version != AD_VERSION)) {\n\t\tDEBUG(1, (\"wrong magic or version\\n\"));\n\t\treturn false;\n\t}\n\n\tmemcpy(ad->ad_filler, ad->ad_data + ADEDOFF_FILLER, ADEDLEN_FILLER);\n\n\tadentries = RSVAL(ad->ad_data, ADEDOFF_NENTRIES);\n\tif (adentries != nentries) {\n\t\tDEBUG(1, (\"invalid number of entries: %zu\\n\",\n\t\t\t adentries));\n\t\treturn false;\n\t}\n\n\t\/* now, read in the entry bits *\/\n\tfor (i = 0; i < adentries; i++) {\n\t\teid = RIVAL(ad->ad_data, AD_HEADER_LEN + (i * AD_ENTRY_LEN));\n\t\teid = get_eid(eid);\n\t\toff = RIVAL(ad->ad_data, AD_HEADER_LEN + (i * AD_ENTRY_LEN) + 4);\n\t\tlen = RIVAL(ad->ad_data, AD_HEADER_LEN + (i * AD_ENTRY_LEN) + 8);\n\n\t\tif (!eid || eid >= ADEID_MAX) {\n\t\t\tDEBUG(1, (\"bogus eid %d\\n\", eid));\n\t\t\treturn false;\n\t\t}\n\n\t\t\/*\n\t\t * All entries other than the resource fork are\n\t\t * expected to be read into the ad_data buffer, so\n\t\t * ensure the specified offset is within that bound\n\t\t *\/\n\t\tif ((off > bufsize) && (eid != ADEID_RFORK)) {\n\t\t\tDEBUG(1, (\"bogus eid %d: off: %\" PRIu32 \", len: %\" PRIu32 \"\\n\",\n\t\t\t\t eid, off, len));\n\t\t\treturn false;\n\t\t}\n\n\t\t\/*\n\t\t * All entries besides FinderInfo and resource fork\n\t\t * must fit into the buffer. FinderInfo is special as\n\t\t * it may be larger then the default 32 bytes (if it\n\t\t * contains marshalled xattrs), but we will fixup that\n\t\t * in ad_convert(). And the resource fork is never\n\t\t * accessed directly by the ad_data buf (also see\n\t\t * comment above) anyway.\n\t\t *\/\n\t\tif ((eid != ADEID_RFORK) &&\n\t\t (eid != ADEID_FINDERI) &&\n\t\t ((off + len) > bufsize)) {\n\t\t\tDEBUG(1, (\"bogus eid %d: off: %\" PRIu32 \", len: %\" PRIu32 \"\\n\",\n\t\t\t\t eid, off, len));\n\t\t\treturn false;\n\t\t}\n\n\t\t\/*\n\t\t * That would be obviously broken\n\t\t *\/\n\t\tif (off > filesize) {\n\t\t\tDEBUG(1, (\"bogus eid %d: off: %\" PRIu32 \", len: %\" PRIu32 \"\\n\",\n\t\t\t\t eid, off, len));\n\t\t\treturn false;\n\t\t}\n\n\t\t\/*\n\t\t * Check for any entry that has its end beyond the\n\t\t * filesize.\n\t\t *\/\n\t\tif (off + len < off) {\n\t\t\tDEBUG(1, (\"offset wrap in eid %d: off: %\" PRIu32\n\t\t\t\t \", len: %\" PRIu32 \"\\n\",\n\t\t\t\t eid, off, len));\n\t\t\treturn false;\n\n\t\t}\n\t\tif (off + len > filesize) {\n\t\t\t\/*\n\t\t\t * If this is the resource fork entry, we fix\n\t\t\t * up the length, for any other entry we bail\n\t\t\t * out.\n\t\t\t *\/\n\t\t\tif (eid != ADEID_RFORK) {\n\t\t\t\tDEBUG(1, (\"bogus eid %d: off: %\" PRIu32\n\t\t\t\t\t \", len: %\" PRIu32 \"\\n\",\n\t\t\t\t\t eid, off, len));\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Fixup the resource fork entry by limiting\n\t\t\t * the size to entryoffset - filesize.\n\t\t\t *\/\n\t\t\tlen = filesize - off;\n\t\t\tDEBUG(1, (\"Limiting ADEID_RFORK: off: %\" PRIu32\n\t\t\t\t \", len: %\" PRIu32 \"\\n\", off, len));\n\t\t}\n\n\t\tad->ad_eid[eid].ade_off = off;\n\t\tad->ad_eid[eid].ade_len = len;\n\t}\n\n\tif (ad->ad_type == ADOUBLE_RSRC) {\n\t\tok = ad_unpack_xattrs(ad);\n\t\tif (!ok) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}","target":1,"code_token_length":1117,"total_token_length":1353,"max_tokens_setting":2048} +{"idx":140566,"func":"MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,\n const double attenuate,ExceptionInfo *exception)\n{\n#define AddNoiseImageTag \"AddNoise\/Image\"\n\n CacheView\n *image_view,\n *noise_view;\n\n Image\n *noise_image;\n\n MagickBooleanType\n status;\n\n MagickOffsetType\n progress;\n\n RandomInfo\n **magick_restrict random_info;\n\n ssize_t\n y;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n unsigned long\n key;\n#endif\n\n \/*\n Initialize noise image attributes.\n *\/\n assert(image != (const Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n#if defined(MAGICKCORE_OPENCL_SUPPORT)\n noise_image=AccelerateAddNoiseImage(image,noise_type,exception);\n if (noise_image != (Image *) NULL)\n return(noise_image);\n#endif\n noise_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);\n if (noise_image == (Image *) NULL)\n return((Image *) NULL);\n if (SetImageStorageClass(noise_image,DirectClass,exception) == MagickFalse)\n {\n noise_image=DestroyImage(noise_image);\n return((Image *) NULL);\n }\n \/*\n Add noise in each row.\n *\/\n status=MagickTrue;\n progress=0;\n random_info=AcquireRandomInfoThreadSet();\n image_view=AcquireVirtualCacheView(image,exception);\n noise_view=AcquireAuthenticCacheView(noise_image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n key=GetRandomSecretKey(random_info[0]);\n #pragma omp parallel for schedule(static,4) shared(progress,status) \\\n magick_threads(image,noise_image,image->rows,key == ~0UL)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n const int\n id = GetOpenMPThreadId();\n\n MagickBooleanType\n sync;\n\n register const Quantum\n *magick_restrict p;\n\n register ssize_t\n x;\n\n register Quantum\n *magick_restrict q;\n\n if (status == MagickFalse)\n continue;\n p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);\n q=QueueCacheViewAuthenticPixels(noise_view,0,y,noise_image->columns,1,\n exception);\n if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))\n {\n status=MagickFalse;\n continue;\n }\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n register ssize_t\n i;\n\n for (i=0; i < (ssize_t) GetPixelChannels(image); i++)\n {\n PixelChannel channel=GetPixelChannelChannel(image,i);\n PixelTrait traits=GetPixelChannelTraits(image,channel);\n PixelTrait noise_traits=GetPixelChannelTraits(noise_image,channel);\n if ((traits == UndefinedPixelTrait) ||\n (noise_traits == UndefinedPixelTrait))\n continue;\n if (((noise_traits & CopyPixelTrait) != 0) ||\n (GetPixelReadMask(image,p) == 0))\n {\n SetPixelChannel(noise_image,channel,p[i],q);\n continue;\n }\n SetPixelChannel(noise_image,channel,ClampToQuantum(\n GenerateDifferentialNoise(random_info[id],p[i],noise_type,attenuate)),\n q);\n }\n p+=GetPixelChannels(image);\n q+=GetPixelChannels(noise_image);\n }\n sync=SyncCacheViewAuthenticPixels(noise_view,exception);\n if (sync == MagickFalse)\n status=MagickFalse;\n if (image->progress_monitor != (MagickProgressMonitor) NULL)\n {\n MagickBooleanType\n proceed;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp critical (MagickCore_AddNoiseImage)\n#endif\n proceed=SetImageProgress(image,AddNoiseImageTag,progress++,\n image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n noise_view=DestroyCacheView(noise_view);\n image_view=DestroyCacheView(image_view);\n random_info=DestroyRandomInfoThreadSet(random_info);\n if (status == MagickFalse)\n noise_image=DestroyImage(noise_image);\n return(noise_image);\n}","target":0,"code_token_length":1013,"total_token_length":1249,"max_tokens_setting":2048} +{"idx":127225,"func":"auth_check2( httpd_conn* hc, char* dirname )\n {\n static char* authpath;\n static size_t maxauthpath = 0;\n struct stat sb;\n char authinfo[500];\n char* authpass;\n char* colon;\n int l;\n FILE* fp;\n char line[500];\n char* cryp;\n static char* prevauthpath;\n static size_t maxprevauthpath = 0;\n static time_t prevmtime;\n static char* prevuser;\n static size_t maxprevuser = 0;\n static char* prevcryp;\n static size_t maxprevcryp = 0;\n char *crypt_result;\n\n \/* Construct auth filename. *\/\n httpd_realloc_str(\n\t&authpath, &maxauthpath, strlen( dirname ) + 1 + sizeof(AUTH_FILE) );\n (void) my_snprintf( authpath, maxauthpath, \"%s\/%s\", dirname, AUTH_FILE );\n\n \/* Does this directory have an auth file? *\/\n if ( stat( authpath, &sb ) < 0 )\n\t\/* Nope, let the request go through. *\/\n\treturn 0;\n\n \/* Does this request contain basic authorization info? *\/\n if ( hc->authorization[0] == '\\0' ||\n\t strncmp( hc->authorization, \"Basic \", 6 ) != 0 )\n\t{\n\t\/* Nope, return a 401 Unauthorized. *\/\n\tsend_authenticate( hc, dirname );\n\treturn -1;\n\t}\n\n \/* Decode it. *\/\n l = b64_decode(\n\t&(hc->authorization[6]), (unsigned char*) authinfo,\n\tsizeof(authinfo) - 1 );\n authinfo[l] = '\\0';\n \/* Split into user and password. *\/\n authpass = strchr( authinfo, ':' );\n if ( authpass == (char*) 0 )\n\t{\n\t\/* No colon? Bogus auth info. *\/\n\tsend_authenticate( hc, dirname );\n\treturn -1;\n\t}\n *authpass++ = '\\0';\n \/* If there are more fields, cut them off. *\/\n colon = strchr( authpass, ':' );\n if ( colon != (char*) 0 )\n\t*colon = '\\0';\n\n \/* See if we have a cached entry and can use it. *\/\n if ( maxprevauthpath != 0 &&\n\t strcmp( authpath, prevauthpath ) == 0 &&\n\t sb.st_mtime == prevmtime &&\n\t strcmp( authinfo, prevuser ) == 0 )\n\t{\n\t\/* Yes. Check against the cached encrypted password. *\/\n\tcrypt_result = crypt( authpass, prevcryp );\n\tif ( ! crypt_result )\n\t return -1;\n\tif ( strcmp( crypt_result, prevcryp ) == 0 )\n\t {\n\t \/* Ok! *\/\n\t httpd_realloc_str(\n\t\t&hc->remoteuser, &hc->maxremoteuser, strlen( authinfo ) );\n\t (void) strcpy( hc->remoteuser, authinfo );\n\t return 1;\n\t }\n\telse\n\t {\n\t \/* No. *\/\n\t send_authenticate( hc, dirname );\n\t return -1;\n\t }\n\t}\n\n \/* Open the password file. *\/\n fp = fopen( authpath, \"r\" );\n if ( fp == (FILE*) 0 )\n\t{\n\t\/* The file exists but we can't open it? Disallow access. *\/\n\tsyslog(\n\t LOG_ERR, \"%.80s auth file %.80s could not be opened - %m\",\n\t httpd_ntoa( &hc->client_addr ), authpath );\n\thttpd_send_err(\n\t hc, 403, err403title, \"\",\n\t ERROR_FORM( err403form, \"The requested URL '%.80s' is protected by an authentication file, but the authentication file cannot be opened.\\n\" ),\n\t hc->encodedurl );\n\treturn -1;\n\t}\n\n \/* Read it. *\/\n while ( fgets( line, sizeof(line), fp ) != (char*) 0 )\n\t{\n\t\/* Nuke newline. *\/\n\tl = strlen( line );\n\tif ( line[l - 1] == '\\n' )\n\t line[l - 1] = '\\0';\n\t\/* Split into user and encrypted password. *\/\n\tcryp = strchr( line, ':' );\n\tif ( cryp == (char*) 0 )\n\t continue;\n\t*cryp++ = '\\0';\n\t\/* Is this the right user? *\/\n\tif ( strcmp( line, authinfo ) == 0 )\n\t {\n\t \/* Yes. *\/\n\t (void) fclose( fp );\n\t \/* So is the password right? *\/\n\t crypt_result = crypt( authpass, cryp );\n\t if ( ! crypt_result )\n\t\treturn -1;\n\t if ( strcmp( crypt_result, cryp ) == 0 )\n\t\t{\n\t\t\/* Ok! *\/\n\t\thttpd_realloc_str(\n\t\t &hc->remoteuser, &hc->maxremoteuser, strlen( line ) );\n\t\t(void) strcpy( hc->remoteuser, line );\n\t\t\/* And cache this user's info for next time. *\/\n\t\thttpd_realloc_str(\n\t\t &prevauthpath, &maxprevauthpath, strlen( authpath ) );\n\t\t(void) strcpy( prevauthpath, authpath );\n\t\tprevmtime = sb.st_mtime;\n\t\thttpd_realloc_str(\n\t\t &prevuser, &maxprevuser, strlen( authinfo ) );\n\t\t(void) strcpy( prevuser, authinfo );\n\t\thttpd_realloc_str( &prevcryp, &maxprevcryp, strlen( cryp ) );\n\t\t(void) strcpy( prevcryp, cryp );\n\t\treturn 1;\n\t\t}\n\t else\n\t\t{\n\t\t\/* No. *\/\n\t\tsend_authenticate( hc, dirname );\n\t\treturn -1;\n\t\t}\n\t }\n\t}\n\n \/* Didn't find that user. Access denied. *\/\n (void) fclose( fp );\n send_authenticate( hc, dirname );\n return -1;\n }","target":0,"code_token_length":1304,"total_token_length":1540,"max_tokens_setting":2048} +{"idx":87596,"func":"static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,\n\t\t\t\t u16 tss_selector, int idt_index, int reason,\n\t\t\t\t bool has_error_code, u32 error_code)\n{\n\tconst struct x86_emulate_ops *ops = ctxt->ops;\n\tstruct desc_struct curr_tss_desc, next_tss_desc;\n\tint ret;\n\tu16 old_tss_sel = get_segment_selector(ctxt, VCPU_SREG_TR);\n\tulong old_tss_base =\n\t\tops->get_cached_segment_base(ctxt, VCPU_SREG_TR);\n\tu32 desc_limit;\n\tulong desc_addr, dr7;\n\n\t\/* FIXME: old_tss_base == ~0 ? *\/\n\n\tret = read_segment_descriptor(ctxt, tss_selector, &next_tss_desc, &desc_addr);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\tret = read_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc, &desc_addr);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\n\t\/* FIXME: check that next_tss_desc is tss *\/\n\n\t\/*\n\t * Check privileges. The three cases are task switch caused by...\n\t *\n\t * 1. jmp\/call\/int to task gate: Check against DPL of the task gate\n\t * 2. Exception\/IRQ\/iret: No check is performed\n\t * 3. jmp\/call to TSS\/task-gate: No check is performed since the\n\t * hardware checks it before exiting.\n\t *\/\n\tif (reason == TASK_SWITCH_GATE) {\n\t\tif (idt_index != -1) {\n\t\t\t\/* Software interrupts *\/\n\t\t\tstruct desc_struct task_gate_desc;\n\t\t\tint dpl;\n\n\t\t\tret = read_interrupt_descriptor(ctxt, idt_index,\n\t\t\t\t\t\t\t&task_gate_desc);\n\t\t\tif (ret != X86EMUL_CONTINUE)\n\t\t\t\treturn ret;\n\n\t\t\tdpl = task_gate_desc.dpl;\n\t\t\tif ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl)\n\t\t\t\treturn emulate_gp(ctxt, (idt_index << 3) | 0x2);\n\t\t}\n\t}\n\n\tdesc_limit = desc_limit_scaled(&next_tss_desc);\n\tif (!next_tss_desc.p ||\n\t ((desc_limit < 0x67 && (next_tss_desc.type & 8)) ||\n\t desc_limit < 0x2b)) {\n\t\treturn emulate_ts(ctxt, tss_selector & 0xfffc);\n\t}\n\n\tif (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) {\n\t\tcurr_tss_desc.type &= ~(1 << 1); \/* clear busy flag *\/\n\t\twrite_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc);\n\t}\n\n\tif (reason == TASK_SWITCH_IRET)\n\t\tctxt->eflags = ctxt->eflags & ~X86_EFLAGS_NT;\n\n\t\/* set back link to prev task only if NT bit is set in eflags\n\t note that old_tss_sel is not used after this point *\/\n\tif (reason != TASK_SWITCH_CALL && reason != TASK_SWITCH_GATE)\n\t\told_tss_sel = 0xffff;\n\n\tif (next_tss_desc.type & 8)\n\t\tret = task_switch_32(ctxt, tss_selector, old_tss_sel,\n\t\t\t\t old_tss_base, &next_tss_desc);\n\telse\n\t\tret = task_switch_16(ctxt, tss_selector, old_tss_sel,\n\t\t\t\t old_tss_base, &next_tss_desc);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\n\tif (reason == TASK_SWITCH_CALL || reason == TASK_SWITCH_GATE)\n\t\tctxt->eflags = ctxt->eflags | X86_EFLAGS_NT;\n\n\tif (reason != TASK_SWITCH_IRET) {\n\t\tnext_tss_desc.type |= (1 << 1); \/* set busy flag *\/\n\t\twrite_segment_descriptor(ctxt, tss_selector, &next_tss_desc);\n\t}\n\n\tops->set_cr(ctxt, 0, ops->get_cr(ctxt, 0) | X86_CR0_TS);\n\tops->set_segment(ctxt, tss_selector, &next_tss_desc, 0, VCPU_SREG_TR);\n\n\tif (has_error_code) {\n\t\tctxt->op_bytes = ctxt->ad_bytes = (next_tss_desc.type & 8) ? 4 : 2;\n\t\tctxt->lock_prefix = 0;\n\t\tctxt->src.val = (unsigned long) error_code;\n\t\tret = em_push(ctxt);\n\t}\n\n\tops->get_dr(ctxt, 7, &dr7);\n\tops->set_dr(ctxt, 7, dr7 & ~(DR_LOCAL_ENABLE_MASK | DR_LOCAL_SLOWDOWN));\n\n\treturn ret;\n}","target":0,"code_token_length":1020,"total_token_length":1256,"max_tokens_setting":2048} +{"idx":195682,"func":"transform_info_imp(transform_display *dp, png_structp pp, png_infop pi)\n{\n \/* Reuse the standard stuff as appropriate. *\/\n standard_info_part1(&dp->this, pp, pi);\n\n \/* Now set the list of transforms. *\/\n dp->transform_list->set(dp->transform_list, dp, pp, pi);\n\n \/* Update the info structure for these transforms: *\/\n {\n int i = dp->this.use_update_info;\n \/* Always do one call, even if use_update_info is 0. *\/\n do\n png_read_update_info(pp, pi);\n while (--i > 0);\n }\n\n \/* And get the output information into the standard_display *\/\n standard_info_part2(&dp->this, pp, pi, 1\/*images*\/);\n\n \/* Plus the extra stuff we need for the transform tests: *\/\n\n dp->output_colour_type = png_get_color_type(pp, pi);\n dp->output_bit_depth = png_get_bit_depth(pp, pi);\n \n \/* If png_set_filler is in action then fake the output color type to include\n * an alpha channel where appropriate.\n *\/\n if (dp->output_bit_depth >= 8 &&\n (dp->output_colour_type == PNG_COLOR_TYPE_RGB ||\n dp->output_colour_type == PNG_COLOR_TYPE_GRAY) && dp->this.filler)\n dp->output_colour_type |= 4;\n\n \/* Validate the combination of colour type and bit depth that we are getting\n * out of libpng; the semantics of something not in the PNG spec are, at\n * best, unclear.\n *\/\n switch (dp->output_colour_type)\n {\n case PNG_COLOR_TYPE_PALETTE:\n if (dp->output_bit_depth > 8) goto error;\n \/*FALL THROUGH*\/\n case PNG_COLOR_TYPE_GRAY:\n if (dp->output_bit_depth == 1 || dp->output_bit_depth == 2 ||\n dp->output_bit_depth == 4)\n break;\n \/*FALL THROUGH*\/\n default:\n if (dp->output_bit_depth == 8 || dp->output_bit_depth == 16)\n break;\n \/*FALL THROUGH*\/\n error:\n {\n char message[128];\n size_t pos;\n\n pos = safecat(message, sizeof message, 0,\n \"invalid final bit depth: colour type(\");\n pos = safecatn(message, sizeof message, pos, dp->output_colour_type);\n pos = safecat(message, sizeof message, pos, \") with bit depth: \");\n pos = safecatn(message, sizeof message, pos, dp->output_bit_depth);\n\n png_error(pp, message);\n }\n\n }\n \n \/* Use a test pixel to check that the output agrees with what we expect -\n * this avoids running the whole test if the output is unexpected. This also\n * checks for internal errors.\n *\/\n {\n image_pixel test_pixel;\n\n memset(&test_pixel, 0, sizeof test_pixel);\n test_pixel.colour_type = dp->this.colour_type; \/* input *\/\n test_pixel.bit_depth = dp->this.bit_depth;\n if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE)\n test_pixel.sample_depth = 8;\n else\n test_pixel.sample_depth = test_pixel.bit_depth;\n\n \/* Don't need sBIT here, but it must be set to non-zero to avoid\n * arithmetic overflows.\n *\/\n test_pixel.have_tRNS = dp->this.is_transparent != 0;\n test_pixel.red_sBIT = test_pixel.green_sBIT = test_pixel.blue_sBIT =\n test_pixel.alpha_sBIT = test_pixel.sample_depth;\n \n dp->transform_list->mod(dp->transform_list, &test_pixel, pp, dp);\n\n if (test_pixel.colour_type != dp->output_colour_type)\n {\n char message[128];\n size_t pos = safecat(message, sizeof message, 0, \"colour type \");\n\n pos = safecatn(message, sizeof message, pos, dp->output_colour_type);\n pos = safecat(message, sizeof message, pos, \" expected \");\n pos = safecatn(message, sizeof message, pos, test_pixel.colour_type);\n\n png_error(pp, message);\n }\n\n if (test_pixel.bit_depth != dp->output_bit_depth)\n {\n char message[128];\n size_t pos = safecat(message, sizeof message, 0, \"bit depth \");\n\n pos = safecatn(message, sizeof message, pos, dp->output_bit_depth);\n pos = safecat(message, sizeof message, pos, \" expected \");\n pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth);\n\n png_error(pp, message);\n\n }\n \n \/* If both bit depth and colour type are correct check the sample depth.\n *\/\n if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE &&\n test_pixel.sample_depth != 8) \/* oops - internal error! *\/\n png_error(pp, \"pngvalid: internal: palette sample depth not 8\");\n else if (dp->unpacked && test_pixel.bit_depth != 8)\n png_error(pp, \"pngvalid: internal: bad unpacked pixel depth\");\n else if (!dp->unpacked && test_pixel.colour_type != PNG_COLOR_TYPE_PALETTE\n && test_pixel.bit_depth != test_pixel.sample_depth)\n {\n char message[128];\n size_t pos = safecat(message, sizeof message, 0,\n \"internal: sample depth \");\n \n \/* Because unless something has set 'unpacked' or the image is palette\n * mapped we expect the transform to keep sample depth and bit depth\n * the same.\n *\/\n pos = safecatn(message, sizeof message, pos, test_pixel.sample_depth);\n pos = safecat(message, sizeof message, pos, \" expected \");\n pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth);\n\n png_error(pp, message);\n }\n else if (test_pixel.bit_depth != dp->output_bit_depth)\n {\n \/* This could be a libpng error too; libpng has not produced what we\n * expect for the output bit depth.\n *\/\n char message[128];\n size_t pos = safecat(message, sizeof message, 0,\n \"internal: bit depth \");\n\n pos = safecatn(message, sizeof message, pos, dp->output_bit_depth);\n pos = safecat(message, sizeof message, pos, \" expected \");\n pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth);\n \n png_error(pp, message);\n }\n }\n}\n","target":0,"code_token_length":1399,"total_token_length":1635,"max_tokens_setting":2048} +{"idx":393677,"func":"PHP_FUNCTION(odbc_result)\n{\n\tchar *field;\n\tint field_ind;\n\tSQLSMALLINT sql_c_type = SQL_C_CHAR;\n\todbc_result *result;\n\tint i = 0;\n\tRETCODE rc;\n\tSQLLEN\tfieldsize;\n\tzval *pv_res, **pv_field;\n#ifdef HAVE_SQL_EXTENDED_FETCH\n\tSQLULEN crow;\n\tSQLUSMALLINT RowStatus[1];\n#endif\n\n\tfield_ind = -1;\n\tfield = NULL;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rZ\", &pv_res, &pv_field) == FAILURE) {\n\t\treturn;\n\t}\n\t\n\tif (Z_TYPE_PP(pv_field) == IS_STRING) {\n\t\tfield = Z_STRVAL_PP(pv_field);\n\t} else {\n\t\tconvert_to_long_ex(pv_field);\n\t\tfield_ind = Z_LVAL_PP(pv_field) - 1;\n\t}\n\t\n\tZEND_FETCH_RESOURCE(result, odbc_result *, &pv_res, -1, \"ODBC result\", le_result);\n\t\n\tif ((result->numcols == 0)) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"No tuples available at this result index\");\n\t\tRETURN_FALSE;\n\t}\n\t\n\t\/* get field index if the field parameter was a string *\/\n\tif (field != NULL) {\n\t\tif (result->values == NULL) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Result set contains no data\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\n\t\tfor(i = 0; i < result->numcols; i++) {\n\t\t\tif (!strcasecmp(result->values[i].name, field)) {\n\t\t\t\tfield_ind = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (field_ind < 0) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Field %s not found\", field);\n\t\t\tRETURN_FALSE;\n\t\t}\n\t} else {\n\t\t\/* check for limits of field_ind if the field parameter was an int *\/\n\t\tif (field_ind >= result->numcols || field_ind < 0) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Field index is larger than the number of fields\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\t}\n\n\tif (result->fetched == 0) {\n\t\t\/* User forgot to call odbc_fetch_row(), or wants to reload the results, do it now *\/\n#ifdef HAVE_SQL_EXTENDED_FETCH\n\t\tif (result->fetch_abs)\n\t\t\trc = SQLExtendedFetch(result->stmt, SQL_FETCH_NEXT, 1, &crow,RowStatus);\n\t\telse\n#endif\n\t\t\trc = SQLFetch(result->stmt);\n\n\t\tif (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\t\n\t\tresult->fetched++;\n\t}\n\n\tswitch(result->values[field_ind].coltype) {\n\t\tcase SQL_BINARY:\n\t\tcase SQL_VARBINARY:\n\t\tcase SQL_LONGVARBINARY:\n\t\t\tif (result->binmode <= 1) {\n\t\t\t\tsql_c_type = SQL_C_BINARY;\n\t\t\t}\n\t\t\tif (result->binmode <= 0) {\n\t\t\t\tbreak; \n\t\t\t}\n\t\tcase SQL_LONGVARCHAR:\n#if defined(ODBCVER) && (ODBCVER >= 0x0300)\n\t\tcase SQL_WLONGVARCHAR:\n#endif\n\t\t\tif (IS_SQL_LONG(result->values[field_ind].coltype)) {\n\t\t\t\tif (result->longreadlen <= 0) {\n\t\t\t\t break;\n\t\t\t\t} else {\n\t\t\t\t fieldsize = result->longreadlen;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t PHP_ODBC_SQLCOLATTRIBUTE(result->stmt, (SQLUSMALLINT)(field_ind + 1), \n\t\t\t\t\t \t\t\t(SQLUSMALLINT)((sql_c_type == SQL_C_BINARY) ? SQL_COLUMN_LENGTH :\n\t\t\t\t\t \t\t\tSQL_COLUMN_DISPLAY_SIZE),\n\t\t\t\t\t \t\t\tNULL, 0, NULL, &fieldsize);\n\t\t\t}\n\t\t\t\/* For char data, the length of the returned string will be longreadlen - 1 *\/\n\t\t\tfieldsize = (result->longreadlen <= 0) ? 4096 : result->longreadlen;\n\t\t\tfield = emalloc(fieldsize);\n\n\t\t\/* SQLGetData will truncate CHAR data to fieldsize - 1 bytes and append \\0.\n\t\t * For binary data it is truncated to fieldsize bytes. \n\t\t *\/\n\t\t\trc = SQLGetData(result->stmt, (SQLUSMALLINT)(field_ind + 1), sql_c_type,\n\t\t\t\t\t\t\tfield, fieldsize, &result->values[field_ind].vallen);\n\n\t\t\tif (rc == SQL_ERROR) {\n\t\t\t\todbc_sql_error(result->conn_ptr, result->stmt, \"SQLGetData\");\n\t\t\t\tefree(field);\n\t\t\t\tRETURN_FALSE;\n\t\t\t}\n\n\t\t\tif (result->values[field_ind].vallen == SQL_NULL_DATA) {\n\t\t\t\tefree(field);\n\t\t\t\tRETURN_NULL();\n\t\t\t} else if (rc == SQL_NO_DATA_FOUND) {\n\t\t\t\tefree(field);\n\t\t\t\tRETURN_FALSE;\n\t\t\t}\n\t\t\t\/* Reduce fieldlen by 1 if we have char data. One day we might \n\t\t\t have binary strings... *\/\n\t\t\tif ((result->values[field_ind].coltype == SQL_LONGVARCHAR)\n#if defined(ODBCVER) && (ODBCVER >= 0x0300)\n\t\t\t || (result->values[field_ind].coltype == SQL_WLONGVARCHAR)\n#endif\n\t\t\t) {\n\t\t\t\tfieldsize -= 1;\n\t\t\t}\n\t\t\t\/* Don't duplicate result, saves one emalloc.\n\t\t\t For SQL_SUCCESS, the length is in vallen.\n\t\t\t *\/\n\t\t\tRETURN_STRINGL(field, (rc == SQL_SUCCESS_WITH_INFO) ? fieldsize : result->values[field_ind].vallen, 0);\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\tif (result->values[field_ind].vallen == SQL_NULL_DATA) {\n\t\t\t\tRETURN_NULL();\n\t\t\t} else {\n\t\t\t\tRETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen, 1);\n\t\t\t}\n\t\t\tbreak;\n\t}\n\n\/* If we come here, output unbound LONG and\/or BINARY column data to the client *\/\n\t\n\t\/* We emalloc 1 byte more for SQL_C_CHAR (trailing \\0) *\/\n\tfieldsize = (sql_c_type == SQL_C_CHAR) ? 4096 : 4095;\n\tfield = emalloc(fieldsize);\n\t\n\t\/* Call SQLGetData() until SQL_SUCCESS is returned *\/\n\twhile(1) {\n\t\trc = SQLGetData(result->stmt, (SQLUSMALLINT)(field_ind + 1),sql_c_type, field, fieldsize, &result->values[field_ind].vallen);\n\n\t\tif (rc == SQL_ERROR) {\n\t\t\todbc_sql_error(result->conn_ptr, result->stmt, \"SQLGetData\");\n\t\t\tefree(field);\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\t\n\t\tif (result->values[field_ind].vallen == SQL_NULL_DATA) {\n\t\t\tefree(field);\n\t\t\tRETURN_NULL();\n\t\t}\n\t\t\/* chop the trailing \\0 by outputing only 4095 bytes *\/\n\t\tPHPWRITE(field,(rc == SQL_SUCCESS_WITH_INFO) ? 4095 : result->values[field_ind].vallen);\n\n\t\tif (rc == SQL_SUCCESS) { \/* no more data avail *\/\n\t\t\tefree(field);\n\t\t\tRETURN_TRUE;\n\t\t}\n\t}\n\tRETURN_TRUE;\n}","target":0,"code_token_length":1558,"total_token_length":1794,"max_tokens_setting":2048} +{"idx":521428,"func":"setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,\n\t\t Ref_ptr_array ref_pointer_array,\n\t\t List &res_selected_fields, List &res_all_fields,\n\t\t uint elements, List &all_fields)\n{\n Item *pos;\n List_iterator_fast li(all_fields);\n Copy_field *copy= NULL;\n Copy_field *copy_start __attribute__((unused));\n res_selected_fields.empty();\n res_all_fields.empty();\n List_iterator_fast itr(res_all_fields);\n List extra_funcs;\n uint i, border= all_fields.elements - elements;\n DBUG_ENTER(\"setup_copy_fields\");\n\n if (param->field_count && \n !(copy=param->copy_field= new (thd->mem_root) Copy_field[param->field_count]))\n goto err2;\n\n param->copy_funcs.empty();\n copy_start= copy;\n for (i= 0; (pos= li++); i++)\n {\n Field *field;\n uchar *tmp;\n Item *real_pos= pos->real_item();\n \/*\n Aggregate functions can be substituted for fields (by e.g. temp tables).\n We need to filter those substituted fields out.\n *\/\n if (real_pos->type() == Item::FIELD_ITEM &&\n !(real_pos != pos &&\n ((Item_ref *)pos)->ref_type() == Item_ref::AGGREGATE_REF))\n {\n Item_field *item;\n if (!(item= new (thd->mem_root) Item_field(thd, ((Item_field*) real_pos))))\n\tgoto err;\n if (pos->type() == Item::REF_ITEM)\n {\n \/* preserve the names of the ref when dereferncing *\/\n Item_ref *ref= (Item_ref *) pos;\n item->db_name= ref->db_name;\n item->table_name= ref->table_name;\n item->name= ref->name;\n }\n pos= item;\n if (item->field->flags & BLOB_FLAG)\n {\n\tif (!(pos= new (thd->mem_root) Item_copy_string(thd, pos)))\n\t goto err;\n \/*\n Item_copy_string::copy for function can call \n Item_copy_string::val_int for blob via Item_ref.\n But if Item_copy_string::copy for blob isn't called before,\n it's value will be wrong\n so let's insert Item_copy_string for blobs in the beginning of \n copy_funcs\n (to see full test case look at having.test, BUG #4358) \n *\/\n\tif (param->copy_funcs.push_front(pos, thd->mem_root))\n\t goto err;\n }\n else\n {\n\t\/* \n\t set up save buffer and change result_field to point at \n\t saved value\n\t*\/\n\tfield= item->field;\n\titem->result_field=field->make_new_field(thd->mem_root,\n field->table, 1);\n \/*\n We need to allocate one extra byte for null handling and\n another extra byte to not get warnings from purify in\n Field_string::val_int\n *\/\n\tif (!(tmp= (uchar*) thd->alloc(field->pack_length()+2)))\n\t goto err;\n if (copy)\n {\n DBUG_ASSERT (param->field_count > (uint) (copy - copy_start));\n copy->set(tmp, item->result_field);\n item->result_field->move_field(copy->to_ptr,copy->to_null_ptr,1);\n#ifdef HAVE_valgrind\n copy->to_ptr[copy->from_length]= 0;\n#endif\n copy++;\n }\n }\n }\n else if ((real_pos->type() == Item::FUNC_ITEM ||\n\t real_pos->real_type() == Item::SUBSELECT_ITEM ||\n\t real_pos->type() == Item::CACHE_ITEM ||\n\t real_pos->type() == Item::COND_ITEM) &&\n\t !real_pos->with_sum_func)\n {\t\t\t\t\t\t\/\/ Save for send fields\n pos= real_pos;\n \/* TODO:\n\t In most cases this result will be sent to the user.\n\t This should be changed to use copy_int or copy_real depending\n\t on how the value is to be used: In some cases this may be an\n\t argument in a group function, like: IF(ISNULL(col),0,COUNT(*))\n *\/\n if (!(pos=new (thd->mem_root) Item_copy_string(thd, pos)))\n\tgoto err;\n if (i < border) \/\/ HAVING, ORDER and GROUP BY\n {\n if (extra_funcs.push_back(pos, thd->mem_root))\n goto err;\n }\n else if (param->copy_funcs.push_back(pos, thd->mem_root))\n\tgoto err;\n }\n res_all_fields.push_back(pos, thd->mem_root);\n ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]=\n pos;\n }\n param->copy_field_end= copy;\n\n for (i= 0; i < border; i++)\n itr++;\n itr.sublist(res_selected_fields, elements);\n \/*\n Put elements from HAVING, ORDER BY and GROUP BY last to ensure that any\n reference used in these will resolve to a item that is already calculated\n *\/\n param->copy_funcs.append(&extra_funcs);\n\n DBUG_RETURN(0);\n\n err:\n if (copy)\n delete [] param->copy_field;\t\t\t\/\/ This is never 0\n param->copy_field= 0;\nerr2:\n DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":1177,"total_token_length":1413,"max_tokens_setting":2048} +{"idx":364504,"func":"die(int sig)\n{\n\tchar buf[256];\n\n\tDBGPRINTF(\"exiting on signal %d\\n\", sig);\n\n\t\/* IMPORTANT: we should close the inputs first, and THEN send our termination\n\t * message. If we do it the other way around, logmsgInternal() may block on\n\t * a full queue and the inputs still fill up that queue. Depending on the\n\t * scheduling order, we may end up with logmsgInternal being held for a quite\n\t * long time. When the inputs are terminated first, that should not happen\n\t * because the queue is drained in parallel. The situation could only become\n\t * an issue with extremely long running actions in a queue full environment.\n\t * However, such actions are at least considered poorly written, if not\n\t * outright wrong. So we do not care about this very remote problem.\n\t * rgerhards, 2008-01-11\n\t *\/\n\n\t\/* close the inputs *\/\n\tDBGPRINTF(\"Terminating input threads...\\n\");\n\tthrdTerminateAll();\n\n\t\/* and THEN send the termination log message (see long comment above) *\/\n\tif (sig) {\n\t\t(void) snprintf(buf, sizeof(buf) \/ sizeof(char),\n\t\t \" [origin software=\\\"rsyslogd\\\" \" \"swVersion=\\\"\" VERSION \\\n\t\t \"\\\" x-pid=\\\"%d\\\" x-info=\\\"http:\/\/www.rsyslog.com\\\"]\" \" exiting on signal %d.\",\n\t\t (int) myPid, sig);\n\t\terrno = 0;\n\t\tlogmsgInternal(NO_ERRCODE, LOG_SYSLOG|LOG_INFO, (uchar*)buf, 0);\n\t}\n\t\n\t\/* drain queue (if configured so) and stop main queue worker thread pool *\/\n\tDBGPRINTF(\"Terminating main queue...\\n\");\n\tqqueueDestruct(&pMsgQueue);\n\tpMsgQueue = NULL;\n\n\t\/* Free ressources and close connections. This includes flushing any remaining\n\t * repeated msgs.\n\t *\/\n\tDBGPRINTF(\"Terminating outputs...\\n\");\n\tdestructAllActions();\n\n\tDBGPRINTF(\"all primary multi-thread sources have been terminated - now doing aux cleanup...\\n\");\n\t\/* rger 2005-02-22\n\t * now clean up the in-memory structures. OK, the OS\n\t * would also take care of that, but if we do it\n\t * ourselfs, this makes finding memory leaks a lot\n\t * easier.\n\t *\/\n\ttplDeleteAll();\n\n\tremove_pid(PidFile);\n\n\t\/* de-init some modules *\/\n\tmodExitIminternal();\n\n\t\/*dbgPrintAllDebugInfo(); \/ * this is the last spot where this can be done - below output modules are unloaded! *\/\n\n\t\/* the following line cleans up CfSysLineHandlers that were not based on loadable\n\t * modules. As such, they are not yet cleared.\n\t *\/\n\tunregCfSysLineHdlrs();\n\n\tlegacyOptsFree();\n\n\t\/* destruct our global properties *\/\n\tif(pInternalInputName != NULL)\n\t\tprop.Destruct(&pInternalInputName);\n\tif(pLocalHostIP != NULL)\n\t\tprop.Destruct(&pLocalHostIP);\n\n\t\/* terminate the remaining classes *\/\n\tGlobalClassExit();\n\n\t\/* TODO: this would also be the right place to de-init the builtin output modules. We\n\t * do not currently do that, because the module interface does not allow for\n\t * it. This will come some time later (it's essential with loadable modules).\n\t * For the time being, this is a memory leak on exit, but as the process is\n\t * terminated, we do not really bother about it.\n\t * rgerhards, 2007-08-03\n\t * I have added some code now, but all that mod init\/de-init should be moved to\n\t * init, so that modules are unloaded and reloaded on HUP to. Eventually it should go\n\t * into destructAllActions() - but that needs to be seen. -- rgerhards, 2007-08-09\n\t *\/\n\tmodule.UnloadAndDestructAll(eMOD_LINK_ALL);\n\n\tDBGPRINTF(\"Clean shutdown completed, bye\\n\");\n\t\/* dbgClassExit MUST be the last one, because it de-inits the debug system *\/\n\tdbgClassExit();\n\n\t\/* free all remaining memory blocks - this is not absolutely necessary, but helps\n\t * us keep memory debugger logs clean and this is in aid in developing. It doesn't\n\t * cost much time, so we do it always. -- rgerhards, 2008-03-20\n\t *\/\n\tfreeAllDynMemForTermination();\n\t\/* NO CODE HERE - feeelAllDynMemForTermination() must be the last thing before exit()! *\/\n\texit(0); \/* \"good\" exit, this is the terminator function for rsyslog [die()] *\/\n}","target":0,"code_token_length":1021,"total_token_length":1257,"max_tokens_setting":2048} +{"idx":225444,"func":"static MagickBooleanType DecodeImage(Image *image,\n const MagickBooleanType compression,unsigned char *pixels)\n{\n#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__) || defined(__MINGW64__)\n#define BI_RGB 0\n#define BI_RLE8 1\n#define BI_RLE4 2\n#define BI_BITFIELDS 3\n#endif\n\n int\n count;\n\n ssize_t\n y;\n\n register ssize_t\n i,\n x;\n\n register unsigned char\n *p,\n *q;\n\n unsigned char\n byte;\n\n assert(image != (Image *) NULL);\n assert(image->signature == MagickSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(pixels != (unsigned char *) NULL);\n (void) ResetMagickMemory(pixels,0,(size_t) image->columns*image->rows*\n sizeof(*pixels));\n byte=0;\n x=0;\n p=pixels;\n q=pixels+(size_t) image->columns*image->rows;\n for (y=0; y < (ssize_t) image->rows; )\n {\n if ((p < pixels) || (p >= q))\n break;\n count=ReadBlobByte(image);\n if (count == EOF)\n break;\n if (count != 0)\n {\n count=(int) MagickMin((size_t) count,(size_t) (q-p));\n \/*\n Encoded mode.\n *\/\n byte=(unsigned char) ReadBlobByte(image);\n if (compression == BI_RLE8)\n {\n for (i=0; i < count; i++)\n *p++=(unsigned char) byte;\n }\n else\n {\n for (i=0; i < count; i++)\n *p++=(unsigned char)\n ((i & 0x01) != 0 ? (byte & 0x0f) : ((byte >> 4) & 0x0f));\n }\n x+=count;\n }\n else\n {\n \/*\n Escape mode.\n *\/\n count=ReadBlobByte(image);\n if (count == 0x01)\n return(MagickTrue);\n switch (count)\n {\n case 0x00:\n {\n \/*\n End of line.\n *\/\n x=0;\n y++;\n p=pixels+y*image->columns;\n break;\n }\n case 0x02:\n {\n \/*\n Delta mode.\n *\/\n x+=ReadBlobByte(image);\n y+=ReadBlobByte(image);\n p=pixels+y*image->columns+x;\n break;\n }\n default:\n {\n \/*\n Absolute mode.\n *\/\n count=(int) MagickMin((size_t) count,(size_t) (q-p));\n if (compression == BI_RLE8)\n for (i=0; i < count; i++)\n *p++=(unsigned char) ReadBlobByte(image);\n else\n for (i=0; i < count; i++)\n {\n if ((i & 0x01) == 0)\n byte=(unsigned char) ReadBlobByte(image);\n *p++=(unsigned char)\n ((i & 0x01) != 0 ? (byte & 0x0f) : ((byte >> 4) & 0x0f));\n }\n x+=count;\n \/*\n Read pad byte.\n *\/\n if (compression == BI_RLE8)\n {\n if ((count & 0x01) != 0)\n (void) ReadBlobByte(image);\n }\n else\n if (((count & 0x03) == 1) || ((count & 0x03) == 2))\n (void) ReadBlobByte(image);\n break;\n }\n }\n }\n if (SetImageProgress(image,LoadImageTag,y,image->rows) == MagickFalse)\n break;\n }\n (void) ReadBlobByte(image); \/* end of line *\/\n (void) ReadBlobByte(image);\n return(MagickTrue);\n}\n","target":0,"code_token_length":920,"total_token_length":1156,"max_tokens_setting":2048} +{"idx":266579,"func":"static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)\n\n{\n\n const uint16_t *end;\n\n const uint16_t *mm_end;\n\n uint8_t *d = (uint8_t *)dst;\n\n const uint16_t *s = (const uint16_t *)src;\n\n end = s + src_size\/2;\n\n __asm__ volatile(PREFETCH\" %0\"::\"m\"(*s):\"memory\");\n\n mm_end = end - 7;\n\n while (s < mm_end) {\n\n __asm__ volatile(\n\n PREFETCH\" 32%1 \\n\\t\"\n\n \"movq %1, %%mm0 \\n\\t\"\n\n \"movq %1, %%mm1 \\n\\t\"\n\n \"movq %1, %%mm2 \\n\\t\"\n\n \"pand %2, %%mm0 \\n\\t\"\n\n \"pand %3, %%mm1 \\n\\t\"\n\n \"pand %4, %%mm2 \\n\\t\"\n\n \"psllq $3, %%mm0 \\n\\t\"\n\n \"psrlq $3, %%mm1 \\n\\t\"\n\n \"psrlq $8, %%mm2 \\n\\t\"\n\n \"movq %%mm0, %%mm3 \\n\\t\"\n\n \"movq %%mm1, %%mm4 \\n\\t\"\n\n \"movq %%mm2, %%mm5 \\n\\t\"\n\n \"punpcklwd %5, %%mm0 \\n\\t\"\n\n \"punpcklwd %5, %%mm1 \\n\\t\"\n\n \"punpcklwd %5, %%mm2 \\n\\t\"\n\n \"punpckhwd %5, %%mm3 \\n\\t\"\n\n \"punpckhwd %5, %%mm4 \\n\\t\"\n\n \"punpckhwd %5, %%mm5 \\n\\t\"\n\n \"psllq $8, %%mm1 \\n\\t\"\n\n \"psllq $16, %%mm2 \\n\\t\"\n\n \"por %%mm1, %%mm0 \\n\\t\"\n\n \"por %%mm2, %%mm0 \\n\\t\"\n\n \"psllq $8, %%mm4 \\n\\t\"\n\n \"psllq $16, %%mm5 \\n\\t\"\n\n \"por %%mm4, %%mm3 \\n\\t\"\n\n \"por %%mm5, %%mm3 \\n\\t\"\n\n\n\n \"movq %%mm0, %%mm6 \\n\\t\"\n\n \"movq %%mm3, %%mm7 \\n\\t\"\n\n\n\n \"movq 8%1, %%mm0 \\n\\t\"\n\n \"movq 8%1, %%mm1 \\n\\t\"\n\n \"movq 8%1, %%mm2 \\n\\t\"\n\n \"pand %2, %%mm0 \\n\\t\"\n\n \"pand %3, %%mm1 \\n\\t\"\n\n \"pand %4, %%mm2 \\n\\t\"\n\n \"psllq $3, %%mm0 \\n\\t\"\n\n \"psrlq $3, %%mm1 \\n\\t\"\n\n \"psrlq $8, %%mm2 \\n\\t\"\n\n \"movq %%mm0, %%mm3 \\n\\t\"\n\n \"movq %%mm1, %%mm4 \\n\\t\"\n\n \"movq %%mm2, %%mm5 \\n\\t\"\n\n \"punpcklwd %5, %%mm0 \\n\\t\"\n\n \"punpcklwd %5, %%mm1 \\n\\t\"\n\n \"punpcklwd %5, %%mm2 \\n\\t\"\n\n \"punpckhwd %5, %%mm3 \\n\\t\"\n\n \"punpckhwd %5, %%mm4 \\n\\t\"\n\n \"punpckhwd %5, %%mm5 \\n\\t\"\n\n \"psllq $8, %%mm1 \\n\\t\"\n\n \"psllq $16, %%mm2 \\n\\t\"\n\n \"por %%mm1, %%mm0 \\n\\t\"\n\n \"por %%mm2, %%mm0 \\n\\t\"\n\n \"psllq $8, %%mm4 \\n\\t\"\n\n \"psllq $16, %%mm5 \\n\\t\"\n\n \"por %%mm4, %%mm3 \\n\\t\"\n\n \"por %%mm5, %%mm3 \\n\\t\"\n\n :\"=m\"(*d)\n\n :\"m\"(*s),\"m\"(mask16b),\"m\"(mask16g),\"m\"(mask16r),\"m\"(mmx_null)\n\n :\"memory\");\n\n \/* borrowed 32 to 24 *\/\n\n __asm__ volatile(\n\n \"movq %%mm0, %%mm4 \\n\\t\"\n\n \"movq %%mm3, %%mm5 \\n\\t\"\n\n \"movq %%mm6, %%mm0 \\n\\t\"\n\n \"movq %%mm7, %%mm1 \\n\\t\"\n\n\n\n \"movq %%mm4, %%mm6 \\n\\t\"\n\n \"movq %%mm5, %%mm7 \\n\\t\"\n\n \"movq %%mm0, %%mm2 \\n\\t\"\n\n \"movq %%mm1, %%mm3 \\n\\t\"\n\n\n\n STORE_BGR24_MMX\n\n\n\n :\"=m\"(*d)\n\n :\"m\"(*s)\n\n :\"memory\");\n\n d += 24;\n\n s += 8;\n\n }\n\n __asm__ volatile(SFENCE:::\"memory\");\n\n __asm__ volatile(EMMS:::\"memory\");\n\n while (s < end) {\n\n register uint16_t bgr;\n\n bgr = *s++;\n\n *d++ = (bgr&0x1F)<<3;\n\n *d++ = (bgr&0x7E0)>>3;\n\n *d++ = (bgr&0xF800)>>8;\n\n }\n\n}\n","target":1,"code_token_length":1429,"total_token_length":1665,"max_tokens_setting":2048} +{"idx":150080,"func":"AddAnyPortMapping(struct upnphttp * h, const char * action, const char * ns)\n{\n\tint r;\n\tstatic const char resp[] =\n\t\t\"\"\n\t\t\"%hu<\/NewReservedPort>\"\n\t\t\"<\/u:%sResponse>\";\n\n\tchar body[512];\n\tint bodylen;\n\n\tstruct NameValueParserData data;\n\tconst char * int_ip, * int_port, * ext_port, * protocol, * desc;\n\tconst char * r_host;\n\tunsigned short iport, eport;\n\tconst char * leaseduration_str;\n\tunsigned int leaseduration;\n\n\tstruct hostent *hp; \/* getbyhostname() *\/\n\tchar ** ptr; \/* getbyhostname() *\/\n\tstruct in_addr result_ip;\/*unsigned char result_ip[16];*\/ \/* inet_pton() *\/\n\n\tParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);\n\tr_host = GetValueFromNameValueList(&data, \"NewRemoteHost\");\n\text_port = GetValueFromNameValueList(&data, \"NewExternalPort\");\n\tprotocol = GetValueFromNameValueList(&data, \"NewProtocol\");\n\tint_port = GetValueFromNameValueList(&data, \"NewInternalPort\");\n\tint_ip = GetValueFromNameValueList(&data, \"NewInternalClient\");\n\t\/* NewEnabled *\/\n\tdesc = GetValueFromNameValueList(&data, \"NewPortMappingDescription\");\n\tleaseduration_str = GetValueFromNameValueList(&data, \"NewLeaseDuration\");\n\n\tleaseduration = leaseduration_str ? atoi(leaseduration_str) : 0;\n\tif(leaseduration == 0)\n\t\tleaseduration = 604800;\n\n\tif (!int_ip || !ext_port || !int_port)\n\t{\n\t\tClearNameValueList(&data);\n\t\tSoapError(h, 402, \"Invalid Args\");\n\t\treturn;\n\t}\n\n\teport = (unsigned short)atoi(ext_port);\n\tiport = (unsigned short)atoi(int_port);\n\tif(iport == 0 || !is_numeric(ext_port)) {\n\t\tClearNameValueList(&data);\n\t\tSoapError(h, 402, \"Invalid Args\");\n\t\treturn;\n\t}\n#ifndef SUPPORT_REMOTEHOST\n#ifdef UPNP_STRICT\n\tif (r_host && (r_host[0] != '\\0') && (0 != strcmp(r_host, \"*\")))\n\t{\n\t\tClearNameValueList(&data);\n\t\tSoapError(h, 726, \"RemoteHostOnlySupportsWildcard\");\n\t\treturn;\n\t}\n#endif\n#endif\n\n\t\/* if ip not valid assume hostname and convert *\/\n\tif (inet_pton(AF_INET, int_ip, &result_ip) <= 0)\n\t{\n\t\thp = gethostbyname(int_ip);\n\t\tif(hp && hp->h_addrtype == AF_INET)\n\t\t{\n\t\t\tfor(ptr = hp->h_addr_list; ptr && *ptr; ptr++)\n\t\t \t{\n\t\t\t\tint_ip = inet_ntoa(*((struct in_addr *) *ptr));\n\t\t\t\tresult_ip = *((struct in_addr *) *ptr);\n\t\t\t\t\/* TODO : deal with more than one ip per hostname *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsyslog(LOG_ERR, \"Failed to convert hostname '%s' to ip address\", int_ip);\n\t\t\tClearNameValueList(&data);\n\t\t\tSoapError(h, 402, \"Invalid Args\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\t\/* check if NewInternalAddress is the client address *\/\n\tif(GETFLAG(SECUREMODEMASK))\n\t{\n\t\tif(h->clientaddr.s_addr != result_ip.s_addr)\n\t\t{\n\t\t\tsyslog(LOG_INFO, \"Client %s tried to redirect port to %s\",\n\t\t\t inet_ntoa(h->clientaddr), int_ip);\n\t\t\tClearNameValueList(&data);\n\t\t\tSoapError(h, 606, \"Action not authorized\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\t\/* TODO : accept a different external port\n\t * have some smart strategy to choose the port *\/\n\tfor(;;) {\n\t\tr = upnp_redirect(r_host, eport, int_ip, iport, protocol, desc, leaseduration);\n\t\tif(r==-2 && eport < 65535) {\n\t\t\teport++;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tClearNameValueList(&data);\n\n\tswitch(r)\n\t{\n\tcase 0:\t\/* success *\/\n\t\tbodylen = snprintf(body, sizeof(body), resp,\n\t\t action, ns, \/*SERVICE_TYPE_WANIPC,*\/\n\t\t\t\t\t eport, action);\n\t\tBuildSendAndCloseSoapResp(h, body, bodylen);\n\t\tbreak;\n\tcase -2:\t\/* already redirected *\/\n\t\tSoapError(h, 718, \"ConflictInMappingEntry\");\n\t\tbreak;\n\tcase -3:\t\/* not permitted *\/\n\t\tSoapError(h, 606, \"Action not authorized\");\n\t\tbreak;\n\tdefault:\n\t\tSoapError(h, 501, \"ActionFailed\");\n\t}\n}","target":0,"code_token_length":1068,"total_token_length":1304,"max_tokens_setting":2048} +{"idx":3739,"func":"\nstatic void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, const char *data, int data_len, char *mode, const char *iv, int iv_len, int argc, int dencrypt, zval* return_value TSRMLS_DC) \/* {{{ *\/\n{\n\tchar *cipher_dir_string;\n\tchar *module_dir_string;\n\tint block_size, max_key_length, use_key_length, i, count, iv_size;\n\tunsigned long int data_size;\n\tint *key_length_sizes;\n\tchar *key_s = NULL, *iv_s;\n\tchar *data_s;\n\tMCRYPT td;\n\n\tMCRYPT_GET_INI\n\n\ttd = mcrypt_module_open(cipher, cipher_dir_string, mode, module_dir_string);\n\tif (td == MCRYPT_FAILED) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_OPEN_MODULE_FAILED);\n\t\tRETURN_FALSE;\n\t}\n\t\/* Checking for key-length *\/\n\tmax_key_length = mcrypt_enc_get_key_size(td);\n\tif (key_len > max_key_length) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Size of key is too large for this algorithm\");\n\t}\n\tkey_length_sizes = mcrypt_enc_get_supported_key_sizes(td, &count);\n\tif (count == 0 && key_length_sizes == NULL) { \/* all lengths 1 - k_l_s = OK *\/\n\t\tuse_key_length = key_len;\n\t\tkey_s = emalloc(use_key_length);\n\t\tmemset(key_s, 0, use_key_length);\n\t\tmemcpy(key_s, key, use_key_length);\n\t} else if (count == 1) { \/* only m_k_l = OK *\/\n\t\tkey_s = emalloc(key_length_sizes[0]);\n\t\tmemset(key_s, 0, key_length_sizes[0]);\n\t\tmemcpy(key_s, key, MIN(key_len, key_length_sizes[0]));\n\t\tuse_key_length = key_length_sizes[0];\n\t} else { \/* dertermine smallest supported key > length of requested key *\/\n\t\tuse_key_length = max_key_length; \/* start with max key length *\/\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tif (key_length_sizes[i] >= key_len && \n\t\t\t\tkey_length_sizes[i] < use_key_length)\n\t\t\t{\n\t\t\t\tuse_key_length = key_length_sizes[i];\n\t\t\t}\n\t\t}\n\t\tkey_s = emalloc(use_key_length);\n\t\tmemset(key_s, 0, use_key_length);\n\t\tmemcpy(key_s, key, MIN(key_len, use_key_length));\n\t}\n\tmcrypt_free (key_length_sizes);\n\t\n\t\/* Check IV *\/\n\tiv_s = NULL;\n\tiv_size = mcrypt_enc_get_iv_size (td);\n\t\n\t\/* IV is required *\/\n\tif (mcrypt_enc_mode_has_iv(td) == 1) {\n\t\tif (argc == 5) {\n\t\t\tif (iv_size != iv_len) {\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE);\n\t\t\t} else {\n\t\t\t\tiv_s = emalloc(iv_size + 1);\n\t\t\t\tmemcpy(iv_s, iv, iv_size);\n\t\t\t}\n\t\t} else if (argc == 4) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Attempt to use an empty IV, which is NOT recommend\");\n\t\t\tiv_s = emalloc(iv_size + 1);\n\t\t\tmemset(iv_s, 0, iv_size + 1);\n\t\t}\n\t}\n\n\t\/* Check blocksize *\/\n\tif (mcrypt_enc_is_block_mode(td) == 1) { \/* It's a block algorithm *\/\n\t\tblock_size = mcrypt_enc_get_block_size(td);\n\t\tdata_size = (((data_len - 1) \/ block_size) + 1) * block_size;\n\t\tdata_s = emalloc(data_size);\n\t\tmemset(data_s, 0, data_size);\n\t\tmemcpy(data_s, data, data_len);\n\t} else { \/* It's not a block algorithm *\/\n\t\tdata_size = data_len;\n\t\tdata_s = emalloc(data_size);\n\t\tmemset(data_s, 0, data_size);\n\t\tmemcpy(data_s, data, data_len);\n\t}\n\n\tif (mcrypt_generic_init(td, key_s, use_key_length, iv_s) < 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, \"Mcrypt initialisation failed\");\n\t\tRETURN_FALSE;\n\t}\n\tif (dencrypt == MCRYPT_ENCRYPT) {\n\t\tmcrypt_generic(td, data_s, data_size);\n\t} else {\n\t\tmdecrypt_generic(td, data_s, data_size);\n\t}\n\t\n\tRETVAL_STRINGL(data_s, data_size, 1);\n\n\t\/* freeing vars *\/\n\tmcrypt_generic_end(td);\n\tif (key_s != NULL) {\n\t\tefree (key_s);\n\t}\n\tif (iv_s != NULL) {\n\t\tefree (iv_s);\n\t}\n\tefree (data_s);","target":1,"code_token_length":1027,"total_token_length":1263,"max_tokens_setting":2048} +{"idx":447387,"func":"int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,\n\tstruct sldns_file_parse_state* parse_state)\n{\n\tchar line[LDNS_RR_BUF_SIZE+1];\n\tssize_t size;\n\n\t\/* read an entire line in from the file *\/\n\tif((size = sldns_fget_token_l(in, line, LDNS_PARSE_SKIP_SPACE,\n\t\tLDNS_RR_BUF_SIZE, parse_state?&parse_state->lineno:NULL))\n\t\t== -1) {\n\t\t\/* if last line was empty, we are now at feof, which is not\n\t\t * always a parse error (happens when for instance last line\n\t\t * was a comment)\n\t\t *\/\n\t\treturn LDNS_WIREPARSE_ERR_SYNTAX;\n\t}\n\n\t\/* we can have the situation, where we've read ok, but still got\n\t * no bytes to play with, in this case size is 0 *\/\n\tif(size == 0) {\n\t\tif(*len > 0)\n\t\t\trr[0] = 0;\n\t\t*len = 0;\n\t\t*dname_len = 0;\n\t\treturn LDNS_WIREPARSE_ERR_OK;\n\t}\n\n\tif(strncmp(line, \"$ORIGIN\", 7) == 0 && isspace((unsigned char)line[7])) {\n\t\tint s;\n\t\tstrlcpy((char*)rr, line, *len);\n\t\t*len = 0;\n\t\t*dname_len = 0;\n\t\tif(!parse_state) return LDNS_WIREPARSE_ERR_OK;\n\t\tparse_state->origin_len = sizeof(parse_state->origin);\n\t\ts = sldns_str2wire_dname_buf(sldns_strip_ws(line+8),\n\t\t\tparse_state->origin, &parse_state->origin_len);\n\t\tif(s) parse_state->origin_len = 0;\n\t\treturn s;\n\t} else if(strncmp(line, \"$TTL\", 4) == 0 && isspace((unsigned char)line[4])) {\n\t\tconst char* end = NULL;\n\t\tstrlcpy((char*)rr, line, *len);\n\t\t*len = 0;\n\t\t*dname_len = 0;\n\t\tif(!parse_state) return LDNS_WIREPARSE_ERR_OK;\n\t\tparse_state->default_ttl = sldns_str2period(\n\t\t\tsldns_strip_ws(line+5), &end);\n\t} else if (strncmp(line, \"$INCLUDE\", 8) == 0) {\n\t\tstrlcpy((char*)rr, line, *len);\n\t\t*len = 0;\n\t\t*dname_len = 0;\n\t\treturn LDNS_WIREPARSE_ERR_INCLUDE;\n\t} else if (strncmp(line, \"$\", 1) == 0) {\n\t\tstrlcpy((char*)rr, line, *len);\n\t\t*len = 0;\n\t\t*dname_len = 0;\n\t\treturn LDNS_WIREPARSE_ERR_INCLUDE;\n\t} else {\n\t\tint r = sldns_str2wire_rr_buf(line, rr, len, dname_len,\n\t\t\tparse_state?parse_state->default_ttl:0,\n\t\t\t(parse_state&&parse_state->origin_len)?\n\t\t\t\tparse_state->origin:NULL,\n\t\t\tparse_state?parse_state->origin_len:0,\n\t\t\t(parse_state&&parse_state->prev_rr_len)?\n\t\t\t\tparse_state->prev_rr:NULL,\n\t\t\tparse_state?parse_state->prev_rr_len:0);\n\t\tif(r == LDNS_WIREPARSE_ERR_OK && (*dname_len) != 0 &&\n\t\t\tparse_state &&\n\t\t\t(*dname_len) <= sizeof(parse_state->prev_rr)) {\n\t\t\tmemmove(parse_state->prev_rr, rr, *dname_len);\n\t\t\tparse_state->prev_rr_len = (*dname_len);\n\t\t}\n\t\treturn r;\n\t}\n\treturn LDNS_WIREPARSE_ERR_OK;\n}","target":0,"code_token_length":827,"total_token_length":1063,"max_tokens_setting":2048} +{"idx":63479,"func":"void CLASS setCanonBodyFeatures(unsigned id)\n{\n imgdata.lens.makernotes.CamID = id;\n if ((id == 0x80000001) || \/\/ 1D\n (id == 0x80000174) || \/\/ 1D2\n (id == 0x80000232) || \/\/ 1D2N\n (id == 0x80000169) || \/\/ 1D3\n (id == 0x80000281) \/\/ 1D4\n )\n {\n imgdata.lens.makernotes.CameraFormat = LIBRAW_FORMAT_APSH;\n imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_Canon_EF;\n }\n else if ((id == 0x80000167) || \/\/ 1Ds\n (id == 0x80000188) || \/\/ 1Ds2\n (id == 0x80000215) || \/\/ 1Ds3\n (id == 0x80000269) || \/\/ 1DX\n (id == 0x80000328) || \/\/ 1DX2\n (id == 0x80000324) || \/\/ 1DC\n (id == 0x80000213) || \/\/ 5D\n (id == 0x80000218) || \/\/ 5D2\n (id == 0x80000285) || \/\/ 5D3\n (id == 0x80000349) || \/\/ 5D4\n (id == 0x80000382) || \/\/ 5DS\n (id == 0x80000401) || \/\/ 5DS R\n (id == 0x80000302) \/\/ 6D\n )\n {\n imgdata.lens.makernotes.CameraFormat = LIBRAW_FORMAT_FF;\n imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_Canon_EF;\n }\n else if ((id == 0x80000331) || \/\/ M\n (id == 0x80000355) || \/\/ M2\n (id == 0x80000374) || \/\/ M3\n (id == 0x80000384) || \/\/ M10\n (id == 0x80000394) \/\/ M5\n )\n {\n imgdata.lens.makernotes.CameraFormat = LIBRAW_FORMAT_APSC;\n imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_Canon_EF_M;\n }\n else if ((id == 0x01140000) || \/\/ D30\n (id == 0x01668000) || \/\/ D60\n (id > 0x80000000))\n {\n imgdata.lens.makernotes.CameraFormat = LIBRAW_FORMAT_APSC;\n imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_Canon_EF;\n imgdata.lens.makernotes.LensMount = LIBRAW_MOUNT_Unknown;\n }\n else\n {\n imgdata.lens.makernotes.CameraMount = LIBRAW_MOUNT_FixedLens;\n imgdata.lens.makernotes.LensMount = LIBRAW_MOUNT_FixedLens;\n }\n\n return;\n}","target":0,"code_token_length":849,"total_token_length":1085,"max_tokens_setting":2048} +{"idx":448844,"func":"template_mark_fill_rect(int w, int h, byte *gs_restrict dst_ptr, byte *gs_restrict src, int num_comp, int num_spots, int first_blend_spot,\n byte src_alpha, int rowstride, int planestride, bool additive, pdf14_device *pdev, gs_blend_mode_t blend_mode,\n bool overprint, gx_color_index drawn_comps, int tag_off, gs_graphics_type_tag_t curr_tag,\n int alpha_g_off, int shape_off, byte shape, bool isolated)\n{\n int i, j, k;\n gx_color_index comps;\n byte dst[PDF14_MAX_PLANES] = { 0 };\n byte dest_alpha;\n bool tag_blend = blend_mode == BLEND_MODE_Normal ||\n blend_mode == BLEND_MODE_Compatible ||\n blend_mode == BLEND_MODE_CompatibleOverprint;\n\n for (j = h; j > 0; --j) {\n for (i = w; i > 0; --i) {\n if ((blend_mode == BLEND_MODE_Normal && src[num_comp] == 0xff && !overprint) || dst_ptr[num_comp * planestride] == 0) {\n \/* dest alpha is zero (or normal, and solid src) just use source. *\/\n if (additive) {\n \/* Hybrid case *\/\n for (k = 0; k < (num_comp - num_spots); k++) {\n dst_ptr[k * planestride] = src[k];\n }\n for (k = 0; k < num_spots; k++) {\n dst_ptr[(k + num_comp - num_spots) * planestride] =\n 255 - src[k + num_comp - num_spots];\n }\n } else {\n \/* Pure subtractive *\/\n for (k = 0; k < num_comp; k++) {\n dst_ptr[k * planestride] = 255 - src[k];\n }\n }\n \/* alpha *\/\n dst_ptr[num_comp * planestride] = src[num_comp];\n } else if (src[num_comp] != 0) {\n byte *pdst;\n \/* Complement subtractive planes *\/\n if (!additive) {\n \/* Pure subtractive *\/\n for (k = 0; k < num_comp; ++k)\n dst[k] = 255 - dst_ptr[k * planestride];\n } else {\n \/* Hybrid case, additive with subtractive spots *\/\n for (k = 0; k < (num_comp - num_spots); k++) {\n dst[k] = dst_ptr[k * planestride];\n }\n for (k = 0; k < num_spots; k++) {\n dst[k + num_comp - num_spots] =\n 255 - dst_ptr[(k + num_comp - num_spots) * planestride];\n }\n }\n dst[num_comp] = dst_ptr[num_comp * planestride];\n dest_alpha = dst[num_comp];\n pdst = art_pdf_composite_pixel_alpha_8_inline(dst, src, num_comp, blend_mode, first_blend_spot,\n pdev->blend_procs, pdev);\n \/* Until I see otherwise in AR or the spec, do not fool\n with spot overprinting while we are in an RGB or Gray\n blend color space. *\/\n if (!additive && overprint) {\n \/* If this is an overprint case, and alpha_r is different\n than alpha_d then we will need to adjust\n the colors of the non-drawn components here too *\/\n for (k = 0, comps = drawn_comps; comps != 0; ++k, comps >>= 1) {\n if ((comps & 0x1) != 0) {\n dst_ptr[k * planestride] = 255 - pdst[k];\n } else if (dest_alpha != pdst[num_comp]) {\n \/* We need val_new = (val_old * old_alpha) \/ new_alpha *\/\n if (pdst[num_comp] != 0) {\n int val = (int)floor(((float)dest_alpha \/ (float)pdst[num_comp]) * (255 - pdst[k]) + 0.5);\n if (val < 0)\n val = 0;\n else if (val > 255)\n val = 255;\n dst_ptr[k * planestride] = val;\n }\n }\n }\n } else {\n \/* Post blend complement for subtractive *\/\n if (!additive) {\n \/* Pure subtractive *\/\n for (k = 0; k < num_comp; ++k)\n dst_ptr[k * planestride] = 255 - pdst[k];\n\n } else {\n \/* Hybrid case, additive with subtractive spots *\/\n for (k = 0; k < (num_comp - num_spots); k++) {\n dst_ptr[k * planestride] = pdst[k];\n }\n for (k = 0; k < num_spots; k++) {\n dst_ptr[(k + num_comp - num_spots) * planestride] =\n 255 - pdst[k + num_comp - num_spots];\n }\n }\n }\n \/* The alpha channel *\/\n dst_ptr[num_comp * planestride] = pdst[num_comp];\n }\n if (tag_off) {\n \/* If src alpha is 100% then set to curr_tag, else or *\/\n \/* other than Normal BM, we always OR *\/\n if (src[num_comp] == 255 && tag_blend) {\n dst_ptr[tag_off] = curr_tag;\n } else {\n dst_ptr[tag_off] |= curr_tag;\n }\n }\n if (alpha_g_off) {\n int tmp = (255 - dst_ptr[alpha_g_off]) * src_alpha + 0x80;\n dst_ptr[alpha_g_off] = 255 - ((tmp + (tmp >> 8)) >> 8);\n }\n if (shape_off) {\n int tmp = (255 - dst_ptr[shape_off]) * shape + 0x80;\n dst_ptr[shape_off] = 255 - ((tmp + (tmp >> 8)) >> 8);\n }\n ++dst_ptr;\n }\n dst_ptr += rowstride;\n }\n}","target":0,"code_token_length":1380,"total_token_length":1616,"max_tokens_setting":2048} +{"idx":306403,"func":"lyp_check_import(struct lys_module *module, const char *value, struct lys_import *imp)\n{\n int i;\n struct lys_module *dup = NULL;\n struct ly_ctx *ctx = module->ctx;\n\n \/* check for importing a single module in multiple revisions *\/\n for (i = 0; i < module->imp_size; i++) {\n if (!module->imp[i].module) {\n \/* skip the not yet filled records *\/\n continue;\n }\n if (ly_strequal(module->imp[i].module->name, value, 1)) {\n \/* check revisions, including multiple revisions of a single module is error *\/\n if (imp->rev[0] && (!module->imp[i].module->rev_size || strcmp(module->imp[i].module->rev[0].date, imp->rev))) {\n \/* the already imported module has\n * - no revision, but here we require some\n * - different revision than the one required here *\/\n LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"import\");\n LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, \"Importing multiple revisions of module \\\"%s\\\".\", value);\n return -1;\n } else if (!imp->rev[0]) {\n \/* no revision, remember the duplication, but check revisions after loading the module\n * because the current revision can be the same (then it is ok) or it can differ (then it\n * is error *\/\n dup = module->imp[i].module;\n break;\n }\n\n \/* there is duplication, but since prefixes differs (checked in caller of this function),\n * it is ok *\/\n imp->module = module->imp[i].module;\n return 0;\n }\n }\n\n \/* circular import check *\/\n if (lyp_check_circmod(module, value, 1)) {\n return -1;\n }\n\n \/* load module - in specific situations it tries to get the module from the context *\/\n imp->module = (struct lys_module *)ly_ctx_load_sub_module(module->ctx, NULL, value, imp->rev[0] ? imp->rev : NULL,\n module->ctx->models.flags & LY_CTX_ALLIMPLEMENTED ? 1 : 0,\n NULL);\n\n \/* check the result *\/\n if (!imp->module) {\n LOGERR(ctx, LY_EVALID, \"Importing \\\"%s\\\" module into \\\"%s\\\" failed.\", value, module->name);\n return -1;\n }\n\n if (imp->rev[0] && imp->module->rev_size && strcmp(imp->rev, imp->module->rev[0].date)) {\n LOGERR(ctx, LY_EVALID, \"\\\"%s\\\" import of module \\\"%s\\\" in revision \\\"%s\\\" not found.\",\n module->name, value, imp->rev);\n return -1;\n }\n\n if (dup) {\n \/* check the revisions *\/\n if ((dup != imp->module) ||\n (dup->rev_size != imp->module->rev_size && (!dup->rev_size || imp->module->rev_size)) ||\n (dup->rev_size && strcmp(dup->rev[0].date, imp->module->rev[0].date))) {\n \/* - modules are not the same\n * - one of modules has no revision (except they both has no revision)\n * - revisions of the modules are not the same *\/\n LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, \"import\");\n LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, \"Importing multiple revisions of module \\\"%s\\\".\", value);\n return -1;\n } else {\n LOGWRN(ctx, \"Module \\\"%s\\\" is imported by \\\"%s\\\" multiple times with different prefixes.\", dup->name, module->name);\n }\n }\n\n return 0;\n}","target":0,"code_token_length":835,"total_token_length":1071,"max_tokens_setting":2048} +{"idx":113213,"func":"gnutls_ocsp_resp_get_single(gnutls_ocsp_resp_t resp,\n\t\t\t unsigned indx,\n\t\t\t gnutls_digest_algorithm_t * digest,\n\t\t\t gnutls_datum_t * issuer_name_hash,\n\t\t\t gnutls_datum_t * issuer_key_hash,\n\t\t\t gnutls_datum_t * serial_number,\n\t\t\t unsigned int *cert_status,\n\t\t\t time_t * this_update,\n\t\t\t time_t * next_update,\n\t\t\t time_t * revocation_time,\n\t\t\t unsigned int *revocation_reason)\n{\n\tgnutls_datum_t sa;\n\tchar name[ASN1_MAX_NAME_SIZE];\n\tint ret;\n\n\tsnprintf(name, sizeof(name),\n\t\t \"tbsResponseData.responses.?%u.certID.hashAlgorithm.algorithm\",\n\t\t indx + 1);\n\tret = _gnutls_x509_read_value(resp->basicresp, name, &sa);\n\tif (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)\n\t\treturn GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;\n\telse if (ret < 0) {\n\t\tgnutls_assert();\n\t\treturn ret;\n\t}\n\n\tret = gnutls_oid_to_digest((char *) sa.data);\n\t_gnutls_free_datum(&sa);\n\tif (ret < 0) {\n\t\tgnutls_assert();\n\t\treturn ret;\n\t}\n\n\tif (digest)\n\t\t*digest = ret;\n\n\tif (issuer_name_hash) {\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.certID.issuerNameHash\",\n\t\t\t indx + 1);\n\t\tret = _gnutls_x509_read_value(resp->basicresp, name,\n\t\t\t\t\t issuer_name_hash);\n\t\tif (ret != GNUTLS_E_SUCCESS) {\n\t\t\tgnutls_assert();\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tif (issuer_key_hash) {\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.certID.issuerKeyHash\",\n\t\t\t indx + 1);\n\t\tret = _gnutls_x509_read_value(resp->basicresp, name,\n\t\t\t\t\t issuer_key_hash);\n\t\tif (ret != GNUTLS_E_SUCCESS) {\n\t\t\tgnutls_assert();\n\t\t\tif (issuer_name_hash)\n\t\t\t\tgnutls_free(issuer_name_hash->data);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tif (serial_number) {\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.certID.serialNumber\",\n\t\t\t indx + 1);\n\t\tret = _gnutls_x509_read_value(resp->basicresp, name,\n\t\t\t\t\t serial_number);\n\t\tif (ret != GNUTLS_E_SUCCESS) {\n\t\t\tgnutls_assert();\n\t\t\tif (issuer_name_hash)\n\t\t\t\tgnutls_free(issuer_name_hash->data);\n\t\t\tif (issuer_key_hash)\n\t\t\t\tgnutls_free(issuer_key_hash->data);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tif (cert_status) {\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.certStatus\",\n\t\t\t indx + 1);\n\t\tret = _gnutls_x509_read_value(resp->basicresp, name, &sa);\n\t\tif (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)\n\t\t\treturn GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;\n\t\telse if (ret < 0) {\n\t\t\tgnutls_assert();\n\t\t\treturn ret;\n\t\t}\n\t\tif (sa.size == 5 && memcmp(sa.data, \"good\", sa.size) == 0)\n\t\t\t*cert_status = GNUTLS_OCSP_CERT_GOOD;\n\t\telse if (sa.size == 8\n\t\t\t && memcmp(sa.data, \"revoked\", sa.size) == 0)\n\t\t\t*cert_status = GNUTLS_OCSP_CERT_REVOKED;\n\t\telse if (sa.size == 8\n\t\t\t && memcmp(sa.data, \"unknown\", sa.size) == 0)\n\t\t\t*cert_status = GNUTLS_OCSP_CERT_UNKNOWN;\n\t\telse {\n\t\t\tgnutls_assert();\n\t\t\tgnutls_free(sa.data);\n\t\t\treturn GNUTLS_E_ASN1_DER_ERROR;\n\t\t}\n\t\tgnutls_free(sa.data);\n\t}\n\n\tif (this_update) {\n\t\tchar ttime[MAX_TIME];\n\t\tint len;\n\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.thisUpdate\",\n\t\t\t indx + 1);\n\t\tlen = sizeof(ttime) - 1;\n\t\tret = asn1_read_value(resp->basicresp, name, ttime, &len);\n\t\tif (ret != ASN1_SUCCESS) {\n\t\t\tgnutls_assert();\n\t\t\treturn GNUTLS_E_ASN1_DER_ERROR;\n\t\t} else {\n\t\t\t*this_update =\n\t\t\t _gnutls_x509_generalTime2gtime(ttime);\n\t\t}\n\t}\n\n\tif (next_update) {\n\t\tchar ttime[MAX_TIME];\n\t\tint len;\n\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.nextUpdate\",\n\t\t\t indx + 1);\n\t\tlen = sizeof(ttime) - 1;\n\t\tret = asn1_read_value(resp->basicresp, name, ttime, &len);\n\t\tif (ret != ASN1_SUCCESS) {\n\t\t\tgnutls_assert();\n\t\t\t*next_update = (time_t) (-1);\n\t\t} else\n\t\t\t*next_update =\n\t\t\t _gnutls_x509_generalTime2gtime(ttime);\n\t}\n\n\tif (revocation_time) {\n\t\tchar ttime[MAX_TIME];\n\t\tint len;\n\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.certStatus.\"\n\t\t\t \"revoked.revocationTime\", indx + 1);\n\t\tlen = sizeof(ttime) - 1;\n\t\tret = asn1_read_value(resp->basicresp, name, ttime, &len);\n\t\tif (ret != ASN1_SUCCESS) {\n\t\t\tgnutls_assert();\n\t\t\t*revocation_time = (time_t) (-1);\n\t\t} else\n\t\t\t*revocation_time =\n\t\t\t _gnutls_x509_generalTime2gtime(ttime);\n\t}\n\n\t\/* revocation_reason *\/\n\tif (revocation_reason) {\n\t\tsnprintf(name, sizeof(name),\n\t\t\t \"tbsResponseData.responses.?%u.certStatus.\"\n\t\t\t \"revoked.revocationReason\", indx + 1);\n\n\t\tret = _gnutls_x509_read_uint(resp->basicresp, name,\n\t\t\t\t\t revocation_reason);\n\t\tif (ret < 0)\n\t\t\t*revocation_reason =\n\t\t\t GNUTLS_X509_CRLREASON_UNSPECIFIED;\n\t}\n\n\treturn GNUTLS_E_SUCCESS;\n}","target":0,"code_token_length":1387,"total_token_length":1623,"max_tokens_setting":2048} +{"idx":125461,"func":"cursor_correct(void)\n{\n int\t\tabove = 0;\t \/\/ screen lines above topline\n linenr_T\ttopline;\n int\t\tbelow = 0;\t \/\/ screen lines below botline\n linenr_T\tbotline;\n int\t\tabove_wanted, below_wanted;\n linenr_T\tcln;\t\t \/\/ Cursor Line Number\n int\t\tmax_off;\n long so = get_scrolloff_value();\n\n \/*\n * How many lines we would like to have above\/below the cursor depends on\n * whether the first\/last line of the file is on screen.\n *\/\n above_wanted = so;\n below_wanted = so;\n if (mouse_dragging > 0)\n {\n\tabove_wanted = mouse_dragging - 1;\n\tbelow_wanted = mouse_dragging - 1;\n }\n if (curwin->w_topline == 1)\n {\n\tabove_wanted = 0;\n\tmax_off = curwin->w_height \/ 2;\n\tif (below_wanted > max_off)\n\t below_wanted = max_off;\n }\n validate_botline();\n if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1\n\t && mouse_dragging == 0)\n {\n\tbelow_wanted = 0;\n\tmax_off = (curwin->w_height - 1) \/ 2;\n\tif (above_wanted > max_off)\n\t above_wanted = max_off;\n }\n\n \/*\n * If there are sufficient file-lines above and below the cursor, we can\n * return now.\n *\/\n cln = curwin->w_cursor.lnum;\n if (cln >= curwin->w_topline + above_wanted\n\t && cln < curwin->w_botline - below_wanted\n#ifdef FEAT_FOLDING\n\t && !hasAnyFolding(curwin)\n#endif\n\t )\n\treturn;\n\n \/*\n * Narrow down the area where the cursor can be put by taking lines from\n * the top and the bottom until:\n * - the desired context lines are found\n * - the lines from the top is past the lines from the bottom\n *\/\n topline = curwin->w_topline;\n botline = curwin->w_botline - 1;\n#ifdef FEAT_DIFF\n \/\/ count filler lines as context\n above = curwin->w_topfill;\n below = curwin->w_filler_rows;\n#endif\n while ((above < above_wanted || below < below_wanted) && topline < botline)\n {\n\tif (below < below_wanted && (below <= above || above >= above_wanted))\n\t{\n#ifdef FEAT_FOLDING\n\t if (hasFolding(botline, &botline, NULL))\n\t\t++below;\n\t else\n#endif\n\t\tbelow += plines(botline);\n\t --botline;\n\t}\n\tif (above < above_wanted && (above < below || below >= below_wanted))\n\t{\n#ifdef FEAT_FOLDING\n\t if (hasFolding(topline, NULL, &topline))\n\t\t++above;\n\t else\n#endif\n\t\tabove += PLINES_NOFILL(topline);\n#ifdef FEAT_DIFF\n\t \/\/ Count filler lines below this line as context.\n\t if (topline < botline)\n\t\tabove += diff_check_fill(curwin, topline + 1);\n#endif\n\t ++topline;\n\t}\n }\n if (topline == botline || botline == 0)\n\tcurwin->w_cursor.lnum = topline;\n else if (topline > botline)\n\tcurwin->w_cursor.lnum = botline;\n else\n {\n\tif (cln < topline && curwin->w_topline > 1)\n\t{\n\t curwin->w_cursor.lnum = topline;\n\t curwin->w_valid &=\n\t\t\t ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW);\n\t}\n\tif (cln > botline && curwin->w_botline <= curbuf->b_ml.ml_line_count)\n\t{\n\t curwin->w_cursor.lnum = botline;\n\t curwin->w_valid &=\n\t\t\t ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW);\n\t}\n }\n curwin->w_valid |= VALID_TOPLINE;\n}","target":0,"code_token_length":935,"total_token_length":1171,"max_tokens_setting":2048} +{"idx":13562,"func":"long Segment::DoLoadClusterUnknownSize(\n long long& pos,\n long& len)\n{\n assert(m_pos < 0);\n assert(m_pUnknownSize);\n \n #if 0\n assert(m_pUnknownSize->GetElementSize() < 0); \/\/TODO: verify this\n\n const long long element_start = m_pUnknownSize->m_element_start;\n\n pos = -m_pos;\n assert(pos > element_start);\n\n\n long long total, avail;\n\n long status = m_pReader->Length(&total, &avail);\n\n if (status < 0) \/\/error\n return status;\n\n assert((total < 0) || (avail <= total));\n\n const long long segment_stop = (m_size < 0) ? -1 : m_start + m_size;\n\n \n long long element_size = -1;\n \n for (;;) \/\/determine cluster size\n {\n if ((total >= 0) && (pos >= total))\n {\n element_size = total - element_start;\n assert(element_size > 0);\n\n break;\n }\n\n if ((segment_stop >= 0) && (pos >= segment_stop))\n {\n element_size = segment_stop - element_start;\n assert(element_size > 0);\n\n break;\n }\n\n\n if ((pos + 1) > avail)\n {\n len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n long long result = GetUIntLength(m_pReader, pos, len);\n\n if (result < 0) \/\/error\n return static_cast(result);\n\n if (result > 0) \/\/weird\n return E_BUFFER_NOT_FULL;\n\n if ((segment_stop >= 0) && ((pos + len) > segment_stop))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long idpos = pos;\n const long long id = ReadUInt(m_pReader, idpos, len);\n\n if (id < 0) \/\/error (or underflow)\n return static_cast(id);\n\n\n \n if ((id == 0x0F43B675) || (id == 0x0C53BB6B)) \/\/Cluster ID or Cues ID\n {\n element_size = pos - element_start;\n assert(element_size > 0);\n \n break;\n }\n\n#ifdef _DEBUG\n switch (id)\n {\n case 0x20: \/\/BlockGroup\n case 0x23: \/\/Simple Block\n case 0x67: \/\/TimeCode\n case 0x2B: \/\/PrevSize\n break;\n\n default:\n assert(false);\n break;\n }\n#endif\n\n pos += len; \/\/consume ID (of sub-element)\n\n\n if ((pos + 1) > avail)\n {\n len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n result = GetUIntLength(m_pReader, pos, len);\n\n if (result < 0) \/\/error\n return static_cast(result);\n\n if (result > 0) \/\/weird\n return E_BUFFER_NOT_FULL;\n\n if ((segment_stop >= 0) && ((pos + len) > segment_stop))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long size = ReadUInt(m_pReader, pos, len);\n\n if (size < 0) \/\/error\n return static_cast(size);\n\n pos += len; \/\/consume size field of element\n\n\n if (size == 0) \/\/weird\n continue;\n\n const long long unknown_size = (1LL << (7 * len)) - 1;\n\n if (size == unknown_size)\n return E_FILE_FORMAT_INVALID; \/\/not allowed for sub-elements\n\n if ((segment_stop >= 0) && ((pos + size) > segment_stop)) \/\/weird\n return E_FILE_FORMAT_INVALID;\n\n pos += size; \/\/consume payload of sub-element\n assert((segment_stop < 0) || (pos <= segment_stop));\n } \/\/determine cluster size\n\n assert(element_size >= 0);\n\n m_pos = element_start + element_size;\n m_pUnknownSize = 0;\n\n \n return 2; \/\/continue parsing\n #else\n const long status = m_pUnknownSize->Parse(pos, len);\n \n if (status < 0) \/\/error or underflow\n return status;\n \n if (status == 0) \/\/parsed a block\n return 2; \/\/continue parsing\n \n assert(status > 0); \/\/nothing left to parse of this cluster\n \n const long long start = m_pUnknownSize->m_element_start;\n \n const long long size = m_pUnknownSize->GetElementSize();\n assert(size >= 0);\n \n pos = start + size;\n m_pos = pos;\n \n m_pUnknownSize = 0;\n \n return 2; \/\/continue parsing\n #endif\n }\n","target":1,"code_token_length":1024,"total_token_length":1260,"max_tokens_setting":2048} +{"idx":353933,"func":"reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_read, int outputfd)\n{\n int ret;\n pid_t pid;\n char b;\n pid_t ppid = getpid ();\n char **argv;\n char uid[16];\n char gid[16];\n char *listen_fds = NULL;\n char *listen_pid = NULL;\n bool do_socket_activation = false;\n char *cwd = getcwd (NULL, 0);\n sigset_t sigset, oldsigset;\n\n if (cwd == NULL)\n {\n fprintf (stderr, \"error getting current working directory: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n listen_pid = getenv(\"LISTEN_PID\");\n listen_fds = getenv(\"LISTEN_FDS\");\n\n if (listen_pid != NULL && listen_fds != NULL)\n {\n if (strtol(listen_pid, NULL, 10) == getpid())\n do_socket_activation = true;\n }\n\n sprintf (uid, \"%d\", geteuid ());\n sprintf (gid, \"%d\", getegid ());\n\n pid = syscall_clone (CLONE_NEWUSER|CLONE_NEWNS|SIGCHLD, NULL);\n if (pid < 0)\n {\n fprintf (stderr, \"cannot clone: %s\\n\", strerror (errno));\n check_proc_sys_userns_file (_max_user_namespaces);\n check_proc_sys_userns_file (_unprivileged_user_namespaces);\n }\n if (pid)\n {\n if (do_socket_activation)\n {\n long num_fds;\n num_fds = strtol (listen_fds, NULL, 10);\n if (num_fds != LONG_MIN && num_fds != LONG_MAX)\n {\n long i;\n for (i = 3; i < num_fds + 3; i++)\n if (FD_ISSET (i, &open_files_set))\n close (i);\n }\n unsetenv (\"LISTEN_PID\");\n unsetenv (\"LISTEN_FDS\");\n unsetenv (\"LISTEN_FDNAMES\");\n }\n return pid;\n }\n\n if (sigfillset (&sigset) < 0)\n {\n fprintf (stderr, \"cannot fill sigset: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (sigdelset (&sigset, SIGCHLD) < 0)\n {\n fprintf (stderr, \"cannot sigdelset(SIGCHLD): %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (sigdelset (&sigset, SIGTERM) < 0)\n {\n fprintf (stderr, \"cannot sigdelset(SIGTERM): %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (sigprocmask (SIG_BLOCK, &sigset, &oldsigset) < 0)\n {\n fprintf (stderr, \"cannot block signals: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n argv = get_cmd_line_args (ppid);\n if (argv == NULL)\n {\n fprintf (stderr, \"cannot read argv: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n if (do_socket_activation)\n {\n char s[32];\n sprintf (s, \"%d\", getpid());\n setenv (\"LISTEN_PID\", s, true);\n }\n\n setenv (\"_CONTAINERS_USERNS_CONFIGURED\", \"init\", 1);\n setenv (\"_CONTAINERS_ROOTLESS_UID\", uid, 1);\n setenv (\"_CONTAINERS_ROOTLESS_GID\", gid, 1);\n\n ret = TEMP_FAILURE_RETRY (read (ready, &b, 1));\n if (ret < 0)\n {\n fprintf (stderr, \"cannot read from sync pipe: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n if (b != '0')\n _exit (EXIT_FAILURE);\n\n if (syscall_setresgid (0, 0, 0) < 0)\n {\n fprintf (stderr, \"cannot setresgid: %s\\n\", strerror (errno));\n TEMP_FAILURE_RETRY (write (ready, \"1\", 1));\n _exit (EXIT_FAILURE);\n }\n\n if (syscall_setresuid (0, 0, 0) < 0)\n {\n fprintf (stderr, \"cannot setresuid: %s\\n\", strerror (errno));\n TEMP_FAILURE_RETRY (write (ready, \"1\", 1));\n _exit (EXIT_FAILURE);\n }\n\n if (chdir (cwd) < 0)\n {\n fprintf (stderr, \"cannot chdir: %s\\n\", strerror (errno));\n TEMP_FAILURE_RETRY (write (ready, \"1\", 1));\n _exit (EXIT_FAILURE);\n }\n free (cwd);\n\n if (pause_pid_file_path && pause_pid_file_path[0] != '\\0')\n {\n if (create_pause_process (pause_pid_file_path, argv) < 0)\n {\n TEMP_FAILURE_RETRY (write (ready, \"2\", 1));\n _exit (EXIT_FAILURE);\n }\n }\n\n ret = TEMP_FAILURE_RETRY (write (ready, \"0\", 1));\n if (ret < 0)\n {\n\t fprintf (stderr, \"cannot write to ready pipe: %s\\n\", strerror (errno));\n\t _exit (EXIT_FAILURE);\n }\n close (ready);\n\n if (sigprocmask (SIG_SETMASK, &oldsigset, NULL) < 0)\n {\n fprintf (stderr, \"cannot block signals: %s\\n\", strerror (errno));\n _exit (EXIT_FAILURE);\n }\n\n if (file_to_read && file_to_read[0])\n {\n ret = copy_file_to_fd (file_to_read, outputfd);\n close (outputfd);\n _exit (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);\n }\n\n execvp (argv[0], argv);\n\n _exit (EXIT_FAILURE);\n}","target":1,"code_token_length":1300,"total_token_length":1536,"max_tokens_setting":2048} +{"idx":393582,"func":"xmlFACompareRanges(xmlRegRangePtr range1, xmlRegRangePtr range2) {\n int ret = 0;\n\n if ((range1->type == XML_REGEXP_RANGES) ||\n (range2->type == XML_REGEXP_RANGES) ||\n (range2->type == XML_REGEXP_SUBREG) ||\n (range1->type == XML_REGEXP_SUBREG) ||\n (range1->type == XML_REGEXP_STRING) ||\n (range2->type == XML_REGEXP_STRING))\n\treturn(-1);\n\n \/* put them in order *\/\n if (range1->type > range2->type) {\n xmlRegRangePtr tmp;\n\n\ttmp = range1;\n\trange1 = range2;\n\trange2 = tmp;\n }\n if ((range1->type == XML_REGEXP_ANYCHAR) ||\n (range2->type == XML_REGEXP_ANYCHAR)) {\n\tret = 1;\n } else if ((range1->type == XML_REGEXP_EPSILON) ||\n (range2->type == XML_REGEXP_EPSILON)) {\n\treturn(0);\n } else if (range1->type == range2->type) {\n if (range1->type != XML_REGEXP_CHARVAL)\n ret = 1;\n else if ((range1->end < range2->start) ||\n\t (range2->end < range1->start))\n\t ret = 0;\n\telse\n\t ret = 1;\n } else if (range1->type == XML_REGEXP_CHARVAL) {\n int codepoint;\n\tint neg = 0;\n\n\t\/*\n\t * just check all codepoints in the range for acceptance,\n\t * this is usually way cheaper since done only once at\n\t * compilation than testing over and over at runtime or\n\t * pushing too many states when evaluating.\n\t *\/\n\tif (((range1->neg == 0) && (range2->neg != 0)) ||\n\t ((range1->neg != 0) && (range2->neg == 0)))\n\t neg = 1;\n\n\tfor (codepoint = range1->start;codepoint <= range1->end ;codepoint++) {\n\t ret = xmlRegCheckCharacterRange(range2->type, codepoint,\n\t\t\t\t\t 0, range2->start, range2->end,\n\t\t\t\t\t range2->blockName);\n\t if (ret < 0)\n\t return(-1);\n\t if (((neg == 1) && (ret == 0)) ||\n\t ((neg == 0) && (ret == 1)))\n\t\treturn(1);\n\t}\n\treturn(0);\n } else if ((range1->type == XML_REGEXP_BLOCK_NAME) ||\n (range2->type == XML_REGEXP_BLOCK_NAME)) {\n\tif (range1->type == range2->type) {\n\t ret = xmlStrEqual(range1->blockName, range2->blockName);\n\t} else {\n\t \/*\n\t * comparing a block range with anything else is way\n\t * too costly, and maintining the table is like too much\n\t * memory too, so let's force the automata to save state\n\t * here.\n\t *\/\n\t return(1);\n\t}\n } else if ((range1->type < XML_REGEXP_LETTER) ||\n (range2->type < XML_REGEXP_LETTER)) {\n\tif ((range1->type == XML_REGEXP_ANYSPACE) &&\n\t (range2->type == XML_REGEXP_NOTSPACE))\n\t ret = 0;\n\telse if ((range1->type == XML_REGEXP_INITNAME) &&\n\t (range2->type == XML_REGEXP_NOTINITNAME))\n\t ret = 0;\n\telse if ((range1->type == XML_REGEXP_NAMECHAR) &&\n\t (range2->type == XML_REGEXP_NOTNAMECHAR))\n\t ret = 0;\n\telse if ((range1->type == XML_REGEXP_DECIMAL) &&\n\t (range2->type == XML_REGEXP_NOTDECIMAL))\n\t ret = 0;\n\telse if ((range1->type == XML_REGEXP_REALCHAR) &&\n\t (range2->type == XML_REGEXP_NOTREALCHAR))\n\t ret = 0;\n\telse {\n\t \/* same thing to limit complexity *\/\n\t return(1);\n\t}\n } else {\n ret = 0;\n \/* range1->type < range2->type here *\/\n switch (range1->type) {\n\t case XML_REGEXP_LETTER:\n\t \/* all disjoint except in the subgroups *\/\n\t if ((range2->type == XML_REGEXP_LETTER_UPPERCASE) ||\n\t\t (range2->type == XML_REGEXP_LETTER_LOWERCASE) ||\n\t\t (range2->type == XML_REGEXP_LETTER_TITLECASE) ||\n\t\t (range2->type == XML_REGEXP_LETTER_MODIFIER) ||\n\t\t (range2->type == XML_REGEXP_LETTER_OTHERS))\n\t\t ret = 1;\n\t\t break;\n\t case XML_REGEXP_MARK:\n\t if ((range2->type == XML_REGEXP_MARK_NONSPACING) ||\n\t\t (range2->type == XML_REGEXP_MARK_SPACECOMBINING) ||\n\t\t (range2->type == XML_REGEXP_MARK_ENCLOSING))\n\t\t ret = 1;\n\t\t break;\n\t case XML_REGEXP_NUMBER:\n\t if ((range2->type == XML_REGEXP_NUMBER_DECIMAL) ||\n\t\t (range2->type == XML_REGEXP_NUMBER_LETTER) ||\n\t\t (range2->type == XML_REGEXP_NUMBER_OTHERS))\n\t\t ret = 1;\n\t\t break;\n\t case XML_REGEXP_PUNCT:\n\t if ((range2->type == XML_REGEXP_PUNCT_CONNECTOR) ||\n\t\t (range2->type == XML_REGEXP_PUNCT_DASH) ||\n\t\t (range2->type == XML_REGEXP_PUNCT_OPEN) ||\n\t\t (range2->type == XML_REGEXP_PUNCT_CLOSE) ||\n\t\t (range2->type == XML_REGEXP_PUNCT_INITQUOTE) ||\n\t\t (range2->type == XML_REGEXP_PUNCT_FINQUOTE) ||\n\t\t (range2->type == XML_REGEXP_PUNCT_OTHERS))\n\t\t ret = 1;\n\t\t break;\n\t case XML_REGEXP_SEPAR:\n\t if ((range2->type == XML_REGEXP_SEPAR_SPACE) ||\n\t\t (range2->type == XML_REGEXP_SEPAR_LINE) ||\n\t\t (range2->type == XML_REGEXP_SEPAR_PARA))\n\t\t ret = 1;\n\t\t break;\n\t case XML_REGEXP_SYMBOL:\n\t if ((range2->type == XML_REGEXP_SYMBOL_MATH) ||\n\t\t (range2->type == XML_REGEXP_SYMBOL_CURRENCY) ||\n\t\t (range2->type == XML_REGEXP_SYMBOL_MODIFIER) ||\n\t\t (range2->type == XML_REGEXP_SYMBOL_OTHERS))\n\t\t ret = 1;\n\t\t break;\n\t case XML_REGEXP_OTHER:\n\t if ((range2->type == XML_REGEXP_OTHER_CONTROL) ||\n\t\t (range2->type == XML_REGEXP_OTHER_FORMAT) ||\n\t\t (range2->type == XML_REGEXP_OTHER_PRIVATE))\n\t\t ret = 1;\n\t\t break;\n default:\n\t if ((range2->type >= XML_REGEXP_LETTER) &&\n\t\t (range2->type < XML_REGEXP_BLOCK_NAME))\n\t\t ret = 0;\n\t\t else {\n\t\t \/* safety net ! *\/\n\t\t return(1);\n\t\t }\n\t}\n }\n if (((range1->neg == 0) && (range2->neg != 0)) ||\n ((range1->neg != 0) && (range2->neg == 0)))\n\tret = !ret;\n return(ret);\n}","target":0,"code_token_length":1596,"total_token_length":1832,"max_tokens_setting":2048} +{"idx":506605,"func":"void SSL_free(SSL *s)\n\t{\n\tint i;\n\n\tif(s == NULL)\n\t return;\n\n\ti=CRYPTO_add(&s->references,-1,CRYPTO_LOCK_SSL);\n#ifdef REF_PRINT\n\tREF_PRINT(\"SSL\",s);\n#endif\n\tif (i > 0) return;\n#ifdef REF_CHECK\n\tif (i < 0)\n\t\t{\n\t\tfprintf(stderr,\"SSL_free, bad reference count\\n\");\n\t\tabort(); \/* ok *\/\n\t\t}\n#endif\n\n\tif (s->param)\n\t\tX509_VERIFY_PARAM_free(s->param);\n\n\tCRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n\n\tif (s->bbio != NULL)\n\t\t{\n\t\t\/* If the buffering BIO is in place, pop it off *\/\n\t\tif (s->bbio == s->wbio)\n\t\t\t{\n\t\t\ts->wbio=BIO_pop(s->wbio);\n\t\t\t}\n\t\tBIO_free(s->bbio);\n\t\ts->bbio=NULL;\n\t\t}\n\tif (s->rbio != NULL)\n\t\tBIO_free_all(s->rbio);\n\tif ((s->wbio != NULL) && (s->wbio != s->rbio))\n\t\tBIO_free_all(s->wbio);\n\n\tif (s->init_buf != NULL) BUF_MEM_free(s->init_buf);\n\n\t\/* add extra stuff *\/\n\tif (s->cipher_list != NULL) sk_SSL_CIPHER_free(s->cipher_list);\n\tif (s->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(s->cipher_list_by_id);\n\n\t\/* Make the next call work :-) *\/\n\tif (s->session != NULL)\n\t\t{\n\t\tssl_clear_bad_session(s);\n\t\tSSL_SESSION_free(s->session);\n\t\t}\n\n\tssl_clear_cipher_ctx(s);\n\tssl_clear_hash_ctx(&s->read_hash);\n\tssl_clear_hash_ctx(&s->write_hash);\n\n\tif (s->cert != NULL) ssl_cert_free(s->cert);\n\t\/* Free up if allocated *\/\n\n#ifndef OPENSSL_NO_TLSEXT\n\tif (s->tlsext_hostname)\n\t\tOPENSSL_free(s->tlsext_hostname);\n\tif (s->initial_ctx) SSL_CTX_free(s->initial_ctx);\n#ifndef OPENSSL_NO_EC\n\tif (s->tlsext_ecpointformatlist) OPENSSL_free(s->tlsext_ecpointformatlist);\n\tif (s->tlsext_ellipticcurvelist) OPENSSL_free(s->tlsext_ellipticcurvelist);\n#endif \/* OPENSSL_NO_EC *\/\n\tif (s->tlsext_opaque_prf_input) OPENSSL_free(s->tlsext_opaque_prf_input);\n\tif (s->tlsext_ocsp_exts)\n\t\tsk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts,\n\t\t\t\t\t\tX509_EXTENSION_free);\n\tif (s->tlsext_ocsp_ids)\n\t\tsk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free);\n\tif (s->tlsext_ocsp_resp)\n\t\tOPENSSL_free(s->tlsext_ocsp_resp);\n#endif\n\n\tif (s->client_CA != NULL)\n\t\tsk_X509_NAME_pop_free(s->client_CA,X509_NAME_free);\n\n\tif (s->method != NULL) s->method->ssl_free(s);\n\n\tif (s->ctx) SSL_CTX_free(s->ctx);\n\n#ifndef\tOPENSSL_NO_KRB5\n\tif (s->kssl_ctx != NULL)\n\t\tkssl_ctx_free(s->kssl_ctx);\n#endif\t\/* OPENSSL_NO_KRB5 *\/\n\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)\n\tif (s->next_proto_negotiated)\n\t\tOPENSSL_free(s->next_proto_negotiated);\n#endif\n\n\tOPENSSL_free(s);\n\t}","target":0,"code_token_length":819,"total_token_length":1055,"max_tokens_setting":2048} +{"idx":65501,"func":"Status ValidateInput(const OpInputList& indices_list_in,\n const OpInputList& values_list_in,\n const OpInputList& shapes_list_in,\n const OpInputList& dense_list_in,\n const DataType& internal_type) {\n const auto size = indices_list_in.size();\n \/\/ Only perform internal_type check for SparseCrossOp.\n \/\/ Check if the internal_type is not invalid before doing so.\n bool check_type = internal_type != DT_INVALID;\n \/\/ Validates indices_list_in OpInputList.\n for (int i = 0; i < size; i++) {\n if (check_type && indices_list_in[i].dtype() != DT_INT64) {\n return errors::InvalidArgument(\"Input indices should be of type \",\n DT_INT64, \" but received \",\n indices_list_in[i].dtype());\n }\n if (!TensorShapeUtils::IsMatrix(indices_list_in[i].shape())) {\n return errors::InvalidArgument(\n \"Input indices should be a matrix but received shape \",\n indices_list_in[i].shape().DebugString(), \" at position \", i);\n }\n if (indices_list_in[i].shape().dim_size(1) != 2) {\n return errors::InvalidArgument(\"Expected D2 of index to be 2 got \",\n indices_list_in[i].shape().dim_size(1),\n \" at position \", i);\n }\n }\n\n \/\/ Validates values_list_in OpInputList.\n if (values_list_in.size() != size) {\n return errors::InvalidArgument(\"Expected \", size, \" input values, got \",\n values_list_in.size());\n }\n for (int i = 0; i < size; i++) {\n \/\/ Make sure to avoid the expected type to be string, but input values to be\n \/\/ int64.\n if (check_type && internal_type == DT_STRING &&\n values_list_in[i].dtype() == DT_INT64) {\n return errors::InvalidArgument(\"Input values should be of internal type \",\n internal_type, \" but received \",\n values_list_in[i].dtype());\n }\n if (!TensorShapeUtils::IsVector(values_list_in[i].shape())) {\n return errors::InvalidArgument(\n \"Input values should be a vector but received shape \",\n values_list_in[i].shape().DebugString(), \" at position \", i);\n }\n if (indices_list_in[i].shape().dim_size(0) !=\n values_list_in[i].shape().dim_size(0)) {\n return errors::InvalidArgument(\n \"Expected size of values to be \",\n indices_list_in[i].shape().dim_size(0), \" got \",\n values_list_in[i].shape().dim_size(0), \" at position \", i);\n }\n }\n\n \/\/ Validates shapes_list_in OpInputList\n if (shapes_list_in.size() != size) {\n return errors::InvalidArgument(\"Expected \", size, \" input shapes, got \",\n shapes_list_in.size());\n }\n for (int i = 0; i < size; i++) {\n if (check_type && shapes_list_in[i].dtype() != DT_INT64) {\n return errors::InvalidArgument(\"Input shape should be of type \", DT_INT64,\n \" but received \",\n shapes_list_in[i].dtype());\n }\n if (!TensorShapeUtils::IsVector(shapes_list_in[i].shape())) {\n return errors::InvalidArgument(\n \"Input shapes should be a vector but received shape \",\n shapes_list_in[i].shape().DebugString(), \" at position \", i);\n }\n\n if (shapes_list_in[i].vec().size() != 2) {\n return errors::InvalidArgument(\"shape should imply a 2D tensor, but got \",\n shapes_list_in[i].shape().DebugString(),\n \" at position \", i);\n }\n }\n\n \/\/ Validates dense_list_in OpInputList\n for (int i = 0; i < dense_list_in.size(); ++i) {\n \/\/ Make sure to avoid the expected type to be string, but input values to be\n \/\/ int64.\n if (check_type && internal_type == DT_STRING &&\n dense_list_in[i].dtype() == DT_INT64) {\n return errors::InvalidArgument(\"Dense inputs should be of internal type \",\n internal_type, \" but received \",\n dense_list_in[i].dtype());\n }\n if (!TensorShapeUtils::IsMatrix(dense_list_in[i].shape())) {\n return errors::InvalidArgument(\n \"Dense inputs should be a matrix but received shape \",\n dense_list_in[i].shape().DebugString(), \" at position \", i);\n }\n }\n\n \/\/ Validates batch sizes. (Note: we do this after validating the input\n \/\/ shapes, because CalculateBatchSize() depends on inputs having valid\n \/\/ shapes).\n const auto batch_size = CalculateBatchSize(shapes_list_in, dense_list_in);\n for (int i = 0; i < size; i++) {\n if (shapes_list_in[i].vec()(0) != batch_size) {\n return errors::InvalidArgument(\"Expected batch size \", batch_size,\n \" got \", shapes_list_in[i].vec()(0),\n \" at position \", i);\n }\n }\n for (int i = 0; i < dense_list_in.size(); ++i) {\n if (dense_list_in[i].dim_size(0) != batch_size) {\n return errors::InvalidArgument(\"Expected batch size \", batch_size,\n \" got \", dense_list_in[i].dim_size(0),\n \" at dense tensor \", i);\n }\n }\n\n return Status::OK();\n}","target":0,"code_token_length":1210,"total_token_length":1446,"max_tokens_setting":2048} +{"idx":418688,"func":"fix_message_string(\n message_t *message,\n gboolean want_quoted,\n char *msg)\n{\n char *m;\n char num[NUM_STR_SIZE];\n char code[100];\n char *c;\n int i;\n char *quoted;\n GString *result;\n\n if (!msg)\n\treturn NULL;\n\n result = g_string_sized_new(strlen(msg)*2);\n for (m = msg; *m != '\\0'; m++) {\n\tc = code;\n\tif (*m == '%' && *(m+1) == '%') {\n\t g_string_append_c(result, *m);\n\t m++;\n\t} else if (*m == '%' && *(m+1) == '{') {\n\t m += 2;\n\t while (*m != '}') {\n\t\t*c++ = *m++;\n\t }\n\t *c = '\\0';\n\t if (strcmp(code, \"file\") == 0) {\n\t\tif (want_quoted) {\n\t\t quoted = quote_string(message->file);\n\t\t g_string_append(result, quoted);\n\t\t g_free(quoted);\n\t\t} else {\n\t\t g_string_append(result, message->file);\n\t\t}\n\t } else if (strcmp(code, \"line\") == 0) {\n\t\tg_snprintf(num, sizeof(num),\n \"%d\", message->line);\n\t\tg_string_append(result, num);\n\t } else if (strcmp(code, \"code\") == 0) {\n\t\tg_snprintf(num, sizeof(num),\n \"%d\", message->code);\n\t\tg_string_append(result, num);\n\t } else if (strcmp(code, \"severity\") == 0) {\n\t\tg_string_append(result, severity_name(message->severity));\n\t } else if (strcmp(code, \"errnostr\") == 0) {\n\t\tg_string_append(result, message->errnostr);\n\t } else if (strcmp(code, \"errnocode\") == 0) {\n\t\tg_string_append(result, message->errnocode);\n\t } else {\n\t\tchar *c = strchr(code, ':');\n\t\tchar *format = NULL;\n\t\tchar *ccode = code;\n\t\tif (c) {\n\t\t *c = '\\0';\n\t\t format = code;\n\t\t ccode = c+1;\n\t\t}\n\t\ti = 0;\n\t\twhile (message->arg_array[i].key != NULL &&\n\t\t strcmp(message->arg_array[i].key, ccode) != 0) {\n\t\t i++;\n\t\t}\n\t\tif (message->arg_array[i].key != NULL) {\n\t\t if (format) {\n\t\t\tassert(message->arg_array[i].value.type == MESSAGE_STRING);\n\t\t\tif (strcmp(format,\"size\") == 0) {\n\t\t\t long long llvalue = atoll(message->arg_array[i].value.string);\n\t\t\t g_string_append_printf(result, \"%lld %sB\", llvalue\/getconf_unit_divisor(),\n\t\t\t\t\t\t\t\t getconf_str(CNF_DISPLAYUNIT));\n\t\t\t} else {\n\t\t\t g_string_append(result, \"BAD-FORMAT\");\n\t\t\t}\n\t\t } else {\n\t\t\tif (message->arg_array[i].value.type == MESSAGE_NULL) {\n\t\t\t} else if (message->arg_array[i].value.type == MESSAGE_STRING) {\n\t\t\t if (message->arg_array[i].value.string == NULL) {\n\t\t\t\tg_string_append(result, \"null\");\n\t\t\t } else if (want_quoted) {\n\t\t\t\tquoted = quote_string(message->arg_array[i].value.string);\n\t\t\t\tg_string_append(result, quoted);\n\t\t\t\tg_free(quoted);\n\t\t\t } else {\n\t\t\t\tg_string_append(result, message->arg_array[i].value.string);\n\t\t\t }\n\t\t\t}\n\t\t }\n\t\t} else {\n\t\t g_string_append(result, \"NONE\");\n\t\t}\n\t }\n\t} else {\n\t g_string_append_c(result, *m);\n\t}\n }\n\n return result;\n}","target":0,"code_token_length":799,"total_token_length":1035,"max_tokens_setting":2048} +{"idx":135068,"func":"static MagickBooleanType ReadPSDLayer(Image *image,const ImageInfo *image_info,\n const PSDInfo *psd_info,LayerInfo* layer_info,ExceptionInfo *exception)\n{\n char\n message[MagickPathExtent];\n\n MagickBooleanType\n status;\n\n PSDCompressionType\n compression;\n\n ssize_t\n j;\n\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" setting up new layer image\");\n if (psd_info->mode != IndexedMode)\n (void) SetImageBackgroundColor(layer_info->image,exception);\n layer_info->image->compose=PSDBlendModeToCompositeOperator(\n layer_info->blendkey);\n if (layer_info->visible == MagickFalse)\n layer_info->image->compose=NoCompositeOp;\n if (psd_info->mode == CMYKMode)\n SetImageColorspace(layer_info->image,CMYKColorspace,exception);\n else if ((psd_info->mode == BitmapMode) || (psd_info->mode == DuotoneMode) ||\n (psd_info->mode == GrayscaleMode))\n SetImageColorspace(layer_info->image,GRAYColorspace,exception);\n \/*\n Set up some hidden attributes for folks that need them.\n *\/\n (void) FormatLocaleString(message,MagickPathExtent,\"%.20g\",\n (double) layer_info->page.x);\n (void) SetImageArtifact(layer_info->image,\"psd:layer.x\",message);\n (void) FormatLocaleString(message,MagickPathExtent,\"%.20g\",\n (double) layer_info->page.y);\n (void) SetImageArtifact(layer_info->image,\"psd:layer.y\",message);\n (void) FormatLocaleString(message,MagickPathExtent,\"%.20g\",(double)\n layer_info->opacity);\n (void) SetImageArtifact(layer_info->image,\"psd:layer.opacity\",message);\n (void) SetImageProperty(layer_info->image,\"label\",(char *) layer_info->name,\n exception);\n\n status=MagickTrue;\n for (j=0; j < (ssize_t) layer_info->channels; j++)\n {\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" reading data for channel %.20g\",(double) j);\n\n compression=(PSDCompressionType) ReadBlobShort(layer_info->image);\n layer_info->image->compression=ConvertPSDCompression(compression);\n if (layer_info->channel_info[j].type == -1)\n layer_info->image->alpha_trait=BlendPixelTrait;\n\n status=ReadPSDChannel(layer_info->image,image_info,psd_info,layer_info,j,\n compression,exception);\n\n if (status == MagickFalse)\n break;\n }\n\n if (status != MagickFalse)\n status=ApplyPSDLayerOpacity(layer_info->image,layer_info->opacity,\n MagickFalse,exception);\n\n if ((status != MagickFalse) &&\n (layer_info->image->colorspace == CMYKColorspace))\n status=NegateCMYK(layer_info->image,exception);\n\n if ((status != MagickFalse) && (layer_info->mask.image != (Image *) NULL))\n {\n const char\n *option;\n \n layer_info->mask.image->page.x=layer_info->mask.page.x;\n layer_info->mask.image->page.y=layer_info->mask.page.y;\n \/* Do not composite the mask when it is disabled *\/\n if ((layer_info->mask.flags & 0x02) == 0x02)\n layer_info->mask.image->compose=NoCompositeOp;\n else\n status=ApplyPSDOpacityMask(layer_info->image,layer_info->mask.image,\n layer_info->mask.background == 0 ? 0 : QuantumRange,MagickFalse,\n exception);\n option=GetImageOption(image_info,\"psd:preserve-opacity-mask\");\n if (IsStringTrue(option) != MagickFalse)\n PreservePSDOpacityMask(image,layer_info,exception);\n layer_info->mask.image=DestroyImage(layer_info->mask.image);\n }\n\n return(status);\n}","target":0,"code_token_length":920,"total_token_length":1156,"max_tokens_setting":2048} +{"idx":213810,"func":"WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(\n RenderFrame* render_frame,\n const NavigationPolicyInfo& info) {\n Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame,\n info.urlRequest));\n\n if (SiteIsolationPolicy::IsSwappedOutStateForbidden() && is_subframe_) {\n } else {\n if (is_swapped_out_) {\n if (info.urlRequest.url() != GURL(kSwappedOutURL)) {\n if (info.frame->parent() == NULL) {\n OpenURL(info.frame, info.urlRequest.url(), referrer,\n info.defaultPolicy);\n return blink::WebNavigationPolicyIgnore; \/\/ Suppress the load here.\n }\n\n return blink::WebNavigationPolicyIgnore;\n }\n\n return info.defaultPolicy;\n }\n }\n\n const GURL& url = info.urlRequest.url();\n\n DocumentState* document_state = static_cast(info.extraData);\n bool is_content_initiated =\n document_state->navigation_state()->IsContentInitiated();\n\n if (is_content_initiated) {\n bool is_form_post =\n ((info.navigationType == blink::WebNavigationTypeFormSubmitted) ||\n (info.navigationType == blink::WebNavigationTypeFormResubmitted)) &&\n base::EqualsASCII(base::StringPiece16(info.urlRequest.httpMethod()),\n \"POST\");\n bool browser_handles_request =\n render_view_->renderer_preferences_\n .browser_handles_non_local_top_level_requests\n && IsNonLocalTopLevelNavigation(url, info.frame, info.navigationType,\n is_form_post);\n if (!browser_handles_request) {\n browser_handles_request = IsTopLevelNavigation(info.frame) &&\n render_view_->renderer_preferences_\n .browser_handles_all_top_level_requests;\n }\n\n if (browser_handles_request) {\n OpenURL(info.frame, url, referrer, info.defaultPolicy);\n return blink::WebNavigationPolicyIgnore; \/\/ Suppress the load here.\n }\n }\n\n GURL old_url(info.frame->dataSource()->request().url());\n\n if (!info.frame->parent() && is_content_initiated &&\n !url.SchemeIs(url::kAboutScheme)) {\n bool send_referrer = false;\n\n int cumulative_bindings = RenderProcess::current()->GetEnabledBindings();\n bool is_initial_navigation = render_view_->history_list_length_ == 0;\n bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) ||\n (cumulative_bindings & BINDINGS_POLICY_WEB_UI) ||\n url.SchemeIs(kViewSourceScheme) ||\n (info.frame->isViewSourceModeEnabled() &&\n info.navigationType != blink::WebNavigationTypeReload);\n\n if (!should_fork && url.SchemeIs(url::kFileScheme)) {\n GURL source_url(old_url);\n if (is_initial_navigation && source_url.is_empty() &&\n info.frame->opener())\n source_url = info.frame->opener()->top()->document().url();\n DCHECK(!source_url.is_empty());\n should_fork = !source_url.SchemeIs(url::kFileScheme);\n }\n\n if (!should_fork) {\n should_fork = GetContentClient()->renderer()->ShouldFork(\n info.frame, url, info.urlRequest.httpMethod().utf8(),\n is_initial_navigation, info.isRedirect, &send_referrer);\n }\n\n if (should_fork) {\n OpenURL(info.frame, url, send_referrer ? referrer : Referrer(),\n info.defaultPolicy);\n return blink::WebNavigationPolicyIgnore; \/\/ Suppress the load here.\n }\n }\n\n bool is_fork =\n old_url == GURL(url::kAboutBlankURL) &&\n render_view_->historyBackListCount() < 1 &&\n render_view_->historyForwardListCount() < 1 &&\n info.frame->opener() == NULL &&\n info.frame->parent() == NULL &&\n is_content_initiated &&\n info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&\n info.navigationType == blink::WebNavigationTypeOther;\n\n if (is_fork) {\n OpenURL(info.frame, url, Referrer(), info.defaultPolicy);\n return blink::WebNavigationPolicyIgnore;\n }\n\n if (base::CommandLine::ForCurrentProcess()->HasSwitch(\n switches::kEnableBrowserSideNavigation) &&\n info.urlRequest.checkForBrowserSideNavigation() &&\n ShouldMakeNetworkRequestForURL(url)) {\n BeginNavigation(&info.urlRequest);\n return blink::WebNavigationPolicyIgnore;\n }\n\n return info.defaultPolicy;\n}\n","target":0,"code_token_length":950,"total_token_length":1186,"max_tokens_setting":2048} +{"idx":382270,"func":"ShowUsage(const char *title)\n{\n\tStringInfoData str;\n\tstruct timeval user,\n\t\t\t\tsys;\n\tstruct timeval elapse_t;\n\tstruct rusage r;\n\n\tgetrusage(RUSAGE_SELF, &r);\n\tgettimeofday(&elapse_t, NULL);\n\tmemcpy((char *) &user, (char *) &r.ru_utime, sizeof(user));\n\tmemcpy((char *) &sys, (char *) &r.ru_stime, sizeof(sys));\n\tif (elapse_t.tv_usec < Save_t.tv_usec)\n\t{\n\t\telapse_t.tv_sec--;\n\t\telapse_t.tv_usec += 1000000;\n\t}\n\tif (r.ru_utime.tv_usec < Save_r.ru_utime.tv_usec)\n\t{\n\t\tr.ru_utime.tv_sec--;\n\t\tr.ru_utime.tv_usec += 1000000;\n\t}\n\tif (r.ru_stime.tv_usec < Save_r.ru_stime.tv_usec)\n\t{\n\t\tr.ru_stime.tv_sec--;\n\t\tr.ru_stime.tv_usec += 1000000;\n\t}\n\n\t\/*\n\t * the only stats we don't show here are for memory usage -- i can't\n\t * figure out how to interpret the relevant fields in the rusage struct,\n\t * and they change names across o\/s platforms, anyway. if you can figure\n\t * out what the entries mean, you can somehow extract resident set size,\n\t * shared text size, and unshared data and stack sizes.\n\t *\/\n\tinitStringInfo(&str);\n\n\tappendStringInfoString(&str, \"! system usage stats:\\n\");\n\tappendStringInfo(&str,\n\t\t\t\t\"!\\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\\n\",\n\t\t\t\t\t (long) (elapse_t.tv_sec - Save_t.tv_sec),\n\t\t\t\t\t (long) (elapse_t.tv_usec - Save_t.tv_usec),\n\t\t\t\t\t (long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec),\n\t\t\t\t\t (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),\n\t\t\t\t\t (long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec),\n\t\t\t\t\t (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec));\n\tappendStringInfo(&str,\n\t\t\t\t\t \"!\\t[%ld.%06ld user %ld.%06ld sys total]\\n\",\n\t\t\t\t\t (long) user.tv_sec,\n\t\t\t\t\t (long) user.tv_usec,\n\t\t\t\t\t (long) sys.tv_sec,\n\t\t\t\t\t (long) sys.tv_usec);\n#if defined(HAVE_GETRUSAGE)\n\tappendStringInfo(&str,\n\t\t\t\t\t \"!\\t%ld\/%ld [%ld\/%ld] filesystem blocks in\/out\\n\",\n\t\t\t\t\t r.ru_inblock - Save_r.ru_inblock,\n\t\/* they only drink coffee at dec *\/\n\t\t\t\t\t r.ru_oublock - Save_r.ru_oublock,\n\t\t\t\t\t r.ru_inblock, r.ru_oublock);\n\tappendStringInfo(&str,\n\t\t\t \"!\\t%ld\/%ld [%ld\/%ld] page faults\/reclaims, %ld [%ld] swaps\\n\",\n\t\t\t\t\t r.ru_majflt - Save_r.ru_majflt,\n\t\t\t\t\t r.ru_minflt - Save_r.ru_minflt,\n\t\t\t\t\t r.ru_majflt, r.ru_minflt,\n\t\t\t\t\t r.ru_nswap - Save_r.ru_nswap,\n\t\t\t\t\t r.ru_nswap);\n\tappendStringInfo(&str,\n\t\t \"!\\t%ld [%ld] signals rcvd, %ld\/%ld [%ld\/%ld] messages rcvd\/sent\\n\",\n\t\t\t\t\t r.ru_nsignals - Save_r.ru_nsignals,\n\t\t\t\t\t r.ru_nsignals,\n\t\t\t\t\t r.ru_msgrcv - Save_r.ru_msgrcv,\n\t\t\t\t\t r.ru_msgsnd - Save_r.ru_msgsnd,\n\t\t\t\t\t r.ru_msgrcv, r.ru_msgsnd);\n\tappendStringInfo(&str,\n\t\t\t \"!\\t%ld\/%ld [%ld\/%ld] voluntary\/involuntary context switches\\n\",\n\t\t\t\t\t r.ru_nvcsw - Save_r.ru_nvcsw,\n\t\t\t\t\t r.ru_nivcsw - Save_r.ru_nivcsw,\n\t\t\t\t\t r.ru_nvcsw, r.ru_nivcsw);\n#endif \/* HAVE_GETRUSAGE *\/\n\n\t\/* remove trailing newline *\/\n\tif (str.data[str.len - 1] == '\\n')\n\t\tstr.data[--str.len] = '\\0';\n\n\tereport(LOG,\n\t\t\t(errmsg_internal(\"%s\", title),\n\t\t\t errdetail_internal(\"%s\", str.data)));\n\n\tpfree(str.data);\n}","target":0,"code_token_length":934,"total_token_length":1170,"max_tokens_setting":2048} +{"idx":104820,"func":"static int sctp_setsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, unsigned int optlen)\n{\n\tint retval = 0;\n\n\tpr_debug(\"%s: sk:%p, optname:%d\\n\", __func__, sk, optname);\n\n\t\/* I can hardly begin to describe how wrong this is. This is\n\t * so broken as to be worse than useless. The API draft\n\t * REALLY is NOT helpful here... I am not convinced that the\n\t * semantics of setsockopt() with a level OTHER THAN SOL_SCTP\n\t * are at all well-founded.\n\t *\/\n\tif (level != SOL_SCTP) {\n\t\tstruct sctp_af *af = sctp_sk(sk)->pf->af;\n\t\tretval = af->setsockopt(sk, level, optname, optval, optlen);\n\t\tgoto out_nounlock;\n\t}\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\tcase SCTP_SOCKOPT_BINDX_ADD:\n\t\t\/* 'optlen' is the size of the addresses buffer. *\/\n\t\tretval = sctp_setsockopt_bindx(sk, (struct sockaddr __user *)optval,\n\t\t\t\t\t optlen, SCTP_BINDX_ADD_ADDR);\n\t\tbreak;\n\n\tcase SCTP_SOCKOPT_BINDX_REM:\n\t\t\/* 'optlen' is the size of the addresses buffer. *\/\n\t\tretval = sctp_setsockopt_bindx(sk, (struct sockaddr __user *)optval,\n\t\t\t\t\t optlen, SCTP_BINDX_REM_ADDR);\n\t\tbreak;\n\n\tcase SCTP_SOCKOPT_CONNECTX_OLD:\n\t\t\/* 'optlen' is the size of the addresses buffer. *\/\n\t\tretval = sctp_setsockopt_connectx_old(sk,\n\t\t\t\t\t (struct sockaddr __user *)optval,\n\t\t\t\t\t optlen);\n\t\tbreak;\n\n\tcase SCTP_SOCKOPT_CONNECTX:\n\t\t\/* 'optlen' is the size of the addresses buffer. *\/\n\t\tretval = sctp_setsockopt_connectx(sk,\n\t\t\t\t\t (struct sockaddr __user *)optval,\n\t\t\t\t\t optlen);\n\t\tbreak;\n\n\tcase SCTP_DISABLE_FRAGMENTS:\n\t\tretval = sctp_setsockopt_disable_fragments(sk, optval, optlen);\n\t\tbreak;\n\n\tcase SCTP_EVENTS:\n\t\tretval = sctp_setsockopt_events(sk, optval, optlen);\n\t\tbreak;\n\n\tcase SCTP_AUTOCLOSE:\n\t\tretval = sctp_setsockopt_autoclose(sk, optval, optlen);\n\t\tbreak;\n\n\tcase SCTP_PEER_ADDR_PARAMS:\n\t\tretval = sctp_setsockopt_peer_addr_params(sk, optval, optlen);\n\t\tbreak;\n\n\tcase SCTP_DELAYED_SACK:\n\t\tretval = sctp_setsockopt_delayed_ack(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_PARTIAL_DELIVERY_POINT:\n\t\tretval = sctp_setsockopt_partial_delivery_point(sk, optval, optlen);\n\t\tbreak;\n\n\tcase SCTP_INITMSG:\n\t\tretval = sctp_setsockopt_initmsg(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_DEFAULT_SEND_PARAM:\n\t\tretval = sctp_setsockopt_default_send_param(sk, optval,\n\t\t\t\t\t\t\t optlen);\n\t\tbreak;\n\tcase SCTP_DEFAULT_SNDINFO:\n\t\tretval = sctp_setsockopt_default_sndinfo(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_PRIMARY_ADDR:\n\t\tretval = sctp_setsockopt_primary_addr(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_SET_PEER_PRIMARY_ADDR:\n\t\tretval = sctp_setsockopt_peer_primary_addr(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_NODELAY:\n\t\tretval = sctp_setsockopt_nodelay(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_RTOINFO:\n\t\tretval = sctp_setsockopt_rtoinfo(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_ASSOCINFO:\n\t\tretval = sctp_setsockopt_associnfo(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_I_WANT_MAPPED_V4_ADDR:\n\t\tretval = sctp_setsockopt_mappedv4(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_MAXSEG:\n\t\tretval = sctp_setsockopt_maxseg(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_ADAPTATION_LAYER:\n\t\tretval = sctp_setsockopt_adaptation_layer(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_CONTEXT:\n\t\tretval = sctp_setsockopt_context(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_FRAGMENT_INTERLEAVE:\n\t\tretval = sctp_setsockopt_fragment_interleave(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_MAX_BURST:\n\t\tretval = sctp_setsockopt_maxburst(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_AUTH_CHUNK:\n\t\tretval = sctp_setsockopt_auth_chunk(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_HMAC_IDENT:\n\t\tretval = sctp_setsockopt_hmac_ident(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_AUTH_KEY:\n\t\tretval = sctp_setsockopt_auth_key(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_AUTH_ACTIVE_KEY:\n\t\tretval = sctp_setsockopt_active_key(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_AUTH_DELETE_KEY:\n\t\tretval = sctp_setsockopt_del_key(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_AUTO_ASCONF:\n\t\tretval = sctp_setsockopt_auto_asconf(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_PEER_ADDR_THLDS:\n\t\tretval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_RECVRCVINFO:\n\t\tretval = sctp_setsockopt_recvrcvinfo(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_RECVNXTINFO:\n\t\tretval = sctp_setsockopt_recvnxtinfo(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_PR_SUPPORTED:\n\t\tretval = sctp_setsockopt_pr_supported(sk, optval, optlen);\n\t\tbreak;\n\tcase SCTP_DEFAULT_PRINFO:\n\t\tretval = sctp_setsockopt_default_prinfo(sk, optval, optlen);\n\t\tbreak;\n\tdefault:\n\t\tretval = -ENOPROTOOPT;\n\t\tbreak;\n\t}\n\n\trelease_sock(sk);\n\nout_nounlock:\n\treturn retval;\n}","target":0,"code_token_length":1329,"total_token_length":1565,"max_tokens_setting":2048} +{"idx":427398,"func":"static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)\n{\n uint8_t* config = qxl->pci.config;\n uint32_t pci_device_rev;\n uint32_t io_size;\n\n qemu_spice_display_init_common(&qxl->ssd);\n qxl->mode = QXL_MODE_UNDEFINED;\n qxl->num_memslots = NUM_MEMSLOTS;\n qemu_mutex_init(&qxl->track_lock);\n qemu_mutex_init(&qxl->async_lock);\n qxl->current_async = QXL_UNDEFINED_IO;\n qxl->guest_bug = 0;\n\n switch (qxl->revision) {\n case 1: \/* spice 0.4 -- qxl-1 *\/\n pci_device_rev = QXL_REVISION_STABLE_V04;\n io_size = 8;\n break;\n case 2: \/* spice 0.6 -- qxl-2 *\/\n pci_device_rev = QXL_REVISION_STABLE_V06;\n io_size = 16;\n break;\n case 3: \/* qxl-3 *\/\n pci_device_rev = QXL_REVISION_STABLE_V10;\n io_size = 32; \/* PCI region size must be pow2 *\/\n break;\n case 4: \/* qxl-4 *\/\n pci_device_rev = QXL_REVISION_STABLE_V12;\n io_size = pow2ceil(QXL_IO_RANGE_SIZE);\n break;\n default:\n error_setg(errp, \"Invalid revision %d for qxl device (max %d)\",\n qxl->revision, QXL_DEFAULT_REVISION);\n return;\n }\n\n pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);\n pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);\n\n qxl->rom_size = qxl_rom_size();\n memory_region_init_ram(&qxl->rom_bar, OBJECT(qxl), \"qxl.vrom\",\n qxl->rom_size, &error_fatal);\n init_qxl_rom(qxl);\n init_qxl_ram(qxl);\n\n qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);\n memory_region_init_ram(&qxl->vram_bar, OBJECT(qxl), \"qxl.vram\",\n qxl->vram_size, &error_fatal);\n memory_region_init_alias(&qxl->vram32_bar, OBJECT(qxl), \"qxl.vram32\",\n &qxl->vram_bar, 0, qxl->vram32_size);\n\n memory_region_init_io(&qxl->io_bar, OBJECT(qxl), &qxl_io_ops, qxl,\n \"qxl-ioports\", io_size);\n if (qxl->have_vga) {\n vga_dirty_log_start(&qxl->vga);\n }\n memory_region_set_flush_coalesced(&qxl->io_bar);\n\n\n pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,\n PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);\n\n pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,\n PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);\n\n pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,\n PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);\n\n pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,\n PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);\n\n if (qxl->vram32_size < qxl->vram_size) {\n \/*\n * Make the 64bit vram bar show up only in case it is\n * configured to be larger than the 32bit vram bar.\n *\/\n pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,\n PCI_BASE_ADDRESS_SPACE_MEMORY |\n PCI_BASE_ADDRESS_MEM_TYPE_64 |\n PCI_BASE_ADDRESS_MEM_PREFETCH,\n &qxl->vram_bar);\n }\n\n \/* print pci bar details *\/\n dprint(qxl, 1, \"ram\/%s: %\" PRId64 \" MB [region 0]\\n\",\n qxl->have_vga ? \"pri\" : \"sec\", qxl->vga.vram_size \/ MiB);\n dprint(qxl, 1, \"vram\/32: %\" PRIx64 \" MB [region 1]\\n\",\n qxl->vram32_size \/ MiB);\n dprint(qxl, 1, \"vram\/64: %\" PRIx64 \" MB %s\\n\",\n qxl->vram_size \/ MiB,\n qxl->vram32_size < qxl->vram_size ? \"[region 4]\" : \"[unmapped]\");\n\n qxl->ssd.qxl.base.sif = &qxl_interface.base;\n if (qemu_spice_add_display_interface(&qxl->ssd.qxl, qxl->vga.con) != 0) {\n error_setg(errp, \"qxl interface %d.%d not supported by spice-server\",\n SPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);\n return;\n }\n\n#if SPICE_SERVER_VERSION >= 0x000e02 \/* release 0.14.2 *\/\n char device_address[256] = \"\";\n if (qemu_spice_fill_device_address(qxl->vga.con, device_address, 256)) {\n spice_qxl_set_device_info(&qxl->ssd.qxl,\n device_address,\n 0,\n qxl->max_outputs);\n }\n#endif\n\n qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);\n\n qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);\n qxl_reset_state(qxl);\n\n qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);\n qxl->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl->ssd);\n}","target":0,"code_token_length":1326,"total_token_length":1562,"max_tokens_setting":2048} +{"idx":262417,"func":"TEST_P(SslSocketTest, RevokedIntermediateCertificateCRLInTrustedCA) {\n\n \/\/ This should succeed, since the crl chain is complete.\n \/\/\n \/\/ Trust chain contains:\n \/\/ - Root authority certificate (i.e., ca_cert.pem)\n \/\/ - Root authority certificate revocation list (i.e., ca_cert.crl)\n \/\/ - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n \/\/ - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl)\n const std::string complete_server_ctx_yaml = R\"EOF(\n common_tls_context:\n tls_certificates:\n certificate_chain:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n private_key:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n validation_context:\n trusted_ca:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain_with_crl_chain.pem\"\n)EOF\";\n\n \/\/ This should fail, since the crl chain is incomplete.\n \/\/\n \/\/ Trust chain contains:\n \/\/ - Root authority certificate (i.e., ca_cert.pem)\n \/\/ - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n \/\/ - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl)\n \/\/\n \/\/ Trust chain omits:\n \/\/ - Root authority certificate revocation list (i.e., ca_cert.crl)\n const std::string incomplete_server_ctx_yaml = R\"EOF(\n common_tls_context:\n tls_certificates:\n certificate_chain:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n private_key:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n validation_context:\n trusted_ca:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain_with_crl.pem\"\n)EOF\";\n\n \/\/ This should fail, since the certificate has been revoked.\n const std::string revoked_client_ctx_yaml = R\"EOF(\n common_tls_context:\n tls_certificates:\n certificate_chain:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_cert.pem\"\n private_key:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_key.pem\"\n)EOF\";\n\n \/\/ This should succeed, since the certificate has not been revoked.\n const std::string unrevoked_client_ctx_yaml = R\"EOF(\n common_tls_context:\n tls_certificates:\n certificate_chain:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns4_cert.pem\"\n private_key:\n filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns4_key.pem\"\n)EOF\";\n\n \/\/ Ensure that incomplete crl chains fail with revoked certificates.\n TestUtilOptions incomplete_revoked_test_options(revoked_client_ctx_yaml,\n incomplete_server_ctx_yaml, false, GetParam());\n testUtil(incomplete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n \/\/ Ensure that incomplete crl chains fail with unrevoked certificates.\n TestUtilOptions incomplete_unrevoked_test_options(unrevoked_client_ctx_yaml,\n incomplete_server_ctx_yaml, false, GetParam());\n testUtil(incomplete_unrevoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n .setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_CRL));\n\n \/\/ Ensure that complete crl chains fail with revoked certificates.\n TestUtilOptions complete_revoked_test_options(revoked_client_ctx_yaml, complete_server_ctx_yaml,\n false, GetParam());\n testUtil(complete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n \/\/ Ensure that complete crl chains succeed with unrevoked certificates.\n TestUtilOptions complete_unrevoked_test_options(unrevoked_client_ctx_yaml,\n complete_server_ctx_yaml, true, GetParam());\n testUtil(complete_unrevoked_test_options.setExpectedSerialNumber(TEST_SAN_DNS4_CERT_SERIAL));\n}","target":0,"code_token_length":958,"total_token_length":1194,"max_tokens_setting":2048} +{"idx":26835,"func":"ParseResult mime_scanner_get ( MIMEScanner * S , const char * * raw_input_s , const char * raw_input_e , const char * * output_s , const char * * output_e , bool * output_shares_raw_input , bool raw_input_eof , int raw_input_scan_type ) {\n const char * raw_input_c , * lf_ptr ;\n ParseResult zret = PARSE_RESULT_CONT ;\n static const char RAW_CR = ParseRules : : CHAR_CR ;\n ink_assert ( ( raw_input_s != nullptr ) && ( * raw_input_s != nullptr ) ) ;\n ink_assert ( raw_input_e != nullptr ) ;\n raw_input_c = * raw_input_s ;\n while ( PARSE_RESULT_CONT == zret && raw_input_c < raw_input_e ) {\n ptrdiff_t runway = raw_input_e - raw_input_c ;\n switch ( S -> m_state ) {\n case MIME_PARSE_BEFORE : if ( ParseRules : : is_cr ( * raw_input_c ) ) {\n ++ raw_input_c ;\n if ( runway >= 2 && ParseRules : : is_lf ( * raw_input_c ) ) {\n ++ raw_input_c ;\n zret = PARSE_RESULT_DONE ;\n }\n else {\n S -> m_state = MIME_PARSE_FOUND_CR ;\n }\n }\n else if ( ParseRules : : is_lf ( * raw_input_c ) ) {\n ++ raw_input_c ;\n zret = PARSE_RESULT_DONE ;\n }\n else {\n S -> m_state = MIME_PARSE_INSIDE ;\n }\n break ;\n case MIME_PARSE_FOUND_CR : if ( ParseRules : : is_lf ( * raw_input_c ) ) {\n ++ raw_input_c ;\n zret = PARSE_RESULT_DONE ;\n }\n else {\n mime_scanner_append ( S , & RAW_CR , 1 ) ;\n S -> m_state = MIME_PARSE_INSIDE ;\n }\n break ;\n case MIME_PARSE_INSIDE : lf_ptr = static_cast < const char * > ( memchr ( raw_input_c , ParseRules : : CHAR_LF , runway ) ) ;\n if ( lf_ptr ) {\n raw_input_c = lf_ptr + 1 ;\n if ( MIME_SCANNER_TYPE_LINE == raw_input_scan_type ) {\n zret = PARSE_RESULT_OK ;\n S -> m_state = MIME_PARSE_BEFORE ;\n }\n else {\n S -> m_state = MIME_PARSE_AFTER ;\n }\n }\n else {\n raw_input_c = raw_input_e ;\n }\n break ;\n case MIME_PARSE_AFTER : if ( ParseRules : : is_ws ( * raw_input_c ) ) {\n char * unfold = const_cast < char * > ( raw_input_c - 1 ) ;\n * unfold -- = ' ' ;\n if ( ParseRules : : is_cr ( * unfold ) ) {\n * unfold = ' ' ;\n }\n S -> m_state = MIME_PARSE_INSIDE ;\n }\n else {\n S -> m_state = MIME_PARSE_BEFORE ;\n zret = PARSE_RESULT_OK ;\n }\n break ;\n }\n }\n ptrdiff_t data_size = raw_input_c - * raw_input_s ;\n if ( PARSE_RESULT_CONT == zret ) {\n if ( raw_input_eof ) {\n if ( 0 == data_size ) {\n if ( MIME_PARSE_INSIDE != S -> m_state ) {\n S -> m_state = MIME_PARSE_BEFORE ;\n zret = PARSE_RESULT_DONE ;\n }\n else {\n zret = PARSE_RESULT_ERROR ;\n }\n }\n else if ( MIME_PARSE_AFTER == S -> m_state ) {\n S -> m_state = MIME_PARSE_BEFORE ;\n zret = PARSE_RESULT_OK ;\n }\n else {\n zret = PARSE_RESULT_ERROR ;\n }\n }\n else if ( data_size ) {\n if ( MIME_PARSE_INSIDE == S -> m_state ) {\n mime_scanner_append ( S , * raw_input_s , data_size ) ;\n data_size = 0 ;\n }\n else if ( MIME_PARSE_AFTER == S -> m_state ) {\n S -> m_state = MIME_PARSE_BEFORE ;\n zret = PARSE_RESULT_OK ;\n }\n }\n }\n if ( data_size && S -> m_line_length ) {\n mime_scanner_append ( S , * raw_input_s , data_size ) ;\n }\n * output_shares_raw_input = 0 == S -> m_line_length ;\n if ( PARSE_RESULT_CONT != zret ) {\n if ( 0 != S -> m_line_length ) {\n * output_s = S -> m_line ;\n * output_e = * output_s + S -> m_line_length ;\n S -> m_line_length = 0 ;\n }\n else {\n * output_s = * raw_input_s ;\n * output_e = raw_input_c ;\n }\n }\n if ( zret != PARSE_RESULT_ERROR && memchr ( * raw_input_s , '\\0' , raw_input_c - * raw_input_s ) != nullptr ) {\n zret = PARSE_RESULT_ERROR ;\n }\n * raw_input_s = raw_input_c ;\n return zret ;\n }","target":0,"code_token_length":965,"total_token_length":1201,"max_tokens_setting":2048} +{"idx":511434,"func":"skip_to_histexp (string, start, delims, flags)\n char *string;\n int start;\n char *delims;\n int flags;\n{\n int i, pass_next, backq, dquote, si, c, oldjmp;\n int histexp_comsub, histexp_backq, old_dquote;\n size_t slen;\n char *temp, open[3];\n DECLARE_MBSTATE;\n\n slen = strlen (string + start) + start;\n oldjmp = no_longjmp_on_fatal_error;\n if (flags & SD_NOJMP)\n no_longjmp_on_fatal_error = 1;\n\n histexp_comsub = histexp_backq = old_dquote = 0;\n\n i = start;\n pass_next = backq = dquote = 0;\n while (c = string[i])\n {\n if (pass_next)\n\t{\n\t pass_next = 0;\n\t if (c == 0)\n\t CQ_RETURN(i);\n\t ADVANCE_CHAR (string, slen, i);\n\t continue;\n\t}\n else if (c == '\\\\')\n\t{\n\t pass_next = 1;\n\t i++;\n\t continue;\n\t}\n else if (backq && c == '`')\n\t{\n\t backq = 0;\n\t histexp_backq--;\n\t dquote = old_dquote;\n\t i++;\n\t continue;\n\t}\n else if (c == '`')\n\t{\n\t backq = 1;\n\t histexp_backq++;\n\t old_dquote = dquote;\t\t\/* simple - one level for now *\/\n\t dquote = 0;\n\t i++;\n\t continue;\n\t}\n \/* When in double quotes, act as if the double quote is a member of\n\t history_no_expand_chars, like the history library does *\/\n else if (dquote && c == delims[0] && string[i+1] == '\"')\n\t{\n\t i++;\n\t continue;\n\t}\n else if (c == delims[0])\n\tbreak;\n \/* the usual case is to use skip_xxx_quoted, but we don't skip over double\n\t quoted strings when looking for the history expansion character as a\n\t delimiter. *\/\n else if (dquote && c == '\\'')\n {\n i++;\n continue;\n }\n else if (c == '\\'')\n\ti = skip_single_quoted (string, slen, ++i, 0);\n \/* The posixly_correct test makes posix-mode shells allow double quotes\n\t to quote the history expansion character *\/\n else if (posixly_correct == 0 && c == '\"')\n\t{\n\t dquote = 1 - dquote;\n\t i++;\n\t continue;\n\t} \n else if (c == '\"')\n\ti = skip_double_quoted (string, slen, ++i, 0);\n#if defined (PROCESS_SUBSTITUTION)\n else if ((c == '$' || c == '<' || c == '>') && string[i+1] == LPAREN && string[i+2] != LPAREN)\n#else\n else if (c == '$' && string[i+1] == LPAREN && string[i+2] != LPAREN)\n#endif\n {\n\t if (string[i+2] == '\\0')\n\t CQ_RETURN(i+2);\n\t i += 2;\n\t histexp_comsub++;\n\t old_dquote = dquote;\n\t dquote = 0;\n }\n else if (histexp_comsub && c == RPAREN)\n\t{\n\t histexp_comsub--;\n\t dquote = old_dquote;\n\t i++;\n\t continue;\n\t}\n else if (backq)\t\t\/* placeholder *\/\n\t{\n\t ADVANCE_CHAR (string, slen, i);\n\t continue;\n\t}\n else\n\tADVANCE_CHAR (string, slen, i);\n }\n\n CQ_RETURN(i);\n}","target":0,"code_token_length":817,"total_token_length":1053,"max_tokens_setting":2048} +{"idx":338984,"func":"static void dvbsub_parse_region_segment(AVCodecContext *avctx,\n\n const uint8_t *buf, int buf_size)\n\n{\n\n DVBSubContext *ctx = avctx->priv_data;\n\n\n\n const uint8_t *buf_end = buf + buf_size;\n\n int region_id, object_id;\n\n int av_unused version;\n\n DVBSubRegion *region;\n\n DVBSubObject *object;\n\n DVBSubObjectDisplay *display;\n\n int fill;\n\n\n\n if (buf_size < 10)\n\n\n\n\n region_id = *buf++;\n\n\n\n region = get_region(ctx, region_id);\n\n\n\n if (!region) {\n\n region = av_mallocz(sizeof(DVBSubRegion));\n\n\n\n\n\n region->id = region_id;\n\n region->version = -1;\n\n\n\n region->next = ctx->region_list;\n\n ctx->region_list = region;\n\n }\n\n\n\n version = ((*buf)>>4) & 15;\n\n fill = ((*buf++) >> 3) & 1;\n\n\n\n region->width = AV_RB16(buf);\n\n buf += 2;\n\n region->height = AV_RB16(buf);\n\n buf += 2;\n\n\n\n if (region->width * region->height != region->buf_size) {\n\n av_free(region->pbuf);\n\n\n\n region->buf_size = region->width * region->height;\n\n\n\n region->pbuf = av_malloc(region->buf_size);\n\n\n\n fill = 1;\n\n region->dirty = 0;\n\n }\n\n\n\n region->depth = 1 << (((*buf++) >> 2) & 7);\n\n if(region->depth<2 || region->depth>8){\n\n av_log(avctx, AV_LOG_ERROR, \"region depth %d is invalid\\n\", region->depth);\n\n region->depth= 4;\n\n }\n\n region->clut = *buf++;\n\n\n\n if (region->depth == 8) {\n\n region->bgcolor = *buf++;\n\n buf += 1;\n\n } else {\n\n buf += 1;\n\n\n\n if (region->depth == 4)\n\n region->bgcolor = (((*buf++) >> 4) & 15);\n\n else\n\n region->bgcolor = (((*buf++) >> 2) & 3);\n\n }\n\n\n\n av_dlog(avctx, \"Region %d, (%dx%d)\\n\", region_id, region->width, region->height);\n\n\n\n if (fill) {\n\n memset(region->pbuf, region->bgcolor, region->buf_size);\n\n av_dlog(avctx, \"Fill region (%d)\\n\", region->bgcolor);\n\n }\n\n\n\n delete_region_display_list(ctx, region);\n\n\n\n while (buf + 5 < buf_end) {\n\n object_id = AV_RB16(buf);\n\n buf += 2;\n\n\n\n object = get_object(ctx, object_id);\n\n\n\n if (!object) {\n\n object = av_mallocz(sizeof(DVBSubObject));\n\n\n\n object->id = object_id;\n\n object->next = ctx->object_list;\n\n ctx->object_list = object;\n\n }\n\n\n\n object->type = (*buf) >> 6;\n\n\n\n display = av_mallocz(sizeof(DVBSubObjectDisplay));\n\n\n\n display->object_id = object_id;\n\n display->region_id = region_id;\n\n\n\n display->x_pos = AV_RB16(buf) & 0xfff;\n\n buf += 2;\n\n display->y_pos = AV_RB16(buf) & 0xfff;\n\n buf += 2;\n\n\n\n if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {\n\n display->fgcolor = *buf++;\n\n display->bgcolor = *buf++;\n\n }\n\n\n\n display->region_list_next = region->display_list;\n\n region->display_list = display;\n\n\n\n display->object_list_next = object->display_list;\n\n object->display_list = display;\n\n }\n\n}","target":1,"code_token_length":817,"total_token_length":1053,"max_tokens_setting":2048} +{"idx":478753,"func":" const CImg& _save_inr(std::FILE *const file, const char *const filename, const float *const voxel_size) const {\n if (!file && !filename)\n throw CImgArgumentException(_cimg_instance\n \"save_inr(): Specified filename is (null).\",\n cimg_instance);\n if (is_empty()) { cimg::fempty(file,filename); return *this; }\n\n int inrpixsize = -1;\n const char *inrtype = \"unsigned fixed\\nPIXSIZE=8 bits\\nSCALE=2**0\";\n if (!cimg::strcasecmp(pixel_type(),\"unsigned char\")) {\n inrtype = \"unsigned fixed\\nPIXSIZE=8 bits\\nSCALE=2**0\"; inrpixsize = 1;\n }\n if (!cimg::strcasecmp(pixel_type(),\"char\")) {\n inrtype = \"fixed\\nPIXSIZE=8 bits\\nSCALE=2**0\"; inrpixsize = 1;\n }\n if (!cimg::strcasecmp(pixel_type(),\"unsigned short\")) {\n inrtype = \"unsigned fixed\\nPIXSIZE=16 bits\\nSCALE=2**0\";inrpixsize = 2;\n }\n if (!cimg::strcasecmp(pixel_type(),\"short\")) {\n inrtype = \"fixed\\nPIXSIZE=16 bits\\nSCALE=2**0\"; inrpixsize = 2;\n }\n if (!cimg::strcasecmp(pixel_type(),\"unsigned int\")) {\n inrtype = \"unsigned fixed\\nPIXSIZE=32 bits\\nSCALE=2**0\";inrpixsize = 4;\n }\n if (!cimg::strcasecmp(pixel_type(),\"int\")) {\n inrtype = \"fixed\\nPIXSIZE=32 bits\\nSCALE=2**0\"; inrpixsize = 4;\n }\n if (!cimg::strcasecmp(pixel_type(),\"float\")) {\n inrtype = \"float\\nPIXSIZE=32 bits\"; inrpixsize = 4;\n }\n if (!cimg::strcasecmp(pixel_type(),\"double\")) {\n inrtype = \"float\\nPIXSIZE=64 bits\"; inrpixsize = 8;\n }\n if (inrpixsize<=0)\n throw CImgIOException(_cimg_instance\n \"save_inr(): Unsupported pixel type '%s' for file '%s'\",\n cimg_instance,\n pixel_type(),filename?filename:\"(FILE*)\");\n\n std::FILE *const nfile = file?file:cimg::fopen(filename,\"wb\");\n CImg header(257);\n int err = cimg_snprintf(header,header._width,\"#INRIMAGE-4#{\\nXDIM=%u\\nYDIM=%u\\nZDIM=%u\\nVDIM=%u\\n\",\n _width,_height,_depth,_spectrum);\n if (voxel_size) err+=cimg_sprintf(header._data + err,\"VX=%g\\nVY=%g\\nVZ=%g\\n\",\n voxel_size[0],voxel_size[1],voxel_size[2]);\n err+=cimg_sprintf(header._data + err,\"TYPE=%s\\nCPU=%s\\n\",inrtype,cimg::endianness()?\"sun\":\"decm\");\n std::memset(header._data + err,'\\n',252 - err);\n std::memcpy(header._data + 252,\"##}\\n\",4);\n cimg::fwrite(header._data,256,nfile);\n cimg_forXYZ(*this,x,y,z) cimg_forC(*this,c) cimg::fwrite(&((*this)(x,y,z,c)),1,nfile);\n if (!file) cimg::fclose(nfile);\n return *this;\n }","target":0,"code_token_length":796,"total_token_length":1032,"max_tokens_setting":2048} +{"idx":175876,"func":"void CL_InitRef( void ) {\n\trefimport_t ri;\n\trefexport_t *ret;\n#ifdef USE_RENDERER_DLOPEN\n\tGetRefAPI_t\t\tGetRefAPI;\n\tchar\t\t\tdllName[MAX_OSPATH];\n#endif\n\n \tCom_Printf( \"----- Initializing Renderer ----\\n\" );\n \n #ifdef USE_RENDERER_DLOPEN\n\tcl_renderer = Cvar_Get(\"cl_renderer\", \"opengl1\", CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED);\n \n \tCom_sprintf(dllName, sizeof(dllName), \"renderer_sp_%s_\" ARCH_STRING DLL_EXT, cl_renderer->string);\n \n\tif(!(rendererLib = Sys_LoadDll(dllName, qfalse)) && strcmp(cl_renderer->string, cl_renderer->resetString))\n\t{\n\t\tCom_Printf(\"failed:\\n\\\"%s\\\"\\n\", Sys_LibraryError());\n\t\tCvar_ForceReset(\"cl_renderer\");\n\n\t\tCom_sprintf(dllName, sizeof(dllName), \"renderer_sp_opengl1_\" ARCH_STRING DLL_EXT);\n\t\trendererLib = Sys_LoadDll(dllName, qfalse);\n\t}\n\n\tif(!rendererLib)\n\t{\n\t\tCom_Printf(\"failed:\\n\\\"%s\\\"\\n\", Sys_LibraryError());\n\t\tCom_Error(ERR_FATAL, \"Failed to load renderer\");\n\t}\n\n\tGetRefAPI = Sys_LoadFunction(rendererLib, \"GetRefAPI\");\n\tif(!GetRefAPI)\n\t{\n\t\tCom_Error(ERR_FATAL, \"Can't load symbol GetRefAPI: '%s'\", Sys_LibraryError());\n\t}\n#endif\n\n\tri.Cmd_AddCommand = Cmd_AddCommand;\n\tri.Cmd_RemoveCommand = Cmd_RemoveCommand;\n\tri.Cmd_Argc = Cmd_Argc;\n\tri.Cmd_Argv = Cmd_Argv;\n\tri.Cmd_ExecuteText = Cbuf_ExecuteText;\n\tri.Printf = CL_RefPrintf;\n\tri.Error = Com_Error;\n\tri.Milliseconds = CL_ScaledMilliseconds;\n\n\tri.Z_Malloc = Z_Malloc;\n\tri.Free = Z_Free;\n\tri.Hunk_Clear = Hunk_ClearToMark;\n#ifdef HUNK_DEBUG\n\tri.Hunk_AllocDebug = Hunk_AllocDebug;\n#else\n\tri.Hunk_Alloc = Hunk_Alloc;\n#endif\n\tri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory;\n\tri.Hunk_FreeTempMemory = Hunk_FreeTempMemory;\n\n\tri.CM_ClusterPVS = CM_ClusterPVS;\n\tri.CM_DrawDebugSurface = CM_DrawDebugSurface;\n\tri.FS_ReadFile = FS_ReadFile;\n\tri.FS_FreeFile = FS_FreeFile;\n\tri.FS_WriteFile = FS_WriteFile;\n\tri.FS_FreeFileList = FS_FreeFileList;\n\tri.FS_ListFiles = FS_ListFiles;\n\tri.FS_FileIsInPAK = FS_FileIsInPAK;\n\tri.FS_FileExists = FS_FileExists;\n\tri.Cvar_Get = Cvar_Get;\n\tri.Cvar_Set = Cvar_Set;\n\tri.Cvar_SetValue = Cvar_SetValue;\n\tri.Cvar_CheckRange = Cvar_CheckRange;\n\tri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue;\n\n\n\tri.CIN_UploadCinematic = CIN_UploadCinematic;\n\tri.CIN_PlayCinematic = CIN_PlayCinematic;\n\tri.CIN_RunCinematic = CIN_RunCinematic;\n\n\tri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame;\n\n\tri.IN_Init = IN_Init;\n\tri.IN_Shutdown = IN_Shutdown;\n\tri.IN_Restart = IN_Restart;\n\n\tri.ftol = Q_ftol;\n\n\tri.Sys_SetEnv = Sys_SetEnv;\n\tri.Sys_GLimpSafeInit = Sys_GLimpSafeInit;\n\tri.Sys_GLimpInit = Sys_GLimpInit;\n\tri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory;\n\n\tret = GetRefAPI( REF_API_VERSION, &ri );\n\n\tif ( !ret ) {\n\t\tCom_Error( ERR_FATAL, \"Couldn't initialize refresh\" );\n\t}\n\n\tre = *ret;\n\n\tCom_Printf( \"---- Renderer Initialization Complete ----\\n\" );\n\n\tCvar_Set( \"cl_paused\", \"0\" );\n}\n","target":0,"code_token_length":891,"total_token_length":1127,"max_tokens_setting":2048} +{"idx":288773,"func":"static void test_bug10794 ( ) {\n MYSQL_STMT * stmt , * stmt1 ;\n MYSQL_BIND my_bind [ 2 ] ;\n char a [ 21 ] ;\n int id_val ;\n ulong a_len ;\n int rc ;\n const char * stmt_text ;\n int i = 0 ;\n ulong type ;\n myheader ( \"test_bug10794\" ) ;\n mysql_query ( mysql , \"drop table if exists t1\" ) ;\n mysql_query ( mysql , \"create table t1 (id integer not null primary key,\" \"name varchar(20) not null)\" ) ;\n stmt = mysql_stmt_init ( mysql ) ;\n stmt_text = \"insert into t1 (id, name) values (?, ?)\" ;\n rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ;\n check_execute ( stmt , rc ) ;\n memset ( my_bind , 0 , sizeof ( my_bind ) ) ;\n my_bind [ 0 ] . buffer_type = MYSQL_TYPE_LONG ;\n my_bind [ 0 ] . buffer = ( void * ) & id_val ;\n my_bind [ 1 ] . buffer_type = MYSQL_TYPE_STRING ;\n my_bind [ 1 ] . buffer = ( void * ) a ;\n my_bind [ 1 ] . length = & a_len ;\n rc = mysql_stmt_bind_param ( stmt , my_bind ) ;\n check_execute ( stmt , rc ) ;\n for ( i = 0 ;\n i < 42 ;\n i ++ ) {\n id_val = ( i + 1 ) * 10 ;\n sprintf ( a , \"a%d\" , i ) ;\n a_len = strlen ( a ) ;\n rc = mysql_stmt_execute ( stmt ) ;\n check_execute ( stmt , rc ) ;\n }\n stmt_text = \"select name from t1\" ;\n rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ;\n type = ( ulong ) CURSOR_TYPE_READ_ONLY ;\n mysql_stmt_attr_set ( stmt , STMT_ATTR_CURSOR_TYPE , ( const void * ) & type ) ;\n stmt1 = mysql_stmt_init ( mysql ) ;\n mysql_stmt_attr_set ( stmt1 , STMT_ATTR_CURSOR_TYPE , ( const void * ) & type ) ;\n memset ( my_bind , 0 , sizeof ( my_bind ) ) ;\n my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;\n my_bind [ 0 ] . buffer = ( void * ) a ;\n my_bind [ 0 ] . buffer_length = sizeof ( a ) ;\n my_bind [ 0 ] . length = & a_len ;\n rc = mysql_stmt_bind_result ( stmt , my_bind ) ;\n check_execute ( stmt , rc ) ;\n rc = mysql_stmt_execute ( stmt ) ;\n check_execute ( stmt , rc ) ;\n rc = mysql_stmt_fetch ( stmt ) ;\n check_execute ( stmt , rc ) ;\n if ( ! opt_silent ) printf ( \"Fetched row from stmt: %s\\n\" , a ) ;\n mysql_stmt_free_result ( stmt ) ;\n mysql_stmt_reset ( stmt ) ;\n stmt_text = \"select name from t1 where id=10\" ;\n rc = mysql_stmt_prepare ( stmt1 , stmt_text , strlen ( stmt_text ) ) ;\n check_execute ( stmt1 , rc ) ;\n rc = mysql_stmt_bind_result ( stmt1 , my_bind ) ;\n check_execute ( stmt1 , rc ) ;\n rc = mysql_stmt_execute ( stmt1 ) ;\n while ( 1 ) {\n rc = mysql_stmt_fetch ( stmt1 ) ;\n if ( rc == MYSQL_NO_DATA ) {\n if ( ! opt_silent ) printf ( \"End of data in stmt1\\n\" ) ;\n break ;\n }\n check_execute ( stmt1 , rc ) ;\n if ( ! opt_silent ) printf ( \"Fetched row from stmt1: %s\\n\" , a ) ;\n }\n mysql_stmt_close ( stmt ) ;\n mysql_stmt_close ( stmt1 ) ;\n rc = mysql_query ( mysql , \"drop table t1\" ) ;\n myquery ( rc ) ;\n }","target":0,"code_token_length":812,"total_token_length":1048,"max_tokens_setting":2048} +{"idx":480471,"func":"Mat_WriteEmptyVariable5(mat_t *mat, const char *name, int rank, size_t *dims)\n{\n mat_uint32_t array_flags;\n mat_uint32_t array_name_type = MAT_T_INT8;\n const mat_uint32_t matrix_type = MAT_T_MATRIX;\n int array_flags_type = MAT_T_UINT32, dims_array_type = MAT_T_INT32;\n int array_flags_size = 8, nBytes, i;\n const mat_uint32_t pad4 = 0;\n const mat_uint8_t pad1 = 0;\n size_t byteswritten = 0;\n long start = 0, end = 0;\n\n fwrite(&matrix_type, 4, 1, (FILE *)mat->fp);\n fwrite(&pad4, 4, 1, (FILE *)mat->fp);\n start = ftell((FILE *)mat->fp);\n\n \/* Array Flags *\/\n array_flags = MAT_C_DOUBLE;\n\n if ( mat->byteswap )\n array_flags = Mat_int32Swap((mat_int32_t *)&array_flags);\n byteswritten += fwrite(&array_flags_type, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(&array_flags_size, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(&array_flags, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(&pad4, 4, 1, (FILE *)mat->fp);\n \/* Rank and Dimension *\/\n nBytes = rank * 4;\n byteswritten += fwrite(&dims_array_type, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(&nBytes, 4, 1, (FILE *)mat->fp);\n for ( i = 0; i < rank; i++ ) {\n mat_int32_t dim;\n dim = dims[i];\n byteswritten += fwrite(&dim, 4, 1, (FILE *)mat->fp);\n }\n if ( rank % 2 != 0 )\n byteswritten += fwrite(&pad4, 4, 1, (FILE *)mat->fp);\n\n if ( NULL == name ) {\n \/* Name of variable *\/\n byteswritten += fwrite(&array_name_type, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(&pad4, 4, 1, (FILE *)mat->fp);\n } else {\n mat_int32_t array_name_len = (mat_int32_t)strlen(name);\n \/* Name of variable *\/\n if ( array_name_len <= 4 ) {\n array_name_type |= array_name_len << 16;\n byteswritten += fwrite(&array_name_type, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(name, 1, array_name_len, (FILE *)mat->fp);\n for ( i = array_name_len; i < 4; i++ )\n byteswritten += fwrite(&pad1, 1, 1, (FILE *)mat->fp);\n } else {\n byteswritten += fwrite(&array_name_type, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(&array_name_len, 4, 1, (FILE *)mat->fp);\n byteswritten += fwrite(name, 1, array_name_len, (FILE *)mat->fp);\n if ( array_name_len % 8 )\n for ( i = array_name_len % 8; i < 8; i++ )\n byteswritten += fwrite(&pad1, 1, 1, (FILE *)mat->fp);\n }\n }\n\n nBytes = WriteData(mat, NULL, 0, MAT_T_DOUBLE);\n byteswritten += nBytes;\n if ( nBytes % 8 )\n for ( i = nBytes % 8; i < 8; i++ )\n byteswritten += fwrite(&pad1, 1, 1, (FILE *)mat->fp);\n\n end = ftell((FILE *)mat->fp);\n if ( start != -1L && end != -1L ) {\n nBytes = (int)(end - start);\n (void)fseek((FILE *)mat->fp, (long)-(nBytes + 4), SEEK_CUR);\n fwrite(&nBytes, 4, 1, (FILE *)mat->fp);\n (void)fseek((FILE *)mat->fp, end, SEEK_SET);\n } else {\n Mat_Critical(\"Couldn't determine file position\");\n }\n\n return byteswritten;\n}","target":0,"code_token_length":989,"total_token_length":1225,"max_tokens_setting":2048} +{"idx":341245,"func":"static void vfio_pci_size_rom(VFIOPCIDevice *vdev)\n\n{\n\n uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);\n\n off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;\n\n DeviceState *dev = DEVICE(vdev);\n\n char name[32];\n\n int fd = vdev->vbasedev.fd;\n\n\n\n if (vdev->pdev.romfile || !vdev->pdev.rom_bar) {\n\n \/* Since pci handles romfile, just print a message and return *\/\n\n if (vfio_blacklist_opt_rom(vdev) && vdev->pdev.romfile) {\n\n error_printf(\"Warning : Device at %04x:%02x:%02x.%x \"\n\n \"is known to cause system instability issues during \"\n\n \"option rom execution. \"\n\n \"Proceeding anyway since user specified romfile\\n\",\n\n vdev->host.domain, vdev->host.bus, vdev->host.slot,\n\n vdev->host.function);\n\n }\n\n return;\n\n }\n\n\n\n \/*\n\n * Use the same size ROM BAR as the physical device. The contents\n\n * will get filled in later when the guest tries to read it.\n\n *\/\n\n if (pread(fd, &orig, 4, offset) != 4 ||\n\n pwrite(fd, &size, 4, offset) != 4 ||\n\n pread(fd, &size, 4, offset) != 4 ||\n\n pwrite(fd, &orig, 4, offset) != 4) {\n\n error_report(\"%s(%04x:%02x:%02x.%x) failed: %m\",\n\n __func__, vdev->host.domain, vdev->host.bus,\n\n vdev->host.slot, vdev->host.function);\n\n return;\n\n }\n\n\n\n size = ~(le32_to_cpu(size) & PCI_ROM_ADDRESS_MASK) + 1;\n\n\n\n if (!size) {\n\n return;\n\n }\n\n\n\n if (vfio_blacklist_opt_rom(vdev)) {\n\n if (dev->opts && qemu_opt_get(dev->opts, \"rombar\")) {\n\n error_printf(\"Warning : Device at %04x:%02x:%02x.%x \"\n\n \"is known to cause system instability issues during \"\n\n \"option rom execution. \"\n\n \"Proceeding anyway since user specified non zero value for \"\n\n \"rombar\\n\",\n\n vdev->host.domain, vdev->host.bus, vdev->host.slot,\n\n vdev->host.function);\n\n } else {\n\n error_printf(\"Warning : Rom loading for device at \"\n\n \"%04x:%02x:%02x.%x has been disabled due to \"\n\n \"system instability issues. \"\n\n \"Specify rombar=1 or romfile to force\\n\",\n\n vdev->host.domain, vdev->host.bus, vdev->host.slot,\n\n vdev->host.function);\n\n return;\n\n }\n\n }\n\n\n\n trace_vfio_pci_size_rom(vdev->vbasedev.name, size);\n\n\n\n snprintf(name, sizeof(name), \"vfio[%04x:%02x:%02x.%x].rom\",\n\n vdev->host.domain, vdev->host.bus, vdev->host.slot,\n\n vdev->host.function);\n\n\n\n memory_region_init_io(&vdev->pdev.rom, OBJECT(vdev),\n\n &vfio_rom_ops, vdev, name, size);\n\n\n\n pci_register_bar(&vdev->pdev, PCI_ROM_SLOT,\n\n PCI_BASE_ADDRESS_SPACE_MEMORY, &vdev->pdev.rom);\n\n\n\n vdev->pdev.has_rom = true;\n\n vdev->rom_read_failed = false;\n\n}\n","target":0,"code_token_length":792,"total_token_length":1028,"max_tokens_setting":2048} +{"idx":321374,"func":"static AddressParts gen_lea_modrm_0(CPUX86State *env, DisasContext *s,\n\n int modrm)\n\n{\n\n int def_seg, base, index, scale, mod, rm;\n\n target_long disp;\n\n bool havesib;\n\n\n\n def_seg = R_DS;\n\n index = -1;\n\n scale = 0;\n\n disp = 0;\n\n\n\n mod = (modrm >> 6) & 3;\n\n rm = modrm & 7;\n\n base = rm | REX_B(s);\n\n\n\n if (mod == 3) {\n\n \/* Normally filtered out earlier, but including this path\n\n simplifies multi-byte nop, as well as bndcl, bndcu, bndcn. *\/\n\n goto done;\n\n }\n\n\n\n switch (s->aflag) {\n\n case MO_64:\n\n case MO_32:\n\n havesib = 0;\n\n if (rm == 4) {\n\n int code = cpu_ldub_code(env, s->pc++);\n\n scale = (code >> 6) & 3;\n\n index = ((code >> 3) & 7) | REX_X(s);\n\n if (index == 4) {\n\n index = -1; \/* no index *\/\n\n }\n\n base = (code & 7) | REX_B(s);\n\n havesib = 1;\n\n }\n\n\n\n switch (mod) {\n\n case 0:\n\n if ((base & 7) == 5) {\n\n base = -1;\n\n disp = (int32_t)cpu_ldl_code(env, s->pc);\n\n s->pc += 4;\n\n if (CODE64(s) && !havesib) {\n\n base = -2;\n\n disp += s->pc + s->rip_offset;\n\n }\n\n }\n\n break;\n\n case 1:\n\n disp = (int8_t)cpu_ldub_code(env, s->pc++);\n\n break;\n\n default:\n\n case 2:\n\n disp = (int32_t)cpu_ldl_code(env, s->pc);\n\n s->pc += 4;\n\n break;\n\n }\n\n\n\n \/* For correct popl handling with esp. *\/\n\n if (base == R_ESP && s->popl_esp_hack) {\n\n disp += s->popl_esp_hack;\n\n }\n\n if (base == R_EBP || base == R_ESP) {\n\n def_seg = R_SS;\n\n }\n\n break;\n\n\n\n case MO_16:\n\n if (mod == 0) {\n\n if (rm == 6) {\n\n base = -1;\n\n disp = cpu_lduw_code(env, s->pc);\n\n s->pc += 2;\n\n break;\n\n }\n\n } else if (mod == 1) {\n\n disp = (int8_t)cpu_ldub_code(env, s->pc++);\n\n } else {\n\n disp = (int16_t)cpu_lduw_code(env, s->pc);\n\n s->pc += 2;\n\n }\n\n\n\n switch (rm) {\n\n case 0:\n\n base = R_EBX;\n\n index = R_ESI;\n\n break;\n\n case 1:\n\n base = R_EBX;\n\n index = R_EDI;\n\n break;\n\n case 2:\n\n base = R_EBP;\n\n index = R_ESI;\n\n def_seg = R_SS;\n\n break;\n\n case 3:\n\n base = R_EBP;\n\n index = R_EDI;\n\n def_seg = R_SS;\n\n break;\n\n case 4:\n\n base = R_ESI;\n\n break;\n\n case 5:\n\n base = R_EDI;\n\n break;\n\n case 6:\n\n base = R_EBP;\n\n def_seg = R_SS;\n\n break;\n\n default:\n\n case 7:\n\n base = R_EBX;\n\n break;\n\n }\n\n break;\n\n\n\n default:\n\n tcg_abort();\n\n }\n\n\n\n done:\n\n return (AddressParts){ def_seg, base, index, scale, disp };\n\n}\n","target":0,"code_token_length":870,"total_token_length":1106,"max_tokens_setting":2048} +{"idx":147211,"func":"set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)\n{\n asdl_seq *s = NULL;\n \/* If a particular expression type can't be used for assign \/ delete,\n set expr_name to its name and an error message will be generated.\n *\/\n const char* expr_name = NULL;\n\n \/* The ast defines augmented store and load contexts, but the\n implementation here doesn't actually use them. The code may be\n a little more complex than necessary as a result. It also means\n that expressions in an augmented assignment have a Store context.\n Consider restructuring so that augmented assignment uses\n set_context(), too.\n *\/\n assert(ctx != AugStore && ctx != AugLoad);\n\n switch (e->kind) {\n case Attribute_kind:\n if (ctx == NamedStore) {\n expr_name = \"attribute\";\n break;\n }\n\n e->v.Attribute.ctx = ctx;\n if (ctx == Store && forbidden_name(c, e->v.Attribute.attr, n, 1))\n return 0;\n break;\n case Subscript_kind:\n if (ctx == NamedStore) {\n expr_name = \"subscript\";\n break;\n }\n\n e->v.Subscript.ctx = ctx;\n break;\n case Starred_kind:\n if (ctx == NamedStore) {\n expr_name = \"starred\";\n break;\n }\n\n e->v.Starred.ctx = ctx;\n if (!set_context(c, e->v.Starred.value, ctx, n))\n return 0;\n break;\n case Name_kind:\n if (ctx == Store) {\n if (forbidden_name(c, e->v.Name.id, n, 0))\n return 0; \/* forbidden_name() calls ast_error() *\/\n }\n e->v.Name.ctx = ctx;\n break;\n case List_kind:\n if (ctx == NamedStore) {\n expr_name = \"list\";\n break;\n }\n\n e->v.List.ctx = ctx;\n s = e->v.List.elts;\n break;\n case Tuple_kind:\n if (ctx == NamedStore) {\n expr_name = \"tuple\";\n break;\n }\n\n e->v.Tuple.ctx = ctx;\n s = e->v.Tuple.elts;\n break;\n case Lambda_kind:\n expr_name = \"lambda\";\n break;\n case Call_kind:\n expr_name = \"function call\";\n break;\n case BoolOp_kind:\n case BinOp_kind:\n case UnaryOp_kind:\n expr_name = \"operator\";\n break;\n case GeneratorExp_kind:\n expr_name = \"generator expression\";\n break;\n case Yield_kind:\n case YieldFrom_kind:\n expr_name = \"yield expression\";\n break;\n case Await_kind:\n expr_name = \"await expression\";\n break;\n case ListComp_kind:\n expr_name = \"list comprehension\";\n break;\n case SetComp_kind:\n expr_name = \"set comprehension\";\n break;\n case DictComp_kind:\n expr_name = \"dict comprehension\";\n break;\n case Dict_kind:\n expr_name = \"dict display\";\n break;\n case Set_kind:\n expr_name = \"set display\";\n break;\n case JoinedStr_kind:\n case FormattedValue_kind:\n expr_name = \"f-string expression\";\n break;\n case Constant_kind: {\n PyObject *value = e->v.Constant.value;\n if (value == Py_None || value == Py_False || value == Py_True\n || value == Py_Ellipsis)\n {\n return ast_error(c, n, \"cannot %s %R\",\n ctx == Store ? \"assign to\" : \"delete\",\n value);\n }\n expr_name = \"literal\";\n break;\n }\n case Compare_kind:\n expr_name = \"comparison\";\n break;\n case IfExp_kind:\n expr_name = \"conditional expression\";\n break;\n case NamedExpr_kind:\n expr_name = \"named expression\";\n break;\n default:\n PyErr_Format(PyExc_SystemError,\n \"unexpected expression in %sassignment %d (line %d)\",\n ctx == NamedStore ? \"named \": \"\",\n e->kind, e->lineno);\n return 0;\n }\n \/* Check for error string set by switch *\/\n if (expr_name) {\n if (ctx == NamedStore) {\n return ast_error(c, n, \"cannot use named assignment with %s\",\n expr_name);\n }\n else {\n return ast_error(c, n, \"cannot %s %s\",\n ctx == Store ? \"assign to\" : \"delete\",\n expr_name);\n }\n }\n\n \/* If the LHS is a list or tuple, we need to set the assignment\n context for all the contained elements.\n *\/\n if (s) {\n Py_ssize_t i;\n\n for (i = 0; i < asdl_seq_LEN(s); i++) {\n if (!set_context(c, (expr_ty)asdl_seq_GET(s, i), ctx, n))\n return 0;\n }\n }\n return 1;\n}","target":0,"code_token_length":1099,"total_token_length":1335,"max_tokens_setting":2048} +{"idx":60920,"func":"void pjsip_dlg_on_rx_request( pjsip_dialog *dlg, pjsip_rx_data *rdata )\n{\n pj_status_t status;\n pjsip_transaction *tsx = NULL;\n pj_bool_t processed = PJ_FALSE;\n unsigned i;\n\n PJ_LOG(5,(dlg->obj_name, \"Received %s\",\n\t pjsip_rx_data_get_info(rdata)));\n pj_log_push_indent();\n\n \/* Lock dialog and increment session. *\/\n pjsip_dlg_inc_lock(dlg);\n\n \/* Check CSeq *\/\n if (rdata->msg_info.cseq->cseq <= dlg->remote.cseq &&\n\trdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD &&\n\trdata->msg_info.msg->line.req.method.id != PJSIP_CANCEL_METHOD)\n {\n\t\/* Invalid CSeq.\n\t * Respond statelessly with 500 (Internal Server Error)\n\t *\/\n\tpj_str_t warn_text;\n\n\t\/* Unlock dialog and dec session, may destroy dialog. *\/\n\tpjsip_dlg_dec_lock(dlg);\n\n\tpj_assert(pjsip_rdata_get_tsx(rdata) == NULL);\n\twarn_text = pj_str(\"Invalid CSeq\");\n\tpjsip_endpt_respond_stateless(dlg->endpt,\n\t\t\t\t rdata, 500, &warn_text, NULL, NULL);\n\tpj_log_pop_indent();\n\treturn;\n }\n\n \/* Update CSeq. *\/\n dlg->remote.cseq = rdata->msg_info.cseq->cseq;\n\n \/* Update To tag if necessary.\n * This only happens if UAS sends a new request before answering\n * our request (e.g. UAS sends NOTIFY before answering our\n * SUBSCRIBE request).\n *\/\n if (dlg->remote.info->tag.slen == 0) {\n\tpj_strdup(dlg->pool, &dlg->remote.info->tag,\n\t\t &rdata->msg_info.from->tag);\n }\n\n \/* Create UAS transaction for this request. *\/\n if (pjsip_rdata_get_tsx(rdata) == NULL &&\n\trdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD)\n {\n\tstatus = pjsip_tsx_create_uas(dlg->ua, rdata, &tsx);\n\tif (status != PJ_SUCCESS) {\n\t \/* Once case for this is when re-INVITE contains same\n\t * Via branch value as previous INVITE (ticket #965).\n\t *\/\n\t char errmsg[PJ_ERR_MSG_SIZE];\n\t pj_str_t reason;\n\n\t reason = pj_strerror(status, errmsg, sizeof(errmsg));\n\t pjsip_endpt_respond_stateless(dlg->endpt, rdata, 500, &reason,\n\t\t\t\t\t NULL, NULL);\n\t goto on_return;\n\t}\n\n\t\/* Put this dialog in the transaction data. *\/\n\ttsx->mod_data[dlg->ua->id] = dlg;\n\n\t\/* Add transaction count. *\/\n\t++dlg->tsx_count;\n }\n\n \/* Update the target URI if this is a target refresh request.\n * We have passed the basic checking for the request, I think we\n * should update the target URI regardless of whether the request\n * is accepted or not (e.g. when re-INVITE is answered with 488,\n * we would still need to update the target URI, otherwise our\n * target URI would be wrong, wouldn't it).\n *\/\n if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method)) {\n\tpjsip_contact_hdr *contact;\n\n\tcontact = (pjsip_contact_hdr*)\n\t\t pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,\n\t\t\t\t NULL);\n\tif (contact && contact->uri &&\n\t (dlg->remote.contact==NULL ||\n \t pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI,\n\t\t\t dlg->remote.contact->uri,\n\t\t\t contact->uri)))\n\t{\n\t dlg->remote.contact = (pjsip_contact_hdr*)\n\t \t\t\t pjsip_hdr_clone(dlg->pool, contact);\n\t dlg->target = dlg->remote.contact->uri;\n\t}\n }\n\n \/* Report the request to dialog usages. *\/\n for (i=0; iusage_cnt; ++i) {\n\n\tif (!dlg->usage[i]->on_rx_request)\n\t continue;\n\n\tprocessed = (*dlg->usage[i]->on_rx_request)(rdata);\n\n\tif (processed)\n\t break;\n }\n\n \/* Feed the first request to the transaction. *\/\n if (tsx)\n\tpjsip_tsx_recv_msg(tsx, rdata);\n\n \/* If no dialog usages has claimed the processing of the transaction,\n * and if transaction has not sent final response, respond with\n * 500\/Internal Server Error.\n *\/\n if (!processed && tsx && tsx->status_code < 200) {\n\tpjsip_tx_data *tdata;\n\tconst pj_str_t reason = { \"Unhandled by dialog usages\", 26};\n\n\tPJ_LOG(4,(tsx->obj_name, \"%s was unhandled by \"\n\t\t\t\t \"dialog usages, sending 500 response\",\n\t\t\t\t pjsip_rx_data_get_info(rdata)));\n\n\tstatus = pjsip_dlg_create_response(dlg, rdata, 500, &reason, &tdata);\n\tif (status == PJ_SUCCESS) {\n\t status = pjsip_dlg_send_response(dlg, tsx, tdata);\n\t}\n }\n\non_return:\n \/* Unlock dialog and dec session, may destroy dialog. *\/\n pjsip_dlg_dec_lock(dlg);\n pj_log_pop_indent();\n}","target":0,"code_token_length":1199,"total_token_length":1435,"max_tokens_setting":2048} +{"idx":260776,"func":"static int pad_pkcs2(bn_t m, int *p_len, int m_len, int k_len, int operation) {\n uint8_t pad, h1[RLC_MD_LEN], h2[RLC_MD_LEN];\n \/* MSVC does not allow dynamic stack arrays *\/\n uint8_t *mask = RLC_ALLOCA(uint8_t, k_len);\n\tint result = RLC_ERR;\n\tbn_t t;\n\n\tbn_null(t);\n\n\tRLC_TRY {\n\t\tbn_new(t);\n\n\t\tswitch (operation) {\n\t\t\tcase RSA_ENC:\n\t\t\t\t\/* DB = lHash | PS | 01 | D. *\/\n\t\t\t\tmd_map(h1, NULL, 0);\n\t\t\t\tbn_read_bin(m, h1, RLC_MD_LEN);\n\t\t\t\t*p_len = k_len - 2 * RLC_MD_LEN - 2 - m_len;\n\t\t\t\tbn_lsh(m, m, *p_len * 8);\n\t\t\t\tbn_lsh(m, m, 8);\n\t\t\t\tbn_add_dig(m, m, 0x01);\n\t\t\t\t\/* Make room for the real message. *\/\n\t\t\t\tbn_lsh(m, m, m_len * 8);\n\t\t\t\tresult = RLC_OK;\n\t\t\t\tbreak;\n\t\t\tcase RSA_ENC_FIN:\n\t\t\t\t\/* EB = 00 | maskedSeed | maskedDB. *\/\n\t\t\t\trand_bytes(h1, RLC_MD_LEN);\n\t\t\t\tmd_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);\n\t\t\t\tbn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);\n\t\t\t\tfor (int i = 0; i < t->used; i++) {\n\t\t\t\t\tm->dp[i] ^= t->dp[i];\n\t\t\t\t}\n\t\t\t\tbn_write_bin(mask, k_len - RLC_MD_LEN - 1, m);\n\t\t\t\tmd_mgf(h2, RLC_MD_LEN, mask, k_len - RLC_MD_LEN - 1);\n\t\t\t\tfor (int i = 0; i < RLC_MD_LEN; i++) {\n\t\t\t\t\th1[i] ^= h2[i];\n\t\t\t\t}\n\t\t\t\tbn_read_bin(t, h1, RLC_MD_LEN);\n\t\t\t\tbn_lsh(t, t, 8 * (k_len - RLC_MD_LEN - 1));\n\t\t\t\tbn_add(t, t, m);\n\t\t\t\tbn_copy(m, t);\n\t\t\t\tresult = RLC_OK;\n\t\t\t\tbreak;\n\t\t\tcase RSA_DEC:\n\t\t\t\tm_len = k_len - 1;\n\t\t\t\tbn_rsh(t, m, 8 * m_len);\n\t\t\t\tif (bn_is_zero(t)) {\n\t\t\t\t\tm_len -= RLC_MD_LEN;\n\t\t\t\t\tbn_rsh(t, m, 8 * m_len);\n\t\t\t\t\tbn_write_bin(h1, RLC_MD_LEN, t);\n\t\t\t\t\tbn_mod_2b(m, m, 8 * m_len);\n\t\t\t\t\tbn_write_bin(mask, m_len, m);\n\t\t\t\t\tmd_mgf(h2, RLC_MD_LEN, mask, m_len);\n\t\t\t\t\tfor (int i = 0; i < RLC_MD_LEN; i++) {\n\t\t\t\t\t\th1[i] ^= h2[i];\n\t\t\t\t\t}\n\t\t\t\t\tmd_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);\n\t\t\t\t\tbn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);\n\t\t\t\t\tfor (int i = 0; i < t->used; i++) {\n\t\t\t\t\t\tm->dp[i] ^= t->dp[i];\n\t\t\t\t\t}\n\t\t\t\t\tm_len -= RLC_MD_LEN;\n\t\t\t\t\tbn_rsh(t, m, 8 * m_len);\n\t\t\t\t\tbn_write_bin(h2, RLC_MD_LEN, t);\n\t\t\t\t\tmd_map(h1, NULL, 0);\n\t\t\t\t\tpad = 0;\n\t\t\t\t\tfor (int i = 0; i < RLC_MD_LEN; i++) {\n\t\t\t\t\t\tpad |= h1[i] ^ h2[i];\n\t\t\t\t\t}\n\t\t\t\t\tbn_mod_2b(m, m, 8 * m_len);\n\t\t\t\t\t*p_len = bn_size_bin(m);\n\t\t\t\t\t(*p_len)--;\n\t\t\t\t\tbn_rsh(t, m, *p_len * 8);\n\t\t\t\t\tif (pad == 0 && bn_cmp_dig(t, 1) == RLC_EQ) {\n\t\t\t\t\t\tresult = RLC_OK;\n\t\t\t\t\t}\n\t\t\t\t\tbn_mod_2b(m, m, *p_len * 8);\n\t\t\t\t\t*p_len = k_len - *p_len;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase RSA_SIG:\n\t\t\tcase RSA_SIG_HASH:\n\t\t\t\t\/* M' = 00 00 00 00 00 00 00 00 | H(M). *\/\n\t\t\t\tbn_zero(m);\n\t\t\t\tbn_lsh(m, m, 64);\n\t\t\t\t\/* Make room for the real message. *\/\n\t\t\t\tbn_lsh(m, m, RLC_MD_LEN * 8);\n\t\t\t\tresult = RLC_OK;\n\t\t\t\tbreak;\n\t\t\tcase RSA_SIG_FIN:\n\t\t\t\tmemset(mask, 0, 8);\n\t\t\t\tbn_write_bin(mask + 8, RLC_MD_LEN, m);\n\t\t\t\tmd_map(h1, mask, RLC_MD_LEN + 8);\n\t\t\t\tbn_read_bin(m, h1, RLC_MD_LEN);\n\t\t\t\tmd_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);\n\t\t\t\tbn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);\n\t\t\t\tt->dp[0] ^= 0x01;\n\t\t\t\t\/* m_len is now the size in bits of the modulus. *\/\n\t\t\t\tbn_lsh(t, t, 8 * RLC_MD_LEN);\n\t\t\t\tbn_add(m, t, m);\n\t\t\t\tbn_lsh(m, m, 8);\n\t\t\t\tbn_add_dig(m, m, RSA_PSS);\n\t\t\t\tfor (int i = m_len - 1; i < 8 * k_len; i++) {\n\t\t\t\t\tbn_set_bit(m, i, 0);\n\t\t\t\t}\n\t\t\t\tresult = RLC_OK;\n\t\t\t\tbreak;\n\t\t\tcase RSA_VER:\n\t\t\tcase RSA_VER_HASH:\n\t\t\t\tbn_mod_2b(t, m, 8);\n\t\t\t\tpad = (uint8_t)t->dp[0];\n\t\t\t\tif (pad == RSA_PSS) {\n\t\t\t\t\tint r = 1;\n\t\t\t\t\tfor (int i = m_len; i < 8 * k_len; i++) {\n\t\t\t\t\t\tif (bn_get_bit(m, i) != 0) {\n\t\t\t\t\t\t\tr = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbn_rsh(m, m, 8);\n\t\t\t\t\tbn_mod_2b(t, m, 8 * RLC_MD_LEN);\n\t\t\t\t\tbn_write_bin(h2, RLC_MD_LEN, t);\n\t\t\t\t\tbn_rsh(m, m, 8 * RLC_MD_LEN);\n\t\t\t\t\tbn_write_bin(h1, RLC_MD_LEN, t);\n\t\t\t\t\tmd_mgf(mask, k_len - RLC_MD_LEN - 1, h1, RLC_MD_LEN);\n\t\t\t\t\tbn_read_bin(t, mask, k_len - RLC_MD_LEN - 1);\n\t\t\t\t\tfor (int i = 0; i < t->used; i++) {\n\t\t\t\t\t\tm->dp[i] ^= t->dp[i];\n\t\t\t\t\t}\n\t\t\t\t\tm->dp[0] ^= 0x01;\n\t\t\t\t\tfor (int i = m_len - 1; i < 8 * k_len; i++) {\n\t\t\t\t\t\tbn_set_bit(m, i - ((RLC_MD_LEN + 1) * 8), 0);\n\t\t\t\t\t}\n\t\t\t\t\tif (r == 1 && bn_is_zero(m)) {\n\t\t\t\t\t\tresult = RLC_OK;\n\t\t\t\t\t}\n\t\t\t\t\tbn_read_bin(m, h2, RLC_MD_LEN);\n\t\t\t\t\t*p_len = k_len - RLC_MD_LEN;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tRLC_CATCH_ANY {\n\t\tresult = RLC_ERR;\n\t}\n\tRLC_FINALLY {\n\t\tbn_free(t);\n\t}\n\n RLC_FREE(mask);\n\n\treturn result;\n}","target":0,"code_token_length":1735,"total_token_length":1971,"max_tokens_setting":2048} +{"idx":284678,"func":"bool Document::SetFocusedElement(Element* new_focused_element,\n const FocusParams& params) {\n DCHECK(!lifecycle_.InDetach());\n\n clear_focused_element_timer_.Stop();\n\n if (new_focused_element && (new_focused_element->GetDocument() != this))\n return true;\n\n if (NodeChildRemovalTracker::IsBeingRemoved(new_focused_element))\n return true;\n\n if (focused_element_ == new_focused_element)\n return true;\n\n bool focus_change_blocked = false;\n Element* old_focused_element = focused_element_;\n focused_element_ = nullptr;\n\n UpdateDistributionForFlatTreeTraversal();\n Node* ancestor = (old_focused_element && old_focused_element->isConnected() &&\n new_focused_element)\n ? FlatTreeTraversal::CommonAncestor(*old_focused_element,\n *new_focused_element)\n : nullptr;\n\n if (old_focused_element) {\n old_focused_element->SetFocused(false, params.type);\n old_focused_element->SetHasFocusWithinUpToAncestor(false, ancestor);\n\n if (GetPage() && (GetPage()->GetFocusController().IsFocused())) {\n old_focused_element->DispatchBlurEvent(new_focused_element, params.type,\n params.source_capabilities);\n if (focused_element_) {\n focus_change_blocked = true;\n new_focused_element = nullptr;\n }\n\n old_focused_element->DispatchFocusOutEvent(EventTypeNames::focusout,\n new_focused_element,\n params.source_capabilities);\n old_focused_element->DispatchFocusOutEvent(EventTypeNames::DOMFocusOut,\n new_focused_element,\n params.source_capabilities);\n\n if (focused_element_) {\n focus_change_blocked = true;\n new_focused_element = nullptr;\n }\n }\n }\n\n if (new_focused_element)\n UpdateStyleAndLayoutTreeForNode(new_focused_element);\n if (new_focused_element && new_focused_element->IsFocusable()) {\n if (IsRootEditableElement(*new_focused_element) &&\n !AcceptsEditingFocus(*new_focused_element)) {\n focus_change_blocked = true;\n goto SetFocusedElementDone;\n }\n focused_element_ = new_focused_element;\n SetSequentialFocusNavigationStartingPoint(focused_element_.Get());\n\n if (params.type != kWebFocusTypeNone)\n last_focus_type_ = params.type;\n\n focused_element_->SetFocused(true, params.type);\n focused_element_->SetHasFocusWithinUpToAncestor(true, ancestor);\n\n if (focused_element_ != new_focused_element) {\n focus_change_blocked = true;\n goto SetFocusedElementDone;\n }\n CancelFocusAppearanceUpdate();\n EnsurePaintLocationDataValidForNode(focused_element_);\n if (focused_element_ != new_focused_element) {\n focus_change_blocked = true;\n goto SetFocusedElementDone;\n }\n focused_element_->UpdateFocusAppearanceWithOptions(\n params.selection_behavior, params.options);\n\n if (GetPage() && (GetPage()->GetFocusController().IsFocused())) {\n focused_element_->DispatchFocusEvent(old_focused_element, params.type,\n params.source_capabilities);\n\n if (focused_element_ != new_focused_element) {\n focus_change_blocked = true;\n goto SetFocusedElementDone;\n }\n focused_element_->DispatchFocusInEvent(EventTypeNames::focusin,\n old_focused_element, params.type,\n params.source_capabilities);\n\n if (focused_element_ != new_focused_element) {\n focus_change_blocked = true;\n goto SetFocusedElementDone;\n }\n\n focused_element_->DispatchFocusInEvent(EventTypeNames::DOMFocusIn,\n old_focused_element, params.type,\n params.source_capabilities);\n\n if (focused_element_ != new_focused_element) {\n focus_change_blocked = true;\n goto SetFocusedElementDone;\n }\n }\n }\n\n if (!focus_change_blocked && focused_element_) {\n if (AXObjectCache* cache = ExistingAXObjectCache()) {\n cache->HandleFocusedUIElementChanged(old_focused_element,\n new_focused_element);\n }\n }\n\n if (!focus_change_blocked && GetPage()) {\n GetPage()->GetChromeClient().FocusedNodeChanged(old_focused_element,\n focused_element_.Get());\n }\n\nSetFocusedElementDone:\n UpdateStyleAndLayoutTree();\n if (LocalFrame* frame = GetFrame())\n frame->Selection().DidChangeFocus();\n return !focus_change_blocked;\n}\n","target":0,"code_token_length":934,"total_token_length":1170,"max_tokens_setting":2048} +{"idx":154883,"func":"TEST_F(EnvoyQuicProofSourceTest, UnexpectedPrivateKey) {\n EXPECT_CALL(listen_socket_, ioHandle());\n EXPECT_CALL(filter_chain_manager_, findFilterChain(_))\n .WillOnce(Invoke([&](const Network::ConnectionSocket&) { return &filter_chain_; }));\n EXPECT_CALL(filter_chain_, transportSocketFactory())\n .WillRepeatedly(ReturnRef(*transport_socket_factory_));\n\n Ssl::MockTlsCertificateConfig tls_cert_config;\n std::vector> tls_cert_configs{\n std::reference_wrapper(tls_cert_config)};\n EXPECT_CALL(*mock_context_config_, tlsCertificates()).WillRepeatedly(Return(tls_cert_configs));\n EXPECT_CALL(*mock_context_config_, isReady()).WillOnce(Return(true));\n std::string rsa_pkey_1024_len(R\"(-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgQC79hDq\/OwN3ke3EF6Ntdi9R+VSrl9MStk992l1us8lZhq+e0zU\nOlvxbUeZ8wyVkzs1gqI1it1IwF+EpdGhHhjggZjg040GD3HWSuyCzpHh+nLwJxtQ\nD837PCg0zl+TnKv1YjY3I1F3trGhIqfd2B6pgaJ4hpr+0hdqnKP0Htd4DwIDAQAB\nAoGASNypUD59Tx70k+1fifWNMEq3heacgJmfPxsyoXWqKSg8g8yOStLYo20mTXJf\nVXg+go7CTJkpELOqE2SoL5nYMD0D\/YIZCgDx85k0GWHdA6udNn4to95ZTeZPrBHx\nT0QNQHnZI3A7RwLinO60IRY0NYzhkTEBxIuvIY6u0DVbrAECQQDpshbxK3DHc7Yi\nAu7BUsxP8RbG4pP5IIVoD4YvJuwUkdrfrwejqTdkfchJJc+Gu\/+h8vy7eASPHLLT\nNBk5wFoPAkEAzeaKnx0CgNs0RX4+sSF727FroD98VUM38OFEJQ6U9OAWGvaKd8ey\nyAYUjR2Sl5ZRyrwWv4IqyWgUGhZqNG0CAQJAPTjjm8DGpenhcB2WkNzxG4xMbEQV\ngfGMIYvXmmi29liTn4AKH00IbvIo00jtih2cRcATh8VUZG2fR4dhiGik7wJAWSwS\nNwzaS7IjtkERp6cHvELfiLxV\/Zsp\/BGjcKUbD96I1E6X834ySHyRo\/f9x9bbP4Es\nHO6j1yxTIGU6w8++AQJACdFPnRidOaj5oJmcZq0s6WGTYfegjTOKgi5KQzO0FTwG\nqGm130brdD+1U1EJnEFmleLZ\/W6mEi3MxcKpWOpTqQ==\n-----END RSA PRIVATE KEY-----)\");\n EXPECT_CALL(tls_cert_config, privateKey()).WillOnce(ReturnRef(rsa_pkey_1024_len));\n std::string signature;\n proof_source_.ComputeTlsSignature(\n server_address_, client_address_, hostname_, SSL_SIGN_RSA_PSS_RSAE_SHA256, \"payload\",\n std::make_unique(false, filter_chain_, signature));\n}","target":0,"code_token_length":915,"total_token_length":1151,"max_tokens_setting":2048} +{"idx":55438,"func":"void rfbSendInteractionCaps(rfbClientPtr cl)\n{\n rfbInteractionCapsMsg intr_caps;\n rfbCapabilityInfo enc_list[N_ENC_CAPS];\n int i;\n\n \/* Fill in the header structure sent prior to capability lists. *\/\n intr_caps.nServerMessageTypes = Swap16IfLE(N_SMSG_CAPS);\n intr_caps.nClientMessageTypes = Swap16IfLE(N_CMSG_CAPS);\n intr_caps.nEncodingTypes = Swap16IfLE(N_ENC_CAPS);\n intr_caps.pad = 0;\n\n \/* Supported server->client message types. *\/\n \/* For future file transfer support:\n i = 0;\n SetCapInfo(&smsg_list[i++], rfbFileListData, rfbTightVncVendor);\n SetCapInfo(&smsg_list[i++], rfbFileDownloadData, rfbTightVncVendor);\n SetCapInfo(&smsg_list[i++], rfbFileUploadCancel, rfbTightVncVendor);\n SetCapInfo(&smsg_list[i++], rfbFileDownloadFailed, rfbTightVncVendor);\n if (i != N_SMSG_CAPS) {\n rfbLog(\"rfbSendInteractionCaps: assertion failed, i != N_SMSG_CAPS\\n\");\n rfbCloseClient(cl);\n return;\n }\n *\/\n\n \/* Supported client->server message types. *\/\n \/* For future file transfer support:\n i = 0;\n SetCapInfo(&cmsg_list[i++], rfbFileListRequest, rfbTightVncVendor);\n SetCapInfo(&cmsg_list[i++], rfbFileDownloadRequest, rfbTightVncVendor);\n SetCapInfo(&cmsg_list[i++], rfbFileUploadRequest, rfbTightVncVendor);\n SetCapInfo(&cmsg_list[i++], rfbFileUploadData, rfbTightVncVendor);\n SetCapInfo(&cmsg_list[i++], rfbFileDownloadCancel, rfbTightVncVendor);\n SetCapInfo(&cmsg_list[i++], rfbFileUploadFailed, rfbTightVncVendor);\n if (i != N_CMSG_CAPS) {\n rfbLog(\"rfbSendInteractionCaps: assertion failed, i != N_CMSG_CAPS\\n\");\n rfbCloseClient(cl);\n return;\n }\n *\/\n\n \/* Encoding types. *\/\n i = 0;\n SetCapInfo(&enc_list[i++], rfbEncodingCopyRect, rfbStandardVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingRRE, rfbStandardVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingCoRRE, rfbStandardVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingHextile, rfbStandardVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingZlib, rfbTridiaVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingZRLE, rfbTridiaVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingZYWRLE, rfbTridiaVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingTight, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingCompressLevel0, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingQualityLevel0, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingFineQualityLevel0, rfbTurboVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingSubsamp1X, rfbTurboVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingXCursor, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingRichCursor, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingPointerPos, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbEncodingLastRect, rfbTightVncVendor);\n SetCapInfo(&enc_list[i++], rfbGIIServer, rfbGIIVendor);\n if (i != N_ENC_CAPS) {\n rfbLog(\"rfbSendInteractionCaps: assertion failed, i != N_ENC_CAPS\\n\");\n rfbCloseClient(cl);\n return;\n }\n\n \/* Send header and capability lists *\/\n if (WriteExact(cl, (char *)&intr_caps,\n sz_rfbInteractionCapsMsg) < 0 ||\n WriteExact(cl, (char *)&enc_list[0],\n sz_rfbCapabilityInfo * N_ENC_CAPS) < 0) {\n rfbLogPerror(\"rfbSendInteractionCaps: write\");\n rfbCloseClient(cl);\n return;\n }\n\n \/* Dispatch client input to rfbProcessClientNormalMessage(). *\/\n cl->state = RFB_NORMAL;\n}","target":0,"code_token_length":1128,"total_token_length":1364,"max_tokens_setting":2048} +{"idx":138654,"func":"static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)\n{\n\tstruct vcpu_vmx *vmx = to_vmx(vcpu);\n\tstruct shared_msr_entry *msr;\n\tint ret = 0;\n\tu32 msr_index = msr_info->index;\n\tu64 data = msr_info->data;\n\n\tswitch (msr_index) {\n\tcase MSR_EFER:\n\t\tret = kvm_set_msr_common(vcpu, msr_info);\n\t\tbreak;\n#ifdef CONFIG_X86_64\n\tcase MSR_FS_BASE:\n\t\tvmx_segment_cache_clear(vmx);\n\t\tvmcs_writel(GUEST_FS_BASE, data);\n\t\tbreak;\n\tcase MSR_GS_BASE:\n\t\tvmx_segment_cache_clear(vmx);\n\t\tvmcs_writel(GUEST_GS_BASE, data);\n\t\tbreak;\n\tcase MSR_KERNEL_GS_BASE:\n\t\tvmx_load_host_state(vmx);\n\t\tvmx->msr_guest_kernel_gs_base = data;\n\t\tbreak;\n#endif\n\tcase MSR_IA32_SYSENTER_CS:\n\t\tvmcs_write32(GUEST_SYSENTER_CS, data);\n\t\tbreak;\n\tcase MSR_IA32_SYSENTER_EIP:\n\t\tvmcs_writel(GUEST_SYSENTER_EIP, data);\n\t\tbreak;\n\tcase MSR_IA32_SYSENTER_ESP:\n\t\tvmcs_writel(GUEST_SYSENTER_ESP, data);\n\t\tbreak;\n\tcase MSR_IA32_BNDCFGS:\n\t\tif (!vmx_mpx_supported())\n\t\t\treturn 1;\n\t\tvmcs_write64(GUEST_BNDCFGS, data);\n\t\tbreak;\n\tcase MSR_IA32_TSC:\n\t\tkvm_write_tsc(vcpu, msr_info);\n\t\tbreak;\n\tcase MSR_IA32_CR_PAT:\n\t\tif (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {\n\t\t\tif (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))\n\t\t\t\treturn 1;\n\t\t\tvmcs_write64(GUEST_IA32_PAT, data);\n\t\t\tvcpu->arch.pat = data;\n\t\t\tbreak;\n\t\t}\n\t\tret = kvm_set_msr_common(vcpu, msr_info);\n\t\tbreak;\n\tcase MSR_IA32_TSC_ADJUST:\n\t\tret = kvm_set_msr_common(vcpu, msr_info);\n\t\tbreak;\n\tcase MSR_IA32_FEATURE_CONTROL:\n\t\tif (!nested_vmx_allowed(vcpu) ||\n\t\t (to_vmx(vcpu)->nested.msr_ia32_feature_control &\n\t\t FEATURE_CONTROL_LOCKED && !msr_info->host_initiated))\n\t\t\treturn 1;\n\t\tvmx->nested.msr_ia32_feature_control = data;\n\t\tif (msr_info->host_initiated && data == 0)\n\t\t\tvmx_leave_nested(vcpu);\n\t\tbreak;\n\tcase MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC:\n\t\treturn 1; \/* they are read-only *\/\n\tcase MSR_TSC_AUX:\n\t\tif (!vmx->rdtscp_enabled)\n\t\t\treturn 1;\n\t\t\/* Check reserved bit, higher 32 bits should be zero *\/\n\t\tif ((data >> 32) != 0)\n\t\t\treturn 1;\n\t\t\/* Otherwise falls through *\/\n\tdefault:\n\t\tmsr = find_msr_entry(vmx, msr_index);\n\t\tif (msr) {\n\t\t\tmsr->data = data;\n\t\t\tif (msr - vmx->guest_msrs < vmx->save_nmsrs) {\n\t\t\t\tpreempt_disable();\n\t\t\t\tkvm_set_shared_msr(msr->index, msr->data,\n\t\t\t\t\t\t msr->mask);\n\t\t\t\tpreempt_enable();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tret = kvm_set_msr_common(vcpu, msr_info);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":810,"total_token_length":1046,"max_tokens_setting":2048} +{"idx":351170,"func":"libxlDomainShutdownThread(void *opaque)\n{\n struct libxlShutdownThreadInfo *shutdown_info = opaque;\n virDomainObj *vm = shutdown_info->vm;\n libxl_event *ev = shutdown_info->event;\n libxlDriverPrivate *driver = shutdown_info->driver;\n virObjectEvent *dom_event = NULL;\n libxl_shutdown_reason xl_reason = ev->u.domain_shutdown.shutdown_reason;\n g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);\n libxl_domain_config d_config;\n\n libxl_domain_config_init(&d_config);\n\n if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)\n goto cleanup;\n\n if (xl_reason == LIBXL_SHUTDOWN_REASON_POWEROFF) {\n virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF,\n VIR_DOMAIN_SHUTOFF_SHUTDOWN);\n\n dom_event = virDomainEventLifecycleNewFromObj(vm,\n VIR_DOMAIN_EVENT_STOPPED,\n VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);\n switch ((virDomainLifecycleAction) vm->def->onPoweroff) {\n case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:\n libxlDomainShutdownHandleDestroy(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:\n case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME:\n libxlDomainShutdownHandleRestart(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:\n case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:\n case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:\n case VIR_DOMAIN_LIFECYCLE_ACTION_LAST:\n goto endjob;\n }\n } else if (xl_reason == LIBXL_SHUTDOWN_REASON_CRASH) {\n virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF,\n VIR_DOMAIN_SHUTOFF_CRASHED);\n\n dom_event = virDomainEventLifecycleNewFromObj(vm,\n VIR_DOMAIN_EVENT_STOPPED,\n VIR_DOMAIN_EVENT_STOPPED_CRASHED);\n switch ((virDomainLifecycleAction) vm->def->onCrash) {\n case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:\n libxlDomainShutdownHandleDestroy(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:\n case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME:\n libxlDomainShutdownHandleRestart(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:\n case VIR_DOMAIN_LIFECYCLE_ACTION_LAST:\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:\n libxlDomainAutoCoreDump(driver, vm);\n libxlDomainShutdownHandleDestroy(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:\n libxlDomainAutoCoreDump(driver, vm);\n libxlDomainShutdownHandleRestart(driver, vm);\n goto endjob;\n }\n } else if (xl_reason == LIBXL_SHUTDOWN_REASON_REBOOT) {\n virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF,\n VIR_DOMAIN_SHUTOFF_SHUTDOWN);\n\n dom_event = virDomainEventLifecycleNewFromObj(vm,\n VIR_DOMAIN_EVENT_STOPPED,\n VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);\n switch ((virDomainLifecycleAction) vm->def->onReboot) {\n case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY:\n libxlDomainShutdownHandleDestroy(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART:\n case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME:\n libxlDomainShutdownHandleRestart(driver, vm);\n goto endjob;\n case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE:\n case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY:\n case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART:\n case VIR_DOMAIN_LIFECYCLE_ACTION_LAST:\n goto endjob;\n }\n } else if (xl_reason == LIBXL_SHUTDOWN_REASON_SOFT_RESET) {\n libxlDomainObjPrivate *priv = vm->privateData;\n\n if (libxlRetrieveDomainConfigurationWrapper(cfg->ctx, vm->def->id,\n &d_config) != 0) {\n VIR_ERROR(_(\"Failed to retrieve config for VM '%s'. \"\n \"Unable to perform soft reset. Destroying VM\"),\n vm->def->name);\n libxlDomainShutdownHandleDestroy(driver, vm);\n goto endjob;\n }\n\n if (priv->deathW) {\n libxl_evdisable_domain_death(cfg->ctx, priv->deathW);\n priv->deathW = NULL;\n }\n\n if (libxl_domain_soft_reset(cfg->ctx, &d_config, vm->def->id,\n NULL, NULL) != 0) {\n VIR_ERROR(_(\"Failed to soft reset VM '%s'. Destroying VM\"),\n vm->def->name);\n libxlDomainShutdownHandleDestroy(driver, vm);\n goto endjob;\n }\n libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW);\n libxlDomainUnpauseWrapper(cfg->ctx, vm->def->id);\n } else {\n VIR_INFO(\"Unhandled shutdown_reason %d\", xl_reason);\n }\n\n endjob:\n libxlDomainObjEndJob(driver, vm);\n\n cleanup:\n virDomainObjEndAPI(&vm);\n virObjectEventStateQueue(driver->domainEventState, dom_event);\n libxl_event_free(cfg->ctx, ev);\n VIR_FREE(shutdown_info);\n libxl_domain_config_dispose(&d_config);\n}","target":1,"code_token_length":1223,"total_token_length":1459,"max_tokens_setting":2048} +{"idx":344873,"func":"file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unused)),\n const void *buf, size_t nb)\n{\n\tint m = 0, rv = 0, looks_text = 0;\n\tint mime = ms->flags & MAGIC_MIME;\n\tconst unsigned char *ubuf = CAST(const unsigned char *, buf);\n\tunichar *u8buf = NULL;\n\tsize_t ulen;\n\tconst char *code = NULL;\n\tconst char *code_mime = \"binary\";\n\tconst char *type = \"application\/octet-stream\";\n\tconst char *def = \"data\";\n\n\n\n\tif (nb == 0) {\n\t\tdef = \"empty\";\n\t\ttype = \"application\/x-empty\";\n\t\tgoto simple;\n\t} else if (nb == 1) {\n\t\tdef = \"very short file (no magic)\";\n\t\tgoto simple;\n\t}\n\n\tif ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {\n\t\tlooks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen,\n\t\t &code, &code_mime, &type);\n\t}\n\n#ifdef __EMX__\n\tif ((ms->flags & MAGIC_NO_CHECK_APPTYPE) == 0 && inname) {\n\t\tswitch (file_os2_apptype(ms, inname, buf, nb)) {\n\t\tcase -1:\n\t\t\treturn -1;\n\t\tcase 0:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn 1;\n\t\t}\n\t}\n#endif\n#if HAVE_FORK\n\t\/* try compression stuff *\/\n\tif ((ms->flags & MAGIC_NO_CHECK_COMPRESS) == 0)\n\t\tif ((m = file_zmagic(ms, fd, inname, ubuf, nb)) != 0) {\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t(void)fprintf(stderr, \"zmagic %d\\n\", m);\n\t\t\tgoto done_encoding;\n\t\t}\n#endif\n\t\/* Check if we have a tar file *\/\n\tif ((ms->flags & MAGIC_NO_CHECK_TAR) == 0)\n\t\tif ((m = file_is_tar(ms, ubuf, nb)) != 0) {\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t(void)fprintf(stderr, \"tar %d\\n\", m);\n\t\t\tgoto done;\n\t\t}\n\n\t\/* Check if we have a CDF file *\/\n\tif ((ms->flags & MAGIC_NO_CHECK_CDF) == 0)\n\t\tif ((m = file_trycdf(ms, fd, ubuf, nb)) != 0) {\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t(void)fprintf(stderr, \"cdf %d\\n\", m);\n\t\t\tgoto done;\n\t\t}\n\n\t\/* try soft magic tests *\/\n\tif ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)\n\t\tif ((m = file_softmagic(ms, ubuf, nb, BINTEST,\n\t\t looks_text)) != 0) {\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t(void)fprintf(stderr, \"softmagic %d\\n\", m);\n#ifdef BUILTIN_ELF\n\t\t\tif ((ms->flags & MAGIC_NO_CHECK_ELF) == 0 && m == 1 &&\n\t\t\t nb > 5 && fd != -1) {\n\t\t\t\t\/*\n\t\t\t\t * We matched something in the file, so this\n\t\t\t\t * *might* be an ELF file, and the file is at\n\t\t\t\t * least 5 bytes long, so if it's an ELF file\n\t\t\t\t * it has at least one byte past the ELF magic\n\t\t\t\t * number - try extracting information from the\n\t\t\t\t * ELF headers that cannot easily * be\n\t\t\t\t * extracted with rules in the magic file.\n\t\t\t\t *\/\n\t\t\t\tif ((m = file_tryelf(ms, fd, ubuf, nb)) != 0)\n\t\t\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t\t\t(void)fprintf(stderr,\n\t\t\t\t\t\t \"elf %d\\n\", m);\n\t\t\t}\n#endif\n\t\t\tgoto done;\n\t\t}\n\n\t\/* try text properties *\/\n\tif ((ms->flags & MAGIC_NO_CHECK_TEXT) == 0) {\n\n\t\tif ((m = file_ascmagic(ms, ubuf, nb, looks_text)) != 0) {\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t(void)fprintf(stderr, \"ascmagic %d\\n\", m);\n\t\t\tgoto done;\n\t\t}\n\n\t\t\/* try to discover text encoding *\/\n\t\tif ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {\n\t\t\tif (looks_text == 0)\n\t\t\t\tif ((m = file_ascmagic_with_encoding( ms, ubuf,\n\t\t\t\t nb, u8buf, ulen, code, type, looks_text))\n\t\t\t\t != 0) {\n\t\t\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t\t\t(void)fprintf(stderr,\n\t\t\t\t\t\t \"ascmagic\/enc %d\\n\", m);\n\t\t\t\t\tgoto done;\n\t\t\t\t}\n\t\t}\n\t}\n\nsimple:\n\t\/* give up *\/\n\tm = 1;\n\tif ((!mime || (mime & MAGIC_MIME_TYPE)) &&\n\t file_printf(ms, \"%s\", mime ? type : def) == -1) {\n\t rv = -1;\n\t}\n done:\n\tif ((ms->flags & MAGIC_MIME_ENCODING) != 0) {\n\t\tif (ms->flags & MAGIC_MIME_TYPE)\n\t\t\tif (file_printf(ms, \"; charset=\") == -1)\n\t\t\t\trv = -1;\n\t\tif (file_printf(ms, \"%s\", code_mime) == -1)\n\t\t\trv = -1;\n\t}\n done_encoding:\n\tfree(u8buf);\n\tif (rv)\n\t\treturn rv;\n\n\treturn m;\n}","target":1,"code_token_length":1189,"total_token_length":1425,"max_tokens_setting":2048} +{"idx":361152,"func":"NTSTATUS smb_set_file_time(connection_struct *conn,\n\t\t\t files_struct *fsp,\n\t\t\t const struct smb_filename *smb_fname,\n\t\t\t struct smb_file_time *ft,\n\t\t\t bool setting_write_time)\n{\n\tstruct smb_filename smb_fname_base;\n\tuint32 action =\n\t\tFILE_NOTIFY_CHANGE_LAST_ACCESS\n\t\t|FILE_NOTIFY_CHANGE_LAST_WRITE\n\t\t|FILE_NOTIFY_CHANGE_CREATION;\n\n\tif (!VALID_STAT(smb_fname->st)) {\n\t\treturn NT_STATUS_OBJECT_NAME_NOT_FOUND;\n\t}\n\n\t\/* get some defaults (no modifications) if any info is zero or -1. *\/\n\tif (null_timespec(ft->create_time)) {\n\t\taction &= ~FILE_NOTIFY_CHANGE_CREATION;\n\t}\n\n\tif (null_timespec(ft->atime)) {\n\t\taction &= ~FILE_NOTIFY_CHANGE_LAST_ACCESS;\n\t}\n\n\tif (null_timespec(ft->mtime)) {\n\t\taction &= ~FILE_NOTIFY_CHANGE_LAST_WRITE;\n\t}\n\n\tif (!setting_write_time) {\n\t\t\/* ft->mtime comes from change time, not write time. *\/\n\t\taction &= ~FILE_NOTIFY_CHANGE_LAST_WRITE;\n\t}\n\n\t\/* Ensure the resolution is the correct for\n\t * what we can store on this filesystem. *\/\n\n\tround_timespec(conn->ts_res, &ft->create_time);\n\tround_timespec(conn->ts_res, &ft->ctime);\n\tround_timespec(conn->ts_res, &ft->atime);\n\tround_timespec(conn->ts_res, &ft->mtime);\n\n\tDEBUG(5,(\"smb_set_filetime: actime: %s\\n \",\n\t\ttime_to_asc(convert_timespec_to_time_t(ft->atime))));\n\tDEBUG(5,(\"smb_set_filetime: modtime: %s\\n \",\n\t\ttime_to_asc(convert_timespec_to_time_t(ft->mtime))));\n\tDEBUG(5,(\"smb_set_filetime: ctime: %s\\n \",\n\t\ttime_to_asc(convert_timespec_to_time_t(ft->ctime))));\n\tDEBUG(5,(\"smb_set_file_time: createtime: %s\\n \",\n\t\ttime_to_asc(convert_timespec_to_time_t(ft->create_time))));\n\n\tif (setting_write_time) {\n\t\t\/*\n\t\t * This was a Windows setfileinfo on an open file.\n\t\t * NT does this a lot. We also need to \n\t\t * set the time here, as it can be read by \n\t\t * FindFirst\/FindNext and with the patch for bug #2045\n\t\t * in smbd\/fileio.c it ensures that this timestamp is\n\t\t * kept sticky even after a write. We save the request\n\t\t * away and will set it on file close and after a write. JRA.\n\t\t *\/\n\n\t\tDEBUG(10,(\"smb_set_file_time: setting pending modtime to %s\\n\",\n\t\t\t time_to_asc(convert_timespec_to_time_t(ft->mtime))));\n\n\t\tif (fsp != NULL) {\n\t\t\tif (fsp->base_fsp) {\n\t\t\t\tset_sticky_write_time_fsp(fsp->base_fsp,\n\t\t\t\t\t\t\t ft->mtime);\n\t\t\t} else {\n\t\t\t\tset_sticky_write_time_fsp(fsp, ft->mtime);\n\t\t\t}\n\t\t} else {\n\t\t\tset_sticky_write_time_path(\n\t\t\t\tvfs_file_id_from_sbuf(conn, &smb_fname->st),\n\t\t\t\tft->mtime);\n\t\t}\n\t}\n\n\tDEBUG(10,(\"smb_set_file_time: setting utimes to modified values.\\n\"));\n\n\t\/* Always call ntimes on the base, even if a stream was passed in. *\/\n\tsmb_fname_base = *smb_fname;\n\tsmb_fname_base.stream_name = NULL;\n\n\tif(file_ntimes(conn, &smb_fname_base, ft)!=0) {\n\t\treturn map_nt_error_from_unix(errno);\n\t}\n\n\tnotify_fname(conn, NOTIFY_ACTION_MODIFIED, action,\n\t\t smb_fname->base_name);\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":800,"total_token_length":1036,"max_tokens_setting":2048} +{"idx":258842,"func":"PackOpenBSDElf32x86::generateElfHdr(\n OutputFile *fo,\n void const *proto,\n unsigned const brka\n)\n{\n cprElfHdr3 *const h3 = (cprElfHdr3 *)(void *)&elfout;\n memcpy(h3, proto, sizeof(*h3)); \/\/ reads beyond, but OK\n h3->ehdr.e_ident[Elf32_Ehdr::EI_OSABI] = ei_osabi;\n assert(2==get_te16(&h3->ehdr.e_phnum));\n set_te16(&h3->ehdr.e_phnum, 3);\n\n assert(get_te32(&h3->ehdr.e_phoff) == sizeof(Elf32_Ehdr));\n h3->ehdr.e_shoff = 0;\n assert(get_te16(&h3->ehdr.e_ehsize) == sizeof(Elf32_Ehdr));\n assert(get_te16(&h3->ehdr.e_phentsize) == sizeof(Elf32_Phdr));\n set_te16(&h3->ehdr.e_shentsize, sizeof(Elf32_Shdr));\n h3->ehdr.e_shnum = 0;\n h3->ehdr.e_shstrndx = 0;\n\n struct {\n Elf32_Nhdr nhdr;\n char name[8];\n unsigned body;\n } elfnote;\n\n unsigned const note_offset = sizeof(*h3) - sizeof(linfo);\n sz_elf_hdrs = sizeof(elfnote) + note_offset;\n\n set_te32(&h3->phdr[C_NOTE].p_type, PT_NOTE32);\n set_te32(&h3->phdr[C_NOTE].p_offset, note_offset);\n set_te32(&h3->phdr[C_NOTE].p_vaddr, note_offset);\n set_te32(&h3->phdr[C_NOTE].p_paddr, note_offset);\n set_te32(&h3->phdr[C_NOTE].p_filesz, sizeof(elfnote));\n set_te32(&h3->phdr[C_NOTE].p_memsz, sizeof(elfnote));\n set_te32(&h3->phdr[C_NOTE].p_flags, Elf32_Phdr::PF_R);\n set_te32(&h3->phdr[C_NOTE].p_align, 4);\n\n \/\/ Q: Same as this->note_body[0 .. this->note_size-1] ?\n set_te32(&elfnote.nhdr.namesz, 8);\n set_te32(&elfnote.nhdr.descsz, OPENBSD_DESCSZ);\n set_te32(&elfnote.nhdr.type, NHDR_OPENBSD_TAG);\n memcpy(elfnote.name, \"OpenBSD\", sizeof(elfnote.name));\n elfnote.body = 0;\n\n set_te32(&h3->phdr[C_TEXT].p_filesz, sz_elf_hdrs);\n h3->phdr[C_TEXT].p_memsz = h3->phdr[C_TEXT].p_filesz;\n\n unsigned const brkb = brka | ((0==(~page_mask & brka)) ? 0x20 : 0);\n set_te32(&h3->phdr[C_BASE].p_type, PT_LOAD32); \/\/ be sure\n set_te32(&h3->phdr[C_BASE].p_offset, ~page_mask & brkb);\n set_te32(&h3->phdr[C_BASE].p_vaddr, brkb);\n set_te32(&h3->phdr[C_BASE].p_paddr, brkb);\n h3->phdr[C_BASE].p_filesz = 0;\n \/\/ Too many kernels have bugs when 0==.p_memsz\n set_te32(&h3->phdr[C_BASE].p_memsz, 1);\n set_te32(&h3->phdr[C_BASE].p_flags, Elf32_Phdr::PF_R | Elf32_Phdr::PF_W);\n\n if (ph.format==getFormat()) {\n memset(&h3->linfo, 0, sizeof(h3->linfo));\n fo->write(h3, sizeof(*h3) - sizeof(h3->linfo));\n fo->write(&elfnote, sizeof(elfnote));\n fo->write(&h3->linfo, sizeof(h3->linfo));\n }\n else {\n assert(false); \/\/ unknown ph.format, PackLinuxElf32\n }\n}","target":0,"code_token_length":984,"total_token_length":1220,"max_tokens_setting":2048} +{"idx":123682,"func":"int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)\n{\n\tstruct btrfs_fs_info *fs_info = trans->fs_info;\n\tstruct extent_map *em;\n\tstruct map_lookup *map;\n\tu64 dev_extent_len = 0;\n\tint i, ret = 0;\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\n\tem = btrfs_get_chunk_map(fs_info, chunk_offset, 1);\n\tif (IS_ERR(em)) {\n\t\t\/*\n\t\t * This is a logic error, but we don't want to just rely on the\n\t\t * user having built with ASSERT enabled, so if ASSERT doesn't\n\t\t * do anything we still error out.\n\t\t *\/\n\t\tASSERT(0);\n\t\treturn PTR_ERR(em);\n\t}\n\tmap = em->map_lookup;\n\n\t\/*\n\t * First delete the device extent items from the devices btree.\n\t * We take the device_list_mutex to avoid racing with the finishing phase\n\t * of a device replace operation. See the comment below before acquiring\n\t * fs_info->chunk_mutex. Note that here we do not acquire the chunk_mutex\n\t * because that can result in a deadlock when deleting the device extent\n\t * items from the devices btree - COWing an extent buffer from the btree\n\t * may result in allocating a new metadata chunk, which would attempt to\n\t * lock again fs_info->chunk_mutex.\n\t *\/\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tfor (i = 0; i < map->num_stripes; i++) {\n\t\tstruct btrfs_device *device = map->stripes[i].dev;\n\t\tret = btrfs_free_dev_extent(trans, device,\n\t\t\t\t\t map->stripes[i].physical,\n\t\t\t\t\t &dev_extent_len);\n\t\tif (ret) {\n\t\t\tmutex_unlock(&fs_devices->device_list_mutex);\n\t\t\tbtrfs_abort_transaction(trans, ret);\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (device->bytes_used > 0) {\n\t\t\tmutex_lock(&fs_info->chunk_mutex);\n\t\t\tbtrfs_device_set_bytes_used(device,\n\t\t\t\t\tdevice->bytes_used - dev_extent_len);\n\t\t\tatomic64_add(dev_extent_len, &fs_info->free_chunk_space);\n\t\t\tbtrfs_clear_space_info_full(fs_info);\n\t\t\tmutex_unlock(&fs_info->chunk_mutex);\n\t\t}\n\t}\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\t\/*\n\t * We acquire fs_info->chunk_mutex for 2 reasons:\n\t *\n\t * 1) Just like with the first phase of the chunk allocation, we must\n\t * reserve system space, do all chunk btree updates and deletions, and\n\t * update the system chunk array in the superblock while holding this\n\t * mutex. This is for similar reasons as explained on the comment at\n\t * the top of btrfs_chunk_alloc();\n\t *\n\t * 2) Prevent races with the final phase of a device replace operation\n\t * that replaces the device object associated with the map's stripes,\n\t * because the device object's id can change at any time during that\n\t * final phase of the device replace operation\n\t * (dev-replace.c:btrfs_dev_replace_finishing()), so we could grab the\n\t * replaced device and then see it with an ID of\n\t * BTRFS_DEV_REPLACE_DEVID, which would cause a failure when updating\n\t * the device item, which does not exists on the chunk btree.\n\t * The finishing phase of device replace acquires both the\n\t * device_list_mutex and the chunk_mutex, in that order, so we are\n\t * safe by just acquiring the chunk_mutex.\n\t *\/\n\ttrans->removing_chunk = true;\n\tmutex_lock(&fs_info->chunk_mutex);\n\n\tcheck_system_chunk(trans, map->type);\n\n\tret = remove_chunk_item(trans, map, chunk_offset);\n\t\/*\n\t * Normally we should not get -ENOSPC since we reserved space before\n\t * through the call to check_system_chunk().\n\t *\n\t * Despite our system space_info having enough free space, we may not\n\t * be able to allocate extents from its block groups, because all have\n\t * an incompatible profile, which will force us to allocate a new system\n\t * block group with the right profile, or right after we called\n\t * check_system_space() above, a scrub turned the only system block group\n\t * with enough free space into RO mode.\n\t * This is explained with more detail at do_chunk_alloc().\n\t *\n\t * So if we get -ENOSPC, allocate a new system chunk and retry once.\n\t *\/\n\tif (ret == -ENOSPC) {\n\t\tconst u64 sys_flags = btrfs_system_alloc_profile(fs_info);\n\t\tstruct btrfs_block_group *sys_bg;\n\n\t\tsys_bg = btrfs_alloc_chunk(trans, sys_flags);\n\t\tif (IS_ERR(sys_bg)) {\n\t\t\tret = PTR_ERR(sys_bg);\n\t\t\tbtrfs_abort_transaction(trans, ret);\n\t\t\tgoto out;\n\t\t}\n\n\t\tret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg);\n\t\tif (ret) {\n\t\t\tbtrfs_abort_transaction(trans, ret);\n\t\t\tgoto out;\n\t\t}\n\n\t\tret = remove_chunk_item(trans, map, chunk_offset);\n\t\tif (ret) {\n\t\t\tbtrfs_abort_transaction(trans, ret);\n\t\t\tgoto out;\n\t\t}\n\t} else if (ret) {\n\t\tbtrfs_abort_transaction(trans, ret);\n\t\tgoto out;\n\t}\n\n\ttrace_btrfs_chunk_free(fs_info, map, chunk_offset, em->len);\n\n\tif (map->type & BTRFS_BLOCK_GROUP_SYSTEM) {\n\t\tret = btrfs_del_sys_chunk(fs_info, chunk_offset);\n\t\tif (ret) {\n\t\t\tbtrfs_abort_transaction(trans, ret);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tmutex_unlock(&fs_info->chunk_mutex);\n\ttrans->removing_chunk = false;\n\n\t\/*\n\t * We are done with chunk btree updates and deletions, so release the\n\t * system space we previously reserved (with check_system_chunk()).\n\t *\/\n\tbtrfs_trans_release_chunk_metadata(trans);\n\n\tret = btrfs_remove_block_group(trans, chunk_offset, em);\n\tif (ret) {\n\t\tbtrfs_abort_transaction(trans, ret);\n\t\tgoto out;\n\t}\n\nout:\n\tif (trans->removing_chunk) {\n\t\tmutex_unlock(&fs_info->chunk_mutex);\n\t\ttrans->removing_chunk = false;\n\t}\n\t\/* once for us *\/\n\tfree_extent_map(em);\n\treturn ret;\n}","target":0,"code_token_length":1359,"total_token_length":1595,"max_tokens_setting":2048} +{"idx":32390,"func":"void LeptonCodec::ThreadState::decode_row_internal(BlockBasedImagePerChannel& image_data,\n Sirikata::Array1d component_size_in_blocks,\n int component,\n int curr_y) {\n using std::tuple;\n tuple corner(EACH_BLOCK_TYPE(false,false,false));\n tuple top(EACH_BLOCK_TYPE(true,false,false));\n tuple midleft(EACH_BLOCK_TYPE(false, true, true));\n tuple middle(EACH_BLOCK_TYPE(true,true,true));\n tuple midright(EACH_BLOCK_TYPE(true, true, false));\n tuple width_one(EACH_BLOCK_TYPE(false, true, false));\n context_.at(component)\n = image_data[component]->off_y(curr_y,\n num_nonzeros_.at(component).begin());\n \n int block_width = image_data[component]->block_width();\n if (is_top_row_.at(component)) {\n is_top_row_.at(component) = false;\n switch((BlockType)component) {\n case BlockType::Y:\n decode_row(std::get<(int)BlockType::Y>(corner),\n std::get<(int)BlockType::Y>(top),\n std::get<(int)BlockType::Y>(top),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n break;\n case BlockType::Cb:\n decode_row(std::get<(int)BlockType::Cb>(corner),\n std::get<(int)BlockType::Cb>(top),\n std::get<(int)BlockType::Cb>(top),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n case BlockType::Cr:\n decode_row(std::get<(int)BlockType::Cr>(corner),\n std::get<(int)BlockType::Cr>(top),\n std::get<(int)BlockType::Cr>(top),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n#ifdef ALLOW_FOUR_COLORS\n case BlockType::Ck:\n decode_row(std::get<(int)BlockType::Ck>(corner),\n std::get<(int)BlockType::Ck>(top),\n std::get<(int)BlockType::Ck>(top),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n#endif\n }\n } else if (block_width > 1) {\n dev_assert(curr_y); \/\/ just a sanity check that the zeroth row took the first branch\n switch((BlockType)component) {\n case BlockType::Y:\n decode_row(std::get<(int)BlockType::Y>(midleft),\n std::get<(int)BlockType::Y>(middle),\n std::get<(int)BlockType::Y>(midright),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n case BlockType::Cb:\n decode_row(std::get<(int)BlockType::Cb>(midleft),\n std::get<(int)BlockType::Cb>(middle),\n std::get<(int)BlockType::Cb>(midright),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n case BlockType::Cr:\n decode_row(std::get<(int)BlockType::Cr>(midleft),\n std::get<(int)BlockType::Cr>(middle),\n std::get<(int)BlockType::Cr>(midright),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n#ifdef ALLOW_FOUR_COLORS\n case BlockType::Ck:\n decode_row(std::get<(int)BlockType::Ck>(midleft),\n std::get<(int)BlockType::Ck>(middle),\n std::get<(int)BlockType::Ck>(midright),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n#endif\n }\n } else {\n dev_assert(curr_y); \/\/ just a sanity check that the zeroth row took the first branch\n dev_assert(block_width == 1);\n switch((BlockType)component) {\n case BlockType::Y:\n decode_row(std::get<(int)BlockType::Y>(width_one),\n std::get<(int)BlockType::Y>(width_one),\n std::get<(int)BlockType::Y>(width_one),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n case BlockType::Cb:\n decode_row(std::get<(int)BlockType::Cb>(width_one),\n std::get<(int)BlockType::Cb>(width_one),\n std::get<(int)BlockType::Cb>(width_one),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n case BlockType::Cr:\n decode_row(std::get<(int)BlockType::Cr>(width_one),\n std::get<(int)BlockType::Cr>(width_one),\n std::get<(int)BlockType::Cr>(width_one),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n#ifdef ALLOW_FOUR_COLORS\n case BlockType::Ck:\n decode_row(std::get<(int)BlockType::Ck>(width_one),\n std::get<(int)BlockType::Ck>(width_one),\n std::get<(int)BlockType::Ck>(width_one),\n curr_y,\n image_data,\n component_size_in_blocks[component]);\n \n break;\n#endif\n }\n }\n}","target":0,"code_token_length":1283,"total_token_length":1519,"max_tokens_setting":2048} +{"idx":320539,"func":"static int curl_open(BlockDriverState *bs, QDict *options, int flags,\n\n Error **errp)\n\n{\n\n BDRVCURLState *s = bs->opaque;\n\n CURLState *state = NULL;\n\n QemuOpts *opts;\n\n Error *local_err = NULL;\n\n const char *file;\n\n const char *cookie;\n\n const char *cookie_secret;\n\n double d;\n\n const char *secretid;\n\n const char *protocol_delimiter;\n\n\n\n static int inited = 0;\n\n\n\n if (flags & BDRV_O_RDWR) {\n\n error_setg(errp, \"curl block device does not support writes\");\n\n return -EROFS;\n\n }\n\n\n\n qemu_mutex_init(&s->mutex);\n\n opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);\n\n qemu_opts_absorb_qdict(opts, options, &local_err);\n\n if (local_err) {\n\n error_propagate(errp, local_err);\n\n goto out_noclean;\n\n }\n\n\n\n s->readahead_size = qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD,\n\n READ_AHEAD_DEFAULT);\n\n if ((s->readahead_size & 0x1ff) != 0) {\n\n error_setg(errp, \"HTTP_READAHEAD_SIZE %zd is not a multiple of 512\",\n\n s->readahead_size);\n\n goto out_noclean;\n\n }\n\n\n\n s->timeout = qemu_opt_get_number(opts, CURL_BLOCK_OPT_TIMEOUT,\n\n CURL_TIMEOUT_DEFAULT);\n\n if (s->timeout > CURL_TIMEOUT_MAX) {\n\n error_setg(errp, \"timeout parameter is too large or negative\");\n\n goto out_noclean;\n\n }\n\n\n\n s->sslverify = qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, true);\n\n\n\n cookie = qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE);\n\n cookie_secret = qemu_opt_get(opts, CURL_BLOCK_OPT_COOKIE_SECRET);\n\n\n\n if (cookie && cookie_secret) {\n\n error_setg(errp,\n\n \"curl driver cannot handle both cookie and cookie secret\");\n\n goto out_noclean;\n\n }\n\n\n\n if (cookie_secret) {\n\n s->cookie = qcrypto_secret_lookup_as_utf8(cookie_secret, errp);\n\n if (!s->cookie) {\n\n goto out_noclean;\n\n }\n\n } else {\n\n s->cookie = g_strdup(cookie);\n\n }\n\n\n\n file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);\n\n if (file == NULL) {\n\n error_setg(errp, \"curl block driver requires an 'url' option\");\n\n goto out_noclean;\n\n }\n\n\n\n if (!strstart(file, bs->drv->protocol_name, &protocol_delimiter) ||\n\n !strstart(protocol_delimiter, \":\/\/\", NULL))\n\n {\n\n error_setg(errp, \"%s curl driver cannot handle the URL '%s' (does not \"\n\n \"start with '%s:\/\/')\", bs->drv->protocol_name, file,\n\n bs->drv->protocol_name);\n\n goto out_noclean;\n\n }\n\n\n\n s->username = g_strdup(qemu_opt_get(opts, CURL_BLOCK_OPT_USERNAME));\n\n secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PASSWORD_SECRET);\n\n\n\n if (secretid) {\n\n s->password = qcrypto_secret_lookup_as_utf8(secretid, errp);\n\n if (!s->password) {\n\n goto out_noclean;\n\n }\n\n }\n\n\n\n s->proxyusername = g_strdup(\n\n qemu_opt_get(opts, CURL_BLOCK_OPT_PROXY_USERNAME));\n\n secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PROXY_PASSWORD_SECRET);\n\n if (secretid) {\n\n s->proxypassword = qcrypto_secret_lookup_as_utf8(secretid, errp);\n\n if (!s->proxypassword) {\n\n goto out_noclean;\n\n }\n\n }\n\n\n\n if (!inited) {\n\n curl_global_init(CURL_GLOBAL_ALL);\n\n inited = 1;\n\n }\n\n\n\n DPRINTF(\"CURL: Opening %s\\n\", file);\n\n QSIMPLEQ_INIT(&s->free_state_waitq);\n\n s->aio_context = bdrv_get_aio_context(bs);\n\n s->url = g_strdup(file);\n\n qemu_mutex_lock(&s->mutex);\n\n state = curl_find_state(s);\n\n qemu_mutex_unlock(&s->mutex);\n\n if (!state) {\n\n goto out_noclean;\n\n }\n\n\n\n \/\/ Get file size\n\n\n\n if (curl_init_state(s, state) < 0) {\n\n goto out;\n\n }\n\n\n\n s->accept_range = false;\n\n curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);\n\n curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,\n\n curl_header_cb);\n\n curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);\n\n if (curl_easy_perform(state->curl))\n\n goto out;\n\n if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {\n\n goto out;\n\n }\n\n \/* Prior CURL 7.19.4 return value of 0 could mean that the file size is not\n\n * know or the size is zero. From 7.19.4 CURL returns -1 if size is not\n\n * known and zero if it is realy zero-length file. *\/\n\n#if LIBCURL_VERSION_NUM >= 0x071304\n\n if (d < 0) {\n\n pstrcpy(state->errmsg, CURL_ERROR_SIZE,\n\n \"Server didn't report file size.\");\n\n goto out;\n\n }\n\n#else\n\n if (d <= 0) {\n\n pstrcpy(state->errmsg, CURL_ERROR_SIZE,\n\n \"Unknown file size or zero-length file.\");\n\n goto out;\n\n }\n\n#endif\n\n\n\n s->len = d;\n\n\n\n if ((!strncasecmp(s->url, \"http:\/\/\", strlen(\"http:\/\/\"))\n\n || !strncasecmp(s->url, \"https:\/\/\", strlen(\"https:\/\/\")))\n\n && !s->accept_range) {\n\n pstrcpy(state->errmsg, CURL_ERROR_SIZE,\n\n \"Server does not support 'range' (byte ranges).\");\n\n goto out;\n\n }\n\n DPRINTF(\"CURL: Size = %\" PRIu64 \"\\n\", s->len);\n\n\n\n qemu_mutex_lock(&s->mutex);\n\n curl_clean_state(state);\n\n qemu_mutex_unlock(&s->mutex);\n\n curl_easy_cleanup(state->curl);\n\n state->curl = NULL;\n\n\n\n curl_attach_aio_context(bs, bdrv_get_aio_context(bs));\n\n\n\n qemu_opts_del(opts);\n\n return 0;\n\n\n\nout:\n\n error_setg(errp, \"CURL: Error opening file: %s\", state->errmsg);\n\n curl_easy_cleanup(state->curl);\n\n state->curl = NULL;\n\nout_noclean:\n\n qemu_mutex_destroy(&s->mutex);\n\n g_free(s->cookie);\n\n g_free(s->url);\n\n qemu_opts_del(opts);\n\n return -EINVAL;\n\n}\n","target":1,"code_token_length":1456,"total_token_length":1692,"max_tokens_setting":2048} +{"idx":43060,"func":"hfs_attr_walk_compressed_rsrc(const TSK_FS_ATTR * fs_attr,\n int flags, TSK_FS_FILE_WALK_CB a_action, void *ptr,\n int (*read_block_table)(const TSK_FS_ATTR *rAttr,\n CMP_OFFSET_ENTRY** offsetTableOut,\n uint32_t* tableSizeOut,\n uint32_t* tableOffsetOut),\n int (*decompress_block)(char* rawBuf,\n uint32_t len,\n char* uncBuf,\n uint64_t* uncLen))\n{\n TSK_FS_INFO *fs;\n TSK_FS_FILE *fs_file;\n const TSK_FS_ATTR *rAttr; \/\/ resource fork attribute\n char *rawBuf = NULL; \/\/ compressed data\n char *uncBuf = NULL; \/\/ uncompressed data\n uint32_t offsetTableOffset;\n uint32_t offsetTableSize; \/\/ The number of table entries\n CMP_OFFSET_ENTRY *offsetTable = NULL;\n size_t indx; \/\/ index for looping over the offset table\n TSK_OFF_T off = 0; \/\/ the offset in the uncompressed data stream consumed thus far\n\n if (tsk_verbose)\n tsk_fprintf(stderr,\n \"%s: Entered, because this is a compressed file with compressed data in the resource fork\\n\", __func__);\n\n \/\/ clean up any error messages that are lying around\n tsk_error_reset();\n if ((fs_attr == NULL) || (fs_attr->fs_file == NULL)\n || (fs_attr->fs_file->meta == NULL)\n || (fs_attr->fs_file->fs_info == NULL)) {\n tsk_error_set_errno(TSK_ERR_FS_ARG);\n tsk_error_set_errstr(\"%s: Null arguments given\\n\", __func__);\n return 1;\n }\n\n \/\/ Check that the ATTR being read is the main DATA resource, 128-0,\n \/\/ because this is the only one that can be compressed in HFS+\n if ((fs_attr->id != HFS_FS_ATTR_ID_DATA) ||\n (fs_attr->type != TSK_FS_ATTR_TYPE_HFS_DATA)) {\n error_detected(TSK_ERR_FS_ARG,\n \"%s: arg specified an attribute %u-%u that is not the data fork, \"\n \"Only the data fork can be compressed.\", __func__, fs_attr->type,\n fs_attr->id);\n return 1;\n }\n\n \/* This MUST be a compressed attribute *\/\n if (!(fs_attr->flags & TSK_FS_ATTR_COMP)) {\n error_detected(TSK_ERR_FS_FWALK,\n \"%s: called with non-special attribute: %x\",\n __func__, fs_attr->flags);\n return 1;\n }\n\n fs = fs_attr->fs_file->fs_info;\n fs_file = fs_attr->fs_file;\n\n \/******** Open the Resource Fork ***********\/\n\n \/\/ find the attribute for the resource fork\n rAttr =\n tsk_fs_file_attr_get_type(fs_file, TSK_FS_ATTR_TYPE_HFS_RSRC,\n HFS_FS_ATTR_ID_RSRC, TRUE);\n if (rAttr == NULL) {\n error_returned\n (\" %s: could not get the attribute for the resource fork of the file\", __func__);\n return 1;\n }\n\n \/\/ read the offset table from the fork header\n if (!read_block_table(rAttr, &offsetTable, &offsetTableSize, &offsetTableOffset)) {\n return 1;\n }\n\n \/\/ Allocate two buffers for the raw and uncompressed data\n \/* Raw data can be COMPRESSION_UNIT_SIZE+1 if the data is not\n * compressed and there is a 1-byte flag that indicates that\n * the data is not compressed. *\/\n rawBuf = (char *) tsk_malloc(COMPRESSION_UNIT_SIZE + 1);\n if (rawBuf == NULL) {\n error_returned\n (\" %s: buffers for reading and uncompressing\", __func__);\n goto on_error;\n }\n\n uncBuf = (char *) tsk_malloc(COMPRESSION_UNIT_SIZE);\n if (uncBuf == NULL) {\n error_returned\n (\" %s: buffers for reading and uncompressing\", __func__);\n goto on_error;\n }\n\n \/\/ FOR entry in the table DO\n for (indx = 0; indx < offsetTableSize; ++indx) {\n ssize_t uncLen; \/\/ uncompressed length\n unsigned int blockSize;\n uint64_t lumpSize;\n uint64_t remaining;\n char *lumpStart;\n\n switch ((uncLen = read_and_decompress_block(\n rAttr, rawBuf, uncBuf,\n offsetTable, offsetTableSize, offsetTableOffset, indx,\n decompress_block)))\n {\n case -1:\n goto on_error;\n case 0:\n continue;\n default:\n break;\n }\n\n \/\/ Call the a_action callback with \"Lumps\"\n \/\/ that are at most the block size.\n blockSize = fs->block_size;\n remaining = uncLen;\n lumpStart = uncBuf;\n\n while (remaining > 0) {\n int retval; \/\/ action return value\n lumpSize = remaining <= blockSize ? remaining : blockSize;\n\n \/\/ Apply the callback function\n if (tsk_verbose)\n tsk_fprintf(stderr,\n \"%s: Calling action on lump of size %\"\n PRIu64 \" offset %\" PRIu64 \" in the compression unit\\n\",\n __func__, lumpSize, uncLen - remaining);\n if (lumpSize > SIZE_MAX) {\n error_detected(TSK_ERR_FS_FWALK,\n \" %s: lumpSize is too large for the action\", __func__);\n goto on_error;\n }\n\n retval = a_action(fs_attr->fs_file, off, 0, lumpStart,\n (size_t) lumpSize, \/\/ cast OK because of above test\n TSK_FS_BLOCK_FLAG_COMP, ptr);\n\n if (retval == TSK_WALK_ERROR) {\n error_detected(TSK_ERR_FS | 201,\n \"%s: callback returned an error\", __func__);\n goto on_error;\n }\n else if (retval == TSK_WALK_STOP) {\n break;\n }\n\n \/\/ Find the next lump\n off += lumpSize;\n remaining -= lumpSize;\n lumpStart += lumpSize;\n }\n }\n\n \/\/ Done, so free up the allocated resources.\n free(offsetTable);\n free(rawBuf);\n free(uncBuf);\n return 0;\n\non_error:\n free(offsetTable);\n free(rawBuf);\n free(uncBuf);\n return 0;\n}","target":0,"code_token_length":1418,"total_token_length":1654,"max_tokens_setting":2048} +{"idx":386199,"func":"xsltFreeStylePreComp(xsltStylePreCompPtr comp) {\n if (comp == NULL)\n\treturn;\n#ifdef XSLT_REFACTORED\n \/*\n * URGENT TODO: Implement destructors.\n *\/\n switch (comp->type) {\n\tcase XSLT_FUNC_LITERAL_RESULT_ELEMENT:\n\t break;\n\tcase XSLT_FUNC_COPY:\n break;\n case XSLT_FUNC_SORT: {\n\t\txsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp;\n\t\tif (item->locale != (xsltLocale)0)\n\t\t xsltFreeLocale(item->locale);\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n break;\n case XSLT_FUNC_TEXT:\n break;\n case XSLT_FUNC_ELEMENT:\n break;\n case XSLT_FUNC_ATTRIBUTE:\n break;\n case XSLT_FUNC_COMMENT:\n break;\n case XSLT_FUNC_PI:\n\t break;\n case XSLT_FUNC_COPYOF: {\n\t\txsltStyleItemCopyOfPtr item = (xsltStyleItemCopyOfPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n break;\n case XSLT_FUNC_VALUEOF: {\n\t\txsltStyleItemValueOfPtr item = (xsltStyleItemValueOfPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n break;\n case XSLT_FUNC_NUMBER: {\n xsltStyleItemNumberPtr item = (xsltStyleItemNumberPtr) comp;\n if (item->numdata.countPat != NULL)\n xsltFreeCompMatchList(item->numdata.countPat);\n if (item->numdata.fromPat != NULL)\n xsltFreeCompMatchList(item->numdata.fromPat);\n }\n break;\n case XSLT_FUNC_APPLYIMPORTS:\n break;\n case XSLT_FUNC_CALLTEMPLATE:\n break;\n case XSLT_FUNC_APPLYTEMPLATES: {\n\t\txsltStyleItemApplyTemplatesPtr item =\n\t\t (xsltStyleItemApplyTemplatesPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n break;\n case XSLT_FUNC_CHOOSE:\n break;\n case XSLT_FUNC_IF: {\n\t\txsltStyleItemIfPtr item = (xsltStyleItemIfPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n break;\n case XSLT_FUNC_FOREACH: {\n\t\txsltStyleItemForEachPtr item =\n\t\t (xsltStyleItemForEachPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n break;\n case XSLT_FUNC_DOCUMENT:\n break;\n\tcase XSLT_FUNC_WITHPARAM: {\n\t\txsltStyleItemWithParamPtr item =\n\t\t (xsltStyleItemWithParamPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n\t break;\n\tcase XSLT_FUNC_PARAM: {\n\t\txsltStyleItemParamPtr item =\n\t\t (xsltStyleItemParamPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n\t break;\n\tcase XSLT_FUNC_VARIABLE: {\n\t\txsltStyleItemVariablePtr item =\n\t\t (xsltStyleItemVariablePtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n\t break;\n\tcase XSLT_FUNC_WHEN: {\n\t\txsltStyleItemWhenPtr item =\n\t\t (xsltStyleItemWhenPtr) comp;\n\t\tif (item->comp != NULL)\n\t\t xmlXPathFreeCompExpr(item->comp);\n\t }\n\t break;\n\tcase XSLT_FUNC_OTHERWISE:\n\tcase XSLT_FUNC_FALLBACK:\n\tcase XSLT_FUNC_MESSAGE:\n\tcase XSLT_FUNC_INCLUDE:\n\tcase XSLT_FUNC_ATTRSET:\n\n\t break;\n\tdefault:\n\t \/* TODO: Raise error. *\/\n\t break;\n }\n#else\n if (comp->locale != (xsltLocale)0)\n\txsltFreeLocale(comp->locale);\n if (comp->comp != NULL)\n\txmlXPathFreeCompExpr(comp->comp);\n if (comp->numdata.countPat != NULL)\n xsltFreeCompMatchList(comp->numdata.countPat);\n if (comp->numdata.fromPat != NULL)\n xsltFreeCompMatchList(comp->numdata.fromPat);\n if (comp->nsList != NULL)\n\txmlFree(comp->nsList);\n#endif\n\n xmlFree(comp);\n}","target":0,"code_token_length":1001,"total_token_length":1237,"max_tokens_setting":2048} +{"idx":261637,"func":"inline void StridedSlice(const tflite::StridedSliceParams& op_params,\n const RuntimeShape& unextended_input_shape,\n const RuntimeShape& unextended_output_shape,\n SequentialTensorWriter* writer) {\n using strided_slice::LoopCondition;\n using strided_slice::StartForAxis;\n using strided_slice::StopForAxis;\n\n ruy::profiler::ScopeLabel label(\"StridedSlice\");\n\n \/\/ Note that the output_shape is not used herein.\n tflite::StridedSliceParams params_copy = op_params;\n\n TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 5);\n TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 5);\n const RuntimeShape input_shape =\n RuntimeShape::ExtendedShape(5, unextended_input_shape);\n const RuntimeShape output_shape =\n RuntimeShape::ExtendedShape(5, unextended_output_shape);\n\n \/\/ Reverse and pad to 5 dimensions because that is what the runtime code\n \/\/ requires (ie. all shapes must be 5D and are given backwards).\n strided_slice::StridedSlicePadIndices(¶ms_copy, 5);\n\n const int start_0 = StartForAxis(params_copy, input_shape, 0);\n const int stop_0 = StopForAxis(params_copy, input_shape, 0, start_0);\n const int start_1 = StartForAxis(params_copy, input_shape, 1);\n const int stop_1 = StopForAxis(params_copy, input_shape, 1, start_1);\n const int start_2 = StartForAxis(params_copy, input_shape, 2);\n const int stop_2 = StopForAxis(params_copy, input_shape, 2, start_2);\n const int start_3 = StartForAxis(params_copy, input_shape, 3);\n const int stop_3 = StopForAxis(params_copy, input_shape, 3, start_3);\n const int start_4 = StartForAxis(params_copy, input_shape, 4);\n const int stop_4 = StopForAxis(params_copy, input_shape, 4, start_4);\n const bool inner_stride_is_1 = params_copy.strides[4] == 1;\n\n for (int offset_0 = start_0 * input_shape.Dims(1),\n end_0 = stop_0 * input_shape.Dims(1),\n step_0 = params_copy.strides[0] * input_shape.Dims(1);\n !LoopCondition(offset_0, end_0, params_copy.strides[0]);\n offset_0 += step_0) {\n for (int offset_1 = (offset_0 + start_1) * input_shape.Dims(2),\n end_1 = (offset_0 + stop_1) * input_shape.Dims(2),\n step_1 = params_copy.strides[1] * input_shape.Dims(2);\n !LoopCondition(offset_1, end_1, params_copy.strides[1]);\n offset_1 += step_1) {\n for (int offset_2 = (offset_1 + start_2) * input_shape.Dims(3),\n end_2 = (offset_1 + stop_2) * input_shape.Dims(3),\n step_2 = params_copy.strides[2] * input_shape.Dims(3);\n !LoopCondition(offset_2, end_2, params_copy.strides[2]);\n offset_2 += step_2) {\n for (int offset_3 = (offset_2 + start_3) * input_shape.Dims(4),\n end_3 = (offset_2 + stop_3) * input_shape.Dims(4),\n step_3 = params_copy.strides[3] * input_shape.Dims(4);\n !LoopCondition(offset_3, end_3, params_copy.strides[3]);\n offset_3 += step_3) {\n \/\/ When the stride is 1, the inner loop is equivalent to the\n \/\/ optimized slice inner loop. Otherwise, it is identical to the\n \/\/ strided_slice reference implementation inner loop.\n if (inner_stride_is_1) {\n const int len = stop_4 - start_4;\n if (len > 0) {\n writer->WriteN(offset_3 + start_4, len);\n }\n } else {\n for (int offset_4 = offset_3 + start_4, end_4 = offset_3 + stop_4;\n !LoopCondition(offset_4, end_4, params_copy.strides[4]);\n offset_4 += params_copy.strides[4]) {\n writer->Write(offset_4);\n }\n }\n }\n }\n }\n }\n}","target":0,"code_token_length":1028,"total_token_length":1264,"max_tokens_setting":2048} +{"idx":372459,"func":"cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)\n{\n cmsICCHeader Header;\n cmsUInt32Number i;\n cmsTagEntry Tag;\n cmsInt32Number Count = 0;\n\n Header.size = _cmsAdjustEndianess32(UsedSpace);\n Header.cmmId = _cmsAdjustEndianess32(lcmsSignature);\n Header.version = _cmsAdjustEndianess32(Icc ->Version);\n\n Header.deviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Icc -> DeviceClass);\n Header.colorSpace = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Icc -> ColorSpace);\n Header.pcs = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Icc -> PCS);\n\n \/\/ NOTE: in v4 Timestamp must be in UTC rather than in local time\n _cmsEncodeDateTimeNumber(&Header.date, &Icc ->Created);\n\n Header.magic = _cmsAdjustEndianess32(cmsMagicNumber);\n\n#ifdef CMS_IS_WINDOWS_\n Header.platform = (cmsPlatformSignature) _cmsAdjustEndianess32(cmsSigMicrosoft);\n#else\n Header.platform = (cmsPlatformSignature) _cmsAdjustEndianess32(cmsSigMacintosh);\n#endif\n\n Header.flags = _cmsAdjustEndianess32(Icc -> flags);\n Header.manufacturer = _cmsAdjustEndianess32(Icc -> manufacturer);\n Header.model = _cmsAdjustEndianess32(Icc -> model);\n\n _cmsAdjustEndianess64(&Header.attributes, &Icc -> attributes);\n\n \/\/ Rendering intent in the header (for embedded profiles)\n Header.renderingIntent = _cmsAdjustEndianess32(Icc -> RenderingIntent);\n\n \/\/ Illuminant is always D50\n Header.illuminant.X = _cmsAdjustEndianess32(_cmsDoubleTo15Fixed16(cmsD50_XYZ()->X));\n Header.illuminant.Y = _cmsAdjustEndianess32(_cmsDoubleTo15Fixed16(cmsD50_XYZ()->Y));\n Header.illuminant.Z = _cmsAdjustEndianess32(_cmsDoubleTo15Fixed16(cmsD50_XYZ()->Z));\n\n \/\/ Created by LittleCMS (that's me!)\n Header.creator = _cmsAdjustEndianess32(lcmsSignature);\n\n memset(&Header.reserved, 0, sizeof(Header.reserved));\n\n \/\/ Set profile ID. Endianess is always big endian\n memmove(&Header.profileID, &Icc ->ProfileID, 16);\n\n \/\/ Dump the header\n if (!Icc -> IOhandler->Write(Icc->IOhandler, sizeof(cmsICCHeader), &Header)) return FALSE;\n\n \/\/ Saves Tag directory\n\n \/\/ Get true count\n for (i=0; i < Icc -> TagCount; i++) {\n if (Icc ->TagNames[i] != 0)\n Count++;\n }\n\n \/\/ Store number of tags\n if (!_cmsWriteUInt32Number(Icc ->IOhandler, Count)) return FALSE;\n\n for (i=0; i < Icc -> TagCount; i++) {\n\n if (Icc ->TagNames[i] == 0) continue; \/\/ It is just a placeholder\n\n Tag.sig = (cmsTagSignature) _cmsAdjustEndianess32((cmsInt32Number) Icc -> TagNames[i]);\n Tag.offset = _cmsAdjustEndianess32((cmsInt32Number) Icc -> TagOffsets[i]);\n Tag.size = _cmsAdjustEndianess32((cmsInt32Number) Icc -> TagSizes[i]);\n\n if (!Icc ->IOhandler -> Write(Icc-> IOhandler, sizeof(cmsTagEntry), &Tag)) return FALSE;\n }\n\n return TRUE;\n}","target":0,"code_token_length":844,"total_token_length":1080,"max_tokens_setting":2048} +{"idx":24106,"func":"static void set_pseudo_header_frame4 ( union wtap_pseudo_header * pseudo_header , struct frame4_rec * frame4 ) {\n guint32 StatusWord ;\n guint8 aal_type , hl_type ;\n guint16 vpi , vci ;\n pseudo_header -> atm . flags = 0 ;\n StatusWord = pletoh32 ( & frame4 -> atm_info . StatusWord ) ;\n if ( StatusWord & SW_RAW_CELL ) pseudo_header -> atm . flags |= ATM_RAW_CELL ;\n aal_type = frame4 -> atm_info . AppTrafType & ATT_AALTYPE ;\n hl_type = frame4 -> atm_info . AppTrafType & ATT_HLTYPE ;\n vpi = pletoh16 ( & frame4 -> atm_info . Vpi ) ;\n vci = pletoh16 ( & frame4 -> atm_info . Vci ) ;\n switch ( aal_type ) {\n case ATT_AAL_UNKNOWN : if ( vpi == 0 && vci == 5 ) pseudo_header -> atm . aal = AAL_SIGNALLING ;\n else pseudo_header -> atm . aal = AAL_UNKNOWN ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_AAL1 : pseudo_header -> atm . aal = AAL_1 ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_AAL3_4 : pseudo_header -> atm . aal = AAL_3_4 ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_AAL5 : pseudo_header -> atm . aal = AAL_5 ;\n switch ( hl_type ) {\n case ATT_HL_UNKNOWN : pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_HL_LLCMX : pseudo_header -> atm . type = TRAF_LLCMX ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_HL_VCMX : pseudo_header -> atm . type = TRAF_VCMX ;\n switch ( frame4 -> atm_info . AppHLType ) {\n case AHLT_UNKNOWN : pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case AHLT_VCMX_802_3_FCS : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_3_FCS ;\n break ;\n case AHLT_VCMX_802_4_FCS : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_4_FCS ;\n break ;\n case AHLT_VCMX_802_5_FCS : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_5_FCS ;\n break ;\n case AHLT_VCMX_FDDI_FCS : pseudo_header -> atm . subtype = TRAF_ST_VCMX_FDDI_FCS ;\n break ;\n case AHLT_VCMX_802_6_FCS : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_6_FCS ;\n break ;\n case AHLT_VCMX_802_3 : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_3 ;\n break ;\n case AHLT_VCMX_802_4 : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_4 ;\n break ;\n case AHLT_VCMX_802_5 : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_5 ;\n break ;\n case AHLT_VCMX_FDDI : pseudo_header -> atm . subtype = TRAF_ST_VCMX_FDDI ;\n break ;\n case AHLT_VCMX_802_6 : pseudo_header -> atm . subtype = TRAF_ST_VCMX_802_6 ;\n break ;\n case AHLT_VCMX_FRAGMENTS : pseudo_header -> atm . subtype = TRAF_ST_VCMX_FRAGMENTS ;\n break ;\n case AHLT_VCMX_BPDU : pseudo_header -> atm . subtype = TRAF_ST_VCMX_BPDU ;\n break ;\n default : pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n }\n break ;\n case ATT_HL_LANE : pseudo_header -> atm . type = TRAF_LANE ;\n switch ( frame4 -> atm_info . AppHLType ) {\n case AHLT_UNKNOWN : pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case AHLT_LANE_LE_CTRL : pseudo_header -> atm . subtype = TRAF_ST_LANE_LE_CTRL ;\n break ;\n case AHLT_LANE_802_3 : pseudo_header -> atm . subtype = TRAF_ST_LANE_802_3 ;\n break ;\n case AHLT_LANE_802_5 : pseudo_header -> atm . subtype = TRAF_ST_LANE_802_5 ;\n break ;\n case AHLT_LANE_802_3_MC : pseudo_header -> atm . subtype = TRAF_ST_LANE_802_3_MC ;\n break ;\n case AHLT_LANE_802_5_MC : pseudo_header -> atm . subtype = TRAF_ST_LANE_802_5_MC ;\n break ;\n default : pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n }\n break ;\n case ATT_HL_ILMI : pseudo_header -> atm . type = TRAF_ILMI ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_HL_FRMR : pseudo_header -> atm . type = TRAF_FR ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_HL_SPANS : pseudo_header -> atm . type = TRAF_SPANS ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_HL_IPSILON : pseudo_header -> atm . type = TRAF_IPSILON ;\n switch ( frame4 -> atm_info . AppHLType ) {\n case AHLT_UNKNOWN : pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case AHLT_IPSILON_FT0 : pseudo_header -> atm . subtype = TRAF_ST_IPSILON_FT0 ;\n break ;\n case AHLT_IPSILON_FT1 : pseudo_header -> atm . subtype = TRAF_ST_IPSILON_FT1 ;\n break ;\n case AHLT_IPSILON_FT2 : pseudo_header -> atm . subtype = TRAF_ST_IPSILON_FT2 ;\n break ;\n default : pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n }\n break ;\n default : pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n }\n break ;\n case ATT_AAL_USER : pseudo_header -> atm . aal = AAL_USER ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_AAL_SIGNALLING : pseudo_header -> atm . aal = AAL_SIGNALLING ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n case ATT_OAMCELL : pseudo_header -> atm . aal = AAL_OAMCELL ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n default : pseudo_header -> atm . aal = AAL_UNKNOWN ;\n pseudo_header -> atm . type = TRAF_UNKNOWN ;\n pseudo_header -> atm . subtype = TRAF_ST_UNKNOWN ;\n break ;\n }\n pseudo_header -> atm . vpi = vpi ;\n pseudo_header -> atm . vci = vci ;\n pseudo_header -> atm . channel = pletoh16 ( & frame4 -> atm_info . channel ) ;\n pseudo_header -> atm . cells = pletoh16 ( & frame4 -> atm_info . cells ) ;\n pseudo_header -> atm . aal5t_u2u = pletoh16 ( & frame4 -> atm_info . Trailer . aal5t_u2u ) ;\n pseudo_header -> atm . aal5t_len = pletoh16 ( & frame4 -> atm_info . Trailer . aal5t_len ) ;\n pseudo_header -> atm . aal5t_chksum = pntoh32 ( & frame4 -> atm_info . Trailer . aal5t_chksum ) ;\n }","target":0,"code_token_length":1778,"total_token_length":2014,"max_tokens_setting":2048} +{"idx":354087,"func":"onscreen_mvcur(NCURSES_SP_DCLx\n\t int yold, int xold,\n\t int ynew, int xnew, int ovw,\n\t NCURSES_SP_OUTC myOutCh)\n\/* onscreen move from (yold, xold) to (ynew, xnew) *\/\n{\n string_desc result;\n char buffer[OPT_SIZE];\n int tactic = 0, newcost, usecost = INFINITY;\n int t5_cr_cost;\n\n#if defined(MAIN) || defined(NCURSES_TEST)\n struct timeval before, after;\n\n gettimeofday(&before, NULL);\n#endif \/* MAIN *\/\n\n#define NullResult _nc_str_null(&result, sizeof(buffer))\n#define InitResult _nc_str_init(&result, buffer, sizeof(buffer))\n\n \/* tactic #0: use direct cursor addressing *\/\n if (_nc_safe_strcpy(InitResult, TPARM_2(SP_PARM->_address_cursor, ynew, xnew))) {\n\ttactic = 0;\n\tusecost = SP_PARM->_cup_cost;\n\n#if defined(TRACE) || defined(NCURSES_TEST)\n\tif (!(_nc_optimize_enable & OPTIMIZE_MVCUR))\n\t goto nonlocal;\n#endif \/* TRACE *\/\n\n\t\/*\n\t * We may be able to tell in advance that the full optimization\n\t * will probably not be worth its overhead. Also, don't try to\n\t * use local movement if the current attribute is anything but\n\t * A_NORMAL...there are just too many ways this can screw up\n\t * (like, say, local-movement \\n getting mapped to some obscure\n\t * character because A_ALTCHARSET is on).\n\t *\/\n\tif (yold == -1 || xold == -1 || NOT_LOCAL(SP_PARM, yold, xold, ynew, xnew)) {\n#if defined(MAIN) || defined(NCURSES_TEST)\n\t if (!profiling) {\n\t\t(void) fputs(\"nonlocal\\n\", stderr);\n\t\tgoto nonlocal;\t\/* always run the optimizer if profiling *\/\n\t }\n#else\n\t goto nonlocal;\n#endif \/* MAIN *\/\n\t}\n }\n#ifndef NO_OPTIMIZE\n \/* tactic #1: use local movement *\/\n if (yold != -1 && xold != -1\n\t&& ((newcost = relative_move(NCURSES_SP_ARGx\n\t\t\t\t NullResult,\n\t\t\t\t yold, xold,\n\t\t\t\t ynew, xnew, ovw)) != INFINITY)\n\t&& newcost < usecost) {\n\ttactic = 1;\n\tusecost = newcost;\n }\n\n \/* tactic #2: use carriage-return + local movement *\/\n if (yold != -1 && carriage_return\n\t&& ((newcost = relative_move(NCURSES_SP_ARGx\n\t\t\t\t NullResult,\n\t\t\t\t yold, 0,\n\t\t\t\t ynew, xnew, ovw)) != INFINITY)\n\t&& SP_PARM->_cr_cost + newcost < usecost) {\n\ttactic = 2;\n\tusecost = SP_PARM->_cr_cost + newcost;\n }\n\n \/* tactic #3: use home-cursor + local movement *\/\n if (cursor_home\n\t&& ((newcost = relative_move(NCURSES_SP_ARGx\n\t\t\t\t NullResult,\n\t\t\t\t 0, 0,\n\t\t\t\t ynew, xnew, ovw)) != INFINITY)\n\t&& SP_PARM->_home_cost + newcost < usecost) {\n\ttactic = 3;\n\tusecost = SP_PARM->_home_cost + newcost;\n }\n\n \/* tactic #4: use home-down + local movement *\/\n if (cursor_to_ll\n\t&& ((newcost = relative_move(NCURSES_SP_ARGx\n\t\t\t\t NullResult,\n\t\t\t\t screen_lines(SP_PARM) - 1, 0,\n\t\t\t\t ynew, xnew, ovw)) != INFINITY)\n\t&& SP_PARM->_ll_cost + newcost < usecost) {\n\ttactic = 4;\n\tusecost = SP_PARM->_ll_cost + newcost;\n }\n\n \/*\n * tactic #5: use left margin for wrap to right-hand side,\n * unless strange wrap behavior indicated by xenl might hose us.\n *\/\n t5_cr_cost = (xold > 0 ? SP_PARM->_cr_cost : 0);\n if (auto_left_margin && !eat_newline_glitch\n\t&& yold > 0 && cursor_left\n\t&& ((newcost = relative_move(NCURSES_SP_ARGx\n\t\t\t\t NullResult,\n\t\t\t\t yold - 1, screen_columns(SP_PARM) - 1,\n\t\t\t\t ynew, xnew, ovw)) != INFINITY)\n\t&& t5_cr_cost + SP_PARM->_cub1_cost + newcost < usecost) {\n\ttactic = 5;\n\tusecost = t5_cr_cost + SP_PARM->_cub1_cost + newcost;\n }\n\n \/*\n * These cases are ordered by estimated relative frequency.\n *\/\n if (tactic)\n\tInitResult;\n switch (tactic) {\n case 1:\n\t(void) relative_move(NCURSES_SP_ARGx\n\t\t\t &result,\n\t\t\t yold, xold,\n\t\t\t ynew, xnew, ovw);\n\tbreak;\n case 2:\n\t(void) _nc_safe_strcpy(&result, carriage_return);\n\t(void) relative_move(NCURSES_SP_ARGx\n\t\t\t &result,\n\t\t\t yold, 0,\n\t\t\t ynew, xnew, ovw);\n\tbreak;\n case 3:\n\t(void) _nc_safe_strcpy(&result, cursor_home);\n\t(void) relative_move(NCURSES_SP_ARGx\n\t\t\t &result, 0, 0,\n\t\t\t ynew, xnew, ovw);\n\tbreak;\n case 4:\n\t(void) _nc_safe_strcpy(&result, cursor_to_ll);\n\t(void) relative_move(NCURSES_SP_ARGx\n\t\t\t &result,\n\t\t\t screen_lines(SP_PARM) - 1, 0,\n\t\t\t ynew, xnew, ovw);\n\tbreak;\n case 5:\n\tif (xold > 0)\n\t (void) _nc_safe_strcat(&result, carriage_return);\n\t(void) _nc_safe_strcat(&result, cursor_left);\n\t(void) relative_move(NCURSES_SP_ARGx\n\t\t\t &result,\n\t\t\t yold - 1, screen_columns(SP_PARM) - 1,\n\t\t\t ynew, xnew, ovw);\n\tbreak;\n }\n#endif \/* !NO_OPTIMIZE *\/\n\n nonlocal:\n#if defined(MAIN) || defined(NCURSES_TEST)\n gettimeofday(&after, NULL);\n diff = after.tv_usec - before.tv_usec\n\t+ (after.tv_sec - before.tv_sec) * 1000000;\n if (!profiling)\n\t(void) fprintf(stderr,\n\t\t \"onscreen: %d microsec, %f 28.8Kbps char-equivalents\\n\",\n\t\t (int) diff, diff \/ 288);\n#endif \/* MAIN *\/\n\n if (usecost != INFINITY) {\n\tTR(TRACE_MOVE, (\"mvcur tactic %d\", tactic));\n\tTPUTS_TRACE(\"mvcur\");\n\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\tbuffer, 1, myOutCh);\n\tSP_PARM->_cursrow = ynew;\n\tSP_PARM->_curscol = xnew;\n\treturn (OK);\n } else\n\treturn (ERR);\n}","target":1,"code_token_length":1561,"total_token_length":1797,"max_tokens_setting":2048} +{"idx":116296,"func":"static void swoole_serialize_object(seriaString *buffer, zval *obj, size_t start)\n{\n zend_string *name = Z_OBJCE_P(obj)->name;\n if (GC_IS_RECURSIVE(Z_OBJPROP_P(obj)))\n {\n zend_throw_exception_ex(NULL, 0, \"the object %s has cycle ref.\", name->val);\n return;\n }\n if (name->len > 0xffff)\n {\/\/so long?\n zend_throw_exception_ex(NULL, 0, \"the object name is too long.\");\n }\n else\n {\n SERIA_SET_ENTRY_SHORT(buffer, name->len);\n swoole_string_cpy(buffer, name->val, name->len);\n }\n\n zend_class_entry *ce = Z_OBJ_P(obj)->ce;\n if (ce && zend_hash_exists(&ce->function_table, Z_STR(swSeriaG.sleep_fname)))\n {\n zval retval;\n if (call_user_function_ex(NULL, obj, &swSeriaG.sleep_fname, &retval, 0, 0, 1, NULL) == SUCCESS)\n {\n if (EG(exception))\n {\n zval_dtor(&retval);\n return;\n }\n if (Z_TYPE(retval) == IS_ARRAY)\n {\n zend_string *prop_key;\n zval *prop_value, *sleep_value;\n const char *prop_name, *class_name;\n size_t prop_key_len;\n int got_num = 0;\n\n \/\/for the zero malloc\n zend_array tmp_arr;\n zend_array *ht = (zend_array *) & tmp_arr;\n#if PHP_VERSION_ID >= 70300\n _zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL(retval)), ZVAL_PTR_DTOR, 0);\n#else\n _zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL(retval)), ZVAL_PTR_DTOR, 0 ZEND_FILE_LINE_CC);\n#endif\n ht->nTableMask = -(ht)->nTableSize;\n ALLOCA_FLAG(use_heap);\n void *ht_addr = do_alloca(HT_SIZE(ht), use_heap);\n HT_SET_DATA_ADDR(ht, ht_addr);\n ht->u.flags |= HASH_FLAG_INITIALIZED;\n HT_HASH_RESET(ht);\n\n \/\/just clean property do not add null when does not exist\n \/\/we double for each, cause we do not malloc and release it\n\n ZEND_HASH_FOREACH_STR_KEY_VAL(Z_OBJPROP_P(obj), prop_key, prop_value)\n {\n \/\/get origin property name\n zend_unmangle_property_name_ex(prop_key, &class_name, &prop_name, &prop_key_len);\n\n ZEND_HASH_FOREACH_VAL(Z_ARRVAL(retval), sleep_value)\n {\n if (Z_TYPE_P(sleep_value) == IS_STRING &&\n Z_STRLEN_P(sleep_value) == prop_key_len &&\n memcmp(Z_STRVAL_P(sleep_value), prop_name, prop_key_len) == 0)\n {\n got_num++;\n \/\/add mangle key,unmangle in unseria\n _zend_hash_add_or_update(ht, prop_key, prop_value, HASH_UPDATE ZEND_FILE_LINE_CC);\n\n break;\n }\n\n }\n ZEND_HASH_FOREACH_END();\n\n }\n ZEND_HASH_FOREACH_END();\n\n \/\/there some member not in property\n if (zend_hash_num_elements(Z_ARRVAL(retval)) > got_num)\n {\n php_error_docref(NULL TSRMLS_CC, E_NOTICE, \"__sleep() retrun a member but does not exist in property\");\n\n }\n seria_array_type(ht, buffer, start, buffer->offset);\n swoole_serialize_arr(buffer, ht);\n ZSTR_ALLOCA_FREE(ht_addr, use_heap);\n zval_dtor(&retval);\n return;\n\n }\n else\n {\n php_error_docref(NULL TSRMLS_CC, E_NOTICE, \" __sleep should return an array only containing the \"\n \"names of instance-variables to serialize\");\n zval_dtor(&retval);\n }\n\n }\n }\n seria_array_type(Z_OBJPROP_P(obj), buffer, start, buffer->offset);\n swoole_serialize_arr(buffer, Z_OBJPROP_P(obj));\n \/\/ printf(\"hash2 %u\\n\",ce->properties_info.arData[0].key->h);\n}","target":0,"code_token_length":899,"total_token_length":1135,"max_tokens_setting":2048} +{"idx":145753,"func":"MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)\n{\n#define FlopImageTag \"Flop\/Image\"\n\n CacheView\n *flop_view,\n *image_view;\n\n Image\n *flop_image;\n\n MagickBooleanType\n status;\n\n MagickOffsetType\n progress;\n\n RectangleInfo\n page;\n\n ssize_t\n y;\n\n assert(image != (const Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n flop_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);\n if (flop_image == (Image *) NULL)\n return((Image *) NULL);\n \/*\n Flop each row.\n *\/\n status=MagickTrue;\n progress=0;\n page=image->page;\n image_view=AcquireVirtualCacheView(image,exception);\n flop_view=AcquireAuthenticCacheView(flop_image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static,4) shared(status) \\\n magick_threads(image,flop_image,1,1)\n#endif\n for (y=0; y < (ssize_t) flop_image->rows; y++)\n {\n register const Quantum\n *restrict p;\n\n register ssize_t\n x;\n\n register Quantum\n *restrict q;\n\n if (status == MagickFalse)\n continue;\n p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);\n q=QueueCacheViewAuthenticPixels(flop_view,0,y,flop_image->columns,1,\n exception);\n if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))\n {\n status=MagickFalse;\n continue;\n }\n q+=GetPixelChannels(flop_image)*flop_image->columns;\n for (x=0; x < (ssize_t) flop_image->columns; x++)\n {\n register ssize_t\n i;\n\n q-=GetPixelChannels(flop_image);\n if (GetPixelReadMask(image,p) == 0)\n {\n p+=GetPixelChannels(image);\n continue;\n }\n for (i=0; i < (ssize_t) GetPixelChannels(image); i++)\n {\n PixelChannel channel=GetPixelChannelChannel(image,i);\n PixelTrait traits=GetPixelChannelTraits(image,channel);\n PixelTrait flop_traits=GetPixelChannelTraits(flop_image,channel);\n if ((traits == UndefinedPixelTrait) ||\n (flop_traits == UndefinedPixelTrait))\n continue;\n SetPixelChannel(flop_image,channel,p[i],q);\n }\n p+=GetPixelChannels(image);\n }\n if (SyncCacheViewAuthenticPixels(flop_view,exception) == MagickFalse)\n status=MagickFalse;\n if (image->progress_monitor != (MagickProgressMonitor) NULL)\n {\n MagickBooleanType\n proceed;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp critical (MagickCore_FlopImage)\n#endif\n proceed=SetImageProgress(image,FlopImageTag,progress++,image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n flop_view=DestroyCacheView(flop_view);\n image_view=DestroyCacheView(image_view);\n flop_image->type=image->type;\n if (page.width != 0)\n page.x=(ssize_t) (page.width-flop_image->columns-page.x);\n flop_image->page=page;\n if (status == MagickFalse)\n flop_image=DestroyImage(flop_image);\n return(flop_image);\n}","target":0,"code_token_length":838,"total_token_length":1074,"max_tokens_setting":2048} +{"idx":16673,"func":"gcry_error_t gcry_mpi_scan ( struct gcry_mpi * * ret_mpi , enum gcry_mpi_format format , const void * buffer_arg , size_t buflen , size_t * nscanned ) {\n const unsigned char * buffer = ( const unsigned char * ) buffer_arg ;\n struct gcry_mpi * a = NULL ;\n unsigned int len ;\n int secure = ( buffer && gcry_is_secure ( buffer ) ) ;\n if ( format == GCRYMPI_FMT_SSH ) len = 0 ;\n else len = buflen ;\n if ( format == GCRYMPI_FMT_STD ) {\n const unsigned char * s = buffer ;\n a = secure ? mpi_alloc_secure ( ( len + BYTES_PER_MPI_LIMB - 1 ) \/ BYTES_PER_MPI_LIMB ) : mpi_alloc ( ( len + BYTES_PER_MPI_LIMB - 1 ) \/ BYTES_PER_MPI_LIMB ) ;\n if ( len ) {\n a -> sign = ! ! ( * s & 0x80 ) ;\n if ( a -> sign ) {\n mpi_free ( a ) ;\n return gcry_error ( GPG_ERR_INTERNAL ) ;\n }\n else _gcry_mpi_set_buffer ( a , s , len , 0 ) ;\n }\n if ( ret_mpi ) {\n mpi_normalize ( a ) ;\n * ret_mpi = a ;\n }\n else mpi_free ( a ) ;\n return 0 ;\n }\n else if ( format == GCRYMPI_FMT_USG ) {\n a = secure ? mpi_alloc_secure ( ( len + BYTES_PER_MPI_LIMB - 1 ) \/ BYTES_PER_MPI_LIMB ) : mpi_alloc ( ( len + BYTES_PER_MPI_LIMB - 1 ) \/ BYTES_PER_MPI_LIMB ) ;\n if ( len ) _gcry_mpi_set_buffer ( a , buffer , len , 0 ) ;\n if ( ret_mpi ) {\n mpi_normalize ( a ) ;\n * ret_mpi = a ;\n }\n else mpi_free ( a ) ;\n return 0 ;\n }\n else if ( format == GCRYMPI_FMT_PGP ) {\n a = mpi_read_from_buffer ( buffer , & len , secure ) ;\n if ( nscanned ) * nscanned = len ;\n if ( ret_mpi && a ) {\n mpi_normalize ( a ) ;\n * ret_mpi = a ;\n }\n else if ( a ) {\n mpi_free ( a ) ;\n a = NULL ;\n }\n return a ? 0 : gcry_error ( GPG_ERR_INV_OBJ ) ;\n }\n else if ( format == GCRYMPI_FMT_SSH ) {\n const unsigned char * s = buffer ;\n size_t n ;\n if ( len && len < 4 ) return gcry_error ( GPG_ERR_TOO_SHORT ) ;\n n = ( s [ 0 ] << 24 | s [ 1 ] << 16 | s [ 2 ] << 8 | s [ 3 ] ) ;\n s += 4 ;\n if ( len ) len -= 4 ;\n if ( len && n > len ) return gcry_error ( GPG_ERR_TOO_LARGE ) ;\n a = secure ? mpi_alloc_secure ( ( n + BYTES_PER_MPI_LIMB - 1 ) \/ BYTES_PER_MPI_LIMB ) : mpi_alloc ( ( n + BYTES_PER_MPI_LIMB - 1 ) \/ BYTES_PER_MPI_LIMB ) ;\n if ( n ) {\n a -> sign = ! ! ( * s & 0x80 ) ;\n if ( a -> sign ) {\n mpi_free ( a ) ;\n return gcry_error ( GPG_ERR_INTERNAL ) ;\n }\n else _gcry_mpi_set_buffer ( a , s , n , 0 ) ;\n }\n if ( nscanned ) * nscanned = n + 4 ;\n if ( ret_mpi ) {\n mpi_normalize ( a ) ;\n * ret_mpi = a ;\n }\n else mpi_free ( a ) ;\n return 0 ;\n }\n else if ( format == GCRYMPI_FMT_HEX ) {\n if ( buflen ) return gcry_error ( GPG_ERR_INV_ARG ) ;\n a = secure ? mpi_alloc_secure ( 0 ) : mpi_alloc ( 0 ) ;\n if ( mpi_fromstr ( a , ( const char * ) buffer ) ) {\n mpi_free ( a ) ;\n return gcry_error ( GPG_ERR_INV_OBJ ) ;\n }\n if ( ret_mpi ) {\n mpi_normalize ( a ) ;\n * ret_mpi = a ;\n }\n else mpi_free ( a ) ;\n return 0 ;\n }\n else return gcry_error ( GPG_ERR_INV_ARG ) ;\n }","target":0,"code_token_length":922,"total_token_length":1158,"max_tokens_setting":2048} +{"idx":431533,"func":" bool run(OperationContext* opCtx,\n const string& dbname,\n const BSONObj& cmdObj,\n BSONObjBuilder& result) {\n RoleName roleName;\n Status status = auth::parseDropRoleCommand(cmdObj, dbname, &roleName);\n if (!status.isOK()) {\n return appendCommandStatus(result, status);\n }\n\n ServiceContext* serviceContext = opCtx->getClient()->getServiceContext();\n stdx::lock_guard lk(getAuthzDataMutex(serviceContext));\n\n AuthorizationManager* authzManager = AuthorizationManager::get(serviceContext);\n status = requireAuthSchemaVersion26Final(opCtx, authzManager);\n if (!status.isOK()) {\n return appendCommandStatus(result, status);\n }\n\n if (RoleGraph::isBuiltinRole(roleName)) {\n return appendCommandStatus(\n result,\n Status(ErrorCodes::InvalidRoleModification,\n str::stream() << roleName.getFullName()\n << \" is a built-in role and cannot be modified.\"));\n }\n\n BSONObj roleDoc;\n status = authzManager->getRoleDescription(opCtx, roleName, &roleDoc);\n if (!status.isOK()) {\n return appendCommandStatus(result, status);\n }\n\n \/\/ Remove this role from all users\n long long nMatched;\n status = updateAuthzDocuments(\n opCtx,\n AuthorizationManager::usersCollectionNamespace,\n BSON(\"roles\" << BSON(\"$elemMatch\" << BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME\n << roleName.getRole()\n << AuthorizationManager::ROLE_DB_FIELD_NAME\n << roleName.getDB()))),\n BSON(\"$pull\" << BSON(\"roles\" << BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME\n << roleName.getRole()\n << AuthorizationManager::ROLE_DB_FIELD_NAME\n << roleName.getDB()))),\n false,\n true,\n &nMatched);\n \/\/ Must invalidate even on bad status - what if the write succeeded but the GLE failed?\n authzManager->invalidateUserCache();\n if (!status.isOK()) {\n ErrorCodes::Error code = status.code() == ErrorCodes::UnknownError\n ? ErrorCodes::UserModificationFailed\n : status.code();\n return appendCommandStatus(result,\n Status(code,\n str::stream() << \"Failed to remove role \"\n << roleName.getFullName()\n << \" from all users: \"\n << status.reason()));\n }\n\n \/\/ Remove this role from all other roles\n status = updateAuthzDocuments(\n opCtx,\n AuthorizationManager::rolesCollectionNamespace,\n BSON(\"roles\" << BSON(\"$elemMatch\" << BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME\n << roleName.getRole()\n << AuthorizationManager::ROLE_DB_FIELD_NAME\n << roleName.getDB()))),\n BSON(\"$pull\" << BSON(\"roles\" << BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME\n << roleName.getRole()\n << AuthorizationManager::ROLE_DB_FIELD_NAME\n << roleName.getDB()))),\n false,\n true,\n &nMatched);\n \/\/ Must invalidate even on bad status - what if the write succeeded but the GLE failed?\n authzManager->invalidateUserCache();\n if (!status.isOK()) {\n ErrorCodes::Error code = status.code() == ErrorCodes::UnknownError\n ? ErrorCodes::RoleModificationFailed\n : status.code();\n return appendCommandStatus(\n result,\n Status(code,\n str::stream() << \"Removed role \" << roleName.getFullName()\n << \" from all users but failed to remove from all roles: \"\n << status.reason()));\n }\n\n audit::logDropRole(Client::getCurrent(), roleName);\n \/\/ Finally, remove the actual role document\n status = removeRoleDocuments(opCtx,\n BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME\n << roleName.getRole()\n << AuthorizationManager::ROLE_DB_FIELD_NAME\n << roleName.getDB()),\n &nMatched);\n \/\/ Must invalidate even on bad status - what if the write succeeded but the GLE failed?\n authzManager->invalidateUserCache();\n if (!status.isOK()) {\n return appendCommandStatus(\n result,\n Status(status.code(),\n str::stream() << \"Removed role \" << roleName.getFullName()\n << \" from all users and roles but failed to actually delete\"\n \" the role itself: \"\n << status.reason()));\n }\n\n dassert(nMatched == 0 || nMatched == 1);\n if (nMatched == 0) {\n return appendCommandStatus(\n result,\n Status(ErrorCodes::RoleNotFound,\n str::stream() << \"Role '\" << roleName.getFullName() << \"' not found\"));\n }\n\n return true;\n }","target":0,"code_token_length":1000,"total_token_length":1236,"max_tokens_setting":2048} +{"idx":481923,"func":"void __init pt_regs_check(void)\n{\n\tBUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=\n\t\t offsetof(struct user_pt_regs, gpr));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, nip) !=\n\t\t offsetof(struct user_pt_regs, nip));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, msr) !=\n\t\t offsetof(struct user_pt_regs, msr));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=\n\t\t offsetof(struct user_pt_regs, orig_gpr3));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, ctr) !=\n\t\t offsetof(struct user_pt_regs, ctr));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, link) !=\n\t\t offsetof(struct user_pt_regs, link));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, xer) !=\n\t\t offsetof(struct user_pt_regs, xer));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, ccr) !=\n\t\t offsetof(struct user_pt_regs, ccr));\n#ifdef __powerpc64__\n\tBUILD_BUG_ON(offsetof(struct pt_regs, softe) !=\n\t\t offsetof(struct user_pt_regs, softe));\n#else\n\tBUILD_BUG_ON(offsetof(struct pt_regs, mq) !=\n\t\t offsetof(struct user_pt_regs, mq));\n#endif\n\tBUILD_BUG_ON(offsetof(struct pt_regs, trap) !=\n\t\t offsetof(struct user_pt_regs, trap));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, dar) !=\n\t\t offsetof(struct user_pt_regs, dar));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, dear) !=\n\t\t offsetof(struct user_pt_regs, dar));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, dsisr) !=\n\t\t offsetof(struct user_pt_regs, dsisr));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, esr) !=\n\t\t offsetof(struct user_pt_regs, dsisr));\n\tBUILD_BUG_ON(offsetof(struct pt_regs, result) !=\n\t\t offsetof(struct user_pt_regs, result));\n\n\tBUILD_BUG_ON(sizeof(struct user_pt_regs) > sizeof(struct pt_regs));\n\n\t\/\/ Now check that the pt_regs offsets match the uapi #defines\n\t#define CHECK_REG(_pt, _reg) \\\n\t\tBUILD_BUG_ON(_pt != (offsetof(struct user_pt_regs, _reg) \/ \\\n\t\t\t\t sizeof(unsigned long)));\n\n\tCHECK_REG(PT_R0, gpr[0]);\n\tCHECK_REG(PT_R1, gpr[1]);\n\tCHECK_REG(PT_R2, gpr[2]);\n\tCHECK_REG(PT_R3, gpr[3]);\n\tCHECK_REG(PT_R4, gpr[4]);\n\tCHECK_REG(PT_R5, gpr[5]);\n\tCHECK_REG(PT_R6, gpr[6]);\n\tCHECK_REG(PT_R7, gpr[7]);\n\tCHECK_REG(PT_R8, gpr[8]);\n\tCHECK_REG(PT_R9, gpr[9]);\n\tCHECK_REG(PT_R10, gpr[10]);\n\tCHECK_REG(PT_R11, gpr[11]);\n\tCHECK_REG(PT_R12, gpr[12]);\n\tCHECK_REG(PT_R13, gpr[13]);\n\tCHECK_REG(PT_R14, gpr[14]);\n\tCHECK_REG(PT_R15, gpr[15]);\n\tCHECK_REG(PT_R16, gpr[16]);\n\tCHECK_REG(PT_R17, gpr[17]);\n\tCHECK_REG(PT_R18, gpr[18]);\n\tCHECK_REG(PT_R19, gpr[19]);\n\tCHECK_REG(PT_R20, gpr[20]);\n\tCHECK_REG(PT_R21, gpr[21]);\n\tCHECK_REG(PT_R22, gpr[22]);\n\tCHECK_REG(PT_R23, gpr[23]);\n\tCHECK_REG(PT_R24, gpr[24]);\n\tCHECK_REG(PT_R25, gpr[25]);\n\tCHECK_REG(PT_R26, gpr[26]);\n\tCHECK_REG(PT_R27, gpr[27]);\n\tCHECK_REG(PT_R28, gpr[28]);\n\tCHECK_REG(PT_R29, gpr[29]);\n\tCHECK_REG(PT_R30, gpr[30]);\n\tCHECK_REG(PT_R31, gpr[31]);\n\tCHECK_REG(PT_NIP, nip);\n\tCHECK_REG(PT_MSR, msr);\n\tCHECK_REG(PT_ORIG_R3, orig_gpr3);\n\tCHECK_REG(PT_CTR, ctr);\n\tCHECK_REG(PT_LNK, link);\n\tCHECK_REG(PT_XER, xer);\n\tCHECK_REG(PT_CCR, ccr);\n#ifdef CONFIG_PPC64\n\tCHECK_REG(PT_SOFTE, softe);\n#else\n\tCHECK_REG(PT_MQ, mq);\n#endif\n\tCHECK_REG(PT_TRAP, trap);\n\tCHECK_REG(PT_DAR, dar);\n\tCHECK_REG(PT_DSISR, dsisr);\n\tCHECK_REG(PT_RESULT, result);\n\t#undef CHECK_REG\n\n\tBUILD_BUG_ON(PT_REGS_COUNT != sizeof(struct user_pt_regs) \/ sizeof(unsigned long));\n\n\t\/*\n\t * PT_DSCR isn't a real reg, but it's important that it doesn't overlap the\n\t * real registers.\n\t *\/\n\tBUILD_BUG_ON(PT_DSCR < sizeof(struct user_pt_regs) \/ sizeof(unsigned long));\n\n\t\/\/ ptrace_get\/put_fpr() rely on PPC32 and VSX being incompatible\n\tBUILD_BUG_ON(IS_ENABLED(CONFIG_PPC32) && IS_ENABLED(CONFIG_VSX));\n}","target":0,"code_token_length":1178,"total_token_length":1414,"max_tokens_setting":2048} +{"idx":76112,"func":"add_llist_tags(\n char_u\t*tag,\n int\t\tnum_matches,\n char_u\t**matches)\n{\n list_T\t*list;\n char_u\ttag_name[128 + 1];\n char_u\t*fname;\n char_u\t*cmd;\n int\t\ti;\n char_u\t*p;\n tagptrs_T\ttagp;\n\n fname = alloc(MAXPATHL + 1);\n cmd = alloc(CMDBUFFSIZE + 1);\n list = list_alloc();\n if (list == NULL || fname == NULL || cmd == NULL)\n {\n\tvim_free(cmd);\n\tvim_free(fname);\n\tif (list != NULL)\n\t list_free(list);\n\treturn FAIL;\n }\n\n for (i = 0; i < num_matches; ++i)\n {\n\tint\t len, cmd_len;\n\tlong lnum;\n\tdict_T *dict;\n\n\tparse_match(matches[i], &tagp);\n\n\t\/\/ Save the tag name\n\tlen = (int)(tagp.tagname_end - tagp.tagname);\n\tif (len > 128)\n\t len = 128;\n\tvim_strncpy(tag_name, tagp.tagname, len);\n\ttag_name[len] = NUL;\n\n\t\/\/ Save the tag file name\n\tp = tag_full_fname(&tagp);\n\tif (p == NULL)\n\t continue;\n\tvim_strncpy(fname, p, MAXPATHL);\n\tvim_free(p);\n\n\t\/\/ Get the line number or the search pattern used to locate\n\t\/\/ the tag.\n\tlnum = 0;\n\tif (isdigit(*tagp.command))\n\t \/\/ Line number is used to locate the tag\n\t lnum = atol((char *)tagp.command);\n\telse\n\t{\n\t char_u *cmd_start, *cmd_end;\n\n\t \/\/ Search pattern is used to locate the tag\n\n\t \/\/ Locate the end of the command\n\t cmd_start = tagp.command;\n\t cmd_end = tagp.command_end;\n\t if (cmd_end == NULL)\n\t {\n\t\tfor (p = tagp.command;\n\t\t *p && *p != '\\r' && *p != '\\n'; ++p)\n\t\t ;\n\t\tcmd_end = p;\n\t }\n\n\t \/\/ Now, cmd_end points to the character after the\n\t \/\/ command. Adjust it to point to the last\n\t \/\/ character of the command.\n\t cmd_end--;\n\n\t \/\/ Skip the '\/' and '?' characters at the\n\t \/\/ beginning and end of the search pattern.\n\t if (*cmd_start == '\/' || *cmd_start == '?')\n\t\tcmd_start++;\n\n\t if (*cmd_end == '\/' || *cmd_end == '?')\n\t\tcmd_end--;\n\n\t len = 0;\n\t cmd[0] = NUL;\n\n\t \/\/ If \"^\" is present in the tag search pattern, then\n\t \/\/ copy it first.\n\t if (*cmd_start == '^')\n\t {\n\t\tSTRCPY(cmd, \"^\");\n\t\tcmd_start++;\n\t\tlen++;\n\t }\n\n\t \/\/ Precede the tag pattern with \\V to make it very\n\t \/\/ nomagic.\n\t STRCAT(cmd, \"\\\\V\");\n\t len += 2;\n\n\t cmd_len = (int)(cmd_end - cmd_start + 1);\n\t if (cmd_len > (CMDBUFFSIZE - 5))\n\t\tcmd_len = CMDBUFFSIZE - 5;\n\t STRNCAT(cmd, cmd_start, cmd_len);\n\t len += cmd_len;\n\n\t if (cmd[len - 1] == '$')\n\t {\n\t\t\/\/ Replace '$' at the end of the search pattern\n\t\t\/\/ with '\\$'\n\t\tcmd[len - 1] = '\\\\';\n\t\tcmd[len] = '$';\n\t\tlen++;\n\t }\n\n\t cmd[len] = NUL;\n\t}\n\n\tif ((dict = dict_alloc()) == NULL)\n\t continue;\n\tif (list_append_dict(list, dict) == FAIL)\n\t{\n\t vim_free(dict);\n\t continue;\n\t}\n\n\tdict_add_string(dict, \"text\", tag_name);\n\tdict_add_string(dict, \"filename\", fname);\n\tdict_add_number(dict, \"lnum\", lnum);\n\tif (lnum == 0)\n\t dict_add_string(dict, \"pattern\", cmd);\n }\n\n vim_snprintf((char *)IObuff, IOSIZE, \"ltag %s\", tag);\n set_errorlist(curwin, list, ' ', IObuff, NULL);\n\n list_free(list);\n vim_free(fname);\n vim_free(cmd);\n\n return OK;\n}","target":0,"code_token_length":931,"total_token_length":1167,"max_tokens_setting":2048} +{"idx":346682,"func":"extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang,\n int *ressize, bool is_icon)\n{\n\tWin32CursorIconDir *icondir;\n\tWin32CursorIconFileDir *fileicondir;\n\tchar *memory;\n\tint c, size, offset, skipped;\n\n\t\/* get resource data and size *\/\n\ticondir = (Win32CursorIconDir *) get_resource_entry(fi, wr, &size);\n\tif (icondir == NULL) {\n\t\t\/* get_resource_entry will print error *\/\n\t\treturn NULL;\n\t}\n\n\t\/* calculate total size of output file *\/\n\tRETURN_IF_BAD_POINTER(NULL, icondir->count);\n\tskipped = 0;\n\tfor (c = 0 ; c < icondir->count ; c++) {\n\t\tint level;\n\t \tint iconsize;\n\t\tchar name[14];\n\t\tWinResource *fwr;\n\n\t\tRETURN_IF_BAD_POINTER(NULL, icondir->entries[c]);\n\t\t\/*printf(\"%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d\\n\", c,\n\t\t\ticondir->entries[c].bytes_in_res,\n\t\t\t(is_icon ? icondir->entries[c].res_info.icon.width : icondir->entries[c].res_info.cursor.width),\n\t\t\t(is_icon ? icondir->entries[c].res_info.icon.height : icondir->entries[c].res_info.cursor.height),\n\t\t\ticondir->entries[c].plane_count,\n\t\t\ticondir->entries[c].bit_count);*\/\n\n\t\t\/* find the corresponding icon resource *\/\n\t\tsnprintf(name, sizeof(name)\/sizeof(char), \"-%d\", icondir->entries[c].res_id);\n\t\tfwr = find_resource(fi, (is_icon ? \"-3\" : \"-1\"), name, lang, &level);\n\t\tif (fwr == NULL) {\n\t\t\twarn(_(\"%s: could not find `%s' in `%s' resource.\"),\n\t\t\t \tfi->name, &name[1], (is_icon ? \"group_icon\" : \"group_cursor\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (get_resource_entry(fi, fwr, &iconsize) != NULL) {\n\t\t if (iconsize == 0) {\n\t\t\twarn(_(\"%s: icon resource `%s' is empty, skipping\"), fi->name, name);\n\t\t\tskipped++;\n\t\t\tcontinue;\n\t\t }\n\t\t if (iconsize != icondir->entries[c].bytes_in_res) {\n\t\t\twarn(_(\"%s: mismatch of size in icon resource `%s' and group (%d vs %d)\"), fi->name, name, iconsize, icondir->entries[c].bytes_in_res);\n\t\t }\n\t\t size += iconsize < icondir->entries[c].bytes_in_res ? icondir->entries[c].bytes_in_res : iconsize;\n\n\t\t \/* cursor resources have two additional WORDs that contain\n\t\t * hotspot info *\/\n\t\t if (!is_icon)\n\t\t\tsize -= sizeof(uint16_t)*2;\n\t\t}\n\t}\n\toffset = sizeof(Win32CursorIconFileDir) + (icondir->count-skipped) * sizeof(Win32CursorIconFileDirEntry);\n\tsize += offset;\n\t*ressize = size;\n\n\t\/* allocate that much memory *\/\n\tmemory = xmalloc(size);\n\tfileicondir = (Win32CursorIconFileDir *) memory;\n\n\t\/* transfer Win32CursorIconDir structure members *\/\n\tfileicondir->reserved = icondir->reserved;\n\tfileicondir->type = icondir->type;\n\tfileicondir->count = icondir->count - skipped;\n\n\t\/* transfer each cursor\/icon: Win32CursorIconDirEntry and data *\/\n\tskipped = 0;\n\tfor (c = 0 ; c < icondir->count ; c++) {\n\t\tint level;\n\t\tchar name[14];\n\t\tWinResource *fwr;\n\t\tchar *data;\n\t\n\t\t\/* find the corresponding icon resource *\/\n\t\tsnprintf(name, sizeof(name)\/sizeof(char), \"-%d\", icondir->entries[c].res_id);\n\t\tfwr = find_resource(fi, (is_icon ? \"-3\" : \"-1\"), name, lang, &level);\n\t\tif (fwr == NULL) {\n\t\t\twarn(_(\"%s: could not find `%s' in `%s' resource.\"),\n\t\t\t \tfi->name, &name[1], (is_icon ? \"group_icon\" : \"group_cursor\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\t\/* get data and size of that resource *\/\n\t\tdata = get_resource_entry(fi, fwr, &size);\n\t\tif (data == NULL) {\n\t\t\t\/* get_resource_entry has printed error *\/\n\t\t\treturn NULL;\n\t\t}\n \t \tif (size == 0) {\n\t\t skipped++;\n\t\t continue;\n\t\t}\n\n\t\t\/* copy ICONDIRENTRY (not including last dwImageOffset) *\/\n\t\tmemcpy(&fileicondir->entries[c-skipped], &icondir->entries[c],\n\t\t\tsizeof(Win32CursorIconFileDirEntry)-sizeof(uint32_t));\n\n\t\t\/* special treatment for cursors *\/\n\t\tif (!is_icon) {\n\t\t\tfileicondir->entries[c-skipped].width = icondir->entries[c].res_info.cursor.width;\n\t\t\tfileicondir->entries[c-skipped].height = icondir->entries[c].res_info.cursor.height \/ 2;\n\t\t\tfileicondir->entries[c-skipped].color_count = 0;\n\t\t\tfileicondir->entries[c-skipped].reserved = 0;\n\t\t}\n\n\t\t\/* set image offset and increase it *\/\n\t\tfileicondir->entries[c-skipped].dib_offset = offset;\n\n\t\t\/* transfer resource into file memory *\/\n\t\tif (size > icondir->entries[c].bytes_in_res)\n\t\t\tsize = icondir->entries[c].bytes_in_res;\n\t\tif (is_icon) {\n\t\t\tmemcpy(&memory[offset], data, size);\n\t\t} else {\n\t\t\tfileicondir->entries[c-skipped].hotspot_x = ((uint16_t *) data)[0];\n\t\t\tfileicondir->entries[c-skipped].hotspot_y = ((uint16_t *) data)[1];\n\t\t\tmemcpy(&memory[offset], data+sizeof(uint16_t)*2,\n\t\t\t\t size-sizeof(uint16_t)*2);\n\t\t\toffset -= sizeof(uint16_t)*2;\n\t\t}\n\n\t\t\/* increase the offset pointer *\/\n\t\toffset += icondir->entries[c].bytes_in_res;\n\t}\n\n\treturn (void *) memory;\n}","target":1,"code_token_length":1355,"total_token_length":1591,"max_tokens_setting":2048} +{"idx":73980,"func":"tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb,\n\t\t\tu32 prior_snd_una, struct tcp_sacktag_state *state)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tconst unsigned char *ptr = (skb_transport_header(ack_skb) +\n\t\t\t\t TCP_SKB_CB(ack_skb)->sacked);\n\tstruct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2);\n\tstruct tcp_sack_block sp[TCP_NUM_SACKS];\n\tstruct tcp_sack_block *cache;\n\tstruct sk_buff *skb;\n\tint num_sacks = min(TCP_NUM_SACKS, (ptr[1] - TCPOLEN_SACK_BASE) >> 3);\n\tint used_sacks;\n\tbool found_dup_sack = false;\n\tint i, j;\n\tint first_sack_index;\n\n\tstate->flag = 0;\n\tstate->reord = tp->packets_out;\n\n\tif (!tp->sacked_out) {\n\t\tif (WARN_ON(tp->fackets_out))\n\t\t\ttp->fackets_out = 0;\n\t\ttcp_highest_sack_reset(sk);\n\t}\n\n\tfound_dup_sack = tcp_check_dsack(sk, ack_skb, sp_wire,\n\t\t\t\t\t num_sacks, prior_snd_una);\n\tif (found_dup_sack)\n\t\tstate->flag |= FLAG_DSACKING_ACK;\n\n\t\/* Eliminate too old ACKs, but take into\n\t * account more or less fresh ones, they can\n\t * contain valid SACK info.\n\t *\/\n\tif (before(TCP_SKB_CB(ack_skb)->ack_seq, prior_snd_una - tp->max_window))\n\t\treturn 0;\n\n\tif (!tp->packets_out)\n\t\tgoto out;\n\n\tused_sacks = 0;\n\tfirst_sack_index = 0;\n\tfor (i = 0; i < num_sacks; i++) {\n\t\tbool dup_sack = !i && found_dup_sack;\n\n\t\tsp[used_sacks].start_seq = get_unaligned_be32(&sp_wire[i].start_seq);\n\t\tsp[used_sacks].end_seq = get_unaligned_be32(&sp_wire[i].end_seq);\n\n\t\tif (!tcp_is_sackblock_valid(tp, dup_sack,\n\t\t\t\t\t sp[used_sacks].start_seq,\n\t\t\t\t\t sp[used_sacks].end_seq)) {\n\t\t\tint mib_idx;\n\n\t\t\tif (dup_sack) {\n\t\t\t\tif (!tp->undo_marker)\n\t\t\t\t\tmib_idx = LINUX_MIB_TCPDSACKIGNOREDNOUNDO;\n\t\t\t\telse\n\t\t\t\t\tmib_idx = LINUX_MIB_TCPDSACKIGNOREDOLD;\n\t\t\t} else {\n\t\t\t\t\/* Don't count olds caused by ACK reordering *\/\n\t\t\t\tif ((TCP_SKB_CB(ack_skb)->ack_seq != tp->snd_una) &&\n\t\t\t\t !after(sp[used_sacks].end_seq, tp->snd_una))\n\t\t\t\t\tcontinue;\n\t\t\t\tmib_idx = LINUX_MIB_TCPSACKDISCARD;\n\t\t\t}\n\n\t\t\tNET_INC_STATS(sock_net(sk), mib_idx);\n\t\t\tif (i == 0)\n\t\t\t\tfirst_sack_index = -1;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Ignore very old stuff early *\/\n\t\tif (!after(sp[used_sacks].end_seq, prior_snd_una))\n\t\t\tcontinue;\n\n\t\tused_sacks++;\n\t}\n\n\t\/* order SACK blocks to allow in order walk of the retrans queue *\/\n\tfor (i = used_sacks - 1; i > 0; i--) {\n\t\tfor (j = 0; j < i; j++) {\n\t\t\tif (after(sp[j].start_seq, sp[j + 1].start_seq)) {\n\t\t\t\tswap(sp[j], sp[j + 1]);\n\n\t\t\t\t\/* Track where the first SACK block goes to *\/\n\t\t\t\tif (j == first_sack_index)\n\t\t\t\t\tfirst_sack_index = j + 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tskb = tcp_write_queue_head(sk);\n\tstate->fack_count = 0;\n\ti = 0;\n\n\tif (!tp->sacked_out) {\n\t\t\/* It's already past, so skip checking against it *\/\n\t\tcache = tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache);\n\t} else {\n\t\tcache = tp->recv_sack_cache;\n\t\t\/* Skip empty blocks in at head of the cache *\/\n\t\twhile (tcp_sack_cache_ok(tp, cache) && !cache->start_seq &&\n\t\t !cache->end_seq)\n\t\t\tcache++;\n\t}\n\n\twhile (i < used_sacks) {\n\t\tu32 start_seq = sp[i].start_seq;\n\t\tu32 end_seq = sp[i].end_seq;\n\t\tbool dup_sack = (found_dup_sack && (i == first_sack_index));\n\t\tstruct tcp_sack_block *next_dup = NULL;\n\n\t\tif (found_dup_sack && ((i + 1) == first_sack_index))\n\t\t\tnext_dup = &sp[i + 1];\n\n\t\t\/* Skip too early cached blocks *\/\n\t\twhile (tcp_sack_cache_ok(tp, cache) &&\n\t\t !before(start_seq, cache->end_seq))\n\t\t\tcache++;\n\n\t\t\/* Can skip some work by looking recv_sack_cache? *\/\n\t\tif (tcp_sack_cache_ok(tp, cache) && !dup_sack &&\n\t\t after(end_seq, cache->start_seq)) {\n\n\t\t\t\/* Head todo? *\/\n\t\t\tif (before(start_seq, cache->start_seq)) {\n\t\t\t\tskb = tcp_sacktag_skip(skb, sk, state,\n\t\t\t\t\t\t start_seq);\n\t\t\t\tskb = tcp_sacktag_walk(skb, sk, next_dup,\n\t\t\t\t\t\t state,\n\t\t\t\t\t\t start_seq,\n\t\t\t\t\t\t cache->start_seq,\n\t\t\t\t\t\t dup_sack);\n\t\t\t}\n\n\t\t\t\/* Rest of the block already fully processed? *\/\n\t\t\tif (!after(end_seq, cache->end_seq))\n\t\t\t\tgoto advance_sp;\n\n\t\t\tskb = tcp_maybe_skipping_dsack(skb, sk, next_dup,\n\t\t\t\t\t\t state,\n\t\t\t\t\t\t cache->end_seq);\n\n\t\t\t\/* ...tail remains todo... *\/\n\t\t\tif (tcp_highest_sack_seq(tp) == cache->end_seq) {\n\t\t\t\t\/* ...but better entrypoint exists! *\/\n\t\t\t\tskb = tcp_highest_sack(sk);\n\t\t\t\tif (!skb)\n\t\t\t\t\tbreak;\n\t\t\t\tstate->fack_count = tp->fackets_out;\n\t\t\t\tcache++;\n\t\t\t\tgoto walk;\n\t\t\t}\n\n\t\t\tskb = tcp_sacktag_skip(skb, sk, state, cache->end_seq);\n\t\t\t\/* Check overlap against next cached too (past this one already) *\/\n\t\t\tcache++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!before(start_seq, tcp_highest_sack_seq(tp))) {\n\t\t\tskb = tcp_highest_sack(sk);\n\t\t\tif (!skb)\n\t\t\t\tbreak;\n\t\t\tstate->fack_count = tp->fackets_out;\n\t\t}\n\t\tskb = tcp_sacktag_skip(skb, sk, state, start_seq);\n\nwalk:\n\t\tskb = tcp_sacktag_walk(skb, sk, next_dup, state,\n\t\t\t\t start_seq, end_seq, dup_sack);\n\nadvance_sp:\n\t\ti++;\n\t}\n\n\t\/* Clear the head of the cache sack blocks so we can skip it next time *\/\n\tfor (i = 0; i < ARRAY_SIZE(tp->recv_sack_cache) - used_sacks; i++) {\n\t\ttp->recv_sack_cache[i].start_seq = 0;\n\t\ttp->recv_sack_cache[i].end_seq = 0;\n\t}\n\tfor (j = 0; j < used_sacks; j++)\n\t\ttp->recv_sack_cache[i++] = sp[j];\n\n\tif ((state->reord < tp->fackets_out) &&\n\t ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker))\n\t\ttcp_update_reordering(sk, tp->fackets_out - state->reord, 0);\n\n\ttcp_verify_left_out(tp);\nout:\n\n#if FASTRETRANS_DEBUG > 0\n\tWARN_ON((int)tp->sacked_out < 0);\n\tWARN_ON((int)tp->lost_out < 0);\n\tWARN_ON((int)tp->retrans_out < 0);\n\tWARN_ON((int)tcp_packets_in_flight(tp) < 0);\n#endif\n\treturn state->flag;\n}","target":0,"code_token_length":1743,"total_token_length":1979,"max_tokens_setting":2048} +{"idx":392576,"func":"int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,\n\t\t\t\t void *base_addr)\n{\n\tstatic int smap[PERCPU_DYNAMIC_EARLY_SLOTS] __initdata;\n\tstatic int dmap[PERCPU_DYNAMIC_EARLY_SLOTS] __initdata;\n\tsize_t dyn_size = ai->dyn_size;\n\tsize_t size_sum = ai->static_size + ai->reserved_size + dyn_size;\n\tstruct pcpu_chunk *schunk, *dchunk = NULL;\n\tunsigned long *group_offsets;\n\tsize_t *group_sizes;\n\tunsigned long *unit_off;\n\tunsigned int cpu;\n\tint *unit_map;\n\tint group, unit, i;\n\n#define PCPU_SETUP_BUG_ON(cond)\tdo {\t\t\t\t\t\\\n\tif (unlikely(cond)) {\t\t\t\t\t\t\\\n\t\tpr_emerg(\"failed to initialize, %s\\n\", #cond);\t\t\\\n\t\tpr_emerg(\"cpu_possible_mask=%*pb\\n\",\t\t\t\\\n\t\t\t cpumask_pr_args(cpu_possible_mask));\t\t\\\n\t\tpcpu_dump_alloc_info(KERN_EMERG, ai);\t\t\t\\\n\t\tBUG();\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n} while (0)\n\n\t\/* sanity checks *\/\n\tPCPU_SETUP_BUG_ON(ai->nr_groups <= 0);\n#ifdef CONFIG_SMP\n\tPCPU_SETUP_BUG_ON(!ai->static_size);\n\tPCPU_SETUP_BUG_ON(offset_in_page(__per_cpu_start));\n#endif\n\tPCPU_SETUP_BUG_ON(!base_addr);\n\tPCPU_SETUP_BUG_ON(offset_in_page(base_addr));\n\tPCPU_SETUP_BUG_ON(ai->unit_size < size_sum);\n\tPCPU_SETUP_BUG_ON(offset_in_page(ai->unit_size));\n\tPCPU_SETUP_BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE);\n\tPCPU_SETUP_BUG_ON(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE);\n\tPCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0);\n\n\t\/* process group information and build config tables accordingly *\/\n\tgroup_offsets = memblock_virt_alloc(ai->nr_groups *\n\t\t\t\t\t sizeof(group_offsets[0]), 0);\n\tgroup_sizes = memblock_virt_alloc(ai->nr_groups *\n\t\t\t\t\t sizeof(group_sizes[0]), 0);\n\tunit_map = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_map[0]), 0);\n\tunit_off = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_off[0]), 0);\n\n\tfor (cpu = 0; cpu < nr_cpu_ids; cpu++)\n\t\tunit_map[cpu] = UINT_MAX;\n\n\tpcpu_low_unit_cpu = NR_CPUS;\n\tpcpu_high_unit_cpu = NR_CPUS;\n\n\tfor (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) {\n\t\tconst struct pcpu_group_info *gi = &ai->groups[group];\n\n\t\tgroup_offsets[group] = gi->base_offset;\n\t\tgroup_sizes[group] = gi->nr_units * ai->unit_size;\n\n\t\tfor (i = 0; i < gi->nr_units; i++) {\n\t\t\tcpu = gi->cpu_map[i];\n\t\t\tif (cpu == NR_CPUS)\n\t\t\t\tcontinue;\n\n\t\t\tPCPU_SETUP_BUG_ON(cpu >= nr_cpu_ids);\n\t\t\tPCPU_SETUP_BUG_ON(!cpu_possible(cpu));\n\t\t\tPCPU_SETUP_BUG_ON(unit_map[cpu] != UINT_MAX);\n\n\t\t\tunit_map[cpu] = unit + i;\n\t\t\tunit_off[cpu] = gi->base_offset + i * ai->unit_size;\n\n\t\t\t\/* determine low\/high unit_cpu *\/\n\t\t\tif (pcpu_low_unit_cpu == NR_CPUS ||\n\t\t\t unit_off[cpu] < unit_off[pcpu_low_unit_cpu])\n\t\t\t\tpcpu_low_unit_cpu = cpu;\n\t\t\tif (pcpu_high_unit_cpu == NR_CPUS ||\n\t\t\t unit_off[cpu] > unit_off[pcpu_high_unit_cpu])\n\t\t\t\tpcpu_high_unit_cpu = cpu;\n\t\t}\n\t}\n\tpcpu_nr_units = unit;\n\n\tfor_each_possible_cpu(cpu)\n\t\tPCPU_SETUP_BUG_ON(unit_map[cpu] == UINT_MAX);\n\n\t\/* we're done parsing the input, undefine BUG macro and dump config *\/\n#undef PCPU_SETUP_BUG_ON\n\tpcpu_dump_alloc_info(KERN_DEBUG, ai);\n\n\tpcpu_nr_groups = ai->nr_groups;\n\tpcpu_group_offsets = group_offsets;\n\tpcpu_group_sizes = group_sizes;\n\tpcpu_unit_map = unit_map;\n\tpcpu_unit_offsets = unit_off;\n\n\t\/* determine basic parameters *\/\n\tpcpu_unit_pages = ai->unit_size >> PAGE_SHIFT;\n\tpcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT;\n\tpcpu_atom_size = ai->atom_size;\n\tpcpu_chunk_struct_size = sizeof(struct pcpu_chunk) +\n\t\tBITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long);\n\n\t\/*\n\t * Allocate chunk slots. The additional last slot is for\n\t * empty chunks.\n\t *\/\n\tpcpu_nr_slots = __pcpu_size_to_slot(pcpu_unit_size) + 2;\n\tpcpu_slot = memblock_virt_alloc(\n\t\t\tpcpu_nr_slots * sizeof(pcpu_slot[0]), 0);\n\tfor (i = 0; i < pcpu_nr_slots; i++)\n\t\tINIT_LIST_HEAD(&pcpu_slot[i]);\n\n\t\/*\n\t * Initialize static chunk. If reserved_size is zero, the\n\t * static chunk covers static area + dynamic allocation area\n\t * in the first chunk. If reserved_size is not zero, it\n\t * covers static area + reserved area (mostly used for module\n\t * static percpu allocation).\n\t *\/\n\tschunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0);\n\tINIT_LIST_HEAD(&schunk->list);\n\tINIT_LIST_HEAD(&schunk->map_extend_list);\n\tschunk->base_addr = base_addr;\n\tschunk->map = smap;\n\tschunk->map_alloc = ARRAY_SIZE(smap);\n\tschunk->immutable = true;\n\tbitmap_fill(schunk->populated, pcpu_unit_pages);\n\tschunk->nr_populated = pcpu_unit_pages;\n\n\tif (ai->reserved_size) {\n\t\tschunk->free_size = ai->reserved_size;\n\t\tpcpu_reserved_chunk = schunk;\n\t\tpcpu_reserved_chunk_limit = ai->static_size + ai->reserved_size;\n\t} else {\n\t\tschunk->free_size = dyn_size;\n\t\tdyn_size = 0;\t\t\t\/* dynamic area covered *\/\n\t}\n\tschunk->contig_hint = schunk->free_size;\n\n\tschunk->map[0] = 1;\n\tschunk->map[1] = ai->static_size;\n\tschunk->map_used = 1;\n\tif (schunk->free_size)\n\t\tschunk->map[++schunk->map_used] = ai->static_size + schunk->free_size;\n\tschunk->map[schunk->map_used] |= 1;\n\n\t\/* init dynamic chunk if necessary *\/\n\tif (dyn_size) {\n\t\tdchunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0);\n\t\tINIT_LIST_HEAD(&dchunk->list);\n\t\tINIT_LIST_HEAD(&dchunk->map_extend_list);\n\t\tdchunk->base_addr = base_addr;\n\t\tdchunk->map = dmap;\n\t\tdchunk->map_alloc = ARRAY_SIZE(dmap);\n\t\tdchunk->immutable = true;\n\t\tbitmap_fill(dchunk->populated, pcpu_unit_pages);\n\t\tdchunk->nr_populated = pcpu_unit_pages;\n\n\t\tdchunk->contig_hint = dchunk->free_size = dyn_size;\n\t\tdchunk->map[0] = 1;\n\t\tdchunk->map[1] = pcpu_reserved_chunk_limit;\n\t\tdchunk->map[2] = (pcpu_reserved_chunk_limit + dchunk->free_size) | 1;\n\t\tdchunk->map_used = 2;\n\t}\n\n\t\/* link the first chunk in *\/\n\tpcpu_first_chunk = dchunk ?: schunk;\n\tpcpu_nr_empty_pop_pages +=\n\t\tpcpu_count_occupied_pages(pcpu_first_chunk, 1);\n\tpcpu_chunk_relocate(pcpu_first_chunk, -1);\n\n\t\/* we're done *\/\n\tpcpu_base_addr = base_addr;\n\treturn 0;\n}","target":0,"code_token_length":1711,"total_token_length":1947,"max_tokens_setting":2048} +{"idx":222906,"func":"static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t size)\n{\n VirtIONet *n = qemu_get_nic_opaque(nc);\n VirtIONetQueue *q = virtio_net_get_subqueue(nc);\n VirtIODevice *vdev = VIRTIO_DEVICE(n);\n struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];\n struct virtio_net_hdr_mrg_rxbuf mhdr;\n unsigned mhdr_cnt = 0;\n size_t offset, i, guest_offset;\n\n if (!virtio_net_can_receive(nc)) {\n return -1;\n }\n\n \/* hdr_len refers to the header we supply to the guest *\/\n if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {\n return 0;\n }\n\n if (!receive_filter(n, buf, size))\n return size;\n\n offset = i = 0;\n\n while (offset < size) {\n VirtQueueElement elem;\n int len, total;\n const struct iovec *sg = elem.in_sg;\n\n total = 0;\n\n if (virtqueue_pop(q->rx_vq, &elem) == 0) {\n if (i == 0)\n return -1;\n error_report(\"virtio-net unexpected empty queue: \"\n \"i %zd mergeable %d offset %zd, size %zd, \"\n \"guest hdr len %zd, host hdr len %zd guest features 0x%x\",\n i, n->mergeable_rx_bufs, offset, size,\n n->guest_hdr_len, n->host_hdr_len, vdev->guest_features);\n exit(1);\n }\n\n if (elem.in_num < 1) {\n error_report(\"virtio-net receive queue contains no in buffers\");\n exit(1);\n }\n\n if (i == 0) {\n assert(offset == 0);\n if (n->mergeable_rx_bufs) {\n mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),\n sg, elem.in_num,\n offsetof(typeof(mhdr), num_buffers),\n sizeof(mhdr.num_buffers));\n }\n\n receive_header(n, sg, elem.in_num, buf, size);\n offset = n->host_hdr_len;\n total += n->guest_hdr_len;\n guest_offset = n->guest_hdr_len;\n } else {\n guest_offset = 0;\n }\n\n \/* copy in packet. ugh *\/\n len = iov_from_buf(sg, elem.in_num, guest_offset,\n buf + offset, size - offset);\n total += len;\n offset += len;\n \/* If buffers can't be merged, at this point we\n * must have consumed the complete packet.\n * Otherwise, drop it. *\/\n if (!n->mergeable_rx_bufs && offset < size) {\n#if 0\n error_report(\"virtio-net truncated non-mergeable packet: \"\n \"i %zd mergeable %d offset %zd, size %zd, \"\n \"guest hdr len %zd, host hdr len %zd\",\n i, n->mergeable_rx_bufs,\n offset, size, n->guest_hdr_len, n->host_hdr_len);\n#endif\n return size;\n }\n\n \/* signal other side *\/\n virtqueue_fill(q->rx_vq, &elem, total, i++);\n }\n\n if (mhdr_cnt) {\n stw_p(&mhdr.num_buffers, i);\n iov_from_buf(mhdr_sg, mhdr_cnt,\n 0,\n &mhdr.num_buffers, sizeof mhdr.num_buffers);\n }\n\n virtqueue_flush(q->rx_vq, i);\n virtio_notify(vdev, q->rx_vq);\n\n return size;\n}\n","target":0,"code_token_length":809,"total_token_length":1045,"max_tokens_setting":2048} +{"idx":7409,"func":"\nprivate int\nmcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,\n const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt)\n{\n\t\/*\n\t * Note: FILE_SEARCH and FILE_REGEX do not actually copy\n\t * anything, but setup pointers into the source\n\t *\/\n\tif (indir == 0) {\n\t\tswitch (type) {\n\t\tcase FILE_SEARCH:\n\t\t\tms->search.s = RCAST(const char *, s) + offset;\n\t\t\tms->search.s_len = nbytes - offset;\n\t\t\tms->search.offset = offset;\n\t\t\treturn 0;\n\n\t\tcase FILE_REGEX: {\n\t\t\tconst char *b;\n\t\t\tconst char *c;\n\t\t\tconst char *last;\t\/* end of search region *\/\n\t\t\tconst char *buf;\t\/* start of search region *\/\n\t\t\tconst char *end;\n\t\t\tsize_t lines;\n\n\t\t\tif (s == NULL) {\n\t\t\t\tms->search.s_len = 0;\n\t\t\t\tms->search.s = NULL;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbuf = RCAST(const char *, s) + offset;\n\t\t\tend = last = RCAST(const char *, s) + nbytes;\n\t\t\t\/* mget() guarantees buf <= last *\/\n\t\t\tfor (lines = linecnt, b = buf; lines && b < end &&\n\t\t\t ((b = CAST(const char *,\n\t\t\t\t memchr(c = b, '\\n', CAST(size_t, (end - b)))))\n\t\t\t || (b = CAST(const char *,\n\t\t\t\t memchr(c, '\\r', CAST(size_t, (end - c))))));\n\t\t\t lines--, b++) {\n\t\t\t\tlast = b;\n\t\t\t\tif (b[0] == '\\r' && b[1] == '\\n')\n\t\t\t\t\tb++;\n\t\t\t}\n\t\t\tif (lines)\n\t\t\t\tlast = RCAST(const char *, s) + nbytes;\n\n\t\t\tms->search.s = buf;\n\t\t\tms->search.s_len = last - buf;\n\t\t\tms->search.offset = offset;\n\t\t\tms->search.rm_len = 0;\n\t\t\treturn 0;\n\t\t}\n\t\tcase FILE_BESTRING16:\n\t\tcase FILE_LESTRING16: {\n\t\t\tconst unsigned char *src = s + offset;\n\t\t\tconst unsigned char *esrc = s + nbytes;\n\t\t\tchar *dst = p->s;\n\t\t\tchar *edst = &p->s[sizeof(p->s) - 1];\n\n\t\t\tif (type == FILE_BESTRING16)\n\t\t\t\tsrc++;\n\n\t\t\t\/* check that offset is within range *\/\n\t\t\tif (offset >= nbytes)\n\t\t\t\tbreak;\n\t\t\tfor (\/*EMPTY*\/; src < esrc; src += 2, dst++) {\n\t\t\t\tif (dst < edst)\n\t\t\t\t\t*dst = *src;\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t\tif (*dst == '\\0') {\n\t\t\t\t\tif (type == FILE_BESTRING16 ?\n\t\t\t\t\t *(src - 1) != '\\0' :\n\t\t\t\t\t *(src + 1) != '\\0')\n\t\t\t\t\t\t*dst = ' ';\n\t\t\t\t}\n\t\t\t}\n\t\t\t*edst = '\\0';\n\t\t\treturn 0;\n\t\t}\n\t\tcase FILE_STRING:\t\/* XXX - these two should not need *\/\n\t\tcase FILE_PSTRING:\t\/* to copy anything, but do anyway. *\/\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (offset >= nbytes) {\n\t\t(void)memset(p, '\\0', sizeof(*p));\n\t\treturn 0;\n\t}\n\tif (nbytes - offset < sizeof(*p))\n\t\tnbytes = nbytes - offset;\n\telse\n\t\tnbytes = sizeof(*p);\n\n\t(void)memcpy(p, s + offset, nbytes);\n\n\t\/*\n\t * the usefulness of padding with zeroes eludes me, it\n\t * might even cause problems\n\t *\/\n\tif (nbytes < sizeof(*p))\n\t\t(void)memset(((char *)(void *)p) + nbytes, '\\0',\n\t\t sizeof(*p) - nbytes);","target":1,"code_token_length":830,"total_token_length":1066,"max_tokens_setting":2048} +{"idx":332697,"func":"void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,\n\n const ARMCPRegInfo *r, void *opaque)\n\n{\n\n \/* Define implementations of coprocessor registers.\n\n * We store these in a hashtable because typically\n\n * there are less than 150 registers in a space which\n\n * is 16*16*16*8*8 = 262144 in size.\n\n * Wildcarding is supported for the crm, opc1 and opc2 fields.\n\n * If a register is defined twice then the second definition is\n\n * used, so this can be used to define some generic registers and\n\n * then override them with implementation specific variations.\n\n * At least one of the original and the second definition should\n\n * include ARM_CP_OVERRIDE in its type bits -- this is just a guard\n\n * against accidental use.\n\n *\/\n\n int crm, opc1, opc2;\n\n int crmmin = (r->crm == CP_ANY) ? 0 : r->crm;\n\n int crmmax = (r->crm == CP_ANY) ? 15 : r->crm;\n\n int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1;\n\n int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1;\n\n int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2;\n\n int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2;\n\n \/* 64 bit registers have only CRm and Opc1 fields *\/\n\n assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn)));\n\n \/* Check that the register definition has enough info to handle\n\n * reads and writes if they are permitted.\n\n *\/\n\n if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) {\n\n if (r->access & PL3_R) {\n\n assert(r->fieldoffset || r->readfn);\n\n }\n\n if (r->access & PL3_W) {\n\n assert(r->fieldoffset || r->writefn);\n\n }\n\n }\n\n \/* Bad type field probably means missing sentinel at end of reg list *\/\n\n assert(cptype_valid(r->type));\n\n for (crm = crmmin; crm <= crmmax; crm++) {\n\n for (opc1 = opc1min; opc1 <= opc1max; opc1++) {\n\n for (opc2 = opc2min; opc2 <= opc2max; opc2++) {\n\n uint32_t *key = g_new(uint32_t, 1);\n\n ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));\n\n int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;\n\n *key = ENCODE_CP_REG(r->cp, is64, r->crn, crm, opc1, opc2);\n\n if (opaque) {\n\n r2->opaque = opaque;\n\n }\n\n \/* Make sure reginfo passed to helpers for wildcarded regs\n\n * has the correct crm\/opc1\/opc2 for this reg, not CP_ANY:\n\n *\/\n\n r2->crm = crm;\n\n r2->opc1 = opc1;\n\n r2->opc2 = opc2;\n\n \/* By convention, for wildcarded registers only the first\n\n * entry is used for migration; the others are marked as\n\n * NO_MIGRATE so we don't try to transfer the register\n\n * multiple times. Special registers (ie NOP\/WFI) are\n\n * never migratable.\n\n *\/\n\n if ((r->type & ARM_CP_SPECIAL) ||\n\n ((r->crm == CP_ANY) && crm != 0) ||\n\n ((r->opc1 == CP_ANY) && opc1 != 0) ||\n\n ((r->opc2 == CP_ANY) && opc2 != 0)) {\n\n r2->type |= ARM_CP_NO_MIGRATE;\n\n }\n\n\n\n \/* Overriding of an existing definition must be explicitly\n\n * requested.\n\n *\/\n\n if (!(r->type & ARM_CP_OVERRIDE)) {\n\n ARMCPRegInfo *oldreg;\n\n oldreg = g_hash_table_lookup(cpu->cp_regs, key);\n\n if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {\n\n fprintf(stderr, \"Register redefined: cp=%d %d bit \"\n\n \"crn=%d crm=%d opc1=%d opc2=%d, \"\n\n \"was %s, now %s\\n\", r2->cp, 32 + 32 * is64,\n\n r2->crn, r2->crm, r2->opc1, r2->opc2,\n\n oldreg->name, r2->name);\n\n g_assert_not_reached();\n\n }\n\n }\n\n g_hash_table_insert(cpu->cp_regs, key, r2);\n\n }\n\n }\n\n }\n\n}\n","target":0,"code_token_length":1098,"total_token_length":1334,"max_tokens_setting":2048} diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.pkl new file mode 100644 index 0000000000000000000000000000000000000000..c2307893c2404ba3548ce908e90e1c328d9ad061 --- /dev/null +++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d615af340a4d6041260750c2c29ce5feeb6a36320b83511b9f0b18559b6e7df +size 2546664 diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..e125ba71344dd042515ed695bbec1ec0d7d2e3da --- /dev/null +++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.jsonl @@ -0,0 +1,10 @@ +{"idx":295879,"func":"WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,\n const char **argv,Image **image,ExceptionInfo *exception)\n{\n CompositeOperator\n compose;\n\n const char\n *format,\n *option;\n\n double\n attenuate;\n\n DrawInfo\n *draw_info;\n\n GeometryInfo\n geometry_info;\n\n ImageInfo\n *mogrify_info;\n\n MagickStatusType\n status;\n\n PixelInfo\n fill;\n\n MagickStatusType\n flags;\n\n PixelInterpolateMethod\n interpolate_method;\n\n QuantizeInfo\n *quantize_info;\n\n RectangleInfo\n geometry,\n region_geometry;\n\n register ssize_t\n i;\n\n \/*\n Initialize method variables.\n *\/\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickCoreSignature);\n assert(image != (Image **) NULL);\n assert((*image)->signature == MagickCoreSignature);\n if ((*image)->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",(*image)->filename);\n if (argc < 0)\n return(MagickTrue);\n mogrify_info=CloneImageInfo(image_info);\n draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL);\n quantize_info=AcquireQuantizeInfo(mogrify_info);\n SetGeometryInfo(&geometry_info);\n GetPixelInfo(*image,&fill);\n fill=(*image)->background_color;\n attenuate=1.0;\n compose=(*image)->compose;\n interpolate_method=UndefinedInterpolatePixel;\n format=GetImageOption(mogrify_info,\"format\");\n SetGeometry(*image,®ion_geometry);\n \/*\n Transmogrify the image.\n *\/\n for (i=0; i < (ssize_t) argc; i++)\n {\n Image\n *mogrify_image;\n\n ssize_t\n count;\n\n option=argv[i];\n if (IsCommandOption(option) == MagickFalse)\n continue;\n count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option),\n 0L);\n if ((i+count) >= (ssize_t) argc)\n break;\n status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);\n mogrify_image=(Image *) NULL;\n switch (*(option+1))\n {\n case 'a':\n {\n if (LocaleCompare(\"adaptive-blur\",option+1) == 0)\n {\n \/*\n Adaptive blur image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"adaptive-resize\",option+1) == 0)\n {\n \/*\n Adaptive resize image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=AdaptiveResizeImage(*image,geometry.width,\n geometry.height,exception);\n break;\n }\n if (LocaleCompare(\"adaptive-sharpen\",option+1) == 0)\n {\n \/*\n Adaptive sharpen image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"affine\",option+1) == 0)\n {\n \/*\n Affine matrix.\n *\/\n if (*option == '+')\n {\n GetAffineMatrix(&draw_info->affine);\n break;\n }\n (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);\n break;\n }\n if (LocaleCompare(\"alpha\",option+1) == 0)\n {\n AlphaChannelOption\n alpha_type;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n alpha_type=(AlphaChannelOption) ParseCommandOption(\n MagickAlphaChannelOptions,MagickFalse,argv[i+1]);\n (void) SetImageAlphaChannel(*image,alpha_type,exception);\n break;\n }\n if (LocaleCompare(\"annotate\",option+1) == 0)\n {\n char\n *text,\n geometry_str[MagickPathExtent];\n\n \/*\n Annotate image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n SetGeometryInfo(&geometry_info);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n text=InterpretImageProperties(mogrify_info,*image,argv[i+2],\n exception);\n if (text == (char *) NULL)\n break;\n (void) CloneString(&draw_info->text,text);\n text=DestroyString(text);\n (void) FormatLocaleString(geometry_str,MagickPathExtent,\"%+f%+f\",\n geometry_info.xi,geometry_info.psi);\n (void) CloneString(&draw_info->geometry,geometry_str);\n draw_info->affine.sx=cos(DegreesToRadians(\n fmod(geometry_info.rho,360.0)));\n draw_info->affine.rx=sin(DegreesToRadians(\n fmod(geometry_info.rho,360.0)));\n draw_info->affine.ry=(-sin(DegreesToRadians(\n fmod(geometry_info.sigma,360.0))));\n draw_info->affine.sy=cos(DegreesToRadians(\n fmod(geometry_info.sigma,360.0)));\n (void) AnnotateImage(*image,draw_info,exception);\n break;\n }\n if (LocaleCompare(\"antialias\",option+1) == 0)\n {\n draw_info->stroke_antialias=(*option == '-') ? MagickTrue :\n MagickFalse;\n draw_info->text_antialias=(*option == '-') ? MagickTrue :\n MagickFalse;\n break;\n }\n if (LocaleCompare(\"attenuate\",option+1) == 0)\n {\n if (*option == '+')\n {\n attenuate=1.0;\n break;\n }\n attenuate=StringToDouble(argv[i+1],(char **) NULL);\n break;\n }\n if (LocaleCompare(\"auto-gamma\",option+1) == 0)\n {\n \/*\n Auto Adjust Gamma of image based on its mean\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) AutoGammaImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"auto-level\",option+1) == 0)\n {\n \/*\n Perfectly Normalize (max\/min stretch) the image\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) AutoLevelImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"auto-orient\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=AutoOrientImage(*image,(*image)->orientation,\n exception);\n break;\n }\n if (LocaleCompare(\"auto-threshold\",option+1) == 0)\n {\n AutoThresholdMethod\n method;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n method=(AutoThresholdMethod) ParseCommandOption(\n MagickAutoThresholdOptions,MagickFalse,argv[i+1]);\n (void) AutoThresholdImage(*image,method,exception);\n break;\n }\n break;\n }\n case 'b':\n {\n if (LocaleCompare(\"black-threshold\",option+1) == 0)\n {\n \/*\n Black threshold image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) BlackThresholdImage(*image,argv[i+1],exception);\n break;\n }\n if (LocaleCompare(\"blue-shift\",option+1) == 0)\n {\n \/*\n Blue shift image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n geometry_info.rho=1.5;\n if (*option == '-')\n flags=ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception);\n break;\n }\n if (LocaleCompare(\"blur\",option+1) == 0)\n {\n \/*\n Gaussian blur image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=0.0;\n mogrify_image=BlurImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"border\",option+1) == 0)\n {\n \/*\n Surround image with a border of solid color.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=BorderImage(*image,&geometry,compose,exception);\n break;\n }\n if (LocaleCompare(\"bordercolor\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,\n &draw_info->border_color,exception);\n break;\n }\n (void) QueryColorCompliance(argv[i+1],AllCompliance,\n &draw_info->border_color,exception);\n break;\n }\n if (LocaleCompare(\"box\",option+1) == 0)\n {\n (void) QueryColorCompliance(argv[i+1],AllCompliance,\n &draw_info->undercolor,exception);\n break;\n }\n if (LocaleCompare(\"brightness-contrast\",option+1) == 0)\n {\n double\n brightness,\n contrast;\n\n \/*\n Brightness \/ contrast image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n brightness=geometry_info.rho;\n contrast=0.0;\n if ((flags & SigmaValue) != 0)\n contrast=geometry_info.sigma;\n (void) BrightnessContrastImage(*image,brightness,contrast,\n exception);\n break;\n }\n break;\n }\n case 'c':\n {\n if (LocaleCompare(\"canny\",option+1) == 0)\n {\n \/*\n Detect edges in the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=0.10;\n if ((flags & PsiValue) == 0)\n geometry_info.psi=0.30;\n if ((flags & PercentValue) != 0)\n {\n geometry_info.xi\/=100.0;\n geometry_info.psi\/=100.0;\n }\n mogrify_image=CannyEdgeImage(*image,geometry_info.rho,\n geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);\n break;\n }\n if (LocaleCompare(\"cdl\",option+1) == 0)\n {\n char\n *color_correction_collection;\n\n \/*\n Color correct with a color decision list.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n color_correction_collection=FileToString(argv[i+1],~0UL,exception);\n if (color_correction_collection == (char *) NULL)\n break;\n (void) ColorDecisionListImage(*image,color_correction_collection,\n exception);\n break;\n }\n if (LocaleCompare(\"channel\",option+1) == 0)\n {\n ChannelType\n channel;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n (void) SetPixelChannelMask(*image,DefaultChannels);\n break;\n }\n channel=(ChannelType) ParseChannelOption(argv[i+1]);\n (void) SetPixelChannelMask(*image,channel);\n break;\n }\n if (LocaleCompare(\"charcoal\",option+1) == 0)\n {\n \/*\n Charcoal image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=1.0;\n mogrify_image=CharcoalImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"chop\",option+1) == 0)\n {\n \/*\n Chop the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=ChopImage(*image,&geometry,exception);\n break;\n }\n if (LocaleCompare(\"clahe\",option+1) == 0)\n {\n \/*\n Contrast limited adaptive histogram equalization.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n (void) CLAHEImage(*image,geometry.width,geometry.height,\n (size_t) geometry.x,geometry_info.psi,exception);\n break;\n }\n if (LocaleCompare(\"clip\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,\n exception);\n break;\n }\n (void) ClipImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"clip-mask\",option+1) == 0)\n {\n Image\n *clip_mask;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n \/*\n Remove a mask.\n *\/\n (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,\n exception);\n break;\n }\n \/*\n Set the image mask.\n *\/\n clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);\n if (clip_mask == (Image *) NULL)\n break;\n (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);\n clip_mask=DestroyImage(clip_mask);\n break;\n }\n if (LocaleCompare(\"clip-path\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :\n MagickFalse,exception);\n break;\n }\n if (LocaleCompare(\"colorize\",option+1) == 0)\n {\n \/*\n Colorize the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);\n break;\n }\n if (LocaleCompare(\"color-matrix\",option+1) == 0)\n {\n KernelInfo\n *kernel;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n kernel=AcquireKernelInfo(argv[i+1],exception);\n if (kernel == (KernelInfo *) NULL)\n break;\n \/* FUTURE: check on size of the matrix *\/\n mogrify_image=ColorMatrixImage(*image,kernel,exception);\n kernel=DestroyKernelInfo(kernel);\n break;\n }\n if (LocaleCompare(\"colors\",option+1) == 0)\n {\n \/*\n Reduce the number of colors in the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n quantize_info->number_colors=StringToUnsignedLong(argv[i+1]);\n if (quantize_info->number_colors == 0)\n break;\n if (((*image)->storage_class == DirectClass) ||\n (*image)->colors > quantize_info->number_colors)\n (void) QuantizeImage(quantize_info,*image,exception);\n else\n (void) CompressImageColormap(*image,exception);\n break;\n }\n if (LocaleCompare(\"colorspace\",option+1) == 0)\n {\n ColorspaceType\n colorspace;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n (void) TransformImageColorspace(*image,sRGBColorspace,\n exception);\n break;\n }\n colorspace=(ColorspaceType) ParseCommandOption(\n MagickColorspaceOptions,MagickFalse,argv[i+1]);\n (void) TransformImageColorspace(*image,colorspace,exception);\n break;\n }\n if (LocaleCompare(\"compose\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,\n MagickFalse,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"connected-components\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=ConnectedComponentsImage(*image,(size_t)\n StringToInteger(argv[i+1]),(CCObjectInfo **) NULL,exception);\n break;\n }\n if (LocaleCompare(\"contrast\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ContrastImage(*image,(*option == '-') ? MagickTrue :\n MagickFalse,exception);\n break;\n }\n if (LocaleCompare(\"contrast-stretch\",option+1) == 0)\n {\n double\n black_point,\n white_point;\n\n \/*\n Contrast stretch image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n black_point=geometry_info.rho;\n white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :\n black_point;\n if ((flags & PercentValue) != 0)\n {\n black_point*=(double) (*image)->columns*(*image)->rows\/100.0;\n white_point*=(double) (*image)->columns*(*image)->rows\/100.0;\n }\n white_point=(double) (*image)->columns*(*image)->rows-\n white_point;\n (void) ContrastStretchImage(*image,black_point,white_point,\n exception);\n break;\n }\n if (LocaleCompare(\"convolve\",option+1) == 0)\n {\n double\n gamma;\n\n KernelInfo\n *kernel_info;\n\n register ssize_t\n j;\n\n size_t\n extent;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n kernel_info=AcquireKernelInfo(argv[i+1],exception);\n if (kernel_info == (KernelInfo *) NULL)\n break;\n extent=kernel_info->width*kernel_info->height;\n gamma=0.0;\n for (j=0; j < (ssize_t) extent; j++)\n gamma+=kernel_info->values[j];\n gamma=1.0\/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);\n for (j=0; j < (ssize_t) extent; j++)\n kernel_info->values[j]*=gamma;\n mogrify_image=MorphologyImage(*image,CorrelateMorphology,1,\n kernel_info,exception);\n kernel_info=DestroyKernelInfo(kernel_info);\n break;\n }\n if (LocaleCompare(\"crop\",option+1) == 0)\n {\n \/*\n Crop a image to a smaller size\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=CropImageToTiles(*image,argv[i+1],exception);\n break;\n }\n if (LocaleCompare(\"cycle\",option+1) == 0)\n {\n \/*\n Cycle an image colormap.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]),\n exception);\n break;\n }\n break;\n }\n case 'd':\n {\n if (LocaleCompare(\"decipher\",option+1) == 0)\n {\n StringInfo\n *passkey;\n\n \/*\n Decipher pixels.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n passkey=FileToStringInfo(argv[i+1],~0UL,exception);\n if (passkey != (StringInfo *) NULL)\n {\n (void) PasskeyDecipherImage(*image,passkey,exception);\n passkey=DestroyStringInfo(passkey);\n }\n break;\n }\n if (LocaleCompare(\"density\",option+1) == 0)\n {\n \/*\n Set image density.\n *\/\n (void) CloneString(&draw_info->density,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"depth\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception);\n break;\n }\n (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]),\n exception);\n break;\n }\n if (LocaleCompare(\"deskew\",option+1) == 0)\n {\n double\n threshold;\n\n \/*\n Straighten the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n threshold=40.0*QuantumRange\/100.0;\n else\n threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+\n 1.0);\n mogrify_image=DeskewImage(*image,threshold,exception);\n break;\n }\n if (LocaleCompare(\"despeckle\",option+1) == 0)\n {\n \/*\n Reduce the speckles within an image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=DespeckleImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"display\",option+1) == 0)\n {\n (void) CloneString(&draw_info->server_name,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"distort\",option+1) == 0)\n {\n char\n *args,\n token[MagickPathExtent];\n\n const char\n *p;\n\n DistortMethod\n method;\n\n double\n *arguments;\n\n register ssize_t\n x;\n\n size_t\n number_arguments;\n\n \/*\n Distort image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n method=(DistortMethod) ParseCommandOption(MagickDistortOptions,\n MagickFalse,argv[i+1]);\n if (method == ResizeDistortion)\n {\n double\n resize_args[2];\n\n \/*\n Special Case - Argument is actually a resize geometry!\n Convert that to an appropriate distortion argument array.\n *\/\n (void) ParseRegionGeometry(*image,argv[i+2],&geometry,\n exception);\n resize_args[0]=(double) geometry.width;\n resize_args[1]=(double) geometry.height;\n mogrify_image=DistortImage(*image,method,(size_t)2,\n resize_args,MagickTrue,exception);\n break;\n }\n args=InterpretImageProperties(mogrify_info,*image,argv[i+2],\n exception);\n if (args == (char *) NULL)\n break;\n p=(char *) args;\n for (x=0; *p != '\\0'; x++)\n {\n GetNextToken(p,&p,MagickPathExtent,token);\n if (*token == ',')\n GetNextToken(p,&p,MagickPathExtent,token);\n }\n number_arguments=(size_t) x;\n arguments=(double *) AcquireQuantumMemory(number_arguments,\n sizeof(*arguments));\n if (arguments == (double *) NULL)\n ThrowWandFatalException(ResourceLimitFatalError,\n \"MemoryAllocationFailed\",(*image)->filename);\n (void) memset(arguments,0,number_arguments*\n sizeof(*arguments));\n p=(char *) args;\n for (x=0; (x < (ssize_t) number_arguments) && (*p != '\\0'); x++)\n {\n GetNextToken(p,&p,MagickPathExtent,token);\n if (*token == ',')\n GetNextToken(p,&p,MagickPathExtent,token);\n arguments[x]=StringToDouble(token,(char **) NULL);\n }\n args=DestroyString(args);\n mogrify_image=DistortImage(*image,method,number_arguments,arguments,\n (*option == '+') ? MagickTrue : MagickFalse,exception);\n arguments=(double *) RelinquishMagickMemory(arguments);\n break;\n }\n if (LocaleCompare(\"dither\",option+1) == 0)\n {\n if (*option == '+')\n {\n quantize_info->dither_method=NoDitherMethod;\n break;\n }\n quantize_info->dither_method=(DitherMethod) ParseCommandOption(\n MagickDitherOptions,MagickFalse,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"draw\",option+1) == 0)\n {\n \/*\n Draw image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) CloneString(&draw_info->primitive,argv[i+1]);\n (void) DrawImage(*image,draw_info,exception);\n break;\n }\n break;\n }\n case 'e':\n {\n if (LocaleCompare(\"edge\",option+1) == 0)\n {\n \/*\n Enhance edges in the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=EdgeImage(*image,geometry_info.rho,exception);\n break;\n }\n if (LocaleCompare(\"emboss\",option+1) == 0)\n {\n \/*\n Emboss image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=EmbossImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"encipher\",option+1) == 0)\n {\n StringInfo\n *passkey;\n\n \/*\n Encipher pixels.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n passkey=FileToStringInfo(argv[i+1],~0UL,exception);\n if (passkey != (StringInfo *) NULL)\n {\n (void) PasskeyEncipherImage(*image,passkey,exception);\n passkey=DestroyStringInfo(passkey);\n }\n break;\n }\n if (LocaleCompare(\"encoding\",option+1) == 0)\n {\n (void) CloneString(&draw_info->encoding,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"enhance\",option+1) == 0)\n {\n \/*\n Enhance image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=EnhanceImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"equalize\",option+1) == 0)\n {\n \/*\n Equalize image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) EqualizeImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"evaluate\",option+1) == 0)\n {\n double\n constant;\n\n MagickEvaluateOperator\n op;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n op=(MagickEvaluateOperator) ParseCommandOption(\n MagickEvaluateOptions,MagickFalse,argv[i+1]);\n constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+\n 1.0);\n (void) EvaluateImage(*image,op,constant,exception);\n break;\n }\n if (LocaleCompare(\"extent\",option+1) == 0)\n {\n \/*\n Set the image extent.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);\n if (geometry.width == 0)\n geometry.width=(*image)->columns;\n if (geometry.height == 0)\n geometry.height=(*image)->rows;\n mogrify_image=ExtentImage(*image,&geometry,exception);\n break;\n }\n break;\n }\n case 'f':\n {\n if (LocaleCompare(\"family\",option+1) == 0)\n {\n if (*option == '+')\n {\n if (draw_info->family != (char *) NULL)\n draw_info->family=DestroyString(draw_info->family);\n break;\n }\n (void) CloneString(&draw_info->family,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"features\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) DeleteImageArtifact(*image,\"identify:features\");\n break;\n }\n (void) SetImageArtifact(*image,\"identify:features\",argv[i+1]);\n (void) SetImageArtifact(*image,\"verbose\",\"true\");\n break;\n }\n if (LocaleCompare(\"fill\",option+1) == 0)\n {\n ExceptionInfo\n *sans;\n\n PixelInfo\n color;\n\n GetPixelInfo(*image,&fill);\n if (*option == '+')\n {\n (void) QueryColorCompliance(\"none\",AllCompliance,&fill,\n exception);\n draw_info->fill=fill;\n if (draw_info->fill_pattern != (Image *) NULL)\n draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);\n break;\n }\n sans=AcquireExceptionInfo();\n status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);\n sans=DestroyExceptionInfo(sans);\n if (status == MagickFalse)\n draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],\n exception);\n else\n draw_info->fill=fill=color;\n break;\n }\n if (LocaleCompare(\"flip\",option+1) == 0)\n {\n \/*\n Flip image scanlines.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=FlipImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"floodfill\",option+1) == 0)\n {\n PixelInfo\n target;\n\n \/*\n Floodfill image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);\n (void) QueryColorCompliance(argv[i+2],AllCompliance,&target,\n exception);\n (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x,\n geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception);\n break;\n }\n if (LocaleCompare(\"flop\",option+1) == 0)\n {\n \/*\n Flop image scanlines.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=FlopImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"font\",option+1) == 0)\n {\n if (*option == '+')\n {\n if (draw_info->font != (char *) NULL)\n draw_info->font=DestroyString(draw_info->font);\n break;\n }\n (void) CloneString(&draw_info->font,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"format\",option+1) == 0)\n {\n format=argv[i+1];\n break;\n }\n if (LocaleCompare(\"frame\",option+1) == 0)\n {\n FrameInfo\n frame_info;\n\n \/*\n Surround image with an ornamental border.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);\n frame_info.width=geometry.width;\n frame_info.height=geometry.height;\n frame_info.outer_bevel=geometry.x;\n frame_info.inner_bevel=geometry.y;\n frame_info.x=(ssize_t) frame_info.width;\n frame_info.y=(ssize_t) frame_info.height;\n frame_info.width=(*image)->columns+2*frame_info.width;\n frame_info.height=(*image)->rows+2*frame_info.height;\n mogrify_image=FrameImage(*image,&frame_info,compose,exception);\n break;\n }\n if (LocaleCompare(\"function\",option+1) == 0)\n {\n char\n *arguments,\n token[MagickPathExtent];\n\n const char\n *p;\n\n double\n *parameters;\n\n MagickFunction\n function;\n\n register ssize_t\n x;\n\n size_t\n number_parameters;\n\n \/*\n Function Modify Image Values\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n function=(MagickFunction) ParseCommandOption(MagickFunctionOptions,\n MagickFalse,argv[i+1]);\n arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],\n exception);\n if (arguments == (char *) NULL)\n break;\n p=(char *) arguments;\n for (x=0; *p != '\\0'; x++)\n {\n GetNextToken(p,&p,MagickPathExtent,token);\n if (*token == ',')\n GetNextToken(p,&p,MagickPathExtent,token);\n }\n number_parameters=(size_t) x;\n parameters=(double *) AcquireQuantumMemory(number_parameters,\n sizeof(*parameters));\n if (parameters == (double *) NULL)\n ThrowWandFatalException(ResourceLimitFatalError,\n \"MemoryAllocationFailed\",(*image)->filename);\n (void) memset(parameters,0,number_parameters*\n sizeof(*parameters));\n p=(char *) arguments;\n for (x=0; (x < (ssize_t) number_parameters) && (*p != '\\0'); x++)\n {\n GetNextToken(p,&p,MagickPathExtent,token);\n if (*token == ',')\n GetNextToken(p,&p,MagickPathExtent,token);\n parameters[x]=StringToDouble(token,(char **) NULL);\n }\n arguments=DestroyString(arguments);\n (void) FunctionImage(*image,function,number_parameters,parameters,\n exception);\n parameters=(double *) RelinquishMagickMemory(parameters);\n break;\n }\n break;\n }\n case 'g':\n {\n if (LocaleCompare(\"gamma\",option+1) == 0)\n {\n \/*\n Gamma image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL);\n else\n (void) GammaImage(*image,StringToDouble(argv[i+1],(char **) NULL),\n exception);\n break;\n }\n if ((LocaleCompare(\"gaussian-blur\",option+1) == 0) ||\n (LocaleCompare(\"gaussian\",option+1) == 0))\n {\n \/*\n Gaussian blur image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=GaussianBlurImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"geometry\",option+1) == 0)\n {\n \/*\n Record Image offset, Resize last image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n if ((*image)->geometry != (char *) NULL)\n (*image)->geometry=DestroyString((*image)->geometry);\n break;\n }\n flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n if (((flags & XValue) != 0) || ((flags & YValue) != 0))\n (void) CloneString(&(*image)->geometry,argv[i+1]);\n else\n mogrify_image=ResizeImage(*image,geometry.width,geometry.height,\n (*image)->filter,exception);\n break;\n }\n if (LocaleCompare(\"gravity\",option+1) == 0)\n {\n if (*option == '+')\n {\n draw_info->gravity=UndefinedGravity;\n break;\n }\n draw_info->gravity=(GravityType) ParseCommandOption(\n MagickGravityOptions,MagickFalse,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"grayscale\",option+1) == 0)\n {\n PixelIntensityMethod\n method;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n method=(PixelIntensityMethod) ParseCommandOption(\n MagickPixelIntensityOptions,MagickFalse,argv[i+1]);\n (void) GrayscaleImage(*image,method,exception);\n break;\n }\n break;\n }\n case 'h':\n {\n if (LocaleCompare(\"highlight-color\",option+1) == 0)\n {\n (void) SetImageArtifact(*image,\"compare:highlight-color\",argv[i+1]);\n break;\n }\n if (LocaleCompare(\"hough-lines\",option+1) == 0)\n {\n \/*\n Detect edges in the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n if ((flags & XiValue) == 0)\n geometry_info.xi=40;\n mogrify_image=HoughLineImage(*image,(size_t) geometry_info.rho,\n (size_t) geometry_info.sigma,(size_t) geometry_info.xi,exception);\n break;\n }\n break;\n }\n case 'i':\n {\n if (LocaleCompare(\"identify\",option+1) == 0)\n {\n char\n *text;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (format == (char *) NULL)\n {\n (void) IdentifyImage(*image,stdout,mogrify_info->verbose,\n exception);\n break;\n }\n text=InterpretImageProperties(mogrify_info,*image,format,\n exception);\n if (text == (char *) NULL)\n break;\n (void) fputs(text,stdout);\n text=DestroyString(text);\n break;\n }\n if (LocaleCompare(\"implode\",option+1) == 0)\n {\n \/*\n Implode image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=ImplodeImage(*image,geometry_info.rho,\n interpolate_method,exception);\n break;\n }\n if (LocaleCompare(\"interline-spacing\",option+1) == 0)\n {\n if (*option == '+')\n (void) ParseGeometry(\"0\",&geometry_info);\n else\n (void) ParseGeometry(argv[i+1],&geometry_info);\n draw_info->interline_spacing=geometry_info.rho;\n break;\n }\n if (LocaleCompare(\"interpolate\",option+1) == 0)\n {\n interpolate_method=(PixelInterpolateMethod) ParseCommandOption(\n MagickInterpolateOptions,MagickFalse,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"interword-spacing\",option+1) == 0)\n {\n if (*option == '+')\n (void) ParseGeometry(\"0\",&geometry_info);\n else\n (void) ParseGeometry(argv[i+1],&geometry_info);\n draw_info->interword_spacing=geometry_info.rho;\n break;\n }\n if (LocaleCompare(\"interpolative-resize\",option+1) == 0)\n {\n \/*\n Interpolative resize image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=InterpolativeResizeImage(*image,geometry.width,\n geometry.height,interpolate_method,exception);\n break;\n }\n break;\n }\n case 'k':\n {\n if (LocaleCompare(\"kerning\",option+1) == 0)\n {\n if (*option == '+')\n (void) ParseGeometry(\"0\",&geometry_info);\n else\n (void) ParseGeometry(argv[i+1],&geometry_info);\n draw_info->kerning=geometry_info.rho;\n break;\n }\n if (LocaleCompare(\"kuwahara\",option+1) == 0)\n {\n \/*\n Edge preserving blur.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho-0.5;\n mogrify_image=KuwaharaImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n break;\n }\n case 'l':\n {\n if (LocaleCompare(\"lat\",option+1) == 0)\n {\n \/*\n Local adaptive threshold image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & PercentValue) != 0)\n geometry_info.xi=(double) QuantumRange*geometry_info.xi\/100.0;\n mogrify_image=AdaptiveThresholdImage(*image,(size_t)\n geometry_info.rho,(size_t) geometry_info.sigma,(double)\n geometry_info.xi,exception);\n break;\n }\n if (LocaleCompare(\"level\",option+1) == 0)\n {\n double\n black_point,\n gamma,\n white_point;\n\n \/*\n Parse levels.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n black_point=geometry_info.rho;\n white_point=(double) QuantumRange;\n if ((flags & SigmaValue) != 0)\n white_point=geometry_info.sigma;\n gamma=1.0;\n if ((flags & XiValue) != 0)\n gamma=geometry_info.xi;\n if ((flags & PercentValue) != 0)\n {\n black_point*=(double) (QuantumRange\/100.0);\n white_point*=(double) (QuantumRange\/100.0);\n }\n if ((flags & SigmaValue) == 0)\n white_point=(double) QuantumRange-black_point;\n if ((*option == '+') || ((flags & AspectValue) != 0))\n (void) LevelizeImage(*image,black_point,white_point,gamma,\n exception);\n else\n (void) LevelImage(*image,black_point,white_point,gamma,\n exception);\n break;\n }\n if (LocaleCompare(\"level-colors\",option+1) == 0)\n {\n char\n token[MagickPathExtent];\n\n const char\n *p;\n\n PixelInfo\n black_point,\n white_point;\n\n p=(const char *) argv[i+1];\n GetNextToken(p,&p,MagickPathExtent,token); \/* get black point color *\/\n if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))\n (void) QueryColorCompliance(token,AllCompliance,\n &black_point,exception);\n else\n (void) QueryColorCompliance(\"#000000\",AllCompliance,\n &black_point,exception);\n if (isalpha((int) token[0]) || (token[0] == '#'))\n GetNextToken(p,&p,MagickPathExtent,token);\n if (*token == '\\0')\n white_point=black_point; \/* set everything to that color *\/\n else\n {\n if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))\n GetNextToken(p,&p,MagickPathExtent,token); \/* Get white point color. *\/\n if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))\n (void) QueryColorCompliance(token,AllCompliance,\n &white_point,exception);\n else\n (void) QueryColorCompliance(\"#ffffff\",AllCompliance,\n &white_point,exception);\n }\n (void) LevelImageColors(*image,&black_point,&white_point,\n *option == '+' ? MagickTrue : MagickFalse,exception);\n break;\n }\n if (LocaleCompare(\"linear-stretch\",option+1) == 0)\n {\n double\n black_point,\n white_point;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n black_point=geometry_info.rho;\n white_point=(double) (*image)->columns*(*image)->rows;\n if ((flags & SigmaValue) != 0)\n white_point=geometry_info.sigma;\n if ((flags & PercentValue) != 0)\n {\n black_point*=(double) (*image)->columns*(*image)->rows\/100.0;\n white_point*=(double) (*image)->columns*(*image)->rows\/100.0;\n }\n if ((flags & SigmaValue) == 0)\n white_point=(double) (*image)->columns*(*image)->rows-\n black_point;\n (void) LinearStretchImage(*image,black_point,white_point,exception);\n break;\n }\n if (LocaleCompare(\"liquid-rescale\",option+1) == 0)\n {\n \/*\n Liquid rescale image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n if ((flags & XValue) == 0)\n geometry.x=1;\n if ((flags & YValue) == 0)\n geometry.y=0;\n mogrify_image=LiquidRescaleImage(*image,geometry.width,\n geometry.height,1.0*geometry.x,1.0*geometry.y,exception);\n break;\n }\n if (LocaleCompare(\"local-contrast\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & RhoValue) == 0)\n geometry_info.rho=10;\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=12.5;\n mogrify_image=LocalContrastImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"lowlight-color\",option+1) == 0)\n {\n (void) SetImageArtifact(*image,\"compare:lowlight-color\",argv[i+1]);\n break;\n }\n break;\n }\n case 'm':\n {\n if (LocaleCompare(\"magnify\",option+1) == 0)\n {\n \/*\n Double image size.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=MagnifyImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"map\",option+1) == 0)\n {\n Image\n *remap_image;\n\n \/*\n Transform image colors to match this set of colors.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n break;\n remap_image=GetImageCache(mogrify_info,argv[i+1],exception);\n if (remap_image == (Image *) NULL)\n break;\n (void) RemapImage(quantize_info,*image,remap_image,exception);\n remap_image=DestroyImage(remap_image);\n break;\n }\n if (LocaleCompare(\"mask\",option+1) == 0)\n {\n Image\n *mask;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n \/*\n Remove a mask.\n *\/\n (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,\n exception);\n break;\n }\n \/*\n Set the image mask.\n *\/\n mask=GetImageCache(mogrify_info,argv[i+1],exception);\n if (mask == (Image *) NULL)\n break;\n (void) SetImageMask(*image,WritePixelMask,mask,exception);\n mask=DestroyImage(mask);\n break;\n }\n if (LocaleCompare(\"matte\",option+1) == 0)\n {\n (void) SetImageAlphaChannel(*image,(*option == '-') ?\n SetAlphaChannel : DeactivateAlphaChannel,exception);\n break;\n }\n if (LocaleCompare(\"mean-shift\",option+1) == 0)\n {\n \/*\n Detect edges in the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n if ((flags & XiValue) == 0)\n geometry_info.xi=0.10*QuantumRange;\n if ((flags & PercentValue) != 0)\n geometry_info.xi=(double) QuantumRange*geometry_info.xi\/100.0;\n mogrify_image=MeanShiftImage(*image,(size_t) geometry_info.rho,\n (size_t) geometry_info.sigma,geometry_info.xi,exception);\n break;\n }\n if (LocaleCompare(\"median\",option+1) == 0)\n {\n \/*\n Median filter image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n mogrify_image=StatisticImage(*image,MedianStatistic,(size_t)\n geometry_info.rho,(size_t) geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"mode\",option+1) == 0)\n {\n \/*\n Mode image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n mogrify_image=StatisticImage(*image,ModeStatistic,(size_t)\n geometry_info.rho,(size_t) geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"modulate\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ModulateImage(*image,argv[i+1],exception);\n break;\n }\n if (LocaleCompare(\"moments\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) DeleteImageArtifact(*image,\"identify:moments\");\n break;\n }\n (void) SetImageArtifact(*image,\"identify:moments\",argv[i+1]);\n (void) SetImageArtifact(*image,\"verbose\",\"true\");\n break;\n }\n if (LocaleCompare(\"monitor\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) SetImageProgressMonitor(*image,\n (MagickProgressMonitor) NULL,(void *) NULL);\n break;\n }\n (void) SetImageProgressMonitor(*image,MonitorProgress,\n (void *) NULL);\n break;\n }\n if (LocaleCompare(\"monochrome\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) SetImageType(*image,BilevelType,exception);\n break;\n }\n if (LocaleCompare(\"morphology\",option+1) == 0)\n {\n char\n token[MagickPathExtent];\n\n const char\n *p;\n\n KernelInfo\n *kernel;\n\n MorphologyMethod\n method;\n\n ssize_t\n iterations;\n\n \/*\n Morphological Image Operation\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n p=argv[i+1];\n GetNextToken(p,&p,MagickPathExtent,token);\n method=(MorphologyMethod) ParseCommandOption(\n MagickMorphologyOptions,MagickFalse,token);\n iterations=1L;\n GetNextToken(p,&p,MagickPathExtent,token);\n if ((*p == ':') || (*p == ','))\n GetNextToken(p,&p,MagickPathExtent,token);\n if ((*p != '\\0'))\n iterations=(ssize_t) StringToLong(p);\n kernel=AcquireKernelInfo(argv[i+2],exception);\n if (kernel == (KernelInfo *) NULL)\n {\n (void) ThrowMagickException(exception,GetMagickModule(),\n OptionError,\"UnabletoParseKernel\",\"morphology\");\n status=MagickFalse;\n break;\n }\n mogrify_image=MorphologyImage(*image,method,iterations,kernel,\n exception);\n kernel=DestroyKernelInfo(kernel);\n break;\n }\n if (LocaleCompare(\"motion-blur\",option+1) == 0)\n {\n \/*\n Motion blur image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=MotionBlurImage(*image,geometry_info.rho,\n geometry_info.sigma,geometry_info.xi,exception);\n break;\n }\n break;\n }\n case 'n':\n {\n if (LocaleCompare(\"negate\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) NegateImage(*image,*option == '+' ? MagickTrue :\n MagickFalse,exception);\n break;\n }\n if (LocaleCompare(\"noise\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '-')\n {\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t)\n geometry_info.rho,(size_t) geometry_info.sigma,exception);\n }\n else\n {\n NoiseType\n noise;\n\n noise=(NoiseType) ParseCommandOption(MagickNoiseOptions,\n MagickFalse,argv[i+1]);\n mogrify_image=AddNoiseImage(*image,noise,attenuate,exception);\n }\n break;\n }\n if (LocaleCompare(\"normalize\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) NormalizeImage(*image,exception);\n break;\n }\n break;\n }\n case 'o':\n {\n if (LocaleCompare(\"opaque\",option+1) == 0)\n {\n PixelInfo\n target;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,\n exception);\n (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ?\n MagickFalse : MagickTrue,exception);\n break;\n }\n if (LocaleCompare(\"ordered-dither\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) OrderedDitherImage(*image,argv[i+1],exception);\n break;\n }\n break;\n }\n case 'p':\n {\n if (LocaleCompare(\"paint\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=OilPaintImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"perceptible\",option+1) == 0)\n {\n \/*\n Perceptible image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) PerceptibleImage(*image,StringToDouble(argv[i+1],\n (char **) NULL),exception);\n break;\n }\n if (LocaleCompare(\"pointsize\",option+1) == 0)\n {\n if (*option == '+')\n (void) ParseGeometry(\"12\",&geometry_info);\n else\n (void) ParseGeometry(argv[i+1],&geometry_info);\n draw_info->pointsize=geometry_info.rho;\n break;\n }\n if (LocaleCompare(\"polaroid\",option+1) == 0)\n {\n const char\n *caption;\n\n double\n angle;\n\n RandomInfo\n *random_info;\n\n \/*\n Simulate a Polaroid picture.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n random_info=AcquireRandomInfo();\n angle=22.5*(GetPseudoRandomValue(random_info)-0.5);\n random_info=DestroyRandomInfo(random_info);\n if (*option == '-')\n {\n SetGeometryInfo(&geometry_info);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n angle=geometry_info.rho;\n }\n caption=GetImageProperty(*image,\"caption\",exception);\n mogrify_image=PolaroidImage(*image,draw_info,caption,angle,\n interpolate_method,exception);\n break;\n }\n if (LocaleCompare(\"posterize\",option+1) == 0)\n {\n \/*\n Posterize image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]),\n quantize_info->dither_method,exception);\n break;\n }\n if (LocaleCompare(\"preview\",option+1) == 0)\n {\n PreviewType\n preview_type;\n\n \/*\n Preview image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n preview_type=UndefinedPreview;\n else\n preview_type=(PreviewType) ParseCommandOption(\n MagickPreviewOptions,MagickFalse,argv[i+1]);\n mogrify_image=PreviewImage(*image,preview_type,exception);\n break;\n }\n if (LocaleCompare(\"profile\",option+1) == 0)\n {\n const char\n *name;\n\n const StringInfo\n *profile;\n\n Image\n *profile_image;\n\n ImageInfo\n *profile_info;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n \/*\n Remove a profile from the image.\n *\/\n (void) ProfileImage(*image,argv[i+1],(const unsigned char *)\n NULL,0,exception);\n break;\n }\n \/*\n Associate a profile with the image.\n *\/\n profile_info=CloneImageInfo(mogrify_info);\n profile=GetImageProfile(*image,\"iptc\");\n if (profile != (StringInfo *) NULL)\n profile_info->profile=(void *) CloneStringInfo(profile);\n profile_image=GetImageCache(profile_info,argv[i+1],exception);\n profile_info=DestroyImageInfo(profile_info);\n if (profile_image == (Image *) NULL)\n {\n StringInfo\n *file_data;\n\n profile_info=CloneImageInfo(mogrify_info);\n (void) CopyMagickString(profile_info->filename,argv[i+1],\n MagickPathExtent);\n file_data=FileToStringInfo(profile_info->filename,~0UL,\n exception);\n if (file_data != (StringInfo *) NULL)\n {\n (void) SetImageInfo(profile_info,0,exception);\n (void) ProfileImage(*image,profile_info->magick,\n GetStringInfoDatum(file_data),\n GetStringInfoLength(file_data),exception);\n file_data=DestroyStringInfo(file_data);\n }\n profile_info=DestroyImageInfo(profile_info);\n break;\n }\n ResetImageProfileIterator(profile_image);\n name=GetNextImageProfile(profile_image);\n while (name != (const char *) NULL)\n {\n profile=GetImageProfile(profile_image,name);\n if (profile != (StringInfo *) NULL)\n (void) ProfileImage(*image,name,GetStringInfoDatum(profile),\n (size_t) GetStringInfoLength(profile),exception);\n name=GetNextImageProfile(profile_image);\n }\n profile_image=DestroyImage(profile_image);\n break;\n }\n break;\n }\n case 'q':\n {\n if (LocaleCompare(\"quantize\",option+1) == 0)\n {\n if (*option == '+')\n {\n quantize_info->colorspace=UndefinedColorspace;\n break;\n }\n quantize_info->colorspace=(ColorspaceType) ParseCommandOption(\n MagickColorspaceOptions,MagickFalse,argv[i+1]);\n break;\n }\n break;\n }\n case 'r':\n {\n if (LocaleCompare(\"rotational-blur\",option+1) == 0)\n {\n \/*\n Rotational blur image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=RotationalBlurImage(*image,geometry_info.rho,\n exception);\n break;\n }\n if (LocaleCompare(\"raise\",option+1) == 0)\n {\n \/*\n Surround image with a raise of solid color.\n *\/\n flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);\n (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :\n MagickFalse,exception);\n break;\n }\n if (LocaleCompare(\"random-threshold\",option+1) == 0)\n {\n \/*\n Random threshold image.\n *\/\n double\n min_threshold,\n max_threshold;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n min_threshold=0.0;\n max_threshold=(double) QuantumRange;\n flags=ParseGeometry(argv[i+1],&geometry_info);\n min_threshold=geometry_info.rho;\n max_threshold=geometry_info.sigma;\n if ((flags & SigmaValue) == 0)\n max_threshold=min_threshold;\n if (strchr(argv[i+1],'%') != (char *) NULL)\n {\n max_threshold*=(double) (0.01*QuantumRange);\n min_threshold*=(double) (0.01*QuantumRange);\n }\n (void) RandomThresholdImage(*image,min_threshold,max_threshold,\n exception);\n break;\n }\n if (LocaleCompare(\"range-threshold\",option+1) == 0)\n {\n \/*\n Range threshold image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n if ((flags & XiValue) == 0)\n geometry_info.xi=geometry_info.sigma;\n if ((flags & PsiValue) == 0)\n geometry_info.psi=geometry_info.xi;\n if (strchr(argv[i+1],'%') != (char *) NULL)\n {\n geometry_info.rho*=(double) (0.01*QuantumRange);\n geometry_info.sigma*=(double) (0.01*QuantumRange);\n geometry_info.xi*=(double) (0.01*QuantumRange);\n geometry_info.psi*=(double) (0.01*QuantumRange);\n }\n (void) RangeThresholdImage(*image,geometry_info.rho,\n geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);\n break;\n }\n if (LocaleCompare(\"read-mask\",option+1) == 0)\n {\n Image\n *mask;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n \/*\n Remove a mask.\n *\/\n (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,\n exception);\n break;\n }\n \/*\n Set the image mask.\n *\/\n mask=GetImageCache(mogrify_info,argv[i+1],exception);\n if (mask == (Image *) NULL)\n break;\n (void) SetImageMask(*image,ReadPixelMask,mask,exception);\n mask=DestroyImage(mask);\n break;\n }\n if (LocaleCompare(\"region\",option+1) == 0)\n {\n \/*\n Apply read mask as defined by a region geometry.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n (void) SetImageRegionMask(*image,WritePixelMask,\n (const RectangleInfo *) NULL,exception);\n break;\n }\n (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);\n (void) SetImageRegionMask(*image,WritePixelMask,&geometry,\n exception);\n break;\n }\n if (LocaleCompare(\"render\",option+1) == 0)\n {\n (void) SyncImageSettings(mogrify_info,*image,exception);\n draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;\n break;\n }\n if (LocaleCompare(\"remap\",option+1) == 0)\n {\n Image\n *remap_image;\n\n \/*\n Transform image colors to match this set of colors.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n break;\n remap_image=GetImageCache(mogrify_info,argv[i+1],exception);\n if (remap_image == (Image *) NULL)\n break;\n (void) RemapImage(quantize_info,*image,remap_image,exception);\n remap_image=DestroyImage(remap_image);\n break;\n }\n if (LocaleCompare(\"repage\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) ParseAbsoluteGeometry(\"0x0+0+0\",&(*image)->page);\n break;\n }\n (void) ResetImagePage(*image,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"resample\",option+1) == 0)\n {\n \/*\n Resample image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n mogrify_image=ResampleImage(*image,geometry_info.rho,\n geometry_info.sigma,(*image)->filter,exception);\n break;\n }\n if (LocaleCompare(\"resize\",option+1) == 0)\n {\n \/*\n Resize image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=ResizeImage(*image,geometry.width,geometry.height,\n (*image)->filter,exception);\n break;\n }\n if (LocaleCompare(\"roll\",option+1) == 0)\n {\n \/*\n Roll image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);\n if ((flags & PercentValue) != 0)\n {\n geometry.x*=(double) (*image)->columns\/100.0;\n geometry.y*=(double) (*image)->rows\/100.0;\n }\n mogrify_image=RollImage(*image,geometry.x,geometry.y,exception);\n break;\n }\n if (LocaleCompare(\"rotate\",option+1) == 0)\n {\n char\n *rotation;\n\n \/*\n Check for conditional image rotation.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (strchr(argv[i+1],'>') != (char *) NULL)\n if ((*image)->columns <= (*image)->rows)\n break;\n if (strchr(argv[i+1],'<') != (char *) NULL)\n if ((*image)->columns >= (*image)->rows)\n break;\n \/*\n Rotate image.\n *\/\n rotation=ConstantString(argv[i+1]);\n (void) SubstituteString(&rotation,\">\",\"\");\n (void) SubstituteString(&rotation,\"<\",\"\");\n (void) ParseGeometry(rotation,&geometry_info);\n rotation=DestroyString(rotation);\n mogrify_image=RotateImage(*image,geometry_info.rho,exception);\n break;\n }\n break;\n }\n case 's':\n {\n if (LocaleCompare(\"sample\",option+1) == 0)\n {\n \/*\n Sample image with pixel replication.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=SampleImage(*image,geometry.width,geometry.height,\n exception);\n break;\n }\n if (LocaleCompare(\"scale\",option+1) == 0)\n {\n \/*\n Resize image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=ScaleImage(*image,geometry.width,geometry.height,\n exception);\n break;\n }\n if (LocaleCompare(\"selective-blur\",option+1) == 0)\n {\n \/*\n Selectively blur pixels within a contrast threshold.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & PercentValue) != 0)\n geometry_info.xi=(double) QuantumRange*geometry_info.xi\/100.0;\n mogrify_image=SelectiveBlurImage(*image,geometry_info.rho,\n geometry_info.sigma,geometry_info.xi,exception);\n break;\n }\n if (LocaleCompare(\"separate\",option+1) == 0)\n {\n \/*\n Break channels into separate images.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=SeparateImages(*image,exception);\n break;\n }\n if (LocaleCompare(\"sepia-tone\",option+1) == 0)\n {\n double\n threshold;\n\n \/*\n Sepia-tone image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+\n 1.0);\n mogrify_image=SepiaToneImage(*image,threshold,exception);\n break;\n }\n if (LocaleCompare(\"segment\",option+1) == 0)\n {\n \/*\n Segment image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n (void) SegmentImage(*image,(*image)->colorspace,\n mogrify_info->verbose,geometry_info.rho,geometry_info.sigma,\n exception);\n break;\n }\n if (LocaleCompare(\"set\",option+1) == 0)\n {\n char\n *value;\n\n \/*\n Set image option.\n *\/\n if (*option == '+')\n {\n if (LocaleNCompare(argv[i+1],\"registry:\",9) == 0)\n (void) DeleteImageRegistry(argv[i+1]+9);\n else\n if (LocaleNCompare(argv[i+1],\"option:\",7) == 0)\n {\n (void) DeleteImageOption(mogrify_info,argv[i+1]+7);\n (void) DeleteImageArtifact(*image,argv[i+1]+7);\n }\n else\n (void) DeleteImageProperty(*image,argv[i+1]);\n break;\n }\n value=InterpretImageProperties(mogrify_info,*image,argv[i+2],\n exception);\n if (value == (char *) NULL)\n break;\n if (LocaleNCompare(argv[i+1],\"registry:\",9) == 0)\n (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value,\n exception);\n else\n if (LocaleNCompare(argv[i+1],\"option:\",7) == 0)\n {\n (void) SetImageOption(image_info,argv[i+1]+7,value);\n (void) SetImageOption(mogrify_info,argv[i+1]+7,value);\n (void) SetImageArtifact(*image,argv[i+1]+7,value);\n }\n else\n (void) SetImageProperty(*image,argv[i+1],value,exception);\n value=DestroyString(value);\n break;\n }\n if (LocaleCompare(\"shade\",option+1) == 0)\n {\n \/*\n Shade image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue :\n MagickFalse,geometry_info.rho,geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"shadow\",option+1) == 0)\n {\n \/*\n Shadow image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=4.0;\n if ((flags & PsiValue) == 0)\n geometry_info.psi=4.0;\n mogrify_image=ShadowImage(*image,geometry_info.rho,\n geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),\n (ssize_t) ceil(geometry_info.psi-0.5),exception);\n break;\n }\n if (LocaleCompare(\"sharpen\",option+1) == 0)\n {\n \/*\n Sharpen image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=0.0;\n mogrify_image=SharpenImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"shave\",option+1) == 0)\n {\n \/*\n Shave the image edges.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=ShaveImage(*image,&geometry,exception);\n break;\n }\n if (LocaleCompare(\"shear\",option+1) == 0)\n {\n \/*\n Shear image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=geometry_info.rho;\n mogrify_image=ShearImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"sigmoidal-contrast\",option+1) == 0)\n {\n \/*\n Sigmoidal non-linearity contrast control.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=(double) QuantumRange\/2.0;\n if ((flags & PercentValue) != 0)\n geometry_info.sigma=(double) QuantumRange*geometry_info.sigma\/\n 100.0;\n (void) SigmoidalContrastImage(*image,(*option == '-') ?\n MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma,\n exception);\n break;\n }\n if (LocaleCompare(\"sketch\",option+1) == 0)\n {\n \/*\n Sketch image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=SketchImage(*image,geometry_info.rho,\n geometry_info.sigma,geometry_info.xi,exception);\n break;\n }\n if (LocaleCompare(\"solarize\",option+1) == 0)\n {\n double\n threshold;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+\n 1.0);\n (void) SolarizeImage(*image,threshold,exception);\n break;\n }\n if (LocaleCompare(\"sparse-color\",option+1) == 0)\n {\n SparseColorMethod\n method;\n\n char\n *arguments;\n\n \/*\n Sparse Color Interpolated Gradient\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n method=(SparseColorMethod) ParseCommandOption(\n MagickSparseColorOptions,MagickFalse,argv[i+1]);\n arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2],\n exception);\n if (arguments == (char *) NULL)\n break;\n mogrify_image=SparseColorOption(*image,method,arguments,\n option[0] == '+' ? MagickTrue : MagickFalse,exception);\n arguments=DestroyString(arguments);\n break;\n }\n if (LocaleCompare(\"splice\",option+1) == 0)\n {\n \/*\n Splice a solid color into the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=SpliceImage(*image,&geometry,exception);\n break;\n }\n if (LocaleCompare(\"spread\",option+1) == 0)\n {\n \/*\n Spread an image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=SpreadImage(*image,interpolate_method,\n geometry_info.rho,exception);\n break;\n }\n if (LocaleCompare(\"statistic\",option+1) == 0)\n {\n StatisticType\n type;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n type=(StatisticType) ParseCommandOption(MagickStatisticOptions,\n MagickFalse,argv[i+1]);\n (void) ParseGeometry(argv[i+2],&geometry_info);\n mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho,\n (size_t) geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"stretch\",option+1) == 0)\n {\n if (*option == '+')\n {\n draw_info->stretch=UndefinedStretch;\n break;\n }\n draw_info->stretch=(StretchType) ParseCommandOption(\n MagickStretchOptions,MagickFalse,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"strip\",option+1) == 0)\n {\n \/*\n Strip image of profiles and comments.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) StripImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"stroke\",option+1) == 0)\n {\n ExceptionInfo\n *sans;\n\n PixelInfo\n color;\n\n if (*option == '+')\n {\n (void) QueryColorCompliance(\"none\",AllCompliance,\n &draw_info->stroke,exception);\n if (draw_info->stroke_pattern != (Image *) NULL)\n draw_info->stroke_pattern=DestroyImage(\n draw_info->stroke_pattern);\n break;\n }\n sans=AcquireExceptionInfo();\n status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans);\n sans=DestroyExceptionInfo(sans);\n if (status == MagickFalse)\n draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1],\n exception);\n else\n draw_info->stroke=color;\n break;\n }\n if (LocaleCompare(\"strokewidth\",option+1) == 0)\n {\n draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL);\n break;\n }\n if (LocaleCompare(\"style\",option+1) == 0)\n {\n if (*option == '+')\n {\n draw_info->style=UndefinedStyle;\n break;\n }\n draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,\n MagickFalse,argv[i+1]);\n break;\n }\n if (LocaleCompare(\"swirl\",option+1) == 0)\n {\n \/*\n Swirl image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseGeometry(argv[i+1],&geometry_info);\n mogrify_image=SwirlImage(*image,geometry_info.rho,\n interpolate_method,exception);\n break;\n }\n break;\n }\n case 't':\n {\n if (LocaleCompare(\"threshold\",option+1) == 0)\n {\n double\n threshold;\n\n \/*\n Threshold image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n threshold=(double) QuantumRange\/2;\n else\n threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+\n 1.0);\n (void) BilevelImage(*image,threshold,exception);\n break;\n }\n if (LocaleCompare(\"thumbnail\",option+1) == 0)\n {\n \/*\n Thumbnail image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);\n mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height,\n exception);\n break;\n }\n if (LocaleCompare(\"tile\",option+1) == 0)\n {\n if (*option == '+')\n {\n if (draw_info->fill_pattern != (Image *) NULL)\n draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);\n break;\n }\n draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1],\n exception);\n break;\n }\n if (LocaleCompare(\"tint\",option+1) == 0)\n {\n \/*\n Tint the image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=TintImage(*image,argv[i+1],&fill,exception);\n break;\n }\n if (LocaleCompare(\"transform\",option+1) == 0)\n {\n \/*\n Affine transform image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=AffineTransformImage(*image,&draw_info->affine,\n exception);\n break;\n }\n if (LocaleCompare(\"transparent\",option+1) == 0)\n {\n PixelInfo\n target;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) QueryColorCompliance(argv[i+1],AllCompliance,&target,\n exception);\n (void) TransparentPaintImage(*image,&target,(Quantum)\n TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue,\n exception);\n break;\n }\n if (LocaleCompare(\"transpose\",option+1) == 0)\n {\n \/*\n Transpose image scanlines.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=TransposeImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"transverse\",option+1) == 0)\n {\n \/*\n Transverse image scanlines.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=TransverseImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"treedepth\",option+1) == 0)\n {\n quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]);\n break;\n }\n if (LocaleCompare(\"trim\",option+1) == 0)\n {\n \/*\n Trim image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=TrimImage(*image,exception);\n break;\n }\n if (LocaleCompare(\"type\",option+1) == 0)\n {\n ImageType\n type;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n type=UndefinedType;\n else\n type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,\n argv[i+1]);\n (*image)->type=UndefinedType;\n (void) SetImageType(*image,type,exception);\n break;\n }\n break;\n }\n case 'u':\n {\n if (LocaleCompare(\"undercolor\",option+1) == 0)\n {\n (void) QueryColorCompliance(argv[i+1],AllCompliance,\n &draw_info->undercolor,exception);\n break;\n }\n if (LocaleCompare(\"unique\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) DeleteImageArtifact(*image,\"identify:unique-colors\");\n break;\n }\n (void) SetImageArtifact(*image,\"identify:unique-colors\",\"true\");\n (void) SetImageArtifact(*image,\"verbose\",\"true\");\n break;\n }\n if (LocaleCompare(\"unique-colors\",option+1) == 0)\n {\n \/*\n Unique image colors.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n mogrify_image=UniqueImageColors(*image,exception);\n break;\n }\n if (LocaleCompare(\"unsharp\",option+1) == 0)\n {\n \/*\n Unsharp mask image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=1.0;\n if ((flags & PsiValue) == 0)\n geometry_info.psi=0.05;\n mogrify_image=UnsharpMaskImage(*image,geometry_info.rho,\n geometry_info.sigma,geometry_info.xi,geometry_info.psi,\n exception);\n break;\n }\n break;\n }\n case 'v':\n {\n if (LocaleCompare(\"verbose\",option+1) == 0)\n {\n (void) SetImageArtifact(*image,option+1,\n *option == '+' ? \"false\" : \"true\");\n break;\n }\n if (LocaleCompare(\"vignette\",option+1) == 0)\n {\n \/*\n Vignette image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n if ((flags & XiValue) == 0)\n geometry_info.xi=0.1*(*image)->columns;\n if ((flags & PsiValue) == 0)\n geometry_info.psi=0.1*(*image)->rows;\n if ((flags & PercentValue) != 0)\n {\n geometry_info.xi*=(double) (*image)->columns\/100.0;\n geometry_info.psi*=(double) (*image)->rows\/100.0;\n }\n mogrify_image=VignetteImage(*image,geometry_info.rho,\n geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),\n (ssize_t) ceil(geometry_info.psi-0.5),exception);\n break;\n }\n if (LocaleCompare(\"virtual-pixel\",option+1) == 0)\n {\n if (*option == '+')\n {\n (void) SetImageVirtualPixelMethod(*image,\n UndefinedVirtualPixelMethod,exception);\n break;\n }\n (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)\n ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,\n argv[i+1]),exception);\n break;\n }\n break;\n }\n case 'w':\n {\n if (LocaleCompare(\"wave\",option+1) == 0)\n {\n \/*\n Wave image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=1.0;\n mogrify_image=WaveImage(*image,geometry_info.rho,\n geometry_info.sigma,interpolate_method,exception);\n break;\n }\n if (LocaleCompare(\"wavelet-denoise\",option+1) == 0)\n {\n \/*\n Wavelet denoise image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n flags=ParseGeometry(argv[i+1],&geometry_info);\n if ((flags & PercentValue) != 0)\n {\n geometry_info.rho=QuantumRange*geometry_info.rho\/100.0;\n geometry_info.sigma=QuantumRange*geometry_info.sigma\/100.0;\n }\n if ((flags & SigmaValue) == 0)\n geometry_info.sigma=0.0;\n mogrify_image=WaveletDenoiseImage(*image,geometry_info.rho,\n geometry_info.sigma,exception);\n break;\n }\n if (LocaleCompare(\"weight\",option+1) == 0)\n {\n ssize_t\n weight;\n\n weight=ParseCommandOption(MagickWeightOptions,MagickFalse,\n argv[i+1]);\n if (weight == -1)\n weight=(ssize_t) StringToUnsignedLong(argv[i+1]);\n draw_info->weight=(size_t) weight;\n break;\n }\n if (LocaleCompare(\"white-threshold\",option+1) == 0)\n {\n \/*\n White threshold image.\n *\/\n (void) SyncImageSettings(mogrify_info,*image,exception);\n (void) WhiteThresholdImage(*image,argv[i+1],exception);\n break;\n }\n if (LocaleCompare(\"write-mask\",option+1) == 0)\n {\n Image\n *mask;\n\n (void) SyncImageSettings(mogrify_info,*image,exception);\n if (*option == '+')\n {\n \/*\n Remove a mask.\n *\/\n (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,\n exception);\n break;\n }\n \/*\n Set the image mask.\n *\/\n mask=GetImageCache(mogrify_info,argv[i+1],exception);\n if (mask == (Image *) NULL)\n break;\n (void) SetImageMask(*image,WritePixelMask,mask,exception);\n mask=DestroyImage(mask);\n break;\n }\n break;\n }\n default:\n break;\n }\n \/*\n Replace current image with any image that was generated\n *\/\n if (mogrify_image != (Image *) NULL)\n ReplaceImageInListReturnLast(image,mogrify_image);\n i+=count;\n }\n \/*\n Free resources.\n *\/\n quantize_info=DestroyQuantizeInfo(quantize_info);\n draw_info=DestroyDrawInfo(draw_info);\n mogrify_info=DestroyImageInfo(mogrify_info);\n status=(MagickStatusType) (exception->severity < ErrorException ? 1 : 0);\n return(status == 0 ? MagickFalse : MagickTrue);\n}","target":0,"code_token_length":21121,"total_token_length":21357,"max_tokens_setting":28000} +{"idx":375325,"func":"StartupXLOG(void)\n{\n\tXLogCtlInsert *Insert;\n\tCheckPoint\tcheckPoint;\n\tbool\t\twasShutdown;\n\tbool\t\treachedStopPoint = false;\n\tbool\t\thaveBackupLabel = false;\n\tXLogRecPtr\tRecPtr,\n\t\t\t\tcheckPointLoc,\n\t\t\t\tEndOfLog;\n\tXLogSegNo\tendLogSegNo;\n\tTimeLineID\tPrevTimeLineID;\n\tXLogRecord *record;\n\tTransactionId oldestActiveXID;\n\tbool\t\tbackupEndRequired = false;\n\tbool\t\tbackupFromStandby = false;\n\tDBState\t\tdbstate_at_startup;\n\tXLogReaderState *xlogreader;\n\tXLogPageReadPrivate private;\n\tbool\t\tfast_promoted = false;\n\n\t\/*\n\t * Read control file and check XLOG status looks valid.\n\t *\n\t * Note: in most control paths, *ControlFile is already valid and we need\n\t * not do ReadControlFile() here, but might as well do it to be sure.\n\t *\/\n\tReadControlFile();\n\n\tif (ControlFile->state < DB_SHUTDOWNED ||\n\t\tControlFile->state > DB_IN_PRODUCTION ||\n\t\t!XRecOffIsValid(ControlFile->checkPoint))\n\t\tereport(FATAL,\n\t\t\t\t(errmsg(\"control file contains invalid data\")));\n\n\tif (ControlFile->state == DB_SHUTDOWNED)\n\t{\n\t\t\/* This is the expected case, so don't be chatty in standalone mode *\/\n\t\tereport(IsPostmasterEnvironment ? LOG : NOTICE,\n\t\t\t\t(errmsg(\"database system was shut down at %s\",\n\t\t\t\t\t\tstr_time(ControlFile->time))));\n\t}\n\telse if (ControlFile->state == DB_SHUTDOWNED_IN_RECOVERY)\n\t\tereport(LOG,\n\t\t\t\t(errmsg(\"database system was shut down in recovery at %s\",\n\t\t\t\t\t\tstr_time(ControlFile->time))));\n\telse if (ControlFile->state == DB_SHUTDOWNING)\n\t\tereport(LOG,\n\t\t\t\t(errmsg(\"database system shutdown was interrupted; last known up at %s\",\n\t\t\t\t\t\tstr_time(ControlFile->time))));\n\telse if (ControlFile->state == DB_IN_CRASH_RECOVERY)\n\t\tereport(LOG,\n\t\t (errmsg(\"database system was interrupted while in recovery at %s\",\n\t\t\t\t str_time(ControlFile->time)),\n\t\t\terrhint(\"This probably means that some data is corrupted and\"\n\t\t\t\t\t\" you will have to use the last backup for recovery.\")));\n\telse if (ControlFile->state == DB_IN_ARCHIVE_RECOVERY)\n\t\tereport(LOG,\n\t\t\t\t(errmsg(\"database system was interrupted while in recovery at log time %s\",\n\t\t\t\t\t\tstr_time(ControlFile->checkPointCopy.time)),\n\t\t\t\t errhint(\"If this has occurred more than once some data might be corrupted\"\n\t\t\t \" and you might need to choose an earlier recovery target.\")));\n\telse if (ControlFile->state == DB_IN_PRODUCTION)\n\t\tereport(LOG,\n\t\t\t (errmsg(\"database system was interrupted; last known up at %s\",\n\t\t\t\t\t str_time(ControlFile->time))));\n\n\t\/* This is just to allow attaching to startup process with a debugger *\/\n#ifdef XLOG_REPLAY_DELAY\n\tif (ControlFile->state != DB_SHUTDOWNED)\n\t\tpg_usleep(60000000L);\n#endif\n\n\t\/*\n\t * Verify that pg_xlog and pg_xlog\/archive_status exist. In cases where\n\t * someone has performed a copy for PITR, these directories may have been\n\t * excluded and need to be re-created.\n\t *\/\n\tValidateXLOGDirectoryStructure();\n\n\t\/*\n\t * Clear out any old relcache cache files.\tThis is *necessary* if we do\n\t * any WAL replay, since that would probably result in the cache files\n\t * being out of sync with database reality. In theory we could leave them\n\t * in place if the database had been cleanly shut down, but it seems\n\t * safest to just remove them always and let them be rebuilt during the\n\t * first backend startup.\n\t *\/\n\tRelationCacheInitFileRemove();\n\n\t\/*\n\t * Initialize on the assumption we want to recover to the latest timeline\n\t * that's active according to pg_control.\n\t *\/\n\tif (ControlFile->minRecoveryPointTLI >\n\t\tControlFile->checkPointCopy.ThisTimeLineID)\n\t\trecoveryTargetTLI = ControlFile->minRecoveryPointTLI;\n\telse\n\t\trecoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID;\n\n\t\/*\n\t * Check for recovery control file, and if so set up state for offline\n\t * recovery\n\t *\/\n\treadRecoveryCommandFile();\n\n\t\/*\n\t * Save archive_cleanup_command in shared memory so that other processes\n\t * can see it.\n\t *\/\n\tstrlcpy(XLogCtl->archiveCleanupCommand,\n\t\t\tarchiveCleanupCommand ? archiveCleanupCommand : \"\",\n\t\t\tsizeof(XLogCtl->archiveCleanupCommand));\n\n\tif (ArchiveRecoveryRequested)\n\t{\n\t\tif (StandbyModeRequested)\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"entering standby mode\")));\n\t\telse if (recoveryTarget == RECOVERY_TARGET_XID)\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"starting point-in-time recovery to XID %u\",\n\t\t\t\t\t\t\trecoveryTargetXid)));\n\t\telse if (recoveryTarget == RECOVERY_TARGET_TIME)\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"starting point-in-time recovery to %s\",\n\t\t\t\t\t\t\ttimestamptz_to_str(recoveryTargetTime))));\n\t\telse if (recoveryTarget == RECOVERY_TARGET_NAME)\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"starting point-in-time recovery to \\\"%s\\\"\",\n\t\t\t\t\t\t\trecoveryTargetName)));\n\t\telse if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE)\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"starting point-in-time recovery to earliest consistent point\")));\n\t\telse\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"starting archive recovery\")));\n\t}\n\n\t\/*\n\t * Take ownership of the wakeup latch if we're going to sleep during\n\t * recovery.\n\t *\/\n\tif (StandbyModeRequested)\n\t\tOwnLatch(&XLogCtl->recoveryWakeupLatch);\n\n\t\/* Set up XLOG reader facility *\/\n\tMemSet(&private, 0, sizeof(XLogPageReadPrivate));\n\txlogreader = XLogReaderAllocate(&XLogPageRead, &private);\n\tif (!xlogreader)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_OUT_OF_MEMORY),\n\t\t\t\t errmsg(\"out of memory\"),\n\t\t\terrdetail(\"Failed while allocating an XLog reading processor.\")));\n\txlogreader->system_identifier = ControlFile->system_identifier;\n\n\tif (read_backup_label(&checkPointLoc, &backupEndRequired,\n\t\t\t\t\t\t &backupFromStandby))\n\t{\n\t\t\/*\n\t\t * Archive recovery was requested, and thanks to the backup label\n\t\t * file, we know how far we need to replay to reach consistency. Enter\n\t\t * archive recovery directly.\n\t\t *\/\n\t\tInArchiveRecovery = true;\n\t\tif (StandbyModeRequested)\n\t\t\tStandbyMode = true;\n\n\t\t\/*\n\t\t * When a backup_label file is present, we want to roll forward from\n\t\t * the checkpoint it identifies, rather than using pg_control.\n\t\t *\/\n\t\trecord = ReadCheckpointRecord(xlogreader, checkPointLoc, 0, true);\n\t\tif (record != NULL)\n\t\t{\n\t\t\tmemcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));\n\t\t\twasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);\n\t\t\tereport(DEBUG1,\n\t\t\t\t\t(errmsg(\"checkpoint record is at %X\/%X\",\n\t\t\t\t (uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));\n\t\t\tInRecovery = true;\t\/* force recovery even if SHUTDOWNED *\/\n\n\t\t\t\/*\n\t\t\t * Make sure that REDO location exists. This may not be the case\n\t\t\t * if there was a crash during an online backup, which left a\n\t\t\t * backup_label around that references a WAL segment that's\n\t\t\t * already been archived.\n\t\t\t *\/\n\t\t\tif (checkPoint.redo < checkPointLoc)\n\t\t\t{\n\t\t\t\tif (!ReadRecord(xlogreader, checkPoint.redo, LOG, false))\n\t\t\t\t\tereport(FATAL,\n\t\t\t\t\t\t\t(errmsg(\"could not find redo location referenced by checkpoint record\"),\n\t\t\t\t\t\t\t errhint(\"If you are not restoring from a backup, try removing the file \\\"%s\/backup_label\\\".\", DataDir)));\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errmsg(\"could not locate required checkpoint record\"),\n\t\t\t\t\t errhint(\"If you are not restoring from a backup, try removing the file \\\"%s\/backup_label\\\".\", DataDir)));\n\t\t\twasShutdown = false;\t\/* keep compiler quiet *\/\n\t\t}\n\t\t\/* set flag to delete it later *\/\n\t\thaveBackupLabel = true;\n\t}\n\telse\n\t{\n\t\t\/*\n\t\t * It's possible that archive recovery was requested, but we don't\n\t\t * know how far we need to replay the WAL before we reach consistency.\n\t\t * This can happen for example if a base backup is taken from a\n\t\t * running server using an atomic filesystem snapshot, without calling\n\t\t * pg_start\/stop_backup. Or if you just kill a running master server\n\t\t * and put it into archive recovery by creating a recovery.conf file.\n\t\t *\n\t\t * Our strategy in that case is to perform crash recovery first,\n\t\t * replaying all the WAL present in pg_xlog, and only enter archive\n\t\t * recovery after that.\n\t\t *\n\t\t * But usually we already know how far we need to replay the WAL (up\n\t\t * to minRecoveryPoint, up to backupEndPoint, or until we see an\n\t\t * end-of-backup record), and we can enter archive recovery directly.\n\t\t *\/\n\t\tif (ArchiveRecoveryRequested &&\n\t\t\t(ControlFile->minRecoveryPoint != InvalidXLogRecPtr ||\n\t\t\t ControlFile->backupEndRequired ||\n\t\t\t ControlFile->backupEndPoint != InvalidXLogRecPtr ||\n\t\t\t ControlFile->state == DB_SHUTDOWNED))\n\t\t{\n\t\t\tInArchiveRecovery = true;\n\t\t\tif (StandbyModeRequested)\n\t\t\t\tStandbyMode = true;\n\t\t}\n\n\t\t\/*\n\t\t * Get the last valid checkpoint record. If the latest one according\n\t\t * to pg_control is broken, try the next-to-last one.\n\t\t *\/\n\t\tcheckPointLoc = ControlFile->checkPoint;\n\t\tRedoStartLSN = ControlFile->checkPointCopy.redo;\n\t\trecord = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, true);\n\t\tif (record != NULL)\n\t\t{\n\t\t\tereport(DEBUG1,\n\t\t\t\t\t(errmsg(\"checkpoint record is at %X\/%X\",\n\t\t\t\t (uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));\n\t\t}\n\t\telse if (StandbyMode)\n\t\t{\n\t\t\t\/*\n\t\t\t * The last valid checkpoint record required for a streaming\n\t\t\t * recovery exists in neither standby nor the primary.\n\t\t\t *\/\n\t\t\tereport(PANIC,\n\t\t\t\t\t(errmsg(\"could not locate a valid checkpoint record\")));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcheckPointLoc = ControlFile->prevCheckPoint;\n\t\t\trecord = ReadCheckpointRecord(xlogreader, checkPointLoc, 2, true);\n\t\t\tif (record != NULL)\n\t\t\t{\n\t\t\t\tereport(LOG,\n\t\t\t\t\t\t(errmsg(\"using previous checkpoint record at %X\/%X\",\n\t\t\t\t (uint32) (checkPointLoc >> 32), (uint32) checkPointLoc)));\n\t\t\t\tInRecovery = true;\t\t\/* force recovery even if SHUTDOWNED *\/\n\t\t\t}\n\t\t\telse\n\t\t\t\tereport(PANIC,\n\t\t\t\t\t (errmsg(\"could not locate a valid checkpoint record\")));\n\t\t}\n\t\tmemcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));\n\t\twasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);\n\t}\n\n\t\/*\n\t * If the location of the checkpoint record is not on the expected\n\t * timeline in the history of the requested timeline, we cannot proceed:\n\t * the backup is not part of the history of the requested timeline.\n\t *\/\n\tAssert(expectedTLEs);\t\t\/* was initialized by reading checkpoint\n\t\t\t\t\t\t\t\t * record *\/\n\tif (tliOfPointInHistory(checkPointLoc, expectedTLEs) !=\n\t\tcheckPoint.ThisTimeLineID)\n\t{\n\t\tXLogRecPtr\tswitchpoint;\n\n\t\t\/*\n\t\t * tliSwitchPoint will throw an error if the checkpoint's timeline is\n\t\t * not in expectedTLEs at all.\n\t\t *\/\n\t\tswitchpoint = tliSwitchPoint(ControlFile->checkPointCopy.ThisTimeLineID, expectedTLEs, NULL);\n\t\tereport(FATAL,\n\t\t\t\t(errmsg(\"requested timeline %u is not a child of this server's history\",\n\t\t\t\t\t\trecoveryTargetTLI),\n\t\t\t\t errdetail(\"Latest checkpoint is at %X\/%X on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %X\/%X.\",\n\t\t\t\t\t\t (uint32) (ControlFile->checkPoint >> 32),\n\t\t\t\t\t\t (uint32) ControlFile->checkPoint,\n\t\t\t\t\t\t ControlFile->checkPointCopy.ThisTimeLineID,\n\t\t\t\t\t\t (uint32) (switchpoint >> 32),\n\t\t\t\t\t\t (uint32) switchpoint)));\n\t}\n\n\t\/*\n\t * The min recovery point should be part of the requested timeline's\n\t * history, too.\n\t *\/\n\tif (!XLogRecPtrIsInvalid(ControlFile->minRecoveryPoint) &&\n\t tliOfPointInHistory(ControlFile->minRecoveryPoint - 1, expectedTLEs) !=\n\t\tControlFile->minRecoveryPointTLI)\n\t\tereport(FATAL,\n\t\t\t\t(errmsg(\"requested timeline %u does not contain minimum recovery point %X\/%X on timeline %u\",\n\t\t\t\t\t\trecoveryTargetTLI,\n\t\t\t\t\t\t(uint32) (ControlFile->minRecoveryPoint >> 32),\n\t\t\t\t\t\t(uint32) ControlFile->minRecoveryPoint,\n\t\t\t\t\t\tControlFile->minRecoveryPointTLI)));\n\n\tLastRec = RecPtr = checkPointLoc;\n\n\tereport(DEBUG1,\n\t\t\t(errmsg(\"redo record is at %X\/%X; shutdown %s\",\n\t\t\t\t (uint32) (checkPoint.redo >> 32), (uint32) checkPoint.redo,\n\t\t\t\t\twasShutdown ? \"TRUE\" : \"FALSE\")));\n\tereport(DEBUG1,\n\t\t\t(errmsg(\"next transaction ID: %u\/%u; next OID: %u\",\n\t\t\t\t\tcheckPoint.nextXidEpoch, checkPoint.nextXid,\n\t\t\t\t\tcheckPoint.nextOid)));\n\tereport(DEBUG1,\n\t\t\t(errmsg(\"next MultiXactId: %u; next MultiXactOffset: %u\",\n\t\t\t\t\tcheckPoint.nextMulti, checkPoint.nextMultiOffset)));\n\tereport(DEBUG1,\n\t\t\t(errmsg(\"oldest unfrozen transaction ID: %u, in database %u\",\n\t\t\t\t\tcheckPoint.oldestXid, checkPoint.oldestXidDB)));\n\tereport(DEBUG1,\n\t\t\t(errmsg(\"oldest MultiXactId: %u, in database %u\",\n\t\t\t\t\tcheckPoint.oldestMulti, checkPoint.oldestMultiDB)));\n\tif (!TransactionIdIsNormal(checkPoint.nextXid))\n\t\tereport(PANIC,\n\t\t\t\t(errmsg(\"invalid next transaction ID\")));\n\n\t\/* initialize shared memory variables from the checkpoint record *\/\n\tShmemVariableCache->nextXid = checkPoint.nextXid;\n\tShmemVariableCache->nextOid = checkPoint.nextOid;\n\tShmemVariableCache->oidCount = 0;\n\tMultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);\n\tSetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);\n\tSetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB);\n\tXLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch;\n\tXLogCtl->ckptXid = checkPoint.nextXid;\n\n\t\/*\n\t * Initialize replication slots, before there's a chance to remove\n\t * required resources.\n\t *\/\n\tStartupReplicationSlots(checkPoint.redo);\n\n\t\/*\n\t * Startup MultiXact. We need to do this early for two reasons: one\n\t * is that we might try to access multixacts when we do tuple freezing,\n\t * and the other is we need its state initialized because we attempt\n\t * truncation during restartpoints.\n\t *\/\n\tStartupMultiXact();\n\n\t\/*\n\t * Initialize unlogged LSN. On a clean shutdown, it's restored from the\n\t * control file. On recovery, all unlogged relations are blown away, so\n\t * the unlogged LSN counter can be reset too.\n\t *\/\n\tif (ControlFile->state == DB_SHUTDOWNED)\n\t\tXLogCtl->unloggedLSN = ControlFile->unloggedLSN;\n\telse\n\t\tXLogCtl->unloggedLSN = 1;\n\n\t\/*\n\t * We must replay WAL entries using the same TimeLineID they were created\n\t * under, so temporarily adopt the TLI indicated by the checkpoint (see\n\t * also xlog_redo()).\n\t *\/\n\tThisTimeLineID = checkPoint.ThisTimeLineID;\n\n\t\/*\n\t * Copy any missing timeline history files between 'now' and the recovery\n\t * target timeline from archive to pg_xlog. While we don't need those\n\t * files ourselves - the history file of the recovery target timeline\n\t * covers all the previous timelines in the history too - a cascading\n\t * standby server might be interested in them. Or, if you archive the WAL\n\t * from this server to a different archive than the master, it'd be good\n\t * for all the history files to get archived there after failover, so that\n\t * you can use one of the old timelines as a PITR target. Timeline history\n\t * files are small, so it's better to copy them unnecessarily than not\n\t * copy them and regret later.\n\t *\/\n\trestoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI);\n\n\tlastFullPageWrites = checkPoint.fullPageWrites;\n\n\tRedoRecPtr = XLogCtl->RedoRecPtr = XLogCtl->Insert.RedoRecPtr = checkPoint.redo;\n\n\tif (RecPtr < checkPoint.redo)\n\t\tereport(PANIC,\n\t\t\t\t(errmsg(\"invalid redo in checkpoint record\")));\n\n\t\/*\n\t * Check whether we need to force recovery from WAL. If it appears to\n\t * have been a clean shutdown and we did not have a recovery.conf file,\n\t * then assume no recovery needed.\n\t *\/\n\tif (checkPoint.redo < RecPtr)\n\t{\n\t\tif (wasShutdown)\n\t\t\tereport(PANIC,\n\t\t\t\t\t(errmsg(\"invalid redo record in shutdown checkpoint\")));\n\t\tInRecovery = true;\n\t}\n\telse if (ControlFile->state != DB_SHUTDOWNED)\n\t\tInRecovery = true;\n\telse if (ArchiveRecoveryRequested)\n\t{\n\t\t\/* force recovery due to presence of recovery.conf *\/\n\t\tInRecovery = true;\n\t}\n\n\t\/* REDO *\/\n\tif (InRecovery)\n\t{\n\t\tint\t\t\trmid;\n\n\t\t\/* use volatile pointer to prevent code rearrangement *\/\n\t\tvolatile XLogCtlData *xlogctl = XLogCtl;\n\n\t\t\/*\n\t\t * Update pg_control to show that we are recovering and to show the\n\t\t * selected checkpoint as the place we are starting from. We also mark\n\t\t * pg_control with any minimum recovery stop point obtained from a\n\t\t * backup history file.\n\t\t *\/\n\t\tdbstate_at_startup = ControlFile->state;\n\t\tif (InArchiveRecovery)\n\t\t\tControlFile->state = DB_IN_ARCHIVE_RECOVERY;\n\t\telse\n\t\t{\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"database system was not properly shut down; \"\n\t\t\t\t\t\t\t\"automatic recovery in progress\")));\n\t\t\tif (recoveryTargetTLI > ControlFile->checkPointCopy.ThisTimeLineID)\n\t\t\t\tereport(LOG,\n\t\t\t\t\t\t(errmsg(\"crash recovery starts in timeline %u \"\n\t\t\t\t\t\t\t\t\"and has target timeline %u\",\n\t\t\t\t\t\t\t\tControlFile->checkPointCopy.ThisTimeLineID,\n\t\t\t\t\t\t\t\trecoveryTargetTLI)));\n\t\t\tControlFile->state = DB_IN_CRASH_RECOVERY;\n\t\t}\n\t\tControlFile->prevCheckPoint = ControlFile->checkPoint;\n\t\tControlFile->checkPoint = checkPointLoc;\n\t\tControlFile->checkPointCopy = checkPoint;\n\t\tif (InArchiveRecovery)\n\t\t{\n\t\t\t\/* initialize minRecoveryPoint if not set yet *\/\n\t\t\tif (ControlFile->minRecoveryPoint < checkPoint.redo)\n\t\t\t{\n\t\t\t\tControlFile->minRecoveryPoint = checkPoint.redo;\n\t\t\t\tControlFile->minRecoveryPointTLI = checkPoint.ThisTimeLineID;\n\t\t\t}\n\t\t}\n\n\t\t\/*\n\t\t * Set backupStartPoint if we're starting recovery from a base backup.\n\t\t *\n\t\t * Set backupEndPoint and use minRecoveryPoint as the backup end\n\t\t * location if we're starting recovery from a base backup which was\n\t\t * taken from the standby. In this case, the database system status in\n\t\t * pg_control must indicate DB_IN_ARCHIVE_RECOVERY. If not, which\n\t\t * means that backup is corrupted, so we cancel recovery.\n\t\t *\/\n\t\tif (haveBackupLabel)\n\t\t{\n\t\t\tControlFile->backupStartPoint = checkPoint.redo;\n\t\t\tControlFile->backupEndRequired = backupEndRequired;\n\n\t\t\tif (backupFromStandby)\n\t\t\t{\n\t\t\t\tif (dbstate_at_startup != DB_IN_ARCHIVE_RECOVERY)\n\t\t\t\t\tereport(FATAL,\n\t\t\t\t\t\t\t(errmsg(\"backup_label contains data inconsistent with control file\"),\n\t\t\t\t\t\t\t errhint(\"This means that the backup is corrupted and you will \"\n\t\t\t\t\t\t\t \"have to use another backup for recovery.\")));\n\t\t\t\tControlFile->backupEndPoint = ControlFile->minRecoveryPoint;\n\t\t\t}\n\t\t}\n\t\tControlFile->time = (pg_time_t) time(NULL);\n\t\t\/* No need to hold ControlFileLock yet, we aren't up far enough *\/\n\t\tUpdateControlFile();\n\n\t\t\/* initialize our local copy of minRecoveryPoint *\/\n\t\tminRecoveryPoint = ControlFile->minRecoveryPoint;\n\t\tminRecoveryPointTLI = ControlFile->minRecoveryPointTLI;\n\n\t\t\/*\n\t\t * Reset pgstat data, because it may be invalid after recovery.\n\t\t *\/\n\t\tpgstat_reset_all();\n\n\t\t\/*\n\t\t * If there was a backup label file, it's done its job and the info\n\t\t * has now been propagated into pg_control. We must get rid of the\n\t\t * label file so that if we crash during recovery, we'll pick up at\n\t\t * the latest recovery restartpoint instead of going all the way back\n\t\t * to the backup start point. It seems prudent though to just rename\n\t\t * the file out of the way rather than delete it completely.\n\t\t *\/\n\t\tif (haveBackupLabel)\n\t\t{\n\t\t\tunlink(BACKUP_LABEL_OLD);\n\t\t\tif (rename(BACKUP_LABEL_FILE, BACKUP_LABEL_OLD) != 0)\n\t\t\t\tereport(FATAL,\n\t\t\t\t\t\t(errcode_for_file_access(),\n\t\t\t\t\t\t errmsg(\"could not rename file \\\"%s\\\" to \\\"%s\\\": %m\",\n\t\t\t\t\t\t\t\tBACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));\n\t\t}\n\n\t\t\/* Check that the GUCs used to generate the WAL allow recovery *\/\n\t\tCheckRequiredParameterValues();\n\n\t\t\/*\n\t\t * We're in recovery, so unlogged relations may be trashed and must be\n\t\t * reset. This should be done BEFORE allowing Hot Standby\n\t\t * connections, so that read-only backends don't try to read whatever\n\t\t * garbage is left over from before.\n\t\t *\/\n\t\tResetUnloggedRelations(UNLOGGED_RELATION_CLEANUP);\n\n\t\t\/*\n\t\t * Likewise, delete any saved transaction snapshot files that got left\n\t\t * behind by crashed backends.\n\t\t *\/\n\t\tDeleteAllExportedSnapshotFiles();\n\n\t\t\/*\n\t\t * Initialize for Hot Standby, if enabled. We won't let backends in\n\t\t * yet, not until we've reached the min recovery point specified in\n\t\t * control file and we've established a recovery snapshot from a\n\t\t * running-xacts WAL record.\n\t\t *\/\n\t\tif (ArchiveRecoveryRequested && EnableHotStandby)\n\t\t{\n\t\t\tTransactionId *xids;\n\t\t\tint\t\t\tnxids;\n\n\t\t\tereport(DEBUG1,\n\t\t\t\t\t(errmsg(\"initializing for hot standby\")));\n\n\t\t\tInitRecoveryTransactionEnvironment();\n\n\t\t\tif (wasShutdown)\n\t\t\t\toldestActiveXID = PrescanPreparedTransactions(&xids, &nxids);\n\t\t\telse\n\t\t\t\toldestActiveXID = checkPoint.oldestActiveXid;\n\t\t\tAssert(TransactionIdIsValid(oldestActiveXID));\n\n\t\t\t\/* Tell procarray about the range of xids it has to deal with *\/\n\t\t\tProcArrayInitRecovery(ShmemVariableCache->nextXid);\n\n\t\t\t\/*\n\t\t\t * Startup commit log and subtrans only. MultiXact has already\n\t\t\t * been started up and other SLRUs are not maintained during\n\t\t\t * recovery and need not be started yet.\n\t\t\t *\/\n\t\t\tStartupCLOG();\n\t\t\tStartupSUBTRANS(oldestActiveXID);\n\n\t\t\t\/*\n\t\t\t * If we're beginning at a shutdown checkpoint, we know that\n\t\t\t * nothing was running on the master at this point. So fake-up an\n\t\t\t * empty running-xacts record and use that here and now. Recover\n\t\t\t * additional standby state for prepared transactions.\n\t\t\t *\/\n\t\t\tif (wasShutdown)\n\t\t\t{\n\t\t\t\tRunningTransactionsData running;\n\t\t\t\tTransactionId latestCompletedXid;\n\n\t\t\t\t\/*\n\t\t\t\t * Construct a RunningTransactions snapshot representing a\n\t\t\t\t * shut down server, with only prepared transactions still\n\t\t\t\t * alive. We're never overflowed at this point because all\n\t\t\t\t * subxids are listed with their parent prepared transactions.\n\t\t\t\t *\/\n\t\t\t\trunning.xcnt = nxids;\n\t\t\t\trunning.subxcnt = 0;\n\t\t\t\trunning.subxid_overflow = false;\n\t\t\t\trunning.nextXid = checkPoint.nextXid;\n\t\t\t\trunning.oldestRunningXid = oldestActiveXID;\n\t\t\t\tlatestCompletedXid = checkPoint.nextXid;\n\t\t\t\tTransactionIdRetreat(latestCompletedXid);\n\t\t\t\tAssert(TransactionIdIsNormal(latestCompletedXid));\n\t\t\t\trunning.latestCompletedXid = latestCompletedXid;\n\t\t\t\trunning.xids = xids;\n\n\t\t\t\tProcArrayApplyRecoveryInfo(&running);\n\n\t\t\t\tStandbyRecoverPreparedTransactions(false);\n\t\t\t}\n\t\t}\n\n\t\t\/* Initialize resource managers *\/\n\t\tfor (rmid = 0; rmid <= RM_MAX_ID; rmid++)\n\t\t{\n\t\t\tif (RmgrTable[rmid].rm_startup != NULL)\n\t\t\t\tRmgrTable[rmid].rm_startup();\n\t\t}\n\n\t\t\/*\n\t\t * Initialize shared variables for tracking progress of WAL replay,\n\t\t * as if we had just replayed the record before the REDO location.\n\t\t *\/\n\t\tSpinLockAcquire(&xlogctl->info_lck);\n\t\txlogctl->replayEndRecPtr = checkPoint.redo;\n\t\txlogctl->replayEndTLI = ThisTimeLineID;\n\t\txlogctl->lastReplayedEndRecPtr = checkPoint.redo;\n\t\txlogctl->lastReplayedTLI = ThisTimeLineID;\n\t\txlogctl->recoveryLastXTime = 0;\n\t\txlogctl->currentChunkStartTime = 0;\n\t\txlogctl->recoveryPause = false;\n\t\tSpinLockRelease(&xlogctl->info_lck);\n\n\t\t\/* Also ensure XLogReceiptTime has a sane value *\/\n\t\tXLogReceiptTime = GetCurrentTimestamp();\n\n\t\t\/*\n\t\t * Let postmaster know we've started redo now, so that it can launch\n\t\t * checkpointer to perform restartpoints. We don't bother during\n\t\t * crash recovery as restartpoints can only be performed during\n\t\t * archive recovery. And we'd like to keep crash recovery simple, to\n\t\t * avoid introducing bugs that could affect you when recovering after\n\t\t * crash.\n\t\t *\n\t\t * After this point, we can no longer assume that we're the only\n\t\t * process in addition to postmaster! Also, fsync requests are\n\t\t * subsequently to be handled by the checkpointer, not locally.\n\t\t *\/\n\t\tif (ArchiveRecoveryRequested && IsUnderPostmaster)\n\t\t{\n\t\t\tPublishStartupProcessInformation();\n\t\t\tSetForwardFsyncRequests();\n\t\t\tSendPostmasterSignal(PMSIGNAL_RECOVERY_STARTED);\n\t\t\tbgwriterLaunched = true;\n\t\t}\n\n\t\t\/*\n\t\t * Allow read-only connections immediately if we're consistent\n\t\t * already.\n\t\t *\/\n\t\tCheckRecoveryConsistency();\n\n\t\t\/*\n\t\t * Find the first record that logically follows the checkpoint --- it\n\t\t * might physically precede it, though.\n\t\t *\/\n\t\tif (checkPoint.redo < RecPtr)\n\t\t{\n\t\t\t\/* back up to find the record *\/\n\t\t\trecord = ReadRecord(xlogreader, checkPoint.redo, PANIC, false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\/* just have to read next record after CheckPoint *\/\n\t\t\trecord = ReadRecord(xlogreader, InvalidXLogRecPtr, LOG, false);\n\t\t}\n\n\t\tif (record != NULL)\n\t\t{\n\t\t\tErrorContextCallback errcallback;\n\t\t\tTimestampTz xtime;\n\n\t\t\tInRedo = true;\n\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"redo starts at %X\/%X\",\n\t\t\t\t\t\t (uint32) (ReadRecPtr >> 32), (uint32) ReadRecPtr)));\n\n\t\t\t\/*\n\t\t\t * main redo apply loop\n\t\t\t *\/\n\t\t\tdo\n\t\t\t{\n\t\t\t\tbool\t\tswitchedTLI = false;\n\n#ifdef WAL_DEBUG\n\t\t\t\tif (XLOG_DEBUG ||\n\t\t\t\t (rmid == RM_XACT_ID && trace_recovery_messages <= DEBUG2) ||\n\t\t\t\t\t(rmid != RM_XACT_ID && trace_recovery_messages <= DEBUG3))\n\t\t\t\t{\n\t\t\t\t\tStringInfoData buf;\n\n\t\t\t\t\tinitStringInfo(&buf);\n\t\t\t\t\tappendStringInfo(&buf, \"REDO @ %X\/%X; LSN %X\/%X: \",\n\t\t\t\t\t\t\t(uint32) (ReadRecPtr >> 32), (uint32) ReadRecPtr,\n\t\t\t\t\t\t\t (uint32) (EndRecPtr >> 32), (uint32) EndRecPtr);\n\t\t\t\t\txlog_outrec(&buf, record);\n\t\t\t\t\tappendStringInfoString(&buf, \" - \");\n\t\t\t\t\tRmgrTable[record->xl_rmid].rm_desc(&buf,\n\t\t\t\t\t\t\t\t\t\t\t\t\t record->xl_info,\n\t\t\t\t\t\t\t\t\t\t\t\t\t XLogRecGetData(record));\n\t\t\t\t\telog(LOG, \"%s\", buf.data);\n\t\t\t\t\tpfree(buf.data);\n\t\t\t\t}\n#endif\n\n\t\t\t\t\/* Handle interrupt signals of startup process *\/\n\t\t\t\tHandleStartupProcInterrupts();\n\n\t\t\t\t\/*\n\t\t\t\t * Pause WAL replay, if requested by a hot-standby session via\n\t\t\t\t * SetRecoveryPause().\n\t\t\t\t *\n\t\t\t\t * Note that we intentionally don't take the info_lck spinlock\n\t\t\t\t * here. We might therefore read a slightly stale value of\n\t\t\t\t * the recoveryPause flag, but it can't be very stale (no\n\t\t\t\t * worse than the last spinlock we did acquire). Since a\n\t\t\t\t * pause request is a pretty asynchronous thing anyway,\n\t\t\t\t * possibly responding to it one WAL record later than we\n\t\t\t\t * otherwise would is a minor issue, so it doesn't seem worth\n\t\t\t\t * adding another spinlock cycle to prevent that.\n\t\t\t\t *\/\n\t\t\t\tif (xlogctl->recoveryPause)\n\t\t\t\t\trecoveryPausesHere();\n\n\t\t\t\t\/*\n\t\t\t\t * Have we reached our recovery target?\n\t\t\t\t *\/\n\t\t\t\tif (recoveryStopsBefore(record))\n\t\t\t\t{\n\t\t\t\t\treachedStopPoint = true;\t\/* see below *\/\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * If we've been asked to lag the master, wait on\n\t\t\t\t * latch until enough time has passed.\n\t\t\t\t *\/\n\t\t\t\tif (recoveryApplyDelay(record))\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * We test for paused recovery again here. If\n\t\t\t\t\t * user sets delayed apply, it may be because\n\t\t\t\t\t * they expect to pause recovery in case of\n\t\t\t\t\t * problems, so we must test again here otherwise\n\t\t\t\t\t * pausing during the delay-wait wouldn't work.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (xlogctl->recoveryPause)\n\t\t\t\t\t\trecoveryPausesHere();\n\t\t\t\t}\n\n\t\t\t\t\/* Setup error traceback support for ereport() *\/\n\t\t\t\terrcallback.callback = rm_redo_error_callback;\n\t\t\t\terrcallback.arg = (void *) record;\n\t\t\t\terrcallback.previous = error_context_stack;\n\t\t\t\terror_context_stack = &errcallback;\n\n\t\t\t\t\/*\n\t\t\t\t * ShmemVariableCache->nextXid must be beyond record's xid.\n\t\t\t\t *\n\t\t\t\t * We don't expect anyone else to modify nextXid, hence we\n\t\t\t\t * don't need to hold a lock while examining it. We still\n\t\t\t\t * acquire the lock to modify it, though.\n\t\t\t\t *\/\n\t\t\t\tif (TransactionIdFollowsOrEquals(record->xl_xid,\n\t\t\t\t\t\t\t\t\t\t\t\t ShmemVariableCache->nextXid))\n\t\t\t\t{\n\t\t\t\t\tLWLockAcquire(XidGenLock, LW_EXCLUSIVE);\n\t\t\t\t\tShmemVariableCache->nextXid = record->xl_xid;\n\t\t\t\t\tTransactionIdAdvance(ShmemVariableCache->nextXid);\n\t\t\t\t\tLWLockRelease(XidGenLock);\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Before replaying this record, check if this record causes\n\t\t\t\t * the current timeline to change. The record is already\n\t\t\t\t * considered to be part of the new timeline, so we update\n\t\t\t\t * ThisTimeLineID before replaying it. That's important so\n\t\t\t\t * that replayEndTLI, which is recorded as the minimum\n\t\t\t\t * recovery point's TLI if recovery stops after this record,\n\t\t\t\t * is set correctly.\n\t\t\t\t *\/\n\t\t\t\tif (record->xl_rmid == RM_XLOG_ID)\n\t\t\t\t{\n\t\t\t\t\tTimeLineID\tnewTLI = ThisTimeLineID;\n\t\t\t\t\tTimeLineID\tprevTLI = ThisTimeLineID;\n\t\t\t\t\tuint8\t\tinfo = record->xl_info & ~XLR_INFO_MASK;\n\n\t\t\t\t\tif (info == XLOG_CHECKPOINT_SHUTDOWN)\n\t\t\t\t\t{\n\t\t\t\t\t\tCheckPoint\tcheckPoint;\n\n\t\t\t\t\t\tmemcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));\n\t\t\t\t\t\tnewTLI = checkPoint.ThisTimeLineID;\n\t\t\t\t\t\tprevTLI = checkPoint.PrevTimeLineID;\n\t\t\t\t\t}\n\t\t\t\t\telse if (info == XLOG_END_OF_RECOVERY)\n\t\t\t\t\t{\n\t\t\t\t\t\txl_end_of_recovery xlrec;\n\n\t\t\t\t\t\tmemcpy(&xlrec, XLogRecGetData(record), sizeof(xl_end_of_recovery));\n\t\t\t\t\t\tnewTLI = xlrec.ThisTimeLineID;\n\t\t\t\t\t\tprevTLI = xlrec.PrevTimeLineID;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (newTLI != ThisTimeLineID)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Check that it's OK to switch to this TLI *\/\n\t\t\t\t\t\tcheckTimeLineSwitch(EndRecPtr, newTLI, prevTLI);\n\n\t\t\t\t\t\t\/* Following WAL records should be run with new TLI *\/\n\t\t\t\t\t\tThisTimeLineID = newTLI;\n\t\t\t\t\t\tswitchedTLI = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Update shared replayEndRecPtr before replaying this record,\n\t\t\t\t * so that XLogFlush will update minRecoveryPoint correctly.\n\t\t\t\t *\/\n\t\t\t\tSpinLockAcquire(&xlogctl->info_lck);\n\t\t\t\txlogctl->replayEndRecPtr = EndRecPtr;\n\t\t\t\txlogctl->replayEndTLI = ThisTimeLineID;\n\t\t\t\tSpinLockRelease(&xlogctl->info_lck);\n\n\t\t\t\t\/*\n\t\t\t\t * If we are attempting to enter Hot Standby mode, process\n\t\t\t\t * XIDs we see\n\t\t\t\t *\/\n\t\t\t\tif (standbyState >= STANDBY_INITIALIZED &&\n\t\t\t\t\tTransactionIdIsValid(record->xl_xid))\n\t\t\t\t\tRecordKnownAssignedTransactionIds(record->xl_xid);\n\n\t\t\t\t\/* Now apply the WAL record itself *\/\n\t\t\t\tRmgrTable[record->xl_rmid].rm_redo(EndRecPtr, record);\n\n\t\t\t\t\/* Pop the error context stack *\/\n\t\t\t\terror_context_stack = errcallback.previous;\n\n\t\t\t\t\/*\n\t\t\t\t * Update lastReplayedEndRecPtr after this record has been\n\t\t\t\t * successfully replayed.\n\t\t\t\t *\/\n\t\t\t\tSpinLockAcquire(&xlogctl->info_lck);\n\t\t\t\txlogctl->lastReplayedEndRecPtr = EndRecPtr;\n\t\t\t\txlogctl->lastReplayedTLI = ThisTimeLineID;\n\t\t\t\tSpinLockRelease(&xlogctl->info_lck);\n\n\t\t\t\t\/* Remember this record as the last-applied one *\/\n\t\t\t\tLastRec = ReadRecPtr;\n\n\t\t\t\t\/* Allow read-only connections if we're consistent now *\/\n\t\t\t\tCheckRecoveryConsistency();\n\n\t\t\t\t\/*\n\t\t\t\t * If this record was a timeline switch, wake up any\n\t\t\t\t * walsenders to notice that we are on a new timeline.\n\t\t\t\t *\/\n\t\t\t\tif (switchedTLI && AllowCascadeReplication())\n\t\t\t\t\tWalSndWakeup();\n\n\t\t\t\t\/* Exit loop if we reached inclusive recovery target *\/\n\t\t\t\tif (recoveryStopsAfter(record))\n\t\t\t\t{\n\t\t\t\t\treachedStopPoint = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t\/* Else, try to fetch the next WAL record *\/\n\t\t\t\trecord = ReadRecord(xlogreader, InvalidXLogRecPtr, LOG, false);\n\t\t\t} while (record != NULL);\n\n\t\t\t\/*\n\t\t\t * end of main redo apply loop\n\t\t\t *\/\n\n\t\t\tif (recoveryPauseAtTarget && reachedStopPoint)\n\t\t\t{\n\t\t\t\tSetRecoveryPause(true);\n\t\t\t\trecoveryPausesHere();\n\t\t\t}\n\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"redo done at %X\/%X\",\n\t\t\t\t\t\t (uint32) (ReadRecPtr >> 32), (uint32) ReadRecPtr)));\n\t\t\txtime = GetLatestXTime();\n\t\t\tif (xtime)\n\t\t\t\tereport(LOG,\n\t\t\t\t\t (errmsg(\"last completed transaction was at log time %s\",\n\t\t\t\t\t\t\t timestamptz_to_str(xtime))));\n\t\t\tInRedo = false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\/* there are no WAL records following the checkpoint *\/\n\t\t\tereport(LOG,\n\t\t\t\t\t(errmsg(\"redo is not required\")));\n\t\t}\n\t}\n\n\t\/*\n\t * Kill WAL receiver, if it's still running, before we continue to write\n\t * the startup checkpoint record. It will trump over the checkpoint and\n\t * subsequent records if it's still alive when we start writing WAL.\n\t *\/\n\tShutdownWalRcv();\n\n\t\/*\n\t * We don't need the latch anymore. It's not strictly necessary to disown\n\t * it, but let's do it for the sake of tidiness.\n\t *\/\n\tif (StandbyModeRequested)\n\t\tDisownLatch(&XLogCtl->recoveryWakeupLatch);\n\n\t\/*\n\t * We are now done reading the xlog from stream. Turn off streaming\n\t * recovery to force fetching the files (which would be required at end of\n\t * recovery, e.g., timeline history file) from archive or pg_xlog.\n\t *\/\n\tStandbyMode = false;\n\n\t\/*\n\t * Re-fetch the last valid or last applied record, so we can identify the\n\t * exact endpoint of what we consider the valid portion of WAL.\n\t *\/\n\trecord = ReadRecord(xlogreader, LastRec, PANIC, false);\n\tEndOfLog = EndRecPtr;\n\tXLByteToPrevSeg(EndOfLog, endLogSegNo);\n\n\t\/*\n\t * Complain if we did not roll forward far enough to render the backup\n\t * dump consistent. Note: it is indeed okay to look at the local variable\n\t * minRecoveryPoint here, even though ControlFile->minRecoveryPoint might\n\t * be further ahead --- ControlFile->minRecoveryPoint cannot have been\n\t * advanced beyond the WAL we processed.\n\t *\/\n\tif (InRecovery &&\n\t\t(EndOfLog < minRecoveryPoint ||\n\t\t !XLogRecPtrIsInvalid(ControlFile->backupStartPoint)))\n\t{\n\t\tif (reachedStopPoint)\n\t\t{\n\t\t\t\/* stopped because of stop request *\/\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errmsg(\"requested recovery stop point is before consistent recovery point\")));\n\t\t}\n\n\t\t\/*\n\t\t * Ran off end of WAL before reaching end-of-backup WAL record, or\n\t\t * minRecoveryPoint. That's usually a bad sign, indicating that you\n\t\t * tried to recover from an online backup but never called\n\t\t * pg_stop_backup(), or you didn't archive all the WAL up to that\n\t\t * point. However, this also happens in crash recovery, if the system\n\t\t * crashes while an online backup is in progress. We must not treat\n\t\t * that as an error, or the database will refuse to start up.\n\t\t *\/\n\t\tif (ArchiveRecoveryRequested || ControlFile->backupEndRequired)\n\t\t{\n\t\t\tif (ControlFile->backupEndRequired)\n\t\t\t\tereport(FATAL,\n\t\t\t\t\t\t(errmsg(\"WAL ends before end of online backup\"),\n\t\t\t\t\t\t errhint(\"All WAL generated while online backup was taken must be available at recovery.\")));\n\t\t\telse if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))\n\t\t\t\tereport(FATAL,\n\t\t\t\t\t\t(errmsg(\"WAL ends before end of online backup\"),\n\t\t\t\t\t\t errhint(\"Online backup started with pg_start_backup() must be ended with pg_stop_backup(), and all WAL up to that point must be available at recovery.\")));\n\t\t\telse\n\t\t\t\tereport(FATAL,\n\t\t\t\t\t (errmsg(\"WAL ends before consistent recovery point\")));\n\t\t}\n\t}\n\n\t\/*\n\t * Consider whether we need to assign a new timeline ID.\n\t *\n\t * If we are doing an archive recovery, we always assign a new ID.\tThis\n\t * handles a couple of issues.\tIf we stopped short of the end of WAL\n\t * during recovery, then we are clearly generating a new timeline and must\n\t * assign it a unique new ID. Even if we ran to the end, modifying the\n\t * current last segment is problematic because it may result in trying to\n\t * overwrite an already-archived copy of that segment, and we encourage\n\t * DBAs to make their archive_commands reject that. We can dodge the\n\t * problem by making the new active segment have a new timeline ID.\n\t *\n\t * In a normal crash recovery, we can just extend the timeline we were in.\n\t *\/\n\tPrevTimeLineID = ThisTimeLineID;\n\tif (ArchiveRecoveryRequested)\n\t{\n\t\tchar\t\treason[200];\n\n\t\tAssert(InArchiveRecovery);\n\n\t\tThisTimeLineID = findNewestTimeLine(recoveryTargetTLI) + 1;\n\t\tereport(LOG,\n\t\t\t\t(errmsg(\"selected new timeline ID: %u\", ThisTimeLineID)));\n\n\t\t\/*\n\t\t * Create a comment for the history file to explain why and where\n\t\t * timeline changed.\n\t\t *\/\n\t\tif (recoveryTarget == RECOVERY_TARGET_XID)\n\t\t\tsnprintf(reason, sizeof(reason),\n\t\t\t\t\t \"%s transaction %u\",\n\t\t\t\t\t recoveryStopAfter ? \"after\" : \"before\",\n\t\t\t\t\t recoveryStopXid);\n\t\telse if (recoveryTarget == RECOVERY_TARGET_TIME)\n\t\t\tsnprintf(reason, sizeof(reason),\n\t\t\t\t\t \"%s %s\\n\",\n\t\t\t\t\t recoveryStopAfter ? \"after\" : \"before\",\n\t\t\t\t\t timestamptz_to_str(recoveryStopTime));\n\t\telse if (recoveryTarget == RECOVERY_TARGET_NAME)\n\t\t\tsnprintf(reason, sizeof(reason),\n\t\t\t\t\t \"at restore point \\\"%s\\\"\",\n\t\t\t\t\t recoveryStopName);\n\t\telse if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE)\n\t\t\tsnprintf(reason, sizeof(reason), \"reached consistency\");\n\t\telse\n\t\t\tsnprintf(reason, sizeof(reason), \"no recovery target specified\");\n\n\t\twriteTimeLineHistory(ThisTimeLineID, recoveryTargetTLI,\n\t\t\t\t\t\t\t EndRecPtr, reason);\n\t}\n\n\t\/* Save the selected TimeLineID in shared memory, too *\/\n\tXLogCtl->ThisTimeLineID = ThisTimeLineID;\n\tXLogCtl->PrevTimeLineID = PrevTimeLineID;\n\n\t\/*\n\t * We are now done reading the old WAL. Turn off archive fetching if it\n\t * was active, and make a writable copy of the last WAL segment. (Note\n\t * that we also have a copy of the last block of the old WAL in readBuf;\n\t * we will use that below.)\n\t *\/\n\tif (ArchiveRecoveryRequested)\n\t\texitArchiveRecovery(xlogreader->readPageTLI, endLogSegNo);\n\n\t\/*\n\t * Prepare to write WAL starting at EndOfLog position, and init xlog\n\t * buffer cache using the block containing the last record from the\n\t * previous incarnation.\n\t *\/\n\topenLogSegNo = endLogSegNo;\n\topenLogFile = XLogFileOpen(openLogSegNo);\n\topenLogOff = 0;\n\tInsert = &XLogCtl->Insert;\n\tInsert->PrevBytePos = XLogRecPtrToBytePos(LastRec);\n\tInsert->CurrBytePos = XLogRecPtrToBytePos(EndOfLog);\n\n\t\/*\n\t * Tricky point here: readBuf contains the *last* block that the LastRec\n\t * record spans, not the one it starts in.\tThe last block is indeed the\n\t * one we want to use.\n\t *\/\n\tif (EndOfLog % XLOG_BLCKSZ != 0)\n\t{\n\t\tchar\t *page;\n\t\tint\t\t\tlen;\n\t\tint\t\t\tfirstIdx;\n\t\tXLogRecPtr\tpageBeginPtr;\n\n\t\tpageBeginPtr = EndOfLog - (EndOfLog % XLOG_BLCKSZ);\n\t\tAssert(readOff == pageBeginPtr % XLogSegSize);\n\n\t\tfirstIdx = XLogRecPtrToBufIdx(EndOfLog);\n\n\t\t\/* Copy the valid part of the last block, and zero the rest *\/\n\t\tpage = &XLogCtl->pages[firstIdx * XLOG_BLCKSZ];\n\t\tlen = EndOfLog % XLOG_BLCKSZ;\n\t\tmemcpy(page, xlogreader->readBuf, len);\n\t\tmemset(page + len, 0, XLOG_BLCKSZ - len);\n\n\t\tXLogCtl->xlblocks[firstIdx] = pageBeginPtr + XLOG_BLCKSZ;\n\t\tXLogCtl->InitializedUpTo = pageBeginPtr + XLOG_BLCKSZ;\n\t}\n\telse\n\t{\n\t\t\/*\n\t\t * There is no partial block to copy. Just set InitializedUpTo,\n\t\t * and let the first attempt to insert a log record to initialize\n\t\t * the next buffer.\n\t\t *\/\n\t\tXLogCtl->InitializedUpTo = EndOfLog;\n\t}\n\n\tLogwrtResult.Write = LogwrtResult.Flush = EndOfLog;\n\n\tXLogCtl->LogwrtResult = LogwrtResult;\n\n\tXLogCtl->LogwrtRqst.Write = EndOfLog;\n\tXLogCtl->LogwrtRqst.Flush = EndOfLog;\n\n\t\/* Pre-scan prepared transactions to find out the range of XIDs present *\/\n\toldestActiveXID = PrescanPreparedTransactions(NULL, NULL);\n\n\t\/*\n\t * Update full_page_writes in shared memory and write an XLOG_FPW_CHANGE\n\t * record before resource manager writes cleanup WAL records or checkpoint\n\t * record is written.\n\t *\/\n\tInsert->fullPageWrites = lastFullPageWrites;\n\tLocalSetXLogInsertAllowed();\n\tUpdateFullPageWrites();\n\tLocalXLogInsertAllowed = -1;\n\n\tif (InRecovery)\n\t{\n\t\tint\t\t\trmid;\n\n\t\t\/*\n\t\t * Resource managers might need to write WAL records, eg, to record\n\t\t * index cleanup actions. So temporarily enable XLogInsertAllowed in\n\t\t * this process only.\n\t\t *\/\n\t\tLocalSetXLogInsertAllowed();\n\n\t\t\/*\n\t\t * Allow resource managers to do any required cleanup.\n\t\t *\/\n\t\tfor (rmid = 0; rmid <= RM_MAX_ID; rmid++)\n\t\t{\n\t\t\tif (RmgrTable[rmid].rm_cleanup != NULL)\n\t\t\t\tRmgrTable[rmid].rm_cleanup();\n\t\t}\n\n\t\t\/* Disallow XLogInsert again *\/\n\t\tLocalXLogInsertAllowed = -1;\n\n\t\t\/*\n\t\t * Perform a checkpoint to update all our recovery activity to disk.\n\t\t *\n\t\t * Note that we write a shutdown checkpoint rather than an on-line\n\t\t * one. This is not particularly critical, but since we may be\n\t\t * assigning a new TLI, using a shutdown checkpoint allows us to have\n\t\t * the rule that TLI only changes in shutdown checkpoints, which\n\t\t * allows some extra error checking in xlog_redo.\n\t\t *\n\t\t * In fast promotion, only create a lightweight end-of-recovery record\n\t\t * instead of a full checkpoint. A checkpoint is requested later,\n\t\t * after we're fully out of recovery mode and already accepting\n\t\t * queries.\n\t\t *\/\n\t\tif (bgwriterLaunched)\n\t\t{\n\t\t\tif (fast_promote)\n\t\t\t{\n\t\t\t\tcheckPointLoc = ControlFile->prevCheckPoint;\n\n\t\t\t\t\/*\n\t\t\t\t * Confirm the last checkpoint is available for us to recover\n\t\t\t\t * from if we fail. Note that we don't check for the secondary\n\t\t\t\t * checkpoint since that isn't available in most base backups.\n\t\t\t\t *\/\n\t\t\t\trecord = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, false);\n\t\t\t\tif (record != NULL)\n\t\t\t\t{\n\t\t\t\t\tfast_promoted = true;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Insert a special WAL record to mark the end of\n\t\t\t\t\t * recovery, since we aren't doing a checkpoint. That\n\t\t\t\t\t * means that the checkpointer process may likely be in\n\t\t\t\t\t * the middle of a time-smoothed restartpoint and could\n\t\t\t\t\t * continue to be for minutes after this. That sounds\n\t\t\t\t\t * strange, but the effect is roughly the same and it\n\t\t\t\t\t * would be stranger to try to come out of the\n\t\t\t\t\t * restartpoint and then checkpoint. We request a\n\t\t\t\t\t * checkpoint later anyway, just for safety.\n\t\t\t\t\t *\/\n\t\t\t\t\tCreateEndOfRecoveryRecord();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!fast_promoted)\n\t\t\t\tRequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |\n\t\t\t\t\t\t\t\t CHECKPOINT_IMMEDIATE |\n\t\t\t\t\t\t\t\t CHECKPOINT_WAIT);\n\t\t}\n\t\telse\n\t\t\tCreateCheckPoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE);\n\n\t\t\/*\n\t\t * And finally, execute the recovery_end_command, if any.\n\t\t *\/\n\t\tif (recoveryEndCommand)\n\t\t\tExecuteRecoveryCommand(recoveryEndCommand,\n\t\t\t\t\t\t\t\t \"recovery_end_command\",\n\t\t\t\t\t\t\t\t true);\n\t}\n\n\t\/*\n\t * Preallocate additional log files, if wanted.\n\t *\/\n\tPreallocXlogFiles(EndOfLog);\n\n\t\/*\n\t * Reset initial contents of unlogged relations. This has to be done\n\t * AFTER recovery is complete so that any unlogged relations created\n\t * during recovery also get picked up.\n\t *\/\n\tif (InRecovery)\n\t\tResetUnloggedRelations(UNLOGGED_RELATION_INIT);\n\n\t\/*\n\t * Okay, we're officially UP.\n\t *\/\n\tInRecovery = false;\n\n\tLWLockAcquire(ControlFileLock, LW_EXCLUSIVE);\n\tControlFile->state = DB_IN_PRODUCTION;\n\tControlFile->time = (pg_time_t) time(NULL);\n\tUpdateControlFile();\n\tLWLockRelease(ControlFileLock);\n\n\t\/* start the archive_timeout timer running *\/\n\tXLogCtl->lastSegSwitchTime = (pg_time_t) time(NULL);\n\n\t\/* also initialize latestCompletedXid, to nextXid - 1 *\/\n\tLWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);\n\tShmemVariableCache->latestCompletedXid = ShmemVariableCache->nextXid;\n\tTransactionIdRetreat(ShmemVariableCache->latestCompletedXid);\n\tLWLockRelease(ProcArrayLock);\n\n\t\/*\n\t * Start up the commit log and subtrans, if not already done for hot\n\t * standby.\n\t *\/\n\tif (standbyState == STANDBY_DISABLED)\n\t{\n\t\tStartupCLOG();\n\t\tStartupSUBTRANS(oldestActiveXID);\n\t}\n\n\t\/*\n\t * Perform end of recovery actions for any SLRUs that need it.\n\t *\/\n\tTrimCLOG();\n\tTrimMultiXact();\n\n\t\/* Reload shared-memory state for prepared transactions *\/\n\tRecoverPreparedTransactions();\n\n\t\/*\n\t * Shutdown the recovery environment. This must occur after\n\t * RecoverPreparedTransactions(), see notes for lock_twophase_recover()\n\t *\/\n\tif (standbyState != STANDBY_DISABLED)\n\t\tShutdownRecoveryTransactionEnvironment();\n\n\t\/* Shut down xlogreader *\/\n\tif (readFile >= 0)\n\t{\n\t\tclose(readFile);\n\t\treadFile = -1;\n\t}\n\tXLogReaderFree(xlogreader);\n\n\t\/*\n\t * If any of the critical GUCs have changed, log them before we allow\n\t * backends to write WAL.\n\t *\/\n\tLocalSetXLogInsertAllowed();\n\tXLogReportParameters();\n\n\t\/*\n\t * All done. Allow backends to write WAL.\t(Although the bool flag is\n\t * probably atomic in itself, we use the info_lck here to ensure that\n\t * there are no race conditions concerning visibility of other recent\n\t * updates to shared memory.)\n\t *\/\n\t{\n\t\t\/* use volatile pointer to prevent code rearrangement *\/\n\t\tvolatile XLogCtlData *xlogctl = XLogCtl;\n\n\t\tSpinLockAcquire(&xlogctl->info_lck);\n\t\txlogctl->SharedRecoveryInProgress = false;\n\t\tSpinLockRelease(&xlogctl->info_lck);\n\t}\n\n\t\/*\n\t * If there were cascading standby servers connected to us, nudge any wal\n\t * sender processes to notice that we've been promoted.\n\t *\/\n\tWalSndWakeup();\n\n\t\/*\n\t * If this was a fast promotion, request an (online) checkpoint now. This\n\t * isn't required for consistency, but the last restartpoint might be far\n\t * back, and in case of a crash, recovering from it might take a longer\n\t * than is appropriate now that we're not in standby mode anymore.\n\t *\/\n\tif (fast_promoted)\n\t\tRequestCheckpoint(CHECKPOINT_FORCE);\n}","target":0,"code_token_length":11526,"total_token_length":11762,"max_tokens_setting":28000} +{"idx":18217,"func":"static int cert_status_cb ( SSL * s , void * arg ) {\n tlsextstatusctx * srctx = arg ;\n BIO * err = srctx -> err ;\n char * host , * port , * path ;\n int use_ssl ;\n unsigned char * rspder = NULL ;\n int rspderlen ;\n STACK_OF ( OPENSSL_STRING ) * aia = NULL ;\n X509 * x = NULL ;\n X509_STORE_CTX inctx ;\n X509_OBJECT obj ;\n OCSP_REQUEST * req = NULL ;\n OCSP_RESPONSE * resp = NULL ;\n OCSP_CERTID * id = NULL ;\n STACK_OF ( X509_EXTENSION ) * exts ;\n int ret = SSL_TLSEXT_ERR_NOACK ;\n int i ;\n # if 0 STACK_OF ( OCSP_RESPID ) * ids ;\n SSL_get_tlsext_status_ids ( s , & ids ) ;\n BIO_printf ( err , \"cert_status: received %d ids\\n\" , sk_OCSP_RESPID_num ( ids ) ) ;\n # endif if ( srctx -> verbose ) BIO_puts ( err , \"cert_status: callback called\\n\" ) ;\n x = SSL_get_certificate ( s ) ;\n aia = X509_get1_ocsp ( x ) ;\n if ( aia ) {\n if ( ! OCSP_parse_url ( sk_OPENSSL_STRING_value ( aia , 0 ) , & host , & port , & path , & use_ssl ) ) {\n BIO_puts ( err , \"cert_status: can't parse AIA URL\\n\" ) ;\n goto err ;\n }\n if ( srctx -> verbose ) BIO_printf ( err , \"cert_status: AIA URL: %s\\n\" , sk_OPENSSL_STRING_value ( aia , 0 ) ) ;\n }\n else {\n if ( ! srctx -> host ) {\n BIO_puts ( srctx -> err , \"cert_status: no AIA and no default responder URL\\n\" ) ;\n goto done ;\n }\n host = srctx -> host ;\n path = srctx -> path ;\n port = srctx -> port ;\n use_ssl = srctx -> use_ssl ;\n }\n if ( ! X509_STORE_CTX_init ( & inctx , SSL_CTX_get_cert_store ( SSL_get_SSL_CTX ( s ) ) , NULL , NULL ) ) goto err ;\n if ( X509_STORE_get_by_subject ( & inctx , X509_LU_X509 , X509_get_issuer_name ( x ) , & obj ) <= 0 ) {\n BIO_puts ( err , \"cert_status: Can't retrieve issuer certificate.\\n\" ) ;\n X509_STORE_CTX_cleanup ( & inctx ) ;\n goto done ;\n }\n req = OCSP_REQUEST_new ( ) ;\n if ( ! req ) goto err ;\n id = OCSP_cert_to_id ( NULL , x , obj . data . x509 ) ;\n X509_free ( obj . data . x509 ) ;\n X509_STORE_CTX_cleanup ( & inctx ) ;\n if ( ! id ) goto err ;\n if ( ! OCSP_request_add0_id ( req , id ) ) goto err ;\n id = NULL ;\n SSL_get_tlsext_status_exts ( s , & exts ) ;\n for ( i = 0 ;\n i < sk_X509_EXTENSION_num ( exts ) ;\n i ++ ) {\n X509_EXTENSION * ext = sk_X509_EXTENSION_value ( exts , i ) ;\n if ( ! OCSP_REQUEST_add_ext ( req , ext , - 1 ) ) goto err ;\n }\n resp = process_responder ( err , req , host , path , port , use_ssl , NULL , srctx -> timeout ) ;\n if ( ! resp ) {\n BIO_puts ( err , \"cert_status: error querying responder\\n\" ) ;\n goto done ;\n }\n rspderlen = i2d_OCSP_RESPONSE ( resp , & rspder ) ;\n if ( rspderlen <= 0 ) goto err ;\n SSL_set_tlsext_status_ocsp_resp ( s , rspder , rspderlen ) ;\n if ( srctx -> verbose ) {\n BIO_puts ( err , \"cert_status: ocsp response sent:\\n\" ) ;\n OCSP_RESPONSE_print ( err , resp , 2 ) ;\n }\n ret = SSL_TLSEXT_ERR_OK ;\n done : if ( ret != SSL_TLSEXT_ERR_OK ) ERR_print_errors ( err ) ;\n if ( aia ) {\n OPENSSL_free ( host ) ;\n OPENSSL_free ( path ) ;\n OPENSSL_free ( port ) ;\n X509_email_free ( aia ) ;\n }\n if ( id ) OCSP_CERTID_free ( id ) ;\n if ( req ) OCSP_REQUEST_free ( req ) ;\n if ( resp ) OCSP_RESPONSE_free ( resp ) ;\n return ret ;\n err : ret = SSL_TLSEXT_ERR_ALERT_FATAL ;\n goto done ;\n }\n # ifndef OPENSSL_NO_NEXTPROTONEG typedef struct tlsextnextprotoctx_st {\n unsigned char * data ;\n unsigned int len ;\n }\n tlsextnextprotoctx ;\n static int next_proto_cb ( SSL * s , const unsigned char * * data , unsigned int * len , void * arg ) {\n tlsextnextprotoctx * next_proto = arg ;\n * data = next_proto -> data ;\n * len = next_proto -> len ;\n return SSL_TLSEXT_ERR_OK ;\n }\n # endif # endif int MAIN ( int , char * * ) ;\n # ifndef OPENSSL_NO_JPAKE static char * jpake_secret = NULL ;\n # endif # ifndef OPENSSL_NO_SRP static srpsrvparm srp_callback_parm ;\n # endif # ifndef OPENSSL_NO_SRTP static char * srtp_profiles = NULL ;\n # endif int MAIN ( int argc , char * argv [ ] ) {\n X509_VERIFY_PARAM * vpm = NULL ;\n int badarg = 0 ;\n short port = PORT ;\n char * CApath = NULL , * CAfile = NULL ;\n unsigned char * context = NULL ;\n char * dhfile = NULL ;\n # ifndef OPENSSL_NO_ECDH char * named_curve = NULL ;\n # endif int badop = 0 , bugs = 0 ;\n int ret = 1 ;\n int off = 0 ;\n int no_tmp_rsa = 0 , no_dhe = 0 , nocert = 0 ;\n # ifndef OPENSSL_NO_ECDH int no_ecdhe = 0 ;\n # endif int state = 0 ;\n const SSL_METHOD * meth = NULL ;\n int socket_type = SOCK_STREAM ;\n ENGINE * e = NULL ;\n char * inrand = NULL ;\n int s_cert_format = FORMAT_PEM , s_key_format = FORMAT_PEM ;\n char * passarg = NULL , * pass = NULL ;\n char * dpassarg = NULL , * dpass = NULL ;\n int s_dcert_format = FORMAT_PEM , s_dkey_format = FORMAT_PEM ;\n X509 * s_cert = NULL , * s_dcert = NULL ;\n EVP_PKEY * s_key = NULL , * s_dkey = NULL ;\n int no_cache = 0 ;\n # ifndef OPENSSL_NO_TLSEXT EVP_PKEY * s_key2 = NULL ;\n X509 * s_cert2 = NULL ;\n tlsextctx tlsextcbp = {\n NULL , NULL , SSL_TLSEXT_ERR_ALERT_WARNING }\n ;\n # ifndef OPENSSL_NO_NEXTPROTONEG const char * next_proto_neg_in = NULL ;\n tlsextnextprotoctx next_proto ;\n # endif # endif # ifndef OPENSSL_NO_PSK static char * psk_identity_hint = NULL ;\n # endif # ifndef OPENSSL_NO_SRP char * srpuserseed = NULL ;\n char * srp_verifier_file = NULL ;\n # endif meth = SSLv23_server_method ( ) ;\n local_argc = argc ;\n local_argv = argv ;\n apps_startup ( ) ;\n # ifdef MONOLITH s_server_init ( ) ;\n # endif if ( bio_err == NULL ) bio_err = BIO_new_fp ( stderr , BIO_NOCLOSE ) ;\n if ( ! load_config ( bio_err , NULL ) ) goto end ;\n verify_depth = 0 ;\n # ifdef FIONBIO s_nbio = 0 ;\n # endif s_nbio_test = 0 ;\n argc -- ;\n argv ++ ;\n while ( argc >= 1 ) {\n if ( ( strcmp ( * argv , \"-port\" ) == 0 ) || ( strcmp ( * argv , \"-accept\" ) == 0 ) ) {\n if ( -- argc < 1 ) goto bad ;\n if ( ! extract_port ( * ( ++ argv ) , & port ) ) goto bad ;\n }\n else if ( strcmp ( * argv , \"-verify\" ) == 0 ) {\n s_server_verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE ;\n if ( -- argc < 1 ) goto bad ;\n verify_depth = atoi ( * ( ++ argv ) ) ;\n BIO_printf ( bio_err , \"verify depth is %d\\n\" , verify_depth ) ;\n }\n else if ( strcmp ( * argv , \"-Verify\" ) == 0 ) {\n s_server_verify = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE ;\n if ( -- argc < 1 ) goto bad ;\n verify_depth = atoi ( * ( ++ argv ) ) ;\n BIO_printf ( bio_err , \"verify depth is %d, must return a certificate\\n\" , verify_depth ) ;\n }\n else if ( strcmp ( * argv , \"-context\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n context = ( unsigned char * ) * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-cert\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_cert_file = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-certform\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_cert_format = str2fmt ( * ( ++ argv ) ) ;\n }\n else if ( strcmp ( * argv , \"-key\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_key_file = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-keyform\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_key_format = str2fmt ( * ( ++ argv ) ) ;\n }\n else if ( strcmp ( * argv , \"-pass\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n passarg = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-dhparam\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n dhfile = * ( ++ argv ) ;\n }\n # ifndef OPENSSL_NO_ECDH else if ( strcmp ( * argv , \"-named_curve\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n named_curve = * ( ++ argv ) ;\n }\n # endif else if ( strcmp ( * argv , \"-dcertform\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_dcert_format = str2fmt ( * ( ++ argv ) ) ;\n }\n else if ( strcmp ( * argv , \"-dcert\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_dcert_file = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-dkeyform\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_dkey_format = str2fmt ( * ( ++ argv ) ) ;\n }\n else if ( strcmp ( * argv , \"-dpass\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n dpassarg = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-dkey\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_dkey_file = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-nocert\" ) == 0 ) {\n nocert = 1 ;\n }\n else if ( strcmp ( * argv , \"-CApath\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n CApath = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-no_cache\" ) == 0 ) no_cache = 1 ;\n else if ( args_verify ( & argv , & argc , & badarg , bio_err , & vpm ) ) {\n if ( badarg ) goto bad ;\n continue ;\n }\n else if ( strcmp ( * argv , \"-verify_return_error\" ) == 0 ) verify_return_error = 1 ;\n else if ( strcmp ( * argv , \"-serverpref\" ) == 0 ) {\n off |= SSL_OP_CIPHER_SERVER_PREFERENCE ;\n }\n else if ( strcmp ( * argv , \"-legacy_renegotiation\" ) == 0 ) off |= SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION ;\n else if ( strcmp ( * argv , \"-cipher\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n cipher = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-CAfile\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n CAfile = * ( ++ argv ) ;\n }\n # ifdef FIONBIO else if ( strcmp ( * argv , \"-nbio\" ) == 0 ) {\n s_nbio = 1 ;\n }\n # endif else if ( strcmp ( * argv , \"-nbio_test\" ) == 0 ) {\n # ifdef FIONBIO s_nbio = 1 ;\n # endif s_nbio_test = 1 ;\n }\n else if ( strcmp ( * argv , \"-debug\" ) == 0 ) {\n s_debug = 1 ;\n }\n # ifndef OPENSSL_NO_TLSEXT else if ( strcmp ( * argv , \"-tlsextdebug\" ) == 0 ) s_tlsextdebug = 1 ;\n else if ( strcmp ( * argv , \"-status\" ) == 0 ) s_tlsextstatus = 1 ;\n else if ( strcmp ( * argv , \"-status_verbose\" ) == 0 ) {\n s_tlsextstatus = 1 ;\n tlscstatp . verbose = 1 ;\n }\n else if ( ! strcmp ( * argv , \"-status_timeout\" ) ) {\n s_tlsextstatus = 1 ;\n if ( -- argc < 1 ) goto bad ;\n tlscstatp . timeout = atoi ( * ( ++ argv ) ) ;\n }\n else if ( ! strcmp ( * argv , \"-status_url\" ) ) {\n s_tlsextstatus = 1 ;\n if ( -- argc < 1 ) goto bad ;\n if ( ! OCSP_parse_url ( * ( ++ argv ) , & tlscstatp . host , & tlscstatp . port , & tlscstatp . path , & tlscstatp . use_ssl ) ) {\n BIO_printf ( bio_err , \"Error parsing URL\\n\" ) ;\n goto bad ;\n }\n }\n # endif else if ( strcmp ( * argv , \"-msg\" ) == 0 ) {\n s_msg = 1 ;\n }\n else if ( strcmp ( * argv , \"-hack\" ) == 0 ) {\n hack = 1 ;\n }\n else if ( strcmp ( * argv , \"-state\" ) == 0 ) {\n state = 1 ;\n }\n else if ( strcmp ( * argv , \"-crlf\" ) == 0 ) {\n s_crlf = 1 ;\n }\n else if ( strcmp ( * argv , \"-quiet\" ) == 0 ) {\n s_quiet = 1 ;\n }\n else if ( strcmp ( * argv , \"-bugs\" ) == 0 ) {\n bugs = 1 ;\n }\n else if ( strcmp ( * argv , \"-no_tmp_rsa\" ) == 0 ) {\n no_tmp_rsa = 1 ;\n }\n else if ( strcmp ( * argv , \"-no_dhe\" ) == 0 ) {\n no_dhe = 1 ;\n }\n # ifndef OPENSSL_NO_ECDH else if ( strcmp ( * argv , \"-no_ecdhe\" ) == 0 ) {\n no_ecdhe = 1 ;\n }\n # endif # ifndef OPENSSL_NO_PSK else if ( strcmp ( * argv , \"-psk_hint\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n psk_identity_hint = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-psk\" ) == 0 ) {\n size_t i ;\n if ( -- argc < 1 ) goto bad ;\n psk_key = * ( ++ argv ) ;\n for ( i = 0 ;\n i < strlen ( psk_key ) ;\n i ++ ) {\n if ( isxdigit ( ( unsigned char ) psk_key [ i ] ) ) continue ;\n BIO_printf ( bio_err , \"Not a hex number '%s'\\n\" , * argv ) ;\n goto bad ;\n }\n }\n # endif # ifndef OPENSSL_NO_SRP else if ( strcmp ( * argv , \"-srpvfile\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n srp_verifier_file = * ( ++ argv ) ;\n meth = TLSv1_server_method ( ) ;\n }\n else if ( strcmp ( * argv , \"-srpuserseed\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n srpuserseed = * ( ++ argv ) ;\n meth = TLSv1_server_method ( ) ;\n }\n # endif else if ( strcmp ( * argv , \"-www\" ) == 0 ) {\n www = 1 ;\n }\n else if ( strcmp ( * argv , \"-WWW\" ) == 0 ) {\n www = 2 ;\n }\n else if ( strcmp ( * argv , \"-HTTP\" ) == 0 ) {\n www = 3 ;\n }\n else if ( strcmp ( * argv , \"-no_ssl2\" ) == 0 ) {\n off |= SSL_OP_NO_SSLv2 ;\n }\n else if ( strcmp ( * argv , \"-no_ssl3\" ) == 0 ) {\n off |= SSL_OP_NO_SSLv3 ;\n }\n else if ( strcmp ( * argv , \"-no_tls1\" ) == 0 ) {\n off |= SSL_OP_NO_TLSv1 ;\n }\n else if ( strcmp ( * argv , \"-no_tls1_1\" ) == 0 ) {\n off |= SSL_OP_NO_TLSv1_1 ;\n }\n else if ( strcmp ( * argv , \"-no_tls1_2\" ) == 0 ) {\n off |= SSL_OP_NO_TLSv1_2 ;\n }\n else if ( strcmp ( * argv , \"-no_comp\" ) == 0 ) {\n off |= SSL_OP_NO_COMPRESSION ;\n }\n # ifndef OPENSSL_NO_TLSEXT else if ( strcmp ( * argv , \"-no_ticket\" ) == 0 ) {\n off |= SSL_OP_NO_TICKET ;\n }\n # endif # ifndef OPENSSL_NO_SSL2 else if ( strcmp ( * argv , \"-ssl2\" ) == 0 ) {\n meth = SSLv2_server_method ( ) ;\n }\n # endif # ifndef OPENSSL_NO_SSL3_METHOD else if ( strcmp ( * argv , \"-ssl3\" ) == 0 ) {\n meth = SSLv3_server_method ( ) ;\n }\n # endif # ifndef OPENSSL_NO_TLS1 else if ( strcmp ( * argv , \"-tls1\" ) == 0 ) {\n meth = TLSv1_server_method ( ) ;\n }\n else if ( strcmp ( * argv , \"-tls1_1\" ) == 0 ) {\n meth = TLSv1_1_server_method ( ) ;\n }\n else if ( strcmp ( * argv , \"-tls1_2\" ) == 0 ) {\n meth = TLSv1_2_server_method ( ) ;\n }\n # endif # ifndef OPENSSL_NO_DTLS1 else if ( strcmp ( * argv , \"-dtls1\" ) == 0 ) {\n meth = DTLSv1_server_method ( ) ;\n socket_type = SOCK_DGRAM ;\n }\n else if ( strcmp ( * argv , \"-timeout\" ) == 0 ) enable_timeouts = 1 ;\n else if ( strcmp ( * argv , \"-mtu\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n socket_mtu = atol ( * ( ++ argv ) ) ;\n }\n else if ( strcmp ( * argv , \"-chain\" ) == 0 ) cert_chain = 1 ;\n # endif else if ( strcmp ( * argv , \"-id_prefix\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n session_id_prefix = * ( ++ argv ) ;\n }\n # ifndef OPENSSL_NO_ENGINE else if ( strcmp ( * argv , \"-engine\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n engine_id = * ( ++ argv ) ;\n }\n # endif else if ( strcmp ( * argv , \"-rand\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n inrand = * ( ++ argv ) ;\n }\n # ifndef OPENSSL_NO_TLSEXT else if ( strcmp ( * argv , \"-servername\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n tlsextcbp . servername = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-servername_fatal\" ) == 0 ) {\n tlsextcbp . extension_error = SSL_TLSEXT_ERR_ALERT_FATAL ;\n }\n else if ( strcmp ( * argv , \"-cert2\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_cert_file2 = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-key2\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n s_key_file2 = * ( ++ argv ) ;\n }\n # ifndef OPENSSL_NO_NEXTPROTONEG else if ( strcmp ( * argv , \"-nextprotoneg\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n next_proto_neg_in = * ( ++ argv ) ;\n }\n # endif # endif # if ! defined ( OPENSSL_NO_JPAKE ) && ! defined ( OPENSSL_NO_PSK ) else if ( strcmp ( * argv , \"-jpake\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n jpake_secret = * ( ++ argv ) ;\n }\n # endif # ifndef OPENSSL_NO_SRTP else if ( strcmp ( * argv , \"-use_srtp\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n srtp_profiles = * ( ++ argv ) ;\n }\n # endif else if ( strcmp ( * argv , \"-keymatexport\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n keymatexportlabel = * ( ++ argv ) ;\n }\n else if ( strcmp ( * argv , \"-keymatexportlen\" ) == 0 ) {\n if ( -- argc < 1 ) goto bad ;\n keymatexportlen = atoi ( * ( ++ argv ) ) ;\n if ( keymatexportlen == 0 ) goto bad ;\n }\n else {\n BIO_printf ( bio_err , \"unknown option %s\\n\" , * argv ) ;\n badop = 1 ;\n break ;\n }\n argc -- ;\n argv ++ ;\n }\n if ( badop ) {\n bad : sv_usage ( ) ;\n goto end ;\n }\n # ifndef OPENSSL_NO_DTLS1 if ( www && socket_type == SOCK_DGRAM ) {\n BIO_printf ( bio_err , \"Can't use -HTTP, -www or -WWW with DTLS\\n\" ) ;\n goto end ;\n }\n # endif # if ! defined ( OPENSSL_NO_JPAKE ) && ! defined ( OPENSSL_NO_PSK ) if ( jpake_secret ) {\n if ( psk_key ) {\n BIO_printf ( bio_err , \"Can't use JPAKE and PSK together\\n\" ) ;\n goto end ;\n }\n psk_identity = \"JPAKE\" ;\n if ( cipher ) {\n BIO_printf ( bio_err , \"JPAKE sets cipher to PSK\\n\" ) ;\n goto end ;\n }\n cipher = \"PSK\" ;\n }\n # endif SSL_load_error_strings ( ) ;\n OpenSSL_add_ssl_algorithms ( ) ;\n # ifndef OPENSSL_NO_ENGINE e = setup_engine ( bio_err , engine_id , 1 ) ;\n # endif if ( ! app_passwd ( bio_err , passarg , dpassarg , & pass , & dpass ) ) {\n BIO_printf ( bio_err , \"Error getting password\\n\" ) ;\n goto end ;\n }\n if ( s_key_file == NULL ) s_key_file = s_cert_file ;\n # ifndef OPENSSL_NO_TLSEXT if ( s_key_file2 == NULL ) s_key_file2 = s_cert_file2 ;\n # endif if ( nocert == 0 ) {\n s_key = load_key ( bio_err , s_key_file , s_key_format , 0 , pass , e , \"server certificate private key file\" ) ;\n if ( ! s_key ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n s_cert = load_cert ( bio_err , s_cert_file , s_cert_format , NULL , e , \"server certificate file\" ) ;\n if ( ! s_cert ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n # ifndef OPENSSL_NO_TLSEXT if ( tlsextcbp . servername ) {\n s_key2 = load_key ( bio_err , s_key_file2 , s_key_format , 0 , pass , e , \"second server certificate private key file\" ) ;\n if ( ! s_key2 ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n s_cert2 = load_cert ( bio_err , s_cert_file2 , s_cert_format , NULL , e , \"second server certificate file\" ) ;\n if ( ! s_cert2 ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n }\n # endif }\n # if ! defined ( OPENSSL_NO_TLSEXT ) && ! defined ( OPENSSL_NO_NEXTPROTONEG ) if ( next_proto_neg_in ) {\n unsigned short len ;\n next_proto . data = next_protos_parse ( & len , next_proto_neg_in ) ;\n if ( next_proto . data == NULL ) goto end ;\n next_proto . len = len ;\n }\n else {\n next_proto . data = NULL ;\n }\n # endif if ( s_dcert_file ) {\n if ( s_dkey_file == NULL ) s_dkey_file = s_dcert_file ;\n s_dkey = load_key ( bio_err , s_dkey_file , s_dkey_format , 0 , dpass , e , \"second certificate private key file\" ) ;\n if ( ! s_dkey ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n s_dcert = load_cert ( bio_err , s_dcert_file , s_dcert_format , NULL , e , \"second server certificate file\" ) ;\n if ( ! s_dcert ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n }\n if ( ! app_RAND_load_file ( NULL , bio_err , 1 ) && inrand == NULL && ! RAND_status ( ) ) {\n BIO_printf ( bio_err , \"warning, not much extra random data, consider using the -rand option\\n\" ) ;\n }\n if ( inrand != NULL ) BIO_printf ( bio_err , \"%ld semi-random bytes loaded\\n\" , app_RAND_load_files ( inrand ) ) ;\n if ( bio_s_out == NULL ) {\n if ( s_quiet && ! s_debug && ! s_msg ) {\n bio_s_out = BIO_new ( BIO_s_null ( ) ) ;\n }\n else {\n if ( bio_s_out == NULL ) bio_s_out = BIO_new_fp ( stdout , BIO_NOCLOSE ) ;\n }\n }\n # if ! defined ( OPENSSL_NO_RSA ) || ! defined ( OPENSSL_NO_DSA ) || ! defined ( OPENSSL_NO_ECDSA ) if ( nocert ) # endif {\n s_cert_file = NULL ;\n s_key_file = NULL ;\n s_dcert_file = NULL ;\n s_dkey_file = NULL ;\n # ifndef OPENSSL_NO_TLSEXT s_cert_file2 = NULL ;\n s_key_file2 = NULL ;\n # endif }\n ctx = SSL_CTX_new ( meth ) ;\n if ( ctx == NULL ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n if ( session_id_prefix ) {\n if ( strlen ( session_id_prefix ) >= 32 ) BIO_printf ( bio_err , \"warning: id_prefix is too long, only one new session will be possible\\n\" ) ;\n else if ( strlen ( session_id_prefix ) >= 16 ) BIO_printf ( bio_err , \"warning: id_prefix is too long if you use SSLv2\\n\" ) ;\n if ( ! SSL_CTX_set_generate_session_id ( ctx , generate_session_id ) ) {\n BIO_printf ( bio_err , \"error setting 'id_prefix'\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n BIO_printf ( bio_err , \"id_prefix '%s' set.\\n\" , session_id_prefix ) ;\n }\n SSL_CTX_set_quiet_shutdown ( ctx , 1 ) ;\n if ( bugs ) SSL_CTX_set_options ( ctx , SSL_OP_ALL ) ;\n if ( hack ) SSL_CTX_set_options ( ctx , SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG ) ;\n SSL_CTX_set_options ( ctx , off ) ;\n if ( state ) SSL_CTX_set_info_callback ( ctx , apps_ssl_info_callback ) ;\n if ( no_cache ) SSL_CTX_set_session_cache_mode ( ctx , SSL_SESS_CACHE_OFF ) ;\n else SSL_CTX_sess_set_cache_size ( ctx , 128 ) ;\n # ifndef OPENSSL_NO_SRTP if ( srtp_profiles != NULL ) SSL_CTX_set_tlsext_use_srtp ( ctx , srtp_profiles ) ;\n # endif # if 0 if ( cipher == NULL ) cipher = getenv ( \"SSL_CIPHER\" ) ;\n # endif # if 0 if ( s_cert_file == NULL ) {\n BIO_printf ( bio_err , \"You must specify a certificate file for the server to use\\n\" ) ;\n goto end ;\n }\n # endif if ( ( ! SSL_CTX_load_verify_locations ( ctx , CAfile , CApath ) ) || ( ! SSL_CTX_set_default_verify_paths ( ctx ) ) ) {\n ERR_print_errors ( bio_err ) ;\n }\n if ( vpm ) SSL_CTX_set1_param ( ctx , vpm ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( s_cert2 ) {\n ctx2 = SSL_CTX_new ( meth ) ;\n if ( ctx2 == NULL ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n }\n if ( ctx2 ) {\n BIO_printf ( bio_s_out , \"Setting secondary ctx parameters\\n\" ) ;\n if ( session_id_prefix ) {\n if ( strlen ( session_id_prefix ) >= 32 ) BIO_printf ( bio_err , \"warning: id_prefix is too long, only one new session will be possible\\n\" ) ;\n else if ( strlen ( session_id_prefix ) >= 16 ) BIO_printf ( bio_err , \"warning: id_prefix is too long if you use SSLv2\\n\" ) ;\n if ( ! SSL_CTX_set_generate_session_id ( ctx2 , generate_session_id ) ) {\n BIO_printf ( bio_err , \"error setting 'id_prefix'\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n BIO_printf ( bio_err , \"id_prefix '%s' set.\\n\" , session_id_prefix ) ;\n }\n SSL_CTX_set_quiet_shutdown ( ctx2 , 1 ) ;\n if ( bugs ) SSL_CTX_set_options ( ctx2 , SSL_OP_ALL ) ;\n if ( hack ) SSL_CTX_set_options ( ctx2 , SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG ) ;\n SSL_CTX_set_options ( ctx2 , off ) ;\n if ( state ) SSL_CTX_set_info_callback ( ctx2 , apps_ssl_info_callback ) ;\n if ( no_cache ) SSL_CTX_set_session_cache_mode ( ctx2 , SSL_SESS_CACHE_OFF ) ;\n else SSL_CTX_sess_set_cache_size ( ctx2 , 128 ) ;\n if ( ( ! SSL_CTX_load_verify_locations ( ctx2 , CAfile , CApath ) ) || ( ! SSL_CTX_set_default_verify_paths ( ctx2 ) ) ) {\n ERR_print_errors ( bio_err ) ;\n }\n if ( vpm ) SSL_CTX_set1_param ( ctx2 , vpm ) ;\n }\n # ifndef OPENSSL_NO_NEXTPROTONEG if ( next_proto . data ) SSL_CTX_set_next_protos_advertised_cb ( ctx , next_proto_cb , & next_proto ) ;\n # endif # endif # ifndef OPENSSL_NO_DH if ( ! no_dhe ) {\n DH * dh = NULL ;\n if ( dhfile ) dh = load_dh_param ( dhfile ) ;\n else if ( s_cert_file ) dh = load_dh_param ( s_cert_file ) ;\n if ( dh != NULL ) {\n BIO_printf ( bio_s_out , \"Setting temp DH parameters\\n\" ) ;\n }\n else {\n BIO_printf ( bio_s_out , \"Using default temp DH parameters\\n\" ) ;\n dh = get_dh2048 ( ) ;\n if ( dh == NULL ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n }\n ( void ) BIO_flush ( bio_s_out ) ;\n SSL_CTX_set_tmp_dh ( ctx , dh ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 ) {\n if ( ! dhfile ) {\n DH * dh2 = load_dh_param ( s_cert_file2 ) ;\n if ( dh2 != NULL ) {\n BIO_printf ( bio_s_out , \"Setting temp DH parameters\\n\" ) ;\n ( void ) BIO_flush ( bio_s_out ) ;\n DH_free ( dh ) ;\n dh = dh2 ;\n }\n }\n SSL_CTX_set_tmp_dh ( ctx2 , dh ) ;\n }\n # endif DH_free ( dh ) ;\n }\n # endif # ifndef OPENSSL_NO_ECDH if ( ! no_ecdhe ) {\n EC_KEY * ecdh = NULL ;\n if ( named_curve ) {\n int nid = OBJ_sn2nid ( named_curve ) ;\n if ( nid == 0 ) {\n BIO_printf ( bio_err , \"unknown curve name (%s)\\n\" , named_curve ) ;\n goto end ;\n }\n ecdh = EC_KEY_new_by_curve_name ( nid ) ;\n if ( ecdh == NULL ) {\n BIO_printf ( bio_err , \"unable to create curve (%s)\\n\" , named_curve ) ;\n goto end ;\n }\n }\n if ( ecdh != NULL ) {\n BIO_printf ( bio_s_out , \"Setting temp ECDH parameters\\n\" ) ;\n }\n else {\n BIO_printf ( bio_s_out , \"Using default temp ECDH parameters\\n\" ) ;\n ecdh = EC_KEY_new_by_curve_name ( NID_X9_62_prime256v1 ) ;\n if ( ecdh == NULL ) {\n BIO_printf ( bio_err , \"unable to create curve (nistp256)\\n\" ) ;\n goto end ;\n }\n }\n ( void ) BIO_flush ( bio_s_out ) ;\n SSL_CTX_set_tmp_ecdh ( ctx , ecdh ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 ) SSL_CTX_set_tmp_ecdh ( ctx2 , ecdh ) ;\n # endif EC_KEY_free ( ecdh ) ;\n }\n # endif if ( ! set_cert_key_stuff ( ctx , s_cert , s_key ) ) goto end ;\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 && ! set_cert_key_stuff ( ctx2 , s_cert2 , s_key2 ) ) goto end ;\n # endif if ( s_dcert != NULL ) {\n if ( ! set_cert_key_stuff ( ctx , s_dcert , s_dkey ) ) goto end ;\n }\n # ifndef OPENSSL_NO_RSA # if 1 if ( ! no_tmp_rsa ) {\n SSL_CTX_set_tmp_rsa_callback ( ctx , tmp_rsa_cb ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 ) SSL_CTX_set_tmp_rsa_callback ( ctx2 , tmp_rsa_cb ) ;\n # endif }\n # else if ( ! no_tmp_rsa && SSL_CTX_need_tmp_RSA ( ctx ) ) {\n RSA * rsa ;\n BIO_printf ( bio_s_out , \"Generating temp (512 bit) RSA key...\" ) ;\n BIO_flush ( bio_s_out ) ;\n rsa = RSA_generate_key ( 512 , RSA_F4 , NULL ) ;\n if ( ! SSL_CTX_set_tmp_rsa ( ctx , rsa ) ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 ) {\n if ( ! SSL_CTX_set_tmp_rsa ( ctx2 , rsa ) ) {\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n }\n # endif RSA_free ( rsa ) ;\n BIO_printf ( bio_s_out , \"\\n\" ) ;\n }\n # endif # endif # ifndef OPENSSL_NO_PSK # ifdef OPENSSL_NO_JPAKE if ( psk_key != NULL ) # else if ( psk_key != NULL || jpake_secret ) # endif {\n if ( s_debug ) BIO_printf ( bio_s_out , \"PSK key given or JPAKE in use, setting server callback\\n\" ) ;\n SSL_CTX_set_psk_server_callback ( ctx , psk_server_cb ) ;\n }\n if ( ! SSL_CTX_use_psk_identity_hint ( ctx , psk_identity_hint ) ) {\n BIO_printf ( bio_err , \"error setting PSK identity hint to context\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n # endif if ( cipher != NULL ) {\n if ( ! SSL_CTX_set_cipher_list ( ctx , cipher ) ) {\n BIO_printf ( bio_err , \"error setting cipher list\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 && ! SSL_CTX_set_cipher_list ( ctx2 , cipher ) ) {\n BIO_printf ( bio_err , \"error setting cipher list\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n goto end ;\n }\n # endif }\n SSL_CTX_set_verify ( ctx , s_server_verify , verify_callback ) ;\n SSL_CTX_set_session_id_context ( ctx , ( void * ) & s_server_session_id_context , sizeof s_server_session_id_context ) ;\n SSL_CTX_set_cookie_generate_cb ( ctx , generate_cookie_callback ) ;\n SSL_CTX_set_cookie_verify_cb ( ctx , verify_cookie_callback ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 ) {\n SSL_CTX_set_verify ( ctx2 , s_server_verify , verify_callback ) ;\n SSL_CTX_set_session_id_context ( ctx2 , ( void * ) & s_server_session_id_context , sizeof s_server_session_id_context ) ;\n tlsextcbp . biodebug = bio_s_out ;\n SSL_CTX_set_tlsext_servername_callback ( ctx2 , ssl_servername_cb ) ;\n SSL_CTX_set_tlsext_servername_arg ( ctx2 , & tlsextcbp ) ;\n SSL_CTX_set_tlsext_servername_callback ( ctx , ssl_servername_cb ) ;\n SSL_CTX_set_tlsext_servername_arg ( ctx , & tlsextcbp ) ;\n }\n # endif # ifndef OPENSSL_NO_SRP if ( srp_verifier_file != NULL ) {\n srp_callback_parm . vb = SRP_VBASE_new ( srpuserseed ) ;\n srp_callback_parm . user = NULL ;\n srp_callback_parm . login = NULL ;\n if ( ( ret = SRP_VBASE_init ( srp_callback_parm . vb , srp_verifier_file ) ) != SRP_NO_ERROR ) {\n BIO_printf ( bio_err , \"Cannot initialize SRP verifier file \\\"%s\\\":ret=%d\\n\" , srp_verifier_file , ret ) ;\n goto end ;\n }\n SSL_CTX_set_verify ( ctx , SSL_VERIFY_NONE , verify_callback ) ;\n SSL_CTX_set_srp_cb_arg ( ctx , & srp_callback_parm ) ;\n SSL_CTX_set_srp_username_callback ( ctx , ssl_srp_server_param_cb ) ;\n }\n else # endif if ( CAfile != NULL ) {\n SSL_CTX_set_client_CA_list ( ctx , SSL_load_client_CA_file ( CAfile ) ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( ctx2 ) SSL_CTX_set_client_CA_list ( ctx2 , SSL_load_client_CA_file ( CAfile ) ) ;\n # endif }\n BIO_printf ( bio_s_out , \"ACCEPT\\n\" ) ;\n ( void ) BIO_flush ( bio_s_out ) ;\n if ( www ) do_server ( port , socket_type , & accept_socket , www_body , context ) ;\n else do_server ( port , socket_type , & accept_socket , sv_body , context ) ;\n print_stats ( bio_s_out , ctx ) ;\n ret = 0 ;\n end : if ( ctx != NULL ) SSL_CTX_free ( ctx ) ;\n if ( s_cert ) X509_free ( s_cert ) ;\n if ( s_dcert ) X509_free ( s_dcert ) ;\n if ( s_key ) EVP_PKEY_free ( s_key ) ;\n if ( s_dkey ) EVP_PKEY_free ( s_dkey ) ;\n if ( pass ) OPENSSL_free ( pass ) ;\n if ( dpass ) OPENSSL_free ( dpass ) ;\n if ( vpm ) X509_VERIFY_PARAM_free ( vpm ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( tlscstatp . host ) OPENSSL_free ( tlscstatp . host ) ;\n if ( tlscstatp . port ) OPENSSL_free ( tlscstatp . port ) ;\n if ( tlscstatp . path ) OPENSSL_free ( tlscstatp . path ) ;\n if ( ctx2 != NULL ) SSL_CTX_free ( ctx2 ) ;\n if ( s_cert2 ) X509_free ( s_cert2 ) ;\n if ( s_key2 ) EVP_PKEY_free ( s_key2 ) ;\n # endif if ( bio_s_out != NULL ) {\n BIO_free ( bio_s_out ) ;\n bio_s_out = NULL ;\n }\n apps_shutdown ( ) ;\n OPENSSL_EXIT ( ret ) ;\n }\n static void print_stats ( BIO * bio , SSL_CTX * ssl_ctx ) {\n BIO_printf ( bio , \"%4ld items in the session cache\\n\" , SSL_CTX_sess_number ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld client connects (SSL_connect())\\n\" , SSL_CTX_sess_connect ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld client renegotiates (SSL_connect())\\n\" , SSL_CTX_sess_connect_renegotiate ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld client connects that finished\\n\" , SSL_CTX_sess_connect_good ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld server accepts (SSL_accept())\\n\" , SSL_CTX_sess_accept ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld server renegotiates (SSL_accept())\\n\" , SSL_CTX_sess_accept_renegotiate ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld server accepts that finished\\n\" , SSL_CTX_sess_accept_good ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld session cache hits\\n\" , SSL_CTX_sess_hits ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld session cache misses\\n\" , SSL_CTX_sess_misses ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld session cache timeouts\\n\" , SSL_CTX_sess_timeouts ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld callback cache hits\\n\" , SSL_CTX_sess_cb_hits ( ssl_ctx ) ) ;\n BIO_printf ( bio , \"%4ld cache full overflows (%ld allowed)\\n\" , SSL_CTX_sess_cache_full ( ssl_ctx ) , SSL_CTX_sess_get_cache_size ( ssl_ctx ) ) ;\n }\n static int sv_body ( char * hostname , int s , unsigned char * context ) {\n char * buf = NULL ;\n fd_set readfds ;\n int ret = 1 , width ;\n int k , i ;\n unsigned long l ;\n SSL * con = NULL ;\n BIO * sbio ;\n # ifndef OPENSSL_NO_KRB5 KSSL_CTX * kctx ;\n # endif struct timeval timeout ;\n # if defined ( OPENSSL_SYS_WINDOWS ) || defined ( OPENSSL_SYS_MSDOS ) || defined ( OPENSSL_SYS_NETWARE ) || defined ( OPENSSL_SYS_BEOS_R5 ) struct timeval tv ;\n # else struct timeval * timeoutp ;\n # endif if ( ( buf = OPENSSL_malloc ( bufsize ) ) == NULL ) {\n BIO_printf ( bio_err , \"out of memory\\n\" ) ;\n goto err ;\n }\n # ifdef FIONBIO if ( s_nbio ) {\n unsigned long sl = 1 ;\n if ( ! s_quiet ) BIO_printf ( bio_err , \"turning on non blocking io\\n\" ) ;\n if ( BIO_socket_ioctl ( s , FIONBIO , & sl ) < 0 ) ERR_print_errors ( bio_err ) ;\n }\n # endif if ( con == NULL ) {\n con = SSL_new ( ctx ) ;\n # ifndef OPENSSL_NO_TLSEXT if ( s_tlsextdebug ) {\n SSL_set_tlsext_debug_callback ( con , tlsext_cb ) ;\n SSL_set_tlsext_debug_arg ( con , bio_s_out ) ;\n }\n if ( s_tlsextstatus ) {\n SSL_CTX_set_tlsext_status_cb ( ctx , cert_status_cb ) ;\n tlscstatp . err = bio_err ;\n SSL_CTX_set_tlsext_status_arg ( ctx , & tlscstatp ) ;\n }\n # endif # ifndef OPENSSL_NO_KRB5 if ( ( kctx = kssl_ctx_new ( ) ) != NULL ) {\n SSL_set0_kssl_ctx ( con , kctx ) ;\n kssl_ctx_setstring ( kctx , KSSL_SERVICE , KRB5SVC ) ;\n kssl_ctx_setstring ( kctx , KSSL_KEYTAB , KRB5KEYTAB ) ;\n }\n # endif if ( context ) SSL_set_session_id_context ( con , context , strlen ( ( char * ) context ) ) ;\n }\n SSL_clear ( con ) ;\n # if 0 # ifdef TLSEXT_TYPE_opaque_prf_input SSL_set_tlsext_opaque_prf_input ( con , \"Test server\" , 11 ) ;\n # endif # endif if ( SSL_version ( con ) == DTLS1_VERSION ) {\n sbio = BIO_new_dgram ( s , BIO_NOCLOSE ) ;\n if ( enable_timeouts ) {\n timeout . tv_sec = 0 ;\n timeout . tv_usec = DGRAM_RCV_TIMEOUT ;\n BIO_ctrl ( sbio , BIO_CTRL_DGRAM_SET_RECV_TIMEOUT , 0 , & timeout ) ;\n timeout . tv_sec = 0 ;\n timeout . tv_usec = DGRAM_SND_TIMEOUT ;\n BIO_ctrl ( sbio , BIO_CTRL_DGRAM_SET_SEND_TIMEOUT , 0 , & timeout ) ;\n }\n if ( socket_mtu ) {\n if ( socket_mtu < DTLS_get_link_min_mtu ( con ) ) {\n BIO_printf ( bio_err , \"MTU too small. Must be at least %ld\\n\" , DTLS_get_link_min_mtu ( con ) ) ;\n ret = - 1 ;\n BIO_free ( sbio ) ;\n goto err ;\n }\n SSL_set_options ( con , SSL_OP_NO_QUERY_MTU ) ;\n if ( ! DTLS_set_link_mtu ( con , socket_mtu ) ) {\n BIO_printf ( bio_err , \"Failed to set MTU\\n\" ) ;\n ret = - 1 ;\n BIO_free ( sbio ) ;\n goto err ;\n }\n }\n else BIO_ctrl ( sbio , BIO_CTRL_DGRAM_MTU_DISCOVER , 0 , NULL ) ;\n SSL_set_options ( con , SSL_OP_COOKIE_EXCHANGE ) ;\n }\n else sbio = BIO_new_socket ( s , BIO_NOCLOSE ) ;\n if ( s_nbio_test ) {\n BIO * test ;\n test = BIO_new ( BIO_f_nbio_test ( ) ) ;\n sbio = BIO_push ( test , sbio ) ;\n }\n # ifndef OPENSSL_NO_JPAKE if ( jpake_secret ) jpake_server_auth ( bio_s_out , sbio , jpake_secret ) ;\n # endif SSL_set_bio ( con , sbio , sbio ) ;\n SSL_set_accept_state ( con ) ;\n if ( s_debug ) {\n SSL_set_debug ( con , 1 ) ;\n BIO_set_callback ( SSL_get_rbio ( con ) , bio_dump_callback ) ;\n BIO_set_callback_arg ( SSL_get_rbio ( con ) , ( char * ) bio_s_out ) ;\n }\n if ( s_msg ) {\n SSL_set_msg_callback ( con , msg_cb ) ;\n SSL_set_msg_callback_arg ( con , bio_s_out ) ;\n }\n # ifndef OPENSSL_NO_TLSEXT if ( s_tlsextdebug ) {\n SSL_set_tlsext_debug_callback ( con , tlsext_cb ) ;\n SSL_set_tlsext_debug_arg ( con , bio_s_out ) ;\n }\n # endif width = s + 1 ;\n for ( ;\n ;\n ) {\n int read_from_terminal ;\n int read_from_sslcon ;\n read_from_terminal = 0 ;\n read_from_sslcon = SSL_pending ( con ) ;\n if ( ! read_from_sslcon ) {\n FD_ZERO ( & readfds ) ;\n # if ! defined ( OPENSSL_SYS_WINDOWS ) && ! defined ( OPENSSL_SYS_MSDOS ) && ! defined ( OPENSSL_SYS_NETWARE ) && ! defined ( OPENSSL_SYS_BEOS_R5 ) openssl_fdset ( fileno ( stdin ) , & readfds ) ;\n # endif openssl_fdset ( s , & readfds ) ;\n # if defined ( OPENSSL_SYS_WINDOWS ) || defined ( OPENSSL_SYS_MSDOS ) || defined ( OPENSSL_SYS_NETWARE ) tv . tv_sec = 1 ;\n tv . tv_usec = 0 ;\n i = select ( width , ( void * ) & readfds , NULL , NULL , & tv ) ;\n if ( ( i < 0 ) || ( ! i && ! _kbhit ( ) ) ) continue ;\n if ( _kbhit ( ) ) read_from_terminal = 1 ;\n # elif defined ( OPENSSL_SYS_BEOS_R5 ) tv . tv_sec = 1 ;\n tv . tv_usec = 0 ;\n ( void ) fcntl ( fileno ( stdin ) , F_SETFL , O_NONBLOCK ) ;\n i = select ( width , ( void * ) & readfds , NULL , NULL , & tv ) ;\n if ( ( i < 0 ) || ( ! i && read ( fileno ( stdin ) , buf , 0 ) < 0 ) ) continue ;\n if ( read ( fileno ( stdin ) , buf , 0 ) >= 0 ) read_from_terminal = 1 ;\n ( void ) fcntl ( fileno ( stdin ) , F_SETFL , 0 ) ;\n # else if ( ( SSL_version ( con ) == DTLS1_VERSION ) && DTLSv1_get_timeout ( con , & timeout ) ) timeoutp = & timeout ;\n else timeoutp = NULL ;\n i = select ( width , ( void * ) & readfds , NULL , NULL , timeoutp ) ;\n if ( ( SSL_version ( con ) == DTLS1_VERSION ) && DTLSv1_handle_timeout ( con ) > 0 ) {\n BIO_printf ( bio_err , \"TIMEOUT occured\\n\" ) ;\n }\n if ( i <= 0 ) continue ;\n if ( FD_ISSET ( fileno ( stdin ) , & readfds ) ) read_from_terminal = 1 ;\n # endif if ( FD_ISSET ( s , & readfds ) ) read_from_sslcon = 1 ;\n }\n if ( read_from_terminal ) {\n if ( s_crlf ) {\n int j , lf_num ;\n i = raw_read_stdin ( buf , bufsize \/ 2 ) ;\n lf_num = 0 ;\n for ( j = 0 ;\n j < i ;\n j ++ ) if ( buf [ j ] == '\\n' ) lf_num ++ ;\n for ( j = i - 1 ;\n j >= 0 ;\n j -- ) {\n buf [ j + lf_num ] = buf [ j ] ;\n if ( buf [ j ] == '\\n' ) {\n lf_num -- ;\n i ++ ;\n buf [ j + lf_num ] = '\\r' ;\n }\n }\n assert ( lf_num == 0 ) ;\n }\n else i = raw_read_stdin ( buf , bufsize ) ;\n if ( ! s_quiet ) {\n if ( ( i <= 0 ) || ( buf [ 0 ] == 'Q' ) ) {\n BIO_printf ( bio_s_out , \"DONE\\n\" ) ;\n SHUTDOWN ( s ) ;\n close_accept_socket ( ) ;\n ret = - 11 ;\n goto err ;\n }\n if ( ( i <= 0 ) || ( buf [ 0 ] == 'q' ) ) {\n BIO_printf ( bio_s_out , \"DONE\\n\" ) ;\n if ( SSL_version ( con ) != DTLS1_VERSION ) SHUTDOWN ( s ) ;\n goto err ;\n }\n # ifndef OPENSSL_NO_HEARTBEATS if ( ( buf [ 0 ] == 'B' ) && ( ( buf [ 1 ] == '\\n' ) || ( buf [ 1 ] == '\\r' ) ) ) {\n BIO_printf ( bio_err , \"HEARTBEATING\\n\" ) ;\n SSL_heartbeat ( con ) ;\n i = 0 ;\n continue ;\n }\n # endif if ( ( buf [ 0 ] == 'r' ) && ( ( buf [ 1 ] == '\\n' ) || ( buf [ 1 ] == '\\r' ) ) ) {\n SSL_renegotiate ( con ) ;\n i = SSL_do_handshake ( con ) ;\n printf ( \"SSL_do_handshake -> %d\\n\" , i ) ;\n i = 0 ;\n continue ;\n }\n if ( ( buf [ 0 ] == 'R' ) && ( ( buf [ 1 ] == '\\n' ) || ( buf [ 1 ] == '\\r' ) ) ) {\n SSL_set_verify ( con , SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE , NULL ) ;\n SSL_renegotiate ( con ) ;\n i = SSL_do_handshake ( con ) ;\n printf ( \"SSL_do_handshake -> %d\\n\" , i ) ;\n i = 0 ;\n continue ;\n }\n if ( buf [ 0 ] == 'P' ) {\n static const char * str = \"Lets print some clear text\\n\" ;\n BIO_write ( SSL_get_wbio ( con ) , str , strlen ( str ) ) ;\n }\n if ( buf [ 0 ] == 'S' ) {\n print_stats ( bio_s_out , SSL_get_SSL_CTX ( con ) ) ;\n }\n }\n # ifdef CHARSET_EBCDIC ebcdic2ascii ( buf , buf , i ) ;\n # endif l = k = 0 ;\n for ( ;\n ;\n ) {\n # ifdef RENEG {\n static count = 0 ;\n if ( ++ count == 100 ) {\n count = 0 ;\n SSL_renegotiate ( con ) ;\n }\n }\n # endif k = SSL_write ( con , & ( buf [ l ] ) , ( unsigned int ) i ) ;\n # ifndef OPENSSL_NO_SRP while ( SSL_get_error ( con , k ) == SSL_ERROR_WANT_X509_LOOKUP ) {\n BIO_printf ( bio_s_out , \"LOOKUP renego during write\\n\" ) ;\n SRP_user_pwd_free ( srp_callback_parm . user ) ;\n srp_callback_parm . user = SRP_VBASE_get1_by_user ( srp_callback_parm . vb , srp_callback_parm . login ) ;\n if ( srp_callback_parm . user ) BIO_printf ( bio_s_out , \"LOOKUP done %s\\n\" , srp_callback_parm . user -> info ) ;\n else BIO_printf ( bio_s_out , \"LOOKUP not successful\\n\" ) ;\n k = SSL_write ( con , & ( buf [ l ] ) , ( unsigned int ) i ) ;\n }\n # endif switch ( SSL_get_error ( con , k ) ) {\n case SSL_ERROR_NONE : break ;\n case SSL_ERROR_WANT_WRITE : case SSL_ERROR_WANT_READ : case SSL_ERROR_WANT_X509_LOOKUP : BIO_printf ( bio_s_out , \"Write BLOCK\\n\" ) ;\n break ;\n case SSL_ERROR_SYSCALL : case SSL_ERROR_SSL : BIO_printf ( bio_s_out , \"ERROR\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n ret = 1 ;\n goto err ;\n case SSL_ERROR_ZERO_RETURN : BIO_printf ( bio_s_out , \"DONE\\n\" ) ;\n ret = 1 ;\n goto err ;\n }\n if ( k > 0 ) {\n l += k ;\n i -= k ;\n }\n if ( i <= 0 ) break ;\n }\n }\n if ( read_from_sslcon ) {\n if ( ! SSL_is_init_finished ( con ) ) {\n i = init_ssl_connection ( con ) ;\n if ( i < 0 ) {\n ret = 0 ;\n goto err ;\n }\n else if ( i == 0 ) {\n ret = 1 ;\n goto err ;\n }\n }\n else {\n again : i = SSL_read ( con , ( char * ) buf , bufsize ) ;\n # ifndef OPENSSL_NO_SRP while ( SSL_get_error ( con , i ) == SSL_ERROR_WANT_X509_LOOKUP ) {\n BIO_printf ( bio_s_out , \"LOOKUP renego during read\\n\" ) ;\n SRP_user_pwd_free ( srp_callback_parm . user ) ;\n srp_callback_parm . user = SRP_VBASE_get1_by_user ( srp_callback_parm . vb , srp_callback_parm . login ) ;\n if ( srp_callback_parm . user ) BIO_printf ( bio_s_out , \"LOOKUP done %s\\n\" , srp_callback_parm . user -> info ) ;\n else BIO_printf ( bio_s_out , \"LOOKUP not successful\\n\" ) ;\n i = SSL_read ( con , ( char * ) buf , bufsize ) ;\n }\n # endif switch ( SSL_get_error ( con , i ) ) {\n case SSL_ERROR_NONE : # ifdef CHARSET_EBCDIC ascii2ebcdic ( buf , buf , i ) ;\n # endif raw_write_stdout ( buf , ( unsigned int ) i ) ;\n if ( SSL_pending ( con ) ) goto again ;\n break ;\n case SSL_ERROR_WANT_WRITE : case SSL_ERROR_WANT_READ : BIO_printf ( bio_s_out , \"Read BLOCK\\n\" ) ;\n break ;\n case SSL_ERROR_SYSCALL : case SSL_ERROR_SSL : BIO_printf ( bio_s_out , \"ERROR\\n\" ) ;\n ERR_print_errors ( bio_err ) ;\n ret = 1 ;\n goto err ;\n case SSL_ERROR_ZERO_RETURN : BIO_printf ( bio_s_out , \"DONE\\n\" ) ;\n ret = 1 ;\n goto err ;\n }\n }\n }\n }\n err : if ( con != NULL ) {\n BIO_printf ( bio_s_out , \"shutting down SSL\\n\" ) ;\n # if 1 SSL_set_shutdown ( con , SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN ) ;\n # else SSL_shutdown ( con ) ;\n # endif SSL_free ( con ) ;\n }\n BIO_printf ( bio_s_out , \"CONNECTION CLOSED\\n\" ) ;\n if ( buf != NULL ) {\n OPENSSL_cleanse ( buf , bufsize ) ;\n OPENSSL_free ( buf ) ;\n }\n if ( ret >= 0 ) BIO_printf ( bio_s_out , \"ACCEPT\\n\" ) ;\n return ( ret ) ;\n }\n static void close_accept_socket ( void ) {\n BIO_printf ( bio_err , \"shutdown accept socket\\n\" ) ;\n if ( accept_socket >= 0 ) {\n SHUTDOWN2 ( accept_socket ) ;\n }\n }\n static int init_ssl_connection ( SSL * con ) {\n int i ;\n const char * str ;\n X509 * peer ;\n long verify_error ;\n MS_STATIC char buf [ BUFSIZ ] ;\n # ifndef OPENSSL_NO_KRB5 char * client_princ ;\n # endif # if ! defined ( OPENSSL_NO_TLSEXT ) && ! defined ( OPENSSL_NO_NEXTPROTONEG ) const unsigned char * next_proto_neg ;\n unsigned next_proto_neg_len ;\n # endif unsigned char * exportedkeymat ;\n i = SSL_accept ( con ) ;\n # ifndef OPENSSL_NO_SRP while ( i <= 0 && SSL_get_error ( con , i ) == SSL_ERROR_WANT_X509_LOOKUP ) {\n BIO_printf ( bio_s_out , \"LOOKUP during accept %s\\n\" , srp_callback_parm . login ) ;\n SRP_user_pwd_free ( srp_callback_parm . user ) ;\n srp_callback_parm . user = SRP_VBASE_get1_by_user ( srp_callback_parm . vb , srp_callback_parm . login ) ;\n if ( srp_callback_parm . user ) BIO_printf ( bio_s_out , \"LOOKUP done %s\\n\" , srp_callback_parm . user -> info ) ;\n else BIO_printf ( bio_s_out , \"LOOKUP not successful\\n\" ) ;\n i = SSL_accept ( con ) ;\n }\n # endif if ( i <= 0 ) {\n if ( BIO_sock_should_retry ( i ) ) {\n BIO_printf ( bio_s_out , \"DELAY\\n\" ) ;\n return ( 1 ) ;\n }\n BIO_printf ( bio_err , \"ERROR\\n\" ) ;\n verify_error = SSL_get_verify_result ( con ) ;\n if ( verify_error != X509_V_OK ) {\n BIO_printf ( bio_err , \"verify error:%s\\n\" , X509_verify_cert_error_string ( verify_error ) ) ;\n }\n else ERR_print_errors ( bio_err ) ;\n return ( 0 ) ;\n }\n PEM_write_bio_SSL_SESSION ( bio_s_out , SSL_get_session ( con ) ) ;\n peer = SSL_get_peer_certificate ( con ) ;\n if ( peer != NULL ) {\n BIO_printf ( bio_s_out , \"Client certificate\\n\" ) ;\n PEM_write_bio_X509 ( bio_s_out , peer ) ;\n X509_NAME_oneline ( X509_get_subject_name ( peer ) , buf , sizeof buf ) ;\n BIO_printf ( bio_s_out , \"subject=%s\\n\" , buf ) ;\n X509_NAME_oneline ( X509_get_issuer_name ( peer ) , buf , sizeof buf ) ;\n BIO_printf ( bio_s_out , \"issuer=%s\\n\" , buf ) ;\n X509_free ( peer ) ;\n }\n if ( SSL_get_shared_ciphers ( con , buf , sizeof buf ) != NULL ) BIO_printf ( bio_s_out , \"Shared ciphers:%s\\n\" , buf ) ;\n str = SSL_CIPHER_get_name ( SSL_get_current_cipher ( con ) ) ;\n BIO_printf ( bio_s_out , \"CIPHER is %s\\n\" , ( str != NULL ) ? str : \"(NONE)\" ) ;\n # if ! defined ( OPENSSL_NO_TLSEXT ) && ! defined ( OPENSSL_NO_NEXTPROTONEG ) SSL_get0_next_proto_negotiated ( con , & next_proto_neg , & next_proto_neg_len ) ;\n if ( next_proto_neg ) {\n BIO_printf ( bio_s_out , \"NEXTPROTO is \" ) ;\n BIO_write ( bio_s_out , next_proto_neg , next_proto_neg_len ) ;\n BIO_printf ( bio_s_out , \"\\n\" ) ;\n }\n # endif # ifndef OPENSSL_NO_SRTP {\n SRTP_PROTECTION_PROFILE * srtp_profile = SSL_get_selected_srtp_profile ( con ) ;\n if ( srtp_profile ) BIO_printf ( bio_s_out , \"SRTP Extension negotiated, profile=%s\\n\" , srtp_profile -> name ) ;\n }\n # endif if ( SSL_cache_hit ( con ) ) BIO_printf ( bio_s_out , \"Reused session-id\\n\" ) ;\n if ( SSL_ctrl ( con , SSL_CTRL_GET_FLAGS , 0 , NULL ) & TLS1_FLAGS_TLS_PADDING_BUG ) BIO_printf ( bio_s_out , \"Peer has incorrect TLSv1 block padding\\n\" ) ;\n # ifndef OPENSSL_NO_KRB5 client_princ = kssl_ctx_get0_client_princ ( SSL_get0_kssl_ctx ( con ) ) ;\n if ( client_princ != NULL ) {\n BIO_printf ( bio_s_out , \"Kerberos peer principal is %s\\n\" , client_princ ) ;\n }\n # endif BIO_printf ( bio_s_out , \"Secure Renegotiation IS%s supported\\n\" , SSL_get_secure_renegotiation_support ( con ) ? \"\" : \" NOT\" ) ;\n if ( keymatexportlabel != NULL ) {\n BIO_printf ( bio_s_out , \"Keying material exporter:\\n\" ) ;\n BIO_printf ( bio_s_out , \" Label: '%s'\\n\" , keymatexportlabel ) ;\n BIO_printf ( bio_s_out , \" Length: %i bytes\\n\" , keymatexportlen ) ;\n exportedkeymat = OPENSSL_malloc ( keymatexportlen ) ;\n if ( exportedkeymat != NULL ) {\n if ( ! SSL_export_keying_material ( con , exportedkeymat , keymatexportlen , keymatexportlabel , strlen ( keymatexportlabel ) , NULL , 0 , 0 ) ) {\n BIO_printf ( bio_s_out , \" Error\\n\" ) ;\n }\n else {\n BIO_printf ( bio_s_out , \" Keying material: \" ) ;\n for ( i = 0 ;\n i < keymatexportlen ;\n i ++ ) BIO_printf ( bio_s_out , \"%02X\" , exportedkeymat [ i ] ) ;\n BIO_printf ( bio_s_out , \"\\n\" ) ;\n }\n OPENSSL_free ( exportedkeymat ) ;\n }\n }\n return ( 1 ) ;\n }\n # ifndef OPENSSL_NO_DH static DH * load_dh_param ( const char * dhfile ) {\n DH * ret = NULL ;\n BIO * bio ;\n if ( ( bio = BIO_new_file ( dhfile , \"r\" ) ) == NULL ) goto err ;\n ret = PEM_read_bio_DHparams ( bio , NULL , NULL , NULL ) ;\n err : if ( bio != NULL ) BIO_free ( bio ) ;\n return ( ret ) ;\n }\n # endif # ifndef OPENSSL_NO_KRB5 char * client_princ ;\n # endif # if 0 static int load_CA ( SSL_CTX * ctx , char * file ) {\n FILE * in ;\n X509 * x = NULL ;\n if ( ( in = fopen ( file , \"r\" ) ) == NULL ) return ( 0 ) ;\n for ( ;\n ;\n ) {\n if ( PEM_read_X509 ( in , & x , NULL ) == NULL ) break ;\n SSL_CTX_add_client_CA ( ctx , x ) ;\n }\n if ( x != NULL ) X509_free ( x ) ;\n fclose ( in ) ;\n return ( 1 ) ;\n }\n # endif static int www_body ( char * hostname , int s , unsigned char * context ) {\n char * buf = NULL ;\n int ret = 1 ;\n int i , j , k , dot ;\n SSL * con ;\n const SSL_CIPHER * c ;\n BIO * io , * ssl_bio , * sbio ;\n # ifndef OPENSSL_NO_KRB5 KSSL_CTX * kctx ;\n # endif buf = OPENSSL_malloc ( bufsize ) ;\n if ( buf == NULL ) return ( 0 ) ;\n io = BIO_new ( BIO_f_buffer ( ) ) ;\n ssl_bio = BIO_new ( BIO_f_ssl ( ) ) ;\n if ( ( io == NULL ) || ( ssl_bio == NULL ) ) goto err ;\n # ifdef FIONBIO if ( s_nbio ) {\n unsigned long sl = 1 ;\n if ( ! s_quiet ) BIO_printf ( bio_err , \"turning on non blocking io\\n\" ) ;\n if ( BIO_socket_ioctl ( s , FIONBIO , & sl ) < 0 ) ERR_print_errors ( bio_err ) ;\n }\n # endif if ( ! BIO_set_write_buffer_size ( io , bufsize ) ) goto err ;\n if ( ( con = SSL_new ( ctx ) ) == NULL ) goto err ;\n # ifndef OPENSSL_NO_TLSEXT if ( s_tlsextdebug ) {\n SSL_set_tlsext_debug_callback ( con , tlsext_cb ) ;\n SSL_set_tlsext_debug_arg ( con , bio_s_out ) ;\n }\n # endif # ifndef OPENSSL_NO_KRB5 if ( ( kctx = kssl_ctx_new ( ) ) != NULL ) {\n kssl_ctx_setstring ( kctx , KSSL_SERVICE , KRB5SVC ) ;\n kssl_ctx_setstring ( kctx , KSSL_KEYTAB , KRB5KEYTAB ) ;\n }\n # endif if ( context ) SSL_set_session_id_context ( con , context , strlen ( ( char * ) context ) ) ;\n sbio = BIO_new_socket ( s , BIO_NOCLOSE ) ;\n if ( s_nbio_test ) {\n BIO * test ;\n test = BIO_new ( BIO_f_nbio_test ( ) ) ;\n sbio = BIO_push ( test , sbio ) ;\n }\n SSL_set_bio ( con , sbio , sbio ) ;\n SSL_set_accept_state ( con ) ;\n BIO_set_ssl ( ssl_bio , con , BIO_CLOSE ) ;\n BIO_push ( io , ssl_bio ) ;\n # ifdef CHARSET_EBCDIC io = BIO_push ( BIO_new ( BIO_f_ebcdic_filter ( ) ) , io ) ;\n # endif if ( s_debug ) {\n SSL_set_debug ( con , 1 ) ;\n BIO_set_callback ( SSL_get_rbio ( con ) , bio_dump_callback ) ;\n BIO_set_callback_arg ( SSL_get_rbio ( con ) , ( char * ) bio_s_out ) ;\n }\n if ( s_msg ) {\n SSL_set_msg_callback ( con , msg_cb ) ;\n SSL_set_msg_callback_arg ( con , bio_s_out ) ;\n }\n for ( ;\n ;\n ) {\n if ( hack ) {\n i = SSL_accept ( con ) ;\n # ifndef OPENSSL_NO_SRP while ( i <= 0 && SSL_get_error ( con , i ) == SSL_ERROR_WANT_X509_LOOKUP ) {\n BIO_printf ( bio_s_out , \"LOOKUP during accept %s\\n\" , srp_callback_parm . login ) ;\n SRP_user_pwd_free ( srp_callback_parm . user ) ;\n srp_callback_parm . user = SRP_VBASE_get1_by_user ( srp_callback_parm . vb , srp_callback_parm . login ) ;\n if ( srp_callback_parm . user ) BIO_printf ( bio_s_out , \"LOOKUP done %s\\n\" , srp_callback_parm . user -> info ) ;\n else BIO_printf ( bio_s_out , \"LOOKUP not successful\\n\" ) ;\n i = SSL_accept ( con ) ;\n }\n # endif switch ( SSL_get_error ( con , i ) ) {\n case SSL_ERROR_NONE : break ;\n case SSL_ERROR_WANT_WRITE : case SSL_ERROR_WANT_READ : case SSL_ERROR_WANT_X509_LOOKUP : continue ;\n case SSL_ERROR_SYSCALL : case SSL_ERROR_SSL : case SSL_ERROR_ZERO_RETURN : ret = 1 ;\n goto err ;\n }\n SSL_renegotiate ( con ) ;\n SSL_write ( con , NULL , 0 ) ;\n }\n i = BIO_gets ( io , buf , bufsize - 1 ) ;\n if ( i < 0 ) {\n if ( ! BIO_should_retry ( io ) ) {\n if ( ! s_quiet ) ERR_print_errors ( bio_err ) ;\n goto err ;\n }\n else {\n BIO_printf ( bio_s_out , \"read R BLOCK\\n\" ) ;\n # ifndef OPENSSL_NO_SRP if ( BIO_should_io_special ( io ) && BIO_get_retry_reason ( io ) == BIO_RR_SSL_X509_LOOKUP ) {\n BIO_printf ( bio_s_out , \"LOOKUP renego during read\\n\" ) ;\n SRP_user_pwd_free ( srp_callback_parm . user ) ;\n srp_callback_parm . user = SRP_VBASE_get1_by_user ( srp_callback_parm . vb , srp_callback_parm . login ) ;\n if ( srp_callback_parm . user ) BIO_printf ( bio_s_out , \"LOOKUP done %s\\n\" , srp_callback_parm . user -> info ) ;\n else BIO_printf ( bio_s_out , \"LOOKUP not successful\\n\" ) ;\n continue ;\n }\n # endif # if defined ( OPENSSL_SYS_NETWARE ) delay ( 1000 ) ;\n # elif ! defined ( OPENSSL_SYS_MSDOS ) && ! defined ( __DJGPP__ ) sleep ( 1 ) ;\n # endif continue ;\n }\n }\n else if ( i == 0 ) {\n ret = 1 ;\n goto end ;\n }\n if ( ( ( www == 1 ) && ( strncmp ( \"GET \" , buf , 4 ) == 0 ) ) || ( ( www == 2 ) && ( strncmp ( \"GET \/stats \" , buf , 11 ) == 0 ) ) ) {\n char * p ;\n X509 * peer ;\n STACK_OF ( SSL_CIPHER ) * sk ;\n static const char * space = \" \" ;\n BIO_puts ( io , \"HTTP\/1.0 200 ok\\r\\nContent-type: text\/html\\r\\n\\r\\n\" ) ;\n BIO_puts ( io , \"\\n\" ) ;\n BIO_puts ( io , \"
\\n\" ) ;\n BIO_puts ( io , \"\\n\" ) ;\n for ( i = 0 ;\n i < local_argc ;\n i ++ ) {\n BIO_puts ( io , local_argv [ i ] ) ;\n BIO_write ( io , \" \" , 1 ) ;\n }\n BIO_puts ( io , \"\\n\" ) ;\n BIO_printf ( io , \"Secure Renegotiation IS%s supported\\n\" , SSL_get_secure_renegotiation_support ( con ) ? \"\" : \" NOT\" ) ;\n BIO_printf ( io , \"Ciphers supported in s_server binary\\n\" ) ;\n sk = SSL_get_ciphers ( con ) ;\n j = sk_SSL_CIPHER_num ( sk ) ;\n for ( i = 0 ;\n i < j ;\n i ++ ) {\n c = sk_SSL_CIPHER_value ( sk , i ) ;\n BIO_printf ( io , \"%-11s:%-25s\" , SSL_CIPHER_get_version ( c ) , SSL_CIPHER_get_name ( c ) ) ;\n if ( ( ( ( i + 1 ) % 2 ) == 0 ) && ( i + 1 != j ) ) BIO_puts ( io , \"\\n\" ) ;\n }\n BIO_puts ( io , \"\\n\" ) ;\n p = SSL_get_shared_ciphers ( con , buf , bufsize ) ;\n if ( p != NULL ) {\n BIO_printf ( io , \"---\\nCiphers common between both SSL end points:\\n\" ) ;\n j = i = 0 ;\n while ( * p ) {\n if ( * p == ':' ) {\n BIO_write ( io , space , 26 - j ) ;\n i ++ ;\n j = 0 ;\n BIO_write ( io , ( ( i % 3 ) ? \" \" : \"\\n\" ) , 1 ) ;\n }\n else {\n BIO_write ( io , p , 1 ) ;\n j ++ ;\n }\n p ++ ;\n }\n BIO_puts ( io , \"\\n\" ) ;\n }\n BIO_printf ( io , ( SSL_cache_hit ( con ) ? \"---\\nReused, \" : \"---\\nNew, \" ) ) ;\n c = SSL_get_current_cipher ( con ) ;\n BIO_printf ( io , \"%s, Cipher is %s\\n\" , SSL_CIPHER_get_version ( c ) , SSL_CIPHER_get_name ( c ) ) ;\n SSL_SESSION_print ( io , SSL_get_session ( con ) ) ;\n BIO_printf ( io , \"---\\n\" ) ;\n print_stats ( io , SSL_get_SSL_CTX ( con ) ) ;\n BIO_printf ( io , \"---\\n\" ) ;\n peer = SSL_get_peer_certificate ( con ) ;\n if ( peer != NULL ) {\n BIO_printf ( io , \"Client certificate\\n\" ) ;\n X509_print ( io , peer ) ;\n PEM_write_bio_X509 ( io , peer ) ;\n }\n else BIO_puts ( io , \"no client certificate available\\n\" ) ;\n BIO_puts ( io , \"<\/BODY><\/HTML>\\r\\n\\r\\n\" ) ;\n break ;\n }\n else if ( ( www == 2 || www == 3 ) && ( strncmp ( \"GET \/\" , buf , 5 ) == 0 ) ) {\n BIO * file ;\n char * p , * e ;\n static const char * text = \"HTTP\/1.0 200 ok\\r\\nContent-type: text\/plain\\r\\n\\r\\n\" ;\n p = & ( buf [ 5 ] ) ;\n dot = 1 ;\n for ( e = p ;\n * e != '\\0' ;\n e ++ ) {\n if ( e [ 0 ] == ' ' ) break ;\n switch ( dot ) {\n case 1 : dot = ( e [ 0 ] == '.' ) ? 2 : 0 ;\n break ;\n case 2 : dot = ( e [ 0 ] == '.' ) ? 3 : 0 ;\n break ;\n case 3 : dot = ( e [ 0 ] == '\/' ) ? - 1 : 0 ;\n break ;\n }\n if ( dot == 0 ) dot = ( e [ 0 ] == '\/' ) ? 1 : 0 ;\n }\n dot = ( dot == 3 ) || ( dot == - 1 ) ;\n if ( * e == '\\0' ) {\n BIO_puts ( io , text ) ;\n BIO_printf ( io , \"'%s' is an invalid file name\\r\\n\" , p ) ;\n break ;\n }\n * e = '\\0' ;\n if ( dot ) {\n BIO_puts ( io , text ) ;\n BIO_printf ( io , \"'%s' contains '..' reference\\r\\n\" , p ) ;\n break ;\n }\n if ( * p == '\/' ) {\n BIO_puts ( io , text ) ;\n BIO_printf ( io , \"'%s' is an invalid path\\r\\n\" , p ) ;\n break ;\n }\n # if 0 if ( e [ - 1 ] == '\/' ) strcat ( p , \"index.html\" ) ;\n # endif if ( app_isdir ( p ) > 0 ) {\n # if 0 strcat ( p , \"\/index.html\" ) ;\n # else BIO_puts ( io , text ) ;\n BIO_printf ( io , \"'%s' is a directory\\r\\n\" , p ) ;\n break ;\n # endif }\n if ( ( file = BIO_new_file ( p , \"r\" ) ) == NULL ) {\n BIO_puts ( io , text ) ;\n BIO_printf ( io , \"Error opening '%s'\\r\\n\" , p ) ;\n ERR_print_errors ( io ) ;\n break ;\n }\n if ( ! s_quiet ) BIO_printf ( bio_err , \"FILE:%s\\n\" , p ) ;\n if ( www == 2 ) {\n i = strlen ( p ) ;\n if ( ( ( i > 5 ) && ( strcmp ( & ( p [ i - 5 ] ) , \".html\" ) == 0 ) ) || ( ( i > 4 ) && ( strcmp ( & ( p [ i - 4 ] ) , \".php\" ) == 0 ) ) || ( ( i > 4 ) && ( strcmp ( & ( p [ i - 4 ] ) , \".htm\" ) == 0 ) ) ) BIO_puts ( io , \"HTTP\/1.0 200 ok\\r\\nContent-type: text\/html\\r\\n\\r\\n\" ) ;\n else BIO_puts ( io , \"HTTP\/1.0 200 ok\\r\\nContent-type: text\/plain\\r\\n\\r\\n\" ) ;\n }\n for ( ;\n ;\n ) {\n i = BIO_read ( file , buf , bufsize ) ;\n if ( i <= 0 ) break ;\n # ifdef RENEG total_bytes += i ;\n fprintf ( stderr , \"%d\\n\" , i ) ;\n if ( total_bytes > 3 * 1024 ) {\n total_bytes = 0 ;\n fprintf ( stderr , \"RENEGOTIATE\\n\" ) ;\n SSL_renegotiate ( con ) ;\n }\n # endif for ( j = 0 ;\n j < i ;\n ) {\n # ifdef RENEG {\n static count = 0 ;\n if ( ++ count == 13 ) {\n SSL_renegotiate ( con ) ;\n }\n }\n # endif k = BIO_write ( io , & ( buf [ j ] ) , i - j ) ;\n if ( k <= 0 ) {\n if ( ! BIO_should_retry ( io ) ) goto write_error ;\n else {\n BIO_printf ( bio_s_out , \"rwrite W BLOCK\\n\" ) ;\n }\n }\n else {\n j += k ;\n }\n }\n }\n write_error : BIO_free ( file ) ;\n break ;\n }\n }\n for ( ;\n ;\n ) {\n i = ( int ) BIO_flush ( io ) ;\n if ( i <= 0 ) {\n if ( ! BIO_should_retry ( io ) ) break ;\n }\n else break ;\n }\n end : # if 1 SSL_set_shutdown ( con , SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN ) ;\n # else # endif err : if ( ret >= 0 ) BIO_printf ( bio_s_out , \"ACCEPT\\n\" ) ;\n if ( buf != NULL ) OPENSSL_free ( buf ) ;\n if ( io != NULL ) BIO_free_all ( io ) ;\n return ( ret ) ;\n }\n # ifndef OPENSSL_NO_RSA static RSA MS_CALLBACK * tmp_rsa_cb ( SSL * s , int is_export , int keylength ) {\n BIGNUM * bn = NULL ;\n static RSA * rsa_tmp = NULL ;\n if ( ! rsa_tmp && ( ( bn = BN_new ( ) ) == NULL ) ) BIO_printf ( bio_err , \"Allocation error in generating RSA key\\n\" ) ;\n if ( ! rsa_tmp && bn ) {\n if ( ! s_quiet ) {\n BIO_printf ( bio_err , \"Generating temp (%d bit) RSA key...\" , keylength ) ;\n ( void ) BIO_flush ( bio_err ) ;\n }\n if ( ! BN_set_word ( bn , RSA_F4 ) || ( ( rsa_tmp = RSA_new ( ) ) == NULL ) || ! RSA_generate_key_ex ( rsa_tmp , keylength , bn , NULL ) ) {\n if ( rsa_tmp ) RSA_free ( rsa_tmp ) ;\n rsa_tmp = NULL ;\n }\n if ( ! s_quiet ) {\n BIO_printf ( bio_err , \"\\n\" ) ;\n ( void ) BIO_flush ( bio_err ) ;\n }\n BN_free ( bn ) ;\n }\n return ( rsa_tmp ) ;\n }\n # endif # define MAX_SESSION_ID_ATTEMPTS 10 static int generate_session_id ( const SSL * ssl , unsigned char * id , unsigned int * id_len ) {\n unsigned int count = 0 ;\n do {\n if ( RAND_pseudo_bytes ( id , * id_len ) < 0 ) return 0 ;\n memcpy ( id , session_id_prefix , ( strlen ( session_id_prefix ) < * id_len ) ? strlen ( session_id_prefix ) : * id_len ) ;\n }\n while ( SSL_has_matching_session_id ( ssl , id , * id_len ) && ( ++ count < MAX_SESSION_ID_ATTEMPTS ) ) ;\n if ( count >= MAX_SESSION_ID_ATTEMPTS ) return 0 ;\n return 1 ;\n }","target":0,"code_token_length":17181,"total_token_length":17417,"max_tokens_setting":28000}
+{"idx":273192,"func":"suggest_trie_walk(\n    suginfo_T\t*su,\n    langp_T\t*lp,\n    char_u\t*fword,\n    int\t\tsoundfold)\n{\n    char_u\ttword[MAXWLEN];\t    \/\/ good word collected so far\n    trystate_T\tstack[MAXWLEN];\n    char_u\tpreword[MAXWLEN * 3]; \/\/ word found with proper case;\n\t\t\t\t      \/\/ concatenation of prefix compound\n\t\t\t\t      \/\/ words and split word.  NUL terminated\n\t\t\t\t      \/\/ when going deeper but not when coming\n\t\t\t\t      \/\/ back.\n    char_u\tcompflags[MAXWLEN];\t\/\/ compound flags, one for each word\n    trystate_T\t*sp;\n    int\t\tnewscore;\n    int\t\tscore;\n    char_u\t*byts, *fbyts, *pbyts;\n    idx_T\t*idxs, *fidxs, *pidxs;\n    int\t\tdepth;\n    int\t\tc, c2, c3;\n    int\t\tn = 0;\n    int\t\tflags;\n    garray_T\t*gap;\n    idx_T\tarridx;\n    int\t\tlen;\n    char_u\t*p;\n    fromto_T\t*ftp;\n    int\t\tfl = 0, tl;\n    int\t\trepextra = 0;\t    \/\/ extra bytes in fword[] from REP item\n    slang_T\t*slang = lp->lp_slang;\n    int\t\tfword_ends;\n    int\t\tgoodword_ends;\n#ifdef DEBUG_TRIEWALK\n    \/\/ Stores the name of the change made at each level.\n    char_u\tchangename[MAXWLEN][80];\n#endif\n    int\t\tbreakcheckcount = 1000;\n#ifdef FEAT_RELTIME\n    proftime_T\ttime_limit;\n#endif\n    int\t\tcompound_ok;\n\n    \/\/ Go through the whole case-fold tree, try changes at each node.\n    \/\/ \"tword[]\" contains the word collected from nodes in the tree.\n    \/\/ \"fword[]\" the word we are trying to match with (initially the bad\n    \/\/ word).\n    depth = 0;\n    sp = &stack[0];\n    CLEAR_POINTER(sp);\n    sp->ts_curi = 1;\n\n    if (soundfold)\n    {\n\t\/\/ Going through the soundfold tree.\n\tbyts = fbyts = slang->sl_sbyts;\n\tidxs = fidxs = slang->sl_sidxs;\n\tpbyts = NULL;\n\tpidxs = NULL;\n\tsp->ts_prefixdepth = PFD_NOPREFIX;\n\tsp->ts_state = STATE_START;\n    }\n    else\n    {\n\t\/\/ When there are postponed prefixes we need to use these first.  At\n\t\/\/ the end of the prefix we continue in the case-fold tree.\n\tfbyts = slang->sl_fbyts;\n\tfidxs = slang->sl_fidxs;\n\tpbyts = slang->sl_pbyts;\n\tpidxs = slang->sl_pidxs;\n\tif (pbyts != NULL)\n\t{\n\t    byts = pbyts;\n\t    idxs = pidxs;\n\t    sp->ts_prefixdepth = PFD_PREFIXTREE;\n\t    sp->ts_state = STATE_NOPREFIX;\t\/\/ try without prefix first\n\t}\n\telse\n\t{\n\t    byts = fbyts;\n\t    idxs = fidxs;\n\t    sp->ts_prefixdepth = PFD_NOPREFIX;\n\t    sp->ts_state = STATE_START;\n\t}\n    }\n#ifdef FEAT_RELTIME\n    \/\/ The loop may take an indefinite amount of time. Break out after some\n    \/\/ time.\n    if (spell_suggest_timeout > 0)\n\tprofile_setlimit(spell_suggest_timeout, &time_limit);\n#endif\n\n    \/\/ Loop to find all suggestions.  At each round we either:\n    \/\/ - For the current state try one operation, advance \"ts_curi\",\n    \/\/   increase \"depth\".\n    \/\/ - When a state is done go to the next, set \"ts_state\".\n    \/\/ - When all states are tried decrease \"depth\".\n    while (depth >= 0 && !got_int)\n    {\n\tsp = &stack[depth];\n\tswitch (sp->ts_state)\n\t{\n\tcase STATE_START:\n\tcase STATE_NOPREFIX:\n\t    \/\/ Start of node: Deal with NUL bytes, which means\n\t    \/\/ tword[] may end here.\n\t    arridx = sp->ts_arridx;\t    \/\/ current node in the tree\n\t    len = byts[arridx];\t\t    \/\/ bytes in this node\n\t    arridx += sp->ts_curi;\t    \/\/ index of current byte\n\n\t    if (sp->ts_prefixdepth == PFD_PREFIXTREE)\n\t    {\n\t\t\/\/ Skip over the NUL bytes, we use them later.\n\t\tfor (n = 0; n < len && byts[arridx + n] == 0; ++n)\n\t\t    ;\n\t\tsp->ts_curi += n;\n\n\t\t\/\/ Always past NUL bytes now.\n\t\tn = (int)sp->ts_state;\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_ENDNUL;\n\t\tsp->ts_save_badflags = su->su_badflags;\n\n\t\t\/\/ At end of a prefix or at start of prefixtree: check for\n\t\t\/\/ following word.\n\t\tif (depth < MAXWLEN - 1\n\t\t\t    && (byts[arridx] == 0 || n == (int)STATE_NOPREFIX))\n\t\t{\n\t\t    \/\/ Set su->su_badflags to the caps type at this position.\n\t\t    \/\/ Use the caps type until here for the prefix itself.\n\t\t    if (has_mbyte)\n\t\t\tn = nofold_len(fword, sp->ts_fidx, su->su_badptr);\n\t\t    else\n\t\t\tn = sp->ts_fidx;\n\t\t    flags = badword_captype(su->su_badptr, su->su_badptr + n);\n\t\t    su->su_badflags = badword_captype(su->su_badptr + n,\n\t\t\t\t\t       su->su_badptr + su->su_badlen);\n#ifdef DEBUG_TRIEWALK\n\t\t    sprintf(changename[depth], \"prefix\");\n#endif\n\t\t    go_deeper(stack, depth, 0);\n\t\t    ++depth;\n\t\t    sp = &stack[depth];\n\t\t    sp->ts_prefixdepth = depth - 1;\n\t\t    byts = fbyts;\n\t\t    idxs = fidxs;\n\t\t    sp->ts_arridx = 0;\n\n\t\t    \/\/ Move the prefix to preword[] with the right case\n\t\t    \/\/ and make find_keepcap_word() works.\n\t\t    tword[sp->ts_twordlen] = NUL;\n\t\t    make_case_word(tword + sp->ts_splitoff,\n\t\t\t\t\t  preword + sp->ts_prewordlen, flags);\n\t\t    sp->ts_prewordlen = (char_u)STRLEN(preword);\n\t\t    sp->ts_splitoff = sp->ts_twordlen;\n\t\t}\n\t\tbreak;\n\t    }\n\n\t    if (sp->ts_curi > len || byts[arridx] != 0)\n\t    {\n\t\t\/\/ Past bytes in node and\/or past NUL bytes.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_ENDNUL;\n\t\tsp->ts_save_badflags = su->su_badflags;\n\t\tbreak;\n\t    }\n\n\t    \/\/ End of word in tree.\n\t    ++sp->ts_curi;\t\t\/\/ eat one NUL byte\n\n\t    flags = (int)idxs[arridx];\n\n\t    \/\/ Skip words with the NOSUGGEST flag.\n\t    if (flags & WF_NOSUGGEST)\n\t\tbreak;\n\n\t    fword_ends = (fword[sp->ts_fidx] == NUL\n\t\t\t   || (soundfold\n\t\t\t       ? VIM_ISWHITE(fword[sp->ts_fidx])\n\t\t\t       : !spell_iswordp(fword + sp->ts_fidx, curwin)));\n\t    tword[sp->ts_twordlen] = NUL;\n\n\t    if (sp->ts_prefixdepth <= PFD_NOTSPECIAL\n\t\t\t\t\t&& (sp->ts_flags & TSF_PREFIXOK) == 0\n\t\t\t\t\t&& pbyts != NULL)\n\t    {\n\t\t\/\/ There was a prefix before the word.  Check that the prefix\n\t\t\/\/ can be used with this word.\n\t\t\/\/ Count the length of the NULs in the prefix.  If there are\n\t\t\/\/ none this must be the first try without a prefix.\n\t\tn = stack[sp->ts_prefixdepth].ts_arridx;\n\t\tlen = pbyts[n++];\n\t\tfor (c = 0; c < len && pbyts[n + c] == 0; ++c)\n\t\t    ;\n\t\tif (c > 0)\n\t\t{\n\t\t    c = valid_word_prefix(c, n, flags,\n\t\t\t\t       tword + sp->ts_splitoff, slang, FALSE);\n\t\t    if (c == 0)\n\t\t\tbreak;\n\n\t\t    \/\/ Use the WF_RARE flag for a rare prefix.\n\t\t    if (c & WF_RAREPFX)\n\t\t\tflags |= WF_RARE;\n\n\t\t    \/\/ Tricky: when checking for both prefix and compounding\n\t\t    \/\/ we run into the prefix flag first.\n\t\t    \/\/ Remember that it's OK, so that we accept the prefix\n\t\t    \/\/ when arriving at a compound flag.\n\t\t    sp->ts_flags |= TSF_PREFIXOK;\n\t\t}\n\t    }\n\n\t    \/\/ Check NEEDCOMPOUND: can't use word without compounding.  Do try\n\t    \/\/ appending another compound word below.\n\t    if (sp->ts_complen == sp->ts_compsplit && fword_ends\n\t\t\t\t\t\t     && (flags & WF_NEEDCOMP))\n\t\tgoodword_ends = FALSE;\n\t    else\n\t\tgoodword_ends = TRUE;\n\n\t    p = NULL;\n\t    compound_ok = TRUE;\n\t    if (sp->ts_complen > sp->ts_compsplit)\n\t    {\n\t\tif (slang->sl_nobreak)\n\t\t{\n\t\t    \/\/ There was a word before this word.  When there was no\n\t\t    \/\/ change in this word (it was correct) add the first word\n\t\t    \/\/ as a suggestion.  If this word was corrected too, we\n\t\t    \/\/ need to check if a correct word follows.\n\t\t    if (sp->ts_fidx - sp->ts_splitfidx\n\t\t\t\t\t  == sp->ts_twordlen - sp->ts_splitoff\n\t\t\t    && STRNCMP(fword + sp->ts_splitfidx,\n\t\t\t\t\ttword + sp->ts_splitoff,\n\t\t\t\t\t sp->ts_fidx - sp->ts_splitfidx) == 0)\n\t\t    {\n\t\t\tpreword[sp->ts_prewordlen] = NUL;\n\t\t\tnewscore = score_wordcount_adj(slang, sp->ts_score,\n\t\t\t\t\t\t preword + sp->ts_prewordlen,\n\t\t\t\t\t\t sp->ts_prewordlen > 0);\n\t\t\t\/\/ Add the suggestion if the score isn't too bad.\n\t\t\tif (newscore <= su->su_maxscore)\n\t\t\t    add_suggestion(su, &su->su_ga, preword,\n\t\t\t\t    sp->ts_splitfidx - repextra,\n\t\t\t\t    newscore, 0, FALSE,\n\t\t\t\t    lp->lp_sallang, FALSE);\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ There was a compound word before this word.  If this\n\t\t    \/\/ word does not support compounding then give up\n\t\t    \/\/ (splitting is tried for the word without compound\n\t\t    \/\/ flag).\n\t\t    if (((unsigned)flags >> 24) == 0\n\t\t\t    || sp->ts_twordlen - sp->ts_splitoff\n\t\t\t\t\t\t       < slang->sl_compminlen)\n\t\t\tbreak;\n\t\t    \/\/ For multi-byte chars check character length against\n\t\t    \/\/ COMPOUNDMIN.\n\t\t    if (has_mbyte\n\t\t\t    && slang->sl_compminlen > 0\n\t\t\t    && mb_charlen(tword + sp->ts_splitoff)\n\t\t\t\t\t\t       < slang->sl_compminlen)\n\t\t\tbreak;\n\n\t\t    compflags[sp->ts_complen] = ((unsigned)flags >> 24);\n\t\t    compflags[sp->ts_complen + 1] = NUL;\n\t\t    vim_strncpy(preword + sp->ts_prewordlen,\n\t\t\t    tword + sp->ts_splitoff,\n\t\t\t    sp->ts_twordlen - sp->ts_splitoff);\n\n\t\t    \/\/ Verify CHECKCOMPOUNDPATTERN  rules.\n\t\t    if (match_checkcompoundpattern(preword,  sp->ts_prewordlen,\n\t\t\t\t\t\t\t  &slang->sl_comppat))\n\t\t\tcompound_ok = FALSE;\n\n\t\t    if (compound_ok)\n\t\t    {\n\t\t\tp = preword;\n\t\t\twhile (*skiptowhite(p) != NUL)\n\t\t\t    p = skipwhite(skiptowhite(p));\n\t\t\tif (fword_ends && !can_compound(slang, p,\n\t\t\t\t\t\tcompflags + sp->ts_compsplit))\n\t\t\t    \/\/ Compound is not allowed.  But it may still be\n\t\t\t    \/\/ possible if we add another (short) word.\n\t\t\t    compound_ok = FALSE;\n\t\t    }\n\n\t\t    \/\/ Get pointer to last char of previous word.\n\t\t    p = preword + sp->ts_prewordlen;\n\t\t    MB_PTR_BACK(preword, p);\n\t\t}\n\t    }\n\n\t    \/\/ Form the word with proper case in preword.\n\t    \/\/ If there is a word from a previous split, append.\n\t    \/\/ For the soundfold tree don't change the case, simply append.\n\t    if (soundfold)\n\t\tSTRCPY(preword + sp->ts_prewordlen, tword + sp->ts_splitoff);\n\t    else if (flags & WF_KEEPCAP)\n\t\t\/\/ Must find the word in the keep-case tree.\n\t\tfind_keepcap_word(slang, tword + sp->ts_splitoff,\n\t\t\t\t\t\t preword + sp->ts_prewordlen);\n\t    else\n\t    {\n\t\t\/\/ Include badflags: If the badword is onecap or allcap\n\t\t\/\/ use that for the goodword too.  But if the badword is\n\t\t\/\/ allcap and it's only one char long use onecap.\n\t\tc = su->su_badflags;\n\t\tif ((c & WF_ALLCAP)\n\t\t\t&& su->su_badlen == (*mb_ptr2len)(su->su_badptr))\n\t\t    c = WF_ONECAP;\n\t\tc |= flags;\n\n\t\t\/\/ When appending a compound word after a word character don't\n\t\t\/\/ use Onecap.\n\t\tif (p != NULL && spell_iswordp_nmw(p, curwin))\n\t\t    c &= ~WF_ONECAP;\n\t\tmake_case_word(tword + sp->ts_splitoff,\n\t\t\t\t\t      preword + sp->ts_prewordlen, c);\n\t    }\n\n\t    if (!soundfold)\n\t    {\n\t\t\/\/ Don't use a banned word.  It may appear again as a good\n\t\t\/\/ word, thus remember it.\n\t\tif (flags & WF_BANNED)\n\t\t{\n\t\t    add_banned(su, preword + sp->ts_prewordlen);\n\t\t    break;\n\t\t}\n\t\tif ((sp->ts_complen == sp->ts_compsplit\n\t\t\t    && WAS_BANNED(su, preword + sp->ts_prewordlen))\n\t\t\t\t\t\t   || WAS_BANNED(su, preword))\n\t\t{\n\t\t    if (slang->sl_compprog == NULL)\n\t\t\tbreak;\n\t\t    \/\/ the word so far was banned but we may try compounding\n\t\t    goodword_ends = FALSE;\n\t\t}\n\t    }\n\n\t    newscore = 0;\n\t    if (!soundfold)\t\/\/ soundfold words don't have flags\n\t    {\n\t\tif ((flags & WF_REGION)\n\t\t\t    && (((unsigned)flags >> 16) & lp->lp_region) == 0)\n\t\t    newscore += SCORE_REGION;\n\t\tif (flags & WF_RARE)\n\t\t    newscore += SCORE_RARE;\n\n\t\tif (!spell_valid_case(su->su_badflags,\n\t\t\t\t  captype(preword + sp->ts_prewordlen, NULL)))\n\t\t    newscore += SCORE_ICASE;\n\t    }\n\n\t    \/\/ TODO: how about splitting in the soundfold tree?\n\t    if (fword_ends\n\t\t    && goodword_ends\n\t\t    && sp->ts_fidx >= sp->ts_fidxtry\n\t\t    && compound_ok)\n\t    {\n\t\t\/\/ The badword also ends: add suggestions.\n#ifdef DEBUG_TRIEWALK\n\t\tif (soundfold && STRCMP(preword, \"smwrd\") == 0)\n\t\t{\n\t\t    int\t    j;\n\n\t\t    \/\/ print the stack of changes that brought us here\n\t\t    smsg(\"------ %s -------\", fword);\n\t\t    for (j = 0; j < depth; ++j)\n\t\t\tsmsg(\"%s\", changename[j]);\n\t\t}\n#endif\n\t\tif (soundfold)\n\t\t{\n\t\t    \/\/ For soundfolded words we need to find the original\n\t\t    \/\/ words, the edit distance and then add them.\n\t\t    add_sound_suggest(su, preword, sp->ts_score, lp);\n\t\t}\n\t\telse if (sp->ts_fidx > 0)\n\t\t{\n\t\t    \/\/ Give a penalty when changing non-word char to word\n\t\t    \/\/ char, e.g., \"thes,\" -> \"these\".\n\t\t    p = fword + sp->ts_fidx;\n\t\t    MB_PTR_BACK(fword, p);\n\t\t    if (!spell_iswordp(p, curwin) && *preword != NUL)\n\t\t    {\n\t\t\tp = preword + STRLEN(preword);\n\t\t\tMB_PTR_BACK(preword, p);\n\t\t\tif (spell_iswordp(p, curwin))\n\t\t\t    newscore += SCORE_NONWORD;\n\t\t    }\n\n\t\t    \/\/ Give a bonus to words seen before.\n\t\t    score = score_wordcount_adj(slang,\n\t\t\t\t\t\tsp->ts_score + newscore,\n\t\t\t\t\t\tpreword + sp->ts_prewordlen,\n\t\t\t\t\t\tsp->ts_prewordlen > 0);\n\n\t\t    \/\/ Add the suggestion if the score isn't too bad.\n\t\t    if (score <= su->su_maxscore)\n\t\t    {\n\t\t\tadd_suggestion(su, &su->su_ga, preword,\n\t\t\t\t    sp->ts_fidx - repextra,\n\t\t\t\t    score, 0, FALSE, lp->lp_sallang, FALSE);\n\n\t\t\tif (su->su_badflags & WF_MIXCAP)\n\t\t\t{\n\t\t\t    \/\/ We really don't know if the word should be\n\t\t\t    \/\/ upper or lower case, add both.\n\t\t\t    c = captype(preword, NULL);\n\t\t\t    if (c == 0 || c == WF_ALLCAP)\n\t\t\t    {\n\t\t\t\tmake_case_word(tword + sp->ts_splitoff,\n\t\t\t\t\t      preword + sp->ts_prewordlen,\n\t\t\t\t\t\t      c == 0 ? WF_ALLCAP : 0);\n\n\t\t\t\tadd_suggestion(su, &su->su_ga, preword,\n\t\t\t\t\tsp->ts_fidx - repextra,\n\t\t\t\t\tscore + SCORE_ICASE, 0, FALSE,\n\t\t\t\t\tlp->lp_sallang, FALSE);\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\n\t    \/\/ Try word split and\/or compounding.\n\t    if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends)\n\t\t    \/\/ Don't split halfway a character.\n\t\t    && (!has_mbyte || sp->ts_tcharlen == 0))\n\t    {\n\t\tint\ttry_compound;\n\t\tint\ttry_split;\n\n\t\t\/\/ If past the end of the bad word don't try a split.\n\t\t\/\/ Otherwise try changing the next word.  E.g., find\n\t\t\/\/ suggestions for \"the the\" where the second \"the\" is\n\t\t\/\/ different.  It's done like a split.\n\t\t\/\/ TODO: word split for soundfold words\n\t\ttry_split = (sp->ts_fidx - repextra < su->su_badlen)\n\t\t\t\t\t\t\t\t&& !soundfold;\n\n\t\t\/\/ Get here in several situations:\n\t\t\/\/ 1. The word in the tree ends:\n\t\t\/\/    If the word allows compounding try that.  Otherwise try\n\t\t\/\/    a split by inserting a space.  For both check that a\n\t\t\/\/    valid words starts at fword[sp->ts_fidx].\n\t\t\/\/    For NOBREAK do like compounding to be able to check if\n\t\t\/\/    the next word is valid.\n\t\t\/\/ 2. The badword does end, but it was due to a change (e.g.,\n\t\t\/\/    a swap).  No need to split, but do check that the\n\t\t\/\/    following word is valid.\n\t\t\/\/ 3. The badword and the word in the tree end.  It may still\n\t\t\/\/    be possible to compound another (short) word.\n\t\ttry_compound = FALSE;\n\t\tif (!soundfold\n\t\t\t&& !slang->sl_nocompoundsugs\n\t\t\t&& slang->sl_compprog != NULL\n\t\t\t&& ((unsigned)flags >> 24) != 0\n\t\t\t&& sp->ts_twordlen - sp->ts_splitoff\n\t\t\t\t\t\t       >= slang->sl_compminlen\n\t\t\t&& (!has_mbyte\n\t\t\t    || slang->sl_compminlen == 0\n\t\t\t    || mb_charlen(tword + sp->ts_splitoff)\n\t\t\t\t\t\t      >= slang->sl_compminlen)\n\t\t\t&& (slang->sl_compsylmax < MAXWLEN\n\t\t\t    || sp->ts_complen + 1 - sp->ts_compsplit\n\t\t\t\t\t\t\t  < slang->sl_compmax)\n\t\t\t&& (can_be_compound(sp, slang,\n\t\t\t\t\t compflags, ((unsigned)flags >> 24))))\n\n\t\t{\n\t\t    try_compound = TRUE;\n\t\t    compflags[sp->ts_complen] = ((unsigned)flags >> 24);\n\t\t    compflags[sp->ts_complen + 1] = NUL;\n\t\t}\n\n\t\t\/\/ For NOBREAK we never try splitting, it won't make any word\n\t\t\/\/ valid.\n\t\tif (slang->sl_nobreak && !slang->sl_nocompoundsugs)\n\t\t    try_compound = TRUE;\n\n\t\t\/\/ If we could add a compound word, and it's also possible to\n\t\t\/\/ split at this point, do the split first and set\n\t\t\/\/ TSF_DIDSPLIT to avoid doing it again.\n\t\telse if (!fword_ends\n\t\t\t&& try_compound\n\t\t\t&& (sp->ts_flags & TSF_DIDSPLIT) == 0)\n\t\t{\n\t\t    try_compound = FALSE;\n\t\t    sp->ts_flags |= TSF_DIDSPLIT;\n\t\t    --sp->ts_curi;\t    \/\/ do the same NUL again\n\t\t    compflags[sp->ts_complen] = NUL;\n\t\t}\n\t\telse\n\t\t    sp->ts_flags &= ~TSF_DIDSPLIT;\n\n\t\tif (try_split || try_compound)\n\t\t{\n\t\t    if (!try_compound && (!fword_ends || !goodword_ends))\n\t\t    {\n\t\t\t\/\/ If we're going to split need to check that the\n\t\t\t\/\/ words so far are valid for compounding.  If there\n\t\t\t\/\/ is only one word it must not have the NEEDCOMPOUND\n\t\t\t\/\/ flag.\n\t\t\tif (sp->ts_complen == sp->ts_compsplit\n\t\t\t\t\t\t     && (flags & WF_NEEDCOMP))\n\t\t\t    break;\n\t\t\tp = preword;\n\t\t\twhile (*skiptowhite(p) != NUL)\n\t\t\t    p = skipwhite(skiptowhite(p));\n\t\t\tif (sp->ts_complen > sp->ts_compsplit\n\t\t\t\t&& !can_compound(slang, p,\n\t\t\t\t\t\tcompflags + sp->ts_compsplit))\n\t\t\t    break;\n\n\t\t\tif (slang->sl_nosplitsugs)\n\t\t\t    newscore += SCORE_SPLIT_NO;\n\t\t\telse\n\t\t\t    newscore += SCORE_SPLIT;\n\n\t\t\t\/\/ Give a bonus to words seen before.\n\t\t\tnewscore = score_wordcount_adj(slang, newscore,\n\t\t\t\t\t   preword + sp->ts_prewordlen, TRUE);\n\t\t    }\n\n\t\t    if (TRY_DEEPER(su, stack, depth, newscore))\n\t\t    {\n\t\t\tgo_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\t\tif (!try_compound && !fword_ends)\n\t\t\t    sprintf(changename[depth], \"%.*s-%s: split\",\n\t\t\t\t sp->ts_twordlen, tword, fword + sp->ts_fidx);\n\t\t\telse\n\t\t\t    sprintf(changename[depth], \"%.*s-%s: compound\",\n\t\t\t\t sp->ts_twordlen, tword, fword + sp->ts_fidx);\n#endif\n\t\t\t\/\/ Save things to be restored at STATE_SPLITUNDO.\n\t\t\tsp->ts_save_badflags = su->su_badflags;\n\t\t\tPROF_STORE(sp->ts_state)\n\t\t\tsp->ts_state = STATE_SPLITUNDO;\n\n\t\t\t++depth;\n\t\t\tsp = &stack[depth];\n\n\t\t\t\/\/ Append a space to preword when splitting.\n\t\t\tif (!try_compound && !fword_ends)\n\t\t\t    STRCAT(preword, \" \");\n\t\t\tsp->ts_prewordlen = (char_u)STRLEN(preword);\n\t\t\tsp->ts_splitoff = sp->ts_twordlen;\n\t\t\tsp->ts_splitfidx = sp->ts_fidx;\n\n\t\t\t\/\/ If the badword has a non-word character at this\n\t\t\t\/\/ position skip it.  That means replacing the\n\t\t\t\/\/ non-word character with a space.  Always skip a\n\t\t\t\/\/ character when the word ends.  But only when the\n\t\t\t\/\/ good word can end.\n\t\t\tif (((!try_compound && !spell_iswordp_nmw(fword\n\t\t\t\t\t\t\t       + sp->ts_fidx,\n\t\t\t\t\t\t\t       curwin))\n\t\t\t\t    || fword_ends)\n\t\t\t\t&& fword[sp->ts_fidx] != NUL\n\t\t\t\t&& goodword_ends)\n\t\t\t{\n\t\t\t    int\t    l;\n\n\t\t\t    l = mb_ptr2len(fword + sp->ts_fidx);\n\t\t\t    if (fword_ends)\n\t\t\t    {\n\t\t\t\t\/\/ Copy the skipped character to preword.\n\t\t\t\tmch_memmove(preword + sp->ts_prewordlen,\n\t\t\t\t\t\t      fword + sp->ts_fidx, l);\n\t\t\t\tsp->ts_prewordlen += l;\n\t\t\t\tpreword[sp->ts_prewordlen] = NUL;\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tsp->ts_score -= SCORE_SPLIT - SCORE_SUBST;\n\t\t\t    sp->ts_fidx += l;\n\t\t\t}\n\n\t\t\t\/\/ When compounding include compound flag in\n\t\t\t\/\/ compflags[] (already set above).  When splitting we\n\t\t\t\/\/ may start compounding over again.\n\t\t\tif (try_compound)\n\t\t\t    ++sp->ts_complen;\n\t\t\telse\n\t\t\t    sp->ts_compsplit = sp->ts_complen;\n\t\t\tsp->ts_prefixdepth = PFD_NOPREFIX;\n\n\t\t\t\/\/ set su->su_badflags to the caps type at this\n\t\t\t\/\/ position\n\t\t\tif (has_mbyte)\n\t\t\t    n = nofold_len(fword, sp->ts_fidx, su->su_badptr);\n\t\t\telse\n\t\t\t    n = sp->ts_fidx;\n\t\t\tsu->su_badflags = badword_captype(su->su_badptr + n,\n\t\t\t\t\t       su->su_badptr + su->su_badlen);\n\n\t\t\t\/\/ Restart at top of the tree.\n\t\t\tsp->ts_arridx = 0;\n\n\t\t\t\/\/ If there are postponed prefixes, try these too.\n\t\t\tif (pbyts != NULL)\n\t\t\t{\n\t\t\t    byts = pbyts;\n\t\t\t    idxs = pidxs;\n\t\t\t    sp->ts_prefixdepth = PFD_PREFIXTREE;\n\t\t\t    PROF_STORE(sp->ts_state)\n\t\t\t    sp->ts_state = STATE_NOPREFIX;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\tcase STATE_SPLITUNDO:\n\t    \/\/ Undo the changes done for word split or compound word.\n\t    su->su_badflags = sp->ts_save_badflags;\n\n\t    \/\/ Continue looking for NUL bytes.\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_START;\n\n\t    \/\/ In case we went into the prefix tree.\n\t    byts = fbyts;\n\t    idxs = fidxs;\n\t    break;\n\n\tcase STATE_ENDNUL:\n\t    \/\/ Past the NUL bytes in the node.\n\t    su->su_badflags = sp->ts_save_badflags;\n\t    if (fword[sp->ts_fidx] == NUL && sp->ts_tcharlen == 0)\n\t    {\n\t\t\/\/ The badword ends, can't use STATE_PLAIN.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_DEL;\n\t\tbreak;\n\t    }\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_PLAIN;\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_PLAIN:\n\t    \/\/ Go over all possible bytes at this node, add each to tword[]\n\t    \/\/ and use child node.  \"ts_curi\" is the index.\n\t    arridx = sp->ts_arridx;\n\t    if (sp->ts_curi > byts[arridx])\n\t    {\n\t\t\/\/ Done all bytes at this node, do next state.  When still at\n\t\t\/\/ already changed bytes skip the other tricks.\n\t\tPROF_STORE(sp->ts_state)\n\t\tif (sp->ts_fidx >= sp->ts_fidxtry)\n\t\t    sp->ts_state = STATE_DEL;\n\t\telse\n\t\t    sp->ts_state = STATE_FINAL;\n\t    }\n\t    else\n\t    {\n\t\tarridx += sp->ts_curi++;\n\t\tc = byts[arridx];\n\n\t\t\/\/ Normal byte, go one level deeper.  If it's not equal to the\n\t\t\/\/ byte in the bad word adjust the score.  But don't even try\n\t\t\/\/ when the byte was already changed.  And don't try when we\n\t\t\/\/ just deleted this byte, accepting it is always cheaper than\n\t\t\/\/ delete + substitute.\n\t\tif (c == fword[sp->ts_fidx]\n\t\t\t|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE))\n\t\t    newscore = 0;\n\t\telse\n\t\t    newscore = SCORE_SUBST;\n\t\tif ((newscore == 0\n\t\t\t    || (sp->ts_fidx >= sp->ts_fidxtry\n\t\t\t\t&& ((sp->ts_flags & TSF_DIDDEL) == 0\n\t\t\t\t    || c != fword[sp->ts_delidx])))\n\t\t\t&& TRY_DEEPER(su, stack, depth, newscore))\n\t\t{\n\t\t    go_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\t    if (newscore > 0)\n\t\t\tsprintf(changename[depth], \"%.*s-%s: subst %c to %c\",\n\t\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\t\tfword[sp->ts_fidx], c);\n\t\t    else\n\t\t\tsprintf(changename[depth], \"%.*s-%s: accept %c\",\n\t\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\t\tfword[sp->ts_fidx]);\n#endif\n\t\t    ++depth;\n\t\t    sp = &stack[depth];\n\t\t    ++sp->ts_fidx;\n\t\t    tword[sp->ts_twordlen++] = c;\n\t\t    sp->ts_arridx = idxs[arridx];\n\t\t    if (newscore == SCORE_SUBST)\n\t\t\tsp->ts_isdiff = DIFF_YES;\n\t\t    if (has_mbyte)\n\t\t    {\n\t\t\t\/\/ Multi-byte characters are a bit complicated to\n\t\t\t\/\/ handle: They differ when any of the bytes differ\n\t\t\t\/\/ and then their length may also differ.\n\t\t\tif (sp->ts_tcharlen == 0)\n\t\t\t{\n\t\t\t    \/\/ First byte.\n\t\t\t    sp->ts_tcharidx = 0;\n\t\t\t    sp->ts_tcharlen = MB_BYTE2LEN(c);\n\t\t\t    sp->ts_fcharstart = sp->ts_fidx - 1;\n\t\t\t    sp->ts_isdiff = (newscore != 0)\n\t\t\t\t\t\t       ? DIFF_YES : DIFF_NONE;\n\t\t\t}\n\t\t\telse if (sp->ts_isdiff == DIFF_INSERT)\n\t\t\t    \/\/ When inserting trail bytes don't advance in the\n\t\t\t    \/\/ bad word.\n\t\t\t    --sp->ts_fidx;\n\t\t\tif (++sp->ts_tcharidx == sp->ts_tcharlen)\n\t\t\t{\n\t\t\t    \/\/ Last byte of character.\n\t\t\t    if (sp->ts_isdiff == DIFF_YES)\n\t\t\t    {\n\t\t\t\t\/\/ Correct ts_fidx for the byte length of the\n\t\t\t\t\/\/ character (we didn't check that before).\n\t\t\t\tsp->ts_fidx = sp->ts_fcharstart\n\t\t\t\t\t    + mb_ptr2len(\n\t\t\t\t\t\t    fword + sp->ts_fcharstart);\n\t\t\t\t\/\/ For changing a composing character adjust\n\t\t\t\t\/\/ the score from SCORE_SUBST to\n\t\t\t\t\/\/ SCORE_SUBCOMP.\n\t\t\t\tif (enc_utf8\n\t\t\t\t\t&& utf_iscomposing(\n\t\t\t\t\t    utf_ptr2char(tword\n\t\t\t\t\t\t+ sp->ts_twordlen\n\t\t\t\t\t\t\t   - sp->ts_tcharlen))\n\t\t\t\t\t&& utf_iscomposing(\n\t\t\t\t\t    utf_ptr2char(fword\n\t\t\t\t\t\t\t+ sp->ts_fcharstart)))\n\t\t\t\t    sp->ts_score -=\n\t\t\t\t\t\t  SCORE_SUBST - SCORE_SUBCOMP;\n\n\t\t\t\t\/\/ For a similar character adjust score from\n\t\t\t\t\/\/ SCORE_SUBST to SCORE_SIMILAR.\n\t\t\t\telse if (!soundfold\n\t\t\t\t\t&& slang->sl_has_map\n\t\t\t\t\t&& similar_chars(slang,\n\t\t\t\t\t    mb_ptr2char(tword\n\t\t\t\t\t\t+ sp->ts_twordlen\n\t\t\t\t\t\t\t   - sp->ts_tcharlen),\n\t\t\t\t\t    mb_ptr2char(fword\n\t\t\t\t\t\t\t+ sp->ts_fcharstart)))\n\t\t\t\t    sp->ts_score -=\n\t\t\t\t\t\t  SCORE_SUBST - SCORE_SIMILAR;\n\t\t\t    }\n\t\t\t    else if (sp->ts_isdiff == DIFF_INSERT\n\t\t\t\t\t && sp->ts_twordlen > sp->ts_tcharlen)\n\t\t\t    {\n\t\t\t\tp = tword + sp->ts_twordlen - sp->ts_tcharlen;\n\t\t\t\tc = mb_ptr2char(p);\n\t\t\t\tif (enc_utf8 && utf_iscomposing(c))\n\t\t\t\t{\n\t\t\t\t    \/\/ Inserting a composing char doesn't\n\t\t\t\t    \/\/ count that much.\n\t\t\t\t    sp->ts_score -= SCORE_INS - SCORE_INSCOMP;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    \/\/ If the previous character was the same,\n\t\t\t\t    \/\/ thus doubling a character, give a bonus\n\t\t\t\t    \/\/ to the score.  Also for the soundfold\n\t\t\t\t    \/\/ tree (might seem illogical but does\n\t\t\t\t    \/\/ give better scores).\n\t\t\t\t    MB_PTR_BACK(tword, p);\n\t\t\t\t    if (c == mb_ptr2char(p))\n\t\t\t\t\tsp->ts_score -= SCORE_INS\n\t\t\t\t\t\t\t       - SCORE_INSDUP;\n\t\t\t\t}\n\t\t\t    }\n\n\t\t\t    \/\/ Starting a new char, reset the length.\n\t\t\t    sp->ts_tcharlen = 0;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ If we found a similar char adjust the score.\n\t\t\t\/\/ We do this after calling go_deeper() because\n\t\t\t\/\/ it's slow.\n\t\t\tif (newscore != 0\n\t\t\t\t&& !soundfold\n\t\t\t\t&& slang->sl_has_map\n\t\t\t\t&& similar_chars(slang,\n\t\t\t\t\t\t   c, fword[sp->ts_fidx - 1]))\n\t\t\t    sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\tcase STATE_DEL:\n\t    \/\/ When past the first byte of a multi-byte char don't try\n\t    \/\/ delete\/insert\/swap a character.\n\t    if (has_mbyte && sp->ts_tcharlen > 0)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\t    \/\/ Try skipping one character in the bad word (delete it).\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_INS_PREP;\n\t    sp->ts_curi = 1;\n\t    if (soundfold && sp->ts_fidx == 0 && fword[sp->ts_fidx] == '*')\n\t\t\/\/ Deleting a vowel at the start of a word counts less, see\n\t\t\/\/ soundalike_score().\n\t\tnewscore = 2 * SCORE_DEL \/ 3;\n\t    else\n\t\tnewscore = SCORE_DEL;\n\t    if (fword[sp->ts_fidx] != NUL\n\t\t\t\t    && TRY_DEEPER(su, stack, depth, newscore))\n\t    {\n\t\tgo_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: delete %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tfword[sp->ts_fidx]);\n#endif\n\t\t++depth;\n\n\t\t\/\/ Remember what character we deleted, so that we can avoid\n\t\t\/\/ inserting it again.\n\t\tstack[depth].ts_flags |= TSF_DIDDEL;\n\t\tstack[depth].ts_delidx = sp->ts_fidx;\n\n\t\t\/\/ Advance over the character in fword[].  Give a bonus to the\n\t\t\/\/ score if the same character is following \"nn\" -> \"n\".  It's\n\t\t\/\/ a bit illogical for soundfold tree but it does give better\n\t\t\/\/ results.\n\t\tif (has_mbyte)\n\t\t{\n\t\t    c = mb_ptr2char(fword + sp->ts_fidx);\n\t\t    stack[depth].ts_fidx += mb_ptr2len(fword + sp->ts_fidx);\n\t\t    if (enc_utf8 && utf_iscomposing(c))\n\t\t\tstack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;\n\t\t    else if (c == mb_ptr2char(fword + stack[depth].ts_fidx))\n\t\t\tstack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;\n\t\t}\n\t\telse\n\t\t{\n\t\t    ++stack[depth].ts_fidx;\n\t\t    if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])\n\t\t\tstack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;\n\t\t}\n\t\tbreak;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_INS_PREP:\n\t    if (sp->ts_flags & TSF_DIDDEL)\n\t    {\n\t\t\/\/ If we just deleted a byte then inserting won't make sense,\n\t\t\/\/ a substitute is always cheaper.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_SWAP;\n\t\tbreak;\n\t    }\n\n\t    \/\/ skip over NUL bytes\n\t    n = sp->ts_arridx;\n\t    for (;;)\n\t    {\n\t\tif (sp->ts_curi > byts[n])\n\t\t{\n\t\t    \/\/ Only NUL bytes at this node, go to next state.\n\t\t    PROF_STORE(sp->ts_state)\n\t\t    sp->ts_state = STATE_SWAP;\n\t\t    break;\n\t\t}\n\t\tif (byts[n + sp->ts_curi] != NUL)\n\t\t{\n\t\t    \/\/ Found a byte to insert.\n\t\t    PROF_STORE(sp->ts_state)\n\t\t    sp->ts_state = STATE_INS;\n\t\t    break;\n\t\t}\n\t\t++sp->ts_curi;\n\t    }\n\t    break;\n\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_INS:\n\t    \/\/ Insert one byte.  Repeat this for each possible byte at this\n\t    \/\/ node.\n\t    n = sp->ts_arridx;\n\t    if (sp->ts_curi > byts[n])\n\t    {\n\t\t\/\/ Done all bytes at this node, go to next state.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_SWAP;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Do one more byte at this node, but:\n\t    \/\/ - Skip NUL bytes.\n\t    \/\/ - Skip the byte if it's equal to the byte in the word,\n\t    \/\/   accepting that byte is always better.\n\t    n += sp->ts_curi++;\n\t    c = byts[n];\n\t    if (soundfold && sp->ts_twordlen == 0 && c == '*')\n\t\t\/\/ Inserting a vowel at the start of a word counts less,\n\t\t\/\/ see soundalike_score().\n\t\tnewscore = 2 * SCORE_INS \/ 3;\n\t    else\n\t\tnewscore = SCORE_INS;\n\t    if (c != fword[sp->ts_fidx]\n\t\t\t\t    && TRY_DEEPER(su, stack, depth, newscore))\n\t    {\n\t\tgo_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: insert %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tc);\n#endif\n\t\t++depth;\n\t\tsp = &stack[depth];\n\t\ttword[sp->ts_twordlen++] = c;\n\t\tsp->ts_arridx = idxs[n];\n\t\tif (has_mbyte)\n\t\t{\n\t\t    fl = MB_BYTE2LEN(c);\n\t\t    if (fl > 1)\n\t\t    {\n\t\t\t\/\/ There are following bytes for the same character.\n\t\t\t\/\/ We must find all bytes before trying\n\t\t\t\/\/ delete\/insert\/swap\/etc.\n\t\t\tsp->ts_tcharlen = fl;\n\t\t\tsp->ts_tcharidx = 1;\n\t\t\tsp->ts_isdiff = DIFF_INSERT;\n\t\t    }\n\t\t}\n\t\telse\n\t\t    fl = 1;\n\t\tif (fl == 1)\n\t\t{\n\t\t    \/\/ If the previous character was the same, thus doubling a\n\t\t    \/\/ character, give a bonus to the score.  Also for\n\t\t    \/\/ soundfold words (illogical but does give a better\n\t\t    \/\/ score).\n\t\t    if (sp->ts_twordlen >= 2\n\t\t\t\t\t   && tword[sp->ts_twordlen - 2] == c)\n\t\t\tsp->ts_score -= SCORE_INS - SCORE_INSDUP;\n\t\t}\n\t    }\n\t    break;\n\n\tcase STATE_SWAP:\n\t    \/\/ Swap two bytes in the bad word: \"12\" -> \"21\".\n\t    \/\/ We change \"fword\" here, it's changed back afterwards at\n\t    \/\/ STATE_UNSWAP.\n\t    p = fword + sp->ts_fidx;\n\t    c = *p;\n\t    if (c == NUL)\n\t    {\n\t\t\/\/ End of word, can't swap or replace.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Don't swap if the first character is not a word character.\n\t    \/\/ SWAP3 etc. also don't make sense then.\n\t    if (!soundfold && !spell_iswordp(p, curwin))\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\n\t    if (has_mbyte)\n\t    {\n\t\tn = MB_CPTR2LEN(p);\n\t\tc = mb_ptr2char(p);\n\t\tif (p[n] == NUL)\n\t\t    c2 = NUL;\n\t\telse if (!soundfold && !spell_iswordp(p + n, curwin))\n\t\t    c2 = c; \/\/ don't swap non-word char\n\t\telse\n\t\t    c2 = mb_ptr2char(p + n);\n\t    }\n\t    else\n\t    {\n\t\tif (p[1] == NUL)\n\t\t    c2 = NUL;\n\t\telse if (!soundfold && !spell_iswordp(p + 1, curwin))\n\t\t    c2 = c; \/\/ don't swap non-word char\n\t\telse\n\t\t    c2 = p[1];\n\t    }\n\n\t    \/\/ When the second character is NUL we can't swap.\n\t    if (c2 == NUL)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\n\t    \/\/ When characters are identical, swap won't do anything.\n\t    \/\/ Also get here if the second char is not a word character.\n\t    if (c == c2)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_SWAP3;\n\t\tbreak;\n\t    }\n\t    if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: swap %c and %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tc, c2);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNSWAP;\n\t\t++depth;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    fl = mb_char2len(c2);\n\t\t    mch_memmove(p, p + n, fl);\n\t\t    mb_char2bytes(c, p + fl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    p[0] = c2;\n\t\t    p[1] = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 2;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ If this swap doesn't work then SWAP3 won't either.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNSWAP:\n\t    \/\/ Undo the STATE_SWAP swap: \"21\" -> \"12\".\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = mb_ptr2len(p);\n\t\tc = mb_ptr2char(p + n);\n\t\tmch_memmove(p + mb_ptr2len(p + n), p, n);\n\t\tmb_char2bytes(c, p);\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\t*p = p[1];\n\t\tp[1] = c;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_SWAP3:\n\t    \/\/ Swap two bytes, skipping one: \"123\" -> \"321\".  We change\n\t    \/\/ \"fword\" here, it's changed back afterwards at STATE_UNSWAP3.\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = MB_CPTR2LEN(p);\n\t\tc = mb_ptr2char(p);\n\t\tfl = MB_CPTR2LEN(p + n);\n\t\tc2 = mb_ptr2char(p + n);\n\t\tif (!soundfold && !spell_iswordp(p + n + fl, curwin))\n\t\t    c3 = c;\t\/\/ don't swap non-word char\n\t\telse\n\t\t    c3 = mb_ptr2char(p + n + fl);\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\tc2 = p[1];\n\t\tif (!soundfold && !spell_iswordp(p + 2, curwin))\n\t\t    c3 = c;\t\/\/ don't swap non-word char\n\t\telse\n\t\t    c3 = p[2];\n\t    }\n\n\t    \/\/ When characters are identical: \"121\" then SWAP3 result is\n\t    \/\/ identical, ROT3L result is same as SWAP: \"211\", ROT3L result is\n\t    \/\/ same as SWAP on next char: \"112\".  Thus skip all swapping.\n\t    \/\/ Also skip when c3 is NUL.\n\t    \/\/ Also get here when the third character is not a word character.\n\t    \/\/ Second character may any char: \"a.b\" -> \"b.a\"\n\t    if (c == c3 || c3 == NUL)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\t    if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP3);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: swap3 %c and %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tc, c3);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNSWAP3;\n\t\t++depth;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    tl = mb_char2len(c3);\n\t\t    mch_memmove(p, p + n + fl, tl);\n\t\t    mb_char2bytes(c2, p + tl);\n\t\t    mb_char2bytes(c, p + fl + tl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    p[0] = p[2];\n\t\t    p[2] = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 3;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNSWAP3:\n\t    \/\/ Undo STATE_SWAP3: \"321\" -> \"123\"\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = mb_ptr2len(p);\n\t\tc2 = mb_ptr2char(p + n);\n\t\tfl = mb_ptr2len(p + n);\n\t\tc = mb_ptr2char(p + n + fl);\n\t\ttl = mb_ptr2len(p + n + fl);\n\t\tmch_memmove(p + fl + tl, p, n);\n\t\tmb_char2bytes(c, p);\n\t\tmb_char2bytes(c2, p + tl);\n\t\tp = p + tl;\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\t*p = p[2];\n\t\tp[2] = c;\n\t\t++p;\n\t    }\n\n\t    if (!soundfold && !spell_iswordp(p, curwin))\n\t    {\n\t\t\/\/ Middle char is not a word char, skip the rotate.  First and\n\t\t\/\/ third char were already checked at swap and swap3.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Rotate three characters left: \"123\" -> \"231\".  We change\n\t    \/\/ \"fword\" here, it's changed back afterwards at STATE_UNROT3L.\n\t    if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP3);\n#ifdef DEBUG_TRIEWALK\n\t\tp = fword + sp->ts_fidx;\n\t\tsprintf(changename[depth], \"%.*s-%s: rotate left %c%c%c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tp[0], p[1], p[2]);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNROT3L;\n\t\t++depth;\n\t\tp = fword + sp->ts_fidx;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    n = MB_CPTR2LEN(p);\n\t\t    c = mb_ptr2char(p);\n\t\t    fl = MB_CPTR2LEN(p + n);\n\t\t    fl += MB_CPTR2LEN(p + n + fl);\n\t\t    mch_memmove(p, p + n, fl);\n\t\t    mb_char2bytes(c, p + fl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    c = *p;\n\t\t    *p = p[1];\n\t\t    p[1] = p[2];\n\t\t    p[2] = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 3;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNROT3L:\n\t    \/\/ Undo ROT3L: \"231\" -> \"123\"\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = mb_ptr2len(p);\n\t\tn += mb_ptr2len(p + n);\n\t\tc = mb_ptr2char(p + n);\n\t\ttl = mb_ptr2len(p + n);\n\t\tmch_memmove(p + tl, p, n);\n\t\tmb_char2bytes(c, p);\n\t    }\n\t    else\n\t    {\n\t\tc = p[2];\n\t\tp[2] = p[1];\n\t\tp[1] = *p;\n\t\t*p = c;\n\t    }\n\n\t    \/\/ Rotate three bytes right: \"123\" -> \"312\".  We change \"fword\"\n\t    \/\/ here, it's changed back afterwards at STATE_UNROT3R.\n\t    if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP3);\n#ifdef DEBUG_TRIEWALK\n\t\tp = fword + sp->ts_fidx;\n\t\tsprintf(changename[depth], \"%.*s-%s: rotate right %c%c%c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tp[0], p[1], p[2]);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNROT3R;\n\t\t++depth;\n\t\tp = fword + sp->ts_fidx;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    n = MB_CPTR2LEN(p);\n\t\t    n += MB_CPTR2LEN(p + n);\n\t\t    c = mb_ptr2char(p + n);\n\t\t    tl = MB_CPTR2LEN(p + n);\n\t\t    mch_memmove(p + tl, p, n);\n\t\t    mb_char2bytes(c, p);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    c = p[2];\n\t\t    p[2] = p[1];\n\t\t    p[1] = *p;\n\t\t    *p = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 3;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNROT3R:\n\t    \/\/ Undo ROT3R: \"312\" -> \"123\"\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tc = mb_ptr2char(p);\n\t\ttl = mb_ptr2len(p);\n\t\tn = mb_ptr2len(p + tl);\n\t\tn += mb_ptr2len(p + tl + n);\n\t\tmch_memmove(p, p + tl, n);\n\t\tmb_char2bytes(c, p + n);\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\t*p = p[1];\n\t\tp[1] = p[2];\n\t\tp[2] = c;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_REP_INI:\n\t    \/\/ Check if matching with REP items from the .aff file would work.\n\t    \/\/ Quickly skip if:\n\t    \/\/ - there are no REP items and we are not in the soundfold trie\n\t    \/\/ - the score is going to be too high anyway\n\t    \/\/ - already applied a REP item or swapped here\n\t    if ((lp->lp_replang == NULL && !soundfold)\n\t\t    || sp->ts_score + SCORE_REP >= su->su_maxscore\n\t\t    || sp->ts_fidx < sp->ts_fidxtry)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Use the first byte to quickly find the first entry that may\n\t    \/\/ match.  If the index is -1 there is none.\n\t    if (soundfold)\n\t\tsp->ts_curi = slang->sl_repsal_first[fword[sp->ts_fidx]];\n\t    else\n\t\tsp->ts_curi = lp->lp_replang->sl_rep_first[fword[sp->ts_fidx]];\n\n\t    if (sp->ts_curi < 0)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_REP;\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_REP:\n\t    \/\/ Try matching with REP items from the .aff file.  For each match\n\t    \/\/ replace the characters and check if the resulting word is\n\t    \/\/ valid.\n\t    p = fword + sp->ts_fidx;\n\n\t    if (soundfold)\n\t\tgap = &slang->sl_repsal;\n\t    else\n\t\tgap = &lp->lp_replang->sl_rep;\n\t    while (sp->ts_curi < gap->ga_len)\n\t    {\n\t\tftp = (fromto_T *)gap->ga_data + sp->ts_curi++;\n\t\tif (*ftp->ft_from != *p)\n\t\t{\n\t\t    \/\/ past possible matching entries\n\t\t    sp->ts_curi = gap->ga_len;\n\t\t    break;\n\t\t}\n\t\tif (STRNCMP(ftp->ft_from, p, STRLEN(ftp->ft_from)) == 0\n\t\t\t&& TRY_DEEPER(su, stack, depth, SCORE_REP))\n\t\t{\n\t\t    go_deeper(stack, depth, SCORE_REP);\n#ifdef DEBUG_TRIEWALK\n\t\t    sprintf(changename[depth], \"%.*s-%s: replace %s with %s\",\n\t\t\t    sp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\t    ftp->ft_from, ftp->ft_to);\n#endif\n\t\t    \/\/ Need to undo this afterwards.\n\t\t    PROF_STORE(sp->ts_state)\n\t\t    sp->ts_state = STATE_REP_UNDO;\n\n\t\t    \/\/ Change the \"from\" to the \"to\" string.\n\t\t    ++depth;\n\t\t    fl = (int)STRLEN(ftp->ft_from);\n\t\t    tl = (int)STRLEN(ftp->ft_to);\n\t\t    if (fl != tl)\n\t\t    {\n\t\t\tSTRMOVE(p + tl, p + fl);\n\t\t\trepextra += tl - fl;\n\t\t    }\n\t\t    mch_memmove(p, ftp->ft_to, tl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + tl;\n\t\t    stack[depth].ts_tcharlen = 0;\n\t\t    break;\n\t\t}\n\t    }\n\n\t    if (sp->ts_curi >= gap->ga_len && sp->ts_state == STATE_REP)\n\t    {\n\t\t\/\/ No (more) matches.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t    }\n\n\t    break;\n\n\tcase STATE_REP_UNDO:\n\t    \/\/ Undo a REP replacement and continue with the next one.\n\t    if (soundfold)\n\t\tgap = &slang->sl_repsal;\n\t    else\n\t\tgap = &lp->lp_replang->sl_rep;\n\t    ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;\n\t    fl = (int)STRLEN(ftp->ft_from);\n\t    tl = (int)STRLEN(ftp->ft_to);\n\t    p = fword + sp->ts_fidx;\n\t    if (fl != tl)\n\t    {\n\t\tSTRMOVE(p + fl, p + tl);\n\t\trepextra -= tl - fl;\n\t    }\n\t    mch_memmove(p, ftp->ft_from, fl);\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_REP;\n\t    break;\n\n\tdefault:\n\t    \/\/ Did all possible states at this level, go up one level.\n\t    --depth;\n\n\t    if (depth >= 0 && stack[depth].ts_prefixdepth == PFD_PREFIXTREE)\n\t    {\n\t\t\/\/ Continue in or go back to the prefix tree.\n\t\tbyts = pbyts;\n\t\tidxs = pidxs;\n\t    }\n\n\t    \/\/ Don't check for CTRL-C too often, it takes time.\n\t    if (--breakcheckcount == 0)\n\t    {\n\t\tui_breakcheck();\n\t\tbreakcheckcount = 1000;\n#ifdef FEAT_RELTIME\n\t\tif (spell_suggest_timeout > 0\n\t\t\t\t\t  && profile_passed_limit(&time_limit))\n\t\t    got_int = TRUE;\n#endif\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":12887,"total_token_length":13123,"max_tokens_setting":28000}
+{"idx":7032,"func":"\nint cli_scanpe(cli_ctx *ctx)\n{\n\tuint16_t e_magic; \/* DOS signature (\"MZ\") *\/\n\tuint16_t nsections;\n\tuint32_t e_lfanew; \/* address of new exe header *\/\n\tuint32_t ep, vep; \/* entry point (raw, virtual) *\/\n\tuint8_t polipos = 0;\n\ttime_t timestamp;\n\tstruct pe_image_file_hdr file_hdr;\n\tunion {\n\t    struct pe_image_optional_hdr64 opt64;\n\t    struct pe_image_optional_hdr32 opt32;\n\t} pe_opt;\n\tstruct pe_image_section_hdr *section_hdr;\n\tchar sname[9], epbuff[4096], *tempfile;\n\tuint32_t epsize;\n\tssize_t bytes, at;\n\tunsigned int i, found, upx_success = 0, min = 0, max = 0, err, overlays = 0;\n\tunsigned int ssize = 0, dsize = 0, dll = 0, pe_plus = 0, corrupted_cur;\n\tint (*upxfn)(const char *, uint32_t, char *, uint32_t *, uint32_t, uint32_t, uint32_t) = NULL;\n\tconst char *src = NULL;\n\tchar *dest = NULL;\n\tint ndesc, ret = CL_CLEAN, upack = 0, native=0;\n\tsize_t fsize;\n\tuint32_t valign, falign, hdr_size, j;\n\tstruct cli_exe_section *exe_sections;\n\tchar timestr[32];\n\tstruct pe_image_data_dir *dirs;\n\tstruct cli_bc_ctx *bc_ctx;\n\tfmap_t *map;\n\tstruct cli_pe_hook_data pedata;\n#ifdef HAVE__INTERNAL__SHA_COLLECT\n\tint sha_collect = ctx->sha_collect;\n#endif\n    const char *archtype=NULL, *subsystem=NULL;\n\tuint32_t viruses_found = 0;\n#if HAVE_JSON\n        int toval = 0;\n        struct json_object *pe_json=NULL;\n        char jsonbuf[128];\n#endif\n\n    if(!ctx) {\n\tcli_errmsg(\"cli_scanpe: ctx == NULL\\n\");\n\treturn CL_ENULLARG;\n    }\n\n#if HAVE_JSON\n    if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {\n        return CL_ETIMEOUT;\n    }\n\n    if (ctx->options & CL_SCAN_FILE_PROPERTIES) {\n        pe_json = get_pe_property(ctx);\n    }\n#endif\n    map = *ctx->fmap;\n    if(fmap_readn(map, &e_magic, 0, sizeof(e_magic)) != sizeof(e_magic)) {\n\tcli_dbgmsg(\"Can't read DOS signature\\n\");\n\treturn CL_CLEAN;\n    }\n\n    if(EC16(e_magic) != PE_IMAGE_DOS_SIGNATURE && EC16(e_magic) != PE_IMAGE_DOS_SIGNATURE_OLD) {\n\tcli_dbgmsg(\"Invalid DOS signature\\n\");\n\treturn CL_CLEAN;\n    }\n\n    if(fmap_readn(map, &e_lfanew, 58 + sizeof(e_magic), sizeof(e_lfanew)) != sizeof(e_lfanew)) {\n\tcli_dbgmsg(\"Can't read new header address\\n\");\n\t\/* truncated header? *\/\n\tif(DETECT_BROKEN_PE) {\n\t    cli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t    return CL_VIRUS;\n\t}\n\treturn CL_CLEAN;\n    }\n\n    e_lfanew = EC32(e_lfanew);\n    cli_dbgmsg(\"e_lfanew == %d\\n\", e_lfanew);\n    if(!e_lfanew) {\n\tcli_dbgmsg(\"Not a PE file\\n\");\n\treturn CL_CLEAN;\n    }\n\n    if(fmap_readn(map, &file_hdr, e_lfanew, sizeof(struct pe_image_file_hdr)) != sizeof(struct pe_image_file_hdr)) {\n\t\/* bad information in e_lfanew - probably not a PE file *\/\n\tcli_dbgmsg(\"Can't read file header\\n\");\n\treturn CL_CLEAN;\n    }\n\n    if(EC32(file_hdr.Magic) != PE_IMAGE_NT_SIGNATURE) {\n\tcli_dbgmsg(\"Invalid PE signature (probably NE file)\\n\");\n\treturn CL_CLEAN;\n    }\n\n    if(EC16(file_hdr.Characteristics) & 0x2000) {\n#if HAVE_JSON\n        if ((pe_json))\n            cli_jsonstr(pe_json, \"Type\", \"DLL\");\n#endif\n\tcli_dbgmsg(\"File type: DLL\\n\");\n\tdll = 1;\n    } else if(EC16(file_hdr.Characteristics) & 0x01) {\n#if HAVE_JSON\n        if ((pe_json))\n            cli_jsonstr(pe_json, \"Type\", \"EXE\");\n#endif\n\tcli_dbgmsg(\"File type: Executable\\n\");\n    }\n\n    switch(EC16(file_hdr.Machine)) {\n\tcase 0x0:\n        archtype = \"Unknown\";\n\t    break;\n\tcase 0x14c:\n        archtype = \"80386\";\n\t    break;\n\tcase 0x14d:\n        archtype = \"80486\";\n\t    break;\n\tcase 0x14e:\n        archtype = \"80586\";\n\t    break;\n\tcase 0x160:\n        archtype = \"R30000 (big-endian)\";\n\t    break;\n\tcase 0x162:\n        archtype = \"R3000\";\n\t    break;\n\tcase 0x166:\n        archtype = \"R4000\";\n\t    break;\n\tcase 0x168:\n        archtype = \"R10000\";\n\t    break;\n\tcase 0x184:\n        archtype = \"DEC Alpha AXP\";\n\t    break;\n\tcase 0x284:\n        archtype = \"DEC Alpha AXP 64bit\";\n\t    break;\n\tcase 0x1f0:\n        archtype = \"PowerPC\";\n\t    break;\n\tcase 0x200:\n        archtype = \"IA64\";\n\t    break;\n\tcase 0x268:\n        archtype = \"M68k\";\n\t    break;\n\tcase 0x266:\n        archtype = \"MIPS16\";\n\t    break;\n\tcase 0x366:\n        archtype = \"MIPS+FPU\";\n\t    break;\n\tcase 0x466:\n        archtype = \"MIPS16+FPU\";\n\t    break;\n\tcase 0x1a2:\n        archtype = \"Hitachi SH3\";\n\t    break;\n\tcase 0x1a3:\n        archtype = \"Hitachi SH3-DSP\";\n\t    break;\n\tcase 0x1a4:\n        archtype = \"Hitachi SH3-E\";\n\t    break;\n\tcase 0x1a6:\n        archtype = \"Hitachi SH4\";\n\t    break;\n\tcase 0x1a8:\n        archtype = \"Hitachi SH5\";\n\t    break;\n\tcase 0x1c0:\n        archtype = \"ARM\";\n\t    break;\n\tcase 0x1c2:\n        archtype = \"THUMB\";\n\t    break;\n\tcase 0x1d3:\n        archtype = \"AM33\";\n\t    break;\n\tcase 0x520:\n        archtype = \"Infineon TriCore\";\n\t    break;\n\tcase 0xcef:\n        archtype = \"CEF\";\n\t    break;\n\tcase 0xebc:\n        archtype = \"EFI Byte Code\";\n\t    break;\n\tcase 0x9041:\n        archtype = \"M32R\";\n\t    break;\n\tcase 0xc0ee:\n        archtype = \"CEEE\";\n\t    break;\n\tcase 0x8664:\n        archtype = \"AMD64\";\n\t    break;\n\tdefault:\n        archtype = \"Unknown\";\n    }\n\n    if ((archtype)) {\n        cli_dbgmsg(\"Machine type: %s\\n\", archtype);\n#if HAVE_JSON\n        cli_jsonstr(pe_json, \"ArchType\", archtype);\n#endif\n    }\n\n    nsections = EC16(file_hdr.NumberOfSections);\n    if(nsections < 1 || nsections > 96) {\n#if HAVE_JSON\n        pe_add_heuristic_property(ctx, \"BadNumberOfSections\");\n#endif\n\tif(DETECT_BROKEN_PE) {\n\t    cli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t    return CL_VIRUS;\n\t}\n\tif(!ctx->corrupted_input) {\n\t    if(nsections)\n\t\tcli_warnmsg(\"PE file contains %d sections\\n\", nsections);\n\t    else\n\t\tcli_warnmsg(\"PE file contains no sections\\n\");\n\t}\n\treturn CL_CLEAN;\n    }\n    cli_dbgmsg(\"NumberOfSections: %d\\n\", nsections);\n\n    timestamp = (time_t) EC32(file_hdr.TimeDateStamp);\n    cli_dbgmsg(\"TimeDateStamp: %s\", cli_ctime(×tamp, timestr, sizeof(timestr)));\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"TimeDateStamp\", cli_ctime(×tamp, timestr, sizeof(timestr)));\n#endif\n\n    cli_dbgmsg(\"SizeOfOptionalHeader: %x\\n\", EC16(file_hdr.SizeOfOptionalHeader));\n\n#if HAVE_JSON\n    cli_jsonint(pe_json, \"SizeOfOptionalHeader\", EC16(file_hdr.SizeOfOptionalHeader));\n#endif\n\n    if (EC16(file_hdr.SizeOfOptionalHeader) < sizeof(struct pe_image_optional_hdr32)) {\n#if HAVE_JSON\n        pe_add_heuristic_property(ctx, \"BadOptionalHeaderSize\");\n#endif\n        cli_dbgmsg(\"SizeOfOptionalHeader too small\\n\");\n\tif(DETECT_BROKEN_PE) {\n\t    cli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t    return CL_VIRUS;\n\t}\n\treturn CL_CLEAN;\n    }\n\n    at = e_lfanew + sizeof(struct pe_image_file_hdr);\n    if(fmap_readn(map, &optional_hdr32, at, sizeof(struct pe_image_optional_hdr32)) != sizeof(struct pe_image_optional_hdr32)) {\n        cli_dbgmsg(\"Can't read optional file header\\n\");\n\tif(DETECT_BROKEN_PE) {\n\t    cli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t    return CL_VIRUS;\n\t}\n\treturn CL_CLEAN;\n    }\n    at += sizeof(struct pe_image_optional_hdr32);\n\n    \/* This will be a chicken and egg problem until we drop 9x *\/\n    if(EC16(optional_hdr64.Magic)==PE32P_SIGNATURE) {\n#if HAVE_JSON\n        pe_add_heuristic_property(ctx, \"BadOptionalHeaderSizePE32Plus\");\n#endif\n        if(EC16(file_hdr.SizeOfOptionalHeader)!=sizeof(struct pe_image_optional_hdr64)) {\n\t    \/* FIXME: need to play around a bit more with xp64 *\/\n\t    cli_dbgmsg(\"Incorrect SizeOfOptionalHeader for PE32+\\n\");\n\t    if(DETECT_BROKEN_PE) {\n\t\tcli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t\treturn CL_VIRUS;\n\t    }\n\t    return CL_CLEAN;\n\t}\n\tpe_plus = 1;\n    }\n\n    if(!pe_plus) { \/* PE *\/\n\tif (EC16(file_hdr.SizeOfOptionalHeader)!=sizeof(struct pe_image_optional_hdr32)) {\n\t    \/* Seek to the end of the long header *\/\n\t    at += EC16(file_hdr.SizeOfOptionalHeader)-sizeof(struct pe_image_optional_hdr32);\n\t}\n\n\tif(DCONF & PE_CONF_UPACK)\n\t    upack = (EC16(file_hdr.SizeOfOptionalHeader)==0x148);\n\n\tvep = EC32(optional_hdr32.AddressOfEntryPoint);\n\thdr_size = EC32(optional_hdr32.SizeOfHeaders);\n\tcli_dbgmsg(\"File format: PE\\n\");\n\n\tcli_dbgmsg(\"MajorLinkerVersion: %d\\n\", optional_hdr32.MajorLinkerVersion);\n\tcli_dbgmsg(\"MinorLinkerVersion: %d\\n\", optional_hdr32.MinorLinkerVersion);\n\tcli_dbgmsg(\"SizeOfCode: 0x%x\\n\", EC32(optional_hdr32.SizeOfCode));\n\tcli_dbgmsg(\"SizeOfInitializedData: 0x%x\\n\", EC32(optional_hdr32.SizeOfInitializedData));\n\tcli_dbgmsg(\"SizeOfUninitializedData: 0x%x\\n\", EC32(optional_hdr32.SizeOfUninitializedData));\n\tcli_dbgmsg(\"AddressOfEntryPoint: 0x%x\\n\", vep);\n\tcli_dbgmsg(\"BaseOfCode: 0x%x\\n\", EC32(optional_hdr32.BaseOfCode));\n\tcli_dbgmsg(\"SectionAlignment: 0x%x\\n\", EC32(optional_hdr32.SectionAlignment));\n\tcli_dbgmsg(\"FileAlignment: 0x%x\\n\", EC32(optional_hdr32.FileAlignment));\n\tcli_dbgmsg(\"MajorSubsystemVersion: %d\\n\", EC16(optional_hdr32.MajorSubsystemVersion));\n\tcli_dbgmsg(\"MinorSubsystemVersion: %d\\n\", EC16(optional_hdr32.MinorSubsystemVersion));\n\tcli_dbgmsg(\"SizeOfImage: 0x%x\\n\", EC32(optional_hdr32.SizeOfImage));\n\tcli_dbgmsg(\"SizeOfHeaders: 0x%x\\n\", hdr_size);\n\tcli_dbgmsg(\"NumberOfRvaAndSizes: %d\\n\", EC32(optional_hdr32.NumberOfRvaAndSizes));\n\tdirs = optional_hdr32.DataDirectory;\n#if HAVE_JSON\n    cli_jsonint(pe_json, \"MajorLinkerVersion\", optional_hdr32.MajorLinkerVersion);\n    cli_jsonint(pe_json, \"MinorLinkerVersion\", optional_hdr32.MinorLinkerVersion);\n    cli_jsonint(pe_json, \"SizeOfCode\", EC32(optional_hdr32.SizeOfCode));\n    cli_jsonint(pe_json, \"SizeOfInitializedData\", EC32(optional_hdr32.SizeOfInitializedData));\n    cli_jsonint(pe_json, \"SizeOfUninitializedData\", EC32(optional_hdr32.SizeOfUninitializedData));\n    cli_jsonint(pe_json, \"NumberOfRvaAndSizes\", EC32(optional_hdr32.NumberOfRvaAndSizes));\n    cli_jsonint(pe_json, \"MajorSubsystemVersion\", EC16(optional_hdr32.MajorSubsystemVersion));\n    cli_jsonint(pe_json, \"MinorSubsystemVersion\", EC16(optional_hdr32.MinorSubsystemVersion));\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr32.BaseOfCode));\n    cli_jsonstr(pe_json, \"BaseOfCode\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr32.SectionAlignment));\n    cli_jsonstr(pe_json, \"SectionAlignment\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr32.FileAlignment));\n    cli_jsonstr(pe_json, \"FileAlignment\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr32.SizeOfImage));\n    cli_jsonstr(pe_json, \"SizeOfImage\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", hdr_size);\n    cli_jsonstr(pe_json, \"SizeOfHeaders\", jsonbuf);\n#endif\n\n    } else { \/* PE+ *\/\n        \/* read the remaining part of the header *\/\n        if(fmap_readn(map, &optional_hdr32 + 1, at, sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32)) != sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32)) {\n\t    cli_dbgmsg(\"Can't read optional file header\\n\");\n\t    if(DETECT_BROKEN_PE) {\n\t\tcli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t\treturn CL_VIRUS;\n\t    }\n\t    return CL_CLEAN;\n\t}\n\tat += sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32);\n\tvep = EC32(optional_hdr64.AddressOfEntryPoint);\n\thdr_size = EC32(optional_hdr64.SizeOfHeaders);\n\tcli_dbgmsg(\"File format: PE32+\\n\");\n\n\tcli_dbgmsg(\"MajorLinkerVersion: %d\\n\", optional_hdr64.MajorLinkerVersion);\n\tcli_dbgmsg(\"MinorLinkerVersion: %d\\n\", optional_hdr64.MinorLinkerVersion);\n\tcli_dbgmsg(\"SizeOfCode: 0x%x\\n\", EC32(optional_hdr64.SizeOfCode));\n\tcli_dbgmsg(\"SizeOfInitializedData: 0x%x\\n\", EC32(optional_hdr64.SizeOfInitializedData));\n\tcli_dbgmsg(\"SizeOfUninitializedData: 0x%x\\n\", EC32(optional_hdr64.SizeOfUninitializedData));\n\tcli_dbgmsg(\"AddressOfEntryPoint: 0x%x\\n\", vep);\n\tcli_dbgmsg(\"BaseOfCode: 0x%x\\n\", EC32(optional_hdr64.BaseOfCode));\n\tcli_dbgmsg(\"SectionAlignment: 0x%x\\n\", EC32(optional_hdr64.SectionAlignment));\n\tcli_dbgmsg(\"FileAlignment: 0x%x\\n\", EC32(optional_hdr64.FileAlignment));\n\tcli_dbgmsg(\"MajorSubsystemVersion: %d\\n\", EC16(optional_hdr64.MajorSubsystemVersion));\n\tcli_dbgmsg(\"MinorSubsystemVersion: %d\\n\", EC16(optional_hdr64.MinorSubsystemVersion));\n\tcli_dbgmsg(\"SizeOfImage: 0x%x\\n\", EC32(optional_hdr64.SizeOfImage));\n\tcli_dbgmsg(\"SizeOfHeaders: 0x%x\\n\", hdr_size);\n\tcli_dbgmsg(\"NumberOfRvaAndSizes: %d\\n\", EC32(optional_hdr64.NumberOfRvaAndSizes));\n\tdirs = optional_hdr64.DataDirectory;\n#if HAVE_JSON\n    cli_jsonint(pe_json, \"MajorLinkerVersion\", optional_hdr64.MajorLinkerVersion);\n    cli_jsonint(pe_json, \"MinorLinkerVersion\", optional_hdr64.MinorLinkerVersion);\n    cli_jsonint(pe_json, \"SizeOfCode\", EC32(optional_hdr64.SizeOfCode));\n    cli_jsonint(pe_json, \"SizeOfInitializedData\", EC32(optional_hdr64.SizeOfInitializedData));\n    cli_jsonint(pe_json, \"SizeOfUninitializedData\", EC32(optional_hdr64.SizeOfUninitializedData));\n    cli_jsonint(pe_json, \"NumberOfRvaAndSizes\", EC32(optional_hdr64.NumberOfRvaAndSizes));\n    cli_jsonint(pe_json, \"MajorSubsystemVersion\", EC16(optional_hdr64.MajorSubsystemVersion));\n    cli_jsonint(pe_json, \"MinorSubsystemVersion\", EC16(optional_hdr64.MinorSubsystemVersion));\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr64.BaseOfCode));\n    cli_jsonstr(pe_json, \"BaseOfCode\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr64.SectionAlignment));\n    cli_jsonstr(pe_json, \"SectionAlignment\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr64.FileAlignment));\n    cli_jsonstr(pe_json, \"FileAlignment\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", EC32(optional_hdr64.SizeOfImage));\n    cli_jsonstr(pe_json, \"SizeOfImage\", jsonbuf);\n\n    snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", hdr_size);\n    cli_jsonstr(pe_json, \"SizeOfHeaders\", jsonbuf);\n#endif\n    }\n\n#if HAVE_JSON\n    if (ctx->options & CL_SCAN_FILE_PROPERTIES) {\n        snprintf(jsonbuf, sizeof(jsonbuf), \"0x%x\", vep);\n        cli_jsonstr(pe_json, \"EntryPoint\", jsonbuf);\n    }\n#endif\n\n\n    switch(pe_plus ? EC16(optional_hdr64.Subsystem) : EC16(optional_hdr32.Subsystem)) {\n\tcase 0:\n        subsystem = \"Unknown\";\n\t    break;\n\tcase 1:\n        subsystem = \"Native (svc)\";\n\t    native = 1;\n\t    break;\n\tcase 2:\n        subsystem = \"Win32 GUI\";\n\t    break;\n\tcase 3:\n        subsystem = \"Win32 console\";\n\t    break;\n\tcase 5:\n        subsystem = \"OS\/2 console\";\n\t    break;\n\tcase 7:\n        subsystem = \"POSIX console\";\n\t    break;\n\tcase 8:\n        subsystem = \"Native Win9x driver\";\n\t    break;\n\tcase 9:\n        subsystem = \"WinCE GUI\";\n\t    break;\n\tcase 10:\n        subsystem = \"EFI application\";\n\t    break;\n\tcase 11:\n        subsystem = \"EFI driver\";\n\t    break;\n\tcase 12:\n        subsystem = \"EFI runtime driver\";\n\t    break;\n\tcase 13:\n        subsystem = \"EFI ROM image\";\n\t    break;\n\tcase 14:\n        subsystem = \"Xbox\";\n\t    break;\n\tcase 16:\n        subsystem = \"Boot application\";\n\t    break;\n\tdefault:\n        subsystem = \"Unknown\";\n    }\n\n    cli_dbgmsg(\"Subsystem: %s\\n\", subsystem);\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Subsystem\", subsystem);\n#endif\n\n    cli_dbgmsg(\"------------------------------------\\n\");\n\n    if (DETECT_BROKEN_PE && !native && (!(pe_plus?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment)) || (pe_plus?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment))%0x1000)) {\n        cli_dbgmsg(\"Bad virtual alignemnt\\n\");\n\tcli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\treturn CL_VIRUS;\n    }\n\n    if (DETECT_BROKEN_PE && !native && (!(pe_plus?EC32(optional_hdr64.FileAlignment):EC32(optional_hdr32.FileAlignment)) || (pe_plus?EC32(optional_hdr64.FileAlignment):EC32(optional_hdr32.FileAlignment))%0x200)) {\n        cli_dbgmsg(\"Bad file alignemnt\\n\");\n\tcli_append_virus(ctx, \"Heuristics.Broken.Executable\");\n\treturn CL_VIRUS;\n    }\n\n    fsize = map->len;\n\n    section_hdr = (struct pe_image_section_hdr *) cli_calloc(nsections, sizeof(struct pe_image_section_hdr));\n\n    if(!section_hdr) {\n\tcli_dbgmsg(\"Can't allocate memory for section headers\\n\");\n\treturn CL_EMEM;\n    }\n\n    exe_sections = (struct cli_exe_section *) cli_calloc(nsections, sizeof(struct cli_exe_section));\n    \n    if(!exe_sections) {\n\tcli_dbgmsg(\"Can't allocate memory for section headers\\n\");\n\tfree(section_hdr);\n\treturn CL_EMEM;\n    }\n\n    valign = (pe_plus)?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment);\n    falign = (pe_plus)?EC32(optional_hdr64.FileAlignment):EC32(optional_hdr32.FileAlignment);\n\n    if(fmap_readn(map, section_hdr, at, sizeof(struct pe_image_section_hdr)*nsections) != (int)(nsections*sizeof(struct pe_image_section_hdr))) {\n        cli_dbgmsg(\"Can't read section header\\n\");\n\tcli_dbgmsg(\"Possibly broken PE file\\n\");\n\tfree(section_hdr);\n\tfree(exe_sections);\n\tif(DETECT_BROKEN_PE) {\n\t    cli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t    return CL_VIRUS;\n\t}\n\treturn CL_CLEAN;\n    }\n    at += sizeof(struct pe_image_section_hdr)*nsections;\n\n    for(i = 0; falign!=0x200 && iexe_sections[i].raw && !CLI_ISCONTAINED(0, (uint32_t) fsize, exe_sections[i].raw, exe_sections[i].rsz))\n\t    exe_sections[i].rsz = fsize - exe_sections[i].raw;\n\t\n\tcli_dbgmsg(\"Section %d\\n\", i);\n\tcli_dbgmsg(\"Section name: %s\\n\", sname);\n\tcli_dbgmsg(\"Section data (from headers - in memory)\\n\");\n\tcli_dbgmsg(\"VirtualSize: 0x%x 0x%x\\n\", exe_sections[i].uvsz, exe_sections[i].vsz);\n\tcli_dbgmsg(\"VirtualAddress: 0x%x 0x%x\\n\", exe_sections[i].urva, exe_sections[i].rva);\n\tcli_dbgmsg(\"SizeOfRawData: 0x%x 0x%x\\n\", exe_sections[i].ursz, exe_sections[i].rsz);\n\tcli_dbgmsg(\"PointerToRawData: 0x%x 0x%x\\n\", exe_sections[i].uraw, exe_sections[i].raw);\n\n\tif(exe_sections[i].chr & 0x20) {\n\t    cli_dbgmsg(\"Section contains executable code\\n\");\n\n\t    if(exe_sections[i].vsz < exe_sections[i].rsz) {\n\t\tcli_dbgmsg(\"Section contains free space\\n\");\n\t\t\/*\n\t\tcli_dbgmsg(\"Dumping %d bytes\\n\", section_hdr.SizeOfRawData - section_hdr.VirtualSize);\n\t\tddump(desc, section_hdr.PointerToRawData + section_hdr.VirtualSize, section_hdr.SizeOfRawData - section_hdr.VirtualSize, cli_gentemp(NULL));\n\t\t*\/\n\n\t    }\n\t}\n\n\tif(exe_sections[i].chr & 0x20000000)\n\t    cli_dbgmsg(\"Section's memory is executable\\n\");\n\n\tif(exe_sections[i].chr & 0x80000000)\n\t    cli_dbgmsg(\"Section's memory is writeable\\n\");\n\n\tif (DETECT_BROKEN_PE && (!valign || (exe_sections[i].urva % valign))) { \/* Bad virtual alignment *\/\n\t    cli_dbgmsg(\"VirtualAddress is misaligned\\n\");\n\t    cli_dbgmsg(\"------------------------------------\\n\");\n\t    cli_append_virus(ctx, \"Heuristics.Broken.Executable\");\n\t    free(section_hdr);\n\t    free(exe_sections);\n\t    return CL_VIRUS;\n\t}\n\n\tif (exe_sections[i].rsz) { \/* Don't bother with virtual only sections *\/\n\t    if (exe_sections[i].raw >= fsize) { \/* really broken *\/\n\t      cli_dbgmsg(\"Broken PE file - Section %d starts beyond the end of file (Offset@ %lu, Total filesize %lu)\\n\", i, (unsigned long)exe_sections[i].raw, (unsigned long)fsize);\n\t      cli_dbgmsg(\"------------------------------------\\n\");\n\t\tfree(section_hdr);\n\t\tfree(exe_sections);\n\t\tif(DETECT_BROKEN_PE) {\n\t\t    cli_append_virus(ctx, \"Heuristics.Broken.Executable\");\n\t\t    return CL_VIRUS;\n\t\t}\n\t\treturn CL_CLEAN; \/* no ninjas to see here! move along! *\/\n\t    }\n\n\t    if(SCAN_ALGO && (DCONF & PE_CONF_POLIPOS) && !*sname && exe_sections[i].vsz > 40000 && exe_sections[i].vsz < 70000 && exe_sections[i].chr == 0xe0000060) polipos = i;\n\n\t    \/* check hash section sigs *\/\n\t    if((DCONF & PE_CONF_MD5SECT) && ctx->engine->hm_mdb) {\n\t        ret = scan_pe_mdb(ctx, &exe_sections[i]);\n\t        if (ret != CL_CLEAN) {\n\t            if (ret != CL_VIRUS)\n\t                cli_errmsg(\"scan_pe: scan_pe_mdb failed: %s!\\n\", cl_strerror(ret));\n\t\t    cli_dbgmsg(\"------------------------------------\\n\");\n\t            free(section_hdr);\n\t            free(exe_sections);\n\t            return ret;\n\t        }\n\t    }\n\t}\n\tcli_dbgmsg(\"------------------------------------\\n\");\n\n\tif (exe_sections[i].urva>>31 || exe_sections[i].uvsz>>31 || (exe_sections[i].rsz && exe_sections[i].uraw>>31) || exe_sections[i].ursz>>31) {\n\t    cli_dbgmsg(\"Found PE values with sign bit set\\n\");\n\t    free(section_hdr);\n\t    free(exe_sections);\n\t    if(DETECT_BROKEN_PE) {\n\t\tcli_append_virus(ctx, \"Heuristics.Broken.Executable\");\n\t\treturn CL_VIRUS;\n\t    }\n\t    return CL_CLEAN;\n\t}\n\n\tif(!i) {\n\t    if (DETECT_BROKEN_PE && exe_sections[i].urva!=hdr_size) { \/* Bad first section RVA *\/\n\t        cli_dbgmsg(\"First section is in the wrong place\\n\");\n\t\tcli_append_virus(ctx, \"Heuristics.Broken.Executable\");\n\t\tfree(section_hdr);\n\t\tfree(exe_sections);\n\t\treturn CL_VIRUS;\n\t    }\n\t    min = exe_sections[i].rva;\n\t    max = exe_sections[i].rva + exe_sections[i].rsz;\n\t} else {\n\t    if (DETECT_BROKEN_PE && exe_sections[i].urva - exe_sections[i-1].urva != exe_sections[i-1].vsz) { \/* No holes, no overlapping, no virtual disorder *\/\n\t        cli_dbgmsg(\"Virtually misplaced section (wrong order, overlapping, non contiguous)\\n\");\n\t\tcli_append_virus(ctx, \"Heuristics.Broken.Executable\");\n\t\tfree(section_hdr);\n\t\tfree(exe_sections);\n\t\treturn CL_VIRUS;\n\t    }\n\t    if(exe_sections[i].rva < min)\n\t        min = exe_sections[i].rva;\n\n\t    if(exe_sections[i].rva + exe_sections[i].rsz > max) {\n\t        max = exe_sections[i].rva + exe_sections[i].rsz;\n\t\toverlays = exe_sections[i].raw + exe_sections[i].rsz;\n\t    }\n\t}\n    }\n\n    free(section_hdr);\n\n    if(!(ep = cli_rawaddr(vep, exe_sections, nsections, &err, fsize, hdr_size)) && err) {\n\tcli_dbgmsg(\"EntryPoint out of file\\n\");\n\tfree(exe_sections);\n\tif(DETECT_BROKEN_PE) {\n\t    cli_append_virus(ctx,\"Heuristics.Broken.Executable\");\n\t    return CL_VIRUS;\n\t}\n\treturn CL_CLEAN;\n    }\n\n#if HAVE_JSON\n    cli_jsonint(pe_json, \"EntryPointOffset\", ep);\n\n    if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {\n        return CL_ETIMEOUT;\n    }\n#endif\n\n    cli_dbgmsg(\"EntryPoint offset: 0x%x (%d)\\n\", ep, ep);\n\n    if(pe_plus) { \/* Do not continue for PE32+ files *\/\n\tfree(exe_sections);\n\treturn CL_CLEAN;\n    }\n\n    epsize = fmap_readn(map, epbuff, ep, 4096);\n\n\n    \/* Disasm scan disabled since it's now handled by the bytecode *\/\n\n    \/* CLI_UNPTEMP(\"DISASM\",(exe_sections,0)); *\/\n    \/* if(disasmbuf((unsigned char*)epbuff, epsize, ndesc)) *\/\n    \/* \tret = cli_scandesc(ndesc, ctx, CL_TYPE_PE_DISASM, 1, NULL, AC_SCAN_VIR); *\/\n    \/* close(ndesc); *\/\n    \/* CLI_TMPUNLK(); *\/\n    \/* free(tempfile); *\/\n    \/* if(ret == CL_VIRUS) { *\/\n    \/* \tfree(exe_sections); *\/\n    \/* \treturn ret; *\/\n    \/* } *\/\n\n    if(overlays) {\n\tint overlays_sz = fsize - overlays;\n\tif(overlays_sz > 0) {\n\t    ret = cli_scanishield(ctx, overlays, overlays_sz);\n\t    if(ret != CL_CLEAN) {\n\t\tfree(exe_sections);\n\t\treturn ret;\n\t    }\n\t}\n    }\n\n    pedata.nsections = nsections;\n    pedata.ep = ep;\n    pedata.offset = 0;\n    memcpy(&pedata.file_hdr, &file_hdr, sizeof(file_hdr));\n    memcpy(&pedata.opt32, &pe_opt.opt32, sizeof(pe_opt.opt32));\n    memcpy(&pedata.opt64, &pe_opt.opt64, sizeof(pe_opt.opt64));\n    memcpy(&pedata.dirs, dirs, sizeof(pedata.dirs));\n    pedata.e_lfanew = e_lfanew;\n    pedata.overlays = overlays;\n    pedata.overlays_sz = fsize - overlays;\n    pedata.hdr_size = hdr_size;\n\n    \/* Bytecode BC_PE_ALL hook *\/\n    bc_ctx = cli_bytecode_context_alloc();\n    if (!bc_ctx) {\n\tcli_errmsg(\"cli_scanpe: can't allocate memory for bc_ctx\\n\");\n\tfree(exe_sections);\n\treturn CL_EMEM;\n    }\n    cli_bytecode_context_setpe(bc_ctx, &pedata, exe_sections);\n    cli_bytecode_context_setctx(bc_ctx, ctx);\n    ret = cli_bytecode_runhook(ctx, ctx->engine, bc_ctx, BC_PE_ALL, map);\n    switch (ret) {\n        case CL_ENULLARG:\n            cli_warnmsg(\"cli_scanpe: NULL argument supplied\\n\");\n            break;\n        case CL_VIRUS:\n        case CL_BREAK:\n            free(exe_sections);\n            cli_bytecode_context_destroy(bc_ctx);\n            return ret == CL_VIRUS ? CL_VIRUS : CL_CLEAN;\n    }\n    cli_bytecode_context_destroy(bc_ctx);\n    \/* Attempt to detect some popular polymorphic viruses *\/\n\n    \/* W32.Parite.B *\/\n    if(SCAN_ALGO && (DCONF & PE_CONF_PARITE) && !dll && epsize == 4096 && ep == exe_sections[nsections - 1].raw) {\n        const char *pt = cli_memstr(epbuff, 4040, \"\\x47\\x65\\x74\\x50\\x72\\x6f\\x63\\x41\\x64\\x64\\x72\\x65\\x73\\x73\\x00\", 15);\n\tif(pt) {\n\t    pt += 15;\n\t    if((((uint32_t)cli_readint32(pt) ^ (uint32_t)cli_readint32(pt + 4)) == 0x505a4f) && (((uint32_t)cli_readint32(pt + 8) ^ (uint32_t)cli_readint32(pt + 12)) == 0xffffb) && (((uint32_t)cli_readint32(pt + 16) ^ (uint32_t)cli_readint32(pt + 20)) == 0xb8)) {\n\t        cli_append_virus(ctx,\"Heuristics.W32.Parite.B\");\n\t\tif (!SCAN_ALL) {\n\t\t    free(exe_sections);\n\t\t    return CL_VIRUS;\n\t\t}\n\t\tviruses_found++;\n\t    }\n\t}\n    }\n\n    \/* Kriz *\/\n    if(SCAN_ALGO && (DCONF & PE_CONF_KRIZ) && epsize >= 200 && CLI_ISCONTAINED(exe_sections[nsections - 1].raw, exe_sections[nsections - 1].rsz, ep, 0x0fd2) && epbuff[1]=='\\x9c' && epbuff[2]=='\\x60') {\n\tenum {KZSTRASH,KZSCDELTA,KZSPDELTA,KZSGETSIZE,KZSXORPRFX,KZSXOR,KZSDDELTA,KZSLOOP,KZSTOP};\n\tuint8_t kzs[] = {KZSTRASH,KZSCDELTA,KZSPDELTA,KZSGETSIZE,KZSTRASH,KZSXORPRFX,KZSXOR,KZSTRASH,KZSDDELTA,KZSTRASH,KZSLOOP,KZSTOP};\n\tuint8_t *kzstate = kzs;\n\tuint8_t *kzcode = (uint8_t *)epbuff + 3;\n\tuint8_t kzdptr=0xff, kzdsize=0xff;\n\tint kzlen = 197, kzinitlen=0xffff, kzxorlen=-1;\n\tcli_dbgmsg(\"in kriz\\n\");\n\n\twhile(*kzstate!=KZSTOP) {\n\t    uint8_t op;\n\t    if(kzlen<=6) break;\n\t    op = *kzcode++;\n\t    kzlen--;\n\t    switch (*kzstate) {\n\t    case KZSTRASH: case KZSGETSIZE: {\n\t\tint opsz=0;\n\t\tswitch(op) {\n\t\tcase 0x81:\n\t\t    kzcode+=5;\n\t\t    kzlen-=5;\n\t\t    break;\n\t\tcase 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbd: case 0xbe: case 0xbf:\n\t\t    if(*kzstate==KZSGETSIZE && cli_readint32(kzcode)==0x0fd2) {\n\t\t\tkzinitlen = kzlen-5;\n\t\t\tkzdsize=op-0xb8;\n\t\t\tkzstate++;\n\t\t\top=4; \/* fake the register to avoid breaking out *\/\n\t\t\tcli_dbgmsg(\"kriz: using #%d as size counter\\n\", kzdsize);\n\t\t    }\n\t\t    opsz=4;\n\t\tcase 0x48: case 0x49: case 0x4a: case 0x4b: case 0x4d: case 0x4e: case 0x4f:\n\t\t    op&=7;\n\t\t    if(op!=kzdptr && op!=kzdsize) {\n\t\t\tkzcode+=opsz;\n\t\t\tkzlen-=opsz;\n\t\t\tbreak;\n\t\t    }\n\t\tdefault:\n\t\t    kzcode--;\n\t\t    kzlen++;\n\t\t    kzstate++;\n\t\t}\n\t\tbreak;\n\t    }\n\t    case KZSCDELTA:\n\t\tif(op==0xe8 && (uint32_t)cli_readint32(kzcode) < 0xff) {\n\t\t    kzlen-=*kzcode+4;\n\t\t    kzcode+=*kzcode+4;\n\t\t    kzstate++;\n\t\t} else *kzstate=KZSTOP;\n\t\tbreak;\n\t    case KZSPDELTA:\n\t\tif((op&0xf8)==0x58 && (kzdptr=op-0x58)!=4) {\n\t\t    kzstate++;\n\t\t    cli_dbgmsg(\"kriz: using #%d as pointer\\n\", kzdptr);\n\t\t} else *kzstate=KZSTOP;\n\t\tbreak;\n\t    case KZSXORPRFX:\n\t\tkzstate++;\n\t\tif(op==0x3e) break;\n\t    case KZSXOR:\n\t\tif (op==0x80 && *kzcode==kzdptr+0xb0) {\n\t\t    kzxorlen=kzlen;\n\t\t    kzcode+=+6;\n\t\t    kzlen-=+6;\n\t\t    kzstate++;\n\t\t} else *kzstate=KZSTOP;\n\t\tbreak;\n\t    case KZSDDELTA:\n\t\tif (op==kzdptr+0x48) kzstate++;\n\t\telse *kzstate=KZSTOP;\n\t\tbreak;\n\t    case KZSLOOP:\n\t\tif (op==kzdsize+0x48 && *kzcode==0x75 && kzlen-(int8_t)kzcode[1]-3<=kzinitlen && kzlen-(int8_t)kzcode[1]>=kzxorlen) {\n\t\t    cli_append_virus(ctx,\"Heuristics.W32.Kriz\");\n\t\t    if (!SCAN_ALL) {\n\t\t        free(exe_sections);\n\t\t\treturn CL_VIRUS;\n\t\t    }\n\t\t    viruses_found++;\n\t\t}\n\t\tcli_dbgmsg(\"kriz: loop out of bounds, corrupted sample?\\n\");\n\t\tkzstate++;\n\t    }\n\t}\n    }\n\n    \/* W32.Magistr.A\/B *\/\n    if(SCAN_ALGO && (DCONF & PE_CONF_MAGISTR) && !dll && (nsections>1) && (exe_sections[nsections - 1].chr & 0x80000000)) {\n        uint32_t rsize, vsize, dam = 0;\n\n\tvsize = exe_sections[nsections - 1].uvsz;\n\trsize = exe_sections[nsections - 1].rsz;\n\tif(rsize < exe_sections[nsections - 1].ursz) {\n\t    rsize = exe_sections[nsections - 1].ursz;\n\t    dam = 1;\n\t}\n\n\tif(vsize >= 0x612c && rsize >= 0x612c && ((vsize & 0xff) == 0xec)) {\n\t\tint bw = rsize < 0x7000 ? rsize : 0x7000;\n\t\tconst char *tbuff;\n\n\t    if((tbuff = fmap_need_off_once(map, exe_sections[nsections - 1].raw + rsize - bw, 4096))) {\n\t\tif(cli_memstr(tbuff, 4091, \"\\xe8\\x2c\\x61\\x00\\x00\", 5)) {\n\t\t    cli_append_virus(ctx, dam ? \"Heuristics.W32.Magistr.A.dam\" : \"Heuristics.W32.Magistr.A\");\n\t\t    if (!SCAN_ALL) {\n\t\t        free(exe_sections);\n\t\t\treturn CL_VIRUS;\n\t\t    }\n\t\t    viruses_found++;\n\t\t}\n\t    }\n\n\t} else if(rsize >= 0x7000 && vsize >= 0x7000 && ((vsize & 0xff) == 0xed)) {\n\t\tint bw = rsize < 0x8000 ? rsize : 0x8000;\n\t\tconst char *tbuff;\n\n\t    if((tbuff = fmap_need_off_once(map, exe_sections[nsections - 1].raw + rsize - bw, 4096))) {\n\t\tif(cli_memstr(tbuff, 4091, \"\\xe8\\x04\\x72\\x00\\x00\", 5)) {\n\t\t    cli_append_virus(ctx,dam ? \"Heuristics.W32.Magistr.B.dam\" : \"Heuristics.W32.Magistr.B\");\n\t\t    if (!SCAN_ALL) {\n\t\t        free(exe_sections);\n\t\t\treturn CL_VIRUS;\n\t\t    }\n\t\t    viruses_found++;\n\t\t} \n\t    }\n\t}\n    }\n\n    \/* W32.Polipos.A *\/\n    while(polipos && !dll && nsections > 2 && nsections < 13 && e_lfanew <= 0x800 && (EC16(optional_hdr32.Subsystem) == 2 || EC16(optional_hdr32.Subsystem) == 3) && EC16(file_hdr.Machine) == 0x14c && optional_hdr32.SizeOfStackReserve >= 0x80000) {\n\tuint32_t jump, jold, *jumps = NULL;\n\tconst uint8_t *code;\n\tunsigned int xsjs = 0;\n\n\tif(exe_sections[0].rsz > CLI_MAX_ALLOCATION) break;\n\n\tif(!exe_sections[0].rsz) break;\n\tif(!(code=fmap_need_off_once(map, exe_sections[0].raw, exe_sections[0].rsz))) break;\n\tfor(i=0; i 1) continue;\n\t    jump = cli_rawaddr(exe_sections[0].rva+i+5+cli_readint32(&code[i+1]), exe_sections, nsections, &err, fsize, hdr_size);\n\t    if(err || !CLI_ISCONTAINED(exe_sections[polipos].raw, exe_sections[polipos].rsz, jump, 9)) continue;\n\t    if(xsjs % 128 == 0) {\n\t\tif(xsjs == 1280) break;\n\t\tif(!(jumps=(uint32_t *)cli_realloc2(jumps, (xsjs+128)*sizeof(uint32_t)))) {\n\t\t    free(exe_sections);\n\t\t    return CL_EMEM;\n\t\t}\n\t    }\n\t    j=0;\n\t    for(; j 1 && fsize > 64*1024 && fsize < 4*1024*1024) {\n\t    if(dirs[2].Size) {\n\t\t    struct swizz_stats *stats = cli_calloc(1, sizeof(*stats));\n\t\t    unsigned int m = 1000;\n\t\t    ret = CL_CLEAN;\n\n\t\t    if (!stats)\n\t\t\t    ret = CL_EMEM;\n\t\t    else {\n\t\t\t    cli_parseres_special(EC32(dirs[2].VirtualAddress), EC32(dirs[2].VirtualAddress), map, exe_sections, nsections, fsize, hdr_size, 0, 0, &m, stats);\n\t\t\t    if ((ret = cli_detect_swizz(stats)) == CL_VIRUS) {\n\t\t\t\tcli_append_virus(ctx,\"Heuristics.Trojan.Swizzor.Gen\");\n\t\t\t    }\n\t\t\t    free(stats);\n\t\t    }\n\t\t    if (ret != CL_CLEAN) {\n\t\t\tif (!(ret == CL_VIRUS && SCAN_ALL)) {\n\t\t\t    free(exe_sections);\n\t\t\t    return ret;\n\t\t\t}\n\t\t\tviruses_found++;\n\t\t    }\n\t    }\n    }\n\n\n    \/* !!!!!!!!!!!!!!    PACKERS START HERE    !!!!!!!!!!!!!! *\/\n    corrupted_cur = ctx->corrupted_input;\n    ctx->corrupted_input = 2; \/* caller will reset on return *\/\n\n\n    \/* UPX, FSG, MEW support *\/\n\n    \/* try to find the first section with physical size == 0 *\/\n    found = 0;\n    if(DCONF & (PE_CONF_UPX | PE_CONF_FSG | PE_CONF_MEW)) {\n\tfor(i = 0; i < (unsigned int) nsections - 1; i++) {\n\t    if(!exe_sections[i].rsz && exe_sections[i].vsz && exe_sections[i + 1].rsz && exe_sections[i + 1].vsz) {\n\t\tfound = 1;\n\t\tcli_dbgmsg(\"UPX\/FSG\/MEW: empty section found - assuming compression\\n\");\n#if HAVE_JSON\n        cli_jsonbool(pe_json, \"HasEmptySection\", 1);\n#endif\n\t\tbreak;\n\t    }\n\t}\n    }\n\n    \/* MEW support *\/\n    if (found && (DCONF & PE_CONF_MEW) && epsize>=16 && epbuff[0]=='\\xe9') {\n\tuint32_t fileoffset;\n\tconst char *tbuff;\n\n\tfileoffset = (vep + cli_readint32(epbuff + 1) + 5);\n\twhile (fileoffset == 0x154 || fileoffset == 0x158) {\n\t    char *src;\n\t    uint32_t offdiff, uselzma;\n\n\t    cli_dbgmsg (\"MEW: found MEW characteristics %08X + %08X + 5 = %08X\\n\", \n\t\t\tcli_readint32(epbuff + 1), vep, cli_readint32(epbuff + 1) + vep + 5);\n\n\t    if(!(tbuff = fmap_need_off_once(map, fileoffset, 0xb0)))\n\t\tbreak;\n\t    if (fileoffset == 0x154) cli_dbgmsg(\"MEW: Win9x compatibility was set!\\n\");\n\t    else cli_dbgmsg(\"MEW: Win9x compatibility was NOT set!\\n\");\n\n\t    if((offdiff = cli_readint32(tbuff+1) - EC32(optional_hdr32.ImageBase)) <= exe_sections[i + 1].rva || offdiff >= exe_sections[i + 1].rva + exe_sections[i + 1].raw - 4) {\n\t        cli_dbgmsg(\"MEW: ESI is not in proper section\\n\");\n\t\tbreak;\n\t    }\n\t    offdiff -= exe_sections[i + 1].rva;\n\n\t    if(!exe_sections[i + 1].rsz) {\n\t\tcli_dbgmsg(\"MEW: mew section is empty\\n\");\n\t\tbreak;\n\t    }\n\t    ssize = exe_sections[i + 1].vsz;\n\t    dsize = exe_sections[i].vsz;\n\n\t    cli_dbgmsg(\"MEW: ssize %08x dsize %08x offdiff: %08x\\n\", ssize, dsize, offdiff);\n\n\t    CLI_UNPSIZELIMITS(\"MEW\", MAX(ssize, dsize));\n\t    CLI_UNPSIZELIMITS(\"MEW\", MAX(ssize + dsize, exe_sections[i + 1].rsz));\n\n\t    if (exe_sections[i + 1].rsz < offdiff + 12 || exe_sections[i + 1].rsz > ssize) {\n\t        cli_dbgmsg(\"MEW: Size mismatch: %08x\\n\", exe_sections[i + 1].rsz);\n\t\tbreak;\n\t    }\n\n\t    \/* allocate needed buffer *\/\n\t    if (!(src = cli_calloc (ssize + dsize, sizeof(char)))) {\n\t        free(exe_sections);\n\t\treturn CL_EMEM;\n\t    }\n\n\t    if((bytes = fmap_readn(map, src + dsize, exe_sections[i + 1].raw, exe_sections[i + 1].rsz)) != exe_sections[i + 1].rsz) {\n\t\tcli_dbgmsg(\"MEW: Can't read %d bytes [read: %lu]\\n\", exe_sections[i + 1].rsz, (unsigned long)bytes);\n\t\tfree(exe_sections);\n\t\tfree(src);\n\t\treturn CL_EREAD;\n\t    }\n\t    cli_dbgmsg(\"MEW: %u (%08x) bytes read\\n\", (unsigned int)bytes, (unsigned int)bytes);\n\n\t    \/* count offset to lzma proc, if lzma used, 0xe8 -> call *\/\n\t    if (tbuff[0x7b] == '\\xe8') {\n\t        if (!CLI_ISCONTAINED(exe_sections[1].rva, exe_sections[1].vsz, cli_readint32(tbuff + 0x7c) + fileoffset + 0x80, 4)) {\n\t\t    cli_dbgmsg(\"MEW: lzma proc out of bounds!\\n\");\n\t\t    free(src);\n\t\t    break; \/* to next unpacker in chain *\/\n\t\t}\n\t\tuselzma = cli_readint32(tbuff + 0x7c) - (exe_sections[0].rva - fileoffset - 0x80);\n\t    } else {\n\t        uselzma = 0;\n\t    }\n\n#if HAVE_JSON\n        cli_jsonstr(pe_json, \"Packer\", \"MEW\");\n#endif\n\n\t    CLI_UNPTEMP(\"MEW\",(src,exe_sections,0));\n\t    CLI_UNPRESULTS(\"MEW\",(unmew11(src, offdiff, ssize, dsize, EC32(optional_hdr32.ImageBase), exe_sections[0].rva, uselzma, ndesc)),1,(src,0));\n\t    break;\n\t}\n    }\n\n    if(epsize<168) {\n\tfree(exe_sections);\n\treturn CL_CLEAN;\n    }\n\n    if (found || upack) {\n\t\/* Check EP for UPX vs. FSG vs. Upack *\/\n\n\t\/* Upack 0.39 produces 2 types of executables\n\t * 3 sections:           | 2 sections (one empty, I don't chech found if !upack, since it's in OR above):\n\t *   mov esi, value      |   pusha\n\t *   lodsd               |   call $+0x9\n\t *   push eax            |\n\t *\n\t * Upack 1.1\/1.2 Beta produces [based on 2 samples (sUx) provided by aCaB]:\n\t * 2 sections\n\t *   mov esi, value\n\t *   loads\n\t *   mov edi, eax\n\t *\n\t * Upack unknown [sample 0297729]\n\t * 3 sections\n\t *   mov esi, value\n\t *   push [esi]\n\t *   jmp\n\t * \n\t *\/\n\t\/* upack 0.39-3s + sample 0151477*\/\n \twhile(((upack && nsections == 3) && \/* 3 sections *\/\n\t    ((\n\t     epbuff[0] == '\\xbe' && cli_readint32(epbuff + 1) - EC32(optional_hdr32.ImageBase) > min && \/* mov esi *\/\n\t     epbuff[5] == '\\xad' && epbuff[6] == '\\x50' \/* lodsd; push eax *\/\n\t     )\n\t    || \n\t    \/* based on 0297729 sample from aCaB *\/\n\t    (epbuff[0] == '\\xbe' && cli_readint32(epbuff + 1) - EC32(optional_hdr32.ImageBase) > min && \/* mov esi *\/\n\t     epbuff[5] == '\\xff' && epbuff[6] == '\\x36' \/* push [esi] *\/\n\t     )\n\t   )) \n\t   ||\n\t   ((!upack && nsections == 2) && \/* 2 sections *\/\n\t    (( \/* upack 0.39-2s *\/\n\t     epbuff[0] == '\\x60' && epbuff[1] == '\\xe8' && cli_readint32(epbuff+2) == 0x9 \/* pusha; call+9 *\/\n\t     )\n\t    ||\n\t    ( \/* upack 1.1\/1.2, based on 2 samples *\/\n\t     epbuff[0] == '\\xbe' && cli_readint32(epbuff+1) - EC32(optional_hdr32.ImageBase) < min &&  \/* mov esi *\/\n\t     cli_readint32(epbuff + 1) - EC32(optional_hdr32.ImageBase) > 0 &&\n\t     epbuff[5] == '\\xad' && epbuff[6] == '\\x8b' && epbuff[7] == '\\xf8' \/* loads;  mov edi, eax *\/\n\t     )\n\t   ))\n\t   ) { \n\t    uint32_t vma, off;\n\t    int a,b,c;\n\n\t    cli_dbgmsg(\"Upack characteristics found.\\n\");\n\t    a = exe_sections[0].vsz;\n\t    b = exe_sections[1].vsz;\n\t    if (upack) {\n\t        cli_dbgmsg(\"Upack: var set\\n\");\n\t\tc = exe_sections[2].vsz;\n\t\tssize = exe_sections[0].ursz + exe_sections[0].uraw;\n\t\toff = exe_sections[0].rva;\n\t\tvma = EC32(optional_hdr32.ImageBase) + exe_sections[0].rva;\n\t    } else {\n\t        cli_dbgmsg(\"Upack: var NOT set\\n\");\n\t\tc = exe_sections[1].rva;\n\t\tssize = exe_sections[1].uraw;\n\t\toff = 0;\n\t\tvma = exe_sections[1].rva - exe_sections[1].uraw;\n\t    }\n\n\t    dsize = a+b+c;\n\n\t    CLI_UNPSIZELIMITS(\"Upack\", MAX(MAX(dsize, ssize), exe_sections[1].ursz));\n\n\t    if (!CLI_ISCONTAINED(0, dsize, exe_sections[1].rva - off, exe_sections[1].ursz) || (upack && !CLI_ISCONTAINED(0, dsize, exe_sections[2].rva - exe_sections[0].rva, ssize)) || ssize > dsize) {\n\t        cli_dbgmsg(\"Upack: probably malformed pe-header, skipping to next unpacker\\n\");\n\t\tbreak;\n\t    }\n\t\t\t\n\t    if((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) {\n\t        free(exe_sections);\n\t\treturn CL_EMEM;\n\t    }\n\n\t    if((unsigned int)fmap_readn(map, dest, 0, ssize) != ssize) {\n\t        cli_dbgmsg(\"Upack: Can't read raw data of section 0\\n\");\n\t\tfree(dest);\n\t\tbreak;\n\t    }\n\n\t    if(upack) memmove(dest + exe_sections[2].rva - exe_sections[0].rva, dest, ssize);\n\n\t    if((unsigned int)fmap_readn(map, dest + exe_sections[1].rva - off, exe_sections[1].uraw, exe_sections[1].ursz) != exe_sections[1].ursz) {\n\t\tcli_dbgmsg(\"Upack: Can't read raw data of section 1\\n\");\n\t\tfree(dest);\n\t\tbreak;\n\t    }\n\n#if HAVE_JSON\n        cli_jsonstr(pe_json, \"Packer\", \"Upack\");\n#endif\n\n\t    CLI_UNPTEMP(\"Upack\",(dest,exe_sections,0));\n\t    CLI_UNPRESULTS(\"Upack\",(unupack(upack, dest, dsize, epbuff, vma, ep, EC32(optional_hdr32.ImageBase), exe_sections[0].rva, ndesc)),1,(dest,0));\n\t    break;\n\t}\n    }\n\n    \n    while(found  && (DCONF & PE_CONF_FSG) && epbuff[0] == '\\x87' && epbuff[1] == '\\x25') {\n\tconst char *dst;\n\n\t\/* FSG v2.0 support - thanks to aCaB ! *\/\n\n\tuint32_t newesi, newedi, newebx, newedx;\n\t\n\tssize = exe_sections[i + 1].rsz;\n\tdsize = exe_sections[i].vsz;\n\n\tCLI_UNPSIZELIMITS(\"FSG\", MAX(dsize, ssize));\n\n\tif(ssize <= 0x19 || dsize <= ssize) {\n\t    cli_dbgmsg(\"FSG: Size mismatch (ssize: %d, dsize: %d)\\n\", ssize, dsize);\n\t    free(exe_sections);\n\t    return CL_CLEAN;\n\t}\n\t\n\tnewedx = cli_readint32(epbuff + 2) - EC32(optional_hdr32.ImageBase);\n\tif(!CLI_ISCONTAINED(exe_sections[i + 1].rva, exe_sections[i + 1].rsz, newedx, 4)) {\n\t    cli_dbgmsg(\"FSG: xchg out of bounds (%x), giving up\\n\", newedx);\n\t    break;\n\t}\n\t\n\tif(!exe_sections[i + 1].rsz || !(src = fmap_need_off_once(map, exe_sections[i + 1].raw, ssize))) {\n\t    cli_dbgmsg(\"Can't read raw data of section %d\\n\", i + 1);\n\t    free(exe_sections);\n\t    return CL_ESEEK;\n\t}\n\n\tdst = src + newedx - exe_sections[i + 1].rva;\n\tif(newedx < exe_sections[i + 1].rva || !CLI_ISCONTAINED(src, ssize, dst, 4)) {\n\t    cli_dbgmsg(\"FSG: New ESP out of bounds\\n\");\n\t    break;\n\t}\n\n\tnewedx = cli_readint32(dst) - EC32(optional_hdr32.ImageBase);\n\tif(!CLI_ISCONTAINED(exe_sections[i + 1].rva, exe_sections[i + 1].rsz, newedx, 4)) {\n\t    cli_dbgmsg(\"FSG: New ESP (%x) is wrong\\n\", newedx);\n\t    break;\n\t}\n \n\tdst = src + newedx - exe_sections[i + 1].rva;\n\tif(!CLI_ISCONTAINED(src, ssize, dst, 32)) {\n\t    cli_dbgmsg(\"FSG: New stack out of bounds\\n\");\n\t    break;\n\t}\n\n\tnewedi = cli_readint32(dst) - EC32(optional_hdr32.ImageBase);\n\tnewesi = cli_readint32(dst + 4) - EC32(optional_hdr32.ImageBase);\n\tnewebx = cli_readint32(dst + 16) - EC32(optional_hdr32.ImageBase);\n\tnewedx = cli_readint32(dst + 20);\n\n\tif(newedi != exe_sections[i].rva) {\n\t    cli_dbgmsg(\"FSG: Bad destination buffer (edi is %x should be %x)\\n\", newedi, exe_sections[i].rva);\n\t    break;\n\t}\n\n\tif(newesi < exe_sections[i + 1].rva || newesi - exe_sections[i + 1].rva >= exe_sections[i + 1].rsz) {\n\t    cli_dbgmsg(\"FSG: Source buffer out of section bounds\\n\");\n\t    break;\n\t}\n\n\tif(!CLI_ISCONTAINED(exe_sections[i + 1].rva, exe_sections[i + 1].rsz, newebx, 16)) {\n\t    cli_dbgmsg(\"FSG: Array of functions out of bounds\\n\");\n\t    break;\n\t}\n\n\tnewedx=cli_readint32(newebx + 12 - exe_sections[i + 1].rva + src) - EC32(optional_hdr32.ImageBase);\n\tcli_dbgmsg(\"FSG: found old EP @%x\\n\",newedx);\n\n\tif((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) {\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Packer\", \"FSG\");\n#endif\n\n\tCLI_UNPTEMP(\"FSG\",(dest,exe_sections,0));\n\tCLI_UNPRESULTSFSG2(\"FSG\",(unfsg_200(newesi - exe_sections[i + 1].rva + src, dest, ssize + exe_sections[i + 1].rva - newesi, dsize, newedi, EC32(optional_hdr32.ImageBase), newedx, ndesc)),1,(dest,0));\n\tbreak;\n    }\n\n\n    while(found && (DCONF & PE_CONF_FSG) && epbuff[0] == '\\xbe' && cli_readint32(epbuff + 1) - EC32(optional_hdr32.ImageBase) < min) {\n\n\t\/* FSG support - v. 1.33 (thx trog for the many samples) *\/\n\n\tint sectcnt = 0;\n\tconst char *support;\n\tuint32_t newesi, newedi, oldep, gp, t;\n\tstruct cli_exe_section *sections;\n\n\tssize = exe_sections[i + 1].rsz;\n\tdsize = exe_sections[i].vsz;\n\n\tCLI_UNPSIZELIMITS(\"FSG\", MAX(dsize, ssize));\n\n\tif(ssize <= 0x19 || dsize <= ssize) {\n\t    cli_dbgmsg(\"FSG: Size mismatch (ssize: %d, dsize: %d)\\n\", ssize, dsize);\n\t    free(exe_sections);\n\t    return CL_CLEAN;\n\t}\n\n\tif(!(t = cli_rawaddr(cli_readint32(epbuff + 1) - EC32(optional_hdr32.ImageBase), NULL, 0 , &err, fsize, hdr_size)) && err ) {\n\t    cli_dbgmsg(\"FSG: Support data out of padding area\\n\");\n\t    break;\n\t}\n\n\tgp = exe_sections[i + 1].raw - t;\n\n\tCLI_UNPSIZELIMITS(\"FSG\", gp);\n\n\tif(!(support = fmap_need_off_once(map, t, gp))) {\n\t    cli_dbgmsg(\"Can't read %d bytes from padding area\\n\", gp); \n\t    free(exe_sections);\n\t    return CL_EREAD;\n\t}\n\n\t\/* newebx = cli_readint32(support) - EC32(optional_hdr32.ImageBase);  Unused *\/\n\tnewedi = cli_readint32(support + 4) - EC32(optional_hdr32.ImageBase); \/* 1st dest *\/\n\tnewesi = cli_readint32(support + 8) - EC32(optional_hdr32.ImageBase); \/* Source *\/\n\n\tif(newesi < exe_sections[i + 1].rva || newesi - exe_sections[i + 1].rva >= exe_sections[i + 1].rsz) {\n\t    cli_dbgmsg(\"FSG: Source buffer out of section bounds\\n\");\n\t    break;\n\t}\n\n\tif(newedi != exe_sections[i].rva) {\n\t    cli_dbgmsg(\"FSG: Bad destination (is %x should be %x)\\n\", newedi, exe_sections[i].rva);\n\t    break;\n\t}\n\n\t\/* Counting original sections *\/\n\tfor(t = 12; t < gp - 4; t += 4) {\n\t    uint32_t rva = cli_readint32(support+t);\n\n\t    if(!rva)\n\t\tbreak;\n\n\t    rva -= EC32(optional_hdr32.ImageBase)+1;\n\t    sectcnt++;\n\n\t    if(rva % 0x1000) cli_dbgmsg(\"FSG: Original section %d is misaligned\\n\", sectcnt);\n\n\t    if(rva < exe_sections[i].rva || rva - exe_sections[i].rva >= exe_sections[i].vsz) {\n\t\tcli_dbgmsg(\"FSG: Original section %d is out of bounds\\n\", sectcnt);\n\t\tbreak;\n\t    }\n\t}\n\n\tif(t >= gp - 4 || cli_readint32(support + t)) {\n\t    break;\n\t}\n\n\tif((sections = (struct cli_exe_section *) cli_malloc((sectcnt + 1) * sizeof(struct cli_exe_section))) == NULL) {\n        cli_errmsg(\"FSG: Unable to allocate memory for sections %lu\\n\", (sectcnt + 1) * sizeof(struct cli_exe_section));\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\n\tsections[0].rva = newedi;\n\tfor(t = 1; t <= (uint32_t)sectcnt; t++)\n\t    sections[t].rva = cli_readint32(support + 8 + t * 4) - 1 - EC32(optional_hdr32.ImageBase);\n\n\tif(!exe_sections[i + 1].rsz || !(src = fmap_need_off_once(map, exe_sections[i + 1].raw, ssize))) {\n\t    cli_dbgmsg(\"Can't read raw data of section %d\\n\", i);\n\t    free(exe_sections);\n\t    free(sections);\n\t    return CL_EREAD;\n\t}\n\n\tif((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) {\n\t    free(exe_sections);\n\t    free(sections);\n\t    return CL_EMEM;\n\t}\n\n\toldep = vep + 161 + 6 + cli_readint32(epbuff+163);\n\tcli_dbgmsg(\"FSG: found old EP @%x\\n\", oldep);\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Packer\", \"FSG\");\n#endif\n\n\tCLI_UNPTEMP(\"FSG\",(dest,sections,exe_sections,0));\n\tCLI_UNPRESULTSFSG1(\"FSG\",(unfsg_133(src + newesi - exe_sections[i + 1].rva, dest, ssize + exe_sections[i + 1].rva - newesi, dsize, sections, sectcnt, EC32(optional_hdr32.ImageBase), oldep, ndesc)),1,(dest,sections,0));\n\tbreak; \/* were done with 1.33 *\/\n    }\n\n\n    while(found && (DCONF & PE_CONF_FSG) && epbuff[0] == '\\xbb' && cli_readint32(epbuff + 1) - EC32(optional_hdr32.ImageBase) < min && epbuff[5] == '\\xbf' && epbuff[10] == '\\xbe' && vep >= exe_sections[i + 1].rva && vep - exe_sections[i + 1].rva > exe_sections[i + 1].rva - 0xe0 ) {\n\n\t\/* FSG support - v. 1.31 *\/\n\n\tint sectcnt = 0;\n\tuint32_t gp, t = cli_rawaddr(cli_readint32(epbuff+1) - EC32(optional_hdr32.ImageBase), NULL, 0 , &err, fsize, hdr_size);\n\tconst char *support;\n\tuint32_t newesi = cli_readint32(epbuff+11) - EC32(optional_hdr32.ImageBase);\n\tuint32_t newedi = cli_readint32(epbuff+6) - EC32(optional_hdr32.ImageBase);\n\tuint32_t oldep = vep - exe_sections[i + 1].rva;\n\tstruct cli_exe_section *sections;\n\n\tssize = exe_sections[i + 1].rsz;\n\tdsize = exe_sections[i].vsz;\n\n\tif(err) {\n\t    cli_dbgmsg(\"FSG: Support data out of padding area\\n\");\n\t    break;\n\t}\n\n\tif(newesi < exe_sections[i + 1].rva || newesi - exe_sections[i + 1].rva >= exe_sections[i + 1].raw) {\n\t    cli_dbgmsg(\"FSG: Source buffer out of section bounds\\n\");\n\t    break;\n\t}\n\n\tif(newedi != exe_sections[i].rva) {\n\t    cli_dbgmsg(\"FSG: Bad destination (is %x should be %x)\\n\", newedi, exe_sections[i].rva);\n\t    break;\n\t}\n\n\tCLI_UNPSIZELIMITS(\"FSG\", MAX(dsize, ssize));\n\n\tif(ssize <= 0x19 || dsize <= ssize) {\n\t    cli_dbgmsg(\"FSG: Size mismatch (ssize: %d, dsize: %d)\\n\", ssize, dsize);\n\t    free(exe_sections);\n\t    return CL_CLEAN;\n\t}\n\n\tgp = exe_sections[i + 1].raw - t;\n\n\tCLI_UNPSIZELIMITS(\"FSG\", gp)\n\n\tif(!(support = fmap_need_off_once(map, t, gp))) {\n\t    cli_dbgmsg(\"Can't read %d bytes from padding area\\n\", gp); \n\t    free(exe_sections);\n\t    return CL_EREAD;\n\t}\n\n\t\/* Counting original sections *\/\n\tfor(t = 0; t < gp - 2; t += 2) {\n\t    uint32_t rva = support[t]|(support[t+1]<<8);\n\n\t    if (rva == 2 || rva == 1)\n\t\tbreak;\n\n\t    rva = ((rva-2)<<12) - EC32(optional_hdr32.ImageBase);\n\t    sectcnt++;\n\n\t    if(rva < exe_sections[i].rva || rva - exe_sections[i].rva >= exe_sections[i].vsz) {\n\t\tcli_dbgmsg(\"FSG: Original section %d is out of bounds\\n\", sectcnt);\n\t\tbreak;\n\t    }\n\t}\n\n\tif(t >= gp-10 || cli_readint32(support + t + 6) != 2) {\n\t    break;\n\t}\n\n\tif((sections = (struct cli_exe_section *) cli_malloc((sectcnt + 1) * sizeof(struct cli_exe_section))) == NULL) {\n        cli_errmsg(\"FSG: Unable to allocate memory for sections %lu\\n\", (sectcnt + 1) * sizeof(struct cli_exe_section));\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\n\tsections[0].rva = newedi;\n\tfor(t = 0; t <= (uint32_t)sectcnt - 1; t++) {\n\t    sections[t+1].rva = (((support[t*2]|(support[t*2+1]<<8))-2)<<12)-EC32(optional_hdr32.ImageBase);\n\t}\n\n\tif(!exe_sections[i + 1].rsz || !(src = fmap_need_off_once(map, exe_sections[i + 1].raw, ssize))) {\n\t    cli_dbgmsg(\"FSG: Can't read raw data of section %d\\n\", i);\n\t    free(exe_sections);\n\t    free(sections);\n\t    return CL_EREAD;\n\t}\n\n\tif((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) {\n\t    free(exe_sections);\n\t    free(sections);\n\t    return CL_EMEM;\n\t}\n\n\tgp = 0xda + 6*(epbuff[16]=='\\xe8');\n\toldep = vep + gp + 6 + cli_readint32(src+gp+2+oldep);\n\tcli_dbgmsg(\"FSG: found old EP @%x\\n\", oldep);\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Packer\", \"FSG\");\n#endif\n\n\tCLI_UNPTEMP(\"FSG\",(dest,sections,exe_sections,0));\n\tCLI_UNPRESULTSFSG1(\"FSG\",(unfsg_133(src + newesi - exe_sections[i + 1].rva, dest, ssize + exe_sections[i + 1].rva - newesi, dsize, sections, sectcnt, EC32(optional_hdr32.ImageBase), oldep, ndesc)),1,(dest,sections,0));\n\tbreak; \/* were done with 1.31 *\/\n    }\n\n\n    if(found && (DCONF & PE_CONF_UPX)) {\n\n\t\/* UPX support *\/\n\n\t\/* we assume (i + 1) is UPX1 *\/\n\tssize = exe_sections[i + 1].rsz;\n\tdsize = exe_sections[i].vsz + exe_sections[i + 1].vsz;\n\n        \/* cli_dbgmsg(\"UPX: ssize %u dsize %u\\n\", ssize, dsize); *\/\n\n\tCLI_UNPSIZELIMITS(\"UPX\", MAX(dsize, ssize));\n\n\tif(ssize <= 0x19 || dsize <= ssize || dsize > CLI_MAX_ALLOCATION ) {\n\t    cli_dbgmsg(\"UPX: Size mismatch or dsize too big (ssize: %d, dsize: %d)\\n\", ssize, dsize);\n\t    free(exe_sections);\n\t    return CL_CLEAN;\n\t}\n\n\tif(!exe_sections[i + 1].rsz || !(src = fmap_need_off_once(map, exe_sections[i + 1].raw, ssize))) {\n\t    cli_dbgmsg(\"UPX: Can't read raw data of section %d\\n\", i+1);\n\t    free(exe_sections);\n\t    return CL_EREAD;\n\t}\n\n\tif((dest = (char *) cli_calloc(dsize + 8192, sizeof(char))) == NULL) {\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\n\t\/* try to detect UPX code *\/\n\tif(cli_memstr(UPX_NRV2B, 24, epbuff + 0x69, 13) || cli_memstr(UPX_NRV2B, 24, epbuff + 0x69 + 8, 13)) {\n\t    cli_dbgmsg(\"UPX: Looks like a NRV2B decompression routine\\n\");\n\t    upxfn = upx_inflate2b;\n\t} else if(cli_memstr(UPX_NRV2D, 24, epbuff + 0x69, 13) || cli_memstr(UPX_NRV2D, 24, epbuff + 0x69 + 8, 13)) {\n\t    cli_dbgmsg(\"UPX: Looks like a NRV2D decompression routine\\n\");\n\t    upxfn = upx_inflate2d;\n\t} else if(cli_memstr(UPX_NRV2E, 24, epbuff + 0x69, 13) || cli_memstr(UPX_NRV2E, 24, epbuff + 0x69 + 8, 13)) {\n\t    cli_dbgmsg(\"UPX: Looks like a NRV2E decompression routine\\n\");\n\t    upxfn = upx_inflate2e;\n\t}\n\n\tif(upxfn) {\n\t    int skew = cli_readint32(epbuff + 2) - EC32(optional_hdr32.ImageBase) - exe_sections[i + 1].rva;\n\n\t    if(epbuff[1] != '\\xbe' || skew <= 0 || skew > 0xfff) { \/* FIXME: legit skews?? *\/\n\t\tskew = 0; \n\t    } else if ((unsigned int)skew > ssize) {\n\t\t\/* Ignore suggested skew larger than section size *\/\n\t\tskew = 0;\n\t    } else {\n\t\tcli_dbgmsg(\"UPX: UPX1 seems skewed by %d bytes\\n\", skew);\n\t    }\n\n\t    \/* Try skewed first (skew may be zero) *\/\n\t    if(upxfn(src + skew, ssize - skew, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep-skew) >= 0) {\n\t\tupx_success = 1;\n\t    }\n\t    \/* If skew not successful and non-zero, try no skew *\/\n\t    else if(skew && (upxfn(src, ssize, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep) >= 0)) {\n\t\tupx_success = 1;\n\t    }\n\n\t    if(upx_success)\n\t\tcli_dbgmsg(\"UPX: Successfully decompressed\\n\");\n\t    else\n\t\tcli_dbgmsg(\"UPX: Preferred decompressor failed\\n\");\n\t}\n\n\tif(!upx_success && upxfn != upx_inflate2b) {\n\t    if(upx_inflate2b(src, ssize, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep) == -1 && upx_inflate2b(src + 0x15, ssize - 0x15, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep - 0x15) == -1) {\n\n\t\tcli_dbgmsg(\"UPX: NRV2B decompressor failed\\n\");\n\t    } else {\n\t\tupx_success = 1;\n\t\tcli_dbgmsg(\"UPX: Successfully decompressed with NRV2B\\n\");\n\t    }\n\t}\n\n\tif(!upx_success && upxfn != upx_inflate2d) {\n\t    if(upx_inflate2d(src, ssize, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep) == -1 && upx_inflate2d(src + 0x15, ssize - 0x15, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep - 0x15) == -1) {\n\n\t\tcli_dbgmsg(\"UPX: NRV2D decompressor failed\\n\");\n\t    } else {\n\t\tupx_success = 1;\n\t\tcli_dbgmsg(\"UPX: Successfully decompressed with NRV2D\\n\");\n\t    }\n\t}\n\n\tif(!upx_success && upxfn != upx_inflate2e) {\n\t    if(upx_inflate2e(src, ssize, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep) == -1 && upx_inflate2e(src + 0x15, ssize - 0x15, dest, &dsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep - 0x15) == -1) {\n\t\tcli_dbgmsg(\"UPX: NRV2E decompressor failed\\n\");\n\t    } else {\n\t\tupx_success = 1;\n\t\tcli_dbgmsg(\"UPX: Successfully decompressed with NRV2E\\n\");\n\t    }\n\t}\n\n\tif(cli_memstr(UPX_LZMA2, 20, epbuff + 0x2f, 20)) {\n\t    uint32_t strictdsize=cli_readint32(epbuff+0x21), skew = 0;\n\t    if(ssize > 0x15 && epbuff[0] == '\\x60' && epbuff[1] == '\\xbe') {\n\t\tskew = cli_readint32(epbuff+2) - exe_sections[i + 1].rva - optional_hdr32.ImageBase;\n\t\tif(skew!=0x15) skew = 0;\n\t    }\n\t    if(strictdsize<=dsize)\n\t\tupx_success = upx_inflatelzma(src+skew, ssize-skew, dest, &strictdsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep) >=0;\n\t} else if (cli_memstr(UPX_LZMA1, 20, epbuff + 0x39, 20)) {\n\t    uint32_t strictdsize=cli_readint32(epbuff+0x2b), skew = 0;\n\t    if(ssize > 0x15 && epbuff[0] == '\\x60' && epbuff[1] == '\\xbe') {\n\t\tskew = cli_readint32(epbuff+2) - exe_sections[i + 1].rva - optional_hdr32.ImageBase;\n\t\tif(skew!=0x15) skew = 0;\n\t    }\n\t    if(strictdsize<=dsize)\n\t\tupx_success = upx_inflatelzma(src+skew, ssize-skew, dest, &strictdsize, exe_sections[i].rva, exe_sections[i + 1].rva, vep) >=0;\n\t}\n\n\tif(!upx_success) {\n\t    cli_dbgmsg(\"UPX: All decompressors failed\\n\");\n\t    free(dest);\n\t}\n    }\n\n    if(upx_success) {\n\tfree(exe_sections);\n\n\tCLI_UNPTEMP(\"UPX\/FSG\",(dest,0));\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Packer\", \"UPX\");\n#endif\n\n\tif((unsigned int) write(ndesc, dest, dsize) != dsize) {\n\t    cli_dbgmsg(\"UPX\/FSG: Can't write %d bytes\\n\", dsize);\n\t    free(tempfile);\n\t    free(dest);\n\t    close(ndesc);\n\t    return CL_EWRITE;\n\t}\n\n\tfree(dest);\n\tif (lseek(ndesc, 0, SEEK_SET) == -1) {\n        cli_dbgmsg(\"UPX\/FSG: lseek() failed\\n\");\n        close(ndesc);\n        CLI_TMPUNLK();\n        free(tempfile);\n        SHA_RESET;\n        return CL_ESEEK;\n    }\n\n\tif(ctx->engine->keeptmp)\n\t    cli_dbgmsg(\"UPX\/FSG: Decompressed data saved in %s\\n\", tempfile);\n\n\tcli_dbgmsg(\"***** Scanning decompressed file *****\\n\");\n\tSHA_OFF;\n\tif((ret = cli_magic_scandesc(ndesc, ctx)) == CL_VIRUS) {\n\t    close(ndesc);\n\t    CLI_TMPUNLK();\n\t    free(tempfile);\n\t    SHA_RESET;\n\t    return CL_VIRUS;\n\t}\n\n\tSHA_RESET;\n\tclose(ndesc);\n\tCLI_TMPUNLK();\n\tfree(tempfile);\n\treturn ret;\n    }\n\n\n    \/* Petite *\/\n\n    if(epsize<200) {\n\tfree(exe_sections);\n\treturn CL_CLEAN;\n    }\n\n    found = 2;\n\n    if(epbuff[0] != '\\xb8' || (uint32_t) cli_readint32(epbuff + 1) != exe_sections[nsections - 1].rva + EC32(optional_hdr32.ImageBase)) {\n\tif(nsections < 2 || epbuff[0] != '\\xb8' || (uint32_t) cli_readint32(epbuff + 1) != exe_sections[nsections - 2].rva + EC32(optional_hdr32.ImageBase))\n\t    found = 0;\n\telse\n\t    found = 1;\n    }\n\n    if(found && (DCONF & PE_CONF_PETITE)) {\n\tcli_dbgmsg(\"Petite: v2.%d compression detected\\n\", found);\n\n\tif(cli_readint32(epbuff + 0x80) == 0x163c988d) {\n\t    cli_dbgmsg(\"Petite: level zero compression is not supported yet\\n\");\n\t} else {\n\t    dsize = max - min;\n\n\t    CLI_UNPSIZELIMITS(\"Petite\", dsize);\n\n\t    if((dest = (char *) cli_calloc(dsize, sizeof(char))) == NULL) {\n\t\tcli_dbgmsg(\"Petite: Can't allocate %d bytes\\n\", dsize);\n\t\tfree(exe_sections);\n\t\treturn CL_EMEM;\n\t    }\n\n\t    for(i = 0 ; i < nsections; i++) {\n\t\tif(exe_sections[i].raw) {\n\t\t    if(!exe_sections[i].rsz || (unsigned int)fmap_readn(map, dest + exe_sections[i].rva - min, exe_sections[i].raw, exe_sections[i].ursz) != exe_sections[i].ursz) {\n\t\t\tfree(exe_sections);\n\t\t\tfree(dest);\n\t\t\treturn CL_CLEAN;\n\t\t    }\n\t\t}\n\t    }\n\n#if HAVE_JSON\n        cli_jsonstr(pe_json, \"Packer\", \"Petite\");\n#endif\n\n\t    CLI_UNPTEMP(\"Petite\",(dest,exe_sections,0));\n\t    CLI_UNPRESULTS(\"Petite\",(petite_inflate2x_1to9(dest, min, max - min, exe_sections, nsections - (found == 1 ? 1 : 0), EC32(optional_hdr32.ImageBase),vep, ndesc, found, EC32(optional_hdr32.DataDirectory[2].VirtualAddress),EC32(optional_hdr32.DataDirectory[2].Size))),0,(dest,0));\n\t}\n    }\n\n    \/* PESpin 1.1 *\/\n\n    if((DCONF & PE_CONF_PESPIN) && nsections > 1 &&\n       vep >= exe_sections[nsections - 1].rva &&\n       vep < exe_sections[nsections - 1].rva + exe_sections[nsections - 1].rsz - 0x3217 - 4 &&\n       memcmp(epbuff+4, \"\\xe8\\x00\\x00\\x00\\x00\\x8b\\x1c\\x24\\x83\\xc3\", 10) == 0)  {\n\n\tchar *spinned;\n\n\tCLI_UNPSIZELIMITS(\"PEspin\", fsize);\n\n\tif((spinned = (char *) cli_malloc(fsize)) == NULL) {\n        cli_errmsg(\"PESping: Unable to allocate memory for spinned %lu\\n\", (unsigned long)fsize);\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\n\tif((size_t) fmap_readn(map, spinned, 0, fsize) != fsize) {\n\t    cli_dbgmsg(\"PESpin: Can't read %lu bytes\\n\", (unsigned long)fsize);\n\t    free(spinned);\n\t    free(exe_sections);\n\t    return CL_EREAD;\n\t}\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Packer\", \"PEspin\");\n#endif\n\n\tCLI_UNPTEMP(\"PESpin\",(spinned,exe_sections,0));\n\tCLI_UNPRESULTS_(\"PEspin\",SPINCASE(),(unspin(spinned, fsize, exe_sections, nsections - 1, vep, ndesc, ctx)),0,(spinned,0));\n    }\n\n\n    \/* yC 1.3 & variants *\/\n    if((DCONF & PE_CONF_YC) && nsections > 1 &&\n       (EC32(optional_hdr32.AddressOfEntryPoint) == exe_sections[nsections - 1].rva + 0x60)) {\n\n\tuint32_t ecx = 0;\n\tint16_t offset;\n\n\t\/* yC 1.3 *\/\n\tif (!memcmp(epbuff, \"\\x55\\x8B\\xEC\\x53\\x56\\x57\\x60\\xE8\\x00\\x00\\x00\\x00\\x5D\\x81\\xED\", 15) &&\n\t    !memcmp(epbuff+0x26, \"\\x8D\\x3A\\x8B\\xF7\\x33\\xC0\\xEB\\x04\\x90\\xEB\\x01\\xC2\\xAC\", 13) &&\n\t    ((uint8_t)epbuff[0x13] == 0xB9) &&\n\t    ((uint16_t)(cli_readint16(epbuff+0x18)) == 0xE981) &&\n\t    !memcmp(epbuff+0x1e,\"\\x8B\\xD5\\x81\\xC2\", 4)) {\n\n\t    offset = 0;\n\t    if (0x6c - cli_readint32(epbuff+0xf) + cli_readint32(epbuff+0x22) == 0xC6)\n\t\tecx = cli_readint32(epbuff+0x14) - cli_readint32(epbuff+0x1a);\n\t}\n\n\t\/* yC 1.3 variant *\/\n\tif (!ecx && !memcmp(epbuff, \"\\x55\\x8B\\xEC\\x83\\xEC\\x40\\x53\\x56\\x57\", 9) &&\n\t    !memcmp(epbuff+0x17, \"\\xe8\\x00\\x00\\x00\\x00\\x5d\\x81\\xed\", 8) &&\n\t    ((uint8_t)epbuff[0x23] == 0xB9)) {\n\n\t    offset = 0x10;\n\t    if (0x6c - cli_readint32(epbuff+0x1f) + cli_readint32(epbuff+0x32) == 0xC6)\n\t\tecx = cli_readint32(epbuff+0x24) - cli_readint32(epbuff+0x2a);\n\t}\n\n\t\/* yC 1.x\/modified *\/\n\tif (!ecx && !memcmp(epbuff, \"\\x60\\xe8\\x00\\x00\\x00\\x00\\x5d\\x81\\xed\",9) &&\n\t    ((uint8_t)epbuff[0xd] == 0xb9) &&\n\t    ((uint16_t)cli_readint16(epbuff + 0x12)== 0xbd8d) &&\n\t    !memcmp(epbuff+0x18, \"\\x8b\\xf7\\xac\", 3)) {\n\n\t    offset = -0x18;\n\t    if (0x66 - cli_readint32(epbuff+0x9) + cli_readint32(epbuff+0x14) == 0xae)\n\t\tecx = cli_readint32(epbuff+0xe);\n\t}\n\n\tif (ecx > 0x800 && ecx < 0x2000 &&\n\t    !memcmp(epbuff+0x63+offset, \"\\xaa\\xe2\\xcc\", 3) &&\n\t    (fsize >= exe_sections[nsections-1].raw + 0xC6 + ecx + offset)) {\n\n\t    char *spinned;\n\n\t    if((spinned = (char *) cli_malloc(fsize)) == NULL) {\n            cli_errmsg(\"yC: Unable to allocate memory for spinned %lu\\n\", (unsigned long)fsize);\n\t      free(exe_sections);\n\t      return CL_EMEM;\n\t    }\n\n\t    if((size_t) fmap_readn(map, spinned, 0, fsize) != fsize) {\n\t      cli_dbgmsg(\"yC: Can't read %lu bytes\\n\", (unsigned long)fsize);\n\t      free(spinned);\n\t      free(exe_sections);\n\t      return CL_EREAD;\n\t    }\n\n#if HAVE_JSON\n        cli_jsonstr(pe_json, \"Packer\", \"yC\");\n#endif\n\n\t    cli_dbgmsg(\"%d,%d,%d,%d\\n\", nsections-1, e_lfanew, ecx, offset);\n\t    CLI_UNPTEMP(\"yC\",(spinned,exe_sections,0));\n\t    CLI_UNPRESULTS(\"yC\",(yc_decrypt(spinned, fsize, exe_sections, nsections-1, e_lfanew, ndesc, ecx, offset)),0,(spinned,0));\n\t}\n    }\n\n    \/* WWPack *\/\n\n    while ((DCONF & PE_CONF_WWPACK) && nsections > 1 &&\n       vep == exe_sections[nsections - 1].rva &&\n       memcmp(epbuff, \"\\x53\\x55\\x8b\\xe8\\x33\\xdb\\xeb\", 7) == 0 &&\n       memcmp(epbuff+0x68, \"\\xe8\\x00\\x00\\x00\\x00\\x58\\x2d\\x6d\\x00\\x00\\x00\\x50\\x60\\x33\\xc9\\x50\\x58\\x50\\x50\", 19) == 0)  {\n\tuint32_t head = exe_sections[nsections - 1].raw;\n        uint8_t *packer;\n\tchar *src;\n\n\tssize = 0;\n\tfor(i=0 ; ; i++) {\n\t    if(exe_sections[i].rawssize) break;\n\n\tCLI_UNPSIZELIMITS(\"WWPack\", ssize);\n\n        if(!(src=(char *)cli_calloc(ssize, sizeof(char)))) {\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\tif((size_t) fmap_readn(map, src, 0, head) != head) {\n\t    cli_dbgmsg(\"WWPack: Can't read %d bytes from headers\\n\", head);\n\t    free(src);\n\t    free(exe_sections);\n\t    return CL_EREAD;\n\t}\n        for(i = 0 ; i < (unsigned int)nsections-1; i++) {\n\t    if(!exe_sections[i].rsz) continue;\n            if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break;\n            if((unsigned int)fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break;\n        }\n        if(i+1!=nsections) {\n            cli_dbgmsg(\"WWpack: Probably hacked\/damaged file.\\n\");\n            free(src);\n            break;\n        }\n\tif((packer = (uint8_t *) cli_calloc(exe_sections[nsections - 1].rsz, sizeof(char))) == NULL) {\n\t    free(src);\n\t    free(exe_sections);\n\t    return CL_EMEM;\n\t}\n\tif(!exe_sections[nsections - 1].rsz || (size_t) fmap_readn(map, packer, exe_sections[nsections - 1].raw, exe_sections[nsections - 1].rsz) != exe_sections[nsections - 1].rsz) {\n\t    cli_dbgmsg(\"WWPack: Can't read %d bytes from wwpack sect\\n\", exe_sections[nsections - 1].rsz);\n\t    free(src);\n\t    free(packer);\n\t    free(exe_sections);\n\t    return CL_EREAD;\n\t}\n\n#if HAVE_JSON\n    cli_jsonstr(pe_json, \"Packer\", \"WWPack\");\n#endif\n\n\tCLI_UNPTEMP(\"WWPack\",(src,packer,exe_sections,0));\n\tCLI_UNPRESULTS(\"WWPack\",(wwunpack((uint8_t *)src, ssize, packer, exe_sections, nsections-1, e_lfanew, ndesc)),0,(src,packer,0));\n\tbreak;\n    }\n\n\n    \/* ASPACK support *\/\n    while((DCONF & PE_CONF_ASPACK) && ep+58+0x70e < fsize && !memcmp(epbuff,\"\\x60\\xe8\\x03\\x00\\x00\\x00\\xe9\\xeb\",8)) {\n\tchar *src;\n\n        if(epsize<0x3bf || memcmp(epbuff+0x3b9, \"\\x68\\x00\\x00\\x00\\x00\\xc3\",6)) break;\n\tssize = 0;\n\tfor(i=0 ; i< nsections ; i++)\n\t    if(ssizecorrupted_input = corrupted_cur;\n\n    \/* Bytecode BC_PE_UNPACKER hook *\/\n    bc_ctx = cli_bytecode_context_alloc();\n    if (!bc_ctx) {\n\tcli_errmsg(\"cli_scanpe: can't allocate memory for bc_ctx\\n\");\n\treturn CL_EMEM;\n    }\n    cli_bytecode_context_setpe(bc_ctx, &pedata, exe_sections);\n    cli_bytecode_context_setctx(bc_ctx, ctx);\n    ret = cli_bytecode_runhook(ctx, ctx->engine, bc_ctx, BC_PE_UNPACKER, map);\n    switch (ret) {\n\tcase CL_VIRUS:\n\t    free(exe_sections);\n\t    cli_bytecode_context_destroy(bc_ctx);\n\t    return CL_VIRUS;\n\tcase CL_SUCCESS:\n\t    ndesc = cli_bytecode_context_getresult_file(bc_ctx, &tempfile);\n\t    cli_bytecode_context_destroy(bc_ctx);\n\t    if (ndesc != -1 && tempfile) {\n\t\tCLI_UNPRESULTS(\"bytecode PE hook\", 1, 1, (0));\n\t    }\n\t    break;\n\tdefault:\n\t    cli_bytecode_context_destroy(bc_ctx);\n    }\n\n    free(exe_sections);\n#if HAVE_JSON\n    if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {\n        return CL_ETIMEOUT;\n    }\n#endif\n    if (SCAN_ALL && viruses_found)\n\treturn CL_VIRUS;\n    return CL_CLEAN;","target":1,"code_token_length":22656,"total_token_length":22892,"max_tokens_setting":28000}
+{"idx":339889,"func":"long disas_insn(DisasContext *s, uint8_t *pc_start)\n\n{\n\n    int b, prefixes, aflag, dflag;\n\n    int shift, ot;\n\n    int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val;\n\n    unsigned int next_eip;\n\n\n\n    s->pc = pc_start;\n\n    prefixes = 0;\n\n    aflag = s->code32;\n\n    dflag = s->code32;\n\n    s->override = -1;\n\n next_byte:\n\n    b = ldub(s->pc);\n\n    s->pc++;\n\n    \/* check prefixes *\/\n\n    switch (b) {\n\n    case 0xf3:\n\n        prefixes |= PREFIX_REPZ;\n\n        goto next_byte;\n\n    case 0xf2:\n\n        prefixes |= PREFIX_REPNZ;\n\n        goto next_byte;\n\n    case 0xf0:\n\n        prefixes |= PREFIX_LOCK;\n\n        goto next_byte;\n\n    case 0x2e:\n\n        s->override = R_CS;\n\n        goto next_byte;\n\n    case 0x36:\n\n        s->override = R_SS;\n\n        goto next_byte;\n\n    case 0x3e:\n\n        s->override = R_DS;\n\n        goto next_byte;\n\n    case 0x26:\n\n        s->override = R_ES;\n\n        goto next_byte;\n\n    case 0x64:\n\n        s->override = R_FS;\n\n        goto next_byte;\n\n    case 0x65:\n\n        s->override = R_GS;\n\n        goto next_byte;\n\n    case 0x66:\n\n        prefixes |= PREFIX_DATA;\n\n        goto next_byte;\n\n    case 0x67:\n\n        prefixes |= PREFIX_ADR;\n\n        goto next_byte;\n\n    case 0x9b:\n\n        prefixes |= PREFIX_FWAIT;\n\n        goto next_byte;\n\n    }\n\n\n\n    if (prefixes & PREFIX_DATA)\n\n        dflag ^= 1;\n\n    if (prefixes & PREFIX_ADR)\n\n        aflag ^= 1;\n\n\n\n    s->prefix = prefixes;\n\n    s->aflag = aflag;\n\n    s->dflag = dflag;\n\n\n\n    \/* lock generation *\/\n\n    if (prefixes & PREFIX_LOCK)\n\n        gen_op_lock();\n\n\n\n    \/* now check op code *\/\n\n reswitch:\n\n    switch(b) {\n\n    case 0x0f:\n\n        \/**************************\/\n\n        \/* extended op code *\/\n\n        b = ldub(s->pc++) | 0x100;\n\n        goto reswitch;\n\n        \n\n        \/**************************\/\n\n        \/* arith & logic *\/\n\n    case 0x00 ... 0x05:\n\n    case 0x08 ... 0x0d:\n\n    case 0x10 ... 0x15:\n\n    case 0x18 ... 0x1d:\n\n    case 0x20 ... 0x25:\n\n    case 0x28 ... 0x2d:\n\n    case 0x30 ... 0x35:\n\n    case 0x38 ... 0x3d:\n\n        {\n\n            int op, f, val;\n\n            op = (b >> 3) & 7;\n\n            f = (b >> 1) & 3;\n\n\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            \n\n            switch(f) {\n\n            case 0: \/* OP Ev, Gv *\/\n\n                modrm = ldub(s->pc++);\n\n                reg = ((modrm >> 3) & 7) + OR_EAX;\n\n                mod = (modrm >> 6) & 3;\n\n                rm = modrm & 7;\n\n                if (mod != 3) {\n\n                    gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n                    gen_op_ld_T0_A0[ot]();\n\n                    opreg = OR_TMP0;\n\n                } else {\n\n                    opreg = OR_EAX + rm;\n\n                }\n\n                gen_op(s, op, ot, opreg, reg);\n\n                if (mod != 3 && op != 7) {\n\n                    gen_op_st_T0_A0[ot]();\n\n                }\n\n                break;\n\n            case 1: \/* OP Gv, Ev *\/\n\n                modrm = ldub(s->pc++);\n\n                mod = (modrm >> 6) & 3;\n\n                reg = ((modrm >> 3) & 7) + OR_EAX;\n\n                rm = modrm & 7;\n\n                if (mod != 3) {\n\n                    gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n                    gen_op_ld_T1_A0[ot]();\n\n                    opreg = OR_TMP1;\n\n                } else {\n\n                    opreg = OR_EAX + rm;\n\n                }\n\n                gen_op(s, op, ot, reg, opreg);\n\n                break;\n\n            case 2: \/* OP A, Iv *\/\n\n                val = insn_get(s, ot);\n\n                gen_opi(s, op, ot, OR_EAX, val);\n\n                break;\n\n            }\n\n        }\n\n        break;\n\n\n\n    case 0x80: \/* GRP1 *\/\n\n    case 0x81:\n\n    case 0x83:\n\n        {\n\n            int val;\n\n\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            \n\n            modrm = ldub(s->pc++);\n\n            mod = (modrm >> 6) & 3;\n\n            rm = modrm & 7;\n\n            op = (modrm >> 3) & 7;\n\n            \n\n            if (mod != 3) {\n\n                gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n                gen_op_ld_T0_A0[ot]();\n\n                opreg = OR_TMP0;\n\n            } else {\n\n                opreg = rm + OR_EAX;\n\n            }\n\n\n\n            switch(b) {\n\n            default:\n\n            case 0x80:\n\n            case 0x81:\n\n                val = insn_get(s, ot);\n\n                break;\n\n            case 0x83:\n\n                val = (int8_t)insn_get(s, OT_BYTE);\n\n                break;\n\n            }\n\n\n\n            gen_opi(s, op, ot, opreg, val);\n\n            if (op != 7 && mod != 3) {\n\n                gen_op_st_T0_A0[ot]();\n\n            }\n\n        }\n\n        break;\n\n\n\n        \/**************************\/\n\n        \/* inc, dec, and other misc arith *\/\n\n    case 0x40 ... 0x47: \/* inc Gv *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        gen_inc(s, ot, OR_EAX + (b & 7), 1);\n\n        break;\n\n    case 0x48 ... 0x4f: \/* dec Gv *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        gen_inc(s, ot, OR_EAX + (b & 7), -1);\n\n        break;\n\n    case 0xf6: \/* GRP3 *\/\n\n    case 0xf7:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n\n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        op = (modrm >> 3) & 7;\n\n        if (mod != 3) {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_ld_T0_A0[ot]();\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][0][rm]();\n\n        }\n\n\n\n        switch(op) {\n\n        case 0: \/* test *\/\n\n            val = insn_get(s, ot);\n\n            gen_op_movl_T1_im(val);\n\n            gen_op_testl_T0_T1_cc();\n\n            s->cc_op = CC_OP_LOGICB + ot;\n\n            break;\n\n        case 2: \/* not *\/\n\n            gen_op_notl_T0();\n\n            if (mod != 3) {\n\n                gen_op_st_T0_A0[ot]();\n\n            } else {\n\n                gen_op_mov_reg_T0[ot][rm]();\n\n            }\n\n            break;\n\n        case 3: \/* neg *\/\n\n            gen_op_negl_T0_cc();\n\n            if (mod != 3) {\n\n                gen_op_st_T0_A0[ot]();\n\n            } else {\n\n                gen_op_mov_reg_T0[ot][rm]();\n\n            }\n\n            s->cc_op = CC_OP_SUBB + ot;\n\n            break;\n\n        case 4: \/* mul *\/\n\n            switch(ot) {\n\n            case OT_BYTE:\n\n                gen_op_mulb_AL_T0();\n\n                break;\n\n            case OT_WORD:\n\n                gen_op_mulw_AX_T0();\n\n                break;\n\n            default:\n\n            case OT_LONG:\n\n                gen_op_mull_EAX_T0();\n\n                break;\n\n            }\n\n            s->cc_op = CC_OP_MUL;\n\n            break;\n\n        case 5: \/* imul *\/\n\n            switch(ot) {\n\n            case OT_BYTE:\n\n                gen_op_imulb_AL_T0();\n\n                break;\n\n            case OT_WORD:\n\n                gen_op_imulw_AX_T0();\n\n                break;\n\n            default:\n\n            case OT_LONG:\n\n                gen_op_imull_EAX_T0();\n\n                break;\n\n            }\n\n            s->cc_op = CC_OP_MUL;\n\n            break;\n\n        case 6: \/* div *\/\n\n            switch(ot) {\n\n            case OT_BYTE:\n\n                gen_op_divb_AL_T0();\n\n                break;\n\n            case OT_WORD:\n\n                gen_op_divw_AX_T0();\n\n                break;\n\n            default:\n\n            case OT_LONG:\n\n                gen_op_divl_EAX_T0();\n\n                break;\n\n            }\n\n            break;\n\n        case 7: \/* idiv *\/\n\n            switch(ot) {\n\n            case OT_BYTE:\n\n                gen_op_idivb_AL_T0();\n\n                break;\n\n            case OT_WORD:\n\n                gen_op_idivw_AX_T0();\n\n                break;\n\n            default:\n\n            case OT_LONG:\n\n                gen_op_idivl_EAX_T0();\n\n                break;\n\n            }\n\n            break;\n\n        default:\n\n            goto illegal_op;\n\n        }\n\n        break;\n\n\n\n    case 0xfe: \/* GRP4 *\/\n\n    case 0xff: \/* GRP5 *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n\n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        op = (modrm >> 3) & 7;\n\n        if (op >= 2 && b == 0xfe) {\n\n            goto illegal_op;\n\n        }\n\n        if (mod != 3) {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            if (op != 3 && op != 5)\n\n                gen_op_ld_T0_A0[ot]();\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][0][rm]();\n\n        }\n\n\n\n        switch(op) {\n\n        case 0: \/* inc Ev *\/\n\n            gen_inc(s, ot, OR_TMP0, 1);\n\n            if (mod != 3)\n\n                gen_op_st_T0_A0[ot]();\n\n            else\n\n                gen_op_mov_reg_T0[ot][rm]();\n\n            break;\n\n        case 1: \/* dec Ev *\/\n\n            gen_inc(s, ot, OR_TMP0, -1);\n\n            if (mod != 3)\n\n                gen_op_st_T0_A0[ot]();\n\n            else\n\n                gen_op_mov_reg_T0[ot][rm]();\n\n            break;\n\n        case 2: \/* call Ev *\/\n\n            \/* XXX: optimize if memory (no and is necessary) *\/\n\n            if (s->dflag == 0)\n\n                gen_op_andl_T0_ffff();\n\n            gen_op_jmp_T0();\n\n            next_eip = s->pc - s->cs_base;\n\n            gen_op_movl_T0_im(next_eip);\n\n            gen_push_T0(s);\n\n            s->is_jmp = 1;\n\n            break;\n\n        case 3: \/* lcall Ev *\/\n\n            \/* push return segment + offset *\/\n\n            gen_op_movl_T0_seg(R_CS);\n\n            gen_push_T0(s);\n\n            next_eip = s->pc - s->cs_base;\n\n            gen_op_movl_T0_im(next_eip);\n\n            gen_push_T0(s);\n\n\n\n            gen_op_ld_T1_A0[ot]();\n\n            gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));\n\n            gen_op_lduw_T0_A0();\n\n            gen_movl_seg_T0(s, R_CS);\n\n            gen_op_movl_T0_T1();\n\n            gen_op_jmp_T0();\n\n            s->is_jmp = 1;\n\n            break;\n\n        case 4: \/* jmp Ev *\/\n\n            if (s->dflag == 0)\n\n                gen_op_andl_T0_ffff();\n\n            gen_op_jmp_T0();\n\n            s->is_jmp = 1;\n\n            break;\n\n        case 5: \/* ljmp Ev *\/\n\n            gen_op_ld_T1_A0[ot]();\n\n            gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));\n\n            gen_op_lduw_T0_A0();\n\n            gen_movl_seg_T0(s, R_CS);\n\n            gen_op_movl_T0_T1();\n\n            gen_op_jmp_T0();\n\n            s->is_jmp = 1;\n\n            break;\n\n        case 6: \/* push Ev *\/\n\n            gen_push_T0(s);\n\n            break;\n\n        default:\n\n            goto illegal_op;\n\n        }\n\n        break;\n\n\n\n    case 0x84: \/* test Ev, Gv *\/\n\n    case 0x85: \n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n\n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        reg = (modrm >> 3) & 7;\n\n        \n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);\n\n        gen_op_mov_TN_reg[ot][1][reg + OR_EAX]();\n\n        gen_op_testl_T0_T1_cc();\n\n        s->cc_op = CC_OP_LOGICB + ot;\n\n        break;\n\n        \n\n    case 0xa8: \/* test eAX, Iv *\/\n\n    case 0xa9:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        val = insn_get(s, ot);\n\n\n\n        gen_op_mov_TN_reg[ot][0][OR_EAX]();\n\n        gen_op_movl_T1_im(val);\n\n        gen_op_testl_T0_T1_cc();\n\n        s->cc_op = CC_OP_LOGICB + ot;\n\n        break;\n\n        \n\n    case 0x98: \/* CWDE\/CBW *\/\n\n        if (dflag)\n\n            gen_op_movswl_EAX_AX();\n\n        else\n\n            gen_op_movsbw_AX_AL();\n\n        break;\n\n    case 0x99: \/* CDQ\/CWD *\/\n\n        if (dflag)\n\n            gen_op_movslq_EDX_EAX();\n\n        else\n\n            gen_op_movswl_DX_AX();\n\n        break;\n\n    case 0x1af: \/* imul Gv, Ev *\/\n\n    case 0x69: \/* imul Gv, Ev, I *\/\n\n    case 0x6b:\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = ((modrm >> 3) & 7) + OR_EAX;\n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);\n\n        if (b == 0x69) {\n\n            val = insn_get(s, ot);\n\n            gen_op_movl_T1_im(val);\n\n        } else if (b == 0x6b) {\n\n            val = insn_get(s, OT_BYTE);\n\n            gen_op_movl_T1_im(val);\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][1][reg]();\n\n        }\n\n\n\n        if (ot == OT_LONG) {\n\n            gen_op_imull_T0_T1();\n\n        } else {\n\n            gen_op_imulw_T0_T1();\n\n        }\n\n        gen_op_mov_reg_T0[ot][reg]();\n\n        s->cc_op = CC_OP_MUL;\n\n        break;\n\n    case 0x1c0:\n\n    case 0x1c1: \/* xadd Ev, Gv *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        if (mod == 3) {\n\n            rm = modrm & 7;\n\n            gen_op_mov_TN_reg[ot][0][reg]();\n\n            gen_op_mov_TN_reg[ot][1][rm]();\n\n            gen_op_addl_T0_T1_cc();\n\n            gen_op_mov_reg_T0[ot][rm]();\n\n            gen_op_mov_reg_T1[ot][reg]();\n\n        } else {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_mov_TN_reg[ot][0][reg]();\n\n            gen_op_ld_T1_A0[ot]();\n\n            gen_op_addl_T0_T1_cc();\n\n            gen_op_st_T0_A0[ot]();\n\n            gen_op_mov_reg_T1[ot][reg]();\n\n        }\n\n        s->cc_op = CC_OP_ADDB + ot;\n\n        break;\n\n    case 0x1b0:\n\n    case 0x1b1: \/* cmpxchg Ev, Gv *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        gen_op_mov_TN_reg[ot][1][reg]();\n\n        if (mod == 3) {\n\n            rm = modrm & 7;\n\n            gen_op_mov_TN_reg[ot][0][rm]();\n\n            gen_op_cmpxchg_T0_T1_EAX_cc[ot]();\n\n            gen_op_mov_reg_T0[ot][rm]();\n\n        } else {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_ld_T0_A0[ot]();\n\n            gen_op_cmpxchg_T0_T1_EAX_cc[ot]();\n\n            gen_op_st_T0_A0[ot]();\n\n        }\n\n        s->cc_op = CC_OP_SUBB + ot;\n\n        break;\n\n    case 0x1c7: \/* cmpxchg8b *\/\n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        if (mod == 3)\n\n            goto illegal_op;\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n        gen_op_cmpxchg8b();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n        \n\n        \/**************************\/\n\n        \/* push\/pop *\/\n\n    case 0x50 ... 0x57: \/* push *\/\n\n        gen_op_mov_TN_reg[OT_LONG][0][b & 7]();\n\n        gen_push_T0(s);\n\n        break;\n\n    case 0x58 ... 0x5f: \/* pop *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        gen_pop_T0(s);\n\n        gen_op_mov_reg_T0[ot][b & 7]();\n\n        gen_pop_update(s);\n\n        break;\n\n    case 0x60: \/* pusha *\/\n\n        gen_pusha(s);\n\n        break;\n\n    case 0x61: \/* popa *\/\n\n        gen_popa(s);\n\n        break;\n\n    case 0x68: \/* push Iv *\/\n\n    case 0x6a:\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        if (b == 0x68)\n\n            val = insn_get(s, ot);\n\n        else\n\n            val = (int8_t)insn_get(s, OT_BYTE);\n\n        gen_op_movl_T0_im(val);\n\n        gen_push_T0(s);\n\n        break;\n\n    case 0x8f: \/* pop Ev *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        gen_pop_T0(s);\n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);\n\n        gen_pop_update(s);\n\n        break;\n\n    case 0xc8: \/* enter *\/\n\n        {\n\n            int level;\n\n            val = lduw(s->pc);\n\n            s->pc += 2;\n\n            level = ldub(s->pc++);\n\n            gen_enter(s, val, level);\n\n        }\n\n        break;\n\n    case 0xc9: \/* leave *\/\n\n        \/* XXX: exception not precise (ESP is update before potential exception) *\/\n\n        if (s->ss32) {\n\n            gen_op_mov_TN_reg[OT_LONG][0][R_EBP]();\n\n            gen_op_mov_reg_T0[OT_LONG][R_ESP]();\n\n        } else {\n\n            gen_op_mov_TN_reg[OT_WORD][0][R_EBP]();\n\n            gen_op_mov_reg_T0[OT_WORD][R_ESP]();\n\n        }\n\n        gen_pop_T0(s);\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        gen_op_mov_reg_T0[ot][R_EBP]();\n\n        gen_pop_update(s);\n\n        break;\n\n    case 0x06: \/* push es *\/\n\n    case 0x0e: \/* push cs *\/\n\n    case 0x16: \/* push ss *\/\n\n    case 0x1e: \/* push ds *\/\n\n        gen_op_movl_T0_seg(b >> 3);\n\n        gen_push_T0(s);\n\n        break;\n\n    case 0x1a0: \/* push fs *\/\n\n    case 0x1a8: \/* push gs *\/\n\n        gen_op_movl_T0_seg((b >> 3) & 7);\n\n        gen_push_T0(s);\n\n        break;\n\n    case 0x07: \/* pop es *\/\n\n    case 0x17: \/* pop ss *\/\n\n    case 0x1f: \/* pop ds *\/\n\n        gen_pop_T0(s);\n\n        gen_movl_seg_T0(s, b >> 3);\n\n        gen_pop_update(s);\n\n        break;\n\n    case 0x1a1: \/* pop fs *\/\n\n    case 0x1a9: \/* pop gs *\/\n\n        gen_pop_T0(s);\n\n        gen_movl_seg_T0(s, (b >> 3) & 7);\n\n        gen_pop_update(s);\n\n        break;\n\n\n\n        \/**************************\/\n\n        \/* mov *\/\n\n    case 0x88:\n\n    case 0x89: \/* mov Gv, Ev *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        \n\n        \/* generate a generic store *\/\n\n        gen_ldst_modrm(s, modrm, ot, OR_EAX + reg, 1);\n\n        break;\n\n    case 0xc6:\n\n    case 0xc7: \/* mov Ev, Iv *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        if (mod != 3)\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n        val = insn_get(s, ot);\n\n        gen_op_movl_T0_im(val);\n\n        if (mod != 3)\n\n            gen_op_st_T0_A0[ot]();\n\n        else\n\n            gen_op_mov_reg_T0[ot][modrm & 7]();\n\n        break;\n\n    case 0x8a:\n\n    case 0x8b: \/* mov Ev, Gv *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        \n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);\n\n        gen_op_mov_reg_T0[ot][reg]();\n\n        break;\n\n    case 0x8e: \/* mov seg, Gv *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);\n\n        if (reg >= 6 || reg == R_CS)\n\n            goto illegal_op;\n\n        gen_movl_seg_T0(s, reg);\n\n        break;\n\n    case 0x8c: \/* mov Gv, seg *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        if (reg >= 6)\n\n            goto illegal_op;\n\n        gen_op_movl_T0_seg(reg);\n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);\n\n        break;\n\n\n\n    case 0x1b6: \/* movzbS Gv, Eb *\/\n\n    case 0x1b7: \/* movzwS Gv, Eb *\/\n\n    case 0x1be: \/* movsbS Gv, Eb *\/\n\n    case 0x1bf: \/* movswS Gv, Eb *\/\n\n        {\n\n            int d_ot;\n\n            \/* d_ot is the size of destination *\/\n\n            d_ot = dflag + OT_WORD;\n\n            \/* ot is the size of source *\/\n\n            ot = (b & 1) + OT_BYTE;\n\n            modrm = ldub(s->pc++);\n\n            reg = ((modrm >> 3) & 7) + OR_EAX;\n\n            mod = (modrm >> 6) & 3;\n\n            rm = modrm & 7;\n\n            \n\n            if (mod == 3) {\n\n                gen_op_mov_TN_reg[ot][0][rm]();\n\n                switch(ot | (b & 8)) {\n\n                case OT_BYTE:\n\n                    gen_op_movzbl_T0_T0();\n\n                    break;\n\n                case OT_BYTE | 8:\n\n                    gen_op_movsbl_T0_T0();\n\n                    break;\n\n                case OT_WORD:\n\n                    gen_op_movzwl_T0_T0();\n\n                    break;\n\n                default:\n\n                case OT_WORD | 8:\n\n                    gen_op_movswl_T0_T0();\n\n                    break;\n\n                }\n\n                gen_op_mov_reg_T0[d_ot][reg]();\n\n            } else {\n\n                gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n                if (b & 8) {\n\n                    gen_op_lds_T0_A0[ot]();\n\n                } else {\n\n                    gen_op_ldu_T0_A0[ot]();\n\n                }\n\n                gen_op_mov_reg_T0[d_ot][reg]();\n\n            }\n\n        }\n\n        break;\n\n\n\n    case 0x8d: \/* lea *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        \/* we must ensure that no segment is added *\/\n\n        s->override = -1;\n\n        val = s->addseg;\n\n        s->addseg = 0;\n\n        gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n        s->addseg = val;\n\n        gen_op_mov_reg_A0[ot - OT_WORD][reg]();\n\n        break;\n\n        \n\n    case 0xa0: \/* mov EAX, Ov *\/\n\n    case 0xa1:\n\n    case 0xa2: \/* mov Ov, EAX *\/\n\n    case 0xa3:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        if (s->aflag)\n\n            offset_addr = insn_get(s, OT_LONG);\n\n        else\n\n            offset_addr = insn_get(s, OT_WORD);\n\n        gen_op_movl_A0_im(offset_addr);\n\n        \/* handle override *\/\n\n        {\n\n            int override, must_add_seg;\n\n            must_add_seg = s->addseg;\n\n            if (s->override >= 0) {\n\n                override = s->override;\n\n                must_add_seg = 1;\n\n            } else {\n\n                override = R_DS;\n\n            }\n\n            if (must_add_seg) {\n\n                gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));\n\n            }\n\n        }\n\n        if ((b & 2) == 0) {\n\n            gen_op_ld_T0_A0[ot]();\n\n            gen_op_mov_reg_T0[ot][R_EAX]();\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][0][R_EAX]();\n\n            gen_op_st_T0_A0[ot]();\n\n        }\n\n        break;\n\n    case 0xd7: \/* xlat *\/\n\n        gen_op_movl_A0_reg[R_EBX]();\n\n        gen_op_addl_A0_AL();\n\n        if (s->aflag == 0)\n\n            gen_op_andl_A0_ffff();\n\n        \/* handle override *\/\n\n        {\n\n            int override, must_add_seg;\n\n            must_add_seg = s->addseg;\n\n            override = R_DS;\n\n            if (s->override >= 0) {\n\n                override = s->override;\n\n                must_add_seg = 1;\n\n            } else {\n\n                override = R_DS;\n\n            }\n\n            if (must_add_seg) {\n\n                gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));\n\n            }\n\n        }\n\n        gen_op_ldub_T0_A0();\n\n        gen_op_mov_reg_T0[OT_BYTE][R_EAX]();\n\n        break;\n\n    case 0xb0 ... 0xb7: \/* mov R, Ib *\/\n\n        val = insn_get(s, OT_BYTE);\n\n        gen_op_movl_T0_im(val);\n\n        gen_op_mov_reg_T0[OT_BYTE][b & 7]();\n\n        break;\n\n    case 0xb8 ... 0xbf: \/* mov R, Iv *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        val = insn_get(s, ot);\n\n        reg = OR_EAX + (b & 7);\n\n        gen_op_movl_T0_im(val);\n\n        gen_op_mov_reg_T0[ot][reg]();\n\n        break;\n\n\n\n    case 0x91 ... 0x97: \/* xchg R, EAX *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        reg = b & 7;\n\n        rm = R_EAX;\n\n        goto do_xchg_reg;\n\n    case 0x86:\n\n    case 0x87: \/* xchg Ev, Gv *\/\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        if (mod == 3) {\n\n            rm = modrm & 7;\n\n        do_xchg_reg:\n\n            gen_op_mov_TN_reg[ot][0][reg]();\n\n            gen_op_mov_TN_reg[ot][1][rm]();\n\n            gen_op_mov_reg_T0[ot][rm]();\n\n            gen_op_mov_reg_T1[ot][reg]();\n\n        } else {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_mov_TN_reg[ot][0][reg]();\n\n            \/* for xchg, lock is implicit *\/\n\n            if (!(prefixes & PREFIX_LOCK))\n\n                gen_op_lock();\n\n            gen_op_ld_T1_A0[ot]();\n\n            gen_op_st_T0_A0[ot]();\n\n            if (!(prefixes & PREFIX_LOCK))\n\n                gen_op_unlock();\n\n            gen_op_mov_reg_T1[ot][reg]();\n\n        }\n\n        break;\n\n    case 0xc4: \/* les Gv *\/\n\n        op = R_ES;\n\n        goto do_lxx;\n\n    case 0xc5: \/* lds Gv *\/\n\n        op = R_DS;\n\n        goto do_lxx;\n\n    case 0x1b2: \/* lss Gv *\/\n\n        op = R_SS;\n\n        goto do_lxx;\n\n    case 0x1b4: \/* lfs Gv *\/\n\n        op = R_FS;\n\n        goto do_lxx;\n\n    case 0x1b5: \/* lgs Gv *\/\n\n        op = R_GS;\n\n    do_lxx:\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        if (mod == 3)\n\n            goto illegal_op;\n\n        gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n        gen_op_ld_T1_A0[ot]();\n\n        gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));\n\n        \/* load the segment first to handle exceptions properly *\/\n\n        gen_op_lduw_T0_A0();\n\n        gen_movl_seg_T0(s, op);\n\n        \/* then put the data *\/\n\n        gen_op_mov_reg_T1[ot][reg]();\n\n        break;\n\n        \n\n        \/************************\/\n\n        \/* shifts *\/\n\n    case 0xc0:\n\n    case 0xc1:\n\n        \/* shift Ev,Ib *\/\n\n        shift = 2;\n\n    grp2:\n\n        {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            \n\n            modrm = ldub(s->pc++);\n\n            mod = (modrm >> 6) & 3;\n\n            rm = modrm & 7;\n\n            op = (modrm >> 3) & 7;\n\n            \n\n            if (mod != 3) {\n\n                gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n                gen_op_ld_T0_A0[ot]();\n\n                opreg = OR_TMP0;\n\n            } else {\n\n                opreg = rm + OR_EAX;\n\n            }\n\n\n\n            \/* simpler op *\/\n\n            if (shift == 0) {\n\n                gen_shift(s, op, ot, opreg, OR_ECX);\n\n            } else {\n\n                if (shift == 2) {\n\n                    shift = ldub(s->pc++);\n\n                }\n\n                gen_shifti(s, op, ot, opreg, shift);\n\n            }\n\n\n\n            if (mod != 3) {\n\n                gen_op_st_T0_A0[ot]();\n\n            }\n\n        }\n\n        break;\n\n    case 0xd0:\n\n    case 0xd1:\n\n        \/* shift Ev,1 *\/\n\n        shift = 1;\n\n        goto grp2;\n\n    case 0xd2:\n\n    case 0xd3:\n\n        \/* shift Ev,cl *\/\n\n        shift = 0;\n\n        goto grp2;\n\n\n\n    case 0x1a4: \/* shld imm *\/\n\n        op = 0;\n\n        shift = 1;\n\n        goto do_shiftd;\n\n    case 0x1a5: \/* shld cl *\/\n\n        op = 0;\n\n        shift = 0;\n\n        goto do_shiftd;\n\n    case 0x1ac: \/* shrd imm *\/\n\n        op = 1;\n\n        shift = 1;\n\n        goto do_shiftd;\n\n    case 0x1ad: \/* shrd cl *\/\n\n        op = 1;\n\n        shift = 0;\n\n    do_shiftd:\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        reg = (modrm >> 3) & 7;\n\n        \n\n        if (mod != 3) {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_ld_T0_A0[ot]();\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][0][rm]();\n\n        }\n\n        gen_op_mov_TN_reg[ot][1][reg]();\n\n        \n\n        if (shift) {\n\n            val = ldub(s->pc++);\n\n            val &= 0x1f;\n\n            if (val) {\n\n                gen_op_shiftd_T0_T1_im_cc[ot - OT_WORD][op](val);\n\n                if (op == 0 && ot != OT_WORD)\n\n                    s->cc_op = CC_OP_SHLB + ot;\n\n                else\n\n                    s->cc_op = CC_OP_SARB + ot;\n\n            }\n\n        } else {\n\n            if (s->cc_op != CC_OP_DYNAMIC)\n\n                gen_op_set_cc_op(s->cc_op);\n\n            gen_op_shiftd_T0_T1_ECX_cc[ot - OT_WORD][op]();\n\n            s->cc_op = CC_OP_DYNAMIC; \/* cannot predict flags after *\/\n\n        }\n\n        if (mod != 3) {\n\n            gen_op_st_T0_A0[ot]();\n\n        } else {\n\n            gen_op_mov_reg_T0[ot][rm]();\n\n        }\n\n        break;\n\n\n\n        \/************************\/\n\n        \/* floats *\/\n\n    case 0xd8 ... 0xdf: \n\n        modrm = ldub(s->pc++);\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        op = ((b & 7) << 3) | ((modrm >> 3) & 7);\n\n        \n\n        if (mod != 3) {\n\n            \/* memory op *\/\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            switch(op) {\n\n            case 0x00 ... 0x07: \/* fxxxs *\/\n\n            case 0x10 ... 0x17: \/* fixxxl *\/\n\n            case 0x20 ... 0x27: \/* fxxxl *\/\n\n            case 0x30 ... 0x37: \/* fixxx *\/\n\n                {\n\n                    int op1;\n\n                    op1 = op & 7;\n\n\n\n                    switch(op >> 4) {\n\n                    case 0:\n\n                        gen_op_flds_FT0_A0();\n\n                        break;\n\n                    case 1:\n\n                        gen_op_fildl_FT0_A0();\n\n                        break;\n\n                    case 2:\n\n                        gen_op_fldl_FT0_A0();\n\n                        break;\n\n                    case 3:\n\n                    default:\n\n                        gen_op_fild_FT0_A0();\n\n                        break;\n\n                    }\n\n                    \n\n                    gen_op_fp_arith_ST0_FT0[op1]();\n\n                    if (op1 == 3) {\n\n                        \/* fcomp needs pop *\/\n\n                        gen_op_fpop();\n\n                    }\n\n                }\n\n                break;\n\n            case 0x08: \/* flds *\/\n\n            case 0x0a: \/* fsts *\/\n\n            case 0x0b: \/* fstps *\/\n\n            case 0x18: \/* fildl *\/\n\n            case 0x1a: \/* fistl *\/\n\n            case 0x1b: \/* fistpl *\/\n\n            case 0x28: \/* fldl *\/\n\n            case 0x2a: \/* fstl *\/\n\n            case 0x2b: \/* fstpl *\/\n\n            case 0x38: \/* filds *\/\n\n            case 0x3a: \/* fists *\/\n\n            case 0x3b: \/* fistps *\/\n\n                \n\n                switch(op & 7) {\n\n                case 0:\n\n                    gen_op_fpush();\n\n                    switch(op >> 4) {\n\n                    case 0:\n\n                        gen_op_flds_ST0_A0();\n\n                        break;\n\n                    case 1:\n\n                        gen_op_fildl_ST0_A0();\n\n                        break;\n\n                    case 2:\n\n                        gen_op_fldl_ST0_A0();\n\n                        break;\n\n                    case 3:\n\n                    default:\n\n                        gen_op_fild_ST0_A0();\n\n                        break;\n\n                    }\n\n                    break;\n\n                default:\n\n                    switch(op >> 4) {\n\n                    case 0:\n\n                        gen_op_fsts_ST0_A0();\n\n                        break;\n\n                    case 1:\n\n                        gen_op_fistl_ST0_A0();\n\n                        break;\n\n                    case 2:\n\n                        gen_op_fstl_ST0_A0();\n\n                        break;\n\n                    case 3:\n\n                    default:\n\n                        gen_op_fist_ST0_A0();\n\n                        break;\n\n                    }\n\n                    if ((op & 7) == 3)\n\n                        gen_op_fpop();\n\n                    break;\n\n                }\n\n                break;\n\n            case 0x0d: \/* fldcw mem *\/\n\n                gen_op_fldcw_A0();\n\n                break;\n\n            case 0x0f: \/* fnstcw mem *\/\n\n                gen_op_fnstcw_A0();\n\n                break;\n\n            case 0x1d: \/* fldt mem *\/\n\n                gen_op_fpush();\n\n                gen_op_fldt_ST0_A0();\n\n                break;\n\n            case 0x1f: \/* fstpt mem *\/\n\n                gen_op_fstt_ST0_A0();\n\n                gen_op_fpop();\n\n                break;\n\n            case 0x2f: \/* fnstsw mem *\/\n\n                gen_op_fnstsw_A0();\n\n                break;\n\n            case 0x3c: \/* fbld *\/\n\n                gen_op_fpush();\n\n                gen_op_fbld_ST0_A0();\n\n                break;\n\n            case 0x3e: \/* fbstp *\/\n\n                gen_op_fbst_ST0_A0();\n\n                gen_op_fpop();\n\n                break;\n\n            case 0x3d: \/* fildll *\/\n\n                gen_op_fpush();\n\n                gen_op_fildll_ST0_A0();\n\n                break;\n\n            case 0x3f: \/* fistpll *\/\n\n                gen_op_fistll_ST0_A0();\n\n                gen_op_fpop();\n\n                break;\n\n            default:\n\n                goto illegal_op;\n\n            }\n\n        } else {\n\n            \/* register float ops *\/\n\n            opreg = rm;\n\n\n\n            switch(op) {\n\n            case 0x08: \/* fld sti *\/\n\n                gen_op_fpush();\n\n                gen_op_fmov_ST0_STN((opreg + 1) & 7);\n\n                break;\n\n            case 0x09: \/* fxchg sti *\/\n\n                gen_op_fxchg_ST0_STN(opreg);\n\n                break;\n\n            case 0x0a: \/* grp d9\/2 *\/\n\n                switch(rm) {\n\n                case 0: \/* fnop *\/\n\n                    break;\n\n                default:\n\n                    goto illegal_op;\n\n                }\n\n                break;\n\n            case 0x0c: \/* grp d9\/4 *\/\n\n                switch(rm) {\n\n                case 0: \/* fchs *\/\n\n                    gen_op_fchs_ST0();\n\n                    break;\n\n                case 1: \/* fabs *\/\n\n                    gen_op_fabs_ST0();\n\n                    break;\n\n                case 4: \/* ftst *\/\n\n                    gen_op_fldz_FT0();\n\n                    gen_op_fcom_ST0_FT0();\n\n                    break;\n\n                case 5: \/* fxam *\/\n\n                    gen_op_fxam_ST0();\n\n                    break;\n\n                default:\n\n                    goto illegal_op;\n\n                }\n\n                break;\n\n            case 0x0d: \/* grp d9\/5 *\/\n\n                {\n\n                    switch(rm) {\n\n                    case 0:\n\n                        gen_op_fpush();\n\n                        gen_op_fld1_ST0();\n\n                        break;\n\n                    case 1:\n\n                        gen_op_fpush();\n\n                        gen_op_fldl2t_ST0();\n\n                        break;\n\n                    case 2:\n\n                        gen_op_fpush();\n\n                        gen_op_fldl2e_ST0();\n\n                        break;\n\n                    case 3:\n\n                        gen_op_fpush();\n\n                        gen_op_fldpi_ST0();\n\n                        break;\n\n                    case 4:\n\n                        gen_op_fpush();\n\n                        gen_op_fldlg2_ST0();\n\n                        break;\n\n                    case 5:\n\n                        gen_op_fpush();\n\n                        gen_op_fldln2_ST0();\n\n                        break;\n\n                    case 6:\n\n                        gen_op_fpush();\n\n                        gen_op_fldz_ST0();\n\n                        break;\n\n                    default:\n\n                        goto illegal_op;\n\n                    }\n\n                }\n\n                break;\n\n            case 0x0e: \/* grp d9\/6 *\/\n\n                switch(rm) {\n\n                case 0: \/* f2xm1 *\/\n\n                    gen_op_f2xm1();\n\n                    break;\n\n                case 1: \/* fyl2x *\/\n\n                    gen_op_fyl2x();\n\n                    break;\n\n                case 2: \/* fptan *\/\n\n                    gen_op_fptan();\n\n                    break;\n\n                case 3: \/* fpatan *\/\n\n                    gen_op_fpatan();\n\n                    break;\n\n                case 4: \/* fxtract *\/\n\n                    gen_op_fxtract();\n\n                    break;\n\n                case 5: \/* fprem1 *\/\n\n                    gen_op_fprem1();\n\n                    break;\n\n                case 6: \/* fdecstp *\/\n\n                    gen_op_fdecstp();\n\n                    break;\n\n                default:\n\n                case 7: \/* fincstp *\/\n\n                    gen_op_fincstp();\n\n                    break;\n\n                }\n\n                break;\n\n            case 0x0f: \/* grp d9\/7 *\/\n\n                switch(rm) {\n\n                case 0: \/* fprem *\/\n\n                    gen_op_fprem();\n\n                    break;\n\n                case 1: \/* fyl2xp1 *\/\n\n                    gen_op_fyl2xp1();\n\n                    break;\n\n                case 2: \/* fsqrt *\/\n\n                    gen_op_fsqrt();\n\n                    break;\n\n                case 3: \/* fsincos *\/\n\n                    gen_op_fsincos();\n\n                    break;\n\n                case 5: \/* fscale *\/\n\n                    gen_op_fscale();\n\n                    break;\n\n                case 4: \/* frndint *\/\n\n                    gen_op_frndint();\n\n                    break;\n\n                case 6: \/* fsin *\/\n\n                    gen_op_fsin();\n\n                    break;\n\n                default:\n\n                case 7: \/* fcos *\/\n\n                    gen_op_fcos();\n\n                    break;\n\n                }\n\n                break;\n\n            case 0x00: case 0x01: case 0x04 ... 0x07: \/* fxxx st, sti *\/\n\n            case 0x20: case 0x21: case 0x24 ... 0x27: \/* fxxx sti, st *\/\n\n            case 0x30: case 0x31: case 0x34 ... 0x37: \/* fxxxp sti, st *\/\n\n                {\n\n                    int op1;\n\n                    \n\n                    op1 = op & 7;\n\n                    if (op >= 0x20) {\n\n                        gen_op_fp_arith_STN_ST0[op1](opreg);\n\n                        if (op >= 0x30)\n\n                            gen_op_fpop();\n\n                    } else {\n\n                        gen_op_fmov_FT0_STN(opreg);\n\n                        gen_op_fp_arith_ST0_FT0[op1]();\n\n                    }\n\n                }\n\n                break;\n\n            case 0x02: \/* fcom *\/\n\n                gen_op_fmov_FT0_STN(opreg);\n\n                gen_op_fcom_ST0_FT0();\n\n                break;\n\n            case 0x03: \/* fcomp *\/\n\n                gen_op_fmov_FT0_STN(opreg);\n\n                gen_op_fcom_ST0_FT0();\n\n                gen_op_fpop();\n\n                break;\n\n            case 0x15: \/* da\/5 *\/\n\n                switch(rm) {\n\n                case 1: \/* fucompp *\/\n\n                    gen_op_fmov_FT0_STN(1);\n\n                    gen_op_fucom_ST0_FT0();\n\n                    gen_op_fpop();\n\n                    gen_op_fpop();\n\n                    break;\n\n                default:\n\n                    goto illegal_op;\n\n                }\n\n                break;\n\n            case 0x1c:\n\n                switch(rm) {\n\n                case 2: \/* fclex *\/\n\n                    gen_op_fclex();\n\n                    break;\n\n                case 3: \/* fninit *\/\n\n                    gen_op_fninit();\n\n                    break;\n\n                default:\n\n                    goto illegal_op;\n\n                }\n\n                break;\n\n            case 0x2a: \/* fst sti *\/\n\n                gen_op_fmov_STN_ST0(opreg);\n\n                break;\n\n            case 0x2b: \/* fstp sti *\/\n\n                gen_op_fmov_STN_ST0(opreg);\n\n                gen_op_fpop();\n\n                break;\n\n            case 0x2c: \/* fucom st(i) *\/\n\n                gen_op_fmov_FT0_STN(opreg);\n\n                gen_op_fucom_ST0_FT0();\n\n                break;\n\n            case 0x2d: \/* fucomp st(i) *\/\n\n                gen_op_fmov_FT0_STN(opreg);\n\n                gen_op_fucom_ST0_FT0();\n\n                gen_op_fpop();\n\n                break;\n\n            case 0x33: \/* de\/3 *\/\n\n                switch(rm) {\n\n                case 1: \/* fcompp *\/\n\n                    gen_op_fmov_FT0_STN(1);\n\n                    gen_op_fcom_ST0_FT0();\n\n                    gen_op_fpop();\n\n                    gen_op_fpop();\n\n                    break;\n\n                default:\n\n                    goto illegal_op;\n\n                }\n\n                break;\n\n            case 0x3c: \/* df\/4 *\/\n\n                switch(rm) {\n\n                case 0:\n\n                    gen_op_fnstsw_EAX();\n\n                    break;\n\n                default:\n\n                    goto illegal_op;\n\n                }\n\n                break;\n\n            default:\n\n                goto illegal_op;\n\n            }\n\n        }\n\n        break;\n\n        \/************************\/\n\n        \/* string ops *\/\n\n\n\n    case 0xa4: \/* movsS *\/\n\n    case 0xa5:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n\n\n        if (prefixes & PREFIX_REPZ) {\n\n            gen_string_ds(s, ot, gen_op_movs + 9);\n\n        } else {\n\n            gen_string_ds(s, ot, gen_op_movs);\n\n        }\n\n        break;\n\n        \n\n    case 0xaa: \/* stosS *\/\n\n    case 0xab:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n\n\n        if (prefixes & PREFIX_REPZ) {\n\n            gen_string_es(s, ot, gen_op_stos + 9);\n\n        } else {\n\n            gen_string_es(s, ot, gen_op_stos);\n\n        }\n\n        break;\n\n    case 0xac: \/* lodsS *\/\n\n    case 0xad:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        if (prefixes & PREFIX_REPZ) {\n\n            gen_string_ds(s, ot, gen_op_lods + 9);\n\n        } else {\n\n            gen_string_ds(s, ot, gen_op_lods);\n\n        }\n\n        break;\n\n    case 0xae: \/* scasS *\/\n\n    case 0xaf:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n        if (prefixes & PREFIX_REPNZ) {\n\n            if (s->cc_op != CC_OP_DYNAMIC)\n\n                gen_op_set_cc_op(s->cc_op);\n\n            gen_string_es(s, ot, gen_op_scas + 9 * 2);\n\n            s->cc_op = CC_OP_DYNAMIC; \/* cannot predict flags after *\/\n\n        } else if (prefixes & PREFIX_REPZ) {\n\n            if (s->cc_op != CC_OP_DYNAMIC)\n\n                gen_op_set_cc_op(s->cc_op);\n\n            gen_string_es(s, ot, gen_op_scas + 9);\n\n            s->cc_op = CC_OP_DYNAMIC; \/* cannot predict flags after *\/\n\n        } else {\n\n            gen_string_es(s, ot, gen_op_scas);\n\n            s->cc_op = CC_OP_SUBB + ot;\n\n        }\n\n        break;\n\n\n\n    case 0xa6: \/* cmpsS *\/\n\n    case 0xa7:\n\n        if ((b & 1) == 0)\n\n            ot = OT_BYTE;\n\n        else\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n        if (prefixes & PREFIX_REPNZ) {\n\n            if (s->cc_op != CC_OP_DYNAMIC)\n\n                gen_op_set_cc_op(s->cc_op);\n\n            gen_string_ds(s, ot, gen_op_cmps + 9 * 2);\n\n            s->cc_op = CC_OP_DYNAMIC; \/* cannot predict flags after *\/\n\n        } else if (prefixes & PREFIX_REPZ) {\n\n            if (s->cc_op != CC_OP_DYNAMIC)\n\n                gen_op_set_cc_op(s->cc_op);\n\n            gen_string_ds(s, ot, gen_op_cmps + 9);\n\n            s->cc_op = CC_OP_DYNAMIC; \/* cannot predict flags after *\/\n\n        } else {\n\n            gen_string_ds(s, ot, gen_op_cmps);\n\n            s->cc_op = CC_OP_SUBB + ot;\n\n        }\n\n        break;\n\n    case 0x6c: \/* insS *\/\n\n    case 0x6d:\n\n        if (s->cpl > s->iopl || s->vm86) {\n\n            \/* NOTE: even for (E)CX = 0 the exception is raised *\/\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            if (prefixes & PREFIX_REPZ) {\n\n                gen_string_es(s, ot, gen_op_ins + 9);\n\n            } else {\n\n                gen_string_es(s, ot, gen_op_ins);\n\n            }\n\n        }\n\n        break;\n\n    case 0x6e: \/* outsS *\/\n\n    case 0x6f:\n\n        if (s->cpl > s->iopl || s->vm86) {\n\n            \/* NOTE: even for (E)CX = 0 the exception is raised *\/\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            if (prefixes & PREFIX_REPZ) {\n\n                gen_string_ds(s, ot, gen_op_outs + 9);\n\n            } else {\n\n                gen_string_ds(s, ot, gen_op_outs);\n\n            }\n\n        }\n\n        break;\n\n\n\n        \/************************\/\n\n        \/* port I\/O *\/\n\n    case 0xe4:\n\n    case 0xe5:\n\n        if (s->cpl > s->iopl || s->vm86) {\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            val = ldub(s->pc++);\n\n            gen_op_movl_T0_im(val);\n\n            gen_op_in[ot]();\n\n            gen_op_mov_reg_T1[ot][R_EAX]();\n\n        }\n\n        break;\n\n    case 0xe6:\n\n    case 0xe7:\n\n        if (s->cpl > s->iopl || s->vm86) {\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            val = ldub(s->pc++);\n\n            gen_op_movl_T0_im(val);\n\n            gen_op_mov_TN_reg[ot][1][R_EAX]();\n\n            gen_op_out[ot]();\n\n        }\n\n        break;\n\n    case 0xec:\n\n    case 0xed:\n\n        if (s->cpl > s->iopl || s->vm86) {\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            gen_op_mov_TN_reg[OT_WORD][0][R_EDX]();\n\n            gen_op_in[ot]();\n\n            gen_op_mov_reg_T1[ot][R_EAX]();\n\n        }\n\n        break;\n\n    case 0xee:\n\n    case 0xef:\n\n        if (s->cpl > s->iopl || s->vm86) {\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if ((b & 1) == 0)\n\n                ot = OT_BYTE;\n\n            else\n\n                ot = dflag ? OT_LONG : OT_WORD;\n\n            gen_op_mov_TN_reg[OT_WORD][0][R_EDX]();\n\n            gen_op_mov_TN_reg[ot][1][R_EAX]();\n\n            gen_op_out[ot]();\n\n        }\n\n        break;\n\n\n\n        \/************************\/\n\n        \/* control *\/\n\n    case 0xc2: \/* ret im *\/\n\n        val = ldsw(s->pc);\n\n        s->pc += 2;\n\n        gen_pop_T0(s);\n\n        if (s->ss32)\n\n            gen_op_addl_ESP_im(val + (2 << s->dflag));\n\n        else\n\n            gen_op_addw_ESP_im(val + (2 << s->dflag));\n\n        if (s->dflag == 0)\n\n            gen_op_andl_T0_ffff();\n\n        gen_op_jmp_T0();\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xc3: \/* ret *\/\n\n        gen_pop_T0(s);\n\n        gen_pop_update(s);\n\n        if (s->dflag == 0)\n\n            gen_op_andl_T0_ffff();\n\n        gen_op_jmp_T0();\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xca: \/* lret im *\/\n\n        \/* XXX: not restartable *\/\n\n        val = ldsw(s->pc);\n\n        s->pc += 2;\n\n        \/* pop offset *\/\n\n        gen_pop_T0(s);\n\n        if (s->dflag == 0)\n\n            gen_op_andl_T0_ffff();\n\n        gen_op_jmp_T0();\n\n        gen_pop_update(s);\n\n        \/* pop selector *\/\n\n        gen_pop_T0(s);\n\n        gen_movl_seg_T0(s, R_CS);\n\n        gen_pop_update(s);\n\n        \/* add stack offset *\/\n\n        if (s->ss32)\n\n            gen_op_addl_ESP_im(val + (2 << s->dflag));\n\n        else\n\n            gen_op_addw_ESP_im(val + (2 << s->dflag));\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xcb: \/* lret *\/\n\n        \/* XXX: not restartable *\/\n\n        \/* pop offset *\/\n\n        gen_pop_T0(s);\n\n        if (s->dflag == 0)\n\n            gen_op_andl_T0_ffff();\n\n        gen_op_jmp_T0();\n\n        gen_pop_update(s);\n\n        \/* pop selector *\/\n\n        gen_pop_T0(s);\n\n        gen_movl_seg_T0(s, R_CS);\n\n        gen_pop_update(s);\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xcf: \/* iret *\/\n\n        \/* XXX: not restartable *\/\n\n        \/* pop offset *\/\n\n        gen_pop_T0(s);\n\n        if (s->dflag == 0)\n\n            gen_op_andl_T0_ffff();\n\n        gen_op_jmp_T0();\n\n        gen_pop_update(s);\n\n        \/* pop selector *\/\n\n        gen_pop_T0(s);\n\n        gen_movl_seg_T0(s, R_CS);\n\n        gen_pop_update(s);\n\n        \/* pop eflags *\/\n\n        gen_pop_T0(s);\n\n        if (s->dflag) {\n\n            if (s->vm86)\n\n                gen_op_movl_eflags_T0_vm(pc_start - s->cs_base);\n\n            else\n\n                gen_op_movl_eflags_T0();\n\n        } else {\n\n            if (s->vm86)\n\n                gen_op_movw_eflags_T0_vm(pc_start - s->cs_base);\n\n            else\n\n                gen_op_movw_eflags_T0();\n\n        }\n\n        gen_pop_update(s);\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xe8: \/* call im *\/\n\n        {\n\n            unsigned int next_eip;\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n            val = insn_get(s, ot);\n\n            next_eip = s->pc - s->cs_base;\n\n            val += next_eip;\n\n            if (s->dflag == 0)\n\n                val &= 0xffff;\n\n            gen_op_movl_T0_im(next_eip);\n\n            gen_push_T0(s);\n\n            gen_op_jmp_im(val);\n\n            s->is_jmp = 1;\n\n        }\n\n        break;\n\n    case 0x9a: \/* lcall im *\/\n\n        {\n\n            unsigned int selector, offset;\n\n\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n            offset = insn_get(s, ot);\n\n            selector = insn_get(s, OT_WORD);\n\n            \n\n            \/* push return segment + offset *\/\n\n            gen_op_movl_T0_seg(R_CS);\n\n            gen_push_T0(s);\n\n            next_eip = s->pc - s->cs_base;\n\n            gen_op_movl_T0_im(next_eip);\n\n            gen_push_T0(s);\n\n\n\n            \/* change cs and pc *\/\n\n            gen_op_movl_T0_im(selector);\n\n            gen_movl_seg_T0(s, R_CS);\n\n            gen_op_jmp_im((unsigned long)offset);\n\n            s->is_jmp = 1;\n\n        }\n\n        break;\n\n    case 0xe9: \/* jmp *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        val = insn_get(s, ot);\n\n        val += s->pc - s->cs_base;\n\n        if (s->dflag == 0)\n\n            val = val & 0xffff;\n\n        gen_op_jmp_im(val);\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xea: \/* ljmp im *\/\n\n        {\n\n            unsigned int selector, offset;\n\n\n\n            ot = dflag ? OT_LONG : OT_WORD;\n\n            offset = insn_get(s, ot);\n\n            selector = insn_get(s, OT_WORD);\n\n            \n\n            \/* change cs and pc *\/\n\n            gen_op_movl_T0_im(selector);\n\n            gen_movl_seg_T0(s, R_CS);\n\n            gen_op_jmp_im((unsigned long)offset);\n\n            s->is_jmp = 1;\n\n        }\n\n        break;\n\n    case 0xeb: \/* jmp Jb *\/\n\n        val = (int8_t)insn_get(s, OT_BYTE);\n\n        val += s->pc - s->cs_base;\n\n        if (s->dflag == 0)\n\n            val = val & 0xffff;\n\n        gen_op_jmp_im(val);\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0x70 ... 0x7f: \/* jcc Jb *\/\n\n        val = (int8_t)insn_get(s, OT_BYTE);\n\n        goto do_jcc;\n\n    case 0x180 ... 0x18f: \/* jcc Jv *\/\n\n        if (dflag) {\n\n            val = insn_get(s, OT_LONG);\n\n        } else {\n\n            val = (int16_t)insn_get(s, OT_WORD); \n\n        }\n\n    do_jcc:\n\n        next_eip = s->pc - s->cs_base;\n\n        val += next_eip;\n\n        if (s->dflag == 0)\n\n            val &= 0xffff;\n\n        gen_jcc(s, b, val, next_eip);\n\n        s->is_jmp = 1;\n\n        break;\n\n\n\n    case 0x190 ... 0x19f: \/* setcc Gv *\/\n\n        modrm = ldub(s->pc++);\n\n        gen_setcc(s, b);\n\n        gen_ldst_modrm(s, modrm, OT_BYTE, OR_TMP0, 1);\n\n        break;\n\n    case 0x140 ... 0x14f: \/* cmov Gv, Ev *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        gen_setcc(s, b);\n\n        if (mod != 3) {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_ld_T1_A0[ot]();\n\n        } else {\n\n            rm = modrm & 7;\n\n            gen_op_mov_TN_reg[ot][1][rm]();\n\n        }\n\n        gen_op_cmov_reg_T1_T0[ot - OT_WORD][reg]();\n\n        break;\n\n        \n\n        \/************************\/\n\n        \/* flags *\/\n\n    case 0x9c: \/* pushf *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        if (s->vm86)\n\n            gen_op_movl_T0_eflags_vm();\n\n        else\n\n            gen_op_movl_T0_eflags();\n\n        gen_push_T0(s);\n\n        break;\n\n    case 0x9d: \/* popf *\/\n\n        gen_pop_T0(s);\n\n        if (s->dflag) {\n\n            if (s->vm86)\n\n                gen_op_movl_eflags_T0_vm(pc_start - s->cs_base);\n\n            else\n\n                gen_op_movl_eflags_T0();\n\n        } else {\n\n            if (s->vm86)\n\n                gen_op_movw_eflags_T0_vm(pc_start - s->cs_base);\n\n            else\n\n                gen_op_movw_eflags_T0();\n\n        }\n\n        gen_pop_update(s);\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0x9e: \/* sahf *\/\n\n        gen_op_mov_TN_reg[OT_BYTE][0][R_AH]();\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_movb_eflags_T0();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0x9f: \/* lahf *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_movl_T0_eflags();\n\n        gen_op_mov_reg_T0[OT_BYTE][R_AH]();\n\n        break;\n\n    case 0xf5: \/* cmc *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_cmc();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0xf8: \/* clc *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_clc();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0xf9: \/* stc *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_stc();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0xfc: \/* cld *\/\n\n        gen_op_cld();\n\n        break;\n\n    case 0xfd: \/* std *\/\n\n        gen_op_std();\n\n        break;\n\n\n\n        \/************************\/\n\n        \/* bit operations *\/\n\n    case 0x1ba: \/* bt\/bts\/btr\/btc Gv, im *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        op = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        if (mod != 3) {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            gen_op_ld_T0_A0[ot]();\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][0][rm]();\n\n        }\n\n        \/* load shift *\/\n\n        val = ldub(s->pc++);\n\n        gen_op_movl_T1_im(val);\n\n        if (op < 4)\n\n            goto illegal_op;\n\n        op -= 4;\n\n        gen_op_btx_T0_T1_cc[ot - OT_WORD][op]();\n\n        s->cc_op = CC_OP_SARB + ot;\n\n        if (op != 0) {\n\n            if (mod != 3)\n\n                gen_op_st_T0_A0[ot]();\n\n            else\n\n                gen_op_mov_reg_T0[ot][rm]();\n\n        }\n\n        break;\n\n    case 0x1a3: \/* bt Gv, Ev *\/\n\n        op = 0;\n\n        goto do_btx;\n\n    case 0x1ab: \/* bts *\/\n\n        op = 1;\n\n        goto do_btx;\n\n    case 0x1b3: \/* btr *\/\n\n        op = 2;\n\n        goto do_btx;\n\n    case 0x1bb: \/* btc *\/\n\n        op = 3;\n\n    do_btx:\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        rm = modrm & 7;\n\n        gen_op_mov_TN_reg[OT_LONG][1][reg]();\n\n        if (mod != 3) {\n\n            gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n            \/* specific case: we need to add a displacement *\/\n\n            if (ot == OT_WORD)\n\n                gen_op_add_bitw_A0_T1();\n\n            else\n\n                gen_op_add_bitl_A0_T1();\n\n            gen_op_ld_T0_A0[ot]();\n\n        } else {\n\n            gen_op_mov_TN_reg[ot][0][rm]();\n\n        }\n\n        gen_op_btx_T0_T1_cc[ot - OT_WORD][op]();\n\n        s->cc_op = CC_OP_SARB + ot;\n\n        if (op != 0) {\n\n            if (mod != 3)\n\n                gen_op_st_T0_A0[ot]();\n\n            else\n\n                gen_op_mov_reg_T0[ot][rm]();\n\n        }\n\n        break;\n\n    case 0x1bc: \/* bsf *\/\n\n    case 0x1bd: \/* bsr *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);\n\n        gen_op_bsx_T0_cc[ot - OT_WORD][b & 1]();\n\n        \/* NOTE: we always write back the result. Intel doc says it is\n\n           undefined if T0 == 0 *\/\n\n        gen_op_mov_reg_T0[ot][reg]();\n\n        s->cc_op = CC_OP_LOGICB + ot;\n\n        break;\n\n        \/************************\/\n\n        \/* bcd *\/\n\n    case 0x27: \/* daa *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_daa();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0x2f: \/* das *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_das();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0x37: \/* aaa *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_aaa();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0x3f: \/* aas *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_aas();\n\n        s->cc_op = CC_OP_EFLAGS;\n\n        break;\n\n    case 0xd4: \/* aam *\/\n\n        val = ldub(s->pc++);\n\n        gen_op_aam(val);\n\n        s->cc_op = CC_OP_LOGICB;\n\n        break;\n\n    case 0xd5: \/* aad *\/\n\n        val = ldub(s->pc++);\n\n        gen_op_aad(val);\n\n        s->cc_op = CC_OP_LOGICB;\n\n        break;\n\n        \/************************\/\n\n        \/* misc *\/\n\n    case 0x90: \/* nop *\/\n\n        break;\n\n    case 0xcc: \/* int3 *\/\n\n        gen_op_int3((long)pc_start);\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xcd: \/* int N *\/\n\n        val = ldub(s->pc++);\n\n        gen_op_int_im(val, pc_start - s->cs_base);\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0xce: \/* into *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_into();\n\n        break;\n\n    case 0xfa: \/* cli *\/\n\n        if (!s->vm86) {\n\n            if (s->cpl <= s->iopl)\n\n                gen_op_cli();\n\n            else\n\n                gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if (s->iopl == 3)\n\n                gen_op_cli();\n\n            else\n\n                gen_op_cli_vm();\n\n        }\n\n        break;\n\n    case 0xfb: \/* sti *\/\n\n        if (!s->vm86) {\n\n            if (s->cpl <= s->iopl)\n\n                gen_op_sti();\n\n            else\n\n                gen_op_gpf(pc_start - s->cs_base);\n\n        } else {\n\n            if (s->iopl == 3)\n\n                gen_op_sti();\n\n            else\n\n                gen_op_sti_vm(pc_start - s->cs_base);\n\n        }\n\n        break;\n\n    case 0x62: \/* bound *\/\n\n        ot = dflag ? OT_LONG : OT_WORD;\n\n        modrm = ldub(s->pc++);\n\n        reg = (modrm >> 3) & 7;\n\n        mod = (modrm >> 6) & 3;\n\n        if (mod == 3)\n\n            goto illegal_op;\n\n        gen_op_mov_reg_T0[ot][reg]();\n\n        gen_lea_modrm(s, modrm, ®_addr, &offset_addr);\n\n        if (ot == OT_WORD)\n\n            gen_op_boundw();\n\n        else\n\n            gen_op_boundl();\n\n        break;\n\n    case 0x1c8 ... 0x1cf: \/* bswap reg *\/\n\n        reg = b & 7;\n\n        gen_op_mov_TN_reg[OT_LONG][0][reg]();\n\n        gen_op_bswapl_T0();\n\n        gen_op_mov_reg_T0[OT_LONG][reg]();\n\n        break;\n\n    case 0xd6: \/* salc *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        gen_op_salc();\n\n        break;\n\n    case 0xe0: \/* loopnz *\/\n\n    case 0xe1: \/* loopz *\/\n\n        if (s->cc_op != CC_OP_DYNAMIC)\n\n            gen_op_set_cc_op(s->cc_op);\n\n        \/* FALL THRU *\/\n\n    case 0xe2: \/* loop *\/\n\n    case 0xe3: \/* jecxz *\/\n\n        val = (int8_t)insn_get(s, OT_BYTE);\n\n        next_eip = s->pc - s->cs_base;\n\n        val += next_eip;\n\n        if (s->dflag == 0)\n\n            val &= 0xffff;\n\n        gen_op_loop[s->aflag][b & 3](val, next_eip);\n\n        s->is_jmp = 1;\n\n        break;\n\n    case 0x131: \/* rdtsc *\/\n\n        gen_op_rdtsc();\n\n        break;\n\n    case 0x1a2: \/* cpuid *\/\n\n        gen_op_cpuid();\n\n        break;\n\n    case 0xf4: \/* hlt *\/\n\n        if (s->cpl == 0) {\n\n            \/* ignored *\/\n\n        } else {\n\n            gen_op_gpf(pc_start - s->cs_base);\n\n        }\n\n        break;\n\n    default:\n\n        goto illegal_op;\n\n    }\n\n    \/* lock generation *\/\n\n    if (s->prefix & PREFIX_LOCK)\n\n        gen_op_unlock();\n\n    return (long)s->pc;\n\n illegal_op:\n\n    \/* XXX: ensure that no lock was generated *\/\n\n    return -1;\n\n}\n","target":1,"code_token_length":16690,"total_token_length":16926,"max_tokens_setting":28000}
+{"idx":46545,"func":"void CLASS identify()\n{\n  char head[32], *cp;\n  int hlen, flen, fsize, zero_fsize=1, i, c, is_canon;\n  struct jhead jh;\n  short pana[][6] = {\n    { 3130, 1743,  4,  0, -6,  0 },\n    { 3130, 2055,  4,  0, -6,  0 },\n    { 3130, 2319,  4,  0, -6,  0 },\n    { 3170, 2103, 18,  0,-42, 20 },\n    { 3170, 2367, 18, 13,-42,-21 },\n    { 3177, 2367,  0,  0, -1,  0 },\n    { 3304, 2458,  0,  0, -1,  0 },\n    { 3330, 2463,  9,  0, -5,  0 },\n    { 3330, 2479,  9,  0,-17,  4 },\n    { 3370, 1899, 15,  0,-44, 20 },\n    { 3370, 2235, 15,  0,-44, 20 },\n    { 3370, 2511, 15, 10,-44,-21 },\n    { 3690, 2751,  3,  0, -8, -3 },\n    { 3710, 2751,  0,  0, -3,  0 },\n    { 3724, 2450,  0,  0,  0, -2 },\n    { 3770, 2487, 17,  0,-44, 19 },\n    { 3770, 2799, 17, 15,-44,-19 },\n    { 3880, 2170,  6,  0, -6,  0 },\n    { 4060, 3018,  0,  0,  0, -2 },\n    { 4290, 2391,  3,  0, -8, -1 },\n    { 4330, 2439, 17, 15,-44,-19 },\n    { 4508, 2962,  0,  0, -3, -4 },\n    { 4508, 3330,  0,  0, -3, -6 } };\n  static const struct {\n    int fsize;\n    const char make[12], model[19], withjpeg;\n  } table[] = {\n    {    62464, \"Kodak\",    \"DC20\"            ,0 },\n    {   124928, \"Kodak\",    \"DC20\"            ,0 },\n    {  1652736, \"Kodak\",    \"DCS200\"          ,0 },\n    {  4159302, \"Kodak\",    \"C330\"            ,0 },\n    {  4162462, \"Kodak\",    \"C330\"            ,0 },\n    {   460800, \"Kodak\",    \"C603v\"           ,0 },\n    {   614400, \"Kodak\",    \"C603v\"           ,0 },\n    {  6163328, \"Kodak\",    \"C603\"            ,0 },\n    {  6166488, \"Kodak\",    \"C603\"            ,0 },\n    {  9116448, \"Kodak\",    \"C603y\"           ,0 },\n    {   311696, \"ST Micro\", \"STV680 VGA\"      ,0 },  \/* SPYz *\/\n    {   787456, \"Creative\", \"PC-CAM 600\"      ,0 },\n    {  1138688, \"Minolta\",  \"RD175\"           ,0 },\n    {  3840000, \"Foculus\",  \"531C\"            ,0 },\n    {   786432, \"AVT\",      \"F-080C\"          ,0 },\n    {  1447680, \"AVT\",      \"F-145C\"          ,0 },\n    {  1920000, \"AVT\",      \"F-201C\"          ,0 },\n    {  5067304, \"AVT\",      \"F-510C\"          ,0 },\n    {  5067316, \"AVT\",      \"F-510C\"          ,0 },\n    { 10134608, \"AVT\",      \"F-510C\"          ,0 },\n    { 10134620, \"AVT\",      \"F-510C\"          ,0 },\n    { 16157136, \"AVT\",      \"F-810C\"          ,0 },\n    {  1409024, \"Sony\",     \"XCD-SX910CR\"     ,0 },\n    {  2818048, \"Sony\",     \"XCD-SX910CR\"     ,0 },\n    {  3884928, \"Micron\",   \"2010\"            ,0 },\n    {  6624000, \"Pixelink\", \"A782\"            ,0 },\n    { 13248000, \"Pixelink\", \"A782\"            ,0 },\n    {  6291456, \"RoverShot\",\"3320AF\"          ,0 },\n    {  6553440, \"Canon\",    \"PowerShot A460\"  ,0 },\n    {  6653280, \"Canon\",    \"PowerShot A530\"  ,0 },\n    {  6573120, \"Canon\",    \"PowerShot A610\"  ,0 },\n    {  9219600, \"Canon\",    \"PowerShot A620\"  ,0 },\n    {  9243240, \"Canon\",    \"PowerShot A470\"  ,0 },\n    { 10341600, \"Canon\",    \"PowerShot A720 IS\",0 },\n    { 10383120, \"Canon\",    \"PowerShot A630\"  ,0 },\n    { 12945240, \"Canon\",    \"PowerShot A640\"  ,0 },\n    { 15636240, \"Canon\",    \"PowerShot A650\"  ,0 },\n    {  5298000, \"Canon\",    \"PowerShot SD300\" ,0 },\n    {  7710960, \"Canon\",    \"PowerShot S3 IS\" ,0 },\n    { 15467760, \"Canon\",    \"PowerShot SX110 IS\",0 },\n    { 15534576, \"Canon\",    \"PowerShot SX120 IS\",0 },\n    { 18653760, \"Canon\",    \"PowerShot SX20 IS\",0 },\n    { 21936096, \"Canon\",    \"PowerShot SX30 IS\",0 },\n    {  5939200, \"OLYMPUS\",  \"C770UZ\"          ,0 },\n    {  1581060, \"NIKON\",    \"E900\"            ,1 },  \/* or E900s,E910 *\/\n    {  2465792, \"NIKON\",    \"E950\"            ,1 },  \/* or E800,E700 *\/\n    {  2940928, \"NIKON\",    \"E2100\"           ,1 },  \/* or E2500 *\/\n    {  4771840, \"NIKON\",    \"E990\"            ,1 },  \/* or E995, Oly C3030Z *\/\n    {  4775936, \"NIKON\",    \"E3700\"           ,1 },  \/* or Optio 33WR *\/\n    {  5869568, \"NIKON\",    \"E4300\"           ,1 },  \/* or DiMAGE Z2 *\/\n    {  5865472, \"NIKON\",    \"E4500\"           ,1 },\n    {  7438336, \"NIKON\",    \"E5000\"           ,1 },  \/* or E5700 *\/\n    {  8998912, \"NIKON\",    \"COOLPIX S6\"      ,1 },\n    {  1976352, \"CASIO\",    \"QV-2000UX\"       ,1 },\n    {  3217760, \"CASIO\",    \"QV-3*00EX\"       ,1 },\n    {  6218368, \"CASIO\",    \"QV-5700\"         ,1 },\n    {  6054400, \"CASIO\",    \"QV-R41\"          ,1 },\n    {  7530816, \"CASIO\",    \"QV-R51\"          ,1 },\n    {  7684000, \"CASIO\",    \"QV-4000\"         ,1 },\n    {  2937856, \"CASIO\",    \"EX-S20\"          ,1 },\n    {  4948608, \"CASIO\",    \"EX-S100\"         ,1 },\n    {  7542528, \"CASIO\",    \"EX-Z50\"          ,1 },\n    {  7562048, \"CASIO\",    \"EX-Z500\"         ,1 },\n    {  7753344, \"CASIO\",    \"EX-Z55\"          ,1 },\n    {  7816704, \"CASIO\",    \"EX-Z60\"          ,1 },\n    { 10843712, \"CASIO\",    \"EX-Z75\"          ,1 },\n    { 10834368, \"CASIO\",    \"EX-Z750\"         ,1 },\n    { 12310144, \"CASIO\",    \"EX-Z850\"         ,1 },\n    { 15499264, \"CASIO\",    \"EX-Z1050\"        ,1 },\n    {  7426656, \"CASIO\",    \"EX-P505\"         ,1 },\n    {  9313536, \"CASIO\",    \"EX-P600\"         ,1 },\n    { 10979200, \"CASIO\",    \"EX-P700\"         ,1 },\n    {  3178560, \"PENTAX\",   \"Optio S\"         ,1 },\n    {  4841984, \"PENTAX\",   \"Optio S\"         ,1 },\n    {  6114240, \"PENTAX\",   \"Optio S4\"        ,1 },  \/* or S4i, CASIO EX-Z4 *\/\n    { 10702848, \"PENTAX\",   \"Optio 750Z\"      ,1 },\n    { 15980544, \"AGFAPHOTO\",\"DC-833m\"         ,1 },\n    { 16098048, \"SAMSUNG\",  \"S85\"             ,1 },\n    { 16215552, \"SAMSUNG\",  \"S85\"             ,1 },\n    { 20487168, \"SAMSUNG\",  \"WB550\"           ,1 },\n    { 24000000, \"SAMSUNG\",  \"WB550\"           ,1 },\n    { 12582980, \"Sinar\",    \"\"                ,0 },\n    { 33292868, \"Sinar\",    \"\"                ,0 },\n    { 44390468, \"Sinar\",    \"\"                ,0 } };\n  static const char *corp[] =\n    { \"Canon\", \"NIKON\", \"EPSON\", \"KODAK\", \"Kodak\", \"OLYMPUS\", \"PENTAX\",\n      \"MINOLTA\", \"Minolta\", \"Konica\", \"CASIO\", \"Sinar\", \"Phase One\",\n      \"SAMSUNG\", \"Mamiya\", \"MOTOROLA\" };\n\n  tiff_flip = flip = filters = -1;\t\/* 0 is valid, so -1 is unknown *\/\n  raw_height = raw_width = fuji_width = fuji_layout = cr2_slice[0] = 0;\n  maximum = height = width = top_margin = left_margin = 0;\n  cdesc[0] = desc[0] = artist[0] = make[0] = model[0] = model2[0] = 0;\n  iso_speed = shutter = aperture = focal_len = unique_id = 0;\n  tiff_nifds = 0;\n  memset (tiff_ifd, 0, sizeof tiff_ifd);\n  memset (gpsdata, 0, sizeof gpsdata);\n  memset (cblack, 0, sizeof cblack);\n  memset (white, 0, sizeof white);\n  thumb_offset = thumb_length = thumb_width = thumb_height = 0;\n  load_raw = thumb_load_raw = 0;\n  write_thumb = &CLASS jpeg_thumb;\n  data_offset = meta_length = tiff_bps = tiff_compress = 0;\n  kodak_cbpp = zero_after_ff = dng_version = load_flags = 0;\n  timestamp = shot_order = tiff_samples = black = is_foveon = 0;\n  mix_green = profile_length = data_error = zero_is_bad = 0;\n  pixel_aspect = is_raw = raw_color = 1;\n  tile_width = tile_length = INT_MAX;\n  for (i=0; i < 4; i++) {\n    cam_mul[i] = i == 1;\n    pre_mul[i] = i < 3;\n    FORC3 cmatrix[c][i] = 0;\n    FORC3 rgb_cam[c][i] = c == i;\n  }\n  colors = 3;\n  for (i=0; i < 0x4000; i++) curve[i] = i;\n\n  order = get2();\n  hlen = get4();\n  fseek (ifp, 0, SEEK_SET);\n  fread (head, 1, 32, ifp);\n  fseek (ifp, 0, SEEK_END);\n  flen = fsize = ftell(ifp);\n  \/* Note for Rawstudio maintainers, this check is not present in upstream dcraw *\/\n  if (fsize < 32)\n    return;\n  if ((cp = (char *) memmem (head, 32, \"MMMM\", 4)) ||\n      (cp = (char *) memmem (head, 32, \"IIII\", 4))) {\n    parse_phase_one (cp-head);\n    if (cp-head && parse_tiff(0)) apply_tiff();\n  } else if (order == 0x4949 || order == 0x4d4d) {\n    if (!memcmp (head+6,\"HEAPCCDR\",8)) {\n      data_offset = hlen;\n      parse_ciff (hlen, flen - hlen);\n    } else if (parse_tiff(0)) apply_tiff();\n  } else if (!memcmp (head,\"\\xff\\xd8\\xff\\xe1\",4) &&\n\t     !memcmp (head+6,\"Exif\",4)) {\n    fseek (ifp, 4, SEEK_SET);\n    data_offset = 4 + get2();\n    fseek (ifp, data_offset, SEEK_SET);\n    if (fgetc(ifp) != 0xff)\n      parse_tiff(12);\n    thumb_offset = 0;\n  } else if (!memcmp (head+25,\"ARECOYK\",7)) {\n    strcpy (make, \"Contax\");\n    strcpy (model,\"N Digital\");\n    fseek (ifp, 33, SEEK_SET);\n    get_timestamp(1);\n    fseek (ifp, 60, SEEK_SET);\n    FORC4 cam_mul[c ^ (c >> 1)] = get4();\n  } else if (!strcmp (head, \"PXN\")) {\n    strcpy (make, \"Logitech\");\n    strcpy (model,\"Fotoman Pixtura\");\n  } else if (!strcmp (head, \"qktk\")) {\n    strcpy (make, \"Apple\");\n    strcpy (model,\"QuickTake 100\");\n    load_raw = &CLASS quicktake_100_load_raw;\n  } else if (!strcmp (head, \"qktn\")) {\n    strcpy (make, \"Apple\");\n    strcpy (model,\"QuickTake 150\");\n    load_raw = &CLASS kodak_radc_load_raw;\n  } else if (!memcmp (head,\"FUJIFILM\",8)) {\n    fseek (ifp, 84, SEEK_SET);\n    thumb_offset = get4();\n    thumb_length = get4();\n    fseek (ifp, 92, SEEK_SET);\n    parse_fuji (get4());\n    if (thumb_offset > 120) {\n      fseek (ifp, 120, SEEK_SET);\n      is_raw += (i = get4()) && 1;\n      if (is_raw == 2 && shot_select)\n\tparse_fuji (i);\n    }\n    fseek (ifp, 100+28*(shot_select > 0), SEEK_SET);\n    parse_tiff (data_offset = get4());\n    parse_tiff (thumb_offset+12);\n    apply_tiff();\n  } else if (!memcmp (head,\"RIFF\",4)) {\n    fseek (ifp, 0, SEEK_SET);\n    parse_riff();\n  } else if (!memcmp (head,\"\\0\\001\\0\\001\\0@\",6)) {\n    fseek (ifp, 6, SEEK_SET);\n    fread (make, 1, 8, ifp);\n    fread (model, 1, 8, ifp);\n    fread (model2, 1, 16, ifp);\n    data_offset = get2();\n    get2();\n    raw_width = get2();\n    raw_height = get2();\n    load_raw = &CLASS nokia_load_raw;\n    filters = 0x61616161;\n  } else if (!memcmp (head,\"NOKIARAW\",8)) {\n    strcpy (make, \"NOKIA\");\n    strcpy (model, \"X2\");\n    order = 0x4949;\n    fseek (ifp, 300, SEEK_SET);\n    data_offset = get4();\n    i = get4();\n    width = get2();\n    height = get2();\n    data_offset += i - width * 5 \/ 4 * height;\n    load_raw = &CLASS nokia_load_raw;\n    filters = 0x61616161;\n  } else if (!memcmp (head,\"ARRI\",4)) {\n    order = 0x4949;\n    fseek (ifp, 20, SEEK_SET);\n    width = get4();\n    height = get4();\n    strcpy (make, \"ARRI\");\n    fseek (ifp, 668, SEEK_SET);\n    fread (model, 1, 64, ifp);\n    data_offset = 4096;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 88;\n    filters = 0x61616161;\n  } else if (!memcmp (head+4,\"RED1\",4)) {\n    strcpy (make, \"RED\");\n    strcpy (model,\"ONE\");\n    parse_redcine();\n    load_raw = &CLASS redcine_load_raw;\n    gamma_curve (1\/2.4, 12.92, 1, 4095);\n    filters = 0x49494949;\n  } else if (!memcmp (head,\"DSC-Image\",9))\n    parse_rollei();\n  else if (!memcmp (head,\"PWAD\",4))\n    parse_sinar_ia();\n  else if (!memcmp (head,\"\\0MRM\",4))\n    parse_minolta(0);\n  else if (!memcmp (head,\"FOVb\",4))\n    parse_foveon();\n  else if (!memcmp (head,\"CI\",2))\n    parse_cine();\n  else\n    for (zero_fsize=i=0; i < (int) sizeof table \/ (int) sizeof *table; i++)\n      if (fsize == table[i].fsize) {\n\tstrcpy (make,  table[i].make );\n\tstrcpy (model, table[i].model);\n\tif (table[i].withjpeg)\n\t  parse_external_jpeg();\n      }\n  if (zero_fsize) fsize = 0;\n  if (make[0] == 0) parse_smal (0, flen);\n  if (make[0] == 0) parse_jpeg (is_raw = 0);\n\n  for (i=0; i < (int) sizeof corp \/ (int) sizeof *corp; i++)\n    if (strstr (make, corp[i]))\t\t\/* Simplify company names *\/\n\tstrcpy (make, corp[i]);\n  if (!strncmp (make,\"KODAK\",5) &&\n\t((cp = strstr(model,\" DIGITAL CAMERA\")) ||\n\t (cp = strstr(model,\" Digital Camera\")) ||\n\t (cp = strstr(model,\"FILE VERSION\"))))\n     *cp = 0;\n  cp = make + strlen(make);\t\t\/* Remove trailing spaces *\/\n  while (*--cp == ' ') *cp = 0;\n  cp = model + strlen(model);\n  while (*--cp == ' ') *cp = 0;\n  i = strlen(make);\t\t\t\/* Remove make from model *\/\n  if (!strncasecmp (model, make, i) && model[i++] == ' ')\n    memmove (model, model+i, 64-i);\n  if (!strncmp (model,\"Digital Camera \",15))\n    strcpy (model, model+15);\n  desc[511] = artist[63] = make[63] = model[63] = model2[63] = 0;\n  if (!is_raw) goto notraw;\n\n  if (!height) height = raw_height;\n  if (!width)  width  = raw_width;\n  if (fuji_width) {\n    fuji_width = (raw_width+1)\/2;\n    width = height + fuji_width;\n    height = width - 1;\n    pixel_aspect = 1;\n  }\n  if (height == 2624 && width == 3936)\t\/* Pentax K10D and Samsung GX10 *\/\n    { height  = 2616;   width  = 3896; }\n  if (height == 3136 && width == 4864)  \/* Pentax K20D and Samsung GX20 *\/\n    { height  = 3124;   width  = 4688; filters = 0x16161616; }\n  if (width == 4352 && (!strcmp(model,\"K-r\") || !strcmp(model,\"K-x\")))\n    {\t\t\twidth  = 4309; filters = 0x16161616; }\n  if (width >= 4960 && !strcmp(model,\"K-5\"))\n    { left_margin = 10; width  = 4950; filters = 0x16161616; }\n  if (width == 4736 && !strcmp(model,\"K-7\"))\n    { height  = 3122;   width  = 4684; filters = 0x16161616; top_margin = 2; }\n  if (width == 7424 && !strcmp(model,\"645D\"))\n    { height  = 5502;   width  = 7328; filters = 0x61616161; top_margin = 29;\n      left_margin = 48; }\n  if (height == 3014 && width == 4096)\t\/* Ricoh GX200 *\/\n\t\t\twidth  = 4014;\n  if (dng_version) {\n    if (filters == UINT_MAX) filters = 0;\n    if (filters) is_raw = tiff_samples;\n    else\t colors = tiff_samples;\n    if (tiff_compress == 1)\n      load_raw = &CLASS adobe_dng_load_raw_nc;\n    if (tiff_compress == 7)\n      load_raw = &CLASS adobe_dng_load_raw_lj;\n    goto dng_skip;\n  }\n  if ((is_canon = !strcmp(make,\"Canon\")))\n    load_raw = memcmp (head+6,\"HEAPCCDR\",8) ?\n\t&CLASS lossless_jpeg_load_raw : &CLASS canon_compressed_load_raw;\n  if (!strcmp(make,\"NIKON\")) {\n    if (!load_raw)\n      load_raw = &CLASS packed_load_raw;\n    if (model[0] == 'E')\n      load_flags |= !data_offset << 2 | 2;\n  }\n  if (!strcmp(make,\"CASIO\")) {\n    load_raw = &CLASS packed_load_raw;\n    maximum = 0xf7f;\n  }\n\n\/* Set parameters based on camera name (for non-DNG files). *\/\n\n  if (is_foveon) {\n    if (height*2 < width) pixel_aspect = 0.5;\n    if (height   > width) pixel_aspect = 2;\n    filters = 0;\n    load_raw = &CLASS foveon_load_raw;\n    simple_coeff(0);\n  } else if (is_canon && tiff_bps == 15) {\n    switch (width) {\n      case 3344: width -= 66;\n      case 3872: width -= 6;\n    }\n    filters = 0;\n    load_raw = &CLASS canon_sraw_load_raw;\n  } else if (!strcmp(model,\"PowerShot 600\")) {\n    height = 613;\n    width  = 854;\n    raw_width = 896;\n    pixel_aspect = 607\/628.0;\n    colors = 4;\n    filters = 0xe1e4e1e4;\n    load_raw = &CLASS canon_600_load_raw;\n  } else if (!strcmp(model,\"PowerShot A5\") ||\n\t     !strcmp(model,\"PowerShot A5 Zoom\")) {\n    height = 773;\n    width  = 960;\n    raw_width = 992;\n    pixel_aspect = 256\/235.0;\n    colors = 4;\n    filters = 0x1e4e1e4e;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A50\")) {\n    height =  968;\n    width  = 1290;\n    raw_width = 1320;\n    colors = 4;\n    filters = 0x1b4e4b1e;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot Pro70\")) {\n    height = 1024;\n    width  = 1552;\n    colors = 4;\n    filters = 0x1e4b4e1b;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot SD300\")) {\n    height = 1752;\n    width  = 2344;\n    raw_height = 1766;\n    raw_width  = 2400;\n    top_margin  = 12;\n    left_margin = 12;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A460\")) {\n    height = 1960;\n    width  = 2616;\n    raw_height = 1968;\n    raw_width  = 2664;\n    top_margin  = 4;\n    left_margin = 4;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A530\")) {\n    height = 1984;\n    width  = 2620;\n    raw_height = 1992;\n    raw_width  = 2672;\n    top_margin  = 6;\n    left_margin = 10;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A610\")) {\n    if (canon_s2is()) strcpy (model+10, \"S2 IS\");\n    height = 1960;\n    width  = 2616;\n    raw_height = 1968;\n    raw_width  = 2672;\n    top_margin  = 8;\n    left_margin = 12;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A620\")) {\n    height = 2328;\n    width  = 3112;\n    raw_height = 2340;\n    raw_width  = 3152;\n    top_margin  = 12;\n    left_margin = 36;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A470\")) {\n    height = 2328;\n    width  = 3096;\n    raw_height = 2346;\n    raw_width  = 3152;\n    top_margin  = 6;\n    left_margin = 12;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A720 IS\")) {\n    height = 2472;\n    width  = 3298;\n    raw_height = 2480;\n    raw_width  = 3336;\n    top_margin  = 5;\n    left_margin = 6;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A630\")) {\n    height = 2472;\n    width  = 3288;\n    raw_height = 2484;\n    raw_width  = 3344;\n    top_margin  = 6;\n    left_margin = 12;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A640\")) {\n    height = 2760;\n    width  = 3672;\n    raw_height = 2772;\n    raw_width  = 3736;\n    top_margin  = 6;\n    left_margin = 12;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot A650\")) {\n    height = 3024;\n    width  = 4032;\n    raw_height = 3048;\n    raw_width  = 4104;\n    top_margin  = 12;\n    left_margin = 48;\n    goto canon_a5;\n  } else if (!strcmp(model,\"PowerShot S3 IS\")) {\n    height = 2128;\n    width  = 2840;\n    raw_height = 2136;\n    raw_width  = 2888;\n    top_margin  = 8;\n    left_margin = 44;\ncanon_a5:\n    tiff_bps = 10;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 40;\n    if (raw_width > 1600) zero_is_bad = 1;\n  } else if (!strcmp(model,\"PowerShot SX110 IS\")) {\n    height = 2760;\n    width  = 3684;\n    raw_height = 2772;\n    raw_width  = 3720;\n    top_margin  = 12;\n    left_margin = 6;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 40;\n    zero_is_bad = 1;\n  } else if (!strcmp(model,\"PowerShot SX120 IS\")) {\n    height = 2742;\n    width  = 3664;\n    raw_height = 2778;\n    raw_width  = 3728;\n    top_margin  = 18;\n    left_margin = 16;\n    filters = 0x49494949;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 40;\n    zero_is_bad = 1;\n  } else if (!strcmp(model,\"PowerShot SX20 IS\")) {\n    height = 3024;\n    width  = 4032;\n    raw_height = 3048;\n    raw_width  = 4080;\n    top_margin  = 12;\n    left_margin = 24;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 40;\n    zero_is_bad = 1;\n  } else if (!strcmp(model,\"PowerShot SX30 IS\")) {\n    height = 3254;\n    width  = 4366;\n    raw_height = 3276;\n    raw_width  = 4464;\n    top_margin  = 10;\n    left_margin = 25;\n    filters = 0x16161616;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 40;\n    zero_is_bad = 1;\n  } else if (!strcmp(model,\"PowerShot Pro90 IS\")) {\n    width  = 1896;\n    colors = 4;\n    filters = 0xb4b4b4b4;\n  } else if (is_canon && raw_width == 2144) {\n    height = 1550;\n    width  = 2088;\n    top_margin  = 8;\n    left_margin = 4;\n    if (!strcmp(model,\"PowerShot G1\")) {\n      colors = 4;\n      filters = 0xb4b4b4b4;\n    }\n  } else if (is_canon && raw_width == 2224) {\n    height = 1448;\n    width  = 2176;\n    top_margin  = 6;\n    left_margin = 48;\n  } else if (is_canon && raw_width == 2376) {\n    height = 1720;\n    width  = 2312;\n    top_margin  = 6;\n    left_margin = 12;\n  } else if (is_canon && raw_width == 2672) {\n    height = 1960;\n    width  = 2616;\n    top_margin  = 6;\n    left_margin = 12;\n  } else if (is_canon && raw_width == 3152) {\n    height = 2056;\n    width  = 3088;\n    top_margin  = 12;\n    left_margin = 64;\n    if (unique_id == 0x80000170)\n      adobe_coeff (\"Canon\",\"EOS 300D\");\n  } else if (is_canon && raw_width == 3160) {\n    height = 2328;\n    width  = 3112;\n    top_margin  = 12;\n    left_margin = 44;\n  } else if (is_canon && raw_width == 3344) {\n    height = 2472;\n    width  = 3288;\n    top_margin  = 6;\n    left_margin = 4;\n  } else if (!strcmp(model,\"EOS D2000C\")) {\n    filters = 0x61616161;\n    black = curve[200];\n  } else if (is_canon && raw_width == 3516) {\n    top_margin  = 14;\n    left_margin = 42;\n    if (unique_id == 0x80000189)\n      adobe_coeff (\"Canon\",\"EOS 350D\");\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 3596) {\n    top_margin  = 12;\n    left_margin = 74;\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 3744) {\n    height = 2760;\n    width  = 3684;\n    top_margin  = 16;\n    left_margin = 8;\n    if (unique_id > 0x2720000) {\n      top_margin  = 12;\n      left_margin = 52;\n    }\n  } else if (is_canon && raw_width == 3944) {\n    height = 2602;\n    width  = 3908;\n    top_margin  = 18;\n    left_margin = 30;\n  } else if (is_canon && raw_width == 3948) {\n    top_margin  = 18;\n    left_margin = 42;\n    height -= 2;\n    if (unique_id == 0x80000236)\n      adobe_coeff (\"Canon\",\"EOS 400D\");\n    if (unique_id == 0x80000254)\n      adobe_coeff (\"Canon\",\"EOS 1000D\");\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 3984) {\n    top_margin  = 20;\n    left_margin = 76;\n    height -= 2;\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 4104) {\n    height = 3024;\n    width  = 4032;\n    top_margin  = 12;\n    left_margin = 48;\n  } else if (is_canon && raw_width == 4152) {\n    top_margin  = 12;\n    left_margin = 192;\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 4160) {\n    height = 3048;\n    width  = 4048;\n    top_margin  = 11;\n    left_margin = 104;\n  } else if (is_canon && raw_width == 4312) {\n    top_margin  = 18;\n    left_margin = 22;\n    height -= 2;\n    if (unique_id == 0x80000176)\n      adobe_coeff (\"Canon\",\"EOS 450D\");\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 4352) {\n    top_margin  = 18;\n    left_margin = 62;\n    if (unique_id == 0x80000288)\n      adobe_coeff (\"Canon\",\"EOS 1100D\");\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 4476) {\n    top_margin  = 34;\n    left_margin = 90;\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 4480) {\n    height = 3326;\n    width  = 4432;\n    top_margin  = 10;\n    left_margin = 12;\n    filters = 0x49494949;\n  } else if (is_canon && raw_width == 4832) {\n    top_margin = unique_id == 0x80000261 ? 51:26;\n    left_margin = 62;\n    if (unique_id == 0x80000252)\n      adobe_coeff (\"Canon\",\"EOS 500D\");\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 5120) {\n    height -= top_margin = 45;\n    left_margin = 142;\n    width = 4916;\n  } else if (is_canon && raw_width == 5344) {\n    top_margin = 51;\n    left_margin = 142;\n    if (unique_id == 0x80000270)\n      adobe_coeff (\"Canon\",\"EOS 550D\");\n    if (unique_id == 0x80000286)\n      adobe_coeff (\"Canon\",\"EOS 600D\");\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 5360) {\n    top_margin = 51;\n    left_margin = 158;\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 5792) {\n    top_margin  = 51;\n    left_margin = 158;\n    goto canon_cr2;\n  } else if (is_canon && raw_width == 5108) {\n    top_margin  = 13;\n    left_margin = 98;\ncanon_cr2:\n    height -= top_margin;\n    width  -= left_margin;\n  } else if (is_canon && raw_width == 5712) {\n    height = 3752;\n    width  = 5640;\n    top_margin  = 20;\n    left_margin = 62;\n  } else if (!strcmp(model,\"D1\")) {\n    cam_mul[0] *= 256\/527.0;\n    cam_mul[2] *= 256\/317.0;\n  } else if (!strcmp(model,\"D1X\")) {\n    width -= 4;\n    pixel_aspect = 0.5;\n  } else if (!strcmp(model,\"D40X\") ||\n\t     !strcmp(model,\"D60\")  ||\n\t     !strcmp(model,\"D80\")  ||\n\t     !strcmp(model,\"D3000\")) {\n    height -= 3;\n    width  -= 4;\n  } else if (!strcmp(model,\"D3\")   ||\n\t     !strcmp(model,\"D3S\")  ||\n\t     !strcmp(model,\"D700\")) {\n    width -= 4;\n    left_margin = 2;\n  } else if (!strcmp(model,\"D5000\")) {\n    width -= 42;\n  } else if (!strcmp(model,\"D5100\") ||\n\t     !strcmp(model,\"D7000\")) {\n    width -= 44;\n  } else if (!strcmp(model,\"D3100\")) {\n    width -= 28;\n    left_margin = 6;\n  } else if (!strncmp(model,\"D40\",3) ||\n\t     !strncmp(model,\"D50\",3) ||\n\t     !strncmp(model,\"D70\",3)) {\n    width--;\n  } else if (!strcmp(model,\"D90\")) {\n    width -= 42;\n  } else if (!strcmp(model,\"D100\")) {\n    if (tiff_compress == 34713 && !nikon_is_compressed()) {\n      load_raw = &CLASS packed_load_raw;\n      load_flags |= 1;\n      raw_width = (width += 3) + 3;\n    }\n  } else if (!strcmp(model,\"D200\")) {\n    left_margin = 1;\n    width -= 4;\n    filters = 0x94949494;\n  } else if (!strncmp(model,\"D2H\",3)) {\n    left_margin = 6;\n    width -= 14;\n  } else if (!strncmp(model,\"D2X\",3)) {\n    if (width == 3264) width -= 32;\n    else width -= 8;\n  } else if (!strncmp(model,\"D300\",4)) {\n    width -= 32;\n  } else if (!strncmp(model,\"COOLPIX P\",9)) {\n    load_flags = 24;\n    filters = 0x94949494;\n    if (model[9] == '7' && iso_speed >= 400)\n      black = 255;\n  } else if (!strncmp(model,\"1 \",2)) {\n    height -= 2;\n  } else if (fsize == 1581060) {\n    height = 963;\n    width = 1287;\n    raw_width = 1632;\n    maximum = 0x3f4;\n    colors = 4;\n    filters = 0x1e1e1e1e;\n    simple_coeff(3);\n    pre_mul[0] = 1.2085;\n    pre_mul[1] = 1.0943;\n    pre_mul[3] = 1.1103;\n    goto e900;\n  } else if (fsize == 2465792) {\n    height = 1203;\n    width  = 1616;\n    raw_width = 2048;\n    colors = 4;\n    filters = 0x4b4b4b4b;\n    adobe_coeff (\"NIKON\",\"E950\");\ne900:\n    tiff_bps = 10;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 6;\n  } else if (fsize == 4771840) {\n    height = 1540;\n    width  = 2064;\n    colors = 4;\n    filters = 0xe1e1e1e1;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 6;\n    if (!timestamp && nikon_e995())\n      strcpy (model, \"E995\");\n    if (strcmp(model,\"E995\")) {\n      filters = 0xb4b4b4b4;\n      simple_coeff(3);\n      pre_mul[0] = 1.196;\n      pre_mul[1] = 1.246;\n      pre_mul[2] = 1.018;\n    }\n  } else if (!strcmp(model,\"E2100\")) {\n    if (!timestamp && !nikon_e2100()) goto cp_e2500;\n    height = 1206;\n    width  = 1616;\n    load_flags = 30;\n  } else if (!strcmp(model,\"E2500\")) {\ncp_e2500:\n    strcpy (model, \"E2500\");\n    height = 1204;\n    width  = 1616;\n    colors = 4;\n    filters = 0x4b4b4b4b;\n  } else if (fsize == 4775936) {\n    height = 1542;\n    width  = 2064;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 30;\n    if (!timestamp) nikon_3700();\n    if (model[0] == 'E' && atoi(model+1) < 3700)\n      filters = 0x49494949;\n    if (!strcmp(model,\"Optio 33WR\")) {\n      flip = 1;\n      filters = 0x16161616;\n    }\n    if (make[0] == 'O') {\n      i = find_green (12, 32, 1188864, 3576832);\n      c = find_green (12, 32, 2383920, 2387016);\n      if (abs(i) < abs(c)) {\n\tSWAP(i,c);\n\tload_flags = 24;\n      }\n      if (i < 0) filters = 0x61616161;\n    }\n  } else if (fsize == 5869568) {\n    height = 1710;\n    width  = 2288;\n    filters = 0x16161616;\n    if (!timestamp && minolta_z2()) {\n      strcpy (make, \"Minolta\");\n      strcpy (model,\"DiMAGE Z2\");\n    }\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 6 + 24*(make[0] == 'M');\n  } else if (!strcmp(model,\"E4500\")) {\n    height = 1708;\n    width  = 2288;\n    colors = 4;\n    filters = 0xb4b4b4b4;\n  } else if (fsize == 7438336) {\n    height = 1924;\n    width  = 2576;\n    colors = 4;\n    filters = 0xb4b4b4b4;\n  } else if (fsize == 8998912) {\n    height = 2118;\n    width  = 2832;\n    maximum = 0xf83;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 30;\n  } else if (!strcmp(model,\"FinePix S5100\") ||\n\t     !strcmp(model,\"FinePix S5500\")) {\n    height -= top_margin = 6;\n  } else if (!strcmp(make,\"FUJIFILM\")) {\n    if (!strcmp(model+7,\"S2Pro\")) {\n      strcpy (model+7,\" S2Pro\");\n      height = 2144;\n      width  = 2880;\n      flip = 6;\n    } else if (load_raw != &CLASS packed_load_raw)\n      maximum = (is_raw == 2 && shot_select) ? 0x2f00 : 0x3e00;\n    top_margin = (raw_height - height) >> 2 << 1;\n    left_margin = (raw_width - width ) >> 2 << 1;\n    if (width == 3328) {\n      width = 3262;\n      left_margin = 34;\n    }\n    if (!strcmp(model,\"X10\"))\n      filters = 0x16161616;\n    if (fuji_layout) raw_width *= is_raw;\n    if (load_raw == &CLASS fuji_load_raw) {\n      fuji_width = width >> !fuji_layout;\n      width = (height >> fuji_layout) + fuji_width;\n      raw_height = height;\n      height = width - 1;\n      if (~fuji_width & 1) filters = 0x49494949;\n    }\n  } else if (!strcmp(model,\"RD175\")) {\n    height = 986;\n    width = 1534;\n    data_offset = 513;\n    filters = 0x61616161;\n    load_raw = &CLASS minolta_rd175_load_raw;\n  } else if (!strcmp(model,\"KD-400Z\")) {\n    height = 1712;\n    width  = 2312;\n    raw_width = 2336;\n    goto konica_400z;\n  } else if (!strcmp(model,\"KD-510Z\")) {\n    goto konica_510z;\n  } else if (!strcasecmp(make,\"MINOLTA\")) {\n    load_raw = &CLASS unpacked_load_raw;\n    maximum = 0xfff;\n    if (!strncmp(model,\"DiMAGE A\",8)) {\n      if (!strcmp(model,\"DiMAGE A200\"))\n\tfilters = 0x49494949;\n      tiff_bps = 12;\n      load_raw = &CLASS packed_load_raw;\n    } else if (!strncmp(model,\"ALPHA\",5) ||\n\t       !strncmp(model,\"DYNAX\",5) ||\n\t       !strncmp(model,\"MAXXUM\",6)) {\n      sprintf (model+20, \"DYNAX %-10s\", model+6+(model[0]=='M'));\n      adobe_coeff (make, model+20);\n      load_raw = &CLASS packed_load_raw;\n    } else if (!strncmp(model,\"DiMAGE G\",8)) {\n      if (model[8] == '4') {\n\theight = 1716;\n\twidth  = 2304;\n      } else if (model[8] == '5') {\nkonica_510z:\n\theight = 1956;\n\twidth  = 2607;\n\traw_width = 2624;\n      } else if (model[8] == '6') {\n\theight = 2136;\n\twidth  = 2848;\n      }\n      data_offset += 14;\n      filters = 0x61616161;\nkonica_400z:\n      load_raw = &CLASS unpacked_load_raw;\n      maximum = 0x3df;\n      order = 0x4d4d;\n    }\n  } else if (!strcmp(model,\"*ist D\")) {\n    data_error = -1;\n  } else if (!strcmp(model,\"*ist DS\")) {\n    height -= 2;\n  } else if (!strcmp(model,\"Optio S\")) {\n    if (fsize == 3178560) {\n      height = 1540;\n      width  = 2064;\n      load_raw = &CLASS eight_bit_load_raw;\n      cam_mul[0] *= 4;\n      cam_mul[2] *= 4;\n    } else {\n      height = 1544;\n      width  = 2068;\n      raw_width = 3136;\n      load_raw = &CLASS packed_load_raw;\n      maximum = 0xf7c;\n    }\n  } else if (fsize == 6114240) {\n    height = 1737;\n    width  = 2324;\n    raw_width = 3520;\n    load_raw = &CLASS packed_load_raw;\n    maximum = 0xf7a;\n  } else if (!strcmp(model,\"Optio 750Z\")) {\n    height = 2302;\n    width  = 3072;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 30;\n  } else if (!strcmp(model,\"DC-833m\")) {\n    height = 2448;\n    width  = 3264;\n    order = 0x4949;\n    filters = 0x61616161;\n    load_raw = &CLASS unpacked_load_raw;\n    maximum = 0xfc00;\n  } else if (!strncmp(model,\"S85\",3)) {\n    height = 2448;\n    width  = 3264;\n    raw_width = fsize\/height\/2;\n    order = 0x4d4d;\n    load_raw = &CLASS unpacked_load_raw;\n  } else if (!strncmp(model,\"NX1\",3)) {\n    height -= top_margin = 8;\n    width -= 2 * (left_margin = 8);\n    load_flags = 32;\n  } else if (!strcmp(model,\"NX200\")) {\n    order = 0x4949;\n    height = 3662;\n    width  = 5528;\n    top_margin = 2;\n    left_margin = 46;\n  } else if (!strcmp(model,\"EX1\")) {\n    order = 0x4949;\n    height -= 20;\n    top_margin = 2;\n    if ((width -= 6) > 3682) {\n      height -= 10;\n      width  -= 46;\n      top_margin = 8;\n    }\n  } else if (!strcmp(model,\"WB2000\")) {\n    order = 0x4949;\n    height -= 3;\n    top_margin = 2;\n    if ((width -= 10) > 3718) {\n      height -= 28;\n      width  -= 56;\n      top_margin = 8;\n    }\n  } else if (fsize == 20487168) {\n    height = 2808;\n    width  = 3648;\n    goto wb550;\n  } else if (fsize == 24000000) {\n    height = 3000;\n    width  = 4000;\nwb550:\n    strcpy (model, \"WB550\");\n    order = 0x4d4d;\n    load_raw = &CLASS unpacked_load_raw;\n    load_flags = 6;\n    maximum = 0x3df;\n  } else if (!strcmp(model,\"STV680 VGA\")) {\n    height = 484;\n    width  = 644;\n    load_raw = &CLASS eight_bit_load_raw;\n    flip = 2;\n    filters = 0x16161616;\n    black = 16;\n  } else if (!strcmp(model,\"N95\")) {\n    height = raw_height - (top_margin = 2);\n  } else if (!strcmp(model,\"531C\")) {\n    height = 1200;\n    width  = 1600;\n    load_raw = &CLASS unpacked_load_raw;\n    filters = 0x49494949;\n  } else if (!strcmp(model,\"F-080C\")) {\n    height = 768;\n    width  = 1024;\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (!strcmp(model,\"F-145C\")) {\n    height = 1040;\n    width  = 1392;\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (!strcmp(model,\"F-201C\")) {\n    height = 1200;\n    width  = 1600;\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (!strcmp(model,\"F-510C\")) {\n    height = 1958;\n    width  = 2588;\n    load_raw = fsize < 7500000 ?\n\t&CLASS eight_bit_load_raw : &CLASS unpacked_load_raw;\n    data_offset = fsize - width*height*(fsize >> 22);\n    maximum = 0xfff0;\n  } else if (!strcmp(model,\"F-810C\")) {\n    height = 2469;\n    width  = 3272;\n    load_raw = &CLASS unpacked_load_raw;\n    maximum = 0xfff0;\n  } else if (!strcmp(model,\"XCD-SX910CR\")) {\n    height = 1024;\n    width  = 1375;\n    raw_width = 1376;\n    filters = 0x49494949;\n    maximum = 0x3ff;\n    load_raw = fsize < 2000000 ?\n\t&CLASS eight_bit_load_raw : &CLASS unpacked_load_raw;\n  } else if (!strcmp(model,\"2010\")) {\n    height = 1207;\n    width  = 1608;\n    order = 0x4949;\n    filters = 0x16161616;\n    data_offset = 3212;\n    maximum = 0x3ff;\n    load_raw = &CLASS unpacked_load_raw;\n  } else if (!strcmp(model,\"A782\")) {\n    height = 3000;\n    width  = 2208;\n    filters = 0x61616161;\n    load_raw = fsize < 10000000 ?\n\t&CLASS eight_bit_load_raw : &CLASS unpacked_load_raw;\n    maximum = 0xffc0;\n  } else if (!strcmp(model,\"3320AF\")) {\n    height = 1536;\n    raw_width = width = 2048;\n    filters = 0x61616161;\n    load_raw = &CLASS unpacked_load_raw;\n    maximum = 0x3ff;\n    fseek (ifp, 0x300000, SEEK_SET);\n    if ((order = guess_byte_order(0x10000)) == 0x4d4d) {\n      height -= (top_margin = 16);\n      width -= (left_margin = 28);\n      maximum = 0xf5c0;\n      strcpy (make, \"ISG\");\n      model[0] = 0;\n    }\n  } else if (!strcmp(make,\"Hasselblad\")) {\n    if (load_raw == &CLASS lossless_jpeg_load_raw)\n      load_raw = &CLASS hasselblad_load_raw;\n    if (raw_width == 7262) {\n      height = 5444;\n      width  = 7248;\n      top_margin  = 4;\n      left_margin = 7;\n      filters = 0x61616161;\n    } else if (raw_width == 7410) {\n      height = 5502;\n      width  = 7328;\n      top_margin  = 4;\n      left_margin = 41;\n      filters = 0x61616161;\n    } else if (raw_width == 9044) {\n      height = 6716;\n      width  = 8964;\n      top_margin  = 8;\n      left_margin = 40;\n      black += load_flags = 256;\n      maximum = 0x8101;\n    } else if (raw_width == 4090) {\n      strcpy (model, \"V96C\");\n      height -= (top_margin = 6);\n      width -= (left_margin = 3) + 7;\n      filters = 0x61616161;\n    }\n  } else if (!strcmp(make,\"Sinar\")) {\n    if (!memcmp(head,\"8BPS\",4)) {\n      fseek (ifp, 14, SEEK_SET);\n      height = get4();\n      width  = get4();\n      filters = 0x61616161;\n      data_offset = 68;\n    }\n    if (!load_raw) load_raw = &CLASS unpacked_load_raw;\n    maximum = 0x3fff;\n  } else if (!strcmp(make,\"Leaf\")) {\n    maximum = 0x3fff;\n    fseek (ifp, data_offset, SEEK_SET);\n    if (ljpeg_start (&jh, 1) && jh.bits == 15)\n      maximum = 0x1fff;\n    if (tiff_samples > 1) filters = 0;\n    if (tiff_samples > 1 || tile_length < raw_height) {\n      load_raw = &CLASS leaf_hdr_load_raw;\n      raw_width = tile_width;\n    }\n    if ((width | height) == 2048) {\n      if (tiff_samples == 1) {\n\tfilters = 1;\n\tstrcpy (cdesc, \"RBTG\");\n\tstrcpy (model, \"CatchLight\");\n\ttop_margin =  8; left_margin = 18; height = 2032; width = 2016;\n      } else {\n\tstrcpy (model, \"DCB2\");\n\ttop_margin = 10; left_margin = 16; height = 2028; width = 2022;\n      }\n    } else if (width+height == 3144+2060) {\n      if (!model[0]) strcpy (model, \"Cantare\");\n      if (width > height) {\n\t top_margin = 6; left_margin = 32; height = 2048;  width = 3072;\n\tfilters = 0x61616161;\n      } else {\n\tleft_margin = 6;  top_margin = 32;  width = 2048; height = 3072;\n\tfilters = 0x16161616;\n      }\n      if (!cam_mul[0] || model[0] == 'V') filters = 0;\n      else is_raw = tiff_samples;\n    } else if (width == 2116) {\n      strcpy (model, \"Valeo 6\");\n      height -= 2 * (top_margin = 30);\n      width -= 2 * (left_margin = 55);\n      filters = 0x49494949;\n    } else if (width == 3171) {\n      strcpy (model, \"Valeo 6\");\n      height -= 2 * (top_margin = 24);\n      width -= 2 * (left_margin = 24);\n      filters = 0x16161616;\n    }\n  } else if (!strcmp(make,\"LEICA\") || !strcmp(make,\"Panasonic\")) {\n    if ((flen - data_offset) \/ (raw_width*8\/7) == raw_height)\n      load_raw = &CLASS panasonic_load_raw;\n    if (!load_raw) {\n      load_raw = &CLASS unpacked_load_raw;\n      load_flags = 4;\n    }\n    zero_is_bad = 1;\n    if ((height += 12) > raw_height) height = raw_height;\n    for (i=0; i < (int) sizeof pana \/ (int) sizeof *pana; i++)\n      if (raw_width == pana[i][0] && raw_height == pana[i][1]) {\n\tleft_margin = pana[i][2];\n\t top_margin = pana[i][3];\n\t     width += pana[i][4];\n\t    height += pana[i][5];\n      }\n    filters = 0x01010101 * (uchar) \"\\x94\\x61\\x49\\x16\"\n\t[((filters-1) ^ (left_margin & 1) ^ (top_margin << 1)) & 3];\n  } else if (!strcmp(model,\"C770UZ\")) {\n    height = 1718;\n    width  = 2304;\n    filters = 0x16161616;\n    load_raw = &CLASS packed_load_raw;\n    load_flags = 30;\n  } else if (!strcmp(make,\"OLYMPUS\")) {\n    height += height & 1;\n    filters = exif_cfa;\n    if (width == 4100) width -= 4;\n    if (width == 4080) width -= 24;\n    if (load_raw == &CLASS unpacked_load_raw)\n      load_flags = 4;\n    tiff_bps = 12;\n    if (!strcmp(model,\"E-300\") ||\n\t!strcmp(model,\"E-500\")) {\n      width -= 20;\n      if (load_raw == &CLASS unpacked_load_raw) {\n\tmaximum = 0xfc3;\n\tmemset (cblack, 0, sizeof cblack);\n      }\n    } else if (!strcmp(model,\"E-330\")) {\n      width -= 30;\n      if (load_raw == &CLASS unpacked_load_raw)\n\tmaximum = 0xf79;\n    } else if (!strcmp(model,\"SP550UZ\")) {\n      thumb_length = flen - (thumb_offset = 0xa39800);\n      thumb_height = 480;\n      thumb_width  = 640;\n    }\n  } else if (!strcmp(model,\"N Digital\")) {\n    height = 2047;\n    width  = 3072;\n    filters = 0x61616161;\n    data_offset = 0x1a00;\n    load_raw = &CLASS packed_load_raw;\n  } else if (!strcmp(model,\"DSC-F828\")) {\n    width = 3288;\n    left_margin = 5;\n    data_offset = 862144;\n    load_raw = &CLASS sony_load_raw;\n    filters = 0x9c9c9c9c;\n    colors = 4;\n    strcpy (cdesc, \"RGBE\");\n  } else if (!strcmp(model,\"DSC-V3\")) {\n    width = 3109;\n    left_margin = 59;\n    data_offset = 787392;\n    load_raw = &CLASS sony_load_raw;\n  } else if (!strcmp(make,\"SONY\") && raw_width == 3984) {\n    adobe_coeff (\"SONY\",\"DSC-R1\");\n    width = 3925;\n    order = 0x4d4d;\n  } else if (!strcmp(make,\"SONY\") && raw_width == 6048) {\n    width -= 24;\n  } else if (!strcmp(model,\"DSLR-A100\")) {\n    if (width == 3880) {\n      height--;\n      width = ++raw_width;\n    } else {\n      order = 0x4d4d;\n      load_flags = 2;\n    }\n    filters = 0x61616161;\n  } else if (!strcmp(model,\"DSLR-A350\")) {\n    height -= 4;\n  } else if (!strcmp(model,\"NEX-5N\")) {\n    width -= 24;\n  } else if (!strcmp(model,\"PIXL\")) {\n    height -= top_margin = 4;\n    width -= left_margin = 32;\n    gamma_curve (0, 7, 1, 255);\n  } else if (!strcmp(model,\"C603v\")) {\n    height = 480;\n    width  = 640;\n    if (fsize < 614400 || find_green (16, 16, 3840, 5120) < 25) goto c603v;\n    strcpy (model,\"KAI-0340\");\n    height -= 3;\n    data_offset = 3840;\n    order = 0x4949;\n    load_raw = &CLASS unpacked_load_raw;\n  } else if (!strcmp(model,\"C603y\")) {\n    height = 2134;\n    width  = 2848;\nc603v:\n    filters = 0;\n    load_raw = &CLASS kodak_yrgb_load_raw;\n    gamma_curve (0, 3.875, 1, 255);\n  } else if (!strcmp(model,\"C603\")) {\n    raw_height = height = 2152;\n    raw_width  = width  = 2864;\n    goto c603;\n  } else if (!strcmp(model,\"C330\")) {\n    height = 1744;\n    width  = 2336;\n    raw_height = 1779;\n    raw_width  = 2338;\n    top_margin = 33;\n    left_margin = 1;\nc603:\n    order = 0x4949;\n    if ((data_offset = fsize - raw_height*raw_width)) {\n      fseek (ifp, 168, SEEK_SET);\n      read_shorts (curve, 256);\n    } else gamma_curve (0, 3.875, 1, 255);\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (!strncasecmp(model,\"EasyShare\",9)) {\n    data_offset = data_offset < 0x15000 ? 0x15000 : 0x17000;\n    load_raw = &CLASS packed_load_raw;\n  } else if (!strcasecmp(make,\"KODAK\")) {\n    if (filters == UINT_MAX) filters = 0x61616161;\n    if (!strncmp(model,\"NC2000\",6)) {\n      width -= 4;\n      left_margin = 2;\n    } else if (!strcmp(model,\"EOSDCS3B\")) {\n      width -= 4;\n      left_margin = 2;\n    } else if (!strcmp(model,\"EOSDCS1\")) {\n      width -= 4;\n      left_margin = 2;\n    } else if (!strcmp(model,\"DCS420\")) {\n      width -= 4;\n      left_margin = 2;\n    } else if (!strncmp(model,\"DCS460 \",7)) {\n      model[6] = 0;\n      width -= 4;\n      left_margin = 2;\n    } else if (!strcmp(model,\"DCS460A\")) {\n      width -= 4;\n      left_margin = 2;\n      colors = 1;\n      filters = 0;\n    } else if (!strcmp(model,\"DCS660M\")) {\n      black = 214;\n      colors = 1;\n      filters = 0;\n    } else if (!strcmp(model,\"DCS760M\")) {\n      colors = 1;\n      filters = 0;\n    }\n    if (!strcmp(model+4,\"20X\"))\n      strcpy (cdesc, \"MYCY\");\n    if (strstr(model,\"DC25\")) {\n      strcpy (model, \"DC25\");\n      data_offset = 15424;\n    }\n    if (!strncmp(model,\"DC2\",3)) {\n      height = 242;\n      if (flen < 100000) {\n\traw_width = 256; width = 249;\n\tpixel_aspect = (4.0*height) \/ (3.0*width);\n      } else {\n\traw_width = 512; width = 501;\n\tpixel_aspect = (493.0*height) \/ (373.0*width);\n      }\n      data_offset += raw_width + 1;\n      colors = 4;\n      filters = 0x8d8d8d8d;\n      simple_coeff(1);\n      pre_mul[1] = 1.179;\n      pre_mul[2] = 1.209;\n      pre_mul[3] = 1.036;\n      load_raw = &CLASS eight_bit_load_raw;\n    } else if (!strcmp(model,\"40\")) {\n      strcpy (model, \"DC40\");\n      height = 512;\n      width  = 768;\n      data_offset = 1152;\n      load_raw = &CLASS kodak_radc_load_raw;\n    } else if (strstr(model,\"DC50\")) {\n      strcpy (model, \"DC50\");\n      height = 512;\n      width  = 768;\n      data_offset = 19712;\n      load_raw = &CLASS kodak_radc_load_raw;\n    } else if (strstr(model,\"DC120\")) {\n      strcpy (model, \"DC120\");\n      height = 976;\n      width  = 848;\n      pixel_aspect = height\/0.75\/width;\n      load_raw = tiff_compress == 7 ?\n\t&CLASS kodak_jpeg_load_raw : &CLASS kodak_dc120_load_raw;\n    } else if (!strcmp(model,\"DCS200\")) {\n      thumb_height = 128;\n      thumb_width  = 192;\n      thumb_offset = 6144;\n      thumb_misc   = 360;\n      write_thumb = &CLASS layer_thumb;\n      height = 1024;\n      width  = 1536;\n      data_offset = 79872;\n      load_raw = &CLASS eight_bit_load_raw;\n      black = 17;\n    }\n  } else if (!strcmp(model,\"Fotoman Pixtura\")) {\n    height = 512;\n    width  = 768;\n    data_offset = 3632;\n    load_raw = &CLASS kodak_radc_load_raw;\n    filters = 0x61616161;\n    simple_coeff(2);\n  } else if (!strncmp(model,\"QuickTake\",9)) {\n    if (head[5]) strcpy (model+10, \"200\");\n    fseek (ifp, 544, SEEK_SET);\n    height = get2();\n    width  = get2();\n    data_offset = (get4(),get2()) == 30 ? 738:736;\n    if (height > width) {\n      SWAP(height,width);\n      fseek (ifp, data_offset-6, SEEK_SET);\n      flip = ~get2() & 3 ? 5:6;\n    }\n    filters = 0x61616161;\n  } else if (!strcmp(make,\"Rollei\") && !load_raw) {\n    switch (raw_width) {\n      case 1316:\n\theight = 1030;\n\twidth  = 1300;\n\ttop_margin  = 1;\n\tleft_margin = 6;\n\tbreak;\n      case 2568:\n\theight = 1960;\n\twidth  = 2560;\n\ttop_margin  = 2;\n\tleft_margin = 8;\n    }\n    filters = 0x16161616;\n    load_raw = &CLASS rollei_load_raw;\n  } else if (!strcmp(model,\"PC-CAM 600\")) {\n    height = 768;\n    data_offset = width = 1024;\n    filters = 0x49494949;\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (!strcmp(model,\"QV-2000UX\")) {\n    height = 1208;\n    width  = 1632;\n    data_offset = width * 2;\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (fsize == 3217760) {\n    height = 1546;\n    width  = 2070;\n    raw_width = 2080;\n    load_raw = &CLASS eight_bit_load_raw;\n  } else if (!strcmp(model,\"QV-4000\")) {\n    height = 1700;\n    width  = 2260;\n    load_raw = &CLASS unpacked_load_raw;\n    maximum = 0xffff;\n  } else if (!strcmp(model,\"QV-5700\")) {\n    height = 1924;\n    width  = 2576;\n    raw_width = 3232;\n    tiff_bps = 10;\n  } else if (!strcmp(model,\"QV-R41\")) {\n    height = 1720;\n    width  = 2312;\n    raw_width = 3520;\n    left_margin = 2;\n  } else if (!strcmp(model,\"QV-R51\")) {\n    height = 1926;\n    width  = 2580;\n    raw_width = 3904;\n  } else if (!strcmp(model,\"EX-S20\")) {\n    height = 1208;\n    width  = 1620;\n    raw_width = 2432;\n    flip = 3;\n  } else if (!strcmp(model,\"EX-S100\")) {\n    height = 1544;\n    width  = 2058;\n    raw_width = 3136;\n  } else if (!strcmp(model,\"EX-Z50\")) {\n    height = 1931;\n    width  = 2570;\n    raw_width = 3904;\n  } else if (!strcmp(model,\"EX-Z500\")) {\n    height = 1937;\n    width  = 2577;\n    raw_width = 3904;\n    filters = 0x16161616;\n  } else if (!strcmp(model,\"EX-Z55\")) {\n    height = 1960;\n    width  = 2570;\n    raw_width = 3904;\n  } else if (!strcmp(model,\"EX-Z60\")) {\n    height = 2145;\n    width  = 2833;\n    raw_width = 3584;\n    filters = 0x16161616;\n    tiff_bps = 10;\n  } else if (!strcmp(model,\"EX-Z75\")) {\n    height = 2321;\n    width  = 3089;\n    raw_width = 4672;\n    maximum = 0xfff;\n  } else if (!strcmp(model,\"EX-Z750\")) {\n    height = 2319;\n    width  = 3087;\n    raw_width = 4672;\n    maximum = 0xfff;\n  } else if (!strcmp(model,\"EX-Z850\")) {\n    height = 2468;\n    width  = 3279;\n    raw_width = 4928;\n    maximum = 0xfff;\n  } else if (fsize == 15499264) {\t\/* EX-Z1050 or EX-Z1080 *\/\n    height = 2752;\n    width  = 3672;\n    raw_width = 5632;\n  } else if (!strcmp(model,\"EX-P505\")) {\n    height = 1928;\n    width  = 2568;\n    raw_width = 3852;\n    maximum = 0xfff;\n  } else if (fsize == 9313536) {\t\/* EX-P600 or QV-R61 *\/\n    height = 2142;\n    width  = 2844;\n    raw_width = 4288;\n  } else if (!strcmp(model,\"EX-P700\")) {\n    height = 2318;\n    width  = 3082;\n    raw_width = 4672;\n  }\n  if (!model[0])\n    sprintf (model, \"%dx%d\", width, height);\n  if (filters == UINT_MAX) filters = 0x94949494;\n  if (raw_color) adobe_coeff (make, model);\n  if (load_raw == &CLASS kodak_radc_load_raw)\n    if (raw_color) adobe_coeff (\"Apple\",\"Quicktake\");\n  if (thumb_offset && !thumb_height) {\n    fseek (ifp, thumb_offset, SEEK_SET);\n    if (ljpeg_start (&jh, 1)) {\n      thumb_width  = jh.wide;\n      thumb_height = jh.high;\n    }\n  }\ndng_skip:\n  if (!tiff_bps) tiff_bps = 12;\n  if (!maximum) maximum = (1 << tiff_bps) - 1;\n  if (!load_raw || height < 22) is_raw = 0;\n#ifndef HAVE_LIBJASPER\n  if (load_raw == &CLASS redcine_load_raw) {\n    dcraw_message (DCRAW_ERROR,_(\"%s: You must link dcraw with %s!!\\n\"),\n\tifname_display, \"libjasper\");\n    is_raw = 0;\n  }\n#endif\n#ifndef HAVE_LIBJPEG\n  if (load_raw == &CLASS kodak_jpeg_load_raw) {\n    dcraw_message (DCRAW_ERROR,_(\"%s: You must link dcraw with %s!!\\n\"),\n\tifname_display, \"libjpeg\");\n    is_raw = 0;\n  }\n#endif\n  if (!cdesc[0])\n    strcpy (cdesc, colors == 3 ? \"RGBG\":\"GMCY\");\n  if (!raw_height) raw_height = height;\n  if (!raw_width ) raw_width  = width;\n  if (filters && colors == 3)\n    filters |= ((filters >> 2 & 0x22222222) |\n\t\t(filters << 2 & 0x88888888)) & filters << 1;\nnotraw:\n  if (flip == -1) flip = tiff_flip;\n  if (flip == -1) flip = 0;\n}","target":0,"code_token_length":19342,"total_token_length":19578,"max_tokens_setting":28000}
+{"idx":346036,"func":"receive(\n\tstruct recvbuf *rbufp\n\t)\n{\n\tregister struct peer *peer;\t\/* peer structure pointer *\/\n\tregister struct pkt *pkt;\t\/* receive packet pointer *\/\n\tu_char\thisversion;\t\t\/* packet version *\/\n\tu_char\thisleap;\t\t\/* packet leap indicator *\/\n\tu_char\thismode;\t\t\/* packet mode *\/\n\tu_char\thisstratum;\t\t\/* packet stratum *\/\n\tu_short\trestrict_mask;\t\t\/* restrict bits *\/\n\tconst char *hm_str;\t\t\/* hismode string *\/\n\tconst char *am_str;\t\t\/* association match string *\/\n\tint\tkissCode = NOKISS;\t\/* Kiss Code *\/\n\tint\thas_mac;\t\t\/* length of MAC field *\/\n\tint\tauthlen;\t\t\/* offset of MAC field *\/\n\tint\tis_authentic = 0;\t\/* cryptosum ok *\/\n\tint\tretcode = AM_NOMATCH;\t\/* match code *\/\n\tkeyid_t\tskeyid = 0;\t\t\/* key IDs *\/\n\tu_int32\topcode = 0;\t\t\/* extension field opcode *\/\n\tsockaddr_u *dstadr_sin;\t\t\/* active runway *\/\n\tstruct peer *peer2;\t\t\/* aux peer structure pointer *\/\n\tendpt\t*match_ep;\t\t\/* newpeer() local address *\/\n\tl_fp\tp_org;\t\t\t\/* origin timestamp *\/\n\tl_fp\tp_rec;\t\t\t\/* receive timestamp *\/\n\tl_fp\tp_xmt;\t\t\t\/* transmit timestamp *\/\n#ifdef AUTOKEY\n\tchar\thostname[NTP_MAXSTRLEN + 1];\n\tchar\t*groupname = NULL;\n\tstruct autokey *ap;\t\t\/* autokey structure pointer *\/\n\tint\trval;\t\t\t\/* cookie snatcher *\/\n\tkeyid_t\tpkeyid = 0, tkeyid = 0;\t\/* key IDs *\/\n#endif\t\/* AUTOKEY *\/\n#ifdef HAVE_NTP_SIGND\n\tstatic unsigned char zero_key[16];\n#endif \/* HAVE_NTP_SIGND *\/\n\n\t\/*\n\t * Monitor the packet and get restrictions. Note that the packet\n\t * length for control and private mode packets must be checked\n\t * by the service routines. Some restrictions have to be handled\n\t * later in order to generate a kiss-o'-death packet.\n\t *\/\n\t\/*\n\t * Bogus port check is before anything, since it probably\n\t * reveals a clogging attack.\n\t *\/\n\tsys_received++;\n\tif (0 == SRCPORT(&rbufp->recv_srcadr)) {\n\t\tsys_badlength++;\n\t\treturn;\t\t\t\t\/* bogus port *\/\n\t}\n\trestrict_mask = restrictions(&rbufp->recv_srcadr);\n\tpkt = &rbufp->recv_pkt;\n\tDPRINTF(2, (\"receive: at %ld %s<-%s flags %x restrict %03x org %#010x.%08x xmt %#010x.%08x\\n\",\n\t\t    current_time, stoa(&rbufp->dstadr->sin),\n\t\t    stoa(&rbufp->recv_srcadr), rbufp->dstadr->flags,\n\t\t    restrict_mask, ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),\n\t\t    ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));\n\thisversion = PKT_VERSION(pkt->li_vn_mode);\n\thisleap = PKT_LEAP(pkt->li_vn_mode);\n\thismode = (int)PKT_MODE(pkt->li_vn_mode);\n\thisstratum = PKT_TO_STRATUM(pkt->stratum);\n\tif (restrict_mask & RES_IGNORE) {\n\t\tsys_restricted++;\n\t\treturn;\t\t\t\t\/* ignore everything *\/\n\t}\n\tif (hismode == MODE_PRIVATE) {\n\t\tif (!ntp_mode7 || (restrict_mask & RES_NOQUERY)) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* no query private *\/\n\t\t}\n\t\tprocess_private(rbufp, ((restrict_mask &\n\t\t    RES_NOMODIFY) == 0));\n\t\treturn;\n\t}\n\tif (hismode == MODE_CONTROL) {\n\t\tif (restrict_mask & RES_NOQUERY) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* no query control *\/\n\t\t}\n\t\tprocess_control(rbufp, restrict_mask);\n\t\treturn;\n\t}\n\tif (restrict_mask & RES_DONTSERVE) {\n\t\tsys_restricted++;\n\t\treturn;\t\t\t\t\/* no time serve *\/\n\t}\n\n\t\/*\n\t * This is for testing. If restricted drop ten percent of\n\t * surviving packets.\n\t *\/\n\tif (restrict_mask & RES_FLAKE) {\n\t\tif ((double)ntp_random() \/ 0x7fffffff < .1) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* no flakeway *\/\n\t\t}\n\t}\n\n\t\/*\n\t * Version check must be after the query packets, since they\n\t * intentionally use an early version.\n\t *\/\n\tif (hisversion == NTP_VERSION) {\n\t\tsys_newversion++;\t\t\/* new version *\/\n\t} else if (   !(restrict_mask & RES_VERSION)\n\t\t   && hisversion >= NTP_OLDVERSION) {\n\t\tsys_oldversion++;\t\t\/* previous version *\/\n\t} else {\n\t\tsys_badlength++;\n\t\treturn;\t\t\t\t\/* old version *\/\n\t}\n\n\t\/*\n\t * Figure out his mode and validate the packet. This has some\n\t * legacy raunch that probably should be removed. In very early\n\t * NTP versions mode 0 was equivalent to what later versions\n\t * would interpret as client mode.\n\t *\/\n\tif (hismode == MODE_UNSPEC) {\n\t\tif (hisversion == NTP_OLDVERSION) {\n\t\t\thismode = MODE_CLIENT;\n\t\t} else {\n\t\t\tsys_badlength++;\n\t\t\treturn;                 \/* invalid mode *\/\n\t\t}\n\t}\n\n\t\/*\n\t * Parse the extension field if present. We figure out whether\n\t * an extension field is present by measuring the MAC size. If\n\t * the number of words following the packet header is 0, no MAC\n\t * is present and the packet is not authenticated. If 1, the\n\t * packet is a crypto-NAK; if 3, the packet is authenticated\n\t * with DES; if 5, the packet is authenticated with MD5; if 6,\n\t * the packet is authenticated with SHA. If 2 or * 4, the packet\n\t * is a runt and discarded forthwith. If greater than 6, an\n\t * extension field is present, so we subtract the length of the\n\t * field and go around again.\n\t *\/\n\tauthlen = LEN_PKT_NOMAC;\n\thas_mac = rbufp->recv_length - authlen;\n\twhile (has_mac > 0) {\n\t\tu_int32\tlen;\n#ifdef AUTOKEY\n\t\tu_int32\thostlen;\n\t\tstruct exten *ep;\n#endif \/*AUTOKEY *\/\n\n\t\tif (has_mac % 4 != 0 || has_mac < (int)MIN_MAC_LEN) {\n\t\t\tsys_badlength++;\n\t\t\treturn;\t\t\t\/* bad length *\/\n\t\t}\n\t\tif (has_mac <= (int)MAX_MAC_LEN) {\n\t\t\tskeyid = ntohl(((u_int32 *)pkt)[authlen \/ 4]);\n\t\t\tbreak;\n\n\t\t} else {\n\t\t\topcode = ntohl(((u_int32 *)pkt)[authlen \/ 4]);\n\t\t\tlen = opcode & 0xffff;\n\t\t\tif (   len % 4 != 0\n\t\t\t    || len < 4\n\t\t\t    || (int)len + authlen > rbufp->recv_length) {\n\t\t\t\tsys_badlength++;\n\t\t\t\treturn;\t\t\/* bad length *\/\n\t\t\t}\n#ifdef AUTOKEY\n\t\t\t\/*\n\t\t\t * Extract calling group name for later.  If\n\t\t\t * sys_groupname is non-NULL, there must be\n\t\t\t * a group name provided to elicit a response.\n\t\t\t *\/\n\t\t\tif (   (opcode & 0x3fff0000) == CRYPTO_ASSOC\n\t\t\t    && sys_groupname != NULL) {\n\t\t\t\tep = (struct exten *)&((u_int32 *)pkt)[authlen \/ 4];\n\t\t\t\thostlen = ntohl(ep->vallen);\n\t\t\t\tif (   hostlen >= sizeof(hostname)\n\t\t\t\t    || hostlen > len -\n\t\t\t\t\t\toffsetof(struct exten, pkt)) {\n\t\t\t\t\tsys_badlength++;\n\t\t\t\t\treturn;\t\t\/* bad length *\/\n\t\t\t\t}\n\t\t\t\tmemcpy(hostname, &ep->pkt, hostlen);\n\t\t\t\thostname[hostlen] = '\\0';\n\t\t\t\tgroupname = strchr(hostname, '@');\n\t\t\t\tif (groupname == NULL) {\n\t\t\t\t\tsys_declined++;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgroupname++;\n\t\t\t}\n#endif \/* AUTOKEY *\/\n\t\t\tauthlen += len;\n\t\t\thas_mac -= len;\n\t\t}\n\t}\n\n\t\/*\n\t * If has_mac is < 0 we had a malformed packet.\n\t *\/\n\tif (has_mac < 0) {\n\t\tsys_badlength++;\n\t\treturn;\t\t\/* bad length *\/\n\t}\n\n\t\/*\n\t * If authentication required, a MAC must be present.\n\t *\/\n\tif (restrict_mask & RES_DONTTRUST && has_mac == 0) {\n\t\tsys_restricted++;\n\t\treturn;\t\t\t\t\/* access denied *\/\n\t}\n\n\t\/*\n\t * Update the MRU list and finger the cloggers. It can be a\n\t * little expensive, so turn it off for production use.\n\t * RES_LIMITED and RES_KOD will be cleared in the returned\n\t * restrict_mask unless one or both actions are warranted.\n\t *\/\n\trestrict_mask = ntp_monitor(rbufp, restrict_mask);\n\tif (restrict_mask & RES_LIMITED) {\n\t\tsys_limitrejected++;\n\t\tif (   !(restrict_mask & RES_KOD)\n\t\t    || MODE_BROADCAST == hismode\n\t\t    || MODE_SERVER == hismode) {\n\t\t\tif (MODE_SERVER == hismode)\n\t\t\t\tDPRINTF(1, (\"Possibly self-induced rate limiting of MODE_SERVER from %s\\n\",\n\t\t\t\t\tstoa(&rbufp->recv_srcadr)));\n\t\t\treturn;\t\t\t\/* rate exceeded *\/\n\t\t}\n\t\tif (hismode == MODE_CLIENT)\n\t\t\tfast_xmit(rbufp, MODE_SERVER, skeyid,\n\t\t\t    restrict_mask);\n\t\telse\n\t\t\tfast_xmit(rbufp, MODE_ACTIVE, skeyid,\n\t\t\t    restrict_mask);\n\t\treturn;\t\t\t\t\/* rate exceeded *\/\n\t}\n\trestrict_mask &= ~RES_KOD;\n\n\t\/*\n\t * We have tossed out as many buggy packets as possible early in\n\t * the game to reduce the exposure to a clogging attack. Now we\n\t * have to burn some cycles to find the association and\n\t * authenticate the packet if required. Note that we burn only\n\t * digest cycles, again to reduce exposure. There may be no\n\t * matching association and that's okay.\n\t *\n\t * More on the autokey mambo. Normally the local interface is\n\t * found when the association was mobilized with respect to a\n\t * designated remote address. We assume packets arriving from\n\t * the remote address arrive via this interface and the local\n\t * address used to construct the autokey is the unicast address\n\t * of the interface. However, if the sender is a broadcaster,\n\t * the interface broadcast address is used instead.\n\t * Notwithstanding this technobabble, if the sender is a\n\t * multicaster, the broadcast address is null, so we use the\n\t * unicast address anyway. Don't ask.\n\t *\/\n\tpeer = findpeer(rbufp,  hismode, &retcode);\n\tdstadr_sin = &rbufp->dstadr->sin;\n\tNTOHL_FP(&pkt->org, &p_org);\n\tNTOHL_FP(&pkt->rec, &p_rec);\n\tNTOHL_FP(&pkt->xmt, &p_xmt);\n\thm_str = modetoa(hismode);\n\tam_str = amtoa(retcode);\n\n\t\/*\n\t * Authentication is conditioned by three switches:\n\t *\n\t * NOPEER  (RES_NOPEER) do not mobilize an association unless\n\t *         authenticated\n\t * NOTRUST (RES_DONTTRUST) do not allow access unless\n\t *         authenticated (implies NOPEER)\n\t * enable  (sys_authenticate) master NOPEER switch, by default\n\t *         on\n\t *\n\t * The NOPEER and NOTRUST can be specified on a per-client basis\n\t * using the restrict command. The enable switch if on implies\n\t * NOPEER for all clients. There are four outcomes:\n\t *\n\t * NONE    The packet has no MAC.\n\t * OK      the packet has a MAC and authentication succeeds\n\t * ERROR   the packet has a MAC and authentication fails\n\t * CRYPTO  crypto-NAK. The MAC has four octets only.\n\t *\n\t * Note: The AUTH(x, y) macro is used to filter outcomes. If x\n\t * is zero, acceptable outcomes of y are NONE and OK. If x is\n\t * one, the only acceptable outcome of y is OK.\n\t *\/\n\n\tif (has_mac == 0) {\n\t\trestrict_mask &= ~RES_MSSNTP;\n\t\tis_authentic = AUTH_NONE; \/* not required *\/\n\t\tDPRINTF(2, (\"receive: at %ld %s<-%s mode %d\/%s:%s len %d org %#010x.%08x xmt %#010x.%08x NOMAC\\n\",\n\t\t\t    current_time, stoa(dstadr_sin),\n\t\t\t    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,\n\t\t\t    authlen,\n\t\t\t    ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),\n\t\t\t    ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));\n\t} else if (has_mac == 4) {\n\t\trestrict_mask &= ~RES_MSSNTP;\n\t\tis_authentic = AUTH_CRYPTO; \/* crypto-NAK *\/\n\t\tDPRINTF(2, (\"receive: at %ld %s<-%s mode %d\/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x MAC4\\n\",\n\t\t\t    current_time, stoa(dstadr_sin),\n\t\t\t    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,\n\t\t\t    skeyid, authlen + has_mac, is_authentic,\n\t\t\t    ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),\n\t\t\t    ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));\n\n#ifdef HAVE_NTP_SIGND\n\t\t\/*\n\t\t * If the signature is 20 bytes long, the last 16 of\n\t\t * which are zero, then this is a Microsoft client\n\t\t * wanting AD-style authentication of the server's\n\t\t * reply.\n\t\t *\n\t\t * This is described in Microsoft's WSPP docs, in MS-SNTP:\n\t\t * http:\/\/msdn.microsoft.com\/en-us\/library\/cc212930.aspx\n\t\t *\/\n\t} else if (   has_mac == MAX_MD5_LEN\n\t\t   && (restrict_mask & RES_MSSNTP)\n\t\t   && (retcode == AM_FXMIT || retcode == AM_NEWPASS)\n\t\t   && (memcmp(zero_key, (char *)pkt + authlen + 4,\n\t\t\t      MAX_MD5_LEN - 4) == 0)) {\n\t\tis_authentic = AUTH_NONE;\n#endif \/* HAVE_NTP_SIGND *\/\n\n\t} else {\n\t\trestrict_mask &= ~RES_MSSNTP;\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * For autokey modes, generate the session key\n\t\t * and install in the key cache. Use the socket\n\t\t * broadcast or unicast address as appropriate.\n\t\t *\/\n\t\tif (crypto_flags && skeyid > NTP_MAXKEY) {\n\n\t\t\t\/*\n\t\t\t * More on the autokey dance (AKD). A cookie is\n\t\t\t * constructed from public and private values.\n\t\t\t * For broadcast packets, the cookie is public\n\t\t\t * (zero). For packets that match no\n\t\t\t * association, the cookie is hashed from the\n\t\t\t * addresses and private value. For server\n\t\t\t * packets, the cookie was previously obtained\n\t\t\t * from the server. For symmetric modes, the\n\t\t\t * cookie was previously constructed using an\n\t\t\t * agreement protocol; however, should PKI be\n\t\t\t * unavailable, we construct a fake agreement as\n\t\t\t * the EXOR of the peer and host cookies.\n\t\t\t *\n\t\t\t * hismode\tephemeral\tpersistent\n\t\t\t * =======================================\n\t\t\t * active\t0\t\tcookie#\n\t\t\t * passive\t0%\t\tcookie#\n\t\t\t * client\tsys cookie\t0%\n\t\t\t * server\t0%\t\tsys cookie\n\t\t\t * broadcast\t0\t\t0\n\t\t\t *\n\t\t\t * # if unsync, 0\n\t\t\t * % can't happen\n\t\t\t *\/\n\t\t\tif (has_mac < (int)MAX_MD5_LEN) {\n\t\t\t\tsys_badauth++;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (hismode == MODE_BROADCAST) {\n\n\t\t\t\t\/*\n\t\t\t\t * For broadcaster, use the interface\n\t\t\t\t * broadcast address when available;\n\t\t\t\t * otherwise, use the unicast address\n\t\t\t\t * found when the association was\n\t\t\t\t * mobilized. However, if this is from\n\t\t\t\t * the wildcard interface, game over.\n\t\t\t\t *\/\n\t\t\t\tif (   crypto_flags\n\t\t\t\t    && rbufp->dstadr ==\n\t\t\t\t       ANY_INTERFACE_CHOOSE(&rbufp->recv_srcadr)) {\n\t\t\t\t\tsys_restricted++;\n\t\t\t\t\treturn;\t     \/* no wildcard *\/\n\t\t\t\t}\n\t\t\t\tpkeyid = 0;\n\t\t\t\tif (!SOCK_UNSPEC(&rbufp->dstadr->bcast))\n\t\t\t\t\tdstadr_sin =\n\t\t\t\t\t    &rbufp->dstadr->bcast;\n\t\t\t} else if (peer == NULL) {\n\t\t\t\tpkeyid = session_key(\n\t\t\t\t    &rbufp->recv_srcadr, dstadr_sin, 0,\n\t\t\t\t    sys_private, 0);\n\t\t\t} else {\n\t\t\t\tpkeyid = peer->pcookie;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * The session key includes both the public\n\t\t\t * values and cookie. In case of an extension\n\t\t\t * field, the cookie used for authentication\n\t\t\t * purposes is zero. Note the hash is saved for\n\t\t\t * use later in the autokey mambo.\n\t\t\t *\/\n\t\t\tif (authlen > (int)LEN_PKT_NOMAC && pkeyid != 0) {\n\t\t\t\tsession_key(&rbufp->recv_srcadr,\n\t\t\t\t    dstadr_sin, skeyid, 0, 2);\n\t\t\t\ttkeyid = session_key(\n\t\t\t\t    &rbufp->recv_srcadr, dstadr_sin,\n\t\t\t\t    skeyid, pkeyid, 0);\n\t\t\t} else {\n\t\t\t\ttkeyid = session_key(\n\t\t\t\t    &rbufp->recv_srcadr, dstadr_sin,\n\t\t\t\t    skeyid, pkeyid, 2);\n\t\t\t}\n\n\t\t}\n#endif\t\/* AUTOKEY *\/\n\n\t\t\/*\n\t\t * Compute the cryptosum. Note a clogging attack may\n\t\t * succeed in bloating the key cache. If an autokey,\n\t\t * purge it immediately, since we won't be needing it\n\t\t * again. If the packet is authentic, it can mobilize an\n\t\t * association. Note that there is no key zero.\n\t\t *\/\n\t\tif (!authdecrypt(skeyid, (u_int32 *)pkt, authlen,\n\t\t    has_mac))\n\t\t\tis_authentic = AUTH_ERROR;\n\t\telse\n\t\t\tis_authentic = AUTH_OK;\n#ifdef AUTOKEY\n\t\tif (crypto_flags && skeyid > NTP_MAXKEY)\n\t\t\tauthtrust(skeyid, 0);\n#endif\t\/* AUTOKEY *\/\n\t\tDPRINTF(2, (\"receive: at %ld %s<-%s mode %d\/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x\\n\",\n\t\t\t    current_time, stoa(dstadr_sin),\n\t\t\t    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,\n\t\t\t    skeyid, authlen + has_mac, is_authentic,\n\t\t\t    ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),\n\t\t\t    ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));\n\t}\n\n\t\/*\n\t * The association matching rules are implemented by a set of\n\t * routines and an association table. A packet matching an\n\t * association is processed by the peer process for that\n\t * association. If there are no errors, an ephemeral association\n\t * is mobilized: a broadcast packet mobilizes a broadcast client\n\t * aassociation; a manycast server packet mobilizes a manycast\n\t * client association; a symmetric active packet mobilizes a\n\t * symmetric passive association.\n\t *\/\n\tswitch (retcode) {\n\n\t\/*\n\t * This is a client mode packet not matching any association. If\n\t * an ordinary client, simply toss a server mode packet back\n\t * over the fence. If a manycast client, we have to work a\n\t * little harder.\n\t *\/\n\tcase AM_FXMIT:\n\n\t\t\/*\n\t\t * If authentication OK, send a server reply; otherwise,\n\t\t * send a crypto-NAK.\n\t\t *\/\n\t\tif (!(rbufp->dstadr->flags & INT_MCASTOPEN)) {\n\t\t\tif (AUTH(restrict_mask & RES_DONTTRUST,\n\t\t\t   is_authentic)) {\n\t\t\t\tfast_xmit(rbufp, MODE_SERVER, skeyid,\n\t\t\t\t    restrict_mask);\n\t\t\t} else if (is_authentic == AUTH_ERROR) {\n\t\t\t\tfast_xmit(rbufp, MODE_SERVER, 0,\n\t\t\t\t    restrict_mask);\n\t\t\t\tsys_badauth++;\n\t\t\t} else {\n\t\t\t\tsys_restricted++;\n\t\t\t}\n\t\t\treturn;\t\t\t\/* hooray *\/\n\t\t}\n\n\t\t\/*\n\t\t * This must be manycast. Do not respond if not\n\t\t * configured as a manycast server.\n\t\t *\/\n\t\tif (!sys_manycastserver) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* not enabled *\/\n\t\t}\n\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * Do not respond if not the same group.\n\t\t *\/\n\t\tif (group_test(groupname, NULL)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\n\t\t}\n#endif \/* AUTOKEY *\/\n\n\t\t\/*\n\t\t * Do not respond if we are not synchronized or our\n\t\t * stratum is greater than the manycaster or the\n\t\t * manycaster has already synchronized to us.\n\t\t *\/\n\t\tif (   sys_leap == LEAP_NOTINSYNC\n\t\t    || sys_stratum >= hisstratum\n\t\t    || (!sys_cohort && sys_stratum == hisstratum + 1)\n\t\t    || rbufp->dstadr->addr_refid == pkt->refid) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* no help *\/\n\t\t}\n\n\t\t\/*\n\t\t * Respond only if authentication succeeds. Don't do a\n\t\t * crypto-NAK, as that would not be useful.\n\t\t *\/\n\t\tif (AUTH(restrict_mask & RES_DONTTRUST, is_authentic))\n\t\t\tfast_xmit(rbufp, MODE_SERVER, skeyid,\n\t\t\t    restrict_mask);\n\t\treturn;\t\t\t\t\/* hooray *\/\n\n\t\/*\n\t * This is a server mode packet returned in response to a client\n\t * mode packet sent to a multicast group address (for\n\t * manycastclient) or to a unicast address (for pool). The\n\t * origin timestamp is a good nonce to reliably associate the\n\t * reply with what was sent. If there is no match, that's\n\t * curious and could be an intruder attempting to clog, so we\n\t * just ignore it.\n\t *\n\t * If the packet is authentic and the manycastclient or pool\n\t * association is found, we mobilize a client association and\n\t * copy pertinent variables from the manycastclient or pool\n\t * association to the new client association. If not, just\n\t * ignore the packet.\n\t *\n\t * There is an implosion hazard at the manycast client, since\n\t * the manycast servers send the server packet immediately. If\n\t * the guy is already here, don't fire up a duplicate.\n\t *\/\n\tcase AM_MANYCAST:\n\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * Do not respond if not the same group.\n\t\t *\/\n\t\tif (group_test(groupname, NULL)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\n\t\t}\n#endif \/* AUTOKEY *\/\n\t\tif ((peer2 = findmanycastpeer(rbufp)) == NULL) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* not enabled *\/\n\t\t}\n\t\tif (!AUTH(  (!(peer2->cast_flags & MDF_POOL)\n\t\t\t     && sys_authenticate)\n\t\t\t  || (restrict_mask & (RES_NOPEER |\n\t\t\t      RES_DONTTRUST)), is_authentic)) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* access denied *\/\n\t\t}\n\n\t\t\/*\n\t\t * Do not respond if unsynchronized or stratum is below\n\t\t * the floor or at or above the ceiling.\n\t\t *\/\n\t\tif (   hisleap == LEAP_NOTINSYNC\n\t\t    || hisstratum < sys_floor\n\t\t    || hisstratum >= sys_ceiling) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* no help *\/\n\t\t}\n\t\tpeer = newpeer(&rbufp->recv_srcadr, NULL, rbufp->dstadr,\n\t\t\t       MODE_CLIENT, hisversion, peer2->minpoll,\n\t\t\t       peer2->maxpoll, FLAG_PREEMPT |\n\t\t\t       (FLAG_IBURST & peer2->flags), MDF_UCAST |\n\t\t\t       MDF_UCLNT, 0, skeyid, sys_ident);\n\t\tif (NULL == peer) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* ignore duplicate  *\/\n\t\t}\n\n\t\t\/*\n\t\t * After each ephemeral pool association is spun,\n\t\t * accelerate the next poll for the pool solicitor so\n\t\t * the pool will fill promptly.\n\t\t *\/\n\t\tif (peer2->cast_flags & MDF_POOL)\n\t\t\tpeer2->nextdate = current_time + 1;\n\n\t\t\/*\n\t\t * Further processing of the solicitation response would\n\t\t * simply detect its origin timestamp as bogus for the\n\t\t * brand-new association (it matches the prototype\n\t\t * association) and tinker with peer->nextdate delaying\n\t\t * first sync.\n\t\t *\/\n\t\treturn;\t\t\/* solicitation response handled *\/\n\n\t\/*\n\t * This is the first packet received from a broadcast server. If\n\t * the packet is authentic and we are enabled as broadcast\n\t * client, mobilize a broadcast client association. We don't\n\t * kiss any frogs here.\n\t *\/\n\tcase AM_NEWBCL:\n\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * Do not respond if not the same group.\n\t\t *\/\n\t\tif (group_test(groupname, sys_ident)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\n\t\t}\n#endif \/* AUTOKEY *\/\n\t\tif (sys_bclient == 0) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* not enabled *\/\n\t\t}\n\t\tif (!AUTH(sys_authenticate | (restrict_mask &\n\t\t    (RES_NOPEER | RES_DONTTRUST)), is_authentic)) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* access denied *\/\n\t\t}\n\n\t\t\/*\n\t\t * Do not respond if unsynchronized or stratum is below\n\t\t * the floor or at or above the ceiling.\n\t\t *\/\n\t\tif (   hisleap == LEAP_NOTINSYNC\n\t\t    || hisstratum < sys_floor\n\t\t    || hisstratum >= sys_ceiling) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* no help *\/\n\t\t}\n\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * Do not respond if Autokey and the opcode is not a\n\t\t * CRYPTO_ASSOC response with association ID.\n\t\t *\/\n\t\tif (   crypto_flags && skeyid > NTP_MAXKEY\n\t\t    && (opcode & 0xffff0000) != (CRYPTO_ASSOC | CRYPTO_RESP)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* protocol error *\/\n\t\t}\n#endif\t\/* AUTOKEY *\/\n\n\t\t\/*\n\t\t * Broadcasts received via a multicast address may\n\t\t * arrive after a unicast volley has begun\n\t\t * with the same remote address.  newpeer() will not\n\t\t * find duplicate associations on other local endpoints\n\t\t * if a non-NULL endpoint is supplied.  multicastclient\n\t\t * ephemeral associations are unique across all local\n\t\t * endpoints.\n\t\t *\/\n\t\tif (!(INT_MCASTOPEN & rbufp->dstadr->flags))\n\t\t\tmatch_ep = rbufp->dstadr;\n\t\telse\n\t\t\tmatch_ep = NULL;\n\n\t\t\/*\n\t\t * Determine whether to execute the initial volley.\n\t\t *\/\n\t\tif (sys_bdelay != 0) {\n#ifdef AUTOKEY\n\t\t\t\/*\n\t\t\t * If a two-way exchange is not possible,\n\t\t\t * neither is Autokey.\n\t\t\t *\/\n\t\t\tif (crypto_flags && skeyid > NTP_MAXKEY) {\n\t\t\t\tsys_restricted++;\n\t\t\t\treturn;\t\t\/* no autokey *\/\n\t\t\t}\n#endif\t\/* AUTOKEY *\/\n\n\t\t\t\/*\n\t\t\t * Do not execute the volley. Start out in\n\t\t\t * broadcast client mode.\n\t\t\t *\/\n\t\t\tpeer = newpeer(&rbufp->recv_srcadr, NULL,\n\t\t\t    match_ep, MODE_BCLIENT, hisversion,\n\t\t\t    pkt->ppoll, pkt->ppoll, FLAG_PREEMPT,\n\t\t\t    MDF_BCLNT, 0, skeyid, sys_ident);\n\t\t\tif (NULL == peer) {\n\t\t\t\tsys_restricted++;\n\t\t\t\treturn;\t\t\/* ignore duplicate *\/\n\n\t\t\t} else {\n\t\t\t\tpeer->delay = sys_bdelay;\n\t\t\t\tpeer->bxmt = p_xmt;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * Execute the initial volley in order to calibrate the\n\t\t * propagation delay and run the Autokey protocol.\n\t\t *\n\t\t * Note that the minpoll is taken from the broadcast\n\t\t * packet, normally 6 (64 s) and that the poll interval\n\t\t * is fixed at this value.\n\t\t *\/\n\t\tpeer = newpeer(&rbufp->recv_srcadr, NULL, match_ep,\n\t\t    MODE_CLIENT, hisversion, pkt->ppoll, pkt->ppoll,\n\t\t    FLAG_BC_VOL | FLAG_IBURST | FLAG_PREEMPT, MDF_BCLNT,\n\t\t    0, skeyid, sys_ident);\n\t\tif (NULL == peer) {\n\t\t\tsys_restricted++;\n\t\t\treturn;\t\t\t\/* ignore duplicate *\/\n\t\t}\n\t\tpeer->bxmt = p_xmt;\n#ifdef AUTOKEY\n\t\tif (skeyid > NTP_MAXKEY)\n\t\t\tcrypto_recv(peer, rbufp);\n#endif\t\/* AUTOKEY *\/\n\n\t\treturn;\t\t\t\t\/* hooray *\/\n\n\t\/*\n\t * This is the first packet received from a symmetric active\n\t * peer. If the packet is authentic and the first he sent,\n\t * mobilize a passive association. If not, kiss the frog.\n\t *\/\n\tcase AM_NEWPASS:\n\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * Do not respond if not the same group.\n\t\t *\/\n\t\tif (group_test(groupname, sys_ident)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\n\t\t}\n#endif \/* AUTOKEY *\/\n\t\tif (!AUTH(sys_authenticate | (restrict_mask &\n\t\t    (RES_NOPEER | RES_DONTTRUST)), is_authentic)) {\n\n\t\t\t\/*\n\t\t\t * If authenticated but cannot mobilize an\n\t\t\t * association, send a symmetric passive\n\t\t\t * response without mobilizing an association.\n\t\t\t * This is for drat broken Windows clients. See\n\t\t\t * Microsoft KB 875424 for preferred workaround.\n\t\t\t *\/\n\t\t\tif (AUTH(restrict_mask & RES_DONTTRUST,\n\t\t\t    is_authentic)) {\n\t\t\t\tfast_xmit(rbufp, MODE_PASSIVE, skeyid,\n\t\t\t\t    restrict_mask);\n\t\t\t\treturn;\t\t\t\/* hooray *\/\n\t\t\t}\n\t\t\tif (is_authentic == AUTH_ERROR) {\n\t\t\t\tfast_xmit(rbufp, MODE_ACTIVE, 0,\n\t\t\t\t    restrict_mask);\n\t\t\t\tsys_restricted++;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\/* [Bug 2941]\n\t\t\t * If we got here, the packet isn't part of an\n\t\t\t * existing association, it isn't correctly\n\t\t\t * authenticated, and it didn't meet either of\n\t\t\t * the previous two special cases so we should\n\t\t\t * just drop it on the floor.  For example,\n\t\t\t * crypto-NAKs (is_authentic == AUTH_CRYPTO)\n\t\t\t * will make it this far.  This is just\n\t\t\t * debug-printed and not logged to avoid log\n\t\t\t * flooding.\n\t\t\t *\/\n\t\t\tDPRINTF(2, (\"receive: at %ld refusing to mobilize passive association\"\n\t\t\t\t    \" with unknown peer %s mode %d\/%s:%s keyid %08x len %d auth %d\\n\",\n\t\t\t\t    current_time, stoa(&rbufp->recv_srcadr),\n\t\t\t\t    hismode, hm_str, am_str, skeyid,\n\t\t\t\t    (authlen + has_mac), is_authentic));\n\t\t\tsys_declined++;\n\t\t\treturn;\n\t\t}\n\n\t\t\/*\n\t\t * Do not respond if synchronized and if stratum is\n\t\t * below the floor or at or above the ceiling. Note,\n\t\t * this allows an unsynchronized peer to synchronize to\n\t\t * us. It would be very strange if he did and then was\n\t\t * nipped, but that could only happen if we were\n\t\t * operating at the top end of the range.  It also means\n\t\t * we will spin an ephemeral association in response to\n\t\t * MODE_ACTIVE KoDs, which will time out eventually.\n\t\t *\/\n\t\tif (   hisleap != LEAP_NOTINSYNC\n\t\t    && (hisstratum < sys_floor || hisstratum >= sys_ceiling)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* no help *\/\n\t\t}\n\n\t\t\/*\n\t\t * The message is correctly authenticated and allowed.\n\t\t * Mobilize a symmetric passive association.\n\t\t *\/\n\t\tif ((peer = newpeer(&rbufp->recv_srcadr, NULL,\n\t\t    rbufp->dstadr, MODE_PASSIVE, hisversion, pkt->ppoll,\n\t\t    NTP_MAXDPOLL, 0, MDF_UCAST, 0, skeyid,\n\t\t    sys_ident)) == NULL) {\n\t\t\tsys_declined++;\n\t\t\treturn;\t\t\t\/* ignore duplicate *\/\n\t\t}\n\t\tbreak;\n\n\n\t\/*\n\t * Process regular packet. Nothing special.\n\t *\/\n\tcase AM_PROCPKT:\n\n#ifdef AUTOKEY\n\t\t\/*\n\t\t * Do not respond if not the same group.\n\t\t *\/\n\t\tif (group_test(groupname, peer->ident)) {\n\t\t\tsys_declined++;\n\t\t\treturn;\n\t\t}\n#endif \/* AUTOKEY *\/\n\n\t\tif (MODE_BROADCAST == hismode) {\n\t\t\tu_char poll;\n\t\t\tint bail = 0;\n\n\t\t\tDPRINTF(2, (\"receive: PROCPKT\/BROADCAST: prev pkt %ld seconds ago, ppoll: %d, %d secs\\n\",\n\t\t\t\t    (current_time - peer->timelastrec),\n\t\t\t\t    peer->ppoll, (1 << peer->ppoll)\n\t\t\t\t    ));\n\t\t\t\/* Things we can check:\n\t\t\t *\n\t\t\t * Did the poll interval change?\n\t\t\t * Is the poll interval in the packet in-range?\n\t\t\t * Did this packet arrive too soon?\n\t\t\t * Is the timestamp in this packet monotonic\n\t\t\t *  with respect to the previous packet?\n\t\t\t *\/\n\n\t\t\t\/* This is noteworthy, not error-worthy *\/\n\t\t\tif (pkt->ppoll != peer->ppoll) {\n\t\t\t\tmsyslog(LOG_INFO, \"receive: broadcast poll from %s changed from %ud to %ud\",\n\t\t\t\t\tstoa(&rbufp->recv_srcadr),\n\t\t\t\t\tpeer->ppoll, pkt->ppoll);\n\t\t\t}\n\n\t\t\tpoll = min(peer->maxpoll,\n\t\t\t\t   max(peer->minpoll, pkt->ppoll));\n\n\t\t\t\/* This is error-worthy *\/\n\t\t\tif (pkt->ppoll != poll) {\n\t\t\t\tmsyslog(LOG_INFO, \"receive: broadcast poll of %ud from %s is out-of-range (%d to %d)!\",\n\t\t\t\t\tpkt->ppoll, stoa(&rbufp->recv_srcadr),\n\t\t\t\t\tpeer->minpoll, peer->maxpoll);\n\t\t\t\t++bail;\n\t\t\t}\n\n\t\t\tif (  (current_time - peer->timelastrec)\n\t\t\t    < (1 << pkt->ppoll)) {\n\t\t\t\tmsyslog(LOG_INFO, \"receive: broadcast packet from %s arrived after %ld, not %d seconds!\",\n\t\t\t\t\tstoa(&rbufp->recv_srcadr),\n\t\t\t\t\t(current_time - peer->timelastrec),\n\t\t\t\t\t(1 << pkt->ppoll)\n\t\t\t\t\t);\n\t\t\t\t++bail;\n\t\t\t}\n\n\t\t\tif (L_ISGT(&peer->bxmt, &p_xmt)) {\n\t\t\t\tmsyslog(LOG_INFO, \"receive: broadcast packet from %s contains non-monotonic timestamp: %#010x.%08x -> %#010x.%08x\",\n\t\t\t\t\tstoa(&rbufp->recv_srcadr),\n\t\t\t\t\tpeer->bxmt.l_ui, peer->bxmt.l_uf,\n\t\t\t\t\tp_xmt.l_ui, p_xmt.l_uf\n\t\t\t\t\t);\n\t\t\t\t++bail;\n\t\t\t}\n\n\t\t\tpeer->bxmt = p_xmt;\n\n\t\t\tif (bail) {\n\t\t\t\tpeer->timelastrec = current_time;\n\t\t\t\tsys_declined++;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tbreak;\n\n\t\/*\n\t * A passive packet matches a passive association. This is\n\t * usually the result of reconfiguring a client on the fly. As\n\t * this association might be legitimate and this packet an\n\t * attempt to deny service, just ignore it.\n\t *\/\n\tcase AM_ERR:\n\t\tsys_declined++;\n\t\treturn;\n\n\t\/*\n\t * For everything else there is the bit bucket.\n\t *\/\n\tdefault:\n\t\tsys_declined++;\n\t\treturn;\n\t}\n\n#ifdef AUTOKEY\n\t\/*\n\t * If the association is configured for Autokey, the packet must\n\t * have a public key ID; if not, the packet must have a\n\t * symmetric key ID.\n\t *\/\n\tif (   is_authentic != AUTH_CRYPTO\n\t    && (   ((peer->flags & FLAG_SKEY) && skeyid <= NTP_MAXKEY)\n\t        || (!(peer->flags & FLAG_SKEY) && skeyid > NTP_MAXKEY))) {\n\t\tsys_badauth++;\n\t\treturn;\n\t}\n#endif\t\/* AUTOKEY *\/\n\tpeer->received++;\n\tpeer->flash &= ~PKT_TEST_MASK;\n\tif (peer->flags & FLAG_XBOGUS) {\n\t\tpeer->flags &= ~FLAG_XBOGUS;\n\t\tpeer->flash |= TEST3;\n\t}\n\n\t\/*\n\t * Next comes a rigorous schedule of timestamp checking. If the\n\t * transmit timestamp is zero, the server has not initialized in\n\t * interleaved modes or is horribly broken.\n\t *\/\n\tif (L_ISZERO(&p_xmt)) {\n\t\tpeer->flash |= TEST3;\t\t\t\/* unsynch *\/\n\n\t\/*\n\t * If the transmit timestamp duplicates a previous one, the\n\t * packet is a replay. This prevents the bad guys from replaying\n\t * the most recent packet, authenticated or not.\n\t *\/\n\t} else if (L_ISEQU(&peer->xmt, &p_xmt)) {\n\t\tpeer->flash |= TEST1;\t\t\t\/* duplicate *\/\n\t\tpeer->oldpkt++;\n\t\treturn;\n\n\t\/*\n\t * If this is a broadcast mode packet, skip further checking. If\n\t * an initial volley, bail out now and let the client do its\n\t * stuff. If the origin timestamp is nonzero, this is an\n\t * interleaved broadcast. so restart the protocol.\n\t *\/\n\t} else if (hismode == MODE_BROADCAST) {\n\t\tif (!L_ISZERO(&p_org) && !(peer->flags & FLAG_XB)) {\n\t\t\tpeer->flags |= FLAG_XB;\n\t\t\tpeer->aorg = p_xmt;\n\t\t\tpeer->borg = rbufp->recv_time;\n\t\t\treport_event(PEVNT_XLEAVE, peer, NULL);\n\t\t\treturn;\n\t\t}\n\n\t\/*\n\t * Basic mode checks:\n\t *\n\t * If there is no origin timestamp, it's an initial packet.\n\t *\n\t * Otherwise, check for bogus packet in basic mode.\n\t * If it is bogus, switch to interleaved mode and resynchronize,\n\t * but only after confirming the packet is not bogus in\n\t * symmetric interleaved mode.\n\t *\n\t * This could also mean somebody is forging packets claiming to\n\t * be from us, attempting to cause our server to KoD us.\n\t *\/\n\t} else if (peer->flip == 0) {\n\t\tif (0 < hisstratum && L_ISZERO(&p_org)) {\n\t\t\tL_CLR(&peer->aorg);\n\t\t} else if (!L_ISEQU(&p_org, &peer->aorg)) {\n\t\t\tpeer->bogusorg++;\n\t\t\tpeer->flash |= TEST2;\t\/* bogus *\/\n\t\t\tmsyslog(LOG_INFO,\n\t\t\t\t\"receive: Unexpected origin timestamp %#010x.%08x from %s xmt %#010x.%08x\",\n\t\t\t\tntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),\n\t\t\t\tntoa(&peer->srcadr),\n\t\t\t\tntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf));\n\t\t\tif (  !L_ISZERO(&peer->dst)\n\t\t\t    && L_ISEQU(&p_org, &peer->dst)) {\n\t\t\t\t\/* Might be the start of an interleave *\/\n\t\t\t\tpeer->flip = 1;\n\t\t\t\treport_event(PEVNT_XLEAVE, peer, NULL);\n\t\t\t}\n\t\t\treturn; \/* Bogus or possible interleave packet *\/\n\t\t} else {\n\t\t\tL_CLR(&peer->aorg);\n\t\t}\n\n\t\/*\n\t * Check for valid nonzero timestamp fields.\n\t *\/\n\t} else if (L_ISZERO(&p_org) || L_ISZERO(&p_rec) ||\n\t    L_ISZERO(&peer->dst)) {\n\t\tpeer->flash |= TEST3;\t\t\/* unsynch *\/\n\n\t\/*\n\t * Check for bogus packet in interleaved symmetric mode. This\n\t * can happen if a packet is lost, duplicated or crossed. If\n\t * found, flip and resynchronize.\n\t *\/\n\t} else if (   !L_ISZERO(&peer->dst)\n\t\t   && !L_ISEQU(&p_org, &peer->dst)) {\n\t\tpeer->bogusorg++;\n\t\tpeer->flags |= FLAG_XBOGUS;\n\t\tpeer->flash |= TEST2;\t\t\/* bogus *\/\n\t\treturn; \/* Bogus packet, we are done *\/\n\t}\n\n\t\/*\n\t * If this is a crypto_NAK, the server cannot authenticate a\n\t * client packet. The server might have just changed keys. Clear\n\t * the association and restart the protocol.\n\t *\/\n\tif (is_authentic == AUTH_CRYPTO) {\n\t\treport_event(PEVNT_AUTH, peer, \"crypto_NAK\");\n\t\tpeer->flash |= TEST5;\t\t\/* bad auth *\/\n\t\tpeer->badauth++;\n\t\tif (peer->flags & FLAG_PREEMPT) {\n\t\t\tunpeer(peer);\n\t\t\treturn;\n\t\t}\n#ifdef AUTOKEY\n\t\tif (peer->crypto)\n\t\t\tpeer_clear(peer, \"AUTH\");\n#endif\t\/* AUTOKEY *\/\n\t\treturn;\n\n\t\/*\n\t * If the digest fails or it's missing for authenticated\n\t * associations, the client cannot authenticate a server\n\t * reply to a client packet previously sent. The loopback check\n\t * is designed to avoid a bait-and-switch attack, which was\n\t * possible in past versions. If symmetric modes, return a\n\t * crypto-NAK. The peer should restart the protocol.\n\t *\/\n\t} else if (!AUTH(peer->keyid || has_mac ||\n\t\t\t (restrict_mask & RES_DONTTRUST), is_authentic)) {\n\t\treport_event(PEVNT_AUTH, peer, \"digest\");\n\t\tpeer->flash |= TEST5;\t\t\/* bad auth *\/\n\t\tpeer->badauth++;\n\t\tif (   has_mac\n\t\t    && (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE))\n\t\t\tfast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask);\n\t\tif (peer->flags & FLAG_PREEMPT) {\n\t\t\tunpeer(peer);\n\t\t\treturn;\n\t\t}\n#ifdef AUTOKEY\n\t\tif (peer->crypto)\n\t\t\tpeer_clear(peer, \"AUTH\");\n#endif\t\/* AUTOKEY *\/\n\t\treturn;\n\t}\n\n\t\/*\n\t * Update the state variables.\n\t *\/\n\tif (peer->flip == 0) {\n\t\tif (hismode != MODE_BROADCAST)\n\t\t\tpeer->rec = p_xmt;\n\t\tpeer->dst = rbufp->recv_time;\n\t}\n\tpeer->xmt = p_xmt;\n\n\t\/*\n\t * Set the peer ppoll to the maximum of the packet ppoll and the\n\t * peer minpoll. If a kiss-o'-death, set the peer minpoll to\n\t * this maximum and advance the headway to give the sender some\n\t * headroom. Very intricate.\n\t *\/\n\n\t\/*\n\t * Check for any kiss codes. Note this is only used when a server\n\t * responds to a packet request\n\t *\/\n\n\tkissCode = kiss_code_check(hisleap, hisstratum, hismode, pkt->refid);\n\n\t\/*\n\t * Check to see if this is a RATE Kiss Code\n\t * Currently this kiss code will accept whatever poll\n\t * rate that the server sends\n\t *\/\n\tpeer->ppoll = max(peer->minpoll, pkt->ppoll);\n\tif (kissCode == RATEKISS) {\n\t\tpeer->selbroken++;\t\/* Increment the KoD count *\/\n\t\treport_event(PEVNT_RATE, peer, NULL);\n\t\tif (pkt->ppoll > peer->minpoll)\n\t\t\tpeer->minpoll = peer->ppoll;\n\t\tpeer->burst = peer->retry = 0;\n\t\tpeer->throttle = (NTP_SHIFT + 1) * (1 << peer->minpoll);\n\t\tpoll_update(peer, pkt->ppoll);\n\t\treturn;\t\t\t\t\/* kiss-o'-death *\/\n\t}\n\tif (kissCode != NOKISS) {\n\t\tpeer->selbroken++;\t\/* Increment the KoD count *\/\n\t\treturn;\t\t\/* Drop any other kiss code packets *\/\n\t}\n\n\n\t\/*\n\t * That was hard and I am sweaty, but the packet is squeaky\n\t * clean. Get on with real work.\n\t *\/\n\tpeer->timereceived = current_time;\n\tpeer->timelastrec = current_time;\n\tif (is_authentic == AUTH_OK)\n\t\tpeer->flags |= FLAG_AUTHENTIC;\n\telse\n\t\tpeer->flags &= ~FLAG_AUTHENTIC;\n\n#ifdef AUTOKEY\n\t\/*\n\t * More autokey dance. The rules of the cha-cha are as follows:\n\t *\n\t * 1. If there is no key or the key is not auto, do nothing.\n\t *\n\t * 2. If this packet is in response to the one just previously\n\t *    sent or from a broadcast server, do the extension fields.\n\t *    Otherwise, assume bogosity and bail out.\n\t *\n\t * 3. If an extension field contains a verified signature, it is\n\t *    self-authenticated and we sit the dance.\n\t *\n\t * 4. If this is a server reply, check only to see that the\n\t *    transmitted key ID matches the received key ID.\n\t *\n\t * 5. Check to see that one or more hashes of the current key ID\n\t *    matches the previous key ID or ultimate original key ID\n\t *    obtained from the broadcaster or symmetric peer. If no\n\t *    match, sit the dance and call for new autokey values.\n\t *\n\t * In case of crypto error, fire the orchestra, stop dancing and\n\t * restart the protocol.\n\t *\/\n\tif (peer->flags & FLAG_SKEY) {\n\t\t\/*\n\t\t * Decrement remaining autokey hashes. This isn't\n\t\t * perfect if a packet is lost, but results in no harm.\n\t\t *\/\n\t\tap = (struct autokey *)peer->recval.ptr;\n\t\tif (ap != NULL) {\n\t\t\tif (ap->seq > 0)\n\t\t\t\tap->seq--;\n\t\t}\n\t\tpeer->flash |= TEST8;\n\t\trval = crypto_recv(peer, rbufp);\n\t\tif (rval == XEVNT_OK) {\n\t\t\tpeer->unreach = 0;\n\t\t} else {\n\t\t\tif (rval == XEVNT_ERR) {\n\t\t\t\treport_event(PEVNT_RESTART, peer,\n\t\t\t\t    \"crypto error\");\n\t\t\t\tpeer_clear(peer, \"CRYP\");\n\t\t\t\tpeer->flash |= TEST9;\t\/* bad crypt *\/\n\t\t\t\tif (peer->flags & FLAG_PREEMPT)\n\t\t\t\t\tunpeer(peer);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t\/*\n\t\t * If server mode, verify the receive key ID matches\n\t\t * the transmit key ID.\n\t\t *\/\n\t\tif (hismode == MODE_SERVER) {\n\t\t\tif (skeyid == peer->keyid)\n\t\t\t\tpeer->flash &= ~TEST8;\n\n\t\t\/*\n\t\t * If an extension field is present, verify only that it\n\t\t * has been correctly signed. We don't need a sequence\n\t\t * check here, but the sequence continues.\n\t\t *\/\n\t\t} else if (!(peer->flash & TEST8)) {\n\t\t\tpeer->pkeyid = skeyid;\n\n\t\t\/*\n\t\t * Now the fun part. Here, skeyid is the current ID in\n\t\t * the packet, pkeyid is the ID in the last packet and\n\t\t * tkeyid is the hash of skeyid. If the autokey values\n\t\t * have not been received, this is an automatic error.\n\t\t * If so, check that the tkeyid matches pkeyid. If not,\n\t\t * hash tkeyid and try again. If the number of hashes\n\t\t * exceeds the number remaining in the sequence, declare\n\t\t * a successful failure and refresh the autokey values.\n\t\t *\/\n\t\t} else if (ap != NULL) {\n\t\t\tint i;\n\n\t\t\tfor (i = 0; ; i++) {\n\t\t\t\tif (   tkeyid == peer->pkeyid\n\t\t\t\t    || tkeyid == ap->key) {\n\t\t\t\t\tpeer->flash &= ~TEST8;\n\t\t\t\t\tpeer->pkeyid = skeyid;\n\t\t\t\t\tap->seq -= i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (i > ap->seq) {\n\t\t\t\t\tpeer->crypto &=\n\t\t\t\t\t    ~CRYPTO_FLAG_AUTO;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ttkeyid = session_key(\n\t\t\t\t    &rbufp->recv_srcadr, dstadr_sin,\n\t\t\t\t    tkeyid, pkeyid, 0);\n\t\t\t}\n\t\t\tif (peer->flash & TEST8)\n\t\t\t\treport_event(PEVNT_AUTH, peer, \"keylist\");\n\t\t}\n\t\tif (!(peer->crypto & CRYPTO_FLAG_PROV)) \/* test 9 *\/\n\t\t\tpeer->flash |= TEST8;\t\/* bad autokey *\/\n\n\t\t\/*\n\t\t * The maximum lifetime of the protocol is about one\n\t\t * week before restarting the Autokey protocol to\n\t\t * refresh certificates and leapseconds values.\n\t\t *\/\n\t\tif (current_time > peer->refresh) {\n\t\t\treport_event(PEVNT_RESTART, peer,\n\t\t\t    \"crypto refresh\");\n\t\t\tpeer_clear(peer, \"TIME\");\n\t\t\treturn;\n\t\t}\n\t}\n#endif\t\/* AUTOKEY *\/\n\n\t\/*\n\t * The dance is complete and the flash bits have been lit. Toss\n\t * the packet over the fence for processing, which may light up\n\t * more flashers.\n\t *\/\n\tprocess_packet(peer, pkt, rbufp->recv_length);\n\n\t\/*\n\t * In interleaved mode update the state variables. Also adjust the\n\t * transmit phase to avoid crossover.\n\t *\/\n\tif (peer->flip != 0) {\n\t\tpeer->rec = p_rec;\n\t\tpeer->dst = rbufp->recv_time;\n\t\tif (peer->nextdate - current_time < (1U << min(peer->ppoll,\n\t\t    peer->hpoll)) \/ 2)\n\t\t\tpeer->nextdate++;\n\t\telse\n\t\t\tpeer->nextdate--;\n\t}\n}","target":1,"code_token_length":11207,"total_token_length":11443,"max_tokens_setting":28000}
+{"idx":14659,"func":"do_REMOTE_syscall()\n{\n\tint condor_sysnum;\n\tint\trval = -1, result = -1, fd = -1, mode = -1, uid = -1, gid = -1;\n\tint length = -1;\n\tcondor_errno_t terrno;\n\tchar *path = NULL, *buffer = NULL;\n\tvoid *buf = NULL;\n\n\tsyscall_sock->decode();\n\n\tdprintf(D_SYSCALLS, \"About to decode condor_sysnum\\n\");\n\n\trval = syscall_sock->code(condor_sysnum);\n\tif (!rval) {\n\t\tMyString err_msg;\n\t\terr_msg = \"Can no longer talk to condor_starter <\";\n\t\terr_msg += syscall_sock->peer_ip_str();\n\t\terr_msg += ':';\n\t\terr_msg += syscall_sock->peer_port();\n\t\terr_msg += '>';\n\n\t\tthisRemoteResource->closeClaimSock();\n\n            \/* It is possible that we are failing to read the\n            syscall number because the starter went away\n            because we *asked* it to go away. Don't be shocked\n            and surprised if the startd\/starter actually did\n            what we asked when we deactivated the claim *\/\n       if ( thisRemoteResource->wasClaimDeactivated() ) {\n           return 0;\n       }\n\n\t\tif( Shadow->supportsReconnect() ) {\n\t\t\tdprintf( D_ALWAYS, \"%s\\n\", err_msg.Value() );\n\n\t\t\tconst char* txt = \"Socket between submit and execute hosts \"\n\t\t\t\t\"closed unexpectedly\";\n\t\t\tShadow->logDisconnectedEvent( txt ); \n\n\t\t\tif (!Shadow->shouldAttemptReconnect(thisRemoteResource)) {\n\t\t\t\t\tdprintf(D_ALWAYS, \"This job cannot reconnect to starter, so job exiting\\n\");\n\t\t\t\t\tShadow->gracefulShutDown();\n\t\t\t\t\tEXCEPT( \"%s\", err_msg.Value() );\n\t\t\t}\n\t\t\tShadow->reconnect();\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tEXCEPT( \"%s\", err_msg.Value() );\n\t\t}\n\t}\n\n\tdprintf(D_SYSCALLS,\n\t\t\"Got request for syscall %s (%d)\\n\",\n\t\tshadow_syscall_name(condor_sysnum), condor_sysnum);\n\n\tswitch( condor_sysnum ) {\n\n\tcase CONDOR_register_starter_info:\n\t{\n\t\tClassAd ad;\n\t\tresult = ( ad.initFromStream(*syscall_sock) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_register_starter_info( &ad );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_register_job_info:\n\t{\n\t\tClassAd ad;\n\t\tresult = ( ad.initFromStream(*syscall_sock) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_register_job_info( &ad );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_get_job_info:\n\t{\n\t\tClassAd *ad = NULL;\n\t\tbool delete_ad;\n\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_get_job_info(ad, delete_ad);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t} else {\n\t\t\tresult = ( ad->put(*syscall_sock) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\tif ( delete_ad ) {\n\t\t\tdelete ad;\n\t\t}\n\t\treturn 0;\n\t}\n\n\n\tcase CONDOR_get_user_info:\n\t{\n\t\tClassAd *ad = NULL;\n\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_get_user_info(ad);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t} else {\n\t\t\tresult = ( ad->put(*syscall_sock) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\n\tcase CONDOR_job_exit:\n\t{\n\t\tint status=0;\n\t\tint reason=0;\n\t\tClassAd ad;\n\n\t\tresult = ( syscall_sock->code(status) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->code(reason) );\n\t\tASSERT( result );\n\t\tresult = ( ad.initFromStream(*syscall_sock) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_job_exit(status, reason, &ad);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn -1;\n\t}\n\n\tcase CONDOR_job_termination:\n\t{\n\t\tClassAd ad;\n\t\tresult = ( ad.initFromStream(*syscall_sock) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_job_termination( &ad );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_begin_execution:\n\t{\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_begin_execution();\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_open:\n\t  {\n\t\topen_flags_t flags;\n\t\tint   lastarg;\n\n\t\tresult = ( syscall_sock->code(flags) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  flags = %d\\n\", flags );\n\t\tresult = ( syscall_sock->code(lastarg) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  lastarg = %d\\n\", lastarg );\n\t\tpath = NULL;\n\t\tresult = ( syscall_sock->code(path) );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\n\t\tbool access_ok;\n\t\tif ( flags & O_RDONLY ) {\n\t\t\taccess_ok = read_access(path);\n\t\t} else {\n\t\t\taccess_ok = write_access(path);\n\t\t}\n\n\t\terrno = 0;\n\t\tif ( access_ok ) {\n\t\t\trval = safe_open_wrapper_follow( path , flags , lastarg);\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\n\t\tfree( (char *)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_close:\n\t  {\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = close( fd);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_read:\n\t  {\n\t\tsize_t   len;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(len) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  len = %ld\\n\", (long)len );\n\t\tbuf = (void *)malloc( (unsigned)len );\n\t\tmemset( buf, 0, (unsigned)len );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = read( fd , buf , len);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tif( rval >= 0 ) {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buf, rval) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_write:\n\t  {\n\t\tsize_t   len;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(len) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  len = %ld\\n\", (long)len );\n\t\tbuf = (void *)malloc( (unsigned)len );\n\t\tmemset( buf, 0, (unsigned)len );\n\t\tresult = ( syscall_sock->code_bytes_bool(buf, len) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = write( fd , buf , len);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_lseek:\n\tcase CONDOR_lseek64:\n\tcase CONDOR_llseek:\n\t  {\n\t\toff_t   offset;\n\t\tint   whence;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(offset) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  offset = %ld\\n\", (long)offset );\n\t\tresult = ( syscall_sock->code(whence) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  whence = %d\\n\", whence );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = lseek( fd , offset , whence);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_unlink:\n\t  {\n\t\tpath = NULL;\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\tif ( write_access(path) ) {\n\t\t\terrno = 0;\n\t\t\trval = unlink( path);\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char *)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_rename:\n\t  {\n\t\tchar *  from;\n\t\tchar *  to;\n\n\t\tto = NULL;\n\t\tfrom = NULL;\n\t\tresult = ( syscall_sock->code(from) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  from = %s\\n\", from );\n\t\tresult = ( syscall_sock->code(to) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  to = %s\\n\", to );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\tif ( write_access(from) && write_access(to) ) {\n\t\t\terrno = 0;\n\t\t\trval = rename( from , to);\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char *)to );\n\t\tfree( (char *)from );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_register_mpi_master_info:\n\t{\n\t\tClassAd ad;\n\t\tresult = ( ad.initFromStream(*syscall_sock) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pseudo_register_mpi_master_info( &ad );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_mkdir:\n\t  {\n\t\tpath = NULL;\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(mode) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  mode = %d\\n\", mode );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\tif ( write_access(path) ) {\n\t\t\terrno = 0;\n\t\t\trval = mkdir(path,mode);\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char *)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_rmdir:\n\t  {\n\t\tpath = NULL;\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\tif ( write_access(path) ) {\n\t\t\terrno = 0;\n\t\t\trval = rmdir( path);\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_fsync:\n\t  {\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fs = %d\\n\", fd );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = fsync(fd);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_get_file_info_new:\n\t  {\n\t\tchar *  logical_name;\n\t\tchar *  actual_url;\n \n\t\tactual_url = NULL;\n\t\tlogical_name = NULL;\n\t\tASSERT( syscall_sock->code(logical_name) );\n\t\tASSERT( syscall_sock->end_of_message() );;\n \n\t\terrno = (condor_errno_t)0;\n\t\trval = pseudo_get_file_info_new( logical_name , actual_url );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, (int)terrno );\n \n\t\tsyscall_sock->encode();\n\t\tASSERT( syscall_sock->code(rval) );\n\t\tif( rval < 0 ) {\n\t\t\tASSERT( syscall_sock->code(terrno) );\n\t\t}\n\t\tif( rval >= 0 ) {\n\t\t\tASSERT( syscall_sock->code(actual_url) );\n\t\t}\n\t\tfree( (char *)actual_url );\n\t\tfree( (char *)logical_name );\n\t\tASSERT( syscall_sock->end_of_message() );;\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_ulog:\n\t{\n\t\tClassAd ad;\n\n\t\tresult = ( ad.initFromStream(*syscall_sock) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\trval = pseudo_ulog(&ad);\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d\\n\", rval );\n\n\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_get_job_attr:\n\t  {\n\t\tchar *  attrname = 0;\n\n\t\tassert( syscall_sock->code(attrname) );\n\t\tassert( syscall_sock->end_of_message() );;\n\n\t\terrno = (condor_errno_t)0;\n\t\tMyString expr;\n\t\tif ( thisRemoteResource->allowRemoteReadAttributeAccess(attrname) ) {\n\t\t\trval = pseudo_get_job_attr( attrname , expr);\n\t\t\tterrno = (condor_errno_t)errno;\n\t\t} else {\n\t\t\trval = -1;\n\t\t\tterrno = (condor_errno_t)EACCES;\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, (int)terrno );\n\n\t\tsyscall_sock->encode();\n\t\tassert( syscall_sock->code(rval) );\n\t\tif( rval < 0 ) {\n\t\t\tassert( syscall_sock->code(terrno) );\n\t\t}\n\t\tif( rval >= 0 ) {\n\t\t\tassert( syscall_sock->put(expr.Value()) );\n\t\t}\n\t\tfree( (char *)attrname );\n\t\tassert( syscall_sock->end_of_message() );;\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_set_job_attr:\n\t  {\n\t\tchar *  attrname = 0;\n\t\tchar *  expr = 0;\n\n\t\tassert( syscall_sock->code(expr) );\n\t\tassert( syscall_sock->code(attrname) );\n\t\tassert( syscall_sock->end_of_message() );;\n\n\t\terrno = (condor_errno_t)0;\n\t\tif ( thisRemoteResource->allowRemoteWriteAttributeAccess(attrname) ) {\n\t\t\trval = pseudo_set_job_attr( attrname , expr , true );\n\t\t\tterrno = (condor_errno_t)errno;\n\t\t} else {\n\t\t\trval = -1;\n\t\t\tterrno = (condor_errno_t)EACCES;\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, (int)terrno );\n\n\t\tsyscall_sock->encode();\n\t\tassert( syscall_sock->code(rval) );\n\t\tif( rval < 0 ) {\n\t\t\tassert( syscall_sock->code(terrno) );\n\t\t}\n\t\tfree( (char *)expr );\n\t\tfree( (char *)attrname );\n\t\tassert( syscall_sock->end_of_message() );;\n\t\treturn 0;\n\t}\n\n\tcase CONDOR_constrain:\n\t  {\n\t\tchar *  expr = 0;\n\n\t\tassert( syscall_sock->code(expr) );\n\t\tassert( syscall_sock->end_of_message() );;\n\n\t\terrno = (condor_errno_t)0;\n\t\tif ( thisRemoteResource->allowRemoteWriteAttributeAccess(ATTR_REQUIREMENTS) ) {\n\t\t\trval = pseudo_constrain( expr);\n\t\t\tterrno = (condor_errno_t)errno;\n\t\t} else {\n\t\t\trval = -1;\n\t\t\tterrno = (condor_errno_t)EACCES;\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, (int)terrno );\n\n\t\tsyscall_sock->encode();\n\t\tassert( syscall_sock->code(rval) );\n\t\tif( rval < 0 ) {\n\t\t\tassert( syscall_sock->code(terrno) );\n\t\t}\n\t\tfree( (char *)expr );\n\t\tassert( syscall_sock->end_of_message() );;\n\t\treturn 0;\n\t}\n\tcase CONDOR_get_sec_session_info:\n\t{\n\t\tMyString starter_reconnect_session_info;\n\t\tMyString starter_filetrans_session_info;\n\t\tMyString reconnect_session_id;\n\t\tMyString reconnect_session_info;\n\t\tMyString reconnect_session_key;\n\t\tMyString filetrans_session_id;\n\t\tMyString filetrans_session_info;\n\t\tMyString filetrans_session_key;\n\t\tbool socket_default_crypto = syscall_sock->get_encryption();\n\t\tif( !socket_default_crypto ) {\n\t\t\tsyscall_sock->set_crypto_mode(true);\n\t\t}\n\t\tassert( syscall_sock->code(starter_reconnect_session_info) );\n\t\tassert( syscall_sock->code(starter_filetrans_session_info) );\n\t\tassert( syscall_sock->end_of_message() );\n\n\t\terrno = (condor_errno_t)0;\n\t\trval = pseudo_get_sec_session_info(\n\t\t\tstarter_reconnect_session_info.Value(),\n\t\t\treconnect_session_id,\n\t\t\treconnect_session_info,\n\t\t\treconnect_session_key,\n\t\t\tstarter_filetrans_session_info.Value(),\n\t\t\tfiletrans_session_id,\n\t\t\tfiletrans_session_info,\n\t\t\tfiletrans_session_key );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, (int)terrno );\n\n\t\tsyscall_sock->encode();\n\t\tassert( syscall_sock->code(rval) );\n\t\tif( rval < 0 ) {\n\t\t\tassert( syscall_sock->code(terrno) );\n\t\t}\n\t\telse {\n\t\t\tassert( syscall_sock->code(reconnect_session_id) );\n\t\t\tassert( syscall_sock->code(reconnect_session_info) );\n\t\t\tassert( syscall_sock->code(reconnect_session_key) );\n\n\t\t\tassert( syscall_sock->code(filetrans_session_id) );\n\t\t\tassert( syscall_sock->code(filetrans_session_info) );\n\t\t\tassert( syscall_sock->code(filetrans_session_key) );\n\t\t}\n\n\t\tassert( syscall_sock->end_of_message() );\n\n\t\tif( !socket_default_crypto ) {\n\t\t\tsyscall_sock->set_crypto_mode( false );  \/\/ restore default\n\t\t}\n\t\treturn 0;\n\t}\n#ifdef WIN32\n#else\n\tcase CONDOR_pread:\n\t  {\n\t\tsize_t len, offset;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(len) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  len = %ld\\n\", (long)len );\n\t\tresult = ( syscall_sock->code(offset) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  offset = %ld\\n\", (long)offset );\n\t\tbuf = (void *)malloc( (unsigned)len );\n\t\tmemset( buf, 0, (unsigned)len );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pread( fd , buf , len, offset );\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buf, rval) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_pwrite:\n\t  {\n\t\tsize_t   len, offset;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(len) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  len = %ld\\n\", (long)len );\n\t\tresult = ( syscall_sock->code(offset) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  offset = %ld\\n\", (long)offset);\n\t\tbuf = malloc( (unsigned)len );\n\t\tmemset( buf, 0, (unsigned)len );\n\t\tresult = ( syscall_sock->code_bytes_bool(buf, len) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = pwrite( fd , buf , len, offset);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_sread:\n\t  {\n\t\tsize_t   len, offset, stride_length, stride_skip;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(len) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  len = %ld\\n\", (long)len );\n\t\tresult = ( syscall_sock->code(offset) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  offset = %ld\\n\", (long)offset );\n\t\tresult = ( syscall_sock->code(stride_length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  stride_length = %ld\\n\", (long)stride_length);\n\t\tresult = ( syscall_sock->code(stride_skip) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  stride_skip = %ld\\n\", (long)stride_skip);\n\t\tbuf = (void *)malloc( (unsigned)len );\n\t\tmemset( buf, 0, (unsigned)len );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = EINVAL;\n\t\trval = -1;\n\t\tunsigned int total = 0;\n\t\tbuffer = (char*)buf;\n\n\t\twhile(total < len && stride_length > 0) {\n\t\t\tif(len - total < stride_length) {\n\t\t\t\tstride_length = len - total;\n\t\t\t}\n\t\t\trval = pread( fd, (void*)&buffer[total], stride_length, offset );\n\t\t\tif(rval >= 0) {\n\t\t\t\ttotal += rval;\n\t\t\t\toffset += stride_skip;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tsyscall_sock->encode();\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code(rval) );\n\t\t\tASSERT( result );\n\t\t\tterrno = (condor_errno_t)errno;\n\t\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", total, terrno );\n\t\t\tresult = ( syscall_sock->code(total) );\n\t\t\tASSERT( result );\n\t\t\tdprintf( D_ALWAYS, \"buffer: %s\\n\", buffer);\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buf, total) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_swrite:\n\t  {\n\t\tsize_t   len, offset, stride_length, stride_skip;\n\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(len) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  len = %ld\\n\", (long)len );\n\t\tresult = ( syscall_sock->code(offset) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  offset = %ld\\n\", (long)offset);\n\t\tresult = ( syscall_sock->code(stride_length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  stride_length = %ld\\n\", (long)stride_length);\n\t\tresult = ( syscall_sock->code(stride_skip) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  stride_skip = %ld\\n\", (long)stride_skip);\n\t\tbuf = (void *)malloc( (unsigned)len );\n\t\tmemset( buf, 0, (unsigned)len );\n\t\tresult = ( syscall_sock->code_bytes_bool(buf, len) );\n\t\tASSERT( result );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = EINVAL;\n\t\trval = -1;\n\t\tunsigned int total = 0;\n\t\tbuffer = (char*)buf;\n\n\t\twhile(total < len && stride_length > 0) {\n\t\t\tif(len - total < stride_length) {\n\t\t\t\tstride_length = len - total;\n\t\t\t}\n\t\t\trval = pwrite( fd, (void*)&buffer[total], stride_length, offset);\n\t\t\tif(rval >= 0) {\n\t\t\t\ttotal += rval;\n\t\t\t\toffset += stride_skip;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tsyscall_sock->encode();\n\t\tif( rval < 0 ) {\n\t\t\tterrno = (condor_errno_t)errno;\n\t\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d (%s)\\n\", rval, terrno, strerror(errno));\n\t\t\tresult = ( syscall_sock->code(rval) );\n\t\t\tASSERT( result );\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d (%s)\\n\", total, terrno, strerror(errno));\n\t\t\tresult = ( syscall_sock->code(total) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_rmall:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\tif ( write_access(path) ) {\n\t\t\trval = rmdir(path);\n\t\t\t\n\t\t\tif(rval == -1) {\n\t\t\t\tDirectory dir(path);\n\t\t\t\tif(dir.Remove_Entire_Directory()) {\n\t\t\t\t\trval = rmdir(path);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char *)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\ncase CONDOR_getfile:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\tfd = safe_open_wrapper_follow( path, O_RDONLY );\n\t\tif(fd >= 0) {\n\t\t\tstruct stat info;\n\t\t\tstat(path, &info);\n\t\t\tlength = info.st_size;\n\t\t\tbuf = (void *)malloc( (unsigned)length );\n\t\t\tmemset( buf, 0, (unsigned)length );\n\n\t\t\terrno = 0;\n\t\t\trval = read( fd , buf , length);\n\t\t} else {\n\t\t\trval = fd;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\t\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buf, rval) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char *)path );\n\t\tfree( buf );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\ncase CONDOR_putfile:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf(D_SYSCALLS, \"  path: %s\\n\", path);\n\t\tresult = ( syscall_sock->code(mode) );\n\t\tASSERT( result );\n\t\tdprintf(D_SYSCALLS, \"  mode: %d\\n\", mode);\n\t\tresult = ( syscall_sock->code(length) );\n\t\tASSERT( result );\n\t\tdprintf(D_SYSCALLS, \"  length: %d\\n\", length);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\tfd = safe_open_wrapper_follow(path, O_CREAT | O_WRONLY | O_TRUNC, mode);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tif( fd < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\tint num = -1;\n\t\tif(fd >= 0) {\n\t\t\tsyscall_sock->decode();\n\t\t\tbuffer = (char*)malloc( (unsigned)length );\n\t\t\tmemset( buffer, 0, (unsigned)length );\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buffer, length) );\n\t\t\tASSERT( result );\n\t\t\tresult = ( syscall_sock->end_of_message() );\n\t\t\tASSERT( result );\n\t\t\tnum = write(fd, buffer, length);\n\t\t}\n\t\telse {\n\t\t\tdprintf(D_SYSCALLS, \"Unable to put file %s\\n\", path);\n\t\t}\n\t\tclose(fd);\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(num) );\n\t\tASSERT( result );\n\t\tif( num < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)path);\n\t\tfree((char*)buffer);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\ncase CONDOR_getlongdir:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = -1;\n\t\tMyString msg, check;\n\t\tconst char *next;\n\t\tDirectory directory(path);\n\t\tstruct stat stat_buf;\n\t\tchar line[1024];\n\t\t\n\t\twhile((next = directory.Next())) {\n\t\t\tdprintf(D_ALWAYS, \"next: %s\\n\", next);\n\t\t\tmsg.sprintf_cat(\"%s\\n\", next);\n\t\t\tcheck.sprintf(\"%s%c%s\", path, DIR_DELIM_CHAR, next);\n\t\t\trval = stat(check.Value(), &stat_buf);\n\t\t\tterrno = (condor_errno_t)errno;\n\t\t\tif(rval == -1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(stat_string(line, &stat_buf) < 0) {\n\t\t\t\trval = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmsg.sprintf_cat(\"%s\", line);\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tif(msg.Length() > 0) {\n\t\t\tmsg.sprintf_cat(\"\\n\");\t\/\/ Needed to signify end of data\n\t\t\trval = msg.Length();\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->put(msg.Value()) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)path);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\ncase CONDOR_getdir:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\trval = -1;\n\t\tMyString msg;\n\t\tconst char *next;\n\t\tDirectory directory(path);\n \n                while((next = directory.Next())) {\n                       msg.sprintf_cat(next);\n                        msg.sprintf_cat(\"\\n\");\n                }\n                terrno = (condor_errno_t)errno;\n\t\tif(msg.Length() > 0) {\n\t\t\tmsg.sprintf_cat(\"\\n\");\t\/\/ Needed to signify end of data\n\t\t\trval = msg.Length();\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->put(msg.Value()) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)path);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_whoami:\n\t{\n\t\tresult = ( syscall_sock->code(length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  length = %d\\n\", length );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\tbuffer = (char*)malloc( (unsigned)length );\n\t\tint size = 6;\n\t\tif(length < size) {\n\t\t\trval = -1;\n\t\t\tterrno = (condor_errno_t) ENOSPC;\n\t\t}\n\t\telse {\n\t\t\trval = sprintf(buffer, \"CONDOR\");\n\t\t\tterrno = (condor_errno_t) errno;\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval != size) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buffer, rval));\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)buffer);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_whoareyou:\n\t{\n\t\tchar *host = NULL;\n\n\t\tresult = ( syscall_sock->code(host) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  host = %s\\n\", host );\n\t\tresult = ( syscall_sock->code(length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  length = %d\\n\", length );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\tbuffer = (char*)malloc( (unsigned)length );\n\t\tint size = 7;\n\t\tif(length < size) {\n\t\t\trval = -1;\n\t\t\tterrno = (condor_errno_t) ENOSPC;\n\t\t}\n\t\telse {\n\t\t\trval = sprintf(buffer, \"UNKNOWN\");\n\t\t\tterrno = (condor_errno_t) errno;\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval != size) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(buffer, rval));\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)buffer);\n\t\tfree((char*)host);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_fstatfs:\n\t{\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n#if defined(Solaris)\n\t\tstruct statvfs statfs_buf;\n\t\trval = fstatvfs(fd, &statfs_buf);\n#else\n\t\tstruct statfs statfs_buf;\n\t\trval = fstatfs(fd, &statfs_buf);\n#endif\n\t\tterrno = (condor_errno_t)errno;\n\t\tchar line[1024];\n\t\tif(rval == 0) {\n\t\t\tif(statfs_string(line, &statfs_buf) < 0) {\n\t\t\t\trval = -1;\n\t\t\t\tterrno = (condor_errno_t)errno;\n\t\t\t}\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(line, 1024) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\t\n\t}\n\tcase CONDOR_fchown:\n\t{\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(uid) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  uid = %d\\n\", uid );\n\t\tresult = ( syscall_sock->code(gid) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  gid = %d\\n\", gid );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = fchown(fd, uid, gid);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_fchmod:\n\t{\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(mode) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  mode = %d\\n\", mode );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = fchmod(fd, (mode_t)mode);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_ftruncate:\n\t{\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->code(length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  length = %d\\n\", length );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = ftruncate(fd, length);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\t\n\t\n\t\n\t\n\t\n\t\n\tcase CONDOR_link:\n\t{\n\t\tchar *newpath = NULL;\n\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(newpath) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  newpath = %s\\n\", newpath );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = link(path, newpath);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)path);\n\t\tfree((char*)newpath);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_symlink:\n\t{\n\t\tchar *newpath = NULL;\n\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(newpath) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  newpath = %s\\n\", newpath );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = symlink(path, newpath);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree((char*)path);\n\t\tfree((char*)newpath);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_readlink:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  length = %d\\n\", length );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\tchar *lbuffer = (char*)malloc(length);\n\t\terrno = 0;\n\t\trval = readlink(path, lbuffer, length);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(lbuffer, rval));\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree(lbuffer);\n\t\tfree(path);\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_lstat:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\tstruct stat stat_buf;\n\t\trval = lstat(path, &stat_buf);\n\t\tterrno = (condor_errno_t)errno;\n\t\tchar line[1024];\n\t\tif(rval == 0) {\n\t\t\tif(stat_string(line, &stat_buf) < 0) {\n\t\t\t\trval = -1;\n\t\t\t\tterrno = (condor_errno_t)errno;\n\t\t\t}\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(line, 1024) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_statfs:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n#if defined(Solaris)\n\t\tstruct statvfs statfs_buf;\n\t\trval = statvfs(path, &statfs_buf);\n#else\n\t\tstruct statfs statfs_buf;\n\t\trval = statfs(path, &statfs_buf);\n#endif\n\t\tterrno = (condor_errno_t)errno;\n\t\tchar line[1024];\n\t\tif(rval == 0) {\n\t\t\tif(statfs_string(line, &statfs_buf) < 0) {\n\t\t\t\trval = -1;\n\t\t\t\tterrno = (condor_errno_t)errno;\n\t\t\t}\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(line, 1024) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_chown:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(uid) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  uid = %d\\n\", uid );\n\t\tresult = ( syscall_sock->code(gid) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  gid = %d\\n\", gid );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = chown(path, uid, gid);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_lchown:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(uid) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  uid = %d\\n\", uid );\n\t\tresult = ( syscall_sock->code(gid) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  gid = %d\\n\", gid );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = lchown(path, uid, gid);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_truncate:\n\t{\n\t\t\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(length) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  length = %d\\n\", length );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\tif ( write_access(path) ) {\n\t\t\terrno = 0;\n\t\t\trval = truncate(path, length);\n\t\t} else {\n\t\t\trval = -1;\n\t\t\terrno = EACCES;\n\t\t}\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n#endif \/\/ ! WIN32\n\n\tcase CONDOR_fstat:\n\t{\n\t\tresult = ( syscall_sock->code(fd) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  fd = %d\\n\", fd );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\tstruct stat stat_buf;\n\t\trval = fstat(fd, &stat_buf);\n\t\tterrno = (condor_errno_t)errno;\n\t\tchar line[1024];\n\t\tif(rval == 0) {\n\t\t\tif(stat_string(line, &stat_buf) < 0) {\n\t\t\t\trval = -1;\n\t\t\t\tterrno = (condor_errno_t)errno;\n\t\t\t}\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(line, 1024) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\t\n\t}\n\tcase CONDOR_stat:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\n\t\terrno = 0;\n\t\tstruct stat stat_buf;\n\t\trval = stat(path, &stat_buf);\n\t\tterrno = (condor_errno_t)errno;\n\t\tchar line[1024];\n\t\tif(rval == 0) {\n\t\t\tif(stat_string(line, &stat_buf) < 0) {\n\t\t\t\trval = -1;\n\t\t\t\tterrno = (condor_errno_t)errno;\n\t\t\t}\n\t\t}\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif( rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\telse {\n\t\t\tresult = ( syscall_sock->code_bytes_bool(line, 1024) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_access:\n\t{\n\t\tint flags = -1;\n\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(flags) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  flags = %d\\n\", flags );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = access(path, flags);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0 ) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_chmod:\n\t{\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(mode) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  mode = %d\\n\", mode );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\terrno = 0;\n\t\trval = chmod(path, mode);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\t\t\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tcase CONDOR_utime:\n\t{\n\t\ttime_t actime = -1, modtime = -1;\n\n\t\tresult = ( syscall_sock->code(path) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  path = %s\\n\", path );\n\t\tresult = ( syscall_sock->code(actime) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  actime = %ld\\n\", actime );\n\t\tresult = ( syscall_sock->code(modtime) );\n\t\tASSERT( result );\n\t\tdprintf( D_SYSCALLS, \"  modtime = %ld\\n\", modtime );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\t\n\t\tstruct utimbuf ut;\n\t\tut.actime = actime;\n\t\tut.modtime = modtime;\n\t\t\n\t\terrno = 0;\n\t\trval = utime(path, &ut);\n\t\tterrno = (condor_errno_t)errno;\n\t\tdprintf( D_SYSCALLS, \"\\trval = %d, errno = %d\\n\", rval, terrno );\n\n\t\tsyscall_sock->encode();\n\t\tresult = ( syscall_sock->code(rval) );\n\t\tASSERT( result );\n\t\tif(rval < 0) {\n\t\t\tresult = ( syscall_sock->code( terrno ) );\n\t\t\tASSERT( result );\n\t\t}\n\t\tfree( (char*)path );\n\t\tresult = ( syscall_sock->end_of_message() );\n\t\tASSERT( result );\n\t\treturn 0;\n\t}\n\tdefault:\n\t{\n\t\tdprintf(D_ALWAYS, \"ERROR: unknown syscall %d received\\n\", condor_sysnum );\n\t\treturn 0;\n\t\t\n\t}\n\n\t}\t\/* End of switch on system call number *\/\n\n\treturn -1;\n\n}\t\/* End of do_REMOTE_syscall() procedure *\/\n","target":1,"code_token_length":15344,"total_token_length":15580,"max_tokens_setting":28000}
+{"idx":477709,"func":"    CImg get_resize(const int size_x, const int size_y = -100,\n                       const int size_z = -100, const int size_c = -100,\n                       const int interpolation_type=1, const unsigned int boundary_conditions=0,\n                       const float centering_x = 0, const float centering_y = 0,\n                       const float centering_z = 0, const float centering_c = 0) const {\n      if (centering_x<0 || centering_x>1 || centering_y<0 || centering_y>1 ||\n          centering_z<0 || centering_z>1 || centering_c<0 || centering_c>1)\n        throw CImgArgumentException(_cimg_instance\n                                    \"resize(): Specified centering arguments (%g,%g,%g,%g) are outside range [0,1].\",\n                                    cimg_instance,\n                                    centering_x,centering_y,centering_z,centering_c);\n\n      if (!size_x || !size_y || !size_z || !size_c) return CImg();\n      const unsigned int\n        sx = std::max(1U,(unsigned int)(size_x>=0?size_x:-size_x*width()\/100)),\n        sy = std::max(1U,(unsigned int)(size_y>=0?size_y:-size_y*height()\/100)),\n        sz = std::max(1U,(unsigned int)(size_z>=0?size_z:-size_z*depth()\/100)),\n        sc = std::max(1U,(unsigned int)(size_c>=0?size_c:-size_c*spectrum()\/100));\n      if (sx==_width && sy==_height && sz==_depth && sc==_spectrum) return +*this;\n      if (is_empty()) return CImg(sx,sy,sz,sc,(T)0);\n      CImg res;\n      switch (interpolation_type) {\n\n        \/\/ Raw resizing.\n        \/\/\n      case -1 :\n        std::memcpy(res.assign(sx,sy,sz,sc,(T)0)._data,_data,sizeof(T)*std::min(size(),(ulongT)sx*sy*sz*sc));\n        break;\n\n        \/\/ No interpolation.\n        \/\/\n      case 0 : {\n        const int\n          xc = (int)(centering_x*((int)sx - width())),\n          yc = (int)(centering_y*((int)sy - height())),\n          zc = (int)(centering_z*((int)sz - depth())),\n          cc = (int)(centering_c*((int)sc - spectrum()));\n\n        switch (boundary_conditions) {\n        case 3 : { \/\/ Mirror\n          res.assign(sx,sy,sz,sc);\n          const int w2 = 2*width(), h2 = 2*height(), d2 = 2*depth(), s2 = 2*spectrum();\n          cimg_pragma_openmp(parallel for cimg_openmp_collapse(3) cimg_openmp_if_size(res.size(),1024*1024))\n          cimg_forXYZC(res,x,y,z,c) {\n            const int\n              mx = cimg::mod(x - xc,w2), my = cimg::mod(y - yc,h2),\n              mz = cimg::mod(z - zc,d2), mc = cimg::mod(c - cc,s2);\n            res(x,y,z,c) = (*this)(mx sprite;\n          if (xc>0) {  \/\/ X-backward\n            res.get_crop(xc,yc,zc,cc,xc,yc + height() - 1,zc + depth() - 1,cc + spectrum() - 1).move_to(sprite);\n            for (int x = xc - 1; x>=0; --x) res.draw_image(x,yc,zc,cc,sprite);\n          }\n          if (xc + width()<(int)sx) { \/\/ X-forward\n            res.get_crop(xc + width() - 1,yc,zc,cc,xc + width() - 1,yc + height() - 1,\n                         zc + depth() - 1,cc + spectrum() - 1).move_to(sprite);\n            for (int x = xc + width(); x<(int)sx; ++x) res.draw_image(x,yc,zc,cc,sprite);\n          }\n          if (yc>0) {  \/\/ Y-backward\n            res.get_crop(0,yc,zc,cc,sx - 1,yc,zc + depth() - 1,cc + spectrum() - 1).move_to(sprite);\n            for (int y = yc - 1; y>=0; --y) res.draw_image(0,y,zc,cc,sprite);\n          }\n          if (yc + height()<(int)sy) { \/\/ Y-forward\n            res.get_crop(0,yc + height() - 1,zc,cc,sx - 1,yc + height() - 1,\n                         zc + depth() - 1,cc + spectrum() - 1).move_to(sprite);\n            for (int y = yc + height(); y<(int)sy; ++y) res.draw_image(0,y,zc,cc,sprite);\n          }\n          if (zc>0) {  \/\/ Z-backward\n            res.get_crop(0,0,zc,cc,sx - 1,sy - 1,zc,cc + spectrum() - 1).move_to(sprite);\n            for (int z = zc - 1; z>=0; --z) res.draw_image(0,0,z,cc,sprite);\n          }\n          if (zc + depth()<(int)sz) { \/\/ Z-forward\n            res.get_crop(0,0,zc  +depth() - 1,cc,sx - 1,sy - 1,zc + depth() - 1,cc + spectrum() - 1).move_to(sprite);\n            for (int z = zc + depth(); z<(int)sz; ++z) res.draw_image(0,0,z,cc,sprite);\n          }\n          if (cc>0) {  \/\/ C-backward\n            res.get_crop(0,0,0,cc,sx - 1,sy - 1,sz - 1,cc).move_to(sprite);\n            for (int c = cc - 1; c>=0; --c) res.draw_image(0,0,0,c,sprite);\n          }\n          if (cc + spectrum()<(int)sc) { \/\/ C-forward\n            res.get_crop(0,0,0,cc + spectrum() - 1,sx - 1,sy - 1,sz - 1,cc + spectrum() - 1).move_to(sprite);\n            for (int c = cc + spectrum(); c<(int)sc; ++c) res.draw_image(0,0,0,c,sprite);\n          }\n        } break;\n        default : \/\/ Dirichlet\n          res.assign(sx,sy,sz,sc,(T)0).draw_image(xc,yc,zc,cc,*this);\n        }\n        break;\n      } break;\n\n        \/\/ Nearest neighbor interpolation.\n        \/\/\n      case 1 : {\n        res.assign(sx,sy,sz,sc);\n        CImg off_x(sx), off_y(sy + 1), off_z(sz + 1), off_c(sc + 1);\n        const ulongT\n          wh = (ulongT)_width*_height,\n          whd = (ulongT)_width*_height*_depth,\n          sxy = (ulongT)sx*sy,\n          sxyz = (ulongT)sx*sy*sz,\n          one = (ulongT)1;\n        if (sx==_width) off_x.fill(1);\n        else {\n          ulongT *poff_x = off_x._data, curr = 0;\n          cimg_forX(res,x) {\n            const ulongT old = curr;\n            curr = (x + one)*_width\/sx;\n            *(poff_x++) = curr - old;\n          }\n        }\n        if (sy==_height) off_y.fill(_width);\n        else {\n          ulongT *poff_y = off_y._data, curr = 0;\n          cimg_forY(res,y) {\n            const ulongT old = curr;\n            curr = (y + one)*_height\/sy;\n            *(poff_y++) = _width*(curr - old);\n          }\n          *poff_y = 0;\n        }\n        if (sz==_depth) off_z.fill(wh);\n        else {\n          ulongT *poff_z = off_z._data, curr = 0;\n          cimg_forZ(res,z) {\n            const ulongT old = curr;\n            curr = (z + one)*_depth\/sz;\n            *(poff_z++) = wh*(curr - old);\n          }\n          *poff_z = 0;\n        }\n        if (sc==_spectrum) off_c.fill(whd);\n        else {\n          ulongT *poff_c = off_c._data, curr = 0;\n          cimg_forC(res,c) {\n            const ulongT old = curr;\n            curr = (c + one)*_spectrum\/sc;\n            *(poff_c++) = whd*(curr - old);\n          }\n          *poff_c = 0;\n        }\n\n        T *ptrd = res._data;\n        const T* ptrc = _data;\n        const ulongT *poff_c = off_c._data;\n        for (unsigned int c = 0; c_width) get_resize(sx,_height,_depth,_spectrum,1).move_to(res);\n          else {\n            CImg tmp(sx,_height,_depth,_spectrum,0);\n            cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                               cimg_openmp_if(sx>=256 && _height*_depth*_spectrum>=256))\n            cimg_forYZC(tmp,y,z,v) {\n              for (unsigned int a = _width*sx, b = _width, c = sx, s = 0, t = 0; a; ) {\n                const unsigned int d = std::min(b,c);\n                a-=d; b-=d; c-=d;\n                tmp(t,y,z,v)+=(Tfloat)(*this)(s,y,z,v)*d;\n                if (!b) { tmp(t++,y,z,v)\/=_width; b = _width; }\n                if (!c) { ++s; c = sx; }\n              }\n            }\n            tmp.move_to(res);\n          }\n          instance_first = false;\n        }\n\n        if (sy!=_height) {\n          if (sy>_height) get_resize(sx,sy,_depth,_spectrum,1).move_to(res);\n          else {\n            CImg tmp(sx,sy,_depth,_spectrum,0);\n            cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                               cimg_openmp_if(sy>=256 && _width*_depth*_spectrum>=256))\n            cimg_forXZC(tmp,x,z,v) {\n              for (unsigned int a = _height*sy, b = _height, c = sy, s = 0, t = 0; a; ) {\n                const unsigned int d = std::min(b,c);\n                a-=d; b-=d; c-=d;\n                if (instance_first) tmp(x,t,z,v)+=(Tfloat)(*this)(x,s,z,v)*d;\n                else tmp(x,t,z,v)+=(Tfloat)res(x,s,z,v)*d;\n                if (!b) { tmp(x,t++,z,v)\/=_height; b = _height; }\n                if (!c) { ++s; c = sy; }\n              }\n            }\n            tmp.move_to(res);\n          }\n          instance_first = false;\n        }\n\n        if (sz!=_depth) {\n          if (sz>_depth) get_resize(sx,sy,sz,_spectrum,1).move_to(res);\n          else {\n            CImg tmp(sx,sy,sz,_spectrum,0);\n            cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                               cimg_openmp_if(sz>=256 && _width*_height*_spectrum>=256))\n            cimg_forXYC(tmp,x,y,v) {\n              for (unsigned int a = _depth*sz, b = _depth, c = sz, s = 0, t = 0; a; ) {\n                const unsigned int d = std::min(b,c);\n                a-=d; b-=d; c-=d;\n                if (instance_first) tmp(x,y,t,v)+=(Tfloat)(*this)(x,y,s,v)*d;\n                else tmp(x,y,t,v)+=(Tfloat)res(x,y,s,v)*d;\n                if (!b) { tmp(x,y,t++,v)\/=_depth; b = _depth; }\n                if (!c) { ++s; c = sz; }\n              }\n            }\n            tmp.move_to(res);\n          }\n          instance_first = false;\n        }\n\n        if (sc!=_spectrum) {\n          if (sc>_spectrum) get_resize(sx,sy,sz,sc,1).move_to(res);\n          else {\n            CImg tmp(sx,sy,sz,sc,0);\n            cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                               cimg_openmp_if(sc>=256 && _width*_height*_depth>=256))\n            cimg_forXYZ(tmp,x,y,z) {\n              for (unsigned int a = _spectrum*sc, b = _spectrum, c = sc, s = 0, t = 0; a; ) {\n                const unsigned int d = std::min(b,c);\n                a-=d; b-=d; c-=d;\n                if (instance_first) tmp(x,y,z,t)+=(Tfloat)(*this)(x,y,z,s)*d;\n                else tmp(x,y,z,t)+=(Tfloat)res(x,y,z,s)*d;\n                if (!b) { tmp(x,y,z,t++)\/=_spectrum; b = _spectrum; }\n                if (!c) { ++s; c = sc; }\n              }\n            }\n            tmp.move_to(res);\n          }\n          instance_first = false;\n        }\n\n      } break;\n\n        \/\/ Linear interpolation.\n        \/\/\n      case 3 : {\n        CImg off(cimg::max(sx,sy,sz,sc));\n        CImg foff(off._width);\n        CImg resx, resy, resz, resc;\n        double curr, old;\n\n        if (sx!=_width) {\n          if (_width==1) get_resize(sx,_height,_depth,_spectrum,1).move_to(resx);\n          else if (_width>sx) get_resize(sx,_height,_depth,_spectrum,2).move_to(resx);\n          else {\n            const double fx = (!boundary_conditions && sx>_width)?(sx>1?(_width - 1.)\/(sx - 1):0):\n              (double)_width\/sx;\n            resx.assign(sx,_height,_depth,_spectrum);\n            curr = old = 0;\n            {\n              unsigned int *poff = off._data;\n              double *pfoff = foff._data;\n              cimg_forX(resx,x) {\n                *(pfoff++) = curr - (unsigned int)curr;\n                old = curr;\n                curr = std::min(width() - 1.,curr + fx);\n                *(poff++) = (unsigned int)curr - (unsigned int)old;\n              }\n            }\n            cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                               cimg_openmp_if(resx._width>=256 && resx._height*resx._depth*resx._spectrum>=256))\n              cimg_forYZC(resx,y,z,c) {\n              const T *ptrs = data(0,y,z,c), *const ptrsmax = ptrs + _width - 1;\n              T *ptrd = resx.data(0,y,z,c);\n              const unsigned int *poff = off._data;\n              const double *pfoff = foff._data;\n              cimg_forX(resx,x) {\n                const double alpha = *(pfoff++);\n                const T val1 = *ptrs, val2 = ptrssy) resx.get_resize(sx,sy,_depth,_spectrum,2).move_to(resy);\n            else {\n              const double fy = (!boundary_conditions && sy>_height)?(sy>1?(_height - 1.)\/(sy - 1):0):\n                (double)_height\/sy;\n              resy.assign(sx,sy,_depth,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forY(resy,y) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(height() - 1.,curr + fy);\n                  *(poff++) = sx*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resy._height>=256 && resy._width*resy._depth*resy._spectrum>=256))\n              cimg_forXZC(resy,x,z,c) {\n                const T *ptrs = resx.data(x,0,z,c), *const ptrsmax = ptrs + (_height - 1)*sx;\n                T *ptrd = resy.data(x,0,z,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forY(resy,y) {\n                  const double alpha = *(pfoff++);\n                  const T val1 = *ptrs, val2 = ptrssz) resy.get_resize(sx,sy,sz,_spectrum,2).move_to(resz);\n            else {\n              const double fz = (!boundary_conditions && sz>_depth)?(sz>1?(_depth - 1.)\/(sz - 1):0):\n                (double)_depth\/sz;\n              const unsigned int sxy = sx*sy;\n              resz.assign(sx,sy,sz,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forZ(resz,z) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(depth() - 1.,curr + fz);\n                  *(poff++) = sxy*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resz._depth>=256 && resz._width*resz._height*resz._spectrum>=256))\n              cimg_forXYC(resz,x,y,c) {\n                const T *ptrs = resy.data(x,y,0,c), *const ptrsmax = ptrs + (_depth - 1)*sxy;\n                T *ptrd = resz.data(x,y,0,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forZ(resz,z) {\n                  const double alpha = *(pfoff++);\n                  const T val1 = *ptrs, val2 = ptrssc) resz.get_resize(sx,sy,sz,sc,2).move_to(resc);\n            else {\n              const double fc = (!boundary_conditions && sc>_spectrum)?(sc>1?(_spectrum - 1.)\/(sc - 1):0):\n                (double)_spectrum\/sc;\n              const unsigned int sxyz = sx*sy*sz;\n              resc.assign(sx,sy,sz,sc);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forC(resc,c) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(spectrum() - 1.,curr + fc);\n                  *(poff++) = sxyz*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resc._spectrum>=256 && resc._width*resc._height*resc._depth>=256))\n              cimg_forXYZ(resc,x,y,z) {\n                const T *ptrs = resz.data(x,y,z,0), *const ptrsmax = ptrs + (_spectrum - 1)*sxyz;\n                T *ptrd = resc.data(x,y,z,0);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forC(resc,c) {\n                  const double alpha = *(pfoff++);\n                  const T val1 = *ptrs, val2 = ptrs resx, resy, resz, resc;\n        if (sx!=_width) {\n          if (sx<_width) get_resize(sx,_height,_depth,_spectrum,1).move_to(resx);\n          else {\n            resx.assign(sx,_height,_depth,_spectrum,(T)0);\n            const int dx = (int)(2*sx), dy = 2*width();\n            int err = (int)(dy + centering_x*(sx*dy\/width() - dy)), xs = 0;\n            cimg_forX(resx,x) if ((err-=dy)<=0) {\n              cimg_forYZC(resx,y,z,c) resx(x,y,z,c) = (*this)(xs,y,z,c);\n              ++xs;\n              err+=dx;\n            }\n          }\n        } else resx.assign(*this,true);\n\n        if (sy!=_height) {\n          if (sy<_height) resx.get_resize(sx,sy,_depth,_spectrum,1).move_to(resy);\n          else {\n            resy.assign(sx,sy,_depth,_spectrum,(T)0);\n            const int dx = (int)(2*sy), dy = 2*height();\n            int err = (int)(dy + centering_y*(sy*dy\/height() - dy)), ys = 0;\n            cimg_forY(resy,y) if ((err-=dy)<=0) {\n              cimg_forXZC(resy,x,z,c) resy(x,y,z,c) = resx(x,ys,z,c);\n              ++ys;\n              err+=dx;\n            }\n          }\n          resx.assign();\n        } else resy.assign(resx,true);\n\n        if (sz!=_depth) {\n          if (sz<_depth) resy.get_resize(sx,sy,sz,_spectrum,1).move_to(resz);\n          else {\n            resz.assign(sx,sy,sz,_spectrum,(T)0);\n            const int dx = (int)(2*sz), dy = 2*depth();\n            int err = (int)(dy + centering_z*(sz*dy\/depth() - dy)), zs = 0;\n            cimg_forZ(resz,z) if ((err-=dy)<=0) {\n              cimg_forXYC(resz,x,y,c) resz(x,y,z,c) = resy(x,y,zs,c);\n              ++zs;\n              err+=dx;\n            }\n          }\n          resy.assign();\n        } else resz.assign(resy,true);\n\n        if (sc!=_spectrum) {\n          if (sc<_spectrum) resz.get_resize(sx,sy,sz,sc,1).move_to(resc);\n          else {\n            resc.assign(sx,sy,sz,sc,(T)0);\n            const int dx = (int)(2*sc), dy = 2*spectrum();\n            int err = (int)(dy + centering_c*(sc*dy\/spectrum() - dy)), cs = 0;\n            cimg_forC(resc,c) if ((err-=dy)<=0) {\n              cimg_forXYZ(resc,x,y,z) resc(x,y,z,c) = resz(x,y,z,cs);\n              ++cs;\n              err+=dx;\n            }\n          }\n          resz.assign();\n        } else resc.assign(resz,true);\n\n        return resc._is_shared?(resz._is_shared?(resy._is_shared?(resx._is_shared?(+(*this)):resx):resy):resz):resc;\n      } break;\n\n        \/\/ Cubic interpolation.\n        \/\/\n      case 5 : {\n        const Tfloat vmin = (Tfloat)cimg::type::min(), vmax = (Tfloat)cimg::type::max();\n        CImg off(cimg::max(sx,sy,sz,sc));\n        CImg foff(off._width);\n        CImg resx, resy, resz, resc;\n        double curr, old;\n\n        if (sx!=_width) {\n          if (_width==1) get_resize(sx,_height,_depth,_spectrum,1).move_to(resx);\n          else {\n            if (_width>sx) get_resize(sx,_height,_depth,_spectrum,2).move_to(resx);\n            else {\n              const double fx = (!boundary_conditions && sx>_width)?(sx>1?(_width - 1.)\/(sx - 1):0):\n                (double)_width\/sx;\n              resx.assign(sx,_height,_depth,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forX(resx,x) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(width() - 1.,curr + fx);\n                  *(poff++) = (unsigned int)curr - (unsigned int)old;\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resx._width>=256 && resx._height*resx._depth*resx._spectrum>=256))\n              cimg_forYZC(resx,y,z,c) {\n                const T *const ptrs0 = data(0,y,z,c), *ptrs = ptrs0, *const ptrsmax = ptrs + (_width - 2);\n                T *ptrd = resx.data(0,y,z,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forX(resx,x) {\n                  const double\n                    t = *(pfoff++),\n                    val1 = (double)*ptrs,\n                    val0 = ptrs>ptrs0?(double)*(ptrs - 1):val1,\n                    val2 = ptrs<=ptrsmax?(double)*(ptrs + 1):val1,\n                    val3 = ptrsvmax?vmax:val);\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n        } else resx.assign(*this,true);\n\n        if (sy!=_height) {\n          if (_height==1) resx.get_resize(sx,sy,_depth,_spectrum,1).move_to(resy);\n          else {\n            if (_height>sy) resx.get_resize(sx,sy,_depth,_spectrum,2).move_to(resy);\n            else {\n              const double fy = (!boundary_conditions && sy>_height)?(sy>1?(_height - 1.)\/(sy - 1):0):\n                (double)_height\/sy;\n              resy.assign(sx,sy,_depth,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forY(resy,y) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(height() - 1.,curr + fy);\n                  *(poff++) = sx*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resy._height>=256 && resy._width*resy._depth*resy._spectrum>=256))\n              cimg_forXZC(resy,x,z,c) {\n                const T *const ptrs0 = resx.data(x,0,z,c), *ptrs = ptrs0, *const ptrsmax = ptrs + (_height - 2)*sx;\n                T *ptrd = resy.data(x,0,z,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forY(resy,y) {\n                  const double\n                    t = *(pfoff++),\n                    val1 = (double)*ptrs,\n                    val0 = ptrs>ptrs0?(double)*(ptrs - sx):val1,\n                    val2 = ptrs<=ptrsmax?(double)*(ptrs + sx):val1,\n                    val3 = ptrsvmax?vmax:val);\n                  ptrd+=sx;\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n          resx.assign();\n        } else resy.assign(resx,true);\n\n        if (sz!=_depth) {\n          if (_depth==1) resy.get_resize(sx,sy,sz,_spectrum,1).move_to(resz);\n          else {\n            if (_depth>sz) resy.get_resize(sx,sy,sz,_spectrum,2).move_to(resz);\n            else {\n              const double fz = (!boundary_conditions && sz>_depth)?(sz>1?(_depth - 1.)\/(sz - 1):0):\n                (double)_depth\/sz;\n              const unsigned int sxy = sx*sy;\n              resz.assign(sx,sy,sz,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forZ(resz,z) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(depth() - 1.,curr + fz);\n                  *(poff++) = sxy*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resz._depth>=256 && resz._width*resz._height*resz._spectrum>=256))\n              cimg_forXYC(resz,x,y,c) {\n                const T *const ptrs0 = resy.data(x,y,0,c), *ptrs = ptrs0, *const ptrsmax = ptrs + (_depth - 2)*sxy;\n                T *ptrd = resz.data(x,y,0,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forZ(resz,z) {\n                  const double\n                    t = *(pfoff++),\n                    val1 = (double)*ptrs,\n                    val0 = ptrs>ptrs0?(double)*(ptrs - sxy):val1,\n                    val2 = ptrs<=ptrsmax?(double)*(ptrs + sxy):val1,\n                    val3 = ptrsvmax?vmax:val);\n                  ptrd+=sxy;\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n          resy.assign();\n        } else resz.assign(resy,true);\n\n        if (sc!=_spectrum) {\n          if (_spectrum==1) resz.get_resize(sx,sy,sz,sc,1).move_to(resc);\n          else {\n            if (_spectrum>sc) resz.get_resize(sx,sy,sz,sc,2).move_to(resc);\n            else {\n              const double fc = (!boundary_conditions && sc>_spectrum)?(sc>1?(_spectrum - 1.)\/(sc - 1):0):\n                (double)_spectrum\/sc;\n              const unsigned int sxyz = sx*sy*sz;\n              resc.assign(sx,sy,sz,sc);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forC(resc,c) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(spectrum() - 1.,curr + fc);\n                  *(poff++) = sxyz*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resc._spectrum>=256 && resc._width*resc._height*resc._depth>=256))\n              cimg_forXYZ(resc,x,y,z) {\n                const T *const ptrs0 = resz.data(x,y,z,0), *ptrs = ptrs0, *const ptrsmax = ptrs + (_spectrum - 2)*sxyz;\n                T *ptrd = resc.data(x,y,z,0);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forC(resc,c) {\n                  const double\n                    t = *(pfoff++),\n                    val1 = (double)*ptrs,\n                    val0 = ptrs>ptrs0?(double)*(ptrs - sxyz):val1,\n                    val2 = ptrs<=ptrsmax?(double)*(ptrs + sxyz):val1,\n                    val3 = ptrsvmax?vmax:val);\n                  ptrd+=sxyz;\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n          resz.assign();\n        } else resc.assign(resz,true);\n\n        return resc._is_shared?(resz._is_shared?(resy._is_shared?(resx._is_shared?(+(*this)):resx):resy):resz):resc;\n      } break;\n\n        \/\/ Lanczos interpolation.\n        \/\/\n      case 6 : {\n        const double vmin = (double)cimg::type::min(), vmax = (double)cimg::type::max();\n        CImg off(cimg::max(sx,sy,sz,sc));\n        CImg foff(off._width);\n        CImg resx, resy, resz, resc;\n        double curr, old;\n\n        if (sx!=_width) {\n          if (_width==1) get_resize(sx,_height,_depth,_spectrum,1).move_to(resx);\n          else {\n            if (_width>sx) get_resize(sx,_height,_depth,_spectrum,2).move_to(resx);\n            else {\n              const double fx = (!boundary_conditions && sx>_width)?(sx>1?(_width - 1.)\/(sx - 1):0):\n                (double)_width\/sx;\n              resx.assign(sx,_height,_depth,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forX(resx,x) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(width() - 1.,curr + fx);\n                  *(poff++) = (unsigned int)curr - (unsigned int)old;\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resx._width>=256 && resx._height*resx._depth*resx._spectrum>=256))\n              cimg_forYZC(resx,y,z,c) {\n                const T *const ptrs0 = data(0,y,z,c), *ptrs = ptrs0, *const ptrsmin = ptrs0 + 1,\n                  *const ptrsmax = ptrs0 + (_width - 2);\n                T *ptrd = resx.data(0,y,z,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forX(resx,x) {\n                  const double\n                    t = *(pfoff++),\n                    w0 = _cimg_lanczos(t + 2),\n                    w1 = _cimg_lanczos(t + 1),\n                    w2 = _cimg_lanczos(t),\n                    w3 = _cimg_lanczos(t - 1),\n                    w4 = _cimg_lanczos(t - 2),\n                    val2 = (double)*ptrs,\n                    val1 = ptrs>=ptrsmin?(double)*(ptrs - 1):val2,\n                    val0 = ptrs>ptrsmin?(double)*(ptrs - 2):val1,\n                    val3 = ptrs<=ptrsmax?(double)*(ptrs + 1):val2,\n                    val4 = ptrsvmax?vmax:val);\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n        } else resx.assign(*this,true);\n\n        if (sy!=_height) {\n          if (_height==1) resx.get_resize(sx,sy,_depth,_spectrum,1).move_to(resy);\n          else {\n            if (_height>sy) resx.get_resize(sx,sy,_depth,_spectrum,2).move_to(resy);\n            else {\n              const double fy = (!boundary_conditions && sy>_height)?(sy>1?(_height - 1.)\/(sy - 1):0):\n                (double)_height\/sy;\n              resy.assign(sx,sy,_depth,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forY(resy,y) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(height() - 1.,curr + fy);\n                  *(poff++) = sx*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resy._height>=256 && resy._width*resy._depth*resy._spectrum>=256))\n              cimg_forXZC(resy,x,z,c) {\n                const T *const ptrs0 = resx.data(x,0,z,c), *ptrs = ptrs0, *const ptrsmin = ptrs0 + sx,\n                  *const ptrsmax = ptrs0 + (_height - 2)*sx;\n                T *ptrd = resy.data(x,0,z,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forY(resy,y) {\n                  const double\n                    t = *(pfoff++),\n                    w0 = _cimg_lanczos(t + 2),\n                    w1 = _cimg_lanczos(t + 1),\n                    w2 = _cimg_lanczos(t),\n                    w3 = _cimg_lanczos(t - 1),\n                    w4 = _cimg_lanczos(t - 2),\n                    val2 = (double)*ptrs,\n                    val1 = ptrs>=ptrsmin?(double)*(ptrs - sx):val2,\n                    val0 = ptrs>ptrsmin?(double)*(ptrs - 2*sx):val1,\n                    val3 = ptrs<=ptrsmax?(double)*(ptrs + sx):val2,\n                    val4 = ptrsvmax?vmax:val);\n                  ptrd+=sx;\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n          resx.assign();\n        } else resy.assign(resx,true);\n\n        if (sz!=_depth) {\n          if (_depth==1) resy.get_resize(sx,sy,sz,_spectrum,1).move_to(resz);\n          else {\n            if (_depth>sz) resy.get_resize(sx,sy,sz,_spectrum,2).move_to(resz);\n            else {\n              const double fz = (!boundary_conditions && sz>_depth)?(sz>1?(_depth - 1.)\/(sz - 1):0):\n                (double)_depth\/sz;\n              const unsigned int sxy = sx*sy;\n              resz.assign(sx,sy,sz,_spectrum);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forZ(resz,z) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(depth() - 1.,curr + fz);\n                  *(poff++) = sxy*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resz._depth>=256 && resz._width*resz._height*resz._spectrum>=256))\n              cimg_forXYC(resz,x,y,c) {\n                const T *const ptrs0 = resy.data(x,y,0,c), *ptrs = ptrs0, *const ptrsmin = ptrs0 + sxy,\n                  *const ptrsmax = ptrs0 + (_depth - 2)*sxy;\n                T *ptrd = resz.data(x,y,0,c);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forZ(resz,z) {\n                  const double\n                    t = *(pfoff++),\n                    w0 = _cimg_lanczos(t + 2),\n                    w1 = _cimg_lanczos(t + 1),\n                    w2 = _cimg_lanczos(t),\n                    w3 = _cimg_lanczos(t - 1),\n                    w4 = _cimg_lanczos(t - 2),\n                    val2 = (double)*ptrs,\n                    val1 = ptrs>=ptrsmin?(double)*(ptrs - sxy):val2,\n                    val0 = ptrs>ptrsmin?(double)*(ptrs - 2*sxy):val1,\n                    val3 = ptrs<=ptrsmax?(double)*(ptrs + sxy):val2,\n                    val4 = ptrsvmax?vmax:val);\n                  ptrd+=sxy;\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n          resy.assign();\n        } else resz.assign(resy,true);\n\n        if (sc!=_spectrum) {\n          if (_spectrum==1) resz.get_resize(sx,sy,sz,sc,1).move_to(resc);\n          else {\n            if (_spectrum>sc) resz.get_resize(sx,sy,sz,sc,2).move_to(resc);\n            else {\n              const double fc = (!boundary_conditions && sc>_spectrum)?(sc>1?(_spectrum - 1.)\/(sc - 1):0):\n                (double)_spectrum\/sc;\n              const unsigned int sxyz = sx*sy*sz;\n              resc.assign(sx,sy,sz,sc);\n              curr = old = 0;\n              {\n                unsigned int *poff = off._data;\n                double *pfoff = foff._data;\n                cimg_forC(resc,c) {\n                  *(pfoff++) = curr - (unsigned int)curr;\n                  old = curr;\n                  curr = std::min(spectrum() - 1.,curr + fc);\n                  *(poff++) = sxyz*((unsigned int)curr - (unsigned int)old);\n                }\n              }\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(3)\n                                 cimg_openmp_if(resc._spectrum>=256 && resc._width*resc._height*resc._depth>=256))\n              cimg_forXYZ(resc,x,y,z) {\n                const T *const ptrs0 = resz.data(x,y,z,0), *ptrs = ptrs0, *const ptrsmin = ptrs0 + sxyz,\n                  *const ptrsmax = ptrs + (_spectrum - 2)*sxyz;\n                T *ptrd = resc.data(x,y,z,0);\n                const unsigned int *poff = off._data;\n                const double *pfoff = foff._data;\n                cimg_forC(resc,c) {\n                  const double\n                    t = *(pfoff++),\n                    w0 = _cimg_lanczos(t + 2),\n                    w1 = _cimg_lanczos(t + 1),\n                    w2 = _cimg_lanczos(t),\n                    w3 = _cimg_lanczos(t - 1),\n                    w4 = _cimg_lanczos(t - 2),\n                    val2 = (double)*ptrs,\n                    val1 = ptrs>=ptrsmin?(double)*(ptrs - sxyz):val2,\n                    val0 = ptrs>ptrsmin?(double)*(ptrs - 2*sxyz):val1,\n                    val3 = ptrs<=ptrsmax?(double)*(ptrs + sxyz):val2,\n                    val4 = ptrsvmax?vmax:val);\n                  ptrd+=sxyz;\n                  ptrs+=*(poff++);\n                }\n              }\n            }\n          }\n          resz.assign();\n        } else resc.assign(resz,true);\n\n        return resc._is_shared?(resz._is_shared?(resy._is_shared?(resx._is_shared?(+(*this)):resx):resy):resz):resc;\n      } break;\n\n        \/\/ Unknown interpolation.\n        \/\/\n      default :\n        throw CImgArgumentException(_cimg_instance\n                                    \"resize(): Invalid specified interpolation %d \"\n                                    \"(should be { -1=raw | 0=none | 1=nearest | 2=average | 3=linear | 4=grid | \"\n                                    \"5=cubic | 6=lanczos }).\",\n                                    cimg_instance,\n                                    interpolation_type);\n      }\n      return res;\n    }","target":0,"code_token_length":12213,"total_token_length":12449,"max_tokens_setting":28000}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..1a6e5b39280fe7393bc2730cb2d1f6ba0e12deee
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a5b3bf72acf3708ced6d9f87749dcb2a8774c1358cf758483fd2c4b85b738060
+size 533575
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..f1d57926298086189556657391d6414e67a65751
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.jsonl
@@ -0,0 +1,183 @@
+{"idx":338772,"func":"int net_client_init(const char *device, const char *p)\n\n{\n\n    static const char * const fd_params[] = {\n\n        \"vlan\", \"name\", \"fd\", NULL\n\n    };\n\n    char buf[1024];\n\n    int vlan_id, ret;\n\n    VLANState *vlan;\n\n    char *name = NULL;\n\n\n\n    vlan_id = 0;\n\n    if (get_param_value(buf, sizeof(buf), \"vlan\", p)) {\n\n        vlan_id = strtol(buf, NULL, 0);\n\n    }\n\n    vlan = qemu_find_vlan(vlan_id);\n\n\n\n    if (get_param_value(buf, sizeof(buf), \"name\", p)) {\n\n        name = strdup(buf);\n\n    }\n\n    if (!strcmp(device, \"nic\")) {\n\n        static const char * const nic_params[] = {\n\n            \"vlan\", \"name\", \"macaddr\", \"model\", NULL\n\n        };\n\n        NICInfo *nd;\n\n        uint8_t *macaddr;\n\n        int idx = nic_get_free_idx();\n\n\n\n        if (check_params(nic_params, p) < 0) {\n\n            fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                    buf, p);\n\n            return -1;\n\n        }\n\n        if (idx == -1 || nb_nics >= MAX_NICS) {\n\n            fprintf(stderr, \"Too Many NICs\\n\");\n\n            ret = -1;\n\n            goto out;\n\n        }\n\n        nd = &nd_table[idx];\n\n        macaddr = nd->macaddr;\n\n        macaddr[0] = 0x52;\n\n        macaddr[1] = 0x54;\n\n        macaddr[2] = 0x00;\n\n        macaddr[3] = 0x12;\n\n        macaddr[4] = 0x34;\n\n        macaddr[5] = 0x56 + idx;\n\n\n\n        if (get_param_value(buf, sizeof(buf), \"macaddr\", p)) {\n\n            if (parse_macaddr(macaddr, buf) < 0) {\n\n                fprintf(stderr, \"invalid syntax for ethernet address\\n\");\n\n                ret = -1;\n\n                goto out;\n\n            }\n\n        }\n\n        if (get_param_value(buf, sizeof(buf), \"model\", p)) {\n\n            nd->model = strdup(buf);\n\n        }\n\n        nd->vlan = vlan;\n\n        nd->name = name;\n\n        nd->used = 1;\n\n        name = NULL;\n\n        nb_nics++;\n\n        vlan->nb_guest_devs++;\n\n        ret = idx;\n\n    } else\n\n    if (!strcmp(device, \"none\")) {\n\n        if (*p != '\\0') {\n\n            fprintf(stderr, \"qemu: 'none' takes no parameters\\n\");\n\n            return -1;\n\n        }\n\n        \/* does nothing. It is needed to signal that no network cards\n\n           are wanted *\/\n\n        ret = 0;\n\n    } else\n\n#ifdef CONFIG_SLIRP\n\n    if (!strcmp(device, \"user\")) {\n\n        static const char * const slirp_params[] = {\n\n            \"vlan\", \"name\", \"hostname\", \"restrict\", \"ip\", NULL\n\n        };\n\n        if (check_params(slirp_params, p) < 0) {\n\n            fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                    buf, p);\n\n            return -1;\n\n        }\n\n        if (get_param_value(buf, sizeof(buf), \"hostname\", p)) {\n\n            pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);\n\n        }\n\n        if (get_param_value(buf, sizeof(buf), \"restrict\", p)) {\n\n            slirp_restrict = (buf[0] == 'y') ? 1 : 0;\n\n        }\n\n        if (get_param_value(buf, sizeof(buf), \"ip\", p)) {\n\n            slirp_ip = strdup(buf);\n\n        }\n\n        vlan->nb_host_devs++;\n\n        ret = net_slirp_init(vlan, device, name);\n\n    } else if (!strcmp(device, \"channel\")) {\n\n        long port;\n\n        char name[20], *devname;\n\n        struct VMChannel *vmc;\n\n\n\n        port = strtol(p, &devname, 10);\n\n        devname++;\n\n        if (port < 1 || port > 65535) {\n\n            fprintf(stderr, \"vmchannel wrong port number\\n\");\n\n            ret = -1;\n\n            goto out;\n\n        }\n\n        vmc = malloc(sizeof(struct VMChannel));\n\n        snprintf(name, 20, \"vmchannel%ld\", port);\n\n        vmc->hd = qemu_chr_open(name, devname, NULL);\n\n        if (!vmc->hd) {\n\n            fprintf(stderr, \"qemu: could not open vmchannel device\"\n\n                    \"'%s'\\n\", devname);\n\n            ret = -1;\n\n            goto out;\n\n        }\n\n        vmc->port = port;\n\n        slirp_add_exec(3, vmc->hd, 4, port);\n\n        qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_read,\n\n                NULL, vmc);\n\n        ret = 0;\n\n    } else\n\n#endif\n\n#ifdef _WIN32\n\n    if (!strcmp(device, \"tap\")) {\n\n        static const char * const tap_params[] = {\n\n            \"vlan\", \"name\", \"ifname\", NULL\n\n        };\n\n        char ifname[64];\n\n\n\n        if (check_params(tap_params, p) < 0) {\n\n            fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                    buf, p);\n\n            return -1;\n\n        }\n\n        if (get_param_value(ifname, sizeof(ifname), \"ifname\", p) <= 0) {\n\n            fprintf(stderr, \"tap: no interface name\\n\");\n\n            ret = -1;\n\n            goto out;\n\n        }\n\n        vlan->nb_host_devs++;\n\n        ret = tap_win32_init(vlan, device, name, ifname);\n\n    } else\n\n#elif defined (_AIX)\n\n#else\n\n    if (!strcmp(device, \"tap\")) {\n\n        char ifname[64];\n\n        char setup_script[1024], down_script[1024];\n\n        int fd;\n\n        vlan->nb_host_devs++;\n\n        if (get_param_value(buf, sizeof(buf), \"fd\", p) > 0) {\n\n            if (check_params(fd_params, p) < 0) {\n\n                fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                        buf, p);\n\n                return -1;\n\n            }\n\n            fd = strtol(buf, NULL, 0);\n\n            fcntl(fd, F_SETFL, O_NONBLOCK);\n\n            net_tap_fd_init(vlan, device, name, fd);\n\n            ret = 0;\n\n        } else {\n\n            static const char * const tap_params[] = {\n\n                \"vlan\", \"name\", \"ifname\", \"script\", \"downscript\", NULL\n\n            };\n\n            if (check_params(tap_params, p) < 0) {\n\n                fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                        buf, p);\n\n                return -1;\n\n            }\n\n            if (get_param_value(ifname, sizeof(ifname), \"ifname\", p) <= 0) {\n\n                ifname[0] = '\\0';\n\n            }\n\n            if (get_param_value(setup_script, sizeof(setup_script), \"script\", p) == 0) {\n\n                pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);\n\n            }\n\n            if (get_param_value(down_script, sizeof(down_script), \"downscript\", p) == 0) {\n\n                pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT);\n\n            }\n\n            ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script);\n\n        }\n\n    } else\n\n#endif\n\n    if (!strcmp(device, \"socket\")) {\n\n        if (get_param_value(buf, sizeof(buf), \"fd\", p) > 0) {\n\n            int fd;\n\n            if (check_params(fd_params, p) < 0) {\n\n                fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                        buf, p);\n\n                return -1;\n\n            }\n\n            fd = strtol(buf, NULL, 0);\n\n            ret = -1;\n\n            if (net_socket_fd_init(vlan, device, name, fd, 1))\n\n                ret = 0;\n\n        } else if (get_param_value(buf, sizeof(buf), \"listen\", p) > 0) {\n\n            static const char * const listen_params[] = {\n\n                \"vlan\", \"name\", \"listen\", NULL\n\n            };\n\n            if (check_params(listen_params, p) < 0) {\n\n                fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                        buf, p);\n\n                return -1;\n\n            }\n\n            ret = net_socket_listen_init(vlan, device, name, buf);\n\n        } else if (get_param_value(buf, sizeof(buf), \"connect\", p) > 0) {\n\n            static const char * const connect_params[] = {\n\n                \"vlan\", \"name\", \"connect\", NULL\n\n            };\n\n            if (check_params(connect_params, p) < 0) {\n\n                fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                        buf, p);\n\n                return -1;\n\n            }\n\n            ret = net_socket_connect_init(vlan, device, name, buf);\n\n        } else if (get_param_value(buf, sizeof(buf), \"mcast\", p) > 0) {\n\n            static const char * const mcast_params[] = {\n\n                \"vlan\", \"name\", \"mcast\", NULL\n\n            };\n\n            if (check_params(mcast_params, p) < 0) {\n\n                fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                        buf, p);\n\n                return -1;\n\n            }\n\n            ret = net_socket_mcast_init(vlan, device, name, buf);\n\n        } else {\n\n            fprintf(stderr, \"Unknown socket options: %s\\n\", p);\n\n            ret = -1;\n\n            goto out;\n\n        }\n\n        vlan->nb_host_devs++;\n\n    } else\n\n#ifdef CONFIG_VDE\n\n    if (!strcmp(device, \"vde\")) {\n\n        static const char * const vde_params[] = {\n\n            \"vlan\", \"name\", \"sock\", \"port\", \"group\", \"mode\", NULL\n\n        };\n\n        char vde_sock[1024], vde_group[512];\n\n\tint vde_port, vde_mode;\n\n\n\n        if (check_params(vde_params, p) < 0) {\n\n            fprintf(stderr, \"qemu: invalid parameter '%s' in '%s'\\n\",\n\n                    buf, p);\n\n            return -1;\n\n        }\n\n        vlan->nb_host_devs++;\n\n        if (get_param_value(vde_sock, sizeof(vde_sock), \"sock\", p) <= 0) {\n\n\t    vde_sock[0] = '\\0';\n\n\t}\n\n\tif (get_param_value(buf, sizeof(buf), \"port\", p) > 0) {\n\n\t    vde_port = strtol(buf, NULL, 10);\n\n\t} else {\n\n\t    vde_port = 0;\n\n\t}\n\n\tif (get_param_value(vde_group, sizeof(vde_group), \"group\", p) <= 0) {\n\n\t    vde_group[0] = '\\0';\n\n\t}\n\n\tif (get_param_value(buf, sizeof(buf), \"mode\", p) > 0) {\n\n\t    vde_mode = strtol(buf, NULL, 8);\n\n\t} else {\n\n\t    vde_mode = 0700;\n\n\t}\n\n\tret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode);\n\n    } else\n\n#endif\n\n    if (!strcmp(device, \"dump\")) {\n\n        int len = 65536;\n\n\n\n        if (get_param_value(buf, sizeof(buf), \"len\", p) > 0) {\n\n            len = strtol(buf, NULL, 0);\n\n        }\n\n        if (!get_param_value(buf, sizeof(buf), \"file\", p)) {\n\n            snprintf(buf, sizeof(buf), \"qemu-vlan%d.pcap\", vlan_id);\n\n        }\n\n        ret = net_dump_init(vlan, device, name, buf, len);\n\n    } else {\n\n        fprintf(stderr, \"Unknown network device: %s\\n\", device);\n\n        ret = -1;\n\n        goto out;\n\n    }\n\n    if (ret < 0) {\n\n        fprintf(stderr, \"Could not initialize device '%s'\\n\", device);\n\n    }\n\nout:\n\n    if (name)\n\n        free(name);\n\n    return ret;\n\n}\n","target":0,"code_token_length":2673,"total_token_length":2909,"max_tokens_setting":4096}
+{"idx":380984,"func":"int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)\n{\n\tconst struct x86_emulate_ops *ops = ctxt->ops;\n\tint rc = X86EMUL_CONTINUE;\n\tint saved_dst_type = ctxt->dst.type;\n\n\tctxt->mem_read.pos = 0;\n\n\t\/* LOCK prefix is allowed only with some instructions *\/\n\tif (ctxt->lock_prefix && (!(ctxt->d & Lock) || ctxt->dst.type != OP_MEM)) {\n\t\trc = emulate_ud(ctxt);\n\t\tgoto done;\n\t}\n\n\tif ((ctxt->d & SrcMask) == SrcMemFAddr && ctxt->src.type != OP_MEM) {\n\t\trc = emulate_ud(ctxt);\n\t\tgoto done;\n\t}\n\n\tif (unlikely(ctxt->d &\n\t\t     (No64|Undefined|Sse|Mmx|Intercept|CheckPerm|Priv|Prot|String))) {\n\t\tif ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) ||\n\t\t\t\t(ctxt->d & Undefined)) {\n\t\t\trc = emulate_ud(ctxt);\n\t\t\tgoto done;\n\t\t}\n\n\t\tif (((ctxt->d & (Sse|Mmx)) && ((ops->get_cr(ctxt, 0) & X86_CR0_EM)))\n\t\t    || ((ctxt->d & Sse) && !(ops->get_cr(ctxt, 4) & X86_CR4_OSFXSR))) {\n\t\t\trc = emulate_ud(ctxt);\n\t\t\tgoto done;\n\t\t}\n\n\t\tif ((ctxt->d & (Sse|Mmx)) && (ops->get_cr(ctxt, 0) & X86_CR0_TS)) {\n\t\t\trc = emulate_nm(ctxt);\n\t\t\tgoto done;\n\t\t}\n\n\t\tif (ctxt->d & Mmx) {\n\t\t\trc = flush_pending_x87_faults(ctxt);\n\t\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\t\tgoto done;\n\t\t\t\/*\n\t\t\t * Now that we know the fpu is exception safe, we can fetch\n\t\t\t * operands from it.\n\t\t\t *\/\n\t\t\tfetch_possible_mmx_operand(ctxt, &ctxt->src);\n\t\t\tfetch_possible_mmx_operand(ctxt, &ctxt->src2);\n\t\t\tif (!(ctxt->d & Mov))\n\t\t\t\tfetch_possible_mmx_operand(ctxt, &ctxt->dst);\n\t\t}\n\n\t\tif (unlikely(ctxt->guest_mode) && (ctxt->d & Intercept)) {\n\t\t\trc = emulator_check_intercept(ctxt, ctxt->intercept,\n\t\t\t\t\t\t      X86_ICPT_PRE_EXCEPT);\n\t\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\t\tgoto done;\n\t\t}\n\n\t\t\/* Privileged instruction can be executed only in CPL=0 *\/\n\t\tif ((ctxt->d & Priv) && ops->cpl(ctxt)) {\n\t\t\tif (ctxt->d & PrivUD)\n\t\t\t\trc = emulate_ud(ctxt);\n\t\t\telse\n\t\t\t\trc = emulate_gp(ctxt, 0);\n\t\t\tgoto done;\n\t\t}\n\n\t\t\/* Instruction can only be executed in protected mode *\/\n\t\tif ((ctxt->d & Prot) && ctxt->mode < X86EMUL_MODE_PROT16) {\n\t\t\trc = emulate_ud(ctxt);\n\t\t\tgoto done;\n\t\t}\n\n\t\t\/* Do instruction specific permission checks *\/\n\t\tif (ctxt->d & CheckPerm) {\n\t\t\trc = ctxt->check_perm(ctxt);\n\t\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\t\tgoto done;\n\t\t}\n\n\t\tif (unlikely(ctxt->guest_mode) && (ctxt->d & Intercept)) {\n\t\t\trc = emulator_check_intercept(ctxt, ctxt->intercept,\n\t\t\t\t\t\t      X86_ICPT_POST_EXCEPT);\n\t\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\t\tgoto done;\n\t\t}\n\n\t\tif (ctxt->rep_prefix && (ctxt->d & String)) {\n\t\t\t\/* All REP prefixes have the same first termination condition *\/\n\t\t\tif (address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) == 0) {\n\t\t\t\tctxt->eip = ctxt->_eip;\n\t\t\t\tctxt->eflags &= ~EFLG_RF;\n\t\t\t\tgoto done;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ((ctxt->src.type == OP_MEM) && !(ctxt->d & NoAccess)) {\n\t\trc = segmented_read(ctxt, ctxt->src.addr.mem,\n\t\t\t\t    ctxt->src.valptr, ctxt->src.bytes);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t\tctxt->src.orig_val64 = ctxt->src.val64;\n\t}\n\n\tif (ctxt->src2.type == OP_MEM) {\n\t\trc = segmented_read(ctxt, ctxt->src2.addr.mem,\n\t\t\t\t    &ctxt->src2.val, ctxt->src2.bytes);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t}\n\n\tif ((ctxt->d & DstMask) == ImplicitOps)\n\t\tgoto special_insn;\n\n\n\tif ((ctxt->dst.type == OP_MEM) && !(ctxt->d & Mov)) {\n\t\t\/* optimisation - avoid slow emulated read if Mov *\/\n\t\trc = segmented_read(ctxt, ctxt->dst.addr.mem,\n\t\t\t\t   &ctxt->dst.val, ctxt->dst.bytes);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t}\n\tctxt->dst.orig_val = ctxt->dst.val;\n\nspecial_insn:\n\n\tif (unlikely(ctxt->guest_mode) && (ctxt->d & Intercept)) {\n\t\trc = emulator_check_intercept(ctxt, ctxt->intercept,\n\t\t\t\t\t      X86_ICPT_POST_MEMACCESS);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t}\n\n\tif (ctxt->rep_prefix && (ctxt->d & String))\n\t\tctxt->eflags |= EFLG_RF;\n\telse\n\t\tctxt->eflags &= ~EFLG_RF;\n\n\tif (ctxt->execute) {\n\t\tif (ctxt->d & Fastop) {\n\t\t\tvoid (*fop)(struct fastop *) = (void *)ctxt->execute;\n\t\t\trc = fastop(ctxt, fop);\n\t\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\t\tgoto done;\n\t\t\tgoto writeback;\n\t\t}\n\t\trc = ctxt->execute(ctxt);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t\tgoto writeback;\n\t}\n\n\tif (ctxt->opcode_len == 2)\n\t\tgoto twobyte_insn;\n\telse if (ctxt->opcode_len == 3)\n\t\tgoto threebyte_insn;\n\n\tswitch (ctxt->b) {\n\tcase 0x63:\t\t\/* movsxd *\/\n\t\tif (ctxt->mode != X86EMUL_MODE_PROT64)\n\t\t\tgoto cannot_emulate;\n\t\tctxt->dst.val = (s32) ctxt->src.val;\n\t\tbreak;\n\tcase 0x70 ... 0x7f: \/* jcc (short) *\/\n\t\tif (test_cc(ctxt->b, ctxt->eflags))\n\t\t\trc = jmp_rel(ctxt, ctxt->src.val);\n\t\tbreak;\n\tcase 0x8d: \/* lea r16\/r32, m *\/\n\t\tctxt->dst.val = ctxt->src.addr.mem.ea;\n\t\tbreak;\n\tcase 0x90 ... 0x97: \/* nop \/ xchg reg, rax *\/\n\t\tif (ctxt->dst.addr.reg == reg_rmw(ctxt, VCPU_REGS_RAX))\n\t\t\tctxt->dst.type = OP_NONE;\n\t\telse\n\t\t\trc = em_xchg(ctxt);\n\t\tbreak;\n\tcase 0x98: \/* cbw\/cwde\/cdqe *\/\n\t\tswitch (ctxt->op_bytes) {\n\t\tcase 2: ctxt->dst.val = (s8)ctxt->dst.val; break;\n\t\tcase 4: ctxt->dst.val = (s16)ctxt->dst.val; break;\n\t\tcase 8: ctxt->dst.val = (s32)ctxt->dst.val; break;\n\t\t}\n\t\tbreak;\n\tcase 0xcc:\t\t\/* int3 *\/\n\t\trc = emulate_int(ctxt, 3);\n\t\tbreak;\n\tcase 0xcd:\t\t\/* int n *\/\n\t\trc = emulate_int(ctxt, ctxt->src.val);\n\t\tbreak;\n\tcase 0xce:\t\t\/* into *\/\n\t\tif (ctxt->eflags & EFLG_OF)\n\t\t\trc = emulate_int(ctxt, 4);\n\t\tbreak;\n\tcase 0xe9: \/* jmp rel *\/\n\tcase 0xeb: \/* jmp rel short *\/\n\t\trc = jmp_rel(ctxt, ctxt->src.val);\n\t\tctxt->dst.type = OP_NONE; \/* Disable writeback. *\/\n\t\tbreak;\n\tcase 0xf4:              \/* hlt *\/\n\t\tctxt->ops->halt(ctxt);\n\t\tbreak;\n\tcase 0xf5:\t\/* cmc *\/\n\t\t\/* complement carry flag from eflags reg *\/\n\t\tctxt->eflags ^= EFLG_CF;\n\t\tbreak;\n\tcase 0xf8: \/* clc *\/\n\t\tctxt->eflags &= ~EFLG_CF;\n\t\tbreak;\n\tcase 0xf9: \/* stc *\/\n\t\tctxt->eflags |= EFLG_CF;\n\t\tbreak;\n\tcase 0xfc: \/* cld *\/\n\t\tctxt->eflags &= ~EFLG_DF;\n\t\tbreak;\n\tcase 0xfd: \/* std *\/\n\t\tctxt->eflags |= EFLG_DF;\n\t\tbreak;\n\tdefault:\n\t\tgoto cannot_emulate;\n\t}\n\n\tif (rc != X86EMUL_CONTINUE)\n\t\tgoto done;\n\nwriteback:\n\tif (ctxt->d & SrcWrite) {\n\t\tBUG_ON(ctxt->src.type == OP_MEM || ctxt->src.type == OP_MEM_STR);\n\t\trc = writeback(ctxt, &ctxt->src);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t}\n\tif (!(ctxt->d & NoWrite)) {\n\t\trc = writeback(ctxt, &ctxt->dst);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tgoto done;\n\t}\n\n\t\/*\n\t * restore dst type in case the decoding will be reused\n\t * (happens for string instruction )\n\t *\/\n\tctxt->dst.type = saved_dst_type;\n\n\tif ((ctxt->d & SrcMask) == SrcSI)\n\t\tstring_addr_inc(ctxt, VCPU_REGS_RSI, &ctxt->src);\n\n\tif ((ctxt->d & DstMask) == DstDI)\n\t\tstring_addr_inc(ctxt, VCPU_REGS_RDI, &ctxt->dst);\n\n\tif (ctxt->rep_prefix && (ctxt->d & String)) {\n\t\tunsigned int count;\n\t\tstruct read_cache *r = &ctxt->io_read;\n\t\tif ((ctxt->d & SrcMask) == SrcSI)\n\t\t\tcount = ctxt->src.count;\n\t\telse\n\t\t\tcount = ctxt->dst.count;\n\t\tregister_address_increment(ctxt, reg_rmw(ctxt, VCPU_REGS_RCX),\n\t\t\t\t-count);\n\n\t\tif (!string_insn_completed(ctxt)) {\n\t\t\t\/*\n\t\t\t * Re-enter guest when pio read ahead buffer is empty\n\t\t\t * or, if it is not used, after each 1024 iteration.\n\t\t\t *\/\n\t\t\tif ((r->end != 0 || reg_read(ctxt, VCPU_REGS_RCX) & 0x3ff) &&\n\t\t\t    (r->end == 0 || r->end != r->pos)) {\n\t\t\t\t\/*\n\t\t\t\t * Reset read cache. Usually happens before\n\t\t\t\t * decode, but since instruction is restarted\n\t\t\t\t * we have to do it here.\n\t\t\t\t *\/\n\t\t\t\tctxt->mem_read.end = 0;\n\t\t\t\twriteback_registers(ctxt);\n\t\t\t\treturn EMULATION_RESTART;\n\t\t\t}\n\t\t\tgoto done; \/* skip rip writeback *\/\n\t\t}\n\t\tctxt->eflags &= ~EFLG_RF;\n\t}\n\n\tctxt->eip = ctxt->_eip;\n\ndone:\n\tif (rc == X86EMUL_PROPAGATE_FAULT) {\n\t\tWARN_ON(ctxt->exception.vector > 0x1f);\n\t\tctxt->have_exception = true;\n\t}\n\tif (rc == X86EMUL_INTERCEPTED)\n\t\treturn EMULATION_INTERCEPTED;\n\n\tif (rc == X86EMUL_CONTINUE)\n\t\twriteback_registers(ctxt);\n\n\treturn (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK;\n\ntwobyte_insn:\n\tswitch (ctxt->b) {\n\tcase 0x09:\t\t\/* wbinvd *\/\n\t\t(ctxt->ops->wbinvd)(ctxt);\n\t\tbreak;\n\tcase 0x08:\t\t\/* invd *\/\n\tcase 0x0d:\t\t\/* GrpP (prefetch) *\/\n\tcase 0x18:\t\t\/* Grp16 (prefetch\/nop) *\/\n\tcase 0x1f:\t\t\/* nop *\/\n\t\tbreak;\n\tcase 0x20: \/* mov cr, reg *\/\n\t\tctxt->dst.val = ops->get_cr(ctxt, ctxt->modrm_reg);\n\t\tbreak;\n\tcase 0x21: \/* mov from dr to reg *\/\n\t\tops->get_dr(ctxt, ctxt->modrm_reg, &ctxt->dst.val);\n\t\tbreak;\n\tcase 0x40 ... 0x4f:\t\/* cmov *\/\n\t\tif (test_cc(ctxt->b, ctxt->eflags))\n\t\t\tctxt->dst.val = ctxt->src.val;\n\t\telse if (ctxt->mode != X86EMUL_MODE_PROT64 ||\n\t\t\t ctxt->op_bytes != 4)\n\t\t\tctxt->dst.type = OP_NONE; \/* no writeback *\/\n\t\tbreak;\n\tcase 0x80 ... 0x8f: \/* jnz rel, etc*\/\n\t\tif (test_cc(ctxt->b, ctxt->eflags))\n\t\t\trc = jmp_rel(ctxt, ctxt->src.val);\n\t\tbreak;\n\tcase 0x90 ... 0x9f:     \/* setcc r\/m8 *\/\n\t\tctxt->dst.val = test_cc(ctxt->b, ctxt->eflags);\n\t\tbreak;\n\tcase 0xb6 ... 0xb7:\t\/* movzx *\/\n\t\tctxt->dst.bytes = ctxt->op_bytes;\n\t\tctxt->dst.val = (ctxt->src.bytes == 1) ? (u8) ctxt->src.val\n\t\t\t\t\t\t       : (u16) ctxt->src.val;\n\t\tbreak;\n\tcase 0xbe ... 0xbf:\t\/* movsx *\/\n\t\tctxt->dst.bytes = ctxt->op_bytes;\n\t\tctxt->dst.val = (ctxt->src.bytes == 1) ? (s8) ctxt->src.val :\n\t\t\t\t\t\t\t(s16) ctxt->src.val;\n\t\tbreak;\n\tcase 0xc3:\t\t\/* movnti *\/\n\t\tctxt->dst.bytes = ctxt->op_bytes;\n\t\tctxt->dst.val = (ctxt->op_bytes == 8) ? (u64) ctxt->src.val :\n\t\t\t\t\t\t\t(u32) ctxt->src.val;\n\t\tbreak;\n\tdefault:\n\t\tgoto cannot_emulate;\n\t}\n\nthreebyte_insn:\n\n\tif (rc != X86EMUL_CONTINUE)\n\t\tgoto done;\n\n\tgoto writeback;\n\ncannot_emulate:\n\treturn EMULATION_FAILED;\n}","target":0,"code_token_length":3231,"total_token_length":3467,"max_tokens_setting":4096}
+{"idx":255947,"func":"int ssl3_connect(SSL *s)\n\t{\n\tBUF_MEM *buf=NULL;\n\tunsigned long Time=(unsigned long)time(NULL);\n\tvoid (*cb)(const SSL *ssl,int type,int val)=NULL;\n\tint ret= -1;\n\tint new_state,state,skip=0;\n\n\tRAND_add(&Time,sizeof(Time),0);\n\tERR_clear_error();\n\tclear_sys_error();\n\n\tif (s->info_callback != NULL)\n\t\tcb=s->info_callback;\n\telse if (s->ctx->info_callback != NULL)\n\t\tcb=s->ctx->info_callback;\n\t\n\ts->in_handshake++;\n\tif (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); \n\n#ifndef OPENSSL_NO_HEARTBEATS\n\t\/* If we're awaiting a HeartbeatResponse, pretend we\n\t * already got and don't await it anymore, because\n\t * Heartbeats don't make sense during handshakes anyway.\n\t *\/\n\tif (s->tlsext_hb_pending)\n\t\t{\n\t\ts->tlsext_hb_pending = 0;\n\t\ts->tlsext_hb_seq++;\n\t\t}\n#endif\n\n\tfor (;;)\n\t\t{\n\t\tstate=s->state;\n\n\t\tswitch(s->state)\n\t\t\t{\n\t\tcase SSL_ST_RENEGOTIATE:\n\t\t\ts->renegotiate=1;\n\t\t\ts->state=SSL_ST_CONNECT;\n\t\t\ts->ctx->stats.sess_connect_renegotiate++;\n\t\t\t\/* break *\/\n\t\tcase SSL_ST_BEFORE:\n\t\tcase SSL_ST_CONNECT:\n\t\tcase SSL_ST_BEFORE|SSL_ST_CONNECT:\n\t\tcase SSL_ST_OK|SSL_ST_CONNECT:\n\n\t\t\ts->server=0;\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);\n\n\t\t\tif ((s->version & 0xff00 ) != 0x0300)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);\n\t\t\t\tret = -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\/* s->version=SSL3_VERSION; *\/\n\t\t\ts->type=SSL_ST_CONNECT;\n\n\t\t\tif (s->init_buf == NULL)\n\t\t\t\t{\n\t\t\t\tif ((buf=BUF_MEM_new()) == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tif (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\ts->init_buf=buf;\n\t\t\t\tbuf=NULL;\n\t\t\t\t}\n\n\t\t\tif (!ssl3_setup_buffers(s)) { ret= -1; goto end; }\n\n\t\t\t\/* setup buffing BIO *\/\n\t\t\tif (!ssl_init_wbio_buffer(s,0)) { ret= -1; goto end; }\n\n\t\t\t\/* don't push the buffering BIO quite yet *\/\n\n\t\t\tssl3_init_finished_mac(s);\n\n\t\t\ts->state=SSL3_ST_CW_CLNT_HELLO_A;\n\t\t\ts->ctx->stats.sess_connect++;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CLNT_HELLO_A:\n\t\tcase SSL3_ST_CW_CLNT_HELLO_B:\n\n\t\t\ts->shutdown=0;\n\t\t\tret=ssl3_client_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_SRVR_HELLO_A;\n\t\t\ts->init_num=0;\n\n\t\t\t\/* turn on buffering for the next lot of output *\/\n\t\t\tif (s->bbio != s->wbio)\n\t\t\t\ts->wbio=BIO_push(s->bbio,s->wbio);\n\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_SRVR_HELLO_A:\n\t\tcase SSL3_ST_CR_SRVR_HELLO_B:\n\t\t\tret=ssl3_get_server_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\n\t\t\tif (s->hit)\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_CR_FINISHED_A;\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\t\tif (s->tlsext_ticket_expected)\n\t\t\t\t\t{\n\t\t\t\t\t\/* receive renewed session ticket *\/\n\t\t\t\t\ts->state=SSL3_ST_CR_SESSION_TICKET_A;\n\t\t\t\t\t}\n#endif\n\t\t\t\t}\n\t\t\telse\n\t\t\t\ts->state=SSL3_ST_CR_CERT_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_CERT_A:\n\t\tcase SSL3_ST_CR_CERT_B:\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\tret=ssl3_check_finished(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\tif (ret == 2)\n\t\t\t\t{\n\t\t\t\ts->hit = 1;\n\t\t\t\tif (s->tlsext_ticket_expected)\n\t\t\t\t\ts->state=SSL3_ST_CR_SESSION_TICKET_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_CR_FINISHED_A;\n\t\t\t\ts->init_num=0;\n\t\t\t\tbreak;\n\t\t\t\t}\n#endif\n\t\t\t\/* Check if it is anon DH\/ECDH *\/\n\t\t\t\/* or PSK *\/\n\t\t\tif (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&\n\t\t\t    !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK))\n\t\t\t\t{\n\t\t\t\tret=ssl3_get_server_certificate(s);\n\t\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\t\tif (s->tlsext_status_expected)\n\t\t\t\t\ts->state=SSL3_ST_CR_CERT_STATUS_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tskip = 1;\n\t\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n\t\t\t\t}\n#else\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tskip=1;\n\n\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n#endif\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_KEY_EXCH_A:\n\t\tcase SSL3_ST_CR_KEY_EXCH_B:\n\t\t\tret=ssl3_get_key_exchange(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_CERT_REQ_A;\n\t\t\ts->init_num=0;\n\n\t\t\t\/* at this point we check that we have the\n\t\t\t * required stuff from the server *\/\n\t\t\tif (!ssl3_check_cert_and_algorithm(s))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_CERT_REQ_A:\n\t\tcase SSL3_ST_CR_CERT_REQ_B:\n\t\t\tret=ssl3_get_certificate_request(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_SRVR_DONE_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_SRVR_DONE_A:\n\t\tcase SSL3_ST_CR_SRVR_DONE_B:\n\t\t\tret=ssl3_get_server_done(s);\n\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_SRP\n\t\t\tif (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP)\n\t\t\t\t{\n\t\t\t\tif ((ret = SRP_Calc_A_param(s))<=0)\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_CONNECT,SSL_R_SRP_A_CALC);\n\t\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_INTERNAL_ERROR);\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\t\t\tif (s->s3->tmp.cert_req)\n\t\t\t\ts->state=SSL3_ST_CW_CERT_A;\n\t\t\telse\n\t\t\t\ts->state=SSL3_ST_CW_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CERT_A:\n\t\tcase SSL3_ST_CW_CERT_B:\n\t\tcase SSL3_ST_CW_CERT_C:\n\t\tcase SSL3_ST_CW_CERT_D:\n\t\t\tret=ssl3_send_client_certificate(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CW_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_KEY_EXCH_A:\n\t\tcase SSL3_ST_CW_KEY_EXCH_B:\n\t\t\tret=ssl3_send_client_key_exchange(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\t\/* EAY EAY EAY need to check for DH fix cert\n\t\t\t * sent back *\/\n\t\t\t\/* For TLS, cert_req is set to 2, so a cert chain\n\t\t\t * of nothing is sent, but no verify packet is sent *\/\n\t\t\t\/* XXX: For now, we do not support client \n\t\t\t * authentication in ECDH cipher suites with\n\t\t\t * ECDH (rather than ECDSA) certificates.\n\t\t\t * We need to skip the certificate verify \n\t\t\t * message when client's ECDH public key is sent \n\t\t\t * inside the client certificate.\n\t\t\t *\/\n\t\t\tif (s->s3->tmp.cert_req == 1)\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_CW_CERT_VRFY_A;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\t\ts->s3->change_cipher_spec=0;\n\t\t\t\t}\n\t\t\tif (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY)\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\t\ts->s3->change_cipher_spec=0;\n\t\t\t\t}\n\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CERT_VRFY_A:\n\t\tcase SSL3_ST_CW_CERT_VRFY_B:\n\t\t\tret=ssl3_send_client_verify(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\ts->init_num=0;\n\t\t\ts->s3->change_cipher_spec=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CHANGE_A:\n\t\tcase SSL3_ST_CW_CHANGE_B:\n\t\t\tret=ssl3_send_change_cipher_spec(s,\n\t\t\t\tSSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);\n\t\t\tif (ret <= 0) goto end;\n\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n\t\t\ts->state=SSL3_ST_CW_FINISHED_A;\n#else\n\t\t\tif (s->s3->next_proto_neg_seen)\n\t\t\t\ts->state=SSL3_ST_CW_NEXT_PROTO_A;\n\t\t\telse\n\t\t\t\ts->state=SSL3_ST_CW_FINISHED_A;\n#endif\n\t\t\ts->init_num=0;\n\n\t\t\ts->session->cipher=s->s3->tmp.new_cipher;\n#ifdef OPENSSL_NO_COMP\n\t\t\ts->session->compress_meth=0;\n#else\n\t\t\tif (s->s3->tmp.new_compression == NULL)\n\t\t\t\ts->session->compress_meth=0;\n\t\t\telse\n\t\t\t\ts->session->compress_meth=\n\t\t\t\t\ts->s3->tmp.new_compression->id;\n#endif\n\t\t\tif (!s->method->ssl3_enc->setup_key_block(s))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\tif (!s->method->ssl3_enc->change_cipher_state(s,\n\t\t\t\tSSL3_CHANGE_CIPHER_CLIENT_WRITE))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\tbreak;\n\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)\n\t\tcase SSL3_ST_CW_NEXT_PROTO_A:\n\t\tcase SSL3_ST_CW_NEXT_PROTO_B:\n\t\t\tret=ssl3_send_next_proto(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CW_FINISHED_A;\n\t\t\tbreak;\n#endif\n\n\t\tcase SSL3_ST_CW_FINISHED_A:\n\t\tcase SSL3_ST_CW_FINISHED_B:\n\t\t\tret=ssl3_send_finished(s,\n\t\t\t\tSSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,\n\t\t\t\ts->method->ssl3_enc->client_finished_label,\n\t\t\t\ts->method->ssl3_enc->client_finished_label_len);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CW_FLUSH;\n\n\t\t\t\/* clear flags *\/\n\t\t\ts->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;\n\t\t\tif (s->hit)\n\t\t\t\t{\n\t\t\t\ts->s3->tmp.next_state=SSL_ST_OK;\n\t\t\t\tif (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED)\n\t\t\t\t\t{\n\t\t\t\t\ts->state=SSL_ST_OK;\n\t\t\t\t\ts->s3->flags|=SSL3_FLAGS_POP_BUFFER;\n\t\t\t\t\ts->s3->delay_buf_pop_ret=0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\t\t\/* Allow NewSessionTicket if ticket expected *\/\n\t\t\t\tif (s->tlsext_ticket_expected)\n\t\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;\n\t\t\t\telse\n#endif\n\t\t\t\t\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;\n\t\t\t\t}\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\tcase SSL3_ST_CR_SESSION_TICKET_A:\n\t\tcase SSL3_ST_CR_SESSION_TICKET_B:\n\t\t\tret=ssl3_get_new_session_ticket(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_FINISHED_A;\n\t\t\ts->init_num=0;\n\t\tbreak;\n\n\t\tcase SSL3_ST_CR_CERT_STATUS_A:\n\t\tcase SSL3_ST_CR_CERT_STATUS_B:\n\t\t\tret=ssl3_get_cert_status(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\t\tbreak;\n#endif\n\n                case SSL3_ST_CR_FINISHED_A:\n                case SSL3_ST_CR_FINISHED_B:\n \n                        ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,\n                                SSL3_ST_CR_FINISHED_B);\n                        if (ret <= 0) goto end;\n\t\t\tif (s->hit)\n\t\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\telse\n\t\t\t\ts->state=SSL_ST_OK;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_FLUSH:\n\t\t\ts->rwstate=SSL_WRITING;\n\t\t\tif (BIO_flush(s->wbio) <= 0)\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\ts->state=s->s3->tmp.next_state;\n\t\t\tbreak;\n\n\t\tcase SSL_ST_OK:\n\t\t\t\/* clean a few things up *\/\n\t\t\tssl3_cleanup_key_block(s);\n\n\t\t\tif (s->init_buf != NULL)\n\t\t\t\t{\n\t\t\t\tBUF_MEM_free(s->init_buf);\n\t\t\t\ts->init_buf=NULL;\n\t\t\t\t}\n\n\t\t\t\/* If we are not 'joining' the last two packets,\n\t\t\t * remove the buffering now *\/\n\t\t\tif (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER))\n\t\t\t\tssl_free_wbio_buffer(s);\n\t\t\t\/* else do it later in ssl3_write *\/\n\n\t\t\ts->init_num=0;\n\t\t\ts->renegotiate=0;\n\t\t\ts->new_session=0;\n\n\t\t\tssl_update_cache(s,SSL_SESS_CACHE_CLIENT);\n\t\t\tif (s->hit) s->ctx->stats.sess_hit++;\n\n\t\t\tret=1;\n\t\t\t\/* s->server=0; *\/\n\t\t\ts->handshake_func=ssl3_connect;\n\t\t\ts->ctx->stats.sess_connect_good++;\n\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);\n\n\t\t\tgoto end;\n\t\t\t\/* break; *\/\n\t\t\t\n\t\tdefault:\n\t\t\tSSLerr(SSL_F_SSL3_CONNECT,SSL_R_UNKNOWN_STATE);\n\t\t\tret= -1;\n\t\t\tgoto end;\n\t\t\t\/* break; *\/\n\t\t\t}\n\n\t\t\/* did we do anything *\/\n\t\tif (!s->s3->tmp.reuse_message && !skip)\n\t\t\t{\n\t\t\tif (s->debug)\n\t\t\t\t{\n\t\t\t\tif ((ret=BIO_flush(s->wbio)) <= 0)\n\t\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\tif ((cb != NULL) && (s->state != state))\n\t\t\t\t{\n\t\t\t\tnew_state=s->state;\n\t\t\t\ts->state=state;\n\t\t\t\tcb(s,SSL_CB_CONNECT_LOOP,1);\n\t\t\t\ts->state=new_state;\n\t\t\t\t}\n\t\t\t}\n\t\tskip=0;\n\t\t}\n","target":1,"code_token_length":3506,"total_token_length":3742,"max_tokens_setting":4096}
+{"idx":308760,"func":"int tls_construct_server_key_exchange(SSL *s)\n{\n#ifndef OPENSSL_NO_DH\n    EVP_PKEY *pkdh = NULL;\n    int j;\n#endif\n#ifndef OPENSSL_NO_EC\n    unsigned char *encodedPoint = NULL;\n    int encodedlen = 0;\n    int curve_id = 0;\n#endif\n    EVP_PKEY *pkey;\n    const EVP_MD *md = NULL;\n    unsigned char *p, *d;\n    int al, i;\n    unsigned long type;\n    int n;\n    const BIGNUM *r[4];\n    int nr[4], kn;\n    BUF_MEM *buf;\n    EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();\n\n    if (md_ctx == NULL) {\n        SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);\n        al = SSL_AD_INTERNAL_ERROR;\n        goto f_err;\n    }\n\n    type = s->s3->tmp.new_cipher->algorithm_mkey;\n\n    buf = s->init_buf;\n\n    r[0] = r[1] = r[2] = r[3] = NULL;\n    n = 0;\n#ifndef OPENSSL_NO_PSK\n    if (type & SSL_PSK) {\n        \/*\n         * reserve size for record length and PSK identity hint\n         *\/\n        n += 2;\n        if (s->cert->psk_identity_hint)\n            n += strlen(s->cert->psk_identity_hint);\n    }\n    \/* Plain PSK or RSAPSK nothing to do *\/\n    if (type & (SSL_kPSK | SSL_kRSAPSK)) {\n    } else\n#endif                          \/* !OPENSSL_NO_PSK *\/\n#ifndef OPENSSL_NO_DH\n    if (type & (SSL_kDHE | SSL_kDHEPSK)) {\n        CERT *cert = s->cert;\n\n        EVP_PKEY *pkdhp = NULL;\n        DH *dh;\n\n        if (s->cert->dh_tmp_auto) {\n            DH *dhp = ssl_get_auto_dh(s);\n            pkdh = EVP_PKEY_new();\n            if (pkdh == NULL || dhp == NULL) {\n                DH_free(dhp);\n                al = SSL_AD_INTERNAL_ERROR;\n                SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto f_err;\n            }\n            EVP_PKEY_assign_DH(pkdh, dhp);\n            pkdhp = pkdh;\n        } else {\n            pkdhp = cert->dh_tmp;\n        }\n        if ((pkdhp == NULL) && (s->cert->dh_tmp_cb != NULL)) {\n            DH *dhp = s->cert->dh_tmp_cb(s, 0, 1024);\n            pkdh = ssl_dh_to_pkey(dhp);\n            if (pkdh == NULL) {\n                al = SSL_AD_INTERNAL_ERROR;\n                SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto f_err;\n            }\n            pkdhp = pkdh;\n        }\n        if (pkdhp == NULL) {\n            al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   SSL_R_MISSING_TMP_DH_KEY);\n            goto f_err;\n        }\n        if (!ssl_security(s, SSL_SECOP_TMP_DH,\n                          EVP_PKEY_security_bits(pkdhp), 0, pkdhp)) {\n            al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   SSL_R_DH_KEY_TOO_SMALL);\n            goto f_err;\n        }\n        if (s->s3->tmp.pkey != NULL) {\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n\n        s->s3->tmp.pkey = ssl_generate_pkey(pkdhp);\n\n        if (s->s3->tmp.pkey == NULL) {\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_EVP_LIB);\n            goto err;\n        }\n\n        dh = EVP_PKEY_get0_DH(s->s3->tmp.pkey);\n\n        EVP_PKEY_free(pkdh);\n        pkdh = NULL;\n\n        DH_get0_pqg(dh, &r[0], NULL, &r[1]);\n        DH_get0_key(dh, &r[2], NULL);\n    } else\n#endif\n#ifndef OPENSSL_NO_EC\n    if (type & (SSL_kECDHE | SSL_kECDHEPSK)) {\n        int nid;\n\n        if (s->s3->tmp.pkey != NULL) {\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n\n        \/* Get NID of appropriate shared curve *\/\n        nid = tls1_shared_curve(s, -2);\n        curve_id = tls1_ec_nid2curve_id(nid);\n        if (curve_id == 0) {\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   SSL_R_UNSUPPORTED_ELLIPTIC_CURVE);\n            goto err;\n        }\n        s->s3->tmp.pkey = ssl_generate_pkey_curve(curve_id);\n        \/* Generate a new key for this curve *\/\n        if (s->s3->tmp.pkey == NULL) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_EVP_LIB);\n            goto f_err;\n        }\n\n        \/* Encode the public key. *\/\n        encodedlen = EVP_PKEY_get1_tls_encodedpoint(s->s3->tmp.pkey,\n                                                    &encodedPoint);\n        if (encodedlen == 0) {\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_EC_LIB);\n            goto err;\n        }\n\n        \/*\n         * We only support named (not generic) curves in ECDH ephemeral key\n         * exchanges. In this situation, we need four additional bytes to\n         * encode the entire ServerECDHParams structure.\n         *\/\n        n += 4 + encodedlen;\n\n        \/*\n         * We'll generate the serverKeyExchange message explicitly so we\n         * can set these to NULLs\n         *\/\n        r[0] = NULL;\n        r[1] = NULL;\n        r[2] = NULL;\n        r[3] = NULL;\n    } else\n#endif                          \/* !OPENSSL_NO_EC *\/\n#ifndef OPENSSL_NO_SRP\n    if (type & SSL_kSRP) {\n        if ((s->srp_ctx.N == NULL) ||\n            (s->srp_ctx.g == NULL) ||\n            (s->srp_ctx.s == NULL) || (s->srp_ctx.B == NULL)) {\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   SSL_R_MISSING_SRP_PARAM);\n            goto err;\n        }\n        r[0] = s->srp_ctx.N;\n        r[1] = s->srp_ctx.g;\n        r[2] = s->srp_ctx.s;\n        r[3] = s->srp_ctx.B;\n    } else\n#endif\n    {\n        al = SSL_AD_HANDSHAKE_FAILURE;\n        SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n               SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE);\n        goto f_err;\n    }\n    for (i = 0; i < 4 && r[i] != NULL; i++) {\n        nr[i] = BN_num_bytes(r[i]);\n#ifndef OPENSSL_NO_SRP\n        if ((i == 2) && (type & SSL_kSRP))\n            n += 1 + nr[i];\n        else\n#endif\n#ifndef OPENSSL_NO_DH\n        \/*-\n         * for interoperability with some versions of the Microsoft TLS\n         * stack, we need to zero pad the DHE pub key to the same length\n         * as the prime, so use the length of the prime here\n         *\/\n        if ((i == 2) && (type & (SSL_kDHE | SSL_kDHEPSK)))\n            n += 2 + nr[0];\n        else\n#endif\n            n += 2 + nr[i];\n    }\n\n    if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))\n        && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK)) {\n        if ((pkey = ssl_get_sign_pkey(s, s->s3->tmp.new_cipher, &md))\n            == NULL) {\n            al = SSL_AD_DECODE_ERROR;\n            goto f_err;\n        }\n        kn = EVP_PKEY_size(pkey);\n        \/* Allow space for signature algorithm *\/\n        if (SSL_USE_SIGALGS(s))\n            kn += 2;\n        \/* Allow space for signature length *\/\n        kn += 2;\n    } else {\n        pkey = NULL;\n        kn = 0;\n    }\n\n    if (!BUF_MEM_grow_clean(buf, n + SSL_HM_HEADER_LENGTH(s) + kn)) {\n        SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_LIB_BUF);\n        goto err;\n    }\n    d = p = ssl_handshake_start(s);\n\n#ifndef OPENSSL_NO_PSK\n    if (type & SSL_PSK) {\n        \/* copy PSK identity hint *\/\n        if (s->cert->psk_identity_hint) {\n            size_t len = strlen(s->cert->psk_identity_hint);\n            if (len > PSK_MAX_IDENTITY_LEN) {\n                \/*\n                 * Should not happen - we already checked this when we set\n                 * the identity hint\n                 *\/\n                SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            s2n(len, p);\n            memcpy(p, s->cert->psk_identity_hint, len);\n            p += len;\n        } else {\n            s2n(0, p);\n        }\n    }\n#endif\n\n    for (i = 0; i < 4 && r[i] != NULL; i++) {\n#ifndef OPENSSL_NO_SRP\n        if ((i == 2) && (type & SSL_kSRP)) {\n            *p = nr[i];\n            p++;\n        } else\n#endif\n#ifndef OPENSSL_NO_DH\n        \/*-\n         * for interoperability with some versions of the Microsoft TLS\n         * stack, we need to zero pad the DHE pub key to the same length\n         * as the prime\n         *\/\n        if ((i == 2) && (type & (SSL_kDHE | SSL_kDHEPSK))) {\n            s2n(nr[0], p);\n            for (j = 0; j < (nr[0] - nr[2]); ++j) {\n                *p = 0;\n                ++p;\n            }\n        } else\n#endif\n            s2n(nr[i], p);\n        BN_bn2bin(r[i], p);\n        p += nr[i];\n    }\n\n#ifndef OPENSSL_NO_EC\n    if (type & (SSL_kECDHE | SSL_kECDHEPSK)) {\n        \/*\n         * XXX: For now, we only support named (not generic) curves. In\n         * this situation, the serverKeyExchange message has: [1 byte\n         * CurveType], [2 byte CurveName] [1 byte length of encoded\n         * point], followed by the actual encoded point itself\n         *\/\n        *p = NAMED_CURVE_TYPE;\n        p += 1;\n        *p = 0;\n        p += 1;\n        *p = curve_id;\n        p += 1;\n        *p = encodedlen;\n        p += 1;\n        memcpy(p, encodedPoint, encodedlen);\n        OPENSSL_free(encodedPoint);\n        encodedPoint = NULL;\n        p += encodedlen;\n    }\n#endif\n\n    \/* not anonymous *\/\n    if (pkey != NULL) {\n        \/*\n         * n is the length of the params, they start at &(d[4]) and p\n         * points to the space at the end.\n         *\/\n        if (md) {\n            \/* send signature algorithm *\/\n            if (SSL_USE_SIGALGS(s)) {\n                if (!tls12_get_sigandhash(p, pkey, md)) {\n                    \/* Should never happen *\/\n                    al = SSL_AD_INTERNAL_ERROR;\n                    SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                           ERR_R_INTERNAL_ERROR);\n                    goto f_err;\n                }\n                p += 2;\n            }\n#ifdef SSL_DEBUG\n            fprintf(stderr, \"Using hash %s\\n\", EVP_MD_name(md));\n#endif\n            if (EVP_SignInit_ex(md_ctx, md, NULL) <= 0\n                || EVP_SignUpdate(md_ctx, &(s->s3->client_random[0]),\n                                  SSL3_RANDOM_SIZE) <= 0\n                || EVP_SignUpdate(md_ctx, &(s->s3->server_random[0]),\n                                  SSL3_RANDOM_SIZE) <= 0\n                || EVP_SignUpdate(md_ctx, d, n) <= 0\n                || EVP_SignFinal(md_ctx, &(p[2]),\n                                 (unsigned int *)&i, pkey) <= 0) {\n                SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_LIB_EVP);\n                al = SSL_AD_INTERNAL_ERROR;\n                goto f_err;\n            }\n            s2n(i, p);\n            n += i + 2;\n            if (SSL_USE_SIGALGS(s))\n                n += 2;\n        } else {\n            \/* Is this error check actually needed? *\/\n            al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE,\n                   SSL_R_UNKNOWN_PKEY_TYPE);\n            goto f_err;\n        }\n    }\n\n    if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_KEY_EXCHANGE, n)) {\n        al = SSL_AD_HANDSHAKE_FAILURE;\n        SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n        goto f_err;\n    }\n\n    EVP_MD_CTX_free(md_ctx);\n    return 1;\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n#ifndef OPENSSL_NO_DH\n    EVP_PKEY_free(pkdh);\n#endif\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(encodedPoint);\n#endif\n    EVP_MD_CTX_free(md_ctx);\n    ossl_statem_set_error(s);\n    return 0;\n}\n","target":0,"code_token_length":3071,"total_token_length":3307,"max_tokens_setting":4096}
+{"idx":371037,"func":"int LibRaw::raw2image_ex(void)\n{\n    CHECK_ORDER_LOW(LIBRAW_PROGRESS_LOAD_RAW);\n\n    raw2image_start();\n\n    \/\/ process cropping\n    int do_crop = 0;\n    unsigned save_filters = imgdata.idata.filters;\n    unsigned save_width = S.width;\n    if (~O.cropbox[2] && ~O.cropbox[3])\n        {\n            int crop[4],c,filt;\n            for(int c=0;c<4;c++) \n                {\n                    crop[c] = O.cropbox[c];\n                    if(crop[c]<0)\n                        crop[c]=0;\n                }\n            if(IO.fwidth) \n                {\n                    crop[0] = (crop[0]\/4)*4;\n                    crop[1] = (crop[1]\/4)*4;\n                }\n            do_crop = 1;\n            crop[2] = MIN (crop[2], (signed) S.width-crop[0]);\n            crop[3] = MIN (crop[3], (signed) S.height-crop[1]);\n            if (crop[2] <= 0 || crop[3] <= 0)\n                throw LIBRAW_EXCEPTION_BAD_CROP;\n            \n            \/\/ adjust sizes!\n            S.left_margin+=crop[0];\n            S.top_margin+=crop[1];\n            S.width=crop[2];\n            S.height=crop[3];\n            \n            S.iheight = (S.height + IO.shrink) >> IO.shrink;\n            S.iwidth  = (S.width  + IO.shrink) >> IO.shrink;\n            if(!IO.fwidth && imgdata.idata.filters)\n                {\n                    for (filt=c=0; c < 16; c++)\n                        filt |= FC((c >> 1)+(crop[1]),\n                                   (c &  1)+(crop[0])) << c*2;\n                    imgdata.idata.filters = filt;\n                }\n        }\n\n    if(IO.fwidth) \n        {\n            ushort fiwidth,fiheight;\n            if(do_crop)\n                {\n                    IO.fuji_width = S.width >> !libraw_internal_data.unpacker_data.fuji_layout;\n                    IO.fwidth = (S.height >> libraw_internal_data.unpacker_data.fuji_layout) + IO.fuji_width;\n                    IO.fheight = IO.fwidth - 1;\n                }\n\n            fiheight = (IO.fheight + IO.shrink) >> IO.shrink;\n            fiwidth = (IO.fwidth + IO.shrink) >> IO.shrink;\n            if(imgdata.image)\n                    {\n                        imgdata.image = (ushort (*)[4])realloc(imgdata.image,fiheight*fiwidth*sizeof (*imgdata.image));\n                        memset(imgdata.image,0,fiheight*fiwidth *sizeof (*imgdata.image));\n                    }\n                else\n                    imgdata.image = (ushort (*)[4]) calloc (fiheight*fiwidth, sizeof (*imgdata.image));\n            merror (imgdata.image, \"raw2image_ex()\");\n\n            int cblk[4],i;\n            for(i=0;i<4;i++)\n                cblk[i] = C.cblack[i]+C.black;\n            ZERO(C.channel_maximum);\n\n            int row,col;\n            for(row=0;row> 1);\n                                c = col + ((row+1) >> 1);\n                            } else {\n                                r = IO.fuji_width - 1 + row - (col >> 1);\n                                c = row + ((col+1) >> 1);\n                            }\n                            \n                            int val = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_width\n                                                            +(col+S.left_margin)];\n                            int cc = FCF(row,col);\n                            if(val > cblk[cc])\n                                val -= cblk[cc];\n                            else\n                                val = 0;\n                            imgdata.image[((r) >> IO.shrink)*fiwidth + ((c) >> IO.shrink)][cc] = val;\n                            if(C.channel_maximum[cc] < val) C.channel_maximum[cc] = val;\n                        }\n                }\n            C.maximum -= C.black;\n            ZERO(C.cblack);\n            C.black = 0;\n\n            \/\/ restore fuji sizes!\n            S.height = IO.fheight;\n            S.width = IO.fwidth;\n            S.iheight = (S.height + IO.shrink) >> IO.shrink;\n            S.iwidth  = (S.width  + IO.shrink) >> IO.shrink;\n            S.raw_height -= 2*S.top_margin;\n        }\n    else\n        {\n\n                if(imgdata.image)\n                    {\n                        imgdata.image = (ushort (*)[4]) realloc (imgdata.image,S.iheight*S.iwidth \n                                                                 *sizeof (*imgdata.image));\n                        memset(imgdata.image,0,S.iheight*S.iwidth *sizeof (*imgdata.image));\n                    }\n                else\n                    imgdata.image = (ushort (*)[4]) calloc (S.iheight*S.iwidth, sizeof (*imgdata.image));\n\n                merror (imgdata.image, \"raw2image_ex()\");\n                \n                libraw_decoder_info_t decoder_info;\n                get_decoder_info(&decoder_info);\n\n\n                if(decoder_info.decoder_flags & LIBRAW_DECODER_FLATFIELD)\n                    {\n                        if(decoder_info.decoder_flags & LIBRAW_DECODER_USEBAYER2)\n#if defined(LIBRAW_USE_OPENMP)\n#pragma omp parallel for default(shared)\n#endif\n                            for(int row = 0; row < S.height; row++)\n                                for(int col = 0; col < S.width; col++)\n                                    imgdata.image[(row >> IO.shrink)*S.iwidth + (col>>IO.shrink)][fc(row,col)]\n                                        = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_width\n                                                                    +(col+S.left_margin)];\n                        else\n#if defined(LIBRAW_USE_OPENMP)\n#pragma omp parallel for default(shared)\n#endif\n                            for(int row = 0; row < S.height; row++)\n                                {\n                                    int colors[2];\n                                    for (int xx=0;xx<2;xx++)\n                                        colors[xx] = COLOR(row,xx);\n                                    for(int col = 0; col < S.width; col++)\n                                        {\n                                            int cc = colors[col&1];\n                                            imgdata.image[(row >> IO.shrink)*S.iwidth + (col>>IO.shrink)][cc] =\n                                                imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_width\n                                                                          +(col+S.left_margin)];\n                                        }\n                                }\n                    }\n                else if (decoder_info.decoder_flags & LIBRAW_DECODER_4COMPONENT)\n                    {\n#define FC0(row,col) (save_filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)\n                        if(IO.shrink)\n#if defined(LIBRAW_USE_OPENMP)\n#pragma omp parallel for default(shared)\n#endif\n                            for(int row = 0; row < S.height; row++)\n                                for(int col = 0; col < S.width; col++)\n                                    imgdata.image[(row >> IO.shrink)*S.iwidth + (col>>IO.shrink)][FC(row,col)] \n                                        = imgdata.rawdata.color_image[(row+S.top_margin)*S.raw_width\n                                                                      +S.left_margin+col]\n                                        [FC0(row+S.top_margin,col+S.left_margin)];\n#undef FC0\n                        else\n#if defined(LIBRAW_USE_OPENMP)\n#pragma omp parallel for default(shared)\n#endif\n                            for(int row = 0; row < S.height; row++)\n                                memmove(&imgdata.image[row*S.width],\n                                        &imgdata.rawdata.color_image[(row+S.top_margin)*S.raw_width+S.left_margin],\n                                        S.width*sizeof(*imgdata.image));\n                    }\n                else if(decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)\n                    {\n                        if(do_crop)\n#if defined(LIBRAW_USE_OPENMP)\n#pragma omp parallel for default(shared)\n#endif\n                            for(int row = 0; row < S.height; row++)\n                                memmove(&imgdata.image[row*S.width],\n                                        &imgdata.rawdata.color_image[(row+S.top_margin)*save_width+S.left_margin],\n                                        S.width*sizeof(*imgdata.image));\n                                \n                        else \n                            memmove(imgdata.image,imgdata.rawdata.color_image,\n                                    S.width*S.height*sizeof(*imgdata.image));\n                    }\n\n                if(imgdata.rawdata.use_ph1_correct) \/\/ Phase one unpacked!\n                        phase_one_correct();\n            }\n    return LIBRAW_SUCCESS;\n}","target":0,"code_token_length":1836,"total_token_length":2072,"max_tokens_setting":4096}
+{"idx":413492,"func":"void slurmctld_req(slurm_msg_t *msg, connection_arg_t *arg)\n{\n\tDEF_TIMERS;\n\tint i, rpc_type_index = -1, rpc_user_index = -1;\n\tuint32_t rpc_uid;\n\n\tif (arg && (arg->newsockfd >= 0))\n\t\tfd_set_nonblocking(arg->newsockfd);\n\n#ifndef NDEBUG\n\tif ((msg->flags & SLURM_DROP_PRIV))\n\t\tdrop_priv = true;\n#endif\n\n\t\/* Just to validate the cred *\/\n\trpc_uid = (uint32_t) g_slurm_auth_get_uid(msg->auth_cred,\n\t\t\t\t\t\t  slurmctld_config.auth_info);\n\tif (g_slurm_auth_errno(msg->auth_cred) != SLURM_SUCCESS) {\n\t\terror(\"Bad authentication: %s\",\n\t\t      g_slurm_auth_errstr(g_slurm_auth_errno(msg->auth_cred)));\n\t\treturn;\n\t}\n\tslurm_mutex_lock(&rpc_mutex);\n\tif (rpc_type_size == 0) {\n\t\trpc_type_size = 100;  \/* Capture info for first 100 RPC types *\/\n\t\trpc_type_id   = xmalloc(sizeof(uint16_t) * rpc_type_size);\n\t\trpc_type_cnt  = xmalloc(sizeof(uint32_t) * rpc_type_size);\n\t\trpc_type_time = xmalloc(sizeof(uint64_t) * rpc_type_size);\n\t}\n\tfor (i = 0; i < rpc_type_size; i++) {\n\t\tif (rpc_type_id[i] == 0)\n\t\t\trpc_type_id[i] = msg->msg_type;\n\t\telse if (rpc_type_id[i] != msg->msg_type)\n\t\t\tcontinue;\n\t\trpc_type_index = i;\n\t\tbreak;\n\t}\n\tif (rpc_user_size == 0) {\n\t\trpc_user_size = 200;  \/* Capture info for first 200 RPC users *\/\n\t\trpc_user_id   = xmalloc(sizeof(uint32_t) * rpc_user_size);\n\t\trpc_user_cnt  = xmalloc(sizeof(uint32_t) * rpc_user_size);\n\t\trpc_user_time = xmalloc(sizeof(uint64_t) * rpc_user_size);\n\t}\n\tfor (i = 0; i < rpc_user_size; i++) {\n\t\tif ((rpc_user_id[i] == 0) && (i != 0))\n\t\t\trpc_user_id[i] = rpc_uid;\n\t\telse if (rpc_user_id[i] != rpc_uid)\n\t\t\tcontinue;\n\t\trpc_user_index = i;\n\t\tbreak;\n\t}\n\tslurm_mutex_unlock(&rpc_mutex);\n\n\t\/* Debug the protocol layer.\n\t *\/\n\tSTART_TIMER;\n\tif (slurmctld_conf.debug_flags & DEBUG_FLAG_PROTOCOL) {\n\t\tchar *p = rpc_num2string(msg->msg_type);\n\t\tif (msg->conn) {\n\t\t\tinfo(\"%s: received opcode %s from persist conn on (%s)%s\",\n\t\t\t     __func__, p, msg->conn->cluster_name,\n\t\t\t     msg->conn->rem_host);\n\t\t} else if (arg) {\n\t\t\tchar inetbuf[64];\n\t\t\tslurm_print_slurm_addr(&arg->cli_addr,\n\t\t\t\t\t       inetbuf,\n\t\t\t\t\t       sizeof(inetbuf));\n\t\t\tinfo(\"%s: received opcode %s from %s\",\n\t\t\t     __func__, p, inetbuf);\n\t\t} else {\n\t\t\terror(\"%s: No arg given and this doesn't appear to be a persistent connection, this should never happen\", __func__);\n\t\t}\n\t}\n\n\tswitch (msg->msg_type) {\n\tcase REQUEST_RESOURCE_ALLOCATION:\n\t\t_slurm_rpc_allocate_resources(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_PACK_ALLOCATION:\n\t\t_slurm_rpc_allocate_pack(msg);\n\t\tbreak;\n\tcase REQUEST_BUILD_INFO:\n\t\t_slurm_rpc_dump_conf(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_INFO:\n\t\t_slurm_rpc_dump_jobs(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_USER_INFO:\n\t\t_slurm_rpc_dump_jobs_user(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_INFO_SINGLE:\n\t\t_slurm_rpc_dump_job_single(msg);\n\t\tbreak;\n\tcase REQUEST_BATCH_SCRIPT:\n\t\t_slurm_rpc_dump_batch_script(msg);\n\t\tbreak;\n\tcase REQUEST_SHARE_INFO:\n\t\t_slurm_rpc_get_shares(msg);\n\t\tbreak;\n\tcase REQUEST_PRIORITY_FACTORS:\n\t\t_slurm_rpc_get_priority_factors(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_END_TIME:\n\t\t_slurm_rpc_end_time(msg);\n\t\tbreak;\n\tcase REQUEST_FED_INFO:\n\t\t_slurm_rpc_get_fed(msg);\n\t\tbreak;\n\tcase REQUEST_FRONT_END_INFO:\n\t\t_slurm_rpc_dump_front_end(msg);\n\t\tbreak;\n\tcase REQUEST_NODE_INFO:\n\t\t_slurm_rpc_dump_nodes(msg);\n\t\tbreak;\n\tcase REQUEST_NODE_INFO_SINGLE:\n\t\t_slurm_rpc_dump_node_single(msg);\n\t\tbreak;\n\tcase REQUEST_PARTITION_INFO:\n\t\t_slurm_rpc_dump_partitions(msg);\n\t\tbreak;\n\tcase MESSAGE_EPILOG_COMPLETE:\n\t\ti = 0;\n\t\t_slurm_rpc_epilog_complete(msg, (bool *)&i, 0);\n\t\tbreak;\n\tcase REQUEST_CANCEL_JOB_STEP:\n\t\t_slurm_rpc_job_step_kill(rpc_uid, msg);\n\t\tbreak;\n\tcase REQUEST_COMPLETE_JOB_ALLOCATION:\n\t\t_slurm_rpc_complete_job_allocation(msg);\n\t\tbreak;\n\tcase REQUEST_COMPLETE_PROLOG:\n\t\t_slurm_rpc_complete_prolog(msg);\n\t\tbreak;\n\tcase REQUEST_COMPLETE_BATCH_JOB:\n\tcase REQUEST_COMPLETE_BATCH_SCRIPT:\n\t\ti = 0;\n\t\t_slurm_rpc_complete_batch_script(msg, (bool *)&i, 0);\n\t\tbreak;\n\tcase REQUEST_JOB_STEP_CREATE:\n\t\t_slurm_rpc_job_step_create(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_STEP_INFO:\n\t\t_slurm_rpc_job_step_get_info(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_WILL_RUN:\n\t\t_slurm_rpc_job_will_run(msg);\n\t\tbreak;\n\tcase REQUEST_SIB_JOB_LOCK:\n\t\t_slurm_rpc_sib_job_lock(rpc_uid, msg);\n\t\tbreak;\n\tcase REQUEST_SIB_JOB_UNLOCK:\n\t\t_slurm_rpc_sib_job_unlock(rpc_uid, msg);\n\t\tbreak;\n\tcase REQUEST_CTLD_MULT_MSG:\n\t\t_proc_multi_msg(rpc_uid, msg);\n\t\tbreak;\n\tcase MESSAGE_NODE_REGISTRATION_STATUS:\n\t\t_slurm_rpc_node_registration(msg, 0);\n\t\tbreak;\n\tcase REQUEST_JOB_ALLOCATION_INFO:\n\tcase DEFUNCT_REQUEST_JOB_ALLOCATION_INFO_LITE:\n\t\t_slurm_rpc_job_alloc_info(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_PACK_ALLOC_INFO:\n\t\t_slurm_rpc_job_pack_alloc_info(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_SBCAST_CRED:\n\t\t_slurm_rpc_job_sbcast_cred(msg);\n\t\tbreak;\n\tcase REQUEST_PING:\n\t\t_slurm_rpc_ping(msg);\n\t\tbreak;\n\tcase REQUEST_RECONFIGURE:\n\t\t_slurm_rpc_reconfigure_controller(msg);\n\t\tbreak;\n\tcase REQUEST_CONTROL:\n\t\t_slurm_rpc_shutdown_controller(msg);\n\t\tbreak;\n\tcase REQUEST_TAKEOVER:\n\t\t_slurm_rpc_takeover(msg);\n\t\tbreak;\n\tcase REQUEST_SHUTDOWN:\n\t\t_slurm_rpc_shutdown_controller(msg);\n\t\tbreak;\n\tcase REQUEST_SHUTDOWN_IMMEDIATE:\n\t\t_slurm_rpc_shutdown_controller_immediate(msg);\n\t\tbreak;\n\tcase REQUEST_SUBMIT_BATCH_JOB:\n\t\t_slurm_rpc_submit_batch_job(msg);\n\t\tbreak;\n\tcase REQUEST_SUBMIT_BATCH_JOB_PACK:\n\t\t_slurm_rpc_submit_batch_pack_job(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_FRONT_END:\n\t\t_slurm_rpc_update_front_end(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_JOB:\n\t\t_slurm_rpc_update_job(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_NODE:\n\t\t_slurm_rpc_update_node(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_LAYOUT:\n\t\t_slurm_rpc_update_layout(msg);\n\t\tbreak;\n\tcase REQUEST_CREATE_PARTITION:\n\tcase REQUEST_UPDATE_PARTITION:\n\t\t_slurm_rpc_update_partition(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_POWERCAP:\n\t\t_slurm_rpc_update_powercap(msg);\n\t\tbreak;\n\tcase REQUEST_DELETE_PARTITION:\n\t\t_slurm_rpc_delete_partition(msg);\n\t\tbreak;\n\tcase REQUEST_CREATE_RESERVATION:\n\t\t_slurm_rpc_resv_create(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_RESERVATION:\n\t\t_slurm_rpc_resv_update(msg);\n\t\tbreak;\n\tcase REQUEST_DELETE_RESERVATION:\n\t\t_slurm_rpc_resv_delete(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_BLOCK:\n\t\t_slurm_rpc_update_block(msg);\n\t\tbreak;\n\tcase REQUEST_RESERVATION_INFO:\n\t\t_slurm_rpc_resv_show(msg);\n\t\tbreak;\n\tcase REQUEST_LAYOUT_INFO:\n\t\t_slurm_rpc_layout_show(msg);\n\t\tbreak;\n\tcase REQUEST_NODE_REGISTRATION_STATUS:\n\t\terror(\"slurmctld is talking with itself. \"\n\t\t      \"SlurmctldPort == SlurmdPort\");\n\t\tslurm_send_rc_msg(msg, EINVAL);\n\t\tbreak;\n\tcase REQUEST_CHECKPOINT:\n\t\t_slurm_rpc_checkpoint(msg);\n\t\tbreak;\n\tcase REQUEST_CHECKPOINT_COMP:\n\t\t_slurm_rpc_checkpoint_comp(msg);\n\t\tbreak;\n\tcase REQUEST_CHECKPOINT_TASK_COMP:\n\t\t_slurm_rpc_checkpoint_task_comp(msg);\n\t\tbreak;\n\tcase REQUEST_SUSPEND:\n\t\t_slurm_rpc_suspend(msg);\n\t\tbreak;\n\tcase REQUEST_TOP_JOB:\n\t\t_slurm_rpc_top_job(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_REQUEUE:\n\t\t_slurm_rpc_requeue(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_READY:\n\t\t_slurm_rpc_job_ready(msg);\n\t\tbreak;\n\tcase REQUEST_BLOCK_INFO:\n\t\t_slurm_rpc_block_info(msg);\n\t\tbreak;\n\tcase REQUEST_BURST_BUFFER_INFO:\n\t\t_slurm_rpc_burst_buffer_info(msg);\n\t\tbreak;\n\tcase REQUEST_STEP_COMPLETE:\n\t\t_slurm_rpc_step_complete(msg, 0);\n\t\tbreak;\n\tcase REQUEST_STEP_LAYOUT:\n\t\t_slurm_rpc_step_layout(msg);\n\t\tbreak;\n\tcase REQUEST_UPDATE_JOB_STEP:\n\t\t_slurm_rpc_step_update(msg);\n\t\tbreak;\n\tcase REQUEST_TRIGGER_SET:\n\t\t_slurm_rpc_trigger_set(msg);\n\t\tbreak;\n\tcase REQUEST_TRIGGER_GET:\n\t\t_slurm_rpc_trigger_get(msg);\n\t\tbreak;\n\tcase REQUEST_TRIGGER_CLEAR:\n\t\t_slurm_rpc_trigger_clear(msg);\n\t\tbreak;\n\tcase REQUEST_TRIGGER_PULL:\n\t\t_slurm_rpc_trigger_pull(msg);\n\t\tbreak;\n\tcase REQUEST_JOB_NOTIFY:\n\t\t_slurm_rpc_job_notify(msg);\n\t\tbreak;\n\tcase REQUEST_SET_DEBUG_FLAGS:\n\t\t_slurm_rpc_set_debug_flags(msg);\n\t\tbreak;\n\tcase REQUEST_SET_DEBUG_LEVEL:\n\t\t_slurm_rpc_set_debug_level(msg);\n\t\tbreak;\n\tcase REQUEST_SET_SCHEDLOG_LEVEL:\n\t\t_slurm_rpc_set_schedlog_level(msg);\n\t\tbreak;\n\tcase ACCOUNTING_UPDATE_MSG:\n\t\t_slurm_rpc_accounting_update_msg(msg);\n\t\tbreak;\n\tcase ACCOUNTING_FIRST_REG:\n\t\t_slurm_rpc_accounting_first_reg(msg);\n\t\tbreak;\n\tcase ACCOUNTING_REGISTER_CTLD:\n\t\t_slurm_rpc_accounting_register_ctld(msg);\n\t\tbreak;\n\tcase REQUEST_TOPO_INFO:\n\t\t_slurm_rpc_get_topo(msg);\n\t\tbreak;\n\tcase REQUEST_POWERCAP_INFO:\n\t\t_slurm_rpc_get_powercap(msg);\n\t\tbreak;\n\tcase REQUEST_SPANK_ENVIRONMENT:\n\t\t_slurm_rpc_dump_spank(msg);\n\t\tbreak;\n\tcase REQUEST_REBOOT_NODES:\n\t\t_slurm_rpc_reboot_nodes(msg);\n\t\tbreak;\n\tcase REQUEST_STATS_INFO:\n\t\t_slurm_rpc_dump_stats(msg);\n\t\tbreak;\n\tcase REQUEST_LICENSE_INFO:\n\t\t_slurm_rpc_dump_licenses(msg);\n\t\tbreak;\n\tcase REQUEST_KILL_JOB:\n\t\t_slurm_rpc_kill_job(msg);\n\t\tbreak;\n\tcase MESSAGE_COMPOSITE:\n\t\t_slurm_rpc_composite_msg(msg);\n\t\tbreak;\n\tcase REQUEST_ASSOC_MGR_INFO:\n\t\t_slurm_rpc_assoc_mgr_info(msg);\n\t\tbreak;\n\tcase REQUEST_PERSIST_INIT:\n\t\tif (msg->conn)\n\t\t\terror(\"We already have a persistent connect, this should never happen\");\n\t\t_slurm_rpc_persist_init(msg, arg);\n\t\tbreak;\n\tcase REQUEST_EVENT_LOG:\n\t\t_slurm_rpc_event_log(msg);\n\t\tbreak;\n\tcase REQUEST_SET_FS_DAMPENING_FACTOR:\n\t\t_slurm_rpc_set_fs_dampening_factor(msg);\n\t\tbreak;\n\tdefault:\n\t\terror(\"invalid RPC msg_type=%u\", msg->msg_type);\n\t\tslurm_send_rc_msg(msg, EINVAL);\n\t\tbreak;\n\t}\n\n\tEND_TIMER;\n\tslurm_mutex_lock(&rpc_mutex);\n\tif (rpc_type_index >= 0) {\n\t\trpc_type_cnt[rpc_type_index]++;\n\t\trpc_type_time[rpc_type_index] += DELTA_TIMER;\n\t}\n\tif (rpc_user_index >= 0) {\n\t\trpc_user_cnt[rpc_user_index]++;\n\t\trpc_user_time[rpc_user_index] += DELTA_TIMER;\n\t}\n\tslurm_mutex_unlock(&rpc_mutex);\n}","target":0,"code_token_length":2611,"total_token_length":2847,"max_tokens_setting":4096}
+{"idx":503446,"func":"ra_input(void)\n{\n  uip_lladdr_t lladdr_aligned;\n\n  LOG_INFO(\"Received RA from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\" to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\"\\n\");\n  UIP_STAT(++uip_stat.nd6.recv);\n\n#if UIP_CONF_IPV6_CHECKS\n  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||\n     (!uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr)) ||\n     (UIP_ICMP_BUF->icode != 0)) {\n    LOG_ERR(\"RA received is bad\");\n    goto discard;\n  }\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n\n  if(UIP_ND6_RA_BUF->cur_ttl != 0) {\n    uip_ds6_if.cur_hop_limit = UIP_ND6_RA_BUF->cur_ttl;\n    LOG_INFO(\"uip_ds6_if.cur_hop_limit %u\\n\", uip_ds6_if.cur_hop_limit);\n  }\n\n  if(UIP_ND6_RA_BUF->reachable_time != 0) {\n    if(uip_ds6_if.base_reachable_time !=\n       uip_ntohl(UIP_ND6_RA_BUF->reachable_time)) {\n      uip_ds6_if.base_reachable_time = uip_ntohl(UIP_ND6_RA_BUF->reachable_time);\n      uip_ds6_if.reachable_time = uip_ds6_compute_reachable_time();\n    }\n  }\n  if(UIP_ND6_RA_BUF->retrans_timer != 0) {\n    uip_ds6_if.retrans_timer = uip_ntohl(UIP_ND6_RA_BUF->retrans_timer);\n  }\n\n  \/* Options processing *\/\n  nd6_opt_offset = UIP_ND6_RA_LEN;\n  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {\n    if(ND6_OPT_HDR_BUF(nd6_opt_offset)->len == 0) {\n      LOG_ERR(\"RA received is bad\");\n      goto discard;\n    }\n    switch (ND6_OPT_HDR_BUF(nd6_opt_offset)->type) {\n    case UIP_ND6_OPT_SLLAO:\n      LOG_DBG(\"Processing SLLAO option in RA\\n\");\n      nd6_opt_llao = (uint8_t *) ND6_OPT_HDR_BUF(nd6_opt_offset);\n      nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);\n      if(!extract_lladdr_from_llao_aligned(&lladdr_aligned)) {\n        \/* failed to extract llao - discard packet *\/\n        goto discard;\n      }\n      if(nbr == NULL) {\n        nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,\n                              1, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);\n      } else {\n        const uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(nbr);\n        if(lladdr == NULL) {\n          goto discard;\n        }\n        if(nbr->state == NBR_INCOMPLETE) {\n          nbr->state = NBR_STALE;\n        }\n        if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],\n                  lladdr, UIP_LLADDR_LEN) != 0) {\n          \/* change of link layer address *\/\n          if(uip_ds6_nbr_update_ll(&nbr,\n                                   (const uip_lladdr_t *)&lladdr_aligned) < 0) {\n            \/* failed to update the lladdr *\/\n            goto discard;\n          }\n          nbr->state = NBR_STALE;\n        }\n        nbr->isrouter = 1;\n      }\n      break;\n    case UIP_ND6_OPT_MTU:\n      LOG_DBG(\"Processing MTU option in RA\\n\");\n      uip_ds6_if.link_mtu =\n        uip_ntohl(((uip_nd6_opt_mtu *) ND6_OPT_HDR_BUF(nd6_opt_offset))->mtu);\n      break;\n    case UIP_ND6_OPT_PREFIX_INFO:\n      LOG_DBG(\"Processing PREFIX option in RA\\n\");\n      nd6_opt_prefix_info = (uip_nd6_opt_prefix_info *) ND6_OPT_HDR_BUF(nd6_opt_offset);\n      if((uip_ntohl(nd6_opt_prefix_info->validlt) >=\n          uip_ntohl(nd6_opt_prefix_info->preferredlt))\n         && (!uip_is_addr_linklocal(&nd6_opt_prefix_info->prefix))) {\n        \/* on-link flag related processing *\/\n        if(nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_ONLINK) {\n          prefix =\n            uip_ds6_prefix_lookup(&nd6_opt_prefix_info->prefix,\n                                  nd6_opt_prefix_info->preflen);\n          if(prefix == NULL) {\n            if(nd6_opt_prefix_info->validlt != 0) {\n              if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {\n                prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,\n                                            nd6_opt_prefix_info->preflen,\n                                            uip_ntohl(nd6_opt_prefix_info->\n                                                  validlt));\n              } else {\n                prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,\n                                            nd6_opt_prefix_info->preflen, 0);\n              }\n            }\n          } else {\n            switch (nd6_opt_prefix_info->validlt) {\n            case 0:\n              uip_ds6_prefix_rm(prefix);\n              break;\n            case UIP_ND6_INFINITE_LIFETIME:\n              prefix->isinfinite = 1;\n              break;\n            default:\n              LOG_DBG(\"Updating timer of prefix \");\n              LOG_DBG_6ADDR(&prefix->ipaddr);\n              LOG_DBG_(\" new value %\"PRIu32\"\\n\", uip_ntohl(nd6_opt_prefix_info->validlt));\n              stimer_set(&prefix->vlifetime,\n                         uip_ntohl(nd6_opt_prefix_info->validlt));\n              prefix->isinfinite = 0;\n              break;\n            }\n          }\n        }\n        \/* End of on-link flag related processing *\/\n        \/* autonomous flag related processing *\/\n        if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS)\n           && (nd6_opt_prefix_info->validlt != 0)\n           && (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) {\n\n          uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix);\n          uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);\n          addr = uip_ds6_addr_lookup(&ipaddr);\n          if((addr != NULL) && (addr->type == ADDR_AUTOCONF)) {\n            if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {\n              \/* The processing below is defined in RFC4862 section 5.5.3 e *\/\n              if((uip_ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) ||\n                 (uip_ntohl(nd6_opt_prefix_info->validlt) >\n                  stimer_remaining(&addr->vlifetime))) {\n                LOG_DBG(\"Updating timer of address \");\n                LOG_DBG_6ADDR(&addr->ipaddr);\n                LOG_DBG_(\" new value %lu\\n\",\n                       (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt));\n                stimer_set(&addr->vlifetime,\n                           uip_ntohl(nd6_opt_prefix_info->validlt));\n              } else {\n                stimer_set(&addr->vlifetime, 2 * 60 * 60);\n                LOG_DBG(\"Updating timer of address \");\n                LOG_DBG_6ADDR(&addr->ipaddr);\n                LOG_DBG_(\" new value %lu\\n\", (unsigned long)(2 * 60 * 60));\n              }\n              addr->isinfinite = 0;\n            } else {\n              addr->isinfinite = 1;\n            }\n          } else {\n            if(uip_ntohl(nd6_opt_prefix_info->validlt) ==\n               UIP_ND6_INFINITE_LIFETIME) {\n              uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);\n            } else {\n              uip_ds6_addr_add(&ipaddr, uip_ntohl(nd6_opt_prefix_info->validlt),\n                               ADDR_AUTOCONF);\n            }\n          }\n        }\n        \/* End of autonomous flag related processing *\/\n      }\n      break;\n#if UIP_ND6_RA_RDNSS\n    case UIP_ND6_OPT_RDNSS:\n      LOG_DBG(\"Processing RDNSS option\\n\");\n      uint8_t naddr = (ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len - 1) \/ 2;\n      uip_ipaddr_t *ip = (uip_ipaddr_t *)(&ND6_OPT_RDNSS_BUF(nd6_opt_offset)->ip);\n      LOG_DBG(\"got %d nameservers\\n\", naddr);\n      while(naddr-- > 0) {\n        LOG_DBG(\"nameserver: \");\n        LOG_DBG_6ADDR(ip);\n        LOG_DBG_(\" lifetime: %\"PRIx32\"\\n\", uip_ntohl(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime));\n        uip_nameserver_update(ip, uip_ntohl(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime));\n        ip++;\n      }\n      break;\n#endif \/* UIP_ND6_RA_RDNSS *\/\n    default:\n      LOG_ERR(\"ND option not supported in RA\\n\");\n      break;\n    }\n    nd6_opt_offset += (ND6_OPT_HDR_BUF(nd6_opt_offset)->len << 3);\n  }\n\n  defrt = uip_ds6_defrt_lookup(&UIP_IP_BUF->srcipaddr);\n  if(UIP_ND6_RA_BUF->router_lifetime != 0) {\n    if(nbr != NULL) {\n      nbr->isrouter = 1;\n    }\n    if(defrt == NULL) {\n      uip_ds6_defrt_add(&UIP_IP_BUF->srcipaddr,\n                        (unsigned\n                         long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime)));\n    } else {\n      stimer_set(&(defrt->lifetime),\n                 (unsigned long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime)));\n    }\n  } else {\n    if(defrt != NULL) {\n      uip_ds6_defrt_rm(defrt);\n    }\n  }\n\n#if UIP_CONF_IPV6_QUEUE_PKT\n  \/* If the nbr just became reachable (e.g. it was in NBR_INCOMPLETE state\n   * and we got a SLLAO), check if we had buffered a pkt for it *\/\n  \/*  if((nbr != NULL) && (nbr->queue_buf_len != 0)) {\n    uip_len = nbr->queue_buf_len;\n    memcpy(UIP_IP_BUF, nbr->queue_buf, uip_len);\n    nbr->queue_buf_len = 0;\n    return;\n    }*\/\n  if(nbr != NULL && uip_packetqueue_buflen(&nbr->packethandle) != 0) {\n    uip_len = uip_packetqueue_buflen(&nbr->packethandle);\n    memcpy(UIP_IP_BUF, uip_packetqueue_buf(&nbr->packethandle), uip_len);\n    uip_packetqueue_free(&nbr->packethandle);\n    return;\n  }\n\n#endif \/*UIP_CONF_IPV6_QUEUE_PKT *\/\n\ndiscard:\n  uipbuf_clear();\n  return;\n}","target":0,"code_token_length":2434,"total_token_length":2670,"max_tokens_setting":4096}
+{"idx":489779,"func":"static void nhmldump_send_header(GF_NHMLDumpCtx *ctx)\n{\n\tGF_FilterPacket *dst_pck;\n\tchar nhml[1024];\n\tu32 size;\n\tu8 *output;\n\tconst GF_PropertyValue *p;\n\n\tctx->szRootName = \"NHNTStream\";\n\tif (ctx->dims) {\n\t\tctx->szRootName = \"DIMSStream\";\n\t}\n\n\tif (!ctx->filep) {\n\t\tsprintf(nhml, \"\\n\");\n\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t}\n\n\t\/*write header*\/\n\tsprintf(nhml, \"<%s version=\\\"1.0\\\" \", ctx->szRootName);\n\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\n\n\tNHML_PRINT_UINT(GF_PROP_PID_ID, NULL, \"trackID\")\n\tNHML_PRINT_UINT(GF_PROP_PID_TIMESCALE, NULL, \"timeScale\")\n\n\tp = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_IN_IOD);\n\tif (p && p->value.boolean) {\n\t\tsprintf(nhml, \"inRootOD=\\\"yes\\\" \");\n\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t}\n\n\tif (ctx->oti && (ctx->otistreamtype, ctx->oti);\n\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32)strlen(nhml));\n\t} else {\n\t\tp = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_SUBTYPE);\n\t\tif (p) {\n\t\t\tsprintf(nhml, \"%s=\\\"%s\\\" \", \"mediaType\", gf_4cc_to_str(p->value.uint));\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\n\t\t\tNHML_PRINT_4CC(GF_PROP_PID_ISOM_SUBTYPE, \"mediaSubType\", \"mediaSubType\")\n\t\t} else {\n\t\t\tNHML_PRINT_4CC(GF_PROP_PID_CODECID, NULL, \"codecID\")\n\t\t}\n\t}\n\n\tif (ctx->w && ctx->h) {\n\t\t\/\/compatibility with old arch, we might want to remove this\n\t\tswitch (ctx->streamtype) {\n\t\tcase GF_STREAM_VISUAL:\n\t\tcase GF_STREAM_SCENE:\n\t\t\tsprintf(nhml, \"width=\\\"%d\\\" height=\\\"%d\\\" \", ctx->w, ctx->h);\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (ctx->sr && ctx->chan) {\n\t\tsprintf(nhml, \"sampleRate=\\\"%d\\\" numChannels=\\\"%d\\\" \", ctx->sr, ctx->chan);\n\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\tp = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_AUDIO_FORMAT);\n\t\tif (p) {\n\t\t\tsprintf(nhml, \"bitsPerSample=\\\"%d\\\" \", gf_audio_fmt_bit_depth(p->value.uint));\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\t}\n\t}\n\n\tNHML_PRINT_4CC(0, \"codec_vendor\", \"codecVendor\")\n\tNHML_PRINT_UINT(0, \"codec_version\", \"codecVersion\")\n\tNHML_PRINT_UINT(0, \"codec_revision\", \"codecRevision\")\n\tNHML_PRINT_STRING(0, \"compressor_name\", \"compressorName\")\n\tNHML_PRINT_UINT(0, \"temporal_quality\", \"temporalQuality\")\n\tNHML_PRINT_UINT(0, \"spatial_quality\", \"spatialQuality\")\n\tNHML_PRINT_UINT(0, \"hres\", \"horizontalResolution\")\n\tNHML_PRINT_UINT(0, \"vres\", \"verticalResolution\")\n\tNHML_PRINT_UINT(GF_PROP_PID_BIT_DEPTH_Y, NULL, \"bitDepth\")\n\n\tNHML_PRINT_STRING(0, \"meta:xmlns\", \"xml_namespace\")\n\tNHML_PRINT_STRING(0, \"meta:schemaloc\", \"xml_schema_location\")\n\tNHML_PRINT_STRING(0, \"meta:mime\", \"mime_type\")\n\n\tNHML_PRINT_STRING(0, \"meta:config\", \"config\")\n\tNHML_PRINT_STRING(0, \"meta:aux_mimes\", \"aux_mime_type\")\n\n\tif (ctx->codecid == GF_CODECID_DIMS) {\n\t\tif (gf_filter_pid_get_property_str(ctx->ipid, \"meta:xmlns\")==NULL) {\n\t\t\tsprintf(nhml, \"xmlns=\\\"http:\/\/www.3gpp.org\/richmedia\\\" \");\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\t}\n\n\t\tNHML_PRINT_UINT(0, \"dims:profile\", \"profile\")\n\t\tNHML_PRINT_UINT(0, \"dims:level\", \"level\")\n\t\tNHML_PRINT_UINT(0, \"dims:pathComponents\", \"pathComponents\")\n\n\t\tp = gf_filter_pid_get_property_str(ctx->ipid, \"dims:fullRequestHost\");\n\t\tif (p) {\n\t\t\tsprintf(nhml, \"useFullRequestHost=\\\"%s\\\" \", p->value.boolean ? \"yes\" : \"no\");\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\t}\n\t\tp = gf_filter_pid_get_property_str(ctx->ipid, \"dims:streamType\");\n\t\tif (p) {\n\t\t\tsprintf(nhml, \"stream_type=\\\"%s\\\" \", p->value.boolean ? \"primary\" : \"secondary\");\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\t}\n\t\tp = gf_filter_pid_get_property_str(ctx->ipid, \"dims:redundant\");\n\t\tif (p) {\n\t\t\tsprintf(nhml, \"contains_redundant=\\\"%s\\\" \", (p->value.uint==1) ? \"main\" : ((p->value.uint==1) ? \"redundant\" : \"main+redundant\") );\n\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t\t}\n\t\tNHML_PRINT_UINT(0, \"dims:scriptTypes\", \"scriptTypes\")\n\t}\n\n\t\/\/send DCD\n\tif (ctx->opid_info) {\n\t\tsprintf(nhml, \"specificInfoFile=\\\"%s\\\" \", gf_file_basename(ctx->info_file) );\n\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\n\t\tdst_pck = gf_filter_pck_new_shared(ctx->opid_info, ctx->dcfg, ctx->dcfg_size, NULL);\n\t\tif (dst_pck) {\n\t\t\tgf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);\n\t\t\tgf_filter_pck_set_readonly(dst_pck);\n\t\t\tgf_filter_pck_send(dst_pck);\n\t\t}\n\t}\n\t\n\tNHML_PRINT_STRING(0, \"meta:encoding\", \"encoding\")\n\tNHML_PRINT_STRING(0, \"meta:contentEncoding\", \"content_encoding\")\n\tctx->uncompress = GF_FALSE;\n\tif (p) {\n\t\tif (!strcmp(p->value.string, \"deflate\")) ctx->uncompress = GF_TRUE;\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (\"[NHMLMx] content_encoding %s not supported\\n\", p->value.string ));\n\t\t}\n\t}\n\n\tif (ctx->opid_mdia) {\n\t\tsprintf(nhml, \"baseMediaFile=\\\"%s\\\" \", gf_file_basename(ctx->media_file) );\n\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\t}\n\tsprintf(nhml, \">\\n\");\n\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\n\tgf_bs_get_content_no_truncate(ctx->bs_w, &ctx->nhml_buffer, &size, &ctx->nhml_buffer_size);\n\n\tif (ctx->filep) {\n\t\tgf_fwrite(ctx->nhml_buffer, size, ctx->filep);\n\t\treturn;\n\t}\n\n\tdst_pck = gf_filter_pck_new_alloc(ctx->opid_nhml, size, &output);\n\tif (!dst_pck) return;\n\n\tmemcpy(output, ctx->nhml_buffer, size);\n\tgf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_FALSE);\n\tgf_filter_pck_send(dst_pck);\n}","target":0,"code_token_length":1913,"total_token_length":2149,"max_tokens_setting":4096}
+{"idx":344940,"func":"nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,\n\t\t\t   struct nf_queue_entry *entry,\n\t\t\t   __be32 **packet_id_ptr)\n{\n\tsize_t size;\n\tsize_t data_len = 0, cap_len = 0;\n\tunsigned int hlen = 0;\n\tstruct sk_buff *skb;\n\tstruct nlattr *nla;\n\tstruct nfqnl_msg_packet_hdr *pmsg;\n\tstruct nlmsghdr *nlh;\n\tstruct nfgenmsg *nfmsg;\n\tstruct sk_buff *entskb = entry->skb;\n\tstruct net_device *indev;\n\tstruct net_device *outdev;\n\tstruct nf_conn *ct = NULL;\n\tenum ip_conntrack_info uninitialized_var(ctinfo);\n\tbool csum_verify;\n\n\tsize =    nlmsg_total_size(sizeof(struct nfgenmsg))\n\t\t+ nla_total_size(sizeof(struct nfqnl_msg_packet_hdr))\n\t\t+ nla_total_size(sizeof(u_int32_t))\t\/* ifindex *\/\n\t\t+ nla_total_size(sizeof(u_int32_t))\t\/* ifindex *\/\n#ifdef CONFIG_BRIDGE_NETFILTER\n\t\t+ nla_total_size(sizeof(u_int32_t))\t\/* ifindex *\/\n\t\t+ nla_total_size(sizeof(u_int32_t))\t\/* ifindex *\/\n#endif\n\t\t+ nla_total_size(sizeof(u_int32_t))\t\/* mark *\/\n\t\t+ nla_total_size(sizeof(struct nfqnl_msg_packet_hw))\n\t\t+ nla_total_size(sizeof(u_int32_t))\t\/* skbinfo *\/\n\t\t+ nla_total_size(sizeof(u_int32_t));\t\/* cap_len *\/\n\n\tif (entskb->tstamp.tv64)\n\t\tsize += nla_total_size(sizeof(struct nfqnl_msg_packet_timestamp));\n\n\tif (entry->hook <= NF_INET_FORWARD ||\n\t   (entry->hook == NF_INET_POST_ROUTING && entskb->sk == NULL))\n\t\tcsum_verify = !skb_csum_unnecessary(entskb);\n\telse\n\t\tcsum_verify = false;\n\n\toutdev = entry->outdev;\n\n\tswitch ((enum nfqnl_config_mode)ACCESS_ONCE(queue->copy_mode)) {\n\tcase NFQNL_COPY_META:\n\tcase NFQNL_COPY_NONE:\n\t\tbreak;\n\n\tcase NFQNL_COPY_PACKET:\n\t\tif (!(queue->flags & NFQA_CFG_F_GSO) &&\n\t\t    entskb->ip_summed == CHECKSUM_PARTIAL &&\n\t\t    skb_checksum_help(entskb))\n\t\t\treturn NULL;\n\n\t\tdata_len = ACCESS_ONCE(queue->copy_range);\n\t\tif (data_len > entskb->len)\n\t\t\tdata_len = entskb->len;\n\n\t\thlen = skb_zerocopy_headlen(entskb);\n\t\thlen = min_t(unsigned int, hlen, data_len);\n\t\tsize += sizeof(struct nlattr) + hlen;\n\t\tcap_len = entskb->len;\n\t\tbreak;\n\t}\n\n\tif (queue->flags & NFQA_CFG_F_CONNTRACK)\n\t\tct = nfqnl_ct_get(entskb, &size, &ctinfo);\n\n\tif (queue->flags & NFQA_CFG_F_UID_GID) {\n\t\tsize +=  (nla_total_size(sizeof(u_int32_t))\t\/* uid *\/\n\t\t\t+ nla_total_size(sizeof(u_int32_t)));\t\/* gid *\/\n\t}\n\n\tskb = nfnetlink_alloc_skb(net, size, queue->peer_portid,\n\t\t\t\t  GFP_ATOMIC);\n\tif (!skb)\n\t\treturn NULL;\n\n\tnlh = nlmsg_put(skb, 0, 0,\n\t\t\tNFNL_SUBSYS_QUEUE << 8 | NFQNL_MSG_PACKET,\n\t\t\tsizeof(struct nfgenmsg), 0);\n\tif (!nlh) {\n\t\tkfree_skb(skb);\n\t\treturn NULL;\n\t}\n\tnfmsg = nlmsg_data(nlh);\n\tnfmsg->nfgen_family = entry->pf;\n\tnfmsg->version = NFNETLINK_V0;\n\tnfmsg->res_id = htons(queue->queue_num);\n\n\tnla = __nla_reserve(skb, NFQA_PACKET_HDR, sizeof(*pmsg));\n\tpmsg = nla_data(nla);\n\tpmsg->hw_protocol\t= entskb->protocol;\n\tpmsg->hook\t\t= entry->hook;\n\t*packet_id_ptr\t\t= &pmsg->packet_id;\n\n\tindev = entry->indev;\n\tif (indev) {\n#ifndef CONFIG_BRIDGE_NETFILTER\n\t\tif (nla_put_be32(skb, NFQA_IFINDEX_INDEV, htonl(indev->ifindex)))\n\t\t\tgoto nla_put_failure;\n#else\n\t\tif (entry->pf == PF_BRIDGE) {\n\t\t\t\/* Case 1: indev is physical input device, we need to\n\t\t\t * look for bridge group (when called from\n\t\t\t * netfilter_bridge) *\/\n\t\t\tif (nla_put_be32(skb, NFQA_IFINDEX_PHYSINDEV,\n\t\t\t\t\t htonl(indev->ifindex)) ||\n\t\t\t\/* this is the bridge group \"brX\" *\/\n\t\t\t\/* rcu_read_lock()ed by __nf_queue *\/\n\t\t\t    nla_put_be32(skb, NFQA_IFINDEX_INDEV,\n\t\t\t\t\t htonl(br_port_get_rcu(indev)->br->dev->ifindex)))\n\t\t\t\tgoto nla_put_failure;\n\t\t} else {\n\t\t\t\/* Case 2: indev is bridge group, we need to look for\n\t\t\t * physical device (when called from ipv4) *\/\n\t\t\tif (nla_put_be32(skb, NFQA_IFINDEX_INDEV,\n\t\t\t\t\t htonl(indev->ifindex)))\n\t\t\t\tgoto nla_put_failure;\n\t\t\tif (entskb->nf_bridge && entskb->nf_bridge->physindev &&\n\t\t\t    nla_put_be32(skb, NFQA_IFINDEX_PHYSINDEV,\n\t\t\t\t\t htonl(entskb->nf_bridge->physindev->ifindex)))\n\t\t\t\tgoto nla_put_failure;\n\t\t}\n#endif\n\t}\n\n\tif (outdev) {\n#ifndef CONFIG_BRIDGE_NETFILTER\n\t\tif (nla_put_be32(skb, NFQA_IFINDEX_OUTDEV, htonl(outdev->ifindex)))\n\t\t\tgoto nla_put_failure;\n#else\n\t\tif (entry->pf == PF_BRIDGE) {\n\t\t\t\/* Case 1: outdev is physical output device, we need to\n\t\t\t * look for bridge group (when called from\n\t\t\t * netfilter_bridge) *\/\n\t\t\tif (nla_put_be32(skb, NFQA_IFINDEX_PHYSOUTDEV,\n\t\t\t\t\t htonl(outdev->ifindex)) ||\n\t\t\t\/* this is the bridge group \"brX\" *\/\n\t\t\t\/* rcu_read_lock()ed by __nf_queue *\/\n\t\t\t    nla_put_be32(skb, NFQA_IFINDEX_OUTDEV,\n\t\t\t\t\t htonl(br_port_get_rcu(outdev)->br->dev->ifindex)))\n\t\t\t\tgoto nla_put_failure;\n\t\t} else {\n\t\t\t\/* Case 2: outdev is bridge group, we need to look for\n\t\t\t * physical output device (when called from ipv4) *\/\n\t\t\tif (nla_put_be32(skb, NFQA_IFINDEX_OUTDEV,\n\t\t\t\t\t htonl(outdev->ifindex)))\n\t\t\t\tgoto nla_put_failure;\n\t\t\tif (entskb->nf_bridge && entskb->nf_bridge->physoutdev &&\n\t\t\t    nla_put_be32(skb, NFQA_IFINDEX_PHYSOUTDEV,\n\t\t\t\t\t htonl(entskb->nf_bridge->physoutdev->ifindex)))\n\t\t\t\tgoto nla_put_failure;\n\t\t}\n#endif\n\t}\n\n\tif (entskb->mark &&\n\t    nla_put_be32(skb, NFQA_MARK, htonl(entskb->mark)))\n\t\tgoto nla_put_failure;\n\n\tif (indev && entskb->dev &&\n\t    entskb->mac_header != entskb->network_header) {\n\t\tstruct nfqnl_msg_packet_hw phw;\n\t\tint len;\n\n\t\tmemset(&phw, 0, sizeof(phw));\n\t\tlen = dev_parse_header(entskb, phw.hw_addr);\n\t\tif (len) {\n\t\t\tphw.hw_addrlen = htons(len);\n\t\t\tif (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))\n\t\t\t\tgoto nla_put_failure;\n\t\t}\n\t}\n\n\tif (entskb->tstamp.tv64) {\n\t\tstruct nfqnl_msg_packet_timestamp ts;\n\t\tstruct timeval tv = ktime_to_timeval(entskb->tstamp);\n\t\tts.sec = cpu_to_be64(tv.tv_sec);\n\t\tts.usec = cpu_to_be64(tv.tv_usec);\n\n\t\tif (nla_put(skb, NFQA_TIMESTAMP, sizeof(ts), &ts))\n\t\t\tgoto nla_put_failure;\n\t}\n\n\tif ((queue->flags & NFQA_CFG_F_UID_GID) && entskb->sk &&\n\t    nfqnl_put_sk_uidgid(skb, entskb->sk) < 0)\n\t\tgoto nla_put_failure;\n\n\tif (ct && nfqnl_ct_put(skb, ct, ctinfo) < 0)\n\t\tgoto nla_put_failure;\n\n\tif (cap_len > data_len &&\n\t    nla_put_be32(skb, NFQA_CAP_LEN, htonl(cap_len)))\n\t\tgoto nla_put_failure;\n\n\tif (nfqnl_put_packet_info(skb, entskb, csum_verify))\n\t\tgoto nla_put_failure;\n\n\tif (data_len) {\n\t\tstruct nlattr *nla;\n\n\t\tif (skb_tailroom(skb) < sizeof(*nla) + hlen)\n\t\t\tgoto nla_put_failure;\n\n\t\tnla = (struct nlattr *)skb_put(skb, sizeof(*nla));\n\t\tnla->nla_type = NFQA_PAYLOAD;\n\t\tnla->nla_len = nla_attr_size(data_len);\n\n\t\tskb_zerocopy(skb, entskb, data_len, hlen);\n\t}\n\n\tnlh->nlmsg_len = skb->len;\n\treturn skb;\n\nnla_put_failure:\n\tkfree_skb(skb);\n\tnet_err_ratelimited(\"nf_queue: error creating packet message\\n\");\n\treturn NULL;\n}","target":1,"code_token_length":2063,"total_token_length":2299,"max_tokens_setting":4096}
+{"idx":236180,"func":"qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,\n    guint32 fourcc, const guint8 * data, int len, gchar ** codec_name)\n{\n  GstCaps *caps;\n  const GstStructure *s;\n  const gchar *name;\n  gint endian = 0;\n\n  GST_DEBUG_OBJECT (qtdemux, \"resolve fourcc %08x\", fourcc);\n\n  switch (fourcc) {\n    case GST_MAKE_FOURCC ('N', 'O', 'N', 'E'):\n    case GST_MAKE_FOURCC ('r', 'a', 'w', ' '):\n      _codec (\"Raw 8-bit PCM audio\");\n      caps = gst_caps_new_simple (\"audio\/x-raw-int\", \"width\", G_TYPE_INT, 8,\n          \"depth\", G_TYPE_INT, 8, \"signed\", G_TYPE_BOOLEAN, FALSE, NULL);\n      break;\n    case GST_MAKE_FOURCC ('t', 'w', 'o', 's'):\n      endian = G_BIG_ENDIAN;\n      \/* fall-through *\/\n    case GST_MAKE_FOURCC ('s', 'o', 'w', 't'):\n    {\n      gchar *str;\n      gint depth;\n\n      if (!endian)\n        endian = G_LITTLE_ENDIAN;\n\n      depth = stream->bytes_per_packet * 8;\n      str = g_strdup_printf (\"Raw %d-bit PCM audio\", depth);\n      _codec (str);\n      g_free (str);\n      caps = gst_caps_new_simple (\"audio\/x-raw-int\",\n          \"width\", G_TYPE_INT, depth, \"depth\", G_TYPE_INT, depth,\n          \"endianness\", G_TYPE_INT, endian,\n          \"signed\", G_TYPE_BOOLEAN, TRUE, NULL);\n      break;\n    }\n    case GST_MAKE_FOURCC ('f', 'l', '6', '4'):\n      _codec (\"Raw 64-bit floating-point audio\");\n      caps = gst_caps_new_simple (\"audio\/x-raw-float\", \"width\", G_TYPE_INT, 64,\n          \"endianness\", G_TYPE_INT, G_BIG_ENDIAN, NULL);\n      break;\n    case GST_MAKE_FOURCC ('f', 'l', '3', '2'):\n      _codec (\"Raw 32-bit floating-point audio\");\n      caps = gst_caps_new_simple (\"audio\/x-raw-float\", \"width\", G_TYPE_INT, 32,\n          \"endianness\", G_TYPE_INT, G_BIG_ENDIAN, NULL);\n      break;\n    case GST_MAKE_FOURCC ('i', 'n', '2', '4'):\n      _codec (\"Raw 24-bit PCM audio\");\n      caps = gst_caps_new_simple (\"audio\/x-raw-int\", \"width\", G_TYPE_INT, 24,\n          \"depth\", G_TYPE_INT, 24,\n          \"endianness\", G_TYPE_INT, G_BIG_ENDIAN,\n          \"signed\", G_TYPE_BOOLEAN, TRUE, NULL);\n      break;\n    case GST_MAKE_FOURCC ('i', 'n', '3', '2'):\n      _codec (\"Raw 32-bit PCM audio\");\n      caps = gst_caps_new_simple (\"audio\/x-raw-int\", \"width\", G_TYPE_INT, 32,\n          \"depth\", G_TYPE_INT, 32,\n          \"endianness\", G_TYPE_INT, G_BIG_ENDIAN,\n          \"signed\", G_TYPE_BOOLEAN, TRUE, NULL);\n      break;\n    case GST_MAKE_FOURCC ('u', 'l', 'a', 'w'):\n      _codec (\"Mu-law audio\");\n      caps = gst_caps_new_simple (\"audio\/x-mulaw\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('a', 'l', 'a', 'w'):\n      _codec (\"A-law audio\");\n      caps = gst_caps_new_simple (\"audio\/x-alaw\", NULL);\n      break;\n    case 0x0200736d:\n    case 0x6d730002:\n      _codec (\"Microsoft ADPCM\");\n      \/* Microsoft ADPCM-ACM code 2 *\/\n      caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n          \"layout\", G_TYPE_STRING, \"microsoft\", NULL);\n      break;\n    case 0x1100736d:\n    case 0x6d730011:\n      _codec (\"IMA Loki SDL MJPEG ADPCM\");\n      \/* Loki ADPCM, See #550288 for a file that only decodes\n       * with the smjpeg variant of the ADPCM decoder. *\/\n      caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n          \"layout\", G_TYPE_STRING, \"smjpeg\", NULL);\n      break;\n    case 0x1700736d:\n    case 0x6d730017:\n      _codec (\"DVI\/Intel IMA ADPCM\");\n      \/* FIXME DVI\/Intel IMA ADPCM\/ACM code 17 *\/\n      caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n          \"layout\", G_TYPE_STRING, \"quicktime\", NULL);\n      break;\n    case 0x5500736d:\n    case 0x6d730055:\n      \/* MPEG layer 3, CBR only (pre QT4.1) *\/\n    case GST_MAKE_FOURCC ('.', 'm', 'p', '3'):\n      _codec (\"MPEG-1 layer 3\");\n      \/* MPEG layer 3, CBR & VBR (QT4.1 and later) *\/\n      caps = gst_caps_new_simple (\"audio\/mpeg\", \"layer\", G_TYPE_INT, 3,\n          \"mpegversion\", G_TYPE_INT, 1, NULL);\n      break;\n    case 0x20736d:\n      _codec (\"AC-3 audio\");\n      caps = gst_caps_new_simple (\"audio\/x-ac3\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('M', 'A', 'C', '3'):\n      _codec (\"MACE-3\");\n      caps = gst_caps_new_simple (\"audio\/x-mace\",\n          \"maceversion\", G_TYPE_INT, 3, NULL);\n      break;\n    case GST_MAKE_FOURCC ('M', 'A', 'C', '6'):\n      _codec (\"MACE-6\");\n      caps = gst_caps_new_simple (\"audio\/x-mace\",\n          \"maceversion\", G_TYPE_INT, 6, NULL);\n      break;\n    case GST_MAKE_FOURCC ('O', 'g', 'g', 'V'):\n      \/* ogg\/vorbis *\/\n      caps = gst_caps_new_simple (\"application\/ogg\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('d', 'v', 'c', 'a'):\n      _codec (\"DV audio\");\n      caps = gst_caps_new_simple (\"audio\/x-dv\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('m', 'p', '4', 'a'):\n      _codec (\"MPEG-4 AAC audio\");\n      caps = gst_caps_new_simple (\"audio\/mpeg\",\n          \"mpegversion\", G_TYPE_INT, 4, \"framed\", G_TYPE_BOOLEAN, TRUE, NULL);\n      break;\n    case GST_MAKE_FOURCC ('Q', 'D', 'M', 'C'):\n      _codec (\"QDesign Music\");\n      caps = gst_caps_new_simple (\"audio\/x-qdm\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('Q', 'D', 'M', '2'):\n      _codec (\"QDesign Music v.2\");\n      \/* FIXME: QDesign music version 2 (no constant) *\/\n      if (data) {\n        caps = gst_caps_new_simple (\"audio\/x-qdm2\",\n            \"framesize\", G_TYPE_INT, QT_UINT32 (data + 52),\n            \"bitrate\", G_TYPE_INT, QT_UINT32 (data + 40),\n            \"blocksize\", G_TYPE_INT, QT_UINT32 (data + 44), NULL);\n      } else {\n        caps = gst_caps_new_simple (\"audio\/x-qdm2\", NULL);\n      }\n      break;\n    case GST_MAKE_FOURCC ('a', 'g', 's', 'm'):\n      _codec (\"GSM audio\");\n      caps = gst_caps_new_simple (\"audio\/x-gsm\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('s', 'a', 'm', 'r'):\n      _codec (\"AMR audio\");\n      caps = gst_caps_new_simple (\"audio\/AMR\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('s', 'a', 'w', 'b'):\n      _codec (\"AMR-WB audio\");\n      caps = gst_caps_new_simple (\"audio\/AMR-WB\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('i', 'm', 'a', '4'):\n      _codec (\"Quicktime IMA ADPCM\");\n      caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n          \"layout\", G_TYPE_STRING, \"quicktime\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('a', 'l', 'a', 'c'):\n      _codec (\"Apple lossless audio\");\n      caps = gst_caps_new_simple (\"audio\/x-alac\", NULL);\n      break;\n    case GST_MAKE_FOURCC ('q', 't', 'v', 'r'):\n      \/* ? *\/\n    case GST_MAKE_FOURCC ('Q', 'c', 'l', 'p'):\n      \/* QUALCOMM PureVoice *\/\n    default:\n    {\n      char *s;\n\n      s = g_strdup_printf (\"audio\/x-gst-fourcc-%\" GST_FOURCC_FORMAT,\n          GST_FOURCC_ARGS (fourcc));\n      caps = gst_caps_new_simple (s, NULL);\n      break;\n    }\n  }\n\n  \/* enable clipping for raw audio streams *\/\n  s = gst_caps_get_structure (caps, 0);\n  name = gst_structure_get_name (s);\n  if (g_str_has_prefix (name, \"audio\/x-raw-\")) {\n    stream->need_clip = TRUE;\n  }\n  return caps;\n}\n","target":0,"code_token_length":2152,"total_token_length":2388,"max_tokens_setting":4096}
+{"idx":155649,"func":"static int irda_getsockopt(struct socket *sock, int level, int optname,\n\t\t\t   char __user *optval, int __user *optlen)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct irda_sock *self = irda_sk(sk);\n\tstruct irda_device_list list;\n\tstruct irda_device_info *discoveries;\n\tstruct irda_ias_set *\tias_opt;\t\/* IAS get\/query params *\/\n\tstruct ias_object *\tias_obj;\t\/* Object in IAS *\/\n\tstruct ias_attrib *\tias_attr;\t\/* Attribute in IAS object *\/\n\tint daddr = DEV_ADDR_ANY;\t\/* Dest address for IAS queries *\/\n\tint val = 0;\n\tint len = 0;\n\tint err = 0;\n\tint offset, total;\n\n\tIRDA_DEBUG(2, \"%s(%p)\\n\", __func__, self);\n\n\tif (level != SOL_IRLMP)\n\t\treturn -ENOPROTOOPT;\n\n\tif (get_user(len, optlen))\n\t\treturn -EFAULT;\n\n\tif(len < 0)\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\tcase IRLMP_ENUMDEVICES:\n\n\t\t\/* Offset to first device entry *\/\n\t\toffset = sizeof(struct irda_device_list) -\n\t\t\tsizeof(struct irda_device_info);\n\n\t\tif (len < offset) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Ask lmp for the current discovery log *\/\n\t\tdiscoveries = irlmp_get_discoveries(&list.len, self->mask.word,\n\t\t\t\t\t\t    self->nslots);\n\t\t\/* Check if the we got some results *\/\n\t\tif (discoveries == NULL) {\n\t\t\terr = -EAGAIN;\n\t\t\tgoto out;\t\t\/* Didn't find any devices *\/\n\t\t}\n\n\t\t\/* Write total list length back to client *\/\n\t\tif (copy_to_user(optval, &list, offset))\n\t\t\terr = -EFAULT;\n\n\t\t\/* Copy the list itself - watch for overflow *\/\n\t\tif (list.len > 2048) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto bed;\n\t\t}\n\t\ttotal = offset + (list.len * sizeof(struct irda_device_info));\n\t\tif (total > len)\n\t\t\ttotal = len;\n\t\tif (copy_to_user(optval+offset, discoveries, total - offset))\n\t\t\terr = -EFAULT;\n\n\t\t\/* Write total number of bytes used back to client *\/\n\t\tif (put_user(total, optlen))\n\t\t\terr = -EFAULT;\nbed:\n\t\t\/* Free up our buffer *\/\n\t\tkfree(discoveries);\n\t\tbreak;\n\tcase IRLMP_MAX_SDU_SIZE:\n\t\tval = self->max_data_size;\n\t\tlen = sizeof(int);\n\t\tif (put_user(len, optlen)) {\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (copy_to_user(optval, &val, len)) {\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\n\t\tbreak;\n\tcase IRLMP_IAS_GET:\n\t\t\/* The user want an object from our local IAS database.\n\t\t * We just need to query the IAS and return the value\n\t\t * that we found *\/\n\n\t\t\/* Check that the user has allocated the right space for us *\/\n\t\tif (len != sizeof(struct irda_ias_set)) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\tias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC);\n\t\tif (ias_opt == NULL) {\n\t\t\terr = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Copy query to the driver. *\/\n\t\tif (copy_from_user(ias_opt, optval, len)) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Find the object we target.\n\t\t * If the user gives us an empty string, we use the object\n\t\t * associated with this socket. This will workaround\n\t\t * duplicated class name - Jean II *\/\n\t\tif(ias_opt->irda_class_name[0] == '\\0')\n\t\t\tias_obj = self->ias_obj;\n\t\telse\n\t\t\tias_obj = irias_find_object(ias_opt->irda_class_name);\n\t\tif(ias_obj == (struct ias_object *) NULL) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Find the attribute (in the object) we target *\/\n\t\tias_attr = irias_find_attrib(ias_obj,\n\t\t\t\t\t     ias_opt->irda_attrib_name);\n\t\tif(ias_attr == (struct ias_attrib *) NULL) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Translate from internal to user structure *\/\n\t\terr = irda_extract_ias_value(ias_opt, ias_attr->value);\n\t\tif(err) {\n\t\t\tkfree(ias_opt);\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Copy reply to the user *\/\n\t\tif (copy_to_user(optval, ias_opt,\n\t\t\t\t sizeof(struct irda_ias_set))) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\t\t\/* Note : don't need to put optlen, we checked it *\/\n\t\tkfree(ias_opt);\n\t\tbreak;\n\tcase IRLMP_IAS_QUERY:\n\t\t\/* The user want an object from a remote IAS database.\n\t\t * We need to use IAP to query the remote database and\n\t\t * then wait for the answer to come back. *\/\n\n\t\t\/* Check that the user has allocated the right space for us *\/\n\t\tif (len != sizeof(struct irda_ias_set)) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\tias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC);\n\t\tif (ias_opt == NULL) {\n\t\t\terr = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Copy query to the driver. *\/\n\t\tif (copy_from_user(ias_opt, optval, len)) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* At this point, there are two cases...\n\t\t * 1) the socket is connected - that's the easy case, we\n\t\t *\tjust query the device we are connected to...\n\t\t * 2) the socket is not connected - the user doesn't want\n\t\t *\tto connect and\/or may not have a valid service name\n\t\t *\t(so can't create a fake connection). In this case,\n\t\t *\twe assume that the user pass us a valid destination\n\t\t *\taddress in the requesting structure...\n\t\t *\/\n\t\tif(self->daddr != DEV_ADDR_ANY) {\n\t\t\t\/* We are connected - reuse known daddr *\/\n\t\t\tdaddr = self->daddr;\n\t\t} else {\n\t\t\t\/* We are not connected, we must specify a valid\n\t\t\t * destination address *\/\n\t\t\tdaddr = ias_opt->daddr;\n\t\t\tif((!daddr) || (daddr == DEV_ADDR_ANY)) {\n\t\t\t\tkfree(ias_opt);\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\n\t\t\/* Check that we can proceed with IAP *\/\n\t\tif (self->iriap) {\n\t\t\tIRDA_WARNING(\"%s: busy with a previous query\\n\",\n\t\t\t\t     __func__);\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EBUSY;\n\t\t\tgoto out;\n\t\t}\n\n\t\tself->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,\n\t\t\t\t\t irda_getvalue_confirm);\n\n\t\tif (self->iriap == NULL) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Treat unexpected wakeup as disconnect *\/\n\t\tself->errno = -EHOSTUNREACH;\n\n\t\t\/* Query remote LM-IAS *\/\n\t\tiriap_getvaluebyclass_request(self->iriap,\n\t\t\t\t\t      self->saddr, daddr,\n\t\t\t\t\t      ias_opt->irda_class_name,\n\t\t\t\t\t      ias_opt->irda_attrib_name);\n\n\t\t\/* Wait for answer, if not yet finished (or failed) *\/\n\t\tif (wait_event_interruptible(self->query_wait,\n\t\t\t\t\t     (self->iriap == NULL))) {\n\t\t\t\/* pending request uses copy of ias_opt-content\n\t\t\t * we can free it regardless! *\/\n\t\t\tkfree(ias_opt);\n\t\t\t\/* Treat signals as disconnect *\/\n\t\t\terr = -EHOSTUNREACH;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Check what happened *\/\n\t\tif (self->errno)\n\t\t{\n\t\t\tkfree(ias_opt);\n\t\t\t\/* Requested object\/attribute doesn't exist *\/\n\t\t\tif((self->errno == IAS_CLASS_UNKNOWN) ||\n\t\t\t   (self->errno == IAS_ATTRIB_UNKNOWN))\n\t\t\t\terr = -EADDRNOTAVAIL;\n\t\t\telse\n\t\t\t\terr = -EHOSTUNREACH;\n\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Translate from internal to user structure *\/\n\t\terr = irda_extract_ias_value(ias_opt, self->ias_result);\n\t\tif (self->ias_result)\n\t\t\tirias_delete_value(self->ias_result);\n\t\tif (err) {\n\t\t\tkfree(ias_opt);\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Copy reply to the user *\/\n\t\tif (copy_to_user(optval, ias_opt,\n\t\t\t\t sizeof(struct irda_ias_set))) {\n\t\t\tkfree(ias_opt);\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\t\t\/* Note : don't need to put optlen, we checked it *\/\n\t\tkfree(ias_opt);\n\t\tbreak;\n\tcase IRLMP_WAITDEVICE:\n\t\t\/* This function is just another way of seeing life ;-)\n\t\t * IRLMP_ENUMDEVICES assumes that you have a static network,\n\t\t * and that you just want to pick one of the devices present.\n\t\t * On the other hand, in here we assume that no device is\n\t\t * present and that at some point in the future a device will\n\t\t * come into range. When this device arrive, we just wake\n\t\t * up the caller, so that he has time to connect to it before\n\t\t * the device goes away...\n\t\t * Note : once the node has been discovered for more than a\n\t\t * few second, it won't trigger this function, unless it\n\t\t * goes away and come back changes its hint bits (so we\n\t\t * might call it IRLMP_WAITNEWDEVICE).\n\t\t *\/\n\n\t\t\/* Check that the user is passing us an int *\/\n\t\tif (len != sizeof(int)) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\t\t\/* Get timeout in ms (max time we block the caller) *\/\n\t\tif (get_user(val, (int __user *)optval)) {\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Tell IrLMP we want to be notified *\/\n\t\tirlmp_update_client(self->ckey, self->mask.word,\n\t\t\t\t    irda_selective_discovery_indication,\n\t\t\t\t    NULL, (void *) self);\n\n\t\t\/* Do some discovery (and also return cached results) *\/\n\t\tirlmp_discovery_request(self->nslots);\n\n\t\t\/* Wait until a node is discovered *\/\n\t\tif (!self->cachedaddr) {\n\t\t\tIRDA_DEBUG(1, \"%s(), nothing discovered yet, going to sleep...\\n\", __func__);\n\n\t\t\t\/* Set watchdog timer to expire in  ms. *\/\n\t\t\tself->errno = 0;\n\t\t\tsetup_timer(&self->watchdog, irda_discovery_timeout,\n\t\t\t\t\t(unsigned long)self);\n\t\t\tmod_timer(&self->watchdog,\n\t\t\t\t  jiffies + msecs_to_jiffies(val));\n\n\t\t\t\/* Wait for IR-LMP to call us back *\/\n\t\t\terr = __wait_event_interruptible(self->query_wait,\n\t\t\t      (self->cachedaddr != 0 || self->errno == -ETIME));\n\n\t\t\t\/* If watchdog is still activated, kill it! *\/\n\t\t\tdel_timer(&(self->watchdog));\n\n\t\t\tIRDA_DEBUG(1, \"%s(), ...waking up !\\n\", __func__);\n\n\t\t\tif (err != 0)\n\t\t\t\tgoto out;\n\t\t}\n\t\telse\n\t\t\tIRDA_DEBUG(1, \"%s(), found immediately !\\n\",\n\t\t\t\t   __func__);\n\n\t\t\/* Tell IrLMP that we have been notified *\/\n\t\tirlmp_update_client(self->ckey, self->mask.word,\n\t\t\t\t    NULL, NULL, NULL);\n\n\t\t\/* Check if the we got some results *\/\n\t\tif (!self->cachedaddr) {\n\t\t\terr = -EAGAIN;\t\t\/* Didn't find any devices *\/\n\t\t\tgoto out;\n\t\t}\n\t\tdaddr = self->cachedaddr;\n\t\t\/* Cleanup *\/\n\t\tself->cachedaddr = 0;\n\n\t\t\/* We return the daddr of the device that trigger the\n\t\t * wakeup. As irlmp pass us only the new devices, we\n\t\t * are sure that it's not an old device.\n\t\t * If the user want more details, he should query\n\t\t * the whole discovery log and pick one device...\n\t\t *\/\n\t\tif (put_user(daddr, (int __user *)optval)) {\n\t\t\terr = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\n\t\tbreak;\n\tdefault:\n\t\terr = -ENOPROTOOPT;\n\t}\n\nout:\n\n\trelease_sock(sk);\n\n\treturn err;\n}","target":0,"code_token_length":2839,"total_token_length":3075,"max_tokens_setting":4096}
+{"idx":142592,"func":"static int fixup_bpf_calls(struct bpf_verifier_env *env)\n{\n\tstruct bpf_prog *prog = env->prog;\n\tbool expect_blinding = bpf_jit_blinding_enabled(prog);\n\tstruct bpf_insn *insn = prog->insnsi;\n\tconst struct bpf_func_proto *fn;\n\tconst int insn_cnt = prog->len;\n\tconst struct bpf_map_ops *ops;\n\tstruct bpf_insn_aux_data *aux;\n\tstruct bpf_insn insn_buf[16];\n\tstruct bpf_prog *new_prog;\n\tstruct bpf_map *map_ptr;\n\tint i, ret, cnt, delta = 0;\n\n\tfor (i = 0; i < insn_cnt; i++, insn++) {\n\t\tif (insn->code == (BPF_ALU64 | BPF_MOD | BPF_X) ||\n\t\t    insn->code == (BPF_ALU64 | BPF_DIV | BPF_X) ||\n\t\t    insn->code == (BPF_ALU | BPF_MOD | BPF_X) ||\n\t\t    insn->code == (BPF_ALU | BPF_DIV | BPF_X)) {\n\t\t\tbool is64 = BPF_CLASS(insn->code) == BPF_ALU64;\n\t\t\tstruct bpf_insn mask_and_div[] = {\n\t\t\t\tBPF_MOV32_REG(insn->src_reg, insn->src_reg),\n\t\t\t\t\/* Rx div 0 -> 0 *\/\n\t\t\t\tBPF_JMP_IMM(BPF_JNE, insn->src_reg, 0, 2),\n\t\t\t\tBPF_ALU32_REG(BPF_XOR, insn->dst_reg, insn->dst_reg),\n\t\t\t\tBPF_JMP_IMM(BPF_JA, 0, 0, 1),\n\t\t\t\t*insn,\n\t\t\t};\n\t\t\tstruct bpf_insn mask_and_mod[] = {\n\t\t\t\tBPF_MOV32_REG(insn->src_reg, insn->src_reg),\n\t\t\t\t\/* Rx mod 0 -> Rx *\/\n\t\t\t\tBPF_JMP_IMM(BPF_JEQ, insn->src_reg, 0, 1),\n\t\t\t\t*insn,\n\t\t\t};\n\t\t\tstruct bpf_insn *patchlet;\n\n\t\t\tif (insn->code == (BPF_ALU64 | BPF_DIV | BPF_X) ||\n\t\t\t    insn->code == (BPF_ALU | BPF_DIV | BPF_X)) {\n\t\t\t\tpatchlet = mask_and_div + (is64 ? 1 : 0);\n\t\t\t\tcnt = ARRAY_SIZE(mask_and_div) - (is64 ? 1 : 0);\n\t\t\t} else {\n\t\t\t\tpatchlet = mask_and_mod + (is64 ? 1 : 0);\n\t\t\t\tcnt = ARRAY_SIZE(mask_and_mod) - (is64 ? 1 : 0);\n\t\t\t}\n\n\t\t\tnew_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt);\n\t\t\tif (!new_prog)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tdelta    += cnt - 1;\n\t\t\tenv->prog = prog = new_prog;\n\t\t\tinsn      = new_prog->insnsi + i + delta;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (BPF_CLASS(insn->code) == BPF_LD &&\n\t\t    (BPF_MODE(insn->code) == BPF_ABS ||\n\t\t     BPF_MODE(insn->code) == BPF_IND)) {\n\t\t\tcnt = env->ops->gen_ld_abs(insn, insn_buf);\n\t\t\tif (cnt == 0 || cnt >= ARRAY_SIZE(insn_buf)) {\n\t\t\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\tnew_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);\n\t\t\tif (!new_prog)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tdelta    += cnt - 1;\n\t\t\tenv->prog = prog = new_prog;\n\t\t\tinsn      = new_prog->insnsi + i + delta;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (insn->code == (BPF_ALU64 | BPF_ADD | BPF_X) ||\n\t\t    insn->code == (BPF_ALU64 | BPF_SUB | BPF_X)) {\n\t\t\tconst u8 code_add = BPF_ALU64 | BPF_ADD | BPF_X;\n\t\t\tconst u8 code_sub = BPF_ALU64 | BPF_SUB | BPF_X;\n\t\t\tstruct bpf_insn insn_buf[16];\n\t\t\tstruct bpf_insn *patch = &insn_buf[0];\n\t\t\tbool issrc, isneg;\n\t\t\tu32 off_reg;\n\n\t\t\taux = &env->insn_aux_data[i + delta];\n\t\t\tif (!aux->alu_state ||\n\t\t\t    aux->alu_state == BPF_ALU_NON_POINTER)\n\t\t\t\tcontinue;\n\n\t\t\tisneg = aux->alu_state & BPF_ALU_NEG_VALUE;\n\t\t\tissrc = (aux->alu_state & BPF_ALU_SANITIZE) ==\n\t\t\t\tBPF_ALU_SANITIZE_SRC;\n\n\t\t\toff_reg = issrc ? insn->src_reg : insn->dst_reg;\n\t\t\tif (isneg)\n\t\t\t\t*patch++ = BPF_ALU64_IMM(BPF_MUL, off_reg, -1);\n\t\t\t*patch++ = BPF_MOV32_IMM(BPF_REG_AX, aux->alu_limit - 1);\n\t\t\t*patch++ = BPF_ALU64_REG(BPF_SUB, BPF_REG_AX, off_reg);\n\t\t\t*patch++ = BPF_ALU64_REG(BPF_OR, BPF_REG_AX, off_reg);\n\t\t\t*patch++ = BPF_ALU64_IMM(BPF_NEG, BPF_REG_AX, 0);\n\t\t\t*patch++ = BPF_ALU64_IMM(BPF_ARSH, BPF_REG_AX, 63);\n\t\t\tif (issrc) {\n\t\t\t\t*patch++ = BPF_ALU64_REG(BPF_AND, BPF_REG_AX,\n\t\t\t\t\t\t\t off_reg);\n\t\t\t\tinsn->src_reg = BPF_REG_AX;\n\t\t\t} else {\n\t\t\t\t*patch++ = BPF_ALU64_REG(BPF_AND, off_reg,\n\t\t\t\t\t\t\t BPF_REG_AX);\n\t\t\t}\n\t\t\tif (isneg)\n\t\t\t\tinsn->code = insn->code == code_add ?\n\t\t\t\t\t     code_sub : code_add;\n\t\t\t*patch++ = *insn;\n\t\t\tif (issrc && isneg)\n\t\t\t\t*patch++ = BPF_ALU64_IMM(BPF_MUL, off_reg, -1);\n\t\t\tcnt = patch - insn_buf;\n\n\t\t\tnew_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);\n\t\t\tif (!new_prog)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tdelta    += cnt - 1;\n\t\t\tenv->prog = prog = new_prog;\n\t\t\tinsn      = new_prog->insnsi + i + delta;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (insn->code != (BPF_JMP | BPF_CALL))\n\t\t\tcontinue;\n\t\tif (insn->src_reg == BPF_PSEUDO_CALL)\n\t\t\tcontinue;\n\n\t\tif (insn->imm == BPF_FUNC_get_route_realm)\n\t\t\tprog->dst_needed = 1;\n\t\tif (insn->imm == BPF_FUNC_get_prandom_u32)\n\t\t\tbpf_user_rnd_init_once();\n\t\tif (insn->imm == BPF_FUNC_override_return)\n\t\t\tprog->kprobe_override = 1;\n\t\tif (insn->imm == BPF_FUNC_tail_call) {\n\t\t\t\/* If we tail call into other programs, we\n\t\t\t * cannot make any assumptions since they can\n\t\t\t * be replaced dynamically during runtime in\n\t\t\t * the program array.\n\t\t\t *\/\n\t\t\tprog->cb_access = 1;\n\t\t\tenv->prog->aux->stack_depth = MAX_BPF_STACK;\n\t\t\tenv->prog->aux->max_pkt_offset = MAX_PACKET_OFF;\n\n\t\t\t\/* mark bpf_tail_call as different opcode to avoid\n\t\t\t * conditional branch in the interpeter for every normal\n\t\t\t * call and to prevent accidental JITing by JIT compiler\n\t\t\t * that doesn't support bpf_tail_call yet\n\t\t\t *\/\n\t\t\tinsn->imm = 0;\n\t\t\tinsn->code = BPF_JMP | BPF_TAIL_CALL;\n\n\t\t\taux = &env->insn_aux_data[i + delta];\n\t\t\tif (env->bpf_capable && !expect_blinding &&\n\t\t\t    prog->jit_requested &&\n\t\t\t    !bpf_map_key_poisoned(aux) &&\n\t\t\t    !bpf_map_ptr_poisoned(aux) &&\n\t\t\t    !bpf_map_ptr_unpriv(aux)) {\n\t\t\t\tstruct bpf_jit_poke_descriptor desc = {\n\t\t\t\t\t.reason = BPF_POKE_REASON_TAIL_CALL,\n\t\t\t\t\t.tail_call.map = BPF_MAP_PTR(aux->map_ptr_state),\n\t\t\t\t\t.tail_call.key = bpf_map_key_immediate(aux),\n\t\t\t\t};\n\n\t\t\t\tret = bpf_jit_add_poke_descriptor(prog, &desc);\n\t\t\t\tif (ret < 0) {\n\t\t\t\t\tverbose(env, \"adding tail call poke descriptor failed\\n\");\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\n\t\t\t\tinsn->imm = ret + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!bpf_map_ptr_unpriv(aux))\n\t\t\t\tcontinue;\n\n\t\t\t\/* instead of changing every JIT dealing with tail_call\n\t\t\t * emit two extra insns:\n\t\t\t * if (index >= max_entries) goto out;\n\t\t\t * index &= array->index_mask;\n\t\t\t * to avoid out-of-bounds cpu speculation\n\t\t\t *\/\n\t\t\tif (bpf_map_ptr_poisoned(aux)) {\n\t\t\t\tverbose(env, \"tail_call abusing map_ptr\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\tmap_ptr = BPF_MAP_PTR(aux->map_ptr_state);\n\t\t\tinsn_buf[0] = BPF_JMP_IMM(BPF_JGE, BPF_REG_3,\n\t\t\t\t\t\t  map_ptr->max_entries, 2);\n\t\t\tinsn_buf[1] = BPF_ALU32_IMM(BPF_AND, BPF_REG_3,\n\t\t\t\t\t\t    container_of(map_ptr,\n\t\t\t\t\t\t\t\t struct bpf_array,\n\t\t\t\t\t\t\t\t map)->index_mask);\n\t\t\tinsn_buf[2] = *insn;\n\t\t\tcnt = 3;\n\t\t\tnew_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);\n\t\t\tif (!new_prog)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tdelta    += cnt - 1;\n\t\t\tenv->prog = prog = new_prog;\n\t\t\tinsn      = new_prog->insnsi + i + delta;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* BPF_EMIT_CALL() assumptions in some of the map_gen_lookup\n\t\t * and other inlining handlers are currently limited to 64 bit\n\t\t * only.\n\t\t *\/\n\t\tif (prog->jit_requested && BITS_PER_LONG == 64 &&\n\t\t    (insn->imm == BPF_FUNC_map_lookup_elem ||\n\t\t     insn->imm == BPF_FUNC_map_update_elem ||\n\t\t     insn->imm == BPF_FUNC_map_delete_elem ||\n\t\t     insn->imm == BPF_FUNC_map_push_elem   ||\n\t\t     insn->imm == BPF_FUNC_map_pop_elem    ||\n\t\t     insn->imm == BPF_FUNC_map_peek_elem)) {\n\t\t\taux = &env->insn_aux_data[i + delta];\n\t\t\tif (bpf_map_ptr_poisoned(aux))\n\t\t\t\tgoto patch_call_imm;\n\n\t\t\tmap_ptr = BPF_MAP_PTR(aux->map_ptr_state);\n\t\t\tops = map_ptr->ops;\n\t\t\tif (insn->imm == BPF_FUNC_map_lookup_elem &&\n\t\t\t    ops->map_gen_lookup) {\n\t\t\t\tcnt = ops->map_gen_lookup(map_ptr, insn_buf);\n\t\t\t\tif (cnt == 0 || cnt >= ARRAY_SIZE(insn_buf)) {\n\t\t\t\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\t\t\t\treturn -EINVAL;\n\t\t\t\t}\n\n\t\t\t\tnew_prog = bpf_patch_insn_data(env, i + delta,\n\t\t\t\t\t\t\t       insn_buf, cnt);\n\t\t\t\tif (!new_prog)\n\t\t\t\t\treturn -ENOMEM;\n\n\t\t\t\tdelta    += cnt - 1;\n\t\t\t\tenv->prog = prog = new_prog;\n\t\t\t\tinsn      = new_prog->insnsi + i + delta;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tBUILD_BUG_ON(!__same_type(ops->map_lookup_elem,\n\t\t\t\t     (void *(*)(struct bpf_map *map, void *key))NULL));\n\t\t\tBUILD_BUG_ON(!__same_type(ops->map_delete_elem,\n\t\t\t\t     (int (*)(struct bpf_map *map, void *key))NULL));\n\t\t\tBUILD_BUG_ON(!__same_type(ops->map_update_elem,\n\t\t\t\t     (int (*)(struct bpf_map *map, void *key, void *value,\n\t\t\t\t\t      u64 flags))NULL));\n\t\t\tBUILD_BUG_ON(!__same_type(ops->map_push_elem,\n\t\t\t\t     (int (*)(struct bpf_map *map, void *value,\n\t\t\t\t\t      u64 flags))NULL));\n\t\t\tBUILD_BUG_ON(!__same_type(ops->map_pop_elem,\n\t\t\t\t     (int (*)(struct bpf_map *map, void *value))NULL));\n\t\t\tBUILD_BUG_ON(!__same_type(ops->map_peek_elem,\n\t\t\t\t     (int (*)(struct bpf_map *map, void *value))NULL));\n\n\t\t\tswitch (insn->imm) {\n\t\t\tcase BPF_FUNC_map_lookup_elem:\n\t\t\t\tinsn->imm = BPF_CAST_CALL(ops->map_lookup_elem) -\n\t\t\t\t\t    __bpf_call_base;\n\t\t\t\tcontinue;\n\t\t\tcase BPF_FUNC_map_update_elem:\n\t\t\t\tinsn->imm = BPF_CAST_CALL(ops->map_update_elem) -\n\t\t\t\t\t    __bpf_call_base;\n\t\t\t\tcontinue;\n\t\t\tcase BPF_FUNC_map_delete_elem:\n\t\t\t\tinsn->imm = BPF_CAST_CALL(ops->map_delete_elem) -\n\t\t\t\t\t    __bpf_call_base;\n\t\t\t\tcontinue;\n\t\t\tcase BPF_FUNC_map_push_elem:\n\t\t\t\tinsn->imm = BPF_CAST_CALL(ops->map_push_elem) -\n\t\t\t\t\t    __bpf_call_base;\n\t\t\t\tcontinue;\n\t\t\tcase BPF_FUNC_map_pop_elem:\n\t\t\t\tinsn->imm = BPF_CAST_CALL(ops->map_pop_elem) -\n\t\t\t\t\t    __bpf_call_base;\n\t\t\t\tcontinue;\n\t\t\tcase BPF_FUNC_map_peek_elem:\n\t\t\t\tinsn->imm = BPF_CAST_CALL(ops->map_peek_elem) -\n\t\t\t\t\t    __bpf_call_base;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tgoto patch_call_imm;\n\t\t}\n\n\t\tif (prog->jit_requested && BITS_PER_LONG == 64 &&\n\t\t    insn->imm == BPF_FUNC_jiffies64) {\n\t\t\tstruct bpf_insn ld_jiffies_addr[2] = {\n\t\t\t\tBPF_LD_IMM64(BPF_REG_0,\n\t\t\t\t\t     (unsigned long)&jiffies),\n\t\t\t};\n\n\t\t\tinsn_buf[0] = ld_jiffies_addr[0];\n\t\t\tinsn_buf[1] = ld_jiffies_addr[1];\n\t\t\tinsn_buf[2] = BPF_LDX_MEM(BPF_DW, BPF_REG_0,\n\t\t\t\t\t\t  BPF_REG_0, 0);\n\t\t\tcnt = 3;\n\n\t\t\tnew_prog = bpf_patch_insn_data(env, i + delta, insn_buf,\n\t\t\t\t\t\t       cnt);\n\t\t\tif (!new_prog)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tdelta    += cnt - 1;\n\t\t\tenv->prog = prog = new_prog;\n\t\t\tinsn      = new_prog->insnsi + i + delta;\n\t\t\tcontinue;\n\t\t}\n\npatch_call_imm:\n\t\tfn = env->ops->get_func_proto(insn->imm, env->prog);\n\t\t\/* all functions that have prototype and verifier allowed\n\t\t * programs to call them, must be real in-kernel functions\n\t\t *\/\n\t\tif (!fn->func) {\n\t\t\tverbose(env,\n\t\t\t\t\"kernel subsystem misconfigured func %s#%d\\n\",\n\t\t\t\tfunc_id_name(insn->imm), insn->imm);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\tinsn->imm = fn->func - __bpf_call_base;\n\t}\n\n\t\/* Since poke tab is now finalized, publish aux to tracker. *\/\n\tfor (i = 0; i < prog->aux->size_poke_tab; i++) {\n\t\tmap_ptr = prog->aux->poke_tab[i].tail_call.map;\n\t\tif (!map_ptr->ops->map_poke_track ||\n\t\t    !map_ptr->ops->map_poke_untrack ||\n\t\t    !map_ptr->ops->map_poke_run) {\n\t\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tret = map_ptr->ops->map_poke_track(map_ptr, prog->aux);\n\t\tif (ret < 0) {\n\t\t\tverbose(env, \"tracking tail call prog failed\\n\");\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":3492,"total_token_length":3728,"max_tokens_setting":4096}
+{"idx":484185,"func":"mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq,\n\t\t\t  struct rte_mbuf **__rte_restrict pkts,\n\t\t\t  unsigned int pkts_n,\n\t\t\t  struct mlx5_txq_local *__rte_restrict loc,\n\t\t\t  unsigned int olx)\n{\n\t\/*\n\t * Subroutine is the part of mlx5_tx_burst_single()\n\t * and sends single-segment packet with SEND opcode.\n\t *\/\n\tMLX5_ASSERT(loc->elts_free && loc->wqe_free);\n\tMLX5_ASSERT(pkts_n > loc->pkts_sent);\n\tpkts += loc->pkts_sent + 1;\n\tpkts_n -= loc->pkts_sent;\n\tfor (;;) {\n\t\tstruct mlx5_wqe *__rte_restrict wqe;\n\t\tenum mlx5_txcmp_code ret;\n\n\t\tMLX5_ASSERT(NB_SEGS(loc->mbuf) == 1);\n\t\tif (MLX5_TXOFF_CONFIG(TXPP)) {\n\t\t\tenum mlx5_txcmp_code wret;\n\n\t\t\t\/* Generate WAIT for scheduling if requested. *\/\n\t\t\twret = mlx5_tx_schedule_send(txq, loc, olx);\n\t\t\tif (wret == MLX5_TXCMP_CODE_EXIT)\n\t\t\t\treturn MLX5_TXCMP_CODE_EXIT;\n\t\t\tif (wret == MLX5_TXCMP_CODE_ERROR)\n\t\t\t\treturn MLX5_TXCMP_CODE_ERROR;\n\t\t}\n\t\tif (MLX5_TXOFF_CONFIG(INLINE)) {\n\t\t\tunsigned int inlen, vlan = 0;\n\n\t\t\tinlen = rte_pktmbuf_data_len(loc->mbuf);\n\t\t\tif (MLX5_TXOFF_CONFIG(VLAN) &&\n\t\t\t    loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) {\n\t\t\t\tvlan = sizeof(struct rte_vlan_hdr);\n\t\t\t\tinlen += vlan;\n\t\t\t\tstatic_assert((sizeof(struct rte_vlan_hdr) +\n\t\t\t\t\t       sizeof(struct rte_ether_hdr)) ==\n\t\t\t\t\t       MLX5_ESEG_MIN_INLINE_SIZE,\n\t\t\t\t\t       \"invalid min inline data size\");\n\t\t\t}\n\t\t\t\/*\n\t\t\t * If inlining is enabled at configuration time\n\t\t\t * the limit must be not less than minimal size.\n\t\t\t * Otherwise we would do extra check for data\n\t\t\t * size to avoid crashes due to length overflow.\n\t\t\t *\/\n\t\t\tMLX5_ASSERT(txq->inlen_send >=\n\t\t\t\t    MLX5_ESEG_MIN_INLINE_SIZE);\n\t\t\tif (inlen <= txq->inlen_send) {\n\t\t\t\tunsigned int seg_n, wqe_n;\n\n\t\t\t\trte_prefetch0(rte_pktmbuf_mtod\n\t\t\t\t\t\t(loc->mbuf, uint8_t *));\n\t\t\t\t\/* Check against minimal length. *\/\n\t\t\t\tif (inlen <= MLX5_ESEG_MIN_INLINE_SIZE)\n\t\t\t\t\treturn MLX5_TXCMP_CODE_ERROR;\n\t\t\t\tif (loc->mbuf->ol_flags &\n\t\t\t\t    PKT_TX_DYNF_NOINLINE) {\n\t\t\t\t\t\/*\n\t\t\t\t\t * The hint flag not to inline packet\n\t\t\t\t\t * data is set. Check whether we can\n\t\t\t\t\t * follow the hint.\n\t\t\t\t\t *\/\n\t\t\t\t\tif ((!MLX5_TXOFF_CONFIG(EMPW) &&\n\t\t\t\t\t      txq->inlen_mode) ||\n\t\t\t\t\t    (MLX5_TXOFF_CONFIG(MPW) &&\n\t\t\t\t\t     txq->inlen_mode)) {\n\t\t\t\t\t\tif (inlen <= txq->inlen_send)\n\t\t\t\t\t\t\tgoto single_inline;\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * The hardware requires the\n\t\t\t\t\t\t * minimal inline data header.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tgoto single_min_inline;\n\t\t\t\t\t}\n\t\t\t\t\tif (MLX5_TXOFF_CONFIG(VLAN) &&\n\t\t\t\t\t    vlan && !txq->vlan_en) {\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * We must insert VLAN tag\n\t\t\t\t\t\t * by software means.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tgoto single_part_inline;\n\t\t\t\t\t}\n\t\t\t\t\tgoto single_no_inline;\n\t\t\t\t}\nsingle_inline:\n\t\t\t\t\/*\n\t\t\t\t * Completely inlined packet data WQE:\n\t\t\t\t * - Control Segment, SEND opcode\n\t\t\t\t * - Ethernet Segment, no VLAN insertion\n\t\t\t\t * - Data inlined, VLAN optionally inserted\n\t\t\t\t * - Alignment to MLX5_WSEG_SIZE\n\t\t\t\t * Have to estimate amount of WQEBBs\n\t\t\t\t *\/\n\t\t\t\tseg_n = (inlen + 3 * MLX5_WSEG_SIZE -\n\t\t\t\t\t MLX5_ESEG_MIN_INLINE_SIZE +\n\t\t\t\t\t MLX5_WSEG_SIZE - 1) \/ MLX5_WSEG_SIZE;\n\t\t\t\t\/* Check if there are enough WQEBBs. *\/\n\t\t\t\twqe_n = (seg_n + 3) \/ 4;\n\t\t\t\tif (wqe_n > loc->wqe_free)\n\t\t\t\t\treturn MLX5_TXCMP_CODE_EXIT;\n\t\t\t\twqe = txq->wqes + (txq->wqe_ci & txq->wqe_m);\n\t\t\t\tloc->wqe_last = wqe;\n\t\t\t\tmlx5_tx_cseg_init(txq, loc, wqe, seg_n,\n\t\t\t\t\t\t  MLX5_OPCODE_SEND, olx);\n\t\t\t\tmlx5_tx_eseg_data(txq, loc, wqe,\n\t\t\t\t\t\t  vlan, inlen, 0, olx);\n\t\t\t\ttxq->wqe_ci += wqe_n;\n\t\t\t\tloc->wqe_free -= wqe_n;\n\t\t\t\t\/*\n\t\t\t\t * Packet data are completely inlined,\n\t\t\t\t * free the packet immediately.\n\t\t\t\t *\/\n\t\t\t\trte_pktmbuf_free_seg(loc->mbuf);\n\t\t\t} else if ((!MLX5_TXOFF_CONFIG(EMPW) ||\n\t\t\t\t     MLX5_TXOFF_CONFIG(MPW)) &&\n\t\t\t\t\ttxq->inlen_mode) {\n\t\t\t\t\/*\n\t\t\t\t * If minimal inlining is requested the eMPW\n\t\t\t\t * feature should be disabled due to data is\n\t\t\t\t * inlined into Ethernet Segment, which can\n\t\t\t\t * not contain inlined data for eMPW due to\n\t\t\t\t * segment shared for all packets.\n\t\t\t\t *\/\n\t\t\t\tstruct mlx5_wqe_dseg *__rte_restrict dseg;\n\t\t\t\tunsigned int ds;\n\t\t\t\tuint8_t *dptr;\n\n\t\t\t\t\/*\n\t\t\t\t * The inline-mode settings require\n\t\t\t\t * to inline the specified amount of\n\t\t\t\t * data bytes to the Ethernet Segment.\n\t\t\t\t * We should check the free space in\n\t\t\t\t * WQE ring buffer to inline partially.\n\t\t\t\t *\/\nsingle_min_inline:\n\t\t\t\tMLX5_ASSERT(txq->inlen_send >= txq->inlen_mode);\n\t\t\t\tMLX5_ASSERT(inlen > txq->inlen_mode);\n\t\t\t\tMLX5_ASSERT(txq->inlen_mode >=\n\t\t\t\t\t    MLX5_ESEG_MIN_INLINE_SIZE);\n\t\t\t\t\/*\n\t\t\t\t * Check whether there are enough free WQEBBs:\n\t\t\t\t * - Control Segment\n\t\t\t\t * - Ethernet Segment\n\t\t\t\t * - First Segment of inlined Ethernet data\n\t\t\t\t * - ... data continued ...\n\t\t\t\t * - Finishing Data Segment of pointer type\n\t\t\t\t *\/\n\t\t\t\tds = (MLX5_WQE_CSEG_SIZE +\n\t\t\t\t      MLX5_WQE_ESEG_SIZE +\n\t\t\t\t      MLX5_WQE_DSEG_SIZE +\n\t\t\t\t      txq->inlen_mode -\n\t\t\t\t      MLX5_ESEG_MIN_INLINE_SIZE +\n\t\t\t\t      MLX5_WQE_DSEG_SIZE +\n\t\t\t\t      MLX5_WSEG_SIZE - 1) \/ MLX5_WSEG_SIZE;\n\t\t\t\tif (loc->wqe_free < ((ds + 3) \/ 4))\n\t\t\t\t\treturn MLX5_TXCMP_CODE_EXIT;\n\t\t\t\t\/*\n\t\t\t\t * Build the ordinary SEND WQE:\n\t\t\t\t * - Control Segment\n\t\t\t\t * - Ethernet Segment, inline inlen_mode bytes\n\t\t\t\t * - Data Segment of pointer type\n\t\t\t\t *\/\n\t\t\t\twqe = txq->wqes + (txq->wqe_ci & txq->wqe_m);\n\t\t\t\tloc->wqe_last = wqe;\n\t\t\t\tmlx5_tx_cseg_init(txq, loc, wqe, ds,\n\t\t\t\t\t\t  MLX5_OPCODE_SEND, olx);\n\t\t\t\tdseg = mlx5_tx_eseg_data(txq, loc, wqe, vlan,\n\t\t\t\t\t\t\t txq->inlen_mode,\n\t\t\t\t\t\t\t 0, olx);\n\t\t\t\tdptr = rte_pktmbuf_mtod(loc->mbuf, uint8_t *) +\n\t\t\t\t       txq->inlen_mode - vlan;\n\t\t\t\tinlen -= txq->inlen_mode;\n\t\t\t\tmlx5_tx_dseg_ptr(txq, loc, dseg,\n\t\t\t\t\t\t dptr, inlen, olx);\n\t\t\t\t\/*\n\t\t\t\t * WQE is built, update the loop parameters\n\t\t\t\t * and got to the next packet.\n\t\t\t\t *\/\n\t\t\t\ttxq->wqe_ci += (ds + 3) \/ 4;\n\t\t\t\tloc->wqe_free -= (ds + 3) \/ 4;\n\t\t\t\t\/* We have to store mbuf in elts.*\/\n\t\t\t\tMLX5_ASSERT(MLX5_TXOFF_CONFIG(INLINE));\n\t\t\t\ttxq->elts[txq->elts_head++ & txq->elts_m] =\n\t\t\t\t\t\tloc->mbuf;\n\t\t\t\t--loc->elts_free;\n\t\t\t} else {\n\t\t\t\tuint8_t *dptr;\n\t\t\t\tunsigned int dlen;\n\n\t\t\t\t\/*\n\t\t\t\t * Partially inlined packet data WQE, we have\n\t\t\t\t * some space in title WQEBB, we can fill it\n\t\t\t\t * with some packet data. It takes one WQEBB,\n\t\t\t\t * it is available, no extra space check:\n\t\t\t\t * - Control Segment, SEND opcode\n\t\t\t\t * - Ethernet Segment, no VLAN insertion\n\t\t\t\t * - MLX5_ESEG_MIN_INLINE_SIZE bytes of Data\n\t\t\t\t * - Data Segment, pointer type\n\t\t\t\t *\n\t\t\t\t * We also get here if VLAN insertion is not\n\t\t\t\t * supported by HW, the inline is enabled.\n\t\t\t\t *\/\nsingle_part_inline:\n\t\t\t\twqe = txq->wqes + (txq->wqe_ci & txq->wqe_m);\n\t\t\t\tloc->wqe_last = wqe;\n\t\t\t\tmlx5_tx_cseg_init(txq, loc, wqe, 4,\n\t\t\t\t\t\t  MLX5_OPCODE_SEND, olx);\n\t\t\t\tmlx5_tx_eseg_dmin(txq, loc, wqe, vlan, olx);\n\t\t\t\tdptr = rte_pktmbuf_mtod(loc->mbuf, uint8_t *) +\n\t\t\t\t       MLX5_ESEG_MIN_INLINE_SIZE - vlan;\n\t\t\t\t\/*\n\t\t\t\t * The length check is performed above, by\n\t\t\t\t * comparing with txq->inlen_send. We should\n\t\t\t\t * not get overflow here.\n\t\t\t\t *\/\n\t\t\t\tMLX5_ASSERT(inlen > MLX5_ESEG_MIN_INLINE_SIZE);\n\t\t\t\tdlen = inlen - MLX5_ESEG_MIN_INLINE_SIZE;\n\t\t\t\tmlx5_tx_dseg_ptr(txq, loc, &wqe->dseg[1],\n\t\t\t\t\t\t dptr, dlen, olx);\n\t\t\t\t++txq->wqe_ci;\n\t\t\t\t--loc->wqe_free;\n\t\t\t\t\/* We have to store mbuf in elts.*\/\n\t\t\t\tMLX5_ASSERT(MLX5_TXOFF_CONFIG(INLINE));\n\t\t\t\ttxq->elts[txq->elts_head++ & txq->elts_m] =\n\t\t\t\t\t\tloc->mbuf;\n\t\t\t\t--loc->elts_free;\n\t\t\t}\n#ifdef MLX5_PMD_SOFT_COUNTERS\n\t\t\t\/* Update sent data bytes counter. *\/\n\t\t\ttxq->stats.obytes += vlan +\n\t\t\t\t\trte_pktmbuf_data_len(loc->mbuf);\n#endif\n\t\t} else {\n\t\t\t\/*\n\t\t\t * No inline at all, it means the CPU cycles saving\n\t\t\t * is prioritized at configuration, we should not\n\t\t\t * copy any packet data to WQE.\n\t\t\t *\n\t\t\t * SEND WQE, one WQEBB:\n\t\t\t * - Control Segment, SEND opcode\n\t\t\t * - Ethernet Segment, optional VLAN, no inline\n\t\t\t * - Data Segment, pointer type\n\t\t\t *\/\nsingle_no_inline:\n\t\t\twqe = txq->wqes + (txq->wqe_ci & txq->wqe_m);\n\t\t\tloc->wqe_last = wqe;\n\t\t\tmlx5_tx_cseg_init(txq, loc, wqe, 3,\n\t\t\t\t\t  MLX5_OPCODE_SEND, olx);\n\t\t\tmlx5_tx_eseg_none(txq, loc, wqe, olx);\n\t\t\tmlx5_tx_dseg_ptr\n\t\t\t\t(txq, loc, &wqe->dseg[0],\n\t\t\t\t rte_pktmbuf_mtod(loc->mbuf, uint8_t *),\n\t\t\t\t rte_pktmbuf_data_len(loc->mbuf), olx);\n\t\t\t++txq->wqe_ci;\n\t\t\t--loc->wqe_free;\n\t\t\t\/*\n\t\t\t * We should not store mbuf pointer in elts\n\t\t\t * if no inlining is configured, this is done\n\t\t\t * by calling routine in a batch copy.\n\t\t\t *\/\n\t\t\tMLX5_ASSERT(!MLX5_TXOFF_CONFIG(INLINE));\n\t\t\t--loc->elts_free;\n#ifdef MLX5_PMD_SOFT_COUNTERS\n\t\t\t\/* Update sent data bytes counter. *\/\n\t\t\ttxq->stats.obytes += rte_pktmbuf_data_len(loc->mbuf);\n\t\t\tif (MLX5_TXOFF_CONFIG(VLAN) &&\n\t\t\t    loc->mbuf->ol_flags & PKT_TX_VLAN_PKT)\n\t\t\t\ttxq->stats.obytes +=\n\t\t\t\t\tsizeof(struct rte_vlan_hdr);\n#endif\n\t\t}\n\t\t++loc->pkts_sent;\n\t\t--pkts_n;\n\t\tif (unlikely(!pkts_n || !loc->elts_free || !loc->wqe_free))\n\t\t\treturn MLX5_TXCMP_CODE_EXIT;\n\t\tloc->mbuf = *pkts++;\n\t\tif (pkts_n > 1)\n\t\t\trte_prefetch0(*pkts);\n\t\tret = mlx5_tx_able_to_empw(txq, loc, olx, true);\n\t\tif (unlikely(ret != MLX5_TXCMP_CODE_SINGLE))\n\t\t\treturn ret;\n\t}\n\tMLX5_ASSERT(false);\n}","target":0,"code_token_length":2884,"total_token_length":3120,"max_tokens_setting":4096}
+{"idx":300376,"func":"TEST_F(SecretManagerImplTest, ConfigDumpHandler) {\n  Server::MockInstance server;\n  auto secret_manager = std::make_unique(config_tracker_);\n  time_system_.setSystemTime(std::chrono::milliseconds(1234567891234));\n\n  NiceMock secret_context;\n\n  envoy::config::core::v3::ConfigSource config_source;\n  NiceMock local_info;\n  NiceMock dispatcher;\n  NiceMock random;\n  Stats::IsolatedStoreImpl stats;\n  NiceMock init_manager;\n  NiceMock init_watcher;\n  Init::TargetHandlePtr init_target_handle;\n  EXPECT_CALL(init_manager, add(_))\n      .WillRepeatedly(Invoke([&init_target_handle](const Init::Target& target) {\n        init_target_handle = target.createHandle(\"test\");\n      }));\n  EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats));\n  EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager));\n  EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher));\n  EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info));\n\n  auto secret_provider =\n      secret_manager->findOrCreateTlsCertificateProvider(config_source, \"abc.com\", secret_context);\n  const std::string yaml =\n      R\"EOF(\nname: \"abc.com\"\ntls_certificate:\n  certificate_chain:\n    inline_string: \"DUMMY_INLINE_BYTES_FOR_CERT_CHAIN\"\n  private_key:\n    inline_string: \"DUMMY_INLINE_BYTES_FOR_PRIVATE_KEY\"\n  password:\n    inline_string: \"DUMMY_PASSWORD\"\n)EOF\";\n  envoy::extensions::transport_sockets::tls::v3::Secret typed_secret;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), typed_secret);\n  const auto decoded_resources = TestUtility::decodeResources({typed_secret});\n  init_target_handle->initialize(init_watcher);\n  secret_context.cluster_manager_.subscription_factory_.callbacks_->onConfigUpdate(\n      decoded_resources.refvec_, \"keycert-v1\");\n  testing::NiceMock ctx;\n  Ssl::TlsCertificateConfigImpl tls_config(*secret_provider->secret(), ctx, *api_);\n  EXPECT_EQ(\"DUMMY_INLINE_BYTES_FOR_CERT_CHAIN\", tls_config.certificateChain());\n  EXPECT_EQ(\"DUMMY_INLINE_BYTES_FOR_PRIVATE_KEY\", tls_config.privateKey());\n  EXPECT_EQ(\"DUMMY_PASSWORD\", tls_config.password());\n\n  \/\/ Private key and password are removed.\n  const std::string expected_secrets_config_dump = R\"EOF(\ndynamic_active_secrets:\n- name: \"abc.com\"\n  version_info: \"keycert-v1\"\n  last_updated:\n    seconds: 1234567891\n    nanos: 234000000\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com\"\n    tls_certificate:\n      certificate_chain:\n        inline_string: \"DUMMY_INLINE_BYTES_FOR_CERT_CHAIN\"\n      private_key:\n        inline_string: \"[redacted]\"\n      password:\n        inline_string: \"[redacted]\"\n)EOF\";\n  checkConfigDump(expected_secrets_config_dump);\n  StrictMock mock_matcher;\n  EXPECT_CALL(mock_matcher, match(\"abc.com\")).WillOnce(Return(false));\n  checkConfigDump(\"{}\", mock_matcher);\n\n  \/\/ Add a dynamic tls validation context provider.\n  time_system_.setSystemTime(std::chrono::milliseconds(1234567899000));\n  auto context_secret_provider = secret_manager->findOrCreateCertificateValidationContextProvider(\n      config_source, \"abc.com.validation\", secret_context);\n  const std::string validation_yaml = R\"EOF(\nname: \"abc.com.validation\"\nvalidation_context:\n  trusted_ca:\n    inline_string: \"DUMMY_INLINE_STRING_TRUSTED_CA\"\n)EOF\";\n  TestUtility::loadFromYaml(TestEnvironment::substitute(validation_yaml), typed_secret);\n  const auto decoded_resources_2 = TestUtility::decodeResources({typed_secret});\n\n  init_target_handle->initialize(init_watcher);\n  secret_context.cluster_manager_.subscription_factory_.callbacks_->onConfigUpdate(\n      decoded_resources_2.refvec_, \"validation-context-v1\");\n  Ssl::CertificateValidationContextConfigImpl cert_validation_context(\n      *context_secret_provider->secret(), *api_);\n  EXPECT_EQ(\"DUMMY_INLINE_STRING_TRUSTED_CA\", cert_validation_context.caCert());\n  const std::string updated_config_dump = R\"EOF(\ndynamic_active_secrets:\n- name: \"abc.com\"\n  version_info: \"keycert-v1\"\n  last_updated:\n    seconds: 1234567891\n    nanos: 234000000\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com\"\n    tls_certificate:\n      certificate_chain:\n        inline_string: \"DUMMY_INLINE_BYTES_FOR_CERT_CHAIN\"\n      private_key:\n        inline_string: \"[redacted]\"\n      password:\n        inline_string: \"[redacted]\"\n- name: \"abc.com.validation\"\n  version_info: \"validation-context-v1\"\n  last_updated:\n    seconds: 1234567899\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com.validation\"\n    validation_context:\n      trusted_ca:\n        inline_string: \"DUMMY_INLINE_STRING_TRUSTED_CA\"\n)EOF\";\n  checkConfigDump(updated_config_dump);\n  EXPECT_CALL(mock_matcher, match(\"abc.com\")).WillOnce(Return(false));\n  EXPECT_CALL(mock_matcher, match(\"abc.com.validation\")).WillOnce(Return(false));\n  checkConfigDump(\"{}\", mock_matcher);\n\n  \/\/ Add a dynamic tls session ticket encryption keys context provider.\n  time_system_.setSystemTime(std::chrono::milliseconds(1234567899000));\n  auto stek_secret_provider = secret_manager->findOrCreateTlsSessionTicketKeysContextProvider(\n      config_source, \"abc.com.stek\", secret_context);\n  const std::string stek_yaml = R\"EOF(\nname: \"abc.com.stek\"\nsession_ticket_keys:\n  keys:\n    - filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n    - inline_string: \"DUMMY_INLINE_STRING\"\n    - inline_bytes: \"RFVNTVlfSU5MSU5FX0JZVEVT\"\n)EOF\";\n  TestUtility::loadFromYaml(TestEnvironment::substitute(stek_yaml), typed_secret);\n  const auto decoded_resources_3 = TestUtility::decodeResources({typed_secret});\n\n  init_target_handle->initialize(init_watcher);\n  secret_context.cluster_manager_.subscription_factory_.callbacks_->onConfigUpdate(\n      decoded_resources_3.refvec_, \"stek-context-v1\");\n  EXPECT_EQ(stek_secret_provider->secret()->keys()[1].inline_string(), \"DUMMY_INLINE_STRING\");\n\n  const std::string updated_once_more_config_dump = R\"EOF(\ndynamic_active_secrets:\n- name: \"abc.com\"\n  version_info: \"keycert-v1\"\n  last_updated:\n    seconds: 1234567891\n    nanos: 234000000\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com\"\n    tls_certificate:\n      certificate_chain:\n        inline_string: \"DUMMY_INLINE_BYTES_FOR_CERT_CHAIN\"\n      private_key:\n        inline_string: \"[redacted]\"\n      password:\n        inline_string: \"[redacted]\"\n- name: \"abc.com.validation\"\n  version_info: \"validation-context-v1\"\n  last_updated:\n    seconds: 1234567899\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com.validation\"\n    validation_context:\n      trusted_ca:\n        inline_string: \"DUMMY_INLINE_STRING_TRUSTED_CA\"\n- name: \"abc.com.stek\"\n  version_info: \"stek-context-v1\"\n  last_updated:\n    seconds: 1234567899\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com.stek\"\n    session_ticket_keys:\n      keys:\n        - filename: \"[redacted]\"\n        - inline_string: \"[redacted]\"\n        - inline_bytes: \"W3JlZGFjdGVkXQ==\"\n)EOF\";\n  checkConfigDump(TestEnvironment::substitute(updated_once_more_config_dump));\n  EXPECT_CALL(mock_matcher, match(\"abc.com\")).WillOnce(Return(false));\n  EXPECT_CALL(mock_matcher, match(\"abc.com.validation\")).WillOnce(Return(false));\n  EXPECT_CALL(mock_matcher, match(\"abc.com.stek\")).WillOnce(Return(false));\n  checkConfigDump(\"{}\", mock_matcher);\n\n  \/\/ Add a dynamic generic secret provider.\n  time_system_.setSystemTime(std::chrono::milliseconds(1234567900000));\n  auto generic_secret_provider = secret_manager->findOrCreateGenericSecretProvider(\n      config_source, \"signing_key\", secret_context);\n\n  const std::string generic_secret_yaml = R\"EOF(\nname: \"signing_key\"\ngeneric_secret:\n  secret:\n    inline_string: \"DUMMY_ECDSA_KEY\"\n)EOF\";\n  TestUtility::loadFromYaml(TestEnvironment::substitute(generic_secret_yaml), typed_secret);\n  const auto decoded_resources_4 = TestUtility::decodeResources({typed_secret});\n  init_target_handle->initialize(init_watcher);\n  secret_context.cluster_manager_.subscription_factory_.callbacks_->onConfigUpdate(\n      decoded_resources_4.refvec_, \"signing-key-v1\");\n\n  const envoy::extensions::transport_sockets::tls::v3::GenericSecret generic_secret(\n      *generic_secret_provider->secret());\n  EXPECT_EQ(\"DUMMY_ECDSA_KEY\", generic_secret.secret().inline_string());\n\n  const std::string config_dump_with_generic_secret = R\"EOF(\ndynamic_active_secrets:\n- name: \"abc.com\"\n  version_info: \"keycert-v1\"\n  last_updated:\n    seconds: 1234567891\n    nanos: 234000000\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com\"\n    tls_certificate:\n      certificate_chain:\n        inline_string: \"DUMMY_INLINE_BYTES_FOR_CERT_CHAIN\"\n      private_key:\n        inline_string: \"[redacted]\"\n      password:\n        inline_string: \"[redacted]\"\n- name: \"abc.com.validation\"\n  version_info: \"validation-context-v1\"\n  last_updated:\n    seconds: 1234567899\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com.validation\"\n    validation_context:\n      trusted_ca:\n        inline_string: \"DUMMY_INLINE_STRING_TRUSTED_CA\"\n- name: \"abc.com.stek\"\n  version_info: \"stek-context-v1\"\n  last_updated:\n    seconds: 1234567899\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com.stek\"\n    session_ticket_keys:\n      keys:\n        - filename: \"[redacted]\"\n        - inline_string: \"[redacted]\"\n        - inline_bytes: \"W3JlZGFjdGVkXQ==\"\n- name: \"signing_key\"\n  version_info: \"signing-key-v1\"\n  last_updated:\n    seconds: 1234567900\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"signing_key\"\n    generic_secret:\n      secret:\n        inline_string: \"[redacted]\"\n)EOF\";\n  checkConfigDump(TestEnvironment::substitute(config_dump_with_generic_secret));\n  EXPECT_CALL(mock_matcher, match(\"abc.com\")).WillOnce(Return(false));\n  EXPECT_CALL(mock_matcher, match(\"abc.com.validation\")).WillOnce(Return(false));\n  EXPECT_CALL(mock_matcher, match(\"abc.com.stek\")).WillOnce(Return(false));\n  EXPECT_CALL(mock_matcher, match(\"signing_key\")).WillOnce(Return(false));\n  checkConfigDump(\"{}\", mock_matcher);\n}","target":0,"code_token_length":2725,"total_token_length":2961,"max_tokens_setting":4096}
+{"idx":10458,"func":"qtdemux_parse_samples (GstQTDemux * qtdemux, QtDemuxStream * stream,\n    GNode * stbl)\n{\n  int offset;\n  GNode *stsc;\n  GNode *stsz;\n  GNode *stco;\n  GNode *co64;\n  GNode *stts;\n  GNode *stss;\n  GNode *ctts;\n  const guint8 *stsc_data, *stsz_data, *stco_data;\n  int sample_size;\n  int sample_index;\n  int n_samples;\n  int n_samples_per_chunk;\n  int n_sample_times;\n  QtDemuxSample *samples;\n  gint i, j, k;\n  int index;\n  guint64 timestamp, time;\n\n  \/* sample to chunk *\/\n  if (!(stsc = qtdemux_tree_get_child_by_type (stbl, FOURCC_stsc)))\n    goto corrupt_file;\n  stsc_data = (const guint8 *) stsc->data;\n  \/* sample size *\/\n  if (!(stsz = qtdemux_tree_get_child_by_type (stbl, FOURCC_stsz)))\n    goto corrupt_file;\n  stsz_data = (const guint8 *) stsz->data;\n  \/* chunk offsets *\/\n  stco = qtdemux_tree_get_child_by_type (stbl, FOURCC_stco);\n  co64 = qtdemux_tree_get_child_by_type (stbl, FOURCC_co64);\n  if (stco) {\n    stco_data = (const guint8 *) stco->data;\n  } else {\n    stco_data = NULL;\n    if (co64 == NULL)\n      goto corrupt_file;\n  }\n  \/* sample time *\/\n  if (!(stts = qtdemux_tree_get_child_by_type (stbl, FOURCC_stts)))\n    goto corrupt_file;\n\n  \/* sample sync, can be NULL *\/\n  stss = qtdemux_tree_get_child_by_type (stbl, FOURCC_stss);\n\n  sample_size = QT_UINT32 (stsz_data + 12);\n  if (sample_size == 0 || stream->sampled) {\n    n_samples = QT_UINT32 (stsz_data + 16);\n    GST_DEBUG_OBJECT (qtdemux, \"stsz sample_size 0, allocating n_samples %d\",\n        n_samples);\n    stream->n_samples = n_samples;\n    samples = g_new0 (QtDemuxSample, n_samples);\n    stream->samples = samples;\n\n    for (i = 0; i < n_samples; i++) {\n      if (sample_size == 0)\n        samples[i].size = QT_UINT32 (stsz_data + i * 4 + 20);\n      else\n        samples[i].size = sample_size;\n\n      GST_LOG_OBJECT (qtdemux, \"sample %d has size %d\", i, samples[i].size);\n      \/* init other fields to defaults for this sample *\/\n      samples[i].keyframe = FALSE;\n    }\n    n_samples_per_chunk = QT_UINT32 (stsc_data + 12);\n    index = 0;\n    for (i = 0; i < n_samples_per_chunk; i++) {\n      guint32 first_chunk, last_chunk;\n      guint32 samples_per_chunk;\n\n      first_chunk = QT_UINT32 (stsc_data + 16 + i * 12 + 0) - 1;\n      if (i == n_samples_per_chunk - 1) {\n        last_chunk = G_MAXUINT32;\n      } else {\n        last_chunk = QT_UINT32 (stsc_data + 16 + i * 12 + 12) - 1;\n      }\n      samples_per_chunk = QT_UINT32 (stsc_data + 16 + i * 12 + 4);\n\n      for (j = first_chunk; j < last_chunk; j++) {\n        guint64 chunk_offset;\n\n        if (stco) {\n          chunk_offset = QT_UINT32 (stco_data + 16 + j * 4);\n        } else {\n          chunk_offset = QT_UINT64 ((guint8 *) co64->data + 16 + j * 8);\n        }\n        for (k = 0; k < samples_per_chunk; k++) {\n          GST_LOG_OBJECT (qtdemux, \"Creating entry %d with offset %lld\",\n              index, chunk_offset);\n          samples[index].chunk = j;\n          samples[index].offset = chunk_offset;\n          chunk_offset += samples[index].size;\n          index++;\n          if (index >= n_samples)\n            goto done2;\n        }\n      }\n    }\n  done2:\n\n    n_sample_times = QT_UINT32 ((guint8 *) stts->data + 12);\n    timestamp = 0;\n     stream->min_duration = 0;\n     time = 0;\n     index = 0;\n    for (i = 0; i < n_sample_times; i++) {\n       guint32 n;\n       guint32 duration;\n \n       n = QT_UINT32 ((guint8 *) stts->data + 16 + 8 * i);\n       duration = QT_UINT32 ((guint8 *) stts->data + 16 + 8 * i + 4);\n      for (j = 0; j < n; j++) {\n         GST_DEBUG_OBJECT (qtdemux, \"sample %d: timestamp %\" GST_TIME_FORMAT,\n             index, GST_TIME_ARGS (timestamp));\n \n        samples[index].timestamp = timestamp;\n        \/* take first duration for fps *\/\n        if (stream->min_duration == 0)\n          stream->min_duration = duration;\n        \/* add non-scaled values to avoid rounding errors *\/\n        time += duration;\n        timestamp = gst_util_uint64_scale (time, GST_SECOND, stream->timescale);\n        samples[index].duration = timestamp - samples[index].timestamp;\n\n        index++;\n      }\n    }\n    if (stss) {\n      \/* mark keyframes *\/\n      guint32 n_sample_syncs;\n\n      n_sample_syncs = QT_UINT32 ((guint8 *) stss->data + 12);\n      if (n_sample_syncs == 0) {\n        stream->all_keyframe = TRUE;\n      } else {\n        offset = 16;\n         for (i = 0; i < n_sample_syncs; i++) {\n           \/* note that the first sample is index 1, not 0 *\/\n           index = QT_UINT32 ((guint8 *) stss->data + offset);\n          if (index > 0) {\n             samples[index - 1].keyframe = TRUE;\n             offset += 4;\n           }\n        }\n      }\n    } else {\n      \/* no stss, all samples are keyframes *\/\n      stream->all_keyframe = TRUE;\n    }\n  } else {\n    GST_DEBUG_OBJECT (qtdemux,\n        \"stsz sample_size %d != 0, treating chunks as samples\", sample_size);\n\n    \/* treat chunks as samples *\/\n    if (stco) {\n      n_samples = QT_UINT32 (stco_data + 12);\n    } else {\n      n_samples = QT_UINT32 ((guint8 *) co64->data + 12);\n    }\n    stream->n_samples = n_samples;\n    GST_DEBUG_OBJECT (qtdemux, \"allocating n_samples %d\", n_samples);\n    samples = g_new0 (QtDemuxSample, n_samples);\n    stream->samples = samples;\n\n    n_samples_per_chunk = QT_UINT32 (stsc_data + 12);\n    GST_DEBUG_OBJECT (qtdemux, \"n_samples_per_chunk %d\", n_samples_per_chunk);\n    sample_index = 0;\n    timestamp = 0;\n    for (i = 0; i < n_samples_per_chunk; i++) {\n      guint32 first_chunk, last_chunk;\n      guint32 samples_per_chunk;\n\n      first_chunk = QT_UINT32 (stsc_data + 16 + i * 12 + 0) - 1;\n      \/* the last chunk of each entry is calculated by taking the first chunk\n       * of the next entry; except if there is no next, where we fake it with\n       * INT_MAX *\/\n      if (i == n_samples_per_chunk - 1) {\n        last_chunk = G_MAXUINT32;\n      } else {\n        last_chunk = QT_UINT32 (stsc_data + 16 + i * 12 + 12) - 1;\n      }\n      samples_per_chunk = QT_UINT32 (stsc_data + 16 + i * 12 + 4);\n\n      GST_LOG_OBJECT (qtdemux,\n          \"entry %d has first_chunk %d, last_chunk %d, samples_per_chunk %d\", i,\n          first_chunk, last_chunk, samples_per_chunk);\n\n      for (j = first_chunk; j < last_chunk; j++) {\n        guint64 chunk_offset;\n\n        if (j >= n_samples)\n          goto done;\n\n        if (stco) {\n          chunk_offset = QT_UINT32 (stco_data + 16 + j * 4);\n        } else {\n          chunk_offset = QT_UINT64 ((guint8 *) co64->data + 16 + j * 8);\n        }\n        GST_LOG_OBJECT (qtdemux,\n            \"Creating entry %d with offset %\" G_GUINT64_FORMAT, j,\n            chunk_offset);\n\n        samples[j].chunk = j;\n        samples[j].offset = chunk_offset;\n\n        if (stream->samples_per_frame * stream->bytes_per_frame) {\n          samples[j].size = (samples_per_chunk * stream->n_channels) \/\n              stream->samples_per_frame * stream->bytes_per_frame;\n        } else {\n          samples[j].size = samples_per_chunk;\n        }\n\n        GST_DEBUG_OBJECT (qtdemux, \"sample %d: timestamp %\" GST_TIME_FORMAT\n            \", size %u\", j, GST_TIME_ARGS (timestamp), samples[j].size);\n\n        samples[j].timestamp = timestamp;\n        sample_index += samples_per_chunk;\n\n        timestamp = gst_util_uint64_scale (sample_index,\n            GST_SECOND, stream->timescale);\n        samples[j].duration = timestamp - samples[j].timestamp;\n\n        samples[j].keyframe = TRUE;\n      }\n    }\n  }\n\n  \/* composition time to sample *\/\n  if ((ctts = qtdemux_tree_get_child_by_type (stbl, FOURCC_ctts))) {\n    const guint8 *ctts_data = (const guint8 *) ctts->data;\n    guint32 n_entries = QT_UINT32 (ctts_data + 12);\n    guint32 count;\n    gint32 soffset;\n\n    \/* Fill in the pts_offsets *\/\n     for (i = 0, j = 0; (j < stream->n_samples) && (i < n_entries); i++) {\n       count = QT_UINT32 (ctts_data + 16 + i * 8);\n       soffset = QT_UINT32 (ctts_data + 20 + i * 8);\n      for (k = 0; k < count; k++, j++) {\n         \/* we operate with very small soffset values here, it shouldn't overflow *\/\n         samples[j].pts_offset = soffset * GST_SECOND \/ stream->timescale;\n       }\n    }\n  }\ndone:\n  return TRUE;\n\n\/* ERRORS *\/\ncorrupt_file:\n  {\n    GST_ELEMENT_ERROR (qtdemux, STREAM, DECODE,\n        (_(\"This file is corrupt and cannot be played.\")), (NULL));\n    return FALSE;\n  }\n}\n","target":1,"code_token_length":2502,"total_token_length":2738,"max_tokens_setting":4096}
+{"idx":269136,"func":"MagickExport MagickBooleanType SetImageProperty(Image *image,\n  const char *property,const char *value,ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  MagickStatusType\n    flags;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  if (image->properties == (void *) NULL)\n    image->properties=NewSplayTree(CompareSplayTreeString,\n      RelinquishMagickMemory,RelinquishMagickMemory);  \/* create splay-tree *\/\n  if (value == (const char *) NULL)\n    return(DeleteImageProperty(image,property));  \/* delete if NULL *\/\n  status=MagickTrue;\n  if (strlen(property) <= 1)\n    {\n      \/*\n        Do not 'set' single letter properties - read only shorthand.\n       *\/\n      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n        \"SetReadOnlyProperty\",\"`%s'\",property);\n      return(MagickFalse);\n    }\n\n  \/* FUTURE: binary chars or quotes in key should produce a error *\/\n  \/* Set attributes with known names or special prefixes\n     return result is found, or break to set a free form properity\n  *\/\n  switch (*property)\n  {\n#if 0  \/* Percent escape's sets values with this prefix: for later use\n          Throwing an exception causes this setting to fail *\/\n    case '8':\n    {\n      if (LocaleNCompare(\"8bim:\",property,5) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break;\n    }\n#endif\n    case 'B':\n    case 'b':\n    {\n      if (LocaleCompare(\"background\",property) == 0)\n        {\n          (void) QueryColorCompliance(value,AllCompliance,\n               &image->background_color,exception);\n          \/* check for FUTURE: value exception?? *\/\n          \/* also add user input to splay tree *\/\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'C':\n    case 'c':\n    {\n      if (LocaleCompare(\"channels\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n            \"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      if (LocaleCompare(\"colorspace\",property) == 0)\n        {\n          ssize_t\n            colorspace;\n\n          colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,\n            value);\n          if (colorspace < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));\n        }\n      if (LocaleCompare(\"compose\",property) == 0)\n        {\n          ssize_t\n            compose;\n\n          compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);\n          if (compose < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->compose=(CompositeOperator) compose;\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"compress\",property) == 0)\n        {\n          ssize_t\n            compression;\n\n          compression=ParseCommandOption(MagickCompressOptions,MagickFalse,\n            value);\n          if (compression < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->compression=(CompressionType) compression;\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'D':\n    case 'd':\n    {\n      if (LocaleCompare(\"delay\",property) == 0)\n        {\n          GeometryInfo\n            geometry_info;\n\n          flags=ParseGeometry(value,&geometry_info);\n          if ((flags & GreaterValue) != 0)\n            {\n              if (image->delay > (size_t) floor(geometry_info.rho+0.5))\n                image->delay=(size_t) floor(geometry_info.rho+0.5);\n            }\n          else\n            if ((flags & LessValue) != 0)\n              {\n                if (image->delay < (size_t) floor(geometry_info.rho+0.5))\n                  image->delay=(ssize_t)\n                    floor(geometry_info.sigma+0.5);\n              }\n            else\n              image->delay=(size_t) floor(geometry_info.rho+0.5);\n          if ((flags & SigmaValue) != 0)\n            image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"delay_units\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      if (LocaleCompare(\"density\",property) == 0)\n        {\n          GeometryInfo\n            geometry_info;\n\n          flags=ParseGeometry(value,&geometry_info);\n          image->resolution.x=geometry_info.rho;\n          image->resolution.y=geometry_info.sigma;\n          if ((flags & SigmaValue) == 0)\n            image->resolution.y=image->resolution.x;\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"depth\",property) == 0)\n        {\n          image->depth=StringToUnsignedLong(value);\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"dispose\",property) == 0)\n        {\n          ssize_t\n            dispose;\n\n          dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);\n          if (dispose < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->dispose=(DisposeType) dispose;\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n#if 0  \/* Percent escape's sets values with this prefix: for later use\n          Throwing an exception causes this setting to fail *\/\n    case 'E':\n    case 'e':\n    {\n      if (LocaleNCompare(\"exif:\",property,5) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'F':\n    case 'f':\n    {\n      if (LocaleNCompare(\"fx:\",property,3) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n#endif\n    case 'G':\n    case 'g':\n    {\n      if (LocaleCompare(\"gamma\",property) == 0)\n        {\n          image->gamma=StringToDouble(value,(char **) NULL);\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"gravity\",property) == 0)\n        {\n          ssize_t\n            gravity;\n\n          gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);\n          if (gravity < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->gravity=(GravityType) gravity;\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'H':\n    case 'h':\n    {\n      if (LocaleCompare(\"height\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'I':\n    case 'i':\n    {\n      if (LocaleCompare(\"intensity\",property) == 0)\n        {\n          ssize_t\n            intensity;\n\n          intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,\n            value);\n          if (intensity < 0)\n            return(MagickFalse);\n          image->intensity=(PixelIntensityMethod) intensity;\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"intent\",property) == 0)\n        {\n          ssize_t\n            rendering_intent;\n\n          rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,\n            value);\n          if (rendering_intent < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->rendering_intent=(RenderingIntent) rendering_intent;\n          return(MagickTrue);\n        }\n      if (LocaleCompare(\"interpolate\",property) == 0)\n        {\n          ssize_t\n            interpolate;\n\n          interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,\n            value);\n          if (interpolate < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->interpolate=(PixelInterpolateMethod) interpolate;\n          return(MagickTrue);\n        }\n#if 0  \/* Percent escape's sets values with this prefix: for later use\n          Throwing an exception causes this setting to fail *\/\n      if (LocaleNCompare(\"iptc:\",property,5) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n#endif\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'K':\n    case 'k':\n      if (LocaleCompare(\"kurtosis\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    case 'L':\n    case 'l':\n    {\n      if (LocaleCompare(\"loop\",property) == 0)\n        {\n          image->iterations=StringToUnsignedLong(value);\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'M':\n    case 'm':\n      if ( (LocaleCompare(\"magick\",property) == 0) ||\n           (LocaleCompare(\"max\",property) == 0) ||\n           (LocaleCompare(\"mean\",property) == 0) ||\n           (LocaleCompare(\"min\",property) == 0) ||\n           (LocaleCompare(\"min\",property) == 0) )\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n             \"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    case 'O':\n    case 'o':\n      if (LocaleCompare(\"opaque\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    case 'P':\n    case 'p':\n    {\n      if (LocaleCompare(\"page\",property) == 0)\n        {\n          char\n            *geometry;\n\n          geometry=GetPageGeometry(value);\n          flags=ParseAbsoluteGeometry(geometry,&image->page);\n          geometry=DestroyString(geometry);\n          return(MagickTrue);\n        }\n#if 0  \/* Percent escape's sets values with this prefix: for later use\n          Throwing an exception causes this setting to fail *\/\n      if (LocaleNCompare(\"pixel:\",property,6) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n#endif\n      if (LocaleCompare(\"profile\",property) == 0)\n        {\n          ImageInfo\n            *image_info;\n\n          StringInfo\n            *profile;\n\n          image_info=AcquireImageInfo();\n          (void) CopyMagickString(image_info->filename,value,MagickPathExtent);\n          (void) SetImageInfo(image_info,1,exception);\n          profile=FileToStringInfo(image_info->filename,~0UL,exception);\n          if (profile != (StringInfo *) NULL)\n            status=SetImageProfile(image,image_info->magick,profile,exception);\n          image_info=DestroyImageInfo(image_info);\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'R':\n    case 'r':\n    {\n      if (LocaleCompare(\"rendering-intent\",property) == 0)\n        {\n          ssize_t\n            rendering_intent;\n\n          rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,\n            value);\n          if (rendering_intent < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->rendering_intent=(RenderingIntent) rendering_intent;\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'S':\n    case 's':\n      if ( (LocaleCompare(\"size\",property) == 0) ||\n           (LocaleCompare(\"skewness\",property) == 0) ||\n           (LocaleCompare(\"scenes\",property) == 0) ||\n           (LocaleCompare(\"standard-deviation\",property) == 0) )\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    case 'T':\n    case 't':\n    {\n      if (LocaleCompare(\"tile-offset\",property) == 0)\n        {\n          char\n            *geometry;\n\n          geometry=GetPageGeometry(value);\n          flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);\n          geometry=DestroyString(geometry);\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'U':\n    case 'u':\n    {\n      if (LocaleCompare(\"units\",property) == 0)\n        {\n          ssize_t\n            units;\n\n          units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);\n          if (units < 0)\n            return(MagickFalse); \/* FUTURE: value exception?? *\/\n          image->units=(ResolutionType) units;\n          return(MagickTrue);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'V':\n    case 'v':\n    {\n      if (LocaleCompare(\"version\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n    case 'W':\n    case 'w':\n    {\n      if (LocaleCompare(\"width\",property) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n#if 0  \/* Percent escape's sets values with this prefix: for later use\n          Throwing an exception causes this setting to fail *\/\n    case 'X':\n    case 'x':\n    {\n      if (LocaleNCompare(\"xmp:\",property,4) == 0)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n               OptionError,\"SetReadOnlyProperty\",\"`%s'\",property);\n          return(MagickFalse);\n        }\n      break; \/* not an attribute, add as a property *\/\n    }\n#endif\n  }\n  \/* Default: not an attribute, add as a property *\/\n  status=AddValueToSplayTree((SplayTreeInfo *) image->properties,\n    ConstantString(property),ConstantString(value));\n  \/* FUTURE: error if status is bad? *\/\n  return(status);\n}","target":0,"code_token_length":3583,"total_token_length":3819,"max_tokens_setting":4096}
+{"idx":156854,"func":"void CLASS parse_ciff (int offset, int length, int depth)\n{\n  int tboff, nrecs, c, type, len, save, wbi=-1;\n  ushort key[] = { 0x410, 0x45f3 };\n\n  fseek (ifp, offset+length-4, SEEK_SET);\n  tboff = get4() + offset;\n  fseek (ifp, tboff, SEEK_SET);\n  nrecs = get2();\n  if ((nrecs | depth) > 127) return;\n  while (nrecs--) {\n    type = get2();\n    len  = get4();\n    save = ftell(ifp) + 4;\n    fseek (ifp, offset+get4(), SEEK_SET);\n    if ((((type >> 8) + 8) | 8) == 0x38) {\n      parse_ciff (ftell(ifp), len, depth+1); \/* Parse a sub-table *\/\n    }\n#ifdef LIBRAW_LIBRARY_BUILD\n    if (type == 0x3004) parse_ciff (ftell(ifp), len, depth+1);\n#endif\n    if (type == 0x0810)\n      fread (artist, 64, 1, ifp);\n    if (type == 0x080a) {\n      fread (make, 64, 1, ifp);\n      fseek (ifp, strbuflen(make) - 63, SEEK_CUR);\n      fread (model, 64, 1, ifp);\n    }\n    if (type == 0x1810) {\n      width = get4();\n      height = get4();\n      pixel_aspect = int_to_float(get4());\n      flip = get4();\n    }\n    if (type == 0x1835)\t\t\t\/* Get the decoder table *\/\n      tiff_compress = get4();\n    if (type == 0x2007) {\n      thumb_offset = ftell(ifp);\n      thumb_length = len;\n    }\n    if (type == 0x1818) {\n      shutter = libraw_powf64(2.0f, -int_to_float((get4(),get4())));\n      aperture = libraw_powf64(2.0f, int_to_float(get4())\/2);\n#ifdef LIBRAW_LIBRARY_BUILD\n      imgdata.lens.makernotes.CurAp = aperture;\n#endif\n    }\n    if (type == 0x102a) {\n\/\/      iso_speed = pow (2.0, (get4(),get2())\/32.0 - 4) * 50;\n      iso_speed = libraw_powf64(2.0f, ((get2(),get2()) + get2())\/32.0f - 5.0f) * 100.0f;\n#ifdef LIBRAW_LIBRARY_BUILD\n      aperture  = _CanonConvertAperture((get2(),get2()));\n      imgdata.lens.makernotes.CurAp = aperture;\n#else\n      aperture  = libraw_powf64(2.0, (get2(),(short)get2())\/64.0);\n#endif\n      shutter   = libraw_powf64(2.0,-((short)get2())\/32.0);\n      wbi = (get2(),get2());\n      if (wbi > 17) wbi = 0;\n      fseek (ifp, 32, SEEK_CUR);\n      if (shutter > 1e6) shutter = get2()\/10.0;\n    }\n    if (type == 0x102c) {\n      if (get2() > 512) {\t\t\/* Pro90, G1 *\/\n\tfseek (ifp, 118, SEEK_CUR);\n\tFORC4 cam_mul[c ^ 2] = get2();\n      } else {\t\t\t\t\/* G2, S30, S40 *\/\n\tfseek (ifp, 98, SEEK_CUR);\n\tFORC4 cam_mul[c ^ (c >> 1) ^ 1] = get2();\n      }\n    }\n#ifdef LIBRAW_LIBRARY_BUILD\n    if (type == 0x10a9)\n      {\n\tINT64 o = ftell(ifp);\n\tfseek (ifp, (0x5<<1), SEEK_CUR);\n\tCanon_WBpresets(0,0);\n\tfseek(ifp,o,SEEK_SET);\n      }\n    if (type == 0x102d)\n      {\n\tINT64 o = ftell(ifp);\n\tCanon_CameraSettings();\n\tfseek(ifp,o,SEEK_SET);\n      }\n    if (type == 0x580b)\n      {\n        if (strcmp(model,\"Canon EOS D30\")) sprintf(imgdata.shootinginfo.BodySerial, \"%d\", len);\n        else sprintf(imgdata.shootinginfo.BodySerial, \"%0x-%05d\", len>>16, len&0xffff);\n      }\n#endif\n    if (type == 0x0032) {\n      if (len == 768) {\t\t\t\/* EOS D30 *\/\n\tfseek (ifp, 72, SEEK_CUR);\n\tFORC4 cam_mul[c ^ (c >> 1)] = 1024.0 \/ get2();\n\tif (!wbi) cam_mul[0] = -1;\t\/* use my auto white balance *\/\n      } else if (!cam_mul[0]) {\n\tif (get2() == key[0])\t\t\/* Pro1, G6, S60, S70 *\/\n\t  c = (strstr(model,\"Pro1\") ?\n\t      \"012346000000000000\":\"01345:000000006008\")[LIM(0,wbi,17)]-'0'+ 2;\n\telse {\t\t\t\t\/* G3, G5, S45, S50 *\/\n\t  c = \"023457000000006000\"[LIM(0,wbi,17)]-'0';\n\t  key[0] = key[1] = 0;\n\t}\n\tfseek (ifp, 78 + c*8, SEEK_CUR);\n\tFORC4 cam_mul[c ^ (c >> 1) ^ 1] = get2() ^ key[c & 1];\n\tif (!wbi) cam_mul[0] = -1;\n      }\n    }\n    if (type == 0x10a9) {\t\t\/* D60, 10D, 300D, and clones *\/\n      if (len > 66) wbi = \"0134567028\"[LIM(0,wbi,9)]-'0';\n      fseek (ifp, 2 + wbi*8, SEEK_CUR);\n      FORC4 cam_mul[c ^ (c >> 1)] = get2();\n    }\n    if (type == 0x1030 && wbi>=0 && (0x18040 >> wbi & 1))\n      ciff_block_1030();\t\t\/* all that don't have 0x10a9 *\/\n    if (type == 0x1031) {\n      raw_width = (get2(),get2());\n      raw_height = get2();\n    }\n    if (type == 0x501c) {\n      iso_speed = len & 0xffff;\n    }\n    if (type == 0x5029) {\n#ifdef LIBRAW_LIBRARY_BUILD\n      imgdata.lens.makernotes.CurFocal  = len >> 16;\n      imgdata.lens.makernotes.FocalType = len & 0xffff;\n      if (imgdata.lens.makernotes.FocalType == 2) {\n        imgdata.lens.makernotes.CanonFocalUnits = 32;\n\tif(imgdata.lens.makernotes.CanonFocalUnits>1)\n\t  imgdata.lens.makernotes.CurFocal \/= (float)imgdata.lens.makernotes.CanonFocalUnits;\n      }\n      focal_len = imgdata.lens.makernotes.CurFocal;\n#else\n      focal_len = len >> 16;\n      if ((len & 0xffff) == 2) focal_len \/= 32;\n#endif\n    }\n    if (type == 0x5813) flash_used = int_to_float(len);\n    if (type == 0x5814) canon_ev   = int_to_float(len);\n    if (type == 0x5817) shot_order = len;\n    if (type == 0x5834)\n      {\n         unique_id  = len;\n#ifdef LIBRAW_LIBRARY_BUILD\n         setCanonBodyFeatures(unique_id);\n#endif\n      }\n    if (type == 0x580e) timestamp  = len;\n    if (type == 0x180e) timestamp  = get4();\n#ifdef LOCALTIME\n    if ((type | 0x4000) == 0x580e)\n      timestamp = mktime (gmtime (×tamp));\n#endif\n    fseek (ifp, save, SEEK_SET);\n  }\n}","target":0,"code_token_length":2048,"total_token_length":2284,"max_tokens_setting":4096}
+{"idx":348471,"func":"int memory_failure(unsigned long pfn, int trapno, int flags)\n{\n\tstruct page_state *ps;\n\tstruct page *p;\n\tstruct page *hpage;\n\tstruct page *orig_head;\n\tint res;\n\tunsigned int nr_pages;\n\tunsigned long page_flags;\n\n\tif (!sysctl_memory_failure_recovery)\n\t\tpanic(\"Memory failure from trap %d on page %lx\", trapno, pfn);\n\n\tif (!pfn_valid(pfn)) {\n\t\tpr_err(\"Memory failure: %#lx: memory outside kernel control\\n\",\n\t\t\tpfn);\n\t\treturn -ENXIO;\n\t}\n\n\tp = pfn_to_page(pfn);\n\torig_head = hpage = compound_head(p);\n\tif (TestSetPageHWPoison(p)) {\n\t\tpr_err(\"Memory failure: %#lx: already hardware poisoned\\n\",\n\t\t\tpfn);\n\t\treturn 0;\n\t}\n\n\t\/*\n\t * Currently errors on hugetlbfs pages are measured in hugepage units,\n\t * so nr_pages should be 1 << compound_order.  OTOH when errors are on\n\t * transparent hugepages, they are supposed to be split and error\n\t * measurement is done in normal page units.  So nr_pages should be one\n\t * in this case.\n\t *\/\n\tif (PageHuge(p))\n\t\tnr_pages = 1 << compound_order(hpage);\n\telse \/* normal page or thp *\/\n\t\tnr_pages = 1;\n\tnum_poisoned_pages_add(nr_pages);\n\n\t\/*\n\t * We need\/can do nothing about count=0 pages.\n\t * 1) it's a free page, and therefore in safe hand:\n\t *    prep_new_page() will be the gate keeper.\n\t * 2) it's a free hugepage, which is also safe:\n\t *    an affected hugepage will be dequeued from hugepage freelist,\n\t *    so there's no concern about reusing it ever after.\n\t * 3) it's part of a non-compound high order page.\n\t *    Implies some kernel user: cannot stop them from\n\t *    R\/W the page; let's pray that the page has been\n\t *    used and will be freed some time later.\n\t * In fact it's dangerous to directly bump up page count from 0,\n\t * that may make page_freeze_refs()\/page_unfreeze_refs() mismatch.\n\t *\/\n\tif (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) {\n\t\tif (is_free_buddy_page(p)) {\n\t\t\taction_result(pfn, MF_MSG_BUDDY, MF_DELAYED);\n\t\t\treturn 0;\n\t\t} else if (PageHuge(hpage)) {\n\t\t\t\/*\n\t\t\t * Check \"filter hit\" and \"race with other subpage.\"\n\t\t\t *\/\n\t\t\tlock_page(hpage);\n\t\t\tif (PageHWPoison(hpage)) {\n\t\t\t\tif ((hwpoison_filter(p) && TestClearPageHWPoison(p))\n\t\t\t\t    || (p != hpage && TestSetPageHWPoison(hpage))) {\n\t\t\t\t\tnum_poisoned_pages_sub(nr_pages);\n\t\t\t\t\tunlock_page(hpage);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tset_page_hwpoison_huge_page(hpage);\n\t\t\tres = dequeue_hwpoisoned_huge_page(hpage);\n\t\t\taction_result(pfn, MF_MSG_FREE_HUGE,\n\t\t\t\t      res ? MF_IGNORED : MF_DELAYED);\n\t\t\tunlock_page(hpage);\n\t\t\treturn res;\n\t\t} else {\n\t\t\taction_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED);\n\t\t\treturn -EBUSY;\n\t\t}\n\t}\n\n\tif (!PageHuge(p) && PageTransHuge(hpage)) {\n\t\tlock_page(hpage);\n\t\tif (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {\n\t\t\tunlock_page(hpage);\n\t\t\tif (!PageAnon(hpage))\n\t\t\t\tpr_err(\"Memory failure: %#lx: non anonymous thp\\n\",\n\t\t\t\t\tpfn);\n\t\t\telse\n\t\t\t\tpr_err(\"Memory failure: %#lx: thp split failed\\n\",\n\t\t\t\t\tpfn);\n\t\t\tif (TestClearPageHWPoison(p))\n\t\t\t\tnum_poisoned_pages_sub(nr_pages);\n\t\t\tput_hwpoison_page(p);\n\t\t\treturn -EBUSY;\n\t\t}\n\t\tunlock_page(hpage);\n\t\tget_hwpoison_page(p);\n\t\tput_hwpoison_page(hpage);\n\t\tVM_BUG_ON_PAGE(!page_count(p), p);\n\t\thpage = compound_head(p);\n\t}\n\n\t\/*\n\t * We ignore non-LRU pages for good reasons.\n\t * - PG_locked is only well defined for LRU pages and a few others\n\t * - to avoid races with __SetPageLocked()\n\t * - to avoid races with __SetPageSlab*() (and more non-atomic ops)\n\t * The check (unnecessarily) ignores LRU pages being isolated and\n\t * walked by the page reclaim code, however that's not a big loss.\n\t *\/\n\tif (!PageHuge(p)) {\n\t\tif (!PageLRU(p))\n\t\t\tshake_page(p, 0);\n\t\tif (!PageLRU(p)) {\n\t\t\t\/*\n\t\t\t * shake_page could have turned it free.\n\t\t\t *\/\n\t\t\tif (is_free_buddy_page(p)) {\n\t\t\t\tif (flags & MF_COUNT_INCREASED)\n\t\t\t\t\taction_result(pfn, MF_MSG_BUDDY, MF_DELAYED);\n\t\t\t\telse\n\t\t\t\t\taction_result(pfn, MF_MSG_BUDDY_2ND,\n\t\t\t\t\t\t      MF_DELAYED);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tlock_page(hpage);\n\n\t\/*\n\t * The page could have changed compound pages during the locking.\n\t * If this happens just bail out.\n\t *\/\n\tif (PageCompound(p) && compound_head(p) != orig_head) {\n\t\taction_result(pfn, MF_MSG_DIFFERENT_COMPOUND, MF_IGNORED);\n\t\tres = -EBUSY;\n\t\tgoto out;\n\t}\n\n\t\/*\n\t * We use page flags to determine what action should be taken, but\n\t * the flags can be modified by the error containment action.  One\n\t * example is an mlocked page, where PG_mlocked is cleared by\n\t * page_remove_rmap() in try_to_unmap_one(). So to determine page status\n\t * correctly, we save a copy of the page flags at this time.\n\t *\/\n\tpage_flags = p->flags;\n\n\t\/*\n\t * unpoison always clear PG_hwpoison inside page lock\n\t *\/\n\tif (!PageHWPoison(p)) {\n\t\tpr_err(\"Memory failure: %#lx: just unpoisoned\\n\", pfn);\n\t\tnum_poisoned_pages_sub(nr_pages);\n\t\tunlock_page(hpage);\n\t\tput_hwpoison_page(hpage);\n\t\treturn 0;\n\t}\n\tif (hwpoison_filter(p)) {\n\t\tif (TestClearPageHWPoison(p))\n\t\t\tnum_poisoned_pages_sub(nr_pages);\n\t\tunlock_page(hpage);\n\t\tput_hwpoison_page(hpage);\n\t\treturn 0;\n\t}\n\n\tif (!PageHuge(p) && !PageTransTail(p) && !PageLRU(p))\n\t\tgoto identify_page_state;\n\n\t\/*\n\t * For error on the tail page, we should set PG_hwpoison\n\t * on the head page to show that the hugepage is hwpoisoned\n\t *\/\n\tif (PageHuge(p) && PageTail(p) && TestSetPageHWPoison(hpage)) {\n\t\taction_result(pfn, MF_MSG_POISONED_HUGE, MF_IGNORED);\n\t\tunlock_page(hpage);\n\t\tput_hwpoison_page(hpage);\n\t\treturn 0;\n\t}\n\t\/*\n\t * Set PG_hwpoison on all pages in an error hugepage,\n\t * because containment is done in hugepage unit for now.\n\t * Since we have done TestSetPageHWPoison() for the head page with\n\t * page lock held, we can safely set PG_hwpoison bits on tail pages.\n\t *\/\n\tif (PageHuge(p))\n\t\tset_page_hwpoison_huge_page(hpage);\n\n\t\/*\n\t * It's very difficult to mess with pages currently under IO\n\t * and in many cases impossible, so we just avoid it here.\n\t *\/\n\twait_on_page_writeback(p);\n\n\t\/*\n\t * Now take care of user space mappings.\n\t * Abort on fail: __delete_from_page_cache() assumes unmapped page.\n\t *\n\t * When the raw error page is thp tail page, hpage points to the raw\n\t * page after thp split.\n\t *\/\n\tif (hwpoison_user_mappings(p, pfn, trapno, flags, &hpage)\n\t    != SWAP_SUCCESS) {\n\t\taction_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED);\n\t\tres = -EBUSY;\n\t\tgoto out;\n\t}\n\n\t\/*\n\t * Torn down by someone else?\n\t *\/\n\tif (PageLRU(p) && !PageSwapCache(p) && p->mapping == NULL) {\n\t\taction_result(pfn, MF_MSG_TRUNCATED_LRU, MF_IGNORED);\n\t\tres = -EBUSY;\n\t\tgoto out;\n\t}\n\nidentify_page_state:\n\tres = -EBUSY;\n\t\/*\n\t * The first check uses the current page flags which may not have any\n\t * relevant information. The second check with the saved page flagss is\n\t * carried out only if the first check can't determine the page status.\n\t *\/\n\tfor (ps = error_states;; ps++)\n\t\tif ((p->flags & ps->mask) == ps->res)\n\t\t\tbreak;\n\n\tpage_flags |= (p->flags & (1UL << PG_dirty));\n\n\tif (!ps->mask)\n\t\tfor (ps = error_states;; ps++)\n\t\t\tif ((page_flags & ps->mask) == ps->res)\n\t\t\t\tbreak;\n\tres = page_action(ps, p, pfn);\nout:\n\tunlock_page(hpage);\n\treturn res;\n}","target":1,"code_token_length":2091,"total_token_length":2327,"max_tokens_setting":4096}
+{"idx":322397,"func":"DECLARE_LOOP_FILTER(mmxext)\n\nDECLARE_LOOP_FILTER(sse2)\n\nDECLARE_LOOP_FILTER(ssse3)\n\nDECLARE_LOOP_FILTER(sse4)\n\n\n\n#endif \/* HAVE_YASM *\/\n\n\n\n#define VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) \\\n\n    c->put_vp8_epel_pixels_tab[IDX][0][2] = ff_put_vp8_epel ## SIZE ## _h6_ ## OPT; \\\n\n    c->put_vp8_epel_pixels_tab[IDX][2][0] = ff_put_vp8_epel ## SIZE ## _v6_ ## OPT; \\\n\n    c->put_vp8_epel_pixels_tab[IDX][2][2] = ff_put_vp8_epel ## SIZE ## _h6v6_ ## OPT\n\n\n\n#define VP8_MC_FUNC(IDX, SIZE, OPT) \\\n\n    c->put_vp8_epel_pixels_tab[IDX][0][1] = ff_put_vp8_epel ## SIZE ## _h4_ ## OPT; \\\n\n    c->put_vp8_epel_pixels_tab[IDX][1][0] = ff_put_vp8_epel ## SIZE ## _v4_ ## OPT; \\\n\n    c->put_vp8_epel_pixels_tab[IDX][1][1] = ff_put_vp8_epel ## SIZE ## _h4v4_ ## OPT; \\\n\n    c->put_vp8_epel_pixels_tab[IDX][1][2] = ff_put_vp8_epel ## SIZE ## _h6v4_ ## OPT; \\\n\n    c->put_vp8_epel_pixels_tab[IDX][2][1] = ff_put_vp8_epel ## SIZE ## _h4v6_ ## OPT; \\\n\n    VP8_LUMA_MC_FUNC(IDX, SIZE, OPT)\n\n\n\n#define VP8_BILINEAR_MC_FUNC(IDX, SIZE, OPT) \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][0][1] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][0][2] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][1][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][1][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][1][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][2][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][2][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \\\n\n    c->put_vp8_bilinear_pixels_tab[IDX][2][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT\n\n\n\n\n\nav_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)\n\n{\n\n#if HAVE_YASM\n\n    int mm_flags = av_get_cpu_flags();\n\n\n\n    if (mm_flags & AV_CPU_FLAG_MMX) {\n\n        c->vp8_idct_dc_add    = ff_vp8_idct_dc_add_mmx;\n\n        c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;\n\n#if ARCH_X86_32\n\n        c->vp8_idct_dc_add4y  = ff_vp8_idct_dc_add4y_mmx;\n\n        c->vp8_idct_add       = ff_vp8_idct_add_mmx;\n\n        c->vp8_luma_dc_wht    = ff_vp8_luma_dc_wht_mmx;\n\n        c->put_vp8_epel_pixels_tab[0][0][0]     =\n\n        c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;\n\n#endif\n\n        c->put_vp8_epel_pixels_tab[1][0][0]     =\n\n        c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;\n\n\n\n#if ARCH_X86_32\n\n        c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx;\n\n        c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx;\n\n\n\n        c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx;\n\n        c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx;\n\n        c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx;\n\n        c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx;\n\n\n\n        c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_mmx;\n\n        c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_mmx;\n\n        c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_mmx;\n\n        c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_mmx;\n\n#endif\n\n    }\n\n\n\n    \/* note that 4-tap width=16 functions are missing because w=16\n\n     * is only used for luma, and luma is always a copy or sixtap. *\/\n\n    if (mm_flags & AV_CPU_FLAG_MMXEXT) {\n\n        VP8_MC_FUNC(2, 4, mmxext);\n\n        VP8_BILINEAR_MC_FUNC(2, 4, mmxext);\n\n#if ARCH_X86_32\n\n        VP8_LUMA_MC_FUNC(0, 16, mmxext);\n\n        VP8_MC_FUNC(1, 8, mmxext);\n\n        VP8_BILINEAR_MC_FUNC(0, 16, mmxext);\n\n        VP8_BILINEAR_MC_FUNC(1,  8, mmxext);\n\n\n\n        c->vp8_v_loop_filter_simple   = ff_vp8_v_loop_filter_simple_mmxext;\n\n        c->vp8_h_loop_filter_simple   = ff_vp8_h_loop_filter_simple_mmxext;\n\n\n\n        c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmxext;\n\n        c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmxext;\n\n        c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmxext;\n\n        c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmxext;\n\n\n\n        c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_mmxext;\n\n        c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_mmxext;\n\n        c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_mmxext;\n\n        c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_mmxext;\n\n#endif\n\n    }\n\n\n\n    if (mm_flags & AV_CPU_FLAG_SSE) {\n\n        c->vp8_idct_add                         = ff_vp8_idct_add_sse;\n\n        c->vp8_luma_dc_wht                      = ff_vp8_luma_dc_wht_sse;\n\n        c->put_vp8_epel_pixels_tab[0][0][0]     =\n\n        c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;\n\n    }\n\n\n\n    if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {\n\n        VP8_LUMA_MC_FUNC(0, 16, sse2);\n\n        VP8_MC_FUNC(1, 8, sse2);\n\n        VP8_BILINEAR_MC_FUNC(0, 16, sse2);\n\n        VP8_BILINEAR_MC_FUNC(1, 8, sse2);\n\n\n\n        c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2;\n\n\n\n#if ARCH_X86_64 || HAVE_ALIGNED_STACK\n\n        c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2;\n\n        c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_sse2;\n\n\n\n        c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_sse2;\n\n        c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_sse2;\n\n#endif\n\n    }\n\n\n\n    if (mm_flags & AV_CPU_FLAG_SSE2) {\n\n        c->vp8_idct_dc_add4y          = ff_vp8_idct_dc_add4y_sse2;\n\n\n\n        c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;\n\n\n\n#if ARCH_X86_64 || HAVE_ALIGNED_STACK\n\n        c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2;\n\n        c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2;\n\n\n\n        c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_sse2;\n\n        c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_sse2;\n\n#endif\n\n    }\n\n\n\n    if (mm_flags & AV_CPU_FLAG_SSSE3) {\n\n        VP8_LUMA_MC_FUNC(0, 16, ssse3);\n\n        VP8_MC_FUNC(1, 8, ssse3);\n\n        VP8_MC_FUNC(2, 4, ssse3);\n\n        VP8_BILINEAR_MC_FUNC(0, 16, ssse3);\n\n        VP8_BILINEAR_MC_FUNC(1, 8, ssse3);\n\n        VP8_BILINEAR_MC_FUNC(2, 4, ssse3);\n\n\n\n        c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_ssse3;\n\n        c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_ssse3;\n\n\n\n#if ARCH_X86_64 || HAVE_ALIGNED_STACK\n\n        c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_ssse3;\n\n        c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_ssse3;\n\n        c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_ssse3;\n\n        c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_ssse3;\n\n\n\n        c->vp8_v_loop_filter16y       = ff_vp8_v_loop_filter16y_mbedge_ssse3;\n\n        c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_ssse3;\n\n        c->vp8_v_loop_filter8uv       = ff_vp8_v_loop_filter8uv_mbedge_ssse3;\n\n        c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_ssse3;\n\n#endif\n\n    }\n\n\n\n    if (mm_flags & AV_CPU_FLAG_SSE4) {\n\n        c->vp8_idct_dc_add                  = ff_vp8_idct_dc_add_sse4;\n\n\n\n        c->vp8_h_loop_filter_simple   = ff_vp8_h_loop_filter_simple_sse4;\n\n#if ARCH_X86_64 || HAVE_ALIGNED_STACK\n\n        c->vp8_h_loop_filter16y       = ff_vp8_h_loop_filter16y_mbedge_sse4;\n\n        c->vp8_h_loop_filter8uv       = ff_vp8_h_loop_filter8uv_mbedge_sse4;\n\n#endif\n\n    }\n\n#endif \/* HAVE_YASM *\/\n\n}\n","target":0,"code_token_length":2678,"total_token_length":2914,"max_tokens_setting":4096}
+{"idx":426208,"func":"flatpak_context_load_metadata (FlatpakContext *context,\n                               GKeyFile       *metakey,\n                               GError        **error)\n{\n  gboolean remove;\n  g_auto(GStrv) groups = NULL;\n  int i;\n\n  if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SHARED, NULL))\n    {\n      g_auto(GStrv) shares = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,\n                                                         FLATPAK_METADATA_KEY_SHARED, NULL, error);\n      if (shares == NULL)\n        return FALSE;\n\n      for (i = 0; shares[i] != NULL; i++)\n        {\n          FlatpakContextShares share;\n\n          share = flatpak_context_share_from_string (parse_negated (shares[i], &remove), error);\n          if (share == 0)\n            return FALSE;\n          if (remove)\n            flatpak_context_remove_shares (context, share);\n          else\n            flatpak_context_add_shares (context, share);\n        }\n    }\n\n  if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SOCKETS, NULL))\n    {\n      g_auto(GStrv) sockets = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,\n                                                          FLATPAK_METADATA_KEY_SOCKETS, NULL, error);\n      if (sockets == NULL)\n        return FALSE;\n\n      for (i = 0; sockets[i] != NULL; i++)\n        {\n          FlatpakContextSockets socket = flatpak_context_socket_from_string (parse_negated (sockets[i], &remove), error);\n          if (socket == 0)\n            return FALSE;\n          if (remove)\n            flatpak_context_remove_sockets (context, socket);\n          else\n            flatpak_context_add_sockets (context, socket);\n        }\n    }\n\n  if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_DEVICES, NULL))\n    {\n      g_auto(GStrv) devices = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,\n                                                          FLATPAK_METADATA_KEY_DEVICES, NULL, error);\n      if (devices == NULL)\n        return FALSE;\n\n\n      for (i = 0; devices[i] != NULL; i++)\n        {\n          FlatpakContextDevices device = flatpak_context_device_from_string (parse_negated (devices[i], &remove), error);\n          if (device == 0)\n            return FALSE;\n          if (remove)\n            flatpak_context_remove_devices (context, device);\n          else\n            flatpak_context_add_devices (context, device);\n        }\n    }\n\n  if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FEATURES, NULL))\n    {\n      g_auto(GStrv) features = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,\n                                                         FLATPAK_METADATA_KEY_FEATURES, NULL, error);\n      if (features == NULL)\n        return FALSE;\n\n\n      for (i = 0; features[i] != NULL; i++)\n        {\n          FlatpakContextFeatures feature = flatpak_context_feature_from_string (parse_negated (features[i], &remove), error);\n          if (feature == 0)\n            return FALSE;\n          if (remove)\n            flatpak_context_remove_features (context, feature);\n          else\n            flatpak_context_add_features (context, feature);\n        }\n    }\n\n  if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FILESYSTEMS, NULL))\n    {\n      g_auto(GStrv) filesystems = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,\n                                                              FLATPAK_METADATA_KEY_FILESYSTEMS, NULL, error);\n      if (filesystems == NULL)\n        return FALSE;\n\n      for (i = 0; filesystems[i] != NULL; i++)\n        {\n          const char *fs = parse_negated (filesystems[i], &remove);\n          if (!flatpak_context_verify_filesystem (fs, error))\n            return FALSE;\n          if (remove)\n            flatpak_context_remove_filesystem (context, fs);\n          else\n            flatpak_context_add_filesystem (context, fs);\n        }\n    }\n\n  if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_PERSISTENT, NULL))\n    {\n      g_auto(GStrv) persistent = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT,\n                                                             FLATPAK_METADATA_KEY_PERSISTENT, NULL, error);\n      if (persistent == NULL)\n        return FALSE;\n\n      for (i = 0; persistent[i] != NULL; i++)\n        flatpak_context_set_persistent (context, persistent[i]);\n    }\n\n  if (g_key_file_has_group (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY))\n    {\n      g_auto(GStrv) keys = NULL;\n      gsize i, keys_count;\n\n      keys = g_key_file_get_keys (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY, &keys_count, NULL);\n      for (i = 0; i < keys_count; i++)\n        {\n          const char *key = keys[i];\n          g_autofree char *value = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY, key, NULL);\n          FlatpakPolicy policy;\n\n          if (!flatpak_verify_dbus_name (key, error))\n            return FALSE;\n\n          policy = flatpak_policy_from_string (value, error);\n          if ((int) policy == -1)\n            return FALSE;\n\n          flatpak_context_set_session_bus_policy (context, key, policy);\n        }\n    }\n\n  if (g_key_file_has_group (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY))\n    {\n      g_auto(GStrv) keys = NULL;\n      gsize i, keys_count;\n\n      keys = g_key_file_get_keys (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY, &keys_count, NULL);\n      for (i = 0; i < keys_count; i++)\n        {\n          const char *key = keys[i];\n          g_autofree char *value = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY, key, NULL);\n          FlatpakPolicy policy;\n\n          if (!flatpak_verify_dbus_name (key, error))\n            return FALSE;\n\n          policy = flatpak_policy_from_string (value, error);\n          if ((int) policy == -1)\n            return FALSE;\n\n          flatpak_context_set_system_bus_policy (context, key, policy);\n        }\n    }\n\n  if (g_key_file_has_group (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT))\n    {\n      g_auto(GStrv) keys = NULL;\n      gsize i, keys_count;\n\n      keys = g_key_file_get_keys (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT, &keys_count, NULL);\n      for (i = 0; i < keys_count; i++)\n        {\n          const char *key = keys[i];\n          g_autofree char *value = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT, key, NULL);\n\n          flatpak_context_set_env_var (context, key, value);\n        }\n    }\n\n  groups = g_key_file_get_groups (metakey, NULL);\n  for (i = 0; groups[i] != NULL; i++)\n    {\n      const char *group = groups[i];\n      const char *subsystem;\n      int j;\n\n      if (g_str_has_prefix (group, FLATPAK_METADATA_GROUP_PREFIX_POLICY))\n        {\n          g_auto(GStrv) keys = NULL;\n          subsystem = group + strlen (FLATPAK_METADATA_GROUP_PREFIX_POLICY);\n          keys = g_key_file_get_keys (metakey, group, NULL, NULL);\n          for (j = 0; keys != NULL && keys[j] != NULL; j++)\n            {\n              const char *key = keys[j];\n              g_autofree char *policy_key = g_strdup_printf (\"%s.%s\", subsystem, key);\n              g_auto(GStrv) values = NULL;\n              int k;\n\n              values = g_key_file_get_string_list (metakey, group, key, NULL, NULL);\n              for (k = 0; values != NULL && values[k] != NULL; k++)\n                flatpak_context_apply_generic_policy (context, policy_key,\n                                                      values[k]);\n            }\n        }\n    }\n\n  return TRUE;\n}","target":0,"code_token_length":1871,"total_token_length":2107,"max_tokens_setting":4096}
+{"idx":508894,"func":"int ssl3_send_server_key_exchange(SSL *s)\n{\n#ifndef OPENSSL_NO_RSA\n    unsigned char *q;\n    int j, num;\n    RSA *rsa;\n    unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];\n    unsigned int u;\n#endif\n#ifndef OPENSSL_NO_DH\n    DH *dh = NULL, *dhp;\n#endif\n#ifndef OPENSSL_NO_ECDH\n    EC_KEY *ecdh = NULL, *ecdhp;\n    unsigned char *encodedPoint = NULL;\n    int encodedlen = 0;\n    int curve_id = 0;\n    BN_CTX *bn_ctx = NULL;\n#endif\n    EVP_PKEY *pkey;\n    const EVP_MD *md = NULL;\n    unsigned char *p, *d;\n    int al, i;\n    unsigned long type;\n    int n;\n    CERT *cert;\n    BIGNUM *r[4];\n    int nr[4], kn;\n    BUF_MEM *buf;\n    EVP_MD_CTX md_ctx;\n\n    EVP_MD_CTX_init(&md_ctx);\n    if (s->state == SSL3_ST_SW_KEY_EXCH_A) {\n        type = s->s3->tmp.new_cipher->algorithm_mkey;\n        cert = s->cert;\n\n        buf = s->init_buf;\n\n        r[0] = r[1] = r[2] = r[3] = NULL;\n        n = 0;\n#ifndef OPENSSL_NO_RSA\n        if (type & SSL_kRSA) {\n            rsa = cert->rsa_tmp;\n            if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) {\n                rsa = s->cert->rsa_tmp_cb(s,\n                                          SSL_C_IS_EXPORT(s->s3->\n                                                          tmp.new_cipher),\n                                          SSL_C_EXPORT_PKEYLENGTH(s->s3->\n                                                                  tmp.new_cipher));\n                if (rsa == NULL) {\n                    al = SSL_AD_HANDSHAKE_FAILURE;\n                    SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                           SSL_R_ERROR_GENERATING_TMP_RSA_KEY);\n                    goto f_err;\n                }\n                RSA_up_ref(rsa);\n                cert->rsa_tmp = rsa;\n            }\n            if (rsa == NULL) {\n                al = SSL_AD_HANDSHAKE_FAILURE;\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_MISSING_TMP_RSA_KEY);\n                goto f_err;\n            }\n            r[0] = rsa->n;\n            r[1] = rsa->e;\n            s->s3->tmp.use_rsa_tmp = 1;\n        } else\n#endif\n#ifndef OPENSSL_NO_DH\n        if (type & SSL_kEDH) {\n            dhp = cert->dh_tmp;\n            if ((dhp == NULL) && (s->cert->dh_tmp_cb != NULL))\n                dhp = s->cert->dh_tmp_cb(s,\n                                         SSL_C_IS_EXPORT(s->s3->\n                                                         tmp.new_cipher),\n                                         SSL_C_EXPORT_PKEYLENGTH(s->s3->\n                                                                 tmp.new_cipher));\n            if (dhp == NULL) {\n                al = SSL_AD_HANDSHAKE_FAILURE;\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_MISSING_TMP_DH_KEY);\n                goto f_err;\n            }\n\n            if (s->s3->tmp.dh != NULL) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            if ((dh = DHparams_dup(dhp)) == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB);\n                goto err;\n            }\n\n            s->s3->tmp.dh = dh;\n            if (!DH_generate_key(dh)) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB);\n                goto err;\n            }\n            r[0] = dh->p;\n            r[1] = dh->g;\n            r[2] = dh->pub_key;\n        } else\n#endif\n#ifndef OPENSSL_NO_ECDH\n        if (type & SSL_kEECDH) {\n            const EC_GROUP *group;\n\n            ecdhp = cert->ecdh_tmp;\n            if (s->cert->ecdh_tmp_auto) {\n                \/* Get NID of appropriate shared curve *\/\n                int nid = tls1_shared_curve(s, -2);\n                if (nid != NID_undef)\n                    ecdhp = EC_KEY_new_by_curve_name(nid);\n            } else if ((ecdhp == NULL) && s->cert->ecdh_tmp_cb) {\n                ecdhp = s->cert->ecdh_tmp_cb(s,\n                                             SSL_C_IS_EXPORT(s->s3->\n                                                             tmp.new_cipher),\n                                             SSL_C_EXPORT_PKEYLENGTH(s->\n                                                                     s3->tmp.new_cipher));\n            }\n            if (ecdhp == NULL) {\n                al = SSL_AD_HANDSHAKE_FAILURE;\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_MISSING_TMP_ECDH_KEY);\n                goto f_err;\n            }\n\n            if (s->s3->tmp.ecdh != NULL) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            \/* Duplicate the ECDH structure. *\/\n            if (ecdhp == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n                goto err;\n            }\n            if (s->cert->ecdh_tmp_auto)\n                ecdh = ecdhp;\n            else if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n                goto err;\n            }\n\n            s->s3->tmp.ecdh = ecdh;\n            if ((EC_KEY_get0_public_key(ecdh) == NULL) ||\n                (EC_KEY_get0_private_key(ecdh) == NULL) ||\n                (s->options & SSL_OP_SINGLE_ECDH_USE)) {\n                if (!EC_KEY_generate_key(ecdh)) {\n                    SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                           ERR_R_ECDH_LIB);\n                    goto err;\n                }\n            }\n\n            if (((group = EC_KEY_get0_group(ecdh)) == NULL) ||\n                (EC_KEY_get0_public_key(ecdh) == NULL) ||\n                (EC_KEY_get0_private_key(ecdh) == NULL)) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n                goto err;\n            }\n\n            if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) &&\n                (EC_GROUP_get_degree(group) > 163)) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER);\n                goto err;\n            }\n\n            \/*\n             * XXX: For now, we only support ephemeral ECDH keys over named\n             * (not generic) curves. For supported named curves, curve_id is\n             * non-zero.\n             *\/\n            if ((curve_id =\n                 tls1_ec_nid2curve_id(EC_GROUP_get_curve_name(group)))\n                == 0) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_UNSUPPORTED_ELLIPTIC_CURVE);\n                goto err;\n            }\n\n            \/*\n             * Encode the public key. First check the size of encoding and\n             * allocate memory accordingly.\n             *\/\n            encodedlen = EC_POINT_point2oct(group,\n                                            EC_KEY_get0_public_key(ecdh),\n                                            POINT_CONVERSION_UNCOMPRESSED,\n                                            NULL, 0, NULL);\n\n            encodedPoint = (unsigned char *)\n                OPENSSL_malloc(encodedlen * sizeof(unsigned char));\n            bn_ctx = BN_CTX_new();\n            if ((encodedPoint == NULL) || (bn_ctx == NULL)) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n\n            encodedlen = EC_POINT_point2oct(group,\n                                            EC_KEY_get0_public_key(ecdh),\n                                            POINT_CONVERSION_UNCOMPRESSED,\n                                            encodedPoint, encodedlen, bn_ctx);\n\n            if (encodedlen == 0) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n                goto err;\n            }\n\n            BN_CTX_free(bn_ctx);\n            bn_ctx = NULL;\n\n            \/*\n             * XXX: For now, we only support named (not generic) curves in\n             * ECDH ephemeral key exchanges. In this situation, we need four\n             * additional bytes to encode the entire ServerECDHParams\n             * structure.\n             *\/\n            n = 4 + encodedlen;\n\n            \/*\n             * We'll generate the serverKeyExchange message explicitly so we\n             * can set these to NULLs\n             *\/\n            r[0] = NULL;\n            r[1] = NULL;\n            r[2] = NULL;\n            r[3] = NULL;\n        } else\n#endif                          \/* !OPENSSL_NO_ECDH *\/\n#ifndef OPENSSL_NO_PSK\n        if (type & SSL_kPSK) {\n            \/*\n             * reserve size for record length and PSK identity hint\n             *\/\n            n += 2 + strlen(s->ctx->psk_identity_hint);\n        } else\n#endif                          \/* !OPENSSL_NO_PSK *\/\n#ifndef OPENSSL_NO_SRP\n        if (type & SSL_kSRP) {\n            if ((s->srp_ctx.N == NULL) ||\n                (s->srp_ctx.g == NULL) ||\n                (s->srp_ctx.s == NULL) || (s->srp_ctx.B == NULL)) {\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_MISSING_SRP_PARAM);\n                goto err;\n            }\n            r[0] = s->srp_ctx.N;\n            r[1] = s->srp_ctx.g;\n            r[2] = s->srp_ctx.s;\n            r[3] = s->srp_ctx.B;\n        } else\n#endif\n        {\n            al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                   SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE);\n            goto f_err;\n        }\n        for (i = 0; i < 4 && r[i] != NULL; i++) {\n            nr[i] = BN_num_bytes(r[i]);\n#ifndef OPENSSL_NO_SRP\n            if ((i == 2) && (type & SSL_kSRP))\n                n += 1 + nr[i];\n            else\n#endif\n                n += 2 + nr[i];\n        }\n\n        if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))\n            && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {\n            if ((pkey = ssl_get_sign_pkey(s, s->s3->tmp.new_cipher, &md))\n                == NULL) {\n                al = SSL_AD_DECODE_ERROR;\n                goto f_err;\n            }\n            kn = EVP_PKEY_size(pkey);\n        } else {\n            pkey = NULL;\n            kn = 0;\n        }\n\n        if (!BUF_MEM_grow_clean(buf, n + SSL_HM_HEADER_LENGTH(s) + kn)) {\n            SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_BUF);\n            goto err;\n        }\n        d = p = ssl_handshake_start(s);\n\n        for (i = 0; i < 4 && r[i] != NULL; i++) {\n#ifndef OPENSSL_NO_SRP\n            if ((i == 2) && (type & SSL_kSRP)) {\n                *p = nr[i];\n                p++;\n            } else\n#endif\n                s2n(nr[i], p);\n            BN_bn2bin(r[i], p);\n            p += nr[i];\n        }\n\n#ifndef OPENSSL_NO_ECDH\n        if (type & SSL_kEECDH) {\n            \/*\n             * XXX: For now, we only support named (not generic) curves. In\n             * this situation, the serverKeyExchange message has: [1 byte\n             * CurveType], [2 byte CurveName] [1 byte length of encoded\n             * point], followed by the actual encoded point itself\n             *\/\n            *p = NAMED_CURVE_TYPE;\n            p += 1;\n            *p = 0;\n            p += 1;\n            *p = curve_id;\n            p += 1;\n            *p = encodedlen;\n            p += 1;\n            memcpy((unsigned char *)p,\n                   (unsigned char *)encodedPoint, encodedlen);\n            OPENSSL_free(encodedPoint);\n            encodedPoint = NULL;\n            p += encodedlen;\n        }\n#endif\n\n#ifndef OPENSSL_NO_PSK\n        if (type & SSL_kPSK) {\n            \/* copy PSK identity hint *\/\n            s2n(strlen(s->ctx->psk_identity_hint), p);\n            strncpy((char *)p, s->ctx->psk_identity_hint,\n                    strlen(s->ctx->psk_identity_hint));\n            p += strlen(s->ctx->psk_identity_hint);\n        }\n#endif\n\n        \/* not anonymous *\/\n        if (pkey != NULL) {\n            \/*\n             * n is the length of the params, they start at &(d[4]) and p\n             * points to the space at the end.\n             *\/\n#ifndef OPENSSL_NO_RSA\n            if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) {\n                q = md_buf;\n                j = 0;\n                for (num = 2; num > 0; num--) {\n                    EVP_MD_CTX_set_flags(&md_ctx,\n                                         EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);\n                    if (EVP_DigestInit_ex(&md_ctx,\n                                          (num == 2) ? s->ctx->md5\n                                                     : s->ctx->sha1,\n                                          NULL) <= 0\n                        || EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]),\n                                            SSL3_RANDOM_SIZE) <= 0\n                        || EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]),\n                                            SSL3_RANDOM_SIZE) <= 0\n                        || EVP_DigestUpdate(&md_ctx, d, n) <= 0\n                        || EVP_DigestFinal_ex(&md_ctx, q,\n                                              (unsigned int *)&i) <= 0) {\n                        SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                               ERR_LIB_EVP);\n                        al = SSL_AD_INTERNAL_ERROR;\n                        goto f_err;\n                    }\n                    q += i;\n                    j += i;\n                }\n                if (RSA_sign(NID_md5_sha1, md_buf, j,\n                             &(p[2]), &u, pkey->pkey.rsa) <= 0) {\n                    SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_RSA);\n                    goto err;\n                }\n                s2n(u, p);\n                n += u + 2;\n            } else\n#endif\n            if (md) {\n                \/* send signature algorithm *\/\n                if (SSL_USE_SIGALGS(s)) {\n                    if (!tls12_get_sigandhash(p, pkey, md)) {\n                        \/* Should never happen *\/\n                        al = SSL_AD_INTERNAL_ERROR;\n                        SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                               ERR_R_INTERNAL_ERROR);\n                        goto f_err;\n                    }\n                    p += 2;\n                }\n#ifdef SSL_DEBUG\n                fprintf(stderr, \"Using hash %s\\n\", EVP_MD_name(md));\n#endif\n                if (EVP_SignInit_ex(&md_ctx, md, NULL) <= 0\n                        || EVP_SignUpdate(&md_ctx, &(s->s3->client_random[0]),\n                                          SSL3_RANDOM_SIZE) <= 0\n                        || EVP_SignUpdate(&md_ctx, &(s->s3->server_random[0]),\n                                          SSL3_RANDOM_SIZE) <= 0\n                        || EVP_SignUpdate(&md_ctx, d, n) <= 0\n                        || EVP_SignFinal(&md_ctx, &(p[2]),\n                                         (unsigned int *)&i, pkey) <= 0) {\n                    SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_EVP);\n                    al = SSL_AD_INTERNAL_ERROR;\n                    goto f_err;\n                }\n                s2n(i, p);\n                n += i + 2;\n                if (SSL_USE_SIGALGS(s))\n                    n += 2;\n            } else {\n                \/* Is this error check actually needed? *\/\n                al = SSL_AD_HANDSHAKE_FAILURE;\n                SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,\n                       SSL_R_UNKNOWN_PKEY_TYPE);\n                goto f_err;\n            }\n        }\n\n        ssl_set_handshake_header(s, SSL3_MT_SERVER_KEY_EXCHANGE, n);\n    }\n\n    s->state = SSL3_ST_SW_KEY_EXCH_B;\n    EVP_MD_CTX_cleanup(&md_ctx);\n    return ssl_do_write(s);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n#ifndef OPENSSL_NO_ECDH\n    if (encodedPoint != NULL)\n        OPENSSL_free(encodedPoint);\n    BN_CTX_free(bn_ctx);\n#endif\n    EVP_MD_CTX_cleanup(&md_ctx);\n    s->state = SSL_ST_ERR;\n    return (-1);\n}","target":0,"code_token_length":3695,"total_token_length":3931,"max_tokens_setting":4096}
+{"idx":16927,"func":"int ff_MPV_frame_start ( MpegEncContext * s , AVCodecContext * avctx ) {\n int i , ret ;\n Picture * pic ;\n s -> mb_skipped = 0 ;\n if ( s -> out_format != FMT_H264 || s -> codec_id == AV_CODEC_ID_SVQ3 ) {\n if ( s -> pict_type != AV_PICTURE_TYPE_B && s -> last_picture_ptr && s -> last_picture_ptr != s -> next_picture_ptr && s -> last_picture_ptr -> f . data [ 0 ] ) {\n ff_mpeg_unref_picture ( s , s -> last_picture_ptr ) ;\n }\n if ( ! s -> encoding ) {\n for ( i = 0 ;\n i < MAX_PICTURE_COUNT ;\n i ++ ) {\n if ( & s -> picture [ i ] != s -> last_picture_ptr && & s -> picture [ i ] != s -> next_picture_ptr && s -> picture [ i ] . reference && ! s -> picture [ i ] . needs_realloc ) {\n if ( ! ( avctx -> active_thread_type & FF_THREAD_FRAME ) ) av_log ( avctx , AV_LOG_ERROR , \"releasing zombie picture\\n\" ) ;\n ff_mpeg_unref_picture ( s , & s -> picture [ i ] ) ;\n }\n }\n }\n }\n if ( ! s -> encoding ) {\n ff_release_unused_pictures ( s , 1 ) ;\n if ( s -> current_picture_ptr && s -> current_picture_ptr -> f . data [ 0 ] == NULL ) {\n pic = s -> current_picture_ptr ;\n }\n else {\n i = ff_find_unused_picture ( s , 0 ) ;\n if ( i < 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"no frame buffer available\\n\" ) ;\n return i ;\n }\n pic = & s -> picture [ i ] ;\n }\n pic -> reference = 0 ;\n if ( ! s -> droppable ) {\n if ( s -> codec_id == AV_CODEC_ID_H264 ) pic -> reference = s -> picture_structure ;\n else if ( s -> pict_type != AV_PICTURE_TYPE_B ) pic -> reference = 3 ;\n }\n pic -> f . coded_picture_number = s -> coded_picture_number ++ ;\n if ( ff_alloc_picture ( s , pic , 0 ) < 0 ) return - 1 ;\n s -> current_picture_ptr = pic ;\n s -> current_picture_ptr -> f . top_field_first = s -> top_field_first ;\n if ( s -> codec_id == AV_CODEC_ID_MPEG1VIDEO || s -> codec_id == AV_CODEC_ID_MPEG2VIDEO ) {\n if ( s -> picture_structure != PICT_FRAME ) s -> current_picture_ptr -> f . top_field_first = ( s -> picture_structure == PICT_TOP_FIELD ) == s -> first_field ;\n }\n s -> current_picture_ptr -> f . interlaced_frame = ! s -> progressive_frame && ! s -> progressive_sequence ;\n s -> current_picture_ptr -> field_picture = s -> picture_structure != PICT_FRAME ;\n }\n s -> current_picture_ptr -> f . pict_type = s -> pict_type ;\n s -> current_picture_ptr -> f . key_frame = s -> pict_type == AV_PICTURE_TYPE_I ;\n ff_mpeg_unref_picture ( s , & s -> current_picture ) ;\n if ( ( ret = ff_mpeg_ref_picture ( s , & s -> current_picture , s -> current_picture_ptr ) ) < 0 ) return ret ;\n if ( s -> codec_id != AV_CODEC_ID_H264 && s -> pict_type != AV_PICTURE_TYPE_B ) {\n s -> last_picture_ptr = s -> next_picture_ptr ;\n if ( ! s -> droppable ) s -> next_picture_ptr = s -> current_picture_ptr ;\n }\n av_dlog ( s -> avctx , \"L%p N%p C%p L%p N%p C%p type:%d drop:%d\\n\" , s -> last_picture_ptr , s -> next_picture_ptr , s -> current_picture_ptr , s -> last_picture_ptr ? s -> last_picture_ptr -> f . data [ 0 ] : NULL , s -> next_picture_ptr ? s -> next_picture_ptr -> f . data [ 0 ] : NULL , s -> current_picture_ptr ? s -> current_picture_ptr -> f . data [ 0 ] : NULL , s -> pict_type , s -> droppable ) ;\n if ( s -> codec_id != AV_CODEC_ID_H264 ) {\n if ( ( s -> last_picture_ptr == NULL || s -> last_picture_ptr -> f . data [ 0 ] == NULL ) && ( s -> pict_type != AV_PICTURE_TYPE_I || s -> picture_structure != PICT_FRAME ) ) {\n int h_chroma_shift , v_chroma_shift ;\n av_pix_fmt_get_chroma_sub_sample ( s -> avctx -> pix_fmt , & h_chroma_shift , & v_chroma_shift ) ;\n if ( s -> pict_type != AV_PICTURE_TYPE_I ) av_log ( avctx , AV_LOG_ERROR , \"warning: first frame is no keyframe\\n\" ) ;\n else if ( s -> picture_structure != PICT_FRAME ) av_log ( avctx , AV_LOG_INFO , \"allocate dummy last picture for field based first keyframe\\n\" ) ;\n i = ff_find_unused_picture ( s , 0 ) ;\n if ( i < 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"no frame buffer available\\n\" ) ;\n return i ;\n }\n s -> last_picture_ptr = & s -> picture [ i ] ;\n if ( ff_alloc_picture ( s , s -> last_picture_ptr , 0 ) < 0 ) {\n s -> last_picture_ptr = NULL ;\n return - 1 ;\n }\n memset ( s -> last_picture_ptr -> f . data [ 0 ] , 0 , avctx -> height * s -> last_picture_ptr -> f . linesize [ 0 ] ) ;\n memset ( s -> last_picture_ptr -> f . data [ 1 ] , 0x80 , ( avctx -> height >> v_chroma_shift ) * s -> last_picture_ptr -> f . linesize [ 1 ] ) ;\n memset ( s -> last_picture_ptr -> f . data [ 2 ] , 0x80 , ( avctx -> height >> v_chroma_shift ) * s -> last_picture_ptr -> f . linesize [ 2 ] ) ;\n ff_thread_report_progress ( & s -> last_picture_ptr -> tf , INT_MAX , 0 ) ;\n ff_thread_report_progress ( & s -> last_picture_ptr -> tf , INT_MAX , 1 ) ;\n }\n if ( ( s -> next_picture_ptr == NULL || s -> next_picture_ptr -> f . data [ 0 ] == NULL ) && s -> pict_type == AV_PICTURE_TYPE_B ) {\n i = ff_find_unused_picture ( s , 0 ) ;\n if ( i < 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"no frame buffer available\\n\" ) ;\n return i ;\n }\n s -> next_picture_ptr = & s -> picture [ i ] ;\n if ( ff_alloc_picture ( s , s -> next_picture_ptr , 0 ) < 0 ) {\n s -> next_picture_ptr = NULL ;\n return - 1 ;\n }\n ff_thread_report_progress ( & s -> next_picture_ptr -> tf , INT_MAX , 0 ) ;\n ff_thread_report_progress ( & s -> next_picture_ptr -> tf , INT_MAX , 1 ) ;\n }\n }\n if ( s -> codec_id != AV_CODEC_ID_H264 ) {\n if ( s -> last_picture_ptr ) {\n ff_mpeg_unref_picture ( s , & s -> last_picture ) ;\n if ( s -> last_picture_ptr -> f . data [ 0 ] && ( ret = ff_mpeg_ref_picture ( s , & s -> last_picture , s -> last_picture_ptr ) ) < 0 ) return ret ;\n }\n if ( s -> next_picture_ptr ) {\n ff_mpeg_unref_picture ( s , & s -> next_picture ) ;\n if ( s -> next_picture_ptr -> f . data [ 0 ] && ( ret = ff_mpeg_ref_picture ( s , & s -> next_picture , s -> next_picture_ptr ) ) < 0 ) return ret ;\n }\n assert ( s -> pict_type == AV_PICTURE_TYPE_I || ( s -> last_picture_ptr && s -> last_picture_ptr -> f . data [ 0 ] ) ) ;\n }\n if ( s -> picture_structure != PICT_FRAME && s -> out_format != FMT_H264 ) {\n int i ;\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n if ( s -> picture_structure == PICT_BOTTOM_FIELD ) {\n s -> current_picture . f . data [ i ] += s -> current_picture . f . linesize [ i ] ;\n }\n s -> current_picture . f . linesize [ i ] *= 2 ;\n s -> last_picture . f . linesize [ i ] *= 2 ;\n s -> next_picture . f . linesize [ i ] *= 2 ;\n }\n }\n s -> err_recognition = avctx -> err_recognition ;\n if ( s -> mpeg_quant || s -> codec_id == AV_CODEC_ID_MPEG2VIDEO ) {\n s -> dct_unquantize_intra = s -> dct_unquantize_mpeg2_intra ;\n s -> dct_unquantize_inter = s -> dct_unquantize_mpeg2_inter ;\n }\n else if ( s -> out_format == FMT_H263 || s -> out_format == FMT_H261 ) {\n s -> dct_unquantize_intra = s -> dct_unquantize_h263_intra ;\n s -> dct_unquantize_inter = s -> dct_unquantize_h263_inter ;\n }\n else {\n s -> dct_unquantize_intra = s -> dct_unquantize_mpeg1_intra ;\n s -> dct_unquantize_inter = s -> dct_unquantize_mpeg1_inter ;\n }\n if ( s -> dct_error_sum ) {\n assert ( s -> avctx -> noise_reduction && s -> encoding ) ;\n update_noise_reduction ( s ) ;\n }\n if ( CONFIG_MPEG_XVMC_DECODER && s -> avctx -> xvmc_acceleration ) return ff_xvmc_field_start ( s , avctx ) ;\n return 0 ;\n }","target":0,"code_token_length":2115,"total_token_length":2351,"max_tokens_setting":4096}
+{"idx":9250,"func":"void CL_Init( void ) {\n\tCom_Printf( \"----- Client Initialization -----\\n\" );\n\n\tCon_Init();\n\n\tif(!com_fullyInitialized)\n\t{\n\t\tCL_ClearState();\n\t\tclc.state = CA_DISCONNECTED;\t\/\/ no longer CA_UNINITIALIZED\n\t\tcl_oldGameSet = qfalse;\n\t}\n\n\tcls.realtime = 0;\n\n\tCL_InitInput();\n\n\tcl_noprint = Cvar_Get( \"cl_noprint\", \"0\", 0 );\n#ifdef UPDATE_SERVER_NAME\n\tcl_motd = Cvar_Get( \"cl_motd\", \"1\", 0 );\n#endif\n\tcl_autoupdate = Cvar_Get( \"cl_autoupdate\", \"0\", CVAR_ARCHIVE );\n\n\tcl_timeout = Cvar_Get( \"cl_timeout\", \"200\", 0 );\n\n\tcl_wavefilerecord = Cvar_Get( \"cl_wavefilerecord\", \"0\", CVAR_TEMP );\n\n\tcl_timeNudge = Cvar_Get( \"cl_timeNudge\", \"0\", CVAR_TEMP );\n\tcl_shownet = Cvar_Get( \"cl_shownet\", \"0\", CVAR_TEMP );\n\tcl_shownuments = Cvar_Get( \"cl_shownuments\", \"0\", CVAR_TEMP );\n\tcl_visibleClients = Cvar_Get( \"cl_visibleClients\", \"0\", CVAR_TEMP );\n\tcl_showServerCommands = Cvar_Get( \"cl_showServerCommands\", \"0\", 0 );\n\tcl_showSend = Cvar_Get( \"cl_showSend\", \"0\", CVAR_TEMP );\n\tcl_showTimeDelta = Cvar_Get( \"cl_showTimeDelta\", \"0\", CVAR_TEMP );\n\tcl_freezeDemo = Cvar_Get( \"cl_freezeDemo\", \"0\", CVAR_TEMP );\n\trcon_client_password = Cvar_Get( \"rconPassword\", \"\", CVAR_TEMP );\n\tcl_activeAction = Cvar_Get( \"activeAction\", \"\", CVAR_TEMP );\n\n\tcl_timedemo = Cvar_Get( \"timedemo\", \"0\", 0 );\n\tcl_timedemoLog = Cvar_Get (\"cl_timedemoLog\", \"\", CVAR_ARCHIVE);\n\tcl_autoRecordDemo = Cvar_Get (\"cl_autoRecordDemo\", \"0\", CVAR_ARCHIVE);\n\tcl_aviFrameRate = Cvar_Get (\"cl_aviFrameRate\", \"25\", CVAR_ARCHIVE);\n\tcl_aviMotionJpeg = Cvar_Get (\"cl_aviMotionJpeg\", \"1\", CVAR_ARCHIVE);\n\tcl_avidemo = Cvar_Get( \"cl_avidemo\", \"0\", 0 );\n\tcl_forceavidemo = Cvar_Get( \"cl_forceavidemo\", \"0\", 0 );\n\n\trconAddress = Cvar_Get( \"rconAddress\", \"\", 0 );\n\n\tcl_yawspeed = Cvar_Get( \"cl_yawspeed\", \"140\", CVAR_ARCHIVE );\n\tcl_pitchspeed = Cvar_Get( \"cl_pitchspeed\", \"140\", CVAR_ARCHIVE );\n\tcl_anglespeedkey = Cvar_Get( \"cl_anglespeedkey\", \"1.5\", 0 );\n\n\tcl_maxpackets = Cvar_Get( \"cl_maxpackets\", \"38\", CVAR_ARCHIVE );\n\tcl_packetdup = Cvar_Get( \"cl_packetdup\", \"1\", CVAR_ARCHIVE );\n\n\tcl_showPing = Cvar_Get( \"cl_showPing\", \"0\", CVAR_ARCHIVE );\n\n\tcl_run = Cvar_Get( \"cl_run\", \"1\", CVAR_ARCHIVE );\n\tcl_sensitivity = Cvar_Get( \"sensitivity\", \"5\", CVAR_ARCHIVE );\n\tcl_mouseAccel = Cvar_Get( \"cl_mouseAccel\", \"0\", CVAR_ARCHIVE );\n\tcl_freelook = Cvar_Get( \"cl_freelook\", \"1\", CVAR_ARCHIVE );\n\n\tcl_mouseAccelStyle = Cvar_Get( \"cl_mouseAccelStyle\", \"0\", CVAR_ARCHIVE );\n\tcl_mouseAccelOffset = Cvar_Get( \"cl_mouseAccelOffset\", \"5\", CVAR_ARCHIVE );\n\tCvar_CheckRange(cl_mouseAccelOffset, 0.001f, 50000.0f, qfalse);\n\n\tcl_showMouseRate = Cvar_Get( \"cl_showmouserate\", \"0\", 0 );\n \n \tcl_allowDownload = Cvar_Get( \"cl_allowDownload\", \"1\", CVAR_ARCHIVE );\n #ifdef USE_CURL_DLOPEN\n\tcl_cURLLib = Cvar_Get(\"cl_cURLLib\", DEFAULT_CURL_LIB, CVAR_ARCHIVE);\n #endif\n \n\tCvar_Get( \"cg_autoswitch\", \"0\", CVAR_ARCHIVE );\n\n\tCvar_Get( \"cg_wolfparticles\", \"1\", CVAR_ARCHIVE );\n\n\tcl_conXOffset = Cvar_Get( \"cl_conXOffset\", \"0\", 0 );\n\tcl_inGameVideo = Cvar_Get( \"r_inGameVideo\", \"1\", CVAR_ARCHIVE );\n\n\tcl_serverStatusResendTime = Cvar_Get( \"cl_serverStatusResendTime\", \"750\", 0 );\n\n\tcl_recoilPitch = Cvar_Get( \"cg_recoilPitch\", \"0\", CVAR_ROM );\n\n\tcl_bypassMouseInput = Cvar_Get( \"cl_bypassMouseInput\", \"0\", 0 ); \/\/CVAR_ROM );\t\t\t\/\/ NERVE - SMF\n\n\tm_pitch = Cvar_Get( \"m_pitch\", \"0.022\", CVAR_ARCHIVE );\n\tm_yaw = Cvar_Get( \"m_yaw\", \"0.022\", CVAR_ARCHIVE );\n\tm_forward = Cvar_Get( \"m_forward\", \"0.25\", CVAR_ARCHIVE );\n\tm_side = Cvar_Get( \"m_side\", \"0.25\", CVAR_ARCHIVE );\n\tm_filter = Cvar_Get( \"m_filter\", \"0\", CVAR_ARCHIVE );\n\n\tj_pitch =        Cvar_Get (\"j_pitch\",        \"0.022\", CVAR_ARCHIVE);\n\tj_yaw =          Cvar_Get (\"j_yaw\",          \"-0.022\", CVAR_ARCHIVE);\n\tj_forward =      Cvar_Get (\"j_forward\",      \"-0.25\", CVAR_ARCHIVE);\n\tj_side =         Cvar_Get (\"j_side\",         \"0.25\", CVAR_ARCHIVE);\n\tj_up =           Cvar_Get (\"j_up\",           \"0\", CVAR_ARCHIVE);\n\n\tj_pitch_axis =   Cvar_Get (\"j_pitch_axis\",   \"3\", CVAR_ARCHIVE);\n\tj_yaw_axis =     Cvar_Get (\"j_yaw_axis\",     \"2\", CVAR_ARCHIVE);\n\tj_forward_axis = Cvar_Get (\"j_forward_axis\", \"1\", CVAR_ARCHIVE);\n\tj_side_axis =    Cvar_Get (\"j_side_axis\",    \"0\", CVAR_ARCHIVE);\n\tj_up_axis =      Cvar_Get (\"j_up_axis\",      \"4\", CVAR_ARCHIVE);\n\n\tCvar_CheckRange(j_pitch_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue);\n\tCvar_CheckRange(j_yaw_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue);\n\tCvar_CheckRange(j_forward_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue);\n\tCvar_CheckRange(j_side_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue);\n\tCvar_CheckRange(j_up_axis, 0, MAX_JOYSTICK_AXIS-1, qtrue);\n\n\tcl_motdString = Cvar_Get( \"cl_motdString\", \"\", CVAR_ROM );\n\n\tCvar_Get( \"cl_maxPing\", \"800\", CVAR_ARCHIVE );\n\n\tcl_lanForcePackets = Cvar_Get (\"cl_lanForcePackets\", \"1\", CVAR_ARCHIVE);\n\n\tcl_guid = Cvar_Get( \"cl_guid\", \"unknown\", CVAR_USERINFO | CVAR_ROM );\n\n\tcl_guidServerUniq = Cvar_Get (\"cl_guidServerUniq\", \"1\", CVAR_ARCHIVE);\n\n\tcl_consoleKeys = Cvar_Get( \"cl_consoleKeys\", \"~ ` 0x7e 0x60\", CVAR_ARCHIVE);\n\n\tCvar_Get( \"cg_drawCompass\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_drawNotifyText\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_quickMessageAlt\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_popupLimboMenu\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_descriptiveText\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_drawTeamOverlay\", \"2\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_uselessNostalgia\", \"0\", CVAR_ARCHIVE ); \/\/ JPW NERVE\n\tCvar_Get( \"cg_drawGun\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_cursorHints\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_voiceSpriteTime\", \"6000\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_teamChatsOnly\", \"0\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_noVoiceChats\", \"0\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_noVoiceText\", \"0\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_crosshairSize\", \"48\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_drawCrosshair\", \"1\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_zoomDefaultSniper\", \"20\", CVAR_ARCHIVE );\n\tCvar_Get( \"cg_zoomstepsniper\", \"2\", CVAR_ARCHIVE );\n\n\tCvar_Get( \"mp_playerType\", \"0\", 0 );\n\tCvar_Get( \"mp_currentPlayerType\", \"0\", 0 );\n\tCvar_Get( \"mp_weapon\", \"0\", 0 );\n\tCvar_Get( \"mp_team\", \"0\", 0 );\n\tCvar_Get( \"mp_currentTeam\", \"0\", 0 );\n\n\tCvar_Get( \"name\", \"WolfPlayer\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tcl_rate = Cvar_Get( \"rate\", \"25000\", CVAR_USERINFO | CVAR_ARCHIVE );     \/\/ NERVE - SMF - changed from 3000\n\tCvar_Get( \"snaps\", \"20\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get( \"model\", \"multi\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get( \"head\", \"default\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get( \"color\", \"4\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get( \"handicap\", \"100\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get( \"sex\", \"male\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get( \"cl_anonymous\", \"0\", CVAR_USERINFO | CVAR_ARCHIVE );\n\n\tCvar_Get( \"password\", \"\", CVAR_USERINFO );\n\tCvar_Get( \"cg_predictItems\", \"1\", CVAR_USERINFO | CVAR_ARCHIVE );\n\n#ifdef USE_MUMBLE\n\tcl_useMumble = Cvar_Get (\"cl_useMumble\", \"0\", CVAR_ARCHIVE | CVAR_LATCH);\n\tcl_mumbleScale = Cvar_Get (\"cl_mumbleScale\", \"0.0254\", CVAR_ARCHIVE);\n#endif\n\n#ifdef USE_VOIP\n\tcl_voipSend = Cvar_Get (\"cl_voipSend\", \"0\", 0);\n\tcl_voipSendTarget = Cvar_Get (\"cl_voipSendTarget\", \"spatial\", 0);\n\tcl_voipGainDuringCapture = Cvar_Get (\"cl_voipGainDuringCapture\", \"0.2\", CVAR_ARCHIVE);\n\tcl_voipCaptureMult = Cvar_Get (\"cl_voipCaptureMult\", \"2.0\", CVAR_ARCHIVE);\n\tcl_voipUseVAD = Cvar_Get (\"cl_voipUseVAD\", \"0\", CVAR_ARCHIVE);\n\tcl_voipVADThreshold = Cvar_Get (\"cl_voipVADThreshold\", \"0.25\", CVAR_ARCHIVE);\n\tcl_voipShowMeter = Cvar_Get (\"cl_voipShowMeter\", \"1\", CVAR_ARCHIVE);\n\n\tcl_voip = Cvar_Get (\"cl_voip\", \"1\", CVAR_ARCHIVE);\n\tCvar_CheckRange( cl_voip, 0, 1, qtrue );\n\tcl_voipProtocol = Cvar_Get (\"cl_voipProtocol\", cl_voip->integer ? \"opus\" : \"\", CVAR_USERINFO | CVAR_ROM);\n#endif\n\n\tCvar_Get( \"cg_autoactivate\", \"1\", CVAR_USERINFO | CVAR_ARCHIVE );\n\n\tCvar_Get( \"cg_viewsize\", \"100\", CVAR_ARCHIVE );\n\tCvar_Get (\"cg_stereoSeparation\", \"0\", CVAR_ROM);\n\n\tCvar_Get( \"cg_autoReload\", \"1\", CVAR_ARCHIVE | CVAR_USERINFO );\n\n\tcl_missionStats = Cvar_Get( \"g_missionStats\", \"0\", CVAR_ROM );\n\tcl_waitForFire = Cvar_Get( \"cl_waitForFire\", \"0\", CVAR_ROM );\n\n\tcl_language = Cvar_Get( \"cl_language\", \"0\", CVAR_ARCHIVE );\n\tcl_debugTranslation = Cvar_Get( \"cl_debugTranslation\", \"0\", 0 );\n\n\tcl_updateavailable = Cvar_Get( \"cl_updateavailable\", \"0\", CVAR_ROM );\n\tcl_updatefiles = Cvar_Get( \"cl_updatefiles\", \"\", CVAR_ROM );\n\n\tQ_strncpyz( cls.autoupdateServerNames[0], AUTOUPDATE_SERVER1_NAME, MAX_QPATH );\n\tQ_strncpyz( cls.autoupdateServerNames[1], AUTOUPDATE_SERVER2_NAME, MAX_QPATH );\n\tQ_strncpyz( cls.autoupdateServerNames[2], AUTOUPDATE_SERVER3_NAME, MAX_QPATH );\n\tQ_strncpyz( cls.autoupdateServerNames[3], AUTOUPDATE_SERVER4_NAME, MAX_QPATH );\n\tQ_strncpyz( cls.autoupdateServerNames[4], AUTOUPDATE_SERVER5_NAME, MAX_QPATH );\n\n\tCmd_AddCommand( \"cmd\", CL_ForwardToServer_f );\n\tCmd_AddCommand( \"configstrings\", CL_Configstrings_f );\n\tCmd_AddCommand( \"clientinfo\", CL_Clientinfo_f );\n\tCmd_AddCommand( \"snd_restart\", CL_Snd_Restart_f );\n\tCmd_AddCommand( \"vid_restart\", CL_Vid_Restart_f );\n\tCmd_AddCommand( \"ui_restart\", CL_UI_Restart_f );          \/\/ NERVE - SMF\n\tCmd_AddCommand( \"disconnect\", CL_Disconnect_f );\n\tCmd_AddCommand( \"record\", CL_Record_f );\n\tCmd_AddCommand( \"demo\", CL_PlayDemo_f );\n\tCmd_SetCommandCompletionFunc( \"demo\", CL_CompleteDemoName );\n\tCmd_AddCommand( \"cinematic\", CL_PlayCinematic_f );\n\tCmd_AddCommand( \"stoprecord\", CL_StopRecord_f );\n\tCmd_AddCommand( \"connect\", CL_Connect_f );\n\tCmd_AddCommand( \"reconnect\", CL_Reconnect_f );\n\tCmd_AddCommand( \"localservers\", CL_LocalServers_f );\n\tCmd_AddCommand( \"globalservers\", CL_GlobalServers_f );\n\tCmd_AddCommand( \"rcon\", CL_Rcon_f );\n\tCmd_SetCommandCompletionFunc( \"rcon\", CL_CompleteRcon );\n\tCmd_AddCommand( \"ping\", CL_Ping_f );\n\tCmd_AddCommand( \"serverstatus\", CL_ServerStatus_f );\n\tCmd_AddCommand( \"showip\", CL_ShowIP_f );\n\tCmd_AddCommand( \"fs_openedList\", CL_OpenedPK3List_f );\n\tCmd_AddCommand( \"fs_referencedList\", CL_ReferencedPK3List_f );\n\tCmd_AddCommand (\"video\", CL_Video_f );\n\tCmd_AddCommand (\"stopvideo\", CL_StopVideo_f );\n\n\tCmd_AddCommand( \"cache_startgather\", CL_Cache_StartGather_f );\n\tCmd_AddCommand( \"cache_usedfile\", CL_Cache_UsedFile_f );\n\tCmd_AddCommand( \"cache_setindex\", CL_Cache_SetIndex_f );\n\tCmd_AddCommand( \"cache_mapchange\", CL_Cache_MapChange_f );\n\tCmd_AddCommand( \"cache_endgather\", CL_Cache_EndGather_f );\n\n\tCmd_AddCommand( \"updatehunkusage\", CL_UpdateLevelHunkUsage );\n\tCmd_AddCommand( \"updatescreen\", SCR_UpdateScreen );\n\tCmd_AddCommand( \"SaveTranslations\", CL_SaveTranslations_f );     \/\/ NERVE - SMF - localization\n\tCmd_AddCommand( \"SaveNewTranslations\", CL_SaveNewTranslations_f );   \/\/ NERVE - SMF - localization\n\tCmd_AddCommand( \"LoadTranslations\", CL_LoadTranslations_f );     \/\/ NERVE - SMF - localization\n\n\tCmd_AddCommand( \"startSingleplayer\", CL_startSingleplayer_f );      \/\/ NERVE - SMF\n\n\tCmd_AddCommand( \"setRecommended\", CL_SetRecommended_f );\n\n\tCL_InitRef();\n\n\tSCR_Init();\n\n\n\tCvar_Set( \"cl_running\", \"1\" );\n\n\tautoupdateChecked = qfalse;\n\tautoupdateStarted = qfalse;\n\n\tCL_InitTranslation();   \/\/ NERVE - SMF - localization\n\n\tCL_GenerateQKey();\n\tCL_UpdateGUID( NULL, 0 );\n\n\tCom_Printf( \"----- Client Initialization Complete -----\\n\" );\n}\n","target":1,"code_token_length":3615,"total_token_length":3851,"max_tokens_setting":4096}
+{"idx":255603,"func":"int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,\n              rpmpsm psm, char ** failedFile)\n{\n    FD_t payload = rpmtePayload(te);\n    rpmfi fi = NULL;\n    rpmfs fs = rpmteGetFileStates(te);\n    rpmPlugins plugins = rpmtsPlugins(ts);\n    int rc = 0;\n    int fx = -1;\n    int fc = rpmfilesFC(files);\n    int nodigest = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOFILEDIGEST) ? 1 : 0;\n    int nofcaps = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCAPS) ? 1 : 0;\n    FD_t firstlinkfile = NULL;\n    char *tid = NULL;\n    struct filedata_s *fdata = xcalloc(fc, sizeof(*fdata));\n    struct filedata_s *firstlink = NULL;\n\n    \/* transaction id used for temporary path suffix while installing *\/\n    rasprintf(&tid, \";%08x\", (unsigned)rpmtsGetTid(ts));\n\n    \/* Collect state data for the whole operation *\/\n    fi = rpmfilesIter(files, RPMFI_ITER_FWD);\n    while (!rc && (fx = rpmfiNext(fi)) >= 0) {\n\tstruct filedata_s *fp = &fdata[fx];\n\tif (rpmfiFFlags(fi) & RPMFILE_GHOST)\n            fp->action = FA_SKIP;\n\telse\n\t    fp->action = rpmfsGetAction(fs, fx);\n\tfp->skip = XFA_SKIPPING(fp->action);\n\tfp->setmeta = 1;\n\tif (XFA_CREATING(fp->action) && !S_ISDIR(rpmfiFMode(fi)))\n\t    fp->suffix = tid;\n\tfp->fpath = fsmFsPath(fi, fp->suffix);\n\n\t\/* Remap file perms, owner, and group. *\/\n\trc = rpmfiStat(fi, 1, &fp->sb);\n\n\tsetFileState(fs, fx);\n\tfsmDebug(fp->fpath, fp->action, &fp->sb);\n\n\t\/* Run fsm file pre hook for all plugins *\/\n\trc = rpmpluginsCallFsmFilePre(plugins, fi, fp->fpath,\n\t\t\t\t      fp->sb.st_mode, fp->action);\n\tfp->stage = FILE_PRE;\n    }\n    fi = rpmfiFree(fi);\n\n    if (rc)\n\tgoto exit;\n\n    if (rpmteType(te) == TR_ADDED)\n\tfi = rpmfiNewArchiveReader(payload, files, RPMFI_ITER_READ_ARCHIVE);\n    else\n\tfi = rpmfilesIter(files, RPMFI_ITER_FWD);\n    if (fi == NULL) {\n        rc = RPMERR_BAD_MAGIC;\n        goto exit;\n    }\n\n    \/* Detect and create directories not explicitly in package. *\/\n    if (!rc)\n\trc = fsmMkdirs(files, fs, plugins);\n\n    \/* Process the payload *\/\n    while (!rc && (fx = rpmfiNext(fi)) >= 0) {\n\tstruct filedata_s *fp = &fdata[fx];\n\n        if (!fp->skip) {\n\t    \/* Directories replacing something need early backup *\/\n\t    if (!fp->suffix) {\n\t\trc = fsmBackup(fi, fp->action);\n\t    }\n\t    \/* Assume file does't exist when tmp suffix is in use *\/\n\t    if (!fp->suffix) {\n\t\tif (fp->action == FA_TOUCH) {\n\t\t    struct stat sb;\n\t\t    rc = fsmStat(fp->fpath, 1, &sb);\n\t\t} else {\n\t\t    rc = fsmVerify(fp->fpath, fi);\n\t\t}\n\t    } else {\n\t\trc = RPMERR_ENOENT;\n\t    }\n\n\t    \/* See if the file was removed while our attention was elsewhere *\/\n\t    if (rc == RPMERR_ENOENT && fp->action == FA_TOUCH) {\n\t\trpmlog(RPMLOG_DEBUG, \"file %s vanished unexpectedly\\n\",\n\t\t\tfp->fpath);\n\t\tfp->action = FA_CREATE;\n\t\tfsmDebug(fp->fpath, fp->action, &fp->sb);\n\t    }\n\n\t    \/* When touching we don't need any of this... *\/\n\t    if (fp->action == FA_TOUCH)\n\t\tcontinue;\n\n            if (S_ISREG(fp->sb.st_mode)) {\n\t\tif (rc == RPMERR_ENOENT) {\n\t\t    rc = fsmMkfile(fi, fp, files, psm, nodigest,\n\t\t\t\t   &firstlink, &firstlinkfile);\n\t\t}\n            } else if (S_ISDIR(fp->sb.st_mode)) {\n                if (rc == RPMERR_ENOENT) {\n                    mode_t mode = fp->sb.st_mode;\n                    mode &= ~07777;\n                    mode |=  00700;\n                    rc = fsmMkdir(fp->fpath, mode);\n                }\n            } else if (S_ISLNK(fp->sb.st_mode)) {\n\t\tif (rc == RPMERR_ENOENT) {\n\t\t    rc = fsmSymlink(rpmfiFLink(fi), fp->fpath);\n\t\t}\n            } else if (S_ISFIFO(fp->sb.st_mode)) {\n                \/* This mimics cpio S_ISSOCK() behavior but probably isn't right *\/\n                if (rc == RPMERR_ENOENT) {\n                    rc = fsmMkfifo(fp->fpath, 0000);\n                }\n            } else if (S_ISCHR(fp->sb.st_mode) ||\n                       S_ISBLK(fp->sb.st_mode) ||\n                       S_ISSOCK(fp->sb.st_mode))\n            {\n                if (rc == RPMERR_ENOENT) {\n                    rc = fsmMknod(fp->fpath, fp->sb.st_mode, fp->sb.st_rdev);\n                }\n            } else {\n                \/* XXX Special case \/dev\/log, which shouldn't be packaged anyways *\/\n                if (!IS_DEV_LOG(fp->fpath))\n                    rc = RPMERR_UNKNOWN_FILETYPE;\n            }\n\t} else if (firstlink && rpmfiArchiveHasContent(fi)) {\n\t    \/*\n\t     * Tricksy case: this file is a being skipped, but it's part of\n\t     * a hardlinked set and has the actual content linked with it.\n\t     * Write the content to the first non-skipped file of the set\n\t     * instead.\n\t     *\/\n\t    rc = fsmMkfile(fi, firstlink, files, psm, nodigest,\n\t\t\t   &firstlink, &firstlinkfile);\n\t}\n\n\t\/* Notify on success. *\/\n\tif (rc)\n\t    *failedFile = xstrdup(fp->fpath);\n\telse\n\t    rpmpsmNotify(psm, RPMCALLBACK_INST_PROGRESS, rpmfiArchiveTell(fi));\n\tfp->stage = FILE_UNPACK;\n    }\n    fi = rpmfiFree(fi);\n\n    if (!rc && fx < 0 && fx != RPMERR_ITER_END)\n\trc = fx;\n\n    \/* Set permissions, timestamps etc for non-hardlink entries *\/\n    fi = rpmfilesIter(files, RPMFI_ITER_FWD);\n    while (!rc && (fx = rpmfiNext(fi)) >= 0) {\n\tstruct filedata_s *fp = &fdata[fx];\n\tif (!fp->skip && fp->setmeta) {\n\t    rc = fsmSetmeta(fp->fpath, fi, plugins, fp->action,\n\t\t\t    &fp->sb, nofcaps);\n\t}\n\tif (rc)\n\t    *failedFile = xstrdup(fp->fpath);\n\tfp->stage = FILE_PREP;\n    }\n    fi = rpmfiFree(fi);\n\n    \/* If all went well, commit files to final destination *\/\n    fi = rpmfilesIter(files, RPMFI_ITER_FWD);\n    while (!rc && (fx = rpmfiNext(fi)) >= 0) {\n\tstruct filedata_s *fp = &fdata[fx];\n\n\tif (!fp->skip) {\n\t    \/* Backup file if needed. Directories are handled earlier *\/\n\t    if (!rc && fp->suffix)\n\t\trc = fsmBackup(fi, fp->action);\n\n\t    if (!rc)\n\t\trc = fsmCommit(&fp->fpath, fi, fp->action, fp->suffix);\n\n\t    if (!rc)\n\t\tfp->stage = FILE_COMMIT;\n\t    else\n\t\t*failedFile = xstrdup(fp->fpath);\n\t}\n    }\n    fi = rpmfiFree(fi);\n\n    \/* Walk backwards in case we need to erase *\/\n    fi = rpmfilesIter(files, RPMFI_ITER_BACK);\n    while ((fx = rpmfiNext(fi)) >= 0) {\n\tstruct filedata_s *fp = &fdata[fx];\n\t\/* Run fsm file post hook for all plugins for all processed files *\/\n\tif (fp->stage) {\n\t    rpmpluginsCallFsmFilePost(plugins, fi, fp->fpath,\n\t\t\t\t      fp->sb.st_mode, fp->action, rc);\n\t}\n\n\t\/* On failure, erase non-committed files *\/\n\tif (rc && fp->stage > FILE_NONE && !fp->skip) {\n\t    (void) fsmRemove(fp->fpath, fp->sb.st_mode);\n\t}\n    }\n\n    rpmswAdd(rpmtsOp(ts, RPMTS_OP_UNCOMPRESS), fdOp(payload, FDSTAT_READ));\n    rpmswAdd(rpmtsOp(ts, RPMTS_OP_DIGEST), fdOp(payload, FDSTAT_DIGEST));\n\nexit:\n    fi = rpmfiFree(fi);\n    Fclose(payload);\n    free(tid);\n    for (int i = 0; i < fc; i++)\n\tfree(fdata[i].fpath);\n    free(fdata);\n\n    return rc;\n}","target":1,"code_token_length":1983,"total_token_length":2219,"max_tokens_setting":4096}
+{"idx":40951,"func":"int ssl_connect(struct tunnel *tunnel)\n{\n\tssl_disconnect(tunnel);\n\n\ttunnel->ssl_socket = tcp_connect(tunnel);\n\tif (tunnel->ssl_socket == -1)\n\t\treturn 1;\n\n\t\/\/ registration is deprecated from OpenSSL 1.1.0 onward\n#if OPENSSL_API_COMPAT < 0x10100000L\n\t\/\/ Register the error strings for libcrypto & libssl\n\tSSL_load_error_strings();\n\t\/\/ Register the available ciphers and digests\n\tSSL_library_init();\n#endif\n\n\ttunnel->ssl_context = SSL_CTX_new(SSLv23_client_method());\n\tif (tunnel->ssl_context == NULL) {\n\t\tlog_error(\"SSL_CTX_new: %s\\n\",\n\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\treturn 1;\n\t}\n\n\t\/\/ Load the OS default CA files\n\tif (!SSL_CTX_set_default_verify_paths(tunnel->ssl_context))\n\t\tlog_error(\"Could not load OS OpenSSL files.\\n\");\n\n\tif (tunnel->config->ca_file) {\n\t\tif (!SSL_CTX_load_verify_locations(\n\t\t            tunnel->ssl_context,\n\t\t            tunnel->config->ca_file, NULL)) {\n\t\t\tlog_error(\"SSL_CTX_load_verify_locations: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\t\/* Use engine for PIV if user-cert config starts with pkcs11 URI: *\/\n\tif (tunnel->config->use_engine > 0) {\n\n\t\tENGINE *e;\n\t\tENGINE_load_builtin_engines();\n\t\te = ENGINE_by_id(\"pkcs11\");\n\t\tif (!e) {\n\t\t\tlog_error(\"Could not load pkcs11 Engine: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\t\tif (!ENGINE_init(e)) {\n\t\t\tlog_error(\"Could not init pkcs11 Engine: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\tENGINE_free(e);\n\t\t\treturn 1;\n\t\t}\n\t\tif (!ENGINE_set_default_RSA(e))\n\t\t\tabort();\n\n\t\tENGINE_finish(e);\n\t\tENGINE_free(e);\n\n\t\tstruct token parms;\n\t\tparms.uri = tunnel->config->user_cert;\n\t\tparms.cert = NULL;\n\n\t\tif (!ENGINE_ctrl_cmd(e, \"LOAD_CERT_CTRL\", 0, &parms, NULL, 1)) {\n\t\t\tlog_error(\"PKCS11 ENGINE_ctrl_cmd: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (!SSL_CTX_use_certificate(tunnel->ssl_context, parms.cert)) {\n\t\t\tlog_error(\"PKCS11 SSL_CTX_use_certificate: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\n\t\tEVP_PKEY * privkey = ENGINE_load_private_key(\n\t\t                             e, parms.uri, UI_OpenSSL(), NULL);\n\t\tif (!privkey) {\n\t\t\tlog_error(\"PKCS11 ENGINE_load_private_key: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (!SSL_CTX_use_PrivateKey(tunnel->ssl_context, privkey)) {\n\t\t\tlog_error(\"PKCS11 SSL_CTX_use_PrivateKey_file: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (!SSL_CTX_check_private_key(tunnel->ssl_context)) {\n\t\t\tlog_error(\"PKCS11 SSL_CTX_check_private_key: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\n\t} else {        \/* end PKCS11-engine *\/\n\n\t\tif (tunnel->config->user_cert) {\n\t\t\tif (!SSL_CTX_use_certificate_file(\n\t\t\t            tunnel->ssl_context, tunnel->config->user_cert,\n\t\t\t            SSL_FILETYPE_PEM)) {\n\t\t\t\tlog_error(\"SSL_CTX_use_certificate_file: %s\\n\",\n\t\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tif (tunnel->config->user_key) {\n\t\t\tif (!SSL_CTX_use_PrivateKey_file(\n\t\t\t            tunnel->ssl_context, tunnel->config->user_key,\n\t\t\t            SSL_FILETYPE_PEM)) {\n\t\t\t\tlog_error(\"SSL_CTX_use_PrivateKey_file: %s\\n\",\n\t\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tif (tunnel->config->user_cert && tunnel->config->user_key) {\n\t\t\tif (!SSL_CTX_check_private_key(tunnel->ssl_context)) {\n\t\t\t\tlog_error(\"SSL_CTX_check_private_key: %s\\n\",\n\t\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!tunnel->config->insecure_ssl) {\n\t\tlong sslctxopt = SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION;\n\t\tlong checkopt;\n\n\t\tcheckopt = SSL_CTX_set_options(tunnel->ssl_context, sslctxopt);\n\t\tif ((checkopt & sslctxopt) != sslctxopt) {\n\t\t\tlog_error(\"SSL_CTX_set_options didn't set opt: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\ttunnel->ssl_handle = SSL_new(tunnel->ssl_context);\n\tif (tunnel->ssl_handle == NULL) {\n\t\tlog_error(\"SSL_new: %s\\n\",\n\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\treturn 1;\n\t}\n\n\tif (!tunnel->config->insecure_ssl) {\n\t\tif (!tunnel->config->cipher_list) {\n\t\t\tconst char *cipher_list;\n\t\t\tif (tunnel->config->seclevel_1)\n\t\t\t\tcipher_list = \"HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4@SECLEVEL=1\";\n\t\t\telse\n\t\t\t\tcipher_list = \"HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4\";\n\t\t\ttunnel->config->cipher_list = strdup(cipher_list);\n\t\t}\n\t} else {\n#if OPENSSL_VERSION_NUMBER >= 0x10100000L\n\t\tif (tunnel->config->min_tls <= 0)\n\t\t\ttunnel->config->min_tls = TLS1_VERSION;\n#endif\n\t\tif (!tunnel->config->cipher_list && tunnel->config->seclevel_1) {\n\t\t\tconst char *cipher_list = \"DEFAULT@SECLEVEL=1\";\n\t\t\ttunnel->config->cipher_list = strdup(cipher_list);\n\t\t}\n\t}\n\n\tif (tunnel->config->cipher_list) {\n\t\tlog_debug(\"Setting cipher list to: %s\\n\", tunnel->config->cipher_list);\n\t\tif (!SSL_set_cipher_list(tunnel->ssl_handle,\n\t\t                         tunnel->config->cipher_list)) {\n\t\t\tlog_error(\"SSL_set_cipher_list failed: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n#if OPENSSL_VERSION_NUMBER >= 0x10100000L\n\tif (tunnel->config->min_tls > 0) {\n\t\tlog_debug(\"Setting min proto version to: 0x%x\\n\",\n\t\t          tunnel->config->min_tls);\n\t\tif (!SSL_set_min_proto_version(tunnel->ssl_handle,\n\t\t                               tunnel->config->min_tls)) {\n\t\t\tlog_error(\"SSL_set_min_proto_version failed: %s\\n\",\n\t\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\t\treturn 1;\n\t\t}\n\t}\n#endif\n\n\tif (!SSL_set_fd(tunnel->ssl_handle, tunnel->ssl_socket)) {\n\t\tlog_error(\"SSL_set_fd: %s\\n\",\n\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\treturn 1;\n\t}\n\tSSL_set_mode(tunnel->ssl_handle, SSL_MODE_AUTO_RETRY);\n\n\t\/\/ Initiate SSL handshake\n\tif (SSL_connect(tunnel->ssl_handle) != 1) {\n\t\tlog_error(\"SSL_connect: %s\\n\"\n\t\t          \"You might want to try --insecure-ssl or specify a different --cipher-list\\n\",\n\t\t          ERR_error_string(ERR_peek_last_error(), NULL));\n\t\treturn 1;\n\t}\n\tSSL_set_mode(tunnel->ssl_handle, SSL_MODE_AUTO_RETRY);\n\n\tif (ssl_verify_cert(tunnel))\n\t\treturn 1;\n\n\t\/\/ Disable SIGPIPE (occurs when trying to write to an already-closed\n\t\/\/ socket).\n\tsignal(SIGPIPE, SIG_IGN);\n\n\treturn 0;\n}","target":0,"code_token_length":1842,"total_token_length":2078,"max_tokens_setting":4096}
+{"idx":105635,"func":"static void ExportGrayQuantum(const Image *image,QuantumInfo *quantum_info,\n  const MagickSizeType number_pixels,const Quantum *magick_restrict p,\n  unsigned char *magick_restrict q,ExceptionInfo *exception)\n{\n  QuantumAny\n    range;\n\n  ssize_t\n    x;\n\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  switch (quantum_info->depth)\n  {\n    case 1:\n    {\n      double\n        threshold;\n\n      unsigned char\n        black,\n        white;\n\n      ssize_t\n        bit;\n\n      black=0x00;\n      white=0x01;\n      if (quantum_info->min_is_white != MagickFalse)\n        {\n          black=0x01;\n          white=0x00;\n        }\n      threshold=QuantumRange\/2.0;\n      for (x=((ssize_t) number_pixels-7); x > 0; x-=8)\n      {\n        *q='\\0';\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 7;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 6;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 5;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 4;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 3;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 2;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 1;\n        p+=GetPixelChannels(image);\n        *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 0;\n        p+=GetPixelChannels(image);\n        q++;\n      }\n      if ((number_pixels % 8) != 0)\n        {\n          *q='\\0';\n          for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)\n          {\n            *q|=(GetPixelLuma(image,p) < threshold ? black : white) << bit;\n            p+=GetPixelChannels(image);\n          }\n          q++;\n        }\n      break;\n    }\n    case 4:\n    {\n      unsigned char\n        pixel;\n\n      for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)\n      {\n        pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));\n        *q=(((pixel >> 4) & 0xf) << 4);\n        p+=GetPixelChannels(image);\n        pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));\n        *q|=pixel >> 4;\n        p+=GetPixelChannels(image);\n        q++;\n      }\n      if ((number_pixels % 2) != 0)\n        {\n          pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));\n          *q=(((pixel >> 4) & 0xf) << 4);\n          p+=GetPixelChannels(image);\n          q++;\n        }\n      break;\n    }\n    case 8:\n    {\n      unsigned char\n        pixel;\n\n      for (x=0; x < (ssize_t) number_pixels; x++)\n      {\n        pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));\n        q=PopCharPixel(pixel,q);\n        p+=GetPixelChannels(image);\n        q+=quantum_info->pad;\n      }\n      break;\n    }\n    case 10:\n    {\n      range=GetQuantumRange(quantum_info->depth);\n      if (quantum_info->pack == MagickFalse)\n        {\n          unsigned int\n            pixel;\n\n          for (x=0; x < (ssize_t) (number_pixels-2); x+=3)\n          {\n            pixel=(unsigned int) (ScaleQuantumToAny(ClampToQuantum(\n              GetPixelLuma(image,p+2*GetPixelChannels(image))),range) << 22 |\n              ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+\n              GetPixelChannels(image))),range) << 12 | ScaleQuantumToAny(\n              ClampToQuantum(GetPixelLuma(image,p)),range) << 2);\n            q=PopLongPixel(quantum_info->endian,pixel,q);\n            p+=3*GetPixelChannels(image);\n            q+=quantum_info->pad;\n          }\n          if (x < (ssize_t) number_pixels)\n            {\n              pixel=0U;\n              if (x++ < (ssize_t) (number_pixels-1))\n                pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+\n                  GetPixelChannels(image))),range) << 12;\n              if (x++ < (ssize_t) number_pixels)\n                pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p)),\n                  range) << 2;\n              q=PopLongPixel(quantum_info->endian,pixel,q);\n            }\n          break;\n        }\n      for (x=0; x < (ssize_t) number_pixels; x++)\n      {\n        q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(\n          GetPixelLuma(image,p)),range),q);\n        p+=GetPixelChannels(image);\n        q+=quantum_info->pad;\n      }\n      break;\n    }\n    case 12:\n    {\n      unsigned short\n        pixel;\n\n      range=GetQuantumRange(quantum_info->depth);\n      if (quantum_info->pack == MagickFalse)\n        {\n          for (x=0; x < (ssize_t) number_pixels; x++)\n          {\n            pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));\n            q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel >> 4),\n              q);\n            p+=GetPixelChannels(image);\n            q+=quantum_info->pad;\n          }\n          break;\n        }\n      for (x=0; x < (ssize_t) number_pixels; x++)\n      {\n        q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(\n          GetPixelLuma(image,p)),range),q);\n        p+=GetPixelChannels(image);\n        q+=quantum_info->pad;\n      }\n      break;\n    }\n    case 16:\n    {\n      unsigned short\n        pixel;\n\n      if (quantum_info->format == FloatingPointQuantumFormat)\n        {\n          for (x=0; x < (ssize_t) number_pixels; x++)\n          {\n            pixel=SinglePrecisionToHalf(QuantumScale*GetPixelLuma(image,p));\n            q=PopShortPixel(quantum_info->endian,pixel,q);\n            p+=GetPixelChannels(image);\n            q+=quantum_info->pad;\n          }\n          break;\n        }\n      for (x=0; x < (ssize_t) number_pixels; x++)\n      {\n        pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));\n        q=PopShortPixel(quantum_info->endian,pixel,q);\n        p+=GetPixelChannels(image);\n        q+=quantum_info->pad;\n      }\n      break;\n    }\n    case 32:\n    {\n      unsigned int\n        pixel;\n\n      if (quantum_info->format == FloatingPointQuantumFormat)\n        {\n          for (x=0; x < (ssize_t) number_pixels; x++)\n          {\n            float\n              float_pixel;\n\n            float_pixel=(float) GetPixelLuma(image,p);\n            q=PopFloatPixel(quantum_info,float_pixel,q);\n            p+=GetPixelChannels(image);\n            q+=quantum_info->pad;\n          }\n          break;\n        }\n      for (x=0; x < (ssize_t) number_pixels; x++)\n      {\n        pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p)));\n        q=PopLongPixel(quantum_info->endian,pixel,q);\n        p+=GetPixelChannels(image);\n        q+=quantum_info->pad;\n      }\n      break;\n    }\n    case 64:\n    {\n      if (quantum_info->format == FloatingPointQuantumFormat)\n        {\n          for (x=0; x < (ssize_t) number_pixels; x++)\n          {\n            double\n              pixel;\n\n            pixel=GetPixelLuma(image,p);\n            q=PopDoublePixel(quantum_info,pixel,q);\n            p+=GetPixelChannels(image);\n            q+=quantum_info->pad;\n          }\n          break;\n        }\n    }\n    default:\n    {\n      range=GetQuantumRange(quantum_info->depth);\n      for (x=0; x < (ssize_t) number_pixels; x++)\n      {\n        q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(\n          GetPixelLuma(image,p)),range),q);\n        p+=GetPixelChannels(image);\n        q+=quantum_info->pad;\n      }\n      break;\n    }\n  }\n}","target":0,"code_token_length":2056,"total_token_length":2292,"max_tokens_setting":4096}
+{"idx":305778,"func":"schannel_recv(struct Curl_easy *data, int sockindex,\n              char *buf, size_t len, CURLcode *err)\n{\n  size_t size = 0;\n  ssize_t nread = -1;\n  struct connectdata *conn = data->conn;\n  struct ssl_connect_data *connssl = &conn->ssl[sockindex];\n  unsigned char *reallocated_buffer;\n  size_t reallocated_length;\n  bool done = FALSE;\n  SecBuffer inbuf[4];\n  SecBufferDesc inbuf_desc;\n  SECURITY_STATUS sspi_status = SEC_E_OK;\n  \/* we want the length of the encrypted buffer to be at least large enough\n     that it can hold all the bytes requested and some TLS record overhead. *\/\n  size_t min_encdata_length = len + CURL_SCHANNEL_BUFFER_FREE_SIZE;\n\n  \/****************************************************************************\n   * Don't return or set BACKEND->recv_unrecoverable_err unless in the cleanup.\n   * The pattern for return error is set *err, optional infof, goto cleanup.\n   *\n   * Our priority is to always return as much decrypted data to the caller as\n   * possible, even if an error occurs. The state of the decrypted buffer must\n   * always be valid. Transfer of decrypted data to the caller's buffer is\n   * handled in the cleanup.\n   *\/\n\n  DEBUGF(infof(data, \"schannel: client wants to read %zu bytes\\n\", len));\n  *err = CURLE_OK;\n\n  if(len && len <= BACKEND->decdata_offset) {\n    infof(data, \"schannel: enough decrypted data is already available\\n\");\n    goto cleanup;\n  }\n  else if(BACKEND->recv_unrecoverable_err) {\n    *err = BACKEND->recv_unrecoverable_err;\n    infof(data, \"schannel: an unrecoverable error occurred in a prior call\\n\");\n    goto cleanup;\n  }\n  else if(BACKEND->recv_sspi_close_notify) {\n    \/* once a server has indicated shutdown there is no more encrypted data *\/\n    infof(data, \"schannel: server indicated shutdown in a prior call\\n\");\n    goto cleanup;\n  }\n\n  \/* It's debatable what to return when !len. Regardless we can't return\n     immediately because there may be data to decrypt (in the case we want to\n     decrypt all encrypted cached data) so handle !len later in cleanup.\n  *\/\n  else if(len && !BACKEND->recv_connection_closed) {\n    \/* increase enc buffer in order to fit the requested amount of data *\/\n    size = BACKEND->encdata_length - BACKEND->encdata_offset;\n    if(size < CURL_SCHANNEL_BUFFER_FREE_SIZE ||\n       BACKEND->encdata_length < min_encdata_length) {\n      reallocated_length = BACKEND->encdata_offset +\n        CURL_SCHANNEL_BUFFER_FREE_SIZE;\n      if(reallocated_length < min_encdata_length) {\n        reallocated_length = min_encdata_length;\n      }\n      reallocated_buffer = realloc(BACKEND->encdata_buffer,\n                                   reallocated_length);\n      if(!reallocated_buffer) {\n        *err = CURLE_OUT_OF_MEMORY;\n        failf(data, \"schannel: unable to re-allocate memory\");\n        goto cleanup;\n      }\n\n      BACKEND->encdata_buffer = reallocated_buffer;\n      BACKEND->encdata_length = reallocated_length;\n      size = BACKEND->encdata_length - BACKEND->encdata_offset;\n      DEBUGF(infof(data, \"schannel: encdata_buffer resized %zu\\n\",\n                   BACKEND->encdata_length));\n    }\n\n    DEBUGF(infof(data,\n                 \"schannel: encrypted data buffer: offset %zu length %zu\\n\",\n                 BACKEND->encdata_offset, BACKEND->encdata_length));\n\n    \/* read encrypted data from socket *\/\n    *err = Curl_read_plain(conn->sock[sockindex],\n                           (char *)(BACKEND->encdata_buffer +\n                                    BACKEND->encdata_offset),\n                           size, &nread);\n    if(*err) {\n      nread = -1;\n      if(*err == CURLE_AGAIN)\n        DEBUGF(infof(data,\n                     \"schannel: Curl_read_plain returned CURLE_AGAIN\\n\"));\n      else if(*err == CURLE_RECV_ERROR)\n        infof(data, \"schannel: Curl_read_plain returned CURLE_RECV_ERROR\\n\");\n      else\n        infof(data, \"schannel: Curl_read_plain returned error %d\\n\", *err);\n    }\n    else if(nread == 0) {\n      BACKEND->recv_connection_closed = true;\n      DEBUGF(infof(data, \"schannel: server closed the connection\\n\"));\n    }\n    else if(nread > 0) {\n      BACKEND->encdata_offset += (size_t)nread;\n      BACKEND->encdata_is_incomplete = false;\n      DEBUGF(infof(data, \"schannel: encrypted data got %zd\\n\", nread));\n    }\n  }\n\n  DEBUGF(infof(data,\n               \"schannel: encrypted data buffer: offset %zu length %zu\\n\",\n               BACKEND->encdata_offset, BACKEND->encdata_length));\n\n  \/* decrypt loop *\/\n  while(BACKEND->encdata_offset > 0 && sspi_status == SEC_E_OK &&\n        (!len || BACKEND->decdata_offset < len ||\n         BACKEND->recv_connection_closed)) {\n    \/* prepare data buffer for DecryptMessage call *\/\n    InitSecBuffer(&inbuf[0], SECBUFFER_DATA, BACKEND->encdata_buffer,\n                  curlx_uztoul(BACKEND->encdata_offset));\n\n    \/* we need 3 more empty input buffers for possible output *\/\n    InitSecBuffer(&inbuf[1], SECBUFFER_EMPTY, NULL, 0);\n    InitSecBuffer(&inbuf[2], SECBUFFER_EMPTY, NULL, 0);\n    InitSecBuffer(&inbuf[3], SECBUFFER_EMPTY, NULL, 0);\n    InitSecBufferDesc(&inbuf_desc, inbuf, 4);\n\n    \/* https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa375348.aspx\n     *\/\n    sspi_status = s_pSecFn->DecryptMessage(&BACKEND->ctxt->ctxt_handle,\n                                           &inbuf_desc, 0, NULL);\n\n    \/* check if everything went fine (server may want to renegotiate\n       or shutdown the connection context) *\/\n    if(sspi_status == SEC_E_OK || sspi_status == SEC_I_RENEGOTIATE ||\n       sspi_status == SEC_I_CONTEXT_EXPIRED) {\n      \/* check for successfully decrypted data, even before actual\n         renegotiation or shutdown of the connection context *\/\n      if(inbuf[1].BufferType == SECBUFFER_DATA) {\n        DEBUGF(infof(data, \"schannel: decrypted data length: %lu\\n\",\n                     inbuf[1].cbBuffer));\n\n        \/* increase buffer in order to fit the received amount of data *\/\n        size = inbuf[1].cbBuffer > CURL_SCHANNEL_BUFFER_FREE_SIZE ?\n          inbuf[1].cbBuffer : CURL_SCHANNEL_BUFFER_FREE_SIZE;\n        if(BACKEND->decdata_length - BACKEND->decdata_offset < size ||\n           BACKEND->decdata_length < len) {\n          \/* increase internal decrypted data buffer *\/\n          reallocated_length = BACKEND->decdata_offset + size;\n          \/* make sure that the requested amount of data fits *\/\n          if(reallocated_length < len) {\n            reallocated_length = len;\n          }\n          reallocated_buffer = realloc(BACKEND->decdata_buffer,\n                                       reallocated_length);\n          if(!reallocated_buffer) {\n            *err = CURLE_OUT_OF_MEMORY;\n            failf(data, \"schannel: unable to re-allocate memory\");\n            goto cleanup;\n          }\n          BACKEND->decdata_buffer = reallocated_buffer;\n          BACKEND->decdata_length = reallocated_length;\n        }\n\n        \/* copy decrypted data to internal buffer *\/\n        size = inbuf[1].cbBuffer;\n        if(size) {\n          memcpy(BACKEND->decdata_buffer + BACKEND->decdata_offset,\n                 inbuf[1].pvBuffer, size);\n          BACKEND->decdata_offset += size;\n        }\n\n        DEBUGF(infof(data, \"schannel: decrypted data added: %zu\\n\", size));\n        DEBUGF(infof(data,\n                     \"schannel: decrypted cached: offset %zu length %zu\\n\",\n                     BACKEND->decdata_offset, BACKEND->decdata_length));\n      }\n\n      \/* check for remaining encrypted data *\/\n      if(inbuf[3].BufferType == SECBUFFER_EXTRA && inbuf[3].cbBuffer > 0) {\n        DEBUGF(infof(data, \"schannel: encrypted data length: %lu\\n\",\n                     inbuf[3].cbBuffer));\n\n        \/* check if the remaining data is less than the total amount\n         * and therefore begins after the already processed data\n         *\/\n        if(BACKEND->encdata_offset > inbuf[3].cbBuffer) {\n          \/* move remaining encrypted data forward to the beginning of\n             buffer *\/\n          memmove(BACKEND->encdata_buffer,\n                  (BACKEND->encdata_buffer + BACKEND->encdata_offset) -\n                  inbuf[3].cbBuffer, inbuf[3].cbBuffer);\n          BACKEND->encdata_offset = inbuf[3].cbBuffer;\n        }\n\n        DEBUGF(infof(data,\n                     \"schannel: encrypted cached: offset %zu length %zu\\n\",\n                     BACKEND->encdata_offset, BACKEND->encdata_length));\n      }\n      else {\n        \/* reset encrypted buffer offset, because there is no data remaining *\/\n        BACKEND->encdata_offset = 0;\n      }\n\n      \/* check if server wants to renegotiate the connection context *\/\n      if(sspi_status == SEC_I_RENEGOTIATE) {\n        infof(data, \"schannel: remote party requests renegotiation\\n\");\n        if(*err && *err != CURLE_AGAIN) {\n          infof(data, \"schannel: can't renogotiate, an error is pending\\n\");\n          goto cleanup;\n        }\n        if(BACKEND->encdata_offset) {\n          *err = CURLE_RECV_ERROR;\n          infof(data, \"schannel: can't renogotiate, \"\n                \"encrypted data available\\n\");\n          goto cleanup;\n        }\n        \/* begin renegotiation *\/\n        infof(data, \"schannel: renegotiating SSL\/TLS connection\\n\");\n        connssl->state = ssl_connection_negotiating;\n        connssl->connecting_state = ssl_connect_2_writing;\n        *err = schannel_connect_common(data, conn, sockindex, FALSE, &done);\n        if(*err) {\n          infof(data, \"schannel: renegotiation failed\\n\");\n          goto cleanup;\n        }\n        \/* now retry receiving data *\/\n        sspi_status = SEC_E_OK;\n        infof(data, \"schannel: SSL\/TLS connection renegotiated\\n\");\n        continue;\n      }\n      \/* check if the server closed the connection *\/\n      else if(sspi_status == SEC_I_CONTEXT_EXPIRED) {\n        \/* In Windows 2000 SEC_I_CONTEXT_EXPIRED (close_notify) is not\n           returned so we have to work around that in cleanup. *\/\n        BACKEND->recv_sspi_close_notify = true;\n        if(!BACKEND->recv_connection_closed) {\n          BACKEND->recv_connection_closed = true;\n          infof(data, \"schannel: server closed the connection\\n\");\n        }\n        goto cleanup;\n      }\n    }\n    else if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) {\n      BACKEND->encdata_is_incomplete = true;\n      if(!*err)\n        *err = CURLE_AGAIN;\n      infof(data, \"schannel: failed to decrypt data, need more data\\n\");\n      goto cleanup;\n    }\n    else {\n#ifndef CURL_DISABLE_VERBOSE_STRINGS\n      char buffer[STRERROR_LEN];\n#endif\n      *err = CURLE_RECV_ERROR;\n      infof(data, \"schannel: failed to read data from server: %s\\n\",\n            Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));\n      goto cleanup;\n    }\n  }\n\n  DEBUGF(infof(data,\n               \"schannel: encrypted data buffer: offset %zu length %zu\\n\",\n               BACKEND->encdata_offset, BACKEND->encdata_length));\n\n  DEBUGF(infof(data,\n               \"schannel: decrypted data buffer: offset %zu length %zu\\n\",\n               BACKEND->decdata_offset, BACKEND->decdata_length));\n\n  cleanup:\n  \/* Warning- there is no guarantee the encdata state is valid at this point *\/\n  DEBUGF(infof(data, \"schannel: schannel_recv cleanup\\n\"));\n\n  \/* Error if the connection has closed without a close_notify.\n\n     The behavior here is a matter of debate. We don't want to be vulnerable\n     to a truncation attack however there's some browser precedent for\n     ignoring the close_notify for compatibility reasons.\n\n     Additionally, Windows 2000 (v5.0) is a special case since it seems it\n     doesn't return close_notify. In that case if the connection was closed we\n     assume it was graceful (close_notify) since there doesn't seem to be a\n     way to tell.\n  *\/\n  if(len && !BACKEND->decdata_offset && BACKEND->recv_connection_closed &&\n     !BACKEND->recv_sspi_close_notify) {\n    bool isWin2k = curlx_verify_windows_version(5, 0, PLATFORM_WINNT,\n                                                VERSION_EQUAL);\n\n    if(isWin2k && sspi_status == SEC_E_OK)\n      BACKEND->recv_sspi_close_notify = true;\n    else {\n      *err = CURLE_RECV_ERROR;\n      infof(data, \"schannel: server closed abruptly (missing close_notify)\\n\");\n    }\n  }\n\n  \/* Any error other than CURLE_AGAIN is an unrecoverable error. *\/\n  if(*err && *err != CURLE_AGAIN)\n    BACKEND->recv_unrecoverable_err = *err;\n\n  size = len < BACKEND->decdata_offset ? len : BACKEND->decdata_offset;\n  if(size) {\n    memcpy(buf, BACKEND->decdata_buffer, size);\n    memmove(BACKEND->decdata_buffer, BACKEND->decdata_buffer + size,\n            BACKEND->decdata_offset - size);\n    BACKEND->decdata_offset -= size;\n    DEBUGF(infof(data, \"schannel: decrypted data returned %zu\\n\", size));\n    DEBUGF(infof(data,\n                 \"schannel: decrypted data buffer: offset %zu length %zu\\n\",\n                 BACKEND->decdata_offset, BACKEND->decdata_length));\n    *err = CURLE_OK;\n    return (ssize_t)size;\n  }\n\n  if(!*err && !BACKEND->recv_connection_closed)\n    *err = CURLE_AGAIN;\n\n  \/* It's debatable what to return when !len. We could return whatever error\n     we got from decryption but instead we override here so the return is\n     consistent.\n  *\/\n  if(!len)\n    *err = CURLE_OK;\n\n  return *err ? -1 : 0;\n}","target":0,"code_token_length":3201,"total_token_length":3437,"max_tokens_setting":4096}
+{"idx":350386,"func":"serialNumberAndIssuerSerialCheck(\n\tstruct berval *in,\n\tstruct berval *sn,\n\tstruct berval *is,\n\tstruct berval *i_sn,\t\/* contain serial of baseCertificateID *\/\n\tvoid *ctx )\n{\n\t\/* Parse GSER format *\/ \n\tenum {\n\t\tHAVE_NONE = 0x0,\n\t\tHAVE_SN = 0x1,\n\t\tHAVE_ISSUER = 0x2,\n\t\tHAVE_ALL = ( HAVE_SN | HAVE_ISSUER )\n\t} have = HAVE_NONE, have2 = HAVE_NONE;\n\tint numdquotes = 0;\n\tstruct berval x = *in;\n\tstruct berval ni;\n\n\tif ( in->bv_len < 3 ) return LDAP_INVALID_SYNTAX;\n\n\t\/* no old format *\/\n\tif ( in->bv_val[0] != '{' && in->bv_val[in->bv_len-1] != '}' ) return LDAP_INVALID_SYNTAX;\n\n\tx.bv_val++;\n\tx.bv_len -= 2;\n\n\tdo {\n\n\t\t\/* eat leading spaces *\/\n\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\/* empty *\/;\n\t\t}\n\n\t\t\/* should be at issuer or serialNumber NamedValue *\/\n\t\tif ( strncasecmp( x.bv_val, \"issuer\", STRLENOF(\"issuer\") ) == 0 ) {\n\t\t\tif ( have & HAVE_ISSUER ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\n\t\t\t\/* parse IssuerSerial *\/\n\t\t\tx.bv_val += STRLENOF(\"issuer\");\n\t\t\tx.bv_len -= STRLENOF(\"issuer\");\n\n\t\t\tif ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\tif ( x.bv_val[0] != '{' \/*}*\/ ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\tif ( strncasecmp( x.bv_val, \"baseCertificateID \", STRLENOF(\"baseCertificateID \") ) != 0 ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\t\t\tx.bv_val += STRLENOF(\"baseCertificateID \");\n\t\t\tx.bv_len -= STRLENOF(\"baseCertificateID \");\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\tif ( x.bv_val[0] != '{' \/*}*\/ ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\tdo {\n\t\t\t\t\/* eat leading spaces *\/\n\t\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\t\/* empty *\/;\n\t\t\t\t}\n\n\t\t\t\t\/* parse issuer of baseCertificateID *\/\n\t\t\t\tif ( strncasecmp( x.bv_val, \"issuer \", STRLENOF(\"issuer \") ) == 0 ) {\n\t\t\t\t\tif ( have2 & HAVE_ISSUER ) {\n\t\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t\t}\n\n\t\t\t\t\tx.bv_val += STRLENOF(\"issuer \");\n\t\t\t\t\tx.bv_len -= STRLENOF(\"issuer \");\n\n\t\t\t\t\t\/* eat leading spaces *\/\n\t\t\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\t\t\/* empty *\/;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( x.bv_val[0] != '{' \/*}*\/ ) return LDAP_INVALID_SYNTAX;\n\t\t\t\t\tx.bv_val++;\n\t\t\t\t\tx.bv_len--;\n\n\t\t\t\t\t\/* eat leading spaces *\/\n\t\t\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\t\t\/* empty *\/;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( strncasecmp( x.bv_val, \"directoryName:rdnSequence:\", STRLENOF(\"directoryName:rdnSequence:\") ) != 0 ) {\n\t\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t\t}\n\t\t\t\t\tx.bv_val += STRLENOF(\"directoryName:rdnSequence:\");\n\t\t\t\t\tx.bv_len -= STRLENOF(\"directoryName:rdnSequence:\");\n\n\t\t\t\t\tif ( x.bv_val[0] != '\"' ) return LDAP_INVALID_SYNTAX;\n\t\t\t\t\tx.bv_val++;\n\t\t\t\t\tx.bv_len--;\n\n\t\t\t\t\tis->bv_val = x.bv_val;\n\t\t\t\t\tis->bv_len = 0;\n\n\t\t\t\t\tfor ( ; is->bv_len < x.bv_len; ) {\n\t\t\t\t\t\tif ( is->bv_val[is->bv_len] != '\"' ) {\n\t\t\t\t\t\t\tis->bv_len++;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( is->bv_val[is->bv_len + 1] == '\"' ) {\n\t\t\t\t\t\t\t\/* double dquote *\/\n\t\t\t\t\t\t\tnumdquotes++;\n\t\t\t\t\t\t\tis->bv_len += 2;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tx.bv_val += is->bv_len + 1;\n\t\t\t\t\tx.bv_len -= is->bv_len + 1;\n\n\t\t\t\t\t\/* eat leading spaces *\/\n\t\t\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\t\t\/* empty *\/;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( x.bv_val[0] != \/*{*\/ '}' ) return LDAP_INVALID_SYNTAX;\n\t\t\t\t\tx.bv_val++;\n\t\t\t\t\tx.bv_len--;\n\n\t\t\t\t\thave2 |= HAVE_ISSUER;\n\n\t\t\t\t} else if ( strncasecmp( x.bv_val, \"serial \", STRLENOF(\"serial \") ) == 0 ) {\n\t\t\t\t\tif ( have2 & HAVE_SN ) {\n\t\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t\t}\n\n\t\t\t\t\tx.bv_val += STRLENOF(\"serial \");\n\t\t\t\t\tx.bv_len -= STRLENOF(\"serial \");\n\n\t\t\t\t\t\/* eat leading spaces *\/\n\t\t\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len--) {\n\t\t\t\t\t\t\/* empty *\/;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( checkNum( &x, i_sn ) ) {\n\t\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t\t}\n\n\t\t\t\t\tx.bv_val += i_sn->bv_len;\n\t\t\t\t\tx.bv_len -= i_sn->bv_len;\n\n\t\t\t\t\thave2 |= HAVE_SN;\n\n\t\t\t\t} else {\n\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t}\n\n\t\t\t\t\/* eat leading spaces *\/\n\t\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\t\/* empty *\/;\n\t\t\t\t}\n\n\t\t\t\tif ( have2 == HAVE_ALL ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif ( x.bv_val[0] != ',' ) return LDAP_INVALID_SYNTAX;\n\t\t\t\tx.bv_val++;\n\t\t\t\tx.bv_len--;\n\t\t\t} while ( 1 );\n\n\t\t\tif ( x.bv_val[0] != \/*{*\/ '}' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\tif ( x.bv_val[0] != \/*{*\/ '}' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\thave |= HAVE_ISSUER;\n\n\t\t} else if ( strncasecmp( x.bv_val, \"serialNumber\", STRLENOF(\"serialNumber\") ) == 0 ) {\n\t\t\tif ( have & HAVE_SN ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\n\t\t\t\/* parse serialNumber *\/\n\t\t\tx.bv_val += STRLENOF(\"serialNumber\");\n\t\t\tx.bv_len -= STRLENOF(\"serialNumber\");\n\n\t\t\tif ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\t\t\t\n\t\t\tif ( checkNum( &x, sn ) ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\n\t\t\tx.bv_val += sn->bv_len;\n\t\t\tx.bv_len -= sn->bv_len;\n\n\t\t\thave |= HAVE_SN;\n\n\t\t} else {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\t\/* eat spaces *\/\n\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\/* empty *\/;\n\t\t}\n\n\t\tif ( have == HAVE_ALL ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( x.bv_val[0] != ',' ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t\tx.bv_val++ ;\n\t\tx.bv_len--;\n\t} while ( 1 );\n\n\t\/* should have no characters left... *\/\n\tif( x.bv_len ) return LDAP_INVALID_SYNTAX;\n\n\tif ( numdquotes == 0 ) {\n\t\tber_dupbv_x( &ni, is, ctx );\n\n\t} else {\n\t\tber_len_t src, dst;\n\n\t\tni.bv_len = is->bv_len - numdquotes;\n\t\tni.bv_val = ber_memalloc_x( ni.bv_len + 1, ctx );\n\t\tfor ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) {\n\t\t\tif ( is->bv_val[src] == '\"' ) {\n\t\t\t\tsrc++;\n\t\t\t}\n\t\t\tni.bv_val[dst] = is->bv_val[src];\n\t\t}\n\t\tni.bv_val[dst] = '\\0';\n\t}\n\n\t*is = ni;\n\n\t\/* need to handle double dquotes here *\/\n\treturn 0;\n}","target":1,"code_token_length":2260,"total_token_length":2496,"max_tokens_setting":4096}
+{"idx":37299,"func":"MagickExport MagickBooleanType XPreferencesWidget(Display *display,\n  XResourceInfo *resource_info,XWindows *windows)\n{\n#define ApplyButtonText  \"Apply\"\n#define CacheButtonText  \"%lu mega-bytes of memory in the undo edit cache   \"\n#define CancelButtonText  \"Cancel\"\n#define NumberPreferences  8\n\n  static const char\n    *Preferences[] =\n    {\n      \"display image centered on a backdrop\",\n      \"confirm on program exit\",\n      \"confirm on image edits\",\n      \"correct image for display gamma\",\n      \"display warning messages\",\n      \"apply Floyd\/Steinberg error diffusion to image\",\n      \"use a shared colormap for colormapped X visuals\",\n      \"display images as an X server pixmap\"\n    };\n\n  char\n    cache[MaxTextExtent];\n\n  int\n    x,\n    y;\n\n  int\n    i;\n\n  Status\n    status;\n\n  unsigned int\n    height,\n    text_width,\n    width;\n\n  size_t\n    state;\n\n  XEvent\n    event;\n\n  XFontStruct\n    *font_info;\n\n  XTextProperty\n    window_name;\n\n  XWidgetInfo\n    apply_info,\n    cache_info,\n    cancel_info,\n    preferences_info[NumberPreferences];\n\n  XWindowChanges\n    window_changes;\n\n  \/*\n    Determine Preferences widget attributes.\n  *\/\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"...\");\n  assert(display != (Display *) NULL);\n  assert(resource_info != (XResourceInfo *) NULL);\n  assert(windows != (XWindows *) NULL);\n  XCheckRefreshWindows(display,windows);\n  font_info=windows->widget.font_info;\n  text_width=WidgetTextWidth(font_info,CacheButtonText);\n  for (i=0; i < NumberPreferences; i++)\n    if (WidgetTextWidth(font_info,(char *) Preferences[i]) > text_width)\n      text_width=WidgetTextWidth(font_info,(char *) Preferences[i]);\n  width=WidgetTextWidth(font_info,ApplyButtonText);\n  if (WidgetTextWidth(font_info,CancelButtonText) > width)\n    width=WidgetTextWidth(font_info,CancelButtonText);\n  width+=(unsigned int) QuantumMargin;\n  height=(unsigned int) (font_info->ascent+font_info->descent);\n  \/*\n    Position Preferences widget.\n  *\/\n  windows->widget.width=(unsigned int) (MagickMax((int) (width << 1),\n    (int) text_width)+6*QuantumMargin);\n  windows->widget.min_width=(width << 1)+QuantumMargin;\n  if (windows->widget.width < windows->widget.min_width)\n    windows->widget.width=windows->widget.min_width;\n  windows->widget.height=(unsigned int)\n    (7*height+NumberPreferences*(height+(QuantumMargin >> 1)));\n  windows->widget.min_height=(unsigned int)\n    (7*height+NumberPreferences*(height+(QuantumMargin >> 1)));\n  if (windows->widget.height < windows->widget.min_height)\n    windows->widget.height=windows->widget.min_height;\n  XConstrainWindowPosition(display,&windows->widget);\n  \/*\n    Map Preferences widget.\n  *\/\n  (void) CopyMagickString(windows->widget.name,\"Preferences\",MaxTextExtent);\n  status=XStringListToTextProperty(&windows->widget.name,1,&window_name);\n  if (status != False)\n    {\n      XSetWMName(display,windows->widget.id,&window_name);\n      XSetWMIconName(display,windows->widget.id,&window_name);\n      (void) XFree((void *) window_name.value);\n    }\n  window_changes.width=(int) windows->widget.width;\n  window_changes.height=(int) windows->widget.height;\n  window_changes.x=windows->widget.x;\n  window_changes.y=windows->widget.y;\n  (void) XReconfigureWMWindow(display,windows->widget.id,windows->widget.screen,\n    (unsigned int) (CWWidth | CWHeight | CWX | CWY),&window_changes);\n  (void) XMapRaised(display,windows->widget.id);\n  windows->widget.mapped=MagickFalse;\n  \/*\n    Respond to X events.\n  *\/\n  state=UpdateConfigurationState;\n  XSetCursorState(display,windows,MagickTrue);\n  do\n  {\n    if (state & UpdateConfigurationState)\n      {\n        \/*\n          Initialize button information.\n        *\/\n        XGetWidgetInfo(CancelButtonText,&cancel_info);\n        cancel_info.width=width;\n        cancel_info.height=(unsigned int) (3*height) >> 1;\n        cancel_info.x=(int) windows->widget.width-cancel_info.width-\n          (QuantumMargin << 1);\n        cancel_info.y=(int) windows->widget.height-\n          cancel_info.height-QuantumMargin;\n        XGetWidgetInfo(ApplyButtonText,&apply_info);\n        apply_info.width=width;\n        apply_info.height=(unsigned int) (3*height) >> 1;\n        apply_info.x=QuantumMargin << 1;\n        apply_info.y=cancel_info.y;\n        y=(int) (height << 1);\n        for (i=0; i < NumberPreferences; i++)\n        {\n          XGetWidgetInfo(Preferences[i],&preferences_info[i]);\n          preferences_info[i].bevel_width--;\n          preferences_info[i].width=(unsigned int) QuantumMargin >> 1;\n          preferences_info[i].height=(unsigned int) QuantumMargin >> 1;\n          preferences_info[i].x=QuantumMargin << 1;\n          preferences_info[i].y=y;\n          y+=height+(QuantumMargin >> 1);\n        }\n        preferences_info[0].raised=resource_info->backdrop ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        preferences_info[1].raised=resource_info->confirm_exit ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        preferences_info[2].raised=resource_info->confirm_edit ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        preferences_info[3].raised=resource_info->gamma_correct ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        preferences_info[4].raised=resource_info->display_warnings ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        preferences_info[5].raised=resource_info->quantize_info->dither ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        preferences_info[6].raised=resource_info->colormap !=\n          SharedColormap ? MagickTrue : MagickFalse;\n        preferences_info[7].raised=resource_info->use_pixmap ==\n          MagickFalse ? MagickTrue : MagickFalse;\n        (void) FormatLocaleString(cache,MaxTextExtent,CacheButtonText,\n          (unsigned long) resource_info->undo_cache);\n        XGetWidgetInfo(cache,&cache_info);\n        cache_info.bevel_width--;\n        cache_info.width=(unsigned int) QuantumMargin >> 1;\n        cache_info.height=(unsigned int) QuantumMargin >> 1;\n        cache_info.x=QuantumMargin << 1;\n        cache_info.y=y;\n        state&=(~UpdateConfigurationState);\n      }\n    if (state & RedrawWidgetState)\n      {\n        \/*\n          Redraw Preferences widget.\n        *\/\n        XDrawBeveledButton(display,&windows->widget,&apply_info);\n        XDrawBeveledButton(display,&windows->widget,&cancel_info);\n        for (i=0; i < NumberPreferences; i++)\n          XDrawBeveledButton(display,&windows->widget,&preferences_info[i]);\n        XDrawTriangleEast(display,&windows->widget,&cache_info);\n        XHighlightWidget(display,&windows->widget,BorderOffset,BorderOffset);\n        state&=(~RedrawWidgetState);\n      }\n    \/*\n      Wait for next event.\n    *\/\n    (void) XIfEvent(display,&event,XScreenEvent,(char *) windows);\n    switch (event.type)\n    {\n      case ButtonPress:\n      {\n        if (MatteIsActive(apply_info,event.xbutton))\n          {\n            \/*\n              User pressed Apply button.\n            *\/\n            apply_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&apply_info);\n            break;\n          }\n        if (MatteIsActive(cancel_info,event.xbutton))\n          {\n            \/*\n              User pressed Cancel button.\n            *\/\n            cancel_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&cancel_info);\n            break;\n          }\n        for (i=0; i < NumberPreferences; i++)\n          if (MatteIsActive(preferences_info[i],event.xbutton))\n            {\n              \/*\n                User pressed a Preferences button.\n              *\/\n              preferences_info[i].raised=preferences_info[i].raised ==\n                MagickFalse ? MagickTrue : MagickFalse;\n              XDrawBeveledButton(display,&windows->widget,&preferences_info[i]);\n              break;\n            }\n        if (MatteIsActive(cache_info,event.xbutton))\n          {\n            \/*\n              User pressed Cache button.\n            *\/\n            x=cache_info.x+cache_info.width+cache_info.bevel_width+\n              (QuantumMargin >> 1);\n            y=cache_info.y+((cache_info.height-height) >> 1);\n            width=WidgetTextWidth(font_info,cache);\n            (void) XClearArea(display,windows->widget.id,x,y,width,height,\n              False);\n            resource_info->undo_cache<<=1;\n            if (resource_info->undo_cache > 256)\n              resource_info->undo_cache=1;\n            (void) FormatLocaleString(cache,MaxTextExtent,CacheButtonText,\n              (unsigned long) resource_info->undo_cache);\n            cache_info.raised=MagickFalse;\n            XDrawTriangleEast(display,&windows->widget,&cache_info);\n            break;\n          }\n        break;\n      }\n      case ButtonRelease:\n      {\n        if (windows->widget.mapped == MagickFalse)\n          break;\n        if (apply_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              if (MatteIsActive(apply_info,event.xbutton))\n                state|=ExitState;\n            apply_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&apply_info);\n            apply_info.raised=MagickFalse;\n          }\n        if (cancel_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              if (MatteIsActive(cancel_info,event.xbutton))\n                state|=ExitState;\n            cancel_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&cancel_info);\n          }\n        if (cache_info.raised == MagickFalse)\n          {\n            cache_info.raised=MagickTrue;\n            XDrawTriangleEast(display,&windows->widget,&cache_info);\n          }\n        break;\n      }\n      case ClientMessage:\n      {\n        \/*\n          If client window delete message, exit.\n        *\/\n        if (event.xclient.message_type != windows->wm_protocols)\n          break;\n        if (*event.xclient.data.l == (int) windows->wm_take_focus)\n          {\n            (void) XSetInputFocus(display,event.xclient.window,RevertToParent,\n              (Time) event.xclient.data.l[1]);\n            break;\n          }\n        if (*event.xclient.data.l != (int) windows->wm_delete_window)\n          break;\n        if (event.xclient.window == windows->widget.id)\n          {\n            state|=ExitState;\n            break;\n          }\n        break;\n      }\n      case ConfigureNotify:\n      {\n        \/*\n          Update widget configuration.\n        *\/\n        if (event.xconfigure.window != windows->widget.id)\n          break;\n        if ((event.xconfigure.width == (int) windows->widget.width) &&\n            (event.xconfigure.height == (int) windows->widget.height))\n          break;\n        windows->widget.width=(unsigned int)\n          MagickMax(event.xconfigure.width,(int) windows->widget.min_width);\n        windows->widget.height=(unsigned int)\n          MagickMax(event.xconfigure.height,(int) windows->widget.min_height);\n        state|=UpdateConfigurationState;\n        break;\n      }\n      case EnterNotify:\n      {\n        if (event.xcrossing.window != windows->widget.id)\n          break;\n        state&=(~InactiveWidgetState);\n        break;\n      }\n      case Expose:\n      {\n        if (event.xexpose.window != windows->widget.id)\n          break;\n        if (event.xexpose.count != 0)\n          break;\n        state|=RedrawWidgetState;\n        break;\n      }\n      case KeyPress:\n      {\n        static char\n          command[MaxTextExtent];\n\n        static KeySym\n          key_symbol;\n\n        \/*\n          Respond to a user key press.\n        *\/\n        if (event.xkey.window != windows->widget.id)\n          break;\n        (void) XLookupString((XKeyEvent *) &event.xkey,command,\n          (int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);\n        if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))\n          {\n            apply_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&apply_info);\n            state|=ExitState;\n            break;\n          }\n        break;\n      }\n      case LeaveNotify:\n      {\n        if (event.xcrossing.window != windows->widget.id)\n          break;\n        state|=InactiveWidgetState;\n        break;\n      }\n      case MotionNotify:\n      {\n        \/*\n          Discard pending button motion events.\n        *\/\n        while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ;\n        if (state & InactiveWidgetState)\n          break;\n        if (apply_info.raised == MatteIsActive(apply_info,event.xmotion))\n          {\n            \/*\n              Apply button status changed.\n            *\/\n            apply_info.raised=\n              apply_info.raised == MagickFalse ? MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&apply_info);\n            break;\n          }\n        if (cancel_info.raised == MatteIsActive(cancel_info,event.xmotion))\n          {\n            \/*\n              Cancel button status changed.\n            *\/\n            cancel_info.raised=\n              cancel_info.raised == MagickFalse ? MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&cancel_info);\n            break;\n          }\n        break;\n      }\n      default:\n        break;\n    }\n  } while ((state & ExitState) == 0);\n  XSetCursorState(display,windows,MagickFalse);\n  (void) XWithdrawWindow(display,windows->widget.id,windows->widget.screen);\n  XCheckRefreshWindows(display,windows);\n  if (apply_info.raised)\n    return(MagickFalse);\n  \/*\n    Save user preferences to the client configuration file.\n  *\/\n  resource_info->backdrop=\n    preferences_info[0].raised == MagickFalse ? MagickTrue : MagickFalse;\n  resource_info->confirm_exit=\n    preferences_info[1].raised == MagickFalse ? MagickTrue : MagickFalse;\n  resource_info->confirm_edit=\n    preferences_info[2].raised == MagickFalse ? MagickTrue : MagickFalse;\n  resource_info->gamma_correct=\n    preferences_info[3].raised == MagickFalse ? MagickTrue : MagickFalse;\n  resource_info->display_warnings=\n     preferences_info[4].raised == MagickFalse ? MagickTrue : MagickFalse;\n  resource_info->quantize_info->dither=\n    preferences_info[5].raised == MagickFalse ? MagickTrue : MagickFalse;\n  resource_info->colormap=SharedColormap;\n  if (preferences_info[6].raised)\n    resource_info->colormap=PrivateColormap;\n  resource_info->use_pixmap=\n    preferences_info[7].raised == MagickFalse ? MagickTrue : MagickFalse;\n  XUserPreferences(resource_info);\n  return(MagickTrue);\n}","target":0,"code_token_length":3301,"total_token_length":3537,"max_tokens_setting":4096}
+{"idx":269983,"func":"static void processCertificateElements(struct ndpi_detection_module_struct *ndpi_struct,\n\t\t\t\t       struct ndpi_flow_struct *flow,\n\t\t\t\t       u_int16_t p_offset, u_int16_t certificate_len) {\n  struct ndpi_packet_struct *packet = &flow->packet;\n  u_int num_found = 0, i;\n  char buffer[64] = { '\\0' }, rdnSeqBuf[2048] = { '\\0' };\n  u_int rdn_len = 0;\n\n#ifdef DEBUG_TLS\n  printf(\"[TLS] %s() [offset: %u][certificate_len: %u]\\n\", __FUNCTION__, p_offset, certificate_len);\n#endif\n\n  \/* Check after handshake protocol header (5 bytes) and message header (4 bytes) *\/\n  for(i = p_offset; i < certificate_len; i++) {\n    \/*\n       See https:\/\/www.ibm.com\/support\/knowledgecenter\/SSFKSJ_7.5.0\/com.ibm.mq.sec.doc\/q009860_.htm\n       for X.509 certificate labels\n    *\/\n    if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x03)) {\n      \/* Common Name *\/\n      int rc = extractRDNSequence(packet, i, buffer, sizeof(buffer), rdnSeqBuf, &rdn_len, sizeof(rdnSeqBuf), \"CN\");\n      if(rc == -1) break;\n\n#ifdef DEBUG_TLS\n      printf(\"[TLS] %s() [%s][%s: %s]\\n\", __FUNCTION__, (num_found == 0) ? \"Subject\" : \"Issuer\", \"Common Name\", buffer);\n#endif\n    } else if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x06)) {\n      \/* Country *\/\n      int rc = extractRDNSequence(packet, i, buffer, sizeof(buffer), rdnSeqBuf, &rdn_len, sizeof(rdnSeqBuf), \"C\");\n      if(rc == -1) break;\n\n#ifdef DEBUG_TLS\n      printf(\"[TLS] %s() [%s][%s: %s]\\n\", __FUNCTION__, (num_found == 0) ? \"Subject\" : \"Issuer\", \"Country\", buffer);\n#endif\n    } else if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x07)) {\n      \/* Locality *\/\n      int rc = extractRDNSequence(packet, i, buffer, sizeof(buffer), rdnSeqBuf, &rdn_len, sizeof(rdnSeqBuf), \"L\");\n      if(rc == -1) break;\n\n#ifdef DEBUG_TLS\n      printf(\"[TLS] %s() [%s][%s: %s]\\n\", __FUNCTION__, (num_found == 0) ? \"Subject\" : \"Issuer\", \"Locality\", buffer);\n#endif\n    } else if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x08)) {\n      \/* State or Province *\/\n      int rc = extractRDNSequence(packet, i, buffer, sizeof(buffer), rdnSeqBuf, &rdn_len, sizeof(rdnSeqBuf), \"ST\");\n      if(rc == -1) break;\n\n#ifdef DEBUG_TLS\n      printf(\"[TLS] %s() [%s][%s: %s]\\n\", __FUNCTION__, (num_found == 0) ? \"Subject\" : \"Issuer\", \"State or Province\", buffer);\n#endif\n    } else if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x0a)) {\n      \/* Organization Name *\/\n      int rc = extractRDNSequence(packet, i, buffer, sizeof(buffer), rdnSeqBuf, &rdn_len, sizeof(rdnSeqBuf), \"O\");\n      if(rc == -1) break;\n\n#ifdef DEBUG_TLS\n      printf(\"[TLS] %s() [%s][%s: %s]\\n\", __FUNCTION__, (num_found == 0) ? \"Subject\" : \"Issuer\", \"Organization Name\", buffer);\n#endif\n\n    } else if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x04) && (packet->payload[i+2] == 0x0b)) {\n      \/* Organization Unit *\/\n      int rc = extractRDNSequence(packet, i, buffer, sizeof(buffer), rdnSeqBuf, &rdn_len, sizeof(rdnSeqBuf), \"OU\");\n      if(rc == -1) break;\n\n#ifdef DEBUG_TLS\n      printf(\"[TLS] %s() [%s][%s: %s]\\n\", __FUNCTION__, (num_found == 0) ? \"Subject\" : \"Issuer\", \"Organization Unit\", buffer);\n#endif\n    } else if((packet->payload[i] == 0x30) && (packet->payload[i+1] == 0x1e) && (packet->payload[i+2] == 0x17)) {\n      \/* Certificate Validity *\/\n      u_int8_t len = packet->payload[i+3];\n      u_int offset = i+4;\n\n      if(num_found == 0) {\n\tnum_found++;\n\n#ifdef DEBUG_TLS\n\tprintf(\"[TLS] %s() IssuerDN [%s]\\n\", __FUNCTION__, rdnSeqBuf);\n#endif\n\n\tif(rdn_len) flow->protos.stun_ssl.ssl.issuerDN = ndpi_strdup(rdnSeqBuf);\n\trdn_len = 0; \/* Reset buffer *\/\n      }\n\n      if((offset+len) < packet->payload_packet_len) {\n\tchar utcDate[32];\n\n#ifdef DEBUG_TLS\n\tu_int j;\n\n\tprintf(\"[CERTIFICATE] notBefore [len: %u][\", len);\n\tfor(j=0; jpayload[i+4+j]);\n\tprintf(\"]\\n\");\n#endif\n\n\tif(len < (sizeof(utcDate)-1)) {\n\t  struct tm utc;\n\t  utc.tm_isdst = -1; \/* Not set by strptime *\/\n\n\t  strncpy(utcDate, (const char*)&packet->payload[i+4], len);\n\t  utcDate[len] = '\\0';\n\n\t  \/* 141021000000Z *\/\n\t  if(strptime(utcDate, \"%y%m%d%H%M%SZ\", &utc) != NULL) {\n\t    flow->protos.stun_ssl.ssl.notBefore = timegm(&utc);\n#ifdef DEBUG_TLS\n\t    printf(\"[CERTIFICATE] notBefore %u [%s]\\n\",\n\t\t   flow->protos.stun_ssl.ssl.notBefore, utcDate);\n#endif\n\t  }\n\t}\n\n\toffset += len;\n\n\tif((offset+1) < packet->payload_packet_len) {\n\t  len = packet->payload[offset+1];\n\n\t  offset += 2;\n\n\t  if((offset+len) < packet->payload_packet_len) {\n\t    u_int32_t time_sec = flow->packet.current_time_ms \/ 1000;\n#ifdef DEBUG_TLS\n\t    u_int j;\n\n\t    printf(\"[CERTIFICATE] notAfter [len: %u][\", len);\n\t    for(j=0; jpayload[offset+j]);\n\t    printf(\"]\\n\");\n#endif\n\n\t    if(len < (sizeof(utcDate)-1)) {\n\t      struct tm utc;\n\t      utc.tm_isdst = -1; \/* Not set by strptime *\/\n\n\t      strncpy(utcDate, (const char*)&packet->payload[offset], len);\n\t      utcDate[len] = '\\0';\n\n\t      \/* 141021000000Z *\/\n\t      if(strptime(utcDate, \"%y%m%d%H%M%SZ\", &utc) != NULL) {\n\t\tflow->protos.stun_ssl.ssl.notAfter = timegm(&utc);\n#ifdef DEBUG_TLS\n\t\tprintf(\"[CERTIFICATE] notAfter %u [%s]\\n\",\n\t\t       flow->protos.stun_ssl.ssl.notAfter, utcDate);\n#endif\n\t      }\n\t    }\n\n\n\t    if((time_sec < flow->protos.stun_ssl.ssl.notBefore)\n\t       || (time_sec > flow->protos.stun_ssl.ssl.notAfter))\n\t    NDPI_SET_BIT(flow->risk, NDPI_TLS_CERTIFICATE_EXPIRED); \/* Certificate expired *\/\n\t  }\n\t}\n      }\n    } else if((packet->payload[i] == 0x55) && (packet->payload[i+1] == 0x1d) && (packet->payload[i+2] == 0x11)) {\n      \/* Organization OID: 2.5.29.17 (subjectAltName) *\/\n      u_int8_t matched_name = 0;\n\n#ifdef DEBUG_TLS\n      printf(\"******* [TLS] Found subjectAltName\\n\");\n#endif\n\n      i += 3 \/* skip the initial patten 55 1D 11 *\/;\n      i++; \/* skip the first type, 0x04 == BIT STRING, and jump to it's length *\/\n      if(i < packet->payload_packet_len) {\n\ti += (packet->payload[i] & 0x80) ? (packet->payload[i] & 0x7F) : 0; \/* skip BIT STRING length *\/\n\tif(i < packet->payload_packet_len) {\n\t  i += 2; \/* skip the second type, 0x30 == SEQUENCE, and jump to it's length *\/\n\t  if(i < packet->payload_packet_len) {\n\t    i += (packet->payload[i] & 0x80) ? (packet->payload[i] & 0x7F) : 0; \/* skip SEQUENCE length *\/\n\t    i++;\n\n\t    while(i < packet->payload_packet_len) {\n\t      if(packet->payload[i] == 0x82) {\n\t\tif((i < (packet->payload_packet_len - 1))\n\t\t   && ((i + packet->payload[i + 1] + 2) < packet->payload_packet_len)) {\n\t\t  u_int8_t len = packet->payload[i + 1];\n\t\t  char dNSName[256];\n\n\t\t  i += 2;\n\n\t\t  \/* The check \"len > sizeof(dNSName) - 1\" will be always false. If we add it,\n\t\t     the compiler is smart enough to detect it and throws a warning *\/\n\t\t  if(len == 0 \/* Looks something went wrong *\/)\n\t\t    break;\n\n\t\t  strncpy(dNSName, (const char*)&packet->payload[i], len);\n\t\t  dNSName[len] = '\\0';\n\n\t\t  cleanupServerName(dNSName, len);\n\n#if DEBUG_TLS\n\t\t  printf(\"[TLS] dNSName %s [%s]\\n\", dNSName, flow->protos.stun_ssl.ssl.client_requested_server_name);\n#endif\n\t\t  if(matched_name == 0) {\n\t\t    if((dNSName[0] == '*') && strstr(flow->protos.stun_ssl.ssl.client_requested_server_name, &dNSName[1]))\n\t\t      matched_name = 1;\n\t\t    else if(strcmp(flow->protos.stun_ssl.ssl.client_requested_server_name, dNSName) == 0)\n\t\t      matched_name = 1;\n\t\t  }\n\n\t\t  if(flow->protos.stun_ssl.ssl.server_names == NULL)\n\t\t    flow->protos.stun_ssl.ssl.server_names = ndpi_strdup(dNSName),\n\t\t      flow->protos.stun_ssl.ssl.server_names_len = strlen(dNSName);\n\t\t  else {\n\t\t    u_int16_t dNSName_len = strlen(dNSName);\n\t\t    u_int16_t newstr_len = flow->protos.stun_ssl.ssl.server_names_len + dNSName_len + 1;\n\t\t    char *newstr = (char*)ndpi_realloc(flow->protos.stun_ssl.ssl.server_names,\n\t\t\t\t\t\t       flow->protos.stun_ssl.ssl.server_names_len+1, newstr_len+1);\n\n\t\t    if(newstr) {\n\t\t      flow->protos.stun_ssl.ssl.server_names = newstr;\n\t\t      flow->protos.stun_ssl.ssl.server_names[flow->protos.stun_ssl.ssl.server_names_len] = ',';\n\t\t      strncpy(&flow->protos.stun_ssl.ssl.server_names[flow->protos.stun_ssl.ssl.server_names_len+1],\n\t\t\t      dNSName, dNSName_len+1);\n\t\t      flow->protos.stun_ssl.ssl.server_names[newstr_len] = '\\0';\n\t\t      flow->protos.stun_ssl.ssl.server_names_len = newstr_len;\n\t\t    }\n\t\t  }\n\n\t\t  if(!flow->l4.tcp.tls.subprotocol_detected)\n\t\t    if(ndpi_match_hostname_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TLS, dNSName, len))\n\t\t      flow->l4.tcp.tls.subprotocol_detected = 1;\n\n\t\t  i += len;\n\t\t} else {\n#if DEBUG_TLS\n\t\t  printf(\"[TLS] Leftover %u bytes\", packet->payload_packet_len - i);\n#endif\n\t\t  break;\n\t\t}\n\t      } else {\n\t\tbreak;\n\t      }\n\t    } \/* while *\/\n\n\t    if(!matched_name)\n\t      NDPI_SET_BIT(flow->risk, NDPI_TLS_CERTIFICATE_MISMATCH); \/* Certificate mismatch *\/\n\t  }\n\t}\n      }\n    }\n  }\n\n  if(rdn_len) flow->protos.stun_ssl.ssl.subjectDN = ndpi_strdup(rdnSeqBuf);\n\n  if(flow->protos.stun_ssl.ssl.subjectDN && flow->protos.stun_ssl.ssl.issuerDN\n     && (!strcmp(flow->protos.stun_ssl.ssl.subjectDN, flow->protos.stun_ssl.ssl.issuerDN)))\n    NDPI_SET_BIT(flow->risk, NDPI_TLS_SELFSIGNED_CERTIFICATE);\n\n#if DEBUG_TLS\n  printf(\"[TLS] %s() SubjectDN [%s]\\n\", __FUNCTION__, rdnSeqBuf);\n#endif\n}","target":0,"code_token_length":3004,"total_token_length":3240,"max_tokens_setting":4096}
+{"idx":176695,"func":"WORD32 ih264d_parse_imb_cabac(dec_struct_t * ps_dec,\n dec_mb_info_t * ps_cur_mb_info,\n                              UWORD8 u1_mb_type)\n{\n    WORD8 i1_delta_qp;\n    UWORD8 u1_cbp;\n    UWORD8 u1_offset;\n \/* Variables for handling Cabac contexts *\/\n ctxt_inc_mb_info_t *p_curr_ctxt = ps_dec->ps_curr_ctxt_mb_info;\n ctxt_inc_mb_info_t *ps_left_ctxt = ps_dec->p_left_ctxt_mb_info;\n dec_bit_stream_t * const ps_bitstrm = ps_dec->ps_bitstrm;\n bin_ctxt_model_t *p_bin_ctxt;\n\n    UWORD8 u1_intra_chrom_pred_mode;\n    UWORD8 u1_dc_block_flag = 0;\n    WORD32 ret;\n\n    ps_cur_mb_info->u1_yuv_dc_block_flag = 0;\n\n if(ps_left_ctxt == ps_dec->ps_def_ctxt_mb_info)\n {\n        ps_dec->pu1_left_yuv_dc_csbp[0] = 0xf;\n }\n\n if(ps_dec->ps_cur_slice->u1_slice_type != I_SLICE)\n {\n        WORD32 *pi4_buf;\n        WORD8 *pi1_buf;\n        MEMSET_16BYTES(&ps_dec->pu1_left_mv_ctxt_inc[0][0], 0);\n *((UWORD32 *)ps_dec->pi1_left_ref_idx_ctxt_inc) = 0;\n        MEMSET_16BYTES(p_curr_ctxt->u1_mv, 0);\n        pi1_buf = p_curr_ctxt->i1_ref_idx;\n        pi4_buf = (WORD32 *)pi1_buf;\n *pi4_buf = 0;\n }\n\n if(u1_mb_type == I_4x4_MB)\n {\n        ps_cur_mb_info->ps_curmb->u1_mb_type = I_4x4_MB;\n        p_curr_ctxt->u1_mb_type = CAB_I4x4;\n        u1_offset = 0;\n\n        ps_cur_mb_info->u1_tran_form8x8 = 0;\n        ps_cur_mb_info->ps_curmb->u1_tran_form8x8 = 0;\n\n \/*--------------------------------------------------------------------*\/\n \/* Read transform_size_8x8_flag if present                            *\/\n \/*--------------------------------------------------------------------*\/\n if(ps_dec->s_high_profile.u1_transform8x8_present)\n {\n            ps_cur_mb_info->u1_tran_form8x8 = ih264d_parse_transform8x8flag_cabac(\n                            ps_dec, ps_cur_mb_info);\n            COPYTHECONTEXT(\"transform_size_8x8_flag\", ps_cur_mb_info->u1_tran_form8x8);\n            p_curr_ctxt->u1_transform8x8_ctxt = ps_cur_mb_info->u1_tran_form8x8;\n            ps_cur_mb_info->ps_curmb->u1_tran_form8x8 = ps_cur_mb_info->u1_tran_form8x8;\n }\n else\n {\n            p_curr_ctxt->u1_transform8x8_ctxt = 0;\n }\n\n \/*--------------------------------------------------------------------*\/\n \/* Read the IntraPrediction modes for LUMA                            *\/\n \/*--------------------------------------------------------------------*\/\n if (!ps_cur_mb_info->u1_tran_form8x8)\n {\n            UWORD8 *pu1_temp;\n            ih264d_read_intra_pred_modes_cabac(\n                            ps_dec,\n ((UWORD8 *)ps_dec->pv_parse_tu_coeff_data),\n ((UWORD8 *)ps_dec->pv_parse_tu_coeff_data+16),\n                            ps_cur_mb_info->u1_tran_form8x8);\n            pu1_temp = (UWORD8 *)ps_dec->pv_parse_tu_coeff_data;\n            pu1_temp += 32;\n            ps_dec->pv_parse_tu_coeff_data = (void *)pu1_temp;\n }\n else\n {\n            UWORD8 *pu1_temp;\n            ih264d_read_intra_pred_modes_cabac(\n                            ps_dec,\n ((UWORD8 *)ps_dec->pv_parse_tu_coeff_data),\n ((UWORD8 *)ps_dec->pv_parse_tu_coeff_data+4),\n                            ps_cur_mb_info->u1_tran_form8x8);\n            pu1_temp = (UWORD8 *)ps_dec->pv_parse_tu_coeff_data;\n            pu1_temp += 8;\n            ps_dec->pv_parse_tu_coeff_data = (void *)pu1_temp;\n }\n \/*--------------------------------------------------------------------*\/\n \/* Read the IntraPrediction mode for CHROMA                           *\/\n \/*--------------------------------------------------------------------*\/\n        u1_intra_chrom_pred_mode = ih264d_parse_chroma_pred_mode_cabac(ps_dec);\n        COPYTHECONTEXT(\"intra_chroma_pred_mode\", u1_intra_chrom_pred_mode);\n        p_curr_ctxt->u1_intra_chroma_pred_mode = ps_cur_mb_info->u1_chroma_pred_mode =\n                        u1_intra_chrom_pred_mode;\n\n \/*--------------------------------------------------------------------*\/\n \/* Read the Coded block pattern                                       *\/\n \/*--------------------------------------------------------------------*\/\n        u1_cbp = ih264d_parse_ctx_cbp_cabac(ps_dec);\n        COPYTHECONTEXT(\"coded_block_pattern\", u1_cbp);\n        ps_cur_mb_info->u1_cbp = u1_cbp;\n        p_curr_ctxt->u1_cbp = u1_cbp;\n\n \/*--------------------------------------------------------------------*\/\n \/* Read mb_qp_delta                                                   *\/\n \/*--------------------------------------------------------------------*\/\n if(ps_cur_mb_info->u1_cbp)\n {\n            ret = ih264d_parse_mb_qp_delta_cabac(ps_dec, &i1_delta_qp);\n if(ret != OK)\n return ret;\n            COPYTHECONTEXT(\"mb_qp_delta\", i1_delta_qp);\n if(i1_delta_qp != 0)\n {\n                ret = ih264d_update_qp(ps_dec, i1_delta_qp);\n if(ret != OK)\n return ret;\n }\n }\n else\n            ps_dec->i1_prev_mb_qp_delta = 0;\n        p_curr_ctxt->u1_yuv_dc_csbp &= 0xFE;\n }\n else\n {\n        u1_offset = 1;\n        ps_cur_mb_info->ps_curmb->u1_mb_type = I_16x16_MB;\n        p_curr_ctxt->u1_mb_type = CAB_I16x16;\n        ps_cur_mb_info->u1_tran_form8x8 = 0;\n        p_curr_ctxt->u1_transform8x8_ctxt = 0;\n        ps_cur_mb_info->ps_curmb->u1_tran_form8x8 = 0;\n \/*--------------------------------------------------------------------*\/\n \/* Read the IntraPrediction mode for CHROMA                           *\/\n \/*--------------------------------------------------------------------*\/\n        u1_intra_chrom_pred_mode = ih264d_parse_chroma_pred_mode_cabac(ps_dec);\n if(u1_intra_chrom_pred_mode > 3)\n return ERROR_CHROMA_PRED_MODE;\n\n        COPYTHECONTEXT(\"Chroma intra_chroma_pred_mode pred mode\", u1_intra_chrom_pred_mode);\n        p_curr_ctxt->u1_intra_chroma_pred_mode = ps_cur_mb_info->u1_chroma_pred_mode =\n                        u1_intra_chrom_pred_mode;\n\n \/*--------------------------------------------------------------------*\/\n \/* Read the Coded block pattern                                       *\/\n \/*--------------------------------------------------------------------*\/\n        u1_cbp = gau1_ih264d_cbp_tab[(u1_mb_type - 1) >> 2];\n        ps_cur_mb_info->u1_cbp = u1_cbp;\n        p_curr_ctxt->u1_cbp = u1_cbp;\n\n \/*--------------------------------------------------------------------*\/\n \/* Read mb_qp_delta                                                   *\/\n \/*--------------------------------------------------------------------*\/\n        ret = ih264d_parse_mb_qp_delta_cabac(ps_dec, &i1_delta_qp);\n if(ret != OK)\n return ret;\n        COPYTHECONTEXT(\"mb_qp_delta\", i1_delta_qp);\n if(i1_delta_qp != 0)\n {\n            ret = ih264d_update_qp(ps_dec, i1_delta_qp);\n if(ret != OK)\n return ret;\n }\n\n {\n            WORD16 i_scaleFactor;\n            WORD16* pi2_scale_matrix_ptr;\n \/*******************************************************************\/\n \/* for luma DC coefficients the scaling is done during the parsing *\/\n \/* to preserve the precision                                       *\/\n \/*******************************************************************\/\n if(ps_dec->s_high_profile.u1_scaling_present)\n {\n                pi2_scale_matrix_ptr =\n                                ps_dec->s_high_profile.i2_scalinglist4x4[0];\n\n }\n else\n {\n                i_scaleFactor = 16;\n                pi2_scale_matrix_ptr = &i_scaleFactor;\n }\n {\n ctxt_inc_mb_info_t *ps_top_ctxt = ps_dec->p_top_ctxt_mb_info;\n                UWORD8 uc_a, uc_b;\n                UWORD32 u4_ctx_inc;\n\n                INC_SYM_COUNT(&(ps_dec->s_cab_dec_env));\n\n \/* if MbAddrN not available then CondTermN = 1 *\/\n                uc_b = ((ps_top_ctxt->u1_yuv_dc_csbp) & 0x01);\n\n \/* if MbAddrN not available then CondTermN = 1 *\/\n                uc_a = ((ps_dec->pu1_left_yuv_dc_csbp[0]) & 0x01);\n\n                u4_ctx_inc = (uc_a + (uc_b << 1));\n\n {\n                    WORD16 pi2_dc_coef[16];\n tu_sblk4x4_coeff_data_t *ps_tu_4x4 =\n (tu_sblk4x4_coeff_data_t *)ps_dec->pv_parse_tu_coeff_data;\n                    WORD16 *pi2_coeff_block =\n (WORD16 *)ps_dec->pv_parse_tu_coeff_data;\n\n                    p_bin_ctxt = (ps_dec->p_cbf_t[LUMA_DC_CTXCAT]) + u4_ctx_inc;\n\n                    u1_dc_block_flag =\n                                    ih264d_read_coeff4x4_cabac(ps_bitstrm,\n                                                    LUMA_DC_CTXCAT,\n                                                    ps_dec->p_significant_coeff_flag_t[LUMA_DC_CTXCAT],\n                                                    ps_dec, p_bin_ctxt);\n\n \/* Store coded_block_flag *\/\n                    p_curr_ctxt->u1_yuv_dc_csbp &= 0xFE;\n                    p_curr_ctxt->u1_yuv_dc_csbp |= u1_dc_block_flag;\n if(u1_dc_block_flag)\n {\n                        WORD32 pi4_tmp[16];\n                        memset(pi2_dc_coef,0,sizeof(pi2_dc_coef));\n                        ih264d_unpack_coeff4x4_dc_4x4blk(ps_tu_4x4,\n                                                         pi2_dc_coef,\n                                                         ps_dec->pu1_inv_scan);\n\n                        PROFILE_DISABLE_IQ_IT_RECON()\n                        ps_dec->pf_ihadamard_scaling_4x4(pi2_dc_coef,\n                                                         pi2_coeff_block,\n                                                         ps_dec->pu2_quant_scale_y,\n (UWORD16 *)pi2_scale_matrix_ptr,\n                                                         ps_dec->u1_qp_y_div6,\n                                                         pi4_tmp);\n                        pi2_coeff_block += 16;\n                        ps_dec->pv_parse_tu_coeff_data = (void *)pi2_coeff_block;\n                        SET_BIT(ps_cur_mb_info->u1_yuv_dc_block_flag,0);\n }\n\n }\n\n }\n }\n }\n\n    ps_dec->pu1_left_yuv_dc_csbp[0] &= 0x6;\n    ps_dec->pu1_left_yuv_dc_csbp[0] |= u1_dc_block_flag;\n\n    ih264d_parse_residual4x4_cabac(ps_dec, ps_cur_mb_info, u1_offset);\n if(EXCEED_OFFSET(ps_bitstrm))\n return ERROR_EOB_TERMINATE_T;\n return OK;\n}\n","target":0,"code_token_length":2408,"total_token_length":2644,"max_tokens_setting":4096}
+{"idx":81855,"func":"static int __ip_append_data(struct sock *sk, struct sk_buff_head *queue,\n\t\t\t    struct inet_cork *cork,\n\t\t\t    int getfrag(void *from, char *to, int offset,\n\t\t\t\t\tint len, int odd, struct sk_buff *skb),\n\t\t\t    void *from, int length, int transhdrlen,\n\t\t\t    unsigned int flags)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct sk_buff *skb;\n\n\tstruct ip_options *opt = cork->opt;\n\tint hh_len;\n\tint exthdrlen;\n\tint mtu;\n\tint copy;\n\tint err;\n\tint offset = 0;\n\tunsigned int maxfraglen, fragheaderlen;\n\tint csummode = CHECKSUM_NONE;\n\tstruct rtable *rt = (struct rtable *)cork->dst;\n\n\texthdrlen = transhdrlen ? rt->dst.header_len : 0;\n\tlength += exthdrlen;\n\ttranshdrlen += exthdrlen;\n\tmtu = cork->fragsize;\n\n\thh_len = LL_RESERVED_SPACE(rt->dst.dev);\n\n\tfragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);\n\tmaxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;\n\n\tif (cork->length + length > 0xFFFF - fragheaderlen) {\n\t\tip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport,\n\t\t\t       mtu-exthdrlen);\n\t\treturn -EMSGSIZE;\n\t}\n\n\t\/*\n\t * transhdrlen > 0 means that this is the first fragment and we wish\n\t * it won't be fragmented in the future.\n\t *\/\n\tif (transhdrlen &&\n\t    length + fragheaderlen <= mtu &&\n\t    rt->dst.dev->features & NETIF_F_V4_CSUM &&\n\t    !exthdrlen)\n\t\tcsummode = CHECKSUM_PARTIAL;\n\n\tskb = skb_peek_tail(queue);\n\n\tcork->length += length;\n\tif (((length > mtu) || (skb && skb_is_gso(skb))) &&\n\t    (sk->sk_protocol == IPPROTO_UDP) &&\n\t    (rt->dst.dev->features & NETIF_F_UFO)) {\n\t\terr = ip_ufo_append_data(sk, queue, getfrag, from, length,\n\t\t\t\t\t hh_len, fragheaderlen, transhdrlen,\n\t\t\t\t\t mtu, flags);\n\t\tif (err)\n\t\t\tgoto error;\n\t\treturn 0;\n\t}\n\n\t\/* So, what's going on in the loop below?\n\t *\n\t * We use calculated fragment length to generate chained skb,\n\t * each of segments is IP fragment ready for sending to network after\n\t * adding appropriate IP header.\n\t *\/\n\n\tif (!skb)\n\t\tgoto alloc_new_skb;\n\n\twhile (length > 0) {\n\t\t\/* Check if the remaining data fits into current packet. *\/\n\t\tcopy = mtu - skb->len;\n\t\tif (copy < length)\n\t\t\tcopy = maxfraglen - skb->len;\n\t\tif (copy <= 0) {\n\t\t\tchar *data;\n\t\t\tunsigned int datalen;\n\t\t\tunsigned int fraglen;\n\t\t\tunsigned int fraggap;\n\t\t\tunsigned int alloclen;\n\t\t\tstruct sk_buff *skb_prev;\nalloc_new_skb:\n\t\t\tskb_prev = skb;\n\t\t\tif (skb_prev)\n\t\t\t\tfraggap = skb_prev->len - maxfraglen;\n\t\t\telse\n\t\t\t\tfraggap = 0;\n\n\t\t\t\/*\n\t\t\t * If remaining data exceeds the mtu,\n\t\t\t * we know we need more fragment(s).\n\t\t\t *\/\n\t\t\tdatalen = length + fraggap;\n\t\t\tif (datalen > mtu - fragheaderlen)\n\t\t\t\tdatalen = maxfraglen - fragheaderlen;\n\t\t\tfraglen = datalen + fragheaderlen;\n\n\t\t\tif ((flags & MSG_MORE) &&\n\t\t\t    !(rt->dst.dev->features&NETIF_F_SG))\n\t\t\t\talloclen = mtu;\n\t\t\telse\n\t\t\t\talloclen = fraglen;\n\n\t\t\t\/* The last fragment gets additional space at tail.\n\t\t\t * Note, with MSG_MORE we overallocate on fragments,\n\t\t\t * because we have no idea what fragment will be\n\t\t\t * the last.\n\t\t\t *\/\n\t\t\tif (datalen == length + fraggap) {\n\t\t\t\talloclen += rt->dst.trailer_len;\n\t\t\t\t\/* make sure mtu is not reached *\/\n\t\t\t\tif (datalen > mtu - fragheaderlen - rt->dst.trailer_len)\n\t\t\t\t\tdatalen -= ALIGN(rt->dst.trailer_len, 8);\n\t\t\t}\n\t\t\tif (transhdrlen) {\n\t\t\t\tskb = sock_alloc_send_skb(sk,\n\t\t\t\t\t\talloclen + hh_len + 15,\n\t\t\t\t\t\t(flags & MSG_DONTWAIT), &err);\n\t\t\t} else {\n\t\t\t\tskb = NULL;\n\t\t\t\tif (atomic_read(&sk->sk_wmem_alloc) <=\n\t\t\t\t    2 * sk->sk_sndbuf)\n\t\t\t\t\tskb = sock_wmalloc(sk,\n\t\t\t\t\t\t\t   alloclen + hh_len + 15, 1,\n\t\t\t\t\t\t\t   sk->sk_allocation);\n\t\t\t\tif (unlikely(skb == NULL))\n\t\t\t\t\terr = -ENOBUFS;\n\t\t\t\telse\n\t\t\t\t\t\/* only the initial fragment is\n\t\t\t\t\t   time stamped *\/\n\t\t\t\t\tcork->tx_flags = 0;\n\t\t\t}\n\t\t\tif (skb == NULL)\n\t\t\t\tgoto error;\n\n\t\t\t\/*\n\t\t\t *\tFill in the control structures\n\t\t\t *\/\n\t\t\tskb->ip_summed = csummode;\n\t\t\tskb->csum = 0;\n\t\t\tskb_reserve(skb, hh_len);\n\t\t\tskb_shinfo(skb)->tx_flags = cork->tx_flags;\n\n\t\t\t\/*\n\t\t\t *\tFind where to start putting bytes.\n\t\t\t *\/\n\t\t\tdata = skb_put(skb, fraglen);\n\t\t\tskb_set_network_header(skb, exthdrlen);\n\t\t\tskb->transport_header = (skb->network_header +\n\t\t\t\t\t\t fragheaderlen);\n\t\t\tdata += fragheaderlen;\n\n\t\t\tif (fraggap) {\n\t\t\t\tskb->csum = skb_copy_and_csum_bits(\n\t\t\t\t\tskb_prev, maxfraglen,\n\t\t\t\t\tdata + transhdrlen, fraggap, 0);\n\t\t\t\tskb_prev->csum = csum_sub(skb_prev->csum,\n\t\t\t\t\t\t\t  skb->csum);\n\t\t\t\tdata += fraggap;\n\t\t\t\tpskb_trim_unique(skb_prev, maxfraglen);\n\t\t\t}\n\n\t\t\tcopy = datalen - transhdrlen - fraggap;\n\t\t\tif (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, fraggap, skb) < 0) {\n\t\t\t\terr = -EFAULT;\n\t\t\t\tkfree_skb(skb);\n\t\t\t\tgoto error;\n\t\t\t}\n\n\t\t\toffset += copy;\n\t\t\tlength -= datalen - fraggap;\n\t\t\ttranshdrlen = 0;\n\t\t\texthdrlen = 0;\n\t\t\tcsummode = CHECKSUM_NONE;\n\n\t\t\t\/*\n\t\t\t * Put the packet on the pending queue.\n\t\t\t *\/\n\t\t\t__skb_queue_tail(queue, skb);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (copy > length)\n\t\t\tcopy = length;\n\n\t\tif (!(rt->dst.dev->features&NETIF_F_SG)) {\n\t\t\tunsigned int off;\n\n\t\t\toff = skb->len;\n\t\t\tif (getfrag(from, skb_put(skb, copy),\n\t\t\t\t\toffset, copy, off, skb) < 0) {\n\t\t\t\t__skb_trim(skb, off);\n\t\t\t\terr = -EFAULT;\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t} else {\n\t\t\tint i = skb_shinfo(skb)->nr_frags;\n\t\t\tskb_frag_t *frag = &skb_shinfo(skb)->frags[i-1];\n\t\t\tstruct page *page = cork->page;\n\t\t\tint off = cork->off;\n\t\t\tunsigned int left;\n\n\t\t\tif (page && (left = PAGE_SIZE - off) > 0) {\n\t\t\t\tif (copy >= left)\n\t\t\t\t\tcopy = left;\n\t\t\t\tif (page != frag->page) {\n\t\t\t\t\tif (i == MAX_SKB_FRAGS) {\n\t\t\t\t\t\terr = -EMSGSIZE;\n\t\t\t\t\t\tgoto error;\n\t\t\t\t\t}\n\t\t\t\t\tget_page(page);\n\t\t\t\t\tskb_fill_page_desc(skb, i, page, off, 0);\n\t\t\t\t\tfrag = &skb_shinfo(skb)->frags[i];\n\t\t\t\t}\n\t\t\t} else if (i < MAX_SKB_FRAGS) {\n\t\t\t\tif (copy > PAGE_SIZE)\n\t\t\t\t\tcopy = PAGE_SIZE;\n\t\t\t\tpage = alloc_pages(sk->sk_allocation, 0);\n\t\t\t\tif (page == NULL)  {\n\t\t\t\t\terr = -ENOMEM;\n\t\t\t\t\tgoto error;\n\t\t\t\t}\n\t\t\t\tcork->page = page;\n\t\t\t\tcork->off = 0;\n\n\t\t\t\tskb_fill_page_desc(skb, i, page, 0, 0);\n\t\t\t\tfrag = &skb_shinfo(skb)->frags[i];\n\t\t\t} else {\n\t\t\t\terr = -EMSGSIZE;\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\tif (getfrag(from, page_address(frag->page)+frag->page_offset+frag->size, offset, copy, skb->len, skb) < 0) {\n\t\t\t\terr = -EFAULT;\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\tcork->off += copy;\n\t\t\tfrag->size += copy;\n\t\t\tskb->len += copy;\n\t\t\tskb->data_len += copy;\n\t\t\tskb->truesize += copy;\n\t\t\tatomic_add(copy, &sk->sk_wmem_alloc);\n\t\t}\n\t\toffset += copy;\n\t\tlength -= copy;\n\t}\n\n\treturn 0;\n\nerror:\n\tcork->length -= length;\n\tIP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTDISCARDS);\n\treturn err;\n}","target":0,"code_token_length":2009,"total_token_length":2245,"max_tokens_setting":4096}
+{"idx":330671,"func":"static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,\n\n\tlong width, long height,\n\n\tlong lumStride, long chromStride, long srcStride)\n\n{\n\n\tlong y;\n\n\tconst long chromWidth= width>>1;\n\n\tfor(y=0; ytype);\n    p7->state = PKCS7_S_HEADER;\n\n    switch (i) {\n    case NID_pkcs7_signed:\n        data_body = PKCS7_get_octet_string(p7->d.sign->contents);\n        if (!PKCS7_is_detached(p7) && data_body == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                     PKCS7_R_INVALID_SIGNED_DATA_TYPE);\n            goto err;\n        }\n        md_sk = p7->d.sign->md_algs;\n        break;\n    case NID_pkcs7_signedAndEnveloped:\n        rsk = p7->d.signed_and_enveloped->recipientinfo;\n        md_sk = p7->d.signed_and_enveloped->md_algs;\n        data_body = p7->d.signed_and_enveloped->enc_data->enc_data;\n        enc_alg = p7->d.signed_and_enveloped->enc_data->algorithm;\n        evp_cipher = EVP_get_cipherbyobj(enc_alg->algorithm);\n        if (evp_cipher == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                     PKCS7_R_UNSUPPORTED_CIPHER_TYPE);\n            goto err;\n        }\n        break;\n    case NID_pkcs7_enveloped:\n        rsk = p7->d.enveloped->recipientinfo;\n        enc_alg = p7->d.enveloped->enc_data->algorithm;\n        data_body = p7->d.enveloped->enc_data->enc_data;\n        evp_cipher = EVP_get_cipherbyobj(enc_alg->algorithm);\n        if (evp_cipher == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                     PKCS7_R_UNSUPPORTED_CIPHER_TYPE);\n            goto err;\n        }\n        break;\n    default:\n        PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_UNSUPPORTED_CONTENT_TYPE);\n        goto err;\n    }\n\n    \/* We will be checking the signature *\/\n    if (md_sk != NULL) {\n        for (i = 0; i < sk_X509_ALGOR_num(md_sk); i++) {\n            xa = sk_X509_ALGOR_value(md_sk, i);\n            if ((btmp = BIO_new(BIO_f_md())) == NULL) {\n                PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_BIO_LIB);\n                goto err;\n            }\n\n            j = OBJ_obj2nid(xa->algorithm);\n            evp_md = EVP_get_digestbynid(j);\n            if (evp_md == NULL) {\n                PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                         PKCS7_R_UNKNOWN_DIGEST_TYPE);\n                goto err;\n            }\n\n            BIO_set_md(btmp, evp_md);\n            if (out == NULL)\n                out = btmp;\n            else\n                BIO_push(out, btmp);\n            btmp = NULL;\n        }\n    }\n\n    if (evp_cipher != NULL) {\n#if 0\n        unsigned char key[EVP_MAX_KEY_LENGTH];\n        unsigned char iv[EVP_MAX_IV_LENGTH];\n        unsigned char *p;\n        int keylen, ivlen;\n        int max;\n        X509_OBJECT ret;\n#endif\n\n        if ((etmp = BIO_new(BIO_f_cipher())) == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_BIO_LIB);\n            goto err;\n        }\n\n        \/*\n         * It was encrypted, we need to decrypt the secret key with the\n         * private key\n         *\/\n\n        \/*\n         * Find the recipientInfo which matches the passed certificate (if\n         * any)\n         *\/\n\n        if (pcert) {\n            for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) {\n                ri = sk_PKCS7_RECIP_INFO_value(rsk, i);\n                if (!pkcs7_cmp_ri(ri, pcert))\n                    break;\n                ri = NULL;\n            }\n            if (ri == NULL) {\n                PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                         PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE);\n                goto err;\n            }\n        }\n\n        \/* If we haven't got a certificate try each ri in turn *\/\n        if (pcert == NULL) {\n            \/*\n             * Always attempt to decrypt all rinfo even after sucess as a\n             * defence against MMA timing attacks.\n             *\/\n            for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) {\n                ri = sk_PKCS7_RECIP_INFO_value(rsk, i);\n\n                if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0)\n                    goto err;\n                ERR_clear_error();\n            }\n        } else {\n            \/* Only exit on fatal errors, not decrypt failure *\/\n            if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0)\n                goto err;\n            ERR_clear_error();\n        }\n\n        evp_ctx = NULL;\n        BIO_get_cipher_ctx(etmp, &evp_ctx);\n        if (EVP_CipherInit_ex(evp_ctx, evp_cipher, NULL, NULL, NULL, 0) <= 0)\n            goto err;\n        if (EVP_CIPHER_asn1_to_param(evp_ctx, enc_alg->parameter) < 0)\n            goto err;\n        \/* Generate random key as MMA defence *\/\n        tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx);\n        tkey = OPENSSL_malloc(tkeylen);\n        if (!tkey)\n            goto err;\n        if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0)\n            goto err;\n        if (ek == NULL) {\n            ek = tkey;\n            eklen = tkeylen;\n            tkey = NULL;\n        }\n\n        if (eklen != EVP_CIPHER_CTX_key_length(evp_ctx)) {\n            \/*\n             * Some S\/MIME clients don't use the same key and effective key\n             * length. The key length is determined by the size of the\n             * decrypted RSA key.\n             *\/\n            if (!EVP_CIPHER_CTX_set_key_length(evp_ctx, eklen)) {\n                \/* Use random key as MMA defence *\/\n                OPENSSL_cleanse(ek, eklen);\n                OPENSSL_free(ek);\n                ek = tkey;\n                eklen = tkeylen;\n                tkey = NULL;\n            }\n        }\n        \/* Clear errors so we don't leak information useful in MMA *\/\n        ERR_clear_error();\n        if (EVP_CipherInit_ex(evp_ctx, NULL, NULL, ek, NULL, 0) <= 0)\n            goto err;\n\n        if (ek) {\n            OPENSSL_cleanse(ek, eklen);\n            OPENSSL_free(ek);\n            ek = NULL;\n        }\n        if (tkey) {\n            OPENSSL_cleanse(tkey, tkeylen);\n            OPENSSL_free(tkey);\n            tkey = NULL;\n        }\n\n        if (out == NULL)\n            out = etmp;\n        else\n            BIO_push(out, etmp);\n        etmp = NULL;\n    }\n#if 1\n    if (PKCS7_is_detached(p7) || (in_bio != NULL)) {\n        bio = in_bio;\n    } else {\n# if 0\n        bio = BIO_new(BIO_s_mem());\n        \/*\n         * We need to set this so that when we have read all the data, the\n         * encrypt BIO, if present, will read EOF and encode the last few\n         * bytes\n         *\/\n        BIO_set_mem_eof_return(bio, 0);\n\n        if (data_body->length > 0)\n            BIO_write(bio, (char *)data_body->data, data_body->length);\n# else\n        if (data_body->length > 0)\n            bio = BIO_new_mem_buf(data_body->data, data_body->length);\n        else {\n            bio = BIO_new(BIO_s_mem());\n            BIO_set_mem_eof_return(bio, 0);\n        }\n        if (bio == NULL)\n            goto err;\n# endif\n    }\n    BIO_push(out, bio);\n    bio = NULL;\n#endif\n    if (0) {\n err:\n        if (ek) {\n            OPENSSL_cleanse(ek, eklen);\n            OPENSSL_free(ek);\n        }\n        if (tkey) {\n            OPENSSL_cleanse(tkey, tkeylen);\n            OPENSSL_free(tkey);\n        }\n        if (out != NULL)\n            BIO_free_all(out);\n        if (btmp != NULL)\n            BIO_free_all(btmp);\n        if (etmp != NULL)\n            BIO_free_all(etmp);\n        if (bio != NULL)\n            BIO_free_all(bio);\n        out = NULL;\n    }\n    return (out);\n}","target":1,"code_token_length":2121,"total_token_length":2357,"max_tokens_setting":4096}
+{"idx":411232,"func":"    **\/\n    CImg& dilate(const unsigned int sx, const unsigned int sy, const unsigned int sz=1) {\n      if (is_empty() || (sx==1 && sy==1 && sz==1)) return *this;\n      if (sx>1 && _width>1) { \/\/ Along X-axis.\n        const int L = width(), off = 1, s = (int)sx, _s1 = s\/2, _s2 = s - _s1, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2;\n        CImg buf(L);\n        cimg_pragma_openmp(parallel for collapse(3) firstprivate(buf) if (size()>524288))\n        cimg_forYZC(*this,y,z,c) {\n          T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1;\n          const T *const ptrsb = data(0,y,z,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off;\n          T cur = *ptrs; ptrs+=off; bool is_first = true;\n          for (int p = s2 - 1; p>0 && ptrs<=ptrse; --p) {\n            const T val = *ptrs; ptrs+=off; if (val>=cur) { cur = val; is_first = false; }\n          }\n          *(ptrd++) = cur;\n          if (ptrs>=ptrse) {\n            T *pd = data(0,y,z,c); cur = std::max(cur,*ptrse); cimg_forX(buf,x) { *pd = cur; pd+=off; }\n          } else {\n            for (int p = s1; p>0 && ptrd<=ptrde; --p) {\n              const T val = *ptrs; if (ptrs=cur) { cur = val; is_first = false; }\n              *(ptrd++) = cur;\n            }\n            for (int p = L - s - 1; p>0; --p) {\n              const T val = *ptrs; ptrs+=off;\n              if (is_first) {\n                const T *nptrs = ptrs - off; cur = val;\n                for (int q = s - 2; q>0; --q) { nptrs-=off; const T nval = *nptrs; if (nval>cur) cur = nval; }\n                nptrs-=off; const T nval = *nptrs; if (nval>cur) { cur = nval; is_first = true; } else is_first = false;\n              } else { if (val>=cur) cur = val; else if (cur==*(ptrs-s*off)) is_first = true; }\n              *(ptrd++) = cur;\n            }\n            ptrd = ptrde; ptrs = ptrse; cur = *ptrs; ptrs-=off;\n            for (int p = s1; p>0 && ptrs>=ptrsb; --p) {\n              const T val = *ptrs; ptrs-=off; if (val>cur) cur = val;\n            }\n            *(ptrd--) = cur;\n            for (int p = s2 - 1; p>0 && ptrd>=ptrdb; --p) {\n              const T val = *ptrs; if (ptrs>ptrsb) ptrs-=off; if (val>cur) cur = val; *(ptrd--) = cur;\n            }\n            T *pd = data(0,y,z,c); cimg_for(buf,ps,T) { *pd = *ps; pd+=off; }\n          }\n        }\n      }\n\n      if (sy>1 && _height>1) { \/\/ Along Y-axis.\n        const int L = height(), off = width(), s = (int)sy, _s1 = s\/2, _s2 = s - _s1, s1 = _s1>L?L:_s1,\n          s2 = _s2>L?L:_s2;\n        CImg buf(L);\n        cimg_pragma_openmp(parallel for collapse(3) firstprivate(buf) if (size()>524288))\n        cimg_forXZC(*this,x,z,c) {\n          T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1;\n          const T *const ptrsb = data(x,0,z,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off;\n          T cur = *ptrs; ptrs+=off; bool is_first = true;\n          for (int p = s2 - 1; p>0 && ptrs<=ptrse; --p) {\n            const T val = *ptrs; ptrs+=off; if (val>=cur) { cur = val; is_first = false; }\n          }\n          *(ptrd++) = cur;\n          if (ptrs>=ptrse) {\n            T *pd = data(x,0,z,c); cur = std::max(cur,*ptrse); cimg_forX(buf,x) { *pd = cur; pd+=off; }\n          } else {\n            for (int p = s1; p>0 && ptrd<=ptrde; --p) {\n              const T val = *ptrs; if (ptrs=cur) { cur = val; is_first = false; }\n              *(ptrd++) = cur;\n            }\n            for (int p = L - s - 1; p>0; --p) {\n              const T val = *ptrs; ptrs+=off;\n              if (is_first) {\n                const T *nptrs = ptrs - off; cur = val;\n                for (int q = s - 2; q>0; --q) { nptrs-=off; const T nval = *nptrs; if (nval>cur) cur = nval; }\n                nptrs-=off; const T nval = *nptrs; if (nval>cur) { cur = nval; is_first = true; } else is_first = false;\n              } else { if (val>=cur) cur = val; else if (cur==*(ptrs-s*off)) is_first = true; }\n              *(ptrd++) = cur;\n            }\n            ptrd = ptrde; ptrs = ptrse; cur = *ptrs; ptrs-=off;\n            for (int p = s1; p>0 && ptrs>=ptrsb; --p) {\n              const T val = *ptrs; ptrs-=off; if (val>cur) cur = val;\n            }\n            *(ptrd--) = cur;\n            for (int p = s2 - 1; p>0 && ptrd>=ptrdb; --p) {\n              const T val = *ptrs; if (ptrs>ptrsb) ptrs-=off; if (val>cur) cur = val; *(ptrd--) = cur;\n            }\n            T *pd = data(x,0,z,c); cimg_for(buf,ps,T) { *pd = *ps; pd+=off; }\n          }\n        }\n      }\n\n      if (sz>1 && _depth>1) { \/\/ Along Z-axis.\n        const int L = depth(), off = width()*height(), s = (int)sz, _s1 = s\/2, _s2 = s - _s1, s1 = _s1>L?L:_s1,\n          s2 = _s2>L?L:_s2;\n        CImg buf(L);\n        cimg_pragma_openmp(parallel for collapse(3) firstprivate(buf) if (size()>524288))\n        cimg_forXYC(*this,x,y,c) {\n          T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1;\n          const T *const ptrsb = data(x,y,0,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off;\n          T cur = *ptrs; ptrs+=off; bool is_first = true;\n          for (int p = s2 - 1; p>0 && ptrs<=ptrse; --p) {\n            const T val = *ptrs; ptrs+=off; if (val>=cur) { cur = val; is_first = false; }\n          }\n          *(ptrd++) = cur;\n          if (ptrs>=ptrse) {\n            T *pd = data(x,y,0,c); cur = std::max(cur,*ptrse); cimg_forX(buf,x) { *pd = cur; pd+=off; }\n          } else {\n            for (int p = s1; p>0 && ptrd<=ptrde; --p) {\n              const T val = *ptrs; if (ptrs=cur) { cur = val; is_first = false; }\n              *(ptrd++) = cur;\n            }\n            for (int p = L - s - 1; p>0; --p) {\n              const T val = *ptrs; ptrs+=off;\n              if (is_first) {\n                const T *nptrs = ptrs - off; cur = val;\n                for (int q = s - 2; q>0; --q) { nptrs-=off; const T nval = *nptrs; if (nval>cur) cur = nval; }\n                nptrs-=off; const T nval = *nptrs; if (nval>cur) { cur = nval; is_first = true; } else is_first = false;\n              } else { if (val>=cur) cur = val; else if (cur==*(ptrs-s*off)) is_first = true; }\n              *(ptrd++) = cur;\n            }\n            ptrd = ptrde; ptrs = ptrse; cur = *ptrs; ptrs-=off;\n            for (int p = s1; p>0 && ptrs>=ptrsb; --p) {\n              const T val = *ptrs; ptrs-=off; if (val>cur) cur = val;\n            }\n            *(ptrd--) = cur;\n            for (int p = s2 - 1; p>0 && ptrd>=ptrdb; --p) {\n              const T val = *ptrs; if (ptrs>ptrsb) ptrs-=off; if (val>cur) cur = val; *(ptrd--) = cur;\n            }\n            T *pd = data(x,y,0,c); cimg_for(buf,ps,T) { *pd = *ps; pd+=off; }\n          }\n        }\n      }\n      return *this;","target":0,"code_token_length":2420,"total_token_length":2656,"max_tokens_setting":4096}
+{"idx":17488,"func":"int ff_h263_decode_picture_header ( MpegEncContext * s ) {\n int format , width , height , i ;\n uint32_t startcode ;\n align_get_bits ( & s -> gb ) ;\n startcode = get_bits ( & s -> gb , 22 - 8 ) ;\n for ( i = get_bits_left ( & s -> gb ) ;\n i > 24 ;\n i -= 8 ) {\n startcode = ( ( startcode << 8 ) | get_bits ( & s -> gb , 8 ) ) & 0x003FFFFF ;\n if ( startcode == 0x20 ) break ;\n }\n if ( startcode != 0x20 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Bad picture start code\\n\" ) ;\n return - 1 ;\n }\n i = get_bits ( & s -> gb , 8 ) ;\n if ( ( s -> picture_number & ~ 0xFF ) + i < s -> picture_number ) i += 256 ;\n s -> current_picture_ptr -> f . pts = s -> picture_number = ( s -> picture_number & ~ 0xFF ) + i ;\n if ( get_bits1 ( & s -> gb ) != 1 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Bad marker\\n\" ) ;\n return - 1 ;\n }\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Bad H263 id\\n\" ) ;\n return - 1 ;\n }\n skip_bits1 ( & s -> gb ) ;\n skip_bits1 ( & s -> gb ) ;\n skip_bits1 ( & s -> gb ) ;\n format = get_bits ( & s -> gb , 3 ) ;\n if ( format != 7 && format != 6 ) {\n s -> h263_plus = 0 ;\n width = ff_h263_format [ format ] [ 0 ] ;\n height = ff_h263_format [ format ] [ 1 ] ;\n if ( ! width ) return - 1 ;\n s -> pict_type = AV_PICTURE_TYPE_I + get_bits1 ( & s -> gb ) ;\n s -> h263_long_vectors = get_bits1 ( & s -> gb ) ;\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"H263 SAC not supported\\n\" ) ;\n return - 1 ;\n }\n s -> obmc = get_bits1 ( & s -> gb ) ;\n s -> unrestricted_mv = s -> h263_long_vectors || s -> obmc ;\n s -> pb_frame = get_bits1 ( & s -> gb ) ;\n s -> chroma_qscale = s -> qscale = get_bits ( & s -> gb , 5 ) ;\n skip_bits1 ( & s -> gb ) ;\n s -> width = width ;\n s -> height = height ;\n s -> avctx -> sample_aspect_ratio = ( AVRational ) {\n 12 , 11 }\n ;\n s -> avctx -> time_base = ( AVRational ) {\n 1001 , 30000 }\n ;\n }\n else {\n int ufep ;\n s -> h263_plus = 1 ;\n ufep = get_bits ( & s -> gb , 3 ) ;\n if ( ufep == 1 ) {\n format = get_bits ( & s -> gb , 3 ) ;\n av_dlog ( s -> avctx , \"ufep=1, format: %d\\n\" , format ) ;\n s -> custom_pcf = get_bits1 ( & s -> gb ) ;\n s -> umvplus = get_bits1 ( & s -> gb ) ;\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Syntax-based Arithmetic Coding (SAC) not supported\\n\" ) ;\n }\n s -> obmc = get_bits1 ( & s -> gb ) ;\n s -> h263_aic = get_bits1 ( & s -> gb ) ;\n s -> loop_filter = get_bits1 ( & s -> gb ) ;\n s -> unrestricted_mv = s -> umvplus || s -> obmc || s -> loop_filter ;\n s -> h263_slice_structured = get_bits1 ( & s -> gb ) ;\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Reference Picture Selection not supported\\n\" ) ;\n }\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Independent Segment Decoding not supported\\n\" ) ;\n }\n s -> alt_inter_vlc = get_bits1 ( & s -> gb ) ;\n s -> modified_quant = get_bits1 ( & s -> gb ) ;\n if ( s -> modified_quant ) s -> chroma_qscale_table = ff_h263_chroma_qscale_table ;\n skip_bits ( & s -> gb , 1 ) ;\n skip_bits ( & s -> gb , 3 ) ;\n }\n else if ( ufep != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"Bad UFEP type (%d)\\n\" , ufep ) ;\n return - 1 ;\n }\n s -> pict_type = get_bits ( & s -> gb , 3 ) ;\n switch ( s -> pict_type ) {\n case 0 : s -> pict_type = AV_PICTURE_TYPE_I ;\n break ;\n case 1 : s -> pict_type = AV_PICTURE_TYPE_P ;\n break ;\n case 2 : s -> pict_type = AV_PICTURE_TYPE_P ;\n s -> pb_frame = 3 ;\n break ;\n case 3 : s -> pict_type = AV_PICTURE_TYPE_B ;\n break ;\n case 7 : s -> pict_type = AV_PICTURE_TYPE_I ;\n break ;\n default : return - 1 ;\n }\n skip_bits ( & s -> gb , 2 ) ;\n s -> no_rounding = get_bits1 ( & s -> gb ) ;\n skip_bits ( & s -> gb , 4 ) ;\n if ( ufep ) {\n if ( format == 6 ) {\n s -> aspect_ratio_info = get_bits ( & s -> gb , 4 ) ;\n av_dlog ( s -> avctx , \"aspect: %d\\n\" , s -> aspect_ratio_info ) ;\n width = ( get_bits ( & s -> gb , 9 ) + 1 ) * 4 ;\n skip_bits1 ( & s -> gb ) ;\n height = get_bits ( & s -> gb , 9 ) * 4 ;\n av_dlog ( s -> avctx , \"\\nH.263+ Custom picture: %dx%d\\n\" , width , height ) ;\n if ( s -> aspect_ratio_info == FF_ASPECT_EXTENDED ) {\n s -> avctx -> sample_aspect_ratio . num = get_bits ( & s -> gb , 8 ) ;\n s -> avctx -> sample_aspect_ratio . den = get_bits ( & s -> gb , 8 ) ;\n }\n else {\n s -> avctx -> sample_aspect_ratio = ff_h263_pixel_aspect [ s -> aspect_ratio_info ] ;\n }\n }\n else {\n width = ff_h263_format [ format ] [ 0 ] ;\n height = ff_h263_format [ format ] [ 1 ] ;\n s -> avctx -> sample_aspect_ratio = ( AVRational ) {\n 12 , 11 }\n ;\n }\n if ( ( width == 0 ) || ( height == 0 ) ) return - 1 ;\n s -> width = width ;\n s -> height = height ;\n if ( s -> custom_pcf ) {\n int gcd ;\n s -> avctx -> time_base . den = 1800000 ;\n s -> avctx -> time_base . num = 1000 + get_bits1 ( & s -> gb ) ;\n s -> avctx -> time_base . num *= get_bits ( & s -> gb , 7 ) ;\n if ( s -> avctx -> time_base . num == 0 ) {\n av_log ( s , AV_LOG_ERROR , \"zero framerate\\n\" ) ;\n return - 1 ;\n }\n gcd = av_gcd ( s -> avctx -> time_base . den , s -> avctx -> time_base . num ) ;\n s -> avctx -> time_base . den \/= gcd ;\n s -> avctx -> time_base . num \/= gcd ;\n }\n else {\n s -> avctx -> time_base = ( AVRational ) {\n 1001 , 30000 }\n ;\n }\n }\n if ( s -> custom_pcf ) {\n skip_bits ( & s -> gb , 2 ) ;\n }\n if ( ufep ) {\n if ( s -> umvplus ) {\n if ( get_bits1 ( & s -> gb ) == 0 ) skip_bits1 ( & s -> gb ) ;\n }\n if ( s -> h263_slice_structured ) {\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"rectangular slices not supported\\n\" ) ;\n }\n if ( get_bits1 ( & s -> gb ) != 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"unordered slices not supported\\n\" ) ;\n }\n }\n }\n s -> qscale = get_bits ( & s -> gb , 5 ) ;\n }\n s -> mb_width = ( s -> width + 15 ) \/ 16 ;\n s -> mb_height = ( s -> height + 15 ) \/ 16 ;\n s -> mb_num = s -> mb_width * s -> mb_height ;\n if ( s -> pb_frame ) {\n skip_bits ( & s -> gb , 3 ) ;\n if ( s -> custom_pcf ) skip_bits ( & s -> gb , 2 ) ;\n skip_bits ( & s -> gb , 2 ) ;\n }\n if ( s -> pict_type != AV_PICTURE_TYPE_B ) {\n s -> time = s -> picture_number ;\n s -> pp_time = s -> time - s -> last_non_b_time ;\n s -> last_non_b_time = s -> time ;\n }\n else {\n s -> time = s -> picture_number ;\n s -> pb_time = s -> pp_time - ( s -> last_non_b_time - s -> time ) ;\n if ( s -> pp_time <= s -> pb_time || s -> pp_time <= s -> pp_time - s -> pb_time || s -> pp_time <= 0 ) {\n s -> pp_time = 2 ;\n s -> pb_time = 1 ;\n }\n ff_mpeg4_init_direct_mv ( s ) ;\n }\n while ( get_bits1 ( & s -> gb ) != 0 ) {\n skip_bits ( & s -> gb , 8 ) ;\n }\n if ( s -> h263_slice_structured ) {\n if ( get_bits1 ( & s -> gb ) != 1 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"SEPB1 marker missing\\n\" ) ;\n return - 1 ;\n }\n ff_h263_decode_mba ( s ) ;\n if ( get_bits1 ( & s -> gb ) != 1 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"SEPB2 marker missing\\n\" ) ;\n return - 1 ;\n }\n }\n s -> f_code = 1 ;\n if ( s -> h263_aic ) {\n s -> y_dc_scale_table = s -> c_dc_scale_table = ff_aic_dc_scale_table ;\n }\n else {\n s -> y_dc_scale_table = s -> c_dc_scale_table = ff_mpeg1_dc_scale_table ;\n }\n ff_h263_show_pict_info ( s ) ;\n if ( s -> pict_type == AV_PICTURE_TYPE_I && s -> codec_tag == AV_RL32 ( \"ZYGO\" ) ) {\n int i , j ;\n for ( i = 0 ;\n i < 85 ;\n i ++ ) av_log ( s -> avctx , AV_LOG_DEBUG , \"%d\" , get_bits1 ( & s -> gb ) ) ;\n av_log ( s -> avctx , AV_LOG_DEBUG , \"\\n\" ) ;\n for ( i = 0 ;\n i < 13 ;\n i ++ ) {\n for ( j = 0 ;\n j < 3 ;\n j ++ ) {\n int v = get_bits ( & s -> gb , 8 ) ;\n v |= get_sbits ( & s -> gb , 8 ) << 8 ;\n av_log ( s -> avctx , AV_LOG_DEBUG , \" %5d\" , v ) ;\n }\n av_log ( s -> avctx , AV_LOG_DEBUG , \"\\n\" ) ;\n }\n for ( i = 0 ;\n i < 50 ;\n i ++ ) av_log ( s -> avctx , AV_LOG_DEBUG , \"%d\" , get_bits1 ( & s -> gb ) ) ;\n }\n return 0 ;\n }","target":0,"code_token_length":2703,"total_token_length":2939,"max_tokens_setting":4096}
+{"idx":182339,"func":" void MigrationTest::SetUpVersion67Database() {\n  sql::Connection connection;\n  ASSERT_TRUE(connection.Open(GetDatabasePath()));\n  ASSERT_TRUE(connection.BeginTransaction());\n  ASSERT_TRUE(connection.Execute(\n      \"CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), \"\n          \"value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);\"\n      \"CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,\"\n          \"base_version bigint default -1,server_version bigint default 0,\"\n          \"mtime bigint default 0,server_mtime bigint default 0,\"\n          \"ctime bigint default 0,server_ctime bigint default 0,\"\n          \"server_position_in_parent bigint default 0,\"\n          \"local_external_id bigint default 0,id varchar(255) default 'r',\"\n          \"parent_id varchar(255) default 'r',\"\n          \"server_parent_id varchar(255) default 'r',\"\n          \"prev_id varchar(255) default 'r',next_id varchar(255) default 'r',\"\n          \"is_unsynced bit default 0,is_unapplied_update bit default 0,\"\n          \"is_del bit default 0,is_dir bit default 0,\"\n          \"is_bookmark_object bit default 0,server_is_dir bit default 0,\"\n          \"server_is_del bit default 0,server_is_bookmark_object bit default 0,\"\n          \"name varchar(255), \"  \/* COLLATE PATHNAME, *\/\n          \"unsanitized_name varchar(255),\" \/* COLLATE PATHNAME, *\/\n          \"non_unique_name varchar,\"\n          \"server_name varchar(255),\"  \/* COLLATE PATHNAME *\/\n          \"server_non_unique_name varchar,\"\n           \"bookmark_url varchar,server_bookmark_url varchar,\"\n           \"singleton_tag varchar,bookmark_favicon blob,\"\n           \"server_bookmark_favicon blob);\"\n      \"INSERT INTO metas VALUES(1,-1,0,129079956640320000,0,\"\n          \"129079956640320000,0,0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,\"\n           \"NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);\"\n      \"INSERT INTO metas VALUES(2,669,669,128976886618480000,\"\n          \"128976886618480000,128976886618480000,128976886618480000,-2097152,\"\n           \"4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,\"\n           \"'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item',\"\n           \"'http:\/\/www.google.com\/','http:\/\/www.google.com\/2',NULL,'AASGASGA',\"\n           \"'ASADGADGADG');\"\n      \"INSERT INTO metas VALUES(4,681,681,129002163642690000,\"\n          \"129002163642690000,129002163642690000,129002163642690000,-3145728,\"\n           \"3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,\"\n           \"'Welcome to Chromium',NULL,'Welcome to Chromium',\"\n           \"'Welcome to Chromium','Welcome to Chromium',\"\n           \"'http:\/\/www.google.com\/chrome\/intl\/en\/welcome.html',\"\n           \"'http:\/\/www.google.com\/chrome\/intl\/en\/welcome.html',NULL,NULL,\"\n           \"NULL);\"\n      \"INSERT INTO metas VALUES(5,677,677,129001555500000000,\"\n          \"129001555500000000,129001555500000000,129001555500000000,1048576,\"\n           \"7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,\"\n           \"'Google',NULL,'Google','Google','Google','http:\/\/www.google.com\/',\"\n           \"'http:\/\/www.google.com\/',NULL,'AGASGASG','AGFDGASG');\"\n      \"INSERT INTO metas VALUES(6,694,694,129053976170000000,\"\n          \"129053976170000000,129053976170000000,129053976170000000,-4194304,\"\n           \"6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,\"\n           \"'The Internet',NULL,'The Internet','The Internet',\"\n           \"'The Internet',NULL,NULL,NULL,NULL,NULL);\"\n      \"INSERT INTO metas VALUES(7,663,663,128976864758480000,\"\n          \"128976864758480000,128976864758480000,128976864758480000,\"\n           \"1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,\"\n           \"'Google Chrome',NULL,'Google Chrome','Google Chrome',\"\n           \"'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);\"\n      \"INSERT INTO metas VALUES(8,664,664,128976864758480000,\"\n          \"128976864758480000,128976864758480000,128976864758480000,1048576,\"\n           \"0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',\"\n           \"NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL,\"\n           \"'google_chrome_bookmarks',NULL,NULL);\"\n      \"INSERT INTO metas VALUES(9,665,665,128976864758480000,\"\n          \"128976864758480000,128976864758480000,128976864758480000,\"\n           \"1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,\"\n           \"1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar',\"\n           \"NULL,NULL,'bookmark_bar',NULL,NULL);\"\n      \"INSERT INTO metas VALUES(10,666,666,128976864758480000,\"\n          \"128976864758480000,128976864758480000,128976864758480000,2097152,\"\n           \"2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,\"\n           \"'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks',\"\n           \"'Other Bookmarks',NULL,NULL,'other_bookmarks',\"\n           \"NULL,NULL);\"\n      \"INSERT INTO metas VALUES(11,683,683,129079956948440000,\"\n          \"129079956948440000,129079956948440000,129079956948440000,-1048576,\"\n           \"8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,\"\n           \"'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)',\"\n           \"'Home (The Chromium Projects)','Home (The Chromium Projects)',\"\n           \"'http:\/\/dev.chromium.org\/','http:\/\/dev.chromium.org\/other',NULL,\"\n           \"'AGATWA','AFAGVASF');\"\n      \"INSERT INTO metas VALUES(12,685,685,129079957513650000,\"\n          \"129079957513650000,129079957513650000,129079957513650000,0,9,\"\n           \"'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,\"\n           \"'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks',\"\n           \"'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);\"\n      \"INSERT INTO metas VALUES(13,687,687,129079957985300000,\"\n          \"129079957985300000,129079957985300000,129079957985300000,-917504,\"\n           \"10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,\"\n           \"1,'ICANN | Internet Corporation for Assigned Names and Numbers',\"\n           \"'ICANN  Internet Corporation for Assigned Names and Numbers',\"\n          \"'ICANN | Internet Corporation for Assigned Names and Numbers',\"\n          \"'ICANN | Internet Corporation for Assigned Names and Numbers',\"\n           \"'ICANN | Internet Corporation for Assigned Names and Numbers',\"\n           \"'http:\/\/www.icann.com\/','http:\/\/www.icann.com\/',NULL,\"\n           \"'PNGAXF0AAFF','DAAFASF');\"\n      \"INSERT INTO metas VALUES(14,692,692,129079958383000000,\"\n          \"129079958383000000,129079958383000000,129079958383000000,1048576,\"\n           \"11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,\"\n           \"'The WebKit Open Source Project',NULL,\"\n           \"'The WebKit Open Source Project','The WebKit Open Source Project',\"\n          \"'The WebKit Open Source Project','http:\/\/webkit.org\/',\"\n          \"'http:\/\/webkit.org\/x',NULL,'PNGX','PNG2Y');\"\n      \"CREATE TABLE share_info (id VARCHAR(128) primary key, \"\n          \"last_sync_timestamp INT, name VARCHAR(128), \"\n          \"initial_sync_ended BIT default 0, store_birthday VARCHAR(256), \"\n          \"db_create_version VARCHAR(128), db_create_time int, \"\n          \"next_id bigint default -2, cache_guid VARCHAR(32));\"\n      \"INSERT INTO share_info VALUES('nick@chromium.org',694,\"\n          \"'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',\"\n          \"'Unknown',1263522064,-65542,\"\n          \"'9010788312004066376x-6609234393368420856x');\"\n      \"CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);\"\n      \"INSERT INTO share_version VALUES('nick@chromium.org',68);\"));\n  ASSERT_TRUE(connection.CommitTransaction());\n}\n","target":0,"code_token_length":3109,"total_token_length":3345,"max_tokens_setting":4096}
+{"idx":340975,"func":"void helper_set_cp15(CPUState *env, uint32_t insn, uint32_t val)\n\n{\n\n    uint32_t op2;\n\n    uint32_t crm;\n\n\n\n    op2 = (insn >> 5) & 7;\n\n    crm = insn & 0xf;\n\n    switch ((insn >> 16) & 0xf) {\n\n    case 0: \/* ID codes.  *\/\n\n        if (arm_feature(env, ARM_FEATURE_XSCALE))\n\n            break;\n\n        if (arm_feature(env, ARM_FEATURE_OMAPCP))\n\n            break;\n\n        goto bad_reg;\n\n    case 1: \/* System configuration.  *\/\n\n        if (arm_feature(env, ARM_FEATURE_OMAPCP))\n\n            op2 = 0;\n\n        switch (op2) {\n\n        case 0:\n\n            if (!arm_feature(env, ARM_FEATURE_XSCALE) || crm == 0)\n\n                env->cp15.c1_sys = val;\n\n            \/* ??? Lots of these bits are not implemented.  *\/\n\n            \/* This may enable\/disable the MMU, so do a TLB flush.  *\/\n\n            tlb_flush(env, 1);\n\n            break;\n\n        case 1:\n\n            if (arm_feature(env, ARM_FEATURE_XSCALE)) {\n\n                env->cp15.c1_xscaleauxcr = val;\n\n                break;\n\n            }\n\n            goto bad_reg;\n\n        case 2:\n\n            if (arm_feature(env, ARM_FEATURE_XSCALE))\n\n                goto bad_reg;\n\n            env->cp15.c1_coproc = val;\n\n            \/* ??? Is this safe when called from within a TB?  *\/\n\n            tb_flush(env);\n\n            break;\n\n        default:\n\n            goto bad_reg;\n\n        }\n\n        break;\n\n    case 2: \/* MMU Page table control \/ MPU cache control.  *\/\n\n        if (arm_feature(env, ARM_FEATURE_MPU)) {\n\n            switch (op2) {\n\n            case 0:\n\n                env->cp15.c2_data = val;\n\n                break;\n\n            case 1:\n\n                env->cp15.c2_insn = val;\n\n                break;\n\n            default:\n\n                goto bad_reg;\n\n            }\n\n        } else {\n\n            env->cp15.c2_base = val;\n\n        }\n\n        break;\n\n    case 3: \/* MMU Domain access control \/ MPU write buffer control.  *\/\n\n        env->cp15.c3 = val;\n\n        break;\n\n    case 4: \/* Reserved.  *\/\n\n        goto bad_reg;\n\n    case 5: \/* MMU Fault status \/ MPU access permission.  *\/\n\n        if (arm_feature(env, ARM_FEATURE_OMAPCP))\n\n            op2 = 0;\n\n        switch (op2) {\n\n        case 0:\n\n            if (arm_feature(env, ARM_FEATURE_MPU))\n\n                val = extended_mpu_ap_bits(val);\n\n            env->cp15.c5_data = val;\n\n            break;\n\n        case 1:\n\n            if (arm_feature(env, ARM_FEATURE_MPU))\n\n                val = extended_mpu_ap_bits(val);\n\n            env->cp15.c5_insn = val;\n\n            break;\n\n        case 2:\n\n            if (!arm_feature(env, ARM_FEATURE_MPU))\n\n                goto bad_reg;\n\n            env->cp15.c5_data = val;\n\n            break;\n\n        case 3:\n\n            if (!arm_feature(env, ARM_FEATURE_MPU))\n\n                goto bad_reg;\n\n            env->cp15.c5_insn = val;\n\n            break;\n\n        default:\n\n            goto bad_reg;\n\n        }\n\n        break;\n\n    case 6: \/* MMU Fault address \/ MPU base\/size.  *\/\n\n        if (arm_feature(env, ARM_FEATURE_MPU)) {\n\n            if (crm >= 8)\n\n                goto bad_reg;\n\n            env->cp15.c6_region[crm] = val;\n\n        } else {\n\n            if (arm_feature(env, ARM_FEATURE_OMAPCP))\n\n                op2 = 0;\n\n            switch (op2) {\n\n            case 0:\n\n                env->cp15.c6_data = val;\n\n                break;\n\n            case 1:\n\n                env->cp15.c6_insn = val;\n\n                break;\n\n            default:\n\n                goto bad_reg;\n\n            }\n\n        }\n\n        break;\n\n    case 7: \/* Cache control.  *\/\n\n        env->cp15.c15_i_max = 0x000;\n\n        env->cp15.c15_i_min = 0xff0;\n\n        \/* No cache, so nothing to do.  *\/\n\n        break;\n\n    case 8: \/* MMU TLB control.  *\/\n\n        switch (op2) {\n\n        case 0: \/* Invalidate all.  *\/\n\n            tlb_flush(env, 0);\n\n            break;\n\n        case 1: \/* Invalidate single TLB entry.  *\/\n\n#if 0\n\n            \/* ??? This is wrong for large pages and sections.  *\/\n\n            \/* As an ugly hack to make linux work we always flush a 4K\n\n               pages.  *\/\n\n            val &= 0xfffff000;\n\n            tlb_flush_page(env, val);\n\n            tlb_flush_page(env, val + 0x400);\n\n            tlb_flush_page(env, val + 0x800);\n\n            tlb_flush_page(env, val + 0xc00);\n\n#else\n\n            tlb_flush(env, 1);\n\n#endif\n\n            break;\n\n        default:\n\n            goto bad_reg;\n\n        }\n\n        break;\n\n    case 9:\n\n        if (arm_feature(env, ARM_FEATURE_OMAPCP))\n\n            break;\n\n        switch (crm) {\n\n        case 0: \/* Cache lockdown.  *\/\n\n            switch (op2) {\n\n            case 0:\n\n                env->cp15.c9_data = val;\n\n                break;\n\n            case 1:\n\n                env->cp15.c9_insn = val;\n\n                break;\n\n            default:\n\n                goto bad_reg;\n\n            }\n\n            break;\n\n        case 1: \/* TCM memory region registers.  *\/\n\n            \/* Not implemented.  *\/\n\n            goto bad_reg;\n\n        default:\n\n            goto bad_reg;\n\n        }\n\n        break;\n\n    case 10: \/* MMU TLB lockdown.  *\/\n\n        \/* ??? TLB lockdown not implemented.  *\/\n\n        break;\n\n    case 12: \/* Reserved.  *\/\n\n        goto bad_reg;\n\n    case 13: \/* Process ID.  *\/\n\n        switch (op2) {\n\n        case 0:\n\n            if (!arm_feature(env, ARM_FEATURE_MPU))\n\n                goto bad_reg;\n\n            \/* Unlike real hardware the qemu TLB uses virtual addresses,\n\n               not modified virtual addresses, so this causes a TLB flush.\n\n             *\/\n\n            if (env->cp15.c13_fcse != val)\n\n              tlb_flush(env, 1);\n\n            env->cp15.c13_fcse = val;\n\n            break;\n\n        case 1:\n\n            \/* This changes the ASID, so do a TLB flush.  *\/\n\n            if (env->cp15.c13_context != val\n\n                && !arm_feature(env, ARM_FEATURE_MPU))\n\n              tlb_flush(env, 0);\n\n            env->cp15.c13_context = val;\n\n            break;\n\n        default:\n\n            goto bad_reg;\n\n        }\n\n        break;\n\n    case 14: \/* Reserved.  *\/\n\n        goto bad_reg;\n\n    case 15: \/* Implementation specific.  *\/\n\n        if (arm_feature(env, ARM_FEATURE_XSCALE)) {\n\n            if (op2 == 0 && crm == 1) {\n\n                if (env->cp15.c15_cpar != (val & 0x3fff)) {\n\n                    \/* Changes cp0 to cp13 behavior, so needs a TB flush.  *\/\n\n                    tb_flush(env);\n\n                    env->cp15.c15_cpar = val & 0x3fff;\n\n                }\n\n                break;\n\n            }\n\n            goto bad_reg;\n\n        }\n\n        if (arm_feature(env, ARM_FEATURE_OMAPCP)) {\n\n            switch (crm) {\n\n            case 0:\n\n                break;\n\n            case 1: \/* Set TI925T configuration.  *\/\n\n                env->cp15.c15_ticonfig = val & 0xe7;\n\n                env->cp15.c0_cpuid = (val & (1 << 5)) ? \/* OS_TYPE bit *\/\n\n                        ARM_CPUID_TI915T : ARM_CPUID_TI925T;\n\n                break;\n\n            case 2: \/* Set I_max.  *\/\n\n                env->cp15.c15_i_max = val;\n\n                break;\n\n            case 3: \/* Set I_min.  *\/\n\n                env->cp15.c15_i_min = val;\n\n                break;\n\n            case 4: \/* Set thread-ID.  *\/\n\n                env->cp15.c15_threadid = val & 0xffff;\n\n                break;\n\n            case 8: \/* Wait-for-interrupt (deprecated).  *\/\n\n                cpu_interrupt(env, CPU_INTERRUPT_HALT);\n\n                break;\n\n            default:\n\n                goto bad_reg;\n\n            }\n\n        }\n\n        break;\n\n    }\n\n    return;\n\nbad_reg:\n\n    \/* ??? For debugging only.  Should raise illegal instruction exception.  *\/\n\n    cpu_abort(env, \"Unimplemented cp15 register write\\n\");\n\n}\n","target":0,"code_token_length":1940,"total_token_length":2176,"max_tokens_setting":4096}
+{"idx":43800,"func":"static void dump_vmcs(void)\n{\n\tu32 vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS);\n\tu32 vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS);\n\tu32 cpu_based_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);\n\tu32 pin_based_exec_ctrl = vmcs_read32(PIN_BASED_VM_EXEC_CONTROL);\n\tu32 secondary_exec_control = 0;\n\tunsigned long cr4 = vmcs_readl(GUEST_CR4);\n\tu64 efer = vmcs_readl(GUEST_IA32_EFER);\n\tint i, n;\n\n\tif (cpu_has_secondary_exec_ctrls())\n\t\tsecondary_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);\n\n\tpr_err(\"*** Guest State ***\\n\");\n\tpr_err(\"CR0: actual=0x%016lx, shadow=0x%016lx, gh_mask=%016lx\\n\",\n\t       vmcs_readl(GUEST_CR0), vmcs_readl(CR0_READ_SHADOW),\n\t       vmcs_readl(CR0_GUEST_HOST_MASK));\n\tpr_err(\"CR4: actual=0x%016lx, shadow=0x%016lx, gh_mask=%016lx\\n\",\n\t       cr4, vmcs_readl(CR4_READ_SHADOW), vmcs_readl(CR4_GUEST_HOST_MASK));\n\tpr_err(\"CR3 = 0x%016lx\\n\", vmcs_readl(GUEST_CR3));\n\tif ((secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) &&\n\t    (cr4 & X86_CR4_PAE) && !(efer & EFER_LMA))\n\t{\n\t\tpr_err(\"PDPTR0 = 0x%016lx  PDPTR1 = 0x%016lx\\n\",\n\t\t       vmcs_readl(GUEST_PDPTR0), vmcs_readl(GUEST_PDPTR1));\n\t\tpr_err(\"PDPTR2 = 0x%016lx  PDPTR3 = 0x%016lx\\n\",\n\t\t       vmcs_readl(GUEST_PDPTR2), vmcs_readl(GUEST_PDPTR3));\n\t}\n\tpr_err(\"RSP = 0x%016lx  RIP = 0x%016lx\\n\",\n\t       vmcs_readl(GUEST_RSP), vmcs_readl(GUEST_RIP));\n\tpr_err(\"RFLAGS=0x%08lx         DR7 = 0x%016lx\\n\",\n\t       vmcs_readl(GUEST_RFLAGS), vmcs_readl(GUEST_DR7));\n\tpr_err(\"Sysenter RSP=%016lx CS:RIP=%04x:%016lx\\n\",\n\t       vmcs_readl(GUEST_SYSENTER_ESP),\n\t       vmcs_read32(GUEST_SYSENTER_CS), vmcs_readl(GUEST_SYSENTER_EIP));\n\tvmx_dump_sel(\"CS:  \", GUEST_CS_SELECTOR);\n\tvmx_dump_sel(\"DS:  \", GUEST_DS_SELECTOR);\n\tvmx_dump_sel(\"SS:  \", GUEST_SS_SELECTOR);\n\tvmx_dump_sel(\"ES:  \", GUEST_ES_SELECTOR);\n\tvmx_dump_sel(\"FS:  \", GUEST_FS_SELECTOR);\n\tvmx_dump_sel(\"GS:  \", GUEST_GS_SELECTOR);\n\tvmx_dump_dtsel(\"GDTR:\", GUEST_GDTR_LIMIT);\n\tvmx_dump_sel(\"LDTR:\", GUEST_LDTR_SELECTOR);\n\tvmx_dump_dtsel(\"IDTR:\", GUEST_IDTR_LIMIT);\n\tvmx_dump_sel(\"TR:  \", GUEST_TR_SELECTOR);\n\tif ((vmexit_ctl & (VM_EXIT_SAVE_IA32_PAT | VM_EXIT_SAVE_IA32_EFER)) ||\n\t    (vmentry_ctl & (VM_ENTRY_LOAD_IA32_PAT | VM_ENTRY_LOAD_IA32_EFER)))\n\t\tpr_err(\"EFER =     0x%016llx  PAT = 0x%016lx\\n\",\n\t\t       efer, vmcs_readl(GUEST_IA32_PAT));\n\tpr_err(\"DebugCtl = 0x%016lx  DebugExceptions = 0x%016lx\\n\",\n\t       vmcs_readl(GUEST_IA32_DEBUGCTL),\n\t       vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS));\n\tif (vmentry_ctl & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL)\n\t\tpr_err(\"PerfGlobCtl = 0x%016lx\\n\",\n\t\t       vmcs_readl(GUEST_IA32_PERF_GLOBAL_CTRL));\n\tif (vmentry_ctl & VM_ENTRY_LOAD_BNDCFGS)\n\t\tpr_err(\"BndCfgS = 0x%016lx\\n\", vmcs_readl(GUEST_BNDCFGS));\n\tpr_err(\"Interruptibility = %08x  ActivityState = %08x\\n\",\n\t       vmcs_read32(GUEST_INTERRUPTIBILITY_INFO),\n\t       vmcs_read32(GUEST_ACTIVITY_STATE));\n\tif (secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY)\n\t\tpr_err(\"InterruptStatus = %04x\\n\",\n\t\t       vmcs_read16(GUEST_INTR_STATUS));\n\n\tpr_err(\"*** Host State ***\\n\");\n\tpr_err(\"RIP = 0x%016lx  RSP = 0x%016lx\\n\",\n\t       vmcs_readl(HOST_RIP), vmcs_readl(HOST_RSP));\n\tpr_err(\"CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x TR=%04x\\n\",\n\t       vmcs_read16(HOST_CS_SELECTOR), vmcs_read16(HOST_SS_SELECTOR),\n\t       vmcs_read16(HOST_DS_SELECTOR), vmcs_read16(HOST_ES_SELECTOR),\n\t       vmcs_read16(HOST_FS_SELECTOR), vmcs_read16(HOST_GS_SELECTOR),\n\t       vmcs_read16(HOST_TR_SELECTOR));\n\tpr_err(\"FSBase=%016lx GSBase=%016lx TRBase=%016lx\\n\",\n\t       vmcs_readl(HOST_FS_BASE), vmcs_readl(HOST_GS_BASE),\n\t       vmcs_readl(HOST_TR_BASE));\n\tpr_err(\"GDTBase=%016lx IDTBase=%016lx\\n\",\n\t       vmcs_readl(HOST_GDTR_BASE), vmcs_readl(HOST_IDTR_BASE));\n\tpr_err(\"CR0=%016lx CR3=%016lx CR4=%016lx\\n\",\n\t       vmcs_readl(HOST_CR0), vmcs_readl(HOST_CR3),\n\t       vmcs_readl(HOST_CR4));\n\tpr_err(\"Sysenter RSP=%016lx CS:RIP=%04x:%016lx\\n\",\n\t       vmcs_readl(HOST_IA32_SYSENTER_ESP),\n\t       vmcs_read32(HOST_IA32_SYSENTER_CS),\n\t       vmcs_readl(HOST_IA32_SYSENTER_EIP));\n\tif (vmexit_ctl & (VM_EXIT_LOAD_IA32_PAT | VM_EXIT_LOAD_IA32_EFER))\n\t\tpr_err(\"EFER = 0x%016lx  PAT = 0x%016lx\\n\",\n\t\t       vmcs_readl(HOST_IA32_EFER), vmcs_readl(HOST_IA32_PAT));\n\tif (vmexit_ctl & VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL)\n\t\tpr_err(\"PerfGlobCtl = 0x%016lx\\n\",\n\t\t       vmcs_readl(HOST_IA32_PERF_GLOBAL_CTRL));\n\n\tpr_err(\"*** Control State ***\\n\");\n\tpr_err(\"PinBased=%08x CPUBased=%08x SecondaryExec=%08x\\n\",\n\t       pin_based_exec_ctrl, cpu_based_exec_ctrl, secondary_exec_control);\n\tpr_err(\"EntryControls=%08x ExitControls=%08x\\n\", vmentry_ctl, vmexit_ctl);\n\tpr_err(\"ExceptionBitmap=%08x PFECmask=%08x PFECmatch=%08x\\n\",\n\t       vmcs_read32(EXCEPTION_BITMAP),\n\t       vmcs_read32(PAGE_FAULT_ERROR_CODE_MASK),\n\t       vmcs_read32(PAGE_FAULT_ERROR_CODE_MATCH));\n\tpr_err(\"VMEntry: intr_info=%08x errcode=%08x ilen=%08x\\n\",\n\t       vmcs_read32(VM_ENTRY_INTR_INFO_FIELD),\n\t       vmcs_read32(VM_ENTRY_EXCEPTION_ERROR_CODE),\n\t       vmcs_read32(VM_ENTRY_INSTRUCTION_LEN));\n\tpr_err(\"VMExit: intr_info=%08x errcode=%08x ilen=%08x\\n\",\n\t       vmcs_read32(VM_EXIT_INTR_INFO),\n\t       vmcs_read32(VM_EXIT_INTR_ERROR_CODE),\n\t       vmcs_read32(VM_EXIT_INSTRUCTION_LEN));\n\tpr_err(\"        reason=%08x qualification=%016lx\\n\",\n\t       vmcs_read32(VM_EXIT_REASON), vmcs_readl(EXIT_QUALIFICATION));\n\tpr_err(\"IDTVectoring: info=%08x errcode=%08x\\n\",\n\t       vmcs_read32(IDT_VECTORING_INFO_FIELD),\n\t       vmcs_read32(IDT_VECTORING_ERROR_CODE));\n\tpr_err(\"TSC Offset = 0x%016lx\\n\", vmcs_readl(TSC_OFFSET));\n\tif (secondary_exec_control & SECONDARY_EXEC_TSC_SCALING)\n\t\tpr_err(\"TSC Multiplier = 0x%016lx\\n\",\n\t\t       vmcs_readl(TSC_MULTIPLIER));\n\tif (cpu_based_exec_ctrl & CPU_BASED_TPR_SHADOW)\n\t\tpr_err(\"TPR Threshold = 0x%02x\\n\", vmcs_read32(TPR_THRESHOLD));\n\tif (pin_based_exec_ctrl & PIN_BASED_POSTED_INTR)\n\t\tpr_err(\"PostedIntrVec = 0x%02x\\n\", vmcs_read16(POSTED_INTR_NV));\n\tif ((secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT))\n\t\tpr_err(\"EPT pointer = 0x%016lx\\n\", vmcs_readl(EPT_POINTER));\n\tn = vmcs_read32(CR3_TARGET_COUNT);\n\tfor (i = 0; i + 1 < n; i += 4)\n\t\tpr_err(\"CR3 target%u=%016lx target%u=%016lx\\n\",\n\t\t       i, vmcs_readl(CR3_TARGET_VALUE0 + i * 2),\n\t\t       i + 1, vmcs_readl(CR3_TARGET_VALUE0 + i * 2 + 2));\n\tif (i < n)\n\t\tpr_err(\"CR3 target%u=%016lx\\n\",\n\t\t       i, vmcs_readl(CR3_TARGET_VALUE0 + i * 2));\n\tif (secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING)\n\t\tpr_err(\"PLE Gap=%08x Window=%08x\\n\",\n\t\t       vmcs_read32(PLE_GAP), vmcs_read32(PLE_WINDOW));\n\tif (secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID)\n\t\tpr_err(\"Virtual processor ID = 0x%04x\\n\",\n\t\t       vmcs_read16(VIRTUAL_PROCESSOR_ID));\n}","target":0,"code_token_length":2410,"total_token_length":2646,"max_tokens_setting":4096}
+{"idx":479746,"func":"    CImg get_blur_median(const unsigned int n, const float threshold=0) const {\n      if (is_empty() || n<=1) return +*this;\n      CImg res(_width,_height,_depth,_spectrum);\n      T *ptrd = res._data;\n      cimg::unused(ptrd);\n      const int hr = (int)n\/2, hl = n - hr - 1;\n      if (res._depth!=1) { \/\/ 3D\n        if (threshold>0)\n          cimg_pragma_openmp(parallel for cimg_openmp_collapse(3) cimg_openmp_if(_width>=(cimg_openmp_sizefactor)*16 &&\n                                                                     _height*_depth*_spectrum>=4))\n          cimg_forXYZC(*this,x,y,z,c) { \/\/ With threshold\n            const int\n              x0 = x - hl, y0 = y - hl, z0 = z - hl, x1 = x + hr, y1 = y + hr, z1 = z + hr,\n              nx0 = x0<0?0:x0, ny0 = y0<0?0:y0, nz0 = z0<0?0:z0,\n              nx1 = x1>=width()?width() - 1:x1, ny1 = y1>=height()?height() - 1:y1, nz1 = z1>=depth()?depth() - 1:z1;\n            const Tfloat val0 = (Tfloat)(*this)(x,y,z,c);\n            CImg values(n*n*n);\n            unsigned int nb_values = 0;\n            T *_ptrd = values.data();\n            cimg_for_inXYZ(*this,nx0,ny0,nz0,nx1,ny1,nz1,p,q,r)\n              if (cimg::abs((*this)(p,q,r,c) - val0)<=threshold) { *(_ptrd++) = (*this)(p,q,r,c); ++nb_values; }\n            res(x,y,z,c) = nb_values?values.get_shared_points(0,nb_values - 1).median():(*this)(x,y,z,c);\n          }\n        else\n          cimg_pragma_openmp(parallel for cimg_openmp_collapse(3) cimg_openmp_if(_width>=(cimg_openmp_sizefactor)*16 &&\n                                                                     _height*_depth*_spectrum>=4))\n          cimg_forXYZC(*this,x,y,z,c) { \/\/ Without threshold\n            const int\n              x0 = x - hl, y0 = y - hl, z0 = z - hl, x1 = x + hr, y1 = y + hr, z1 = z + hr,\n              nx0 = x0<0?0:x0, ny0 = y0<0?0:y0, nz0 = z0<0?0:z0,\n              nx1 = x1>=width()?width() - 1:x1, ny1 = y1>=height()?height() - 1:y1, nz1 = z1>=depth()?depth() - 1:z1;\n            res(x,y,z,c) = get_crop(nx0,ny0,nz0,c,nx1,ny1,nz1,c).median();\n          }\n      } else {\n        if (threshold>0)\n          cimg_pragma_openmp(parallel for cimg_openmp_collapse(2) cimg_openmp_if(_width>=(cimg_openmp_sizefactor)*16 &&\n                                                                     _height*_spectrum>=4))\n          cimg_forXYC(*this,x,y,c) { \/\/ With threshold\n            const int\n              x0 = x - hl, y0 = y - hl, x1 = x + hr, y1 = y + hr,\n              nx0 = x0<0?0:x0, ny0 = y0<0?0:y0,\n                                        nx1 = x1>=width()?width() - 1:x1, ny1 = y1>=height()?height() - 1:y1;\n            const Tfloat val0 = (Tfloat)(*this)(x,y,c);\n            CImg values(n*n);\n            unsigned int nb_values = 0;\n            T *_ptrd = values.data();\n            cimg_for_inXY(*this,nx0,ny0,nx1,ny1,p,q)\n              if (cimg::abs((*this)(p,q,c) - val0)<=threshold) { *(_ptrd++) = (*this)(p,q,c); ++nb_values; }\n            res(x,y,c) = nb_values?values.get_shared_points(0,nb_values - 1).median():(*this)(x,y,c);\n          }\n        else {\n          const int\n            w1 = width() - 1, h1 = height() - 1,\n            w2 = width() - 2, h2 = height() - 2,\n            w3 = width() - 3, h3 = height() - 3,\n            w4 = width() - 4, h4 = height() - 4;\n          switch (n) { \/\/ Without threshold\n          case 3 : {\n            cimg_pragma_openmp(parallel for cimg_openmp_if(_spectrum>=2))\n            cimg_forC(*this,c) {\n              CImg I(9);\n              cimg_for_in3x3(*this,1,1,w2,h2,x,y,0,c,I,T)\n                res(x,y,c) = cimg::median(I[0],I[1],I[2],I[3],I[4],I[5],I[6],I[7],I[8]);\n              cimg_for_borderXY(*this,x,y,1)\n                res(x,y,c) = get_crop(std::max(0,x - 1),std::max(0,y - 1),0,c,\n                                      std::min(w1,x + 1),std::min(h1,y + 1),0,c).median();\n            }\n          } break;\n          case 5 : {\n            cimg_pragma_openmp(parallel for cimg_openmp_if(_spectrum>=2))\n            cimg_forC(*this,c) {\n              CImg I(25);\n              cimg_for_in5x5(*this,2,2,w3,h3,x,y,0,c,I,T)\n                res(x,y,c) = cimg::median(I[0],I[1],I[2],I[3],I[4],\n                                          I[5],I[6],I[7],I[8],I[9],\n                                          I[10],I[11],I[12],I[13],I[14],\n                                          I[15],I[16],I[17],I[18],I[19],\n                                          I[20],I[21],I[22],I[23],I[24]);\n              cimg_for_borderXY(*this,x,y,2)\n                res(x,y,c) = get_crop(std::max(0,x - 2),std::max(0,y - 2),0,c,\n                                      std::min(w1,x + 2),std::min(h1,y + 2),0,c).median();\n            }\n          } break;\n          case 7 : {\n            cimg_pragma_openmp(parallel for cimg_openmp_if(_spectrum>=2))\n            cimg_forC(*this,c) {\n              CImg I(49);\n              cimg_for_in7x7(*this,3,3,w4,h4,x,y,0,c,I,T)\n                res(x,y,c) = cimg::median(I[0],I[1],I[2],I[3],I[4],I[5],I[6],\n                                          I[7],I[8],I[9],I[10],I[11],I[12],I[13],\n                                          I[14],I[15],I[16],I[17],I[18],I[19],I[20],\n                                          I[21],I[22],I[23],I[24],I[25],I[26],I[27],\n                                          I[28],I[29],I[30],I[31],I[32],I[33],I[34],\n                                          I[35],I[36],I[37],I[38],I[39],I[40],I[41],\n                                          I[42],I[43],I[44],I[45],I[46],I[47],I[48]);\n              cimg_for_borderXY(*this,x,y,3)\n                res(x,y,c) = get_crop(std::max(0,x - 3),std::max(0,y - 3),0,c,\n                                      std::min(w1,x + 3),std::min(h1,y + 3),0,c).median();\n            }\n          } break;\n          default : {\n            cimg_pragma_openmp(parallel for cimg_openmp_collapse(2)\n                               cimg_openmp_if(_width>=(cimg_openmp_sizefactor)*16 && _height*_spectrum>=4))\n            cimg_forXYC(*this,x,y,c) {\n              const int\n                x0 = x - hl, y0 = y - hl, x1 = x + hr, y1 = y + hr,\n                nx0 = x0<0?0:x0, ny0 = y0<0?0:y0,\n                                          nx1 = x1>=width()?width() - 1:x1, ny1 = y1>=height()?height() - 1:y1;\n              res(x,y,c) = get_crop(nx0,ny0,0,c,nx1,ny1,0,c).median();\n            }\n          }\n          }\n        }\n      }\n      return res;\n    }","target":0,"code_token_length":2194,"total_token_length":2430,"max_tokens_setting":4096}
+{"idx":173027,"func":" generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,\n    int bit_depth, png_const_bytep gamma_table, double conv,\n   unsigned int *colors, int small)\n {\n   int filters = 0; \/* file *MASK*, 0 means the default, not NONE *\/\n   png_uint_32 size_max =\n      image_size_of_type(color_type, bit_depth, colors, small)-1;\n    png_uint_32 depth_max = (1U << bit_depth)-1; \/* up to 65536 *\/\n \n   if (colors[0] == 0) if (small)\n   {\n      unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth);\n\n      \/* For pixel depths less than 16 generate a single row containing all the\n       * possible pixel values.  For 16 generate all 65536 byte pair\n       * combinations in a 256x256 pixel array.\n       *\/\n      switch (pixel_depth)\n      {\n         case 1:\n            assert(y == 0 && rowbytes == 1 && size_max == 1);\n            row[0] = 0x6CU; \/* binary: 01101100, only top 2 bits used *\/\n            filters = PNG_FILTER_NONE;\n            break;\n\n         case 2:\n            assert(y == 0 && rowbytes == 1 && size_max == 3);\n            row[0] = 0x1BU; \/* binary 00011011, all bits used *\/\n            filters = PNG_FILTER_NONE;\n            break;\n\n         case 4:\n            assert(y == 0 && rowbytes == 8 && size_max == 15);\n            row[0] = 0x01U;\n            row[1] = 0x23U; \/* SUB gives 0x22U for all following bytes *\/\n            row[2] = 0x45U;\n            row[3] = 0x67U;\n            row[4] = 0x89U;\n            row[5] = 0xABU;\n            row[6] = 0xCDU;\n            row[7] = 0xEFU;\n            filters = PNG_FILTER_SUB;\n            break;\n\n         case 8:\n            \/* The row will have all the pixel values in order starting with\n             * '1', the SUB filter will change every byte into '1' (including\n             * the last, which generates pixel value '0').  Since the SUB filter\n             * has value 1 this should result in maximum compression.\n             *\/\n            assert(y == 0 && rowbytes == 256 && size_max == 255);\n            for (;;)\n            {\n               row[size_max] = 0xFFU & (size_max+1);\n               if (size_max == 0)\n                  break;\n               --size_max;\n            }\n            filters = PNG_FILTER_SUB;\n            break;\n\n         case 16:\n            \/* Rows are generated such that each row has a constant difference\n             * between the first and second byte of each pixel and so that the\n             * difference increases by 1 at each row.  The rows start with the\n             * first byte value of 0 and the value increases to 255 across the\n             * row.\n             *\n             * The difference starts at 1, so the first row is:\n             *\n             *     0 1 1 2 2 3 3 4 ... 254 255 255 0\n             *\n             * This means that running the SUB filter on the first row produces:\n             *\n             *   [SUB==1] 0 1 0 1 0 1...\n             *\n             * Then the difference is 2 on the next row, giving:\n             *\n             *    0 2 1 3 2 4 3 5 ... 254 0 255 1\n             *\n             * When the UP filter is run on this libpng produces:\n             *\n             *   [UP ==2] 0 1 0 1 0 1...\n             *\n             * And so on for all the remain rows to the final two * rows:\n             *\n             *    row 254: 0 255 1 0 2 1 3 2 4 3 ... 254 253 255 254\n             *    row 255: 0   0 1 1 2 2 3 3 4 4 ... 254 254 255 255\n             *\/\n            assert(rowbytes == 512 && size_max == 255);\n            for (;;)\n            {\n               row[2*size_max  ] = 0xFFU & size_max;\n               row[2*size_max+1] = 0xFFU & (size_max+y+1);\n               if (size_max == 0)\n                  break;\n               --size_max;\n            }\n            \/* The first row must include PNG_FILTER_UP so that libpng knows we\n             * need to keep it for the following row:\n             *\/\n            filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);\n            break;\n\n         case 24:\n         case 32:\n         case 48:\n         case 64:\n            \/* The rows are filled by an alogorithm similar to the above, in the\n             * first row pixel bytes are all equal, increasing from 0 by 1 for\n             * each pixel.  In the second row the bytes within a pixel are\n             * incremented 1,3,5,7,... from the previous row byte.  Using an odd\n             * number ensures all the possible byte values are used.\n             *\/\n            assert(size_max == 255 && rowbytes == 256*(pixel_depth>>3));\n            pixel_depth >>= 3; \/* now in bytes *\/\n            while (rowbytes > 0)\n            {\n               const size_t pixel_index = --rowbytes\/pixel_depth;\n\n               if (y == 0)\n                  row[rowbytes] = 0xFFU & pixel_index;\n\n               else\n               {\n                  const size_t byte_offset =\n                     rowbytes - pixel_index * pixel_depth;\n\n                  row[rowbytes] =\n                     0xFFU & (pixel_index + (byte_offset * 2*y) + 1);\n               }\n            }\n            filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);\n            break;\n\n         default:\n            assert(0\/*NOT REACHED*\/);\n      }\n   }\n\n   else switch (channels_of_type(color_type))\n    {\n    \/* 1 channel: a square image with a diamond, the least luminous colors are on\n     *    the edge of the image, the most luminous in the center.\n    *\/\n case 1:\n {\n            png_uint_32 x;\n            png_uint_32 base = 2*size_max - abs(2*y-size_max);\n\n for (x=0; x<=size_max; ++x)\n {\n               png_uint_32 luma = base - abs(2*x-size_max);\n\n \/* 'luma' is now in the range 0..2*size_max, we need\n                * 0..depth_max\n                *\/\n               luma = (luma*depth_max + size_max) \/ (2*size_max);\n               set_value(row, rowbytes, x, bit_depth, luma, gamma_table, conv);\n }\n }\n break;\n\n \/* 2 channels: the color channel increases in luminosity from top to bottom,\n    *    the alpha channel increases in opacity from left to right.\n    *\/\n case 2:\n {\n            png_uint_32 alpha = (depth_max * y * 2 + size_max) \/ (2 * size_max);\n            png_uint_32 x;\n\n for (x=0; x<=size_max; ++x)\n {\n               set_value(row, rowbytes, 2*x, bit_depth,\n (depth_max * x * 2 + size_max) \/ (2 * size_max), gamma_table,\n                  conv);\n               set_value(row, rowbytes, 2*x+1, bit_depth, alpha, gamma_table,\n                  conv);\n }\n }\n break;\n\n \/* 3 channels: linear combinations of, from the top-left corner clockwise,\n    *    black, green, white, red.\n    *\/\n case 3:\n {\n \/* x0: the black->red scale (the value of the red component) at the\n             *     start of the row (blue and green are 0).\n             * x1: the green->white scale (the value of the red and blue\n             *     components at the end of the row; green is depth_max).\n             *\/\n            png_uint_32 Y = (depth_max * y * 2 + size_max) \/ (2 * size_max);\n            png_uint_32 x;\n\n \/* Interpolate x\/depth_max from start to end:\n             *\n             *        start end         difference\n             * red:     Y    Y            0\n             * green:   0   depth_max   depth_max\n             * blue:    0    Y            Y\n             *\/\n for (x=0; x<=size_max; ++x)\n {\n               set_value(row, rowbytes, 3*x+0, bit_depth, \/* red *\/ Y,\n                     gamma_table, conv);\n               set_value(row, rowbytes, 3*x+1, bit_depth, \/* green *\/\n (depth_max * x * 2 + size_max) \/ (2 * size_max),\n                  gamma_table, conv);\n               set_value(row, rowbytes, 3*x+2, bit_depth, \/* blue *\/\n (Y * x * 2 + size_max) \/ (2 * size_max),\n                  gamma_table, conv);\n }\n }\n break;\n\n \/* 4 channels: linear combinations of, from the top-left corner clockwise,\n    *    transparent, red, green, blue.\n    *\/\n case 4:\n {\n \/* x0: the transparent->blue scale (the value of the blue and alpha\n             *     components) at the start of the row (red and green are 0).\n             * x1: the red->green scale (the value of the red and green\n             *     components at the end of the row; blue is 0 and alpha is\n             *     depth_max).\n             *\/\n            png_uint_32 Y = (depth_max * y * 2 + size_max) \/ (2 * size_max);\n            png_uint_32 x;\n\n \/* Interpolate x\/depth_max from start to end:\n             *\n             *        start    end       difference\n             * red:     0   depth_max-Y depth_max-Y\n             * green:   0       Y             Y\n             * blue:    Y       0            -Y\n             * alpha:   Y    depth_max  depth_max-Y\n             *\/\n for (x=0; x<=size_max; ++x)\n {\n               set_value(row, rowbytes, 4*x+0, bit_depth, \/* red *\/\n ((depth_max-Y) * x * 2 + size_max) \/ (2 * size_max),\n                  gamma_table, conv);\n               set_value(row, rowbytes, 4*x+1, bit_depth, \/* green *\/\n (Y * x * 2 + size_max) \/ (2 * size_max),\n                  gamma_table, conv);\n               set_value(row, rowbytes, 4*x+2, bit_depth, \/* blue *\/\n                  Y - (Y * x * 2 + size_max) \/ (2 * size_max),\n                  gamma_table, conv);\n               set_value(row, rowbytes, 4*x+3, bit_depth, \/* alpha *\/\n                  Y + ((depth_max-Y) * x * 2 + size_max) \/ (2 * size_max),\n                  gamma_table, conv);\n }\n }\n break;\n\n default:\n         fprintf(stderr, \"makepng: internal bad channel count\\n\");\n         exit(2);\n }\n\n else if (color_type & PNG_COLOR_MASK_PALETTE)\n {\n \/* Palette with fixed color: the image rows are all 0 and the image width\n       * is 16.\n       *\/\n      memset(row, 0, rowbytes);\n }\n\n else if (colors[0] == channels_of_type(color_type))\n switch (channels_of_type(color_type))\n {\n case 1:\n {\n const png_uint_32 luma = colors[1];\n               png_uint_32 x;\n\n for (x=0; x<=size_max; ++x)\n                  set_value(row, rowbytes, x, bit_depth, luma, gamma_table,\n                     conv);\n }\n break;\n\n case 2:\n {\n const png_uint_32 luma = colors[1];\n const png_uint_32 alpha = colors[2];\n               png_uint_32 x;\n\n for (x=0; xtoString().c_str());\n\n    if (path->isRoot())\n    {\n\tycp2error (\"Write () called without sub-path\");\n\treturn YCPBoolean (false);\n    }\n\n    const string cmd = path->component_str (0); \/\/ just a shortcut\n\n    if (cmd == \"passwd\")\n    {\n\t\/**\n\t * @builtin Write (.target.passwd.<name>, string cryptval) -> bool\n\t * .passwd can be used to set or modify the encrypted password\n\t * of an already existing user in \/etc\/passwd and \/etc\/shadow.\n\t *\n\t * This call returns true on success and false, if it fails.\n\t *\n\t * @example Write (.target.passwd.root, crypt (a_passwd))\n\t *\/\n\n\tif (path->length() != 2)\n\t{\n\t    ycp2error (\"Bad path argument in call to Write (.passwd.name)\");\n\t    return YCPBoolean (false);\n\t}\n\n\tif (value.isNull() || !value->isString())\n\t{\n\t    ycp2error (\"Bad password argument in call to Write (.passwd)\");\n\t    return YCPBoolean (false);\n\t}\n\n\tstring passwd = value->asString()->value();\n\n\tstring bashcommand =\n\t    string (\"\/bin\/echo '\") +\n\t    path->component_str (1).c_str () + \":\" + passwd +\n\t    \"' |\/usr\/sbin\/chpasswd -e >\/dev\/null 2>&1\";\n\n\t\/\/ Don't write the password into the log - even though it's crypted\n\t\/\/ y2debug(\"Executing: '%s'\", bashcommand.c_str());\n\n\tint exitcode = system(bashcommand.c_str());\n\n\treturn YCPBoolean (WIFEXITED (exitcode) && WEXITSTATUS (exitcode) == 0);\n    }\n\n    else if (cmd == \"string\")\n    {\n\t\/**\n\t * @builtin Write (.target.string, string filename, string value) -> boolean\n\t * @builtin Write (.target.string, [string filename, integer filemode] , string value) -> boolean\n\t * Writes the string value<\/tt> into a file. If the file already\n\t * exists, the existing file is overwritten. The return value is\n\t * true, if the file has been written successfully.\n         *\n         * @example Write(.target.string, \"\/etc\/papersize\", \"a4\") -> true\n         * @example Write(.target.string, [\"\/etc\/rsyncd.secrets\", 0600], \"user:passwd\") -> true\n\t *\/\n\n\tif (value.isNull() || !(value->isString() || value->isList()))\n\t{\n\t    ycp2error (\"Bad filename arg for Write (.string ...)\");\n\t    return YCPBoolean (false);\n\t}\n\n\tstring filename;\n\tmode_t filemode = 0644;\n\n\tif (value->isString())\n\t{\n\t    filename = value->asString()->value();\n\t}\n\telse\n\t{\t\t\t\/\/ value is list\n\t    YCPList flist = value->asList();\n\t    if ((flist->size() != 2)\n\t\t|| (!flist->value(0)->isString())\n\t\t|| (!flist->value(1)->isInteger()))\n\t    {\n\t\tycp2error (\"Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)\",\n\t\t    cmd.c_str ());\n\t\treturn YCPBoolean (false);\n\t    }\n\t    filename = flist->value(0)->asString()->value();\n\t    filemode = (int)(flist->value(1)->asInteger()->value());\n\t}\n\n\tif (arg.isNull() || !arg->isString())\n\t{\n\t    ycp2error (\"Bad string value for Write (.string ...)\");\n\t    return YCPBoolean (false);\n\t}\n\n\tint fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, filemode);\n\tif (fd >= 0)\n\t{\n\t    string cont = arg->asString()->value();\n\t    const char *buffer = cont.c_str();\n\t    size_t length = cont.length();\n\t    size_t written = write(fd, buffer, length);\n\t    close(fd);\n\t    return YCPBoolean (written == length);\n\t}\n\tycp2error (\"Write (.string, \\\"%s\\\") failed: %s\", filename.c_str (), strerror (errno));\n\treturn YCPBoolean(false);\n    }\n\n    else if (cmd == \"byte\")\n    {\n\t\/**\n\t * @builtin Write (.target.byte, string filename, byteblock) -> boolean\n\t * Write a byteblock into a file.\n\t *\/\n\n\tif (value.isNull () || !value->isString ())\n\t{\n\t    ycp2error (\"Bad filename arg for Write (.byte, ...)\");\n\t    return YCPBoolean (false);\n\t}\n\n\tif (arg.isNull () || !arg->isByteblock ())\n\t{\n\t    ycp2error (\"Bad value for Write (.byte, filename, byteblock)\");\n\t    return YCPBoolean (false);\n\t}\n\n\tstring filename = value->asString ()->value ();\n\tYCPByteblock byteblock = arg->asByteblock ();\n\n\tint fd = open (filename.c_str (), O_WRONLY | O_CREAT | O_TRUNC, 0644);\n\tif (fd >= 0)\n\t{\n\t    size_t size = byteblock->size ();\n\t    size_t write_size = write (fd, byteblock->value (), size);\n\t    close (fd);\n\t    return YCPBoolean (write_size == size);\n\t}\n\n\tycp2error (\"Write (.byte, \\\"%s\\\") failed: %s\", filename.c_str (), strerror (errno));\n\treturn YCPBoolean (false);\n    }\n\n    else if (cmd == \"ycp\" || cmd == \"yast2\")\n    {\n\t\/**\n\t * @builtin Write (.target.ycp, string filename, any value) -> boolean\n\t * Opens a file for writing and prints the value value<\/tt> in\n\t * YCP syntax to that file. Returns true, if the file has\n\t * been written, false otherwise. The newly created file gets\n\t * the mode 0644 minus umask. Furthermore any missing directory in the\n\t * pathname filename<\/tt> is created automatically.\n\t *\/\n\n\t\/**\n\t * @builtin Write (.target.ycp, [ string filename, integer mode], any value) -> boolean\n\t * Opens a file for writing and prints the value value<\/tt> in\n\t * YCP syntax to that file. Returns true, if the file has\n\t * been written, false otherwise. The newly created file gets\n\t * the mode mode minus umask. Furthermore any missing directory in the\n\t * pathname filename<\/tt> is created automatically.\n\t *\/\n\n\t\/\/ either string or list\n\n\tif (value.isNull() || !(value->isString() || value->isList()))\n\t{\n\t    ycp2error (\"Bad arguments to Write (%s, string filename ...)\", cmd.c_str ());\n\t    return YCPBoolean (false);\n\t}\n\n\tstring filename;\n\tmode_t filemode = 0644;\n\n\tif (value->isString())\n\t{\n\t    filename = value->asString()->value();\n\t}\n\telse\n\t{\t\t\t\/\/ value is list\n\t    YCPList flist = value->asList();\n\t    if ((flist->size() != 2)\n\t\t|| (!flist->value(0)->isString())\n\t\t|| (!flist->value(1)->isInteger()))\n\t    {\n\t\tycp2error (\"Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)\",\n\t\t    cmd.c_str ());\n\t\treturn YCPBoolean (false);\n\t    }\n\t    filename = flist->value(0)->asString()->value();\n\t    filemode = (int)(flist->value(1)->asInteger()->value());\n\t}\n\n\tif (filename.length() == 0)\n\t{\n\t    ycp2error (\"Invalid empty filename in Write (%s, ...)\", cmd.c_str ());\n\t    return YCPBoolean (false);\n\t}\n\n\t\/\/ Create directory, if missing\n\tsize_t pos = 0;\n\twhile (pos = filename.find('\/', pos + 1), pos != string::npos)\n\t    mkdir (filename.substr(0, pos).c_str(), 0775);\n\n\t\/\/ Remove file, if existing\n\tremove (filename.c_str());\n\n\tint fd = open (filename.c_str(), O_WRONLY | O_CREAT |  O_TRUNC , filemode);\n\tbool success = false;\n\tif (fd < 0)\n\t{\n\t    ycp2error (\"Error opening '%s': %s\", filename.c_str (), strerror (errno));\n\t    return YCPBoolean (false);\n\t}\n\n\t\/\/ string contents = (arg.isNull() ? \"\" : arg->toString());\n\tstring contents = (arg.isNull() ? \"\" : dump_value(0, arg));\n\tssize_t size = contents.length();\n\tif (size == write(fd, contents.c_str(), size)\n\t    && write(fd, \"\\n\", 1) == 1)\n\t    success = true;\n\tclose(fd);\n\n\treturn YCPBoolean(success);\n    }\n\n    ycp2error (\"Undefined subpath for Write (%s)\", path->toString ().c_str ());\n    return YCPBoolean (false);\n}","target":0,"code_token_length":1970,"total_token_length":2206,"max_tokens_setting":4096}
+{"idx":477802,"func":"    CImg<_cimg_Tt> get_erode(const CImg& kernel, const unsigned int boundary_conditions=1,\n                             const bool is_real=false) const {\n      if (is_empty() || !kernel) return *this;\n      if (!is_real && kernel==0) return CImg(width(),height(),depth(),spectrum(),0);\n      typedef _cimg_Tt Tt;\n      CImg res(_width,_height,_depth,std::max(_spectrum,kernel._spectrum));\n      const int\n        mx2 = kernel.width()\/2, my2 = kernel.height()\/2, mz2 = kernel.depth()\/2,\n        mx1 = kernel.width() - mx2 - 1, my1 = kernel.height() - my2 - 1, mz1 = kernel.depth() - mz2 - 1,\n        mxe = width() - mx2, mye = height() - my2, mze = depth() - mz2,\n        w2 = 2*width(), h2 = 2*height(), d2 = 2*depth();\n      const bool\n        is_inner_parallel = _width*_height*_depth>=(cimg_openmp_sizefactor)*32768,\n        is_outer_parallel = res.size()>=(cimg_openmp_sizefactor)*32768;\n      cimg::unused(is_inner_parallel,is_outer_parallel);\n      _cimg_abort_init_openmp;\n      cimg_abort_init;\n      cimg_pragma_openmp(parallel for cimg_openmp_if(!is_inner_parallel && is_outer_parallel))\n      cimg_forC(res,c) _cimg_abort_try_openmp {\n        cimg_abort_test;\n        const CImg img = get_shared_channel(c%_spectrum);\n        const CImg K = kernel.get_shared_channel(c%kernel._spectrum);\n        if (is_real) { \/\/ Real erosion\n          cimg_pragma_openmp(parallel for cimg_openmp_collapse(3) cimg_openmp_if(is_inner_parallel))\n          for (int z = mz1; z::max();\n                for (int zm = -mz1; zm<=mz2; ++zm)\n                  for (int ym = -my1; ym<=my2; ++ym)\n                    for (int xm = -mx1; xm<=mx2; ++xm) {\n                      const t mval = K(mx1 + xm,my1 + ym,mz1 + zm);\n                      const Tt cval = (Tt)(img(x + xm,y + ym,z + zm) - mval);\n                      if (cval=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) {\n              Tt min_val = cimg::type::max();\n              for (int zm = -mz1; zm<=mz2; ++zm)\n                for (int ym = -my1; ym<=my2; ++ym)\n                  for (int xm = -mx1; xm<=mx2; ++xm) {\n                    const t mval = K(mx1 + xm,my1 + ym,mz1 + zm);\n                    Tt cval;\n                    switch (boundary_conditions) {\n                    case 0 : cval = (Tt)(img.atXYZ(x + xm,y + ym,z + zm,0,(T)0) - mval); break;\n                    case 1 : cval = (Tt)(img._atXYZ(x + xm,y + ym,z + zm) - mval); break;\n                    case 2 : {\n                      const int\n                        nx = cimg::mod(x + xm,width()),\n                        ny = cimg::mod(y + ym,height()),\n                        nz = cimg::mod(z + zm,depth());\n                      cval = img(nx,ny,nz) - mval;\n                    } break;\n                    default : {\n                      const int\n                        tx = cimg::mod(x + xm,w2),\n                        ty = cimg::mod(y + ym,h2),\n                        tz = cimg::mod(z + zm,d2),\n                        nx = tx::max();\n                for (int zm = -mz1; zm<=mz2; ++zm)\n                  for (int ym = -my1; ym<=my2; ++ym)\n                    for (int xm = -mx1; xm<=mx2; ++xm)\n                      if (K(mx1 + xm,my1 + ym,mz1 + zm)) {\n                        const Tt cval = (Tt)img(x + xm,y + ym,z + zm);\n                        if (cval=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) {\n              Tt min_val = cimg::type::max();\n              for (int zm = -mz1; zm<=mz2; ++zm)\n                for (int ym = -my1; ym<=my2; ++ym)\n                  for (int xm = -mx1; xm<=mx2; ++xm) {\n                    if (K(mx1 + xm,my1 + ym,mz1 + zm)) {\n                      Tt cval;\n                      switch (boundary_conditions) {\n                      case 0 : cval = (Tt)img.atXYZ(x + xm,y + ym,z + zm,0,(T)0); break;\n                      case 1 : cval = (Tt)img._atXYZ(x + xm,y + ym,z + zm); break;\n                      case 2 : {\n                        const int\n                          nx = cimg::mod(x + xm,width()),\n                          ny = cimg::mod(y + ym,height()),\n                          nz = cimg::mod(z + zm,depth());\n                        cval = img(nx,ny,nz);\n                      } break;\n                      default : {\n                        const int\n                          tx = cimg::mod(x + xm,w2),\n                          ty = cimg::mod(y + ym,h2),\n                          tz = cimg::mod(z + zm,d2),\n                          nx = tx 256) {\n        L_WARNING(\"max colors > 256; setting to 256\\n\", procName);\n        maxcolors = 256;\n    }\n\n    pixGetDimensions(pixs, &w, &h, NULL);\n    datas = pixGetData(pixs);\n    wpls = pixGetWpl(pixs);\n    minside = L_MIN(w, h);\n    if (subsample <= 0) {\n       subsample = L_MAX(1, minside \/ 200);\n    }\n\n    if (maxcolors <= 16) {\n        bpp = 4;\n        pixd = pixCreate(w, h, bpp);\n        maxlevel = 2;\n        ncubes = 64;   \/* 2^6 *\/\n        nbase = 8;\n        nextra = maxcolors - nbase;\n    } else if (maxcolors <= 64) {\n        bpp = 8;\n        pixd = pixCreate(w, h, bpp);\n        maxlevel = 2;\n        ncubes = 64;  \/* 2^6 *\/\n        nbase = 8;\n        nextra = maxcolors - nbase;\n    } else {  \/* maxcolors <= 256 *\/\n        bpp = 8;\n        pixd = pixCreate(w, h, bpp);\n        maxlevel = 3;\n        ncubes = 512;  \/* 2^9 *\/\n        nbase = 64;\n        nextra = maxcolors - nbase;\n    }\n\n    pixCopyResolution(pixd, pixs);\n    pixCopyInputFormat(pixd, pixs);\n\n        \/*----------------------------------------------------------*\n         * If we're using the minimum number of colors, it is       *\n         * much simpler.  We just use 'nbase' octcubes.             *\n         * For this case, we don't eliminate any extra colors.      *\n         *----------------------------------------------------------*\/\n    if (nextra == 0) {\n            \/* prepare the OctcubeQuantCell array *\/\n        if ((oqca = (OQCELL **)LEPT_CALLOC(nbase, sizeof(OQCELL *))) == NULL) {\n            pixDestroy(&pixd);\n            return (PIX *)ERROR_PTR(\"oqca not made\", procName, NULL);\n        }\n        for (i = 0; i < nbase; i++) {\n            oqca[i] = (OQCELL *)LEPT_CALLOC(1, sizeof(OQCELL));\n            oqca[i]->n = 0.0;\n        }\n\n        rtab = gtab = btab = NULL;\n        makeRGBToIndexTables(maxlevel - 1, &rtab, >ab, &btab);\n\n            \/* Go through the entire image, gathering statistics and\n             * assigning pixels to their quantized value *\/\n        datad = pixGetData(pixd);\n        wpld = pixGetWpl(pixd);\n        for (i = 0; i < h; i++) {\n            lines = datas + i * wpls;\n            lined = datad + i * wpld;\n            for (j = 0; j < w; j++) {\n                pspixel = lines + j;\n                extractRGBValues(*pspixel, &rval, &gval, &bval);\n                getOctcubeIndexFromRGB(rval, gval, bval,\n                                       rtab, gtab, btab, &index);\n\/*                lept_stderr(\"rval = %d, gval = %d, bval = %d,\"\n                              \" index = %d\\n\", rval, gval, bval, index); *\/\n                if (bpp == 4)\n                    SET_DATA_QBIT(lined, j, index);\n                else  \/* bpp == 8 *\/\n                    SET_DATA_BYTE(lined, j, index);\n                oqca[index]->n += 1.0;\n                oqca[index]->rcum += rval;\n                oqca[index]->gcum += gval;\n                oqca[index]->bcum += bval;\n            }\n        }\n\n            \/* Compute average color values in each octcube, and\n             * generate colormap *\/\n        cmap = pixcmapCreate(bpp);\n        pixSetColormap(pixd, cmap);\n        for (i = 0; i < nbase; i++) {\n            oqc = oqca[i];\n            if (oqc->n != 0) {\n                oqc->rval = (l_int32)(oqc->rcum \/ oqc->n);\n                oqc->gval = (l_int32)(oqc->gcum \/ oqc->n);\n                oqc->bval = (l_int32)(oqc->bcum \/ oqc->n);\n            } else {\n                getRGBFromOctcube(i, maxlevel - 1, &oqc->rval,\n                                  &oqc->gval, &oqc->bval);\n            }\n            pixcmapAddColor(cmap, oqc->rval, oqc->gval, oqc->bval);\n        }\n\n        for (i = 0; i < nbase; i++)\n            LEPT_FREE(oqca[i]);\n        LEPT_FREE(oqca);\n        LEPT_FREE(rtab);\n        LEPT_FREE(gtab);\n        LEPT_FREE(btab);\n        return pixd;\n    }\n\n        \/*------------------------------------------------------------*\n         * General case: we will use colors in octcubes at maxlevel.  *\n         * We also remove any colors that are not populated from      *\n         * the colormap.                                              *\n         *------------------------------------------------------------*\/\n        \/* Prepare the OctcubeQuantCell array *\/\n    if ((oqca = (OQCELL **)LEPT_CALLOC(ncubes, sizeof(OQCELL *))) == NULL) {\n        pixDestroy(&pixd);\n        return (PIX *)ERROR_PTR(\"oqca not made\", procName, NULL);\n    }\n    for (i = 0; i < ncubes; i++) {\n        oqca[i] = (OQCELL *)LEPT_CALLOC(1, sizeof(OQCELL));\n        oqca[i]->n = 0.0;\n    }\n\n        \/* Make the tables to map color to the octindex,\n         * of which there are 'ncubes' at 'maxlevel' *\/\n    rtab = gtab = btab = NULL;\n    makeRGBToIndexTables(maxlevel, &rtab, >ab, &btab);\n\n        \/* Estimate the color distribution; we want to find the\n         * most popular nextra colors at 'maxlevel' *\/\n    for (i = 0; i < h; i += subsample) {\n        lines = datas + i * wpls;\n        for (j = 0; j < w; j += subsample) {\n            pspixel = lines + j;\n            extractRGBValues(*pspixel, &rval, &gval, &bval);\n            getOctcubeIndexFromRGB(rval, gval, bval, rtab, gtab, btab, &index);\n            oqca[index]->n += 1.0;\n            oqca[index]->octindex = index;\n            oqca[index]->rcum += rval;\n            oqca[index]->gcum += gval;\n            oqca[index]->bcum += bval;\n        }\n    }\n\n        \/* Transfer the OQCELL from the array, and order in a heap *\/\n    lh = lheapCreate(512, L_SORT_DECREASING);\n    for (i = 0; i < ncubes; i++)\n        lheapAdd(lh, oqca[i]);\n    LEPT_FREE(oqca);  \/* don't need this array *\/\n\n        \/* Prepare a new OctcubeQuantCell array, with maxcolors cells  *\/\n    oqca = (OQCELL **)LEPT_CALLOC(maxcolors, sizeof(OQCELL *));\n    for (i = 0; i < nbase; i++) {  \/* make nbase cells *\/\n        oqca[i] = (OQCELL *)LEPT_CALLOC(1, sizeof(OQCELL));\n        oqca[i]->n = 0.0;\n    }\n\n        \/* Remove the nextra most populated ones, and put them in the array *\/\n    for (i = 0; i < nextra; i++) {\n        oqc = (OQCELL *)lheapRemove(lh);\n        oqc->n = 0.0;  \/* reinit *\/\n        oqc->rcum = 0;\n        oqc->gcum = 0;\n        oqc->bcum = 0;\n        oqca[nbase + i] = oqc;  \/* store it in the array *\/\n    }\n\n        \/* Destroy the heap and its remaining contents *\/\n    lheapDestroy(&lh, TRUE);\n\n        \/* Generate a lookup table from octindex at maxlevel\n         * to color table index *\/\n    lut1 = (l_int32 *)LEPT_CALLOC(ncubes, sizeof(l_int32));\n    for (i = 0; i < nextra; i++)\n        lut1[oqca[nbase + i]->octindex] = nbase + i;\n    for (index = 0; index < ncubes; index++) {\n        if (lut1[index] == 0)  \/* not one of the extras; need to assign *\/\n            lut1[index] = index >> 3;  \/* remove the least significant bits *\/\n\/*        lept_stderr(\"lut1[%d] = %d\\n\", index, lut1[index]); *\/\n    }\n\n        \/* Go through the entire image, gathering statistics and\n         * assigning pixels to their quantized value *\/\n    datad = pixGetData(pixd);\n    wpld = pixGetWpl(pixd);\n    for (i = 0; i < h; i++) {\n        lines = datas + i * wpls;\n        lined = datad + i * wpld;\n        for (j = 0; j < w; j++) {\n            pspixel = lines + j;\n            extractRGBValues(*pspixel, &rval, &gval, &bval);\n            getOctcubeIndexFromRGB(rval, gval, bval, rtab, gtab, btab, &index);\n\/*            lept_stderr(\"rval = %d, gval = %d, bval = %d, index = %d\\n\",\n                          rval, gval, bval, index); *\/\n            val = lut1[index];\n            switch (bpp) {\n            case 4:\n                SET_DATA_QBIT(lined, j, val);\n                break;\n            case 8:\n                SET_DATA_BYTE(lined, j, val);\n                break;\n            default:\n                LEPT_FREE(oqca);\n                LEPT_FREE(lut1);\n                return (PIX *)ERROR_PTR(\"bpp not 4 or 8!\", procName, NULL);\n                break;\n            }\n            oqca[val]->n += 1.0;\n            oqca[val]->rcum += rval;\n            oqca[val]->gcum += gval;\n            oqca[val]->bcum += bval;\n        }\n    }\n\n        \/* Compute averages, set up a colormap, and make a second\n         * lut that converts from the color values currently in\n         * the image to a minimal set *\/\n    lut2 = (l_int32 *)LEPT_CALLOC(ncubes, sizeof(l_int32));\n    cmap = pixcmapCreate(bpp);\n    pixSetColormap(pixd, cmap);\n    for (i = 0, index = 0; i < maxcolors; i++) {\n        oqc = oqca[i];\n        lut2[i] = index;\n        if (oqc->n == 0)  \/* no occupancy; don't bump up index *\/\n            continue;\n        oqc->rval = (l_int32)(oqc->rcum \/ oqc->n);\n        oqc->gval = (l_int32)(oqc->gcum \/ oqc->n);\n        oqc->bval = (l_int32)(oqc->bcum \/ oqc->n);\n        pixcmapAddColor(cmap, oqc->rval, oqc->gval, oqc->bval);\n        index++;\n    }\n\/*    pixcmapWriteStream(stderr, cmap); *\/\n    actualcolors = pixcmapGetCount(cmap);\n\/*    lept_stderr(\"Number of different colors = %d\\n\", actualcolors); *\/\n\n        \/* Last time through the image; use the lookup table to\n         * remap the pixel value to the minimal colormap *\/\n    if (actualcolors < maxcolors) {\n        for (i = 0; i < h; i++) {\n            lined = datad + i * wpld;\n            for (j = 0; j < w; j++) {\n                switch (bpp) {\n                case 4:\n                    val = GET_DATA_QBIT(lined, j);\n                    SET_DATA_QBIT(lined, j, lut2[val]);\n                    break;\n                case 8:\n                    val = GET_DATA_BYTE(lined, j);\n                    SET_DATA_BYTE(lined, j, lut2[val]);\n                    break;\n                }\n            }\n        }\n    }\n\n    if (oqca) {\n        for (i = 0; i < maxcolors; i++)\n            LEPT_FREE(oqca[i]);\n    }\n    LEPT_FREE(oqca);\n    LEPT_FREE(lut1);\n    LEPT_FREE(lut2);\n    LEPT_FREE(rtab);\n    LEPT_FREE(gtab);\n    LEPT_FREE(btab);\n    return pixd;\n}","target":0,"code_token_length":3224,"total_token_length":3460,"max_tokens_setting":4096}
+{"idx":371681,"func":"extract_archive_thread (GSimpleAsyncResult *result,\n\t\t\tGObject            *object,\n\t\t\tGCancellable       *cancellable)\n{\n\tExtractData          *extract_data;\n\tLoadData             *load_data;\n\tGHashTable           *checked_folders;\n\tstruct archive       *a;\n\tstruct archive_entry *entry;\n\tint                   r;\n\n\textract_data = g_simple_async_result_get_op_res_gpointer (result);\n\tload_data = LOAD_DATA (extract_data);\n\n\tchecked_folders = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);\n\tfr_archive_progress_set_total_files (load_data->archive, extract_data->n_files_to_extract);\n\n\ta = archive_read_new ();\n\tarchive_read_support_filter_all (a);\n\tarchive_read_support_format_all (a);\n\tarchive_read_open (a, load_data, load_data_open, load_data_read, load_data_close);\n\twhile ((r = archive_read_next_header (a, &entry)) == ARCHIVE_OK) {\n\t\tconst char    *pathname;\n\t\tchar          *fullpath;\n\t\tconst char    *relative_path;\n\t\tGFile         *file;\n\t\tGFile         *parent;\n\t\tGOutputStream *ostream;\n\t\tconst void    *buffer;\n\t\tsize_t         buffer_size;\n\t\tint64_t        offset;\n\t\tGError        *local_error = NULL;\n\t\t__LA_MODE_T    filetype;\n\n\t\tif (g_cancellable_is_cancelled (cancellable))\n\t\t\tbreak;\n\n\t\tpathname = archive_entry_pathname (entry);\n\t\tif (! extract_data_get_extraction_requested (extract_data, pathname)) {\n\t\t\tarchive_read_data_skip (a);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfullpath = (*pathname == '\/') ? g_strdup (pathname) : g_strconcat (\"\/\", pathname, NULL);\n\t\trelative_path = _g_path_get_relative_basename_safe (fullpath, extract_data->base_dir, extract_data->junk_paths);\n\t\tif (relative_path == NULL) {\n\t\t\tarchive_read_data_skip (a);\n\t\t\tcontinue;\n\t\t}\n\t\tfile = g_file_get_child (extract_data->destination, relative_path);\n\n\t\t\/* honor the skip_older and overwrite options *\/\n\n\t\tif (extract_data->skip_older || ! extract_data->overwrite) {\n\t\t\tGFileInfo *info;\n\n\t\t\tinfo = g_file_query_info (file,\n\t\t\t\t\t\t  G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME \",\" G_FILE_ATTRIBUTE_TIME_MODIFIED,\n\t\t\t\t\t\t  G_FILE_QUERY_INFO_NONE,\n\t\t\t\t\t\t  cancellable,\n\t\t\t\t\t\t  &local_error);\n\t\t\tif (info != NULL) {\n\t\t\t\tgboolean skip = FALSE;\n\n\t\t\t\tif (! extract_data->overwrite) {\n\t\t\t\t\tskip = TRUE;\n\t\t\t\t}\n\t\t\t\telse if (extract_data->skip_older) {\n\t\t\t\t\tGTimeVal modification_time;\n\n\t\t\t\t\tg_file_info_get_modification_time (info, &modification_time);\n\t\t\t\t\tif (archive_entry_mtime (entry) < modification_time.tv_sec)\n\t\t\t\t\t\tskip = TRUE;\n\t\t\t\t}\n\n\t\t\t\tg_object_unref (info);\n\n\t\t\t\tif (skip) {\n\t\t\t\t\tg_object_unref (file);\n\n\t\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\t\tfr_archive_progress_inc_completed_bytes (load_data->archive, archive_entry_size_is_set (entry) ? archive_entry_size (entry) : 0);\n\n\t\t\t\t\tif ((extract_data->file_list != NULL) && (--extract_data->n_files_to_extract == 0)) {\n\t\t\t\t\t\tr = ARCHIVE_EOF;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {\n\t\t\t\t\tload_data->error = local_error;\n\t\t\t\t\tg_object_unref (info);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tg_error_free (local_error);\n\t\t\t}\n\t\t}\n\n\t\tfr_archive_progress_inc_completed_files (load_data->archive, 1);\n\n\t\t\/* create the file parents *\/\n\n\t\tparent = g_file_get_parent (file);\n\n\t\tif ((parent != NULL)\n\t\t    && (g_hash_table_lookup (checked_folders, parent) == NULL)\n\t\t    && ! g_file_query_exists (parent, cancellable))\n\t\t{\n\t\t\tif (g_file_make_directory_with_parents (parent, cancellable, &load_data->error)) {\n\t\t\t\tGFile *grandparent;\n\n\t\t\t\tgrandparent = g_object_ref (parent);\n\t\t\t\twhile (grandparent != NULL) {\n\t\t\t\t\tif (g_hash_table_lookup (checked_folders, grandparent) == NULL)\n\t\t\t\t\t\tg_hash_table_insert (checked_folders, grandparent, GINT_TO_POINTER (1));\n\t\t\t\t\tgrandparent = g_file_get_parent (grandparent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tg_object_unref (parent);\n\n\t\t\/* create the file *\/\n\n\t\tfiletype = archive_entry_filetype (entry);\n\n\t\tif (load_data->error == NULL) {\n\t\t\tconst char  *linkname;\n\n\t\t\tlinkname = archive_entry_hardlink (entry);\n\t\t\tif (linkname != NULL) {\n\t\t\t\tchar        *link_fullpath;\n\t\t\t\tconst char  *relative_path;\n\t\t\t\tGFile       *link_file;\n\t\t\t\tchar        *oldname;\n\t\t\t\tchar        *newname;\n\t\t\t\tint          r;\n\n\t\t\t\tlink_fullpath = (*linkname == '\/') ? g_strdup (linkname) : g_strconcat (\"\/\", linkname, NULL);\n\t\t\t\trelative_path = _g_path_get_relative_basename_safe (link_fullpath, extract_data->base_dir, extract_data->junk_paths);\n\t\t\t\tif (relative_path == NULL) {\n\t\t\t\t\tg_free (link_fullpath);\n\t\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tlink_file = g_file_get_child (extract_data->destination, relative_path);\n\t\t\t\toldname = g_file_get_path (link_file);\n\t\t\t\tnewname = g_file_get_path (file);\n\n\t\t\t\tif ((oldname != NULL) && (newname != NULL))\n\t\t\t\t\tr = link (oldname, newname);\n\t\t\t\telse\n\t\t\t\t\tr = -1;\n\n\t\t\t\tif (r == 0) {\n\t\t\t\t\t__LA_INT64_T filesize;\n\n\t\t\t\t\tif (archive_entry_size_is_set (entry))\n\t\t\t\t\t\tfilesize = archive_entry_size (entry);\n\t\t\t\t\telse\n\t\t\t\t\t\tfilesize = -1;\n\n\t\t\t\t\tif (filesize > 0)\n\t\t\t\t\t\tfiletype = AE_IFREG; \/* treat as a regular file to save the data *\/\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tchar *uri;\n\t\t\t\t\tchar *msg;\n\n\t\t\t\t\turi = g_file_get_uri (file);\n\t\t\t\t\tmsg = g_strdup_printf (\"Could not create the hard link %s\", uri);\n\t\t\t\t\tload_data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, msg);\n\n\t\t\t\t\tg_free (msg);\n\t\t\t\t\tg_free (uri);\n\t\t\t\t}\n\n\t\t\t\tg_free (newname);\n\t\t\t\tg_free (oldname);\n\t\t\t\tg_object_unref (link_file);\n\t\t\t\tg_free (link_fullpath);\n\t\t\t}\n\t\t}\n\n\t\tif (load_data->error == NULL) {\n\t\t\tswitch (filetype) {\n\t\t\tcase AE_IFDIR:\n\t\t\t\tif (! g_file_make_directory (file, cancellable, &local_error)) {\n\t\t\t\t\tif (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))\n\t\t\t\t\t\tload_data->error = g_error_copy (local_error);\n\t\t\t\t\tg_error_free (local_error);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t_g_file_set_attributes_from_entry (file, entry, extract_data, cancellable);\n\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\tbreak;\n\n\t\t\tcase AE_IFREG:\n\t\t\t\tostream = (GOutputStream *) g_file_replace (file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, cancellable, &load_data->error);\n\t\t\t\tif (ostream == NULL)\n\t\t\t\t\tbreak;\n\n\t\t\t\twhile ((r = archive_read_data_block (a, &buffer, &buffer_size, &offset)) == ARCHIVE_OK) {\n\t\t\t\t\tif (g_output_stream_write (ostream, buffer, buffer_size, cancellable, &load_data->error) == -1)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tfr_archive_progress_inc_completed_bytes (load_data->archive, buffer_size);\n\t\t\t\t}\n\t\t\t\t_g_object_unref (ostream);\n\n\t\t\t\tif (r != ARCHIVE_EOF)\n\t\t\t\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));\n\t\t\t\telse\n\t\t\t\t\t_g_file_set_attributes_from_entry (file, entry, extract_data, cancellable);\n\t\t\t\tbreak;\n\n\t\t\tcase AE_IFLNK:\n\t\t\t\tif (! g_file_make_symbolic_link (file, archive_entry_symlink (entry), cancellable, &local_error)) {\n\t\t\t\t\tif (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))\n\t\t\t\t\t\tload_data->error = g_error_copy (local_error);\n\t\t\t\t\tg_error_free (local_error);\n\t\t\t\t}\n\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tg_object_unref (file);\n\t\tg_free (fullpath);\n\n\t\tif (load_data->error != NULL)\n\t\t\tbreak;\n\n\t\tif ((extract_data->file_list != NULL) && (--extract_data->n_files_to_extract == 0)) {\n\t\t\tr = ARCHIVE_EOF;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ((load_data->error == NULL) && (r != ARCHIVE_EOF))\n\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));\n\tif (load_data->error == NULL)\n\t\tg_cancellable_set_error_if_cancelled (cancellable, &load_data->error);\n\tif (load_data->error != NULL)\n\t\tg_simple_async_result_set_from_error (result, load_data->error);\n\n\tg_hash_table_unref (checked_folders);\n\tarchive_read_free (a);\n\textract_data_free (extract_data);\n}","target":0,"code_token_length":2030,"total_token_length":2266,"max_tokens_setting":4096}
+{"idx":763,"func":"static void dissect_q931_IEs ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * root_tree , proto_tree * q931_tree , gboolean is_over_ip , int offset , int initial_codeset ) {\n proto_item * ti ;\n proto_tree * ie_tree = NULL ;\n guint8 info_element ;\n guint8 dummy ;\n guint16 info_element_len ;\n int codeset , locked_codeset ;\n gboolean non_locking_shift , first_segment ;\n tvbuff_t * h225_tvb , * next_tvb ;\n e164_info_t e164_info ;\n e164_info . e164_number_type = NONE ;\n e164_info . nature_of_address = NONE ;\n e164_info . E164_number_str = \"\" ;\n e164_info . E164_number_length = NONE ;\n codeset = locked_codeset = initial_codeset ;\n first_segment = FALSE ;\n while ( tvb_reported_length_remaining ( tvb , offset ) > 0 ) {\n info_element = tvb_get_guint8 ( tvb , offset ) ;\n if ( ( info_element & Q931_IE_SO_MASK ) && ( ( info_element & Q931_IE_SO_IDENTIFIER_MASK ) == Q931_IE_SHIFT ) ) {\n non_locking_shift = info_element & Q931_IE_SHIFT_NON_LOCKING ;\n codeset = info_element & Q931_IE_SHIFT_CODESET ;\n if ( ! non_locking_shift ) locked_codeset = codeset ;\n if ( q931_tree != NULL ) {\n proto_tree_add_uint_format ( q931_tree , hf_q931_locking_codeset , tvb , offset , 1 , codeset , \"%s shift to codeset %u: %s\" , ( non_locking_shift ? \"Non-locking\" : \"Locking\" ) , codeset , val_to_str ( codeset , q931_codeset_vals , \"Unknown (0x%02X)\" ) ) ;\n }\n offset += 1 ;\n continue ;\n }\n if ( info_element & Q931_IE_SO_MASK ) {\n if ( dissector_get_uint_handle ( codeset_dissector_table , codeset ) || dissector_get_uint_handle ( ie_dissector_table , ( codeset << 8 ) | ( info_element & Q931_IE_SO_IDENTIFIER_MASK ) ) ) {\n next_tvb = tvb_new_subset_length ( tvb , offset , 1 ) ;\n if ( dissector_try_uint ( ie_dissector_table , ( codeset << 8 ) | ( info_element & Q931_IE_SO_IDENTIFIER_MASK ) , next_tvb , pinfo , q931_tree ) || dissector_try_uint ( codeset_dissector_table , codeset , next_tvb , pinfo , q931_tree ) ) {\n offset += 1 ;\n codeset = locked_codeset ;\n continue ;\n }\n }\n switch ( ( codeset << 8 ) | ( info_element & Q931_IE_SO_IDENTIFIER_MASK ) ) {\n case CS0 | Q931_IE_MORE_DATA_OR_SEND_COMP : switch ( info_element ) {\n case Q931_IE_MORE_DATA : proto_tree_add_item ( q931_tree , hf_q931_more_data , tvb , offset , 1 , ENC_NA ) ;\n break ;\n case Q931_IE_SENDING_COMPLETE : proto_tree_add_item ( q931_tree , hf_q931_sending_complete , tvb , offset , 1 , ENC_NA ) ;\n break ;\n default : proto_tree_add_expert_format ( q931_tree , pinfo , & ei_q931_information_element , tvb , offset , 1 , \"Unknown information element (0x%02X)\" , info_element ) ;\n break ;\n }\n break ;\n case CS0 | Q931_IE_CONGESTION_LEVEL : proto_tree_add_item ( q931_tree , hf_q931_congestion_level , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;\n break ;\n case CS0 | Q931_IE_REPEAT_INDICATOR : proto_tree_add_item ( q931_tree , hf_q931_repeat_indicator , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;\n break ;\n default : proto_tree_add_expert_format ( q931_tree , pinfo , & ei_q931_information_element , tvb , offset , 1 , \"Unknown information element (0x%02X)\" , info_element ) ;\n break ;\n }\n offset += 1 ;\n codeset = locked_codeset ;\n continue ;\n }\n if ( is_over_ip && tvb_bytes_exist ( tvb , offset , 4 ) && codeset == 0 && tvb_get_guint8 ( tvb , offset ) == Q931_IE_USER_USER && tvb_get_guint8 ( tvb , offset + 3 ) == Q931_PROTOCOL_DISCRIMINATOR_ASN1 ) {\n info_element_len = tvb_get_ntohs ( tvb , offset + 1 ) ;\n if ( q931_tree != NULL ) {\n ie_tree = proto_tree_add_subtree ( q931_tree , tvb , offset , 1 + 2 + info_element_len , ett_q931_ie [ info_element ] , NULL , val_to_str ( info_element , q931_info_element_vals [ codeset ] , \"Unknown information element (0x%02X)\" ) ) ;\n proto_tree_add_uint_format_value ( ie_tree , hf_q931_information_element , tvb , offset , 1 , info_element , \"%s\" , val_to_str ( info_element , q931_info_element_vals [ codeset ] , \"Unknown (0x%02X)\" ) ) ;\n proto_tree_add_item ( ie_tree , hf_q931_information_element_len , tvb , offset + 1 , 2 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_item ( ie_tree , hf_q931_user_protocol_discriminator , tvb , offset + 3 , 1 , ENC_NA ) ;\n }\n if ( info_element_len > 1 ) {\n if ( ! pinfo -> can_desegment ) {\n info_element_len = MIN ( info_element_len , tvb_captured_length_remaining ( tvb , offset + 3 ) ) ;\n }\n if ( h225_handle != NULL ) {\n h225_tvb = tvb_new_subset_length ( tvb , offset + 4 , info_element_len - 1 ) ;\n call_dissector ( h225_handle , h225_tvb , pinfo , root_tree ) ;\n }\n else {\n proto_tree_add_item ( ie_tree , hf_q931_user_information_bytes , tvb , offset + 4 , info_element_len - 1 , ENC_NA ) ;\n }\n }\n offset += 1 + 2 + info_element_len ;\n }\n else {\n info_element_len = tvb_get_guint8 ( tvb , offset + 1 ) ;\n if ( first_segment && ( tvb_reported_length_remaining ( tvb , offset + 2 ) < info_element_len ) ) {\n proto_tree_add_expert ( q931_tree , pinfo , & ei_q931_incomplete_ie , tvb , offset , - 1 ) ;\n break ;\n }\n if ( dissector_get_uint_handle ( codeset_dissector_table , codeset ) || dissector_get_uint_handle ( ie_dissector_table , ( codeset << 8 ) | info_element ) ) {\n next_tvb = tvb_new_subset_length ( tvb , offset , info_element_len + 2 ) ;\n if ( dissector_try_uint ( ie_dissector_table , ( codeset << 8 ) | info_element , next_tvb , pinfo , q931_tree ) || dissector_try_uint ( codeset_dissector_table , codeset , next_tvb , pinfo , q931_tree ) ) {\n offset += 2 + info_element_len ;\n codeset = locked_codeset ;\n continue ;\n }\n }\n ie_tree = proto_tree_add_subtree ( q931_tree , tvb , offset , 1 + 1 + info_element_len , ett_q931_ie [ info_element ] , & ti , val_to_str ( info_element , q931_info_element_vals [ codeset ] , \"Unknown information element (0x%02X)\" ) ) ;\n proto_tree_add_uint_format_value ( ie_tree , hf_q931_information_element , tvb , offset , 1 , info_element , \"%s\" , val_to_str ( info_element , q931_info_element_vals [ codeset ] , \"Unknown (0x%02X)\" ) ) ;\n proto_tree_add_uint ( ie_tree , hf_q931_information_element_len , tvb , offset + 1 , 1 , info_element_len ) ;\n if ( ( ( codeset << 8 ) | info_element ) == ( CS0 | Q931_IE_SEGMENTED_MESSAGE ) ) {\n dissect_q931_segmented_message_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree , ti ) ;\n col_append_fstr ( pinfo -> cinfo , COL_INFO , \" of %s\" , val_to_str_ext ( tvb_get_guint8 ( tvb , offset + 3 ) , & q931_message_type_vals_ext , \"Unknown message type (0x%02X)\" ) ) ;\n if ( tvb_get_guint8 ( tvb , offset + 2 ) & 0x80 ) {\n first_segment = TRUE ;\n }\n else {\n proto_tree_add_item ( q931_tree , hf_q931_message_segment , tvb , offset + 4 , - 1 , ENC_NA ) ;\n info_element_len += tvb_reported_length_remaining ( tvb , offset + 4 ) ;\n }\n }\n else {\n switch ( ( codeset << 8 ) | info_element ) {\n case CS0 | Q931_IE_BEARER_CAPABILITY : case CS0 | Q931_IE_LOW_LAYER_COMPAT : if ( q931_tree != NULL ) {\n dissect_q931_bearer_capability_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_CAUSE : dissect_q931_cause_ie_unsafe ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_cause_value , & dummy , q931_info_element_vals0 ) ;\n break ;\n case CS0 | Q931_IE_CHANGE_STATUS : if ( q931_tree != NULL ) {\n dissect_q931_change_status_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_CALL_STATE : if ( q931_tree != NULL ) {\n dissect_q931_call_state_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_CHANNEL_IDENTIFICATION : if ( q931_tree != NULL ) {\n dissect_q931_channel_identification_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_PROGRESS_INDICATOR : if ( q931_tree != NULL ) {\n dissect_q931_progress_indicator_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_NETWORK_SPECIFIC_FACIL : case CS0 | Q931_IE_TRANSIT_NETWORK_SEL : if ( q931_tree != NULL ) {\n dissect_q931_ns_facilities_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_NOTIFICATION_INDICATOR : if ( q931_tree != NULL ) {\n dissect_q931_notification_indicator_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_DISPLAY : if ( q931_tree != NULL ) {\n dissect_q931_ia5_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_display_information ) ;\n }\n break ;\n case CS0 | Q931_IE_DATE_TIME : dissect_q931_date_time_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree ) ;\n break ;\n case CS0 | Q931_IE_KEYPAD_FACILITY : if ( q931_tree != NULL ) {\n dissect_q931_ia5_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_keypad_facility ) ;\n }\n break ;\n case CS0 | Q931_IE_SIGNAL : dissect_q931_signal_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree , ti ) ;\n break ;\n case CS0 | Q931_IE_INFORMATION_RATE : dissect_q931_information_rate_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree , ti ) ;\n break ;\n case CS0 | Q931_IE_E2E_TRANSIT_DELAY : dissect_q931_e2e_transit_delay_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree , ti ) ;\n break ;\n case CS0 | Q931_IE_TD_SELECTION_AND_INT : dissect_q931_td_selection_and_int_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree , ti ) ;\n break ;\n case CS0 | Q931_IE_PL_BINARY_PARAMETERS : if ( q931_tree != NULL ) {\n dissect_q931_pl_binary_parameters_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_PL_WINDOW_SIZE : if ( q931_tree != NULL ) {\n dissect_q931_pl_window_size_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_PACKET_SIZE : if ( q931_tree != NULL ) {\n dissect_q931_packet_size_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_CUG : if ( q931_tree != NULL ) {\n dissect_q931_cug_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_REVERSE_CHARGE_IND : if ( q931_tree != NULL ) {\n dissect_q931_reverse_charge_ind_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_CONNECTED_NUMBER_DEFAULT : if ( q931_tree != NULL ) {\n dissect_q931_number_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_connected_number , e164_info ) ;\n }\n break ;\n case CS0 | Q931_IE_CALLING_PARTY_NUMBER : e164_info . e164_number_type = CALLING_PARTY_NUMBER ;\n dissect_q931_number_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_calling_party_number , e164_info ) ;\n break ;\n case CS0 | Q931_IE_CALLED_PARTY_NUMBER : e164_info . e164_number_type = CALLED_PARTY_NUMBER ;\n dissect_q931_number_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_called_party_number , e164_info ) ;\n break ;\n case CS0 | Q931_IE_CALLING_PARTY_SUBADDR : case CS0 | Q931_IE_CALLED_PARTY_SUBADDR : if ( q931_tree != NULL ) {\n dissect_q931_party_subaddr_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_REDIRECTING_NUMBER : if ( q931_tree != NULL ) {\n dissect_q931_number_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_redirecting_number , e164_info ) ;\n }\n break ;\n case CS0 | Q931_IE_RESTART_INDICATOR : dissect_q931_restart_indicator_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree , ti ) ;\n break ;\n case CS0 | Q931_IE_HIGH_LAYER_COMPAT : if ( q931_tree != NULL ) {\n dissect_q931_high_layer_compat_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS0 | Q931_IE_USER_USER : if ( q931_tree != NULL ) {\n dissect_q931_user_user_ie ( tvb , pinfo , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS5 | Q931_IE_PARTY_CATEGORY : if ( q931_tree != NULL ) {\n dissect_q931_party_category_ie ( tvb , offset + 2 , info_element_len , ie_tree ) ;\n }\n break ;\n case CS6 | Q931_IE_DISPLAY : if ( q931_tree != NULL ) {\n dissect_q931_ia5_ie ( tvb , offset + 2 , info_element_len , ie_tree , hf_q931_avaya_display ) ;\n }\n break ;\n default : if ( q931_tree != NULL ) {\n proto_tree_add_item ( ie_tree , hf_q931_data , tvb , offset + 2 , info_element_len , ENC_NA ) ;\n }\n break ;\n }\n }\n offset += 1 + 1 + info_element_len ;\n }\n codeset = locked_codeset ;\n }\n if ( have_valid_q931_pi ) {\n tap_queue_packet ( q931_tap , pinfo , q931_pi ) ;\n }\n have_valid_q931_pi = FALSE ;\n }","target":1,"code_token_length":3841,"total_token_length":4077,"max_tokens_setting":4096}
+{"idx":434032,"func":"static int vrend_renderer_resource_allocate_texture(struct vrend_resource *gr,\n                                                    void *image_oes)\n{\n   uint level;\n   GLenum internalformat, glformat, gltype;\n   enum virgl_formats format = gr->base.format;\n   struct vrend_texture *gt = (struct vrend_texture *)gr;\n   struct pipe_resource *pr = &gr->base;\n\n   if (pr->width0 == 0)\n      return EINVAL;\n\n   if (!image_oes && vrend_allocate_using_gbm(gr)) {\n      if ((gr->base.bind & (VIRGL_BIND_RENDER_TARGET | VIRGL_BIND_SAMPLER_VIEW)) == 0) {\n         gr->storage = VREND_RESOURCE_STORAGE_GBM_ONLY;\n         return 0;\n      }\n      image_oes = virgl_egl_image_from_dmabuf(egl, gr->gbm_bo);\n      if (!image_oes) {\n         gbm_bo_destroy(gr->gbm_bo);\n         gr->gbm_bo = NULL;\n      } else {\n         gr->egl_image = image_oes;\n      }\n   }\n\n   bool format_can_texture_storage = has_feature(feat_texture_storage) &&\n         (tex_conv_table[format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE);\n\n   if (image_oes)\n      gr->base.bind &= ~VIRGL_BIND_PREFER_EMULATED_BGRA;\n   else {\n      \/* On GLES there is no support for glTexImage*DMultisample and\n       * BGRA surfaces are also unlikely to support glTexStorage2DMultisample\n       * so we try to emulate here *\/\n      if (vrend_state.use_gles && pr->nr_samples > 0 && !format_can_texture_storage) {\n         VREND_DEBUG(dbg_tex, NULL, \"Apply VIRGL_BIND_PREFER_EMULATED_BGRA because GLES+MS+noTS\\n\");\n         gr->base.bind |= VIRGL_BIND_PREFER_EMULATED_BGRA;\n      }\n      format = vrend_format_replace_emulated(gr->base.bind, gr->base.format);\n      format_can_texture_storage = has_feature(feat_texture_storage) &&\n            (tex_conv_table[format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE);\n   }\n\n   gr->target = tgsitargettogltarget(pr->target, pr->nr_samples);\n   gr->storage = VREND_RESOURCE_STORAGE_TEXTURE;\n\n   \/* ugly workaround for texture rectangle missing on GLES *\/\n   if (vrend_state.use_gles && gr->target == GL_TEXTURE_RECTANGLE_NV) {\n      \/* for some guests this is the only usage of rect *\/\n      if (pr->width0 != 1 || pr->height0 != 1) {\n         report_gles_warn(NULL, GLES_WARN_TEXTURE_RECT);\n      }\n      gr->target = GL_TEXTURE_2D;\n   }\n\n   \/* fallback for 1D textures *\/\n   if (vrend_state.use_gles && gr->target == GL_TEXTURE_1D) {\n      gr->target = GL_TEXTURE_2D;\n   }\n\n   \/* fallback for 1D array textures *\/\n   if (vrend_state.use_gles && gr->target == GL_TEXTURE_1D_ARRAY) {\n      gr->target = GL_TEXTURE_2D_ARRAY;\n   }\n\n   debug_texture(__func__, gr);\n\n   glGenTextures(1, &gr->id);\n   glBindTexture(gr->target, gr->id);\n\n   if (image_oes) {\n      if (epoxy_has_gl_extension(\"GL_OES_EGL_image_external\")) {\n         glEGLImageTargetTexture2DOES(gr->target, (GLeglImageOES) image_oes);\n      } else {\n         vrend_printf( \"missing GL_OES_EGL_image_external extension\\n\");\n         glBindTexture(gr->target, 0);\n         FREE(gr);\n         return EINVAL;\n      }\n   } else {\n      internalformat = tex_conv_table[format].internalformat;\n      glformat = tex_conv_table[format].glformat;\n      gltype = tex_conv_table[format].gltype;\n\n      if (internalformat == 0) {\n         vrend_printf(\"unknown format is %d\\n\", pr->format);\n         glBindTexture(gr->target, 0);\n         FREE(gt);\n         return EINVAL;\n      }\n\n      if (pr->nr_samples > 0) {\n         if (format_can_texture_storage) {\n            if (gr->target == GL_TEXTURE_2D_MULTISAMPLE) {\n               glTexStorage2DMultisample(gr->target, pr->nr_samples,\n                                         internalformat, pr->width0, pr->height0,\n                                         GL_TRUE);\n            } else {\n               glTexStorage3DMultisample(gr->target, pr->nr_samples,\n                                         internalformat, pr->width0, pr->height0, pr->array_size,\n                                         GL_TRUE);\n            }\n         } else {\n            if (gr->target == GL_TEXTURE_2D_MULTISAMPLE) {\n               glTexImage2DMultisample(gr->target, pr->nr_samples,\n                                       internalformat, pr->width0, pr->height0,\n                                       GL_TRUE);\n            } else {\n               glTexImage3DMultisample(gr->target, pr->nr_samples,\n                                       internalformat, pr->width0, pr->height0, pr->array_size,\n                                       GL_TRUE);\n            }\n         }\n      } else if (gr->target == GL_TEXTURE_CUBE_MAP) {\n            int i;\n            if (format_can_texture_storage)\n               glTexStorage2D(GL_TEXTURE_CUBE_MAP, pr->last_level + 1, internalformat, pr->width0, pr->height0);\n            else {\n               for (i = 0; i < 6; i++) {\n                  GLenum ctarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;\n                  for (level = 0; level <= pr->last_level; level++) {\n                     unsigned mwidth = u_minify(pr->width0, level);\n                     unsigned mheight = u_minify(pr->height0, level);\n\n                     glTexImage2D(ctarget, level, internalformat, mwidth, mheight, 0, glformat,\n                                  gltype, NULL);\n                  }\n               }\n            }\n      } else if (gr->target == GL_TEXTURE_3D ||\n                 gr->target == GL_TEXTURE_2D_ARRAY ||\n                 gr->target == GL_TEXTURE_CUBE_MAP_ARRAY) {\n         if (format_can_texture_storage) {\n            unsigned depth_param = (gr->target == GL_TEXTURE_2D_ARRAY || gr->target == GL_TEXTURE_CUBE_MAP_ARRAY) ?\n                                      pr->array_size : pr->depth0;\n            glTexStorage3D(gr->target, pr->last_level + 1, internalformat, pr->width0, pr->height0, depth_param);\n         } else {\n            for (level = 0; level <= pr->last_level; level++) {\n               unsigned depth_param = (gr->target == GL_TEXTURE_2D_ARRAY || gr->target == GL_TEXTURE_CUBE_MAP_ARRAY) ?\n                                         pr->array_size : u_minify(pr->depth0, level);\n               unsigned mwidth = u_minify(pr->width0, level);\n               unsigned mheight = u_minify(pr->height0, level);\n               glTexImage3D(gr->target, level, internalformat, mwidth, mheight,\n                            depth_param, 0, glformat, gltype, NULL);\n            }\n         }\n      } else if (gr->target == GL_TEXTURE_1D && vrend_state.use_gles) {\n         report_gles_missing_func(NULL, \"glTexImage1D\");\n      } else if (gr->target == GL_TEXTURE_1D) {\n         if (format_can_texture_storage) {\n            glTexStorage1D(gr->target, pr->last_level + 1, internalformat, pr->width0);\n         } else {\n            for (level = 0; level <= pr->last_level; level++) {\n               unsigned mwidth = u_minify(pr->width0, level);\n               glTexImage1D(gr->target, level, internalformat, mwidth, 0,\n                            glformat, gltype, NULL);\n            }\n         }\n      } else {\n         if (format_can_texture_storage)\n            glTexStorage2D(gr->target, pr->last_level + 1, internalformat, pr->width0,\n                           gr->target == GL_TEXTURE_1D_ARRAY ? pr->array_size : pr->height0);\n         else {\n            for (level = 0; level <= pr->last_level; level++) {\n               unsigned mwidth = u_minify(pr->width0, level);\n               unsigned mheight = u_minify(pr->height0, level);\n               glTexImage2D(gr->target, level, internalformat, mwidth,\n                            gr->target == GL_TEXTURE_1D_ARRAY ? pr->array_size : mheight,\n                            0, glformat, gltype, NULL);\n            }\n         }\n      }\n   }\n\n   if (!format_can_texture_storage) {\n      glTexParameteri(gr->target, GL_TEXTURE_BASE_LEVEL, 0);\n      glTexParameteri(gr->target, GL_TEXTURE_MAX_LEVEL, pr->last_level);\n   }\n\n   glBindTexture(gr->target, 0);\n\n   gt->state.max_lod = -1;\n   gt->cur_swizzle_r = gt->cur_swizzle_g = gt->cur_swizzle_b = gt->cur_swizzle_a = -1;\n   gt->cur_base = -1;\n   gt->cur_max = 10000;\n   return 0;\n}","target":0,"code_token_length":1996,"total_token_length":2232,"max_tokens_setting":4096}
+{"idx":1758,"func":"static int flic_decode_frame_15_16BPP ( AVCodecContext * avctx , void * data , int * got_frame , const uint8_t * buf , int buf_size ) {\n FlicDecodeContext * s = avctx -> priv_data ;\n GetByteContext g2 ;\n int pixel_ptr ;\n unsigned char palette_idx1 ;\n unsigned int frame_size ;\n int num_chunks ;\n unsigned int chunk_size ;\n int chunk_type ;\n int i , j , ret ;\n int lines ;\n int compressed_lines ;\n signed short line_packets ;\n int y_ptr ;\n int byte_run ;\n int pixel_skip ;\n int pixel_countdown ;\n unsigned char * pixels ;\n int pixel ;\n unsigned int pixel_limit ;\n bytestream2_init ( & g2 , buf , buf_size ) ;\n s -> frame . reference = 1 ;\n s -> frame . buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE ;\n if ( ( ret = avctx -> reget_buffer ( avctx , & s -> frame ) ) < 0 ) {\n av_log ( avctx , AV_LOG_ERROR , \"reget_buffer() failed\\n\" ) ;\n return ret ;\n }\n pixels = s -> frame . data [ 0 ] ;\n pixel_limit = s -> avctx -> height * s -> frame . linesize [ 0 ] ;\n frame_size = bytestream2_get_le32 ( & g2 ) ;\n bytestream2_skip ( & g2 , 2 ) ;\n num_chunks = bytestream2_get_le16 ( & g2 ) ;\n bytestream2_skip ( & g2 , 8 ) ;\n frame_size -= 16 ;\n while ( ( frame_size > 0 ) && ( num_chunks > 0 ) ) {\n chunk_size = bytestream2_get_le32 ( & g2 ) ;\n chunk_type = bytestream2_get_le16 ( & g2 ) ;\n switch ( chunk_type ) {\n case FLI_256_COLOR : case FLI_COLOR : av_dlog ( avctx , \"Unexpected Palette chunk %d in non-palettized FLC\\n\" , chunk_type ) ;\n bytestream2_skip ( & g2 , chunk_size - 6 ) ;\n break ;\n case FLI_DELTA : case FLI_DTA_LC : y_ptr = 0 ;\n compressed_lines = bytestream2_get_le16 ( & g2 ) ;\n while ( compressed_lines > 0 ) {\n line_packets = bytestream2_get_le16 ( & g2 ) ;\n if ( line_packets < 0 ) {\n line_packets = - line_packets ;\n y_ptr += line_packets * s -> frame . linesize [ 0 ] ;\n }\n else {\n compressed_lines -- ;\n pixel_ptr = y_ptr ;\n CHECK_PIXEL_PTR ( 0 ) ;\n pixel_countdown = s -> avctx -> width ;\n for ( i = 0 ;\n i < line_packets ;\n i ++ ) {\n pixel_skip = bytestream2_get_byte ( & g2 ) ;\n pixel_ptr += ( pixel_skip * 2 ) ;\n pixel_countdown -= pixel_skip ;\n byte_run = sign_extend ( bytestream2_get_byte ( & g2 ) , 8 ) ;\n if ( byte_run < 0 ) {\n byte_run = - byte_run ;\n pixel = bytestream2_get_le16 ( & g2 ) ;\n CHECK_PIXEL_PTR ( 2 * byte_run ) ;\n for ( j = 0 ;\n j < byte_run ;\n j ++ , pixel_countdown -= 2 ) {\n * ( ( signed short * ) ( & pixels [ pixel_ptr ] ) ) = pixel ;\n pixel_ptr += 2 ;\n }\n }\n else {\n CHECK_PIXEL_PTR ( 2 * byte_run ) ;\n for ( j = 0 ;\n j < byte_run ;\n j ++ , pixel_countdown -- ) {\n * ( ( signed short * ) ( & pixels [ pixel_ptr ] ) ) = bytestream2_get_le16 ( & g2 ) ;\n pixel_ptr += 2 ;\n }\n }\n }\n y_ptr += s -> frame . linesize [ 0 ] ;\n }\n }\n break ;\n case FLI_LC : av_log ( avctx , AV_LOG_ERROR , \"Unexpected FLI_LC chunk in non-paletised FLC\\n\" ) ;\n bytestream2_skip ( & g2 , chunk_size - 6 ) ;\n break ;\n case FLI_BLACK : memset ( pixels , 0x0000 , s -> frame . linesize [ 0 ] * s -> avctx -> height ) ;\n break ;\n case FLI_BRUN : y_ptr = 0 ;\n for ( lines = 0 ;\n lines < s -> avctx -> height ;\n lines ++ ) {\n pixel_ptr = y_ptr ;\n bytestream2_skip ( & g2 , 1 ) ;\n pixel_countdown = ( s -> avctx -> width * 2 ) ;\n while ( pixel_countdown > 0 ) {\n byte_run = sign_extend ( bytestream2_get_byte ( & g2 ) , 8 ) ;\n if ( byte_run > 0 ) {\n palette_idx1 = bytestream2_get_byte ( & g2 ) ;\n CHECK_PIXEL_PTR ( byte_run ) ;\n for ( j = 0 ;\n j < byte_run ;\n j ++ ) {\n pixels [ pixel_ptr ++ ] = palette_idx1 ;\n pixel_countdown -- ;\n if ( pixel_countdown < 0 ) av_log ( avctx , AV_LOG_ERROR , \"pixel_countdown < 0 (%d) (linea%d)\\n\" , pixel_countdown , lines ) ;\n }\n }\n else {\n byte_run = - byte_run ;\n CHECK_PIXEL_PTR ( byte_run ) ;\n for ( j = 0 ;\n j < byte_run ;\n j ++ ) {\n palette_idx1 = bytestream2_get_byte ( & g2 ) ;\n pixels [ pixel_ptr ++ ] = palette_idx1 ;\n pixel_countdown -- ;\n if ( pixel_countdown < 0 ) av_log ( avctx , AV_LOG_ERROR , \"pixel_countdown < 0 (%d) at line %d\\n\" , pixel_countdown , lines ) ;\n }\n }\n }\n # if HAVE_BIGENDIAN pixel_ptr = y_ptr ;\n pixel_countdown = s -> avctx -> width ;\n while ( pixel_countdown > 0 ) {\n * ( ( signed short * ) ( & pixels [ pixel_ptr ] ) ) = AV_RL16 ( & buf [ pixel_ptr ] ) ;\n pixel_ptr += 2 ;\n }\n # endif y_ptr += s -> frame . linesize [ 0 ] ;\n }\n break ;\n case FLI_DTA_BRUN : y_ptr = 0 ;\n for ( lines = 0 ;\n lines < s -> avctx -> height ;\n lines ++ ) {\n pixel_ptr = y_ptr ;\n bytestream2_skip ( & g2 , 1 ) ;\n pixel_countdown = s -> avctx -> width ;\n while ( pixel_countdown > 0 ) {\n byte_run = sign_extend ( bytestream2_get_byte ( & g2 ) , 8 ) ;\n if ( byte_run > 0 ) {\n pixel = bytestream2_get_le16 ( & g2 ) ;\n CHECK_PIXEL_PTR ( 2 * byte_run ) ;\n for ( j = 0 ;\n j < byte_run ;\n j ++ ) {\n * ( ( signed short * ) ( & pixels [ pixel_ptr ] ) ) = pixel ;\n pixel_ptr += 2 ;\n pixel_countdown -- ;\n if ( pixel_countdown < 0 ) av_log ( avctx , AV_LOG_ERROR , \"pixel_countdown < 0 (%d)\\n\" , pixel_countdown ) ;\n }\n }\n else {\n byte_run = - byte_run ;\n CHECK_PIXEL_PTR ( 2 * byte_run ) ;\n for ( j = 0 ;\n j < byte_run ;\n j ++ ) {\n * ( ( signed short * ) ( & pixels [ pixel_ptr ] ) ) = bytestream2_get_le16 ( & g2 ) ;\n pixel_ptr += 2 ;\n pixel_countdown -- ;\n if ( pixel_countdown < 0 ) av_log ( avctx , AV_LOG_ERROR , \"pixel_countdown < 0 (%d)\\n\" , pixel_countdown ) ;\n }\n }\n }\n y_ptr += s -> frame . linesize [ 0 ] ;\n }\n break ;\n case FLI_COPY : case FLI_DTA_COPY : if ( chunk_size - 6 > ( unsigned int ) ( s -> avctx -> width * s -> avctx -> height ) * 2 ) {\n av_log ( avctx , AV_LOG_ERROR , \"In chunk FLI_COPY : source data (%d bytes) \" \\ \"bigger than image, skipping chunk\\n\" , chunk_size - 6 ) ;\n bytestream2_skip ( & g2 , chunk_size - 6 ) ;\n }\n else {\n for ( y_ptr = 0 ;\n y_ptr < s -> frame . linesize [ 0 ] * s -> avctx -> height ;\n y_ptr += s -> frame . linesize [ 0 ] ) {\n pixel_countdown = s -> avctx -> width ;\n pixel_ptr = 0 ;\n while ( pixel_countdown > 0 ) {\n * ( ( signed short * ) ( & pixels [ y_ptr + pixel_ptr ] ) ) = bytestream2_get_le16 ( & g2 ) ;\n pixel_ptr += 2 ;\n pixel_countdown -- ;\n }\n }\n }\n break ;\n case FLI_MINI : bytestream2_skip ( & g2 , chunk_size - 6 ) ;\n break ;\n default : av_log ( avctx , AV_LOG_ERROR , \"Unrecognized chunk type: %d\\n\" , chunk_type ) ;\n break ;\n }\n frame_size -= chunk_size ;\n num_chunks -- ;\n }\n if ( ( bytestream2_get_bytes_left ( & g2 ) != 0 ) && ( bytestream2_get_bytes_left ( & g2 ) != 1 ) ) av_log ( avctx , AV_LOG_ERROR , \"Processed FLI chunk where chunk size = %d \" \\ \"and final chunk ptr = %d\\n\" , buf_size , bytestream2_tell ( & g2 ) ) ;\n * got_frame = 1 ;\n * ( AVFrame * ) data = s -> frame ;\n return buf_size ;\n }","target":1,"code_token_length":2112,"total_token_length":2348,"max_tokens_setting":4096}
+{"idx":283185,"func":"unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf,\n                                          unsigned char *limit)\n{\n    int extdatalen = 0;\n    unsigned char *orig = buf;\n    unsigned char *ret = buf;\n# ifndef OPENSSL_NO_NEXTPROTONEG\n    int next_proto_neg_seen;\n# endif\n\n    \/*\n     * don't add extensions for SSLv3, unless doing secure renegotiation\n     *\/\n    if (s->version == SSL3_VERSION && !s->s3->send_connection_binding)\n        return orig;\n\n    ret += 2;\n    if (ret >= limit)\n        return NULL;            \/* this really never occurs, but ... *\/\n\n    if (!s->hit && s->servername_done == 1\n        && s->session->tlsext_hostname != NULL) {\n        if ((long)(limit - ret - 4) < 0)\n            return NULL;\n\n        s2n(TLSEXT_TYPE_server_name, ret);\n        s2n(0, ret);\n    }\n\n    if (s->s3->send_connection_binding) {\n        int el;\n\n        if (!ssl_add_serverhello_renegotiate_ext(s, 0, &el, 0)) {\n            SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);\n            return NULL;\n        }\n\n        if ((limit - ret - 4 - el) < 0)\n            return NULL;\n\n        s2n(TLSEXT_TYPE_renegotiate, ret);\n        s2n(el, ret);\n\n        if (!ssl_add_serverhello_renegotiate_ext(s, ret, &el, el)) {\n            SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);\n            return NULL;\n        }\n\n        ret += el;\n    }\n# ifndef OPENSSL_NO_EC\n    if (s->tlsext_ecpointformatlist != NULL) {\n        \/*\n         * Add TLS extension ECPointFormats to the ServerHello message\n         *\/\n        long lenmax;\n\n        if ((lenmax = limit - ret - 5) < 0)\n            return NULL;\n        if (s->tlsext_ecpointformatlist_length > (unsigned long)lenmax)\n            return NULL;\n        if (s->tlsext_ecpointformatlist_length > 255) {\n            SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);\n            return NULL;\n        }\n\n        s2n(TLSEXT_TYPE_ec_point_formats, ret);\n        s2n(s->tlsext_ecpointformatlist_length + 1, ret);\n        *(ret++) = (unsigned char)s->tlsext_ecpointformatlist_length;\n        memcpy(ret, s->tlsext_ecpointformatlist,\n               s->tlsext_ecpointformatlist_length);\n        ret += s->tlsext_ecpointformatlist_length;\n\n    }\n    \/*\n     * Currently the server should not respond with a SupportedCurves\n     * extension\n     *\/\n# endif                         \/* OPENSSL_NO_EC *\/\n\n    if (s->tlsext_ticket_expected && !(SSL_get_options(s) & SSL_OP_NO_TICKET)) {\n        if ((long)(limit - ret - 4) < 0)\n            return NULL;\n        s2n(TLSEXT_TYPE_session_ticket, ret);\n        s2n(0, ret);\n    }\n\n    if (s->tlsext_status_expected) {\n        if ((long)(limit - ret - 4) < 0)\n            return NULL;\n        s2n(TLSEXT_TYPE_status_request, ret);\n        s2n(0, ret);\n    }\n# ifdef TLSEXT_TYPE_opaque_prf_input\n    if (s->s3->server_opaque_prf_input != NULL && s->version != DTLS1_VERSION) {\n        size_t sol = s->s3->server_opaque_prf_input_len;\n\n        if ((long)(limit - ret - 6 - sol) < 0)\n            return NULL;\n        if (sol > 0xFFFD)       \/* can't happen *\/\n            return NULL;\n\n        s2n(TLSEXT_TYPE_opaque_prf_input, ret);\n        s2n(sol + 2, ret);\n        s2n(sol, ret);\n        memcpy(ret, s->s3->server_opaque_prf_input, sol);\n        ret += sol;\n    }\n# endif\n\n# ifndef OPENSSL_NO_SRTP\n    if (SSL_IS_DTLS(s) && s->srtp_profile) {\n        int el;\n\n        ssl_add_serverhello_use_srtp_ext(s, 0, &el, 0);\n\n        if ((limit - ret - 4 - el) < 0)\n            return NULL;\n\n        s2n(TLSEXT_TYPE_use_srtp, ret);\n        s2n(el, ret);\n\n        if (ssl_add_serverhello_use_srtp_ext(s, ret, &el, el)) {\n            SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);\n            return NULL;\n        }\n        ret += el;\n    }\n# endif\n\n    if (((s->s3->tmp.new_cipher->id & 0xFFFF) == 0x80\n         || (s->s3->tmp.new_cipher->id & 0xFFFF) == 0x81)\n        && (SSL_get_options(s) & SSL_OP_CRYPTOPRO_TLSEXT_BUG)) {\n        const unsigned char cryptopro_ext[36] = {\n            0xfd, 0xe8,         \/* 65000 *\/\n            0x00, 0x20,         \/* 32 bytes length *\/\n            0x30, 0x1e, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85,\n            0x03, 0x02, 0x02, 0x09, 0x30, 0x08, 0x06, 0x06,\n            0x2a, 0x85, 0x03, 0x02, 0x02, 0x16, 0x30, 0x08,\n            0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x17\n        };\n        if (limit - ret < 36)\n            return NULL;\n        memcpy(ret, cryptopro_ext, 36);\n        ret += 36;\n\n    }\n# ifndef OPENSSL_NO_HEARTBEATS\n    \/* Add Heartbeat extension if we've received one *\/\n    if (s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) {\n        if ((limit - ret - 4 - 1) < 0)\n            return NULL;\n        s2n(TLSEXT_TYPE_heartbeat, ret);\n        s2n(1, ret);\n        \/*-\n         * Set mode:\n         * 1: peer may send requests\n         * 2: peer not allowed to send requests\n         *\/\n        if (s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_RECV_REQUESTS)\n            *(ret++) = SSL_TLSEXT_HB_DONT_SEND_REQUESTS;\n        else\n            *(ret++) = SSL_TLSEXT_HB_ENABLED;\n\n    }\n# endif\n\n# ifndef OPENSSL_NO_NEXTPROTONEG\n    next_proto_neg_seen = s->s3->next_proto_neg_seen;\n    s->s3->next_proto_neg_seen = 0;\n    if (next_proto_neg_seen && s->ctx->next_protos_advertised_cb) {\n        const unsigned char *npa;\n        unsigned int npalen;\n        int r;\n\n        r = s->ctx->next_protos_advertised_cb(s, &npa, &npalen,\n                                              s->\n                                              ctx->next_protos_advertised_cb_arg);\n        if (r == SSL_TLSEXT_ERR_OK) {\n            if ((long)(limit - ret - 4 - npalen) < 0)\n                return NULL;\n            s2n(TLSEXT_TYPE_next_proto_neg, ret);\n            s2n(npalen, ret);\n            memcpy(ret, npa, npalen);\n            ret += npalen;\n            s->s3->next_proto_neg_seen = 1;\n        }\n    }\n# endif\n\n    if ((extdatalen = ret - orig - 2) == 0)\n        return orig;\n\n    s2n(extdatalen, orig);\n    return ret;\n}\n","target":0,"code_token_length":1893,"total_token_length":2129,"max_tokens_setting":4096}
+{"idx":350587,"func":"wolfssl_connect_step1(struct Curl_easy *data, struct connectdata *conn,\n                     int sockindex)\n{\n  char *ciphers;\n  struct ssl_connect_data *connssl = &conn->ssl[sockindex];\n  struct ssl_backend_data *backend = connssl->backend;\n  SSL_METHOD* req_method = NULL;\n  curl_socket_t sockfd = conn->sock[sockindex];\n#ifdef HAVE_SNI\n  bool sni = FALSE;\n#define use_sni(x)  sni = (x)\n#else\n#define use_sni(x)  Curl_nop_stmt\n#endif\n\n  if(connssl->state == ssl_connection_complete)\n    return CURLE_OK;\n\n  if(SSL_CONN_CONFIG(version_max) != CURL_SSLVERSION_MAX_NONE) {\n    failf(data, \"wolfSSL does not support to set maximum SSL\/TLS version\");\n    return CURLE_SSL_CONNECT_ERROR;\n  }\n\n  \/* check to see if we've been told to use an explicit SSL\/TLS version *\/\n  switch(SSL_CONN_CONFIG(version)) {\n  case CURL_SSLVERSION_DEFAULT:\n  case CURL_SSLVERSION_TLSv1:\n#if LIBWOLFSSL_VERSION_HEX >= 0x03003000 \/* >= 3.3.0 *\/\n    \/* minimum protocol version is set later after the CTX object is created *\/\n    req_method = SSLv23_client_method();\n#else\n    infof(data, \"wolfSSL <3.3.0 cannot be configured to use TLS 1.0-1.2, \"\n          \"TLS 1.0 is used exclusively\\n\");\n    req_method = TLSv1_client_method();\n#endif\n    use_sni(TRUE);\n    break;\n  case CURL_SSLVERSION_TLSv1_0:\n#if defined(WOLFSSL_ALLOW_TLSV10) && !defined(NO_OLD_TLS)\n    req_method = TLSv1_client_method();\n    use_sni(TRUE);\n#else\n    failf(data, \"wolfSSL does not support TLS 1.0\");\n    return CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURL_SSLVERSION_TLSv1_1:\n#ifndef NO_OLD_TLS\n    req_method = TLSv1_1_client_method();\n    use_sni(TRUE);\n#else\n    failf(data, \"wolfSSL does not support TLS 1.1\");\n    return CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURL_SSLVERSION_TLSv1_2:\n    req_method = TLSv1_2_client_method();\n    use_sni(TRUE);\n    break;\n  case CURL_SSLVERSION_TLSv1_3:\n#ifdef WOLFSSL_TLS13\n    req_method = wolfTLSv1_3_client_method();\n    use_sni(TRUE);\n    break;\n#else\n    failf(data, \"wolfSSL: TLS 1.3 is not yet supported\");\n    return CURLE_SSL_CONNECT_ERROR;\n#endif\n  case CURL_SSLVERSION_SSLv3:\n#ifdef WOLFSSL_ALLOW_SSLV3\n    req_method = SSLv3_client_method();\n    use_sni(FALSE);\n#else\n    failf(data, \"wolfSSL does not support SSLv3\");\n    return CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURL_SSLVERSION_SSLv2:\n    failf(data, \"wolfSSL does not support SSLv2\");\n    return CURLE_SSL_CONNECT_ERROR;\n  default:\n    failf(data, \"Unrecognized parameter passed via CURLOPT_SSLVERSION\");\n    return CURLE_SSL_CONNECT_ERROR;\n  }\n\n  if(!req_method) {\n    failf(data, \"SSL: couldn't create a method!\");\n    return CURLE_OUT_OF_MEMORY;\n  }\n\n  if(backend->ctx)\n    SSL_CTX_free(backend->ctx);\n  backend->ctx = SSL_CTX_new(req_method);\n\n  if(!backend->ctx) {\n    failf(data, \"SSL: couldn't create a context!\");\n    return CURLE_OUT_OF_MEMORY;\n  }\n\n  switch(SSL_CONN_CONFIG(version)) {\n  case CURL_SSLVERSION_DEFAULT:\n  case CURL_SSLVERSION_TLSv1:\n#if LIBWOLFSSL_VERSION_HEX > 0x03004006 \/* > 3.4.6 *\/\n    \/* Versions 3.3.0 to 3.4.6 we know the minimum protocol version is\n     * whatever minimum version of TLS was built in and at least TLS 1.0. For\n     * later library versions that could change (eg TLS 1.0 built in but\n     * defaults to TLS 1.1) so we have this short circuit evaluation to find\n     * the minimum supported TLS version.\n    *\/\n    if((wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1) != 1) &&\n       (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_1) != 1) &&\n       (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_2) != 1)\n#ifdef WOLFSSL_TLS13\n       && (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_3) != 1)\n#endif\n      ) {\n      failf(data, \"SSL: couldn't set the minimum protocol version\");\n      return CURLE_SSL_CONNECT_ERROR;\n    }\n#endif\n    break;\n  }\n\n  ciphers = SSL_CONN_CONFIG(cipher_list);\n  if(ciphers) {\n    if(!SSL_CTX_set_cipher_list(backend->ctx, ciphers)) {\n      failf(data, \"failed setting cipher list: %s\", ciphers);\n      return CURLE_SSL_CIPHER;\n    }\n    infof(data, \"Cipher selection: %s\\n\", ciphers);\n  }\n\n#ifndef NO_FILESYSTEM\n  \/* load trusted cacert *\/\n  if(SSL_CONN_CONFIG(CAfile)) {\n    if(1 != SSL_CTX_load_verify_locations(backend->ctx,\n                                      SSL_CONN_CONFIG(CAfile),\n                                      SSL_CONN_CONFIG(CApath))) {\n      if(SSL_CONN_CONFIG(verifypeer)) {\n        \/* Fail if we insist on successfully verifying the server. *\/\n        failf(data, \"error setting certificate verify locations:\"\n              \" CAfile: %s CApath: %s\",\n              SSL_CONN_CONFIG(CAfile)?\n              SSL_CONN_CONFIG(CAfile): \"none\",\n              SSL_CONN_CONFIG(CApath)?\n              SSL_CONN_CONFIG(CApath) : \"none\");\n        return CURLE_SSL_CACERT_BADFILE;\n      }\n      else {\n        \/* Just continue with a warning if no strict certificate\n           verification is required. *\/\n        infof(data, \"error setting certificate verify locations,\"\n              \" continuing anyway:\\n\");\n      }\n    }\n    else {\n      \/* Everything is fine. *\/\n      infof(data, \"successfully set certificate verify locations:\\n\");\n    }\n    infof(data, \" CAfile: %s\\n\",\n          SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile) : \"none\");\n    infof(data, \" CApath: %s\\n\",\n          SSL_CONN_CONFIG(CApath) ? SSL_CONN_CONFIG(CApath) : \"none\");\n  }\n\n  \/* Load the client certificate, and private key *\/\n  if(SSL_SET_OPTION(primary.clientcert) && SSL_SET_OPTION(key)) {\n    int file_type = do_file_type(SSL_SET_OPTION(cert_type));\n\n    if(SSL_CTX_use_certificate_file(backend->ctx,\n                                    SSL_SET_OPTION(primary.clientcert),\n                                    file_type) != 1) {\n      failf(data, \"unable to use client certificate (no key or wrong pass\"\n            \" phrase?)\");\n      return CURLE_SSL_CONNECT_ERROR;\n    }\n\n    file_type = do_file_type(SSL_SET_OPTION(key_type));\n    if(SSL_CTX_use_PrivateKey_file(backend->ctx, SSL_SET_OPTION(key),\n                                    file_type) != 1) {\n      failf(data, \"unable to set private key\");\n      return CURLE_SSL_CONNECT_ERROR;\n    }\n  }\n#endif \/* !NO_FILESYSTEM *\/\n\n  \/* SSL always tries to verify the peer, this only says whether it should\n   * fail to connect if the verification fails, or if it should continue\n   * anyway. In the latter case the result of the verification is checked with\n   * SSL_get_verify_result() below. *\/\n  SSL_CTX_set_verify(backend->ctx,\n                     SSL_CONN_CONFIG(verifypeer)?SSL_VERIFY_PEER:\n                                                 SSL_VERIFY_NONE,\n                     NULL);\n\n#ifdef HAVE_SNI\n  if(sni) {\n    struct in_addr addr4;\n#ifdef ENABLE_IPV6\n    struct in6_addr addr6;\n#endif\n#ifndef CURL_DISABLE_PROXY\n    const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :\n      conn->host.name;\n#else\n    const char * const hostname = conn->host.name;\n#endif\n    size_t hostname_len = strlen(hostname);\n    if((hostname_len < USHRT_MAX) &&\n       (0 == Curl_inet_pton(AF_INET, hostname, &addr4)) &&\n#ifdef ENABLE_IPV6\n       (0 == Curl_inet_pton(AF_INET6, hostname, &addr6)) &&\n#endif\n       (wolfSSL_CTX_UseSNI(backend->ctx, WOLFSSL_SNI_HOST_NAME, hostname,\n                          (unsigned short)hostname_len) != 1)) {\n      infof(data, \"WARNING: failed to configure server name indication (SNI) \"\n            \"TLS extension\\n\");\n    }\n  }\n#endif\n\n  \/* give application a chance to interfere with SSL set up. *\/\n  if(data->set.ssl.fsslctx) {\n    CURLcode result = (*data->set.ssl.fsslctx)(data, backend->ctx,\n                                               data->set.ssl.fsslctxp);\n    if(result) {\n      failf(data, \"error signaled by ssl ctx callback\");\n      return result;\n    }\n  }\n#ifdef NO_FILESYSTEM\n  else if(SSL_CONN_CONFIG(verifypeer)) {\n    failf(data, \"SSL: Certificates can't be loaded because wolfSSL was built\"\n          \" with \\\"no filesystem\\\". Either disable peer verification\"\n          \" (insecure) or if you are building an application with libcurl you\"\n          \" can load certificates via CURLOPT_SSL_CTX_FUNCTION.\");\n    return CURLE_SSL_CONNECT_ERROR;\n  }\n#endif\n\n  \/* Let's make an SSL structure *\/\n  if(backend->handle)\n    SSL_free(backend->handle);\n  backend->handle = SSL_new(backend->ctx);\n  if(!backend->handle) {\n    failf(data, \"SSL: couldn't create a context (handle)!\");\n    return CURLE_OUT_OF_MEMORY;\n  }\n\n#ifdef HAVE_ALPN\n  if(conn->bits.tls_enable_alpn) {\n    char protocols[128];\n    *protocols = '\\0';\n\n    \/* wolfSSL's ALPN protocol name list format is a comma separated string of\n       protocols in descending order of preference, eg: \"h2,http\/1.1\" *\/\n\n#ifdef USE_NGHTTP2\n    if(data->state.httpversion >= CURL_HTTP_VERSION_2) {\n      strcpy(protocols + strlen(protocols), NGHTTP2_PROTO_VERSION_ID \",\");\n      infof(data, \"ALPN, offering %s\\n\", NGHTTP2_PROTO_VERSION_ID);\n    }\n#endif\n\n    strcpy(protocols + strlen(protocols), ALPN_HTTP_1_1);\n    infof(data, \"ALPN, offering %s\\n\", ALPN_HTTP_1_1);\n\n    if(wolfSSL_UseALPN(backend->handle, protocols,\n                       (unsigned)strlen(protocols),\n                       WOLFSSL_ALPN_CONTINUE_ON_MISMATCH) != SSL_SUCCESS) {\n      failf(data, \"SSL: failed setting ALPN protocols\");\n      return CURLE_SSL_CONNECT_ERROR;\n    }\n  }\n#endif \/* HAVE_ALPN *\/\n\n#ifdef OPENSSL_EXTRA\n  if(Curl_tls_keylog_enabled()) {\n    \/* Ensure the Client Random is preserved. *\/\n    wolfSSL_KeepArrays(backend->handle);\n#if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)\n    wolfSSL_set_tls13_secret_cb(backend->handle,\n                                wolfssl_tls13_secret_callback, NULL);\n#endif\n  }\n#endif \/* OPENSSL_EXTRA *\/\n\n#ifdef HAVE_SECURE_RENEGOTIATION\n  if(wolfSSL_UseSecureRenegotiation(backend->handle) != SSL_SUCCESS) {\n    failf(data, \"SSL: failed setting secure renegotiation\");\n    return CURLE_SSL_CONNECT_ERROR;\n  }\n#endif \/* HAVE_SECURE_RENEGOTIATION *\/\n\n  \/* Check if there's a cached ID we can\/should use here! *\/\n  if(SSL_SET_OPTION(primary.sessionid)) {\n    void *ssl_sessionid = NULL;\n\n    Curl_ssl_sessionid_lock(data);\n    if(!Curl_ssl_getsessionid(data, conn, &ssl_sessionid, NULL, sockindex)) {\n      \/* we got a session id, use it! *\/\n      if(!SSL_set_session(backend->handle, ssl_sessionid)) {\n        char error_buffer[WOLFSSL_MAX_ERROR_SZ];\n        Curl_ssl_sessionid_unlock(data);\n        failf(data, \"SSL: SSL_set_session failed: %s\",\n              ERR_error_string(SSL_get_error(backend->handle, 0),\n                               error_buffer));\n        return CURLE_SSL_CONNECT_ERROR;\n      }\n      \/* Informational message *\/\n      infof(data, \"SSL re-using session ID\\n\");\n    }\n    Curl_ssl_sessionid_unlock(data);\n  }\n\n  \/* pass the raw socket into the SSL layer *\/\n  if(!SSL_set_fd(backend->handle, (int)sockfd)) {\n    failf(data, \"SSL: SSL_set_fd failed\");\n    return CURLE_SSL_CONNECT_ERROR;\n  }\n\n  connssl->connecting_state = ssl_connect_2;\n  return CURLE_OK;\n}","target":1,"code_token_length":2873,"total_token_length":3109,"max_tokens_setting":4096}
+{"idx":3634,"func":"buf_copy_options(buf_T *buf, int flags)\n{\n    int\t\tshould_copy = TRUE;\n    char_u\t*save_p_isk = NULL;\t    \/\/ init for GCC\n    int\t\tdont_do_help;\n    int\t\tdid_isk = FALSE;\n\n    \/*\n     * Skip this when the option defaults have not been set yet.  Happens when\n     * main() allocates the first buffer.\n     *\/\n    if (p_cpo != NULL)\n    {\n\t\/*\n\t * Always copy when entering and 'cpo' contains 'S'.\n\t * Don't copy when already initialized.\n\t * Don't copy when 'cpo' contains 's' and not entering.\n\t * 'S'\tBCO_ENTER  initialized\t's'  should_copy\n\t * yes\t  yes\t       X\t X\tTRUE\n\t * yes\t  no\t      yes\t X\tFALSE\n\t * no\t   X\t      yes\t X\tFALSE\n\t *  X\t  no\t      no\tyes\tFALSE\n\t *  X\t  no\t      no\tno\tTRUE\n\t * no\t  yes\t      no\t X\tTRUE\n\t *\/\n\tif ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))\n\t\t&& (buf->b_p_initialized\n\t\t    || (!(flags & BCO_ENTER)\n\t\t\t&& vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))\n\t    should_copy = FALSE;\n\n\tif (should_copy || (flags & BCO_ALWAYS))\n\t{\n#ifdef FEAT_EVAL\n\t    CLEAR_FIELD(buf->b_p_script_ctx);\n\t    init_buf_opt_idx();\n#endif\n\t    \/\/ Don't copy the options specific to a help buffer when\n\t    \/\/ BCO_NOHELP is given or the options were initialized already\n\t    \/\/ (jumping back to a help file with CTRL-T or CTRL-O)\n\t    dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)\n\t\t\t\t\t\t       || buf->b_p_initialized;\n\t    if (dont_do_help)\t\t\/\/ don't free b_p_isk\n\t    {\n\t\tsave_p_isk = buf->b_p_isk;\n\t\tbuf->b_p_isk = NULL;\n\t    }\n\t    \/*\n\t     * Always free the allocated strings.  If not already initialized,\n\t     * reset 'readonly' and copy 'fileformat'.\n\t     *\/\n\t    if (!buf->b_p_initialized)\n\t    {\n\t\tfree_buf_options(buf, TRUE);\n\t\tbuf->b_p_ro = FALSE;\t\t\/\/ don't copy readonly\n\t\tbuf->b_p_tx = p_tx;\n\t\tbuf->b_p_fenc = vim_strsave(p_fenc);\n\t\tswitch (*p_ffs)\n\t\t{\n\t\t    case 'm':\n\t\t\tbuf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;\n\t\t    case 'd':\n\t\t\tbuf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;\n\t\t    case 'u':\n\t\t\tbuf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;\n\t\t    default:\n\t\t\tbuf->b_p_ff = vim_strsave(p_ff);\n\t\t}\n\t\tif (buf->b_p_ff != NULL)\n\t\t    buf->b_start_ffc = *buf->b_p_ff;\n\t\tbuf->b_p_bh = empty_option;\n\t\tbuf->b_p_bt = empty_option;\n\t    }\n\t    else\n\t\tfree_buf_options(buf, FALSE);\n\n\t    buf->b_p_ai = p_ai;\n\t    COPY_OPT_SCTX(buf, BV_AI);\n\t    buf->b_p_ai_nopaste = p_ai_nopaste;\n\t    buf->b_p_sw = p_sw;\n\t    COPY_OPT_SCTX(buf, BV_SW);\n\t    buf->b_p_tw = p_tw;\n\t    COPY_OPT_SCTX(buf, BV_TW);\n\t    buf->b_p_tw_nopaste = p_tw_nopaste;\n\t    buf->b_p_tw_nobin = p_tw_nobin;\n\t    buf->b_p_wm = p_wm;\n\t    COPY_OPT_SCTX(buf, BV_WM);\n\t    buf->b_p_wm_nopaste = p_wm_nopaste;\n\t    buf->b_p_wm_nobin = p_wm_nobin;\n\t    buf->b_p_bin = p_bin;\n\t    COPY_OPT_SCTX(buf, BV_BIN);\n\t    buf->b_p_bomb = p_bomb;\n\t    COPY_OPT_SCTX(buf, BV_BOMB);\n\t    buf->b_p_fixeol = p_fixeol;\n\t    COPY_OPT_SCTX(buf, BV_FIXEOL);\n\t    buf->b_p_et = p_et;\n\t    COPY_OPT_SCTX(buf, BV_ET);\n\t    buf->b_p_et_nobin = p_et_nobin;\n\t    buf->b_p_et_nopaste = p_et_nopaste;\n\t    buf->b_p_ml = p_ml;\n\t    COPY_OPT_SCTX(buf, BV_ML);\n\t    buf->b_p_ml_nobin = p_ml_nobin;\n\t    buf->b_p_inf = p_inf;\n\t    COPY_OPT_SCTX(buf, BV_INF);\n\t    if (cmdmod.cmod_flags & CMOD_NOSWAPFILE)\n\t\tbuf->b_p_swf = FALSE;\n\t    else\n\t    {\n\t\tbuf->b_p_swf = p_swf;\n\t\tCOPY_OPT_SCTX(buf, BV_SWF);\n\t    }\n\t    buf->b_p_cpt = vim_strsave(p_cpt);\n\t    COPY_OPT_SCTX(buf, BV_CPT);\n#ifdef BACKSLASH_IN_FILENAME\n\t    buf->b_p_csl = vim_strsave(p_csl);\n\t    COPY_OPT_SCTX(buf, BV_CSL);\n#endif\n#ifdef FEAT_COMPL_FUNC\n\t    buf->b_p_cfu = vim_strsave(p_cfu);\n\t    COPY_OPT_SCTX(buf, BV_CFU);\n\t    set_buflocal_cfu_callback(buf);\n\t    buf->b_p_ofu = vim_strsave(p_ofu);\n\t    COPY_OPT_SCTX(buf, BV_OFU);\n\t    set_buflocal_ofu_callback(buf);\n#endif\n#ifdef FEAT_EVAL\n\t    buf->b_p_tfu = vim_strsave(p_tfu);\n\t    COPY_OPT_SCTX(buf, BV_TFU);\n\t    set_buflocal_tfu_callback(buf);\n#endif\n\t    buf->b_p_sts = p_sts;\n\t    COPY_OPT_SCTX(buf, BV_STS);\n\t    buf->b_p_sts_nopaste = p_sts_nopaste;\n#ifdef FEAT_VARTABS\n\t    buf->b_p_vsts = vim_strsave(p_vsts);\n\t    COPY_OPT_SCTX(buf, BV_VSTS);\n\t    if (p_vsts && p_vsts != empty_option)\n\t\t(void)tabstop_set(p_vsts, &buf->b_p_vsts_array);\n\t    else\n\t\tbuf->b_p_vsts_array = 0;\n\t    buf->b_p_vsts_nopaste = p_vsts_nopaste\n\t\t\t\t ? vim_strsave(p_vsts_nopaste) : NULL;\n#endif\n\t    buf->b_p_sn = p_sn;\n\t    COPY_OPT_SCTX(buf, BV_SN);\n\t    buf->b_p_com = vim_strsave(p_com);\n\t    COPY_OPT_SCTX(buf, BV_COM);\n#ifdef FEAT_FOLDING\n\t    buf->b_p_cms = vim_strsave(p_cms);\n\t    COPY_OPT_SCTX(buf, BV_CMS);\n#endif\n\t    buf->b_p_fo = vim_strsave(p_fo);\n\t    COPY_OPT_SCTX(buf, BV_FO);\n\t    buf->b_p_flp = vim_strsave(p_flp);\n\t    COPY_OPT_SCTX(buf, BV_FLP);\n\t    \/\/ NOTE: Valgrind may report a bogus memory leak for 'nrformats'\n\t    \/\/ when it is set to 8 bytes in defaults.vim.\n\t    buf->b_p_nf = vim_strsave(p_nf);\n\t    COPY_OPT_SCTX(buf, BV_NF);\n\t    buf->b_p_mps = vim_strsave(p_mps);\n\t    COPY_OPT_SCTX(buf, BV_MPS);\n#ifdef FEAT_SMARTINDENT\n\t    buf->b_p_si = p_si;\n\t    COPY_OPT_SCTX(buf, BV_SI);\n#endif\n\t    buf->b_p_ci = p_ci;\n\t    COPY_OPT_SCTX(buf, BV_CI);\n#ifdef FEAT_CINDENT\n\t    buf->b_p_cin = p_cin;\n\t    COPY_OPT_SCTX(buf, BV_CIN);\n\t    buf->b_p_cink = vim_strsave(p_cink);\n\t    COPY_OPT_SCTX(buf, BV_CINK);\n\t    buf->b_p_cino = vim_strsave(p_cino);\n\t    COPY_OPT_SCTX(buf, BV_CINO);\n#endif\n\t    \/\/ Don't copy 'filetype', it must be detected\n\t    buf->b_p_ft = empty_option;\n\t    buf->b_p_pi = p_pi;\n\t    COPY_OPT_SCTX(buf, BV_PI);\n#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)\n\t    buf->b_p_cinw = vim_strsave(p_cinw);\n\t    COPY_OPT_SCTX(buf, BV_CINW);\n#endif\n#ifdef FEAT_LISP\n\t    buf->b_p_lisp = p_lisp;\n\t    COPY_OPT_SCTX(buf, BV_LISP);\n#endif\n#ifdef FEAT_SYN_HL\n\t    \/\/ Don't copy 'syntax', it must be set\n\t    buf->b_p_syn = empty_option;\n\t    buf->b_p_smc = p_smc;\n\t    COPY_OPT_SCTX(buf, BV_SMC);\n\t    buf->b_s.b_syn_isk = empty_option;\n#endif\n#ifdef FEAT_SPELL\n\t    buf->b_s.b_p_spc = vim_strsave(p_spc);\n\t    COPY_OPT_SCTX(buf, BV_SPC);\n\t    (void)compile_cap_prog(&buf->b_s);\n\t    buf->b_s.b_p_spf = vim_strsave(p_spf);\n\t    COPY_OPT_SCTX(buf, BV_SPF);\n\t    buf->b_s.b_p_spl = vim_strsave(p_spl);\n\t    COPY_OPT_SCTX(buf, BV_SPL);\n\t    buf->b_s.b_p_spo = vim_strsave(p_spo);\n\t    COPY_OPT_SCTX(buf, BV_SPO);\n#endif\n#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)\n\t    buf->b_p_inde = vim_strsave(p_inde);\n\t    COPY_OPT_SCTX(buf, BV_INDE);\n\t    buf->b_p_indk = vim_strsave(p_indk);\n\t    COPY_OPT_SCTX(buf, BV_INDK);\n#endif\n\t    buf->b_p_fp = empty_option;\n#if defined(FEAT_EVAL)\n\t    buf->b_p_fex = vim_strsave(p_fex);\n\t    COPY_OPT_SCTX(buf, BV_FEX);\n#endif\n#ifdef FEAT_CRYPT\n\t    buf->b_p_key = vim_strsave(p_key);\n\t    COPY_OPT_SCTX(buf, BV_KEY);\n#endif\n#ifdef FEAT_SEARCHPATH\n\t    buf->b_p_sua = vim_strsave(p_sua);\n\t    COPY_OPT_SCTX(buf, BV_SUA);\n#endif\n#ifdef FEAT_KEYMAP\n\t    buf->b_p_keymap = vim_strsave(p_keymap);\n\t    COPY_OPT_SCTX(buf, BV_KMAP);\n\t    buf->b_kmap_state |= KEYMAP_INIT;\n#endif\n#ifdef FEAT_TERMINAL\n\t    buf->b_p_twsl = p_twsl;\n\t    COPY_OPT_SCTX(buf, BV_TWSL);\n#endif\n\t    \/\/ This isn't really an option, but copying the langmap and IME\n\t    \/\/ state from the current buffer is better than resetting it.\n\t    buf->b_p_iminsert = p_iminsert;\n\t    COPY_OPT_SCTX(buf, BV_IMI);\n\t    buf->b_p_imsearch = p_imsearch;\n\t    COPY_OPT_SCTX(buf, BV_IMS);\n\n\t    \/\/ options that are normally global but also have a local value\n\t    \/\/ are not copied, start using the global value\n\t    buf->b_p_ar = -1;\n\t    buf->b_p_ul = NO_LOCAL_UNDOLEVEL;\n\t    buf->b_p_bkc = empty_option;\n\t    buf->b_bkc_flags = 0;\n#ifdef FEAT_QUICKFIX\n\t    buf->b_p_gp = empty_option;\n\t    buf->b_p_mp = empty_option;\n\t    buf->b_p_efm = empty_option;\n#endif\n\t    buf->b_p_ep = empty_option;\n\t    buf->b_p_kp = empty_option;\n\t    buf->b_p_path = empty_option;\n\t    buf->b_p_tags = empty_option;\n\t    buf->b_p_tc = empty_option;\n\t    buf->b_tc_flags = 0;\n#ifdef FEAT_FIND_ID\n\t    buf->b_p_def = empty_option;\n\t    buf->b_p_inc = empty_option;\n# ifdef FEAT_EVAL\n\t    buf->b_p_inex = vim_strsave(p_inex);\n\t    COPY_OPT_SCTX(buf, BV_INEX);\n# endif\n#endif\n\t    buf->b_p_dict = empty_option;\n\t    buf->b_p_tsr = empty_option;\n#ifdef FEAT_COMPL_FUNC\n\t    buf->b_p_tsrfu = empty_option;\n#endif\n#ifdef FEAT_TEXTOBJ\n\t    buf->b_p_qe = vim_strsave(p_qe);\n\t    COPY_OPT_SCTX(buf, BV_QE);\n#endif\n#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)\n\t    buf->b_p_bexpr = empty_option;\n#endif\n#if defined(FEAT_CRYPT)\n\t    buf->b_p_cm = empty_option;\n#endif\n#ifdef FEAT_PERSISTENT_UNDO\n\t    buf->b_p_udf = p_udf;\n\t    COPY_OPT_SCTX(buf, BV_UDF);\n#endif\n#ifdef FEAT_LISP\n\t    buf->b_p_lw = empty_option;\n#endif\n\t    buf->b_p_menc = empty_option;\n\n\t    \/*\n\t     * Don't copy the options set by ex_help(), use the saved values,\n\t     * when going from a help buffer to a non-help buffer.\n\t     * Don't touch these at all when BCO_NOHELP is used and going from\n\t     * or to a help buffer.\n\t     *\/\n\t    if (dont_do_help)\n\t    {\n\t\tbuf->b_p_isk = save_p_isk;\n#ifdef FEAT_VARTABS\n\t\tif (p_vts && p_vts != empty_option && !buf->b_p_vts_array)\n\t\t    (void)tabstop_set(p_vts, &buf->b_p_vts_array);\n\t\telse\n\t\t    buf->b_p_vts_array = NULL;\n#endif\n\t    }\n\t    else\n\t    {\n\t\tbuf->b_p_isk = vim_strsave(p_isk);\n\t\tCOPY_OPT_SCTX(buf, BV_ISK);\n\t\tdid_isk = TRUE;\n\t\tbuf->b_p_ts = p_ts;\n\t\tCOPY_OPT_SCTX(buf, BV_TS);\n#ifdef FEAT_VARTABS\n\t\tbuf->b_p_vts = vim_strsave(p_vts);\n\t\tCOPY_OPT_SCTX(buf, BV_VTS);\n\t\tif (p_vts && p_vts != empty_option && !buf->b_p_vts_array)\n\t\t    (void)tabstop_set(p_vts, &buf->b_p_vts_array);\n\t\telse\n\t\t    buf->b_p_vts_array = NULL;\n#endif\n\t\tbuf->b_help = FALSE;\n\t\tif (buf->b_p_bt[0] == 'h')\n\t\t    clear_string_option(&buf->b_p_bt);\n\t\tbuf->b_p_ma = p_ma;\n\t\tCOPY_OPT_SCTX(buf, BV_MA);\n\t    }\n\t}\n\n\t\/*\n\t * When the options should be copied (ignoring BCO_ALWAYS), set the\n\t * flag that indicates that the options have been initialized.\n\t *\/\n\tif (should_copy)\n\t    buf->b_p_initialized = TRUE;\n    }\n\n    check_buf_options(buf);\t    \/\/ make sure we don't have NULLs\n    if (did_isk)\n\t(void)buf_init_chartab(buf, FALSE);\n}","target":1,"code_token_length":3340,"total_token_length":3576,"max_tokens_setting":4096}
+{"idx":338960,"func":"static av_cold int cook_decode_init(AVCodecContext *avctx)\n\n{\n\n    COOKContext *q = avctx->priv_data;\n\n    const uint8_t *edata_ptr = avctx->extradata;\n\n    const uint8_t *edata_ptr_end = edata_ptr + avctx->extradata_size;\n\n    int extradata_size = avctx->extradata_size;\n\n    int s = 0;\n\n    unsigned int channel_mask = 0;\n\n    int samples_per_frame;\n\n    int ret;\n\n    q->avctx = avctx;\n\n\n\n    \/* Take care of the codec specific extradata. *\/\n\n    if (extradata_size < 8) {\n\n        av_log(avctx, AV_LOG_ERROR, \"Necessary extradata missing!\\n\");\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n    av_log(avctx, AV_LOG_DEBUG, \"codecdata_length=%d\\n\", avctx->extradata_size);\n\n\n\n    \/* Take data from the AVCodecContext (RM container). *\/\n\n    if (!avctx->channels) {\n\n        av_log(avctx, AV_LOG_ERROR, \"Invalid number of channels\\n\");\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    \/* Initialize RNG. *\/\n\n    av_lfg_init(&q->random_state, 0);\n\n\n\n    ff_audiodsp_init(&q->adsp);\n\n\n\n    while (edata_ptr < edata_ptr_end) {\n\n        \/* 8 for mono, 16 for stereo, ? for multichannel\n\n           Swap to right endianness so we don't need to care later on. *\/\n\n        if (extradata_size >= 8) {\n\n            q->subpacket[s].cookversion = bytestream_get_be32(&edata_ptr);\n\n            samples_per_frame           = bytestream_get_be16(&edata_ptr);\n\n            q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr);\n\n            extradata_size -= 8;\n\n        }\n\n        if (extradata_size >= 8) {\n\n            bytestream_get_be32(&edata_ptr);    \/\/ Unknown unused\n\n            q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr);\n\n            q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr);\n\n            extradata_size -= 8;\n\n        }\n\n\n\n        \/* Initialize extradata related variables. *\/\n\n        q->subpacket[s].samples_per_channel = samples_per_frame \/ avctx->channels;\n\n        q->subpacket[s].bits_per_subpacket = avctx->block_align * 8;\n\n\n\n        \/* Initialize default data states. *\/\n\n        q->subpacket[s].log2_numvector_size = 5;\n\n        q->subpacket[s].total_subbands = q->subpacket[s].subbands;\n\n        q->subpacket[s].num_channels = 1;\n\n\n\n        \/* Initialize version-dependent variables *\/\n\n\n\n        av_log(avctx, AV_LOG_DEBUG, \"subpacket[%i].cookversion=%x\\n\", s,\n\n               q->subpacket[s].cookversion);\n\n        q->subpacket[s].joint_stereo = 0;\n\n        switch (q->subpacket[s].cookversion) {\n\n        case MONO:\n\n            if (avctx->channels != 1) {\n\n                avpriv_request_sample(avctx, \"Container channels != 1\");\n\n                return AVERROR_PATCHWELCOME;\n\n            }\n\n            av_log(avctx, AV_LOG_DEBUG, \"MONO\\n\");\n\n            break;\n\n        case STEREO:\n\n            if (avctx->channels != 1) {\n\n                q->subpacket[s].bits_per_subpdiv = 1;\n\n                q->subpacket[s].num_channels = 2;\n\n            }\n\n            av_log(avctx, AV_LOG_DEBUG, \"STEREO\\n\");\n\n            break;\n\n        case JOINT_STEREO:\n\n            if (avctx->channels != 2) {\n\n                avpriv_request_sample(avctx, \"Container channels != 2\");\n\n                return AVERROR_PATCHWELCOME;\n\n            }\n\n            av_log(avctx, AV_LOG_DEBUG, \"JOINT_STEREO\\n\");\n\n            if (avctx->extradata_size >= 16) {\n\n                q->subpacket[s].total_subbands = q->subpacket[s].subbands +\n\n                                                 q->subpacket[s].js_subband_start;\n\n                q->subpacket[s].joint_stereo = 1;\n\n                q->subpacket[s].num_channels = 2;\n\n            }\n\n            if (q->subpacket[s].samples_per_channel > 256) {\n\n                q->subpacket[s].log2_numvector_size = 6;\n\n            }\n\n            if (q->subpacket[s].samples_per_channel > 512) {\n\n                q->subpacket[s].log2_numvector_size = 7;\n\n            }\n\n            break;\n\n        case MC_COOK:\n\n            av_log(avctx, AV_LOG_DEBUG, \"MULTI_CHANNEL\\n\");\n\n            if (extradata_size >= 4)\n\n                channel_mask |= q->subpacket[s].channel_mask = bytestream_get_be32(&edata_ptr);\n\n\n\n            if (av_get_channel_layout_nb_channels(q->subpacket[s].channel_mask) > 1) {\n\n                q->subpacket[s].total_subbands = q->subpacket[s].subbands +\n\n                                                 q->subpacket[s].js_subband_start;\n\n                q->subpacket[s].joint_stereo = 1;\n\n                q->subpacket[s].num_channels = 2;\n\n                q->subpacket[s].samples_per_channel = samples_per_frame >> 1;\n\n\n\n                if (q->subpacket[s].samples_per_channel > 256) {\n\n                    q->subpacket[s].log2_numvector_size = 6;\n\n                }\n\n                if (q->subpacket[s].samples_per_channel > 512) {\n\n                    q->subpacket[s].log2_numvector_size = 7;\n\n                }\n\n            } else\n\n                q->subpacket[s].samples_per_channel = samples_per_frame;\n\n\n\n            break;\n\n        default:\n\n            avpriv_request_sample(avctx, \"Cook version %d\",\n\n                                  q->subpacket[s].cookversion);\n\n            return AVERROR_PATCHWELCOME;\n\n        }\n\n\n\n        if (s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) {\n\n            av_log(avctx, AV_LOG_ERROR, \"different number of samples per channel!\\n\");\n\n            return AVERROR_INVALIDDATA;\n\n        } else\n\n            q->samples_per_channel = q->subpacket[0].samples_per_channel;\n\n\n\n\n\n        \/* Initialize variable relations *\/\n\n        q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size);\n\n\n\n        \/* Try to catch some obviously faulty streams, otherwise it might be exploitable *\/\n\n        if (q->subpacket[s].total_subbands > 53) {\n\n            avpriv_request_sample(avctx, \"total_subbands > 53\");\n\n            return AVERROR_PATCHWELCOME;\n\n        }\n\n\n\n        if ((q->subpacket[s].js_vlc_bits > 6) ||\n\n            (q->subpacket[s].js_vlc_bits < 2 * q->subpacket[s].joint_stereo)) {\n\n            av_log(avctx, AV_LOG_ERROR, \"js_vlc_bits = %d, only >= %d and <= 6 allowed!\\n\",\n\n                   q->subpacket[s].js_vlc_bits, 2 * q->subpacket[s].joint_stereo);\n\n            return AVERROR_INVALIDDATA;\n\n        }\n\n\n\n        if (q->subpacket[s].subbands > 50) {\n\n            avpriv_request_sample(avctx, \"subbands > 50\");\n\n            return AVERROR_PATCHWELCOME;\n\n        }\n\n        q->subpacket[s].gains1.now      = q->subpacket[s].gain_1;\n\n        q->subpacket[s].gains1.previous = q->subpacket[s].gain_2;\n\n        q->subpacket[s].gains2.now      = q->subpacket[s].gain_3;\n\n        q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;\n\n\n\n        q->num_subpackets++;\n\n        s++;\n\n        if (s > MAX_SUBPACKETS) {\n\n            avpriv_request_sample(avctx, \"subpackets > %d\", MAX_SUBPACKETS);\n\n            return AVERROR_PATCHWELCOME;\n\n        }\n\n    }\n\n    \/* Generate tables *\/\n\n    init_pow2table();\n\n    init_gain_table(q);\n\n    init_cplscales_table(q);\n\n\n\n    if ((ret = init_cook_vlc_tables(q)))\n\n        return ret;\n\n\n\n\n\n    if (avctx->block_align >= UINT_MAX \/ 2)\n\n        return AVERROR(EINVAL);\n\n\n\n    \/* Pad the databuffer with:\n\n       DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(),\n\n       AV_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. *\/\n\n    q->decoded_bytes_buffer =\n\n        av_mallocz(avctx->block_align\n\n                   + DECODE_BYTES_PAD1(avctx->block_align)\n\n                   + AV_INPUT_BUFFER_PADDING_SIZE);\n\n    if (!q->decoded_bytes_buffer)\n\n        return AVERROR(ENOMEM);\n\n\n\n    \/* Initialize transform. *\/\n\n    if ((ret = init_cook_mlt(q)))\n\n        return ret;\n\n\n\n    \/* Initialize COOK signal arithmetic handling *\/\n\n    if (1) {\n\n        q->scalar_dequant  = scalar_dequant_float;\n\n        q->decouple        = decouple_float;\n\n        q->imlt_window     = imlt_window_float;\n\n        q->interpolate     = interpolate_float;\n\n        q->saturate_output = saturate_output_float;\n\n    }\n\n\n\n    \/* Try to catch some obviously faulty streams, otherwise it might be exploitable *\/\n\n    if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&\n\n        q->samples_per_channel != 1024) {\n\n        avpriv_request_sample(avctx, \"samples_per_channel = %d\",\n\n                              q->samples_per_channel);\n\n        return AVERROR_PATCHWELCOME;\n\n    }\n\n\n\n    avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;\n\n    if (channel_mask)\n\n        avctx->channel_layout = channel_mask;\n\n    else\n\n        avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;\n\n\n\n#ifdef DEBUG\n\n    dump_cook_context(q);\n\n#endif\n\n    return 0;\n\n}\n","target":1,"code_token_length":2186,"total_token_length":2422,"max_tokens_setting":4096}
+{"idx":436464,"func":"static int hidpp_ff_upload_effect(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old)\n{\n\tstruct hidpp_ff_private_data *data = dev->ff->private;\n\tu8 params[20];\n\tu8 size;\n\tint force;\n\n\t\/* set common parameters *\/\n\tparams[2] = effect->replay.length >> 8;\n\tparams[3] = effect->replay.length & 255;\n\tparams[4] = effect->replay.delay >> 8;\n\tparams[5] = effect->replay.delay & 255;\n\n\tswitch (effect->type) {\n\tcase FF_CONSTANT:\n\t\tforce = (effect->u.constant.level * fixp_sin16((effect->direction * 360) >> 16)) >> 15;\n\t\tparams[1] = HIDPP_FF_EFFECT_CONSTANT;\n\t\tparams[6] = force >> 8;\n\t\tparams[7] = force & 255;\n\t\tparams[8] = effect->u.constant.envelope.attack_level >> 7;\n\t\tparams[9] = effect->u.constant.envelope.attack_length >> 8;\n\t\tparams[10] = effect->u.constant.envelope.attack_length & 255;\n\t\tparams[11] = effect->u.constant.envelope.fade_level >> 7;\n\t\tparams[12] = effect->u.constant.envelope.fade_length >> 8;\n\t\tparams[13] = effect->u.constant.envelope.fade_length & 255;\n\t\tsize = 14;\n\t\tdbg_hid(\"Uploading constant force level=%d in dir %d = %d\\n\",\n\t\t\t\teffect->u.constant.level,\n\t\t\t\teffect->direction, force);\n\t\tdbg_hid(\"          envelope attack=(%d, %d ms) fade=(%d, %d ms)\\n\",\n\t\t\t\teffect->u.constant.envelope.attack_level,\n\t\t\t\teffect->u.constant.envelope.attack_length,\n\t\t\t\teffect->u.constant.envelope.fade_level,\n\t\t\t\teffect->u.constant.envelope.fade_length);\n\t\tbreak;\n\tcase FF_PERIODIC:\n\t{\n\t\tswitch (effect->u.periodic.waveform) {\n\t\tcase FF_SINE:\n\t\t\tparams[1] = HIDPP_FF_EFFECT_PERIODIC_SINE;\n\t\t\tbreak;\n\t\tcase FF_SQUARE:\n\t\t\tparams[1] = HIDPP_FF_EFFECT_PERIODIC_SQUARE;\n\t\t\tbreak;\n\t\tcase FF_SAW_UP:\n\t\t\tparams[1] = HIDPP_FF_EFFECT_PERIODIC_SAWTOOTHUP;\n\t\t\tbreak;\n\t\tcase FF_SAW_DOWN:\n\t\t\tparams[1] = HIDPP_FF_EFFECT_PERIODIC_SAWTOOTHDOWN;\n\t\t\tbreak;\n\t\tcase FF_TRIANGLE:\n\t\t\tparams[1] = HIDPP_FF_EFFECT_PERIODIC_TRIANGLE;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\thid_err(data->hidpp->hid_dev, \"Unexpected periodic waveform type %i!\\n\", effect->u.periodic.waveform);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tforce = (effect->u.periodic.magnitude * fixp_sin16((effect->direction * 360) >> 16)) >> 15;\n\t\tparams[6] = effect->u.periodic.magnitude >> 8;\n\t\tparams[7] = effect->u.periodic.magnitude & 255;\n\t\tparams[8] = effect->u.periodic.offset >> 8;\n\t\tparams[9] = effect->u.periodic.offset & 255;\n\t\tparams[10] = effect->u.periodic.period >> 8;\n\t\tparams[11] = effect->u.periodic.period & 255;\n\t\tparams[12] = effect->u.periodic.phase >> 8;\n\t\tparams[13] = effect->u.periodic.phase & 255;\n\t\tparams[14] = effect->u.periodic.envelope.attack_level >> 7;\n\t\tparams[15] = effect->u.periodic.envelope.attack_length >> 8;\n\t\tparams[16] = effect->u.periodic.envelope.attack_length & 255;\n\t\tparams[17] = effect->u.periodic.envelope.fade_level >> 7;\n\t\tparams[18] = effect->u.periodic.envelope.fade_length >> 8;\n\t\tparams[19] = effect->u.periodic.envelope.fade_length & 255;\n\t\tsize = 20;\n\t\tdbg_hid(\"Uploading periodic force mag=%d\/dir=%d, offset=%d, period=%d ms, phase=%d\\n\",\n\t\t\t\teffect->u.periodic.magnitude, effect->direction,\n\t\t\t\teffect->u.periodic.offset,\n\t\t\t\teffect->u.periodic.period,\n\t\t\t\teffect->u.periodic.phase);\n\t\tdbg_hid(\"          envelope attack=(%d, %d ms) fade=(%d, %d ms)\\n\",\n\t\t\t\teffect->u.periodic.envelope.attack_level,\n\t\t\t\teffect->u.periodic.envelope.attack_length,\n\t\t\t\teffect->u.periodic.envelope.fade_level,\n\t\t\t\teffect->u.periodic.envelope.fade_length);\n\t\tbreak;\n\t}\n\tcase FF_RAMP:\n\t\tparams[1] = HIDPP_FF_EFFECT_RAMP;\n\t\tforce = (effect->u.ramp.start_level * fixp_sin16((effect->direction * 360) >> 16)) >> 15;\n\t\tparams[6] = force >> 8;\n\t\tparams[7] = force & 255;\n\t\tforce = (effect->u.ramp.end_level * fixp_sin16((effect->direction * 360) >> 16)) >> 15;\n\t\tparams[8] = force >> 8;\n\t\tparams[9] = force & 255;\n\t\tparams[10] = effect->u.ramp.envelope.attack_level >> 7;\n\t\tparams[11] = effect->u.ramp.envelope.attack_length >> 8;\n\t\tparams[12] = effect->u.ramp.envelope.attack_length & 255;\n\t\tparams[13] = effect->u.ramp.envelope.fade_level >> 7;\n\t\tparams[14] = effect->u.ramp.envelope.fade_length >> 8;\n\t\tparams[15] = effect->u.ramp.envelope.fade_length & 255;\n\t\tsize = 16;\n\t\tdbg_hid(\"Uploading ramp force level=%d -> %d in dir %d = %d\\n\",\n\t\t\t\teffect->u.ramp.start_level,\n\t\t\t\teffect->u.ramp.end_level,\n\t\t\t\teffect->direction, force);\n\t\tdbg_hid(\"          envelope attack=(%d, %d ms) fade=(%d, %d ms)\\n\",\n\t\t\t\teffect->u.ramp.envelope.attack_level,\n\t\t\t\teffect->u.ramp.envelope.attack_length,\n\t\t\t\teffect->u.ramp.envelope.fade_level,\n\t\t\t\teffect->u.ramp.envelope.fade_length);\n\t\tbreak;\n\tcase FF_FRICTION:\n\tcase FF_INERTIA:\n\tcase FF_SPRING:\n\tcase FF_DAMPER:\n\t\tparams[1] = HIDPP_FF_CONDITION_CMDS[effect->type - FF_SPRING];\n\t\tparams[6] = effect->u.condition[0].left_saturation >> 9;\n\t\tparams[7] = (effect->u.condition[0].left_saturation >> 1) & 255;\n\t\tparams[8] = effect->u.condition[0].left_coeff >> 8;\n\t\tparams[9] = effect->u.condition[0].left_coeff & 255;\n\t\tparams[10] = effect->u.condition[0].deadband >> 9;\n\t\tparams[11] = (effect->u.condition[0].deadband >> 1) & 255;\n\t\tparams[12] = effect->u.condition[0].center >> 8;\n\t\tparams[13] = effect->u.condition[0].center & 255;\n\t\tparams[14] = effect->u.condition[0].right_coeff >> 8;\n\t\tparams[15] = effect->u.condition[0].right_coeff & 255;\n\t\tparams[16] = effect->u.condition[0].right_saturation >> 9;\n\t\tparams[17] = (effect->u.condition[0].right_saturation >> 1) & 255;\n\t\tsize = 18;\n\t\tdbg_hid(\"Uploading %s force left coeff=%d, left sat=%d, right coeff=%d, right sat=%d\\n\",\n\t\t\t\tHIDPP_FF_CONDITION_NAMES[effect->type - FF_SPRING],\n\t\t\t\teffect->u.condition[0].left_coeff,\n\t\t\t\teffect->u.condition[0].left_saturation,\n\t\t\t\teffect->u.condition[0].right_coeff,\n\t\t\t\teffect->u.condition[0].right_saturation);\n\t\tdbg_hid(\"          deadband=%d, center=%d\\n\",\n\t\t\t\teffect->u.condition[0].deadband,\n\t\t\t\teffect->u.condition[0].center);\n\t\tbreak;\n\tdefault:\n\t\thid_err(data->hidpp->hid_dev, \"Unexpected force type %i!\\n\", effect->type);\n\t\treturn -EINVAL;\n\t}\n\n\treturn hidpp_ff_queue_work(data, effect->id, HIDPP_FF_DOWNLOAD_EFFECT, params, size);\n}","target":0,"code_token_length":1973,"total_token_length":2209,"max_tokens_setting":4096}
+{"idx":129061,"func":"static void gf_isom_check_sample_desc(GF_TrackBox *trak)\n{\n\tGF_BitStream *bs;\n\tGF_UnknownBox *a;\n\tu32 i;\n\n\tif (!trak->Media || !trak->Media->information) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Track with no media box !\\n\" ));\n\t\treturn;\n\t}\n\tif (!trak->Media->information->sampleTable) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Track with no sample table !\\n\" ));\n\t\ttrak->Media->information->sampleTable = (GF_SampleTableBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STBL);\n\t}\n\n\tif (!trak->Media->information->sampleTable->SampleDescription) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Track with no sample description box !\\n\" ));\n\t\ttrak->Media->information->sampleTable->SampleDescription = (GF_SampleDescriptionBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STSD);\n\t\treturn;\n\t}\n\n\ti=0;\n\twhile ((a = (GF_UnknownBox*)gf_list_enum(trak->Media->information->sampleTable->SampleDescription->other_boxes, &i))) {\n\t\tswitch (a->type) {\n\t\tcase GF_ISOM_BOX_TYPE_MP4S:\n\t\tcase GF_ISOM_BOX_TYPE_ENCS:\n\t\tcase GF_ISOM_BOX_TYPE_MP4A:\n\t\tcase GF_ISOM_BOX_TYPE_ENCA:\n\t\tcase GF_ISOM_BOX_TYPE_MP4V:\n\t\tcase GF_ISOM_BOX_TYPE_ENCV:\n\t\tcase GF_ISOM_BOX_TYPE_RESV:\n\t\tcase GF_ISOM_SUBTYPE_3GP_AMR:\n\t\tcase GF_ISOM_SUBTYPE_3GP_AMR_WB:\n\t\tcase GF_ISOM_SUBTYPE_3GP_EVRC:\n\t\tcase GF_ISOM_SUBTYPE_3GP_QCELP:\n\t\tcase GF_ISOM_SUBTYPE_3GP_SMV:\n\t\tcase GF_ISOM_SUBTYPE_3GP_H263:\n\t\tcase GF_ISOM_BOX_TYPE_GHNT:\n\t\tcase GF_ISOM_BOX_TYPE_RTP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_SRTP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_FDP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_RRTP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_RTCP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_METX:\n\t\tcase GF_ISOM_BOX_TYPE_METT:\n\t\tcase GF_ISOM_BOX_TYPE_STXT:\n\t\tcase GF_ISOM_BOX_TYPE_AVC1:\n\t\tcase GF_ISOM_BOX_TYPE_AVC2:\n\t\tcase GF_ISOM_BOX_TYPE_AVC3:\n\t\tcase GF_ISOM_BOX_TYPE_AVC4:\n\t\tcase GF_ISOM_BOX_TYPE_SVC1:\n\t\tcase GF_ISOM_BOX_TYPE_MVC1:\n\t\tcase GF_ISOM_BOX_TYPE_HVC1:\n\t\tcase GF_ISOM_BOX_TYPE_HEV1:\n\t\tcase GF_ISOM_BOX_TYPE_HVC2:\n\t\tcase GF_ISOM_BOX_TYPE_HEV2:\n\t\tcase GF_ISOM_BOX_TYPE_HVT1:\n\t\tcase GF_ISOM_BOX_TYPE_LHV1:\n\t\tcase GF_ISOM_BOX_TYPE_LHE1:\n\t\tcase GF_ISOM_BOX_TYPE_AV01:\n\t\tcase GF_ISOM_BOX_TYPE_VP08:\n\t\tcase GF_ISOM_BOX_TYPE_VP09:\n\t\tcase GF_ISOM_BOX_TYPE_AV1C:\n\t\tcase GF_ISOM_BOX_TYPE_TX3G:\n\t\tcase GF_ISOM_BOX_TYPE_TEXT:\n\t\tcase GF_ISOM_BOX_TYPE_ENCT:\n\t\tcase GF_ISOM_BOX_TYPE_DIMS:\n\t\tcase GF_ISOM_BOX_TYPE_AC3:\n\t\tcase GF_ISOM_BOX_TYPE_EC3:\n\t\tcase GF_ISOM_BOX_TYPE_LSR1:\n\t\tcase GF_ISOM_BOX_TYPE_WVTT:\n\t\tcase GF_ISOM_BOX_TYPE_STPP:\n\t\tcase GF_ISOM_BOX_TYPE_SBTT:\n\t\tcase GF_ISOM_BOX_TYPE_MP3:\n\t\tcase GF_ISOM_BOX_TYPE_JPEG:\n\t\tcase GF_ISOM_BOX_TYPE_PNG:\n\t\tcase GF_ISOM_BOX_TYPE_JP2K:\n\t\tcase GF_ISOM_BOX_TYPE_MHA1:\n\t\tcase GF_ISOM_BOX_TYPE_MHA2:\n\t\tcase GF_ISOM_BOX_TYPE_MHM1:\n\t\tcase GF_ISOM_BOX_TYPE_MHM2:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_RAW:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_TWOS:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_SOWT:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_FL32:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_FL64:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_IN24:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_IN32:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_ULAW:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_ALAW:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_ADPCM:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_IMA_ADPCM:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_DVCA:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_QDMC:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_QDMC2:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_QCELP:\n\t\tcase GF_QT_BOX_TYPE_AUDIO_kMP3:\n\t\t\tcontinue;\n\n\t\tcase GF_ISOM_BOX_TYPE_UNKNOWN:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (gf_box_valid_in_parent((GF_Box *) a, \"stsd\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Unexpected box %s in stsd!\\n\", gf_4cc_to_str(a->type)));\n\t\t\tcontinue;\n\t\t}\n\t\t\/\/we are sure to have an unknown box here\n\t\tassert(a->type==GF_ISOM_BOX_TYPE_UNKNOWN);\n\n\t\tif (!a->data || (a->dataSize<8) ) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Sample description %s does not have at least 8 bytes!\\n\", gf_4cc_to_str(a->original_4cc) ));\n\t\t\tcontinue;\n\t\t}\n\t\telse if (a->dataSize > a->size) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Sample description %s has wrong data size %d!\\n\", gf_4cc_to_str(a->original_4cc), a->dataSize));\n\t\t\tcontinue;\n\t\t}\n\n#define STSD_SWITCH_BOX(_box) \\\n\t\tif (gf_bs_available(bs)) { \\\n\t\t\tu64 pos = gf_bs_get_position(bs); \\\n\t\t\tu32 count_subb = 0; \\\n\t\t\tGF_Err e;\\\n\t\t\tgf_bs_set_cookie(bs, 1);\\\n\t\t\te = gf_isom_box_array_read((GF_Box *) _box, bs, gf_isom_box_add_default); \\\n\t\t\tcount_subb = _box->other_boxes ? gf_list_count(_box->other_boxes) : 0; \\\n\t\t\tif (!count_subb || e) { \\\n\t\t\t\tgf_bs_seek(bs, pos); \\\n\t\t\t\t_box->data_size = (u32) gf_bs_available(bs); \\\n\t\t\t\tif (_box->data_size) { \\\n\t\t\t\t\t_box->data = a->data; \\\n\t\t\t\t\ta->data = NULL; \\\n\t\t\t\t\tmemmove(_box->data, _box->data + pos, _box->data_size); \\\n\t\t\t\t} \\\n\t\t\t} else { \\\n\t\t\t\t_box->data_size = 0; \\\n\t\t\t} \\\n\t\t} \\\n\t\tgf_bs_del(bs); \\\n\t\tif (!_box->data_size && _box->data) { \\\n\t\t\tgf_free(_box->data); \\\n\t\t\t_box->data = NULL; \\\n\t\t} \\\n\t\t_box->size = 0; \\\n\t\t_box->EntryType = a->original_4cc; \\\n\t\tgf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1); \\\n\t\tgf_isom_box_del((GF_Box *)a); \\\n\t\tgf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, _box, i-1); \\\n\n\n\t\t\/*only process visual or audio*\/\n\t\tswitch (trak->Media->handler->handlerType) {\n        case GF_ISOM_MEDIA_VISUAL:\n\t\tcase GF_ISOM_MEDIA_AUXV:\n\t\tcase GF_ISOM_MEDIA_PICT:\n\t\t{\n\t\t\tGF_GenericVisualSampleEntryBox *genv = (GF_GenericVisualSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRV);\n\t\t\tbs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);\n\t\t\tgenv->size = a->size-8;\n\t\t\tgf_isom_video_sample_entry_read((GF_VisualSampleEntryBox *) genv, bs);\n\n\t\t\tSTSD_SWITCH_BOX(genv)\n\n\t\t}\n\t\tbreak;\n\t\tcase GF_ISOM_MEDIA_AUDIO:\n\t\t{\n\t\t\tGF_GenericAudioSampleEntryBox *gena = (GF_GenericAudioSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRA);\n\t\t\tgena->size = a->size-8;\n\t\t\tbs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);\n\t\t\tgf_isom_audio_sample_entry_read((GF_AudioSampleEntryBox *) gena, bs);\n\n\t\t\tSTSD_SWITCH_BOX(gena)\n\n\t\t}\n\t\tbreak;\n\n\t\tdefault:\n\t\t{\n\t\t\tGF_Err e;\n\t\t\tGF_GenericSampleEntryBox *genm = (GF_GenericSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRM);\n\t\t\tgenm->size = a->size-8;\n\t\t\tbs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);\n\n\t\t\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)genm, bs);\n\t\t\tif (e) return;\n\n\t\t\tSTSD_SWITCH_BOX(genm)\n\t\t}\n\t\tbreak;\n\t\t}\n\n\t}","target":0,"code_token_length":2130,"total_token_length":2366,"max_tokens_setting":4096}
+{"idx":60029,"func":"void proxyToClash(std::vector &nodes, YAML::Node &yamlnode, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext)\n{\n    YAML::Node proxies, singleproxy, singlegroup, original_groups;\n    std::vector nodelist;\n    string_array remarks_list, filtered_nodelist;\n    \/\/\/ proxies style\n    bool block = false, compact = false;\n    switch(hash_(ext.clash_proxies_style))\n    {\n    case \"block\"_hash:\n        block = true;\n        break;\n    default:\n    case \"flow\"_hash:\n        break;\n    case \"compact\"_hash:\n        compact = true;\n        break;\n    }\n\n    for(Proxy &x : nodes)\n    {\n        singleproxy.reset();\n\n        std::string type = getProxyTypeName(x.Type);\n        std::string remark, pluginopts = replaceAllDistinct(x.PluginOption, \";\", \"&\");\n        if(ext.append_proxy_type)\n            x.Remark = \"[\" + type + \"] \" + x.Remark;\n\n        processRemark(x.Remark, remark, remarks_list, false);\n\n        tribool udp = ext.udp;\n        tribool scv = ext.skip_cert_verify;\n        udp.define(x.UDP);\n        scv.define(x.AllowInsecure);\n\n        singleproxy[\"name\"] = remark;\n        singleproxy[\"server\"] = x.Hostname;\n        singleproxy[\"port\"] = x.Port;\n\n        switch(x.Type)\n        {\n        case ProxyType::Shadowsocks:\n            \/\/latest clash core removed support for chacha20 encryption\n            if(ext.filter_deprecated && x.EncryptMethod == \"chacha20\")\n                continue;\n            singleproxy[\"type\"] = \"ss\";\n            singleproxy[\"cipher\"] = x.EncryptMethod;\n            singleproxy[\"password\"] = x.Password;\n            if(std::all_of(x.Password.begin(), x.Password.end(), ::isdigit) && !x.Password.empty())\n                singleproxy[\"password\"].SetTag(\"str\");\n            switch(hash_(x.Plugin))\n            {\n            case \"simple-obfs\"_hash:\n            case \"obfs-local\"_hash:\n                singleproxy[\"plugin\"] = \"obfs\";\n                singleproxy[\"plugin-opts\"][\"mode\"] = urlDecode(getUrlArg(pluginopts, \"obfs\"));\n                singleproxy[\"plugin-opts\"][\"host\"] = urlDecode(getUrlArg(pluginopts, \"obfs-host\"));\n                break;\n            case \"v2ray-plugin\"_hash:\n                singleproxy[\"plugin\"] = \"v2ray-plugin\";\n                singleproxy[\"plugin-opts\"][\"mode\"] = getUrlArg(pluginopts, \"mode\");\n                singleproxy[\"plugin-opts\"][\"host\"] = getUrlArg(pluginopts, \"host\");\n                singleproxy[\"plugin-opts\"][\"path\"] = getUrlArg(pluginopts, \"path\");\n                singleproxy[\"plugin-opts\"][\"tls\"] = pluginopts.find(\"tls\") != std::string::npos;\n                singleproxy[\"plugin-opts\"][\"mux\"] = pluginopts.find(\"mux\") != std::string::npos;\n                if(!scv.is_undef())\n                    singleproxy[\"plugin-opts\"][\"skip-cert-verify\"] = scv.get();\n                break;\n            }\n            break;\n        case ProxyType::VMess:\n            singleproxy[\"type\"] = \"vmess\";\n            singleproxy[\"uuid\"] = x.UserId;\n            singleproxy[\"alterId\"] = x.AlterId;\n            singleproxy[\"cipher\"] = x.EncryptMethod;\n            singleproxy[\"tls\"] = x.TLSSecure;\n            if(!scv.is_undef())\n                singleproxy[\"skip-cert-verify\"] = scv.get();\n            if(!x.ServerName.empty())\n                singleproxy[\"servername\"] = x.ServerName;\n            switch(hash_(x.TransferProtocol))\n            {\n            case \"tcp\"_hash:\n                break;\n            case \"ws\"_hash:\n                singleproxy[\"network\"] = x.TransferProtocol;\n                if(ext.clash_new_field_name)\n                {\n                    singleproxy[\"ws-opts\"][\"path\"] = x.Path;\n                    if(!x.Host.empty())\n                        singleproxy[\"ws-opts\"][\"headers\"][\"Host\"] = x.Host;\n                    if(!x.Edge.empty())\n                        singleproxy[\"ws-opts\"][\"headers\"][\"Edge\"] = x.Edge;\n                }\n                else\n                {\n                    singleproxy[\"ws-path\"] = x.Path;\n                    if(!x.Host.empty())\n                        singleproxy[\"ws-headers\"][\"Host\"] = x.Host;\n                    if(!x.Edge.empty())\n                        singleproxy[\"ws-headers\"][\"Edge\"] = x.Edge;\n                }\n                break;\n            case \"http\"_hash:\n                singleproxy[\"network\"] = x.TransferProtocol;\n                singleproxy[\"http-opts\"][\"method\"] = \"GET\";\n                singleproxy[\"http-opts\"][\"path\"].push_back(x.Path);\n                if(!x.Host.empty())\n                    singleproxy[\"http-opts\"][\"headers\"][\"Host\"].push_back(x.Host);\n                if(!x.Edge.empty())\n                    singleproxy[\"http-opts\"][\"headers\"][\"Edge\"].push_back(x.Edge);\n                break;\n            case \"h2\"_hash:\n                singleproxy[\"network\"] = x.TransferProtocol;\n                singleproxy[\"h2-opts\"][\"path\"] = x.Path;\n                if(!x.Host.empty())\n                    singleproxy[\"h2-opts\"][\"host\"].push_back(x.Host);\n                break;\n            case \"grpc\"_hash:\n                singleproxy[\"network\"] = x.TransferProtocol;\n                singleproxy[\"servername\"] = x.Host;\n                singleproxy[\"grpc-opts\"][\"grpc-service-name\"] = x.Path;\n                break;\n            default:\n                continue;\n            }\n            break;\n        case ProxyType::ShadowsocksR:\n            \/\/ignoring all nodes with unsupported obfs, protocols and encryption\n            if(ext.filter_deprecated)\n            {\n                if(!clashR && std::find(clash_ssr_ciphers.cbegin(), clash_ssr_ciphers.cend(), x.EncryptMethod) == clash_ssr_ciphers.cend())\n                    continue;\n                if(std::find(clashr_protocols.cbegin(), clashr_protocols.cend(), x.Protocol) == clashr_protocols.cend())\n                    continue;\n                if(std::find(clashr_obfs.cbegin(), clashr_obfs.cend(), x.OBFS) == clashr_obfs.cend())\n                    continue;\n            }\n\n            singleproxy[\"type\"] = \"ssr\";\n            singleproxy[\"cipher\"] = x.EncryptMethod == \"none\" ? \"dummy\" : x.EncryptMethod;\n            singleproxy[\"password\"] = x.Password;\n            if(std::all_of(x.Password.begin(), x.Password.end(), ::isdigit) && !x.Password.empty())\n                singleproxy[\"password\"].SetTag(\"str\");\n            singleproxy[\"protocol\"] = x.Protocol;\n            singleproxy[\"obfs\"] = x.OBFS;\n            if(clashR)\n            {\n                singleproxy[\"protocolparam\"] = x.ProtocolParam;\n                singleproxy[\"obfsparam\"] = x.OBFSParam;\n            }\n            else\n            {\n                singleproxy[\"protocol-param\"] = x.ProtocolParam;\n                singleproxy[\"obfs-param\"] = x.OBFSParam;\n            }\n            break;\n        case ProxyType::SOCKS5:\n            singleproxy[\"type\"] = \"socks5\";\n            if(!x.Username.empty())\n                singleproxy[\"username\"] = x.Username;\n            if(!x.Password.empty())\n            {\n                singleproxy[\"password\"] = x.Password;\n                if(std::all_of(x.Password.begin(), x.Password.end(), ::isdigit))\n                    singleproxy[\"password\"].SetTag(\"str\");\n            }\n            if(!scv.is_undef())\n                singleproxy[\"skip-cert-verify\"] = scv.get();\n            break;\n        case ProxyType::HTTP:\n        case ProxyType::HTTPS:\n            singleproxy[\"type\"] = \"http\";\n            if(!x.Username.empty())\n                singleproxy[\"username\"] = x.Username;\n            if(!x.Password.empty())\n            {\n                singleproxy[\"password\"] = x.Password;\n                if(std::all_of(x.Password.begin(), x.Password.end(), ::isdigit))\n                    singleproxy[\"password\"].SetTag(\"str\");\n            }\n            singleproxy[\"tls\"] = x.TLSSecure;\n            if(!scv.is_undef())\n                singleproxy[\"skip-cert-verify\"] = scv.get();\n            break;\n        case ProxyType::Trojan:\n            singleproxy[\"type\"] = \"trojan\";\n            singleproxy[\"password\"] = x.Password;\n            if(!x.Host.empty())\n                singleproxy[\"sni\"] = x.Host;\n            if(std::all_of(x.Password.begin(), x.Password.end(), ::isdigit) && !x.Password.empty())\n                singleproxy[\"password\"].SetTag(\"str\");\n            if(!scv.is_undef())\n                singleproxy[\"skip-cert-verify\"] = scv.get();\n            switch(hash_(x.TransferProtocol))\n            {\n            case \"tcp\"_hash:\n                break;\n            case \"grpc\"_hash:\n                singleproxy[\"network\"] = x.TransferProtocol;\n                if(!x.Path.empty())\n                    singleproxy[\"grpc-opts\"][\"grpc-service-name\"] = x.Path;\n                break;\n            case \"ws\"_hash:\n                singleproxy[\"network\"] = x.TransferProtocol;\n                singleproxy[\"ws-opts\"][\"path\"] = x.Path;\n                if(!x.Host.empty())\n                    singleproxy[\"ws-opts\"][\"headers\"][\"Host\"] = x.Host;\n                break;\n            }\n            break;\n        case ProxyType::Snell:\n            singleproxy[\"type\"] = \"snell\";\n            singleproxy[\"psk\"] = x.Password;\n            if(x.SnellVersion != 0)\n                singleproxy[\"version\"] = x.SnellVersion;\n            if(!x.OBFS.empty())\n            {\n                singleproxy[\"obfs-opts\"][\"mode\"] = x.OBFS;\n                if(!x.Host.empty())\n                    singleproxy[\"obfs-opts\"][\"host\"] = x.Host;\n            }\n            if(std::all_of(x.Password.begin(), x.Password.end(), ::isdigit) && !x.Password.empty())\n                singleproxy[\"password\"].SetTag(\"str\");\n            break;\n        default:\n            continue;\n        }\n\n        if(udp)\n            singleproxy[\"udp\"] = true;\n        if(block)\n            singleproxy.SetStyle(YAML::EmitterStyle::Block);\n        else\n            singleproxy.SetStyle(YAML::EmitterStyle::Flow);\n        proxies.push_back(singleproxy);\n        remarks_list.emplace_back(std::move(remark));\n        nodelist.emplace_back(x);\n    }\n\n    if(compact)\n        proxies.SetStyle(YAML::EmitterStyle::Flow);\n\n    if(ext.nodelist)\n    {\n        YAML::Node provider;\n        provider[\"proxies\"] = proxies;\n        yamlnode.reset(provider);\n        return;\n    }\n\n    if(ext.clash_new_field_name)\n        yamlnode[\"proxies\"] = proxies;\n    else\n        yamlnode[\"Proxy\"] = proxies;\n\n\n    for(const ProxyGroupConfig &x : extra_proxy_group)\n    {\n        singlegroup.reset();\n        eraseElements(filtered_nodelist);\n\n        singlegroup[\"name\"] = x.Name;\n        singlegroup[\"type\"] = x.TypeStr();\n\n        switch(x.Type)\n        {\n        case ProxyGroupType::Select:\n        case ProxyGroupType::Relay:\n            break;\n        case ProxyGroupType::LoadBalance:\n            singlegroup[\"strategy\"] = x.StrategyStr();\n            [[fallthrough]];\n        case ProxyGroupType::URLTest:\n            if(!x.Lazy.is_undef())\n                singlegroup[\"lazy\"] = x.Lazy.get();\n            [[fallthrough]];\n        case ProxyGroupType::Fallback:\n            singlegroup[\"url\"] = x.Url;\n            if(x.Interval > 0)\n                singlegroup[\"interval\"] = x.Interval;\n            if(x.Tolerance > 0)\n                singlegroup[\"tolerance\"] = x.Tolerance;\n            break;\n        default:\n            continue;\n        }\n        if(!x.DisableUdp.is_undef())\n            singlegroup[\"disable-udp\"] = x.DisableUdp.get();\n\n        for(const auto& y : x.Proxies)\n            groupGenerate(y, nodelist, filtered_nodelist, true, ext);\n\n        if(!x.UsingProvider.empty())\n            singlegroup[\"use\"] = x.UsingProvider;\n        else\n        {\n            if(filtered_nodelist.empty())\n                filtered_nodelist.emplace_back(\"DIRECT\");\n        }\n        if(!filtered_nodelist.empty())\n            singlegroup[\"proxies\"] = filtered_nodelist;\n        \/\/singlegroup.SetStyle(YAML::EmitterStyle::Flow);\n\n        bool replace_flag = false;\n        for(unsigned int i = 0; i < original_groups.size(); i++)\n        {\n            if(original_groups[i][\"name\"].as() == x.Name)\n            {\n                original_groups[i] = singlegroup;\n                replace_flag = true;\n                break;\n            }\n        }\n        if(!replace_flag)\n            original_groups.push_back(singlegroup);\n    }\n\n    if(ext.clash_new_field_name)\n        yamlnode[\"proxy-groups\"] = original_groups;\n    else\n        yamlnode[\"Proxy Group\"] = original_groups;\n}","target":0,"code_token_length":2761,"total_token_length":2997,"max_tokens_setting":4096}
+{"idx":89162,"func":"static void gf_isom_check_sample_desc(GF_TrackBox *trak)\n{\n\tGF_BitStream *bs;\n\tGF_UnknownBox *a;\n\tu32 i;\n\n\tif (!trak->Media || !trak->Media->information) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Track with no media box !\\n\" ));\n\t\treturn;\n\t}\n\tif (!trak->Media->information->sampleTable) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Track with no sample table !\\n\" ));\n\t\ttrak->Media->information->sampleTable = (GF_SampleTableBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STBL);\n\t}\n\n\tif (!trak->Media->information->sampleTable->SampleDescription) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Track with no sample description box !\\n\" ));\n\t\ttrak->Media->information->sampleTable->SampleDescription = (GF_SampleDescriptionBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STSD);\n\t\treturn;\n\t}\n\n\ti=0;\n\twhile ((a = (GF_UnknownBox*)gf_list_enum(trak->Media->information->sampleTable->SampleDescription->other_boxes, &i))) {\n\t\tswitch (a->type) {\n\t\tcase GF_ISOM_BOX_TYPE_MP4S:\n\t\tcase GF_ISOM_BOX_TYPE_ENCS:\n\t\tcase GF_ISOM_BOX_TYPE_MP4A:\n\t\tcase GF_ISOM_BOX_TYPE_ENCA:\n\t\tcase GF_ISOM_BOX_TYPE_MP4V:\n\t\tcase GF_ISOM_BOX_TYPE_ENCV:\n\t\tcase GF_ISOM_BOX_TYPE_RESV:\n\t\tcase GF_ISOM_SUBTYPE_3GP_AMR:\n\t\tcase GF_ISOM_SUBTYPE_3GP_AMR_WB:\n\t\tcase GF_ISOM_SUBTYPE_3GP_EVRC:\n\t\tcase GF_ISOM_SUBTYPE_3GP_QCELP:\n\t\tcase GF_ISOM_SUBTYPE_3GP_SMV:\n\t\tcase GF_ISOM_SUBTYPE_3GP_H263:\n\t\tcase GF_ISOM_BOX_TYPE_GHNT:\n\t\tcase GF_ISOM_BOX_TYPE_RTP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_SRTP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_FDP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_RRTP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_RTCP_STSD:\n\t\tcase GF_ISOM_BOX_TYPE_METX:\n\t\tcase GF_ISOM_BOX_TYPE_METT:\n\t\tcase GF_ISOM_BOX_TYPE_STXT:\n\t\tcase GF_ISOM_BOX_TYPE_AVC1:\n\t\tcase GF_ISOM_BOX_TYPE_AVC2:\n\t\tcase GF_ISOM_BOX_TYPE_AVC3:\n\t\tcase GF_ISOM_BOX_TYPE_AVC4:\n\t\tcase GF_ISOM_BOX_TYPE_SVC1:\n\t\tcase GF_ISOM_BOX_TYPE_MVC1:\n\t\tcase GF_ISOM_BOX_TYPE_HVC1:\n\t\tcase GF_ISOM_BOX_TYPE_HEV1:\n\t\tcase GF_ISOM_BOX_TYPE_HVC2:\n\t\tcase GF_ISOM_BOX_TYPE_HEV2:\n\t\tcase GF_ISOM_BOX_TYPE_HVT1:\n\t\tcase GF_ISOM_BOX_TYPE_LHV1:\n\t\tcase GF_ISOM_BOX_TYPE_LHE1:\n\t\tcase GF_ISOM_BOX_TYPE_TX3G:\n\t\tcase GF_ISOM_BOX_TYPE_TEXT:\n\t\tcase GF_ISOM_BOX_TYPE_ENCT:\n\t\tcase GF_ISOM_BOX_TYPE_DIMS:\n\t\tcase GF_ISOM_BOX_TYPE_AC3:\n\t\tcase GF_ISOM_BOX_TYPE_EC3:\n\t\tcase GF_ISOM_BOX_TYPE_LSR1:\n\t\tcase GF_ISOM_BOX_TYPE_WVTT:\n\t\tcase GF_ISOM_BOX_TYPE_STPP:\n\t\tcase GF_ISOM_BOX_TYPE_SBTT:\n\t\tcase GF_ISOM_BOX_TYPE_MP3:\n\t\tcase GF_ISOM_BOX_TYPE_JPEG:\n\t\tcase GF_ISOM_BOX_TYPE_PNG:\n\t\tcase GF_ISOM_BOX_TYPE_JP2K:\n\t\t\tcontinue;\n\t\tcase GF_ISOM_BOX_TYPE_UNKNOWN:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Unexpected box %s in stsd!\\n\", gf_4cc_to_str(a->type)));\n\t\t\tcontinue;\n\t\t}\n\t\t\/\/we are sure to have an unknown box here\n\t\tassert(a->type==GF_ISOM_BOX_TYPE_UNKNOWN);\n\n\t\tif (!a->data || (a->dataSize<8) ) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Sample description %s does not have at least 8 bytes!\\n\", gf_4cc_to_str(a->original_4cc) ));\n\t\t\tcontinue;\n\t\t}\n\t\telse if (a->dataSize > a->size) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Sample description %s has wrong data size %d!\\n\", gf_4cc_to_str(a->original_4cc), a->dataSize));\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/*only process visual or audio*\/\n\t\tswitch (trak->Media->handler->handlerType) {\n        case GF_ISOM_MEDIA_VISUAL:\n\t\tcase GF_ISOM_MEDIA_AUXV:\n\t\tcase GF_ISOM_MEDIA_PICT:\n\t\t{\n\t\t\tGF_GenericVisualSampleEntryBox *genv;\n\t\t\t\/*remove entry*\/\n\t\t\tgf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1);\n\t\t\tgenv = (GF_GenericVisualSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRV);\n\t\t\tbs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);\n\t\t\tgenv->size = a->size-8;\n\t\t\tgf_isom_video_sample_entry_read((GF_VisualSampleEntryBox *) genv, bs);\n\n\t\t\tif (gf_bs_available(bs)) {\n\t\t\t\tu64 pos = gf_bs_get_position(bs);\n\t\t\t\t\/\/try to parse as boxes\n\t\t\t\tGF_Err e = gf_isom_box_array_read((GF_Box *) genv, bs, gf_isom_box_add_default);\n\t\t\t\tif (e) {\n\t\t\t\t\tgf_bs_seek(bs, pos);\n\t\t\t\t\tgenv->data_size = (u32) gf_bs_available(bs);\n\t\t\t\t\tif (genv->data_size) {\n\t\t\t\t\t\tgenv->data = a->data;\n\t\t\t\t\t\ta->data = NULL;\n\t\t\t\t\t\tmemmove(genv->data, genv->data + pos, genv->data_size);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgenv->data_size = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_bs_del(bs);\n\t\t\tif (!genv->data_size && genv->data) {\n\t\t\t\tgf_free(genv->data);\n\t\t\t\tgenv->data = NULL;\n\t\t\t}\n\n\t\t\tgenv->size = 0;\n\t\t\tgenv->EntryType = a->original_4cc;\n\t\t\tgf_isom_box_del((GF_Box *)a);\n\t\t\tgf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, genv, i-1);\n\t\t}\n\t\tbreak;\n\t\tcase GF_ISOM_MEDIA_AUDIO:\n\t\t{\n\t\t\tGF_GenericAudioSampleEntryBox *gena;\n\t\t\t\/*remove entry*\/\n\t\t\tgf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1);\n\t\t\tgena = (GF_GenericAudioSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRA);\n\t\t\tgena->size = a->size-8;\n\t\t\tbs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);\n\t\t\tgf_isom_audio_sample_entry_read((GF_AudioSampleEntryBox *) gena, bs);\n\n\t\t\tif (gf_bs_available(bs)) {\n\t\t\t\tu64 pos = gf_bs_get_position(bs);\n\t\t\t\t\/\/try to parse as boxes\n\t\t\t\tGF_Err e = gf_isom_box_array_read((GF_Box *) gena, bs, gf_isom_box_add_default);\n\t\t\t\tif (e) {\n\t\t\t\t\tgf_bs_seek(bs, pos);\n\t\t\t\t\tgena->data_size = (u32) gf_bs_available(bs);\n\t\t\t\t\tif (gena->data_size) {\n\t\t\t\t\t\tgena->data = a->data;\n\t\t\t\t\t\ta->data = NULL;\n\t\t\t\t\t\tmemmove(gena->data, gena->data + pos, gena->data_size);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgena->data_size = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_bs_del(bs);\n\t\t\tif (!gena->data_size && gena->data) {\n\t\t\t\tgf_free(gena->data);\n\t\t\t\tgena->data = NULL;\n\t\t\t}\n\t\t\tgena->size = 0;\n\t\t\tgena->EntryType = a->original_4cc;\n\t\t\tgf_isom_box_del((GF_Box *)a);\n\t\t\tgf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, gena, i-1);\n\t\t}\n\t\tbreak;\n\n\t\tdefault:\n\t\t{\n\t\t\tGF_Err e;\n\t\t\tGF_GenericSampleEntryBox *genm;\n\t\t\t\/*remove entry*\/\n\t\t\tgf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1);\n\t\t\tgenm = (GF_GenericSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRM);\n\t\t\tgenm->size = a->size-8;\n\t\t\tbs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);\n\n\t\t\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)genm, bs);\n\t\t\tif (e) return;\n\n\t\t\tgenm->size -= 8;\n\n\t\t\tif (gf_bs_available(bs)) {\n\t\t\t\tu64 pos = gf_bs_get_position(bs);\n\t\t\t\t\/\/try to parse as boxes\n\t\t\t\tGF_Err e = gf_isom_box_array_read((GF_Box *) genm, bs, gf_isom_box_add_default);\n\t\t\t\tif (e) {\n\t\t\t\t\tgf_bs_seek(bs, pos);\n\t\t\t\t\tgenm->data_size = (u32) gf_bs_available(bs);\n\t\t\t\t\tif (genm->data_size) {\n\t\t\t\t\t\tgenm->data = a->data;\n\t\t\t\t\t\ta->data = NULL;\n\t\t\t\t\t\tmemmove(genm->data, genm->data + pos, genm->data_size);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgenm->data_size = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_bs_del(bs);\n\t\t\tif (!genm->data_size && genm->data) {\n\t\t\t\tgf_free(genm->data);\n\t\t\t\tgenm->data = NULL;\n\t\t\t}\n\t\t\tgenm->size = 0;\n\n\t\t\tgenm->EntryType = a->original_4cc;\n\t\t\tgf_isom_box_del((GF_Box *)a);\n\t\t\tgf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, genm, i-1);\n\t\t}\n\t\tbreak;\n\t\t}\n\n\t}\n}","target":0,"code_token_length":2350,"total_token_length":2586,"max_tokens_setting":4096}
+{"idx":506234,"func":"static int ssl3_get_record(SSL *s)\n\t{\n\tint ssl_major,ssl_minor,al;\n\tint enc_err,n,i,ret= -1;\n\tSSL3_RECORD *rr;\n\tSSL_SESSION *sess;\n\tunsigned char *p;\n\tunsigned char md[EVP_MAX_MD_SIZE];\n\tshort version;\n\tunsigned int mac_size;\n\tint clear=0;\n\tsize_t extra;\n\tint decryption_failed_or_bad_record_mac = 0;\n\tunsigned char *mac = NULL;\n\n\trr= &(s->s3->rrec);\n\tsess=s->session;\n\n\tif (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)\n\t\textra=SSL3_RT_MAX_EXTRA;\n\telse\n\t\textra=0;\n\tif (extra && !s->s3->init_extra)\n\t\t{\n\t\t\/* An application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER\n\t\t * set after ssl3_setup_buffers() was done *\/\n\t\tSSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR);\n\t\treturn -1;\n\t\t}\n\nagain:\n\t\/* check if we have the header *\/\n\tif (\t(s->rstate != SSL_ST_READ_BODY) ||\n\t\t(s->packet_length < SSL3_RT_HEADER_LENGTH)) \n\t\t{\n\t\tn=ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);\n\t\tif (n <= 0) return(n); \/* error or non-blocking *\/\n\t\ts->rstate=SSL_ST_READ_BODY;\n\n\t\tp=s->packet;\n\n\t\t\/* Pull apart the header into the SSL3_RECORD *\/\n\t\trr->type= *(p++);\n\t\tssl_major= *(p++);\n\t\tssl_minor= *(p++);\n\t\tversion=(ssl_major<<8)|ssl_minor;\n\t\tn2s(p,rr->length);\n#if 0\nfprintf(stderr, \"Record type=%d, Length=%d\\n\", rr->type, rr->length);\n#endif\n\n\t\t\/* Lets check version *\/\n\t\tif (!s->first_packet)\n\t\t\t{\n\t\t\tif (version != s->version)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER);\n\t\t\t\t\/* Send back error using their\n\t\t\t\t * version number :-) *\/\n\t\t\t\ts->version=version;\n\t\t\t\tal=SSL_AD_PROTOCOL_VERSION;\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\t}\n\n\t\tif ((version>>8) != SSL3_VERSION_MAJOR)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER);\n\t\t\tgoto err;\n\t\t\t}\n\n\t\tif (rr->length > s->s3->rbuf.len - SSL3_RT_HEADER_LENGTH)\n\t\t\t{\n\t\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG);\n\t\t\tgoto f_err;\n\t\t\t}\n\n\t\t\/* now s->rstate == SSL_ST_READ_BODY *\/\n\t\t}\n\n\t\/* s->rstate == SSL_ST_READ_BODY, get and decode the data *\/\n\n\tif (rr->length > s->packet_length-SSL3_RT_HEADER_LENGTH)\n\t\t{\n\t\t\/* now s->packet_length == SSL3_RT_HEADER_LENGTH *\/\n\t\ti=rr->length;\n\t\tn=ssl3_read_n(s,i,i,1);\n\t\tif (n <= 0) return(n); \/* error or non-blocking io *\/\n\t\t\/* now n == rr->length,\n\t\t * and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length *\/\n\t\t}\n\n\ts->rstate=SSL_ST_READ_HEADER; \/* set state for later operations *\/\n\n\t\/* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length,\n\t * and we have that many bytes in s->packet\n\t *\/\n\trr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]);\n\n\t\/* ok, we can now read from 's->packet' data into 'rr'\n\t * rr->input points at rr->length bytes, which\n\t * need to be copied into rr->data by either\n\t * the decryption or by the decompression\n\t * When the data is 'copied' into the rr->data buffer,\n\t * rr->input will be pointed at the new buffer *\/ \n\n\t\/* We now have - encrypted [ MAC [ compressed [ plain ] ] ]\n\t * rr->length bytes of encrypted compressed stuff. *\/\n\n\t\/* check is not needed I believe *\/\n\tif (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)\n\t\t{\n\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG);\n\t\tgoto f_err;\n\t\t}\n\n\t\/* decrypt in place in 'rr->input' *\/\n\trr->data=rr->input;\n\n\tenc_err = s->method->ssl3_enc->enc(s,0);\n\tif (enc_err <= 0)\n\t\t{\n\t\tif (enc_err == 0)\n\t\t\t\/* SSLerr() and ssl3_send_alert() have been called *\/\n\t\t\tgoto err;\n\n\t\t\/* Otherwise enc_err == -1, which indicates bad padding\n\t\t * (rec->length has not been changed in this case).\n\t\t * To minimize information leaked via timing, we will perform\n\t\t * the MAC computation anyway. *\/\n\t\tdecryption_failed_or_bad_record_mac = 1;\n\t\t}\n\n#ifdef TLS_DEBUG\nprintf(\"dec %d\\n\",rr->length);\n{ unsigned int z; for (z=0; zlength; z++) printf(\"%02X%c\",rr->data[z],((z+1)%16)?' ':'\\n'); }\nprintf(\"\\n\");\n#endif\n\n\t\/* r->length is now the compressed data plus mac *\/\n\tif (\t(sess == NULL) ||\n\t\t(s->enc_read_ctx == NULL) ||\n\t\t(EVP_MD_CTX_md(s->read_hash) == NULL))\n\t\tclear=1;\n\n\tif (!clear)\n\t\t{\n\t\tmac_size=EVP_MD_CTX_size(s->read_hash);\n\n\t\tif (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size)\n\t\t\t{\n#if 0 \/* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) *\/\n\t\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);\n\t\t\tgoto f_err;\n#else\n\t\t\tdecryption_failed_or_bad_record_mac = 1;\n#endif\t\t\t\n\t\t\t}\n\t\t\/* check the MAC for rr->input (it's in mac_size bytes at the tail) *\/\n\t\tif (rr->length >= mac_size)\n\t\t\t{\n\t\t\trr->length -= mac_size;\n\t\t\tmac = &rr->data[rr->length];\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t\/* record (minus padding) is too short to contain a MAC *\/\n#if 0 \/* OK only for stream ciphers *\/\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);\n\t\t\tgoto f_err;\n#else\n\t\t\tdecryption_failed_or_bad_record_mac = 1;\n\t\t\trr->length = 0;\n#endif\n\t\t\t}\n\t\ti=s->method->ssl3_enc->mac(s,md,0);\n\t\tif (mac == NULL || memcmp(md, mac, mac_size) != 0)\n\t\t\t{\n\t\t\tdecryption_failed_or_bad_record_mac = 1;\n\t\t\t}\n\t\t}\n\n\tif (decryption_failed_or_bad_record_mac)\n\t\t{\n\t\t\/* A separate 'decryption_failed' alert was introduced with TLS 1.0,\n\t\t * SSL 3.0 only has 'bad_record_mac'.  But unless a decryption\n\t\t * failure is directly visible from the ciphertext anyway,\n\t\t * we should not reveal which kind of error occured -- this\n\t\t * might become visible to an attacker (e.g. via a logfile) *\/\n\t\tal=SSL_AD_BAD_RECORD_MAC;\n\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);\n\t\tgoto f_err;\n\t\t}\n\n\t\/* r->length is now just compressed *\/\n\tif (s->expand != NULL)\n\t\t{\n\t\tif (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra)\n\t\t\t{\n\t\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (!ssl3_do_uncompress(s))\n\t\t\t{\n\t\t\tal=SSL_AD_DECOMPRESSION_FAILURE;\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BAD_DECOMPRESSION);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\n\tif (rr->length > SSL3_RT_MAX_PLAIN_LENGTH+extra)\n\t\t{\n\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG);\n\t\tgoto f_err;\n\t\t}\n\n\trr->off=0;\n\t\/* So at this point the following is true\n\t * ssl->s3->rrec.type \tis the type of record\n\t * ssl->s3->rrec.length\t== number of bytes in record\n\t * ssl->s3->rrec.off\t== offset to first valid byte\n\t * ssl->s3->rrec.data\t== where to take bytes from, increment\n\t *\t\t\t   after use :-).\n\t *\/\n\n\t\/* we have pulled in a full packet so zero things *\/\n\ts->packet_length=0;\n\n\t\/* just read a 0 length packet *\/\n\tif (rr->length == 0) goto again;\n\n#if 0\nfprintf(stderr, \"Ultimate Record type=%d, Length=%d\\n\", rr->type, rr->length);\n#endif\n\n\treturn(1);\n\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\nerr:\n\treturn(ret);\n\t}","target":0,"code_token_length":2104,"total_token_length":2340,"max_tokens_setting":4096}
+{"idx":25050,"func":"static void fdct16 ( const tran_low_t in [ 16 ] , tran_low_t out [ 16 ] ) {\n tran_high_t step1 [ 8 ] ;\n tran_high_t step2 [ 8 ] ;\n tran_high_t step3 [ 8 ] ;\n tran_high_t input [ 8 ] ;\n tran_high_t temp1 , temp2 ;\n input [ 0 ] = in [ 0 ] + in [ 15 ] ;\n input [ 1 ] = in [ 1 ] + in [ 14 ] ;\n input [ 2 ] = in [ 2 ] + in [ 13 ] ;\n input [ 3 ] = in [ 3 ] + in [ 12 ] ;\n input [ 4 ] = in [ 4 ] + in [ 11 ] ;\n input [ 5 ] = in [ 5 ] + in [ 10 ] ;\n input [ 6 ] = in [ 6 ] + in [ 9 ] ;\n input [ 7 ] = in [ 7 ] + in [ 8 ] ;\n step1 [ 0 ] = in [ 7 ] - in [ 8 ] ;\n step1 [ 1 ] = in [ 6 ] - in [ 9 ] ;\n step1 [ 2 ] = in [ 5 ] - in [ 10 ] ;\n step1 [ 3 ] = in [ 4 ] - in [ 11 ] ;\n step1 [ 4 ] = in [ 3 ] - in [ 12 ] ;\n step1 [ 5 ] = in [ 2 ] - in [ 13 ] ;\n step1 [ 6 ] = in [ 1 ] - in [ 14 ] ;\n step1 [ 7 ] = in [ 0 ] - in [ 15 ] ;\n {\n tran_high_t s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ;\n tran_high_t t0 , t1 , t2 , t3 ;\n tran_high_t x0 , x1 , x2 , x3 ;\n s0 = input [ 0 ] + input [ 7 ] ;\n s1 = input [ 1 ] + input [ 6 ] ;\n s2 = input [ 2 ] + input [ 5 ] ;\n s3 = input [ 3 ] + input [ 4 ] ;\n s4 = input [ 3 ] - input [ 4 ] ;\n s5 = input [ 2 ] - input [ 5 ] ;\n s6 = input [ 1 ] - input [ 6 ] ;\n s7 = input [ 0 ] - input [ 7 ] ;\n x0 = s0 + s3 ;\n x1 = s1 + s2 ;\n x2 = s1 - s2 ;\n x3 = s0 - s3 ;\n t0 = ( x0 + x1 ) * cospi_16_64 ;\n t1 = ( x0 - x1 ) * cospi_16_64 ;\n t2 = x3 * cospi_8_64 + x2 * cospi_24_64 ;\n t3 = x3 * cospi_24_64 - x2 * cospi_8_64 ;\n out [ 0 ] = fdct_round_shift ( t0 ) ;\n out [ 4 ] = fdct_round_shift ( t2 ) ;\n out [ 8 ] = fdct_round_shift ( t1 ) ;\n out [ 12 ] = fdct_round_shift ( t3 ) ;\n t0 = ( s6 - s5 ) * cospi_16_64 ;\n t1 = ( s6 + s5 ) * cospi_16_64 ;\n t2 = fdct_round_shift ( t0 ) ;\n t3 = fdct_round_shift ( t1 ) ;\n x0 = s4 + t2 ;\n x1 = s4 - t2 ;\n x2 = s7 - t3 ;\n x3 = s7 + t3 ;\n t0 = x0 * cospi_28_64 + x3 * cospi_4_64 ;\n t1 = x1 * cospi_12_64 + x2 * cospi_20_64 ;\n t2 = x2 * cospi_12_64 + x1 * - cospi_20_64 ;\n t3 = x3 * cospi_28_64 + x0 * - cospi_4_64 ;\n out [ 2 ] = fdct_round_shift ( t0 ) ;\n out [ 6 ] = fdct_round_shift ( t2 ) ;\n out [ 10 ] = fdct_round_shift ( t1 ) ;\n out [ 14 ] = fdct_round_shift ( t3 ) ;\n }\n temp1 = ( step1 [ 5 ] - step1 [ 2 ] ) * cospi_16_64 ;\n temp2 = ( step1 [ 4 ] - step1 [ 3 ] ) * cospi_16_64 ;\n step2 [ 2 ] = fdct_round_shift ( temp1 ) ;\n step2 [ 3 ] = fdct_round_shift ( temp2 ) ;\n temp1 = ( step1 [ 4 ] + step1 [ 3 ] ) * cospi_16_64 ;\n temp2 = ( step1 [ 5 ] + step1 [ 2 ] ) * cospi_16_64 ;\n step2 [ 4 ] = fdct_round_shift ( temp1 ) ;\n step2 [ 5 ] = fdct_round_shift ( temp2 ) ;\n step3 [ 0 ] = step1 [ 0 ] + step2 [ 3 ] ;\n step3 [ 1 ] = step1 [ 1 ] + step2 [ 2 ] ;\n step3 [ 2 ] = step1 [ 1 ] - step2 [ 2 ] ;\n step3 [ 3 ] = step1 [ 0 ] - step2 [ 3 ] ;\n step3 [ 4 ] = step1 [ 7 ] - step2 [ 4 ] ;\n step3 [ 5 ] = step1 [ 6 ] - step2 [ 5 ] ;\n step3 [ 6 ] = step1 [ 6 ] + step2 [ 5 ] ;\n step3 [ 7 ] = step1 [ 7 ] + step2 [ 4 ] ;\n temp1 = step3 [ 1 ] * - cospi_8_64 + step3 [ 6 ] * cospi_24_64 ;\n temp2 = step3 [ 2 ] * cospi_24_64 + step3 [ 5 ] * cospi_8_64 ;\n step2 [ 1 ] = fdct_round_shift ( temp1 ) ;\n step2 [ 2 ] = fdct_round_shift ( temp2 ) ;\n temp1 = step3 [ 2 ] * cospi_8_64 - step3 [ 5 ] * cospi_24_64 ;\n temp2 = step3 [ 1 ] * cospi_24_64 + step3 [ 6 ] * cospi_8_64 ;\n step2 [ 5 ] = fdct_round_shift ( temp1 ) ;\n step2 [ 6 ] = fdct_round_shift ( temp2 ) ;\n step1 [ 0 ] = step3 [ 0 ] + step2 [ 1 ] ;\n step1 [ 1 ] = step3 [ 0 ] - step2 [ 1 ] ;\n step1 [ 2 ] = step3 [ 3 ] + step2 [ 2 ] ;\n step1 [ 3 ] = step3 [ 3 ] - step2 [ 2 ] ;\n step1 [ 4 ] = step3 [ 4 ] - step2 [ 5 ] ;\n step1 [ 5 ] = step3 [ 4 ] + step2 [ 5 ] ;\n step1 [ 6 ] = step3 [ 7 ] - step2 [ 6 ] ;\n step1 [ 7 ] = step3 [ 7 ] + step2 [ 6 ] ;\n temp1 = step1 [ 0 ] * cospi_30_64 + step1 [ 7 ] * cospi_2_64 ;\n temp2 = step1 [ 1 ] * cospi_14_64 + step1 [ 6 ] * cospi_18_64 ;\n out [ 1 ] = fdct_round_shift ( temp1 ) ;\n out [ 9 ] = fdct_round_shift ( temp2 ) ;\n temp1 = step1 [ 2 ] * cospi_22_64 + step1 [ 5 ] * cospi_10_64 ;\n temp2 = step1 [ 3 ] * cospi_6_64 + step1 [ 4 ] * cospi_26_64 ;\n out [ 5 ] = fdct_round_shift ( temp1 ) ;\n out [ 13 ] = fdct_round_shift ( temp2 ) ;\n temp1 = step1 [ 3 ] * - cospi_26_64 + step1 [ 4 ] * cospi_6_64 ;\n temp2 = step1 [ 2 ] * - cospi_10_64 + step1 [ 5 ] * cospi_22_64 ;\n out [ 3 ] = fdct_round_shift ( temp1 ) ;\n out [ 11 ] = fdct_round_shift ( temp2 ) ;\n temp1 = step1 [ 1 ] * - cospi_18_64 + step1 [ 6 ] * cospi_14_64 ;\n temp2 = step1 [ 0 ] * - cospi_2_64 + step1 [ 7 ] * cospi_30_64 ;\n out [ 7 ] = fdct_round_shift ( temp1 ) ;\n out [ 15 ] = fdct_round_shift ( temp2 ) ;\n }","target":0,"code_token_length":2140,"total_token_length":2376,"max_tokens_setting":4096}
+{"idx":235144,"func":"png_write_find_filter(png_structp png_ptr, png_row_infop row_info)\n{\n   png_bytep best_row;\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   png_bytep prev_row, row_buf;\n    png_uint_32 mins, bpp;\n    png_byte filter_to_do = png_ptr->do_filter;\n    png_uint_32 row_bytes = row_info->rowbytes;\n \n    png_debug(1, \"in png_write_find_filter\");\n \n    \/* Find out how many bytes offset each pixel is *\/\n    bpp = (row_info->pixel_depth + 7) >> 3;\n \n   prev_row = png_ptr->prev_row;\n#endif\n   best_row = png_ptr->row_buf;\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   row_buf = best_row;\n   mins = PNG_MAXSUM;\n\n   \/* The prediction method we use is to find which method provides the\n    * smallest value when summing the absolute values of the distances\n    * from zero, using anything >= 128 as negative numbers.  This is known\n    * as the \"minimum sum of absolute differences\" heuristic.  Other\n    * heuristics are the \"weighted minimum sum of absolute differences\"\n    * (experimental and can in theory improve compression), and the \"zlib\n    * predictive\" method (not implemented yet), which does test compressions\n    * of lines using different filter methods, and then chooses the\n    * (series of) filter(s) that give minimum compressed data size (VERY\n    * computationally expensive).\n    *\n    * GRR 980525:  consider also\n    *   (1) minimum sum of absolute differences from running average (i.e.,\n    *       keep running sum of non-absolute differences & count of bytes)\n    *       [track dispersion, too?  restart average if dispersion too large?]\n    *  (1b) minimum sum of absolute differences from sliding average, probably\n    *       with window size <= deflate window (usually 32K)\n    *   (2) minimum sum of squared differences from zero or running average\n    *       (i.e., ~ root-mean-square approach)\n    *\/\n\n\n   \/* We don't need to test the 'no filter' case if this is the only filter\n    * that has been chosen, as it doesn't actually do anything to the data.\n    *\/\n   if ((filter_to_do & PNG_FILTER_NONE) &&\n       filter_to_do != PNG_FILTER_NONE)\n   {\n      png_bytep rp;\n      png_uint_32 sum = 0;\n      png_uint_32 i;\n      int v;\n\n      for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)\n      {\n         v = *rp;\n          sum += (v < 128) ? v : 256 - v;\n       }\n \n       mins = sum;\n    }\n \n   \/* Sub filter *\/\n   if (filter_to_do == PNG_FILTER_SUB)\n   \/* It's the only filter so no testing is needed *\/\n   {\n      png_bytep rp, lp, dp;\n      png_uint_32 i;\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n           i++, rp++, dp++)\n      {\n         *dp = *rp;\n      }\n      for (lp = row_buf + 1; i < row_bytes;\n         i++, rp++, lp++, dp++)\n      {\n         *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n      }\n      best_row = png_ptr->sub_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_SUB)\n   {\n      png_bytep rp, dp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n       png_uint_32 i;\n       int v;\n \n       for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n            i++, rp++, dp++)\n       {\n         v = *dp = *rp;\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n      for (lp = row_buf + 1; i < row_bytes;\n         i++, rp++, lp++, dp++)\n      {\n         v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  \/* We are already worse, don't continue. *\/\n             break;\n       }\n \n       if (sum < mins)\n       {\n          mins = sum;\n         best_row = png_ptr->sub_row;\n      }\n   }\n\n   \/* Up filter *\/\n   if (filter_to_do == PNG_FILTER_UP)\n   {\n      png_bytep rp, dp, pp;\n      png_uint_32 i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n           pp = prev_row + 1; i < row_bytes;\n           i++, rp++, pp++, dp++)\n      {\n         *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);\n      }\n      best_row = png_ptr->up_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_UP)\n   {\n      png_bytep rp, dp, pp;\n      png_uint_32 sum = 0, lmins = mins;\n       png_uint_32 i;\n       int v;\n \n       for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n            pp = prev_row + 1; i < row_bytes; i++)\n       {\n         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  \/* We are already worse, don't continue. *\/\n             break;\n       }\n \n       if (sum < mins)\n       {\n          mins = sum;\n         best_row = png_ptr->up_row;\n      }\n   }\n\n   \/* Avg filter *\/\n   if (filter_to_do == PNG_FILTER_AVG)\n   {\n      png_bytep rp, dp, pp, lp;\n      png_uint_32 i;\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n           pp = prev_row + 1; i < bpp; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ \/ 2)) & 0xff);\n      }\n      for (lp = row_buf + 1; i < row_bytes; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) \/ 2))\n                 & 0xff);\n      }\n      best_row = png_ptr->avg_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_AVG)\n   {\n      png_bytep rp, dp, pp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n       png_uint_32 i;\n       int v;\n \n       for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n            pp = prev_row + 1; i < bpp; i++)\n       {\n         v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ \/ 2)) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n      for (lp = row_buf + 1; i < row_bytes; i++)\n      {\n         v = *dp++ =\n          (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) \/ 2)) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  \/* We are already worse, don't continue. *\/\n             break;\n       }\n \n       if (sum < mins)\n       {\n          mins = sum;\n         best_row = png_ptr->avg_row;\n      }\n   }\n\n   \/* Paeth filter *\/\n   if (filter_to_do == PNG_FILTER_PAETH)\n   {\n      png_bytep rp, dp, pp, cp, lp;\n      png_uint_32 i;\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n           pp = prev_row + 1; i < bpp; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n      }\n\n      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n      {\n         int a, b, c, pa, pb, pc, p;\n\n         b = *pp++;\n         c = *cp++;\n         a = *lp++;\n\n         p = b - c;\n         pc = a - c;\n\n#ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n\n         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n\n         *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n      }\n      best_row = png_ptr->paeth_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_PAETH)\n   {\n      png_bytep rp, dp, pp, cp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n       png_uint_32 i;\n       int v;\n \n       for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n            pp = prev_row + 1; i < bpp; i++)\n       {\n         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n      {\n         int a, b, c, pa, pb, pc, p;\n\n         b = *pp++;\n         c = *cp++;\n         a = *lp++;\n\n#ifndef PNG_SLOW_PAETH\n         p = b - c;\n         pc = a - c;\n#ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n#else \/* PNG_SLOW_PAETH *\/\n         p = a + b - c;\n         pa = abs(p - a);\n         pb = abs(p - b);\n         pc = abs(p - c);\n         if (pa <= pb && pa <= pc)\n            p = a;\n         else if (pb <= pc)\n            p = b;\n         else\n            p = c;\n#endif \/* PNG_SLOW_PAETH *\/\n\n         v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  \/* We are already worse, don't continue. *\/\n             break;\n       }\n \n       if (sum < mins)\n       {\n          best_row = png_ptr->paeth_row;\n      }\n   }\n#endif \/* PNG_WRITE_FILTER_SUPPORTED *\/\n    \/* Do the actual writing of the filtered row data from the chosen filter. *\/\n \n    png_write_filtered_row(png_ptr, best_row);\n }\n","target":0,"code_token_length":2695,"total_token_length":2931,"max_tokens_setting":4096}
+{"idx":345334,"func":"ProcessStartupPacket(Port *port, bool SSLdone)\n{\n\tint32\t\tlen;\n\tvoid\t   *buf;\n\tProtocolVersion proto;\n\tMemoryContext oldcontext;\n\n\tif (pq_getbytes((char *) &len, 4) == EOF)\n\t{\n\t\t\/*\n\t\t * EOF after SSLdone probably means the client didn't like our\n\t\t * response to NEGOTIATE_SSL_CODE.  That's not an error condition, so\n\t\t * don't clutter the log with a complaint.\n\t\t *\/\n\t\tif (!SSLdone)\n\t\t\tereport(COMMERROR,\n\t\t\t\t\t(errcode(ERRCODE_PROTOCOL_VIOLATION),\n\t\t\t\t\t errmsg(\"incomplete startup packet\")));\n\t\treturn STATUS_ERROR;\n\t}\n\n\tlen = ntohl(len);\n\tlen -= 4;\n\n\tif (len < (int32) sizeof(ProtocolVersion) ||\n\t\tlen > MAX_STARTUP_PACKET_LENGTH)\n\t{\n\t\tereport(COMMERROR,\n\t\t\t\t(errcode(ERRCODE_PROTOCOL_VIOLATION),\n\t\t\t\t errmsg(\"invalid length of startup packet\")));\n\t\treturn STATUS_ERROR;\n\t}\n\n\t\/*\n\t * Allocate at least the size of an old-style startup packet, plus one\n\t * extra byte, and make sure all are zeroes.  This ensures we will have\n\t * null termination of all strings, in both fixed- and variable-length\n\t * packet layouts.\n\t *\/\n\tif (len <= (int32) sizeof(StartupPacket))\n\t\tbuf = palloc0(sizeof(StartupPacket) + 1);\n\telse\n\t\tbuf = palloc0(len + 1);\n\n\tif (pq_getbytes(buf, len) == EOF)\n\t{\n\t\tereport(COMMERROR,\n\t\t\t\t(errcode(ERRCODE_PROTOCOL_VIOLATION),\n\t\t\t\t errmsg(\"incomplete startup packet\")));\n\t\treturn STATUS_ERROR;\n\t}\n\n\t\/*\n\t * The first field is either a protocol version number or a special\n\t * request code.\n\t *\/\n\tport->proto = proto = ntohl(*((ProtocolVersion *) buf));\n\n\tif (proto == CANCEL_REQUEST_CODE)\n\t{\n\t\tprocessCancelRequest(port, buf);\n\t\t\/* Not really an error, but we don't want to proceed further *\/\n\t\treturn STATUS_ERROR;\n\t}\n\n\tif (proto == NEGOTIATE_SSL_CODE && !SSLdone)\n\t{\n\t\tchar\t\tSSLok;\n\n#ifdef USE_SSL\n\t\t\/* No SSL when disabled or on Unix sockets *\/\n\t\tif (!EnableSSL || IS_AF_UNIX(port->laddr.addr.ss_family))\n\t\t\tSSLok = 'N';\n\t\telse\n\t\t\tSSLok = 'S';\t\t\/* Support for SSL *\/\n#else\n\t\tSSLok = 'N';\t\t\t\/* No support for SSL *\/\n#endif\n\nretry1:\n\t\tif (send(port->sock, &SSLok, 1, 0) != 1)\n\t\t{\n\t\t\tif (errno == EINTR)\n\t\t\t\tgoto retry1;\t\/* if interrupted, just retry *\/\n\t\t\tereport(COMMERROR,\n\t\t\t\t\t(errcode_for_socket_access(),\n\t\t\t\t\t errmsg(\"failed to send SSL negotiation response: %m\")));\n\t\t\treturn STATUS_ERROR;\t\/* close the connection *\/\n\t\t}\n\n#ifdef USE_SSL\n\t\tif (SSLok == 'S' && secure_open_server(port) == -1)\n\t\t\treturn STATUS_ERROR;\n#endif\n\t\t\/* regular startup packet, cancel, etc packet should follow... *\/\n\t\t\/* but not another SSL negotiation request *\/\n\t\treturn ProcessStartupPacket(port, true);\n\t}\n\n\t\/* Could add additional special packet types here *\/\n\n\t\/*\n\t * Set FrontendProtocol now so that ereport() knows what format to send if\n\t * we fail during startup.\n\t *\/\n\tFrontendProtocol = proto;\n\n\t\/* Check we can handle the protocol the frontend is using. *\/\n\n\tif (PG_PROTOCOL_MAJOR(proto) < PG_PROTOCOL_MAJOR(PG_PROTOCOL_EARLIEST) ||\n\t\tPG_PROTOCOL_MAJOR(proto) > PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) ||\n\t\t(PG_PROTOCOL_MAJOR(proto) == PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) &&\n\t\t PG_PROTOCOL_MINOR(proto) > PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST)))\n\t\tereport(FATAL,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"unsupported frontend protocol %u.%u: server supports %u.0 to %u.%u\",\n\t\t\t\t\t\tPG_PROTOCOL_MAJOR(proto), PG_PROTOCOL_MINOR(proto),\n\t\t\t\t\t\tPG_PROTOCOL_MAJOR(PG_PROTOCOL_EARLIEST),\n\t\t\t\t\t\tPG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST),\n\t\t\t\t\t\tPG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST))));\n\n\t\/*\n\t * Now fetch parameters out of startup packet and save them into the Port\n\t * structure.  All data structures attached to the Port struct must be\n\t * allocated in TopMemoryContext so that they will remain available in a\n\t * running backend (even after PostmasterContext is destroyed).  We need\n\t * not worry about leaking this storage on failure, since we aren't in the\n\t * postmaster process anymore.\n\t *\/\n\toldcontext = MemoryContextSwitchTo(TopMemoryContext);\n\n\tif (PG_PROTOCOL_MAJOR(proto) >= 3)\n\t{\n\t\tint32\t\toffset = sizeof(ProtocolVersion);\n\n\t\t\/*\n\t\t * Scan packet body for name\/option pairs.  We can assume any string\n\t\t * beginning within the packet body is null-terminated, thanks to\n\t\t * zeroing extra byte above.\n\t\t *\/\n\t\tport->guc_options = NIL;\n\n\t\twhile (offset < len)\n\t\t{\n\t\t\tchar\t   *nameptr = ((char *) buf) + offset;\n\t\t\tint32\t\tvaloffset;\n\t\t\tchar\t   *valptr;\n\n\t\t\tif (*nameptr == '\\0')\n\t\t\t\tbreak;\t\t\t\/* found packet terminator *\/\n\t\t\tvaloffset = offset + strlen(nameptr) + 1;\n\t\t\tif (valoffset >= len)\n\t\t\t\tbreak;\t\t\t\/* missing value, will complain below *\/\n\t\t\tvalptr = ((char *) buf) + valoffset;\n\n\t\t\tif (strcmp(nameptr, \"database\") == 0)\n\t\t\t\tport->database_name = pstrdup(valptr);\n\t\t\telse if (strcmp(nameptr, \"user\") == 0)\n\t\t\t\tport->user_name = pstrdup(valptr);\n\t\t\telse if (strcmp(nameptr, \"options\") == 0)\n\t\t\t\tport->cmdline_options = pstrdup(valptr);\n\t\t\telse if (strcmp(nameptr, \"replication\") == 0)\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Due to backward compatibility concerns the replication\n\t\t\t\t * parameter is a hybrid beast which allows the value to be\n\t\t\t\t * either boolean or the string 'database'. The latter\n\t\t\t\t * connects to a specific database which is e.g. required for\n\t\t\t\t * logical decoding while.\n\t\t\t\t *\/\n\t\t\t\tif (strcmp(valptr, \"database\") == 0)\n\t\t\t\t{\n\t\t\t\t\tam_walsender = true;\n\t\t\t\t\tam_db_walsender = true;\n\t\t\t\t}\n\t\t\t\telse if (!parse_bool(valptr, &am_walsender))\n\t\t\t\t\tereport(FATAL,\n\t\t\t\t\t\t\t(errcode(ERRCODE_INVALID_PARAMETER_VALUE),\n\t\t\t\t\t   errmsg(\"invalid value for parameter \\\"replication\\\"\"),\n\t\t\t\t\t\t\t errhint(\"Valid values are: false, 0, true, 1, database.\")));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t\/* Assume it's a generic GUC option *\/\n\t\t\t\tport->guc_options = lappend(port->guc_options,\n\t\t\t\t\t\t\t\t\t\t\tpstrdup(nameptr));\n\t\t\t\tport->guc_options = lappend(port->guc_options,\n\t\t\t\t\t\t\t\t\t\t\tpstrdup(valptr));\n\t\t\t}\n\t\t\toffset = valoffset + strlen(valptr) + 1;\n\t\t}\n\n\t\t\/*\n\t\t * If we didn't find a packet terminator exactly at the end of the\n\t\t * given packet length, complain.\n\t\t *\/\n\t\tif (offset != len - 1)\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errcode(ERRCODE_PROTOCOL_VIOLATION),\n\t\t\t\t\t errmsg(\"invalid startup packet layout: expected terminator as last byte\")));\n\t}\n\telse\n\t{\n\t\t\/*\n\t\t * Get the parameters from the old-style, fixed-width-fields startup\n\t\t * packet as C strings.  The packet destination was cleared first so a\n\t\t * short packet has zeros silently added.  We have to be prepared to\n\t\t * truncate the pstrdup result for oversize fields, though.\n\t\t *\/\n\t\tStartupPacket *packet = (StartupPacket *) buf;\n\n\t\tport->database_name = pstrdup(packet->database);\n\t\tif (strlen(port->database_name) > sizeof(packet->database))\n\t\t\tport->database_name[sizeof(packet->database)] = '\\0';\n\t\tport->user_name = pstrdup(packet->user);\n\t\tif (strlen(port->user_name) > sizeof(packet->user))\n\t\t\tport->user_name[sizeof(packet->user)] = '\\0';\n\t\tport->cmdline_options = pstrdup(packet->options);\n\t\tif (strlen(port->cmdline_options) > sizeof(packet->options))\n\t\t\tport->cmdline_options[sizeof(packet->options)] = '\\0';\n\t\tport->guc_options = NIL;\n\t}\n\n\t\/* Check a user name was given. *\/\n\tif (port->user_name == NULL || port->user_name[0] == '\\0')\n\t\tereport(FATAL,\n\t\t\t\t(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),\n\t\t\t errmsg(\"no PostgreSQL user name specified in startup packet\")));\n\n\t\/* The database defaults to the user name. *\/\n\tif (port->database_name == NULL || port->database_name[0] == '\\0')\n\t\tport->database_name = pstrdup(port->user_name);\n\n\tif (Db_user_namespace)\n\t{\n\t\t\/*\n\t\t * If user@, it is a global user, remove '@'. We only want to do this\n\t\t * if there is an '@' at the end and no earlier in the user string or\n\t\t * they may fake as a local user of another database attaching to this\n\t\t * database.\n\t\t *\/\n\t\tif (strchr(port->user_name, '@') ==\n\t\t\tport->user_name + strlen(port->user_name) - 1)\n\t\t\t*strchr(port->user_name, '@') = '\\0';\n\t\telse\n\t\t{\n\t\t\t\/* Append '@' and dbname *\/\n\t\t\tport->user_name = psprintf(\"%s@%s\", port->user_name, port->database_name);\n\t\t}\n\t}\n\n\t\/*\n\t * Truncate given database and user names to length of a Postgres name.\n\t * This avoids lookup failures when overlength names are given.\n\t *\/\n\tif (strlen(port->database_name) >= NAMEDATALEN)\n\t\tport->database_name[NAMEDATALEN - 1] = '\\0';\n\tif (strlen(port->user_name) >= NAMEDATALEN)\n\t\tport->user_name[NAMEDATALEN - 1] = '\\0';\n\n\t\/*\n\t * Normal walsender backends, e.g. for streaming replication, are not\n\t * connected to a particular database. But walsenders used for logical\n\t * replication need to connect to a specific database. We allow streaming\n\t * replication commands to be issued even if connected to a database as it\n\t * can make sense to first make a basebackup and then stream changes\n\t * starting from that.\n\t *\/\n\tif (am_walsender && !am_db_walsender)\n\t\tport->database_name[0] = '\\0';\n\n\t\/*\n\t * Done putting stuff in TopMemoryContext.\n\t *\/\n\tMemoryContextSwitchTo(oldcontext);\n\n\t\/*\n\t * If we're going to reject the connection due to database state, say so\n\t * now instead of wasting cycles on an authentication exchange. (This also\n\t * allows a pg_ping utility to be written.)\n\t *\/\n\tswitch (port->canAcceptConnections)\n\t{\n\t\tcase CAC_STARTUP:\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errcode(ERRCODE_CANNOT_CONNECT_NOW),\n\t\t\t\t\t errmsg(\"the database system is starting up\")));\n\t\t\tbreak;\n\t\tcase CAC_SHUTDOWN:\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errcode(ERRCODE_CANNOT_CONNECT_NOW),\n\t\t\t\t\t errmsg(\"the database system is shutting down\")));\n\t\t\tbreak;\n\t\tcase CAC_RECOVERY:\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errcode(ERRCODE_CANNOT_CONNECT_NOW),\n\t\t\t\t\t errmsg(\"the database system is in recovery mode\")));\n\t\t\tbreak;\n\t\tcase CAC_TOOMANY:\n\t\t\tereport(FATAL,\n\t\t\t\t\t(errcode(ERRCODE_TOO_MANY_CONNECTIONS),\n\t\t\t\t\t errmsg(\"sorry, too many clients already\")));\n\t\t\tbreak;\n\t\tcase CAC_WAITBACKUP:\n\t\t\t\/* OK for now, will check in InitPostgres *\/\n\t\t\tbreak;\n\t\tcase CAC_OK:\n\t\t\tbreak;\n\t}\n\n\treturn STATUS_OK;\n}","target":1,"code_token_length":2640,"total_token_length":2876,"max_tokens_setting":4096}
+{"idx":246740,"func":"void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines)\n{\n    RenderStyle* styleToUse = style();\n    bool paginated = view()->layoutState() && view()->layoutState()->isPaginated();\n    LineMidpointState& lineMidpointState = resolver.midpointState();\n    InlineIterator end = resolver.position();\n    bool checkForEndLineMatch = layoutState.endLine();\n    RenderTextInfo renderTextInfo;\n    VerticalPositionCache verticalPositionCache;\n\n    LineBreaker lineBreaker(this);\n\n    LayoutUnit absoluteLogicalTop;\n    ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();\n    if (shapeInsideInfo) {\n        ASSERT(shapeInsideInfo->owner() == this || allowsShapeInsideInfoSharing());\n        if (shapeInsideInfo != this->shapeInsideInfo()) {\n            absoluteLogicalTop = logicalTop();\n        }\n        if (logicalHeight() + absoluteLogicalTop < shapeInsideInfo->shapeLogicalTop()) {\n            LayoutUnit logicalHeight = shapeInsideInfo->shapeLogicalTop() - absoluteLogicalTop;\n            if (layoutState.flowThread())\n                logicalHeight -= shapeInsideInfo->owner()->borderAndPaddingBefore();\n            setLogicalHeight(logicalHeight);\n        }\n    }\n\n    while (!end.atEnd()) {\n        if (checkForEndLineMatch) {\n            layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus));\n            if (layoutState.endLineMatched()) {\n                resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);\n                break;\n            }\n        }\n\n        lineMidpointState.reset();\n\n        layoutState.lineInfo().setEmpty(true);\n        layoutState.lineInfo().resetRunsFromLeadingWhitespace();\n\n        const InlineIterator oldEnd = end;\n        bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly();\n        FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? m_floatingObjects->set().last() : 0;\n\n        updateShapeAndSegmentsForCurrentLine(shapeInsideInfo, absoluteLogicalTop, layoutState);\n\n        WordMeasurements wordMeasurements;\n        end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);\n        renderTextInfo.m_lineBreakIterator.resetPriorContext();\n        if (resolver.position().atEnd()) {\n            resolver.runs().deleteRuns();\n            resolver.markCurrentRunEmpty(); \/\/ FIXME: This can probably be replaced by an ASSERT (or just removed).\n            layoutState.setCheckForFloatsFromLastLine(true);\n            resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);\n            break;\n        }\n\n        if (adjustLogicalLineTopAndLogicalHeightIfNeeded(shapeInsideInfo, absoluteLogicalTop, layoutState, resolver, lastFloatFromPreviousLine, end, wordMeasurements))\n            continue;\n\n        ASSERT(end != resolver.position());\n\n        if (layoutState.lineInfo().isEmpty()) {\n            if (lastRootBox())\n                lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.status());\n        } else {\n            VisualDirectionOverride override = (styleToUse->rtlOrdering() == VisualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualRightToLeftOverride) : NoVisualOverride);\n\n            if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !resolver.context()->parent()) {\n                TextDirection direction = determinePlaintextDirectionality(resolver.position().root(), resolver.position().object(), resolver.position().offset());\n                resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->unicodeBidi())));\n            }\n            BidiRunList& bidiRuns = resolver.runs();\n            constructBidiRunsForLine(this, resolver, bidiRuns, end, override, layoutState.lineInfo().previousLineBrokeCleanly());\n            ASSERT(resolver.position() == end);\n\n            BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrokeCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0;\n\n            if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) {\n                bidiRuns.logicallyLastRun()->m_hasHyphen = true;\n                consecutiveHyphenatedLines++;\n            } else\n                consecutiveHyphenatedLines = 0;\n\n\n            LayoutUnit oldLogicalHeight = logicalHeight();\n            RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status().context->level(), bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements);\n\n            bidiRuns.deleteRuns();\n            resolver.markCurrentRunEmpty(); \/\/ FIXME: This can probably be replaced by an ASSERT (or just removed).\n\n            if (lineBox) {\n                lineBox->setLineBreakInfo(end.m_obj, end.m_pos, resolver.status());\n                if (layoutState.usesRepaintBounds())\n                    layoutState.updateRepaintRangeFromBox(lineBox);\n\n                if (paginated) {\n                    LayoutUnit adjustment = 0;\n                    adjustLinePositionForPagination(lineBox, adjustment, layoutState.flowThread());\n                    if (adjustment) {\n                        LayoutUnit oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine());\n                        lineBox->adjustBlockDirectionPosition(adjustment);\n                        if (layoutState.usesRepaintBounds())\n                            layoutState.updateRepaintRangeFromBox(lineBox);\n\n                        if (availableLogicalWidthForLine(oldLogicalHeight + adjustment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) {\n                            lineBox->deleteLine();\n                            end = restartLayoutRunsAndFloatsInRange(oldLogicalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, oldEnd);\n                            continue;\n                        }\n\n                        setLogicalHeight(lineBox->lineBottomWithLeading());\n                    }\n\n                    if (layoutState.flowThread())\n                        lineBox->setContainingRegion(regionAtBlockOffset(lineBox->lineTopWithLeading()));\n                }\n            }\n        }\n\n        for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i)\n            setStaticPositions(this, lineBreaker.positionedObjects()[i]);\n\n        if (!layoutState.lineInfo().isEmpty()) {\n            layoutState.lineInfo().setFirstLine(false);\n            newLine(lineBreaker.clear());\n        }\n\n        if (m_floatingObjects && lastRootBox()) {\n            const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();\n            FloatingObjectSetIterator it = floatingObjectSet.begin();\n            FloatingObjectSetIterator end = floatingObjectSet.end();\n            if (layoutState.lastFloat()) {\n                FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(layoutState.lastFloat());\n                ASSERT(lastFloatIterator != end);\n                ++lastFloatIterator;\n                it = lastFloatIterator;\n            }\n            for (; it != end; ++it) {\n                FloatingObject* f = *it;\n                appendFloatingObjectToLastLine(f);\n                ASSERT(f->renderer() == layoutState.floats()[layoutState.floatIndex()].object);\n                if (layoutState.floats()[layoutState.floatIndex()].rect != f->frameRect())\n                    checkForEndLineMatch = false;\n                layoutState.setFloatIndex(layoutState.floatIndex() + 1);\n            }\n            layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSet.last() : 0);\n        }\n\n        lineMidpointState.reset();\n        resolver.setPosition(end, numberOfIsolateAncestors(end));\n    }\n\n    if (paginated && !style()->hasAutoWidows()) {\n\n        RootInlineBox* lineBox = lastRootBox();\n\n        RootInlineBox* firstLineInBlock = firstRootBox();\n        int numLinesHanging = 1;\n        while (lineBox && lineBox != firstLineInBlock && !lineBox->isFirstAfterPageBreak()) {\n            ++numLinesHanging;\n            lineBox = lineBox->prevRootBox();\n        }\n\n        if (!lineBox || !lineBox->isFirstAfterPageBreak() || lineBox == firstLineInBlock)\n            return;\n\n        if (numLinesHanging < style()->widows()) {\n            int numLinesNeeded = style()->widows() - numLinesHanging;\n            RootInlineBox* currentFirstLineOfNewPage = lineBox;\n\n            lineBox = lineBox->prevRootBox();\n            int numLinesInPreviousPage = 1;\n            while (lineBox && lineBox != firstLineInBlock && !lineBox->isFirstAfterPageBreak()) {\n                ++numLinesInPreviousPage;\n                lineBox = lineBox->prevRootBox();\n            }\n\n            int orphans = style()->hasAutoOrphans() ? style()->initialOrphans() : style()->orphans();\n            int numLinesAvailable = numLinesInPreviousPage - orphans;\n            if (numLinesAvailable <= 0)\n                return;\n\n            int numLinesToTake = min(numLinesAvailable, numLinesNeeded);\n            lineBox = currentFirstLineOfNewPage;\n            for (int i = 0; i < numLinesToTake; ++i)\n                lineBox = lineBox->prevRootBox();\n\n            setBreakAtLineToAvoidWidow(lineBox);\n            markLinesDirtyInBlockRange(lastRootBox()->lineBottomWithLeading(), lineBox->lineBottomWithLeading(), lineBox);\n        }\n    }\n}\n","target":0,"code_token_length":2028,"total_token_length":2264,"max_tokens_setting":4096}
+{"idx":351885,"func":"void ext4_free_blocks(handle_t *handle, struct inode *inode,\n\t\t      struct buffer_head *bh, ext4_fsblk_t block,\n\t\t      unsigned long count, int flags)\n{\n\tstruct buffer_head *bitmap_bh = NULL;\n\tstruct super_block *sb = inode->i_sb;\n\tstruct ext4_group_desc *gdp;\n\tunsigned int overflow;\n\text4_grpblk_t bit;\n\tstruct buffer_head *gd_bh;\n\text4_group_t block_group;\n\tstruct ext4_sb_info *sbi;\n\tstruct ext4_buddy e4b;\n\tunsigned int count_clusters;\n\tint err = 0;\n\tint ret;\n\n\tmight_sleep();\n\tif (bh) {\n\t\tif (block)\n\t\t\tBUG_ON(block != bh->b_blocknr);\n\t\telse\n\t\t\tblock = bh->b_blocknr;\n\t}\n\n\tsbi = EXT4_SB(sb);\n\tif (!(flags & EXT4_FREE_BLOCKS_VALIDATED) &&\n\t    !ext4_data_block_valid(sbi, block, count)) {\n\t\text4_error(sb, \"Freeing blocks not in datazone - \"\n\t\t\t   \"block = %llu, count = %lu\", block, count);\n\t\tgoto error_return;\n\t}\n\n\text4_debug(\"freeing block %llu\\n\", block);\n\ttrace_ext4_free_blocks(inode, block, count, flags);\n\n\tif (bh && (flags & EXT4_FREE_BLOCKS_FORGET)) {\n\t\tBUG_ON(count > 1);\n\n\t\text4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,\n\t\t\t    inode, bh, block);\n\t}\n\n\t\/*\n\t * If the extent to be freed does not begin on a cluster\n\t * boundary, we need to deal with partial clusters at the\n\t * beginning and end of the extent.  Normally we will free\n\t * blocks at the beginning or the end unless we are explicitly\n\t * requested to avoid doing so.\n\t *\/\n\toverflow = EXT4_PBLK_COFF(sbi, block);\n\tif (overflow) {\n\t\tif (flags & EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER) {\n\t\t\toverflow = sbi->s_cluster_ratio - overflow;\n\t\t\tblock += overflow;\n\t\t\tif (count > overflow)\n\t\t\t\tcount -= overflow;\n\t\t\telse\n\t\t\t\treturn;\n\t\t} else {\n\t\t\tblock -= overflow;\n\t\t\tcount += overflow;\n\t\t}\n\t}\n\toverflow = EXT4_LBLK_COFF(sbi, count);\n\tif (overflow) {\n\t\tif (flags & EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER) {\n\t\t\tif (count > overflow)\n\t\t\t\tcount -= overflow;\n\t\t\telse\n\t\t\t\treturn;\n\t\t} else\n\t\t\tcount += sbi->s_cluster_ratio - overflow;\n\t}\n\n\tif (!bh && (flags & EXT4_FREE_BLOCKS_FORGET)) {\n\t\tint i;\n\t\tint is_metadata = flags & EXT4_FREE_BLOCKS_METADATA;\n\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tcond_resched();\n\t\t\tif (is_metadata)\n\t\t\t\tbh = sb_find_get_block(inode->i_sb, block + i);\n\t\t\text4_forget(handle, is_metadata, inode, bh, block + i);\n\t\t}\n\t}\n\ndo_more:\n\toverflow = 0;\n\text4_get_group_no_and_offset(sb, block, &block_group, &bit);\n\n\tif (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(\n\t\t\text4_get_group_info(sb, block_group))))\n\t\treturn;\n\n\t\/*\n\t * Check to see if we are freeing blocks across a group\n\t * boundary.\n\t *\/\n\tif (EXT4_C2B(sbi, bit) + count > EXT4_BLOCKS_PER_GROUP(sb)) {\n\t\toverflow = EXT4_C2B(sbi, bit) + count -\n\t\t\tEXT4_BLOCKS_PER_GROUP(sb);\n\t\tcount -= overflow;\n\t}\n\tcount_clusters = EXT4_NUM_B2C(sbi, count);\n\tbitmap_bh = ext4_read_block_bitmap(sb, block_group);\n\tif (IS_ERR(bitmap_bh)) {\n\t\terr = PTR_ERR(bitmap_bh);\n\t\tbitmap_bh = NULL;\n\t\tgoto error_return;\n\t}\n\tgdp = ext4_get_group_desc(sb, block_group, &gd_bh);\n\tif (!gdp) {\n\t\terr = -EIO;\n\t\tgoto error_return;\n\t}\n\n\tif (in_range(ext4_block_bitmap(sb, gdp), block, count) ||\n\t    in_range(ext4_inode_bitmap(sb, gdp), block, count) ||\n\t    in_range(block, ext4_inode_table(sb, gdp),\n\t\t     sbi->s_itb_per_group) ||\n\t    in_range(block + count - 1, ext4_inode_table(sb, gdp),\n\t\t     sbi->s_itb_per_group)) {\n\n\t\text4_error(sb, \"Freeing blocks in system zone - \"\n\t\t\t   \"Block = %llu, count = %lu\", block, count);\n\t\t\/* err = 0. ext4_std_error should be a no op *\/\n\t\tgoto error_return;\n\t}\n\n\tBUFFER_TRACE(bitmap_bh, \"getting write access\");\n\terr = ext4_journal_get_write_access(handle, bitmap_bh);\n\tif (err)\n\t\tgoto error_return;\n\n\t\/*\n\t * We are about to modify some metadata.  Call the journal APIs\n\t * to unshare ->b_data if a currently-committing transaction is\n\t * using it\n\t *\/\n\tBUFFER_TRACE(gd_bh, \"get_write_access\");\n\terr = ext4_journal_get_write_access(handle, gd_bh);\n\tif (err)\n\t\tgoto error_return;\n#ifdef AGGRESSIVE_CHECK\n\t{\n\t\tint i;\n\t\tfor (i = 0; i < count_clusters; i++)\n\t\t\tBUG_ON(!mb_test_bit(bit + i, bitmap_bh->b_data));\n\t}\n#endif\n\ttrace_ext4_mballoc_free(sb, inode, block_group, bit, count_clusters);\n\n\t\/* __GFP_NOFAIL: retry infinitely, ignore TIF_MEMDIE and memcg limit. *\/\n\terr = ext4_mb_load_buddy_gfp(sb, block_group, &e4b,\n\t\t\t\t     GFP_NOFS|__GFP_NOFAIL);\n\tif (err)\n\t\tgoto error_return;\n\n\t\/*\n\t * We need to make sure we don't reuse the freed block until after the\n\t * transaction is committed. We make an exception if the inode is to be\n\t * written in writeback mode since writeback mode has weak data\n\t * consistency guarantees.\n\t *\/\n\tif (ext4_handle_valid(handle) &&\n\t    ((flags & EXT4_FREE_BLOCKS_METADATA) ||\n\t     !ext4_should_writeback_data(inode))) {\n\t\tstruct ext4_free_data *new_entry;\n\t\t\/*\n\t\t * We use __GFP_NOFAIL because ext4_free_blocks() is not allowed\n\t\t * to fail.\n\t\t *\/\n\t\tnew_entry = kmem_cache_alloc(ext4_free_data_cachep,\n\t\t\t\tGFP_NOFS|__GFP_NOFAIL);\n\t\tnew_entry->efd_start_cluster = bit;\n\t\tnew_entry->efd_group = block_group;\n\t\tnew_entry->efd_count = count_clusters;\n\t\tnew_entry->efd_tid = handle->h_transaction->t_tid;\n\n\t\text4_lock_group(sb, block_group);\n\t\tmb_clear_bits(bitmap_bh->b_data, bit, count_clusters);\n\t\text4_mb_free_metadata(handle, &e4b, new_entry);\n\t} else {\n\t\t\/* need to update group_info->bb_free and bitmap\n\t\t * with group lock held. generate_buddy look at\n\t\t * them with group lock_held\n\t\t *\/\n\t\tif (test_opt(sb, DISCARD)) {\n\t\t\terr = ext4_issue_discard(sb, block_group, bit, count,\n\t\t\t\t\t\t NULL);\n\t\t\tif (err && err != -EOPNOTSUPP)\n\t\t\t\text4_msg(sb, KERN_WARNING, \"discard request in\"\n\t\t\t\t\t \" group:%d block:%d count:%lu failed\"\n\t\t\t\t\t \" with %d\", block_group, bit, count,\n\t\t\t\t\t err);\n\t\t} else\n\t\t\tEXT4_MB_GRP_CLEAR_TRIMMED(e4b.bd_info);\n\n\t\text4_lock_group(sb, block_group);\n\t\tmb_clear_bits(bitmap_bh->b_data, bit, count_clusters);\n\t\tmb_free_blocks(inode, &e4b, bit, count_clusters);\n\t}\n\n\tret = ext4_free_group_clusters(sb, gdp) + count_clusters;\n\text4_free_group_clusters_set(sb, gdp, ret);\n\text4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh);\n\text4_group_desc_csum_set(sb, block_group, gdp);\n\text4_unlock_group(sb, block_group);\n\n\tif (sbi->s_log_groups_per_flex) {\n\t\text4_group_t flex_group = ext4_flex_group(sbi, block_group);\n\t\tatomic64_add(count_clusters,\n\t\t\t     &sbi_array_rcu_deref(sbi, s_flex_groups,\n\t\t\t\t\t\t  flex_group)->free_clusters);\n\t}\n\n\t\/*\n\t * on a bigalloc file system, defer the s_freeclusters_counter\n\t * update to the caller (ext4_remove_space and friends) so they\n\t * can determine if a cluster freed here should be rereserved\n\t *\/\n\tif (!(flags & EXT4_FREE_BLOCKS_RERESERVE_CLUSTER)) {\n\t\tif (!(flags & EXT4_FREE_BLOCKS_NO_QUOT_UPDATE))\n\t\t\tdquot_free_block(inode, EXT4_C2B(sbi, count_clusters));\n\t\tpercpu_counter_add(&sbi->s_freeclusters_counter,\n\t\t\t\t   count_clusters);\n\t}\n\n\text4_mb_unload_buddy(&e4b);\n\n\t\/* We dirtied the bitmap block *\/\n\tBUFFER_TRACE(bitmap_bh, \"dirtied bitmap block\");\n\terr = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);\n\n\t\/* And the group descriptor block *\/\n\tBUFFER_TRACE(gd_bh, \"dirtied group descriptor block\");\n\tret = ext4_handle_dirty_metadata(handle, NULL, gd_bh);\n\tif (!err)\n\t\terr = ret;\n\n\tif (overflow && !err) {\n\t\tblock += count;\n\t\tcount = overflow;\n\t\tput_bh(bitmap_bh);\n\t\tgoto do_more;\n\t}\nerror_return:\n\tbrelse(bitmap_bh);\n\text4_std_error(sb, err);\n\treturn;\n}","target":1,"code_token_length":2100,"total_token_length":2336,"max_tokens_setting":4096}
+{"idx":346504,"func":"static int startApp(QCommandLineParser& p)\n{\n    \/\/ Stop daemon and exit?\n    if (p.isSet(\"s\"))\n    {\n        KDEsuClient client;\n        if (client.ping() == -1)\n        {\n            qCCritical(category) << \"Daemon not running -- nothing to stop\\n\";\n            p.showHelp(1);\n        }\n        if (client.stopServer() != -1)\n        {\n            qCDebug(category) << \"Daemon stopped\\n\";\n            exit(0);\n        }\n        qCCritical(category) << \"Could not stop daemon\\n\";\n        p.showHelp(1);\n    }\n\n    QString icon;\n    if ( p.isSet(\"i\"))\n        icon = p.value(\"i\");\n\n    bool prompt = true;\n    if ( p.isSet(\"d\"))\n        prompt = false;\n\n    \/\/ Get target uid\n    QByteArray user = p.value(\"u\").toLocal8Bit();\n    QByteArray auth_user = user;\n    struct passwd *pw = getpwnam(user);\n    if (pw == 0L)\n    {\n        qCCritical(category) << \"User \" << user << \" does not exist\\n\";\n        p.showHelp(1);\n    }\n    bool other_uid = (getuid() != pw->pw_uid);\n    bool change_uid = other_uid;\n    if (!change_uid) {\n        char *cur_user = getenv(\"USER\");\n        if (!cur_user)\n            cur_user = getenv(\"LOGNAME\");\n        change_uid = (!cur_user || user != cur_user);\n    }\n\n    \/\/ If file is writeable, do not change uid\n    QString file = p.value(\"f\");\n    if (other_uid && !file.isEmpty())\n    {\n        if (file.startsWith('\/'))\n        {\n            file = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, file);\n            if (file.isEmpty())\n            {\n                qCCritical(category) << \"Config file not found: \" << file;\n                p.showHelp(1);\n            }\n        }\n        QFileInfo fi(file);\n        if (!fi.exists())\n        {\n            qCCritical(category) << \"File does not exist: \" << file;\n            p.showHelp(1);\n        }\n        change_uid = !fi.isWritable();\n    }\n\n    \/\/ Get priority\/scheduler\n    QString tmp = p.value(\"p\");\n    bool ok;\n    int priority = tmp.toInt(&ok);\n    if (!ok || (priority < 0) || (priority > 100))\n    {\n        qCCritical(category) << i18n(\"Illegal priority: %1\", tmp);\n        p.showHelp(1);\n    }\n    int scheduler = SuProcess::SchedNormal;\n    if (p.isSet(\"r\"))\n        scheduler = SuProcess::SchedRealtime;\n    if ((priority > 50) || (scheduler != SuProcess::SchedNormal))\n    {\n        change_uid = true;\n        auth_user = \"root\";\n    }\n\n    \/\/ Get command\n    if (p.isSet(\"c\"))\n    {\n        command = p.value(\"c\").toLocal8Bit();\n        \/\/ Accepting additional arguments here is somewhat weird,\n        \/\/ but one can conceive use cases: have a complex command with\n        \/\/ redirections and additional file names which need to be quoted\n        \/\/ safely.\n    }\n    else\n    {\n        if( p.positionalArguments().count() == 0 )\n        {\n            qCCritical(category) << i18n(\"No command specified.\");\n            p.showHelp(1);\n        }\n    }\n    foreach(const QString& arg, p.positionalArguments())\n    {\n        command += ' ';\n        command += QFile::encodeName(KShell::quoteArg(arg));\n    }\n\n    \/\/ Don't change uid if we're don't need to.\n    if (!change_uid)\n    {\n        int result = system(command);\n        result = WEXITSTATUS(result);\n        return result;\n    }\n\n    \/\/ Check for daemon and start if necessary\n    bool just_started = false;\n    bool have_daemon = true;\n    KDEsuClient client;\n    if (!client.isServerSGID())\n    {\n        qCWarning(category) << \"Daemon not safe (not sgid), not using it.\\n\";\n        have_daemon = false;\n    }\n    else if (client.ping() == -1)\n    {\n        if (client.startServer() == -1)\n        {\n            qCWarning(category) << \"Could not start daemon, reduced functionality.\\n\";\n            have_daemon = false;\n        }\n        just_started = true;\n    }\n\n    \/\/ Try to exec the command with kdesud.\n    bool keep = !p.isSet(\"n\") && have_daemon;\n    bool terminal = p.isSet(\"t\");\n    bool withIgnoreButton = !p.isSet(\"noignorebutton\");\n    int winid = -1;\n    bool attach = p.isSet(\"attach\");\n    if(attach) {\n        winid = p.value(\"attach\").toInt(&attach, 0);  \/\/C style parsing.  If the string begins with \"0x\", base 16 is used; if the string begins with \"0\", base 8 is used; otherwise, base 10 is used.\n        if(!attach)\n            qCWarning(category) << \"Specified winid to attach to is not a valid number\";\n    } else if(p.isSet(\"embed\")) {\n        \/* KDialog originally used --embed for attaching the dialog box.  However this is misleading and so we changed to --attach.\n         * For consistancy, we silently map --embed to --attach *\/\n        attach = true;\n        winid = p.value(\"embed\").toInt(&attach, 0);  \/\/C style parsing.  If the string begins with \"0x\", base 16 is used; if the string begins with \"0\", base 8 is used; otherwise, base 10 is used.\n        if(!attach)\n            qCWarning(category) << \"Specified winid to attach to is not a valid number\";\n    }\n\n\n    QList env;\n    QByteArray options;\n    env << ( \"DESKTOP_STARTUP_ID=\" + KStartupInfo::startupId());\n\n\/\/     TODO: Maybe should port this to XDG_*, somehow?\n\/\/     if (pw->pw_uid)\n\/\/     {\n\/\/        \/\/ Only propagate KDEHOME for non-root users,\n\/\/        \/\/ root uses KDEROOTHOME\n\/\/\n\/\/        \/\/ Translate the KDEHOME of this user to the new user.\n\/\/        QString kdeHome = KGlobal::dirs()->relativeLocation(\"home\", KGlobal::dirs()->localkdedir());\n\/\/        if (kdeHome[0] != '\/')\n\/\/           kdeHome.prepend(\"~\/\");\n\/\/        else\n\/\/           kdeHome.clear(); \/\/ Use default\n\/\/\n\/\/        env << (\"KDEHOME=\"+ QFile::encodeName(kdeHome));\n\/\/     }\n\n    KUser u;\n    env << (QByteArray) (\"KDESU_USER=\" + u.loginName().toLocal8Bit());\n\n    if (keep && !terminal && !just_started)\n    {\n        client.setPriority(priority);\n        client.setScheduler(scheduler);\n        int result = client.exec(command, user, options, env);\n        if (result == 0)\n        {\n           result = client.exitCode();\n           return result;\n        }\n    }\n\n    \/\/ Set core dump size to 0 because we will have\n    \/\/ root's password in memory.\n    struct rlimit rlim;\n    rlim.rlim_cur = rlim.rlim_max = 0;\n    if (setrlimit(RLIMIT_CORE, &rlim))\n    {\n        qCCritical(category) << \"rlimit(): \" << ERR;\n        p.showHelp(1);\n    }\n\n    \/\/ Read configuration\n    KConfigGroup config(KSharedConfig::openConfig(), \"Passwords\");\n    int timeout = config.readEntry(\"Timeout\", defTimeout);\n\n    \/\/ Check if we need a password\n    SuProcess proc;\n    proc.setUser(auth_user);\n    int needpw = proc.checkNeedPassword();\n    if (needpw < 0)\n    {\n        QString err = i18n(\"Su returned with an error.\\n\");\n        KMessageBox::error(0L, err);\n        p.showHelp(1);\n    }\n    if (needpw == 0)\n    {\n        keep = 0;\n        qDebug() << \"Don't need password!!\\n\";\n    }\n\n    \/\/ Start the dialog\n    QString password;\n    if (needpw)\n    {\n#ifdef HAVE_X11\n        KStartupInfoId id;\n        id.initId();\n        KStartupInfoData data;\n        data.setSilent( KStartupInfoData::Yes );\n        KStartupInfo::sendChange( id, data );\n#endif\n        KDEsuDialog dlg(user, auth_user, keep && !terminal, icon, withIgnoreButton);\n        if (prompt)\n            dlg.addCommentLine(i18n(\"Command:\"), QFile::decodeName(command));\n        if (defKeep)\n            dlg.setKeepPassword(true);\n\n        if ((priority != 50) || (scheduler != SuProcess::SchedNormal))\n        {\n            QString prio;\n            if (scheduler == SuProcess::SchedRealtime)\n                prio += i18n(\"realtime: \");\n            prio += QString(\"%1\/100\").arg(priority);\n            if (prompt)\n                dlg.addCommentLine(i18n(\"Priority:\"), prio);\n        }\n\n\t\/\/Attach dialog\n#ifdef HAVE_X11\n\tif(attach)\n            KWindowSystem::setMainWindow(&dlg, (WId)winid);\n#endif\n        int ret = dlg.exec();\n        if (ret == KDEsuDialog::Rejected)\n        {\n#ifdef HAVE_X11\n            KStartupInfo::sendFinish( id );\n#endif\n            p.showHelp(1);\n        }\n        if (ret == KDEsuDialog::AsUser)\n            change_uid = false;\n        password = dlg.password();\n        keep = dlg.keepPassword();\n#ifdef HAVE_X11\n        data.setSilent( KStartupInfoData::No );\n        KStartupInfo::sendChange( id, data );\n#endif\n    }\n\n    \/\/ Some events may need to be handled (like a button animation)\n    qApp->processEvents();\n\n    \/\/ Run command\n    if (!change_uid)\n    {\n        int result = system(command);\n        result = WEXITSTATUS(result);\n        return result;\n    }\n    else if (keep && have_daemon)\n    {\n        client.setPass(password.toLocal8Bit(), timeout);\n        client.setPriority(priority);\n        client.setScheduler(scheduler);\n        int result = client.exec(command, user, options, env);\n        if (result == 0)\n        {\n            result = client.exitCode();\n            return result;\n        }\n    } else\n    {\n        SuProcess proc;\n        proc.setTerminal(terminal);\n        proc.setErase(true);\n        proc.setUser(user);\n        proc.setEnvironment(env);\n        proc.setPriority(priority);\n        proc.setScheduler(scheduler);\n        proc.setCommand(command);\n        int result = proc.exec(password.toLocal8Bit());\n        return result;\n    }\n    return -1;\n}","target":1,"code_token_length":2333,"total_token_length":2569,"max_tokens_setting":4096}
+{"idx":371013,"func":"guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs)\n{\n  int r;\n\n  fs->type = OS_TYPE_LINUX;\n\n  if (guestfs_exists (g, \"\/etc\/lsb-release\") > 0) {\n    r = parse_lsb_release (g, fs);\n    if (r == -1)        \/* error *\/\n      return -1;\n    if (r == 1)         \/* ok - detected the release from this file *\/\n      goto skip_release_checks;\n  }\n\n  if (guestfs_exists (g, \"\/etc\/redhat-release\") > 0) {\n    fs->distro = OS_DISTRO_REDHAT_BASED; \/* Something generic Red Hat-like. *\/\n\n    if (parse_release_file (g, fs, \"\/etc\/redhat-release\") == -1)\n      return -1;\n\n    char *major, *minor;\n    if ((major = match1 (g, fs->product_name, re_fedora)) != NULL) {\n      fs->distro = OS_DISTRO_FEDORA;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1)\n        return -1;\n    }\n    else if (match2 (g, fs->product_name, re_rhel_old, &major, &minor) ||\n             match2 (g, fs->product_name, re_rhel, &major, &minor)) {\n      fs->distro = OS_DISTRO_RHEL;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1) {\n        free (minor);\n        return -1;\n      }\n      fs->minor_version = guestfs___parse_unsigned_int (g, minor);\n      free (minor);\n      if (fs->minor_version == -1)\n        return -1;\n    }\n    else if ((major = match1 (g, fs->product_name, re_rhel_no_minor)) != NULL) {\n      fs->distro = OS_DISTRO_RHEL;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1)\n        return -1;\n      fs->minor_version = 0;\n    }\n    else if (match2 (g, fs->product_name, re_centos_old, &major, &minor) ||\n             match2 (g, fs->product_name, re_centos, &major, &minor)) {\n      fs->distro = OS_DISTRO_CENTOS;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1) {\n        free (minor);\n        return -1;\n      }\n      fs->minor_version = guestfs___parse_unsigned_int (g, minor);\n      free (minor);\n      if (fs->minor_version == -1)\n        return -1;\n    }\n    else if ((major = match1 (g, fs->product_name, re_centos_no_minor)) != NULL) {\n      fs->distro = OS_DISTRO_CENTOS;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1)\n        return -1;\n      fs->minor_version = 0;\n    }\n    else if (match2 (g, fs->product_name, re_scientific_linux_old, &major, &minor) ||\n             match2 (g, fs->product_name, re_scientific_linux, &major, &minor)) {\n      fs->distro = OS_DISTRO_SCIENTIFIC_LINUX;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1) {\n        free (minor);\n        return -1;\n      }\n      fs->minor_version = guestfs___parse_unsigned_int (g, minor);\n      free (minor);\n      if (fs->minor_version == -1)\n        return -1;\n    }\n    else if ((major = match1 (g, fs->product_name, re_scientific_linux_no_minor)) != NULL) {\n      fs->distro = OS_DISTRO_SCIENTIFIC_LINUX;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1)\n        return -1;\n      fs->minor_version = 0;\n    }\n  }\n  else if (guestfs_exists (g, \"\/etc\/debian_version\") > 0) {\n    fs->distro = OS_DISTRO_DEBIAN;\n\n    if (parse_release_file (g, fs, \"\/etc\/debian_version\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n  else if (guestfs_exists (g, \"\/etc\/pardus-release\") > 0) {\n    fs->distro = OS_DISTRO_PARDUS;\n\n    if (parse_release_file (g, fs, \"\/etc\/pardus-release\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n  else if (guestfs_exists (g, \"\/etc\/arch-release\") > 0) {\n    fs->distro = OS_DISTRO_ARCHLINUX;\n\n    \/* \/etc\/arch-release file is empty and I can't see a way to\n     * determine the actual release or product string.\n     *\/\n  }\n  else if (guestfs_exists (g, \"\/etc\/gentoo-release\") > 0) {\n    fs->distro = OS_DISTRO_GENTOO;\n\n    if (parse_release_file (g, fs, \"\/etc\/gentoo-release\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n  else if (guestfs_exists (g, \"\/etc\/meego-release\") > 0) {\n    fs->distro = OS_DISTRO_MEEGO;\n\n    if (parse_release_file (g, fs, \"\/etc\/meego-release\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n  else if (guestfs_exists (g, \"\/etc\/slackware-version\") > 0) {\n    fs->distro = OS_DISTRO_SLACKWARE;\n\n    if (parse_release_file (g, fs, \"\/etc\/slackware-version\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n  else if (guestfs_exists (g, \"\/etc\/ttylinux-target\") > 0) {\n    fs->distro = OS_DISTRO_TTYLINUX;\n\n    if (parse_release_file (g, fs, \"\/etc\/ttylinux-target\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n  else if (guestfs_exists (g, \"\/etc\/SuSE-release\") > 0) {\n    fs->distro = OS_DISTRO_SUSE_BASED;\n\n    if (parse_suse_release (g, fs, \"\/etc\/SuSE-release\") == -1)\n      return -1;\n\n  }\n  \/* Buildroot (http:\/\/buildroot.net) is an embedded Linux distro\n   * toolkit.  It is used by specific distros such as Cirros.\n   *\/\n  else if (guestfs_exists (g, \"\/etc\/br-version\") > 0) {\n    if (guestfs_exists (g, \"\/usr\/share\/cirros\/logo\") > 0)\n      fs->distro = OS_DISTRO_CIRROS;\n    else\n      fs->distro = OS_DISTRO_BUILDROOT;\n\n    \/* \/etc\/br-version has the format YYYY.MM[-git\/hg\/svn release] *\/\n    if (parse_release_file (g, fs, \"\/etc\/br-version\") == -1)\n      return -1;\n\n    if (guestfs___parse_major_minor (g, fs) == -1)\n      return -1;\n  }\n\n skip_release_checks:;\n\n  \/* Determine the architecture. *\/\n  check_architecture (g, fs);\n\n  \/* We already know \/etc\/fstab exists because it's part of the test\n   * for Linux root above.  We must now parse this file to determine\n   * which filesystems are used by the operating system and how they\n   * are mounted.\n   *\/\n  const char *configfiles[] = { \"\/etc\/fstab\", \"\/etc\/mdadm.conf\", NULL };\n  if (inspect_with_augeas (g, fs, configfiles, check_fstab) == -1)\n    return -1;\n\n  \/* Determine hostname. *\/\n  if (check_hostname_unix (g, fs) == -1)\n    return -1;\n\n  return 0;\n}","target":0,"code_token_length":1965,"total_token_length":2201,"max_tokens_setting":4096}
+{"idx":53967,"func":"int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,\n\t\t\tstruct ext4_map_blocks *map, int flags)\n{\n\tstruct ext4_ext_path *path = NULL;\n\tstruct ext4_extent newex, *ex, *ex2;\n\tstruct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);\n\text4_fsblk_t newblock = 0;\n\tint free_on_err = 0, err = 0, depth, ret;\n\tunsigned int allocated = 0, offset = 0;\n\tunsigned int allocated_clusters = 0;\n\tstruct ext4_allocation_request ar;\n\text4_io_end_t *io = ext4_inode_aio(inode);\n\text4_lblk_t cluster_offset;\n\tint set_unwritten = 0;\n\tbool map_from_cluster = false;\n\n\text_debug(\"blocks %u\/%u requested for inode %lu\\n\",\n\t\t  map->m_lblk, map->m_len, inode->i_ino);\n\ttrace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);\n\n\t\/* find extent for this block *\/\n\tpath = ext4_find_extent(inode, map->m_lblk, NULL, 0);\n\tif (IS_ERR(path)) {\n\t\terr = PTR_ERR(path);\n\t\tpath = NULL;\n\t\tgoto out2;\n\t}\n\n\tdepth = ext_depth(inode);\n\n\t\/*\n\t * consistent leaf must not be empty;\n\t * this situation is possible, though, _during_ tree modification;\n\t * this is why assert can't be put in ext4_find_extent()\n\t *\/\n\tif (unlikely(path[depth].p_ext == NULL && depth != 0)) {\n\t\tEXT4_ERROR_INODE(inode, \"bad extent address \"\n\t\t\t\t \"lblock: %lu, depth: %d pblock %lld\",\n\t\t\t\t (unsigned long) map->m_lblk, depth,\n\t\t\t\t path[depth].p_block);\n\t\terr = -EIO;\n\t\tgoto out2;\n\t}\n\n\tex = path[depth].p_ext;\n\tif (ex) {\n\t\text4_lblk_t ee_block = le32_to_cpu(ex->ee_block);\n\t\text4_fsblk_t ee_start = ext4_ext_pblock(ex);\n\t\tunsigned short ee_len;\n\n\n\t\t\/*\n\t\t * unwritten extents are treated as holes, except that\n\t\t * we split out initialized portions during a write.\n\t\t *\/\n\t\tee_len = ext4_ext_get_actual_len(ex);\n\n\t\ttrace_ext4_ext_show_extent(inode, ee_block, ee_start, ee_len);\n\n\t\t\/* if found extent covers block, simply return it *\/\n\t\tif (in_range(map->m_lblk, ee_block, ee_len)) {\n\t\t\tnewblock = map->m_lblk - ee_block + ee_start;\n\t\t\t\/* number of remaining blocks in the extent *\/\n\t\t\tallocated = ee_len - (map->m_lblk - ee_block);\n\t\t\text_debug(\"%u fit into %u:%d -> %llu\\n\", map->m_lblk,\n\t\t\t\t  ee_block, ee_len, newblock);\n\n\t\t\t\/*\n\t\t\t * If the extent is initialized check whether the\n\t\t\t * caller wants to convert it to unwritten.\n\t\t\t *\/\n\t\t\tif ((!ext4_ext_is_unwritten(ex)) &&\n\t\t\t    (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {\n\t\t\t\tallocated = convert_initialized_extent(\n\t\t\t\t\t\thandle, inode, map, &path,\n\t\t\t\t\t\tflags, allocated, newblock);\n\t\t\t\tgoto out2;\n\t\t\t} else if (!ext4_ext_is_unwritten(ex))\n\t\t\t\tgoto out;\n\n\t\t\tret = ext4_ext_handle_unwritten_extents(\n\t\t\t\thandle, inode, map, &path, flags,\n\t\t\t\tallocated, newblock);\n\t\t\tif (ret < 0)\n\t\t\t\terr = ret;\n\t\t\telse\n\t\t\t\tallocated = ret;\n\t\t\tgoto out2;\n\t\t}\n\t}\n\n\t\/*\n\t * requested block isn't allocated yet;\n\t * we couldn't try to create block if create flag is zero\n\t *\/\n\tif ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {\n\t\t\/*\n\t\t * put just found gap into cache to speed up\n\t\t * subsequent requests\n\t\t *\/\n\t\text4_ext_put_gap_in_cache(inode, path, map->m_lblk);\n\t\tgoto out2;\n\t}\n\n\t\/*\n\t * Okay, we need to do block allocation.\n\t *\/\n\tnewex.ee_block = cpu_to_le32(map->m_lblk);\n\tcluster_offset = EXT4_LBLK_COFF(sbi, map->m_lblk);\n\n\t\/*\n\t * If we are doing bigalloc, check to see if the extent returned\n\t * by ext4_find_extent() implies a cluster we can use.\n\t *\/\n\tif (cluster_offset && ex &&\n\t    get_implied_cluster_alloc(inode->i_sb, map, ex, path)) {\n\t\tar.len = allocated = map->m_len;\n\t\tnewblock = map->m_pblk;\n\t\tmap_from_cluster = true;\n\t\tgoto got_allocated_blocks;\n\t}\n\n\t\/* find neighbour allocated blocks *\/\n\tar.lleft = map->m_lblk;\n\terr = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft);\n\tif (err)\n\t\tgoto out2;\n\tar.lright = map->m_lblk;\n\tex2 = NULL;\n\terr = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2);\n\tif (err)\n\t\tgoto out2;\n\n\t\/* Check if the extent after searching to the right implies a\n\t * cluster we can use. *\/\n\tif ((sbi->s_cluster_ratio > 1) && ex2 &&\n\t    get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) {\n\t\tar.len = allocated = map->m_len;\n\t\tnewblock = map->m_pblk;\n\t\tmap_from_cluster = true;\n\t\tgoto got_allocated_blocks;\n\t}\n\n\t\/*\n\t * See if request is beyond maximum number of blocks we can have in\n\t * a single extent. For an initialized extent this limit is\n\t * EXT_INIT_MAX_LEN and for an unwritten extent this limit is\n\t * EXT_UNWRITTEN_MAX_LEN.\n\t *\/\n\tif (map->m_len > EXT_INIT_MAX_LEN &&\n\t    !(flags & EXT4_GET_BLOCKS_UNWRIT_EXT))\n\t\tmap->m_len = EXT_INIT_MAX_LEN;\n\telse if (map->m_len > EXT_UNWRITTEN_MAX_LEN &&\n\t\t (flags & EXT4_GET_BLOCKS_UNWRIT_EXT))\n\t\tmap->m_len = EXT_UNWRITTEN_MAX_LEN;\n\n\t\/* Check if we can really insert (m_lblk)::(m_lblk + m_len) extent *\/\n\tnewex.ee_len = cpu_to_le16(map->m_len);\n\terr = ext4_ext_check_overlap(sbi, inode, &newex, path);\n\tif (err)\n\t\tallocated = ext4_ext_get_actual_len(&newex);\n\telse\n\t\tallocated = map->m_len;\n\n\t\/* allocate new block *\/\n\tar.inode = inode;\n\tar.goal = ext4_ext_find_goal(inode, path, map->m_lblk);\n\tar.logical = map->m_lblk;\n\t\/*\n\t * We calculate the offset from the beginning of the cluster\n\t * for the logical block number, since when we allocate a\n\t * physical cluster, the physical block should start at the\n\t * same offset from the beginning of the cluster.  This is\n\t * needed so that future calls to get_implied_cluster_alloc()\n\t * work correctly.\n\t *\/\n\toffset = EXT4_LBLK_COFF(sbi, map->m_lblk);\n\tar.len = EXT4_NUM_B2C(sbi, offset+allocated);\n\tar.goal -= offset;\n\tar.logical -= offset;\n\tif (S_ISREG(inode->i_mode))\n\t\tar.flags = EXT4_MB_HINT_DATA;\n\telse\n\t\t\/* disable in-core preallocation for non-regular files *\/\n\t\tar.flags = 0;\n\tif (flags & EXT4_GET_BLOCKS_NO_NORMALIZE)\n\t\tar.flags |= EXT4_MB_HINT_NOPREALLOC;\n\tif (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)\n\t\tar.flags |= EXT4_MB_DELALLOC_RESERVED;\n\tnewblock = ext4_mb_new_blocks(handle, &ar, &err);\n\tif (!newblock)\n\t\tgoto out2;\n\text_debug(\"allocate new block: goal %llu, found %llu\/%u\\n\",\n\t\t  ar.goal, newblock, allocated);\n\tfree_on_err = 1;\n\tallocated_clusters = ar.len;\n\tar.len = EXT4_C2B(sbi, ar.len) - offset;\n\tif (ar.len > allocated)\n\t\tar.len = allocated;\n\ngot_allocated_blocks:\n\t\/* try to insert new extent into found leaf and return *\/\n\text4_ext_store_pblock(&newex, newblock + offset);\n\tnewex.ee_len = cpu_to_le16(ar.len);\n\t\/* Mark unwritten *\/\n\tif (flags & EXT4_GET_BLOCKS_UNWRIT_EXT){\n\t\text4_ext_mark_unwritten(&newex);\n\t\tmap->m_flags |= EXT4_MAP_UNWRITTEN;\n\t\t\/*\n\t\t * io_end structure was created for every IO write to an\n\t\t * unwritten extent. To avoid unnecessary conversion,\n\t\t * here we flag the IO that really needs the conversion.\n\t\t * For non asycn direct IO case, flag the inode state\n\t\t * that we need to perform conversion when IO is done.\n\t\t *\/\n\t\tif (flags & EXT4_GET_BLOCKS_PRE_IO)\n\t\t\tset_unwritten = 1;\n\t}\n\n\terr = 0;\n\tif ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0)\n\t\terr = check_eofblocks_fl(handle, inode, map->m_lblk,\n\t\t\t\t\t path, ar.len);\n\tif (!err)\n\t\terr = ext4_ext_insert_extent(handle, inode, &path,\n\t\t\t\t\t     &newex, flags);\n\n\tif (!err && set_unwritten) {\n\t\tif (io)\n\t\t\text4_set_io_unwritten_flag(inode, io);\n\t\telse\n\t\t\text4_set_inode_state(inode,\n\t\t\t\t\t     EXT4_STATE_DIO_UNWRITTEN);\n\t}\n\n\tif (err && free_on_err) {\n\t\tint fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?\n\t\t\tEXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;\n\t\t\/* free data blocks we just allocated *\/\n\t\t\/* not a good idea to call discard here directly,\n\t\t * but otherwise we'd need to call it every free() *\/\n\t\text4_discard_preallocations(inode);\n\t\text4_free_blocks(handle, inode, NULL, newblock,\n\t\t\t\t EXT4_C2B(sbi, allocated_clusters), fb_flags);\n\t\tgoto out2;\n\t}\n\n\t\/* previous routine could use block we allocated *\/\n\tnewblock = ext4_ext_pblock(&newex);\n\tallocated = ext4_ext_get_actual_len(&newex);\n\tif (allocated > map->m_len)\n\t\tallocated = map->m_len;\n\tmap->m_flags |= EXT4_MAP_NEW;\n\n\t\/*\n\t * Update reserved blocks\/metadata blocks after successful\n\t * block allocation which had been deferred till now.\n\t *\/\n\tif (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) {\n\t\tunsigned int reserved_clusters;\n\t\t\/*\n\t\t * Check how many clusters we had reserved this allocated range\n\t\t *\/\n\t\treserved_clusters = get_reserved_cluster_alloc(inode,\n\t\t\t\t\t\tmap->m_lblk, allocated);\n\t\tif (map_from_cluster) {\n\t\t\tif (reserved_clusters) {\n\t\t\t\t\/*\n\t\t\t\t * We have clusters reserved for this range.\n\t\t\t\t * But since we are not doing actual allocation\n\t\t\t\t * and are simply using blocks from previously\n\t\t\t\t * allocated cluster, we should release the\n\t\t\t\t * reservation and not claim quota.\n\t\t\t\t *\/\n\t\t\t\text4_da_update_reserve_space(inode,\n\t\t\t\t\t\treserved_clusters, 0);\n\t\t\t}\n\t\t} else {\n\t\t\tBUG_ON(allocated_clusters < reserved_clusters);\n\t\t\tif (reserved_clusters < allocated_clusters) {\n\t\t\t\tstruct ext4_inode_info *ei = EXT4_I(inode);\n\t\t\t\tint reservation = allocated_clusters -\n\t\t\t\t\t\t  reserved_clusters;\n\t\t\t\t\/*\n\t\t\t\t * It seems we claimed few clusters outside of\n\t\t\t\t * the range of this allocation. We should give\n\t\t\t\t * it back to the reservation pool. This can\n\t\t\t\t * happen in the following case:\n\t\t\t\t *\n\t\t\t\t * * Suppose s_cluster_ratio is 4 (i.e., each\n\t\t\t\t *   cluster has 4 blocks. Thus, the clusters\n\t\t\t\t *   are [0-3],[4-7],[8-11]...\n\t\t\t\t * * First comes delayed allocation write for\n\t\t\t\t *   logical blocks 10 & 11. Since there were no\n\t\t\t\t *   previous delayed allocated blocks in the\n\t\t\t\t *   range [8-11], we would reserve 1 cluster\n\t\t\t\t *   for this write.\n\t\t\t\t * * Next comes write for logical blocks 3 to 8.\n\t\t\t\t *   In this case, we will reserve 2 clusters\n\t\t\t\t *   (for [0-3] and [4-7]; and not for [8-11] as\n\t\t\t\t *   that range has a delayed allocated blocks.\n\t\t\t\t *   Thus total reserved clusters now becomes 3.\n\t\t\t\t * * Now, during the delayed allocation writeout\n\t\t\t\t *   time, we will first write blocks [3-8] and\n\t\t\t\t *   allocate 3 clusters for writing these\n\t\t\t\t *   blocks. Also, we would claim all these\n\t\t\t\t *   three clusters above.\n\t\t\t\t * * Now when we come here to writeout the\n\t\t\t\t *   blocks [10-11], we would expect to claim\n\t\t\t\t *   the reservation of 1 cluster we had made\n\t\t\t\t *   (and we would claim it since there are no\n\t\t\t\t *   more delayed allocated blocks in the range\n\t\t\t\t *   [8-11]. But our reserved cluster count had\n\t\t\t\t *   already gone to 0.\n\t\t\t\t *\n\t\t\t\t *   Thus, at the step 4 above when we determine\n\t\t\t\t *   that there are still some unwritten delayed\n\t\t\t\t *   allocated blocks outside of our current\n\t\t\t\t *   block range, we should increment the\n\t\t\t\t *   reserved clusters count so that when the\n\t\t\t\t *   remaining blocks finally gets written, we\n\t\t\t\t *   could claim them.\n\t\t\t\t *\/\n\t\t\t\tdquot_reserve_block(inode,\n\t\t\t\t\t\tEXT4_C2B(sbi, reservation));\n\t\t\t\tspin_lock(&ei->i_block_reservation_lock);\n\t\t\t\tei->i_reserved_data_blocks += reservation;\n\t\t\t\tspin_unlock(&ei->i_block_reservation_lock);\n\t\t\t}\n\t\t\t\/*\n\t\t\t * We will claim quota for all newly allocated blocks.\n\t\t\t * We're updating the reserved space *after* the\n\t\t\t * correction above so we do not accidentally free\n\t\t\t * all the metadata reservation because we might\n\t\t\t * actually need it later on.\n\t\t\t *\/\n\t\t\text4_da_update_reserve_space(inode, allocated_clusters,\n\t\t\t\t\t\t\t1);\n\t\t}\n\t}\n\n\t\/*\n\t * Cache the extent and update transaction to commit on fdatasync only\n\t * when it is _not_ an unwritten extent.\n\t *\/\n\tif ((flags & EXT4_GET_BLOCKS_UNWRIT_EXT) == 0)\n\t\text4_update_inode_fsync_trans(handle, inode, 1);\n\telse\n\t\text4_update_inode_fsync_trans(handle, inode, 0);\nout:\n\tif (allocated > map->m_len)\n\t\tallocated = map->m_len;\n\text4_ext_show_leaf(inode, path);\n\tmap->m_flags |= EXT4_MAP_MAPPED;\n\tmap->m_pblk = newblock;\n\tmap->m_len = allocated;\nout2:\n\text4_ext_drop_refs(path);\n\tkfree(path);\n\n\ttrace_ext4_ext_map_blocks_exit(inode, flags, map,\n\t\t\t\t       err ? err : allocated);\n\treturn err ? err : allocated;\n}","target":0,"code_token_length":3294,"total_token_length":3530,"max_tokens_setting":4096}
+{"idx":440414,"func":"PHP_METHOD(Phar, webPhar)\n{\n\tzval *mimeoverride = NULL, *rewrite = NULL;\n\tchar *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL;\n\tsize_t alias_len = 0, f404_len = 0, free_pathinfo = 0;\n\tint  ru_len = 0;\n\tchar *fname, *path_info, *mime_type = NULL, *entry, *pt;\n\tconst char *basename;\n\tsize_t fname_len, index_php_len = 0;\n\tint entry_len, code, not_cgi;\n\tphar_archive_data *phar = NULL;\n\tphar_entry_info *info = NULL;\n\tsize_t sapi_mod_name_len = strlen(sapi_module.name);\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"|s!s!saz\", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) {\n\t\treturn;\n\t}\n\n\tphar_request_initialize();\n\tfname = (char*)zend_get_executed_filename();\n\tfname_len = strlen(fname);\n\n\tif (ZEND_SIZE_T_INT_OVFL(alias_len)\n\t\t\t|| ZEND_SIZE_T_INT_OVFL(f404_len) || ZEND_SIZE_T_INT_OVFL(index_php_len)) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (phar_open_executed_filename(alias, (int)alias_len, &error) != SUCCESS) {\n\t\tif (error) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"%s\", error);\n\t\t\tefree(error);\n\t\t}\n\t\treturn;\n\t}\n\n\t\/* retrieve requested file within phar *\/\n\tif (!(SG(request_info).request_method\n          && SG(request_info).request_uri\n          && (!strcmp(SG(request_info).request_method, \"GET\")\n           || !strcmp(SG(request_info).request_method, \"POST\")\n           || !strcmp(SG(request_info).request_method, \"DELETE\")\n           || !strcmp(SG(request_info).request_method, \"HEAD\")\n           || !strcmp(SG(request_info).request_method, \"OPTIONS\")\n           || !strcmp(SG(request_info).request_method, \"PATCH\")\n           || !strcmp(SG(request_info).request_method, \"PUT\")\n          )\n         )\n      ) {\n\t\treturn;\n\t}\n\n#ifdef PHP_WIN32\n\tfname = estrndup(fname, fname_len);\n\tphar_unixify_path_separators(fname, fname_len);\n#endif\n\tbasename = zend_memrchr(fname, '\/', fname_len);\n\n\tif (!basename) {\n\t\tbasename = fname;\n\t} else {\n\t\t++basename;\n\t}\n\n\tif ((sapi_mod_name_len == sizeof(\"cgi-fcgi\") - 1 && !strncmp(sapi_module.name, \"cgi-fcgi\", sizeof(\"cgi-fcgi\") - 1))\n\t\t|| (sapi_mod_name_len == sizeof(\"fpm-fcgi\") - 1 && !strncmp(sapi_module.name, \"fpm-fcgi\", sizeof(\"fpm-fcgi\") - 1))\n\t\t|| (sapi_mod_name_len == sizeof(\"cgi\") - 1 && !strncmp(sapi_module.name, \"cgi\", sizeof(\"cgi\") - 1))) {\n\n\t\tif (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) {\n\t\t\tHashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);\n\t\t\tzval *z_script_name, *z_path_info;\n\n\t\t\tif (NULL == (z_script_name = zend_hash_str_find(_server, \"SCRIPT_NAME\", sizeof(\"SCRIPT_NAME\")-1)) ||\n\t\t\t\tIS_STRING != Z_TYPE_P(z_script_name) ||\n\t\t\t\t!strstr(Z_STRVAL_P(z_script_name), basename)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (NULL != (z_path_info = zend_hash_str_find(_server, \"PATH_INFO\", sizeof(\"PATH_INFO\")-1)) &&\n\t\t\t\tIS_STRING == Z_TYPE_P(z_path_info)) {\n\t\t\t\tentry_len = (int)Z_STRLEN_P(z_path_info);\n\t\t\t\tentry = estrndup(Z_STRVAL_P(z_path_info), entry_len);\n\t\t\t\tpath_info = emalloc(Z_STRLEN_P(z_script_name) + entry_len + 1);\n\t\t\t\tmemcpy(path_info, Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name));\n\t\t\t\tmemcpy(path_info + Z_STRLEN_P(z_script_name), entry, entry_len + 1);\n\t\t\t\tfree_pathinfo = 1;\n\t\t\t} else {\n\t\t\t\tentry_len = 0;\n\t\t\t\tentry = estrndup(\"\", 0);\n\t\t\t\tpath_info = Z_STRVAL_P(z_script_name);\n\t\t\t}\n\n\t\t\tpt = estrndup(Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name));\n\n\t\t} else {\n\t\t\tchar *testit;\n\n\t\t\ttestit = sapi_getenv(\"SCRIPT_NAME\", sizeof(\"SCRIPT_NAME\")-1);\n\t\t\tif (!(pt = strstr(testit, basename))) {\n\t\t\t\tefree(testit);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tpath_info = sapi_getenv(\"PATH_INFO\", sizeof(\"PATH_INFO\")-1);\n\n\t\t\tif (path_info) {\n\t\t\t\tentry = path_info;\n\t\t\t\tentry_len = (int)strlen(entry);\n\t\t\t\tspprintf(&path_info, 0, \"%s%s\", testit, path_info);\n\t\t\t\tfree_pathinfo = 1;\n\t\t\t} else {\n\t\t\t\tpath_info = testit;\n\t\t\t\tfree_pathinfo = 1;\n\t\t\t\tentry = estrndup(\"\", 0);\n\t\t\t\tentry_len = 0;\n\t\t\t}\n\n\t\t\tpt = estrndup(testit, (pt - testit) + (fname_len - (basename - fname)));\n\t\t}\n\t\tnot_cgi = 0;\n\t} else {\n\t\tpath_info = SG(request_info).request_uri;\n\n\t\tif (!(pt = strstr(path_info, basename))) {\n\t\t\t\/* this can happen with rewrite rules - and we have no idea what to do then, so return *\/\n\t\t\treturn;\n\t\t}\n\n\t\tentry_len = (int)strlen(path_info);\n\t\tentry_len -= (pt - path_info) + (fname_len - (basename - fname));\n\t\tentry = estrndup(pt + (fname_len - (basename - fname)), entry_len);\n\n\t\tpt = estrndup(path_info, (pt - path_info) + (fname_len - (basename - fname)));\n\t\tnot_cgi = 1;\n\t}\n\n\tif (rewrite) {\n\t\tzend_fcall_info fci;\n\t\tzend_fcall_info_cache fcc;\n\t\tzval params, retval;\n\n\t\tZVAL_STRINGL(¶ms, entry, entry_len);\n\n\t\tif (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar error: invalid rewrite callback\");\n\n\t\t\tif (free_pathinfo) {\n\t\t\t\tefree(path_info);\n\t\t\t}\n\t\t\tefree(pt);\n\n\t\t\treturn;\n\t\t}\n\n\t\tfci.param_count = 1;\n\t\tfci.params = ¶ms;\n\t\tZ_ADDREF(params);\n\t\tfci.retval = &retval;\n\n\t\tif (FAILURE == zend_call_function(&fci, &fcc)) {\n\t\t\tif (!EG(exception)) {\n\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar error: failed to call rewrite callback\");\n\t\t\t}\n\n\t\t\tif (free_pathinfo) {\n\t\t\t\tefree(path_info);\n\t\t\t}\n\t\t\tefree(pt);\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) {\n\t\t\tif (free_pathinfo) {\n\t\t\t\tefree(path_info);\n\t\t\t}\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar error: rewrite callback must return a string or false\");\n\t\t\tefree(pt);\n\t\t\treturn;\n\t\t}\n\n\t\tswitch (Z_TYPE(retval)) {\n\t\t\tcase IS_STRING:\n\t\t\t\tefree(entry);\n\t\t\t\tif (ZEND_SIZE_T_INT_OVFL(Z_STRLEN_P(fci.retval))) {\n\t\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar error: rewrite callback returned oversized value\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tentry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval));\n\t\t\t\tentry_len = (int)Z_STRLEN_P(fci.retval);\n\t\t\t\tbreak;\n\t\t\tcase IS_TRUE:\n\t\t\tcase IS_FALSE:\n\t\t\t\tphar_do_403(entry, entry_len);\n\n\t\t\t\tif (free_pathinfo) {\n\t\t\t\t\tefree(path_info);\n\t\t\t\t}\n\t\t\t\tefree(pt);\n\n\t\t\t\tzend_bailout();\n\t\t\t\treturn;\n\t\t\tdefault:\n\t\t\t\tif (free_pathinfo) {\n\t\t\t\t\tefree(path_info);\n\t\t\t\t}\n\t\t\t\tefree(pt);\n\n\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar error: rewrite callback must return a string or false\");\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tif (entry_len) {\n\t\tphar_postprocess_ru_web(fname, (int)fname_len, &entry, &entry_len, &ru, &ru_len);\n\t}\n\n\tif (!entry_len || (entry_len == 1 && entry[0] == '\/')) {\n\t\tefree(entry);\n\t\t\/* direct request *\/\n\t\tif (index_php_len) {\n\t\t\tentry = index_php;\n\t\t\tentry_len = (int)index_php_len;\n\t\t\tif (entry[0] != '\/') {\n\t\t\t\tspprintf(&entry, 0, \"\/%s\", index_php);\n\t\t\t\t++entry_len;\n\t\t\t}\n\t\t} else {\n\t\t\t\/* assume \"index.php\" is starting point *\/\n\t\t\tentry = estrndup(\"\/index.php\", sizeof(\"\/index.php\"));\n\t\t\tentry_len = sizeof(\"\/index.php\")-1;\n\t\t}\n\n\t\tif (FAILURE == phar_get_archive(&phar, fname, (int)fname_len, NULL, 0, NULL) ||\n\t\t\t(info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) {\n\t\t\tphar_do_404(phar, fname, (int)fname_len, f404, (int)f404_len, entry, entry_len);\n\n\t\t\tif (free_pathinfo) {\n\t\t\t\tefree(path_info);\n\t\t\t}\n\n\t\t\tzend_bailout();\n\t\t} else {\n\t\t\tchar *tmp = NULL, sa = '\\0';\n\t\t\tsapi_header_line ctr = {0};\n\t\t\tctr.response_code = 301;\n\t\t\tctr.line_len = sizeof(\"HTTP\/1.1 301 Moved Permanently\")-1;\n\t\t\tctr.line = \"HTTP\/1.1 301 Moved Permanently\";\n\t\t\tsapi_header_op(SAPI_HEADER_REPLACE, &ctr);\n\n\t\t\tif (not_cgi) {\n\t\t\t\ttmp = strstr(path_info, basename) + fname_len;\n\t\t\t\tsa = *tmp;\n\t\t\t\t*tmp = '\\0';\n\t\t\t}\n\n\t\t\tctr.response_code = 0;\n\n\t\t\tif (path_info[strlen(path_info)-1] == '\/') {\n\t\t\t\tctr.line_len = spprintf(&(ctr.line), 4096, \"Location: %s%s\", path_info, entry + 1);\n\t\t\t} else {\n\t\t\t\tctr.line_len = spprintf(&(ctr.line), 4096, \"Location: %s%s\", path_info, entry);\n\t\t\t}\n\n\t\t\tif (not_cgi) {\n\t\t\t\t*tmp = sa;\n\t\t\t}\n\n\t\t\tif (free_pathinfo) {\n\t\t\t\tefree(path_info);\n\t\t\t}\n\n\t\t\tsapi_header_op(SAPI_HEADER_REPLACE, &ctr);\n\t\t\tsapi_send_headers();\n\t\t\tefree(ctr.line);\n\t\t\tzend_bailout();\n\t\t}\n\t}\n\n\tif (FAILURE == phar_get_archive(&phar, fname, (int)fname_len, NULL, 0, NULL) ||\n\t\t(info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) {\n\t\tphar_do_404(phar, fname, (int)fname_len, f404, (int)f404_len, entry, entry_len);\n#ifdef PHP_WIN32\n\t\tefree(fname);\n#endif\n\t\tzend_bailout();\n\t}\n\n\tif (mimeoverride && zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) {\n\t\tconst char *ext = zend_memrchr(entry, '.', entry_len);\n\t\tzval *val;\n\n\t\tif (ext) {\n\t\t\t++ext;\n\n\t\t\tif (NULL != (val = zend_hash_str_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)))) {\n\t\t\t\tswitch (Z_TYPE_P(val)) {\n\t\t\t\t\tcase IS_LONG:\n\t\t\t\t\t\tif (Z_LVAL_P(val) == PHAR_MIME_PHP || Z_LVAL_P(val) == PHAR_MIME_PHPS) {\n\t\t\t\t\t\t\tmime_type = \"\";\n\t\t\t\t\t\t\tcode = (int)Z_LVAL_P(val);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed\");\n\t\t\t\t\t\t\tif (free_pathinfo) {\n\t\t\t\t\t\t\t\tefree(path_info);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tefree(pt);\n\t\t\t\t\t\t\tefree(entry);\n#ifdef PHP_WIN32\n\t\t\t\t\t\t\tefree(fname);\n#endif\n\t\t\t\t\t\t\tRETURN_FALSE;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase IS_STRING:\n\t\t\t\t\t\tmime_type = Z_STRVAL_P(val);\n\t\t\t\t\t\tcode = PHAR_MIME_OTHER;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed\");\n\t\t\t\t\t\tif (free_pathinfo) {\n\t\t\t\t\t\t\tefree(path_info);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tefree(pt);\n\t\t\t\t\t\tefree(entry);\n#ifdef PHP_WIN32\n\t\t\t\t\t\tefree(fname);\n#endif\n\t\t\t\t\t\tRETURN_FALSE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!mime_type) {\n\t\tcode = phar_file_type(&PHAR_G(mime_types), entry, &mime_type);\n\t}\n\tphar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len);\n}","target":0,"code_token_length":3079,"total_token_length":3315,"max_tokens_setting":4096}
+{"idx":80284,"func":"  void operator()(OpKernelContext* context, const Tensor& x,\n                  const Tensor& scale, const Tensor& offset,\n                  const Tensor& estimated_mean,\n                  const Tensor& estimated_variance, const Tensor* side_input,\n                  U epsilon, U exponential_avg_factor,\n                  FusedBatchNormActivationMode activation_mode, Tensor* y,\n                  Tensor* batch_mean, Tensor* batch_var, Tensor* saved_mean,\n                  Tensor* saved_inv_var, TensorFormat tensor_format,\n                  bool use_reserved_space) {\n    auto* stream = context->op_device_context()->stream();\n    OP_REQUIRES(context, stream, errors::Internal(\"No GPU stream available\"));\n\n    const int64_t batch_size = GetTensorDim(x, tensor_format, 'N');\n    const int64_t channels = GetTensorDim(x, tensor_format, 'C');\n    const int64_t height = GetTensorDim(x, tensor_format, 'H');\n    const int64_t width = GetTensorDim(x, tensor_format, 'W');\n\n    \/\/ If use_reserved_space we have reserve_space_3 output (only in\n    \/\/ FusedBatchNormV3 op).\n\n#if GOOGLE_CUDA\n    \/\/ Check if cuDNN batch normalization has a fast NHWC implementation:\n    \/\/   (1) In inference mode it's always fast.\n    \/\/   (2) Tensorflow enabled batchnorm spatial persistence, we are called\n    \/\/   from\n    \/\/       FusedBatchNormV3, i.e. use_reserved_space is true.\n    const bool fast_nhwc_batch_norm =\n        !is_training ||\n        (BatchnormSpatialPersistentEnabled() &&\n         DataTypeToEnum::value == DT_HALF && use_reserved_space);\n#else\n    \/\/ fast NHWC implementation is a CUDA only feature\n    const bool fast_nhwc_batch_norm = false;\n#endif\n\n    \/\/ If input tensor is in NHWC format, and we have a fast cuDNN\n    \/\/ implementation, there is no need to do data format conversion.\n    TensorFormat compute_format =\n        fast_nhwc_batch_norm && tensor_format == FORMAT_NHWC ? FORMAT_NHWC\n                                                             : FORMAT_NCHW;\n\n    VLOG(2) << \"FusedBatchNorm:\"\n            << \" batch_size: \" << batch_size << \" channels: \" << channels\n            << \" height: \" << height << \" width:\" << width\n            << \" x shape: \" << x.shape().DebugString()\n            << \" scale shape: \" << scale.shape().DebugString()\n            << \" offset shape: \" << offset.shape().DebugString()\n            << \" activation mode: \" << ToString(activation_mode)\n            << \" tensor format: \" << ToString(tensor_format)\n            << \" compute format: \" << ToString(compute_format);\n\n    auto maybe_make_dummy_output = [context, use_reserved_space]() -> Status {\n      if (use_reserved_space) {\n        Tensor* dummy_reserve_space = nullptr;\n        return context->allocate_output(5, {}, &dummy_reserve_space);\n      }\n      return Status::OK();\n    };\n\n    \/\/ If input is empty, return NaN mean\/variance\n    if (x.shape().num_elements() == 0) {\n      OP_REQUIRES_OK(context, maybe_make_dummy_output());\n      functor::SetNanFunctor f;\n      f(context->eigen_device(), batch_mean->flat());\n      f(context->eigen_device(), batch_var->flat());\n      return;\n    }\n\n    \/\/ In inference mode we use custom CUDA kernel, because cuDNN does not\n    \/\/ support side input and activations for inference.\n    const bool has_side_input = side_input != nullptr;\n    const bool has_activation =\n        activation_mode != FusedBatchNormActivationMode::kIdentity;\n\n    if (!is_training && (has_side_input || has_activation)) {\n      OP_REQUIRES_OK(context, maybe_make_dummy_output());\n      FusedBatchNormInferenceFunctor inference_functor;\n\n      if (has_side_input) {\n        inference_functor(context, tensor_format, x.tensor(),\n                          scale.vec(), offset.vec(),\n                          estimated_mean.vec(), estimated_variance.vec(),\n                          side_input->tensor(), epsilon, activation_mode,\n                          y->tensor());\n      } else {\n        typename TTypes::ConstTensor empty_tensor(nullptr, 0, 0, 0, 0);\n        inference_functor(context, tensor_format, x.tensor(),\n                          scale.vec(), offset.vec(),\n                          estimated_mean.vec(), estimated_variance.vec(),\n                          empty_tensor, epsilon, activation_mode,\n                          y->tensor());\n      }\n      return;\n    }\n\n    Tensor x_maybe_transformed = x;\n    Tensor x_transformed;\n    Tensor y_transformed;\n    se::DeviceMemory y_ptr;\n\n    if (tensor_format == compute_format) {\n      y_ptr = StreamExecutorUtil::AsDeviceMemory(*y);\n    } else if (tensor_format == FORMAT_NHWC && compute_format == FORMAT_NCHW) {\n      OP_REQUIRES_OK(context, context->allocate_temp(\n                                  DataTypeToEnum::value,\n                                  ShapeFromFormat(compute_format, batch_size,\n                                                  height, width, channels),\n                                  &x_transformed));\n      functor::NHWCToNCHW()(\n          context->eigen_device(),\n          const_cast(x_maybe_transformed).tensor(),\n          x_transformed.tensor());\n      x_maybe_transformed = x_transformed;\n\n      OP_REQUIRES_OK(context, context->allocate_temp(\n                                  DataTypeToEnum::value,\n                                  ShapeFromFormat(compute_format, batch_size,\n                                                  height, width, channels),\n                                  &y_transformed));\n      y_ptr = StreamExecutorUtil::AsDeviceMemory(y_transformed);\n    } else {\n      context->SetStatus(errors::Internal(\n          \"Unsupported tensor format: \", ToString(tensor_format),\n          \" and compute format: \", ToString(compute_format)));\n      return;\n    }\n\n    const se::dnn::DataLayout data_layout =\n        compute_format == FORMAT_NHWC ? se::dnn::DataLayout::kBatchYXDepth\n                                      : se::dnn::DataLayout::kBatchDepthYX;\n\n    se::dnn::BatchDescriptor x_desc;\n    x_desc.set_count(batch_size)\n        .set_feature_map_count(channels)\n        .set_height(height)\n        .set_width(width)\n        .set_layout(data_layout);\n\n    se::dnn::BatchDescriptor scale_offset_desc;\n    scale_offset_desc.set_count(1)\n        .set_feature_map_count(channels)\n        .set_height(1)\n        .set_width(1)\n        .set_layout(se::dnn::DataLayout::kBatchDepthYX);\n\n    auto x_ptr = StreamExecutorUtil::AsDeviceMemory(x_maybe_transformed);\n    auto scale_ptr = StreamExecutorUtil::AsDeviceMemory(scale);\n    auto offset_ptr = StreamExecutorUtil::AsDeviceMemory(offset);\n    auto estimated_mean_ptr =\n        StreamExecutorUtil::AsDeviceMemory(estimated_mean);\n    auto estimated_variance_ptr =\n        StreamExecutorUtil::AsDeviceMemory(estimated_variance);\n    auto side_input_ptr =\n        side_input != nullptr\n            ? StreamExecutorUtil::AsDeviceMemory(*side_input)\n            : se::DeviceMemory();\n    auto batch_mean_ptr = StreamExecutorUtil::AsDeviceMemory(*batch_mean);\n\n    auto batch_var_ptr = StreamExecutorUtil::AsDeviceMemory(*batch_var);\n    auto saved_mean_ptr = StreamExecutorUtil::AsDeviceMemory(*saved_mean);\n    auto saved_inv_var_ptr =\n        StreamExecutorUtil::AsDeviceMemory(*saved_inv_var);\n\n    std::unique_ptr>\n        reserve_space_allocator;\n    std::unique_ptr>\n        workspace_allocator;\n    if (use_reserved_space) {\n      reserve_space_allocator.reset(\n          new functor::CudnnBatchNormAllocatorInOutput(context, 5));\n      workspace_allocator.reset(\n          new functor::CudnnBatchNormAllocatorInTemp(context));\n    }\n    if (!batch_mean->SharesBufferWith(estimated_mean) &&\n        exponential_avg_factor != 1.0f) {\n      OP_REQUIRES(\n          context,\n          stream\n              ->ThenMemcpyD2D(&batch_mean_ptr, estimated_mean_ptr,\n                              estimated_mean.NumElements() * sizeof(U))\n              .ok(),\n          errors::Internal(\"MatrixTriangularSolveOp: failed to copy rhs \"\n                           \"from device\"));\n    }\n    if (!batch_var->SharesBufferWith(estimated_variance) &&\n        exponential_avg_factor != 1.0f) {\n      OP_REQUIRES(\n          context,\n          stream\n              ->ThenMemcpyD2D(&batch_var_ptr, estimated_variance_ptr,\n                              estimated_variance.NumElements() * sizeof(U))\n              .ok(),\n          errors::Internal(\"MatrixTriangularSolveOp: failed to copy rhs \"\n                           \"from device\"));\n    }\n    bool cudnn_launch_status =\n        stream\n            ->ThenBatchNormalizationForward(\n                x_ptr, scale_ptr, offset_ptr, estimated_mean_ptr,\n                estimated_variance_ptr, side_input_ptr, x_desc,\n                scale_offset_desc, static_cast(epsilon),\n                static_cast(exponential_avg_factor),\n                AsDnnActivationMode(activation_mode), &y_ptr, &batch_mean_ptr,\n                &batch_var_ptr, &saved_mean_ptr, &saved_inv_var_ptr,\n                is_training, reserve_space_allocator.get(),\n                workspace_allocator.get())\n            .ok();\n\n    if (!cudnn_launch_status) {\n      context->SetStatus(\n          errors::Internal(\"cuDNN launch failure : input shape (\",\n                           x.shape().DebugString(), \")\"));\n      return;\n    }\n\n    if (tensor_format == FORMAT_NHWC && compute_format == FORMAT_NCHW) {\n      functor::NCHWToNHWC()(\n          context->eigen_device(),\n          const_cast(y_transformed).tensor(),\n          y->tensor());\n    }\n  }","target":0,"code_token_length":2176,"total_token_length":2412,"max_tokens_setting":4096}
+{"idx":506453,"func":"const char *SSL_state_string(const SSL *s)\n\t{\n\tconst char *str;\n\n\tswitch (s->state)\n\t\t{\ncase SSL_ST_BEFORE:\t\t\t\tstr=\"PINIT \"; break;\ncase SSL_ST_ACCEPT:\t\t\t\tstr=\"AINIT \"; break;\ncase SSL_ST_CONNECT:\t\t\t\tstr=\"CINIT \"; break;\ncase SSL_ST_OK:\t\t\t \t\tstr=\"SSLOK \"; break;\n#ifndef OPENSSL_NO_SSL2\ncase SSL2_ST_CLIENT_START_ENCRYPTION:\t\tstr=\"2CSENC\"; break;\ncase SSL2_ST_SERVER_START_ENCRYPTION:\t\tstr=\"2SSENC\"; break;\ncase SSL2_ST_SEND_CLIENT_HELLO_A:\t\tstr=\"2SCH_A\"; break;\ncase SSL2_ST_SEND_CLIENT_HELLO_B:\t\tstr=\"2SCH_B\"; break;\ncase SSL2_ST_GET_SERVER_HELLO_A:\t\tstr=\"2GSH_A\"; break;\ncase SSL2_ST_GET_SERVER_HELLO_B:\t\tstr=\"2GSH_B\"; break;\ncase SSL2_ST_SEND_CLIENT_MASTER_KEY_A:\t\tstr=\"2SCMKA\"; break;\ncase SSL2_ST_SEND_CLIENT_MASTER_KEY_B:\t\tstr=\"2SCMKB\"; break;\ncase SSL2_ST_SEND_CLIENT_FINISHED_A:\t\tstr=\"2SCF_A\"; break;\ncase SSL2_ST_SEND_CLIENT_FINISHED_B:\t\tstr=\"2SCF_B\"; break;\ncase SSL2_ST_SEND_CLIENT_CERTIFICATE_A:\t\tstr=\"2SCC_A\"; break;\ncase SSL2_ST_SEND_CLIENT_CERTIFICATE_B:\t\tstr=\"2SCC_B\"; break;\ncase SSL2_ST_SEND_CLIENT_CERTIFICATE_C:\t\tstr=\"2SCC_C\"; break;\ncase SSL2_ST_SEND_CLIENT_CERTIFICATE_D:\t\tstr=\"2SCC_D\"; break;\ncase SSL2_ST_GET_SERVER_VERIFY_A:\t\tstr=\"2GSV_A\"; break;\ncase SSL2_ST_GET_SERVER_VERIFY_B:\t\tstr=\"2GSV_B\"; break;\ncase SSL2_ST_GET_SERVER_FINISHED_A:\t\tstr=\"2GSF_A\"; break;\ncase SSL2_ST_GET_SERVER_FINISHED_B:\t\tstr=\"2GSF_B\"; break;\ncase SSL2_ST_GET_CLIENT_HELLO_A:\t\tstr=\"2GCH_A\"; break;\ncase SSL2_ST_GET_CLIENT_HELLO_B:\t\tstr=\"2GCH_B\"; break;\ncase SSL2_ST_GET_CLIENT_HELLO_C:\t\tstr=\"2GCH_C\"; break;\ncase SSL2_ST_SEND_SERVER_HELLO_A:\t\tstr=\"2SSH_A\"; break;\ncase SSL2_ST_SEND_SERVER_HELLO_B:\t\tstr=\"2SSH_B\"; break;\ncase SSL2_ST_GET_CLIENT_MASTER_KEY_A:\t\tstr=\"2GCMKA\"; break;\ncase SSL2_ST_GET_CLIENT_MASTER_KEY_B:\t\tstr=\"2GCMKA\"; break;\ncase SSL2_ST_SEND_SERVER_VERIFY_A:\t\tstr=\"2SSV_A\"; break;\ncase SSL2_ST_SEND_SERVER_VERIFY_B:\t\tstr=\"2SSV_B\"; break;\ncase SSL2_ST_SEND_SERVER_VERIFY_C:\t\tstr=\"2SSV_C\"; break;\ncase SSL2_ST_GET_CLIENT_FINISHED_A:\t\tstr=\"2GCF_A\"; break;\ncase SSL2_ST_GET_CLIENT_FINISHED_B:\t\tstr=\"2GCF_B\"; break;\ncase SSL2_ST_SEND_SERVER_FINISHED_A:\t\tstr=\"2SSF_A\"; break;\ncase SSL2_ST_SEND_SERVER_FINISHED_B:\t\tstr=\"2SSF_B\"; break;\ncase SSL2_ST_SEND_REQUEST_CERTIFICATE_A:\tstr=\"2SRC_A\"; break;\ncase SSL2_ST_SEND_REQUEST_CERTIFICATE_B:\tstr=\"2SRC_B\"; break;\ncase SSL2_ST_SEND_REQUEST_CERTIFICATE_C:\tstr=\"2SRC_C\"; break;\ncase SSL2_ST_SEND_REQUEST_CERTIFICATE_D:\tstr=\"2SRC_D\"; break;\ncase SSL2_ST_X509_GET_SERVER_CERTIFICATE:\tstr=\"2X9GSC\"; break;\ncase SSL2_ST_X509_GET_CLIENT_CERTIFICATE:\tstr=\"2X9GCC\"; break;\n#endif\n\n#ifndef OPENSSL_NO_SSL3\n\/* SSLv3 additions *\/\ncase SSL3_ST_SW_FLUSH:\ncase SSL3_ST_CW_FLUSH:\t\t\t\tstr=\"3FLUSH\"; break;\ncase SSL3_ST_CW_CLNT_HELLO_A:\t\t\tstr=\"3WCH_A\"; break;\ncase SSL3_ST_CW_CLNT_HELLO_B:\t\t\tstr=\"3WCH_B\"; break;\ncase SSL3_ST_CR_SRVR_HELLO_A:\t\t\tstr=\"3RSH_A\"; break;\ncase SSL3_ST_CR_SRVR_HELLO_B:\t\t\tstr=\"3RSH_B\"; break;\ncase SSL3_ST_CR_CERT_A:\t\t\t\tstr=\"3RSC_A\"; break;\ncase SSL3_ST_CR_CERT_B:\t\t\t\tstr=\"3RSC_B\"; break;\ncase SSL3_ST_CR_KEY_EXCH_A:\t\t\tstr=\"3RSKEA\"; break;\ncase SSL3_ST_CR_KEY_EXCH_B:\t\t\tstr=\"3RSKEB\"; break;\ncase SSL3_ST_CR_CERT_REQ_A:\t\t\tstr=\"3RCR_A\"; break;\ncase SSL3_ST_CR_CERT_REQ_B:\t\t\tstr=\"3RCR_B\"; break;\ncase SSL3_ST_CR_SRVR_DONE_A:\t\t\tstr=\"3RSD_A\"; break;\ncase SSL3_ST_CR_SRVR_DONE_B:\t\t\tstr=\"3RSD_B\"; break;\ncase SSL3_ST_CW_CERT_A:\t\t\t\tstr=\"3WCC_A\"; break;\ncase SSL3_ST_CW_CERT_B:\t\t\t\tstr=\"3WCC_B\"; break;\ncase SSL3_ST_CW_CERT_C:\t\t\t\tstr=\"3WCC_C\"; break;\ncase SSL3_ST_CW_CERT_D:\t\t\t\tstr=\"3WCC_D\"; break;\ncase SSL3_ST_CW_KEY_EXCH_A:\t\t\tstr=\"3WCKEA\"; break;\ncase SSL3_ST_CW_KEY_EXCH_B:\t\t\tstr=\"3WCKEB\"; break;\ncase SSL3_ST_CW_CERT_VRFY_A:\t\t\tstr=\"3WCV_A\"; break;\ncase SSL3_ST_CW_CERT_VRFY_B:\t\t\tstr=\"3WCV_B\"; break;\n\ncase SSL3_ST_SW_CHANGE_A:\ncase SSL3_ST_CW_CHANGE_A:\t\t\tstr=\"3WCCSA\"; break;\ncase SSL3_ST_SW_CHANGE_B:\ncase SSL3_ST_CW_CHANGE_B:\t\t\tstr=\"3WCCSB\"; break;\ncase SSL3_ST_SW_FINISHED_A:\ncase SSL3_ST_CW_FINISHED_A:\t\t\tstr=\"3WFINA\"; break;\ncase SSL3_ST_SW_FINISHED_B:\ncase SSL3_ST_CW_FINISHED_B:\t\t\tstr=\"3WFINB\"; break;\ncase SSL3_ST_SR_CHANGE_A:\ncase SSL3_ST_CR_CHANGE_A:\t\t\tstr=\"3RCCSA\"; break;\ncase SSL3_ST_SR_CHANGE_B:\ncase SSL3_ST_CR_CHANGE_B:\t\t\tstr=\"3RCCSB\"; break;\ncase SSL3_ST_SR_FINISHED_A:\ncase SSL3_ST_CR_FINISHED_A:\t\t\tstr=\"3RFINA\"; break;\ncase SSL3_ST_SR_FINISHED_B:\ncase SSL3_ST_CR_FINISHED_B:\t\t\tstr=\"3RFINB\"; break;\n\ncase SSL3_ST_SW_HELLO_REQ_A:\t\t\tstr=\"3WHR_A\"; break;\ncase SSL3_ST_SW_HELLO_REQ_B:\t\t\tstr=\"3WHR_B\"; break;\ncase SSL3_ST_SW_HELLO_REQ_C:\t\t\tstr=\"3WHR_C\"; break;\ncase SSL3_ST_SR_CLNT_HELLO_A:\t\t\tstr=\"3RCH_A\"; break;\ncase SSL3_ST_SR_CLNT_HELLO_B:\t\t\tstr=\"3RCH_B\"; break;\ncase SSL3_ST_SR_CLNT_HELLO_C:\t\t\tstr=\"3RCH_C\"; break;\ncase SSL3_ST_SW_SRVR_HELLO_A:\t\t\tstr=\"3WSH_A\"; break;\ncase SSL3_ST_SW_SRVR_HELLO_B:\t\t\tstr=\"3WSH_B\"; break;\ncase SSL3_ST_SW_CERT_A:\t\t\t\tstr=\"3WSC_A\"; break;\ncase SSL3_ST_SW_CERT_B:\t\t\t\tstr=\"3WSC_B\"; break;\ncase SSL3_ST_SW_KEY_EXCH_A:\t\t\tstr=\"3WSKEA\"; break;\ncase SSL3_ST_SW_KEY_EXCH_B:\t\t\tstr=\"3WSKEB\"; break;\ncase SSL3_ST_SW_CERT_REQ_A:\t\t\tstr=\"3WCR_A\"; break;\ncase SSL3_ST_SW_CERT_REQ_B:\t\t\tstr=\"3WCR_B\"; break;\ncase SSL3_ST_SW_SRVR_DONE_A:\t\t\tstr=\"3WSD_A\"; break;\ncase SSL3_ST_SW_SRVR_DONE_B:\t\t\tstr=\"3WSD_B\"; break;\ncase SSL3_ST_SR_CERT_A:\t\t\t\tstr=\"3RCC_A\"; break;\ncase SSL3_ST_SR_CERT_B:\t\t\t\tstr=\"3RCC_B\"; break;\ncase SSL3_ST_SR_KEY_EXCH_A:\t\t\tstr=\"3RCKEA\"; break;\ncase SSL3_ST_SR_KEY_EXCH_B:\t\t\tstr=\"3RCKEB\"; break;\ncase SSL3_ST_SR_CERT_VRFY_A:\t\t\tstr=\"3RCV_A\"; break;\ncase SSL3_ST_SR_CERT_VRFY_B:\t\t\tstr=\"3RCV_B\"; break;\n#endif\n\n#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)\n\/* SSLv2\/v3 compatibility states *\/\n\/* client *\/\ncase SSL23_ST_CW_CLNT_HELLO_A:\t\t\tstr=\"23WCHA\"; break;\ncase SSL23_ST_CW_CLNT_HELLO_B:\t\t\tstr=\"23WCHB\"; break;\ncase SSL23_ST_CR_SRVR_HELLO_A:\t\t\tstr=\"23RSHA\"; break;\ncase SSL23_ST_CR_SRVR_HELLO_B:\t\t\tstr=\"23RSHA\"; break;\n\/* server *\/\ncase SSL23_ST_SR_CLNT_HELLO_A:\t\t\tstr=\"23RCHA\"; break;\ncase SSL23_ST_SR_CLNT_HELLO_B:\t\t\tstr=\"23RCHB\"; break;\n#endif\n\/* DTLS *\/\ncase DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str=\"DRCHVA\"; break;\ncase DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str=\"DRCHVB\"; break;\ncase DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str=\"DWCHVA\"; break;\ncase DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str=\"DWCHVB\"; break;\n\ndefault:\t\t\t\t\tstr=\"UNKWN \"; break;\n\t\t}\n\treturn(str);\n\t}","target":0,"code_token_length":2209,"total_token_length":2445,"max_tokens_setting":4096}
+{"idx":204964,"func":"bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::SubmitDecode(\n    const scoped_refptr& pic,\n    const media::Vp8FrameHeader* frame_hdr,\n    const scoped_refptr& last_frame,\n    const scoped_refptr& golden_frame,\n    const scoped_refptr& alt_frame) {\n  VAIQMatrixBufferVP8 iq_matrix_buf;\n  memset(&iq_matrix_buf, 0, sizeof(VAIQMatrixBufferVP8));\n\n  const media::Vp8SegmentationHeader& sgmnt_hdr = frame_hdr->segmentation_hdr;\n  const media::Vp8QuantizationHeader& quant_hdr = frame_hdr->quantization_hdr;\n  static_assert(\n      arraysize(iq_matrix_buf.quantization_index) == media::kMaxMBSegments,\n      \"incorrect quantization matrix size\");\n  for (size_t i = 0; i < media::kMaxMBSegments; ++i) {\n    int q = quant_hdr.y_ac_qi;\n\n    if (sgmnt_hdr.segmentation_enabled) {\n      if (sgmnt_hdr.segment_feature_mode ==\n          media::Vp8SegmentationHeader::FEATURE_MODE_ABSOLUTE)\n        q = sgmnt_hdr.quantizer_update_value[i];\n      else\n        q += sgmnt_hdr.quantizer_update_value[i];\n    }\n\n#define CLAMP_Q(q) std::min(std::max(q, 0), 127)\n    static_assert(arraysize(iq_matrix_buf.quantization_index[i]) == 6,\n                  \"incorrect quantization matrix size\");\n    iq_matrix_buf.quantization_index[i][0] = CLAMP_Q(q);\n    iq_matrix_buf.quantization_index[i][1] = CLAMP_Q(q + quant_hdr.y_dc_delta);\n    iq_matrix_buf.quantization_index[i][2] = CLAMP_Q(q + quant_hdr.y2_dc_delta);\n    iq_matrix_buf.quantization_index[i][3] = CLAMP_Q(q + quant_hdr.y2_ac_delta);\n    iq_matrix_buf.quantization_index[i][4] = CLAMP_Q(q + quant_hdr.uv_dc_delta);\n    iq_matrix_buf.quantization_index[i][5] = CLAMP_Q(q + quant_hdr.uv_ac_delta);\n#undef CLAMP_Q\n  }\n\n  if (!vaapi_wrapper_->SubmitBuffer(VAIQMatrixBufferType,\n                                    sizeof(VAIQMatrixBufferVP8),\n                                    &iq_matrix_buf))\n    return false;\n\n  VAProbabilityDataBufferVP8 prob_buf;\n  memset(&prob_buf, 0, sizeof(VAProbabilityDataBufferVP8));\n\n  const media::Vp8EntropyHeader& entr_hdr = frame_hdr->entropy_hdr;\n  ARRAY_MEMCPY_CHECKED(prob_buf.dct_coeff_probs, entr_hdr.coeff_probs);\n\n  if (!vaapi_wrapper_->SubmitBuffer(VAProbabilityBufferType,\n                                    sizeof(VAProbabilityDataBufferVP8),\n                                    &prob_buf))\n    return false;\n\n  VAPictureParameterBufferVP8 pic_param;\n  memset(&pic_param, 0, sizeof(VAPictureParameterBufferVP8));\n  pic_param.frame_width = frame_hdr->width;\n  pic_param.frame_height = frame_hdr->height;\n\n  if (last_frame) {\n    scoped_refptr last_frame_surface =\n        VP8PictureToVaapiDecodeSurface(last_frame);\n    pic_param.last_ref_frame = last_frame_surface->va_surface()->id();\n  } else {\n    pic_param.last_ref_frame = VA_INVALID_SURFACE;\n  }\n\n  if (golden_frame) {\n    scoped_refptr golden_frame_surface =\n        VP8PictureToVaapiDecodeSurface(golden_frame);\n    pic_param.golden_ref_frame = golden_frame_surface->va_surface()->id();\n  } else {\n    pic_param.golden_ref_frame = VA_INVALID_SURFACE;\n  }\n\n  if (alt_frame) {\n    scoped_refptr alt_frame_surface =\n        VP8PictureToVaapiDecodeSurface(alt_frame);\n    pic_param.alt_ref_frame = alt_frame_surface->va_surface()->id();\n  } else {\n    pic_param.alt_ref_frame = VA_INVALID_SURFACE;\n  }\n\n  pic_param.out_of_loop_frame = VA_INVALID_SURFACE;\n \n   const media::Vp8LoopFilterHeader& lf_hdr = frame_hdr->loopfilter_hdr;\n \n#define FHDR_TO_PP_PF(a, b) pic_param.pic_fields.bits.a = (b);\n   FHDR_TO_PP_PF(key_frame, frame_hdr->IsKeyframe() ? 0 : 1);\n   FHDR_TO_PP_PF(version, frame_hdr->version);\n   FHDR_TO_PP_PF(segmentation_enabled, sgmnt_hdr.segmentation_enabled);\n  FHDR_TO_PP_PF(update_mb_segmentation_map,\n                sgmnt_hdr.update_mb_segmentation_map);\n  FHDR_TO_PP_PF(update_segment_feature_data,\n                sgmnt_hdr.update_segment_feature_data);\n  FHDR_TO_PP_PF(filter_type, lf_hdr.type);\n  FHDR_TO_PP_PF(sharpness_level, lf_hdr.sharpness_level);\n  FHDR_TO_PP_PF(loop_filter_adj_enable, lf_hdr.loop_filter_adj_enable);\n  FHDR_TO_PP_PF(mode_ref_lf_delta_update, lf_hdr.mode_ref_lf_delta_update);\n  FHDR_TO_PP_PF(sign_bias_golden, frame_hdr->sign_bias_golden);\n  FHDR_TO_PP_PF(sign_bias_alternate, frame_hdr->sign_bias_alternate);\n  FHDR_TO_PP_PF(mb_no_coeff_skip, frame_hdr->mb_no_skip_coeff);\n  FHDR_TO_PP_PF(loop_filter_disable, lf_hdr.level == 0);\n#undef FHDR_TO_PP_PF\n\n  ARRAY_MEMCPY_CHECKED(pic_param.mb_segment_tree_probs, sgmnt_hdr.segment_prob);\n\n  static_assert(arraysize(sgmnt_hdr.lf_update_value) ==\n                    arraysize(pic_param.loop_filter_level),\n                \"loop filter level arrays mismatch\");\n  for (size_t i = 0; i < arraysize(sgmnt_hdr.lf_update_value); ++i) {\n    int lf_level = lf_hdr.level;\n    if (sgmnt_hdr.segmentation_enabled) {\n      if (sgmnt_hdr.segment_feature_mode ==\n          media::Vp8SegmentationHeader::FEATURE_MODE_ABSOLUTE)\n        lf_level = sgmnt_hdr.lf_update_value[i];\n      else\n        lf_level += sgmnt_hdr.lf_update_value[i];\n    }\n\n    lf_level = std::min(std::max(lf_level, 0), 63);\n    pic_param.loop_filter_level[i] = lf_level;\n  }\n\n  static_assert(arraysize(lf_hdr.ref_frame_delta) ==\n                    arraysize(pic_param.loop_filter_deltas_ref_frame) &&\n                arraysize(lf_hdr.mb_mode_delta) ==\n                    arraysize(pic_param.loop_filter_deltas_mode) &&\n                arraysize(lf_hdr.ref_frame_delta) ==\n                    arraysize(lf_hdr.mb_mode_delta),\n                \"loop filter deltas arrays size mismatch\");\n  for (size_t i = 0; i < arraysize(lf_hdr.ref_frame_delta); ++i) {\n    pic_param.loop_filter_deltas_ref_frame[i] = lf_hdr.ref_frame_delta[i];\n     pic_param.loop_filter_deltas_mode[i] = lf_hdr.mb_mode_delta[i];\n   }\n \n#define FHDR_TO_PP(a) pic_param.a = frame_hdr->a;\n   FHDR_TO_PP(prob_skip_false);\n   FHDR_TO_PP(prob_intra);\n   FHDR_TO_PP(prob_last);\n  FHDR_TO_PP(prob_gf);\n#undef FHDR_TO_PP\n\n  ARRAY_MEMCPY_CHECKED(pic_param.y_mode_probs, entr_hdr.y_mode_probs);\n  ARRAY_MEMCPY_CHECKED(pic_param.uv_mode_probs, entr_hdr.uv_mode_probs);\n  ARRAY_MEMCPY_CHECKED(pic_param.mv_probs, entr_hdr.mv_probs);\n\n  pic_param.bool_coder_ctx.range = frame_hdr->bool_dec_range;\n  pic_param.bool_coder_ctx.value = frame_hdr->bool_dec_value;\n   pic_param.bool_coder_ctx.count = frame_hdr->bool_dec_count;\n \n   if (!vaapi_wrapper_->SubmitBuffer(VAPictureParameterBufferType,\n                                    sizeof(VAPictureParameterBufferVP8),\n                                    &pic_param))\n     return false;\n \n   VASliceParameterBufferVP8 slice_param;\n  memset(&slice_param, 0, sizeof(VASliceParameterBufferVP8));\n   slice_param.slice_data_size = frame_hdr->frame_size;\n   slice_param.slice_data_offset = frame_hdr->first_part_offset;\n   slice_param.slice_data_flag = VA_SLICE_DATA_FLAG_ALL;\n  slice_param.macroblock_offset = frame_hdr->macroblock_bit_offset;\n  slice_param.num_of_partitions = frame_hdr->num_of_dct_partitions + 1;\n\n  slice_param.partition_size[0] =\n      frame_hdr->first_part_size - ((frame_hdr->macroblock_bit_offset + 7) \/ 8);\n\n  for (size_t i = 0; i < frame_hdr->num_of_dct_partitions; ++i)\n    slice_param.partition_size[i + 1] = frame_hdr->dct_partition_sizes[i];\n\n  if (!vaapi_wrapper_->SubmitBuffer(VASliceParameterBufferType,\n                                    sizeof(VASliceParameterBufferVP8),\n                                    &slice_param))\n    return false;\n\n  void* non_const_ptr = const_cast(frame_hdr->data);\n  if (!vaapi_wrapper_->SubmitBuffer(VASliceDataBufferType,\n                                    frame_hdr->frame_size,\n                                    non_const_ptr))\n    return false;\n\n  scoped_refptr dec_surface =\n      VP8PictureToVaapiDecodeSurface(pic);\n\n  return vaapi_dec_->DecodeSurface(dec_surface);\n}\n","target":0,"code_token_length":2015,"total_token_length":2251,"max_tokens_setting":4096}
+{"idx":349462,"func":"int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,\n\t\t\t\t\t      off_t bl_len)\n{\n  const char *content_type = NULL;\n  string content_type_str;\n  map response_attrs;\n  map::iterator riter;\n  bufferlist metadata_bl;\n\n  if (sent_header)\n    goto send_data;\n\n  if (custom_http_ret) {\n    set_req_state_err(s, 0);\n    dump_errno(s, custom_http_ret);\n  } else {\n    set_req_state_err(s, (partial_content && !op_ret) ? STATUS_PARTIAL_CONTENT\n                  : op_ret);\n    dump_errno(s);\n  }\n\n  if (op_ret)\n    goto done;\n\n  if (range_str)\n    dump_range(s, start, end, s->obj_size);\n\n  if (s->system_request &&\n      s->info.args.exists(RGW_SYS_PARAM_PREFIX \"prepend-metadata\")) {\n\n    dump_header(s, \"Rgwx-Object-Size\", (long long)total_len);\n\n    if (rgwx_stat) {\n      \/*\n       * in this case, we're not returning the object's content, only the prepended\n       * extra metadata\n       *\/\n      total_len = 0;\n    }\n\n    \/* JSON encode object metadata *\/\n    JSONFormatter jf;\n    jf.open_object_section(\"obj_metadata\");\n    encode_json(\"attrs\", attrs, &jf);\n    utime_t ut(lastmod);\n    encode_json(\"mtime\", ut, &jf);\n    jf.close_section();\n    stringstream ss;\n    jf.flush(ss);\n    metadata_bl.append(ss.str());\n    dump_header(s, \"Rgwx-Embedded-Metadata-Len\", metadata_bl.length());\n    total_len += metadata_bl.length();\n  }\n\n  if (s->system_request && !real_clock::is_zero(lastmod)) {\n    \/* we end up dumping mtime in two different methods, a bit redundant *\/\n    dump_epoch_header(s, \"Rgwx-Mtime\", lastmod);\n    uint64_t pg_ver = 0;\n    int r = decode_attr_bl_single_value(attrs, RGW_ATTR_PG_VER, &pg_ver, (uint64_t)0);\n    if (r < 0) {\n      ldout(s->cct, 0) << \"ERROR: failed to decode pg ver attr, ignoring\" << dendl;\n    }\n    dump_header(s, \"Rgwx-Obj-PG-Ver\", pg_ver);\n\n    uint32_t source_zone_short_id = 0;\n    r = decode_attr_bl_single_value(attrs, RGW_ATTR_SOURCE_ZONE, &source_zone_short_id, (uint32_t)0);\n    if (r < 0) {\n      ldout(s->cct, 0) << \"ERROR: failed to decode pg ver attr, ignoring\" << dendl;\n    }\n    if (source_zone_short_id != 0) {\n      dump_header(s, \"Rgwx-Source-Zone-Short-Id\", source_zone_short_id);\n    }\n  }\n\n  for (auto &it : crypt_http_responses)\n    dump_header(s, it.first, it.second);\n\n  dump_content_length(s, total_len);\n  dump_last_modified(s, lastmod);\n  dump_header_if_nonempty(s, \"x-amz-version-id\", version_id);\n  if (attrs.find(RGW_ATTR_APPEND_PART_NUM) != attrs.end()) {\n    dump_header(s, \"x-rgw-object-type\", \"Appendable\");\n    dump_header(s, \"x-rgw-next-append-position\", s->obj_size);\n  } else {\n    dump_header(s, \"x-rgw-object-type\", \"Normal\");\n  }\n\n  if (! op_ret) {\n    if (! lo_etag.empty()) {\n      \/* Handle etag of Swift API's large objects (DLO\/SLO). It's entirerly\n       * legit to perform GET on them through S3 API. In such situation,\n       * a client should receive the composited content with corresponding\n       * etag value. *\/\n      dump_etag(s, lo_etag);\n    } else {\n      auto iter = attrs.find(RGW_ATTR_ETAG);\n      if (iter != attrs.end()) {\n        dump_etag(s, iter->second.to_str());\n      }\n    }\n\n    for (struct response_attr_param *p = resp_attr_params; p->param; p++) {\n      bool exists;\n      string val = s->info.args.get(p->param, &exists);\n      if (exists) {\n\t\/* reject unauthenticated response header manipulation, see\n\t * https:\/\/docs.aws.amazon.com\/AmazonS3\/latest\/API\/API_GetObject.html *\/\n\tif (s->auth.identity->is_anonymous()) {\n\t  return -EPERM;\n\t}\n\tif (strcmp(p->param, \"response-content-type\") != 0) {\n\t  response_attrs[p->http_attr] = val;\n\t} else {\n\t  content_type_str = val;\n\t  content_type = content_type_str.c_str();\n\t}\n      }\n    }\n\n    for (auto iter = attrs.begin(); iter != attrs.end(); ++iter) {\n      const char *name = iter->first.c_str();\n      map::iterator aiter = rgw_to_http_attrs.find(name);\n      if (aiter != rgw_to_http_attrs.end()) {\n        if (response_attrs.count(aiter->second) == 0) {\n          \/* Was not already overridden by a response param. *\/\n\n          size_t len = iter->second.length();\n          string s(iter->second.c_str(), len);\n          while (len && !s[len - 1]) {\n            --len;\n            s.resize(len);\n          }\n          response_attrs[aiter->second] = s;\n        }\n      } else if (iter->first.compare(RGW_ATTR_CONTENT_TYPE) == 0) {\n        \/* Special handling for content_type. *\/\n        if (!content_type) {\n          content_type_str = rgw_bl_str(iter->second);\n          content_type = content_type_str.c_str();\n        }\n      } else if (strcmp(name, RGW_ATTR_SLO_UINDICATOR) == 0) {\n        \/\/ this attr has an extra length prefix from encode() in prior versions\n        dump_header(s, \"X-Object-Meta-Static-Large-Object\", \"True\");\n      } else if (strncmp(name, RGW_ATTR_META_PREFIX,\n\t\t\t sizeof(RGW_ATTR_META_PREFIX)-1) == 0) {\n        \/* User custom metadata. *\/\n        name += sizeof(RGW_ATTR_PREFIX) - 1;\n        dump_header(s, name, iter->second);\n      } else if (iter->first.compare(RGW_ATTR_TAGS) == 0) {\n        RGWObjTags obj_tags;\n        try{\n          auto it = iter->second.cbegin();\n          obj_tags.decode(it);\n        } catch (buffer::error &err) {\n          ldout(s->cct,0) << \"Error caught buffer::error couldn't decode TagSet \" << dendl;\n        }\n        dump_header(s, RGW_AMZ_TAG_COUNT, obj_tags.count());\n      } else if (iter->first.compare(RGW_ATTR_OBJECT_RETENTION) == 0 && get_retention){\n        RGWObjectRetention retention;\n        try {\n          decode(retention, iter->second);\n          dump_header(s, \"x-amz-object-lock-mode\", retention.get_mode());\n          dump_time_header(s, \"x-amz-object-lock-retain-until-date\", retention.get_retain_until_date());\n        } catch (buffer::error& err) {\n          ldpp_dout(this, 0) << \"ERROR: failed to decode RGWObjectRetention\" << dendl;\n        }\n      } else if (iter->first.compare(RGW_ATTR_OBJECT_LEGAL_HOLD) == 0 && get_legal_hold) {\n        RGWObjectLegalHold legal_hold;\n        try {\n          decode(legal_hold, iter->second);\n          dump_header(s, \"x-amz-object-lock-legal-hold\",legal_hold.get_status());\n        } catch (buffer::error& err) {\n          ldpp_dout(this, 0) << \"ERROR: failed to decode RGWObjectLegalHold\" << dendl;\n        }\n      }\n    }\n  }\n\ndone:\n  for (riter = response_attrs.begin(); riter != response_attrs.end();\n       ++riter) {\n    dump_header(s, riter->first, riter->second);\n  }\n\n  if (op_ret == -ERR_NOT_MODIFIED) {\n      end_header(s, this);\n  } else {\n      if (!content_type)\n          content_type = \"binary\/octet-stream\";\n\n      end_header(s, this, content_type);\n  }\n\n  if (metadata_bl.length()) {\n    dump_body(s, metadata_bl);\n  }\n  sent_header = true;\n\nsend_data:\n  if (get_data && !op_ret) {\n    int r = dump_body(s, bl.c_str() + bl_ofs, bl_len);\n    if (r < 0)\n      return r;\n  }\n\n  return 0;\n}","target":1,"code_token_length":1896,"total_token_length":2132,"max_tokens_setting":4096}
+{"idx":415605,"func":"static Image *ReadMETAImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  Image\n    *buff,\n    *image;\n\n  MagickBooleanType\n    status;\n\n  StringInfo\n    *profile;\n\n  size_t\n    length;\n\n  void\n    *blob;\n\n  \/*\n    Open file containing binary metadata\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  image->columns=1;\n  image->rows=1;\n  if (SetImageBackgroundColor(image) == MagickFalse)\n    {\n      InheritException(exception,&image->exception);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  length=1;\n  if (LocaleNCompare(image_info->magick,\"8BIM\",4) == 0)\n    {\n      \/*\n        Read 8BIM binary metadata.\n      *\/\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) memset(blob,0,length);\n      AttachBlob(buff->blob,blob,length);\n      if (LocaleCompare(image_info->magick,\"8BIMTEXT\") == 0)\n        {\n          length=(size_t) parse8BIM(image, buff);\n          if (length == 0)\n            {\n              blob=DetachBlob(buff->blob);\n              blob=(unsigned char *) RelinquishMagickMemory(blob);\n              buff=DestroyImage(buff);\n              ThrowReaderException(CorruptImageError,\"CorruptImage\");\n            }\n          if (length & 1)\n            (void) WriteBlobByte(buff,0x0);\n        }\n      else if (LocaleCompare(image_info->magick,\"8BIMWTEXT\") == 0)\n        {\n          length=(size_t) parse8BIMW(image, buff);\n          if (length == 0)\n            {\n              blob=DetachBlob(buff->blob);\n              blob=(unsigned char *) RelinquishMagickMemory(blob);\n              buff=DestroyImage(buff);\n              ThrowReaderException(CorruptImageError,\"CorruptImage\");\n            }\n          if (length & 1)\n            (void) WriteBlobByte(buff,0x0);\n        }\n      else\n        CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      status=SetImageProfile(image,\"8bim\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n      if (status == MagickFalse)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    }\n  if (LocaleNCompare(image_info->magick,\"APP1\",4) == 0)\n    {\n      char\n        name[MaxTextExtent];\n\n      (void) FormatLocaleString(name,MaxTextExtent,\"APP%d\",1);\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      if (LocaleCompare(image_info->magick,\"APP1JPEG\") == 0)\n        {\n          Image\n            *iptc;\n\n          int\n            result;\n\n          if (image_info->profile == (void *) NULL)\n            {\n              blob=DetachBlob(buff->blob);\n              blob=(unsigned char *) RelinquishMagickMemory(blob);\n              buff=DestroyImage(buff);\n              ThrowReaderException(CoderError,\"NoIPTCProfileAvailable\");\n            }\n          profile=CloneStringInfo((StringInfo *) image_info->profile);\n          iptc=AcquireImage((ImageInfo *) NULL);\n          if (iptc == (Image *) NULL)\n            {\n              blob=DetachBlob(buff->blob);\n              blob=(unsigned char *) RelinquishMagickMemory(blob);\n              buff=DestroyImage(buff);\n              ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n            }\n          AttachBlob(iptc->blob,GetStringInfoDatum(profile),\n            GetStringInfoLength(profile));\n          result=jpeg_embed(image,buff,iptc);\n          blob=DetachBlob(iptc->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          iptc=DestroyImage(iptc);\n          if (result == 0)\n            ThrowReaderException(CoderError,\"JPEGEmbeddingFailed\");\n        }\n      else\n        CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      status=SetImageProfile(image,name,profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n      if (status == MagickFalse)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n    }\n  if ((LocaleCompare(image_info->magick,\"ICC\") == 0) ||\n      (LocaleCompare(image_info->magick,\"ICM\") == 0))\n    {\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) SetImageProfile(image,\"icc\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n    }\n  if (LocaleCompare(image_info->magick,\"IPTC\") == 0)\n    {\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) SetImageProfile(image,\"iptc\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n    }\n  if (LocaleCompare(image_info->magick,\"XMP\") == 0)\n    {\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) SetImageProfile(image,\"xmp\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n    }\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":2147,"total_token_length":2383,"max_tokens_setting":4096}
+{"idx":6420,"func":"bool read_ujpg( void )\n{\n    using namespace IOUtil;\n    using namespace Sirikata;\n\/\/    colldata.start_decoder_worker_thread(std::bind(&simple_decoder, &colldata, str_in));\n    unsigned char ujpg_mrk[ 64 ];\n    \/\/ this is where we will enable seccomp, before reading user data\n    write_byte_bill(Billing::HEADER, true, 24); \/\/ for the fixed header\n\n    str_out->call_size_callback(max_file_size);\n    uint32_t compressed_header_size = 0;\n    if (ReadFull(str_in, ujpg_mrk, 4) != 4) {\n        custom_exit(ExitCode::SHORT_READ);\n    }\n    write_byte_bill(Billing::HEADER, true, 4);\n\n    compressed_header_size = LEtoUint32(ujpg_mrk);\n    if (compressed_header_size > 128 * 1024 * 1024 || max_file_size > 128 * 1024 * 1024) {\n        always_assert(false && \"Only support images < 128 megs\");\n        return false; \/\/ bool too big\n    }\n    bool pending_header_reads = false;\n    if (header_reader == NULL) {\n        std::vector > compressed_header_buffer(compressed_header_size);\n        IOUtil::ReadFull(str_in, compressed_header_buffer.data(), compressed_header_buffer.size());\n        header_reader = new MemReadWriter((JpegAllocator()));\n        {\n            if (ujgversion == 1) {\n                JpegAllocator no_free_allocator;\n#if !defined(USE_STANDARD_MEMORY_ALLOCATORS) && !defined(_WIN32) && !defined(EMSCRIPTEN)\n                no_free_allocator.setup_memory_subsystem(32 * 1024 * 1024,\n                                                         16,\n                                                         &mem_init_nop,\n                                                         &MemMgrAllocatorMalloc,\n                                                         &mem_nop,\n                                                         &mem_realloc_nop,\n                                                         &MemMgrAllocatorMsize);\n#endif\n                std::pair >,\n                          JpegError> uncompressed_header_buffer(\n                              ZlibDecoderDecompressionReader::Decompress(compressed_header_buffer.data(),\n                                                                         compressed_header_buffer.size(),\n                                                                         no_free_allocator,\n                                                                         max_file_size + 2048));\n                if (uncompressed_header_buffer.second) {\n                    always_assert(false && \"Data not properly zlib coded\");\n                    return false;\n                }\n                zlib_hdrs = compressed_header_buffer.size();\n                header_reader->SwapIn(uncompressed_header_buffer.first, 0);\n            } else {\n                std::pair >,\n                          JpegError> uncompressed_header_buffer(\n                              Sirikata::BrotliCodec::Decompress(compressed_header_buffer.data(),\n                                                                compressed_header_buffer.size(),\n                                                                JpegAllocator(),\n                                                                max_file_size * 2 + 128 * 1024 * 1024));\n                if (uncompressed_header_buffer.second) {\n                    always_assert(false && \"Data not properly zlib coded\");\n                    return false;\n                }\n                zlib_hdrs = compressed_header_buffer.size();\n                header_reader->SwapIn(uncompressed_header_buffer.first, 0);            \n            }\n        }\n        write_byte_bill(Billing::HEADER,\n                        true,\n                        compressed_header_buffer.size());\n    } else {\n        always_assert(compressed_header_size == 0 && \"Special concatenation requires 0 size header\");\n    }\n    grbs = sizeof(EOI);\n    grbgdata = EOI; \/\/ if we don't have any garbage, assume FFD9 EOI\n    \/\/ read header from file\n    ReadFull(header_reader, ujpg_mrk, 3 ) ;\n    \/\/ check marker\n    if ( memcmp( ujpg_mrk, \"HDR\", 3 ) == 0 ) {\n        \/\/ read size of header, alloc memory\n        ReadFull(header_reader, ujpg_mrk, 4 );\n        hdrs = LEtoUint32(ujpg_mrk);\n        hdrdata = (unsigned char*) aligned_alloc(hdrs);\n        memset(hdrdata, 0, hdrs);\n        if ( hdrdata == NULL ) {\n            fprintf( stderr, MEM_ERRMSG );\n            errorlevel.store(2);\n            return false;\n        }\n        \/\/ read hdrdata\n        ReadFull(header_reader, hdrdata, hdrs );\n    }\n    else {\n        fprintf( stderr, \"HDR marker not found\" );\n        errorlevel.store(2);\n        return false;\n    }\n    bool memory_optimized_image = (filetype != UJG) && !g_allow_progressive;\n    \/\/ parse header for image-info\n    if ( !setup_imginfo_jpg(memory_optimized_image) )\n        return false;\n\n    \/\/ beginning here: recovery information (needed for exact JPEG recovery)\n\n    \/\/ read padbit information from file\n    ReadFull(header_reader, ujpg_mrk, 3 );\n    \/\/ check marker\n    if ( memcmp( ujpg_mrk, \"P0D\", 3 ) == 0 ) {\n        \/\/ This is a more nuanced pad byte that can have different values per bit\n        header_reader->Read( reinterpret_cast(&padbit), 1 );\n    }\n    else if ( memcmp( ujpg_mrk, \"PAD\", 3 ) == 0 ) {\n        \/\/ this is a single pad bit that is implied to have all the same values\n        header_reader->Read( reinterpret_cast(&padbit), 1 );\n        if (!(padbit == 0 || padbit == 1 ||padbit == -1)) {\n            while (write(2,\n                        \"Legacy Padbit must be 0, 1 or -1\\n\",\n                         strlen(\"Legacy Padbit must be 0, 1 or -1\\n\")) < 0\n                   && errno == EINTR) {\n            }\n            custom_exit(ExitCode::STREAM_INCONSISTENT);\n        }\n        if (padbit == 1) {\n            padbit = 0x7f; \/\/ all 6 bits set\n        }\n    }\n    else {\n        fprintf( stderr, \"PAD marker not found\" );\n        errorlevel.store(2);\n        return false;\n    }\n    std::vector thread_handoff;\n    \/\/ read further recovery information if any\n    while ( ReadFull(header_reader, ujpg_mrk, 3 ) == 3 ) {\n        \/\/ check marker\n        if ( memcmp( ujpg_mrk, \"CRS\", 3 ) == 0 ) {\n            rst_cnt_set = true;\n            ReadFull(header_reader, ujpg_mrk, 4);\n            rst_cnt.resize(LEtoUint32(ujpg_mrk));\n            for (size_t i = 0; i < rst_cnt.size(); ++i) {\n                ReadFull(header_reader, ujpg_mrk, 4);\n                rst_cnt.at(i) = LEtoUint32(ujpg_mrk);\n            }\n        } else if ( memcmp( ujpg_mrk, \"HHX\", 2 ) == 0 ) { \/\/ only look at first two bytes\n            size_t to_alloc = ThreadHandoff::get_remaining_data_size_from_two_bytes(ujpg_mrk + 1) + 2;\n            if(to_alloc) {\n                std::vector data(to_alloc);\n                data[0] = ujpg_mrk[1];\n                data[1] = ujpg_mrk[2];\n                ReadFull(header_reader, &data[2], to_alloc - 2);\n                thread_handoff = ThreadHandoff::deserialize(&data[0], to_alloc);\n            }\n        } else if ( memcmp( ujpg_mrk, \"FRS\", 3 ) == 0 ) {\n            \/\/ read number of false set RST markers per scan from file\n            ReadFull(header_reader, ujpg_mrk, 4);\n            scnc = LEtoUint32(ujpg_mrk);\n            \n            rst_err.insert(rst_err.end(), scnc - rst_err.size(), 0);\n            \/\/ read data\n            ReadFull(header_reader, rst_err.data(), scnc );\n        }\n        else if ( memcmp( ujpg_mrk, \"GRB\", 3 ) == 0 ) {\n            \/\/ read garbage (data after end of JPG) from file\n            ReadFull(header_reader, ujpg_mrk, 4);\n            grbs = LEtoUint32(ujpg_mrk);\n            grbgdata = aligned_alloc(grbs);\n            memset(grbgdata, 0, sizeof(grbs));\n            if ( grbgdata == NULL ) {\n                fprintf( stderr, MEM_ERRMSG );\n                errorlevel.store(2);\n                return false;\n            }\n            \/\/ read garbage data\n            ReadFull(header_reader, grbgdata, grbs );\n        }\n        else if ( memcmp( ujpg_mrk, \"PGR\", 3 ) == 0 || memcmp( ujpg_mrk, \"PGE\", 3 ) == 0 ) {\n            \/\/ read prefix garbage (data before beginning of JPG) from file\n            if (ujpg_mrk[2] == 'E') {\n                \/\/ embedded jpeg: full header required\n                embedded_jpeg = true;\n            }\n            ReadFull(header_reader, ujpg_mrk, 4);\n            prefix_grbs = LEtoUint32(ujpg_mrk);\n            prefix_grbgdata = aligned_alloc(prefix_grbs);\n            memset(prefix_grbgdata, 0, sizeof(prefix_grbs));\n            if ( prefix_grbgdata == NULL ) {\n                fprintf( stderr, MEM_ERRMSG );\n                errorlevel.store(2);\n                return false;\n            }\n            \/\/ read garbage data\n            ReadFull(header_reader, prefix_grbgdata, prefix_grbs );\n        }\n        else if ( memcmp( ujpg_mrk, \"SIZ\", 3 ) == 0 ) {\n            \/\/ full size of the original file\n            ReadFull(header_reader, ujpg_mrk, 4);\n            max_file_size = LEtoUint32(ujpg_mrk);\n        }\n        else if ( memcmp( ujpg_mrk, \"EEE\", 3) == 0) {\n            ReadFull(header_reader, ujpg_mrk, 28);\n            max_cmp = LEtoUint32(ujpg_mrk);\n            max_bpos = LEtoUint32(ujpg_mrk + 4);\n            max_sah = LEtoUint32(ujpg_mrk + 8);\n            max_dpos[0] = LEtoUint32(ujpg_mrk + 12);\n            max_dpos[1] = LEtoUint32(ujpg_mrk + 16);\n            max_dpos[2] = LEtoUint32(ujpg_mrk + 20);\n            max_dpos[3] = LEtoUint32(ujpg_mrk + 24);\n            early_eof_encountered = true;\n            colldata.set_truncation_bounds(max_cmp, max_bpos, max_dpos, max_sah);\n        }\n        else {\n            if (memcmp(ujpg_mrk, \"CNT\", 3) == 0 ) {\n                pending_header_reads = true;\n                break;\n            } else if (memcmp(ujpg_mrk, \"CMP\", 3) == 0 ) {\n                break;\n            } else {\n                fprintf( stderr, \"unknown data found\" );\n                errorlevel.store(2);\n            }\n            return false;\n        }\n    }\n    if (!pending_header_reads) {\n        delete header_reader;\n        header_reader = NULL;\n    }\n    write_byte_bill(Billing::HEADER,\n                    false,\n                    2 + hdrs + prefix_grbs + grbs);\n\n    ReadFull(str_in, ujpg_mrk, 3 ) ;\n    write_byte_bill(Billing::HEADER, true, 3);\n\n    write_byte_bill(Billing::DELIMITERS, true, 4 * NUM_THREADS); \/\/ trailing vpx_encode bits\n    write_byte_bill(Billing::HEADER, true, 4); \/\/trailing size\n\n    if (memcmp(ujpg_mrk, \"CMP\", 3) != 0) {\n        always_assert(false && \"CMP must be present (uncompressed) in the file or CNT continue marker\");\n        return false; \/\/ not a JPG\n    }\n    colldata.signal_worker_should_begin();\n    g_decoder->initialize(str_in, thread_handoff);\n    colldata.start_decoder(g_decoder);\n    return true;\n}","target":1,"code_token_length":2673,"total_token_length":2909,"max_tokens_setting":4096}
+{"idx":6377,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& images = context->input(0);\n    const Tensor& boxes = context->input(1);\n    const int64 depth = images.dim_size(3);\n\n    OP_REQUIRES(context, images.dims() == 4,\n                errors::InvalidArgument(\"The rank of the images should be 4\"));\n    OP_REQUIRES(\n        context, boxes.dims() == 3,\n        errors::InvalidArgument(\"The rank of the boxes tensor should be 3\"));\n    OP_REQUIRES(context, images.dim_size(0) == boxes.dim_size(0),\n                errors::InvalidArgument(\"The batch sizes should be the same\"));\n\n    OP_REQUIRES(\n        context, depth == 4 || depth == 1 || depth == 3,\n        errors::InvalidArgument(\"Channel depth should be either 1 (GRY), \"\n                                \"3 (RGB), or 4 (RGBA)\"));\n\n    const int64 batch_size = images.dim_size(0);\n    const int64 height = images.dim_size(1);\n    const int64 width = images.dim_size(2);\n    std::vector> color_table;\n    if (context->num_inputs() == 3) {\n      const Tensor& colors_tensor = context->input(2);\n      OP_REQUIRES(context, colors_tensor.shape().dims() == 2,\n                  errors::InvalidArgument(\"colors must be a 2-D matrix\",\n                                          colors_tensor.shape().DebugString()));\n      OP_REQUIRES(context, colors_tensor.shape().dim_size(1) >= depth,\n                  errors::InvalidArgument(\"colors must have equal or more \",\n                                          \"channels than the image provided: \",\n                                          colors_tensor.shape().DebugString()));\n      if (colors_tensor.NumElements() != 0) {\n        color_table.clear();\n\n        auto colors = colors_tensor.matrix();\n        for (int64 i = 0; i < colors.dimension(0); i++) {\n          std::vector color_value(4);\n          for (int64 j = 0; j < 4; j++) {\n            color_value[j] = colors(i, j);\n          }\n          color_table.emplace_back(color_value);\n        }\n      }\n    }\n    if (color_table.empty()) {\n      color_table = DefaultColorTable(depth);\n    }\n    Tensor* output;\n    OP_REQUIRES_OK(\n        context,\n        context->allocate_output(\n            0, TensorShape({batch_size, height, width, depth}), &output));\n\n    output->tensor() = images.tensor();\n    auto canvas = output->tensor();\n\n    for (int64 b = 0; b < batch_size; ++b) {\n      const int64 num_boxes = boxes.dim_size(1);\n      const auto tboxes = boxes.tensor();\n      for (int64 bb = 0; bb < num_boxes; ++bb) {\n        int64 color_index = bb % color_table.size();\n        const int64 min_box_row =\n            static_cast(tboxes(b, bb, 0)) * (height - 1);\n        const int64 min_box_row_clamp = std::max(min_box_row, int64{0});\n        const int64 max_box_row =\n            static_cast(tboxes(b, bb, 2)) * (height - 1);\n        const int64 max_box_row_clamp =\n            std::min(max_box_row, height - 1);\n        const int64 min_box_col =\n            static_cast(tboxes(b, bb, 1)) * (width - 1);\n        const int64 min_box_col_clamp = std::max(min_box_col, int64{0});\n        const int64 max_box_col =\n            static_cast(tboxes(b, bb, 3)) * (width - 1);\n        const int64 max_box_col_clamp = std::min(max_box_col, width - 1);\n\n        if (min_box_row > max_box_row || min_box_col > max_box_col) {\n          LOG(WARNING) << \"Bounding box (\" << min_box_row << \",\" << min_box_col\n                       << \",\" << max_box_row << \",\" << max_box_col\n                       << \") is inverted and will not be drawn.\";\n          continue;\n        }\n        if (min_box_row >= height || max_box_row < 0 || min_box_col >= width ||\n            max_box_col < 0) {\n          LOG(WARNING) << \"Bounding box (\" << min_box_row << \",\" << min_box_col\n                       << \",\" << max_box_row << \",\" << max_box_col\n                       << \") is completely outside the image\"\n                       << \" and will not be drawn.\";\n          continue;\n        }\n\n        \/\/ At this point, {min,max}_box_{row,col}_clamp are inside the\n        \/\/ image.\n        OP_REQUIRES(\n            context, min_box_row_clamp >= 0,\n            errors::InvalidArgument(\"Min box row clamp is less than 0.\"));\n        OP_REQUIRES(\n            context, max_box_row_clamp >= 0,\n            errors::InvalidArgument(\"Max box row clamp is less than 0.\"));\n        OP_REQUIRES(context, min_box_row_clamp <= height,\n                    errors::InvalidArgument(\n                        \"Min box row clamp is greater than height.\"));\n        OP_REQUIRES(context, max_box_row_clamp <= height,\n                    errors::InvalidArgument(\n                        \"Max box row clamp is greater than height.\"));\n\n        OP_REQUIRES(\n            context, min_box_col_clamp >= 0,\n            errors::InvalidArgument(\"Min box col clamp is less than 0.\"));\n        OP_REQUIRES(\n            context, max_box_col_clamp >= 0,\n            errors::InvalidArgument(\"Max box col clamp is less than 0.\"));\n        OP_REQUIRES(context, min_box_col_clamp <= width,\n                    errors::InvalidArgument(\n                        \"Min box col clamp is greater than width.\"));\n        OP_REQUIRES(context, max_box_col_clamp <= width,\n                    errors::InvalidArgument(\n                        \"Max box col clamp is greater than width.\"));\n\n        \/\/ At this point, the min_box_row and min_box_col are either\n        \/\/ in the image or above\/left of it, and max_box_row and\n        \/\/ max_box_col are either in the image or below\/right or it.\n\n        OP_REQUIRES(\n            context, min_box_row <= height,\n            errors::InvalidArgument(\"Min box row is greater than height.\"));\n        OP_REQUIRES(context, max_box_row >= 0,\n                    errors::InvalidArgument(\"Max box row is less than 0.\"));\n        OP_REQUIRES(\n            context, min_box_col <= width,\n            errors::InvalidArgument(\"Min box col is greater than width.\"));\n        OP_REQUIRES(context, max_box_col >= 0,\n                    errors::InvalidArgument(\"Max box col is less than 0.\"));\n\n        \/\/ Draw top line.\n        if (min_box_row >= 0) {\n          for (int64 j = min_box_col_clamp; j <= max_box_col_clamp; ++j)\n            for (int64 c = 0; c < depth; c++) {\n              canvas(b, min_box_row, j, c) =\n                  static_cast(color_table[color_index][c]);\n            }\n        }\n        \/\/ Draw bottom line.\n        if (max_box_row < height) {\n          for (int64 j = min_box_col_clamp; j <= max_box_col_clamp; ++j)\n            for (int64 c = 0; c < depth; c++) {\n              canvas(b, max_box_row, j, c) =\n                  static_cast(color_table[color_index][c]);\n            }\n        }\n        \/\/ Draw left line.\n        if (min_box_col >= 0) {\n          for (int64 i = min_box_row_clamp; i <= max_box_row_clamp; ++i)\n            for (int64 c = 0; c < depth; c++) {\n              canvas(b, i, min_box_col, c) =\n                  static_cast(color_table[color_index][c]);\n            }\n        }\n        \/\/ Draw right line.\n        if (max_box_col < width) {\n          for (int64 i = min_box_row_clamp; i <= max_box_row_clamp; ++i)\n            for (int64 c = 0; c < depth; c++) {\n              canvas(b, i, max_box_col, c) =\n                  static_cast(color_table[color_index][c]);\n            }\n        }\n      }\n    }\n  }","target":1,"code_token_length":1831,"total_token_length":2067,"max_tokens_setting":4096}
+{"idx":488308,"func":"static s64 ntfs_attr_pread_i(ntfs_attr *na, const s64 pos, s64 count, void *b)\n{\n\ts64 br, to_read, ofs, total, total2, max_read, max_init;\n\tntfs_volume *vol;\n\trunlist_element *rl;\n\tu16 efs_padding_length;\n\n\t\/* Sanity checking arguments is done in ntfs_attr_pread(). *\/\n\t\n\tif ((na->data_flags & ATTR_COMPRESSION_MASK) && NAttrNonResident(na)) {\n\t\tif ((na->data_flags & ATTR_COMPRESSION_MASK)\n\t\t    == ATTR_IS_COMPRESSED)\n\t\t\treturn ntfs_compressed_attr_pread(na, pos, count, b);\n\t\telse {\n\t\t\t\t\/* compression mode not supported *\/\n\t\t\terrno = EOPNOTSUPP;\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\/*\n\t * Encrypted non-resident attributes are not supported.  We return\n\t * access denied, which is what Windows NT4 does, too.\n\t * However, allow if mounted with efs_raw option\n\t *\/\n\tvol = na->ni->vol;\n\tif (!vol->efs_raw && NAttrEncrypted(na) && NAttrNonResident(na)) {\n\t\terrno = EACCES;\n\t\treturn -1;\n\t}\n\t\n\tif (!count)\n\t\treturn 0;\n\t\t\/*\n\t\t * Truncate reads beyond end of attribute,\n\t\t * but round to next 512 byte boundary for encrypted\n\t\t * attributes with efs_raw mount option\n\t\t *\/\n\tmax_read = na->data_size;\n\tmax_init = na->initialized_size;\n\tif (na->ni->vol->efs_raw\n\t    && (na->data_flags & ATTR_IS_ENCRYPTED)\n\t    && NAttrNonResident(na)) {\n\t\tif (na->data_size != na->initialized_size) {\n\t\t\tntfs_log_error(\"uninitialized encrypted file not supported\\n\");\n\t\t\terrno = EINVAL;\n\t\t\treturn -1;\n\t\t}\t\n\t\tmax_init = max_read = ((na->data_size + 511) & ~511) + 2;\n\t}\n\tif (pos + count > max_read) {\n\t\tif (pos >= max_read)\n\t\t\treturn 0;\n\t\tcount = max_read - pos;\n\t}\n\t\/* If it is a resident attribute, get the value from the mft record. *\/\n\tif (!NAttrNonResident(na)) {\n\t\tntfs_attr_search_ctx *ctx;\n\t\tchar *val;\n\n\t\tctx = ntfs_attr_get_search_ctx(na->ni, NULL);\n\t\tif (!ctx)\n\t\t\treturn -1;\n\t\tif (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,\n\t\t\t\t0, NULL, 0, ctx)) {\nres_err_out:\n\t\t\tntfs_attr_put_search_ctx(ctx);\n\t\t\treturn -1;\n\t\t}\n\t\tval = (char*)ctx->attr + le16_to_cpu(ctx->attr->value_offset);\n\t\tif (val < (char*)ctx->attr || val +\n\t\t\t\tle32_to_cpu(ctx->attr->value_length) >\n\t\t\t\t(char*)ctx->mrec + vol->mft_record_size) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"%s: Sanity check failed\", __FUNCTION__);\n\t\t\tgoto res_err_out;\n\t\t}\n\t\tmemcpy(b, val + pos, count);\n\t\tntfs_attr_put_search_ctx(ctx);\n\t\treturn count;\n\t}\n\ttotal = total2 = 0;\n\t\/* Zero out reads beyond initialized size. *\/\n\tif (pos + count > max_init) {\n\t\tif (pos >= max_init) {\n\t\t\tmemset(b, 0, count);\n\t\t\treturn count;\n\t\t}\n\t\ttotal2 = pos + count - max_init;\n\t\tcount -= total2;\n\t\tmemset((u8*)b + count, 0, total2);\n\t}\n\t\t\/*\n\t\t * for encrypted non-resident attributes with efs_raw set \n\t\t * the last two bytes aren't read from disk but contain\n\t\t * the number of padding bytes so original size can be \n\t\t * restored\n\t\t *\/\n\tif (na->ni->vol->efs_raw && \n\t\t\t(na->data_flags & ATTR_IS_ENCRYPTED) && \n\t\t\t((pos + count) > max_init-2)) {\n\t\tefs_padding_length = 511 - ((na->data_size - 1) & 511);\n\t\tif (pos+count == max_init) {\n\t\t\tif (count == 1) {\n\t\t\t\t*((u8*)b+count-1) = (u8)(efs_padding_length >> 8);\n\t\t\t\tcount--;\n\t\t\t\ttotal2++;\n\t\t\t} else {\n\t\t\t\t*(le16*)((u8*)b+count-2) = cpu_to_le16(efs_padding_length);\n\t\t\t\tcount -= 2;\n\t\t\t\ttotal2 +=2;\n\t\t\t}\n\t\t} else {\n\t\t\t*((u8*)b+count-1) = (u8)(efs_padding_length & 0xff);\n\t\t\tcount--;\n\t\t\ttotal2++;\n\t\t}\n\t}\n\t\n\t\/* Find the runlist element containing the vcn. *\/\n\trl = ntfs_attr_find_vcn(na, pos >> vol->cluster_size_bits);\n\tif (!rl) {\n\t\t\/*\n\t\t * If the vcn is not present it is an out of bounds read.\n\t\t * However, we already truncated the read to the data_size,\n\t\t * so getting this here is an error.\n\t\t *\/\n\t\tif (errno == ENOENT) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"%s: Failed to find VCN #1\", __FUNCTION__);\n\t\t}\n\t\treturn -1;\n\t}\n\t\/*\n\t * Gather the requested data into the linear destination buffer. Note,\n\t * a partial final vcn is taken care of by the @count capping of read\n\t * length.\n\t *\/\n\tofs = pos - (rl->vcn << vol->cluster_size_bits);\n\tfor (; count; rl++, ofs = 0) {\n\t\tif (rl->lcn == LCN_RL_NOT_MAPPED) {\n\t\t\trl = ntfs_attr_find_vcn(na, rl->vcn);\n\t\t\tif (!rl) {\n\t\t\t\tif (errno == ENOENT) {\n\t\t\t\t\terrno = EIO;\n\t\t\t\t\tntfs_log_perror(\"%s: Failed to find VCN #2\",\n\t\t\t\t\t\t\t__FUNCTION__);\n\t\t\t\t}\n\t\t\t\tgoto rl_err_out;\n\t\t\t}\n\t\t\t\/* Needed for case when runs merged. *\/\n\t\t\tofs = pos + total - (rl->vcn << vol->cluster_size_bits);\n\t\t}\n\t\tif (!rl->length) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"%s: Zero run length\", __FUNCTION__);\n\t\t\tgoto rl_err_out;\n\t\t}\n\t\tif (rl->lcn < (LCN)0) {\n\t\t\tif (rl->lcn != (LCN)LCN_HOLE) {\n\t\t\t\tntfs_log_perror(\"%s: Bad run (%lld)\", \n\t\t\t\t\t\t__FUNCTION__,\n\t\t\t\t\t\t(long long)rl->lcn);\n\t\t\t\tgoto rl_err_out;\n\t\t\t}\n\t\t\t\/* It is a hole, just zero the matching @b range. *\/\n\t\t\tto_read = min(count, (rl->length <<\n\t\t\t\t\tvol->cluster_size_bits) - ofs);\n\t\t\tmemset(b, 0, to_read);\n\t\t\t\/* Update progress counters. *\/\n\t\t\ttotal += to_read;\n\t\t\tcount -= to_read;\n\t\t\tb = (u8*)b + to_read;\n\t\t\tcontinue;\n\t\t}\n\t\t\/* It is a real lcn, read it into @dst. *\/\n\t\tto_read = min(count, (rl->length << vol->cluster_size_bits) -\n\t\t\t\tofs);\nretry:\n\t\tntfs_log_trace(\"Reading %lld bytes from vcn %lld, lcn %lld, ofs\"\n\t\t\t\t\" %lld.\\n\", (long long)to_read, (long long)rl->vcn,\n\t\t\t       (long long )rl->lcn, (long long)ofs);\n\t\tbr = ntfs_pread(vol->dev, (rl->lcn << vol->cluster_size_bits) +\n\t\t\t\tofs, to_read, b);\n\t\t\/* If everything ok, update progress counters and continue. *\/\n\t\tif (br > 0) {\n\t\t\ttotal += br;\n\t\t\tcount -= br;\n\t\t\tb = (u8*)b + br;\n\t\t}\n\t\tif (br == to_read)\n\t\t\tcontinue;\n\t\t\/* If the syscall was interrupted, try again. *\/\n\t\tif (br == (s64)-1 && errno == EINTR)\n\t\t\tgoto retry;\n\t\tif (total)\n\t\t\treturn total;\n\t\tif (!br)\n\t\t\terrno = EIO;\n\t\tntfs_log_perror(\"%s: ntfs_pread failed\", __FUNCTION__);\n\t\treturn -1;\n\t}\n\t\/* Finally, return the number of bytes read. *\/\n\treturn total + total2;\nrl_err_out:\n\tif (total)\n\t\treturn total;\n\terrno = EIO;\n\treturn -1;\n}","target":0,"code_token_length":1940,"total_token_length":2176,"max_tokens_setting":4096}
+{"idx":327695,"func":"mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){\n\n    MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, next_vf));\n\n  mp_image_t* mpi=NULL;\n\n  int w2;\n\n  int number = mp_imgtype >> 16;\n\n\n\n  av_assert0(vf->next == NULL); \/\/ all existing filters call this just on next\n\n\n\n  \/\/vf_dint needs these as it calls vf_get_image() before configuring the output\n\n  if(vf->w==0 && w>0) vf->w=w;\n\n  if(vf->h==0 && h>0) vf->h=h;\n\n\n\n  av_assert0(w == -1 || w >= vf->w);\n\n  av_assert0(h == -1 || h >= vf->h);\n\n  av_assert0(vf->w > 0);\n\n  av_assert0(vf->h > 0);\n\n\n\n  av_log(m->avfctx, AV_LOG_DEBUG, \"get_image: %d:%d, vf: %d:%d\\n\", w,h,vf->w,vf->h);\n\n\n\n  if (w == -1) w = vf->w;\n\n  if (h == -1) h = vf->h;\n\n\n\n  w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w;\n\n\n\n  \/\/ Note: we should call libvo first to check if it supports direct rendering\n\n  \/\/ and if not, then fallback to software buffers:\n\n  switch(mp_imgtype & 0xff){\n\n  case MP_IMGTYPE_EXPORT:\n\n    if(!vf->imgctx.export_images[0]) vf->imgctx.export_images[0]=new_mp_image(w2,h);\n\n    mpi=vf->imgctx.export_images[0];\n\n    break;\n\n  case MP_IMGTYPE_STATIC:\n\n    if(!vf->imgctx.static_images[0]) vf->imgctx.static_images[0]=new_mp_image(w2,h);\n\n    mpi=vf->imgctx.static_images[0];\n\n    break;\n\n  case MP_IMGTYPE_TEMP:\n\n    if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);\n\n    mpi=vf->imgctx.temp_images[0];\n\n    break;\n\n  case MP_IMGTYPE_IPB:\n\n    if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ \/\/ B frame:\n\n      if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);\n\n      mpi=vf->imgctx.temp_images[0];\n\n      break;\n\n    }\n\n  case MP_IMGTYPE_IP:\n\n    if(!vf->imgctx.static_images[vf->imgctx.static_idx]) vf->imgctx.static_images[vf->imgctx.static_idx]=new_mp_image(w2,h);\n\n    mpi=vf->imgctx.static_images[vf->imgctx.static_idx];\n\n    vf->imgctx.static_idx^=1;\n\n    break;\n\n  case MP_IMGTYPE_NUMBERED:\n\n    if (number == -1) {\n\n      int i;\n\n      for (i = 0; i < NUM_NUMBERED_MPI; i++)\n\n        if (!vf->imgctx.numbered_images[i] || !vf->imgctx.numbered_images[i]->usage_count)\n\n          break;\n\n      number = i;\n\n    }\n\n    if (number < 0 || number >= NUM_NUMBERED_MPI) return NULL;\n\n    if (!vf->imgctx.numbered_images[number]) vf->imgctx.numbered_images[number] = new_mp_image(w2,h);\n\n    mpi = vf->imgctx.numbered_images[number];\n\n    mpi->number = number;\n\n    break;\n\n  }\n\n  if(mpi){\n\n    mpi->type=mp_imgtype;\n\n    mpi->w=vf->w; mpi->h=vf->h;\n\n    \/\/ keep buffer allocation status & color flags only:\n\n\/\/    mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);\n\n    mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;\n\n    \/\/ accept restrictions, draw_slice and palette flags only:\n\n    mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE);\n\n    if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;\n\n    if(mpi->width!=w2 || mpi->height!=h){\n\n\/\/      printf(\"vf.c: MPI parameters changed!  %dx%d -> %dx%d   \\n\", mpi->width,mpi->height,w2,h);\n\n        if(mpi->flags&MP_IMGFLAG_ALLOCATED){\n\n            if(mpi->widthheightplanes[0]);\n\n                mpi->flags&=~MP_IMGFLAG_ALLOCATED;\n\n                mp_msg(MSGT_VFILTER,MSGL_V,\"vf.c: have to REALLOCATE buffer memory :(\\n\");\n\n            }\n\n\/\/      } else {\n\n        } {\n\n            mpi->width=w2; mpi->chroma_width=(w2 + (1<chroma_x_shift) - 1)>>mpi->chroma_x_shift;\n\n            mpi->height=h; mpi->chroma_height=(h + (1<chroma_y_shift) - 1)>>mpi->chroma_y_shift;\n\n        }\n\n    }\n\n    if(!mpi->bpp) mp_image_setfmt(mpi,outfmt);\n\n    if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){\n\n\n\n        av_assert0(!vf->get_image);\n\n        \/\/ check libvo first!\n\n        if(vf->get_image) vf->get_image(vf,mpi);\n\n\n\n        if(!(mpi->flags&MP_IMGFLAG_DIRECT)){\n\n          \/\/ non-direct and not yet allocated image. allocate it!\n\n          if (!mpi->bpp) { \/\/ no way we can allocate this\n\n              mp_msg(MSGT_DECVIDEO, MSGL_FATAL,\n\n                     \"vf_get_image: Tried to allocate a format that can not be allocated!\\n\");\n\n              return NULL;\n\n          }\n\n\n\n          \/\/ check if codec prefer aligned stride:\n\n          if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){\n\n              int align=(mpi->flags&MP_IMGFLAG_PLANAR &&\n\n                         mpi->flags&MP_IMGFLAG_YUV) ?\n\n                         (8<chroma_x_shift)-1 : 15; \/\/ -- maybe FIXME\n\n              w2=((w+align)&(~align));\n\n              if(mpi->width!=w2){\n\n#if 0\n\n                  \/\/ we have to change width... check if we CAN co it:\n\n                  int flags=vf->query_format(vf,outfmt); \/\/ should not fail\n\n                  if(!(flags&3)) mp_msg(MSGT_DECVIDEO,MSGL_WARN,\"??? vf_get_image{vf->query_format(outfmt)} failed!\\n\");\n\n\/\/                printf(\"query -> 0x%X    \\n\",flags);\n\n                  if(flags&VFCAP_ACCEPT_STRIDE){\n\n#endif\n\n                      mpi->width=w2;\n\n                      mpi->chroma_width=(w2 + (1<chroma_x_shift) - 1)>>mpi->chroma_x_shift;\n\n\/\/                  }\n\n              }\n\n          }\n\n\n\n          mp_image_alloc_planes(mpi);\n\n\/\/        printf(\"clearing img!\\n\");\n\n          vf_mpi_clear(mpi,0,0,mpi->width,mpi->height);\n\n        }\n\n    }\n\n    av_assert0(!vf->start_slice);\n\n    if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)\n\n        if(vf->start_slice) vf->start_slice(vf,mpi);\n\n    if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){\n\n            mp_msg(MSGT_DECVIDEO,MSGL_V,\"*** [%s] %s%s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\\n\",\n\n                  \"NULL\"\/*vf->info->name*\/,\n\n                  (mpi->type==MP_IMGTYPE_EXPORT)?\"Exporting\":\n\n                  ((mpi->flags&MP_IMGFLAG_DIRECT)?\"Direct Rendering\":\"Allocating\"),\n\n                  (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)?\" (slices)\":\"\",\n\n                  mpi->width,mpi->height,mpi->bpp,\n\n                  (mpi->flags&MP_IMGFLAG_YUV)?\"YUV\":((mpi->flags&MP_IMGFLAG_SWAPPED)?\"BGR\":\"RGB\"),\n\n                  (mpi->flags&MP_IMGFLAG_PLANAR)?\"planar\":\"packed\",\n\n                  mpi->bpp*mpi->width*mpi->height\/8);\n\n            mp_msg(MSGT_DECVIDEO,MSGL_DBG2,\"(imgfmt: %x, planes: %p,%p,%p strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\\n\",\n\n                mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2],\n\n                mpi->stride[0], mpi->stride[1], mpi->stride[2],\n\n                mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift);\n\n            mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED;\n\n    }\n\n\n\n  mpi->qscale = NULL;\n\n  }\n\n  mpi->usage_count++;\n\n\/\/    printf(\"\\rVF_MPI: %p %p %p %d %d %d    \\n\",\n\n\/\/      mpi->planes[0],mpi->planes[1],mpi->planes[2],\n\n\/\/      mpi->stride[0],mpi->stride[1],mpi->stride[2]);\n\n  return mpi;\n\n}\n","target":1,"code_token_length":2064,"total_token_length":2300,"max_tokens_setting":4096}
+{"idx":149012,"func":"kadm5_create_principal_3(void *server_handle,\n                         kadm5_principal_ent_t entry, long mask,\n                         int n_ks_tuple, krb5_key_salt_tuple *ks_tuple,\n                         char *password)\n{\n    krb5_db_entry               *kdb;\n    osa_princ_ent_rec           adb;\n    kadm5_policy_ent_rec        polent;\n    krb5_boolean                have_polent = FALSE;\n    krb5_int32                  now;\n    krb5_tl_data                *tl_data_tail;\n    unsigned int                ret;\n    kadm5_server_handle_t handle = server_handle;\n    krb5_keyblock               *act_mkey;\n    krb5_kvno                   act_kvno;\n    int                         new_n_ks_tuple = 0;\n    krb5_key_salt_tuple         *new_ks_tuple = NULL;\n\n    CHECK_HANDLE(server_handle);\n\n    krb5_clear_error_message(handle->context);\n\n    check_1_6_dummy(entry, mask, n_ks_tuple, ks_tuple, &password);\n\n    \/*\n     * Argument sanity checking, and opening up the DB\n     *\/\n    if (entry == NULL)\n        return EINVAL;\n    if(!(mask & KADM5_PRINCIPAL) || (mask & KADM5_MOD_NAME) ||\n       (mask & KADM5_MOD_TIME) || (mask & KADM5_LAST_PWD_CHANGE) ||\n       (mask & KADM5_MKVNO) || (mask & KADM5_AUX_ATTRIBUTES) ||\n       (mask & KADM5_LAST_SUCCESS) || (mask & KADM5_LAST_FAILED) ||\n       (mask & KADM5_FAIL_AUTH_COUNT))\n        return KADM5_BAD_MASK;\n    if ((mask & KADM5_KEY_DATA) && entry->n_key_data != 0)\n        return KADM5_BAD_MASK;\n    if((mask & KADM5_POLICY) && entry->policy == NULL)\n        return KADM5_BAD_MASK;\n    if((mask & KADM5_POLICY) && (mask & KADM5_POLICY_CLR))\n        return KADM5_BAD_MASK;\n    if((mask & ~ALL_PRINC_MASK))\n        return KADM5_BAD_MASK;\n\n    \/*\n     * Check to see if the principal exists\n     *\/\n    ret = kdb_get_entry(handle, entry->principal, &kdb, &adb);\n\n    switch(ret) {\n    case KADM5_UNK_PRINC:\n        break;\n    case 0:\n        kdb_free_entry(handle, kdb, &adb);\n        return KADM5_DUP;\n    default:\n        return ret;\n    }\n\n    kdb = krb5_db_alloc(handle->context, NULL, sizeof(*kdb));\n    if (kdb == NULL)\n        return ENOMEM;\n    memset(kdb, 0, sizeof(*kdb));\n    memset(&adb, 0, sizeof(osa_princ_ent_rec));\n\n    \/*\n     * If a policy was specified, load it.\n     * If we can not find the one specified return an error\n     *\/\n    if ((mask & KADM5_POLICY)) {\n        ret = get_policy(handle, entry->policy, &polent, &have_polent);\n        if (ret)\n            goto cleanup;\n    }\n    if (password) {\n        ret = passwd_check(handle, password, have_polent ? &polent : NULL,\n                           entry->principal);\n        if (ret)\n            goto cleanup;\n    }\n    \/*\n     * Start populating the various DB fields, using the\n     * \"defaults\" for fields that were not specified by the\n     * mask.\n     *\/\n    if ((ret = krb5_timeofday(handle->context, &now)))\n        goto cleanup;\n\n    kdb->magic = KRB5_KDB_MAGIC_NUMBER;\n    kdb->len = KRB5_KDB_V1_BASE_LENGTH; \/* gag me with a chainsaw *\/\n\n    if ((mask & KADM5_ATTRIBUTES))\n        kdb->attributes = entry->attributes;\n    else\n        kdb->attributes = handle->params.flags;\n\n    if ((mask & KADM5_MAX_LIFE))\n        kdb->max_life = entry->max_life;\n    else\n        kdb->max_life = handle->params.max_life;\n\n    if (mask & KADM5_MAX_RLIFE)\n        kdb->max_renewable_life = entry->max_renewable_life;\n    else\n        kdb->max_renewable_life = handle->params.max_rlife;\n\n    if ((mask & KADM5_PRINC_EXPIRE_TIME))\n        kdb->expiration = entry->princ_expire_time;\n    else\n        kdb->expiration = handle->params.expiration;\n\n    kdb->pw_expiration = 0;\n    if (have_polent) {\n        if(polent.pw_max_life)\n            kdb->pw_expiration = now + polent.pw_max_life;\n        else\n            kdb->pw_expiration = 0;\n    }\n    if ((mask & KADM5_PW_EXPIRATION))\n        kdb->pw_expiration = entry->pw_expiration;\n\n    kdb->last_success = 0;\n    kdb->last_failed = 0;\n    kdb->fail_auth_count = 0;\n\n    \/* this is kind of gross, but in order to free the tl data, I need\n       to free the entire kdb entry, and that will try to free the\n       principal. *\/\n\n    if ((ret = kadm5_copy_principal(handle->context,\n                                    entry->principal, &(kdb->princ))))\n        goto cleanup;\n\n    if ((ret = krb5_dbe_update_last_pwd_change(handle->context, kdb, now)))\n        goto cleanup;\n\n    if (mask & KADM5_TL_DATA) {\n        \/* splice entry->tl_data onto the front of kdb->tl_data *\/\n        for (tl_data_tail = entry->tl_data; tl_data_tail;\n             tl_data_tail = tl_data_tail->tl_data_next)\n        {\n            ret = krb5_dbe_update_tl_data(handle->context, kdb, tl_data_tail);\n            if( ret )\n                goto cleanup;\n        }\n    }\n\n    \/*\n     * We need to have setup the TL data, so we have strings, so we can\n     * check enctype policy, which is why we check\/initialize ks_tuple\n     * this late.\n     *\/\n    ret = apply_keysalt_policy(handle, entry->policy, n_ks_tuple, ks_tuple,\n                               &new_n_ks_tuple, &new_ks_tuple);\n    if (ret)\n        goto cleanup;\n\n    \/* initialize the keys *\/\n\n    ret = kdb_get_active_mkey(handle, &act_kvno, &act_mkey);\n    if (ret)\n        goto cleanup;\n\n    if (mask & KADM5_KEY_DATA) {\n        \/* The client requested no keys for this principal. *\/\n        assert(entry->n_key_data == 0);\n    } else if (password) {\n        ret = krb5_dbe_cpw(handle->context, act_mkey, new_ks_tuple,\n                           new_n_ks_tuple, password,\n                           (mask & KADM5_KVNO)?entry->kvno:1,\n                           FALSE, kdb);\n    } else {\n        \/* Null password means create with random key (new in 1.8). *\/\n        ret = krb5_dbe_crk(handle->context, &master_keyblock,\n                           new_ks_tuple, new_n_ks_tuple, FALSE, kdb);\n    }\n    if (ret)\n        goto cleanup;\n\n    \/* Record the master key VNO used to encrypt this entry's keys *\/\n    ret = krb5_dbe_update_mkvno(handle->context, kdb, act_kvno);\n    if (ret)\n        goto cleanup;\n\n    ret = k5_kadm5_hook_create(handle->context, handle->hook_handles,\n                               KADM5_HOOK_STAGE_PRECOMMIT, entry, mask,\n                               new_n_ks_tuple, new_ks_tuple, password);\n    if (ret)\n        goto cleanup;\n\n    \/* populate the admin-server-specific fields.  In the OV server,\n       this used to be in a separate database.  Since there's already\n       marshalling code for the admin fields, to keep things simple,\n       I'm going to keep it, and make all the admin stuff occupy a\n       single tl_data record, *\/\n\n    adb.admin_history_kvno = INITIAL_HIST_KVNO;\n    if (mask & KADM5_POLICY) {\n        adb.aux_attributes = KADM5_POLICY;\n\n        \/* this does *not* need to be strdup'ed, because adb is xdr *\/\n        \/* encoded in osa_adb_create_princ, and not ever freed *\/\n\n        adb.policy = entry->policy;\n    }\n\n    \/* In all cases key and the principal data is set, let the database provider know *\/\n    kdb->mask = mask | KADM5_KEY_DATA | KADM5_PRINCIPAL ;\n\n    \/* store the new db entry *\/\n    ret = kdb_put_entry(handle, kdb, &adb);\n\n    (void) k5_kadm5_hook_create(handle->context, handle->hook_handles,\n                                KADM5_HOOK_STAGE_POSTCOMMIT, entry, mask,\n                                new_n_ks_tuple, new_ks_tuple, password);\n\ncleanup:\n    free(new_ks_tuple);\n    krb5_db_free_principal(handle->context, kdb);\n    if (have_polent)\n        (void) kadm5_free_policy_ent(handle->lhandle, &polent);\n    return ret;\n}","target":0,"code_token_length":1990,"total_token_length":2226,"max_tokens_setting":4096}
+{"idx":375020,"func":"generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,\n\t\t\t\t\t\tconst AttrNumber *attmap, int attmap_length)\n{\n\tOid\t\t\tsource_relid = RelationGetRelid(source_idx);\n\tForm_pg_attribute *attrs = RelationGetDescr(source_idx)->attrs;\n\tHeapTuple\tht_idxrel;\n\tHeapTuple\tht_idx;\n\tForm_pg_class idxrelrec;\n\tForm_pg_index idxrec;\n\tForm_pg_am\tamrec;\n\toidvector  *indcollation;\n\toidvector  *indclass;\n\tIndexStmt  *index;\n\tList\t   *indexprs;\n\tListCell   *indexpr_item;\n\tOid\t\t\tindrelid;\n\tint\t\t\tkeyno;\n\tOid\t\t\tkeycoltype;\n\tDatum\t\tdatum;\n\tbool\t\tisnull;\n\n\t\/*\n\t * Fetch pg_class tuple of source index.  We can't use the copy in the\n\t * relcache entry because it doesn't include optional fields.\n\t *\/\n\tht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(source_relid));\n\tif (!HeapTupleIsValid(ht_idxrel))\n\t\telog(ERROR, \"cache lookup failed for relation %u\", source_relid);\n\tidxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);\n\n\t\/* Fetch pg_index tuple for source index from relcache entry *\/\n\tht_idx = source_idx->rd_indextuple;\n\tidxrec = (Form_pg_index) GETSTRUCT(ht_idx);\n\tindrelid = idxrec->indrelid;\n\n\t\/* Fetch pg_am tuple for source index from relcache entry *\/\n\tamrec = source_idx->rd_am;\n\n\t\/* Extract indcollation from the pg_index tuple *\/\n\tdatum = SysCacheGetAttr(INDEXRELID, ht_idx,\n\t\t\t\t\t\t\tAnum_pg_index_indcollation, &isnull);\n\tAssert(!isnull);\n\tindcollation = (oidvector *) DatumGetPointer(datum);\n\n\t\/* Extract indclass from the pg_index tuple *\/\n\tdatum = SysCacheGetAttr(INDEXRELID, ht_idx,\n\t\t\t\t\t\t\tAnum_pg_index_indclass, &isnull);\n\tAssert(!isnull);\n\tindclass = (oidvector *) DatumGetPointer(datum);\n\n\t\/* Begin building the IndexStmt *\/\n\tindex = makeNode(IndexStmt);\n\tindex->relation = cxt->relation;\n\tindex->accessMethod = pstrdup(NameStr(amrec->amname));\n\tif (OidIsValid(idxrelrec->reltablespace))\n\t\tindex->tableSpace = get_tablespace_name(idxrelrec->reltablespace);\n\telse\n\t\tindex->tableSpace = NULL;\n\tindex->excludeOpNames = NIL;\n\tindex->idxcomment = NULL;\n\tindex->indexOid = InvalidOid;\n\tindex->oldNode = InvalidOid;\n\tindex->unique = idxrec->indisunique;\n\tindex->primary = idxrec->indisprimary;\n\tindex->concurrent = false;\n\n\t\/*\n\t * We don't try to preserve the name of the source index; instead, just\n\t * let DefineIndex() choose a reasonable name.\n\t *\/\n\tindex->idxname = NULL;\n\n\t\/*\n\t * If the index is marked PRIMARY or has an exclusion condition, it's\n\t * certainly from a constraint; else, if it's not marked UNIQUE, it\n\t * certainly isn't.  If it is or might be from a constraint, we have to\n\t * fetch the pg_constraint record.\n\t *\/\n\tif (index->primary || index->unique || idxrec->indisexclusion)\n\t{\n\t\tOid\t\t\tconstraintId = get_index_constraint(source_relid);\n\n\t\tif (OidIsValid(constraintId))\n\t\t{\n\t\t\tHeapTuple\tht_constr;\n\t\t\tForm_pg_constraint conrec;\n\n\t\t\tht_constr = SearchSysCache1(CONSTROID,\n\t\t\t\t\t\t\t\t\t\tObjectIdGetDatum(constraintId));\n\t\t\tif (!HeapTupleIsValid(ht_constr))\n\t\t\t\telog(ERROR, \"cache lookup failed for constraint %u\",\n\t\t\t\t\t constraintId);\n\t\t\tconrec = (Form_pg_constraint) GETSTRUCT(ht_constr);\n\n\t\t\tindex->isconstraint = true;\n\t\t\tindex->deferrable = conrec->condeferrable;\n\t\t\tindex->initdeferred = conrec->condeferred;\n\n\t\t\t\/* If it's an exclusion constraint, we need the operator names *\/\n\t\t\tif (idxrec->indisexclusion)\n\t\t\t{\n\t\t\t\tDatum\t   *elems;\n\t\t\t\tint\t\t\tnElems;\n\t\t\t\tint\t\t\ti;\n\n\t\t\t\tAssert(conrec->contype == CONSTRAINT_EXCLUSION);\n\t\t\t\t\/* Extract operator OIDs from the pg_constraint tuple *\/\n\t\t\t\tdatum = SysCacheGetAttr(CONSTROID, ht_constr,\n\t\t\t\t\t\t\t\t\t\tAnum_pg_constraint_conexclop,\n\t\t\t\t\t\t\t\t\t\t&isnull);\n\t\t\t\tif (isnull)\n\t\t\t\t\telog(ERROR, \"null conexclop for constraint %u\",\n\t\t\t\t\t\t constraintId);\n\n\t\t\t\tdeconstruct_array(DatumGetArrayTypeP(datum),\n\t\t\t\t\t\t\t\t  OIDOID, sizeof(Oid), true, 'i',\n\t\t\t\t\t\t\t\t  &elems, NULL, &nElems);\n\n\t\t\t\tfor (i = 0; i < nElems; i++)\n\t\t\t\t{\n\t\t\t\t\tOid\t\t\toperid = DatumGetObjectId(elems[i]);\n\t\t\t\t\tHeapTuple\topertup;\n\t\t\t\t\tForm_pg_operator operform;\n\t\t\t\t\tchar\t   *oprname;\n\t\t\t\t\tchar\t   *nspname;\n\t\t\t\t\tList\t   *namelist;\n\n\t\t\t\t\topertup = SearchSysCache1(OPEROID,\n\t\t\t\t\t\t\t\t\t\t\t  ObjectIdGetDatum(operid));\n\t\t\t\t\tif (!HeapTupleIsValid(opertup))\n\t\t\t\t\t\telog(ERROR, \"cache lookup failed for operator %u\",\n\t\t\t\t\t\t\t operid);\n\t\t\t\t\toperform = (Form_pg_operator) GETSTRUCT(opertup);\n\t\t\t\t\toprname = pstrdup(NameStr(operform->oprname));\n\t\t\t\t\t\/* For simplicity we always schema-qualify the op name *\/\n\t\t\t\t\tnspname = get_namespace_name(operform->oprnamespace);\n\t\t\t\t\tnamelist = list_make2(makeString(nspname),\n\t\t\t\t\t\t\t\t\t\t  makeString(oprname));\n\t\t\t\t\tindex->excludeOpNames = lappend(index->excludeOpNames,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnamelist);\n\t\t\t\t\tReleaseSysCache(opertup);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tReleaseSysCache(ht_constr);\n\t\t}\n\t\telse\n\t\t\tindex->isconstraint = false;\n\t}\n\telse\n\t\tindex->isconstraint = false;\n\n\t\/* Get the index expressions, if any *\/\n\tdatum = SysCacheGetAttr(INDEXRELID, ht_idx,\n\t\t\t\t\t\t\tAnum_pg_index_indexprs, &isnull);\n\tif (!isnull)\n\t{\n\t\tchar\t   *exprsString;\n\n\t\texprsString = TextDatumGetCString(datum);\n\t\tindexprs = (List *) stringToNode(exprsString);\n\t}\n\telse\n\t\tindexprs = NIL;\n\n\t\/* Build the list of IndexElem *\/\n\tindex->indexParams = NIL;\n\n\tindexpr_item = list_head(indexprs);\n\tfor (keyno = 0; keyno < idxrec->indnatts; keyno++)\n\t{\n\t\tIndexElem  *iparam;\n\t\tAttrNumber\tattnum = idxrec->indkey.values[keyno];\n\t\tint16\t\topt = source_idx->rd_indoption[keyno];\n\n\t\tiparam = makeNode(IndexElem);\n\n\t\tif (AttributeNumberIsValid(attnum))\n\t\t{\n\t\t\t\/* Simple index column *\/\n\t\t\tchar\t   *attname;\n\n\t\t\tattname = get_relid_attribute_name(indrelid, attnum);\n\t\t\tkeycoltype = get_atttype(indrelid, attnum);\n\n\t\t\tiparam->name = attname;\n\t\t\tiparam->expr = NULL;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\/* Expressional index *\/\n\t\t\tNode\t   *indexkey;\n\t\t\tbool\t\tfound_whole_row;\n\n\t\t\tif (indexpr_item == NULL)\n\t\t\t\telog(ERROR, \"too few entries in indexprs list\");\n\t\t\tindexkey = (Node *) lfirst(indexpr_item);\n\t\t\tindexpr_item = lnext(indexpr_item);\n\n\t\t\t\/* Adjust Vars to match new table's column numbering *\/\n\t\t\tindexkey = map_variable_attnos(indexkey,\n\t\t\t\t\t\t\t\t\t\t   1, 0,\n\t\t\t\t\t\t\t\t\t\t   attmap, attmap_length,\n\t\t\t\t\t\t\t\t\t\t   &found_whole_row);\n\n\t\t\t\/* As in transformTableLikeClause, reject whole-row variables *\/\n\t\t\tif (found_whole_row)\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t\t errmsg(\"cannot convert whole-row table reference\"),\n\t\t\t\t\t\t errdetail(\"Index \\\"%s\\\" contains a whole-row table reference.\",\n\t\t\t\t\t\t\t\t   RelationGetRelationName(source_idx))));\n\n\t\t\tiparam->name = NULL;\n\t\t\tiparam->expr = indexkey;\n\n\t\t\tkeycoltype = exprType(indexkey);\n\t\t}\n\n\t\t\/* Copy the original index column name *\/\n\t\tiparam->indexcolname = pstrdup(NameStr(attrs[keyno]->attname));\n\n\t\t\/* Add the collation name, if non-default *\/\n\t\tiparam->collation = get_collation(indcollation->values[keyno], keycoltype);\n\n\t\t\/* Add the operator class name, if non-default *\/\n\t\tiparam->opclass = get_opclass(indclass->values[keyno], keycoltype);\n\n\t\tiparam->ordering = SORTBY_DEFAULT;\n\t\tiparam->nulls_ordering = SORTBY_NULLS_DEFAULT;\n\n\t\t\/* Adjust options if necessary *\/\n\t\tif (amrec->amcanorder)\n\t\t{\n\t\t\t\/*\n\t\t\t * If it supports sort ordering, copy DESC and NULLS opts. Don't\n\t\t\t * set non-default settings unnecessarily, though, so as to\n\t\t\t * improve the chance of recognizing equivalence to constraint\n\t\t\t * indexes.\n\t\t\t *\/\n\t\t\tif (opt & INDOPTION_DESC)\n\t\t\t{\n\t\t\t\tiparam->ordering = SORTBY_DESC;\n\t\t\t\tif ((opt & INDOPTION_NULLS_FIRST) == 0)\n\t\t\t\t\tiparam->nulls_ordering = SORTBY_NULLS_LAST;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (opt & INDOPTION_NULLS_FIRST)\n\t\t\t\t\tiparam->nulls_ordering = SORTBY_NULLS_FIRST;\n\t\t\t}\n\t\t}\n\n\t\tindex->indexParams = lappend(index->indexParams, iparam);\n\t}\n\n\t\/* Copy reloptions if any *\/\n\tdatum = SysCacheGetAttr(RELOID, ht_idxrel,\n\t\t\t\t\t\t\tAnum_pg_class_reloptions, &isnull);\n\tif (!isnull)\n\t\tindex->options = untransformRelOptions(datum);\n\n\t\/* If it's a partial index, decompile and append the predicate *\/\n\tdatum = SysCacheGetAttr(INDEXRELID, ht_idx,\n\t\t\t\t\t\t\tAnum_pg_index_indpred, &isnull);\n\tif (!isnull)\n\t{\n\t\tchar\t   *pred_str;\n\t\tNode\t   *pred_tree;\n\t\tbool\t\tfound_whole_row;\n\n\t\t\/* Convert text string to node tree *\/\n\t\tpred_str = TextDatumGetCString(datum);\n\t\tpred_tree = (Node *) stringToNode(pred_str);\n\n\t\t\/* Adjust Vars to match new table's column numbering *\/\n\t\tpred_tree = map_variable_attnos(pred_tree,\n\t\t\t\t\t\t\t\t\t\t1, 0,\n\t\t\t\t\t\t\t\t\t\tattmap, attmap_length,\n\t\t\t\t\t\t\t\t\t\t&found_whole_row);\n\n\t\t\/* As in transformTableLikeClause, reject whole-row variables *\/\n\t\tif (found_whole_row)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"cannot convert whole-row table reference\"),\n\t\t\t  errdetail(\"Index \\\"%s\\\" contains a whole-row table reference.\",\n\t\t\t\t\t\tRelationGetRelationName(source_idx))));\n\n\t\tindex->whereClause = pred_tree;\n\t}\n\n\t\/* Clean up *\/\n\tReleaseSysCache(ht_idxrel);\n\n\treturn index;\n}","target":0,"code_token_length":2446,"total_token_length":2682,"max_tokens_setting":4096}
+{"idx":492034,"func":"int LibRaw::unpack(void)\n{\n  CHECK_ORDER_HIGH(LIBRAW_PROGRESS_LOAD_RAW);\n  CHECK_ORDER_LOW(LIBRAW_PROGRESS_IDENTIFY);\n  try {\n\n    if(!libraw_internal_data.internal_data.input)\n      return LIBRAW_INPUT_CLOSED;\n\n    RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,0,2);\n    if (O.shot_select >= P1.raw_count)\n      return LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE;\n\n    if(!load_raw)\n      return LIBRAW_UNSPECIFIED_ERROR;\n\n    \/\/ already allocated ?\n    if(imgdata.image)\n      {\n        free(imgdata.image);\n        imgdata.image = 0;\n      }\n    if(imgdata.rawdata.raw_alloc)\n      {\n        free(imgdata.rawdata.raw_alloc);\n        imgdata.rawdata.raw_alloc = 0;\n      }\n    if (libraw_internal_data.unpacker_data.meta_length)\n      {\n        libraw_internal_data.internal_data.meta_data =\n          (char *) malloc (libraw_internal_data.unpacker_data.meta_length);\n        merror (libraw_internal_data.internal_data.meta_data, \"LibRaw::unpack()\");\n      }\n\n    libraw_decoder_info_t decoder_info;\n    get_decoder_info(&decoder_info);\n\n    int save_iwidth = S.iwidth, save_iheight = S.iheight, save_shrink = IO.shrink;\n\n    int rwidth = S.raw_width, rheight = S.raw_height;\n    if( !IO.fuji_width)\n      {\n        \/\/ adjust non-Fuji allocation\n        if(rwidth < S.width + S.left_margin)\n          rwidth = S.width + S.left_margin;\n        if(rheight < S.height + S.top_margin)\n          rheight = S.height + S.top_margin;\n      }\n\n    imgdata.rawdata.raw_image = 0;\n    imgdata.rawdata.color4_image = 0;\n    imgdata.rawdata.color3_image = 0;\n\timgdata.rawdata.float_image = 0;\n\timgdata.rawdata.float3_image = 0;\n\n#ifdef USE_DNGSDK\n\tif(imgdata.idata.dng_version && dnghost && valid_for_dngsdk() && load_raw != &LibRaw::pentax_4shot_load_raw)\n\t{\n\t\tint rr = try_dngsdk();\n\t}\n#endif\n\n#ifdef USE_RAWSPEED\n\tif(!raw_was_read())\n\t{\n\t\tint rawspeed_enabled = 1;\n\n\t\tif(imgdata.idata.dng_version && libraw_internal_data.unpacker_data.tiff_samples == 2)\n\t\t\trawspeed_enabled = 0;\n\n\t\tif(imgdata.idata.raw_count > 1)\n\t\t\trawspeed_enabled = 0;\n\n\t\t\/\/ Disable rawspeed for double-sized Oly files\n\t\tif(!strncasecmp(imgdata.idata.make,\"Olympus\",7) &&\n\t\t\t( ( imgdata.sizes.raw_width > 6000) || !strncasecmp(imgdata.idata.model,\"SH-2\",4) || !strncasecmp(imgdata.idata.model,\"SH-3\",4) || !strncasecmp(imgdata.idata.model,\"TG-4\",4))\n\t\t\t)\n\t\t\trawspeed_enabled = 0;\n\n\t\tif(imgdata.idata.dng_version && imgdata.idata.filters==0 && libraw_internal_data.unpacker_data.tiff_bps == 8) \/\/ Disable for 8 bit\n\t\t\trawspeed_enabled = 0;\n\n\t\tif(load_raw == &LibRaw::packed_load_raw && !strncasecmp(imgdata.idata.make,\"Nikon\",5) && !strncasecmp(imgdata.idata.model,\"E\",1) )\n\t\t\trawspeed_enabled = 0;\n\n\t\t\/\/ RawSpeed Supported,\n\t\tif(O.use_rawspeed  && rawspeed_enabled\n\t\t\t&& !(is_sraw() && (O.raw_processing_options & (LIBRAW_PROCESSING_SRAW_NO_RGB | LIBRAW_PROCESSING_SRAW_NO_INTERPOLATE)))\n\t\t\t&& (decoder_info.decoder_flags & LIBRAW_DECODER_TRYRAWSPEED) && _rawspeed_camerameta)\n\t\t{\n\t\t\tint rr = try_rawspeed();\n\t\t}\n\t}\n#endif\n    if(!raw_was_read()) \/\/RawSpeed failed or not run\n      {\n        \/\/ Not allocated on RawSpeed call, try call LibRaow\n\t\tint zero_rawimage = 0;\n        if(decoder_info.decoder_flags &  LIBRAW_DECODER_OWNALLOC)\n          {\n            \/\/ x3f foveon decoder and DNG float\n            \/\/ Do nothing! Decoder will allocate data internally\n          }\n        else if(imgdata.idata.filters || P1.colors == 1) \/\/ Bayer image or single color -> decode to raw_image\n          {\n            imgdata.rawdata.raw_alloc = malloc(rwidth*(rheight+8)*sizeof(imgdata.rawdata.raw_image[0]));\n            imgdata.rawdata.raw_image = (ushort*) imgdata.rawdata.raw_alloc;\n            if(!S.raw_pitch)\n                S.raw_pitch = S.raw_width*2; \/\/ Bayer case, not set before\n          }\n        else \/\/ NO LEGACY FLAG if (decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)\n          {\n            \/\/ sRAW and old Foveon decoders only, so extra buffer size is just 1\/4\n            S.iwidth = S.width;\n            S.iheight= S.height;\n            IO.shrink = 0;\n\t\t\tif(!S.raw_pitch)\n\t\t\t\tS.raw_pitch = (decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY_WITH_MARGINS) ? S.raw_width*8 : S.width*8;\n            \/\/ allocate image as temporary buffer, size\n            imgdata.rawdata.raw_alloc = 0;\n            imgdata.image = (ushort (*)[4]) calloc(unsigned(MAX(S.width,S.raw_width))*unsigned(MAX(S.height,S.raw_height)),sizeof(*imgdata.image));\n\t\t\tif(!(decoder_info.decoder_flags &  LIBRAW_DECODER_ADOBECOPYPIXEL))\n\t\t\t{\n\t\t\t\timgdata.rawdata.raw_image = (ushort*) imgdata.image ;\n\t\t\t\tzero_rawimage = 1;\n\t\t\t}\n          }\n        ID.input->seek(libraw_internal_data.unpacker_data.data_offset, SEEK_SET);\n\n        unsigned m_save = C.maximum;\n        if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,\"Nikon\"))\n          C.maximum=65535;\n        (this->*load_raw)();\n\t\tif(zero_rawimage)\n\t\t\timgdata.rawdata.raw_image = 0;\n        if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,\"Nikon\"))\n          C.maximum = m_save;\n        if(decoder_info.decoder_flags &  LIBRAW_DECODER_OWNALLOC)\n          {\n            \/\/ x3f foveon decoder only: do nothing\n\n          }\n        else if (!(imgdata.idata.filters || P1.colors == 1) ) \/\/ legacy decoder, ownalloc handled above\n          {\n            \/\/ successfully decoded legacy image, attach image to raw_alloc\n            imgdata.rawdata.raw_alloc = imgdata.image;\n\t\t    imgdata.rawdata.color4_image = (ushort (*)[4]) imgdata.rawdata.raw_alloc;\n            imgdata.image = 0;\n            \/\/ Restore saved values. Note: Foveon have masked frame\n            \/\/ Other 4-color legacy data: no borders\n\t\t\tif(!(libraw_internal_data.unpacker_data.load_flags & 256))\n\t\t\t{\n\t\t\t\tS.raw_width = S.width;\n\t\t\t\tS.left_margin = 0;\n\t\t\t\tS.raw_height = S.height;\n\t\t\t\tS.top_margin = 0;\n\t\t\t}\n          }\n      }\n\n    if(imgdata.rawdata.raw_image)\n      crop_masked_pixels(); \/\/ calculate black levels\n\n    \/\/ recover image sizes\n    S.iwidth = save_iwidth;\n    S.iheight = save_iheight;\n    IO.shrink = save_shrink;\n\n    \/\/ adjust black to possible maximum\n    unsigned int i = C.cblack[3];\n    unsigned int c;\n    for(c=0;c<3;c++)\n      if (i > C.cblack[c]) i = C.cblack[c];\n    for (c=0;c<4;c++)\n      C.cblack[c] -= i;\n    C.black += i;\n\n    \/\/ Save color,sizes and internal data into raw_image fields\n    memmove(&imgdata.rawdata.color,&imgdata.color,sizeof(imgdata.color));\n    memmove(&imgdata.rawdata.sizes,&imgdata.sizes,sizeof(imgdata.sizes));\n    memmove(&imgdata.rawdata.iparams,&imgdata.idata,sizeof(imgdata.idata));\n    memmove(&imgdata.rawdata.ioparams,&libraw_internal_data.internal_output_params,sizeof(libraw_internal_data.internal_output_params));\n\n    SET_PROC_FLAG(LIBRAW_PROGRESS_LOAD_RAW);\n    RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,1,2);\n\n    return 0;\n  }\n  catch ( LibRaw_exceptions err) {\n    EXCEPTION_HANDLER(err);\n  }\n  catch (std::exception ee) {\n    EXCEPTION_HANDLER(LIBRAW_EXCEPTION_IO_CORRUPT);\n  }\n}","target":0,"code_token_length":1905,"total_token_length":2141,"max_tokens_setting":4096}
+{"idx":86742,"func":"cupsdAcceptClient(cupsd_listener_t *lis)\/* I - Listener socket *\/\n{\n  const char\t\t*hostname;\t\/* Hostname of client *\/\n  char\t\t\tname[256];\t\/* Hostname of client *\/\n  int\t\t\tcount;\t\t\/* Count of connections on a host *\/\n  cupsd_client_t\t*con,\t\t\/* New client pointer *\/\n\t\t\t*tempcon;\t\/* Temporary client pointer *\/\n  socklen_t\t\taddrlen;\t\/* Length of address *\/\n  http_addr_t\t\ttemp;\t\t\/* Temporary address variable *\/\n  static time_t\t\tlast_dos = 0;\t\/* Time of last DoS attack *\/\n#ifdef HAVE_TCPD_H\n  struct request_info\twrap_req;\t\/* TCP wrappers request information *\/\n#endif \/* HAVE_TCPD_H *\/\n\n\n  cupsdLogMessage(CUPSD_LOG_DEBUG2, \"cupsdAcceptClient(lis=%p(%d)) Clients=%d\", lis, lis->fd, cupsArrayCount(Clients));\n\n \/*\n  * Make sure we don't have a full set of clients already...\n  *\/\n\n  if (cupsArrayCount(Clients) == MaxClients)\n    return;\n\n \/*\n  * Get a pointer to the next available client...\n  *\/\n\n  if (!Clients)\n    Clients = cupsArrayNew(NULL, NULL);\n\n  if (!Clients)\n  {\n    cupsdLogMessage(CUPSD_LOG_ERROR,\n                    \"Unable to allocate memory for clients array!\");\n    cupsdPauseListening();\n    return;\n  }\n\n  if (!ActiveClients)\n    ActiveClients = cupsArrayNew((cups_array_func_t)compare_clients, NULL);\n\n  if (!ActiveClients)\n  {\n    cupsdLogMessage(CUPSD_LOG_ERROR,\n                    \"Unable to allocate memory for active clients array!\");\n    cupsdPauseListening();\n    return;\n  }\n\n  if ((con = calloc(1, sizeof(cupsd_client_t))) == NULL)\n  {\n    cupsdLogMessage(CUPSD_LOG_ERROR, \"Unable to allocate memory for client!\");\n    cupsdPauseListening();\n    return;\n  }\n\n \/*\n  * Accept the client and get the remote address...\n  *\/\n\n  con->number = ++ LastClientNumber;\n  con->file   = -1;\n\n  if ((con->http = httpAcceptConnection(lis->fd, 0)) == NULL)\n  {\n    if (errno == ENFILE || errno == EMFILE)\n      cupsdPauseListening();\n\n    cupsdLogMessage(CUPSD_LOG_ERROR, \"Unable to accept client connection - %s.\",\n                    strerror(errno));\n    free(con);\n\n    return;\n  }\n\n \/*\n  * Save the connected address and port number...\n  *\/\n\n  addrlen = sizeof(con->clientaddr);\n\n  if (getsockname(httpGetFd(con->http), (struct sockaddr *)&con->clientaddr, &addrlen) || addrlen == 0)\n    con->clientaddr = lis->address;\n\n  cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Server address is \\\"%s\\\".\", httpAddrString(&con->clientaddr, name, sizeof(name)));\n\n \/*\n  * Check the number of clients on the same address...\n  *\/\n\n  for (count = 0, tempcon = (cupsd_client_t *)cupsArrayFirst(Clients);\n       tempcon;\n       tempcon = (cupsd_client_t *)cupsArrayNext(Clients))\n    if (httpAddrEqual(httpGetAddress(tempcon->http), httpGetAddress(con->http)))\n    {\n      count ++;\n      if (count >= MaxClientsPerHost)\n\tbreak;\n    }\n\n  if (count >= MaxClientsPerHost)\n  {\n    if ((time(NULL) - last_dos) >= 60)\n    {\n      last_dos = time(NULL);\n      cupsdLogMessage(CUPSD_LOG_WARN,\n                      \"Possible DoS attack - more than %d clients connecting \"\n\t\t      \"from %s.\",\n\t              MaxClientsPerHost,\n\t\t      httpGetHostname(con->http, name, sizeof(name)));\n    }\n\n    httpClose(con->http);\n    free(con);\n    return;\n  }\n\n \/*\n  * Get the hostname or format the IP address as needed...\n  *\/\n\n  if (HostNameLookups)\n    hostname = httpResolveHostname(con->http, NULL, 0);\n  else\n    hostname = httpGetHostname(con->http, NULL, 0);\n\n  if (hostname == NULL && HostNameLookups == 2)\n  {\n   \/*\n    * Can't have an unresolved IP address with double-lookups enabled...\n    *\/\n\n    httpClose(con->http);\n\n    cupsdLogClient(con, CUPSD_LOG_WARN,\n                    \"Name lookup failed - connection from %s closed!\",\n                    httpGetHostname(con->http, NULL, 0));\n\n    free(con);\n    return;\n  }\n\n  if (HostNameLookups == 2)\n  {\n   \/*\n    * Do double lookups as needed...\n    *\/\n\n    http_addrlist_t\t*addrlist,\t\/* List of addresses *\/\n\t\t\t*addr;\t\t\/* Current address *\/\n\n    if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, NULL)) != NULL)\n    {\n     \/*\n      * See if the hostname maps to the same IP address...\n      *\/\n\n      for (addr = addrlist; addr; addr = addr->next)\n        if (httpAddrEqual(httpGetAddress(con->http), &(addr->addr)))\n          break;\n    }\n    else\n      addr = NULL;\n\n    httpAddrFreeList(addrlist);\n\n    if (!addr)\n    {\n     \/*\n      * Can't have a hostname that doesn't resolve to the same IP address\n      * with double-lookups enabled...\n      *\/\n\n      httpClose(con->http);\n\n      cupsdLogClient(con, CUPSD_LOG_WARN,\n                      \"IP lookup failed - connection from %s closed!\",\n                      httpGetHostname(con->http, NULL, 0));\n      free(con);\n      return;\n    }\n  }\n\n#ifdef HAVE_TCPD_H\n \/*\n  * See if the connection is denied by TCP wrappers...\n  *\/\n\n  request_init(&wrap_req, RQ_DAEMON, \"cupsd\", RQ_FILE, httpGetFd(con->http),\n               NULL);\n  fromhost(&wrap_req);\n\n  if (!hosts_access(&wrap_req))\n  {\n    httpClose(con->http);\n\n    cupsdLogClient(con, CUPSD_LOG_WARN,\n                    \"Connection from %s refused by \/etc\/hosts.allow and \"\n\t\t    \"\/etc\/hosts.deny rules.\", httpGetHostname(con->http, NULL, 0));\n    free(con);\n    return;\n  }\n#endif \/* HAVE_TCPD_H *\/\n\n#ifdef AF_LOCAL\n  if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL)\n  {\n#  ifdef __APPLE__\n    socklen_t\tpeersize;\t\t\/* Size of peer credentials *\/\n    pid_t\tpeerpid;\t\t\/* Peer process ID *\/\n    char\tpeername[256];\t\t\/* Name of process *\/\n\n    peersize = sizeof(peerpid);\n    if (!getsockopt(httpGetFd(con->http), SOL_LOCAL, LOCAL_PEERPID, &peerpid,\n                    &peersize))\n    {\n      if (!proc_name((int)peerpid, peername, sizeof(peername)))\n\tcupsdLogClient(con, CUPSD_LOG_DEBUG,\n\t               \"Accepted from %s (Domain ???[%d])\",\n                       httpGetHostname(con->http, NULL, 0), (int)peerpid);\n      else\n\tcupsdLogClient(con, CUPSD_LOG_DEBUG,\n                       \"Accepted from %s (Domain %s[%d])\",\n                       httpGetHostname(con->http, NULL, 0), peername, (int)peerpid);\n    }\n    else\n#  endif \/* __APPLE__ *\/\n\n    cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Accepted from %s (Domain)\",\n                   httpGetHostname(con->http, NULL, 0));\n  }\n  else\n#endif \/* AF_LOCAL *\/\n  cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Accepted from %s:%d (IPv%d)\",\n                 httpGetHostname(con->http, NULL, 0),\n\t\t httpAddrPort(httpGetAddress(con->http)),\n\t\t httpAddrFamily(httpGetAddress(con->http)) == AF_INET ? 4 : 6);\n\n \/*\n  * Get the local address the client connected to...\n  *\/\n\n  addrlen = sizeof(temp);\n  if (getsockname(httpGetFd(con->http), (struct sockaddr *)&temp, &addrlen))\n  {\n    cupsdLogClient(con, CUPSD_LOG_ERROR, \"Unable to get local address - %s\",\n                   strerror(errno));\n\n    strlcpy(con->servername, \"localhost\", sizeof(con->servername));\n    con->serverport = LocalPort;\n  }\n#ifdef AF_LOCAL\n  else if (httpAddrFamily(&temp) == AF_LOCAL)\n  {\n    strlcpy(con->servername, \"localhost\", sizeof(con->servername));\n    con->serverport = LocalPort;\n  }\n#endif \/* AF_LOCAL *\/\n  else\n  {\n    if (httpAddrLocalhost(&temp))\n      strlcpy(con->servername, \"localhost\", sizeof(con->servername));\n    else if (HostNameLookups)\n      httpAddrLookup(&temp, con->servername, sizeof(con->servername));\n    else\n      httpAddrString(&temp, con->servername, sizeof(con->servername));\n\n    con->serverport = httpAddrPort(&(lis->address));\n  }\n\n \/*\n  * Add the connection to the array of active clients...\n  *\/\n\n  cupsArrayAdd(Clients, con);\n\n \/*\n  * Add the socket to the server select.\n  *\/\n\n  cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient, NULL,\n                 con);\n\n  cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Waiting for request.\");\n\n \/*\n  * Temporarily suspend accept()'s until we lose a client...\n  *\/\n\n  if (cupsArrayCount(Clients) == MaxClients)\n    cupsdPauseListening();\n\n#ifdef HAVE_SSL\n \/*\n  * See if we are connecting on a secure port...\n  *\/\n\n  if (lis->encryption == HTTP_ENCRYPTION_ALWAYS)\n  {\n   \/*\n    * https connection; go secure...\n    *\/\n\n    if (cupsd_start_tls(con, HTTP_ENCRYPTION_ALWAYS))\n      cupsdCloseClient(con);\n  }\n  else\n    con->auto_ssl = 1;\n#endif \/* HAVE_SSL *\/\n}","target":0,"code_token_length":2189,"total_token_length":2425,"max_tokens_setting":4096}
+{"idx":184199,"func":"int ssl3_get_record(SSL *s)\n{\n    int ssl_major, ssl_minor, al;\n    int enc_err, n, i, ret = -1;\n    SSL3_RECORD *rr;\n    SSL3_BUFFER *rbuf;\n    SSL_SESSION *sess;\n    unsigned char *p;\n    unsigned char md[EVP_MAX_MD_SIZE];\n    short version;\n    unsigned mac_size;\n    unsigned int num_recs = 0;\n    unsigned int max_recs;\n    unsigned int j;\n\n    rr = RECORD_LAYER_get_rrec(&s->rlayer);\n    rbuf = RECORD_LAYER_get_rbuf(&s->rlayer);\n    max_recs = s->max_pipelines;\n    if (max_recs == 0)\n        max_recs = 1;\n    sess = s->session;\n\n    do {\n        \/* check if we have the header *\/\n        if ((RECORD_LAYER_get_rstate(&s->rlayer) != SSL_ST_READ_BODY) ||\n            (RECORD_LAYER_get_packet_length(&s->rlayer)\n             < SSL3_RT_HEADER_LENGTH)) {\n            n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH,\n                            SSL3_BUFFER_get_len(rbuf), 0,\n                            num_recs == 0 ? 1 : 0);\n            if (n <= 0)\n                return (n);     \/* error or non-blocking *\/\n            RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_BODY);\n\n            p = RECORD_LAYER_get_packet(&s->rlayer);\n\n            \/*\n             * The first record received by the server may be a V2ClientHello.\n             *\/\n            if (s->server && RECORD_LAYER_is_first_record(&s->rlayer)\n                && (p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) {\n                \/*\n                 *  SSLv2 style record\n                 *\n                 * |num_recs| here will actually always be 0 because\n                 * |num_recs > 0| only ever occurs when we are processing\n                 * multiple app data records - which we know isn't the case here\n                 * because it is an SSLv2ClientHello. We keep it using\n                 * |num_recs| for the sake of consistency\n                 *\/\n                rr[num_recs].type = SSL3_RT_HANDSHAKE;\n                rr[num_recs].rec_version = SSL2_VERSION;\n\n                rr[num_recs].length = ((p[0] & 0x7f) << 8) | p[1];\n\n                if (rr[num_recs].length > SSL3_BUFFER_get_len(rbuf)\n                    - SSL2_RT_HEADER_LENGTH) {\n                    al = SSL_AD_RECORD_OVERFLOW;\n                    SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG);\n                    goto f_err;\n                }\n\n                if (rr[num_recs].length < MIN_SSL2_RECORD_LEN) {\n                    al = SSL_AD_HANDSHAKE_FAILURE;\n                    SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT);\n                    goto f_err;\n                }\n            } else {\n                \/* SSLv3+ style record *\/\n                if (s->msg_callback)\n                    s->msg_callback(0, 0, SSL3_RT_HEADER, p, 5, s,\n                                    s->msg_callback_arg);\n\n                \/* Pull apart the header into the SSL3_RECORD *\/\n                rr[num_recs].type = *(p++);\n                ssl_major = *(p++);\n                ssl_minor = *(p++);\n                version = (ssl_major << 8) | ssl_minor;\n                rr[num_recs].rec_version = version;\n                n2s(p, rr[num_recs].length);\n\n                \/* Lets check version *\/\n                if (!s->first_packet && version != s->version) {\n                    SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);\n                    if ((s->version & 0xFF00) == (version & 0xFF00)\n                        && !s->enc_write_ctx && !s->write_hash) {\n                        if (rr->type == SSL3_RT_ALERT) {\n                            \/*\n                             * The record is using an incorrect version number,\n                             * but what we've got appears to be an alert. We\n                             * haven't read the body yet to check whether its a\n                             * fatal or not - but chances are it is. We probably\n                             * shouldn't send a fatal alert back. We'll just\n                             * end.\n                             *\/\n                            goto err;\n                        }\n                        \/*\n                         * Send back error using their minor version number :-)\n                         *\/\n                        s->version = (unsigned short)version;\n                    }\n                    al = SSL_AD_PROTOCOL_VERSION;\n                    goto f_err;\n                }\n\n                if ((version >> 8) != SSL3_VERSION_MAJOR) {\n                    if (RECORD_LAYER_is_first_record(&s->rlayer)) {\n                        \/* Go back to start of packet, look at the five bytes\n                         * that we have. *\/\n                        p = RECORD_LAYER_get_packet(&s->rlayer);\n                        if (strncmp((char *)p, \"GET \", 4) == 0 ||\n                            strncmp((char *)p, \"POST \", 5) == 0 ||\n                            strncmp((char *)p, \"HEAD \", 5) == 0 ||\n                            strncmp((char *)p, \"PUT \", 4) == 0) {\n                            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_HTTP_REQUEST);\n                            goto err;\n                        } else if (strncmp((char *)p, \"CONNE\", 5) == 0) {\n                            SSLerr(SSL_F_SSL3_GET_RECORD,\n                                   SSL_R_HTTPS_PROXY_REQUEST);\n                            goto err;\n                        }\n\n                        \/* Doesn't look like TLS - don't send an alert *\/\n                        SSLerr(SSL_F_SSL3_GET_RECORD,\n                               SSL_R_WRONG_VERSION_NUMBER);\n                        goto err;\n                    } else {\n                        SSLerr(SSL_F_SSL3_GET_RECORD,\n                               SSL_R_WRONG_VERSION_NUMBER);\n                        al = SSL_AD_PROTOCOL_VERSION;\n                        goto f_err;\n                    }\n                }\n\n                if (rr[num_recs].length >\n                    SSL3_BUFFER_get_len(rbuf) - SSL3_RT_HEADER_LENGTH) {\n                    al = SSL_AD_RECORD_OVERFLOW;\n                    SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG);\n                    goto f_err;\n                }\n            }\n\n            \/* now s->rlayer.rstate == SSL_ST_READ_BODY *\/\n        }\n\n        \/*\n         * s->rlayer.rstate == SSL_ST_READ_BODY, get and decode the data.\n         * Calculate how much more data we need to read for the rest of the\n         * record\n         *\/\n        if (rr[num_recs].rec_version == SSL2_VERSION) {\n            i = rr[num_recs].length + SSL2_RT_HEADER_LENGTH\n                - SSL3_RT_HEADER_LENGTH;\n        } else {\n            i = rr[num_recs].length;\n        }\n        if (i > 0) {\n            \/* now s->packet_length == SSL3_RT_HEADER_LENGTH *\/\n\n            n = ssl3_read_n(s, i, i, 1, 0);\n            if (n <= 0)\n                return (n);     \/* error or non-blocking io *\/\n        }\n\n        \/* set state for later operations *\/\n        RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_HEADER);\n\n        \/*\n         * At this point, s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length,\n         * or s->packet_length == SSL2_RT_HEADER_LENGTH + rr->length\n         * and we have that many bytes in s->packet\n         *\/\n        if (rr[num_recs].rec_version == SSL2_VERSION) {\n            rr[num_recs].input =\n                &(RECORD_LAYER_get_packet(&s->rlayer)[SSL2_RT_HEADER_LENGTH]);\n        } else {\n            rr[num_recs].input =\n                &(RECORD_LAYER_get_packet(&s->rlayer)[SSL3_RT_HEADER_LENGTH]);\n        }\n\n        \/*\n         * ok, we can now read from 's->packet' data into 'rr' rr->input points\n         * at rr->length bytes, which need to be copied into rr->data by either\n         * the decryption or by the decompression When the data is 'copied' into\n         * the rr->data buffer, rr->input will be pointed at the new buffer\n         *\/\n\n        \/*\n         * We now have - encrypted [ MAC [ compressed [ plain ] ] ] rr->length\n         * bytes of encrypted compressed stuff.\n         *\/\n\n        \/* check is not needed I believe *\/\n        if (rr[num_recs].length > SSL3_RT_MAX_ENCRYPTED_LENGTH) {\n            al = SSL_AD_RECORD_OVERFLOW;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_ENCRYPTED_LENGTH_TOO_LONG);\n            goto f_err;\n        }\n\n        \/* decrypt in place in 'rr->input' *\/\n        rr[num_recs].data = rr[num_recs].input;\n        rr[num_recs].orig_len = rr[num_recs].length;\n\n        \/* Mark this record as not read by upper layers yet *\/\n        rr[num_recs].read = 0;\n\n        num_recs++;\n\n        \/* we have pulled in a full packet so zero things *\/\n        RECORD_LAYER_reset_packet_length(&s->rlayer);\n        RECORD_LAYER_clear_first_record(&s->rlayer);\n    } while (num_recs < max_recs\n             && rr[num_recs - 1].type == SSL3_RT_APPLICATION_DATA\n             && SSL_USE_EXPLICIT_IV(s)\n             && s->enc_read_ctx != NULL\n             && (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(s->enc_read_ctx))\n                 & EVP_CIPH_FLAG_PIPELINE)\n             && ssl3_record_app_data_waiting(s));\n\n    \/*\n      * If in encrypt-then-mac mode calculate mac from encrypted record. All\n      * the details below are public so no timing details can leak.\n      *\/\n    if (SSL_READ_ETM(s) && s->read_hash) {\n         unsigned char *mac;\n         mac_size = EVP_MD_CTX_size(s->read_hash);\n         OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);\n        for (j = 0; j < num_recs; j++) {\n            if (rr[j].length < mac_size) {\n                al = SSL_AD_DECODE_ERROR;\n                SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT);\n                goto f_err;\n            }\n            rr[j].length -= mac_size;\n            mac = rr[j].data + rr[j].length;\n            i = s->method->ssl3_enc->mac(s, &rr[j], md, 0 \/* not send *\/ );\n            if (i < 0 || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0) {\n                al = SSL_AD_BAD_RECORD_MAC;\n                SSLerr(SSL_F_SSL3_GET_RECORD,\n                       SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);\n                goto f_err;\n            }\n        }\n    }\n\n    enc_err = s->method->ssl3_enc->enc(s, rr, num_recs, 0);\n    \/*-\n     * enc_err is:\n     *    0: (in non-constant time) if the record is publically invalid.\n     *    1: if the padding is valid\n     *    -1: if the padding is invalid\n     *\/\n    if (enc_err == 0) {\n        al = SSL_AD_DECRYPTION_FAILED;\n        SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);\n        goto f_err;\n    }\n#ifdef SSL_DEBUG\n    printf(\"dec %d\\n\", rr->length);\n    {\n        unsigned int z;\n        for (z = 0; z < rr->length; z++)\n            printf(\"%02X%c\", rr->data[z], ((z + 1) % 16) ? ' ' : '\\n');\n    }\n    printf(\"\\n\");\n#endif\n\n     \/* r->length is now the compressed data plus mac *\/\n     if ((sess != NULL) &&\n         (s->enc_read_ctx != NULL) &&\n        (!SSL_READ_ETM(s) && EVP_MD_CTX_md(s->read_hash) != NULL)) {\n         \/* s->read_hash != NULL => mac_size != -1 *\/\n         unsigned char *mac = NULL;\n         unsigned char mac_tmp[EVP_MAX_MD_SIZE];\n\n        mac_size = EVP_MD_CTX_size(s->read_hash);\n        OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);\n\n        for (j = 0; j < num_recs; j++) {\n            \/*\n             * orig_len is the length of the record before any padding was\n             * removed. This is public information, as is the MAC in use,\n             * therefore we can safely process the record in a different amount\n             * of time if it's too short to possibly contain a MAC.\n             *\/\n            if (rr[j].orig_len < mac_size ||\n                \/* CBC records must have a padding length byte too. *\/\n                (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&\n                 rr[j].orig_len < mac_size + 1)) {\n                al = SSL_AD_DECODE_ERROR;\n                SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT);\n                goto f_err;\n            }\n\n            if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) {\n                \/*\n                 * We update the length so that the TLS header bytes can be\n                 * constructed correctly but we need to extract the MAC in\n                 * constant time from within the record, without leaking the\n                 * contents of the padding bytes.\n                 *\/\n                mac = mac_tmp;\n                ssl3_cbc_copy_mac(mac_tmp, &rr[j], mac_size);\n                rr[j].length -= mac_size;\n            } else {\n                \/*\n                 * In this case there's no padding, so |rec->orig_len| equals\n                 * |rec->length| and we checked that there's enough bytes for\n                 * |mac_size| above.\n                 *\/\n                rr[j].length -= mac_size;\n                mac = &rr[j].data[rr[j].length];\n            }\n\n            i = s->method->ssl3_enc->mac(s, &rr[j], md, 0 \/* not send *\/ );\n            if (i < 0 || mac == NULL\n                || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)\n                enc_err = -1;\n            if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + mac_size)\n                enc_err = -1;\n        }\n    }\n\n    if (enc_err < 0) {\n        \/*\n         * A separate 'decryption_failed' alert was introduced with TLS 1.0,\n         * SSL 3.0 only has 'bad_record_mac'.  But unless a decryption\n         * failure is directly visible from the ciphertext anyway, we should\n         * not reveal which kind of error occurred -- this might become\n         * visible to an attacker (e.g. via a logfile)\n         *\/\n        al = SSL_AD_BAD_RECORD_MAC;\n        SSLerr(SSL_F_SSL3_GET_RECORD,\n               SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);\n        goto f_err;\n    }\n\n    for (j = 0; j < num_recs; j++) {\n        \/* rr[j].length is now just compressed *\/\n        if (s->expand != NULL) {\n            if (rr[j].length > SSL3_RT_MAX_COMPRESSED_LENGTH) {\n                al = SSL_AD_RECORD_OVERFLOW;\n                SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_COMPRESSED_LENGTH_TOO_LONG);\n                goto f_err;\n            }\n            if (!ssl3_do_uncompress(s, &rr[j])) {\n                al = SSL_AD_DECOMPRESSION_FAILURE;\n                SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BAD_DECOMPRESSION);\n                goto f_err;\n            }\n        }\n\n        if (rr[j].length > SSL3_RT_MAX_PLAIN_LENGTH) {\n            al = SSL_AD_RECORD_OVERFLOW;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DATA_LENGTH_TOO_LONG);\n            goto f_err;\n        }\n\n        rr[j].off = 0;\n        \/*-\n         * So at this point the following is true\n         * rr[j].type   is the type of record\n         * rr[j].length == number of bytes in record\n         * rr[j].off    == offset to first valid byte\n         * rr[j].data   == where to take bytes from, increment after use :-).\n         *\/\n\n        \/* just read a 0 length packet *\/\n        if (rr[j].length == 0) {\n            RECORD_LAYER_inc_empty_record_count(&s->rlayer);\n            if (RECORD_LAYER_get_empty_record_count(&s->rlayer)\n                > MAX_EMPTY_RECORDS) {\n                al = SSL_AD_UNEXPECTED_MESSAGE;\n                SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_RECORD_TOO_SMALL);\n                goto f_err;\n            }\n        } else {\n            RECORD_LAYER_reset_empty_record_count(&s->rlayer);\n        }\n    }\n\n    RECORD_LAYER_set_numrpipes(&s->rlayer, num_recs);\n    return 1;\n\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    return ret;\n}\n","target":0,"code_token_length":3652,"total_token_length":3888,"max_tokens_setting":4096}
+{"idx":488263,"func":"njs_object_prop_define(njs_vm_t *vm, njs_value_t *object,\n    njs_value_t *name, njs_value_t *value, njs_object_prop_define_t type)\n{\n    uint32_t              length;\n    njs_int_t             ret;\n    njs_array_t           *array;\n    njs_object_prop_t     *prop, *prev;\n    njs_property_query_t  pq;\n\n    static const njs_str_t  length_key = njs_str(\"length\");\n\n    if (njs_slow_path(!njs_is_key(name))) {\n        ret = njs_value_to_key(vm, name, name);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n    }\n\nagain:\n\n    njs_property_query_init(&pq, NJS_PROPERTY_QUERY_SET, 1);\n\n    ret = njs_property_query(vm, &pq, object, name);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    prop = njs_object_prop_alloc(vm, name, &njs_value_invalid,\n                                 NJS_ATTRIBUTE_UNSET);\n    if (njs_slow_path(prop == NULL)) {\n        return NJS_ERROR;\n    }\n\n    switch (type) {\n\n    case NJS_OBJECT_PROP_DESCRIPTOR:\n        if (njs_descriptor_prop(vm, prop, value) != NJS_OK) {\n            return NJS_ERROR;\n        }\n\n        break;\n\n    case NJS_OBJECT_PROP_GETTER:\n        prop->getter = *value;\n        njs_set_invalid(&prop->setter);\n        prop->enumerable = NJS_ATTRIBUTE_TRUE;\n        prop->configurable = NJS_ATTRIBUTE_TRUE;\n\n        break;\n\n    case NJS_OBJECT_PROP_SETTER:\n        prop->setter = *value;\n        njs_set_invalid(&prop->getter);\n        prop->enumerable = NJS_ATTRIBUTE_TRUE;\n        prop->configurable = NJS_ATTRIBUTE_TRUE;\n\n        break;\n    }\n\n    if (njs_fast_path(ret == NJS_DECLINED)) {\n\nset_prop:\n\n        if (!njs_object(object)->extensible) {\n            njs_key_string_get(vm, &pq.key,  &pq.lhq.key);\n            njs_type_error(vm, \"Cannot add property \\\"%V\\\", \"\n                           \"object is not extensible\", &pq.lhq.key);\n            return NJS_ERROR;\n        }\n\n        if (njs_slow_path(njs_is_typed_array(object)\n                          && njs_is_string(name)))\n        {\n            \/* Integer-Indexed Exotic Objects [[DefineOwnProperty]]. *\/\n            if (!isnan(njs_string_to_index(name))) {\n                njs_type_error(vm, \"Invalid typed array index\");\n                return NJS_ERROR;\n            }\n        }\n\n        \/* 6.2.5.6 CompletePropertyDescriptor *\/\n\n        if (njs_is_accessor_descriptor(prop)) {\n            if (!njs_is_valid(&prop->getter)) {\n                njs_set_undefined(&prop->getter);\n            }\n\n            if (!njs_is_valid(&prop->setter)) {\n                njs_set_undefined(&prop->setter);\n            }\n\n        } else {\n            if (prop->writable == NJS_ATTRIBUTE_UNSET) {\n                prop->writable = 0;\n            }\n\n            if (!njs_is_valid(&prop->value)) {\n                njs_set_undefined(&prop->value);\n            }\n        }\n\n        if (prop->enumerable == NJS_ATTRIBUTE_UNSET) {\n            prop->enumerable = 0;\n        }\n\n        if (prop->configurable == NJS_ATTRIBUTE_UNSET) {\n            prop->configurable = 0;\n        }\n\n        if (njs_slow_path(pq.lhq.value != NULL)) {\n            prev = pq.lhq.value;\n\n            if (njs_slow_path(prev->type == NJS_WHITEOUT)) {\n                \/* Previously deleted property.  *\/\n                *prev = *prop;\n            }\n\n        } else {\n            pq.lhq.value = prop;\n            pq.lhq.replace = 0;\n            pq.lhq.pool = vm->mem_pool;\n\n            ret = njs_lvlhsh_insert(njs_object_hash(object), &pq.lhq);\n            if (njs_slow_path(ret != NJS_OK)) {\n                njs_internal_error(vm, \"lvlhsh insert failed\");\n                return NJS_ERROR;\n            }\n        }\n\n        return NJS_OK;\n    }\n\n    \/* Updating existing prop. *\/\n\n    prev = pq.lhq.value;\n\n    switch (prev->type) {\n    case NJS_PROPERTY:\n    case NJS_PROPERTY_HANDLER:\n        break;\n\n    case NJS_PROPERTY_REF:\n        if (njs_is_accessor_descriptor(prop)\n            || prop->configurable == NJS_ATTRIBUTE_FALSE\n            || prop->enumerable == NJS_ATTRIBUTE_FALSE\n            || prop->writable == NJS_ATTRIBUTE_FALSE)\n        {\n            array = njs_array(object);\n            length = array->length;\n\n            ret = njs_array_convert_to_slow_array(vm, array);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            ret = njs_array_length_redefine(vm, object, length);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            goto again;\n        }\n\n        if (njs_is_valid(&prop->value)) {\n            *prev->value.data.u.value = prop->value;\n        } else {\n            njs_set_undefined(prev->value.data.u.value);\n        }\n\n        return NJS_OK;\n\n    case NJS_PROPERTY_TYPED_ARRAY_REF:\n        if (njs_is_accessor_descriptor(prop)) {\n            goto exception;\n        }\n\n        if (prop->configurable == NJS_ATTRIBUTE_TRUE ||\n            prop->enumerable == NJS_ATTRIBUTE_FALSE ||\n            prop->writable == NJS_ATTRIBUTE_FALSE)\n        {\n            goto exception;\n        }\n\n        if (njs_is_valid(&prop->value)) {\n            return njs_typed_array_set_value(vm, njs_typed_array(&prev->value),\n                                             prev->value.data.magic32,\n                                             &prop->value);\n        }\n\n        return NJS_OK;\n\n    default:\n        njs_internal_error(vm, \"unexpected property type \\\"%s\\\" \"\n                           \"while defining property\",\n                           njs_prop_type_string(prev->type));\n\n        return NJS_ERROR;\n    }\n\n    \/* 9.1.6.3 ValidateAndApplyPropertyDescriptor *\/\n\n    if (!prev->configurable) {\n\n        if (prop->configurable == NJS_ATTRIBUTE_TRUE) {\n            goto exception;\n        }\n\n        if (prop->enumerable != NJS_ATTRIBUTE_UNSET\n            && prev->enumerable != prop->enumerable)\n        {\n            goto exception;\n        }\n    }\n\n    if (njs_is_generic_descriptor(prop)) {\n        goto done;\n    }\n\n    if (njs_is_data_descriptor(prev) != njs_is_data_descriptor(prop)) {\n        if (!prev->configurable) {\n            goto exception;\n        }\n\n        \/*\n         * 6.b-c Preserve the existing values of the converted property's\n         * [[Configurable]] and [[Enumerable]] attributes and set the rest of\n         * the property's attributes to their default values.\n         *\/\n\n        if (pq.temp) {\n            pq.lhq.value = NULL;\n            prop->configurable = prev->configurable;\n            prop->enumerable = prev->enumerable;\n            goto set_prop;\n        }\n\n        prev->type = prop->type;\n\n        if (njs_is_data_descriptor(prev)) {\n            njs_set_undefined(&prev->getter);\n            njs_set_undefined(&prev->setter);\n\n            njs_set_invalid(&prev->value);\n            prev->writable = NJS_ATTRIBUTE_UNSET;\n\n        } else {\n            njs_set_undefined(&prev->value);\n            prev->writable = NJS_ATTRIBUTE_FALSE;\n\n            njs_set_invalid(&prev->getter);\n            njs_set_invalid(&prev->setter);\n        }\n\n\n    } else if (njs_is_data_descriptor(prev)\n               && njs_is_data_descriptor(prop))\n    {\n        if (!prev->configurable && !prev->writable) {\n            if (prop->writable == NJS_ATTRIBUTE_TRUE) {\n                goto exception;\n            }\n\n            if (njs_is_valid(&prop->value)\n                && prev->type != NJS_PROPERTY_HANDLER\n                && !njs_values_same(&prop->value, &prev->value))\n            {\n                goto exception;\n            }\n        }\n\n    } else {\n        if (!prev->configurable) {\n            if (njs_is_valid(&prop->getter)\n                && !njs_values_strict_equal(&prop->getter, &prev->getter))\n            {\n                goto exception;\n            }\n\n            if (njs_is_valid(&prop->setter)\n                && !njs_values_strict_equal(&prop->setter, &prev->setter))\n            {\n                goto exception;\n            }\n        }\n    }\n\ndone:\n\n    if (njs_is_valid(&prop->value)) {\n        if (prev->type == NJS_PROPERTY_HANDLER) {\n            if (prev->writable) {\n                ret = prev->value.data.u.prop_handler(vm, prev, object,\n                                                      &prop->value,\n                                                      &vm->retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    return ret;\n                }\n\n                if (ret == NJS_DECLINED) {\n                    pq.lhq.value = NULL;\n                    goto set_prop;\n                }\n            }\n\n        } else {\n            if (njs_slow_path(pq.lhq.key_hash == NJS_LENGTH_HASH)) {\n                if (njs_strstr_eq(&pq.lhq.key, &length_key)) {\n                    ret = njs_array_length_set(vm, object, prev, &prop->value);\n                    if (ret != NJS_DECLINED) {\n                        return ret;\n                    }\n                }\n            }\n\n            prev->value = prop->value;\n        }\n    }\n\n    \/*\n     * 9. For each field of Desc that is present, set the corresponding\n     * attribute of the property named P of object O to the value of the field.\n     *\/\n\n    if (njs_is_valid(&prop->getter)) {\n        prev->getter = prop->getter;\n    }\n\n    if (njs_is_valid(&prop->setter)) {\n        prev->setter = prop->setter;\n    }\n\n    if (prop->writable != NJS_ATTRIBUTE_UNSET) {\n        prev->writable = prop->writable;\n    }\n\n    if (prop->enumerable != NJS_ATTRIBUTE_UNSET) {\n        prev->enumerable = prop->enumerable;\n    }\n\n    if (prop->configurable != NJS_ATTRIBUTE_UNSET) {\n        prev->configurable = prop->configurable;\n    }\n\n    return NJS_OK;\n\nexception:\n\n    njs_key_string_get(vm, &pq.key,  &pq.lhq.key);\n    njs_type_error(vm, \"Cannot redefine property: \\\"%V\\\"\", &pq.lhq.key);\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":2287,"total_token_length":2523,"max_tokens_setting":4096}
+{"idx":484398,"func":"std::unique_ptr JBIG2Stream::readGenericRefinementRegion(int w, int h, int templ, bool tpgrOn, JBIG2Bitmap *refBitmap, int refDX, int refDY, int *atx, int *aty)\n{\n    bool ltp;\n    unsigned int ltpCX, cx, cx0, cx2, cx3, cx4, tpgrCX0, tpgrCX1, tpgrCX2;\n    JBIG2BitmapPtr cxPtr0 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr cxPtr1 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr cxPtr2 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr cxPtr3 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr cxPtr4 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr cxPtr5 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr cxPtr6 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr tpgrCXPtr0 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr tpgrCXPtr1 = { nullptr, 0, 0 };\n    JBIG2BitmapPtr tpgrCXPtr2 = { nullptr, 0, 0 };\n    int x, y, pix;\n\n    if (!refBitmap) {\n        return nullptr;\n    }\n\n    auto bitmap = std::make_unique(0, w, h);\n    if (!bitmap->isOk()) {\n        return nullptr;\n    }\n    bitmap->clearToZero();\n\n    \/\/ set up the typical row context\n    if (templ) {\n        ltpCX = 0x008;\n    } else {\n        ltpCX = 0x0010;\n    }\n\n    ltp = false;\n    for (y = 0; y < h; ++y) {\n\n        if (templ) {\n\n            \/\/ set up the context\n            bitmap->getPixelPtr(0, y - 1, &cxPtr0);\n            cx0 = bitmap->nextPixel(&cxPtr0);\n            bitmap->getPixelPtr(-1, y, &cxPtr1);\n            refBitmap->getPixelPtr(-refDX, y - 1 - refDY, &cxPtr2);\n            refBitmap->getPixelPtr(-1 - refDX, y - refDY, &cxPtr3);\n            cx3 = refBitmap->nextPixel(&cxPtr3);\n            cx3 = (cx3 << 1) | refBitmap->nextPixel(&cxPtr3);\n            refBitmap->getPixelPtr(-refDX, y + 1 - refDY, &cxPtr4);\n            cx4 = refBitmap->nextPixel(&cxPtr4);\n\n            \/\/ set up the typical prediction context\n            tpgrCX0 = tpgrCX1 = tpgrCX2 = 0; \/\/ make gcc happy\n            if (tpgrOn) {\n                refBitmap->getPixelPtr(-1 - refDX, y - 1 - refDY, &tpgrCXPtr0);\n                tpgrCX0 = refBitmap->nextPixel(&tpgrCXPtr0);\n                tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0);\n                tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0);\n                refBitmap->getPixelPtr(-1 - refDX, y - refDY, &tpgrCXPtr1);\n                tpgrCX1 = refBitmap->nextPixel(&tpgrCXPtr1);\n                tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1);\n                tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1);\n                refBitmap->getPixelPtr(-1 - refDX, y + 1 - refDY, &tpgrCXPtr2);\n                tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);\n                tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);\n                tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);\n            } else {\n                tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = nullptr; \/\/ make gcc happy\n                tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;\n                tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;\n            }\n\n            for (x = 0; x < w; ++x) {\n\n                \/\/ update the context\n                cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 7;\n                cx3 = ((cx3 << 1) | refBitmap->nextPixel(&cxPtr3)) & 7;\n                cx4 = ((cx4 << 1) | refBitmap->nextPixel(&cxPtr4)) & 3;\n\n                if (tpgrOn) {\n                    \/\/ update the typical predictor context\n                    tpgrCX0 = ((tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0)) & 7;\n                    tpgrCX1 = ((tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1)) & 7;\n                    tpgrCX2 = ((tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2)) & 7;\n\n                    \/\/ check for a \"typical\" pixel\n                    if (arithDecoder->decodeBit(ltpCX, refinementRegionStats)) {\n                        ltp = !ltp;\n                    }\n                    if (tpgrCX0 == 0 && tpgrCX1 == 0 && tpgrCX2 == 0) {\n                        bitmap->clearPixel(x, y);\n                        continue;\n                    } else if (tpgrCX0 == 7 && tpgrCX1 == 7 && tpgrCX2 == 7) {\n                        bitmap->setPixel(x, y);\n                        continue;\n                    }\n                }\n\n                \/\/ build the context\n                cx = (cx0 << 7) | (bitmap->nextPixel(&cxPtr1) << 6) | (refBitmap->nextPixel(&cxPtr2) << 5) | (cx3 << 2) | cx4;\n\n                \/\/ decode the pixel\n                if ((pix = arithDecoder->decodeBit(cx, refinementRegionStats))) {\n                    bitmap->setPixel(x, y);\n                }\n            }\n\n        } else {\n\n            \/\/ set up the context\n            bitmap->getPixelPtr(0, y - 1, &cxPtr0);\n            cx0 = bitmap->nextPixel(&cxPtr0);\n            bitmap->getPixelPtr(-1, y, &cxPtr1);\n            refBitmap->getPixelPtr(-refDX, y - 1 - refDY, &cxPtr2);\n            cx2 = refBitmap->nextPixel(&cxPtr2);\n            refBitmap->getPixelPtr(-1 - refDX, y - refDY, &cxPtr3);\n            cx3 = refBitmap->nextPixel(&cxPtr3);\n            cx3 = (cx3 << 1) | refBitmap->nextPixel(&cxPtr3);\n            refBitmap->getPixelPtr(-1 - refDX, y + 1 - refDY, &cxPtr4);\n            cx4 = refBitmap->nextPixel(&cxPtr4);\n            cx4 = (cx4 << 1) | refBitmap->nextPixel(&cxPtr4);\n            bitmap->getPixelPtr(atx[0], y + aty[0], &cxPtr5);\n            refBitmap->getPixelPtr(atx[1] - refDX, y + aty[1] - refDY, &cxPtr6);\n\n            \/\/ set up the typical prediction context\n            tpgrCX0 = tpgrCX1 = tpgrCX2 = 0; \/\/ make gcc happy\n            if (tpgrOn) {\n                refBitmap->getPixelPtr(-1 - refDX, y - 1 - refDY, &tpgrCXPtr0);\n                tpgrCX0 = refBitmap->nextPixel(&tpgrCXPtr0);\n                tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0);\n                tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0);\n                refBitmap->getPixelPtr(-1 - refDX, y - refDY, &tpgrCXPtr1);\n                tpgrCX1 = refBitmap->nextPixel(&tpgrCXPtr1);\n                tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1);\n                tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1);\n                refBitmap->getPixelPtr(-1 - refDX, y + 1 - refDY, &tpgrCXPtr2);\n                tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);\n                tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);\n                tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);\n            } else {\n                tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = nullptr; \/\/ make gcc happy\n                tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;\n                tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;\n            }\n\n            for (x = 0; x < w; ++x) {\n\n                \/\/ update the context\n                cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 3;\n                cx2 = ((cx2 << 1) | refBitmap->nextPixel(&cxPtr2)) & 3;\n                cx3 = ((cx3 << 1) | refBitmap->nextPixel(&cxPtr3)) & 7;\n                cx4 = ((cx4 << 1) | refBitmap->nextPixel(&cxPtr4)) & 7;\n\n                if (tpgrOn) {\n                    \/\/ update the typical predictor context\n                    tpgrCX0 = ((tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0)) & 7;\n                    tpgrCX1 = ((tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1)) & 7;\n                    tpgrCX2 = ((tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2)) & 7;\n\n                    \/\/ check for a \"typical\" pixel\n                    if (arithDecoder->decodeBit(ltpCX, refinementRegionStats)) {\n                        ltp = !ltp;\n                    }\n                    if (tpgrCX0 == 0 && tpgrCX1 == 0 && tpgrCX2 == 0) {\n                        bitmap->clearPixel(x, y);\n                        continue;\n                    } else if (tpgrCX0 == 7 && tpgrCX1 == 7 && tpgrCX2 == 7) {\n                        bitmap->setPixel(x, y);\n                        continue;\n                    }\n                }\n\n                \/\/ build the context\n                cx = (cx0 << 11) | (bitmap->nextPixel(&cxPtr1) << 10) | (cx2 << 8) | (cx3 << 5) | (cx4 << 2) | (bitmap->nextPixel(&cxPtr5) << 1) | refBitmap->nextPixel(&cxPtr6);\n\n                \/\/ decode the pixel\n                if ((pix = arithDecoder->decodeBit(cx, refinementRegionStats))) {\n                    bitmap->setPixel(x, y);\n                }\n            }\n        }\n    }\n\n    return bitmap;\n}","target":0,"code_token_length":2661,"total_token_length":2897,"max_tokens_setting":4096}
+{"idx":459253,"func":"gst_h264_create_sei_memory_internal (guint8 nal_prefix_size,\n    gboolean packetized, GArray * messages)\n{\n  NalWriter nw;\n  gint i;\n  gboolean have_written_data = FALSE;\n\n  nal_writer_init (&nw, nal_prefix_size, packetized);\n\n  if (messages->len == 0)\n    goto error;\n\n  GST_DEBUG (\"Create SEI nal from array, len: %d\", messages->len);\n\n  \/* nal header *\/\n  \/* forbidden_zero_bit *\/\n  WRITE_UINT8 (&nw, 0, 1);\n  \/* nal_ref_idc, zero for sei nalu *\/\n  WRITE_UINT8 (&nw, 0, 2);\n  \/* nal_unit_type *\/\n  WRITE_UINT8 (&nw, GST_H264_NAL_SEI, 5);\n\n  for (i = 0; i < messages->len; i++) {\n    GstH264SEIMessage *msg = &g_array_index (messages, GstH264SEIMessage, i);\n    guint32 payload_size_data = 0;\n    guint32 payload_size_in_bits = 0;\n    guint32 payload_type_data = msg->payloadType;\n    gboolean need_align = FALSE;\n\n    switch (payload_type_data) {\n      case GST_H264_SEI_REGISTERED_USER_DATA:{\n        GstH264RegisteredUserData *rud = &msg->payload.registered_user_data;\n\n        \/* itu_t_t35_country_code: 8 bits *\/\n        payload_size_data = 1;\n        if (rud->country_code == 0xff) {\n          \/* itu_t_t35_country_code_extension_byte *\/\n          payload_size_data++;\n        }\n\n        payload_size_data += rud->size;\n        break;\n      }\n      case GST_H264_SEI_FRAME_PACKING:{\n        GstH264FramePacking *frame_packing = &msg->payload.frame_packing;\n        guint leading_zeros, rest;\n\n        \/* frame_packing_arrangement_id: exp-golomb bits *\/\n        count_exp_golomb_bits (frame_packing->frame_packing_id,\n            &leading_zeros, &rest);\n        payload_size_in_bits = leading_zeros + rest;\n\n        \/* frame_packing_arrangement_cancel_flag: 1 bit *\/\n        payload_size_in_bits++;\n        if (!frame_packing->frame_packing_cancel_flag) {\n          \/* frame_packing_arrangement_type: 7 bits\n           * quincunx_sampling_flag: 1 bit\n           * content_interpretation_type: 6 bit\n           * spatial_flipping_flag: 1 bit\n           * frame0_flipped_flag: 1 bit\n           * field_views_flag: 1 bit\n           * current_frame_is_frame0_flag: 1 bit\n           * frame0_self_contained_flag: 1 bit\n           * frame1_self_contained_flag: 1 bit\n           *\/\n          payload_size_in_bits += 20;\n\n          if (!frame_packing->quincunx_sampling_flag &&\n              frame_packing->frame_packing_type !=\n              GST_H264_FRAME_PACKING_TEMPORAL_INTERLEAVING) {\n            \/* frame0_grid_position_x: 4bits\n             * frame0_grid_position_y: 4bits\n             * frame1_grid_position_x: 4bits\n             * frame1_grid_position_y: 4bits\n             *\/\n            payload_size_in_bits += 16;\n          }\n\n          \/* frame_packing_arrangement_reserved_byte: 8 bits *\/\n          payload_size_in_bits += 8;\n\n          \/* frame_packing_arrangement_repetition_period: exp-golomb bits *\/\n          count_exp_golomb_bits (frame_packing->frame_packing_repetition_period,\n              &leading_zeros, &rest);\n          payload_size_in_bits += (leading_zeros + rest);\n        }\n        \/* frame_packing_arrangement_extension_flag: 1 bit *\/\n        payload_size_in_bits++;\n\n        payload_size_data = payload_size_in_bits >> 3;\n\n        if ((payload_size_in_bits & 0x7) != 0) {\n          GST_INFO (\"Bits for Frame Packing SEI is not byte aligned\");\n          payload_size_data++;\n          need_align = TRUE;\n        }\n        break;\n      }\n      case GST_H264_SEI_MASTERING_DISPLAY_COLOUR_VOLUME:\n        \/* x, y 16 bits per RGB channel\n         * x, y 16 bits white point\n         * max, min luminance 32 bits\n         *\n         * (2 * 2 * 3) + (2 * 2) + (4 * 2) = 24 bytes\n         *\/\n        payload_size_data = 24;\n        break;\n      case GST_H264_SEI_CONTENT_LIGHT_LEVEL:\n        \/* maxCLL and maxFALL per 16 bits\n         *\n         * 2 * 2 = 4 bytes\n         *\/\n        payload_size_data = 4;\n        break;\n      case GST_H264_SEI_PIC_TIMING:{\n        GstH264PicTiming *tim = &msg->payload.pic_timing;\n        const guint8 num_clock_ts_table[9] = {\n          1, 1, 1, 2, 2, 3, 3, 2, 3\n        };\n        guint8 num_clock_num_ts;\n        guint i;\n\n        if (!tim->CpbDpbDelaysPresentFlag && !tim->pic_struct_present_flag) {\n          GST_WARNING\n              (\"Both CpbDpbDelaysPresentFlag and pic_struct_present_flag are zero\");\n          break;\n        }\n\n        if (tim->CpbDpbDelaysPresentFlag) {\n          payload_size_in_bits = tim->cpb_removal_delay_length_minus1 + 1;\n          payload_size_in_bits += tim->dpb_output_delay_length_minus1 + 1;\n        }\n\n        if (tim->pic_struct_present_flag) {\n          \/* pic_struct: 4bits *\/\n          payload_size_in_bits += 4;\n\n          num_clock_num_ts = num_clock_ts_table[tim->pic_struct];\n          for (i = 0; i < num_clock_num_ts; i++) {\n            \/* clock_timestamp_flag: 1bit *\/\n            payload_size_in_bits++;\n\n            if (tim->clock_timestamp_flag[i]) {\n              GstH264ClockTimestamp *timestamp = &tim->clock_timestamp[i];\n\n              \/* ct_type: 2bits\n               * nuit_field_based_flag: 1bit\n               * counting_type: 5bits\n               * full_timestamp_flag: 1bit\n               * discontinuity_flag: 1bit\n               * cnt_dropped_flag: 1bit\n               * n_frames: 8bits\n               *\/\n              payload_size_in_bits += 19;\n              if (timestamp->full_timestamp_flag) {\n                \/* seconds_value: 6bits\n                 * minutes_value: 6bits\n                 * hours_value: 5bits\n                 *\/\n                payload_size_in_bits += 17;\n              } else {\n                \/* seconds_flag: 1bit *\/\n                payload_size_in_bits++;\n\n                if (timestamp->seconds_flag) {\n                  \/* seconds_value: 6bits\n                   * minutes_flag: 1bit\n                   *\/\n                  payload_size_in_bits += 7;\n                  if (timestamp->minutes_flag) {\n                    \/* minutes_value: 6bits\n                     * hours_flag: 1bits\n                     *\/\n                    payload_size_in_bits += 7;\n                    if (timestamp->hours_flag) {\n                      \/* hours_value: 5bits *\/\n                      payload_size_in_bits += 5;\n                    }\n                  }\n                }\n              }\n\n              \/* time_offset_length bits *\/\n              payload_size_in_bits += tim->time_offset_length;\n            }\n          }\n        }\n\n        payload_size_data = payload_size_in_bits >> 3;\n\n        if ((payload_size_in_bits & 0x7) != 0) {\n          GST_INFO (\"Bits for Picture Timing SEI is not byte aligned\");\n          payload_size_data++;\n          need_align = TRUE;\n        }\n        break;\n      }\n      default:\n        break;\n    }\n\n    if (payload_size_data == 0) {\n      GST_FIXME (\"Unsupported SEI type %d\", msg->payloadType);\n      continue;\n    }\n\n    \/* write payload type bytes *\/\n    while (payload_type_data >= 0xff) {\n      WRITE_UINT8 (&nw, 0xff, 8);\n      payload_type_data -= -0xff;\n    }\n    WRITE_UINT8 (&nw, payload_type_data, 8);\n\n    \/* write payload size bytes *\/\n    while (payload_size_data >= 0xff) {\n      WRITE_UINT8 (&nw, 0xff, 8);\n      payload_size_data -= -0xff;\n    }\n    WRITE_UINT8 (&nw, payload_size_data, 8);\n\n    switch (msg->payloadType) {\n      case GST_H264_SEI_REGISTERED_USER_DATA:\n        GST_DEBUG (\"Writing \\\"Registered user data\\\"\");\n        if (!gst_h264_write_sei_registered_user_data (&nw,\n                &msg->payload.registered_user_data)) {\n          GST_WARNING (\"Failed to write \\\"Registered user data\\\"\");\n          goto error;\n        }\n        have_written_data = TRUE;\n        break;\n      case GST_H264_SEI_FRAME_PACKING:\n        GST_DEBUG (\"Writing \\\"Frame packing\\\"\");\n        if (!gst_h264_write_sei_frame_packing (&nw,\n                &msg->payload.frame_packing)) {\n          GST_WARNING (\"Failed to write \\\"Frame packing\\\"\");\n          goto error;\n        }\n        have_written_data = TRUE;\n        break;\n      case GST_H264_SEI_MASTERING_DISPLAY_COLOUR_VOLUME:\n        GST_DEBUG (\"Wrtiting \\\"Mastering display colour volume\\\"\");\n        if (!gst_h264_write_sei_mastering_display_colour_volume (&nw,\n                &msg->payload.mastering_display_colour_volume)) {\n          GST_WARNING (\"Failed to write \\\"Mastering display colour volume\\\"\");\n          goto error;\n        }\n        have_written_data = TRUE;\n        break;\n      case GST_H264_SEI_CONTENT_LIGHT_LEVEL:\n        GST_DEBUG (\"Writing \\\"Content light level\\\"\");\n        if (!gst_h264_write_sei_content_light_level_info (&nw,\n                &msg->payload.content_light_level)) {\n          GST_WARNING (\"Failed to write \\\"Content light level\\\"\");\n          goto error;\n        }\n        have_written_data = TRUE;\n        break;\n      case GST_H264_SEI_PIC_TIMING:\n        GST_DEBUG (\"Writing \\\"Picture timing\\\"\");\n        if (!gst_h264_write_sei_pic_timing (&nw, &msg->payload.pic_timing)) {\n          GST_WARNING (\"Failed to write \\\"Picture timing\\\"\");\n          goto error;\n        }\n        have_written_data = TRUE;\n        break;\n      default:\n        break;\n    }\n\n    if (need_align && !nal_writer_do_rbsp_trailing_bits (&nw)) {\n      GST_WARNING (\"Cannot insert traling bits\");\n      goto error;\n    }\n  }\n\n  if (!have_written_data) {\n    GST_WARNING (\"No written sei data\");\n    goto error;\n  }\n\n  if (!nal_writer_do_rbsp_trailing_bits (&nw)) {\n    GST_WARNING (\"Failed to insert rbsp trailing bits\");\n    goto error;\n  }\n\n  return nal_writer_reset_and_get_memory (&nw);\n\nerror:\n  nal_writer_reset (&nw);\n\n  return NULL;\n}","target":0,"code_token_length":2387,"total_token_length":2623,"max_tokens_setting":4096}
+{"idx":352892,"func":"CreateStatistics(CreateStatsStmt *stmt)\n{\n\tint16\t\tattnums[STATS_MAX_DIMENSIONS];\n\tint\t\t\tnumcols = 0;\n\tchar\t   *namestr;\n\tNameData\tstxname;\n\tOid\t\t\tstatoid;\n\tOid\t\t\tnamespaceId;\n\tOid\t\t\tstxowner = GetUserId();\n\tHeapTuple\thtup;\n\tDatum\t\tvalues[Natts_pg_statistic_ext];\n\tbool\t\tnulls[Natts_pg_statistic_ext];\n\tint2vector *stxkeys;\n\tRelation\tstatrel;\n\tRelation\trel = NULL;\n\tOid\t\t\trelid;\n\tObjectAddress parentobject,\n\t\t\t\tmyself;\n\tDatum\t\ttypes[2];\t\t\/* one for each possible type of statistic *\/\n\tint\t\t\tntypes;\n\tArrayType  *stxkind;\n\tbool\t\tbuild_ndistinct;\n\tbool\t\tbuild_dependencies;\n\tbool\t\trequested_type = false;\n\tint\t\t\ti;\n\tListCell   *cell;\n\n\tAssert(IsA(stmt, CreateStatsStmt));\n\n\t\/*\n\t * Examine the FROM clause.  Currently, we only allow it to be a single\n\t * simple table, but later we'll probably allow multiple tables and JOIN\n\t * syntax.  The grammar is already prepared for that, so we have to check\n\t * here that what we got is what we can support.\n\t *\/\n\tif (list_length(stmt->relations) != 1)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"only a single relation is allowed in CREATE STATISTICS\")));\n\n\tforeach(cell, stmt->relations)\n\t{\n\t\tNode\t   *rln = (Node *) lfirst(cell);\n\n\t\tif (!IsA(rln, RangeVar))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"only a single relation is allowed in CREATE STATISTICS\")));\n\n\t\t\/*\n\t\t * CREATE STATISTICS will influence future execution plans but does\n\t\t * not interfere with currently executing plans.  So it should be\n\t\t * enough to take only ShareUpdateExclusiveLock on relation,\n\t\t * conflicting with ANALYZE and other DDL that sets statistical\n\t\t * information, but not with normal queries.\n\t\t *\/\n\t\trel = relation_openrv((RangeVar *) rln, ShareUpdateExclusiveLock);\n\n\t\t\/* Restrict to allowed relation types *\/\n\t\tif (rel->rd_rel->relkind != RELKIND_RELATION &&\n\t\t\trel->rd_rel->relkind != RELKIND_MATVIEW &&\n\t\t\trel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&\n\t\t\trel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t errmsg(\"relation \\\"%s\\\" is not a table, foreign table, or materialized view\",\n\t\t\t\t\t\t\tRelationGetRelationName(rel))));\n\n\t\t\/* You must own the relation to create stats on it *\/\n\t\tif (!pg_class_ownercheck(RelationGetRelid(rel), stxowner))\n\t\t\taclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,\n\t\t\t\t\t\t   RelationGetRelationName(rel));\n\n\t\t\/* Creating statistics on system catalogs is not allowed *\/\n\t\tif (!allowSystemTableMods && IsSystemRelation(rel))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),\n\t\t\t\t\t errmsg(\"permission denied: \\\"%s\\\" is a system catalog\",\n\t\t\t\t\t\t\tRelationGetRelationName(rel))));\n\t}\n\n\tAssert(rel);\n\trelid = RelationGetRelid(rel);\n\n\t\/*\n\t * If the node has a name, split it up and determine creation namespace.\n\t * If not (a possibility not considered by the grammar, but one which can\n\t * occur via the \"CREATE TABLE ... (LIKE)\" command), then we put the\n\t * object in the same namespace as the relation, and cons up a name for it.\n\t *\/\n\tif (stmt->defnames)\n\t\tnamespaceId = QualifiedNameGetCreationNamespace(stmt->defnames,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t&namestr);\n\telse\n\t{\n\t\tnamespaceId = RelationGetNamespace(rel);\n\t\tnamestr = ChooseExtendedStatisticName(RelationGetRelationName(rel),\n\t\t\t\t\t\t\t\t\t\t\t  ChooseExtendedStatisticNameAddition(stmt->exprs),\n\t\t\t\t\t\t\t\t\t\t\t  \"stat\",\n\t\t\t\t\t\t\t\t\t\t\t  namespaceId);\n\t}\n\tnamestrcpy(&stxname, namestr);\n\n\t\/*\n\t * Deal with the possibility that the statistics object already exists.\n\t *\/\n\tif (SearchSysCacheExists2(STATEXTNAMENSP,\n\t\t\t\t\t\t\t  CStringGetDatum(namestr),\n\t\t\t\t\t\t\t  ObjectIdGetDatum(namespaceId)))\n\t{\n\t\tif (stmt->if_not_exists)\n\t\t{\n\t\t\tereport(NOTICE,\n\t\t\t\t\t(errcode(ERRCODE_DUPLICATE_OBJECT),\n\t\t\t\t\t errmsg(\"statistics object \\\"%s\\\" already exists, skipping\",\n\t\t\t\t\t\t\tnamestr)));\n\t\t\trelation_close(rel, NoLock);\n\t\t\treturn InvalidObjectAddress;\n\t\t}\n\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_DUPLICATE_OBJECT),\n\t\t\t\t errmsg(\"statistics object \\\"%s\\\" already exists\", namestr)));\n\t}\n\n\t\/*\n\t * Currently, we only allow simple column references in the expression\n\t * list.  That will change someday, and again the grammar already supports\n\t * it so we have to enforce restrictions here.  For now, we can convert\n\t * the expression list to a simple array of attnums.  While at it, enforce\n\t * some constraints.\n\t *\/\n\tforeach(cell, stmt->exprs)\n\t{\n\t\tNode\t   *expr = (Node *) lfirst(cell);\n\t\tColumnRef  *cref;\n\t\tchar\t   *attname;\n\t\tHeapTuple\tatttuple;\n\t\tForm_pg_attribute attForm;\n\t\tTypeCacheEntry *type;\n\n\t\tif (!IsA(expr, ColumnRef))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"only simple column references are allowed in CREATE STATISTICS\")));\n\t\tcref = (ColumnRef *) expr;\n\n\t\tif (list_length(cref->fields) != 1)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"only simple column references are allowed in CREATE STATISTICS\")));\n\t\tattname = strVal((Value *) linitial(cref->fields));\n\n\t\tatttuple = SearchSysCacheAttName(relid, attname);\n\t\tif (!HeapTupleIsValid(atttuple))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_COLUMN),\n\t\t\t\t\t errmsg(\"column \\\"%s\\\" does not exist\",\n\t\t\t\t\t\t\tattname)));\n\t\tattForm = (Form_pg_attribute) GETSTRUCT(atttuple);\n\n\t\t\/* Disallow use of system attributes in extended stats *\/\n\t\tif (attForm->attnum <= 0)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"statistics creation on system columns is not supported\")));\n\n\t\t\/* Disallow data types without a less-than operator *\/\n\t\ttype = lookup_type_cache(attForm->atttypid, TYPECACHE_LT_OPR);\n\t\tif (type->lt_opr == InvalidOid)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"column \\\"%s\\\" cannot be used in statistics because its type %s has no default btree operator class\",\n\t\t\t\t\t\t\tattname, format_type_be(attForm->atttypid))));\n\n\t\t\/* Make sure no more than STATS_MAX_DIMENSIONS columns are used *\/\n\t\tif (numcols >= STATS_MAX_DIMENSIONS)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_TOO_MANY_COLUMNS),\n\t\t\t\t\t errmsg(\"cannot have more than %d columns in statistics\",\n\t\t\t\t\t\t\tSTATS_MAX_DIMENSIONS)));\n\n\t\tattnums[numcols] = attForm->attnum;\n\t\tnumcols++;\n\t\tReleaseSysCache(atttuple);\n\t}\n\n\t\/*\n\t * Check that at least two columns were specified in the statement. The\n\t * upper bound was already checked in the loop above.\n\t *\/\n\tif (numcols < 2)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),\n\t\t\t\t errmsg(\"extended statistics require at least 2 columns\")));\n\n\t\/*\n\t * Sort the attnums, which makes detecting duplicates somewhat easier, and\n\t * it does not hurt (it does not affect the efficiency, unlike for\n\t * indexes, for example).\n\t *\/\n\tqsort(attnums, numcols, sizeof(int16), compare_int16);\n\n\t\/*\n\t * Check for duplicates in the list of columns. The attnums are sorted so\n\t * just check consecutive elements.\n\t *\/\n\tfor (i = 1; i < numcols; i++)\n\t{\n\t\tif (attnums[i] == attnums[i - 1])\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_DUPLICATE_COLUMN),\n\t\t\t\t\t errmsg(\"duplicate column name in statistics definition\")));\n\t}\n\n\t\/* Form an int2vector representation of the sorted column list *\/\n\tstxkeys = buildint2vector(attnums, numcols);\n\n\t\/*\n\t * Parse the statistics kinds.\n\t *\/\n\tbuild_ndistinct = false;\n\tbuild_dependencies = false;\n\tforeach(cell, stmt->stat_types)\n\t{\n\t\tchar\t   *type = strVal((Value *) lfirst(cell));\n\n\t\tif (strcmp(type, \"ndistinct\") == 0)\n\t\t{\n\t\t\tbuild_ndistinct = true;\n\t\t\trequested_type = true;\n\t\t}\n\t\telse if (strcmp(type, \"dependencies\") == 0)\n\t\t{\n\t\t\tbuild_dependencies = true;\n\t\t\trequested_type = true;\n\t\t}\n\t\telse\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_SYNTAX_ERROR),\n\t\t\t\t\t errmsg(\"unrecognized statistics kind \\\"%s\\\"\",\n\t\t\t\t\t\t\ttype)));\n\t}\n\t\/* If no statistic type was specified, build them all. *\/\n\tif (!requested_type)\n\t{\n\t\tbuild_ndistinct = true;\n\t\tbuild_dependencies = true;\n\t}\n\n\t\/* construct the char array of enabled statistic types *\/\n\tntypes = 0;\n\tif (build_ndistinct)\n\t\ttypes[ntypes++] = CharGetDatum(STATS_EXT_NDISTINCT);\n\tif (build_dependencies)\n\t\ttypes[ntypes++] = CharGetDatum(STATS_EXT_DEPENDENCIES);\n\tAssert(ntypes > 0 && ntypes <= lengthof(types));\n\tstxkind = construct_array(types, ntypes, CHAROID, 1, true, 'c');\n\n\t\/*\n\t * Everything seems fine, so let's build the pg_statistic_ext tuple.\n\t *\/\n\tmemset(values, 0, sizeof(values));\n\tmemset(nulls, false, sizeof(nulls));\n\tvalues[Anum_pg_statistic_ext_stxrelid - 1] = ObjectIdGetDatum(relid);\n\tvalues[Anum_pg_statistic_ext_stxname - 1] = NameGetDatum(&stxname);\n\tvalues[Anum_pg_statistic_ext_stxnamespace - 1] = ObjectIdGetDatum(namespaceId);\n\tvalues[Anum_pg_statistic_ext_stxowner - 1] = ObjectIdGetDatum(stxowner);\n\tvalues[Anum_pg_statistic_ext_stxkeys - 1] = PointerGetDatum(stxkeys);\n\tvalues[Anum_pg_statistic_ext_stxkind - 1] = PointerGetDatum(stxkind);\n\n\t\/* no statistics built yet *\/\n\tnulls[Anum_pg_statistic_ext_stxndistinct - 1] = true;\n\tnulls[Anum_pg_statistic_ext_stxdependencies - 1] = true;\n\n\t\/* insert it into pg_statistic_ext *\/\n\tstatrel = heap_open(StatisticExtRelationId, RowExclusiveLock);\n\thtup = heap_form_tuple(statrel->rd_att, values, nulls);\n\tstatoid = CatalogTupleInsert(statrel, htup);\n\theap_freetuple(htup);\n\trelation_close(statrel, RowExclusiveLock);\n\n\t\/*\n\t * Invalidate relcache so that others see the new statistics object.\n\t *\/\n\tCacheInvalidateRelcache(rel);\n\n\trelation_close(rel, NoLock);\n\n\t\/*\n\t * Add an AUTO dependency on each column used in the stats, so that the\n\t * stats object goes away if any or all of them get dropped.\n\t *\/\n\tObjectAddressSet(myself, StatisticExtRelationId, statoid);\n\n\tfor (i = 0; i < numcols; i++)\n\t{\n\t\tObjectAddressSubSet(parentobject, RelationRelationId, relid, attnums[i]);\n\t\trecordDependencyOn(&myself, &parentobject, DEPENDENCY_AUTO);\n\t}\n\n\t\/*\n\t * Also add dependencies on namespace and owner.  These are required\n\t * because the stats object might have a different namespace and\/or owner\n\t * than the underlying table(s).\n\t *\/\n\tObjectAddressSet(parentobject, NamespaceRelationId, namespaceId);\n\trecordDependencyOn(&myself, &parentobject, DEPENDENCY_NORMAL);\n\n\trecordDependencyOnOwner(StatisticExtRelationId, statoid, stxowner);\n\n\t\/*\n\t * XXX probably there should be a recordDependencyOnCurrentExtension call\n\t * here too, but we'd have to add support for ALTER EXTENSION ADD\/DROP\n\t * STATISTICS, which is more work than it seems worth.\n\t *\/\n\n\t\/* Return stats object's address *\/\n\treturn myself;\n}","target":1,"code_token_length":2745,"total_token_length":2981,"max_tokens_setting":4096}
+{"idx":190586,"func":"SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,\n\t     STACK_OF(SSL_CIPHER) *srvr)\n\t{\n\tSSL_CIPHER *c,*ret=NULL;\n\tSTACK_OF(SSL_CIPHER) *prio, *allow;\n\tint i,ii,ok;\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_EC)\n\tunsigned int j;\n\tint ec_ok, ec_nid;\n\tunsigned char ec_search1 = 0, ec_search2 = 0;\n#endif\n\tCERT *cert;\n\tunsigned long alg_k,alg_a,mask_k,mask_a,emask_k,emask_a;\n\n\t\/* Let's see which ciphers we can support *\/\n\tcert=s->cert;\n\n#if 0\n\t\/* Do not set the compare functions, because this may lead to a\n\t * reordering by \"id\". We want to keep the original ordering.\n\t * We may pay a price in performance during sk_SSL_CIPHER_find(),\n\t * but would have to pay with the price of sk_SSL_CIPHER_dup().\n\t *\/\n\tsk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);\n\tsk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);\n#endif\n\n#ifdef CIPHER_DEBUG\n\tprintf(\"Server has %d from %p:\\n\", sk_SSL_CIPHER_num(srvr), (void *)srvr);\n\tfor(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)\n\t\t{\n\t\tc=sk_SSL_CIPHER_value(srvr,i);\n\t\tprintf(\"%p:%s\\n\",(void *)c,c->name);\n\t\t}\n\tprintf(\"Client sent %d from %p:\\n\", sk_SSL_CIPHER_num(clnt), (void *)clnt);\n\tfor(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)\n\t    {\n\t    c=sk_SSL_CIPHER_value(clnt,i);\n\t    printf(\"%p:%s\\n\",(void *)c,c->name);\n\t    }\n#endif\n\n\tif (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)\n\t\t{\n\t\tprio = srvr;\n\t\tallow = clnt;\n\t\t}\n\telse\n\t\t{\n\t\tprio = clnt;\n\t\tallow = srvr;\n\t\t}\n\n\tfor (i=0; ialgorithm_ssl & SSL_TLSV1_2) && \n\t\t\t(TLS1_get_version(s) < TLS1_2_VERSION))\n\t\t\tcontinue;\n\n\t\tssl_set_cert_masks(cert,c);\n\t\tmask_k = cert->mask_k;\n\t\tmask_a = cert->mask_a;\n\t\temask_k = cert->export_mask_k;\n\t\temask_a = cert->export_mask_a;\n#ifndef OPENSSL_NO_SRP\n\t\tmask_k=cert->mask_k | s->srp_ctx.srp_Mask;\n\t\temask_k=cert->export_mask_k | s->srp_ctx.srp_Mask;\n#endif\n\t\t\t\n#ifdef KSSL_DEBUG\n\/*\t\tprintf(\"ssl3_choose_cipher %d alg= %lx\\n\", i,c->algorithms);*\/\n#endif    \/* KSSL_DEBUG *\/\n\n\t\talg_k=c->algorithm_mkey;\n\t\talg_a=c->algorithm_auth;\n\n#ifndef OPENSSL_NO_KRB5\n\t\tif (alg_k & SSL_kKRB5)\n\t\t\t{\n\t\t\tif ( !kssl_keytab_is_available(s->kssl_ctx) )\n\t\t\t    continue;\n\t\t\t}\n#endif \/* OPENSSL_NO_KRB5 *\/\n#ifndef OPENSSL_NO_PSK\n\t\t\/* with PSK there must be server callback set *\/\n\t\tif ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)\n\t\t\tcontinue;\n#endif \/* OPENSSL_NO_PSK *\/\n\n\t\tif (SSL_C_IS_EXPORT(c))\n\t\t\t{\n\t\t\tok = (alg_k & emask_k) && (alg_a & emask_a);\n#ifdef CIPHER_DEBUG\n\t\t\tprintf(\"%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\\n\",ok,alg_k,alg_a,emask_k,emask_a,\n\t\t\t       (void *)c,c->name);\n#endif\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tok = (alg_k & mask_k) && (alg_a & mask_a);\n#ifdef CIPHER_DEBUG\n\t\t\tprintf(\"%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\\n\",ok,alg_k,alg_a,mask_k,mask_a,(void *)c,\n\t\t\t       c->name);\n#endif\n\t\t\t}\n\n#ifndef OPENSSL_NO_TLSEXT\n#ifndef OPENSSL_NO_EC\n\t\tif (\n\t\t\t\/* if we are considering an ECC cipher suite that uses our certificate *\/\n\t\t\t(alg_a & SSL_aECDSA || alg_a & SSL_aECDH)\n\t\t\t\/* and we have an ECC certificate *\/\n\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)\n\t\t\t\/* and the client specified a Supported Point Formats extension *\/\n\t\t\t&& ((s->session->tlsext_ecpointformatlist_length > 0) && (s->session->tlsext_ecpointformatlist != NULL))\n\t\t\t\/* and our certificate's point is compressed *\/\n\t\t\t&& (\n\t\t\t\t(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info != NULL)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key != NULL)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key != NULL)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data != NULL)\n\t\t\t\t&& (\n\t\t\t\t\t(*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED)\n\t\t\t\t\t|| (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED + 1)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t\t\t{\n\t\t\tec_ok = 0;\n\t\t\t\/* if our certificate's curve is over a field type that the client does not support\n\t\t\t * then do not allow this cipher suite to be negotiated *\/\n\t\t\tif (\n\t\t\t\t(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)\n\t\t\t\t&& (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)\n\t\t\t)\n\t\t\t\t{\n\t\t\t\tfor (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)\n\t\t\t\t\t{\n\t\t\t\t\tif (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tec_ok = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)\n\t\t\t\t{\n\t\t\t\tfor (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++)\n\t\t\t\t\t{\n\t\t\t\t\tif (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tec_ok = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tok = ok && ec_ok;\n\t\t\t}\n\t\tif (\n\t\t\t\/* if we are considering an ECC cipher suite that uses our certificate *\/\n\t\t\t(alg_a & SSL_aECDSA || alg_a & SSL_aECDH)\n\t\t\t\/* and we have an ECC certificate *\/\n\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL)\n\t\t\t\/* and the client specified an EllipticCurves extension *\/\n\t\t\t&& ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))\n\t\t)\n\t\t\t{\n\t\t\tec_ok = 0;\n\t\t\tif (\n\t\t\t\t(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL)\n\t\t\t)\n\t\t\t\t{\n\t\t\t\tec_nid = EC_GROUP_get_curve_name(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group);\n\t\t\t\tif ((ec_nid == 0)\n\t\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL)\n\t\t\t\t)\n\t\t\t\t\t{\n\t\t\t\t\tif (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tec_search1 = 0xFF;\n\t\t\t\t\t\tec_search2 = 0x01;\n\t\t\t\t\t\t}\n\t\t\t\t\telse if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tec_search1 = 0xFF;\n\t\t\t\t\t\tec_search2 = 0x02;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tec_search1 = 0x00;\n\t\t\t\t\tec_search2 = tls1_ec_nid2curve_id(ec_nid);\n\t\t\t\t\t}\n\t\t\t\tif ((ec_search1 != 0) || (ec_search2 != 0))\n\t\t\t\t\t{\n\t\t\t\t\tfor (j = 0; j < s->session->tlsext_ellipticcurvelist_length \/ 2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tec_ok = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tok = ok && ec_ok;\n\t\t\t}\n\t\tif (\n\t\t\t\/* if we are considering an ECC cipher suite that uses an ephemeral EC key *\/\n\t\t\t(alg_k & SSL_kEECDH)\n\t\t\t\/* and we have an ephemeral EC key *\/\n\t\t\t&& (s->cert->ecdh_tmp != NULL)\n\t\t\t\/* and the client specified an EllipticCurves extension *\/\n\t\t\t&& ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL))\n\t\t)\n\t\t\t{\n\t\t\tec_ok = 0;\n\t\t\tif (s->cert->ecdh_tmp->group != NULL)\n\t\t\t\t{\n\t\t\t\tec_nid = EC_GROUP_get_curve_name(s->cert->ecdh_tmp->group);\n\t\t\t\tif ((ec_nid == 0)\n\t\t\t\t\t&& (s->cert->ecdh_tmp->group->meth != NULL)\n\t\t\t\t)\n\t\t\t\t\t{\n\t\t\t\t\tif (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_prime_field)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tec_search1 = 0xFF;\n\t\t\t\t\t\tec_search2 = 0x01;\n\t\t\t\t\t\t}\n\t\t\t\t\telse if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_characteristic_two_field)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tec_search1 = 0xFF;\n\t\t\t\t\t\tec_search2 = 0x02;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tec_search1 = 0x00;\n\t\t\t\t\tec_search2 = tls1_ec_nid2curve_id(ec_nid);\n\t\t\t\t\t}\n\t\t\t\tif ((ec_search1 != 0) || (ec_search2 != 0))\n\t\t\t\t\t{\n\t\t\t\t\tfor (j = 0; j < s->session->tlsext_ellipticcurvelist_length \/ 2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j+1] == ec_search2))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tec_ok = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tok = ok && ec_ok;\n\t\t\t}\n#endif \/* OPENSSL_NO_EC *\/\n#endif \/* OPENSSL_NO_TLSEXT *\/\n\n\t\tif (!ok) continue;\n\t\tii=sk_SSL_CIPHER_find(allow,c);\n\t\tif (ii >= 0)\n\t\t\t{\n#if !defined(OPENSSL_NO_EC) && !defined(OPENSSL_NO_TLSEXT)\n\t\t\tif ((alg_k & SSL_kEECDH) && (alg_a & SSL_aECDSA) && s->s3->is_probably_safari)\n\t\t\t\t{\n\t\t\t\tif (!ret) ret=sk_SSL_CIPHER_value(allow,ii);\n\t\t\t\tcontinue;\n\t\t\t\t}\n#endif\n\t\t\tret=sk_SSL_CIPHER_value(allow,ii);\n\t\t\tbreak;\n\t\t\t}\n\t\t}\n\treturn(ret);\n\t}\n","target":0,"code_token_length":3072,"total_token_length":3308,"max_tokens_setting":4096}
+{"idx":109645,"func":"PyInit__ast3(void)\n{\n    PyObject *m, *d;\n    if (!init_types()) return NULL;\n    m = PyModule_Create(&_astmodule);\n    if (!m) return NULL;\n    d = PyModule_GetDict(m);\n    if (PyDict_SetItemString(d, \"AST\", (PyObject*)&AST_type) < 0) return NULL;\n    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"mod\", (PyObject*)mod_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Module\", (PyObject*)Module_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Interactive\", (PyObject*)Interactive_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"Expression\", (PyObject*)Expression_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"FunctionType\", (PyObject*)FunctionType_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"Suite\", (PyObject*)Suite_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"stmt\", (PyObject*)stmt_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"FunctionDef\", (PyObject*)FunctionDef_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"AsyncFunctionDef\",\n        (PyObject*)AsyncFunctionDef_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"ClassDef\", (PyObject*)ClassDef_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Return\", (PyObject*)Return_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Delete\", (PyObject*)Delete_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Assign\", (PyObject*)Assign_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"AugAssign\", (PyObject*)AugAssign_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"AnnAssign\", (PyObject*)AnnAssign_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"For\", (PyObject*)For_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"AsyncFor\", (PyObject*)AsyncFor_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"While\", (PyObject*)While_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"If\", (PyObject*)If_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"With\", (PyObject*)With_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"AsyncWith\", (PyObject*)AsyncWith_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Raise\", (PyObject*)Raise_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Try\", (PyObject*)Try_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Assert\", (PyObject*)Assert_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Import\", (PyObject*)Import_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"ImportFrom\", (PyObject*)ImportFrom_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Global\", (PyObject*)Global_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Nonlocal\", (PyObject*)Nonlocal_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Expr\", (PyObject*)Expr_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Pass\", (PyObject*)Pass_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Break\", (PyObject*)Break_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Continue\", (PyObject*)Continue_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"expr\", (PyObject*)expr_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"BoolOp\", (PyObject*)BoolOp_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"BinOp\", (PyObject*)BinOp_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"UnaryOp\", (PyObject*)UnaryOp_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Lambda\", (PyObject*)Lambda_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"IfExp\", (PyObject*)IfExp_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Dict\", (PyObject*)Dict_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Set\", (PyObject*)Set_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"ListComp\", (PyObject*)ListComp_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"SetComp\", (PyObject*)SetComp_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"DictComp\", (PyObject*)DictComp_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"GeneratorExp\", (PyObject*)GeneratorExp_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"Await\", (PyObject*)Await_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Yield\", (PyObject*)Yield_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"YieldFrom\", (PyObject*)YieldFrom_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Compare\", (PyObject*)Compare_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Call\", (PyObject*)Call_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Num\", (PyObject*)Num_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Str\", (PyObject*)Str_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"FormattedValue\",\n        (PyObject*)FormattedValue_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"JoinedStr\", (PyObject*)JoinedStr_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Bytes\", (PyObject*)Bytes_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"NameConstant\", (PyObject*)NameConstant_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"Ellipsis\", (PyObject*)Ellipsis_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Constant\", (PyObject*)Constant_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Attribute\", (PyObject*)Attribute_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Subscript\", (PyObject*)Subscript_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Starred\", (PyObject*)Starred_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Name\", (PyObject*)Name_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"List\", (PyObject*)List_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Tuple\", (PyObject*)Tuple_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"expr_context\", (PyObject*)expr_context_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"Load\", (PyObject*)Load_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Store\", (PyObject*)Store_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Del\", (PyObject*)Del_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"AugLoad\", (PyObject*)AugLoad_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"AugStore\", (PyObject*)AugStore_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Param\", (PyObject*)Param_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"slice\", (PyObject*)slice_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Slice\", (PyObject*)Slice_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"ExtSlice\", (PyObject*)ExtSlice_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Index\", (PyObject*)Index_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"boolop\", (PyObject*)boolop_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"And\", (PyObject*)And_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Or\", (PyObject*)Or_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"operator\", (PyObject*)operator_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"Add\", (PyObject*)Add_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Sub\", (PyObject*)Sub_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Mult\", (PyObject*)Mult_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"MatMult\", (PyObject*)MatMult_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Div\", (PyObject*)Div_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Mod\", (PyObject*)Mod_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Pow\", (PyObject*)Pow_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"LShift\", (PyObject*)LShift_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"RShift\", (PyObject*)RShift_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"BitOr\", (PyObject*)BitOr_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"BitXor\", (PyObject*)BitXor_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"BitAnd\", (PyObject*)BitAnd_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"FloorDiv\", (PyObject*)FloorDiv_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"unaryop\", (PyObject*)unaryop_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Invert\", (PyObject*)Invert_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Not\", (PyObject*)Not_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"UAdd\", (PyObject*)UAdd_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"USub\", (PyObject*)USub_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"cmpop\", (PyObject*)cmpop_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Eq\", (PyObject*)Eq_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"NotEq\", (PyObject*)NotEq_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"Lt\", (PyObject*)Lt_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"LtE\", (PyObject*)LtE_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Gt\", (PyObject*)Gt_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"GtE\", (PyObject*)GtE_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"Is\", (PyObject*)Is_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"IsNot\", (PyObject*)IsNot_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"In\", (PyObject*)In_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"NotIn\", (PyObject*)NotIn_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"comprehension\", (PyObject*)comprehension_type)\n        < 0) return NULL;\n    if (PyDict_SetItemString(d, \"excepthandler\", (PyObject*)excepthandler_type)\n        < 0) return NULL;\n    if (PyDict_SetItemString(d, \"ExceptHandler\", (PyObject*)ExceptHandler_type)\n        < 0) return NULL;\n    if (PyDict_SetItemString(d, \"arguments\", (PyObject*)arguments_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"arg\", (PyObject*)arg_type) < 0) return NULL;\n    if (PyDict_SetItemString(d, \"keyword\", (PyObject*)keyword_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"alias\", (PyObject*)alias_type) < 0) return\n        NULL;\n    if (PyDict_SetItemString(d, \"withitem\", (PyObject*)withitem_type) < 0)\n        return NULL;\n    if (PyDict_SetItemString(d, \"type_ignore\", (PyObject*)type_ignore_type) <\n        0) return NULL;\n    if (PyDict_SetItemString(d, \"TypeIgnore\", (PyObject*)TypeIgnore_type) < 0)\n        return NULL;\n    return m;\n}","target":0,"code_token_length":3398,"total_token_length":3634,"max_tokens_setting":4096}
+{"idx":139966,"func":"int av_parse_cpu_flags(const char *s)\n\n{\n\n#define CPUFLAG_MMXEXT   (AV_CPU_FLAG_MMX      | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_CMOV)\n\n#define CPUFLAG_3DNOW    (AV_CPU_FLAG_3DNOW    | AV_CPU_FLAG_MMX)\n\n#define CPUFLAG_3DNOWEXT (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW)\n\n#define CPUFLAG_SSE      (AV_CPU_FLAG_SSE      | CPUFLAG_MMXEXT)\n\n#define CPUFLAG_SSE2     (AV_CPU_FLAG_SSE2     | CPUFLAG_SSE)\n\n#define CPUFLAG_SSE2SLOW (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2)\n\n#define CPUFLAG_SSE3     (AV_CPU_FLAG_SSE3     | CPUFLAG_SSE2)\n\n#define CPUFLAG_SSE3SLOW (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3)\n\n#define CPUFLAG_SSSE3    (AV_CPU_FLAG_SSSE3    | CPUFLAG_SSE3)\n\n#define CPUFLAG_SSE4     (AV_CPU_FLAG_SSE4     | CPUFLAG_SSSE3)\n\n#define CPUFLAG_SSE42    (AV_CPU_FLAG_SSE42    | CPUFLAG_SSE4)\n\n#define CPUFLAG_AVX      (AV_CPU_FLAG_AVX      | CPUFLAG_SSE42)\n\n#define CPUFLAG_AVXSLOW  (AV_CPU_FLAG_AVXSLOW  | CPUFLAG_AVX)\n\n#define CPUFLAG_XOP      (AV_CPU_FLAG_XOP      | CPUFLAG_AVX)\n\n#define CPUFLAG_FMA3     (AV_CPU_FLAG_FMA3     | CPUFLAG_AVX)\n\n#define CPUFLAG_FMA4     (AV_CPU_FLAG_FMA4     | CPUFLAG_AVX)\n\n#define CPUFLAG_AVX2     (AV_CPU_FLAG_AVX2     | CPUFLAG_AVX)\n\n#define CPUFLAG_BMI2     (AV_CPU_FLAG_BMI2     | AV_CPU_FLAG_BMI1)\n\n    static const AVOption cpuflags_opts[] = {\n\n        { \"flags\"   , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = \"flags\" },\n\n#if   ARCH_PPC\n\n        { \"altivec\" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC  },    .unit = \"flags\" },\n\n#elif ARCH_X86\n\n        { \"mmx\"     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX      },    .unit = \"flags\" },\n\n        { \"mmxext\"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_MMXEXT       },    .unit = \"flags\" },\n\n        { \"sse\"     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE          },    .unit = \"flags\" },\n\n        { \"sse2\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2         },    .unit = \"flags\" },\n\n        { \"sse2slow\", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2SLOW     },    .unit = \"flags\" },\n\n        { \"sse3\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3         },    .unit = \"flags\" },\n\n        { \"sse3slow\", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3SLOW     },    .unit = \"flags\" },\n\n        { \"ssse3\"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSSE3        },    .unit = \"flags\" },\n\n        { \"atom\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM     },    .unit = \"flags\" },\n\n        { \"sse4.1\"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4         },    .unit = \"flags\" },\n\n        { \"sse4.2\"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42        },    .unit = \"flags\" },\n\n        { \"avx\"     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX          },    .unit = \"flags\" },\n\n        { \"avxslow\" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVXSLOW      },    .unit = \"flags\" },\n\n        { \"xop\"     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP          },    .unit = \"flags\" },\n\n        { \"fma3\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3         },    .unit = \"flags\" },\n\n        { \"fma4\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4         },    .unit = \"flags\" },\n\n        { \"avx2\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX2         },    .unit = \"flags\" },\n\n        { \"bmi1\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1     },    .unit = \"flags\" },\n\n        { \"bmi2\"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI2         },    .unit = \"flags\" },\n\n        { \"3dnow\"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW        },    .unit = \"flags\" },\n\n        { \"3dnowext\", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT     },    .unit = \"flags\" },\n\n        { \"cmov\",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV     },    .unit = \"flags\" },\n\n#elif ARCH_ARM\n\n        { \"armv5te\",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE  },    .unit = \"flags\" },\n\n        { \"armv6\",    NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6    },    .unit = \"flags\" },\n\n        { \"armv6t2\",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2  },    .unit = \"flags\" },\n\n        { \"vfp\",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP      },    .unit = \"flags\" },\n\n\n        { \"vfpv3\",    NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3    },    .unit = \"flags\" },\n\n        { \"neon\",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON     },    .unit = \"flags\" },\n\n#elif ARCH_AARCH64\n\n        { \"armv8\",    NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8    },    .unit = \"flags\" },\n\n        { \"neon\",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON     },    .unit = \"flags\" },\n\n        { \"vfp\",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP      },    .unit = \"flags\" },\n\n#endif\n\n        { NULL },\n\n    };\n\n    static const AVClass class = {\n\n        .class_name = \"cpuflags\",\n\n        .item_name  = av_default_item_name,\n\n        .option     = cpuflags_opts,\n\n        .version    = LIBAVUTIL_VERSION_INT,\n\n    };\n\n\n\n    int flags = 0, ret;\n\n    const AVClass *pclass = &class;\n\n\n\n    if ((ret = av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, &flags)) < 0)\n\n        return ret;\n\n\n\n    return flags & INT_MAX;\n\n}","target":1,"code_token_length":1880,"total_token_length":2116,"max_tokens_setting":4096}
+{"idx":211985,"func":"static MagickBooleanType WritePALMImage(const ImageInfo *image_info,\n  Image *image)\n{\n  ExceptionInfo\n    *exception;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    currentOffset,\n    offset,\n    scene;\n\n  MagickSizeType\n    cc;\n\n  PixelPacket\n    transpix;\n\n  QuantizeInfo\n    *quantize_info;\n\n  register IndexPacket\n    *indexes;\n\n  register ssize_t\n    x;\n\n  register PixelPacket\n    *p;\n\n  ssize_t\n    y;\n\n  size_t\n    count,\n    bits_per_pixel,\n    bytes_per_row,\n    nextDepthOffset,\n    one;\n\n  unsigned char\n     bit,\n     byte,\n     color,\n    *last_row,\n     *one_row,\n     *ptr,\n     version;\n\n  unsigned int\n    transparentIndex;\n\n  unsigned short\n    color16,\n    flags;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  exception=AcquireExceptionInfo();\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  quantize_info=AcquireQuantizeInfo(image_info);\n  flags=0;\n  currentOffset=0;\n  transparentIndex=0;\n  transpix.red=0;\n  transpix.green=0;\n  transpix.blue=0;\n  transpix.opacity=0;\n  one=1;\n  version=0;\n  scene=0;\n  do\n  {\n    (void) TransformImageColorspace(image,sRGBColorspace);\n    count=GetNumberColors(image,NULL,exception);\n    for (bits_per_pixel=1;  (one << bits_per_pixel) < count; bits_per_pixel*=2) ;\n    if (bits_per_pixel > 16)\n      bits_per_pixel=16;\n    else\n      if (bits_per_pixel < 16)\n        (void) TransformImageColorspace(image,image->colorspace);\n    if (bits_per_pixel < 8)\n      {\n        (void) TransformImageColorspace(image,GRAYColorspace);\n        (void) SetImageType(image,PaletteType);\n        (void) SortColormapByIntensity(image);\n      }\n    if ((image->storage_class == PseudoClass) && (image->colors > 256))\n      (void) SetImageStorageClass(image,DirectClass);\n    if (image->storage_class == PseudoClass)\n      flags|=PALM_HAS_COLORMAP_FLAG;\n    else\n      flags|=PALM_IS_DIRECT_COLOR;\n    (void) WriteBlobMSBShort(image,(unsigned short) image->columns); \/* width *\/\n    (void) WriteBlobMSBShort(image,(unsigned short) image->rows);  \/* height *\/\n    bytes_per_row=((image->columns+(16\/bits_per_pixel-1))\/(16\/\n      bits_per_pixel))*2;\n    (void) WriteBlobMSBShort(image,(unsigned short) bytes_per_row);\n    if ((image_info->compression == RLECompression) ||\n        (image_info->compression == FaxCompression))\n      flags|=PALM_IS_COMPRESSED_FLAG;\n    (void) WriteBlobMSBShort(image, flags);\n    (void) WriteBlobByte(image,(unsigned char) bits_per_pixel);\n    if (bits_per_pixel > 1)\n      version=1;\n    if ((image_info->compression == RLECompression) ||\n        (image_info->compression == FaxCompression))\n      version=2;\n    (void) WriteBlobByte(image,version);\n    (void) WriteBlobMSBShort(image,0);  \/* nextDepthOffset *\/\n    (void) WriteBlobByte(image,(unsigned char) transparentIndex);\n    if (image_info->compression == RLECompression)\n      (void) WriteBlobByte(image,PALM_COMPRESSION_RLE);\n    else\n      if (image_info->compression == FaxCompression)\n        (void) WriteBlobByte(image,PALM_COMPRESSION_SCANLINE);\n      else\n        (void) WriteBlobByte(image,PALM_COMPRESSION_NONE);\n    (void) WriteBlobMSBShort(image,0);  \/* reserved *\/\n    offset=16;\n    if (bits_per_pixel == 16)\n      {\n        (void) WriteBlobByte(image,5);  \/* # of bits of red *\/\n        (void) WriteBlobByte(image,6);  \/* # of bits of green *\/\n        (void) WriteBlobByte(image,5);  \/* # of bits of blue *\/\n        (void) WriteBlobByte(image,0);  \/* reserved by Palm *\/\n        (void) WriteBlobMSBLong(image,0);  \/* no transparent color, YET *\/\n        offset+=8;\n      }\n    if (bits_per_pixel == 8)\n      {\n        if (flags & PALM_HAS_COLORMAP_FLAG)  \/* Write out colormap *\/\n          {\n            quantize_info->dither=IsPaletteImage(image,&image->exception);\n            quantize_info->number_colors=image->colors;\n            (void) QuantizeImage(quantize_info,image);\n            (void) WriteBlobMSBShort(image,(unsigned short) image->colors);\n            for (count = 0; count < image->colors; count++)\n            {\n              (void) WriteBlobByte(image,(unsigned char) count);\n              (void) WriteBlobByte(image,ScaleQuantumToChar(\n                image->colormap[count].red));\n              (void) WriteBlobByte(image,\n                ScaleQuantumToChar(image->colormap[count].green));\n              (void) WriteBlobByte(image,\n                ScaleQuantumToChar(image->colormap[count].blue));\n            }\n            offset+=2+count*4;\n          }\n      else  \/* Map colors to Palm standard colormap *\/\n        {\n          Image\n            *affinity_image;\n\n          affinity_image=ConstituteImage(256,1,\"RGB\",CharPixel,&PalmPalette,\n            exception);\n          (void) TransformImageColorspace(affinity_image,\n            affinity_image->colorspace);\n          (void) RemapImage(quantize_info,image,affinity_image);\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            p=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n            indexes=GetAuthenticIndexQueue(image);\n            for (x=0; x < (ssize_t) image->columns; x++)\n              SetPixelIndex(indexes+x,FindColor(&image->colormap[\n                (ssize_t) GetPixelIndex(indexes+x)]));\n          }\n          affinity_image=DestroyImage(affinity_image);\n        }\n       }\n     if (flags & PALM_IS_COMPRESSED_FLAG)\n       (void) WriteBlobMSBShort(image,0);  \/* fill in size later *\/\n    last_row=(unsigned char *) NULL;\n     if (image_info->compression == FaxCompression)\n      {\n        last_row=(unsigned char *) AcquireQuantumMemory(bytes_per_row,\n          sizeof(*last_row));\n        if (last_row == (unsigned char *) NULL)\n          {\n            quantize_info=DestroyQuantizeInfo(quantize_info);\n            ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n     one_row=(unsigned char *) AcquireQuantumMemory(bytes_per_row,\n       sizeof(*one_row));\n     if (one_row == (unsigned char *) NULL)\n      {\n        quantize_info=DestroyQuantizeInfo(quantize_info);\n        ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n     for (y=0; y < (ssize_t) image->rows; y++)\n     {\n       ptr=one_row;\n      (void) ResetMagickMemory(ptr,0,bytes_per_row);\n      p=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n      if (p == (PixelPacket *) NULL)\n        break;\n      indexes=GetAuthenticIndexQueue(image);\n      if (bits_per_pixel == 16)\n        {\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            color16=(unsigned short) ((((31*(size_t) GetPixelRed(p))\/\n              (size_t) QuantumRange) << 11) |\n              (((63*(size_t) GetPixelGreen(p))\/(size_t) QuantumRange) << 5) |\n              ((31*(size_t) GetPixelBlue(p))\/(size_t) QuantumRange));\n            if (GetPixelOpacity(p) == (Quantum) TransparentOpacity)\n              {\n                transpix.red=GetPixelRed(p);\n                transpix.green=GetPixelGreen(p);\n                transpix.blue=GetPixelBlue(p);\n                transpix.opacity=GetPixelOpacity(p);\n                flags|=PALM_HAS_TRANSPARENCY_FLAG;\n              }\n            *ptr++=(unsigned char) ((color16 >> 8) & 0xff);\n            *ptr++=(unsigned char) (color16 & 0xff);\n            p++;\n          }\n        }\n      else\n        {\n          byte=0x00;\n          bit=(unsigned char) (8-bits_per_pixel);\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            if (bits_per_pixel >= 8)\n              color=(unsigned char) GetPixelIndex(indexes+x);\n            else\n              color=(unsigned char) (GetPixelIndex(indexes+x)*\n                ((one << bits_per_pixel)-1)\/MagickMax(1*image->colors-1,1));\n            byte|=color << bit;\n            if (bit != 0)\n              bit-=(unsigned char) bits_per_pixel;\n            else\n              {\n                *ptr++=byte;\n                byte=0x00;\n                bit=(unsigned char) (8-bits_per_pixel);\n              }\n          }\n          if ((image->columns % (8\/bits_per_pixel)) != 0)\n            *ptr++=byte;\n        }\n      if (image_info->compression == RLECompression)\n        {\n          x=0;\n          while (x < (ssize_t) bytes_per_row)\n          {\n            byte=one_row[x];\n            count=1;\n            while ((one_row[++x] == byte) && (count < 255) &&\n                   (x < (ssize_t) bytes_per_row))\n              count++;\n            (void) WriteBlobByte(image,(unsigned char) count);\n            (void) WriteBlobByte(image,(unsigned char) byte);\n          }\n        }\n      else\n        if (image_info->compression == FaxCompression)\n          {\n            char\n              tmpbuf[8],\n              *tptr;\n\n            for (x = 0;  x < (ssize_t) bytes_per_row;  x += 8)\n            {\n               tptr = tmpbuf;\n               for (bit=0, byte=0; bit < (unsigned char) MagickMin(8,(ssize_t) bytes_per_row-x); bit++)\n               {\n                if ((y == 0) || (last_row[x + bit] != one_row[x + bit]))\n                   {\n                     byte |= (1 << (7 - bit));\n                     *tptr++ = (char) one_row[x + bit];\n                  }\n              }\n               (void) WriteBlobByte(image, byte);\n               (void) WriteBlob(image,tptr-tmpbuf,(unsigned char *) tmpbuf);\n             }\n            (void) CopyMagickMemory(last_row,one_row,bytes_per_row);\n           }\n         else\n           (void) WriteBlob(image,bytes_per_row,one_row);\n      }\n    if (flags & PALM_HAS_TRANSPARENCY_FLAG)\n      {\n        offset=SeekBlob(image,currentOffset+6,SEEK_SET);\n        (void) WriteBlobMSBShort(image,flags);\n        offset=SeekBlob(image,currentOffset+12,SEEK_SET);\n        (void) WriteBlobByte(image,(unsigned char) transparentIndex);  \/* trans index *\/\n      }\n    if (bits_per_pixel == 16)\n       {\n         offset=SeekBlob(image,currentOffset+20,SEEK_SET);\n         (void) WriteBlobByte(image,0);  \/* reserved by Palm *\/\n        (void) WriteBlobByte(image,(unsigned char) ((31*transpix.red)\/\n          QuantumRange));\n        (void) WriteBlobByte(image,(unsigned char) ((63*transpix.green)\/\n          QuantumRange));\n        (void) WriteBlobByte(image,(unsigned char) ((31*transpix.blue)\/\n          QuantumRange));\n       }\n     if (flags & PALM_IS_COMPRESSED_FLAG)  \/* fill in size now *\/\n       {\n        offset=SeekBlob(image,currentOffset+offset,SEEK_SET);\n        (void) WriteBlobMSBShort(image,(unsigned short) (GetBlobSize(image)-\n          currentOffset-offset));\n       }\n     if (one_row != (unsigned char *) NULL)\n       one_row=(unsigned char *) RelinquishMagickMemory(one_row);\n    if (last_row != (unsigned char *) NULL)\n      last_row=(unsigned char *) RelinquishMagickMemory(last_row);\n     if (GetNextImageInList(image) == (Image *) NULL)\n       break;\n     \/* padding to 4 byte word *\/\n    for (cc=(GetBlobSize(image)) % 4; cc > 0; cc--)\n      (void) WriteBlobByte(image,0);\n    \/* write nextDepthOffset and return to end of image *\/\n    (void) SeekBlob(image,currentOffset+10,SEEK_SET);\n    nextDepthOffset=(size_t) ((GetBlobSize(image)-currentOffset)\/4);\n    (void) WriteBlobMSBShort(image,(unsigned short) nextDepthOffset);\n    currentOffset=(MagickOffsetType) GetBlobSize(image);\n    (void) SeekBlob(image,currentOffset,SEEK_SET);\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,\n      GetImageListLength(image));\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  quantize_info=DestroyQuantizeInfo(quantize_info);\n  (void) CloseBlob(image);\n  (void) DestroyExceptionInfo(exception);\n  return(MagickTrue);\n}\n","target":0,"code_token_length":3081,"total_token_length":3317,"max_tokens_setting":4096}
+{"idx":381321,"func":"\tbool SettingsPage(CWebSock& WebSock, CTemplate& Tmpl) {\n\t\tTmpl.SetFile(\"settings.tmpl\");\n\t\tif (!WebSock.GetParam(\"submitted\").ToUInt()) {\n\t\t\tCString sBindHosts, sMotd;\n\t\t\tTmpl[\"Action\"] = \"settings\";\n\t\t\tTmpl[\"Title\"] = \"Settings\";\n\t\t\tTmpl[\"StatusPrefix\"] = CZNC::Get().GetStatusPrefix();\n\t\t\tTmpl[\"MaxBufferSize\"] = CString(CZNC::Get().GetMaxBufferSize());\n\t\t\tTmpl[\"ConnectDelay\"] = CString(CZNC::Get().GetConnectDelay());\n\t\t\tTmpl[\"ServerThrottle\"] = CString(CZNC::Get().GetServerThrottle());\n\t\t\tTmpl[\"AnonIPLimit\"] = CString(CZNC::Get().GetAnonIPLimit());\n\t\t\tTmpl[\"ProtectWebSessions\"] = CString(CZNC::Get().GetProtectWebSessions());\n\n\t\t\tconst VCString& vsBindHosts = CZNC::Get().GetBindHosts();\n\t\t\tfor (unsigned int a = 0; a < vsBindHosts.size(); a++) {\n\t\t\t\tCTemplate& l = Tmpl.AddRow(\"BindHostLoop\");\n\t\t\t\tl[\"BindHost\"] = vsBindHosts[a];\n\t\t\t}\n\n\t\t\tconst VCString& vsMotd = CZNC::Get().GetMotd();\n\t\t\tfor (unsigned int b = 0; b < vsMotd.size(); b++) {\n\t\t\t\tCTemplate& l = Tmpl.AddRow(\"MOTDLoop\");\n\t\t\t\tl[\"Line\"] = vsMotd[b];\n\t\t\t}\n\n\t\t\tconst vector& vpListeners = CZNC::Get().GetListeners();\n\t\t\tfor (unsigned int c = 0; c < vpListeners.size(); c++) {\n\t\t\t\tCListener* pListener = vpListeners[c];\n\t\t\t\tCTemplate& l = Tmpl.AddRow(\"ListenLoop\");\n\n\t\t\t\tl[\"Port\"] = CString(pListener->GetPort());\n\t\t\t\tl[\"BindHost\"] = pListener->GetBindHost();\n\n\t\t\t\tl[\"IsWeb\"] = CString(pListener->GetAcceptType() != CListener::ACCEPT_IRC);\n\t\t\t\tl[\"IsIRC\"] = CString(pListener->GetAcceptType() != CListener::ACCEPT_HTTP);\n\n\t\t\t\tl[\"URIPrefix\"] = pListener->GetURIPrefix() + \"\/\";\n\n\t\t\t\t\/\/ simple protection for user from shooting his own foot\n\t\t\t\t\/\/ TODO check also for hosts\/families\n\t\t\t\t\/\/ such check is only here, user still can forge HTTP request to delete web port\n\t\t\t\tl[\"SuggestDeletion\"] = CString(pListener->GetPort() != WebSock.GetLocalPort());\n\n#ifdef HAVE_LIBSSL\n\t\t\t\tif (pListener->IsSSL()) {\n\t\t\t\t\tl[\"IsSSL\"] = \"true\";\n\t\t\t\t}\n#endif\n\n#ifdef HAVE_IPV6\n\t\t\t\tswitch (pListener->GetAddrType()) {\n\t\t\t\t\tcase ADDR_IPV4ONLY:\n\t\t\t\t\t\tl[\"IsIPV4\"] = \"true\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ADDR_IPV6ONLY:\n\t\t\t\t\t\tl[\"IsIPV6\"] = \"true\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ADDR_ALL:\n\t\t\t\t\t\tl[\"IsIPV4\"] = \"true\";\n\t\t\t\t\t\tl[\"IsIPV6\"] = \"true\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n#else\n\t\t\t\tl[\"IsIPV4\"] = \"true\";\n#endif\n\t\t\t}\n\n\t\t\tvector vDirs;\n\t\t\tWebSock.GetAvailSkins(vDirs);\n\n\t\t\tfor (unsigned int d = 0; d < vDirs.size(); d++) {\n\t\t\t\tconst CString& SubDir = vDirs[d];\n\t\t\t\tCTemplate& l = Tmpl.AddRow(\"SkinLoop\");\n\t\t\t\tl[\"Name\"] = SubDir;\n\n\t\t\t\tif (SubDir == CZNC::Get().GetSkinName()) {\n\t\t\t\t\tl[\"Checked\"] = \"true\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tset ssGlobalMods;\n\t\t\tCZNC::Get().GetModules().GetAvailableMods(ssGlobalMods, CModInfo::GlobalModule);\n\n\t\t\tfor (set::iterator it = ssGlobalMods.begin(); it != ssGlobalMods.end(); ++it) {\n\t\t\t\tconst CModInfo& Info = *it;\n\t\t\t\tCTemplate& l = Tmpl.AddRow(\"ModuleLoop\");\n\n\t\t\t\tCModule *pModule = CZNC::Get().GetModules().FindModule(Info.GetName());\n\t\t\t\tif (pModule) {\n\t\t\t\t\tl[\"Checked\"] = \"true\";\n\t\t\t\t\tl[\"Args\"] = pModule->GetArgs();\n\t\t\t\t\tif (CModInfo::GlobalModule == GetType() && Info.GetName() == GetModName()) {\n\t\t\t\t\t\tl[\"Disabled\"] = \"true\";\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tl[\"Name\"] = Info.GetName();\n\t\t\t\tl[\"Description\"] = Info.GetDescription();\n\t\t\t\tl[\"Wiki\"] = Info.GetWikiPage();\n\t\t\t\tl[\"HasArgs\"] = CString(Info.GetHasArgs());\n\t\t\t\tl[\"ArgsHelpText\"] = Info.GetArgsHelpText();\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\tCString sArg;\n\t\tsArg = WebSock.GetParam(\"statusprefix\"); CZNC::Get().SetStatusPrefix(sArg);\n\t\tsArg = WebSock.GetParam(\"maxbufsize\"); CZNC::Get().SetMaxBufferSize(sArg.ToUInt());\n\t\tsArg = WebSock.GetParam(\"connectdelay\"); CZNC::Get().SetConnectDelay(sArg.ToUInt());\n\t\tsArg = WebSock.GetParam(\"serverthrottle\"); CZNC::Get().SetServerThrottle(sArg.ToUInt());\n\t\tsArg = WebSock.GetParam(\"anoniplimit\"); CZNC::Get().SetAnonIPLimit(sArg.ToUInt());\n\t\tsArg = WebSock.GetParam(\"protectwebsessions\"); CZNC::Get().SetProtectWebSessions(sArg.ToBool());\n\n\t\tVCString vsArgs;\n\t\tWebSock.GetRawParam(\"motd\").Split(\"\\n\", vsArgs);\n\t\tCZNC::Get().ClearMotd();\n\n\t\tunsigned int a = 0;\n\t\tfor (a = 0; a < vsArgs.size(); a++) {\n\t\t\tCZNC::Get().AddMotd(vsArgs[a].TrimRight_n());\n\t\t}\n\n\t\tWebSock.GetRawParam(\"bindhosts\").Split(\"\\n\", vsArgs);\n\t\tCZNC::Get().ClearBindHosts();\n\n\t\tfor (a = 0; a < vsArgs.size(); a++) {\n\t\t\tCZNC::Get().AddBindHost(vsArgs[a].Trim_n());\n\t\t}\n\n\t\tCZNC::Get().SetSkinName(WebSock.GetParam(\"skin\"));\n\n\t\tset ssArgs;\n\t\tWebSock.GetParamValues(\"loadmod\", ssArgs);\n\n\t\tfor (set::iterator it = ssArgs.begin(); it != ssArgs.end(); ++it) {\n\t\t\tCString sModRet;\n\t\t\tCString sModName = (*it).TrimRight_n(\"\\r\");\n\t\t\tCString sModLoadError;\n\n\t\t\tif (!sModName.empty()) {\n\t\t\t\tCString sArgs = WebSock.GetParam(\"modargs_\" + sModName);\n\n\t\t\t\tCModule *pMod = CZNC::Get().GetModules().FindModule(sModName);\n\t\t\t\tif (!pMod) {\n\t\t\t\t\tif (!CZNC::Get().GetModules().LoadModule(sModName, sArgs, CModInfo::GlobalModule, NULL, NULL, sModRet)) {\n\t\t\t\t\t\tsModLoadError = \"Unable to load module [\" + sModName + \"] [\" + sModRet + \"]\";\n\t\t\t\t\t}\n\t\t\t\t} else if (pMod->GetArgs() != sArgs) {\n\t\t\t\t\tif (!CZNC::Get().GetModules().ReloadModule(sModName, sArgs, NULL, NULL, sModRet)) {\n\t\t\t\t\t\tsModLoadError = \"Unable to reload module [\" + sModName + \"] [\" + sModRet + \"]\";\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!sModLoadError.empty()) {\n\t\t\t\t\tDEBUG(sModLoadError);\n\t\t\t\t\tWebSock.GetSession()->AddError(sModLoadError);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst CModules& vCurMods = CZNC::Get().GetModules();\n\t\tset ssUnloadMods;\n\n\t\tfor (a = 0; a < vCurMods.size(); a++) {\n\t\t\tCModule* pCurMod = vCurMods[a];\n\n\t\t\tif (ssArgs.find(pCurMod->GetModName()) == ssArgs.end() &&\n\t\t\t\t\t(CModInfo::GlobalModule != GetType() || pCurMod->GetModName() != GetModName())) {\n\t\t\t\tssUnloadMods.insert(pCurMod->GetModName());\n\t\t\t}\n\t\t}\n\n\t\tfor (set::iterator it2 = ssUnloadMods.begin(); it2 != ssUnloadMods.end(); ++it2) {\n\t\t\tCZNC::Get().GetModules().UnloadModule(*it2);\n\t\t}\n\n\t\tif (!CZNC::Get().WriteConfig()) {\n\t\t\tWebSock.GetSession()->AddError(\"Settings changed, but config was not written\");\n\t\t}\n\n\t\tWebSock.Redirect(GetWebPath() + \"settings\");\n\t\t\/* we don't want the template to be printed while we redirect *\/\n\t\treturn false;\n\t}","target":0,"code_token_length":1926,"total_token_length":2162,"max_tokens_setting":4096}
+{"idx":152486,"func":"    void JavascriptArray::ArraySpliceHelper(JavascriptArray* pnewArr, JavascriptArray* pArr, uint32 start, uint32 deleteLen, Var* insertArgs, uint32 insertLen, ScriptContext *scriptContext)\n    {\n        \/\/ Skip pnewArr->EnsureHead(): we don't use existing segment at all.\n        Recycler *recycler  = scriptContext->GetRecycler();\n\n        SparseArraySegmentBase** prevSeg  = &pArr->head;        \/\/ holds the next pointer of previous\n        SparseArraySegmentBase** prevPrevSeg  = &pArr->head;    \/\/ this holds the previous pointer to prevSeg dirty trick.\n        SparseArraySegmentBase* savePrev = nullptr;\n\n        Assert(pArr->head); \/\/ We should never have a null head.\n        pArr->EnsureHead();\n        SparseArraySegment* startSeg = (SparseArraySegment*)pArr->head;\n\n        const uint32 limit = start + deleteLen;\n        uint32 rightLimit;\n        if (UInt32Math::Add(startSeg->left, startSeg->size, &rightLimit))\n        {\n            rightLimit = JavascriptArray::MaxArrayLength;\n        }\n\n        \/\/ Find out the segment to start delete\n        while (startSeg && (rightLimit <= start))\n        {\n            savePrev = startSeg;\n            prevPrevSeg = prevSeg;\n            prevSeg = &startSeg->next;\n            startSeg = (SparseArraySegment*)startSeg->next;\n\n            if (startSeg)\n            {\n                if (UInt32Math::Add(startSeg->left, startSeg->size, &rightLimit))\n                {\n                    rightLimit = JavascriptArray::MaxArrayLength;\n                }\n            }\n        }\n\n        \/\/ handle inlined segment\n        SparseArraySegmentBase* inlineHeadSegment = nullptr;\n        bool hasInlineSegment = false;\n        \/\/ The following if else set is used to determine whether a shallow or hard copy is needed\n        if (JavascriptNativeArray::Is(pArr))\n        {\n            if (JavascriptNativeFloatArray::Is(pArr))\n            {\n                inlineHeadSegment = DetermineInlineHeadSegmentPointer((JavascriptNativeFloatArray*)pArr);\n            }\n            else if (JavascriptNativeIntArray::Is(pArr))\n            {\n                inlineHeadSegment = DetermineInlineHeadSegmentPointer((JavascriptNativeIntArray*)pArr);\n            }\n            Assert(inlineHeadSegment);\n            hasInlineSegment = (startSeg == (SparseArraySegment*)inlineHeadSegment);\n        }\n        else\n        {\n            \/\/ This will result in false positives. It is used because DetermineInlineHeadSegmentPointer\n            \/\/ does not handle Arrays that change type e.g. from JavascriptNativeIntArray to JavascriptArray\n            \/\/ This conversion in particular is problematic because JavascriptNativeIntArray is larger than JavascriptArray\n            \/\/ so the returned head segment ptr never equals pArr->head. So we will default to using this and deal with\n            \/\/ false positives. It is better than always doing a hard copy.\n            hasInlineSegment = HasInlineHeadSegment(pArr->head->length);\n        }\n\n        if (startSeg)\n        {\n            \/\/ Delete Phase\n            if (startSeg->left <= start && (startSeg->left + startSeg->length) >= limit)\n            {\n                \/\/ All splice happens in one segment.\n                SparseArraySegmentBase *nextSeg = startSeg->next;\n                \/\/ Splice the segment first, which might OOM throw but the array would be intact.\n                JavascriptArray::ArraySegmentSpliceHelper(pnewArr, (SparseArraySegment*)startSeg, (SparseArraySegment**)prevSeg, start, deleteLen, insertArgs, insertLen, recycler);\n                while (nextSeg)\n                {\n                    \/\/ adjust next segments left\n                    nextSeg->left = nextSeg->left - deleteLen + insertLen;\n                    if (nextSeg->next == nullptr)\n                    {\n                        nextSeg->EnsureSizeInBound();\n                    }\n                    nextSeg = nextSeg->next;\n                }\n                if (*prevSeg)\n                {\n                    (*prevSeg)->EnsureSizeInBound();\n                }\n                return;\n            }\n            else\n            {\n                SparseArraySegment* newHeadSeg = nullptr; \/\/ pnewArr->head is null\n                SparseArraySegmentBase** prevNewHeadSeg = &(pnewArr->head);\n\n                \/\/ delete till deleteLen and reuse segments for new array if it is possible.\n                \/\/ 3 steps -\n                \/\/1. delete 1st segment (which may be partial delete)\n                \/\/ 2. delete next n complete segments\n                \/\/ 3. delete last segment (which again may be partial delete)\n\n                \/\/ Step (1)  -- WOOB 1116297: When left >= start, step (1) is skipped, resulting in pNewArr->head->left != 0. We need to touch up pNewArr.\n                if (startSeg->left < start)\n                {\n                    if (start < startSeg->left + startSeg->length)\n                    {\n                        uint32 headDeleteLen = startSeg->left + startSeg->length - start;\n\n                        if (startSeg->next)\n                        {\n                            \/\/ We know the new segment will have a next segment, so allocate it as non-leaf.\n                            newHeadSeg = SparseArraySegment::template AllocateSegmentImpl(recycler, 0, headDeleteLen, headDeleteLen, nullptr);\n                        }\n                        else\n                        {\n                            newHeadSeg = SparseArraySegment::AllocateSegment(recycler, 0, headDeleteLen, headDeleteLen, nullptr);\n                        }\n                        newHeadSeg = SparseArraySegment::CopySegment(recycler, newHeadSeg, 0, startSeg, start, headDeleteLen);\n                        newHeadSeg->next = nullptr;\n                        *prevNewHeadSeg = newHeadSeg;\n                        prevNewHeadSeg = &newHeadSeg->next;\n                        startSeg->Truncate(start);\n                    }\n                    savePrev = startSeg;\n                    prevPrevSeg = prevSeg;\n                    prevSeg = &startSeg->next;\n                    startSeg = (SparseArraySegment*)startSeg->next;\n                }\n\n                \/\/ Step (2) first we should do a hard copy if we have an inline head Segment\n                else if (hasInlineSegment && nullptr != startSeg)\n                {\n                    \/\/ start should be in between left and left + length\n                    if (startSeg->left  <= start && start < startSeg->left + startSeg->length)\n                    {\n                        uint32 headDeleteLen = startSeg->left + startSeg->length - start;\n                        if (startSeg->next)\n                        {\n                            \/\/ We know the new segment will have a next segment, so allocate it as non-leaf.\n                            newHeadSeg = SparseArraySegment::template AllocateSegmentImpl(recycler, 0, headDeleteLen, headDeleteLen, nullptr);\n                        }\n                        else\n                        {\n                            newHeadSeg = SparseArraySegment::AllocateSegment(recycler, 0, headDeleteLen, headDeleteLen, nullptr);\n                        }\n                        newHeadSeg = SparseArraySegment::CopySegment(recycler, newHeadSeg, 0, startSeg, start, headDeleteLen);\n                        *prevNewHeadSeg = newHeadSeg;\n                        prevNewHeadSeg = &newHeadSeg->next;\n\n                        \/\/ Remove the entire segment from the original array\n                        *prevSeg = startSeg->next;\n                        startSeg = (SparseArraySegment*)startSeg->next;\n                    }\n                    \/\/ if we have an inline head segment with 0 elements, remove it\n                    else if (startSeg->left == 0 && startSeg->length == 0)\n                    {\n                        Assert(startSeg->size != 0);\n                        *prevSeg = startSeg->next;\n                        startSeg = (SparseArraySegment*)startSeg->next;\n                    }\n                }\n                \/\/ Step (2) proper\n                SparseArraySegmentBase *temp = nullptr;\n                while (startSeg && (startSeg->left + startSeg->length) <= limit)\n                {\n                    temp = startSeg->next;\n\n                    \/\/ move that entire segment to new array\n                    startSeg->left = startSeg->left - start;\n                    startSeg->next = nullptr;\n                    *prevNewHeadSeg = startSeg;\n                    prevNewHeadSeg = &startSeg->next;\n\n                    \/\/ Remove the entire segment from the original array\n                    *prevSeg = temp;\n                    startSeg = (SparseArraySegment*)temp;\n                }\n\n                \/\/ Step(2) above could delete the original head segment entirely, causing current head not\n                \/\/ starting from 0. Then if any of the following throw, we have a corrupted array. Need\n                \/\/ protection here.\n                bool dummyHeadNodeInserted = false;\n                if (!savePrev && (!startSeg || startSeg->left != 0))\n                {\n                    Assert(pArr->head == startSeg);\n                    pArr->EnsureHeadStartsFromZero(recycler);\n                    Assert(pArr->head && pArr->head->next == startSeg);\n\n                    savePrev = pArr->head;\n                    prevPrevSeg = prevSeg;\n                    prevSeg = &pArr->head->next;\n                    dummyHeadNodeInserted = true;\n                }\n\n                \/\/ Step (3)\n                if (startSeg && (startSeg->left < limit))\n                {\n                    \/\/ copy the first part of the last segment to be deleted to new array\n                    uint32 headDeleteLen = start + deleteLen - startSeg->left ;\n\n                    newHeadSeg = SparseArraySegment::AllocateSegment(recycler, startSeg->left -  start, headDeleteLen, (SparseArraySegmentBase *)nullptr);\n                    newHeadSeg = SparseArraySegment::CopySegment(recycler, newHeadSeg, startSeg->left -  start, startSeg, startSeg->left, headDeleteLen);\n                    newHeadSeg->next = nullptr;\n                    *prevNewHeadSeg = newHeadSeg;\n                    prevNewHeadSeg = &newHeadSeg->next;\n\n                    \/\/ move the last segment\n                    memmove(startSeg->elements, startSeg->elements + headDeleteLen, sizeof(T) * (startSeg->length - headDeleteLen));\n                    startSeg->left = startSeg->left + headDeleteLen; \/\/ We are moving the left ahead to point to the right index\n                    startSeg->length = startSeg->length - headDeleteLen;\n                    startSeg->Truncate(startSeg->left + startSeg->length);\n                    startSeg->EnsureSizeInBound(); \/\/ Just truncated, size might exceed next.left\n                }\n\n                if (startSeg && ((startSeg->left - deleteLen + insertLen) == 0) && dummyHeadNodeInserted)\n                {\n                    Assert(start + insertLen == 0);\n                    \/\/ Remove the dummy head node to preserve array consistency.\n                    pArr->head = startSeg;\n                    savePrev = nullptr;\n                    prevSeg = &pArr->head;\n                }\n\n                while (startSeg)\n                {\n                    startSeg->left = startSeg->left - deleteLen + insertLen ;\n                    if (startSeg->next == nullptr)\n                    {\n                        startSeg->EnsureSizeInBound();\n                    }\n                    startSeg = (SparseArraySegment*)startSeg->next;\n                }\n            }\n        }\n\n        \/\/ The size of pnewArr head allocated in above step 1 might exceed next.left concatenated in step 2\/3.\n        pnewArr->head->EnsureSizeInBound();\n        if (savePrev)\n        {\n            savePrev->EnsureSizeInBound();\n        }\n\n        \/\/ insert elements\n        if (insertLen > 0)\n        {\n            Assert(!JavascriptNativeIntArray::Is(pArr) && !JavascriptNativeFloatArray::Is(pArr));\n\n            \/\/ InsertPhase\n            SparseArraySegment *segInsert = nullptr;\n\n            \/\/ see if we are just about the right of the previous segment\n            Assert(!savePrev || savePrev->left <= start);\n            if (savePrev && (start - savePrev->left < savePrev->size))\n            {\n                segInsert = (SparseArraySegment*)savePrev;\n                uint32 spaceLeft = segInsert->size - (start - segInsert->left);\n                if(spaceLeft < insertLen)\n                {\n                    if (!segInsert->next)\n                    {\n                        segInsert = segInsert->GrowByMin(recycler, insertLen - spaceLeft);\n                    }\n                    else\n                    {\n                        segInsert = segInsert->GrowByMinMax(recycler, insertLen - spaceLeft, segInsert->next->left - segInsert->left - segInsert->size);\n                    }\n                }\n                *prevPrevSeg = segInsert;\n                segInsert->length = start + insertLen - segInsert->left;\n            }\n            else\n            {\n                segInsert = SparseArraySegment::AllocateSegment(recycler, start, insertLen, *prevSeg);\n                segInsert->next = *prevSeg;\n                *prevSeg = segInsert;\n                savePrev = segInsert;\n            }\n\n            uint32 relativeStart = start - segInsert->left;\n            \/\/ inserted elements starts at argument 3 of splice(start, deleteNumber, insertelem1, insertelem2, insertelem3, ...);\n            js_memcpy_s(segInsert->elements + relativeStart, sizeof(T) * insertLen, insertArgs, sizeof(T) * insertLen);\n        }\n    }","target":0,"code_token_length":2852,"total_token_length":3088,"max_tokens_setting":4096}
+{"idx":480220,"func":"static int rotateLogSet(const struct logInfo *log, int force)\n{\n    unsigned i, j;\n    int hasErrors = 0;\n    int *logHasErrors;\n    int numRotated = 0;\n    struct logState **state;\n    struct logNames **rotNames;\n\n    message(MESS_DEBUG, \"\\nrotating pattern: %s \", log->pattern);\n    if (force) {\n        message(MESS_DEBUG, \"forced from command line \");\n    }\n    else {\n        switch (log->criterium) {\n            case ROT_HOURLY:\n                message(MESS_DEBUG, \"hourly \");\n                break;\n            case ROT_DAYS:\n                message(MESS_DEBUG, \"after %jd days \", (intmax_t)log->threshold);\n                break;\n            case ROT_WEEKLY:\n                message(MESS_DEBUG, \"weekly \");\n                break;\n            case ROT_MONTHLY:\n                message(MESS_DEBUG, \"monthly \");\n                break;\n            case ROT_YEARLY:\n                message(MESS_DEBUG, \"yearly \");\n                break;\n            case ROT_SIZE:\n                message(MESS_DEBUG, \"%jd bytes \", (intmax_t)log->threshold);\n                break;\n            default:\n                message(MESS_FATAL, \"rotateLogSet() does not have case for: %u \",\n                        (unsigned) log->criterium);\n        }\n    }\n\n    if (log->rotateCount > 0)\n        message(MESS_DEBUG, \"(%d rotations)\\n\", log->rotateCount);\n    else if (log->rotateCount == 0)\n        message(MESS_DEBUG, \"(no old logs will be kept)\\n\");\n\n    if (log->oldDir)\n        message(MESS_DEBUG, \"olddir is %s, \", log->oldDir);\n\n    if (log->flags & LOG_FLAG_IFEMPTY)\n        message(MESS_DEBUG, \"empty log files are rotated, \");\n    else\n        message(MESS_DEBUG, \"empty log files are not rotated, \");\n\n    if (log->minsize)\n        message(MESS_DEBUG, \"only log files >= %jd bytes are rotated, \", (intmax_t)log->minsize);\n\n    if (log->maxsize)\n        message(MESS_DEBUG, \"log files >= %jd are rotated earlier, \", (intmax_t)log->maxsize);\n\n    if (log->rotateMinAge)\n        message(MESS_DEBUG, \"only log files older than %d days are rotated, \", log->rotateMinAge);\n\n    if (log->logAddress) {\n        message(MESS_DEBUG, \"old logs mailed to %s\\n\", log->logAddress);\n    } else {\n        message(MESS_DEBUG, \"old logs are removed\\n\");\n    }\n\n    if (log->numFiles == 0) {\n        message(MESS_DEBUG, \"No logs found. Rotation not needed.\\n\");\n        return 0;\n    }\n\n    logHasErrors = calloc(log->numFiles, sizeof(int));\n    if (!logHasErrors) {\n        message_OOM();\n        return 1;\n    }\n\n    if (log->flags & LOG_FLAG_SU) {\n        if (switch_user(log->suUid, log->suGid) != 0) {\n            free(logHasErrors);\n            return 1;\n        }\n    }\n\n    for (i = 0; i < log->numFiles; i++) {\n        struct logState *logState;\n        logHasErrors[i] = findNeedRotating(log, i, force);\n        hasErrors |= logHasErrors[i];\n\n        \/* sure is a lot of findStating going on .. *\/\n        if (((logState = findState(log->files[i]))) && logState->doRotate)\n            numRotated++;\n    }\n\n    if (log->first) {\n        if (!numRotated) {\n            message(MESS_DEBUG, \"not running first action script, \"\n                    \"since no logs will be rotated\\n\");\n        } else {\n            message(MESS_DEBUG, \"running first action script\\n\");\n            if (runScript(log, log->pattern, NULL, log->first)) {\n                message(MESS_ERROR, \"error running first action script \"\n                        \"for %s\\n\", log->pattern);\n                hasErrors = 1;\n                if (log->flags & LOG_FLAG_SU) {\n                    if (switch_user_back() != 0) {\n                        free(logHasErrors);\n                        return 1;\n                    }\n                }\n                \/* finish early, firstaction failed, affects all logs in set *\/\n                free(logHasErrors);\n                return hasErrors;\n            }\n        }\n    }\n\n    state = malloc(log->numFiles * sizeof(struct logState *));\n    rotNames = malloc(log->numFiles * sizeof(struct logNames *));\n\n    if (state == NULL || rotNames == NULL) {\n        message_OOM();\n        if (log->flags & LOG_FLAG_SU) {\n            switch_user_back();\n        }\n        free(rotNames);\n        free(state);\n        free(logHasErrors);\n        return 1;\n    }\n\n    for (j = 0;\n            (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && j < log->numFiles)\n            || ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && j < 1); j++) {\n\n        for (i = j;\n                ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)\n                || (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {\n            state[i] = findState(log->files[i]);\n            if (!state[i])\n                logHasErrors[i] = 1;\n\n            rotNames[i] = malloc(sizeof(struct logNames));\n            if (rotNames[i] == NULL) {\n                message_OOM();\n                if (log->flags & LOG_FLAG_SU) {\n                    switch_user_back();\n                }\n                free(rotNames);\n                free(state);\n                free(logHasErrors);\n                return 1;\n            }\n            memset(rotNames[i], 0, sizeof(struct logNames));\n\n            logHasErrors[i] |=\n                prerotateSingleLog(log, i, state[i], rotNames[i]);\n            hasErrors |= logHasErrors[i];\n        }\n\n        if (log->pre\n                && (!(\n                        (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && (logHasErrors[j] || !state[j]->doRotate))\n                        || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS))\n                     ))\n           ) {\n            if (!numRotated) {\n                message(MESS_DEBUG, \"not running prerotate script, \"\n                        \"since no logs will be rotated\\n\");\n            } else {\n                message(MESS_DEBUG, \"running prerotate script\\n\");\n                if (runScript(log, (log->flags & LOG_FLAG_SHAREDSCRIPTS) ? log->pattern : log->files[j], NULL, log->pre)) {\n                    if (log->flags & LOG_FLAG_SHAREDSCRIPTS)\n                        message(MESS_ERROR,\n                                \"error running shared prerotate script \"\n                                \"for '%s'\\n\", log->pattern);\n                    else {\n                        message(MESS_ERROR,\n                                \"error running non-shared prerotate script \"\n                                \"for %s of '%s'\\n\", log->files[j], log->pattern);\n                    }\n                    logHasErrors[j] = 1;\n                    hasErrors = 1;\n                }\n            }\n        }\n\n        for (i = j;\n                ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)\n                || (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {\n            if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))\n                        || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) {\n                logHasErrors[i] |=\n                    rotateSingleLog(log, i, state[i], rotNames[i]);\n                hasErrors |= logHasErrors[i];\n            }\n        }\n\n        if (log->post\n                && (!(\n                        (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && (logHasErrors[j] || !state[j]->doRotate))\n                        || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS))\n                     ))\n           ) {\n            if (!numRotated) {\n                message(MESS_DEBUG, \"not running postrotate script, \"\n                        \"since no logs were rotated\\n\");\n            } else {\n                char *logfn = (log->flags & LOG_FLAG_SHAREDSCRIPTS) ? log->pattern : log->files[j];\n\n                \/* It only makes sense to pass in a final rotated filename if scripts are not shared *\/\n                char *logrotfn = (log->flags & LOG_FLAG_SHAREDSCRIPTS) ? NULL : rotNames[j]->finalName;\n\n                message(MESS_DEBUG, \"running postrotate script\\n\");\n                if (runScript(log, logfn, logrotfn, log->post)) {\n                    if (log->flags & LOG_FLAG_SHAREDSCRIPTS)\n                        message(MESS_ERROR,\n                                \"error running shared postrotate script \"\n                                \"for '%s'\\n\", log->pattern);\n                    else {\n                        message(MESS_ERROR,\n                                \"error running non-shared postrotate script \"\n                                \"for %s of '%s'\\n\", log->files[j], log->pattern);\n                    }\n                    logHasErrors[j] = 1;\n                    hasErrors = 1;\n                }\n            }\n        }\n\n        for (i = j;\n                ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)\n                || (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {\n            if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))\n                        || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) {\n                logHasErrors[i] |=\n                    postrotateSingleLog(log, i, state[i], rotNames[i]);\n                hasErrors |= logHasErrors[i];\n            }\n        }\n\n    }\n\n    for (i = 0; i < log->numFiles; i++) {\n        free(rotNames[i]->firstRotated);\n        free(rotNames[i]->disposeName);\n        free(rotNames[i]->finalName);\n        free(rotNames[i]->dirName);\n        free(rotNames[i]->baseName);\n        free(rotNames[i]);\n    }\n    free(rotNames);\n    free(state);\n\n    if (log->last) {\n        if (!numRotated) {\n            message(MESS_DEBUG, \"not running last action script, \"\n                    \"since no logs will be rotated\\n\");\n        } else {\n            message(MESS_DEBUG, \"running last action script\\n\");\n            if (runScript(log, log->pattern, NULL, log->last)) {\n                message(MESS_ERROR, \"error running last action script \"\n                        \"for %s\\n\", log->pattern);\n                hasErrors = 1;\n            }\n        }\n    }\n\n    if (log->flags & LOG_FLAG_SU) {\n        if (switch_user_back() != 0) {\n            free(logHasErrors);\n            return 1;\n        }\n    }\n    free(logHasErrors);\n    return hasErrors;\n}","target":0,"code_token_length":2337,"total_token_length":2573,"max_tokens_setting":4096}
+{"idx":6777,"func":"void *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child)\n{\n    directory_config *parent = (directory_config *)_parent;\n    directory_config *child = (directory_config *)_child;\n    directory_config *merged = create_directory_config(mp, NULL);\n\n    #ifdef DEBUG_CONF\n    ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_NOERRNO, 0, mp, \"Merge parent %pp child %pp RESULT %pp\", _parent, _child, merged);\n    #endif\n\n    if (merged == NULL) return NULL;\n\n    \/* Use values from the child configuration where possible,\n     * otherwise use the parent's.\n     *\/\n\n    merged->is_enabled = (child->is_enabled == NOT_SET\n        ? parent->is_enabled : child->is_enabled);\n\n    \/* IO parameters *\/\n    merged->reqbody_access = (child->reqbody_access == NOT_SET\n        ? parent->reqbody_access : child->reqbody_access);\n    merged->reqbody_buffering = (child->reqbody_buffering == NOT_SET\n        ? parent->reqbody_buffering : child->reqbody_buffering);\n    merged->reqbody_inmemory_limit = (child->reqbody_inmemory_limit == NOT_SET\n        ? parent->reqbody_inmemory_limit : child->reqbody_inmemory_limit);\n    merged->reqbody_limit = (child->reqbody_limit == NOT_SET\n        ? parent->reqbody_limit : child->reqbody_limit);\n    merged->reqbody_no_files_limit = (child->reqbody_no_files_limit == NOT_SET\n        ? parent->reqbody_no_files_limit : child->reqbody_no_files_limit);\n    merged->resbody_access = (child->resbody_access == NOT_SET\n        ? parent->resbody_access : child->resbody_access);\n\n    merged->of_limit = (child->of_limit == NOT_SET\n        ? parent->of_limit : child->of_limit);\n    merged->if_limit_action = (child->if_limit_action == NOT_SET\n        ? parent->if_limit_action : child->if_limit_action);\n    merged->of_limit_action = (child->of_limit_action == NOT_SET\n        ? parent->of_limit_action : child->of_limit_action);\n    merged->reqintercept_oe = (child->reqintercept_oe == NOT_SET\n        ? parent->reqintercept_oe : child->reqintercept_oe);\n\n    if (child->of_mime_types != NOT_SET_P) {\n        \/* Child added to the table *\/\n\n        if (child->of_mime_types_cleared == 1) {\n            \/* The list of MIME types was cleared in the child,\n             * which means the parent's MIME types went away and\n             * we should not take them into consideration here.\n             *\/\n            merged->of_mime_types = child->of_mime_types;\n            merged->of_mime_types_cleared = 1;\n        } else {\n            \/* Add MIME types defined in the child to those\n             * defined in the parent context.\n             *\/\n            if (parent->of_mime_types == NOT_SET_P) {\n                merged->of_mime_types = child->of_mime_types;\n                merged->of_mime_types_cleared = NOT_SET;\n            } else {\n                merged->of_mime_types = apr_table_overlay(mp, parent->of_mime_types,\n                    child->of_mime_types);\n                if (merged->of_mime_types == NULL) return NULL;\n            }\n        }\n    } else {\n        \/* Child did not add to the table *\/\n\n        if (child->of_mime_types_cleared == 1) {\n            merged->of_mime_types_cleared = 1;\n        } else {\n            merged->of_mime_types = parent->of_mime_types;\n            merged->of_mime_types_cleared = parent->of_mime_types_cleared;\n        }\n    }\n\n    \/* debug log *\/\n    if (child->debuglog_fd == NOT_SET_P) {\n        merged->debuglog_name = parent->debuglog_name;\n        merged->debuglog_fd = parent->debuglog_fd;\n    } else {\n        merged->debuglog_name = child->debuglog_name;\n        merged->debuglog_fd = child->debuglog_fd;\n    }\n\n    merged->debuglog_level = (child->debuglog_level == NOT_SET\n        ? parent->debuglog_level : child->debuglog_level);\n\n    merged->cookie_format = (child->cookie_format == NOT_SET\n        ? parent->cookie_format : child->cookie_format);\n    merged->argument_separator = (child->argument_separator == NOT_SET\n        ? parent->argument_separator : child->argument_separator);\n    merged->cookiev0_separator = (child->cookiev0_separator == NOT_SET_P\n        ? parent->cookiev0_separator : child->cookiev0_separator);\n\n\n    \/* rule inheritance *\/\n    if ((child->rule_inheritance == NOT_SET)||(child->rule_inheritance == 1)) {\n        merged->rule_inheritance = parent->rule_inheritance;\n        if ((child->ruleset == NULL)&&(parent->ruleset == NULL)) {\n            #ifdef DEBUG_CONF\n            ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_NOERRNO, 0, mp, \"No rules in this context.\");\n            #endif\n\n            \/* Do nothing, there are no rules in either context. *\/\n        } else\n        if (child->ruleset == NULL) {\n            #ifdef DEBUG_CONF\n            ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_NOERRNO, 0, mp, \"Using parent rules in this context.\");\n            #endif\n\n            \/* Copy the rules from the parent context. *\/\n            merged->ruleset = msre_ruleset_create(parent->ruleset->engine, mp);\n            copy_rules(mp, parent->ruleset, merged->ruleset, child->rule_exceptions);\n        } else\n        if (parent->ruleset == NULL) {\n            #ifdef DEBUG_CONF\n            ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_NOERRNO, 0, mp, \"Using child rules in this context.\");\n            #endif\n\n            \/* Copy child rules. *\/\n            merged->ruleset = msre_ruleset_create(child->ruleset->engine, mp);\n            merged->ruleset->phase_request_headers = apr_array_copy(mp,\n                child->ruleset->phase_request_headers);\n            merged->ruleset->phase_request_body = apr_array_copy(mp,\n                child->ruleset->phase_request_body);\n            merged->ruleset->phase_response_headers = apr_array_copy(mp,\n                child->ruleset->phase_response_headers);\n            merged->ruleset->phase_response_body = apr_array_copy(mp,\n                child->ruleset->phase_response_body);\n            merged->ruleset->phase_logging = apr_array_copy(mp,\n                child->ruleset->phase_logging);\n        } else {\n            #ifdef DEBUG_CONF\n            ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_NOERRNO, 0, mp, \"Using parent then child rules in this context.\");\n            #endif\n\n            \/* Copy parent rules, then add child rules to it. *\/\n            merged->ruleset = msre_ruleset_create(parent->ruleset->engine, mp);\n            copy_rules(mp, parent->ruleset, merged->ruleset, child->rule_exceptions);\n\n            apr_array_cat(merged->ruleset->phase_request_headers,\n                child->ruleset->phase_request_headers);\n            apr_array_cat(merged->ruleset->phase_request_body,\n                child->ruleset->phase_request_body);\n            apr_array_cat(merged->ruleset->phase_response_headers,\n                child->ruleset->phase_response_headers);\n            apr_array_cat(merged->ruleset->phase_response_body,\n                child->ruleset->phase_response_body);\n            apr_array_cat(merged->ruleset->phase_logging,\n                child->ruleset->phase_logging);\n        }\n    } else {\n        merged->rule_inheritance = 0;\n        if (child->ruleset != NULL) {\n            \/* Copy child rules. *\/\n            merged->ruleset = msre_ruleset_create(child->ruleset->engine, mp);\n            merged->ruleset->phase_request_headers = apr_array_copy(mp,\n                child->ruleset->phase_request_headers);\n            merged->ruleset->phase_request_body = apr_array_copy(mp,\n                child->ruleset->phase_request_body);\n            merged->ruleset->phase_response_headers = apr_array_copy(mp,\n                child->ruleset->phase_response_headers);\n            merged->ruleset->phase_response_body = apr_array_copy(mp,\n                child->ruleset->phase_response_body);\n            merged->ruleset->phase_logging = apr_array_copy(mp,\n                child->ruleset->phase_logging);\n        }\n    }\n\n    \/* Merge rule exceptions. *\/\n    merged->rule_exceptions = apr_array_append(mp, parent->rule_exceptions,\n        child->rule_exceptions);\n\n    merged->hash_method = apr_array_append(mp, parent->hash_method,\n        child->hash_method);\n\n    \/* audit log variables *\/\n    merged->auditlog_flag = (child->auditlog_flag == NOT_SET\n        ? parent->auditlog_flag : child->auditlog_flag);\n    merged->auditlog_type = (child->auditlog_type == NOT_SET\n        ? parent->auditlog_type : child->auditlog_type);\n    merged->max_rule_time = (child->max_rule_time == NOT_SET\n        ? parent->max_rule_time : child->max_rule_time);\n    merged->auditlog_dirperms = (child->auditlog_dirperms == NOT_SET\n        ? parent->auditlog_dirperms : child->auditlog_dirperms);\n    merged->auditlog_fileperms = (child->auditlog_fileperms == NOT_SET\n        ? parent->auditlog_fileperms : child->auditlog_fileperms);\n    if (child->auditlog_fd != NOT_SET_P) {\n        merged->auditlog_fd = child->auditlog_fd;\n        merged->auditlog_name = child->auditlog_name;\n    } else {\n        merged->auditlog_fd = parent->auditlog_fd;\n        merged->auditlog_name = parent->auditlog_name;\n    }\n    if (child->auditlog2_fd != NOT_SET_P) {\n        merged->auditlog2_fd = child->auditlog2_fd;\n        merged->auditlog2_name = child->auditlog2_name;\n    } else {\n        merged->auditlog2_fd = parent->auditlog2_fd;\n        merged->auditlog2_name = parent->auditlog2_name;\n    }\n    merged->auditlog_storage_dir = (child->auditlog_storage_dir == NOT_SET_P\n        ? parent->auditlog_storage_dir : child->auditlog_storage_dir);\n    merged->auditlog_parts = (child->auditlog_parts == NOT_SET_P\n        ? parent->auditlog_parts : child->auditlog_parts);\n    merged->auditlog_relevant_regex = (child->auditlog_relevant_regex == NOT_SET_P\n        ? parent->auditlog_relevant_regex : child->auditlog_relevant_regex);\n\n    \/* Upload *\/\n    merged->tmp_dir = (child->tmp_dir == NOT_SET_P\n        ? parent->tmp_dir : child->tmp_dir);\n    merged->upload_dir = (child->upload_dir == NOT_SET_P\n        ? parent->upload_dir : child->upload_dir);\n    merged->upload_keep_files = (child->upload_keep_files == NOT_SET\n        ? parent->upload_keep_files : child->upload_keep_files);\n    merged->upload_validates_files = (child->upload_validates_files == NOT_SET\n        ? parent->upload_validates_files : child->upload_validates_files);\n    merged->upload_filemode = (child->upload_filemode == NOT_SET\n        ? parent->upload_filemode : child->upload_filemode);\n    merged->upload_file_limit = (child->upload_file_limit == NOT_SET\n        ? parent->upload_file_limit : child->upload_file_limit);\n\n    \/* Misc *\/\n    merged->data_dir = (child->data_dir == NOT_SET_P\n        ? parent->data_dir : child->data_dir);\n    merged->webappid = (child->webappid == NOT_SET_P\n        ? parent->webappid : child->webappid);\n    merged->sensor_id = (child->sensor_id == NOT_SET_P\n        ? parent->sensor_id : child->sensor_id);\n    merged->httpBlkey = (child->httpBlkey == NOT_SET_P\n        ? parent->httpBlkey : child->httpBlkey);\n\n    \/* Content injection. *\/\n    merged->content_injection_enabled = (child->content_injection_enabled == NOT_SET\n        ? parent->content_injection_enabled : child->content_injection_enabled);\n\n    \/* Stream inspection *\/\n    merged->stream_inbody_inspection = (child->stream_inbody_inspection == NOT_SET\n        ? parent->stream_inbody_inspection : child->stream_inbody_inspection);\n    merged->stream_outbody_inspection = (child->stream_outbody_inspection == NOT_SET\n        ? parent->stream_outbody_inspection : child->stream_outbody_inspection);\n\n    \/* Geo Lookup *\/\n    merged->geo = (child->geo == NOT_SET_P\n        ? parent->geo : child->geo);\n\n    \/* Gsb Lookup *\/\n    merged->gsb = (child->gsb == NOT_SET_P\n        ? parent->gsb : child->gsb);\n\n    \/* Unicode Map *\/\n    merged->u_map = (child->u_map == NOT_SET_P\n        ? parent->u_map : child->u_map);\n\n    \/* Cache *\/\n    merged->cache_trans = (child->cache_trans == NOT_SET\n        ? parent->cache_trans : child->cache_trans);\n    merged->cache_trans_incremental = (child->cache_trans_incremental == NOT_SET\n        ? parent->cache_trans_incremental : child->cache_trans_incremental);\n    merged->cache_trans_min = (child->cache_trans_min == (apr_size_t)NOT_SET\n        ? parent->cache_trans_min : child->cache_trans_min);\n    merged->cache_trans_max = (child->cache_trans_max == (apr_size_t)NOT_SET\n        ? parent->cache_trans_max : child->cache_trans_max);\n    merged->cache_trans_maxitems = (child->cache_trans_maxitems == (apr_size_t)NOT_SET\n        ? parent->cache_trans_maxitems : child->cache_trans_maxitems);\n\n    \/* Merge component signatures. *\/\n    merged->component_signatures = apr_array_append(mp, parent->component_signatures,\n        child->component_signatures);\n\n    merged->request_encoding = (child->request_encoding == NOT_SET_P\n        ? parent->request_encoding : child->request_encoding);\n\n    merged->disable_backend_compression = (child->disable_backend_compression == NOT_SET\n        ? parent->disable_backend_compression : child->disable_backend_compression);\n\n    merged->col_timeout = (child->col_timeout == NOT_SET\n        ? parent->col_timeout : child->col_timeout);\n\n    \/* Hash *\/\n    merged->crypto_key = (child->crypto_key == NOT_SET_P\n        ? parent->crypto_key : child->crypto_key);\n    merged->crypto_key_len = (child->crypto_key_len == NOT_SET\n        ? parent->crypto_key_len : child->crypto_key_len);\n    merged->crypto_key_add = (child->crypto_key_add == NOT_SET\n        ? parent->crypto_key_add : child->crypto_key_add);\n    merged->crypto_param_name = (child->crypto_param_name == NOT_SET_P\n        ? parent->crypto_param_name : child->crypto_param_name);\n    merged->hash_is_enabled = (child->hash_is_enabled == NOT_SET\n        ? parent->hash_is_enabled : child->hash_is_enabled);\n    merged->hash_enforcement = (child->hash_enforcement == NOT_SET\n        ? parent->hash_enforcement : child->hash_enforcement);\n    merged->crypto_hash_href_rx = (child->crypto_hash_href_rx == NOT_SET\n        ? parent->crypto_hash_href_rx : child->crypto_hash_href_rx);\n    merged->crypto_hash_faction_rx = (child->crypto_hash_faction_rx == NOT_SET\n        ? parent->crypto_hash_faction_rx : child->crypto_hash_faction_rx);\n    merged->crypto_hash_location_rx = (child->crypto_hash_location_rx == NOT_SET\n        ? parent->crypto_hash_location_rx : child->crypto_hash_location_rx);\n    merged->crypto_hash_iframesrc_rx = (child->crypto_hash_iframesrc_rx == NOT_SET\n        ? parent->crypto_hash_iframesrc_rx : child->crypto_hash_iframesrc_rx);\n    merged->crypto_hash_framesrc_rx = (child->crypto_hash_framesrc_rx == NOT_SET\n        ? parent->crypto_hash_framesrc_rx : child->crypto_hash_framesrc_rx);\n    merged->crypto_hash_href_pm = (child->crypto_hash_href_pm == NOT_SET\n        ? parent->crypto_hash_href_pm : child->crypto_hash_href_pm);\n    merged->crypto_hash_faction_pm = (child->crypto_hash_faction_pm == NOT_SET\n        ? parent->crypto_hash_faction_pm : child->crypto_hash_faction_pm);\n    merged->crypto_hash_location_pm = (child->crypto_hash_location_pm == NOT_SET\n        ? parent->crypto_hash_location_pm : child->crypto_hash_location_pm);\n    merged->crypto_hash_iframesrc_pm = (child->crypto_hash_iframesrc_pm == NOT_SET\n        ? parent->crypto_hash_iframesrc_pm : child->crypto_hash_iframesrc_pm);\n    merged->crypto_hash_framesrc_pm = (child->crypto_hash_framesrc_pm == NOT_SET\n        ? parent->crypto_hash_framesrc_pm : child->crypto_hash_framesrc_pm);\n\n    return merged;\n}","target":1,"code_token_length":3719,"total_token_length":3955,"max_tokens_setting":4096}
+{"idx":118127,"func":"long kvm_arch_vm_ioctl(struct file *filp,\n\t\t       unsigned int ioctl, unsigned long arg)\n{\n\tstruct kvm *kvm = filp->private_data;\n\tvoid __user *argp = (void __user *)arg;\n\tint r = -ENOTTY;\n\t\/*\n\t * This union makes it completely explicit to gcc-3.x\n\t * that these two variables' stack usage should be\n\t * combined, not added together.\n\t *\/\n\tunion {\n\t\tstruct kvm_pit_state ps;\n\t\tstruct kvm_pit_state2 ps2;\n\t\tstruct kvm_pit_config pit_config;\n\t} u;\n\n\tswitch (ioctl) {\n\tcase KVM_SET_TSS_ADDR:\n\t\tr = kvm_vm_ioctl_set_tss_addr(kvm, arg);\n\t\tbreak;\n\tcase KVM_SET_IDENTITY_MAP_ADDR: {\n\t\tu64 ident_addr;\n\n\t\tmutex_lock(&kvm->lock);\n\t\tr = -EINVAL;\n\t\tif (kvm->created_vcpus)\n\t\t\tgoto set_identity_unlock;\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&ident_addr, argp, sizeof(ident_addr)))\n\t\t\tgoto set_identity_unlock;\n\t\tr = kvm_vm_ioctl_set_identity_map_addr(kvm, ident_addr);\nset_identity_unlock:\n\t\tmutex_unlock(&kvm->lock);\n\t\tbreak;\n\t}\n\tcase KVM_SET_NR_MMU_PAGES:\n\t\tr = kvm_vm_ioctl_set_nr_mmu_pages(kvm, arg);\n\t\tbreak;\n\tcase KVM_GET_NR_MMU_PAGES:\n\t\tr = kvm_vm_ioctl_get_nr_mmu_pages(kvm);\n\t\tbreak;\n\tcase KVM_CREATE_IRQCHIP: {\n\t\tmutex_lock(&kvm->lock);\n\n\t\tr = -EEXIST;\n\t\tif (irqchip_in_kernel(kvm))\n\t\t\tgoto create_irqchip_unlock;\n\n\t\tr = -EINVAL;\n\t\tif (kvm->created_vcpus)\n\t\t\tgoto create_irqchip_unlock;\n\n\t\tr = kvm_pic_init(kvm);\n\t\tif (r)\n\t\t\tgoto create_irqchip_unlock;\n\n\t\tr = kvm_ioapic_init(kvm);\n\t\tif (r) {\n\t\t\tkvm_pic_destroy(kvm);\n\t\t\tgoto create_irqchip_unlock;\n\t\t}\n\n\t\tr = kvm_setup_default_irq_routing(kvm);\n\t\tif (r) {\n\t\t\tkvm_ioapic_destroy(kvm);\n\t\t\tkvm_pic_destroy(kvm);\n\t\t\tgoto create_irqchip_unlock;\n\t\t}\n\t\t\/* Write kvm->irq_routing before enabling irqchip_in_kernel. *\/\n\t\tsmp_wmb();\n\t\tkvm->arch.irqchip_mode = KVM_IRQCHIP_KERNEL;\n\t\tkvm_clear_apicv_inhibit(kvm, APICV_INHIBIT_REASON_ABSENT);\n\tcreate_irqchip_unlock:\n\t\tmutex_unlock(&kvm->lock);\n\t\tbreak;\n\t}\n\tcase KVM_CREATE_PIT:\n\t\tu.pit_config.flags = KVM_PIT_SPEAKER_DUMMY;\n\t\tgoto create_pit;\n\tcase KVM_CREATE_PIT2:\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&u.pit_config, argp,\n\t\t\t\t   sizeof(struct kvm_pit_config)))\n\t\t\tgoto out;\n\tcreate_pit:\n\t\tmutex_lock(&kvm->lock);\n\t\tr = -EEXIST;\n\t\tif (kvm->arch.vpit)\n\t\t\tgoto create_pit_unlock;\n\t\tr = -ENOMEM;\n\t\tkvm->arch.vpit = kvm_create_pit(kvm, u.pit_config.flags);\n\t\tif (kvm->arch.vpit)\n\t\t\tr = 0;\n\tcreate_pit_unlock:\n\t\tmutex_unlock(&kvm->lock);\n\t\tbreak;\n\tcase KVM_GET_IRQCHIP: {\n\t\t\/* 0: PIC master, 1: PIC slave, 2: IOAPIC *\/\n\t\tstruct kvm_irqchip *chip;\n\n\t\tchip = memdup_user(argp, sizeof(*chip));\n\t\tif (IS_ERR(chip)) {\n\t\t\tr = PTR_ERR(chip);\n\t\t\tgoto out;\n\t\t}\n\n\t\tr = -ENXIO;\n\t\tif (!irqchip_kernel(kvm))\n\t\t\tgoto get_irqchip_out;\n\t\tr = kvm_vm_ioctl_get_irqchip(kvm, chip);\n\t\tif (r)\n\t\t\tgoto get_irqchip_out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, chip, sizeof(*chip)))\n\t\t\tgoto get_irqchip_out;\n\t\tr = 0;\n\tget_irqchip_out:\n\t\tkfree(chip);\n\t\tbreak;\n\t}\n\tcase KVM_SET_IRQCHIP: {\n\t\t\/* 0: PIC master, 1: PIC slave, 2: IOAPIC *\/\n\t\tstruct kvm_irqchip *chip;\n\n\t\tchip = memdup_user(argp, sizeof(*chip));\n\t\tif (IS_ERR(chip)) {\n\t\t\tr = PTR_ERR(chip);\n\t\t\tgoto out;\n\t\t}\n\n\t\tr = -ENXIO;\n\t\tif (!irqchip_kernel(kvm))\n\t\t\tgoto set_irqchip_out;\n\t\tr = kvm_vm_ioctl_set_irqchip(kvm, chip);\n\tset_irqchip_out:\n\t\tkfree(chip);\n\t\tbreak;\n\t}\n\tcase KVM_GET_PIT: {\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&u.ps, argp, sizeof(struct kvm_pit_state)))\n\t\t\tgoto out;\n\t\tr = -ENXIO;\n\t\tif (!kvm->arch.vpit)\n\t\t\tgoto out;\n\t\tr = kvm_vm_ioctl_get_pit(kvm, &u.ps);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &u.ps, sizeof(struct kvm_pit_state)))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_PIT: {\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&u.ps, argp, sizeof(u.ps)))\n\t\t\tgoto out;\n\t\tmutex_lock(&kvm->lock);\n\t\tr = -ENXIO;\n\t\tif (!kvm->arch.vpit)\n\t\t\tgoto set_pit_out;\n\t\tr = kvm_vm_ioctl_set_pit(kvm, &u.ps);\nset_pit_out:\n\t\tmutex_unlock(&kvm->lock);\n\t\tbreak;\n\t}\n\tcase KVM_GET_PIT2: {\n\t\tr = -ENXIO;\n\t\tif (!kvm->arch.vpit)\n\t\t\tgoto out;\n\t\tr = kvm_vm_ioctl_get_pit2(kvm, &u.ps2);\n\t\tif (r)\n\t\t\tgoto out;\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(argp, &u.ps2, sizeof(u.ps2)))\n\t\t\tgoto out;\n\t\tr = 0;\n\t\tbreak;\n\t}\n\tcase KVM_SET_PIT2: {\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&u.ps2, argp, sizeof(u.ps2)))\n\t\t\tgoto out;\n\t\tmutex_lock(&kvm->lock);\n\t\tr = -ENXIO;\n\t\tif (!kvm->arch.vpit)\n\t\t\tgoto set_pit2_out;\n\t\tr = kvm_vm_ioctl_set_pit2(kvm, &u.ps2);\nset_pit2_out:\n\t\tmutex_unlock(&kvm->lock);\n\t\tbreak;\n\t}\n\tcase KVM_REINJECT_CONTROL: {\n\t\tstruct kvm_reinject_control control;\n\t\tr =  -EFAULT;\n\t\tif (copy_from_user(&control, argp, sizeof(control)))\n\t\t\tgoto out;\n\t\tr = -ENXIO;\n\t\tif (!kvm->arch.vpit)\n\t\t\tgoto out;\n\t\tr = kvm_vm_ioctl_reinject(kvm, &control);\n\t\tbreak;\n\t}\n\tcase KVM_SET_BOOT_CPU_ID:\n\t\tr = 0;\n\t\tmutex_lock(&kvm->lock);\n\t\tif (kvm->created_vcpus)\n\t\t\tr = -EBUSY;\n\t\telse\n\t\t\tkvm->arch.bsp_vcpu_id = arg;\n\t\tmutex_unlock(&kvm->lock);\n\t\tbreak;\n#ifdef CONFIG_KVM_XEN\n\tcase KVM_XEN_HVM_CONFIG: {\n\t\tstruct kvm_xen_hvm_config xhc;\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&xhc, argp, sizeof(xhc)))\n\t\t\tgoto out;\n\t\tr = kvm_xen_hvm_config(kvm, &xhc);\n\t\tbreak;\n\t}\n\tcase KVM_XEN_HVM_GET_ATTR: {\n\t\tstruct kvm_xen_hvm_attr xha;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&xha, argp, sizeof(xha)))\n\t\t\tgoto out;\n\t\tr = kvm_xen_hvm_get_attr(kvm, &xha);\n\t\tif (!r && copy_to_user(argp, &xha, sizeof(xha)))\n\t\t\tr = -EFAULT;\n\t\tbreak;\n\t}\n\tcase KVM_XEN_HVM_SET_ATTR: {\n\t\tstruct kvm_xen_hvm_attr xha;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&xha, argp, sizeof(xha)))\n\t\t\tgoto out;\n\t\tr = kvm_xen_hvm_set_attr(kvm, &xha);\n\t\tbreak;\n\t}\n\tcase KVM_XEN_HVM_EVTCHN_SEND: {\n\t\tstruct kvm_irq_routing_xen_evtchn uxe;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&uxe, argp, sizeof(uxe)))\n\t\t\tgoto out;\n\t\tr = kvm_xen_hvm_evtchn_send(kvm, &uxe);\n\t\tbreak;\n\t}\n#endif\n\tcase KVM_SET_CLOCK:\n\t\tr = kvm_vm_ioctl_set_clock(kvm, argp);\n\t\tbreak;\n\tcase KVM_GET_CLOCK:\n\t\tr = kvm_vm_ioctl_get_clock(kvm, argp);\n\t\tbreak;\n\tcase KVM_SET_TSC_KHZ: {\n\t\tu32 user_tsc_khz;\n\n\t\tr = -EINVAL;\n\t\tuser_tsc_khz = (u32)arg;\n\n\t\tif (kvm_has_tsc_control &&\n\t\t    user_tsc_khz >= kvm_max_guest_tsc_khz)\n\t\t\tgoto out;\n\n\t\tif (user_tsc_khz == 0)\n\t\t\tuser_tsc_khz = tsc_khz;\n\n\t\tWRITE_ONCE(kvm->arch.default_tsc_khz, user_tsc_khz);\n\t\tr = 0;\n\n\t\tgoto out;\n\t}\n\tcase KVM_GET_TSC_KHZ: {\n\t\tr = READ_ONCE(kvm->arch.default_tsc_khz);\n\t\tgoto out;\n\t}\n\tcase KVM_MEMORY_ENCRYPT_OP: {\n\t\tr = -ENOTTY;\n\t\tif (!kvm_x86_ops.mem_enc_ioctl)\n\t\t\tgoto out;\n\n\t\tr = static_call(kvm_x86_mem_enc_ioctl)(kvm, argp);\n\t\tbreak;\n\t}\n\tcase KVM_MEMORY_ENCRYPT_REG_REGION: {\n\t\tstruct kvm_enc_region region;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(®ion, argp, sizeof(region)))\n\t\t\tgoto out;\n\n\t\tr = -ENOTTY;\n\t\tif (!kvm_x86_ops.mem_enc_register_region)\n\t\t\tgoto out;\n\n\t\tr = static_call(kvm_x86_mem_enc_register_region)(kvm, ®ion);\n\t\tbreak;\n\t}\n\tcase KVM_MEMORY_ENCRYPT_UNREG_REGION: {\n\t\tstruct kvm_enc_region region;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(®ion, argp, sizeof(region)))\n\t\t\tgoto out;\n\n\t\tr = -ENOTTY;\n\t\tif (!kvm_x86_ops.mem_enc_unregister_region)\n\t\t\tgoto out;\n\n\t\tr = static_call(kvm_x86_mem_enc_unregister_region)(kvm, ®ion);\n\t\tbreak;\n\t}\n\tcase KVM_HYPERV_EVENTFD: {\n\t\tstruct kvm_hyperv_eventfd hvevfd;\n\n\t\tr = -EFAULT;\n\t\tif (copy_from_user(&hvevfd, argp, sizeof(hvevfd)))\n\t\t\tgoto out;\n\t\tr = kvm_vm_ioctl_hv_eventfd(kvm, &hvevfd);\n\t\tbreak;\n\t}\n\tcase KVM_SET_PMU_EVENT_FILTER:\n\t\tr = kvm_vm_ioctl_set_pmu_event_filter(kvm, argp);\n\t\tbreak;\n\tcase KVM_X86_SET_MSR_FILTER:\n\t\tr = kvm_vm_ioctl_set_msr_filter(kvm, argp);\n\t\tbreak;\n\tdefault:\n\t\tr = -ENOTTY;\n\t}\nout:\n\treturn r;\n}","target":0,"code_token_length":2550,"total_token_length":2786,"max_tokens_setting":4096}
+{"idx":430536,"func":"cupsdWriteClient(cupsd_client_t *con)\t\/* I - Client connection *\/\n{\n  int\t\tbytes,\t\t\t\/* Number of bytes written *\/\n\t\tfield_col;\t\t\/* Current column *\/\n  char\t\t*bufptr,\t\t\/* Pointer into buffer *\/\n\t\t*bufend;\t\t\/* Pointer to end of buffer *\/\n  ipp_state_t\tipp_state;\t\t\/* IPP state value *\/\n\n\n  cupsdLogClient(con, CUPSD_LOG_DEBUG, \"con->http=%p\", con->http);\n  cupsdLogClient(con, CUPSD_LOG_DEBUG,\n\t\t \"cupsdWriteClient \"\n\t\t \"error=%d, \"\n\t\t \"used=%d, \"\n\t\t \"state=%s, \"\n\t\t \"data_encoding=HTTP_ENCODING_%s, \"\n\t\t \"data_remaining=\" CUPS_LLFMT \", \"\n\t\t \"response=%p(%s), \"\n\t\t \"pipe_pid=%d, \"\n\t\t \"file=%d\",\n\t\t httpError(con->http), (int)httpGetReady(con->http),\n\t\t httpStateString(httpGetState(con->http)),\n\t\t httpIsChunked(con->http) ? \"CHUNKED\" : \"LENGTH\",\n\t\t CUPS_LLCAST httpGetLength2(con->http),\n\t\t con->response,\n\t\t con->response ? ippStateString(ippGetState(con->request)) : \"\",\n\t\t con->pipe_pid, con->file);\n\n  if (httpGetState(con->http) != HTTP_STATE_GET_SEND &&\n      httpGetState(con->http) != HTTP_STATE_POST_SEND)\n  {\n   \/*\n    * If we get called in the wrong state, then something went wrong with the\n    * connection and we need to shut it down...\n    *\/\n\n    cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Closing on unexpected HTTP write state %s.\",\n\t\t   httpStateString(httpGetState(con->http)));\n    cupsdCloseClient(con);\n    return;\n  }\n\n  if (con->pipe_pid)\n  {\n   \/*\n    * Make sure we select on the CGI output...\n    *\/\n\n    cupsdAddSelect(con->file, (cupsd_selfunc_t)write_pipe, NULL, con);\n\n    cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Waiting for CGI data.\");\n\n    if (!con->file_ready)\n    {\n     \/*\n      * Try again later when there is CGI output available...\n      *\/\n\n      cupsdRemoveSelect(httpGetFd(con->http));\n      return;\n    }\n\n    con->file_ready = 0;\n  }\n\n  bytes = (ssize_t)(sizeof(con->header) - (size_t)con->header_used);\n\n  if (!con->pipe_pid && bytes > (ssize_t)httpGetRemaining(con->http))\n  {\n   \/*\n    * Limit GET bytes to original size of file (STR #3265)...\n    *\/\n\n    bytes = (ssize_t)httpGetRemaining(con->http);\n  }\n\n  if (con->response && con->response->state != IPP_STATE_DATA)\n  {\n    size_t wused = httpGetPending(con->http);\t\/* Previous write buffer use *\/\n\n    do\n    {\n     \/*\n      * Write a single attribute or the IPP message header...\n      *\/\n\n      ipp_state = ippWrite(con->http, con->response);\n\n     \/*\n      * If the write buffer has been flushed, stop buffering up attributes...\n      *\/\n\n      if (httpGetPending(con->http) <= wused)\n        break;\n    }\n    while (ipp_state != IPP_STATE_DATA && ipp_state != IPP_STATE_ERROR);\n\n    cupsdLogClient(con, CUPSD_LOG_DEBUG,\n                   \"Writing IPP response, ipp_state=%s, old \"\n                   \"wused=\" CUPS_LLFMT \", new wused=\" CUPS_LLFMT,\n                   ippStateString(ipp_state),\n\t\t   CUPS_LLCAST wused, CUPS_LLCAST httpGetPending(con->http));\n\n    if (httpGetPending(con->http) > 0)\n      httpFlushWrite(con->http);\n\n    bytes = ipp_state != IPP_STATE_ERROR &&\n\t    (con->file >= 0 || ipp_state != IPP_STATE_DATA);\n\n    cupsdLogClient(con, CUPSD_LOG_DEBUG,\n                   \"bytes=%d, http_state=%d, data_remaining=\" CUPS_LLFMT,\n                   (int)bytes, httpGetState(con->http),\n                   CUPS_LLCAST httpGetLength2(con->http));\n  }\n  else if ((bytes = read(con->file, con->header + con->header_used, (size_t)bytes)) > 0)\n  {\n    con->header_used += bytes;\n\n    if (con->pipe_pid && !con->got_fields)\n    {\n     \/*\n      * Inspect the data for Content-Type and other fields.\n      *\/\n\n      for (bufptr = con->header, bufend = con->header + con->header_used,\n               field_col = 0;\n           !con->got_fields && bufptr < bufend;\n\t   bufptr ++)\n      {\n        if (*bufptr == '\\n')\n\t{\n\t \/*\n\t  * Send line to client...\n\t  *\/\n\n\t  if (bufptr > con->header && bufptr[-1] == '\\r')\n\t    bufptr[-1] = '\\0';\n\t  *bufptr++ = '\\0';\n\n          cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Script header: %s\", con->header);\n\n          if (!con->sent_header)\n\t  {\n\t   \/*\n\t    * Handle redirection and CGI status codes...\n\t    *\/\n\n\t    http_field_t field;\t\t\/* HTTP field *\/\n\t    char\t*value = strchr(con->header, ':');\n\t\t\t\t\t\/* Value of field *\/\n\n\t    if (value)\n\t    {\n\t      *value++ = '\\0';\n\t      while (isspace(*value & 255))\n\t\tvalue ++;\n\t    }\n\n\t    field = httpFieldValue(con->header);\n\n\t    if (field != HTTP_FIELD_UNKNOWN && value)\n\t    {\n\t      httpSetField(con->http, field, value);\n\n\t      if (field == HTTP_FIELD_LOCATION)\n\t      {\n\t\tcon->pipe_status = HTTP_STATUS_SEE_OTHER;\n\t\tcon->sent_header = 2;\n\t      }\n\t      else\n\t        con->sent_header = 1;\n\t    }\n\t    else if (!_cups_strcasecmp(con->header, \"Status\") && value)\n\t    {\n  \t      con->pipe_status = (http_status_t)atoi(value);\n\t      con->sent_header = 2;\n\t    }\n\t    else if (!_cups_strcasecmp(con->header, \"Set-Cookie\") && value)\n\t    {\n\t      httpSetCookie(con->http, value);\n\t      con->sent_header = 1;\n\t    }\n\t  }\n\n         \/*\n\t  * Update buffer...\n\t  *\/\n\n\t  con->header_used -= bufptr - con->header;\n\n\t  if (con->header_used > 0)\n\t    memmove(con->header, bufptr, (size_t)con->header_used);\n\n\t  bufptr = con->header - 1;\n\n         \/*\n\t  * See if the line was empty...\n\t  *\/\n\n\t  if (field_col == 0)\n\t  {\n\t    con->got_fields = 1;\n\n\t    if (httpGetVersion(con->http) == HTTP_VERSION_1_1 &&\n\t\t!httpGetField(con->http, HTTP_FIELD_CONTENT_LENGTH)[0])\n\t      httpSetLength(con->http, 0);\n\n            cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Sending status %d for CGI.\", con->pipe_status);\n\n            if (con->pipe_status == HTTP_STATUS_OK)\n\t    {\n\t      if (!cupsdSendHeader(con, con->pipe_status, NULL, CUPSD_AUTH_NONE))\n\t      {\n\t\tcupsdCloseClient(con);\n\t\treturn;\n\t      }\n\t    }\n\t    else\n\t    {\n\t      if (!cupsdSendError(con, con->pipe_status, CUPSD_AUTH_NONE))\n\t      {\n\t\tcupsdCloseClient(con);\n\t\treturn;\n\t      }\n\t    }\n          }\n\t  else\n\t    field_col = 0;\n\t}\n\telse if (*bufptr != '\\r')\n\t  field_col ++;\n      }\n\n      if (!con->got_fields)\n        return;\n    }\n\n    if (con->header_used > 0)\n    {\n      if (httpWrite2(con->http, con->header, (size_t)con->header_used) < 0)\n      {\n\tcupsdLogClient(con, CUPSD_LOG_DEBUG, \"Closing for error %d (%s)\",\n\t\t       httpError(con->http), strerror(httpError(con->http)));\n\tcupsdCloseClient(con);\n\treturn;\n      }\n\n      if (httpIsChunked(con->http))\n        httpFlushWrite(con->http);\n\n      con->bytes += con->header_used;\n\n      if (httpGetState(con->http) == HTTP_STATE_WAITING)\n\tbytes = 0;\n      else\n        bytes = con->header_used;\n\n      con->header_used = 0;\n    }\n  }\n\n  if (bytes <= 0 ||\n      (httpGetState(con->http) != HTTP_STATE_GET_SEND &&\n       httpGetState(con->http) != HTTP_STATE_POST_SEND))\n  {\n    if (!con->sent_header && con->pipe_pid)\n      cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE);\n    else\n    {\n      cupsdLogRequest(con, HTTP_STATUS_OK);\n\n      if (httpIsChunked(con->http) && (!con->pipe_pid || con->sent_header > 0))\n      {\n        cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Sending 0-length chunk.\");\n\n\tif (httpWrite2(con->http, \"\", 0) < 0)\n\t{\n\t  cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Closing for error %d (%s)\",\n\t\t\t httpError(con->http), strerror(httpError(con->http)));\n\t  cupsdCloseClient(con);\n\t  return;\n\t}\n      }\n\n      cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Flushing write buffer.\");\n      httpFlushWrite(con->http);\n      cupsdLogClient(con, CUPSD_LOG_DEBUG, \"New state is %s\", httpStateString(httpGetState(con->http)));\n    }\n\n    cupsdAddSelect(httpGetFd(con->http), (cupsd_selfunc_t)cupsdReadClient, NULL, con);\n\n    cupsdLogClient(con, CUPSD_LOG_DEBUG, \"Waiting for request.\");\n\n    if (con->file >= 0)\n    {\n      cupsdRemoveSelect(con->file);\n\n      if (con->pipe_pid)\n\tcupsdEndProcess(con->pipe_pid, 0);\n\n      close(con->file);\n      con->file     = -1;\n      con->pipe_pid = 0;\n    }\n\n    if (con->filename)\n    {\n      unlink(con->filename);\n      cupsdClearString(&con->filename);\n    }\n\n    if (con->request)\n    {\n      ippDelete(con->request);\n      con->request = NULL;\n    }\n\n    if (con->response)\n    {\n      ippDelete(con->response);\n      con->response = NULL;\n    }\n\n    cupsdClearString(&con->command);\n    cupsdClearString(&con->options);\n    cupsdClearString(&con->query_string);\n\n    if (!httpGetKeepAlive(con->http))\n    {\n      cupsdLogClient(con, CUPSD_LOG_DEBUG,\n\t\t     \"Closing because Keep-Alive is disabled.\");\n      cupsdCloseClient(con);\n      return;\n    }\n    else\n    {\n      cupsArrayRemove(ActiveClients, con);\n      cupsdSetBusyState(0);\n    }\n  }\n}","target":0,"code_token_length":2431,"total_token_length":2667,"max_tokens_setting":4096}
+{"idx":233550,"func":"static int aesni_cbc_hmac_sha256_cipher(EVP_CIPHER_CTX *ctx,\n                                        unsigned char *out,\n                                        const unsigned char *in, size_t len)\n{\n    EVP_AES_HMAC_SHA256 *key = data(ctx);\n    unsigned int l;\n    size_t plen = key->payload_length, iv = 0, \/* explicit IV in TLS 1.1 and\n                                                * later *\/\n        sha_off = 0;\n#  if defined(STITCHED_CALL)\n    size_t aes_off = 0, blocks;\n\n    sha_off = SHA256_CBLOCK - key->md.num;\n#  endif\n\n    key->payload_length = NO_PAYLOAD_LENGTH;\n\n    if (len % AES_BLOCK_SIZE)\n        return 0;\n\n    if (ctx->encrypt) {\n        if (plen == NO_PAYLOAD_LENGTH)\n            plen = len;\n        else if (len !=\n                 ((plen + SHA256_DIGEST_LENGTH +\n                   AES_BLOCK_SIZE) & -AES_BLOCK_SIZE))\n            return 0;\n        else if (key->aux.tls_ver >= TLS1_1_VERSION)\n            iv = AES_BLOCK_SIZE;\n\n#  if defined(STITCHED_CALL)\n        \/*\n         * Assembly stitch handles AVX-capable processors, but its\n         * performance is not optimal on AMD Jaguar, ~40% worse, for\n         * unknown reasons. Incidentally processor in question supports\n         * AVX, but not AMD-specific XOP extension, which can be used\n         * to identify it and avoid stitch invocation. So that after we\n         * establish that current CPU supports AVX, we even see if it's\n         * either even XOP-capable Bulldozer-based or GenuineIntel one.\n         *\/\n        if (OPENSSL_ia32cap_P[1] & (1 << (60 - 32)) && \/* AVX? *\/\n            ((OPENSSL_ia32cap_P[1] & (1 << (43 - 32))) \/* XOP? *\/\n             | (OPENSSL_ia32cap_P[0] & (1<<30))) &&    \/* \"Intel CPU\"? *\/\n            plen > (sha_off + iv) &&\n            (blocks = (plen - (sha_off + iv)) \/ SHA256_CBLOCK)) {\n            SHA256_Update(&key->md, in + iv, sha_off);\n\n            (void)aesni_cbc_sha256_enc(in, out, blocks, &key->ks,\n                                       ctx->iv, &key->md, in + iv + sha_off);\n            blocks *= SHA256_CBLOCK;\n            aes_off += blocks;\n            sha_off += blocks;\n            key->md.Nh += blocks >> 29;\n            key->md.Nl += blocks <<= 3;\n            if (key->md.Nl < (unsigned int)blocks)\n                key->md.Nh++;\n        } else {\n            sha_off = 0;\n        }\n#  endif\n        sha_off += iv;\n        SHA256_Update(&key->md, in + sha_off, plen - sha_off);\n\n        if (plen != len) {      \/* \"TLS\" mode of operation *\/\n            if (in != out)\n                memcpy(out + aes_off, in + aes_off, plen - aes_off);\n\n            \/* calculate HMAC and append it to payload *\/\n            SHA256_Final(out + plen, &key->md);\n            key->md = key->tail;\n            SHA256_Update(&key->md, out + plen, SHA256_DIGEST_LENGTH);\n            SHA256_Final(out + plen, &key->md);\n\n            \/* pad the payload|hmac *\/\n            plen += SHA256_DIGEST_LENGTH;\n            for (l = len - plen - 1; plen < len; plen++)\n                out[plen] = l;\n            \/* encrypt HMAC|padding at once *\/\n            aesni_cbc_encrypt(out + aes_off, out + aes_off, len - aes_off,\n                              &key->ks, ctx->iv, 1);\n        } else {\n            aesni_cbc_encrypt(in + aes_off, out + aes_off, len - aes_off,\n                              &key->ks, ctx->iv, 1);\n        }\n    } else {\n        union {\n            unsigned int u[SHA256_DIGEST_LENGTH \/ sizeof(unsigned int)];\n            unsigned char c[64 + SHA256_DIGEST_LENGTH];\n        } mac, *pmac;\n\n        \/* arrange cache line alignment *\/\n        pmac = (void *)(((size_t)mac.c + 63) & ((size_t)0 - 64));\n\n        \/* decrypt HMAC|padding at once *\/\n        aesni_cbc_encrypt(in, out, len, &key->ks, ctx->iv, 0);\n\n        if (plen != NO_PAYLOAD_LENGTH) { \/* \"TLS\" mode of operation *\/\n            size_t inp_len, mask, j, i;\n            unsigned int res, maxpad, pad, bitlen;\n            int ret = 1;\n            union {\n                unsigned int u[SHA_LBLOCK];\n                unsigned char c[SHA256_CBLOCK];\n            } *data = (void *)key->md.data;\n\n            if ((key->aux.tls_aad[plen - 4] << 8 | key->aux.tls_aad[plen - 3])\n                >= TLS1_1_VERSION)\n                iv = AES_BLOCK_SIZE;\n\n            if (len < (iv + SHA256_DIGEST_LENGTH + 1))\n                return 0;\n\n            \/* omit explicit iv *\/\n            out += iv;\n            len -= iv;\n\n            \/* figure out payload length *\/\n            pad = out[len - 1];\n            maxpad = len - (SHA256_DIGEST_LENGTH + 1);\n            maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8);\n             maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8);\n             maxpad &= 255;\n \n            ret &= constant_time_ge(maxpad, pad);\n\n             inp_len = len - (SHA256_DIGEST_LENGTH + pad + 1);\n             mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1)));\n             inp_len &= mask;\n            key->aux.tls_aad[plen - 1] = inp_len;\n\n            \/* calculate HMAC *\/\n            key->md = key->head;\n            SHA256_Update(&key->md, key->aux.tls_aad, plen);\n\n#  if 1\n            len -= SHA256_DIGEST_LENGTH; \/* amend mac *\/\n            if (len >= (256 + SHA256_CBLOCK)) {\n                j = (len - (256 + SHA256_CBLOCK)) & (0 - SHA256_CBLOCK);\n                j += SHA256_CBLOCK - key->md.num;\n                SHA256_Update(&key->md, out, j);\n                out += j;\n                len -= j;\n                inp_len -= j;\n            }\n\n            \/* but pretend as if we hashed padded payload *\/\n            bitlen = key->md.Nl + (inp_len << 3); \/* at most 18 bits *\/\n#   ifdef BSWAP4\n            bitlen = BSWAP4(bitlen);\n#   else\n            mac.c[0] = 0;\n            mac.c[1] = (unsigned char)(bitlen >> 16);\n            mac.c[2] = (unsigned char)(bitlen >> 8);\n            mac.c[3] = (unsigned char)bitlen;\n            bitlen = mac.u[0];\n#   endif\n\n            pmac->u[0] = 0;\n            pmac->u[1] = 0;\n            pmac->u[2] = 0;\n            pmac->u[3] = 0;\n            pmac->u[4] = 0;\n            pmac->u[5] = 0;\n            pmac->u[6] = 0;\n            pmac->u[7] = 0;\n\n            for (res = key->md.num, j = 0; j < len; j++) {\n                size_t c = out[j];\n                mask = (j - inp_len) >> (sizeof(j) * 8 - 8);\n                c &= mask;\n                c |= 0x80 & ~mask & ~((inp_len - j) >> (sizeof(j) * 8 - 8));\n                data->c[res++] = (unsigned char)c;\n\n                if (res != SHA256_CBLOCK)\n                    continue;\n\n                \/* j is not incremented yet *\/\n                mask = 0 - ((inp_len + 7 - j) >> (sizeof(j) * 8 - 1));\n                data->u[SHA_LBLOCK - 1] |= bitlen & mask;\n                sha256_block_data_order(&key->md, data, 1);\n                mask &= 0 - ((j - inp_len - 72) >> (sizeof(j) * 8 - 1));\n                pmac->u[0] |= key->md.h[0] & mask;\n                pmac->u[1] |= key->md.h[1] & mask;\n                pmac->u[2] |= key->md.h[2] & mask;\n                pmac->u[3] |= key->md.h[3] & mask;\n                pmac->u[4] |= key->md.h[4] & mask;\n                pmac->u[5] |= key->md.h[5] & mask;\n                pmac->u[6] |= key->md.h[6] & mask;\n                pmac->u[7] |= key->md.h[7] & mask;\n                res = 0;\n            }\n\n            for (i = res; i < SHA256_CBLOCK; i++, j++)\n                data->c[i] = 0;\n\n            if (res > SHA256_CBLOCK - 8) {\n                mask = 0 - ((inp_len + 8 - j) >> (sizeof(j) * 8 - 1));\n                data->u[SHA_LBLOCK - 1] |= bitlen & mask;\n                sha256_block_data_order(&key->md, data, 1);\n                mask &= 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1));\n                pmac->u[0] |= key->md.h[0] & mask;\n                pmac->u[1] |= key->md.h[1] & mask;\n                pmac->u[2] |= key->md.h[2] & mask;\n                pmac->u[3] |= key->md.h[3] & mask;\n                pmac->u[4] |= key->md.h[4] & mask;\n                pmac->u[5] |= key->md.h[5] & mask;\n                pmac->u[6] |= key->md.h[6] & mask;\n                pmac->u[7] |= key->md.h[7] & mask;\n\n                memset(data, 0, SHA256_CBLOCK);\n                j += 64;\n            }\n            data->u[SHA_LBLOCK - 1] = bitlen;\n            sha256_block_data_order(&key->md, data, 1);\n            mask = 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1));\n            pmac->u[0] |= key->md.h[0] & mask;\n            pmac->u[1] |= key->md.h[1] & mask;\n            pmac->u[2] |= key->md.h[2] & mask;\n            pmac->u[3] |= key->md.h[3] & mask;\n            pmac->u[4] |= key->md.h[4] & mask;\n            pmac->u[5] |= key->md.h[5] & mask;\n            pmac->u[6] |= key->md.h[6] & mask;\n            pmac->u[7] |= key->md.h[7] & mask;\n\n#   ifdef BSWAP4\n            pmac->u[0] = BSWAP4(pmac->u[0]);\n            pmac->u[1] = BSWAP4(pmac->u[1]);\n            pmac->u[2] = BSWAP4(pmac->u[2]);\n            pmac->u[3] = BSWAP4(pmac->u[3]);\n            pmac->u[4] = BSWAP4(pmac->u[4]);\n            pmac->u[5] = BSWAP4(pmac->u[5]);\n            pmac->u[6] = BSWAP4(pmac->u[6]);\n            pmac->u[7] = BSWAP4(pmac->u[7]);\n#   else\n            for (i = 0; i < 8; i++) {\n                res = pmac->u[i];\n                pmac->c[4 * i + 0] = (unsigned char)(res >> 24);\n                pmac->c[4 * i + 1] = (unsigned char)(res >> 16);\n                pmac->c[4 * i + 2] = (unsigned char)(res >> 8);\n                pmac->c[4 * i + 3] = (unsigned char)res;\n            }\n#   endif\n            len += SHA256_DIGEST_LENGTH;\n#  else\n            SHA256_Update(&key->md, out, inp_len);\n            res = key->md.num;\n            SHA256_Final(pmac->c, &key->md);\n\n            {\n                unsigned int inp_blocks, pad_blocks;\n\n                \/* but pretend as if we hashed padded payload *\/\n                inp_blocks =\n                    1 + ((SHA256_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1));\n                res += (unsigned int)(len - inp_len);\n                pad_blocks = res \/ SHA256_CBLOCK;\n                res %= SHA256_CBLOCK;\n                pad_blocks +=\n                    1 + ((SHA256_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1));\n                for (; inp_blocks < pad_blocks; inp_blocks++)\n                    sha1_block_data_order(&key->md, data, 1);\n            }\n#  endif\n            key->md = key->tail;\n            SHA256_Update(&key->md, pmac->c, SHA256_DIGEST_LENGTH);\n            SHA256_Final(pmac->c, &key->md);\n\n            \/* verify HMAC *\/\n            out += inp_len;\n            len -= inp_len;\n#  if 1\n            {\n                unsigned char *p =\n                    out + len - 1 - maxpad - SHA256_DIGEST_LENGTH;\n                size_t off = out - p;\n                unsigned int c, cmask;\n\n                maxpad += SHA256_DIGEST_LENGTH;\n                for (res = 0, i = 0, j = 0; j < maxpad; j++) {\n                    c = p[j];\n                    cmask =\n                        ((int)(j - off - SHA256_DIGEST_LENGTH)) >>\n                        (sizeof(int) * 8 - 1);\n                    res |= (c ^ pad) & ~cmask; \/* ... and padding *\/\n                    cmask &= ((int)(off - 1 - j)) >> (sizeof(int) * 8 - 1);\n                    res |= (c ^ pmac->c[i]) & cmask;\n                    i += 1 & cmask;\n                }\n                maxpad -= SHA256_DIGEST_LENGTH;\n\n                res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1));\n                ret &= (int)~res;\n            }\n#  else\n            for (res = 0, i = 0; i < SHA256_DIGEST_LENGTH; i++)\n                res |= out[i] ^ pmac->c[i];\n            res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1));\n            ret &= (int)~res;\n\n            \/* verify padding *\/\n            pad = (pad & ~res) | (maxpad & res);\n            out = out + len - 1 - pad;\n            for (res = 0, i = 0; i < pad; i++)\n                res |= out[i] ^ pad;\n\n            res = (0 - res) >> (sizeof(res) * 8 - 1);\n            ret &= (int)~res;\n#  endif\n            return ret;\n        } else {\n            SHA256_Update(&key->md, out, len);\n        }\n    }\n\n    return 1;\n}\n","target":0,"code_token_length":3657,"total_token_length":3893,"max_tokens_setting":4096}
+{"idx":71582,"func":"static int vcpu_enter_guest(struct kvm_vcpu *vcpu)\n{\n\tint r;\n\tbool req_int_win =\n\t\tdm_request_for_irq_injection(vcpu) &&\n\t\tkvm_cpu_accept_dm_intr(vcpu);\n\tfastpath_t exit_fastpath;\n\n\tbool req_immediate_exit = false;\n\n\t\/* Forbid vmenter if vcpu dirty ring is soft-full *\/\n\tif (unlikely(vcpu->kvm->dirty_ring_size &&\n\t\t     kvm_dirty_ring_soft_full(&vcpu->dirty_ring))) {\n\t\tvcpu->run->exit_reason = KVM_EXIT_DIRTY_RING_FULL;\n\t\ttrace_kvm_dirty_ring_exit(vcpu);\n\t\tr = 0;\n\t\tgoto out;\n\t}\n\n\tif (kvm_request_pending(vcpu)) {\n\t\tif (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) {\n\t\t\tr = -EIO;\n\t\t\tgoto out;\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu)) {\n\t\t\tif (unlikely(!kvm_x86_ops.nested_ops->get_nested_state_pages(vcpu))) {\n\t\t\t\tr = 0;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu))\n\t\t\tkvm_mmu_free_obsolete_roots(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu))\n\t\t\t__kvm_migrate_timers(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu))\n\t\t\tkvm_update_masterclock(vcpu->kvm);\n\t\tif (kvm_check_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu))\n\t\t\tkvm_gen_kvmclock_update(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_CLOCK_UPDATE, vcpu)) {\n\t\t\tr = kvm_guest_time_update(vcpu);\n\t\t\tif (unlikely(r))\n\t\t\t\tgoto out;\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu))\n\t\t\tkvm_mmu_sync_roots(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_LOAD_MMU_PGD, vcpu))\n\t\t\tkvm_mmu_load_pgd(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) {\n\t\t\tkvm_vcpu_flush_tlb_all(vcpu);\n\n\t\t\t\/* Flushing all ASIDs flushes the current ASID... *\/\n\t\t\tkvm_clear_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu);\n\t\t}\n\t\tkvm_service_local_tlb_flush_requests(vcpu);\n\n\t\tif (kvm_check_request(KVM_REQ_REPORT_TPR_ACCESS, vcpu)) {\n\t\t\tvcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS;\n\t\t\tr = 0;\n\t\t\tgoto out;\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {\n\t\t\tif (is_guest_mode(vcpu)) {\n\t\t\t\tkvm_x86_ops.nested_ops->triple_fault(vcpu);\n\t\t\t} else {\n\t\t\t\tvcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;\n\t\t\t\tvcpu->mmio_needed = 0;\n\t\t\t\tr = 0;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_APF_HALT, vcpu)) {\n\t\t\t\/* Page is swapped out. Do synthetic halt *\/\n\t\t\tvcpu->arch.apf.halted = true;\n\t\t\tr = 1;\n\t\t\tgoto out;\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_STEAL_UPDATE, vcpu))\n\t\t\trecord_steal_time(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_SMI, vcpu))\n\t\t\tprocess_smi(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_NMI, vcpu))\n\t\t\tprocess_nmi(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_PMU, vcpu))\n\t\t\tkvm_pmu_handle_event(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_PMI, vcpu))\n\t\t\tkvm_pmu_deliver_pmi(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_IOAPIC_EOI_EXIT, vcpu)) {\n\t\t\tBUG_ON(vcpu->arch.pending_ioapic_eoi > 255);\n\t\t\tif (test_bit(vcpu->arch.pending_ioapic_eoi,\n\t\t\t\t     vcpu->arch.ioapic_handled_vectors)) {\n\t\t\t\tvcpu->run->exit_reason = KVM_EXIT_IOAPIC_EOI;\n\t\t\t\tvcpu->run->eoi.vector =\n\t\t\t\t\t\tvcpu->arch.pending_ioapic_eoi;\n\t\t\t\tr = 0;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_SCAN_IOAPIC, vcpu))\n\t\t\tvcpu_scan_ioapic(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_LOAD_EOI_EXITMAP, vcpu))\n\t\t\tvcpu_load_eoi_exitmap(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))\n\t\t\tkvm_vcpu_reload_apic_access_page(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) {\n\t\t\tvcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;\n\t\t\tvcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH;\n\t\t\tvcpu->run->system_event.ndata = 0;\n\t\t\tr = 0;\n\t\t\tgoto out;\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_HV_RESET, vcpu)) {\n\t\t\tvcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;\n\t\t\tvcpu->run->system_event.type = KVM_SYSTEM_EVENT_RESET;\n\t\t\tvcpu->run->system_event.ndata = 0;\n\t\t\tr = 0;\n\t\t\tgoto out;\n\t\t}\n\t\tif (kvm_check_request(KVM_REQ_HV_EXIT, vcpu)) {\n\t\t\tstruct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);\n\n\t\t\tvcpu->run->exit_reason = KVM_EXIT_HYPERV;\n\t\t\tvcpu->run->hyperv = hv_vcpu->exit;\n\t\t\tr = 0;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/*\n\t\t * KVM_REQ_HV_STIMER has to be processed after\n\t\t * KVM_REQ_CLOCK_UPDATE, because Hyper-V SynIC timers\n\t\t * depend on the guest clock being up-to-date\n\t\t *\/\n\t\tif (kvm_check_request(KVM_REQ_HV_STIMER, vcpu))\n\t\t\tkvm_hv_process_stimers(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_APICV_UPDATE, vcpu))\n\t\t\tkvm_vcpu_update_apicv(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_APF_READY, vcpu))\n\t\t\tkvm_check_async_pf_completion(vcpu);\n\t\tif (kvm_check_request(KVM_REQ_MSR_FILTER_CHANGED, vcpu))\n\t\t\tstatic_call(kvm_x86_msr_filter_changed)(vcpu);\n\n\t\tif (kvm_check_request(KVM_REQ_UPDATE_CPU_DIRTY_LOGGING, vcpu))\n\t\t\tstatic_call(kvm_x86_update_cpu_dirty_logging)(vcpu);\n\t}\n\n\tif (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win ||\n\t    kvm_xen_has_interrupt(vcpu)) {\n\t\t++vcpu->stat.req_event;\n\t\tr = kvm_apic_accept_events(vcpu);\n\t\tif (r < 0) {\n\t\t\tr = 0;\n\t\t\tgoto out;\n\t\t}\n\t\tif (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {\n\t\t\tr = 1;\n\t\t\tgoto out;\n\t\t}\n\n\t\tr = inject_pending_event(vcpu, &req_immediate_exit);\n\t\tif (r < 0) {\n\t\t\tr = 0;\n\t\t\tgoto out;\n\t\t}\n\t\tif (req_int_win)\n\t\t\tstatic_call(kvm_x86_enable_irq_window)(vcpu);\n\n\t\tif (kvm_lapic_enabled(vcpu)) {\n\t\t\tupdate_cr8_intercept(vcpu);\n\t\t\tkvm_lapic_sync_to_vapic(vcpu);\n\t\t}\n\t}\n\n\tr = kvm_mmu_reload(vcpu);\n\tif (unlikely(r)) {\n\t\tgoto cancel_injection;\n\t}\n\n\tpreempt_disable();\n\n\tstatic_call(kvm_x86_prepare_switch_to_guest)(vcpu);\n\n\t\/*\n\t * Disable IRQs before setting IN_GUEST_MODE.  Posted interrupt\n\t * IPI are then delayed after guest entry, which ensures that they\n\t * result in virtual interrupt delivery.\n\t *\/\n\tlocal_irq_disable();\n\n\t\/* Store vcpu->apicv_active before vcpu->mode.  *\/\n\tsmp_store_release(&vcpu->mode, IN_GUEST_MODE);\n\n\tkvm_vcpu_srcu_read_unlock(vcpu);\n\n\t\/*\n\t * 1) We should set ->mode before checking ->requests.  Please see\n\t * the comment in kvm_vcpu_exiting_guest_mode().\n\t *\n\t * 2) For APICv, we should set ->mode before checking PID.ON. This\n\t * pairs with the memory barrier implicit in pi_test_and_set_on\n\t * (see vmx_deliver_posted_interrupt).\n\t *\n\t * 3) This also orders the write to mode from any reads to the page\n\t * tables done while the VCPU is running.  Please see the comment\n\t * in kvm_flush_remote_tlbs.\n\t *\/\n\tsmp_mb__after_srcu_read_unlock();\n\n\t\/*\n\t * Process pending posted interrupts to handle the case where the\n\t * notification IRQ arrived in the host, or was never sent (because the\n\t * target vCPU wasn't running).  Do this regardless of the vCPU's APICv\n\t * status, KVM doesn't update assigned devices when APICv is inhibited,\n\t * i.e. they can post interrupts even if APICv is temporarily disabled.\n\t *\/\n\tif (kvm_lapic_enabled(vcpu))\n\t\tstatic_call_cond(kvm_x86_sync_pir_to_irr)(vcpu);\n\n\tif (kvm_vcpu_exit_request(vcpu)) {\n\t\tvcpu->mode = OUTSIDE_GUEST_MODE;\n\t\tsmp_wmb();\n\t\tlocal_irq_enable();\n\t\tpreempt_enable();\n\t\tkvm_vcpu_srcu_read_lock(vcpu);\n\t\tr = 1;\n\t\tgoto cancel_injection;\n\t}\n\n\tif (req_immediate_exit) {\n\t\tkvm_make_request(KVM_REQ_EVENT, vcpu);\n\t\tstatic_call(kvm_x86_request_immediate_exit)(vcpu);\n\t}\n\n\tfpregs_assert_state_consistent();\n\tif (test_thread_flag(TIF_NEED_FPU_LOAD))\n\t\tswitch_fpu_return();\n\n\tif (vcpu->arch.guest_fpu.xfd_err)\n\t\twrmsrl(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err);\n\n\tif (unlikely(vcpu->arch.switch_db_regs)) {\n\t\tset_debugreg(0, 7);\n\t\tset_debugreg(vcpu->arch.eff_db[0], 0);\n\t\tset_debugreg(vcpu->arch.eff_db[1], 1);\n\t\tset_debugreg(vcpu->arch.eff_db[2], 2);\n\t\tset_debugreg(vcpu->arch.eff_db[3], 3);\n\t} else if (unlikely(hw_breakpoint_active())) {\n\t\tset_debugreg(0, 7);\n\t}\n\n\tguest_timing_enter_irqoff();\n\n\tfor (;;) {\n\t\t\/*\n\t\t * Assert that vCPU vs. VM APICv state is consistent.  An APICv\n\t\t * update must kick and wait for all vCPUs before toggling the\n\t\t * per-VM state, and responsing vCPUs must wait for the update\n\t\t * to complete before servicing KVM_REQ_APICV_UPDATE.\n\t\t *\/\n\t\tWARN_ON_ONCE(kvm_vcpu_apicv_activated(vcpu) != kvm_vcpu_apicv_active(vcpu));\n\n\t\texit_fastpath = static_call(kvm_x86_vcpu_run)(vcpu);\n\t\tif (likely(exit_fastpath != EXIT_FASTPATH_REENTER_GUEST))\n\t\t\tbreak;\n\n\t\tif (kvm_lapic_enabled(vcpu))\n\t\t\tstatic_call_cond(kvm_x86_sync_pir_to_irr)(vcpu);\n\n\t\tif (unlikely(kvm_vcpu_exit_request(vcpu))) {\n\t\t\texit_fastpath = EXIT_FASTPATH_EXIT_HANDLED;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/*\n\t * Do this here before restoring debug registers on the host.  And\n\t * since we do this before handling the vmexit, a DR access vmexit\n\t * can (a) read the correct value of the debug registers, (b) set\n\t * KVM_DEBUGREG_WONT_EXIT again.\n\t *\/\n\tif (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {\n\t\tWARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);\n\t\tstatic_call(kvm_x86_sync_dirty_debug_regs)(vcpu);\n\t\tkvm_update_dr0123(vcpu);\n\t\tkvm_update_dr7(vcpu);\n\t}\n\n\t\/*\n\t * If the guest has used debug registers, at least dr7\n\t * will be disabled while returning to the host.\n\t * If we don't have active breakpoints in the host, we don't\n\t * care about the messed up debug address registers. But if\n\t * we have some of them active, restore the old state.\n\t *\/\n\tif (hw_breakpoint_active())\n\t\thw_breakpoint_restore();\n\n\tvcpu->arch.last_vmentry_cpu = vcpu->cpu;\n\tvcpu->arch.last_guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc());\n\n\tvcpu->mode = OUTSIDE_GUEST_MODE;\n\tsmp_wmb();\n\n\t\/*\n\t * Sync xfd before calling handle_exit_irqoff() which may\n\t * rely on the fact that guest_fpu::xfd is up-to-date (e.g.\n\t * in #NM irqoff handler).\n\t *\/\n\tif (vcpu->arch.xfd_no_write_intercept)\n\t\tfpu_sync_guest_vmexit_xfd_state();\n\n\tstatic_call(kvm_x86_handle_exit_irqoff)(vcpu);\n\n\tif (vcpu->arch.guest_fpu.xfd_err)\n\t\twrmsrl(MSR_IA32_XFD_ERR, 0);\n\n\t\/*\n\t * Consume any pending interrupts, including the possible source of\n\t * VM-Exit on SVM and any ticks that occur between VM-Exit and now.\n\t * An instruction is required after local_irq_enable() to fully unblock\n\t * interrupts on processors that implement an interrupt shadow, the\n\t * stat.exits increment will do nicely.\n\t *\/\n\tkvm_before_interrupt(vcpu, KVM_HANDLING_IRQ);\n\tlocal_irq_enable();\n\t++vcpu->stat.exits;\n\tlocal_irq_disable();\n\tkvm_after_interrupt(vcpu);\n\n\t\/*\n\t * Wait until after servicing IRQs to account guest time so that any\n\t * ticks that occurred while running the guest are properly accounted\n\t * to the guest.  Waiting until IRQs are enabled degrades the accuracy\n\t * of accounting via context tracking, but the loss of accuracy is\n\t * acceptable for all known use cases.\n\t *\/\n\tguest_timing_exit_irqoff();\n\n\tlocal_irq_enable();\n\tpreempt_enable();\n\n\tkvm_vcpu_srcu_read_lock(vcpu);\n\n\t\/*\n\t * Profile KVM exit RIPs:\n\t *\/\n\tif (unlikely(prof_on == KVM_PROFILING)) {\n\t\tunsigned long rip = kvm_rip_read(vcpu);\n\t\tprofile_hit(KVM_PROFILING, (void *)rip);\n\t}\n\n\tif (unlikely(vcpu->arch.tsc_always_catchup))\n\t\tkvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);\n\n\tif (vcpu->arch.apic_attention)\n\t\tkvm_lapic_sync_from_vapic(vcpu);\n\n\tr = static_call(kvm_x86_handle_exit)(vcpu, exit_fastpath);\n\treturn r;\n\ncancel_injection:\n\tif (req_immediate_exit)\n\t\tkvm_make_request(KVM_REQ_EVENT, vcpu);\n\tstatic_call(kvm_x86_cancel_injection)(vcpu);\n\tif (unlikely(vcpu->arch.apic_attention))\n\t\tkvm_lapic_sync_from_vapic(vcpu);\nout:\n\treturn r;\n}","target":0,"code_token_length":3446,"total_token_length":3682,"max_tokens_setting":4096}
+{"idx":284325,"func":"int ssl3_get_server_hello(SSL *s)\n\t{\n\tSTACK_OF(SSL_CIPHER) *sk;\n\tconst SSL_CIPHER *c;\n\tCERT *ct = s->cert;\n\tunsigned char *p,*d;\n\tint i,al=SSL_AD_INTERNAL_ERROR,ok;\n\tunsigned int j;\n\tlong n;\n#ifndef OPENSSL_NO_COMP\n\tSSL_COMP *comp;\n#endif\n\t\/* Hello verify request and\/or server hello version may not\n\t * match so set first packet if we're negotiating version.\n\t *\/\n\tif (SSL_IS_DTLS(s))\n\t\ts->first_packet = 1;\n\n\tn=s->method->ssl_get_message(s,\n\t\tSSL3_ST_CR_SRVR_HELLO_A,\n\t\tSSL3_ST_CR_SRVR_HELLO_B,\n\t\t-1,\n\t\t20000, \/* ?? *\/\n\t\t&ok);\n\n\tif (!ok) return((int)n);\n\n\tif (SSL_IS_DTLS(s))\n\t\t{\n\t\ts->first_packet = 0;\n\t\tif ( s->s3->tmp.message_type == DTLS1_MT_HELLO_VERIFY_REQUEST)\n\t\t\t{\n\t\t\tif ( s->d1->send_cookie == 0)\n\t\t\t\t{\n\t\t\t\ts->s3->tmp.reuse_message = 1;\n\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\telse \/* already sent a cookie *\/\n\t\t\t\t{\n\t\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_MESSAGE_TYPE);\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tif ( s->s3->tmp.message_type != SSL3_MT_SERVER_HELLO)\n\t\t{\n\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_MESSAGE_TYPE);\n\t\tgoto f_err;\n\t\t}\n\n\td=p=(unsigned char *)s->init_msg;\n\tif (s->method->version == DTLS_ANY_VERSION)\n\t\t{\n\t\t\/* Work out correct protocol version to use *\/\n\t\tint hversion = (p[0] << 8)|p[1];\n\t\tint options = s->options;\n\t\tif (hversion == DTLS1_2_VERSION\n\t\t\t&& !(options & SSL_OP_NO_DTLSv1_2))\n\t\t\ts->method = DTLSv1_2_client_method();\n\t\telse if (tls1_suiteb(s))\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);\n\t\t\ts->version = hversion;\n\t\t\tal = SSL_AD_PROTOCOL_VERSION;\n\t\t\tgoto f_err;\n\t\t\t}\n\t\telse if (hversion == DTLS1_VERSION\n\t\t\t&& !(options & SSL_OP_NO_DTLSv1))\n\t\t\ts->method = DTLSv1_client_method();\n\t\telse\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION);\n\t\t\ts->version = hversion;\n\t\t\tal = SSL_AD_PROTOCOL_VERSION;\n\t\t\tgoto f_err;\n\t\t\t}\n\t\ts->version = s->method->version;\n\t\t}\n\n\tif ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff)))\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION);\n\t\ts->version=(s->version&0xff00)|p[1];\n\t\tal=SSL_AD_PROTOCOL_VERSION;\n\t\tgoto f_err;\n\t\t}\n\tp+=2;\n\n\t\/* load the server hello data *\/\n\t\/* load the server random *\/\n\tmemcpy(s->s3->server_random,p,SSL3_RANDOM_SIZE);\n\tp+=SSL3_RANDOM_SIZE;\n\n\ts->hit = 0;\n\n\t\/* get the session-id *\/\n\tj= *(p++);\n\n\tif ((j > sizeof s->session->session_id) || (j > SSL3_SESSION_ID_SIZE))\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_LONG);\n\t\tgoto f_err;\n\t\t}\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\/* check if we want to resume the session based on external pre-shared secret *\/\n\tif (s->version >= TLS1_VERSION && s->tls_session_secret_cb)\n\t\t{\n\t\tSSL_CIPHER *pref_cipher=NULL;\n\t\ts->session->master_key_length=sizeof(s->session->master_key);\n\t\tif (s->tls_session_secret_cb(s, s->session->master_key,\n\t\t\t\t\t     &s->session->master_key_length,\n\t\t\t\t\t     NULL, &pref_cipher,\n\t\t\t\t\t     s->tls_session_secret_cb_arg))\n\t\t\t{\n\t\t\ts->session->cipher = pref_cipher ?\n\t\t\t\tpref_cipher : ssl_get_cipher_by_char(s, p+j);\n\t\t\ts->hit = 1;\n\t\t\t}\n\t\t}\n#endif \/* OPENSSL_NO_TLSEXT *\/\n\n\tif (!s->hit && j != 0 && j == s->session->session_id_length\n\t    && memcmp(p,s->session->session_id,j) == 0)\n\t    {\n\t    if(s->sid_ctx_length != s->session->sid_ctx_length\n\t       || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length))\n\t\t{\n\t\t\/* actually a client application bug *\/\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);\n\t\tgoto f_err;\n\t\t}\n\t    s->hit=1;\n\t    }\n\t\/* a miss or crap from the other end *\/\n\tif (!s->hit)\n\t\t{\n\t\t\/* If we were trying for session-id reuse, make a new\n\t\t * SSL_SESSION so we don't stuff up other people *\/\n\t\tif (s->session->session_id_length > 0)\n\t\t\t{\n\t\t\tif (!ssl_get_new_session(s,0))\n\t\t\t\t{\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\t}\n\t\ts->session->session_id_length=j;\n\t\tmemcpy(s->session->session_id,p,j); \/* j could be 0 *\/\n\t\t}\n\tp+=j;\n\tc=ssl_get_cipher_by_char(s,p);\n\tif (c == NULL)\n\t\t{\n\t\t\/* unknown cipher *\/\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNKNOWN_CIPHER_RETURNED);\n\t\tgoto f_err;\n\t\t}\n\t\/* Set version disabled mask now we know version *\/\n\tif (!SSL_USE_TLS1_2_CIPHERS(s))\n\t\tct->mask_ssl = SSL_TLSV1_2;\n\telse\n\t\tct->mask_ssl = 0;\n\t\/* If it is a disabled cipher we didn't send it in client hello,\n\t * so return an error.\n\t *\/\n\tif (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK))\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED);\n\t\tgoto f_err;\n\t\t}\n\tp+=ssl_put_cipher_by_char(s,NULL,NULL);\n\n\tsk=ssl_get_ciphers_by_id(s);\n\ti=sk_SSL_CIPHER_find(sk,c);\n\tif (i < 0)\n\t\t{\n\t\t\/* we did not say we would use this cipher *\/\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_CIPHER_RETURNED);\n\t\tgoto f_err;\n\t\t}\n\n\t\/* Depending on the session caching (internal\/external), the cipher\n\t   and\/or cipher_id values may not be set. Make sure that\n\t   cipher_id is set and use it for comparison. *\/\n\tif (s->session->cipher)\n\t\ts->session->cipher_id = s->session->cipher->id;\n\tif (s->hit && (s->session->cipher_id != c->id))\n\t\t{\n\/* Workaround is now obsolete *\/\n#if 0\n\t\tif (!(s->options &\n\t\t\tSSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG))\n#endif\n\t\t\t{\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\ts->s3->tmp.new_cipher=c;\n\t\/* Don't digest cached records if no sigalgs: we may need them for\n\t * client authentication.\n\t *\/\n\tif (!SSL_USE_SIGALGS(s) && !ssl3_digest_cached_records(s))\n\t\tgoto f_err;\n\t\/* lets get the compression algorithm *\/\n\t\/* COMPRESSION *\/\n#ifdef OPENSSL_NO_COMP\n\tif (*(p++) != 0)\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);\n\t\tgoto f_err;\n\t\t}\n\t\/* If compression is disabled we'd better not try to resume a session\n\t * using compression.\n\t *\/\n\tif (s->session->compress_meth != 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_INCONSISTENT_COMPRESSION);\n\t\tgoto f_err;\n\t\t}\n#else\n\tj= *(p++);\n\tif (s->hit && j != s->session->compress_meth)\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED);\n\t\tgoto f_err;\n\t\t}\n\tif (j == 0)\n\t\tcomp=NULL;\n\telse if (!ssl_allow_compression(s))\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_COMPRESSION_DISABLED);\n\t\tgoto f_err;\n\t\t}\n\telse\n\t\tcomp=ssl3_comp_find(s->ctx->comp_methods,j);\n\t\n\tif ((j != 0) && (comp == NULL))\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);\n\t\tgoto f_err;\n\t\t}\n\telse\n\t\t{\n\t\ts->s3->tmp.new_compression=comp;\n\t\t}\n#endif\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\/* TLS extensions*\/\n\tif (!ssl_parse_serverhello_tlsext(s,&p,d,n))\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_PARSE_TLSEXT);\n\t\tgoto err; \n\t\t}\n#endif\n\n\tif (p != (d+n))\n\t\t{\n\t\t\/* wrong packet length *\/\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_PACKET_LENGTH);\n\t\tgoto f_err;\n\t\t}\n\n\treturn(1);\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\nerr:\n\treturn(-1);\n\t}\n","target":0,"code_token_length":2327,"total_token_length":2563,"max_tokens_setting":4096}
+{"idx":411699,"func":"\n    CImg& _load_pandore(std::FILE *const file, const char *const filename) {\n#define __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,ndim,stype) \\\n        cimg::fread(dims,nbdim,nfile); \\\n        if (endian) cimg::invert_endianness(dims,nbdim); \\\n        assign(nwidth,nheight,ndepth,ndim); \\\n        const size_t siz = size(); \\\n        stype *buffer = new stype[siz]; \\\n        cimg::fread(buffer,siz,nfile); \\\n        if (endian) cimg::invert_endianness(buffer,siz); \\\n        T *ptrd = _data; \\\n        cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \\\n        buffer-=siz; \\\n        delete[] buffer\n\n#define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \\\n        if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \\\n        else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \\\n        else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \\\n        else throw CImgIOException(_cimg_instance \\\n                                   \"load_pandore(): Unknown pixel datatype in file '%s'.\", \\\n                                   cimg_instance, \\\n                                   filename?filename:\"(FILE*)\"); }\n      if (!file && !filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"load_pandore(): Specified filename is (null).\",\n                                    cimg_instance);\n\n      std::FILE *const nfile = file?file:cimg::fopen(filename,\"rb\");\n      CImg header(32);\n      cimg::fread(header._data,12,nfile);\n      if (cimg::strncasecmp(\"PANDORE\",header,7)) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_pandore(): PANDORE header not found in file '%s'.\",\n                              cimg_instance,\n                              filename?filename:\"(FILE*)\");\n      }\n      unsigned int imageid, dims[8] = { 0 };\n      int ptbuf[4] = { 0 };\n      cimg::fread(&imageid,1,nfile);\n      const bool endian = imageid>255;\n      if (endian) cimg::invert_endianness(imageid);\n      cimg::fread(header._data,20,nfile);\n\n      switch (imageid) {\n      case 2 : _cimg_load_pandore_case(2,dims[1],1,1,1,unsigned char,unsigned char,unsigned char,1); break;\n      case 3 : _cimg_load_pandore_case(2,dims[1],1,1,1,long,int,short,4); break;\n      case 4 : _cimg_load_pandore_case(2,dims[1],1,1,1,double,float,float,4); break;\n      case 5 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,unsigned char,unsigned char,unsigned char,1); break;\n      case 6 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,long,int,short,4); break;\n      case 7 : _cimg_load_pandore_case(3,dims[2],dims[1],1,1,double,float,float,4); break;\n      case 8 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,unsigned char,unsigned char,unsigned char,1); break;\n      case 9 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,long,int,short,4); break;\n      case 10 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,double,float,float,4); break;\n      case 11 : { \/\/ Region 1d\n        cimg::fread(dims,3,nfile);\n        if (endian) cimg::invert_endianness(dims,3);\n        assign(dims[1],1,1,1);\n        const unsigned siz = size();\n        if (dims[2]<256) {\n          unsigned char *buffer = new unsigned char[siz];\n          cimg::fread(buffer,siz,nfile);\n          T *ptrd = _data;\n          cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n          buffer-=siz;\n          delete[] buffer;\n        } else {\n          if (dims[2]<65536) {\n            unsigned short *buffer = new unsigned short[siz];\n            cimg::fread(buffer,siz,nfile);\n            if (endian) cimg::invert_endianness(buffer,siz);\n            T *ptrd = _data;\n            cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n            buffer-=siz;\n            delete[] buffer;\n          } else {\n            unsigned int *buffer = new unsigned int[siz];\n            cimg::fread(buffer,siz,nfile);\n            if (endian) cimg::invert_endianness(buffer,siz);\n            T *ptrd = _data;\n            cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n            buffer-=siz;\n            delete[] buffer;\n          }\n        }\n      }\n        break;\n      case 12 : { \/\/ Region 2d\n        cimg::fread(dims,4,nfile);\n        if (endian) cimg::invert_endianness(dims,4);\n        assign(dims[2],dims[1],1,1);\n        const size_t siz = size();\n        if (dims[3]<256) {\n          unsigned char *buffer = new unsigned char[siz];\n          cimg::fread(buffer,siz,nfile);\n          T *ptrd = _data;\n          cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n          buffer-=siz;\n          delete[] buffer;\n        } else {\n          if (dims[3]<65536) {\n            unsigned short *buffer = new unsigned short[siz];\n            cimg::fread(buffer,siz,nfile);\n            if (endian) cimg::invert_endianness(buffer,siz);\n            T *ptrd = _data;\n            cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n            buffer-=siz;\n            delete[] buffer;\n          } else {\n            unsigned int *buffer = new unsigned int[siz];\n            cimg::fread(buffer,siz,nfile);\n            if (endian) cimg::invert_endianness(buffer,siz);\n            T *ptrd = _data;\n            cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n            buffer-=siz;\n            delete[] buffer;\n          }\n        }\n      }\n        break;\n      case 13 : { \/\/ Region 3d\n        cimg::fread(dims,5,nfile);\n        if (endian) cimg::invert_endianness(dims,5);\n        assign(dims[3],dims[2],dims[1],1);\n        const size_t siz = size();\n        if (dims[4]<256) {\n          unsigned char *buffer = new unsigned char[siz];\n          cimg::fread(buffer,siz,nfile);\n          T *ptrd = _data;\n          cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n          buffer-=siz;\n          delete[] buffer;\n        } else {\n          if (dims[4]<65536) {\n            unsigned short *buffer = new unsigned short[siz];\n            cimg::fread(buffer,siz,nfile);\n            if (endian) cimg::invert_endianness(buffer,siz);\n            T *ptrd = _data;\n            cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n            buffer-=siz;\n            delete[] buffer;\n          } else {\n            unsigned int *buffer = new unsigned int[siz];\n            cimg::fread(buffer,siz,nfile);\n            if (endian) cimg::invert_endianness(buffer,siz);\n            T *ptrd = _data;\n            cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);\n            buffer-=siz;\n            delete[] buffer;\n          }\n        }\n      }\n        break;\n      case 16 : _cimg_load_pandore_case(4,dims[2],dims[1],1,3,unsigned char,unsigned char,unsigned char,1); break;\n      case 17 : _cimg_load_pandore_case(4,dims[2],dims[1],1,3,long,int,short,4); break;\n      case 18 : _cimg_load_pandore_case(4,dims[2],dims[1],1,3,double,float,float,4); break;\n      case 19 : _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,unsigned char,unsigned char,unsigned char,1); break;\n      case 20 : _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,long,int,short,4); break;\n      case 21 : _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,double,float,float,4); break;\n      case 22 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],unsigned char,unsigned char,unsigned char,1); break;\n      case 23 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],long,int,short,4); break;\n      case 24 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],unsigned long,unsigned int,unsigned short,4); break;\n      case 25 : _cimg_load_pandore_case(2,dims[1],1,1,dims[0],double,float,float,4); break;\n      case 26 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],unsigned char,unsigned char,unsigned char,1); break;\n      case 27 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],long,int,short,4); break;\n      case 28 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],unsigned long,unsigned int,unsigned short,4); break;\n      case 29 : _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],double,float,float,4); break;\n      case 30 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],unsigned char,unsigned char,unsigned char,1);\n        break;\n      case 31 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],long,int,short,4); break;\n      case 32 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],unsigned long,unsigned int,unsigned short,4);\n        break;\n      case 33 : _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],double,float,float,4); break;\n      case 34 : { \/\/ Points 1d\n        cimg::fread(ptbuf,1,nfile);\n        if (endian) cimg::invert_endianness(ptbuf,1);\n        assign(1); (*this)(0) = (T)ptbuf[0];\n      } break;\n      case 35 : { \/\/ Points 2d\n        cimg::fread(ptbuf,2,nfile);\n        if (endian) cimg::invert_endianness(ptbuf,2);\n        assign(2); (*this)(0) = (T)ptbuf[1]; (*this)(1) = (T)ptbuf[0];\n      } break;\n      case 36 : { \/\/ Points 3d\n        cimg::fread(ptbuf,3,nfile);\n        if (endian) cimg::invert_endianness(ptbuf,3);\n        assign(3); (*this)(0) = (T)ptbuf[2]; (*this)(1) = (T)ptbuf[1]; (*this)(2) = (T)ptbuf[0];\n      } break;\n      default :\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_pandore(): Unable to load data with ID_type %u in file '%s'.\",\n                              cimg_instance,\n                              imageid,filename?filename:\"(FILE*)\");\n      }\n      if (!file) cimg::fclose(nfile);\n      return *this;","target":0,"code_token_length":3028,"total_token_length":3264,"max_tokens_setting":4096}
+{"idx":1245,"func":"static int vc1_decode_p_mb ( VC1Context * v ) {\n MpegEncContext * s = & v -> s ;\n GetBitContext * gb = & s -> gb ;\n int i , j ;\n int mb_pos = s -> mb_x + s -> mb_y * s -> mb_stride ;\n int cbp ;\n int mqdiff , mquant ;\n int ttmb = v -> ttfrm ;\n int mb_has_coeffs = 1 ;\n int dmv_x , dmv_y ;\n int index , index1 ;\n int val , sign ;\n int first_block = 1 ;\n int dst_idx , off ;\n int skipped , fourmv ;\n int block_cbp = 0 , pat , block_tt = 0 , block_intra = 0 ;\n mquant = v -> pq ;\n if ( v -> mv_type_is_raw ) fourmv = get_bits1 ( gb ) ;\n else fourmv = v -> mv_type_mb_plane [ mb_pos ] ;\n if ( v -> skip_is_raw ) skipped = get_bits1 ( gb ) ;\n else skipped = v -> s . mbskip_table [ mb_pos ] ;\n if ( ! fourmv ) {\n if ( ! skipped ) {\n GET_MVDATA ( dmv_x , dmv_y ) ;\n if ( s -> mb_intra ) {\n s -> current_picture . f . motion_val [ 1 ] [ s -> block_index [ 0 ] ] [ 0 ] = 0 ;\n s -> current_picture . f . motion_val [ 1 ] [ s -> block_index [ 0 ] ] [ 1 ] = 0 ;\n }\n s -> current_picture . f . mb_type [ mb_pos ] = s -> mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16 ;\n vc1_pred_mv ( v , 0 , dmv_x , dmv_y , 1 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;\n if ( s -> mb_intra && ! mb_has_coeffs ) {\n GET_MQUANT ( ) ;\n s -> ac_pred = get_bits1 ( gb ) ;\n cbp = 0 ;\n }\n else if ( mb_has_coeffs ) {\n if ( s -> mb_intra ) s -> ac_pred = get_bits1 ( gb ) ;\n cbp = get_vlc2 ( & v -> s . gb , v -> cbpcy_vlc -> table , VC1_CBPCY_P_VLC_BITS , 2 ) ;\n GET_MQUANT ( ) ;\n }\n else {\n mquant = v -> pq ;\n cbp = 0 ;\n }\n s -> current_picture . f . qscale_table [ mb_pos ] = mquant ;\n if ( ! v -> ttmbf && ! s -> mb_intra && mb_has_coeffs ) ttmb = get_vlc2 ( gb , ff_vc1_ttmb_vlc [ v -> tt_index ] . table , VC1_TTMB_VLC_BITS , 2 ) ;\n if ( ! s -> mb_intra ) vc1_mc_1mv ( v , 0 ) ;\n dst_idx = 0 ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) {\n s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;\n dst_idx += i >> 2 ;\n val = ( ( cbp >> ( 5 - i ) ) & 1 ) ;\n off = ( i & 4 ) ? 0 : ( ( i & 1 ) * 8 + ( i & 2 ) * 4 * s -> linesize ) ;\n v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = s -> mb_intra ;\n if ( s -> mb_intra ) {\n v -> a_avail = v -> c_avail = 0 ;\n if ( i == 2 || i == 3 || ! s -> first_slice_line ) v -> a_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - s -> block_wrap [ i ] ] ;\n if ( i == 1 || i == 3 || s -> mb_x ) v -> c_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - 1 ] ;\n vc1_decode_intra_block ( v , s -> block [ i ] , i , val , mquant , ( i & 4 ) ? v -> codingset2 : v -> codingset ) ;\n if ( ( i > 3 ) && ( s -> flags & CODEC_FLAG_GRAY ) ) continue ;\n v -> vc1dsp . vc1_inv_trans_8x8 ( s -> block [ i ] ) ;\n if ( v -> rangeredfrm ) for ( j = 0 ;\n j < 64 ;\n j ++ ) s -> block [ i ] [ j ] <<= 1 ;\n s -> dsp . put_signed_pixels_clamped ( s -> block [ i ] , s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;\n if ( v -> pq >= 9 && v -> overlap ) {\n if ( v -> c_avail ) v -> vc1dsp . vc1_h_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;\n if ( v -> a_avail ) v -> vc1dsp . vc1_v_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;\n }\n block_cbp |= 0xF << ( i << 2 ) ;\n block_intra |= 1 << i ;\n }\n else if ( val ) {\n pat = vc1_decode_p_block ( v , s -> block [ i ] , i , mquant , ttmb , first_block , s -> dest [ dst_idx ] + off , ( i & 4 ) ? s -> uvlinesize : s -> linesize , ( i & 4 ) && ( s -> flags & CODEC_FLAG_GRAY ) , & block_tt ) ;\n block_cbp |= pat << ( i << 2 ) ;\n if ( ! v -> ttmbf && ttmb < 8 ) ttmb = - 1 ;\n first_block = 0 ;\n }\n }\n }\n else {\n s -> mb_intra = 0 ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) {\n v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = 0 ;\n s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;\n }\n s -> current_picture . f . mb_type [ mb_pos ] = MB_TYPE_SKIP ;\n s -> current_picture . f . qscale_table [ mb_pos ] = 0 ;\n vc1_pred_mv ( v , 0 , 0 , 0 , 1 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;\n vc1_mc_1mv ( v , 0 ) ;\n }\n }\n else {\n if ( ! skipped ) {\n int intra_count = 0 , coded_inter = 0 ;\n int is_intra [ 6 ] , is_coded [ 6 ] ;\n cbp = get_vlc2 ( & v -> s . gb , v -> cbpcy_vlc -> table , VC1_CBPCY_P_VLC_BITS , 2 ) ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) {\n val = ( ( cbp >> ( 5 - i ) ) & 1 ) ;\n s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;\n s -> mb_intra = 0 ;\n if ( i < 4 ) {\n dmv_x = dmv_y = 0 ;\n s -> mb_intra = 0 ;\n mb_has_coeffs = 0 ;\n if ( val ) {\n GET_MVDATA ( dmv_x , dmv_y ) ;\n }\n vc1_pred_mv ( v , i , dmv_x , dmv_y , 0 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;\n if ( ! s -> mb_intra ) vc1_mc_4mv_luma ( v , i , 0 ) ;\n intra_count += s -> mb_intra ;\n is_intra [ i ] = s -> mb_intra ;\n is_coded [ i ] = mb_has_coeffs ;\n }\n if ( i & 4 ) {\n is_intra [ i ] = ( intra_count >= 3 ) ;\n is_coded [ i ] = val ;\n }\n if ( i == 4 ) vc1_mc_4mv_chroma ( v , 0 ) ;\n v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = is_intra [ i ] ;\n if ( ! coded_inter ) coded_inter = ! is_intra [ i ] & is_coded [ i ] ;\n }\n dst_idx = 0 ;\n if ( ! intra_count && ! coded_inter ) goto end ;\n GET_MQUANT ( ) ;\n s -> current_picture . f . qscale_table [ mb_pos ] = mquant ;\n {\n int intrapred = 0 ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) if ( is_intra [ i ] ) {\n if ( ( ( ! s -> first_slice_line || ( i == 2 || i == 3 ) ) && v -> mb_type [ 0 ] [ s -> block_index [ i ] - s -> block_wrap [ i ] ] ) || ( ( s -> mb_x || ( i == 1 || i == 3 ) ) && v -> mb_type [ 0 ] [ s -> block_index [ i ] - 1 ] ) ) {\n intrapred = 1 ;\n break ;\n }\n }\n if ( intrapred ) s -> ac_pred = get_bits1 ( gb ) ;\n else s -> ac_pred = 0 ;\n }\n if ( ! v -> ttmbf && coded_inter ) ttmb = get_vlc2 ( gb , ff_vc1_ttmb_vlc [ v -> tt_index ] . table , VC1_TTMB_VLC_BITS , 2 ) ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) {\n dst_idx += i >> 2 ;\n off = ( i & 4 ) ? 0 : ( ( i & 1 ) * 8 + ( i & 2 ) * 4 * s -> linesize ) ;\n s -> mb_intra = is_intra [ i ] ;\n if ( is_intra [ i ] ) {\n v -> a_avail = v -> c_avail = 0 ;\n if ( i == 2 || i == 3 || ! s -> first_slice_line ) v -> a_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - s -> block_wrap [ i ] ] ;\n if ( i == 1 || i == 3 || s -> mb_x ) v -> c_avail = v -> mb_type [ 0 ] [ s -> block_index [ i ] - 1 ] ;\n vc1_decode_intra_block ( v , s -> block [ i ] , i , is_coded [ i ] , mquant , ( i & 4 ) ? v -> codingset2 : v -> codingset ) ;\n if ( ( i > 3 ) && ( s -> flags & CODEC_FLAG_GRAY ) ) continue ;\n v -> vc1dsp . vc1_inv_trans_8x8 ( s -> block [ i ] ) ;\n if ( v -> rangeredfrm ) for ( j = 0 ;\n j < 64 ;\n j ++ ) s -> block [ i ] [ j ] <<= 1 ;\n s -> dsp . put_signed_pixels_clamped ( s -> block [ i ] , s -> dest [ dst_idx ] + off , ( i & 4 ) ? s -> uvlinesize : s -> linesize ) ;\n if ( v -> pq >= 9 && v -> overlap ) {\n if ( v -> c_avail ) v -> vc1dsp . vc1_h_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;\n if ( v -> a_avail ) v -> vc1dsp . vc1_v_overlap ( s -> dest [ dst_idx ] + off , i & 4 ? s -> uvlinesize : s -> linesize ) ;\n }\n block_cbp |= 0xF << ( i << 2 ) ;\n block_intra |= 1 << i ;\n }\n else if ( is_coded [ i ] ) {\n pat = vc1_decode_p_block ( v , s -> block [ i ] , i , mquant , ttmb , first_block , s -> dest [ dst_idx ] + off , ( i & 4 ) ? s -> uvlinesize : s -> linesize , ( i & 4 ) && ( s -> flags & CODEC_FLAG_GRAY ) , & block_tt ) ;\n block_cbp |= pat << ( i << 2 ) ;\n if ( ! v -> ttmbf && ttmb < 8 ) ttmb = - 1 ;\n first_block = 0 ;\n }\n }\n }\n else {\n s -> mb_intra = 0 ;\n s -> current_picture . f . qscale_table [ mb_pos ] = 0 ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) {\n v -> mb_type [ 0 ] [ s -> block_index [ i ] ] = 0 ;\n s -> dc_val [ 0 ] [ s -> block_index [ i ] ] = 0 ;\n }\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n vc1_pred_mv ( v , i , 0 , 0 , 0 , v -> range_x , v -> range_y , v -> mb_type [ 0 ] , 0 , 0 ) ;\n vc1_mc_4mv_luma ( v , i , 0 ) ;\n }\n vc1_mc_4mv_chroma ( v , 0 ) ;\n s -> current_picture . f . qscale_table [ mb_pos ] = 0 ;\n }\n }\n end : v -> cbp [ s -> mb_x ] = block_cbp ;\n v -> ttblk [ s -> mb_x ] = block_tt ;\n v -> is_intra [ s -> mb_x ] = block_intra ;\n return 0 ;\n }","target":1,"code_token_length":3031,"total_token_length":3267,"max_tokens_setting":4096}
+{"idx":311947,"func":"ecc_generate (const gcry_sexp_t genparms, gcry_sexp_t *r_skey)\n{\n  gpg_err_code_t rc;\n  unsigned int nbits;\n  elliptic_curve_t E;\n  ECC_secret_key sk;\n  gcry_mpi_t Gx = NULL;\n  gcry_mpi_t Gy = NULL;\n  gcry_mpi_t Qx = NULL;\n  gcry_mpi_t Qy = NULL;\n  char *curve_name = NULL;\n  gcry_sexp_t l1;\n  mpi_ec_t ctx = NULL;\n  gcry_sexp_t curve_info = NULL;\n  gcry_sexp_t curve_flags = NULL;\n  gcry_mpi_t base = NULL;\n  gcry_mpi_t public = NULL;\n  gcry_mpi_t secret = NULL;\n  int flags = 0;\n\n  memset (&E, 0, sizeof E);\n  memset (&sk, 0, sizeof sk);\n\n  rc = _gcry_pk_util_get_nbits (genparms, &nbits);\n  if (rc)\n    return rc;\n\n  \/* Parse the optional \"curve\" parameter. *\/\n  l1 = sexp_find_token (genparms, \"curve\", 0);\n  if (l1)\n    {\n      curve_name = _gcry_sexp_nth_string (l1, 1);\n      sexp_release (l1);\n      if (!curve_name)\n        return GPG_ERR_INV_OBJ; \/* No curve name or value too large. *\/\n    }\n\n  \/* Parse the optional flags list.  *\/\n  l1 = sexp_find_token (genparms, \"flags\", 0);\n  if (l1)\n    {\n      rc = _gcry_pk_util_parse_flaglist (l1, &flags, NULL);\n      sexp_release (l1);\n      if (rc)\n        goto leave;\n    }\n\n  \/* Parse the deprecated optional transient-key flag.  *\/\n  l1 = sexp_find_token (genparms, \"transient-key\", 0);\n  if (l1)\n    {\n      flags |= PUBKEY_FLAG_TRANSIENT_KEY;\n      sexp_release (l1);\n    }\n\n  \/* NBITS is required if no curve name has been given.  *\/\n  if (!nbits && !curve_name)\n    return GPG_ERR_NO_OBJ; \/* No NBITS parameter. *\/\n\n  rc = _gcry_ecc_fill_in_curve (nbits, curve_name, &E, &nbits);\n  if (rc)\n    goto leave;\n\n  if (DBG_CIPHER)\n    {\n      log_debug (\"ecgen curve info: %s\/%s\\n\",\n                 _gcry_ecc_model2str (E.model),\n                 _gcry_ecc_dialect2str (E.dialect));\n      if (E.name)\n        log_debug (\"ecgen curve used: %s\\n\", E.name);\n      log_printmpi (\"ecgen curve   p\", E.p);\n      log_printmpi (\"ecgen curve   a\", E.a);\n      log_printmpi (\"ecgen curve   b\", E.b);\n      log_printmpi (\"ecgen curve   n\", E.n);\n      log_printmpi (\"ecgen curve   h\", E.h);\n      log_printpnt (\"ecgen curve G\", &E.G, NULL);\n    }\n\n  ctx = _gcry_mpi_ec_p_internal_new (E.model, E.dialect, flags, E.p, E.a, E.b);\n\n  if (E.model == MPI_EC_MONTGOMERY)\n    rc = nist_generate_key (&sk, &E, ctx, flags, nbits, &Qx, NULL);\n  else if ((flags & PUBKEY_FLAG_EDDSA))\n    rc = _gcry_ecc_eddsa_genkey (&sk, &E, ctx, flags);\n  else\n    rc = nist_generate_key (&sk, &E, ctx, flags, nbits, &Qx, &Qy);\n  if (rc)\n    goto leave;\n\n  \/* Copy data to the result.  *\/\n  Gx = mpi_new (0);\n  Gy = mpi_new (0);\n  if (E.model != MPI_EC_MONTGOMERY)\n    {\n      if (_gcry_mpi_ec_get_affine (Gx, Gy, &sk.E.G, ctx))\n        log_fatal (\"ecgen: Failed to get affine coordinates for %s\\n\", \"G\");\n      base = _gcry_ecc_ec2os (Gx, Gy, sk.E.p);\n    }\n  if ((sk.E.dialect == ECC_DIALECT_ED25519 || E.model == MPI_EC_MONTGOMERY)\n      && !(flags & PUBKEY_FLAG_NOCOMP))\n    {\n      unsigned char *encpk;\n      unsigned int encpklen;\n\n      if (E.model != MPI_EC_MONTGOMERY)\n        \/* (Gx and Gy are used as scratch variables)  *\/\n        rc = _gcry_ecc_eddsa_encodepoint (&sk.Q, ctx, Gx, Gy,\n                                          !!(flags & PUBKEY_FLAG_COMP),\n                                          &encpk, &encpklen);\n      else\n        {\n          encpk = _gcry_mpi_get_buffer_extra (Qx, nbits\/8,\n                                              -1, &encpklen, NULL);\n          if (encpk == NULL)\n            rc = gpg_err_code_from_syserror ();\n          else\n            {\n              encpk[0] = 0x40;\n              encpklen++;\n            }\n        }\n      if (rc)\n        goto leave;\n      public = mpi_new (0);\n      mpi_set_opaque (public, encpk, encpklen*8);\n    }\n  else\n    {\n      if (!Qx)\n        {\n          \/* This is the case for a key from _gcry_ecc_eddsa_generate\n             with no compression.  *\/\n          Qx = mpi_new (0);\n          Qy = mpi_new (0);\n          if (_gcry_mpi_ec_get_affine (Qx, Qy, &sk.Q, ctx))\n            log_fatal (\"ecgen: Failed to get affine coordinates for %s\\n\", \"Q\");\n        }\n      public = _gcry_ecc_ec2os (Qx, Qy, sk.E.p);\n    }\n  secret = sk.d; sk.d = NULL;\n  if (E.name)\n    {\n      rc = sexp_build (&curve_info, NULL, \"(curve %s)\", E.name);\n      if (rc)\n        goto leave;\n    }\n\n  if ((flags & PUBKEY_FLAG_PARAM) || (flags & PUBKEY_FLAG_EDDSA)\n      || (flags & PUBKEY_FLAG_DJB_TWEAK))\n    {\n      rc = sexp_build\n        (&curve_flags, NULL,\n         ((flags & PUBKEY_FLAG_PARAM) && (flags & PUBKEY_FLAG_EDDSA))?\n         \"(flags param eddsa)\" :\n         ((flags & PUBKEY_FLAG_PARAM) && (flags & PUBKEY_FLAG_EDDSA))?\n         \"(flags param djb-tweak)\" :\n         ((flags & PUBKEY_FLAG_PARAM))?\n         \"(flags param)\" : ((flags & PUBKEY_FLAG_EDDSA))?\n         \"(flags eddsa)\" : \"(flags djb-tweak)\" );\n      if (rc)\n        goto leave;\n    }\n\n  if ((flags & PUBKEY_FLAG_PARAM) && E.name)\n    rc = sexp_build (r_skey, NULL,\n                     \"(key-data\"\n                     \" (public-key\"\n                     \"  (ecc%S%S(p%m)(a%m)(b%m)(g%m)(n%m)(h%m)(q%m)))\"\n                     \" (private-key\"\n                     \"  (ecc%S%S(p%m)(a%m)(b%m)(g%m)(n%m)(h%m)(q%m)(d%m)))\"\n                     \" )\",\n                     curve_info, curve_flags,\n                     sk.E.p, sk.E.a, sk.E.b, base, sk.E.n, sk.E.h, public,\n                     curve_info, curve_flags,\n                     sk.E.p, sk.E.a, sk.E.b, base, sk.E.n, sk.E.h, public,\n                                                                   secret);\n  else\n    rc = sexp_build (r_skey, NULL,\n                     \"(key-data\"\n                     \" (public-key\"\n                     \"  (ecc%S%S(q%m)))\"\n                     \" (private-key\"\n                     \"  (ecc%S%S(q%m)(d%m)))\"\n                     \" )\",\n                     curve_info, curve_flags,\n                     public,\n                     curve_info, curve_flags,\n                     public, secret);\n  if (rc)\n    goto leave;\n\n  if (DBG_CIPHER)\n    {\n      log_printmpi (\"ecgen result  p\", sk.E.p);\n      log_printmpi (\"ecgen result  a\", sk.E.a);\n      log_printmpi (\"ecgen result  b\", sk.E.b);\n      log_printmpi (\"ecgen result  G\", base);\n      log_printmpi (\"ecgen result  n\", sk.E.n);\n      log_printmpi (\"ecgen result  h\", sk.E.h);\n      log_printmpi (\"ecgen result  Q\", public);\n      log_printmpi (\"ecgen result  d\", secret);\n      if ((flags & PUBKEY_FLAG_EDDSA))\n        log_debug (\"ecgen result  using Ed25519+EdDSA\\n\");\n    }\n\n leave:\n  mpi_free (secret);\n  mpi_free (public);\n  mpi_free (base);\n  {\n    _gcry_ecc_curve_free (&sk.E);\n    point_free (&sk.Q);\n    mpi_free (sk.d);\n  }\n  _gcry_ecc_curve_free (&E);\n  mpi_free (Gx);\n  mpi_free (Gy);\n  mpi_free (Qx);\n  mpi_free (Qy);\n  _gcry_mpi_ec_free (ctx);\n  xfree (curve_name);\n  sexp_release (curve_flags);\n  sexp_release (curve_info);\n  return rc;\n}\n","target":0,"code_token_length":2069,"total_token_length":2305,"max_tokens_setting":4096}
+{"idx":34164,"func":"void sqlite3EndTable(\n  Parse *pParse,          \/* Parse context *\/\n  Token *pCons,           \/* The ',' token after the last column defn. *\/\n  Token *pEnd,            \/* The ')' before options in the CREATE TABLE *\/\n  u8 tabOpts,             \/* Extra table options. Usually 0. *\/\n  Select *pSelect         \/* Select from a \"CREATE ... AS SELECT\" *\/\n){\n  Table *p;                 \/* The new table *\/\n  sqlite3 *db = pParse->db; \/* The database connection *\/\n  int iDb;                  \/* Database in which the table lives *\/\n  Index *pIdx;              \/* An implied index of the table *\/\n\n  if( pEnd==0 && pSelect==0 ){\n    return;\n  }\n  assert( !db->mallocFailed );\n  p = pParse->pNewTable;\n  if( p==0 ) return;\n\n  if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){\n    p->tabFlags |= TF_Shadow;\n  }\n\n  \/* If the db->init.busy is 1 it means we are reading the SQL off the\n  ** \"sqlite_master\" or \"sqlite_temp_master\" table on the disk.\n  ** So do not write to the disk again.  Extract the root page number\n  ** for the table from the db->init.newTnum field.  (The page number\n  ** should have been put there by the sqliteOpenCb routine.)\n  **\n  ** If the root page number is 1, that means this is the sqlite_master\n  ** table itself.  So mark it read-only.\n  *\/\n  if( db->init.busy ){\n    if( pSelect ){\n      sqlite3ErrorMsg(pParse, \"\");\n      return;\n    }\n    p->tnum = db->init.newTnum;\n    if( p->tnum==1 ) p->tabFlags |= TF_Readonly;\n  }\n\n  assert( (p->tabFlags & TF_HasPrimaryKey)==0\n       || p->iPKey>=0 || sqlite3PrimaryKeyIndex(p)!=0 );\n  assert( (p->tabFlags & TF_HasPrimaryKey)!=0\n       || (p->iPKey<0 && sqlite3PrimaryKeyIndex(p)==0) );\n\n  \/* Special processing for WITHOUT ROWID Tables *\/\n  if( tabOpts & TF_WithoutRowid ){\n    if( (p->tabFlags & TF_Autoincrement) ){\n      sqlite3ErrorMsg(pParse,\n          \"AUTOINCREMENT not allowed on WITHOUT ROWID tables\");\n      return;\n    }\n    if( (p->tabFlags & TF_HasPrimaryKey)==0 ){\n      sqlite3ErrorMsg(pParse, \"PRIMARY KEY missing on table %s\", p->zName);\n      return;\n    }\n    p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;\n    convertToWithoutRowidTable(pParse, p);\n  }\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n\n#ifndef SQLITE_OMIT_CHECK\n  \/* Resolve names in all CHECK constraint expressions.\n  *\/\n  if( p->pCheck ){\n    sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);\n  }\n#endif \/* !defined(SQLITE_OMIT_CHECK) *\/\n#ifndef SQLITE_OMIT_GENERATED_COLUMNS\n  if( p->tabFlags & TF_HasGenerated ){\n    int ii, nNG = 0;\n    testcase( p->tabFlags & TF_HasVirtual );\n    testcase( p->tabFlags & TF_HasStored );\n    for(ii=0; iinCol; ii++){\n      u32 colFlags = p->aCol[ii].colFlags;\n      if( (colFlags & COLFLAG_GENERATED)!=0 ){\n        testcase( colFlags & COLFLAG_VIRTUAL );\n        testcase( colFlags & COLFLAG_STORED );\n        sqlite3ResolveSelfReference(pParse, p, NC_GenCol, \n                                    p->aCol[ii].pDflt, 0);\n      }else{\n        nNG++;\n      }\n    }\n    if( nNG==0 ){\n      sqlite3ErrorMsg(pParse, \"must have at least one non-generated column\");\n      return;\n    }\n  }\n#endif\n\n  \/* Estimate the average row size for the table and for all implied indices *\/\n  estimateTableWidth(p);\n  for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n    estimateIndexWidth(pIdx);\n  }\n\n  \/* If not initializing, then create a record for the new table\n  ** in the SQLITE_MASTER table of the database.\n  **\n  ** If this is a TEMPORARY table, write the entry into the auxiliary\n  ** file instead of into the main database file.\n  *\/\n  if( !db->init.busy ){\n    int n;\n    Vdbe *v;\n    char *zType;    \/* \"view\" or \"table\" *\/\n    char *zType2;   \/* \"VIEW\" or \"TABLE\" *\/\n    char *zStmt;    \/* Text of the CREATE TABLE or CREATE VIEW statement *\/\n\n    v = sqlite3GetVdbe(pParse);\n    if( NEVER(v==0) ) return;\n\n    sqlite3VdbeAddOp1(v, OP_Close, 0);\n\n    \/* \n    ** Initialize zType for the new view or table.\n    *\/\n    if( p->pSelect==0 ){\n      \/* A regular table *\/\n      zType = \"table\";\n      zType2 = \"TABLE\";\n#ifndef SQLITE_OMIT_VIEW\n    }else{\n      \/* A view *\/\n      zType = \"view\";\n      zType2 = \"VIEW\";\n#endif\n    }\n\n    \/* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT\n    ** statement to populate the new table. The root-page number for the\n    ** new table is in register pParse->regRoot.\n    **\n    ** Once the SELECT has been coded by sqlite3Select(), it is in a\n    ** suitable state to query for the column names and types to be used\n    ** by the new table.\n    **\n    ** A shared-cache write-lock is not required to write to the new table,\n    ** as a schema-lock must have already been obtained to create it. Since\n    ** a schema-lock excludes all other database users, the write-lock would\n    ** be redundant.\n    *\/\n    if( pSelect ){\n      SelectDest dest;    \/* Where the SELECT should store results *\/\n      int regYield;       \/* Register holding co-routine entry-point *\/\n      int addrTop;        \/* Top of the co-routine *\/\n      int regRec;         \/* A record to be insert into the new table *\/\n      int regRowid;       \/* Rowid of the next row to insert *\/\n      int addrInsLoop;    \/* Top of the loop for inserting rows *\/\n      Table *pSelTab;     \/* A table that describes the SELECT results *\/\n\n      regYield = ++pParse->nMem;\n      regRec = ++pParse->nMem;\n      regRowid = ++pParse->nMem;\n      assert(pParse->nTab==1);\n      sqlite3MayAbort(pParse);\n      sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);\n      sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);\n      pParse->nTab = 2;\n      addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n      if( pParse->nErr ) return;\n      pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);\n      if( pSelTab==0 ) return;\n      assert( p->aCol==0 );\n      p->nCol = p->nNVCol = pSelTab->nCol;\n      p->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      sqlite3DeleteTable(db, pSelTab);\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n      sqlite3Select(pParse, pSelect, &dest);\n      if( pParse->nErr ) return;\n      sqlite3VdbeEndCoroutine(v, regYield);\n      sqlite3VdbeJumpHere(v, addrTop - 1);\n      addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);\n      sqlite3TableAffinity(v, p, 0);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);\n      sqlite3VdbeGoto(v, addrInsLoop);\n      sqlite3VdbeJumpHere(v, addrInsLoop);\n      sqlite3VdbeAddOp1(v, OP_Close, 1);\n    }\n\n    \/* Compute the complete text of the CREATE statement *\/\n    if( pSelect ){\n      zStmt = createTableStmt(db, p);\n    }else{\n      Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd;\n      n = (int)(pEnd2->z - pParse->sNameToken.z);\n      if( pEnd2->z[0]!=';' ) n += pEnd2->n;\n      zStmt = sqlite3MPrintf(db, \n          \"CREATE %s %.*s\", zType2, n, pParse->sNameToken.z\n      );\n    }\n\n    \/* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.\n    *\/\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      zType,\n      p->zName,\n      p->zName,\n      pParse->regRoot,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    sqlite3ChangeCookie(pParse, iDb);\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    \/* Check to see if we need to create an sqlite_sequence table for\n    ** keeping track of autoincrement keys.\n    *\/\n    if( (p->tabFlags & TF_Autoincrement)!=0 ){\n      Db *pDb = &db->aDb[iDb];\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      if( pDb->pSchema->pSeqTab==0 ){\n        sqlite3NestedParse(pParse,\n          \"CREATE TABLE %Q.sqlite_sequence(name,seq)\",\n          pDb->zDbSName\n        );\n      }\n    }\n#endif\n\n    \/* Reparse everything to update our internal data structures *\/\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n           sqlite3MPrintf(db, \"tbl_name='%q' AND type!='trigger'\", p->zName));\n  }\n\n  \/* Add the table to the in-memory representation of the database.\n  *\/\n  if( db->init.busy ){\n    Table *pOld;\n    Schema *pSchema = p->pSchema;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);\n    if( pOld ){\n      assert( p==pOld );  \/* Malloc must have failed inside HashInsert() *\/\n      sqlite3OomFault(db);\n      return;\n    }\n    pParse->pNewTable = 0;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n    if( !p->pSelect ){\n      const char *zName = (const char *)pParse->sNameToken.z;\n      int nName;\n      assert( !pSelect && pCons && pEnd );\n      if( pCons->z==0 ){\n        pCons = pEnd;\n      }\n      nName = (int)((const char *)pCons->z - zName);\n      p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);\n    }\n#endif\n  }\n}","target":0,"code_token_length":2703,"total_token_length":2939,"max_tokens_setting":4096}
+{"idx":287628,"func":"tiffcp(TIFF* in, TIFF* out)\n{\n\tuint16 bitspersample, samplesperpixel;\n\tuint16 input_compression, input_photometric;\n\tcopyFunc cf;\n\tuint32 width, length;\n\tstruct cpTag* p;\n\n\tCopyField(TIFFTAG_IMAGEWIDTH, width);\n\tCopyField(TIFFTAG_IMAGELENGTH, length);\n\tCopyField(TIFFTAG_BITSPERSAMPLE, bitspersample);\n\tCopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);\n\tif (compression != (uint16)-1)\n\t\tTIFFSetField(out, TIFFTAG_COMPRESSION, compression);\n\telse\n\t\tCopyField(TIFFTAG_COMPRESSION, compression);\n\tTIFFGetFieldDefaulted(in, TIFFTAG_COMPRESSION, &input_compression);\n\tTIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric);\n\tif (input_compression == COMPRESSION_JPEG) {\n\t\t\/* Force conversion to RGB *\/\n\t\tTIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);\n\t} else if (input_photometric == PHOTOMETRIC_YCBCR) {\n\t\t\/* Otherwise, can't handle subsampled input *\/\n\t\tuint16 subsamplinghor,subsamplingver;\n\n\t\tTIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING,\n\t\t\t\t      &subsamplinghor, &subsamplingver);\n\t\tif (subsamplinghor!=1 || subsamplingver!=1) {\n\t\t\tfprintf(stderr, \"tiffcp: %s: Can't copy\/convert subsampled image.\\n\",\n\t\t\t\tTIFFFileName(in));\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\tif (compression == COMPRESSION_JPEG) {\n\t\tif (input_photometric == PHOTOMETRIC_RGB &&\n\t\t    jpegcolormode == JPEGCOLORMODE_RGB)\n\t\t  TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR);\n\t\telse\n\t\t  TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric);\n\t}\n\telse if (compression == COMPRESSION_SGILOG\n\t    || compression == COMPRESSION_SGILOG24)\n\t\tTIFFSetField(out, TIFFTAG_PHOTOMETRIC,\n\t\t    samplesperpixel == 1 ?\n\t\t    PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV);\n\telse if (input_compression == COMPRESSION_JPEG &&\n\t\t\t samplesperpixel == 3 ) {\n\t\t\/* RGB conversion was forced above\n\t\thence the output will be of the same type *\/\n\t\tTIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);\n\t}\n\telse\n\t\tCopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT);\n\tif (fillorder != 0)\n\t\tTIFFSetField(out, TIFFTAG_FILLORDER, fillorder);\n\telse\n\t\tCopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT);\n\t\/*\n\t * Will copy `Orientation' tag from input image\n\t *\/\n\tTIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation);\n\tswitch (orientation) {\n\t\tcase ORIENTATION_BOTRIGHT:\n\t\tcase ORIENTATION_RIGHTBOT:\t\/* XXX *\/\n\t\t\tTIFFWarning(TIFFFileName(in), \"using bottom-left orientation\");\n\t\t\torientation = ORIENTATION_BOTLEFT;\n\t\t\/* fall thru... *\/\n\t\tcase ORIENTATION_LEFTBOT:\t\/* XXX *\/\n\t\tcase ORIENTATION_BOTLEFT:\n\t\t\tbreak;\n\t\tcase ORIENTATION_TOPRIGHT:\n\t\tcase ORIENTATION_RIGHTTOP:\t\/* XXX *\/\n\t\tdefault:\n\t\t\tTIFFWarning(TIFFFileName(in), \"using top-left orientation\");\n\t\t\torientation = ORIENTATION_TOPLEFT;\n\t\t\/* fall thru... *\/\n\t\tcase ORIENTATION_LEFTTOP:\t\/* XXX *\/\n\t\tcase ORIENTATION_TOPLEFT:\n\t\t\tbreak;\n\t}\n\tTIFFSetField(out, TIFFTAG_ORIENTATION, orientation);\n\t\/*\n\t * Choose tiles\/strip for the output image according to\n\t * the command line arguments (-tiles, -strips) and the\n\t * structure of the input image.\n\t *\/\n\tif (outtiled == -1)\n\t\touttiled = TIFFIsTiled(in);\n\tif (outtiled) {\n\t\t\/*\n\t\t * Setup output file's tile width&height.  If either\n\t\t * is not specified, use either the value from the\n\t\t * input image or, if nothing is defined, use the\n\t\t * library default.\n\t\t *\/\n\t\tif (tilewidth == (uint32) -1)\n\t\t\tTIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth);\n\t\tif (tilelength == (uint32) -1)\n\t\t\tTIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength);\n\t\tTIFFDefaultTileSize(out, &tilewidth, &tilelength);\n\t\tTIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth);\n\t\tTIFFSetField(out, TIFFTAG_TILELENGTH, tilelength);\n\t} else {\n\t\t\/*\n\t\t * RowsPerStrip is left unspecified: use either the\n\t\t * value from the input image or, if nothing is defined,\n\t\t * use the library default.\n\t\t *\/\n\t\tif (rowsperstrip == (uint32) 0) {\n\t\t\tif (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP,\n\t\t\t    &rowsperstrip)) {\n\t\t\t\trowsperstrip =\n\t\t\t\t    TIFFDefaultStripSize(out, rowsperstrip);\n\t\t\t}\n\t\t\tif (rowsperstrip > length && rowsperstrip != (uint32)-1)\n\t\t\t\trowsperstrip = length;\n\t\t}\n\t\telse if (rowsperstrip == (uint32) -1)\n\t\t\trowsperstrip = length;\n\t\tTIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);\n\t}\n\tif (config != (uint16) -1)\n\t\tTIFFSetField(out, TIFFTAG_PLANARCONFIG, config);\n\telse\n\t\tCopyField(TIFFTAG_PLANARCONFIG, config);\n\tif (samplesperpixel <= 4)\n\t\tCopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT);\n\tCopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT);\n\/* SMinSampleValue & SMaxSampleValue *\/\n\tswitch (compression) {\n\t\tcase COMPRESSION_JPEG:\n\t\t\tTIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);\n\t\t\tTIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);\n\t\t\tbreak;\n\t\tcase COMPRESSION_JBIG:\n\t\t\tCopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII);\n\t\t\tCopyTag(TIFFTAG_FAXDCS, 1, TIFF_ASCII);\n\t\t\tbreak;\n\t\tcase COMPRESSION_LZW:\n\t\tcase COMPRESSION_ADOBE_DEFLATE:\n\t\tcase COMPRESSION_DEFLATE:\n                case COMPRESSION_LZMA:\n\t\t\tif (predictor != (uint16)-1)\n\t\t\t\tTIFFSetField(out, TIFFTAG_PREDICTOR, predictor);\n\t\t\telse\n\t\t\t\tCopyField(TIFFTAG_PREDICTOR, predictor);\n\t\t\tif (preset != -1) {\n                                if (compression == COMPRESSION_ADOBE_DEFLATE\n                                         || compression == COMPRESSION_DEFLATE)\n                                        TIFFSetField(out, TIFFTAG_ZIPQUALITY, preset);\n\t\t\t\telse if (compression == COMPRESSION_LZMA)\n\t\t\t\t\tTIFFSetField(out, TIFFTAG_LZMAPRESET, preset);\n                        }\n\t\t\tbreak;\n\t\tcase COMPRESSION_CCITTFAX3:\n\t\tcase COMPRESSION_CCITTFAX4:\n\t\t\tif (compression == COMPRESSION_CCITTFAX3) {\n\t\t\t\tif (g3opts != (uint32) -1)\n\t\t\t\t\tTIFFSetField(out, TIFFTAG_GROUP3OPTIONS,\n\t\t\t\t\t    g3opts);\n\t\t\t\telse\n\t\t\t\t\tCopyField(TIFFTAG_GROUP3OPTIONS, g3opts);\n\t\t\t} else\n\t\t\t\tCopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG);\n\t\t\tCopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII);\n\t\t\tbreak;\n\t}\n\t{\n\t\tuint32 len32;\n\t\tvoid** data;\n\t\tif (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data))\n\t\t\tTIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data);\n\t}\n\t{\n\t\tuint16 ninks;\n\t\tconst char* inknames;\n\t\tif (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) {\n\t\t\tTIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks);\n\t\t\tif (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) {\n\t\t\t\tint inknameslen = strlen(inknames) + 1;\n\t\t\t\tconst char* cp = inknames;\n\t\t\t\twhile (ninks > 1) {\n\t\t\t\t\tcp = strchr(cp, '\\0');\n                                        cp++;\n                                        inknameslen += (strlen(cp) + 1);\n\t\t\t\t\tninks--;\n\t\t\t\t}\n\t\t\t\tTIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames);\n\t\t\t}\n\t\t}\n\t}\n\t{\n\t\tunsigned short pg0, pg1;\n\n\t\tif (pageInSeq == 1) {\n\t\t\tif (pageNum < 0) \/* only one input file *\/ {\n\t\t\t\tif (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1))\n\t\t\t\t\tTIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1);\n\t\t\t} else\n\t\t\t\tTIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0);\n\n\t\t} else {\n\t\t\tif (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) {\n\t\t\t\tif (pageNum < 0) \/* only one input file *\/\n\t\t\t\t\tTIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1);\n\t\t\t\telse\n\t\t\t\t\tTIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (p = tags; p < &tags[NTAGS]; p++)\n\t\tCopyTag(p->tag, p->count, p->type);\n\n\tcf = pickCopyFunc(in, out, bitspersample, samplesperpixel);\n\treturn (cf ? (*cf)(in, out, length, width, samplesperpixel) : FALSE);\n}","target":1,"code_token_length":2335,"total_token_length":2571,"max_tokens_setting":4096}
+{"idx":23475,"func":"static int replace_user_table ( THD * thd , TABLE * table , const LEX_USER & combo , ulong rights , bool revoke_grant , bool can_create_user , bool no_auto_create ) {\n int error = - 1 ;\n bool old_row_exists = 0 ;\n const char * password = \"\" ;\n uint password_len = 0 ;\n char what = ( revoke_grant ) ? 'N' : 'Y' ;\n uchar user_key [ MAX_KEY_LENGTH ] ;\n LEX * lex = thd -> lex ;\n DBUG_ENTER ( \"replace_user_table\" ) ;\n safe_mutex_assert_owner ( & acl_cache -> lock ) ;\n if ( combo . password . str && combo . password . str [ 0 ] ) {\n if ( combo . password . length != SCRAMBLED_PASSWORD_CHAR_LENGTH && combo . password . length != SCRAMBLED_PASSWORD_CHAR_LENGTH_323 ) {\n my_error ( ER_PASSWD_LENGTH , MYF ( 0 ) , SCRAMBLED_PASSWORD_CHAR_LENGTH ) ;\n DBUG_RETURN ( - 1 ) ;\n }\n password_len = combo . password . length ;\n password = combo . password . str ;\n }\n table -> use_all_columns ( ) ;\n table -> field [ 0 ] -> store ( combo . host . str , combo . host . length , system_charset_info ) ;\n table -> field [ 1 ] -> store ( combo . user . str , combo . user . length , system_charset_info ) ;\n key_copy ( user_key , table -> record [ 0 ] , table -> key_info , table -> key_info -> key_length ) ;\n if ( table -> file -> index_read_idx_map ( table -> record [ 0 ] , 0 , user_key , HA_WHOLE_KEY , HA_READ_KEY_EXACT ) ) {\n if ( what == 'N' ) {\n my_error ( ER_NONEXISTING_GRANT , MYF ( 0 ) , combo . user . str , combo . host . str ) ;\n goto end ;\n }\n else if ( ! password_len && no_auto_create ) {\n my_error ( ER_PASSWORD_NO_MATCH , MYF ( 0 ) ) ;\n goto end ;\n }\n else if ( ! can_create_user ) {\n my_error ( ER_CANT_CREATE_USER_WITH_GRANT , MYF ( 0 ) ) ;\n goto end ;\n }\n old_row_exists = 0 ;\n restore_record ( table , s -> default_values ) ;\n table -> field [ 0 ] -> store ( combo . host . str , combo . host . length , system_charset_info ) ;\n table -> field [ 1 ] -> store ( combo . user . str , combo . user . length , system_charset_info ) ;\n table -> field [ 2 ] -> store ( password , password_len , system_charset_info ) ;\n }\n else {\n old_row_exists = 1 ;\n store_record ( table , record [ 1 ] ) ;\n if ( combo . password . str ) table -> field [ 2 ] -> store ( password , password_len , system_charset_info ) ;\n else if ( ! rights && ! revoke_grant && lex -> ssl_type == SSL_TYPE_NOT_SPECIFIED && ! lex -> mqh . specified_limits ) {\n DBUG_RETURN ( 0 ) ;\n }\n }\n Field * * tmp_field ;\n ulong priv ;\n uint next_field ;\n for ( tmp_field = table -> field + 3 , priv = SELECT_ACL ;\n * tmp_field && ( * tmp_field ) -> real_type ( ) == MYSQL_TYPE_ENUM && ( ( Field_enum * ) ( * tmp_field ) ) -> typelib -> count == 2 ;\n tmp_field ++ , priv <<= 1 ) {\n if ( priv & rights ) ( * tmp_field ) -> store ( & what , 1 , & my_charset_latin1 ) ;\n }\n rights = get_access ( table , 3 , & next_field ) ;\n DBUG_PRINT ( \"info\" , ( \"table fields: %d\" , table -> s -> fields ) ) ;\n if ( table -> s -> fields >= 31 ) {\n switch ( lex -> ssl_type ) {\n case SSL_TYPE_ANY : table -> field [ next_field ] -> store ( STRING_WITH_LEN ( \"ANY\" ) , & my_charset_latin1 ) ;\n table -> field [ next_field + 1 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 2 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 3 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n break ;\n case SSL_TYPE_X509 : table -> field [ next_field ] -> store ( STRING_WITH_LEN ( \"X509\" ) , & my_charset_latin1 ) ;\n table -> field [ next_field + 1 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 2 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 3 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n break ;\n case SSL_TYPE_SPECIFIED : table -> field [ next_field ] -> store ( STRING_WITH_LEN ( \"SPECIFIED\" ) , & my_charset_latin1 ) ;\n table -> field [ next_field + 1 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 2 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 3 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n if ( lex -> ssl_cipher ) table -> field [ next_field + 1 ] -> store ( lex -> ssl_cipher , strlen ( lex -> ssl_cipher ) , system_charset_info ) ;\n if ( lex -> x509_issuer ) table -> field [ next_field + 2 ] -> store ( lex -> x509_issuer , strlen ( lex -> x509_issuer ) , system_charset_info ) ;\n if ( lex -> x509_subject ) table -> field [ next_field + 3 ] -> store ( lex -> x509_subject , strlen ( lex -> x509_subject ) , system_charset_info ) ;\n break ;\n case SSL_TYPE_NOT_SPECIFIED : break ;\n case SSL_TYPE_NONE : table -> field [ next_field ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 1 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 2 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n table -> field [ next_field + 3 ] -> store ( \"\" , 0 , & my_charset_latin1 ) ;\n break ;\n }\n next_field += 4 ;\n USER_RESOURCES mqh = lex -> mqh ;\n if ( mqh . specified_limits & USER_RESOURCES : : QUERIES_PER_HOUR ) table -> field [ next_field ] -> store ( ( longlong ) mqh . questions , TRUE ) ;\n if ( mqh . specified_limits & USER_RESOURCES : : UPDATES_PER_HOUR ) table -> field [ next_field + 1 ] -> store ( ( longlong ) mqh . updates , TRUE ) ;\n if ( mqh . specified_limits & USER_RESOURCES : : CONNECTIONS_PER_HOUR ) table -> field [ next_field + 2 ] -> store ( ( longlong ) mqh . conn_per_hour , TRUE ) ;\n if ( table -> s -> fields >= 36 && ( mqh . specified_limits & USER_RESOURCES : : USER_CONNECTIONS ) ) table -> field [ next_field + 3 ] -> store ( ( longlong ) mqh . user_conn , TRUE ) ;\n mqh_used = mqh_used || mqh . questions || mqh . updates || mqh . conn_per_hour ;\n }\n if ( old_row_exists ) {\n if ( cmp_record ( table , record [ 1 ] ) ) {\n if ( ( error = table -> file -> ha_update_row ( table -> record [ 1 ] , table -> record [ 0 ] ) ) && error != HA_ERR_RECORD_IS_THE_SAME ) {\n table -> file -> print_error ( error , MYF ( 0 ) ) ;\n error = - 1 ;\n goto end ;\n }\n else error = 0 ;\n }\n }\n else if ( ( error = table -> file -> ha_write_row ( table -> record [ 0 ] ) ) ) {\n if ( table -> file -> is_fatal_error ( error , HA_CHECK_DUP ) ) {\n table -> file -> print_error ( error , MYF ( 0 ) ) ;\n error = - 1 ;\n goto end ;\n }\n }\n error = 0 ;\n end : if ( ! error ) {\n acl_cache -> clear ( 1 ) ;\n if ( old_row_exists ) acl_update_user ( combo . user . str , combo . host . str , combo . password . str , password_len , lex -> ssl_type , lex -> ssl_cipher , lex -> x509_issuer , lex -> x509_subject , & lex -> mqh , rights ) ;\n else acl_insert_user ( combo . user . str , combo . host . str , password , password_len , lex -> ssl_type , lex -> ssl_cipher , lex -> x509_issuer , lex -> x509_subject , & lex -> mqh , rights ) ;\n }\n DBUG_RETURN ( error ) ;\n }","target":0,"code_token_length":1972,"total_token_length":2208,"max_tokens_setting":4096}
+{"idx":127749,"func":"static void cmd_anal_hint(RCore *core, const char *input) {\n\tswitch (input[0]) {\n\tcase '?':\n\t\tif (input[1]) {\n\t\t\tut64 addr = r_num_math (core->num, input + 1);\n\t\t\tr_core_anal_hint_print (core->anal, addr, 0);\n\t\t} else {\n\t\t\tr_core_cmd_help (core, help_msg_ah);\n\t\t}\n\t\tbreak;\n\tcase '.': \/\/ \"ah.\"\n\t\tr_core_anal_hint_print (core->anal, core->offset, 0);\n\t\tbreak;\n\tcase 'a': \/\/ \"aha\" set arch\n\t\tif (input[1]) {\n\t\t\tint i;\n\t\t\tchar *ptr = strdup (input + 2);\n\t\t\ti = r_str_word_set0 (ptr);\n\t\t\tif (i == 2) {\n\t\t\t\tr_num_math (core->num, r_str_word_get0 (ptr, 1));\n\t\t\t}\n\t\t\tr_anal_hint_set_arch (core->anal, core->offset, r_str_word_get0 (ptr, 0));\n\t\t\tfree (ptr);\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_arch (core->anal, core->offset);\n\t\t} else {\n\t\t\teprintf (\"Missing argument\\n\");\n\t\t}\n\t\tbreak;\n\tcase 'b': \/\/ \"ahb\" set bits\n\t\tif (input[1]) {\n\t\t\tchar *ptr = strdup (input + 2);\n\t\t\tint bits;\n\t\t\tint i = r_str_word_set0 (ptr);\n\t\t\tif (i == 2) {\n\t\t\t\tr_num_math (core->num, r_str_word_get0 (ptr, 1));\n\t\t\t}\n\t\t\tbits = r_num_math (core->num, r_str_word_get0 (ptr, 0));\n\t\t\tr_anal_hint_set_bits (core->anal, core->offset, bits);\n\t\t\tfree (ptr);\n\t\t}  else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_bits (core->anal, core->offset);\n\t\t} else {\n\t\t\teprintf (\"Missing argument\\n\");\n\t\t}\n\t\tbreak;\n\tcase 'i': \/\/ \"ahi\"\n\t\tif (input[1] == '?') {\n\t\t\tr_core_cmd_help (core, help_msg_ahi);\n\t\t} else if (input[1] == ' ') {\n\t\t\/\/ You can either specify immbase with letters, or numbers\n\t\t\tconst int base =\n\t\t\t\t(input[2] == 's') ? 1 :\n\t\t\t\t(input[2] == 'b') ? 2 :\n\t\t\t\t(input[2] == 'p') ? 3 :\n\t\t\t\t(input[2] == 'o') ? 8 :\n\t\t\t\t(input[2] == 'd') ? 10 :\n\t\t\t\t(input[2] == 'h') ? 16 :\n\t\t\t\t(input[2] == 'i') ? 32 : \/\/ ip address\n\t\t\t\t(input[2] == 'S') ? 80 : \/\/ syscall\n\t\t\t\t(int) r_num_math (core->num, input + 1);\n\t\t\tr_anal_hint_set_immbase (core->anal, core->offset, base);\n\t\t} else if (input[1] == '-') { \/\/ \"ahi-\"\n\t\t\tr_anal_hint_set_immbase (core->anal, core->offset, 0);\n\t\t} else {\n\t\t\teprintf (\"|ERROR| Usage: ahi [base]\\n\");\n\t\t}\n\t\tbreak;\n\tcase 'h': \/\/ \"ahh\"\n\t\tif (input[1] == '-') {\n\t\t\tr_anal_hint_unset_high (core->anal, core->offset);\n\t\t} else if (input[1] == ' ') {\n\t\t\tr_anal_hint_set_high (core->anal, r_num_math (core->num, input + 1));\n\t\t} else {\n\t\t\tr_anal_hint_set_high (core->anal, core->offset);\n\t\t}\n\t\tbreak;\n\tcase 'c': \/\/ \"ahc\"\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_jump (\n\t\t\t\tcore->anal, core->offset,\n\t\t\t\tr_num_math (core->num, input + 1));\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_jump (core->anal, core->offset);\n\t\t}\n\t\tbreak;\n\tcase 'f': \/\/ \"ahf\"\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_fail (\n\t\t\t\tcore->anal, core->offset,\n\t\t\t\tr_num_math (core->num, input + 1));\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_fail (core->anal, core->offset);\n\t\t}\n\t\tbreak;\n\tcase 's': \/\/ \"ahs\" set size (opcode length)\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_size (core->anal, core->offset, atoi (input + 1));\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_size (core->anal, core->offset);\n\t\t} else {\n\t\t\teprintf (\"Usage: ahs 16\\n\");\n\t\t}\n\t\tbreak;\n\tcase 'S': \/\/ \"ahS\" set size (opcode length)\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_syntax (core->anal, core->offset, input + 2);\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_syntax (core->anal, core->offset);\n\t\t} else {\n\t\t\teprintf (\"Usage: ahS att\\n\");\n\t\t}\n\t\tbreak;\n\tcase 'o': \/\/ \"aho\" set opcode string\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_opcode (core->anal, core->offset, input + 2);\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_opcode (core->anal, core->offset);\n\t\t} else {\n\t\t\teprintf (\"Usage: aho popall\\n\");\n\t\t}\n\t\tbreak;\n\tcase 'e': \/\/ \"ahe\" set ESIL string\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_esil (core->anal, core->offset, input + 2);\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_esil (core->anal, core->offset);\n\t\t} else {\n\t\t\teprintf (\"Usage: ahe r0,pc,=\\n\");\n\t\t}\n\t\tbreak;\n#if 0\n\tcase 'e': \/\/ set endian\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_opcode (core->anal, core->offset, atoi (input + 1));\n\t\t} else if (input[1] == '-') {\n\t\t\tr_anal_hint_unset_opcode (core->anal, core->offset);\n\t\t}\n\t\tbreak;\n#endif\n\tcase 'p': \/\/ \"ahp\"\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_pointer (core->anal, core->offset, r_num_math (core->num, input + 1));\n\t\t} else if (input[1] == '-') { \/\/ \"ahp-\"\n\t\t\tr_anal_hint_unset_pointer (core->anal, core->offset);\n\t\t}\n\t\tbreak;\n\tcase 'r': \/\/ \"ahr\"\n\t\tif (input[1] == ' ') {\n\t\t\tr_anal_hint_set_ret (core->anal, core->offset, r_num_math (core->num, input + 1));\n\t\t} else if (input[1] == '-') { \/\/ \"ahr-\"\n\t\t\tr_anal_hint_unset_ret (core->anal, core->offset);\n\t\t}\n\tcase '*': \/\/ \"ah*\"\n\t\tif (input[1] == ' ') {\n\t\t\tchar *ptr = strdup (r_str_trim_ro (input + 2));\n\t\t\tr_str_word_set0 (ptr);\n\t\t\tut64 addr = r_num_math (core->num, r_str_word_get0 (ptr, 0));\n\t\t\tr_core_anal_hint_print (core->anal, addr, '*');\n\t\t} else {\n\t\t\tr_core_anal_hint_list (core->anal, input[0]);\n\t\t}\n\t\tbreak;\n\tcase 'j': \/\/ \"ahj\"\n\tcase '\\0': \/\/ \"ah\"\n\t\tr_core_anal_hint_list (core->anal, input[0]);\n\t\tbreak;\n\tcase '-': \/\/ \"ah-\"\n\t\tif (input[1]) {\n\t\t\tif (input[1] == '*') {\n\t\t\t\tr_anal_hint_clear (core->anal);\n\t\t\t} else {\n\t\t\t\tchar *ptr = strdup (r_str_trim_ro (input + 1));\n\t\t\t\tut64 addr;\n\t\t\t\tint size = 1;\n\t\t\t\tint i = r_str_word_set0 (ptr);\n\t\t\t\tif (i == 2) {\n\t\t\t\t\tsize = r_num_math (core->num, r_str_word_get0 (ptr, 1));\n\t\t\t\t}\n\t\t\t\tconst char *a0 = r_str_word_get0 (ptr, 0);\n\t\t\t\tif (a0 && *a0) {\n\t\t\t\t\taddr = r_num_math (core->num, a0);\n\t\t\t\t} else {\n\t\t\t\t\taddr = core->offset;\n\t\t\t\t}\n\t\t\t\tr_anal_hint_del (core->anal, addr, size);\n\t\t\t\tfree (ptr);\n\t\t\t}\n\t\t} else {\n\t\t\tr_anal_hint_clear (core->anal);\n\t\t}\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":2058,"total_token_length":2294,"max_tokens_setting":4096}
+{"idx":324077,"func":"static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,\n\n                         Error **errp)\n\n{\n\n    BDRVQcow2State *s = bs->opaque;\n\n    unsigned int len, i;\n\n    int ret = 0;\n\n    QCowHeader header;\n\n    Error *local_err = NULL;\n\n    uint64_t ext_end;\n\n    uint64_t l1_vm_state_index;\n\n\n\n    ret = bdrv_pread(bs->file, 0, &header, sizeof(header));\n\n    if (ret < 0) {\n\n        error_setg_errno(errp, -ret, \"Could not read qcow2 header\");\n\n        goto fail;\n\n    }\n\n    be32_to_cpus(&header.magic);\n\n    be32_to_cpus(&header.version);\n\n    be64_to_cpus(&header.backing_file_offset);\n\n    be32_to_cpus(&header.backing_file_size);\n\n    be64_to_cpus(&header.size);\n\n    be32_to_cpus(&header.cluster_bits);\n\n    be32_to_cpus(&header.crypt_method);\n\n    be64_to_cpus(&header.l1_table_offset);\n\n    be32_to_cpus(&header.l1_size);\n\n    be64_to_cpus(&header.refcount_table_offset);\n\n    be32_to_cpus(&header.refcount_table_clusters);\n\n    be64_to_cpus(&header.snapshots_offset);\n\n    be32_to_cpus(&header.nb_snapshots);\n\n\n\n    if (header.magic != QCOW_MAGIC) {\n\n        error_setg(errp, \"Image is not in qcow2 format\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n    if (header.version < 2 || header.version > 3) {\n\n        error_setg(errp, \"Unsupported qcow2 version %\" PRIu32, header.version);\n\n        ret = -ENOTSUP;\n\n        goto fail;\n\n    }\n\n\n\n    s->qcow_version = header.version;\n\n\n\n    \/* Initialise cluster size *\/\n\n    if (header.cluster_bits < MIN_CLUSTER_BITS ||\n\n        header.cluster_bits > MAX_CLUSTER_BITS) {\n\n        error_setg(errp, \"Unsupported cluster size: 2^%\" PRIu32,\n\n                   header.cluster_bits);\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    s->cluster_bits = header.cluster_bits;\n\n    s->cluster_size = 1 << s->cluster_bits;\n\n    s->cluster_sectors = 1 << (s->cluster_bits - 9);\n\n\n\n    \/* Initialise version 3 header fields *\/\n\n    if (header.version == 2) {\n\n        header.incompatible_features    = 0;\n\n        header.compatible_features      = 0;\n\n        header.autoclear_features       = 0;\n\n        header.refcount_order           = 4;\n\n        header.header_length            = 72;\n\n    } else {\n\n        be64_to_cpus(&header.incompatible_features);\n\n        be64_to_cpus(&header.compatible_features);\n\n        be64_to_cpus(&header.autoclear_features);\n\n        be32_to_cpus(&header.refcount_order);\n\n        be32_to_cpus(&header.header_length);\n\n\n\n        if (header.header_length < 104) {\n\n            error_setg(errp, \"qcow2 header too short\");\n\n            ret = -EINVAL;\n\n            goto fail;\n\n        }\n\n    }\n\n\n\n    if (header.header_length > s->cluster_size) {\n\n        error_setg(errp, \"qcow2 header exceeds cluster size\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    if (header.header_length > sizeof(header)) {\n\n        s->unknown_header_fields_size = header.header_length - sizeof(header);\n\n        s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);\n\n        ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,\n\n                         s->unknown_header_fields_size);\n\n        if (ret < 0) {\n\n            error_setg_errno(errp, -ret, \"Could not read unknown qcow2 header \"\n\n                             \"fields\");\n\n            goto fail;\n\n        }\n\n    }\n\n\n\n    if (header.backing_file_offset > s->cluster_size) {\n\n        error_setg(errp, \"Invalid backing file offset\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    if (header.backing_file_offset) {\n\n        ext_end = header.backing_file_offset;\n\n    } else {\n\n        ext_end = 1 << header.cluster_bits;\n\n    }\n\n\n\n    \/* Handle feature bits *\/\n\n    s->incompatible_features    = header.incompatible_features;\n\n    s->compatible_features      = header.compatible_features;\n\n    s->autoclear_features       = header.autoclear_features;\n\n\n\n    if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {\n\n        void *feature_table = NULL;\n\n        qcow2_read_extensions(bs, header.header_length, ext_end,\n\n                              &feature_table, NULL);\n\n        report_unsupported_feature(errp, feature_table,\n\n                                   s->incompatible_features &\n\n                                   ~QCOW2_INCOMPAT_MASK);\n\n        ret = -ENOTSUP;\n\n        g_free(feature_table);\n\n        goto fail;\n\n    }\n\n\n\n    if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {\n\n        \/* Corrupt images may not be written to unless they are being repaired\n\n         *\/\n\n        if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {\n\n            error_setg(errp, \"qcow2: Image is corrupt; cannot be opened \"\n\n                       \"read\/write\");\n\n            ret = -EACCES;\n\n            goto fail;\n\n        }\n\n    }\n\n\n\n    \/* Check support for various header values *\/\n\n    if (header.refcount_order > 6) {\n\n        error_setg(errp, \"Reference count entry width too large; may not \"\n\n                   \"exceed 64 bits\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n    s->refcount_order = header.refcount_order;\n\n    s->refcount_bits = 1 << s->refcount_order;\n\n    s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);\n\n    s->refcount_max += s->refcount_max - 1;\n\n\n\n    if (header.crypt_method > QCOW_CRYPT_AES) {\n\n        error_setg(errp, \"Unsupported encryption method: %\" PRIu32,\n\n                   header.crypt_method);\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n    if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,\n\n                                 QCRYPTO_CIPHER_MODE_CBC)) {\n\n        error_setg(errp, \"AES cipher not available\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n    s->crypt_method_header = header.crypt_method;\n\n    if (s->crypt_method_header) {\n\n        if (bdrv_uses_whitelist() &&\n\n            s->crypt_method_header == QCOW_CRYPT_AES) {\n\n            error_setg(errp,\n\n                       \"Use of AES-CBC encrypted qcow2 images is no longer \"\n\n                       \"supported in system emulators\");\n\n            error_append_hint(errp,\n\n                              \"You can use 'qemu-img convert' to convert your \"\n\n                              \"image to an alternative supported format, such \"\n\n                              \"as unencrypted qcow2, or raw with the LUKS \"\n\n                              \"format instead.\\n\");\n\n            ret = -ENOSYS;\n\n            goto fail;\n\n        }\n\n\n\n        bs->encrypted = true;\n\n    }\n\n\n\n    s->l2_bits = s->cluster_bits - 3; \/* L2 is always one cluster *\/\n\n    s->l2_size = 1 << s->l2_bits;\n\n    \/* 2^(s->refcount_order - 3) is the refcount width in bytes *\/\n\n    s->refcount_block_bits = s->cluster_bits - (s->refcount_order - 3);\n\n    s->refcount_block_size = 1 << s->refcount_block_bits;\n\n    bs->total_sectors = header.size \/ 512;\n\n    s->csize_shift = (62 - (s->cluster_bits - 8));\n\n    s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;\n\n    s->cluster_offset_mask = (1LL << s->csize_shift) - 1;\n\n\n\n    s->refcount_table_offset = header.refcount_table_offset;\n\n    s->refcount_table_size =\n\n        header.refcount_table_clusters << (s->cluster_bits - 3);\n\n\n\n    if (header.refcount_table_clusters > qcow2_max_refcount_clusters(s)) {\n\n        error_setg(errp, \"Reference count table too large\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    ret = validate_table_offset(bs, s->refcount_table_offset,\n\n                                s->refcount_table_size, sizeof(uint64_t));\n\n    if (ret < 0) {\n\n        error_setg(errp, \"Invalid reference count table offset\");\n\n        goto fail;\n\n    }\n\n\n\n    \/* Snapshot table offset\/length *\/\n\n    if (header.nb_snapshots > QCOW_MAX_SNAPSHOTS) {\n\n        error_setg(errp, \"Too many snapshots\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    ret = validate_table_offset(bs, header.snapshots_offset,\n\n                                header.nb_snapshots,\n\n                                sizeof(QCowSnapshotHeader));\n\n    if (ret < 0) {\n\n        error_setg(errp, \"Invalid snapshot table offset\");\n\n        goto fail;\n\n    }\n\n\n\n    \/* read the level 1 table *\/\n\n    if (header.l1_size > QCOW_MAX_L1_SIZE \/ sizeof(uint64_t)) {\n\n        error_setg(errp, \"Active L1 table too large\");\n\n        ret = -EFBIG;\n\n        goto fail;\n\n    }\n\n    s->l1_size = header.l1_size;\n\n\n\n    l1_vm_state_index = size_to_l1(s, header.size);\n\n    if (l1_vm_state_index > INT_MAX) {\n\n        error_setg(errp, \"Image is too big\");\n\n        ret = -EFBIG;\n\n        goto fail;\n\n    }\n\n    s->l1_vm_state_index = l1_vm_state_index;\n\n\n\n    \/* the L1 table must contain at least enough entries to put\n\n       header.size bytes *\/\n\n    if (s->l1_size < s->l1_vm_state_index) {\n\n        error_setg(errp, \"L1 table is too small\");\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    ret = validate_table_offset(bs, header.l1_table_offset,\n\n                                header.l1_size, sizeof(uint64_t));\n\n    if (ret < 0) {\n\n        error_setg(errp, \"Invalid L1 table offset\");\n\n        goto fail;\n\n    }\n\n    s->l1_table_offset = header.l1_table_offset;\n\n\n\n\n\n    if (s->l1_size > 0) {\n\n        s->l1_table = qemu_try_blockalign(bs->file->bs,\n\n            align_offset(s->l1_size * sizeof(uint64_t), 512));\n\n        if (s->l1_table == NULL) {\n\n            error_setg(errp, \"Could not allocate L1 table\");\n\n            ret = -ENOMEM;\n\n            goto fail;\n\n        }\n\n        ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,\n\n                         s->l1_size * sizeof(uint64_t));\n\n        if (ret < 0) {\n\n            error_setg_errno(errp, -ret, \"Could not read L1 table\");\n\n            goto fail;\n\n        }\n\n        for(i = 0;i < s->l1_size; i++) {\n\n            be64_to_cpus(&s->l1_table[i]);\n\n        }\n\n    }\n\n\n\n    \/* Parse driver-specific options *\/\n\n    ret = qcow2_update_options(bs, options, flags, errp);\n\n    if (ret < 0) {\n\n        goto fail;\n\n    }\n\n\n\n    s->cluster_cache = g_malloc(s->cluster_size);\n\n    \/* one more sector for decompressed data alignment *\/\n\n    s->cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS\n\n                                                    * s->cluster_size + 512);\n\n    if (s->cluster_data == NULL) {\n\n        error_setg(errp, \"Could not allocate temporary cluster buffer\");\n\n        ret = -ENOMEM;\n\n        goto fail;\n\n    }\n\n\n\n    s->cluster_cache_offset = -1;\n\n    s->flags = flags;\n\n\n\n    ret = qcow2_refcount_init(bs);\n\n    if (ret != 0) {\n\n        error_setg_errno(errp, -ret, \"Could not initialize refcount handling\");\n\n        goto fail;\n\n    }\n\n\n\n    QLIST_INIT(&s->cluster_allocs);\n\n    QTAILQ_INIT(&s->discards);\n\n\n\n    \/* read qcow2 extensions *\/\n\n    if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,\n\n        &local_err)) {\n\n        error_propagate(errp, local_err);\n\n        ret = -EINVAL;\n\n        goto fail;\n\n    }\n\n\n\n    \/* read the backing file name *\/\n\n    if (header.backing_file_offset != 0) {\n\n        len = header.backing_file_size;\n\n        if (len > MIN(1023, s->cluster_size - header.backing_file_offset) ||\n\n            len >= sizeof(bs->backing_file)) {\n\n            error_setg(errp, \"Backing file name too long\");\n\n            ret = -EINVAL;\n\n            goto fail;\n\n        }\n\n        ret = bdrv_pread(bs->file, header.backing_file_offset,\n\n                         bs->backing_file, len);\n\n        if (ret < 0) {\n\n            error_setg_errno(errp, -ret, \"Could not read backing file name\");\n\n            goto fail;\n\n        }\n\n        bs->backing_file[len] = '\\0';\n\n        s->image_backing_file = g_strdup(bs->backing_file);\n\n    }\n\n\n\n    \/* Internal snapshots *\/\n\n    s->snapshots_offset = header.snapshots_offset;\n\n    s->nb_snapshots = header.nb_snapshots;\n\n\n\n    ret = qcow2_read_snapshots(bs);\n\n    if (ret < 0) {\n\n        error_setg_errno(errp, -ret, \"Could not read snapshots\");\n\n        goto fail;\n\n    }\n\n\n\n    \/* Clear unknown autoclear feature bits *\/\n\n    if (!bs->read_only && !(flags & BDRV_O_INACTIVE) && s->autoclear_features) {\n\n        s->autoclear_features = 0;\n\n        ret = qcow2_update_header(bs);\n\n        if (ret < 0) {\n\n            error_setg_errno(errp, -ret, \"Could not update qcow2 header\");\n\n            goto fail;\n\n        }\n\n    }\n\n\n\n    \/* Initialise locks *\/\n\n    qemu_co_mutex_init(&s->lock);\n\n    bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;\n\n\n\n    \/* Repair image if dirty *\/\n\n    if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only &&\n\n        (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {\n\n        BdrvCheckResult result = {0};\n\n\n\n        ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS | BDRV_FIX_LEAKS);\n\n        if (ret < 0) {\n\n            error_setg_errno(errp, -ret, \"Could not repair dirty image\");\n\n            goto fail;\n\n        }\n\n    }\n\n\n\n#ifdef DEBUG_ALLOC\n\n    {\n\n        BdrvCheckResult result = {0};\n\n        qcow2_check_refcounts(bs, &result, 0);\n\n    }\n\n#endif\n\n    return ret;\n\n\n\n fail:\n\n    g_free(s->unknown_header_fields);\n\n    cleanup_unknown_header_ext(bs);\n\n    qcow2_free_snapshots(bs);\n\n    qcow2_refcount_close(bs);\n\n    qemu_vfree(s->l1_table);\n\n    \/* else pre-write overlap checks in cache_destroy may crash *\/\n\n    s->l1_table = NULL;\n\n    cache_clean_timer_del(bs);\n\n    if (s->l2_table_cache) {\n\n        qcow2_cache_destroy(bs, s->l2_table_cache);\n\n    }\n\n    if (s->refcount_block_cache) {\n\n        qcow2_cache_destroy(bs, s->refcount_block_cache);\n\n    }\n\n    g_free(s->cluster_cache);\n\n    qemu_vfree(s->cluster_data);\n\n    return ret;\n\n}\n","target":0,"code_token_length":3411,"total_token_length":3647,"max_tokens_setting":4096}
+{"idx":436883,"func":"static int fts3InitVtab(\n  int isCreate,                   \/* True for xCreate, false for xConnect *\/\n  sqlite3 *db,                    \/* The SQLite database connection *\/\n  void *pAux,                     \/* Hash table containing tokenizers *\/\n  int argc,                       \/* Number of elements in argv array *\/\n  const char * const *argv,       \/* xCreate\/xConnect argument array *\/\n  sqlite3_vtab **ppVTab,          \/* Write the resulting vtab structure here *\/\n  char **pzErr                    \/* Write any error message here *\/\n){\n  Fts3Hash *pHash = (Fts3Hash *)pAux;\n  Fts3Table *p = 0;               \/* Pointer to allocated vtab *\/\n  int rc = SQLITE_OK;             \/* Return code *\/\n  int i;                          \/* Iterator variable *\/\n  sqlite3_int64 nByte;            \/* Size of allocation used for *p *\/\n  int iCol;                       \/* Column index *\/\n  int nString = 0;                \/* Bytes required to hold all column names *\/\n  int nCol = 0;                   \/* Number of columns in the FTS table *\/\n  char *zCsr;                     \/* Space for holding column names *\/\n  int nDb;                        \/* Bytes required to hold database name *\/\n  int nName;                      \/* Bytes required to hold table name *\/\n  int isFts4 = (argv[0][3]=='4'); \/* True for FTS4, false for FTS3 *\/\n  const char **aCol;              \/* Array of column names *\/\n  sqlite3_tokenizer *pTokenizer = 0;        \/* Tokenizer for this table *\/\n\n  int nIndex = 0;                 \/* Size of aIndex[] array *\/\n  struct Fts3Index *aIndex = 0;   \/* Array of indexes for this table *\/\n\n  \/* The results of parsing supported FTS4 key=value options: *\/\n  int bNoDocsize = 0;             \/* True to omit %_docsize table *\/\n  int bDescIdx = 0;               \/* True to store descending indexes *\/\n  char *zPrefix = 0;              \/* Prefix parameter value (or NULL) *\/\n  char *zCompress = 0;            \/* compress=? parameter (or NULL) *\/\n  char *zUncompress = 0;          \/* uncompress=? parameter (or NULL) *\/\n  char *zContent = 0;             \/* content=? parameter (or NULL) *\/\n  char *zLanguageid = 0;          \/* languageid=? parameter (or NULL) *\/\n  char **azNotindexed = 0;        \/* The set of notindexed= columns *\/\n  int nNotindexed = 0;            \/* Size of azNotindexed[] array *\/\n\n  assert( strlen(argv[0])==4 );\n  assert( (sqlite3_strnicmp(argv[0], \"fts4\", 4)==0 && isFts4)\n       || (sqlite3_strnicmp(argv[0], \"fts3\", 4)==0 && !isFts4)\n  );\n\n  nDb = (int)strlen(argv[1]) + 1;\n  nName = (int)strlen(argv[2]) + 1;\n\n  nByte = sizeof(const char *) * (argc-2);\n  aCol = (const char **)sqlite3_malloc64(nByte);\n  if( aCol ){\n    memset((void*)aCol, 0, nByte);\n    azNotindexed = (char **)sqlite3_malloc64(nByte);\n  }\n  if( azNotindexed ){\n    memset(azNotindexed, 0, nByte);\n  }\n  if( !aCol || !azNotindexed ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n\n  \/* Loop through all of the arguments passed by the user to the FTS3\/4\n  ** module (i.e. all the column names and special arguments). This loop\n  ** does the following:\n  **\n  **   + Figures out the number of columns the FTSX table will have, and\n  **     the number of bytes of space that must be allocated to store copies\n  **     of the column names.\n  **\n  **   + If there is a tokenizer specification included in the arguments,\n  **     initializes the tokenizer pTokenizer.\n  *\/\n  for(i=3; rc==SQLITE_OK && i8\n     && 0==sqlite3_strnicmp(z, \"tokenize\", 8) \n     && 0==sqlite3Fts3IsIdChar(z[8])\n    ){\n      rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr);\n    }\n\n    \/* Check if it is an FTS4 special argument. *\/\n    else if( isFts4 && fts3IsSpecialColumn(z, &nKey, &zVal) ){\n      struct Fts4Option {\n        const char *zOpt;\n        int nOpt;\n      } aFts4Opt[] = {\n        { \"matchinfo\",   9 },     \/* 0 -> MATCHINFO *\/\n        { \"prefix\",      6 },     \/* 1 -> PREFIX *\/\n        { \"compress\",    8 },     \/* 2 -> COMPRESS *\/\n        { \"uncompress\", 10 },     \/* 3 -> UNCOMPRESS *\/\n        { \"order\",       5 },     \/* 4 -> ORDER *\/\n        { \"content\",     7 },     \/* 5 -> CONTENT *\/\n        { \"languageid\", 10 },     \/* 6 -> LANGUAGEID *\/\n        { \"notindexed\", 10 }      \/* 7 -> NOTINDEXED *\/\n      };\n\n      int iOpt;\n      if( !zVal ){\n        rc = SQLITE_NOMEM;\n      }else{\n        for(iOpt=0; iOptnOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){\n            break;\n          }\n        }\n        switch( iOpt ){\n          case 0:               \/* MATCHINFO *\/\n            if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"fts3\", 4) ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bNoDocsize = 1;\n            break;\n\n          case 1:               \/* PREFIX *\/\n            sqlite3_free(zPrefix);\n            zPrefix = zVal;\n            zVal = 0;\n            break;\n\n          case 2:               \/* COMPRESS *\/\n            sqlite3_free(zCompress);\n            zCompress = zVal;\n            zVal = 0;\n            break;\n\n          case 3:               \/* UNCOMPRESS *\/\n            sqlite3_free(zUncompress);\n            zUncompress = zVal;\n            zVal = 0;\n            break;\n\n          case 4:               \/* ORDER *\/\n            if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, \"asc\", 3)) \n             && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"desc\", 4)) \n            ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized order: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bDescIdx = (zVal[0]=='d' || zVal[0]=='D');\n            break;\n\n          case 5:              \/* CONTENT *\/\n            sqlite3_free(zContent);\n            zContent = zVal;\n            zVal = 0;\n            break;\n\n          case 6:              \/* LANGUAGEID *\/\n            assert( iOpt==6 );\n            sqlite3_free(zLanguageid);\n            zLanguageid = zVal;\n            zVal = 0;\n            break;\n\n          case 7:              \/* NOTINDEXED *\/\n            azNotindexed[nNotindexed++] = zVal;\n            zVal = 0;\n            break;\n\n          default:\n            assert( iOpt==SizeofArray(aFts4Opt) );\n            sqlite3Fts3ErrMsg(pzErr, \"unrecognized parameter: %s\", z);\n            rc = SQLITE_ERROR;\n            break;\n        }\n        sqlite3_free(zVal);\n      }\n    }\n\n    \/* Otherwise, the argument is a column name. *\/\n    else {\n      nString += (int)(strlen(z) + 1);\n      aCol[nCol++] = z;\n    }\n  }\n\n  \/* If a content=xxx option was specified, the following:\n  **\n  **   1. Ignore any compress= and uncompress= options.\n  **\n  **   2. If no column names were specified as part of the CREATE VIRTUAL\n  **      TABLE statement, use all columns from the content table.\n  *\/\n  if( rc==SQLITE_OK && zContent ){\n    sqlite3_free(zCompress); \n    sqlite3_free(zUncompress); \n    zCompress = 0;\n    zUncompress = 0;\n    if( nCol==0 ){\n      sqlite3_free((void*)aCol); \n      aCol = 0;\n      rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);\n\n      \/* If a languageid= option was specified, remove the language id\n      ** column from the aCol[] array. *\/ \n      if( rc==SQLITE_OK && zLanguageid ){\n        int j;\n        for(j=0; jdb = db;\n  p->nColumn = nCol;\n  p->nPendingData = 0;\n  p->azColumn = (char **)&p[1];\n  p->pTokenizer = pTokenizer;\n  p->nMaxPendingData = FTS3_MAX_PENDING_DATA;\n  p->bHasDocsize = (isFts4 && bNoDocsize==0);\n  p->bHasStat = (u8)isFts4;\n  p->bFts4 = (u8)isFts4;\n  p->bDescIdx = (u8)bDescIdx;\n  p->nAutoincrmerge = 0xff;   \/* 0xff means setting unknown *\/\n  p->zContentTbl = zContent;\n  p->zLanguageid = zLanguageid;\n  zContent = 0;\n  zLanguageid = 0;\n  TESTONLY( p->inTransaction = -1 );\n  TESTONLY( p->mxSavepoint = -1 );\n\n  p->aIndex = (struct Fts3Index *)&p->azColumn[nCol];\n  memcpy(p->aIndex, aIndex, sizeof(struct Fts3Index) * nIndex);\n  p->nIndex = nIndex;\n  for(i=0; iaIndex[i].hPending, FTS3_HASH_STRING, 1);\n  }\n  p->abNotindexed = (u8 *)&p->aIndex[nIndex];\n\n  \/* Fill in the zName and zDb fields of the vtab structure. *\/\n  zCsr = (char *)&p->abNotindexed[nCol];\n  p->zName = zCsr;\n  memcpy(zCsr, argv[2], nName);\n  zCsr += nName;\n  p->zDb = zCsr;\n  memcpy(zCsr, argv[1], nDb);\n  zCsr += nDb;\n\n  \/* Fill in the azColumn array *\/\n  for(iCol=0; iCol0 ){\n      memcpy(zCsr, z, n);\n    }\n    zCsr[n] = '\\0';\n    sqlite3Fts3Dequote(zCsr);\n    p->azColumn[iCol] = zCsr;\n    zCsr += n+1;\n    assert( zCsr <= &((char *)p)[nByte] );\n  }\n\n  \/* Fill in the abNotindexed array *\/\n  for(iCol=0; iColazColumn[iCol]);\n    for(i=0; iazColumn[iCol], zNot, n) \n      ){\n        p->abNotindexed[iCol] = 1;\n        sqlite3_free(zNot);\n        azNotindexed[i] = 0;\n      }\n    }\n  }\n  for(i=0; izReadExprlist = fts3ReadExprList(p, zUncompress, &rc);\n  p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  \/* If this is an xCreate call, create the underlying tables in the \n  ** database. TODO: For xConnect(), it could verify that said tables exist.\n  *\/\n  if( isCreate ){\n    rc = fts3CreateTables(p);\n  }\n\n  \/* Check to see if a legacy fts3 table has been \"upgraded\" by the\n  ** addition of a %_stat table so that it can use incremental merge.\n  *\/\n  if( !isFts4 && !isCreate ){\n    p->bHasStat = 2;\n  }\n\n  \/* Figure out the page-size for the database. This is required in order to\n  ** estimate the cost of loading large doclists from the database.  *\/\n  fts3DatabasePageSize(&rc, p);\n  p->nNodeSize = p->nPgsz-35;\n\n#if defined(SQLITE_DEBUG)||defined(SQLITE_TEST)\n  p->nMergeCount = FTS3_MERGE_COUNT;\n#endif\n\n  \/* Declare the table schema to SQLite. *\/\n  fts3DeclareVtab(&rc, p);\n\nfts3_init_out:\n  sqlite3_free(zPrefix);\n  sqlite3_free(aIndex);\n  sqlite3_free(zCompress);\n  sqlite3_free(zUncompress);\n  sqlite3_free(zContent);\n  sqlite3_free(zLanguageid);\n  for(i=0; ipModule->xDestroy(pTokenizer);\n    }\n  }else{\n    assert( p->pSegments==0 );\n    *ppVTab = &p->base;\n  }\n  return rc;\n}","target":0,"code_token_length":3800,"total_token_length":4036,"max_tokens_setting":4096}
+{"idx":5660,"func":"composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)\n{\n\tstruct usb_composite_dev\t*cdev = get_gadget_data(gadget);\n\tstruct usb_request\t\t*req = cdev->req;\n\tint\t\t\t\tvalue = -EOPNOTSUPP;\n\tint\t\t\t\tstatus = 0;\n\tu16\t\t\t\tw_index = le16_to_cpu(ctrl->wIndex);\n\tu8\t\t\t\tintf = w_index & 0xFF;\n\tu16\t\t\t\tw_value = le16_to_cpu(ctrl->wValue);\n\tu16\t\t\t\tw_length = le16_to_cpu(ctrl->wLength);\n\tstruct usb_function\t\t*f = NULL;\n\tu8\t\t\t\tendp;\n\n\tif (w_length > USB_COMP_EP0_BUFSIZ) {\n\t\tif (ctrl->bRequestType & USB_DIR_IN) {\n\t\t\t\/* Cast away the const, we are going to overwrite on purpose. *\/\n\t\t\t__le16 *temp = (__le16 *)&ctrl->wLength;\n\n\t\t\t*temp = cpu_to_le16(USB_COMP_EP0_BUFSIZ);\n\t\t\tw_length = USB_COMP_EP0_BUFSIZ;\n\t\t} else {\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\t\/* partial re-init of the response message; the function or the\n\t * gadget might need to intercept e.g. a control-OUT completion\n\t * when we delegate to it.\n\t *\/\n\treq->zero = 0;\n\treq->context = cdev;\n\treq->complete = composite_setup_complete;\n\treq->length = 0;\n\tgadget->ep0->driver_data = cdev;\n\n\t\/*\n\t * Don't let non-standard requests match any of the cases below\n\t * by accident.\n\t *\/\n\tif ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)\n\t\tgoto unknown;\n\n\tswitch (ctrl->bRequest) {\n\n\t\/* we handle all standard USB descriptors *\/\n\tcase USB_REQ_GET_DESCRIPTOR:\n\t\tif (ctrl->bRequestType != USB_DIR_IN)\n\t\t\tgoto unknown;\n\t\tswitch (w_value >> 8) {\n\n\t\tcase USB_DT_DEVICE:\n\t\t\tcdev->desc.bNumConfigurations =\n\t\t\t\tcount_configs(cdev, USB_DT_DEVICE);\n\t\t\tcdev->desc.bMaxPacketSize0 =\n\t\t\t\tcdev->gadget->ep0->maxpacket;\n\t\t\tif (gadget_is_superspeed(gadget)) {\n\t\t\t\tif (gadget->speed >= USB_SPEED_SUPER) {\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0320);\n\t\t\t\t\tcdev->desc.bMaxPacketSize0 = 9;\n\t\t\t\t} else {\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0210);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (gadget->lpm_capable)\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0201);\n\t\t\t\telse\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0200);\n\t\t\t}\n\n\t\t\tvalue = min(w_length, (u16) sizeof cdev->desc);\n\t\t\tmemcpy(req->buf, &cdev->desc, value);\n\t\t\tbreak;\n\t\tcase USB_DT_DEVICE_QUALIFIER:\n\t\t\tif (!gadget_is_dualspeed(gadget) ||\n\t\t\t    gadget->speed >= USB_SPEED_SUPER)\n\t\t\t\tbreak;\n\t\t\tdevice_qual(cdev);\n\t\t\tvalue = min_t(int, w_length,\n\t\t\t\tsizeof(struct usb_qualifier_descriptor));\n\t\t\tbreak;\n\t\tcase USB_DT_OTHER_SPEED_CONFIG:\n\t\t\tif (!gadget_is_dualspeed(gadget) ||\n\t\t\t    gadget->speed >= USB_SPEED_SUPER)\n\t\t\t\tbreak;\n\t\t\tfallthrough;\n\t\tcase USB_DT_CONFIG:\n\t\t\tvalue = config_desc(cdev, w_value);\n\t\t\tif (value >= 0)\n\t\t\t\tvalue = min(w_length, (u16) value);\n\t\t\tbreak;\n\t\tcase USB_DT_STRING:\n\t\t\tvalue = get_string(cdev, req->buf,\n\t\t\t\t\tw_index, w_value & 0xff);\n\t\t\tif (value >= 0)\n\t\t\t\tvalue = min(w_length, (u16) value);\n\t\t\tbreak;\n\t\tcase USB_DT_BOS:\n\t\t\tif (gadget_is_superspeed(gadget) ||\n\t\t\t    gadget->lpm_capable) {\n\t\t\t\tvalue = bos_desc(cdev);\n\t\t\t\tvalue = min(w_length, (u16) value);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase USB_DT_OTG:\n\t\t\tif (gadget_is_otg(gadget)) {\n\t\t\t\tstruct usb_configuration *config;\n\t\t\t\tint otg_desc_len = 0;\n\n\t\t\t\tif (cdev->config)\n\t\t\t\t\tconfig = cdev->config;\n\t\t\t\telse\n\t\t\t\t\tconfig = list_first_entry(\n\t\t\t\t\t\t\t&cdev->configs,\n\t\t\t\t\t\tstruct usb_configuration, list);\n\t\t\t\tif (!config)\n\t\t\t\t\tgoto done;\n\n\t\t\t\tif (gadget->otg_caps &&\n\t\t\t\t\t(gadget->otg_caps->otg_rev >= 0x0200))\n\t\t\t\t\totg_desc_len += sizeof(\n\t\t\t\t\t\tstruct usb_otg20_descriptor);\n\t\t\t\telse\n\t\t\t\t\totg_desc_len += sizeof(\n\t\t\t\t\t\tstruct usb_otg_descriptor);\n\n\t\t\t\tvalue = min_t(int, w_length, otg_desc_len);\n\t\t\t\tmemcpy(req->buf, config->descriptors[0], value);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\t\/* any number of configs can work *\/\n\tcase USB_REQ_SET_CONFIGURATION:\n\t\tif (ctrl->bRequestType != 0)\n\t\t\tgoto unknown;\n\t\tif (gadget_is_otg(gadget)) {\n\t\t\tif (gadget->a_hnp_support)\n\t\t\t\tDBG(cdev, \"HNP available\\n\");\n\t\t\telse if (gadget->a_alt_hnp_support)\n\t\t\t\tDBG(cdev, \"HNP on another port\\n\");\n\t\t\telse\n\t\t\t\tVDBG(cdev, \"HNP inactive\\n\");\n\t\t}\n\t\tspin_lock(&cdev->lock);\n\t\tvalue = set_config(cdev, ctrl, w_value);\n\t\tspin_unlock(&cdev->lock);\n\t\tbreak;\n\tcase USB_REQ_GET_CONFIGURATION:\n\t\tif (ctrl->bRequestType != USB_DIR_IN)\n\t\t\tgoto unknown;\n\t\tif (cdev->config)\n\t\t\t*(u8 *)req->buf = cdev->config->bConfigurationValue;\n\t\telse\n\t\t\t*(u8 *)req->buf = 0;\n\t\tvalue = min(w_length, (u16) 1);\n\t\tbreak;\n\n\t\/* function drivers must handle get\/set altsetting *\/\n\tcase USB_REQ_SET_INTERFACE:\n\t\tif (ctrl->bRequestType != USB_RECIP_INTERFACE)\n\t\t\tgoto unknown;\n\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\tbreak;\n\t\tf = cdev->config->interface[intf];\n\t\tif (!f)\n\t\t\tbreak;\n\n\t\t\/*\n\t\t * If there's no get_alt() method, we know only altsetting zero\n\t\t * works. There is no need to check if set_alt() is not NULL\n\t\t * as we check this in usb_add_function().\n\t\t *\/\n\t\tif (w_value && !f->get_alt)\n\t\t\tbreak;\n\n\t\tspin_lock(&cdev->lock);\n\t\tvalue = f->set_alt(f, w_index, w_value);\n\t\tif (value == USB_GADGET_DELAYED_STATUS) {\n\t\t\tDBG(cdev,\n\t\t\t \"%s: interface %d (%s) requested delayed status\\n\",\n\t\t\t\t\t__func__, intf, f->name);\n\t\t\tcdev->delayed_status++;\n\t\t\tDBG(cdev, \"delayed_status count %d\\n\",\n\t\t\t\t\tcdev->delayed_status);\n\t\t}\n\t\tspin_unlock(&cdev->lock);\n\t\tbreak;\n\tcase USB_REQ_GET_INTERFACE:\n\t\tif (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))\n\t\t\tgoto unknown;\n\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\tbreak;\n\t\tf = cdev->config->interface[intf];\n\t\tif (!f)\n\t\t\tbreak;\n\t\t\/* lots of interfaces only need altsetting zero... *\/\n\t\tvalue = f->get_alt ? f->get_alt(f, w_index) : 0;\n\t\tif (value < 0)\n\t\t\tbreak;\n\t\t*((u8 *)req->buf) = value;\n\t\tvalue = min(w_length, (u16) 1);\n\t\tbreak;\n\tcase USB_REQ_GET_STATUS:\n\t\tif (gadget_is_otg(gadget) && gadget->hnp_polling_support &&\n\t\t\t\t\t\t(w_index == OTG_STS_SELECTOR)) {\n\t\t\tif (ctrl->bRequestType != (USB_DIR_IN |\n\t\t\t\t\t\t\tUSB_RECIP_DEVICE))\n\t\t\t\tgoto unknown;\n\t\t\t*((u8 *)req->buf) = gadget->host_request_flag;\n\t\t\tvalue = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * USB 3.0 additions:\n\t\t * Function driver should handle get_status request. If such cb\n\t\t * wasn't supplied we respond with default value = 0\n\t\t * Note: function driver should supply such cb only for the\n\t\t * first interface of the function\n\t\t *\/\n\t\tif (!gadget_is_superspeed(gadget))\n\t\t\tgoto unknown;\n\t\tif (ctrl->bRequestType != (USB_DIR_IN | USB_RECIP_INTERFACE))\n\t\t\tgoto unknown;\n\t\tvalue = 2;\t\/* This is the length of the get_status reply *\/\n\t\tput_unaligned_le16(0, req->buf);\n\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\tbreak;\n\t\tf = cdev->config->interface[intf];\n\t\tif (!f)\n\t\t\tbreak;\n\t\tstatus = f->get_status ? f->get_status(f) : 0;\n\t\tif (status < 0)\n\t\t\tbreak;\n\t\tput_unaligned_le16(status & 0x0000ffff, req->buf);\n\t\tbreak;\n\t\/*\n\t * Function drivers should handle SetFeature\/ClearFeature\n\t * (FUNCTION_SUSPEND) request. function_suspend cb should be supplied\n\t * only for the first interface of the function\n\t *\/\n\tcase USB_REQ_CLEAR_FEATURE:\n\tcase USB_REQ_SET_FEATURE:\n\t\tif (!gadget_is_superspeed(gadget))\n\t\t\tgoto unknown;\n\t\tif (ctrl->bRequestType != (USB_DIR_OUT | USB_RECIP_INTERFACE))\n\t\t\tgoto unknown;\n\t\tswitch (w_value) {\n\t\tcase USB_INTRF_FUNC_SUSPEND:\n\t\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\t\tbreak;\n\t\t\tf = cdev->config->interface[intf];\n\t\t\tif (!f)\n\t\t\t\tbreak;\n\t\t\tvalue = 0;\n\t\t\tif (f->func_suspend)\n\t\t\t\tvalue = f->func_suspend(f, w_index >> 8);\n\t\t\tif (value < 0) {\n\t\t\t\tERROR(cdev,\n\t\t\t\t      \"func_suspend() returned error %d\\n\",\n\t\t\t\t      value);\n\t\t\t\tvalue = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tdefault:\nunknown:\n\t\t\/*\n\t\t * OS descriptors handling\n\t\t *\/\n\t\tif (cdev->use_os_string && cdev->os_desc_config &&\n\t\t    (ctrl->bRequestType & USB_TYPE_VENDOR) &&\n\t\t    ctrl->bRequest == cdev->b_vendor_code) {\n\t\t\tstruct usb_configuration\t*os_desc_cfg;\n\t\t\tu8\t\t\t\t*buf;\n\t\t\tint\t\t\t\tinterface;\n\t\t\tint\t\t\t\tcount = 0;\n\n\t\t\treq = cdev->os_desc_req;\n\t\t\treq->context = cdev;\n\t\t\treq->complete = composite_setup_complete;\n\t\t\tbuf = req->buf;\n\t\t\tos_desc_cfg = cdev->os_desc_config;\n\t\t\tw_length = min_t(u16, w_length, USB_COMP_EP0_OS_DESC_BUFSIZ);\n\t\t\tmemset(buf, 0, w_length);\n\t\t\tbuf[5] = 0x01;\n\t\t\tswitch (ctrl->bRequestType & USB_RECIP_MASK) {\n\t\t\tcase USB_RECIP_DEVICE:\n\t\t\t\tif (w_index != 0x4 || (w_value >> 8))\n\t\t\t\t\tbreak;\n\t\t\t\tbuf[6] = w_index;\n\t\t\t\t\/* Number of ext compat interfaces *\/\n\t\t\t\tcount = count_ext_compat(os_desc_cfg);\n\t\t\t\tbuf[8] = count;\n\t\t\t\tcount *= 24; \/* 24 B\/ext compat desc *\/\n\t\t\t\tcount += 16; \/* header *\/\n\t\t\t\tput_unaligned_le32(count, buf);\n\t\t\t\tvalue = w_length;\n\t\t\t\tif (w_length > 0x10) {\n\t\t\t\t\tvalue = fill_ext_compat(os_desc_cfg, buf);\n\t\t\t\t\tvalue = min_t(u16, w_length, value);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase USB_RECIP_INTERFACE:\n\t\t\t\tif (w_index != 0x5 || (w_value >> 8))\n\t\t\t\t\tbreak;\n\t\t\t\tinterface = w_value & 0xFF;\n\t\t\t\tbuf[6] = w_index;\n\t\t\t\tcount = count_ext_prop(os_desc_cfg,\n\t\t\t\t\tinterface);\n\t\t\t\tput_unaligned_le16(count, buf + 8);\n\t\t\t\tcount = len_ext_prop(os_desc_cfg,\n\t\t\t\t\tinterface);\n\t\t\t\tput_unaligned_le32(count, buf);\n\t\t\t\tvalue = w_length;\n\t\t\t\tif (w_length > 0x0A) {\n\t\t\t\t\tvalue = fill_ext_prop(os_desc_cfg,\n\t\t\t\t\t\t\t      interface, buf);\n\t\t\t\t\tif (value >= 0)\n\t\t\t\t\t\tvalue = min_t(u16, w_length, value);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tgoto check_value;\n\t\t}\n\n\t\tVDBG(cdev,\n\t\t\t\"non-core control req%02x.%02x v%04x i%04x l%d\\n\",\n\t\t\tctrl->bRequestType, ctrl->bRequest,\n\t\t\tw_value, w_index, w_length);\n\n\t\t\/* functions always handle their interfaces and endpoints...\n\t\t * punt other recipients (other, WUSB, ...) to the current\n\t\t * configuration code.\n\t\t *\/\n\t\tif (cdev->config) {\n\t\t\tlist_for_each_entry(f, &cdev->config->functions, list)\n\t\t\t\tif (f->req_match &&\n\t\t\t\t    f->req_match(f, ctrl, false))\n\t\t\t\t\tgoto try_fun_setup;\n\t\t} else {\n\t\t\tstruct usb_configuration *c;\n\t\t\tlist_for_each_entry(c, &cdev->configs, list)\n\t\t\t\tlist_for_each_entry(f, &c->functions, list)\n\t\t\t\t\tif (f->req_match &&\n\t\t\t\t\t    f->req_match(f, ctrl, true))\n\t\t\t\t\t\tgoto try_fun_setup;\n\t\t}\n\t\tf = NULL;\n\n\t\tswitch (ctrl->bRequestType & USB_RECIP_MASK) {\n\t\tcase USB_RECIP_INTERFACE:\n\t\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\t\tbreak;\n\t\t\tf = cdev->config->interface[intf];\n\t\t\tbreak;\n\n\t\tcase USB_RECIP_ENDPOINT:\n\t\t\tif (!cdev->config)\n\t\t\t\tbreak;\n\t\t\tendp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);\n\t\t\tlist_for_each_entry(f, &cdev->config->functions, list) {\n\t\t\t\tif (test_bit(endp, f->endpoints))\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (&f->list == &cdev->config->functions)\n\t\t\t\tf = NULL;\n\t\t\tbreak;\n\t\t}\ntry_fun_setup:\n\t\tif (f && f->setup)\n\t\t\tvalue = f->setup(f, ctrl);\n\t\telse {\n\t\t\tstruct usb_configuration\t*c;\n\n\t\t\tc = cdev->config;\n\t\t\tif (!c)\n\t\t\t\tgoto done;\n\n\t\t\t\/* try current config's setup *\/\n\t\t\tif (c->setup) {\n\t\t\t\tvalue = c->setup(c, ctrl);\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\t\/* try the only function in the current config *\/\n\t\t\tif (!list_is_singular(&c->functions))\n\t\t\t\tgoto done;\n\t\t\tf = list_first_entry(&c->functions, struct usb_function,\n\t\t\t\t\t     list);\n\t\t\tif (f->setup)\n\t\t\t\tvalue = f->setup(f, ctrl);\n\t\t}\n\n\t\tgoto done;\n\t}\n\ncheck_value:\n\t\/* respond with data transfer before status phase? *\/\n\tif (value >= 0 && value != USB_GADGET_DELAYED_STATUS) {\n\t\treq->length = value;\n\t\treq->context = cdev;\n\t\treq->zero = value < w_length;\n\t\tvalue = composite_ep0_queue(cdev, req, GFP_ATOMIC);\n\t\tif (value < 0) {\n\t\t\tDBG(cdev, \"ep_queue --> %d\\n\", value);\n\t\t\treq->status = 0;\n\t\t\tcomposite_setup_complete(gadget->ep0, req);\n\t\t}\n\t} else if (value == USB_GADGET_DELAYED_STATUS && w_length != 0) {\n\t\tWARN(cdev,\n\t\t\t\"%s: Delayed status not supported for w_length != 0\",\n\t\t\t__func__);\n\t}\n\ndone:\n\t\/* device either stalls (value < 0) or reports success *\/\n\treturn value;\n}","target":1,"code_token_length":3542,"total_token_length":3778,"max_tokens_setting":4096}
+{"idx":8047,"func":"static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {\n  PyObject *__pyx_r = NULL;\n  __Pyx_RefNannyDeclarations\n  PyObject *__pyx_t_1 = NULL;\n  Py_ssize_t __pyx_t_2;\n  int __pyx_t_3;\n  int __pyx_t_4;\n  int __pyx_t_5;\n  PyObject *__pyx_t_6 = NULL;\n  PyObject *__pyx_t_7 = NULL;\n  PyObject *__pyx_t_8 = NULL;\n  __Pyx_RefNannySetupContext(\"__pyx_unpickle_BufferedSocketReader__set_state\", 0);\n\n  \/* \"(tree fragment)\":12\n *     return __pyx_result\n * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):\n *     __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]             # <<<<<<<<<<<<<<\n *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):\n *         __pyx_result.__dict__.update(__pyx_state[4])\n *\/\n  if (unlikely(__pyx_v___pyx_state == Py_None)) {\n    PyErr_SetString(PyExc_TypeError, \"'NoneType' object is not subscriptable\");\n    __PYX_ERR(1, 12, __pyx_L1_error)\n  }\n  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_GOTREF(__pyx_t_1);\n  if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, \"Expected %.16s, got %.200s\", \"bytearray\", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_GIVEREF(__pyx_t_1);\n  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.buffer);\n  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.buffer);\n  __pyx_v___pyx_result->__pyx_base.buffer = ((PyObject*)__pyx_t_1);\n  __pyx_t_1 = 0;\n  if (unlikely(__pyx_v___pyx_state == Py_None)) {\n    PyErr_SetString(PyExc_TypeError, \"'NoneType' object is not subscriptable\");\n    __PYX_ERR(1, 12, __pyx_L1_error)\n  }\n  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_GOTREF(__pyx_t_1);\n  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;\n  __pyx_v___pyx_result->__pyx_base.current_buffer_size = __pyx_t_2;\n  if (unlikely(__pyx_v___pyx_state == Py_None)) {\n    PyErr_SetString(PyExc_TypeError, \"'NoneType' object is not subscriptable\");\n    __PYX_ERR(1, 12, __pyx_L1_error)\n  }\n  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_GOTREF(__pyx_t_1);\n  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;\n  __pyx_v___pyx_result->__pyx_base.position = __pyx_t_2;\n  if (unlikely(__pyx_v___pyx_state == Py_None)) {\n    PyErr_SetString(PyExc_TypeError, \"'NoneType' object is not subscriptable\");\n    __PYX_ERR(1, 12, __pyx_L1_error)\n  }\n  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)\n  __Pyx_GOTREF(__pyx_t_1);\n  __Pyx_GIVEREF(__pyx_t_1);\n  __Pyx_GOTREF(__pyx_v___pyx_result->sock);\n  __Pyx_DECREF(__pyx_v___pyx_result->sock);\n  __pyx_v___pyx_result->sock = __pyx_t_1;\n  __pyx_t_1 = 0;\n\n  \/* \"(tree fragment)\":13\n * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):\n *     __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]\n *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<\n *         __pyx_result.__dict__.update(__pyx_state[4])\n *\/\n  if (unlikely(__pyx_v___pyx_state == Py_None)) {\n    PyErr_SetString(PyExc_TypeError, \"object of type 'NoneType' has no len()\");\n    __PYX_ERR(1, 13, __pyx_L1_error)\n  }\n  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)\n  __pyx_t_4 = ((__pyx_t_2 > 4) != 0);\n  if (__pyx_t_4) {\n  } else {\n    __pyx_t_3 = __pyx_t_4;\n    goto __pyx_L4_bool_binop_done;\n  }\n  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)\n  __pyx_t_5 = (__pyx_t_4 != 0);\n  __pyx_t_3 = __pyx_t_5;\n  __pyx_L4_bool_binop_done:;\n  if (__pyx_t_3) {\n\n    \/* \"(tree fragment)\":14\n *     __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]\n *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):\n *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<\n *\/\n    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)\n    __Pyx_GOTREF(__pyx_t_6);\n    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)\n    __Pyx_GOTREF(__pyx_t_7);\n    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;\n    if (unlikely(__pyx_v___pyx_state == Py_None)) {\n      PyErr_SetString(PyExc_TypeError, \"'NoneType' object is not subscriptable\");\n      __PYX_ERR(1, 14, __pyx_L1_error)\n    }\n    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)\n    __Pyx_GOTREF(__pyx_t_6);\n    __pyx_t_8 = NULL;\n    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {\n      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);\n      if (likely(__pyx_t_8)) {\n        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);\n        __Pyx_INCREF(__pyx_t_8);\n        __Pyx_INCREF(function);\n        __Pyx_DECREF_SET(__pyx_t_7, function);\n      }\n    }\n    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);\n    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;\n    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;\n    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)\n    __Pyx_GOTREF(__pyx_t_1);\n    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;\n    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;\n\n    \/* \"(tree fragment)\":13\n * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):\n *     __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]\n *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<\n *         __pyx_result.__dict__.update(__pyx_state[4])\n *\/\n  }\n\n  \/* \"(tree fragment)\":11\n *         __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state)\n *     return __pyx_result\n * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<\n *     __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]\n *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):\n *\/\n\n  \/* function exit code *\/\n  __pyx_r = Py_None; __Pyx_INCREF(Py_None);\n  goto __pyx_L0;\n  __pyx_L1_error:;\n  __Pyx_XDECREF(__pyx_t_1);\n  __Pyx_XDECREF(__pyx_t_6);\n  __Pyx_XDECREF(__pyx_t_7);\n  __Pyx_XDECREF(__pyx_t_8);\n  __Pyx_AddTraceback(\"clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader__set_state\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n  __pyx_r = 0;\n  __pyx_L0:;\n  __Pyx_XGIVEREF(__pyx_r);\n  __Pyx_RefNannyFinishContext();\n  return __pyx_r;\n}","target":1,"code_token_length":2847,"total_token_length":3083,"max_tokens_setting":4096}
+{"idx":46597,"func":"static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)\n{\n\t\/*\n\t * Note that as a general rule, the high half of the MSRs (bits in\n\t * the control fields which may be 1) should be initialized by the\n\t * intersection of the underlying hardware's MSR (i.e., features which\n\t * can be supported) and the list of features we want to expose -\n\t * because they are known to be properly supported in our code.\n\t * Also, usually, the low half of the MSRs (bits which must be 1) can\n\t * be set to 0, meaning that L1 may turn off any of these bits. The\n\t * reason is that if one of these bits is necessary, it will appear\n\t * in vmcs01 and prepare_vmcs02, when it bitwise-or's the control\n\t * fields of vmcs01 and vmcs02, will turn these bits off - and\n\t * nested_vmx_exit_handled() will not pass related exits to L1.\n\t * These rules have exceptions below.\n\t *\/\n\n\t\/* pin-based controls *\/\n\trdmsr(MSR_IA32_VMX_PINBASED_CTLS,\n\t\tvmx->nested.nested_vmx_pinbased_ctls_low,\n\t\tvmx->nested.nested_vmx_pinbased_ctls_high);\n\tvmx->nested.nested_vmx_pinbased_ctls_low |=\n\t\tPIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR;\n\tvmx->nested.nested_vmx_pinbased_ctls_high &=\n\t\tPIN_BASED_EXT_INTR_MASK |\n\t\tPIN_BASED_NMI_EXITING |\n\t\tPIN_BASED_VIRTUAL_NMIS;\n\tvmx->nested.nested_vmx_pinbased_ctls_high |=\n\t\tPIN_BASED_ALWAYSON_WITHOUT_TRUE_MSR |\n\t\tPIN_BASED_VMX_PREEMPTION_TIMER;\n\tif (kvm_vcpu_apicv_active(&vmx->vcpu))\n\t\tvmx->nested.nested_vmx_pinbased_ctls_high |=\n\t\t\tPIN_BASED_POSTED_INTR;\n\n\t\/* exit controls *\/\n\trdmsr(MSR_IA32_VMX_EXIT_CTLS,\n\t\tvmx->nested.nested_vmx_exit_ctls_low,\n\t\tvmx->nested.nested_vmx_exit_ctls_high);\n\tvmx->nested.nested_vmx_exit_ctls_low =\n\t\tVM_EXIT_ALWAYSON_WITHOUT_TRUE_MSR;\n\n\tvmx->nested.nested_vmx_exit_ctls_high &=\n#ifdef CONFIG_X86_64\n\t\tVM_EXIT_HOST_ADDR_SPACE_SIZE |\n#endif\n\t\tVM_EXIT_LOAD_IA32_PAT | VM_EXIT_SAVE_IA32_PAT;\n\tvmx->nested.nested_vmx_exit_ctls_high |=\n\t\tVM_EXIT_ALWAYSON_WITHOUT_TRUE_MSR |\n\t\tVM_EXIT_LOAD_IA32_EFER | VM_EXIT_SAVE_IA32_EFER |\n\t\tVM_EXIT_SAVE_VMX_PREEMPTION_TIMER | VM_EXIT_ACK_INTR_ON_EXIT;\n\n\tif (kvm_mpx_supported())\n\t\tvmx->nested.nested_vmx_exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS;\n\n\t\/* We support free control of debug control saving. *\/\n\tvmx->nested.nested_vmx_true_exit_ctls_low =\n\t\tvmx->nested.nested_vmx_exit_ctls_low &\n\t\t~VM_EXIT_SAVE_DEBUG_CONTROLS;\n\n\t\/* entry controls *\/\n\trdmsr(MSR_IA32_VMX_ENTRY_CTLS,\n\t\tvmx->nested.nested_vmx_entry_ctls_low,\n\t\tvmx->nested.nested_vmx_entry_ctls_high);\n\tvmx->nested.nested_vmx_entry_ctls_low =\n\t\tVM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR;\n\tvmx->nested.nested_vmx_entry_ctls_high &=\n#ifdef CONFIG_X86_64\n\t\tVM_ENTRY_IA32E_MODE |\n#endif\n\t\tVM_ENTRY_LOAD_IA32_PAT;\n\tvmx->nested.nested_vmx_entry_ctls_high |=\n\t\t(VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER);\n\tif (kvm_mpx_supported())\n\t\tvmx->nested.nested_vmx_entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS;\n\n\t\/* We support free control of debug control loading. *\/\n\tvmx->nested.nested_vmx_true_entry_ctls_low =\n\t\tvmx->nested.nested_vmx_entry_ctls_low &\n\t\t~VM_ENTRY_LOAD_DEBUG_CONTROLS;\n\n\t\/* cpu-based controls *\/\n\trdmsr(MSR_IA32_VMX_PROCBASED_CTLS,\n\t\tvmx->nested.nested_vmx_procbased_ctls_low,\n\t\tvmx->nested.nested_vmx_procbased_ctls_high);\n\tvmx->nested.nested_vmx_procbased_ctls_low =\n\t\tCPU_BASED_ALWAYSON_WITHOUT_TRUE_MSR;\n\tvmx->nested.nested_vmx_procbased_ctls_high &=\n\t\tCPU_BASED_VIRTUAL_INTR_PENDING |\n\t\tCPU_BASED_VIRTUAL_NMI_PENDING | CPU_BASED_USE_TSC_OFFSETING |\n\t\tCPU_BASED_HLT_EXITING | CPU_BASED_INVLPG_EXITING |\n\t\tCPU_BASED_MWAIT_EXITING | CPU_BASED_CR3_LOAD_EXITING |\n\t\tCPU_BASED_CR3_STORE_EXITING |\n#ifdef CONFIG_X86_64\n\t\tCPU_BASED_CR8_LOAD_EXITING | CPU_BASED_CR8_STORE_EXITING |\n#endif\n\t\tCPU_BASED_MOV_DR_EXITING | CPU_BASED_UNCOND_IO_EXITING |\n\t\tCPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_TRAP_FLAG |\n\t\tCPU_BASED_MONITOR_EXITING | CPU_BASED_RDPMC_EXITING |\n\t\tCPU_BASED_RDTSC_EXITING | CPU_BASED_PAUSE_EXITING |\n\t\tCPU_BASED_TPR_SHADOW | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;\n\t\/*\n\t * We can allow some features even when not supported by the\n\t * hardware. For example, L1 can specify an MSR bitmap - and we\n\t * can use it to avoid exits to L1 - even when L0 runs L2\n\t * without MSR bitmaps.\n\t *\/\n\tvmx->nested.nested_vmx_procbased_ctls_high |=\n\t\tCPU_BASED_ALWAYSON_WITHOUT_TRUE_MSR |\n\t\tCPU_BASED_USE_MSR_BITMAPS;\n\n\t\/* We support free control of CR3 access interception. *\/\n\tvmx->nested.nested_vmx_true_procbased_ctls_low =\n\t\tvmx->nested.nested_vmx_procbased_ctls_low &\n\t\t~(CPU_BASED_CR3_LOAD_EXITING | CPU_BASED_CR3_STORE_EXITING);\n\n\t\/* secondary cpu-based controls *\/\n\trdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,\n\t\tvmx->nested.nested_vmx_secondary_ctls_low,\n\t\tvmx->nested.nested_vmx_secondary_ctls_high);\n\tvmx->nested.nested_vmx_secondary_ctls_low = 0;\n\tvmx->nested.nested_vmx_secondary_ctls_high &=\n\t\tSECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |\n\t\tSECONDARY_EXEC_RDTSCP |\n\t\tSECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |\n\t\tSECONDARY_EXEC_ENABLE_VPID |\n\t\tSECONDARY_EXEC_APIC_REGISTER_VIRT |\n\t\tSECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |\n\t\tSECONDARY_EXEC_WBINVD_EXITING |\n\t\tSECONDARY_EXEC_XSAVES |\n\t\tSECONDARY_EXEC_PCOMMIT;\n\n\tif (enable_ept) {\n\t\t\/* nested EPT: emulate EPT also to L1 *\/\n\t\tvmx->nested.nested_vmx_secondary_ctls_high |=\n\t\t\tSECONDARY_EXEC_ENABLE_EPT;\n\t\tvmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT |\n\t\t\t VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT |\n\t\t\t VMX_EPT_INVEPT_BIT;\n\t\tvmx->nested.nested_vmx_ept_caps &= vmx_capability.ept;\n\t\t\/*\n\t\t * For nested guests, we don't do anything specific\n\t\t * for single context invalidation. Hence, only advertise\n\t\t * support for global context invalidation.\n\t\t *\/\n\t\tvmx->nested.nested_vmx_ept_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;\n\t} else\n\t\tvmx->nested.nested_vmx_ept_caps = 0;\n\n\t\/*\n\t * Old versions of KVM use the single-context version without\n\t * checking for support, so declare that it is supported even\n\t * though it is treated as global context.  The alternative is\n\t * not failing the single-context invvpid, and it is worse.\n\t *\/\n\tif (enable_vpid)\n\t\tvmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT |\n\t\t\t\tVMX_VPID_EXTENT_SINGLE_CONTEXT_BIT |\n\t\t\t\tVMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT;\n\telse\n\t\tvmx->nested.nested_vmx_vpid_caps = 0;\n\n\tif (enable_unrestricted_guest)\n\t\tvmx->nested.nested_vmx_secondary_ctls_high |=\n\t\t\tSECONDARY_EXEC_UNRESTRICTED_GUEST;\n\n\t\/* miscellaneous data *\/\n\trdmsr(MSR_IA32_VMX_MISC,\n\t\tvmx->nested.nested_vmx_misc_low,\n\t\tvmx->nested.nested_vmx_misc_high);\n\tvmx->nested.nested_vmx_misc_low &= VMX_MISC_SAVE_EFER_LMA;\n\tvmx->nested.nested_vmx_misc_low |=\n\t\tVMX_MISC_EMULATED_PREEMPTION_TIMER_RATE |\n\t\tVMX_MISC_ACTIVITY_HLT;\n\tvmx->nested.nested_vmx_misc_high = 0;\n}","target":0,"code_token_length":2083,"total_token_length":2319,"max_tokens_setting":4096}
+{"idx":71809,"func":"static void zynq_init(MachineState *machine)\n\n{\n\n    ram_addr_t ram_size = machine->ram_size;\n\n    const char *cpu_model = machine->cpu_model;\n\n    const char *kernel_filename = machine->kernel_filename;\n\n    const char *kernel_cmdline = machine->kernel_cmdline;\n\n    const char *initrd_filename = machine->initrd_filename;\n\n    ObjectClass *cpu_oc;\n\n    ARMCPU *cpu;\n\n    MemoryRegion *address_space_mem = get_system_memory();\n\n    MemoryRegion *ext_ram = g_new(MemoryRegion, 1);\n\n    MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);\n\n    DeviceState *dev;\n\n    SysBusDevice *busdev;\n\n    qemu_irq pic[64];\n\n    Error *err = NULL;\n\n    int n;\n\n\n\n    if (!cpu_model) {\n\n        cpu_model = \"cortex-a9\";\n\n    }\n\n    cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);\n\n\n\n    cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));\n\n\n\n    \/* By default A9 CPUs have EL3 enabled.  This board does not\n\n     * currently support EL3 so the CPU EL3 property is disabled before\n\n     * realization.\n\n     *\/\n\n    if (object_property_find(OBJECT(cpu), \"has_el3\", NULL)) {\n\n        object_property_set_bool(OBJECT(cpu), false, \"has_el3\", &err);\n\n        if (err) {\n\n            error_report_err(err);\n\n            exit(1);\n\n        }\n\n    }\n\n\n\n    object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, \"midr\", &err);\n\n    if (err) {\n\n        error_report_err(err);\n\n        exit(1);\n\n    }\n\n\n\n    object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, \"reset-cbar\", &err);\n\n    if (err) {\n\n        error_report_err(err);\n\n        exit(1);\n\n    }\n\n    object_property_set_bool(OBJECT(cpu), true, \"realized\", &err);\n\n    if (err) {\n\n        error_report_err(err);\n\n        exit(1);\n\n    }\n\n\n\n    \/* max 2GB ram *\/\n\n    if (ram_size > 0x80000000) {\n\n        ram_size = 0x80000000;\n\n    }\n\n\n\n    \/* DDR remapped to address zero.  *\/\n\n    memory_region_allocate_system_memory(ext_ram, NULL, \"zynq.ext_ram\",\n\n                                         ram_size);\n\n    memory_region_add_subregion(address_space_mem, 0, ext_ram);\n\n\n\n    \/* 256K of on-chip memory *\/\n\n    memory_region_init_ram(ocm_ram, NULL, \"zynq.ocm_ram\", 256 << 10,\n\n                           &error_abort);\n\n    vmstate_register_ram_global(ocm_ram);\n\n    memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);\n\n\n\n    DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);\n\n\n\n    \/* AMD *\/\n\n    pflash_cfi02_register(0xe2000000, NULL, \"zynq.pflash\", FLASH_SIZE,\n\n                          dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,\n\n                          FLASH_SECTOR_SIZE,\n\n                          FLASH_SIZE\/FLASH_SECTOR_SIZE, 1,\n\n                          1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,\n\n                              0);\n\n\n\n    dev = qdev_create(NULL, \"xilinx,zynq_slcr\");\n\n    qdev_init_nofail(dev);\n\n    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);\n\n\n\n    dev = qdev_create(NULL, \"a9mpcore_priv\");\n\n    qdev_prop_set_uint32(dev, \"num-cpu\", 1);\n\n    qdev_init_nofail(dev);\n\n    busdev = SYS_BUS_DEVICE(dev);\n\n    sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);\n\n    sysbus_connect_irq(busdev, 0,\n\n                       qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));\n\n\n\n    for (n = 0; n < 64; n++) {\n\n        pic[n] = qdev_get_gpio_in(dev, n);\n\n    }\n\n\n\n    zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);\n\n    zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);\n\n    zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);\n\n\n\n    sysbus_create_simple(\"xlnx,ps7-usb\", 0xE0002000, pic[53-IRQ_OFFSET]);\n\n    sysbus_create_simple(\"xlnx,ps7-usb\", 0xE0003000, pic[76-IRQ_OFFSET]);\n\n\n\n    sysbus_create_simple(\"cadence_uart\", 0xE0000000, pic[59-IRQ_OFFSET]);\n\n    sysbus_create_simple(\"cadence_uart\", 0xE0001000, pic[82-IRQ_OFFSET]);\n\n\n\n    sysbus_create_varargs(\"cadence_ttc\", 0xF8001000,\n\n            pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);\n\n    sysbus_create_varargs(\"cadence_ttc\", 0xF8002000,\n\n            pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);\n\n\n\n    gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);\n\n    gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);\n\n\n\n    dev = qdev_create(NULL, \"generic-sdhci\");\n\n    qdev_init_nofail(dev);\n\n    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);\n\n    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);\n\n\n\n    dev = qdev_create(NULL, \"generic-sdhci\");\n\n    qdev_init_nofail(dev);\n\n    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);\n\n    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);\n\n\n\n    dev = qdev_create(NULL, \"pl330\");\n\n    qdev_prop_set_uint8(dev, \"num_chnls\",  8);\n\n    qdev_prop_set_uint8(dev, \"num_periph_req\",  4);\n\n    qdev_prop_set_uint8(dev, \"num_events\",  16);\n\n\n\n    qdev_prop_set_uint8(dev, \"data_width\",  64);\n\n    qdev_prop_set_uint8(dev, \"wr_cap\",  8);\n\n    qdev_prop_set_uint8(dev, \"wr_q_dep\",  16);\n\n    qdev_prop_set_uint8(dev, \"rd_cap\",  8);\n\n    qdev_prop_set_uint8(dev, \"rd_q_dep\",  16);\n\n    qdev_prop_set_uint16(dev, \"data_buffer_dep\",  256);\n\n\n\n    qdev_init_nofail(dev);\n\n    busdev = SYS_BUS_DEVICE(dev);\n\n    sysbus_mmio_map(busdev, 0, 0xF8003000);\n\n    sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]); \/* abort irq line *\/\n\n    for (n = 0; n < 8; ++n) { \/* event irqs *\/\n\n        sysbus_connect_irq(busdev, n + 1, pic[dma_irqs[n] - IRQ_OFFSET]);\n\n    }\n\n\n\n    zynq_binfo.ram_size = ram_size;\n\n    zynq_binfo.kernel_filename = kernel_filename;\n\n    zynq_binfo.kernel_cmdline = kernel_cmdline;\n\n    zynq_binfo.initrd_filename = initrd_filename;\n\n    zynq_binfo.nb_cpus = 1;\n\n    zynq_binfo.board_id = 0xd32;\n\n    zynq_binfo.loader_start = 0;\n\n    arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);\n\n}\n","target":1,"code_token_length":1849,"total_token_length":2085,"max_tokens_setting":4096}
+{"idx":323348,"func":"int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun)\n\n{\n\n    int64_t nb_sectors;\n\n    uint32_t lba;\n\n    uint32_t len;\n\n    int cmdlen;\n\n    int is_write;\n\n\n\n    s->command = buf[0];\n\n    s->tag = tag;\n\n    s->sector_count = 0;\n\n    s->buf_pos = 0;\n\n    s->buf_len = 0;\n\n    is_write = 0;\n\n    DPRINTF(\"Command: 0x%02x\", buf[0]);\n\n    switch (s->command >> 5) {\n\n    case 0:\n\n        lba = buf[3] | (buf[2] << 8) | ((buf[1] & 0x1f) << 16);\n\n        len = buf[4];\n\n        cmdlen = 6;\n\n        break;\n\n    case 1:\n\n    case 2:\n\n        lba = buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24);\n\n        len = buf[8] | (buf[7] << 8);\n\n        cmdlen = 10;\n\n        break;\n\n    case 4:\n\n        lba = buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24);\n\n        len = buf[13] | (buf[12] << 8) | (buf[11] << 16) | (buf[10] << 24);\n\n        cmdlen = 16;\n\n        break;\n\n    case 5:\n\n        lba = buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24);\n\n        len = buf[9] | (buf[8] << 8) | (buf[7] << 16) | (buf[6] << 24);\n\n        cmdlen = 12;\n\n        break;\n\n    default:\n\n        BADF(\"Unsupported command length, command %x\\n\", s->command);\n\n        goto fail;\n\n    }\n\n#ifdef DEBUG_SCSI\n\n    {\n\n        int i;\n\n        for (i = 1; i < cmdlen; i++) {\n\n            printf(\" 0x%02x\", buf[i]);\n\n        }\n\n        printf(\"\\n\");\n\n    }\n\n#endif\n\n    if (lun || buf[1] >> 5) {\n\n        \/* Only LUN 0 supported.  *\/\n\n        DPRINTF(\"Unimplemented LUN %d\\n\", lun ? lun : buf[1] >> 5);\n\n        goto fail;\n\n    }\n\n    switch (s->command) {\n\n    case 0x0:\n\n\tDPRINTF(\"Test Unit Ready\\n\");\n\n\tbreak;\n\n    case 0x03:\n\n        DPRINTF(\"Request Sense (len %d)\\n\", len);\n\n        if (len < 4)\n\n            goto fail;\n\n        memset(buf, 0, 4);\n\n        s->buf[0] = 0xf0;\n\n        s->buf[1] = 0;\n\n        s->buf[2] = s->sense;\n\n        s->buf_len = 4;\n\n        break;\n\n    case 0x12:\n\n        DPRINTF(\"Inquiry (len %d)\\n\", len);\n\n        if (len < 36) {\n\n            BADF(\"Inquiry buffer too small (%d)\\n\", len);\n\n        }\n\n\tmemset(s->buf, 0, 36);\n\n\tif (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {\n\n\t    s->buf[0] = 5;\n\n            s->buf[1] = 0x80;\n\n\t    memcpy(&s->buf[16], \"QEMU CD-ROM    \", 16);\n\n\t} else {\n\n\t    s->buf[0] = 0;\n\n\t    memcpy(&s->buf[16], \"QEMU HARDDISK  \", 16);\n\n\t}\n\n\tmemcpy(&s->buf[8], \"QEMU   \", 8);\n\n        memcpy(&s->buf[32], QEMU_VERSION, 4);\n\n        \/* Identify device as SCSI-3 rev 1.\n\n           Some later commands are also implemented. *\/\n\n\ts->buf[2] = 3;\n\n\ts->buf[3] = 2; \/* Format 2 *\/\n\n\ts->buf[4] = 32;\n\n\ts->buf_len = 36;\n\n\tbreak;\n\n    case 0x16:\n\n        DPRINTF(\"Reserve(6)\\n\");\n\n        if (buf[1] & 1)\n\n            goto fail;\n\n        break;\n\n    case 0x17:\n\n        DPRINTF(\"Release(6)\\n\");\n\n        if (buf[1] & 1)\n\n            goto fail;\n\n        break;\n\n    case 0x1a:\n\n    case 0x5a:\n\n        {\n\n            char *p;\n\n            int page;\n\n\n\n            page = buf[2] & 0x3f;\n\n            DPRINTF(\"Mode Sense (page %d, len %d)\\n\", page, len);\n\n            p = s->buf;\n\n            memset(p, 0, 4);\n\n            s->buf[1] = 0; \/* Default media type.  *\/\n\n            s->buf[3] = 0; \/* Block descriptor length.  *\/\n\n            if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {\n\n                s->buf[2] = 0x80; \/* Readonly.  *\/\n\n            }\n\n            p += 4;\n\n            if ((page == 8 || page == 0x3f)) {\n\n                \/* Caching page.  *\/\n\n                p[0] = 8;\n\n                p[1] = 0x12;\n\n                p[2] = 4; \/* WCE *\/\n\n                p += 19;\n\n            }\n\n            if ((page == 0x3f || page == 0x2a)\n\n                    && (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM)) {\n\n                \/* CD Capabilities and Mechanical Status page. *\/\n\n                p[0] = 0x2a;\n\n                p[1] = 0x14;\n\n                p[2] = 3; \/\/ CD-R & CD-RW read\n\n                p[3] = 0; \/\/ Writing not supported\n\n                p[4] = 0x7f; \/* Audio, composite, digital out,\n\n                                         mode 2 form 1&2, multi session *\/\n\n                p[5] = 0xff; \/* CD DA, DA accurate, RW supported,\n\n                                         RW corrected, C2 errors, ISRC,\n\n                                         UPC, Bar code *\/\n\n                p[6] = 0x2d | (bdrv_is_locked(s->bdrv)? 2 : 0);\n\n                \/* Locking supported, jumper present, eject, tray *\/\n\n                p[7] = 0; \/* no volume & mute control, no\n\n                                      changer *\/\n\n                p[8] = (50 * 176) >> 8; \/\/ 50x read speed\n\n                p[9] = (50 * 176) & 0xff;\n\n                p[10] = 0 >> 8; \/\/ No volume\n\n                p[11] = 0 & 0xff;\n\n                p[12] = 2048 >> 8; \/\/ 2M buffer\n\n                p[13] = 2048 & 0xff;\n\n                p[14] = (16 * 176) >> 8; \/\/ 16x read speed current\n\n                p[15] = (16 * 176) & 0xff;\n\n                p[18] = (16 * 176) >> 8; \/\/ 16x write speed\n\n                p[19] = (16 * 176) & 0xff;\n\n                p[20] = (16 * 176) >> 8; \/\/ 16x write speed current\n\n                p[21] = (16 * 176) & 0xff;\n\n                p += 21;\n\n            }\n\n            s->buf_len = p - s->buf;\n\n            s->buf[0] = s->buf_len - 4;\n\n            if (s->buf_len > len)\n\n                s->buf_len = len;\n\n        }\n\n        break;\n\n    case 0x1b:\n\n        DPRINTF(\"Start Stop Unit\\n\");\n\n\tbreak;\n\n    case 0x1e:\n\n        DPRINTF(\"Prevent Allow Medium Removal (prevent = %d)\\n\", buf[4] & 3);\n\n        bdrv_set_locked(s->bdrv, buf[4] & 1);\n\n\tbreak;\n\n    case 0x25:\n\n\tDPRINTF(\"Read Capacity\\n\");\n\n        \/* The normal LEN field for this command is zero.  *\/\n\n\tmemset(s->buf, 0, 8);\n\n\tbdrv_get_geometry(s->bdrv, &nb_sectors);\n\n\ts->buf[0] = (nb_sectors >> 24) & 0xff;\n\n\ts->buf[1] = (nb_sectors >> 16) & 0xff;\n\n\ts->buf[2] = (nb_sectors >> 8) & 0xff;\n\n\ts->buf[3] = nb_sectors & 0xff;\n\n\ts->buf[4] = 0;\n\n\ts->buf[5] = 0;\n\n        s->buf[6] = s->cluster_size * 2;\n\n\ts->buf[7] = 0;\n\n\ts->buf_len = 8;\n\n\tbreak;\n\n    case 0x08:\n\n    case 0x28:\n\n        DPRINTF(\"Read (sector %d, count %d)\\n\", lba, len);\n\n        s->sector = lba * s->cluster_size;\n\n        s->sector_count = len * s->cluster_size;\n\n        break;\n\n    case 0x0a:\n\n    case 0x2a:\n\n        DPRINTF(\"Write (sector %d, count %d)\\n\", lba, len);\n\n        s->sector = lba * s->cluster_size;\n\n        s->sector_count = len * s->cluster_size;\n\n        is_write = 1;\n\n        break;\n\n    case 0x35:\n\n        DPRINTF(\"Syncronise cache (sector %d, count %d)\\n\", lba, len);\n\n        bdrv_flush(s->bdrv);\n\n        break;\n\n    case 0x43:\n\n        {\n\n            int start_track, format, msf, toclen;\n\n\n\n            msf = buf[1] & 2;\n\n            format = buf[2] & 0xf;\n\n            start_track = buf[6];\n\n            bdrv_get_geometry(s->bdrv, &nb_sectors);\n\n            DPRINTF(\"Read TOC (track %d format %d msf %d)\\n\", start_track, format, msf >> 1);\n\n            switch(format) {\n\n            case 0:\n\n                toclen = cdrom_read_toc(nb_sectors, s->buf, msf, start_track);\n\n                break;\n\n            case 1:\n\n                \/* multi session : only a single session defined *\/\n\n                toclen = 12;\n\n                memset(s->buf, 0, 12);\n\n                s->buf[1] = 0x0a;\n\n                s->buf[2] = 0x01;\n\n                s->buf[3] = 0x01;\n\n                break;\n\n            case 2:\n\n                toclen = cdrom_read_toc_raw(nb_sectors, s->buf, msf, start_track);\n\n                break;\n\n            default:\n\n                goto error_cmd;\n\n            }\n\n            if (toclen > 0) {\n\n                if (len > toclen)\n\n                  len = toclen;\n\n                s->buf_len = len;\n\n                break;\n\n            }\n\n        error_cmd:\n\n            DPRINTF(\"Read TOC error\\n\");\n\n            goto fail;\n\n        }\n\n    case 0x46:\n\n        DPRINTF(\"Get Configuration (rt %d, maxlen %d)\\n\", buf[1] & 3, len);\n\n        memset(s->buf, 0, 8);\n\n        \/* ??? This shoud probably return much more information.  For now\n\n           just return the basic header indicating the CD-ROM profile.  *\/\n\n        s->buf[7] = 8; \/\/ CD-ROM\n\n        s->buf_len = 8;\n\n        break;\n\n    case 0x56:\n\n        DPRINTF(\"Reserve(10)\\n\");\n\n        if (buf[1] & 3)\n\n            goto fail;\n\n        break;\n\n    case 0x57:\n\n        DPRINTF(\"Release(10)\\n\");\n\n        if (buf[1] & 3)\n\n            goto fail;\n\n        break;\n\n    case 0xa0:\n\n        DPRINTF(\"Report LUNs (len %d)\\n\", len);\n\n        if (len < 16)\n\n            goto fail;\n\n        memset(s->buf, 0, 16);\n\n        s->buf[3] = 8;\n\n        s->buf_len = 16;\n\n        break;\n\n    default:\n\n\tDPRINTF(\"Unknown SCSI command (%2.2x)\\n\", buf[0]);\n\n    fail:\n\n        scsi_command_complete(s, SENSE_ILLEGAL_REQUEST);\n\n\treturn 0;\n\n    }\n\n    if (s->sector_count == 0 && s->buf_len == 0) {\n\n        scsi_command_complete(s, SENSE_NO_SENSE);\n\n    }\n\n    len = s->sector_count * 512 + s->buf_len;\n\n    return is_write ? -len : len;\n\n}\n","target":1,"code_token_length":2990,"total_token_length":3226,"max_tokens_setting":4096}
+{"idx":22540,"func":"wtap_open_return_val k12_open ( wtap * wth , int * err , gchar * * err_info ) {\n k12_src_desc_t * rec ;\n guint8 header_buffer [ K12_FILE_HDR_LEN ] ;\n guint8 * read_buffer ;\n guint32 type ;\n long offset ;\n long len ;\n guint port_type ;\n guint32 rec_len ;\n guint32 hwpart_len ;\n guint32 name_len ;\n guint32 stack_len ;\n guint i ;\n k12_t * file_data ;\n # ifdef DEBUG_K12 gchar * env_level = getenv ( \"K12_DEBUG_LEVEL\" ) ;\n env_file = getenv ( \"K12_DEBUG_FILENAME\" ) ;\n if ( env_file ) {\n dbg_out = ws_fopen ( env_file , \"w\" ) ;\n if ( dbg_out == NULL ) {\n dbg_out = stderr ;\n K12_DBG ( 1 , ( \"unable to open K12 DEBUG FILENAME for writing! Logging to standard error\" ) ) ;\n }\n }\n else dbg_out = stderr ;\n if ( env_level ) debug_level = ( unsigned int ) strtoul ( env_level , NULL , 10 ) ;\n K12_DBG ( 1 , ( \"k12_open: ENTER debug_level=%u\" , debug_level ) ) ;\n # endif if ( ! wtap_read_bytes ( wth -> fh , header_buffer , K12_FILE_HDR_LEN , err , err_info ) ) {\n K12_DBG ( 1 , ( \"k12_open: FILE HEADER TOO SHORT OR READ ERROR\" ) ) ;\n if ( * err != WTAP_ERR_SHORT_READ ) {\n return WTAP_OPEN_ERROR ;\n }\n return WTAP_OPEN_NOT_MINE ;\n }\n if ( memcmp ( header_buffer , k12_file_magic , 8 ) != 0 ) {\n K12_DBG ( 1 , ( \"k12_open: BAD MAGIC\" ) ) ;\n return WTAP_OPEN_NOT_MINE ;\n }\n offset = K12_FILE_HDR_LEN ;\n file_data = new_k12_file_data ( ) ;\n file_data -> file_len = pntoh32 ( header_buffer + 0x8 ) ;\n if ( memiszero ( header_buffer + 0x10 , K12_FILE_HDR_LEN - 0x10 ) ) {\n file_data -> num_of_records = pntoh32 ( header_buffer + 0x0C ) ;\n }\n else {\n file_data -> num_of_records = pntoh32 ( header_buffer + K12_FILE_HDR_RECORD_COUNT_1 ) ;\n if ( file_data -> num_of_records != pntoh32 ( header_buffer + K12_FILE_HDR_RECORD_COUNT_2 ) ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup_printf ( \"k12: two different record counts, %u at 0x%02x and %u at 0x%02x\" , file_data -> num_of_records , K12_FILE_HDR_RECORD_COUNT_1 , pntoh32 ( header_buffer + K12_FILE_HDR_RECORD_COUNT_2 ) , K12_FILE_HDR_RECORD_COUNT_2 ) ;\n return WTAP_OPEN_ERROR ;\n }\n }\n K12_DBG ( 5 , ( \"k12_open: FILE_HEADER OK: offset=%x file_len=%i records=%i\" , offset , file_data -> file_len , file_data -> num_of_records ) ) ;\n do {\n if ( file_data -> num_of_records == 0 ) {\n * err = WTAP_ERR_SHORT_READ ;\n destroy_k12_file_data ( file_data ) ;\n return WTAP_OPEN_ERROR ;\n }\n len = get_record ( file_data , wth -> fh , offset , FALSE , err , err_info ) ;\n if ( len < 0 ) {\n K12_DBG ( 1 , ( \"k12_open: BAD HEADER RECORD\" , len ) ) ;\n destroy_k12_file_data ( file_data ) ;\n return WTAP_OPEN_ERROR ;\n }\n if ( len == 0 ) {\n K12_DBG ( 1 , ( \"k12_open: BAD HEADER RECORD\" , len ) ) ;\n * err = WTAP_ERR_SHORT_READ ;\n destroy_k12_file_data ( file_data ) ;\n return WTAP_OPEN_ERROR ;\n }\n read_buffer = file_data -> seq_read_buff ;\n rec_len = pntoh32 ( read_buffer + K12_RECORD_LEN ) ;\n if ( rec_len < K12_RECORD_TYPE + 4 ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup_printf ( \"k12_open: record length %u < %u\" , rec_len , K12_RECORD_TYPE + 4 ) ;\n return WTAP_OPEN_ERROR ;\n }\n type = pntoh32 ( read_buffer + K12_RECORD_TYPE ) ;\n if ( ( type & K12_MASK_PACKET ) == K12_REC_PACKET || ( type & K12_MASK_PACKET ) == K12_REC_D0020 ) {\n if ( file_seek ( wth -> fh , offset , SEEK_SET , err ) == - 1 ) {\n destroy_k12_file_data ( file_data ) ;\n return WTAP_OPEN_ERROR ;\n }\n K12_DBG ( 5 , ( \"k12_open: FIRST PACKET offset=%x\" , offset ) ) ;\n break ;\n }\n switch ( type ) {\n case K12_REC_SRCDSC : case K12_REC_SRCDSC2 : rec = g_new0 ( k12_src_desc_t , 1 ) ;\n if ( rec_len < K12_SRCDESC_HWPART ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup_printf ( \"k12_open: source descriptor record length %u < %u\" , rec_len , K12_SRCDESC_HWPART ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_ERROR ;\n }\n port_type = read_buffer [ K12_SRCDESC_PORT_TYPE ] ;\n hwpart_len = pntoh16 ( read_buffer + K12_SRCDESC_HWPARTLEN ) ;\n name_len = pntoh16 ( read_buffer + K12_SRCDESC_NAMELEN ) ;\n stack_len = pntoh16 ( read_buffer + K12_SRCDESC_STACKLEN ) ;\n rec -> input = pntoh32 ( read_buffer + K12_RECORD_SRC_ID ) ;\n K12_DBG ( 5 , ( \"k12_open: INTERFACE RECORD offset=%x interface=%x\" , offset , rec -> input ) ) ;\n if ( name_len == 0 ) {\n K12_DBG ( 5 , ( \"k12_open: failed (name_len == 0 in source description\" ) ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_NOT_MINE ;\n }\n if ( stack_len == 0 ) {\n K12_DBG ( 5 , ( \"k12_open: failed (stack_len == 0 in source description\" ) ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_NOT_MINE ;\n }\n if ( rec_len < K12_SRCDESC_HWPART + hwpart_len + name_len + stack_len ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup_printf ( \"k12_open: source descriptor record length %u < %u (%u + %u + %u + %u)\" , rec_len , K12_SRCDESC_HWPART + hwpart_len + name_len + stack_len , K12_SRCDESC_HWPART , hwpart_len , name_len , stack_len ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_ERROR ;\n }\n if ( hwpart_len ) {\n if ( hwpart_len < 4 ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup_printf ( \"k12_open: source descriptor hardware part length %u < 4\" , hwpart_len ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_ERROR ;\n }\n switch ( ( rec -> input_type = pntoh32 ( read_buffer + K12_SRCDESC_HWPART + K12_SRCDESC_HWPARTTYPE ) ) ) {\n case K12_PORT_DS0S : rec -> input_info . ds0mask = 0x00000000 ;\n if ( hwpart_len > K12_SRCDESC_DS0_MASK ) {\n for ( i = 0 ;\n i < hwpart_len - K12_SRCDESC_DS0_MASK ;\n i ++ ) {\n rec -> input_info . ds0mask |= ( * ( read_buffer + K12_SRCDESC_HWPART + K12_SRCDESC_DS0_MASK + i ) == 0xff ) ? 1U << ( 31 - i ) : 0x0 ;\n }\n }\n break ;\n case K12_PORT_ATMPVC : if ( hwpart_len < K12_SRCDESC_ATM_VCI + 2 ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup_printf ( \"k12_open: source descriptor hardware part length %u < %u\" , hwpart_len , K12_SRCDESC_ATM_VCI + 2 ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_ERROR ;\n }\n rec -> input_info . atm . vp = pntoh16 ( read_buffer + K12_SRCDESC_HWPART + K12_SRCDESC_ATM_VPI ) ;\n rec -> input_info . atm . vc = pntoh16 ( read_buffer + K12_SRCDESC_HWPART + K12_SRCDESC_ATM_VCI ) ;\n break ;\n default : break ;\n }\n }\n else {\n if ( port_type >= 0x14 && port_type <= 0x17 ) {\n rec -> input_type = K12_PORT_ATMPVC ;\n rec -> input_info . atm . vp = 0 ;\n rec -> input_info . atm . vc = 0 ;\n }\n }\n if ( read_buffer [ K12_SRCDESC_HWPART + hwpart_len + name_len - 1 ] != '\\0' ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup ( \"k12_open: source descriptor record contains non-null-terminated link-layer name\" ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_ERROR ;\n }\n if ( read_buffer [ K12_SRCDESC_HWPART + hwpart_len + name_len + stack_len - 1 ] != '\\0' ) {\n * err = WTAP_ERR_BAD_FILE ;\n * err_info = g_strdup ( \"k12_open: source descriptor record contains non-null-terminated stack path\" ) ;\n destroy_k12_file_data ( file_data ) ;\n g_free ( rec ) ;\n return WTAP_OPEN_ERROR ;\n }\n rec -> input_name = ( gchar * ) g_memdup ( read_buffer + K12_SRCDESC_HWPART + hwpart_len , name_len ) ;\n rec -> stack_file = ( gchar * ) g_memdup ( read_buffer + K12_SRCDESC_HWPART + hwpart_len + name_len , stack_len ) ;\n ascii_strdown_inplace ( rec -> stack_file ) ;\n g_hash_table_insert ( file_data -> src_by_id , GUINT_TO_POINTER ( rec -> input ) , rec ) ;\n g_hash_table_insert ( file_data -> src_by_name , rec -> stack_file , rec ) ;\n break ;\n case K12_REC_STK_FILE : K12_DBG ( 1 , ( \"k12_open: K12_REC_STK_FILE\" ) ) ;\n K12_DBG ( 1 , ( \"Field 1: 0x%08x\" , pntoh32 ( read_buffer + 0x08 ) ) ) ;\n K12_DBG ( 1 , ( \"Field 2: 0x%08x\" , pntoh32 ( read_buffer + 0x0c ) ) ) ;\n K12_ASCII_DUMP ( 1 , read_buffer , rec_len , 16 ) ;\n break ;\n default : K12_DBG ( 1 , ( \"k12_open: RECORD TYPE 0x%08x\" , type ) ) ;\n break ;\n }\n offset += len ;\n file_data -> num_of_records -- ;\n }\n while ( 1 ) ;\n wth -> file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_K12 ;\n wth -> file_encap = WTAP_ENCAP_K12 ;\n wth -> snapshot_length = 0 ;\n wth -> subtype_read = k12_read ;\n wth -> subtype_seek_read = k12_seek_read ;\n wth -> subtype_close = k12_close ;\n wth -> priv = ( void * ) file_data ;\n wth -> file_tsprec = WTAP_TSPREC_NSEC ;\n return WTAP_OPEN_MINE ;\n }","target":0,"code_token_length":2755,"total_token_length":2991,"max_tokens_setting":4096}
+{"idx":195273,"func":"static MagickBooleanType WritePDBImage(const ImageInfo *image_info,Image *image)\n{\n  const char\n    *comment;\n\n  int\n    bits;\n\n  MagickBooleanType\n    status;\n\n  PDBImage\n    pdb_image;\n\n  PDBInfo\n    pdb_info;\n\n  QuantumInfo\n    *quantum_info;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    x;\n\n  register unsigned char\n    *q;\n\n  size_t\n    bits_per_pixel,\n    literal,\n    packets,\n    packet_size,\n    repeat;\n\n  ssize_t\n    y;\n\n  unsigned char\n    *buffer,\n    *runlength,\n    *scanline;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  (void) TransformImageColorspace(image,sRGBColorspace);\n  if ((image -> colors <= 2 ) ||\n      (GetImageType(image,&image->exception ) == BilevelType)) {\n    bits_per_pixel=1;\n  } else if (image->colors <= 4) {\n    bits_per_pixel=2;\n  } else if (image->colors <= 8) {\n    bits_per_pixel=3;\n  } else {\n    bits_per_pixel=4;\n  }\n  (void) ResetMagickMemory(&pdb_info,0,sizeof(pdb_info));\n  (void) CopyMagickString(pdb_info.name,image_info->filename,\n    sizeof(pdb_info.name));\n  pdb_info.attributes=0;\n  pdb_info.version=0;\n  pdb_info.create_time=time(NULL);\n  pdb_info.modify_time=pdb_info.create_time;\n  pdb_info.archive_time=0;\n  pdb_info.modify_number=0;\n  pdb_info.application_info=0;\n  pdb_info.sort_info=0;\n  (void) CopyMagickMemory(pdb_info.type,\"vIMG\",4);\n  (void) CopyMagickMemory(pdb_info.id,\"View\",4);\n  pdb_info.seed=0;\n  pdb_info.next_record=0;\n  comment=GetImageProperty(image,\"comment\");\n  pdb_info.number_records=(comment == (const char *) NULL ? 1 : 2);\n  (void) WriteBlob(image,sizeof(pdb_info.name),(unsigned char *) pdb_info.name);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.attributes);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.version);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.create_time);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.modify_time);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.archive_time);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.modify_number);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.application_info);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.sort_info);\n  (void) WriteBlob(image,4,(unsigned char *) pdb_info.type);\n  (void) WriteBlob(image,4,(unsigned char *) pdb_info.id);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.seed);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.next_record);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.number_records);\n  (void) CopyMagickString(pdb_image.name,pdb_info.name,sizeof(pdb_image.name));\n  pdb_image.version=1;  \/* RLE Compressed *\/\n  switch (bits_per_pixel)\n  {\n    case 1: pdb_image.type=(unsigned char) 0xff; break;  \/* monochrome *\/\n    case 2: pdb_image.type=(unsigned char) 0x00; break;  \/* 2 bit gray *\/\n    default: pdb_image.type=(unsigned char) 0x02;  \/* 4 bit gray *\/\n  }\n  pdb_image.reserved_1=0;\n  pdb_image.note=0;\n  pdb_image.x_last=0;\n  pdb_image.y_last=0;\n  pdb_image.reserved_2=0;\n  pdb_image.x_anchor=(unsigned short) 0xffff;\n  pdb_image.y_anchor=(unsigned short) 0xffff;\n  pdb_image.width=(short) image->columns;\n  if (image->columns % 16)\n    pdb_image.width=(short) (16*(image->columns\/16+1));\n  pdb_image.height=(short) image->rows;\n  packets=((bits_per_pixel*image->columns+7)\/8);\n  runlength=(unsigned char *) AcquireQuantumMemory(9UL*packets,\n    image->rows*sizeof(*runlength));\n  if (runlength == (unsigned char *) NULL)\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n   buffer=(unsigned char *) AcquireQuantumMemory(512,sizeof(*buffer));\n   if (buffer == (unsigned char *) NULL)\n     ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  packet_size=(size_t) (image->depth > 8 ? 2 : 1);\n   scanline=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size*\n     sizeof(*scanline));\n   if (scanline == (unsigned char *) NULL)\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)\n    (void) TransformImageColorspace(image,sRGBColorspace);\n  \/*\n    Convert to GRAY raster scanline.\n  *\/\n   quantum_info=AcquireQuantumInfo(image_info,image);\n   if (quantum_info == (QuantumInfo *) NULL)\n     ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  status=SetQuantumDepth(image,quantum_info,image->depth > 8 ? 16 : 8);\n   bits=8\/(int) bits_per_pixel-1;  \/* start at most significant bits *\/\n   literal=0;\n   repeat=0;\n  q=runlength;\n  buffer[0]=0x00;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n    if (p == (const PixelPacket *) NULL)\n      break;\n    (void) ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,\n      GrayQuantum,scanline,&image->exception);\n    for (x=0; x < (ssize_t) pdb_image.width; x++)\n    {\n      if (x < (ssize_t) image->columns)\n        buffer[literal+repeat]|=(0xff-scanline[x*packet_size]) >>\n          (8-bits_per_pixel) << bits*bits_per_pixel;\n      bits--;\n      if (bits < 0)\n        {\n          if (((literal+repeat) > 0) &&\n              (buffer[literal+repeat] == buffer[literal+repeat-1]))\n            {\n              if (repeat == 0)\n                {\n                  literal--;\n                  repeat++;\n                }\n              repeat++;\n              if (0x7f < repeat)\n                {\n                  q=EncodeRLE(q,buffer,literal,repeat);\n                  literal=0;\n                  repeat=0;\n                }\n            }\n          else\n            {\n              if (repeat >= 2)\n                literal+=repeat;\n              else\n                {\n                  q=EncodeRLE(q,buffer,literal,repeat);\n                  buffer[0]=buffer[literal+repeat];\n                  literal=0;\n                }\n              literal++;\n              repeat=0;\n              if (0x7f < literal)\n                {\n                  q=EncodeRLE(q,buffer,(literal < 0x80 ? literal : 0x80),0);\n                  (void) CopyMagickMemory(buffer,buffer+literal+repeat,0x80);\n                  literal-=0x80;\n                }\n            }\n        bits=8\/(int) bits_per_pixel-1;\n        buffer[literal+repeat]=0x00;\n      }\n    }\n    status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n      image->rows);\n    if (status == MagickFalse)\n      break;\n  }\n  q=EncodeRLE(q,buffer,literal,repeat);\n  scanline=(unsigned char *) RelinquishMagickMemory(scanline);\n  buffer=(unsigned char *) RelinquishMagickMemory(buffer);\n  quantum_info=DestroyQuantumInfo(quantum_info);\n  \/*\n    Write the Image record header.\n  *\/\n  (void) WriteBlobMSBLong(image,(unsigned int) (TellBlob(image)+8*\n    pdb_info.number_records));\n  (void) WriteBlobByte(image,0x40);\n  (void) WriteBlobByte(image,0x6f);\n  (void) WriteBlobByte(image,0x80);\n  (void) WriteBlobByte(image,0);\n  if (pdb_info.number_records > 1)\n    {\n      \/*\n        Write the comment record header.\n      *\/\n      (void) WriteBlobMSBLong(image,(unsigned int) (TellBlob(image)+8+58+q-\n        runlength));\n      (void) WriteBlobByte(image,0x40);\n      (void) WriteBlobByte(image,0x6f);\n      (void) WriteBlobByte(image,0x80);\n      (void) WriteBlobByte(image,1);\n    }\n  \/*\n    Write the Image data.\n  *\/\n  (void) WriteBlob(image,sizeof(pdb_image.name),(unsigned char *)\n    pdb_image.name);\n  (void) WriteBlobByte(image,(unsigned char) pdb_image.version);\n  (void) WriteBlobByte(image,pdb_image.type);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_image.reserved_1);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_image.note);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.x_last);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.y_last);\n  (void) WriteBlobMSBLong(image,(unsigned int) pdb_image.reserved_2);\n  (void) WriteBlobMSBShort(image,pdb_image.x_anchor);\n  (void) WriteBlobMSBShort(image,pdb_image.y_anchor);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.width);\n  (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.height);\n  (void) WriteBlob(image,(size_t) (q-runlength),runlength);\n  runlength=(unsigned char *) RelinquishMagickMemory(runlength);\n  if (pdb_info.number_records > 1)\n    (void) WriteBlobString(image,comment);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}\n","target":0,"code_token_length":2405,"total_token_length":2641,"max_tokens_setting":4096}
+{"idx":487718,"func":"ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,\n\t\t struct ext4_ext_path *path,\n\t\t struct partial_cluster *partial,\n\t\t ext4_lblk_t start, ext4_lblk_t end)\n{\n\tstruct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);\n\tint err = 0, correct_index = 0;\n\tint depth = ext_depth(inode), credits, revoke_credits;\n\tstruct ext4_extent_header *eh;\n\text4_lblk_t a, b;\n\tunsigned num;\n\text4_lblk_t ex_ee_block;\n\tunsigned short ex_ee_len;\n\tunsigned unwritten = 0;\n\tstruct ext4_extent *ex;\n\text4_fsblk_t pblk;\n\n\t\/* the header must be checked already in ext4_ext_remove_space() *\/\n\text_debug(inode, \"truncate since %u in leaf to %u\\n\", start, end);\n\tif (!path[depth].p_hdr)\n\t\tpath[depth].p_hdr = ext_block_hdr(path[depth].p_bh);\n\teh = path[depth].p_hdr;\n\tif (unlikely(path[depth].p_hdr == NULL)) {\n\t\tEXT4_ERROR_INODE(inode, \"path[%d].p_hdr == NULL\", depth);\n\t\treturn -EFSCORRUPTED;\n\t}\n\t\/* find where to start removing *\/\n\tex = path[depth].p_ext;\n\tif (!ex)\n\t\tex = EXT_LAST_EXTENT(eh);\n\n\tex_ee_block = le32_to_cpu(ex->ee_block);\n\tex_ee_len = ext4_ext_get_actual_len(ex);\n\n\ttrace_ext4_ext_rm_leaf(inode, start, ex, partial);\n\n\twhile (ex >= EXT_FIRST_EXTENT(eh) &&\n\t\t\tex_ee_block + ex_ee_len > start) {\n\n\t\tif (ext4_ext_is_unwritten(ex))\n\t\t\tunwritten = 1;\n\t\telse\n\t\t\tunwritten = 0;\n\n\t\text_debug(inode, \"remove ext %u:[%d]%d\\n\", ex_ee_block,\n\t\t\t  unwritten, ex_ee_len);\n\t\tpath[depth].p_ext = ex;\n\n\t\ta = ex_ee_block > start ? ex_ee_block : start;\n\t\tb = ex_ee_block+ex_ee_len - 1 < end ?\n\t\t\tex_ee_block+ex_ee_len - 1 : end;\n\n\t\text_debug(inode, \"  border %u:%u\\n\", a, b);\n\n\t\t\/* If this extent is beyond the end of the hole, skip it *\/\n\t\tif (end < ex_ee_block) {\n\t\t\t\/*\n\t\t\t * We're going to skip this extent and move to another,\n\t\t\t * so note that its first cluster is in use to avoid\n\t\t\t * freeing it when removing blocks.  Eventually, the\n\t\t\t * right edge of the truncated\/punched region will\n\t\t\t * be just to the left.\n\t\t\t *\/\n\t\t\tif (sbi->s_cluster_ratio > 1) {\n\t\t\t\tpblk = ext4_ext_pblock(ex);\n\t\t\t\tpartial->pclu = EXT4_B2C(sbi, pblk);\n\t\t\t\tpartial->state = nofree;\n\t\t\t}\n\t\t\tex--;\n\t\t\tex_ee_block = le32_to_cpu(ex->ee_block);\n\t\t\tex_ee_len = ext4_ext_get_actual_len(ex);\n\t\t\tcontinue;\n\t\t} else if (b != ex_ee_block + ex_ee_len - 1) {\n\t\t\tEXT4_ERROR_INODE(inode,\n\t\t\t\t\t \"can not handle truncate %u:%u \"\n\t\t\t\t\t \"on extent %u:%u\",\n\t\t\t\t\t start, end, ex_ee_block,\n\t\t\t\t\t ex_ee_block + ex_ee_len - 1);\n\t\t\terr = -EFSCORRUPTED;\n\t\t\tgoto out;\n\t\t} else if (a != ex_ee_block) {\n\t\t\t\/* remove tail of the extent *\/\n\t\t\tnum = a - ex_ee_block;\n\t\t} else {\n\t\t\t\/* remove whole extent: excellent! *\/\n\t\t\tnum = 0;\n\t\t}\n\t\t\/*\n\t\t * 3 for leaf, sb, and inode plus 2 (bmap and group\n\t\t * descriptor) for each block group; assume two block\n\t\t * groups plus ex_ee_len\/blocks_per_block_group for\n\t\t * the worst case\n\t\t *\/\n\t\tcredits = 7 + 2*(ex_ee_len\/EXT4_BLOCKS_PER_GROUP(inode->i_sb));\n\t\tif (ex == EXT_FIRST_EXTENT(eh)) {\n\t\t\tcorrect_index = 1;\n\t\t\tcredits += (ext_depth(inode)) + 1;\n\t\t}\n\t\tcredits += EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);\n\t\t\/*\n\t\t * We may end up freeing some index blocks and data from the\n\t\t * punched range. Note that partial clusters are accounted for\n\t\t * by ext4_free_data_revoke_credits().\n\t\t *\/\n\t\trevoke_credits =\n\t\t\text4_free_metadata_revoke_credits(inode->i_sb,\n\t\t\t\t\t\t\t  ext_depth(inode)) +\n\t\t\text4_free_data_revoke_credits(inode, b - a + 1);\n\n\t\terr = ext4_datasem_ensure_credits(handle, inode, credits,\n\t\t\t\t\t\t  credits, revoke_credits);\n\t\tif (err) {\n\t\t\tif (err > 0)\n\t\t\t\terr = -EAGAIN;\n\t\t\tgoto out;\n\t\t}\n\n\t\terr = ext4_ext_get_access(handle, inode, path + depth);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\terr = ext4_remove_blocks(handle, inode, ex, partial, a, b);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\tif (num == 0)\n\t\t\t\/* this extent is removed; mark slot entirely unused *\/\n\t\t\text4_ext_store_pblock(ex, 0);\n\n\t\tex->ee_len = cpu_to_le16(num);\n\t\t\/*\n\t\t * Do not mark unwritten if all the blocks in the\n\t\t * extent have been removed.\n\t\t *\/\n\t\tif (unwritten && num)\n\t\t\text4_ext_mark_unwritten(ex);\n\t\t\/*\n\t\t * If the extent was completely released,\n\t\t * we need to remove it from the leaf\n\t\t *\/\n\t\tif (num == 0) {\n\t\t\tif (end != EXT_MAX_BLOCKS - 1) {\n\t\t\t\t\/*\n\t\t\t\t * For hole punching, we need to scoot all the\n\t\t\t\t * extents up when an extent is removed so that\n\t\t\t\t * we dont have blank extents in the middle\n\t\t\t\t *\/\n\t\t\t\tmemmove(ex, ex+1, (EXT_LAST_EXTENT(eh) - ex) *\n\t\t\t\t\tsizeof(struct ext4_extent));\n\n\t\t\t\t\/* Now get rid of the one at the end *\/\n\t\t\t\tmemset(EXT_LAST_EXTENT(eh), 0,\n\t\t\t\t\tsizeof(struct ext4_extent));\n\t\t\t}\n\t\t\tle16_add_cpu(&eh->eh_entries, -1);\n\t\t}\n\n\t\terr = ext4_ext_dirty(handle, inode, path + depth);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\text_debug(inode, \"new extent: %u:%u:%llu\\n\", ex_ee_block, num,\n\t\t\t\text4_ext_pblock(ex));\n\t\tex--;\n\t\tex_ee_block = le32_to_cpu(ex->ee_block);\n\t\tex_ee_len = ext4_ext_get_actual_len(ex);\n\t}\n\n\tif (correct_index && eh->eh_entries)\n\t\terr = ext4_ext_correct_indexes(handle, inode, path);\n\n\t\/*\n\t * If there's a partial cluster and at least one extent remains in\n\t * the leaf, free the partial cluster if it isn't shared with the\n\t * current extent.  If it is shared with the current extent\n\t * we reset the partial cluster because we've reached the start of the\n\t * truncated\/punched region and we're done removing blocks.\n\t *\/\n\tif (partial->state == tofree && ex >= EXT_FIRST_EXTENT(eh)) {\n\t\tpblk = ext4_ext_pblock(ex) + ex_ee_len - 1;\n\t\tif (partial->pclu != EXT4_B2C(sbi, pblk)) {\n\t\t\tint flags = get_default_free_blocks_flags(inode);\n\n\t\t\tif (ext4_is_pending(inode, partial->lblk))\n\t\t\t\tflags |= EXT4_FREE_BLOCKS_RERESERVE_CLUSTER;\n\t\t\text4_free_blocks(handle, inode, NULL,\n\t\t\t\t\t EXT4_C2B(sbi, partial->pclu),\n\t\t\t\t\t sbi->s_cluster_ratio, flags);\n\t\t\tif (flags & EXT4_FREE_BLOCKS_RERESERVE_CLUSTER)\n\t\t\t\text4_rereserve_cluster(inode, partial->lblk);\n\t\t}\n\t\tpartial->state = initial;\n\t}\n\n\t\/* if this leaf is free, then we should\n\t * remove it from index block above *\/\n\tif (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL)\n\t\terr = ext4_ext_rm_idx(handle, inode, path, depth);\n\nout:\n\treturn err;\n}","target":0,"code_token_length":1866,"total_token_length":2102,"max_tokens_setting":4096}
+{"idx":94694,"func":"PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,\n\t\t\t\t\t\t   pjsip_transport_type_e type,\n\t\t\t\t\t\t   const pj_sockaddr_t *remote,\n\t\t\t\t\t\t   int addr_len,\n\t\t\t\t\t\t   const pjsip_tpselector *sel,\n\t\t\t\t\t\t   pjsip_tx_data *tdata,\n\t\t\t\t\t\t   pjsip_transport **tp)\n{\n    pjsip_tpfactory *factory;\n    pj_status_t status;\n\n    TRACE_((THIS_FILE,\"Acquiring transport type=%s, sel=%s remote=%s:%d\",\n\t\t       pjsip_transport_get_type_name(type),\n\t\t       print_tpsel_info(sel),\n\t\t       addr_string(remote),\n\t\t       pj_sockaddr_get_port(remote)));\n\n    pj_lock_acquire(mgr->lock);\n\n    \/* If transport is specified, then just use it if it is suitable\n     * for the destination.\n     *\/\n    if (sel && sel->type == PJSIP_TPSELECTOR_TRANSPORT &&\n\tsel->u.transport) \n    {\n\tpjsip_transport *seltp = sel->u.transport;\n\n\t\/* See if the transport is (not) suitable *\/\n\tif (seltp->key.type != type) {\n\t    pj_lock_release(mgr->lock);\n\t    TRACE_((THIS_FILE, \"Transport type in tpsel not matched\"));\n\t    return PJSIP_ETPNOTSUITABLE;\n\t}\n\n\t\/* Make sure the transport is not being destroyed *\/\n\tif (seltp->is_destroying) {\n\t    pj_lock_release(mgr->lock);\n\t    TRACE_((THIS_FILE,\"Transport to be acquired is being destroyed\"));\n\t    return PJ_ENOTFOUND;\n\t}\n\n\t\/* We could also verify that the destination address is reachable\n\t * from this transport (i.e. both are equal), but if application\n\t * has requested a specific transport to be used, assume that\n\t * it knows what to do.\n\t *\n\t * In other words, I don't think destination verification is a good\n\t * idea for now.\n\t *\/\n\n\t\/* Transport looks to be suitable to use, so just use it. *\/\n\tpjsip_transport_add_ref(seltp);\n\tpj_lock_release(mgr->lock);\n\t*tp = seltp;\n\n\tTRACE_((THIS_FILE, \"Transport %s acquired\", seltp->obj_name));\n\treturn PJ_SUCCESS;\n\n    } else {\n\n\t\/*\n\t * This is the \"normal\" flow, where application doesn't specify\n\t * specific transport to be used to send message to.\n\t * In this case, lookup the transport from the hash table.\n\t *\/\n\tpjsip_transport_key key;\n\tint key_len;\n\tpjsip_transport *tp_ref = NULL;\n\ttransport *tp_entry = NULL;\n\n\n\t\/* If listener is specified, verify that the listener type matches\n\t * the destination type.\n\t *\/\n\tif (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener)\n\t{\n\t    if (sel->u.listener->type != type) {\n\t\tpj_lock_release(mgr->lock);\n\t\tTRACE_((THIS_FILE, \"Listener type in tpsel not matched\"));\n\t\treturn PJSIP_ETPNOTSUITABLE;\n\t    }\n\t}\n\n\tif (!sel || sel->disable_connection_reuse == PJ_FALSE) {\n\t    pj_bzero(&key, sizeof(key));\n\t    key_len = sizeof(key.type) + addr_len;\n\n\t    \/* First try to get exact destination. *\/\n\t    key.type = type;\n\t    pj_memcpy(&key.rem_addr, remote, addr_len);\n\n\t    tp_entry = (transport *)pj_hash_get(mgr->table, &key, key_len,\n\t\t\t\t\t\tNULL);\n\t    if (tp_entry) {\n\t\ttransport *tp_iter = tp_entry;\n\t\tdo {\n\t\t    \/* Don't use transport being shutdown\/destroyed *\/\n\t\t    if (!tp_iter->tp->is_shutdown &&\n\t\t\t!tp_iter->tp->is_destroying)\n\t\t    {\n\t\t\tif ((type & PJSIP_TRANSPORT_SECURE) && tdata) {\n\t\t\t    \/* For secure transport, make sure tdata's\n\t\t\t     * destination host matches the transport's\n\t\t\t     * remote host.\n\t\t\t     *\/\n\t\t\t    if (pj_stricmp(&tdata->dest_info.name,\n\t\t\t\t  \t   &tp_iter->tp->remote_name.host))\n\t\t\t    {\n\t\t\t    \ttp_iter = tp_iter->next;\n\t\t\t    \tcontinue;\n\t\t\t    }\n\t\t\t}\n\n\t\t\tif (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&\n\t\t\t    sel->u.listener)\n\t\t\t{\n\t\t\t    \/* Match listener if selector is set *\/\n\t\t\t    if (tp_iter->tp->factory == sel->u.listener) {\n\t\t\t\ttp_ref = tp_iter->tp;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t} else {\n\t\t\t    tp_ref = tp_iter->tp;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t    tp_iter = tp_iter->next;\n\t\t} while (tp_iter != tp_entry);\n\t    }\n\t}\n\n\tif (tp_ref == NULL &&\n\t    (!sel || sel->disable_connection_reuse == PJ_FALSE))\n\t{\n\t    unsigned flag = pjsip_transport_get_flag_from_type(type);\n\t    const pj_sockaddr *remote_addr = (const pj_sockaddr*)remote;\n\n\n\t    \/* Ignore address for loop transports. *\/\n\t    if (type == PJSIP_TRANSPORT_LOOP ||\n\t\ttype == PJSIP_TRANSPORT_LOOP_DGRAM)\n\t    {\n\t\tpj_sockaddr *addr = &key.rem_addr;\n\n\t\tpj_bzero(addr, addr_len);\n\t\tkey_len = sizeof(key.type) + addr_len;\n\t\ttp_entry = (transport *) pj_hash_get(mgr->table, &key,\n\t\t\t\t\t\t     key_len, NULL);\n\t\tif (tp_entry) {\n\t\t    tp_ref = tp_entry->tp;\n\t\t}\n\t    }\n\t    \/* For datagram transports, try lookup with zero address.\n\t     *\/\n\t    else if (flag & PJSIP_TRANSPORT_DATAGRAM)\n\t    {\n\t\tpj_sockaddr *addr = &key.rem_addr;\n\n\t\tpj_bzero(addr, addr_len);\n\t\taddr->addr.sa_family = remote_addr->addr.sa_family;\n\n\t\tkey_len = sizeof(key.type) + addr_len;\n\t\ttp_entry = (transport *) pj_hash_get(mgr->table, &key,\n\t\t\t\t\t\t     key_len, NULL);\n\t\tif (tp_entry) {\n\t\t    tp_ref = tp_entry->tp;\n\t\t}\n\t    }\n\t}\n\n\t\/* If transport is found and listener is specified, verify listener *\/\n\telse if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&\n\t\t sel->u.listener && tp_ref->factory != sel->u.listener)\n\t{\n\t    tp_ref = NULL;\n\t    \/* This will cause a new transport to be created which will be a\n\t     * 'duplicate' of the existing transport (same type & remote addr,\n\t     * but different factory).\n\t     *\/\n\t    TRACE_((THIS_FILE, \"Transport found but from different listener\"));\n\t}\n\n\tif (tp_ref!=NULL && !tp_ref->is_shutdown && !tp_ref->is_destroying) {\n\t    \/*\n\t     * Transport found!\n\t     *\/\n\t    pjsip_transport_add_ref(tp_ref);\n\t    pj_lock_release(mgr->lock);\n\t    *tp = tp_ref;\n\n\t    TRACE_((THIS_FILE, \"Transport %s acquired\", tp_ref->obj_name));\n\t    return PJ_SUCCESS;\n\t}\n\n\n\t\/*\n\t * Either transport not found, or we don't want to use the existing\n\t * transport (such as in the case of different factory or\n\t * if connection reuse is disabled). So we need to create one,\n\t * find factory that can create such transport.\n\t *\n\t * If there's an existing transport, its place in the hash table\n\t * will be replaced by this new one. And eventually the existing\n\t * transport will still be freed (by application or #1774).\n\t *\/\n\tif (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener)\n\t{\n\t    \/* Application has requested that a specific listener is to\n\t     * be used.\n\t     *\/\n\n\t    \/* Verify that the listener type matches the destination type *\/\n\t    \/* Already checked above. *\/\n\t    \/*\n\t    if (sel->u.listener->type != type) {\n\t\tpj_lock_release(mgr->lock);\n\t\treturn PJSIP_ETPNOTSUITABLE;\n\t    }\n\t    *\/\n\n\t    \/* We'll use this listener to create transport *\/\n\t    factory = sel->u.listener;\n\n\t    \/* Verify if listener is still valid *\/\n\t    if (!pjsip_tpmgr_is_tpfactory_valid(mgr, factory)) {\n\t\tpj_lock_release(mgr->lock);\n\t\tPJ_LOG(3,(THIS_FILE, \"Specified factory for creating \"\n\t\t\t\t     \"transport is not found\"));\n\t\treturn PJ_ENOTFOUND;\n\t    }\n\n\t} else {\n\n\t    \/* Find factory with type matches the destination type *\/\n\t    factory = mgr->factory_list.next;\n\t    while (factory != &mgr->factory_list) {\n\t\tif (factory->type == type)\n\t\t    break;\n\t\tfactory = factory->next;\n\t    }\n\n\t    if (factory == &mgr->factory_list) {\n\t\t\/* No factory can create the transport! *\/\n\t\tpj_lock_release(mgr->lock);\n\t\tTRACE_((THIS_FILE, \"No suitable factory was found either\"));\n\t\treturn PJSIP_EUNSUPTRANSPORT;\n\t    }\n\t}\n    }\n\n    TRACE_((THIS_FILE, \"Creating new transport from factory\"));\n\n    \/* Request factory to create transport. *\/\n    if (factory->create_transport2) {\n\tstatus = factory->create_transport2(factory, mgr, mgr->endpt,\n\t\t\t\t\t    (const pj_sockaddr*) remote,\n\t\t\t\t\t    addr_len, tdata, tp);\n    } else {\n\tstatus = factory->create_transport(factory, mgr, mgr->endpt,\n\t\t\t\t\t   (const pj_sockaddr*) remote,\n\t\t\t\t\t   addr_len, tp);\n    }\n    if (status == PJ_SUCCESS) {\n\tPJ_ASSERT_ON_FAIL(tp!=NULL,\n\t    {pj_lock_release(mgr->lock); return PJ_EBUG;});\n\tpjsip_transport_add_ref(*tp);\n\t(*tp)->factory = factory;\n    }\n    pj_lock_release(mgr->lock);\n    return status;\n}","target":0,"code_token_length":2098,"total_token_length":2334,"max_tokens_setting":4096}
+{"idx":238456,"func":"struct _mdi *_WM_ParseNewXmi(uint8_t *xmi_data, uint32_t xmi_size) {\n    struct _mdi *xmi_mdi = NULL;\n    uint32_t xmi_tmpdata = 0;\n    uint8_t xmi_formcnt = 0;\n    uint32_t xmi_catlen = 0;\n    uint32_t xmi_subformlen = 0;\n    uint32_t i = 0;\n    uint32_t j = 0;\n\n    uint32_t xmi_evntlen = 0;\n    uint32_t xmi_divisions = 60;\n    uint32_t xmi_tempo = 500000;\n    uint32_t xmi_sample_count = 0;\n    float xmi_sample_count_f = 0.0;\n    float xmi_sample_remainder = 0.0;\n    float xmi_samples_per_delta_f = 0.0;\n    uint8_t xmi_ch = 0;\n    uint8_t xmi_note = 0;\n    uint32_t *xmi_notelen = NULL;\n\n    uint32_t setup_ret = 0;\n    uint32_t xmi_delta = 0;\n    uint32_t xmi_lowestdelta = 0;\n\n    uint32_t xmi_evnt_cnt = 0;\n\n\n    if (memcmp(xmi_data,\"FORM\",4)) {\n        _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n        return NULL;\n    }\n\n    xmi_data += 4;\n    xmi_size -= 4;\n\n    xmi_tmpdata = *xmi_data++ << 24;\n    xmi_tmpdata |= *xmi_data++ << 16;\n    xmi_tmpdata |= *xmi_data++ << 8;\n    xmi_tmpdata |= *xmi_data++;\n    xmi_size -= 4;\n\n    if (memcmp(xmi_data,\"XDIRINFO\",8)) {\n        _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n        return NULL;\n    }\n    xmi_data += 8;\n    xmi_size -= 8;\n\n    \/*\n     0x00 0x00 0x00 0x02 at this point are unknown\n     so skip over them\n     *\/\n    xmi_data += 4;\n    xmi_size -= 4;\n\n    xmi_formcnt = *xmi_data++;\n    if (xmi_formcnt == 0) {\n        _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n        return NULL;\n    }\n    xmi_size--;\n\n    \/*\n     at this stage unsure if remaining data in\n     this section means anything\n     *\/\n    xmi_tmpdata -= 13;\n    xmi_data += xmi_tmpdata;\n    xmi_size -= xmi_tmpdata;\n\n    \/* FIXME: Check: may not even need to process CAT information *\/\n    if (memcmp(xmi_data,\"CAT \",4)) {\n        _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n        return NULL;\n    }\n    xmi_data += 4;\n    xmi_size -= 4;\n\n    xmi_catlen = *xmi_data++ << 24;\n    xmi_catlen |= *xmi_data++ << 16;\n    xmi_catlen |= *xmi_data++ << 8;\n    xmi_catlen |= *xmi_data++;\n    xmi_size -= 4;\n\n    UNUSED(xmi_catlen);\n\n    if (memcmp(xmi_data,\"XMID\",4)) {\n        _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n        return NULL;\n    }\n    xmi_data += 4;\n    xmi_size -= 4;\n\n    xmi_mdi = _WM_initMDI();\n    _WM_midi_setup_divisions(xmi_mdi, xmi_divisions);\n    _WM_midi_setup_tempo(xmi_mdi, xmi_tempo);\n\n    xmi_samples_per_delta_f = _WM_GetSamplesPerTick(xmi_divisions, xmi_tempo);\n\n    xmi_notelen = malloc(sizeof(uint32_t) * 16 * 128);\n    memset(xmi_notelen, 0, (sizeof(uint32_t) * 16 * 128));\n\n    for (i = 0; i < xmi_formcnt; i++) {\n        if (memcmp(xmi_data,\"FORM\",4)) {\n            _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n            goto _xmi_end;\n        }\n        xmi_data += 4;\n        xmi_size -= 4;\n\n        xmi_subformlen = *xmi_data++ << 24;\n        xmi_subformlen |= *xmi_data++ << 16;\n        xmi_subformlen |= *xmi_data++ << 8;\n        xmi_subformlen |= *xmi_data++;\n        xmi_size -= 4;\n\n        if (memcmp(xmi_data,\"XMID\",4)) {\n            _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n            goto _xmi_end;\n        }\n        xmi_data += 4;\n        xmi_size -= 4;\n        xmi_subformlen -= 4;\n\n        do {\n            if (!memcmp(xmi_data,\"TIMB\",4)) {\n                xmi_data += 4;\n\n                xmi_tmpdata = *xmi_data++ << 24;\n                xmi_tmpdata |= *xmi_data++ << 16;\n                xmi_tmpdata |= *xmi_data++ << 8;\n                xmi_tmpdata |= *xmi_data++;\n                xmi_data += xmi_tmpdata;\n                xmi_size -= (8 + xmi_tmpdata);\n                xmi_subformlen -= (8 + xmi_tmpdata);\n\n            } else if (!memcmp(xmi_data,\"RBRN\",4)) {\n                xmi_data += 4;\n\n                xmi_tmpdata = *xmi_data++ << 24;\n                xmi_tmpdata |= *xmi_data++ << 16;\n                xmi_tmpdata |= *xmi_data++ << 8;\n                xmi_tmpdata |= *xmi_data++;\n                xmi_data += xmi_tmpdata;\n                xmi_size -= (8 + xmi_tmpdata);\n                xmi_subformlen -= (8 + xmi_tmpdata);\n\n            } else if (!memcmp(xmi_data,\"EVNT\",4)) {\n                xmi_data += 4;\n\n                xmi_evnt_cnt++;\n\n                xmi_evntlen = *xmi_data++ << 24;\n                xmi_evntlen |= *xmi_data++ << 16;\n                xmi_evntlen |= *xmi_data++ << 8;\n                xmi_evntlen |= *xmi_data++;\n                xmi_size -= 8;\n                xmi_subformlen -= 8;\n\n                do {\n                    if (*xmi_data < 0x80) {\n                        xmi_delta = 0;\n                        if (*xmi_data > 0x7f) {\n                            while (*xmi_data > 0x7f) {\n                                xmi_delta = (xmi_delta << 7) | (*xmi_data++ & 0x7f);\n                                xmi_size--;\n                                xmi_evntlen--;\n                                xmi_subformlen--;\n                            }\n                        }\n                        xmi_delta = (xmi_delta << 7) | (*xmi_data++ & 0x7f);\n                        xmi_size--;\n                        xmi_evntlen--;\n                        xmi_subformlen--;\n\n                        do {\n                            if ((xmi_lowestdelta != 0) && (xmi_lowestdelta <= xmi_delta)) {\n                                xmi_tmpdata = xmi_lowestdelta;\n                            } else {\n                                xmi_tmpdata = xmi_delta;\n                            }\n\n                            xmi_sample_count_f= (((float) xmi_tmpdata * xmi_samples_per_delta_f) + xmi_sample_remainder);\n\n                            xmi_sample_count = (uint32_t) xmi_sample_count_f;\n                            xmi_sample_remainder = xmi_sample_count_f - (float) xmi_sample_count;\n\n                            xmi_mdi->events[xmi_mdi->event_count - 1].samples_to_next += xmi_sample_count;\n                            xmi_mdi->extra_info.approx_total_samples += xmi_sample_count;\n\n                            xmi_lowestdelta = 0;\n\n                            for (j = 0; j < (16*128); j++) {\n                                if (xmi_notelen[j] == 0) continue;\n\n                                xmi_notelen[j] -= xmi_tmpdata;\n\n                                if (xmi_notelen[j] == 0) {\n                                    xmi_ch = j \/ 128;\n                                    xmi_note = j - (xmi_ch * 128);\n                                    _WM_midi_setup_noteoff(xmi_mdi, xmi_ch, xmi_note, 0);\n                                } else {\n                                    if ((xmi_lowestdelta == 0) || (xmi_lowestdelta > xmi_notelen[j])) {\n                                        xmi_lowestdelta = xmi_notelen[j];\n                                    }\n                                }\n                            }\n                            xmi_delta -= xmi_tmpdata;\n                        } while (xmi_delta);\n\n                    } else {\n                        if ((xmi_data[0] == 0xff) && (xmi_data[1] == 0x51) && (xmi_data[2] == 0x03)) {\n                             setup_ret = 6;\n                             goto _XMI_Next_Event;\n                         }\n                        if ((setup_ret = _WM_SetupMidiEvent(xmi_mdi,xmi_data, xmi_size, 0)) == 0) {\n                             goto _xmi_end;\n                         }\n \n                        if ((*xmi_data & 0xf0) == 0x90) {\n                            xmi_ch = *xmi_data & 0x0f;\n                            xmi_note = xmi_data[1];\n                            xmi_data += setup_ret;\n                            xmi_size -= setup_ret;\n                            xmi_evntlen -= setup_ret;\n                            xmi_subformlen -= setup_ret;\n\n                            xmi_tmpdata = 0;\n\n                            if (*xmi_data > 0x7f) {\n                                while (*xmi_data > 0x7f) {\n                                    xmi_tmpdata = (xmi_tmpdata << 7) | (*xmi_data++ & 0x7f);\n                                    xmi_size--;\n                                    xmi_evntlen--;\n                                    xmi_subformlen--;\n                                }\n                            }\n                            xmi_tmpdata = (xmi_tmpdata << 7) | (*xmi_data++ & 0x7f);\n                            xmi_size--;\n                            xmi_evntlen--;\n                            xmi_subformlen--;\n\n                            xmi_notelen[128 * xmi_ch + xmi_note] = xmi_tmpdata;\n                            if ((xmi_tmpdata > 0) && ((xmi_lowestdelta == 0) || (xmi_tmpdata < xmi_lowestdelta))) {\n                                xmi_lowestdelta = xmi_tmpdata;\n                            }\n\n                        } else {\n                        _XMI_Next_Event:\n                            xmi_data += setup_ret;\n                            xmi_size -= setup_ret;\n                            xmi_evntlen -= setup_ret;\n                            xmi_subformlen -= setup_ret;\n                        }\n                    }\n\n                } while (xmi_evntlen);\n\n            } else {\n                _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);\n                goto _xmi_end;\n            }\n\n        } while (xmi_subformlen);\n    }\n\n    if ((xmi_mdi->reverb = _WM_init_reverb(_WM_SampleRate, _WM_reverb_room_width, _WM_reverb_room_length, _WM_reverb_listen_posx, _WM_reverb_listen_posy)) == NULL) {\n        _WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, \"to init reverb\", 0);\n        goto _xmi_end;\n    }\n    xmi_mdi->extra_info.current_sample = 0;\n    xmi_mdi->current_event = &xmi_mdi->events[0];\n    xmi_mdi->samples_to_mix = 0;\n    xmi_mdi->note = NULL;\n    \/* More than 1 event form in XMI means treat as type 2 *\/\n    if (xmi_evnt_cnt > 1) {\n        xmi_mdi->is_type2 = 1;\n    }\n    _WM_ResetToStart(xmi_mdi);\n\n_xmi_end:\n    if (xmi_notelen != NULL) free(xmi_notelen);\n    if (xmi_mdi->reverb) return (xmi_mdi);\n    _WM_freeMDI(xmi_mdi);\n    return NULL;\n}\n","target":0,"code_token_length":2810,"total_token_length":3046,"max_tokens_setting":4096}
+{"idx":354228,"func":"static int ssl_scan_serverhello_tlsext(SSL *s, PACKET *pkt, int *al)\n{\n    unsigned int length, type, size;\n    int tlsext_servername = 0;\n    int renegotiate_seen = 0;\n\n#ifndef OPENSSL_NO_NEXTPROTONEG\n    s->s3->next_proto_neg_seen = 0;\n#endif\n    s->tlsext_ticket_expected = 0;\n\n    OPENSSL_free(s->s3->alpn_selected);\n    s->s3->alpn_selected = NULL;\n#ifndef OPENSSL_NO_HEARTBEATS\n    s->tlsext_heartbeat &= ~(SSL_DTLSEXT_HB_ENABLED |\n                             SSL_DTLSEXT_HB_DONT_SEND_REQUESTS);\n#endif\n\n    s->s3->flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC;\n\n    s->s3->flags &= ~TLS1_FLAGS_RECEIVED_EXTMS;\n\n    if (!PACKET_get_net_2(pkt, &length))\n        goto ri_check;\n\n    if (PACKET_remaining(pkt) != length) {\n        *al = SSL_AD_DECODE_ERROR;\n        return 0;\n    }\n\n    if (!tls1_check_duplicate_extensions(pkt)) {\n        *al = SSL_AD_DECODE_ERROR;\n        return 0;\n    }\n\n    while (PACKET_get_net_2(pkt, &type) && PACKET_get_net_2(pkt, &size)) {\n        const unsigned char *data;\n        PACKET spkt;\n\n        if (!PACKET_get_sub_packet(pkt, &spkt, size)\n            || !PACKET_peek_bytes(&spkt, &data, size))\n            goto ri_check;\n\n        if (s->tlsext_debug_cb)\n            s->tlsext_debug_cb(s, 1, type, data, size, s->tlsext_debug_arg);\n\n        if (type == TLSEXT_TYPE_renegotiate) {\n            if (!ssl_parse_serverhello_renegotiate_ext(s, &spkt, al))\n                return 0;\n            renegotiate_seen = 1;\n        } else if (s->version == SSL3_VERSION) {\n        } else if (type == TLSEXT_TYPE_server_name) {\n            if (s->tlsext_hostname == NULL || size > 0) {\n                *al = TLS1_AD_UNRECOGNIZED_NAME;\n                return 0;\n            }\n            tlsext_servername = 1;\n        }\n#ifndef OPENSSL_NO_EC\n        else if (type == TLSEXT_TYPE_ec_point_formats) {\n            unsigned int ecpointformatlist_length;\n            if (!PACKET_get_1(&spkt, &ecpointformatlist_length)\n                || ecpointformatlist_length != size - 1) {\n                *al = TLS1_AD_DECODE_ERROR;\n                return 0;\n            }\n            if (!s->hit) {\n                s->session->tlsext_ecpointformatlist_length = 0;\n                OPENSSL_free(s->session->tlsext_ecpointformatlist);\n                if ((s->session->tlsext_ecpointformatlist =\n                     OPENSSL_malloc(ecpointformatlist_length)) == NULL) {\n                    *al = TLS1_AD_INTERNAL_ERROR;\n                    return 0;\n                }\n                s->session->tlsext_ecpointformatlist_length =\n                    ecpointformatlist_length;\n                if (!PACKET_copy_bytes(&spkt,\n                                       s->session->tlsext_ecpointformatlist,\n                                       ecpointformatlist_length)) {\n                    *al = TLS1_AD_DECODE_ERROR;\n                    return 0;\n                }\n\n            }\n        }\n#endif                          \/* OPENSSL_NO_EC *\/\n\n        else if (type == TLSEXT_TYPE_session_ticket) {\n            if (s->tls_session_ticket_ext_cb &&\n                !s->tls_session_ticket_ext_cb(s, data, size,\n                                              s->tls_session_ticket_ext_cb_arg))\n            {\n                *al = TLS1_AD_INTERNAL_ERROR;\n                return 0;\n            }\n            if (!tls_use_ticket(s) || (size > 0)) {\n                *al = TLS1_AD_UNSUPPORTED_EXTENSION;\n                return 0;\n            }\n            s->tlsext_ticket_expected = 1;\n        } else if (type == TLSEXT_TYPE_status_request) {\n            \/*\n             * MUST be empty and only sent if we've requested a status\n             * request message.\n             *\/\n            if ((s->tlsext_status_type == -1) || (size > 0)) {\n                *al = TLS1_AD_UNSUPPORTED_EXTENSION;\n                return 0;\n            }\n            \/* Set flag to expect CertificateStatus message *\/\n            s->tlsext_status_expected = 1;\n        }\n#ifndef OPENSSL_NO_CT\n        \/*\n         * Only take it if we asked for it - i.e if there is no CT validation\n         * callback set, then a custom extension MAY be processing it, so we\n         * need to let control continue to flow to that.\n         *\/\n        else if (type == TLSEXT_TYPE_signed_certificate_timestamp &&\n                 s->ct_validation_callback != NULL) {\n            \/* Simply copy it off for later processing *\/\n            if (s->tlsext_scts != NULL) {\n                OPENSSL_free(s->tlsext_scts);\n                s->tlsext_scts = NULL;\n            }\n            s->tlsext_scts_len = size;\n            if (size > 0) {\n                s->tlsext_scts = OPENSSL_malloc(size);\n                if (s->tlsext_scts == NULL) {\n                    *al = TLS1_AD_INTERNAL_ERROR;\n                    return 0;\n                }\n                memcpy(s->tlsext_scts, data, size);\n            }\n        }\n#endif\n#ifndef OPENSSL_NO_NEXTPROTONEG\n        else if (type == TLSEXT_TYPE_next_proto_neg &&\n                 s->s3->tmp.finish_md_len == 0) {\n            unsigned char *selected;\n            unsigned char selected_len;\n            \/* We must have requested it. *\/\n            if (s->ctx->next_proto_select_cb == NULL) {\n                *al = TLS1_AD_UNSUPPORTED_EXTENSION;\n                return 0;\n            }\n            \/* The data must be valid *\/\n            if (!ssl_next_proto_validate(&spkt)) {\n                *al = TLS1_AD_DECODE_ERROR;\n                return 0;\n            }\n            if (s->ctx->next_proto_select_cb(s, &selected, &selected_len, data,\n                                             size,\n                                             s->\n                                             ctx->next_proto_select_cb_arg) !=\n                SSL_TLSEXT_ERR_OK) {\n                *al = TLS1_AD_INTERNAL_ERROR;\n                return 0;\n            }\n            \/*\n             * Could be non-NULL if server has sent multiple NPN extensions in\n             * a single Serverhello\n             *\/\n            OPENSSL_free(s->next_proto_negotiated);\n            s->next_proto_negotiated = OPENSSL_malloc(selected_len);\n            if (s->next_proto_negotiated == NULL) {\n                *al = TLS1_AD_INTERNAL_ERROR;\n                return 0;\n            }\n            memcpy(s->next_proto_negotiated, selected, selected_len);\n            s->next_proto_negotiated_len = selected_len;\n            s->s3->next_proto_neg_seen = 1;\n        }\n#endif\n\n        else if (type == TLSEXT_TYPE_application_layer_protocol_negotiation) {\n            unsigned len;\n            \/* We must have requested it. *\/\n            if (!s->s3->alpn_sent) {\n                *al = TLS1_AD_UNSUPPORTED_EXTENSION;\n                return 0;\n            }\n            \/*-\n             * The extension data consists of:\n             *   uint16 list_length\n             *   uint8 proto_length;\n             *   uint8 proto[proto_length];\n             *\/\n            if (!PACKET_get_net_2(&spkt, &len)\n                || PACKET_remaining(&spkt) != len || !PACKET_get_1(&spkt, &len)\n                || PACKET_remaining(&spkt) != len) {\n                *al = TLS1_AD_DECODE_ERROR;\n                return 0;\n            }\n            OPENSSL_free(s->s3->alpn_selected);\n            s->s3->alpn_selected = OPENSSL_malloc(len);\n            if (s->s3->alpn_selected == NULL) {\n                *al = TLS1_AD_INTERNAL_ERROR;\n                return 0;\n            }\n            if (!PACKET_copy_bytes(&spkt, s->s3->alpn_selected, len)) {\n                *al = TLS1_AD_DECODE_ERROR;\n                return 0;\n            }\n            s->s3->alpn_selected_len = len;\n        }\n#ifndef OPENSSL_NO_HEARTBEATS\n        else if (SSL_IS_DTLS(s) && type == TLSEXT_TYPE_heartbeat) {\n            unsigned int hbtype;\n            if (!PACKET_get_1(&spkt, &hbtype)) {\n                *al = SSL_AD_DECODE_ERROR;\n                return 0;\n            }\n            switch (hbtype) {\n            case 0x01:         \/* Server allows us to send HB requests *\/\n                s->tlsext_heartbeat |= SSL_DTLSEXT_HB_ENABLED;\n                break;\n            case 0x02:         \/* Server doesn't accept HB requests *\/\n                s->tlsext_heartbeat |= SSL_DTLSEXT_HB_ENABLED;\n                s->tlsext_heartbeat |= SSL_DTLSEXT_HB_DONT_SEND_REQUESTS;\n                break;\n            default:\n                *al = SSL_AD_ILLEGAL_PARAMETER;\n                return 0;\n            }\n        }\n#endif\n#ifndef OPENSSL_NO_SRTP\n        else if (SSL_IS_DTLS(s) && type == TLSEXT_TYPE_use_srtp) {\n            if (ssl_parse_serverhello_use_srtp_ext(s, &spkt, al))\n                return 0;\n        }\n#endif\n        else if (type == TLSEXT_TYPE_encrypt_then_mac) {\n            \/* Ignore if inappropriate ciphersuite *\/\n            if (s->s3->tmp.new_cipher->algorithm_mac != SSL_AEAD\n                && s->s3->tmp.new_cipher->algorithm_enc != SSL_RC4)\n                s->s3->flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC;\n        } else if (type == TLSEXT_TYPE_extended_master_secret) {\n            s->s3->flags |= TLS1_FLAGS_RECEIVED_EXTMS;\n            if (!s->hit)\n                s->session->flags |= SSL_SESS_FLAG_EXTMS;\n        }\n        \/*\n         * If this extension type was not otherwise handled, but matches a\n         * custom_cli_ext_record, then send it to the c callback\n         *\/\n        else if (custom_ext_parse(s, 0, type, data, size, al) <= 0)\n            return 0;\n    }\n\n    if (PACKET_remaining(pkt) != 0) {\n        *al = SSL_AD_DECODE_ERROR;\n        return 0;\n    }\n\n    if (!s->hit && tlsext_servername == 1) {\n        if (s->tlsext_hostname) {\n            if (s->session->tlsext_hostname == NULL) {\n                s->session->tlsext_hostname =\n                    OPENSSL_strdup(s->tlsext_hostname);\n                if (!s->session->tlsext_hostname) {\n                    *al = SSL_AD_UNRECOGNIZED_NAME;\n                    return 0;\n                }\n            } else {\n                *al = SSL_AD_DECODE_ERROR;\n                return 0;\n            }\n        }\n    }\n\n ri_check:\n\n    \/*\n     * Determine if we need to see RI. Strictly speaking if we want to avoid\n     * an attack we should *always* see RI even on initial server hello\n     * because the client doesn't see any renegotiation during an attack.\n     * However this would mean we could not connect to any server which\n     * doesn't support RI so for the immediate future tolerate RI absence\n     *\/\n    if (!renegotiate_seen && !(s->options & SSL_OP_LEGACY_SERVER_CONNECT)\n        && !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {\n        *al = SSL_AD_HANDSHAKE_FAILURE;\n        SSLerr(SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT,\n               SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);\n        return 0;\n    }\n\n    if (s->hit) {\n        \/*\n         * Check extended master secret extension is consistent with\n         * original session.\n         *\/\n        if (!(s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) !=\n            !(s->session->flags & SSL_SESS_FLAG_EXTMS)) {\n            *al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT, SSL_R_INCONSISTENT_EXTMS);\n            return 0;\n        }\n    }\n\n    return 1;\n}","target":1,"code_token_length":2709,"total_token_length":2945,"max_tokens_setting":4096}
+{"idx":122731,"func":"int ext4_map_blocks(handle_t *handle, struct inode *inode,\n\t\t    struct ext4_map_blocks *map, int flags)\n{\n\tstruct extent_status es;\n\tint retval;\n\tint ret = 0;\n#ifdef ES_AGGRESSIVE_TEST\n\tstruct ext4_map_blocks orig_map;\n\n\tmemcpy(&orig_map, map, sizeof(*map));\n#endif\n\n\tmap->m_flags = 0;\n\text_debug(\"ext4_map_blocks(): inode %lu, flag %d, max_blocks %u,\"\n\t\t  \"logical block %lu\\n\", inode->i_ino, flags, map->m_len,\n\t\t  (unsigned long) map->m_lblk);\n\n\t\/*\n\t * ext4_map_blocks returns an int, and m_len is an unsigned int\n\t *\/\n\tif (unlikely(map->m_len > INT_MAX))\n\t\tmap->m_len = INT_MAX;\n\n\t\/* We can handle the block number less than EXT_MAX_BLOCKS *\/\n\tif (unlikely(map->m_lblk >= EXT_MAX_BLOCKS))\n\t\treturn -EFSCORRUPTED;\n\n\t\/* Lookup extent status tree firstly *\/\n\tif (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {\n\t\tif (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) {\n\t\t\tmap->m_pblk = ext4_es_pblock(&es) +\n\t\t\t\t\tmap->m_lblk - es.es_lblk;\n\t\t\tmap->m_flags |= ext4_es_is_written(&es) ?\n\t\t\t\t\tEXT4_MAP_MAPPED : EXT4_MAP_UNWRITTEN;\n\t\t\tretval = es.es_len - (map->m_lblk - es.es_lblk);\n\t\t\tif (retval > map->m_len)\n\t\t\t\tretval = map->m_len;\n\t\t\tmap->m_len = retval;\n\t\t} else if (ext4_es_is_delayed(&es) || ext4_es_is_hole(&es)) {\n\t\t\tmap->m_pblk = 0;\n\t\t\tretval = es.es_len - (map->m_lblk - es.es_lblk);\n\t\t\tif (retval > map->m_len)\n\t\t\t\tretval = map->m_len;\n\t\t\tmap->m_len = retval;\n\t\t\tretval = 0;\n\t\t} else {\n\t\t\tBUG_ON(1);\n\t\t}\n#ifdef ES_AGGRESSIVE_TEST\n\t\text4_map_blocks_es_recheck(handle, inode, map,\n\t\t\t\t\t   &orig_map, flags);\n#endif\n\t\tgoto found;\n\t}\n\n\t\/*\n\t * Try to see if we can get the block without requesting a new\n\t * file system block.\n\t *\/\n\tdown_read(&EXT4_I(inode)->i_data_sem);\n\tif (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {\n\t\tretval = ext4_ext_map_blocks(handle, inode, map, flags &\n\t\t\t\t\t     EXT4_GET_BLOCKS_KEEP_SIZE);\n\t} else {\n\t\tretval = ext4_ind_map_blocks(handle, inode, map, flags &\n\t\t\t\t\t     EXT4_GET_BLOCKS_KEEP_SIZE);\n\t}\n\tif (retval > 0) {\n\t\tunsigned int status;\n\n\t\tif (unlikely(retval != map->m_len)) {\n\t\t\text4_warning(inode->i_sb,\n\t\t\t\t     \"ES len assertion failed for inode \"\n\t\t\t\t     \"%lu: retval %d != map->m_len %d\",\n\t\t\t\t     inode->i_ino, retval, map->m_len);\n\t\t\tWARN_ON(1);\n\t\t}\n\n\t\tstatus = map->m_flags & EXT4_MAP_UNWRITTEN ?\n\t\t\t\tEXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;\n\t\tif (!(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) &&\n\t\t    !(status & EXTENT_STATUS_WRITTEN) &&\n\t\t    ext4_find_delalloc_range(inode, map->m_lblk,\n\t\t\t\t\t     map->m_lblk + map->m_len - 1))\n\t\t\tstatus |= EXTENT_STATUS_DELAYED;\n\t\tret = ext4_es_insert_extent(inode, map->m_lblk,\n\t\t\t\t\t    map->m_len, map->m_pblk, status);\n\t\tif (ret < 0)\n\t\t\tretval = ret;\n\t}\n\tup_read((&EXT4_I(inode)->i_data_sem));\n\nfound:\n\tif (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {\n\t\tret = check_block_validity(inode, map);\n\t\tif (ret != 0)\n\t\t\treturn ret;\n\t}\n\n\t\/* If it is only a block(s) look up *\/\n\tif ((flags & EXT4_GET_BLOCKS_CREATE) == 0)\n\t\treturn retval;\n\n\t\/*\n\t * Returns if the blocks have already allocated\n\t *\n\t * Note that if blocks have been preallocated\n\t * ext4_ext_get_block() returns the create = 0\n\t * with buffer head unmapped.\n\t *\/\n\tif (retval > 0 && map->m_flags & EXT4_MAP_MAPPED)\n\t\t\/*\n\t\t * If we need to convert extent to unwritten\n\t\t * we continue and do the actual work in\n\t\t * ext4_ext_map_blocks()\n\t\t *\/\n\t\tif (!(flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN))\n\t\t\treturn retval;\n\n\t\/*\n\t * Here we clear m_flags because after allocating an new extent,\n\t * it will be set again.\n\t *\/\n\tmap->m_flags &= ~EXT4_MAP_FLAGS;\n\n\t\/*\n\t * New blocks allocate and\/or writing to unwritten extent\n\t * will possibly result in updating i_data, so we take\n\t * the write lock of i_data_sem, and call get_block()\n\t * with create == 1 flag.\n\t *\/\n\tdown_write(&EXT4_I(inode)->i_data_sem);\n\n\t\/*\n\t * We need to check for EXT4 here because migrate\n\t * could have changed the inode type in between\n\t *\/\n\tif (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {\n\t\tretval = ext4_ext_map_blocks(handle, inode, map, flags);\n\t} else {\n\t\tretval = ext4_ind_map_blocks(handle, inode, map, flags);\n\n\t\tif (retval > 0 && map->m_flags & EXT4_MAP_NEW) {\n\t\t\t\/*\n\t\t\t * We allocated new blocks which will result in\n\t\t\t * i_data's format changing.  Force the migrate\n\t\t\t * to fail by clearing migrate flags\n\t\t\t *\/\n\t\t\text4_clear_inode_state(inode, EXT4_STATE_EXT_MIGRATE);\n\t\t}\n\n\t\t\/*\n\t\t * Update reserved blocks\/metadata blocks after successful\n\t\t * block allocation which had been deferred till now. We don't\n\t\t * support fallocate for non extent files. So we can update\n\t\t * reserve space here.\n\t\t *\/\n\t\tif ((retval > 0) &&\n\t\t\t(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE))\n\t\t\text4_da_update_reserve_space(inode, retval, 1);\n\t}\n\n\tif (retval > 0) {\n\t\tunsigned int status;\n\n\t\tif (unlikely(retval != map->m_len)) {\n\t\t\text4_warning(inode->i_sb,\n\t\t\t\t     \"ES len assertion failed for inode \"\n\t\t\t\t     \"%lu: retval %d != map->m_len %d\",\n\t\t\t\t     inode->i_ino, retval, map->m_len);\n\t\t\tWARN_ON(1);\n\t\t}\n\n\t\t\/*\n\t\t * We have to zeroout blocks before inserting them into extent\n\t\t * status tree. Otherwise someone could look them up there and\n\t\t * use them before they are really zeroed.\n\t\t *\/\n\t\tif (flags & EXT4_GET_BLOCKS_ZERO &&\n\t\t    map->m_flags & EXT4_MAP_MAPPED &&\n\t\t    map->m_flags & EXT4_MAP_NEW) {\n\t\t\tret = ext4_issue_zeroout(inode, map->m_lblk,\n\t\t\t\t\t\t map->m_pblk, map->m_len);\n\t\t\tif (ret) {\n\t\t\t\tretval = ret;\n\t\t\t\tgoto out_sem;\n\t\t\t}\n\t\t}\n\n\t\t\/*\n\t\t * If the extent has been zeroed out, we don't need to update\n\t\t * extent status tree.\n\t\t *\/\n\t\tif ((flags & EXT4_GET_BLOCKS_PRE_IO) &&\n\t\t    ext4_es_lookup_extent(inode, map->m_lblk, &es)) {\n\t\t\tif (ext4_es_is_written(&es))\n\t\t\t\tgoto out_sem;\n\t\t}\n\t\tstatus = map->m_flags & EXT4_MAP_UNWRITTEN ?\n\t\t\t\tEXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;\n\t\tif (!(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) &&\n\t\t    !(status & EXTENT_STATUS_WRITTEN) &&\n\t\t    ext4_find_delalloc_range(inode, map->m_lblk,\n\t\t\t\t\t     map->m_lblk + map->m_len - 1))\n\t\t\tstatus |= EXTENT_STATUS_DELAYED;\n\t\tret = ext4_es_insert_extent(inode, map->m_lblk, map->m_len,\n\t\t\t\t\t    map->m_pblk, status);\n\t\tif (ret < 0) {\n\t\t\tretval = ret;\n\t\t\tgoto out_sem;\n\t\t}\n\t}\n\nout_sem:\n\tup_write((&EXT4_I(inode)->i_data_sem));\n\tif (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {\n\t\tret = check_block_validity(inode, map);\n\t\tif (ret != 0)\n\t\t\treturn ret;\n\n\t\t\/*\n\t\t * Inodes with freshly allocated blocks where contents will be\n\t\t * visible after transaction commit must be on transaction's\n\t\t * ordered data list.\n\t\t *\/\n\t\tif (map->m_flags & EXT4_MAP_NEW &&\n\t\t    !(map->m_flags & EXT4_MAP_UNWRITTEN) &&\n\t\t    !(flags & EXT4_GET_BLOCKS_ZERO) &&\n\t\t    !IS_NOQUOTA(inode) &&\n\t\t    ext4_should_order_data(inode)) {\n\t\t\tret = ext4_jbd2_file_inode(handle, inode);\n\t\t\tif (ret)\n\t\t\t\treturn ret;\n\t\t}\n\t}\n\treturn retval;\n}","target":0,"code_token_length":2029,"total_token_length":2265,"max_tokens_setting":4096}
+{"idx":132822,"func":"getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opts *dump)\n  {\n  struct offset offsets;\n  int    i;\n  int32  test;\n  uint32 seg, total, need_buff = 0;\n  uint32 buffsize;\n  uint32 zwidth, zlength;\n\n  memset(&offsets, '\\0', sizeof(struct offset));\n  crop->bufftotal = 0;\n  crop->combined_width  = (uint32)0;\n  crop->combined_length = (uint32)0;\n  crop->selections = 0;\n\n  \/* Compute pixel offsets if margins or fixed width or length specified *\/\n  if ((crop->crop_mode & CROP_MARGINS) ||\n      (crop->crop_mode & CROP_REGIONS) ||\n      (crop->crop_mode & CROP_LENGTH)  || \n      (crop->crop_mode & CROP_WIDTH))\n    {\n    if (computeInputPixelOffsets(crop, image, &offsets))\n      {\n      TIFFError (\"getCropOffsets\", \"Unable to compute crop margins\");\n      return (-1);\n      }\n    need_buff = TRUE;\n    crop->selections = crop->regions;\n    \/* Regions are only calculated from top and left edges with no margins *\/\n    if (crop->crop_mode & CROP_REGIONS)\n      return (0);\n    }\n  else\n    { \/* cropped area is the full image *\/\n    offsets.tmargin = 0;\n    offsets.lmargin = 0;\n    offsets.bmargin = 0;\n    offsets.rmargin = 0;\n    offsets.crop_width = image->width;\n    offsets.crop_length = image->length;\n    offsets.startx = 0;\n    offsets.endx = image->width - 1;\n    offsets.starty = 0;\n    offsets.endy = image->length - 1;\n    need_buff = FALSE;\n    }\n\n  if (dump->outfile != NULL)\n    {\n    dump_info (dump->outfile, dump->format, \"\", \"Margins: Top: %d  Left: %d  Bottom: %d  Right: %d\", \n           offsets.tmargin, offsets.lmargin, offsets.bmargin, offsets.rmargin); \n    dump_info (dump->outfile, dump->format, \"\", \"Crop region within margins: Adjusted Width:  %6d  Length: %6d\", \n           offsets.crop_width, offsets.crop_length);\n    }\n\n  if (!(crop->crop_mode & CROP_ZONES)) \/* no crop zones requested *\/\n    {\n    if (need_buff == FALSE)  \/* No margins or fixed width or length areas *\/\n      {\n      crop->selections = 0;\n      crop->combined_width  = image->width;\n      crop->combined_length = image->length;\n      return (0);\n      }\n    else \n      {\n      \/* Use one region for margins and fixed width or length areas\n       * even though it was not formally declared as a region.\n       *\/\n      crop->selections = 1;\n      crop->zones = 1;\n      crop->zonelist[0].total = 1;\n      crop->zonelist[0].position = 1;\n      }\n    }     \n  else\n    crop->selections = crop->zones;\n\n  for (i = 0; i < crop->zones; i++)\n    {\n    seg = crop->zonelist[i].position;\n    total = crop->zonelist[i].total;\n\n    switch (crop->edge_ref) \n      {\n      case EDGE_LEFT: \/* zones from left to right, length from top *\/\n           zlength = offsets.crop_length;\n\t   crop->regionlist[i].y1 = offsets.starty;\n           crop->regionlist[i].y2 = offsets.endy;\n\n           crop->regionlist[i].x1 = offsets.startx + \n                                  (uint32)(offsets.crop_width * 1.0 * (seg - 1) \/ total);\n           test = (int32)offsets.startx + \n                  (int32)(offsets.crop_width * 1.0 * seg \/ total);\n           if (test < 1 )\n             crop->regionlist[i].x2 = 0;\n           else\n\t     {\n\t     if (test > (int32)(image->width - 1))\n               crop->regionlist[i].x2 = image->width - 1;\n             else\n\t       crop->regionlist[i].x2 = test - 1;\n             }\n           zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1  + 1;\n\n\t   \/* This is passed to extractCropZone or extractCompositeZones *\/\n           crop->combined_length = (uint32)zlength;\n           if (crop->exp_mode == COMPOSITE_IMAGES)\n             crop->combined_width += (uint32)zwidth;\n           else\n             crop->combined_width = (uint32)zwidth;\n           break;\n      case EDGE_BOTTOM: \/* width from left, zones from bottom to top *\/\n           zwidth = offsets.crop_width;\n\t   crop->regionlist[i].x1 = offsets.startx;\n           crop->regionlist[i].x2 = offsets.endx;\n\n           test = offsets.endy - (uint32)(offsets.crop_length * 1.0 * seg \/ total);\n           if (test < 1 )\n\t     crop->regionlist[i].y1 = 0;\n           else\n\t     crop->regionlist[i].y1 = test + 1;\n\n           test = offsets.endy - (offsets.crop_length * 1.0 * (seg - 1) \/ total);\n           if (test < 1 )\n             crop->regionlist[i].y2 = 0;\n           else\n\t     {\n             if (test > (int32)(image->length - 1))\n               crop->regionlist[i].y2 = image->length - 1;\n             else \n               crop->regionlist[i].y2 = test;\n\t     }\n           zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1;\n\n\t   \/* This is passed to extractCropZone or extractCompositeZones *\/\n           if (crop->exp_mode == COMPOSITE_IMAGES)\n             crop->combined_length += (uint32)zlength;\n           else\n             crop->combined_length = (uint32)zlength;\n           crop->combined_width = (uint32)zwidth;\n           break;\n      case EDGE_RIGHT: \/* zones from right to left, length from top *\/\n           zlength = offsets.crop_length;\n\t   crop->regionlist[i].y1 = offsets.starty;\n           crop->regionlist[i].y2 = offsets.endy;\n\n           crop->regionlist[i].x1 = offsets.startx +\n                                  (uint32)(offsets.crop_width  * (total - seg) * 1.0 \/ total);\n           test = offsets.startx + \n\t          (offsets.crop_width * (total - seg + 1) * 1.0 \/ total);\n           if (test < 1 )\n             crop->regionlist[i].x2 = 0;\n           else\n\t     {\n\t     if (test > (int32)(image->width - 1))\n               crop->regionlist[i].x2 = image->width - 1;\n             else\n               crop->regionlist[i].x2 = test - 1;\n             }\n           zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1  + 1;\n\n\t   \/* This is passed to extractCropZone or extractCompositeZones *\/\n           crop->combined_length = (uint32)zlength;\n           if (crop->exp_mode == COMPOSITE_IMAGES)\n             crop->combined_width += (uint32)zwidth;\n           else\n             crop->combined_width = (uint32)zwidth;\n           break;\n      case EDGE_TOP: \/* width from left, zones from top to bottom *\/\n      default:\n           zwidth = offsets.crop_width;\n\t   crop->regionlist[i].x1 = offsets.startx;\n           crop->regionlist[i].x2 = offsets.endx;\n\n           crop->regionlist[i].y1 = offsets.starty + (uint32)(offsets.crop_length * 1.0 * (seg - 1) \/ total);\n           test = offsets.starty + (uint32)(offsets.crop_length * 1.0 * seg \/ total);\n           if (test < 1 )\n             crop->regionlist[i].y2 = 0;\n           else\n\t     {\n\t     if (test > (int32)(image->length - 1))\n\t       crop->regionlist[i].y2 = image->length - 1;\n             else\n\t       crop->regionlist[i].y2 = test - 1;\n\t     }\n           zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1;\n\n\t   \/* This is passed to extractCropZone or extractCompositeZones *\/\n           if (crop->exp_mode == COMPOSITE_IMAGES)\n             crop->combined_length += (uint32)zlength;\n           else\n             crop->combined_length = (uint32)zlength;\n           crop->combined_width = (uint32)zwidth;\n           break;\n      } \/* end switch statement *\/\n\n    buffsize = (uint32)\n          ((((zwidth * image->bps * image->spp) + 7 ) \/ 8) * (zlength + 1));\n    crop->regionlist[i].width = (uint32) zwidth;\n    crop->regionlist[i].length = (uint32) zlength;\n    crop->regionlist[i].buffsize = buffsize;\n    crop->bufftotal += buffsize;\n\n\n  if (dump->outfile != NULL)\n    dump_info (dump->outfile, dump->format, \"\",  \"Zone %d, width: %4d, length: %4d, x1: %4d  x2: %4d  y1: %4d  y2: %4d\",\n                    i + 1, (uint32)zwidth, (uint32)zlength,\n\t\t    crop->regionlist[i].x1, crop->regionlist[i].x2, \n                    crop->regionlist[i].y1, crop->regionlist[i].y2);\n    }\n\n  return (0);\n  } \/* end getCropOffsets *\/","target":0,"code_token_length":2213,"total_token_length":2449,"max_tokens_setting":4096}
+{"idx":374075,"func":"int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)\n{\n\tbool pr = false;\n\n\tswitch (msr) {\n\tcase MSR_EFER:\n\t\treturn set_efer(vcpu, data);\n\tcase MSR_K7_HWCR:\n\t\tdata &= ~(u64)0x40;\t\/* ignore flush filter disable *\/\n\t\tdata &= ~(u64)0x100;\t\/* ignore ignne emulation enable *\/\n\t\tdata &= ~(u64)0x8;\t\/* ignore TLB cache disable *\/\n\t\tif (data != 0) {\n\t\t\tpr_unimpl(vcpu, \"unimplemented HWCR wrmsr: 0x%llx\\n\",\n\t\t\t\tdata);\n\t\t\treturn 1;\n\t\t}\n\t\tbreak;\n\tcase MSR_FAM10H_MMIO_CONF_BASE:\n\t\tif (data != 0) {\n\t\t\tpr_unimpl(vcpu, \"unimplemented MMIO_CONF_BASE wrmsr: \"\n\t\t\t\t\"0x%llx\\n\", data);\n\t\t\treturn 1;\n\t\t}\n\t\tbreak;\n\tcase MSR_AMD64_NB_CFG:\n\t\tbreak;\n\tcase MSR_IA32_DEBUGCTLMSR:\n\t\tif (!data) {\n\t\t\t\/* We support the non-activated case already *\/\n\t\t\tbreak;\n\t\t} else if (data & ~(DEBUGCTLMSR_LBR | DEBUGCTLMSR_BTF)) {\n\t\t\t\/* Values other than LBR and BTF are vendor-specific,\n\t\t\t   thus reserved and should throw a #GP *\/\n\t\t\treturn 1;\n\t\t}\n\t\tpr_unimpl(vcpu, \"%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\\n\",\n\t\t\t__func__, data);\n\t\tbreak;\n\tcase MSR_IA32_UCODE_REV:\n\tcase MSR_IA32_UCODE_WRITE:\n\tcase MSR_VM_HSAVE_PA:\n\tcase MSR_AMD64_PATCH_LOADER:\n\t\tbreak;\n\tcase 0x200 ... 0x2ff:\n\t\treturn set_msr_mtrr(vcpu, msr, data);\n\tcase MSR_IA32_APICBASE:\n\t\tkvm_set_apic_base(vcpu, data);\n\t\tbreak;\n\tcase APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff:\n\t\treturn kvm_x2apic_msr_write(vcpu, msr, data);\n\tcase MSR_IA32_TSCDEADLINE:\n\t\tkvm_set_lapic_tscdeadline_msr(vcpu, data);\n\t\tbreak;\n\tcase MSR_IA32_MISC_ENABLE:\n\t\tvcpu->arch.ia32_misc_enable_msr = data;\n\t\tbreak;\n\tcase MSR_KVM_WALL_CLOCK_NEW:\n\tcase MSR_KVM_WALL_CLOCK:\n\t\tvcpu->kvm->arch.wall_clock = data;\n\t\tkvm_write_wall_clock(vcpu->kvm, data);\n\t\tbreak;\n\tcase MSR_KVM_SYSTEM_TIME_NEW:\n\tcase MSR_KVM_SYSTEM_TIME: {\n\t\tkvmclock_reset(vcpu);\n\n\t\tvcpu->arch.time = data;\n\t\tkvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);\n\n\t\t\/* we verify if the enable bit is set... *\/\n\t\tif (!(data & 1))\n\t\t\tbreak;\n\n\t\t\/* ...but clean it before doing the actual write *\/\n\t\tvcpu->arch.time_offset = data & ~(PAGE_MASK | 1);\n\n\t\tvcpu->arch.time_page =\n\t\t\t\tgfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);\n\n\t\tif (is_error_page(vcpu->arch.time_page)) {\n\t\t\tkvm_release_page_clean(vcpu->arch.time_page);\n\t\t\tvcpu->arch.time_page = NULL;\n\t\t}\n\t\tbreak;\n\t}\n\tcase MSR_KVM_ASYNC_PF_EN:\n\t\tif (kvm_pv_enable_async_pf(vcpu, data))\n\t\t\treturn 1;\n\t\tbreak;\n\tcase MSR_KVM_STEAL_TIME:\n\n\t\tif (unlikely(!sched_info_on()))\n\t\t\treturn 1;\n\n\t\tif (data & KVM_STEAL_RESERVED_MASK)\n\t\t\treturn 1;\n\n\t\tif (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.st.stime,\n\t\t\t\t\t\t\tdata & KVM_STEAL_VALID_BITS))\n\t\t\treturn 1;\n\n\t\tvcpu->arch.st.msr_val = data;\n\n\t\tif (!(data & KVM_MSR_ENABLED))\n\t\t\tbreak;\n\n\t\tvcpu->arch.st.last_steal = current->sched_info.run_delay;\n\n\t\tpreempt_disable();\n\t\taccumulate_steal_time(vcpu);\n\t\tpreempt_enable();\n\n\t\tkvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);\n\n\t\tbreak;\n\n\tcase MSR_IA32_MCG_CTL:\n\tcase MSR_IA32_MCG_STATUS:\n\tcase MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:\n\t\treturn set_msr_mce(vcpu, msr, data);\n\n\t\/* Performance counters are not protected by a CPUID bit,\n\t * so we should check all of them in the generic path for the sake of\n\t * cross vendor migration.\n\t * Writing a zero into the event select MSRs disables them,\n\t * which we perfectly emulate ;-). Any other value should be at least\n\t * reported, some guests depend on them.\n\t *\/\n\tcase MSR_K7_EVNTSEL0:\n\tcase MSR_K7_EVNTSEL1:\n\tcase MSR_K7_EVNTSEL2:\n\tcase MSR_K7_EVNTSEL3:\n\t\tif (data != 0)\n\t\t\tpr_unimpl(vcpu, \"unimplemented perfctr wrmsr: \"\n\t\t\t\t\"0x%x data 0x%llx\\n\", msr, data);\n\t\tbreak;\n\t\/* at least RHEL 4 unconditionally writes to the perfctr registers,\n\t * so we ignore writes to make it happy.\n\t *\/\n\tcase MSR_K7_PERFCTR0:\n\tcase MSR_K7_PERFCTR1:\n\tcase MSR_K7_PERFCTR2:\n\tcase MSR_K7_PERFCTR3:\n\t\tpr_unimpl(vcpu, \"unimplemented perfctr wrmsr: \"\n\t\t\t\"0x%x data 0x%llx\\n\", msr, data);\n\t\tbreak;\n\tcase MSR_P6_PERFCTR0:\n\tcase MSR_P6_PERFCTR1:\n\t\tpr = true;\n\tcase MSR_P6_EVNTSEL0:\n\tcase MSR_P6_EVNTSEL1:\n\t\tif (kvm_pmu_msr(vcpu, msr))\n\t\t\treturn kvm_pmu_set_msr(vcpu, msr, data);\n\n\t\tif (pr || data != 0)\n\t\t\tpr_unimpl(vcpu, \"disabled perfctr wrmsr: \"\n\t\t\t\t\"0x%x data 0x%llx\\n\", msr, data);\n\t\tbreak;\n\tcase MSR_K7_CLK_CTL:\n\t\t\/*\n\t\t * Ignore all writes to this no longer documented MSR.\n\t\t * Writes are only relevant for old K7 processors,\n\t\t * all pre-dating SVM, but a recommended workaround from\n\t\t * AMD for these chips. It is possible to speicify the\n\t\t * affected processor models on the command line, hence\n\t\t * the need to ignore the workaround.\n\t\t *\/\n\t\tbreak;\n\tcase HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15:\n\t\tif (kvm_hv_msr_partition_wide(msr)) {\n\t\t\tint r;\n\t\t\tmutex_lock(&vcpu->kvm->lock);\n\t\t\tr = set_msr_hyperv_pw(vcpu, msr, data);\n\t\t\tmutex_unlock(&vcpu->kvm->lock);\n\t\t\treturn r;\n\t\t} else\n\t\t\treturn set_msr_hyperv(vcpu, msr, data);\n\t\tbreak;\n\tcase MSR_IA32_BBL_CR_CTL3:\n\t\t\/* Drop writes to this legacy MSR -- see rdmsr\n\t\t * counterpart for further detail.\n\t\t *\/\n\t\tpr_unimpl(vcpu, \"ignored wrmsr: 0x%x data %llx\\n\", msr, data);\n\t\tbreak;\n\tcase MSR_AMD64_OSVW_ID_LENGTH:\n\t\tif (!guest_cpuid_has_osvw(vcpu))\n\t\t\treturn 1;\n\t\tvcpu->arch.osvw.length = data;\n\t\tbreak;\n\tcase MSR_AMD64_OSVW_STATUS:\n\t\tif (!guest_cpuid_has_osvw(vcpu))\n\t\t\treturn 1;\n\t\tvcpu->arch.osvw.status = data;\n\t\tbreak;\n\tdefault:\n\t\tif (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr))\n\t\t\treturn xen_hvm_config(vcpu, data);\n\t\tif (kvm_pmu_msr(vcpu, msr))\n\t\t\treturn kvm_pmu_set_msr(vcpu, msr, data);\n\t\tif (!ignore_msrs) {\n\t\t\tpr_unimpl(vcpu, \"unhandled wrmsr: 0x%x data %llx\\n\",\n\t\t\t\tmsr, data);\n\t\t\treturn 1;\n\t\t} else {\n\t\t\tpr_unimpl(vcpu, \"ignored wrmsr: 0x%x data %llx\\n\",\n\t\t\t\tmsr, data);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":1920,"total_token_length":2156,"max_tokens_setting":4096}
+{"idx":137408,"func":"static void test_change_user()\n{\n  char buff[256];\n  const char *user_pw= \"mysqltest_pw\";\n  const char *user_no_pw= \"mysqltest_no_pw\";\n  const char *pw= \"password\";\n  const char *db= \"mysqltest_user_test_database\";\n  int rc;\n  MYSQL *l_mysql;\n\n  DBUG_ENTER(\"test_change_user\");\n  myheader(\"test_change_user\");\n\n  l_mysql= mysql_client_init(NULL);\n  DIE_UNLESS(l_mysql != NULL);\n\n  l_mysql= mysql_real_connect(l_mysql, opt_host, opt_user,\n                         opt_password, current_db, opt_port,\n                         opt_unix_socket, 0);\n  DIE_UNLESS(l_mysql != 0);\n\n\n  \/* Prepare environment *\/\n  sprintf(buff, \"drop database if exists %s\", db);\n  rc= mysql_query(l_mysql, buff);\n  myquery2(l_mysql, rc);\n\n  sprintf(buff, \"create database %s\", db);\n  rc= mysql_query(l_mysql, buff);\n  myquery2(l_mysql, rc);\n\n  sprintf(buff,\n          \"grant select on %s.* to %s@'%%' identified by '%s'\",\n          db,\n          user_pw,\n          pw);\n  rc= mysql_query(l_mysql, buff);\n  myquery2(l_mysql, rc);\n\n  sprintf(buff,\n          \"grant select on %s.* to %s@'localhost' identified by '%s'\",\n          db,\n          user_pw,\n          pw);\n  rc= mysql_query(l_mysql, buff);\n  myquery2(l_mysql, rc);\n\n  sprintf(buff,\n          \"grant select on %s.* to %s@'%%'\",\n          db,\n          user_no_pw);\n  rc= mysql_query(l_mysql, buff);\n  myquery2(l_mysql, rc);\n\n  sprintf(buff,\n          \"grant select on %s.* to %s@'localhost'\",\n          db,\n          user_no_pw);\n  rc= mysql_query(l_mysql, buff);\n  myquery2(l_mysql, rc);\n\n  \/* Try some combinations *\/\n  rc= mysql_change_user(l_mysql, NULL, NULL, NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql)); \n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, \"\", NULL, NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, \"\", \"\", NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n\n  rc= mysql_change_user(l_mysql, \"\", \"\", \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, NULL, \"\", \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n\n  rc= mysql_change_user(l_mysql, NULL, NULL, \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, \"\", NULL, \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, NULL, \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, \"\", \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, \"\", NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, NULL, NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, \"\", db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, NULL, db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_pw, pw, db);\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, user_pw, pw, NULL);\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, user_pw, pw, \"\");\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, user_no_pw, pw, db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n\n  rc= mysql_change_user(l_mysql, user_no_pw, pw, \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_no_pw, pw, NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, user_no_pw, \"\", NULL);\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, user_no_pw, \"\", \"\");\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, user_no_pw, \"\", db);\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, user_no_pw, NULL, db);\n  myquery2(l_mysql, rc);\n\n  rc= mysql_change_user(l_mysql, \"\", pw, db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, \"\", pw, \"\");\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, \"\", pw, NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n\n  rc= mysql_change_user(l_mysql, NULL, pw, NULL);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, NULL, NULL, db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, NULL, \"\", db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  rc= mysql_change_user(l_mysql, \"\", \"\", db);\n  DIE_UNLESS(rc);\n  if (! opt_silent)\n    printf(\"Got error (as expected): %s\\n\", mysql_error(l_mysql));\n  reconnect(&l_mysql);\n\n  \/* Cleanup the environment *\/\n\n  mysql_close(l_mysql);\n\n  sprintf(buff, \"drop database %s\", db);\n  rc= mysql_query(mysql, buff);\n  myquery(rc);\n\n  sprintf(buff, \"drop user %s@'%%'\", user_pw);\n  rc= mysql_query(mysql, buff);\n  myquery(rc);\n\n  sprintf(buff, \"drop user %s@'%%'\", user_no_pw);\n  rc= mysql_query(mysql, buff);\n  myquery(rc);\n\n  sprintf(buff, \"drop user %s@'localhost'\", user_pw);\n  rc= mysql_query(mysql, buff);\n  myquery(rc);\n\n  sprintf(buff, \"drop user %s@'localhost'\", user_no_pw);\n  rc= mysql_query(mysql, buff);\n  myquery(rc);\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":1939,"total_token_length":2175,"max_tokens_setting":4096}
+{"idx":410260,"func":"                void printIFD(std::ostream& out, PrintStructureOption option, uint64_t dir_offset, int depth)\n                {\n                    BasicIo& io = Image::io();\n\n                    depth++;\n                    bool bFirst  = true;\n\n                    \/\/ buffer\n                    bool bPrint = true;\n\n                    do\n                    {\n                        \/\/ Read top of directory\n                        io.seek(dir_offset, BasicIo::beg);\n\n                        const uint64_t entries = readData(header_.format() == Header::StandardTiff? 2: 8);\n                        const bool tooBig = entries > 500;\n\n                        if ( bFirst && bPrint )\n                        {\n                            out << Internal::indent(depth) << Internal::stringFormat(\"STRUCTURE OF BIGTIFF FILE \") << io.path() << std::endl;\n                            if (tooBig)\n                                out << Internal::indent(depth) << \"entries = \" << entries << std::endl;\n                        }\n\n                        if (tooBig)\n                            break;\n\n                        \/\/ Read the dictionary\n                        for ( uint64_t i = 0; i < entries; i ++ )\n                        {\n                            if ( bFirst && bPrint )\n                                out << Internal::indent(depth)\n                                    << \" address |    tag                           |     \"\n                                    << \" type |    count |    offset | value\\n\";\n\n                            bFirst = false;\n\n                            const uint16_t tag   = (uint16_t) readData(2);\n                            const uint16_t type  = (uint16_t) readData(2);\n                            const uint64_t count = readData(dataSize_);\n                            const DataBuf  data  = io.read(dataSize_);        \/\/ Read data as raw value. what should be done about it will be decided depending on type\n\n                            std::string sp = \"\" ; \/\/ output spacer\n\n                            \/\/prepare to print the value\n                            \/\/ TODO: figure out what's going on with kount\n                            const uint64_t kount  = isStringType(type)? (count > 32 ? 32 : count) \/\/ restrict long arrays\n                                                            : count > 5              ? 5\n                                                            : count\n                                                            ;\n                            const uint32_t pad    = isStringType(type) ? 1 : 0;\n                            const uint32_t size   = isStringType(type) ? 1\n                                                  : is2ByteType(type)  ? 2\n                                                  : is4ByteType(type)  ? 4\n                                                  : is8ByteType(type)  ? 8\n                                                  : 1;\n\n                            \/\/ #55 and #56 memory allocation crash test\/data\/POC8\n\n                            \/\/ size * count > std::numeric_limits::max()\n                            \/\/ =>\n                            \/\/ size > std::numeric_limits::max() \/ count\n                            if (size > std::numeric_limits::max() \/ count)\n                                throw Error(57);             \/\/ we got number bigger than 2^64\n                                                             \/\/ more than we can handle\n\n                            if (size * count > std::numeric_limits::max() - pad)\n                                throw Error(57);             \/\/ again more than 2^64\n\n                            const uint64_t allocate = size*count + pad;\n                            if ( allocate > io.size() ) {\n                                throw Error(57);\n                            }\n\n                            DataBuf buf(static_cast(allocate));\n\n                            const uint64_t offset = header_.format() == Header::StandardTiff?\n                                    byteSwap4(data, 0, doSwap_):\n                                    byteSwap8(data, 0, doSwap_);\n\n                            \/\/ big data? Use 'data' as pointer to real data\n                            const bool usePointer = (size_t) count*size > (size_t) dataSize_;\n\n                            if ( usePointer )                          \/\/ read into buffer\n                            {\n                                size_t   restore = io.tell();          \/\/ save\n                                io.seek(offset, BasicIo::beg);         \/\/ position\n                                io.read(buf.pData_, (long) count * size);     \/\/ read\n                                io.seek(restore, BasicIo::beg);        \/\/ restore\n                            }\n                            else  \/\/ use 'data' as data :)\n                                std::memcpy(buf.pData_, data.pData_, (size_t) count * size);     \/\/ copy data\n\n                            if ( bPrint )\n                            {\n                                const uint64_t entrySize = header_.format() == Header::StandardTiff? 12: 20;\n                                const uint64_t address = dir_offset + 2 + i * entrySize;\n                                const std::string offsetString = usePointer?\n                                    Internal::stringFormat(\"%10u\", offset):\n                                    \"\";\n\n                                out << Internal::indent(depth)\n                                    << Internal::stringFormat(\"%8u | %#06x %-25s |%10s |%9u |%10s | \",\n                                        address, tag, tagName(tag).c_str(), typeName(type), count, offsetString.c_str());\n\n                                if ( isShortType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        out << sp << byteSwap2(buf, k*size, doSwap_);\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isLongType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        out << sp << byteSwap4(buf, k*size, doSwap_);\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isLongLongType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        out << sp << byteSwap8(buf, k*size, doSwap_);\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isRationalType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        uint32_t a = byteSwap4(buf, k*size+0, doSwap_);\n                                        uint32_t b = byteSwap4(buf, k*size+4, doSwap_);\n                                        out << sp << a << \"\/\" << b;\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isStringType(type) )\n                                    out << sp << Internal::binaryToString(buf, (size_t) kount);\n\n                                sp = kount == count ? \"\" : \" ...\";\n                                out << sp << std::endl;\n\n                                if ( option == kpsRecursive &&\n                                        (tag == 0x8769 \/* ExifTag *\/ || tag == 0x014a\/*SubIFDs*\/ || type == tiffIfd || type == tiffIfd8) )\n                                {\n                                    for ( size_t k = 0 ; k < count ; k++ )\n                                    {\n                                        const size_t restore = io.tell();\n                                        const uint64_t ifdOffset = type == tiffIfd8?\n                                            byteSwap8(buf, k*size, doSwap_):\n                                            byteSwap4(buf, k*size, doSwap_);\n\n                                        printIFD(out, option, ifdOffset, depth);\n                                        io.seek(restore, BasicIo::beg);\n                                    }\n                                }\n                                else if ( option == kpsRecursive && tag == 0x83bb \/* IPTCNAA *\/ )\n                                {\n                                    const size_t restore = io.tell();      \/\/ save\n                                    io.seek(offset, BasicIo::beg);         \/\/ position\n                                    byte* bytes=new byte[(size_t)count] ;  \/\/ allocate memory\n                                    io.read(bytes,(long)count)        ;    \/\/ read\n                                    io.seek(restore, BasicIo::beg);        \/\/ restore\n                                    IptcData::printStructure(out,bytes,(size_t)count,depth);\n                                    delete[] bytes;                        \/\/ free\n                                }\n                                else if ( option == kpsRecursive && tag == 0x927c \/* MakerNote *\/ && count > 10)\n                                {\n                                    size_t   restore = io.tell();  \/\/ save\n\n                                    uint32_t jump= 10           ;\n                                    byte     bytes[20]          ;\n                                    const char* chars = (const char*) &bytes[0] ;\n                                    io.seek(dir_offset, BasicIo::beg);  \/\/ position\n                                    io.read(bytes,jump    )     ;  \/\/ read\n                                    bytes[jump]=0               ;\n                                    if ( ::strcmp(\"Nikon\",chars) == 0 )\n                                    {\n                                        \/\/ tag is an embedded tiff\n                                        byte* bytes=new byte[(size_t)count-jump] ;  \/\/ allocate memory\n                                        io.read(bytes,(long)  count-jump)        ;  \/\/ read\n                                        MemIo memIo(bytes,(long)count-jump)      ;  \/\/ create a file\n                                        std::cerr << \"Nikon makernote\" << std::endl;\n                                        \/\/ printTiffStructure(memIo,out,option,depth);  TODO: fix it\n                                        delete[] bytes                   ;  \/\/ free\n                                    }\n                                    else\n                                    {\n                                        \/\/ tag is an IFD\n                                        io.seek(0, BasicIo::beg);  \/\/ position\n                                        std::cerr << \"makernote\" << std::endl;\n                                        printIFD(out,option,offset,depth);\n                                    }\n\n                                    io.seek(restore,BasicIo::beg); \/\/ restore\n                                }\n                            }\n                        }\n\n                        const uint64_t nextDirOffset = readData(dataSize_);\n\n                        dir_offset = tooBig ? 0 : nextDirOffset;\n                        out.flush();\n                    } while (dir_offset != 0);\n\n                    if ( bPrint )\n                        out << Internal::indent(depth) << \"END \" << io.path() << std::endl;\n\n                    depth--;\n                }","target":0,"code_token_length":2059,"total_token_length":2295,"max_tokens_setting":4096}
+{"idx":606,"func":"static void optimize_b ( MACROBLOCK * mb , int ib , int type , ENTROPY_CONTEXT * a , ENTROPY_CONTEXT * l ) {\n BLOCK * b ;\n BLOCKD * d ;\n vp8_token_state tokens [ 17 ] [ 2 ] ;\n unsigned best_mask [ 2 ] ;\n const short * dequant_ptr ;\n const short * coeff_ptr ;\n short * qcoeff_ptr ;\n short * dqcoeff_ptr ;\n int eob ;\n int i0 ;\n int rc ;\n int x ;\n int sz = 0 ;\n int next ;\n int rdmult ;\n int rddiv ;\n int final_eob ;\n int rd_cost0 ;\n int rd_cost1 ;\n int rate0 ;\n int rate1 ;\n int error0 ;\n int error1 ;\n int t0 ;\n int t1 ;\n int best ;\n int band ;\n int pt ;\n int i ;\n int err_mult = plane_rd_mult [ type ] ;\n b = & mb -> block [ ib ] ;\n d = & mb -> e_mbd . block [ ib ] ;\n # if 0 vp8_strict_quantize_b ( b , d ) ;\n # endif dequant_ptr = d -> dequant ;\n coeff_ptr = b -> coeff ;\n qcoeff_ptr = d -> qcoeff ;\n dqcoeff_ptr = d -> dqcoeff ;\n i0 = ! type ;\n eob = * d -> eob ;\n rdmult = mb -> rdmult * err_mult ;\n if ( mb -> e_mbd . mode_info_context -> mbmi . ref_frame == INTRA_FRAME ) rdmult = ( rdmult * 9 ) >> 4 ;\n rddiv = mb -> rddiv ;\n best_mask [ 0 ] = best_mask [ 1 ] = 0 ;\n tokens [ eob ] [ 0 ] . rate = 0 ;\n tokens [ eob ] [ 0 ] . error = 0 ;\n tokens [ eob ] [ 0 ] . next = 16 ;\n tokens [ eob ] [ 0 ] . token = DCT_EOB_TOKEN ;\n tokens [ eob ] [ 0 ] . qc = 0 ;\n * ( tokens [ eob ] + 1 ) = * ( tokens [ eob ] + 0 ) ;\n next = eob ;\n for ( i = eob ;\n i -- > i0 ;\n ) {\n int base_bits ;\n int d2 ;\n int dx ;\n rc = vp8_default_zig_zag1d [ i ] ;\n x = qcoeff_ptr [ rc ] ;\n if ( x ) {\n int shortcut = 0 ;\n error0 = tokens [ next ] [ 0 ] . error ;\n error1 = tokens [ next ] [ 1 ] . error ;\n rate0 = tokens [ next ] [ 0 ] . rate ;\n rate1 = tokens [ next ] [ 1 ] . rate ;\n t0 = ( vp8_dct_value_tokens_ptr + x ) -> Token ;\n if ( next < 16 ) {\n band = vp8_coef_bands [ i + 1 ] ;\n pt = vp8_prev_token_class [ t0 ] ;\n rate0 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 0 ] . token ] ;\n rate1 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 1 ] . token ] ;\n }\n rd_cost0 = RDCOST ( rdmult , rddiv , rate0 , error0 ) ;\n rd_cost1 = RDCOST ( rdmult , rddiv , rate1 , error1 ) ;\n if ( rd_cost0 == rd_cost1 ) {\n rd_cost0 = RDTRUNC ( rdmult , rddiv , rate0 , error0 ) ;\n rd_cost1 = RDTRUNC ( rdmult , rddiv , rate1 , error1 ) ;\n }\n best = rd_cost1 < rd_cost0 ;\n base_bits = * ( vp8_dct_value_cost_ptr + x ) ;\n dx = dqcoeff_ptr [ rc ] - coeff_ptr [ rc ] ;\n d2 = dx * dx ;\n tokens [ i ] [ 0 ] . rate = base_bits + ( best ? rate1 : rate0 ) ;\n tokens [ i ] [ 0 ] . error = d2 + ( best ? error1 : error0 ) ;\n tokens [ i ] [ 0 ] . next = next ;\n tokens [ i ] [ 0 ] . token = t0 ;\n tokens [ i ] [ 0 ] . qc = x ;\n best_mask [ 0 ] |= best << i ;\n rate0 = tokens [ next ] [ 0 ] . rate ;\n rate1 = tokens [ next ] [ 1 ] . rate ;\n if ( ( abs ( x ) * dequant_ptr [ rc ] > abs ( coeff_ptr [ rc ] ) ) && ( abs ( x ) * dequant_ptr [ rc ] < abs ( coeff_ptr [ rc ] ) + dequant_ptr [ rc ] ) ) shortcut = 1 ;\n else shortcut = 0 ;\n if ( shortcut ) {\n sz = - ( x < 0 ) ;\n x -= 2 * sz + 1 ;\n }\n if ( ! x ) {\n t0 = tokens [ next ] [ 0 ] . token == DCT_EOB_TOKEN ? DCT_EOB_TOKEN : ZERO_TOKEN ;\n t1 = tokens [ next ] [ 1 ] . token == DCT_EOB_TOKEN ? DCT_EOB_TOKEN : ZERO_TOKEN ;\n }\n else {\n t0 = t1 = ( vp8_dct_value_tokens_ptr + x ) -> Token ;\n }\n if ( next < 16 ) {\n band = vp8_coef_bands [ i + 1 ] ;\n if ( t0 != DCT_EOB_TOKEN ) {\n pt = vp8_prev_token_class [ t0 ] ;\n rate0 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 0 ] . token ] ;\n }\n if ( t1 != DCT_EOB_TOKEN ) {\n pt = vp8_prev_token_class [ t1 ] ;\n rate1 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 1 ] . token ] ;\n }\n }\n rd_cost0 = RDCOST ( rdmult , rddiv , rate0 , error0 ) ;\n rd_cost1 = RDCOST ( rdmult , rddiv , rate1 , error1 ) ;\n if ( rd_cost0 == rd_cost1 ) {\n rd_cost0 = RDTRUNC ( rdmult , rddiv , rate0 , error0 ) ;\n rd_cost1 = RDTRUNC ( rdmult , rddiv , rate1 , error1 ) ;\n }\n best = rd_cost1 < rd_cost0 ;\n base_bits = * ( vp8_dct_value_cost_ptr + x ) ;\n if ( shortcut ) {\n dx -= ( dequant_ptr [ rc ] + sz ) ^ sz ;\n d2 = dx * dx ;\n }\n tokens [ i ] [ 1 ] . rate = base_bits + ( best ? rate1 : rate0 ) ;\n tokens [ i ] [ 1 ] . error = d2 + ( best ? error1 : error0 ) ;\n tokens [ i ] [ 1 ] . next = next ;\n tokens [ i ] [ 1 ] . token = best ? t1 : t0 ;\n tokens [ i ] [ 1 ] . qc = x ;\n best_mask [ 1 ] |= best << i ;\n next = i ;\n }\n else {\n band = vp8_coef_bands [ i + 1 ] ;\n t0 = tokens [ next ] [ 0 ] . token ;\n t1 = tokens [ next ] [ 1 ] . token ;\n if ( t0 != DCT_EOB_TOKEN ) {\n tokens [ next ] [ 0 ] . rate += mb -> token_costs [ type ] [ band ] [ 0 ] [ t0 ] ;\n tokens [ next ] [ 0 ] . token = ZERO_TOKEN ;\n }\n if ( t1 != DCT_EOB_TOKEN ) {\n tokens [ next ] [ 1 ] . rate += mb -> token_costs [ type ] [ band ] [ 0 ] [ t1 ] ;\n tokens [ next ] [ 1 ] . token = ZERO_TOKEN ;\n }\n }\n }\n band = vp8_coef_bands [ i + 1 ] ;\n VP8_COMBINEENTROPYCONTEXTS ( pt , * a , * l ) ;\n rate0 = tokens [ next ] [ 0 ] . rate ;\n rate1 = tokens [ next ] [ 1 ] . rate ;\n error0 = tokens [ next ] [ 0 ] . error ;\n error1 = tokens [ next ] [ 1 ] . error ;\n t0 = tokens [ next ] [ 0 ] . token ;\n t1 = tokens [ next ] [ 1 ] . token ;\n rate0 += mb -> token_costs [ type ] [ band ] [ pt ] [ t0 ] ;\n rate1 += mb -> token_costs [ type ] [ band ] [ pt ] [ t1 ] ;\n rd_cost0 = RDCOST ( rdmult , rddiv , rate0 , error0 ) ;\n rd_cost1 = RDCOST ( rdmult , rddiv , rate1 , error1 ) ;\n if ( rd_cost0 == rd_cost1 ) {\n rd_cost0 = RDTRUNC ( rdmult , rddiv , rate0 , error0 ) ;\n rd_cost1 = RDTRUNC ( rdmult , rddiv , rate1 , error1 ) ;\n }\n best = rd_cost1 < rd_cost0 ;\n final_eob = i0 - 1 ;\n for ( i = next ;\n i < eob ;\n i = next ) {\n x = tokens [ i ] [ best ] . qc ;\n if ( x ) final_eob = i ;\n rc = vp8_default_zig_zag1d [ i ] ;\n qcoeff_ptr [ rc ] = x ;\n dqcoeff_ptr [ rc ] = x * dequant_ptr [ rc ] ;\n next = tokens [ i ] [ best ] . next ;\n best = ( best_mask [ best ] >> i ) & 1 ;\n }\n final_eob ++ ;\n * a = * l = ( final_eob != ! type ) ;\n * d -> eob = ( char ) final_eob ;\n }","target":1,"code_token_length":2117,"total_token_length":2353,"max_tokens_setting":4096}
+{"idx":435486,"func":"EXPORTED int meth_propfind(struct transaction_t *txn, void *params)\n{\n    struct meth_params *fparams = (struct meth_params *) params;\n    int ret = 0, r;\n    const char **hdr;\n    unsigned depth;\n    xmlDocPtr indoc = NULL, outdoc = NULL;\n    xmlNodePtr root, cur = NULL, props = NULL;\n    xmlNsPtr ns[NUM_NAMESPACE];\n    struct hash_table ns_table = { 0, NULL, NULL };\n    struct propfind_ctx fctx;\n\n    memset(&fctx, 0, sizeof(struct propfind_ctx));\n\n    \/* Parse the path *\/\n    if (fparams->parse_path) {\n        r = dav_parse_req_target(txn, fparams);\n        if (r) return r;\n    }\n\n    \/* Make sure method is allowed *\/\n    if (!(txn->req_tgt.allow & ALLOW_DAV)) return HTTP_NOT_ALLOWED;\n\n    \/* Check Depth *\/\n    hdr = spool_getheader(txn->req_hdrs, \"Depth\");\n    if (!hdr || !strcmp(hdr[0], \"infinity\")) {\n        depth = 3;\n\n        if ((txn->error.precond = fparams->propfind.finite_depth_precond)) {\n            ret = HTTP_FORBIDDEN;\n            goto done;\n        }\n    }\n    else if (!strcmp(hdr[0], \"1\")) {\n        depth = 1;\n    }\n    else if (!strcmp(hdr[0], \"0\")) {\n        depth = 0;\n    }\n    else {\n        txn->error.desc = \"Illegal Depth value\\r\\n\";\n        return HTTP_BAD_REQUEST;\n    }\n\n    if (txn->req_tgt.mbentry) {\n        int rights;\n\n        \/* Check ACL for current user *\/\n        rights = httpd_myrights(httpd_authstate, txn->req_tgt.mbentry);\n        if ((rights & DACL_READ) != DACL_READ) {\n            \/* DAV:need-privileges *\/\n            txn->error.precond = DAV_NEED_PRIVS;\n            txn->error.resource = txn->req_tgt.path;\n            txn->error.rights = DACL_READ;\n            ret = HTTP_NO_PRIVS;\n            goto done;\n        }\n\n        if (txn->req_tgt.mbentry->server) {\n            \/* Remote mailbox *\/\n            struct backend *be;\n\n            be = proxy_findserver(txn->req_tgt.mbentry->server,\n                                  &http_protocol, httpd_userid,\n                                  &backend_cached, NULL, NULL, httpd_in);\n            if (!be) return HTTP_UNAVAILABLE;\n\n            return http_pipe_req_resp(be, txn);\n        }\n\n        \/* Local Mailbox *\/\n    }\n\n    \/* Principal or Local Mailbox *\/\n\n    \/* Parse the PROPFIND body, if exists *\/\n    ret = parse_xml_body(txn, &root, NULL);\n    if (ret) goto done;\n\n    if (!root) {\n        \/* Empty request *\/\n        fctx.mode = PROPFIND_ALL;\n    }\n    else {\n        indoc = root->doc;\n\n        \/* Make sure its a DAV:propfind element *\/\n        if (!root->ns || xmlStrcmp(root->ns->href, BAD_CAST XML_NS_DAV) ||\n            xmlStrcmp(root->name, BAD_CAST \"propfind\")) {\n            txn->error.desc = \"Missing DAV:propfind element in PROPFIND request\";\n            ret = HTTP_BAD_REQUEST;\n            goto done;\n        }\n\n        \/* Find child element of propfind *\/\n        for (cur = root->children;\n             cur && cur->type != XML_ELEMENT_NODE; cur = cur->next);\n\n        if (!cur) {\n            txn->error.desc = \"Missing child node element in PROPFIND request\";\n            ret = HTTP_BAD_REQUEST;\n            goto done;\n        }\n\n        \/* Add propfind type to our header cache *\/\n        spool_cache_header(xstrdup(\":type\"), xstrdup((const char *) cur->name),\n                           txn->req_hdrs);\n\n        \/* Make sure its a known element *\/\n        if (!xmlStrcmp(cur->name, BAD_CAST \"allprop\")) {\n            fctx.mode = PROPFIND_ALL;\n        }\n        else if (!xmlStrcmp(cur->name, BAD_CAST \"propname\")) {\n            fctx.mode = PROPFIND_NAME;\n            fctx.prefer = PREFER_MIN;  \/* Don't want 404 (Not Found) *\/\n        }\n        else if (!xmlStrcmp(cur->name, BAD_CAST \"prop\")) {\n            fctx.mode = PROPFIND_PROP;\n            props = cur->children;\n        }\n        else {\n            ret = HTTP_BAD_REQUEST;\n            goto done;\n        }\n\n        \/* Check for extra elements *\/\n        for (cur = cur->next; cur; cur = cur->next) {\n            if (cur->type == XML_ELEMENT_NODE) {\n                if ((fctx.mode == PROPFIND_ALL) && !props &&\n                    \/* Check for 'include' element *\/\n                    !xmlStrcmp(cur->name, BAD_CAST \"include\")) {\n                    props = cur->children;\n                }\n                else {\n                    ret = HTTP_BAD_REQUEST;\n                    goto done;\n                }\n            }\n        }\n    }\n\n    \/* Start construction of our multistatus response *\/\n    root = init_xml_response(\"multistatus\", NS_DAV, root, ns);\n    if (!root) {\n        ret = HTTP_SERVER_ERROR;\n        txn->error.desc = \"Unable to create XML response\";\n        goto done;\n    }\n\n    outdoc = root->doc;\n\n    \/* Populate our propfind context *\/\n    fctx.txn = txn;\n    fctx.req_tgt = &txn->req_tgt;\n    fctx.depth = depth;\n    fctx.prefer |= get_preferences(txn);\n    fctx.userid = httpd_userid;\n    fctx.userisadmin = httpd_userisadmin;\n    fctx.authstate = httpd_authstate;\n    fctx.mbentry = NULL;\n    fctx.mailbox = NULL;\n    fctx.record = NULL;\n    fctx.get_validators = fparams->get_validators;\n    fctx.reqd_privs = DACL_READ;\n    fctx.filter = NULL;\n    fctx.filter_crit = NULL;\n    if (fparams->mime_types) fctx.free_obj = fparams->mime_types[0].free;\n    fctx.open_db = fparams->davdb.open_db;\n    fctx.close_db = fparams->davdb.close_db;\n    fctx.lookup_resource = fparams->davdb.lookup_resource;\n    fctx.foreach_resource = fparams->davdb.foreach_resource;\n    fctx.proc_by_resource = &propfind_by_resource;\n    fctx.elist = NULL;\n    fctx.lprops = fparams->propfind.lprops;\n    fctx.root = root;\n    fctx.ns = ns;\n    fctx.ns_table = &ns_table;\n    fctx.ret = &ret;\n\n    \/* Parse the list of properties and build a list of callbacks *\/\n    ret = preload_proplist(props, &fctx);\n    if (ret) goto done;\n\n    \/* iCalendar\/vCard data in response should not be transformed *\/\n    if (fctx.flags.fetcheddata) txn->flags.cc |= CC_NOTRANSFORM;\n\n    \/* Setup for chunked response *\/\n    txn->flags.te |= TE_CHUNKED;\n\n    \/* Begin XML response *\/\n    xml_response(HTTP_MULTI_STATUS, txn, fctx.root->doc);\n\n    \/* Generate responses *\/\n    if (txn->req_tgt.namespace->id == URL_NS_PRINCIPAL) {\n        if (!depth || !(fctx.prefer & PREFER_NOROOT)) {\n            \/* Add response for target URL *\/\n            xml_add_response(&fctx, 0, 0, NULL, NULL);\n        }\n\n        if (depth > 0 && !txn->req_tgt.userid) {\n            size_t len = strlen(namespace_principal.prefix);\n            char *p = txn->req_tgt.path + len;\n\n            if (!strcmp(p, \"\/\" USER_COLLECTION_PREFIX \"\/\")) {\n                \/* Normalize depth so that:\n                 * 0 = prin-set, 1+ = collection, 2+ = principal, 3+ = infinity!\n                 *\/\n                depth++;\n            }\n            else {\n                \/* Add a response for 'user' collection *\/\n                snprintf(p, MAX_MAILBOX_PATH - len,\n                         \"\/%s\/\", USER_COLLECTION_PREFIX);\n                xml_add_response(&fctx, 0, 0, NULL, NULL);\n            }\n\n            if (depth >= 2) {\n                \/* Add responses for all user principals *\/\n                ret = mboxlist_alluser(principal_search, &fctx);\n            }\n        }\n    }\n    else {\n        \/* Normalize depth so that:\n         * 0 = home-set, 1+ = collection, 2+ = resource, 3+ = infinity!\n         *\/\n        if (txn->req_tgt.collection) depth++;\n        if (txn->req_tgt.resource) depth++;\n\n        fctx.depth = depth;\n\n        if (!txn->req_tgt.collection &&\n            (!depth || !(fctx.prefer & PREFER_NOROOT))) {\n            \/* Add response for home-set collection *\/\n            if (txn->req_tgt.mbentry) {\n                \/* Open mailbox for reading *\/\n                if ((r = mailbox_open_irl(txn->req_tgt.mbentry->name,\n                                          &fctx.mailbox))\n                    && r != IMAP_MAILBOX_NONEXISTENT) {\n                    syslog(LOG_INFO, \"mailbox_open_irl(%s) failed: %s\",\n                           txn->req_tgt.mbentry->name, error_message(r));\n                    txn->error.desc = error_message(r);\n                    ret = HTTP_SERVER_ERROR;\n                    goto done;\n                }\n\n                fctx.mbentry = txn->req_tgt.mbentry;\n            }\n\n            if (!fctx.req_tgt->resource)\n                xml_add_response(&fctx, 0, 0, NULL, NULL);\n\n            \/* Resource(s) *\/\n            r = propfind_by_resources(&fctx);\n            if (r) ret = r;\n\n            mailbox_close(&fctx.mailbox);\n        }\n\n        if (depth > 0) {\n            \/* Collection(s) *\/\n\n            if (txn->req_tgt.collection) {\n                \/* Add response for target collection *\/\n                propfind_by_collection(txn->req_tgt.mbentry, &fctx);\n            }\n            else if (config_getswitch(IMAPOPT_FASTMAILSHARING)) {\n                \/* Add responses for all visible collections *\/\n                mboxlist_usermboxtree(httpd_userid, httpd_authstate,\n                                      propfind_by_collection,\n                                      &fctx, MBOXTREE_PLUS_RACL);\n            }\n            else if (txn->req_tgt.mbentry) {\n                \/* Add responses for all contained collections *\/\n                fctx.prefer &= ~PREFER_NOROOT;\n                mboxlist_mboxtree(txn->req_tgt.mbentry->name,\n                                  propfind_by_collection, &fctx,\n                                  MBOXTREE_SKIP_ROOT);\n\n                switch (txn->req_tgt.namespace->id) {\n                case URL_NS_DRIVE:\n                    if (txn->req_tgt.flags == TGT_DRIVE_ROOT) {\n                        \/* Add a response for 'user' hierarchy *\/\n                        buf_setcstr(&fctx.buf, txn->req_tgt.namespace->prefix);\n                        buf_printf(&fctx.buf, \"\/%s\/\", USER_COLLECTION_PREFIX);\n                        strlcpy(fctx.req_tgt->path,\n                                buf_cstring(&fctx.buf), MAX_MAILBOX_PATH);\n                        fctx.mbentry = NULL;\n                        fctx.mailbox = NULL;\n                        r = xml_add_response(&fctx, 0, 0, NULL, NULL);\n                    }\n                    break;\n\n                case URL_NS_CALENDAR:\n                    if (fctx.flags.cs_sharing) {\n                        \/* Add response for notification collection *\/\n                        r = propfind_csnotify_collection(&fctx, props);\n                    }\n                    \/* Fall through *\/\n\n                case URL_NS_ADDRESSBOOK:\n                    \/* Add responses for shared collections *\/\n                    mboxlist_usersubs(txn->req_tgt.userid,\n                                      propfind_by_collection, &fctx,\n                                      MBOXTREE_SKIP_PERSONAL);\n                    break;\n                }\n            }\n\n            ret = *fctx.ret;\n        }\n    }\n\n    if (fctx.davdb) fctx.close_db(fctx.davdb);\n\n    \/* End XML response *\/\n    xml_partial_response(txn, fctx.root->doc, NULL \/* end *\/, 0, &fctx.xmlbuf);\n    xmlBufferFree(fctx.xmlbuf);\n\n    \/* End of output *\/\n    write_body(0, txn, NULL, 0);\n    ret = 0;\n\n  done:\n    \/* Free the entry list *\/\n    free_entry_list(fctx.elist);\n\n    buf_free(&fctx.buf);\n\n    free_hash_table(&ns_table, NULL);\n\n    if (outdoc) xmlFreeDoc(outdoc);\n    if (indoc) xmlFreeDoc(indoc);\n\n    return ret;\n}","target":0,"code_token_length":2679,"total_token_length":2915,"max_tokens_setting":4096}
+{"idx":426582,"func":"static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int ReadNextIFD, tag_table_type tag_table)\n{\n\tsize_t length;\n\tunsigned int tag, format, components;\n\tchar *value_ptr, tagname[64], cbuf[32], *outside=NULL;\n\tsize_t byte_count, offset_val, fpos, fgot;\n\tint64_t byte_count_signed;\n\txp_field_type *tmp_xp;\n#ifdef EXIF_DEBUG\n\tchar *dump_data;\n\tint dump_free;\n#endif \/* EXIF_DEBUG *\/\n\n\t\/* Protect against corrupt headers *\/\n\tif (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) {\n\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"corrupt EXIF header: maximum directory nesting level reached\");\n\t\treturn FALSE;\n\t}\n\tImageInfo->ifd_nesting_level++;\n\n\ttag = php_ifd_get16u(dir_entry, ImageInfo->motorola_intel);\n\tformat = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel);\n\tcomponents = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel);\n\n\tif (!format || format > NUM_FORMATS) {\n\t\t\/* (-1) catches illegal zero case as unsigned underflows to positive large. *\/\n\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Process tag(x%04X=%s): Illegal format code 0x%04X, suppose BYTE\", tag, exif_get_tagname(tag, tagname, -12, tag_table), format);\n\t\tformat = TAG_FMT_BYTE;\n\t\t\/*return TRUE;*\/\n\t}\n\n\tif (components <= 0) {\n\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Process tag(x%04X=%s): Illegal components(%d)\", tag, exif_get_tagname(tag, tagname, -12, tag_table), components);\n\t\treturn FALSE;\n\t}\n\n\tbyte_count_signed = (int64_t)components * php_tiff_bytes_per_format[format];\n\n\tif (byte_count_signed < 0 || (byte_count_signed > INT32_MAX)) {\n\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Process tag(x%04X=%s): Illegal byte_count\", tag, exif_get_tagname(tag, tagname, -12, tag_table));\n\t\treturn FALSE;\n\t}\n\n\tbyte_count = (size_t)byte_count_signed;\n\n\tif (byte_count > 4) {\n\t\toffset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel);\n\t\t\/* If its bigger than 4 bytes, the dir entry contains an offset. *\/\n\t\tvalue_ptr = offset_base+offset_val;\n        \/*\n            dir_entry is ImageInfo->file.list[sn].data+2+i*12\n            offset_base is ImageInfo->file.list[sn].data-dir_offset\n            dir_entry - offset_base is dir_offset+2+i*12\n        *\/\n\t\tif (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {\n\t\t\t\/* It is important to check for IMAGE_FILETYPE_TIFF\n\t\t\t * JPEG does not use absolute pointers instead its pointers are\n\t\t\t * relative to the start of the TIFF header in APP1 section. *\/\n\t\t\tif (byte_count > ImageInfo->FileSize || offset_val>ImageInfo->FileSize-byte_count || (ImageInfo->FileType!=IMAGE_FILETYPE_TIFF_II && ImageInfo->FileType!=IMAGE_FILETYPE_TIFF_MM && ImageInfo->FileType!=IMAGE_FILETYPE_JPEG)) {\n\t\t\t\tif (value_ptr < dir_entry) {\n\t\t\t\t\t\/* we can read this if offset_val > 0 *\/\n\t\t\t\t\t\/* some files have their values in other parts of the file *\/\n\t\t\t\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Process tag(x%04X=%s): Illegal pointer offset(x%04X < x%04X)\", tag, exif_get_tagname(tag, tagname, -12, tag_table), offset_val, dir_entry);\n\t\t\t\t} else {\n\t\t\t\t\t\/* this is for sure not allowed *\/\n\t\t\t\t\t\/* exception are IFD pointers *\/\n\t\t\t\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Process tag(x%04X=%s): Illegal pointer offset(x%04X + x%04X = x%04X > x%04X)\", tag, exif_get_tagname(tag, tagname, -12, tag_table), offset_val, byte_count, offset_val+byte_count, IFDlength);\n\t\t\t\t}\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t\tif (byte_count>sizeof(cbuf)) {\n\t\t\t\t\/* mark as outside range and get buffer *\/\n\t\t\t\tvalue_ptr = safe_emalloc(byte_count, 1, 0);\n\t\t\t\toutside = value_ptr;\n\t\t\t} else {\n\t\t\t\t\/* In most cases we only access a small range so\n\t\t\t\t * it is faster to use a static buffer there\n\t\t\t\t * BUT it offers also the possibility to have\n\t\t\t\t * pointers read without the need to free them\n\t\t\t\t * explicitley before returning. *\/\n\t\t\t\tmemset(&cbuf, 0, sizeof(cbuf));\n\t\t\t\tvalue_ptr = cbuf;\n\t\t\t}\n\n\t\t\tfpos = php_stream_tell(ImageInfo->infile);\n\t\t\tphp_stream_seek(ImageInfo->infile, displacement+offset_val, SEEK_SET);\n\t\t\tfgot = php_stream_tell(ImageInfo->infile);\n\t\t\tif (fgot!=displacement+offset_val) {\n\t\t\t\tEFREE_IF(outside);\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Wrong file pointer: 0x%08X != 0x%08X\", fgot, displacement+offset_val);\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t\tfgot = php_stream_read(ImageInfo->infile, value_ptr, byte_count);\n\t\t\tphp_stream_seek(ImageInfo->infile, fpos, SEEK_SET);\n\t\t\tif (fgotsections_found |= FOUND_ANY_TAG;\n#ifdef EXIF_DEBUG\n\tdump_data = exif_dump_data(&dump_free, format, components, length, ImageInfo->motorola_intel, value_ptr);\n\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Process tag(x%04X=%s,@x%04X + x%04X(=%d)): %s%s %s\", tag, exif_get_tagname(tag, tagname, -12, tag_table), offset_val+displacement, byte_count, byte_count, (components>1)&&format!=TAG_FMT_UNDEFINED&&format!=TAG_FMT_STRING?\"ARRAY OF \":\"\", exif_get_tagformat(format), dump_data);\n\tif (dump_free) {\n\t\tefree(dump_data);\n\t}\n#endif\n\n\tif (section_index==SECTION_THUMBNAIL) {\n\t\tif (!ImageInfo->Thumbnail.data) {\n\t\t\tswitch(tag) {\n\t\t\t\tcase TAG_IMAGEWIDTH:\n\t\t\t\tcase TAG_COMP_IMAGE_WIDTH:\n\t\t\t\t\tImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase TAG_IMAGEHEIGHT:\n\t\t\t\tcase TAG_COMP_IMAGE_HEIGHT:\n\t\t\t\t\tImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase TAG_STRIP_OFFSETS:\n\t\t\t\tcase TAG_JPEG_INTERCHANGE_FORMAT:\n\t\t\t\t\t\/* accept both formats *\/\n\t\t\t\t\tImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase TAG_STRIP_BYTE_COUNTS:\n\t\t\t\t\tif (ImageInfo->FileType == IMAGE_FILETYPE_TIFF_II || ImageInfo->FileType == IMAGE_FILETYPE_TIFF_MM) {\n\t\t\t\t\t\tImageInfo->Thumbnail.filetype = ImageInfo->FileType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/* motorola is easier to read *\/\n\t\t\t\t\t\tImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_TIFF_MM;\n\t\t\t\t\t}\n\t\t\t\t\tImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase TAG_JPEG_INTERCHANGE_FORMAT_LEN:\n\t\t\t\t\tif (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) {\n\t\t\t\t\t\tImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG;\n\t\t\t\t\t\tImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (section_index==SECTION_IFD0 || section_index==SECTION_EXIF)\n\t\tswitch(tag) {\n\t\t\tcase TAG_COPYRIGHT:\n\t\t\t\t\/* check for \" NUL  NUL\" *\/\n\t\t\t\tif (byte_count>1 && (length=php_strnlen(value_ptr, byte_count)) > 0) {\n\t\t\t\t\tif (lengthCopyrightPhotographer  = estrdup(value_ptr);\n\t\t\t\t\t\tImageInfo->CopyrightEditor        = estrndup(value_ptr+length+1, byte_count-length-1);\n\t\t\t\t\t\tspprintf(&ImageInfo->Copyright, 0, \"%s, %s\", ImageInfo->CopyrightPhotographer, ImageInfo->CopyrightEditor);\n\t\t\t\t\t\t\/* format = TAG_FMT_UNDEFINED; this musn't be ASCII         *\/\n\t\t\t\t\t\t\/* but we are not supposed to change this                   *\/\n\t\t\t\t\t\t\/* keep in mind that image_info does not store editor value *\/\n\t\t\t\t\t} else {\n\t\t\t\t\t\tImageInfo->Copyright = estrndup(value_ptr, byte_count);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_USERCOMMENT:\n\t\t\t\tEFREE_IF(ImageInfo->UserComment);\n\t\t\t\tImageInfo->UserComment = NULL;\n\t\t\t\tEFREE_IF(ImageInfo->UserCommentEncoding);\n\t\t\t\tImageInfo->UserCommentEncoding = NULL;\n\t\t\t\tImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(ImageInfo->UserCommentEncoding), value_ptr, byte_count);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_XP_TITLE:\n\t\t\tcase TAG_XP_COMMENTS:\n\t\t\tcase TAG_XP_AUTHOR:\n\t\t\tcase TAG_XP_KEYWORDS:\n\t\t\tcase TAG_XP_SUBJECT:\n\t\t\t\ttmp_xp = (xp_field_type*)safe_erealloc(ImageInfo->xp_fields.list, (ImageInfo->xp_fields.count+1), sizeof(xp_field_type), 0);\n\t\t\t\tImageInfo->sections_found |= FOUND_WINXP;\n\t\t\t\tImageInfo->xp_fields.list = tmp_xp;\n\t\t\t\tImageInfo->xp_fields.count++;\n\t\t\t\texif_process_unicode(ImageInfo, &(ImageInfo->xp_fields.list[ImageInfo->xp_fields.count-1]), tag, value_ptr, byte_count);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_FNUMBER:\n\t\t\t\t\/* Simplest way of expressing aperture, so I trust it the most.\n\t\t\t\t   (overwrite previously computed value if there is one) *\/\n\t\t\t\tImageInfo->ApertureFNumber = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_APERTURE:\n\t\t\tcase TAG_MAX_APERTURE:\n\t\t\t\t\/* More relevant info always comes earlier, so only use this field if we don't\n\t\t\t\t   have appropriate aperture information yet. *\/\n\t\t\t\tif (ImageInfo->ApertureFNumber == 0) {\n\t\t\t\t\tImageInfo->ApertureFNumber\n\t\t\t\t\t\t= (float)exp(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*log(2)*0.5);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_SHUTTERSPEED:\n\t\t\t\t\/* More complicated way of expressing exposure time, so only use\n\t\t\t\t   this value if we don't already have it from somewhere else.\n\t\t\t\t   SHUTTERSPEED comes after EXPOSURE TIME\n\t\t\t\t  *\/\n\t\t\t\tif (ImageInfo->ExposureTime == 0) {\n\t\t\t\t\tImageInfo->ExposureTime\n\t\t\t\t\t\t= (float)(1\/exp(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*log(2)));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase TAG_EXPOSURETIME:\n\t\t\t\tImageInfo->ExposureTime = -1;\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_COMP_IMAGE_WIDTH:\n\t\t\t\tImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_FOCALPLANE_X_RES:\n\t\t\t\tImageInfo->FocalplaneXRes = exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_SUBJECT_DISTANCE:\n\t\t\t\t\/* Inidcates the distacne the autofocus camera is focused to.\n\t\t\t\t   Tends to be less accurate as distance increases. *\/\n\t\t\t\tImageInfo->Distance = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_FOCALPLANE_RESOLUTION_UNIT:\n\t\t\t\tswitch((int)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)) {\n\t\t\t\t\tcase 1: ImageInfo->FocalplaneUnits = 25.4; break; \/* inch *\/\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\/* According to the information I was using, 2 measn meters.\n\t\t\t\t\t\t   But looking at the Cannon powershot's files, inches is the only\n\t\t\t\t\t\t   sensible value. *\/\n\t\t\t\t\t\tImageInfo->FocalplaneUnits = 25.4;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 3: ImageInfo->FocalplaneUnits = 10;   break;  \/* centimeter *\/\n\t\t\t\t\tcase 4: ImageInfo->FocalplaneUnits = 1;    break;  \/* milimeter  *\/\n\t\t\t\t\tcase 5: ImageInfo->FocalplaneUnits = .001; break;  \/* micrometer *\/\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_SUB_IFD:\n\t\t\t\tif (format==TAG_FMT_IFD) {\n\t\t\t\t\t\/* If this is called we are either in a TIFFs thumbnail or a JPEG where we cannot handle it *\/\n\t\t\t\t\t\/* TIFF thumbnail: our data structure cannot store a thumbnail of a thumbnail *\/\n\t\t\t\t\t\/* JPEG do we have the data area and what to do with it *\/\n\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Skip SUB IFD\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_MAKE:\n\t\t\t\tImageInfo->make = estrndup(value_ptr, byte_count);\n\t\t\t\tbreak;\n\t\t\tcase TAG_MODEL:\n\t\t\t\tImageInfo->model = estrndup(value_ptr, byte_count);\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_MAKER_NOTE:\n\t\t\t\tif (!exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, offset_base, IFDlength, displacement)) {\n\t\t\t\t\tEFREE_IF(outside);\n\t\t\t\t\treturn FALSE;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase TAG_EXIF_IFD_POINTER:\n\t\t\tcase TAG_GPS_IFD_POINTER:\n\t\t\tcase TAG_INTEROP_IFD_POINTER:\n\t\t\t\tif (ReadNextIFD) {\n\t\t\t\t\tchar *Subdir_start;\n\t\t\t\t\tint sub_section_index = 0;\n\t\t\t\t\tswitch(tag) {\n\t\t\t\t\t\tcase TAG_EXIF_IFD_POINTER:\n#ifdef EXIF_DEBUG\n\t\t\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Found EXIF\");\n#endif\n\t\t\t\t\t\t\tImageInfo->sections_found |= FOUND_EXIF;\n\t\t\t\t\t\t\tsub_section_index = SECTION_EXIF;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TAG_GPS_IFD_POINTER:\n#ifdef EXIF_DEBUG\n\t\t\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Found GPS\");\n#endif\n\t\t\t\t\t\t\tImageInfo->sections_found |= FOUND_GPS;\n\t\t\t\t\t\t\tsub_section_index = SECTION_GPS;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TAG_INTEROP_IFD_POINTER:\n#ifdef EXIF_DEBUG\n\t\t\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Found INTEROPERABILITY\");\n#endif\n\t\t\t\t\t\t\tImageInfo->sections_found |= FOUND_INTEROP;\n\t\t\t\t\t\t\tsub_section_index = SECTION_INTEROP;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tSubdir_start = offset_base + php_ifd_get32u(value_ptr, ImageInfo->motorola_intel);\n\t\t\t\t\tif (Subdir_start < offset_base || Subdir_start > offset_base+IFDlength) {\n\t\t\t\t\t\texif_error_docref(\"exif_read_data#error_ifd\" EXIFERR_CC, ImageInfo, E_WARNING, \"Illegal IFD Pointer\");\n\t\t\t\t\t\treturn FALSE;\n\t\t\t\t\t}\n\t\t\t\t\tif (!exif_process_IFD_in_JPEG(ImageInfo, Subdir_start, offset_base, IFDlength, displacement, sub_section_index, tag)) {\n\t\t\t\t\t\treturn FALSE;\n\t\t\t\t\t}\n#ifdef EXIF_DEBUG\n\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Subsection %s done\", exif_get_sectionname(sub_section_index));\n#endif\n\t\t\t\t}\n\t\t}\n\t}\n\texif_iif_add_tag(ImageInfo, section_index, exif_get_tagname(tag, tagname, sizeof(tagname), tag_table), tag, format, components, value_ptr, byte_count);\n\tEFREE_IF(outside);\n\treturn TRUE;\n}","target":0,"code_token_length":3839,"total_token_length":4075,"max_tokens_setting":4096}
+{"idx":338193,"func":"void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {\n\n    const int mb_xy= mb_x + mb_y*h->mb_stride;\n\n    const int mb_type = h->cur_pic.mb_type[mb_xy];\n\n    const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;\n\n    int first_vertical_edge_done = 0;\n\n    av_unused int dir;\n\n    int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));\n\n    int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);\n\n    int a = h->slice_alpha_c0_offset - qp_bd_offset;\n\n    int b = h->slice_beta_offset - qp_bd_offset;\n\n\n\n    if (FRAME_MBAFF(h)\n\n            \/\/ and current and left pair do not have the same interlaced type\n\n            && IS_INTERLACED(mb_type^h->left_type[LTOP])\n\n            \/\/ and left mb is in available to us\n\n            && h->left_type[LTOP]) {\n\n        \/* First vertical edge is different in MBAFF frames\n\n         * There are 8 different bS to compute and 2 different Qp\n\n         *\/\n\n        DECLARE_ALIGNED(8, int16_t, bS)[8];\n\n        int qp[2];\n\n        int bqp[2];\n\n        int rqp[2];\n\n        int mb_qp, mbn0_qp, mbn1_qp;\n\n        int i;\n\n        first_vertical_edge_done = 1;\n\n\n\n        if( IS_INTRA(mb_type) ) {\n\n            AV_WN64A(&bS[0], 0x0004000400040004ULL);\n\n            AV_WN64A(&bS[4], 0x0004000400040004ULL);\n\n        } else {\n\n            static const uint8_t offset[2][2][8]={\n\n                {\n\n                    {3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},\n\n                    {3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},\n\n                },{\n\n                    {3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},\n\n                    {3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},\n\n                }\n\n            };\n\n            const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];\n\n            for( i = 0; i < 8; i++ ) {\n\n                int j= MB_FIELD(h) ? i>>2 : i&1;\n\n                int mbn_xy = h->left_mb_xy[LEFT(j)];\n\n                int mbn_type= h->left_type[LEFT(j)];\n\n\n\n                if( IS_INTRA( mbn_type ) )\n\n                    bS[i] = 4;\n\n                else{\n\n                    bS[i] = 1 + !!(h->non_zero_count_cache[12+8*(i>>1)] |\n\n                         ((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?\n\n                            (h->cbp_table[mbn_xy] & (((MB_FIELD(h) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))\n\n                                                                       :\n\n                            h->non_zero_count[mbn_xy][ off[i] ]));\n\n                }\n\n            }\n\n        }\n\n\n\n        mb_qp   = h->cur_pic.qscale_table[mb_xy];\n\n        mbn0_qp = h->cur_pic.qscale_table[h->left_mb_xy[0]];\n\n        mbn1_qp = h->cur_pic.qscale_table[h->left_mb_xy[1]];\n\n        qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;\n\n        bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +\n\n                   get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;\n\n        rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +\n\n                   get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;\n\n        qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;\n\n        bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +\n\n                   get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;\n\n        rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +\n\n                   get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;\n\n\n\n        \/* Filter edge *\/\n\n        tprintf(h->avctx, \"filter mb:%d\/%d MBAFF, QPy:%d\/%d, QPb:%d\/%d QPr:%d\/%d ls:%d uvls:%d\", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);\n\n        { int i; for (i = 0; i < 8; i++) tprintf(h->avctx, \" bS[%d]:%d\", i, bS[i]); tprintf(h->avctx, \"\\n\"); }\n\n        if (MB_FIELD(h)) {\n\n            filter_mb_mbaff_edgev ( h, img_y                ,   linesize, bS  , 1, qp [0], a, b, 1 );\n\n            filter_mb_mbaff_edgev ( h, img_y  + 8*  linesize,   linesize, bS+4, 1, qp [1], a, b, 1 );\n\n            if (chroma){\n\n                if (CHROMA444(h)) {\n\n                    filter_mb_mbaff_edgev ( h, img_cb,                uvlinesize, bS  , 1, bqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );\n\n                    filter_mb_mbaff_edgev ( h, img_cr,                uvlinesize, bS  , 1, rqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );\n\n                } else if (CHROMA422(h)) {\n\n                    filter_mb_mbaff_edgecv(h, img_cb,                uvlinesize, bS  , 1, bqp[0], a, b, 1);\n\n                    filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);\n\n                    filter_mb_mbaff_edgecv(h, img_cr,                uvlinesize, bS  , 1, rqp[0], a, b, 1);\n\n                    filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);\n\n                }else{\n\n                    filter_mb_mbaff_edgecv( h, img_cb,                uvlinesize, bS  , 1, bqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );\n\n                    filter_mb_mbaff_edgecv( h, img_cr,                uvlinesize, bS  , 1, rqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );\n\n                }\n\n            }\n\n        }else{\n\n            filter_mb_mbaff_edgev ( h, img_y              , 2*  linesize, bS  , 2, qp [0], a, b, 1 );\n\n            filter_mb_mbaff_edgev ( h, img_y  +   linesize, 2*  linesize, bS+1, 2, qp [1], a, b, 1 );\n\n            if (chroma){\n\n                if (CHROMA444(h)) {\n\n                    filter_mb_mbaff_edgev ( h, img_cb,              2*uvlinesize, bS  , 2, bqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );\n\n                    filter_mb_mbaff_edgev ( h, img_cr,              2*uvlinesize, bS  , 2, rqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );\n\n                }else{\n\n                    filter_mb_mbaff_edgecv( h, img_cb,              2*uvlinesize, bS  , 2, bqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );\n\n                    filter_mb_mbaff_edgecv( h, img_cr,              2*uvlinesize, bS  , 2, rqp[0], a, b, 1 );\n\n                    filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );\n\n                }\n\n            }\n\n        }\n\n    }\n\n\n\n#if CONFIG_SMALL\n\n    for( dir = 0; dir < 2; dir++ )\n\n        filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, dir);\n\n#else\n\n    filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);\n\n    filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0,                        a, b, chroma, 1);\n\n#endif\n\n}\n","target":0,"code_token_length":2598,"total_token_length":2834,"max_tokens_setting":4096}
+{"idx":148780,"func":"  void operator()(OpKernelContext* context, const Tensor& y_backprop,\n                  const Tensor& x, const Tensor& scale, const Tensor* offset,\n                  const Tensor& mean, const Tensor& inv_variance,\n                  const Tensor* y, U epsilon,\n                  FusedBatchNormActivationMode activation_mode,\n                  Tensor* x_backprop, Tensor* scale_backprop,\n                  Tensor* offset_backprop, Tensor* side_input_backprop,\n                  bool use_reserved_space, TensorFormat tensor_format) {\n    auto* stream = context->op_device_context()->stream();\n    OP_REQUIRES(context, stream, errors::Internal(\"No GPU stream available\"));\n\n    const int64_t batch_size = GetTensorDim(x, tensor_format, 'N');\n    const int64_t channels = GetTensorDim(x, tensor_format, 'C');\n    const int64_t height = GetTensorDim(x, tensor_format, 'H');\n    const int64_t width = GetTensorDim(x, tensor_format, 'W');\n\n#if GOOGLE_CUDA\n    \/\/ Check if cuDNN batch normalization has a fast NHWC implementation:\n    \/\/   (1) Tensorflow enabled batchnorm spatial persistence, and\n    \/\/       FusedBatchNormGradV3 passed non-null reserve space and allocator.\n    const bool fast_nhwc_batch_norm = BatchnormSpatialPersistentEnabled() &&\n                                      DataTypeToEnum::value == DT_HALF &&\n                                      use_reserved_space;\n#else\n    \/\/ fast NHWC implementation is a CUDA only feature\n    const bool fast_nhwc_batch_norm = false;\n#endif\n\n    \/\/ If input tensor is in NHWC format, and we have a fast cuDNN\n    \/\/ implementation, there is no need to do data format conversion.\n    TensorFormat compute_format =\n        fast_nhwc_batch_norm && tensor_format == FORMAT_NHWC ? FORMAT_NHWC\n                                                             : FORMAT_NCHW;\n\n    VLOG(2) << \"FusedBatchNormGrad:\"\n            << \" batch_size: \" << batch_size << \" channels: \" << channels\n            << \" height: \" << height << \" width: \" << width\n            << \" y_backprop shape: \" << y_backprop.shape().DebugString()\n            << \" x shape: \" << x.shape().DebugString()\n            << \" scale shape: \" << scale.shape().DebugString()\n            << \" activation mode: \" << ToString(activation_mode)\n            << \" tensor format: \" << ToString(tensor_format)\n            << \" compute format: \" << ToString(compute_format);\n\n    \/\/ Inputs\n    Tensor y_backprop_maybe_transformed = y_backprop;\n    Tensor x_maybe_transformed = x;\n    Tensor y_backprop_transformed;\n    Tensor x_transformed;\n\n    \/\/ Outputs\n    Tensor x_backprop_transformed;\n    se::DeviceMemory x_backprop_ptr;\n\n    if (tensor_format == compute_format) {\n      x_backprop_ptr = StreamExecutorUtil::AsDeviceMemory(*x_backprop);\n    } else if (tensor_format == FORMAT_NHWC && compute_format == FORMAT_NCHW) {\n      \/\/ Transform inputs from 'NHWC' to 'NCHW'\n      OP_REQUIRES_OK(context, context->allocate_temp(\n                                  DataTypeToEnum::value,\n                                  ShapeFromFormat(FORMAT_NCHW, batch_size,\n                                                  height, width, channels),\n                                  &y_backprop_transformed));\n      functor::NHWCToNCHW()(\n          context->eigen_device(),\n          const_cast(y_backprop_maybe_transformed)\n              .tensor(),\n          y_backprop_transformed.tensor());\n      y_backprop_maybe_transformed = y_backprop_transformed;\n\n      OP_REQUIRES_OK(context, context->allocate_temp(\n                                  DataTypeToEnum::value,\n                                  ShapeFromFormat(FORMAT_NCHW, batch_size,\n                                                  height, width, channels),\n                                  &x_transformed));\n      functor::NHWCToNCHW()(\n          context->eigen_device(),\n          const_cast(x_maybe_transformed).tensor(),\n          x_transformed.tensor());\n      x_maybe_transformed = x_transformed;\n\n      \/\/ Allocate memory for transformed outputs in 'NCHW'\n      OP_REQUIRES_OK(context, context->allocate_temp(\n                                  DataTypeToEnum::value,\n                                  ShapeFromFormat(FORMAT_NCHW, batch_size,\n                                                  height, width, channels),\n                                  &x_backprop_transformed));\n      x_backprop_ptr =\n          StreamExecutorUtil::AsDeviceMemory(x_backprop_transformed);\n    } else {\n      context->SetStatus(errors::Internal(\n          \"Unsupported tensor format: \", ToString(tensor_format),\n          \" and compute format: \", ToString(compute_format)));\n      return;\n    }\n\n    const se::dnn::DataLayout data_layout =\n        compute_format == FORMAT_NHWC ? se::dnn::DataLayout::kBatchYXDepth\n                                      : se::dnn::DataLayout::kBatchDepthYX;\n\n    se::dnn::BatchDescriptor x_desc;\n    x_desc.set_count(batch_size)\n        .set_feature_map_count(channels)\n        .set_height(height)\n        .set_width(width)\n        .set_layout(data_layout);\n\n    se::dnn::BatchDescriptor scale_offset_desc;\n    scale_offset_desc.set_count(1)\n        .set_feature_map_count(channels)\n        .set_height(1)\n        .set_width(1)\n        .set_layout(se::dnn::DataLayout::kBatchDepthYX);\n\n    auto y_backprop_ptr =\n        StreamExecutorUtil::AsDeviceMemory(y_backprop_maybe_transformed);\n    auto x_ptr = StreamExecutorUtil::AsDeviceMemory(x_maybe_transformed);\n    auto scale_ptr = StreamExecutorUtil::AsDeviceMemory(scale);\n    auto offset_ptr = offset != nullptr\n                          ? StreamExecutorUtil::AsDeviceMemory(*offset)\n                          : se::DeviceMemory();\n    auto mean_ptr = StreamExecutorUtil::AsDeviceMemory(mean);\n    auto inv_variance_ptr = StreamExecutorUtil::AsDeviceMemory(inv_variance);\n    auto y_ptr = y != nullptr ? StreamExecutorUtil::AsDeviceMemory(*y)\n                              : se::DeviceMemory();\n    auto scale_backprop_ptr =\n        StreamExecutorUtil::AsDeviceMemory(*scale_backprop);\n    auto offset_backprop_ptr =\n        StreamExecutorUtil::AsDeviceMemory(*offset_backprop);\n    auto side_input_backprop_ptr =\n        side_input_backprop != nullptr\n            ? StreamExecutorUtil::AsDeviceMemory(*side_input_backprop)\n            : se::DeviceMemory();\n\n    std::unique_ptr>\n        workspace_allocator;\n    DeviceMemory* reserve_space_data_ptr = nullptr;\n    DeviceMemory reserve_space_data;\n#if CUDNN_VERSION >= 7402\n    if (use_reserved_space) {\n      const Tensor& reserve_space = context->input(5);\n      workspace_allocator.reset(\n          new functor::CudnnBatchNormAllocatorInTemp(context));\n\n      \/\/ the cudnn kernel outputs inverse variance in forward and reuse it in\n      \/\/ backward\n      if (reserve_space.dims() != 0) {\n        reserve_space_data = functor::CastDeviceMemory(\n            const_cast(&reserve_space));\n        reserve_space_data_ptr = &reserve_space_data;\n      }\n    }\n#endif  \/\/ CUDNN_VERSION >= 7402\n\n    bool cudnn_launch_status =\n        stream\n            ->ThenBatchNormalizationBackward(\n                y_backprop_ptr, x_ptr, scale_ptr, offset_ptr, mean_ptr,\n                inv_variance_ptr, y_ptr, x_desc, scale_offset_desc,\n                static_cast(epsilon),\n                AsDnnActivationMode(activation_mode), &x_backprop_ptr,\n                &scale_backprop_ptr, &offset_backprop_ptr,\n                &side_input_backprop_ptr, reserve_space_data_ptr,\n                workspace_allocator.get())\n            .ok();\n\n    if (!cudnn_launch_status) {\n      context->SetStatus(\n          errors::Internal(\"cuDNN launch failure : input shape (\",\n                           x.shape().DebugString(), \")\"));\n    }\n    if (tensor_format == FORMAT_NHWC && compute_format == FORMAT_NCHW) {\n      functor::NCHWToNHWC()(\n          context->eigen_device(),\n          const_cast(x_backprop_transformed).tensor(),\n          x_backprop->tensor());\n    }\n  }","target":0,"code_token_length":1839,"total_token_length":2075,"max_tokens_setting":4096}
+{"idx":344017,"func":"rfbBool rfbProcessFileTransfer(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length)\n{\n    char *buffer=NULL, *p=NULL;\n    int retval=0;\n    char filename1[MAX_PATH];\n    char filename2[MAX_PATH];\n    char szFileTime[MAX_PATH];\n    struct stat statbuf;\n    uint32_t sizeHtmp=0;\n    int n=0;\n    char timespec[64];\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n    unsigned char compBuff[sz_rfbBlockSize];\n    unsigned long nRawBytes = sz_rfbBlockSize;\n    int nRet = 0;\n#endif\n\n    FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN(\"\", cl, FALSE);\n        \n    \/*\n    rfbLog(\"rfbProcessFileTransfer(%dtype, %dparam, %dsize, %dlen)\\n\", contentType, contentParam, size, length);\n    *\/\n\n    switch (contentType) {\n    case rfbDirContentRequest:\n        switch (contentParam) {\n        case rfbRDrivesList: \/* Client requests the List of Local Drives *\/\n            \/*\n            rfbLog(\"rfbProcessFileTransfer() rfbDirContentRequest: rfbRDrivesList:\\n\");\n            *\/\n            \/* Format when filled : \"C:\\D:\\....Z:\\\n             *\n             * We replace the \"\\\" char following the drive letter and \":\"\n             * with a char corresponding to the type of drive\n             * We obtain something like \"C:lD:c....Z:n\\\"\n             *  Isn't it ugly ?\n             * DRIVE_FIXED = 'l'     (local?)\n             * DRIVE_REMOVABLE = 'f' (floppy?)\n             * DRIVE_CDROM = 'c'\n             * DRIVE_REMOTE = 'n'\n             *\/\n            \n            \/* in unix, there are no 'drives'  (We could list mount points though)\n             * We fake the root as a \"C:\" for the Winblows users\n             *\/\n            filename2[0]='C';\n            filename2[1]=':';\n            filename2[2]='l';\n            filename2[3]=0;\n            filename2[4]=0;\n            retval = rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADrivesList, 0, 5, filename2);\n            if (buffer!=NULL) free(buffer);\n            return retval;\n            break;\n        case rfbRDirContent: \/* Client requests the content of a directory *\/\n            \/*\n            rfbLog(\"rfbProcessFileTransfer() rfbDirContentRequest: rfbRDirContent\\n\");\n            *\/\n            if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE;\n            retval = rfbSendDirContent(cl, length, buffer);\n            if (buffer!=NULL) free(buffer);\n            return retval;\n        }\n        break;\n\n    case rfbDirPacket:\n        rfbLog(\"rfbProcessFileTransfer() rfbDirPacket\\n\");\n        break;\n    case rfbFileAcceptHeader:\n        rfbLog(\"rfbProcessFileTransfer() rfbFileAcceptHeader\\n\");\n        break;\n    case rfbCommandReturn:\n        rfbLog(\"rfbProcessFileTransfer() rfbCommandReturn\\n\");\n        break;\n    case rfbFileChecksums:\n        \/* Destination file already exists - the viewer sends the checksums *\/\n        rfbLog(\"rfbProcessFileTransfer() rfbFileChecksums\\n\");\n        break;\n    case rfbFileTransferAccess:\n        rfbLog(\"rfbProcessFileTransfer() rfbFileTransferAccess\\n\");\n        break;\n\n    \/*\n     * sending from the server to the viewer\n     *\/\n\n    case rfbFileTransferRequest:\n        \/*\n        rfbLog(\"rfbProcessFileTransfer() rfbFileTransferRequest:\\n\");\n        *\/\n        \/* add some space to the end of the buffer as we will be adding a timespec to it *\/\n        if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE;\n        \/* The client requests a File *\/\n        rfbFilenameTranslate2UNIX(cl, buffer, filename1);\n        cl->fileTransfer.fd=open(filename1, O_RDONLY, 0744);\n\n        \/*\n        *\/\n        if (DB) rfbLog(\"rfbProcessFileTransfer() rfbFileTransferRequest(\\\"%s\\\"->\\\"%s\\\") Open: %s fd=%d\\n\", buffer, filename1, (cl->fileTransfer.fd==-1?\"Failed\":\"Success\"), cl->fileTransfer.fd);\n        \n        if (cl->fileTransfer.fd!=-1) {\n            if (fstat(cl->fileTransfer.fd, &statbuf)!=0) {\n                close(cl->fileTransfer.fd);\n                cl->fileTransfer.fd=-1;\n            }\n            else\n            {\n              \/* Add the File Time Stamp to the filename *\/\n              strftime(timespec, sizeof(timespec), \"%m\/%d\/%Y %H:%M\",gmtime(&statbuf.st_ctime));\n              buffer=realloc(buffer, length + strlen(timespec) + 2); \/* comma, and Null term *\/\n              if (buffer==NULL) {\n                  rfbLog(\"rfbProcessFileTransfer() rfbFileTransferRequest: Failed to malloc %d bytes\\n\", length + strlen(timespec) + 2);\n                  return FALSE;\n              }\n              strcat(buffer,\",\");\n              strcat(buffer, timespec);\n              length = strlen(buffer);\n              if (DB) rfbLog(\"rfbProcessFileTransfer() buffer is now: \\\"%s\\\"\\n\", buffer);\n            }\n        }\n\n        \/* The viewer supports compression if size==1 *\/\n        cl->fileTransfer.compressionEnabled = (size==1);\n\n        \/*\n        rfbLog(\"rfbProcessFileTransfer() rfbFileTransferRequest(\\\"%s\\\"->\\\"%s\\\")%s\\n\", buffer, filename1, (size==1?\" \":\"\"));\n        *\/\n\n        \/* File Size in bytes, 0xFFFFFFFF (-1) means error *\/\n        retval = rfbSendFileTransferMessage(cl, rfbFileHeader, 0, (cl->fileTransfer.fd==-1 ? -1 : statbuf.st_size), length, buffer);\n\n        if (cl->fileTransfer.fd==-1)\n        {\n            if (buffer!=NULL) free(buffer);\n            return retval;\n        }\n        \/* setup filetransfer stuff *\/\n        cl->fileTransfer.fileSize = statbuf.st_size;\n        cl->fileTransfer.numPackets = statbuf.st_size \/ sz_rfbBlockSize;\n        cl->fileTransfer.receiving = 0;\n        cl->fileTransfer.sending = 0; \/* set when we receive a rfbFileHeader: *\/\n\n        \/* TODO: finish 64-bit file size support *\/\n        sizeHtmp = 0;        \n        if (rfbWriteExact(cl, (char *)&sizeHtmp, 4) < 0) {\n          rfbLogPerror(\"rfbProcessFileTransfer: write\");\n          rfbCloseClient(cl);\n          if (buffer!=NULL) free(buffer);\n          return FALSE;\n        }\n        break;\n\n    case rfbFileHeader:\n        \/* Destination file (viewer side) is ready for reception (size > 0) or not (size = -1) *\/\n        if (size==-1) {\n            rfbLog(\"rfbProcessFileTransfer() rfbFileHeader (error, aborting)\\n\");\n            close(cl->fileTransfer.fd);\n            cl->fileTransfer.fd=-1;\n            return TRUE;\n        }\n\n        \/*\n        rfbLog(\"rfbProcessFileTransfer() rfbFileHeader (%d bytes of a file)\\n\", size);\n        *\/\n\n        \/* Starts the transfer! *\/\n        cl->fileTransfer.sending=1;\n        return rfbSendFileTransferChunk(cl);\n        break;\n\n\n    \/*\n     * sending from the viewer to the server\n     *\/\n\n    case rfbFileTransferOffer:\n        \/* client is sending a file to us *\/\n        \/* buffer contains full path name (plus FileTime) *\/\n        \/* size contains size of the file *\/\n        \/*\n        rfbLog(\"rfbProcessFileTransfer() rfbFileTransferOffer:\\n\");\n        *\/\n        if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE;\n\n        \/* Parse the FileTime *\/\n        p = strrchr(buffer, ',');\n        if (p!=NULL) {\n            *p = '\\0';\n            strcpy(szFileTime, p+1);\n        } else\n            szFileTime[0]=0;\n\n\n\n        \/* Need to read in sizeHtmp *\/\n        if ((n = rfbReadExact(cl, (char *)&sizeHtmp, 4)) <= 0) {\n            if (n != 0)\n                rfbLogPerror(\"rfbProcessFileTransfer: read sizeHtmp\");\n            rfbCloseClient(cl);\n            \/* NOTE: don't forget to free(buffer) if you return early! *\/\n            if (buffer!=NULL) free(buffer);\n            return FALSE;\n        }\n        sizeHtmp = Swap32IfLE(sizeHtmp);\n        \n        rfbFilenameTranslate2UNIX(cl, buffer, filename1);\n\n        \/* If the file exists... We can send a rfbFileChecksums back to the client before we send an rfbFileAcceptHeader *\/\n        \/* TODO: Delta Transfer *\/\n\n        cl->fileTransfer.fd=open(filename1, O_CREAT|O_WRONLY|O_TRUNC, 0744);\n        if (DB) rfbLog(\"rfbProcessFileTransfer() rfbFileTransferOffer(\\\"%s\\\"->\\\"%s\\\") %s %s fd=%d\\n\", buffer, filename1, (cl->fileTransfer.fd==-1?\"Failed\":\"Success\"), (cl->fileTransfer.fd==-1?strerror(errno):\"\"), cl->fileTransfer.fd);\n        \/*\n        *\/\n        \n        \/* File Size in bytes, 0xFFFFFFFF (-1) means error *\/\n        retval = rfbSendFileTransferMessage(cl, rfbFileAcceptHeader, 0, (cl->fileTransfer.fd==-1 ? -1 : 0), length, buffer);\n        if (cl->fileTransfer.fd==-1) {\n            free(buffer);\n            return retval;\n        }\n        \n        \/* setup filetransfer stuff *\/\n        cl->fileTransfer.fileSize = size;\n        cl->fileTransfer.numPackets = size \/ sz_rfbBlockSize;\n        cl->fileTransfer.receiving = 1;\n        cl->fileTransfer.sending = 0;\n        break;\n\n    case rfbFilePacket:\n        \/*\n        rfbLog(\"rfbProcessFileTransfer() rfbFilePacket:\\n\");\n        *\/\n        if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE;\n        if (cl->fileTransfer.fd!=-1) {\n            \/* buffer contains the contents of the file *\/\n            if (size==0)\n                retval=write(cl->fileTransfer.fd, buffer, length);\n            else\n            {\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n                \/* compressed packet *\/\n                nRet = uncompress(compBuff,&nRawBytes,(const unsigned char*)buffer, length);\n                retval=write(cl->fileTransfer.fd, compBuff, nRawBytes);\n#else\n                \/* Write the file out as received... *\/\n                retval=write(cl->fileTransfer.fd, buffer, length);\n#endif\n            }\n            if (retval==-1)\n            {\n                close(cl->fileTransfer.fd);\n                cl->fileTransfer.fd=-1;\n                cl->fileTransfer.sending   = 0;\n                cl->fileTransfer.receiving = 0;\n            }\n        }\n        break;\n\n    case rfbEndOfFile:\n        if (DB) rfbLog(\"rfbProcessFileTransfer() rfbEndOfFile\\n\");\n        \/*\n        *\/\n        if (cl->fileTransfer.fd!=-1)\n            close(cl->fileTransfer.fd);\n        cl->fileTransfer.fd=-1;\n        cl->fileTransfer.sending   = 0;\n        cl->fileTransfer.receiving = 0;\n        break;\n\n    case rfbAbortFileTransfer:\n        if (DB) rfbLog(\"rfbProcessFileTransfer() rfbAbortFileTransfer\\n\");\n        \/*\n        *\/\n        if (cl->fileTransfer.fd!=-1)\n        {\n            close(cl->fileTransfer.fd);\n            cl->fileTransfer.fd=-1;\n            cl->fileTransfer.sending   = 0;\n            cl->fileTransfer.receiving = 0;\n        }\n        else\n        {\n            \/* We use this message for FileTransfer rights (<=RC18 versions)\n             * The client asks for FileTransfer permission\n             *\/\n            if (contentParam == 0)\n            {\n                rfbLog(\"rfbProcessFileTransfer() File Transfer Permission DENIED! (Client Version <=RC18)\\n\");\n                \/* Old method for FileTransfer handshake perimssion (<=RC18) (Deny it)*\/\n                return rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, -1, 0, \"\");\n            }\n            \/* New method is allowed *\/\n            if (cl->screen->getFileTransferPermission!=NULL)\n            {\n                if (cl->screen->getFileTransferPermission(cl)==TRUE)\n                {\n                    rfbLog(\"rfbProcessFileTransfer() File Transfer Permission Granted!\\n\");\n                    return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, 1 , 0, \"\"); \/* Permit *\/\n                }\n                else\n                {\n                    rfbLog(\"rfbProcessFileTransfer() File Transfer Permission DENIED!\\n\");\n                    return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, -1 , 0, \"\"); \/* Deny *\/\n                }\n            }\n            else\n            {\n                if (cl->screen->permitFileTransfer)\n                {\n                    rfbLog(\"rfbProcessFileTransfer() File Transfer Permission Granted!\\n\");\n                    return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, 1 , 0, \"\"); \/* Permit *\/\n                }\n                else\n                {\n                    rfbLog(\"rfbProcessFileTransfer() File Transfer Permission DENIED by default!\\n\");\n                    return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, -1 , 0, \"\"); \/* DEFAULT: DENY (for security) *\/\n                }\n                \n            }\n        }\n        break;\n\n\n    case rfbCommand:\n        \/*\n        rfbLog(\"rfbProcessFileTransfer() rfbCommand:\\n\");\n        *\/\n        if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE;\n        switch (contentParam) {\n        case rfbCDirCreate:  \/* Client requests the creation of a directory *\/\n            rfbFilenameTranslate2UNIX(cl, buffer, filename1);\n            retval = mkdir(filename1, 0755);\n            if (DB) rfbLog(\"rfbProcessFileTransfer() rfbCommand: rfbCDirCreate(\\\"%s\\\"->\\\"%s\\\") %s\\n\", buffer, filename1, (retval==-1?\"Failed\":\"Success\"));\n            \/*\n            *\/\n            retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbADirCreate, retval, length, buffer);\n            if (buffer!=NULL) free(buffer);\n            return retval;\n        case rfbCFileDelete: \/* Client requests the deletion of a file *\/\n            rfbFilenameTranslate2UNIX(cl, buffer, filename1);\n            if (stat(filename1,&statbuf)==0)\n            {\n                if (S_ISDIR(statbuf.st_mode))\n                    retval = rmdir(filename1);\n                else\n                    retval = unlink(filename1);\n            }\n            else retval=-1;\n            retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbAFileDelete, retval, length, buffer);\n            if (buffer!=NULL) free(buffer);\n            return retval;\n        case rfbCFileRename: \/* Client requests the Renaming of a file\/directory *\/\n            p = strrchr(buffer, '*');\n            if (p != NULL)\n            {\n                \/* Split into 2 filenames ('*' is a seperator) *\/\n                *p = '\\0';\n                rfbFilenameTranslate2UNIX(cl, buffer, filename1);\n                rfbFilenameTranslate2UNIX(cl, p+1,    filename2);\n                retval = rename(filename1,filename2);\n                if (DB) rfbLog(\"rfbProcessFileTransfer() rfbCommand: rfbCFileRename(\\\"%s\\\"->\\\"%s\\\" -->> \\\"%s\\\"->\\\"%s\\\") %s\\n\", buffer, filename1, p+1, filename2, (retval==-1?\"Failed\":\"Success\"));\n                \/*\n                *\/\n                \/* Restore the buffer so the reply is good *\/\n                *p = '*';\n                retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbAFileRename, retval, length, buffer);\n                if (buffer!=NULL) free(buffer);\n                return retval;\n            }\n            break;\n        }\n    \n        break;\n    }\n\n    \/* NOTE: don't forget to free(buffer) if you return early! *\/\n    if (buffer!=NULL) free(buffer);\n    return TRUE;\n}","target":1,"code_token_length":3639,"total_token_length":3875,"max_tokens_setting":4096}
+{"idx":400964,"func":"static int audit_null_notify(MYSQL_THD thd,\n                             mysql_event_class_t event_class,\n                             const void *event)\n{\n  char buffer[2000]= { 0, };\n  int buffer_data= 0;\n  unsigned long event_subclass= (unsigned long)*(int *)event;\n  const char *order_str= (const char *)THDVAR(thd, event_order_check);\n  int event_order_started= (int)THDVAR(thd, event_order_started);\n  int exact_check= (int)THDVAR(thd, event_order_check_exact);\n  LEX_CSTRING event_name= event_to_str(event_class, event_subclass);\n  LEX_CSTRING event_token= get_token(&order_str);\n  LEX_CSTRING event_data= get_token(&order_str);\n  LEX_CSTRING event_command= get_token(&order_str);\n  my_bool consume_event= TRUE;\n\n  \/* prone to races, oh well *\/\n  number_of_calls++;\n\n  if (event_class == MYSQL_AUDIT_GENERAL_CLASS)\n  {\n    const struct mysql_event_general *event_general=\n                                    (const struct mysql_event_general *)event;\n\n    switch (event_general->event_subclass)\n    {\n    case MYSQL_AUDIT_GENERAL_LOG:\n      number_of_calls_general_log++;\n      break;\n    case MYSQL_AUDIT_GENERAL_ERROR:\n      number_of_calls_general_error++;\n      break;\n    case MYSQL_AUDIT_GENERAL_RESULT:\n      number_of_calls_general_result++;\n      break;\n    case MYSQL_AUDIT_GENERAL_STATUS:\n      number_of_calls_general_status++;\n      break;\n    default:\n      break;\n    }\n  }\n  else if (event_class == MYSQL_AUDIT_CONNECTION_CLASS)\n  {\n    const struct mysql_event_connection *event_connection=\n                                (const struct mysql_event_connection *) event;\n\n    switch (event_connection->event_subclass)\n    {\n    case MYSQL_AUDIT_CONNECTION_CONNECT:\n      number_of_calls_connection_connect++;\n      break;\n    case MYSQL_AUDIT_CONNECTION_DISCONNECT:\n      number_of_calls_connection_disconnect++;\n      break;\n    case MYSQL_AUDIT_CONNECTION_CHANGE_USER:\n      number_of_calls_connection_change_user++;\n      break;\n    case MYSQL_AUDIT_CONNECTION_PRE_AUTHENTICATE:\n      number_of_calls_connection_pre_authenticate++;\n        break;\n    default:\n      break;\n    }\n  }\n  else if (event_class == MYSQL_AUDIT_PARSE_CLASS)\n  {\n    const struct mysql_event_parse *event_parse =\n                                      (const struct mysql_event_parse *)event;\n\n    switch (event_parse->event_subclass)\n    {\n    case MYSQL_AUDIT_PARSE_PREPARSE:\n      number_of_calls_parse_preparse++;\n      break;\n    case MYSQL_AUDIT_PARSE_POSTPARSE:\n      number_of_calls_parse_postparse++;\n      break;\n    default:\n      break;\n    }\n  }\n  \/**\n    Currently events not active.\n\n  else if (event_class == MYSQL_AUDIT_AUTHORIZATION_CLASS)\n  {\n    const struct mysql_event_authorization *event_grant =\n                             (const struct mysql_event_authorization *)event;\n\n    buffer_data= sprintf(buffer, \"db=\\\"%s\\\" table=\\\"%s\\\" object=\\\"%s\\\" \"\n                         \"requested=\\\"0x%08x\\\" granted=\\\"0x%08x\\\"\",\n                         event_grant->database.str ? event_grant->database.str : \"\",\n                         event_grant->table.str ? event_grant->table.str : \"\",\n                         event_grant->object.str ? event_grant->object.str : \"\",\n                         event_grant->requested_privilege,\n                         event_grant->granted_privilege);\n\n    switch (event_grant->event_subclass)\n    {\n    case MYSQL_AUDIT_AUTHORIZATION_USER:\n      number_of_calls_authorization_user++;\n      break;\n    case MYSQL_AUDIT_AUTHORIZATION_DB:\n      number_of_calls_authorization_db++;\n      break;\n    case MYSQL_AUDIT_AUTHORIZATION_TABLE:\n      number_of_calls_authorization_table++;\n      break;\n    case MYSQL_AUDIT_AUTHORIZATION_COLUMN:\n      number_of_calls_authorization_column++;\n      break;\n    case MYSQL_AUDIT_AUTHORIZATION_PROCEDURE:\n      number_of_calls_authorization_procedure++;\n      break;\n    case MYSQL_AUDIT_AUTHORIZATION_PROXY:\n      number_of_calls_authorization_proxy++;\n      break;\n    default:\n      break;\n    }\n  }\n  *\/\n  else if (event_class == MYSQL_AUDIT_SERVER_STARTUP_CLASS)\n  {\n    \/* const struct mysql_event_server_startup *event_startup=\n       (const struct mysql_event_server_startup *) event; *\/\n    number_of_calls_server_startup++;\n  }\n  else if (event_class == MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS)\n  {\n    \/* const struct mysql_event_server_shutdown *event_startup=\n       (const struct mysql_event_server_shutdown *) event; *\/\n    number_of_calls_server_shutdown++;\n  }\n  else if (event_class == MYSQL_AUDIT_COMMAND_CLASS)\n  {\n    const struct mysql_event_command *event_command=\n                                    (const struct mysql_event_command *)event;\n\n    buffer_data= sprintf(buffer, \"command_id=\\\"%d\\\"\", event_command->command_id);\n\n    switch (event_command->event_subclass)\n    {\n    case MYSQL_AUDIT_COMMAND_START:\n      number_of_calls_command_start++;\n      break;\n    case MYSQL_AUDIT_COMMAND_END:\n      number_of_calls_command_end++;\n      break;\n    default:\n      break;\n    }\n  }\n  else if (event_class == MYSQL_AUDIT_QUERY_CLASS)\n  {\n    const struct mysql_event_query *event_query=\n                                      (const struct mysql_event_query *)event;\n\n    buffer_data= sprintf(buffer, \"sql_command_id=\\\"%d\\\"\",\n                         (int) event_query->sql_command_id);\n\n    switch (event_query->event_subclass)\n    {\n    case MYSQL_AUDIT_QUERY_START:\n      number_of_calls_query_start++;\n      break;\n    case MYSQL_AUDIT_QUERY_NESTED_START:\n      number_of_calls_query_nested_start++;\n      break;\n    case MYSQL_AUDIT_QUERY_STATUS_END:\n      number_of_calls_query_status_end++;\n      break;\n    case MYSQL_AUDIT_QUERY_NESTED_STATUS_END:\n      number_of_calls_query_nested_status_end++;\n      break;\n    default:\n      break;\n    }\n  }\n  else if (event_class == MYSQL_AUDIT_TABLE_ACCESS_CLASS)\n  {\n    const struct mysql_event_table_access *event_table=\n                               (const struct mysql_event_table_access *)event;\n\n    buffer_data= sprintf(buffer, \"db=\\\"%s\\\" table=\\\"%s\\\"\",\n                         event_table->table_database.str,\n                         event_table->table_name.str);\n\n    switch (event_table->event_subclass)\n    {\n    case MYSQL_AUDIT_TABLE_ACCESS_INSERT:\n      number_of_calls_table_access_insert++;\n      break;\n    case MYSQL_AUDIT_TABLE_ACCESS_DELETE:\n      number_of_calls_table_access_delete++;\n      break;\n    case MYSQL_AUDIT_TABLE_ACCESS_UPDATE:\n      number_of_calls_table_access_update++;\n      break;\n    case MYSQL_AUDIT_TABLE_ACCESS_READ:\n      number_of_calls_table_access_read++;\n      break;\n    default:\n      break;\n    }\n  }\n  else if (event_class == MYSQL_AUDIT_GLOBAL_VARIABLE_CLASS)\n  {\n    const struct mysql_event_global_variable *event_gvar =\n                            (const struct mysql_event_global_variable *)event;\n\n    \/* Copy the variable content into the buffer. We do not guarantee that the\n       variable value will fit into buffer. The buffer should be large enough\n       to be used for the test purposes. *\/\n    buffer_data= sprintf(buffer, \"name=\\\"%.*s\\\"\",\n                         MY_MIN((int) event_gvar->variable_name.length,\n                                (int) (sizeof(buffer) - 8)),\n                          event_gvar->variable_name.str);\n\n    buffer_data+= sprintf(buffer + buffer_data, \" value=\\\"%.*s\\\"\",\n                         MY_MIN((int) event_gvar->variable_value.length,\n                                (int) (sizeof(buffer) - 16)),\n                          event_gvar->variable_value.str);\n    buffer[buffer_data]= '\\0';\n\n    switch (event_gvar->event_subclass)\n    {\n    case MYSQL_AUDIT_GLOBAL_VARIABLE_GET:\n      number_of_calls_global_variable_get++;\n      break;\n    case MYSQL_AUDIT_GLOBAL_VARIABLE_SET:\n      number_of_calls_global_variable_set++;\n      break;\n    default:\n      break;\n    }\n  }\n\n  process_event_record(thd, event_name, buffer, buffer_data);\n\n  if (my_charset_latin1.coll->strnncoll(&my_charset_latin1,\n                                        (const uchar *)event_name.str,\n                                        event_name.length,\n                                        (const uchar *)event_token.str,\n                                        event_token.length, 0))\n  {\n    \/* Clear event command. *\/\n    event_command.str= NULL;\n    event_command.length= 0;\n\n    if (exact_check == 1 && event_order_started == 1)\n    {\n      if (!(event_class == MYSQL_AUDIT_GENERAL_CLASS &&\n            event_subclass == MYSQL_AUDIT_GENERAL_ERROR))\n      {\n        strxnmov(buffer, sizeof(buffer), event_name.str, \" instead of \",\n                 event_token.str, NullS);\n        my_message(ER_AUDIT_API_ABORT, buffer, MYF(0));\n      }\n\n      THDVAR(thd, event_order_started)= 0;\n      THDVAR(thd, event_order_check)= 0;\n\n      return 1;\n    }\n  }\n  else\n  {\n    LEX_CSTRING ignore= { C_STRING_WITH_LEN(\"\") };\n\n    \/* When we are not in the event order check, check if the specified\n       data corresponds to the actual event data. *\/\n    if (my_charset_latin1.coll->strnncoll(&my_charset_latin1,\n                                          (const uchar *)event_data.str,\n                                          event_data.length,\n                                          (const uchar *) ignore.str,\n                                          ignore.length, 0) &&\n        my_charset_latin1.coll->strnncoll(&my_charset_latin1,\n                                          (const uchar *) event_data.str,\n                                          event_data.length,\n                                          (const uchar *)buffer,\n                                          (size_t)buffer_data, 0))\n    {\n      if (exact_check == 1 && event_order_started == 1)\n      {\n        char invalid_data_buffer[sizeof(buffer)]= { 0, };\n        LEX_CSTRING status= { C_STRING_WITH_LEN(\"EVENT-ORDER-INVALID-DATA\") };\n        LEX_CSTRING order_cstr;\n\n        lex_cstring_set(&order_cstr,\n                        (const char *)THDVAR(thd, event_order_check));\n\n        memmove((char *)order_cstr.str,\n                (void *)status.str, status.length + 1);\n\n        strxnmov(invalid_data_buffer, sizeof(invalid_data_buffer),\n                 \"Invalid data for '\", event_name.str, \"' -> \", buffer, NullS);\n        my_message(ER_AUDIT_API_ABORT, invalid_data_buffer, MYF(0));\n\n        THDVAR(thd, event_order_started)= 0;\n        THDVAR(thd, event_order_check)= (char *)order_cstr.str;\n\n        return 1;\n      }\n\n      \/* Clear event command. *\/\n      event_command.str= NULL;\n      event_command.length= 0;\n    }\n    else\n    {\n      LEX_CSTRING order_cstr;\n      ulong consume= THDVAR(thd, event_order_check_consume_ignore_count);\n      lex_cstring_set(&order_cstr,\n                      (const char *)THDVAR(thd, event_order_check));\n\n      THDVAR(thd, event_order_started)= 1;\n\n      if (consume)\n      {\n        \/*\n          Do not consume event this time. Just decrease value and wait until\n          the next event is matched.\n        *\/\n        THDVAR(thd, event_order_check_consume_ignore_count)= consume - 1;\n        consume_event= FALSE;\n      }\n      else\n      {\n        \/* Consume matched event. *\/\n        memmove((char*)order_cstr.str, (void*)order_str,\n          order_cstr.length - (order_str - order_cstr.str) + 1);\n\n        \/* Count new length. *\/\n        lex_cstring_set(&order_cstr, order_cstr.str);\n\n        if (order_cstr.length == 0)\n        {\n          LEX_CSTRING status = { C_STRING_WITH_LEN(\"EVENT-ORDER-OK\") };\n\n          memmove((char *)order_cstr.str,\n                  (void *)status.str, status.length + 1);\n\n          \/* event_order_started contains message. Do not verify it. *\/\n          THDVAR(thd, event_order_started)= 0;\n        }\n      }\n    }\n  }\n\n  return process_command(thd, event_command, consume_event);\n}","target":0,"code_token_length":2584,"total_token_length":2820,"max_tokens_setting":4096}
+{"idx":244866,"func":" int ff_h263_decode_picture_header(MpegEncContext *s)\n {\n    int format, width, height, i, ret;\n     uint32_t startcode;\n \n     align_get_bits(&s->gb);\n    startcode= get_bits(&s->gb, 22-8);\n\n    for(i= get_bits_left(&s->gb); i>24; i-=8) {\n        startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;\n\n        if(startcode == 0x20)\n            break;\n    }\n\n    if (startcode != 0x20) {\n        av_log(s->avctx, AV_LOG_ERROR, \"Bad picture start code\\n\");\n        return -1;\n    }\n    \/* temporal reference *\/\n    i = get_bits(&s->gb, 8); \/* picture timestamp *\/\n    if( (s->picture_number&~0xFF)+i < s->picture_number)\n        i+= 256;\n    s->picture_number= (s->picture_number&~0xFF) + i;\n\n    \/* PTYPE starts here *\/\n    if (get_bits1(&s->gb) != 1) {\n        \/* marker *\/\n        av_log(s->avctx, AV_LOG_ERROR, \"Bad marker\\n\");\n        return -1;\n    }\n    if (get_bits1(&s->gb) != 0) {\n        av_log(s->avctx, AV_LOG_ERROR, \"Bad H263 id\\n\");\n        return -1;      \/* h263 id *\/\n    }\n    skip_bits1(&s->gb);         \/* split screen off *\/\n    skip_bits1(&s->gb);         \/* camera  off *\/\n    skip_bits1(&s->gb);         \/* freeze picture release off *\/\n\n    format = get_bits(&s->gb, 3);\n    \/*\n        0    forbidden\n        1    sub-QCIF\n        10   QCIF\n        7       extended PTYPE (PLUSPTYPE)\n    *\/\n\n    if (format != 7 && format != 6) {\n        s->h263_plus = 0;\n        \/* H.263v1 *\/\n         \/* H.263v1 *\/\n         width = ff_h263_format[format][0];\n         height = ff_h263_format[format][1];\n \n         s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);\n \n\n        s->h263_long_vectors = get_bits1(&s->gb);\n\n        if (get_bits1(&s->gb) != 0) {\n            av_log(s->avctx, AV_LOG_ERROR, \"H263 SAC not supported\\n\");\n            return -1; \/* SAC: off *\/\n        }\n        s->obmc= get_bits1(&s->gb); \/* Advanced prediction mode *\/\n        s->unrestricted_mv = s->h263_long_vectors || s->obmc;\n\n        s->pb_frame = get_bits1(&s->gb);\n        s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);\n        skip_bits1(&s->gb); \/* Continuous Presence Multipoint mode: off *\/\n\n        s->width = width;\n        s->height = height;\n        s->avctx->sample_aspect_ratio= (AVRational){12,11};\n        s->avctx->framerate = (AVRational){ 30000, 1001 };\n    } else {\n        int ufep;\n\n        \/* H.263v2 *\/\n        s->h263_plus = 1;\n        ufep = get_bits(&s->gb, 3); \/* Update Full Extended PTYPE *\/\n\n        \/* ufep other than 0 and 1 are reserved *\/\n        if (ufep == 1) {\n            \/* OPPTYPE *\/\n            format = get_bits(&s->gb, 3);\n            ff_dlog(s->avctx, \"ufep=1, format: %d\\n\", format);\n            s->custom_pcf= get_bits1(&s->gb);\n            s->umvplus = get_bits1(&s->gb); \/* Unrestricted Motion Vector *\/\n            if (get_bits1(&s->gb) != 0) {\n                av_log(s->avctx, AV_LOG_ERROR, \"Syntax-based Arithmetic Coding (SAC) not supported\\n\");\n            }\n            s->obmc= get_bits1(&s->gb); \/* Advanced prediction mode *\/\n            s->h263_aic = get_bits1(&s->gb); \/* Advanced Intra Coding (AIC) *\/\n            s->loop_filter= get_bits1(&s->gb);\n            s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;\n\n            s->h263_slice_structured= get_bits1(&s->gb);\n            if (get_bits1(&s->gb) != 0) {\n                av_log(s->avctx, AV_LOG_ERROR, \"Reference Picture Selection not supported\\n\");\n            }\n            if (get_bits1(&s->gb) != 0) {\n                av_log(s->avctx, AV_LOG_ERROR, \"Independent Segment Decoding not supported\\n\");\n            }\n            s->alt_inter_vlc= get_bits1(&s->gb);\n            s->modified_quant= get_bits1(&s->gb);\n            if(s->modified_quant)\n                s->chroma_qscale_table= ff_h263_chroma_qscale_table;\n\n            skip_bits(&s->gb, 1); \/* Prevent start code emulation *\/\n\n            skip_bits(&s->gb, 3); \/* Reserved *\/\n        } else if (ufep != 0) {\n            av_log(s->avctx, AV_LOG_ERROR, \"Bad UFEP type (%d)\\n\", ufep);\n            return -1;\n        }\n\n        \/* MPPTYPE *\/\n        s->pict_type = get_bits(&s->gb, 3);\n        switch(s->pict_type){\n        case 0: s->pict_type= AV_PICTURE_TYPE_I;break;\n        case 1: s->pict_type= AV_PICTURE_TYPE_P;break;\n        case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break;\n        case 3: s->pict_type= AV_PICTURE_TYPE_B;break;\n        case 7: s->pict_type= AV_PICTURE_TYPE_I;break; \/\/ZYGO\n        default:\n            return -1;\n        }\n        skip_bits(&s->gb, 2);\n        s->no_rounding = get_bits1(&s->gb);\n        skip_bits(&s->gb, 4);\n\n        \/* Get the picture dimensions *\/\n        if (ufep) {\n            if (format == 6) {\n                \/* Custom Picture Format (CPFMT) *\/\n                s->aspect_ratio_info = get_bits(&s->gb, 4);\n                ff_dlog(s->avctx, \"aspect: %d\\n\", s->aspect_ratio_info);\n                \/* aspect ratios:\n                0 - forbidden\n                1 - 1:1\n                2 - 12:11 (CIF 4:3)\n                3 - 10:11 (525-type 4:3)\n                4 - 16:11 (CIF 16:9)\n                5 - 40:33 (525-type 16:9)\n                6-14 - reserved\n                *\/\n                width = (get_bits(&s->gb, 9) + 1) * 4;\n                skip_bits1(&s->gb);\n                height = get_bits(&s->gb, 9) * 4;\n                ff_dlog(s->avctx, \"\\nH.263+ Custom picture: %dx%d\\n\",width,height);\n                if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {\n                    \/* aspected dimensions *\/\n                    s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);\n                    s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);\n                }else{\n                    s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info];\n                }\n            } else {\n                width = ff_h263_format[format][0];\n                height = ff_h263_format[format][1];\n                s->avctx->sample_aspect_ratio= (AVRational){12,11};\n            }\n            if ((width == 0) || (height == 0))\n                return -1;\n            s->width = width;\n            s->height = height;\n\n            if(s->custom_pcf){\n                int gcd;\n                s->avctx->framerate.num  = 1800000;\n                s->avctx->framerate.den  = 1000 + get_bits1(&s->gb);\n                s->avctx->framerate.den *= get_bits(&s->gb, 7);\n                if(s->avctx->framerate.den == 0){\n                    av_log(s, AV_LOG_ERROR, \"zero framerate\\n\");\n                    return -1;\n                }\n                gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num);\n                s->avctx->framerate.den \/= gcd;\n                s->avctx->framerate.num \/= gcd;\n            }else{\n                s->avctx->framerate = (AVRational){ 30000, 1001 };\n            }\n        }\n\n        if(s->custom_pcf){\n            skip_bits(&s->gb, 2); \/\/extended Temporal reference\n        }\n\n        if (ufep) {\n            if (s->umvplus) {\n                if(get_bits1(&s->gb)==0) \/* Unlimited Unrestricted Motion Vectors Indicator (UUI) *\/\n                    skip_bits1(&s->gb);\n            }\n            if(s->h263_slice_structured){\n                if (get_bits1(&s->gb) != 0) {\n                    av_log(s->avctx, AV_LOG_ERROR, \"rectangular slices not supported\\n\");\n                }\n                if (get_bits1(&s->gb) != 0) {\n                    av_log(s->avctx, AV_LOG_ERROR, \"unordered slices not supported\\n\");\n                }\n            }\n        }\n         s->qscale = get_bits(&s->gb, 5);\n     }\n \n    if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0)\n        return ret;\n\n     s->mb_width = (s->width  + 15) \/ 16;\n     s->mb_height = (s->height  + 15) \/ 16;\n     s->mb_num = s->mb_width * s->mb_height;\n        skip_bits(&s->gb, 3); \/* Temporal reference for B-pictures *\/\n        if (s->custom_pcf)\n            skip_bits(&s->gb, 2); \/\/extended Temporal reference\n        skip_bits(&s->gb, 2); \/* Quantization information for B-pictures *\/\n    }\n","target":0,"code_token_length":2426,"total_token_length":2662,"max_tokens_setting":4096}
+{"idx":263948,"func":"static int parseOperand(RAsm *a, const char *str, Operand *op, bool isrepop) {\n\tsize_t pos, nextpos = 0;\n\tx86newTokenType last_type;\n\tint size_token = 1;\n\tbool explicit_size = false;\n\tint reg_index = 0;\n\t\/\/ Reset type\n\top->type = 0;\n\t\/\/ Consume tokens denoting the operand size\n\twhile (size_token) {\n\t\tpos = nextpos;\n\t\tlast_type = getToken (str, &pos, &nextpos);\n\n\t\t\/\/ Token may indicate size: then skip\n\t\tif (!r_str_ncasecmp (str + pos, \"ptr\", 3)) {\n\t\t\tcontinue;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"byte\", 4)) {\n\t\t\top->type |= OT_MEMORY | OT_BYTE;\n\t\t\top->dest_size = OT_BYTE;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"word\", 4)) {\n\t\t\top->type |= OT_MEMORY | OT_WORD;\n\t\t\top->dest_size = OT_WORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"dword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_DWORD;\n\t\t\top->dest_size = OT_DWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"qword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_QWORD;\n\t\t\top->dest_size = OT_QWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"oword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_OWORD;\n\t\t\top->dest_size = OT_OWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"tbyte\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_TBYTE;\n\t\t\top->dest_size = OT_TBYTE;\n\t\t\texplicit_size = true;\n\t\t} else { \/\/ the current token doesn't denote a size\n\t\t\tsize_token = 0;\n\t\t}\n\t}\n\n\t\/\/ Next token: register, immediate, or '['\n\tif (str[pos] == '[') {\n\t\t\/\/ Don't care about size, if none is given.\n\t\tif (!op->type) {\n\t\t\top->type = OT_MEMORY;\n\t\t}\n\t\t\/\/ At the moment, we only accept plain linear combinations:\n\t\t\/\/ part := address | [factor *] register\n\t\t\/\/ address := part {+ part}*\n\t\top->offset = op->scale[0] = op->scale[1] = 0;\n\n\t\tut64 temp = 1;\n\t\tRegister reg = X86R_UNDEFINED;\n\t\tbool first_reg = true;\n\t\twhile (str[pos] != ']') {\n\t\t\tif (pos > nextpos) {\n\t\t\t\/\/\teprintf (\"Error parsing instruction\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpos = nextpos;\n\t\t\tif (!str[pos]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast_type = getToken (str, &pos, &nextpos);\n\n\t\t\tif (last_type == TT_SPECIAL) {\n\t\t\t\tif (str[pos] == '+' || str[pos] == '-' || str[pos] == ']') {\n\t\t\t\t\tif (reg != X86R_UNDEFINED) {\n\t\t\t\t\t\tif (reg_index < 2) {\n\t\t\t\t\t\t\top->regs[reg_index] = reg;\n\t\t\t\t\t\t\top->scale[reg_index] = temp;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t++reg_index;\n\t\t\t\t\t} else {\n\t\t\t\t\t\top->offset += temp;\n\t\t\t\t\t\tif (reg_index < 2) {\n\t\t\t\t\t\t\top->regs[reg_index] = X86R_UNDEFINED;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttemp = 1;\n\t\t\t\t\treg = X86R_UNDEFINED;\n\t\t\t\t} else if (str[pos] == '*') {\n\t\t\t\t\t\/\/ go to ], + or - to get scale\n\n\t\t\t\t\t\/\/ Something to do here?\n\t\t\t\t\t\/\/ Seems we are just ignoring '*' or assuming it implicitly.\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (last_type == TT_WORD) {\n\t\t\t\tut32 reg_type = 0;\n\n\t\t\t\t\/\/ We can't multiply registers\n\t\t\t\tif (reg != X86R_UNDEFINED) {\n\t\t\t\t\top->type = 0;\t\/\/ Make the result invalid\n\t\t\t\t}\n\n\t\t\t\t\/\/ Reset nextpos: parseReg wants to parse from the beginning\n\t\t\t\tnextpos = pos;\n\t\t\t\treg = parseReg (a, str, &nextpos, ®_type);\n\n\t\t\t\tif (first_reg) {\n\t\t\t\t\top->extended = false;\n\t\t\t\t\tif (reg > 8) {\n\t\t\t\t\t\top->extended = true;\n\t\t\t\t\t\top->reg = reg - 9;\n\t\t\t\t\t}\n\t\t\t\t\tfirst_reg = false;\n\t\t\t\t} else if (reg > 8) {\n\t\t\t\t\top->reg = reg - 9;\n\t\t\t\t}\n\t\t\t\tif (reg_type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\t\t\top->reg = reg;\n\t\t\t\t\top->type = reg_type;\n\t\t\t\t\tparse_segment_offset (a, str, &nextpos, op, reg_index);\n\t\t\t\t\treturn nextpos;\n\t\t\t\t}\n\n\t\t\t\t\/\/ Still going to need to know the size if not specified\n\t\t\t\tif (!explicit_size) {\n\t\t\t\t\top->type |= reg_type;\n\t\t\t\t}\n\t\t\t\top->reg_size = reg_type;\n\t\t\t\top->explicit_size = explicit_size;\n\n\t\t\t\t\/\/ Addressing only via general purpose registers\n\t\t\t\tif (!(reg_type & OT_GPREG)) {\n\t\t\t\t\top->type = 0;\t\/\/ Make the result invalid\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tchar *p = strchr (str, '+');\n\t\t\t\top->offset_sign = 1;\n\t\t\t\tif (!p) {\n\t\t\t\t\tp = strchr (str, '-');\n\t\t\t\t\tif (p) {\n\t\t\t\t\t\top->offset_sign = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\/\/with SIB notation, we need to consider the right sign\n\t\t\t\tchar * plus = strchr (str, '+');\n\t\t\t\tchar * minus = strchr (str, '-');\n\t\t\t\tchar * closeB = strchr (str, ']');\n\t\t\t\tif (plus && minus && plus < closeB && minus < closeB) {\n\t\t\t\t\top->offset_sign = -1;\n\t\t\t\t}\n\t\t\t\t\/\/ If there's a scale, we don't want to parse out the\n\t\t\t\t\/\/ scale with the offset (scale + offset) otherwise the scale\n\t\t\t\t\/\/ will be the sum of the two. This splits the numbers\n\t\t\t\tchar *tmp;\n\t\t\t\ttmp = malloc (strlen (str + pos) + 1);\n\t\t\t\tstrcpy (tmp, str + pos);\n\t\t\t\tstrtok (tmp, \"+-\");\n\t\t\t\tst64 read = getnum (a, tmp);\n\t\t\t\tfree (tmp);\n\t\t\t\ttemp *= read;\n\t\t\t}\n\t\t}\n\t} else if (last_type == TT_WORD) {   \/\/ register\n\t\tnextpos = pos;\n\t\tRFlagItem *flag;\n\n\t\tif (isrepop) {\n\t\t\top->is_good_flag = false;\n\t\t\tstrncpy (op->rep_op, str, MAX_REPOP_LENGTH - 1);\n\t\t\top->rep_op[MAX_REPOP_LENGTH - 1] = '\\0';\n\t\t\treturn nextpos;\n\t\t}\n\n\t\top->reg = parseReg (a, str, &nextpos, &op->type);\n\n\t\top->extended = false;\n\t\tif (op->reg > 8) {\n\t\t\top->extended = true;\n\t\t\top->reg -= 9;\n\t\t}\n\t\tif (op->type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tparse_segment_offset (a, str, &nextpos, op, reg_index);\n\t\t\treturn nextpos;\n\t\t}\n\t\tif (op->reg == X86R_UNDEFINED) {\n\t\t\top->is_good_flag = false;\n\t\t\tif (a->num && a->num->value == 0) {\n\t\t\t\treturn nextpos;\n\t\t\t}\n\t\t\top->type = OT_CONSTANT;\n\t\t\tRCore *core = a->num? (RCore *)(a->num->userptr): NULL;\n\t\t\tif (core && (flag = r_flag_get (core->flags, str))) {\n\t\t\t\top->is_good_flag = true;\n\t\t\t}\n\n\t\t\tchar *p = strchr (str, '-');\n\t\t\tif (p) {\n\t\t\t\top->sign = -1;\n\t\t\t\tstr = ++p;\n\t\t\t}\n\t\t\top->immediate = getnum (a, str);\n\t\t} else if (op->reg < X86R_UNDEFINED) {\n\t\t\tstrncpy (op->rep_op, str, MAX_REPOP_LENGTH - 1);\n\t\t\top->rep_op[MAX_REPOP_LENGTH - 1] = '\\0';\n\t\t}\n\t} else {                             \/\/ immediate\n\t\t\/\/ We don't know the size, so let's just set no size flag.\n\t\top->type = OT_CONSTANT;\n\t\top->sign = 1;\n\t\tchar *p = strchr (str, '-');\n\t\tif (p) {\n\t\t\top->sign = -1;\n\t\t\tstr = ++p;\n\t\t}\n\t\top->immediate = getnum (a, str);\n\t}\n\n\treturn nextpos;\n}","target":0,"code_token_length":1966,"total_token_length":2202,"max_tokens_setting":4096}
+{"idx":418709,"func":"main(\n    int\t\targc,\n    char **\targv)\n{\n    int c;\n    char *command;\n    application_argument_t argument;\n    int i;\n\n#ifdef BSDTAR\n    bsdtar_path = g_strdup(BSDTAR);\n#else\n    bsdtar_path = NULL;\n#endif\n    state_dir = NULL;\n    bsdtar_directory = NULL;\n    bsdtar_onefilesystem = 1;\n    exit_handling = NULL;\n\n    \/* initialize *\/\n\n    \/*\n     * Configure program for internationalization:\n     *   1) Only set the message locale for now.\n     *   2) Set textdomain for all amanda related programs to \"amanda\"\n     *      We don't want to be forced to support dozens of message catalogs.\n     *\/\n    setlocale(LC_MESSAGES, \"C\");\n    textdomain(\"amanda\");\n\n    if (argc < 2) {\n        printf(\"ERROR no command given to ambsdtar\\n\");\n        error(_(\"No command given to ambsdtar\"));\n    }\n\n    \/* drop root privileges *\/\n    if (!set_root_privs(0)) {\n\tif (g_str_equal(argv[1], \"selfcheck\")) {\n\t    printf(\"ERROR ambsdtar must be run setuid root\\n\");\n\t}\n\terror(_(\"ambsdtar must be run setuid root\"));\n    }\n\n    safe_fd(3, 2);\n\n    set_pname(\"ambsdtar\");\n\n    \/* Don't die when child closes pipe *\/\n    signal(SIGPIPE, SIG_IGN);\n\n#if defined(USE_DBMALLOC)\n    malloc_size_1 = malloc_inuse(&malloc_hist_1);\n#endif\n\n    add_amanda_log_handler(amanda_log_stderr);\n    add_amanda_log_handler(amanda_log_syslog);\n    dbopen(DBG_SUBDIR_CLIENT);\n    startclock();\n    g_debug(_(\"version %s\"), VERSION);\n\n    config_init(CONFIG_INIT_CLIENT, NULL);\n\n    \/\/check_running_as(RUNNING_AS_DUMPUSER_PREFERRED);\n    \/\/root for amrecover\n    \/\/RUNNING_AS_CLIENT_LOGIN from selfcheck, sendsize, sendbackup\n\n    \/* parse argument *\/\n    command = argv[1];\n\n    argument.config     = NULL;\n    argument.host       = NULL;\n    argument.message    = 0;\n    argument.collection = 0;\n    argument.calcsize = 0;\n    argument.tar_blocksize = NULL;\n    argument.level      = NULL;\n    argument.command_options = NULL;\n    argument.verbose = 0;\n    init_dle(&argument.dle);\n    argument.dle.record = 0;\n\n    while (1) {\n\tint option_index = 0;\n\tc = getopt_long (argc, argv, \"\", long_options, &option_index);\n\tif (c == -1) {\n\t    break;\n\t}\n\tswitch (c) {\n\tcase 1: amfree(argument.config);\n\t\targument.config = g_strdup(optarg);\n\t\tbreak;\n\tcase 2: amfree(argument.host);\n\t\targument.host = g_strdup(optarg);\n\t\tbreak;\n\tcase 3: amfree(argument.dle.disk);\n\t\targument.dle.disk = g_strdup(optarg);\n\t\tbreak;\n\tcase 4: amfree(argument.dle.device);\n\t\targument.dle.device = g_strdup(optarg);\n\t\tbreak;\n\tcase 5: argument.level = g_slist_append(argument.level,\n\t\t\t\t\t        GINT_TO_POINTER(atoi(optarg)));\n\t\tbreak;\n\tcase 6: argument.dle.create_index = 1;\n\t\tbreak;\n\tcase 7: argument.message = 1;\n\t\tbreak;\n\tcase 8: argument.collection = 1;\n\t\tbreak;\n\tcase 9: argument.dle.record = 1;\n\t\tbreak;\n\tcase 10: amfree(bsdtar_path);\n\t\t bsdtar_path = g_strdup(optarg);\n\t\t break;\n\tcase 11: amfree(state_dir);\n\t\t state_dir = g_strdup(optarg);\n\t\t break;\n\tcase 12: if (strcasecmp(optarg, \"NO\") == 0)\n\t\t     bsdtar_onefilesystem = 0;\n\t\t else if (strcasecmp(optarg, \"YES\") == 0)\n\t\t     bsdtar_onefilesystem = 1;\n\t\t else if (strcasecmp(command, \"selfcheck\") == 0)\n\t\t     printf(_(\"ERROR [%s: bad ONE-FILE-SYSTEM property value (%s)]\\n\"), get_pname(), optarg);\n\t\t break;\n\tcase 16: argument.dle.include_file =\n\t\t\t append_sl(argument.dle.include_file, optarg);\n\t\t break;\n\tcase 17: argument.dle.include_list =\n\t\t\t append_sl(argument.dle.include_list, optarg);\n\t\t break;\n\tcase 18: argument.dle.include_optional = 1;\n\t\t break;\n\tcase 19: argument.dle.exclude_file =\n\t\t\t append_sl(argument.dle.exclude_file, optarg);\n\t\t break;\n\tcase 20: argument.dle.exclude_list =\n\t\t\t append_sl(argument.dle.exclude_list, optarg);\n\t\t break;\n\tcase 21: argument.dle.exclude_optional = 1;\n\t\t break;\n\tcase 22: amfree(bsdtar_directory);\n\t\t bsdtar_directory = g_strdup(optarg);\n\t\t break;\n\tcase 23: normal_message =\n\t\t\t g_slist_append(normal_message, optarg);\n\t\t break;\n\tcase 24: ignore_message =\n\t\t\t g_slist_append(ignore_message, optarg);\n\t\t break;\n\tcase 25: strange_message =\n\t\t\t g_slist_append(strange_message, optarg);\n\t\t break;\n\tcase 26: amfree(exit_handling);\n\t\t exit_handling = g_strdup(optarg);\n\t\t break;\n\tcase 27: argument.calcsize = 1;\n\t\t break;\n\tcase 28: amfree(argument.tar_blocksize);\n\t\t argument.tar_blocksize = g_strdup(optarg);\n\t\t gblocksize = atoi(argument.tar_blocksize);\n\t\t break;\n\tcase 33: argument.command_options =\n\t\t\tg_slist_append(argument.command_options,\n\t\t\t\t       g_strdup(optarg));\n\t\t break;\n\tcase 36: if (strcasecmp(optarg, \"YES\") == 0)\n\t\t     argument.verbose = 1;\n\t\t break;\n\tcase ':':\n\tcase '?':\n\t\tbreak;\n\t}\n    }\n\n    if (!argument.dle.disk && argument.dle.device)\n\targument.dle.disk = g_strdup(argument.dle.device);\n    if (!argument.dle.device && argument.dle.disk)\n\targument.dle.device = g_strdup(argument.dle.disk);\n\n    argument.argc = argc - optind;\n    argument.argv = argv + optind;\n\n    if (argument.config) {\n\tconfig_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY,\n\t\t    argument.config);\n\tdbrename(get_config_name(), DBG_SUBDIR_CLIENT);\n    }\n\n    if (config_errors(NULL) >= CFGERR_ERRORS) {\n\tg_critical(_(\"errors processing config file\"));\n    }\n\n    if (state_dir && strlen(state_dir) == 0)\n\tamfree(state_dir);\n    if (!state_dir) {\n\tstate_dir = g_strdup_printf(\"%s\/%s\", amdatadir, \"bsdtar\");\n    }\n\n    re_table = build_re_table(init_re_table, normal_message, ignore_message,\n\t\t\t      strange_message);\n\n    for(i=0;i<256;i++)\n\texit_value[i] = 1; \/* BAD  *\/\n    exit_value[0] = 0;     \/* GOOD *\/\n    if (exit_handling) {\n\tchar *s = exit_handling;\n\twhile (s) {\n\t    char *r = strchr(s, '=');\n\t    if (r) {\n\t\tint j = atoi(s);\n\t\tif (j >= 0 && j < 256) {\n\t\t    r++;\n\t\t    if (strncasecmp(r, \"GOOD\", 4) == 0) {\n\t\t\texit_value[j] = 0;\n\t\t    }\n\t\t}\n\t    }\n\t    s = strchr(s+1, ' ');\n\t}\n    }\n\n    if (bsdtar_path) {\n\tg_debug(\"BSDTAR-PATH %s\", bsdtar_path);\n    } else {\n\tg_debug(\"BSDTAR-PATH is not set\");\n    }\n    if (state_dir) {\n\t    g_debug(\"STATE-DIR %s\", state_dir);\n    } else {\n\tg_debug(\"STATE-DIR is not set\");\n    }\n    if (bsdtar_directory) {\n\tg_debug(\"DIRECTORY %s\", bsdtar_directory);\n    }\n    g_debug(\"ONE-FILE-SYSTEM %s\", bsdtar_onefilesystem? \"yes\":\"no\");\n    {\n\tamregex_t *rp;\n\tfor (rp = re_table; rp->regex != NULL; rp++) {\n\t    switch (rp->typ) {\n\t\tcase DMP_NORMAL : g_debug(\"NORMAL %s\", rp->regex); break;\n\t\tcase DMP_IGNORE : g_debug(\"IGNORE %s\", rp->regex); break;\n\t\tcase DMP_STRANGE: g_debug(\"STRANGE %s\", rp->regex); break;\n\t\tcase DMP_SIZE   : g_debug(\"SIZE %s\", rp->regex); break;\n\t\tcase DMP_ERROR  : g_debug(\"ERROR %s\", rp->regex); break;\n\t    }\n\t}\n    }\n\n    if (g_str_equal(command, \"support\")) {\n\tambsdtar_support(&argument);\n    } else if (g_str_equal(command, \"selfcheck\")) {\n\tambsdtar_selfcheck(&argument);\n    } else if (g_str_equal(command, \"estimate\")) {\n\tambsdtar_estimate(&argument);\n    } else if (g_str_equal(command, \"backup\")) {\n\tambsdtar_backup(&argument);\n    } else if (g_str_equal(command, \"restore\")) {\n\tambsdtar_restore(&argument);\n    } else if (g_str_equal(command, \"validate\")) {\n\tambsdtar_validate(&argument);\n    } else if (g_str_equal(command, \"index\")) {\n\tambsdtar_index(&argument);\n    } else {\n\tg_debug(\"Unknown command `%s'.\", command);\n\tfprintf(stderr, \"Unknown command `%s'.\\n\", command);\n\texit (1);\n    }\n\n    g_free(argument.config);\n    g_free(argument.host);\n    g_free(argument.dle.disk);\n    g_free(argument.dle.device);\n    g_free(argument.tar_blocksize);\n    g_slist_free(argument.level);\n\n    dbclose();\n\n    return exit_status;\n}","target":0,"code_token_length":2123,"total_token_length":2359,"max_tokens_setting":4096}
+{"idx":142098,"func":"void isor_reader_get_sample(ISOMChannel *ch)\n{\n\tGF_Err e;\n\tu32 sample_desc_index;\n\tif (ch->sample) return;\n\n\tif (ch->next_track) {\n\t\tch->track = ch->next_track;\n\t\tch->next_track = 0;\n\t}\n\n\tif (ch->to_init) {\n\t\tinit_reader(ch);\n\t\tsample_desc_index = ch->last_sample_desc_index;\n\t} else if (ch->speed < 0) {\n\t\tif (ch->last_state == GF_EOS) {\n\t\t\tch->sample = NULL;\n\t\t\treturn;\n\t\t}\n\n\t\tif (ch->static_sample->IsRAP) {\n\t\t\tch->last_rap_sample_time = ch->sample_time;\n\t\t}\n\n\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &sample_desc_index, GF_ISOM_SEARCH_FORWARD, &ch->static_sample, &ch->sample_num, NULL);\n\n\t\tif ((e==GF_EOS) || (ch->static_sample->IsRAP)) {\n\t\t\tif (!ch->last_rap_sample_time) {\n\t\t\t\te = GF_EOS;\n\t\t\t} else {\n\t\t\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->last_rap_sample_time - 1, &sample_desc_index, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->static_sample, &ch->sample_num, NULL);\n\t\t\t}\n\t\t}\n\n\t\tif (e) {\n\t\t\tif ((e==GF_EOS) && !ch->owner->frag_type) {\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t}\n\t\t\tch->sample = NULL;\n\t\t\treturn;\n\t\t}\n\t\tch->sample = ch->static_sample;\n\n\t\tif (ch->sample->DTS == ch->sample_time) {\n\t\t\tif (!ch->owner->frag_type) {\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t}\n\t\t}\n\t\tif (ch->sample) {\n\t\t\tch->sample_time = ch->sample->DTS;\n\t\t}\n\n\t} else if (ch->has_edit_list) {\n\t\tu32 prev_sample = ch->sample_num;\n\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &sample_desc_index, GF_ISOM_SEARCH_FORWARD, &ch->static_sample, &ch->sample_num, &ch->sample_data_offset);\n\n\t\tif (e == GF_OK) {\n\t\t\tch->sample = ch->static_sample;\n\n\t\t\t\/*we are in forced seek mode: fetch all samples before the one matching the sample time*\/\n\t\t\tif (ch->edit_sync_frame) {\n\t\t\t\tch->edit_sync_frame++;\n\t\t\t\tif (ch->edit_sync_frame < ch->sample_num) {\n\t\t\t\t\tch->sample = gf_isom_get_sample_ex(ch->owner->mov, ch->track, ch->edit_sync_frame, &sample_desc_index, ch->static_sample, &ch->sample_data_offset);\n\t\t\t\t\tch->sample->DTS = ch->sample_time;\n\t\t\t\t\tch->sample->CTS_Offset = 0;\n\t\t\t\t} else {\n\t\t\t\t\tch->edit_sync_frame = 0;\n\t\t\t\t\tif (ch->sample) ch->sample_time = ch->sample->DTS;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t\/*if we get the same sample, figure out next interesting time (current sample + DTS gap to next sample should be a good bet)*\/\n\t\t\t\tif (prev_sample == ch->sample_num) {\n\t\t\t\t\tif (ch->owner->frag_type && (ch->sample_num==gf_isom_get_sample_count(ch->owner->mov, ch->track))) {\n\t\t\t\t\t\tch->sample = NULL;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu32 sample_num = ch->sample_num ? ch->sample_num : 1;\n\n\t\t\t\t\t\tif (sample_num >= gf_isom_get_sample_count(ch->owner->mov, ch->track) ) {\n\t\t\t\t\t\t\t\/\/e = GF_EOS;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tu32 time_diff = gf_isom_get_sample_duration(ch->owner->mov, ch->track, sample_num);\n\t\t\t\t\t\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + time_diff, &sample_desc_index, GF_ISOM_SEARCH_FORWARD, &ch->static_sample, &ch->sample_num, &ch->sample_data_offset);\n\t\t\t\t\t\t\tif (e==GF_OK) {\n\t\t\t\t\t\t\t\tif (ch->sample_num == prev_sample) {\n\t\t\t\t\t\t\t\t\tch->sample_time += time_diff;\n\t\t\t\t\t\t\t\t\tch->sample = NULL;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tch->sample = ch->static_sample;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/*we jumped to another segment - if RAP is needed look for closest rap in decoding order and\n\t\t\t\tforce seek mode*\/\n\t\t\t\tif (ch->sample && !ch->sample->IsRAP && ch->has_rap && (ch->sample_num != prev_sample+1)) {\n\t\t\t\t\tGF_ISOSample *found = ch->static_sample;\n\t\t\t\t\tu32 samp_num = ch->sample_num;\n\t\t\t\t\tch->sample = NULL;\n\t\t\t\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &sample_desc_index, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->static_sample, &ch->sample_num, &ch->sample_data_offset);\n\n\t\t\t\t\tif (e == GF_OK) ch->sample = ch->static_sample;\n\n\t\t\t\t\t\/*if no sync point in the past, use the first non-sync for the given time*\/\n\t\t\t\t\tif (!ch->sample || !ch->sample->data) {\n\t\t\t\t\t\tch->sample = ch->static_sample = found;\n\t\t\t\t\t\tch->sample_time = ch->sample->DTS;\n\t\t\t\t\t\tch->sample_num = samp_num;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tch->sample = ch->static_sample;\n\t\t\t\t\t\tch->edit_sync_frame = ch->sample_num;\n\t\t\t\t\t\tch->sample->DTS = ch->sample_time;\n\t\t\t\t\t\tch->sample->CTS_Offset = 0;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (ch->sample) ch->sample_time = ch->sample->DTS;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tBool do_fetch = GF_TRUE;\n\t\tch->sample_num++;\n\n\t\tif (ch->sap_only) {\n\t\t\tBool is_rap = gf_isom_get_sample_sync(ch->owner->mov, ch->track, ch->sample_num);\n\t\t\tif (!is_rap) {\n\t\t\t\tGF_ISOSampleRollType roll_type;\n\t\t\t\tgf_isom_get_sample_rap_roll_info(ch->owner->mov, ch->track, ch->sample_num, &is_rap, &roll_type, NULL);\n\t\t\t\tif (roll_type) is_rap = GF_TRUE;\n\t\t\t}\n\n\t\t\tif (!is_rap) {\n\t\t\t\tdo_fetch = GF_FALSE;\n\t\t\t} else if (ch->sap_only==2) {\n\t\t\t\tch->sap_only = 0;\n\t\t\t}\n\t\t}\n\t\tif (do_fetch) {\n\t\t\tif (ch->owner->nodata) {\n\t\t\t\tch->sample = gf_isom_get_sample_info_ex(ch->owner->mov, ch->track, ch->sample_num, &sample_desc_index, &ch->sample_data_offset, ch->static_sample);\n\t\t\t} else {\n\t\t\t\tch->sample = gf_isom_get_sample_ex(ch->owner->mov, ch->track, ch->sample_num, &sample_desc_index, ch->static_sample, &ch->sample_data_offset);\n\t\t\t}\n\t\t\t\/*if sync shadow \/ carousel RAP skip*\/\n\t\t\tif (ch->sample && (ch->sample->IsRAP==RAP_REDUNDANT)) {\n\t\t\t\tch->sample = NULL;\n\t\t\t\tch->sample_num++;\n\t\t\t\tisor_reader_get_sample(ch);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/\/check scalable track change\n\tif (ch->sample && ch->sample->IsRAP && ch->next_track) {\n\t\tch->track = ch->next_track;\n\t\tch->next_track = 0;\n\t\tch->sample = NULL;\n\t\tisor_reader_get_sample(ch);\n\t\treturn;\n\t}\n\n\tif (!ch->sample) {\n\t\tu32 sample_count = gf_isom_get_sample_count(ch->owner->mov, ch->track);\n\t\tch->sample_data_offset = 0;\n\t\t\/*incomplete file - check if we're still downloading or not*\/\n\t\tif (gf_isom_get_missing_bytes(ch->owner->mov, ch->track)) {\n\t\t\tch->last_state = GF_ISOM_INCOMPLETE_FILE;\n\t\t\tif (ch->owner->mem_load_mode==2)\n\t\t\t\tch->owner->force_fetch = GF_TRUE;\n\n\t\t\tif (!ch->owner->input_loaded) {\n\t\t\t\tch->last_state = GF_OK;\n\t\t\t\tif (!ch->has_edit_list && ch->sample_num)\n\t\t\t\t\tch->sample_num--;\n\t\t\t} else {\n\t\t\t\tif (ch->to_init && ch->sample_num) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[IsoMedia] Failed to fetch initial sample %d for track %d\\n\"));\n\t\t\t\t\tch->last_state = GF_ISOM_INVALID_FILE;\n\t\t\t\t}\n\t\t\t\tif (ch->sample_num >= gf_isom_get_sample_count(ch->owner->mov, ch->track)) {\n\t\t\t\t\tch->last_state = GF_EOS;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (!ch->sample_num\n\t\t         || ((ch->speed >= 0) && (ch->sample_num >= sample_count))\n\t\t         || ((ch->speed < 0) && (ch->sample_time == gf_isom_get_current_tfdt(ch->owner->mov, ch->track) ))\n\t\t        ) {\n\n\t\t\tif (ch->owner->frag_type==1) {\n\t\t\t\t\/*if sample cannot be found and file is fragmented, rewind sample*\/\n\t\t\t\tif (ch->sample_num) ch->sample_num--;\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t} else if (ch->last_state != GF_EOS) {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[IsoMedia] Track #%d end of stream reached\\n\", ch->track));\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t\tif (ch->sample_num>sample_count) ch->sample_num = sample_count;\n\t\t\t} else {\n\t\t\t\tif (ch->sample_num>sample_count) ch->sample_num = sample_count;\n\t\t\t}\n\t\t} else {\n\t\t\te = gf_isom_last_error(ch->owner->mov);\n\t\t\tGF_LOG((e==GF_ISOM_INCOMPLETE_FILE) ? GF_LOG_DEBUG : GF_LOG_WARNING, GF_LOG_DASH, (\"[IsoMedia] Track #%d fail to fetch sample %d \/ %d: %s\\n\", ch->track, ch->sample_num, gf_isom_get_sample_count(ch->owner->mov, ch->track), gf_error_to_string(e) ));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (sample_desc_index != ch->last_sample_desc_index) {\n\t\tif (!ch->owner->stsd) {\n\t\t\t\/\/we used sample entry 1 by default to setup, if no active prev sample (edit list might trigger this)\n\t\t\t\/\/and new sample desc is 1, do not reconfigure\n\t\t\tif (!ch->last_sample_desc_index && (sample_desc_index==1)) {\n\n\t\t\t} else {\n\t\t\t\tch->needs_pid_reconfig = GF_TRUE;\n\t\t\t}\n\t\t}\n\t\tch->last_sample_desc_index = sample_desc_index;\n\t}\n\n\tch->last_state = GF_OK;\n\tch->au_duration = gf_isom_get_sample_duration(ch->owner->mov, ch->track, ch->sample_num);\n\n\tch->sap_3 = GF_FALSE;\n\tch->sap_4_type = 0;\n\tch->roll = 0;\n\tch->set_disc = ch->owner->clock_discontinuity ? 2 : 0;\n\tch->owner->clock_discontinuity = 0;\n\n\tif (ch->sample) {\n\t\tgf_isom_get_sample_rap_roll_info(ch->owner->mov, ch->track, ch->sample_num, &ch->sap_3, &ch->sap_4_type, &ch->roll);\n\n\t\t\/*still seeking or not ?\n\t\t 1- when speed is negative, the RAP found is \"after\" the seek point in playback order since we used backward RAP search: nothing to do\n\t\t 2- otherwise set DTS+CTS to start value\n\t\t *\/\n\t\tif ((ch->speed < 0) || (ch->start <= ch->sample->DTS + ch->sample->CTS_Offset)) {\n\t\t\tch->dts = ch->sample->DTS;\n\t\t\tch->cts = ch->sample->DTS + ch->sample->CTS_Offset;\n\t\t\tch->seek_flag = 0;\n\t\t} else {\n\t\t\tch->cts = ch->start;\n\t\t\tch->seek_flag = 1;\n\t\t\tch->dts = ch->start;\n\t\t}\n\n\t\tif (ch->end && (ch->end < ch->sample->DTS + ch->sample->CTS_Offset + ch->au_duration)) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] End of Channel \"LLD\" (CTS \"LLD\")\\n\", ch->end, ch->sample->DTS + ch->sample->CTS_Offset));\n\t\t\tch->sample = NULL;\n\t\t\tch->last_state = GF_EOS;\n\t\t\tch->playing = 2;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (ch->owner->last_sender_ntp && ch->cts==ch->owner->cts_for_last_sender_ntp) {\n\t\tch->sender_ntp = ch->owner->last_sender_ntp;\n\t\tch->ntp_at_server_ntp = ch->owner->ntp_at_last_sender_ntp;\n\t} else if (ch->owner->last_sender_ntp && ch->dts==ch->owner->cts_for_last_sender_ntp) {\n\t\tch->sender_ntp = ch->owner->last_sender_ntp;\n\t\tch->ntp_at_server_ntp = ch->owner->ntp_at_last_sender_ntp;\n\t} else {\n\t\tch->sender_ntp = ch->ntp_at_server_ntp = 0;\n\t}\n\n\tif (!ch->sample_num) return;\n\n\tgf_isom_get_sample_flags(ch->owner->mov, ch->track, ch->sample_num, &ch->isLeading, &ch->dependsOn, &ch->dependedOn, &ch->redundant);\n\n\tif (ch->is_encrypted) {\n\t\t\/*in case of CENC: we write sample auxiliary information to slh->sai; its size is in saiz*\/\n\t\tif (gf_isom_is_cenc_media(ch->owner->mov, ch->track, ch->last_sample_desc_index)) {\n\t\t\tisor_update_cenc_info(ch, GF_FALSE);\n\n\t\t} else if (gf_isom_is_media_encrypted(ch->owner->mov, ch->track, ch->last_sample_desc_index)) {\n\t\t\tch->pck_encrypted = GF_TRUE;\n\t\t} else {\n\t\t\tch->pck_encrypted = GF_FALSE;\n\t\t}\n\t}\n\tif (ch->sample && ch->sample->nb_pack)\n\t\tch->sample_num += ch->sample->nb_pack-1;\n}","target":0,"code_token_length":3284,"total_token_length":3520,"max_tokens_setting":4096}
+{"idx":501788,"func":"transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_clause)\n{\n\tAttrNumber\tparent_attno;\n\tRelation\trelation;\n\tTupleDesc\ttupleDesc;\n\tTupleConstr *constr;\n\tAclResult\taclresult;\n\tchar\t   *comment;\n\tParseCallbackState pcbstate;\n\n\tsetup_parser_errposition_callback(&pcbstate, cxt->pstate,\n\t\t\t\t\t\t\t\t\t  table_like_clause->relation->location);\n\n\t\/* we could support LIKE in many cases, but worry about it another day *\/\n\tif (cxt->isforeign)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"LIKE is not supported for creating foreign tables\")));\n\n\t\/* Open the relation referenced by the LIKE clause *\/\n\trelation = relation_openrv(table_like_clause->relation, AccessShareLock);\n\n\tif (relation->rd_rel->relkind != RELKIND_RELATION &&\n\t\trelation->rd_rel->relkind != RELKIND_VIEW &&\n\t\trelation->rd_rel->relkind != RELKIND_MATVIEW &&\n\t\trelation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&\n\t\trelation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&\n\t\trelation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t errmsg(\"\\\"%s\\\" is not a table, view, materialized view, composite type, or foreign table\",\n\t\t\t\t\t\tRelationGetRelationName(relation))));\n\n\tcancel_parser_errposition_callback(&pcbstate);\n\n\t\/*\n\t * Check for privileges\n\t *\/\n\tif (relation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)\n\t{\n\t\taclresult = pg_type_aclcheck(relation->rd_rel->reltype, GetUserId(),\n\t\t\t\t\t\t\t\t\t ACL_USAGE);\n\t\tif (aclresult != ACLCHECK_OK)\n\t\t\taclcheck_error(aclresult, ACL_KIND_TYPE,\n\t\t\t\t\t\t   RelationGetRelationName(relation));\n\t}\n\telse\n\t{\n\t\taclresult = pg_class_aclcheck(RelationGetRelid(relation), GetUserId(),\n\t\t\t\t\t\t\t\t\t  ACL_SELECT);\n\t\tif (aclresult != ACLCHECK_OK)\n\t\t\taclcheck_error(aclresult, ACL_KIND_CLASS,\n\t\t\t\t\t\t   RelationGetRelationName(relation));\n\t}\n\n\ttupleDesc = RelationGetDescr(relation);\n\tconstr = tupleDesc->constr;\n\n\t\/*\n\t * Insert the copied attributes into the cxt for the new table definition.\n\t * We must do this now so that they appear in the table in the relative\n\t * position where the LIKE clause is, as required by SQL99.\n\t *\/\n\tfor (parent_attno = 1; parent_attno <= tupleDesc->natts;\n\t\t parent_attno++)\n\t{\n\t\tForm_pg_attribute attribute = tupleDesc->attrs[parent_attno - 1];\n\t\tchar\t   *attributeName = NameStr(attribute->attname);\n\t\tColumnDef  *def;\n\n\t\t\/*\n\t\t * Ignore dropped columns in the parent.\n\t\t *\/\n\t\tif (attribute->attisdropped)\n\t\t\tcontinue;\n\n\t\t\/*\n\t\t * Create a new column, which is marked as NOT inherited.\n\t\t *\n\t\t * For constraints, ONLY the NOT NULL constraint is inherited by the\n\t\t * new column definition per SQL99.\n\t\t *\/\n\t\tdef = makeNode(ColumnDef);\n\t\tdef->colname = pstrdup(attributeName);\n\t\tdef->typeName = makeTypeNameFromOid(attribute->atttypid,\n\t\t\t\t\t\t\t\t\t\t\tattribute->atttypmod);\n\t\tdef->inhcount = 0;\n\t\tdef->is_local = true;\n\t\tdef->is_not_null = attribute->attnotnull;\n\t\tdef->is_from_type = false;\n\t\tdef->storage = 0;\n\t\tdef->raw_default = NULL;\n\t\tdef->cooked_default = NULL;\n\t\tdef->collClause = NULL;\n\t\tdef->collOid = attribute->attcollation;\n\t\tdef->constraints = NIL;\n\t\tdef->location = -1;\n\n\t\t\/*\n\t\t * Add to column list\n\t\t *\/\n\t\tcxt->columns = lappend(cxt->columns, def);\n\n\t\t\/*\n\t\t * Copy default, if present and the default has been requested\n\t\t *\/\n\t\tif (attribute->atthasdef &&\n\t\t\t(table_like_clause->options & CREATE_TABLE_LIKE_DEFAULTS))\n\t\t{\n\t\t\tNode\t   *this_default = NULL;\n\t\t\tAttrDefault *attrdef;\n\t\t\tint\t\t\ti;\n\n\t\t\t\/* Find default in constraint structure *\/\n\t\t\tAssert(constr != NULL);\n\t\t\tattrdef = constr->defval;\n\t\t\tfor (i = 0; i < constr->num_defval; i++)\n\t\t\t{\n\t\t\t\tif (attrdef[i].adnum == parent_attno)\n\t\t\t\t{\n\t\t\t\t\tthis_default = stringToNode(attrdef[i].adbin);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tAssert(this_default != NULL);\n\n\t\t\t\/*\n\t\t\t * If default expr could contain any vars, we'd need to fix 'em,\n\t\t\t * but it can't; so default is ready to apply to child.\n\t\t\t *\/\n\n\t\t\tdef->cooked_default = this_default;\n\t\t}\n\n\t\t\/*\n\t\t * Copy identity if requested\n\t\t *\/\n\t\tif (attribute->attidentity &&\n\t\t\t(table_like_clause->options & CREATE_TABLE_LIKE_IDENTITY))\n\t\t{\n\t\t\tOid\t\t\tseq_relid;\n\t\t\tList\t   *seq_options;\n\n\t\t\t\/*\n\t\t\t * find sequence owned by old column; extract sequence parameters;\n\t\t\t * build new create sequence command\n\t\t\t *\/\n\t\t\tseq_relid = getOwnedSequence(RelationGetRelid(relation), attribute->attnum);\n\t\t\tseq_options = sequence_options(seq_relid);\n\t\t\tgenerateSerialExtraStmts(cxt, def,\n\t\t\t\t\t\t\t\t\t InvalidOid, seq_options, true,\n\t\t\t\t\t\t\t\t\t NULL, NULL);\n\t\t\tdef->identity = attribute->attidentity;\n\t\t}\n\n\t\t\/* Likewise, copy storage if requested *\/\n\t\tif (table_like_clause->options & CREATE_TABLE_LIKE_STORAGE)\n\t\t\tdef->storage = attribute->attstorage;\n\t\telse\n\t\t\tdef->storage = 0;\n\n\t\t\/* Likewise, copy comment if requested *\/\n\t\tif ((table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS) &&\n\t\t\t(comment = GetComment(attribute->attrelid,\n\t\t\t\t\t\t\t\t  RelationRelationId,\n\t\t\t\t\t\t\t\t  attribute->attnum)) != NULL)\n\t\t{\n\t\t\tCommentStmt *stmt = makeNode(CommentStmt);\n\n\t\t\tstmt->objtype = OBJECT_COLUMN;\n\t\t\tstmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),\n\t\t\t\t\t\t\t\t\t\t\t   makeString(cxt->relation->relname),\n\t\t\t\t\t\t\t\t\t\t\t   makeString(def->colname));\n\t\t\tstmt->comment = comment;\n\n\t\t\tcxt->alist = lappend(cxt->alist, stmt);\n\t\t}\n\t}\n\n\t\/* We use oids if at least one LIKE'ed table has oids. *\/\n\tcxt->hasoids |= relation->rd_rel->relhasoids;\n\n\t\/*\n\t * We cannot yet deal with CHECK constraints or indexes, since we don't\n\t * yet know what column numbers the copied columns will have in the\n\t * finished table.  If any of those options are specified, add the LIKE\n\t * clause to cxt->likeclauses so that expandTableLikeClause will be called\n\t * after we do know that.  Also, remember the relation OID so that\n\t * expandTableLikeClause is certain to open the same table.\n\t *\/\n\tif (table_like_clause->options &\n\t\t(CREATE_TABLE_LIKE_CONSTRAINTS |\n\t\t CREATE_TABLE_LIKE_INDEXES))\n\t{\n\t\ttable_like_clause->relationOid = RelationGetRelid(relation);\n\t\tcxt->likeclauses = lappend(cxt->likeclauses, table_like_clause);\n\t}\n\n\t\/*\n\t * We may copy extended statistics if requested, since the representation\n\t * of CreateStatsStmt doesn't depend on column numbers.\n\t *\/\n\tif (table_like_clause->options & CREATE_TABLE_LIKE_STATISTICS)\n\t{\n\t\tList\t   *parent_extstats;\n\t\tListCell   *l;\n\n\t\tparent_extstats = RelationGetStatExtList(relation);\n\n\t\tforeach(l, parent_extstats)\n\t\t{\n\t\t\tOid\t\t\tparent_stat_oid = lfirst_oid(l);\n\t\t\tCreateStatsStmt *stats_stmt;\n\n\t\t\tstats_stmt = generateClonedExtStatsStmt(cxt->relation,\n\t\t\t\t\t\t\t\t\t\t\t\t\tRelationGetRelid(relation),\n\t\t\t\t\t\t\t\t\t\t\t\t\tparent_stat_oid);\n\t\t\tcxt->extstats = lappend(cxt->extstats, stats_stmt);\n\n\t\t\t\/*\n\t\t\t * We'd like to clone the comments too, but we lack the support\n\t\t\t * code to do it.\n\t\t\t *\/\n\t\t}\n\n\t\tlist_free(parent_extstats);\n\t}\n\n\t\/*\n\t * Close the parent rel, but keep our AccessShareLock on it until xact\n\t * commit.  That will prevent someone else from deleting or ALTERing the\n\t * parent before we can run expandTableLikeClause.\n\t *\/\n\theap_close(relation, NoLock);\n}","target":0,"code_token_length":1892,"total_token_length":2128,"max_tokens_setting":4096}
+{"idx":369277,"func":"transfer_secret_keys (ctrl_t ctrl, struct stats_s *stats, kbnode_t sec_keyblock)\n{\n  gpg_error_t err = 0;\n  void *kek = NULL;\n  size_t keklen;\n  kbnode_t ctx = NULL;\n  kbnode_t node;\n  PKT_public_key *main_pk, *pk;\n  struct seckey_info *ski;\n  int nskey;\n  membuf_t mbuf;\n  int i, j;\n  unsigned int n;\n  void *format_args_buf_ptr[PUBKEY_MAX_NSKEY];\n  int   format_args_buf_int[PUBKEY_MAX_NSKEY];\n  void *format_args[2*PUBKEY_MAX_NSKEY];\n  gcry_sexp_t skey, prot, tmpsexp;\n  unsigned char *transferkey = NULL;\n  size_t transferkeylen;\n  gcry_cipher_hd_t cipherhd = NULL;\n  unsigned char *wrappedkey = NULL;\n  size_t wrappedkeylen;\n  char *cache_nonce = NULL;\n  gcry_mpi_t ecc_params[5] = {NULL, NULL, NULL, NULL, NULL};\n\n  \/* Get the current KEK.  *\/\n  err = agent_keywrap_key (ctrl, 0, &kek, &keklen);\n  if (err)\n    {\n      log_error (\"error getting the KEK: %s\\n\", gpg_strerror (err));\n      goto leave;\n    }\n\n  \/* Prepare a cipher context.  *\/\n  err = gcry_cipher_open (&cipherhd, GCRY_CIPHER_AES128,\n                          GCRY_CIPHER_MODE_AESWRAP, 0);\n  if (!err)\n    err = gcry_cipher_setkey (cipherhd, kek, keklen);\n  if (err)\n    goto leave;\n  xfree (kek);\n  kek = NULL;\n\n  main_pk = NULL;\n  while ((node = walk_kbnode (sec_keyblock, &ctx, 0)))\n    {\n      if (node->pkt->pkttype != PKT_SECRET_KEY\n          && node->pkt->pkttype != PKT_SECRET_SUBKEY)\n        continue;\n      pk = node->pkt->pkt.public_key;\n      if (!main_pk)\n        main_pk = pk;\n\n      \/* Make sure the keyids are available.  *\/\n      keyid_from_pk (pk, NULL);\n      if (node->pkt->pkttype == PKT_SECRET_KEY)\n        {\n          pk->main_keyid[0] = pk->keyid[0];\n          pk->main_keyid[1] = pk->keyid[1];\n        }\n      else\n        {\n          pk->main_keyid[0] = main_pk->keyid[0];\n          pk->main_keyid[1] = main_pk->keyid[1];\n        }\n\n\n      ski = pk->seckey_info;\n      if (!ski)\n        BUG ();\n\n      stats->count++;\n      stats->secret_read++;\n\n      \/* We ignore stub keys.  The way we handle them in other parts\n         of the code is by asking the agent whether any secret key is\n         available for a given keyblock and then concluding that we\n         have a secret key; all secret (sub)keys of the keyblock the\n         agent does not know of are then stub keys.  This works also\n         for card stub keys.  The learn command or the card-status\n         command may be used to check with the agent whether a card\n         has been inserted and a stub key is in turn generated by the\n         agent.  *\/\n      if (ski->s2k.mode == 1001 || ski->s2k.mode == 1002)\n        continue;\n\n      \/* Convert our internal secret key object into an S-expression.  *\/\n      nskey = pubkey_get_nskey (pk->pubkey_algo);\n      if (!nskey || nskey > PUBKEY_MAX_NSKEY)\n        {\n          err = gpg_error (GPG_ERR_BAD_SECKEY);\n          log_error (\"internal error: %s\\n\", gpg_strerror (err));\n          goto leave;\n        }\n\n      init_membuf (&mbuf, 50);\n      put_membuf_str (&mbuf, \"(skey\");\n      if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA\n          || pk->pubkey_algo == PUBKEY_ALGO_ECDH)\n        {\n          \/* We need special treatment for ECC algorithms.  OpenPGP\n             stores only the curve name but the agent expects a full\n             key.  This is so that we can keep all curve name\n             validation code out of gpg-agent.  *\/\n#if PUBKEY_MAX_NSKEY < 7\n#error  PUBKEY_MAX_NSKEY too low for ECC\n#endif\n          char *curve = openpgp_oid_to_str (pk->pkey[0]);\n          if (!curve)\n            err = gpg_error_from_syserror ();\n          else\n            {\n              gcry_sexp_t cparam = gcry_pk_get_param (GCRY_PK_ECDSA, curve);\n\n              xfree (curve);\n              if (!cparam)\n                err = gpg_error (GPG_ERR_UNKNOWN_CURVE);\n              else\n                {\n                  const char *s;\n\n                  \/* Append the curve parameters P, A, B, G and N.  *\/\n                  for (i=j=0; !err && *(s = \"pabgn\"+i); i++)\n                    {\n                      ecc_params[i] = one_mpi_from_pkey (cparam, s, 1);\n                      if (!ecc_params[i])\n                        err = gpg_error (GPG_ERR_INV_CURVE);\n                      else\n                        {\n                          put_membuf_str (&mbuf, \" _ %m\");\n                          format_args[j++] = ecc_params+i;\n                        }\n                    }\n                  gcry_sexp_release (cparam);\n                  if (!err)\n                    {\n                      \/* Append the public key element Q.  *\/\n                      put_membuf_str (&mbuf, \" _ %m\");\n                      format_args[j++] = pk->pkey + 1;\n\n                      \/* Append the secret key element D.  Note that\n                         for ECDH we need to skip PKEY[2] because this\n                         holds the KEK which is not needed.  *\/\n                      i = pk->pubkey_algo == PUBKEY_ALGO_ECDH? 3 : 2;\n                      if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE))\n                        {\n                          put_membuf_str (&mbuf, \" e %b\");\n                          format_args_buf_ptr[i]\n                            = gcry_mpi_get_opaque (pk->pkey[i],&n);\n                          format_args_buf_int[i] = (n+7)\/8;\n                          format_args[j++] = format_args_buf_int + i;\n                          format_args[j++] = format_args_buf_ptr + i;\n                        }\n                      else\n                        {\n                          put_membuf_str (&mbuf, \" _ %m\");\n                          format_args[j++] = pk->pkey + i;\n                        }\n                    }\n                }\n            }\n        }\n      else\n        {\n          \/* Standard case for the old (non-ECC) algorithms.  *\/\n          for (i=j=0; i < nskey; i++)\n            {\n              if (!pk->pkey[i])\n                ; \/* Protected keys only have NPKEY+1 elements.  *\/\n              else if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE))\n                {\n                  put_membuf_str (&mbuf, \" e %b\");\n                  format_args_buf_ptr[i] = gcry_mpi_get_opaque (pk->pkey[i],&n);\n                  format_args_buf_int[i] = (n+7)\/8;\n                  format_args[j++] = format_args_buf_int + i;\n                  format_args[j++] = format_args_buf_ptr + i;\n                }\n              else\n                {\n                  put_membuf_str (&mbuf, \" _ %m\");\n                  format_args[j++] = pk->pkey + i;\n                }\n            }\n        }\n      put_membuf_str (&mbuf, \")\\n\");\n      put_membuf (&mbuf, \"\", 1);\n      if (err)\n        xfree (get_membuf (&mbuf, NULL));\n      else\n        {\n          char *format = get_membuf (&mbuf, NULL);\n          if (!format)\n            err = gpg_error_from_syserror ();\n          else\n            err = gcry_sexp_build_array (&skey, NULL, format, format_args);\n          xfree (format);\n        }\n      if (err)\n        {\n          log_error (\"error building skey array: %s\\n\", gpg_strerror (err));\n          goto leave;\n        }\n\n      if (ski->is_protected)\n        {\n          char countbuf[35];\n\n          \/* Note that the IVLEN may be zero if we are working on a\n             dummy key.  We can't express that in an S-expression and\n             thus we send dummy data for the IV.  *\/\n          snprintf (countbuf, sizeof countbuf, \"%lu\",\n                    (unsigned long)ski->s2k.count);\n          err = gcry_sexp_build\n            (&prot, NULL,\n             \" (protection %s %s %b %d %s %b %s)\\n\",\n             ski->sha1chk? \"sha1\":\"sum\",\n             openpgp_cipher_algo_name (ski->algo),\n             ski->ivlen? (int)ski->ivlen:1,\n             ski->ivlen? ski->iv: (const unsigned char*)\"X\",\n             ski->s2k.mode,\n             openpgp_md_algo_name (ski->s2k.hash_algo),\n             (int)sizeof (ski->s2k.salt), ski->s2k.salt,\n             countbuf);\n        }\n      else\n        err = gcry_sexp_build (&prot, NULL, \" (protection none)\\n\");\n\n      tmpsexp = NULL;\n      xfree (transferkey);\n      transferkey = NULL;\n      if (!err)\n        err = gcry_sexp_build (&tmpsexp, NULL,\n                               \"(openpgp-private-key\\n\"\n                               \" (version %d)\\n\"\n                               \" (algo %s)\\n\"\n                               \" %S\\n\"\n                               \" (csum %d)\\n\"\n                               \" %S)\\n\",\n                               pk->version,\n                               openpgp_pk_algo_name (pk->pubkey_algo),\n                               skey, (int)(unsigned long)ski->csum, prot);\n      gcry_sexp_release (skey);\n      gcry_sexp_release (prot);\n      if (!err)\n        err = make_canon_sexp_pad (tmpsexp, 1, &transferkey, &transferkeylen);\n      gcry_sexp_release (tmpsexp);\n      if (err)\n        {\n          log_error (\"error building transfer key: %s\\n\", gpg_strerror (err));\n          goto leave;\n        }\n\n      \/* Wrap the key.  *\/\n      wrappedkeylen = transferkeylen + 8;\n      xfree (wrappedkey);\n      wrappedkey = xtrymalloc (wrappedkeylen);\n      if (!wrappedkey)\n        err = gpg_error_from_syserror ();\n      else\n        err = gcry_cipher_encrypt (cipherhd, wrappedkey, wrappedkeylen,\n                                   transferkey, transferkeylen);\n      if (err)\n        goto leave;\n      xfree (transferkey);\n      transferkey = NULL;\n\n      \/* Send the wrapped key to the agent.  *\/\n      {\n        char *desc = gpg_format_keydesc (pk, 1, 1);\n        err = agent_import_key (ctrl, desc, &cache_nonce,\n                                wrappedkey, wrappedkeylen);\n        xfree (desc);\n      }\n      if (!err)\n        {\n          if (opt.verbose)\n            log_info (_(\"key %s: secret key imported\\n\"),\n                      keystr_from_pk_with_sub (main_pk, pk));\n          stats->secret_imported++;\n        }\n      else if ( gpg_err_code (err) == GPG_ERR_EEXIST )\n        {\n          if (opt.verbose)\n            log_info (_(\"key %s: secret key already exists\\n\"),\n                      keystr_from_pk_with_sub (main_pk, pk));\n          err = 0;\n          stats->secret_dups++;\n        }\n      else\n        {\n          log_error (_(\"key %s: error sending to agent: %s\\n\"),\n                     keystr_from_pk_with_sub (main_pk, pk),\n                     gpg_strerror (err));\n          if (gpg_err_code (err) == GPG_ERR_CANCELED\n              || gpg_err_code (err) == GPG_ERR_FULLY_CANCELED)\n            break; \/* Don't try the other subkeys.  *\/\n        }\n    }\n\n leave:\n  for (i=0; i < DIM (ecc_params); i++)\n    gcry_mpi_release (ecc_params[i]);\n  xfree (cache_nonce);\n  xfree (wrappedkey);\n  xfree (transferkey);\n  gcry_cipher_close (cipherhd);\n  xfree (kek);\n  return err;\n}","target":0,"code_token_length":2760,"total_token_length":2996,"max_tokens_setting":4096}
+{"idx":258214,"func":"void proto_register_t38 ( void ) {\n static hf_register_info hf [ ] = {\n # line 1 \"..\/..\/asn1\/t38\/packet-t38-hfarr.c\" {\n & hf_t38_IFPPacket_PDU , {\n \"IFPPacket\" , \"t38.IFPPacket_element\" , FT_NONE , BASE_NONE , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_UDPTLPacket_PDU , {\n \"UDPTLPacket\" , \"t38.UDPTLPacket_element\" , FT_NONE , BASE_NONE , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_type_of_msg , {\n \"type-of-msg\" , \"t38.type_of_msg\" , FT_UINT32 , BASE_DEC , VALS ( t38_Type_of_msg_vals ) , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_data_field , {\n \"data-field\" , \"t38.data_field\" , FT_UINT32 , BASE_DEC , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_t30_indicator , {\n \"t30-indicator\" , \"t38.t30_indicator\" , FT_UINT32 , BASE_DEC , VALS ( t38_T30_indicator_vals ) , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_t30_data , {\n \"t30-data\" , \"t38.t30_data\" , FT_UINT32 , BASE_DEC , VALS ( t38_T30_data_vals ) , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_Data_Field_item , {\n \"Data-Field item\" , \"t38.Data_Field_item_element\" , FT_NONE , BASE_NONE , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_field_type , {\n \"field-type\" , \"t38.field_type\" , FT_UINT32 , BASE_DEC , VALS ( t38_T_field_type_vals ) , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_field_data , {\n \"field-data\" , \"t38.field_data\" , FT_BYTES , BASE_NONE , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_seq_number , {\n \"seq-number\" , \"t38.seq_number\" , FT_UINT32 , BASE_DEC , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_primary_ifp_packet , {\n \"primary-ifp-packet\" , \"t38.primary_ifp_packet_element\" , FT_NONE , BASE_NONE , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_error_recovery , {\n \"error-recovery\" , \"t38.error_recovery\" , FT_UINT32 , BASE_DEC , VALS ( t38_T_error_recovery_vals ) , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_secondary_ifp_packets , {\n \"secondary-ifp-packets\" , \"t38.secondary_ifp_packets\" , FT_UINT32 , BASE_DEC , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_secondary_ifp_packets_item , {\n \"secondary-ifp-packets item\" , \"t38.secondary_ifp_packets_item_element\" , FT_NONE , BASE_NONE , NULL , 0 , \"OpenType_IFPPacket\" , HFILL }\n }\n , {\n & hf_t38_fec_info , {\n \"fec-info\" , \"t38.fec_info_element\" , FT_NONE , BASE_NONE , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_fec_npackets , {\n \"fec-npackets\" , \"t38.fec_npackets\" , FT_INT32 , BASE_DEC , NULL , 0 , \"INTEGER\" , HFILL }\n }\n , {\n & hf_t38_fec_data , {\n \"fec-data\" , \"t38.fec_data\" , FT_UINT32 , BASE_DEC , NULL , 0 , NULL , HFILL }\n }\n , {\n & hf_t38_fec_data_item , {\n \"fec-data item\" , \"t38.fec_data_item\" , FT_BYTES , BASE_NONE , NULL , 0 , \"OCTET_STRING\" , HFILL }\n }\n , # line 659 \"..\/..\/asn1\/t38\/packet-t38-template.c\" {\n & hf_t38_setup , {\n \"Stream setup\" , \"t38.setup\" , FT_STRING , BASE_NONE , NULL , 0x0 , \"Stream setup, method and frame number\" , HFILL }\n }\n , {\n & hf_t38_setup_frame , {\n \"Stream frame\" , \"t38.setup-frame\" , FT_FRAMENUM , BASE_NONE , NULL , 0x0 , \"Frame that set up this stream\" , HFILL }\n }\n , {\n & hf_t38_setup_method , {\n \"Stream Method\" , \"t38.setup-method\" , FT_STRING , BASE_NONE , NULL , 0x0 , \"Method used to set up this stream\" , HFILL }\n }\n , {\n & hf_t38_fragments , {\n \"Message fragments\" , \"t38.fragments\" , FT_NONE , BASE_NONE , NULL , 0x00 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment , {\n \"Message fragment\" , \"t38.fragment\" , FT_FRAMENUM , BASE_NONE , NULL , 0x00 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment_overlap , {\n \"Message fragment overlap\" , \"t38.fragment.overlap\" , FT_BOOLEAN , BASE_NONE , NULL , 0x0 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment_overlap_conflicts , {\n \"Message fragment overlapping with conflicting data\" , \"t38.fragment.overlap.conflicts\" , FT_BOOLEAN , BASE_NONE , NULL , 0x0 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment_multiple_tails , {\n \"Message has multiple tail fragments\" , \"t38.fragment.multiple_tails\" , FT_BOOLEAN , BASE_NONE , NULL , 0x0 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment_too_long_fragment , {\n \"Message fragment too long\" , \"t38.fragment.too_long_fragment\" , FT_BOOLEAN , BASE_NONE , NULL , 0x0 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment_error , {\n \"Message defragmentation error\" , \"t38.fragment.error\" , FT_FRAMENUM , BASE_NONE , NULL , 0x00 , NULL , HFILL }\n }\n , {\n & hf_t38_fragment_count , {\n \"Message fragment count\" , \"t38.fragment.count\" , FT_UINT32 , BASE_DEC , NULL , 0x00 , NULL , HFILL }\n }\n , {\n & hf_t38_reassembled_in , {\n \"Reassembled in\" , \"t38.reassembled.in\" , FT_FRAMENUM , BASE_NONE , NULL , 0x00 , NULL , HFILL }\n }\n , {\n & hf_t38_reassembled_length , {\n \"Reassembled T38 length\" , \"t38.reassembled.length\" , FT_UINT32 , BASE_DEC , NULL , 0x00 , NULL , HFILL }\n }\n , }\n ;\n static gint * ett [ ] = {\n & ett_t38 , # line 1 \"..\/..\/asn1\/t38\/packet-t38-ettarr.c\" & ett_t38_IFPPacket , & ett_t38_Type_of_msg , & ett_t38_Data_Field , & ett_t38_Data_Field_item , & ett_t38_UDPTLPacket , & ett_t38_T_error_recovery , & ett_t38_T_secondary_ifp_packets , & ett_t38_T_fec_info , & ett_t38_T_fec_data , # line 706 \"..\/..\/asn1\/t38\/packet-t38-template.c\" & ett_t38_setup , & ett_data_fragment , & ett_data_fragments }\n ;\n static ei_register_info ei [ ] = {\n {\n & ei_t38_malformed , {\n \"t38.malformed\" , PI_MALFORMED , PI_ERROR , \"Malformed packet\" , EXPFILL }\n }\n , }\n ;\n module_t * t38_module ;\n expert_module_t * expert_t38 ;\n proto_t38 = proto_register_protocol ( \"T.38\" , \"T.38\" , \"t38\" ) ;\n proto_register_field_array ( proto_t38 , hf , array_length ( hf ) ) ;\n proto_register_subtree_array ( ett , array_length ( ett ) ) ;\n expert_t38 = expert_register_protocol ( proto_t38 ) ;\n expert_register_field_array ( expert_t38 , ei , array_length ( ei ) ) ;\n register_dissector ( \"t38_udp\" , dissect_t38_udp , proto_t38 ) ;\n register_init_routine ( t38_defragment_init ) ;\n register_cleanup_routine ( t38_defragment_cleanup ) ;\n t38_tap = register_tap ( \"t38\" ) ;\n t38_module = prefs_register_protocol ( proto_t38 , proto_reg_handoff_t38 ) ;\n prefs_register_bool_preference ( t38_module , \"use_pre_corrigendum_asn1_specification\" , \"Use the Pre-Corrigendum ASN.1 specification\" , \"Whether the T.38 dissector should decode using the Pre-Corrigendum T.38 \" \"ASN.1 specification (1998).\" , & use_pre_corrigendum_asn1_specification ) ;\n prefs_register_bool_preference ( t38_module , \"dissect_possible_rtpv2_packets_as_rtp\" , \"Dissect possible RTP version 2 packets with RTP dissector\" , \"Whether a UDP packet that looks like RTP version 2 packet will \" \"be dissected as RTP packet or T.38 packet. If enabled there is a risk that T.38 UDPTL \" \"packets with sequence number higher than 32767 may be dissected as RTP.\" , & dissect_possible_rtpv2_packets_as_rtp ) ;\n prefs_register_uint_preference ( t38_module , \"tcp.port\" , \"T.38 TCP Port\" , \"Set the TCP port for T.38 messages\" , 10 , & global_t38_tcp_port ) ;\n prefs_register_uint_preference ( t38_module , \"udp.port\" , \"T.38 UDP Port\" , \"Set the UDP port for T.38 messages\" , 10 , & global_t38_udp_port ) ;\n prefs_register_bool_preference ( t38_module , \"reassembly\" , \"Reassemble T.38 PDUs over TPKT over TCP\" , \"Whether the dissector should reassemble T.38 PDUs spanning multiple TCP segments \" \"when TPKT is used over TCP. \" \"To use this option, you must also enable \\\"Allow subdissectors to reassemble \" \"TCP streams\\\" in the TCP protocol settings.\" , & t38_tpkt_reassembly ) ;\n prefs_register_enum_preference ( t38_module , \"tpkt_usage\" , \"TPKT used over TCP\" , \"Whether T.38 is used with TPKT for TCP\" , ( gint * ) & t38_tpkt_usage , t38_tpkt_options , FALSE ) ;\n prefs_register_bool_preference ( t38_module , \"show_setup_info\" , \"Show stream setup information\" , \"Where available, show which protocol and frame caused \" \"this T.38 stream to be created\" , & global_t38_show_setup_info ) ;\n }","target":0,"code_token_length":2547,"total_token_length":2783,"max_tokens_setting":4096}
+{"idx":452906,"func":"static bool torture_smb2_notify_dir(struct torture_context *torture,\n\t\t\t      struct smb2_tree *tree1,\n\t\t\t      struct smb2_tree *tree2)\n{\n\tbool ret = true;\n\tNTSTATUS status;\n\tunion smb_notify notify;\n\tunion smb_open io;\n\tunion smb_close cl;\n\tint i, count;\n\tstruct smb2_handle h1 = {{0}};\n\tstruct smb2_handle h2 = {{0}};\n\tstruct smb2_request *req, *req2;\n\tconst char *fname = BASEDIR_DIR \"\\\\subdir-name\";\n\textern int torture_numops;\n\n\ttorture_comment(torture, \"TESTING CHANGE NOTIFY ON DIRECTORIES\\n\");\n\n\tsmb2_deltree(tree1, BASEDIR_DIR);\n\tsmb2_util_rmdir(tree1, BASEDIR_DIR);\n\t\/*\n\t  get a handle on the directory\n\t*\/\n\tZERO_STRUCT(io.smb2);\n\tio.generic.level = RAW_OPEN_SMB2;\n\tio.smb2.in.create_flags = 0;\n\tio.smb2.in.desired_access = SEC_FILE_ALL;\n\tio.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;\n\tio.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;\n\tio.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ |\n\t\t\t\tNTCREATEX_SHARE_ACCESS_WRITE;\n\tio.smb2.in.alloc_size = 0;\n\tio.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;\n\tio.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;\n\tio.smb2.in.security_flags = 0;\n\tio.smb2.in.fname = BASEDIR_DIR;\n\n\tstatus = smb2_create(tree1, torture, &(io.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\th1 = io.smb2.out.file.handle;\n\n\tio.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;\n\tio.smb2.in.desired_access = SEC_RIGHTS_FILE_READ;\n\tstatus = smb2_create(tree1, torture, &(io.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\th2 = io.smb2.out.file.handle;\n\n\t\/* ask for a change notify,\n\t   on file or directory name changes *\/\n\tZERO_STRUCT(notify.smb2);\n\tnotify.smb2.level = RAW_NOTIFY_SMB2;\n\tnotify.smb2.in.buffer_size = 1000;\n\tnotify.smb2.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;\n\tnotify.smb2.in.file.handle = h1;\n\tnotify.smb2.in.recursive = true;\n\n\ttorture_comment(torture, \"Testing notify cancel\\n\");\n\n\treq = smb2_notify_send(tree1, &(notify.smb2));\n\tsmb2_cancel(req);\n\tstatus = smb2_notify_recv(req, torture, &(notify.smb2));\n\tCHECK_STATUS(status, NT_STATUS_CANCELLED);\n\n\ttorture_comment(torture, \"Testing notify mkdir\\n\");\n\n\treq = smb2_notify_send(tree1, &(notify.smb2));\n\tsmb2_util_mkdir(tree2, fname);\n\n\tstatus = smb2_notify_recv(req, torture, &(notify.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\n\tCHECK_VAL(notify.smb2.out.num_changes, 1);\n\tCHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_ADDED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[0].name, \"subdir-name\");\n\n\ttorture_comment(torture, \"Testing notify rmdir\\n\");\n\n\treq = smb2_notify_send(tree1, &(notify.smb2));\n\tsmb2_util_rmdir(tree2, fname);\n\n\tstatus = smb2_notify_recv(req, torture, &(notify.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VAL(notify.smb2.out.num_changes, 1);\n\tCHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_REMOVED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[0].name, \"subdir-name\");\n\n\ttorture_comment(torture,\n\t\t\"Testing notify mkdir - rmdir - mkdir - rmdir\\n\");\n\n\tsmb2_util_mkdir(tree2, fname);\n\tsmb2_util_rmdir(tree2, fname);\n\tsmb2_util_mkdir(tree2, fname);\n\tsmb2_util_rmdir(tree2, fname);\n\tsmb_msleep(200);\n\treq = smb2_notify_send(tree1, &(notify.smb2));\n\tstatus = smb2_notify_recv(req, torture, &(notify.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VAL(notify.smb2.out.num_changes, 4);\n\tCHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_ADDED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[0].name, \"subdir-name\");\n\tCHECK_VAL(notify.smb2.out.changes[1].action, NOTIFY_ACTION_REMOVED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[1].name, \"subdir-name\");\n\tCHECK_VAL(notify.smb2.out.changes[2].action, NOTIFY_ACTION_ADDED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[2].name, \"subdir-name\");\n\tCHECK_VAL(notify.smb2.out.changes[3].action, NOTIFY_ACTION_REMOVED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[3].name, \"subdir-name\");\n\n\tcount = torture_numops;\n\ttorture_comment(torture,\n\t\t\"Testing buffered notify on create of %d files\\n\", count);\n\tfor (i=0;i __pyx_result, __pyx_state)\n *\/\n  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)\n  __Pyx_GOTREF(__pyx_t_2);\n  __pyx_t_4 = NULL;\n  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {\n    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);\n    if (likely(__pyx_t_4)) {\n      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);\n      __Pyx_INCREF(__pyx_t_4);\n      __Pyx_INCREF(function);\n      __Pyx_DECREF_SET(__pyx_t_2, function);\n    }\n  }\n  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);\n  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;\n  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)\n  __Pyx_GOTREF(__pyx_t_3);\n  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;\n  __pyx_v___pyx_result = __pyx_t_3;\n  __pyx_t_3 = 0;\n\n  \/* \"(tree fragment)\":8\n *         raise __pyx_PickleError(\"Incompatible checksums (%s vs 0x3baf4af = (buffer, buffer_size, position, sock))\" % __pyx_checksum)\n *     __pyx_result = BufferedSocketWriter.__new__(__pyx_type)\n *     if __pyx_state is not None:             # <<<<<<<<<<<<<<\n *         __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state)\n *     return __pyx_result\n *\/\n  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);\n  __pyx_t_6 = (__pyx_t_1 != 0);\n  if (__pyx_t_6) {\n\n    \/* \"(tree fragment)\":9\n *     __pyx_result = BufferedSocketWriter.__new__(__pyx_type)\n *     if __pyx_state is not None:\n *         __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<\n *     return __pyx_result\n * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, tuple __pyx_state):\n *\/\n    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, \"Expected %.16s, got %.200s\", \"tuple\", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)\n    __pyx_t_3 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedSocketWriter__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)\n    __Pyx_GOTREF(__pyx_t_3);\n    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;\n\n    \/* \"(tree fragment)\":8\n *         raise __pyx_PickleError(\"Incompatible checksums (%s vs 0x3baf4af = (buffer, buffer_size, position, sock))\" % __pyx_checksum)\n *     __pyx_result = BufferedSocketWriter.__new__(__pyx_type)\n *     if __pyx_state is not None:             # <<<<<<<<<<<<<<\n *         __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state)\n *     return __pyx_result\n *\/\n  }\n\n  \/* \"(tree fragment)\":10\n *     if __pyx_state is not None:\n *         __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state)\n *     return __pyx_result             # <<<<<<<<<<<<<<\n * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, tuple __pyx_state):\n *     __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]\n *\/\n  __Pyx_XDECREF(__pyx_r);\n  __Pyx_INCREF(__pyx_v___pyx_result);\n  __pyx_r = __pyx_v___pyx_result;\n  goto __pyx_L0;\n\n  \/* \"(tree fragment)\":1\n * def __pyx_unpickle_BufferedSocketWriter(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<\n *     cdef object __pyx_PickleError\n *     cdef object __pyx_result\n *\/\n\n  \/* function exit code *\/\n  __pyx_L1_error:;\n  __Pyx_XDECREF(__pyx_t_2);\n  __Pyx_XDECREF(__pyx_t_3);\n  __Pyx_XDECREF(__pyx_t_4);\n  __Pyx_XDECREF(__pyx_t_5);\n  __Pyx_AddTraceback(\"clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedSocketWriter\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n  __pyx_r = NULL;\n  __pyx_L0:;\n  __Pyx_XDECREF(__pyx_v___pyx_PickleError);\n  __Pyx_XDECREF(__pyx_v___pyx_result);\n  __Pyx_XGIVEREF(__pyx_r);\n  __Pyx_RefNannyFinishContext();\n  return __pyx_r;\n}","target":0,"code_token_length":2994,"total_token_length":3230,"max_tokens_setting":4096}
+{"idx":59053,"func":"int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,\n\t\t\tstruct ext4_map_blocks *map, int flags)\n{\n\tstruct ext4_ext_path *path = NULL;\n\tstruct ext4_extent newex, *ex, *ex2;\n\tstruct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);\n\text4_fsblk_t newblock = 0;\n\tint free_on_err = 0, err = 0, depth, ret;\n\tunsigned int allocated = 0, offset = 0;\n\tunsigned int allocated_clusters = 0;\n\tstruct ext4_allocation_request ar;\n\text4_io_end_t *io = ext4_inode_aio(inode);\n\text4_lblk_t cluster_offset;\n\tint set_unwritten = 0;\n\tbool map_from_cluster = false;\n\n\text_debug(\"blocks %u\/%u requested for inode %lu\\n\",\n\t\t  map->m_lblk, map->m_len, inode->i_ino);\n\ttrace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);\n\n\t\/* find extent for this block *\/\n\tpath = ext4_find_extent(inode, map->m_lblk, NULL, 0);\n\tif (IS_ERR(path)) {\n\t\terr = PTR_ERR(path);\n\t\tpath = NULL;\n\t\tgoto out2;\n\t}\n\n\tdepth = ext_depth(inode);\n\n\t\/*\n\t * consistent leaf must not be empty;\n\t * this situation is possible, though, _during_ tree modification;\n\t * this is why assert can't be put in ext4_find_extent()\n\t *\/\n\tif (unlikely(path[depth].p_ext == NULL && depth != 0)) {\n\t\tEXT4_ERROR_INODE(inode, \"bad extent address \"\n\t\t\t\t \"lblock: %lu, depth: %d pblock %lld\",\n\t\t\t\t (unsigned long) map->m_lblk, depth,\n\t\t\t\t path[depth].p_block);\n\t\terr = -EFSCORRUPTED;\n\t\tgoto out2;\n\t}\n\n\tex = path[depth].p_ext;\n\tif (ex) {\n\t\text4_lblk_t ee_block = le32_to_cpu(ex->ee_block);\n\t\text4_fsblk_t ee_start = ext4_ext_pblock(ex);\n\t\tunsigned short ee_len;\n\n\n\t\t\/*\n\t\t * unwritten extents are treated as holes, except that\n\t\t * we split out initialized portions during a write.\n\t\t *\/\n\t\tee_len = ext4_ext_get_actual_len(ex);\n\n\t\ttrace_ext4_ext_show_extent(inode, ee_block, ee_start, ee_len);\n\n\t\t\/* if found extent covers block, simply return it *\/\n\t\tif (in_range(map->m_lblk, ee_block, ee_len)) {\n\t\t\tnewblock = map->m_lblk - ee_block + ee_start;\n\t\t\t\/* number of remaining blocks in the extent *\/\n\t\t\tallocated = ee_len - (map->m_lblk - ee_block);\n\t\t\text_debug(\"%u fit into %u:%d -> %llu\\n\", map->m_lblk,\n\t\t\t\t  ee_block, ee_len, newblock);\n\n\t\t\t\/*\n\t\t\t * If the extent is initialized check whether the\n\t\t\t * caller wants to convert it to unwritten.\n\t\t\t *\/\n\t\t\tif ((!ext4_ext_is_unwritten(ex)) &&\n\t\t\t    (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {\n\t\t\t\tallocated = convert_initialized_extent(\n\t\t\t\t\t\thandle, inode, map, &path,\n\t\t\t\t\t\tflags, allocated, newblock);\n\t\t\t\tgoto out2;\n\t\t\t} else if (!ext4_ext_is_unwritten(ex))\n\t\t\t\tgoto out;\n\n\t\t\tret = ext4_ext_handle_unwritten_extents(\n\t\t\t\thandle, inode, map, &path, flags,\n\t\t\t\tallocated, newblock);\n\t\t\tif (ret < 0)\n\t\t\t\terr = ret;\n\t\t\telse\n\t\t\t\tallocated = ret;\n\t\t\tgoto out2;\n\t\t}\n\t}\n\n\t\/*\n\t * requested block isn't allocated yet;\n\t * we couldn't try to create block if create flag is zero\n\t *\/\n\tif ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {\n\t\t\/*\n\t\t * put just found gap into cache to speed up\n\t\t * subsequent requests\n\t\t *\/\n\t\text4_ext_put_gap_in_cache(inode, path, map->m_lblk);\n\t\tgoto out2;\n\t}\n\n\t\/*\n\t * Okay, we need to do block allocation.\n\t *\/\n\tnewex.ee_block = cpu_to_le32(map->m_lblk);\n\tcluster_offset = EXT4_LBLK_COFF(sbi, map->m_lblk);\n\n\t\/*\n\t * If we are doing bigalloc, check to see if the extent returned\n\t * by ext4_find_extent() implies a cluster we can use.\n\t *\/\n\tif (cluster_offset && ex &&\n\t    get_implied_cluster_alloc(inode->i_sb, map, ex, path)) {\n\t\tar.len = allocated = map->m_len;\n\t\tnewblock = map->m_pblk;\n\t\tmap_from_cluster = true;\n\t\tgoto got_allocated_blocks;\n\t}\n\n\t\/* find neighbour allocated blocks *\/\n\tar.lleft = map->m_lblk;\n\terr = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft);\n\tif (err)\n\t\tgoto out2;\n\tar.lright = map->m_lblk;\n\tex2 = NULL;\n\terr = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2);\n\tif (err)\n\t\tgoto out2;\n\n\t\/* Check if the extent after searching to the right implies a\n\t * cluster we can use. *\/\n\tif ((sbi->s_cluster_ratio > 1) && ex2 &&\n\t    get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) {\n\t\tar.len = allocated = map->m_len;\n\t\tnewblock = map->m_pblk;\n\t\tmap_from_cluster = true;\n\t\tgoto got_allocated_blocks;\n\t}\n\n\t\/*\n\t * See if request is beyond maximum number of blocks we can have in\n\t * a single extent. For an initialized extent this limit is\n\t * EXT_INIT_MAX_LEN and for an unwritten extent this limit is\n\t * EXT_UNWRITTEN_MAX_LEN.\n\t *\/\n\tif (map->m_len > EXT_INIT_MAX_LEN &&\n\t    !(flags & EXT4_GET_BLOCKS_UNWRIT_EXT))\n\t\tmap->m_len = EXT_INIT_MAX_LEN;\n\telse if (map->m_len > EXT_UNWRITTEN_MAX_LEN &&\n\t\t (flags & EXT4_GET_BLOCKS_UNWRIT_EXT))\n\t\tmap->m_len = EXT_UNWRITTEN_MAX_LEN;\n\n\t\/* Check if we can really insert (m_lblk)::(m_lblk + m_len) extent *\/\n\tnewex.ee_len = cpu_to_le16(map->m_len);\n\terr = ext4_ext_check_overlap(sbi, inode, &newex, path);\n\tif (err)\n\t\tallocated = ext4_ext_get_actual_len(&newex);\n\telse\n\t\tallocated = map->m_len;\n\n\t\/* allocate new block *\/\n\tar.inode = inode;\n\tar.goal = ext4_ext_find_goal(inode, path, map->m_lblk);\n\tar.logical = map->m_lblk;\n\t\/*\n\t * We calculate the offset from the beginning of the cluster\n\t * for the logical block number, since when we allocate a\n\t * physical cluster, the physical block should start at the\n\t * same offset from the beginning of the cluster.  This is\n\t * needed so that future calls to get_implied_cluster_alloc()\n\t * work correctly.\n\t *\/\n\toffset = EXT4_LBLK_COFF(sbi, map->m_lblk);\n\tar.len = EXT4_NUM_B2C(sbi, offset+allocated);\n\tar.goal -= offset;\n\tar.logical -= offset;\n\tif (S_ISREG(inode->i_mode))\n\t\tar.flags = EXT4_MB_HINT_DATA;\n\telse\n\t\t\/* disable in-core preallocation for non-regular files *\/\n\t\tar.flags = 0;\n\tif (flags & EXT4_GET_BLOCKS_NO_NORMALIZE)\n\t\tar.flags |= EXT4_MB_HINT_NOPREALLOC;\n\tif (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)\n\t\tar.flags |= EXT4_MB_DELALLOC_RESERVED;\n\tif (flags & EXT4_GET_BLOCKS_METADATA_NOFAIL)\n\t\tar.flags |= EXT4_MB_USE_RESERVED;\n\tnewblock = ext4_mb_new_blocks(handle, &ar, &err);\n\tif (!newblock)\n\t\tgoto out2;\n\text_debug(\"allocate new block: goal %llu, found %llu\/%u\\n\",\n\t\t  ar.goal, newblock, allocated);\n\tfree_on_err = 1;\n\tallocated_clusters = ar.len;\n\tar.len = EXT4_C2B(sbi, ar.len) - offset;\n\tif (ar.len > allocated)\n\t\tar.len = allocated;\n\ngot_allocated_blocks:\n\t\/* try to insert new extent into found leaf and return *\/\n\text4_ext_store_pblock(&newex, newblock + offset);\n\tnewex.ee_len = cpu_to_le16(ar.len);\n\t\/* Mark unwritten *\/\n\tif (flags & EXT4_GET_BLOCKS_UNWRIT_EXT){\n\t\text4_ext_mark_unwritten(&newex);\n\t\tmap->m_flags |= EXT4_MAP_UNWRITTEN;\n\t\t\/*\n\t\t * io_end structure was created for every IO write to an\n\t\t * unwritten extent. To avoid unnecessary conversion,\n\t\t * here we flag the IO that really needs the conversion.\n\t\t * For non asycn direct IO case, flag the inode state\n\t\t * that we need to perform conversion when IO is done.\n\t\t *\/\n\t\tif (flags & EXT4_GET_BLOCKS_PRE_IO)\n\t\t\tset_unwritten = 1;\n\t}\n\n\terr = 0;\n\tif ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0)\n\t\terr = check_eofblocks_fl(handle, inode, map->m_lblk,\n\t\t\t\t\t path, ar.len);\n\tif (!err)\n\t\terr = ext4_ext_insert_extent(handle, inode, &path,\n\t\t\t\t\t     &newex, flags);\n\n\tif (!err && set_unwritten) {\n\t\tif (io)\n\t\t\text4_set_io_unwritten_flag(inode, io);\n\t\telse\n\t\t\text4_set_inode_state(inode,\n\t\t\t\t\t     EXT4_STATE_DIO_UNWRITTEN);\n\t}\n\n\tif (err && free_on_err) {\n\t\tint fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?\n\t\t\tEXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;\n\t\t\/* free data blocks we just allocated *\/\n\t\t\/* not a good idea to call discard here directly,\n\t\t * but otherwise we'd need to call it every free() *\/\n\t\text4_discard_preallocations(inode);\n\t\text4_free_blocks(handle, inode, NULL, newblock,\n\t\t\t\t EXT4_C2B(sbi, allocated_clusters), fb_flags);\n\t\tgoto out2;\n\t}\n\n\t\/* previous routine could use block we allocated *\/\n\tnewblock = ext4_ext_pblock(&newex);\n\tallocated = ext4_ext_get_actual_len(&newex);\n\tif (allocated > map->m_len)\n\t\tallocated = map->m_len;\n\tmap->m_flags |= EXT4_MAP_NEW;\n\n\t\/*\n\t * Update reserved blocks\/metadata blocks after successful\n\t * block allocation which had been deferred till now.\n\t *\/\n\tif (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) {\n\t\tunsigned int reserved_clusters;\n\t\t\/*\n\t\t * Check how many clusters we had reserved this allocated range\n\t\t *\/\n\t\treserved_clusters = get_reserved_cluster_alloc(inode,\n\t\t\t\t\t\tmap->m_lblk, allocated);\n\t\tif (!map_from_cluster) {\n\t\t\tBUG_ON(allocated_clusters < reserved_clusters);\n\t\t\tif (reserved_clusters < allocated_clusters) {\n\t\t\t\tstruct ext4_inode_info *ei = EXT4_I(inode);\n\t\t\t\tint reservation = allocated_clusters -\n\t\t\t\t\t\t  reserved_clusters;\n\t\t\t\t\/*\n\t\t\t\t * It seems we claimed few clusters outside of\n\t\t\t\t * the range of this allocation. We should give\n\t\t\t\t * it back to the reservation pool. This can\n\t\t\t\t * happen in the following case:\n\t\t\t\t *\n\t\t\t\t * * Suppose s_cluster_ratio is 4 (i.e., each\n\t\t\t\t *   cluster has 4 blocks. Thus, the clusters\n\t\t\t\t *   are [0-3],[4-7],[8-11]...\n\t\t\t\t * * First comes delayed allocation write for\n\t\t\t\t *   logical blocks 10 & 11. Since there were no\n\t\t\t\t *   previous delayed allocated blocks in the\n\t\t\t\t *   range [8-11], we would reserve 1 cluster\n\t\t\t\t *   for this write.\n\t\t\t\t * * Next comes write for logical blocks 3 to 8.\n\t\t\t\t *   In this case, we will reserve 2 clusters\n\t\t\t\t *   (for [0-3] and [4-7]; and not for [8-11] as\n\t\t\t\t *   that range has a delayed allocated blocks.\n\t\t\t\t *   Thus total reserved clusters now becomes 3.\n\t\t\t\t * * Now, during the delayed allocation writeout\n\t\t\t\t *   time, we will first write blocks [3-8] and\n\t\t\t\t *   allocate 3 clusters for writing these\n\t\t\t\t *   blocks. Also, we would claim all these\n\t\t\t\t *   three clusters above.\n\t\t\t\t * * Now when we come here to writeout the\n\t\t\t\t *   blocks [10-11], we would expect to claim\n\t\t\t\t *   the reservation of 1 cluster we had made\n\t\t\t\t *   (and we would claim it since there are no\n\t\t\t\t *   more delayed allocated blocks in the range\n\t\t\t\t *   [8-11]. But our reserved cluster count had\n\t\t\t\t *   already gone to 0.\n\t\t\t\t *\n\t\t\t\t *   Thus, at the step 4 above when we determine\n\t\t\t\t *   that there are still some unwritten delayed\n\t\t\t\t *   allocated blocks outside of our current\n\t\t\t\t *   block range, we should increment the\n\t\t\t\t *   reserved clusters count so that when the\n\t\t\t\t *   remaining blocks finally gets written, we\n\t\t\t\t *   could claim them.\n\t\t\t\t *\/\n\t\t\t\tdquot_reserve_block(inode,\n\t\t\t\t\t\tEXT4_C2B(sbi, reservation));\n\t\t\t\tspin_lock(&ei->i_block_reservation_lock);\n\t\t\t\tei->i_reserved_data_blocks += reservation;\n\t\t\t\tspin_unlock(&ei->i_block_reservation_lock);\n\t\t\t}\n\t\t\t\/*\n\t\t\t * We will claim quota for all newly allocated blocks.\n\t\t\t * We're updating the reserved space *after* the\n\t\t\t * correction above so we do not accidentally free\n\t\t\t * all the metadata reservation because we might\n\t\t\t * actually need it later on.\n\t\t\t *\/\n\t\t\text4_da_update_reserve_space(inode, allocated_clusters,\n\t\t\t\t\t\t\t1);\n\t\t}\n\t}\n\n\t\/*\n\t * Cache the extent and update transaction to commit on fdatasync only\n\t * when it is _not_ an unwritten extent.\n\t *\/\n\tif ((flags & EXT4_GET_BLOCKS_UNWRIT_EXT) == 0)\n\t\text4_update_inode_fsync_trans(handle, inode, 1);\n\telse\n\t\text4_update_inode_fsync_trans(handle, inode, 0);\nout:\n\tif (allocated > map->m_len)\n\t\tallocated = map->m_len;\n\text4_ext_show_leaf(inode, path);\n\tmap->m_flags |= EXT4_MAP_MAPPED;\n\tmap->m_pblk = newblock;\n\tmap->m_len = allocated;\nout2:\n\text4_ext_drop_refs(path);\n\tkfree(path);\n\n\ttrace_ext4_ext_map_blocks_exit(inode, flags, map,\n\t\t\t\t       err ? err : allocated);\n\treturn err ? err : allocated;\n}","target":0,"code_token_length":3234,"total_token_length":3470,"max_tokens_setting":4096}
+{"idx":442524,"func":"static void server_stats(ADD_STAT add_stats, conn *c) {\n    pid_t pid = getpid();\n    rel_time_t now = current_time;\n\n    struct thread_stats thread_stats;\n    threadlocal_stats_aggregate(&thread_stats);\n    struct slab_stats slab_stats;\n    slab_stats_aggregate(&thread_stats, &slab_stats);\n#ifdef EXTSTORE\n    struct extstore_stats st;\n#endif\n#ifndef WIN32\n    struct rusage usage;\n    getrusage(RUSAGE_SELF, &usage);\n#endif \/* !WIN32 *\/\n\n    STATS_LOCK();\n\n    APPEND_STAT(\"pid\", \"%lu\", (long)pid);\n    APPEND_STAT(\"uptime\", \"%u\", now - ITEM_UPDATE_INTERVAL);\n    APPEND_STAT(\"time\", \"%ld\", now + (long)process_started);\n    APPEND_STAT(\"version\", \"%s\", VERSION);\n    APPEND_STAT(\"libevent\", \"%s\", event_get_version());\n    APPEND_STAT(\"pointer_size\", \"%d\", (int)(8 * sizeof(void *)));\n\n#ifndef WIN32\n    append_stat(\"rusage_user\", add_stats, c, \"%ld.%06ld\",\n                (long)usage.ru_utime.tv_sec,\n                (long)usage.ru_utime.tv_usec);\n    append_stat(\"rusage_system\", add_stats, c, \"%ld.%06ld\",\n                (long)usage.ru_stime.tv_sec,\n                (long)usage.ru_stime.tv_usec);\n#endif \/* !WIN32 *\/\n\n    APPEND_STAT(\"max_connections\", \"%d\", settings.maxconns);\n    APPEND_STAT(\"curr_connections\", \"%llu\", (unsigned long long)stats_state.curr_conns - 1);\n    APPEND_STAT(\"total_connections\", \"%llu\", (unsigned long long)stats.total_conns);\n    if (settings.maxconns_fast) {\n        APPEND_STAT(\"rejected_connections\", \"%llu\", (unsigned long long)stats.rejected_conns);\n    }\n    APPEND_STAT(\"connection_structures\", \"%u\", stats_state.conn_structs);\n    APPEND_STAT(\"response_obj_bytes\", \"%llu\", (unsigned long long)thread_stats.response_obj_bytes);\n    APPEND_STAT(\"response_obj_total\", \"%llu\", (unsigned long long)thread_stats.response_obj_total);\n    APPEND_STAT(\"response_obj_free\", \"%llu\", (unsigned long long)thread_stats.response_obj_free);\n    APPEND_STAT(\"response_obj_oom\", \"%llu\", (unsigned long long)thread_stats.response_obj_oom);\n    APPEND_STAT(\"read_buf_bytes\", \"%llu\", (unsigned long long)thread_stats.read_buf_bytes);\n    APPEND_STAT(\"read_buf_bytes_free\", \"%llu\", (unsigned long long)thread_stats.read_buf_bytes_free);\n    APPEND_STAT(\"read_buf_oom\", \"%llu\", (unsigned long long)thread_stats.read_buf_oom);\n    APPEND_STAT(\"reserved_fds\", \"%u\", stats_state.reserved_fds);\n    APPEND_STAT(\"cmd_get\", \"%llu\", (unsigned long long)thread_stats.get_cmds);\n    APPEND_STAT(\"cmd_set\", \"%llu\", (unsigned long long)slab_stats.set_cmds);\n    APPEND_STAT(\"cmd_flush\", \"%llu\", (unsigned long long)thread_stats.flush_cmds);\n    APPEND_STAT(\"cmd_touch\", \"%llu\", (unsigned long long)thread_stats.touch_cmds);\n    APPEND_STAT(\"cmd_meta\", \"%llu\", (unsigned long long)thread_stats.meta_cmds);\n    APPEND_STAT(\"get_hits\", \"%llu\", (unsigned long long)slab_stats.get_hits);\n    APPEND_STAT(\"get_misses\", \"%llu\", (unsigned long long)thread_stats.get_misses);\n    APPEND_STAT(\"get_expired\", \"%llu\", (unsigned long long)thread_stats.get_expired);\n    APPEND_STAT(\"get_flushed\", \"%llu\", (unsigned long long)thread_stats.get_flushed);\n#ifdef EXTSTORE\n    if (c->thread->storage) {\n        APPEND_STAT(\"get_extstore\", \"%llu\", (unsigned long long)thread_stats.get_extstore);\n        APPEND_STAT(\"get_aborted_extstore\", \"%llu\", (unsigned long long)thread_stats.get_aborted_extstore);\n        APPEND_STAT(\"get_oom_extstore\", \"%llu\", (unsigned long long)thread_stats.get_oom_extstore);\n        APPEND_STAT(\"recache_from_extstore\", \"%llu\", (unsigned long long)thread_stats.recache_from_extstore);\n        APPEND_STAT(\"miss_from_extstore\", \"%llu\", (unsigned long long)thread_stats.miss_from_extstore);\n        APPEND_STAT(\"badcrc_from_extstore\", \"%llu\", (unsigned long long)thread_stats.badcrc_from_extstore);\n    }\n#endif\n    APPEND_STAT(\"delete_misses\", \"%llu\", (unsigned long long)thread_stats.delete_misses);\n    APPEND_STAT(\"delete_hits\", \"%llu\", (unsigned long long)slab_stats.delete_hits);\n    APPEND_STAT(\"incr_misses\", \"%llu\", (unsigned long long)thread_stats.incr_misses);\n    APPEND_STAT(\"incr_hits\", \"%llu\", (unsigned long long)slab_stats.incr_hits);\n    APPEND_STAT(\"decr_misses\", \"%llu\", (unsigned long long)thread_stats.decr_misses);\n    APPEND_STAT(\"decr_hits\", \"%llu\", (unsigned long long)slab_stats.decr_hits);\n    APPEND_STAT(\"cas_misses\", \"%llu\", (unsigned long long)thread_stats.cas_misses);\n    APPEND_STAT(\"cas_hits\", \"%llu\", (unsigned long long)slab_stats.cas_hits);\n    APPEND_STAT(\"cas_badval\", \"%llu\", (unsigned long long)slab_stats.cas_badval);\n    APPEND_STAT(\"touch_hits\", \"%llu\", (unsigned long long)slab_stats.touch_hits);\n    APPEND_STAT(\"touch_misses\", \"%llu\", (unsigned long long)thread_stats.touch_misses);\n    APPEND_STAT(\"auth_cmds\", \"%llu\", (unsigned long long)thread_stats.auth_cmds);\n    APPEND_STAT(\"auth_errors\", \"%llu\", (unsigned long long)thread_stats.auth_errors);\n    if (settings.idle_timeout) {\n        APPEND_STAT(\"idle_kicks\", \"%llu\", (unsigned long long)thread_stats.idle_kicks);\n    }\n    APPEND_STAT(\"bytes_read\", \"%llu\", (unsigned long long)thread_stats.bytes_read);\n    APPEND_STAT(\"bytes_written\", \"%llu\", (unsigned long long)thread_stats.bytes_written);\n    APPEND_STAT(\"limit_maxbytes\", \"%llu\", (unsigned long long)settings.maxbytes);\n    APPEND_STAT(\"accepting_conns\", \"%u\", stats_state.accepting_conns);\n    APPEND_STAT(\"listen_disabled_num\", \"%llu\", (unsigned long long)stats.listen_disabled_num);\n    APPEND_STAT(\"time_in_listen_disabled_us\", \"%llu\", stats.time_in_listen_disabled_us);\n    APPEND_STAT(\"threads\", \"%d\", settings.num_threads);\n    APPEND_STAT(\"conn_yields\", \"%llu\", (unsigned long long)thread_stats.conn_yields);\n    APPEND_STAT(\"hash_power_level\", \"%u\", stats_state.hash_power_level);\n    APPEND_STAT(\"hash_bytes\", \"%llu\", (unsigned long long)stats_state.hash_bytes);\n    APPEND_STAT(\"hash_is_expanding\", \"%u\", stats_state.hash_is_expanding);\n    if (settings.slab_reassign) {\n        APPEND_STAT(\"slab_reassign_rescues\", \"%llu\", stats.slab_reassign_rescues);\n        APPEND_STAT(\"slab_reassign_chunk_rescues\", \"%llu\", stats.slab_reassign_chunk_rescues);\n        APPEND_STAT(\"slab_reassign_evictions_nomem\", \"%llu\", stats.slab_reassign_evictions_nomem);\n        APPEND_STAT(\"slab_reassign_inline_reclaim\", \"%llu\", stats.slab_reassign_inline_reclaim);\n        APPEND_STAT(\"slab_reassign_busy_items\", \"%llu\", stats.slab_reassign_busy_items);\n        APPEND_STAT(\"slab_reassign_busy_deletes\", \"%llu\", stats.slab_reassign_busy_deletes);\n        APPEND_STAT(\"slab_reassign_running\", \"%u\", stats_state.slab_reassign_running);\n        APPEND_STAT(\"slabs_moved\", \"%llu\", stats.slabs_moved);\n    }\n    if (settings.lru_crawler) {\n        APPEND_STAT(\"lru_crawler_running\", \"%u\", stats_state.lru_crawler_running);\n        APPEND_STAT(\"lru_crawler_starts\", \"%u\", stats.lru_crawler_starts);\n    }\n    if (settings.lru_maintainer_thread) {\n        APPEND_STAT(\"lru_maintainer_juggles\", \"%llu\", (unsigned long long)stats.lru_maintainer_juggles);\n    }\n    APPEND_STAT(\"malloc_fails\", \"%llu\",\n                (unsigned long long)stats.malloc_fails);\n    APPEND_STAT(\"log_worker_dropped\", \"%llu\", (unsigned long long)stats.log_worker_dropped);\n    APPEND_STAT(\"log_worker_written\", \"%llu\", (unsigned long long)stats.log_worker_written);\n    APPEND_STAT(\"log_watcher_skipped\", \"%llu\", (unsigned long long)stats.log_watcher_skipped);\n    APPEND_STAT(\"log_watcher_sent\", \"%llu\", (unsigned long long)stats.log_watcher_sent);\n    STATS_UNLOCK();\n#ifdef EXTSTORE\n    if (c->thread->storage) {\n        STATS_LOCK();\n        APPEND_STAT(\"extstore_compact_lost\", \"%llu\", (unsigned long long)stats.extstore_compact_lost);\n        APPEND_STAT(\"extstore_compact_rescues\", \"%llu\", (unsigned long long)stats.extstore_compact_rescues);\n        APPEND_STAT(\"extstore_compact_skipped\", \"%llu\", (unsigned long long)stats.extstore_compact_skipped);\n        STATS_UNLOCK();\n        extstore_get_stats(c->thread->storage, &st);\n        APPEND_STAT(\"extstore_page_allocs\", \"%llu\", (unsigned long long)st.page_allocs);\n        APPEND_STAT(\"extstore_page_evictions\", \"%llu\", (unsigned long long)st.page_evictions);\n        APPEND_STAT(\"extstore_page_reclaims\", \"%llu\", (unsigned long long)st.page_reclaims);\n        APPEND_STAT(\"extstore_pages_free\", \"%llu\", (unsigned long long)st.pages_free);\n        APPEND_STAT(\"extstore_pages_used\", \"%llu\", (unsigned long long)st.pages_used);\n        APPEND_STAT(\"extstore_objects_evicted\", \"%llu\", (unsigned long long)st.objects_evicted);\n        APPEND_STAT(\"extstore_objects_read\", \"%llu\", (unsigned long long)st.objects_read);\n        APPEND_STAT(\"extstore_objects_written\", \"%llu\", (unsigned long long)st.objects_written);\n        APPEND_STAT(\"extstore_objects_used\", \"%llu\", (unsigned long long)st.objects_used);\n        APPEND_STAT(\"extstore_bytes_evicted\", \"%llu\", (unsigned long long)st.bytes_evicted);\n        APPEND_STAT(\"extstore_bytes_written\", \"%llu\", (unsigned long long)st.bytes_written);\n        APPEND_STAT(\"extstore_bytes_read\", \"%llu\", (unsigned long long)st.bytes_read);\n        APPEND_STAT(\"extstore_bytes_used\", \"%llu\", (unsigned long long)st.bytes_used);\n        APPEND_STAT(\"extstore_bytes_fragmented\", \"%llu\", (unsigned long long)st.bytes_fragmented);\n        APPEND_STAT(\"extstore_limit_maxbytes\", \"%llu\", (unsigned long long)(st.page_count * st.page_size));\n        APPEND_STAT(\"extstore_io_queue\", \"%llu\", (unsigned long long)(st.io_queue));\n    }\n#endif\n#ifdef TLS\n    if (settings.ssl_enabled) {\n        APPEND_STAT(\"ssl_handshake_errors\", \"%llu\", (unsigned long long)stats.ssl_handshake_errors);\n        APPEND_STAT(\"time_since_server_cert_refresh\", \"%u\", now - settings.ssl_last_cert_refresh_time);\n    }\n#endif\n}","target":0,"code_token_length":2518,"total_token_length":2754,"max_tokens_setting":4096}
+{"idx":347556,"func":"static Token *tokenize(char *line)\n{\n    char c, *p = line;\n    enum pp_token_type type;\n    Token *list = NULL;\n    Token *t, **tail = &list;\n\n    while (*line) {\n        p = line;\n        if (*p == '%') {\n            p++;\n            if (*p == '+' && !nasm_isdigit(p[1])) {\n                p++;\n                type = TOK_PASTE;\n            } else if (nasm_isdigit(*p) ||\n                       ((*p == '-' || *p == '+') && nasm_isdigit(p[1]))) {\n                do {\n                    p++;\n                }\n                while (nasm_isdigit(*p));\n                type = TOK_PREPROC_ID;\n            } else if (*p == '{') {\n                p++;\n                while (*p) {\n                    if (*p == '}')\n                        break;\n                    p[-1] = *p;\n                    p++;\n                }\n                if (*p != '}')\n                    nasm_error(ERR_WARNING | ERR_PASS1,\n\t\t\t       \"unterminated %%{ construct\");\n                p[-1] = '\\0';\n                if (*p)\n                    p++;\n                type = TOK_PREPROC_ID;\n            } else if (*p == '[') {\n                int lvl = 1;\n                line += 2;      \/* Skip the leading %[ *\/\n                p++;\n                while (lvl && (c = *p++)) {\n                    switch (c) {\n                    case ']':\n                        lvl--;\n                        break;\n                    case '%':\n                        if (*p == '[')\n                            lvl++;\n                        break;\n                    case '\\'':\n                    case '\\\"':\n                    case '`':\n                        p = nasm_skip_string(p - 1) + 1;\n                        break;\n                    default:\n                        break;\n                    }\n                }\n                p--;\n                if (*p)\n                    *p++ = '\\0';\n                if (lvl)\n                    nasm_error(ERR_NONFATAL|ERR_PASS1,\n\t\t\t       \"unterminated %%[ construct\");\n                type = TOK_INDIRECT;\n            } else if (*p == '?') {\n                type = TOK_PREPROC_Q; \/* %? *\/\n                p++;\n                if (*p == '?') {\n                    type = TOK_PREPROC_QQ; \/* %?? *\/\n                    p++;\n                }\n            } else if (*p == '!') {\n                type = TOK_PREPROC_ID;\n                p++;\n                if (isidchar(*p)) {\n                    do {\n                        p++;\n                    }\n                    while (isidchar(*p));\n                } else if (*p == '\\'' || *p == '\\\"' || *p == '`') {\n                    p = nasm_skip_string(p);\n                    if (*p)\n                        p++;\n                    else\n                        nasm_error(ERR_NONFATAL|ERR_PASS1,\n\t\t\t\t   \"unterminated %%! string\");\n                } else {\n                    \/* %! without string or identifier *\/\n                    type = TOK_OTHER; \/* Legacy behavior... *\/\n                }\n            } else if (isidchar(*p) ||\n                       ((*p == '!' || *p == '%' || *p == '$') &&\n                        isidchar(p[1]))) {\n                do {\n                    p++;\n                }\n                while (isidchar(*p));\n                type = TOK_PREPROC_ID;\n            } else {\n                type = TOK_OTHER;\n                if (*p == '%')\n                    p++;\n            }\n        } else if (isidstart(*p) || (*p == '$' && isidstart(p[1]))) {\n            type = TOK_ID;\n            p++;\n            while (*p && isidchar(*p))\n                p++;\n        } else if (*p == '\\'' || *p == '\"' || *p == '`') {\n            \/*\n             * A string token.\n             *\/\n            type = TOK_STRING;\n            p = nasm_skip_string(p);\n\n            if (*p) {\n                p++;\n            } else {\n                nasm_error(ERR_WARNING|ERR_PASS1, \"unterminated string\");\n                \/* Handling unterminated strings by UNV *\/\n                \/* type = -1; *\/\n            }\n        } else if (p[0] == '$' && p[1] == '$') {\n            type = TOK_OTHER;   \/* TOKEN_BASE *\/\n            p += 2;\n        } else if (isnumstart(*p)) {\n            bool is_hex = false;\n            bool is_float = false;\n            bool has_e = false;\n            char c, *r;\n\n            \/*\n             * A numeric token.\n             *\/\n\n            if (*p == '$') {\n                p++;\n                is_hex = true;\n            }\n\n            for (;;) {\n                c = *p++;\n\n                if (!is_hex && (c == 'e' || c == 'E')) {\n                    has_e = true;\n                    if (*p == '+' || *p == '-') {\n                        \/*\n                         * e can only be followed by +\/- if it is either a\n                         * prefixed hex number or a floating-point number\n                         *\/\n                        p++;\n                        is_float = true;\n                    }\n                } else if (c == 'H' || c == 'h' || c == 'X' || c == 'x') {\n                    is_hex = true;\n                } else if (c == 'P' || c == 'p') {\n                    is_float = true;\n                    if (*p == '+' || *p == '-')\n                        p++;\n                } else if (isnumchar(c))\n                    ; \/* just advance *\/\n                else if (c == '.') {\n                    \/*\n                     * we need to deal with consequences of the legacy\n                     * parser, like \"1.nolist\" being two tokens\n                     * (TOK_NUMBER, TOK_ID) here; at least give it\n                     * a shot for now.  In the future, we probably need\n                     * a flex-based scanner with proper pattern matching\n                     * to do it as well as it can be done.  Nothing in\n                     * the world is going to help the person who wants\n                     * 0x123.p16 interpreted as two tokens, though.\n                     *\/\n                    r = p;\n                    while (*r == '_')\n                        r++;\n\n                    if (nasm_isdigit(*r) || (is_hex && nasm_isxdigit(*r)) ||\n                        (!is_hex && (*r == 'e' || *r == 'E')) ||\n                        (*r == 'p' || *r == 'P')) {\n                        p = r;\n                        is_float = true;\n                    } else\n                        break;  \/* Terminate the token *\/\n                } else\n                    break;\n            }\n            p--;        \/* Point to first character beyond number *\/\n\n            if (p == line+1 && *line == '$') {\n                type = TOK_OTHER; \/* TOKEN_HERE *\/\n            } else {\n                if (has_e && !is_hex) {\n                    \/* 1e13 is floating-point, but 1e13h is not *\/\n                    is_float = true;\n                }\n\n                type = is_float ? TOK_FLOAT : TOK_NUMBER;\n            }\n        } else if (nasm_isspace(*p)) {\n            type = TOK_WHITESPACE;\n            p = nasm_skip_spaces(p);\n            \/*\n             * Whitespace just before end-of-line is discarded by\n             * pretending it's a comment; whitespace just before a\n             * comment gets lumped into the comment.\n             *\/\n            if (!*p || *p == ';') {\n                type = TOK_COMMENT;\n                while (*p)\n                    p++;\n            }\n        } else if (*p == ';') {\n            type = TOK_COMMENT;\n            while (*p)\n                p++;\n        } else {\n            \/*\n             * Anything else is an operator of some kind. We check\n             * for all the double-character operators (>>, <<, \/\/,\n             * %%, <=, >=, ==, !=, <>, &&, ||, ^^), but anything\n             * else is a single-character operator.\n             *\/\n            type = TOK_OTHER;\n            if ((p[0] == '>' && p[1] == '>') ||\n                (p[0] == '<' && p[1] == '<') ||\n                (p[0] == '\/' && p[1] == '\/') ||\n                (p[0] == '<' && p[1] == '=') ||\n                (p[0] == '>' && p[1] == '=') ||\n                (p[0] == '=' && p[1] == '=') ||\n                (p[0] == '!' && p[1] == '=') ||\n                (p[0] == '<' && p[1] == '>') ||\n                (p[0] == '&' && p[1] == '&') ||\n                (p[0] == '|' && p[1] == '|') ||\n                (p[0] == '^' && p[1] == '^')) {\n                p++;\n            }\n            p++;\n        }\n\n        \/* Handling unterminated string by UNV *\/\n        \/*if (type == -1)\n          {\n          *tail = t = new_Token(NULL, TOK_STRING, line, p-line+1);\n          t->text[p-line] = *line;\n          tail = &t->next;\n          }\n          else *\/\n        if (type != TOK_COMMENT) {\n            *tail = t = new_Token(NULL, type, line, p - line);\n            tail = &t->next;\n        }\n        line = p;\n    }\n    return list;\n}","target":1,"code_token_length":1961,"total_token_length":2197,"max_tokens_setting":4096}
+{"idx":350820,"func":"read_yin_list(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,\n              struct unres_schema *unres)\n{\n    struct ly_ctx *ctx = module->ctx;\n    struct lys_node *retval, *node;\n    struct lys_node_list *list;\n    struct lyxml_elem *sub, *next, root, uniq;\n    int r;\n    int c_tpdf = 0, c_must = 0, c_uniq = 0, c_ftrs = 0, c_ext = 0;\n    int f_ordr = 0, f_max = 0, f_min = 0;\n    const char *value;\n    char *auxs;\n    unsigned long val;\n    void *reallocated;\n\n    \/* init *\/\n    memset(&root, 0, sizeof root);\n    memset(&uniq, 0, sizeof uniq);\n\n    list = calloc(1, sizeof *list);\n    LY_CHECK_ERR_RETURN(!list, LOGMEM(ctx), NULL);\n\n    list->nodetype = LYS_LIST;\n    list->prev = (struct lys_node *)list;\n    retval = (struct lys_node *)list;\n\n    if (read_yin_common(module, parent, retval, LYEXT_PAR_NODE, yin,\n            OPT_IDENT | OPT_MODULE | ((options & LYS_PARSE_OPT_CFG_IGNORE) ? OPT_CFG_IGNORE :\n                (options & LYS_PARSE_OPT_CFG_NOINHERIT) ? OPT_CFG_PARSE : OPT_CFG_PARSE | OPT_CFG_INHERIT),\n            unres)) {\n        goto error;\n    }\n\n    LOGDBG(LY_LDGYIN, \"parsing %s statement \\\"%s\\\"\", yin->name, retval->name);\n\n    \/* insert the node into the schema tree *\/\n    if (lys_node_addchild(parent, lys_main_module(module), retval, options)) {\n        goto error;\n    }\n\n    \/* process list's specific children *\/\n    LY_TREE_FOR_SAFE(yin->child, next, sub) {\n        if (strcmp(sub->ns->value, LY_NSYIN)) {\n            \/* extension *\/\n            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, \"extensions\", \"list\", error);\n            c_ext++;\n            continue;\n\n        \/* data statements *\/\n        } else if (!strcmp(sub->name, \"container\") ||\n                !strcmp(sub->name, \"leaf-list\") ||\n                !strcmp(sub->name, \"leaf\") ||\n                !strcmp(sub->name, \"list\") ||\n                !strcmp(sub->name, \"choice\") ||\n                !strcmp(sub->name, \"uses\") ||\n                !strcmp(sub->name, \"grouping\") ||\n                !strcmp(sub->name, \"anyxml\") ||\n                !strcmp(sub->name, \"anydata\") ||\n                !strcmp(sub->name, \"action\") ||\n                !strcmp(sub->name, \"notification\")) {\n            lyxml_unlink_elem(ctx, sub, 2);\n            lyxml_add_child(ctx, &root, sub);\n\n            \/* array counters *\/\n        } else if (!strcmp(sub->name, \"key\")) {\n            \/* check cardinality 0..1 *\/\n            if (list->keys_size) {\n                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, list->name);\n                goto error;\n            }\n\n            \/* count the number of keys *\/\n            GETVAL(ctx, value, sub, \"value\");\n            list->keys_str = lydict_insert(ctx, value, 0);\n            while ((value = strpbrk(value, \" \\t\\n\"))) {\n                list->keys_size++;\n                while (isspace(*value)) {\n                    value++;\n                }\n            }\n            list->keys_size++;\n            list->keys = calloc(list->keys_size, sizeof *list->keys);\n            LY_CHECK_ERR_GOTO(!list->keys, LOGMEM(ctx), error);\n\n            if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_KEY, 0, unres)) {\n                goto error;\n            }\n            lyxml_free(ctx, sub);\n        } else if (!strcmp(sub->name, \"unique\")) {\n            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_uniq, list->unique_size, \"uniques\", \"list\", error);\n            c_uniq++;\n            lyxml_unlink_elem(ctx, sub, 2);\n            lyxml_add_child(ctx, &uniq, sub);\n        } else if (!strcmp(sub->name, \"typedef\")) {\n            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, list->tpdf_size, \"typedefs\", \"list\", error);\n            c_tpdf++;\n        } else if (!strcmp(sub->name, \"must\")) {\n            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, list->must_size, \"musts\", \"list\", error);\n            c_must++;\n        } else if (!strcmp(sub->name, \"if-feature\")) {\n            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, \"if-features\", \"list\", error);\n            c_ftrs++;\n\n            \/* optional stetments *\/\n        } else if (!strcmp(sub->name, \"ordered-by\")) {\n            if (f_ordr) {\n                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);\n                goto error;\n            }\n            \/* just checking the flags in llist is not sufficient, we would\n             * allow multiple ordered-by statements with the \"system\" value\n             *\/\n            f_ordr = 1;\n\n            if (list->flags & LYS_CONFIG_R) {\n                \/* RFC 6020, 7.7.5 - ignore ordering when the list represents\n                 * state data\n                 *\/\n                lyxml_free(ctx, sub);\n                continue;\n            }\n\n            GETVAL(ctx, value, sub, \"value\");\n            if (!strcmp(value, \"user\")) {\n                list->flags |= LYS_USERORDERED;\n            } else if (strcmp(value, \"system\")) {\n                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);\n                goto error;\n            } \/* else system is the default value, so we can ignore it *\/\n\n            if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_ORDEREDBY, 0, unres)) {\n                goto error;\n            }\n            lyxml_free(ctx, sub);\n        } else if (!strcmp(sub->name, \"min-elements\")) {\n            if (f_min) {\n                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);\n                goto error;\n            }\n            f_min = 1;\n\n            GETVAL(ctx, value, sub, \"value\");\n            while (isspace(value[0])) {\n                value++;\n            }\n\n            \/* convert it to uint32_t *\/\n            errno = 0;\n            auxs = NULL;\n            val = strtoul(value, &auxs, 10);\n            if (*auxs || value[0] == '-' || errno || val > UINT32_MAX) {\n                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);\n                goto error;\n            }\n            list->min = (uint32_t) val;\n            if (list->max && (list->min > list->max)) {\n                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);\n                LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, \"\\\"min-elements\\\" is bigger than \\\"max-elements\\\".\");\n                lyxml_free(ctx, sub);\n                goto error;\n            }\n            if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_MIN, 0, unres)) {\n                goto error;\n            }\n            lyxml_free(ctx, sub);\n        } else if (!strcmp(sub->name, \"max-elements\")) {\n            if (f_max) {\n                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);\n                goto error;\n            }\n            f_max = 1;\n\n            GETVAL(ctx, value, sub, \"value\");\n            while (isspace(value[0])) {\n                value++;\n            }\n\n            if (!strcmp(value, \"unbounded\")) {\n                list->max = 0;;\n            } else {\n                \/* convert it to uint32_t *\/\n                errno = 0;\n                auxs = NULL;\n                val = strtoul(value, &auxs, 10);\n                if (*auxs || value[0] == '-' || errno || val == 0 || val > UINT32_MAX) {\n                    LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);\n                    goto error;\n                }\n                list->max = (uint32_t) val;\n                if (list->min > list->max) {\n                    LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);\n                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, \"\\\"max-elements\\\" is smaller than \\\"min-elements\\\".\");\n                    goto error;\n                }\n            }\n            if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_MAX, 0, unres)) {\n                goto error;\n            }\n            lyxml_free(ctx, sub);\n        } else if (!strcmp(sub->name, \"when\")) {\n            if (list->when) {\n                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);\n                goto error;\n            }\n\n            list->when = read_yin_when(module, sub, unres);\n            if (!list->when) {\n                lyxml_free(ctx, sub);\n                goto error;\n            }\n            lyxml_free(ctx, sub);\n        } else {\n            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);\n            goto error;\n        }\n    }\n\n    \/* check - if list is configuration, key statement is mandatory\n     * (but only if we are not in a grouping or augment, then the check is deferred) *\/\n    for (node = retval; node && !(node->nodetype & (LYS_GROUPING | LYS_AUGMENT | LYS_EXT)); node = node->parent);\n    if (!node && (list->flags & LYS_CONFIG_W) && !list->keys_str) {\n        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, \"key\", \"list\");\n        goto error;\n    }\n\n    \/* middle part - process nodes with cardinality of 0..n except the data nodes *\/\n    if (c_tpdf) {\n        list->tpdf = calloc(c_tpdf, sizeof *list->tpdf);\n        LY_CHECK_ERR_GOTO(!list->tpdf, LOGMEM(ctx), error);\n    }\n    if (c_must) {\n        list->must = calloc(c_must, sizeof *list->must);\n        LY_CHECK_ERR_GOTO(!list->must, LOGMEM(ctx), error);\n    }\n    if (c_ftrs) {\n        list->iffeature = calloc(c_ftrs, sizeof *list->iffeature);\n        LY_CHECK_ERR_GOTO(!list->iffeature, LOGMEM(ctx), error);\n    }\n    if (c_ext) {\n        \/* some extensions may be already present from the substatements *\/\n        reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);\n        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);\n        retval->ext = reallocated;\n\n        \/* init memory *\/\n        memset(&retval->ext[retval->ext_size], 0, c_ext * sizeof *retval->ext);\n    }\n\n    LY_TREE_FOR_SAFE(yin->child, next, sub) {\n        if (strcmp(sub->ns->value, LY_NSYIN)) {\n            \/* extension *\/\n            r = lyp_yin_fill_ext(retval, LYEXT_PAR_NODE, 0, 0, module, sub, &retval->ext, &retval->ext_size, unres);\n            if (r) {\n                goto error;\n            }\n        } else if (!strcmp(sub->name, \"typedef\")) {\n            r = fill_yin_typedef(module, retval, sub, &list->tpdf[list->tpdf_size], unres);\n            list->tpdf_size++;\n            if (r) {\n                goto error;\n            }\n        } else if (!strcmp(sub->name, \"if-feature\")) {\n            r = fill_yin_iffeature(retval, 0, sub, &list->iffeature[list->iffeature_size], unres);\n            list->iffeature_size++;\n            if (r) {\n                goto error;\n            }\n        } else if (!strcmp(sub->name, \"must\")) {\n            r = fill_yin_must(module, sub, &list->must[list->must_size], unres);\n            list->must_size++;\n            if (r) {\n                goto error;\n            }\n        }\n    }\n\n    lyp_reduce_ext_list(&retval->ext, retval->ext_size, c_ext + retval->ext_size);\n\n    \/* last part - process data nodes *\/\n    LY_TREE_FOR_SAFE(root.child, next, sub) {\n        if (!strcmp(sub->name, \"container\")) {\n            node = read_yin_container(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"leaf-list\")) {\n            node = read_yin_leaflist(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"leaf\")) {\n            node = read_yin_leaf(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"list\")) {\n            node = read_yin_list(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"choice\")) {\n            node = read_yin_choice(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"uses\")) {\n            node = read_yin_uses(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"grouping\")) {\n            node = read_yin_grouping(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"anyxml\")) {\n            node = read_yin_anydata(module, retval, sub, LYS_ANYXML, options, unres);\n        } else if (!strcmp(sub->name, \"anydata\")) {\n            node = read_yin_anydata(module, retval, sub, LYS_ANYDATA, options, unres);\n        } else if (!strcmp(sub->name, \"action\")) {\n            node = read_yin_rpc_action(module, retval, sub, options, unres);\n        } else if (!strcmp(sub->name, \"notification\")) {\n            node = read_yin_notif(module, retval, sub, options, unres);\n        } else {\n            LOGINT(ctx);\n            goto error;\n        }\n        if (!node) {\n            goto error;\n        }\n\n        lyxml_free(ctx, sub);\n    }\n\n    if (list->keys_str) {\n        if (unres_schema_add_node(module, unres, list, UNRES_LIST_KEYS, NULL) == -1) {\n            goto error;\n        }\n    } \/* else config false list without a key, key_str presence in case of config true is checked earlier *\/\n\n    \/* process unique statements *\/\n    if (c_uniq) {\n        list->unique = calloc(c_uniq, sizeof *list->unique);\n        LY_CHECK_ERR_GOTO(!list->unique, LOGMEM(ctx), error);\n\n        LY_TREE_FOR_SAFE(uniq.child, next, sub) {\n            r = fill_yin_unique(module, retval, sub, &list->unique[list->unique_size], unres);\n            list->unique_size++;\n            if (r) {\n                goto error;\n            }\n\n            if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub,\n                                     LYEXT_SUBSTMT_UNIQUE, list->unique_size - 1, unres)) {\n                goto error;\n            }\n            lyxml_free(ctx, sub);\n        }\n    }\n\n    \/* check XPath dependencies *\/\n    if (!(ctx->models.flags & LY_CTX_TRUSTED) && (list->when || list->must)) {\n        if (options & LYS_PARSE_OPT_INGRP) {\n            if (lyxp_node_check_syntax(retval)) {\n                goto error;\n            }\n        } else {\n            if (unres_schema_add_node(module, unres, retval, UNRES_XPATH, NULL) == -1) {\n                goto error;\n            }\n        }\n    }\n\n    for (r = 0; r < retval->ext_size; ++r) {\n        \/* set flag, which represent LYEXT_OPT_VALID *\/\n        if (retval->ext[r]->flags & LYEXT_OPT_VALID) {\n            retval->flags |= LYS_VALID_EXT;\n            if (retval->ext[r]->flags & LYEXT_OPT_VALID_SUBTREE) {\n                retval->flags |= LYS_VALID_EXT_SUBTREE;\n                break;\n            }\n        }\n    }\n\n    return retval;\n\nerror:\n\n    lys_node_free(ctx, retval, NULL, 0);\n    while (root.child) {\n        lyxml_free(ctx, root.child);\n    }\n    while (uniq.child) {\n        lyxml_free(ctx, uniq.child);\n    }\n\n    return NULL;\n}","target":1,"code_token_length":3782,"total_token_length":4018,"max_tokens_setting":4096}
+{"idx":291336,"func":"off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)\n{\n    off_t flen = super::pack3(fo, ft);  \/\/ loader follows compressed PT_LOADs\n    \/\/ NOTE: PackLinuxElf::pack3  adjusted xct_off for the extra page\n\n    unsigned v_hole = sz_pack2 + lsize;\n    set_te64(&elfout.phdr[C_TEXT].p_filesz, v_hole);\n    set_te64(&elfout.phdr[C_TEXT].p_memsz,  v_hole);\n    \/\/ Then compressed gaps (including debuginfo.)\n    for (unsigned k = 0; k < e_phnum; ++k) {\n        Extent x;\n        x.size = find_LOAD_gap(phdri, k, e_phnum);\n        if (x.size) {\n            x.offset = get_te64(&phdri[k].p_offset) +\n                       get_te64(&phdri[k].p_filesz);\n            packExtent(x, nullptr, fo);\n        }\n    }\n    \/\/ write block end marker (uncompressed size 0)\n    b_info hdr; memset(&hdr, 0, sizeof(hdr));\n    set_le32(&hdr.sz_cpr, UPX_MAGIC_LE32);\n    fo->write(&hdr, sizeof(hdr));\n    flen = fpad4(fo);\n\n    set_te64(&elfout.phdr[C_TEXT].p_filesz, sz_pack2 + lsize);\n    set_te64(&elfout.phdr[C_TEXT].p_memsz,  sz_pack2 + lsize);\n    if (0==xct_off) { \/\/ not shared library\n        set_te64(&elfout.phdr[C_BASE].p_align, ((upx_uint64_t)0) - page_mask);\n        elfout.phdr[C_BASE].p_paddr = elfout.phdr[C_BASE].p_vaddr;\n        elfout.phdr[C_BASE].p_offset = 0;\n        upx_uint64_t abrk = getbrk(phdri, e_phnum);\n        \/\/ vbase handles ET_EXEC.  FIXME: pre-linking?\n        upx_uint64_t const vbase = get_te64(&elfout.phdr[C_BASE].p_vaddr);\n        set_te64(&elfout.phdr[C_BASE].p_filesz, 0x1000);  \/\/ Linux kernel SIGSEGV if (0==.p_filesz)\n        set_te64(&elfout.phdr[C_BASE].p_memsz, abrk - vbase);\n        set_te32(&elfout.phdr[C_BASE].p_flags, Elf32_Phdr::PF_W|Elf32_Phdr::PF_R);\n        set_te64(&elfout.phdr[C_TEXT].p_vaddr, abrk= (page_mask & (~page_mask + abrk)));\n        elfout.phdr[C_TEXT].p_paddr = elfout.phdr[C_TEXT].p_vaddr;\n        set_te64(&elfout.ehdr.e_entry, abrk + get_te64(&elfout.ehdr.e_entry) - vbase);\n    }\n    if (0!=xct_off) {  \/\/ shared library\n        upx_uint64_t word = load_va + sz_pack2;\n        set_te64(&file_image[user_init_off], word);  \/\/ set the hook\n\n        Elf64_Phdr *phdr = (Elf64_Phdr *)lowmem.subref(\n                \"bad e_phoff\", e_phoff, e_phnum * sizeof(Elf64_Phdr));\n        unsigned off = fo->st_size();\n        so_slide = 0;\n        for (unsigned j = 0; j < e_phnum; ++j, ++phdr) {\n            upx_uint64_t const len  = get_te64(&phdr->p_filesz);\n            upx_uint64_t const ioff = get_te64(&phdri[j].p_offset);\n            upx_uint64_t       align= get_te64(&phdr->p_align);\n            unsigned const type = get_te32(&phdr->p_type);\n            if (Elf64_Phdr::PT_INTERP==type) {\n                \/\/ Rotate to highest position, so it can be lopped\n                \/\/ by decrementing e_phnum.\n                memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr));  \/\/ extract\n                memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr));  \/\/ overlapping\n                memcpy(&phdr[e_phnum - (1+ j)], (unsigned char *)ibuf, sizeof(*phdr));  \/\/ to top\n                --phdr; --e_phnum;\n                set_te16(&ehdri.e_phnum, e_phnum);\n                set_te16(&((Elf64_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);\n                continue;\n            }\n            if (PT_LOAD64 == type) {\n                if ((xct_off - ioff) < len) { \/\/ Change length of compressed PT_LOAD.\n                    set_te64(&phdr->p_filesz, sz_pack2 + lsize - ioff);\n                    set_te64(&phdr->p_memsz,  sz_pack2 + lsize - ioff);\n                    if (user_init_off < xct_off) { \/\/ MIPS puts PT_DYNAMIC here\n                        \/\/ Allow for DT_INIT in a new [stolen] slot\n                        unsigned off2 = user_init_off - sizeof(word);\n                        fo->seek(off2, SEEK_SET);\n                        fo->rewrite(&file_image[off2], 2*sizeof(word));\n                    }\n                }\n                else if (xct_off < ioff) {  \/\/ Slide subsequent PT_LOAD.\n                    \/\/ AMD64 chip supports page sizes of 4KiB, 2MiB, and 1GiB;\n                    \/\/ the operating system chooses one.  .p_align typically\n                    \/\/ is a forward-looking 2MiB.  In 2009 Linux chooses 4KiB.\n                    \/\/ We choose 4KiB to waste less space.  If Linux chooses\n                    \/\/ 2MiB later, then our output will not run.\n                    if ((1u<<12) < align\n                    &&  Elf64_Ehdr::EM_X86_64 ==e_machine\n                    ) {\n                        align = 1u<<12;\n                        set_te64(&phdr->p_align, align);\n                    }\n                    off += (align-1) & (ioff - off);\n                    set_te64(&phdr->p_offset, off);\n                    so_slide = off - ioff;\n                    fo->seek(  off, SEEK_SET);\n                    fo->write(&file_image[ioff], len);\n                    off += len;\n                }\n                continue;  \/\/ all done with this PT_LOAD\n            }\n            if (xct_off < ioff)\n                set_te64(&phdr->p_offset, so_slide + ioff);\n        }  \/\/ end each Phdr\n\n        if (opt->o_unix.android_shlib) {\n            \/\/ Update {DYNAMIC}.sh_offset by so_slide.\n            Elf64_Shdr *shdr = (Elf64_Shdr *)lowmem.subref(\n                    \"bad e_shoff\", xct_off - asl_delta, e_shnum * sizeof(Elf64_Shdr));\n            for (unsigned j = 0; j < e_shnum; ++shdr, ++j) {\n                unsigned sh_type = get_te32(&shdr->sh_type);\n                if (Elf64_Shdr::SHT_DYNAMIC == sh_type) {\n                    upx_uint64_t offset = get_te64(&shdr->sh_offset);\n                    set_te64(&shdr->sh_offset, so_slide + offset);\n                    fo->seek((j * sizeof(Elf64_Shdr)) + xct_off - asl_delta, SEEK_SET);\n                    fo->rewrite(shdr, sizeof(*shdr));\n                    fo->seek(0, SEEK_END);\n                }\n                if (Elf64_Shdr::SHT_RELA == sh_type\n                &&  n_jmp_slot\n                &&  !strcmp(\".rela.plt\", get_te32(&shdr->sh_name) + shstrtab)) {\n                    upx_uint64_t f_off = elf_get_offset_from_address(plt_off);\n                    fo->seek(so_slide + f_off, SEEK_SET);  \/\/ FIXME: assumes PT_LOAD[1]\n                    fo->rewrite(&file_image[f_off], n_jmp_slot * 8);\n                }\n            }\n        }\n        else { \/\/ !opt->o_unix.android_shlib)\n            ehdri.e_shnum = 0;\n            ehdri.e_shoff = 0;\n            ehdri.e_shstrndx = 0;\n        }\n    }\n    return flen;\n}","target":0,"code_token_length":1922,"total_token_length":2158,"max_tokens_setting":4096}
+{"idx":332384,"func":"void helper_rsm(CPUX86State *env)\n{\n    X86CPU *cpu = x86_env_get_cpu(env);\n    CPUState *cs = CPU(cpu);\n    target_ulong sm_state;\n    int i, offset;\n    uint32_t val;\n    sm_state = env->smbase + 0x8000;\n#ifdef TARGET_X86_64\n    cpu_load_efer(env, x86_ldq_phys(cs, sm_state + 0x7ed0));\n    env->gdt.base = x86_ldq_phys(cs, sm_state + 0x7e68);\n    env->gdt.limit = x86_ldl_phys(cs, sm_state + 0x7e64);\n    env->ldt.selector = x86_lduw_phys(cs, sm_state + 0x7e70);\n    env->ldt.base = x86_ldq_phys(cs, sm_state + 0x7e78);\n    env->ldt.limit = x86_ldl_phys(cs, sm_state + 0x7e74);\n    env->ldt.flags = (x86_lduw_phys(cs, sm_state + 0x7e72) & 0xf0ff) << 8;\n    env->idt.base = x86_ldq_phys(cs, sm_state + 0x7e88);\n    env->idt.limit = x86_ldl_phys(cs, sm_state + 0x7e84);\n    env->tr.selector = x86_lduw_phys(cs, sm_state + 0x7e90);\n    env->tr.base = x86_ldq_phys(cs, sm_state + 0x7e98);\n    env->tr.limit = x86_ldl_phys(cs, sm_state + 0x7e94);\n    env->tr.flags = (x86_lduw_phys(cs, sm_state + 0x7e92) & 0xf0ff) << 8;\n    env->regs[R_EAX] = x86_ldq_phys(cs, sm_state + 0x7ff8);\n    env->regs[R_ECX] = x86_ldq_phys(cs, sm_state + 0x7ff0);\n    env->regs[R_EDX] = x86_ldq_phys(cs, sm_state + 0x7fe8);\n    env->regs[R_EBX] = x86_ldq_phys(cs, sm_state + 0x7fe0);\n    env->regs[R_ESP] = x86_ldq_phys(cs, sm_state + 0x7fd8);\n    env->regs[R_EBP] = x86_ldq_phys(cs, sm_state + 0x7fd0);\n    env->regs[R_ESI] = x86_ldq_phys(cs, sm_state + 0x7fc8);\n    env->regs[R_EDI] = x86_ldq_phys(cs, sm_state + 0x7fc0);\n    for (i = 8; i < 16; i++) {\n        env->regs[i] = x86_ldq_phys(cs, sm_state + 0x7ff8 - i * 8);\n    }\n    env->eip = x86_ldq_phys(cs, sm_state + 0x7f78);\n    cpu_load_eflags(env, x86_ldl_phys(cs, sm_state + 0x7f70),\n                    ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK));\n    env->dr[6] = x86_ldl_phys(cs, sm_state + 0x7f68);\n    env->dr[7] = x86_ldl_phys(cs, sm_state + 0x7f60);\n    cpu_x86_update_cr4(env, x86_ldl_phys(cs, sm_state + 0x7f48));\n    cpu_x86_update_cr3(env, x86_ldq_phys(cs, sm_state + 0x7f50));\n    cpu_x86_update_cr0(env, x86_ldl_phys(cs, sm_state + 0x7f58));\n    for (i = 0; i < 6; i++) {\n        offset = 0x7e00 + i * 16;\n        cpu_x86_load_seg_cache(env, i,\n                               x86_lduw_phys(cs, sm_state + offset),\n                               x86_ldq_phys(cs, sm_state + offset + 8),\n                               x86_ldl_phys(cs, sm_state + offset + 4),\n                               (x86_lduw_phys(cs, sm_state + offset + 2) &\n                                0xf0ff) << 8);\n    }\n    val = x86_ldl_phys(cs, sm_state + 0x7efc); \/* revision ID *\/\n    if (val & 0x20000) {\n        env->smbase = x86_ldl_phys(cs, sm_state + 0x7f00);\n    }\n#else\n    cpu_x86_update_cr0(env, x86_ldl_phys(cs, sm_state + 0x7ffc));\n    cpu_x86_update_cr3(env, x86_ldl_phys(cs, sm_state + 0x7ff8));\n    cpu_load_eflags(env, x86_ldl_phys(cs, sm_state + 0x7ff4),\n                    ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK));\n    env->eip = x86_ldl_phys(cs, sm_state + 0x7ff0);\n    env->regs[R_EDI] = x86_ldl_phys(cs, sm_state + 0x7fec);\n    env->regs[R_ESI] = x86_ldl_phys(cs, sm_state + 0x7fe8);\n    env->regs[R_EBP] = x86_ldl_phys(cs, sm_state + 0x7fe4);\n    env->regs[R_ESP] = x86_ldl_phys(cs, sm_state + 0x7fe0);\n    env->regs[R_EBX] = x86_ldl_phys(cs, sm_state + 0x7fdc);\n    env->regs[R_EDX] = x86_ldl_phys(cs, sm_state + 0x7fd8);\n    env->regs[R_ECX] = x86_ldl_phys(cs, sm_state + 0x7fd4);\n    env->regs[R_EAX] = x86_ldl_phys(cs, sm_state + 0x7fd0);\n    env->dr[6] = x86_ldl_phys(cs, sm_state + 0x7fcc);\n    env->dr[7] = x86_ldl_phys(cs, sm_state + 0x7fc8);\n    env->tr.selector = x86_ldl_phys(cs, sm_state + 0x7fc4) & 0xffff;\n    env->tr.base = x86_ldl_phys(cs, sm_state + 0x7f64);\n    env->tr.limit = x86_ldl_phys(cs, sm_state + 0x7f60);\n    env->tr.flags = (x86_ldl_phys(cs, sm_state + 0x7f5c) & 0xf0ff) << 8;\n    env->ldt.selector = x86_ldl_phys(cs, sm_state + 0x7fc0) & 0xffff;\n    env->ldt.base = x86_ldl_phys(cs, sm_state + 0x7f80);\n    env->ldt.limit = x86_ldl_phys(cs, sm_state + 0x7f7c);\n    env->ldt.flags = (x86_ldl_phys(cs, sm_state + 0x7f78) & 0xf0ff) << 8;\n    env->gdt.base = x86_ldl_phys(cs, sm_state + 0x7f74);\n    env->gdt.limit = x86_ldl_phys(cs, sm_state + 0x7f70);\n    env->idt.base = x86_ldl_phys(cs, sm_state + 0x7f58);\n    env->idt.limit = x86_ldl_phys(cs, sm_state + 0x7f54);\n    for (i = 0; i < 6; i++) {\n        if (i < 3) {\n            offset = 0x7f84 + i * 12;\n        } else {\n            offset = 0x7f2c + (i - 3) * 12;\n        }\n        cpu_x86_load_seg_cache(env, i,\n                               x86_ldl_phys(cs,\n                                        sm_state + 0x7fa8 + i * 4) & 0xffff,\n                               x86_ldl_phys(cs, sm_state + offset + 8),\n                               x86_ldl_phys(cs, sm_state + offset + 4),\n                               (x86_ldl_phys(cs,\n                                         sm_state + offset) & 0xf0ff) << 8);\n    }\n    cpu_x86_update_cr4(env, x86_ldl_phys(cs, sm_state + 0x7f14));\n    val = x86_ldl_phys(cs, sm_state + 0x7efc); \/* revision ID *\/\n    if (val & 0x20000) {\n        env->smbase = x86_ldl_phys(cs, sm_state + 0x7ef8);\n    }\n#endif\n    if ((env->hflags2 & HF2_SMM_INSIDE_NMI_MASK) == 0) {\n        env->hflags2 &= ~HF2_NMI_MASK;\n    }\n    env->hflags2 &= ~HF2_SMM_INSIDE_NMI_MASK;\n    env->hflags &= ~HF_SMM_MASK;\n    cpu_smm_update(cpu);\n    qemu_log_mask(CPU_LOG_INT, \"SMM: after RSM\\n\");\n    log_cpu_state_mask(CPU_LOG_INT, CPU(cpu), CPU_DUMP_CCOP);\n}","target":1,"code_token_length":2236,"total_token_length":2472,"max_tokens_setting":4096}
+{"idx":300662,"func":"void CjfifDecode::AddHeader(unsigned nCode)\r\n{\r\n\tCString strTmp;\r\n\r\n\tswitch(nCode)\r\n\t{\r\n\tcase JFIF_SOI: m_pLog->AddLineHdr(_T(\"*** Marker: SOI (xFFD8) ***\")); break;\r\n\r\n\tcase JFIF_APP0: m_pLog->AddLineHdr(_T(\"*** Marker: APP0 (xFFE0) ***\")); break;\r\n\tcase JFIF_APP1: m_pLog->AddLineHdr(_T(\"*** Marker: APP1 (xFFE1) ***\")); break;\r\n\tcase JFIF_APP2: m_pLog->AddLineHdr(_T(\"*** Marker: APP2 (xFFE2) ***\")); break;\r\n\tcase JFIF_APP3: m_pLog->AddLineHdr(_T(\"*** Marker: APP3 (xFFE3) ***\")); break;\r\n\tcase JFIF_APP4: m_pLog->AddLineHdr(_T(\"*** Marker: APP4 (xFFE4) ***\")); break;\r\n\tcase JFIF_APP5: m_pLog->AddLineHdr(_T(\"*** Marker: APP5 (xFFE5) ***\")); break;\r\n\tcase JFIF_APP6: m_pLog->AddLineHdr(_T(\"*** Marker: APP6 (xFFE6) ***\")); break;\r\n\tcase JFIF_APP7: m_pLog->AddLineHdr(_T(\"*** Marker: APP7 (xFFE7) ***\")); break;\r\n\tcase JFIF_APP8: m_pLog->AddLineHdr(_T(\"*** Marker: APP8 (xFFE8) ***\")); break;\r\n\tcase JFIF_APP9: m_pLog->AddLineHdr(_T(\"*** Marker: APP9 (xFFE9) ***\")); break;\r\n\tcase JFIF_APP10: m_pLog->AddLineHdr(_T(\"*** Marker: APP10 (xFFEA) ***\")); break;\r\n\tcase JFIF_APP11: m_pLog->AddLineHdr(_T(\"*** Marker: APP11 (xFFEB) ***\")); break;\r\n\tcase JFIF_APP12: m_pLog->AddLineHdr(_T(\"*** Marker: APP12 (xFFEC) ***\")); break;\r\n\tcase JFIF_APP13: m_pLog->AddLineHdr(_T(\"*** Marker: APP13 (xFFED) ***\")); break;\r\n\tcase JFIF_APP14: m_pLog->AddLineHdr(_T(\"*** Marker: APP14 (xFFEE) ***\")); break;\r\n\tcase JFIF_APP15: m_pLog->AddLineHdr(_T(\"*** Marker: APP15 (xFFEF) ***\")); break;\r\n\r\n\tcase JFIF_SOF0:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF0 (Baseline DCT) (xFFC0) ***\")); break;\r\n\tcase JFIF_SOF1:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF1 (Extended Sequential DCT, Huffman) (xFFC1) ***\")); break;\r\n\tcase JFIF_SOF2:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF2 (Progressive DCT, Huffman) (xFFC2) ***\")); break;\r\n\tcase JFIF_SOF3:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF3 (Lossless Process, Huffman) (xFFC3) ***\")); break;\r\n\tcase JFIF_SOF5:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF5 (Differential Sequential DCT, Huffman) (xFFC4) ***\")); break;\r\n\tcase JFIF_SOF6:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF6 (Differential Progressive DCT, Huffman) (xFFC5) ***\")); break;\r\n\tcase JFIF_SOF7:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF7 (Differential Lossless Process, Huffman) (xFFC6) ***\")); break;\r\n\tcase JFIF_SOF9:  m_pLog->AddLineHdr(_T(\"*** Marker: SOF9 (Sequential DCT, Arithmetic) (xFFC9) ***\")); break;\r\n\tcase JFIF_SOF10: m_pLog->AddLineHdr(_T(\"*** Marker: SOF10 (Progressive DCT, Arithmetic) (xFFCA) ***\")); break;\r\n\tcase JFIF_SOF11: m_pLog->AddLineHdr(_T(\"*** Marker: SOF11 (Lossless Process, Arithmetic) (xFFCB) ***\")); break;\r\n\tcase JFIF_SOF13: m_pLog->AddLineHdr(_T(\"*** Marker: SOF13 (Differential Sequential, Arithmetic) (xFFCD) ***\")); break;\r\n\tcase JFIF_SOF14: m_pLog->AddLineHdr(_T(\"*** Marker: SOF14 (Differential Progressive DCT, Arithmetic) (xFFCE) ***\")); break;\r\n\tcase JFIF_SOF15: m_pLog->AddLineHdr(_T(\"*** Marker: SOF15 (Differential Lossless Process, Arithmetic) (xFFCF) ***\")); break;\r\n\r\n\tcase JFIF_JPG:   m_pLog->AddLineHdr(_T(\"*** Marker: JPG (xFFC8) ***\")); break;\r\n\tcase JFIF_DAC:   m_pLog->AddLineHdr(_T(\"*** Marker: DAC (xFFCC) ***\")); break;\r\n\r\n\tcase JFIF_RST0:\r\n\tcase JFIF_RST1:\r\n\tcase JFIF_RST2:\r\n\tcase JFIF_RST3:\r\n\tcase JFIF_RST4:\r\n\tcase JFIF_RST5:\r\n\tcase JFIF_RST6:\r\n\tcase JFIF_RST7:\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: RST# ***\"));\r\n\t\tbreak;\r\n\r\n\tcase JFIF_DQT:  \/\/ Define quantization tables\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: DQT (xFFDB) ***\"));\r\n\t\tm_pLog->AddLineHdrDesc(_T(\"  Define a Quantization Table.\"));\r\n\t\tbreak;\r\n\r\n\r\n\tcase JFIF_COM: \/\/ COM\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: COM (Comment) (xFFFE) ***\"));\r\n\t\tbreak;\r\n\r\n\tcase JFIF_DHT: \/\/ DHT\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: DHT (Define Huffman Table) (xFFC4) ***\"));\r\n\t\tbreak;\r\n\tcase JFIF_DHT_FAKE: \/\/ DHT from standard table (MotionJPEG)\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: DHT from MotionJPEG standard (Define Huffman Table) ***\"));\r\n\t\tbreak;\r\n\r\n\tcase JFIF_SOS: \/\/ SOS\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: SOS (Start of Scan) (xFFDA) ***\"));\r\n\t\tbreak;\r\n\r\n\tcase JFIF_DRI: \/\/ DRI\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: DRI (Restart Interval) (xFFDD) ***\"));\r\n\t\tbreak;\r\n\r\n\tcase JFIF_EOI: \/\/ EOI\r\n\t\tm_pLog->AddLineHdr(_T(\"*** Marker: EOI (End of Image) (xFFD9) ***\"));\r\n\t\tbreak;\r\n\r\n\tcase JFIF_DNL:   m_pLog->AddLineHdr(_T(\"*** Marker: DNL (Define Number of Lines) (xFFDC) ***\")); break;\r\n\tcase JFIF_DHP:   m_pLog->AddLineHdr(_T(\"*** Marker: DHP (Define Hierarchical Progression) (xFFDE) ***\")); break;\r\n\tcase JFIF_EXP:   m_pLog->AddLineHdr(_T(\"*** Marker: EXP (Expand Reference Components) (xFFDF) ***\")); break;\r\n\tcase JFIF_JPG0:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG0 (JPEG Extension) (xFFF0) ***\")); break;\r\n\tcase JFIF_JPG1:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG1 (JPEG Extension) (xFFF1) ***\")); break;\r\n\tcase JFIF_JPG2:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG2 (JPEG Extension) (xFFF2) ***\")); break;\r\n\tcase JFIF_JPG3:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG3 (JPEG Extension) (xFFF3) ***\")); break;\r\n\tcase JFIF_JPG4:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG4 (JPEG Extension) (xFFF4) ***\")); break;\r\n\tcase JFIF_JPG5:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG5 (JPEG Extension) (xFFF5) ***\")); break;\r\n\tcase JFIF_JPG6:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG6 (JPEG Extension) (xFFF6) ***\")); break;\r\n\tcase JFIF_JPG7:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG7 (JPEG Extension) (xFFF7) ***\")); break;\r\n\tcase JFIF_JPG8:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG8 (JPEG Extension) (xFFF8) ***\")); break;\r\n\tcase JFIF_JPG9:  m_pLog->AddLineHdr(_T(\"*** Marker: JPG9 (JPEG Extension) (xFFF9) ***\")); break;\r\n\tcase JFIF_JPG10: m_pLog->AddLineHdr(_T(\"*** Marker: JPG10 (JPEG Extension) (xFFFA) ***\")); break;\r\n\tcase JFIF_JPG11: m_pLog->AddLineHdr(_T(\"*** Marker: JPG11 (JPEG Extension) (xFFFB) ***\")); break;\r\n\tcase JFIF_JPG12: m_pLog->AddLineHdr(_T(\"*** Marker: JPG12 (JPEG Extension) (xFFFC) ***\")); break;\r\n\tcase JFIF_JPG13: m_pLog->AddLineHdr(_T(\"*** Marker: JPG13 (JPEG Extension) (xFFFD) ***\")); break;\r\n\tcase JFIF_TEM:   m_pLog->AddLineHdr(_T(\"*** Marker: TEM (Temporary) (xFF01) ***\")); break;\r\n\r\n\r\n\r\n\tdefault:\r\n\t\tstrTmp.Format(_T(\"*** Marker: ??? (Unknown) (xFF%02X) ***\"),nCode);\r\n\t\tm_pLog->AddLineHdr(strTmp);\r\n\t\tbreak;\r\n\t}\r\n\t\/\/ Adjust position to account for the word used in decoding the marker!\r\n\tstrTmp.Format(_T(\"  OFFSET: 0x%08X\"),m_nPos-2);\r\n\tm_pLog->AddLine(strTmp);\r\n}\r","target":0,"code_token_length":2229,"total_token_length":2465,"max_tokens_setting":4096}
+{"idx":499114,"func":"static void extract_arg(RzAnalysis *analysis, RzAnalysisFunction *fcn, RzAnalysisOp *op, const char *reg, const char *sign, char type) {\n\tst64 ptr = 0;\n\tchar *addr, *esil_buf = NULL;\n\n\trz_return_if_fail(analysis && fcn && op && reg);\n\n\tsize_t i;\n\tfor (i = 0; i < RZ_ARRAY_SIZE(op->src); i++) {\n\t\tif (op->src[i] && op->src[i]->reg && op->src[i]->reg->name) {\n\t\t\tif (!strcmp(reg, op->src[i]->reg->name)) {\n\t\t\t\tst64 delta = op->src[i]->delta;\n\t\t\t\tif ((delta > 0 && *sign == '+') || (delta < 0 && *sign == '-')) {\n\t\t\t\t\tptr = RZ_ABS(op->src[i]->delta);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!ptr) {\n\t\tconst char *op_esil = rz_strbuf_get(&op->esil);\n\t\tif (!op_esil) {\n\t\t\treturn;\n\t\t}\n\t\tesil_buf = strdup(op_esil);\n\t\tif (!esil_buf) {\n\t\t\treturn;\n\t\t}\n\t\tchar *ptr_end = strstr(esil_buf, sdb_fmt(\",%s,%s,\", reg, sign));\n\t\tif (!ptr_end) {\n\t\t\tfree(esil_buf);\n\t\t\treturn;\n\t\t}\n\t\t*ptr_end = 0;\n\t\taddr = ptr_end;\n\t\twhile ((addr[0] != '0' || addr[1] != 'x') && addr >= esil_buf + 1 && *addr != ',') {\n\t\t\taddr--;\n\t\t}\n\t\tif (strncmp(addr, \"0x\", 2)) {\n\t\t\t\/\/XXX: This is a workaround for inconsistent esil\n\t\t\tif (!op->stackop && op->dst) {\n\t\t\t\tconst char *sp = rz_reg_get_name(analysis->reg, RZ_REG_NAME_SP);\n\t\t\t\tconst char *bp = rz_reg_get_name(analysis->reg, RZ_REG_NAME_BP);\n\t\t\t\tconst char *rn = op->dst->reg ? op->dst->reg->name : NULL;\n\t\t\t\tif (rn && ((bp && !strcmp(bp, rn)) || (sp && !strcmp(sp, rn)))) {\n\t\t\t\t\tif (analysis->verbose) {\n\t\t\t\t\t\teprintf(\"Warning: Analysis didn't fill op->stackop for instruction that alters stack at 0x%\" PFMT64x \".\\n\", op->addr);\n\t\t\t\t\t}\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (*addr == ',') {\n\t\t\t\taddr++;\n\t\t\t}\n\t\t\tif (!op->stackop && op->type != RZ_ANALYSIS_OP_TYPE_PUSH && op->type != RZ_ANALYSIS_OP_TYPE_POP && op->type != RZ_ANALYSIS_OP_TYPE_RET && rz_str_isnumber(addr)) {\n\t\t\t\tptr = (st64)rz_num_get(NULL, addr);\n\t\t\t\tif (ptr && op->src[0] && ptr == op->src[0]->imm) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t} else if ((op->stackop == RZ_ANALYSIS_STACK_SET) || (op->stackop == RZ_ANALYSIS_STACK_GET)) {\n\t\t\t\tif (op->ptr % 4) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t\tptr = RZ_ABS(op->ptr);\n\t\t\t} else {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t} else {\n\t\t\tptr = (st64)rz_num_get(NULL, addr);\n\t\t}\n\t}\n\n\tif (analysis->verbose && (!op->src[0] || !op->dst)) {\n\t\teprintf(\"Warning: Analysis didn't fill op->src\/dst at 0x%\" PFMT64x \".\\n\", op->addr);\n\t}\n\n\tint rw = (op->direction == RZ_ANALYSIS_OP_DIR_WRITE) ? RZ_ANALYSIS_VAR_ACCESS_TYPE_WRITE : RZ_ANALYSIS_VAR_ACCESS_TYPE_READ;\n\tif (*sign == '+') {\n\t\tconst bool isarg = type == RZ_ANALYSIS_VAR_KIND_SPV ? ptr >= fcn->stack : ptr >= fcn->bp_off;\n\t\tconst char *pfx = isarg ? ARGPREFIX : VARPREFIX;\n\t\tst64 frame_off;\n\t\tif (type == RZ_ANALYSIS_VAR_KIND_SPV) {\n\t\t\tframe_off = ptr - fcn->stack;\n\t\t} else {\n\t\t\tframe_off = ptr - fcn->bp_off;\n\t\t}\n\t\tRzAnalysisVar *var = get_stack_var(fcn, frame_off);\n\t\tif (var) {\n\t\t\trz_analysis_var_set_access(var, reg, op->addr, rw, ptr);\n\t\t\tgoto beach;\n\t\t}\n\t\tchar *varname = NULL;\n\t\tRzType *vartype = NULL;\n\t\tif (isarg) {\n\t\t\tconst char *place = fcn->cc ? rz_analysis_cc_arg(analysis, fcn->cc, ST32_MAX) : NULL;\n\t\t\tbool stack_rev = place ? !strcmp(place, \"stack_rev\") : false;\n\t\t\tchar *fname = rz_analysis_function_name_guess(analysis->typedb, fcn->name);\n\t\t\tif (fname) {\n\t\t\t\tut64 sum_sz = 0;\n\t\t\t\tsize_t from, to, i;\n\t\t\t\tif (stack_rev) {\n\t\t\t\t\tconst size_t cnt = rz_type_func_args_count(analysis->typedb, fname);\n\t\t\t\t\tfrom = cnt ? cnt - 1 : cnt;\n\t\t\t\t\tto = fcn->cc ? rz_analysis_cc_max_arg(analysis, fcn->cc) : 0;\n\t\t\t\t} else {\n\t\t\t\t\tfrom = fcn->cc ? rz_analysis_cc_max_arg(analysis, fcn->cc) : 0;\n\t\t\t\t\tto = rz_type_func_args_count(analysis->typedb, fname);\n\t\t\t\t}\n\t\t\t\tconst int bytes = (fcn->bits ? fcn->bits : analysis->bits) \/ 8;\n\t\t\t\tfor (i = from; stack_rev ? i >= to : i < to; stack_rev ? i-- : i++) {\n\t\t\t\t\tRzType *tp = rz_type_func_args_type(analysis->typedb, fname, i);\n\t\t\t\t\tif (!tp) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (sum_sz == frame_off) {\n\t\t\t\t\t\tvartype = tp;\n\t\t\t\t\t\tvarname = strdup(rz_type_func_args_name(analysis->typedb, fname, i));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tut64 bit_sz = rz_type_db_get_bitsize(analysis->typedb, tp);\n\t\t\t\t\tsum_sz += bit_sz ? bit_sz \/ 8 : bytes;\n\t\t\t\t\tsum_sz = RZ_ROUND(sum_sz, bytes);\n\t\t\t\t}\n\t\t\t\tfree(fname);\n\t\t\t}\n\t\t}\n\t\tif (!varname) {\n\t\t\tif (analysis->opt.varname_stack) {\n\t\t\t\tvarname = rz_str_newf(\"%s_%\" PFMT64x \"h\", pfx, RZ_ABS(frame_off));\n\t\t\t} else {\n\t\t\t\tvarname = rz_analysis_function_autoname_var(fcn, type, pfx, ptr);\n\t\t\t}\n\t\t}\n\t\tif (varname) {\n\t\t\tRzAnalysisVar *var = rz_analysis_function_set_var(fcn, frame_off, type, vartype, analysis->bits \/ 8, isarg, varname);\n\t\t\tif (var) {\n\t\t\t\trz_analysis_var_set_access(var, reg, op->addr, rw, ptr);\n\t\t\t}\n\t\t\tfree(varname);\n\t\t}\n\t} else {\n\t\tst64 frame_off = -(ptr + fcn->bp_off);\n\t\tRzAnalysisVar *var = get_stack_var(fcn, frame_off);\n\t\tif (var) {\n\t\t\trz_analysis_var_set_access(var, reg, op->addr, rw, -ptr);\n\t\t\tgoto beach;\n\t\t}\n\t\tchar *varname = analysis->opt.varname_stack\n\t\t\t? rz_str_newf(\"%s_%\" PFMT64x \"h\", VARPREFIX, RZ_ABS(frame_off))\n\t\t\t: rz_analysis_function_autoname_var(fcn, type, VARPREFIX, -ptr);\n\t\tif (varname) {\n\t\t\tRzAnalysisVar *var = rz_analysis_function_set_var(fcn, frame_off, type, NULL, analysis->bits \/ 8, false, varname);\n\t\t\tif (var) {\n\t\t\t\trz_analysis_var_set_access(var, reg, op->addr, rw, -ptr);\n\t\t\t}\n\t\t\tfree(varname);\n\t\t}\n\t}\nbeach:\n\tfree(esil_buf);\n}","target":0,"code_token_length":1818,"total_token_length":2054,"max_tokens_setting":4096}
+{"idx":294022,"func":"main(int argc, char* argv[])\n  {\n\n#if !HAVE_DECL_OPTARG\n  extern int optind;\n#endif\n  uint16 defconfig = (uint16) -1;\n  uint16 deffillorder = 0;\n  uint32 deftilewidth = (uint32) 0;\n  uint32 deftilelength = (uint32) 0;\n  uint32 defrowsperstrip = (uint32) 0;\n  uint32 dirnum = 0;\n\n  TIFF *in = NULL;\n  TIFF *out = NULL;\n  char  mode[10];\n  char *mp = mode;\n\n  \/** RJN additions **\/\n  struct image_data image;     \/* Image parameters for one image *\/\n  struct crop_mask  crop;      \/* Cropping parameters for all images *\/\n  struct pagedef    page;      \/* Page definition for output pages *\/\n  struct pageseg    sections[MAX_SECTIONS];  \/* Sections of one output page *\/\n  struct buffinfo   seg_buffs[MAX_SECTIONS]; \/* Segment buffer sizes and pointers *\/\n  struct dump_opts  dump;                  \/* Data dump options *\/\n  unsigned char *read_buff    = NULL;      \/* Input image data buffer *\/\n  unsigned char *crop_buff    = NULL;      \/* Crop area buffer *\/\n  unsigned char *sect_buff    = NULL;      \/* Image section buffer *\/\n  unsigned char *sect_src     = NULL;      \/* Image section buffer pointer *\/\n  unsigned int  imagelist[MAX_IMAGES + 1]; \/* individually specified images *\/\n  unsigned int  image_count  = 0;\n  unsigned int  dump_images  = 0;\n  unsigned int  next_image   = 0;\n  unsigned int  next_page    = 0;\n  unsigned int  total_pages  = 0;\n  unsigned int  total_images = 0;\n  unsigned int  end_of_input = FALSE;\n  int    seg;\n  size_t length;\n  char   temp_filename[PATH_MAX + 16]; \/* Extra space keeps the compiler from complaining *\/\n\n  little_endian = *((unsigned char *)&little_endian) & '1';\n\n  initImageData(&image);\n  initCropMasks(&crop);\n  initPageSetup(&page, sections, seg_buffs);\n  initDumpOptions(&dump);\n\n  process_command_opts (argc, argv, mp, mode, &dirnum, &defconfig, \n                        &deffillorder, &deftilewidth, &deftilelength, &defrowsperstrip,\n\t                &crop, &page, &dump, imagelist, &image_count);\n\n  if (argc - optind < 2)\n    usage();\n\n  if ((argc - optind) == 2)\n    pageNum = -1;\n  else\n    total_images = 0;\n  \/* Read multiple input files and write to output file(s) *\/\n  while (optind < argc - 1)\n    {\n    in = TIFFOpen (argv[optind], \"r\");\n    if (in == NULL)\n      return (-3);\n\n    \/* If only one input file is specified, we can use directory count *\/\n    total_images = TIFFNumberOfDirectories(in);\n    if (total_images > TIFF_DIR_MAX)\n      {\n      TIFFError (TIFFFileName(in), \"File contains too many directories\");\n      if (out != NULL)\n        (void) TIFFClose(out);\n      return (1);\n      }\n    if (image_count == 0)\n      {\n      dirnum = 0;\n      total_pages = total_images; \/* Only valid with single input file *\/\n      }\n    else\n      {\n      dirnum = (tdir_t)(imagelist[next_image] - 1);\n      next_image++;\n\n      \/* Total pages only valid for enumerated list of pages not derived\n       * using odd, even, or last keywords.\n       *\/\n      if (image_count >  total_images)\n\timage_count = total_images;\n      \n      total_pages = image_count;\n      }\n\n    \/* MAX_IMAGES is used for special case \"last\" in selection list *\/\n    if (dirnum == (MAX_IMAGES - 1))\n      dirnum = total_images - 1;\n\n    if (dirnum > (total_images))\n      {\n      TIFFError (TIFFFileName(in), \n      \"Invalid image number %d, File contains only %d images\", \n\t\t (int)dirnum + 1, total_images);\n      if (out != NULL)\n        (void) TIFFClose(out);\n      return (1);\n      }\n\n    if (dirnum != 0 && !TIFFSetDirectory(in, (tdir_t)dirnum))\n      {\n      TIFFError(TIFFFileName(in),\"Error, setting subdirectory at %d\", dirnum);\n      if (out != NULL)\n        (void) TIFFClose(out);\n      return (1);\n      }\n\n    end_of_input = FALSE;\n    while (end_of_input == FALSE)\n      {\n      config = defconfig;\n      compression = defcompression;\n      predictor = defpredictor;\n      fillorder = deffillorder;\n      rowsperstrip = defrowsperstrip;\n      tilewidth = deftilewidth;\n      tilelength = deftilelength;\n      g3opts = defg3opts;\n\n      if (dump.format != DUMP_NONE)\n        {\n        \/* manage input and\/or output dump files here *\/\n\tdump_images++;\n        length = strlen(dump.infilename);\n        if (length > 0)\n          {\n          if (dump.infile != NULL)\n            fclose (dump.infile);\n\n          \/* dump.infilename is guaranteed to be NUL terminated and have 20 bytes\n             fewer than PATH_MAX *\/\n          snprintf(temp_filename, sizeof(temp_filename), \"%s-read-%03d.%s\",\n\t\t   dump.infilename, dump_images,\n                  (dump.format == DUMP_TEXT) ? \"txt\" : \"raw\");\n          if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL)\n            {\n\t    TIFFError (\"Unable to open dump file for writing\", \"%s\", temp_filename);\n\t    exit (-1);\n            }\n          dump_info(dump.infile, dump.format, \"Reading image\",\"%d from %s\", \n                    dump_images, TIFFFileName(in));\n          } \n        length = strlen(dump.outfilename);\n        if (length > 0)\n          {\n          if (dump.outfile != NULL)\n            fclose (dump.outfile);\n\n          \/* dump.outfilename is guaranteed to be NUL terminated and have 20 bytes\n             fewer than PATH_MAX *\/ \n          snprintf(temp_filename, sizeof(temp_filename), \"%s-write-%03d.%s\",\n\t\t   dump.outfilename, dump_images,\n                  (dump.format == DUMP_TEXT) ? \"txt\" : \"raw\");\n          if ((dump.outfile = fopen(temp_filename, dump.mode)) == NULL)\n            {\n\t      TIFFError (\"Unable to open dump file for writing\", \"%s\", temp_filename);\n\t    exit (-1);\n            }\n          dump_info(dump.outfile, dump.format, \"Writing image\",\"%d from %s\", \n                    dump_images, TIFFFileName(in));\n          } \n        }\n\n      if (dump.debug)\n         TIFFError(\"main\", \"Reading image %4d of %4d total pages.\", dirnum + 1, total_pages);\n\n      if (loadImage(in, &image, &dump, &read_buff))\n        {\n        TIFFError(\"main\", \"Unable to load source image\");\n        exit (-1);\n        }\n\n      \/* Correct the image orientation if it was not ORIENTATION_TOPLEFT.\n       *\/\n      if (image.adjustments != 0)\n        {\n\tif (correct_orientation(&image, &read_buff))\n\t    TIFFError(\"main\", \"Unable to correct image orientation\");\n        }\n\n      if (getCropOffsets(&image, &crop, &dump))\n        {\n        TIFFError(\"main\", \"Unable to define crop regions\");\n        exit (-1);\n\t}\n\n      if (crop.selections > 0)\n        {\n        if (processCropSelections(&image, &crop, &read_buff, seg_buffs))\n          {\n          TIFFError(\"main\", \"Unable to process image selections\");\n          exit (-1);\n\t  }\n\t}\n      else  \/* Single image segment without zones or regions *\/\n        {\n        if (createCroppedImage(&image, &crop, &read_buff, &crop_buff))\n          {\n          TIFFError(\"main\", \"Unable to create output image\");\n          exit (-1);\n\t  }\n\t}\n      if (page.mode == PAGE_MODE_NONE)\n        {  \/* Whole image or sections not based on output page size *\/\n        if (crop.selections > 0)\n          {\n\t  writeSelections(in, &out, &crop, &image, &dump, seg_buffs,\n                          mp, argv[argc - 1], &next_page, total_pages);\n          }\n\telse  \/* One file all images and sections *\/\n          {\n\t  if (update_output_file (&out, mp, crop.exp_mode, argv[argc - 1],\n                                  &next_page))\n             exit (1);\n          if (writeCroppedImage(in, out, &image, &dump,crop.combined_width, \n                                crop.combined_length, crop_buff, next_page, total_pages))\n            {\n             TIFFError(\"main\", \"Unable to write new image\");\n             exit (-1);\n\t    }\n          }\n\t}\n      else\n        {\n\t\/* If we used a crop buffer, our data is there, otherwise it is\n         * in the read_buffer\n         *\/\n\tif (crop_buff != NULL)  \n\t  sect_src = crop_buff;\n        else\n          sect_src = read_buff;\n        \/* Break input image into pages or rows and columns *\/\n        if (computeOutputPixelOffsets(&crop, &image, &page, sections, &dump))\n          {\n          TIFFError(\"main\", \"Unable to compute output section data\");\n          exit (-1);\n\t  }\n        \/* If there are multiple files on the command line, the final one is assumed \n         * to be the output filename into which the images are written.\n         *\/\n\tif (update_output_file (&out, mp, crop.exp_mode, argv[argc - 1], &next_page))\n          exit (1);\n\n\tif (writeImageSections(in, out, &image, &page, sections, &dump, sect_src, §_buff))\n          {\n          TIFFError(\"main\", \"Unable to write image sections\");\n          exit (-1);\n\t  }\n        }\n\n      \/* No image list specified, just read the next image *\/\n      if (image_count == 0)\n        dirnum++;\n      else\n        {\n\tdirnum = (tdir_t)(imagelist[next_image] - 1);\n        next_image++;\n        }\n\n      if (dirnum == MAX_IMAGES - 1)\n        dirnum = TIFFNumberOfDirectories(in) - 1;\n\n      if (!TIFFSetDirectory(in, (tdir_t)dirnum))\n        end_of_input = TRUE;\n      }\n    TIFFClose(in);\n    optind++;\n    }\n\n  \/* If we did not use the read buffer as the crop buffer *\/\n  if (read_buff)\n    _TIFFfree(read_buff);\n\n  if (crop_buff)\n    _TIFFfree(crop_buff);\n\n  if (sect_buff)\n    _TIFFfree(sect_buff);\n\n   \/* Clean up any segment buffers used for zones or regions *\/\n  for (seg = 0; seg < crop.selections; seg++)\n    _TIFFfree (seg_buffs[seg].buffer);\n\n  if (dump.format != DUMP_NONE)\n    {\n    if (dump.infile != NULL)\n     fclose (dump.infile);\n\n    if (dump.outfile != NULL)\n      {\n      dump_info (dump.outfile, dump.format, \"\", \"Completed run for %s\", TIFFFileName(out));\n      fclose (dump.outfile);\n      }\n    }\n\n  TIFFClose(out);\n\n  return (0);\n  } \/* end main *\/","target":0,"code_token_length":2487,"total_token_length":2723,"max_tokens_setting":4096}
+{"idx":4752,"func":"int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)\n{\n\tint rc = X86EMUL_CONTINUE;\n\tint mode = ctxt->mode;\n\tint def_op_bytes, def_ad_bytes, goffset, simd_prefix;\n\tbool op_prefix = false;\n\tbool has_seg_override = false;\n\tstruct opcode opcode;\n\n\tctxt->memop.type = OP_NONE;\n\tctxt->memopp = NULL;\n\tctxt->_eip = ctxt->eip;\n\tctxt->fetch.ptr = ctxt->fetch.data;\n\tctxt->fetch.end = ctxt->fetch.data + insn_len;\n\tctxt->opcode_len = 1;\n\tif (insn_len > 0)\n\t\tmemcpy(ctxt->fetch.data, insn, insn_len);\n\telse {\n\t\trc = __do_insn_fetch_bytes(ctxt, 1);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\treturn rc;\n\t}\n\n\tswitch (mode) {\n\tcase X86EMUL_MODE_REAL:\n\tcase X86EMUL_MODE_VM86:\n\tcase X86EMUL_MODE_PROT16:\n\t\tdef_op_bytes = def_ad_bytes = 2;\n\t\tbreak;\n\tcase X86EMUL_MODE_PROT32:\n\t\tdef_op_bytes = def_ad_bytes = 4;\n\t\tbreak;\n#ifdef CONFIG_X86_64\n\tcase X86EMUL_MODE_PROT64:\n\t\tdef_op_bytes = 4;\n\t\tdef_ad_bytes = 8;\n\t\tbreak;\n#endif\n\tdefault:\n\t\treturn EMULATION_FAILED;\n\t}\n\n\tctxt->op_bytes = def_op_bytes;\n\tctxt->ad_bytes = def_ad_bytes;\n\n\t\/* Legacy prefixes. *\/\n\tfor (;;) {\n\t\tswitch (ctxt->b = insn_fetch(u8, ctxt)) {\n\t\tcase 0x66:\t\/* operand-size override *\/\n\t\t\top_prefix = true;\n\t\t\t\/* switch between 2\/4 bytes *\/\n\t\t\tctxt->op_bytes = def_op_bytes ^ 6;\n\t\t\tbreak;\n\t\tcase 0x67:\t\/* address-size override *\/\n\t\t\tif (mode == X86EMUL_MODE_PROT64)\n\t\t\t\t\/* switch between 4\/8 bytes *\/\n\t\t\t\tctxt->ad_bytes = def_ad_bytes ^ 12;\n\t\t\telse\n\t\t\t\t\/* switch between 2\/4 bytes *\/\n\t\t\t\tctxt->ad_bytes = def_ad_bytes ^ 6;\n\t\t\tbreak;\n\t\tcase 0x26:\t\/* ES override *\/\n\t\tcase 0x2e:\t\/* CS override *\/\n\t\tcase 0x36:\t\/* SS override *\/\n\t\tcase 0x3e:\t\/* DS override *\/\n\t\t\thas_seg_override = true;\n\t\t\tctxt->seg_override = (ctxt->b >> 3) & 3;\n\t\t\tbreak;\n\t\tcase 0x64:\t\/* FS override *\/\n\t\tcase 0x65:\t\/* GS override *\/\n\t\t\thas_seg_override = true;\n\t\t\tctxt->seg_override = ctxt->b & 7;\n\t\t\tbreak;\n\t\tcase 0x40 ... 0x4f: \/* REX *\/\n\t\t\tif (mode != X86EMUL_MODE_PROT64)\n\t\t\t\tgoto done_prefixes;\n\t\t\tctxt->rex_prefix = ctxt->b;\n\t\t\tcontinue;\n\t\tcase 0xf0:\t\/* LOCK *\/\n\t\t\tctxt->lock_prefix = 1;\n\t\t\tbreak;\n\t\tcase 0xf2:\t\/* REPNE\/REPNZ *\/\n\t\tcase 0xf3:\t\/* REP\/REPE\/REPZ *\/\n\t\t\tctxt->rep_prefix = ctxt->b;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tgoto done_prefixes;\n\t\t}\n\n\t\t\/* Any legacy prefix after a REX prefix nullifies its effect. *\/\n\n\t\tctxt->rex_prefix = 0;\n\t}\n\ndone_prefixes:\n\n\t\/* REX prefix. *\/\n\tif (ctxt->rex_prefix & 8)\n\t\tctxt->op_bytes = 8;\t\/* REX.W *\/\n\n\t\/* Opcode byte(s). *\/\n\topcode = opcode_table[ctxt->b];\n\t\/* Two-byte opcode? *\/\n\tif (ctxt->b == 0x0f) {\n\t\tctxt->opcode_len = 2;\n\t\tctxt->b = insn_fetch(u8, ctxt);\n\t\topcode = twobyte_table[ctxt->b];\n\n\t\t\/* 0F_38 opcode map *\/\n\t\tif (ctxt->b == 0x38) {\n\t\t\tctxt->opcode_len = 3;\n\t\t\tctxt->b = insn_fetch(u8, ctxt);\n\t\t\topcode = opcode_map_0f_38[ctxt->b];\n\t\t}\n\t}\n\tctxt->d = opcode.flags;\n\n\tif (ctxt->d & ModRM)\n\t\tctxt->modrm = insn_fetch(u8, ctxt);\n\n\t\/* vex-prefix instructions are not implemented *\/\n\tif (ctxt->opcode_len == 1 && (ctxt->b == 0xc5 || ctxt->b == 0xc4) &&\n\t    (mode == X86EMUL_MODE_PROT64 ||\n\t    (mode >= X86EMUL_MODE_PROT16 && (ctxt->modrm & 0x80)))) {\n\t\tctxt->d = NotImpl;\n\t}\n\n\twhile (ctxt->d & GroupMask) {\n\t\tswitch (ctxt->d & GroupMask) {\n\t\tcase Group:\n\t\t\tgoffset = (ctxt->modrm >> 3) & 7;\n\t\t\topcode = opcode.u.group[goffset];\n\t\t\tbreak;\n\t\tcase GroupDual:\n\t\t\tgoffset = (ctxt->modrm >> 3) & 7;\n\t\t\tif ((ctxt->modrm >> 6) == 3)\n\t\t\t\topcode = opcode.u.gdual->mod3[goffset];\n\t\t\telse\n\t\t\t\topcode = opcode.u.gdual->mod012[goffset];\n\t\t\tbreak;\n\t\tcase RMExt:\n\t\t\tgoffset = ctxt->modrm & 7;\n\t\t\topcode = opcode.u.group[goffset];\n\t\t\tbreak;\n\t\tcase Prefix:\n\t\t\tif (ctxt->rep_prefix && op_prefix)\n\t\t\t\treturn EMULATION_FAILED;\n\t\t\tsimd_prefix = op_prefix ? 0x66 : ctxt->rep_prefix;\n\t\t\tswitch (simd_prefix) {\n\t\t\tcase 0x00: opcode = opcode.u.gprefix->pfx_no; break;\n\t\t\tcase 0x66: opcode = opcode.u.gprefix->pfx_66; break;\n\t\t\tcase 0xf2: opcode = opcode.u.gprefix->pfx_f2; break;\n\t\t\tcase 0xf3: opcode = opcode.u.gprefix->pfx_f3; break;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase Escape:\n\t\t\tif (ctxt->modrm > 0xbf)\n\t\t\t\topcode = opcode.u.esc->high[ctxt->modrm - 0xc0];\n\t\t\telse\n\t\t\t\topcode = opcode.u.esc->op[(ctxt->modrm >> 3) & 7];\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn EMULATION_FAILED;\n\t\t}\n\n\t\tctxt->d &= ~(u64)GroupMask;\n\t\tctxt->d |= opcode.flags;\n\t}\n\n\t\/* Unrecognised? *\/\n\tif (ctxt->d == 0)\n\t\treturn EMULATION_FAILED;\n\n\tctxt->execute = opcode.u.execute;\n\n\tif (unlikely(ctxt->ud) && likely(!(ctxt->d & EmulateOnUD)))\n\t\treturn EMULATION_FAILED;\n\n\tif (unlikely(ctxt->d &\n\t\t     (NotImpl|Stack|Op3264|Sse|Mmx|Intercept|CheckPerm))) {\n\t\t\/*\n\t\t * These are copied unconditionally here, and checked unconditionally\n\t\t * in x86_emulate_insn.\n\t\t *\/\n\t\tctxt->check_perm = opcode.check_perm;\n\t\tctxt->intercept = opcode.intercept;\n\n\t\tif (ctxt->d & NotImpl)\n\t\t\treturn EMULATION_FAILED;\n\n\t\tif (mode == X86EMUL_MODE_PROT64 && (ctxt->d & Stack))\n\t\t\tctxt->op_bytes = 8;\n\n\t\tif (ctxt->d & Op3264) {\n\t\t\tif (mode == X86EMUL_MODE_PROT64)\n\t\t\t\tctxt->op_bytes = 8;\n\t\t\telse\n\t\t\t\tctxt->op_bytes = 4;\n\t\t}\n\n\t\tif (ctxt->d & Sse)\n\t\t\tctxt->op_bytes = 16;\n\t\telse if (ctxt->d & Mmx)\n\t\t\tctxt->op_bytes = 8;\n\t}\n\n\t\/* ModRM and SIB bytes. *\/\n\tif (ctxt->d & ModRM) {\n\t\trc = decode_modrm(ctxt, &ctxt->memop);\n\t\tif (!has_seg_override) {\n\t\t\thas_seg_override = true;\n\t\t\tctxt->seg_override = ctxt->modrm_seg;\n\t\t}\n\t} else if (ctxt->d & MemAbs)\n\t\trc = decode_abs(ctxt, &ctxt->memop);\n\tif (rc != X86EMUL_CONTINUE)\n\t\tgoto done;\n\n\tif (!has_seg_override)\n\t\tctxt->seg_override = VCPU_SREG_DS;\n\n\tctxt->memop.addr.mem.seg = ctxt->seg_override;\n\n\t\/*\n\t * Decode and fetch the source operand: register, memory\n\t * or immediate.\n\t *\/\n\trc = decode_operand(ctxt, &ctxt->src, (ctxt->d >> SrcShift) & OpMask);\n\tif (rc != X86EMUL_CONTINUE)\n\t\tgoto done;\n\n\t\/*\n\t * Decode and fetch the second source operand: register, memory\n\t * or immediate.\n\t *\/\n\trc = decode_operand(ctxt, &ctxt->src2, (ctxt->d >> Src2Shift) & OpMask);\n\tif (rc != X86EMUL_CONTINUE)\n\t\tgoto done;\n\n\t\/* Decode and fetch the destination operand: register or memory. *\/\n\trc = decode_operand(ctxt, &ctxt->dst, (ctxt->d >> DstShift) & OpMask);\n\ndone:\n\tif (ctxt->rip_relative)\n\t\tctxt->memopp->addr.mem.ea += ctxt->_eip;\n\n\treturn (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;\n}","target":1,"code_token_length":2148,"total_token_length":2384,"max_tokens_setting":4096}
+{"idx":204567,"func":"xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,\n const xmlChar **URI, int *tlen) {\n const xmlChar *localname;\n const xmlChar *prefix;\n const xmlChar *attname;\n const xmlChar *aprefix;\n const xmlChar *nsname;\n    xmlChar *attvalue;\n const xmlChar **atts = ctxt->atts;\n int maxatts = ctxt->maxatts;\n int nratts, nbatts, nbdef;\n int i, j, nbNs, attval, oldline, oldcol, inputNr;\n const xmlChar *base;\n unsigned long cur;\n int nsNr = ctxt->nsNr;\n\n if (RAW != '<') return(NULL);\n    NEXT1;\n\n \/*\n     * NOTE: it is crucial with the SAX2 API to never call SHRINK beyond that\n     *       point since the attribute values may be stored as pointers to\n     *       the buffer and calling SHRINK would destroy them !\n     *       The Shrinking is only possible once the full set of attribute\n     *       callbacks have been done.\n     *\/\nreparse:\n    SHRINK;\n    base = ctxt->input->base;\n    cur = ctxt->input->cur - ctxt->input->base;\n    inputNr = ctxt->inputNr;\n    oldline = ctxt->input->line;\n    oldcol = ctxt->input->col;\n    nbatts = 0;\n    nratts = 0;\n    nbdef = 0;\n    nbNs = 0;\n    attval = 0;\n \/* Forget any namespaces added during an earlier parse of this element. *\/\n    ctxt->nsNr = nsNr;\n\n    localname = xmlParseQName(ctxt, &prefix);\n if (localname == NULL) {\n\txmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,\n \"StartTag: invalid element name\\n\");\n return(NULL);\n }\n *tlen = ctxt->input->cur - ctxt->input->base - cur;\n\n \/*\n     * Now parse the attributes, it ends up with the ending\n     *\n     * (S Attribute)* S?\n     *\/\n    SKIP_BLANKS;\n    GROW;\n if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n goto base_changed;\n\n while (((RAW != '>') &&\n ((RAW != '\/') || (NXT(1) != '>')) &&\n (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {\n const xmlChar *q = CUR_PTR;\n unsigned int cons = ctxt->input->consumed;\n int len = -1, alloc = 0;\n\n\tattname = xmlParseAttribute2(ctxt, prefix, localname,\n &aprefix, &attvalue, &len, &alloc);\n if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) {\n if ((attvalue != NULL) && (alloc != 0))\n\t        xmlFree(attvalue);\n\t    attvalue = NULL;\n goto base_changed;\n }\n if ((attname != NULL) && (attvalue != NULL)) {\n if (len < 0) len = xmlStrlen(attvalue);\n if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {\n const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);\n\t\txmlURIPtr uri;\n\n if (URL == NULL) {\n\t\t    xmlErrMemory(ctxt, \"dictionary allocation failure\");\n if ((attvalue != NULL) && (alloc != 0))\n\t\t\txmlFree(attvalue);\n return(NULL);\n }\n if (*URL != 0) {\n\t\t    uri = xmlParseURI((const char *) URL);\n if (uri == NULL) {\n\t\t\txmlNsErr(ctxt, XML_WAR_NS_URI,\n \"xmlns: '%s' is not a valid URI\\n\",\n\t\t\t\t\t   URL, NULL, NULL);\n } else {\n if (uri->scheme == NULL) {\n\t\t\t    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,\n \"xmlns: URI %s is not absolute\\n\",\n\t\t\t\t      URL, NULL, NULL);\n }\n\t\t\txmlFreeURI(uri);\n }\n if (URL == ctxt->str_xml_ns) {\n if (attname != ctxt->str_xml) {\n\t\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"xml namespace URI cannot be the default namespace\\n\",\n\t\t\t\t     NULL, NULL, NULL);\n }\n goto skip_default_ns;\n }\n if ((len == 29) &&\n (xmlStrEqual(URL,\n\t\t\t\t BAD_CAST \"http:\/\/www.w3.org\/2000\/xmlns\/\"))) {\n\t\t\txmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"reuse of the xmlns namespace name is forbidden\\n\",\n\t\t\t\t NULL, NULL, NULL);\n goto skip_default_ns;\n }\n }\n \/*\n\t\t * check that it's not a defined namespace\n\t\t *\/\n for (j = 1;j <= nbNs;j++)\n if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)\n break;\n if (j <= nbNs)\n\t\t    xmlErrAttributeDup(ctxt, NULL, attname);\n else\n if (nsPush(ctxt, NULL, URL) > 0) nbNs++;\nskip_default_ns:\n if ((attvalue != NULL) && (alloc != 0)) {\n\t\t    xmlFree(attvalue);\n\t\t    attvalue = NULL;\n }\n if ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n break;\n if (!IS_BLANK_CH(RAW)) {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n \"attributes construct error\\n\");\n break;\n }\n\t\tSKIP_BLANKS;\n if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n goto base_changed;\n continue;\n }\n if (aprefix == ctxt->str_xmlns) {\n const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);\n\t\txmlURIPtr uri;\n\n if (attname == ctxt->str_xml) {\n if (URL != ctxt->str_xml_ns) {\n\t\t        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"xml namespace prefix mapped to wrong URI\\n\",\n\t\t\t         NULL, NULL, NULL);\n }\n \/*\n\t\t     * Do not keep a namespace definition node\n\t\t     *\/\n goto skip_ns;\n }\n if (URL == ctxt->str_xml_ns) {\n if (attname != ctxt->str_xml) {\n\t\t        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"xml namespace URI mapped to wrong prefix\\n\",\n\t\t\t         NULL, NULL, NULL);\n }\n goto skip_ns;\n }\n if (attname == ctxt->str_xmlns) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"redefinition of the xmlns prefix is forbidden\\n\",\n\t\t\t     NULL, NULL, NULL);\n goto skip_ns;\n }\n if ((len == 29) &&\n (xmlStrEqual(URL,\n\t\t                 BAD_CAST \"http:\/\/www.w3.org\/2000\/xmlns\/\"))) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"reuse of the xmlns namespace name is forbidden\\n\",\n\t\t\t     NULL, NULL, NULL);\n goto skip_ns;\n }\n if ((URL == NULL) || (URL[0] == 0)) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n \"xmlns:%s: Empty XML namespace is not allowed\\n\",\n\t\t\t          attname, NULL, NULL);\n goto skip_ns;\n } else {\n\t\t    uri = xmlParseURI((const char *) URL);\n if (uri == NULL) {\n\t\t\txmlNsErr(ctxt, XML_WAR_NS_URI,\n \"xmlns:%s: '%s' is not a valid URI\\n\",\n\t\t\t\t\t   attname, URL, NULL);\n } else {\n if ((ctxt->pedantic) && (uri->scheme == NULL)) {\n\t\t\t    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,\n \"xmlns:%s: URI %s is not absolute\\n\",\n\t\t\t\t      attname, URL, NULL);\n }\n\t\t\txmlFreeURI(uri);\n }\n }\n\n \/*\n\t\t * check that it's not a defined namespace\n\t\t *\/\n for (j = 1;j <= nbNs;j++)\n if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)\n break;\n if (j <= nbNs)\n\t\t    xmlErrAttributeDup(ctxt, aprefix, attname);\n else\n if (nsPush(ctxt, attname, URL) > 0) nbNs++;\nskip_ns:\n if ((attvalue != NULL) && (alloc != 0)) {\n\t\t    xmlFree(attvalue);\n\t\t    attvalue = NULL;\n }\n if ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n break;\n if (!IS_BLANK_CH(RAW)) {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n \"attributes construct error\\n\");\n break;\n }\n\t\tSKIP_BLANKS;\n if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n goto base_changed;\n continue;\n }\n\n \/*\n\t     * Add the pair to atts\n\t     *\/\n if ((atts == NULL) || (nbatts + 5 > maxatts)) {\n if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {\n if (attvalue[len] == 0)\n\t\t\txmlFree(attvalue);\n goto failed;\n }\n\t        maxatts = ctxt->maxatts;\n\t\tatts = ctxt->atts;\n }\n\t    ctxt->attallocs[nratts++] = alloc;\n\t    atts[nbatts++] = attname;\n\t    atts[nbatts++] = aprefix;\n\t    atts[nbatts++] = NULL; \/* the URI will be fetched later *\/\n\t    atts[nbatts++] = attvalue;\n\t    attvalue += len;\n\t    atts[nbatts++] = attvalue;\n \/*\n\t     * tag if some deallocation is needed\n\t     *\/\n if (alloc != 0) attval = 1;\n } else {\n if ((attvalue != NULL) && (attvalue[len] == 0))\n\t\txmlFree(attvalue);\n }\n\nfailed:\n\n\tGROW\n if (ctxt->instate == XML_PARSER_EOF)\n break;\n if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n goto base_changed;\n if ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n break;\n if (!IS_BLANK_CH(RAW)) {\n\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n \"attributes construct error\\n\");\n break;\n }\n\tSKIP_BLANKS;\n if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&\n (attname == NULL) && (attvalue == NULL)) {\n\t    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,\n \"xmlParseStartTag: problem parsing attributes\\n\");\n break;\n }\n        GROW;\n if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n goto base_changed;\n }\n\n \/*\n     * The attributes defaulting\n     *\/\n if (ctxt->attsDefault != NULL) {\n        xmlDefAttrsPtr defaults;\n\n\tdefaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix);\n if (defaults != NULL) {\n for (i = 0;i < defaults->nbAttrs;i++) {\n\t        attname = defaults->values[5 * i];\n\t\taprefix = defaults->values[5 * i + 1];\n\n \/*\n\t\t * special work for namespaces defaulted defs\n\t\t *\/\n if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {\n \/*\n\t\t     * check that it's not a defined namespace\n\t\t     *\/\n for (j = 1;j <= nbNs;j++)\n if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)\n break;\n if (j <= nbNs) continue;\n\n\t\t    nsname = xmlGetNamespace(ctxt, NULL);\n if (nsname != defaults->values[5 * i + 2]) {\n if (nsPush(ctxt, NULL,\n\t\t\t           defaults->values[5 * i + 2]) > 0)\n\t\t\t    nbNs++;\n }\n } else if (aprefix == ctxt->str_xmlns) {\n \/*\n\t\t     * check that it's not a defined namespace\n\t\t     *\/\n for (j = 1;j <= nbNs;j++)\n if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)\n break;\n if (j <= nbNs) continue;\n\n\t\t    nsname = xmlGetNamespace(ctxt, attname);\n if (nsname != defaults->values[2]) {\n if (nsPush(ctxt, attname,\n\t\t\t           defaults->values[5 * i + 2]) > 0)\n\t\t\t    nbNs++;\n }\n } else {\n \/*\n\t\t     * check that it's not a defined attribute\n\t\t     *\/\n for (j = 0;j < nbatts;j+=5) {\n if ((attname == atts[j]) && (aprefix == atts[j+1]))\n break;\n }\n if (j < nbatts) continue;\n\n if ((atts == NULL) || (nbatts + 5 > maxatts)) {\n if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {\n return(NULL);\n }\n\t\t\tmaxatts = ctxt->maxatts;\n\t\t\tatts = ctxt->atts;\n }\n\t\t    atts[nbatts++] = attname;\n\t\t    atts[nbatts++] = aprefix;\n if (aprefix == NULL)\n\t\t\tatts[nbatts++] = NULL;\n else\n\t\t        atts[nbatts++] = xmlGetNamespace(ctxt, aprefix);\n\t\t    atts[nbatts++] = defaults->values[5 * i + 2];\n\t\t    atts[nbatts++] = defaults->values[5 * i + 3];\n if ((ctxt->standalone == 1) &&\n (defaults->values[5 * i + 4] != NULL)) {\n\t\t\txmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED,\n \"standalone: attribute %s on %s defaulted from external subset\\n\",\n\t                                 attname, localname);\n }\n\t\t    nbdef++;\n }\n }\n }\n }\n\n \/*\n     * The attributes checkings\n     *\/\n for (i = 0; i < nbatts;i += 5) {\n \/*\n\t* The default namespace does not apply to attribute names.\n\t*\/\n if (atts[i + 1] != NULL) {\n\t    nsname = xmlGetNamespace(ctxt, atts[i + 1]);\n if (nsname == NULL) {\n\t\txmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,\n \"Namespace prefix %s for %s on %s is not defined\\n\",\n\t\t    atts[i + 1], atts[i], localname);\n }\n\t    atts[i + 2] = nsname;\n } else\n\t    nsname = NULL;\n \/*\n\t * [ WFC: Unique Att Spec ]\n\t * No attribute name may appear more than once in the same\n\t * start-tag or empty-element tag.\n\t * As extended by the Namespace in XML REC.\n\t *\/\n for (j = 0; j < i;j += 5) {\n if (atts[i] == atts[j]) {\n if (atts[i+1] == atts[j+1]) {\n\t\t    xmlErrAttributeDup(ctxt, atts[i+1], atts[i]);\n break;\n }\n if ((nsname != NULL) && (atts[j + 2] == nsname)) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,\n \"Namespaced Attribute %s in '%s' redefined\\n\",\n\t\t\t     atts[i], nsname, NULL);\n break;\n }\n }\n }\n }\n\n    nsname = xmlGetNamespace(ctxt, prefix);\n if ((prefix != NULL) && (nsname == NULL)) {\n\txmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,\n \"Namespace prefix %s on %s is not defined\\n\",\n\t\t prefix, localname, NULL);\n }\n *pref = prefix;\n *URI = nsname;\n\n \/*\n     * SAX: Start of Element !\n     *\/\n if ((ctxt->sax != NULL) && (ctxt->sax->startElementNs != NULL) &&\n (!ctxt->disableSAX)) {\n if (nbNs > 0)\n\t    ctxt->sax->startElementNs(ctxt->userData, localname, prefix,\n\t\t\t  nsname, nbNs, &ctxt->nsTab[ctxt->nsNr - 2 * nbNs],\n\t\t\t  nbatts \/ 5, nbdef, atts);\n else\n\t    ctxt->sax->startElementNs(ctxt->userData, localname, prefix,\n\t                  nsname, 0, NULL, nbatts \/ 5, nbdef, atts);\n }\n\n \/*\n     * Free up attribute allocated strings if needed\n     *\/\n if (attval != 0) {\n for (i = 3,j = 0; j < nratts;i += 5,j++)\n if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))\n\t        xmlFree((xmlChar *) atts[i]);\n }\n\n return(localname);\n\nbase_changed:\n \/*\n     * the attribute strings are valid iif the base didn't changed\n     *\/\n if (attval != 0) {\n for (i = 3,j = 0; j < nratts;i += 5,j++)\n if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))\n\t        xmlFree((xmlChar *) atts[i]);\n }\n\n \/*\n     * We can't switch from one entity to another in the middle\n     * of a start tag\n     *\/\n if (inputNr != ctxt->inputNr) {\n        xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,\n \"Start tag doesn't start and stop in the same entity\\n\");\n return(NULL);\n }\n\n    ctxt->input->cur = ctxt->input->base + cur;\n    ctxt->input->line = oldline;\n    ctxt->input->col = oldcol;\n if (ctxt->wellFormed == 1) {\n goto reparse;\n }\n return(NULL);\n}\n","target":0,"code_token_length":3785,"total_token_length":4021,"max_tokens_setting":4096}
+{"idx":51225,"func":"static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,\n\t\t\t\t   struct bpf_insn *insn,\n\t\t\t\t   const struct bpf_reg_state *ptr_reg,\n\t\t\t\t   const struct bpf_reg_state *off_reg)\n{\n\tstruct bpf_verifier_state *vstate = env->cur_state;\n\tstruct bpf_func_state *state = vstate->frame[vstate->curframe];\n\tstruct bpf_reg_state *regs = state->regs, *dst_reg;\n\tbool known = tnum_is_const(off_reg->var_off);\n\ts64 smin_val = off_reg->smin_value, smax_val = off_reg->smax_value,\n\t    smin_ptr = ptr_reg->smin_value, smax_ptr = ptr_reg->smax_value;\n\tu64 umin_val = off_reg->umin_value, umax_val = off_reg->umax_value,\n\t    umin_ptr = ptr_reg->umin_value, umax_ptr = ptr_reg->umax_value;\n\tu32 dst = insn->dst_reg, src = insn->src_reg;\n\tu8 opcode = BPF_OP(insn->code);\n\tint ret;\n\n\tdst_reg = ®s[dst];\n\n\tif ((known && (smin_val != smax_val || umin_val != umax_val)) ||\n\t    smin_val > smax_val || umin_val > umax_val) {\n\t\t\/* Taint dst register if offset had invalid bounds derived from\n\t\t * e.g. dead branches.\n\t\t *\/\n\t\t__mark_reg_unknown(env, dst_reg);\n\t\treturn 0;\n\t}\n\n\tif (BPF_CLASS(insn->code) != BPF_ALU64) {\n\t\t\/* 32-bit ALU ops on pointers produce (meaningless) scalars *\/\n\t\tif (opcode == BPF_SUB && env->allow_ptr_leaks) {\n\t\t\t__mark_reg_unknown(env, dst_reg);\n\t\t\treturn 0;\n\t\t}\n\n\t\tverbose(env,\n\t\t\t\"R%d 32-bit pointer arithmetic prohibited\\n\",\n\t\t\tdst);\n\t\treturn -EACCES;\n\t}\n\n\tswitch (ptr_reg->type) {\n\tcase PTR_TO_MAP_VALUE_OR_NULL:\n\t\tverbose(env, \"R%d pointer arithmetic on %s prohibited, null-check it first\\n\",\n\t\t\tdst, reg_type_str[ptr_reg->type]);\n\t\treturn -EACCES;\n\tcase CONST_PTR_TO_MAP:\n\tcase PTR_TO_PACKET_END:\n\tcase PTR_TO_SOCKET:\n\tcase PTR_TO_SOCKET_OR_NULL:\n\tcase PTR_TO_SOCK_COMMON:\n\tcase PTR_TO_SOCK_COMMON_OR_NULL:\n\tcase PTR_TO_TCP_SOCK:\n\tcase PTR_TO_TCP_SOCK_OR_NULL:\n\tcase PTR_TO_XDP_SOCK:\n\t\tverbose(env, \"R%d pointer arithmetic on %s prohibited\\n\",\n\t\t\tdst, reg_type_str[ptr_reg->type]);\n\t\treturn -EACCES;\n\tcase PTR_TO_MAP_VALUE:\n\t\tif (!env->allow_ptr_leaks && !known && (smin_val < 0) != (smax_val < 0)) {\n\t\t\tverbose(env, \"R%d has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root\\n\",\n\t\t\t\toff_reg == dst_reg ? dst : src);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tfallthrough;\n\tdefault:\n\t\tbreak;\n\t}\n\n\t\/* In case of 'scalar += pointer', dst_reg inherits pointer type and id.\n\t * The id may be overwritten later if we create a new variable offset.\n\t *\/\n\tdst_reg->type = ptr_reg->type;\n\tdst_reg->id = ptr_reg->id;\n\n\tif (!check_reg_sane_offset(env, off_reg, ptr_reg->type) ||\n\t    !check_reg_sane_offset(env, ptr_reg, ptr_reg->type))\n\t\treturn -EINVAL;\n\n\t\/* pointer types do not carry 32-bit bounds at the moment. *\/\n\t__mark_reg32_unbounded(dst_reg);\n\n\tswitch (opcode) {\n\tcase BPF_ADD:\n\t\tret = sanitize_ptr_alu(env, insn, ptr_reg, dst_reg, smin_val < 0);\n\t\tif (ret < 0) {\n\t\t\tverbose(env, \"R%d tried to add from different maps or paths\\n\", dst);\n\t\t\treturn ret;\n\t\t}\n\t\t\/* We can take a fixed offset as long as it doesn't overflow\n\t\t * the s32 'off' field\n\t\t *\/\n\t\tif (known && (ptr_reg->off + smin_val ==\n\t\t\t      (s64)(s32)(ptr_reg->off + smin_val))) {\n\t\t\t\/* pointer += K.  Accumulate it into fixed offset *\/\n\t\t\tdst_reg->smin_value = smin_ptr;\n\t\t\tdst_reg->smax_value = smax_ptr;\n\t\t\tdst_reg->umin_value = umin_ptr;\n\t\t\tdst_reg->umax_value = umax_ptr;\n\t\t\tdst_reg->var_off = ptr_reg->var_off;\n\t\t\tdst_reg->off = ptr_reg->off + smin_val;\n\t\t\tdst_reg->raw = ptr_reg->raw;\n\t\t\tbreak;\n\t\t}\n\t\t\/* A new variable offset is created.  Note that off_reg->off\n\t\t * == 0, since it's a scalar.\n\t\t * dst_reg gets the pointer type and since some positive\n\t\t * integer value was added to the pointer, give it a new 'id'\n\t\t * if it's a PTR_TO_PACKET.\n\t\t * this creates a new 'base' pointer, off_reg (variable) gets\n\t\t * added into the variable offset, and we copy the fixed offset\n\t\t * from ptr_reg.\n\t\t *\/\n\t\tif (signed_add_overflows(smin_ptr, smin_val) ||\n\t\t    signed_add_overflows(smax_ptr, smax_val)) {\n\t\t\tdst_reg->smin_value = S64_MIN;\n\t\t\tdst_reg->smax_value = S64_MAX;\n\t\t} else {\n\t\t\tdst_reg->smin_value = smin_ptr + smin_val;\n\t\t\tdst_reg->smax_value = smax_ptr + smax_val;\n\t\t}\n\t\tif (umin_ptr + umin_val < umin_ptr ||\n\t\t    umax_ptr + umax_val < umax_ptr) {\n\t\t\tdst_reg->umin_value = 0;\n\t\t\tdst_reg->umax_value = U64_MAX;\n\t\t} else {\n\t\t\tdst_reg->umin_value = umin_ptr + umin_val;\n\t\t\tdst_reg->umax_value = umax_ptr + umax_val;\n\t\t}\n\t\tdst_reg->var_off = tnum_add(ptr_reg->var_off, off_reg->var_off);\n\t\tdst_reg->off = ptr_reg->off;\n\t\tdst_reg->raw = ptr_reg->raw;\n\t\tif (reg_is_pkt_pointer(ptr_reg)) {\n\t\t\tdst_reg->id = ++env->id_gen;\n\t\t\t\/* something was added to pkt_ptr, set range to zero *\/\n\t\t\tdst_reg->raw = 0;\n\t\t}\n\t\tbreak;\n\tcase BPF_SUB:\n\t\tret = sanitize_ptr_alu(env, insn, ptr_reg, dst_reg, smin_val < 0);\n\t\tif (ret < 0) {\n\t\t\tverbose(env, \"R%d tried to sub from different maps or paths\\n\", dst);\n\t\t\treturn ret;\n\t\t}\n\t\tif (dst_reg == off_reg) {\n\t\t\t\/* scalar -= pointer.  Creates an unknown scalar *\/\n\t\t\tverbose(env, \"R%d tried to subtract pointer from scalar\\n\",\n\t\t\t\tdst);\n\t\t\treturn -EACCES;\n\t\t}\n\t\t\/* We don't allow subtraction from FP, because (according to\n\t\t * test_verifier.c test \"invalid fp arithmetic\", JITs might not\n\t\t * be able to deal with it.\n\t\t *\/\n\t\tif (ptr_reg->type == PTR_TO_STACK) {\n\t\t\tverbose(env, \"R%d subtraction from stack pointer prohibited\\n\",\n\t\t\t\tdst);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tif (known && (ptr_reg->off - smin_val ==\n\t\t\t      (s64)(s32)(ptr_reg->off - smin_val))) {\n\t\t\t\/* pointer -= K.  Subtract it from fixed offset *\/\n\t\t\tdst_reg->smin_value = smin_ptr;\n\t\t\tdst_reg->smax_value = smax_ptr;\n\t\t\tdst_reg->umin_value = umin_ptr;\n\t\t\tdst_reg->umax_value = umax_ptr;\n\t\t\tdst_reg->var_off = ptr_reg->var_off;\n\t\t\tdst_reg->id = ptr_reg->id;\n\t\t\tdst_reg->off = ptr_reg->off - smin_val;\n\t\t\tdst_reg->raw = ptr_reg->raw;\n\t\t\tbreak;\n\t\t}\n\t\t\/* A new variable offset is created.  If the subtrahend is known\n\t\t * nonnegative, then any reg->range we had before is still good.\n\t\t *\/\n\t\tif (signed_sub_overflows(smin_ptr, smax_val) ||\n\t\t    signed_sub_overflows(smax_ptr, smin_val)) {\n\t\t\t\/* Overflow possible, we know nothing *\/\n\t\t\tdst_reg->smin_value = S64_MIN;\n\t\t\tdst_reg->smax_value = S64_MAX;\n\t\t} else {\n\t\t\tdst_reg->smin_value = smin_ptr - smax_val;\n\t\t\tdst_reg->smax_value = smax_ptr - smin_val;\n\t\t}\n\t\tif (umin_ptr < umax_val) {\n\t\t\t\/* Overflow possible, we know nothing *\/\n\t\t\tdst_reg->umin_value = 0;\n\t\t\tdst_reg->umax_value = U64_MAX;\n\t\t} else {\n\t\t\t\/* Cannot overflow (as long as bounds are consistent) *\/\n\t\t\tdst_reg->umin_value = umin_ptr - umax_val;\n\t\t\tdst_reg->umax_value = umax_ptr - umin_val;\n\t\t}\n\t\tdst_reg->var_off = tnum_sub(ptr_reg->var_off, off_reg->var_off);\n\t\tdst_reg->off = ptr_reg->off;\n\t\tdst_reg->raw = ptr_reg->raw;\n\t\tif (reg_is_pkt_pointer(ptr_reg)) {\n\t\t\tdst_reg->id = ++env->id_gen;\n\t\t\t\/* something was added to pkt_ptr, set range to zero *\/\n\t\t\tif (smin_val < 0)\n\t\t\t\tdst_reg->raw = 0;\n\t\t}\n\t\tbreak;\n\tcase BPF_AND:\n\tcase BPF_OR:\n\tcase BPF_XOR:\n\t\t\/* bitwise ops on pointers are troublesome, prohibit. *\/\n\t\tverbose(env, \"R%d bitwise operator %s on pointer prohibited\\n\",\n\t\t\tdst, bpf_alu_string[opcode >> 4]);\n\t\treturn -EACCES;\n\tdefault:\n\t\t\/* other operators (e.g. MUL,LSH) produce non-pointer results *\/\n\t\tverbose(env, \"R%d pointer arithmetic with %s operator prohibited\\n\",\n\t\t\tdst, bpf_alu_string[opcode >> 4]);\n\t\treturn -EACCES;\n\t}\n\n\tif (!check_reg_sane_offset(env, dst_reg, ptr_reg->type))\n\t\treturn -EINVAL;\n\n\t__update_reg_bounds(dst_reg);\n\t__reg_deduce_bounds(dst_reg);\n\t__reg_bound_offset(dst_reg);\n\n\t\/* For unprivileged we require that resulting offset must be in bounds\n\t * in order to be able to sanitize access later on.\n\t *\/\n\tif (!env->bypass_spec_v1) {\n\t\tif (dst_reg->type == PTR_TO_MAP_VALUE &&\n\t\t    check_map_access(env, dst, dst_reg->off, 1, false)) {\n\t\t\tverbose(env, \"R%d pointer arithmetic of map value goes out of range, \"\n\t\t\t\t\"prohibited for !root\\n\", dst);\n\t\t\treturn -EACCES;\n\t\t} else if (dst_reg->type == PTR_TO_STACK &&\n\t\t\t   check_stack_access(env, dst_reg, dst_reg->off +\n\t\t\t\t\t      dst_reg->var_off.value, 1)) {\n\t\t\tverbose(env, \"R%d stack pointer arithmetic goes out of range, \"\n\t\t\t\t\"prohibited for !root\\n\", dst);\n\t\t\treturn -EACCES;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":2522,"total_token_length":2758,"max_tokens_setting":4096}
+{"idx":508929,"func":"int ssl3_get_cert_verify(SSL *s)\n{\n    EVP_PKEY *pkey = NULL;\n    unsigned char *p;\n    int al, ok, ret = 0;\n    long n;\n    int type = 0, i, j;\n    X509 *peer;\n    const EVP_MD *md = NULL;\n    EVP_MD_CTX mctx;\n    EVP_MD_CTX_init(&mctx);\n\n    \/*\n     * We should only process a CertificateVerify message if we have received\n     * a Certificate from the client. If so then |s->session->peer| will be non\n     * NULL. In some instances a CertificateVerify message is not required even\n     * if the peer has sent a Certificate (e.g. such as in the case of static\n     * DH). In that case the ClientKeyExchange processing will skip the\n     * CertificateVerify state so we should not arrive here.\n     *\/\n    if (s->session->peer == NULL) {\n        ret = 1;\n        goto end;\n    }\n\n    n = s->method->ssl_get_message(s,\n                                   SSL3_ST_SR_CERT_VRFY_A,\n                                   SSL3_ST_SR_CERT_VRFY_B,\n                                   SSL3_MT_CERTIFICATE_VERIFY,\n                                   SSL3_RT_MAX_PLAIN_LENGTH, &ok);\n\n    if (!ok)\n        return ((int)n);\n\n    peer = s->session->peer;\n    pkey = X509_get_pubkey(peer);\n    type = X509_certificate_type(peer, pkey);\n\n    if (!(type & EVP_PKT_SIGN)) {\n        SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,\n               SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE);\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        goto f_err;\n    }\n\n    \/* we now have a signature that we need to verify *\/\n    p = (unsigned char *)s->init_msg;\n    \/* Check for broken implementations of GOST ciphersuites *\/\n    \/*\n     * If key is GOST and n is exactly 64, it is bare signature without\n     * length field\n     *\/\n    if (n == 64 && (pkey->type == NID_id_GostR3410_94 ||\n                    pkey->type == NID_id_GostR3410_2001)) {\n        i = 64;\n    } else {\n        if (TLS1_get_version(s) >= TLS1_2_VERSION) {\n            int sigalg = tls12_get_sigid(pkey);\n            \/* Should never happen *\/\n            if (sigalg == -1) {\n                SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR);\n                al = SSL_AD_INTERNAL_ERROR;\n                goto f_err;\n            }\n            \/* Check key type is consistent with signature *\/\n            if (sigalg != (int)p[1]) {\n                SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,\n                       SSL_R_WRONG_SIGNATURE_TYPE);\n                al = SSL_AD_DECODE_ERROR;\n                goto f_err;\n            }\n            md = tls12_get_hash(p[0]);\n            if (md == NULL) {\n                SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_UNKNOWN_DIGEST);\n                al = SSL_AD_DECODE_ERROR;\n                goto f_err;\n            }\n#ifdef SSL_DEBUG\n            fprintf(stderr, \"USING TLSv1.2 HASH %s\\n\", EVP_MD_name(md));\n#endif\n            p += 2;\n            n -= 2;\n        }\n        n2s(p, i);\n        n -= 2;\n        if (i > n) {\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_LENGTH_MISMATCH);\n            al = SSL_AD_DECODE_ERROR;\n            goto f_err;\n        }\n    }\n    j = EVP_PKEY_size(pkey);\n    if ((i > j) || (n > j) || (n <= 0)) {\n        SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_SIZE);\n        al = SSL_AD_DECODE_ERROR;\n        goto f_err;\n    }\n\n    if (TLS1_get_version(s) >= TLS1_2_VERSION) {\n        long hdatalen = 0;\n        void *hdata;\n        hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata);\n        if (hdatalen <= 0) {\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR);\n            al = SSL_AD_INTERNAL_ERROR;\n            goto f_err;\n        }\n#ifdef SSL_DEBUG\n        fprintf(stderr, \"Using TLS 1.2 with client verify alg %s\\n\",\n                EVP_MD_name(md));\n#endif\n        if (!EVP_VerifyInit_ex(&mctx, md, NULL)\n            || !EVP_VerifyUpdate(&mctx, hdata, hdatalen)) {\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_EVP_LIB);\n            al = SSL_AD_INTERNAL_ERROR;\n            goto f_err;\n        }\n\n        if (EVP_VerifyFinal(&mctx, p, i, pkey) <= 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_SIGNATURE);\n            goto f_err;\n        }\n    } else\n#ifndef OPENSSL_NO_RSA\n    if (pkey->type == EVP_PKEY_RSA) {\n        i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,\n                       MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i,\n                       pkey->pkey.rsa);\n        if (i < 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_RSA_DECRYPT);\n            goto f_err;\n        }\n        if (i == 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_RSA_SIGNATURE);\n            goto f_err;\n        }\n    } else\n#endif\n#ifndef OPENSSL_NO_DSA\n    if (pkey->type == EVP_PKEY_DSA) {\n        j = DSA_verify(pkey->save_type,\n                       &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]),\n                       SHA_DIGEST_LENGTH, p, i, pkey->pkey.dsa);\n        if (j <= 0) {\n            \/* bad signature *\/\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_DSA_SIGNATURE);\n            goto f_err;\n        }\n    } else\n#endif\n#ifndef OPENSSL_NO_ECDSA\n    if (pkey->type == EVP_PKEY_EC) {\n        j = ECDSA_verify(pkey->save_type,\n                         &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]),\n                         SHA_DIGEST_LENGTH, p, i, pkey->pkey.ec);\n        if (j <= 0) {\n            \/* bad signature *\/\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE);\n            goto f_err;\n        }\n    } else\n#endif\n    if (pkey->type == NID_id_GostR3410_94\n            || pkey->type == NID_id_GostR3410_2001) {\n        unsigned char signature[64];\n        int idx;\n        EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(pkey, NULL);\n        if (pctx == NULL) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_MALLOC_FAILURE);\n            goto f_err;\n        }\n        if (EVP_PKEY_verify_init(pctx) <= 0) {\n            EVP_PKEY_CTX_free(pctx);\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR);\n            goto f_err;\n        }\n        if (i != 64) {\n            fprintf(stderr, \"GOST signature length is %d\", i);\n        }\n        for (idx = 0; idx < 64; idx++) {\n            signature[63 - idx] = p[idx];\n        }\n        j = EVP_PKEY_verify(pctx, signature, 64, s->s3->tmp.cert_verify_md,\n                            32);\n        EVP_PKEY_CTX_free(pctx);\n        if (j <= 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE);\n            goto f_err;\n        }\n    } else {\n        SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR);\n        al = SSL_AD_UNSUPPORTED_CERTIFICATE;\n        goto f_err;\n    }\n\n    ret = 1;\n    if (0) {\n f_err:\n        ssl3_send_alert(s, SSL3_AL_FATAL, al);\n        s->state = SSL_ST_ERR;\n    }\n end:\n    if (s->s3->handshake_buffer) {\n        BIO_free(s->s3->handshake_buffer);\n        s->s3->handshake_buffer = NULL;\n        s->s3->flags &= ~TLS1_FLAGS_KEEP_HANDSHAKE;\n    }\n    EVP_MD_CTX_cleanup(&mctx);\n    EVP_PKEY_free(pkey);\n    return (ret);\n}","target":0,"code_token_length":1994,"total_token_length":2230,"max_tokens_setting":4096}
+{"idx":375431,"func":"WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,\n\t\t\t\t\t\t\tbool fetching_ckpt, XLogRecPtr tliRecPtr)\n{\n\tstatic pg_time_t last_fail_time = 0;\n\tpg_time_t\tnow;\n\n\t\/*-------\n\t * Standby mode is implemented by a state machine:\n\t *\n\t * 1. Read from either archive or pg_xlog (XLOG_FROM_ARCHIVE), or just\n\t *    pg_xlog (XLOG_FROM_XLOG)\n\t * 2. Check trigger file\n\t * 3. Read from primary server via walreceiver (XLOG_FROM_STREAM)\n\t * 4. Rescan timelines\n\t * 5. Sleep 5 seconds, and loop back to 1.\n\t *\n\t * Failure to read from the current source advances the state machine to\n\t * the next state.\n\t *\n\t * 'currentSource' indicates the current state. There are no currentSource\n\t * values for \"check trigger\", \"rescan timelines\", and \"sleep\" states,\n\t * those actions are taken when reading from the previous source fails, as\n\t * part of advancing to the next state.\n\t *-------\n\t *\/\n\tif (!InArchiveRecovery)\n\t\tcurrentSource = XLOG_FROM_PG_XLOG;\n\telse if (currentSource == 0)\n\t\tcurrentSource = XLOG_FROM_ARCHIVE;\n\n\tfor (;;)\n\t{\n\t\tint\t\t\toldSource = currentSource;\n\n\t\t\/*\n\t\t * First check if we failed to read from the current source, and\n\t\t * advance the state machine if so. The failure to read might've\n\t\t * happened outside this function, e.g when a CRC check fails on a\n\t\t * record, or within this loop.\n\t\t *\/\n\t\tif (lastSourceFailed)\n\t\t{\n\t\t\tswitch (currentSource)\n\t\t\t{\n\t\t\t\tcase XLOG_FROM_ARCHIVE:\n\t\t\t\tcase XLOG_FROM_PG_XLOG:\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Check to see if the trigger file exists. Note that we\n\t\t\t\t\t * do this only after failure, so when you create the\n\t\t\t\t\t * trigger file, we still finish replaying as much as we\n\t\t\t\t\t * can from archive and pg_xlog before failover.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (StandbyMode && CheckForStandbyTrigger())\n\t\t\t\t\t{\n\t\t\t\t\t\tShutdownWalRcv();\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Not in standby mode, and we've now tried the archive\n\t\t\t\t\t * and pg_xlog.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (!StandbyMode)\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If primary_conninfo is set, launch walreceiver to try\n\t\t\t\t\t * to stream the missing WAL.\n\t\t\t\t\t *\n\t\t\t\t\t * If fetching_ckpt is TRUE, RecPtr points to the initial\n\t\t\t\t\t * checkpoint location. In that case, we use RedoStartLSN\n\t\t\t\t\t * as the streaming start position instead of RecPtr, so\n\t\t\t\t\t * that when we later jump backwards to start redo at\n\t\t\t\t\t * RedoStartLSN, we will have the logs streamed already.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (PrimaryConnInfo)\n\t\t\t\t\t{\n\t\t\t\t\t\tXLogRecPtr\tptr;\n\t\t\t\t\t\tTimeLineID\ttli;\n\n\t\t\t\t\t\tif (fetching_ckpt)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tptr = RedoStartLSN;\n\t\t\t\t\t\t\ttli = ControlFile->checkPointCopy.ThisTimeLineID;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tptr = tliRecPtr;\n\t\t\t\t\t\t\ttli = tliOfPointInHistory(tliRecPtr, expectedTLEs);\n\n\t\t\t\t\t\t\tif (curFileTLI > 0 && tli < curFileTLI)\n\t\t\t\t\t\t\t\telog(ERROR, \"according to history file, WAL location %X\/%X belongs to timeline %u, but previous recovered WAL file came from timeline %u\",\n\t\t\t\t\t\t\t\t\t (uint32) (ptr >> 32), (uint32) ptr,\n\t\t\t\t\t\t\t\t\t tli, curFileTLI);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurFileTLI = tli;\n\t\t\t\t\t\tRequestXLogStreaming(tli, ptr, PrimaryConnInfo,\n\t\t\t\t\t\t\t\t\t\t\t PrimarySlotName);\n\t\t\t\t\t\treceivedUpto = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Move to XLOG_FROM_STREAM state in either case. We'll\n\t\t\t\t\t * get immediate failure if we didn't launch walreceiver,\n\t\t\t\t\t * and move on to the next state.\n\t\t\t\t\t *\/\n\t\t\t\t\tcurrentSource = XLOG_FROM_STREAM;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase XLOG_FROM_STREAM:\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Failure while streaming. Most likely, we got here\n\t\t\t\t\t * because streaming replication was terminated, or\n\t\t\t\t\t * promotion was triggered. But we also get here if we\n\t\t\t\t\t * find an invalid record in the WAL streamed from master,\n\t\t\t\t\t * in which case something is seriously wrong. There's\n\t\t\t\t\t * little chance that the problem will just go away, but\n\t\t\t\t\t * PANIC is not good for availability either, especially\n\t\t\t\t\t * in hot standby mode. So, we treat that the same as\n\t\t\t\t\t * disconnection, and retry from archive\/pg_xlog again.\n\t\t\t\t\t * The WAL in the archive should be identical to what was\n\t\t\t\t\t * streamed, so it's unlikely that it helps, but one can\n\t\t\t\t\t * hope...\n\t\t\t\t\t *\/\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Before we leave XLOG_FROM_STREAM state, make sure that\n\t\t\t\t\t * walreceiver is not active, so that it won't overwrite\n\t\t\t\t\t * WAL that we restore from archive.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (WalRcvStreaming())\n\t\t\t\t\t\tShutdownWalRcv();\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Before we sleep, re-scan for possible new timelines if\n\t\t\t\t\t * we were requested to recover to the latest timeline.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (recoveryTargetIsLatest)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (rescanLatestTimeLine())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcurrentSource = XLOG_FROM_ARCHIVE;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * XLOG_FROM_STREAM is the last state in our state\n\t\t\t\t\t * machine, so we've exhausted all the options for\n\t\t\t\t\t * obtaining the requested WAL. We're going to loop back\n\t\t\t\t\t * and retry from the archive, but if it hasn't been long\n\t\t\t\t\t * since last attempt, sleep 5 seconds to avoid\n\t\t\t\t\t * busy-waiting.\n\t\t\t\t\t *\/\n\t\t\t\t\tnow = (pg_time_t) time(NULL);\n\t\t\t\t\tif ((now - last_fail_time) < 5)\n\t\t\t\t\t{\n\t\t\t\t\t\tpg_usleep(1000000L * (5 - (now - last_fail_time)));\n\t\t\t\t\t\tnow = (pg_time_t) time(NULL);\n\t\t\t\t\t}\n\t\t\t\t\tlast_fail_time = now;\n\t\t\t\t\tcurrentSource = XLOG_FROM_ARCHIVE;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\telog(ERROR, \"unexpected WAL source %d\", currentSource);\n\t\t\t}\n\t\t}\n\t\telse if (currentSource == XLOG_FROM_PG_XLOG)\n\t\t{\n\t\t\t\/*\n\t\t\t * We just successfully read a file in pg_xlog. We prefer files in\n\t\t\t * the archive over ones in pg_xlog, so try the next file again\n\t\t\t * from the archive first.\n\t\t\t *\/\n\t\t\tif (InArchiveRecovery)\n\t\t\t\tcurrentSource = XLOG_FROM_ARCHIVE;\n\t\t}\n\n\t\tif (currentSource != oldSource)\n\t\t\telog(DEBUG2, \"switched WAL source from %s to %s after %s\",\n\t\t\t\t xlogSourceNames[oldSource], xlogSourceNames[currentSource],\n\t\t\t\t lastSourceFailed ? \"failure\" : \"success\");\n\n\t\t\/*\n\t\t * We've now handled possible failure. Try to read from the chosen\n\t\t * source.\n\t\t *\/\n\t\tlastSourceFailed = false;\n\n\t\tswitch (currentSource)\n\t\t{\n\t\t\tcase XLOG_FROM_ARCHIVE:\n\t\t\tcase XLOG_FROM_PG_XLOG:\n\t\t\t\t\/* Close any old file we might have open. *\/\n\t\t\t\tif (readFile >= 0)\n\t\t\t\t{\n\t\t\t\t\tclose(readFile);\n\t\t\t\t\treadFile = -1;\n\t\t\t\t}\n\t\t\t\t\/* Reset curFileTLI if random fetch. *\/\n\t\t\t\tif (randAccess)\n\t\t\t\t\tcurFileTLI = 0;\n\n\t\t\t\t\/*\n\t\t\t\t * Try to restore the file from archive, or read an existing\n\t\t\t\t * file from pg_xlog.\n\t\t\t\t *\/\n\t\t\t\treadFile = XLogFileReadAnyTLI(readSegNo, DEBUG2,\n\t\t\t\t\t\tcurrentSource == XLOG_FROM_ARCHIVE ? XLOG_FROM_ANY :\n\t\t\t\t\t\t\t\t\t\t currentSource);\n\t\t\t\tif (readFile >= 0)\n\t\t\t\t\treturn true;\t\/* success! *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Nope, not found in archive or pg_xlog.\n\t\t\t\t *\/\n\t\t\t\tlastSourceFailed = true;\n\t\t\t\tbreak;\n\n\t\t\tcase XLOG_FROM_STREAM:\n\t\t\t\t{\n\t\t\t\t\tbool\t\thavedata;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Check if WAL receiver is still active.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (!WalRcvStreaming())\n\t\t\t\t\t{\n\t\t\t\t\t\tlastSourceFailed = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Walreceiver is active, so see if new data has arrived.\n\t\t\t\t\t *\n\t\t\t\t\t * We only advance XLogReceiptTime when we obtain fresh\n\t\t\t\t\t * WAL from walreceiver and observe that we had already\n\t\t\t\t\t * processed everything before the most recent \"chunk\"\n\t\t\t\t\t * that it flushed to disk.  In steady state where we are\n\t\t\t\t\t * keeping up with the incoming data, XLogReceiptTime will\n\t\t\t\t\t * be updated on each cycle. When we are behind,\n\t\t\t\t\t * XLogReceiptTime will not advance, so the grace time\n\t\t\t\t\t * allotted to conflicting queries will decrease.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (RecPtr < receivedUpto)\n\t\t\t\t\t\thavedata = true;\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tXLogRecPtr\tlatestChunkStart;\n\n\t\t\t\t\t\treceivedUpto = GetWalRcvWriteRecPtr(&latestChunkStart, &receiveTLI);\n\t\t\t\t\t\tif (RecPtr < receivedUpto && receiveTLI == curFileTLI)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thavedata = true;\n\t\t\t\t\t\t\tif (latestChunkStart <= RecPtr)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tXLogReceiptTime = GetCurrentTimestamp();\n\t\t\t\t\t\t\t\tSetCurrentChunkStartTime(XLogReceiptTime);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\thavedata = false;\n\t\t\t\t\t}\n\t\t\t\t\tif (havedata)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Great, streamed far enough.\tOpen the file if it's\n\t\t\t\t\t\t * not open already.  Also read the timeline history\n\t\t\t\t\t\t * file if we haven't initialized timeline history\n\t\t\t\t\t\t * yet; it should be streamed over and present in\n\t\t\t\t\t\t * pg_xlog by now.\tUse XLOG_FROM_STREAM so that\n\t\t\t\t\t\t * source info is set correctly and XLogReceiptTime\n\t\t\t\t\t\t * isn't changed.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (readFile < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (!expectedTLEs)\n\t\t\t\t\t\t\t\texpectedTLEs = readTimeLineHistory(receiveTLI);\n\t\t\t\t\t\t\treadFile = XLogFileRead(readSegNo, PANIC,\n\t\t\t\t\t\t\t\t\t\t\t\t\treceiveTLI,\n\t\t\t\t\t\t\t\t\t\t\t\t\tXLOG_FROM_STREAM, false);\n\t\t\t\t\t\t\tAssert(readFile >= 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* just make sure source info is correct... *\/\n\t\t\t\t\t\t\treadSource = XLOG_FROM_STREAM;\n\t\t\t\t\t\t\tXLogReceiptSource = XLOG_FROM_STREAM;\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Data not here yet. Check for trigger, then wait for\n\t\t\t\t\t * walreceiver to wake us up when new WAL arrives.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (CheckForStandbyTrigger())\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Note that we don't \"return false\" immediately here.\n\t\t\t\t\t\t * After being triggered, we still want to replay all\n\t\t\t\t\t\t * the WAL that was already streamed. It's in pg_xlog\n\t\t\t\t\t\t * now, so we just treat this as a failure, and the\n\t\t\t\t\t\t * state machine will move on to replay the streamed\n\t\t\t\t\t\t * WAL from pg_xlog, and then recheck the trigger and\n\t\t\t\t\t\t * exit replay.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tlastSourceFailed = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Wait for more WAL to arrive. Time out after 5 seconds,\n\t\t\t\t\t * like when polling the archive, to react to a trigger\n\t\t\t\t\t * file promptly.\n\t\t\t\t\t *\/\n\t\t\t\t\tWaitLatch(&XLogCtl->recoveryWakeupLatch,\n\t\t\t\t\t\t\t  WL_LATCH_SET | WL_TIMEOUT,\n\t\t\t\t\t\t\t  5000L);\n\t\t\t\t\tResetLatch(&XLogCtl->recoveryWakeupLatch);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\telog(ERROR, \"unexpected WAL source %d\", currentSource);\n\t\t}\n\n\t\t\/*\n\t\t * This possibly-long loop needs to handle interrupts of startup\n\t\t * process.\n\t\t *\/\n\t\tHandleStartupProcInterrupts();\n\t} while (StandbyMode);\n\n\treturn false;\n}","target":0,"code_token_length":2635,"total_token_length":2871,"max_tokens_setting":4096}
+{"idx":81259,"func":"struct inode *ext4_iget(struct super_block *sb, unsigned long ino)\n{\n\tstruct ext4_iloc iloc;\n\tstruct ext4_inode *raw_inode;\n\tstruct ext4_inode_info *ei;\n\tstruct inode *inode;\n\tjournal_t *journal = EXT4_SB(sb)->s_journal;\n\tlong ret;\n\tint block;\n\tuid_t i_uid;\n\tgid_t i_gid;\n\tprojid_t i_projid;\n\n\tinode = iget_locked(sb, ino);\n\tif (!inode)\n\t\treturn ERR_PTR(-ENOMEM);\n\tif (!(inode->i_state & I_NEW))\n\t\treturn inode;\n\n\tei = EXT4_I(inode);\n\tiloc.bh = NULL;\n\n\tret = __ext4_get_inode_loc(inode, &iloc, 0);\n\tif (ret < 0)\n\t\tgoto bad_inode;\n\traw_inode = ext4_raw_inode(&iloc);\n\n\tif (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {\n\t\tei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);\n\t\tif (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >\n\t\t    EXT4_INODE_SIZE(inode->i_sb)) {\n\t\t\tEXT4_ERROR_INODE(inode, \"bad extra_isize (%u != %u)\",\n\t\t\t\tEXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize,\n\t\t\t\tEXT4_INODE_SIZE(inode->i_sb));\n\t\t\tret = -EFSCORRUPTED;\n\t\t\tgoto bad_inode;\n\t\t}\n\t} else\n\t\tei->i_extra_isize = 0;\n\n\t\/* Precompute checksum seed for inode metadata *\/\n\tif (ext4_has_metadata_csum(sb)) {\n\t\tstruct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);\n\t\t__u32 csum;\n\t\t__le32 inum = cpu_to_le32(inode->i_ino);\n\t\t__le32 gen = raw_inode->i_generation;\n\t\tcsum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum,\n\t\t\t\t   sizeof(inum));\n\t\tei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen,\n\t\t\t\t\t      sizeof(gen));\n\t}\n\n\tif (!ext4_inode_csum_verify(inode, raw_inode, ei)) {\n\t\tEXT4_ERROR_INODE(inode, \"checksum invalid\");\n\t\tret = -EFSBADCRC;\n\t\tgoto bad_inode;\n\t}\n\n\tinode->i_mode = le16_to_cpu(raw_inode->i_mode);\n\ti_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);\n\ti_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);\n\tif (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_PROJECT) &&\n\t    EXT4_INODE_SIZE(sb) > EXT4_GOOD_OLD_INODE_SIZE &&\n\t    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))\n\t\ti_projid = (projid_t)le32_to_cpu(raw_inode->i_projid);\n\telse\n\t\ti_projid = EXT4_DEF_PROJID;\n\n\tif (!(test_opt(inode->i_sb, NO_UID32))) {\n\t\ti_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;\n\t\ti_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;\n\t}\n\ti_uid_write(inode, i_uid);\n\ti_gid_write(inode, i_gid);\n\tei->i_projid = make_kprojid(&init_user_ns, i_projid);\n\tset_nlink(inode, le16_to_cpu(raw_inode->i_links_count));\n\n\text4_clear_state_flags(ei);\t\/* Only relevant on 32-bit archs *\/\n\tei->i_inline_off = 0;\n\tei->i_dir_start_lookup = 0;\n\tei->i_dtime = le32_to_cpu(raw_inode->i_dtime);\n\t\/* We now have enough fields to check if the inode was active or not.\n\t * This is needed because nfsd might try to access dead inodes\n\t * the test is that same one that e2fsck uses\n\t * NeilBrown 1999oct15\n\t *\/\n\tif (inode->i_nlink == 0) {\n\t\tif ((inode->i_mode == 0 ||\n\t\t     !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) &&\n\t\t    ino != EXT4_BOOT_LOADER_INO) {\n\t\t\t\/* this inode is deleted *\/\n\t\t\tret = -ESTALE;\n\t\t\tgoto bad_inode;\n\t\t}\n\t\t\/* The only unlinked inodes we let through here have\n\t\t * valid i_mode and are being read by the orphan\n\t\t * recovery code: that's fine, we're about to complete\n\t\t * the process of deleting those.\n\t\t * OR it is the EXT4_BOOT_LOADER_INO which is\n\t\t * not initialized on a new filesystem. *\/\n\t}\n\tei->i_flags = le32_to_cpu(raw_inode->i_flags);\n\tinode->i_blocks = ext4_inode_blocks(raw_inode, ei);\n\tei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl_lo);\n\tif (ext4_has_feature_64bit(sb))\n\t\tei->i_file_acl |=\n\t\t\t((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;\n\tinode->i_size = ext4_isize(raw_inode);\n\tei->i_disksize = inode->i_size;\n#ifdef CONFIG_QUOTA\n\tei->i_reserved_quota = 0;\n#endif\n\tinode->i_generation = le32_to_cpu(raw_inode->i_generation);\n\tei->i_block_group = iloc.block_group;\n\tei->i_last_alloc_group = ~0;\n\t\/*\n\t * NOTE! The in-memory inode i_data array is in little-endian order\n\t * even on big-endian machines: we do NOT byteswap the block numbers!\n\t *\/\n\tfor (block = 0; block < EXT4_N_BLOCKS; block++)\n\t\tei->i_data[block] = raw_inode->i_block[block];\n\tINIT_LIST_HEAD(&ei->i_orphan);\n\n\t\/*\n\t * Set transaction id's of transactions that have to be committed\n\t * to finish f[data]sync. We set them to currently running transaction\n\t * as we cannot be sure that the inode or some of its metadata isn't\n\t * part of the transaction - the inode could have been reclaimed and\n\t * now it is reread from disk.\n\t *\/\n\tif (journal) {\n\t\ttransaction_t *transaction;\n\t\ttid_t tid;\n\n\t\tread_lock(&journal->j_state_lock);\n\t\tif (journal->j_running_transaction)\n\t\t\ttransaction = journal->j_running_transaction;\n\t\telse\n\t\t\ttransaction = journal->j_committing_transaction;\n\t\tif (transaction)\n\t\t\ttid = transaction->t_tid;\n\t\telse\n\t\t\ttid = journal->j_commit_sequence;\n\t\tread_unlock(&journal->j_state_lock);\n\t\tei->i_sync_tid = tid;\n\t\tei->i_datasync_tid = tid;\n\t}\n\n\tif (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {\n\t\tif (ei->i_extra_isize == 0) {\n\t\t\t\/* The extra space is currently unused. Use it. *\/\n\t\t\tei->i_extra_isize = sizeof(struct ext4_inode) -\n\t\t\t\t\t    EXT4_GOOD_OLD_INODE_SIZE;\n\t\t} else {\n\t\t\text4_iget_extra_inode(inode, raw_inode, ei);\n\t\t}\n\t}\n\n\tEXT4_INODE_GET_XTIME(i_ctime, inode, raw_inode);\n\tEXT4_INODE_GET_XTIME(i_mtime, inode, raw_inode);\n\tEXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);\n\tEXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);\n\n\tif (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {\n\t\tinode->i_version = le32_to_cpu(raw_inode->i_disk_version);\n\t\tif (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {\n\t\t\tif (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))\n\t\t\t\tinode->i_version |=\n\t\t    (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;\n\t\t}\n\t}\n\n\tret = 0;\n\tif (ei->i_file_acl &&\n\t    !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {\n\t\tEXT4_ERROR_INODE(inode, \"bad extended attribute block %llu\",\n\t\t\t\t ei->i_file_acl);\n\t\tret = -EFSCORRUPTED;\n\t\tgoto bad_inode;\n\t} else if (!ext4_has_inline_data(inode)) {\n\t\tif (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {\n\t\t\tif ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||\n\t\t\t    (S_ISLNK(inode->i_mode) &&\n\t\t\t     !ext4_inode_is_fast_symlink(inode))))\n\t\t\t\t\/* Validate extent which is part of inode *\/\n\t\t\t\tret = ext4_ext_check_inode(inode);\n\t\t} else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||\n\t\t\t   (S_ISLNK(inode->i_mode) &&\n\t\t\t    !ext4_inode_is_fast_symlink(inode))) {\n\t\t\t\/* Validate block references which are part of inode *\/\n\t\t\tret = ext4_ind_check_inode(inode);\n\t\t}\n\t}\n\tif (ret)\n\t\tgoto bad_inode;\n\n\tif (S_ISREG(inode->i_mode)) {\n\t\tinode->i_op = &ext4_file_inode_operations;\n\t\tinode->i_fop = &ext4_file_operations;\n\t\text4_set_aops(inode);\n\t} else if (S_ISDIR(inode->i_mode)) {\n\t\tinode->i_op = &ext4_dir_inode_operations;\n\t\tinode->i_fop = &ext4_dir_operations;\n\t} else if (S_ISLNK(inode->i_mode)) {\n\t\tif (ext4_encrypted_inode(inode)) {\n\t\t\tinode->i_op = &ext4_encrypted_symlink_inode_operations;\n\t\t\text4_set_aops(inode);\n\t\t} else if (ext4_inode_is_fast_symlink(inode)) {\n\t\t\tinode->i_link = (char *)ei->i_data;\n\t\t\tinode->i_op = &ext4_fast_symlink_inode_operations;\n\t\t\tnd_terminate_link(ei->i_data, inode->i_size,\n\t\t\t\tsizeof(ei->i_data) - 1);\n\t\t} else {\n\t\t\tinode->i_op = &ext4_symlink_inode_operations;\n\t\t\text4_set_aops(inode);\n\t\t}\n\t\tinode_nohighmem(inode);\n\t} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||\n\t      S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {\n\t\tinode->i_op = &ext4_special_inode_operations;\n\t\tif (raw_inode->i_block[0])\n\t\t\tinit_special_inode(inode, inode->i_mode,\n\t\t\t   old_decode_dev(le32_to_cpu(raw_inode->i_block[0])));\n\t\telse\n\t\t\tinit_special_inode(inode, inode->i_mode,\n\t\t\t   new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));\n\t} else if (ino == EXT4_BOOT_LOADER_INO) {\n\t\tmake_bad_inode(inode);\n\t} else {\n\t\tret = -EFSCORRUPTED;\n\t\tEXT4_ERROR_INODE(inode, \"bogus i_mode (%o)\", inode->i_mode);\n\t\tgoto bad_inode;\n\t}\n\tbrelse(iloc.bh);\n\text4_set_inode_flags(inode);\n\tunlock_new_inode(inode);\n\treturn inode;\n\nbad_inode:\n\tbrelse(iloc.bh);\n\tiget_failed(inode);\n\treturn ERR_PTR(ret);\n}","target":0,"code_token_length":2564,"total_token_length":2800,"max_tokens_setting":4096}
+{"idx":453082,"func":"static MagickBooleanType Classify(Image *image,short **extrema,\n  const double cluster_threshold,\n  const double weighting_exponent,const MagickBooleanType verbose,\n  ExceptionInfo *exception)\n{\n#define SegmentImageTag  \"Segment\/Image\"\n#define ThrowClassifyException(severity,tag,label) \\\n{\\\n  for (cluster=head; cluster != (Cluster *) NULL; cluster=next_cluster) \\\n  { \\\n    next_cluster=cluster->next; \\\n    cluster=(Cluster *) RelinquishMagickMemory(cluster); \\\n  } \\\n  if (squares != (double *) NULL) \\\n    { \\\n      squares-=255; \\\n      free_squares=squares; \\\n      free_squares=(double *) RelinquishMagickMemory(free_squares); \\\n    } \\\n  ThrowBinaryException(severity,tag,label); \\\n}\n\n  CacheView\n    *image_view;\n\n  Cluster\n    *cluster,\n    *head,\n    *last_cluster,\n    *next_cluster;\n\n  ExtentPacket\n    blue,\n    green,\n    red;\n\n  MagickOffsetType\n    progress;\n\n  double\n    *free_squares;\n\n  MagickStatusType\n    status;\n\n  register ssize_t\n    i;\n\n  register double\n    *squares;\n\n  size_t\n    number_clusters;\n\n  ssize_t\n    count,\n    y;\n\n  \/*\n    Form clusters.\n  *\/\n  cluster=(Cluster *) NULL;\n  head=(Cluster *) NULL;\n  squares=(double *) NULL;\n  (void) memset(&red,0,sizeof(red));\n  (void) memset(&green,0,sizeof(green));\n  (void) memset(&blue,0,sizeof(blue));\n  while (DefineRegion(extrema[Red],&red) != 0)\n  {\n    green.index=0;\n    while (DefineRegion(extrema[Green],&green) != 0)\n    {\n      blue.index=0;\n      while (DefineRegion(extrema[Blue],&blue) != 0)\n      {\n        \/*\n          Allocate a new class.\n        *\/\n        if (head != (Cluster *) NULL)\n          {\n            cluster->next=(Cluster *) AcquireMagickMemory(\n              sizeof(*cluster->next));\n            cluster=cluster->next;\n          }\n        else\n          {\n            cluster=(Cluster *) AcquireMagickMemory(sizeof(*cluster));\n            head=cluster;\n          }\n        if (cluster == (Cluster *) NULL)\n          ThrowClassifyException(ResourceLimitError,\"MemoryAllocationFailed\",\n            image->filename);\n        \/*\n          Initialize a new class.\n        *\/\n        cluster->count=0;\n        cluster->red=red;\n        cluster->green=green;\n        cluster->blue=blue;\n        cluster->next=(Cluster *) NULL;\n      }\n    }\n  }\n  if (head == (Cluster *) NULL)\n    {\n      \/*\n        No classes were identified-- create one.\n      *\/\n      cluster=(Cluster *) AcquireMagickMemory(sizeof(*cluster));\n      if (cluster == (Cluster *) NULL)\n        ThrowClassifyException(ResourceLimitError,\"MemoryAllocationFailed\",\n          image->filename);\n      \/*\n        Initialize a new class.\n      *\/\n      cluster->count=0;\n      cluster->red=red;\n      cluster->green=green;\n      cluster->blue=blue;\n      cluster->next=(Cluster *) NULL;\n      head=cluster;\n    }\n  \/*\n    Count the pixels for each cluster.\n  *\/\n  status=MagickTrue;\n  count=0;\n  progress=0;\n  image_view=AcquireVirtualCacheView(image,exception);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    register const Quantum\n      *p;\n\n    register ssize_t\n      x;\n\n    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);\n    if (p == (const Quantum *) NULL)\n      break;\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)\n        if (((ssize_t) ScaleQuantumToChar(GetPixelRed(image,p)) >=\n             (cluster->red.left-SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelRed(image,p)) <=\n             (cluster->red.right+SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelGreen(image,p)) >=\n             (cluster->green.left-SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelGreen(image,p)) <=\n             (cluster->green.right+SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelBlue(image,p)) >=\n             (cluster->blue.left-SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelBlue(image,p)) <=\n             (cluster->blue.right+SafeMargin)))\n          {\n            \/*\n              Count this pixel.\n            *\/\n            count++;\n            cluster->red.center+=(double) ScaleQuantumToChar(\n              GetPixelRed(image,p));\n            cluster->green.center+=(double) ScaleQuantumToChar(\n              GetPixelGreen(image,p));\n            cluster->blue.center+=(double) ScaleQuantumToChar(\n              GetPixelBlue(image,p));\n            cluster->count++;\n            break;\n          }\n      p+=GetPixelChannels(image);\n    }\n    if (image->progress_monitor != (MagickProgressMonitor) NULL)\n      {\n        MagickBooleanType\n          proceed;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n        #pragma omp atomic\n#endif\n        progress++;\n        proceed=SetImageProgress(image,SegmentImageTag,progress,2*image->rows);\n        if (proceed == MagickFalse)\n          status=MagickFalse;\n      }\n  }\n  image_view=DestroyCacheView(image_view);\n  \/*\n    Remove clusters that do not meet minimum cluster threshold.\n  *\/\n  count=0;\n  last_cluster=head;\n  next_cluster=head;\n  for (cluster=head; cluster != (Cluster *) NULL; cluster=next_cluster)\n  {\n    next_cluster=cluster->next;\n    if ((cluster->count > 0) &&\n        (cluster->count >= (count*cluster_threshold\/100.0)))\n      {\n        \/*\n          Initialize cluster.\n        *\/\n        cluster->id=count;\n        cluster->red.center\/=cluster->count;\n        cluster->green.center\/=cluster->count;\n        cluster->blue.center\/=cluster->count;\n        count++;\n        last_cluster=cluster;\n        continue;\n      }\n    \/*\n      Delete cluster.\n    *\/\n    if (cluster == head)\n      head=next_cluster;\n    else\n      last_cluster->next=next_cluster;\n    cluster=(Cluster *) RelinquishMagickMemory(cluster);\n  }\n  number_clusters=(size_t) count;\n  if (verbose != MagickFalse)\n    {\n      \/*\n        Print cluster statistics.\n      *\/\n      (void) FormatLocaleFile(stdout,\"Fuzzy C-means Statistics\\n\");\n      (void) FormatLocaleFile(stdout,\"===================\\n\\n\");\n      (void) FormatLocaleFile(stdout,\"\\tCluster Threshold = %g\\n\",(double)\n        cluster_threshold);\n      (void) FormatLocaleFile(stdout,\"\\tWeighting Exponent = %g\\n\",(double)\n        weighting_exponent);\n      (void) FormatLocaleFile(stdout,\"\\tTotal Number of Clusters = %.20g\\n\\n\",\n        (double) number_clusters);\n      \/*\n        Print the total number of points per cluster.\n      *\/\n      (void) FormatLocaleFile(stdout,\"\\n\\nNumber of Vectors Per Cluster\\n\");\n      (void) FormatLocaleFile(stdout,\"=============================\\n\\n\");\n      for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)\n        (void) FormatLocaleFile(stdout,\"Cluster #%.20g = %.20g\\n\",(double)\n          cluster->id,(double) cluster->count);\n      \/*\n        Print the cluster extents.\n      *\/\n      (void) FormatLocaleFile(stdout,\n        \"\\n\\n\\nCluster Extents:        (Vector Size: %d)\\n\",MaxDimension);\n      (void) FormatLocaleFile(stdout,\"================\");\n      for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)\n      {\n        (void) FormatLocaleFile(stdout,\"\\n\\nCluster #%.20g\\n\\n\",(double)\n          cluster->id);\n        (void) FormatLocaleFile(stdout,\n          \"%.20g-%.20g  %.20g-%.20g  %.20g-%.20g\\n\",(double)\n          cluster->red.left,(double) cluster->red.right,(double)\n          cluster->green.left,(double) cluster->green.right,(double)\n          cluster->blue.left,(double) cluster->blue.right);\n      }\n      \/*\n        Print the cluster center values.\n      *\/\n      (void) FormatLocaleFile(stdout,\n        \"\\n\\n\\nCluster Center Values:        (Vector Size: %d)\\n\",MaxDimension);\n      (void) FormatLocaleFile(stdout,\"=====================\");\n      for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)\n      {\n        (void) FormatLocaleFile(stdout,\"\\n\\nCluster #%.20g\\n\\n\",(double)\n          cluster->id);\n        (void) FormatLocaleFile(stdout,\"%g  %g  %g\\n\",(double)\n          cluster->red.center,(double) cluster->green.center,(double)\n          cluster->blue.center);\n      }\n      (void) FormatLocaleFile(stdout,\"\\n\");\n    }\n  if (number_clusters > 256)\n    ThrowClassifyException(ImageError,\"TooManyClusters\",image->filename);\n  \/*\n    Speed up distance calculations.\n  *\/\n  squares=(double *) AcquireQuantumMemory(513UL,sizeof(*squares));\n  if (squares == (double *) NULL)\n    ThrowClassifyException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  squares+=255;\n  for (i=(-255); i <= 255; i++)\n    squares[i]=(double) i*(double) i;\n  \/*\n    Allocate image colormap.\n  *\/\n  if (AcquireImageColormap(image,number_clusters,exception) == MagickFalse)\n    ThrowClassifyException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  i=0;\n  for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)\n  {\n    image->colormap[i].red=(double) ScaleCharToQuantum((unsigned char)\n      (cluster->red.center+0.5));\n    image->colormap[i].green=(double) ScaleCharToQuantum((unsigned char)\n      (cluster->green.center+0.5));\n    image->colormap[i].blue=(double) ScaleCharToQuantum((unsigned char)\n      (cluster->blue.center+0.5));\n    i++;\n  }\n  \/*\n    Do course grain classes.\n  *\/\n  image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n  #pragma omp parallel for schedule(static) shared(progress,status) \\\n    magick_number_threads(image,image,image->rows,1)\n#endif\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    Cluster\n      *clust;\n\n    register const PixelInfo\n      *magick_restrict p;\n\n    register ssize_t\n      x;\n\n    register Quantum\n      *magick_restrict q;\n\n    if (status == MagickFalse)\n      continue;\n    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      {\n        status=MagickFalse;\n        continue;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      SetPixelIndex(image,(Quantum) 0,q);\n      for (clust=head; clust != (Cluster *) NULL; clust=clust->next)\n      {\n        if (((ssize_t) ScaleQuantumToChar(GetPixelRed(image,q)) >=\n             (clust->red.left-SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelRed(image,q)) <=\n             (clust->red.right+SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelGreen(image,q)) >=\n             (clust->green.left-SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelGreen(image,q)) <=\n             (clust->green.right+SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelBlue(image,q)) >=\n             (clust->blue.left-SafeMargin)) &&\n            ((ssize_t) ScaleQuantumToChar(GetPixelBlue(image,q)) <=\n             (clust->blue.right+SafeMargin)))\n          {\n            \/*\n              Classify this pixel.\n            *\/\n            SetPixelIndex(image,(Quantum) clust->id,q);\n            break;\n          }\n      }\n      if (clust == (Cluster *) NULL)\n        {\n          double\n            distance_squared,\n            local_minima,\n            numerator,\n            ratio,\n            sum;\n\n          register ssize_t\n            j,\n            k;\n\n          \/*\n            Compute fuzzy membership.\n          *\/\n          local_minima=0.0;\n          for (j=0; j < (ssize_t) image->colors; j++)\n          {\n            sum=0.0;\n            p=image->colormap+j;\n            distance_squared=squares[(ssize_t) ScaleQuantumToChar(\n              GetPixelRed(image,q))-(ssize_t)\n              ScaleQuantumToChar(ClampToQuantum(p->red))]+squares[(ssize_t)\n              ScaleQuantumToChar(GetPixelGreen(image,q))-(ssize_t)\n              ScaleQuantumToChar(ClampToQuantum(p->green))]+squares[(ssize_t)\n              ScaleQuantumToChar(GetPixelBlue(image,q))-(ssize_t)\n              ScaleQuantumToChar(ClampToQuantum(p->blue))];\n            numerator=distance_squared;\n            for (k=0; k < (ssize_t) image->colors; k++)\n            {\n              p=image->colormap+k;\n                distance_squared=squares[(ssize_t) ScaleQuantumToChar(\n                  GetPixelRed(image,q))-(ssize_t)\n                  ScaleQuantumToChar(ClampToQuantum(p->red))]+squares[\n                  (ssize_t) ScaleQuantumToChar(GetPixelGreen(image,q))-(ssize_t)\n                  ScaleQuantumToChar(ClampToQuantum(p->green))]+squares[\n                  (ssize_t) ScaleQuantumToChar(GetPixelBlue(image,q))-(ssize_t)\n                  ScaleQuantumToChar(ClampToQuantum(p->blue))];\n              ratio=numerator\/distance_squared;\n              sum+=SegmentPower(ratio);\n            }\n            if ((sum != 0.0) && ((1.0\/sum) > local_minima))\n              {\n                \/*\n                  Classify this pixel.\n                *\/\n                local_minima=1.0\/sum;\n                SetPixelIndex(image,(Quantum) j,q);\n              }\n          }\n        }\n      q+=GetPixelChannels(image);\n    }\n    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n      status=MagickFalse;\n    if (image->progress_monitor != (MagickProgressMonitor) NULL)\n      {\n        MagickBooleanType\n          proceed;\n\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n        #pragma omp atomic\n#endif\n        progress++;\n        proceed=SetImageProgress(image,SegmentImageTag,progress,2*image->rows);\n        if (proceed == MagickFalse)\n          status=MagickFalse;\n      }\n  }\n  image_view=DestroyCacheView(image_view);\n  status&=SyncImage(image,exception);\n  \/*\n    Relinquish resources.\n  *\/\n  for (cluster=head; cluster != (Cluster *) NULL; cluster=next_cluster)\n  {\n    next_cluster=cluster->next;\n    cluster=(Cluster *) RelinquishMagickMemory(cluster);\n  }\n  squares-=255;\n  free_squares=squares;\n  free_squares=(double *) RelinquishMagickMemory(free_squares);\n  return(MagickTrue);\n}","target":0,"code_token_length":3431,"total_token_length":3667,"max_tokens_setting":4096}
+{"idx":343215,"func":"void mips_cpu_do_interrupt(CPUState *cs)\n\n{\n\n#if !defined(CONFIG_USER_ONLY)\n\n    MIPSCPU *cpu = MIPS_CPU(cs);\n\n    CPUMIPSState *env = &cpu->env;\n\n    target_ulong offset;\n\n    int cause = -1;\n\n    const char *name;\n\n\n\n    if (qemu_log_enabled() && cs->exception_index != EXCP_EXT_INTERRUPT) {\n\n        if (cs->exception_index < 0 || cs->exception_index > EXCP_LAST) {\n\n            name = \"unknown\";\n\n        } else {\n\n            name = excp_names[cs->exception_index];\n\n        }\n\n\n\n        qemu_log(\"%s enter: PC \" TARGET_FMT_lx \" EPC \" TARGET_FMT_lx \" %s exception\\n\",\n\n                 __func__, env->active_tc.PC, env->CP0_EPC, name);\n\n    }\n\n    if (cs->exception_index == EXCP_EXT_INTERRUPT &&\n\n        (env->hflags & MIPS_HFLAG_DM)) {\n\n        cs->exception_index = EXCP_DINT;\n\n    }\n\n    offset = 0x180;\n\n    switch (cs->exception_index) {\n\n    case EXCP_DSS:\n\n        env->CP0_Debug |= 1 << CP0DB_DSS;\n\n        \/* Debug single step cannot be raised inside a delay slot and\n\n           resume will always occur on the next instruction\n\n           (but we assume the pc has always been updated during\n\n           code translation). *\/\n\n        env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16);\n\n        goto enter_debug_mode;\n\n    case EXCP_DINT:\n\n        env->CP0_Debug |= 1 << CP0DB_DINT;\n\n        goto set_DEPC;\n\n    case EXCP_DIB:\n\n        env->CP0_Debug |= 1 << CP0DB_DIB;\n\n        goto set_DEPC;\n\n    case EXCP_DBp:\n\n        env->CP0_Debug |= 1 << CP0DB_DBp;\n\n        goto set_DEPC;\n\n    case EXCP_DDBS:\n\n        env->CP0_Debug |= 1 << CP0DB_DDBS;\n\n        goto set_DEPC;\n\n    case EXCP_DDBL:\n\n        env->CP0_Debug |= 1 << CP0DB_DDBL;\n\n    set_DEPC:\n\n        env->CP0_DEPC = exception_resume_pc(env);\n\n        env->hflags &= ~MIPS_HFLAG_BMASK;\n\n enter_debug_mode:\n\n        env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0;\n\n        env->hflags &= ~(MIPS_HFLAG_KSU);\n\n        \/* EJTAG probe trap enable is not implemented... *\/\n\n        if (!(env->CP0_Status & (1 << CP0St_EXL)))\n\n            env->CP0_Cause &= ~(1 << CP0Ca_BD);\n\n        env->active_tc.PC = (int32_t)0xBFC00480;\n\n        set_hflags_for_handler(env);\n\n        break;\n\n    case EXCP_RESET:\n\n        cpu_reset(CPU(cpu));\n\n        break;\n\n    case EXCP_SRESET:\n\n        env->CP0_Status |= (1 << CP0St_SR);\n\n        memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));\n\n        goto set_error_EPC;\n\n    case EXCP_NMI:\n\n        env->CP0_Status |= (1 << CP0St_NMI);\n\n set_error_EPC:\n\n        env->CP0_ErrorEPC = exception_resume_pc(env);\n\n        env->hflags &= ~MIPS_HFLAG_BMASK;\n\n        env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);\n\n        env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;\n\n        env->hflags &= ~(MIPS_HFLAG_KSU);\n\n        if (!(env->CP0_Status & (1 << CP0St_EXL)))\n\n            env->CP0_Cause &= ~(1 << CP0Ca_BD);\n\n        env->active_tc.PC = (int32_t)0xBFC00000;\n\n        set_hflags_for_handler(env);\n\n        break;\n\n    case EXCP_EXT_INTERRUPT:\n\n        cause = 0;\n\n        if (env->CP0_Cause & (1 << CP0Ca_IV))\n\n            offset = 0x200;\n\n\n\n        if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) {\n\n            \/* Vectored Interrupts.  *\/\n\n            unsigned int spacing;\n\n            unsigned int vector;\n\n            unsigned int pending = (env->CP0_Cause & CP0Ca_IP_mask) >> 8;\n\n\n\n            pending &= env->CP0_Status >> 8;\n\n            \/* Compute the Vector Spacing.  *\/\n\n            spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1);\n\n            spacing <<= 5;\n\n\n\n            if (env->CP0_Config3 & (1 << CP0C3_VInt)) {\n\n                \/* For VInt mode, the MIPS computes the vector internally.  *\/\n\n                for (vector = 7; vector > 0; vector--) {\n\n                    if (pending & (1 << vector)) {\n\n                        \/* Found it.  *\/\n\n                        break;\n\n                    }\n\n                }\n\n            } else {\n\n                \/* For VEIC mode, the external interrupt controller feeds the\n\n                   vector through the CP0Cause IP lines.  *\/\n\n                vector = pending;\n\n            }\n\n            offset = 0x200 + vector * spacing;\n\n        }\n\n        goto set_EPC;\n\n    case EXCP_LTLBL:\n\n        cause = 1;\n\n        goto set_EPC;\n\n    case EXCP_TLBL:\n\n        cause = 2;\n\n        if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {\n\n#if defined(TARGET_MIPS64)\n\n            int R = env->CP0_BadVAddr >> 62;\n\n            int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;\n\n            int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;\n\n            int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;\n\n\n\n            if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&\n\n                (!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))\n\n                offset = 0x080;\n\n            else\n\n#endif\n\n                offset = 0x000;\n\n        }\n\n        goto set_EPC;\n\n    case EXCP_TLBS:\n\n        cause = 3;\n\n        if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {\n\n#if defined(TARGET_MIPS64)\n\n            int R = env->CP0_BadVAddr >> 62;\n\n            int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;\n\n            int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;\n\n            int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;\n\n\n\n            if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&\n\n                (!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))\n\n                offset = 0x080;\n\n            else\n\n#endif\n\n                offset = 0x000;\n\n        }\n\n        goto set_EPC;\n\n    case EXCP_AdEL:\n\n        cause = 4;\n\n        goto set_EPC;\n\n    case EXCP_AdES:\n\n        cause = 5;\n\n        goto set_EPC;\n\n    case EXCP_IBE:\n\n        cause = 6;\n\n        goto set_EPC;\n\n    case EXCP_DBE:\n\n        cause = 7;\n\n        goto set_EPC;\n\n    case EXCP_SYSCALL:\n\n        cause = 8;\n\n        goto set_EPC;\n\n    case EXCP_BREAK:\n\n        cause = 9;\n\n        goto set_EPC;\n\n    case EXCP_RI:\n\n        cause = 10;\n\n        goto set_EPC;\n\n    case EXCP_CpU:\n\n        cause = 11;\n\n        env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |\n\n                         (env->error_code << CP0Ca_CE);\n\n        goto set_EPC;\n\n    case EXCP_OVERFLOW:\n\n        cause = 12;\n\n        goto set_EPC;\n\n    case EXCP_TRAP:\n\n        cause = 13;\n\n        goto set_EPC;\n\n    case EXCP_FPE:\n\n        cause = 15;\n\n        goto set_EPC;\n\n    case EXCP_C2E:\n\n        cause = 18;\n\n        goto set_EPC;\n\n    case EXCP_MDMX:\n\n        cause = 22;\n\n        goto set_EPC;\n\n    case EXCP_DWATCH:\n\n        cause = 23;\n\n        \/* XXX: TODO: manage defered watch exceptions *\/\n\n        goto set_EPC;\n\n    case EXCP_MCHECK:\n\n        cause = 24;\n\n        goto set_EPC;\n\n    case EXCP_THREAD:\n\n        cause = 25;\n\n        goto set_EPC;\n\n    case EXCP_DSPDIS:\n\n        cause = 26;\n\n        goto set_EPC;\n\n    case EXCP_CACHE:\n\n        cause = 30;\n\n        if (env->CP0_Status & (1 << CP0St_BEV)) {\n\n            offset = 0x100;\n\n        } else {\n\n            offset = 0x20000100;\n\n        }\n\n set_EPC:\n\n        if (!(env->CP0_Status & (1 << CP0St_EXL))) {\n\n            env->CP0_EPC = exception_resume_pc(env);\n\n            if (env->hflags & MIPS_HFLAG_BMASK) {\n\n                env->CP0_Cause |= (1 << CP0Ca_BD);\n\n            } else {\n\n                env->CP0_Cause &= ~(1 << CP0Ca_BD);\n\n            }\n\n            env->CP0_Status |= (1 << CP0St_EXL);\n\n            env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;\n\n            env->hflags &= ~(MIPS_HFLAG_KSU);\n\n        }\n\n        env->hflags &= ~MIPS_HFLAG_BMASK;\n\n        if (env->CP0_Status & (1 << CP0St_BEV)) {\n\n            env->active_tc.PC = (int32_t)0xBFC00200;\n\n        } else {\n\n            env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff);\n\n        }\n\n        env->active_tc.PC += offset;\n\n        set_hflags_for_handler(env);\n\n        env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);\n\n        break;\n\n    default:\n\n        qemu_log(\"Invalid MIPS exception %d. Exiting\\n\", cs->exception_index);\n\n        printf(\"Invalid MIPS exception %d. Exiting\\n\", cs->exception_index);\n\n        exit(1);\n\n    }\n\n    if (qemu_log_enabled() && cs->exception_index != EXCP_EXT_INTERRUPT) {\n\n        qemu_log(\"%s: PC \" TARGET_FMT_lx \" EPC \" TARGET_FMT_lx \" cause %d\\n\"\n\n                \"    S %08x C %08x A \" TARGET_FMT_lx \" D \" TARGET_FMT_lx \"\\n\",\n\n                __func__, env->active_tc.PC, env->CP0_EPC, cause,\n\n                env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,\n\n                env->CP0_DEPC);\n\n    }\n\n#endif\n\n    cs->exception_index = EXCP_NONE;\n\n}\n","target":1,"code_token_length":2595,"total_token_length":2831,"max_tokens_setting":4096}
+{"idx":126386,"func":"  Status UpdateFunction(const NodeDef* function_node) {\n    NameAttrList function;\n    TF_RETURN_IF_ERROR(NameAndAttrsFromFunctionCall(*function_node, &function));\n    auto it = fun_to_grappler_function_item_.find(function.name());\n    if (it == fun_to_grappler_function_item_.end()) {\n      return errors::InvalidArgument(\n          function.name(),\n          \" was not previously added to SymbolicShapeRefiner.\");\n    }\n\n    const absl::optional& maybe_grappler_function_item =\n        it->second;\n    if (!maybe_grappler_function_item.has_value()) {\n      VLOG(3) << \"Skip failed to instantiate function call: function_name=\"\n              << function.name();\n\n      auto* ctx = GetNodeContext(function_node);\n      auto* ic = ctx->inference_context.get();\n      for (int i = 0; i < ic->num_outputs(); ++i) {\n        TF_RETURN_IF_ERROR(SetUnknownShape(function_node, i));\n      }\n\n      return Status::OK();\n    }\n\n    \/\/ Copy (not reference) so that changes we make here (e.g., replacing\n    \/\/ _Arg with Const and _Retval with Identity) don't affect one in\n    \/\/ fun_to_grappler_function_item_.\n    GrapplerFunctionItem grappler_function_item = *maybe_grappler_function_item;\n    MutableGraphView gv(&grappler_function_item.graph);\n\n    \/\/ Forward shapes from function input nodes to argument nodes.\n    for (int i = 0, end = grappler_function_item.inputs().size(); i < end;\n         ++i) {\n      auto& fun_input = grappler_function_item.input(i);\n      NodeDef* fun_node = gv.GetNode(fun_input.node_name);\n      const TensorId input_tensor = ParseTensorName(function_node->input(i));\n\n      if (IsControlInput(input_tensor)) {\n        return errors::FailedPrecondition(\n            \"Function inputs should not contain control nodes.\");\n      }\n\n      const NodeDef* input_node = graph_.GetNode(input_tensor.node());\n      if (input_node == nullptr) {\n        return errors::FailedPrecondition(input_tensor.node(),\n                                          \" was not found in the graph.\");\n      }\n\n      InferenceContext* input_ic = GetContext(input_node);\n      if (input_ic == nullptr) {\n        return errors::FailedPrecondition(\n            \"Inference context has not been created for \", input_tensor.node());\n      }\n\n      int output_port_num = input_tensor.index();\n      AttrValue attr_output_shape;\n      TensorShapeProto proto;\n      const auto handle = input_ic->output(output_port_num);\n      input_ic->ShapeHandleToProto(handle, &proto);\n      \/\/ There may be dim.size < -1 in SymbolicShapeRefiner. Change those to -1.\n      NormalizeShapeForOutput(&proto);\n      \/\/ _Arg op's output shape uses _output_shapes attr.\n      AttrValue output_attr;\n      output_attr.mutable_list()->add_shape()->Swap(&proto);\n      (*fun_node->mutable_attr())[\"_output_shapes\"] = output_attr;\n\n      \/\/ If dtype is DT_RESOURCE, ops that read _Arg op use _handle_dtypes and\n      \/\/ _handle_shapes attr for its shapes and dtypes.\n      if (fun_input.data_type == DT_RESOURCE) {\n        auto* shapes_and_types =\n            input_ic->output_handle_shapes_and_types(output_port_num);\n        if (shapes_and_types != nullptr && !shapes_and_types->empty()) {\n          AttrValue dtype_attr;\n          AttrValue shape_attr;\n          for (const auto& shape_and_type : *shapes_and_types) {\n            const auto& dtype = shape_and_type.dtype;\n            const auto& shape_handle = shape_and_type.shape;\n            dtype_attr.mutable_list()->add_type(dtype);\n            input_ic->ShapeHandleToProto(\n                shape_handle, shape_attr.mutable_list()->add_shape());\n          }\n          (*fun_node->mutable_attr())[\"_handle_dtypes\"] = dtype_attr;\n          (*fun_node->mutable_attr())[\"_handle_shapes\"] = shape_attr;\n        } else {\n          \/\/ Note that we do not return error here, even if the input node does\n          \/\/ not have shapes_and_types. Within the function, we cannot infer the\n          \/\/ output shape of the DT_RESOURCE input; hence, potentially unknown\n          \/\/ shapes\/dims in the function output shapes.\n          VLOG(2)\n              << \"A function node (\" << function_node->name()\n              << \") has input with DT_RESOURCE, but the input node does not \"\n              << \"have shapes_and_types information: \\n\"\n              << \"function_node: \" << function_node->ShortDebugString() << \"\\n\"\n              << \"function input: \" << i\n              << \", input node's output: \" << output_port_num << \"\\n\"\n              << \"input node: \" << input_node->ShortDebugString();\n        }\n      }\n    }\n\n    \/\/ ReplaceInputWithConst() may break GraphView's internal node mapping\n    \/\/ structure; hence, we separately build node name to NodeDef* map, for the\n    \/\/ output nodes (before GraphView becomes invalid). Note that we use string,\n    \/\/ not string_view.\n    absl::flat_hash_map output_nodes;\n    for (const auto& output_arg : grappler_function_item.outputs()) {\n      output_nodes[output_arg.node_name] = gv.GetNode(output_arg.node_name);\n    }\n\n    \/\/ Replace input nodes with Consts, if values are known. Note that\n    \/\/ we don't check exceptions here as it's done in the above loop.\n    auto* ctx = GetNodeContext(function_node);\n    auto* ic = ctx->inference_context.get();\n    for (int i = grappler_function_item.inputs().size() - 1; i >= 0; --i) {\n      const string& input = function_node->input(i);\n      const string node_name = NodeName(input);\n      const NodeDef* input_node = graph_.GetNode(node_name);\n      if (IsConstant(*input_node)) {\n        TF_CHECK_OK(\n            ReplaceInputWithConst(*input_node, i, &grappler_function_item));\n      } else if (static_cast(ctx->input_tensor_protos.size()) > i &&\n                 ctx->input_tensor_protos[i] != nullptr) {\n        NodeDef const_input_node = MakeConstNodeDefFromTensorProto(\n            ic, *ctx->input_tensor_protos[i], ctx->input_types[i]);\n        TF_CHECK_OK(ReplaceInputWithConst(const_input_node, i,\n                                          &grappler_function_item));\n      } else if (static_cast(ic->input_tensors_as_shapes().size()) > i &&\n                 IsShapeFullyDefinedIntegerVectorOrScalar(\n                     ic, ic->input(i), ic->input_tensors_as_shapes()[i],\n                     ctx->input_types[i])) {\n        \/\/ We have fully defined input_tensors_as_shapes for this input; use it\n        \/\/ as a const input to the function node.\n        NodeDef const_input_node = MakeConstNodeDefFromShape(\n            ic, ic->input(i), ic->input_tensors_as_shapes()[i],\n            ctx->input_types[i]);\n        TF_CHECK_OK(ReplaceInputWithConst(const_input_node, i,\n                                          &grappler_function_item));\n      }\n    }\n    \/\/ node_name to NodeDef* map in GraphView gv can be broken due to\n    \/\/ ReplaceInputWithConst(). gv should not be used after this.\n\n    \/\/ Replace output _Retval nodes with Identity nodes. _Retval is a system op\n    \/\/ without outputs and registered shape function.\n    for (const auto& output_arg : grappler_function_item.outputs()) {\n      NodeDef* output_node = output_nodes[output_arg.node_name];\n      DCHECK_EQ(output_node->op(), \"_Retval\");\n      output_node->set_op(\"Identity\");\n      output_node->mutable_attr()->erase(\"index\");\n    }\n\n    \/\/ Perform inference on function body.\n    GraphProperties gp(grappler_function_item);\n    TF_RETURN_IF_ERROR(gp.InferStatically(\n        \/*assume_valid_feeds=*\/true,\n        \/*aggressive_shape_inference=*\/aggressive_shape_inference_,\n        \/*include_tensor_values=*\/true));\n\n    \/\/ Add return nodes for output shapes.\n    int output = 0;\n    ctx->output_tensors_as_shapes.resize(grappler_function_item.output_size());\n    ctx->output_tensor_protos.resize(grappler_function_item.output_size(),\n                                     nullptr);\n    for (auto const& out_arg : grappler_function_item.outputs()) {\n      \/\/ It is guaranteed that output_tensors does not contain any control\n      \/\/ inputs, so port_id >= 0.\n      TensorId out_tensor = ParseTensorName(out_arg.node_name);\n\n      if (output_nodes.count(out_tensor.node()) <= 0) {\n        return errors::FailedPrecondition(\n            \"Unable to find return function_node \", out_tensor.node(), \" for \",\n            function_node->name());\n      }\n      const NodeDef* retnode = output_nodes[out_tensor.node()];\n\n      auto output_properties = gp.GetOutputProperties(retnode->name());\n      int output_properties_size = output_properties.size();\n      if (out_tensor.index() >= output_properties_size) {\n        return errors::InvalidArgument(\n            out_tensor.ToString(), \" has invalid position \", out_tensor.index(),\n            \" (output_properties.size() = \", output_properties.size(), \").\");\n      }\n      auto& outprop = output_properties[out_tensor.index()];\n      TensorShapeProto shape = outprop.shape();\n      NormalizeShapeForOutput(&shape);\n      ShapeHandle out;\n      TF_RETURN_IF_ERROR(ic->MakeShapeFromShapeProto(shape, &out));\n      ic->set_output(output, out);\n      if (outprop.has_value()) {\n        \/\/ Forward tensor value to output_tensors_as_shape.\n        MaybeTensorProtoToShape(ic, outprop.value(),\n                                &ctx->output_tensors_as_shapes[output]);\n        const_tensors_to_propagate_.push_back(outprop.value());\n        ctx->output_tensor_protos[output] = &const_tensors_to_propagate_.back();\n      }\n      output++;\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":2104,"total_token_length":2340,"max_tokens_setting":4096}
+{"idx":352873,"func":"static void\n_int_free (mstate av, mchunkptr p, int have_lock)\n{\n  INTERNAL_SIZE_T size;        \/* its size *\/\n  mfastbinptr *fb;             \/* associated fastbin *\/\n  mchunkptr nextchunk;         \/* next contiguous chunk *\/\n  INTERNAL_SIZE_T nextsize;    \/* its size *\/\n  int nextinuse;               \/* true if nextchunk is used *\/\n  INTERNAL_SIZE_T prevsize;    \/* size of previous contiguous chunk *\/\n  mchunkptr bck;               \/* misc temp for linking *\/\n  mchunkptr fwd;               \/* misc temp for linking *\/\n\n  size = chunksize (p);\n\n  \/* Little security check which won't hurt performance: the\n     allocator never wrapps around at the end of the address space.\n     Therefore we can exclude some size values which might appear\n     here by accident or by \"design\" from some intruder.  *\/\n  if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0)\n      || __builtin_expect (misaligned_chunk (p), 0))\n    malloc_printerr (\"free(): invalid pointer\");\n  \/* We know that each chunk is at least MINSIZE bytes in size or a\n     multiple of MALLOC_ALIGNMENT.  *\/\n  if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size)))\n    malloc_printerr (\"free(): invalid size\");\n\n  check_inuse_chunk(av, p);\n\n#if USE_TCACHE\n  {\n    size_t tc_idx = csize2tidx (size);\n\n    if (tcache\n\t&& tc_idx < mp_.tcache_bins\n\t&& tcache->counts[tc_idx] < mp_.tcache_count)\n      {\n\ttcache_put (p, tc_idx);\n\treturn;\n      }\n  }\n#endif\n\n  \/*\n    If eligible, place chunk on a fastbin so it can be found\n    and used quickly in malloc.\n  *\/\n\n  if ((unsigned long)(size) <= (unsigned long)(get_max_fast ())\n\n#if TRIM_FASTBINS\n      \/*\n\tIf TRIM_FASTBINS set, don't place chunks\n\tbordering top into fastbins\n      *\/\n      && (chunk_at_offset(p, size) != av->top)\n#endif\n      ) {\n\n    if (__builtin_expect (chunksize_nomask (chunk_at_offset (p, size))\n\t\t\t  <= 2 * SIZE_SZ, 0)\n\t|| __builtin_expect (chunksize (chunk_at_offset (p, size))\n\t\t\t     >= av->system_mem, 0))\n      {\n\tbool fail = true;\n\t\/* We might not have a lock at this point and concurrent modifications\n\t   of system_mem might result in a false positive.  Redo the test after\n\t   getting the lock.  *\/\n\tif (!have_lock)\n\t  {\n\t    __libc_lock_lock (av->mutex);\n\t    fail = (chunksize_nomask (chunk_at_offset (p, size)) <= 2 * SIZE_SZ\n\t\t    || chunksize (chunk_at_offset (p, size)) >= av->system_mem);\n\t    __libc_lock_unlock (av->mutex);\n\t  }\n\n\tif (fail)\n\t  malloc_printerr (\"free(): invalid next size (fast)\");\n      }\n\n    free_perturb (chunk2mem(p), size - 2 * SIZE_SZ);\n\n    atomic_store_relaxed (&av->have_fastchunks, true);\n    unsigned int idx = fastbin_index(size);\n    fb = &fastbin (av, idx);\n\n    \/* Atomically link P to its fastbin: P->FD = *FB; *FB = P;  *\/\n    mchunkptr old = *fb, old2;\n\n    if (SINGLE_THREAD_P)\n      {\n\t\/* Check that the top of the bin is not the record we are going to\n\t   add (i.e., double free).  *\/\n\tif (__builtin_expect (old == p, 0))\n\t  malloc_printerr (\"double free or corruption (fasttop)\");\n\tp->fd = old;\n\t*fb = p;\n      }\n    else\n      do\n\t{\n\t  \/* Check that the top of the bin is not the record we are going to\n\t     add (i.e., double free).  *\/\n\t  if (__builtin_expect (old == p, 0))\n\t    malloc_printerr (\"double free or corruption (fasttop)\");\n\t  p->fd = old2 = old;\n\t}\n      while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2))\n\t     != old2);\n\n    \/* Check that size of fastbin chunk at the top is the same as\n       size of the chunk that we are adding.  We can dereference OLD\n       only if we have the lock, otherwise it might have already been\n       allocated again.  *\/\n    if (have_lock && old != NULL\n\t&& __builtin_expect (fastbin_index (chunksize (old)) != idx, 0))\n      malloc_printerr (\"invalid fastbin entry (free)\");\n  }\n\n  \/*\n    Consolidate other non-mmapped chunks as they arrive.\n  *\/\n\n  else if (!chunk_is_mmapped(p)) {\n\n    \/* If we're single-threaded, don't lock the arena.  *\/\n    if (SINGLE_THREAD_P)\n      have_lock = true;\n\n    if (!have_lock)\n      __libc_lock_lock (av->mutex);\n\n    nextchunk = chunk_at_offset(p, size);\n\n    \/* Lightweight tests: check whether the block is already the\n       top block.  *\/\n    if (__glibc_unlikely (p == av->top))\n      malloc_printerr (\"double free or corruption (top)\");\n    \/* Or whether the next chunk is beyond the boundaries of the arena.  *\/\n    if (__builtin_expect (contiguous (av)\n\t\t\t  && (char *) nextchunk\n\t\t\t  >= ((char *) av->top + chunksize(av->top)), 0))\n\tmalloc_printerr (\"double free or corruption (out)\");\n    \/* Or whether the block is actually not marked used.  *\/\n    if (__glibc_unlikely (!prev_inuse(nextchunk)))\n      malloc_printerr (\"double free or corruption (!prev)\");\n\n    nextsize = chunksize(nextchunk);\n    if (__builtin_expect (chunksize_nomask (nextchunk) <= 2 * SIZE_SZ, 0)\n\t|| __builtin_expect (nextsize >= av->system_mem, 0))\n      malloc_printerr (\"free(): invalid next size (normal)\");\n\n    free_perturb (chunk2mem(p), size - 2 * SIZE_SZ);\n\n    \/* consolidate backward *\/\n    if (!prev_inuse(p)) {\n      prevsize = prev_size (p);\n      size += prevsize;\n      p = chunk_at_offset(p, -((long) prevsize));\n      unlink(av, p, bck, fwd);\n    }\n\n    if (nextchunk != av->top) {\n      \/* get and clear inuse bit *\/\n      nextinuse = inuse_bit_at_offset(nextchunk, nextsize);\n\n      \/* consolidate forward *\/\n      if (!nextinuse) {\n\tunlink(av, nextchunk, bck, fwd);\n\tsize += nextsize;\n      } else\n\tclear_inuse_bit_at_offset(nextchunk, 0);\n\n      \/*\n\tPlace the chunk in unsorted chunk list. Chunks are\n\tnot placed into regular bins until after they have\n\tbeen given one chance to be used in malloc.\n      *\/\n\n      bck = unsorted_chunks(av);\n      fwd = bck->fd;\n      if (__glibc_unlikely (fwd->bk != bck))\n\tmalloc_printerr (\"free(): corrupted unsorted chunks\");\n      p->fd = fwd;\n      p->bk = bck;\n      if (!in_smallbin_range(size))\n\t{\n\t  p->fd_nextsize = NULL;\n\t  p->bk_nextsize = NULL;\n\t}\n      bck->fd = p;\n      fwd->bk = p;\n\n      set_head(p, size | PREV_INUSE);\n      set_foot(p, size);\n\n      check_free_chunk(av, p);\n    }\n\n    \/*\n      If the chunk borders the current high end of memory,\n      consolidate into top\n    *\/\n\n    else {\n      size += nextsize;\n      set_head(p, size | PREV_INUSE);\n      av->top = p;\n      check_chunk(av, p);\n    }\n\n    \/*\n      If freeing a large space, consolidate possibly-surrounding\n      chunks. Then, if the total unused topmost memory exceeds trim\n      threshold, ask malloc_trim to reduce top.\n\n      Unless max_fast is 0, we don't know if there are fastbins\n      bordering top, so we cannot tell for sure whether threshold\n      has been reached unless fastbins are consolidated.  But we\n      don't want to consolidate on each free.  As a compromise,\n      consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD\n      is reached.\n    *\/\n\n    if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {\n      if (atomic_load_relaxed (&av->have_fastchunks))\n\tmalloc_consolidate(av);\n\n      if (av == &main_arena) {\n#ifndef MORECORE_CANNOT_TRIM\n\tif ((unsigned long)(chunksize(av->top)) >=\n\t    (unsigned long)(mp_.trim_threshold))\n\t  systrim(mp_.top_pad, av);\n#endif\n      } else {\n\t\/* Always try heap_trim(), even if the top chunk is not\n\t   large, because the corresponding heap might go away.  *\/\n\theap_info *heap = heap_for_ptr(top(av));\n\n\tassert(heap->ar_ptr == av);\n\theap_trim(heap, mp_.top_pad);\n      }\n    }\n\n    if (!have_lock)\n      __libc_lock_unlock (av->mutex);\n  }\n  \/*\n    If the chunk was allocated via mmap, release via munmap().\n  *\/\n\n  else {\n    munmap_chunk (p);\n  }","target":1,"code_token_length":2053,"total_token_length":2289,"max_tokens_setting":4096}
+{"idx":331896,"func":"static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)\n\n{\n\n    AssignedDevice *dev = PCI_ASSIGN(pci_dev);\n\n    PCIRegion *pci_region = dev->real_device.regions;\n\n    int ret, pos;\n\n\n\n    \/* Clear initial capabilities pointer and status copied from hw *\/\n\n    pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0);\n\n    pci_set_word(pci_dev->config + PCI_STATUS,\n\n                 pci_get_word(pci_dev->config + PCI_STATUS) &\n\n                 ~PCI_STATUS_CAP_LIST);\n\n\n\n    \/* Expose MSI capability\n\n     * MSI capability is the 1st capability in capability config *\/\n\n    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);\n\n    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {\n\n        if (verify_irqchip_in_kernel(errp) < 0) {\n\n            return -ENOTSUP;\n\n        }\n\n        dev->dev.cap_present |= QEMU_PCI_CAP_MSI;\n\n        dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;\n\n        \/* Only 32-bit\/no-mask currently supported *\/\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n        pci_dev->msi_cap = pos;\n\n\n\n        pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS,\n\n                     pci_get_word(pci_dev->config + pos + PCI_MSI_FLAGS) &\n\n                     PCI_MSI_FLAGS_QMASK);\n\n        pci_set_long(pci_dev->config + pos + PCI_MSI_ADDRESS_LO, 0);\n\n        pci_set_word(pci_dev->config + pos + PCI_MSI_DATA_32, 0);\n\n\n\n        \/* Set writable fields *\/\n\n        pci_set_word(pci_dev->wmask + pos + PCI_MSI_FLAGS,\n\n                     PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);\n\n        pci_set_long(pci_dev->wmask + pos + PCI_MSI_ADDRESS_LO, 0xfffffffc);\n\n        pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff);\n\n    }\n\n    \/* Expose MSI-X capability *\/\n\n    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);\n\n    if (pos != 0 && kvm_device_msix_supported(kvm_state)) {\n\n        int bar_nr;\n\n        uint32_t msix_table_entry;\n\n        uint16_t msix_max;\n\n\n\n        if (verify_irqchip_in_kernel(errp) < 0) {\n\n            return -ENOTSUP;\n\n        }\n\n        dev->dev.cap_present |= QEMU_PCI_CAP_MSIX;\n\n        dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n        pci_dev->msix_cap = pos;\n\n\n\n        msix_max = (pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) &\n\n                    PCI_MSIX_FLAGS_QSIZE) + 1;\n\n        msix_max = MIN(msix_max, KVM_MAX_MSIX_PER_DEV);\n\n        pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS, msix_max - 1);\n\n\n\n        \/* Only enable and function mask bits are writable *\/\n\n        pci_set_word(pci_dev->wmask + pos + PCI_MSIX_FLAGS,\n\n                     PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);\n\n\n\n        msix_table_entry = pci_get_long(pci_dev->config + pos + PCI_MSIX_TABLE);\n\n        bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;\n\n        msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;\n\n        dev->msix_table_addr = pci_region[bar_nr].base_addr + msix_table_entry;\n\n        dev->msix_table_size = msix_max * sizeof(MSIXTableEntry);\n\n        dev->msix_max = msix_max;\n\n    }\n\n\n\n    \/* Minimal PM support, nothing writable, device appears to NAK changes *\/\n\n    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0);\n\n    if (pos) {\n\n        uint16_t pmc;\n\n\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n\n\n        assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF);\n\n\n\n        pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS);\n\n        pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);\n\n        pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc);\n\n\n\n        \/* assign_device will bring the device up to D0, so we don't need\n\n         * to worry about doing that ourselves here. *\/\n\n        pci_set_word(pci_dev->config + pos + PCI_PM_CTRL,\n\n                     PCI_PM_CTRL_NO_SOFT_RESET);\n\n\n\n        pci_set_byte(pci_dev->config + pos + PCI_PM_PPB_EXTENSIONS, 0);\n\n        pci_set_byte(pci_dev->config + pos + PCI_PM_DATA_REGISTER, 0);\n\n    }\n\n\n\n    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0);\n\n    if (pos) {\n\n        uint8_t version, size = 0;\n\n        uint16_t type, devctl, lnksta;\n\n        uint32_t devcap, lnkcap;\n\n\n\n        version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);\n\n        version &= PCI_EXP_FLAGS_VERS;\n\n        if (version == 1) {\n\n            size = 0x14;\n\n        } else if (version == 2) {\n\n            \/*\n\n             * Check for non-std size, accept reduced size to 0x34,\n\n             * which is what bcm5761 implemented, violating the\n\n             * PCIe v3.0 spec that regs should exist and be read as 0,\n\n             * not optionally provided and shorten the struct size.\n\n             *\/\n\n            size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos);\n\n            if (size < 0x34) {\n\n                error_setg(errp, \"Invalid size PCIe cap-id 0x%x\",\n\n                           PCI_CAP_ID_EXP);\n\n                return -EINVAL;\n\n            } else if (size != 0x3c) {\n\n                error_report(\"WARNING, %s: PCIe cap-id 0x%x has \"\n\n                             \"non-standard size 0x%x; std size should be 0x3c\",\n\n                             __func__, PCI_CAP_ID_EXP, size);\n\n            }\n\n        } else if (version == 0) {\n\n            uint16_t vid, did;\n\n            vid = pci_get_word(pci_dev->config + PCI_VENDOR_ID);\n\n            did = pci_get_word(pci_dev->config + PCI_DEVICE_ID);\n\n            if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {\n\n                \/*\n\n                 * quirk for Intel 82599 VF with invalid PCIe capability\n\n                 * version, should really be version 2 (same as PF)\n\n                 *\/\n\n                size = 0x3c;\n\n            }\n\n        }\n\n\n\n        if (size == 0) {\n\n            error_setg(errp, \"Unsupported PCI express capability version %d\",\n\n                       version);\n\n            return -EINVAL;\n\n        }\n\n\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n\n\n        assigned_dev_setup_cap_read(dev, pos, size);\n\n\n\n        type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS);\n\n        type = (type & PCI_EXP_FLAGS_TYPE) >> 4;\n\n        if (type != PCI_EXP_TYPE_ENDPOINT &&\n\n            type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {\n\n            error_setg(errp, \"Device assignment only supports endpoint \"\n\n                       \"assignment, device type %d\", type);\n\n            return -EINVAL;\n\n        }\n\n\n\n        \/* capabilities, pass existing read-only copy\n\n         * PCI_EXP_FLAGS_IRQ: updated by hardware, should be direct read *\/\n\n\n\n        \/* device capabilities: hide FLR *\/\n\n        devcap = pci_get_long(pci_dev->config + pos + PCI_EXP_DEVCAP);\n\n        devcap &= ~PCI_EXP_DEVCAP_FLR;\n\n        pci_set_long(pci_dev->config + pos + PCI_EXP_DEVCAP, devcap);\n\n\n\n        \/* device control: clear all error reporting enable bits, leaving\n\n         *                 only a few host values.  Note, these are\n\n         *                 all writable, but not passed to hw.\n\n         *\/\n\n        devctl = pci_get_word(pci_dev->config + pos + PCI_EXP_DEVCTL);\n\n        devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |\n\n                  PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;\n\n        pci_set_word(pci_dev->config + pos + PCI_EXP_DEVCTL, devctl);\n\n        devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;\n\n        pci_set_word(pci_dev->wmask + pos + PCI_EXP_DEVCTL, ~devctl);\n\n\n\n        \/* Clear device status *\/\n\n        pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0);\n\n\n\n        \/* Link capabilities, expose links and latencues, clear reporting *\/\n\n        lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP);\n\n        lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |\n\n                   PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |\n\n                   PCI_EXP_LNKCAP_L1EL);\n\n        pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap);\n\n\n\n        \/* Link control, pass existing read-only copy.  Should be writable? *\/\n\n\n\n        \/* Link status, only expose current speed and width *\/\n\n        lnksta = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKSTA);\n\n        lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);\n\n        pci_set_word(pci_dev->config + pos + PCI_EXP_LNKSTA, lnksta);\n\n\n\n        if (version >= 2) {\n\n            \/* Slot capabilities, control, status - not needed for endpoints *\/\n\n            pci_set_long(pci_dev->config + pos + PCI_EXP_SLTCAP, 0);\n\n            pci_set_word(pci_dev->config + pos + PCI_EXP_SLTCTL, 0);\n\n            pci_set_word(pci_dev->config + pos + PCI_EXP_SLTSTA, 0);\n\n\n\n            \/* Root control, capabilities, status - not needed for endpoints *\/\n\n            pci_set_word(pci_dev->config + pos + PCI_EXP_RTCTL, 0);\n\n            pci_set_word(pci_dev->config + pos + PCI_EXP_RTCAP, 0);\n\n            pci_set_long(pci_dev->config + pos + PCI_EXP_RTSTA, 0);\n\n\n\n            \/* Device capabilities\/control 2, pass existing read-only copy *\/\n\n            \/* Link control 2, pass existing read-only copy *\/\n\n        }\n\n    }\n\n\n\n    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PCIX, 0);\n\n    if (pos) {\n\n        uint16_t cmd;\n\n        uint32_t status;\n\n\n\n        \/* Only expose the minimum, 8 byte capability *\/\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n\n\n        assigned_dev_setup_cap_read(dev, pos, 8);\n\n\n\n        \/* Command register, clear upper bits, including extended modes *\/\n\n        cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD);\n\n        cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |\n\n                PCI_X_CMD_MAX_SPLIT);\n\n        pci_set_word(pci_dev->config + pos + PCI_X_CMD, cmd);\n\n\n\n        \/* Status register, update with emulated PCI bus location, clear\n\n         * error bits, leave the rest. *\/\n\n        status = pci_get_long(pci_dev->config + pos + PCI_X_STATUS);\n\n        status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);\n\n        status |= pci_get_bdf(pci_dev);\n\n        status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |\n\n                    PCI_X_STATUS_SPL_ERR);\n\n        pci_set_long(pci_dev->config + pos + PCI_X_STATUS, status);\n\n    }\n\n\n\n    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0);\n\n    if (pos) {\n\n        \/* Direct R\/W passthrough *\/\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n\n\n        assigned_dev_setup_cap_read(dev, pos, 8);\n\n\n\n        \/* direct write for cap content *\/\n\n        assigned_dev_direct_config_write(dev, pos + 2, 6);\n\n    }\n\n\n\n    \/* Devices can have multiple vendor capabilities, get them all *\/\n\n    for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos));\n\n        pos += PCI_CAP_LIST_NEXT) {\n\n        uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS);\n\n        \/* Direct R\/W passthrough *\/\n\n        ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len,\n\n                                  errp);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n\n\n        assigned_dev_setup_cap_read(dev, pos, len);\n\n\n\n        \/* direct write for cap content *\/\n\n        assigned_dev_direct_config_write(dev, pos + 2, len - 2);\n\n    }\n\n\n\n    \/* If real and virtual capability list status bits differ, virtualize the\n\n     * access. *\/\n\n    if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=\n\n        (assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) &\n\n         PCI_STATUS_CAP_LIST)) {\n\n        dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":3093,"total_token_length":3329,"max_tokens_setting":4096}
+{"idx":498583,"func":"transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_clause)\n{\n\tAttrNumber\tparent_attno;\n\tRelation\trelation;\n\tTupleDesc\ttupleDesc;\n\tTupleConstr *constr;\n\tAclResult\taclresult;\n\tchar\t   *comment;\n\tParseCallbackState pcbstate;\n\n\tsetup_parser_errposition_callback(&pcbstate, cxt->pstate,\n\t\t\t\t\t\t\t\t\t  table_like_clause->relation->location);\n\n\t\/* we could support LIKE in many cases, but worry about it another day *\/\n\tif (cxt->isforeign)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"LIKE is not supported for creating foreign tables\")));\n\n\t\/* Open the relation referenced by the LIKE clause *\/\n\trelation = relation_openrv(table_like_clause->relation, AccessShareLock);\n\n\tif (relation->rd_rel->relkind != RELKIND_RELATION &&\n\t\trelation->rd_rel->relkind != RELKIND_VIEW &&\n\t\trelation->rd_rel->relkind != RELKIND_MATVIEW &&\n\t\trelation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&\n\t\trelation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&\n\t\trelation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t errmsg(\"\\\"%s\\\" is not a table, view, materialized view, composite type, or foreign table\",\n\t\t\t\t\t\tRelationGetRelationName(relation))));\n\n\tcancel_parser_errposition_callback(&pcbstate);\n\n\t\/*\n\t * Check for privileges\n\t *\/\n\tif (relation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)\n\t{\n\t\taclresult = pg_type_aclcheck(relation->rd_rel->reltype, GetUserId(),\n\t\t\t\t\t\t\t\t\t ACL_USAGE);\n\t\tif (aclresult != ACLCHECK_OK)\n\t\t\taclcheck_error(aclresult, OBJECT_TYPE,\n\t\t\t\t\t\t   RelationGetRelationName(relation));\n\t}\n\telse\n\t{\n\t\taclresult = pg_class_aclcheck(RelationGetRelid(relation), GetUserId(),\n\t\t\t\t\t\t\t\t\t  ACL_SELECT);\n\t\tif (aclresult != ACLCHECK_OK)\n\t\t\taclcheck_error(aclresult, get_relkind_objtype(relation->rd_rel->relkind),\n\t\t\t\t\t\t   RelationGetRelationName(relation));\n\t}\n\n\ttupleDesc = RelationGetDescr(relation);\n\tconstr = tupleDesc->constr;\n\n\t\/*\n\t * Insert the copied attributes into the cxt for the new table definition.\n\t * We must do this now so that they appear in the table in the relative\n\t * position where the LIKE clause is, as required by SQL99.\n\t *\/\n\tfor (parent_attno = 1; parent_attno <= tupleDesc->natts;\n\t\t parent_attno++)\n\t{\n\t\tForm_pg_attribute attribute = TupleDescAttr(tupleDesc,\n\t\t\t\t\t\t\t\t\t\t\t\t\tparent_attno - 1);\n\t\tchar\t   *attributeName = NameStr(attribute->attname);\n\t\tColumnDef  *def;\n\n\t\t\/*\n\t\t * Ignore dropped columns in the parent.\n\t\t *\/\n\t\tif (attribute->attisdropped)\n\t\t\tcontinue;\n\n\t\t\/*\n\t\t * Create a new column, which is marked as NOT inherited.\n\t\t *\n\t\t * For constraints, ONLY the NOT NULL constraint is inherited by the\n\t\t * new column definition per SQL99.\n\t\t *\/\n\t\tdef = makeNode(ColumnDef);\n\t\tdef->colname = pstrdup(attributeName);\n\t\tdef->typeName = makeTypeNameFromOid(attribute->atttypid,\n\t\t\t\t\t\t\t\t\t\t\tattribute->atttypmod);\n\t\tdef->inhcount = 0;\n\t\tdef->is_local = true;\n\t\tdef->is_not_null = attribute->attnotnull;\n\t\tdef->is_from_type = false;\n\t\tdef->storage = 0;\n\t\tdef->raw_default = NULL;\n\t\tdef->cooked_default = NULL;\n\t\tdef->collClause = NULL;\n\t\tdef->collOid = attribute->attcollation;\n\t\tdef->constraints = NIL;\n\t\tdef->location = -1;\n\n\t\t\/*\n\t\t * Add to column list\n\t\t *\/\n\t\tcxt->columns = lappend(cxt->columns, def);\n\n\t\t\/*\n\t\t * Copy default, if present and the default has been requested\n\t\t *\/\n\t\tif (attribute->atthasdef &&\n\t\t\t(table_like_clause->options & CREATE_TABLE_LIKE_DEFAULTS))\n\t\t{\n\t\t\tNode\t   *this_default = NULL;\n\t\t\tAttrDefault *attrdef;\n\t\t\tint\t\t\ti;\n\n\t\t\t\/* Find default in constraint structure *\/\n\t\t\tAssert(constr != NULL);\n\t\t\tattrdef = constr->defval;\n\t\t\tfor (i = 0; i < constr->num_defval; i++)\n\t\t\t{\n\t\t\t\tif (attrdef[i].adnum == parent_attno)\n\t\t\t\t{\n\t\t\t\t\tthis_default = stringToNode(attrdef[i].adbin);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tAssert(this_default != NULL);\n\n\t\t\t\/*\n\t\t\t * If default expr could contain any vars, we'd need to fix 'em,\n\t\t\t * but it can't; so default is ready to apply to child.\n\t\t\t *\/\n\n\t\t\tdef->cooked_default = this_default;\n\t\t}\n\n\t\t\/*\n\t\t * Copy identity if requested\n\t\t *\/\n\t\tif (attribute->attidentity &&\n\t\t\t(table_like_clause->options & CREATE_TABLE_LIKE_IDENTITY))\n\t\t{\n\t\t\tOid\t\t\tseq_relid;\n\t\t\tList\t   *seq_options;\n\n\t\t\t\/*\n\t\t\t * find sequence owned by old column; extract sequence parameters;\n\t\t\t * build new create sequence command\n\t\t\t *\/\n\t\t\tseq_relid = getOwnedSequence(RelationGetRelid(relation), attribute->attnum);\n\t\t\tseq_options = sequence_options(seq_relid);\n\t\t\tgenerateSerialExtraStmts(cxt, def,\n\t\t\t\t\t\t\t\t\t InvalidOid, seq_options, true,\n\t\t\t\t\t\t\t\t\t NULL, NULL);\n\t\t\tdef->identity = attribute->attidentity;\n\t\t}\n\n\t\t\/* Likewise, copy storage if requested *\/\n\t\tif (table_like_clause->options & CREATE_TABLE_LIKE_STORAGE)\n\t\t\tdef->storage = attribute->attstorage;\n\t\telse\n\t\t\tdef->storage = 0;\n\n\t\t\/* Likewise, copy comment if requested *\/\n\t\tif ((table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS) &&\n\t\t\t(comment = GetComment(attribute->attrelid,\n\t\t\t\t\t\t\t\t  RelationRelationId,\n\t\t\t\t\t\t\t\t  attribute->attnum)) != NULL)\n\t\t{\n\t\t\tCommentStmt *stmt = makeNode(CommentStmt);\n\n\t\t\tstmt->objtype = OBJECT_COLUMN;\n\t\t\tstmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),\n\t\t\t\t\t\t\t\t\t\t\t   makeString(cxt->relation->relname),\n\t\t\t\t\t\t\t\t\t\t\t   makeString(def->colname));\n\t\t\tstmt->comment = comment;\n\n\t\t\tcxt->alist = lappend(cxt->alist, stmt);\n\t\t}\n\t}\n\n\t\/* We use oids if at least one LIKE'ed table has oids. *\/\n\tcxt->hasoids |= relation->rd_rel->relhasoids;\n\n\t\/*\n\t * We cannot yet deal with CHECK constraints or indexes, since we don't\n\t * yet know what column numbers the copied columns will have in the\n\t * finished table.  If any of those options are specified, add the LIKE\n\t * clause to cxt->likeclauses so that expandTableLikeClause will be called\n\t * after we do know that.  Also, remember the relation OID so that\n\t * expandTableLikeClause is certain to open the same table.\n\t *\/\n\tif (table_like_clause->options &\n\t\t(CREATE_TABLE_LIKE_CONSTRAINTS |\n\t\t CREATE_TABLE_LIKE_INDEXES))\n\t{\n\t\ttable_like_clause->relationOid = RelationGetRelid(relation);\n\t\tcxt->likeclauses = lappend(cxt->likeclauses, table_like_clause);\n\t}\n\n\t\/*\n\t * We may copy extended statistics if requested, since the representation\n\t * of CreateStatsStmt doesn't depend on column numbers.\n\t *\/\n\tif (table_like_clause->options & CREATE_TABLE_LIKE_STATISTICS)\n\t{\n\t\tList\t   *parent_extstats;\n\t\tListCell   *l;\n\n\t\tparent_extstats = RelationGetStatExtList(relation);\n\n\t\tforeach(l, parent_extstats)\n\t\t{\n\t\t\tOid\t\t\tparent_stat_oid = lfirst_oid(l);\n\t\t\tCreateStatsStmt *stats_stmt;\n\n\t\t\tstats_stmt = generateClonedExtStatsStmt(cxt->relation,\n\t\t\t\t\t\t\t\t\t\t\t\t\tRelationGetRelid(relation),\n\t\t\t\t\t\t\t\t\t\t\t\t\tparent_stat_oid);\n\n\t\t\t\/* Copy comment on statistics object, if requested *\/\n\t\t\tif (table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS)\n\t\t\t{\n\t\t\t\tcomment = GetComment(parent_stat_oid, StatisticExtRelationId, 0);\n\n\t\t\t\t\/*\n\t\t\t\t * We make use of CreateStatsStmt's stxcomment option, so as\n\t\t\t\t * not to need to know now what name the statistics will have.\n\t\t\t\t *\/\n\t\t\t\tstats_stmt->stxcomment = comment;\n\t\t\t}\n\n\t\t\tcxt->extstats = lappend(cxt->extstats, stats_stmt);\n\t\t}\n\n\t\tlist_free(parent_extstats);\n\t}\n\n\t\/*\n\t * Close the parent rel, but keep our AccessShareLock on it until xact\n\t * commit.  That will prevent someone else from deleting or ALTERing the\n\t * parent before we can run expandTableLikeClause.\n\t *\/\n\theap_close(relation, NoLock);\n}","target":0,"code_token_length":1975,"total_token_length":2211,"max_tokens_setting":4096}
+{"idx":53442,"func":"void ieee80211_check_fast_xmit(struct sta_info *sta)\n{\n\tstruct ieee80211_fast_tx build = {}, *fast_tx = NULL, *old;\n\tstruct ieee80211_local *local = sta->local;\n\tstruct ieee80211_sub_if_data *sdata = sta->sdata;\n\tstruct ieee80211_hdr *hdr = (void *)build.hdr;\n\tstruct ieee80211_chanctx_conf *chanctx_conf;\n\t__le16 fc;\n\n\tif (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT))\n\t\treturn;\n\n\t\/* Locking here protects both the pointer itself, and against concurrent\n\t * invocations winning data access races to, e.g., the key pointer that\n\t * is used.\n\t * Without it, the invocation of this function right after the key\n\t * pointer changes wouldn't be sufficient, as another CPU could access\n\t * the pointer, then stall, and then do the cache update after the CPU\n\t * that invalidated the key.\n\t * With the locking, such scenarios cannot happen as the check for the\n\t * key and the fast-tx assignment are done atomically, so the CPU that\n\t * modifies the key will either wait or other one will see the key\n\t * cleared\/changed already.\n\t *\/\n\tspin_lock_bh(&sta->lock);\n\tif (ieee80211_hw_check(&local->hw, SUPPORTS_PS) &&\n\t    !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) &&\n\t    sdata->vif.type == NL80211_IFTYPE_STATION)\n\t\tgoto out;\n\n\tif (!test_sta_flag(sta, WLAN_STA_AUTHORIZED))\n\t\tgoto out;\n\n\tif (test_sta_flag(sta, WLAN_STA_PS_STA) ||\n\t    test_sta_flag(sta, WLAN_STA_PS_DRIVER) ||\n\t    test_sta_flag(sta, WLAN_STA_PS_DELIVER) ||\n\t    test_sta_flag(sta, WLAN_STA_CLEAR_PS_FILT))\n\t\tgoto out;\n\n\tif (sdata->noack_map)\n\t\tgoto out;\n\n\t\/* fast-xmit doesn't handle fragmentation at all *\/\n\tif (local->hw.wiphy->frag_threshold != (u32)-1 &&\n\t    !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG))\n\t\tgoto out;\n\n\trcu_read_lock();\n\tchanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);\n\tif (!chanctx_conf) {\n\t\trcu_read_unlock();\n\t\tgoto out;\n\t}\n\tbuild.band = chanctx_conf->def.chan->band;\n\trcu_read_unlock();\n\n\tfc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);\n\n\tswitch (sdata->vif.type) {\n\tcase NL80211_IFTYPE_ADHOC:\n\t\t\/* DA SA BSSID *\/\n\t\tbuild.da_offs = offsetof(struct ieee80211_hdr, addr1);\n\t\tbuild.sa_offs = offsetof(struct ieee80211_hdr, addr2);\n\t\tmemcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN);\n\t\tbuild.hdr_len = 24;\n\t\tbreak;\n\tcase NL80211_IFTYPE_STATION:\n\t\tif (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {\n\t\t\t\/* DA SA BSSID *\/\n\t\t\tbuild.da_offs = offsetof(struct ieee80211_hdr, addr1);\n\t\t\tbuild.sa_offs = offsetof(struct ieee80211_hdr, addr2);\n\t\t\tmemcpy(hdr->addr3, sdata->u.mgd.bssid, ETH_ALEN);\n\t\t\tbuild.hdr_len = 24;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (sdata->u.mgd.use_4addr) {\n\t\t\t\/* non-regular ethertype cannot use the fastpath *\/\n\t\t\tfc |= cpu_to_le16(IEEE80211_FCTL_FROMDS |\n\t\t\t\t\t  IEEE80211_FCTL_TODS);\n\t\t\t\/* RA TA DA SA *\/\n\t\t\tmemcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN);\n\t\t\tmemcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);\n\t\t\tbuild.da_offs = offsetof(struct ieee80211_hdr, addr3);\n\t\t\tbuild.sa_offs = offsetof(struct ieee80211_hdr, addr4);\n\t\t\tbuild.hdr_len = 30;\n\t\t\tbreak;\n\t\t}\n\t\tfc |= cpu_to_le16(IEEE80211_FCTL_TODS);\n\t\t\/* BSSID SA DA *\/\n\t\tmemcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN);\n\t\tbuild.da_offs = offsetof(struct ieee80211_hdr, addr3);\n\t\tbuild.sa_offs = offsetof(struct ieee80211_hdr, addr2);\n\t\tbuild.hdr_len = 24;\n\t\tbreak;\n\tcase NL80211_IFTYPE_AP_VLAN:\n\t\tif (sdata->wdev.use_4addr) {\n\t\t\tfc |= cpu_to_le16(IEEE80211_FCTL_FROMDS |\n\t\t\t\t\t  IEEE80211_FCTL_TODS);\n\t\t\t\/* RA TA DA SA *\/\n\t\t\tmemcpy(hdr->addr1, sta->sta.addr, ETH_ALEN);\n\t\t\tmemcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);\n\t\t\tbuild.da_offs = offsetof(struct ieee80211_hdr, addr3);\n\t\t\tbuild.sa_offs = offsetof(struct ieee80211_hdr, addr4);\n\t\t\tbuild.hdr_len = 30;\n\t\t\tbreak;\n\t\t}\n\t\tfallthrough;\n\tcase NL80211_IFTYPE_AP:\n\t\tfc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);\n\t\t\/* DA BSSID SA *\/\n\t\tbuild.da_offs = offsetof(struct ieee80211_hdr, addr1);\n\t\tmemcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);\n\t\tbuild.sa_offs = offsetof(struct ieee80211_hdr, addr3);\n\t\tbuild.hdr_len = 24;\n\t\tbreak;\n\tdefault:\n\t\t\/* not handled on fast-xmit *\/\n\t\tgoto out;\n\t}\n\n\tif (sta->sta.wme) {\n\t\tbuild.hdr_len += 2;\n\t\tfc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);\n\t}\n\n\t\/* We store the key here so there's no point in using rcu_dereference()\n\t * but that's fine because the code that changes the pointers will call\n\t * this function after doing so. For a single CPU that would be enough,\n\t * for multiple see the comment above.\n\t *\/\n\tbuild.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]);\n\tif (!build.key)\n\t\tbuild.key = rcu_access_pointer(sdata->default_unicast_key);\n\tif (build.key) {\n\t\tbool gen_iv, iv_spc, mmic;\n\n\t\tgen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV;\n\t\tiv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE;\n\t\tmmic = build.key->conf.flags &\n\t\t\t(IEEE80211_KEY_FLAG_GENERATE_MMIC |\n\t\t\t IEEE80211_KEY_FLAG_PUT_MIC_SPACE);\n\n\t\t\/* don't handle software crypto *\/\n\t\tif (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))\n\t\t\tgoto out;\n\n\t\t\/* Key is being removed *\/\n\t\tif (build.key->flags & KEY_FLAG_TAINTED)\n\t\t\tgoto out;\n\n\t\tswitch (build.key->conf.cipher) {\n\t\tcase WLAN_CIPHER_SUITE_CCMP:\n\t\tcase WLAN_CIPHER_SUITE_CCMP_256:\n\t\t\tif (gen_iv)\n\t\t\t\tbuild.pn_offs = build.hdr_len;\n\t\t\tif (gen_iv || iv_spc)\n\t\t\t\tbuild.hdr_len += IEEE80211_CCMP_HDR_LEN;\n\t\t\tbreak;\n\t\tcase WLAN_CIPHER_SUITE_GCMP:\n\t\tcase WLAN_CIPHER_SUITE_GCMP_256:\n\t\t\tif (gen_iv)\n\t\t\t\tbuild.pn_offs = build.hdr_len;\n\t\t\tif (gen_iv || iv_spc)\n\t\t\t\tbuild.hdr_len += IEEE80211_GCMP_HDR_LEN;\n\t\t\tbreak;\n\t\tcase WLAN_CIPHER_SUITE_TKIP:\n\t\t\t\/* cannot handle MMIC or IV generation in xmit-fast *\/\n\t\t\tif (mmic || gen_iv)\n\t\t\t\tgoto out;\n\t\t\tif (iv_spc)\n\t\t\t\tbuild.hdr_len += IEEE80211_TKIP_IV_LEN;\n\t\t\tbreak;\n\t\tcase WLAN_CIPHER_SUITE_WEP40:\n\t\tcase WLAN_CIPHER_SUITE_WEP104:\n\t\t\t\/* cannot handle IV generation in fast-xmit *\/\n\t\t\tif (gen_iv)\n\t\t\t\tgoto out;\n\t\t\tif (iv_spc)\n\t\t\t\tbuild.hdr_len += IEEE80211_WEP_IV_LEN;\n\t\t\tbreak;\n\t\tcase WLAN_CIPHER_SUITE_AES_CMAC:\n\t\tcase WLAN_CIPHER_SUITE_BIP_CMAC_256:\n\t\tcase WLAN_CIPHER_SUITE_BIP_GMAC_128:\n\t\tcase WLAN_CIPHER_SUITE_BIP_GMAC_256:\n\t\t\tWARN(1,\n\t\t\t     \"management cipher suite 0x%x enabled for data\\n\",\n\t\t\t     build.key->conf.cipher);\n\t\t\tgoto out;\n\t\tdefault:\n\t\t\t\/* we don't know how to generate IVs for this at all *\/\n\t\t\tif (WARN_ON(gen_iv))\n\t\t\t\tgoto out;\n\t\t\t\/* pure hardware keys are OK, of course *\/\n\t\t\tif (!(build.key->flags & KEY_FLAG_CIPHER_SCHEME))\n\t\t\t\tbreak;\n\t\t\t\/* cipher scheme might require space allocation *\/\n\t\t\tif (iv_spc &&\n\t\t\t    build.key->conf.iv_len > IEEE80211_FAST_XMIT_MAX_IV)\n\t\t\t\tgoto out;\n\t\t\tif (iv_spc)\n\t\t\t\tbuild.hdr_len += build.key->conf.iv_len;\n\t\t}\n\n\t\tfc |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);\n\t}\n\n\thdr->frame_control = fc;\n\n\tmemcpy(build.hdr + build.hdr_len,\n\t       rfc1042_header,  sizeof(rfc1042_header));\n\tbuild.hdr_len += sizeof(rfc1042_header);\n\n\tfast_tx = kmemdup(&build, sizeof(build), GFP_ATOMIC);\n\t\/* if the kmemdup fails, continue w\/o fast_tx *\/\n\tif (!fast_tx)\n\t\tgoto out;\n\n out:\n\t\/* we might have raced against another call to this function *\/\n\told = rcu_dereference_protected(sta->fast_tx,\n\t\t\t\t\tlockdep_is_held(&sta->lock));\n\trcu_assign_pointer(sta->fast_tx, fast_tx);\n\tif (old)\n\t\tkfree_rcu(old, rcu_head);\n\tspin_unlock_bh(&sta->lock);\n}","target":0,"code_token_length":2347,"total_token_length":2583,"max_tokens_setting":4096}
+{"idx":332607,"func":"static void adpcm_compress_trellis(AVCodecContext *avctx,\n\n                                   const int16_t *samples, uint8_t *dst,\n\n                                   ADPCMChannelStatus *c, int n, int stride)\n\n{\n\n    \/\/FIXME 6% faster if frontier is a compile-time constant\n\n    ADPCMEncodeContext *s = avctx->priv_data;\n\n    const int frontier = 1 << avctx->trellis;\n\n    const int version  = avctx->codec->id;\n\n    TrellisPath *paths       = s->paths, *p;\n\n    TrellisNode *node_buf    = s->node_buf;\n\n    TrellisNode **nodep_buf  = s->nodep_buf;\n\n    TrellisNode **nodes      = nodep_buf; \/\/ nodes[] is always sorted by .ssd\n\n    TrellisNode **nodes_next = nodep_buf + frontier;\n\n    int pathn = 0, froze = -1, i, j, k, generation = 0;\n\n    uint8_t *hash = s->trellis_hash;\n\n    memset(hash, 0xff, 65536 * sizeof(*hash));\n\n\n\n    memset(nodep_buf, 0, 2 * frontier * sizeof(*nodep_buf));\n\n    nodes[0]          = node_buf + frontier;\n\n    nodes[0]->ssd     = 0;\n\n    nodes[0]->path    = 0;\n\n    nodes[0]->step    = c->step_index;\n\n    nodes[0]->sample1 = c->sample1;\n\n    nodes[0]->sample2 = c->sample2;\n\n    if (version == AV_CODEC_ID_ADPCM_IMA_WAV ||\n\n        version == AV_CODEC_ID_ADPCM_IMA_QT  ||\n\n        version == AV_CODEC_ID_ADPCM_SWF)\n\n        nodes[0]->sample1 = c->prev_sample;\n\n    if (version == AV_CODEC_ID_ADPCM_MS)\n\n        nodes[0]->step = c->idelta;\n\n    if (version == AV_CODEC_ID_ADPCM_YAMAHA) {\n\n        if (c->step == 0) {\n\n            nodes[0]->step    = 127;\n\n            nodes[0]->sample1 = 0;\n\n        } else {\n\n            nodes[0]->step    = c->step;\n\n            nodes[0]->sample1 = c->predictor;\n\n        }\n\n    }\n\n\n\n    for (i = 0; i < n; i++) {\n\n        TrellisNode *t = node_buf + frontier*(i&1);\n\n        TrellisNode **u;\n\n        int sample   = samples[i * stride];\n\n        int heap_pos = 0;\n\n        memset(nodes_next, 0, frontier * sizeof(TrellisNode*));\n\n        for (j = 0; j < frontier && nodes[j]; j++) {\n\n            \/\/ higher j have higher ssd already, so they're likely\n\n            \/\/ to yield a suboptimal next sample too\n\n            const int range = (j < frontier \/ 2) ? 1 : 0;\n\n            const int step  = nodes[j]->step;\n\n            int nidx;\n\n            if (version == AV_CODEC_ID_ADPCM_MS) {\n\n                const int predictor = ((nodes[j]->sample1 * c->coeff1) +\n\n                                       (nodes[j]->sample2 * c->coeff2)) \/ 64;\n\n                const int div  = (sample - predictor) \/ step;\n\n                const int nmin = av_clip(div-range, -8, 6);\n\n                const int nmax = av_clip(div+range, -7, 7);\n\n                for (nidx = nmin; nidx <= nmax; nidx++) {\n\n                    const int nibble = nidx & 0xf;\n\n                    int dec_sample   = predictor + nidx * step;\n\n#define STORE_NODE(NAME, STEP_INDEX)\\\n\n                    int d;\\\n\n                    uint32_t ssd;\\\n\n                    int pos;\\\n\n                    TrellisNode *u;\\\n\n                    uint8_t *h;\\\n\n                    dec_sample = av_clip_int16(dec_sample);\\\n\n                    d = sample - dec_sample;\\\n\n                    ssd = nodes[j]->ssd + d*d;\\\n\n                    \/* Check for wraparound, skip such samples completely. \\\n\n                     * Note, changing ssd to a 64 bit variable would be \\\n\n                     * simpler, avoiding this check, but it's slower on \\\n\n                     * x86 32 bit at the moment. *\/\\\n\n                    if (ssd < nodes[j]->ssd)\\\n\n                        goto next_##NAME;\\\n\n                    \/* Collapse any two states with the same previous sample value. \\\n\n                     * One could also distinguish states by step and by 2nd to last\n\n                     * sample, but the effects of that are negligible.\n\n                     * Since nodes in the previous generation are iterated\n\n                     * through a heap, they're roughly ordered from better to\n\n                     * worse, but not strictly ordered. Therefore, an earlier\n\n                     * node with the same sample value is better in most cases\n\n                     * (and thus the current is skipped), but not strictly\n\n                     * in all cases. Only skipping samples where ssd >=\n\n                     * ssd of the earlier node with the same sample gives\n\n                     * slightly worse quality, though, for some reason. *\/ \\\n\n                    h = &hash[(uint16_t) dec_sample];\\\n\n                    if (*h == generation)\\\n\n                        goto next_##NAME;\\\n\n                    if (heap_pos < frontier) {\\\n\n                        pos = heap_pos++;\\\n\n                    } else {\\\n\n                        \/* Try to replace one of the leaf nodes with the new \\\n\n                         * one, but try a different slot each time. *\/\\\n\n                        pos = (frontier >> 1) +\\\n\n                              (heap_pos & ((frontier >> 1) - 1));\\\n\n                        if (ssd > nodes_next[pos]->ssd)\\\n\n                            goto next_##NAME;\\\n\n                        heap_pos++;\\\n\n                    }\\\n\n                    *h = generation;\\\n\n                    u  = nodes_next[pos];\\\n\n                    if (!u) {\\\n\n                        av_assert1(pathn < FREEZE_INTERVAL << avctx->trellis);\\\n\n                        u = t++;\\\n\n                        nodes_next[pos] = u;\\\n\n                        u->path = pathn++;\\\n\n                    }\\\n\n                    u->ssd  = ssd;\\\n\n                    u->step = STEP_INDEX;\\\n\n                    u->sample2 = nodes[j]->sample1;\\\n\n                    u->sample1 = dec_sample;\\\n\n                    paths[u->path].nibble = nibble;\\\n\n                    paths[u->path].prev   = nodes[j]->path;\\\n\n                    \/* Sift the newly inserted node up in the heap to \\\n\n                     * restore the heap property. *\/\\\n\n                    while (pos > 0) {\\\n\n                        int parent = (pos - 1) >> 1;\\\n\n                        if (nodes_next[parent]->ssd <= ssd)\\\n\n                            break;\\\n\n                        FFSWAP(TrellisNode*, nodes_next[parent], nodes_next[pos]);\\\n\n                        pos = parent;\\\n\n                    }\\\n\n                    next_##NAME:;\n\n                    STORE_NODE(ms, FFMAX(16,\n\n                               (ff_adpcm_AdaptationTable[nibble] * step) >> 8));\n\n                }\n\n            } else if (version == AV_CODEC_ID_ADPCM_IMA_WAV ||\n\n                       version == AV_CODEC_ID_ADPCM_IMA_QT  ||\n\n                       version == AV_CODEC_ID_ADPCM_SWF) {\n\n#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\\\n\n                const int predictor = nodes[j]->sample1;\\\n\n                const int div = (sample - predictor) * 4 \/ STEP_TABLE;\\\n\n                int nmin = av_clip(div - range, -7, 6);\\\n\n                int nmax = av_clip(div + range, -6, 7);\\\n\n                if (nmin <= 0)\\\n\n                    nmin--; \/* distinguish -0 from +0 *\/\\\n\n                if (nmax < 0)\\\n\n                    nmax--;\\\n\n                for (nidx = nmin; nidx <= nmax; nidx++) {\\\n\n                    const int nibble = nidx < 0 ? 7 - nidx : nidx;\\\n\n                    int dec_sample = predictor +\\\n\n                                    (STEP_TABLE *\\\n\n                                     ff_adpcm_yamaha_difflookup[nibble]) \/ 8;\\\n\n                    STORE_NODE(NAME, STEP_INDEX);\\\n\n                }\n\n                LOOP_NODES(ima, ff_adpcm_step_table[step],\n\n                           av_clip(step + ff_adpcm_index_table[nibble], 0, 88));\n\n            } else { \/\/AV_CODEC_ID_ADPCM_YAMAHA\n\n                LOOP_NODES(yamaha, step,\n\n                           av_clip((step * ff_adpcm_yamaha_indexscale[nibble]) >> 8,\n\n                                   127, 24567));\n\n#undef LOOP_NODES\n\n#undef STORE_NODE\n\n            }\n\n        }\n\n\n\n        u = nodes;\n\n        nodes = nodes_next;\n\n        nodes_next = u;\n\n\n\n        generation++;\n\n        if (generation == 255) {\n\n            memset(hash, 0xff, 65536 * sizeof(*hash));\n\n            generation = 0;\n\n        }\n\n\n\n        \/\/ prevent overflow\n\n        if (nodes[0]->ssd > (1 << 28)) {\n\n            for (j = 1; j < frontier && nodes[j]; j++)\n\n                nodes[j]->ssd -= nodes[0]->ssd;\n\n            nodes[0]->ssd = 0;\n\n        }\n\n\n\n        \/\/ merge old paths to save memory\n\n        if (i == froze + FREEZE_INTERVAL) {\n\n            p = &paths[nodes[0]->path];\n\n            for (k = i; k > froze; k--) {\n\n                dst[k] = p->nibble;\n\n                p = &paths[p->prev];\n\n            }\n\n            froze = i;\n\n            pathn = 0;\n\n            \/\/ other nodes might use paths that don't coincide with the frozen one.\n\n            \/\/ checking which nodes do so is too slow, so just kill them all.\n\n            \/\/ this also slightly improves quality, but I don't know why.\n\n            memset(nodes + 1, 0, (frontier - 1) * sizeof(TrellisNode*));\n\n        }\n\n    }\n\n\n\n    p = &paths[nodes[0]->path];\n\n    for (i = n - 1; i > froze; i--) {\n\n        dst[i] = p->nibble;\n\n        p = &paths[p->prev];\n\n    }\n\n\n\n    c->predictor  = nodes[0]->sample1;\n\n    c->sample1    = nodes[0]->sample1;\n\n    c->sample2    = nodes[0]->sample2;\n\n    c->step_index = nodes[0]->step;\n\n    c->step       = nodes[0]->step;\n\n    c->idelta     = nodes[0]->step;\n\n}\n","target":1,"code_token_length":2299,"total_token_length":2535,"max_tokens_setting":4096}
+{"idx":6493,"func":"iasecc_select_file(struct sc_card *card, const struct sc_path *path,\n\t\t struct sc_file **file_out)\n{\n\tstruct sc_context *ctx = card->ctx;\n\tstruct sc_path lpath;\n\tint cache_valid = card->cache.valid, df_from_cache = 0;\n\tint rv, ii;\n\n\tLOG_FUNC_CALLED(ctx);\n\tmemcpy(&lpath, path, sizeof(struct sc_path));\n\tif (file_out)\n\t\t*file_out = NULL;\n\n\tsc_log(ctx,\n\t       \"iasecc_select_file(card:%p) path.len %\"SC_FORMAT_LEN_SIZE_T\"u; path.type %i; aid_len %\"SC_FORMAT_LEN_SIZE_T\"u\",\n\t       card, path->len, path->type, path->aid.len);\n\tsc_log(ctx, \"iasecc_select_file() path:%s\", sc_print_path(path));\n\n\tsc_print_cache(card);\n\tif (lpath.len >= 2 && lpath.value[0] == 0x3F && lpath.value[1] == 0x00)   {\n\t\tsc_log(ctx, \"EF.ATR(aid:'%s')\", card->ef_atr ? sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len) : \"\");\n\n\t\trv = iasecc_select_mf(card, file_out);\n\t\tLOG_TEST_RET(ctx, rv, \"MF selection error\");\n\n\t\tif (lpath.len >= 2 && lpath.value[0] == 0x3F && lpath.value[1] == 0x00)\t   {\n\t\t\tmemmove(&lpath.value[0], &lpath.value[2], lpath.len - 2);\n\t\t\tlpath.len -=  2;\n\t\t}\n\t}\n\n\tif (lpath.aid.len)\t{\n\t\tstruct sc_file *file = NULL;\n\t\tstruct sc_path ppath;\n\n\t\tsc_log(ctx,\n\t\t       \"iasecc_select_file() select parent AID:%p\/%\"SC_FORMAT_LEN_SIZE_T\"u\",\n\t\t       lpath.aid.value, lpath.aid.len);\n\t\tsc_log(ctx, \"iasecc_select_file() select parent AID:%s\", sc_dump_hex(lpath.aid.value, lpath.aid.len));\n\t\tmemset(&ppath, 0, sizeof(ppath));\n\t\tmemcpy(ppath.value, lpath.aid.value, lpath.aid.len);\n\t\tppath.len = lpath.aid.len;\n\t\tppath.type = SC_PATH_TYPE_DF_NAME;\n\n\t\tif (card->cache.valid && card->cache.current_df\n\t\t\t\t&& card->cache.current_df->path.len == lpath.aid.len\n\t\t\t\t&& !memcmp(card->cache.current_df->path.value, lpath.aid.value, lpath.aid.len))\n\t\t\tdf_from_cache = 1;\n\n\t\trv = iasecc_select_file(card, &ppath, &file);\n\t\tLOG_TEST_RET(ctx, rv, \"select AID path failed\");\n\n\t\tif (file_out)\n\t\t\t*file_out = file;\n\t\telse\n\t\t   sc_file_free(file);\n\n\t\tif (lpath.type == SC_PATH_TYPE_DF_NAME)\n\t\t\tlpath.type = SC_PATH_TYPE_FROM_CURRENT;\n\t}\n\n\tif (lpath.type == SC_PATH_TYPE_PATH)\n\t\tlpath.type = SC_PATH_TYPE_FROM_CURRENT;\n\n\tif (!lpath.len)\n\t\tLOG_FUNC_RETURN(ctx, SC_SUCCESS);\n\n\tsc_print_cache(card);\n\n\tif (card->cache.valid && card->cache.current_df && lpath.type == SC_PATH_TYPE_DF_NAME\n\t\t\t&& card->cache.current_df->path.len == lpath.len\n\t\t\t&& !memcmp(card->cache.current_df->path.value, lpath.value, lpath.len))   {\n\t\tsc_log(ctx, \"returns current DF path %s\", sc_print_path(&card->cache.current_df->path));\n\t\tif (file_out)   {\n\t\t\tsc_file_free(*file_out);\n\t\t\tsc_file_dup(file_out, card->cache.current_df);\n\t\t}\n\n\t\tsc_print_cache(card);\n\t\tLOG_FUNC_RETURN(ctx, SC_SUCCESS);\n\t}\n\n\tdo   {\n\t\tstruct sc_apdu apdu;\n\t\tstruct sc_file *file = NULL;\n\t\tunsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];\n\t\tint pathlen = lpath.len;\n\n\t\tsc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);\n\n\t\tif (card->type != SC_CARD_TYPE_IASECC_GEMALTO\n\t\t\t\t&& card->type != SC_CARD_TYPE_IASECC_OBERTHUR\n\t\t\t\t&& card->type != SC_CARD_TYPE_IASECC_SAGEM\n\t\t\t\t&& card->type != SC_CARD_TYPE_IASECC_AMOS\n\t\t\t\t&& card->type != SC_CARD_TYPE_IASECC_MI\n\t\t\t\t&& card->type != SC_CARD_TYPE_IASECC_MI2)\n\t\t\tLOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, \"Unsupported card\");\n\n\t\tif (lpath.type == SC_PATH_TYPE_FILE_ID)   {\n\t\t\tapdu.p1 = 0x02;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)   {\n\t\t\t\tapdu.p1 = 0x01;\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\t}\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_AMOS)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_MI)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_MI2)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t}\n\t\telse if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {\n\t\t\tapdu.p1 = 0x09;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_AMOS)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_MI)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_MI2)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t}\n\t\telse if (lpath.type == SC_PATH_TYPE_PARENT)   {\n\t\t\tapdu.p1 = 0x03;\n\t\t\tpathlen = 0;\n\t\t\tapdu.cse = SC_APDU_CASE_2_SHORT;\n\t\t}\n\t\telse if (lpath.type == SC_PATH_TYPE_DF_NAME)   {\n\t\t\tapdu.p1 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_AMOS)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t\tif (card->type == SC_CARD_TYPE_IASECC_MI2)\n\t\t\t\tapdu.p2 = 0x04;\n\t\t}\n\t\telse   {\n\t\t\tsc_log(ctx, \"Invalid PATH type: 0x%X\", lpath.type);\n\t\t\tLOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, \"iasecc_select_file() invalid PATH type\");\n\t\t}\n\n\t\tfor (ii=0; ii<2; ii++)   {\n\t\t\tapdu.lc = pathlen;\n\t\t\tapdu.data = lpath.value;\n\t\t\tapdu.datalen = pathlen;\n\n\t\t\tapdu.resp = rbuf;\n\t\t\tapdu.resplen = sizeof(rbuf);\n\t\t\tapdu.le = 256;\n\n\t\t\trv = sc_transmit_apdu(card, &apdu);\n\t\t\tLOG_TEST_RET(ctx, rv, \"APDU transmit failed\");\n\t\t\trv = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\t\t\tif (rv == SC_ERROR_INCORRECT_PARAMETERS &&\n\t\t\t\t\tlpath.type == SC_PATH_TYPE_DF_NAME && apdu.p2 == 0x00)   {\n\t\t\t\tapdu.p2 = 0x0C;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ii)   {\n\t\t\t\t\/* 'SELECT AID' do not returned FCP. Try to emulate. *\/\n\t\t\t\tapdu.resplen = sizeof(rbuf);\n\t\t\t\trv = iasecc_emulate_fcp(ctx, &apdu);\n\t\t\t\tLOG_TEST_RET(ctx, rv, \"Failed to emulate DF FCP\");\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * Using of the cached DF and EF can cause problems in the multi-thread environment.\n\t\t * FIXME: introduce config. option that invalidates this cache outside the locked card session,\n\t\t *        (or invent something else)\n\t\t *\/\n\t\tif (rv == SC_ERROR_FILE_NOT_FOUND && cache_valid && df_from_cache)   {\n\t\t\tsc_invalidate_cache(card);\n\t\t\tsc_log(ctx, \"iasecc_select_file() file not found, retry without cached DF\");\n\t\t\tif (file_out)   {\n\t\t\t\tsc_file_free(*file_out);\n\t\t\t\t*file_out = NULL;\n\t\t\t}\n\t\t\trv = iasecc_select_file(card, path, file_out);\n\t\t\tLOG_FUNC_RETURN(ctx, rv);\n\t\t}\n\n\t\tLOG_TEST_RET(ctx, rv, \"iasecc_select_file() check SW failed\");\n\n\t\tsc_log(ctx,\n\t\t       \"iasecc_select_file() apdu.resp %\"SC_FORMAT_LEN_SIZE_T\"u\",\n\t\t       apdu.resplen);\n\t\tif (apdu.resplen)   {\n\t\t\tsc_log(ctx, \"apdu.resp %02X:%02X:%02X...\", apdu.resp[0], apdu.resp[1], apdu.resp[2]);\n\n\t\t\tswitch (apdu.resp[0]) {\n\t\t\tcase 0x62:\n\t\t\tcase 0x6F:\n\t\t\t\tfile = sc_file_new();\n\t\t\t\tif (file == NULL)\n\t\t\t\t\tLOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);\n\t\t\t\tfile->path = lpath;\n\n\t\t\t\trv = iasecc_process_fci(card, file, apdu.resp, apdu.resplen);\n\t\t\t\tif (rv)\n\t\t\t\t\tLOG_FUNC_RETURN(ctx, rv);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tLOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t\t\t}\n\n\t\t\tsc_log(ctx, \"FileType %i\", file->type);\n\t\t\tif (file->type == SC_FILE_TYPE_DF)   {\n\t\t\t\tif (card->cache.valid)\n\t\t\t\t\tsc_file_free(card->cache.current_df);\n\t\t\t\tcard->cache.current_df = NULL;\n\n\n\t\t\t\tif (card->cache.valid)\n\t\t\t\t\tsc_file_free(card->cache.current_ef);\n\t\t\t\tcard->cache.current_ef = NULL;\n\n\t\t\t\tsc_file_dup(&card->cache.current_df, file);\n\t\t\t\tcard->cache.valid = 1;\n\t\t\t}\n\t\t\telse   {\n\t\t\t\tif (card->cache.valid)\n\t\t\t\t\tsc_file_free(card->cache.current_ef);\n\n\t\t\t\tcard->cache.current_ef = NULL;\n\n\t\t\t\tsc_file_dup(&card->cache.current_ef, file);\n\t\t\t}\n\n\t\t\tif (file_out)   {\n\t\t\t\tsc_file_free(*file_out);\n\t\t\t\t*file_out = file;\n\t\t\t}\n\t\t\telse   {\n\t\t\t\tsc_file_free(file);\n\t\t\t}\n\t\t}\n\t\telse if (lpath.type == SC_PATH_TYPE_DF_NAME)   {\n\t\t\tsc_file_free(card->cache.current_df);\n\t\t\tcard->cache.current_df = NULL;\n\n\t\t\tsc_file_free(card->cache.current_ef);\n\t\t\tcard->cache.current_ef = NULL;\n\n\t\t\tcard->cache.valid = 1;\n\t\t}\n\t} while(0);\n\n\tsc_print_cache(card);\n\tLOG_FUNC_RETURN(ctx, SC_SUCCESS);\n}","target":1,"code_token_length":2427,"total_token_length":2663,"max_tokens_setting":4096}
+{"idx":493943,"func":"CURLcode Curl_http(struct Curl_easy *data, bool *done)\n{\n  struct connectdata *conn = data->conn;\n  CURLcode result = CURLE_OK;\n  struct HTTP *http;\n  Curl_HttpReq httpreq;\n  const char *te = \"\"; \/* transfer-encoding *\/\n  const char *request;\n  const char *httpstring;\n  struct dynbuf req;\n  char *altused = NULL;\n  const char *p_accept;      \/* Accept: string *\/\n\n  \/* Always consider the DO phase done after this function call, even if there\n     may be parts of the request that are not yet sent, since we can deal with\n     the rest of the request in the PERFORM phase. *\/\n  *done = TRUE;\n\n  if(conn->transport != TRNSPRT_QUIC) {\n    if(conn->httpversion < 20) { \/* unless the connection is re-used and\n                                    already http2 *\/\n      switch(conn->negnpn) {\n      case CURL_HTTP_VERSION_2:\n        conn->httpversion = 20; \/* we know we're on HTTP\/2 now *\/\n\n        result = Curl_http2_switched(data, NULL, 0);\n        if(result)\n          return result;\n        break;\n      case CURL_HTTP_VERSION_1_1:\n        \/* continue with HTTP\/1.1 when explicitly requested *\/\n        break;\n      default:\n        \/* Check if user wants to use HTTP\/2 with clear TCP*\/\n#ifdef USE_NGHTTP2\n        if(data->state.httpwant == CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE) {\n#ifndef CURL_DISABLE_PROXY\n          if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {\n            \/* We don't support HTTP\/2 proxies yet. Also it's debatable\n               whether or not this setting should apply to HTTP\/2 proxies. *\/\n            infof(data, \"Ignoring HTTP\/2 prior knowledge due to proxy\");\n            break;\n          }\n#endif\n          DEBUGF(infof(data, \"HTTP\/2 over clean TCP\"));\n          conn->httpversion = 20;\n\n          result = Curl_http2_switched(data, NULL, 0);\n          if(result)\n            return result;\n        }\n#endif\n        break;\n      }\n    }\n    else {\n      \/* prepare for a http2 request *\/\n      result = Curl_http2_setup(data, conn);\n      if(result)\n        return result;\n    }\n  }\n  http = data->req.p.http;\n  DEBUGASSERT(http);\n\n  result = Curl_http_host(data, conn);\n  if(result)\n    return result;\n\n  result = Curl_http_useragent(data);\n  if(result)\n    return result;\n\n  Curl_http_method(data, conn, &request, &httpreq);\n\n  \/* setup the authentication headers *\/\n  {\n    char *pq = NULL;\n    if(data->state.up.query) {\n      pq = aprintf(\"%s?%s\", data->state.up.path, data->state.up.query);\n      if(!pq)\n        return CURLE_OUT_OF_MEMORY;\n    }\n    result = Curl_http_output_auth(data, conn, request, httpreq,\n                                   (pq ? pq : data->state.up.path), FALSE);\n    free(pq);\n    if(result)\n      return result;\n  }\n\n  Curl_safefree(data->state.aptr.ref);\n  if(data->state.referer && !Curl_checkheaders(data, STRCONST(\"Referer\"))) {\n    data->state.aptr.ref = aprintf(\"Referer: %s\\r\\n\", data->state.referer);\n    if(!data->state.aptr.ref)\n      return CURLE_OUT_OF_MEMORY;\n  }\n\n  if(!Curl_checkheaders(data, STRCONST(\"Accept-Encoding\")) &&\n     data->set.str[STRING_ENCODING]) {\n    Curl_safefree(data->state.aptr.accept_encoding);\n    data->state.aptr.accept_encoding =\n      aprintf(\"Accept-Encoding: %s\\r\\n\", data->set.str[STRING_ENCODING]);\n    if(!data->state.aptr.accept_encoding)\n      return CURLE_OUT_OF_MEMORY;\n  }\n  else\n    Curl_safefree(data->state.aptr.accept_encoding);\n\n#ifdef HAVE_LIBZ\n  \/* we only consider transfer-encoding magic if libz support is built-in *\/\n  result = Curl_transferencode(data);\n  if(result)\n    return result;\n#endif\n\n  result = Curl_http_body(data, conn, httpreq, &te);\n  if(result)\n    return result;\n\n  p_accept = Curl_checkheaders(data,\n                               STRCONST(\"Accept\"))?NULL:\"Accept: *\/*\\r\\n\";\n\n  result = Curl_http_resume(data, conn, httpreq);\n  if(result)\n    return result;\n\n  result = Curl_http_range(data, httpreq);\n  if(result)\n    return result;\n\n  httpstring = get_http_string(data, conn);\n\n  \/* initialize a dynamic send-buffer *\/\n  Curl_dyn_init(&req, DYN_HTTP_REQUEST);\n\n  \/* make sure the header buffer is reset - if there are leftovers from a\n     previous transfer *\/\n  Curl_dyn_reset(&data->state.headerb);\n\n  \/* add the main request stuff *\/\n  \/* GET\/HEAD\/POST\/PUT *\/\n  result = Curl_dyn_addf(&req, \"%s \", request);\n  if(!result)\n    result = Curl_http_target(data, conn, &req);\n  if(result) {\n    Curl_dyn_free(&req);\n    return result;\n  }\n\n#ifndef CURL_DISABLE_ALTSVC\n  if(conn->bits.altused && !Curl_checkheaders(data, STRCONST(\"Alt-Used\"))) {\n    altused = aprintf(\"Alt-Used: %s:%d\\r\\n\",\n                      conn->conn_to_host.name, conn->conn_to_port);\n    if(!altused) {\n      Curl_dyn_free(&req);\n      return CURLE_OUT_OF_MEMORY;\n    }\n  }\n#endif\n  result =\n    Curl_dyn_addf(&req,\n                  \" HTTP\/%s\\r\\n\" \/* HTTP version *\/\n                  \"%s\" \/* host *\/\n                  \"%s\" \/* proxyuserpwd *\/\n                  \"%s\" \/* userpwd *\/\n                  \"%s\" \/* range *\/\n                  \"%s\" \/* user agent *\/\n                  \"%s\" \/* accept *\/\n                  \"%s\" \/* TE: *\/\n                  \"%s\" \/* accept-encoding *\/\n                  \"%s\" \/* referer *\/\n                  \"%s\" \/* Proxy-Connection *\/\n                  \"%s\" \/* transfer-encoding *\/\n                  \"%s\",\/* Alt-Used *\/\n\n                  httpstring,\n                  (data->state.aptr.host?data->state.aptr.host:\"\"),\n                  data->state.aptr.proxyuserpwd?\n                  data->state.aptr.proxyuserpwd:\"\",\n                  data->state.aptr.userpwd?data->state.aptr.userpwd:\"\",\n                  (data->state.use_range && data->state.aptr.rangeline)?\n                  data->state.aptr.rangeline:\"\",\n                  (data->set.str[STRING_USERAGENT] &&\n                   *data->set.str[STRING_USERAGENT] &&\n                   data->state.aptr.uagent)?\n                  data->state.aptr.uagent:\"\",\n                  p_accept?p_accept:\"\",\n                  data->state.aptr.te?data->state.aptr.te:\"\",\n                  (data->set.str[STRING_ENCODING] &&\n                   *data->set.str[STRING_ENCODING] &&\n                   data->state.aptr.accept_encoding)?\n                  data->state.aptr.accept_encoding:\"\",\n                  (data->state.referer && data->state.aptr.ref)?\n                  data->state.aptr.ref:\"\" \/* Referer:  *\/,\n#ifndef CURL_DISABLE_PROXY\n                  (conn->bits.httpproxy &&\n                   !conn->bits.tunnel_proxy &&\n                   !Curl_checkheaders(data, STRCONST(\"Proxy-Connection\")) &&\n                   !Curl_checkProxyheaders(data,\n                                           conn,\n                                           STRCONST(\"Proxy-Connection\")))?\n                  \"Proxy-Connection: Keep-Alive\\r\\n\":\"\",\n#else\n                  \"\",\n#endif\n                  te,\n                  altused ? altused : \"\"\n      );\n\n  \/* clear userpwd and proxyuserpwd to avoid re-using old credentials\n   * from re-used connections *\/\n  Curl_safefree(data->state.aptr.userpwd);\n  Curl_safefree(data->state.aptr.proxyuserpwd);\n  free(altused);\n\n  if(result) {\n    Curl_dyn_free(&req);\n    return result;\n  }\n\n  if(!(conn->handler->flags&PROTOPT_SSL) &&\n     conn->httpversion != 20 &&\n     (data->state.httpwant == CURL_HTTP_VERSION_2)) {\n    \/* append HTTP2 upgrade magic stuff to the HTTP request if it isn't done\n       over SSL *\/\n    result = Curl_http2_request_upgrade(&req, data);\n    if(result) {\n      Curl_dyn_free(&req);\n      return result;\n    }\n  }\n\n  result = Curl_http_cookies(data, conn, &req);\n  if(!result)\n    result = Curl_add_timecondition(data, &req);\n  if(!result)\n    result = Curl_add_custom_headers(data, FALSE, &req);\n\n  if(!result) {\n    http->postdata = NULL;  \/* nothing to post at this point *\/\n    if((httpreq == HTTPREQ_GET) ||\n       (httpreq == HTTPREQ_HEAD))\n      Curl_pgrsSetUploadSize(data, 0); \/* nothing *\/\n\n    \/* bodysend takes ownership of the 'req' memory on success *\/\n    result = Curl_http_bodysend(data, conn, &req, httpreq);\n  }\n  if(result) {\n    Curl_dyn_free(&req);\n    return result;\n  }\n\n  if((http->postsize > -1) &&\n     (http->postsize <= data->req.writebytecount) &&\n     (http->sending != HTTPSEND_REQUEST))\n    data->req.upload_done = TRUE;\n\n  if(data->req.writebytecount) {\n    \/* if a request-body has been sent off, we make sure this progress is noted\n       properly *\/\n    Curl_pgrsSetUploadCounter(data, data->req.writebytecount);\n    if(Curl_pgrsUpdate(data))\n      result = CURLE_ABORTED_BY_CALLBACK;\n\n    if(!http->postsize) {\n      \/* already sent the entire request body, mark the \"upload\" as\n         complete *\/\n      infof(data, \"upload completely sent off: %\" CURL_FORMAT_CURL_OFF_T\n            \" out of %\" CURL_FORMAT_CURL_OFF_T \" bytes\",\n            data->req.writebytecount, http->postsize);\n      data->req.upload_done = TRUE;\n      data->req.keepon &= ~KEEP_SEND; \/* we're done writing *\/\n      data->req.exp100 = EXP100_SEND_DATA; \/* already sent *\/\n      Curl_expire_done(data, EXPIRE_100_TIMEOUT);\n    }\n  }\n\n  if((conn->httpversion == 20) && data->req.upload_chunky)\n    \/* upload_chunky was set above to set up the request in a chunky fashion,\n       but is disabled here again to avoid that the chunked encoded version is\n       actually used when sending the request body over h2 *\/\n    data->req.upload_chunky = FALSE;\n  return result;\n}","target":0,"code_token_length":2324,"total_token_length":2560,"max_tokens_setting":4096}
+{"idx":363068,"func":"DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *file)\n{\n\tFILE\t*p;\n\tInt32\targ;\n\tint\top;\n\tlong\toffset;\n\tint\tn;\n\tDviContext *dvi;\n\tchar\t*filename;\n\tint\tpagecount;\n\n\t\/*\n\t * 1. Open the file and initialize the DVI context\n\t *\/\t\n\n\tfilename = opendvi(file);\n\tif(filename == NULL) {\n\t\tperror(file);\n\t\treturn NULL;\n\t}\n\tp = fopen(filename, \"rb\");\n\tif(p == NULL) {\n\t\tperror(file);\n\t\tmdvi_free(filename);\n\t\treturn NULL;\n\t}\n\tdvi = xalloc(DviContext);\n\tmemzero(dvi, sizeof(DviContext));\n\tdvi->pagemap = NULL;\n\tdvi->filename = filename;\n\tdvi->stack = NULL;\n\tdvi->modtime = get_mtime(fileno(p));\t\n\tdvi->buffer.data = NULL;\n\tdvi->pagesel = spec;\n\tdvi->in = p; \/* now we can use the dget*() functions *\/\n\n\t\/* \n\t * 2. Read the preamble, extract scaling information, and \n\t *    setup the DVI parameters.\n\t *\/\n\n\tif(fuget1(p) != DVI_PRE)\n\t\tgoto bad_dvi;\n\tif((arg = fuget1(p)) != DVI_ID) {\n\t\tmdvi_error(_(\"%s: unsupported DVI format (version %u)\\n\"),\n\t\t\t   file, arg);\n\t\tgoto error; \/* jump to the end of this routine, \n\t\t\t     * where we handle errors *\/\n\t}\n\t\/* get dimensions *\/\n\tdvi->num = fuget4(p);\n\tdvi->den = fuget4(p);\n\tdvi->dvimag = fuget4(p);\n\n\t\/* check that these numbers make sense *\/\n\tif(!dvi->num || !dvi->den || !dvi->dvimag)\n\t\tgoto bad_dvi;\n\t\n\tdvi->params.mag = \n\t\t(par->mag > 0 ? par->mag : (double)dvi->dvimag \/ 1000.0);\n\tdvi->params.hdrift  = par->hdrift;\n\tdvi->params.vdrift  = par->vdrift;\n\tdvi->params.dpi     = par->dpi ? par->dpi : MDVI_DPI;\n\tdvi->params.vdpi    = par->vdpi ? par->vdpi : par->dpi;\n\tdvi->params.hshrink = par->hshrink;\n\tdvi->params.vshrink = par->vshrink;\n\tdvi->params.density = par->density;\n\tdvi->params.gamma   = par->gamma;\n\tdvi->params.conv    = (double)dvi->num \/ dvi->den;\n\tdvi->params.conv   *= (dvi->params.dpi \/ 254000.0) * dvi->params.mag;\n\tdvi->params.vconv   = (double)dvi->num \/ dvi->den;\n\tdvi->params.vconv  *= (dvi->params.vdpi \/ 254000.0) * dvi->params.mag;\n\tdvi->params.tfm_conv = (25400000.0 \/ dvi->num) *\n\t\t\t\t((double)dvi->den \/ 473628672) \/ 16.0;\n\tdvi->params.flags = par->flags;\n\tdvi->params.orientation = par->orientation;\n\tdvi->params.fg = par->fg;\n\tdvi->params.bg = par->bg;\n\n\t\/* initialize colors *\/\n\tdvi->curr_fg = par->fg;\n\tdvi->curr_bg = par->bg;\n\tdvi->color_stack = NULL;\n\tdvi->color_top = 0;\n\tdvi->color_size = 0;\n\n\t\/* pixel conversion factors *\/\n\tdvi->dviconv = dvi->params.conv;\n\tdvi->dvivconv = dvi->params.vconv;\n\tif(dvi->params.hshrink)\n\t\tdvi->params.conv \/= dvi->params.hshrink;\n\tif(dvi->params.vshrink)\n\t\tdvi->params.vconv \/= dvi->params.vshrink;\n\n\t\/* get the comment from the preamble *\/\n\tn = fuget1(p);\n\tdvi->fileid = mdvi_malloc(n + 1);\n\tfread(dvi->fileid, 1, n, p);\n\tdvi->fileid[n] = 0;\n\tDEBUG((DBG_DVI, \"%s: %s\\n\", filename, dvi->fileid));\n\t\n\t\/*\n\t * 3. Read postamble, extract page information (number of\n\t *    pages, dimensions) and stack depth.\n\t *\/\n\n\t\/* jump to the end of the file *\/\n\tif(fseek(p, (long)-1, SEEK_END) == -1)\n\t\tgoto error;\t\n\tfor(n = 0; (op = fuget1(p)) == DVI_TRAILER; n++)\n\t\tif(fseek(p, (long)-2, SEEK_CUR) < 0)\n\t\t\tbreak;\n\tif(op != arg || n < 4)\n\t\tgoto bad_dvi;\n\t\/* get the pointer to postamble *\/\n\tfseek(p, (long)-5, SEEK_CUR);\n\targ = fuget4(p);\n\t\/* jump to it *\/\n\tfseek(p, (long)arg, SEEK_SET);\n\tif(fuget1(p) != DVI_POST)\n\t\tgoto bad_dvi;\n\toffset = fuget4(p);\n\tif(dvi->num != fuget4(p) || dvi->den != fuget4(p) ||\n\t   dvi->dvimag != fuget4(p))\n\t\tgoto bad_dvi;\n\tdvi->dvi_page_h = fuget4(p);\n\tdvi->dvi_page_w = fuget4(p);\n\tdvi->stacksize = fuget2(p);\n\tdvi->npages = fuget2(p);\n\tDEBUG((DBG_DVI, \"%s: from postamble: stack depth %d, %d page%s\\n\",\n\t\tfilename, dvi->stacksize, dvi->npages, dvi->npages > 1 ? \"s\" : \"\"));\n\t\n\t\/*\n\t * 4. Process font definitions.\n\t *\/\n\n\t\/* process font definitions *\/\n\tdvi->nfonts = 0;\n\tdvi->fontmap = NULL;\n\t\/* \n\t * CAREFUL: here we need to use the dvi->buffer, but it might leave the\n\t * the file cursor in the wrong position after reading fonts (because of\n\t * buffering). It's ok, though, because after the font definitions we read\n\t * the page offsets, and we fseek() to the relevant part of the file with\n\t * SEEK_SET. Nothing is read after the page offsets.\n\t *\/\n\twhile((op = duget1(dvi)) != DVI_POST_POST) {\n\t\tDviFontRef *ref;\n\t\t\n\t\tif(op == DVI_NOOP)\n\t\t\tcontinue;\n\t\telse if(op < DVI_FNT_DEF1 || op > DVI_FNT_DEF4)\n\t\t\tgoto error;\n\t\tref = define_font(dvi, op);\n\t\tif(ref == NULL)\n\t\t\tgoto error;\n\t\tref->next = dvi->fonts;\n\t\tdvi->fonts = ref;\n\t\tdvi->nfonts++;\n\t}\n\t\/* we don't need the buffer anymore *\/\n\tdreset(dvi);\n\t\n\tif(op != DVI_POST_POST)\n\t\tgoto bad_dvi;\n\tfont_finish_definitions(dvi);\n\tDEBUG((DBG_DVI, \"%s: %d font%s required by this job\\n\",\n\t\tfilename, dvi->nfonts, dvi->nfonts > 1 ? \"s\" : \"\"));\n\tdvi->findref = font_find_mapped;\n\n\t\/*\n\t * 5. Build the page map.\n\t *\/\n\n\tdvi->pagemap = xnalloc(PageNum, dvi->npages);\n\tmemzero(dvi->pagemap, sizeof(PageNum) * dvi->npages);\n\t\t\n\tn = dvi->npages - 1;\n\tpagecount = n;\n\twhile(offset != -1) {\n\t\tint\ti;\n\t\tPageNum page;\n\n\t\tfseek(p, offset, SEEK_SET);\t\t\n\t\top = fuget1(p);\n\t\tif(op != DVI_BOP || n < 0)\n\t\t\tgoto bad_dvi;\n\t\tfor(i = 1; i <= 10; i++)\n\t\t\tpage[i] = fsget4(p);\n\t\tpage[0] = offset;\n\t\toffset = fsget4(p);\n\t\t\/* check if the page is selected *\/\n\t\tif(spec && mdvi_page_selected(spec, page, n) == 0) {\n\t\t\tDEBUG((DBG_DVI, \"Page %d (%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld) ignored by request\\n\",\n\t\t\tn, page[1], page[2], page[3], page[4], page[5],\n\t\t\t   page[6], page[7], page[8], page[9], page[10]));\n\t\t} else {\n\t\t\tmemcpy(&dvi->pagemap[pagecount], page, sizeof(PageNum));\n\t\t\tpagecount--;\n\t\t}\n\t\tn--;\n\t}\n\tpagecount++;\n\tif(pagecount >= dvi->npages) {\n\t\tmdvi_error(_(\"no pages selected\\n\"));\n\t\tgoto error;\n\t}\n\tif(pagecount) {\n\t\tDEBUG((DBG_DVI, \"%d of %d pages selected\\n\",\n\t\t\tdvi->npages - pagecount, dvi->npages));\n\t\tdvi->npages -= pagecount;\n\t\tmemmove(dvi->pagemap, &dvi->pagemap[pagecount], \n\t\t\tdvi->npages * sizeof(PageNum));\n\t}\n\n\t\/*\n\t * 6. Setup stack, initialize device functions\n\t *\/\n\n\tdvi->curr_layer = 0;\n\tdvi->stack = xnalloc(DviState, dvi->stacksize + 8);\n\n\tdvi->device.draw_glyph   = dummy_draw_glyph;\n\tdvi->device.draw_rule    = dummy_draw_rule;\n\tdvi->device.alloc_colors = dummy_alloc_colors;\n\tdvi->device.create_image = dummy_create_image;\n\tdvi->device.free_image   = dummy_free_image;\n\tdvi->device.dev_destroy  = dummy_dev_destroy;\n\tdvi->device.put_pixel    = dummy_dev_putpixel;\n\tdvi->device.refresh      = dummy_dev_refresh;\n\tdvi->device.set_color    = dummy_dev_set_color;\n\tdvi->device.device_data  = NULL;\n\n\tDEBUG((DBG_DVI, \"%s read successfully\\n\", filename));\n\treturn dvi;\n\nbad_dvi:\n\tmdvi_error(_(\"%s: File corrupted, or not a DVI file\\n\"), file);\nerror:\n\t\/* if we came from the font definitions, this will be non-trivial *\/\n\tdreset(dvi);\n\tmdvi_destroy_context(dvi);\n\treturn NULL;\n}","target":0,"code_token_length":2297,"total_token_length":2533,"max_tokens_setting":4096}
+{"idx":98339,"func":"static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,\n\t\tstruct scsi_cmnd *cmd)\n{\n\tchar *buffer;\n\tunsigned short use_sg;\n\tint retvalue = 0, transfer_len = 0;\n\tunsigned long flags;\n\tstruct CMD_MESSAGE_FIELD *pcmdmessagefld;\n\tuint32_t controlcode = (uint32_t)cmd->cmnd[5] << 24 |\n\t\t(uint32_t)cmd->cmnd[6] << 16 |\n\t\t(uint32_t)cmd->cmnd[7] << 8 |\n\t\t(uint32_t)cmd->cmnd[8];\n\tstruct scatterlist *sg;\n\n\tuse_sg = scsi_sg_count(cmd);\n\tsg = scsi_sglist(cmd);\n\tbuffer = kmap_atomic(sg_page(sg)) + sg->offset;\n\tif (use_sg > 1) {\n\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\tgoto message_out;\n\t}\n\ttransfer_len += sg->length;\n\tif (transfer_len > sizeof(struct CMD_MESSAGE_FIELD)) {\n\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\tpr_info(\"%s: ARCMSR_MESSAGE_FAIL!\\n\", __func__);\n\t\tgoto message_out;\n\t}\n\tpcmdmessagefld = (struct CMD_MESSAGE_FIELD *)buffer;\n\tswitch (controlcode) {\n\tcase ARCMSR_MESSAGE_READ_RQBUFFER: {\n\t\tunsigned char *ver_addr;\n\t\tuint8_t *ptmpQbuffer;\n\t\tuint32_t allxfer_len = 0;\n\t\tver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC);\n\t\tif (!ver_addr) {\n\t\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\t\tpr_info(\"%s: memory not enough!\\n\", __func__);\n\t\t\tgoto message_out;\n\t\t}\n\t\tptmpQbuffer = ver_addr;\n\t\tspin_lock_irqsave(&acb->rqbuffer_lock, flags);\n\t\tif (acb->rqbuf_getIndex != acb->rqbuf_putIndex) {\n\t\t\tunsigned int tail = acb->rqbuf_getIndex;\n\t\t\tunsigned int head = acb->rqbuf_putIndex;\n\t\t\tunsigned int cnt_to_end = CIRC_CNT_TO_END(head, tail, ARCMSR_MAX_QBUFFER);\n\n\t\t\tallxfer_len = CIRC_CNT(head, tail, ARCMSR_MAX_QBUFFER);\n\t\t\tif (allxfer_len > ARCMSR_API_DATA_BUFLEN)\n\t\t\t\tallxfer_len = ARCMSR_API_DATA_BUFLEN;\n\n\t\t\tif (allxfer_len <= cnt_to_end)\n\t\t\t\tmemcpy(ptmpQbuffer, acb->rqbuffer + tail, allxfer_len);\n\t\t\telse {\n\t\t\t\tmemcpy(ptmpQbuffer, acb->rqbuffer + tail, cnt_to_end);\n\t\t\t\tmemcpy(ptmpQbuffer + cnt_to_end, acb->rqbuffer, allxfer_len - cnt_to_end);\n\t\t\t}\n\t\t\tacb->rqbuf_getIndex = (acb->rqbuf_getIndex + allxfer_len) % ARCMSR_MAX_QBUFFER;\n\t\t}\n\t\tmemcpy(pcmdmessagefld->messagedatabuffer, ver_addr,\n\t\t\tallxfer_len);\n\t\tif (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {\n\t\t\tstruct QBUFFER __iomem *prbuffer;\n\t\t\tacb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;\n\t\t\tprbuffer = arcmsr_get_iop_rqbuffer(acb);\n\t\t\tif (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0)\n\t\t\t\tacb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;\n\t\t}\n\t\tspin_unlock_irqrestore(&acb->rqbuffer_lock, flags);\n\t\tkfree(ver_addr);\n\t\tpcmdmessagefld->cmdmessage.Length = allxfer_len;\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_WRITE_WQBUFFER: {\n\t\tunsigned char *ver_addr;\n\t\tuint32_t user_len;\n\t\tint32_t cnt2end;\n\t\tuint8_t *pQbuffer, *ptmpuserbuffer;\n\t\tver_addr = kmalloc(ARCMSR_API_DATA_BUFLEN, GFP_ATOMIC);\n\t\tif (!ver_addr) {\n\t\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\t\tgoto message_out;\n\t\t}\n\t\tptmpuserbuffer = ver_addr;\n\t\tuser_len = pcmdmessagefld->cmdmessage.Length;\n\t\tif (user_len > ARCMSR_API_DATA_BUFLEN) {\n\t\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\t\tkfree(ver_addr);\n\t\t\tgoto message_out;\n\t\t}\n\t\tmemcpy(ptmpuserbuffer,\n\t\t\tpcmdmessagefld->messagedatabuffer, user_len);\n\t\tspin_lock_irqsave(&acb->wqbuffer_lock, flags);\n\t\tif (acb->wqbuf_putIndex != acb->wqbuf_getIndex) {\n\t\t\tstruct SENSE_DATA *sensebuffer =\n\t\t\t\t(struct SENSE_DATA *)cmd->sense_buffer;\n\t\t\tarcmsr_write_ioctldata2iop(acb);\n\t\t\t\/* has error report sensedata *\/\n\t\t\tsensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;\n\t\t\tsensebuffer->SenseKey = ILLEGAL_REQUEST;\n\t\t\tsensebuffer->AdditionalSenseLength = 0x0A;\n\t\t\tsensebuffer->AdditionalSenseCode = 0x20;\n\t\t\tsensebuffer->Valid = 1;\n\t\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\t} else {\n\t\t\tpQbuffer = &acb->wqbuffer[acb->wqbuf_putIndex];\n\t\t\tcnt2end = ARCMSR_MAX_QBUFFER - acb->wqbuf_putIndex;\n\t\t\tif (user_len > cnt2end) {\n\t\t\t\tmemcpy(pQbuffer, ptmpuserbuffer, cnt2end);\n\t\t\t\tptmpuserbuffer += cnt2end;\n\t\t\t\tuser_len -= cnt2end;\n\t\t\t\tacb->wqbuf_putIndex = 0;\n\t\t\t\tpQbuffer = acb->wqbuffer;\n\t\t\t}\n\t\t\tmemcpy(pQbuffer, ptmpuserbuffer, user_len);\n\t\t\tacb->wqbuf_putIndex += user_len;\n\t\t\tacb->wqbuf_putIndex %= ARCMSR_MAX_QBUFFER;\n\t\t\tif (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) {\n\t\t\t\tacb->acb_flags &=\n\t\t\t\t\t\t~ACB_F_MESSAGE_WQBUFFER_CLEARED;\n\t\t\t\tarcmsr_write_ioctldata2iop(acb);\n\t\t\t}\n\t\t}\n\t\tspin_unlock_irqrestore(&acb->wqbuffer_lock, flags);\n\t\tkfree(ver_addr);\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_CLEAR_RQBUFFER: {\n\t\tuint8_t *pQbuffer = acb->rqbuffer;\n\n\t\tarcmsr_clear_iop2drv_rqueue_buffer(acb);\n\t\tspin_lock_irqsave(&acb->rqbuffer_lock, flags);\n\t\tacb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;\n\t\tacb->rqbuf_getIndex = 0;\n\t\tacb->rqbuf_putIndex = 0;\n\t\tmemset(pQbuffer, 0, ARCMSR_MAX_QBUFFER);\n\t\tspin_unlock_irqrestore(&acb->rqbuffer_lock, flags);\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_CLEAR_WQBUFFER: {\n\t\tuint8_t *pQbuffer = acb->wqbuffer;\n\t\tspin_lock_irqsave(&acb->wqbuffer_lock, flags);\n\t\tacb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |\n\t\t\tACB_F_MESSAGE_WQBUFFER_READED);\n\t\tacb->wqbuf_getIndex = 0;\n\t\tacb->wqbuf_putIndex = 0;\n\t\tmemset(pQbuffer, 0, ARCMSR_MAX_QBUFFER);\n\t\tspin_unlock_irqrestore(&acb->wqbuffer_lock, flags);\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_CLEAR_ALLQBUFFER: {\n\t\tuint8_t *pQbuffer;\n\t\tarcmsr_clear_iop2drv_rqueue_buffer(acb);\n\t\tspin_lock_irqsave(&acb->rqbuffer_lock, flags);\n\t\tacb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;\n\t\tacb->rqbuf_getIndex = 0;\n\t\tacb->rqbuf_putIndex = 0;\n\t\tpQbuffer = acb->rqbuffer;\n\t\tmemset(pQbuffer, 0, sizeof(struct QBUFFER));\n\t\tspin_unlock_irqrestore(&acb->rqbuffer_lock, flags);\n\t\tspin_lock_irqsave(&acb->wqbuffer_lock, flags);\n\t\tacb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |\n\t\t\tACB_F_MESSAGE_WQBUFFER_READED);\n\t\tacb->wqbuf_getIndex = 0;\n\t\tacb->wqbuf_putIndex = 0;\n\t\tpQbuffer = acb->wqbuffer;\n\t\tmemset(pQbuffer, 0, sizeof(struct QBUFFER));\n\t\tspin_unlock_irqrestore(&acb->wqbuffer_lock, flags);\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_RETURN_CODE_3F: {\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_3F;\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_SAY_HELLO: {\n\t\tint8_t *hello_string = \"Hello! I am ARCMSR\";\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tmemcpy(pcmdmessagefld->messagedatabuffer,\n\t\t\thello_string, (int16_t)strlen(hello_string));\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_SAY_GOODBYE: {\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tarcmsr_iop_parking(acb);\n\t\tbreak;\n\t}\n\tcase ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE: {\n\t\tif (acb->fw_flag == FW_DEADLOCK)\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;\n\t\telse\n\t\t\tpcmdmessagefld->cmdmessage.ReturnCode =\n\t\t\t\tARCMSR_MESSAGE_RETURNCODE_OK;\n\t\tarcmsr_flush_adapter_cache(acb);\n\t\tbreak;\n\t}\n\tdefault:\n\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\tpr_info(\"%s: unknown controlcode!\\n\", __func__);\n\t}\nmessage_out:\n\tif (use_sg) {\n\t\tstruct scatterlist *sg = scsi_sglist(cmd);\n\t\tkunmap_atomic(buffer - sg->offset);\n\t}\n\treturn retvalue;\n}","target":0,"code_token_length":2672,"total_token_length":2908,"max_tokens_setting":4096}
+{"idx":147934,"func":"static int multiSelectOrderBy(\n  Parse *pParse,        \/* Parsing context *\/\n  Select *p,            \/* The right-most of SELECTs to be coded *\/\n  SelectDest *pDest     \/* What to do with query results *\/\n){\n  int i, j;             \/* Loop counters *\/\n  Select *pPrior;       \/* Another SELECT immediately to our left *\/\n  Vdbe *v;              \/* Generate code to this VDBE *\/\n  SelectDest destA;     \/* Destination for coroutine A *\/\n  SelectDest destB;     \/* Destination for coroutine B *\/\n  int regAddrA;         \/* Address register for select-A coroutine *\/\n  int regAddrB;         \/* Address register for select-B coroutine *\/\n  int addrSelectA;      \/* Address of the select-A coroutine *\/\n  int addrSelectB;      \/* Address of the select-B coroutine *\/\n  int regOutA;          \/* Address register for the output-A subroutine *\/\n  int regOutB;          \/* Address register for the output-B subroutine *\/\n  int addrOutA;         \/* Address of the output-A subroutine *\/\n  int addrOutB = 0;     \/* Address of the output-B subroutine *\/\n  int addrEofA;         \/* Address of the select-A-exhausted subroutine *\/\n  int addrEofA_noB;     \/* Alternate addrEofA if B is uninitialized *\/\n  int addrEofB;         \/* Address of the select-B-exhausted subroutine *\/\n  int addrAltB;         \/* Address of the AB subroutine *\/\n  int regLimitA;        \/* Limit register for select-A *\/\n  int regLimitB;        \/* Limit register for select-A *\/\n  int regPrev;          \/* A range of registers to hold previous output *\/\n  int savedLimit;       \/* Saved value of p->iLimit *\/\n  int savedOffset;      \/* Saved value of p->iOffset *\/\n  int labelCmpr;        \/* Label for the start of the merge algorithm *\/\n  int labelEnd;         \/* Label for the end of the overall SELECT stmt *\/\n  int addr1;            \/* Jump instructions that get retargetted *\/\n  int op;               \/* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT *\/\n  KeyInfo *pKeyDup = 0; \/* Comparison information for duplicate removal *\/\n  KeyInfo *pKeyMerge;   \/* Comparison information for merging rows *\/\n  sqlite3 *db;          \/* Database connection *\/\n  ExprList *pOrderBy;   \/* The ORDER BY clause *\/\n  int nOrderBy;         \/* Number of terms in the ORDER BY clause *\/\n  int *aPermute;        \/* Mapping from ORDER BY terms to result set columns *\/\n\n  assert( p->pOrderBy!=0 );\n  assert( pKeyDup==0 ); \/* \"Managed\" code needs this.  Ticket #3382. *\/\n  db = pParse->db;\n  v = pParse->pVdbe;\n  assert( v!=0 );       \/* Already thrown the error if VDBE alloc failed *\/\n  labelEnd = sqlite3VdbeMakeLabel(pParse);\n  labelCmpr = sqlite3VdbeMakeLabel(pParse);\n\n\n  \/* Patch up the ORDER BY clause\n  *\/\n  op = p->op;  \n  pPrior = p->pPrior;\n  assert( pPrior->pOrderBy==0 );\n  pOrderBy = p->pOrderBy;\n  assert( pOrderBy );\n  nOrderBy = pOrderBy->nExpr;\n\n  \/* For operators other than UNION ALL we have to make sure that\n  ** the ORDER BY clause covers every term of the result set.  Add\n  ** terms to the ORDER BY clause as necessary.\n  *\/\n  if( op!=TK_ALL ){\n    for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){\n      struct ExprList_item *pItem;\n      for(j=0, pItem=pOrderBy->a; ju.x.iOrderByCol>0 );\n        if( pItem->u.x.iOrderByCol==i ) break;\n      }\n      if( j==nOrderBy ){\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = i;\n        p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew);\n        if( pOrderBy ) pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i;\n      }\n    }\n  }\n\n  \/* Compute the comparison permutation and keyinfo that is used with\n  ** the permutation used to determine if the next\n  ** row of results comes from selectA or selectB.  Also add explicit\n  ** collations to the ORDER BY clause terms so that when the subqueries\n  ** to the right and the left are evaluated, they use the correct\n  ** collation.\n  *\/\n  aPermute = sqlite3DbMallocRawNN(db, sizeof(int)*(nOrderBy + 1));\n  if( aPermute ){\n    struct ExprList_item *pItem;\n    aPermute[0] = nOrderBy;\n    for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){\n      assert( pItem->u.x.iOrderByCol>0 );\n      assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );\n      aPermute[i] = pItem->u.x.iOrderByCol - 1;\n    }\n    pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);\n  }else{\n    pKeyMerge = 0;\n  }\n\n  \/* Reattach the ORDER BY clause to the query.\n  *\/\n  p->pOrderBy = pOrderBy;\n  pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);\n\n  \/* Allocate a range of temporary registers and the KeyInfo needed\n  ** for the logic that removes duplicate result rows when the\n  ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).\n  *\/\n  if( op==TK_ALL ){\n    regPrev = 0;\n  }else{\n    int nExpr = p->pEList->nExpr;\n    assert( nOrderBy>=nExpr || db->mallocFailed );\n    regPrev = pParse->nMem+1;\n    pParse->nMem += nExpr+1;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);\n    pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);\n    if( pKeyDup ){\n      assert( sqlite3KeyInfoIsWriteable(pKeyDup) );\n      for(i=0; iaColl[i] = multiSelectCollSeq(pParse, p, i);\n        pKeyDup->aSortFlags[i] = 0;\n      }\n    }\n  }\n \n  \/* Separate the left and the right query from one another\n  *\/\n  p->pPrior = 0;\n  pPrior->pNext = 0;\n  sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, \"ORDER\");\n  if( pPrior->pPrior==0 ){\n    sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, \"ORDER\");\n  }\n\n  \/* Compute the limit registers *\/\n  computeLimitRegisters(pParse, p, labelEnd);\n  if( p->iLimit && op==TK_ALL ){\n    regLimitA = ++pParse->nMem;\n    regLimitB = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit,\n                                  regLimitA);\n    sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB);\n  }else{\n    regLimitA = regLimitB = 0;\n  }\n  sqlite3ExprDelete(db, p->pLimit);\n  p->pLimit = 0;\n\n  regAddrA = ++pParse->nMem;\n  regAddrB = ++pParse->nMem;\n  regOutA = ++pParse->nMem;\n  regOutB = ++pParse->nMem;\n  sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);\n  sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);\n\n  ExplainQueryPlan((pParse, 1, \"MERGE (%s)\", selectOpName(p->op)));\n\n  \/* Generate a coroutine to evaluate the SELECT statement to the\n  ** left of the compound operator - the \"A\" select.\n  *\/\n  addrSelectA = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);\n  VdbeComment((v, \"left SELECT\"));\n  pPrior->iLimit = regLimitA;\n  ExplainQueryPlan((pParse, 1, \"LEFT\"));\n  sqlite3Select(pParse, pPrior, &destA);\n  sqlite3VdbeEndCoroutine(v, regAddrA);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  \/* Generate a coroutine to evaluate the SELECT statement on \n  ** the right - the \"B\" select\n  *\/\n  addrSelectB = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);\n  VdbeComment((v, \"right SELECT\"));\n  savedLimit = p->iLimit;\n  savedOffset = p->iOffset;\n  p->iLimit = regLimitB;\n  p->iOffset = 0;  \n  ExplainQueryPlan((pParse, 1, \"RIGHT\"));\n  sqlite3Select(pParse, p, &destB);\n  p->iLimit = savedLimit;\n  p->iOffset = savedOffset;\n  sqlite3VdbeEndCoroutine(v, regAddrB);\n\n  \/* Generate a subroutine that outputs the current row of the A\n  ** select as the next output row of the compound select.\n  *\/\n  VdbeNoopComment((v, \"Output routine for A\"));\n  addrOutA = generateOutputSubroutine(pParse,\n                 p, &destA, pDest, regOutA,\n                 regPrev, pKeyDup, labelEnd);\n  \n  \/* Generate a subroutine that outputs the current row of the B\n  ** select as the next output row of the compound select.\n  *\/\n  if( op==TK_ALL || op==TK_UNION ){\n    VdbeNoopComment((v, \"Output routine for B\"));\n    addrOutB = generateOutputSubroutine(pParse,\n                 p, &destB, pDest, regOutB,\n                 regPrev, pKeyDup, labelEnd);\n  }\n  sqlite3KeyInfoUnref(pKeyDup);\n\n  \/* Generate a subroutine to run when the results from select A\n  ** are exhausted and only data in select B remains.\n  *\/\n  if( op==TK_EXCEPT || op==TK_INTERSECT ){\n    addrEofA_noB = addrEofA = labelEnd;\n  }else{  \n    VdbeNoopComment((v, \"eof-A subroutine\"));\n    addrEofA = sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n    addrEofA_noB = sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, labelEnd);\n                                     VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofA);\n    p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n  }\n\n  \/* Generate a subroutine to run when the results from select B\n  ** are exhausted and only data in select A remains.\n  *\/\n  if( op==TK_INTERSECT ){\n    addrEofB = addrEofA;\n    if( p->nSelectRow > pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n  }else{  \n    VdbeNoopComment((v, \"eof-B subroutine\"));\n    addrEofB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, labelEnd); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofB);\n  }\n\n  \/* Generate code to handle the case of AB\n  *\/\n  VdbeNoopComment((v, \"A-gt-B subroutine\"));\n  addrAgtB = sqlite3VdbeCurrentAddr(v);\n  if( op==TK_ALL || op==TK_UNION ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n  }\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  \/* This code runs once to initialize everything.\n  *\/\n  sqlite3VdbeJumpHere(v, addr1);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA_noB); VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n\n  \/* Implement the main merge loop\n  *\/\n  sqlite3VdbeResolveLabel(v, labelCmpr);\n  sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);\n  sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,\n                         (char*)pKeyMerge, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE);\n  sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); VdbeCoverage(v);\n\n  \/* Jump to the this point in order to terminate the query.\n  *\/\n  sqlite3VdbeResolveLabel(v, labelEnd);\n\n  \/* Reassembly the compound query so that it will be freed correctly\n  ** by the calling function *\/\n  if( p->pPrior ){\n    sqlite3SelectDelete(db, p->pPrior);\n  }\n  p->pPrior = pPrior;\n  pPrior->pNext = p;\n\n  \/*** TBD:  Insert subroutine calls to close cursors on incomplete\n  **** subqueries ****\/\n  ExplainQueryPlanPop(pParse);\n  return pParse->nErr!=0;\n}","target":0,"code_token_length":3455,"total_token_length":3691,"max_tokens_setting":4096}
+{"idx":62454,"func":"InitialiseRFBConnection(rfbClient* client)\n{\n  rfbProtocolVersionMsg pv;\n  int major,minor;\n  uint32_t authScheme;\n  uint32_t subAuthScheme;\n  rfbClientInitMsg ci;\n\n  \/* if the connection is immediately closed, don't report anything, so\n       that pmw's monitor can make test connections *\/\n\n  if (client->listenSpecified)\n    errorMessageOnReadFailure = FALSE;\n\n  if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;\n  pv[sz_rfbProtocolVersionMsg]=0;\n\n  errorMessageOnReadFailure = TRUE;\n\n  pv[sz_rfbProtocolVersionMsg] = 0;\n\n  if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) {\n    rfbClientLog(\"Not a valid VNC server (%s)\\n\",pv);\n    return FALSE;\n  }\n\n\n  DefaultSupportedMessages(client);\n  client->major = major;\n  client->minor = minor;\n\n  \/* fall back to viewer supported version *\/\n  if ((major==rfbProtocolMajorVersion) && (minor>rfbProtocolMinorVersion))\n    client->minor = rfbProtocolMinorVersion;\n\n  \/* UltraVNC uses minor codes 4 and 6 for the server *\/\n  if (major==3 && (minor==4 || minor==6)) {\n      rfbClientLog(\"UltraVNC server detected, enabling UltraVNC specific messages\\n\",pv);\n      DefaultSupportedMessagesUltraVNC(client);\n  }\n\n  \/* UltraVNC Single Click uses minor codes 14 and 16 for the server *\/\n  if (major==3 && (minor==14 || minor==16)) {\n     minor = minor - 10;\n     client->minor = minor;\n     rfbClientLog(\"UltraVNC Single Click server detected, enabling UltraVNC specific messages\\n\",pv);\n     DefaultSupportedMessagesUltraVNC(client);\n  }\n\n  \/* TightVNC uses minor codes 5 for the server *\/\n  if (major==3 && minor==5) {\n      rfbClientLog(\"TightVNC server detected, enabling TightVNC specific messages\\n\",pv);\n      DefaultSupportedMessagesTightVNC(client);\n  }\n\n  \/* we do not support > RFB3.8 *\/\n  if ((major==3 && minor>8) || major>3)\n  {\n    client->major=3;\n    client->minor=8;\n  }\n\n  rfbClientLog(\"VNC server supports protocol version %d.%d (viewer %d.%d)\\n\",\n\t  major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion);\n\n  sprintf(pv,rfbProtocolVersionFormat,client->major,client->minor);\n\n  if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;\n\n\n  \/* 3.7 and onwards sends a # of security types first *\/\n  if (client->major==3 && client->minor > 6)\n  {\n    if (!ReadSupportedSecurityType(client, &authScheme, FALSE)) return FALSE;\n  }\n  else\n  {\n    if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) return FALSE;\n    authScheme = rfbClientSwap32IfLE(authScheme);\n  }\n  \n  rfbClientLog(\"Selected Security Scheme %d\\n\", authScheme);\n  client->authScheme = authScheme;\n  \n  switch (authScheme) {\n\n  case rfbConnFailed:\n    ReadReason(client);\n    return FALSE;\n\n  case rfbNoAuth:\n    rfbClientLog(\"No authentication needed\\n\");\n\n    \/* 3.8 and upwards sends a Security Result for rfbNoAuth *\/\n    if ((client->major==3 && client->minor > 7) || client->major>3)\n        if (!rfbHandleAuthResult(client)) return FALSE;        \n\n    break;\n\n  case rfbVncAuth:\n    if (!HandleVncAuth(client)) return FALSE;\n    break;\n\n#ifdef LIBVNCSERVER_HAVE_SASL\n  case rfbSASL:\n    if (!HandleSASLAuth(client)) return FALSE;\n    break;\n#endif \/* LIBVNCSERVER_HAVE_SASL *\/\n\n  case rfbMSLogon:\n    if (!HandleMSLogonAuth(client)) return FALSE;\n    break;\n\n  case rfbARD:\n    if (!HandleARDAuth(client)) return FALSE;\n    break;\n\n  case rfbTLS:\n    if (!HandleAnonTLSAuth(client)) return FALSE;\n    \/* After the TLS session is established, sub auth types are expected.\n     * Note that all following reading\/writing are through the TLS session from here.\n     *\/\n    if (!ReadSupportedSecurityType(client, &subAuthScheme, TRUE)) return FALSE;\n    client->subAuthScheme = subAuthScheme;\n\n    switch (subAuthScheme) {\n\n      case rfbConnFailed:\n        ReadReason(client);\n        return FALSE;\n\n      case rfbNoAuth:\n        rfbClientLog(\"No sub authentication needed\\n\");\n        \/* 3.8 and upwards sends a Security Result for rfbNoAuth *\/\n        if ((client->major==3 && client->minor > 7) || client->major>3)\n            if (!rfbHandleAuthResult(client)) return FALSE;\n        break;\n\n      case rfbVncAuth:\n        if (!HandleVncAuth(client)) return FALSE;\n        break;\n\n#ifdef LIBVNCSERVER_HAVE_SASL\n      case rfbSASL:\n        if (!HandleSASLAuth(client)) return FALSE;\n        break;\n#endif \/* LIBVNCSERVER_HAVE_SASL *\/\n\n      default:\n        rfbClientLog(\"Unknown sub authentication scheme from VNC server: %d\\n\",\n            (int)subAuthScheme);\n        return FALSE;\n    }\n\n    break;\n\n  case rfbVeNCrypt:\n    if (!HandleVeNCryptAuth(client)) return FALSE;\n\n    switch (client->subAuthScheme) {\n\n      case rfbVeNCryptTLSNone:\n      case rfbVeNCryptX509None:\n        rfbClientLog(\"No sub authentication needed\\n\");\n        if (!rfbHandleAuthResult(client)) return FALSE;\n        break;\n\n      case rfbVeNCryptTLSVNC:\n      case rfbVeNCryptX509VNC:\n        if (!HandleVncAuth(client)) return FALSE;\n        break;\n\n      case rfbVeNCryptTLSPlain:\n      case rfbVeNCryptX509Plain:\n        if (!HandlePlainAuth(client)) return FALSE;\n        break;\n\n#ifdef LIBVNCSERVER_HAVE_SASL\n      case rfbVeNCryptX509SASL:\n      case rfbVeNCryptTLSSASL:\n        if (!HandleSASLAuth(client)) return FALSE;\n        break;\n#endif \/* LIBVNCSERVER_HAVE_SASL *\/\n\n      default:\n        rfbClientLog(\"Unknown sub authentication scheme from VNC server: %d\\n\",\n            client->subAuthScheme);\n        return FALSE;\n    }\n\n    break;\n\n  default:\n    {\n      rfbBool authHandled=FALSE;\n      rfbClientProtocolExtension* e;\n      for (e = rfbClientExtensions; e; e = e->next) {\n        uint32_t const* secType;\n        if (!e->handleAuthentication) continue;\n        for (secType = e->securityTypes; secType && *secType; secType++) {\n          if (authScheme==*secType) {\n            if (!e->handleAuthentication(client, authScheme)) return FALSE;\n            if (!rfbHandleAuthResult(client)) return FALSE;\n            authHandled=TRUE;\n          }\n        }\n      }\n      if (authHandled) break;\n    }\n    rfbClientLog(\"Unknown authentication scheme from VNC server: %d\\n\",\n\t    (int)authScheme);\n    return FALSE;\n  }\n\n  ci.shared = (client->appData.shareDesktop ? 1 : 0);\n\n  if (!WriteToRFBServer(client,  (char *)&ci, sz_rfbClientInitMsg)) return FALSE;\n\n  if (!ReadFromRFBServer(client, (char *)&client->si, sz_rfbServerInitMsg)) return FALSE;\n\n  client->si.framebufferWidth = rfbClientSwap16IfLE(client->si.framebufferWidth);\n  client->si.framebufferHeight = rfbClientSwap16IfLE(client->si.framebufferHeight);\n  client->si.format.redMax = rfbClientSwap16IfLE(client->si.format.redMax);\n  client->si.format.greenMax = rfbClientSwap16IfLE(client->si.format.greenMax);\n  client->si.format.blueMax = rfbClientSwap16IfLE(client->si.format.blueMax);\n  client->si.nameLength = rfbClientSwap32IfLE(client->si.nameLength);\n\n  if (client->si.nameLength > 1<<20) {\n      rfbClientErr(\"Too big desktop name length sent by server: %u B > 1 MB\\n\", (unsigned int)client->si.nameLength);\n      return FALSE;\n  }\n\n  client->desktopName = malloc(client->si.nameLength + 1);\n  if (!client->desktopName) {\n    rfbClientLog(\"Error allocating memory for desktop name, %lu bytes\\n\",\n            (unsigned long)client->si.nameLength);\n    return FALSE;\n  }\n\n  if (!ReadFromRFBServer(client, client->desktopName, client->si.nameLength)) return FALSE;\n\n  client->desktopName[client->si.nameLength] = 0;\n\n  rfbClientLog(\"Desktop name \\\"%s\\\"\\n\",client->desktopName);\n\n  rfbClientLog(\"Connected to VNC server, using protocol version %d.%d\\n\",\n\t  client->major, client->minor);\n\n  rfbClientLog(\"VNC server default format:\\n\");\n  PrintPixelFormat(&client->si.format);\n\n  return TRUE;\n}","target":0,"code_token_length":2111,"total_token_length":2347,"max_tokens_setting":4096}
+{"idx":209218,"func":"static MagickBooleanType WriteMPCImage(const ImageInfo *image_info,Image *image)\n{\n  char\n    buffer[MaxTextExtent],\n    cache_filename[MaxTextExtent];\n\n  const char\n    *property,\n    *value;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    scene;\n\n  register ssize_t\n    i;\n\n  size_t\n    depth,\n    one;\n\n  \/*\n    Open persistent cache.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  (void) CopyMagickString(cache_filename,image->filename,MaxTextExtent);\n  AppendImageFormat(\"cache\",cache_filename);\n  scene=0;\n  offset=0;\n  one=1;\n  do\n  {\n    \/*\n      Write persistent cache meta-information.\n    *\/\n    depth=GetImageQuantumDepth(image,MagickTrue);\n    if ((image->storage_class == PseudoClass) &&\n        (image->colors > (one << depth)))\n      image->storage_class=DirectClass;\n    (void) WriteBlobString(image,\"id=MagickCache\\n\");\n    (void) FormatLocaleString(buffer,MaxTextExtent,\"magick-signature=%u\\n\",\n      GetMagickSignature((const StringInfo *) NULL));\n    (void) WriteBlobString(image,buffer);\n    (void) FormatLocaleString(buffer,MaxTextExtent,\n      \"class=%s  colors=%.20g  matte=%s\\n\",CommandOptionToMnemonic(\n      MagickClassOptions,image->storage_class),(double) image->colors,\n      CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));\n    (void) WriteBlobString(image,buffer);\n    (void) FormatLocaleString(buffer,MaxTextExtent,\n      \"columns=%.20g  rows=%.20g depth=%.20g\\n\",(double) image->columns,\n      (double) image->rows,(double) image->depth);\n    (void) WriteBlobString(image,buffer);\n    if (image->type != UndefinedType)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"type=%s\\n\",\n          CommandOptionToMnemonic(MagickTypeOptions,image->type));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->colorspace != UndefinedColorspace)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"colorspace=%s\\n\",\n          CommandOptionToMnemonic(MagickColorspaceOptions,image->colorspace));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->intensity != UndefinedPixelIntensityMethod)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"pixel-intensity=%s\\n\",\n          CommandOptionToMnemonic(MagickPixelIntensityOptions,\n          image->intensity));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->endian != UndefinedEndian)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"endian=%s\\n\",\n          CommandOptionToMnemonic(MagickEndianOptions,image->endian));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->compression != UndefinedCompression)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"compression=%s  quality=%.20g\\n\",CommandOptionToMnemonic(\n          MagickCompressOptions,image->compression),(double) image->quality);\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->units != UndefinedResolution)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"units=%s\\n\",\n          CommandOptionToMnemonic(MagickResolutionOptions,image->units));\n        (void) WriteBlobString(image,buffer);\n      }\n    if ((image->x_resolution != 0) || (image->y_resolution != 0))\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"resolution=%gx%g\\n\",image->x_resolution,image->y_resolution);\n        (void) WriteBlobString(image,buffer);\n      }\n    if ((image->page.width != 0) || (image->page.height != 0))\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"page=%.20gx%.20g%+.20g%+.20g\\n\",(double) image->page.width,(double)\n          image->page.height,(double) image->page.x,(double) image->page.y);\n        (void) WriteBlobString(image,buffer);\n      }\n    else\n      if ((image->page.x != 0) || (image->page.y != 0))\n        {\n          (void) FormatLocaleString(buffer,MaxTextExtent,\"page=%+ld%+ld\\n\",\n            (long) image->page.x,(long) image->page.y);\n          (void) WriteBlobString(image,buffer);\n        }\n    if ((image->tile_offset.x != 0) || (image->tile_offset.y != 0))\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"tile-offset=%+ld%+ld\\n\",\n          (long) image->tile_offset.x,(long) image->tile_offset.y);\n        (void) WriteBlobString(image,buffer);\n      }\n    if ((GetNextImageInList(image) != (Image *) NULL) ||\n        (GetPreviousImageInList(image) != (Image *) NULL))\n      {\n        if (image->scene == 0)\n          (void) FormatLocaleString(buffer,MaxTextExtent,\n            \"iterations=%.20g  delay=%.20g  ticks-per-second=%.20g\\n\",(double)\n            image->iterations,(double) image->delay,(double)\n            image->ticks_per_second);\n        else\n          (void) FormatLocaleString(buffer,MaxTextExtent,\"scene=%.20g  \"\n            \"iterations=%.20g  delay=%.20g  ticks-per-second=%.20g\\n\",\n            (double) image->scene,(double) image->iterations,(double)\n            image->delay,(double) image->ticks_per_second);\n        (void) WriteBlobString(image,buffer);\n      }\n    else\n      {\n        if (image->scene != 0)\n          {\n            (void) FormatLocaleString(buffer,MaxTextExtent,\"scene=%.20g\\n\",\n              (double) image->scene);\n            (void) WriteBlobString(image,buffer);\n          }\n        if (image->iterations != 0)\n          {\n            (void) FormatLocaleString(buffer,MaxTextExtent,\"iterations=%.20g\\n\",\n              (double) image->iterations);\n            (void) WriteBlobString(image,buffer);\n          }\n        if (image->delay != 0)\n          {\n            (void) FormatLocaleString(buffer,MaxTextExtent,\"delay=%.20g\\n\",\n              (double) image->delay);\n            (void) WriteBlobString(image,buffer);\n          }\n        if (image->ticks_per_second != UndefinedTicksPerSecond)\n          {\n            (void) FormatLocaleString(buffer,MaxTextExtent,\n              \"ticks-per-second=%.20g\\n\",(double) image->ticks_per_second);\n            (void) WriteBlobString(image,buffer);\n          }\n      }\n    if (image->gravity != UndefinedGravity)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"gravity=%s\\n\",\n          CommandOptionToMnemonic(MagickGravityOptions,image->gravity));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->dispose != UndefinedDispose)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"dispose=%s\\n\",\n          CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->rendering_intent != UndefinedIntent)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"rendering-intent=%s\\n\",CommandOptionToMnemonic(MagickIntentOptions,\n          image->rendering_intent));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->gamma != 0.0)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"gamma=%g\\n\",\n          image->gamma);\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->chromaticity.white_point.x != 0.0)\n      {\n        \/*\n          Note chomaticity points.\n        *\/\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"red-primary=\"\n          \"%g,%g  green-primary=%g,%g  blue-primary=%g,%g\\n\",\n          image->chromaticity.red_primary.x,image->chromaticity.red_primary.y,\n          image->chromaticity.green_primary.x,\n          image->chromaticity.green_primary.y,\n          image->chromaticity.blue_primary.x,\n          image->chromaticity.blue_primary.y);\n        (void) WriteBlobString(image,buffer);\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"white-point=%g,%g\\n\",image->chromaticity.white_point.x,\n          image->chromaticity.white_point.y);\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->orientation != UndefinedOrientation)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"orientation=%s\\n\",CommandOptionToMnemonic(MagickOrientationOptions,\n          image->orientation));\n        (void) WriteBlobString(image,buffer);\n      }\n    if (image->profiles != (void *) NULL)\n      {\n        const char\n          *name;\n\n        const StringInfo\n          *profile;\n\n        \/*\n          Generic profile.\n        *\/\n        ResetImageProfileIterator(image);\n        for (name=GetNextImageProfile(image); name != (const char *) NULL; )\n        {\n          profile=GetImageProfile(image,name);\n          if (profile != (StringInfo *) NULL)\n            {\n              (void) FormatLocaleString(buffer,MaxTextExtent,\n                \"profile:%s=%.20g\\n\",name,(double)\n                GetStringInfoLength(profile));\n              (void) WriteBlobString(image,buffer);\n            }\n          name=GetNextImageProfile(image);\n        }\n      }\n    if (image->montage != (char *) NULL)\n      {\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"montage=%s\\n\",\n          image->montage);\n        (void) WriteBlobString(image,buffer);\n      }\n    ResetImagePropertyIterator(image);\n    property=GetNextImageProperty(image);\n    while (property != (const char *) NULL)\n    {\n      (void) FormatLocaleString(buffer,MaxTextExtent,\"%s=\",property);\n      (void) WriteBlobString(image,buffer);\n      value=GetImageProperty(image,property);\n      if (value != (const char *) NULL)\n        {\n          size_t\n            length;\n\n          length=strlen(value);\n          for (i=0; i < (ssize_t) length; i++)\n            if (isspace((int) ((unsigned char) value[i])) != 0)\n              break;\n          if ((i == (ssize_t) length) && (i != 0))\n            (void) WriteBlob(image,length,(const unsigned char *) value);\n          else\n            {\n              (void) WriteBlobByte(image,'{');\n              if (strchr(value,'}') == (char *) NULL)\n                (void) WriteBlob(image,length,(const unsigned char *) value);\n              else\n                for (i=0; i < (ssize_t) length; i++)\n                {\n                  if (value[i] == (int) '}')\n                    (void) WriteBlobByte(image,'\\\\');\n                  (void) WriteBlobByte(image,value[i]);\n                }\n              (void) WriteBlobByte(image,'}');\n            }\n        }\n      (void) WriteBlobByte(image,'\\n');\n      property=GetNextImageProperty(image);\n    }\n","target":0,"code_token_length":2624,"total_token_length":2860,"max_tokens_setting":4096}
+{"idx":512095,"func":"initialize_shell_variables (env, privmode)\n     char **env;\n     int privmode;\n{\n  char *name, *string, *temp_string;\n  int c, char_index, string_index, string_length, ro;\n  SHELL_VAR *temp_var;\n\n  create_variable_tables ();\n\n  for (string_index = 0; string = env[string_index++]; )\n    {\n      char_index = 0;\n      name = string;\n      while ((c = *string++) && c != '=')\n\t;\n      if (string[-1] == '=')\n\tchar_index = string - name - 1;\n\n      \/* If there are weird things in the environment, like `=xxx' or a\n\t string without an `=', just skip them. *\/\n      if (char_index == 0)\n\tcontinue;\n\n      \/* ASSERT(name[char_index] == '=') *\/\n      name[char_index] = '\\0';\n      \/* Now, name = env variable name, string = env variable value, and\n\t char_index == strlen (name) *\/\n\n      temp_var = (SHELL_VAR *)NULL;\n\n      \/* If exported function, define it now.  Don't import functions from\n\t the environment in privileged mode. *\/\n      if (privmode == 0 && read_but_dont_execute == 0 && STREQN (\"() {\", string, 4))\n\t{\n\t  string_length = strlen (string);\n\t  temp_string = (char *)xmalloc (3 + string_length + char_index);\n\n\t  strcpy (temp_string, name);\n\t  temp_string[char_index] = ' ';\n\t  strcpy (temp_string + char_index + 1, string);\n\n\t  parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);\n\n\t  \/* Ancient backwards compatibility.  Old versions of bash exported\n\t     functions like name()=() {...} *\/\n\t  if (name[char_index - 1] == ')' && name[char_index - 2] == '(')\n\t    name[char_index - 2] = '\\0';\n\n\t  if (temp_var = find_function (name))\n\t    {\n\t      VSETATTR (temp_var, (att_exported|att_imported));\n\t      array_needs_making = 1;\n\t    }\n\t  else\n\t    {\n\t      last_command_exit_value = 1;\n\t      report_error (_(\"error importing function definition for `%s'\"), name);\n\t    }\n\n\t  \/* ( *\/\n\t  if (name[char_index - 1] == ')' && name[char_index - 2] == '\\0')\n\t    name[char_index - 2] = '(';\t\t\/* ) *\/\n\t}\n#if defined (ARRAY_VARS)\n#  if 0\n      \/* Array variables may not yet be exported. *\/\n      else if (*string == '(' && string[1] == '[' && string[strlen (string) - 1] == ')')\n\t{\n\t  string_length = 1;\n\t  temp_string = extract_array_assignment_list (string, &string_length);\n\t  temp_var = assign_array_from_string (name, temp_string);\n\t  FREE (temp_string);\n\t  VSETATTR (temp_var, (att_exported | att_imported));\n\t  array_needs_making = 1;\n\t}\n#  endif\n#endif\n#if 0\n      else if (legal_identifier (name))\n#else\n      else\n#endif\n\t{\n\t  ro = 0;\n\t  if (posixly_correct && STREQ (name, \"SHELLOPTS\"))\n\t    {\n\t      temp_var = find_variable (\"SHELLOPTS\");\n\t      ro = temp_var && readonly_p (temp_var);\n\t      if (temp_var)\n\t\tVUNSETATTR (temp_var, att_readonly);\n\t    }\n\t  temp_var = bind_variable (name, string, 0);\n\t  if (temp_var)\n\t    {\n\t      if (legal_identifier (name))\n\t\tVSETATTR (temp_var, (att_exported | att_imported));\n\t      else\n\t\tVSETATTR (temp_var, (att_exported | att_imported | att_invisible));\n\t      if (ro)\n\t\tVSETATTR (temp_var, att_readonly);\n\t      array_needs_making = 1;\n\t    }\n\t}\n\n      name[char_index] = '=';\n      \/* temp_var can be NULL if it was an exported function with a syntax\n\t error (a different bug, but it still shouldn't dump core). *\/\n      if (temp_var && function_p (temp_var) == 0)\t\/* XXX not yet *\/\n\t{\n\t  CACHE_IMPORTSTR (temp_var, name);\n\t}\n    }\n\n  set_pwd ();\n\n  \/* Set up initial value of $_ *\/\n  temp_var = set_if_not (\"_\", dollar_vars[0]);\n\n  \/* Remember this pid. *\/\n  dollar_dollar_pid = getpid ();\n\n  \/* Now make our own defaults in case the vars that we think are\n     important are missing. *\/\n  temp_var = set_if_not (\"PATH\", DEFAULT_PATH_VALUE);\n#if 0\n  set_auto_export (temp_var);\t\/* XXX *\/\n#endif\n\n  temp_var = set_if_not (\"TERM\", \"dumb\");\n#if 0\n  set_auto_export (temp_var);\t\/* XXX *\/\n#endif\n\n#if defined (__QNX__)\n  \/* set node id -- don't import it from the environment *\/\n  {\n    char node_name[22];\n#  if defined (__QNXNTO__)\n    netmgr_ndtostr(ND2S_LOCAL_STR, ND_LOCAL_NODE, node_name, sizeof(node_name));\n#  else\n    qnx_nidtostr (getnid (), node_name, sizeof (node_name));\n#  endif\n    temp_var = bind_variable (\"NODE\", node_name, 0);\n    set_auto_export (temp_var);\n  }\n#endif\n\n  \/* set up the prompts. *\/\n  if (interactive_shell)\n    {\n#if defined (PROMPT_STRING_DECODE)\n      set_if_not (\"PS1\", primary_prompt);\n#else\n      if (current_user.uid == -1)\n\tget_current_user_info ();\n      set_if_not (\"PS1\", current_user.euid == 0 ? \"# \" : primary_prompt);\n#endif\n      set_if_not (\"PS2\", secondary_prompt);\n    }\n  set_if_not (\"PS4\", \"+ \");\n\n  \/* Don't allow IFS to be imported from the environment. *\/\n  temp_var = bind_variable (\"IFS\", \" \\t\\n\", 0);\n  setifs (temp_var);\n\n  \/* Magic machine types.  Pretty convenient. *\/\n  set_machine_vars ();\n\n  \/* Default MAILCHECK for interactive shells.  Defer the creation of a\n     default MAILPATH until the startup files are read, because MAIL\n     names a mail file if MAILPATH is not set, and we should provide a\n     default only if neither is set. *\/\n  if (interactive_shell)\n    {\n      temp_var = set_if_not (\"MAILCHECK\", posixly_correct ? \"600\" : \"60\");\n      VSETATTR (temp_var, att_integer);\n    }\n\n  \/* Do some things with shell level. *\/\n  initialize_shell_level ();\n\n  set_ppid ();\n\n  \/* Initialize the `getopts' stuff. *\/\n  temp_var = bind_variable (\"OPTIND\", \"1\", 0);\n  VSETATTR (temp_var, att_integer);\n  getopts_reset (0);\n  bind_variable (\"OPTERR\", \"1\", 0);\n  sh_opterr = 1;\n\n  if (login_shell == 1 && posixly_correct == 0)\n    set_home_var ();\n\n  \/* Get the full pathname to THIS shell, and set the BASH variable\n     to it. *\/\n  name = get_bash_name ();\n  temp_var = bind_variable (\"BASH\", name, 0);\n  free (name);\n\n  \/* Make the exported environment variable SHELL be the user's login\n     shell.  Note that the `tset' command looks at this variable\n     to determine what style of commands to output; if it ends in \"csh\",\n     then C-shell commands are output, else Bourne shell commands. *\/\n  set_shell_var ();\n\n  \/* Make a variable called BASH_VERSION which contains the version info. *\/\n  bind_variable (\"BASH_VERSION\", shell_version_string (), 0);\n#if defined (ARRAY_VARS)\n  make_vers_array ();\n#endif\n\n  if (command_execution_string)\n    bind_variable (\"BASH_EXECUTION_STRING\", command_execution_string, 0);\n\n  \/* Find out if we're supposed to be in Posix.2 mode via an\n     environment variable. *\/\n  temp_var = find_variable (\"POSIXLY_CORRECT\");\n  if (!temp_var)\n    temp_var = find_variable (\"POSIX_PEDANTIC\");\n  if (temp_var && imported_p (temp_var))\n    sv_strict_posix (temp_var->name);\n\n#if defined (HISTORY)\n  \/* Set history variables to defaults, and then do whatever we would\n     do if the variable had just been set.  Do this only in the case\n     that we are remembering commands on the history list. *\/\n  if (remember_on_history)\n    {\n      name = bash_tilde_expand (posixly_correct ? \"~\/.sh_history\" : \"~\/.bash_history\", 0);\n\n      set_if_not (\"HISTFILE\", name);\n      free (name);\n    }\n#endif \/* HISTORY *\/\n\n  \/* Seed the random number generator. *\/\n  seedrand ();\n\n  \/* Handle some \"special\" variables that we may have inherited from a\n     parent shell. *\/\n  if (interactive_shell)\n    {\n      temp_var = find_variable (\"IGNOREEOF\");\n      if (!temp_var)\n\ttemp_var = find_variable (\"ignoreeof\");\n      if (temp_var && imported_p (temp_var))\n\tsv_ignoreeof (temp_var->name);\n    }\n\n#if defined (HISTORY)\n  if (interactive_shell && remember_on_history)\n    {\n      sv_history_control (\"HISTCONTROL\");\n      sv_histignore (\"HISTIGNORE\");\n      sv_histtimefmt (\"HISTTIMEFORMAT\");\n    }\n#endif \/* HISTORY *\/\n\n#if defined (READLINE) && defined (STRICT_POSIX)\n  \/* POSIXLY_CORRECT will only be 1 here if the shell was compiled\n     -DSTRICT_POSIX *\/\n  if (interactive_shell && posixly_correct && no_line_editing == 0)\n    rl_prefer_env_winsize = 1;\n#endif \/* READLINE && STRICT_POSIX *\/\n\n     \/*\n      * 24 October 2001\n      *\n      * I'm tired of the arguing and bug reports.  Bash now leaves SSH_CLIENT\n      * and SSH2_CLIENT alone.  I'm going to rely on the shell_level check in\n      * isnetconn() to avoid running the startup files more often than wanted.\n      * That will, of course, only work if the user's login shell is bash, so\n      * I've made that behavior conditional on SSH_SOURCE_BASHRC being defined\n      * in config-top.h.\n      *\/\n#if 0\n  temp_var = find_variable (\"SSH_CLIENT\");\n  if (temp_var && imported_p (temp_var))\n    {\n      VUNSETATTR (temp_var, att_exported);\n      array_needs_making = 1;\n    }\n  temp_var = find_variable (\"SSH2_CLIENT\");\n  if (temp_var && imported_p (temp_var))\n    {\n      VUNSETATTR (temp_var, att_exported);\n      array_needs_making = 1;\n    }\n#endif\n\n  \/* Get the user's real and effective user ids. *\/\n  uidset ();\n\n  temp_var = find_variable (\"BASH_XTRACEFD\");\n  if (temp_var && imported_p (temp_var))\n    sv_xtracefd (temp_var->name);\n\n  \/* Initialize the dynamic variables, and seed their values. *\/\n  initialize_dynamic_variables ();\n}","target":0,"code_token_length":2447,"total_token_length":2683,"max_tokens_setting":4096}
+{"idx":324620,"func":"static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,\n\n                               int access_type, ARMMMUIdx mmu_idx,\n\n                               hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,\n\n                               target_ulong *page_size_ptr, uint32_t *fsr,\n\n                               ARMMMUFaultInfo *fi)\n\n{\n\n    ARMCPU *cpu = arm_env_get_cpu(env);\n\n    CPUState *cs = CPU(cpu);\n\n    \/* Read an LPAE long-descriptor translation table. *\/\n\n    MMUFaultType fault_type = translation_fault;\n\n    uint32_t level;\n\n    uint32_t epd = 0;\n\n    int32_t t0sz, t1sz;\n\n    uint32_t tg;\n\n    uint64_t ttbr;\n\n    int ttbr_select;\n\n    hwaddr descaddr, indexmask, indexmask_grainsize;\n\n    uint32_t tableattrs;\n\n    target_ulong page_size;\n\n    uint32_t attrs;\n\n    int32_t stride = 9;\n\n    int32_t va_size;\n\n    int inputsize;\n\n    int32_t tbi = 0;\n\n    TCR *tcr = regime_tcr(env, mmu_idx);\n\n    int ap, ns, xn, pxn;\n\n    uint32_t el = regime_el(env, mmu_idx);\n\n    bool ttbr1_valid = true;\n\n    uint64_t descaddrmask;\n\n\n\n    \/* TODO:\n\n     * This code does not handle the different format TCR for VTCR_EL2.\n\n     * This code also does not support shareability levels.\n\n     * Attribute and permission bit handling should also be checked when adding\n\n     * support for those page table walks.\n\n     *\/\n\n    if (arm_el_is_aa64(env, el)) {\n\n        level = 0;\n\n        va_size = 64;\n\n        if (el > 1) {\n\n            if (mmu_idx != ARMMMUIdx_S2NS) {\n\n                tbi = extract64(tcr->raw_tcr, 20, 1);\n\n            }\n\n        } else {\n\n            if (extract64(address, 55, 1)) {\n\n                tbi = extract64(tcr->raw_tcr, 38, 1);\n\n            } else {\n\n                tbi = extract64(tcr->raw_tcr, 37, 1);\n\n            }\n\n        }\n\n        tbi *= 8;\n\n\n\n        \/* If we are in 64-bit EL2 or EL3 then there is no TTBR1, so mark it\n\n         * invalid.\n\n         *\/\n\n        if (el > 1) {\n\n            ttbr1_valid = false;\n\n        }\n\n    } else {\n\n        level = 1;\n\n        va_size = 32;\n\n        \/* There is no TTBR1 for EL2 *\/\n\n        if (el == 2) {\n\n            ttbr1_valid = false;\n\n        }\n\n    }\n\n\n\n    \/* Determine whether this address is in the region controlled by\n\n     * TTBR0 or TTBR1 (or if it is in neither region and should fault).\n\n     * This is a Non-secure PL0\/1 stage 1 translation, so controlled by\n\n     * TTBCR\/TTBR0\/TTBR1 in accordance with ARM ARM DDI0406C table B-32:\n\n     *\/\n\n    if (va_size == 64) {\n\n        \/* AArch64 translation.  *\/\n\n        t0sz = extract32(tcr->raw_tcr, 0, 6);\n\n        t0sz = MIN(t0sz, 39);\n\n        t0sz = MAX(t0sz, 16);\n\n    } else if (mmu_idx != ARMMMUIdx_S2NS) {\n\n        \/* AArch32 stage 1 translation.  *\/\n\n        t0sz = extract32(tcr->raw_tcr, 0, 3);\n\n    } else {\n\n        \/* AArch32 stage 2 translation.  *\/\n\n        bool sext = extract32(tcr->raw_tcr, 4, 1);\n\n        bool sign = extract32(tcr->raw_tcr, 3, 1);\n\n        t0sz = sextract32(tcr->raw_tcr, 0, 4);\n\n\n\n        \/* If the sign-extend bit is not the same as t0sz[3], the result\n\n         * is unpredictable. Flag this as a guest error.  *\/\n\n        if (sign != sext) {\n\n            qemu_log_mask(LOG_GUEST_ERROR,\n\n                          \"AArch32: VTCR.S \/ VTCR.T0SZ[3] missmatch\\n\");\n\n        }\n\n    }\n\n    t1sz = extract32(tcr->raw_tcr, 16, 6);\n\n    if (va_size == 64) {\n\n        t1sz = MIN(t1sz, 39);\n\n        t1sz = MAX(t1sz, 16);\n\n    }\n\n    if (t0sz && !extract64(address, va_size - t0sz, t0sz - tbi)) {\n\n        \/* there is a ttbr0 region and we are in it (high bits all zero) *\/\n\n        ttbr_select = 0;\n\n    } else if (ttbr1_valid && t1sz &&\n\n               !extract64(~address, va_size - t1sz, t1sz - tbi)) {\n\n        \/* there is a ttbr1 region and we are in it (high bits all one) *\/\n\n        ttbr_select = 1;\n\n    } else if (!t0sz) {\n\n        \/* ttbr0 region is \"everything not in the ttbr1 region\" *\/\n\n        ttbr_select = 0;\n\n    } else if (!t1sz && ttbr1_valid) {\n\n        \/* ttbr1 region is \"everything not in the ttbr0 region\" *\/\n\n        ttbr_select = 1;\n\n    } else {\n\n        \/* in the gap between the two regions, this is a Translation fault *\/\n\n        fault_type = translation_fault;\n\n        goto do_fault;\n\n    }\n\n\n\n    \/* Note that QEMU ignores shareability and cacheability attributes,\n\n     * so we don't need to do anything with the SH, ORGN, IRGN fields\n\n     * in the TTBCR.  Similarly, TTBCR:A1 selects whether we get the\n\n     * ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently\n\n     * implement any ASID-like capability so we can ignore it (instead\n\n     * we will always flush the TLB any time the ASID is changed).\n\n     *\/\n\n    if (ttbr_select == 0) {\n\n        ttbr = regime_ttbr(env, mmu_idx, 0);\n\n        if (el < 2) {\n\n            epd = extract32(tcr->raw_tcr, 7, 1);\n\n        }\n\n        inputsize = va_size - t0sz;\n\n\n\n        tg = extract32(tcr->raw_tcr, 14, 2);\n\n        if (tg == 1) { \/* 64KB pages *\/\n\n            stride = 13;\n\n        }\n\n        if (tg == 2) { \/* 16KB pages *\/\n\n            stride = 11;\n\n        }\n\n    } else {\n\n        \/* We should only be here if TTBR1 is valid *\/\n\n        assert(ttbr1_valid);\n\n\n\n        ttbr = regime_ttbr(env, mmu_idx, 1);\n\n        epd = extract32(tcr->raw_tcr, 23, 1);\n\n        inputsize = va_size - t1sz;\n\n\n\n        tg = extract32(tcr->raw_tcr, 30, 2);\n\n        if (tg == 3)  { \/* 64KB pages *\/\n\n            stride = 13;\n\n        }\n\n        if (tg == 1) { \/* 16KB pages *\/\n\n            stride = 11;\n\n        }\n\n    }\n\n\n\n    \/* Here we should have set up all the parameters for the translation:\n\n     * va_size, inputsize, ttbr, epd, stride, tbi\n\n     *\/\n\n\n\n    if (epd) {\n\n        \/* Translation table walk disabled => Translation fault on TLB miss\n\n         * Note: This is always 0 on 64-bit EL2 and EL3.\n\n         *\/\n\n        goto do_fault;\n\n    }\n\n\n\n    if (mmu_idx != ARMMMUIdx_S2NS) {\n\n        \/* The starting level depends on the virtual address size (which can\n\n         * be up to 48 bits) and the translation granule size. It indicates\n\n         * the number of strides (stride bits at a time) needed to\n\n         * consume the bits of the input address. In the pseudocode this is:\n\n         *  level = 4 - RoundUp((inputsize - grainsize) \/ stride)\n\n         * where their 'inputsize' is our 'inputsize', 'grainsize' is\n\n         * our 'stride + 3' and 'stride' is our 'stride'.\n\n         * Applying the usual \"rounded up m\/n is (m+n-1)\/n\" and simplifying:\n\n         * = 4 - (inputsize - stride - 3 + stride - 1) \/ stride\n\n         * = 4 - (inputsize - 4) \/ stride;\n\n         *\/\n\n        level = 4 - (inputsize - 4) \/ stride;\n\n    } else {\n\n        \/* For stage 2 translations the starting level is specified by the\n\n         * VTCR_EL2.SL0 field (whose interpretation depends on the page size)\n\n         *\/\n\n        uint32_t sl0 = extract32(tcr->raw_tcr, 6, 2);\n\n        uint32_t startlevel;\n\n        bool ok;\n\n\n\n        if (va_size == 32 || stride == 9) {\n\n            \/* AArch32 or 4KB pages *\/\n\n            startlevel = 2 - sl0;\n\n        } else {\n\n            \/* 16KB or 64KB pages *\/\n\n            startlevel = 3 - sl0;\n\n        }\n\n\n\n        \/* Check that the starting level is valid. *\/\n\n        ok = check_s2_mmu_setup(cpu, va_size == 64, startlevel,\n\n                                inputsize, stride);\n\n        if (!ok) {\n\n            fault_type = translation_fault;\n\n            goto do_fault;\n\n        }\n\n        level = startlevel;\n\n    }\n\n\n\n    indexmask_grainsize = (1ULL << (stride + 3)) - 1;\n\n    indexmask = (1ULL << (inputsize - (stride * (4 - level)))) - 1;\n\n\n\n    \/* Now we can extract the actual base address from the TTBR *\/\n\n    descaddr = extract64(ttbr, 0, 48);\n\n    descaddr &= ~indexmask;\n\n\n\n    \/* The address field in the descriptor goes up to bit 39 for ARMv7\n\n     * but up to bit 47 for ARMv8, but we use the descaddrmask\n\n     * up to bit 39 for AArch32, because we don't need other bits in that case\n\n     * to construct next descriptor address (anyway they should be all zeroes).\n\n     *\/\n\n    descaddrmask = ((1ull << (va_size == 64 ? 48 : 40)) - 1) &\n\n                   ~indexmask_grainsize;\n\n\n\n    \/* Secure accesses start with the page table in secure memory and\n\n     * can be downgraded to non-secure at any step. Non-secure accesses\n\n     * remain non-secure. We implement this by just ORing in the NSTable\/NS\n\n     * bits at each step.\n\n     *\/\n\n    tableattrs = regime_is_secure(env, mmu_idx) ? 0 : (1 << 4);\n\n    for (;;) {\n\n        uint64_t descriptor;\n\n        bool nstable;\n\n\n\n        descaddr |= (address >> (stride * (4 - level))) & indexmask;\n\n        descaddr &= ~7ULL;\n\n        nstable = extract32(tableattrs, 4, 1);\n\n        descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fsr, fi);\n\n        if (fi->s1ptw) {\n\n            goto do_fault;\n\n        }\n\n\n\n        if (!(descriptor & 1) ||\n\n            (!(descriptor & 2) && (level == 3))) {\n\n            \/* Invalid, or the Reserved level 3 encoding *\/\n\n            goto do_fault;\n\n        }\n\n        descaddr = descriptor & descaddrmask;\n\n\n\n        if ((descriptor & 2) && (level < 3)) {\n\n            \/* Table entry. The top five bits are attributes which  may\n\n             * propagate down through lower levels of the table (and\n\n             * which are all arranged so that 0 means \"no effect\", so\n\n             * we can gather them up by ORing in the bits at each level).\n\n             *\/\n\n            tableattrs |= extract64(descriptor, 59, 5);\n\n            level++;\n\n            indexmask = indexmask_grainsize;\n\n            continue;\n\n        }\n\n        \/* Block entry at level 1 or 2, or page entry at level 3.\n\n         * These are basically the same thing, although the number\n\n         * of bits we pull in from the vaddr varies.\n\n         *\/\n\n        page_size = (1ULL << ((stride * (4 - level)) + 3));\n\n        descaddr |= (address & (page_size - 1));\n\n        \/* Extract attributes from the descriptor *\/\n\n        attrs = extract64(descriptor, 2, 10)\n\n            | (extract64(descriptor, 52, 12) << 10);\n\n\n\n        if (mmu_idx == ARMMMUIdx_S2NS) {\n\n            \/* Stage 2 table descriptors do not include any attribute fields *\/\n\n            break;\n\n        }\n\n        \/* Merge in attributes from table descriptors *\/\n\n        attrs |= extract32(tableattrs, 0, 2) << 11; \/* XN, PXN *\/\n\n        attrs |= extract32(tableattrs, 3, 1) << 5; \/* APTable[1] => AP[2] *\/\n\n        \/* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1\n\n         * means \"force PL1 access only\", which means forcing AP[1] to 0.\n\n         *\/\n\n        if (extract32(tableattrs, 2, 1)) {\n\n            attrs &= ~(1 << 4);\n\n        }\n\n        attrs |= nstable << 3; \/* NS *\/\n\n        break;\n\n    }\n\n    \/* Here descaddr is the final physical address, and attributes\n\n     * are all in attrs.\n\n     *\/\n\n    fault_type = access_fault;\n\n    if ((attrs & (1 << 8)) == 0) {\n\n        \/* Access flag *\/\n\n        goto do_fault;\n\n    }\n\n\n\n    ap = extract32(attrs, 4, 2);\n\n    xn = extract32(attrs, 12, 1);\n\n\n\n    if (mmu_idx == ARMMMUIdx_S2NS) {\n\n        ns = true;\n\n        *prot = get_S2prot(env, ap, xn);\n\n    } else {\n\n        ns = extract32(attrs, 3, 1);\n\n        pxn = extract32(attrs, 11, 1);\n\n        *prot = get_S1prot(env, mmu_idx, va_size == 64, ap, ns, xn, pxn);\n\n    }\n\n\n\n    fault_type = permission_fault;\n\n    if (!(*prot & (1 << access_type))) {\n\n        goto do_fault;\n\n    }\n\n\n\n    if (ns) {\n\n        \/* The NS bit will (as required by the architecture) have no effect if\n\n         * the CPU doesn't support TZ or this is a non-secure translation\n\n         * regime, because the attribute will already be non-secure.\n\n         *\/\n\n        txattrs->secure = false;\n\n    }\n\n    *phys_ptr = descaddr;\n\n    *page_size_ptr = page_size;\n\n    return false;\n\n\n\ndo_fault:\n\n    \/* Long-descriptor format IFSR\/DFSR value *\/\n\n    *fsr = (1 << 9) | (fault_type << 2) | level;\n\n    \/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2.  *\/\n\n    fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_S2NS);\n\n    return true;\n\n}\n","target":0,"code_token_length":3494,"total_token_length":3730,"max_tokens_setting":4096}
+{"idx":32587,"func":"int PemToDer(const unsigned char* buff, long longSz, int type,\n              DerBuffer** pDer, void* heap, EncryptedInfo* info, int* keyFormat)\n{\n    const char* header      = NULL;\n    const char* footer      = NULL;\n    const char* headerEnd;\n    const char* footerEnd;\n    const char* consumedEnd;\n    const char* bufferEnd   = (const char*)(buff + longSz);\n    long        neededSz;\n    int         ret         = 0;\n    int         sz          = (int)longSz;\n    int         encrypted_key = 0;\n    DerBuffer*  der;\n#if defined(HAVE_PKCS8) || defined(WOLFSSL_ENCRYPTED_KEYS)\n    word32      algId = 0;\n    #if defined(WOLFSSL_ENCRYPTED_KEYS) && !defined(NO_DES3) && !defined(NO_WOLFSSL_SKIP_TRAILING_PAD)\n        int     padVal = 0;\n    #endif\n#endif\n#ifdef OPENSSL_EXTRA\n    char        beginBuf[PEM_LINE_LEN + 1]; \/* add 1 for null terminator *\/\n    char        endBuf[PEM_LINE_LEN + 1];   \/* add 1 for null terminator *\/\n#endif\n\n    WOLFSSL_ENTER(\"PemToDer\");\n\n    \/* get PEM header and footer based on type *\/\n    ret = wc_PemGetHeaderFooter(type, &header, &footer);\n    if (ret != 0)\n        return ret;\n\n    \/* map header if not found for type *\/\n    for (;;) {\n        headerEnd = XSTRNSTR((char*)buff, header, sz);\n\n        if (headerEnd) {\n            break;\n        } else\n        if (type == PRIVATEKEY_TYPE) {\n            if (header == BEGIN_RSA_PRIV) {\n                header =  BEGIN_PRIV_KEY;       footer = END_PRIV_KEY;\n            } else\n            if (header == BEGIN_PRIV_KEY) {\n                header =  BEGIN_ENC_PRIV_KEY;   footer = END_ENC_PRIV_KEY;\n            } else\n    #ifdef HAVE_ECC\n            if (header == BEGIN_ENC_PRIV_KEY) {\n                header =  BEGIN_EC_PRIV;        footer = END_EC_PRIV;\n            } else\n            if (header == BEGIN_EC_PRIV) {\n                header =  BEGIN_DSA_PRIV;       footer = END_DSA_PRIV;\n            } else\n    #endif\n    #if defined(HAVE_ED25519) || defined(HAVE_ED448)\n        #ifdef HAVE_ECC\n            if (header == BEGIN_DSA_PRIV)\n        #else\n            if (header == BEGIN_ENC_PRIV_KEY)\n        #endif\n            {\n                header =  BEGIN_EDDSA_PRIV;     footer = END_EDDSA_PRIV;\n            } else\n    #endif\n            {\n                break;\n            }\n        } else\n#ifdef HAVE_CRL\n        if ((type == CRL_TYPE) && (header != BEGIN_X509_CRL)) {\n            header =  BEGIN_X509_CRL;           footer = END_X509_CRL;\n        } else\n#endif\n        {\n            break;\n        }\n    }\n\n    if (!headerEnd) {\n#ifdef OPENSSL_EXTRA\n        if (type == PRIVATEKEY_TYPE) {\n            const char* beginEnd;\n            int endLen;\n            \/* see if there is a -----BEGIN * PRIVATE KEY----- header *\/\n            headerEnd = XSTRNSTR((char*)buff, PRIV_KEY_SUFFIX, sz);\n            if (headerEnd) {\n                beginEnd = headerEnd + XSTR_SIZEOF(PRIV_KEY_SUFFIX);\n                if (beginEnd >= (char*)buff + sz) {\n                    return BUFFER_E;\n                }\n\n                \/* back up to BEGIN_PRIV_KEY_PREFIX *\/\n                while (headerEnd > (char*)buff &&\n                        XSTRNCMP(headerEnd, BEGIN_PRIV_KEY_PREFIX,\n                                XSTR_SIZEOF(BEGIN_PRIV_KEY_PREFIX)) != 0 &&\n                        *headerEnd != '\\n') {\n                    headerEnd--;\n                }\n                if (headerEnd <= (char*)buff ||\n                        XSTRNCMP(headerEnd, BEGIN_PRIV_KEY_PREFIX,\n                        XSTR_SIZEOF(BEGIN_PRIV_KEY_PREFIX)) != 0 ||\n                        beginEnd - headerEnd > PEM_LINE_LEN) {\n                    WOLFSSL_MSG(\"Couldn't find PEM header\");\n                    WOLFSSL_ERROR(ASN_NO_PEM_HEADER);\n                    return ASN_NO_PEM_HEADER;\n                }\n\n                \/* headerEnd now points to beginning of header *\/\n                XMEMCPY(beginBuf, headerEnd, beginEnd - headerEnd);\n                beginBuf[beginEnd - headerEnd] = '\\0';\n                \/* look for matching footer *\/\n                footer = XSTRNSTR(beginEnd,\n                                beginBuf + XSTR_SIZEOF(BEGIN_PRIV_KEY_PREFIX),\n                                (unsigned int)((char*)buff + sz - beginEnd));\n                if (!footer) {\n                    WOLFSSL_MSG(\"Couldn't find PEM footer\");\n                    WOLFSSL_ERROR(ASN_NO_PEM_HEADER);\n                    return ASN_NO_PEM_HEADER;\n                }\n\n                footer -= XSTR_SIZEOF(END_PRIV_KEY_PREFIX);\n                if (footer > (char*)buff + sz - XSTR_SIZEOF(END_PRIV_KEY_PREFIX)\n                        || XSTRNCMP(footer, END_PRIV_KEY_PREFIX,\n                            XSTR_SIZEOF(END_PRIV_KEY_PREFIX)) != 0) {\n                    WOLFSSL_MSG(\"Unexpected footer for PEM\");\n                    return BUFFER_E;\n                }\n\n                endLen = (unsigned int)(beginEnd - headerEnd -\n                            (XSTR_SIZEOF(BEGIN_PRIV_KEY_PREFIX) -\n                                    XSTR_SIZEOF(END_PRIV_KEY_PREFIX)));\n                XMEMCPY(endBuf, footer, endLen);\n                endBuf[endLen] = '\\0';\n\n                header = beginBuf;\n                footer = endBuf;\n                headerEnd = beginEnd;\n            }\n        }\n\n        if (!headerEnd) {\n            WOLFSSL_MSG(\"Couldn't find PEM header\");\n            WOLFSSL_ERROR(ASN_NO_PEM_HEADER);\n            return ASN_NO_PEM_HEADER;\n        }\n#else\n        WOLFSSL_MSG(\"Couldn't find PEM header\");\n        return ASN_NO_PEM_HEADER;\n#endif\n    } else {\n        headerEnd += XSTRLEN(header);\n    }\n\n    \/* eat end of line characters *\/\n    headerEnd = SkipEndOfLineChars(headerEnd, bufferEnd);\n\n    if (type == PRIVATEKEY_TYPE) {\n        \/* keyFormat is Key_Sum enum *\/\n        if (keyFormat) {\n        #ifdef HAVE_ECC\n            if (header == BEGIN_EC_PRIV)\n                *keyFormat = ECDSAk;\n        #endif\n        #if !defined(NO_DSA)\n            if (header == BEGIN_DSA_PRIV)\n                *keyFormat = DSAk;\n        #endif\n        }\n    }\n\n#ifdef WOLFSSL_ENCRYPTED_KEYS\n    if (info) {\n        ret = wc_EncryptedInfoParse(info, &headerEnd, bufferEnd - headerEnd);\n        if (ret < 0)\n            return ret;\n        if (info->set)\n            encrypted_key = 1;\n    }\n#endif \/* WOLFSSL_ENCRYPTED_KEYS *\/\n\n    \/* find footer *\/\n    footerEnd = XSTRNSTR(headerEnd, footer, (unsigned int)((char*)buff + sz - headerEnd));\n    if (!footerEnd) {\n        if (info)\n            info->consumed = longSz; \/* No more certs if no footer *\/\n        return BUFFER_E;\n    }\n\n    consumedEnd = footerEnd + XSTRLEN(footer);\n\n    if (consumedEnd < bufferEnd) { \/* handle no end of line on last line *\/\n        \/* eat end of line characters *\/\n        consumedEnd = SkipEndOfLineChars(consumedEnd, bufferEnd);\n        \/* skip possible null term *\/\n        if (consumedEnd < bufferEnd && consumedEnd[0] == '\\0')\n            consumedEnd++;\n    }\n\n    if (info)\n        info->consumed = (long)(consumedEnd - (const char*)buff);\n\n    \/* set up der buffer *\/\n    neededSz = (long)(footerEnd - headerEnd);\n    if (neededSz > sz || neededSz <= 0)\n        return BUFFER_E;\n\n    ret = AllocDer(pDer, (word32)neededSz, type, heap);\n    if (ret < 0) {\n        return ret;\n    }\n    der = *pDer;\n\n    if (Base64_Decode((byte*)headerEnd, (word32)neededSz,\n                      der->buffer, &der->length) < 0)\n        return BUFFER_E;\n\n    if ((header == BEGIN_PRIV_KEY\n#ifdef OPENSSL_EXTRA\n         || header == beginBuf\n#endif\n#ifdef HAVE_ECC\n         || header == BEGIN_EC_PRIV\n#endif\n        ) && !encrypted_key)\n    {\n    #ifdef HAVE_PKCS8\n        \/* pkcs8 key, convert and adjust length *\/\n        if ((ret = ToTraditional_ex(der->buffer, der->length, &algId)) > 0) {\n            der->length = ret;\n            if (keyFormat) {\n                *keyFormat = algId;\n            }\n        }\n        else {\n            \/* ignore failure here and assume key is not pkcs8 wrapped *\/\n        }\n    #endif\n\n        return 0;\n    }\n\n#ifdef WOLFSSL_ENCRYPTED_KEYS\n    if (encrypted_key || header == BEGIN_ENC_PRIV_KEY) {\n        int   passwordSz = NAME_SZ;\n    #ifdef WOLFSSL_SMALL_STACK\n        char* password = NULL;\n    #else\n        char  password[NAME_SZ];\n    #endif\n\n        if (!info || !info->passwd_cb) {\n            WOLFSSL_MSG(\"No password callback set\");\n            return NO_PASSWORD;\n        }\n\n    #ifdef WOLFSSL_SMALL_STACK\n        password = (char*)XMALLOC(passwordSz, heap, DYNAMIC_TYPE_STRING);\n        if (password == NULL)\n            return MEMORY_E;\n    #endif\n\n        \/* get password *\/\n        ret = info->passwd_cb(password, passwordSz, PEM_PASS_READ,\n            info->passwd_userdata);\n        if (ret >= 0) {\n            passwordSz = ret;\n\n            \/* convert and adjust length *\/\n            if (header == BEGIN_ENC_PRIV_KEY) {\n            #ifndef NO_PWDBASED\n                ret = ToTraditionalEnc(der->buffer, der->length,\n                                       password, passwordSz, &algId);\n\n                if (ret >= 0) {\n                    der->length = ret;\n                    if (keyFormat) {\n                        *keyFormat = algId;\n                    }\n                    ret = 0;\n                }\n            #else\n                ret = NOT_COMPILED_IN;\n            #endif\n            }\n            \/* decrypt the key *\/\n            else {\n                if (passwordSz == 0) {\n                    \/* The key is encrypted but does not have a password *\/\n                    WOLFSSL_MSG(\"No password for encrypted key\");\n                    ret = NO_PASSWORD;\n                }\n                else {\n                    ret = wc_BufferKeyDecrypt(info, der->buffer, der->length,\n                        (byte*)password, passwordSz, WC_MD5);\n\n#ifndef NO_WOLFSSL_SKIP_TRAILING_PAD\n                #ifndef NO_DES3\n                    if (info->cipherType == WC_CIPHER_DES3) {\n                        \/* Assuming there is padding:\n                         *      (der->length > 0 && der->length > DES_BLOCK_SIZE &&\n                         *       (der->length % DES_BLOCK_SIZE) != 0)\n                         * and assuming the last value signifies the number of\n                         * padded bytes IE if last value is 0x08 then there are\n                         * 8 bytes of padding:\n                         *      padVal = der->buffer[der->length-1];\n                         * then strip this padding before proceeding:\n                         * der->length -= padVal;\n                         *\/\n                        if (der->length > DES_BLOCK_SIZE &&\n                            (der->length % DES_BLOCK_SIZE) != 0) {\n                            padVal = der->buffer[der->length-1];\n                            if (padVal < DES_BLOCK_SIZE) {\n                                der->length -= padVal;\n                            }\n                        }\n                    }\n                #endif \/* !NO_DES3 *\/\n#endif \/* !NO_WOLFSSL_SKIP_TRAILING_PAD *\/\n                }\n            }\n#ifdef OPENSSL_EXTRA\n            if (ret) {\n                PEMerr(0, PEM_R_BAD_DECRYPT);\n            }\n#endif\n            ForceZero(password, passwordSz);\n        }\n#ifdef OPENSSL_EXTRA\n        else {\n            PEMerr(0, PEM_R_BAD_PASSWORD_READ);\n        }\n#endif\n\n    #ifdef WOLFSSL_SMALL_STACK\n        XFREE(password, heap, DYNAMIC_TYPE_STRING);\n    #endif\n    }\n#endif \/* WOLFSSL_ENCRYPTED_KEYS *\/\n\n    return ret;\n}","target":0,"code_token_length":2658,"total_token_length":2894,"max_tokens_setting":4096}
+{"idx":426262,"func":"static int binder_thread_read(struct binder_proc *proc,\n\t\t\t      struct binder_thread *thread,\n\t\t\t      binder_uintptr_t binder_buffer, size_t size,\n\t\t\t      binder_size_t *consumed, int non_block)\n{\n\tvoid __user *buffer = (void __user *)(uintptr_t)binder_buffer;\n\tvoid __user *ptr = buffer + *consumed;\n\tvoid __user *end = buffer + size;\n\n\tint ret = 0;\n\tint wait_for_proc_work;\n\n\tif (*consumed == 0) {\n\t\tif (put_user(BR_NOOP, (uint32_t __user *)ptr))\n\t\t\treturn -EFAULT;\n\t\tptr += sizeof(uint32_t);\n\t}\n\nretry:\n\tbinder_inner_proc_lock(proc);\n\twait_for_proc_work = binder_available_for_proc_work_ilocked(thread);\n\tbinder_inner_proc_unlock(proc);\n\n\tthread->looper |= BINDER_LOOPER_STATE_WAITING;\n\n\ttrace_binder_wait_for_work(wait_for_proc_work,\n\t\t\t\t   !!thread->transaction_stack,\n\t\t\t\t   !binder_worklist_empty(proc, &thread->todo));\n\tif (wait_for_proc_work) {\n\t\tif (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |\n\t\t\t\t\tBINDER_LOOPER_STATE_ENTERED))) {\n\t\t\tbinder_user_error(\"%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\\n\",\n\t\t\t\tproc->pid, thread->pid, thread->looper);\n\t\t\twait_event_interruptible(binder_user_error_wait,\n\t\t\t\t\t\t binder_stop_on_user_error < 2);\n\t\t}\n\t\tbinder_set_nice(proc->default_priority);\n\t}\n\n\tif (non_block) {\n\t\tif (!binder_has_work(thread, wait_for_proc_work))\n\t\t\tret = -EAGAIN;\n\t} else {\n\t\tret = binder_wait_for_work(thread, wait_for_proc_work);\n\t}\n\n\tthread->looper &= ~BINDER_LOOPER_STATE_WAITING;\n\n\tif (ret)\n\t\treturn ret;\n\n\twhile (1) {\n\t\tuint32_t cmd;\n\t\tstruct binder_transaction_data tr;\n\t\tstruct binder_work *w = NULL;\n\t\tstruct list_head *list = NULL;\n\t\tstruct binder_transaction *t = NULL;\n\t\tstruct binder_thread *t_from;\n\n\t\tbinder_inner_proc_lock(proc);\n\t\tif (!binder_worklist_empty_ilocked(&thread->todo))\n\t\t\tlist = &thread->todo;\n\t\telse if (!binder_worklist_empty_ilocked(&proc->todo) &&\n\t\t\t   wait_for_proc_work)\n\t\t\tlist = &proc->todo;\n\t\telse {\n\t\t\tbinder_inner_proc_unlock(proc);\n\n\t\t\t\/* no data added *\/\n\t\t\tif (ptr - buffer == 4 && !thread->looper_need_return)\n\t\t\t\tgoto retry;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (end - ptr < sizeof(tr) + 4) {\n\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\tbreak;\n\t\t}\n\t\tw = binder_dequeue_work_head_ilocked(list);\n\t\tif (binder_worklist_empty_ilocked(&thread->todo))\n\t\t\tthread->process_todo = false;\n\n\t\tswitch (w->type) {\n\t\tcase BINDER_WORK_TRANSACTION: {\n\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\tt = container_of(w, struct binder_transaction, work);\n\t\t} break;\n\t\tcase BINDER_WORK_RETURN_ERROR: {\n\t\t\tstruct binder_error *e = container_of(\n\t\t\t\t\tw, struct binder_error, work);\n\n\t\t\tWARN_ON(e->cmd == BR_OK);\n\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\tif (put_user(e->cmd, (uint32_t __user *)ptr))\n\t\t\t\treturn -EFAULT;\n\t\t\tcmd = e->cmd;\n\t\t\te->cmd = BR_OK;\n\t\t\tptr += sizeof(uint32_t);\n\n\t\t\tbinder_stat_br(proc, thread, cmd);\n\t\t} break;\n\t\tcase BINDER_WORK_TRANSACTION_COMPLETE: {\n\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\tcmd = BR_TRANSACTION_COMPLETE;\n\t\t\tif (put_user(cmd, (uint32_t __user *)ptr))\n\t\t\t\treturn -EFAULT;\n\t\t\tptr += sizeof(uint32_t);\n\n\t\t\tbinder_stat_br(proc, thread, cmd);\n\t\t\tbinder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE,\n\t\t\t\t     \"%d:%d BR_TRANSACTION_COMPLETE\\n\",\n\t\t\t\t     proc->pid, thread->pid);\n\t\t\tkfree(w);\n\t\t\tbinder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);\n\t\t} break;\n\t\tcase BINDER_WORK_NODE: {\n\t\t\tstruct binder_node *node = container_of(w, struct binder_node, work);\n\t\t\tint strong, weak;\n\t\t\tbinder_uintptr_t node_ptr = node->ptr;\n\t\t\tbinder_uintptr_t node_cookie = node->cookie;\n\t\t\tint node_debug_id = node->debug_id;\n\t\t\tint has_weak_ref;\n\t\t\tint has_strong_ref;\n\t\t\tvoid __user *orig_ptr = ptr;\n\n\t\t\tBUG_ON(proc != node->proc);\n\t\t\tstrong = node->internal_strong_refs ||\n\t\t\t\t\tnode->local_strong_refs;\n\t\t\tweak = !hlist_empty(&node->refs) ||\n\t\t\t\t\tnode->local_weak_refs ||\n\t\t\t\t\tnode->tmp_refs || strong;\n\t\t\thas_strong_ref = node->has_strong_ref;\n\t\t\thas_weak_ref = node->has_weak_ref;\n\n\t\t\tif (weak && !has_weak_ref) {\n\t\t\t\tnode->has_weak_ref = 1;\n\t\t\t\tnode->pending_weak_ref = 1;\n\t\t\t\tnode->local_weak_refs++;\n\t\t\t}\n\t\t\tif (strong && !has_strong_ref) {\n\t\t\t\tnode->has_strong_ref = 1;\n\t\t\t\tnode->pending_strong_ref = 1;\n\t\t\t\tnode->local_strong_refs++;\n\t\t\t}\n\t\t\tif (!strong && has_strong_ref)\n\t\t\t\tnode->has_strong_ref = 0;\n\t\t\tif (!weak && has_weak_ref)\n\t\t\t\tnode->has_weak_ref = 0;\n\t\t\tif (!weak && !strong) {\n\t\t\t\tbinder_debug(BINDER_DEBUG_INTERNAL_REFS,\n\t\t\t\t\t     \"%d:%d node %d u%016llx c%016llx deleted\\n\",\n\t\t\t\t\t     proc->pid, thread->pid,\n\t\t\t\t\t     node_debug_id,\n\t\t\t\t\t     (u64)node_ptr,\n\t\t\t\t\t     (u64)node_cookie);\n\t\t\t\trb_erase(&node->rb_node, &proc->nodes);\n\t\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\t\tbinder_node_lock(node);\n\t\t\t\t\/*\n\t\t\t\t * Acquire the node lock before freeing the\n\t\t\t\t * node to serialize with other threads that\n\t\t\t\t * may have been holding the node lock while\n\t\t\t\t * decrementing this node (avoids race where\n\t\t\t\t * this thread frees while the other thread\n\t\t\t\t * is unlocking the node after the final\n\t\t\t\t * decrement)\n\t\t\t\t *\/\n\t\t\t\tbinder_node_unlock(node);\n\t\t\t\tbinder_free_node(node);\n\t\t\t} else\n\t\t\t\tbinder_inner_proc_unlock(proc);\n\n\t\t\tif (weak && !has_weak_ref)\n\t\t\t\tret = binder_put_node_cmd(\n\t\t\t\t\t\tproc, thread, &ptr, node_ptr,\n\t\t\t\t\t\tnode_cookie, node_debug_id,\n\t\t\t\t\t\tBR_INCREFS, \"BR_INCREFS\");\n\t\t\tif (!ret && strong && !has_strong_ref)\n\t\t\t\tret = binder_put_node_cmd(\n\t\t\t\t\t\tproc, thread, &ptr, node_ptr,\n\t\t\t\t\t\tnode_cookie, node_debug_id,\n\t\t\t\t\t\tBR_ACQUIRE, \"BR_ACQUIRE\");\n\t\t\tif (!ret && !strong && has_strong_ref)\n\t\t\t\tret = binder_put_node_cmd(\n\t\t\t\t\t\tproc, thread, &ptr, node_ptr,\n\t\t\t\t\t\tnode_cookie, node_debug_id,\n\t\t\t\t\t\tBR_RELEASE, \"BR_RELEASE\");\n\t\t\tif (!ret && !weak && has_weak_ref)\n\t\t\t\tret = binder_put_node_cmd(\n\t\t\t\t\t\tproc, thread, &ptr, node_ptr,\n\t\t\t\t\t\tnode_cookie, node_debug_id,\n\t\t\t\t\t\tBR_DECREFS, \"BR_DECREFS\");\n\t\t\tif (orig_ptr == ptr)\n\t\t\t\tbinder_debug(BINDER_DEBUG_INTERNAL_REFS,\n\t\t\t\t\t     \"%d:%d node %d u%016llx c%016llx state unchanged\\n\",\n\t\t\t\t\t     proc->pid, thread->pid,\n\t\t\t\t\t     node_debug_id,\n\t\t\t\t\t     (u64)node_ptr,\n\t\t\t\t\t     (u64)node_cookie);\n\t\t\tif (ret)\n\t\t\t\treturn ret;\n\t\t} break;\n\t\tcase BINDER_WORK_DEAD_BINDER:\n\t\tcase BINDER_WORK_DEAD_BINDER_AND_CLEAR:\n\t\tcase BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {\n\t\t\tstruct binder_ref_death *death;\n\t\t\tuint32_t cmd;\n\t\t\tbinder_uintptr_t cookie;\n\n\t\t\tdeath = container_of(w, struct binder_ref_death, work);\n\t\t\tif (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION)\n\t\t\t\tcmd = BR_CLEAR_DEATH_NOTIFICATION_DONE;\n\t\t\telse\n\t\t\t\tcmd = BR_DEAD_BINDER;\n\t\t\tcookie = death->cookie;\n\n\t\t\tbinder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,\n\t\t\t\t     \"%d:%d %s %016llx\\n\",\n\t\t\t\t      proc->pid, thread->pid,\n\t\t\t\t      cmd == BR_DEAD_BINDER ?\n\t\t\t\t      \"BR_DEAD_BINDER\" :\n\t\t\t\t      \"BR_CLEAR_DEATH_NOTIFICATION_DONE\",\n\t\t\t\t      (u64)cookie);\n\t\t\tif (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) {\n\t\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\t\tkfree(death);\n\t\t\t\tbinder_stats_deleted(BINDER_STAT_DEATH);\n\t\t\t} else {\n\t\t\t\tbinder_enqueue_work_ilocked(\n\t\t\t\t\t\tw, &proc->delivered_death);\n\t\t\t\tbinder_inner_proc_unlock(proc);\n\t\t\t}\n\t\t\tif (put_user(cmd, (uint32_t __user *)ptr))\n\t\t\t\treturn -EFAULT;\n\t\t\tptr += sizeof(uint32_t);\n\t\t\tif (put_user(cookie,\n\t\t\t\t     (binder_uintptr_t __user *)ptr))\n\t\t\t\treturn -EFAULT;\n\t\t\tptr += sizeof(binder_uintptr_t);\n\t\t\tbinder_stat_br(proc, thread, cmd);\n\t\t\tif (cmd == BR_DEAD_BINDER)\n\t\t\t\tgoto done; \/* DEAD_BINDER notifications can cause transactions *\/\n\t\t} break;\n\t\t}\n\n\t\tif (!t)\n\t\t\tcontinue;\n\n\t\tBUG_ON(t->buffer == NULL);\n\t\tif (t->buffer->target_node) {\n\t\t\tstruct binder_node *target_node = t->buffer->target_node;\n\n\t\t\ttr.target.ptr = target_node->ptr;\n\t\t\ttr.cookie =  target_node->cookie;\n\t\t\tt->saved_priority = task_nice(current);\n\t\t\tif (t->priority < target_node->min_priority &&\n\t\t\t    !(t->flags & TF_ONE_WAY))\n\t\t\t\tbinder_set_nice(t->priority);\n\t\t\telse if (!(t->flags & TF_ONE_WAY) ||\n\t\t\t\t t->saved_priority > target_node->min_priority)\n\t\t\t\tbinder_set_nice(target_node->min_priority);\n\t\t\tcmd = BR_TRANSACTION;\n\t\t} else {\n\t\t\ttr.target.ptr = 0;\n\t\t\ttr.cookie = 0;\n\t\t\tcmd = BR_REPLY;\n\t\t}\n\t\ttr.code = t->code;\n\t\ttr.flags = t->flags;\n\t\ttr.sender_euid = from_kuid(current_user_ns(), t->sender_euid);\n\n\t\tt_from = binder_get_txn_from(t);\n\t\tif (t_from) {\n\t\t\tstruct task_struct *sender = t_from->proc->tsk;\n\n\t\t\ttr.sender_pid = task_tgid_nr_ns(sender,\n\t\t\t\t\t\t\ttask_active_pid_ns(current));\n\t\t} else {\n\t\t\ttr.sender_pid = 0;\n\t\t}\n\n\t\tret = binder_apply_fd_fixups(t);\n\t\tif (ret) {\n\t\t\tstruct binder_buffer *buffer = t->buffer;\n\t\t\tbool oneway = !!(t->flags & TF_ONE_WAY);\n\t\t\tint tid = t->debug_id;\n\n\t\t\tif (t_from)\n\t\t\t\tbinder_thread_dec_tmpref(t_from);\n\t\t\tbuffer->transaction = NULL;\n\t\t\tbinder_cleanup_transaction(t, \"fd fixups failed\",\n\t\t\t\t\t\t   BR_FAILED_REPLY);\n\t\t\tbinder_free_buf(proc, buffer);\n\t\t\tbinder_debug(BINDER_DEBUG_FAILED_TRANSACTION,\n\t\t\t\t     \"%d:%d %stransaction %d fd fixups failed %d\/%d, line %d\\n\",\n\t\t\t\t     proc->pid, thread->pid,\n\t\t\t\t     oneway ? \"async \" :\n\t\t\t\t\t(cmd == BR_REPLY ? \"reply \" : \"\"),\n\t\t\t\t     tid, BR_FAILED_REPLY, ret, __LINE__);\n\t\t\tif (cmd == BR_REPLY) {\n\t\t\t\tcmd = BR_FAILED_REPLY;\n\t\t\t\tif (put_user(cmd, (uint32_t __user *)ptr))\n\t\t\t\t\treturn -EFAULT;\n\t\t\t\tptr += sizeof(uint32_t);\n\t\t\t\tbinder_stat_br(proc, thread, cmd);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\ttr.data_size = t->buffer->data_size;\n\t\ttr.offsets_size = t->buffer->offsets_size;\n\t\ttr.data.ptr.buffer = (binder_uintptr_t)\n\t\t\t((uintptr_t)t->buffer->data +\n\t\t\tbinder_alloc_get_user_buffer_offset(&proc->alloc));\n\t\ttr.data.ptr.offsets = tr.data.ptr.buffer +\n\t\t\t\t\tALIGN(t->buffer->data_size,\n\t\t\t\t\t    sizeof(void *));\n\n\t\tif (put_user(cmd, (uint32_t __user *)ptr)) {\n\t\t\tif (t_from)\n\t\t\t\tbinder_thread_dec_tmpref(t_from);\n\n\t\t\tbinder_cleanup_transaction(t, \"put_user failed\",\n\t\t\t\t\t\t   BR_FAILED_REPLY);\n\n\t\t\treturn -EFAULT;\n\t\t}\n\t\tptr += sizeof(uint32_t);\n\t\tif (copy_to_user(ptr, &tr, sizeof(tr))) {\n\t\t\tif (t_from)\n\t\t\t\tbinder_thread_dec_tmpref(t_from);\n\n\t\t\tbinder_cleanup_transaction(t, \"copy_to_user failed\",\n\t\t\t\t\t\t   BR_FAILED_REPLY);\n\n\t\t\treturn -EFAULT;\n\t\t}\n\t\tptr += sizeof(tr);\n\n\t\ttrace_binder_transaction_received(t);\n\t\tbinder_stat_br(proc, thread, cmd);\n\t\tbinder_debug(BINDER_DEBUG_TRANSACTION,\n\t\t\t     \"%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\\n\",\n\t\t\t     proc->pid, thread->pid,\n\t\t\t     (cmd == BR_TRANSACTION) ? \"BR_TRANSACTION\" :\n\t\t\t     \"BR_REPLY\",\n\t\t\t     t->debug_id, t_from ? t_from->proc->pid : 0,\n\t\t\t     t_from ? t_from->pid : 0, cmd,\n\t\t\t     t->buffer->data_size, t->buffer->offsets_size,\n\t\t\t     (u64)tr.data.ptr.buffer, (u64)tr.data.ptr.offsets);\n\n\t\tif (t_from)\n\t\t\tbinder_thread_dec_tmpref(t_from);\n\t\tt->buffer->allow_user_free = 1;\n\t\tif (cmd == BR_TRANSACTION && !(t->flags & TF_ONE_WAY)) {\n\t\t\tbinder_inner_proc_lock(thread->proc);\n\t\t\tt->to_parent = thread->transaction_stack;\n\t\t\tt->to_thread = thread;\n\t\t\tthread->transaction_stack = t;\n\t\t\tbinder_inner_proc_unlock(thread->proc);\n\t\t} else {\n\t\t\tbinder_free_transaction(t);\n\t\t}\n\t\tbreak;\n\t}\n\ndone:\n\n\t*consumed = ptr - buffer;\n\tbinder_inner_proc_lock(proc);\n\tif (proc->requested_threads == 0 &&\n\t    list_empty(&thread->proc->waiting_threads) &&\n\t    proc->requested_threads_started < proc->max_threads &&\n\t    (thread->looper & (BINDER_LOOPER_STATE_REGISTERED |\n\t     BINDER_LOOPER_STATE_ENTERED)) \/* the user-space code fails to *\/\n\t     \/*spawn a new thread if we leave this out *\/) {\n\t\tproc->requested_threads++;\n\t\tbinder_inner_proc_unlock(proc);\n\t\tbinder_debug(BINDER_DEBUG_THREADS,\n\t\t\t     \"%d:%d BR_SPAWN_LOOPER\\n\",\n\t\t\t     proc->pid, thread->pid);\n\t\tif (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer))\n\t\t\treturn -EFAULT;\n\t\tbinder_stat_br(proc, thread, BR_SPAWN_LOOPER);\n\t} else\n\t\tbinder_inner_proc_unlock(proc);\n\treturn 0;\n}","target":0,"code_token_length":3286,"total_token_length":3522,"max_tokens_setting":4096}
+{"idx":96106,"func":"test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param)\n{\n\tstruct usb_device\t*udev = testdev_to_usbdev(dev);\n\tstruct urb\t\t**urb;\n\tstruct ctrl_ctx\t\tcontext;\n\tint\t\t\ti;\n\n\tif (param->sglen == 0 || param->iterations > UINT_MAX \/ param->sglen)\n\t\treturn -EOPNOTSUPP;\n\n\tspin_lock_init(&context.lock);\n\tcontext.dev = dev;\n\tinit_completion(&context.complete);\n\tcontext.count = param->sglen * param->iterations;\n\tcontext.pending = 0;\n\tcontext.status = -ENOMEM;\n\tcontext.param = param;\n\tcontext.last = -1;\n\n\t\/* allocate and init the urbs we'll queue.\n\t * as with bulk\/intr sglists, sglen is the queue depth; it also\n\t * controls which subtests run (more tests than sglen) or rerun.\n\t *\/\n\turb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL);\n\tif (!urb)\n\t\treturn -ENOMEM;\n\tfor (i = 0; i < param->sglen; i++) {\n\t\tint\t\t\tpipe = usb_rcvctrlpipe(udev, 0);\n\t\tunsigned\t\tlen;\n\t\tstruct urb\t\t*u;\n\t\tstruct usb_ctrlrequest\treq;\n\t\tstruct subcase\t\t*reqp;\n\n\t\t\/* sign of this variable means:\n\t\t *  -: tested code must return this (negative) error code\n\t\t *  +: tested code may return this (negative too) error code\n\t\t *\/\n\t\tint\t\t\texpected = 0;\n\n\t\t\/* requests here are mostly expected to succeed on any\n\t\t * device, but some are chosen to trigger protocol stalls\n\t\t * or short reads.\n\t\t *\/\n\t\tmemset(&req, 0, sizeof(req));\n\t\treq.bRequest = USB_REQ_GET_DESCRIPTOR;\n\t\treq.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;\n\n\t\tswitch (i % NUM_SUBCASES) {\n\t\tcase 0:\t\t\/* get device descriptor *\/\n\t\t\treq.wValue = cpu_to_le16(USB_DT_DEVICE << 8);\n\t\t\tlen = sizeof(struct usb_device_descriptor);\n\t\t\tbreak;\n\t\tcase 1:\t\t\/* get first config descriptor (only) *\/\n\t\t\treq.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);\n\t\t\tlen = sizeof(struct usb_config_descriptor);\n\t\t\tbreak;\n\t\tcase 2:\t\t\/* get altsetting (OFTEN STALLS) *\/\n\t\t\treq.bRequest = USB_REQ_GET_INTERFACE;\n\t\t\treq.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;\n\t\t\t\/* index = 0 means first interface *\/\n\t\t\tlen = 1;\n\t\t\texpected = EPIPE;\n\t\t\tbreak;\n\t\tcase 3:\t\t\/* get interface status *\/\n\t\t\treq.bRequest = USB_REQ_GET_STATUS;\n\t\t\treq.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;\n\t\t\t\/* interface 0 *\/\n\t\t\tlen = 2;\n\t\t\tbreak;\n\t\tcase 4:\t\t\/* get device status *\/\n\t\t\treq.bRequest = USB_REQ_GET_STATUS;\n\t\t\treq.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;\n\t\t\tlen = 2;\n\t\t\tbreak;\n\t\tcase 5:\t\t\/* get device qualifier (MAY STALL) *\/\n\t\t\treq.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8);\n\t\t\tlen = sizeof(struct usb_qualifier_descriptor);\n\t\t\tif (udev->speed != USB_SPEED_HIGH)\n\t\t\t\texpected = EPIPE;\n\t\t\tbreak;\n\t\tcase 6:\t\t\/* get first config descriptor, plus interface *\/\n\t\t\treq.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);\n\t\t\tlen = sizeof(struct usb_config_descriptor);\n\t\t\tlen += sizeof(struct usb_interface_descriptor);\n\t\t\tbreak;\n\t\tcase 7:\t\t\/* get interface descriptor (ALWAYS STALLS) *\/\n\t\t\treq.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8);\n\t\t\t\/* interface == 0 *\/\n\t\t\tlen = sizeof(struct usb_interface_descriptor);\n\t\t\texpected = -EPIPE;\n\t\t\tbreak;\n\t\t\/* NOTE: two consecutive stalls in the queue here.\n\t\t *  that tests fault recovery a bit more aggressively. *\/\n\t\tcase 8:\t\t\/* clear endpoint halt (MAY STALL) *\/\n\t\t\treq.bRequest = USB_REQ_CLEAR_FEATURE;\n\t\t\treq.bRequestType = USB_RECIP_ENDPOINT;\n\t\t\t\/* wValue 0 == ep halt *\/\n\t\t\t\/* wIndex 0 == ep0 (shouldn't halt!) *\/\n\t\t\tlen = 0;\n\t\t\tpipe = usb_sndctrlpipe(udev, 0);\n\t\t\texpected = EPIPE;\n\t\t\tbreak;\n\t\tcase 9:\t\t\/* get endpoint status *\/\n\t\t\treq.bRequest = USB_REQ_GET_STATUS;\n\t\t\treq.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT;\n\t\t\t\/* endpoint 0 *\/\n\t\t\tlen = 2;\n\t\t\tbreak;\n\t\tcase 10:\t\/* trigger short read (EREMOTEIO) *\/\n\t\t\treq.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);\n\t\t\tlen = 1024;\n\t\t\texpected = -EREMOTEIO;\n\t\t\tbreak;\n\t\t\/* NOTE: two consecutive _different_ faults in the queue. *\/\n\t\tcase 11:\t\/* get endpoint descriptor (ALWAYS STALLS) *\/\n\t\t\treq.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8);\n\t\t\t\/* endpoint == 0 *\/\n\t\t\tlen = sizeof(struct usb_interface_descriptor);\n\t\t\texpected = EPIPE;\n\t\t\tbreak;\n\t\t\/* NOTE: sometimes even a third fault in the queue! *\/\n\t\tcase 12:\t\/* get string 0 descriptor (MAY STALL) *\/\n\t\t\treq.wValue = cpu_to_le16(USB_DT_STRING << 8);\n\t\t\t\/* string == 0, for language IDs *\/\n\t\t\tlen = sizeof(struct usb_interface_descriptor);\n\t\t\t\/* may succeed when > 4 languages *\/\n\t\t\texpected = EREMOTEIO;\t\/* or EPIPE, if no strings *\/\n\t\t\tbreak;\n\t\tcase 13:\t\/* short read, resembling case 10 *\/\n\t\t\treq.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);\n\t\t\t\/* last data packet \"should\" be DATA1, not DATA0 *\/\n\t\t\tif (udev->speed == USB_SPEED_SUPER)\n\t\t\t\tlen = 1024 - 512;\n\t\t\telse\n\t\t\t\tlen = 1024 - udev->descriptor.bMaxPacketSize0;\n\t\t\texpected = -EREMOTEIO;\n\t\t\tbreak;\n\t\tcase 14:\t\/* short read; try to fill the last packet *\/\n\t\t\treq.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0);\n\t\t\t\/* device descriptor size == 18 bytes *\/\n\t\t\tlen = udev->descriptor.bMaxPacketSize0;\n\t\t\tif (udev->speed == USB_SPEED_SUPER)\n\t\t\t\tlen = 512;\n\t\t\tswitch (len) {\n\t\t\tcase 8:\n\t\t\t\tlen = 24;\n\t\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\tlen = 32;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\texpected = -EREMOTEIO;\n\t\t\tbreak;\n\t\tcase 15:\n\t\t\treq.wValue = cpu_to_le16(USB_DT_BOS << 8);\n\t\t\tif (udev->bos)\n\t\t\t\tlen = le16_to_cpu(udev->bos->desc->wTotalLength);\n\t\t\telse\n\t\t\t\tlen = sizeof(struct usb_bos_descriptor);\n\t\t\tif (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0201)\n\t\t\t\texpected = -EPIPE;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tERROR(dev, \"bogus number of ctrl queue testcases!\\n\");\n\t\t\tcontext.status = -EINVAL;\n\t\t\tgoto cleanup;\n\t\t}\n\t\treq.wLength = cpu_to_le16(len);\n\t\turb[i] = u = simple_alloc_urb(udev, pipe, len, 0);\n\t\tif (!u)\n\t\t\tgoto cleanup;\n\n\t\treqp = kmalloc(sizeof(*reqp), GFP_KERNEL);\n\t\tif (!reqp)\n\t\t\tgoto cleanup;\n\t\treqp->setup = req;\n\t\treqp->number = i % NUM_SUBCASES;\n\t\treqp->expected = expected;\n\t\tu->setup_packet = (char *) &reqp->setup;\n\n\t\tu->context = &context;\n\t\tu->complete = ctrl_complete;\n\t}\n\n\t\/* queue the urbs *\/\n\tcontext.urb = urb;\n\tspin_lock_irq(&context.lock);\n\tfor (i = 0; i < param->sglen; i++) {\n\t\tcontext.status = usb_submit_urb(urb[i], GFP_ATOMIC);\n\t\tif (context.status != 0) {\n\t\t\tERROR(dev, \"can't submit urb[%d], status %d\\n\",\n\t\t\t\t\ti, context.status);\n\t\t\tcontext.count = context.pending;\n\t\t\tbreak;\n\t\t}\n\t\tcontext.pending++;\n\t}\n\tspin_unlock_irq(&context.lock);\n\n\t\/* FIXME  set timer and time out; provide a disconnect hook *\/\n\n\t\/* wait for the last one to complete *\/\n\tif (context.pending > 0)\n\t\twait_for_completion(&context.complete);\n\ncleanup:\n\tfor (i = 0; i < param->sglen; i++) {\n\t\tif (!urb[i])\n\t\t\tcontinue;\n\t\turb[i]->dev = udev;\n\t\tkfree(urb[i]->setup_packet);\n\t\tsimple_free_urb(urb[i]);\n\t}\n\tkfree(urb);\n\treturn context.status;\n}","target":0,"code_token_length":2016,"total_token_length":2252,"max_tokens_setting":4096}
+{"idx":327496,"func":"static void load_elf_image(const char *image_name, int image_fd,\n\n                           struct image_info *info, char **pinterp_name,\n\n                           char bprm_buf[BPRM_BUF_SIZE])\n\n{\n\n    struct elfhdr *ehdr = (struct elfhdr *)bprm_buf;\n\n    struct elf_phdr *phdr;\n\n    abi_ulong load_addr, load_bias, loaddr, hiaddr, error;\n\n    int i, retval;\n\n    const char *errmsg;\n\n\n\n    \/* First of all, some simple consistency checks *\/\n\n    errmsg = \"Invalid ELF image for this architecture\";\n\n    if (!elf_check_ident(ehdr)) {\n\n        goto exit_errmsg;\n\n    }\n\n    bswap_ehdr(ehdr);\n\n    if (!elf_check_ehdr(ehdr)) {\n\n        goto exit_errmsg;\n\n    }\n\n\n\n    i = ehdr->e_phnum * sizeof(struct elf_phdr);\n\n    if (ehdr->e_phoff + i <= BPRM_BUF_SIZE) {\n\n        phdr = (struct elf_phdr *)(bprm_buf + ehdr->e_phoff);\n\n    } else {\n\n        phdr = (struct elf_phdr *) alloca(i);\n\n        retval = pread(image_fd, phdr, i, ehdr->e_phoff);\n\n        if (retval != i) {\n\n            goto exit_read;\n\n        }\n\n    }\n\n    bswap_phdr(phdr, ehdr->e_phnum);\n\n\n\n#ifdef CONFIG_USE_FDPIC\n\n    info->nsegs = 0;\n\n    info->pt_dynamic_addr = 0;\n\n#endif\n\n\n\n    \/* Find the maximum size of the image and allocate an appropriate\n\n       amount of memory to handle that.  *\/\n\n    loaddr = -1, hiaddr = 0;\n\n    for (i = 0; i < ehdr->e_phnum; ++i) {\n\n        if (phdr[i].p_type == PT_LOAD) {\n\n            abi_ulong a = phdr[i].p_vaddr;\n\n            if (a < loaddr) {\n\n                loaddr = a;\n\n            }\n\n            a += phdr[i].p_memsz;\n\n            if (a > hiaddr) {\n\n                hiaddr = a;\n\n            }\n\n#ifdef CONFIG_USE_FDPIC\n\n            ++info->nsegs;\n\n#endif\n\n        }\n\n    }\n\n\n\n    load_addr = loaddr;\n\n    if (ehdr->e_type == ET_DYN) {\n\n        \/* The image indicates that it can be loaded anywhere.  Find a\n\n           location that can hold the memory space required.  If the\n\n           image is pre-linked, LOADDR will be non-zero.  Since we do\n\n           not supply MAP_FIXED here we'll use that address if and\n\n           only if it remains available.  *\/\n\n        load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE,\n\n                                MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,\n\n                                -1, 0);\n\n        if (load_addr == -1) {\n\n            goto exit_perror;\n\n        }\n\n    } else if (pinterp_name != NULL) {\n\n        \/* This is the main executable.  Make sure that the low\n\n           address does not conflict with MMAP_MIN_ADDR or the\n\n           QEMU application itself.  *\/\n\n        probe_guest_base(image_name, loaddr, hiaddr);\n\n    }\n\n    load_bias = load_addr - loaddr;\n\n\n\n#ifdef CONFIG_USE_FDPIC\n\n    {\n\n        struct elf32_fdpic_loadseg *loadsegs = info->loadsegs =\n\n            g_malloc(sizeof(*loadsegs) * info->nsegs);\n\n\n\n        for (i = 0; i < ehdr->e_phnum; ++i) {\n\n            switch (phdr[i].p_type) {\n\n            case PT_DYNAMIC:\n\n                info->pt_dynamic_addr = phdr[i].p_vaddr + load_bias;\n\n                break;\n\n            case PT_LOAD:\n\n                loadsegs->addr = phdr[i].p_vaddr + load_bias;\n\n                loadsegs->p_vaddr = phdr[i].p_vaddr;\n\n                loadsegs->p_memsz = phdr[i].p_memsz;\n\n                ++loadsegs;\n\n                break;\n\n            }\n\n        }\n\n    }\n\n#endif\n\n\n\n    info->load_bias = load_bias;\n\n    info->load_addr = load_addr;\n\n    info->entry = ehdr->e_entry + load_bias;\n\n    info->start_code = -1;\n\n    info->end_code = 0;\n\n    info->start_data = -1;\n\n    info->end_data = 0;\n\n    info->brk = 0;\n\n\n\n\n    for (i = 0; i < ehdr->e_phnum; i++) {\n\n        struct elf_phdr *eppnt = phdr + i;\n\n        if (eppnt->p_type == PT_LOAD) {\n\n            abi_ulong vaddr, vaddr_po, vaddr_ps, vaddr_ef, vaddr_em;\n\n            int elf_prot = 0;\n\n\n\n            if (eppnt->p_flags & PF_R) elf_prot =  PROT_READ;\n\n            if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE;\n\n            if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC;\n\n\n\n            vaddr = load_bias + eppnt->p_vaddr;\n\n            vaddr_po = TARGET_ELF_PAGEOFFSET(vaddr);\n\n            vaddr_ps = TARGET_ELF_PAGESTART(vaddr);\n\n\n\n            error = target_mmap(vaddr_ps, eppnt->p_filesz + vaddr_po,\n\n                                elf_prot, MAP_PRIVATE | MAP_FIXED,\n\n                                image_fd, eppnt->p_offset - vaddr_po);\n\n            if (error == -1) {\n\n                goto exit_perror;\n\n            }\n\n\n\n            vaddr_ef = vaddr + eppnt->p_filesz;\n\n            vaddr_em = vaddr + eppnt->p_memsz;\n\n\n\n            \/* If the load segment requests extra zeros (e.g. bss), map it.  *\/\n\n            if (vaddr_ef < vaddr_em) {\n\n                zero_bss(vaddr_ef, vaddr_em, elf_prot);\n\n            }\n\n\n\n            \/* Find the full program boundaries.  *\/\n\n            if (elf_prot & PROT_EXEC) {\n\n                if (vaddr < info->start_code) {\n\n                    info->start_code = vaddr;\n\n                }\n\n                if (vaddr_ef > info->end_code) {\n\n                    info->end_code = vaddr_ef;\n\n                }\n\n            }\n\n            if (elf_prot & PROT_WRITE) {\n\n                if (vaddr < info->start_data) {\n\n                    info->start_data = vaddr;\n\n                }\n\n                if (vaddr_ef > info->end_data) {\n\n                    info->end_data = vaddr_ef;\n\n                }\n\n                if (vaddr_em > info->brk) {\n\n                    info->brk = vaddr_em;\n\n                }\n\n            }\n\n        } else if (eppnt->p_type == PT_INTERP && pinterp_name) {\n\n            char *interp_name;\n\n\n\n            if (*pinterp_name) {\n\n                errmsg = \"Multiple PT_INTERP entries\";\n\n                goto exit_errmsg;\n\n            }\n\n            interp_name = malloc(eppnt->p_filesz);\n\n            if (!interp_name) {\n\n                goto exit_perror;\n\n            }\n\n\n\n            if (eppnt->p_offset + eppnt->p_filesz <= BPRM_BUF_SIZE) {\n\n                memcpy(interp_name, bprm_buf + eppnt->p_offset,\n\n                       eppnt->p_filesz);\n\n            } else {\n\n                retval = pread(image_fd, interp_name, eppnt->p_filesz,\n\n                               eppnt->p_offset);\n\n                if (retval != eppnt->p_filesz) {\n\n                    goto exit_perror;\n\n                }\n\n            }\n\n            if (interp_name[eppnt->p_filesz - 1] != 0) {\n\n                errmsg = \"Invalid PT_INTERP entry\";\n\n                goto exit_errmsg;\n\n            }\n\n            *pinterp_name = interp_name;\n\n        }\n\n    }\n\n\n\n    if (info->end_data == 0) {\n\n        info->start_data = info->end_code;\n\n        info->end_data = info->end_code;\n\n        info->brk = info->end_code;\n\n    }\n\n\n\n    if (qemu_log_enabled()) {\n\n        load_symbols(ehdr, image_fd, load_bias);\n\n    }\n\n\n\n    close(image_fd);\n\n    return;\n\n\n\n exit_read:\n\n    if (retval >= 0) {\n\n        errmsg = \"Incomplete read of file header\";\n\n        goto exit_errmsg;\n\n    }\n\n exit_perror:\n\n    errmsg = strerror(errno);\n\n exit_errmsg:\n\n    fprintf(stderr, \"%s: %s\\n\", image_name, errmsg);\n\n    exit(-1);\n\n}","target":1,"code_token_length":1812,"total_token_length":2048,"max_tokens_setting":4096}
+{"idx":324473,"func":"int attribute_align_arg sws_scale(struct SwsContext *c,\n\n                                  const uint8_t * const srcSlice[],\n\n                                  const int srcStride[], int srcSliceY,\n\n                                  int srcSliceH, uint8_t *const dst[],\n\n                                  const int dstStride[])\n\n{\n\n    int i, ret;\n\n    const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] };\n\n    uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] };\n\n    uint8_t *rgb0_tmp = NULL;\n\n\n\n    \/\/ do not mess up sliceDir if we have a \"trailing\" 0-size slice\n\n    if (srcSliceH == 0)\n\n        return 0;\n\n\n\n    if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {\n\n        av_log(c, AV_LOG_ERROR, \"bad src image pointers\\n\");\n\n        return 0;\n\n    }\n\n    if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {\n\n        av_log(c, AV_LOG_ERROR, \"bad dst image pointers\\n\");\n\n        return 0;\n\n    }\n\n\n\n    if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {\n\n        av_log(c, AV_LOG_ERROR, \"Slices start in the middle!\\n\");\n\n        return 0;\n\n    }\n\n    if (c->sliceDir == 0) {\n\n        if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;\n\n    }\n\n\n\n    if (usePal(c->srcFormat)) {\n\n        for (i = 0; i < 256; i++) {\n\n            int p, r, g, b, y, u, v, a = 0xff;\n\n            if (c->srcFormat == AV_PIX_FMT_PAL8) {\n\n                p = ((const uint32_t *)(srcSlice[1]))[i];\n\n                a = (p >> 24) & 0xFF;\n\n                r = (p >> 16) & 0xFF;\n\n                g = (p >>  8) & 0xFF;\n\n                b =  p        & 0xFF;\n\n            } else if (c->srcFormat == AV_PIX_FMT_RGB8) {\n\n                r = ( i >> 5     ) * 36;\n\n                g = ((i >> 2) & 7) * 36;\n\n                b = ( i       & 3) * 85;\n\n            } else if (c->srcFormat == AV_PIX_FMT_BGR8) {\n\n                b = ( i >> 6     ) * 85;\n\n                g = ((i >> 3) & 7) * 36;\n\n                r = ( i       & 7) * 36;\n\n            } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {\n\n                r = ( i >> 3     ) * 255;\n\n                g = ((i >> 1) & 3) * 85;\n\n                b = ( i       & 1) * 255;\n\n            } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {\n\n                r = g = b = i;\n\n            } else {\n\n                av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);\n\n                b = ( i >> 3     ) * 255;\n\n                g = ((i >> 1) & 3) * 85;\n\n                r = ( i       & 1) * 255;\n\n            }\n\n#define RGB2YUV_SHIFT 15\n\n#define BY ( (int) (0.114 * 219 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define BV (-(int) (0.081 * 224 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define BU ( (int) (0.500 * 224 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define GY ( (int) (0.587 * 219 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define GV (-(int) (0.419 * 224 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define GU (-(int) (0.331 * 224 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define RY ( (int) (0.299 * 219 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define RV ( (int) (0.500 * 224 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n#define RU (-(int) (0.169 * 224 \/ 255 * (1 << RGB2YUV_SHIFT) + 0.5))\n\n\n\n            y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);\n\n            u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);\n\n            v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);\n\n            c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24);\n\n\n\n            switch (c->dstFormat) {\n\n            case AV_PIX_FMT_BGR32:\n\n#if !HAVE_BIGENDIAN\n\n            case AV_PIX_FMT_RGB24:\n\n#endif\n\n                c->pal_rgb[i]=  r + (g<<8) + (b<<16) + ((unsigned)a<<24);\n\n                break;\n\n            case AV_PIX_FMT_BGR32_1:\n\n#if HAVE_BIGENDIAN\n\n            case AV_PIX_FMT_BGR24:\n\n#endif\n\n                c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24);\n\n                break;\n\n            case AV_PIX_FMT_RGB32_1:\n\n#if HAVE_BIGENDIAN\n\n            case AV_PIX_FMT_RGB24:\n\n#endif\n\n                c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24);\n\n                break;\n\n            case AV_PIX_FMT_RGB32:\n\n#if !HAVE_BIGENDIAN\n\n            case AV_PIX_FMT_BGR24:\n\n#endif\n\n            default:\n\n                c->pal_rgb[i]=  b + (g<<8) + (r<<16) + ((unsigned)a<<24);\n\n            }\n\n        }\n\n    }\n\n\n\n    if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {\n\n        uint8_t *base;\n\n        int x,y;\n\n        rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);\n\n        base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;\n\n        for (y=0; ysrcW);\n\n            for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {\n\n                base[ srcStride[0]*y + x] = 0xFF;\n\n            }\n\n        }\n\n        src2[0] = base;\n\n    }\n\n\n\n    \/\/ copy strides, so they can safely be modified\n\n    if (c->sliceDir == 1) {\n\n        \/\/ slices go from top to bottom\n\n        int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],\n\n                              srcStride[3] };\n\n        int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],\n\n                              dstStride[3] };\n\n\n\n        reset_ptr(src2, c->srcFormat);\n\n        reset_ptr((void*)dst2, c->dstFormat);\n\n\n\n        \/* reset slice direction at end of frame *\/\n\n        if (srcSliceY + srcSliceH == c->srcH)\n\n            c->sliceDir = 0;\n\n\n\n        ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,\n\n                          dstStride2);\n\n    } else {\n\n        \/\/ slices go from bottom to top => we flip the image internally\n\n        int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],\n\n                              -srcStride[3] };\n\n        int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],\n\n                              -dstStride[3] };\n\n\n\n        src2[0] += (srcSliceH - 1) * srcStride[0];\n\n        if (!usePal(c->srcFormat))\n\n            src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];\n\n        src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];\n\n        src2[3] += (srcSliceH - 1) * srcStride[3];\n\n        dst2[0] += ( c->dstH                         - 1) * dstStride[0];\n\n        dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];\n\n        dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];\n\n        dst2[3] += ( c->dstH                         - 1) * dstStride[3];\n\n\n\n        reset_ptr(src2, c->srcFormat);\n\n        reset_ptr((void*)dst2, c->dstFormat);\n\n\n\n        \/* reset slice direction at end of frame *\/\n\n        if (!srcSliceY)\n\n            c->sliceDir = 0;\n\n\n\n        ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,\n\n                          srcSliceH, dst2, dstStride2);\n\n    }\n\n\n\n    av_free(rgb0_tmp);\n\n    return ret;\n\n}\n","target":0,"code_token_length":2384,"total_token_length":2620,"max_tokens_setting":4096}
+{"idx":236085,"func":"static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)\n{\n\tmemset(header, 0, sizeof(*header));\n\t\/* INFO HEADER *\/\n\t\/* ------------- *\/\n\theader->biSize  = (OPJ_UINT32)getc(IN);\n\theader->biSize |= (OPJ_UINT32)getc(IN) << 8;\n\theader->biSize |= (OPJ_UINT32)getc(IN) << 16;\n\theader->biSize |= (OPJ_UINT32)getc(IN) << 24;\n\t\n\tswitch (header->biSize) {\n\t\tcase 12U:  \/* BITMAPCOREHEADER *\/\n\t\tcase 40U:  \/* BITMAPINFOHEADER *\/\n\t\tcase 52U:  \/* BITMAPV2INFOHEADER *\/\n\t\tcase 56U:  \/* BITMAPV3INFOHEADER *\/\n\t\tcase 108U: \/* BITMAPV4HEADER *\/\n\t\tcase 124U: \/* BITMAPV5HEADER *\/\n\t\t\tbreak;\n  default:\n\t\t\tfprintf(stderr,\"Error, unknown BMP header size %d\\n\", header->biSize);\n\t\t\treturn OPJ_FALSE;\n\t}\n\t\n\theader->biWidth  = (OPJ_UINT32)getc(IN);\n\theader->biWidth |= (OPJ_UINT32)getc(IN) << 8;\n\theader->biWidth |= (OPJ_UINT32)getc(IN) << 16;\n\theader->biWidth |= (OPJ_UINT32)getc(IN) << 24;\n\t\n\theader->biHeight  = (OPJ_UINT32)getc(IN);\n\theader->biHeight |= (OPJ_UINT32)getc(IN) << 8;\n\theader->biHeight |= (OPJ_UINT32)getc(IN) << 16;\n\theader->biHeight |= (OPJ_UINT32)getc(IN) << 24;\n\t\n\theader->biPlanes  = (OPJ_UINT16)getc(IN);\n\theader->biPlanes |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);\n\t\n\theader->biBitCount  = (OPJ_UINT16)getc(IN);\n\theader->biBitCount |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);\n\t\n\tif(header->biSize >= 40U) {\n\t\theader->biCompression  = (OPJ_UINT32)getc(IN);\n\t\theader->biCompression |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biCompression |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biCompression |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biSizeImage  = (OPJ_UINT32)getc(IN);\n\t\theader->biSizeImage |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biSizeImage |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biSizeImage |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biXpelsPerMeter  = (OPJ_UINT32)getc(IN);\n\t\theader->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biYpelsPerMeter  = (OPJ_UINT32)getc(IN);\n\t\theader->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biClrUsed  = (OPJ_UINT32)getc(IN);\n\t\theader->biClrUsed |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biClrUsed |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biClrUsed |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biClrImportant  = (OPJ_UINT32)getc(IN);\n\t\theader->biClrImportant |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biClrImportant |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biClrImportant |= (OPJ_UINT32)getc(IN) << 24;\n\t}\n\t\n\tif(header->biSize >= 56U) {\n\t\theader->biRedMask  = (OPJ_UINT32)getc(IN);\n\t\theader->biRedMask |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biRedMask |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biRedMask |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biGreenMask  = (OPJ_UINT32)getc(IN);\n\t\theader->biGreenMask |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biGreenMask |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biGreenMask |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biBlueMask  = (OPJ_UINT32)getc(IN);\n\t\theader->biBlueMask |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biBlueMask |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biBlueMask |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biAlphaMask  = (OPJ_UINT32)getc(IN);\n\t\theader->biAlphaMask |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biAlphaMask |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biAlphaMask |= (OPJ_UINT32)getc(IN) << 24;\n\t}\n\t\n\tif(header->biSize >= 108U) {\n\t\theader->biColorSpaceType  = (OPJ_UINT32)getc(IN);\n\t\theader->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\tif (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) {\n\t\t\tfprintf(stderr,\"Error, can't  read BMP header\\n\");\n\t\t\treturn OPJ_FALSE;\n\t\t}\n\t\t\n\t\theader->biRedGamma  = (OPJ_UINT32)getc(IN);\n\t\theader->biRedGamma |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biRedGamma |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biRedGamma |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biGreenGamma  = (OPJ_UINT32)getc(IN);\n\t\theader->biGreenGamma |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biGreenGamma |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biGreenGamma |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biBlueGamma  = (OPJ_UINT32)getc(IN);\n\t\theader->biBlueGamma |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biBlueGamma |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biBlueGamma |= (OPJ_UINT32)getc(IN) << 24;\n\t}\n\t\n\tif(header->biSize >= 124U) {\n\t\theader->biIntent  = (OPJ_UINT32)getc(IN);\n\t\theader->biIntent |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biIntent |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biIntent |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biIccProfileData  = (OPJ_UINT32)getc(IN);\n\t\theader->biIccProfileData |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biIccProfileData |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biIccProfileData |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biIccProfileSize  = (OPJ_UINT32)getc(IN);\n\t\theader->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 24;\n\t\t\n\t\theader->biReserved  = (OPJ_UINT32)getc(IN);\n\t\theader->biReserved |= (OPJ_UINT32)getc(IN) << 8;\n\t\theader->biReserved |= (OPJ_UINT32)getc(IN) << 16;\n\t\theader->biReserved |= (OPJ_UINT32)getc(IN) << 24;\n\t}\n\treturn OPJ_TRUE;\n}\n","target":0,"code_token_length":2156,"total_token_length":2392,"max_tokens_setting":4096}
+{"idx":498553,"func":"transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,\n\t\t\t\t\t\tconst char *queryString)\n{\n\tRelation\trel;\n\tParseState *pstate;\n\tCreateStmtContext cxt;\n\tList\t   *result;\n\tList\t   *save_alist;\n\tListCell   *lcmd,\n\t\t\t   *l;\n\tList\t   *newcmds = NIL;\n\tbool\t\tskipValidation = true;\n\tAlterTableCmd *newcmd;\n\tRangeTblEntry *rte;\n\n\t\/*\n\t * We must not scribble on the passed-in AlterTableStmt, so copy it. (This\n\t * is overkill, but easy.)\n\t *\/\n\tstmt = copyObject(stmt);\n\n\t\/* Caller is responsible for locking the relation *\/\n\trel = relation_open(relid, NoLock);\n\n\t\/* Set up pstate *\/\n\tpstate = make_parsestate(NULL);\n\tpstate->p_sourcetext = queryString;\n\trte = addRangeTableEntryForRelation(pstate,\n\t\t\t\t\t\t\t\t\t\trel,\n\t\t\t\t\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\ttrue);\n\taddRTEtoQuery(pstate, rte, false, true, true);\n\n\t\/* Set up CreateStmtContext *\/\n\tcxt.pstate = pstate;\n\tif (stmt->relkind == OBJECT_FOREIGN_TABLE)\n\t{\n\t\tcxt.stmtType = \"ALTER FOREIGN TABLE\";\n\t\tcxt.isforeign = true;\n\t}\n\telse\n\t{\n\t\tcxt.stmtType = \"ALTER TABLE\";\n\t\tcxt.isforeign = false;\n\t}\n\tcxt.relation = stmt->relation;\n\tcxt.rel = rel;\n\tcxt.inhRelations = NIL;\n\tcxt.isalter = true;\n\tcxt.hasoids = false;\t\t\/* need not be right *\/\n\tcxt.columns = NIL;\n\tcxt.ckconstraints = NIL;\n\tcxt.fkconstraints = NIL;\n\tcxt.ixconstraints = NIL;\n\tcxt.likeclauses = NIL;\n\tcxt.extstats = NIL;\n\tcxt.blist = NIL;\n\tcxt.alist = NIL;\n\tcxt.pkey = NULL;\n\tcxt.ispartitioned = (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);\n\tcxt.partbound = NULL;\n\tcxt.ofType = false;\n\n\t\/*\n\t * The only subtypes that currently require parse transformation handling\n\t * are ADD COLUMN, ADD CONSTRAINT and SET DATA TYPE.  These largely re-use\n\t * code from CREATE TABLE.\n\t *\/\n\tforeach(lcmd, stmt->cmds)\n\t{\n\t\tAlterTableCmd *cmd = (AlterTableCmd *) lfirst(lcmd);\n\n\t\tswitch (cmd->subtype)\n\t\t{\n\t\t\tcase AT_AddColumn:\n\t\t\tcase AT_AddColumnToView:\n\t\t\t\t{\n\t\t\t\t\tColumnDef  *def = castNode(ColumnDef, cmd->def);\n\n\t\t\t\t\ttransformColumnDefinition(&cxt, def);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If the column has a non-null default, we can't skip\n\t\t\t\t\t * validation of foreign keys.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (def->raw_default != NULL)\n\t\t\t\t\t\tskipValidation = false;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * All constraints are processed in other ways. Remove the\n\t\t\t\t\t * original list\n\t\t\t\t\t *\/\n\t\t\t\t\tdef->constraints = NIL;\n\n\t\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tcase AT_AddConstraint:\n\n\t\t\t\t\/*\n\t\t\t\t * The original AddConstraint cmd node doesn't go to newcmds\n\t\t\t\t *\/\n\t\t\t\tif (IsA(cmd->def, Constraint))\n\t\t\t\t{\n\t\t\t\t\ttransformTableConstraint(&cxt, (Constraint *) cmd->def);\n\t\t\t\t\tif (((Constraint *) cmd->def)->contype == CONSTR_FOREIGN)\n\t\t\t\t\t\tskipValidation = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\telog(ERROR, \"unrecognized node type: %d\",\n\t\t\t\t\t\t (int) nodeTag(cmd->def));\n\t\t\t\tbreak;\n\n\t\t\tcase AT_ProcessedConstraint:\n\n\t\t\t\t\/*\n\t\t\t\t * Already-transformed ADD CONSTRAINT, so just make it look\n\t\t\t\t * like the standard case.\n\t\t\t\t *\/\n\t\t\t\tcmd->subtype = AT_AddConstraint;\n\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\tbreak;\n\n\t\t\tcase AT_AlterColumnType:\n\t\t\t\t{\n\t\t\t\t\tColumnDef  *def = (ColumnDef *) cmd->def;\n\t\t\t\t\tAttrNumber\tattnum;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * For ALTER COLUMN TYPE, transform the USING clause if\n\t\t\t\t\t * one was specified.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (def->raw_default)\n\t\t\t\t\t{\n\t\t\t\t\t\tdef->cooked_default =\n\t\t\t\t\t\t\ttransformExpr(pstate, def->raw_default,\n\t\t\t\t\t\t\t\t\t\t  EXPR_KIND_ALTER_COL_TRANSFORM);\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * For identity column, create ALTER SEQUENCE command to\n\t\t\t\t\t * change the data type of the sequence.\n\t\t\t\t\t *\/\n\t\t\t\t\tattnum = get_attnum(relid, cmd->name);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if attribute not found, something will error about it\n\t\t\t\t\t * later\n\t\t\t\t\t *\/\n\t\t\t\t\tif (attnum > 0 && get_attidentity(relid, attnum))\n\t\t\t\t\t{\n\t\t\t\t\t\tOid\t\t\tseq_relid = getOwnedSequence(relid, attnum);\n\t\t\t\t\t\tOid\t\t\ttypeOid = typenameTypeId(pstate, def->typeName);\n\t\t\t\t\t\tAlterSeqStmt *altseqstmt = makeNode(AlterSeqStmt);\n\n\t\t\t\t\t\taltseqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tget_rel_name(seq_relid),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-1);\n\t\t\t\t\t\taltseqstmt->options = list_make1(makeDefElem(\"as\", (Node *) makeTypeNameFromOid(typeOid, -1), -1));\n\t\t\t\t\t\taltseqstmt->for_identity = true;\n\t\t\t\t\t\tcxt.blist = lappend(cxt.blist, altseqstmt);\n\t\t\t\t\t}\n\n\t\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tcase AT_AddIdentity:\n\t\t\t\t{\n\t\t\t\t\tConstraint *def = castNode(Constraint, cmd->def);\n\t\t\t\t\tColumnDef  *newdef = makeNode(ColumnDef);\n\t\t\t\t\tAttrNumber\tattnum;\n\n\t\t\t\t\tnewdef->colname = cmd->name;\n\t\t\t\t\tnewdef->identity = def->generated_when;\n\t\t\t\t\tcmd->def = (Node *) newdef;\n\n\t\t\t\t\tattnum = get_attnum(relid, cmd->name);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if attribute not found, something will error about it\n\t\t\t\t\t * later\n\t\t\t\t\t *\/\n\t\t\t\t\tif (attnum != InvalidAttrNumber)\n\t\t\t\t\t\tgenerateSerialExtraStmts(&cxt, newdef,\n\t\t\t\t\t\t\t\t\t\t\t\t get_atttype(relid, attnum),\n\t\t\t\t\t\t\t\t\t\t\t\t def->options, true,\n\t\t\t\t\t\t\t\t\t\t\t\t NULL, NULL);\n\n\t\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tcase AT_SetIdentity:\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * Create an ALTER SEQUENCE statement for the internal\n\t\t\t\t\t * sequence of the identity column.\n\t\t\t\t\t *\/\n\t\t\t\t\tListCell   *lc;\n\t\t\t\t\tList\t   *newseqopts = NIL;\n\t\t\t\t\tList\t   *newdef = NIL;\n\t\t\t\t\tList\t   *seqlist;\n\t\t\t\t\tAttrNumber\tattnum;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Split options into those handled by ALTER SEQUENCE and\n\t\t\t\t\t * those for ALTER TABLE proper.\n\t\t\t\t\t *\/\n\t\t\t\t\tforeach(lc, castNode(List, cmd->def))\n\t\t\t\t\t{\n\t\t\t\t\t\tDefElem    *def = lfirst_node(DefElem, lc);\n\n\t\t\t\t\t\tif (strcmp(def->defname, \"generated\") == 0)\n\t\t\t\t\t\t\tnewdef = lappend(newdef, def);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnewseqopts = lappend(newseqopts, def);\n\t\t\t\t\t}\n\n\t\t\t\t\tattnum = get_attnum(relid, cmd->name);\n\n\t\t\t\t\tif (attnum)\n\t\t\t\t\t{\n\t\t\t\t\t\tseqlist = getOwnedSequences(relid, attnum);\n\t\t\t\t\t\tif (seqlist)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tAlterSeqStmt *seqstmt;\n\t\t\t\t\t\t\tOid\t\t\tseq_relid;\n\n\t\t\t\t\t\t\tseqstmt = makeNode(AlterSeqStmt);\n\t\t\t\t\t\t\tseq_relid = linitial_oid(seqlist);\n\t\t\t\t\t\t\tseqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t get_rel_name(seq_relid), -1);\n\t\t\t\t\t\t\tseqstmt->options = newseqopts;\n\t\t\t\t\t\t\tseqstmt->for_identity = true;\n\t\t\t\t\t\t\tseqstmt->missing_ok = false;\n\n\t\t\t\t\t\t\tcxt.alist = lappend(cxt.alist, seqstmt);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If column was not found or was not an identity column,\n\t\t\t\t\t * we just let the ALTER TABLE command error out later.\n\t\t\t\t\t *\/\n\n\t\t\t\t\tcmd->def = (Node *) newdef;\n\t\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tcase AT_AttachPartition:\n\t\t\tcase AT_DetachPartition:\n\t\t\t\t{\n\t\t\t\t\tPartitionCmd *partcmd = (PartitionCmd *) cmd->def;\n\n\t\t\t\t\ttransformPartitionCmd(&cxt, partcmd);\n\t\t\t\t\t\/* assign transformed value of the partition bound *\/\n\t\t\t\t\tpartcmd->bound = cxt.partbound;\n\t\t\t\t}\n\n\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tnewcmds = lappend(newcmds, cmd);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/*\n\t * transformIndexConstraints wants cxt.alist to contain only index\n\t * statements, so transfer anything we already have into save_alist\n\t * immediately.\n\t *\/\n\tsave_alist = cxt.alist;\n\tcxt.alist = NIL;\n\n\t\/* Postprocess constraints *\/\n\ttransformIndexConstraints(&cxt);\n\ttransformFKConstraints(&cxt, skipValidation, true);\n\ttransformCheckConstraints(&cxt, false);\n\n\t\/*\n\t * Push any index-creation commands into the ALTER, so that they can be\n\t * scheduled nicely by tablecmds.c.  Note that tablecmds.c assumes that\n\t * the IndexStmt attached to an AT_AddIndex or AT_AddIndexConstraint\n\t * subcommand has already been through transformIndexStmt.\n\t *\/\n\tforeach(l, cxt.alist)\n\t{\n\t\tIndexStmt  *idxstmt = lfirst_node(IndexStmt, l);\n\n\t\tidxstmt = transformIndexStmt(relid, idxstmt, queryString);\n\t\tnewcmd = makeNode(AlterTableCmd);\n\t\tnewcmd->subtype = OidIsValid(idxstmt->indexOid) ? AT_AddIndexConstraint : AT_AddIndex;\n\t\tnewcmd->def = (Node *) idxstmt;\n\t\tnewcmds = lappend(newcmds, newcmd);\n\t}\n\tcxt.alist = NIL;\n\n\t\/* Append any CHECK or FK constraints to the commands list *\/\n\tforeach(l, cxt.ckconstraints)\n\t{\n\t\tnewcmd = makeNode(AlterTableCmd);\n\t\tnewcmd->subtype = AT_AddConstraint;\n\t\tnewcmd->def = (Node *) lfirst(l);\n\t\tnewcmds = lappend(newcmds, newcmd);\n\t}\n\tforeach(l, cxt.fkconstraints)\n\t{\n\t\tnewcmd = makeNode(AlterTableCmd);\n\t\tnewcmd->subtype = AT_AddConstraint;\n\t\tnewcmd->def = (Node *) lfirst(l);\n\t\tnewcmds = lappend(newcmds, newcmd);\n\t}\n\n\t\/* Append extended statistic objects *\/\n\ttransformExtendedStatistics(&cxt);\n\n\t\/* Close rel *\/\n\trelation_close(rel, NoLock);\n\n\t\/*\n\t * Output results.\n\t *\/\n\tstmt->cmds = newcmds;\n\n\tresult = lappend(cxt.blist, stmt);\n\tresult = list_concat(result, cxt.alist);\n\tresult = list_concat(result, save_alist);\n\n\treturn result;\n}","target":0,"code_token_length":2365,"total_token_length":2601,"max_tokens_setting":4096}
+{"idx":10604,"func":"gs_call_interp(i_ctx_t **pi_ctx_p, ref * pref, int user_errors,\n               int *pexit_code, ref * perror_object)\n{\n    ref *epref = pref;\n    ref doref;\n    ref *perrordict;\n    ref error_name;\n    int code, ccode;\n    ref saref;\n    i_ctx_t *i_ctx_p = *pi_ctx_p;\n    int *gc_signal = &imemory_system->gs_lib_ctx->gcsignal;\n\n    *pexit_code = 0;\n    *gc_signal = 0;\n    ialloc_reset_requested(idmemory);\nagain:\n    \/* Avoid a dangling error object that might get traced by a future GC. *\/\n    make_null(perror_object);\n    o_stack.requested = e_stack.requested = d_stack.requested = 0;\n    while (*gc_signal) { \/* Some routine below triggered a GC. *\/\n        gs_gc_root_t epref_root;\n\n        *gc_signal = 0;\n        \/* Make sure that doref will get relocated properly if *\/\n        \/* a garbage collection happens with epref == &doref. *\/\n        gs_register_ref_root(imemory_system, &epref_root,\n                             (void **)&epref, \"gs_call_interp(epref)\");\n        code = interp_reclaim(pi_ctx_p, -1);\n        i_ctx_p = *pi_ctx_p;\n        gs_unregister_root(imemory_system, &epref_root,\n                           \"gs_call_interp(epref)\");\n        if (code < 0)\n            return code;\n    }\n    code = interp(pi_ctx_p, epref, perror_object);\n    i_ctx_p = *pi_ctx_p;\n    if (!r_has_type(&i_ctx_p->error_object, t__invalid)) {\n        *perror_object = i_ctx_p->error_object;\n        make_t(&i_ctx_p->error_object, t__invalid);\n    }\n    \/* Prevent a dangling reference to the GC signal in ticks_left *\/\n    \/* in the frame of interp, but be prepared to do a GC if *\/\n    \/* an allocation in this routine asks for it. *\/\n    *gc_signal = 0;\n    set_gc_signal(i_ctx_p, 1);\n    if (esp < esbot)            \/* popped guard entry *\/\n        esp = esbot;\n    switch (code) {\n        case gs_error_Fatal:\n            *pexit_code = 255;\n            return code;\n        case gs_error_Quit:\n            *perror_object = osp[-1];\n            *pexit_code = code = osp->value.intval;\n            osp -= 2;\n            return\n                (code == 0 ? gs_error_Quit :\n                 code < 0 && code > -100 ? code : gs_error_Fatal);\n        case gs_error_InterpreterExit:\n            return 0;\n        case gs_error_ExecStackUnderflow:\n\/****** WRONG -- must keep mark blocks intact ******\/\n            ref_stack_pop_block(&e_stack);\n            doref = *perror_object;\n            epref = &doref;\n            goto again;\n        case gs_error_VMreclaim:\n            \/* Do the GC and continue. *\/\n            \/* We ignore the return value here, if it fails here\n             * we'll call it again having jumped to the \"again\" label.\n             * Where, assuming it fails again, we'll handle the error.\n             *\/\n            (void)interp_reclaim(pi_ctx_p,\n                                  (osp->value.intval == 2 ?\n                                   avm_global : avm_local));\n            i_ctx_p = *pi_ctx_p;\n            make_oper(&doref, 0, zpop);\n            epref = &doref;\n            goto again;\n        case gs_error_NeedInput:\n        case gs_error_interrupt:\n            return code;\n    }\n    \/* Adjust osp in case of operand stack underflow *\/\n    if (osp < osbot - 1)\n        osp = osbot - 1;\n    \/* We have to handle stack over\/underflow specially, because *\/\n    \/* we might be able to recover by adding or removing a block. *\/\n    switch (code) {\n        case gs_error_dictstackoverflow:\n            \/* We don't have to handle this specially: *\/\n            \/* The only places that could generate it *\/\n            \/* use check_dstack, which does a ref_stack_extend, *\/\n            \/* so if` we get this error, it's a real one. *\/\n            if (osp >= ostop) {\n                if ((ccode = ref_stack_extend(&o_stack, 1)) < 0)\n                    return ccode;\n            }\n            \/* Skip system dictionaries for CET 20-02-02 *\/\n            ccode = copy_stack(i_ctx_p, &d_stack, min_dstack_size, &saref);\n            if (ccode < 0)\n                return ccode;\n            ref_stack_pop_to(&d_stack, min_dstack_size);\n            dict_set_top();\n            *++osp = saref;\n            break;\n        case gs_error_dictstackunderflow:\n            if (ref_stack_pop_block(&d_stack) >= 0) {\n                dict_set_top();\n                doref = *perror_object;\n                epref = &doref;\n                goto again;\n            }\n            break;\n        case gs_error_execstackoverflow:\n            \/* We don't have to handle this specially: *\/\n            \/* The only places that could generate it *\/\n            \/* use check_estack, which does a ref_stack_extend, *\/\n            \/* so if we get this error, it's a real one. *\/\n            if (osp >= ostop) {\n                if ((ccode = ref_stack_extend(&o_stack, 1)) < 0)\n                    return ccode;\n            }\n            ccode = copy_stack(i_ctx_p, &e_stack, 0, &saref);\n            if (ccode < 0)\n                return ccode;\n            {\n                uint count = ref_stack_count(&e_stack);\n                uint limit = ref_stack_max_count(&e_stack) - ES_HEADROOM;\n\n                if (count > limit) {\n                    \/*\n                     * If there is an e-stack mark within MIN_BLOCK_ESTACK of\n                     * the new top, cut the stack back to remove the mark.\n                     *\/\n                    int skip = count - limit;\n                    int i;\n\n                    for (i = skip; i < skip + MIN_BLOCK_ESTACK; ++i) {\n                        const ref *ep = ref_stack_index(&e_stack, i);\n\n                        if (r_has_type_attrs(ep, t_null, a_executable)) {\n                            skip = i + 1;\n                            break;\n                        }\n                    }\n                    pop_estack(i_ctx_p, skip);\n                }\n            }\n            *++osp = saref;\n            break;\n        case gs_error_stackoverflow:\n            if (ref_stack_extend(&o_stack, o_stack.requested) >= 0) {   \/* We can't just re-execute the object, because *\/\n                \/* it might be a procedure being pushed as a *\/\n                \/* literal.  We check for this case specially. *\/\n                doref = *perror_object;\n                if (r_is_proc(&doref)) {\n                    *++osp = doref;\n                    make_null_proc(&doref);\n                }\n                epref = &doref;\n                goto again;\n            }\n            ccode = copy_stack(i_ctx_p, &o_stack, 0, &saref);\n            if (ccode < 0)\n                return ccode;\n            ref_stack_clear(&o_stack);\n            *++osp = saref;\n            break;\n        case gs_error_stackunderflow:\n            if (ref_stack_pop_block(&o_stack) >= 0) {\n                doref = *perror_object;\n                epref = &doref;\n                goto again;\n            }\n            break;\n    }\n    if (user_errors < 0)\n        return code;\n    if (gs_errorname(i_ctx_p, code, &error_name) < 0)\n        return code;            \/* out-of-range error code! *\/\n\n    \/*  We refer to gserrordict first, which is not accessible to Postcript jobs\n     *  If we're running with SAFERERRORS all the handlers are copied to gserrordict\n     *  so we'll always find the default one. If not SAFERERRORS, only gs specific\n     *  errors are in gserrordict.\n     *\/\n    if (dict_find_string(systemdict, \"gserrordict\", &perrordict) <= 0 ||\n        (dict_find(perrordict, &error_name, &epref) <= 0 &&\n         (dict_find_string(systemdict, \"errordict\", &perrordict) <= 0 ||\n          dict_find(perrordict, &error_name, &epref) <= 0))\n        )\n        return code;            \/* error name not in errordict??? *\/\n\n    doref = *epref;\n     epref = &doref;\n     \/* Push the error object on the operand stack if appropriate. *\/\n     if (!GS_ERROR_IS_INTERRUPT(code)) {\n         \/* Replace the error object if within an oparray or .errorexec. *\/\n         osp++;\n         if (osp >= ostop) {\n        }\n        *osp = *perror_object;\n         }\n         *osp = *perror_object;\n         errorexec_find(i_ctx_p, osp);\n        \/* If using SAFER, hand a name object to the error handler, rather than the executable\n         * object\/operator itself.\n         *\/\n        if (i_ctx_p->LockFilePermissions) {\n             code = obj_cvs(imemory, osp, buf + 2, 256, &rlen, (const byte **)&bufptr);\n             if (code < 0) {\n                 const char *unknownstr = \"--unknown--\";\n                 rlen = strlen(unknownstr);\n                 memcpy(buf, unknownstr, rlen);\n             }\n             else {\n                buf[0] = buf[1] = buf[rlen + 2] = buf[rlen + 3] = '-';\n                rlen += 4;\n             }\n            code = name_ref(imemory, buf, rlen, osp, 1);\n            if (code < 0)\n                make_null(osp);\n         }\n     }\n","target":1,"code_token_length":2155,"total_token_length":2391,"max_tokens_setting":4096}
+{"idx":411871,"func":"__zzip_parse_root_directory(int fd,\n                            struct _disk_trailer *trailer,\n                            struct zzip_dir_hdr **hdr_return,\n                            zzip_plugin_io_t io)\n{\n    auto struct zzip_disk_entry dirent;\n    struct zzip_dir_hdr *hdr;\n    struct zzip_dir_hdr *hdr0;\n    uint16_t *p_reclen = 0;\n    zzip_off64_t entries;\n    zzip_off64_t zz_offset;     \/* offset from start of root directory *\/\n    char *fd_map = 0;\n    zzip_off64_t zz_fd_gap = 0;\n    zzip_off64_t zz_entries = _disk_trailer_localentries(trailer);\n    zzip_off64_t zz_rootsize = _disk_trailer_rootsize(trailer);\n    zzip_off64_t zz_rootseek = _disk_trailer_rootseek(trailer);\n    __correct_rootseek(zz_rootseek, zz_rootsize, trailer);\n\n    if (zz_entries < 0 || zz_rootseek < 0 || zz_rootsize < 0)\n        return ZZIP_CORRUPTED;\n\n    hdr0 = (struct zzip_dir_hdr *) malloc(zz_rootsize);\n    if (! hdr0)\n        return ZZIP_DIRSIZE;\n    hdr = hdr0;\n    __debug_dir_hdr(hdr);\n\n    if (USE_MMAP && io->fd.sys)\n    {\n        zz_fd_gap = zz_rootseek & (_zzip_getpagesize(io->fd.sys) - 1);\n        HINT4(\" fd_gap=%ld, mapseek=0x%lx, maplen=%ld\", (long) (zz_fd_gap),\n              (long) (zz_rootseek - zz_fd_gap),\n              (long) (zz_rootsize + zz_fd_gap));\n        fd_map =\n            _zzip_mmap(io->fd.sys, fd, zz_rootseek - zz_fd_gap,\n                       zz_rootsize + zz_fd_gap);\n        \/* if mmap failed we will fallback to seek\/read mode *\/\n        if (fd_map == MAP_FAILED)\n        {\n            NOTE2(\"map failed: %s\", strerror(errno));\n            fd_map = 0;\n        } else\n        {\n            HINT3(\"mapped *%p len=%li\", fd_map,\n                  (long) (zz_rootsize + zz_fd_gap));\n        }\n    }\n\n    for (entries=0, zz_offset=0; ; entries++)\n    {\n        register struct zzip_disk_entry *d;\n        uint16_t u_extras, u_comment, u_namlen;\n\n#     ifndef ZZIP_ALLOW_MODULO_ENTRIES\n        if (entries >= zz_entries) {\n            if (zz_offset + 256 < zz_rootsize) {\n                FAIL4(\"%li's entry is long before the end of directory - enable modulo_entries? (O:%li R:%li)\",\n                      (long) entries, (long) (zz_offset), (long) zz_rootsize);\n            }\n            break;\n        }\n#     endif\n\n        if (fd_map)\n        {\n            d = (void*)(fd_map+zz_fd_gap+zz_offset); \/* fd_map+fd_gap==u_rootseek *\/\n        } else\n        {\n            if (io->fd.seeks(fd, zz_rootseek + zz_offset, SEEK_SET) < 0)\n                return ZZIP_DIR_SEEK;\n            if (io->fd.read(fd, &dirent, sizeof(dirent)) < __sizeof(dirent))\n                return ZZIP_DIR_READ;\n            d = &dirent;\n        }\n\n        if ((zzip_off64_t) (zz_offset + sizeof(*d)) > zz_rootsize ||\n            (zzip_off64_t) (zz_offset + sizeof(*d)) < 0)\n        {\n            FAIL4(\"%li's entry stretches beyond root directory (O:%li R:%li)\",\n                  (long) entries, (long) (zz_offset), (long) zz_rootsize);\n            break;\n        }\n\n        if (! zzip_disk_entry_check_magic(d)) {\n#        ifndef ZZIP_ALLOW_MODULO_ENTRIES\n            FAIL4(\"%li's entry has no disk_entry magic indicator (O:%li R:%li)\",\n                  (long) entries, (long) (zz_offset), (long) zz_rootsize);\n#        endif\n            break;\n        }\n\n#       if 0 && defined DEBUG\n        zzip_debug_xbuf((unsigned char *) d, sizeof(*d) + 8);\n#       endif\n\n        u_extras = zzip_disk_entry_get_extras(d);\n        u_comment = zzip_disk_entry_get_comment(d);\n        u_namlen = zzip_disk_entry_get_namlen(d);\n        HINT5(\"offset=0x%lx, size %ld, dirent *%p, hdr %p\\n\",\n              (long) (zz_offset + zz_rootseek), (long) zz_rootsize, d, hdr);\n\n        \/* writes over the read buffer, Since the structure where data is\n           copied is smaller than the data in buffer this can be done.\n           It is important that the order of setting the fields is considered\n           when filling the structure, so that some data is not trashed in\n           first structure read.\n           at the end the whole copied list of structures  is copied into\n           newly allocated buffer *\/\n        hdr->d_crc32 = zzip_disk_entry_get_crc32(d);\n        hdr->d_csize = zzip_disk_entry_get_csize(d);\n        hdr->d_usize = zzip_disk_entry_get_usize(d);\n        hdr->d_off = zzip_disk_entry_get_offset(d);\n        hdr->d_compr = zzip_disk_entry_get_compr(d);\n        if (hdr->d_compr > _255)\n            hdr->d_compr = 255;\n\n        if ((zzip_off64_t) (zz_offset + sizeof(*d) + u_namlen) > zz_rootsize ||\n            (zzip_off64_t) (zz_offset + sizeof(*d) + u_namlen) < 0)\n        {\n            FAIL4(\"%li's name stretches beyond root directory (O:%li N:%li)\",\n                  (long) entries, (long) (zz_offset), (long) (u_namlen));\n            break;\n        }\n\n        if (fd_map)\n            {  memcpy(hdr->d_name, fd_map+zz_fd_gap + zz_offset+sizeof(*d), u_namlen); }\n        else\n            { io->fd.read(fd, hdr->d_name, u_namlen); }\n        hdr->d_name[u_namlen] = '\\0';\n        hdr->d_namlen = u_namlen;\n\n        \/* update offset by the total length of this entry -> next entry *\/\n        zz_offset += sizeof(*d) + u_namlen + u_extras + u_comment;\n\n        if (zz_offset > zz_rootsize)\n        {\n            FAIL3(\"%li's entry stretches beyond root directory (O:%li)\",\n                  (long) entries, (long) (zz_offset));\n            entries ++;\n            break;\n        }\n\n        HINT5(\"file %ld { compr=%d crc32=$%x offset=%d\",\n              (long) entries, hdr->d_compr, hdr->d_crc32, hdr->d_off);\n        HINT5(\"csize=%d usize=%d namlen=%d extras=%d\",\n              hdr->d_csize, hdr->d_usize, u_namlen, u_extras);\n        HINT5(\"comment=%d name='%s' %s  } \",\n              u_comment, hdr->d_name, \"\", (int) sizeof(*d));\n\n        p_reclen = &hdr->d_reclen;\n\n        {\n            register char *p = (char *) hdr;\n            register char *q = aligned4(p + sizeof(*hdr) + u_namlen + 1);\n            *p_reclen = (uint16_t) (q - p);\n            hdr = (struct zzip_dir_hdr *) q;\n        }\n    }                           \/*for *\/\n\n    if (USE_MMAP && fd_map)\n    {\n        HINT3(\"unmap *%p len=%li\", fd_map, (long) (zz_rootsize + zz_fd_gap));\n        _zzip_munmap(io->fd.sys, fd_map, zz_rootsize + zz_fd_gap);\n    }\n\n    if (p_reclen)\n    {\n        *p_reclen = 0;          \/* mark end of list *\/\n\n        if (hdr_return)\n            *hdr_return = hdr0;\n    }                           \/* else zero (sane) entries *\/\n#  ifndef ZZIP_ALLOW_MODULO_ENTRIES\n    return (entries != zz_entries ? ZZIP_CORRUPTED : 0);\n#  else\n    return ((entries & (unsigned)0xFFFF) != zz_entries ? ZZIP_CORRUPTED : 0);\n#  endif\n}","target":0,"code_token_length":1887,"total_token_length":2123,"max_tokens_setting":4096}
+{"idx":339629,"func":"static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y,\n\n                                     int mvn, int r_x, int r_y, uint8_t* is_intra, int dir)\n\n{\n\n    MpegEncContext *s = &v->s;\n\n    int xy, wrap, off = 0;\n\n    int A[2], B[2], C[2];\n\n    int px = 0, py = 0;\n\n    int a_valid = 0, b_valid = 0, c_valid = 0;\n\n    int field_a, field_b, field_c; \/\/ 0: same, 1: opposit\n\n    int total_valid, num_samefield, num_oppfield;\n\n    int pos_c, pos_b, n_adj;\n\n\n\n    wrap = s->b8_stride;\n\n    xy = s->block_index[n];\n\n\n\n    if (s->mb_intra) {\n\n        s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0;\n\n        s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0;\n\n        s->current_picture.motion_val[1][xy][0] = 0;\n\n        s->current_picture.motion_val[1][xy][1] = 0;\n\n        if (mvn == 1) { \/* duplicate motion data for 1-MV block *\/\n\n            s->current_picture.motion_val[0][xy + 1][0]        = 0;\n\n            s->current_picture.motion_val[0][xy + 1][1]        = 0;\n\n            s->current_picture.motion_val[0][xy + wrap][0]     = 0;\n\n            s->current_picture.motion_val[0][xy + wrap][1]     = 0;\n\n            s->current_picture.motion_val[0][xy + wrap + 1][0] = 0;\n\n            s->current_picture.motion_val[0][xy + wrap + 1][1] = 0;\n\n            v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;\n\n            s->current_picture.motion_val[1][xy + 1][0]        = 0;\n\n            s->current_picture.motion_val[1][xy + 1][1]        = 0;\n\n            s->current_picture.motion_val[1][xy + wrap][0]     = 0;\n\n            s->current_picture.motion_val[1][xy + wrap][1]     = 0;\n\n            s->current_picture.motion_val[1][xy + wrap + 1][0] = 0;\n\n            s->current_picture.motion_val[1][xy + wrap + 1][1] = 0;\n\n        }\n\n        return;\n\n    }\n\n\n\n    off = ((n == 0) || (n == 1)) ? 1 : -1;\n\n    \/* predict A *\/\n\n    if (s->mb_x || (n == 1) || (n == 3)) {\n\n        if ((v->blk_mv_type[xy]) \/\/ current block (MB) has a field MV\n\n            || (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { \/\/ or both have frame MV\n\n            A[0] = s->current_picture.motion_val[dir][xy - 1][0];\n\n            A[1] = s->current_picture.motion_val[dir][xy - 1][1];\n\n            a_valid = 1;\n\n        } else { \/\/ current block has frame mv and cand. has field MV (so average)\n\n            A[0] = (s->current_picture.motion_val[dir][xy - 1][0]\n\n                    + s->current_picture.motion_val[dir][xy - 1 + off * wrap][0] + 1) >> 1;\n\n            A[1] = (s->current_picture.motion_val[dir][xy - 1][1]\n\n                    + s->current_picture.motion_val[dir][xy - 1 + off * wrap][1] + 1) >> 1;\n\n            a_valid = 1;\n\n        }\n\n        if (!(n & 1) && v->is_intra[s->mb_x - 1]) {\n\n            a_valid = 0;\n\n            A[0] = A[1] = 0;\n\n        }\n\n    } else\n\n        A[0] = A[1] = 0;\n\n    \/* Predict B and C *\/\n\n    B[0] = B[1] = C[0] = C[1] = 0;\n\n    if (n == 0 || n == 1 || v->blk_mv_type[xy]) {\n\n        if (!s->first_slice_line) {\n\n            if (!v->is_intra[s->mb_x - s->mb_stride]) {\n\n                b_valid = 1;\n\n                n_adj   = n | 2;\n\n                pos_b   = s->block_index[n_adj] - 2 * wrap;\n\n                if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) {\n\n                    n_adj = (n & 2) | (n & 1);\n\n                }\n\n                B[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][0];\n\n                B[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][1];\n\n                if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) {\n\n                    B[0] = (B[0] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1;\n\n                    B[1] = (B[1] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1;\n\n                }\n\n            }\n\n            if (s->mb_width > 1) {\n\n                if (!v->is_intra[s->mb_x - s->mb_stride + 1]) {\n\n                    c_valid = 1;\n\n                    n_adj   = 2;\n\n                    pos_c   = s->block_index[2] - 2 * wrap + 2;\n\n                    if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {\n\n                        n_adj = n & 2;\n\n                    }\n\n                    C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][0];\n\n                    C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][1];\n\n                    if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {\n\n                        C[0] = (1 + C[0] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1;\n\n                        C[1] = (1 + C[1] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1;\n\n                    }\n\n                    if (s->mb_x == s->mb_width - 1) {\n\n                        if (!v->is_intra[s->mb_x - s->mb_stride - 1]) {\n\n                            c_valid = 1;\n\n                            n_adj   = 3;\n\n                            pos_c   = s->block_index[3] - 2 * wrap - 2;\n\n                            if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {\n\n                                n_adj = n | 1;\n\n                            }\n\n                            C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][0];\n\n                            C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][1];\n\n                            if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {\n\n                                C[0] = (1 + C[0] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][0]) >> 1;\n\n                                C[1] = (1 + C[1] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][1]) >> 1;\n\n                            }\n\n                        } else\n\n                            c_valid = 0;\n\n                    }\n\n                }\n\n            }\n\n        }\n\n    } else {\n\n        pos_b   = s->block_index[1];\n\n        b_valid = 1;\n\n        B[0]    = s->current_picture.motion_val[dir][pos_b][0];\n\n        B[1]    = s->current_picture.motion_val[dir][pos_b][1];\n\n        pos_c   = s->block_index[0];\n\n        c_valid = 1;\n\n        C[0]    = s->current_picture.motion_val[dir][pos_c][0];\n\n        C[1]    = s->current_picture.motion_val[dir][pos_c][1];\n\n    }\n\n\n\n    total_valid = a_valid + b_valid + c_valid;\n\n    \/\/ check if predictor A is out of bounds\n\n    if (!s->mb_x && !(n == 1 || n == 3)) {\n\n        A[0] = A[1] = 0;\n\n    }\n\n    \/\/ check if predictor B is out of bounds\n\n    if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) {\n\n        B[0] = B[1] = C[0] = C[1] = 0;\n\n    }\n\n    if (!v->blk_mv_type[xy]) {\n\n        if (s->mb_width == 1) {\n\n            px = B[0];\n\n            py = B[1];\n\n        } else {\n\n            if (total_valid >= 2) {\n\n                px = mid_pred(A[0], B[0], C[0]);\n\n                py = mid_pred(A[1], B[1], C[1]);\n\n            } else if (total_valid) {\n\n                if      (a_valid) { px = A[0]; py = A[1]; }\n\n                else if (b_valid) { px = B[0]; py = B[1]; }\n\n                else if (c_valid) { px = C[0]; py = C[1]; }\n\n                else av_assert2(0);\n\n            }\n\n        }\n\n    } else {\n\n        if (a_valid)\n\n            field_a = (A[1] & 4) ? 1 : 0;\n\n        else\n\n            field_a = 0;\n\n        if (b_valid)\n\n            field_b = (B[1] & 4) ? 1 : 0;\n\n        else\n\n            field_b = 0;\n\n        if (c_valid)\n\n            field_c = (C[1] & 4) ? 1 : 0;\n\n        else\n\n            field_c = 0;\n\n\n\n        num_oppfield  = field_a + field_b + field_c;\n\n        num_samefield = total_valid - num_oppfield;\n\n        if (total_valid == 3) {\n\n            if ((num_samefield == 3) || (num_oppfield == 3)) {\n\n                px = mid_pred(A[0], B[0], C[0]);\n\n                py = mid_pred(A[1], B[1], C[1]);\n\n            } else if (num_samefield >= num_oppfield) {\n\n                \/* take one MV from same field set depending on priority\n\n                the check for B may not be necessary *\/\n\n                px = !field_a ? A[0] : B[0];\n\n                py = !field_a ? A[1] : B[1];\n\n            } else {\n\n                px =  field_a ? A[0] : B[0];\n\n                py =  field_a ? A[1] : B[1];\n\n            }\n\n        } else if (total_valid == 2) {\n\n            if (num_samefield >= num_oppfield) {\n\n                if (!field_a && a_valid) {\n\n                    px = A[0];\n\n                    py = A[1];\n\n                } else if (!field_b && b_valid) {\n\n                    px = B[0];\n\n                    py = B[1];\n\n                } else if (c_valid) {\n\n                    px = C[0];\n\n                    py = C[1];\n\n                } else px = py = 0;\n\n            } else {\n\n                if (field_a && a_valid) {\n\n                    px = A[0];\n\n                    py = A[1];\n\n                } else if (field_b && b_valid) {\n\n                    px = B[0];\n\n                    py = B[1];\n\n                } else if (c_valid) {\n\n                    px = C[0];\n\n                    py = C[1];\n\n                }\n\n            }\n\n        } else if (total_valid == 1) {\n\n            px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);\n\n            py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);\n\n        }\n\n    }\n\n\n\n    \/* store MV using signed modulus of MV range defined in 4.11 *\/\n\n    s->mv[dir][n][0] = s->current_picture.motion_val[dir][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;\n\n    s->mv[dir][n][1] = s->current_picture.motion_val[dir][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;\n\n    if (mvn == 1) { \/* duplicate motion data for 1-MV block *\/\n\n        s->current_picture.motion_val[dir][xy +    1    ][0] = s->current_picture.motion_val[dir][xy][0];\n\n        s->current_picture.motion_val[dir][xy +    1    ][1] = s->current_picture.motion_val[dir][xy][1];\n\n        s->current_picture.motion_val[dir][xy + wrap    ][0] = s->current_picture.motion_val[dir][xy][0];\n\n        s->current_picture.motion_val[dir][xy + wrap    ][1] = s->current_picture.motion_val[dir][xy][1];\n\n        s->current_picture.motion_val[dir][xy + wrap + 1][0] = s->current_picture.motion_val[dir][xy][0];\n\n        s->current_picture.motion_val[dir][xy + wrap + 1][1] = s->current_picture.motion_val[dir][xy][1];\n\n    } else if (mvn == 2) { \/* duplicate motion data for 2-Field MV block *\/\n\n        s->current_picture.motion_val[dir][xy + 1][0] = s->current_picture.motion_val[dir][xy][0];\n\n        s->current_picture.motion_val[dir][xy + 1][1] = s->current_picture.motion_val[dir][xy][1];\n\n        s->mv[dir][n + 1][0] = s->mv[dir][n][0];\n\n        s->mv[dir][n + 1][1] = s->mv[dir][n][1];\n\n    }\n\n}\n","target":0,"code_token_length":3334,"total_token_length":3570,"max_tokens_setting":4096}
+{"idx":150211,"func":"    template\n    CImg _permute_axes(const char *const order, const t&) const {\n      if (is_empty() || !order) return CImg(*this,false);\n      CImg res;\n      const T* ptrs = _data;\n      unsigned char s_code[4] = { 0,1,2,3 }, n_code[4] = { 0 };\n      for (unsigned int l = 0; order[l]; ++l) {\n        int c = cimg::lowercase(order[l]);\n        if (c!='x' && c!='y' && c!='z' && c!='c') { *s_code = 4; break; }\n        else { ++n_code[c%=4]; s_code[l] = c; }\n      }\n      if (*order && *s_code<4 && *n_code<=1 && n_code[1]<=1 && n_code[2]<=1 && n_code[3]<=1) {\n        const unsigned int code = (s_code[0]<<12) | (s_code[1]<<8) | (s_code[2]<<4) | (s_code[3]);\n        ulongT wh, whd;\n        switch (code) {\n        case 0x0123 : \/\/ xyzc\n          return +*this;\n        case 0x0132 : \/\/ xycz\n          res.assign(_width,_height,_spectrum,_depth);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(x,y,c,z,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x0213 : \/\/ xzyc\n          res.assign(_width,_depth,_height,_spectrum);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(x,z,y,c,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x0231 : \/\/ xzcy\n          res.assign(_width,_depth,_spectrum,_height);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(x,z,c,y,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x0312 : \/\/ xcyz\n          res.assign(_width,_spectrum,_height,_depth);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(x,c,y,z,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x0321 : \/\/ xczy\n          res.assign(_width,_spectrum,_depth,_height);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(x,c,z,y,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x1023 : \/\/ yxzc\n          res.assign(_height,_width,_depth,_spectrum);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(y,x,z,c,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x1032 : \/\/ yxcz\n          res.assign(_height,_width,_spectrum,_depth);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(y,x,c,z,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x1203 : \/\/ yzxc\n          res.assign(_height,_depth,_width,_spectrum);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(y,z,x,c,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x1230 : \/\/ yzcx\n          res.assign(_height,_depth,_spectrum,_width);\n          switch (_width) {\n          case 1 : {\n            t *ptr_r = res.data(0,0,0,0);\n            for (unsigned int siz = _height*_depth*_spectrum; siz; --siz) {\n              *(ptr_r++) = (t)*(ptrs++);\n            }\n          } break;\n          case 2 : {\n            t *ptr_r = res.data(0,0,0,0), *ptr_g = res.data(0,0,0,1);\n            for (unsigned int siz = _height*_depth*_spectrum; siz; --siz) {\n              *(ptr_r++) = (t)ptrs[0];\n              *(ptr_g++) = (t)ptrs[1];\n              ptrs+=2;\n            }\n          } break;\n          case 3 : { \/\/ Optimization for the classical conversion from interleaved RGB to planar RGB\n            t *ptr_r = res.data(0,0,0,0), *ptr_g = res.data(0,0,0,1), *ptr_b = res.data(0,0,0,2);\n            for (unsigned int siz = _height*_depth*_spectrum; siz; --siz) {\n              *(ptr_r++) = (t)ptrs[0];\n              *(ptr_g++) = (t)ptrs[1];\n              *(ptr_b++) = (t)ptrs[2];\n              ptrs+=3;\n            }\n          } break;\n          case 4 : { \/\/ Optimization for the classical conversion from interleaved RGBA to planar RGBA\n            t\n              *ptr_r = res.data(0,0,0,0), *ptr_g = res.data(0,0,0,1),\n              *ptr_b = res.data(0,0,0,2), *ptr_a = res.data(0,0,0,3);\n            for (unsigned int siz = _height*_depth*_spectrum; siz; --siz) {\n              *(ptr_r++) = (t)ptrs[0];\n              *(ptr_g++) = (t)ptrs[1];\n              *(ptr_b++) = (t)ptrs[2];\n              *(ptr_a++) = (t)ptrs[3];\n              ptrs+=4;\n            }\n          } break;\n          default : {\n            wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n            cimg_forXYZC(*this,x,y,z,c) res(y,z,c,x,wh,whd) = *(ptrs++);\n            return res;\n          }\n          }\n          break;\n        case 0x1302 : \/\/ ycxz\n          res.assign(_height,_spectrum,_width,_depth);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(y,c,x,z,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x1320 : \/\/ yczx\n          res.assign(_height,_spectrum,_depth,_width);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(y,c,z,x,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x2013 : \/\/ zxyc\n          res.assign(_depth,_width,_height,_spectrum);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(z,x,y,c,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x2031 : \/\/ zxcy\n          res.assign(_depth,_width,_spectrum,_height);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(z,x,c,y,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x2103 : \/\/ zyxc\n          res.assign(_depth,_height,_width,_spectrum);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(z,y,x,c,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x2130 : \/\/ zycx\n          res.assign(_depth,_height,_spectrum,_width);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(z,y,c,x,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x2301 : \/\/ zcxy\n          res.assign(_depth,_spectrum,_width,_height);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(z,c,x,y,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x2310 : \/\/ zcyx\n          res.assign(_depth,_spectrum,_height,_width);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(z,c,y,x,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x3012 : \/\/ cxyz\n          res.assign(_spectrum,_width,_height,_depth);\n          switch (_spectrum) {\n          case 1 : {\n            const T *ptr_r = data(0,0,0,0);\n            t *ptrd = res._data;\n            for (ulongT siz = (ulongT)_width*_height*_depth; siz; --siz) *(ptrd++) = (t)*(ptr_r++);\n          } break;\n          case 2 : {\n            const T *ptr_r = data(0,0,0,0), *ptr_g = data(0,0,0,1);\n            t *ptrd = res._data;\n            for (ulongT siz = (ulongT)_width*_height*_depth; siz; --siz) {\n              ptrd[0] = (t)*(ptr_r++);\n              ptrd[1] = (t)*(ptr_g++);\n              ptrd+=2;\n            }\n          } break;\n          case 3 : { \/\/ Optimization for the classical conversion from planar RGB to interleaved RGB\n            const T *ptr_r = data(0,0,0,0), *ptr_g = data(0,0,0,1), *ptr_b = data(0,0,0,2);\n            t *ptrd = res._data;\n            for (ulongT siz = (ulongT)_width*_height*_depth; siz; --siz) {\n              ptrd[0] = (t)*(ptr_r++);\n              ptrd[1] = (t)*(ptr_g++);\n              ptrd[2] = (t)*(ptr_b++);\n              ptrd+=3;\n            }\n          } break;\n          case 4 : { \/\/ Optimization for the classical conversion from planar RGBA to interleaved RGBA\n            const T *ptr_r = data(0,0,0,0), *ptr_g = data(0,0,0,1), *ptr_b = data(0,0,0,2), *ptr_a = data(0,0,0,3);\n            t *ptrd = res._data;\n            for (ulongT siz = (ulongT)_width*_height*_depth; siz; --siz) {\n              ptrd[0] = (t)*(ptr_r++);\n              ptrd[1] = (t)*(ptr_g++);\n              ptrd[2] = (t)*(ptr_b++);\n              ptrd[3] = (t)*(ptr_a++);\n              ptrd+=4;\n            }\n          } break;\n          default : {\n            wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n            cimg_forXYZC(*this,x,y,z,c) res(c,x,y,z,wh,whd) = (t)*(ptrs++);\n          }\n          }\n          break;\n        case 0x3021 : \/\/ cxzy\n          res.assign(_spectrum,_width,_depth,_height);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(c,x,z,y,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x3102 : \/\/ cyxz\n          res.assign(_spectrum,_height,_width,_depth);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(c,y,x,z,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x3120 : \/\/ cyzx\n          res.assign(_spectrum,_height,_depth,_width);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(c,y,z,x,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x3201 : \/\/ czxy\n          res.assign(_spectrum,_depth,_width,_height);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(c,z,x,y,wh,whd) = (t)*(ptrs++);\n          break;\n        case 0x3210 : \/\/ czyx\n          res.assign(_spectrum,_depth,_height,_width);\n          wh = (ulongT)res._width*res._height; whd = wh*res._depth;\n          cimg_forXYZC(*this,x,y,z,c) res(c,z,y,x,wh,whd) = (t)*(ptrs++);\n          break;\n        }\n      }\n      if (!res)\n        throw CImgArgumentException(_cimg_instance\n                                    \"permute_axes(): Invalid specified permutation '%s'.\",\n                                    cimg_instance,\n                                    order);\n      return res;","target":0,"code_token_length":3320,"total_token_length":3556,"max_tokens_setting":4096}
+{"idx":24754,"func":"static void vc1_mc_4mv_luma ( VC1Context * v , int n , int dir ) {\n MpegEncContext * s = & v -> s ;\n DSPContext * dsp = & v -> s . dsp ;\n uint8_t * srcY ;\n int dxy , mx , my , src_x , src_y ;\n int off ;\n int fieldmv = ( v -> fcm == ILACE_FRAME ) ? v -> blk_mv_type [ s -> block_index [ n ] ] : 0 ;\n int v_edge_pos = s -> v_edge_pos >> v -> field_mode ;\n if ( ( ! v -> field_mode || ( v -> ref_field_type [ dir ] == 1 && v -> cur_field_type == 1 ) ) && ! v -> s . last_picture . f . data [ 0 ] ) return ;\n mx = s -> mv [ dir ] [ n ] [ 0 ] ;\n my = s -> mv [ dir ] [ n ] [ 1 ] ;\n if ( ! dir ) {\n if ( v -> field_mode ) {\n if ( ( v -> cur_field_type != v -> ref_field_type [ dir ] ) && v -> cur_field_type ) srcY = s -> current_picture . f . data [ 0 ] ;\n else srcY = s -> last_picture . f . data [ 0 ] ;\n }\n else srcY = s -> last_picture . f . data [ 0 ] ;\n }\n else srcY = s -> next_picture . f . data [ 0 ] ;\n if ( v -> field_mode ) {\n if ( v -> cur_field_type != v -> ref_field_type [ dir ] ) my = my - 2 + 4 * v -> cur_field_type ;\n }\n if ( s -> pict_type == AV_PICTURE_TYPE_P && n == 3 && v -> field_mode ) {\n int same_count = 0 , opp_count = 0 , k ;\n int chosen_mv [ 2 ] [ 4 ] [ 2 ] , f ;\n int tx , ty ;\n for ( k = 0 ;\n k < 4 ;\n k ++ ) {\n f = v -> mv_f [ 0 ] [ s -> block_index [ k ] + v -> blocks_off ] ;\n chosen_mv [ f ] [ f ? opp_count : same_count ] [ 0 ] = s -> mv [ 0 ] [ k ] [ 0 ] ;\n chosen_mv [ f ] [ f ? opp_count : same_count ] [ 1 ] = s -> mv [ 0 ] [ k ] [ 1 ] ;\n opp_count += f ;\n same_count += 1 - f ;\n }\n f = opp_count > same_count ;\n switch ( f ? opp_count : same_count ) {\n case 4 : tx = median4 ( chosen_mv [ f ] [ 0 ] [ 0 ] , chosen_mv [ f ] [ 1 ] [ 0 ] , chosen_mv [ f ] [ 2 ] [ 0 ] , chosen_mv [ f ] [ 3 ] [ 0 ] ) ;\n ty = median4 ( chosen_mv [ f ] [ 0 ] [ 1 ] , chosen_mv [ f ] [ 1 ] [ 1 ] , chosen_mv [ f ] [ 2 ] [ 1 ] , chosen_mv [ f ] [ 3 ] [ 1 ] ) ;\n break ;\n case 3 : tx = mid_pred ( chosen_mv [ f ] [ 0 ] [ 0 ] , chosen_mv [ f ] [ 1 ] [ 0 ] , chosen_mv [ f ] [ 2 ] [ 0 ] ) ;\n ty = mid_pred ( chosen_mv [ f ] [ 0 ] [ 1 ] , chosen_mv [ f ] [ 1 ] [ 1 ] , chosen_mv [ f ] [ 2 ] [ 1 ] ) ;\n break ;\n case 2 : tx = ( chosen_mv [ f ] [ 0 ] [ 0 ] + chosen_mv [ f ] [ 1 ] [ 0 ] ) \/ 2 ;\n ty = ( chosen_mv [ f ] [ 0 ] [ 1 ] + chosen_mv [ f ] [ 1 ] [ 1 ] ) \/ 2 ;\n break ;\n }\n s -> current_picture . motion_val [ 1 ] [ s -> block_index [ 0 ] + v -> blocks_off ] [ 0 ] = tx ;\n s -> current_picture . motion_val [ 1 ] [ s -> block_index [ 0 ] + v -> blocks_off ] [ 1 ] = ty ;\n for ( k = 0 ;\n k < 4 ;\n k ++ ) v -> mv_f [ 1 ] [ s -> block_index [ k ] + v -> blocks_off ] = f ;\n }\n if ( v -> fcm == ILACE_FRAME ) {\n int qx , qy ;\n int width = s -> avctx -> coded_width ;\n int height = s -> avctx -> coded_height >> 1 ;\n qx = ( s -> mb_x * 16 ) + ( mx >> 2 ) ;\n qy = ( s -> mb_y * 8 ) + ( my >> 3 ) ;\n if ( qx < - 17 ) mx -= 4 * ( qx + 17 ) ;\n else if ( qx > width ) mx -= 4 * ( qx - width ) ;\n if ( qy < - 18 ) my -= 8 * ( qy + 18 ) ;\n else if ( qy > height + 1 ) my -= 8 * ( qy - height - 1 ) ;\n }\n if ( ( v -> fcm == ILACE_FRAME ) && fieldmv ) off = ( ( n > 1 ) ? s -> linesize : 0 ) + ( n & 1 ) * 8 ;\n else off = s -> linesize * 4 * ( n & 2 ) + ( n & 1 ) * 8 ;\n if ( v -> field_mode && v -> cur_field_type ) off += s -> current_picture_ptr -> f . linesize [ 0 ] ;\n src_x = s -> mb_x * 16 + ( n & 1 ) * 8 + ( mx >> 2 ) ;\n if ( ! fieldmv ) src_y = s -> mb_y * 16 + ( n & 2 ) * 4 + ( my >> 2 ) ;\n else src_y = s -> mb_y * 16 + ( ( n > 1 ) ? 1 : 0 ) + ( my >> 2 ) ;\n if ( v -> profile != PROFILE_ADVANCED ) {\n src_x = av_clip ( src_x , - 16 , s -> mb_width * 16 ) ;\n src_y = av_clip ( src_y , - 16 , s -> mb_height * 16 ) ;\n }\n else {\n src_x = av_clip ( src_x , - 17 , s -> avctx -> coded_width ) ;\n if ( v -> fcm == ILACE_FRAME ) {\n if ( src_y & 1 ) src_y = av_clip ( src_y , - 17 , s -> avctx -> coded_height + 1 ) ;\n else src_y = av_clip ( src_y , - 18 , s -> avctx -> coded_height ) ;\n }\n else {\n src_y = av_clip ( src_y , - 18 , s -> avctx -> coded_height + 1 ) ;\n }\n }\n srcY += src_y * s -> linesize + src_x ;\n if ( v -> field_mode && v -> ref_field_type [ dir ] ) srcY += s -> current_picture_ptr -> f . linesize [ 0 ] ;\n if ( fieldmv && ! ( src_y & 1 ) ) v_edge_pos -- ;\n if ( fieldmv && ( src_y & 1 ) && src_y < 4 ) src_y -- ;\n if ( v -> rangeredfrm || ( v -> mv_mode == MV_PMODE_INTENSITY_COMP ) || s -> h_edge_pos < 13 || v_edge_pos < 23 || ( unsigned ) ( src_x - s -> mspel ) > s -> h_edge_pos - ( mx & 3 ) - 8 - s -> mspel * 2 || ( unsigned ) ( src_y - ( s -> mspel << fieldmv ) ) > v_edge_pos - ( my & 3 ) - ( ( 8 + s -> mspel * 2 ) << fieldmv ) ) {\n srcY -= s -> mspel * ( 1 + ( s -> linesize << fieldmv ) ) ;\n s -> vdsp . emulated_edge_mc ( s -> edge_emu_buffer , srcY , s -> linesize , 9 + s -> mspel * 2 , ( 9 + s -> mspel * 2 ) << fieldmv , src_x - s -> mspel , src_y - ( s -> mspel << fieldmv ) , s -> h_edge_pos , v_edge_pos ) ;\n srcY = s -> edge_emu_buffer ;\n if ( v -> rangeredfrm ) {\n int i , j ;\n uint8_t * src ;\n src = srcY ;\n for ( j = 0 ;\n j < 9 + s -> mspel * 2 ;\n j ++ ) {\n for ( i = 0 ;\n i < 9 + s -> mspel * 2 ;\n i ++ ) src [ i ] = ( ( src [ i ] - 128 ) >> 1 ) + 128 ;\n src += s -> linesize << fieldmv ;\n }\n }\n if ( v -> mv_mode == MV_PMODE_INTENSITY_COMP ) {\n int i , j ;\n uint8_t * src ;\n src = srcY ;\n for ( j = 0 ;\n j < 9 + s -> mspel * 2 ;\n j ++ ) {\n for ( i = 0 ;\n i < 9 + s -> mspel * 2 ;\n i ++ ) src [ i ] = v -> luty [ src [ i ] ] ;\n src += s -> linesize << fieldmv ;\n }\n }\n srcY += s -> mspel * ( 1 + ( s -> linesize << fieldmv ) ) ;\n }\n if ( s -> mspel ) {\n dxy = ( ( my & 3 ) << 2 ) | ( mx & 3 ) ;\n v -> vc1dsp . put_vc1_mspel_pixels_tab [ dxy ] ( s -> dest [ 0 ] + off , srcY , s -> linesize << fieldmv , v -> rnd ) ;\n }\n else {\n dxy = ( my & 2 ) | ( ( mx & 2 ) >> 1 ) ;\n if ( ! v -> rnd ) dsp -> put_pixels_tab [ 1 ] [ dxy ] ( s -> dest [ 0 ] + off , srcY , s -> linesize , 8 ) ;\n else dsp -> put_no_rnd_pixels_tab [ 1 ] [ dxy ] ( s -> dest [ 0 ] + off , srcY , s -> linesize , 8 ) ;\n }\n }","target":0,"code_token_length":2308,"total_token_length":2544,"max_tokens_setting":4096}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..3f695bcc441f206e33003a5801a5f3002c4884dd
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:84f7f81554641a1e6697e5dca08bd71c7f8e4876bc6929d85e23b8449504d1b5
+size 1609060
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..70d12c8ced9e11d2e3c689fe814a90377aabc0ed
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.jsonl
@@ -0,0 +1,45 @@
+{"idx":157271,"func":"mono_image_create_pefile (MonoReflectionModuleBuilder *mb, HANDLE file)\n{\n\tMonoMSDOSHeader *msdos;\n\tMonoDotNetHeader *header;\n\tMonoSectionTable *section;\n\tMonoCLIHeader *cli_header;\n\tguint32 size, image_size, virtual_base, text_offset;\n\tguint32 header_start, section_start, file_offset, virtual_offset;\n\tMonoDynamicImage *assembly;\n\tMonoReflectionAssemblyBuilder *assemblyb;\n\tMonoDynamicStream pefile_stream = {0};\n\tMonoDynamicStream *pefile = &pefile_stream;\n\tint i, nsections;\n\tguint32 *rva, value;\n\tguchar *p;\n\tstatic const unsigned char msheader[] = {\n\t\t0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00,  0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,\n\t\t0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,\n\t\t0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd,  0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68,\n\t\t0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72,  0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f,\n\t\t0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e,  0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20,\n\t\t0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a,  0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n\t};\n\n\tassemblyb = mb->assemblyb;\n\n\tmono_image_basic_init (assemblyb);\n\tassembly = mb->dynamic_image;\n\n\tassembly->pe_kind = assemblyb->pe_kind;\n\tassembly->machine = assemblyb->machine;\n\t((MonoDynamicImage*)assemblyb->dynamic_assembly->assembly.image)->pe_kind = assemblyb->pe_kind;\n\t((MonoDynamicImage*)assemblyb->dynamic_assembly->assembly.image)->machine = assemblyb->machine;\n\t\n\tmono_image_build_metadata (mb);\n\n\tif (mb->is_main && assemblyb->resources) {\n\t\tint len = mono_array_length (assemblyb->resources);\n\t\tfor (i = 0; i < len; ++i)\n\t\t\tassembly_add_resource (mb, assembly, (MonoReflectionResource*)mono_array_addr (assemblyb->resources, MonoReflectionResource, i));\n\t}\n\n\tif (mb->resources) {\n\t\tint len = mono_array_length (mb->resources);\n\t\tfor (i = 0; i < len; ++i)\n\t\t\tassembly_add_resource (mb, assembly, (MonoReflectionResource*)mono_array_addr (mb->resources, MonoReflectionResource, i));\n\t}\n\n\tbuild_compressed_metadata (assembly);\n\n\tif (mb->is_main)\n\t\tassembly_add_win32_resources (assembly, assemblyb);\n\n\tnsections = calc_section_size (assembly);\n\t\n\t\/* The DOS header and stub *\/\n\tg_assert (sizeof (MonoMSDOSHeader) == sizeof (msheader));\n\tmono_image_add_stream_data (pefile, (char*)msheader, sizeof (msheader));\n\n\t\/* the dotnet header *\/\n\theader_start = mono_image_add_stream_zero (pefile, sizeof (MonoDotNetHeader));\n\n\t\/* the section tables *\/\n\tsection_start = mono_image_add_stream_zero (pefile, sizeof (MonoSectionTable) * nsections);\n\n\tfile_offset = section_start + sizeof (MonoSectionTable) * nsections;\n\tvirtual_offset = VIRT_ALIGN;\n\timage_size = 0;\n\n\tfor (i = 0; i < MONO_SECTION_MAX; ++i) {\n\t\tif (!assembly->sections [i].size)\n\t\t\tcontinue;\n\t\t\/* align offsets *\/\n\t\tfile_offset += FILE_ALIGN - 1;\n\t\tfile_offset &= ~(FILE_ALIGN - 1);\n\t\tvirtual_offset += VIRT_ALIGN - 1;\n\t\tvirtual_offset &= ~(VIRT_ALIGN - 1);\n\n\t\tassembly->sections [i].offset = file_offset;\n\t\tassembly->sections [i].rva = virtual_offset;\n\n\t\tfile_offset += assembly->sections [i].size;\n\t\tvirtual_offset += assembly->sections [i].size;\n\t\timage_size += (assembly->sections [i].size + VIRT_ALIGN - 1) & ~(VIRT_ALIGN - 1);\n\t}\n\n\tfile_offset += FILE_ALIGN - 1;\n\tfile_offset &= ~(FILE_ALIGN - 1);\n\n\timage_size += section_start + sizeof (MonoSectionTable) * nsections;\n\n\t\/* back-patch info *\/\n\tmsdos = (MonoMSDOSHeader*)pefile->data;\n\tmsdos->pe_offset = GUINT32_FROM_LE (sizeof (MonoMSDOSHeader));\n\n\theader = (MonoDotNetHeader*)(pefile->data + header_start);\n\theader->pesig [0] = 'P';\n\theader->pesig [1] = 'E';\n\t\n\theader->coff.coff_machine = GUINT16_FROM_LE (assemblyb->machine);\n\theader->coff.coff_sections = GUINT16_FROM_LE (nsections);\n\theader->coff.coff_time = GUINT32_FROM_LE (time (NULL));\n\theader->coff.coff_opt_header_size = GUINT16_FROM_LE (sizeof (MonoDotNetHeader) - sizeof (MonoCOFFHeader) - 4);\n\tif (assemblyb->pekind == 1) {\n\t\t\/* it's a dll *\/\n\t\theader->coff.coff_attributes = GUINT16_FROM_LE (0x210e);\n\t} else {\n\t\t\/* it's an exe *\/\n\t\theader->coff.coff_attributes = GUINT16_FROM_LE (0x010e);\n\t}\n\n\tvirtual_base = 0x400000; \/* FIXME: 0x10000000 if a DLL *\/\n\n\theader->pe.pe_magic = GUINT16_FROM_LE (0x10B);\n\theader->pe.pe_major = 6;\n\theader->pe.pe_minor = 0;\n\tsize = assembly->sections [MONO_SECTION_TEXT].size;\n\tsize += FILE_ALIGN - 1;\n\tsize &= ~(FILE_ALIGN - 1);\n\theader->pe.pe_code_size = GUINT32_FROM_LE(size);\n\tsize = assembly->sections [MONO_SECTION_RSRC].size;\n\tsize += FILE_ALIGN - 1;\n\tsize &= ~(FILE_ALIGN - 1);\n\theader->pe.pe_data_size = GUINT32_FROM_LE(size);\n\tg_assert (START_TEXT_RVA == assembly->sections [MONO_SECTION_TEXT].rva);\n\theader->pe.pe_rva_code_base = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_TEXT].rva);\n\theader->pe.pe_rva_data_base = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_RSRC].rva);\n\t\/* pe_rva_entry_point always at the beginning of the text section *\/\n\theader->pe.pe_rva_entry_point = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_TEXT].rva);\n\n\theader->nt.pe_image_base = GUINT32_FROM_LE (virtual_base);\n\theader->nt.pe_section_align = GUINT32_FROM_LE (VIRT_ALIGN);\n\theader->nt.pe_file_alignment = GUINT32_FROM_LE (FILE_ALIGN);\n\theader->nt.pe_os_major = GUINT16_FROM_LE (4);\n\theader->nt.pe_os_minor = GUINT16_FROM_LE (0);\n\theader->nt.pe_subsys_major = GUINT16_FROM_LE (4);\n\tsize = section_start;\n\tsize += FILE_ALIGN - 1;\n\tsize &= ~(FILE_ALIGN - 1);\n\theader->nt.pe_header_size = GUINT32_FROM_LE (size);\n\tsize = image_size;\n\tsize += VIRT_ALIGN - 1;\n\tsize &= ~(VIRT_ALIGN - 1);\n\theader->nt.pe_image_size = GUINT32_FROM_LE (size);\n\n\t\/*\n\t\/\/ Translate the PEFileKind value to the value expected by the Windows loader\n\t*\/\n\t{\n\t\tshort kind;\n\n\t\t\/*\n\t\t\/\/ PEFileKinds.Dll == 1\n\t\t\/\/ PEFileKinds.ConsoleApplication == 2\n\t\t\/\/ PEFileKinds.WindowApplication == 3\n\t\t\/\/\n\t\t\/\/ need to get:\n\t\t\/\/     IMAGE_SUBSYSTEM_WINDOWS_GUI 2 \/\/ Image runs in the Windows GUI subsystem.\n                \/\/     IMAGE_SUBSYSTEM_WINDOWS_CUI 3 \/\/ Image runs in the Windows character subsystem.\n\t\t*\/\n\t\tif (assemblyb->pekind == 3)\n\t\t\tkind = 2;\n\t\telse\n\t\t\tkind = 3;\n\t\t\n\t\theader->nt.pe_subsys_required = GUINT16_FROM_LE (kind);\n\t}    \n\theader->nt.pe_stack_reserve = GUINT32_FROM_LE (0x00100000);\n\theader->nt.pe_stack_commit = GUINT32_FROM_LE (0x00001000);\n\theader->nt.pe_heap_reserve = GUINT32_FROM_LE (0x00100000);\n\theader->nt.pe_heap_commit = GUINT32_FROM_LE (0x00001000);\n\theader->nt.pe_loader_flags = GUINT32_FROM_LE (0);\n\theader->nt.pe_data_dir_count = GUINT32_FROM_LE (16);\n\n\t\/* fill data directory entries *\/\n\n\theader->datadir.pe_resource_table.size = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_RSRC].size);\n\theader->datadir.pe_resource_table.rva = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_RSRC].rva);\n\n\theader->datadir.pe_reloc_table.size = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_RELOC].size);\n\theader->datadir.pe_reloc_table.rva = GUINT32_FROM_LE (assembly->sections [MONO_SECTION_RELOC].rva);\n\n\theader->datadir.pe_cli_header.size = GUINT32_FROM_LE (72);\n\theader->datadir.pe_cli_header.rva = GUINT32_FROM_LE (assembly->text_rva + assembly->cli_header_offset);\n\theader->datadir.pe_iat.size = GUINT32_FROM_LE (8);\n\theader->datadir.pe_iat.rva = GUINT32_FROM_LE (assembly->text_rva + assembly->iat_offset);\n\t\/* patch entrypoint name *\/\n\tif (assemblyb->pekind == 1)\n\t\tmemcpy (assembly->code.data + assembly->imp_names_offset + 2, \"_CorDllMain\", 12);\n\telse\n\t\tmemcpy (assembly->code.data + assembly->imp_names_offset + 2, \"_CorExeMain\", 12);\n\t\/* patch imported function RVA name *\/\n\trva = (guint32*)(assembly->code.data + assembly->iat_offset);\n\t*rva = GUINT32_FROM_LE (assembly->text_rva + assembly->imp_names_offset);\n\n\t\/* the import table *\/\n\theader->datadir.pe_import_table.size = GUINT32_FROM_LE (79); \/* FIXME: magic number? *\/\n\theader->datadir.pe_import_table.rva = GUINT32_FROM_LE (assembly->text_rva + assembly->idt_offset);\n\t\/* patch imported dll RVA name and other entries in the dir *\/\n\trva = (guint32*)(assembly->code.data + assembly->idt_offset + G_STRUCT_OFFSET (MonoIDT, name_rva));\n\t*rva = GUINT32_FROM_LE (assembly->text_rva + assembly->imp_names_offset + 14); \/* 14 is hint+strlen+1 of func name *\/\n\trva = (guint32*)(assembly->code.data + assembly->idt_offset + G_STRUCT_OFFSET (MonoIDT, import_address_table_rva));\n\t*rva = GUINT32_FROM_LE (assembly->text_rva + assembly->iat_offset);\n\trva = (guint32*)(assembly->code.data + assembly->idt_offset + G_STRUCT_OFFSET (MonoIDT, import_lookup_table));\n\t*rva = GUINT32_FROM_LE (assembly->text_rva + assembly->ilt_offset);\n\n\tp = (guchar*)(assembly->code.data + assembly->ilt_offset);\n\tvalue = (assembly->text_rva + assembly->imp_names_offset);\n\t*p++ = (value) & 0xff;\n\t*p++ = (value >> 8) & (0xff);\n\t*p++ = (value >> 16) & (0xff);\n\t*p++ = (value >> 24) & (0xff);\n\n\t\/* the CLI header info *\/\n\tcli_header = (MonoCLIHeader*)(assembly->code.data + assembly->cli_header_offset);\n\tcli_header->ch_size = GUINT32_FROM_LE (72);\n\tcli_header->ch_runtime_major = GUINT16_FROM_LE (2);\n\tcli_header->ch_runtime_minor = GUINT16_FROM_LE (5);\n\tcli_header->ch_flags = GUINT32_FROM_LE (assemblyb->pe_kind);\n\tif (assemblyb->entry_point) {\n\t\tguint32 table_idx = 0;\n\t\tif (!strcmp (assemblyb->entry_point->object.vtable->klass->name, \"MethodBuilder\")) {\n\t\t\tMonoReflectionMethodBuilder *methodb = (MonoReflectionMethodBuilder*)assemblyb->entry_point;\n\t\t\ttable_idx = methodb->table_idx;\n\t\t} else {\n\t\t\ttable_idx = GPOINTER_TO_UINT (g_hash_table_lookup (assembly->method_to_table_idx, assemblyb->entry_point->method));\n\t\t}\n\t\tcli_header->ch_entry_point = GUINT32_FROM_LE (table_idx | MONO_TOKEN_METHOD_DEF);\n\t} else {\n\t\tcli_header->ch_entry_point = GUINT32_FROM_LE (0);\n\t}\n\t\/* The embedded managed resources *\/\n\ttext_offset = assembly->text_rva + assembly->code.index;\n\tcli_header->ch_resources.rva = GUINT32_FROM_LE (text_offset);\n\tcli_header->ch_resources.size = GUINT32_FROM_LE (assembly->resources.index);\n\ttext_offset += assembly->resources.index;\n\tcli_header->ch_metadata.rva = GUINT32_FROM_LE (text_offset);\n\tcli_header->ch_metadata.size = GUINT32_FROM_LE (assembly->meta_size);\n\ttext_offset += assembly->meta_size;\n\tif (assembly->strong_name_size) {\n\t\tcli_header->ch_strong_name.rva = GUINT32_FROM_LE (text_offset);\n\t\tcli_header->ch_strong_name.size = GUINT32_FROM_LE (assembly->strong_name_size);\n\t\ttext_offset += assembly->strong_name_size;\n\t}\n\n\t\/* write the section tables and section content *\/\n\tsection = (MonoSectionTable*)(pefile->data + section_start);\n\tfor (i = 0; i < MONO_SECTION_MAX; ++i) {\n\t\tstatic const char section_names [][7] = {\n\t\t\t\".text\", \".rsrc\", \".reloc\"\n\t\t};\n\t\tif (!assembly->sections [i].size)\n\t\t\tcontinue;\n\t\tstrcpy (section->st_name, section_names [i]);\n\t\t\/*g_print (\"output section %s (%d), size: %d\\n\", section->st_name, i, assembly->sections [i].size);*\/\n\t\tsection->st_virtual_address = GUINT32_FROM_LE (assembly->sections [i].rva);\n\t\tsection->st_virtual_size = GUINT32_FROM_LE (assembly->sections [i].size);\n\t\tsection->st_raw_data_size = GUINT32_FROM_LE (GUINT32_TO_LE (section->st_virtual_size) + (FILE_ALIGN - 1));\n\t\tsection->st_raw_data_size &= GUINT32_FROM_LE (~(FILE_ALIGN - 1));\n\t\tsection->st_raw_data_ptr = GUINT32_FROM_LE (assembly->sections [i].offset);\n\t\tsection->st_flags = GUINT32_FROM_LE (assembly->sections [i].attrs);\n\t\tsection ++;\n\t}\n\t\n\tchecked_write_file (file, pefile->data, pefile->index);\n\t\n\tmono_dynamic_stream_reset (pefile);\n\t\n\tfor (i = 0; i < MONO_SECTION_MAX; ++i) {\n\t\tif (!assembly->sections [i].size)\n\t\t\tcontinue;\n\t\t\n\t\tif (SetFilePointer (file, assembly->sections [i].offset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)\n\t\t\tg_error (\"SetFilePointer returned %d\\n\", GetLastError ());\n\t\t\n\t\tswitch (i) {\n\t\tcase MONO_SECTION_TEXT:\n\t\t\t\/* patch entry point *\/\n\t\t\tp = (guchar*)(assembly->code.data + 2);\n\t\t\tvalue = (virtual_base + assembly->text_rva + assembly->iat_offset);\n\t\t\t*p++ = (value) & 0xff;\n\t\t\t*p++ = (value >> 8) & 0xff;\n\t\t\t*p++ = (value >> 16) & 0xff;\n\t\t\t*p++ = (value >> 24) & 0xff;\n\t\t\n\t\t\tchecked_write_file (file, assembly->code.data, assembly->code.index);\n\t\t\tchecked_write_file (file, assembly->resources.data, assembly->resources.index);\n\t\t\tchecked_write_file (file, assembly->image.raw_metadata, assembly->meta_size);\n\t\t\tchecked_write_file (file, assembly->strong_name, assembly->strong_name_size);\n\t\t\t\t\n\n\t\t\tg_free (assembly->image.raw_metadata);\n\t\t\tbreak;\n\t\tcase MONO_SECTION_RELOC: {\n\t\t\tstruct {\n\t\t\t\tguint32 page_rva;\n\t\t\t\tguint32 block_size;\n\t\t\t\tguint16 type_and_offset;\n\t\t\t\tguint16 term;\n\t\t\t} reloc;\n\t\t\t\n\t\t\tg_assert (sizeof (reloc) == 12);\n\t\t\t\n\t\t\treloc.page_rva = GUINT32_FROM_LE (assembly->text_rva);\n\t\t\treloc.block_size = GUINT32_FROM_LE (12);\n\t\t\t\n\t\t\t\/* \n\t\t\t * the entrypoint is always at the start of the text section \n\t\t\t * 3 is IMAGE_REL_BASED_HIGHLOW\n\t\t\t * 2 is patch_size_rva - text_rva\n\t\t\t *\/\n\t\t\treloc.type_and_offset = GUINT16_FROM_LE ((3 << 12) + (2));\n\t\t\treloc.term = 0;\n\t\t\t\n\t\t\tchecked_write_file (file, &reloc, sizeof (reloc));\n\t\t\t\n\t\t\tbreak;\n\t\t}\n\t\tcase MONO_SECTION_RSRC:\n\t\t\tif (assembly->win32_res) {\n\n\t\t\t\t\/* Fixup the offsets in the IMAGE_RESOURCE_DATA_ENTRY structures *\/\n\t\t\t\tfixup_resource_directory (assembly->win32_res, assembly->win32_res, assembly->sections [i].rva);\n\t\t\t\tchecked_write_file (file, assembly->win32_res, assembly->win32_res_size);\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tg_assert_not_reached ();\n\t\t}\n\t}\n\t\n\t\/* check that the file is properly padded *\/\n\tif (SetFilePointer (file, file_offset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)\n\t\tg_error (\"SetFilePointer returned %d\\n\", GetLastError ());\n\tif (! SetEndOfFile (file))\n\t\tg_error (\"SetEndOfFile returned %d\\n\", GetLastError ());\n\t\n\tmono_dynamic_stream_reset (&assembly->code);\n\tmono_dynamic_stream_reset (&assembly->us);\n\tmono_dynamic_stream_reset (&assembly->blob);\n\tmono_dynamic_stream_reset (&assembly->guid);\n\tmono_dynamic_stream_reset (&assembly->sheap);\n\n\tg_hash_table_foreach (assembly->blob_cache, (GHFunc)g_free, NULL);\n\tg_hash_table_destroy (assembly->blob_cache);\n\tassembly->blob_cache = NULL;\n}","target":0,"code_token_length":4746,"total_token_length":4982,"max_tokens_setting":6144}
+{"idx":278743,"func":"IHEVCD_ERROR_T  ihevcd_parse_coding_unit(codec_t *ps_codec,\n                                         WORD32 x0,\n                                         WORD32 y0,\n                                         WORD32 log2_cb_size)\n{\n    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;\n sps_t *ps_sps;\n pps_t *ps_pps;\n    WORD32 cb_size;\n slice_header_t *ps_slice_hdr;\n    WORD32 skip_flag;\n    WORD32 pcm_flag;\n    UWORD32 *pu4_skip_top = ps_codec->s_parse.pu4_skip_cu_top;\n    UWORD32 u4_skip_left = ps_codec->s_parse.u4_skip_cu_left;\n bitstrm_t *ps_bitstrm = &ps_codec->s_parse.s_bitstrm;\n tu_t *ps_tu = ps_codec->s_parse.ps_tu;\n\n    WORD32 cu_pos_x;\n    WORD32 cu_pos_y;\n cab_ctxt_t *ps_cabac = &ps_codec->s_parse.s_cabac;\n\n    ASSERT(0 == (x0 % 8));\n    ASSERT(0 == (y0 % 8));\n\n    ps_codec->s_parse.s_cu.i4_tu_cnt = 0;\n    ps_sps = ps_codec->s_parse.ps_sps;\n    ps_pps = ps_codec->s_parse.ps_pps;\n\n    cu_pos_x = ps_codec->s_parse.s_cu.i4_pos_x;\n    cu_pos_y = ps_codec->s_parse.s_cu.i4_pos_y;\n\n\n\n    ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr;\n\n\n    cb_size = 1 << log2_cb_size;\n\n    ps_codec->s_parse.s_cu.i4_cu_transquant_bypass = 0;\n\n if(ps_pps->i1_transquant_bypass_enable_flag)\n {\n        TRACE_CABAC_CTXT(\"cu_transquant_bypass_flag\", ps_cabac->u4_range, IHEVC_CAB_CU_TQ_BYPASS_FLAG);\n        ps_codec->s_parse.s_cu.i4_cu_transquant_bypass =\n                        ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm,\n                                                IHEVC_CAB_CU_TQ_BYPASS_FLAG);\n \/* Update transquant_bypass in ps_tu *\/\n\n        AEV_TRACE(\"cu_transquant_bypass_flag\", ps_codec->s_parse.s_cu.i4_cu_transquant_bypass,\n                  ps_cabac->u4_range);\n\n if(ps_codec->s_parse.s_cu.i4_cu_transquant_bypass)\n {\n            UWORD8 *pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag;\n            UWORD32 u4_mask;\n            WORD32 i;\n            WORD32 numbytes_row;\n            numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) \/ 64;\n            pu1_pic_no_loop_filter_flag += (y0 \/ 8) * numbytes_row;\n            pu1_pic_no_loop_filter_flag += (x0 \/ 64);\n\n \/* Generate (cb_size \/ 8) number of 1s *\/\n \/* i.e (log2_cb_size - 2) number of 1s *\/\n            u4_mask = LSB_ONES((cb_size >> 3));\n for(i = 0; i < (cb_size \/ 8); i++)\n {\n *pu1_pic_no_loop_filter_flag |= (u4_mask << (((x0) \/ 8) % 8));\n                pu1_pic_no_loop_filter_flag += numbytes_row;\n }\n }\n }\n\n {\n        UWORD32 u4_skip_top = 0;\n        UWORD32 u4_mask;\n        UWORD32 u4_top_mask, u4_left_mask;\n        UWORD32 u4_min_cu_x = x0 \/ 8;\n        UWORD32 u4_min_cu_y = y0 \/ 8;\n\n        pu4_skip_top += (u4_min_cu_x \/ 32);\n\n\n if(ps_slice_hdr->i1_slice_type != ISLICE)\n {\n            WORD32 ctx_idx_inc;\n            ctx_idx_inc = 0;\n\n if((0 != cu_pos_y) ||\n ((0 != ps_codec->s_parse.i4_ctb_slice_y) &&\n (0 != ps_codec->s_parse.i4_ctb_tile_y)))\n {\n                u4_skip_top = *pu4_skip_top;\n                u4_skip_top >>= (u4_min_cu_x % 32);\n if(u4_skip_top & 1)\n                    ctx_idx_inc++;\n }\n\n \/*****************************************************************\/\n \/* If cu_pos_x is non-zero then left is available                *\/\n \/* If cu_pos_x is zero then ensure both the following are true   *\/\n \/*    Current CTB is not the first CTB in a tile row             *\/\n \/*    Current CTB is not the first CTB in a slice                *\/\n \/*****************************************************************\/\n if((0 != cu_pos_x) ||\n (((0 != ps_codec->s_parse.i4_ctb_slice_x) || (0 != ps_codec->s_parse.i4_ctb_slice_y)) &&\n (0 != ps_codec->s_parse.i4_ctb_tile_x)))\n {\n                u4_skip_left >>= (u4_min_cu_y % 32);\n if(u4_skip_left & 1)\n                    ctx_idx_inc++;\n }\n            TRACE_CABAC_CTXT(\"cu_skip_flag\", ps_cabac->u4_range, (IHEVC_CAB_SKIP_FLAG + ctx_idx_inc));\n            skip_flag = ihevcd_cabac_decode_bin(ps_cabac,\n                                                ps_bitstrm,\n (IHEVC_CAB_SKIP_FLAG + ctx_idx_inc));\n\n            AEV_TRACE(\"cu_skip_flag\", skip_flag, ps_cabac->u4_range);\n }\n else\n            skip_flag = 0;\n\n \/* Update top skip_flag *\/\n        u4_skip_top = *pu4_skip_top;\n \/* Since Max cb_size is 64, maximum of 8 bits will be set or reset *\/\n \/* Also since Coding block will be within 64x64 grid, only 8bits within a WORD32\n         * need to be updated. These 8 bits will not cross 8 bit boundaries\n         *\/\n        u4_mask = LSB_ONES(cb_size \/ 8);\n        u4_top_mask = u4_mask << (u4_min_cu_x % 32);\n\n\n if(skip_flag)\n {\n            u4_skip_top |= u4_top_mask;\n }\n else\n {\n            u4_skip_top &= ~u4_top_mask;\n }\n *pu4_skip_top = u4_skip_top;\n\n \/* Update left skip_flag *\/\n        u4_skip_left = ps_codec->s_parse.u4_skip_cu_left;\n        u4_mask = LSB_ONES(cb_size \/ 8);\n        u4_left_mask = u4_mask << (u4_min_cu_y % 32);\n\n if(skip_flag)\n {\n            u4_skip_left |= u4_left_mask;\n }\n else\n {\n            u4_skip_left &= ~u4_left_mask;\n }\n        ps_codec->s_parse.u4_skip_cu_left = u4_skip_left;\n }\n    ps_codec->s_parse.i4_cu_pcm_flag = 0;\n\n if(skip_flag)\n {\n        WORD32 ctb_x_base;\n        WORD32 ctb_y_base;\n\n        ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size;\n        ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size;\n\n        ps_tu->b1_cb_cbf = 0;\n        ps_tu->b1_cr_cbf = 0;\n        ps_tu->b1_y_cbf = 0;\n        ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2);\n        ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2);\n        ps_tu->b1_transquant_bypass = 0;\n        ps_tu->b3_size = (log2_cb_size - 2);\n        ps_tu->b7_qp = ps_codec->s_parse.u4_qp;\n        ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE;\n        ps_tu->b6_luma_intra_mode   = INTRA_PRED_NONE;\n\n \/* Set the first TU in CU flag *\/\n {\n if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) &&\n (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2))\n {\n                ps_tu->b1_first_tu_in_cu = 1;\n }\n else\n {\n                ps_tu->b1_first_tu_in_cu = 0;\n }\n }\n\n        ps_codec->s_parse.ps_tu++;\n        ps_codec->s_parse.s_cu.i4_tu_cnt++;\n        ps_codec->s_parse.i4_pic_tu_idx++;\n\n        ps_codec->s_parse.s_cu.i4_pred_mode = PRED_MODE_SKIP;\n        ps_codec->s_parse.s_cu.i4_part_mode = PART_2Nx2N;\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n            ps_pu->b2_part_idx = 0;\n            ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size);\n            STATS_UPDATE_PU_SKIP_SIZE(ps_pu);\n }\n }\n else\n {\n        WORD32 pred_mode;\n        WORD32 part_mode;\n        WORD32 intra_split_flag;\n        WORD32 is_mincb;\n        cb_size = (1 << log2_cb_size);\n        is_mincb = (cb_size == (1 << ps_sps->i1_log2_min_coding_block_size));\n        pcm_flag = 0;\n if(ps_slice_hdr->i1_slice_type != ISLICE)\n {\n            TRACE_CABAC_CTXT(\"pred_mode_flag\", ps_cabac->u4_range, IHEVC_CAB_PRED_MODE);\n            pred_mode = ihevcd_cabac_decode_bin(ps_cabac,\n                                                ps_bitstrm,\n                                                IHEVC_CAB_PRED_MODE);\n\n            AEV_TRACE(\"pred_mode_flag\", pred_mode, ps_cabac->u4_range);\n }\n else\n {\n            pred_mode = PRED_MODE_INTRA;\n }\n\n \/* If current CU is intra then set corresponging bit in picture level intra map *\/\n if(PRED_MODE_INTRA == pred_mode)\n {\n            UWORD8 *pu1_pic_intra_flag = ps_codec->s_parse.pu1_pic_intra_flag;\n            UWORD32 u4_mask;\n            WORD32 i;\n            WORD32 numbytes_row;\n            numbytes_row = (ps_sps->i2_pic_width_in_luma_samples + 63) \/ 64;\n            pu1_pic_intra_flag += (y0 \/ 8) * numbytes_row;\n            pu1_pic_intra_flag += (x0 \/ 64);\n\n \/* Generate (cb_size \/ 8) number of 1s *\/\n \/* i.e (log2_cb_size - 2) number of 1s *\/\n            u4_mask = LSB_ONES((cb_size >> 3));\n for(i = 0; i < (cb_size \/ 8); i++)\n {\n *pu1_pic_intra_flag |= (u4_mask << (((x0) \/ 8) % 8));\n                pu1_pic_intra_flag += numbytes_row;\n }\n }\n\n        ps_codec->s_parse.s_cu.i4_pred_mode = pred_mode;\n        intra_split_flag = 0;\n if((PRED_MODE_INTRA != pred_mode) ||\n                        is_mincb)\n {\n            UWORD32 bin;\n if(PRED_MODE_INTRA == pred_mode)\n {\n                TRACE_CABAC_CTXT(\"part_mode\", ps_cabac->u4_range, IHEVC_CAB_PART_MODE);\n                bin = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, IHEVC_CAB_PART_MODE);\n                part_mode = (bin) ? PART_2Nx2N : PART_NxN;\n }\n else\n {\n                WORD32 amp_enabled = ps_sps->i1_amp_enabled_flag;\n\n                UWORD32 u4_max_bin_cnt = 0;\n\n\n\n if(amp_enabled && !is_mincb)\n {\n                    part_mode = ihevcd_parse_part_mode_amp(ps_cabac, ps_bitstrm);\n }\n else\n {\n                    WORD32 ctxt_inc = IHEVC_CAB_PART_MODE;\n\n                    u4_max_bin_cnt = 2;\n if((is_mincb) && (cb_size > 8))\n {\n                        u4_max_bin_cnt++;\n }\n\n                    part_mode = -1;\n                    TRACE_CABAC_CTXT(\"part_mode\", ps_cabac->u4_range, IHEVC_CAB_PART_MODE);\n do\n {\n                        bin = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm,\n                                                      ctxt_inc++);\n                        part_mode++;\n }while(--u4_max_bin_cnt && !bin);\n\n \/* If the last bin was zero, then increment part mode by 1 *\/\n if(!bin)\n                        part_mode++;\n }\n\n\n }\n\n            AEV_TRACE(\"part_mode\", part_mode, ps_cabac->u4_range);\n\n }\n else\n {\n            part_mode = 0;\n            intra_split_flag = 0;\n }\n        ps_codec->s_parse.s_cu.i4_part_mode = part_mode;\n\n if((PRED_MODE_INTRA == ps_codec->s_parse.s_cu.i4_pred_mode) &&\n (PART_NxN == ps_codec->s_parse.s_cu.i4_part_mode))\n {\n            intra_split_flag = 1;\n }\n        ps_codec->s_parse.s_cu.i4_part_mode = part_mode;\n        ps_codec->s_parse.s_cu.i4_intra_split_flag = intra_split_flag;\n if(pred_mode == PRED_MODE_INTRA)\n {\n            ps_codec->s_parse.i4_cu_pcm_flag = 0;\n            ihevcd_parse_coding_unit_intra(ps_codec, x0, y0, log2_cb_size);\n            pcm_flag = ps_codec->s_parse.i4_cu_pcm_flag;\n\n }\n else\n {\n if(part_mode == PART_2Nx2N)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size);\n                ps_pu->b2_part_idx = 0;\n }\n else if(part_mode == PART_2NxN)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size \/ 2);\n                ps_pu->b2_part_idx = 0;\n\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size \/ 2), cb_size, cb_size \/ 2);\n\n                ps_pu->b2_part_idx = 1;\n }\n else if(part_mode == PART_Nx2N)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size \/ 2, cb_size);\n                ps_pu->b2_part_idx = 0;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size \/ 2), y0, cb_size \/ 2, cb_size);\n\n                ps_pu->b2_part_idx = 1;\n }\n else if(part_mode == PART_2NxnU)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size \/ 4);\n                ps_pu->b2_part_idx = 0;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size \/ 4), cb_size, cb_size * 3 \/ 4);\n\n                ps_pu->b2_part_idx = 1;\n }\n else if(part_mode == PART_2NxnD)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size, cb_size * 3 \/ 4);\n                ps_pu->b2_part_idx = 0;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size * 3 \/ 4), cb_size, cb_size \/ 4);\n\n                ps_pu->b2_part_idx = 1;\n }\n else if(part_mode == PART_nLx2N)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size \/ 4, cb_size);\n                ps_pu->b2_part_idx = 0;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size \/ 4), y0, cb_size * 3 \/ 4, cb_size);\n\n                ps_pu->b2_part_idx = 1;\n }\n else if(part_mode == PART_nRx2N)\n {\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size * 3 \/ 4, cb_size);\n                ps_pu->b2_part_idx = 0;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size * 3 \/ 4), y0, cb_size \/ 4, cb_size);\n                ps_pu->b2_part_idx = 1;\n }\n else\n { \/* PART_NxN *\/\n pu_t *ps_pu = ps_codec->s_parse.ps_pu;\n\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0, cb_size \/ 2, cb_size \/ 2);\n                ps_pu->b2_part_idx = 0;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size \/ 2), y0, cb_size \/ 2, cb_size \/ 2);\n\n                ps_pu->b2_part_idx = 1;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0, y0 + (cb_size \/ 2), cb_size \/ 2, cb_size \/ 2);\n\n                ps_pu->b2_part_idx = 2;\n                ps_pu = ps_codec->s_parse.ps_pu;\n                ihevcd_parse_prediction_unit(ps_codec, x0 + (cb_size \/ 2), y0 + (cb_size \/ 2), cb_size \/ 2, cb_size \/ 2);\n\n                ps_pu->b2_part_idx = 3;\n }\n }\n\n if(!pcm_flag)\n {\n            WORD32 no_residual_syntax_flag = 0;\n pu_t *ps_pu;\n \/* Since ps_pu is incremented for each PU parsed, decrement by 1 to\n             *  access last decoded PU\n             *\/\n            ps_pu = ps_codec->s_parse.ps_pu - 1;\n if((PRED_MODE_INTRA != pred_mode) &&\n (!((part_mode == PART_2Nx2N) && ps_pu->b1_merge_flag)))\n {\n\n                TRACE_CABAC_CTXT(\"rqt_root_cbf\", ps_cabac->u4_range, IHEVC_CAB_NORES_IDX);\n                no_residual_syntax_flag = ihevcd_cabac_decode_bin(ps_cabac,\n                                                                  ps_bitstrm,\n                                                                  IHEVC_CAB_NORES_IDX);\n\n                AEV_TRACE(\"rqt_root_cbf\", no_residual_syntax_flag,\n                          ps_cabac->u4_range);\n \/* TODO: HACK FOR COMPLIANCE WITH HM REFERENCE DECODER *\/\n \/*********************************************************\/\n \/* currently the HM decoder expects qtroot cbf instead of *\/\n \/* no_residue_flag which has opposite meaning             *\/\n \/* This will be fixed once the software \/ spec is fixed   *\/\n \/*********************************************************\/\n                no_residual_syntax_flag = 1 - no_residual_syntax_flag;\n }\n\n if(!no_residual_syntax_flag)\n {\n\n                ps_codec->s_parse.s_cu.i4_max_trafo_depth = (pred_mode == PRED_MODE_INTRA) ?\n (ps_sps->i1_max_transform_hierarchy_depth_intra + intra_split_flag) :\n (ps_sps->i1_max_transform_hierarchy_depth_inter);\n                ihevcd_parse_transform_tree(ps_codec, x0, y0, x0, y0,\n                                            log2_cb_size, 0, 0,\n                                            ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]);\n }\n else\n {\n                WORD32 ctb_x_base;\n                WORD32 ctb_y_base;\n\n                ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size;\n                ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size;\n\n                ps_tu = ps_codec->s_parse.ps_tu;\n                ps_tu->b1_cb_cbf = 0;\n                ps_tu->b1_cr_cbf = 0;\n                ps_tu->b1_y_cbf = 0;\n                ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2);\n                ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2);\n                ps_tu->b1_transquant_bypass = 0;\n                ps_tu->b3_size = (log2_cb_size - 2);\n                ps_tu->b7_qp = ps_codec->s_parse.u4_qp;\n                ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE;\n                ps_tu->b6_luma_intra_mode   = ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0];\n\n \/* Set the first TU in CU flag *\/\n {\n if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) &&\n (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2))\n {\n                        ps_tu->b1_first_tu_in_cu = 1;\n }\n else\n {\n                        ps_tu->b1_first_tu_in_cu = 0;\n }\n }\n                ps_codec->s_parse.ps_tu++;\n                ps_codec->s_parse.s_cu.i4_tu_cnt++;\n                ps_codec->s_parse.i4_pic_tu_idx++;\n\n }\n }\n\n }\n\n\n\n\n return ret;\n}\n","target":0,"code_token_length":4983,"total_token_length":5219,"max_tokens_setting":6144}
+{"idx":79770,"func":"static int init_types(void)\n{\n    static int initialized;\n    if (initialized) return 1;\n    if (add_ast_fields() < 0) return 0;\n    mod_type = make_type(\"mod\", &AST_type, NULL, 0);\n    if (!mod_type) return 0;\n    if (!add_attributes(mod_type, NULL, 0)) return 0;\n    Module_type = make_type(\"Module\", mod_type, Module_fields, 2);\n    if (!Module_type) return 0;\n    Interactive_type = make_type(\"Interactive\", mod_type, Interactive_fields,\n                                 1);\n    if (!Interactive_type) return 0;\n    Expression_type = make_type(\"Expression\", mod_type, Expression_fields, 1);\n    if (!Expression_type) return 0;\n    FunctionType_type = make_type(\"FunctionType\", mod_type,\n                                  FunctionType_fields, 2);\n    if (!FunctionType_type) return 0;\n    Suite_type = make_type(\"Suite\", mod_type, Suite_fields, 1);\n    if (!Suite_type) return 0;\n    stmt_type = make_type(\"stmt\", &AST_type, NULL, 0);\n    if (!stmt_type) return 0;\n    if (!add_attributes(stmt_type, stmt_attributes, 4)) return 0;\n    FunctionDef_type = make_type(\"FunctionDef\", stmt_type, FunctionDef_fields,\n                                 6);\n    if (!FunctionDef_type) return 0;\n    AsyncFunctionDef_type = make_type(\"AsyncFunctionDef\", stmt_type,\n                                      AsyncFunctionDef_fields, 6);\n    if (!AsyncFunctionDef_type) return 0;\n    ClassDef_type = make_type(\"ClassDef\", stmt_type, ClassDef_fields, 5);\n    if (!ClassDef_type) return 0;\n    Return_type = make_type(\"Return\", stmt_type, Return_fields, 1);\n    if (!Return_type) return 0;\n    Delete_type = make_type(\"Delete\", stmt_type, Delete_fields, 1);\n    if (!Delete_type) return 0;\n    Assign_type = make_type(\"Assign\", stmt_type, Assign_fields, 3);\n    if (!Assign_type) return 0;\n    AugAssign_type = make_type(\"AugAssign\", stmt_type, AugAssign_fields, 3);\n    if (!AugAssign_type) return 0;\n    AnnAssign_type = make_type(\"AnnAssign\", stmt_type, AnnAssign_fields, 4);\n    if (!AnnAssign_type) return 0;\n    For_type = make_type(\"For\", stmt_type, For_fields, 5);\n    if (!For_type) return 0;\n    AsyncFor_type = make_type(\"AsyncFor\", stmt_type, AsyncFor_fields, 5);\n    if (!AsyncFor_type) return 0;\n    While_type = make_type(\"While\", stmt_type, While_fields, 3);\n    if (!While_type) return 0;\n    If_type = make_type(\"If\", stmt_type, If_fields, 3);\n    if (!If_type) return 0;\n    With_type = make_type(\"With\", stmt_type, With_fields, 3);\n    if (!With_type) return 0;\n    AsyncWith_type = make_type(\"AsyncWith\", stmt_type, AsyncWith_fields, 3);\n    if (!AsyncWith_type) return 0;\n    Raise_type = make_type(\"Raise\", stmt_type, Raise_fields, 2);\n    if (!Raise_type) return 0;\n    Try_type = make_type(\"Try\", stmt_type, Try_fields, 4);\n    if (!Try_type) return 0;\n    Assert_type = make_type(\"Assert\", stmt_type, Assert_fields, 2);\n    if (!Assert_type) return 0;\n    Import_type = make_type(\"Import\", stmt_type, Import_fields, 1);\n    if (!Import_type) return 0;\n    ImportFrom_type = make_type(\"ImportFrom\", stmt_type, ImportFrom_fields, 3);\n    if (!ImportFrom_type) return 0;\n    Global_type = make_type(\"Global\", stmt_type, Global_fields, 1);\n    if (!Global_type) return 0;\n    Nonlocal_type = make_type(\"Nonlocal\", stmt_type, Nonlocal_fields, 1);\n    if (!Nonlocal_type) return 0;\n    Expr_type = make_type(\"Expr\", stmt_type, Expr_fields, 1);\n    if (!Expr_type) return 0;\n    Pass_type = make_type(\"Pass\", stmt_type, NULL, 0);\n    if (!Pass_type) return 0;\n    Break_type = make_type(\"Break\", stmt_type, NULL, 0);\n    if (!Break_type) return 0;\n    Continue_type = make_type(\"Continue\", stmt_type, NULL, 0);\n    if (!Continue_type) return 0;\n    expr_type = make_type(\"expr\", &AST_type, NULL, 0);\n    if (!expr_type) return 0;\n    if (!add_attributes(expr_type, expr_attributes, 4)) return 0;\n    BoolOp_type = make_type(\"BoolOp\", expr_type, BoolOp_fields, 2);\n    if (!BoolOp_type) return 0;\n    NamedExpr_type = make_type(\"NamedExpr\", expr_type, NamedExpr_fields, 2);\n    if (!NamedExpr_type) return 0;\n    BinOp_type = make_type(\"BinOp\", expr_type, BinOp_fields, 3);\n    if (!BinOp_type) return 0;\n    UnaryOp_type = make_type(\"UnaryOp\", expr_type, UnaryOp_fields, 2);\n    if (!UnaryOp_type) return 0;\n    Lambda_type = make_type(\"Lambda\", expr_type, Lambda_fields, 2);\n    if (!Lambda_type) return 0;\n    IfExp_type = make_type(\"IfExp\", expr_type, IfExp_fields, 3);\n    if (!IfExp_type) return 0;\n    Dict_type = make_type(\"Dict\", expr_type, Dict_fields, 2);\n    if (!Dict_type) return 0;\n    Set_type = make_type(\"Set\", expr_type, Set_fields, 1);\n    if (!Set_type) return 0;\n    ListComp_type = make_type(\"ListComp\", expr_type, ListComp_fields, 2);\n    if (!ListComp_type) return 0;\n    SetComp_type = make_type(\"SetComp\", expr_type, SetComp_fields, 2);\n    if (!SetComp_type) return 0;\n    DictComp_type = make_type(\"DictComp\", expr_type, DictComp_fields, 3);\n    if (!DictComp_type) return 0;\n    GeneratorExp_type = make_type(\"GeneratorExp\", expr_type,\n                                  GeneratorExp_fields, 2);\n    if (!GeneratorExp_type) return 0;\n    Await_type = make_type(\"Await\", expr_type, Await_fields, 1);\n    if (!Await_type) return 0;\n    Yield_type = make_type(\"Yield\", expr_type, Yield_fields, 1);\n    if (!Yield_type) return 0;\n    YieldFrom_type = make_type(\"YieldFrom\", expr_type, YieldFrom_fields, 1);\n    if (!YieldFrom_type) return 0;\n    Compare_type = make_type(\"Compare\", expr_type, Compare_fields, 3);\n    if (!Compare_type) return 0;\n    Call_type = make_type(\"Call\", expr_type, Call_fields, 3);\n    if (!Call_type) return 0;\n    FormattedValue_type = make_type(\"FormattedValue\", expr_type,\n                                    FormattedValue_fields, 3);\n    if (!FormattedValue_type) return 0;\n    JoinedStr_type = make_type(\"JoinedStr\", expr_type, JoinedStr_fields, 1);\n    if (!JoinedStr_type) return 0;\n    Constant_type = make_type(\"Constant\", expr_type, Constant_fields, 1);\n    if (!Constant_type) return 0;\n    Attribute_type = make_type(\"Attribute\", expr_type, Attribute_fields, 3);\n    if (!Attribute_type) return 0;\n    Subscript_type = make_type(\"Subscript\", expr_type, Subscript_fields, 3);\n    if (!Subscript_type) return 0;\n    Starred_type = make_type(\"Starred\", expr_type, Starred_fields, 2);\n    if (!Starred_type) return 0;\n    Name_type = make_type(\"Name\", expr_type, Name_fields, 2);\n    if (!Name_type) return 0;\n    List_type = make_type(\"List\", expr_type, List_fields, 2);\n    if (!List_type) return 0;\n    Tuple_type = make_type(\"Tuple\", expr_type, Tuple_fields, 2);\n    if (!Tuple_type) return 0;\n    expr_context_type = make_type(\"expr_context\", &AST_type, NULL, 0);\n    if (!expr_context_type) return 0;\n    if (!add_attributes(expr_context_type, NULL, 0)) return 0;\n    Load_type = make_type(\"Load\", expr_context_type, NULL, 0);\n    if (!Load_type) return 0;\n    Load_singleton = PyType_GenericNew(Load_type, NULL, NULL);\n    if (!Load_singleton) return 0;\n    Store_type = make_type(\"Store\", expr_context_type, NULL, 0);\n    if (!Store_type) return 0;\n    Store_singleton = PyType_GenericNew(Store_type, NULL, NULL);\n    if (!Store_singleton) return 0;\n    Del_type = make_type(\"Del\", expr_context_type, NULL, 0);\n    if (!Del_type) return 0;\n    Del_singleton = PyType_GenericNew(Del_type, NULL, NULL);\n    if (!Del_singleton) return 0;\n    AugLoad_type = make_type(\"AugLoad\", expr_context_type, NULL, 0);\n    if (!AugLoad_type) return 0;\n    AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL);\n    if (!AugLoad_singleton) return 0;\n    AugStore_type = make_type(\"AugStore\", expr_context_type, NULL, 0);\n    if (!AugStore_type) return 0;\n    AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL);\n    if (!AugStore_singleton) return 0;\n    Param_type = make_type(\"Param\", expr_context_type, NULL, 0);\n    if (!Param_type) return 0;\n    Param_singleton = PyType_GenericNew(Param_type, NULL, NULL);\n    if (!Param_singleton) return 0;\n    NamedStore_type = make_type(\"NamedStore\", expr_context_type, NULL, 0);\n    if (!NamedStore_type) return 0;\n    NamedStore_singleton = PyType_GenericNew(NamedStore_type, NULL, NULL);\n    if (!NamedStore_singleton) return 0;\n    slice_type = make_type(\"slice\", &AST_type, NULL, 0);\n    if (!slice_type) return 0;\n    if (!add_attributes(slice_type, NULL, 0)) return 0;\n    Slice_type = make_type(\"Slice\", slice_type, Slice_fields, 3);\n    if (!Slice_type) return 0;\n    ExtSlice_type = make_type(\"ExtSlice\", slice_type, ExtSlice_fields, 1);\n    if (!ExtSlice_type) return 0;\n    Index_type = make_type(\"Index\", slice_type, Index_fields, 1);\n    if (!Index_type) return 0;\n    boolop_type = make_type(\"boolop\", &AST_type, NULL, 0);\n    if (!boolop_type) return 0;\n    if (!add_attributes(boolop_type, NULL, 0)) return 0;\n    And_type = make_type(\"And\", boolop_type, NULL, 0);\n    if (!And_type) return 0;\n    And_singleton = PyType_GenericNew(And_type, NULL, NULL);\n    if (!And_singleton) return 0;\n    Or_type = make_type(\"Or\", boolop_type, NULL, 0);\n    if (!Or_type) return 0;\n    Or_singleton = PyType_GenericNew(Or_type, NULL, NULL);\n    if (!Or_singleton) return 0;\n    operator_type = make_type(\"operator\", &AST_type, NULL, 0);\n    if (!operator_type) return 0;\n    if (!add_attributes(operator_type, NULL, 0)) return 0;\n    Add_type = make_type(\"Add\", operator_type, NULL, 0);\n    if (!Add_type) return 0;\n    Add_singleton = PyType_GenericNew(Add_type, NULL, NULL);\n    if (!Add_singleton) return 0;\n    Sub_type = make_type(\"Sub\", operator_type, NULL, 0);\n    if (!Sub_type) return 0;\n    Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL);\n    if (!Sub_singleton) return 0;\n    Mult_type = make_type(\"Mult\", operator_type, NULL, 0);\n    if (!Mult_type) return 0;\n    Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL);\n    if (!Mult_singleton) return 0;\n    MatMult_type = make_type(\"MatMult\", operator_type, NULL, 0);\n    if (!MatMult_type) return 0;\n    MatMult_singleton = PyType_GenericNew(MatMult_type, NULL, NULL);\n    if (!MatMult_singleton) return 0;\n    Div_type = make_type(\"Div\", operator_type, NULL, 0);\n    if (!Div_type) return 0;\n    Div_singleton = PyType_GenericNew(Div_type, NULL, NULL);\n    if (!Div_singleton) return 0;\n    Mod_type = make_type(\"Mod\", operator_type, NULL, 0);\n    if (!Mod_type) return 0;\n    Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL);\n    if (!Mod_singleton) return 0;\n    Pow_type = make_type(\"Pow\", operator_type, NULL, 0);\n    if (!Pow_type) return 0;\n    Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL);\n    if (!Pow_singleton) return 0;\n    LShift_type = make_type(\"LShift\", operator_type, NULL, 0);\n    if (!LShift_type) return 0;\n    LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL);\n    if (!LShift_singleton) return 0;\n    RShift_type = make_type(\"RShift\", operator_type, NULL, 0);\n    if (!RShift_type) return 0;\n    RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL);\n    if (!RShift_singleton) return 0;\n    BitOr_type = make_type(\"BitOr\", operator_type, NULL, 0);\n    if (!BitOr_type) return 0;\n    BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL);\n    if (!BitOr_singleton) return 0;\n    BitXor_type = make_type(\"BitXor\", operator_type, NULL, 0);\n    if (!BitXor_type) return 0;\n    BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL);\n    if (!BitXor_singleton) return 0;\n    BitAnd_type = make_type(\"BitAnd\", operator_type, NULL, 0);\n    if (!BitAnd_type) return 0;\n    BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL);\n    if (!BitAnd_singleton) return 0;\n    FloorDiv_type = make_type(\"FloorDiv\", operator_type, NULL, 0);\n    if (!FloorDiv_type) return 0;\n    FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL);\n    if (!FloorDiv_singleton) return 0;\n    unaryop_type = make_type(\"unaryop\", &AST_type, NULL, 0);\n    if (!unaryop_type) return 0;\n    if (!add_attributes(unaryop_type, NULL, 0)) return 0;\n    Invert_type = make_type(\"Invert\", unaryop_type, NULL, 0);\n    if (!Invert_type) return 0;\n    Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL);\n    if (!Invert_singleton) return 0;\n    Not_type = make_type(\"Not\", unaryop_type, NULL, 0);\n    if (!Not_type) return 0;\n    Not_singleton = PyType_GenericNew(Not_type, NULL, NULL);\n    if (!Not_singleton) return 0;\n    UAdd_type = make_type(\"UAdd\", unaryop_type, NULL, 0);\n    if (!UAdd_type) return 0;\n    UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL);\n    if (!UAdd_singleton) return 0;\n    USub_type = make_type(\"USub\", unaryop_type, NULL, 0);\n    if (!USub_type) return 0;\n    USub_singleton = PyType_GenericNew(USub_type, NULL, NULL);\n    if (!USub_singleton) return 0;\n    cmpop_type = make_type(\"cmpop\", &AST_type, NULL, 0);\n    if (!cmpop_type) return 0;\n    if (!add_attributes(cmpop_type, NULL, 0)) return 0;\n    Eq_type = make_type(\"Eq\", cmpop_type, NULL, 0);\n    if (!Eq_type) return 0;\n    Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL);\n    if (!Eq_singleton) return 0;\n    NotEq_type = make_type(\"NotEq\", cmpop_type, NULL, 0);\n    if (!NotEq_type) return 0;\n    NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL);\n    if (!NotEq_singleton) return 0;\n    Lt_type = make_type(\"Lt\", cmpop_type, NULL, 0);\n    if (!Lt_type) return 0;\n    Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL);\n    if (!Lt_singleton) return 0;\n    LtE_type = make_type(\"LtE\", cmpop_type, NULL, 0);\n    if (!LtE_type) return 0;\n    LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL);\n    if (!LtE_singleton) return 0;\n    Gt_type = make_type(\"Gt\", cmpop_type, NULL, 0);\n    if (!Gt_type) return 0;\n    Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL);\n    if (!Gt_singleton) return 0;\n    GtE_type = make_type(\"GtE\", cmpop_type, NULL, 0);\n    if (!GtE_type) return 0;\n    GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL);\n    if (!GtE_singleton) return 0;\n    Is_type = make_type(\"Is\", cmpop_type, NULL, 0);\n    if (!Is_type) return 0;\n    Is_singleton = PyType_GenericNew(Is_type, NULL, NULL);\n    if (!Is_singleton) return 0;\n    IsNot_type = make_type(\"IsNot\", cmpop_type, NULL, 0);\n    if (!IsNot_type) return 0;\n    IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL);\n    if (!IsNot_singleton) return 0;\n    In_type = make_type(\"In\", cmpop_type, NULL, 0);\n    if (!In_type) return 0;\n    In_singleton = PyType_GenericNew(In_type, NULL, NULL);\n    if (!In_singleton) return 0;\n    NotIn_type = make_type(\"NotIn\", cmpop_type, NULL, 0);\n    if (!NotIn_type) return 0;\n    NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL);\n    if (!NotIn_singleton) return 0;\n    comprehension_type = make_type(\"comprehension\", &AST_type,\n                                   comprehension_fields, 4);\n    if (!comprehension_type) return 0;\n    if (!add_attributes(comprehension_type, NULL, 0)) return 0;\n    excepthandler_type = make_type(\"excepthandler\", &AST_type, NULL, 0);\n    if (!excepthandler_type) return 0;\n    if (!add_attributes(excepthandler_type, excepthandler_attributes, 4))\n        return 0;\n    ExceptHandler_type = make_type(\"ExceptHandler\", excepthandler_type,\n                                   ExceptHandler_fields, 3);\n    if (!ExceptHandler_type) return 0;\n    arguments_type = make_type(\"arguments\", &AST_type, arguments_fields, 6);\n    if (!arguments_type) return 0;\n    if (!add_attributes(arguments_type, NULL, 0)) return 0;\n    arg_type = make_type(\"arg\", &AST_type, arg_fields, 3);\n    if (!arg_type) return 0;\n    if (!add_attributes(arg_type, arg_attributes, 4)) return 0;\n    keyword_type = make_type(\"keyword\", &AST_type, keyword_fields, 2);\n    if (!keyword_type) return 0;\n    if (!add_attributes(keyword_type, NULL, 0)) return 0;\n    alias_type = make_type(\"alias\", &AST_type, alias_fields, 2);\n    if (!alias_type) return 0;\n    if (!add_attributes(alias_type, NULL, 0)) return 0;\n    withitem_type = make_type(\"withitem\", &AST_type, withitem_fields, 2);\n    if (!withitem_type) return 0;\n    if (!add_attributes(withitem_type, NULL, 0)) return 0;\n    type_ignore_type = make_type(\"type_ignore\", &AST_type, NULL, 0);\n    if (!type_ignore_type) return 0;\n    if (!add_attributes(type_ignore_type, NULL, 0)) return 0;\n    TypeIgnore_type = make_type(\"TypeIgnore\", type_ignore_type,\n                                TypeIgnore_fields, 1);\n    if (!TypeIgnore_type) return 0;\n    initialized = 1;\n    return 1;\n}","target":0,"code_token_length":4746,"total_token_length":4982,"max_tokens_setting":6144}
+{"idx":247147,"func":"static Image *ReadJPEGImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  char\n    value[MaxTextExtent];\n\n  const char\n    *option;\n\n  ErrorManager\n    error_manager;\n\n  Image\n    *image;\n\n  IndexPacket\n    index;\n\n  JSAMPLE\n    *volatile jpeg_pixels;\n\n  JSAMPROW\n    scanline[1];\n\n  MagickBooleanType\n    debug,\n    status;\n\n  MagickSizeType\n    number_pixels;\n\n  MemoryInfo\n    *memory_info;\n\n  register ssize_t\n    i;\n\n  struct jpeg_decompress_struct\n    jpeg_info;\n\n  struct jpeg_error_mgr\n    jpeg_error;\n\n  register JSAMPLE\n    *p;\n\n  size_t\n    units;\n\n  ssize_t\n    y;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickSignature);\n  debug=IsEventLogging();\n  (void) debug;\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Verify that file size large enough to contain a JPEG datastream.\n  *\/\n  if (GetBlobSize(image) < 107)\n    ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n  \/*\n    Initialize JPEG parameters.\n  *\/\n  (void) ResetMagickMemory(&error_manager,0,sizeof(error_manager));\n  (void) ResetMagickMemory(&jpeg_info,0,sizeof(jpeg_info));\n  (void) ResetMagickMemory(&jpeg_error,0,sizeof(jpeg_error));\n  jpeg_info.err=jpeg_std_error(&jpeg_error);\n  jpeg_info.err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler;\n  jpeg_info.err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler;\n  memory_info=(MemoryInfo *) NULL;\n  error_manager.image=image;\n  if (setjmp(error_manager.error_recovery) != 0)\n    {\n      jpeg_destroy_decompress(&jpeg_info);\n      if (error_manager.profile != (StringInfo *) NULL)\n        error_manager.profile=DestroyStringInfo(error_manager.profile);\n      (void) CloseBlob(image);\n      number_pixels=(MagickSizeType) image->columns*image->rows;\n      if (number_pixels != 0)\n        return(GetFirstImageInList(image));\n      InheritException(exception,&image->exception);\n      return(DestroyImage(image));\n    }\n  jpeg_info.client_data=(void *) &error_manager;\n  jpeg_create_decompress(&jpeg_info);\n  JPEGSourceManager(&jpeg_info,image);\n  jpeg_set_marker_processor(&jpeg_info,JPEG_COM,ReadComment);\n  option=GetImageOption(image_info,\"profile:skip\");\n  if (IsOptionMember(\"ICC\",option) == MagickFalse)\n    jpeg_set_marker_processor(&jpeg_info,ICC_MARKER,ReadICCProfile);\n  if (IsOptionMember(\"IPTC\",option) == MagickFalse)\n    jpeg_set_marker_processor(&jpeg_info,IPTC_MARKER,ReadIPTCProfile);\n  for (i=1; i < 16; i++)\n    if ((i != 2) && (i != 13) && (i != 14))\n      if (IsOptionMember(\"APP\",option) == MagickFalse)\n        jpeg_set_marker_processor(&jpeg_info,(int) (JPEG_APP0+i),ReadProfile);\n  i=(ssize_t) jpeg_read_header(&jpeg_info,TRUE);\n  if ((image_info->colorspace == YCbCrColorspace) ||\n      (image_info->colorspace == Rec601YCbCrColorspace) ||\n      (image_info->colorspace == Rec709YCbCrColorspace))\n    jpeg_info.out_color_space=JCS_YCbCr;\n  \/*\n    Set image resolution.\n  *\/\n  units=0;\n  if ((jpeg_info.saw_JFIF_marker != 0) && (jpeg_info.X_density != 1) &&\n      (jpeg_info.Y_density != 1))\n    {\n      image->x_resolution=(double) jpeg_info.X_density;\n      image->y_resolution=(double) jpeg_info.Y_density;\n      units=(size_t) jpeg_info.density_unit;\n    }\n  if (units == 1)\n    image->units=PixelsPerInchResolution;\n  if (units == 2)\n    image->units=PixelsPerCentimeterResolution;\n  number_pixels=(MagickSizeType) image->columns*image->rows;\n  option=GetImageOption(image_info,\"jpeg:size\");\n  if ((option != (const char *) NULL) &&\n      (jpeg_info.out_color_space != JCS_YCbCr))\n    {\n      double\n        scale_factor;\n\n      GeometryInfo\n        geometry_info;\n\n      MagickStatusType\n        flags;\n\n      \/*\n        Scale the image.\n      *\/\n      flags=ParseGeometry(option,&geometry_info);\n      if ((flags & SigmaValue) == 0)\n        geometry_info.sigma=geometry_info.rho;\n      jpeg_calc_output_dimensions(&jpeg_info);\n      image->magick_columns=jpeg_info.output_width;\n      image->magick_rows=jpeg_info.output_height;\n      scale_factor=1.0;\n      if (geometry_info.rho != 0.0)\n        scale_factor=jpeg_info.output_width\/geometry_info.rho;\n      if ((geometry_info.sigma != 0.0) &&\n          (scale_factor > (jpeg_info.output_height\/geometry_info.sigma)))\n        scale_factor=jpeg_info.output_height\/geometry_info.sigma;\n      jpeg_info.scale_num=1U;\n      jpeg_info.scale_denom=(unsigned int) scale_factor;\n      jpeg_calc_output_dimensions(&jpeg_info);\n      if (image->debug != MagickFalse)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Scale factor: %.20g\",(double) scale_factor);\n    }\n#if (JPEG_LIB_VERSION >= 61) && defined(D_PROGRESSIVE_SUPPORTED)\n#if defined(D_LOSSLESS_SUPPORTED)\n  image->interlace=jpeg_info.process == JPROC_PROGRESSIVE ?\n    JPEGInterlace : NoInterlace;\n  image->compression=jpeg_info.process == JPROC_LOSSLESS ?\n    LosslessJPEGCompression : JPEGCompression;\n  if (jpeg_info.data_precision > 8)\n    (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n      \"12-bit JPEG not supported. Reducing pixel data to 8 bits\",\"`%s'\",\n      image->filename);\n  if (jpeg_info.data_precision == 16)\n    jpeg_info.data_precision=12;\n#else\n  image->interlace=jpeg_info.progressive_mode != 0 ? JPEGInterlace :\n    NoInterlace;\n  image->compression=JPEGCompression;\n#endif\n#else\n  image->compression=JPEGCompression;\n  image->interlace=JPEGInterlace;\n#endif\n  option=GetImageOption(image_info,\"jpeg:colors\");\n  if (option != (const char *) NULL)\n    {\n      \/*\n        Let the JPEG library quantize for us.\n      *\/\n      jpeg_info.quantize_colors=TRUE;\n      jpeg_info.desired_number_of_colors=(int) StringToUnsignedLong(option);\n    }\n  option=GetImageOption(image_info,\"jpeg:block-smoothing\");\n  if (option != (const char *) NULL)\n    jpeg_info.do_block_smoothing=IsStringTrue(option) != MagickFalse ? TRUE :\n      FALSE;\n  jpeg_info.dct_method=JDCT_FLOAT;\n  option=GetImageOption(image_info,\"jpeg:dct-method\");\n  if (option != (const char *) NULL)\n    switch (*option)\n    {\n      case 'D':\n      case 'd':\n      {\n        if (LocaleCompare(option,\"default\") == 0)\n          jpeg_info.dct_method=JDCT_DEFAULT;\n        break;\n      }\n      case 'F':\n      case 'f':\n      {\n        if (LocaleCompare(option,\"fastest\") == 0)\n          jpeg_info.dct_method=JDCT_FASTEST;\n        if (LocaleCompare(option,\"float\") == 0)\n          jpeg_info.dct_method=JDCT_FLOAT;\n        break;\n      }\n      case 'I':\n      case 'i':\n      {\n        if (LocaleCompare(option,\"ifast\") == 0)\n          jpeg_info.dct_method=JDCT_IFAST;\n        if (LocaleCompare(option,\"islow\") == 0)\n          jpeg_info.dct_method=JDCT_ISLOW;\n        break;\n      }\n    }\n  option=GetImageOption(image_info,\"jpeg:fancy-upsampling\");\n  if (option != (const char *) NULL)\n    jpeg_info.do_fancy_upsampling=IsStringTrue(option) != MagickFalse ? TRUE :\n      FALSE;\n  (void) jpeg_start_decompress(&jpeg_info);\n  image->columns=jpeg_info.output_width;\n  image->rows=jpeg_info.output_height;\n  image->depth=(size_t) jpeg_info.data_precision;\n  switch (jpeg_info.out_color_space)\n  {\n    case JCS_RGB:\n    default:\n    {\n      (void) SetImageColorspace(image,sRGBColorspace);\n      break;\n    }\n    case JCS_GRAYSCALE:\n    {\n      (void) SetImageColorspace(image,GRAYColorspace);\n      break;\n    }\n    case JCS_YCbCr:\n    {\n      (void) SetImageColorspace(image,YCbCrColorspace);\n      break;\n    }\n    case JCS_CMYK:\n    {\n      (void) SetImageColorspace(image,CMYKColorspace);\n      break;\n    }\n  }\n  if (IsITUFaxImage(image) != MagickFalse)\n    {\n      (void) SetImageColorspace(image,LabColorspace);\n      jpeg_info.out_color_space=JCS_YCbCr;\n    }\n  option=GetImageOption(image_info,\"jpeg:colors\");\n  if (option != (const char *) NULL)\n    if (AcquireImageColormap(image,StringToUnsignedLong(option)) == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n  if ((jpeg_info.output_components == 1) && (jpeg_info.quantize_colors == 0))\n    {\n      size_t\n        colors;\n\n      colors=(size_t) GetQuantumRange(image->depth)+1;\n      if (AcquireImageColormap(image,colors) == MagickFalse)\n        {\n          InheritException(exception,&image->exception);\n          return(DestroyImageList(image));\n        }\n    }\n  if (image->debug != MagickFalse)\n    {\n      if (image->interlace != NoInterlace)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Interlace: progressive\");\n      else\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Interlace: nonprogressive\");\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Data precision: %d\",\n        (int) jpeg_info.data_precision);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Geometry: %dx%d\",\n        (int) jpeg_info.output_width,(int) jpeg_info.output_height);\n    }\n  JPEGSetImageQuality(&jpeg_info,image);\n  JPEGSetImageSamplingFactor(&jpeg_info,image);\n  (void) FormatLocaleString(value,MaxTextExtent,\"%.20g\",(double)\n    jpeg_info.out_color_space);\n  (void) SetImageProperty(image,\"jpeg:colorspace\",value);\n  if (image_info->ping != MagickFalse)\n    {\n      jpeg_destroy_decompress(&jpeg_info);\n      (void) CloseBlob(image);\n      return(GetFirstImageInList(image));\n    }\n  status=SetImageExtent(image,image->columns,image->rows);\n  if (status == MagickFalse)\n    {\n      jpeg_destroy_decompress(&jpeg_info);\n      InheritException(exception,&image->exception);\n      return(DestroyImageList(image));\n    }\n  if ((jpeg_info.output_components != 1) &&\n      (jpeg_info.output_components != 3) && (jpeg_info.output_components != 4))\n    {\n      jpeg_destroy_decompress(&jpeg_info);\n      ThrowReaderException(CorruptImageError,\"ImageTypeNotSupported\");\n    }\n  memory_info=AcquireVirtualMemory((size_t) image->columns,\n    jpeg_info.output_components*sizeof(*jpeg_pixels));\n  if (memory_info == (MemoryInfo *) NULL)\n    {\n      jpeg_destroy_decompress(&jpeg_info);\n       ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n     }\n   jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info);\n  (void) ResetMagickMemory(jpeg_pixels,0,image->columns* \n    jpeg_info.output_components*sizeof(*jpeg_pixels));\n   \/*\n     Convert JPEG pixels to pixel packets.\n   *\/\n  if (setjmp(error_manager.error_recovery) != 0)\n    {\n      if (memory_info != (MemoryInfo *) NULL)\n        memory_info=RelinquishVirtualMemory(memory_info);\n      jpeg_destroy_decompress(&jpeg_info);\n      (void) CloseBlob(image);\n      number_pixels=(MagickSizeType) image->columns*image->rows;\n      if (number_pixels != 0)\n        return(GetFirstImageInList(image));\n      return(DestroyImage(image));\n    }\n  if (jpeg_info.quantize_colors != 0)\n    {\n      image->colors=(size_t) jpeg_info.actual_number_of_colors;\n      if (jpeg_info.out_color_space == JCS_GRAYSCALE)\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);\n          image->colormap[i].green=image->colormap[i].red;\n          image->colormap[i].blue=image->colormap[i].red;\n          image->colormap[i].opacity=OpaqueOpacity;\n        }\n      else\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);\n          image->colormap[i].green=ScaleCharToQuantum(jpeg_info.colormap[1][i]);\n          image->colormap[i].blue=ScaleCharToQuantum(jpeg_info.colormap[2][i]);\n          image->colormap[i].opacity=OpaqueOpacity;\n        }\n    }\n  scanline[0]=(JSAMPROW) jpeg_pixels;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    register IndexPacket\n      *magick_restrict indexes;\n\n    register ssize_t\n      x;\n\n    register PixelPacket\n      *magick_restrict q;\n\n    if (jpeg_read_scanlines(&jpeg_info,scanline,1) != 1)\n      {\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          CorruptImageWarning,\"SkipToSyncByte\",\"`%s'\",image->filename);\n        continue;\n      }\n    p=jpeg_pixels;\n    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n    if (q == (PixelPacket *) NULL)\n      break;\n    indexes=GetAuthenticIndexQueue(image);\n    if (jpeg_info.data_precision > 8)\n      {\n        unsigned short\n          scale;\n\n        scale=65535\/(unsigned short) GetQuantumRange((size_t)\n          jpeg_info.data_precision);\n        if (jpeg_info.output_components == 1)\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            size_t\n              pixel;\n\n            pixel=(size_t) (scale*GETJSAMPLE(*p));\n            index=ConstrainColormapIndex(image,pixel);\n            SetPixelIndex(indexes+x,index);\n            SetPixelRGBO(q,image->colormap+(ssize_t) index);\n            p++;\n            q++;\n          }\n        else\n          if (image->colorspace != CMYKColorspace)\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              SetPixelRed(q,ScaleShortToQuantum((unsigned short)\n                (scale*GETJSAMPLE(*p++))));\n              SetPixelGreen(q,ScaleShortToQuantum((unsigned short)\n                (scale*GETJSAMPLE(*p++))));\n              SetPixelBlue(q,ScaleShortToQuantum((unsigned short)\n                (scale*GETJSAMPLE(*p++))));\n              SetPixelOpacity(q,OpaqueOpacity);\n              q++;\n            }\n          else\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              SetPixelCyan(q,QuantumRange-ScaleShortToQuantum(\n                (unsigned short) (scale*GETJSAMPLE(*p++))));\n              SetPixelMagenta(q,QuantumRange-ScaleShortToQuantum(\n                (unsigned short) (scale*GETJSAMPLE(*p++))));\n              SetPixelYellow(q,QuantumRange-ScaleShortToQuantum(\n                (unsigned short) (scale*GETJSAMPLE(*p++))));\n              SetPixelBlack(indexes+x,QuantumRange-ScaleShortToQuantum(\n                (unsigned short) (scale*GETJSAMPLE(*p++))));\n              SetPixelOpacity(q,OpaqueOpacity);\n              q++;\n            }\n      }\n    else\n      if (jpeg_info.output_components == 1)\n        for (x=0; x < (ssize_t) image->columns; x++)\n        {\n          index=ConstrainColormapIndex(image,(size_t) GETJSAMPLE(*p));\n          SetPixelIndex(indexes+x,index);\n          SetPixelRGBO(q,image->colormap+(ssize_t) index);\n          p++;\n          q++;\n        }\n      else\n        if (image->colorspace != CMYKColorspace)\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(q,ScaleCharToQuantum((unsigned char)\n              GETJSAMPLE(*p++)));\n            SetPixelGreen(q,ScaleCharToQuantum((unsigned char)\n              GETJSAMPLE(*p++)));\n            SetPixelBlue(q,ScaleCharToQuantum((unsigned char)\n              GETJSAMPLE(*p++)));\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n        else\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelCyan(q,QuantumRange-ScaleCharToQuantum((unsigned char)\n              GETJSAMPLE(*p++)));\n            SetPixelMagenta(q,QuantumRange-ScaleCharToQuantum((unsigned char)\n              GETJSAMPLE(*p++)));\n            SetPixelYellow(q,QuantumRange-ScaleCharToQuantum((unsigned char)\n              GETJSAMPLE(*p++)));\n            SetPixelBlack(indexes+x,QuantumRange-ScaleCharToQuantum(\n              (unsigned char) GETJSAMPLE(*p++)));\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n      image->rows);\n    if (status == MagickFalse)\n      {\n        jpeg_abort_decompress(&jpeg_info);\n        break;\n      }\n  }\n  if (status != MagickFalse)\n    {\n      error_manager.finished=MagickTrue;\n      if (setjmp(error_manager.error_recovery) == 0)\n        (void) jpeg_finish_decompress(&jpeg_info);\n    }\n  \/*\n    Free jpeg resources.\n  *\/\n  jpeg_destroy_decompress(&jpeg_info);\n  memory_info=RelinquishVirtualMemory(memory_info);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}\n","target":0,"code_token_length":4255,"total_token_length":4491,"max_tokens_setting":6144}
+{"idx":429086,"func":"static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define ThrowPCXException(severity,tag) \\\n{ \\\n  if (scanline != (unsigned char *) NULL) \\\n    scanline=(unsigned char *) RelinquishMagickMemory(scanline); \\\n  if (pixel_info != (MemoryInfo *) NULL) \\\n    pixel_info=RelinquishVirtualMemory(pixel_info); \\\n  if (page_table != (MagickOffsetType *) NULL) \\\n    page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table); \\\n  ThrowReaderException(severity,tag); \\\n}\n\n  Image\n    *image;\n\n  int\n    bits,\n    id,\n    mask;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    *page_table;\n\n  MemoryInfo\n    *pixel_info;\n\n  PCXInfo\n    pcx_info;\n\n  register IndexPacket\n    *indexes;\n\n  register ssize_t\n    x;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    i;\n\n  register unsigned char\n    *p,\n    *r;\n\n  size_t\n    one,\n    pcx_packets;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    packet,\n    pcx_colormap[768],\n    *pixels,\n    *scanline;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Determine if this a PCX file.\n  *\/\n  page_table=(MagickOffsetType *) NULL;\n  scanline=(unsigned char *) NULL;\n  pixel_info=(MemoryInfo *) NULL;\n  if (LocaleCompare(image_info->magick,\"DCX\") == 0)\n    {\n      size_t\n        magic;\n\n      \/*\n        Read the DCX page table.\n      *\/\n      magic=ReadBlobLSBLong(image);\n      if (magic != 987654321)\n        ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n      page_table=(MagickOffsetType *) AcquireQuantumMemory(1024UL,\n        sizeof(*page_table));\n      if (page_table == (MagickOffsetType *) NULL)\n        ThrowPCXException(ResourceLimitError,\"MemoryAllocationFailed\");\n      for (id=0; id < 1024; id++)\n      {\n        page_table[id]=(MagickOffsetType) ReadBlobLSBLong(image);\n        if (page_table[id] == 0)\n          break;\n      }\n    }\n  if (page_table != (MagickOffsetType *) NULL)\n    {\n      offset=SeekBlob(image,(MagickOffsetType) page_table[0],SEEK_SET);\n      if (offset < 0)\n        ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    }\n  count=ReadBlob(image,1,&pcx_info.identifier);\n  for (id=1; id < 1024; id++)\n  {\n    int\n      bits_per_pixel;\n\n    \/*\n      Verify PCX identifier.\n    *\/\n    pcx_info.version=(unsigned char) ReadBlobByte(image);\n    if ((count != 1) || (pcx_info.identifier != 0x0a))\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    pcx_info.encoding=(unsigned char) ReadBlobByte(image);\n    bits_per_pixel=ReadBlobByte(image);\n    if (bits_per_pixel == -1)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    pcx_info.bits_per_pixel=(unsigned char) bits_per_pixel;\n    pcx_info.left=ReadBlobLSBShort(image);\n    pcx_info.top=ReadBlobLSBShort(image);\n    pcx_info.right=ReadBlobLSBShort(image);\n    pcx_info.bottom=ReadBlobLSBShort(image);\n    pcx_info.horizontal_resolution=ReadBlobLSBShort(image);\n    pcx_info.vertical_resolution=ReadBlobLSBShort(image);\n    \/*\n      Read PCX raster colormap.\n    *\/\n    image->columns=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.right-\n      pcx_info.left)+1UL;\n    image->rows=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.bottom-\n      pcx_info.top)+1UL;\n    if ((image->columns == 0) || (image->rows == 0) ||\n        ((pcx_info.bits_per_pixel != 1) && (pcx_info.bits_per_pixel != 2) &&\n         (pcx_info.bits_per_pixel != 4) && (pcx_info.bits_per_pixel != 8)))\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    image->depth=pcx_info.bits_per_pixel;\n    image->units=PixelsPerInchResolution;\n    image->x_resolution=(double) pcx_info.horizontal_resolution;\n    image->y_resolution=(double) pcx_info.vertical_resolution;\n    image->colors=16;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      ThrowPCXException(image->exception.severity,image->exception.reason);\n    (void) SetImageBackgroundColor(image);\n    (void) memset(pcx_colormap,0,sizeof(pcx_colormap));\n    count=ReadBlob(image,3*image->colors,pcx_colormap);\n    if (count != (ssize_t) (3*image->colors))\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    pcx_info.reserved=(unsigned char) ReadBlobByte(image);\n    pcx_info.planes=(unsigned char) ReadBlobByte(image);\n    if (pcx_info.planes > 6)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    if (pcx_info.planes == 0)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    one=1;\n    if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))\n      if ((pcx_info.version == 3) || (pcx_info.version == 5) ||\n          ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))\n        image->colors=(size_t) MagickMin(one << (1UL*\n          (pcx_info.bits_per_pixel*pcx_info.planes)),256UL);\n    if (AcquireImageColormap(image,image->colors) == MagickFalse)\n      ThrowPCXException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1))\n      image->storage_class=DirectClass;\n    p=pcx_colormap;\n    for (i=0; i < (ssize_t) image->colors; i++)\n    {\n      image->colormap[i].red=ScaleCharToQuantum(*p++);\n      image->colormap[i].green=ScaleCharToQuantum(*p++);\n      image->colormap[i].blue=ScaleCharToQuantum(*p++);\n    }\n    pcx_info.bytes_per_line=ReadBlobLSBShort(image);\n    pcx_info.palette_info=ReadBlobLSBShort(image);\n    pcx_info.horizontal_screensize=ReadBlobLSBShort(image);\n    pcx_info.vertical_screensize=ReadBlobLSBShort(image);\n    for (i=0; i < 54; i++)\n      (void) ReadBlobByte(image);\n    \/*\n      Read image data.\n    *\/\n    if (HeapOverflowSanityCheck(image->rows, (size_t) pcx_info.bytes_per_line) != MagickFalse)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    pcx_packets=(size_t) image->rows*pcx_info.bytes_per_line;\n    if (HeapOverflowSanityCheck(pcx_packets, (size_t) pcx_info.planes) != MagickFalse)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    pcx_packets=(size_t) pcx_packets*pcx_info.planes;\n    if ((size_t) (pcx_info.bits_per_pixel*pcx_info.planes*image->columns) >\n        (pcx_packets*8U))\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    if ((MagickSizeType) (pcx_packets\/8) > GetBlobSize(image))\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    scanline=(unsigned char *) AcquireQuantumMemory(MagickMax(image->columns,\n      pcx_info.bytes_per_line),MagickMax(pcx_info.planes,8)*sizeof(*scanline));\n    pixel_info=AcquireVirtualMemory(pcx_packets,2*sizeof(*pixels));\n    if ((scanline == (unsigned char *) NULL) ||\n        (pixel_info == (MemoryInfo *) NULL))\n      {\n        if (scanline != (unsigned char *) NULL)\n          scanline=(unsigned char *) RelinquishMagickMemory(scanline);\n        if (pixel_info != (MemoryInfo *) NULL)\n          pixel_info=RelinquishVirtualMemory(pixel_info);\n        ThrowPCXException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n    (void) memset(scanline,0,(size_t) MagickMax(image->columns,\n      pcx_info.bytes_per_line)*MagickMax(pcx_info.planes,8)*sizeof(*scanline));\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    (void) memset(pixels,0,(size_t) pcx_packets*(2*sizeof(*pixels)));\n    \/*\n      Uncompress image data.\n    *\/\n    p=pixels;\n    if (pcx_info.encoding == 0)\n      while (pcx_packets != 0)\n      {\n        packet=(unsigned char) ReadBlobByte(image);\n        if (EOFBlob(image) != MagickFalse)\n          ThrowPCXException(CorruptImageError,\"UnexpectedEndOfFile\");\n        *p++=packet;\n        pcx_packets--;\n      }\n    else\n      while (pcx_packets != 0)\n      {\n        packet=(unsigned char) ReadBlobByte(image);\n        if (EOFBlob(image) != MagickFalse)\n          ThrowPCXException(CorruptImageError,\"UnexpectedEndOfFile\");\n        if ((packet & 0xc0) != 0xc0)\n          {\n            *p++=packet;\n            pcx_packets--;\n            continue;\n          }\n        count=(ssize_t) (packet & 0x3f);\n        packet=(unsigned char) ReadBlobByte(image);\n        if (EOFBlob(image) != MagickFalse)\n          ThrowPCXException(CorruptImageError,\"UnexpectedEndOfFile\");\n        for ( ; count != 0; count--)\n        {\n          *p++=packet;\n          pcx_packets--;\n          if (pcx_packets == 0)\n            break;\n        }\n      }\n    if (image->storage_class == DirectClass)\n      image->matte=pcx_info.planes > 3 ? MagickTrue : MagickFalse;\n    else\n      if ((pcx_info.version == 5) ||\n          ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))\n        {\n          \/*\n            Initialize image colormap.\n          *\/\n          if (image->colors > 256)\n            ThrowPCXException(CorruptImageError,\"ColormapExceeds256Colors\");\n          if ((pcx_info.bits_per_pixel*pcx_info.planes) == 1)\n            {\n              \/*\n                Monochrome colormap.\n              *\/\n              image->colormap[0].red=(Quantum) 0;\n              image->colormap[0].green=(Quantum) 0;\n              image->colormap[0].blue=(Quantum) 0;\n              image->colormap[1].red=QuantumRange;\n              image->colormap[1].green=QuantumRange;\n              image->colormap[1].blue=QuantumRange;\n            }\n          else\n            if (image->colors > 16)\n              {\n                \/*\n                  256 color images have their color map at the end of the file.\n                *\/\n                pcx_info.colormap_signature=(unsigned char) ReadBlobByte(image);\n                count=ReadBlob(image,3*image->colors,pcx_colormap);\n                p=pcx_colormap;\n                for (i=0; i < (ssize_t) image->colors; i++)\n                {\n                  image->colormap[i].red=ScaleCharToQuantum(*p++);\n                  image->colormap[i].green=ScaleCharToQuantum(*p++);\n                  image->colormap[i].blue=ScaleCharToQuantum(*p++);\n                }\n            }\n        }\n    \/*\n      Convert PCX raster image to pixel packets.\n    *\/\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      p=pixels+(y*pcx_info.bytes_per_line*pcx_info.planes);\n      q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n      if (q == (PixelPacket *) NULL)\n        break;\n      indexes=GetAuthenticIndexQueue(image);\n      r=scanline;\n      if (image->storage_class == DirectClass)\n        for (i=0; i < pcx_info.planes; i++)\n        {\n          r=scanline+i;\n          for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)\n          {\n            switch (i)\n            {\n              case 0:\n              {\n                *r=(*p++);\n                break;\n              }\n              case 1:\n              {\n                *r=(*p++);\n                break;\n              }\n              case 2:\n              {\n                *r=(*p++);\n                break;\n              }\n              case 3:\n              default:\n              {\n                *r=(*p++);\n                break;\n              }\n            }\n            r+=pcx_info.planes;\n          }\n        }\n      else\n        if (pcx_info.planes > 1)\n          {\n            for (x=0; x < (ssize_t) image->columns; x++)\n              *r++=0;\n            for (i=0; i < pcx_info.planes; i++)\n            {\n              r=scanline;\n              for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)\n              {\n                 bits=(*p++);\n                 for (mask=0x80; mask != 0; mask>>=1)\n                 {\n                   if (bits & mask)\n                     *r|=1 << i;\n                   r++;\n                 }\n               }\n            }\n          }\n        else\n          switch (pcx_info.bits_per_pixel)\n          {\n            case 1:\n            {\n              register ssize_t\n                bit;\n\n              for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n              {\n                for (bit=7; bit >= 0; bit--)\n                  *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00);\n                p++;\n              }\n              if ((image->columns % 8) != 0)\n                {\n                  for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--)\n                    *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00);\n                  p++;\n                }\n              break;\n            }\n            case 2:\n            {\n              for (x=0; x < ((ssize_t) image->columns-3); x+=4)\n              {\n                *r++=(*p >> 6) & 0x3;\n                *r++=(*p >> 4) & 0x3;\n                *r++=(*p >> 2) & 0x3;\n                *r++=(*p) & 0x3;\n                p++;\n              }\n              if ((image->columns % 4) != 0)\n                {\n                  for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--)\n                    *r++=(unsigned char) ((*p >> (i*2)) & 0x03);\n                  p++;\n                }\n              break;\n            }\n            case 4:\n            {\n              for (x=0; x < ((ssize_t) image->columns-1); x+=2)\n              {\n                *r++=(*p >> 4) & 0xf;\n                *r++=(*p) & 0xf;\n                p++;\n              }\n              if ((image->columns % 2) != 0)\n                *r++=(*p++ >> 4) & 0xf;\n              break;\n            }\n            case 8:\n            {\n              (void) memcpy(r,p,image->columns);\n              break;\n            }\n            default:\n              break;\n          }\n      \/*\n        Transfer image scanline.\n      *\/\n      r=scanline;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        if (image->storage_class == PseudoClass)\n          SetPixelIndex(indexes+x,*r++);\n        else\n          {\n            SetPixelRed(q,ScaleCharToQuantum(*r++));\n            SetPixelGreen(q,ScaleCharToQuantum(*r++));\n            SetPixelBlue(q,ScaleCharToQuantum(*r++));\n            if (image->matte != MagickFalse)\n              SetPixelAlpha(q,ScaleCharToQuantum(*r++));\n          }\n        q++;\n      }\n      if (SyncAuthenticPixels(image,exception) == MagickFalse)\n        break;\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    if (image->storage_class == PseudoClass)\n      (void) SyncImage(image);\n    scanline=(unsigned char *) RelinquishMagickMemory(scanline);\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    if (page_table == (MagickOffsetType *) NULL)\n      break;\n    if (page_table[id] == 0)\n      break;\n    offset=SeekBlob(image,(MagickOffsetType) page_table[id],SEEK_SET);\n    if (offset < 0)\n      ThrowPCXException(CorruptImageError,\"ImproperImageHeader\");\n    count=ReadBlob(image,1,&pcx_info.identifier);\n    if ((count != 0) && (pcx_info.identifier == 0x0a))\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  }\n  if (page_table != (MagickOffsetType *) NULL)\n    page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":4451,"total_token_length":4687,"max_tokens_setting":6144}
+{"idx":310038,"func":"static MagickBooleanType WriteGIFImage(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  int\n    c;\n\n  ImageInfo\n    *write_info;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  RectangleInfo\n    page;\n\n  register ssize_t\n    i;\n\n  register unsigned char\n    *q;\n\n  size_t\n    bits_per_pixel,\n    delay,\n    imageListLength,\n    length,\n    one;\n\n  ssize_t\n    j,\n    opacity;\n\n  unsigned char\n    *colormap,\n    *global_colormap;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  \/*\n    Allocate colormap.\n  *\/\n  global_colormap=(unsigned char *) AcquireQuantumMemory(768UL,\n    sizeof(*global_colormap));\n  colormap=(unsigned char *) AcquireQuantumMemory(768UL,sizeof(*colormap));\n  if ((global_colormap == (unsigned char *) NULL) ||\n      (colormap == (unsigned char *) NULL))\n    {\n      if (global_colormap != (unsigned char *) NULL)\n        global_colormap=(unsigned char *) RelinquishMagickMemory(\n          global_colormap);\n      if (colormap != (unsigned char *) NULL)\n        colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    }\n  for (i=0; i < 768; i++)\n    colormap[i]=(unsigned char) 0;\n  \/*\n    Write GIF header.\n  *\/\n  write_info=CloneImageInfo(image_info);\n  if (LocaleCompare(write_info->magick,\"GIF87\") != 0)\n    (void) WriteBlob(image,6,(unsigned char *) \"GIF89a\");\n  else\n    {\n      (void) WriteBlob(image,6,(unsigned char *) \"GIF87a\");\n      write_info->adjoin=MagickFalse;\n    }\n  \/*\n    Determine image bounding box.\n  *\/\n  page.width=image->columns;\n  if (image->page.width > page.width)\n    page.width=image->page.width;\n  page.height=image->rows;\n  if (image->page.height > page.height)\n    page.height=image->page.height;\n  page.x=image->page.x;\n  page.y=image->page.y;\n  (void) WriteBlobLSBShort(image,(unsigned short) page.width);\n  (void) WriteBlobLSBShort(image,(unsigned short) page.height);\n  \/*\n    Write images to file.\n  *\/\n  if ((write_info->adjoin != MagickFalse) &&\n      (GetNextImageInList(image) != (Image *) NULL))\n    write_info->interlace=NoInterlace;\n  scene=0;\n  one=1;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    (void) TransformImageColorspace(image,sRGBColorspace,exception);\n    opacity=(-1);\n    if (IsImageOpaque(image,exception) != MagickFalse)\n      {\n        if ((image->storage_class == DirectClass) || (image->colors > 256))\n          (void) SetImageType(image,PaletteType,exception);\n      }\n    else\n      {\n        double\n          alpha,\n          beta;\n\n        \/*\n          Identify transparent colormap index.\n        *\/\n        if ((image->storage_class == DirectClass) || (image->colors > 256))\n          (void) SetImageType(image,PaletteBilevelAlphaType,exception);\n        for (i=0; i < (ssize_t) image->colors; i++)\n          if (image->colormap[i].alpha != OpaqueAlpha)\n            {\n              if (opacity < 0)\n                {\n                  opacity=i;\n                  continue;\n                }\n              alpha=fabs(image->colormap[i].alpha-TransparentAlpha);\n              beta=fabs(image->colormap[opacity].alpha-TransparentAlpha);\n              if (alpha < beta)\n                opacity=i;\n            }\n        if (opacity == -1)\n          {\n            (void) SetImageType(image,PaletteBilevelAlphaType,exception);\n            for (i=0; i < (ssize_t) image->colors; i++)\n              if (image->colormap[i].alpha != OpaqueAlpha)\n                {\n                  if (opacity < 0)\n                    {\n                      opacity=i;\n                      continue;\n                    }\n                  alpha=fabs(image->colormap[i].alpha-TransparentAlpha);\n                  beta=fabs(image->colormap[opacity].alpha-TransparentAlpha);\n                  if (alpha < beta)\n                    opacity=i;\n                }\n          }\n        if (opacity >= 0)\n          {\n            image->colormap[opacity].red=image->transparent_color.red;\n            image->colormap[opacity].green=image->transparent_color.green;\n            image->colormap[opacity].blue=image->transparent_color.blue;\n          }\n      }\n    if ((image->storage_class == DirectClass) || (image->colors > 256))\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    for (bits_per_pixel=1; bits_per_pixel < 8; bits_per_pixel++)\n      if ((one << bits_per_pixel) >= image->colors)\n        break;\n    q=colormap;\n    for (i=0; i < (ssize_t) image->colors; i++)\n    {\n      *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].red));\n      *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].green));\n      *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].blue));\n    }\n    for ( ; i < (ssize_t) (one << bits_per_pixel); i++)\n    {\n      *q++=(unsigned char) 0x0;\n      *q++=(unsigned char) 0x0;\n      *q++=(unsigned char) 0x0;\n    }\n    if ((GetPreviousImageInList(image) == (Image *) NULL) ||\n        (write_info->adjoin == MagickFalse))\n      {\n        \/*\n          Write global colormap.\n        *\/\n        c=0x80;\n        c|=(8-1) << 4;  \/* color resolution *\/\n        c|=(bits_per_pixel-1);   \/* size of global colormap *\/\n        (void) WriteBlobByte(image,(unsigned char) c);\n        for (j=0; j < (ssize_t) image->colors; j++)\n          if (IsPixelInfoEquivalent(&image->background_color,image->colormap+j))\n            break;\n        (void) WriteBlobByte(image,(unsigned char)\n          (j == (ssize_t) image->colors ? 0 : j));  \/* background color *\/\n        (void) WriteBlobByte(image,(unsigned char) 0x00);  \/* reserved *\/\n        length=(size_t) (3*(one << bits_per_pixel));\n        (void) WriteBlob(image,length,colormap);\n        for (j=0; j < 768; j++)\n          global_colormap[j]=colormap[j];\n      }\n    if (LocaleCompare(write_info->magick,\"GIF87\") != 0)\n      {\n        const char\n          *value;\n\n        \/*\n          Write graphics control extension.\n        *\/\n        (void) WriteBlobByte(image,(unsigned char) 0x21);\n        (void) WriteBlobByte(image,(unsigned char) 0xf9);\n        (void) WriteBlobByte(image,(unsigned char) 0x04);\n        c=image->dispose << 2;\n        if (opacity >= 0)\n          c|=0x01;\n        (void) WriteBlobByte(image,(unsigned char) c);\n        delay=(size_t) (100*image->delay\/MagickMax((size_t)\n          image->ticks_per_second,1));\n        (void) WriteBlobLSBShort(image,(unsigned short) delay);\n        (void) WriteBlobByte(image,(unsigned char) (opacity >= 0 ? opacity :\n          0));\n        (void) WriteBlobByte(image,(unsigned char) 0x00);\n        value=GetImageProperty(image,\"comment\",exception);\n        if (value != (const char *) NULL)\n          {\n            register const char\n              *p;\n\n            size_t\n              count;\n\n            \/*\n              Write comment extension.\n            *\/\n            (void) WriteBlobByte(image,(unsigned char) 0x21);\n            (void) WriteBlobByte(image,(unsigned char) 0xfe);\n            for (p=value; *p != '\\0'; )\n            {\n              count=MagickMin(strlen(p),255);\n              (void) WriteBlobByte(image,(unsigned char) count);\n              for (i=0; i < (ssize_t) count; i++)\n                (void) WriteBlobByte(image,(unsigned char) *p++);\n            }\n            (void) WriteBlobByte(image,(unsigned char) 0x00);\n          }\n        if ((GetPreviousImageInList(image) == (Image *) NULL) &&\n            (GetNextImageInList(image) != (Image *) NULL) &&\n            (image->iterations != 1))\n          {\n            \/*\n              Write Netscape Loop extension.\n            *\/\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n               \"  Writing GIF Extension %s\",\"NETSCAPE2.0\");\n            (void) WriteBlobByte(image,(unsigned char) 0x21);\n            (void) WriteBlobByte(image,(unsigned char) 0xff);\n            (void) WriteBlobByte(image,(unsigned char) 0x0b);\n            (void) WriteBlob(image,11,(unsigned char *) \"NETSCAPE2.0\");\n            (void) WriteBlobByte(image,(unsigned char) 0x03);\n            (void) WriteBlobByte(image,(unsigned char) 0x01);\n            (void) WriteBlobLSBShort(image,(unsigned short) (image->iterations ?\n              image->iterations-1 : 0));\n            (void) WriteBlobByte(image,(unsigned char) 0x00);\n          }\n        if ((image->gamma != 1.0f\/2.2f))\n          {\n            char\n              attributes[MagickPathExtent];\n\n            ssize_t\n              count;\n\n            \/*\n              Write ImageMagick extension.\n            *\/\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n               \"  Writing GIF Extension %s\",\"ImageMagick\");\n            (void) WriteBlobByte(image,(unsigned char) 0x21);\n            (void) WriteBlobByte(image,(unsigned char) 0xff);\n            (void) WriteBlobByte(image,(unsigned char) 0x0b);\n            (void) WriteBlob(image,11,(unsigned char *) \"ImageMagick\");\n            count=FormatLocaleString(attributes,MagickPathExtent,\"gamma=%g\",\n              image->gamma);\n            (void) WriteBlobByte(image,(unsigned char) count);\n            (void) WriteBlob(image,(size_t) count,(unsigned char *) attributes);\n            (void) WriteBlobByte(image,(unsigned char) 0x00);\n          }\n        ResetImageProfileIterator(image);\n        for ( ; ; )\n        {\n          char\n            *name;\n\n          const StringInfo\n            *profile;\n\n          name=GetNextImageProfile(image);\n          if (name == (const char *) NULL)\n            break;\n          profile=GetImageProfile(image,name);\n          if (profile != (StringInfo *) NULL)\n          {\n            if ((LocaleCompare(name,\"ICC\") == 0) ||\n                (LocaleCompare(name,\"ICM\") == 0) ||\n                (LocaleCompare(name,\"IPTC\") == 0) ||\n                (LocaleCompare(name,\"8BIM\") == 0) ||\n                (LocaleNCompare(name,\"gif:\",4) == 0))\n            {\n               ssize_t\n                 offset;\n\n               unsigned char\n                 *datum;\n\n               datum=GetStringInfoDatum(profile);\n               length=GetStringInfoLength(profile);\n               (void) WriteBlobByte(image,(unsigned char) 0x21);\n               (void) WriteBlobByte(image,(unsigned char) 0xff);\n               (void) WriteBlobByte(image,(unsigned char) 0x0b);\n               if ((LocaleCompare(name,\"ICC\") == 0) ||\n                   (LocaleCompare(name,\"ICM\") == 0))\n                 {\n                   \/*\n                     Write ICC extension.\n                   *\/\n                   (void) WriteBlob(image,11,(unsigned char *) \"ICCRGBG1012\");\n                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                     \"  Writing GIF Extension %s\",\"ICCRGBG1012\");\n                 }\n               else\n                 if ((LocaleCompare(name,\"IPTC\") == 0))\n                   {\n                     \/*\n                       Write IPTC extension.\n                     *\/\n                     (void) WriteBlob(image,11,(unsigned char *) \"MGKIPTC0000\");\n                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                       \"  Writing GIF Extension %s\",\"MGKIPTC0000\");\n                   }\n                 else\n                   if ((LocaleCompare(name,\"8BIM\") == 0))\n                     {\n                       \/*\n                         Write 8BIM extension.\n                       *\/\n                        (void) WriteBlob(image,11,(unsigned char *)\n                          \"MGK8BIM0000\");\n                        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                          \"  Writing GIF Extension %s\",\"MGK8BIM0000\");\n                     }\n                   else\n                     {\n                       char\n                         extension[MagickPathExtent];\n\n                       \/*\n                         Write generic extension.\n                       *\/\n                       (void) CopyMagickString(extension,name+4,\n                         sizeof(extension));\n                       (void) WriteBlob(image,11,(unsigned char *) extension);\n                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                         \"  Writing GIF Extension %s\",name);\n                     }\n               offset=0;\n               while ((ssize_t) length > offset)\n               {\n                 size_t\n                   block_length;\n\n                 if ((length-offset) < 255)\n                   block_length=length-offset;\n                 else\n                   block_length=255;\n                 (void) WriteBlobByte(image,(unsigned char) block_length);\n                 (void) WriteBlob(image,(size_t) block_length,datum+offset);\n                 offset+=(ssize_t) block_length;\n               }\n               (void) WriteBlobByte(image,(unsigned char) 0x00);\n            }\n          }\n        }\n      }\n    (void) WriteBlobByte(image,',');  \/* image separator *\/\n    \/*\n      Write the image header.\n    *\/\n    page.x=image->page.x;\n    page.y=image->page.y;\n    if ((image->page.width != 0) && (image->page.height != 0))\n      page=image->page;\n    (void) WriteBlobLSBShort(image,(unsigned short) (page.x < 0 ? 0 : page.x));\n    (void) WriteBlobLSBShort(image,(unsigned short) (page.y < 0 ? 0 : page.y));\n    (void) WriteBlobLSBShort(image,(unsigned short) image->columns);\n    (void) WriteBlobLSBShort(image,(unsigned short) image->rows);\n    c=0x00;\n    if (write_info->interlace != NoInterlace)\n      c|=0x40;  \/* pixel data is interlaced *\/\n    for (j=0; j < (ssize_t) (3*image->colors); j++)\n      if (colormap[j] != global_colormap[j])\n        break;\n    if (j == (ssize_t) (3*image->colors))\n      (void) WriteBlobByte(image,(unsigned char) c);\n    else\n      {\n        c|=0x80;\n        c|=(bits_per_pixel-1);   \/* size of local colormap *\/\n        (void) WriteBlobByte(image,(unsigned char) c);\n        length=(size_t) (3*(one << bits_per_pixel));\n        (void) WriteBlob(image,length,colormap);\n      }\n    \/*\n      Write the image data.\n    *\/\n    c=(int) MagickMax(bits_per_pixel,2);\n    (void) WriteBlobByte(image,(unsigned char) c);\n    status=EncodeImage(write_info,image,(size_t) MagickMax(bits_per_pixel,2)+1,\n      exception);\n    if (status == MagickFalse)\n      {\n        global_colormap=(unsigned char *) RelinquishMagickMemory(\n          global_colormap);\n        colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n        write_info=DestroyImageInfo(write_info);\n        ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n    (void) WriteBlobByte(image,(unsigned char) 0x00);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    scene++;\n    status=SetImageProgress(image,SaveImagesTag,scene,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (write_info->adjoin != MagickFalse);\n  (void) WriteBlobByte(image,';'); \/* terminator *\/\n  global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);\n  colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n  write_info=DestroyImageInfo(write_info);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}\n","target":0,"code_token_length":3865,"total_token_length":4101,"max_tokens_setting":6144}
+{"idx":386380,"func":"\nstatic int\nxmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,\n                           xmlXPathStepOpPtr op,\n\t\t\t   xmlNodePtr * first, xmlNodePtr * last,\n\t\t\t   int toBool)\n{\n\n#define XP_TEST_HIT \\\n    if (hasAxisRange != 0) { \\\n\tif (++pos == maxPos) { \\\n\t    if (addNode(seq, cur) < 0) \\\n\t        ctxt->error = XPATH_MEMORY_ERROR; \\\n\t    goto axis_range_end; } \\\n    } else { \\\n\tif (addNode(seq, cur) < 0) \\\n\t    ctxt->error = XPATH_MEMORY_ERROR; \\\n\tif (breakOnFirstHit) goto first_hit; }\n\n#define XP_TEST_HIT_NS \\\n    if (hasAxisRange != 0) { \\\n\tif (++pos == maxPos) { \\\n\t    hasNsNodes = 1; \\\n\t    if (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \\\n\t        ctxt->error = XPATH_MEMORY_ERROR; \\\n\tgoto axis_range_end; } \\\n    } else { \\\n\thasNsNodes = 1; \\\n\tif (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \\\n\t    ctxt->error = XPATH_MEMORY_ERROR; \\\n\tif (breakOnFirstHit) goto first_hit; }\n\n    xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value;\n    xmlXPathTestVal test = (xmlXPathTestVal) op->value2;\n    xmlXPathTypeVal type = (xmlXPathTypeVal) op->value3;\n    const xmlChar *prefix = op->value4;\n    const xmlChar *name = op->value5;\n    const xmlChar *URI = NULL;\n\n#ifdef DEBUG_STEP\n    int nbMatches = 0, prevMatches = 0;\n#endif\n    int total = 0, hasNsNodes = 0;\n    \/* The popped object holding the context nodes *\/\n    xmlXPathObjectPtr obj;\n    \/* The set of context nodes for the node tests *\/\n    xmlNodeSetPtr contextSeq;\n    int contextIdx;\n    xmlNodePtr contextNode;\n    \/* The final resulting node set wrt to all context nodes *\/\n    xmlNodeSetPtr outSeq;\n    \/*\n    * The temporary resulting node set wrt 1 context node.\n    * Used to feed predicate evaluation.\n    *\/\n    xmlNodeSetPtr seq;\n    xmlNodePtr cur;\n    \/* First predicate operator *\/\n    xmlXPathStepOpPtr predOp;\n    int maxPos; \/* The requested position() (when a \"[n]\" predicate) *\/\n    int hasPredicateRange, hasAxisRange, pos, size, newSize;\n    int breakOnFirstHit;\n\n    xmlXPathTraversalFunction next = NULL;\n    int (*addNode) (xmlNodeSetPtr, xmlNodePtr);\n    xmlXPathNodeSetMergeFunction mergeAndClear;\n    xmlNodePtr oldContextNode;\n    xmlXPathContextPtr xpctxt = ctxt->context;\n\n\n    CHECK_TYPE0(XPATH_NODESET);\n    obj = valuePop(ctxt);\n    \/*\n    * Setup namespaces.\n    *\/\n    if (prefix != NULL) {\n        URI = xmlXPathNsLookup(xpctxt, prefix);\n        if (URI == NULL) {\n\t    xmlXPathReleaseObject(xpctxt, obj);\n            XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR);\n\t}\n    }\n    \/*\n    * Setup axis.\n    *\n    * MAYBE FUTURE TODO: merging optimizations:\n    * - If the nodes to be traversed wrt to the initial nodes and\n    *   the current axis cannot overlap, then we could avoid searching\n    *   for duplicates during the merge.\n    *   But the question is how\/when to evaluate if they cannot overlap.\n    *   Example: if we know that for two initial nodes, the one is\n    *   not in the ancestor-or-self axis of the other, then we could safely\n    *   avoid a duplicate-aware merge, if the axis to be traversed is e.g.\n    *   the descendant-or-self axis.\n    *\/\n    mergeAndClear = xmlXPathNodeSetMergeAndClear;\n    switch (axis) {\n        case AXIS_ANCESTOR:\n            first = NULL;\n            next = xmlXPathNextAncestor;\n            break;\n        case AXIS_ANCESTOR_OR_SELF:\n            first = NULL;\n            next = xmlXPathNextAncestorOrSelf;\n            break;\n        case AXIS_ATTRIBUTE:\n            first = NULL;\n\t    last = NULL;\n            next = xmlXPathNextAttribute;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n        case AXIS_CHILD:\n\t    last = NULL;\n\t    if (((test == NODE_TEST_NAME) || (test == NODE_TEST_ALL)) &&\n\t\t(type == NODE_TYPE_NODE))\n\t    {\n\t\t\/*\n\t\t* Optimization if an element node type is 'element'.\n\t\t*\/\n\t\tnext = xmlXPathNextChildElement;\n\t    } else\n\t\tnext = xmlXPathNextChild;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n        case AXIS_DESCENDANT:\n\t    last = NULL;\n            next = xmlXPathNextDescendant;\n            break;\n        case AXIS_DESCENDANT_OR_SELF:\n\t    last = NULL;\n            next = xmlXPathNextDescendantOrSelf;\n            break;\n        case AXIS_FOLLOWING:\n\t    last = NULL;\n            next = xmlXPathNextFollowing;\n            break;\n        case AXIS_FOLLOWING_SIBLING:\n\t    last = NULL;\n            next = xmlXPathNextFollowingSibling;\n            break;\n        case AXIS_NAMESPACE:\n            first = NULL;\n\t    last = NULL;\n            next = (xmlXPathTraversalFunction) xmlXPathNextNamespace;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n        case AXIS_PARENT:\n            first = NULL;\n            next = xmlXPathNextParent;\n            break;\n        case AXIS_PRECEDING:\n            first = NULL;\n            next = xmlXPathNextPrecedingInternal;\n            break;\n        case AXIS_PRECEDING_SIBLING:\n            first = NULL;\n            next = xmlXPathNextPrecedingSibling;\n            break;\n        case AXIS_SELF:\n            first = NULL;\n\t    last = NULL;\n            next = xmlXPathNextSelf;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n    }\n\n#ifdef DEBUG_STEP\n    xmlXPathDebugDumpStepAxis(op,\n\t(obj->nodesetval != NULL) ? obj->nodesetval->nodeNr : 0);\n#endif\n\n    if (next == NULL) {\n\txmlXPathReleaseObject(xpctxt, obj);\n        return(0);\n    }\n    contextSeq = obj->nodesetval;\n    if ((contextSeq == NULL) || (contextSeq->nodeNr <= 0)) {\n\txmlXPathReleaseObject(xpctxt, obj);\n        valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));\n        return(0);\n    }\n    \/*\n    * Predicate optimization ---------------------------------------------\n    * If this step has a last predicate, which contains a position(),\n    * then we'll optimize (although not exactly \"position()\", but only\n    * the  short-hand form, i.e., \"[n]\".\n    *\n    * Example - expression \"\/foo[parent::bar][1]\":\n    *\n    * COLLECT 'child' 'name' 'node' foo    -- op (we are here)\n    *   ROOT                               -- op->ch1\n    *   PREDICATE                          -- op->ch2 (predOp)\n    *     PREDICATE                          -- predOp->ch1 = [parent::bar]\n    *       SORT\n    *         COLLECT  'parent' 'name' 'node' bar\n    *           NODE\n    *     ELEM Object is a number : 1        -- predOp->ch2 = [1]\n    *\n    *\/\n    maxPos = 0;\n    predOp = NULL;\n    hasPredicateRange = 0;\n    hasAxisRange = 0;\n    if (op->ch2 != -1) {\n\t\/*\n\t* There's at least one predicate. 16 == XPATH_OP_PREDICATE\n\t*\/\n\tpredOp = &ctxt->comp->steps[op->ch2];\n\tif (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) {\n\t    if (predOp->ch1 != -1) {\n\t\t\/*\n\t\t* Use the next inner predicate operator.\n\t\t*\/\n\t\tpredOp = &ctxt->comp->steps[predOp->ch1];\n\t\thasPredicateRange = 1;\n\t    } else {\n\t\t\/*\n\t\t* There's no other predicate than the [n] predicate.\n\t\t*\/\n\t\tpredOp = NULL;\n\t\thasAxisRange = 1;\n\t    }\n\t}\n    }\n    breakOnFirstHit = ((toBool) && (predOp == NULL)) ? 1 : 0;\n    \/*\n    * Axis traversal -----------------------------------------------------\n    *\/\n    \/*\n     * 2.3 Node Tests\n     *  - For the attribute axis, the principal node type is attribute.\n     *  - For the namespace axis, the principal node type is namespace.\n     *  - For other axes, the principal node type is element.\n     *\n     * A node test * is true for any node of the\n     * principal node type. For example, child::* will\n     * select all element children of the context node\n     *\/\n    oldContextNode = xpctxt->node;\n    addNode = xmlXPathNodeSetAddUnique;\n    outSeq = NULL;\n    seq = NULL;\n    contextNode = NULL;\n    contextIdx = 0;\n\n\n    while (((contextIdx < contextSeq->nodeNr) || (contextNode != NULL)) &&\n           (ctxt->error == XPATH_EXPRESSION_OK)) {\n\txpctxt->node = contextSeq->nodeTab[contextIdx++];\n\n\tif (seq == NULL) {\n\t    seq = xmlXPathNodeSetCreate(NULL);\n\t    if (seq == NULL) {\n\t\ttotal = 0;\n\t\tgoto error;\n\t    }\n\t}\n\t\/*\n\t* Traverse the axis and test the nodes.\n\t*\/\n\tpos = 0;\n\tcur = NULL;\n\thasNsNodes = 0;\n        do {\n            cur = next(ctxt, cur);\n            if (cur == NULL)\n                break;\n\n\t    \/*\n\t    * QUESTION TODO: What does the \"first\" and \"last\" stuff do?\n\t    *\/\n            if ((first != NULL) && (*first != NULL)) {\n\t\tif (*first == cur)\n\t\t    break;\n\t\tif (((total % 256) == 0) &&\n#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON\n\t\t    (xmlXPathCmpNodesExt(*first, cur) >= 0))\n#else\n\t\t    (xmlXPathCmpNodes(*first, cur) >= 0))\n#endif\n\t\t{\n\t\t    break;\n\t\t}\n\t    }\n\t    if ((last != NULL) && (*last != NULL)) {\n\t\tif (*last == cur)\n\t\t    break;\n\t\tif (((total % 256) == 0) &&\n#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON\n\t\t    (xmlXPathCmpNodesExt(cur, *last) >= 0))\n#else\n\t\t    (xmlXPathCmpNodes(cur, *last) >= 0))\n#endif\n\t\t{\n\t\t    break;\n\t\t}\n\t    }\n\n            total++;\n\n#ifdef DEBUG_STEP\n            xmlGenericError(xmlGenericErrorContext, \" %s\", cur->name);\n#endif\n\n\t    switch (test) {\n                case NODE_TEST_NONE:\n\t\t    total = 0;\n                    STRANGE\n\t\t    goto error;\n                case NODE_TEST_TYPE:\n\t\t    \/*\n\t\t    * TODO: Don't we need to use\n\t\t    *  xmlXPathNodeSetAddNs() for namespace nodes here?\n\t\t    *  Surprisingly, some c14n tests fail, if we do this.\n\t\t    *\/\n\t\t    if (type == NODE_TYPE_NODE) {\n\t\t\tswitch (cur->type) {\n\t\t\t    case XML_DOCUMENT_NODE:\n\t\t\t    case XML_HTML_DOCUMENT_NODE:\n#ifdef LIBXML_DOCB_ENABLED\n\t\t\t    case XML_DOCB_DOCUMENT_NODE:\n#endif\n\t\t\t    case XML_ELEMENT_NODE:\n\t\t\t    case XML_ATTRIBUTE_NODE:\n\t\t\t    case XML_PI_NODE:\n\t\t\t    case XML_COMMENT_NODE:\n\t\t\t    case XML_CDATA_SECTION_NODE:\n\t\t\t    case XML_TEXT_NODE:\n\t\t\t    case XML_NAMESPACE_DECL:\n\t\t\t\tXP_TEST_HIT\n\t\t\t\tbreak;\n\t\t\t    default:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t    } else if (cur->type == type) {\n\t\t\tif (cur->type == XML_NAMESPACE_DECL)\n\t\t\t    XP_TEST_HIT_NS\n\t\t\telse\n\t\t\t    XP_TEST_HIT\n\t\t    } else if ((type == NODE_TYPE_TEXT) &&\n\t\t\t (cur->type == XML_CDATA_SECTION_NODE))\n\t\t    {\n\t\t\tXP_TEST_HIT\n\t\t    }\n\t\t    break;\n                case NODE_TEST_PI:\n                    if ((cur->type == XML_PI_NODE) &&\n                        ((name == NULL) || xmlStrEqual(name, cur->name)))\n\t\t    {\n\t\t\tXP_TEST_HIT\n                    }\n                    break;\n                case NODE_TEST_ALL:\n                    if (axis == AXIS_ATTRIBUTE) {\n                        if (cur->type == XML_ATTRIBUTE_NODE)\n\t\t\t{\n                            if (prefix == NULL)\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n                            } else if ((cur->ns != NULL) &&\n\t\t\t\t(xmlStrEqual(URI, cur->ns->href)))\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n                            }\n                        }\n                    } else if (axis == AXIS_NAMESPACE) {\n                        if (cur->type == XML_NAMESPACE_DECL)\n\t\t\t{\n\t\t\t    XP_TEST_HIT_NS\n                        }\n                    } else {\n                        if (cur->type == XML_ELEMENT_NODE) {\n                            if (prefix == NULL)\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n\n                            } else if ((cur->ns != NULL) &&\n\t\t\t\t(xmlStrEqual(URI, cur->ns->href)))\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n                            }\n                        }\n                    }\n                    break;\n                case NODE_TEST_NS:{\n                        TODO;\n                        break;\n                    }\n                case NODE_TEST_NAME:\n                    if (axis == AXIS_ATTRIBUTE) {\n                        if (cur->type != XML_ATTRIBUTE_NODE)\n\t\t\t    break;\n\t\t    } else if (axis == AXIS_NAMESPACE) {\n                        if (cur->type != XML_NAMESPACE_DECL)\n\t\t\t    break;\n\t\t    } else {\n\t\t        if (cur->type != XML_ELEMENT_NODE)\n\t\t\t    break;\n\t\t    }\n                    switch (cur->type) {\n                        case XML_ELEMENT_NODE:\n                            if (xmlStrEqual(name, cur->name)) {\n                                if (prefix == NULL) {\n                                    if (cur->ns == NULL)\n\t\t\t\t    {\n\t\t\t\t\tXP_TEST_HIT\n                                    }\n                                } else {\n                                    if ((cur->ns != NULL) &&\n                                        (xmlStrEqual(URI, cur->ns->href)))\n\t\t\t\t    {\n\t\t\t\t\tXP_TEST_HIT\n                                    }\n                                }\n                            }\n                            break;\n                        case XML_ATTRIBUTE_NODE:{\n                                xmlAttrPtr attr = (xmlAttrPtr) cur;\n\n                                if (xmlStrEqual(name, attr->name)) {\n                                    if (prefix == NULL) {\n                                        if ((attr->ns == NULL) ||\n                                            (attr->ns->prefix == NULL))\n\t\t\t\t\t{\n\t\t\t\t\t    XP_TEST_HIT\n                                        }\n                                    } else {\n                                        if ((attr->ns != NULL) &&\n                                            (xmlStrEqual(URI,\n\t\t\t\t\t      attr->ns->href)))\n\t\t\t\t\t{\n\t\t\t\t\t    XP_TEST_HIT\n                                        }\n                                    }\n                                }\n                                break;\n                            }\n                        case XML_NAMESPACE_DECL:\n                            if (cur->type == XML_NAMESPACE_DECL) {\n                                xmlNsPtr ns = (xmlNsPtr) cur;\n\n                                if ((ns->prefix != NULL) && (name != NULL)\n                                    && (xmlStrEqual(ns->prefix, name)))\n\t\t\t\t{\n\t\t\t\t    XP_TEST_HIT_NS\n                                }\n                            }\n                            break;\n                        default:\n                            break;\n                    }\n                    break;\n\t    } \/* switch(test) *\/\n        } while ((cur != NULL) && (ctxt->error == XPATH_EXPRESSION_OK));\n\n\tgoto apply_predicates;\n\naxis_range_end: \/* ----------------------------------------------------- *\/\n\t\/*\n\t* We have a \"\/foo[n]\", and position() = n was reached.\n\t* Note that we can have as well \"\/foo\/::parent::foo[1]\", so\n\t* a duplicate-aware merge is still needed.\n\t* Merge with the result.\n\t*\/\n\tif (outSeq == NULL) {\n\t    outSeq = seq;\n\t    seq = NULL;\n\t} else\n\t    outSeq = mergeAndClear(outSeq, seq, 0);\n\t\/*\n\t* Break if only a true\/false result was requested.\n\t*\/\n\tif (toBool)\n\t    break;\n\tcontinue;\n\nfirst_hit: \/* ---------------------------------------------------------- *\/\n\t\/*\n\t* Break if only a true\/false result was requested and\n\t* no predicates existed and a node test succeeded.\n\t*\/\n\tif (outSeq == NULL) {\n\t    outSeq = seq;\n\t    seq = NULL;\n\t} else\n\t    outSeq = mergeAndClear(outSeq, seq, 0);\n\tbreak;\n\n#ifdef DEBUG_STEP\n\tif (seq != NULL)\n\t    nbMatches += seq->nodeNr;\n#endif\n\napply_predicates: \/* --------------------------------------------------- *\/\n        if (ctxt->error != XPATH_EXPRESSION_OK)\n\t    goto error;\n\n        \/*\n\t* Apply predicates.\n\t*\/\n        if ((predOp != NULL) && (seq->nodeNr > 0)) {\n\t    \/*\n\t    * E.g. when we have a \"\/foo[some expression][n]\".\n\t    *\/\n\t    \/*\n\t    * QUESTION TODO: The old predicate evaluation took into\n\t    *  account location-sets.\n\t    *  (E.g. ctxt->value->type == XPATH_LOCATIONSET)\n\t    *  Do we expect such a set here?\n\t    *  All what I learned now from the evaluation semantics\n\t    *  does not indicate that a location-set will be processed\n\t    *  here, so this looks OK.\n\t    *\/\n\t    \/*\n\t    * Iterate over all predicates, starting with the outermost\n\t    * predicate.\n\t    * TODO: Problem: we cannot execute the inner predicates first\n\t    *  since we cannot go back *up* the operator tree!\n\t    *  Options we have:\n\t    *  1) Use of recursive functions (like is it currently done\n\t    *     via xmlXPathCompOpEval())\n\t    *  2) Add a predicate evaluation information stack to the\n\t    *     context struct\n\t    *  3) Change the way the operators are linked; we need a\n\t    *     \"parent\" field on xmlXPathStepOp\n\t    *\n\t    * For the moment, I'll try to solve this with a recursive\n\t    * function: xmlXPathCompOpEvalPredicate().\n\t    *\/\n\t    size = seq->nodeNr;\n\t    if (hasPredicateRange != 0)\n\t\tnewSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,\n\t\t    predOp, seq, size, maxPos, maxPos, hasNsNodes);\n\t    else\n\t\tnewSize = xmlXPathCompOpEvalPredicate(ctxt,\n\t\t    predOp, seq, size, hasNsNodes);\n\n\t    if (ctxt->error != XPATH_EXPRESSION_OK) {\n\t\ttotal = 0;\n\t\tgoto error;\n\t    }\n\t    \/*\n\t    * Add the filtered set of nodes to the result node set.\n\t    *\/\n\t    if (newSize == 0) {\n\t\t\/*\n\t\t* The predicates filtered all nodes out.\n\t\t*\/\n\t\txmlXPathNodeSetClear(seq, hasNsNodes);\n\t    } else if (seq->nodeNr > 0) {\n\t\t\/*\n\t\t* Add to result set.\n\t\t*\/\n\t\tif (outSeq == NULL) {\n\t\t    if (size != newSize) {\n\t\t\t\/*\n\t\t\t* We need to merge and clear here, since\n\t\t\t* the sequence will contained NULLed entries.\n\t\t\t*\/\n\t\t\toutSeq = mergeAndClear(NULL, seq, 1);\n\t\t    } else {\n\t\t\toutSeq = seq;\n\t\t\tseq = NULL;\n\t\t    }\n\t\t} else\n\t\t    outSeq = mergeAndClear(outSeq, seq,\n\t\t\t(size != newSize) ? 1: 0);\n\t\t\/*\n\t\t* Break if only a true\/false result was requested.\n\t\t*\/\n\t\tif (toBool)\n\t\t    break;\n\t    }\n        } else if (seq->nodeNr > 0) {\n\t    \/*\n\t    * Add to result set.\n\t    *\/\n\t    if (outSeq == NULL) {\n\t\toutSeq = seq;\n\t\tseq = NULL;\n\t    } else {\n\t\toutSeq = mergeAndClear(outSeq, seq, 0);\n\t    }\n\t}\n    }\n\nerror:\n    if ((obj->boolval) && (obj->user != NULL)) {\n\t\/*\n\t* QUESTION TODO: What does this do and why?\n\t* TODO: Do we have to do this also for the \"error\"\n\t* cleanup further down?\n\t*\/\n\tctxt->value->boolval = 1;\n\tctxt->value->user = obj->user;\n\tobj->user = NULL;\n\tobj->boolval = 0;\n    }\n    xmlXPathReleaseObject(xpctxt, obj);\n\n    \/*\n    * Ensure we return at least an emtpy set.\n    *\/\n    if (outSeq == NULL) {\n\tif ((seq != NULL) && (seq->nodeNr == 0))\n\t    outSeq = seq;\n\telse\n\t    outSeq = xmlXPathNodeSetCreate(NULL);\n        \/* XXX what if xmlXPathNodeSetCreate returned NULL here? *\/\n    }\n    if ((seq != NULL) && (seq != outSeq)) {\n\t xmlXPathFreeNodeSet(seq);\n    }\n    \/*\n    * Hand over the result. Better to push the set also in\n    * case of errors.\n    *\/\n    valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq));\n    \/*\n    * Reset the context node.\n    *\/\n    xpctxt->node = oldContextNode;\n\n#ifdef DEBUG_STEP\n    xmlGenericError(xmlGenericErrorContext,\n\t\"\\nExamined %d nodes, found %d nodes at that step\\n\",\n\ttotal, nbMatches);\n#endif\n","target":0,"code_token_length":4610,"total_token_length":4846,"max_tokens_setting":6144}
+{"idx":344880,"func":"\nprivate int\nmget(struct magic_set *ms, const unsigned char *s, struct magic *m,\n    size_t nbytes, size_t o, unsigned int cont_level, int mode, int text,\n    int flip, int recursion_level, int *printed_something,\n    int *need_separator, int *returnval)\n{\n\tuint32_t soffset, offset = ms->offset;\n\tuint32_t count = m->str_range;\n\tint rv, oneed_separator;\n\tchar *sbuf, *rbuf;\n\tunion VALUETYPE *p = &ms->ms_value;\n\tstruct mlist ml;\n\n\tif (recursion_level >= 20) {\n\t\tfile_error(ms, 0, \"recursion nesting exceeded\");\n\t\treturn -1;\n\t}\n\n\tif (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),\n\t    (uint32_t)nbytes, count) == -1)\n\t\treturn -1;\n\n\tif ((ms->flags & MAGIC_DEBUG) != 0) {\n\t\tfprintf(stderr, \"mget(type=%d, flag=%x, offset=%u, o=%zu, \"\n\t\t    \"nbytes=%zu, count=%u)\\n\", m->type, m->flag, offset, o,\n\t\t    nbytes, count);\n\t\tmdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));\n\t}\n\n\tif (m->flag & INDIR) {\n\t\tint off = m->in_offset;\n\t\tif (m->in_op & FILE_OPINDIRECT) {\n\t\t\tconst union VALUETYPE *q = CAST(const union VALUETYPE *,\n\t\t\t    ((const void *)(s + offset + off)));\n\t\t\tswitch (cvt_flip(m->in_type, flip)) {\n\t\t\tcase FILE_BYTE:\n\t\t\t\toff = q->b;\n\t\t\t\tbreak;\n\t\t\tcase FILE_SHORT:\n\t\t\t\toff = q->h;\n\t\t\t\tbreak;\n\t\t\tcase FILE_BESHORT:\n\t\t\t\toff = (short)((q->hs[0]<<8)|(q->hs[1]));\n\t\t\t\tbreak;\n\t\t\tcase FILE_LESHORT:\n\t\t\t\toff = (short)((q->hs[1]<<8)|(q->hs[0]));\n\t\t\t\tbreak;\n\t\t\tcase FILE_LONG:\n\t\t\t\toff = q->l;\n\t\t\t\tbreak;\n\t\t\tcase FILE_BELONG:\n\t\t\tcase FILE_BEID3:\n\t\t\t\toff = (int32_t)((q->hl[0]<<24)|(q->hl[1]<<16)|\n\t\t\t\t\t\t (q->hl[2]<<8)|(q->hl[3]));\n\t\t\t\tbreak;\n\t\t\tcase FILE_LEID3:\n\t\t\tcase FILE_LELONG:\n\t\t\t\toff = (int32_t)((q->hl[3]<<24)|(q->hl[2]<<16)|\n\t\t\t\t\t\t (q->hl[1]<<8)|(q->hl[0]));\n\t\t\t\tbreak;\n\t\t\tcase FILE_MELONG:\n\t\t\t\toff = (int32_t)((q->hl[1]<<24)|(q->hl[0]<<16)|\n\t\t\t\t\t\t (q->hl[3]<<8)|(q->hl[2]));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\tfprintf(stderr, \"indirect offs=%u\\n\", off);\n\t\t}\n\t\tswitch (cvt_flip(m->in_type, flip)) {\n\t\tcase FILE_BYTE:\n\t\t\tif (nbytes < (offset + 1))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = p->b & off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = p->b | off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = p->b ^ off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = p->b + off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = p->b - off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = p->b * off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = p->b \/ off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = p->b % off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = p->b;\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_BESHORT:\n\t\t\tif (nbytes < (offset + 2))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) &\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) |\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) ^\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) +\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) -\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) *\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) \/\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t\t (p->hs[1])) %\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = (short)((p->hs[0]<<8)|\n\t\t\t\t\t\t (p->hs[1]));\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_LESHORT:\n\t\t\tif (nbytes < (offset + 2))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) &\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) |\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) ^\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) +\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) -\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) *\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) \/\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t\t (p->hs[0])) %\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = (short)((p->hs[1]<<8)|\n\t\t\t\t\t\t (p->hs[0]));\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_SHORT:\n\t\t\tif (nbytes < (offset + 2))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = p->h & off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = p->h | off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = p->h ^ off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = p->h + off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = p->h - off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = p->h * off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = p->h \/ off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = p->h % off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t\toffset = p->h;\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_BELONG:\n\t\tcase FILE_BEID3:\n\t\t\tif (nbytes < (offset + 4))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) &\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) |\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) ^\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) +\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) -\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) *\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) \/\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t\t (p->hl[3])) %\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = (int32_t)((p->hl[0]<<24)|\n\t\t\t\t\t\t (p->hl[1]<<16)|\n\t\t\t\t\t\t (p->hl[2]<<8)|\n\t\t\t\t\t\t (p->hl[3]));\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_LELONG:\n\t\tcase FILE_LEID3:\n\t\t\tif (nbytes < (offset + 4))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) &\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) |\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) ^\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) +\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) -\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) *\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) \/\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t\t (p->hl[0])) %\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = (int32_t)((p->hl[3]<<24)|\n\t\t\t\t\t\t (p->hl[2]<<16)|\n\t\t\t\t\t\t (p->hl[1]<<8)|\n\t\t\t\t\t\t (p->hl[0]));\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_MELONG:\n\t\t\tif (nbytes < (offset + 4))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) &\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) |\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) ^\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) +\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) -\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) *\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) \/\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t\t (p->hl[2])) %\n\t\t\t\t\t\t off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = (int32_t)((p->hl[1]<<24)|\n\t\t\t\t\t\t (p->hl[0]<<16)|\n\t\t\t\t\t\t (p->hl[3]<<8)|\n\t\t\t\t\t\t (p->hl[2]));\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\tcase FILE_LONG:\n\t\t\tif (nbytes < (offset + 4))\n\t\t\t\treturn 0;\n\t\t\tif (off) {\n\t\t\t\tswitch (m->in_op & FILE_OPS_MASK) {\n\t\t\t\tcase FILE_OPAND:\n\t\t\t\t\toffset = p->l & off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPOR:\n\t\t\t\t\toffset = p->l | off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPXOR:\n\t\t\t\t\toffset = p->l ^ off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPADD:\n\t\t\t\t\toffset = p->l + off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMINUS:\n\t\t\t\t\toffset = p->l - off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMULTIPLY:\n\t\t\t\t\toffset = p->l * off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPDIVIDE:\n\t\t\t\t\toffset = p->l \/ off;\n\t\t\t\t\tbreak;\n\t\t\t\tcase FILE_OPMODULO:\n\t\t\t\t\toffset = p->l % off;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\toffset = p->l;\n\t\t\tif (m->in_op & FILE_OPINVERSE)\n\t\t\t\toffset = ~offset;\n\t\t\tbreak;\n\t\t}\n\n\t\tswitch (cvt_flip(m->in_type, flip)) {\n\t\tcase FILE_LEID3:\n\t\tcase FILE_BEID3:\n\t\t\toffset = ((((offset >>  0) & 0x7f) <<  0) |\n\t\t\t\t (((offset >>  8) & 0x7f) <<  7) |\n\t\t\t\t (((offset >> 16) & 0x7f) << 14) |\n\t\t\t\t (((offset >> 24) & 0x7f) << 21)) + 10;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t\tif (m->flag & INDIROFFADD) {\n\t\t\toffset += ms->c.li[cont_level-1].off;\n\t\t\tif (offset == 0) {\n\t\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\t\tfprintf(stderr,\n\t\t\t\t\t    \"indirect *zero* offset\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\t\tfprintf(stderr, \"indirect +offs=%u\\n\", offset);\n\t\t}\n\t\tif (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)\n\t\t\treturn -1;\n\t\tms->offset = offset;\n\n\t\tif ((ms->flags & MAGIC_DEBUG) != 0) {\n\t\t\tmdebug(offset, (char *)(void *)p,\n\t\t\t    sizeof(union VALUETYPE));\n\t\t}\n\t}\n\n\t\/* Verify we have enough data to match magic type *\/\n\tswitch (m->type) {\n\tcase FILE_BYTE:\n\t\tif (nbytes < (offset + 1)) \/* should always be true *\/\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase FILE_SHORT:\n\tcase FILE_BESHORT:\n\tcase FILE_LESHORT:\n\t\tif (nbytes < (offset + 2))\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase FILE_LONG:\n\tcase FILE_BELONG:\n\tcase FILE_LELONG:\n\tcase FILE_MELONG:\n\tcase FILE_DATE:\n\tcase FILE_BEDATE:\n\tcase FILE_LEDATE:\n\tcase FILE_MEDATE:\n\tcase FILE_LDATE:\n\tcase FILE_BELDATE:\n\tcase FILE_LELDATE:\n\tcase FILE_MELDATE:\n\tcase FILE_FLOAT:\n\tcase FILE_BEFLOAT:\n\tcase FILE_LEFLOAT:\n\t\tif (nbytes < (offset + 4))\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase FILE_DOUBLE:\n\tcase FILE_BEDOUBLE:\n\tcase FILE_LEDOUBLE:\n\t\tif (nbytes < (offset + 8))\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase FILE_STRING:\n\tcase FILE_PSTRING:\n\tcase FILE_SEARCH:\n\t\tif (nbytes < (offset + m->vallen))\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase FILE_REGEX:\n\t\tif (nbytes < offset)\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase FILE_INDIRECT:\n\t\tif (offset == 0)\n\t\t\treturn 0;\n\t\tif (nbytes < offset)\n\t\t\treturn 0;\n\t\tsbuf = ms->o.buf;\n\t\tsoffset = ms->offset;\n\t\tms->o.buf = NULL;\n\t\tms->offset = 0;\n\t\trv = file_softmagic(ms, s + offset, nbytes - offset,\n\t\t    recursion_level, BINTEST, text);\n\t\tif ((ms->flags & MAGIC_DEBUG) != 0)\n\t\t\tfprintf(stderr, \"indirect @offs=%u[%d]\\n\", offset, rv);\n\t\trbuf = ms->o.buf;\n\t\tms->o.buf = sbuf;\n\t\tms->offset = soffset;\n\t\tif (rv == 1) {\n\t  \tif ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&\n\t\t\t    file_printf(ms, m->desc, offset) == -1)\n\t\t\treturn -1;\n\t\t\tif (file_printf(ms, \"%s\", rbuf) == -1)\n\t\t\t\treturn -1;\n\t\t\tefree(rbuf);\n\t\t}\n\t\treturn rv;\n\n\tcase FILE_USE:\n\t\tif (nbytes < offset)\n\t\t\treturn 0;\n\t\tsbuf = m->value.s;\n\t\tif (*sbuf == '^') {\n\t\t\tsbuf++;\n\t\t\tflip = !flip;\n\t\t}\n\t\tif (file_magicfind(ms, sbuf, &ml) == -1) {\n\t\t\tfile_error(ms, 0, \"cannot find entry `%s'\", sbuf);\n\t\t\treturn -1;\n\t\t}\n\n\t\toneed_separator = *need_separator;\n\t\tif (m->flag & NOSPACE)\n\t\t\t*need_separator = 0;\n\t\trv = match(ms, ml.magic, ml.nmagic, s, nbytes, offset + o,\n\t\t    mode, text, flip, recursion_level, printed_something,\n\t\t    need_separator, returnval);\n\t\tif (rv != 1)\n\t\t    *need_separator = oneed_separator;\n\t\treturn rv;\n\n\tcase FILE_NAME:\n\t\tif (file_printf(ms, \"%s\", m->desc) == -1)\n\t\t\treturn -1;\n\t\treturn 1;\n\tcase FILE_DEFAULT:\t\/* nothing to check *\/\n\tdefault:\n\t\tbreak;\n\t}\n\tif (!mconvert(ms, m, flip))\n\t\treturn 0;","target":1,"code_token_length":5196,"total_token_length":5432,"max_tokens_setting":6144}
+{"idx":426894,"func":"static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define CheckOverflowException(length,width,height) \\\n  (((height) != 0) && ((length)\/((size_t) height) != ((size_t) width)))\n\n  char\n    *comment;\n\n  Image\n    *image;\n\n  int\n    x_status;\n\n  MagickBooleanType\n    authentic_colormap;\n\n  MagickStatusType\n    status;\n\n  Quantum\n    index;\n\n  register ssize_t\n    x;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    i;\n\n  register size_t\n    pixel;\n\n  size_t\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned long\n    lsb_first;\n\n  XColor\n    *colors;\n\n  XImage\n    *ximage;\n\n  XWDFileHeader\n    header;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n     Read in header information.\n  *\/\n  count=ReadBlob(image,sz_XWDheader,(unsigned char *) &header);\n  if (count != sz_XWDheader)\n    ThrowReaderException(CorruptImageError,\"UnableToReadImageHeader\");\n  \/*\n    Ensure the header byte-order is most-significant byte first.\n  *\/\n  lsb_first=1;\n  if ((int) (*(char *) &lsb_first) != 0)\n    MSBOrderLong((unsigned char *) &header,sz_XWDheader);\n  \/*\n    Check to see if the dump file is in the proper format.\n  *\/\n  if (header.file_version != XWD_FILE_VERSION)\n    ThrowReaderException(CorruptImageError,\"FileFormatVersionMismatch\");\n  if (header.header_size < sz_XWDheader)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if ((header.bits_per_pixel == 0) || (header.bits_per_pixel > 32))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if ((header.bitmap_bit_order != MSBFirst) &&\n      (header.bitmap_bit_order != LSBFirst))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if (((header.bitmap_pad % 8) != 0) || (header.bitmap_pad > 32))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if (header.bitmap_unit > 32)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if (header.ncolors > 256)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  switch (header.visual_class)\n  {\n    case StaticGray:\n    case GrayScale:\n    case StaticColor:\n    case PseudoColor:\n    case TrueColor:\n    case DirectColor:\n      break;\n    default:\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  }\n  switch (header.pixmap_format)\n  {\n    case XYBitmap:\n    case XYPixmap:\n    case ZPixmap:\n      break;\n    default:\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  }\n  length=(size_t) (header.header_size-sz_XWDheader);\n  comment=(char *) AcquireQuantumMemory(length+1,sizeof(*comment));\n  if (comment == (char *) NULL)\n    ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n  count=ReadBlob(image,length,(unsigned char *) comment);\n  comment[length]='\\0';\n  (void) SetImageProperty(image,\"comment\",comment,exception);\n  comment=DestroyString(comment);\n  if (count != (ssize_t) length)\n    ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n  \/*\n    Initialize the X image.\n  *\/\n  ximage=(XImage *) AcquireMagickMemory(sizeof(*ximage));\n  if (ximage == (XImage *) NULL)\n    ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n  ximage->depth=(int) header.pixmap_depth;\n  ximage->format=(int) header.pixmap_format;\n  ximage->xoffset=(int) header.xoffset;\n  ximage->data=(char *) NULL;\n  ximage->width=(int) header.pixmap_width;\n  ximage->height=(int) header.pixmap_height;\n  ximage->bitmap_pad=(int) header.bitmap_pad;\n  ximage->bytes_per_line=(int) header.bytes_per_line;\n  ximage->byte_order=(int) header.byte_order;\n  ximage->bitmap_unit=(int) header.bitmap_unit;\n  ximage->bitmap_bit_order=(int) header.bitmap_bit_order;\n  ximage->bits_per_pixel=(int) header.bits_per_pixel;\n  ximage->red_mask=header.red_mask;\n  ximage->green_mask=header.green_mask;\n  ximage->blue_mask=header.blue_mask;\n  if ((ximage->width < 0) || (ximage->height < 0) || (ximage->depth < 0) ||\n      (ximage->format < 0) || (ximage->byte_order < 0) ||\n      (ximage->bitmap_bit_order < 0) || (ximage->bitmap_pad < 0) ||\n      (ximage->bytes_per_line < 0))\n    {\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    }\n  if ((ximage->width > 65535) || (ximage->height > 65535))\n    {\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    }\n  if ((ximage->bits_per_pixel > 32) || (ximage->bitmap_unit > 32))\n    {\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    }\n  x_status=XInitImage(ximage);\n  if (x_status == 0)\n    {\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n    }\n  \/*\n    Read colormap.\n  *\/\n  authentic_colormap=MagickFalse;\n  colors=(XColor *) NULL;\n  if (header.ncolors != 0)\n    {\n      XWDColor\n        color;\n\n      length=(size_t) header.ncolors;\n      if (length > ((~0UL)\/sizeof(*colors)))\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      colors=(XColor *) AcquireQuantumMemory(length,sizeof(*colors));\n      if (colors == (XColor *) NULL)\n        {\n          ximage=(XImage *) RelinquishMagickMemory(ximage);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      for (i=0; i < (ssize_t) header.ncolors; i++)\n      {\n        count=ReadBlob(image,sz_XWDColor,(unsigned char *) &color);\n        if (count != sz_XWDColor)\n          {\n            colors=(XColor *) RelinquishMagickMemory(colors);\n            ximage=(XImage *) RelinquishMagickMemory(ximage);\n            ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n          }\n        colors[i].pixel=color.pixel;\n        colors[i].red=color.red;\n        colors[i].green=color.green;\n        colors[i].blue=color.blue;\n        colors[i].flags=(char) color.flags;\n        if (color.flags != 0)\n          authentic_colormap=MagickTrue;\n      }\n      \/*\n        Ensure the header byte-order is most-significant byte first.\n      *\/\n      lsb_first=1;\n      if ((int) (*(char *) &lsb_first) != 0)\n        for (i=0; i < (ssize_t) header.ncolors; i++)\n        {\n          MSBOrderLong((unsigned char *) &colors[i].pixel,\n            sizeof(colors[i].pixel));\n          MSBOrderShort((unsigned char *) &colors[i].red,3*\n            sizeof(colors[i].red));\n        }\n    }\n  \/*\n    Allocate the pixel buffer.\n  *\/\n  length=(size_t) ximage->bytes_per_line*ximage->height;\n  if (CheckOverflowException(length,ximage->bytes_per_line,ximage->height))\n    {\n      if (header.ncolors != 0)\n        colors=(XColor *) RelinquishMagickMemory(colors);\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    }\n  if (ximage->format != ZPixmap)\n    {\n      size_t\n        extent;\n\n      extent=length;\n      length*=ximage->depth;\n      if (CheckOverflowException(length,extent,ximage->depth))\n        {\n          if (header.ncolors != 0)\n            colors=(XColor *) RelinquishMagickMemory(colors);\n          ximage=(XImage *) RelinquishMagickMemory(ximage);\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n        }\n    }\n  ximage->data=(char *) AcquireQuantumMemory(length,sizeof(*ximage->data));\n  if (ximage->data == (char *) NULL)\n    {\n      if (header.ncolors != 0)\n        colors=(XColor *) RelinquishMagickMemory(colors);\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    }\n  count=ReadBlob(image,length,(unsigned char *) ximage->data);\n  if (count != (ssize_t) length)\n    {\n      if (header.ncolors != 0)\n        colors=(XColor *) RelinquishMagickMemory(colors);\n      ximage->data=DestroyString(ximage->data);\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n    }\n  \/*\n    Convert image to MIFF format.\n  *\/\n  image->columns=(size_t) ximage->width;\n  image->rows=(size_t) ximage->height;\n  image->depth=8;\n  status=SetImageExtent(image,image->columns,image->rows,exception);\n  if (status == MagickFalse)\n    {\n      if (header.ncolors != 0)\n        colors=(XColor *) RelinquishMagickMemory(colors);\n      ximage->data=DestroyString(ximage->data);\n      ximage=(XImage *) RelinquishMagickMemory(ximage);\n      return(DestroyImageList(image));\n    }\n  if ((header.ncolors == 0U) || (ximage->red_mask != 0) ||\n      (ximage->green_mask != 0) || (ximage->blue_mask != 0))\n    image->storage_class=DirectClass;\n  else\n    image->storage_class=PseudoClass;\n  image->colors=header.ncolors;\n  if (image_info->ping == MagickFalse)\n    switch (image->storage_class)\n    {\n      case DirectClass:\n      default:\n      {\n        register size_t\n          color;\n\n        size_t\n          blue_mask,\n          blue_shift,\n          green_mask,\n          green_shift,\n          red_mask,\n          red_shift;\n\n        \/*\n          Determine shift and mask for red, green, and blue.\n        *\/\n        red_mask=ximage->red_mask;\n        red_shift=0;\n        while ((red_mask != 0) && ((red_mask & 0x01) == 0))\n        {\n          red_mask>>=1;\n          red_shift++;\n        }\n        green_mask=ximage->green_mask;\n        green_shift=0;\n        while ((green_mask != 0) && ((green_mask & 0x01) == 0))\n        {\n          green_mask>>=1;\n          green_shift++;\n        }\n        blue_mask=ximage->blue_mask;\n        blue_shift=0;\n        while ((blue_mask != 0) && ((blue_mask & 0x01) == 0))\n        {\n          blue_mask>>=1;\n          blue_shift++;\n        }\n        \/*\n          Convert X image to DirectClass packets.\n        *\/\n        if ((image->colors != 0) && (authentic_colormap != MagickFalse))\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              pixel=XGetPixel(ximage,(int) x,(int) y);\n              index=(Quantum) ConstrainColormapIndex(image,(ssize_t) (pixel >>\n                red_shift) & red_mask,exception);\n              SetPixelRed(image,ScaleShortToQuantum(\n                colors[(ssize_t) index].red),q);\n              index=(Quantum) ConstrainColormapIndex(image,(ssize_t) (pixel >>\n                green_shift) & green_mask,exception);\n              SetPixelGreen(image,ScaleShortToQuantum(\n                colors[(ssize_t) index].green),q);\n              index=(Quantum) ConstrainColormapIndex(image,(ssize_t) (pixel >>\n                blue_shift) & blue_mask,exception);\n              SetPixelBlue(image,ScaleShortToQuantum(\n                colors[(ssize_t) index].blue),q);\n              q+=GetPixelChannels(image);\n            }\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n              image->rows);\n            if (status == MagickFalse)\n              break;\n          }\n        else\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              pixel=XGetPixel(ximage,(int) x,(int) y);\n              color=(pixel >> red_shift) & red_mask;\n              if (red_mask != 0)\n                color=(color*65535UL)\/red_mask;\n              SetPixelRed(image,ScaleShortToQuantum((unsigned short) color),q);\n              color=(pixel >> green_shift) & green_mask;\n              if (green_mask != 0)\n                color=(color*65535UL)\/green_mask;\n              SetPixelGreen(image,ScaleShortToQuantum((unsigned short) color),\n                q);\n              color=(pixel >> blue_shift) & blue_mask;\n              if (blue_mask != 0)\n                color=(color*65535UL)\/blue_mask;\n              SetPixelBlue(image,ScaleShortToQuantum((unsigned short) color),q);\n              q+=GetPixelChannels(image);\n            }\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n              image->rows);\n            if (status == MagickFalse)\n              break;\n          }\n        break;\n      }\n      case PseudoClass:\n      {\n        \/*\n          Convert X image to PseudoClass packets.\n        *\/\n        if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n          {\n            if (header.ncolors != 0)\n              colors=(XColor *) RelinquishMagickMemory(colors);\n            ximage->data=DestroyString(ximage->data);\n            ximage=(XImage *) RelinquishMagickMemory(ximage);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].red=(MagickRealType) ScaleShortToQuantum(\n            colors[i].red);\n          image->colormap[i].green=(MagickRealType) ScaleShortToQuantum(\n            colors[i].green);\n          image->colormap[i].blue=(MagickRealType) ScaleShortToQuantum(\n            colors[i].blue);\n        }\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            index=(Quantum) ConstrainColormapIndex(image,(ssize_t)\n              XGetPixel(ximage,(int) x,(int) y),exception);\n            SetPixelIndex(image,index,q);\n            SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);\n            q+=GetPixelChannels(image);\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n        break;\n      }\n    }\n  \/*\n    Free image and colormap.\n  *\/\n  if (header.ncolors != 0)\n    colors=(XColor *) RelinquishMagickMemory(colors);\n  ximage->data=DestroyString(ximage->data);\n  ximage=(XImage *) RelinquishMagickMemory(ximage);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":3950,"total_token_length":4186,"max_tokens_setting":6144}
+{"idx":429118,"func":"static MagickBooleanType WriteICONImage(const ImageInfo *image_info,\n  Image *image)\n{\n  const char\n    *option;\n\n  IconFile\n    icon_file;\n\n  IconInfo\n    icon_info;\n\n  Image\n    *images,\n    *next;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    scene;\n\n  register const IndexPacket\n    *indexes;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *q;\n\n  size_t\n    bytes_per_line,\n    imageListLength,\n    scanline_pad;\n\n  ssize_t\n    y;\n\n  unsigned char\n    bit,\n    byte,\n    *pixels;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  images=(Image *) NULL;\n  option=GetImageOption(image_info,\"icon:auto-resize\");\n  if (option != (const char *) NULL)\n    {\n      images=AutoResizeImage(image,option,&scene,&image->exception);\n      if (images == (Image *) NULL)\n        ThrowWriterException(ImageError,\"InvalidDimensions\");\n    }\n  else\n    {\n      scene=0;\n      next=image;\n      do\n      {\n        if ((image->columns > 256L) || (image->rows > 256L))\n          ThrowWriterException(ImageError,\"WidthOrHeightExceedsLimit\");\n        scene++;\n        next=SyncNextImageInList(next);\n      } while ((next != (Image *) NULL) && (image_info->adjoin != \n          MagickFalse));\n    }\n  \/*\n    Dump out a ICON header template to be properly initialized later.\n  *\/\n  (void) WriteBlobLSBShort(image,0);\n  (void) WriteBlobLSBShort(image,1);\n  (void) WriteBlobLSBShort(image,(unsigned char) scene);\n  (void) memset(&icon_file,0,sizeof(icon_file));\n  (void) memset(&icon_info,0,sizeof(icon_info));\n  scene=0;\n  next=(images != (Image *) NULL) ? images : image;\n  do\n  {\n    (void) WriteBlobByte(image,icon_file.directory[scene].width);\n    (void) WriteBlobByte(image,icon_file.directory[scene].height);\n    (void) WriteBlobByte(image,icon_file.directory[scene].colors);\n    (void) WriteBlobByte(image,icon_file.directory[scene].reserved);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].size);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].offset);\n    scene++;\n    next=SyncNextImageInList(next);\n  } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));\n  scene=0;\n  next=(images != (Image *) NULL) ? images : image;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    if ((next->columns > 255L) && (next->rows > 255L) &&\n        ((next->compression == UndefinedCompression) ||\n        (next->compression == ZipCompression)))\n      {\n        Image\n          *write_image;\n\n        ImageInfo\n          *write_info;\n\n        size_t\n          length;\n\n        unsigned char\n          *png;\n\n        write_image=CloneImage(next,0,0,MagickTrue,&image->exception);\n        if (write_image == (Image *) NULL)\n          {\n            images=DestroyImageList(images);\n            return(MagickFalse);\n          }\n        write_info=CloneImageInfo(image_info);\n        (void) CopyMagickString(write_info->magick,\"PNG\",MagickPathExtent);\n        length=0;\n\n        \/* Don't write any ancillary chunks except for gAMA *\/\n        (void) SetImageArtifact(write_image,\"png:include-chunk\",\"none,gama\");\n\n        \/* Only write PNG32 formatted PNG (32-bit RGBA), 8 bits per channel *\/\n        (void) SetImageArtifact(write_image,\"png:format\",\"png32\");\n\n        png=(unsigned char *) ImageToBlob(write_info,write_image,&length,\n          &image->exception);\n        write_image=DestroyImageList(write_image);\n        write_info=DestroyImageInfo(write_info);\n        if (png == (unsigned char *) NULL)\n          {\n            images=DestroyImageList(images);\n            return(MagickFalse);\n          }\n        icon_file.directory[scene].width=0;\n        icon_file.directory[scene].height=0;\n        icon_file.directory[scene].colors=0;\n        icon_file.directory[scene].reserved=0;\n        icon_file.directory[scene].planes=1;\n        icon_file.directory[scene].bits_per_pixel=32;\n        icon_file.directory[scene].size=(size_t) length;\n        icon_file.directory[scene].offset=(size_t) TellBlob(image);\n        (void) WriteBlob(image,(size_t) length,png);\n        png=(unsigned char *) RelinquishMagickMemory(png);\n      }\n    else\n      {\n        \/*\n          Initialize ICON raster file header.\n        *\/\n        (void) TransformImageColorspace(image,sRGBColorspace);\n        icon_info.file_size=14+12+28;\n        icon_info.offset_bits=icon_info.file_size;\n        icon_info.compression=BI_RGB;\n        if ((next->storage_class != DirectClass) && (next->colors > 256))\n          (void) SetImageStorageClass(next,DirectClass);\n        if (next->storage_class == DirectClass)\n          {\n            \/*\n              Full color ICON raster.\n            *\/\n            icon_info.number_colors=0;\n            icon_info.bits_per_pixel=32;\n            icon_info.compression=(size_t) BI_RGB;\n          }\n        else\n          {\n            size_t\n              one;\n\n            \/*\n              Colormapped ICON raster.\n            *\/\n            icon_info.bits_per_pixel=8;\n            if (next->colors <= 256)\n              icon_info.bits_per_pixel=8;\n            if (next->colors <= 16)\n              icon_info.bits_per_pixel=4;\n            if (next->colors <= 2)\n              icon_info.bits_per_pixel=1;\n            one=1;\n            icon_info.number_colors=one << icon_info.bits_per_pixel;\n            if (icon_info.number_colors < next->colors)\n              {\n                (void) SetImageStorageClass(next,DirectClass);\n                icon_info.number_colors=0;\n                icon_info.bits_per_pixel=(unsigned short) 24;\n                icon_info.compression=(size_t) BI_RGB;\n              }\n            else\n              {\n                size_t\n                  one;\n\n                one=1;\n                icon_info.file_size+=3*(one << icon_info.bits_per_pixel);\n                icon_info.offset_bits+=3*(one << icon_info.bits_per_pixel);\n                icon_info.file_size+=(one << icon_info.bits_per_pixel);\n                icon_info.offset_bits+=(one << icon_info.bits_per_pixel);\n              }\n          }\n        bytes_per_line=(((next->columns*icon_info.bits_per_pixel)+31) &\n          ~31) >> 3;\n        icon_info.ba_offset=0;\n        icon_info.width=(ssize_t) next->columns;\n        icon_info.height=(ssize_t) next->rows;\n        icon_info.planes=1;\n        icon_info.image_size=bytes_per_line*next->rows;\n        icon_info.size=40;\n        icon_info.size+=(4*icon_info.number_colors);\n        icon_info.size+=icon_info.image_size;\n        icon_info.size+=(((icon_info.width+31) & ~31) >> 3)*icon_info.height;\n        icon_info.file_size+=icon_info.image_size;\n        icon_info.x_pixels=0;\n        icon_info.y_pixels=0;\n        switch (next->units)\n        {\n          case UndefinedResolution:\n          case PixelsPerInchResolution:\n          {\n            icon_info.x_pixels=(size_t) (100.0*next->x_resolution\/2.54);\n            icon_info.y_pixels=(size_t) (100.0*next->y_resolution\/2.54);\n            break;\n          }\n          case PixelsPerCentimeterResolution:\n          {\n            icon_info.x_pixels=(size_t) (100.0*next->x_resolution);\n            icon_info.y_pixels=(size_t) (100.0*next->y_resolution);\n            break;\n          }\n        }\n        icon_info.colors_important=icon_info.number_colors;\n        \/*\n          Convert MIFF to ICON raster pixels.\n        *\/\n        pixels=(unsigned char *) AcquireQuantumMemory((size_t)\n          icon_info.image_size,sizeof(*pixels));\n        if (pixels == (unsigned char *) NULL)\n          {\n            images=DestroyImageList(images);\n            ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n        (void) memset(pixels,0,(size_t) icon_info.image_size);\n        switch (icon_info.bits_per_pixel)\n        {\n          case 1:\n          {\n            size_t\n              bit,\n              byte;\n\n            \/*\n              Convert PseudoClass image to a ICON monochrome image.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              indexes=GetVirtualIndexQueue(next);\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              bit=0;\n              byte=0;\n              for (x=0; x < (ssize_t) next->columns; x++)\n              {\n                byte<<=1;\n                byte|=GetPixelIndex(indexes+x) != 0 ? 0x01 : 0x00;\n                bit++;\n                if (bit == 8)\n                  {\n                    *q++=(unsigned char) byte;\n                    bit=0;\n                    byte=0;\n                  }\n               }\n              if (bit != 0)\n                *q++=(unsigned char) (byte << (8-bit));\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n          case 4:\n          {\n            size_t\n              nibble,\n              byte;\n\n            \/*\n              Convert PseudoClass image to a ICON monochrome image.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              indexes=GetVirtualIndexQueue(next);\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              nibble=0;\n              byte=0;\n              for (x=0; x < (ssize_t) next->columns; x++)\n              {\n                byte<<=4;\n                byte|=((size_t) GetPixelIndex(indexes+x) & 0x0f);\n                nibble++;\n                if (nibble == 2)\n                  {\n                    *q++=(unsigned char) byte;\n                    nibble=0;\n                    byte=0;\n                  }\n               }\n              if (nibble != 0)\n                *q++=(unsigned char) (byte << 4);\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n          case 8:\n          {\n            \/*\n              Convert PseudoClass packet to ICON pixel.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              indexes=GetVirtualIndexQueue(next);\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) next->columns; x++)\n                *q++=(unsigned char) GetPixelIndex(indexes+x);\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n          case 24:\n          case 32:\n          {\n            \/*\n              Convert DirectClass packet to ICON BGR888 or BGRA8888 pixel.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) next->columns; x++)\n              {\n                *q++=ScaleQuantumToChar(GetPixelBlue(p));\n                *q++=ScaleQuantumToChar(GetPixelGreen(p));\n                *q++=ScaleQuantumToChar(GetPixelRed(p));\n                if (next->matte == MagickFalse)\n                  *q++=ScaleQuantumToChar(QuantumRange);\n                else\n                  *q++=ScaleQuantumToChar(GetPixelAlpha(p));\n                p++;\n              }\n              if (icon_info.bits_per_pixel == 24)\n                for (x=3L*(ssize_t) next->columns; x < (ssize_t) bytes_per_line; x++)\n                  *q++=0x00;\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n        }\n        \/*\n          Write 40-byte version 3+ bitmap header.\n        *\/\n        icon_file.directory[scene].width=(unsigned char) icon_info.width;\n        icon_file.directory[scene].height=(unsigned char) icon_info.height;\n        icon_file.directory[scene].colors=(unsigned char)\n          icon_info.number_colors;\n        icon_file.directory[scene].reserved=0;\n        icon_file.directory[scene].planes=icon_info.planes;\n        icon_file.directory[scene].bits_per_pixel=icon_info.bits_per_pixel;\n        icon_file.directory[scene].size=icon_info.size;\n        icon_file.directory[scene].offset=(size_t) TellBlob(image);\n        (void) WriteBlobLSBLong(image,(unsigned int) 40);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.width);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.height*2);\n        (void) WriteBlobLSBShort(image,icon_info.planes);\n        (void) WriteBlobLSBShort(image,icon_info.bits_per_pixel);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.compression);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.image_size);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.x_pixels);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.y_pixels);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.number_colors);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.colors_important);\n        if (next->storage_class == PseudoClass)\n          {\n            unsigned char\n              *icon_colormap;\n\n            \/*\n              Dump colormap to file.\n            *\/\n            icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n              (1UL << icon_info.bits_per_pixel),4UL*sizeof(*icon_colormap));\n            if (icon_colormap == (unsigned char *) NULL)\n              {\n                images=DestroyImageList(images);\n                ThrowWriterException(ResourceLimitError,\n                  \"MemoryAllocationFailed\");\n              }\n            q=icon_colormap;\n            for (i=0; i < (ssize_t) next->colors; i++)\n            {\n              *q++=ScaleQuantumToChar(next->colormap[i].blue);\n              *q++=ScaleQuantumToChar(next->colormap[i].green);\n              *q++=ScaleQuantumToChar(next->colormap[i].red);\n              *q++=(unsigned char) 0x0;\n            }\n            for ( ; i < (ssize_t) (1UL << icon_info.bits_per_pixel); i++)\n            {\n              *q++=(unsigned char) 0x00;\n              *q++=(unsigned char) 0x00;\n              *q++=(unsigned char) 0x00;\n              *q++=(unsigned char) 0x00;\n            }\n            (void) WriteBlob(image,(size_t) (4UL*(1UL <<\n              icon_info.bits_per_pixel)),icon_colormap);\n            icon_colormap=(unsigned char *) RelinquishMagickMemory(\n              icon_colormap);\n          }\n        (void) WriteBlob(image,(size_t) icon_info.image_size,pixels);\n        pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n        \/*\n          Write matte mask.\n        *\/\n        scanline_pad=(((next->columns+31) & ~31)-next->columns) >> 3;\n        for (y=((ssize_t) next->rows - 1); y >= 0; y--)\n        {\n          p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          bit=0;\n          byte=0;\n          for (x=0; x < (ssize_t) next->columns; x++)\n          {\n            byte<<=1;\n            if ((next->matte != MagickFalse) &&\n                (GetPixelOpacity(p) == (Quantum) TransparentOpacity))\n              byte|=0x01;\n            bit++;\n            if (bit == 8)\n              {\n                (void) WriteBlobByte(image,(unsigned char) byte);\n                bit=0;\n                byte=0;\n              }\n            p++;\n          }\n          if (bit != 0)\n            (void) WriteBlobByte(image,(unsigned char) (byte << (8-bit)));\n          for (i=0; i < (ssize_t) scanline_pad; i++)\n            (void) WriteBlobByte(image,(unsigned char) 0);\n        }\n      }\n    if (GetNextImageInList(next) == (Image *) NULL)\n      break;\n    status=SetImageProgress(next,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n    next=SyncNextImageInList(next);\n  } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));\n  offset=SeekBlob(image,0,SEEK_SET);\n  (void) offset;\n  (void) WriteBlobLSBShort(image,0);\n  (void) WriteBlobLSBShort(image,1);\n  (void) WriteBlobLSBShort(image,(unsigned short) (scene+1));\n  scene=0;\n  next=(images != (Image *) NULL) ? images : image;\n  do\n  {\n    (void) WriteBlobByte(image,icon_file.directory[scene].width);\n    (void) WriteBlobByte(image,icon_file.directory[scene].height);\n    (void) WriteBlobByte(image,icon_file.directory[scene].colors);\n    (void) WriteBlobByte(image,icon_file.directory[scene].reserved);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].size);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].offset);\n    scene++;\n    next=SyncNextImageInList(next);\n  } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));\n  (void) CloseBlob(image);\n  images=DestroyImageList(images);\n  return(MagickTrue);\n}","target":0,"code_token_length":4498,"total_token_length":4734,"max_tokens_setting":6144}
+{"idx":42445,"func":"main (int    argc,\n      char **argv)\n{\n  mode_t old_umask;\n  const char *base_path = NULL;\n  int clone_flags;\n  char *old_cwd = NULL;\n  pid_t pid;\n  int event_fd = -1;\n  int child_wait_fd = -1;\n  int setup_finished_pipe[] = {-1, -1};\n  const char *new_cwd;\n  uid_t ns_uid;\n  gid_t ns_gid;\n  struct stat sbuf;\n  uint64_t val;\n  int res UNUSED;\n  cleanup_free char *seccomp_data = NULL;\n  size_t seccomp_len;\n  struct sock_fprog seccomp_prog;\n  cleanup_free char *args_data = NULL;\n\n  \/* Handle --version early on before we try to acquire\/drop\n   * any capabilities so it works in a build environment;\n   * right now flatpak's build runs bubblewrap --version.\n   * https:\/\/github.com\/projectatomic\/bubblewrap\/issues\/185\n   *\/\n  if (argc == 2 && (strcmp (argv[1], \"--version\") == 0))\n    print_version_and_exit ();\n\n  real_uid = getuid ();\n  real_gid = getgid ();\n\n  \/* Get the (optional) privileges we need *\/\n  acquire_privs ();\n\n  \/* Never gain any more privs during exec *\/\n  if (prctl (PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0)\n    die_with_error (\"prctl(PR_SET_NO_NEW_CAPS) failed\");\n\n  \/* The initial code is run with high permissions\n     (i.e. CAP_SYS_ADMIN), so take lots of care. *\/\n\n  read_overflowids ();\n\n  argv0 = argv[0];\n\n  if (isatty (1))\n    host_tty_dev = ttyname (1);\n\n  argv++;\n  argc--;\n\n  if (argc == 0)\n    usage (EXIT_FAILURE, stderr);\n\n  parse_args (&argc, (const char ***) &argv);\n\n  \/* suck the args into a cleanup_free variable to control their lifecycle *\/\n  args_data = opt_args_data;\n  opt_args_data = NULL;\n\n  if ((requested_caps[0] || requested_caps[1]) && is_privileged)\n    die (\"--cap-add in setuid mode can be used only by root\");\n\n  if (opt_userns_block_fd != -1 && !opt_unshare_user)\n    die (\"--userns-block-fd requires --unshare-user\");\n\n  if (opt_userns_block_fd != -1 && opt_info_fd == -1)\n    die (\"--userns-block-fd requires --info-fd\");\n\n  \/* We have to do this if we weren't installed setuid (and we're not\n   * root), so let's just DWIM *\/\n  if (!is_privileged && getuid () != 0)\n    opt_unshare_user = TRUE;\n\n#ifdef ENABLE_REQUIRE_USERNS\n  \/* In this build option, we require userns. *\/\n  if (is_privileged && getuid () != 0)\n    opt_unshare_user = TRUE;\n#endif\n\n  if (opt_unshare_user_try &&\n      stat (\"\/proc\/self\/ns\/user\", &sbuf) == 0)\n    {\n      bool disabled = FALSE;\n\n      \/* RHEL7 has a kernel module parameter that lets you enable user namespaces *\/\n      if (stat (\"\/sys\/module\/user_namespace\/parameters\/enable\", &sbuf) == 0)\n        {\n          cleanup_free char *enable = NULL;\n          enable = load_file_at (AT_FDCWD, \"\/sys\/module\/user_namespace\/parameters\/enable\");\n          if (enable != NULL && enable[0] == 'N')\n            disabled = TRUE;\n        }\n\n      \/* Check for max_user_namespaces *\/\n      if (stat (\"\/proc\/sys\/user\/max_user_namespaces\", &sbuf) == 0)\n        {\n          cleanup_free char *max_user_ns = NULL;\n          max_user_ns = load_file_at (AT_FDCWD, \"\/proc\/sys\/user\/max_user_namespaces\");\n          if (max_user_ns != NULL && strcmp(max_user_ns, \"0\\n\") == 0)\n            disabled = TRUE;\n        }\n\n      \/* Debian lets you disable *unprivileged* user namespaces. However this is not\n         a problem if we're privileged, and if we're not opt_unshare_user is TRUE\n         already, and there is not much we can do, its just a non-working setup. *\/\n\n      if (!disabled)\n        opt_unshare_user = TRUE;\n    }\n\n  if (argc == 0)\n    usage (EXIT_FAILURE, stderr);\n\n  __debug__ ((\"Creating root mount point\\n\"));\n\n  if (opt_sandbox_uid == -1)\n    opt_sandbox_uid = real_uid;\n  if (opt_sandbox_gid == -1)\n    opt_sandbox_gid = real_gid;\n\n  if (!opt_unshare_user && opt_sandbox_uid != real_uid)\n    die (\"Specifying --uid requires --unshare-user\");\n\n  if (!opt_unshare_user && opt_sandbox_gid != real_gid)\n    die (\"Specifying --gid requires --unshare-user\");\n\n  if (!opt_unshare_uts && opt_sandbox_hostname != NULL)\n    die (\"Specifying --hostname requires --unshare-uts\");\n\n  if (opt_as_pid_1 && !opt_unshare_pid)\n    die (\"Specifying --as-pid-1 requires --unshare-pid\");\n\n  if (opt_as_pid_1 && lock_files != NULL)\n    die (\"Specifying --as-pid-1 and --lock-file is not permitted\");\n\n  \/* We need to read stuff from proc during the pivot_root dance, etc.\n     Lets keep a fd to it open *\/\n  proc_fd = open (\"\/proc\", O_PATH);\n  if (proc_fd == -1)\n    die_with_error (\"Can't open \/proc\");\n\n  \/* We need *some* mountpoint where we can mount the root tmpfs.\n   * Because we use pivot_root, it won't appear to be mounted from\n   * the perspective of the sandboxed process, so we can use anywhere\n   * that is sure to exist, that is sure to not be a symlink controlled\n   * by someone malicious, and that we won't immediately need to\n   * access ourselves. *\/\n  base_path = \"\/tmp\";\n\n  __debug__ ((\"creating new namespace\\n\"));\n\n  if (opt_unshare_pid && !opt_as_pid_1)\n    {\n      event_fd = eventfd (0, EFD_CLOEXEC | EFD_NONBLOCK);\n      if (event_fd == -1)\n        die_with_error (\"eventfd()\");\n    }\n\n  \/* We block sigchild here so that we can use signalfd in the monitor. *\/\n  block_sigchild ();\n\n  clone_flags = SIGCHLD | CLONE_NEWNS;\n  if (opt_unshare_user)\n    clone_flags |= CLONE_NEWUSER;\n  if (opt_unshare_pid)\n    clone_flags |= CLONE_NEWPID;\n  if (opt_unshare_net)\n    clone_flags |= CLONE_NEWNET;\n  if (opt_unshare_ipc)\n    clone_flags |= CLONE_NEWIPC;\n  if (opt_unshare_uts)\n    clone_flags |= CLONE_NEWUTS;\n  if (opt_unshare_cgroup)\n    {\n      if (stat (\"\/proc\/self\/ns\/cgroup\", &sbuf))\n        {\n          if (errno == ENOENT)\n            die (\"Cannot create new cgroup namespace because the kernel does not support it\");\n          else\n            die_with_error (\"stat on \/proc\/self\/ns\/cgroup failed\");\n        }\n      clone_flags |= CLONE_NEWCGROUP;\n    }\n  if (opt_unshare_cgroup_try)\n    if (!stat (\"\/proc\/self\/ns\/cgroup\", &sbuf))\n      clone_flags |= CLONE_NEWCGROUP;\n\n  child_wait_fd = eventfd (0, EFD_CLOEXEC);\n  if (child_wait_fd == -1)\n    die_with_error (\"eventfd()\");\n\n  \/* Track whether pre-exec setup finished if we're reporting process exit *\/\n  if (opt_json_status_fd != -1)\n    {\n      int ret;\n      ret = pipe2 (setup_finished_pipe, O_CLOEXEC);\n      if (ret == -1)\n        die_with_error (\"pipe2()\");\n    }\n\n  pid = raw_clone (clone_flags, NULL);\n  if (pid == -1)\n    {\n      if (opt_unshare_user)\n        {\n          if (errno == EINVAL)\n            die (\"Creating new namespace failed, likely because the kernel does not support user namespaces.  bwrap must be installed setuid on such systems.\");\n          else if (errno == EPERM && !is_privileged)\n            die (\"No permissions to creating new namespace, likely because the kernel does not allow non-privileged user namespaces. On e.g. debian this can be enabled with 'sysctl kernel.unprivileged_userns_clone=1'.\");\n        }\n\n      die_with_error (\"Creating new namespace failed\");\n    }\n\n  ns_uid = opt_sandbox_uid;\n  ns_gid = opt_sandbox_gid;\n\n  if (pid != 0)\n    {\n      \/* Parent, outside sandbox, privileged (initially) *\/\n\n      if (is_privileged && opt_unshare_user && opt_userns_block_fd == -1)\n        {\n          \/* We're running as euid 0, but the uid we want to map is\n           * not 0. This means we're not allowed to write this from\n           * the child user namespace, so we do it from the parent.\n           *\n           * Also, we map uid\/gid 0 in the namespace (to overflowuid)\n           * if opt_needs_devpts is true, because otherwise the mount\n           * of devpts fails due to root not being mapped.\n           *\/\n          write_uid_gid_map (ns_uid, real_uid,\n                             ns_gid, real_gid,\n                             pid, TRUE, opt_needs_devpts);\n        }\n\n      \/* Initial launched process, wait for exec:ed command to exit *\/\n\n      \/* We don't need any privileges in the launcher, drop them immediately. *\/\n      drop_privs (FALSE);\n\n      \/* Optionally bind our lifecycle to that of the parent *\/\n      handle_die_with_parent ();\n\n      if (opt_info_fd != -1)\n        {\n          cleanup_free char *output = xasprintf (\"{\\n    \\\"child-pid\\\": %i\\n}\\n\", pid);\n          dump_info (opt_info_fd, output, TRUE);\n          close (opt_info_fd);\n        }\n      if (opt_json_status_fd != -1)\n        {\n          cleanup_free char *output = xasprintf (\"{ \\\"child-pid\\\": %i }\\n\", pid);\n          dump_info (opt_json_status_fd, output, TRUE);\n        }\n\n      if (opt_userns_block_fd != -1)\n        {\n          char b[1];\n          (void) TEMP_FAILURE_RETRY (read (opt_userns_block_fd, b, 1));\n          close (opt_userns_block_fd);\n        }\n\n      \/* Let child run now that the uid maps are set up *\/\n      val = 1;\n      res = write (child_wait_fd, &val, 8);\n      \/* Ignore res, if e.g. the child died and closed child_wait_fd we don't want to error out here *\/\n      close (child_wait_fd);\n\n      return monitor_child (event_fd, pid, setup_finished_pipe[0]);\n    }\n\n  \/* Child, in sandbox, privileged in the parent or in the user namespace (if --unshare-user).\n   *\n   * Note that for user namespaces we run as euid 0 during clone(), so\n   * the child user namespace is owned by euid 0., This means that the\n   * regular user namespace parent (with uid != 0) doesn't have any\n   * capabilities in it, which is nice as we can't exploit those. In\n   * particular the parent user namespace doesn't have CAP_PTRACE\n   * which would otherwise allow the parent to hijack of the child\n   * after this point.\n   *\n   * Unfortunately this also means you can't ptrace the final\n   * sandboxed process from outside the sandbox either.\n   *\/\n\n  if (opt_info_fd != -1)\n    close (opt_info_fd);\n\n  if (opt_json_status_fd != -1)\n    close (opt_json_status_fd);\n\n  \/* Wait for the parent to init uid\/gid maps and drop caps *\/\n  res = read (child_wait_fd, &val, 8);\n  close (child_wait_fd);\n\n  \/* At this point we can completely drop root uid, but retain the\n   * required permitted caps. This allow us to do full setup as\n   * the user uid, which makes e.g. fuse access work.\n   *\/\n  switch_to_user_with_privs ();\n\n  if (opt_unshare_net)\n    loopback_setup (); \/* Will exit if unsuccessful *\/\n\n  ns_uid = opt_sandbox_uid;\n  ns_gid = opt_sandbox_gid;\n  if (!is_privileged && opt_unshare_user && opt_userns_block_fd == -1)\n    {\n      \/* In the unprivileged case we have to write the uid\/gid maps in\n       * the child, because we have no caps in the parent *\/\n\n      if (opt_needs_devpts)\n        {\n          \/* This is a bit hacky, but we need to first map the real uid\/gid to\n             0, otherwise we can't mount the devpts filesystem because root is\n             not mapped. Later we will create another child user namespace and\n             map back to the real uid *\/\n          ns_uid = 0;\n          ns_gid = 0;\n        }\n\n      write_uid_gid_map (ns_uid, real_uid,\n                         ns_gid, real_gid,\n                         -1, TRUE, FALSE);\n    }\n\n  old_umask = umask (0);\n\n  \/* Need to do this before the chroot, but after we're the real uid *\/\n  resolve_symlinks_in_ops ();\n\n  \/* Mark everything as slave, so that we still\n   * receive mounts from the real root, but don't\n   * propagate mounts to the real root. *\/\n  if (mount (NULL, \"\/\", NULL, MS_SLAVE | MS_REC, NULL) < 0)\n    die_with_error (\"Failed to make \/ slave\");\n\n  \/* Create a tmpfs which we will use as \/ in the namespace *\/\n  if (mount (\"tmpfs\", base_path, \"tmpfs\", MS_NODEV | MS_NOSUID, NULL) != 0)\n    die_with_error (\"Failed to mount tmpfs\");\n\n  old_cwd = get_current_dir_name ();\n\n  \/* Chdir to the new root tmpfs mount. This will be the CWD during\n     the entire setup. Access old or new root via \"oldroot\" and \"newroot\". *\/\n  if (chdir (base_path) != 0)\n    die_with_error (\"chdir base_path\");\n\n  \/* We create a subdir \"$base_path\/newroot\" for the new root, that\n   * way we can pivot_root to base_path, and put the old root at\n   * \"$base_path\/oldroot\". This avoids problems accessing the oldroot\n   * dir if the user requested to bind mount something over \/ (or\n   * over \/tmp, now that we use that for base_path). *\/\n\n  if (mkdir (\"newroot\", 0755))\n    die_with_error (\"Creating newroot failed\");\n\n  if (mount (\"newroot\", \"newroot\", NULL, MS_MGC_VAL | MS_BIND | MS_REC, NULL) < 0)\n    die_with_error (\"setting up newroot bind\");\n\n  if (mkdir (\"oldroot\", 0755))\n    die_with_error (\"Creating oldroot failed\");\n\n  if (pivot_root (base_path, \"oldroot\"))\n    die_with_error (\"pivot_root\");\n\n  if (chdir (\"\/\") != 0)\n    die_with_error (\"chdir \/ (base path)\");\n\n  if (is_privileged)\n    {\n      pid_t child;\n      int privsep_sockets[2];\n\n      if (socketpair (AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, privsep_sockets) != 0)\n        die_with_error (\"Can't create privsep socket\");\n\n      child = fork ();\n      if (child == -1)\n        die_with_error (\"Can't fork unprivileged helper\");\n\n      if (child == 0)\n        {\n          \/* Unprivileged setup process *\/\n          drop_privs (FALSE);\n          close (privsep_sockets[0]);\n          setup_newroot (opt_unshare_pid, privsep_sockets[1]);\n          exit (0);\n        }\n      else\n        {\n          int status;\n          uint32_t buffer[2048];  \/* 8k, but is int32 to guarantee nice alignment *\/\n          uint32_t op, flags;\n          const char *arg1, *arg2;\n          cleanup_fd int unpriv_socket = -1;\n\n          unpriv_socket = privsep_sockets[0];\n          close (privsep_sockets[1]);\n\n          do\n            {\n              op = read_priv_sec_op (unpriv_socket, buffer, sizeof (buffer),\n                                     &flags, &arg1, &arg2);\n              privileged_op (-1, op, flags, arg1, arg2);\n              if (write (unpriv_socket, buffer, 1) != 1)\n                die (\"Can't write to op_socket\");\n            }\n          while (op != PRIV_SEP_OP_DONE);\n\n          waitpid (child, &status, 0);\n          \/* Continue post setup *\/\n        }\n    }\n  else\n    {\n      setup_newroot (opt_unshare_pid, -1);\n    }\n\n  close_ops_fd ();\n\n  \/* The old root better be rprivate or we will send unmount events to the parent namespace *\/\n  if (mount (\"oldroot\", \"oldroot\", NULL, MS_REC | MS_PRIVATE, NULL) != 0)\n    die_with_error (\"Failed to make old root rprivate\");\n\n  if (umount2 (\"oldroot\", MNT_DETACH))\n    die_with_error (\"unmount old root\");\n\n  \/* This is our second pivot. It's like we're a Silicon Valley startup flush\n   * with cash but short on ideas!\n   *\n   * We're aiming to make \/newroot the real root, and get rid of \/oldroot. To do\n   * that we need a temporary place to store it before we can unmount it.\n   *\/\n  { cleanup_fd int oldrootfd = open (\"\/\", O_DIRECTORY | O_RDONLY);\n    if (oldrootfd < 0)\n      die_with_error (\"can't open \/\");\n    if (chdir (\"\/newroot\") != 0)\n      die_with_error (\"chdir \/newroot\");\n    \/* While the documentation claims that put_old must be underneath\n     * new_root, it is perfectly fine to use the same directory as the\n     * kernel checks only if old_root is accessible from new_root.\n     *\n     * Both runc and LXC are using this \"alternative\" method for\n     * setting up the root of the container:\n     *\n     * https:\/\/github.com\/opencontainers\/runc\/blob\/master\/libcontainer\/rootfs_linux.go#L671\n     * https:\/\/github.com\/lxc\/lxc\/blob\/master\/src\/lxc\/conf.c#L1121\n     *\/\n    if (pivot_root (\".\", \".\") != 0)\n      die_with_error (\"pivot_root(\/newroot)\");\n    if (fchdir (oldrootfd) < 0)\n      die_with_error (\"fchdir to oldroot\");\n    if (umount2 (\".\", MNT_DETACH) < 0)\n      die_with_error (\"umount old root\");\n    if (chdir (\"\/\") != 0)\n      die_with_error (\"chdir \/\");\n  }\n\n  if (opt_unshare_user &&\n      (ns_uid != opt_sandbox_uid || ns_gid != opt_sandbox_gid) &&\n      opt_userns_block_fd == -1)\n    {\n      \/* Now that devpts is mounted and we've no need for mount\n         permissions we can create a new userspace and map our uid\n         1:1 *\/\n\n      if (unshare (CLONE_NEWUSER))\n        die_with_error (\"unshare user ns\");\n\n      write_uid_gid_map (opt_sandbox_uid, ns_uid,\n                         opt_sandbox_gid, ns_gid,\n                         -1, FALSE, FALSE);\n    }\n\n  \/* All privileged ops are done now, so drop caps we don't need *\/\n  drop_privs (!is_privileged);\n\n  if (opt_block_fd != -1)\n    {\n      char b[1];\n      (void) TEMP_FAILURE_RETRY (read (opt_block_fd, b, 1));\n      close (opt_block_fd);\n    }\n\n  if (opt_seccomp_fd != -1)\n    {\n      seccomp_data = load_file_data (opt_seccomp_fd, &seccomp_len);\n      if (seccomp_data == NULL)\n        die_with_error (\"Can't read seccomp data\");\n\n      if (seccomp_len % 8 != 0)\n        die (\"Invalid seccomp data, must be multiple of 8\");\n\n      seccomp_prog.len = seccomp_len \/ 8;\n      seccomp_prog.filter = (struct sock_filter *) seccomp_data;\n\n      close (opt_seccomp_fd);\n    }\n\n  umask (old_umask);\n\n  new_cwd = \"\/\";\n  if (opt_chdir_path)\n    {\n      if (chdir (opt_chdir_path))\n        die_with_error (\"Can't chdir to %s\", opt_chdir_path);\n      new_cwd = opt_chdir_path;\n    }\n  else if (chdir (old_cwd) == 0)\n    {\n      \/* If the old cwd is mapped in the sandbox, go there *\/\n      new_cwd = old_cwd;\n    }\n  else\n    {\n      \/* If the old cwd is not mapped, go to home *\/\n      const char *home = getenv (\"HOME\");\n      if (home != NULL &&\n          chdir (home) == 0)\n        new_cwd = home;\n    }\n  xsetenv (\"PWD\", new_cwd, 1);\n  free (old_cwd);\n\n  if (opt_new_session &&\n      setsid () == (pid_t) -1)\n    die_with_error (\"setsid\");\n\n  if (label_exec (opt_exec_label) == -1)\n    die_with_error (\"label_exec %s\", argv[0]);\n\n  __debug__ ((\"forking for child\\n\"));\n\n  if (!opt_as_pid_1 && (opt_unshare_pid || lock_files != NULL || opt_sync_fd != -1))\n    {\n      \/* We have to have a pid 1 in the pid namespace, because\n       * otherwise we'll get a bunch of zombies as nothing reaps\n       * them. Alternatively if we're using sync_fd or lock_files we\n       * need some process to own these.\n       *\/\n\n      pid = fork ();\n      if (pid == -1)\n        die_with_error (\"Can't fork for pid 1\");\n\n      if (pid != 0)\n        {\n          drop_all_caps (FALSE);\n\n          \/* Close fds in pid 1, except stdio and optionally event_fd\n             (for syncing pid 2 lifetime with monitor_child) and\n             opt_sync_fd (for syncing sandbox lifetime with outside\n             process).\n             Any other fds will been passed on to the child though. *\/\n          {\n            int dont_close[3];\n            int j = 0;\n            if (event_fd != -1)\n              dont_close[j++] = event_fd;\n            if (opt_sync_fd != -1)\n              dont_close[j++] = opt_sync_fd;\n            dont_close[j++] = -1;\n            fdwalk (proc_fd, close_extra_fds, dont_close);\n          }\n\n          return do_init (event_fd, pid, seccomp_data != NULL ? &seccomp_prog : NULL);\n        }\n    }\n\n  __debug__ ((\"launch executable %s\\n\", argv[0]));\n\n  if (proc_fd != -1)\n    close (proc_fd);\n\n  \/* If we are using --as-pid-1 leak the sync fd into the sandbox.\n     --sync-fd will still work unless the container process doesn't close this file.  *\/\n  if (!opt_as_pid_1)\n    {\n      if (opt_sync_fd != -1)\n        close (opt_sync_fd);\n    }\n\n  \/* We want sigchild in the child *\/\n  unblock_sigchild ();\n\n  \/* Optionally bind our lifecycle *\/\n  handle_die_with_parent ();\n\n  if (!is_privileged)\n    set_ambient_capabilities ();\n\n  \/* Should be the last thing before execve() so that filters don't\n   * need to handle anything above *\/\n  if (seccomp_data != NULL &&\n      prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &seccomp_prog) != 0)\n    die_with_error (\"prctl(PR_SET_SECCOMP)\");\n\n  if (setup_finished_pipe[1] != -1)\n    {\n      char data = 0;\n      res = write_to_fd (setup_finished_pipe[1], &data, 1);\n      \/* Ignore res, if e.g. the parent died and closed setup_finished_pipe[0]\n         we don't want to error out here *\/\n    }\n\n  if (execvp (argv[0], argv) == -1)\n    {\n      if (setup_finished_pipe[1] != -1)\n        {\n          int saved_errno = errno;\n          char data = 0;\n          res = write_to_fd (setup_finished_pipe[1], &data, 1);\n          errno = saved_errno;\n          \/* Ignore res, if e.g. the parent died and closed setup_finished_pipe[0]\n             we don't want to error out here *\/\n        }\n      die_with_error (\"execvp %s\", argv[0]);\n    }\n\n  return 0;\n}","target":0,"code_token_length":5466,"total_token_length":5702,"max_tokens_setting":6144}
+{"idx":287685,"func":"int CLASS parse_tiff_ifd (int base)\n{\n  unsigned entries, tag, type, len, plen=16, save;\n  int ifd, use_cm=0, cfa, i, j, c, ima_len=0;\n  int blrr=1, blrc=1, dblack[] = { 0,0,0,0 };\n  char software[64], *cbuf, *cp;\n  uchar cfa_pat[16], cfa_pc[] = { 0,1,2,3 }, tab[256];\n  double cc[4][4], cm[4][3], cam_xyz[4][3], num;\n  double ab[]={ 1,1,1,1 }, asn[] = { 0,0,0,0 }, xyz[] = { 1,1,1 };\n  unsigned sony_curve[] = { 0,0,0,0,0,4095 };\n  unsigned *buf, sony_offset=0, sony_length=0, sony_key=0;\n  struct jhead jh;\n#ifndef LIBRAW_LIBRARY_BUILD\n  FILE *sfp;\n#endif\n\n  if (tiff_nifds >= sizeof tiff_ifd \/ sizeof tiff_ifd[0])\n    return 1;\n  ifd = tiff_nifds++;\n  for (j=0; j < 4; j++)\n    for (i=0; i < 4; i++)\n      cc[j][i] = i == j;\n  entries = get2();\n  if (entries > 512) return 1;\n  while (entries--) {\n    tiff_get (base, &tag, &type, &len, &save);\n    switch (tag) {\n      case 5:   width  = get2();  break;\n      case 6:   height = get2();  break;\n      case 7:   width += get2();  break;\n      case 9:  filters = get2();  break;\n      case 17: case 18:\n\tif (type == 3 && len == 1)\n\t  cam_mul[(tag-17)*2] = get2() \/ 256.0;\n\tbreak;\n      case 23:\n\tif (type == 3) iso_speed = get2();\n\tbreak;\n      case 36: case 37: case 38:\n\tcam_mul[tag-0x24] = get2();\n\tbreak;\n      case 39:\n\tif (len < 50 || cam_mul[0]) break;\n\tfseek (ifp, 12, SEEK_CUR);\n\tFORC3 cam_mul[c] = get2();\n\tbreak;\n      case 46:\n\tif (type != 7 || fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8) break;\n\tthumb_offset = ftell(ifp) - 2;\n\tthumb_length = len;\n\tbreak;\n      case 61440:\t\t\t\/* Fuji HS10 table *\/\n\tparse_tiff_ifd (base);\n\tbreak;\n      case 2: case 256: case 61441:\t\/* ImageWidth *\/\n\ttiff_ifd[ifd].t_width = getint(type);\n\tbreak;\n      case 3: case 257: case 61442:\t\/* ImageHeight *\/\n\ttiff_ifd[ifd].t_height = getint(type);\n\tbreak;\n      case 258:\t\t\t\t\/* BitsPerSample *\/\n      case 61443:\n\ttiff_ifd[ifd].samples = len & 7;\n\ttiff_ifd[ifd].bps = getint(type);\n\tbreak;\n      case 61446:\n\traw_height = 0;\n\tload_raw = &CLASS packed_load_raw;\n\tload_flags = get4() && (filters=0x16161616) ? 24:80;\n\tbreak;\n      case 259:\t\t\t\t\/* Compression *\/\n\ttiff_ifd[ifd].comp = getint(type);\n\tbreak;\n      case 262:\t\t\t\t\/* PhotometricInterpretation *\/\n\ttiff_ifd[ifd].phint = get2();\n\tbreak;\n      case 270:\t\t\t\t\/* ImageDescription *\/\n\tfread (desc, 512, 1, ifp);\n\tbreak;\n      case 271:\t\t\t\t\/* Make *\/\n\tfgets (make, 64, ifp);\n\tbreak;\n      case 272:\t\t\t\t\/* Model *\/\n\tfgets (model, 64, ifp);\n\tbreak;\n      case 280:\t\t\t\t\/* Panasonic RW2 offset *\/\n\tif (type != 4) break;\n\tload_raw = &CLASS panasonic_load_raw;\n\tload_flags = 0x2008;\n      case 273:\t\t\t\t\/* StripOffset *\/\n      case 513:\t\t\t\t\/* JpegIFOffset *\/\n      case 61447:\n\ttiff_ifd[ifd].offset = get4()+base;\n\tif (!tiff_ifd[ifd].bps && tiff_ifd[ifd].offset > 0) {\n\t  fseek (ifp, tiff_ifd[ifd].offset, SEEK_SET);\n\t  if (ljpeg_start (&jh, 1)) {\n\t    tiff_ifd[ifd].comp    = 6;\n\t    tiff_ifd[ifd].t_width   = jh.wide;\n\t    tiff_ifd[ifd].t_height  = jh.high;\n\t    tiff_ifd[ifd].bps     = jh.bits;\n\t    tiff_ifd[ifd].samples = jh.clrs;\n\t    if (!(jh.sraw || (jh.clrs & 1)))\n\t      tiff_ifd[ifd].t_width *= jh.clrs;\n\t    i = order;\n\t    parse_tiff (tiff_ifd[ifd].offset + 12);\n\t    order = i;\n\t  }\n\t}\n\tbreak;\n      case 274:\t\t\t\t\/* Orientation *\/\n\ttiff_ifd[ifd].t_flip = \"50132467\"[get2() & 7]-'0';\n\tbreak;\n      case 277:\t\t\t\t\/* SamplesPerPixel *\/\n\ttiff_ifd[ifd].samples = getint(type) & 7;\n\tbreak;\n      case 279:\t\t\t\t\/* StripByteCounts *\/\n      case 514:\n      case 61448:\n\ttiff_ifd[ifd].bytes = get4();\n\tbreak;\n      case 61454:\n\tFORC3 cam_mul[(4-c) % 3] = getint(type);\n\tbreak;\n      case 305:  case 11:\t\t\/* Software *\/\n\tfgets (software, 64, ifp);\n\tif (!strncmp(software,\"Adobe\",5) ||\n\t    !strncmp(software,\"dcraw\",5) ||\n\t    !strncmp(software,\"UFRaw\",5) ||\n\t    !strncmp(software,\"Bibble\",6) ||\n\t    !strncmp(software,\"Nikon Scan\",10) ||\n\t    !strcmp (software,\"Digital Photo Professional\"))\n\t  is_raw = 0;\n\tbreak;\n      case 306:\t\t\t\t\/* DateTime *\/\n\tget_timestamp(0);\n\tbreak;\n      case 315:\t\t\t\t\/* Artist *\/\n\tfread (artist, 64, 1, ifp);\n\tbreak;\n      case 322:\t\t\t\t\/* TileWidth *\/\n\ttiff_ifd[ifd].t_tile_width = getint(type);\n\tbreak;\n      case 323:\t\t\t\t\/* TileLength *\/\n\ttiff_ifd[ifd].t_tile_length = getint(type);\n\tbreak;\n      case 324:\t\t\t\t\/* TileOffsets *\/\n\ttiff_ifd[ifd].offset = len > 1 ? ftell(ifp) : get4();\n\tif (len == 4) {\n\t  load_raw = &CLASS sinar_4shot_load_raw;\n\t  is_raw = 5;\n\t}\n\tbreak;\n#ifdef LIBRAW_LIBRARY_BUILD\n      case 325:\t\t\t\t\/* TileByteCount *\/\n          tiff_ifd[ifd].tile_maxbytes = 0;\n          for(int jj=0;jj tiff_ifd[ifd].tile_maxbytes) tiff_ifd[ifd].tile_maxbytes=s;\n              }\n\tbreak;\n#endif\n      case 330:\t\t\t\t\/* SubIFDs *\/\n\tif (!strcmp(model,\"DSLR-A100\") && tiff_ifd[ifd].t_width == 3872) {\n\t  load_raw = &CLASS sony_arw_load_raw;\n\t  data_offset = get4()+base;\n\t  ifd++;  break;\n\t}\n\twhile (len--) {\n\t  i = ftell(ifp);\n\t  fseek (ifp, get4()+base, SEEK_SET);\n\t  if (parse_tiff_ifd (base)) break;\n\t  fseek (ifp, i+4, SEEK_SET);\n\t}\n\tbreak;\n      case 400:\n\tstrcpy (make, \"Sarnoff\");\n\tmaximum = 0xfff;\n\tbreak;\n      case 28688:\n\tFORC4 sony_curve[c+1] = get2() >> 2 & 0xfff;\n\tfor (i=0; i < 5; i++)\n\t  for (j = sony_curve[i]+1; j <= sony_curve[i+1]; j++)\n\t    curve[j] = curve[j-1] + (1 << i);\n\tbreak;\n      case 29184: sony_offset = get4();  break;\n      case 29185: sony_length = get4();  break;\n      case 29217: sony_key    = get4();  break;\n      case 29264:\n\tparse_minolta (ftell(ifp));\n\traw_width = 0;\n\tbreak;\n      case 29443:\n\tFORC4 cam_mul[c ^ (c < 2)] = get2();\n\tbreak;\n      case 29459:\n\tFORC4 cam_mul[c] = get2();\n\ti = (cam_mul[1] == 1024 && cam_mul[2] == 1024) << 1;\n\tSWAP (cam_mul[i],cam_mul[i+1])\n\tbreak;\n      case 33405:\t\t\t\/* Model2 *\/\n\tfgets (model2, 64, ifp);\n\tbreak;\n      case 33422:\t\t\t\/* CFAPattern *\/\n      case 64777:\t\t\t\/* Kodak P-series *\/\n\tif ((plen=len) > 16) plen = 16;\n\tfread (cfa_pat, 1, plen, ifp);\n\tfor (colors=cfa=i=0; i < plen; i++) {\n\t  colors += !(cfa & (1 << cfa_pat[i]));\n\t  cfa |= 1 << cfa_pat[i];\n\t}\n\tif (cfa == 070) memcpy (cfa_pc,\"\\003\\004\\005\",3);\t\/* CMY *\/\n\tif (cfa == 072) memcpy (cfa_pc,\"\\005\\003\\004\\001\",4);\t\/* GMCY *\/\n\tgoto guess_cfa_pc;\n      case 33424:\n      case 65024:\n\tfseek (ifp, get4()+base, SEEK_SET);\n\tparse_kodak_ifd (base);\n\tbreak;\n      case 33434:\t\t\t\/* ExposureTime *\/\n\tshutter = getreal(type);\n\tbreak;\n      case 33437:\t\t\t\/* FNumber *\/\n\taperture = getreal(type);\n\tbreak;\n      case 34306:\t\t\t\/* Leaf white balance *\/\n\tFORC4 cam_mul[c ^ 1] = 4096.0 \/ get2();\n\tbreak;\n      case 34307:\t\t\t\/* Leaf CatchLight color matrix *\/\n\tfread (software, 1, 7, ifp);\n\tif (strncmp(software,\"MATRIX\",6)) break;\n\tcolors = 4;\n\tfor (raw_color = i=0; i < 3; i++) {\n\t  FORC4 fscanf (ifp, \"%f\", &rgb_cam[i][c^1]);\n\t  if (!use_camera_wb) continue;\n\t  num = 0;\n\t  FORC4 num += rgb_cam[i][c];\n\t  FORC4 rgb_cam[i][c] \/= num;\n\t}\n\tbreak;\n      case 34310:\t\t\t\/* Leaf metadata *\/\n\tparse_mos (ftell(ifp));\n      case 34303:\n\tstrcpy (make, \"Leaf\");\n\tbreak;\n      case 34665:\t\t\t\/* EXIF tag *\/\n\tfseek (ifp, get4()+base, SEEK_SET);\n\tparse_exif (base);\n\tbreak;\n      case 34853:\t\t\t\/* GPSInfo tag *\/\n\tfseek (ifp, get4()+base, SEEK_SET);\n\tparse_gps (base);\n\tbreak;\n      case 34675:\t\t\t\/* InterColorProfile *\/\n      case 50831:\t\t\t\/* AsShotICCProfile *\/\n\tprofile_offset = ftell(ifp);\n\tprofile_length = len;\n\tbreak;\n      case 37122:\t\t\t\/* CompressedBitsPerPixel *\/\n\tkodak_cbpp = get4();\n\tbreak;\n      case 37386:\t\t\t\/* FocalLength *\/\n\tfocal_len = getreal(type);\n\tbreak;\n      case 37393:\t\t\t\/* ImageNumber *\/\n\tshot_order = getint(type);\n\tbreak;\n      case 37400:\t\t\t\/* old Kodak KDC tag *\/\n\tfor (raw_color = i=0; i < 3; i++) {\n\t  getreal(type);\n\t  FORC3 rgb_cam[i][c] = getreal(type);\n\t}\n\tbreak;\n      case 46275:\t\t\t\/* Imacon tags *\/\n\tstrcpy (make, \"Imacon\");\n\tdata_offset = ftell(ifp);\n\tima_len = len;\n\tbreak;\n      case 46279:\n\tif (!ima_len) break;\n\tfseek (ifp, 38, SEEK_CUR);\n      case 46274:\n\tfseek (ifp, 40, SEEK_CUR);\n\traw_width  = get4();\n\traw_height = get4();\n\tleft_margin = get4() & 7;\n\twidth = raw_width - left_margin - (get4() & 7);\n\ttop_margin = get4() & 7;\n\theight = raw_height - top_margin - (get4() & 7);\n\tif (raw_width == 7262 && ima_len == 234317952 ) {\n\t  height = 5412;\n\t  width  = 7216;\n\t  left_margin = 7;\n          filters=0;\n\t} else \tif (raw_width == 7262) {\n\t  height = 5444;\n\t  width  = 7244;\n\t  left_margin = 7;\n\t}\n\tfseek (ifp, 52, SEEK_CUR);\n\tFORC3 cam_mul[c] = getreal(11);\n\tfseek (ifp, 114, SEEK_CUR);\n\tflip = (get2() >> 7) * 90;\n\tif (width * height * 6 == ima_len) {\n\t  if (flip % 180 == 90) SWAP(width,height);\n\t  raw_width = width;\n\t  raw_height = height;\n\t  left_margin = top_margin = filters = flip = 0;\n\t}\n\tsprintf (model, \"Ixpress %d-Mp\", height*width\/1000000);\n\tload_raw = &CLASS imacon_full_load_raw;\n\tif (filters) {\n\t  if (left_margin & 1) filters = 0x61616161;\n\t  load_raw = &CLASS unpacked_load_raw;\n\t}\n\tmaximum = 0xffff;\n\tbreak;\n      case 50454:\t\t\t\/* Sinar tag *\/\n      case 50455:\n\tif (!(cbuf = (char *) malloc(len))) break;\n\tfread (cbuf, 1, len, ifp);\n\tfor (cp = cbuf-1; cp && cp < cbuf+len; cp = strchr(cp,'\\n'))\n\t  if (!strncmp (++cp,\"Neutral \",8))\n\t    sscanf (cp+8, \"%f %f %f\", cam_mul, cam_mul+1, cam_mul+2);\n\tfree (cbuf);\n\tbreak;\n      case 50458:\n\tif (!make[0]) strcpy (make, \"Hasselblad\");\n\tbreak;\n      case 50459:\t\t\t\/* Hasselblad tag *\/\n\ti = order;\n\tj = ftell(ifp);\n\tc = tiff_nifds;\n\torder = get2();\n\tfseek (ifp, j+(get2(),get4()), SEEK_SET);\n\tparse_tiff_ifd (j);\n\tmaximum = 0xffff;\n\ttiff_nifds = c;\n\torder = i;\n\tbreak;\n      case 50706:\t\t\t\/* DNGVersion *\/\n\tFORC4 dng_version = (dng_version << 8) + fgetc(ifp);\n\tif (!make[0]) strcpy (make, \"DNG\");\n\tis_raw = 1;\n\tbreak;\n      case 50710:\t\t\t\/* CFAPlaneColor *\/\n\tif (len > 4) len = 4;\n\tcolors = len;\n\tfread (cfa_pc, 1, colors, ifp);\nguess_cfa_pc:\n\tFORCC tab[cfa_pc[c]] = c;\n\tcdesc[c] = 0;\n\tfor (i=16; i--; )\n\t  filters = filters << 2 | tab[cfa_pat[i % plen]];\n\tbreak;\n      case 50711:\t\t\t\/* CFALayout *\/\n\tif (get2() == 2) {\n\t  fuji_width = 1;\n\t  filters = 0x49494949;\n\t}\n\tbreak;\n      case 291:\n      case 50712:\t\t\t\/* LinearizationTable *\/\n\tlinear_table (len);\n\tbreak;\n      case 50713:\t\t\t\/* BlackLevelRepeatDim *\/\n\tblrr = get2();\n\tblrc = get2();\n\tbreak;\n      case 61450:\n\tblrr = blrc = 2;\n      case 50714:\t\t\t\/* BlackLevel *\/\n\tblack = getreal(type);\n\tif (!filters || !~filters) break;\n\tdblack[0] = black;\n\tdblack[1] = (blrc == 2) ? getreal(type):dblack[0];\n\tdblack[2] = (blrr == 2) ? getreal(type):dblack[0];\n\tdblack[3] = (blrc == 2 && blrr == 2) ? getreal(type):dblack[1];\n\tif (colors == 3)\n\t  filters |= ((filters >> 2 & 0x22222222) |\n\t\t      (filters << 2 & 0x88888888)) & filters << 1;\n\tFORC4 cblack[filters >> (c << 1) & 3] = dblack[c];\n\tblack = 0;\n\tbreak;\n      case 50715:\t\t\t\/* BlackLevelDeltaH *\/\n      case 50716:\t\t\t\/* BlackLevelDeltaV *\/\n\tfor (num=i=0; i < len; i++)\n\t  num += getreal(type);\n\tblack += num\/len + 0.5;\n\tbreak;\n      case 50717:\t\t\t\/* WhiteLevel *\/\n\tmaximum = getint(type);\n\tbreak;\n      case 50718:\t\t\t\/* DefaultScale *\/\n\tpixel_aspect  = getreal(type);\n\tpixel_aspect \/= getreal(type);\n\tbreak;\n      case 50721:\t\t\t\/* ColorMatrix1 *\/\n      case 50722:\t\t\t\/* ColorMatrix2 *\/\n\tFORCC for (j=0; j < 3; j++)\n\t  cm[c][j] = getreal(type);\n\tuse_cm = 1;\n\tbreak;\n      case 50723:\t\t\t\/* CameraCalibration1 *\/\n      case 50724:\t\t\t\/* CameraCalibration2 *\/\n\tfor (i=0; i < colors; i++)\n\t  FORCC cc[i][c] = getreal(type);\n\tbreak;\n      case 50727:\t\t\t\/* AnalogBalance *\/\n\tFORCC ab[c] = getreal(type);\n\tbreak;\n      case 50728:\t\t\t\/* AsShotNeutral *\/\n\tFORCC asn[c] = getreal(type);\n\tbreak;\n      case 50729:\t\t\t\/* AsShotWhiteXY *\/\n\txyz[0] = getreal(type);\n\txyz[1] = getreal(type);\n\txyz[2] = 1 - xyz[0] - xyz[1];\n\tFORC3 xyz[c] \/= d65_white[c];\n\tbreak;\n      case 50740:\t\t\t\/* DNGPrivateData *\/\n\tif (dng_version) break;\n\tparse_minolta (j = get4()+base);\n\tfseek (ifp, j, SEEK_SET);\n\tparse_tiff_ifd (base);\n\tbreak;\n      case 50752:\n\tread_shorts (cr2_slice, 3);\n\tbreak;\n      case 50829:\t\t\t\/* ActiveArea *\/\n\ttop_margin = getint(type);\n\tleft_margin = getint(type);\n\theight = getint(type) - top_margin;\n\twidth = getint(type) - left_margin;\n\tbreak;\n      case 50830:\t\t\t\/* MaskedAreas *\/\n        for (i=0; i < len && i < 32; i++)\n\t  mask[0][i] = getint(type);\n\tblack = 0;\n\tbreak;\n      case 51009:\t\t\t\/* OpcodeList2 *\/\n\tmeta_offset = ftell(ifp);\n\tbreak;\n      case 64772:\t\t\t\/* Kodak P-series *\/\n\tif (len < 13) break;\n\tfseek (ifp, 16, SEEK_CUR);\n\tdata_offset = get4();\n\tfseek (ifp, 28, SEEK_CUR);\n\tdata_offset += get4();\n\tload_raw = &CLASS packed_load_raw;\n\tbreak;\n      case 65026:\n\tif (type == 2) fgets (model2, 64, ifp);\n    }\n    fseek (ifp, save, SEEK_SET);\n  }\n  if (sony_length && (buf = (unsigned *) malloc(sony_length))) {\n    fseek (ifp, sony_offset, SEEK_SET);\n    fread (buf, sony_length, 1, ifp);\n    sony_decrypt (buf, sony_length\/4, 1, sony_key);\n#ifndef LIBRAW_LIBRARY_BUILD\n    sfp = ifp;\n    if ((ifp = tmpfile())) {\n      fwrite (buf, sony_length, 1, ifp);\n      fseek (ifp, 0, SEEK_SET);\n      parse_tiff_ifd (-sony_offset);\n      fclose (ifp);\n    }\n    ifp = sfp;\n#else\n    if( !ifp->tempbuffer_open(buf,sony_length))\n        {\n            parse_tiff_ifd(-sony_offset);\n            ifp->tempbuffer_close();\n        }\n#endif\n    free (buf);\n  }\n  for (i=0; i < colors; i++)\n    FORCC cc[i][c] *= ab[i];\n  if (use_cm) {\n    FORCC for (i=0; i < 3; i++)\n      for (cam_xyz[c][i]=j=0; j < colors; j++)\n\tcam_xyz[c][i] += cc[c][j] * cm[j][i] * xyz[i];\n    cam_xyz_coeff (cam_xyz);\n  }\n  if (asn[0]) {\n    cam_mul[3] = 0;\n    FORCC cam_mul[c] = 1 \/ asn[c];\n  }\n  if (!use_cm)\n    FORCC pre_mul[c] \/= cc[c][c];\n  return 0;\n}","target":1,"code_token_length":5310,"total_token_length":5546,"max_tokens_setting":6144}
+{"idx":380378,"func":"HandleRFBServerMessage(rfbClient* client)\n{\n  rfbServerToClientMsg msg;\n\n  if (client->serverPort==-1)\n    client->vncRec->readTimestamp = TRUE;\n  if (!ReadFromRFBServer(client, (char *)&msg, 1))\n    return FALSE;\n\n  switch (msg.type) {\n\n  case rfbSetColourMapEntries:\n  {\n    \/* TODO:\n    int i;\n    uint16_t rgb[3];\n    XColor xc;\n\n    if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n\t\t\t   sz_rfbSetColourMapEntriesMsg - 1))\n      return FALSE;\n\n    msg.scme.firstColour = rfbClientSwap16IfLE(msg.scme.firstColour);\n    msg.scme.nColours = rfbClientSwap16IfLE(msg.scme.nColours);\n\n    for (i = 0; i < msg.scme.nColours; i++) {\n      if (!ReadFromRFBServer(client, (char *)rgb, 6))\n\treturn FALSE;\n      xc.pixel = msg.scme.firstColour + i;\n      xc.red = rfbClientSwap16IfLE(rgb[0]);\n      xc.green = rfbClientSwap16IfLE(rgb[1]);\n      xc.blue = rfbClientSwap16IfLE(rgb[2]);\n      xc.flags = DoRed|DoGreen|DoBlue;\n      XStoreColor(dpy, cmap, &xc);\n    }\n    *\/\n\n    break;\n  }\n\n  case rfbFramebufferUpdate:\n  {\n    rfbFramebufferUpdateRectHeader rect;\n    int linesToRead;\n    int bytesPerLine;\n    int i;\n\n    if (!ReadFromRFBServer(client, ((char *)&msg.fu) + 1,\n\t\t\t   sz_rfbFramebufferUpdateMsg - 1))\n      return FALSE;\n\n    msg.fu.nRects = rfbClientSwap16IfLE(msg.fu.nRects);\n\n    for (i = 0; i < msg.fu.nRects; i++) {\n      if (!ReadFromRFBServer(client, (char *)&rect, sz_rfbFramebufferUpdateRectHeader))\n\treturn FALSE;\n\n      rect.encoding = rfbClientSwap32IfLE(rect.encoding);\n      if (rect.encoding == rfbEncodingLastRect)\n\tbreak;\n\n      rect.r.x = rfbClientSwap16IfLE(rect.r.x);\n      rect.r.y = rfbClientSwap16IfLE(rect.r.y);\n      rect.r.w = rfbClientSwap16IfLE(rect.r.w);\n      rect.r.h = rfbClientSwap16IfLE(rect.r.h);\n\n\n      if (rect.encoding == rfbEncodingXCursor ||\n\t  rect.encoding == rfbEncodingRichCursor) {\n\n\tif (!HandleCursorShape(client,\n\t\t\t       rect.r.x, rect.r.y, rect.r.w, rect.r.h,\n\t\t\t       rect.encoding)) {\n\t  return FALSE;\n\t}\n\tcontinue;\n      }\n\n      if (rect.encoding == rfbEncodingPointerPos) {\n\tif (!client->HandleCursorPos(client,rect.r.x, rect.r.y)) {\n\t  return FALSE;\n\t}\n\tcontinue;\n      }\n      \n      if (rect.encoding == rfbEncodingKeyboardLedState) {\n          \/* OK! We have received a keyboard state message!!! *\/\n          client->KeyboardLedStateEnabled = 1;\n          if (client->HandleKeyboardLedState!=NULL)\n              client->HandleKeyboardLedState(client, rect.r.x, 0);\n          \/* stash it for the future *\/\n          client->CurrentKeyboardLedState = rect.r.x;\n          continue;\n      }\n\n      if (rect.encoding == rfbEncodingNewFBSize) {\n\tclient->width = rect.r.w;\n\tclient->height = rect.r.h;\n\tclient->updateRect.x = client->updateRect.y = 0;\n\tclient->updateRect.w = client->width;\n\tclient->updateRect.h = client->height;\n  if (!client->MallocFrameBuffer(client))\n    return FALSE;\n\tSendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE);\n\trfbClientLog(\"Got new framebuffer size: %dx%d\\n\", rect.r.w, rect.r.h);\n\tcontinue;\n      }\n\n      \/* rect.r.w=byte count *\/\n      if (rect.encoding == rfbEncodingSupportedMessages) {\n          int loop;\n          if (!ReadFromRFBServer(client, (char *)&client->supportedMessages, sz_rfbSupportedMessages))\n              return FALSE;\n\n          \/* msgs is two sets of bit flags of supported messages client2server[] and server2client[] *\/\n          \/* currently ignored by this library *\/\n\n          rfbClientLog(\"client2server supported messages (bit flags)\\n\");\n          for (loop=0;loop<32;loop+=8)\n            rfbClientLog(\"%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\\n\", loop,\n                client->supportedMessages.client2server[loop],   client->supportedMessages.client2server[loop+1],\n                client->supportedMessages.client2server[loop+2], client->supportedMessages.client2server[loop+3],\n                client->supportedMessages.client2server[loop+4], client->supportedMessages.client2server[loop+5],\n                client->supportedMessages.client2server[loop+6], client->supportedMessages.client2server[loop+7]);\n\n          rfbClientLog(\"server2client supported messages (bit flags)\\n\");\n          for (loop=0;loop<32;loop+=8)\n            rfbClientLog(\"%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\\n\", loop,\n                client->supportedMessages.server2client[loop],   client->supportedMessages.server2client[loop+1],\n                client->supportedMessages.server2client[loop+2], client->supportedMessages.server2client[loop+3],\n                client->supportedMessages.server2client[loop+4], client->supportedMessages.server2client[loop+5],\n                client->supportedMessages.server2client[loop+6], client->supportedMessages.server2client[loop+7]);\n          continue;\n      }\n\n      \/* rect.r.w=byte count, rect.r.h=# of encodings *\/\n      if (rect.encoding == rfbEncodingSupportedEncodings) {\n          char *buffer;\n          buffer = malloc(rect.r.w);\n          if (!ReadFromRFBServer(client, buffer, rect.r.w))\n          {\n              free(buffer);\n              return FALSE;\n          }\n\n          \/* buffer now contains rect.r.h # of uint32_t encodings that the server supports *\/\n          \/* currently ignored by this library *\/\n          free(buffer);\n          continue;\n      }\n\n      \/* rect.r.w=byte count *\/\n      if (rect.encoding == rfbEncodingServerIdentity) {\n          char *buffer;\n          buffer = malloc(rect.r.w+1);\n          if (!ReadFromRFBServer(client, buffer, rect.r.w))\n          {\n              free(buffer);\n              return FALSE;\n          }\n          buffer[rect.r.w]=0; \/* null terminate, just in case *\/\n          rfbClientLog(\"Connected to Server \\\"%s\\\"\\n\", buffer);\n          free(buffer);\n          continue;\n      }\n\n      \/* rfbEncodingUltraZip is a collection of subrects.   x = # of subrects, and h is always 0 *\/\n      if (rect.encoding != rfbEncodingUltraZip)\n      {\n        if ((rect.r.x + rect.r.w > client->width) ||\n\t    (rect.r.y + rect.r.h > client->height))\n\t    {\n\t      rfbClientLog(\"Rect too large: %dx%d at (%d, %d)\\n\",\n\t  \t  rect.r.w, rect.r.h, rect.r.x, rect.r.y);\n\t      return FALSE;\n            }\n\n        \/* UltraVNC with scaling, will send rectangles with a zero W or H\n         *\n        if ((rect.encoding != rfbEncodingTight) && \n            (rect.r.h * rect.r.w == 0))\n        {\n\t  rfbClientLog(\"Zero size rect - ignoring (encoding=%d (0x%08x) %dx, %dy, %dw, %dh)\\n\", rect.encoding, rect.encoding, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n\t  continue;\n        }\n        *\/\n        \n        \/* If RichCursor encoding is used, we should prevent collisions\n\t   between framebuffer updates and cursor drawing operations. *\/\n        client->SoftCursorLockArea(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n      }\n\n      switch (rect.encoding) {\n\n      case rfbEncodingRaw: {\n\tint y=rect.r.y, h=rect.r.h;\n\n\tbytesPerLine = rect.r.w * client->format.bitsPerPixel \/ 8;\n\tlinesToRead = RFB_BUFFER_SIZE \/ bytesPerLine;\n\n\twhile (h > 0) {\n\t  if (linesToRead > h)\n\t    linesToRead = h;\n\n\t  if (!ReadFromRFBServer(client, client->buffer,bytesPerLine * linesToRead))\n\t    return FALSE;\n\n\t  CopyRectangle(client, (uint8_t *)client->buffer,\n\t\t\t   rect.r.x, y, rect.r.w,linesToRead);\n\n\t  h -= linesToRead;\n\t  y += linesToRead;\n\n\t}\n      } break;\n\n      case rfbEncodingCopyRect:\n      {\n\trfbCopyRect cr;\n\n\tif (!ReadFromRFBServer(client, (char *)&cr, sz_rfbCopyRect))\n\t  return FALSE;\n\n\tcr.srcX = rfbClientSwap16IfLE(cr.srcX);\n\tcr.srcY = rfbClientSwap16IfLE(cr.srcY);\n\n\t\/* If RichCursor encoding is used, we should extend our\n\t   \"cursor lock area\" (previously set to destination\n\t   rectangle) to the source rectangle as well. *\/\n\tclient->SoftCursorLockArea(client,\n\t\t\t\t   cr.srcX, cr.srcY, rect.r.w, rect.r.h);\n\n        if (client->GotCopyRect != NULL) {\n          client->GotCopyRect(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h,\n              rect.r.x, rect.r.y);\n        } else\n\t\tCopyRectangleFromRectangle(client,\n\t\t\t\t   cr.srcX, cr.srcY, rect.r.w, rect.r.h,\n\t\t\t\t   rect.r.x, rect.r.y);\n\n\tbreak;\n      }\n\n      case rfbEncodingRRE:\n      {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t  if (!HandleRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 16:\n\t  if (!HandleRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 32:\n\t  if (!HandleRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\t}\n\tbreak;\n      }\n\n      case rfbEncodingCoRRE:\n      {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t  if (!HandleCoRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 16:\n\t  if (!HandleCoRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 32:\n\t  if (!HandleCoRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\t}\n\tbreak;\n      }\n\n      case rfbEncodingHextile:\n      {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t  if (!HandleHextile8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 16:\n\t  if (!HandleHextile16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 32:\n\t  if (!HandleHextile32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\t}\n\tbreak;\n      }\n\n      case rfbEncodingUltra:\n      {\n        switch (client->format.bitsPerPixel) {\n        case 8:\n          if (!HandleUltra8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n            return FALSE;\n          break;\n        case 16:\n          if (!HandleUltra16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n            return FALSE;\n          break;\n        case 32:\n          if (!HandleUltra32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n            return FALSE;\n          break;\n        }\n        break;\n      }\n      case rfbEncodingUltraZip:\n      {\n        switch (client->format.bitsPerPixel) {\n        case 8:\n          if (!HandleUltraZip8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n            return FALSE;\n          break;\n        case 16:\n          if (!HandleUltraZip16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n            return FALSE;\n          break;\n        case 32:\n          if (!HandleUltraZip32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n            return FALSE;\n          break;\n        }\n        break;\n      }\n\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n      case rfbEncodingZlib:\n      {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t  if (!HandleZlib8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 16:\n\t  if (!HandleZlib16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 32:\n\t  if (!HandleZlib32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\t}\n\tbreak;\n     }\n\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n      case rfbEncodingTight:\n      {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t  if (!HandleTight8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 16:\n\t  if (!HandleTight16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 32:\n\t  if (!HandleTight32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\t}\n\tbreak;\n      }\n#endif\n      case rfbEncodingZRLE:\n\t\/* Fail safe for ZYWRLE unsupport VNC server. *\/\n\tclient->appData.qualityLevel = 9;\n\t\/* fall through *\/\n      case rfbEncodingZYWRLE:\n      {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t  if (!HandleZRLE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\tcase 16:\n\t  if (client->si.format.greenMax > 0x1F) {\n\t    if (!HandleZRLE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t      return FALSE;\n\t  } else {\n\t    if (!HandleZRLE15(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t      return FALSE;\n\t  }\n\t  break;\n\tcase 32:\n\t{\n\t  uint32_t maxColor=(client->format.redMax<format.redShift)|\n\t\t(client->format.greenMax<format.greenShift)|\n\t\t(client->format.blueMax<format.blueShift);\n\t  if ((client->format.bigEndian && (maxColor&0xff)==0) ||\n\t      (!client->format.bigEndian && (maxColor&0xff000000)==0)) {\n\t    if (!HandleZRLE24(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t      return FALSE;\n\t  } else if (!client->format.bigEndian && (maxColor&0xff)==0) {\n\t    if (!HandleZRLE24Up(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t      return FALSE;\n\t  } else if (client->format.bigEndian && (maxColor&0xff000000)==0) {\n\t    if (!HandleZRLE24Down(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t      return FALSE;\n\t  } else if (!HandleZRLE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t    return FALSE;\n\t  break;\n\t}\n\t}\n\tbreak;\n     }\n\n#endif\n#ifdef LIBVNCSERVER_CONFIG_LIBVA\n      case rfbEncodingH264:\n      {\n\tif (!HandleH264(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n\t  return FALSE;\n\tbreak;\n      }\n#endif\n\n      default:\n\t {\n\t   rfbBool handled = FALSE;\n\t   rfbClientProtocolExtension* e;\n\n\t   for(e = rfbClientExtensions; !handled && e; e = e->next)\n\t     if(e->handleEncoding && e->handleEncoding(client, &rect))\n\t       handled = TRUE;\n\n\t   if(!handled) {\n\t     rfbClientLog(\"Unknown rect encoding %d\\n\",\n\t\t (int)rect.encoding);\n\t     return FALSE;\n\t   }\n\t }\n      }\n\n      \/* Now we may discard \"soft cursor locks\". *\/\n      client->SoftCursorUnlockScreen(client);\n\n      client->GotFrameBufferUpdate(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n    }\n\n    if (!SendIncrementalFramebufferUpdateRequest(client))\n      return FALSE;\n\n    if (client->FinishedFrameBufferUpdate)\n      client->FinishedFrameBufferUpdate(client);\n\n    break;\n  }\n\n  case rfbBell:\n  {\n    client->Bell(client);\n\n    break;\n  }\n\n  case rfbServerCutText:\n  {\n    char *buffer;\n\n    if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n\t\t\t   sz_rfbServerCutTextMsg - 1))\n      return FALSE;\n\n    msg.sct.length = rfbClientSwap32IfLE(msg.sct.length);\n\n    buffer = malloc(msg.sct.length+1);\n\n    if (!ReadFromRFBServer(client, buffer, msg.sct.length))\n      return FALSE;\n\n    buffer[msg.sct.length] = 0;\n\n    if (client->GotXCutText)\n      client->GotXCutText(client, buffer, msg.sct.length);\n\n    free(buffer);\n\n    break;\n  }\n\n  case rfbTextChat:\n  {\n      char *buffer=NULL;\n      if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n                             sz_rfbTextChatMsg- 1))\n        return FALSE;\n      msg.tc.length = rfbClientSwap32IfLE(msg.sct.length);\n      switch(msg.tc.length) {\n      case rfbTextChatOpen:\n          rfbClientLog(\"Received TextChat Open\\n\");\n          if (client->HandleTextChat!=NULL)\n              client->HandleTextChat(client, (int)rfbTextChatOpen, NULL);\n          break;\n      case rfbTextChatClose:\n          rfbClientLog(\"Received TextChat Close\\n\");\n         if (client->HandleTextChat!=NULL)\n              client->HandleTextChat(client, (int)rfbTextChatClose, NULL);\n          break;\n      case rfbTextChatFinished:\n          rfbClientLog(\"Received TextChat Finished\\n\");\n         if (client->HandleTextChat!=NULL)\n              client->HandleTextChat(client, (int)rfbTextChatFinished, NULL);\n          break;\n      default:\n          buffer=malloc(msg.tc.length+1);\n          if (!ReadFromRFBServer(client, buffer, msg.tc.length))\n          {\n              free(buffer);\n              return FALSE;\n          }\n          \/* Null Terminate  *\/\n          buffer[msg.tc.length]=0;\n          rfbClientLog(\"Received TextChat \\\"%s\\\"\\n\", buffer);\n          if (client->HandleTextChat!=NULL)\n              client->HandleTextChat(client, (int)msg.tc.length, buffer);\n          free(buffer);\n          break;\n      }\n      break;\n  }\n\n  case rfbXvp:\n  {\n    if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n                           sz_rfbXvpMsg -1))\n      return FALSE;\n\n    SetClient2Server(client, rfbXvp);\n    \/* technically, we only care what we can *send* to the server\n     * but, we set Server2Client Just in case it ever becomes useful\n     *\/\n    SetServer2Client(client, rfbXvp);\n\n    if(client->HandleXvpMsg)\n      client->HandleXvpMsg(client, msg.xvp.version, msg.xvp.code);\n\n    break;\n  }\n\n  case rfbResizeFrameBuffer:\n  {\n    if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n                           sz_rfbResizeFrameBufferMsg -1))\n      return FALSE;\n    client->width = rfbClientSwap16IfLE(msg.rsfb.framebufferWidth);\n    client->height = rfbClientSwap16IfLE(msg.rsfb.framebufferHeigth);\n    client->updateRect.x = client->updateRect.y = 0;\n    client->updateRect.w = client->width;\n    client->updateRect.h = client->height;\n    if (!client->MallocFrameBuffer(client))\n      return FALSE;\n\n    SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);\n    rfbClientLog(\"Got new framebuffer size: %dx%d\\n\", client->width, client->height);\n    break;\n  }\n\n  case rfbPalmVNCReSizeFrameBuffer:\n  {\n    if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n                           sz_rfbPalmVNCReSizeFrameBufferMsg -1))\n      return FALSE;\n    client->width = rfbClientSwap16IfLE(msg.prsfb.buffer_w);\n    client->height = rfbClientSwap16IfLE(msg.prsfb.buffer_h);\n    client->updateRect.x = client->updateRect.y = 0;\n    client->updateRect.w = client->width;\n    client->updateRect.h = client->height;\n    if (!client->MallocFrameBuffer(client))\n      return FALSE;\n    SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);\n    rfbClientLog(\"Got new framebuffer size: %dx%d\\n\", client->width, client->height);\n    break;\n  }\n\n  default:\n    {\n      rfbBool handled = FALSE;\n      rfbClientProtocolExtension* e;\n\n      for(e = rfbClientExtensions; !handled && e; e = e->next)\n\tif(e->handleMessage && e->handleMessage(client, &msg))\n\t  handled = TRUE;\n\n      if(!handled) {\n\tchar buffer[256];\n\trfbClientLog(\"Unknown message type %d from VNC server\\n\",msg.type);\n\tReadFromRFBServer(client, buffer, 256);\n\treturn FALSE;\n      }\n    }\n  }\n\n  return TRUE;\n}","target":0,"code_token_length":5079,"total_token_length":5315,"max_tokens_setting":6144}
+{"idx":338292,"func":"static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,\n\n             int srcSliceH, uint8_t* dstParam[], int dstStride[]){\n\n\n\n\t\/* load a few things into local vars to make the code more readable? and faster *\/\n\n\tconst int srcW= c->srcW;\n\n\tconst int dstW= c->dstW;\n\n\tconst int dstH= c->dstH;\n\n\tconst int chrDstW= c->chrDstW;\n\n\tconst int lumXInc= c->lumXInc;\n\n\tconst int chrXInc= c->chrXInc;\n\n\tconst int dstFormat= c->dstFormat;\n\n\tconst int flags= c->flags;\n\n\tconst int canMMX2BeUsed= c->canMMX2BeUsed;\n\n\tint16_t *vLumFilterPos= c->vLumFilterPos;\n\n\tint16_t *vChrFilterPos= c->vChrFilterPos;\n\n\tint16_t *hLumFilterPos= c->hLumFilterPos;\n\n\tint16_t *hChrFilterPos= c->hChrFilterPos;\n\n\tint16_t *vLumFilter= c->vLumFilter;\n\n\tint16_t *vChrFilter= c->vChrFilter;\n\n\tint16_t *hLumFilter= c->hLumFilter;\n\n\tint16_t *hChrFilter= c->hChrFilter;\n\n\tint16_t *lumMmxFilter= c->lumMmxFilter;\n\n\tint16_t *chrMmxFilter= c->chrMmxFilter;\n\n\tconst int vLumFilterSize= c->vLumFilterSize;\n\n\tconst int vChrFilterSize= c->vChrFilterSize;\n\n\tconst int hLumFilterSize= c->hLumFilterSize;\n\n\tconst int hChrFilterSize= c->hChrFilterSize;\n\n\tint16_t **lumPixBuf= c->lumPixBuf;\n\n\tint16_t **chrPixBuf= c->chrPixBuf;\n\n\tconst int vLumBufSize= c->vLumBufSize;\n\n\tconst int vChrBufSize= c->vChrBufSize;\n\n\tuint8_t *funnyYCode= c->funnyYCode;\n\n\tuint8_t *funnyUVCode= c->funnyUVCode;\n\n\tuint8_t *formatConvBuffer= c->formatConvBuffer;\n\n\n\n\t\/* vars whch will change and which we need to storw back in the context *\/\n\n\tint dstY= c->dstY;\n\n\tint lumBufIndex= c->lumBufIndex;\n\n\tint chrBufIndex= c->chrBufIndex;\n\n\tint lastInLumBuf= c->lastInLumBuf;\n\n\tint lastInChrBuf= c->lastInChrBuf;\n\n\tint srcStride[3];\n\n\tuint8_t *src[3];\n\n\tuint8_t *dst[3];\n\n\t\n\n\tif((c->srcFormat == IMGFMT_IYUV) || (c->srcFormat == IMGFMT_I420)){\n\n\t\tsrc[0]= srcParam[0];\n\n\t\tsrc[1]= srcParam[2];\n\n\t\tsrc[2]= srcParam[1];\n\n\t\tsrcStride[0]= srcStrideParam[0];\n\n\t\tsrcStride[1]= srcStrideParam[2];\n\n\t\tsrcStride[2]= srcStrideParam[1];\n\n\t}\n\n\telse if(c->srcFormat==IMGFMT_YV12){\n\n\t\tsrc[0]= srcParam[0];\n\n\t\tsrc[1]= srcParam[1];\n\n\t\tsrc[2]= srcParam[2];\n\n\t\tsrcStride[0]= srcStrideParam[0];\n\n\t\tsrcStride[1]= srcStrideParam[1];\n\n\t\tsrcStride[2]= srcStrideParam[2];\n\n\t}\n\n\telse if(isPacked(c->srcFormat)){\n\n\t\tsrc[0]=\n\n\t\tsrc[1]=\n\n\t\tsrc[2]= srcParam[0];\n\n\t\tsrcStride[0]= srcStrideParam[0];\n\n\t\tsrcStride[1]=\n\n\t\tsrcStride[2]= srcStrideParam[0]<<1;\n\n\t}\n\n\telse if(c->srcFormat==IMGFMT_Y8){\n\n\t\tsrc[0]= srcParam[0];\n\n\t\tsrc[1]=\n\n\t\tsrc[2]= NULL;\n\n\t\tsrcStride[0]= srcStrideParam[0];\n\n\t\tsrcStride[1]=\n\n\t\tsrcStride[2]= 0;\n\n\t}\n\n\n\n\tif((c->dstFormat == IMGFMT_IYUV) || (c->dstFormat == IMGFMT_I420)){\n\n\t\tdst[0]= dstParam[0];\n\n\t\tdst[1]= dstParam[2];\n\n\t\tdst[2]= dstParam[1];\n\n\t\t\n\n\t}else{\n\n\t\tdst[0]= dstParam[0];\n\n\t\tdst[1]= dstParam[1];\n\n\t\tdst[2]= dstParam[2];\n\n\t}\n\n\t\n\n\n\n\tif(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)\n\n\t{\n\n\t\tstatic int firstTime=1; \/\/FIXME move this into the context perhaps\n\n\t\tif(flags & SWS_PRINT_INFO && firstTime)\n\n\t\t{\n\n\t\t\tfprintf(stderr, \"SwScaler: Warning: dstStride is not aligned!\\n\"\n\n\t\t\t\t\t\"SwScaler:          ->cannot do aligned memory acesses anymore\\n\");\n\n\t\t\tfirstTime=0;\n\n\t\t}\n\n\t}\n\n\n\n\t\/* Note the user might start scaling the picture in the middle so this will not get executed\n\n\t   this is not really intended but works currently, so ppl might do it *\/\n\n\tif(srcSliceY ==0){\n\n\t\tlumBufIndex=0;\n\n\t\tchrBufIndex=0;\n\n\t\tdstY=0;\t\n\n\t\tlastInLumBuf= -1;\n\n\t\tlastInChrBuf= -1;\n\n\t}\n\n\n\n\tfor(;dstY < dstH; dstY++){\n\n\t\tunsigned char *dest =dst[0]+dstStride[0]*dstY;\n\n\t\tunsigned char *uDest=dst[1]+dstStride[1]*(dstY>>1);\n\n\t\tunsigned char *vDest=dst[2]+dstStride[2]*(dstY>>1);\n\n\t\tconst int chrDstY= isHalfChrV(dstFormat) ? (dstY>>1) : dstY;\n\n\n\n\t\tconst int firstLumSrcY= vLumFilterPos[dstY]; \/\/First line needed as input\n\n\t\tconst int firstChrSrcY= vChrFilterPos[chrDstY]; \/\/First line needed as input\n\n\t\tconst int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; \/\/ Last line needed as input\n\n\t\tconst int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; \/\/ Last line needed as input\n\n\n\n\t\t\/\/handle holes (FAST_BILINEAR & weird filters)\n\n\t\tif(firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;\n\n\t\tif(firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;\n\n\/\/printf(\"%d %d %d\\n\", firstChrSrcY, lastInChrBuf, vChrBufSize);\n\n\t\tASSERT(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1)\n\n\t\tASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)\n\n\n\n\t\t\/\/ Do we have enough lines in this slice to output the dstY line\n\n\t\tif(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < ((srcSliceY + srcSliceH)>>1))\n\n\t\t{\n\n\t\t\t\/\/Do horizontal scaling\n\n\t\t\twhile(lastInLumBuf < lastLumSrcY)\n\n\t\t\t{\n\n\t\t\t\tuint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];\n\n\t\t\t\tlumBufIndex++;\n\n\/\/\t\t\t\tprintf(\"%d %d %d %d\\n\", lumBufIndex, vLumBufSize, lastInLumBuf,  lastLumSrcY);\n\n\t\t\t\tASSERT(lumBufIndex < 2*vLumBufSize)\n\n\t\t\t\tASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)\n\n\t\t\t\tASSERT(lastInLumBuf + 1 - srcSliceY >= 0)\n\n\/\/\t\t\t\tprintf(\"%d %d\\n\", lumBufIndex, vLumBufSize);\n\n\t\t\t\tRENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,\n\n\t\t\t\t\t\tflags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,\n\n\t\t\t\t\t\tfunnyYCode, c->srcFormat, formatConvBuffer);\n\n\t\t\t\tlastInLumBuf++;\n\n\t\t\t}\n\n\t\t\twhile(lastInChrBuf < lastChrSrcY)\n\n\t\t\t{\n\n\t\t\t\tuint8_t *src1= src[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[1];\n\n\t\t\t\tuint8_t *src2= src[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[2];\n\n\t\t\t\tchrBufIndex++;\n\n\t\t\t\tASSERT(chrBufIndex < 2*vChrBufSize)\n\n\t\t\t\tASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < (srcSliceH>>1))\n\n\t\t\t\tASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0)\n\n\t\t\t\t\/\/FIXME replace parameters through context struct (some at least)\n\n\t\t\t\tRENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc,\n\n\t\t\t\t\t\tflags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,\n\n\t\t\t\t\t\tfunnyUVCode, c->srcFormat, formatConvBuffer);\n\n\t\t\t\tlastInChrBuf++;\n\n\t\t\t}\n\n\t\t\t\/\/wrap buf index around to stay inside the ring buffer\n\n\t\t\tif(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;\n\n\t\t\tif(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;\n\n\t\t}\n\n\t\telse \/\/ not enough lines left in this slice -> load the rest in the buffer\n\n\t\t{\n\n\/*\t\tprintf(\"%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\\n\",\n\n\t\t\tfirstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,\n\n\t\t\tlastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,\n\n\t\t\tvChrBufSize, vLumBufSize);\n\n*\/\n\n\t\t\t\/\/Do horizontal scaling\n\n\t\t\twhile(lastInLumBuf+1 < srcSliceY + srcSliceH)\n\n\t\t\t{\n\n\t\t\t\tuint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];\n\n\t\t\t\tlumBufIndex++;\n\n\t\t\t\tASSERT(lumBufIndex < 2*vLumBufSize)\n\n\t\t\t\tASSERT(lastInLumBuf + 1 - srcSliceY < srcSliceH)\n\n\t\t\t\tASSERT(lastInLumBuf + 1 - srcSliceY >= 0)\n\n\t\t\t\tRENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,\n\n\t\t\t\t\t\tflags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,\n\n\t\t\t\t\t\tfunnyYCode, c->srcFormat, formatConvBuffer);\n\n\t\t\t\tlastInLumBuf++;\n\n\t\t\t}\n\n\t\t\twhile(lastInChrBuf+1 < ((srcSliceY + srcSliceH)>>1))\n\n\t\t\t{\n\n\t\t\t\tuint8_t *src1= src[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[1];\n\n\t\t\t\tuint8_t *src2= src[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[2];\n\n\t\t\t\tchrBufIndex++;\n\n\t\t\t\tASSERT(chrBufIndex < 2*vChrBufSize)\n\n\t\t\t\tASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < (srcSliceH>>1))\n\n\t\t\t\tASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0)\n\n\t\t\t\tRENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc,\n\n\t\t\t\t\t\tflags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,\n\n\t\t\t\t\t\tfunnyUVCode, c->srcFormat, formatConvBuffer);\n\n\t\t\t\tlastInChrBuf++;\n\n\t\t\t}\n\n\t\t\t\/\/wrap buf index around to stay inside the ring buffer\n\n\t\t\tif(lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize;\n\n\t\t\tif(chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize;\n\n\t\t\tbreak; \/\/we cant output a dstY line so lets try with the next slice\n\n\t\t}\n\n\n\n#ifdef HAVE_MMX\n\n\t\tb5Dither= dither8[dstY&1];\n\n\t\tg6Dither= dither4[dstY&1];\n\n\t\tg5Dither= dither8[dstY&1];\n\n\t\tr5Dither= dither8[(dstY+1)&1];\n\n#endif\n\n\t    if(dstY < dstH-2)\n\n\t    {\n\n\t\tif(isPlanarYUV(dstFormat)) \/\/YV12 like\n\n\t\t{\n\n\t\t\tif(dstY&1) uDest=vDest= NULL; \/\/FIXME split functions in lumi \/ chromi\n\n\t\t\tif(vLumFilterSize == 1 && vChrFilterSize == 1) \/\/ Unscaled YV12\n\n\t\t\t{\n\n\t\t\t\tint16_t *lumBuf = lumPixBuf[0];\n\n\t\t\t\tint16_t *chrBuf= chrPixBuf[0];\n\n\t\t\t\tRENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW);\n\n\t\t\t}\n\n\t\t\telse \/\/General YV12\n\n\t\t\t{\n\n\t\t\t\tint16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;\n\n\t\t\t\tint16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;\n\n\t\t\t\tRENAME(yuv2yuvX)(\n\n\t\t\t\t\tvLumFilter+dstY*vLumFilterSize     , lumSrcPtr, vLumFilterSize,\n\n\t\t\t\t\tvChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize,\n\n\t\t\t\t\tdest, uDest, vDest, dstW,\n\n\t\t\t\t\tlumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+(dstY>>1)*vChrFilterSize*4);\n\n\t\t\t}\n\n\t\t}\n\n\t\telse\n\n\t\t{\n\n\t\t\tint16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;\n\n\t\t\tint16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;\n\n\n\n\t\t\tASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);\n\n\t\t\tASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);\n\n\t\t\tif(vLumFilterSize == 1 && vChrFilterSize == 2) \/\/Unscaled RGB\n\n\t\t\t{\n\n\t\t\t\tint chrAlpha= vChrFilter[2*dstY+1];\n\n\n\n\t\t\t\tRENAME(yuv2rgb1)(*lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),\n\n\t\t\t\t\t\t dest, dstW, chrAlpha, dstFormat, flags);\n\n\t\t\t}\n\n\t\t\telse if(vLumFilterSize == 2 && vChrFilterSize == 2) \/\/BiLinear Upscale RGB\n\n\t\t\t{\n\n\t\t\t\tint lumAlpha= vLumFilter[2*dstY+1];\n\n\t\t\t\tint chrAlpha= vChrFilter[2*dstY+1];\n\n\n\n\t\t\t\tRENAME(yuv2rgb2)(*lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),\n\n\t\t\t\t\t\t dest, dstW, lumAlpha, chrAlpha, dstFormat, flags);\n\n\t\t\t}\n\n\t\t\telse \/\/General RGB\n\n\t\t\t{\n\n\t\t\t\tRENAME(yuv2rgbX)(\n\n\t\t\t\t\tvLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,\n\n\t\t\t\t\tvChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,\n\n\t\t\t\t\tdest, dstW, dstFormat,\n\n\t\t\t\t\tlumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+dstY*vChrFilterSize*4);\n\n\t\t\t}\n\n\t\t}\n\n            }\n\n\t    else \/\/ hmm looks like we cant use MMX here without overwriting this arrays tail\n\n\t    {\n\n\t\tint16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;\n\n\t\tint16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;\n\n\t\tif(isPlanarYUV(dstFormat)) \/\/YV12\n\n\t\t{\n\n\t\t\tif(dstY&1) uDest=vDest= NULL; \/\/FIXME split functions in lumi \/ chromi\n\n\t\t\tyuv2yuvXinC(\n\n\t\t\t\tvLumFilter+dstY*vLumFilterSize     , lumSrcPtr, vLumFilterSize,\n\n\t\t\t\tvChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize,\n\n\t\t\t\tdest, uDest, vDest, dstW);\n\n\t\t}\n\n\t\telse\n\n\t\t{\n\n\t\t\tASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);\n\n\t\t\tASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2);\n\n\t\t\tyuv2rgbXinC(\n\n\t\t\t\tvLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,\n\n\t\t\t\tvChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,\n\n\t\t\t\tdest, dstW, dstFormat);\n\n\t\t}\n\n\t    }\n\n\t}\n\n\n\n#ifdef HAVE_MMX\n\n\t__asm __volatile(SFENCE:::\"memory\");\n\n\t__asm __volatile(EMMS:::\"memory\");\n\n#endif\n\n\t\/* store changed local vars back in the context *\/\n\n\tc->dstY= dstY;\n\n\tc->lumBufIndex= lumBufIndex;\n\n\tc->chrBufIndex= chrBufIndex;\n\n\tc->lastInLumBuf= lastInLumBuf;\n\n\tc->lastInChrBuf= lastInChrBuf;\n\n}\n","target":0,"code_token_length":4094,"total_token_length":4330,"max_tokens_setting":6144}
+{"idx":386806,"func":"static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,\n                                 OPJ_BYTE * p_header_data,\n                                 OPJ_UINT32 p_header_size,\n                                 opj_event_mgr_t * p_manager\n                                 )\n{\n        OPJ_UINT32 i;\n        OPJ_UINT32 l_nb_comp;\n        OPJ_UINT32 l_nb_comp_remain;\n        OPJ_UINT32 l_remaining_size;\n        OPJ_UINT32 l_nb_tiles;\n        OPJ_UINT32 l_tmp, l_tx1, l_ty1;\n        opj_image_t *l_image = 00;\n        opj_cp_t *l_cp = 00;\n        opj_image_comp_t * l_img_comp = 00;\n        opj_tcp_t * l_current_tile_param = 00;\n\n        \/* preconditions *\/\n        assert(p_j2k != 00);\n        assert(p_manager != 00);\n        assert(p_header_data != 00);\n\n        l_image = p_j2k->m_private_image;\n        l_cp = &(p_j2k->m_cp);\n\n        \/* minimum size == 39 - 3 (= minimum component parameter) *\/\n        if (p_header_size < 36) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker size\\n\");\n                return OPJ_FALSE;\n        }\n\n        l_remaining_size = p_header_size - 36;\n        l_nb_comp = l_remaining_size \/ 3;\n        l_nb_comp_remain = l_remaining_size % 3;\n        if (l_nb_comp_remain != 0){\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker size\\n\");\n                return OPJ_FALSE;\n        }\n\n        opj_read_bytes(p_header_data,&l_tmp ,2);                                                \/* Rsiz (capabilities) *\/\n        p_header_data+=2;\n        l_cp->rsiz = (OPJ_UINT16) l_tmp;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x1, 4);   \/* Xsiz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y1, 4);   \/* Ysiz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x0, 4);   \/* X0siz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y0, 4);   \/* Y0siz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdx, 4);             \/* XTsiz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdy, 4);             \/* YTsiz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tx0, 4);             \/* XT0siz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->ty0, 4);             \/* YT0siz *\/\n        p_header_data+=4;\n        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_tmp, 2);                 \/* Csiz *\/\n        p_header_data+=2;\n        if (l_tmp < 16385)\n                l_image->numcomps = (OPJ_UINT16) l_tmp;\n        else {\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker: number of component is illegal -> %d\\n\", l_tmp);\n                return OPJ_FALSE;\n        }\n\n        if (l_image->numcomps != l_nb_comp) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker: number of component is not compatible with the remaining number of parameters ( %d vs %d)\\n\", l_image->numcomps, l_nb_comp);\n                return OPJ_FALSE;\n        }\n\n        \/* testcase 4035.pdf.SIGSEGV.d8b.3375 *\/\n        \/* testcase issue427-null-image-size.jp2 *\/\n        if ((l_image->x0 >= l_image->x1) || (l_image->y0 >= l_image->y1)) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker: negative or zero image size (%d x %d)\\n\", l_image->x1 - l_image->x0, l_image->y1 - l_image->y0);\n                return OPJ_FALSE;\n        }\n        \/* testcase 2539.pdf.SIGFPE.706.1712 (also 3622.pdf.SIGFPE.706.2916 and 4008.pdf.SIGFPE.706.3345 and maybe more) *\/\n        if (!(l_cp->tdx * l_cp->tdy)) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker: invalid tile size (tdx: %d, tdy: %d)\\n\", l_cp->tdx, l_cp->tdy);\n                return OPJ_FALSE;\n        }\n\n        \/* testcase 1610.pdf.SIGSEGV.59c.681 *\/\n        if (((OPJ_UINT64)l_image->x1) * ((OPJ_UINT64)l_image->y1) != (l_image->x1 * l_image->y1)) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Prevent buffer overflow (x1: %d, y1: %d)\\n\", l_image->x1, l_image->y1);\n                return OPJ_FALSE;\n        }\n\n        \/* testcase issue427-illegal-tile-offset.jp2 *\/\n        l_tx1 = l_cp->tx0 + l_cp->tdx;\n        if (l_tx1 < l_cp->tx0) { \/* manage overflow *\/\n                l_tx1 = 0xFFFFFFFFU;\n        }\n        l_ty1 = l_cp->ty0 + l_cp->tdy;\n        if (l_ty1 < l_cp->ty0) { \/* manage overflow *\/\n                l_ty1 = 0xFFFFFFFFU;\n        }\n        if ((l_cp->tx0 > l_image->x0) || (l_cp->ty0 > l_image->y0) || (l_tx1 <= l_image->x0) || (l_ty1 <= l_image->y0) ) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Error with SIZ marker: illegal tile offset\\n\");\n                return OPJ_FALSE;\n        }\n\n#ifdef USE_JPWL\n        if (l_cp->correct) {\n                \/* if JPWL is on, we check whether TX errors have damaged\n                  too much the SIZ parameters *\/\n                if (!(l_image->x1 * l_image->y1)) {\n                        opj_event_msg(p_manager, EVT_ERROR,\n                                \"JPWL: bad image size (%d x %d)\\n\",\n                                l_image->x1, l_image->y1);\n                        if (!JPWL_ASSUME || JPWL_ASSUME) {\n                                opj_event_msg(p_manager, EVT_ERROR, \"JPWL: giving up\\n\");\n                                return OPJ_FALSE;\n                        }\n                }\n\n        \/* FIXME check previously in the function so why keep this piece of code ? Need by the norm ?\n                if (l_image->numcomps != ((len - 38) \/ 3)) {\n                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,\n                                \"JPWL: Csiz is %d => space in SIZ only for %d comps.!!!\\n\",\n                                l_image->numcomps, ((len - 38) \/ 3));\n                        if (!JPWL_ASSUME) {\n                                opj_event_msg(p_manager, EVT_ERROR, \"JPWL: giving up\\n\");\n                                return OPJ_FALSE;\n                        }\n        *\/              \/* we try to correct *\/\n        \/*              opj_event_msg(p_manager, EVT_WARNING, \"- trying to adjust this\\n\");\n                        if (l_image->numcomps < ((len - 38) \/ 3)) {\n                                len = 38 + 3 * l_image->numcomps;\n                                opj_event_msg(p_manager, EVT_WARNING, \"- setting Lsiz to %d => HYPOTHESIS!!!\\n\",\n                                        len);\n                        } else {\n                                l_image->numcomps = ((len - 38) \/ 3);\n                                opj_event_msg(p_manager, EVT_WARNING, \"- setting Csiz to %d => HYPOTHESIS!!!\\n\",\n                                        l_image->numcomps);\n                        }\n                }\n        *\/\n\n                \/* update components number in the jpwl_exp_comps filed *\/\n                l_cp->exp_comps = l_image->numcomps;\n        }\n#endif \/* USE_JPWL *\/\n\n        \/* Allocate the resulting image components *\/\n        l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps, sizeof(opj_image_comp_t));\n        if (l_image->comps == 00){\n                l_image->numcomps = 0;\n                opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to take in charge SIZ marker\\n\");\n                return OPJ_FALSE;\n        }\n\n        l_img_comp = l_image->comps;\n\n        \/* Read the component information *\/\n        for (i = 0; i < l_image->numcomps; ++i){\n                OPJ_UINT32 tmp;\n                opj_read_bytes(p_header_data,&tmp,1);   \/* Ssiz_i *\/\n                ++p_header_data;\n                l_img_comp->prec = (tmp & 0x7f) + 1;\n                l_img_comp->sgnd = tmp >> 7;\n                opj_read_bytes(p_header_data,&tmp,1);   \/* XRsiz_i *\/\n                ++p_header_data;\n                l_img_comp->dx = (OPJ_UINT32)tmp; \/* should be between 1 and 255 *\/\n                opj_read_bytes(p_header_data,&tmp,1);   \/* YRsiz_i *\/\n                ++p_header_data;\n                l_img_comp->dy = (OPJ_UINT32)tmp; \/* should be between 1 and 255 *\/\n                if( l_img_comp->dx < 1 || l_img_comp->dx > 255 ||\n                    l_img_comp->dy < 1 || l_img_comp->dy > 255 ) {\n                    opj_event_msg(p_manager, EVT_ERROR,\n                                  \"Invalid values for comp = %d : dx=%u dy=%u\\n (should be between 1 and 255 according the JPEG2000 norm)\",\n                                  i, l_img_comp->dx, l_img_comp->dy);\n                    return OPJ_FALSE;\n                }\n\n#ifdef USE_JPWL\n                if (l_cp->correct) {\n                \/* if JPWL is on, we check whether TX errors have damaged\n                        too much the SIZ parameters, again *\/\n                        if (!(l_image->comps[i].dx * l_image->comps[i].dy)) {\n                                opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,\n                                        \"JPWL: bad XRsiz_%d\/YRsiz_%d (%d x %d)\\n\",\n                                        i, i, l_image->comps[i].dx, l_image->comps[i].dy);\n                                if (!JPWL_ASSUME) {\n                                        opj_event_msg(p_manager, EVT_ERROR, \"JPWL: giving up\\n\");\n                                        return OPJ_FALSE;\n                                }\n                                \/* we try to correct *\/\n                                opj_event_msg(p_manager, EVT_WARNING, \"- trying to adjust them\\n\");\n                                if (!l_image->comps[i].dx) {\n                                        l_image->comps[i].dx = 1;\n                                        opj_event_msg(p_manager, EVT_WARNING, \"- setting XRsiz_%d to %d => HYPOTHESIS!!!\\n\",\n                                                i, l_image->comps[i].dx);\n                                }\n                                if (!l_image->comps[i].dy) {\n                                        l_image->comps[i].dy = 1;\n                                        opj_event_msg(p_manager, EVT_WARNING, \"- setting YRsiz_%d to %d => HYPOTHESIS!!!\\n\",\n                                                i, l_image->comps[i].dy);\n                                }\n                        }\n                }\n#endif \/* USE_JPWL *\/\n                l_img_comp->resno_decoded = 0;                                                          \/* number of resolution decoded *\/\n                l_img_comp->factor = l_cp->m_specific_param.m_dec.m_reduce; \/* reducing factor per component *\/\n                ++l_img_comp;\n        }\n\n        \/* Compute the number of tiles *\/\n        l_cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->x1 - l_cp->tx0), (OPJ_INT32)l_cp->tdx);\n        l_cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->y1 - l_cp->ty0), (OPJ_INT32)l_cp->tdy);\n\n        \/* Check that the number of tiles is valid *\/\n        if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 \/ l_cp->th) {\n            opj_event_msg(  p_manager, EVT_ERROR, \n                            \"Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\\n\",\n                            l_cp->tw, l_cp->th);\n            return OPJ_FALSE;\n        }\n        l_nb_tiles = l_cp->tw * l_cp->th;\n\n        \/* Define the tiles which will be decoded *\/\n        if (p_j2k->m_specific_param.m_decoder.m_discard_tiles) {\n                p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) \/ l_cp->tdx;\n                p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) \/ l_cp->tdy;\n                p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), (OPJ_INT32)l_cp->tdx);\n                p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), (OPJ_INT32)l_cp->tdy);\n        }\n        else {\n                p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;\n                p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;\n                p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;\n                p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;\n        }\n\n#ifdef USE_JPWL\n        if (l_cp->correct) {\n                \/* if JPWL is on, we check whether TX errors have damaged\n                  too much the SIZ parameters *\/\n                if ((l_cp->tw < 1) || (l_cp->th < 1) || (l_cp->tw > l_cp->max_tiles) || (l_cp->th > l_cp->max_tiles)) {\n                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,\n                                \"JPWL: bad number of tiles (%d x %d)\\n\",\n                                l_cp->tw, l_cp->th);\n                        if (!JPWL_ASSUME) {\n                                opj_event_msg(p_manager, EVT_ERROR, \"JPWL: giving up\\n\");\n                                return OPJ_FALSE;\n                        }\n                        \/* we try to correct *\/\n                        opj_event_msg(p_manager, EVT_WARNING, \"- trying to adjust them\\n\");\n                        if (l_cp->tw < 1) {\n                                l_cp->tw= 1;\n                                opj_event_msg(p_manager, EVT_WARNING, \"- setting %d tiles in x => HYPOTHESIS!!!\\n\",\n                                                l_cp->tw);\n                        }\n                        if (l_cp->tw > l_cp->max_tiles) {\n                                l_cp->tw= 1;\n                                opj_event_msg(p_manager, EVT_WARNING, \"- too large x, increase expectance of %d\\n\"\n                                        \"- setting %d tiles in x => HYPOTHESIS!!!\\n\",\n                                        l_cp->max_tiles, l_cp->tw);\n                        }\n                        if (l_cp->th < 1) {\n                                l_cp->th= 1;\n                                opj_event_msg(p_manager, EVT_WARNING, \"- setting %d tiles in y => HYPOTHESIS!!!\\n\",\n                                                l_cp->th);\n                        }\n                        if (l_cp->th > l_cp->max_tiles) {\n                                l_cp->th= 1;\n                                opj_event_msg(p_manager, EVT_WARNING, \"- too large y, increase expectance of %d to continue\\n\",\n                                        \"- setting %d tiles in y => HYPOTHESIS!!!\\n\",\n                                        l_cp->max_tiles, l_cp->th);\n                        }\n                }\n        }\n#endif \/* USE_JPWL *\/\n\n        \/* memory allocations *\/\n        l_cp->tcps = (opj_tcp_t*) opj_calloc(l_nb_tiles, sizeof(opj_tcp_t));\n        if (l_cp->tcps == 00) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to take in charge SIZ marker\\n\");\n                return OPJ_FALSE;\n        }\n\n#ifdef USE_JPWL\n        if (l_cp->correct) {\n                if (!l_cp->tcps) {\n                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,\n                                \"JPWL: could not alloc tcps field of cp\\n\");\n                        if (!JPWL_ASSUME || JPWL_ASSUME) {\n                                opj_event_msg(p_manager, EVT_ERROR, \"JPWL: giving up\\n\");\n                                return OPJ_FALSE;\n                        }\n                }\n        }\n#endif \/* USE_JPWL *\/\n\n        p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps =\n                        (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));\n        if(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps  == 00) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to take in charge SIZ marker\\n\");\n                return OPJ_FALSE;\n        }\n\n        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records =\n                        (opj_mct_data_t*)opj_calloc(OPJ_J2K_MCT_DEFAULT_NB_RECORDS ,sizeof(opj_mct_data_t));\n\n        if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to take in charge SIZ marker\\n\");\n                return OPJ_FALSE;\n        }\n        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records = OPJ_J2K_MCT_DEFAULT_NB_RECORDS;\n\n        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records =\n                        (opj_simple_mcc_decorrelation_data_t*)\n                        opj_calloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS, sizeof(opj_simple_mcc_decorrelation_data_t));\n\n        if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) {\n                opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to take in charge SIZ marker\\n\");\n                return OPJ_FALSE;\n        }\n        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records = OPJ_J2K_MCC_DEFAULT_NB_RECORDS;\n\n        \/* set up default dc level shift *\/\n        for (i=0;inumcomps;++i) {\n                if (! l_image->comps[i].sgnd) {\n                        p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1 << (l_image->comps[i].prec - 1);\n                }\n        }\n\n        l_current_tile_param = l_cp->tcps;\n        for     (i = 0; i < l_nb_tiles; ++i) {\n                l_current_tile_param->tccps = (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));\n                if (l_current_tile_param->tccps == 00) {\n                        opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to take in charge SIZ marker\\n\");\n                        return OPJ_FALSE;\n                }\n\n                ++l_current_tile_param;\n        }\n\n        p_j2k->m_specific_param.m_decoder.m_state =  J2K_STATE_MH; \/* FIXME J2K_DEC_STATE_MH; *\/\n        opj_image_comp_header_update(l_image,l_cp);\n\n        return OPJ_TRUE;\n}","target":0,"code_token_length":4690,"total_token_length":4926,"max_tokens_setting":6144}
+{"idx":348135,"func":"print_help (void)\n{\n#ifndef TESTING\n  \/* We split the help text this way to ease translation of individual\n     entries.  *\/\n  static const char *help[] = {\n    \"\\n\",\n    N_(\"\\\nMandatory arguments to long options are mandatory for short options too.\\n\\n\"),\n    N_(\"\\\nStartup:\\n\"),\n    N_(\"\\\n  -V,  --version                   display the version of Wget and exit\\n\"),\n    N_(\"\\\n  -h,  --help                      print this help\\n\"),\n    N_(\"\\\n  -b,  --background                go to background after startup\\n\"),\n    N_(\"\\\n  -e,  --execute=COMMAND           execute a `.wgetrc'-style command\\n\"),\n    \"\\n\",\n\n    N_(\"\\\nLogging and input file:\\n\"),\n    N_(\"\\\n  -o,  --output-file=FILE          log messages to FILE\\n\"),\n    N_(\"\\\n  -a,  --append-output=FILE        append messages to FILE\\n\"),\n#ifdef ENABLE_DEBUG\n    N_(\"\\\n  -d,  --debug                     print lots of debugging information\\n\"),\n#endif\n#ifdef USE_WATT32\n    N_(\"\\\n       --wdebug                    print Watt-32 debug output\\n\"),\n#endif\n    N_(\"\\\n  -q,  --quiet                     quiet (no output)\\n\"),\n    N_(\"\\\n  -v,  --verbose                   be verbose (this is the default)\\n\"),\n    N_(\"\\\n  -nv, --no-verbose                turn off verboseness, without being quiet\\n\"),\n    N_(\"\\\n       --report-speed=TYPE         output bandwidth as TYPE.  TYPE can be bits\\n\"),\n    N_(\"\\\n  -i,  --input-file=FILE           download URLs found in local or external FILE\\n\"),\n#ifdef HAVE_METALINK\n    N_(\"\\\n       --input-metalink=FILE       download files covered in local Metalink FILE\\n\"),\n#endif\n    N_(\"\\\n  -F,  --force-html                treat input file as HTML\\n\"),\n    N_(\"\\\n  -B,  --base=URL                  resolves HTML input-file links (-i -F)\\n\\\n                                     relative to URL\\n\"),\n    N_(\"\\\n       --config=FILE               specify config file to use\\n\"),\n    N_(\"\\\n       --no-config                 do not read any config file\\n\"),\n    N_(\"\\\n       --rejected-log=FILE         log reasons for URL rejection to FILE\\n\"),\n    \"\\n\",\n\n    N_(\"\\\nDownload:\\n\"),\n    N_(\"\\\n  -t,  --tries=NUMBER              set number of retries to NUMBER (0 unlimits)\\n\"),\n    N_(\"\\\n       --retry-connrefused         retry even if connection is refused\\n\"),\n    N_(\"\\\n       --retry-on-http-error=ERRORS    comma-separated list of HTTP errors to retry\\n\"),\n    N_(\"\\\n  -O,  --output-document=FILE      write documents to FILE\\n\"),\n    N_(\"\\\n  -nc, --no-clobber                skip downloads that would download to\\n\\\n                                     existing files (overwriting them)\\n\"),\n    N_(\"\\\n       --no-netrc                  don't try to obtain credentials from .netrc\\n\"),\n    N_(\"\\\n  -c,  --continue                  resume getting a partially-downloaded file\\n\"),\n    N_(\"\\\n       --start-pos=OFFSET          start downloading from zero-based position OFFSET\\n\"),\n    N_(\"\\\n       --progress=TYPE             select progress gauge type\\n\"),\n    N_(\"\\\n       --show-progress             display the progress bar in any verbosity mode\\n\"),\n    N_(\"\\\n  -N,  --timestamping              don't re-retrieve files unless newer than\\n\\\n                                     local\\n\"),\n    N_(\"\\\n       --no-if-modified-since      don't use conditional if-modified-since get\\n\\\n                                     requests in timestamping mode\\n\"),\n    N_(\"\\\n       --no-use-server-timestamps  don't set the local file's timestamp by\\n\\\n                                     the one on the server\\n\"),\n    N_(\"\\\n  -S,  --server-response           print server response\\n\"),\n    N_(\"\\\n       --spider                    don't download anything\\n\"),\n    N_(\"\\\n  -T,  --timeout=SECONDS           set all timeout values to SECONDS\\n\"),\n#ifdef HAVE_LIBCARES\n    N_(\"\\\n       --dns-servers=ADDRESSES     list of DNS servers to query (comma separated)\\n\"),\n    N_(\"\\\n       --bind-dns-address=ADDRESS  bind DNS resolver to ADDRESS (hostname or IP) on local host\\n\"),\n#endif\n    N_(\"\\\n       --dns-timeout=SECS          set the DNS lookup timeout to SECS\\n\"),\n    N_(\"\\\n       --connect-timeout=SECS      set the connect timeout to SECS\\n\"),\n    N_(\"\\\n       --read-timeout=SECS         set the read timeout to SECS\\n\"),\n    N_(\"\\\n  -w,  --wait=SECONDS              wait SECONDS between retrievals\\n\"),\n    N_(\"\\\n       --waitretry=SECONDS         wait 1..SECONDS between retries of a retrieval\\n\"),\n    N_(\"\\\n       --random-wait               wait from 0.5*WAIT...1.5*WAIT secs between retrievals\\n\"),\n    N_(\"\\\n       --no-proxy                  explicitly turn off proxy\\n\"),\n    N_(\"\\\n  -Q,  --quota=NUMBER              set retrieval quota to NUMBER\\n\"),\n    N_(\"\\\n       --bind-address=ADDRESS      bind to ADDRESS (hostname or IP) on local host\\n\"),\n    N_(\"\\\n       --limit-rate=RATE           limit download rate to RATE\\n\"),\n    N_(\"\\\n       --no-dns-cache              disable caching DNS lookups\\n\"),\n    N_(\"\\\n       --restrict-file-names=OS    restrict chars in file names to ones OS allows\\n\"),\n    N_(\"\\\n       --ignore-case               ignore case when matching files\/directories\\n\"),\n#ifdef ENABLE_IPV6\n    N_(\"\\\n  -4,  --inet4-only                connect only to IPv4 addresses\\n\"),\n    N_(\"\\\n  -6,  --inet6-only                connect only to IPv6 addresses\\n\"),\n    N_(\"\\\n       --prefer-family=FAMILY      connect first to addresses of specified family,\\n\\\n                                     one of IPv6, IPv4, or none\\n\"),\n#endif\n    N_(\"\\\n       --user=USER                 set both ftp and http user to USER\\n\"),\n    N_(\"\\\n       --password=PASS             set both ftp and http password to PASS\\n\"),\n    N_(\"\\\n       --ask-password              prompt for passwords\\n\"),\n    N_(\"\\\n       --use-askpass=COMMAND       specify credential handler for requesting \\n\\\n                                     username and password.  If no COMMAND is \\n\\\n                                     specified the WGET_ASKPASS or the SSH_ASKPASS \\n\\\n                                     environment variable is used.\\n\"),\n    N_(\"\\\n       --no-iri                    turn off IRI support\\n\"),\n    N_(\"\\\n       --local-encoding=ENC        use ENC as the local encoding for IRIs\\n\"),\n    N_(\"\\\n       --remote-encoding=ENC       use ENC as the default remote encoding\\n\"),\n    N_(\"\\\n       --unlink                    remove file before clobber\\n\"),\n#ifdef HAVE_METALINK\n    N_(\"\\\n       --keep-badhash              keep files with checksum mismatch (append .badhash)\\n\"),\n    N_(\"\\\n       --metalink-index=NUMBER     Metalink application\/metalink4+xml metaurl ordinal NUMBER\\n\"),\n    N_(\"\\\n       --metalink-over-http        use Metalink metadata from HTTP response headers\\n\"),\n    N_(\"\\\n       --preferred-location        preferred location for Metalink resources\\n\"),\n#endif\n#ifdef ENABLE_XATTR\n    N_(\"\\\n       --no-xattr                  turn off storage of metadata in extended file attributes\\n\"),\n#endif\n    \"\\n\",\n\n    N_(\"\\\nDirectories:\\n\"),\n    N_(\"\\\n  -nd, --no-directories            don't create directories\\n\"),\n    N_(\"\\\n  -x,  --force-directories         force creation of directories\\n\"),\n    N_(\"\\\n  -nH, --no-host-directories       don't create host directories\\n\"),\n    N_(\"\\\n       --protocol-directories      use protocol name in directories\\n\"),\n    N_(\"\\\n  -P,  --directory-prefix=PREFIX   save files to PREFIX\/..\\n\"),\n    N_(\"\\\n       --cut-dirs=NUMBER           ignore NUMBER remote directory components\\n\"),\n    \"\\n\",\n\n    N_(\"\\\nHTTP options:\\n\"),\n    N_(\"\\\n       --http-user=USER            set http user to USER\\n\"),\n    N_(\"\\\n       --http-password=PASS        set http password to PASS\\n\"),\n    N_(\"\\\n       --no-cache                  disallow server-cached data\\n\"),\n    N_ (\"\\\n       --default-page=NAME         change the default page name (normally\\n\\\n                                     this is 'index.html'.)\\n\"),\n    N_(\"\\\n  -E,  --adjust-extension          save HTML\/CSS documents with proper extensions\\n\"),\n    N_(\"\\\n       --ignore-length             ignore 'Content-Length' header field\\n\"),\n    N_(\"\\\n       --header=STRING             insert STRING among the headers\\n\"),\n#ifdef HAVE_LIBZ\n    N_(\"\\\n       --compression=TYPE          choose compression, one of auto, gzip and none. (default: none)\\n\"),\n#endif\n    N_(\"\\\n       --max-redirect              maximum redirections allowed per page\\n\"),\n    N_(\"\\\n       --proxy-user=USER           set USER as proxy username\\n\"),\n    N_(\"\\\n       --proxy-password=PASS       set PASS as proxy password\\n\"),\n    N_(\"\\\n       --referer=URL               include 'Referer: URL' header in HTTP request\\n\"),\n    N_(\"\\\n       --save-headers              save the HTTP headers to file\\n\"),\n    N_(\"\\\n  -U,  --user-agent=AGENT          identify as AGENT instead of Wget\/VERSION\\n\"),\n    N_(\"\\\n       --no-http-keep-alive        disable HTTP keep-alive (persistent connections)\\n\"),\n    N_(\"\\\n       --no-cookies                don't use cookies\\n\"),\n    N_(\"\\\n       --load-cookies=FILE         load cookies from FILE before session\\n\"),\n    N_(\"\\\n       --save-cookies=FILE         save cookies to FILE after session\\n\"),\n    N_(\"\\\n       --keep-session-cookies      load and save session (non-permanent) cookies\\n\"),\n    N_(\"\\\n       --post-data=STRING          use the POST method; send STRING as the data\\n\"),\n    N_(\"\\\n       --post-file=FILE            use the POST method; send contents of FILE\\n\"),\n    N_(\"\\\n       --method=HTTPMethod         use method \\\"HTTPMethod\\\" in the request\\n\"),\n    N_(\"\\\n       --body-data=STRING          send STRING as data. --method MUST be set\\n\"),\n    N_(\"\\\n       --body-file=FILE            send contents of FILE. --method MUST be set\\n\"),\n    N_(\"\\\n       --content-disposition       honor the Content-Disposition header when\\n\\\n                                     choosing local file names (EXPERIMENTAL)\\n\"),\n    N_(\"\\\n       --content-on-error          output the received content on server errors\\n\"),\n    N_(\"\\\n       --auth-no-challenge         send Basic HTTP authentication information\\n\\\n                                     without first waiting for the server's\\n\\\n                                     challenge\\n\"),\n    \"\\n\",\n\n#ifdef HAVE_SSL\n    N_(\"\\\nHTTPS (SSL\/TLS) options:\\n\"),\n    N_(\"\\\n       --secure-protocol=PR        choose secure protocol, one of auto, SSLv2,\\n\\\n                                     SSLv3, TLSv1, TLSv1_1, TLSv1_2 and PFS\\n\"),\n    N_(\"\\\n       --https-only                only follow secure HTTPS links\\n\"),\n    N_(\"\\\n       --no-check-certificate      don't validate the server's certificate\\n\"),\n    N_(\"\\\n       --certificate=FILE          client certificate file\\n\"),\n    N_(\"\\\n       --certificate-type=TYPE     client certificate type, PEM or DER\\n\"),\n    N_(\"\\\n       --private-key=FILE          private key file\\n\"),\n    N_(\"\\\n       --private-key-type=TYPE     private key type, PEM or DER\\n\"),\n    N_(\"\\\n       --ca-certificate=FILE       file with the bundle of CAs\\n\"),\n    N_(\"\\\n       --ca-directory=DIR          directory where hash list of CAs is stored\\n\"),\n    N_(\"\\\n       --crl-file=FILE             file with bundle of CRLs\\n\"),\n    N_(\"\\\n       --pinnedpubkey=FILE\/HASHES  Public key (PEM\/DER) file, or any number\\n\\\n                                   of base64 encoded sha256 hashes preceded by\\n\\\n                                   \\'sha256\/\/\\' and separated by \\';\\', to verify\\n\\\n                                   peer against\\n\"),\n#if defined(HAVE_LIBSSL) || defined(HAVE_LIBSSL32)\n    N_(\"\\\n       --random-file=FILE          file with random data for seeding the SSL PRNG\\n\"),\n#endif\n#if (defined(HAVE_LIBSSL) || defined(HAVE_LIBSSL32)) && defined(HAVE_RAND_EGD)\n    N_(\"\\\n       --egd-file=FILE             file naming the EGD socket with random data\\n\"),\n#endif\n    \"\\n\",\n    N_(\"\\\n       --ciphers=STR           Set the priority string (GnuTLS) or cipher list string (OpenSSL) directly.\\n\\\n                                   Use with care. This option overrides --secure-protocol.\\n\\\n                                   The format and syntax of this string depend on the specific SSL\/TLS engine.\\n\"),\n#endif \/* HAVE_SSL *\/\n\n#ifdef HAVE_HSTS\n    N_(\"\\\nHSTS options:\\n\"),\n    N_(\"\\\n       --no-hsts                   disable HSTS\\n\"),\n    N_(\"\\\n       --hsts-file                 path of HSTS database (will override default)\\n\"),\n    \"\\n\",\n#endif\n\n    N_(\"\\\nFTP options:\\n\"),\n#ifdef __VMS\n    N_(\"\\\n       --ftp-stmlf                 use Stream_LF format for all binary FTP files\\n\"),\n#endif \/* def __VMS *\/\n    N_(\"\\\n       --ftp-user=USER             set ftp user to USER\\n\"),\n    N_(\"\\\n       --ftp-password=PASS         set ftp password to PASS\\n\"),\n    N_(\"\\\n       --no-remove-listing         don't remove '.listing' files\\n\"),\n    N_(\"\\\n       --no-glob                   turn off FTP file name globbing\\n\"),\n    N_(\"\\\n       --no-passive-ftp            disable the \\\"passive\\\" transfer mode\\n\"),\n    N_(\"\\\n       --preserve-permissions      preserve remote file permissions\\n\"),\n    N_(\"\\\n       --retr-symlinks             when recursing, get linked-to files (not dir)\\n\"),\n    \"\\n\",\n\n#ifdef HAVE_SSL\n    N_(\"\\\nFTPS options:\\n\"),\n    N_(\"\\\n       --ftps-implicit                 use implicit FTPS (default port is 990)\\n\"),\n    N_(\"\\\n       --ftps-resume-ssl               resume the SSL\/TLS session started in the control connection when\\n\"\n        \"                                         opening a data connection\\n\"),\n    N_(\"\\\n       --ftps-clear-data-connection    cipher the control channel only; all the data will be in plaintext\\n\"),\n    N_(\"\\\n       --ftps-fallback-to-ftp          fall back to FTP if FTPS is not supported in the target server\\n\"),\n#endif\n\n    N_(\"\\\nWARC options:\\n\"),\n    N_(\"\\\n       --warc-file=FILENAME        save request\/response data to a .warc.gz file\\n\"),\n    N_(\"\\\n       --warc-header=STRING        insert STRING into the warcinfo record\\n\"),\n    N_(\"\\\n       --warc-max-size=NUMBER      set maximum size of WARC files to NUMBER\\n\"),\n    N_(\"\\\n       --warc-cdx                  write CDX index files\\n\"),\n    N_(\"\\\n       --warc-dedup=FILENAME       do not store records listed in this CDX file\\n\"),\n#ifdef HAVE_LIBZ\n    N_(\"\\\n       --no-warc-compression       do not compress WARC files with GZIP\\n\"),\n#endif\n    N_(\"\\\n       --no-warc-digests           do not calculate SHA1 digests\\n\"),\n    N_(\"\\\n       --no-warc-keep-log          do not store the log file in a WARC record\\n\"),\n    N_(\"\\\n       --warc-tempdir=DIRECTORY    location for temporary files created by the\\n\\\n                                     WARC writer\\n\"),\n    \"\\n\",\n\n    N_(\"\\\nRecursive download:\\n\"),\n    N_(\"\\\n  -r,  --recursive                 specify recursive download\\n\"),\n    N_(\"\\\n  -l,  --level=NUMBER              maximum recursion depth (inf or 0 for infinite)\\n\"),\n    N_(\"\\\n       --delete-after              delete files locally after downloading them\\n\"),\n    N_(\"\\\n  -k,  --convert-links             make links in downloaded HTML or CSS point to\\n\\\n                                     local files\\n\"),\n    N_(\"\\\n       --convert-file-only         convert the file part of the URLs only (usually known as the basename)\\n\"),\n    N_(\"\\\n       --backups=N                 before writing file X, rotate up to N backup files\\n\"),\n\n#ifdef __VMS\n    N_(\"\\\n  -K,  --backup-converted          before converting file X, back up as X_orig\\n\"),\n#else \/* def __VMS *\/\n    N_(\"\\\n  -K,  --backup-converted          before converting file X, back up as X.orig\\n\"),\n#endif \/* def __VMS [else] *\/\n    N_(\"\\\n  -m,  --mirror                    shortcut for -N -r -l inf --no-remove-listing\\n\"),\n    N_(\"\\\n  -p,  --page-requisites           get all images, etc. needed to display HTML page\\n\"),\n    N_(\"\\\n       --strict-comments           turn on strict (SGML) handling of HTML comments\\n\"),\n    \"\\n\",\n\n    N_(\"\\\nRecursive accept\/reject:\\n\"),\n    N_(\"\\\n  -A,  --accept=LIST               comma-separated list of accepted extensions\\n\"),\n    N_(\"\\\n  -R,  --reject=LIST               comma-separated list of rejected extensions\\n\"),\n    N_(\"\\\n       --accept-regex=REGEX        regex matching accepted URLs\\n\"),\n    N_(\"\\\n       --reject-regex=REGEX        regex matching rejected URLs\\n\"),\n#if defined HAVE_LIBPCRE || defined HAVE_LIBPCRE2\n    N_(\"\\\n       --regex-type=TYPE           regex type (posix|pcre)\\n\"),\n#else\n    N_(\"\\\n       --regex-type=TYPE           regex type (posix)\\n\"),\n#endif\n    N_(\"\\\n  -D,  --domains=LIST              comma-separated list of accepted domains\\n\"),\n    N_(\"\\\n       --exclude-domains=LIST      comma-separated list of rejected domains\\n\"),\n    N_(\"\\\n       --follow-ftp                follow FTP links from HTML documents\\n\"),\n    N_(\"\\\n       --follow-tags=LIST          comma-separated list of followed HTML tags\\n\"),\n    N_(\"\\\n       --ignore-tags=LIST          comma-separated list of ignored HTML tags\\n\"),\n    N_(\"\\\n  -H,  --span-hosts                go to foreign hosts when recursive\\n\"),\n    N_(\"\\\n  -L,  --relative                  follow relative links only\\n\"),\n    N_(\"\\\n  -I,  --include-directories=LIST  list of allowed directories\\n\"),\n    N_(\"\\\n       --trust-server-names        use the name specified by the redirection\\n\\\n                                     URL's last component\\n\"),\n    N_(\"\\\n  -X,  --exclude-directories=LIST  list of excluded directories\\n\"),\n    N_(\"\\\n  -np, --no-parent                 don't ascend to the parent directory\\n\"),\n    \"\\n\",\n    N_(\"Email bug reports, questions, discussions to \\n\"),\n    N_(\"and\/or open issues at https:\/\/savannah.gnu.org\/bugs\/?func=additem&group=wget.\\n\")\n  };\n\n  size_t i;\n\n  if (printf (_(\"GNU Wget %s, a non-interactive network retriever.\\n\"),\n              version_string) < 0)\n    exit (WGET_EXIT_IO_FAIL);\n  if (print_usage (0) < 0)\n    exit (WGET_EXIT_IO_FAIL);\n\n  for (i = 0; i < countof (help); i++)\n    if (fputs (_(help[i]), stdout) < 0)\n      exit (WGET_EXIT_IO_FAIL);\n#endif \/* TESTING *\/\n  exit (WGET_EXIT_SUCCESS);\n}","target":1,"code_token_length":4513,"total_token_length":4749,"max_tokens_setting":6144}
+{"idx":199538,"func":"static MagickBooleanType WritePICTImage(const ImageInfo *image_info,\n  Image *image)\n{\n#define MaxCount  128\n#define PictCropRegionOp  0x01\n#define PictEndOfPictureOp  0xff\n#define PictJPEGOp  0x8200\n#define PictInfoOp  0x0C00\n#define PictInfoSize  512\n#define PictPixmapOp  0x9A\n#define PictPICTOp  0x98\n#define PictVersion  0x11\n\n  const StringInfo\n    *profile;\n\n  double\n    x_resolution,\n    y_resolution;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset;\n\n  PICTPixmap\n    pixmap;\n\n  PICTRectangle\n    bounds,\n    crop_rectangle,\n    destination_rectangle,\n    frame_rectangle,\n    size_rectangle,\n    source_rectangle;\n\n  register const IndexPacket\n    *indexes;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    i,\n    x;\n\n  size_t\n    bytes_per_line,\n    count,\n    storage_class;\n\n  ssize_t\n    y;\n\n  unsigned char\n    *buffer,\n    *packed_scanline,\n    *scanline;\n\n\n  unsigned short\n    base_address,\n    row_bytes,\n    transfer_mode;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  if ((image->columns > 65535L) || (image->rows > 65535L))\n    ThrowWriterException(ImageError,\"WidthOrHeightExceedsLimit\");\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)\n    (void) TransformImageColorspace(image,sRGBColorspace);\n  \/*\n    Initialize image info.\n  *\/\n  size_rectangle.top=0;\n  size_rectangle.left=0;\n  size_rectangle.bottom=(short) image->rows;\n  size_rectangle.right=(short) image->columns;\n  frame_rectangle=size_rectangle;\n  crop_rectangle=size_rectangle;\n  source_rectangle=size_rectangle;\n  destination_rectangle=size_rectangle;\n  base_address=0xff;\n  row_bytes=(unsigned short) (image->columns | 0x8000);\n  bounds.top=0;\n  bounds.left=0;\n  bounds.bottom=(short) image->rows;\n  bounds.right=(short) image->columns;\n  pixmap.version=0;\n  pixmap.pack_type=0;\n  pixmap.pack_size=0;\n  pixmap.pixel_type=0;\n  pixmap.bits_per_pixel=8;\n  pixmap.component_count=1;\n  pixmap.component_size=8;\n  pixmap.plane_bytes=0;\n  pixmap.table=0;\n  pixmap.reserved=0;\n  transfer_mode=0;\n  x_resolution=image->x_resolution != 0.0 ? image->x_resolution :\n    DefaultResolution;\n  y_resolution=image->y_resolution != 0.0 ? image->y_resolution :\n    DefaultResolution;\n  storage_class=image->storage_class;\n  if (image_info->compression == JPEGCompression)\n    storage_class=DirectClass;\n  if (storage_class == DirectClass)\n    {\n      pixmap.component_count=image->matte != MagickFalse ? 4 : 3;\n      pixmap.pixel_type=16;\n      pixmap.bits_per_pixel=32;\n      pixmap.pack_type=0x04;\n      transfer_mode=0x40;\n      row_bytes=(unsigned short) ((4*image->columns) | 0x8000);\n    }\n  \/*\n    Allocate memory.\n  *\/\n  bytes_per_line=image->columns;\n  if (storage_class == DirectClass)\n    bytes_per_line*=image->matte != MagickFalse ? 4 : 3;\n  buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer));\n  packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t)\n   (row_bytes+MaxCount),sizeof(*packed_scanline));\n  scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline));\n  if ((buffer == (unsigned char *) NULL) ||\n      (packed_scanline == (unsigned char *) NULL) ||\n      (scanline == (unsigned char *) NULL))\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  (void) ResetMagickMemory(scanline,0,row_bytes);\n  (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount));\n  \/*\n    Write header, header size, size bounding box, version, and reserved.\n  *\/\n  (void) ResetMagickMemory(buffer,0,PictInfoSize);\n  (void) WriteBlob(image,PictInfoSize,buffer);\n  (void) WriteBlobMSBShort(image,0);\n  (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top);\n  (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left);\n  (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom);\n  (void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right);\n  (void) WriteBlobMSBShort(image,PictVersion);\n  (void) WriteBlobMSBShort(image,0x02ff);  \/* version #2 *\/\n  (void) WriteBlobMSBShort(image,PictInfoOp);\n  (void) WriteBlobMSBLong(image,0xFFFE0000UL);\n  \/*\n    Write full size of the file, resolution, frame bounding box, and reserved.\n  *\/\n  (void) WriteBlobMSBShort(image,(unsigned short) x_resolution);\n  (void) WriteBlobMSBShort(image,0x0000);\n  (void) WriteBlobMSBShort(image,(unsigned short) y_resolution);\n  (void) WriteBlobMSBShort(image,0x0000);\n  (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top);\n  (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left);\n  (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom);\n  (void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right);\n  (void) WriteBlobMSBLong(image,0x00000000L);\n  profile=GetImageProfile(image,\"iptc\");\n  if (profile != (StringInfo *) NULL)\n    {\n      (void) WriteBlobMSBShort(image,0xa1);\n      (void) WriteBlobMSBShort(image,0x1f2);\n      (void) WriteBlobMSBShort(image,(unsigned short)\n        (GetStringInfoLength(profile)+4));\n      (void) WriteBlobString(image,\"8BIM\");\n      (void) WriteBlob(image,GetStringInfoLength(profile),\n        GetStringInfoDatum(profile));\n    }\n  profile=GetImageProfile(image,\"icc\");\n  if (profile != (StringInfo *) NULL)\n    {\n      (void) WriteBlobMSBShort(image,0xa1);\n      (void) WriteBlobMSBShort(image,0xe0);\n      (void) WriteBlobMSBShort(image,(unsigned short)\n        (GetStringInfoLength(profile)+4));\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlob(image,GetStringInfoLength(profile),\n        GetStringInfoDatum(profile));\n      (void) WriteBlobMSBShort(image,0xa1);\n      (void) WriteBlobMSBShort(image,0xe0);\n      (void) WriteBlobMSBShort(image,4);\n      (void) WriteBlobMSBLong(image,0x00000002UL);\n    }\n  \/*\n    Write crop region opcode and crop bounding box.\n  *\/\n  (void) WriteBlobMSBShort(image,PictCropRegionOp);\n  (void) WriteBlobMSBShort(image,0xa);\n  (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top);\n  (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left);\n  (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom);\n  (void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right);\n  if (image_info->compression == JPEGCompression)\n    {\n      Image\n        *jpeg_image;\n\n      ImageInfo\n        *jpeg_info;\n\n      size_t\n        length;\n\n      unsigned char\n        *blob;\n\n      jpeg_image=CloneImage(image,0,0,MagickTrue,&image->exception);\n      if (jpeg_image == (Image *) NULL)\n        {\n          (void) CloseBlob(image);\n          return(MagickFalse);\n        }\n      jpeg_info=CloneImageInfo(image_info);\n      (void) CopyMagickString(jpeg_info->magick,\"JPEG\",MaxTextExtent);\n      length=0;\n      blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length,\n        &image->exception);\n      jpeg_info=DestroyImageInfo(jpeg_info);\n      if (blob == (unsigned char *) NULL)\n        return(MagickFalse);\n      jpeg_image=DestroyImage(jpeg_image);\n      (void) WriteBlobMSBShort(image,PictJPEGOp);\n      (void) WriteBlobMSBLong(image,(unsigned int) length+154);\n      (void) WriteBlobMSBShort(image,0x0000);\n      (void) WriteBlobMSBLong(image,0x00010000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00010000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x40000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00400000UL);\n      (void) WriteBlobMSBShort(image,0x0000);\n      (void) WriteBlobMSBShort(image,(unsigned short) image->rows);\n      (void) WriteBlobMSBShort(image,(unsigned short) image->columns);\n      (void) WriteBlobMSBShort(image,0x0000);\n      (void) WriteBlobMSBShort(image,768);\n      (void) WriteBlobMSBShort(image,0x0000);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00566A70UL);\n      (void) WriteBlobMSBLong(image,0x65670000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000001UL);\n      (void) WriteBlobMSBLong(image,0x00016170UL);\n      (void) WriteBlobMSBLong(image,0x706C0000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBShort(image,768);\n      (void) WriteBlobMSBShort(image,(unsigned short) image->columns);\n      (void) WriteBlobMSBShort(image,(unsigned short) image->rows);\n      (void) WriteBlobMSBShort(image,(unsigned short) x_resolution);\n      (void) WriteBlobMSBShort(image,0x0000);\n      (void) WriteBlobMSBShort(image,(unsigned short) y_resolution);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x87AC0001UL);\n      (void) WriteBlobMSBLong(image,0x0B466F74UL);\n      (void) WriteBlobMSBLong(image,0x6F202D20UL);\n      (void) WriteBlobMSBLong(image,0x4A504547UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x00000000UL);\n      (void) WriteBlobMSBLong(image,0x0018FFFFUL);\n      (void) WriteBlob(image,length,blob);\n      if ((length & 0x01) != 0)\n        (void) WriteBlobByte(image,'\\0');\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n    }\n  \/*\n    Write picture opcode, row bytes, and picture bounding box, and version.\n  *\/\n  if (storage_class == PseudoClass)\n    (void) WriteBlobMSBShort(image,PictPICTOp);\n  else\n    {\n      (void) WriteBlobMSBShort(image,PictPixmapOp);\n      (void) WriteBlobMSBLong(image,(size_t) base_address);\n    }\n  (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000));\n  (void) WriteBlobMSBShort(image,(unsigned short) bounds.top);\n  (void) WriteBlobMSBShort(image,(unsigned short) bounds.left);\n  (void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom);\n  (void) WriteBlobMSBShort(image,(unsigned short) bounds.right);\n  \/*\n    Write pack type, pack size, resolution, pixel type, and pixel size.\n  *\/\n  (void) WriteBlobMSBShort(image,(unsigned short) pixmap.version);\n  (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type);\n  (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size);\n  (void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5));\n  (void) WriteBlobMSBShort(image,0x0000);\n  (void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5));\n  (void) WriteBlobMSBShort(image,0x0000);\n  (void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type);\n  (void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel);\n  \/*\n    Write component count, size, plane bytes, table size, and reserved.\n  *\/\n  (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count);\n  (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size);\n  (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes);\n  (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table);\n  (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved);\n  if (storage_class == PseudoClass)\n    {\n      \/*\n        Write image colormap.\n      *\/\n      (void) WriteBlobMSBLong(image,0x00000000L);  \/* color seed *\/\n      (void) WriteBlobMSBShort(image,0L);  \/* color flags *\/\n      (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1));\n      for (i=0; i < (ssize_t) image->colors; i++)\n      {\n        (void) WriteBlobMSBShort(image,(unsigned short) i);\n        (void) WriteBlobMSBShort(image,ScaleQuantumToShort(\n          image->colormap[i].red));\n        (void) WriteBlobMSBShort(image,ScaleQuantumToShort(\n          image->colormap[i].green));\n        (void) WriteBlobMSBShort(image,ScaleQuantumToShort(\n          image->colormap[i].blue));\n      }\n    }\n  \/*\n    Write source and destination rectangle.\n  *\/\n  (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top);\n  (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left);\n  (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom);\n  (void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right);\n  (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top);\n  (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left);\n  (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom);\n  (void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right);\n  (void) WriteBlobMSBShort(image,(unsigned short) transfer_mode);\n  \/*\n    Write picture data.\n  *\/\n  count=0;\n  if (storage_class == PseudoClass)\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n      if (p == (const PixelPacket *) NULL)\n        break;\n      indexes=GetVirtualIndexQueue(image);\n      for (x=0; x < (ssize_t) image->columns; x++)\n        scanline[x]=(unsigned char) GetPixelIndex(indexes+x);\n      count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),\n        packed_scanline);\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n  else\n    if (image_info->compression == JPEGCompression)\n      {\n        (void) ResetMagickMemory(scanline,0,row_bytes);\n        for (y=0; y < (ssize_t) image->rows; y++)\n          count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),\n            packed_scanline);\n      }\n    else\n      {\n        register unsigned char\n          *blue,\n          *green,\n          *opacity,\n          *red;\n\n        red=scanline;\n        green=scanline+image->columns;\n        blue=scanline+2*image->columns;\n        opacity=scanline+3*image->columns;\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          red=scanline;\n          green=scanline+image->columns;\n          blue=scanline+2*image->columns;\n          if (image->matte != MagickFalse)\n            {\n              opacity=scanline;\n              red=scanline+image->columns;\n              green=scanline+2*image->columns;\n              blue=scanline+3*image->columns;\n            }\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            *red++=ScaleQuantumToChar(GetPixelRed(p));\n            *green++=ScaleQuantumToChar(GetPixelGreen(p));\n            *blue++=ScaleQuantumToChar(GetPixelBlue(p));\n            if (image->matte != MagickFalse)\n              *opacity++=ScaleQuantumToChar((Quantum)\n                (GetPixelAlpha(p)));\n            p++;\n          }\n          count+=EncodeImage(image,scanline,bytes_per_line & 0x7FFF,\n            packed_scanline);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n      }\n  if ((count & 0x01) != 0)\n    (void) WriteBlobByte(image,'\\0');\n  (void) WriteBlobMSBShort(image,PictEndOfPictureOp);\n  offset=TellBlob(image);\n  offset=SeekBlob(image,512,SEEK_SET);\n  (void) WriteBlobMSBShort(image,(unsigned short) offset);\n  scanline=(unsigned char *) RelinquishMagickMemory(scanline);\n  packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline);\n  buffer=(unsigned char *) RelinquishMagickMemory(buffer);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}\n","target":0,"code_token_length":4771,"total_token_length":5007,"max_tokens_setting":6144}
+{"idx":7640,"func":"static Image *ReadVIFFImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n#define VFF_CM_genericRGB  15\n#define VFF_CM_ntscRGB  1\n#define VFF_CM_NONE  0\n#define VFF_DEP_DECORDER  0x4\n#define VFF_DEP_NSORDER  0x8\n#define VFF_DES_RAW  0\n#define VFF_LOC_IMPLICIT  1\n#define VFF_MAPTYP_NONE  0\n#define VFF_MAPTYP_1_BYTE  1\n#define VFF_MAPTYP_2_BYTE  2\n#define VFF_MAPTYP_4_BYTE  4\n#define VFF_MAPTYP_FLOAT  5\n#define VFF_MAPTYP_DOUBLE  7\n#define VFF_MS_NONE  0\n#define VFF_MS_ONEPERBAND  1\n#define VFF_MS_SHARED  3\n#define VFF_TYP_BIT  0\n#define VFF_TYP_1_BYTE  1\n#define VFF_TYP_2_BYTE  2\n#define VFF_TYP_4_BYTE  4\n#define VFF_TYP_FLOAT  5\n#define VFF_TYP_DOUBLE  9\n\n  typedef struct _ViffInfo\n  {\n    unsigned char\n      identifier,\n      file_type,\n      release,\n      version,\n      machine_dependency,\n      reserve[3];\n\n    char\n      comment[512];\n\n    unsigned int\n      rows,\n      columns,\n      subrows;\n\n    int\n      x_offset,\n      y_offset;\n\n    float\n      x_bits_per_pixel,\n      y_bits_per_pixel;\n\n    unsigned int\n      location_type,\n      location_dimension,\n      number_of_images,\n      number_data_bands,\n      data_storage_type,\n      data_encode_scheme,\n      map_scheme,\n      map_storage_type,\n      map_rows,\n      map_columns,\n      map_subrows,\n      map_enable,\n      maps_per_cycle,\n      color_space_model;\n  } ViffInfo;\n\n  double\n    min_value,\n    scale_factor,\n    value;\n\n  Image\n    *image;\n\n  int\n    bit;\n\n  MagickBooleanType\n    status;\n\n  MagickSizeType\n    number_pixels;\n\n  register ssize_t\n    x;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    i;\n\n  register unsigned char\n    *p;\n\n  size_t\n    bytes_per_pixel,\n    max_packets,\n    quantum;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  unsigned long\n    lsb_first;\n\n  ViffInfo\n    viff_info;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read VIFF header (1024 bytes).\n  *\/\n  count=ReadBlob(image,1,&viff_info.identifier);\n  do\n  {\n    \/*\n      Verify VIFF identifier.\n    *\/\n    if ((count != 1) || ((unsigned char) viff_info.identifier != 0xab))\n      ThrowReaderException(CorruptImageError,\"NotAVIFFImage\");\n    \/*\n      Initialize VIFF image.\n    *\/\n    (void) ReadBlob(image,sizeof(viff_info.file_type),&viff_info.file_type);\n    (void) ReadBlob(image,sizeof(viff_info.release),&viff_info.release);\n    (void) ReadBlob(image,sizeof(viff_info.version),&viff_info.version);\n    (void) ReadBlob(image,sizeof(viff_info.machine_dependency),\n      &viff_info.machine_dependency);\n    (void) ReadBlob(image,sizeof(viff_info.reserve),viff_info.reserve);\n    count=ReadBlob(image,512,(unsigned char *) viff_info.comment);\n    viff_info.comment[511]='\\0';\n    if (strlen(viff_info.comment) > 4)\n      (void) SetImageProperty(image,\"comment\",viff_info.comment,exception);\n    if ((viff_info.machine_dependency == VFF_DEP_DECORDER) ||\n        (viff_info.machine_dependency == VFF_DEP_NSORDER))\n      image->endian=LSBEndian;\n    else\n      image->endian=MSBEndian;\n    viff_info.rows=ReadBlobLong(image);\n    viff_info.columns=ReadBlobLong(image);\n    viff_info.subrows=ReadBlobLong(image);\n    viff_info.x_offset=ReadBlobSignedLong(image);\n    viff_info.y_offset=ReadBlobSignedLong(image);\n    viff_info.x_bits_per_pixel=(float) ReadBlobLong(image);\n    viff_info.y_bits_per_pixel=(float) ReadBlobLong(image);\n    viff_info.location_type=ReadBlobLong(image);\n    viff_info.location_dimension=ReadBlobLong(image);\n    viff_info.number_of_images=ReadBlobLong(image);\n    viff_info.number_data_bands=ReadBlobLong(image);\n    viff_info.data_storage_type=ReadBlobLong(image);\n    viff_info.data_encode_scheme=ReadBlobLong(image);\n    viff_info.map_scheme=ReadBlobLong(image);\n    viff_info.map_storage_type=ReadBlobLong(image);\n    viff_info.map_rows=ReadBlobLong(image);\n    viff_info.map_columns=ReadBlobLong(image);\n    viff_info.map_subrows=ReadBlobLong(image);\n    viff_info.map_enable=ReadBlobLong(image);\n    viff_info.maps_per_cycle=ReadBlobLong(image);\n    viff_info.color_space_model=ReadBlobLong(image);\n    for (i=0; i < 420; i++)\n      (void) ReadBlobByte(image);\n    if (EOFBlob(image) != MagickFalse)\n      ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n    image->columns=viff_info.rows;\n    image->rows=viff_info.columns;\n    image->depth=viff_info.x_bits_per_pixel <= 8 ? 8UL :\n      MAGICKCORE_QUANTUM_DEPTH;\n    \/*\n      Verify that we can read this VIFF image.\n    *\/\n    number_pixels=(MagickSizeType) viff_info.columns*viff_info.rows;\n    if (number_pixels != (size_t) number_pixels)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (number_pixels == 0)\n      ThrowReaderException(CoderError,\"ImageColumnOrRowSizeIsNotSupported\");\n    if ((viff_info.number_data_bands < 1) || (viff_info.number_data_bands > 4))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((viff_info.data_storage_type != VFF_TYP_BIT) &&\n        (viff_info.data_storage_type != VFF_TYP_1_BYTE) &&\n        (viff_info.data_storage_type != VFF_TYP_2_BYTE) &&\n        (viff_info.data_storage_type != VFF_TYP_4_BYTE) &&\n        (viff_info.data_storage_type != VFF_TYP_FLOAT) &&\n        (viff_info.data_storage_type != VFF_TYP_DOUBLE))\n      ThrowReaderException(CoderError,\"DataStorageTypeIsNotSupported\");\n    if (viff_info.data_encode_scheme != VFF_DES_RAW)\n      ThrowReaderException(CoderError,\"DataEncodingSchemeIsNotSupported\");\n    if ((viff_info.map_storage_type != VFF_MAPTYP_NONE) &&\n        (viff_info.map_storage_type != VFF_MAPTYP_1_BYTE) &&\n        (viff_info.map_storage_type != VFF_MAPTYP_2_BYTE) &&\n        (viff_info.map_storage_type != VFF_MAPTYP_4_BYTE) &&\n        (viff_info.map_storage_type != VFF_MAPTYP_FLOAT) &&\n        (viff_info.map_storage_type != VFF_MAPTYP_DOUBLE))\n      ThrowReaderException(CoderError,\"MapStorageTypeIsNotSupported\");\n    if ((viff_info.color_space_model != VFF_CM_NONE) &&\n        (viff_info.color_space_model != VFF_CM_ntscRGB) &&\n        (viff_info.color_space_model != VFF_CM_genericRGB))\n      ThrowReaderException(CoderError,\"ColorspaceModelIsNotSupported\");\n    if (viff_info.location_type != VFF_LOC_IMPLICIT)\n      ThrowReaderException(CoderError,\"LocationTypeIsNotSupported\");\n    if (viff_info.number_of_images != 1)\n      ThrowReaderException(CoderError,\"NumberOfImagesIsNotSupported\");\n    if (viff_info.map_rows == 0)\n      viff_info.map_scheme=VFF_MS_NONE;\n    switch ((int) viff_info.map_scheme)\n    {\n      case VFF_MS_NONE:\n      {\n        if (viff_info.number_data_bands < 3)\n          {\n            \/*\n              Create linear color ramp.\n            *\/\n            if (viff_info.data_storage_type == VFF_TYP_BIT)\n              image->colors=2;\n            else\n              if (viff_info.data_storage_type == VFF_MAPTYP_1_BYTE)\n                image->colors=256UL;\n              else\n                image->colors=image->depth <= 8 ? 256UL : 65536UL;\n            status=AcquireImageColormap(image,image->colors,exception);\n            if (status == MagickFalse)\n              ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n        break;\n      }\n      case VFF_MS_ONEPERBAND:\n      case VFF_MS_SHARED:\n      {\n        unsigned char\n          *viff_colormap;\n\n        \/*\n          Allocate VIFF colormap.\n        *\/\n        switch ((int) viff_info.map_storage_type)\n        {\n          case VFF_MAPTYP_1_BYTE: bytes_per_pixel=1; break;\n          case VFF_MAPTYP_2_BYTE: bytes_per_pixel=2; break;\n          case VFF_MAPTYP_4_BYTE: bytes_per_pixel=4; break;\n          case VFF_MAPTYP_FLOAT: bytes_per_pixel=4; break;\n          case VFF_MAPTYP_DOUBLE: bytes_per_pixel=8; break;\n          default: bytes_per_pixel=1; break;\n        }\n        image->colors=viff_info.map_columns;\n        if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        if (viff_info.map_rows >\n            (viff_info.map_rows*bytes_per_pixel*sizeof(*viff_colormap)))\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n        viff_colormap=(unsigned char *) AcquireQuantumMemory(image->colors,\n          viff_info.map_rows*bytes_per_pixel*sizeof(*viff_colormap));\n        if (viff_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        \/*\n          Read VIFF raster colormap.\n        *\/\n        count=ReadBlob(image,bytes_per_pixel*image->colors*viff_info.map_rows,\n          viff_colormap);\n        lsb_first=1;\n        if (*(char *) &lsb_first &&\n            ((viff_info.machine_dependency != VFF_DEP_DECORDER) &&\n             (viff_info.machine_dependency != VFF_DEP_NSORDER)))\n          switch ((int) viff_info.map_storage_type)\n          {\n            case VFF_MAPTYP_2_BYTE:\n            {\n              MSBOrderShort(viff_colormap,(bytes_per_pixel*image->colors*\n                viff_info.map_rows));\n              break;\n            }\n            case VFF_MAPTYP_4_BYTE:\n            case VFF_MAPTYP_FLOAT:\n            {\n              MSBOrderLong(viff_colormap,(bytes_per_pixel*image->colors*\n                viff_info.map_rows));\n              break;\n            }\n            default: break;\n          }\n        for (i=0; i < (ssize_t) (viff_info.map_rows*image->colors); i++)\n        {\n          switch ((int) viff_info.map_storage_type)\n          {\n            case VFF_MAPTYP_2_BYTE: value=1.0*((short *) viff_colormap)[i]; break;\n            case VFF_MAPTYP_4_BYTE: value=1.0*((int *) viff_colormap)[i]; break;\n            case VFF_MAPTYP_FLOAT: value=((float *) viff_colormap)[i]; break;\n            case VFF_MAPTYP_DOUBLE: value=((double *) viff_colormap)[i]; break;\n            default: value=1.0*viff_colormap[i]; break;\n          }\n          if (i < (ssize_t) image->colors)\n            {\n              image->colormap[i].red=ScaleCharToQuantum((unsigned char) value);\n              image->colormap[i].green=\n                ScaleCharToQuantum((unsigned char) value);\n              image->colormap[i].blue=ScaleCharToQuantum((unsigned char) value);\n            }\n          else\n            if (i < (ssize_t) (2*image->colors))\n              image->colormap[i % image->colors].green=\n                ScaleCharToQuantum((unsigned char) value);\n            else\n              if (i < (ssize_t) (3*image->colors))\n                image->colormap[i % image->colors].blue=\n                  ScaleCharToQuantum((unsigned char) value);\n        }\n        viff_colormap=(unsigned char *) RelinquishMagickMemory(viff_colormap);\n        break;\n      }\n      default:\n        ThrowReaderException(CoderError,\"ColormapTypeNotSupported\");\n    }\n    \/*\n      Initialize image structure.\n    *\/\n    image->alpha_trait=viff_info.number_data_bands == 4 ? BlendPixelTrait :\n      UndefinedPixelTrait;\n    image->storage_class=(viff_info.number_data_bands < 3 ? PseudoClass :\n      DirectClass);\n    image->columns=viff_info.rows;\n    image->rows=viff_info.columns;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      return(DestroyImageList(image));\n    \/*\n      Allocate VIFF pixels.\n    *\/\n    switch ((int) viff_info.data_storage_type)\n    {\n      case VFF_TYP_2_BYTE: bytes_per_pixel=2; break;\n      case VFF_TYP_4_BYTE: bytes_per_pixel=4; break;\n      case VFF_TYP_FLOAT: bytes_per_pixel=4; break;\n      case VFF_TYP_DOUBLE: bytes_per_pixel=8; break;\n      default: bytes_per_pixel=1; break;\n    }\n    if (viff_info.data_storage_type == VFF_TYP_BIT)\n      {\n        if (CheckMemoryOverflow((image->columns+7UL) >> 3UL,image->rows) != MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        max_packets=((image->columns+7UL) >> 3UL)*image->rows;\n      }\n    else\n      {\n        if (CheckMemoryOverflow(number_pixels,viff_info.number_data_bands) != MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        max_packets=(size_t) (number_pixels*viff_info.number_data_bands);\n      }\n    pixels=(unsigned char *) AcquireQuantumMemory(MagickMax(number_pixels,\n      max_packets),bytes_per_pixel*sizeof(*pixels));\n    if (pixels == (unsigned char *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    count=ReadBlob(image,bytes_per_pixel*max_packets,pixels);\n    lsb_first=1;\n    if (*(char *) &lsb_first &&\n        ((viff_info.machine_dependency != VFF_DEP_DECORDER) &&\n         (viff_info.machine_dependency != VFF_DEP_NSORDER)))\n      switch ((int) viff_info.data_storage_type)\n      {\n        case VFF_TYP_2_BYTE:\n        {\n          MSBOrderShort(pixels,bytes_per_pixel*max_packets);\n          break;\n        }\n        case VFF_TYP_4_BYTE:\n        case VFF_TYP_FLOAT:\n        {\n          MSBOrderLong(pixels,bytes_per_pixel*max_packets);\n          break;\n        }\n        default: break;\n      }\n    min_value=0.0;\n    scale_factor=1.0;\n    if ((viff_info.data_storage_type != VFF_TYP_1_BYTE) &&\n        (viff_info.map_scheme == VFF_MS_NONE))\n      {\n        double\n          max_value;\n\n        \/*\n          Determine scale factor.\n        *\/\n        switch ((int) viff_info.data_storage_type)\n        {\n          case VFF_TYP_2_BYTE: value=1.0*((short *) pixels)[0]; break;\n          case VFF_TYP_4_BYTE: value=1.0*((int *) pixels)[0]; break;\n          case VFF_TYP_FLOAT: value=((float *) pixels)[0]; break;\n          case VFF_TYP_DOUBLE: value=((double *) pixels)[0]; break;\n          default: value=1.0*pixels[0]; break;\n        }\n        max_value=value;\n        min_value=value;\n        for (i=0; i < (ssize_t) max_packets; i++)\n        {\n          switch ((int) viff_info.data_storage_type)\n          {\n            case VFF_TYP_2_BYTE: value=1.0*((short *) pixels)[i]; break;\n            case VFF_TYP_4_BYTE: value=1.0*((int *) pixels)[i]; break;\n            case VFF_TYP_FLOAT: value=((float *) pixels)[i]; break;\n            case VFF_TYP_DOUBLE: value=((double *) pixels)[i]; break;\n            default: value=1.0*pixels[i]; break;\n          }\n          if (value > max_value)\n            max_value=value;\n          else\n            if (value < min_value)\n              min_value=value;\n        }\n        if ((min_value == 0) && (max_value == 0))\n          scale_factor=0;\n        else\n          if (min_value == max_value)\n            {\n              scale_factor=(double) QuantumRange\/min_value;\n              min_value=0;\n            }\n          else\n            scale_factor=(double) QuantumRange\/(max_value-min_value);\n      }\n    \/*\n      Convert pixels to Quantum size.\n    *\/\n    p=(unsigned char *) pixels;\n    for (i=0; i < (ssize_t) max_packets; i++)\n    {\n      switch ((int) viff_info.data_storage_type)\n      {\n        case VFF_TYP_2_BYTE: value=1.0*((short *) pixels)[i]; break;\n        case VFF_TYP_4_BYTE: value=1.0*((int *) pixels)[i]; break;\n        case VFF_TYP_FLOAT: value=((float *) pixels)[i]; break;\n        case VFF_TYP_DOUBLE: value=((double *) pixels)[i]; break;\n        default: value=1.0*pixels[i]; break;\n      }\n      if (viff_info.map_scheme == VFF_MS_NONE)\n        {\n          value=(value-min_value)*scale_factor;\n          if (value > QuantumRange)\n            value=QuantumRange;\n          else\n            if (value < 0)\n              value=0;\n        }\n      *p=(unsigned char) ((Quantum) value);\n      p++;\n    }\n    \/*\n      Convert VIFF raster image to pixel packets.\n    *\/\n    p=(unsigned char *) pixels;\n    if (viff_info.data_storage_type == VFF_TYP_BIT)\n      {\n        \/*\n          Convert bitmap scanline.\n        *\/\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          for (x=0; x < (ssize_t) (image->columns-7); x+=8)\n          {\n            for (bit=0; bit < 8; bit++)\n            {\n              quantum=(size_t) ((*p) & (0x01 << bit) ? 0 : 1);\n              SetPixelRed(image,quantum == 0 ? 0 : QuantumRange,q);\n              SetPixelGreen(image,quantum == 0 ? 0 : QuantumRange,q);\n              SetPixelBlue(image,quantum == 0 ? 0 : QuantumRange,q);\n              if (image->storage_class == PseudoClass)\n                SetPixelIndex(image,(Quantum) quantum,q);\n              q+=GetPixelChannels(image);\n            }\n            p++;\n          }\n          if ((image->columns % 8) != 0)\n            {\n              for (bit=0; bit < (int) (image->columns % 8); bit++)\n              {\n                quantum=(size_t) ((*p) & (0x01 << bit) ? 0 : 1);\n                SetPixelRed(image,quantum == 0 ? 0 : QuantumRange,q);\n                SetPixelGreen(image,quantum == 0 ? 0 : QuantumRange,q);\n                SetPixelBlue(image,quantum == 0 ? 0 : QuantumRange,q);\n                if (image->storage_class == PseudoClass)\n                  SetPixelIndex(image,(Quantum) quantum,q);\n                q+=GetPixelChannels(image);\n              }\n              p++;\n            }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n      }\n    else\n      if (image->storage_class == PseudoClass)\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelIndex(image,*p++,q);\n            q+=GetPixelChannels(image);\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n      else\n        {\n          \/*\n            Convert DirectColor scanline.\n          *\/\n          number_pixels=(MagickSizeType) image->columns*image->rows;\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              SetPixelRed(image,ScaleCharToQuantum(*p),q);\n              SetPixelGreen(image,ScaleCharToQuantum(*(p+number_pixels)),q);\n              SetPixelBlue(image,ScaleCharToQuantum(*(p+2*number_pixels)),q);\n              if (image->colors != 0)\n                {\n                  ssize_t\n                    index;\n\n                  index=(ssize_t) GetPixelRed(image,q);\n                  SetPixelRed(image,image->colormap[\n                    ConstrainColormapIndex(image,index,exception)].red,q);\n                  index=(ssize_t) GetPixelGreen(image,q);\n                  SetPixelGreen(image,image->colormap[\n                    ConstrainColormapIndex(image,index,exception)].green,q);\n                  index=(ssize_t) GetPixelBlue(image,q);\n                  SetPixelBlue(image,image->colormap[\n                    ConstrainColormapIndex(image,index,exception)].blue,q);\n                }\n              SetPixelAlpha(image,image->alpha_trait != UndefinedPixelTrait ?\n                ScaleCharToQuantum(*(p+number_pixels*3)) : OpaqueAlpha,q);\n              p++;\n              q+=GetPixelChannels(image);\n            }\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n        }\n    pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n    if (image->storage_class == PseudoClass)\n      (void) SyncImage(image,exception);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    count=ReadBlob(image,1,&viff_info.identifier);\n    if ((count != 0) && (viff_info.identifier == 0xab))\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image,exception);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            image=DestroyImageList(image);\n            return((Image *) NULL);\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((count != 0) && (viff_info.identifier == 0xab));\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":5587,"total_token_length":5823,"max_tokens_setting":6144}
+{"idx":89562,"func":"    \/\/! Estimate displacement field between two images \\newinstance.\n    CImg get_displacement(const CImg& source,\n                                  const float smoothness=0.1f, const float precision=5.f,\n                                  const unsigned int nb_scales=0, const unsigned int iteration_max=10000,\n                                  const bool is_backward=false,\n                                  const CImg& guide=CImg::const_empty()) const {\n      if (is_empty() || !source) return +*this;\n      if (!is_sameXYZC(source))\n        throw CImgArgumentException(_cimg_instance\n                                    \"displacement(): Instance and source image (%u,%u,%u,%u,%p) have \"\n                                    \"different dimensions.\",\n                                    cimg_instance,\n                                    source._width,source._height,source._depth,source._spectrum,source._data);\n      if (precision<0)\n        throw CImgArgumentException(_cimg_instance\n                                    \"displacement(): Invalid specified precision %g \"\n                                    \"(should be >=0)\",\n                                    cimg_instance,\n                                    precision);\n\n      const bool is_3d = source._depth>1;\n      const unsigned int constraint = is_3d?3:2;\n\n      if (guide &&\n          (guide._width!=_width || guide._height!=_height || guide._depth!=_depth || guide._spectrum0?nb_scales:\n        (unsigned int)cimg::round(std::log(mins\/8.)\/std::log(1.5),1,1);\n\n      const float _precision = (float)std::pow(10.,-(double)precision);\n      float sm, sM = source.max_min(sm), tm, tM = max_min(tm);\n      const float sdelta = sm==sM?1:(sM - sm), tdelta = tm==tM?1:(tM - tm);\n\n      CImg U, V;\n      floatT bound = 0;\n      for (int scale = (int)_nb_scales - 1; scale>=0; --scale) {\n        const float factor = (float)std::pow(1.5,(double)scale);\n        const unsigned int\n          _sw = (unsigned int)(_width\/factor), sw = _sw?_sw:1,\n          _sh = (unsigned int)(_height\/factor), sh = _sh?_sh:1,\n          _sd = (unsigned int)(_depth\/factor), sd = _sd?_sd:1;\n        if (sw<5 && sh<5 && (!is_3d || sd<5)) continue;  \/\/ Skip too small scales\n        const CImg\n          I1 = (source.get_resize(sw,sh,sd,-100,2)-=sm)\/=sdelta,\n          I2 = (get_resize(I1,2)-=tm)\/=tdelta;\n        if (guide._spectrum>constraint) guide.get_resize(I2._width,I2._height,I2._depth,-100,1).move_to(V);\n        if (U) (U*=1.5f).resize(I2._width,I2._height,I2._depth,-100,3);\n        else {\n          if (guide)\n            guide.get_shared_channels(0,is_3d?2:1).get_resize(I2._width,I2._height,I2._depth,-100,2).move_to(U);\n          else U.assign(I2._width,I2._height,I2._depth,is_3d?3:2,0);\n        }\n\n        float dt = 2, energy = cimg::type::max();\n        const CImgList dI = is_backward?I1.get_gradient():I2.get_gradient();\n        cimg_abort_init;\n\n        for (unsigned int iteration = 0; iteration=0) \/\/ Isotropic regularization\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(2)\n                                 cimg_openmp_if(_height*_depth>=(cimg_openmp_sizefactor)*8 &&\n                                                _width>=(cimg_openmp_sizefactor)*16)\n                                 reduction(+:_energy))\n              cimg_forYZ(U,y,z) {\n                const int\n                  _p1y = y?y - 1:0, _n1y = yx) U(x,y,z,0) = (float)x;\n                    if (U(x,y,z,1)>y) U(x,y,z,1) = (float)y;\n                    if (U(x,y,z,2)>z) U(x,y,z,2) = (float)z;\n                    bound = (float)x - _width; if (U(x,y,z,0)<=bound) U(x,y,z,0) = bound;\n                    bound = (float)y - _height; if (U(x,y,z,1)<=bound) U(x,y,z,1) = bound;\n                    bound = (float)z - _depth; if (U(x,y,z,2)<=bound) U(x,y,z,2) = bound;\n                  } else {\n                    if (U(x,y,z,0)<-x) U(x,y,z,0) = -(float)x;\n                    if (U(x,y,z,1)<-y) U(x,y,z,1) = -(float)y;\n                    if (U(x,y,z,2)<-z) U(x,y,z,2) = -(float)z;\n                    bound = (float)_width - x; if (U(x,y,z,0)>=bound) U(x,y,z,0) = bound;\n                    bound = (float)_height - y; if (U(x,y,z,1)>=bound) U(x,y,z,1) = bound;\n                    bound = (float)_depth - z; if (U(x,y,z,2)>=bound) U(x,y,z,2) = bound;\n                  }\n                  _energy+=delta_I*delta_I + smoothness*_energy_regul;\n                }\n                if (V) cimg_forXYZ(V,_x,_y,_z) if (V(_x,_y,_z,3)) { \/\/ Apply constraints\n                    U(_x,_y,_z,0) = V(_x,_y,_z,0)\/factor;\n                    U(_x,_y,_z,1) = V(_x,_y,_z,1)\/factor;\n                    U(_x,_y,_z,2) = V(_x,_y,_z,2)\/factor;\n                  }\n              } else { \/\/ Anisotropic regularization\n              const float nsmoothness = -smoothness;\n              cimg_pragma_openmp(parallel for cimg_openmp_collapse(2)\n                                 cimg_openmp_if(_height*_depth>=(cimg_openmp_sizefactor)*8 &&\n                                                _width>=(cimg_openmp_sizefactor)*16)\n                                 reduction(+:_energy))\n              cimg_forYZ(U,y,z) {\n                const int\n                  _p1y = y?y - 1:0, _n1y = yx) U(x,y,z,0) = (float)x;\n                    if (U(x,y,z,1)>y) U(x,y,z,1) = (float)y;\n                    if (U(x,y,z,2)>z) U(x,y,z,2) = (float)z;\n                    bound = (float)x - _width; if (U(x,y,z,0)<=bound) U(x,y,z,0) = bound;\n                    bound = (float)y - _height; if (U(x,y,z,1)<=bound) U(x,y,z,1) = bound;\n                    bound = (float)z - _depth; if (U(x,y,z,2)<=bound) U(x,y,z,2) = bound;\n                  } else {\n                    if (U(x,y,z,0)<-x) U(x,y,z,0) = -(float)x;\n                    if (U(x,y,z,1)<-y) U(x,y,z,1) = -(float)y;\n                    if (U(x,y,z,2)<-z) U(x,y,z,2) = -(float)z;\n                    bound = (float)_width - x; if (U(x,y,z,0)>=bound) U(x,y,z,0) = bound;\n                    bound = (float)_height - y; if (U(x,y,z,1)>=bound) U(x,y,z,1) = bound;\n                    bound = (float)_depth - z; if (U(x,y,z,2)>=bound) U(x,y,z,2) = bound;\n                  }\n                  _energy+=delta_I*delta_I + nsmoothness*_energy_regul;\n                }\n                if (V) cimg_forXYZ(V,_x,_y,_z) if (V(_x,_y,_z,3)) { \/\/ Apply constraints\n                    U(_x,_y,_z,0) = V(_x,_y,_z,0)\/factor;\n                    U(_x,_y,_z,1) = V(_x,_y,_z,1)\/factor;\n                    U(_x,_y,_z,2) = V(_x,_y,_z,2)\/factor;\n                  }\n              }\n            }\n          } else { \/\/ 2D version\n            if (smoothness>=0) \/\/ Isotropic regularization\n              cimg_pragma_openmp(parallel for cimg_openmp_if(_height>=(cimg_openmp_sizefactor)*8 &&\n                                                             _width>=(cimg_openmp_sizefactor)*16) reduction(+:_energy))\n              cimg_forY(U,y) {\n                const int _p1y = y?y - 1:0, _n1y = yx) U(x,y,0) = (float)x;\n                    if (U(x,y,1)>y) U(x,y,1) = (float)y;\n                    bound = (float)x - _width; if (U(x,y,0)<=bound) U(x,y,0) = bound;\n                    bound = (float)y - _height; if (U(x,y,1)<=bound) U(x,y,1) = bound;\n                  } else {\n                    if (U(x,y,0)<-x) U(x,y,0) = -(float)x;\n                    if (U(x,y,1)<-y) U(x,y,1) = -(float)y;\n                    bound = (float)_width - x; if (U(x,y,0)>=bound) U(x,y,0) = bound;\n                    bound = (float)_height - y; if (U(x,y,1)>=bound) U(x,y,1) = bound;\n                  }\n                  _energy+=delta_I*delta_I + smoothness*_energy_regul;\n                }\n                if (V) cimg_forXY(V,_x,_y) if (V(_x,_y,2)) { \/\/ Apply constraints\n                    U(_x,_y,0) = V(_x,_y,0)\/factor;\n                    U(_x,_y,1) = V(_x,_y,1)\/factor;\n                  }\n              } else { \/\/ Anisotropic regularization\n              const float nsmoothness = -smoothness;\n              cimg_pragma_openmp(parallel for cimg_openmp_if(_height>=(cimg_openmp_sizefactor)*8 &&\n                                                             _width>=(cimg_openmp_sizefactor)*16) reduction(+:_energy))\n              cimg_forY(U,y) {\n                const int _p1y = y?y - 1:0, _n1y = yx) U(x,y,0) = (float)x;\n                    if (U(x,y,1)>y) U(x,y,1) = (float)y;\n                    bound = (float)x - _width; if (U(x,y,0)<=bound) U(x,y,0) = bound;\n                    bound = (float)y - _height; if (U(x,y,1)<=bound) U(x,y,1) = bound;\n                  } else {\n                    if (U(x,y,0)<-x) U(x,y,0) = -(float)x;\n                    if (U(x,y,1)<-y) U(x,y,1) = -(float)y;\n                    bound = (float)_width - x; if (U(x,y,0)>=bound) U(x,y,0) = bound;\n                    bound = (float)_height - y; if (U(x,y,1)>=bound) U(x,y,1) = bound;\n                  }\n                  _energy+=delta_I*delta_I + nsmoothness*_energy_regul;\n                }\n                if (V) cimg_forXY(V,_x,_y) if (V(_x,_y,2)) { \/\/ Apply constraints\n                    U(_x,_y,0) = V(_x,_y,0)\/factor;\n                    U(_x,_y,1) = V(_x,_y,1)\/factor;\n                  }\n              }\n            }\n          }\n          const float d_energy = (_energy - energy)\/(sw*sh*sd);\n          if (d_energy<=0 && -d_energy<_precision) break;\n          if (d_energy>0) dt*=0.5f;\n          energy = _energy;\n        }\n      }\n      return U;","target":0,"code_token_length":5205,"total_token_length":5441,"max_tokens_setting":6144}
+{"idx":255026,"func":"fp_set_per_packet_inf_from_conv(umts_fp_conversation_info_t *p_conv_data,\n                                tvbuff_t *tvb, packet_info *pinfo,\n                                proto_tree *tree _U_)\n{\n    fp_info  *fpi;\n    guint8    tfi, c_t;\n    int       offset = 0, i=0, j=0, num_tbs, chan, tb_size, tb_bit_off;\n    gboolean  is_control_frame;\n    umts_mac_info *macinf;\n    rlc_info *rlcinf;\n    guint8 fake_lchid=0;\n    gint *cur_val=NULL;\n\n    fpi = wmem_new0(wmem_file_scope(), fp_info);\n    p_add_proto_data(wmem_file_scope(), pinfo, proto_fp, 0, fpi);\n\n    fpi->iface_type = p_conv_data->iface_type;\n    fpi->division = p_conv_data->division;\n    fpi->release = 7;               \/* Set values greater then the checks performed *\/\n    fpi->release_year = 2006;\n    fpi->release_month = 12;\n    fpi->channel = p_conv_data->channel;\n    fpi->dch_crc_present = p_conv_data->dch_crc_present;\n    \/*fpi->paging_indications;*\/\n    fpi->link_type = FP_Link_Ethernet;\n\n#if 0\n    \/*Only do this the first run, signals that we need to reset the RLC fragtable*\/\n    if (!pinfo->fd->flags.visited &&  p_conv_data->reset_frag ) {\n        fpi->reset_frag = p_conv_data->reset_frag;\n        p_conv_data->reset_frag = FALSE;\n    }\n#endif\n    \/* remember 'lower' UDP layer port information so we can later\n     * differentiate 'lower' UDP layer from 'user data' UDP layer *\/\n    fpi->srcport = pinfo->srcport;\n    fpi->destport = pinfo->destport;\n\n    fpi->com_context_id = p_conv_data->com_context_id;\n\n    if (pinfo->link_dir == P2P_DIR_UL) {\n        fpi->is_uplink = TRUE;\n    } else {\n        fpi->is_uplink = FALSE;\n    }\n\n    is_control_frame = tvb_get_guint8(tvb, offset) & 0x01;\n\n    switch (fpi->channel) {\n        case CHANNEL_HSDSCH: \/* HS-DSCH - High Speed Downlink Shared Channel *\/\n            fpi->hsdsch_entity = p_conv_data->hsdsch_entity;\n            macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n            fpi->hsdsch_macflowd_id = p_conv_data->hsdsch_macdflow_id;\n           macinf->content[0] = hsdsch_macdflow_id_mac_content_map[p_conv_data->hsdsch_macdflow_id]; \/*MAC_CONTENT_PS_DTCH;*\/\n            macinf->lchid[0] = p_conv_data->hsdsch_macdflow_id;\n            \/*macinf->content[0] = lchId_type_table[p_conv_data->edch_lchId[0]];*\/\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf);\n\n            rlcinf = wmem_new0(wmem_file_scope(), rlc_info);\n\n            \/*Figure out RLC_MODE based on MACd-flow-ID, basically MACd-flow-ID = 0 then it's SRB0 == UM else AM*\/\n            rlcinf->mode[0] = hsdsch_macdflow_id_rlc_map[p_conv_data->hsdsch_macdflow_id];\n\n            if (fpi->hsdsch_entity == hs \/*&& !rlc_is_ciphered(pinfo)*\/) {\n                for (i=0; ihrnti))) != NULL) {\n                        j = 1 << i;\n                        fpi->hsdhsch_macfdlow_is_mux[i] = j & *cur_val;\n                    } else {\n                        fpi->hsdhsch_macfdlow_is_mux[i] = FALSE;\n                    }\n\n                }\n            }\n            \/* Make configurable ?(available in NBAP?) *\/\n            \/* urnti[MAX_RLC_CHANS] *\/\n            \/*\n            switch (p_conv_data->rlc_mode) {\n                case FP_RLC_TM:\n                    rlcinf->mode[0] = RLC_TM;\n                    break;\n                case FP_RLC_UM:\n                    rlcinf->mode[0] = RLC_UM;\n                    break;\n                case FP_RLC_AM:\n                    rlcinf->mode[0] = RLC_AM;\n                    break;\n                case FP_RLC_MODE_UNKNOWN:\n                default:\n                    rlcinf->mode[0] = RLC_UNKNOWN_MODE;\n                    break;\n            }*\/\n            \/* rbid[MAX_RLC_CHANS] *\/\n            \/* For RLC re-assembly to work we urnti signaled from NBAP *\/\n            rlcinf->urnti[0] = fpi->com_context_id;\n            rlcinf->li_size[0] = RLC_LI_7BITS;\n            rlcinf->ciphered[0] = FALSE;\n            rlcinf->deciphered[0] = FALSE;\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf);\n\n\n            return fpi;\n\n        case CHANNEL_EDCH:\n            \/*Most configuration is now done in the actual dissecting function*\/\n            macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n            rlcinf = wmem_new0(wmem_file_scope(), rlc_info);\n            fpi->no_ddi_entries = p_conv_data->no_ddi_entries;\n            for (i=0; ino_ddi_entries; i++) {\n                fpi->edch_ddi[i] = p_conv_data->edch_ddi[i];    \/*Set the DDI value*\/\n                fpi->edch_macd_pdu_size[i] = p_conv_data->edch_macd_pdu_size[i];    \/*Set the size*\/\n                fpi->edch_lchId[i] = p_conv_data->edch_lchId[i];    \/*Set the channel id for this entry*\/\n                \/*macinf->content[i] = lchId_type_table[p_conv_data->edch_lchId[i]]; *\/    \/*Set the proper Content type for the mac layer.*\/\n            \/*    rlcinf->mode[i] = lchId_rlc_map[p_conv_data->edch_lchId[i]];*\/ \/* Set RLC mode by lchid to RLC_MODE map in nbap.h *\/\n\n            }\n            fpi->edch_type = p_conv_data->edch_type;\n\n           \/* macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n            macinf->content[0] = MAC_CONTENT_PS_DTCH;*\/\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf);\n\n\n            \/* For RLC re-assembly to work we need a urnti signaled from NBAP *\/\n            rlcinf->urnti[0] = fpi->com_context_id;\n           \/* rlcinf->mode[0] = RLC_AM;*\/\n            rlcinf->li_size[0] = RLC_LI_7BITS;\n            rlcinf->ciphered[0] = FALSE;\n            rlcinf->deciphered[0] = FALSE;\n\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf);\n\n            return fpi;\n\n        case CHANNEL_PCH:\n            fpi->paging_indications = p_conv_data->paging_indications;\n            fpi->num_chans = p_conv_data->num_dch_in_flow;\n            \/* Set offset to point to first TFI\n             *\/\n            if (is_control_frame) {\n                \/* control frame, we're done *\/\n                return fpi;\n            }\n            \/* Set offset to TFI *\/\n            offset = 3;\n            break;\n        case CHANNEL_DCH:\n            fpi->num_chans = p_conv_data->num_dch_in_flow;\n            if (is_control_frame) {\n                \/* control frame, we're done *\/\n                return fpi;\n            }\n\n            rlcinf = wmem_new0(wmem_file_scope(), rlc_info);\n            macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n            offset = 2;    \/*To correctly read the tfi*\/\n            fakes  = 5; \/* Reset fake counter. *\/\n            for (chan=0; chan < fpi->num_chans; chan++) {    \/*Iterate over the what channels*\/\n                    \/*Iterate over the transport blocks*\/\n                   \/*tfi = tvb_get_guint8(tvb, offset);*\/\n                   \/*TFI is 5 bits according to 3GPP TS 25.321, paragraph 6.2.4.4*\/\n                    tfi = tvb_get_bits8(tvb, 3+offset*8, 5);\n\n                   \/*Figure out the number of tbs and size*\/\n                   num_tbs = (fpi->is_uplink) ? p_conv_data->fp_dch_channel_info[chan].ul_chan_num_tbs[tfi] : p_conv_data->fp_dch_channel_info[chan].dl_chan_num_tbs[tfi];\n                   tb_size=  (fpi->is_uplink) ? p_conv_data->fp_dch_channel_info[i].ul_chan_tf_size[tfi] :    p_conv_data->fp_dch_channel_info[i].dl_chan_tf_size[tfi];\n\n                    \/*TODO: This stuff has to be reworked!*\/\n                    \/*Generates a fake logical channel id for non multiplexed channel*\/\n                    if ( p_conv_data->dchs_in_flow_list[chan] != 31 && (p_conv_data->dchs_in_flow_list[chan] == 24 &&\n                     tb_size != 340) ) {\n                        fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]);\n                    }\n                    tb_bit_off = (2+p_conv_data->num_dch_in_flow)*8;    \/*Point to the C\/T of first TB*\/\n                    \/*Set configuration for individual blocks*\/\n                    for (j=0; j < num_tbs && j+chan < MAX_MAC_FRAMES; j++) {\n                        \/*Set transport channel id (useful for debugging)*\/\n                        macinf->trchid[j+chan] = p_conv_data->dchs_in_flow_list[chan];\n\n                        \/*Transport Channel m31 and 24 might be multiplexed!*\/\n                        if ( p_conv_data->dchs_in_flow_list[chan] == 31 || p_conv_data->dchs_in_flow_list[chan] == 24) {\n\n                            \/****** MUST FIGURE OUT IF THIS IS REALLY MULTIPLEXED OR NOT*******\/\n                            \/*If Trchid == 31 and only on TB, we have no multiplexing*\/\n                            if (0\/*p_conv_data->dchs_in_flow_list[chan] == 31 && num_tbs == 1*\/) {\n                                macinf->ctmux[j+chan] = FALSE;\/*Set TRUE if this channel is multiplexed (ie. C\/T flag exists)*\/\n\n                                macinf->lchid[j+chan] = 1;\n\n                                macinf->content[j+chan] = lchId_type_table[1];    \/*Base MAC content on logical channel id (Table is in packet-nbap.h)*\/\n                                rlcinf->mode[j+chan] = lchId_rlc_map[1];    \/*Based RLC mode on logical channel id*\/\n\n                            }\n                            \/*Indicate we don't have multiplexing.*\/\n                            else if (p_conv_data->dchs_in_flow_list[chan] == 24 && tb_size != 340) {\n                                macinf->ctmux[j+chan] = FALSE;\/*Set TRUE if this channel is multiplexed (ie. C\/T flag exists)*\/\n\n                                \/*g_warning(\"settin this for %d\", pinfo->num);*\/\n                                macinf->lchid[j+chan] = fake_lchid;\n                                macinf->fake_chid[j+chan] = TRUE;\n                                macinf->content[j+chan] = MAC_CONTENT_PS_DTCH; \/*lchId_type_table[fake_lchid];*\/    \/*Base MAC content on logical channel id (Table is in packet-nbap.h)*\/\n                                rlcinf->mode[j+chan] = RLC_AM;\/*lchId_rlc_map[fake_lchid];*\/    \/*Based RLC mode on logical channel id*\/\n                            }\n                            \/*We have multiplexing*\/\n                            else {\n                                macinf->ctmux[j+chan] = TRUE;\/*Set TRUE if this channel is multiplexed (ie. C\/T flag exists)*\/\n\n                                \/* Peek at C\/T, different RLC params for different logical channels *\/\n                                \/*C\/T is 4 bits according to 3GPP TS 25.321, paragraph 9.2.1, from MAC header (not FP)*\/\n                                c_t = tvb_get_bits8(tvb, tb_bit_off\/*(2+p_conv_data->num_dch_in_flow)*8*\/, 4);    \/* c_t = tvb_get_guint8(tvb, offset);*\/\n                                macinf->lchid[j+chan] = c_t+1;\n\n                                macinf->content[j+chan] = lchId_type_table[c_t+1];    \/*Base MAC content on logical channel id (Table is in packet-nbap.h)*\/\n                                rlcinf->mode[j+chan] = lchId_rlc_map[c_t+1];    \/*Based RLC mode on logical channel id*\/\n                            }\n                        } else {\n                            fake_lchid = make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]);\n                            macinf->ctmux[j+chan] = FALSE;\/*Set TRUE if this channel is multiplexed (ie. C\/T flag exists)*\/\n                            \/*macinf->content[j+chan] = MAC_CONTENT_CS_DTCH;*\/\n                            macinf->content[j+chan] = lchId_type_table[fake_lchid];\n\n\n                            rlcinf->mode[j+chan] = lchId_rlc_map[fake_lchid];\n\n                            \/*Generate virtual logical channel id*\/\n                            \/************************\/\n                            \/*TODO: Once proper lchid is always set, this has to be removed*\/\n                            macinf->fake_chid[j+chan] = TRUE;\n                            macinf->lchid[j+chan] = fake_lchid;  \/*make_fake_lchid(pinfo, p_conv_data->dchs_in_flow_list[chan]);*\/\n                            \/************************\/\n                        }\n\n                        \/*** Set rlc info ***\/\n                        rlcinf->urnti[j+chan] = p_conv_data->com_context_id;\n                        rlcinf->li_size[j+chan] = RLC_LI_7BITS;\n#if 0\n                        \/*If this entry exists, SECRUITY_MODE is completed (signled by RRC)*\/\n                        if ( rrc_ciph_inf && g_tree_lookup(rrc_ciph_inf, GINT_TO_POINTER((gint)p_conv_data->com_context_id)) != NULL ) {\n                            rlcinf->ciphered[j+chan] = TRUE;\n                        } else {\n                            rlcinf->ciphered[j+chan] = FALSE;\n                        }\n#endif\n                        rlcinf->ciphered[j+chan] = FALSE;\n                        rlcinf->deciphered[j+chan] = FALSE;\n                        rlcinf->rbid[j+chan] = macinf->lchid[j+chan];\n\n\n                        \/*Step over this TB and it's C\/T flag.*\/\n                        tb_bit_off += tb_size+4;\n                    }\n\n                    offset++;\n            }\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf);\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf);\n            \/* Set offset to point to first TFI\n             * the Number of TFI's = number of DCH's in the flow\n             *\/\n            offset = 2;\n            break;\n        case CHANNEL_FACH_FDD:\n            fpi->num_chans = p_conv_data->num_dch_in_flow;\n            if (is_control_frame) {\n                \/* control frame, we're done *\/\n                return fpi;\n            }\n            \/* Set offset to point to first TFI\n             * the Number of TFI's = number of DCH's in the flow\n             *\/\n            offset = 2;\n            \/* Set MAC data *\/\n            macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n            macinf->ctmux[0]   = 1;\n            macinf->content[0] = MAC_CONTENT_DCCH;\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf);\n            \/* Set RLC data *\/\n            rlcinf = wmem_new0(wmem_file_scope(), rlc_info);\n            \/* Make configurable ?(avaliable in NBAP?) *\/\n            \/* For RLC re-assembly to work we need to fake urnti *\/\n            rlcinf->urnti[0] = fpi->channel;\n            rlcinf->mode[0] = RLC_AM;\n            \/* rbid[MAX_RLC_CHANS] *\/\n            rlcinf->li_size[0] = RLC_LI_7BITS;\n            rlcinf->ciphered[0] = FALSE;\n            rlcinf->deciphered[0] = FALSE;\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf);\n            break;\n\n        case CHANNEL_RACH_FDD:\n            fpi->num_chans = p_conv_data->num_dch_in_flow;\n            if (is_control_frame) {\n                \/* control frame, we're done *\/\n                return fpi;\n            }\n            \/* Set offset to point to first TFI\n             * the Number of TFI's = number of DCH's in the flow\n             *\/\n            offset = 2;\n            \/* set MAC data *\/\n            macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n            rlcinf = wmem_new0(wmem_file_scope(), rlc_info);\n            for ( chan = 0; chan < fpi->num_chans; chan++ ) {\n                    macinf->ctmux[chan]   = 1;\n                    macinf->content[chan] = MAC_CONTENT_DCCH;\n                    rlcinf->urnti[chan] = fpi->com_context_id;    \/*Note that MAC probably will change this*\/\n            }\n\n\n\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf);\n            p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf);\n            break;\n        case CHANNEL_HSDSCH_COMMON:\n                rlcinf = wmem_new0(wmem_file_scope(), rlc_info);\n                macinf = wmem_new0(wmem_file_scope(), umts_mac_info);\n                p_add_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0, macinf);\n                p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0, rlcinf);\n            break;\n        default:\n            expert_add_info(pinfo, NULL, &ei_fp_transport_channel_type_unknown);\n            return NULL;\n    }\n\n    \/* Peek at the packet as the per packet info seems not to take the tfi into account *\/\n    for (i=0; inum_chans; i++) {\n        tfi = tvb_get_guint8(tvb, offset);\n\n        \/*TFI is 5 bits according to 3GPP TS 25.321, paragraph 6.2.4.4*\/\n        \/*tfi = tvb_get_bits8(tvb, offset*8, 5);*\/\n        if (pinfo->link_dir == P2P_DIR_UL) {\n            fpi->chan_tf_size[i] = p_conv_data->fp_dch_channel_info[i].ul_chan_tf_size[tfi];\n            fpi->chan_num_tbs[i] = p_conv_data->fp_dch_channel_info[i].ul_chan_num_tbs[tfi];\n        } else {\n            fpi->chan_tf_size[i] = p_conv_data->fp_dch_channel_info[i].dl_chan_tf_size[tfi];\n            fpi->chan_num_tbs[i] = p_conv_data->fp_dch_channel_info[i].dl_chan_num_tbs[tfi];\n        }\n        offset++;\n    }\n\n\n    return fpi;\n}","target":1,"code_token_length":4518,"total_token_length":4754,"max_tokens_setting":6144}
+{"idx":353819,"func":"param_expand (string, sindex, quoted, expanded_something,\n\t      contains_dollar_at, quoted_dollar_at_p, had_quoted_null_p,\n\t      pflags)\n     char *string;\n     int *sindex, quoted, *expanded_something, *contains_dollar_at;\n     int *quoted_dollar_at_p, *had_quoted_null_p, pflags;\n{\n  char *temp, *temp1, uerror[3], *savecmd;\n  int zindex, t_index, expok;\n  unsigned char c;\n  intmax_t number;\n  SHELL_VAR *var;\n  WORD_LIST *list;\n  WORD_DESC *tdesc, *ret;\n  int tflag;\n\n\/*itrace(\"param_expand: `%s' pflags = %d\", string+*sindex, pflags);*\/\n  zindex = *sindex;\n  c = string[++zindex];\n\n  temp = (char *)NULL;\n  ret = tdesc = (WORD_DESC *)NULL;\n  tflag = 0;\n\n  \/* Do simple cases first. Switch on what follows '$'. *\/\n  switch (c)\n    {\n    \/* $0 .. $9? *\/\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9':\n      temp1 = dollar_vars[TODIGIT (c)];\n      if (unbound_vars_is_error && temp1 == (char *)NULL)\n\t{\n\t  uerror[0] = '$';\n\t  uerror[1] = c;\n\t  uerror[2] = '\\0';\n\t  last_command_exit_value = EXECUTION_FAILURE;\n\t  err_unboundvar (uerror);\n\t  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);\n\t}\n      if (temp1)\n\ttemp = (*temp1 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))\n\t\t  ? quote_string (temp1)\n\t\t  : quote_escapes (temp1);\n      else\n\ttemp = (char *)NULL;\n\n      break;\n\n    \/* $$ -- pid of the invoking shell. *\/\n    case '$':\n      temp = itos (dollar_dollar_pid);\n      break;\n\n    \/* $# -- number of positional parameters. *\/\n    case '#':\n      temp = itos (number_of_args ());\n      break;\n\n    \/* $? -- return value of the last synchronous command. *\/\n    case '?':\n      temp = itos (last_command_exit_value);\n      break;\n\n    \/* $- -- flags supplied to the shell on invocation or by `set'. *\/\n    case '-':\n      temp = which_set_flags ();\n      break;\n\n      \/* $! -- Pid of the last asynchronous command. *\/\n    case '!':\n      \/* If no asynchronous pids have been created, expand to nothing.\n\t If `set -u' has been executed, and no async processes have\n\t been created, this is an expansion error. *\/\n      if (last_asynchronous_pid == NO_PID)\n\t{\n\t  if (expanded_something)\n\t    *expanded_something = 0;\n\t  temp = (char *)NULL;\n\t  if (unbound_vars_is_error)\n\t    {\n\t      uerror[0] = '$';\n\t      uerror[1] = c;\n\t      uerror[2] = '\\0';\n\t      last_command_exit_value = EXECUTION_FAILURE;\n\t      err_unboundvar (uerror);\n\t      return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);\n\t    }\n\t}\n      else\n\ttemp = itos (last_asynchronous_pid);\n      break;\n\n    \/* The only difference between this and $@ is when the arg is quoted. *\/\n    case '*':\t\t\/* `$*' *\/\n      list = list_rest_of_args ();\n\n#if 0\n      \/* According to austin-group posix proposal by Geoff Clare in\n\t <20090505091501.GA10097@squonk.masqnet> of 5 May 2009:\n\n \t\"The shell shall write a message to standard error and\n \t immediately exit when it tries to expand an unset parameter\n \t other than the '@' and '*' special parameters.\"\n      *\/\n\n      if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0)\n\t{\n\t  uerror[0] = '$';\n\t  uerror[1] = '*';\n\t  uerror[2] = '\\0';\n\t  last_command_exit_value = EXECUTION_FAILURE;\n\t  err_unboundvar (uerror);\n\t  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);\n\t}\n#endif\n\n      \/* If there are no command-line arguments, this should just\n\t disappear if there are other characters in the expansion,\n\t even if it's quoted. *\/\n      if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && list == 0)\n\ttemp = (char *)NULL;\n      else if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE))\n\t{\n\t  \/* If we have \"$*\" we want to make a string of the positional\n\t     parameters, separated by the first character of $IFS, and\n\t     quote the whole string, including the separators.  If IFS\n\t     is unset, the parameters are separated by ' '; if $IFS is\n\t     null, the parameters are concatenated. *\/\n\t  temp = (quoted & (Q_DOUBLE_QUOTES|Q_PATQUOTE)) ? string_list_dollar_star (list) : string_list (list);\n\t  if (temp)\n\t    {\n\t      temp1 = (quoted & Q_DOUBLE_QUOTES) ? quote_string (temp) : temp;\n\t      if (*temp == 0)\n\t\ttflag |= W_HASQUOTEDNULL;\n\t      if (temp != temp1)\n\t\tfree (temp);\n\t      temp = temp1;\n\t    }\n\t}\n      else\n\t{\n\t  \/* We check whether or not we're eventually going to split $* here,\n\t     for example when IFS is empty and we are processing the rhs of\n\t     an assignment statement.  In that case, we don't separate the\n\t     arguments at all.  Otherwise, if the $* is not quoted it is\n\t     identical to $@ *\/\n#  if defined (HANDLE_MULTIBYTE)\n\t  if (expand_no_split_dollar_star && ifs_firstc[0] == 0)\n#  else\n\t  if (expand_no_split_dollar_star && ifs_firstc == 0)\n#  endif\n\t    temp = string_list_dollar_star (list);\n\t  else\n\t    {\n\t      temp = string_list_dollar_at (list, quoted, 0);\n\t      if (quoted == 0 && (ifs_is_set == 0 || ifs_is_null))\n\t\ttflag |= W_SPLITSPACE;\n\t      \/* If we're not quoted but we still don't want word splitting, make\n\t\t we quote the IFS characters to protect them from splitting (e.g.,\n\t\t when $@ is in the string as well). *\/\n\t      else if (quoted == 0 && ifs_is_set && (pflags & PF_ASSIGNRHS))\n\t\t{\n\t\t  temp1 = quote_string (temp);\n\t\t  free (temp);\n\t\t  temp = temp1;\n\t\t}\n\t    }\n\n\t  if (expand_no_split_dollar_star == 0 && contains_dollar_at)\n\t    *contains_dollar_at = 1;\n\t}\n\n      dispose_words (list);\n      break;\n\n    \/* When we have \"$@\" what we want is \"$1\" \"$2\" \"$3\" ... This\n       means that we have to turn quoting off after we split into\n       the individually quoted arguments so that the final split\n       on the first character of $IFS is still done.  *\/\n    case '@':\t\t\/* `$@' *\/\n      list = list_rest_of_args ();\n\n#if 0\n      \/* According to austin-group posix proposal by Geoff Clare in\n\t <20090505091501.GA10097@squonk.masqnet> of 5 May 2009:\n\n \t\"The shell shall write a message to standard error and\n \t immediately exit when it tries to expand an unset parameter\n \t other than the '@' and '*' special parameters.\"\n      *\/\n\n      if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0)\n\t{\n\t  uerror[0] = '$';\n\t  uerror[1] = '@';\n\t  uerror[2] = '\\0';\n\t  last_command_exit_value = EXECUTION_FAILURE;\n\t  err_unboundvar (uerror);\n\t  return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);\n\t}\n#endif\n\n      \/* We want to flag the fact that we saw this.  We can't turn\n\t off quoting entirely, because other characters in the\n\t string might need it (consider \"\\\"$@\\\"\"), but we need some\n\t way to signal that the final split on the first character\n\t of $IFS should be done, even though QUOTED is 1. *\/\n      \/* XXX - should this test include Q_PATQUOTE? *\/\n      if (quoted_dollar_at_p && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))\n\t*quoted_dollar_at_p = 1;\n      if (contains_dollar_at)\n\t*contains_dollar_at = 1;\n\n      \/* We want to separate the positional parameters with the first\n\t character of $IFS in case $IFS is something other than a space.\n\t We also want to make sure that splitting is done no matter what --\n\t according to POSIX.2, this expands to a list of the positional\n\t parameters no matter what IFS is set to. *\/\n      \/* XXX - what to do when in a context where word splitting is not\n\t performed? Even when IFS is not the default, posix seems to imply\n\t that we behave like unquoted $* ?  Maybe we should use PF_NOSPLIT2\n\t here. *\/\n      temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted, 0);\n\n      tflag |= W_DOLLARAT;\n      dispose_words (list);\n      break;\n\n    case LBRACE:\n      tdesc = parameter_brace_expand (string, &zindex, quoted, pflags,\n\t\t\t\t      quoted_dollar_at_p,\n\t\t\t\t      contains_dollar_at);\n\n      if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)\n\treturn (tdesc);\n      temp = tdesc ? tdesc->word : (char *)0;\n\n      \/* XXX *\/\n      \/* Quoted nulls should be removed if there is anything else\n\t in the string. *\/\n      \/* Note that we saw the quoted null so we can add one back at\n\t the end of this function if there are no other characters\n\t in the string, discard TEMP, and go on.  The exception to\n\t this is when we have \"${@}\" and $1 is '', since $@ needs\n\t special handling. *\/\n      if (tdesc && tdesc->word && (tdesc->flags & W_HASQUOTEDNULL) && QUOTED_NULL (temp))\n\t{\n\t  if (had_quoted_null_p)\n\t    *had_quoted_null_p = 1;\n\t  if (*quoted_dollar_at_p == 0)\n\t    {\n\t      free (temp);\n\t      tdesc->word = temp = (char *)NULL;\n\t    }\n\t    \n\t}\n\n      ret = tdesc;\n      goto return0;\n\n    \/* Do command or arithmetic substitution. *\/\n    case LPAREN:\n      \/* We have to extract the contents of this paren substitution. *\/\n      t_index = zindex + 1;\n      temp = extract_command_subst (string, &t_index, 0);\n      zindex = t_index;\n\n      \/* For Posix.2-style `$(( ))' arithmetic substitution,\n\t extract the expression and pass it to the evaluator. *\/\n      if (temp && *temp == LPAREN)\n\t{\n\t  char *temp2;\n\t  temp1 = temp + 1;\n\t  temp2 = savestring (temp1);\n\t  t_index = strlen (temp2) - 1;\n\n\t  if (temp2[t_index] != RPAREN)\n\t    {\n\t      free (temp2);\n\t      goto comsub;\n\t    }\n\n\t  \/* Cut off ending `)' *\/\n\t  temp2[t_index] = '\\0';\n\n\t  if (chk_arithsub (temp2, t_index) == 0)\n\t    {\n\t      free (temp2);\n#if 0\n\t      internal_warning (_(\"future versions of the shell will force evaluation as an arithmetic substitution\"));\n#endif\n\t      goto comsub;\n\t    }\n\n\t  \/* Expand variables found inside the expression. *\/\n\t  temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES|Q_ARITH);\n\t  free (temp2);\n\narithsub:\n\t  \/* No error messages. *\/\n\t  savecmd = this_command_name;\n\t  this_command_name = (char *)NULL;\n\t  number = evalexp (temp1, &expok);\n\t  this_command_name = savecmd;\n\t  free (temp);\n\t  free (temp1);\n\t  if (expok == 0)\n\t    {\n\t      if (interactive_shell == 0 && posixly_correct)\n\t\t{\n\t\t  last_command_exit_value = EXECUTION_FAILURE;\n\t\t  return (&expand_wdesc_fatal);\n\t\t}\n\t      else\n\t\treturn (&expand_wdesc_error);\n\t    }\n\t  temp = itos (number);\n\t  break;\n\t}\n\ncomsub:\n      if (pflags & PF_NOCOMSUB)\n\t\/* we need zindex+1 because string[zindex] == RPAREN *\/\n\ttemp1 = substring (string, *sindex, zindex+1);\n      else\n\t{\n\t  tdesc = command_substitute (temp, quoted);\n\t  temp1 = tdesc ? tdesc->word : (char *)NULL;\n\t  if (tdesc)\n\t    dispose_word_desc (tdesc);\n\t}\n      FREE (temp);\n      temp = temp1;\n      break;\n\n    \/* Do POSIX.2d9-style arithmetic substitution.  This will probably go\n       away in a future bash release. *\/\n    case '[':\n      \/* Extract the contents of this arithmetic substitution. *\/\n      t_index = zindex + 1;\n      temp = extract_arithmetic_subst (string, &t_index);\n      zindex = t_index;\n      if (temp == 0)\n\t{\n\t  temp = savestring (string);\n\t  if (expanded_something)\n\t    *expanded_something = 0;\n\t  goto return0;\n\t}\t  \n\n       \/* Do initial variable expansion. *\/\n      temp1 = expand_arith_string (temp, Q_DOUBLE_QUOTES|Q_ARITH);\n\n      goto arithsub;\n\n    default:\n      \/* Find the variable in VARIABLE_LIST. *\/\n      temp = (char *)NULL;\n\n      for (t_index = zindex; (c = string[zindex]) && legal_variable_char (c); zindex++)\n\t;\n      temp1 = (zindex > t_index) ? substring (string, t_index, zindex) : (char *)NULL;\n\n      \/* If this isn't a variable name, then just output the `$'. *\/\n      if (temp1 == 0 || *temp1 == '\\0')\n\t{\n\t  FREE (temp1);\n\t  temp = (char *)xmalloc (2);\n\t  temp[0] = '$';\n\t  temp[1] = '\\0';\n\t  if (expanded_something)\n\t    *expanded_something = 0;\n\t  goto return0;\n\t}\n\n      \/* If the variable exists, return its value cell. *\/\n      var = find_variable (temp1);\n\n      if (var && invisible_p (var) == 0 && var_isset (var))\n\t{\n#if defined (ARRAY_VARS)\n\t  if (assoc_p (var) || array_p (var))\n\t    {\n\t      temp = array_p (var) ? array_reference (array_cell (var), 0)\n\t\t\t\t   : assoc_reference (assoc_cell (var), \"0\");\n\t      if (temp)\n\t\ttemp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))\n\t\t\t  ? quote_string (temp)\n\t\t\t  : quote_escapes (temp);\n\t      else if (unbound_vars_is_error)\n\t\tgoto unbound_variable;\n\t    }\n\t  else\n#endif\n\t    {\n\t      temp = value_cell (var);\n\n\t      temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))\n\t\t\t? quote_string (temp)\n\t\t\t: quote_escapes (temp);\n\t    }\n\n\t  free (temp1);\n\n\t  goto return0;\n\t}\n      else if (var && (invisible_p (var) || var_isset (var) == 0))\n\ttemp = (char *)NULL;\n      else if ((var = find_variable_last_nameref (temp1, 0)) && var_isset (var) && invisible_p (var) == 0)\n\t{\n\t  temp = nameref_cell (var);\n#if defined (ARRAY_VARS)\n\t  if (temp && *temp && valid_array_reference (temp, 0))\n\t    {\n\t      tdesc = parameter_brace_expand_word (temp, SPECIAL_VAR (temp, 0), quoted, pflags, (arrayind_t *)NULL);\n\t      if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)\n\t\treturn (tdesc);\n\t      ret = tdesc;\n\t      goto return0;\n\t    }\n\t  else\n#endif\n\t  \/* y=2 ; typeset -n x=y; echo $x is not the same as echo $2 in ksh *\/\n\t  if (temp && *temp && legal_identifier (temp) == 0)\n\t    {\n\t      last_command_exit_value = EXECUTION_FAILURE;\n\t      report_error (_(\"%s: invalid variable name for name reference\"), temp);\n\t      return (&expand_wdesc_error);\t\/* XXX *\/\n\t    }\n\t  else\n\t    temp = (char *)NULL;\n\t}\n\n      temp = (char *)NULL;\n\nunbound_variable:\n      if (unbound_vars_is_error)\n\t{\n\t  last_command_exit_value = EXECUTION_FAILURE;\n\t  err_unboundvar (temp1);\n\t}\n      else\n\t{\n\t  free (temp1);\n\t  goto return0;\n\t}\n\n      free (temp1);\n      last_command_exit_value = EXECUTION_FAILURE;\n      return ((unbound_vars_is_error && interactive_shell == 0)\n\t\t? &expand_wdesc_fatal\n\t\t: &expand_wdesc_error);\n    }\n\n  if (string[zindex])\n    zindex++;\n\nreturn0:\n  *sindex = zindex;\n\n  if (ret == 0)\n    {\n      ret = alloc_word_desc ();\n      ret->flags = tflag;\t\/* XXX *\/\n      ret->word = temp;\n    }\n  return ret;\n}","target":1,"code_token_length":3979,"total_token_length":4215,"max_tokens_setting":6144}
+{"idx":3080,"func":"TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n  OpData* op_data = static_cast(node->user_data);\n\n  TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n  \/\/ Logic for determining regular lstm and layer norm lstm:\n  \/\/ input_size, forget_gate_layer_norm_tensor (20) null? is_layer_norm?\n  \/\/ 20,         N\/A,                                     No.\n  \/\/ 24,         null,                                    No.\n  \/\/ 24,         not null,                                Yes.\n  \/\/ 20-inputs lstm are deprecated and is only kept here for backward\n  \/\/ compatibility.\n  if (node->inputs->size == 24) {\n    const TfLiteTensor* forget_layer_norm_coefficients = GetOptionalInputTensor(\n        context, node, kForgetLayerNormCoefficientsTensor);\n    if (forget_layer_norm_coefficients == nullptr) {\n      op_data->use_layer_norm = false;\n    } else {\n      op_data->use_layer_norm = true;\n    }\n  } else if (node->inputs->size == 20) {\n    \/\/ This is deprecated and is only kept here for backward compatibility.\n    op_data->use_layer_norm = false;\n  } else {\n    context->ReportError(\n        context, \"The LSTM Full kernel expects 20 or 24 inputs. Got %d inputs\",\n        node->inputs->size);\n    return kTfLiteError;\n  }\n\n  const bool use_layer_norm = op_data->use_layer_norm;\n\n  \/\/ Inferring batch size, number of outputs and number of cells from the\n  \/\/ input tensors.\n  const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n  const bool is_integer = input->type == kTfLiteInt8;\n  TF_LITE_ENSURE(context, input->dims->size > 1);\n  const int n_batch = input->dims->data[0];\n  const int n_input = input->dims->data[1];\n\n  const TfLiteTensor* input_to_output_weights =\n      GetInput(context, node, kInputToOutputWeightsTensor);\n  const int n_cell = input_to_output_weights->dims->data[0];\n  TF_LITE_ENSURE_EQ(context, input_to_output_weights->dims->size, 2);\n  TF_LITE_ENSURE_EQ(context, input_to_output_weights->dims->data[1], n_input);\n\n  const TfLiteTensor* recurrent_to_output_weights =\n      GetInput(context, node, kRecurrentToOutputWeightsTensor);\n  TF_LITE_ENSURE_EQ(context, recurrent_to_output_weights->dims->size, 2);\n  TF_LITE_ENSURE_EQ(context, recurrent_to_output_weights->dims->data[0],\n                    n_cell);\n  const int n_output = recurrent_to_output_weights->dims->data[1];\n\n  \/\/ Check that input tensor dimensions matches with each other.\n  TF_LITE_ENSURE_OK(\n      context, CheckInputTensorDimensions(context, node, n_input, n_output,\n                                          n_cell, use_layer_norm, is_integer));\n\n  \/\/ Get the pointer to output, output_state and cell_state tensors.\n  TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n  TfLiteTensor* output_state =\n      GetVariableInput(context, node, kOutputStateTensor);\n  TF_LITE_ENSURE(context, output_state != nullptr);\n  TfLiteTensor* cell_state = GetVariableInput(context, node, kCellStateTensor);\n  TF_LITE_ENSURE(context, cell_state != nullptr);\n\n  \/\/ Check the shape of input state tensors.\n  \/\/ These tensor may be 1D or 2D. It's fine as long as the total size is\n  \/\/ correct.\n  TF_LITE_ENSURE_EQ(context, NumElements(output_state), n_batch * n_output);\n  TF_LITE_ENSURE_EQ(context, NumElements(cell_state), n_batch * n_cell);\n\n  \/\/ Resize the output tensors.\n  TfLiteIntArray* output_size = TfLiteIntArrayCreate(2);\n  output_size->data[0] = n_batch;\n  output_size->data[1] = n_output;\n  TF_LITE_ENSURE_OK(context,\n                    context->ResizeTensor(context, output, output_size));\n\n  \/\/ The weights are of consistent type, so it suffices to check one.\n  const bool is_hybrid_op = IsHybridOp(input, input_to_output_weights);\n\n  const bool is_sparse_op = (input_to_output_weights->sparsity != nullptr);\n\n  \/\/ The type of Integer LSTM.\n  const int num_intermediate_tensors = node->intermediates->size;\n  if (is_integer) {\n    TF_LITE_ENSURE(context, num_intermediate_tensors == 5 ||\n                                num_intermediate_tensors == 12);\n  }\n  \/\/ We use number of intermediate tensors to distinguish the 8 bit matmul\n  \/\/ output and the 16 bit matmul output version.\n  const bool is_8x8_16 = num_intermediate_tensors == 5;\n\n  TfLiteIntArrayFree(node->temporaries);\n  if (is_hybrid_op) {\n    if (is_sparse_op) {\n      node->temporaries =\n          TfLiteIntArrayCreate(kNumHybridTemporaryTensors + kLedgersToAdd);\n    } else {\n      node->temporaries = TfLiteIntArrayCreate(kNumHybridTemporaryTensors);\n    }\n  } else if (is_integer) {\n    if (is_8x8_16) {\n      node->temporaries = TfLiteIntArrayCreate(6);\n    } else {\n      node->temporaries = TfLiteIntArrayCreate(8);\n    }\n  } else {\n    node->temporaries = TfLiteIntArrayCreate(1);\n  }\n\n  \/\/ Create a scratch buffer tensor for float case and hybrid case.\n  \/\/ TODO(b\/152066492): Create a is_float boolean and reorganize the temporary\n  \/\/ buffer allocation logic.\n  if (!is_integer) {\n    node->temporaries->data[kScratchBuffer] =\n        op_data->scratch_tensor_index + kScratchBuffer;\n    TfLiteTensor* scratch_buffer = GetTemporary(context, node, kScratchBuffer);\n    scratch_buffer->type = input->type;\n    scratch_buffer->allocation_type = kTfLiteArenaRw;\n\n    const TfLiteTensor* input_to_input_weights =\n        GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);\n    const bool use_cifg = (input_to_input_weights == nullptr);\n    TfLiteIntArray* scratch_buffer_size = TfLiteIntArrayCreate(2);\n    scratch_buffer_size->data[0] = n_batch;\n    if (use_cifg) {\n      \/\/ Reserving space for Cell, Forget, Output gates\n      scratch_buffer_size->data[1] = n_cell * 3;\n    } else {\n      \/\/ Reserving space for Input, Cell, Forget, Output gates\n      scratch_buffer_size->data[1] = n_cell * 4;\n    }\n    TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, scratch_buffer,\n                                                     scratch_buffer_size));\n  }\n\n  if (is_hybrid_op) {\n    if (!is_sparse_op) {\n      op_data->compute_row_sums = true;\n    }\n    \/\/ Allocate temporary tensors to store quantized values of input,\n    \/\/ output_state and cell_state tensors.\n    node->temporaries->data[kInputQuantized] =\n        op_data->scratch_tensor_index + kInputQuantized;\n    TfLiteTensor* input_quantized =\n        GetTemporary(context, node, kInputQuantized);\n    input_quantized->type = input_to_output_weights->type;\n    input_quantized->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqual(input_quantized->dims, input->dims)) {\n      TfLiteIntArray* input_quantized_size = TfLiteIntArrayCopy(input->dims);\n      TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, input_quantized,\n                                                       input_quantized_size));\n    }\n    node->temporaries->data[kOutputStateQuantized] =\n        op_data->scratch_tensor_index + kOutputStateQuantized;\n    TfLiteTensor* output_state_quantized =\n        GetTemporary(context, node, kOutputStateQuantized);\n    output_state_quantized->type = input_to_output_weights->type;\n    output_state_quantized->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqual(output_state_quantized->dims,\n                             output_state->dims)) {\n      TfLiteIntArray* output_state_quantized_size =\n          TfLiteIntArrayCopy(output_state->dims);\n      TF_LITE_ENSURE_OK(context,\n                        context->ResizeTensor(context, output_state_quantized,\n                                              output_state_quantized_size));\n    }\n    node->temporaries->data[kCellStateQuantized] =\n        op_data->scratch_tensor_index + kCellStateQuantized;\n    TfLiteTensor* cell_state_quantized =\n        GetTemporary(context, node, kCellStateQuantized);\n    cell_state_quantized->type = input_to_output_weights->type;\n    cell_state_quantized->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqual(cell_state_quantized->dims, cell_state->dims)) {\n      TfLiteIntArray* cell_state_quantized_size =\n          TfLiteIntArrayCopy(cell_state->dims);\n      TF_LITE_ENSURE_OK(context,\n                        context->ResizeTensor(context, cell_state_quantized,\n                                              cell_state_quantized_size));\n    }\n    \/\/ Allocate temporary tensors to store scaling factors and product scaling\n    \/\/ factors. The latter is a convenience storage which allows to quantize\n    \/\/ a vector once (which produces the scaling factors) and multiply it with\n    \/\/ different matrices (which requires multiplying the scaling factors with\n    \/\/ the scaling factor of the matrix).\n    node->temporaries->data[kInputScalingFactors] =\n        op_data->scratch_tensor_index + kInputScalingFactors;\n    TfLiteTensor* input_sf = GetTemporary(context, node, kInputScalingFactors);\n    input_sf->type = kTfLiteFloat32;\n    input_sf->allocation_type = kTfLiteArenaRw;\n    int scaling_dims[1] = {n_batch};\n    if (!TfLiteIntArrayEqualsArray(input_sf->dims, 1, scaling_dims)) {\n      TfLiteIntArray* input_sf_size = TfLiteIntArrayCreate(1);\n      input_sf_size->data[0] = n_batch;\n      TF_LITE_ENSURE_OK(\n          context, context->ResizeTensor(context, input_sf, input_sf_size));\n    }\n    node->temporaries->data[kOutputStateScalingFactors] =\n        op_data->scratch_tensor_index + kOutputStateScalingFactors;\n    TfLiteTensor* output_state_sf =\n        GetTemporary(context, node, kOutputStateScalingFactors);\n    output_state_sf->type = kTfLiteFloat32;\n    output_state_sf->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqualsArray(output_state_sf->dims, 1, scaling_dims)) {\n      TfLiteIntArray* output_state_sf_size = TfLiteIntArrayCreate(1);\n      output_state_sf_size->data[0] = n_batch;\n      TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, output_state_sf,\n                                                       output_state_sf_size));\n    }\n    node->temporaries->data[kProductScalingFactors] =\n        op_data->scratch_tensor_index + kProductScalingFactors;\n    TfLiteTensor* prod_scaling_factors =\n        GetTemporary(context, node, kProductScalingFactors);\n    prod_scaling_factors->type = kTfLiteFloat32;\n    prod_scaling_factors->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqualsArray(prod_scaling_factors->dims, 1,\n                                   scaling_dims)) {\n      TfLiteIntArray* prod_scaling_factors_size = TfLiteIntArrayCreate(1);\n      prod_scaling_factors_size->data[0] = n_batch;\n      TF_LITE_ENSURE_OK(context,\n                        context->ResizeTensor(context, prod_scaling_factors,\n                                              prod_scaling_factors_size));\n    }\n\n    \/\/ Allocate a temporary tensor to store the recovered cell weights. Since\n    \/\/ this is used for diagonal matrices, only need to store n_cell values.\n    node->temporaries->data[kRecoveredCellWeights] =\n        op_data->scratch_tensor_index + kRecoveredCellWeights;\n    TfLiteTensor* recovered_cell_weights =\n        GetTemporary(context, node, kRecoveredCellWeights);\n    recovered_cell_weights->type = kTfLiteFloat32;\n    recovered_cell_weights->allocation_type = kTfLiteArenaRw;\n    int recovered_cell_dims[1] = {n_cell};\n    if (!TfLiteIntArrayEqualsArray(recovered_cell_weights->dims, 1,\n                                   recovered_cell_dims)) {\n      TfLiteIntArray* recovered_cell_weights_size = TfLiteIntArrayCreate(1);\n      recovered_cell_weights_size->data[0] = n_cell;\n      TF_LITE_ENSURE_OK(context,\n                        context->ResizeTensor(context, recovered_cell_weights,\n                                              recovered_cell_weights_size));\n    }\n    \/\/ Allocate a temporary tensor to store accumulate values for matrix\n    \/\/ multiplication before multiplication by scaling factor\n    node->temporaries->data[kAccumScratch] =\n        op_data->scratch_tensor_index + kAccumScratch;\n    TfLiteTensor* accum_scratch = GetTemporary(context, node, kAccumScratch);\n    accum_scratch->type = kTfLiteInt32;\n    accum_scratch->allocation_type = kTfLiteArenaRw;\n    int accum_scratch_dims[2] = {n_cell, n_batch};\n    if (!TfLiteIntArrayEqualsArray(accum_scratch->dims, 2,\n                                   accum_scratch_dims)) {\n      TfLiteIntArray* accum_size = TfLiteIntArrayCreate(2);\n      accum_size->data[0] = n_cell;\n      accum_size->data[1] = n_batch;\n      TF_LITE_ENSURE_OK(\n          context, context->ResizeTensor(context, accum_scratch, accum_size));\n    }\n    node->temporaries->data[kInputZeroPoints] =\n        op_data->scratch_tensor_index + kInputZeroPoints;\n    TfLiteTensor* input_zp = GetTemporary(context, node, kInputZeroPoints);\n    input_zp->type = kTfLiteFloat32;\n    input_zp->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqualsArray(input_zp->dims, 1, scaling_dims)) {\n      TfLiteIntArray* input_zp_size = TfLiteIntArrayCreate(1);\n      input_zp_size->data[0] = n_batch;\n      TF_LITE_ENSURE_OK(\n          context, context->ResizeTensor(context, input_zp, input_zp_size));\n    }\n    node->temporaries->data[kOutputStateZeroPoints] =\n        op_data->scratch_tensor_index + kOutputStateZeroPoints;\n    TfLiteTensor* output_state_zp =\n        GetTemporary(context, node, kOutputStateZeroPoints);\n    output_state_zp->type = kTfLiteFloat32;\n    output_state_zp->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqualsArray(output_state_zp->dims, 1, scaling_dims)) {\n      TfLiteIntArray* output_state_zp_size = TfLiteIntArrayCreate(1);\n      output_state_zp_size->data[0] = n_batch;\n      TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, output_state_zp,\n                                                       output_state_zp_size));\n    }\n\n    node->temporaries->data[kRowSums] =\n        op_data->scratch_tensor_index + kRowSums;\n    const TfLiteTensor* input_to_input_weights =\n        GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);\n    const bool use_cifg = (input_to_input_weights == nullptr);\n    int row_sums_rows = use_cifg ? 6 : 8;\n    const TfLiteTensor* projection_weights =\n        GetOptionalInputTensor(context, node, kProjectionWeightsTensor);\n    if (projection_weights != nullptr) {\n      row_sums_rows += ceil(static_cast(n_output) \/ n_cell);\n    }\n\n    TfLiteTensor* row_sums = GetTemporary(context, node, kRowSums);\n    row_sums->type = kTfLiteInt32;\n    row_sums->allocation_type = kTfLiteArenaRwPersistent;\n    const int row_sums_dims[2] = {row_sums_rows, n_cell};\n    if (!TfLiteIntArrayEqualsArray(row_sums->dims, 2, row_sums_dims)) {\n      TfLiteIntArray* row_sums_size = TfLiteIntArrayCreate(2);\n      row_sums_size->data[0] = row_sums_dims[0];\n      row_sums_size->data[1] = row_sums_dims[1];\n      TF_LITE_ENSURE_OK(\n          context, context->ResizeTensor(context, row_sums, row_sums_size));\n    }\n\n    if (is_sparse_op) {\n      op_data->ledger_initialized = false;\n      int offset = kNumHybridTemporaryTensors;\n      {\n        node->temporaries->data[offset + kInputToInputWeightsLedgerOffset] =\n            op_data->ledger_index + kInputToInputWeightsLedgerOffset;\n        const TfLiteTensor* input_to_input_weights =\n            GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);\n        TfLiteTensor* input_to_input_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kInputToInputWeightsLedgerOffset];\n        auto status = make_ledger(input_to_input_weights == nullptr\n                                      ? nullptr\n                                      : input_to_input_weights->sparsity,\n                                  context, input_to_input_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries->data[offset + kInputToForgetWeightsLedgerOffset] =\n            op_data->ledger_index + kInputToForgetWeightsLedgerOffset;\n        const TfLiteTensor* input_to_forget_weights =\n            GetInput(context, node, kInputToForgetWeightsTensor);\n        TfLiteTensor* input_to_forget_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kInputToForgetWeightsLedgerOffset];\n        auto status = make_ledger(input_to_forget_weights->sparsity, context,\n                                  input_to_forget_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries->data[offset + kInputToCellWeightsLedgerOffset] =\n            op_data->ledger_index + kInputToCellWeightsLedgerOffset;\n        const TfLiteTensor* input_to_cell_weights =\n            GetInput(context, node, kInputToCellWeightsTensor);\n        TfLiteTensor* input_to_cell_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kInputToCellWeightsLedgerOffset];\n        auto status = make_ledger(input_to_cell_weights->sparsity, context,\n                                  input_to_cell_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries->data[offset + kInputToOutputWeightsLedgerOffset] =\n            op_data->ledger_index + kInputToOutputWeightsLedgerOffset;\n        const TfLiteTensor* input_to_output_weights =\n            GetInput(context, node, kInputToOutputWeightsTensor);\n        TfLiteTensor* input_to_output_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kInputToOutputWeightsLedgerOffset];\n        auto status = make_ledger(input_to_output_weights->sparsity, context,\n                                  input_to_output_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries->data[offset + kRecurrentToInputWeightsLedgerOffset] =\n            op_data->ledger_index + kRecurrentToInputWeightsLedgerOffset;\n        const TfLiteTensor* recurrent_to_input_weights = GetOptionalInputTensor(\n            context, node, kRecurrentToInputWeightsTensor);\n        TfLiteTensor* recurrent_to_input_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kRecurrentToInputWeightsLedgerOffset];\n        auto status = make_ledger(recurrent_to_input_weights == nullptr\n                                      ? nullptr\n                                      : recurrent_to_input_weights->sparsity,\n                                  context, recurrent_to_input_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries\n            ->data[offset + kRecurrentToForgetWeightsLedgerOffset] =\n            op_data->ledger_index + kRecurrentToForgetWeightsLedgerOffset;\n        const TfLiteTensor* recurrent_to_forget_weights =\n            GetInput(context, node, kRecurrentToForgetWeightsTensor);\n        TfLiteTensor* recurrent_to_forget_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kRecurrentToForgetWeightsLedgerOffset];\n        auto status = make_ledger(recurrent_to_forget_weights->sparsity,\n                                  context, recurrent_to_forget_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries->data[offset + kRecurrentToCellWeightsLedgerOffset] =\n            op_data->ledger_index + kRecurrentToCellWeightsLedgerOffset;\n        const TfLiteTensor* recurrent_to_cell_weights =\n            GetInput(context, node, kRecurrentToCellWeightsTensor);\n        TfLiteTensor* recurrent_to_cell_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kRecurrentToCellWeightsLedgerOffset];\n        auto status = make_ledger(recurrent_to_cell_weights->sparsity, context,\n                                  recurrent_to_cell_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries\n            ->data[offset + kRecurrentToOutputWeightsLedgerOffset] =\n            op_data->ledger_index + kRecurrentToOutputWeightsLedgerOffset;\n        const TfLiteTensor* recurrent_to_output_weights =\n            GetInput(context, node, kRecurrentToOutputWeightsTensor);\n        TfLiteTensor* recurrent_to_output_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kRecurrentToOutputWeightsLedgerOffset];\n        auto status = make_ledger(recurrent_to_output_weights->sparsity,\n                                  context, recurrent_to_output_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n      {\n        node->temporaries->data[offset + kProjectionWeightsLedgerOffset] =\n            op_data->ledger_index + kProjectionWeightsLedgerOffset;\n        const TfLiteTensor* projection_weights =\n            GetInput(context, node, kProjectionWeightsTensor);\n        TfLiteTensor* projection_weights_ledger =\n            &context->tensors[op_data->ledger_index +\n                              kProjectionWeightsLedgerOffset];\n        auto status = make_ledger(projection_weights->sparsity, context,\n                                  projection_weights_ledger);\n        if (status != kTfLiteOk) return status;\n      }\n    }\n  }\n\n  if (is_integer) {\n    if (is_8x8_16) {\n      \/\/ Integer LSTM prepare function for 8x8->16.\n      \/\/ This code path needs 5 intermediate tensors per Op.\n      \/\/ Populate quantization parameters.\n      PopulateQuantizedLstmParams8x8_16(context, node,\n                                        &op_data->integer_lstm_param);\n\n      \/\/ Allocate scratch buffer. Need 6 16bit buffer with size n_batch * n_cell\n      \/\/ and 1 8bit buffer with size n_batch * n_cell. We also need 1 32 bit\n      \/\/ buffer with size n_batch * n_cell.\n      \/\/\n      \/\/ Handle cifg case as well, which might save one buffer.\n      for (int scratch_index = 0; scratch_index < 6; ++scratch_index) {\n        node->temporaries->data[scratch_index] =\n            op_data->scratch_tensor_index + scratch_index;\n        TfLiteTensor* scratch_tensor =\n            GetTemporary(context, node, scratch_index);\n        scratch_tensor->type = kTfLiteInt16;\n        if (scratch_index == 4) {\n          scratch_tensor->type = kTfLiteInt8;\n        } else if (scratch_index == 5) {\n          scratch_tensor->type = kTfLiteInt32;\n        }\n        scratch_tensor->allocation_type = kTfLiteArenaRw;\n        const int scratch_dimension[2] = {n_batch, n_cell};\n        if (!TfLiteIntArrayEqualsArray(scratch_tensor->dims, 2,\n                                       scratch_dimension)) {\n          TfLiteIntArray* scratch_buffer_size = TfLiteIntArrayCreate(2);\n          scratch_buffer_size->data[0] = n_batch;\n          scratch_buffer_size->data[1] = n_cell;\n          TF_LITE_ENSURE_OK(context,\n                            context->ResizeTensor(context, scratch_tensor,\n                                                  scratch_buffer_size));\n        }\n      }\n\n      \/\/ Populate precomputed zp * weight.\n      TF_LITE_ENSURE_OK(context, PopulatePrecomputedZPTimesWeightsWithBias(\n                                     context, op_data, node));\n    } else {\n      \/\/ Integer LSTM prepare function for 8x8->8.\n      \/\/ This code path needs 12 intermediate tensors per Op.\n      PopulateQuantizedLstmParams8x8_8(context, node,\n                                       &op_data->integer_lstm_param);\n\n      \/\/ Allocate scratch buffer. Need 6 16bit buffer with size n_batch * n_cell\n      \/\/ and 2 8bit buffer with size n_batch * n_cell.\n      \/\/\n      \/\/ Handle cifg case as well, which might save one buffer.\n      for (int scratch_index = 0; scratch_index < 8; ++scratch_index) {\n        node->temporaries->data[scratch_index] =\n            op_data->scratch_tensor_index + scratch_index;\n        TfLiteTensor* scratch_tensor =\n            GetTemporary(context, node, scratch_index);\n        if (scratch_index == 0 || scratch_index == 1) {\n          scratch_tensor->type = kTfLiteInt8;\n        } else {\n          scratch_tensor->type = kTfLiteInt16;\n        }\n        scratch_tensor->allocation_type = kTfLiteArenaRw;\n        const int scratch_dimension[2] = {n_batch, n_cell};\n        if (!TfLiteIntArrayEqualsArray(scratch_tensor->dims, 2,\n                                       scratch_dimension)) {\n          TfLiteIntArray* scratch_buffer_size = TfLiteIntArrayCreate(2);\n          scratch_buffer_size->data[0] = n_batch;\n          scratch_buffer_size->data[1] = n_cell;\n          TF_LITE_ENSURE_OK(context,\n                            context->ResizeTensor(context, scratch_tensor,\n                                                  scratch_buffer_size));\n        }\n      }\n    }\n  }\n  return kTfLiteOk;\n}","target":1,"code_token_length":5747,"total_token_length":5983,"max_tokens_setting":6144}
+{"idx":329204,"func":"static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)\n\n{\n\n    ARMCPU *cpu = s->cpu;\n\n    uint32_t val;\n\n\n\n    switch (offset) {\n\n    case 4: \/* Interrupt Control Type.  *\/\n\n        return ((s->num_irq - NVIC_FIRST_IRQ) \/ 32) - 1;\n\n    case 0x380 ... 0x3bf: \/* NVIC_ITNS *\/\n\n    {\n\n        int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ;\n\n        int i;\n\n\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        val = 0;\n\n        for (i = 0; i < 32 && startvec + i < s->num_irq; i++) {\n\n            if (s->itns[startvec + i]) {\n\n                val |= (1 << i);\n\n            }\n\n        }\n\n        return val;\n\n    }\n\n    case 0xd00: \/* CPUID Base.  *\/\n\n        return cpu->midr;\n\n    case 0xd04: \/* Interrupt Control State (ICSR) *\/\n\n        \/* VECTACTIVE *\/\n\n        val = cpu->env.v7m.exception;\n\n        \/* VECTPENDING *\/\n\n        val |= (s->vectpending & 0xff) << 12;\n\n        \/* ISRPENDING - set if any external IRQ is pending *\/\n\n        if (nvic_isrpending(s)) {\n\n            val |= (1 << 22);\n\n        }\n\n        \/* RETTOBASE - set if only one handler is active *\/\n\n        if (nvic_rettobase(s)) {\n\n            val |= (1 << 11);\n\n        }\n\n        if (attrs.secure) {\n\n            \/* PENDSTSET *\/\n\n            if (s->sec_vectors[ARMV7M_EXCP_SYSTICK].pending) {\n\n                val |= (1 << 26);\n\n            }\n\n            \/* PENDSVSET *\/\n\n            if (s->sec_vectors[ARMV7M_EXCP_PENDSV].pending) {\n\n                val |= (1 << 28);\n\n            }\n\n        } else {\n\n            \/* PENDSTSET *\/\n\n            if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {\n\n                val |= (1 << 26);\n\n            }\n\n            \/* PENDSVSET *\/\n\n            if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {\n\n                val |= (1 << 28);\n\n            }\n\n        }\n\n        \/* NMIPENDSET *\/\n\n        if ((cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) &&\n\n            s->vectors[ARMV7M_EXCP_NMI].pending) {\n\n            val |= (1 << 31);\n\n        }\n\n        \/* ISRPREEMPT: RES0 when halting debug not implemented *\/\n\n        \/* STTNS: RES0 for the Main Extension *\/\n\n        return val;\n\n    case 0xd08: \/* Vector Table Offset.  *\/\n\n        return cpu->env.v7m.vecbase[attrs.secure];\n\n    case 0xd0c: \/* Application Interrupt\/Reset Control (AIRCR) *\/\n\n        val = 0xfa050000 | (s->prigroup[attrs.secure] << 8);\n\n        if (attrs.secure) {\n\n            \/* s->aircr stores PRIS, BFHFNMINS, SYSRESETREQS *\/\n\n            val |= cpu->env.v7m.aircr;\n\n        } else {\n\n            if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n                \/* BFHFNMINS is R\/O from NS; other bits are RAZ\/WI. If\n\n                 * security isn't supported then BFHFNMINS is RAO (and\n\n                 * the bit in env.v7m.aircr is always set).\n\n                 *\/\n\n                val |= cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK;\n\n            }\n\n        }\n\n        return val;\n\n    case 0xd10: \/* System Control.  *\/\n\n        \/* TODO: Implement SLEEPONEXIT.  *\/\n\n        return 0;\n\n    case 0xd14: \/* Configuration Control.  *\/\n\n        \/* The BFHFNMIGN bit is the only non-banked bit; we\n\n         * keep it in the non-secure copy of the register.\n\n         *\/\n\n        val = cpu->env.v7m.ccr[attrs.secure];\n\n        val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;\n\n        return val;\n\n    case 0xd24: \/* System Handler Control and State (SHCSR) *\/\n\n        val = 0;\n\n        if (attrs.secure) {\n\n            if (s->sec_vectors[ARMV7M_EXCP_MEM].active) {\n\n                val |= (1 << 0);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_HARD].active) {\n\n                val |= (1 << 2);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_USAGE].active) {\n\n                val |= (1 << 3);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_SVC].active) {\n\n                val |= (1 << 7);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_PENDSV].active) {\n\n                val |= (1 << 10);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_SYSTICK].active) {\n\n                val |= (1 << 11);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_USAGE].pending) {\n\n                val |= (1 << 12);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_MEM].pending) {\n\n                val |= (1 << 13);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_SVC].pending) {\n\n                val |= (1 << 15);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_MEM].enabled) {\n\n                val |= (1 << 16);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_USAGE].enabled) {\n\n                val |= (1 << 18);\n\n            }\n\n            if (s->sec_vectors[ARMV7M_EXCP_HARD].pending) {\n\n                val |= (1 << 21);\n\n            }\n\n            \/* SecureFault is not banked but is always RAZ\/WI to NS *\/\n\n            if (s->vectors[ARMV7M_EXCP_SECURE].active) {\n\n                val |= (1 << 4);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_SECURE].enabled) {\n\n                val |= (1 << 19);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_SECURE].pending) {\n\n                val |= (1 << 20);\n\n            }\n\n        } else {\n\n            if (s->vectors[ARMV7M_EXCP_MEM].active) {\n\n                val |= (1 << 0);\n\n            }\n\n            if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n                \/* HARDFAULTACT, HARDFAULTPENDED not present in v7M *\/\n\n                if (s->vectors[ARMV7M_EXCP_HARD].active) {\n\n                    val |= (1 << 2);\n\n                }\n\n                if (s->vectors[ARMV7M_EXCP_HARD].pending) {\n\n                    val |= (1 << 21);\n\n                }\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_USAGE].active) {\n\n                val |= (1 << 3);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_SVC].active) {\n\n                val |= (1 << 7);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_PENDSV].active) {\n\n                val |= (1 << 10);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {\n\n                val |= (1 << 11);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_USAGE].pending) {\n\n                val |= (1 << 12);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_MEM].pending) {\n\n                val |= (1 << 13);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_SVC].pending) {\n\n                val |= (1 << 15);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_MEM].enabled) {\n\n                val |= (1 << 16);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {\n\n                val |= (1 << 18);\n\n            }\n\n        }\n\n        if (attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {\n\n            if (s->vectors[ARMV7M_EXCP_BUS].active) {\n\n                val |= (1 << 1);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_BUS].pending) {\n\n                val |= (1 << 14);\n\n            }\n\n            if (s->vectors[ARMV7M_EXCP_BUS].enabled) {\n\n                val |= (1 << 17);\n\n            }\n\n            if (arm_feature(&cpu->env, ARM_FEATURE_V8) &&\n\n                s->vectors[ARMV7M_EXCP_NMI].active) {\n\n                \/* NMIACT is not present in v7M *\/\n\n                val |= (1 << 5);\n\n            }\n\n        }\n\n\n\n        \/* TODO: this is RAZ\/WI from NS if DEMCR.SDME is set *\/\n\n        if (s->vectors[ARMV7M_EXCP_DEBUG].active) {\n\n            val |= (1 << 8);\n\n        }\n\n        return val;\n\n    case 0xd28: \/* Configurable Fault Status.  *\/\n\n        \/* The BFSR bits [15:8] are shared between security states\n\n         * and we store them in the NS copy\n\n         *\/\n\n        val = cpu->env.v7m.cfsr[attrs.secure];\n\n        val |= cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;\n\n        return val;\n\n    case 0xd2c: \/* Hard Fault Status.  *\/\n\n        return cpu->env.v7m.hfsr;\n\n    case 0xd30: \/* Debug Fault Status.  *\/\n\n        return cpu->env.v7m.dfsr;\n\n    case 0xd34: \/* MMFAR MemManage Fault Address *\/\n\n        return cpu->env.v7m.mmfar[attrs.secure];\n\n    case 0xd38: \/* Bus Fault Address.  *\/\n\n        return cpu->env.v7m.bfar;\n\n    case 0xd3c: \/* Aux Fault Status.  *\/\n\n        \/* TODO: Implement fault status registers.  *\/\n\n        qemu_log_mask(LOG_UNIMP,\n\n                      \"Aux Fault status registers unimplemented\\n\");\n\n        return 0;\n\n    case 0xd40: \/* PFR0.  *\/\n\n        return 0x00000030;\n\n    case 0xd44: \/* PRF1.  *\/\n\n        return 0x00000200;\n\n    case 0xd48: \/* DFR0.  *\/\n\n        return 0x00100000;\n\n    case 0xd4c: \/* AFR0.  *\/\n\n        return 0x00000000;\n\n    case 0xd50: \/* MMFR0.  *\/\n\n        return 0x00000030;\n\n    case 0xd54: \/* MMFR1.  *\/\n\n        return 0x00000000;\n\n    case 0xd58: \/* MMFR2.  *\/\n\n        return 0x00000000;\n\n    case 0xd5c: \/* MMFR3.  *\/\n\n        return 0x00000000;\n\n    case 0xd60: \/* ISAR0.  *\/\n\n        return 0x01141110;\n\n    case 0xd64: \/* ISAR1.  *\/\n\n        return 0x02111000;\n\n    case 0xd68: \/* ISAR2.  *\/\n\n        return 0x21112231;\n\n    case 0xd6c: \/* ISAR3.  *\/\n\n        return 0x01111110;\n\n    case 0xd70: \/* ISAR4.  *\/\n\n        return 0x01310102;\n\n    \/* TODO: Implement debug registers.  *\/\n\n    case 0xd90: \/* MPU_TYPE *\/\n\n        \/* Unified MPU; if the MPU is not present this value is zero *\/\n\n        return cpu->pmsav7_dregion << 8;\n\n        break;\n\n    case 0xd94: \/* MPU_CTRL *\/\n\n        return cpu->env.v7m.mpu_ctrl[attrs.secure];\n\n    case 0xd98: \/* MPU_RNR *\/\n\n        return cpu->env.pmsav7.rnr[attrs.secure];\n\n    case 0xd9c: \/* MPU_RBAR *\/\n\n    case 0xda4: \/* MPU_RBAR_A1 *\/\n\n    case 0xdac: \/* MPU_RBAR_A2 *\/\n\n    case 0xdb4: \/* MPU_RBAR_A3 *\/\n\n    {\n\n        int region = cpu->env.pmsav7.rnr[attrs.secure];\n\n\n\n        if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            \/* PMSAv8M handling of the aliases is different from v7M:\n\n             * aliases A1, A2, A3 override the low two bits of the region\n\n             * number in MPU_RNR, and there is no 'region' field in the\n\n             * RBAR register.\n\n             *\/\n\n            int aliasno = (offset - 0xd9c) \/ 8; \/* 0..3 *\/\n\n            if (aliasno) {\n\n                region = deposit32(region, 0, 2, aliasno);\n\n            }\n\n            if (region >= cpu->pmsav7_dregion) {\n\n                return 0;\n\n            }\n\n            return cpu->env.pmsav8.rbar[attrs.secure][region];\n\n        }\n\n\n\n        if (region >= cpu->pmsav7_dregion) {\n\n            return 0;\n\n        }\n\n        return (cpu->env.pmsav7.drbar[region] & 0x1f) | (region & 0xf);\n\n    }\n\n    case 0xda0: \/* MPU_RASR (v7M), MPU_RLAR (v8M) *\/\n\n    case 0xda8: \/* MPU_RASR_A1 (v7M), MPU_RLAR_A1 (v8M) *\/\n\n    case 0xdb0: \/* MPU_RASR_A2 (v7M), MPU_RLAR_A2 (v8M) *\/\n\n    case 0xdb8: \/* MPU_RASR_A3 (v7M), MPU_RLAR_A3 (v8M) *\/\n\n    {\n\n        int region = cpu->env.pmsav7.rnr[attrs.secure];\n\n\n\n        if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            \/* PMSAv8M handling of the aliases is different from v7M:\n\n             * aliases A1, A2, A3 override the low two bits of the region\n\n             * number in MPU_RNR.\n\n             *\/\n\n            int aliasno = (offset - 0xda0) \/ 8; \/* 0..3 *\/\n\n            if (aliasno) {\n\n                region = deposit32(region, 0, 2, aliasno);\n\n            }\n\n            if (region >= cpu->pmsav7_dregion) {\n\n                return 0;\n\n            }\n\n            return cpu->env.pmsav8.rlar[attrs.secure][region];\n\n        }\n\n\n\n        if (region >= cpu->pmsav7_dregion) {\n\n            return 0;\n\n        }\n\n        return ((cpu->env.pmsav7.dracr[region] & 0xffff) << 16) |\n\n            (cpu->env.pmsav7.drsr[region] & 0xffff);\n\n    }\n\n    case 0xdc0: \/* MPU_MAIR0 *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        return cpu->env.pmsav8.mair0[attrs.secure];\n\n    case 0xdc4: \/* MPU_MAIR1 *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        return cpu->env.pmsav8.mair1[attrs.secure];\n\n    case 0xdd0: \/* SAU_CTRL *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        return cpu->env.sau.ctrl;\n\n    case 0xdd4: \/* SAU_TYPE *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        return cpu->sau_sregion;\n\n    case 0xdd8: \/* SAU_RNR *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        return cpu->env.sau.rnr;\n\n    case 0xddc: \/* SAU_RBAR *\/\n\n    {\n\n        int region = cpu->env.sau.rnr;\n\n\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        if (region >= cpu->sau_sregion) {\n\n            return 0;\n\n        }\n\n        return cpu->env.sau.rbar[region];\n\n    }\n\n    case 0xde0: \/* SAU_RLAR *\/\n\n    {\n\n        int region = cpu->env.sau.rnr;\n\n\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        if (region >= cpu->sau_sregion) {\n\n            return 0;\n\n        }\n\n        return cpu->env.sau.rlar[region];\n\n    }\n\n    case 0xde4: \/* SFSR *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        return cpu->env.v7m.sfsr;\n\n    case 0xde8: \/* SFAR *\/\n\n        if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {\n\n            goto bad_offset;\n\n        }\n\n        if (!attrs.secure) {\n\n            return 0;\n\n        }\n\n        return cpu->env.v7m.sfar;\n\n    default:\n\n    bad_offset:\n\n        qemu_log_mask(LOG_GUEST_ERROR, \"NVIC: Bad read offset 0x%x\\n\", offset);\n\n        return 0;\n\n    }\n\n}\n","target":1,"code_token_length":4254,"total_token_length":4490,"max_tokens_setting":6144}
+{"idx":306253,"func":"irc_protocol_recv_command (struct t_irc_server *server,\n                           const char *irc_message,\n                           const char *msg_command,\n                           const char *msg_channel)\n{\n    int i, cmd_found, return_code, argc, decode_color, keep_trailing_spaces;\n    int message_ignored, flags;\n    char *message_colors_decoded, *pos_space, *tags;\n    struct t_irc_channel *ptr_channel;\n    t_irc_recv_func *cmd_recv_func;\n    const char *cmd_name, *ptr_msg_after_tags;\n    time_t date;\n    const char *nick1, *address1, *host1;\n    char *nick, *address, *address_color, *host, *host_no_color, *host_color;\n    char **argv, **argv_eol;\n    struct t_hashtable *hash_tags;\n    struct t_irc_protocol_msg irc_protocol_messages[] =\n        { { \"account\", \/* account (cap account-notify) *\/ 1, 0, &irc_protocol_cb_account },\n          { \"authenticate\", \/* authenticate *\/ 1, 0, &irc_protocol_cb_authenticate },\n          { \"away\", \/* away (cap away-notify) *\/ 1, 0, &irc_protocol_cb_away },\n          { \"cap\", \/* client capability *\/ 1, 0, &irc_protocol_cb_cap },\n          { \"chghost\", \/* user\/host change (cap chghost) *\/ 1, 0, &irc_protocol_cb_chghost },\n          { \"error\", \/* error received from IRC server *\/ 1, 0, &irc_protocol_cb_error },\n          { \"invite\", \/* invite a nick on a channel *\/ 1, 0, &irc_protocol_cb_invite },\n          { \"join\", \/* join a channel *\/ 1, 0, &irc_protocol_cb_join },\n          { \"kick\", \/* forcibly remove a user from a channel *\/ 1, 1, &irc_protocol_cb_kick },\n          { \"kill\", \/* close client-server connection *\/ 1, 1, &irc_protocol_cb_kill },\n          { \"mode\", \/* change channel or user mode *\/ 1, 0, &irc_protocol_cb_mode },\n          { \"nick\", \/* change current nickname *\/ 1, 0, &irc_protocol_cb_nick },\n          { \"notice\", \/* send notice message to user *\/ 1, 1, &irc_protocol_cb_notice },\n          { \"part\", \/* leave a channel *\/ 1, 1, &irc_protocol_cb_part },\n          { \"ping\", \/* ping server *\/ 1, 0, &irc_protocol_cb_ping },\n          { \"pong\", \/* answer to a ping message *\/ 1, 0, &irc_protocol_cb_pong },\n          { \"privmsg\", \/* message received *\/ 1, 1, &irc_protocol_cb_privmsg },\n          { \"quit\", \/* close all connections and quit *\/ 1, 1, &irc_protocol_cb_quit },\n          { \"topic\", \/* get\/set channel topic *\/ 0, 1, &irc_protocol_cb_topic },\n          { \"wallops\", \/* send a message to all currently connected users who have \"\n                          \"set the 'w' user mode \"\n                          \"for themselves *\/ 1, 1, &irc_protocol_cb_wallops },\n          { \"001\", \/* a server message *\/ 1, 0, &irc_protocol_cb_001 },\n          { \"005\", \/* a server message *\/ 1, 0, &irc_protocol_cb_005 },\n          { \"008\", \/* server notice mask *\/ 1, 0, &irc_protocol_cb_008 },\n          { \"221\", \/* user mode string *\/ 1, 0, &irc_protocol_cb_221 },\n          { \"223\", \/* whois (charset is) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"264\", \/* whois (is using encrypted connection) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"275\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"276\", \/* whois (has client certificate fingerprint) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"301\", \/* away message *\/ 1, 1, &irc_protocol_cb_301 },\n          { \"303\", \/* ison *\/ 1, 0, &irc_protocol_cb_303 },\n          { \"305\", \/* unaway *\/ 1, 0, &irc_protocol_cb_305 },\n          { \"306\", \/* now away *\/ 1, 0, &irc_protocol_cb_306 },\n          { \"307\", \/* whois (registered nick) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"310\", \/* whois (help mode) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"311\", \/* whois (user) *\/ 1, 0, &irc_protocol_cb_311 },\n          { \"312\", \/* whois (server) *\/ 1, 0, &irc_protocol_cb_312 },\n          { \"313\", \/* whois (operator) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"314\", \/* whowas *\/ 1, 0, &irc_protocol_cb_314 },\n          { \"315\", \/* end of \/who list *\/ 1, 0, &irc_protocol_cb_315 },\n          { \"317\", \/* whois (idle) *\/ 1, 0, &irc_protocol_cb_317 },\n          { \"318\", \/* whois (end) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"319\", \/* whois (channels) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"320\", \/* whois (identified user) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"321\", \/* \/list start *\/ 1, 0, &irc_protocol_cb_321 },\n          { \"322\", \/* channel (for \/list) *\/ 1, 0, &irc_protocol_cb_322 },\n          { \"323\", \/* end of \/list *\/ 1, 0, &irc_protocol_cb_323 },\n          { \"324\", \/* channel mode *\/ 1, 0, &irc_protocol_cb_324 },\n          { \"326\", \/* whois (has oper privs) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"327\", \/* whois (host) *\/ 1, 0, &irc_protocol_cb_327 },\n          { \"328\", \/* channel url *\/ 1, 0, &irc_protocol_cb_328 },\n          { \"329\", \/* channel creation date *\/ 1, 0, &irc_protocol_cb_329 },\n          { \"330\", \/* is logged in as *\/ 1, 0, &irc_protocol_cb_330_343 },\n          { \"331\", \/* no topic for channel *\/ 1, 0, &irc_protocol_cb_331 },\n          { \"332\", \/* topic of channel *\/ 0, 1, &irc_protocol_cb_332 },\n          { \"333\", \/* infos about topic (nick and date changed) *\/ 1, 0, &irc_protocol_cb_333 },\n          { \"335\", \/* is a bot on *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"338\", \/* whois (host) *\/ 1, 0, &irc_protocol_cb_338 },\n          { \"341\", \/* inviting *\/ 1, 0, &irc_protocol_cb_341 },\n          { \"343\", \/* is opered as *\/ 1, 0, &irc_protocol_cb_330_343 },\n          { \"344\", \/* channel reop *\/ 1, 0, &irc_protocol_cb_344 },\n          { \"345\", \/* end of channel reop list *\/ 1, 0, &irc_protocol_cb_345 },\n          { \"346\", \/* invite list *\/ 1, 0, &irc_protocol_cb_346 },\n          { \"347\", \/* end of invite list *\/ 1, 0, &irc_protocol_cb_347 },\n          { \"348\", \/* channel exception list *\/ 1, 0, &irc_protocol_cb_348 },\n          { \"349\", \/* end of channel exception list *\/ 1, 0, &irc_protocol_cb_349 },\n          { \"351\", \/* server version *\/ 1, 0, &irc_protocol_cb_351 },\n          { \"352\", \/* who *\/ 1, 0, &irc_protocol_cb_352 },\n          { \"353\", \/* list of nicks on channel *\/ 1, 0, &irc_protocol_cb_353 },\n          { \"354\", \/* whox *\/ 1, 0, &irc_protocol_cb_354 },\n          { \"366\", \/* end of \/names list *\/ 1, 0, &irc_protocol_cb_366 },\n          { \"367\", \/* banlist *\/ 1, 0, &irc_protocol_cb_367 },\n          { \"368\", \/* end of banlist *\/ 1, 0, &irc_protocol_cb_368 },\n          { \"369\", \/* whowas (end) *\/ 1, 0, &irc_protocol_cb_whowas_nick_msg },\n          { \"378\", \/* whois (connecting from) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"379\", \/* whois (using modes) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"401\", \/* no such nick\/channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"402\", \/* no such server *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"403\", \/* no such channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"404\", \/* cannot send to channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"405\", \/* too many channels *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"406\", \/* was no such nick *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"407\", \/* was no such nick *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"409\", \/* no origin *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"410\", \/* no services *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"411\", \/* no recipient *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"412\", \/* no text to send *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"413\", \/* no toplevel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"414\", \/* wilcard in toplevel domain *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"421\", \/* unknown command *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"422\", \/* MOTD is missing *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"423\", \/* no administrative info *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"424\", \/* file error *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"431\", \/* no nickname given *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"432\", \/* erroneous nickname *\/ 1, 0, &irc_protocol_cb_432 },\n          { \"433\", \/* nickname already in use *\/ 1, 0, &irc_protocol_cb_433 },\n          { \"436\", \/* nickname collision *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"437\", \/* nick\/channel unavailable *\/ 1, 0, &irc_protocol_cb_437 },\n          { \"438\", \/* not authorized to change nickname *\/ 1, 0, &irc_protocol_cb_438 },\n          { \"441\", \/* user not in channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"442\", \/* not on channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"443\", \/* user already on channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"444\", \/* user not logged in *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"445\", \/* summon has been disabled *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"446\", \/* users has been disabled *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"451\", \/* you are not registered *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"461\", \/* not enough parameters *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"462\", \/* you may not register *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"463\", \/* your host isn't among the privileged *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"464\", \/* password incorrect *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"465\", \/* you are banned from this server *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"467\", \/* channel key already set *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"470\", \/* forwarding to another channel *\/ 1, 0, &irc_protocol_cb_470 },\n          { \"471\", \/* channel is already full *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"472\", \/* unknown mode char to me *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"473\", \/* cannot join channel (invite only) *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"474\", \/* cannot join channel (banned from channel) *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"475\", \/* cannot join channel (bad channel key) *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"476\", \/* bad channel mask *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"477\", \/* channel doesn't support modes *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"481\", \/* you're not an IRC operator *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"482\", \/* you're not channel operator *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"483\", \/* you can't kill a server! *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"484\", \/* your connection is restricted! *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"485\", \/* user is immune from kick\/deop *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"487\", \/* network split *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"491\", \/* no O-lines for your host *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"501\", \/* unknown mode flag *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"502\", \/* can't change mode for other users *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"671\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"728\", \/* quietlist *\/ 1, 0, &irc_protocol_cb_728 },\n          { \"729\", \/* end of quietlist *\/ 1, 0, &irc_protocol_cb_729 },\n          { \"730\", \/* monitored nicks online *\/ 1, 0, &irc_protocol_cb_730 },\n          { \"731\", \/* monitored nicks offline *\/ 1, 0, &irc_protocol_cb_731 },\n          { \"732\", \/* list of monitored nicks *\/ 1, 0, &irc_protocol_cb_732 },\n          { \"733\", \/* end of monitor list *\/ 1, 0, &irc_protocol_cb_733 },\n          { \"734\", \/* monitor list is full *\/ 1, 0, &irc_protocol_cb_734 },\n          { \"900\", \/* logged in as (SASL) *\/ 1, 0, &irc_protocol_cb_900 },\n          { \"901\", \/* you are now logged in *\/ 1, 0, &irc_protocol_cb_901 },\n          { \"902\", \/* SASL authentication failed (account locked\/held) *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"903\", \/* SASL authentication successful *\/ 1, 0, &irc_protocol_cb_sasl_end_ok },\n          { \"904\", \/* SASL authentication failed *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"905\", \/* SASL message too long *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"906\", \/* SASL authentication aborted *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"907\", \/* You have already completed SASL authentication *\/ 1, 0, &irc_protocol_cb_sasl_end_ok },\n          { \"936\", \/* censored word *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"973\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_server_mode_reason },\n          { \"974\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_server_mode_reason },\n          { \"975\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_server_mode_reason },\n          { NULL, 0, 0, NULL }\n        };\n\n    if (!msg_command)\n        return;\n\n    message_colors_decoded = NULL;\n    argv = NULL;\n    argv_eol = NULL;\n    hash_tags = NULL;\n    date = 0;\n\n    ptr_msg_after_tags = irc_message;\n\n    \/* get tags as hashtable *\/\n    if (irc_message && (irc_message[0] == '@'))\n    {\n        pos_space = strchr (irc_message, ' ');\n        if (pos_space)\n        {\n            tags = weechat_strndup (irc_message + 1,\n                                    pos_space - (irc_message + 1));\n            if (tags)\n            {\n                hash_tags = irc_protocol_get_message_tags (tags);\n                if (hash_tags)\n                {\n                    date = irc_protocol_parse_time (\n                        weechat_hashtable_get (hash_tags, \"time\"));\n                }\n                free (tags);\n            }\n            ptr_msg_after_tags = pos_space;\n            while (ptr_msg_after_tags[0] == ' ')\n            {\n                ptr_msg_after_tags++;\n            }\n        }\n        else\n            ptr_msg_after_tags = NULL;\n    }\n\n    \/* get nick\/host\/address from IRC message *\/\n    nick1 = NULL;\n    address1 = NULL;\n    host1 = NULL;\n    if (ptr_msg_after_tags && (ptr_msg_after_tags[0] == ':'))\n    {\n        nick1 = irc_message_get_nick_from_host (ptr_msg_after_tags);\n        address1 = irc_message_get_address_from_host (ptr_msg_after_tags);\n        host1 = ptr_msg_after_tags + 1;\n    }\n    nick = (nick1) ? strdup (nick1) : NULL;\n    address = (address1) ? strdup (address1) : NULL;\n    address_color = (address) ?\n        irc_color_decode (\n            address,\n            weechat_config_boolean (irc_config_network_colors_receive)) :\n        NULL;\n    host = (host1) ? strdup (host1) : NULL;\n    if (host)\n    {\n        pos_space = strchr (host, ' ');\n        if (pos_space)\n            pos_space[0] = '\\0';\n    }\n    host_no_color = (host) ? irc_color_decode (host, 0) : NULL;\n    host_color = (host) ?\n        irc_color_decode (\n            host,\n            weechat_config_boolean (irc_config_network_colors_receive)) :\n        NULL;\n\n    \/* check if message is ignored or not *\/\n    ptr_channel = NULL;\n    if (msg_channel)\n        ptr_channel = irc_channel_search (server, msg_channel);\n    message_ignored = irc_ignore_check (\n        server,\n        (ptr_channel) ? ptr_channel->name : msg_channel,\n        nick, host_no_color);\n\n    \/* send signal with received command, even if command is ignored *\/\n    irc_server_send_signal (server, \"irc_raw_in\", msg_command,\n                            irc_message, NULL);\n\n    \/* send signal with received command, only if message is not ignored *\/\n    if (!message_ignored)\n    {\n        irc_server_send_signal (server, \"irc_in\", msg_command,\n                                irc_message, NULL);\n    }\n\n    \/* look for IRC command *\/\n    cmd_found = -1;\n    for (i = 0; irc_protocol_messages[i].name; i++)\n    {\n        if (weechat_strcasecmp (irc_protocol_messages[i].name,\n                                msg_command) == 0)\n        {\n            cmd_found = i;\n            break;\n        }\n    }\n\n    \/* command not found *\/\n    if (cmd_found < 0)\n    {\n        \/* for numeric commands, we use default recv function *\/\n        if (irc_protocol_is_numeric_command (msg_command))\n        {\n            cmd_name = msg_command;\n            decode_color = 1;\n            keep_trailing_spaces = 0;\n            cmd_recv_func = irc_protocol_cb_numeric;\n        }\n        else\n        {\n            weechat_printf (server->buffer,\n                            _(\"%s%s: command \\\"%s\\\" not found:\"),\n                            weechat_prefix (\"error\"), IRC_PLUGIN_NAME,\n                            msg_command);\n            weechat_printf (server->buffer,\n                            \"%s%s\",\n                            weechat_prefix (\"error\"), irc_message);\n            goto end;\n        }\n    }\n    else\n    {\n        cmd_name = irc_protocol_messages[cmd_found].name;\n        decode_color = irc_protocol_messages[cmd_found].decode_color;\n        keep_trailing_spaces = irc_protocol_messages[cmd_found].keep_trailing_spaces;\n        cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;\n    }\n\n    if (cmd_recv_func != NULL)\n    {\n        if (ptr_msg_after_tags)\n        {\n            if (decode_color)\n            {\n                message_colors_decoded = irc_color_decode (\n                    ptr_msg_after_tags,\n                    weechat_config_boolean (irc_config_network_colors_receive));\n            }\n            else\n            {\n                message_colors_decoded = strdup (ptr_msg_after_tags);\n            }\n        }\n        else\n            message_colors_decoded = NULL;\n        argv = weechat_string_split (message_colors_decoded, \" \", NULL,\n                                     WEECHAT_STRING_SPLIT_STRIP_LEFT\n                                     | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                                     | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                                     0, &argc);\n        flags = WEECHAT_STRING_SPLIT_STRIP_LEFT\n            | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS\n            | WEECHAT_STRING_SPLIT_KEEP_EOL;\n        if (keep_trailing_spaces)\n            flags |= WEECHAT_STRING_SPLIT_STRIP_RIGHT;\n        argv_eol = weechat_string_split (message_colors_decoded, \" \", NULL,\n                                         flags, 0, NULL);\n\n        return_code = (int) (cmd_recv_func) (server,\n                                             date, nick, address_color,\n                                             host_color, cmd_name,\n                                             message_ignored, argc, argv,\n                                             argv_eol);\n\n        if (return_code == WEECHAT_RC_ERROR)\n        {\n            weechat_printf (server->buffer,\n                            _(\"%s%s: failed to parse command \\\"%s\\\" (please \"\n                              \"report to developers):\"),\n                            weechat_prefix (\"error\"), IRC_PLUGIN_NAME,\n                            msg_command);\n            weechat_printf (server->buffer,\n                            \"%s%s\",\n                            weechat_prefix (\"error\"), irc_message);\n        }\n\n        \/* send signal with received command (if message is not ignored) *\/\n        if (!message_ignored)\n        {\n            irc_server_send_signal (server, \"irc_in2\", msg_command,\n                                    irc_message, NULL);\n        }\n    }\n\n    \/* send signal with received command, even if command is ignored *\/\n    irc_server_send_signal (server, \"irc_raw_in2\", msg_command,\n                            irc_message, NULL);\n\nend:\n    if (nick)\n        free (nick);\n    if (address)\n        free (address);\n    if (address_color)\n        free (address_color);\n    if (host)\n        free (host);\n    if (host_no_color)\n        free (host_no_color);\n    if (host_color)\n        free (host_color);\n    if (message_colors_decoded)\n        free (message_colors_decoded);\n    if (argv)\n        weechat_string_free_split (argv);\n    if (argv_eol)\n        weechat_string_free_split (argv_eol);\n    if (hash_tags)\n        weechat_hashtable_free (hash_tags);\n}","target":0,"code_token_length":5780,"total_token_length":6016,"max_tokens_setting":6144}
+{"idx":81299,"func":"static uint get_table_structure(char *table, char *db, char *table_type,\n                                char *ignore_flag)\n{\n  my_bool    init=0, write_data, complete_insert;\n  my_ulonglong num_fields;\n  char       *result_table, *opt_quoted_table;\n  const char *insert_option;\n  char\t     name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];\n  char       table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];\n  const char *show_fields_stmt= \"SELECT `COLUMN_NAME` AS `Field`, \"\n                                \"`COLUMN_TYPE` AS `Type`, \"\n                                \"`IS_NULLABLE` AS `Null`, \"\n                                \"`COLUMN_KEY` AS `Key`, \"\n                                \"`COLUMN_DEFAULT` AS `Default`, \"\n                                \"`EXTRA` AS `Extra`, \"\n                                \"`COLUMN_COMMENT` AS `Comment` \"\n                                \"FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE \"\n                                \"TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'\";\n  FILE       *sql_file= md_result_file;\n  int        len;\n  my_bool    is_log_table;\n  MYSQL_RES  *result;\n  MYSQL_ROW  row;\n  DBUG_ENTER(\"get_table_structure\");\n  DBUG_PRINT(\"enter\", (\"db: %s  table: %s\", db, table));\n\n  *ignore_flag= check_if_ignore_table(table, table_type);\n\n  complete_insert= 0;\n  if ((write_data= !(*ignore_flag & IGNORE_DATA)))\n  {\n    complete_insert= opt_complete_insert;\n    if (!insert_pat_inited)\n    {\n      insert_pat_inited= 1;\n      init_dynamic_string_checked(&insert_pat, \"\", 1024, 1024);\n    }\n    else\n      dynstr_set_checked(&insert_pat, \"\");\n  }\n\n  insert_option= (opt_ignore ? \" IGNORE \" : \"\");\n\n  verbose_msg(\"-- Retrieving table structure for table %s...\\n\", table);\n\n  len= my_snprintf(query_buff, sizeof(query_buff),\n                   \"SET SQL_QUOTE_SHOW_CREATE=%d\",\n                   (opt_quoted || opt_keywords));\n  if (!create_options)\n    my_stpcpy(query_buff+len,\n           \"\/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') *\/\");\n\n  result_table=     quote_name(table, table_buff, 1);\n  opt_quoted_table= quote_name(table, table_buff2, 0);\n\n  if (opt_order_by_primary)\n    order_by= primary_key_fields(result_table);\n\n  if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff))\n  {\n    \/* using SHOW CREATE statement *\/\n    if (!opt_no_create_info)\n    {\n      \/* Make an sql-file, if path was given iow. option -T was given *\/\n      char buff[20+FN_REFLEN];\n      MYSQL_FIELD *field;\n\n      my_snprintf(buff, sizeof(buff), \"show create table %s\", result_table);\n\n      if (switch_character_set_results(mysql, \"binary\") ||\n          mysql_query_with_error_report(mysql, &result, buff) ||\n          switch_character_set_results(mysql, default_charset))\n        DBUG_RETURN(0);\n\n      if (path)\n      {\n        if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))\n          DBUG_RETURN(0);\n\n        write_header(sql_file, db);\n      }\n\n      if (strcmp (table_type, \"VIEW\") == 0)         \/* view *\/\n        print_comment(sql_file, 0,\n                      \"\\n--\\n-- Temporary table structure for view %s\\n--\\n\\n\",\n                      result_table);\n      else\n        print_comment(sql_file, 0,\n                      \"\\n--\\n-- Table structure for table %s\\n--\\n\\n\",\n                      result_table);\n\n      if (opt_drop)\n      {\n      \/*\n        Even if the \"table\" is a view, we do a DROP TABLE here.  The\n        view-specific code below fills in the DROP VIEW.\n        We will skip the DROP TABLE for general_log and slow_log, since\n        those stmts will fail, in case we apply dump by enabling logging.\n       *\/\n        if (!general_log_or_slow_log_tables(db, table))\n          fprintf(sql_file, \"DROP TABLE IF EXISTS %s;\\n\",\n                  opt_quoted_table);\n        check_io(sql_file);\n      }\n\n      field= mysql_fetch_field_direct(result, 0);\n      if (strcmp(field->name, \"View\") == 0)\n      {\n        char *scv_buff= NULL;\n        my_ulonglong n_cols;\n\n        verbose_msg(\"-- It's a view, create dummy table for view\\n\");\n\n        \/* save \"show create\" statement for later *\/\n        if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))\n          scv_buff= my_strdup(PSI_NOT_INSTRUMENTED,\n                              scv_buff, MYF(0));\n\n        mysql_free_result(result);\n\n        \/*\n          Create a table with the same name as the view and with columns of\n          the same name in order to satisfy views that depend on this view.\n          The table will be removed when the actual view is created.\n\n          The properties of each column, are not preserved in this temporary\n          table, because they are not necessary.\n\n          This will not be necessary once we can determine dependencies\n          between views and can simply dump them in the appropriate order.\n        *\/\n        my_snprintf(query_buff, sizeof(query_buff),\n                    \"SHOW FIELDS FROM %s\", result_table);\n        if (switch_character_set_results(mysql, \"binary\") ||\n            mysql_query_with_error_report(mysql, &result, query_buff) ||\n            switch_character_set_results(mysql, default_charset))\n        {\n          \/*\n            View references invalid or privileged table\/col\/fun (err 1356),\n            so we cannot create a stand-in table.  Be defensive and dump\n            a comment with the view's 'show create' statement. (Bug #17371)\n          *\/\n\n          if (mysql_errno(mysql) == ER_VIEW_INVALID)\n            fprintf(sql_file, \"\\n-- failed on view %s: %s\\n\\n\", result_table, scv_buff ? scv_buff : \"\");\n\n          my_free(scv_buff);\n\n          DBUG_RETURN(0);\n        }\n        else\n          my_free(scv_buff);\n\n        n_cols= mysql_num_rows(result);\n        if (0 != n_cols)\n        {\n\n          \/*\n            The actual formula is based on the column names and how the .FRM\n            files are stored and is too volatile to be repeated here.\n            Thus we simply warn the user if the columns exceed a limit we\n            know works most of the time.\n          *\/\n          if (n_cols >= 1000)\n            fprintf(stderr,\n                    \"-- Warning: Creating a stand-in table for view %s may\"\n                    \" fail when replaying the dump file produced because \"\n                    \"of the number of columns exceeding 1000. Exercise \"\n                    \"caution when replaying the produced dump file.\\n\", \n                    table);\n          if (opt_drop)\n          {\n            \/*\n              We have already dropped any table of the same name above, so\n              here we just drop the view.\n            *\/\n\n            fprintf(sql_file, \"\/*!50001 DROP VIEW IF EXISTS %s*\/;\\n\",\n                    opt_quoted_table);\n            check_io(sql_file);\n          }\n\n          fprintf(sql_file,\n                  \"SET @saved_cs_client     = @@character_set_client;\\n\"\n                  \"SET character_set_client = utf8;\\n\"\n                  \"\/*!50001 CREATE TABLE %s (\\n\",\n                  result_table);\n\n          \/*\n            Get first row, following loop will prepend comma - keeps from\n            having to know if the row being printed is last to determine if\n            there should be a _trailing_ comma.\n          *\/\n\n          row= mysql_fetch_row(result);\n\n          \/*\n            The actual column type doesn't matter anyway, since the table will\n            be dropped at run time.\n            We do tinyint to avoid hitting the row size limit.\n          *\/\n          fprintf(sql_file, \"  %s tinyint NOT NULL\",\n                  quote_name(row[0], name_buff, 0));\n\n          while((row= mysql_fetch_row(result)))\n          {\n            \/* col name, col type *\/\n            fprintf(sql_file, \",\\n  %s tinyint NOT NULL\",\n                    quote_name(row[0], name_buff, 0));\n          }\n\n          \/*\n            Stand-in tables are always MyISAM tables as the default\n            engine might have a column-limit that's lower than the\n            number of columns in the view, and MyISAM support is\n            guaranteed to be in the server anyway.\n          *\/\n          fprintf(sql_file,\n                  \"\\n) ENGINE=MyISAM *\/;\\n\"\n                  \"SET character_set_client = @saved_cs_client;\\n\");\n\n          check_io(sql_file);\n        }\n\n        mysql_free_result(result);\n\n        if (path)\n          my_fclose(sql_file, MYF(MY_WME));\n\n        seen_views= 1;\n        DBUG_RETURN(0);\n      }\n\n      row= mysql_fetch_row(result);\n\n      is_log_table= general_log_or_slow_log_tables(db, table);\n      if (is_log_table)\n        row[1]+= 13; \/* strlen(\"CREATE TABLE \")= 13 *\/\n      if (opt_compatible_mode & 3)\n      {\n        fprintf(sql_file,\n                is_log_table ? \"CREATE TABLE IF NOT EXISTS %s;\\n\" : \"%s;\\n\",\n                row[1]);\n      }\n      else\n      {\n        fprintf(sql_file,\n                \"\/*!40101 SET @saved_cs_client     = @@character_set_client *\/;\\n\"\n                \"\/*!40101 SET character_set_client = utf8 *\/;\\n\"\n                \"%s%s;\\n\"\n                \"\/*!40101 SET character_set_client = @saved_cs_client *\/;\\n\",\n                is_log_table ? \"CREATE TABLE IF NOT EXISTS \" : \"\",\n                row[1]);\n      }\n\n      check_io(sql_file);\n      mysql_free_result(result);\n    }\n    my_snprintf(query_buff, sizeof(query_buff), \"show fields from %s\",\n                result_table);\n    if (mysql_query_with_error_report(mysql, &result, query_buff))\n    {\n      if (path)\n        my_fclose(sql_file, MYF(MY_WME));\n      DBUG_RETURN(0);\n    }\n\n    \/*\n      If write_data is true, then we build up insert statements for\n      the table's data. Note: in subsequent lines of code, this test\n      will have to be performed each time we are appending to\n      insert_pat.\n    *\/\n    if (write_data)\n    {\n      if (opt_replace_into)\n        dynstr_append_checked(&insert_pat, \"REPLACE \");\n      else\n        dynstr_append_checked(&insert_pat, \"INSERT \");\n      dynstr_append_checked(&insert_pat, insert_option);\n      dynstr_append_checked(&insert_pat, \"INTO \");\n      dynstr_append_checked(&insert_pat, opt_quoted_table);\n      if (complete_insert)\n      {\n        dynstr_append_checked(&insert_pat, \" (\");\n      }\n      else\n      {\n        dynstr_append_checked(&insert_pat, \" VALUES \");\n        if (!extended_insert)\n          dynstr_append_checked(&insert_pat, \"(\");\n      }\n    }\n\n    while ((row= mysql_fetch_row(result)))\n    {\n      if (complete_insert)\n      {\n        if (init)\n        {\n          dynstr_append_checked(&insert_pat, \", \");\n        }\n        init=1;\n        dynstr_append_checked(&insert_pat,\n                      quote_name(row[SHOW_FIELDNAME], name_buff, 0));\n      }\n    }\n    num_fields= mysql_num_rows(result);\n    mysql_free_result(result);\n  }\n  else\n  {\n    verbose_msg(\"%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\\n\",\n                my_progname, mysql_error(mysql));\n\n    my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);\n\n    if (mysql_query_with_error_report(mysql, &result, query_buff))\n      DBUG_RETURN(0);\n\n    \/* Make an sql-file, if path was given iow. option -T was given *\/\n    if (!opt_no_create_info)\n    {\n      if (path)\n      {\n        if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))\n          DBUG_RETURN(0);\n        write_header(sql_file, db);\n      }\n\n      print_comment(sql_file, 0,\n                    \"\\n--\\n-- Table structure for table %s\\n--\\n\\n\",\n                    result_table);\n      if (opt_drop)\n        fprintf(sql_file, \"DROP TABLE IF EXISTS %s;\\n\", result_table);\n      if (!opt_xml)\n        fprintf(sql_file, \"CREATE TABLE %s (\\n\", result_table);\n      else\n        print_xml_tag(sql_file, \"\\t\", \"\\n\", \"table_structure\", \"name=\", table, \n                NullS);\n      check_io(sql_file);\n    }\n\n    if (write_data)\n    {\n      if (opt_replace_into)\n        dynstr_append_checked(&insert_pat, \"REPLACE \");\n      else\n        dynstr_append_checked(&insert_pat, \"INSERT \");\n      dynstr_append_checked(&insert_pat, insert_option);\n      dynstr_append_checked(&insert_pat, \"INTO \");\n      dynstr_append_checked(&insert_pat, result_table);\n      if (complete_insert)\n        dynstr_append_checked(&insert_pat, \" (\");\n      else\n      {\n        dynstr_append_checked(&insert_pat, \" VALUES \");\n        if (!extended_insert)\n          dynstr_append_checked(&insert_pat, \"(\");\n      }\n    }\n\n    while ((row= mysql_fetch_row(result)))\n    {\n      ulong *lengths= mysql_fetch_lengths(result);\n      if (init)\n      {\n        if (!opt_xml && !opt_no_create_info)\n        {\n          fputs(\",\\n\",sql_file);\n          check_io(sql_file);\n        }\n        if (complete_insert)\n          dynstr_append_checked(&insert_pat, \", \");\n      }\n      init=1;\n      if (complete_insert)\n        dynstr_append_checked(&insert_pat,\n                      quote_name(row[SHOW_FIELDNAME], name_buff, 0));\n      if (!opt_no_create_info)\n      {\n        if (opt_xml)\n        {\n          print_xml_row(sql_file, \"field\", result, &row, NullS);\n          continue;\n        }\n\n        if (opt_keywords)\n          fprintf(sql_file, \"  %s.%s %s\", result_table,\n                  quote_name(row[SHOW_FIELDNAME],name_buff, 0),\n                  row[SHOW_TYPE]);\n        else\n          fprintf(sql_file, \"  %s %s\", quote_name(row[SHOW_FIELDNAME],\n                                                  name_buff, 0),\n                  row[SHOW_TYPE]);\n        if (row[SHOW_DEFAULT])\n        {\n          fputs(\" DEFAULT \", sql_file);\n          unescape(sql_file, row[SHOW_DEFAULT], lengths[SHOW_DEFAULT]);\n        }\n        if (!row[SHOW_NULL][0])\n          fputs(\" NOT NULL\", sql_file);\n        if (row[SHOW_EXTRA][0])\n          fprintf(sql_file, \" %s\",row[SHOW_EXTRA]);\n        check_io(sql_file);\n      }\n    }\n    num_fields= mysql_num_rows(result);\n    mysql_free_result(result);\n    if (!opt_no_create_info)\n    {\n      \/* Make an sql-file, if path was given iow. option -T was given *\/\n      char buff[20+FN_REFLEN];\n      uint keynr,primary_key;\n      my_snprintf(buff, sizeof(buff), \"show keys from %s\", result_table);\n      if (mysql_query_with_error_report(mysql, &result, buff))\n      {\n        if (mysql_errno(mysql) == ER_WRONG_OBJECT)\n        {\n          \/* it is VIEW *\/\n          fputs(\"\\t\\t\\n\", sql_file);\n          goto continue_xml;\n        }\n        fprintf(stderr, \"%s: Can't get keys for table %s (%s)\\n\",\n                my_progname, result_table, mysql_error(mysql));\n        if (path)\n          my_fclose(sql_file, MYF(MY_WME));\n        DBUG_RETURN(0);\n      }\n\n      \/* Find first which key is primary key *\/\n      keynr=0;\n      primary_key=INT_MAX;\n      while ((row= mysql_fetch_row(result)))\n      {\n        if (atoi(row[3]) == 1)\n        {\n          keynr++;\n          if (!strcmp(row[2],\"PRIMARY\"))\n          {\n            primary_key=keynr;\n            break;\n          }\n        }\n      }\n      mysql_data_seek(result,0);\n      keynr=0;\n      while ((row= mysql_fetch_row(result)))\n      {\n        if (opt_xml)\n        {\n          print_xml_row(sql_file, \"key\", result, &row, NullS);\n          continue;\n        }\n\n        if (atoi(row[3]) == 1)\n        {\n          if (keynr++)\n            putc(')', sql_file);\n          if (atoi(row[1]))       \/* Test if duplicate key *\/\n            \/* Duplicate allowed *\/\n            fprintf(sql_file, \",\\n  KEY %s (\",quote_name(row[2],name_buff,0));\n          else if (keynr == primary_key)\n            fputs(\",\\n  PRIMARY KEY (\",sql_file); \/* First UNIQUE is primary *\/\n          else\n            fprintf(sql_file, \",\\n  UNIQUE %s (\",quote_name(row[2],name_buff,\n                                                            0));\n        }\n        else\n          putc(',', sql_file);\n        fputs(quote_name(row[4], name_buff, 0), sql_file);\n        if (row[7])\n          fprintf(sql_file, \" (%s)\",row[7]);      \/* Sub key *\/\n        check_io(sql_file);\n      }\n      mysql_free_result(result);\n      if (!opt_xml)\n      {\n        if (keynr)\n          putc(')', sql_file);\n        fputs(\"\\n)\",sql_file);\n        check_io(sql_file);\n      }\n\n      \/* Get MySQL specific create options *\/\n      if (create_options)\n      {\n        char show_name_buff[NAME_LEN*2+2+24];\n\n        \/* Check memory for quote_for_like() *\/\n        my_snprintf(buff, sizeof(buff), \"show table status like %s\",\n                    quote_for_like(table, show_name_buff));\n\n        if (mysql_query_with_error_report(mysql, &result, buff))\n        {\n          if (mysql_errno(mysql) != ER_PARSE_ERROR)\n          {                                     \/* If old MySQL version *\/\n            verbose_msg(\"-- Warning: Couldn't get status information for \" \\\n                        \"table %s (%s)\\n\", result_table,mysql_error(mysql));\n          }\n        }\n        else if (!(row= mysql_fetch_row(result)))\n        {\n          fprintf(stderr,\n                  \"Error: Couldn't read status information for table %s (%s)\\n\",\n                  result_table,mysql_error(mysql));\n        }\n        else\n        {\n          if (opt_xml)\n            print_xml_row(sql_file, \"options\", result, &row, NullS);\n          else\n          {\n            fputs(\"\/*!\",sql_file);\n            print_value(sql_file,result,row,\"engine=\",\"Engine\",0);\n            print_value(sql_file,result,row,\"\",\"Create_options\",0);\n            print_value(sql_file,result,row,\"comment=\",\"Comment\",1);\n            fputs(\" *\/\",sql_file);\n            check_io(sql_file);\n          }\n        }\n        mysql_free_result(result);              \/* Is always safe to free *\/\n      }\ncontinue_xml:\n      if (!opt_xml)\n        fputs(\";\\n\", sql_file);\n      else\n        fputs(\"\\t<\/table_structure>\\n\", sql_file);\n      check_io(sql_file);\n    }\n  }\n  if (complete_insert)\n  {\n    dynstr_append_checked(&insert_pat, \") VALUES \");\n    if (!extended_insert)\n      dynstr_append_checked(&insert_pat, \"(\");\n  }\n  if (sql_file != md_result_file)\n  {\n    fputs(\"\\n\", sql_file);\n    write_footer(sql_file);\n    my_fclose(sql_file, MYF(MY_WME));\n  }\n  DBUG_RETURN((uint) num_fields);\n} \/* get_table_structure *\/","target":0,"code_token_length":4245,"total_token_length":4481,"max_tokens_setting":6144}
+{"idx":506182,"func":"int dtls1_connect(SSL *s)\n\t{\n\tBUF_MEM *buf=NULL;\n\tunsigned long Time=(unsigned long)time(NULL);\n\tvoid (*cb)(const SSL *ssl,int type,int val)=NULL;\n\tint ret= -1;\n\tint new_state,state,skip=0;\n#ifndef OPENSSL_NO_SCTP\n\tunsigned char sctpauthkey[64];\n\tchar labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)];\n#endif\n\n\tRAND_add(&Time,sizeof(Time),0);\n\tERR_clear_error();\n\tclear_sys_error();\n\n\tif (s->info_callback != NULL)\n\t\tcb=s->info_callback;\n\telse if (s->ctx->info_callback != NULL)\n\t\tcb=s->ctx->info_callback;\n\t\n\ts->in_handshake++;\n\tif (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); \n\n#ifndef OPENSSL_NO_SCTP\n\t\/* Notify SCTP BIO socket to enter handshake\n\t * mode and prevent stream identifier other\n\t * than 0. Will be ignored if no SCTP is used.\n\t *\/\n\tBIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, s->in_handshake, NULL);\n#endif\n\n#ifndef OPENSSL_NO_HEARTBEATS\n\t\/* If we're awaiting a HeartbeatResponse, pretend we\n\t * already got and don't await it anymore, because\n\t * Heartbeats don't make sense during handshakes anyway.\n\t *\/\n\tif (s->tlsext_hb_pending)\n\t\t{\n\t\tdtls1_stop_timer(s);\n\t\ts->tlsext_hb_pending = 0;\n\t\ts->tlsext_hb_seq++;\n\t\t}\n#endif\n\n\tfor (;;)\n\t\t{\n\t\tstate=s->state;\n\n\t\tswitch(s->state)\n\t\t\t{\n\t\tcase SSL_ST_RENEGOTIATE:\n\t\t\ts->renegotiate=1;\n\t\t\ts->state=SSL_ST_CONNECT;\n\t\t\ts->ctx->stats.sess_connect_renegotiate++;\n\t\t\t\/* break *\/\n\t\tcase SSL_ST_BEFORE:\n\t\tcase SSL_ST_CONNECT:\n\t\tcase SSL_ST_BEFORE|SSL_ST_CONNECT:\n\t\tcase SSL_ST_OK|SSL_ST_CONNECT:\n\n\t\t\ts->server=0;\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);\n\n\t\t\tif ((s->version & 0xff00 ) != (DTLS1_VERSION & 0xff00) &&\n\t\t\t    (s->version & 0xff00 ) != (DTLS1_BAD_VER & 0xff00))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_DTLS1_CONNECT, ERR_R_INTERNAL_ERROR);\n\t\t\t\tret = -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\/* s->version=SSL3_VERSION; *\/\n\t\t\ts->type=SSL_ST_CONNECT;\n\n\t\t\tif (s->init_buf == NULL)\n\t\t\t\t{\n\t\t\t\tif ((buf=BUF_MEM_new()) == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tif (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\ts->init_buf=buf;\n\t\t\t\tbuf=NULL;\n\t\t\t\t}\n\n\t\t\tif (!ssl3_setup_buffers(s)) { ret= -1; goto end; }\n\n\t\t\t\/* setup buffing BIO *\/\n\t\t\tif (!ssl_init_wbio_buffer(s,0)) { ret= -1; goto end; }\n\n\t\t\t\/* don't push the buffering BIO quite yet *\/\n\n\t\t\ts->state=SSL3_ST_CW_CLNT_HELLO_A;\n\t\t\ts->ctx->stats.sess_connect++;\n\t\t\ts->init_num=0;\n\t\t\t\/* mark client_random uninitialized *\/\n\t\t\tmemset(s->s3->client_random,0,sizeof(s->s3->client_random));\n\t\t\ts->d1->send_cookie = 0;\n\t\t\ts->hit = 0;\n\t\t\tbreak;\n\n#ifndef OPENSSL_NO_SCTP\n\t\tcase DTLS1_SCTP_ST_CR_READ_SOCK:\n\n\t\t\tif (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s)))\n\t\t\t{\n\t\t\t\ts->s3->in_read_app_data=2;\n\t\t\t\ts->rwstate=SSL_READING;\n\t\t\t\tBIO_clear_retry_flags(SSL_get_rbio(s));\n\t\t\t\tBIO_set_retry_read(SSL_get_rbio(s));\n\t\t\t\tret = -1;\n\t\t\t\tgoto end;\n\t\t\t}\n\n\t\t\ts->state=s->s3->tmp.next_state;\n\t\t\tbreak;\n\n\t\tcase DTLS1_SCTP_ST_CW_WRITE_SOCK:\n\t\t\t\/* read app data until dry event *\/\n\n\t\t\tret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s));\n\t\t\tif (ret < 0) goto end;\n\n\t\t\tif (ret == 0)\n\t\t\t{\n\t\t\t\ts->s3->in_read_app_data=2;\n\t\t\t\ts->rwstate=SSL_READING;\n\t\t\t\tBIO_clear_retry_flags(SSL_get_rbio(s));\n\t\t\t\tBIO_set_retry_read(SSL_get_rbio(s));\n\t\t\t\tret = -1;\n\t\t\t\tgoto end;\n\t\t\t}\n\n\t\t\ts->state=s->d1->next_state;\n\t\t\tbreak;\n#endif\n\n\t\tcase SSL3_ST_CW_CLNT_HELLO_A:\n\t\tcase SSL3_ST_CW_CLNT_HELLO_B:\n\n\t\t\ts->shutdown=0;\n\n\t\t\t\/* every DTLS ClientHello resets Finished MAC *\/\n\t\t\tssl3_init_finished_mac(s);\n\n\t\t\tdtls1_start_timer(s);\n\t\t\tret=dtls1_client_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\n\t\t\tif ( s->d1->send_cookie)\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_CW_FLUSH;\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CR_SRVR_HELLO_A;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\ts->state=SSL3_ST_CR_SRVR_HELLO_A;\n\n\t\t\ts->init_num=0;\n\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\/* Disable buffering for SCTP *\/\n\t\t\tif (!BIO_dgram_is_sctp(SSL_get_wbio(s)))\n\t\t\t\t{\n#endif\n\t\t\t\t\/* turn on buffering for the next lot of output *\/\n\t\t\t\tif (s->bbio != s->wbio)\n\t\t\t\t\ts->wbio=BIO_push(s->bbio,s->wbio);\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\t}\n#endif\n\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_SRVR_HELLO_A:\n\t\tcase SSL3_ST_CR_SRVR_HELLO_B:\n\t\t\tret=ssl3_get_server_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tdtls1_stop_timer(s);\n\t\t\t\tif (s->hit)\n\t\t\t\t\t{\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\t\t\/* Add new shared key for SCTP-Auth,\n\t\t\t\t\t * will be ignored if no SCTP used.\n\t\t\t\t\t *\/\n\t\t\t\t\tsnprintf((char*) labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL),\n\t\t\t\t\t         DTLS1_SCTP_AUTH_LABEL);\n\n\t\t\t\t\tSSL_export_keying_material(s, sctpauthkey,\n\t\t\t\t\t                           sizeof(sctpauthkey), labelbuffer,\n\t\t\t\t\t                           sizeof(labelbuffer), NULL, 0, 0);\n\n\t\t\t\t\tBIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY,\n\t\t\t\t\t\t\t sizeof(sctpauthkey), sctpauthkey);\n#endif\n\n\t\t\t\t\ts->state=SSL3_ST_CR_FINISHED_A;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\ts->state=DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A;\n\t\t\t\t}\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:\n\t\tcase DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:\n\n\t\t\tret = dtls1_get_hello_verify(s);\n\t\t\tif ( ret <= 0)\n\t\t\t\tgoto end;\n\t\t\tdtls1_stop_timer(s);\n\t\t\tif ( s->d1->send_cookie) \/* start again, with a cookie *\/\n\t\t\t\ts->state=SSL3_ST_CW_CLNT_HELLO_A;\n\t\t\telse\n\t\t\t\ts->state = SSL3_ST_CR_CERT_A;\n\t\t\ts->init_num = 0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_CERT_A:\n\t\tcase SSL3_ST_CR_CERT_B:\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\tret=ssl3_check_finished(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\tif (ret == 2)\n\t\t\t\t{\n\t\t\t\ts->hit = 1;\n\t\t\t\tif (s->tlsext_ticket_expected)\n\t\t\t\t\ts->state=SSL3_ST_CR_SESSION_TICKET_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_CR_FINISHED_A;\n\t\t\t\ts->init_num=0;\n\t\t\t\tbreak;\n\t\t\t\t}\n#endif\n\t\t\t\/* Check if it is anon DH or PSK *\/\n\t\t\tif (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&\n\t\t\t    !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK))\n\t\t\t\t{\n\t\t\t\tret=ssl3_get_server_certificate(s);\n\t\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\t\tif (s->tlsext_status_expected)\n\t\t\t\t\ts->state=SSL3_ST_CR_CERT_STATUS_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tskip = 1;\n\t\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n\t\t\t\t}\n#else\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tskip=1;\n\n\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n#endif\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_KEY_EXCH_A:\n\t\tcase SSL3_ST_CR_KEY_EXCH_B:\n\t\t\tret=ssl3_get_key_exchange(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_CERT_REQ_A;\n\t\t\ts->init_num=0;\n\n\t\t\t\/* at this point we check that we have the\n\t\t\t * required stuff from the server *\/\n\t\t\tif (!ssl3_check_cert_and_algorithm(s))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_CERT_REQ_A:\n\t\tcase SSL3_ST_CR_CERT_REQ_B:\n\t\t\tret=ssl3_get_certificate_request(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_SRVR_DONE_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CR_SRVR_DONE_A:\n\t\tcase SSL3_ST_CR_SRVR_DONE_B:\n\t\t\tret=ssl3_get_server_done(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\tif (s->s3->tmp.cert_req)\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CW_CERT_A;\n\t\t\telse\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CW_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\n#ifndef OPENSSL_NO_SCTP\t\t\t\n\t\t\tif (BIO_dgram_is_sctp(SSL_get_wbio(s)) &&\n\t\t\t    state == SSL_ST_RENEGOTIATE)\n\t\t\t\ts->state=DTLS1_SCTP_ST_CR_READ_SOCK;\n\t\t\telse\n#endif\t\t\t\n\t\t\ts->state=s->s3->tmp.next_state;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CERT_A:\n\t\tcase SSL3_ST_CW_CERT_B:\n\t\tcase SSL3_ST_CW_CERT_C:\n\t\tcase SSL3_ST_CW_CERT_D:\n\t\t\tdtls1_start_timer(s);\n\t\t\tret=dtls1_send_client_certificate(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CW_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_KEY_EXCH_A:\n\t\tcase SSL3_ST_CW_KEY_EXCH_B:\n\t\t\tdtls1_start_timer(s);\n\t\t\tret=dtls1_send_client_key_exchange(s);\n\t\t\tif (ret <= 0) goto end;\n\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\/* Add new shared key for SCTP-Auth,\n\t\t\t * will be ignored if no SCTP used.\n\t\t\t *\/\n\t\t\tsnprintf((char*) labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL),\n\t\t\t         DTLS1_SCTP_AUTH_LABEL);\n\n\t\t\tSSL_export_keying_material(s, sctpauthkey,\n\t\t\t                           sizeof(sctpauthkey), labelbuffer,\n\t\t\t                           sizeof(labelbuffer), NULL, 0, 0);\n\n\t\t\tBIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY,\n\t\t\t\t\t sizeof(sctpauthkey), sctpauthkey);\n#endif\n\n\t\t\t\/* EAY EAY EAY need to check for DH fix cert\n\t\t\t * sent back *\/\n\t\t\t\/* For TLS, cert_req is set to 2, so a cert chain\n\t\t\t * of nothing is sent, but no verify packet is sent *\/\n\t\t\tif (s->s3->tmp.cert_req == 1)\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_CW_CERT_VRFY_A;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\tif (BIO_dgram_is_sctp(SSL_get_wbio(s)))\n\t\t\t\t\t{\n\t\t\t\t\ts->d1->next_state=SSL3_ST_CW_CHANGE_A;\n\t\t\t\t\ts->state=DTLS1_SCTP_ST_CW_WRITE_SOCK;\n\t\t\t\t\t}\n\t\t\t\telse\n#endif\n\t\t\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\t\ts->s3->change_cipher_spec=0;\n\t\t\t\t}\n\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CERT_VRFY_A:\n\t\tcase SSL3_ST_CW_CERT_VRFY_B:\n\t\t\tdtls1_start_timer(s);\n\t\t\tret=dtls1_send_client_verify(s);\n\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_SCTP\n\t\t\tif (BIO_dgram_is_sctp(SSL_get_wbio(s)))\n\t\t\t{\n\t\t\t\ts->d1->next_state=SSL3_ST_CW_CHANGE_A;\n\t\t\t\ts->state=DTLS1_SCTP_ST_CW_WRITE_SOCK;\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\ts->init_num=0;\n\t\t\ts->s3->change_cipher_spec=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_CHANGE_A:\n\t\tcase SSL3_ST_CW_CHANGE_B:\n\t\t\tif (!s->hit)\n\t\t\t\tdtls1_start_timer(s);\n\t\t\tret=dtls1_send_change_cipher_spec(s,\n\t\t\t\tSSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);\n\t\t\tif (ret <= 0) goto end;\n\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\/* Change to new shared key of SCTP-Auth,\n\t\t\t * will be ignored if no SCTP used.\n\t\t\t *\/\n\t\t\tBIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);\n#endif\n\n\t\t\ts->state=SSL3_ST_CW_FINISHED_A;\n\t\t\ts->init_num=0;\n\n\t\t\ts->session->cipher=s->s3->tmp.new_cipher;\n#ifdef OPENSSL_NO_COMP\n\t\t\ts->session->compress_meth=0;\n#else\n\t\t\tif (s->s3->tmp.new_compression == NULL)\n\t\t\t\ts->session->compress_meth=0;\n\t\t\telse\n\t\t\t\ts->session->compress_meth=\n\t\t\t\t\ts->s3->tmp.new_compression->id;\n#endif\n\t\t\tif (!s->method->ssl3_enc->setup_key_block(s))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\tif (!s->method->ssl3_enc->change_cipher_state(s,\n\t\t\t\tSSL3_CHANGE_CIPHER_CLIENT_WRITE))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t\n\t\t\tdtls1_reset_seq_numbers(s, SSL3_CC_WRITE);\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_FINISHED_A:\n\t\tcase SSL3_ST_CW_FINISHED_B:\n\t\t\tif (!s->hit)\n\t\t\t\tdtls1_start_timer(s);\n\t\t\tret=dtls1_send_finished(s,\n\t\t\t\tSSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,\n\t\t\t\ts->method->ssl3_enc->client_finished_label,\n\t\t\t\ts->method->ssl3_enc->client_finished_label_len);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CW_FLUSH;\n\n\t\t\t\/* clear flags *\/\n\t\t\ts->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;\n\t\t\tif (s->hit)\n\t\t\t\t{\n\t\t\t\ts->s3->tmp.next_state=SSL_ST_OK;\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\tif (BIO_dgram_is_sctp(SSL_get_wbio(s)))\n\t\t\t\t\t{\n\t\t\t\t\t\ts->d1->next_state = s->s3->tmp.next_state;\n\t\t\t\t\t\ts->s3->tmp.next_state=DTLS1_SCTP_ST_CW_WRITE_SOCK;\n\t\t\t\t\t}\n#endif\n\t\t\t\tif (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED)\n\t\t\t\t\t{\n\t\t\t\t\ts->state=SSL_ST_OK;\n#ifndef OPENSSL_NO_SCTP\n\t\t\t\t\tif (BIO_dgram_is_sctp(SSL_get_wbio(s)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ts->d1->next_state = SSL_ST_OK;\n\t\t\t\t\t\t\ts->state=DTLS1_SCTP_ST_CW_WRITE_SOCK;\n\t\t\t\t\t\t}\n#endif\n\t\t\t\t\ts->s3->flags|=SSL3_FLAGS_POP_BUFFER;\n\t\t\t\t\ts->s3->delay_buf_pop_ret=0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\t\t\/* Allow NewSessionTicket if ticket expected *\/\n\t\t\t\tif (s->tlsext_ticket_expected)\n\t\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;\n\t\t\t\telse\n#endif\n\t\t\t\t\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;\n\t\t\t\t}\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\tcase SSL3_ST_CR_SESSION_TICKET_A:\n\t\tcase SSL3_ST_CR_SESSION_TICKET_B:\n\t\t\tret=ssl3_get_new_session_ticket(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_FINISHED_A;\n\t\t\ts->init_num=0;\n\t\tbreak;\n\n\t\tcase SSL3_ST_CR_CERT_STATUS_A:\n\t\tcase SSL3_ST_CR_CERT_STATUS_B:\n\t\t\tret=ssl3_get_cert_status(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_CR_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\t\tbreak;\n#endif\n\n\t\tcase SSL3_ST_CR_FINISHED_A:\n\t\tcase SSL3_ST_CR_FINISHED_B:\n\t\t\ts->d1->change_cipher_spec_ok = 1;\n\t\t\tret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,\n\t\t\t\tSSL3_ST_CR_FINISHED_B);\n\t\t\tif (ret <= 0) goto end;\n\t\t\tdtls1_stop_timer(s);\n\n\t\t\tif (s->hit)\n\t\t\t\ts->state=SSL3_ST_CW_CHANGE_A;\n\t\t\telse\n\t\t\t\ts->state=SSL_ST_OK;\n\n#ifndef OPENSSL_NO_SCTP\n\t\t\tif (BIO_dgram_is_sctp(SSL_get_wbio(s)) &&\n\t\t\t\tstate == SSL_ST_RENEGOTIATE)\n\t\t\t\t{\n\t\t\t\ts->d1->next_state=s->state;\n\t\t\t\ts->state=DTLS1_SCTP_ST_CW_WRITE_SOCK;\n\t\t\t\t}\n#endif\n\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_CW_FLUSH:\n\t\t\ts->rwstate=SSL_WRITING;\n\t\t\tif (BIO_flush(s->wbio) <= 0)\n\t\t\t\t{\n\t\t\t\t\/* If the write error was fatal, stop trying *\/\n\t\t\t\tif (!BIO_should_retry(s->wbio))\n\t\t\t\t\t{\n\t\t\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\t\t\ts->state=s->s3->tmp.next_state;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\ts->state=s->s3->tmp.next_state;\n\t\t\tbreak;\n\n\t\tcase SSL_ST_OK:\n\t\t\t\/* clean a few things up *\/\n\t\t\tssl3_cleanup_key_block(s);\n\n#if 0\n\t\t\tif (s->init_buf != NULL)\n\t\t\t\t{\n\t\t\t\tBUF_MEM_free(s->init_buf);\n\t\t\t\ts->init_buf=NULL;\n\t\t\t\t}\n#endif\n\n\t\t\t\/* If we are not 'joining' the last two packets,\n\t\t\t * remove the buffering now *\/\n\t\t\tif (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER))\n\t\t\t\tssl_free_wbio_buffer(s);\n\t\t\t\/* else do it later in ssl3_write *\/\n\n\t\t\ts->init_num=0;\n\t\t\ts->renegotiate=0;\n\t\t\ts->new_session=0;\n\n\t\t\tssl_update_cache(s,SSL_SESS_CACHE_CLIENT);\n\t\t\tif (s->hit) s->ctx->stats.sess_hit++;\n\n\t\t\tret=1;\n\t\t\t\/* s->server=0; *\/\n\t\t\ts->handshake_func=dtls1_connect;\n\t\t\ts->ctx->stats.sess_connect_good++;\n\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);\n\n\t\t\t\/* done with handshaking *\/\n\t\t\ts->d1->handshake_read_seq  = 0;\n\t\t\ts->d1->next_handshake_write_seq = 0;\n\t\t\tgoto end;\n\t\t\t\/* break; *\/\n\t\t\t\n\t\tdefault:\n\t\t\tSSLerr(SSL_F_DTLS1_CONNECT,SSL_R_UNKNOWN_STATE);\n\t\t\tret= -1;\n\t\t\tgoto end;\n\t\t\t\/* break; *\/\n\t\t\t}\n\n\t\t\/* did we do anything *\/\n\t\tif (!s->s3->tmp.reuse_message && !skip)\n\t\t\t{\n\t\t\tif (s->debug)\n\t\t\t\t{\n\t\t\t\tif ((ret=BIO_flush(s->wbio)) <= 0)\n\t\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\tif ((cb != NULL) && (s->state != state))\n\t\t\t\t{\n\t\t\t\tnew_state=s->state;\n\t\t\t\ts->state=state;\n\t\t\t\tcb(s,SSL_CB_CONNECT_LOOP,1);\n\t\t\t\ts->state=new_state;\n\t\t\t\t}\n\t\t\t}\n\t\tskip=0;\n\t\t}","target":0,"code_token_length":4774,"total_token_length":5010,"max_tokens_setting":6144}
+{"idx":427441,"func":"deliver_local(address_item *addr, BOOL shadowing)\n{\nBOOL use_initgroups;\nuid_t uid;\ngid_t gid;\nint status, len, rc;\nint pfd[2];\npid_t pid;\nuschar *working_directory;\naddress_item *addr2;\ntransport_instance *tp = addr->transport;\n\n\/* Set up the return path from the errors or sender address. If the transport\nhas its own return path setting, expand it and replace the existing value. *\/\n\nif(addr->prop.errors_address)\n  return_path = addr->prop.errors_address;\n#ifdef EXPERIMENTAL_SRS\nelse if (addr->prop.srs_sender)\n  return_path = addr->prop.srs_sender;\n#endif\nelse\n  return_path = sender_address;\n\nif (tp->return_path)\n  {\n  uschar *new_return_path = expand_string(tp->return_path);\n  if (!new_return_path)\n    {\n    if (!expand_string_forcedfail)\n      {\n      common_error(TRUE, addr, ERRNO_EXPANDFAIL,\n        US\"Failed to expand return path \\\"%s\\\" in %s transport: %s\",\n        tp->return_path, tp->name, expand_string_message);\n      return;\n      }\n    }\n  else return_path = new_return_path;\n  }\n\n\/* For local deliveries, one at a time, the value used for logging can just be\nset directly, once and for all. *\/\n\nused_return_path = return_path;\n\n\/* Sort out the uid, gid, and initgroups flag. If an error occurs, the message\ngets put into the address(es), and the expansions are unset, so we can just\nreturn. *\/\n\nif (!findugid(addr, tp, &uid, &gid, &use_initgroups)) return;\n\n\/* See if either the transport or the address specifies a home directory. A\nhome directory set in the address may already be expanded; a flag is set to\nindicate that. In other cases we must expand it. *\/\n\nif (  (deliver_home = tp->home_dir)\t\t\/* Set in transport, or *\/\n   || (  (deliver_home = addr->home_dir)\t\/* Set in address and *\/\n      && !testflag(addr, af_home_expanded)\t\/*   not expanded *\/\n   )  )\n  {\n  uschar *rawhome = deliver_home;\n  deliver_home = NULL;                      \/* in case it contains $home *\/\n  if (!(deliver_home = expand_string(rawhome)))\n    {\n    common_error(TRUE, addr, ERRNO_EXPANDFAIL, US\"home directory \\\"%s\\\" failed \"\n      \"to expand for %s transport: %s\", rawhome, tp->name,\n      expand_string_message);\n    return;\n    }\n  if (*deliver_home != '\/')\n    {\n    common_error(TRUE, addr, ERRNO_NOTABSOLUTE, US\"home directory path \\\"%s\\\" \"\n      \"is not absolute for %s transport\", deliver_home, tp->name);\n    return;\n    }\n  }\n\n\/* See if either the transport or the address specifies a current directory,\nand if so, expand it. If nothing is set, use the home directory, unless it is\nalso unset in which case use \"\/\", which is assumed to be a directory to which\nall users have access. It is necessary to be in a visible directory for some\noperating systems when running pipes, as some commands (e.g. \"rm\" under Solaris\n2.5) require this. *\/\n\nworking_directory = tp->current_dir ? tp->current_dir : addr->current_dir;\nif (working_directory)\n  {\n  uschar *raw = working_directory;\n  if (!(working_directory = expand_string(raw)))\n    {\n    common_error(TRUE, addr, ERRNO_EXPANDFAIL, US\"current directory \\\"%s\\\" \"\n      \"failed to expand for %s transport: %s\", raw, tp->name,\n      expand_string_message);\n    return;\n    }\n  if (*working_directory != '\/')\n    {\n    common_error(TRUE, addr, ERRNO_NOTABSOLUTE, US\"current directory path \"\n      \"\\\"%s\\\" is not absolute for %s transport\", working_directory, tp->name);\n    return;\n    }\n  }\nelse working_directory = deliver_home ? deliver_home : US\"\/\";\n\n\/* If one of the return_output flags is set on the transport, create and open a\nfile in the message log directory for the transport to write its output onto.\nThis is mainly used by pipe transports. The file needs to be unique to the\naddress. This feature is not available for shadow transports. *\/\n\nif (  !shadowing\n   && (  tp->return_output || tp->return_fail_output\n      || tp->log_output || tp->log_fail_output || tp->log_defer_output\n   )  )\n  {\n  uschar * error;\n\n  addr->return_filename =\n    spool_fname(US\"msglog\", message_subdir, message_id,\n      string_sprintf(\"-%d-%d\", getpid(), return_count++));\n\n  if ((addr->return_file = open_msglog_file(addr->return_filename, 0400, &error)) < 0)\n    {\n    common_error(TRUE, addr, errno, US\"Unable to %s file for %s transport \"\n      \"to return message: %s\", error, tp->name, strerror(errno));\n    return;\n    }\n  }\n\n\/* Create the pipe for inter-process communication. *\/\n\nif (pipe(pfd) != 0)\n  {\n  common_error(TRUE, addr, ERRNO_PIPEFAIL, US\"Creation of pipe failed: %s\",\n    strerror(errno));\n  return;\n  }\n\n\/* Now fork the process to do the real work in the subprocess, but first\nensure that all cached resources are freed so that the subprocess starts with\na clean slate and doesn't interfere with the parent process. *\/\n\nsearch_tidyup();\n\nif ((pid = fork()) == 0)\n  {\n  BOOL replicate = TRUE;\n\n  \/* Prevent core dumps, as we don't want them in users' home directories.\n  HP-UX doesn't have RLIMIT_CORE; I don't know how to do this in that\n  system. Some experimental\/developing systems (e.g. GNU\/Hurd) may define\n  RLIMIT_CORE but not support it in setrlimit(). For such systems, do not\n  complain if the error is \"not supported\".\n\n  There are two scenarios where changing the max limit has an effect.  In one,\n  the user is using a .forward and invoking a command of their choice via pipe;\n  for these, we do need the max limit to be 0 unless the admin chooses to\n  permit an increased limit.  In the other, the command is invoked directly by\n  the transport and is under administrator control, thus being able to raise\n  the limit aids in debugging.  So there's no general always-right answer.\n\n  Thus we inhibit core-dumps completely but let individual transports, while\n  still root, re-raise the limits back up to aid debugging.  We make the\n  default be no core-dumps -- few enough people can use core dumps in\n  diagnosis that it's reasonable to make them something that has to be explicitly requested.\n  *\/\n\n#ifdef RLIMIT_CORE\n  struct rlimit rl;\n  rl.rlim_cur = 0;\n  rl.rlim_max = 0;\n  if (setrlimit(RLIMIT_CORE, &rl) < 0)\n    {\n# ifdef SETRLIMIT_NOT_SUPPORTED\n    if (errno != ENOSYS && errno != ENOTSUP)\n# endif\n      log_write(0, LOG_MAIN|LOG_PANIC, \"setrlimit(RLIMIT_CORE) failed: %s\",\n        strerror(errno));\n    }\n#endif\n\n  \/* Reset the random number generator, so different processes don't all\n  have the same sequence. *\/\n\n  random_seed = 0;\n\n  \/* If the transport has a setup entry, call this first, while still\n  privileged. (Appendfile uses this to expand quota, for example, while\n  able to read private files.) *\/\n\n  if (addr->transport->setup)\n    switch((addr->transport->setup)(addr->transport, addr, NULL, uid, gid,\n           &(addr->message)))\n      {\n      case DEFER:\n\taddr->transport_return = DEFER;\n\tgoto PASS_BACK;\n\n      case FAIL:\n\taddr->transport_return = PANIC;\n\tgoto PASS_BACK;\n      }\n\n  \/* Ignore SIGINT and SIGTERM during delivery. Also ignore SIGUSR1, as\n  when the process becomes unprivileged, it won't be able to write to the\n  process log. SIGHUP is ignored throughout exim, except when it is being\n  run as a daemon. *\/\n\n  signal(SIGINT, SIG_IGN);\n  signal(SIGTERM, SIG_IGN);\n  signal(SIGUSR1, SIG_IGN);\n\n  \/* Close the unwanted half of the pipe, and set close-on-exec for the other\n  half - for transports that exec things (e.g. pipe). Then set the required\n  gid\/uid. *\/\n\n  (void)close(pfd[pipe_read]);\n  (void)fcntl(pfd[pipe_write], F_SETFD, fcntl(pfd[pipe_write], F_GETFD) |\n    FD_CLOEXEC);\n  exim_setugid(uid, gid, use_initgroups,\n    string_sprintf(\"local delivery to %s <%s> transport=%s\", addr->local_part,\n      addr->address, addr->transport->name));\n\n  DEBUG(D_deliver)\n    {\n    address_item *batched;\n    debug_printf(\"  home=%s current=%s\\n\", deliver_home, working_directory);\n    for (batched = addr->next; batched; batched = batched->next)\n      debug_printf(\"additional batched address: %s\\n\", batched->address);\n    }\n\n  \/* Set an appropriate working directory. *\/\n\n  if (Uchdir(working_directory) < 0)\n    {\n    addr->transport_return = DEFER;\n    addr->basic_errno = errno;\n    addr->message = string_sprintf(\"failed to chdir to %s\", working_directory);\n    }\n\n  \/* If successful, call the transport *\/\n\n  else\n    {\n    BOOL ok = TRUE;\n    set_process_info(\"delivering %s to %s using %s\", message_id,\n     addr->local_part, addr->transport->name);\n\n    \/* Setting this global in the subprocess means we need never clear it *\/\n    transport_name = addr->transport->name;\n\n    \/* If a transport filter has been specified, set up its argument list.\n    Any errors will get put into the address, and FALSE yielded. *\/\n\n    if (addr->transport->filter_command)\n      {\n      ok = transport_set_up_command(&transport_filter_argv,\n        addr->transport->filter_command,\n        TRUE, PANIC, addr, US\"transport filter\", NULL);\n      transport_filter_timeout = addr->transport->filter_timeout;\n      }\n    else transport_filter_argv = NULL;\n\n    if (ok)\n      {\n      debug_print_string(addr->transport->debug_string);\n      replicate = !(addr->transport->info->code)(addr->transport, addr);\n      }\n    }\n\n  \/* Pass the results back down the pipe. If necessary, first replicate the\n  status in the top address to the others in the batch. The label is the\n  subject of a goto when a call to the transport's setup function fails. We\n  pass the pointer to the transport back in case it got changed as a result of\n  file_format in appendfile. *\/\n\n  PASS_BACK:\n\n  if (replicate) replicate_status(addr);\n  for (addr2 = addr; addr2; addr2 = addr2->next)\n    {\n    int i;\n    int local_part_length = Ustrlen(addr2->local_part);\n    uschar *s;\n    int ret;\n\n    if(  (ret = write(pfd[pipe_write], &addr2->transport_return, sizeof(int))) != sizeof(int)\n      || (ret = write(pfd[pipe_write], &transport_count, sizeof(transport_count))) != sizeof(transport_count)\n      || (ret = write(pfd[pipe_write], &addr2->flags, sizeof(addr2->flags))) != sizeof(addr2->flags)\n      || (ret = write(pfd[pipe_write], &addr2->basic_errno,    sizeof(int))) != sizeof(int)\n      || (ret = write(pfd[pipe_write], &addr2->more_errno,     sizeof(int))) != sizeof(int)\n      || (ret = write(pfd[pipe_write], &addr2->delivery_usec,  sizeof(int))) != sizeof(int)\n      || (ret = write(pfd[pipe_write], &addr2->special_action, sizeof(int))) != sizeof(int)\n      || (ret = write(pfd[pipe_write], &addr2->transport,\n        sizeof(transport_instance *))) != sizeof(transport_instance *)\n\n    \/* For a file delivery, pass back the local part, in case the original\n    was only part of the final delivery path. This gives more complete\n    logging. *\/\n\n      || (testflag(addr2, af_file)\n          && (  (ret = write(pfd[pipe_write], &local_part_length, sizeof(int))) != sizeof(int)\n             || (ret = write(pfd[pipe_write], addr2->local_part, local_part_length)) != local_part_length\n\t     )\n\t )\n      )\n      log_write(0, LOG_MAIN|LOG_PANIC, \"Failed writing transport results to pipe: %s\",\n\tret == -1 ? strerror(errno) : \"short write\");\n\n    \/* Now any messages *\/\n\n    for (i = 0, s = addr2->message; i < 2; i++, s = addr2->user_message)\n      {\n      int message_length = s ? Ustrlen(s) + 1 : 0;\n      if(  (ret = write(pfd[pipe_write], &message_length, sizeof(int))) != sizeof(int)\n        || message_length > 0  && (ret = write(pfd[pipe_write], s, message_length)) != message_length\n\t)\n        log_write(0, LOG_MAIN|LOG_PANIC, \"Failed writing transport results to pipe: %s\",\n\t  ret == -1 ? strerror(errno) : \"short write\");\n      }\n    }\n\n  \/* OK, this process is now done. Free any cached resources that it opened,\n  and close the pipe we were writing down before exiting. *\/\n\n  (void)close(pfd[pipe_write]);\n  search_tidyup();\n  exit(EXIT_SUCCESS);\n  }\n\n\/* Back in the main process: panic if the fork did not succeed. This seems\nbetter than returning an error - if forking is failing it is probably best\nnot to try other deliveries for this message. *\/\n\nif (pid < 0)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"Fork failed for local delivery to %s\",\n    addr->address);\n\n\/* Read the pipe to get the delivery status codes and error messages. Our copy\nof the writing end must be closed first, as otherwise read() won't return zero\non an empty pipe. We check that a status exists for each address before\noverwriting the address structure. If data is missing, the default DEFER status\nwill remain. Afterwards, close the reading end. *\/\n\n(void)close(pfd[pipe_write]);\n\nfor (addr2 = addr; addr2; addr2 = addr2->next)\n  {\n  if ((len = read(pfd[pipe_read], &status, sizeof(int))) > 0)\n    {\n    int i;\n    uschar **sptr;\n\n    addr2->transport_return = status;\n    len = read(pfd[pipe_read], &transport_count,\n      sizeof(transport_count));\n    len = read(pfd[pipe_read], &addr2->flags, sizeof(addr2->flags));\n    len = read(pfd[pipe_read], &addr2->basic_errno,    sizeof(int));\n    len = read(pfd[pipe_read], &addr2->more_errno,     sizeof(int));\n    len = read(pfd[pipe_read], &addr2->delivery_usec,  sizeof(int));\n    len = read(pfd[pipe_read], &addr2->special_action, sizeof(int));\n    len = read(pfd[pipe_read], &addr2->transport,\n      sizeof(transport_instance *));\n\n    if (testflag(addr2, af_file))\n      {\n      int llen;\n      if (  read(pfd[pipe_read], &llen, sizeof(int)) != sizeof(int)\n\t || llen > 64*4\t\/* limit from rfc 5821, times I18N factor *\/\n         )\n\t{\n\tlog_write(0, LOG_MAIN|LOG_PANIC, \"bad local_part length read\"\n\t  \" from delivery subprocess\");\n\tbreak;\n\t}\n      \/* sanity-checked llen so disable the Coverity error *\/\n      \/* coverity[tainted_data] *\/\n      if (read(pfd[pipe_read], big_buffer, llen) != llen)\n\t{\n\tlog_write(0, LOG_MAIN|LOG_PANIC, \"bad local_part read\"\n\t  \" from delivery subprocess\");\n\tbreak;\n\t}\n      big_buffer[llen] = 0;\n      addr2->local_part = string_copy(big_buffer);\n      }\n\n    for (i = 0, sptr = &addr2->message; i < 2; i++, sptr = &addr2->user_message)\n      {\n      int message_length;\n      len = read(pfd[pipe_read], &message_length, sizeof(int));\n      if (message_length > 0)\n        {\n        len = read(pfd[pipe_read], big_buffer, message_length);\n\tbig_buffer[big_buffer_size-1] = '\\0';\t\t\/* guard byte *\/\n        if (len > 0) *sptr = string_copy(big_buffer);\n        }\n      }\n    }\n\n  else\n    {\n    log_write(0, LOG_MAIN|LOG_PANIC, \"failed to read delivery status for %s \"\n      \"from delivery subprocess\", addr2->unique);\n    break;\n    }\n  }\n\n(void)close(pfd[pipe_read]);\n\n\/* Unless shadowing, write all successful addresses immediately to the journal\nfile, to ensure they are recorded asap. For homonymic addresses, use the base\naddress plus the transport name. Failure to write the journal is panic-worthy,\nbut don't stop, as it may prove possible subsequently to update the spool file\nin order to record the delivery. *\/\n\nif (!shadowing)\n  {\n  for (addr2 = addr; addr2; addr2 = addr2->next)\n    if (addr2->transport_return == OK)\n      {\n      if (testflag(addr2, af_homonym))\n\tsprintf(CS big_buffer, \"%.500s\/%s\\n\", addr2->unique + 3, tp->name);\n      else\n\tsprintf(CS big_buffer, \"%.500s\\n\", addr2->unique);\n\n      \/* In the test harness, wait just a bit to let the subprocess finish off\n      any debug output etc first. *\/\n\n      if (running_in_test_harness) millisleep(300);\n\n      DEBUG(D_deliver) debug_printf(\"journalling %s\", big_buffer);\n      len = Ustrlen(big_buffer);\n      if (write(journal_fd, big_buffer, len) != len)\n\tlog_write(0, LOG_MAIN|LOG_PANIC, \"failed to update journal for %s: %s\",\n\t  big_buffer, strerror(errno));\n      }\n\n  \/* Ensure the journal file is pushed out to disk. *\/\n\n  if (EXIMfsync(journal_fd) < 0)\n    log_write(0, LOG_MAIN|LOG_PANIC, \"failed to fsync journal: %s\",\n      strerror(errno));\n  }\n\n\/* Wait for the process to finish. If it terminates with a non-zero code,\nfreeze the message (except for SIGTERM, SIGKILL and SIGQUIT), but leave the\nstatus values of all the addresses as they are. Take care to handle the case\nwhen the subprocess doesn't seem to exist. This has been seen on one system\nwhen Exim was called from an MUA that set SIGCHLD to SIG_IGN. When that\nhappens, wait() doesn't recognize the termination of child processes. Exim now\nresets SIGCHLD to SIG_DFL, but this code should still be robust. *\/\n\nwhile ((rc = wait(&status)) != pid)\n  if (rc < 0 && errno == ECHILD)      \/* Process has vanished *\/\n    {\n    log_write(0, LOG_MAIN, \"%s transport process vanished unexpectedly\",\n      addr->transport->driver_name);\n    status = 0;\n    break;\n    }\n\nif ((status & 0xffff) != 0)\n  {\n  int msb = (status >> 8) & 255;\n  int lsb = status & 255;\n  int code = (msb == 0)? (lsb & 0x7f) : msb;\n  if (msb != 0 || (code != SIGTERM && code != SIGKILL && code != SIGQUIT))\n    addr->special_action = SPECIAL_FREEZE;\n  log_write(0, LOG_MAIN|LOG_PANIC, \"%s transport process returned non-zero \"\n    \"status 0x%04x: %s %d\",\n    addr->transport->driver_name,\n    status,\n    msb == 0 ? \"terminated by signal\" : \"exit code\",\n    code);\n  }\n\n\/* If SPECIAL_WARN is set in the top address, send a warning message. *\/\n\nif (addr->special_action == SPECIAL_WARN && addr->transport->warn_message)\n  {\n  int fd;\n  uschar *warn_message;\n  pid_t pid;\n\n  DEBUG(D_deliver) debug_printf(\"Warning message requested by transport\\n\");\n\n  if (!(warn_message = expand_string(addr->transport->warn_message)))\n    log_write(0, LOG_MAIN|LOG_PANIC, \"Failed to expand \\\"%s\\\" (warning \"\n      \"message for %s transport): %s\", addr->transport->warn_message,\n      addr->transport->name, expand_string_message);\n\n  else if ((pid = child_open_exim(&fd)) > 0)\n    {\n    FILE *f = fdopen(fd, \"wb\");\n    if (errors_reply_to && !contains_header(US\"Reply-To\", warn_message))\n      fprintf(f, \"Reply-To: %s\\n\", errors_reply_to);\n    fprintf(f, \"Auto-Submitted: auto-replied\\n\");\n    if (!contains_header(US\"From\", warn_message))\n      moan_write_from(f);\n    fprintf(f, \"%s\", CS warn_message);\n\n    \/* Close and wait for child process to complete, without a timeout. *\/\n\n    (void)fclose(f);\n    (void)child_close(pid, 0);\n    }\n\n  addr->special_action = SPECIAL_NONE;\n  }\n}","target":0,"code_token_length":4831,"total_token_length":5067,"max_tokens_setting":6144}
+{"idx":286201,"func":"hfs_istat(TSK_FS_INFO * fs, TSK_FS_ISTAT_FLAG_ENUM istat_flags, FILE * hFile, TSK_INUM_T inum,\n    TSK_DADDR_T numblock, int32_t sec_skew)\n{\n    HFS_INFO *hfs = (HFS_INFO *) fs;\n    TSK_FS_FILE *fs_file;\n    char hfs_mode[12];\n    HFS_PRINT_ADDR print;\n    HFS_ENTRY entry;\n    char timeBuf[128];\n    const TSK_FS_ATTR *compressionAttr = NULL;\n    RES_DESCRIPTOR *rd;         \/\/ descriptor of a resource\n\n    tsk_error_reset();\n\n    if (tsk_verbose)\n        tsk_fprintf(stderr,\n            \"hfs_istat: inum: %\" PRIuINUM \" numblock: %\" PRIu32 \"\\n\",\n            inum, numblock);\n\n    if ((fs_file = tsk_fs_file_open_meta(fs, NULL, inum)) == NULL) {\n        error_returned(\"hfs_istat: getting metadata for the file\");\n        return 1;\n    }\n\n    if (inum >= HFS_FIRST_USER_CNID) {\n        int rslt;\n        tsk_fprintf(hFile, \"File Path: \");\n        rslt = print_parent_path(hFile, fs, inum);\n        if (rslt != 0)\n            tsk_fprintf(hFile, \" Error in printing path\\n\");\n        else\n            tsk_fprintf(hFile, \"\\n\");\n    }\n    else {\n        if (fs_file->meta->name2 != NULL)\n            tsk_fprintf(hFile, \"File Name: %s\\n\",\n                fs_file->meta->name2->name);\n    }\n\n    tsk_fprintf(hFile, \"Catalog Record: %\" PRIuINUM \"\\n\", inum);\n    tsk_fprintf(hFile, \"%sAllocated\\n\",\n        (fs_file->meta->flags & TSK_FS_META_FLAG_UNALLOC) ? \"Not \" : \"\");\n\n    tsk_fprintf(hFile, \"Type:\\t\");\n    if (fs_file->meta->type == TSK_FS_META_TYPE_REG)\n        tsk_fprintf(hFile, \"File\\n\");\n    else if (TSK_FS_IS_DIR_META(fs_file->meta->type))\n        tsk_fprintf(hFile, \"Folder\\n\");\n    else\n        tsk_fprintf(hFile, \"\\n\");\n\n    tsk_fs_meta_make_ls(fs_file->meta, hfs_mode, sizeof(hfs_mode));\n    tsk_fprintf(hFile, \"Mode:\\t%s\\n\", hfs_mode);\n    tsk_fprintf(hFile, \"Size:\\t%\" PRIuOFF \"\\n\", fs_file->meta->size);\n\n    if (fs_file->meta->link)\n        tsk_fprintf(hFile, \"Symbolic link to:\\t%s\\n\", fs_file->meta->link);\n\n    tsk_fprintf(hFile, \"uid \/ gid: %\" PRIuUID \" \/ %\" PRIuGID \"\\n\",\n        fs_file->meta->uid, fs_file->meta->gid);\n\n    tsk_fprintf(hFile, \"Link count:\\t%d\\n\", fs_file->meta->nlink);\n\n    if (hfs_cat_file_lookup(hfs, inum, &entry, TRUE) == 0) {\n        hfs_uni_str *nm = &entry.thread.name;\n        char name_buf[HFS_MAXNAMLEN + 1];\n        TSK_INUM_T par_cnid;    \/\/ parent CNID\n\n        tsk_fprintf(hFile, \"\\n\");\n        hfs_UTF16toUTF8(fs, nm->unicode, (int) tsk_getu16(fs->endian,\n                nm->length), &name_buf[0], HFS_MAXNAMLEN + 1,\n            HFS_U16U8_FLAG_REPLACE_SLASH | HFS_U16U8_FLAG_REPLACE_CONTROL);\n        tsk_fprintf(hFile, \"File Name: %s\\n\", name_buf);\n\n        par_cnid = tsk_getu32(fs->endian, &(entry.thread.parent_cnid));\n        if ((hfs->has_meta_dir_crtime && par_cnid == hfs->meta_dir_inum) ||\n            (hfs->has_meta_crtime && par_cnid == hfs->meta_inum)) {\n            int instr = strncmp(name_buf, \"iNode\", 5);\n            int drstr = strncmp(name_buf, \"dir_\", 4);\n\n            if (instr == 0 &&\n                hfs->has_meta_crtime && par_cnid == hfs->meta_inum) {\n                tsk_fprintf(hFile, \"This is a hard link to a file\\n\");\n            }\n            else if (drstr == 0 &&\n                hfs->has_meta_dir_crtime &&\n                par_cnid == hfs->meta_dir_inum) {\n                tsk_fprintf(hFile, \"This is a hard link to a folder.\\n\");\n            }\n        }\n\n        \/* The cat.perm union contains file-type specific values.\n         * Print them if they are relevant. *\/\n        if ((fs_file->meta->type == TSK_FS_META_TYPE_CHR) ||\n            (fs_file->meta->type == TSK_FS_META_TYPE_BLK)) {\n            tsk_fprintf(hFile, \"Device ID:\\t%\" PRIu32 \"\\n\",\n                tsk_getu32(fs->endian, entry.cat.std.perm.special.raw));\n        }\n        else if ((tsk_getu32(fs->endian,\n                    entry.cat.std.u_info.file_type) ==\n                HFS_HARDLINK_FILE_TYPE)\n            && (tsk_getu32(fs->endian,\n                    entry.cat.std.u_info.file_cr) ==\n                HFS_HARDLINK_FILE_CREATOR)) {\n            tsk_fprintf(hFile, \"Hard link inode number\\t %\" PRIu32 \"\\n\",\n                tsk_getu32(fs->endian, entry.cat.std.perm.special.inum));\n        }\n\n        tsk_fprintf(hFile, \"Admin flags: %\" PRIu8,\n            entry.cat.std.perm.a_flags);\n        if (entry.cat.std.perm.a_flags != 0) {\n            tsk_fprintf(hFile, \" - \");\n            if (entry.cat.std.perm.a_flags & HFS_PERM_AFLAG_ARCHIVED)\n                tsk_fprintf(hFile, \"archived \");\n            if (entry.cat.std.perm.a_flags & HFS_PERM_AFLAG_IMMUTABLE)\n                tsk_fprintf(hFile, \"immutable \");\n            if (entry.cat.std.perm.a_flags & HFS_PERM_AFLAG_APPEND)\n                tsk_fprintf(hFile, \"append-only \");\n        }\n        tsk_fprintf(hFile, \"\\n\");\n\n        tsk_fprintf(hFile, \"Owner flags: %\" PRIu8,\n            entry.cat.std.perm.o_flags);\n        if (entry.cat.std.perm.o_flags != 0) {\n            tsk_fprintf(hFile, \" - \");\n            if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_NODUMP)\n                tsk_fprintf(hFile, \"no-dump \");\n            if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_IMMUTABLE)\n                tsk_fprintf(hFile, \"immutable \");\n            if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_APPEND)\n                tsk_fprintf(hFile, \"append-only \");\n            if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_OPAQUE)\n                tsk_fprintf(hFile, \"opaque \");\n            if (entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_COMPRESSED)\n                tsk_fprintf(hFile, \"compressed \");\n        }\n        tsk_fprintf(hFile, \"\\n\");\n\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.flags) & HFS_FILE_FLAG_LOCKED)\n            tsk_fprintf(hFile, \"Locked\\n\");\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.flags) & HFS_FILE_FLAG_ATTR)\n            tsk_fprintf(hFile, \"Has extended attributes\\n\");\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.flags) & HFS_FILE_FLAG_ACL)\n            tsk_fprintf(hFile, \"Has security data (ACLs)\\n\");\n\n        if ( !TSK_FS_IS_DIR_META(fs_file->meta->type)){\n            int windx;          \/\/ loop index\n            tsk_fprintf(hFile,\n                \"File type:\\t%04\" PRIx32 \"  \",\n                tsk_getu32(fs->endian, entry.cat.std.u_info.file_type));\n\n            for (windx = 0; windx < 4; ++windx) {\n                uint8_t cu = entry.cat.std.u_info.file_type[windx];\n                if (cu >= 32 && cu <= 126)\n                    tsk_fprintf(hFile, \"%c\", (char) cu);\n                else\n                    tsk_fprintf(hFile, \" \");\n            }\n            tsk_fprintf(hFile, \"\\n\");\n            tsk_fprintf(hFile,\n                \"File creator:\\t%04\" PRIx32 \"  \",\n                tsk_getu32(fs->endian, entry.cat.std.u_info.file_cr));\n            for (windx = 0; windx < 4; ++windx) {\n                uint8_t cu = entry.cat.std.u_info.file_cr[windx];\n                if (cu >= 32 && cu <= 126)\n                    tsk_fprintf(hFile, \"%c\", (char) cu);\n                else\n                    tsk_fprintf(hFile, \" \");\n            }\n            tsk_fprintf(hFile, \"\\n\");\n        }                       \/\/ END if(not folder)\n\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_NAME_LOCKED)\n            tsk_fprintf(hFile, \"Name locked\\n\");\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_HAS_BUNDLE)\n            tsk_fprintf(hFile, \"Has bundle\\n\");\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_IS_INVISIBLE)\n            tsk_fprintf(hFile, \"Is invisible\\n\");\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.u_info.flags) & HFS_FINDER_FLAG_IS_ALIAS)\n            tsk_fprintf(hFile, \"Is alias\\n\");\n\n        tsk_fprintf(hFile, \"Text encoding:\\t%\" PRIx32 \" = %s\\n\",\n            tsk_getu32(fs->endian, entry.cat.std.text_enc),\n            text_encoding_name(tsk_getu32(fs->endian,\n                    entry.cat.std.text_enc)));\n\n        if (tsk_getu16(fs->endian,\n                entry.cat.std.rec_type) == HFS_FILE_RECORD) {\n            tsk_fprintf(hFile, \"Resource fork size:\\t%\" PRIu64 \"\\n\",\n                tsk_getu64(fs->endian, entry.cat.resource.logic_sz));\n        }\n    }\n\n    if (sec_skew != 0) {\n        tsk_fprintf(hFile, \"\\nAdjusted times:\\n\");\n        if (fs_file->meta->mtime)\n            fs_file->meta->mtime -= sec_skew;\n        if (fs_file->meta->atime)\n            fs_file->meta->atime -= sec_skew;\n        if (fs_file->meta->ctime)\n            fs_file->meta->ctime -= sec_skew;\n        if (fs_file->meta->crtime)\n            fs_file->meta->crtime -= sec_skew;\n        if (fs_file->meta->time2.hfs.bkup_time)\n            fs_file->meta->time2.hfs.bkup_time -= sec_skew;\n\n        tsk_fprintf(hFile, \"Created:\\t%s\\n\",\n            tsk_fs_time_to_str(fs_file->meta->crtime, timeBuf));\n        tsk_fprintf(hFile, \"Content Modified:\\t%s\\n\",\n            tsk_fs_time_to_str(fs_file->meta->mtime, timeBuf));\n        tsk_fprintf(hFile, \"Attributes Modified:\\t%s\\n\",\n            tsk_fs_time_to_str(fs_file->meta->ctime, timeBuf));\n        tsk_fprintf(hFile, \"Accessed:\\t%s\\n\",\n            tsk_fs_time_to_str(fs_file->meta->atime, timeBuf));\n        tsk_fprintf(hFile, \"Backed Up:\\t%s\\n\",\n            tsk_fs_time_to_str(fs_file->meta->time2.hfs.bkup_time,\n                timeBuf));\n\n        if (fs_file->meta->mtime)\n            fs_file->meta->mtime += sec_skew;\n        if (fs_file->meta->atime)\n            fs_file->meta->atime += sec_skew;\n        if (fs_file->meta->ctime)\n            fs_file->meta->ctime += sec_skew;\n        if (fs_file->meta->crtime)\n            fs_file->meta->crtime += sec_skew;\n        if (fs_file->meta->time2.hfs.bkup_time)\n            fs_file->meta->time2.hfs.bkup_time += sec_skew;\n\n        tsk_fprintf(hFile, \"\\nOriginal times:\\n\");\n    }\n    else {\n        tsk_fprintf(hFile, \"\\nTimes:\\n\");\n    }\n\n    tsk_fprintf(hFile, \"Created:\\t%s\\n\",\n        tsk_fs_time_to_str(fs_file->meta->crtime, timeBuf));\n    tsk_fprintf(hFile, \"Content Modified:\\t%s\\n\",\n        tsk_fs_time_to_str(fs_file->meta->mtime, timeBuf));\n    tsk_fprintf(hFile, \"Attributes Modified:\\t%s\\n\",\n        tsk_fs_time_to_str(fs_file->meta->ctime, timeBuf));\n    tsk_fprintf(hFile, \"Accessed:\\t%s\\n\",\n        tsk_fs_time_to_str(fs_file->meta->atime, timeBuf));\n    tsk_fprintf(hFile, \"Backed Up:\\t%s\\n\",\n        tsk_fs_time_to_str(fs_file->meta->time2.hfs.bkup_time, timeBuf));\n\n    if (tsk_getu16(fs->endian, entry.cat.std.rec_type) == HFS_FILE_RECORD) {\n        if (!(entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_COMPRESSED)) {\n\n            if (!(istat_flags & TSK_FS_ISTAT_RUNLIST)) {\n                tsk_fprintf(hFile, \"\\nData Fork Blocks:\\n\");\n                print.idx = 0;\n                print.hFile = hFile;\n                print.accumulating = FALSE;\n                print.startBlock = 0;\n                print.blockCount = 0;\n\n                if (tsk_fs_file_walk_type(fs_file,\n                    TSK_FS_ATTR_TYPE_HFS_DATA, HFS_FS_ATTR_ID_DATA,\n                    (TSK_FS_FILE_WALK_FLAG_AONLY |\n                        TSK_FS_FILE_WALK_FLAG_SLACK), print_addr_act,\n                        (void *)&print)) {\n                    tsk_fprintf(hFile, \"\\nError reading file data fork\\n\");\n                    tsk_error_print(hFile);\n                    tsk_error_reset();\n                }\n                else {\n                    output_print_addr(&print);\n                    if (print.idx != 0)\n                        tsk_fprintf(hFile, \"\\n\");\n                }\n            }\n        }\n\n        if (tsk_getu64(fs->endian, entry.cat.resource.logic_sz) > 0) {\n\n            if (! (istat_flags & TSK_FS_ISTAT_RUNLIST)) {\n                tsk_fprintf(hFile, \"\\nResource Fork Blocks:\\n\");\n\n                print.idx = 0;\n                print.hFile = hFile;\n                print.accumulating = FALSE;\n                print.startBlock = 0;\n                print.blockCount = 0;\n\n                if (tsk_fs_file_walk_type(fs_file,\n                    TSK_FS_ATTR_TYPE_HFS_RSRC, HFS_FS_ATTR_ID_RSRC,\n                    (TSK_FS_FILE_WALK_FLAG_AONLY |\n                        TSK_FS_FILE_WALK_FLAG_SLACK), print_addr_act,\n                        (void *)&print)) {\n                    tsk_fprintf(hFile, \"\\nError reading file resource fork\\n\");\n                    tsk_error_print(hFile);\n                    tsk_error_reset();\n                }\n                else {\n                    output_print_addr(&print);\n                    if (print.idx != 0)\n                        tsk_fprintf(hFile, \"\\n\");\n                }\n            }\n        }\n    }\n\n    (void) tsk_fs_file_attr_get(fs_file);\n\n    \/* Print all of the attributes *\/\n    tsk_fprintf(hFile, \"\\nAttributes: \\n\");\n    if (fs_file->meta->attr) {\n        int cnt, i;\n\n        cnt = tsk_fs_file_attr_getsize(fs_file);\n        for (i = 0; i < cnt; ++i) {\n            const char *type;   \/\/ type of the attribute as a string\n            const TSK_FS_ATTR *fs_attr =\n                tsk_fs_file_attr_get_idx(fs_file, i);\n            if (!fs_attr)\n                continue;\n\n            type = hfs_attrTypeName((uint32_t) fs_attr->type);\n\n\n            \/* print the layout if it is non-resident and not \"special\" *\/\n            if (fs_attr->flags & TSK_FS_ATTR_NONRES) {\n\n                tsk_fprintf(hFile,\n                    \"Type: %s (%\" PRIu32 \"-%\" PRIu16\n                    \")   Name: %s   Non-Resident%s%s%s   size: %\"\n                    PRIuOFF \"  init_size: %\" PRIuOFF \"\\n\", type,\n                    fs_attr->type, fs_attr->id,\n                    (fs_attr->name) ? fs_attr->name : \"N\/A\",\n                    (fs_attr->flags & TSK_FS_ATTR_ENC) ? \", Encrypted\" :\n                    \"\",\n                    (fs_attr->flags & TSK_FS_ATTR_COMP) ? \", Compressed\" :\n                    \"\",\n                    (fs_attr->flags & TSK_FS_ATTR_SPARSE) ? \", Sparse\" :\n                    \"\", fs_attr->size, fs_attr->nrd.initsize);\n\n                if (istat_flags & TSK_FS_ISTAT_RUNLIST) {\n                    if (tsk_fs_attr_print(fs_attr, hFile)) {\n                        tsk_fprintf(hFile, \"\\nError creating run lists\\n\");\n                        tsk_error_print(hFile);\n                        tsk_error_reset();\n                    }\n                }\n            }                   \/\/ END:  non-resident attribute case\n            else {\n                tsk_fprintf(hFile,\n                    \"Type: %s (%\" PRIu32 \"-%\" PRIu16\n                    \")   Name: %s   Resident%s%s%s   size: %\"\n                    PRIuOFF \"\\n\",\n                    type,\n                    fs_attr->type,\n                    fs_attr->id,\n                    (fs_attr->name) ? fs_attr->name : \"N\/A\",\n                    (fs_attr->flags & TSK_FS_ATTR_ENC) ? \", Encrypted\" :\n                    \"\",\n                    (fs_attr->flags & TSK_FS_ATTR_COMP) ? \", Compressed\" :\n                    \"\",\n                    (fs_attr->flags & TSK_FS_ATTR_SPARSE) ? \", Sparse\" :\n                    \"\", fs_attr->size);\n                if (fs_attr->type == TSK_FS_ATTR_TYPE_HFS_COMP_REC) {\n                    if (compressionAttr == NULL) {\n                        compressionAttr = fs_attr;\n                    }\n                    else {\n                        error_detected(TSK_ERR_FS_CORRUPT,\n                            \"hfs_istat: more than one compression attribute\");\n                        return 1;\n                    }\n                }\n            }                   \/\/ END: else (RESIDENT attribute case)\n        }                       \/\/ END:  for(;;)  loop over attributes\n    }                           \/\/ END:  if(fs_file->meta->attr is non-NULL)\n\n    if ((entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_COMPRESSED)\n        && (compressionAttr == NULL))\n        tsk_fprintf(hFile,\n            \"WARNING: Compression Flag is set, but there\"\n            \" is no compression record for this file.\\n\");\n    if (((entry.cat.std.perm.o_flags & HFS_PERM_OFLAG_COMPRESSED) == 0)\n        && (compressionAttr != NULL))\n        tsk_fprintf(hFile,\n            \"WARNING: Compression Flag is NOT set, but there\"\n            \" is a compression record for this file.\\n\");\n\n    if (compressionAttr != NULL) {\n        const TSK_FS_ATTR *fs_attr = compressionAttr;\n        ssize_t attrReadResult;\n        DECMPFS_DISK_HEADER *cmph;\n        uint32_t cmpType;\n        uint64_t uncSize;\n        uint64_t cmpSize = 0;\n\n        char *aBuf = (char *) tsk_malloc((size_t) fs_attr->size);\n        if (aBuf == NULL) {\n            error_returned(\"hfs_istat: space for a compression attribute\");\n            return 1;\n        }\n        attrReadResult = tsk_fs_attr_read(fs_attr, (TSK_OFF_T) 0,\n            aBuf, (size_t) fs_attr->size,\n            (TSK_FS_FILE_READ_FLAG_ENUM) 0x00);\n        if (attrReadResult == -1) {\n            error_returned(\"hfs_istat: reading the compression attribute\");\n            free(aBuf);\n            return 1;\n        }\n        else if (attrReadResult < fs_attr->size) {\n            error_detected(TSK_ERR_FS_READ,\n                \"hfs_istat: could not read the whole compression attribute\");\n            free(aBuf);\n            return 1;\n        }\n        cmph = (DECMPFS_DISK_HEADER *) aBuf;\n        cmpType = tsk_getu32(TSK_LIT_ENDIAN, cmph->compression_type);\n        uncSize = tsk_getu64(TSK_LIT_ENDIAN, cmph->uncompressed_size);\n\n        tsk_fprintf(hFile, \"\\nCompressed File:\\n\");\n        tsk_fprintf(hFile, \"    Uncompressed size: %llu\\n\", uncSize);\n\n        switch (cmpType) {\n        case DECMPFS_TYPE_ZLIB_ATTR:\n            {\n                uint32_t off = (cmph->attr_bytes[0] & 0x0F) == 0x0F ? 17 : 16;\n                cmpSize = fs_attr->size - off;\n\n                tsk_fprintf(hFile,\n                    \"    Data follows compression record in the CMPF attribute\\n\"\n                    \"    %\" PRIu64 \" bytes of data at offset %u, %s compressed\\n\",\n                    cmpSize, off, off == 16 ? \"zlib\" : \"not\");\n            }\n            break;\n\n        case DECMPFS_TYPE_LZVN_ATTR:\n            {\n                uint32_t off = cmph->attr_bytes[0] == 0x06 ? 17 : 16;\n                cmpSize = fs_attr->size - off;\n\n                tsk_fprintf(hFile,\n                    \"    Data follows compression record in the CMPF attribute\\n\"\n                    \"    %\" PRIu64 \" bytes of data at offset %u, %s compressed\\n\",\n                    cmpSize, off, off == 16 ? \"lzvn\" : \"not\");\n            }\n            break;\n\n        case DECMPFS_TYPE_ZLIB_RSRC:\n            tsk_fprintf(hFile,\n                \"    Data is zlib compressed in the resource fork\\n\");\n            break;\n\n        case DECMPFS_TYPE_LZVN_RSRC:\n            tsk_fprintf(hFile,\n                \"    Data is lzvn compressed in the resource fork\\n\");\n            break;\n\n        default:\n            tsk_fprintf(hFile, \"    Compression type is %u: UNKNOWN\\n\",\n                cmpType);\n        }\n\n        free(aBuf);\n\n        if ((cmpType == DECMPFS_TYPE_ZLIB_RSRC ||\n             cmpType == DECMPFS_TYPE_LZVN_RSRC)\n            && (tsk_getu64(fs->endian, entry.cat.resource.logic_sz) == 0))\n            tsk_fprintf(hFile,\n                \"WARNING: Compression record indicates compressed data\"\n                \" in the RSRC Fork, but that fork is empty.\\n\");\n    }\n\n    rd = hfs_parse_resource_fork(fs_file);\n\n    if (rd != NULL) {\n        tsk_fprintf(hFile, \"\\nResources:\\n\");\n        while (rd) {\n            tsk_fprintf(hFile,\n                \"  Type: %s \\tID: %-5u \\tOffset: %-5u \\tSize: %-5u \\tName: %s\\n\",\n                rd->type, rd->id, rd->offset, rd->length, rd->name);\n            rd = rd->next;\n        }\n    }\n    free_res_descriptor(rd);\n\n    tsk_fs_file_close(fs_file);\n    return 0;\n}\n","target":0,"code_token_length":5331,"total_token_length":5567,"max_tokens_setting":6144}
+{"idx":123229,"func":"usm_rgenerate_out_msg(int msgProcModel, \/* (UNUSED) *\/\n                      u_char * globalData,      \/* IN *\/\n                      \/*\n                       * points at the msgGlobalData, which is of length given by next \n                       * parameter.  \n                       *\/\n                      size_t globalDataLen,     \/* IN - Length of msg header data.      *\/\n                      int maxMsgSize,   \/* (UNUSED) *\/\n                      int secModel,     \/* (UNUSED) *\/\n                      u_char * secEngineID,     \/* IN - Pointer snmpEngineID.           *\/\n                      size_t secEngineIDLen,    \/* IN - SnmpEngineID length.            *\/\n                      char *secName,    \/* IN - Pointer to securityName.        *\/\n                      size_t secNameLen,        \/* IN - SecurityName length.            *\/\n                      int secLevel,     \/* IN - AuthNoPriv, authPriv etc.       *\/\n                      u_char * scopedPdu,       \/* IN *\/\n                      \/*\n                       * Pointer to scopedPdu will be encrypted by USM if needed\n                       * * and written to packet buffer immediately following\n                       * * securityParameters, entire msg will be authenticated by\n                       * * USM if needed.\n                       *\/\n                      size_t scopedPduLen,      \/* IN - scopedPdu length. *\/\n                      void *secStateRef,        \/* IN *\/\n                      \/*\n                       * secStateRef, pointer to cached info provided only for\n                       * * Response, otherwise NULL.\n                       *\/\n                      u_char ** wholeMsg,       \/*  IN\/OUT  *\/\n                      \/*\n                       * Points at the pointer to the packet buffer, which might get extended\n                       * if necessary via realloc().  \n                       *\/\n                      size_t * wholeMsgLen,     \/*  IN\/OUT  *\/\n                      \/*\n                       * Length of the entire packet buffer, **not** the length of the\n                       * packet.  \n                       *\/\n                      size_t * offset   \/*  IN\/OUT  *\/\n                      \/*\n                       * Offset from the end of the packet buffer to the start of the packet,\n                       * also known as the packet length.  \n                       *\/\n    )\n{\n    size_t          msgAuthParmLen = 0;\n    u_int           boots_uint;\n    u_int           time_uint;\n    long            boots_long;\n    long            time_long;\n\n    \/*\n     * Indirection because secStateRef values override parameters.\n     * \n     * None of these are to be free'd - they are either pointing to\n     * what's in the secStateRef or to something either in the\n     * actual parameter list or the user list.\n     *\/\n\n    char           *theName = NULL;\n    u_int           theNameLength = 0;\n    u_char         *theEngineID = NULL;\n    u_int           theEngineIDLength = 0;\n    u_char         *theAuthKey = NULL;\n    u_int           theAuthKeyLength = 0;\n    const oid      *theAuthProtocol = NULL;\n    u_int           theAuthProtocolLength = 0;\n    u_char         *thePrivKey = NULL;\n    u_int           thePrivKeyLength = 0;\n    const oid      *thePrivProtocol = NULL;\n    u_int           thePrivProtocolLength = 0;\n    int             theSecLevel = 0;    \/* No defined const for bad\n                                         * value (other then err). *\/\n    size_t          salt_length = 0, save_salt_length = 0;\n    u_char          salt[BYTESIZE(USM_MAX_SALT_LENGTH)];\n    u_char          authParams[USM_MAX_AUTHSIZE];\n    u_char          iv[BYTESIZE(USM_MAX_SALT_LENGTH)];\n    size_t          sp_offset = 0, mac_offset = 0;\n    int             rc = 0;\n\n    DEBUGMSGTL((\"usm\", \"USM processing has begun (offset %d)\\n\", (int)*offset));\n\n    if (secStateRef != NULL) {\n        \/*\n         * To hush the compiler for now.  XXX \n         *\/\n        struct usmStateReference *ref\n            = (struct usmStateReference *) secStateRef;\n\n        theName = ref->usr_name;\n        theNameLength = ref->usr_name_length;\n        theEngineID = ref->usr_engine_id;\n        theEngineIDLength = ref->usr_engine_id_length;\n\n        if (!theEngineIDLength) {\n            theEngineID = secEngineID;\n            theEngineIDLength = secEngineIDLen;\n        }\n\n        theAuthProtocol = ref->usr_auth_protocol;\n        theAuthProtocolLength = ref->usr_auth_protocol_length;\n        theAuthKey = ref->usr_auth_key;\n        theAuthKeyLength = ref->usr_auth_key_length;\n        thePrivProtocol = ref->usr_priv_protocol;\n        thePrivProtocolLength = ref->usr_priv_protocol_length;\n        thePrivKey = ref->usr_priv_key;\n        thePrivKeyLength = ref->usr_priv_key_length;\n        theSecLevel = ref->usr_sec_level;\n    }\n\n    \/*\n     * * Identify the user record.\n     *\/\n    else {\n        struct usmUser *user;\n\n        \/*\n         * we do allow an unknown user name for\n         * unauthenticated requests. \n         *\/\n        if ((user = usm_get_user(secEngineID, secEngineIDLen, secName))\n            == NULL && secLevel != SNMP_SEC_LEVEL_NOAUTH) {\n            DEBUGMSGTL((\"usm\", \"Unknown User\\n\"));\n            return SNMPERR_USM_UNKNOWNSECURITYNAME;\n        }\n\n        theName = secName;\n        theNameLength = secNameLen;\n        theEngineID = secEngineID;\n        theSecLevel = secLevel;\n        theEngineIDLength = secEngineIDLen;\n        if (user) {\n            theAuthProtocol = user->authProtocol;\n            theAuthProtocolLength = user->authProtocolLen;\n            theAuthKey = user->authKey;\n            theAuthKeyLength = user->authKeyLen;\n            thePrivProtocol = user->privProtocol;\n            thePrivProtocolLength = user->privProtocolLen;\n            thePrivKey = user->privKey;\n            thePrivKeyLength = user->privKeyLen;\n        } else {\n            \/*\n             * unknown users can not do authentication (obviously) \n             *\/\n            theAuthProtocol = usmNoAuthProtocol;\n            theAuthProtocolLength =\n                sizeof(usmNoAuthProtocol) \/ sizeof(oid);\n            theAuthKey = NULL;\n            theAuthKeyLength = 0;\n            thePrivProtocol = usmNoPrivProtocol;\n            thePrivProtocolLength =\n                sizeof(usmNoPrivProtocol) \/ sizeof(oid);\n            thePrivKey = NULL;\n            thePrivKeyLength = 0;\n        }\n    }                           \/* endif -- secStateRef==NULL *\/\n\n\n    \/*\n     * From here to the end of the function, avoid reference to\n     * secName, secEngineID, secLevel, and associated lengths.\n     *\/\n\n\n    \/*\n     * Check to see if the user can use the requested sec services.\n     *\/\n    if (usm_check_secLevel_vs_protocols(theSecLevel,\n                                        theAuthProtocol,\n                                        theAuthProtocolLength,\n                                        thePrivProtocol,\n                                        thePrivProtocolLength) == 1) {\n        DEBUGMSGTL((\"usm\", \"Unsupported Security Level or type (%d)\\n\",\n                    theSecLevel));\n\n        return SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;\n    }\n\n\n    \/*\n     * * Retrieve the engine information.\n     * *\n     * * XXX    No error is declared in the EoP when sending messages to\n     * *        unknown engines, processing continues w\/ boots\/time == (0,0).\n     *\/\n    if (get_enginetime(theEngineID, theEngineIDLength,\n                       &boots_uint, &time_uint, FALSE) == -1) {\n        DEBUGMSGTL((\"usm\", \"%s\\n\", \"Failed to find engine data.\"));\n    }\n\n    boots_long = boots_uint;\n    time_long = time_uint;\n\n    if (theSecLevel == SNMP_SEC_LEVEL_AUTHPRIV) {\n        \/*\n         * Initially assume that the ciphertext will end up the same size as\n         * the plaintext plus some padding.  Really sc_encrypt ought to be able\n         * to grow this for us, a la asn_realloc_rbuild_ functions, but\n         * this will do for now.  \n         *\/\n        u_char         *ciphertext = NULL;\n        size_t          ciphertextlen = scopedPduLen + 64;\n        int             priv_type = sc_get_privtype(thePrivProtocol,\n                                                    thePrivProtocolLength);\n\n        if ((ciphertext = (u_char *) malloc(ciphertextlen)) == NULL) {\n            DEBUGMSGTL((\"usm\",\n                        \"couldn't malloc %d bytes for encrypted PDU\\n\",\n                        (int)ciphertextlen));\n            return SNMPERR_MALLOC;\n        }\n\n        \/*\n         * XXX Hardwired to seek into a 1DES private key!  \n         *\/\n#ifdef HAVE_AES\n        if (USM_CREATE_USER_PRIV_AES == (priv_type & USM_PRIV_MASK_ALG)) {\n            salt_length = BYTESIZE(USM_AES_SALT_LENGTH);\n            save_salt_length = BYTESIZE(USM_AES_SALT_LENGTH)\/2;\n            if (!thePrivKey ||\n                usm_set_aes_iv(salt, &salt_length,\n                               htonl(boots_uint), htonl(time_uint),\n                               iv) == -1) {\n                DEBUGMSGTL((\"usm\", \"Can't set AES iv.\\n\"));\n                SNMP_FREE(ciphertext);\n                return SNMPERR_USM_GENERICERROR;\n            }\n        } \n#endif\n#ifndef NETSNMP_DISABLE_DES\n        if (USM_CREATE_USER_PRIV_DES == (priv_type & USM_PRIV_MASK_ALG)) {\n            salt_length = BYTESIZE(USM_DES_SALT_LENGTH);\n            save_salt_length = BYTESIZE(USM_DES_SALT_LENGTH);\n            if (!thePrivKey || (usm_set_salt(salt, &salt_length,\n                                             thePrivKey + 8,\n                                             thePrivKeyLength - 8,\n                                             iv) == -1)) {\n                DEBUGMSGTL((\"usm\", \"Can't set DES-CBC salt.\\n\"));\n                SNMP_FREE(ciphertext);\n                return SNMPERR_USM_GENERICERROR;\n            }\n        }\n#endif\n#ifdef NETSNMP_ENABLE_TESTING_CODE\n        if (debug_is_token_registered(\"usm\/dump\") == SNMPERR_SUCCESS) {\n            dump_chunk(\"usm\/dump\", \"This data was encrypted:\",\n                       scopedPdu, scopedPduLen);\n        }\n#endif\n\n        if (sc_encrypt(thePrivProtocol, thePrivProtocolLength,\n                       thePrivKey, thePrivKeyLength,\n                       salt, salt_length,\n                       scopedPdu, scopedPduLen,\n                       ciphertext, &ciphertextlen) != SNMP_ERR_NOERROR) {\n            DEBUGMSGTL((\"usm\", \"encryption error.\\n\"));\n            SNMP_FREE(ciphertext);\n            return SNMPERR_USM_ENCRYPTIONERROR;\n        }\n\n        \/*\n         * Write the encrypted scopedPdu back into the packet buffer.  \n         *\/\n\n        *offset = 0;\n        rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,\n                                       (u_char) (ASN_UNIVERSAL |\n                                                 ASN_PRIMITIVE |\n                                                 ASN_OCTET_STR),\n                                       ciphertext, ciphertextlen);\n        if (rc == 0) {\n            DEBUGMSGTL((\"usm\", \"Encryption failed.\\n\"));\n            SNMP_FREE(ciphertext);\n            return SNMPERR_USM_ENCRYPTIONERROR;\n        }\n\n#ifdef NETSNMP_ENABLE_TESTING_CODE\n        if (debug_is_token_registered(\"usm\/dump\") == SNMPERR_SUCCESS) {\n            dump_chunk(\"usm\/dump\", \"salt + Encrypted form: \", salt,\n                       salt_length);\n            dump_chunk(\"usm\/dump\", \"wholeMsg:\",\n                       (*wholeMsg + *wholeMsgLen - *offset), *offset);\n        }\n#endif\n\n        DEBUGMSGTL((\"usm\", \"Encryption successful.\\n\"));\n        SNMP_FREE(ciphertext);\n    } else {\n        \/*\n         * theSecLevel != SNMP_SEC_LEVEL_AUTHPRIV  \n         *\/\n    }\n\n    \/*\n     * Start encoding the msgSecurityParameters.  \n     *\/\n\n    sp_offset = *offset;\n\n    DEBUGDUMPHEADER(\"send\", \"msgPrivacyParameters\");\n    \/*\n     * msgPrivacyParameters (warning: assumes DES salt).  \n     *\/\n    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,\n                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE\n                                             | ASN_OCTET_STR),\n                                   iv,\n                                   save_salt_length);\n    DEBUGINDENTLESS();\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building privParams failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    DEBUGDUMPHEADER(\"send\", \"msgAuthenticationParameters\");\n    \/*\n     * msgAuthenticationParameters.\n     *\/\n    if (theSecLevel == SNMP_SEC_LEVEL_AUTHNOPRIV\n        || theSecLevel == SNMP_SEC_LEVEL_AUTHPRIV) {\n        memset(authParams, 0, sizeof(authParams));\n        msgAuthParmLen =\n            sc_get_auth_maclen(sc_get_authtype(theAuthProtocol,\n                                               theAuthProtocolLength));\n    }\n\n    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,\n                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE\n                                             | ASN_OCTET_STR), authParams,\n                                   msgAuthParmLen);\n    DEBUGINDENTLESS();\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building authParams failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * Remember where to put the actual HMAC we calculate later on.  An\n     * encoded OCTET STRING of length USM_MD5_AND_SHA_AUTH_LEN has an ASN.1\n     * header of length 2, hence the fudge factor.  This works as long as\n     * auth lengths stay < 127.\n     *\/\n    mac_offset = *offset - 2;\n\n    \/*\n     * msgUserName.  \n     *\/\n    DEBUGDUMPHEADER(\"send\", \"msgUserName\");\n    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,\n                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE\n                                             | ASN_OCTET_STR),\n                                   (u_char *) theName, theNameLength);\n    DEBUGINDENTLESS();\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building authParams failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * msgAuthoritativeEngineTime.  \n     *\/\n    DEBUGDUMPHEADER(\"send\", \"msgAuthoritativeEngineTime\");\n    rc = asn_realloc_rbuild_int(wholeMsg, wholeMsgLen, offset, 1,\n                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |\n                                          ASN_INTEGER), &time_long,\n                                sizeof(long));\n    DEBUGINDENTLESS();\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\",\n                    \"building msgAuthoritativeEngineTime failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * msgAuthoritativeEngineBoots.  \n     *\/\n    DEBUGDUMPHEADER(\"send\", \"msgAuthoritativeEngineBoots\");\n    rc = asn_realloc_rbuild_int(wholeMsg, wholeMsgLen, offset, 1,\n                                (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE |\n                                          ASN_INTEGER), &boots_long,\n                                sizeof(long));\n    DEBUGINDENTLESS();\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\",\n                    \"building msgAuthoritativeEngineBoots failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    DEBUGDUMPHEADER(\"send\", \"msgAuthoritativeEngineID\");\n    rc = asn_realloc_rbuild_string(wholeMsg, wholeMsgLen, offset, 1,\n                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE\n                                             | ASN_OCTET_STR), theEngineID,\n                                   theEngineIDLength);\n    DEBUGINDENTLESS();\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building msgAuthoritativeEngineID failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * USM msgSecurityParameters sequence header  \n     *\/\n    rc = asn_realloc_rbuild_sequence(wholeMsg, wholeMsgLen, offset, 1,\n                                     (u_char) (ASN_SEQUENCE |\n                                               ASN_CONSTRUCTOR),\n                                     *offset - sp_offset);\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building usm security parameters failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * msgSecurityParameters OCTET STRING wrapper.  \n     *\/\n    rc = asn_realloc_rbuild_header(wholeMsg, wholeMsgLen, offset, 1,\n                                   (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE\n                                             | ASN_OCTET_STR),\n                                   *offset - sp_offset);\n\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building msgSecurityParameters failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * Copy in the msgGlobalData and msgVersion.  \n     *\/\n    while ((*wholeMsgLen - *offset) < globalDataLen) {\n        if (!asn_realloc(wholeMsg, wholeMsgLen)) {\n            DEBUGMSGTL((\"usm\", \"building global data failed.\\n\"));\n            return SNMPERR_TOO_LONG;\n        }\n    }\n\n    *offset += globalDataLen;\n    memcpy(*wholeMsg + *wholeMsgLen - *offset, globalData, globalDataLen);\n\n    \/*\n     * Total packet sequence.  \n     *\/\n    rc = asn_realloc_rbuild_sequence(wholeMsg, wholeMsgLen, offset, 1,\n                                     (u_char) (ASN_SEQUENCE |\n                                               ASN_CONSTRUCTOR), *offset);\n    if (rc == 0) {\n        DEBUGMSGTL((\"usm\", \"building master packet sequence failed.\\n\"));\n        return SNMPERR_TOO_LONG;\n    }\n\n    \/*\n     * Now consider \/ do authentication.  \n     *\/\n\n    if (theSecLevel == SNMP_SEC_LEVEL_AUTHNOPRIV ||\n        theSecLevel == SNMP_SEC_LEVEL_AUTHPRIV) {\n        size_t          temp_sig_len = msgAuthParmLen;\n        u_char         *temp_sig = (u_char *) malloc(temp_sig_len);\n        u_char         *proto_msg = *wholeMsg + *wholeMsgLen - *offset;\n        size_t          proto_msg_len = *offset;\n\n\n        if (temp_sig == NULL) {\n            DEBUGMSGTL((\"usm\", \"Out of memory.\\n\"));\n            return SNMPERR_USM_GENERICERROR;\n        }\n\n        if (sc_generate_keyed_hash(theAuthProtocol, theAuthProtocolLength,\n                                   theAuthKey, theAuthKeyLength,\n                                   proto_msg, proto_msg_len,\n                                   temp_sig, &temp_sig_len)\n            != SNMP_ERR_NOERROR) {\n            SNMP_FREE(temp_sig);\n            DEBUGMSGTL((\"usm\", \"Signing failed.\\n\"));\n            return SNMPERR_USM_AUTHENTICATIONFAILURE;\n        }\n\n        if (temp_sig_len != msgAuthParmLen) {\n            SNMP_FREE(temp_sig);\n            DEBUGMSGTL((\"usm\", \"Signing lengths failed.\\n\"));\n            return SNMPERR_USM_AUTHENTICATIONFAILURE;\n        }\n\n        memcpy(*wholeMsg + *wholeMsgLen - mac_offset, temp_sig,\n               msgAuthParmLen);\n        SNMP_FREE(temp_sig);\n    }\n    \/*\n     * endif -- create keyed hash \n     *\/\n    DEBUGMSGTL((\"usm\", \"USM processing completed.\\n\"));\n    return SNMPERR_SUCCESS;\n}                               \/* end usm_rgenerate_out_msg() *\/","target":0,"code_token_length":4175,"total_token_length":4411,"max_tokens_setting":6144}
+{"idx":255223,"func":"int   MirrorJob::Do()\n{\n   int\t res;\n   int\t m=STALL;\n   FileInfo *file;\n   Job\t *j;\n\n   switch(state)\n   {\n   case(INITIAL_STATE):\n      remove_this_source_dir=(remove_source_dirs && source_dir.last_char()!='\/');\n      if(!strcmp(target_dir,\".\") || !strcmp(target_dir,\"..\") || (FlagSet(SCAN_ALL_FIRST) && parent_mirror))\n\t create_target_dir=false;\n\n      source_session->Chdir(source_dir);\n      source_redirections=0;\n      source_session->Roll();\n      set_state(CHANGING_DIR_SOURCE);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(CHANGING_DIR_SOURCE):\n      HandleChdir(source_session,source_redirections);\n      if(state!=CHANGING_DIR_SOURCE)\n\t return MOVED;\n      if(source_session->IsOpen())\n\t return m;\n\n      source_dir.set(source_session->GetCwd().GetDirectory());\n\n   pre_MAKE_TARGET_DIR:\n   {\n      if(!create_target_dir)\n\t goto pre_CHANGING_DIR_TARGET;\n      if(target_is_local)\n      {\n\t struct stat st;\n\t if((FlagSet(RETR_SYMLINKS)?stat:lstat)(target_dir,&st)!=-1)\n\t {\n\t    if(S_ISDIR(st.st_mode))\n\t    {\n\t       \/\/ try to enable write access\n\t       \/\/ only if not enabled as chmod can clear sgid flags on directories\n\t       if(!script_only && (st.st_mode!=(st.st_mode|0700)))\n\t\t  chmod(target_dir,st.st_mode|0700);\n\t       create_target_dir=false;\n\t       goto pre_CHANGING_DIR_TARGET;\n\t    }\n\t    else\n\t    {\n\t       Report(_(\"Removing old local file `%s'\"),target_dir.get());\n\t       if(script)\n\t       {\n\t\t  ArgV args(\"rm\");\n\t\t  args.Append(target_session->GetFileURL(target_dir));\n\t\t  xstring_ca cmd(args.CombineQuoted());\n\t\t  fprintf(script,\"%s\\n\",cmd.get());\n\t       }\n\t       if(!script_only)\n\t       {\n\t\t  if(remove(target_dir)==-1)\n\t\t     eprintf(\"mirror: remove(%s): %s\\n\",target_dir.get(),strerror(errno));\n\t       }\n\t    }\n\t }\n      }\n\n      if(FlagSet(DEPTH_FIRST))\n\t goto pre_GETTING_LIST_INFO;\n\n      if(target_relative_dir)\n\t Report(_(\"Making directory `%s'\"),target_relative_dir.get());\n      bool mkdir_p=(parent_mirror==0 || parent_mirror->create_target_dir);\n      if(script)\n      {\n\t ArgV args(\"mkdir\");\n\t if(mkdir_p)\n\t    args.Append(\"-p\");\n\t args.Append(target_session->GetFileURL(target_dir));\n\t xstring_ca cmd(args.CombineQuoted());\n\t fprintf(script,\"%s\\n\",cmd.get());\n\t if(script_only)\n\t    goto pre_CHANGING_DIR_TARGET;\n      }\n      target_session->Mkdir(target_dir,mkdir_p);\n      set_state(MAKE_TARGET_DIR);\n      m=MOVED;\n   }\n      \/*fallthrough*\/\n   case(MAKE_TARGET_DIR):\n      res=target_session->Done();\n      if(res==FA::IN_PROGRESS)\n\t return m;\n      target_session->Close();\n      create_target_dir=false;\n\n   pre_CHANGING_DIR_TARGET:\n      target_session->Chdir(target_dir);\n      target_redirections=0;\n      target_session->Roll();\n      set_state(CHANGING_DIR_TARGET);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(CHANGING_DIR_TARGET):\n      HandleChdir(target_session,target_redirections);\n      if(state!=CHANGING_DIR_TARGET)\n\t return MOVED;\n      if(target_session->IsOpen())\n\t return m;\n      create_target_dir=false;\n\n      target_dir.set(target_session->GetCwd().GetDirectory());\n\n   pre_GETTING_LIST_INFO:\n      set_state(GETTING_LIST_INFO);\n      m=MOVED;\n      if(!source_set)\n\t HandleListInfoCreation(source_session,source_list_info,source_relative_dir);\n      if(!target_set && !create_target_dir\n      && (!FlagSet(DEPTH_FIRST) || FlagSet(ONLY_EXISTING))\n      && !(FlagSet(TARGET_FLAT) && parent_mirror))\n\t HandleListInfoCreation(target_session,target_list_info,target_relative_dir);\n      if(state!=GETTING_LIST_INFO)\n      {\n\t source_list_info=0;\n\t target_list_info=0;\n      }\n      return m;\t  \/\/ give time to other tasks\n   case(GETTING_LIST_INFO):\n      HandleListInfo(source_list_info,source_set);\n      HandleListInfo(target_list_info,target_set,&target_set_excluded);\n      if(state!=GETTING_LIST_INFO)\n\t return MOVED;\n      if(source_list_info || target_list_info)\n\t return m;\n\n      MirrorFinished(); \/\/ leave room for transfers.\n\n      if(FlagSet(DEPTH_FIRST) && source_set && !target_set)\n      {\n\t \/\/ transfer directories first\n\t InitSets();\n\t to_transfer->Unsort();\n\t to_transfer->SubtractNotDirs();\n\t goto pre_WAITING_FOR_TRANSFER;\n      }\n\n      \/\/ now we have both target and source file sets.\n      if(parent_mirror)\n\t stats.dirs++;\n\n      if(FlagSet(SCAN_ALL_FIRST) && parent_mirror)\n      {\n\t source_set->PrependPath(source_relative_dir);\n\t if(root_mirror->source_set_recursive)\n\t    root_mirror->source_set_recursive->Merge(source_set);\n\t else\n\t    root_mirror->source_set_recursive=source_set.borrow();\n\t if(target_set) {\n\t    target_set->PrependPath(target_relative_dir);\n\t    if(root_mirror->target_set_recursive)\n\t       root_mirror->target_set_recursive->Merge(target_set);\n\t    else\n\t       root_mirror->target_set_recursive=target_set.borrow();\n\t }\n\t if(target_set_excluded) {\n\t    target_set_excluded->PrependPath(target_relative_dir);\n\t    if(root_mirror->target_set_excluded)\n\t       root_mirror->target_set_excluded->Merge(target_set_excluded);\n\t    else\n\t       root_mirror->target_set_excluded=target_set_excluded.borrow();\n\t }\n\t root_mirror->stats.dirs++;\n\t transfer_count++; \/\/ parent mirror will decrement it.\n\t goto pre_DONE;\n      }\n\n      if(source_set_recursive) {\n\t source_set->Merge(source_set_recursive);\n\t source_set_recursive=0;\n      }\n      if(target_set_recursive) {\n\t target_set->Merge(target_set_recursive);\n\t target_set_recursive=0;\n      }\n      InitSets();\n\n      to_transfer->CountBytes(&bytes_to_transfer);\n      if(parent_mirror)\n\t parent_mirror->AddBytesToTransfer(bytes_to_transfer);\n\n      to_rm->Count(&stats.del_dirs,&stats.del_files,&stats.del_symlinks,&stats.del_files);\n      to_rm->rewind();\n      to_rm_mismatched->Count(&stats.del_dirs,&stats.del_files,&stats.del_symlinks,&stats.del_files);\n      to_rm_mismatched->rewind();\n\n      target_set->Merge(target_set_excluded);\n      target_set_excluded=0;\n\n      set_state(TARGET_REMOVE_OLD_FIRST);\n      goto TARGET_REMOVE_OLD_FIRST_label;\n\n   pre_TARGET_MKDIR:\n      if(!to_mkdir)\n\t goto pre_WAITING_FOR_TRANSFER;\n      to_mkdir->rewind();\n      set_state(TARGET_MKDIR);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(TARGET_MKDIR):\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t JobFinished(j);\n\t m=MOVED;\n      }\n      if(max_error_count>0 && stats.error_count>=max_error_count)\n\t goto pre_FINISHING;\n      while(transfer_countcurr();\n\t if(!file)\n\t    goto pre_WAITING_FOR_TRANSFER;\n\t to_mkdir->next();\n\t if(!file->TypeIs(file->DIRECTORY))\n\t    continue;\n\t if(script)\n\t    fprintf(script,\"mkdir %s\\n\",target_session->GetFileURL(file->name).get());\n\t if(!script_only)\n\t {\n\t    ArgV *a=new ArgV(\"mkdir\");\n\t    a->Append(file->name);\n\t    mkdirJob *mkj=new mkdirJob(target_session->Clone(),a);\n\t    a->CombineTo(mkj->cmdline);\n\t    JobStarted(mkj);\n\t    m=MOVED;\n\t }\n      }\n      break;\n\n   pre_WAITING_FOR_TRANSFER:\n      to_transfer->rewind();\n      set_state(WAITING_FOR_TRANSFER);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(WAITING_FOR_TRANSFER):\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t TransferFinished(j);\n\t m=MOVED;\n      }\n      if(max_error_count>0 && stats.error_count>=max_error_count)\n\t goto pre_FINISHING;\n      while(transfer_countcurr();\n\t if(!file)\n\t {\n\t    \/\/ go to the next step only when all transfers have finished\n\t    if(waiting_num>0)\n\t       break;\n\t    if(FlagSet(DEPTH_FIRST))\n\t    {\n\t       \/\/ we have been in the depth, don't go there again\n\t       SetFlags(DEPTH_FIRST,false);\n\t       SetFlags(NO_RECURSION,true);\n\n\t       \/\/ if we have not created any subdirs and there are only subdirs,\n\t       \/\/ then the directory would be empty - skip it.\n\t       if(FlagSet(NO_EMPTY_DIRS) && stats.dirs==0 && only_dirs)\n\t\t  goto pre_FINISHING_FIX_LOCAL;\n\n\t       MirrorStarted();\n\t       goto pre_MAKE_TARGET_DIR;\n\t    }\n\t    goto pre_TARGET_REMOVE_OLD;\n\t }\n\t HandleFile(file);\n\t to_transfer->next();\n\t m=MOVED;\n      }\n      break;\n\n   pre_TARGET_REMOVE_OLD:\n      if(FlagSet(REMOVE_FIRST))\n\t goto pre_TARGET_CHMOD;\n      set_state(TARGET_REMOVE_OLD);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(TARGET_REMOVE_OLD):\n   case(TARGET_REMOVE_OLD_FIRST):\n   TARGET_REMOVE_OLD_FIRST_label:\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t JobFinished(j);\n\t m=MOVED;\n      }\n      if(max_error_count>0 && stats.error_count>=max_error_count)\n\t goto pre_FINISHING;\n      while(transfer_countcurr();\n\t    to_rm_mismatched->next();\n\t }\n\t if(!file && (state==TARGET_REMOVE_OLD || FlagSet(REMOVE_FIRST)))\n\t {\n\t    file=to_rm->curr();\n\t    to_rm->next();\n\t }\n\t if(!file)\n\t {\n\t    if(waiting_num>0)\n\t       break;\n\t    if(state==TARGET_REMOVE_OLD)\n\t       goto pre_TARGET_CHMOD;\n\t    goto pre_TARGET_MKDIR;\n\t }\n\t if(!FlagSet(DELETE))\n\t {\n\t    if(FlagSet(REPORT_NOT_DELETED))\n\t    {\n\t       const char *target_name_rel=dir_file(target_relative_dir,file->name);\n\t       if(file->TypeIs(file->DIRECTORY))\n\t\t  Report(_(\"Old directory `%s' is not removed\"),target_name_rel);\n\t       else\n\t\t  Report(_(\"Old file `%s' is not removed\"),target_name_rel);\n\t    }\n\t    continue;\n\t }\n\t if(script)\n\t {\n\t    ArgV args(\"rm\");\n\t    if(file->TypeIs(file->DIRECTORY))\n\t    {\n\t       if(recursion_mode==RECURSION_NEVER)\n\t\t  args.setarg(0,\"rmdir\");\n\t       else\n\t\t  args.Append(\"-r\");\n\t    }\n\t    args.Append(target_session->GetFileURL(file->name));\n\t    xstring_ca cmd(args.CombineQuoted());\n\t    fprintf(script,\"%s\\n\",cmd.get());\n\t }\n\t if(!script_only)\n\t {\n\t    ArgV *args=new ArgV(\"rm\");\n\t    args->Append(file->name);\n\t    args->seek(1);\n\t    rmJob *j=new rmJob(target_session->Clone(),args);\n\t    args->CombineTo(j->cmdline);\n\t    JobStarted(j);\n\t    if(file->TypeIs(file->DIRECTORY))\n\t    {\n\t       if(recursion_mode==RECURSION_NEVER)\n\t       {\n\t\t  args->setarg(0,\"rmdir\");\n\t\t  j->Rmdir();\n\t       }\n\t       else\n\t\t  j->Recurse();\n\t    }\n\t }\n\t const char *target_name_rel=dir_file(target_relative_dir,file->name);\n\t if(file->TypeIs(file->DIRECTORY))\n\t    Report(_(\"Removing old directory `%s'\"),target_name_rel);\n\t else\n\t    Report(_(\"Removing old file `%s'\"),target_name_rel);\n      }\n      break;\n\n   pre_TARGET_CHMOD:\n      if(FlagSet(NO_PERMS))\n\t goto pre_FINISHING_FIX_LOCAL;\n\n      to_transfer->rewind();\n      if(FlagSet(TARGET_FLAT))\n\t to_transfer->Sort(FileSet::BYNAME_FLAT);\n      set_state(TARGET_CHMOD);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(TARGET_CHMOD):\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t JobFinished(j);\n\t m=MOVED;\n      }\n      if(max_error_count>0 && stats.error_count>=max_error_count)\n\t goto pre_FINISHING;\n      while(transfer_countcurr();\n\t if(!file)\n\t    goto pre_FINISHING_FIX_LOCAL;\n\t to_transfer->next();\n\t if(file->TypeIs(file->SYMLINK))\n\t    continue;\n\t if(!file->Has(file->MODE))\n\t    continue;\n\t mode_t mode_mask=get_mode_mask();\n\t mode_t def_mode=(file->TypeIs(file->DIRECTORY)?0775:0664)&~mode_mask;\n\t if(target_is_local && file->mode==def_mode)\n\t {\n\t    struct stat st;\n\t    if(!target_is_local || lstat(dir_file(target_dir,file->name),&st)==-1)\n\t       continue;\n\t    if((st.st_mode&07777)==(file->mode&~mode_mask))\n\t       continue;\n\t }\n\t FileInfo *target=target_set->FindByName(file->name);\n\t if(target && target->filetype==file->DIRECTORY && file->filetype==file->DIRECTORY\n\t && target->mode==(file->mode&~mode_mask) && (target->mode&0200))\n\t    continue;\n\t if(script)\n\t {\n\t    ArgV args(\"chmod\");\n\t    args.Append(xstring::format(\"%03lo\",(unsigned long)(file->mode&~mode_mask)));\n\t    args.Append(target_session->GetFileURL(file->name));\n\t    xstring_ca cmd(args.CombineQuoted());\n\t    fprintf(script,\"%s\\n\",cmd.get());\n\t }\n\t if(!script_only)\n\t {\n\t    ArgV *a=new ArgV(\"chmod\");\n\t    a->Append(file->name);\n\t    a->seek(1);\n\t    ChmodJob *cj=new ChmodJob(target_session->Clone(),\n\t\t\t\t file->mode&~mode_mask,a);\n\t    a->CombineTo(cj->cmdline);\n\t    if(!verbose_report)\n\t       cj->BeQuiet(); \/\/ chmod is not supported on all servers; be quiet.\n\t    JobStarted(cj);\n\t    m=MOVED;\n\t }\n      }\n      break;\n\n   pre_FINISHING_FIX_LOCAL:\n      if(target_is_local && !script_only)     \/\/ FIXME\n      {\n\t const bool flat=FlagSet(TARGET_FLAT);\n\t to_transfer->Sort(FileSet::BYNAME_FLAT);\n\t to_transfer->LocalUtime(target_dir,\/*only_dirs=*\/true,flat);\n\t if(FlagSet(ALLOW_CHOWN))\n\t    to_transfer->LocalChown(target_dir,flat);\n\t if(!FlagSet(NO_PERMS) && same)\n\t    same->LocalChmod(target_dir,get_mode_mask(),flat);\n\t if(FlagSet(ALLOW_CHOWN) && same)\n\t    same->LocalChown(target_dir,flat);\n      }\n      if(remove_source_files && (same || to_rm_src))\n\t goto pre_SOURCE_REMOVING_SAME;\n   pre_FINISHING:\n      set_state(FINISHING);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(FINISHING):\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t JobFinished(j);\n\t m=MOVED;\n      }\n      if(waiting_num>0)\n\t break;\n\n      \/\/ all jobs finished.\n      if(remove_this_source_dir) {\n\t \/\/ remove source directory once.\n\t remove_this_source_dir=false;\n\t if(script)\n\t {\n\t    ArgV args(\"rmdir\");\n\t    args.Append(source_session->GetFileURL(source_dir));\n\t    xstring_ca cmd(args.CombineQuoted());\n\t    fprintf(script,\"%s\\n\",cmd.get());\n\t }\n\t if(!script_only)\n\t {\n\t    ArgV *args=new ArgV(\"rmdir\");\n\t    args->Append(source_dir);\n\t    args->seek(1);\n\t    rmJob *j=new rmJob(source_session->Clone(),args);\n\t    args->CombineTo(j->cmdline);\n\t    j->Rmdir();\n\t    JobStarted(j);\n\t }\n\t if(source_relative_dir)\n\t    Report(_(\"Removing source directory `%s'\"),source_relative_dir.get());\n\t m=MOVED;\n\t break;\n      }\n\n      \/\/ all jobs finished and src dir removed, if needed.\n\n      transfer_count++; \/\/ parent mirror will decrement it.\n      if(parent_mirror)\n\t parent_mirror->stats.Add(stats);\n      else\n      {\n\t if(stats.HaveSomethingDone(flags) && on_change)\n\t {\n\t    CmdExec *exec=new CmdExec(source_session->Clone(),0);\n\t    AddWaiting(exec);\n\t    exec->FeedCmd(on_change);\n\t    exec->FeedCmd(\"\\n\");\n\t    set_state(LAST_EXEC);\n\t    break;\n\t }\n      }\n      goto pre_DONE;\n\n   pre_SOURCE_REMOVING_SAME:\n      if(!same)\n\t same=to_rm_src.borrow();\n      else if(to_rm_src)\n\t same->Merge(to_rm_src);\n      same->rewind();\n      set_state(SOURCE_REMOVING_SAME);\n      m=MOVED;\n      \/*fallthrough*\/\n   case(SOURCE_REMOVING_SAME):\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t JobFinished(j);\n\t m=MOVED;\n      }\n      if(max_error_count>0 && stats.error_count>=max_error_count)\n\t goto pre_FINISHING;\n      while(transfer_countcurr();\n\t same->next();\n\t if(!file)\n\t    goto pre_FINISHING;\n\t if(file->TypeIs(file->DIRECTORY))\n\t    continue;\n\t if(script)\n\t {\n\t    ArgV args(\"rm\");\n\t    args.Append(source_session->GetFileURL(file->name));\n\t    xstring_ca cmd(args.CombineQuoted());\n\t    fprintf(script,\"%s\\n\",cmd.get());\n\t }\n\t if(!script_only)\n\t {\n\t    ArgV *args=new ArgV(\"rm\");\n\t    args->Append(file->name);\n\t    args->seek(1);\n\t    rmJob *j=new rmJob(source_session->Clone(),args);\n\t    args->CombineTo(j->cmdline);\n\t    JobStarted(j);\n\t }\n\t const char *source_name_rel=dir_file(source_relative_dir,file->name);\n\t Report(_(\"Removing source file `%s'\"),source_name_rel);\n      }\n      break;\n\n   case(LAST_EXEC):\n      while((j=FindDoneAwaitedJob())!=0)\n      {\n\t RemoveWaiting(j);\n\t Delete(j);\n\t m=MOVED;\n      }\n      if(waiting_num>0)\n\t break;\n   pre_DONE:\n      set_state(DONE);\n      m=MOVED;\n      bytes_transferred=0;\n      if(!parent_mirror && FlagSet(LOOP) && stats.HaveSomethingDone(flags) && !stats.error_count)\n      {\n\t PrintStatus(0,\"\");\n\t printf(_(\"Retrying mirror...\\n\"));\n\t stats.Reset();\n\t source_set=0;\n\t target_set=0;\n\t goto pre_GETTING_LIST_INFO;\n      }\n      \/*fallthrough*\/\n   case(DONE):\n      break;\n   }\n   \/\/ give direct parent priority over grand-parents.\n   if(transfer_countRoll();\n   return m;\n}","target":1,"code_token_length":4231,"total_token_length":4467,"max_tokens_setting":6144}
+{"idx":508909,"func":"int ssl3_accept(SSL *s)\n{\n    BUF_MEM *buf;\n    unsigned long alg_k, Time = (unsigned long)time(NULL);\n    void (*cb) (const SSL *ssl, int type, int val) = NULL;\n    int ret = -1;\n    int new_state, state, skip = 0;\n\n    RAND_add(&Time, sizeof(Time), 0);\n    ERR_clear_error();\n    clear_sys_error();\n\n    if (s->info_callback != NULL)\n        cb = s->info_callback;\n    else if (s->ctx->info_callback != NULL)\n        cb = s->ctx->info_callback;\n\n    \/* init things to blank *\/\n    s->in_handshake++;\n    if (!SSL_in_init(s) || SSL_in_before(s))\n        SSL_clear(s);\n\n    if (s->cert == NULL) {\n        SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET);\n        return (-1);\n    }\n#ifndef OPENSSL_NO_HEARTBEATS\n    \/*\n     * If we're awaiting a HeartbeatResponse, pretend we already got and\n     * don't await it anymore, because Heartbeats don't make sense during\n     * handshakes anyway.\n     *\/\n    if (s->tlsext_hb_pending) {\n        s->tlsext_hb_pending = 0;\n        s->tlsext_hb_seq++;\n    }\n#endif\n\n    for (;;) {\n        state = s->state;\n\n        switch (s->state) {\n        case SSL_ST_RENEGOTIATE:\n            s->renegotiate = 1;\n            \/* s->state=SSL_ST_ACCEPT; *\/\n\n        case SSL_ST_BEFORE:\n        case SSL_ST_ACCEPT:\n        case SSL_ST_BEFORE | SSL_ST_ACCEPT:\n        case SSL_ST_OK | SSL_ST_ACCEPT:\n\n            s->server = 1;\n            if (cb != NULL)\n                cb(s, SSL_CB_HANDSHAKE_START, 1);\n\n            if ((s->version >> 8) != 3) {\n                SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);\n                s->state = SSL_ST_ERR;\n                return -1;\n            }\n            s->type = SSL_ST_ACCEPT;\n\n            if (s->init_buf == NULL) {\n                if ((buf = BUF_MEM_new()) == NULL) {\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n                if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {\n                    BUF_MEM_free(buf);\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n                s->init_buf = buf;\n            }\n\n            if (!ssl3_setup_buffers(s)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n\n            s->init_num = 0;\n            s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY;\n            s->s3->flags &= ~SSL3_FLAGS_CCS_OK;\n            \/*\n             * Should have been reset by ssl3_get_finished, too.\n             *\/\n            s->s3->change_cipher_spec = 0;\n\n            if (s->state != SSL_ST_RENEGOTIATE) {\n                \/*\n                 * Ok, we now need to push on a buffering BIO so that the\n                 * output is sent in a way that TCP likes :-)\n                 *\/\n                if (!ssl_init_wbio_buffer(s, 1)) {\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n\n                ssl3_init_finished_mac(s);\n                s->state = SSL3_ST_SR_CLNT_HELLO_A;\n                s->ctx->stats.sess_accept++;\n            } else if (!s->s3->send_connection_binding &&\n                       !(s->options &\n                         SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {\n                \/*\n                 * Server attempting to renegotiate with client that doesn't\n                 * support secure renegotiation.\n                 *\/\n                SSLerr(SSL_F_SSL3_ACCEPT,\n                       SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            } else {\n                \/*\n                 * s->state == SSL_ST_RENEGOTIATE, we will just send a\n                 * HelloRequest\n                 *\/\n                s->ctx->stats.sess_accept_renegotiate++;\n                s->state = SSL3_ST_SW_HELLO_REQ_A;\n            }\n            break;\n\n        case SSL3_ST_SW_HELLO_REQ_A:\n        case SSL3_ST_SW_HELLO_REQ_B:\n\n            s->shutdown = 0;\n            ret = ssl3_send_hello_request(s);\n            if (ret <= 0)\n                goto end;\n            s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C;\n            s->state = SSL3_ST_SW_FLUSH;\n            s->init_num = 0;\n\n            ssl3_init_finished_mac(s);\n            break;\n\n        case SSL3_ST_SW_HELLO_REQ_C:\n            s->state = SSL_ST_OK;\n            break;\n\n        case SSL3_ST_SR_CLNT_HELLO_A:\n        case SSL3_ST_SR_CLNT_HELLO_B:\n        case SSL3_ST_SR_CLNT_HELLO_C:\n\n            s->shutdown = 0;\n            ret = ssl3_get_client_hello(s);\n            if (ret <= 0)\n                goto end;\n#ifndef OPENSSL_NO_SRP\n            s->state = SSL3_ST_SR_CLNT_HELLO_D;\n        case SSL3_ST_SR_CLNT_HELLO_D:\n            {\n                int al;\n                if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) {\n                    \/*\n                     * callback indicates firther work to be done\n                     *\/\n                    s->rwstate = SSL_X509_LOOKUP;\n                    goto end;\n                }\n                if (ret != SSL_ERROR_NONE) {\n                    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n                    \/*\n                     * This is not really an error but the only means to for\n                     * a client to detect whether srp is supported.\n                     *\/\n                    if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY)\n                        SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT);\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n            }\n#endif\n\n            s->renegotiate = 2;\n            s->state = SSL3_ST_SW_SRVR_HELLO_A;\n            s->init_num = 0;\n            break;\n\n        case SSL3_ST_SW_SRVR_HELLO_A:\n        case SSL3_ST_SW_SRVR_HELLO_B:\n            ret = ssl3_send_server_hello(s);\n            if (ret <= 0)\n                goto end;\n#ifndef OPENSSL_NO_TLSEXT\n            if (s->hit) {\n                if (s->tlsext_ticket_expected)\n                    s->state = SSL3_ST_SW_SESSION_TICKET_A;\n                else\n                    s->state = SSL3_ST_SW_CHANGE_A;\n            }\n#else\n            if (s->hit)\n                s->state = SSL3_ST_SW_CHANGE_A;\n#endif\n            else\n                s->state = SSL3_ST_SW_CERT_A;\n            s->init_num = 0;\n            break;\n\n        case SSL3_ST_SW_CERT_A:\n        case SSL3_ST_SW_CERT_B:\n            \/* Check if it is anon DH or anon ECDH, *\/\n            \/* normal PSK or KRB5 or SRP *\/\n            if (!\n                (s->s3->tmp.\n                 new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 |\n                                               SSL_aSRP))\n&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {\n                ret = ssl3_send_server_certificate(s);\n                if (ret <= 0)\n                    goto end;\n#ifndef OPENSSL_NO_TLSEXT\n                if (s->tlsext_status_expected)\n                    s->state = SSL3_ST_SW_CERT_STATUS_A;\n                else\n                    s->state = SSL3_ST_SW_KEY_EXCH_A;\n            } else {\n                skip = 1;\n                s->state = SSL3_ST_SW_KEY_EXCH_A;\n            }\n#else\n            } else\n                skip = 1;\n\n            s->state = SSL3_ST_SW_KEY_EXCH_A;\n#endif\n            s->init_num = 0;\n            break;\n\n        case SSL3_ST_SW_KEY_EXCH_A:\n        case SSL3_ST_SW_KEY_EXCH_B:\n            alg_k = s->s3->tmp.new_cipher->algorithm_mkey;\n\n            \/*\n             * clear this, it may get reset by\n             * send_server_key_exchange\n             *\/\n            s->s3->tmp.use_rsa_tmp = 0;\n\n            \/*\n             * only send if a DH key exchange, fortezza or RSA but we have a\n             * sign only certificate PSK: may send PSK identity hints For\n             * ECC ciphersuites, we send a serverKeyExchange message only if\n             * the cipher suite is either ECDH-anon or ECDHE. In other cases,\n             * the server certificate contains the server's public key for\n             * key exchange.\n             *\/\n            if (0\n                \/*\n                 * PSK: send ServerKeyExchange if PSK identity hint if\n                 * provided\n                 *\/\n#ifndef OPENSSL_NO_PSK\n                || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint)\n#endif\n#ifndef OPENSSL_NO_SRP\n                \/* SRP: send ServerKeyExchange *\/\n                || (alg_k & SSL_kSRP)\n#endif\n                || (alg_k & SSL_kEDH)\n                || (alg_k & SSL_kEECDH)\n                || ((alg_k & SSL_kRSA)\n                    && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL\n                        || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)\n                            && EVP_PKEY_size(s->cert->pkeys\n                                             [SSL_PKEY_RSA_ENC].privatekey) *\n                            8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)\n                        )\n                    )\n                )\n                ) {\n                ret = ssl3_send_server_key_exchange(s);\n                if (ret <= 0)\n                    goto end;\n            } else\n                skip = 1;\n\n            s->state = SSL3_ST_SW_CERT_REQ_A;\n            s->init_num = 0;\n            break;\n\n        case SSL3_ST_SW_CERT_REQ_A:\n        case SSL3_ST_SW_CERT_REQ_B:\n            if (                \/* don't request cert unless asked for it: *\/\n                   !(s->verify_mode & SSL_VERIFY_PEER) ||\n                   \/*\n                    * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert\n                    * during re-negotiation:\n                    *\/\n                   ((s->session->peer != NULL) &&\n                    (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||\n                   \/*\n                    * never request cert in anonymous ciphersuites (see\n                    * section \"Certificate request\" in SSL 3 drafts and in\n                    * RFC 2246):\n                    *\/\n                   ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&\n                    \/*\n                     * ... except when the application insists on\n                     * verification (against the specs, but s3_clnt.c accepts\n                     * this for SSL 3)\n                     *\/\n                    !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||\n                   \/*\n                    * never request cert in Kerberos ciphersuites\n                    *\/\n                   (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) ||\n                   \/* don't request certificate for SRP auth *\/\n                   (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP)\n                   \/*\n                    * With normal PSK Certificates and Certificate Requests\n                    * are omitted\n                    *\/\n                   || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {\n                \/* no cert request *\/\n                skip = 1;\n                s->s3->tmp.cert_request = 0;\n                s->state = SSL3_ST_SW_SRVR_DONE_A;\n                if (s->s3->handshake_buffer) {\n                    if (!ssl3_digest_cached_records(s)) {\n                        s->state = SSL_ST_ERR;\n                        return -1;\n                    }\n                }\n            } else {\n                s->s3->tmp.cert_request = 1;\n                ret = ssl3_send_certificate_request(s);\n                if (ret <= 0)\n                    goto end;\n#ifndef NETSCAPE_HANG_BUG\n                s->state = SSL3_ST_SW_SRVR_DONE_A;\n#else\n                s->state = SSL3_ST_SW_FLUSH;\n                s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;\n#endif\n                s->init_num = 0;\n            }\n            break;\n\n        case SSL3_ST_SW_SRVR_DONE_A:\n        case SSL3_ST_SW_SRVR_DONE_B:\n            ret = ssl3_send_server_done(s);\n            if (ret <= 0)\n                goto end;\n            s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;\n            s->state = SSL3_ST_SW_FLUSH;\n            s->init_num = 0;\n            break;\n\n        case SSL3_ST_SW_FLUSH:\n\n            \/*\n             * This code originally checked to see if any data was pending\n             * using BIO_CTRL_INFO and then flushed. This caused problems as\n             * documented in PR#1939. The proposed fix doesn't completely\n             * resolve this issue as buggy implementations of\n             * BIO_CTRL_PENDING still exist. So instead we just flush\n             * unconditionally.\n             *\/\n\n            s->rwstate = SSL_WRITING;\n            if (BIO_flush(s->wbio) <= 0) {\n                ret = -1;\n                goto end;\n            }\n            s->rwstate = SSL_NOTHING;\n\n            s->state = s->s3->tmp.next_state;\n            break;\n\n        case SSL3_ST_SR_CERT_A:\n        case SSL3_ST_SR_CERT_B:\n            if (s->s3->tmp.cert_request) {\n                ret = ssl3_get_client_certificate(s);\n                if (ret <= 0)\n                    goto end;\n            }\n            s->init_num = 0;\n            s->state = SSL3_ST_SR_KEY_EXCH_A;\n            break;\n\n        case SSL3_ST_SR_KEY_EXCH_A:\n        case SSL3_ST_SR_KEY_EXCH_B:\n            ret = ssl3_get_client_key_exchange(s);\n            if (ret <= 0)\n                goto end;\n            if (ret == 2) {\n                \/*\n                 * For the ECDH ciphersuites when the client sends its ECDH\n                 * pub key in a certificate, the CertificateVerify message is\n                 * not sent. Also for GOST ciphersuites when the client uses\n                 * its key from the certificate for key exchange.\n                 *\/\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n                s->state = SSL3_ST_SR_FINISHED_A;\n#else\n                if (s->s3->next_proto_neg_seen)\n                    s->state = SSL3_ST_SR_NEXT_PROTO_A;\n                else\n                    s->state = SSL3_ST_SR_FINISHED_A;\n#endif\n                s->init_num = 0;\n            } else if (SSL_USE_SIGALGS(s)) {\n                s->state = SSL3_ST_SR_CERT_VRFY_A;\n                s->init_num = 0;\n                if (!s->session->peer)\n                    break;\n                \/*\n                 * For sigalgs freeze the handshake buffer at this point and\n                 * digest cached records.\n                 *\/\n                if (!s->s3->handshake_buffer) {\n                    SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);\n                    s->state = SSL_ST_ERR;\n                    return -1;\n                }\n                s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;\n                if (!ssl3_digest_cached_records(s)) {\n                    s->state = SSL_ST_ERR;\n                    return -1;\n                }\n            } else {\n                int offset = 0;\n                int dgst_num;\n\n                s->state = SSL3_ST_SR_CERT_VRFY_A;\n                s->init_num = 0;\n\n                \/*\n                 * We need to get hashes here so if there is a client cert,\n                 * it can be verified FIXME - digest processing for\n                 * CertificateVerify should be generalized. But it is next\n                 * step\n                 *\/\n                if (s->s3->handshake_buffer) {\n                    if (!ssl3_digest_cached_records(s)) {\n                        s->state = SSL_ST_ERR;\n                        return -1;\n                    }\n                }\n                for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++)\n                    if (s->s3->handshake_dgst[dgst_num]) {\n                        int dgst_size;\n\n                        s->method->ssl3_enc->cert_verify_mac(s,\n                                                             EVP_MD_CTX_type\n                                                             (s->\n                                                              s3->handshake_dgst\n                                                              [dgst_num]),\n                                                             &(s->s3->\n                                                               tmp.cert_verify_md\n                                                               [offset]));\n                        dgst_size =\n                            EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]);\n                        if (dgst_size < 0) {\n                            s->state = SSL_ST_ERR;\n                            ret = -1;\n                            goto end;\n                        }\n                        offset += dgst_size;\n                    }\n            }\n            break;\n\n        case SSL3_ST_SR_CERT_VRFY_A:\n        case SSL3_ST_SR_CERT_VRFY_B:\n            ret = ssl3_get_cert_verify(s);\n            if (ret <= 0)\n                goto end;\n\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n            s->state = SSL3_ST_SR_FINISHED_A;\n#else\n            if (s->s3->next_proto_neg_seen)\n                s->state = SSL3_ST_SR_NEXT_PROTO_A;\n            else\n                s->state = SSL3_ST_SR_FINISHED_A;\n#endif\n            s->init_num = 0;\n            break;\n\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)\n        case SSL3_ST_SR_NEXT_PROTO_A:\n        case SSL3_ST_SR_NEXT_PROTO_B:\n            \/*\n             * Enable CCS for NPN. Receiving a CCS clears the flag, so make\n             * sure not to re-enable it to ban duplicates. This *should* be the\n             * first time we have received one - but we check anyway to be\n             * cautious.\n             * s->s3->change_cipher_spec is set when a CCS is\n             * processed in s3_pkt.c, and remains set until\n             * the client's Finished message is read.\n             *\/\n            if (!s->s3->change_cipher_spec)\n                s->s3->flags |= SSL3_FLAGS_CCS_OK;\n\n            ret = ssl3_get_next_proto(s);\n            if (ret <= 0)\n                goto end;\n            s->init_num = 0;\n            s->state = SSL3_ST_SR_FINISHED_A;\n            break;\n#endif\n\n        case SSL3_ST_SR_FINISHED_A:\n        case SSL3_ST_SR_FINISHED_B:\n            \/*\n             * Enable CCS for handshakes without NPN. In NPN the CCS flag has\n             * already been set. Receiving a CCS clears the flag, so make\n             * sure not to re-enable it to ban duplicates.\n             * s->s3->change_cipher_spec is set when a CCS is\n             * processed in s3_pkt.c, and remains set until\n             * the client's Finished message is read.\n             *\/\n            if (!s->s3->change_cipher_spec)\n                s->s3->flags |= SSL3_FLAGS_CCS_OK;\n            ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A,\n                                    SSL3_ST_SR_FINISHED_B);\n            if (ret <= 0)\n                goto end;\n            if (s->hit)\n                s->state = SSL_ST_OK;\n#ifndef OPENSSL_NO_TLSEXT\n            else if (s->tlsext_ticket_expected)\n                s->state = SSL3_ST_SW_SESSION_TICKET_A;\n#endif\n            else\n                s->state = SSL3_ST_SW_CHANGE_A;\n            s->init_num = 0;\n            break;\n\n#ifndef OPENSSL_NO_TLSEXT\n        case SSL3_ST_SW_SESSION_TICKET_A:\n        case SSL3_ST_SW_SESSION_TICKET_B:\n            ret = ssl3_send_newsession_ticket(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_SW_CHANGE_A;\n            s->init_num = 0;\n            break;\n\n        case SSL3_ST_SW_CERT_STATUS_A:\n        case SSL3_ST_SW_CERT_STATUS_B:\n            ret = ssl3_send_cert_status(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_SW_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n\n#endif\n\n        case SSL3_ST_SW_CHANGE_A:\n        case SSL3_ST_SW_CHANGE_B:\n\n            s->session->cipher = s->s3->tmp.new_cipher;\n            if (!s->method->ssl3_enc->setup_key_block(s)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n\n            ret = ssl3_send_change_cipher_spec(s,\n                                               SSL3_ST_SW_CHANGE_A,\n                                               SSL3_ST_SW_CHANGE_B);\n\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_SW_FINISHED_A;\n            s->init_num = 0;\n\n            if (!s->method->ssl3_enc->change_cipher_state(s,\n                                                          SSL3_CHANGE_CIPHER_SERVER_WRITE))\n            {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n\n            break;\n\n        case SSL3_ST_SW_FINISHED_A:\n        case SSL3_ST_SW_FINISHED_B:\n            ret = ssl3_send_finished(s,\n                                     SSL3_ST_SW_FINISHED_A,\n                                     SSL3_ST_SW_FINISHED_B,\n                                     s->method->\n                                     ssl3_enc->server_finished_label,\n                                     s->method->\n                                     ssl3_enc->server_finished_label_len);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_SW_FLUSH;\n            if (s->hit) {\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n                s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;\n#else\n                if (s->s3->next_proto_neg_seen) {\n                    s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A;\n                } else\n                    s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;\n#endif\n            } else\n                s->s3->tmp.next_state = SSL_ST_OK;\n            s->init_num = 0;\n            break;\n\n        case SSL_ST_OK:\n            \/* clean a few things up *\/\n            ssl3_cleanup_key_block(s);\n\n            BUF_MEM_free(s->init_buf);\n            s->init_buf = NULL;\n\n            \/* remove buffering on output *\/\n            ssl_free_wbio_buffer(s);\n\n            s->init_num = 0;\n\n            if (s->renegotiate == 2) { \/* skipped if we just sent a\n                                        * HelloRequest *\/\n                s->renegotiate = 0;\n                s->new_session = 0;\n\n                ssl_update_cache(s, SSL_SESS_CACHE_SERVER);\n\n                s->ctx->stats.sess_accept_good++;\n                \/* s->server=1; *\/\n                s->handshake_func = ssl3_accept;\n\n                if (cb != NULL)\n                    cb(s, SSL_CB_HANDSHAKE_DONE, 1);\n            }\n\n            ret = 1;\n            goto end;\n            \/* break; *\/\n\n        case SSL_ST_ERR:\n        default:\n            SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE);\n            ret = -1;\n            goto end;\n            \/* break; *\/\n        }\n\n        if (!s->s3->tmp.reuse_message && !skip) {\n            if (s->debug) {\n                if ((ret = BIO_flush(s->wbio)) <= 0)\n                    goto end;\n            }\n\n            if ((cb != NULL) && (s->state != state)) {\n                new_state = s->state;\n                s->state = state;\n                cb(s, SSL_CB_ACCEPT_LOOP, 1);\n                s->state = new_state;\n            }\n        }\n        skip = 0;\n    }","target":0,"code_token_length":5283,"total_token_length":5519,"max_tokens_setting":6144}
+{"idx":508007,"func":"int ssl3_get_client_hello(SSL *s)\n\t{\n\tint i,j,ok,al,ret= -1;\n\tunsigned int cookie_len;\n\tlong n;\n\tunsigned long id;\n\tunsigned char *p,*d,*q;\n\tSSL_CIPHER *c;\n#ifndef OPENSSL_NO_COMP\n\tSSL_COMP *comp=NULL;\n#endif\n\tSTACK_OF(SSL_CIPHER) *ciphers=NULL;\n\n\t\/* We do this so that we will respond with our native type.\n\t * If we are TLSv1 and we get SSLv3, we will respond with TLSv1,\n\t * This down switching should be handled by a different method.\n\t * If we are SSLv3, we will respond with SSLv3, even if prompted with\n\t * TLSv1.\n\t *\/\n\tif (s->state == SSL3_ST_SR_CLNT_HELLO_A\n\t\t)\n\t\t{\n\t\ts->state=SSL3_ST_SR_CLNT_HELLO_B;\n\t\t}\n\ts->first_packet=1;\n\tn=s->method->ssl_get_message(s,\n\t\tSSL3_ST_SR_CLNT_HELLO_B,\n\t\tSSL3_ST_SR_CLNT_HELLO_C,\n\t\tSSL3_MT_CLIENT_HELLO,\n\t\tSSL3_RT_MAX_PLAIN_LENGTH,\n\t\t&ok);\n\n\tif (!ok) return((int)n);\n\ts->first_packet=0;\n\td=p=(unsigned char *)s->init_msg;\n\n\t\/* use version from inside client hello, not from record header\n\t * (may differ: see RFC 2246, Appendix E, second paragraph) *\/\n\ts->client_version=(((int)p[0])<<8)|(int)p[1];\n\tp+=2;\n\n\tif ((s->version == DTLS1_VERSION && s->client_version > s->version) ||\n\t    (s->version != DTLS1_VERSION && s->client_version < s->version))\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);\n\t\tif ((s->client_version>>8) == SSL3_VERSION_MAJOR)\n\t\t\t{\n\t\t\t\/* similar to ssl3_get_record, send alert using remote version number *\/\n\t\t\ts->version = s->client_version;\n\t\t\t}\n\t\tal = SSL_AD_PROTOCOL_VERSION;\n\t\tgoto f_err;\n\t\t}\n\n\t\/* If we require cookies and this ClientHello doesn't\n\t * contain one, just return since we do not want to\n\t * allocate any memory yet. So check cookie length...\n\t *\/\n\tif (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE)\n\t\t{\n\t\tunsigned int session_length, cookie_length;\n\t\t\n\t\tsession_length = *(p + SSL3_RANDOM_SIZE);\n\t\tcookie_length = *(p + SSL3_RANDOM_SIZE + session_length + 1);\n\n\t\tif (cookie_length == 0)\n\t\t\treturn 1;\n\t\t}\n\n\t\/* load the client random *\/\n\tmemcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE);\n\tp+=SSL3_RANDOM_SIZE;\n\n\t\/* get the session-id *\/\n\tj= *(p++);\n\n\ts->hit=0;\n\t\/* Versions before 0.9.7 always allow clients to resume sessions in renegotiation.\n\t * 0.9.7 and later allow this by default, but optionally ignore resumption requests\n\t * with flag SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather\n\t * than a change to default behavior so that applications relying on this for security\n\t * won't even compile against older library versions).\n\t *\n\t * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to request\n\t * renegotiation but not a new session (s->new_session remains unset): for servers,\n\t * this essentially just means that the SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION\n\t * setting will be ignored.\n\t *\/\n\tif ((s->new_session && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)))\n\t\t{\n\t\tif (!ssl_get_new_session(s,1))\n\t\t\tgoto err;\n\t\t}\n\telse\n\t\t{\n\t\ti=ssl_get_prev_session(s, p, j, d + n);\n\t\tif (i == 1)\n\t\t\t{ \/* previous session *\/\n\t\t\ts->hit=1;\n\t\t\t}\n\t\telse if (i == -1)\n\t\t\tgoto err;\n\t\telse \/* i == 0 *\/\n\t\t\t{\n\t\t\tif (!ssl_get_new_session(s,1))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\n\tp+=j;\n\n\tif (s->version == DTLS1_VERSION || s->version == DTLS1_BAD_VER)\n\t\t{\n\t\t\/* cookie stuff *\/\n\t\tcookie_len = *(p++);\n\n\t\t\/* \n\t\t * The ClientHello may contain a cookie even if the\n\t\t * HelloVerify message has not been sent--make sure that it\n\t\t * does not cause an overflow.\n\t\t *\/\n\t\tif ( cookie_len > sizeof(s->d1->rcvd_cookie))\n\t\t\t{\n\t\t\t\/* too much data *\/\n\t\t\tal = SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH);\n\t\t\tgoto f_err;\n\t\t\t}\n\n\t\t\/* verify the cookie if appropriate option is set. *\/\n\t\tif ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) &&\n\t\t\tcookie_len > 0)\n\t\t\t{\n\t\t\tmemcpy(s->d1->rcvd_cookie, p, cookie_len);\n\n\t\t\tif ( s->ctx->app_verify_cookie_cb != NULL)\n\t\t\t\t{\n\t\t\t\tif ( s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie,\n\t\t\t\t\tcookie_len) == 0)\n\t\t\t\t\t{\n\t\t\t\t\tal=SSL_AD_HANDSHAKE_FAILURE;\n\t\t\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, \n\t\t\t\t\t\tSSL_R_COOKIE_MISMATCH);\n\t\t\t\t\tgoto f_err;\n\t\t\t\t\t}\n\t\t\t\t\/* else cookie verification succeeded *\/\n\t\t\t\t}\n\t\t\telse if ( memcmp(s->d1->rcvd_cookie, s->d1->cookie, \n\t\t\t\t\t\t  s->d1->cookie_len) != 0) \/* default verification *\/\n\t\t\t\t{\n\t\t\t\t\tal=SSL_AD_HANDSHAKE_FAILURE;\n\t\t\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, \n\t\t\t\t\t\tSSL_R_COOKIE_MISMATCH);\n\t\t\t\t\tgoto f_err;\n\t\t\t\t}\n\n\t\t\tret = 2;\n\t\t\t}\n\n\t\tp += cookie_len;\n\t\t}\n\n\tn2s(p,i);\n\tif ((i == 0) && (j != 0))\n\t\t{\n\t\t\/* we need a cipher if we are not resuming a session *\/\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED);\n\t\tgoto f_err;\n\t\t}\n\tif ((p+i) >= (d+n))\n\t\t{\n\t\t\/* not enough data *\/\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH);\n\t\tgoto f_err;\n\t\t}\n\tif ((i > 0) && (ssl_bytes_to_cipher_list(s,p,i,&(ciphers))\n\t\t== NULL))\n\t\t{\n\t\tgoto err;\n\t\t}\n\tp+=i;\n\n\t\/* If it is a hit, check that the cipher is in the list *\/\n\tif ((s->hit) && (i > 0))\n\t\t{\n\t\tj=0;\n\t\tid=s->session->cipher->id;\n\n#ifdef CIPHER_DEBUG\n\t\tprintf(\"client sent %d ciphers\\n\",sk_num(ciphers));\n#endif\n\t\tfor (i=0; iid == id)\n\t\t\t\t{\n\t\t\t\tj=1;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\/* Disabled because it can be used in a ciphersuite downgrade\n * attack: CVE-2010-4180.\n *\/\n#if 0\n\t\tif (j == 0 && (s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) && (sk_SSL_CIPHER_num(ciphers) == 1))\n\t\t\t{\n\t\t\t\/* Special case as client bug workaround: the previously used cipher may\n\t\t\t * not be in the current list, the client instead might be trying to\n\t\t\t * continue using a cipher that before wasn't chosen due to server\n\t\t\t * preferences.  We'll have to reject the connection if the cipher is not\n\t\t\t * enabled, though. *\/\n\t\t\tc = sk_SSL_CIPHER_value(ciphers, 0);\n\t\t\tif (sk_SSL_CIPHER_find(SSL_get_ciphers(s), c) >= 0)\n\t\t\t\t{\n\t\t\t\ts->session->cipher = c;\n\t\t\t\tj = 1;\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\tif (j == 0)\n\t\t\t{\n\t\t\t\/* we need to have the cipher in the cipher\n\t\t\t * list if we are asked to reuse it *\/\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_REQUIRED_CIPHER_MISSING);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\n\t\/* compression *\/\n\ti= *(p++);\n\tif ((p+i) > (d+n))\n\t\t{\n\t\t\/* not enough data *\/\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH);\n\t\tgoto f_err;\n\t\t}\n\tq=p;\n\tfor (j=0; j= i)\n\t\t{\n\t\t\/* no compress *\/\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_COMPRESSION_SPECIFIED);\n\t\tgoto f_err;\n\t\t}\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\/* TLS extensions*\/\n\tif (s->version >= SSL3_VERSION)\n\t\t{\n\t\tif (!ssl_parse_clienthello_tlsext(s,&p,d,n, &al))\n\t\t\t{\n\t\t\t\/* 'al' set by ssl_parse_clienthello_tlsext *\/\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_PARSE_TLSEXT);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\t\tif (ssl_check_clienthello_tlsext(s) <= 0) {\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);\n\t\t\tgoto err;\n\t\t}\n\n\t\/* Check if we want to use external pre-shared secret for this\n\t * handshake for not reused session only. We need to generate\n\t * server_random before calling tls_session_secret_cb in order to allow\n\t * SessionTicket processing to use it in key derivation. *\/\n\t{\n\t\tunsigned long Time;\n\t\tunsigned char *pos;\n\t\tTime=(unsigned long)time(NULL);\t\t\t\/* Time *\/\n\t\tpos=s->s3->server_random;\n\t\tl2n(Time,pos);\n\t\tif (RAND_pseudo_bytes(pos,SSL3_RANDOM_SIZE-4) <= 0)\n\t\t\t{\n\t\t\tal=SSL_AD_INTERNAL_ERROR;\n\t\t\tgoto f_err;\n\t\t\t}\n\t}\n\n\tif (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb)\n\t\t{\n\t\tSSL_CIPHER *pref_cipher=NULL;\n\n\t\ts->session->master_key_length=sizeof(s->session->master_key);\n\t\tif(s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length,\n\t\t\tciphers, &pref_cipher, s->tls_session_secret_cb_arg))\n\t\t\t{\n\t\t\ts->hit=1;\n\t\t\ts->session->ciphers=ciphers;\n\t\t\ts->session->verify_result=X509_V_OK;\n\n\t\t\tciphers=NULL;\n\n\t\t\t\/* check if some cipher was preferred by call back *\/\n\t\t\tpref_cipher=pref_cipher ? pref_cipher : ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s));\n\t\t\tif (pref_cipher == NULL)\n\t\t\t\t{\n\t\t\t\tal=SSL_AD_HANDSHAKE_FAILURE;\n\t\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_SHARED_CIPHER);\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\n\t\t\ts->session->cipher=pref_cipher;\n\n\t\t\tif (s->cipher_list)\n\t\t\t\tsk_SSL_CIPHER_free(s->cipher_list);\n\n\t\t\tif (s->cipher_list_by_id)\n\t\t\t\tsk_SSL_CIPHER_free(s->cipher_list_by_id);\n\n\t\t\ts->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers);\n\t\t\ts->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers);\n\t\t\t}\n\t\t}\n#endif\n\n\t\/* Worst case, we will use the NULL compression, but if we have other\n\t * options, we will now look for them.  We have i-1 compression\n\t * algorithms from the client, starting at q. *\/\n\ts->s3->tmp.new_compression=NULL;\n#ifndef OPENSSL_NO_COMP\n\t\/* This only happens if we have a cache hit *\/\n\tif (s->session->compress_meth != 0)\n\t\t{\n\t\tint m, comp_id = s->session->compress_meth;\n\t\t\/* Perform sanity checks on resumed compression algorithm *\/\n\t\t\/* Can't disable compression *\/\n\t\tif (s->options & SSL_OP_NO_COMPRESSION)\n\t\t\t{\n\t\t\tal=SSL_AD_INTERNAL_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_INCONSISTENT_COMPRESSION);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t\/* Look for resumed compression method *\/\n\t\tfor (m = 0; m < sk_SSL_COMP_num(s->ctx->comp_methods); m++)\n\t\t\t{\n\t\t\tcomp=sk_SSL_COMP_value(s->ctx->comp_methods,m);\n\t\t\tif (comp_id == comp->id)\n\t\t\t\t{\n\t\t\t\ts->s3->tmp.new_compression=comp;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tif (s->s3->tmp.new_compression == NULL)\n\t\t\t{\n\t\t\tal=SSL_AD_INTERNAL_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_INVALID_COMPRESSION_ALGORITHM);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t\/* Look for resumed method in compression list *\/\n\t\tfor (m = 0; m < i; m++)\n\t\t\t{\n\t\t\tif (q[m] == comp_id)\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (m >= i)\n\t\t\t{\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\telse if (s->hit)\n\t\tcomp = NULL;\n\telse if (!(s->options & SSL_OP_NO_COMPRESSION) && s->ctx->comp_methods)\n\t\t{ \/* See if we have a match *\/\n\t\tint m,nn,o,v,done=0;\n\n\t\tnn=sk_SSL_COMP_num(s->ctx->comp_methods);\n\t\tfor (m=0; mctx->comp_methods,m);\n\t\t\tv=comp->id;\n\t\t\tfor (o=0; os3->tmp.new_compression=comp;\n\t\telse\n\t\t\tcomp=NULL;\n\t\t}\n#else\n\t\/* If compression is disabled we'd better not try to resume a session\n\t * using compression.\n\t *\/\n\tif (s->session->compress_meth != 0)\n\t\t{\n\t\tal=SSL_AD_INTERNAL_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_INCONSISTENT_COMPRESSION);\n\t\tgoto f_err;\n\t\t}\n#endif\n\n\t\/* Given s->session->ciphers and SSL_get_ciphers, we must\n\t * pick a cipher *\/\n\n\tif (!s->hit)\n\t\t{\n#ifdef OPENSSL_NO_COMP\n\t\ts->session->compress_meth=0;\n#else\n\t\ts->session->compress_meth=(comp == NULL)?0:comp->id;\n#endif\n\t\tif (s->session->ciphers != NULL)\n\t\t\tsk_SSL_CIPHER_free(s->session->ciphers);\n\t\ts->session->ciphers=ciphers;\n\t\tif (ciphers == NULL)\n\t\t\t{\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_PASSED);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tciphers=NULL;\n\t\tc=ssl3_choose_cipher(s,s->session->ciphers,\n\t\t\t\t     SSL_get_ciphers(s));\n\n\t\tif (c == NULL)\n\t\t\t{\n\t\t\tal=SSL_AD_HANDSHAKE_FAILURE;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_SHARED_CIPHER);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\ts->s3->tmp.new_cipher=c;\n\t\t}\n\telse\n\t\t{\n\t\t\/* Session-id reuse *\/\n#ifdef REUSE_CIPHER_BUG\n\t\tSTACK_OF(SSL_CIPHER) *sk;\n\t\tSSL_CIPHER *nc=NULL;\n\t\tSSL_CIPHER *ec=NULL;\n\n\t\tif (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG)\n\t\t\t{\n\t\t\tsk=s->session->ciphers;\n\t\t\tfor (i=0; ialgorithm_enc & SSL_eNULL)\n\t\t\t\t\tnc=c;\n\t\t\t\tif (SSL_C_IS_EXPORT(c))\n\t\t\t\t\tec=c;\n\t\t\t\t}\n\t\t\tif (nc != NULL)\n\t\t\t\ts->s3->tmp.new_cipher=nc;\n\t\t\telse if (ec != NULL)\n\t\t\t\ts->s3->tmp.new_cipher=ec;\n\t\t\telse\n\t\t\t\ts->s3->tmp.new_cipher=s->session->cipher;\n\t\t\t}\n\t\telse\n#endif\n\t\ts->s3->tmp.new_cipher=s->session->cipher;\n\t\t}\n\n\tif (TLS1_get_version(s) < TLS1_2_VERSION || !(s->verify_mode & SSL_VERIFY_PEER))\n\t\t{\n\t\tif (!ssl3_digest_cached_records(s))\n\t\t\tgoto f_err;\n\t\t}\n\t\n\t\/* we now have the following setup. \n\t * client_random\n\t * cipher_list \t\t- our prefered list of ciphers\n\t * ciphers \t\t- the clients prefered list of ciphers\n\t * compression\t\t- basically ignored right now\n\t * ssl version is set\t- sslv3\n\t * s->session\t\t- The ssl session has been setup.\n\t * s->hit\t\t- session reuse flag\n\t * s->tmp.new_cipher\t- the new cipher to use.\n\t *\/\n\n\tif (ret < 0) ret=1;\n\tif (0)\n\t\t{\nf_err:\n\t\tssl3_send_alert(s,SSL3_AL_FATAL,al);\n\t\t}\nerr:\n\tif (ciphers != NULL) sk_SSL_CIPHER_free(ciphers);\n\treturn(ret);\n\t}","target":0,"code_token_length":4139,"total_token_length":4375,"max_tokens_setting":6144}
+{"idx":370351,"func":"int http_wait_for_request(struct session *s, struct buffer *req, int an_bit)\n{\n\t\/*\n\t * We will parse the partial (or complete) lines.\n\t * We will check the request syntax, and also join multi-line\n\t * headers. An index of all the lines will be elaborated while\n\t * parsing.\n\t *\n\t * For the parsing, we use a 28 states FSM.\n\t *\n\t * Here is the information we currently have :\n\t *   req->data + msg->som  = beginning of request\n\t *   req->data + msg->eoh  = end of processed headers \/ start of current one\n\t *   msg->eol              = end of current header or line (LF or CRLF)\n\t *   req->lr = first non-visited byte\n\t *   req->r  = end of data\n\t *\n\t * At end of parsing, we may perform a capture of the error (if any), and\n\t * we will set a few fields (msg->sol, txn->meth, sn->flags\/SN_REDIRECTABLE).\n\t * We also check for monitor-uri, logging, HTTP\/0.9 to 1.0 conversion, and\n\t * finally headers capture.\n\t *\/\n\n\tint cur_idx;\n\tint use_close_only;\n\tstruct http_txn *txn = &s->txn;\n\tstruct http_msg *msg = &txn->req;\n\tstruct hdr_ctx ctx;\n\n\tDPRINTF(stderr,\"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\\n\",\n\t\tnow_ms, __FUNCTION__,\n\t\ts,\n\t\treq,\n\t\treq->rex, req->wex,\n\t\treq->flags,\n\t\treq->l,\n\t\treq->analysers);\n\n\t\/* we're speaking HTTP here, so let's speak HTTP to the client *\/\n\ts->srv_error = http_return_srv_error;\n\n\t\/* There's a protected area at the end of the buffer for rewriting\n\t * purposes. We don't want to start to parse the request if the\n\t * protected area is affected, because we may have to move processed\n\t * data later, which is much more complicated.\n\t *\/\n\tif (req->l && msg->msg_state < HTTP_MSG_ERROR) {\n\t\tif ((txn->flags & TX_NOT_FIRST) &&\n\t\t    unlikely((req->flags & BF_FULL) ||\n\t\t\t     req->r < req->lr ||\n\t\t\t     req->r > req->data + req->size - global.tune.maxrewrite)) {\n\t\t\tif (req->send_max) {\n\t\t\t\tif (req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT))\n\t\t\t\t\tgoto failed_keep_alive;\n\t\t\t\t\/* some data has still not left the buffer, wake us once that's done *\/\n\t\t\t\tbuffer_dont_connect(req);\n\t\t\t\treq->flags |= BF_READ_DONTWAIT; \/* try to get back here ASAP *\/\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (req->l <= req->size - global.tune.maxrewrite)\n\t\t\t\thttp_buffer_heavy_realign(req, msg);\n\t\t}\n\n\t\t\/* Note that we have the same problem with the response ; we\n\t\t * may want to send a redirect, error or anything which requires\n\t\t * some spare space. So we'll ensure that we have at least\n\t\t * maxrewrite bytes available in the response buffer before\n\t\t * processing that one. This will only affect pipelined\n\t\t * keep-alive requests.\n\t\t *\/\n\t\tif ((txn->flags & TX_NOT_FIRST) &&\n\t\t    unlikely((s->rep->flags & BF_FULL) ||\n\t\t\t     s->rep->r < s->rep->lr ||\n\t\t\t     s->rep->r > s->rep->data + s->rep->size - global.tune.maxrewrite)) {\n\t\t\tif (s->rep->send_max) {\n\t\t\t\tif (s->rep->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT))\n\t\t\t\t\tgoto failed_keep_alive;\n\t\t\t\t\/* don't let a connection request be initiated *\/\n\t\t\t\tbuffer_dont_connect(req);\n\t\t\t\ts->rep->flags &= ~BF_EXPECT_MORE; \/* speed up sending a previous response *\/\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\n\t\tif (likely(req->lr < req->r))\n\t\t\thttp_msg_analyzer(req, msg, &txn->hdr_idx);\n\t}\n\n\t\/* 1: we might have to print this header in debug mode *\/\n\tif (unlikely((global.mode & MODE_DEBUG) &&\n\t\t     (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) &&\n\t\t     msg->sol &&\n\t\t     (msg->msg_state >= HTTP_MSG_BODY || msg->msg_state == HTTP_MSG_ERROR))) {\n\t\tchar *eol, *sol;\n\n\t\tsol = req->data + msg->som;\n\t\teol = sol + msg->sl.rq.l;\n\t\tdebug_hdr(\"clireq\", s, sol, eol);\n\n\t\tsol += hdr_idx_first_pos(&txn->hdr_idx);\n\t\tcur_idx = hdr_idx_first_idx(&txn->hdr_idx);\n\n\t\twhile (cur_idx) {\n\t\t\teol = sol + txn->hdr_idx.v[cur_idx].len;\n\t\t\tdebug_hdr(\"clihdr\", s, sol, eol);\n\t\t\tsol = eol + txn->hdr_idx.v[cur_idx].cr + 1;\n\t\t\tcur_idx = txn->hdr_idx.v[cur_idx].next;\n\t\t}\n\t}\n\n\n\t\/*\n\t * Now we quickly check if we have found a full valid request.\n\t * If not so, we check the FD and buffer states before leaving.\n\t * A full request is indicated by the fact that we have seen\n\t * the double LF\/CRLF, so the state is >= HTTP_MSG_BODY. Invalid\n\t * requests are checked first. When waiting for a second request\n\t * on a keep-alive session, if we encounter and error, close, t\/o,\n\t * we note the error in the session flags but don't set any state.\n\t * Since the error will be noted there, it will not be counted by\n\t * process_session() as a frontend error.\n\t *\/\n\n\tif (unlikely(msg->msg_state < HTTP_MSG_BODY)) {\n\t\t\/*\n\t\t * First, let's catch bad requests.\n\t\t *\/\n\t\tif (unlikely(msg->msg_state == HTTP_MSG_ERROR)) {\n\t\t\tproxy_inc_fe_req_ctr(s->fe);\n\t\t\tgoto return_bad_req;\n\t\t}\n\n\t\t\/* 1: Since we are in header mode, if there's no space\n\t\t *    left for headers, we won't be able to free more\n\t\t *    later, so the session will never terminate. We\n\t\t *    must terminate it now.\n\t\t *\/\n\t\tif (unlikely(req->flags & BF_FULL)) {\n\t\t\t\/* FIXME: check if URI is set and return Status\n\t\t\t * 414 Request URI too long instead.\n\t\t\t *\/\n\t\t\tproxy_inc_fe_req_ctr(s->fe);\n\t\t\tif (msg->err_pos < 0)\n\t\t\t\tmsg->err_pos = req->l;\n\t\t\tgoto return_bad_req;\n\t\t}\n\n\t\t\/* 2: have we encountered a read error ? *\/\n\t\telse if (req->flags & BF_READ_ERROR) {\n\t\t\tif (!(s->flags & SN_ERR_MASK))\n\t\t\t\ts->flags |= SN_ERR_CLICL;\n\n\t\t\tif (txn->flags & TX_WAIT_NEXT_RQ)\n\t\t\t\tgoto failed_keep_alive;\n\n\t\t\t\/* we cannot return any message on error *\/\n\t\t\tif (msg->err_pos >= 0)\n\t\t\t\thttp_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe);\n\n\t\t\ttxn->status = 400;\n\t\t\tstream_int_retnclose(req->prod, NULL);\n\t\t\tmsg->msg_state = HTTP_MSG_ERROR;\n\t\t\treq->analysers = 0;\n\n\t\t\tproxy_inc_fe_req_ctr(s->fe);\n\t\t\ts->fe->counters.failed_req++;\n\t\t\tif (s->listener->counters)\n\t\t\t\ts->listener->counters->failed_req++;\n\n\t\t\tif (!(s->flags & SN_FINST_MASK))\n\t\t\t\ts->flags |= SN_FINST_R;\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* 3: has the read timeout expired ? *\/\n\t\telse if (req->flags & BF_READ_TIMEOUT || tick_is_expired(req->analyse_exp, now_ms)) {\n\t\t\tif (!(s->flags & SN_ERR_MASK))\n\t\t\t\ts->flags |= SN_ERR_CLITO;\n\n\t\t\tif (txn->flags & TX_WAIT_NEXT_RQ)\n\t\t\t\tgoto failed_keep_alive;\n\n\t\t\t\/* read timeout : give up with an error message. *\/\n\t\t\tif (msg->err_pos >= 0)\n\t\t\t\thttp_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe);\n\t\t\ttxn->status = 408;\n\t\t\tstream_int_retnclose(req->prod, error_message(s, HTTP_ERR_408));\n\t\t\tmsg->msg_state = HTTP_MSG_ERROR;\n\t\t\treq->analysers = 0;\n\n\t\t\tproxy_inc_fe_req_ctr(s->fe);\n\t\t\ts->fe->counters.failed_req++;\n\t\t\tif (s->listener->counters)\n\t\t\t\ts->listener->counters->failed_req++;\n\n\t\t\tif (!(s->flags & SN_FINST_MASK))\n\t\t\t\ts->flags |= SN_FINST_R;\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* 4: have we encountered a close ? *\/\n\t\telse if (req->flags & BF_SHUTR) {\n\t\t\tif (!(s->flags & SN_ERR_MASK))\n\t\t\t\ts->flags |= SN_ERR_CLICL;\n\n\t\t\tif (txn->flags & TX_WAIT_NEXT_RQ)\n\t\t\t\tgoto failed_keep_alive;\n\n\t\t\tif (msg->err_pos >= 0)\n\t\t\t\thttp_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe);\n\t\t\ttxn->status = 400;\n\t\t\tstream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));\n\t\t\tmsg->msg_state = HTTP_MSG_ERROR;\n\t\t\treq->analysers = 0;\n\n\t\t\tproxy_inc_fe_req_ctr(s->fe);\n\t\t\ts->fe->counters.failed_req++;\n\t\t\tif (s->listener->counters)\n\t\t\t\ts->listener->counters->failed_req++;\n\n\t\t\tif (!(s->flags & SN_FINST_MASK))\n\t\t\t\ts->flags |= SN_FINST_R;\n\t\t\treturn 0;\n\t\t}\n\n\t\tbuffer_dont_connect(req);\n\t\treq->flags |= BF_READ_DONTWAIT; \/* try to get back here ASAP *\/\n\t\ts->rep->flags &= ~BF_EXPECT_MORE; \/* speed up sending a previous response *\/\n#ifdef TCP_QUICKACK\n\t\tif (s->listener->options & LI_O_NOQUICKACK) {\n\t\t\t\/* We need more data, we have to re-enable quick-ack in case we\n\t\t\t * previously disabled it, otherwise we might cause the client\n\t\t\t * to delay next data.\n\t\t\t *\/\n\t\t\tsetsockopt(s->si[0].fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));\n\t\t}\n#endif\n\n\t\tif ((msg->msg_state != HTTP_MSG_RQBEFORE) && (txn->flags & TX_WAIT_NEXT_RQ)) {\n\t\t\t\/* If the client starts to talk, let's fall back to\n\t\t\t * request timeout processing.\n\t\t\t *\/\n\t\t\ttxn->flags &= ~TX_WAIT_NEXT_RQ;\n\t\t\treq->analyse_exp = TICK_ETERNITY;\n\t\t}\n\n\t\t\/* just set the request timeout once at the beginning of the request *\/\n\t\tif (!tick_isset(req->analyse_exp)) {\n\t\t\tif ((msg->msg_state == HTTP_MSG_RQBEFORE) &&\n\t\t\t    (txn->flags & TX_WAIT_NEXT_RQ) &&\n\t\t\t    tick_isset(s->be->timeout.httpka))\n\t\t\t\treq->analyse_exp = tick_add(now_ms, s->be->timeout.httpka);\n\t\t\telse\n\t\t\t\treq->analyse_exp = tick_add_ifset(now_ms, s->be->timeout.httpreq);\n\t\t}\n\n\t\t\/* we're not ready yet *\/\n\t\treturn 0;\n\n\tfailed_keep_alive:\n\t\t\/* Here we process low-level errors for keep-alive requests. In\n\t\t * short, if the request is not the first one and it experiences\n\t\t * a timeout, read error or shutdown, we just silently close so\n\t\t * that the client can try again.\n\t\t *\/\n\t\ttxn->status = 0;\n\t\tmsg->msg_state = HTTP_MSG_RQBEFORE;\n\t\treq->analysers = 0;\n\t\ts->logs.logwait = 0;\n\t\ts->rep->flags &= ~BF_EXPECT_MORE; \/* speed up sending a previous response *\/\n\t\tstream_int_retnclose(req->prod, NULL);\n\t\treturn 0;\n\t}\n\n\t\/* OK now we have a complete HTTP request with indexed headers. Let's\n\t * complete the request parsing by setting a few fields we will need\n\t * later. At this point, we have the last CRLF at req->data + msg->eoh.\n\t * If the request is in HTTP\/0.9 form, the rule is still true, and eoh\n\t * points to the CRLF of the request line. req->lr points to the first\n\t * byte after the last LF. msg->sov points to the first\n\t * byte of data. msg->eol cannot be trusted because it may have been\n\t * left uninitialized (for instance in the absence of headers).\n\t *\/\n\n\tproxy_inc_fe_req_ctr(s->fe); \/* one more valid request for this FE *\/\n\n\tif (txn->flags & TX_WAIT_NEXT_RQ) {\n\t\t\/* kill the pending keep-alive timeout *\/\n\t\ttxn->flags &= ~TX_WAIT_NEXT_RQ;\n\t\treq->analyse_exp = TICK_ETERNITY;\n\t}\n\n\n\t\/* Maybe we found in invalid header name while we were configured not\n\t * to block on that, so we have to capture it now.\n\t *\/\n\tif (unlikely(msg->err_pos >= 0))\n\t\thttp_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe);\n\n\t\/*\n\t * 1: identify the method\n\t *\/\n\ttxn->meth = find_http_meth(msg->sol, msg->sl.rq.m_l);\n\n\t\/* we can make use of server redirect on GET and HEAD *\/\n\tif (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD)\n\t\ts->flags |= SN_REDIRECTABLE;\n\n\t\/*\n\t * 2: check if the URI matches the monitor_uri.\n\t * We have to do this for every request which gets in, because\n\t * the monitor-uri is defined by the frontend.\n\t *\/\n\tif (unlikely((s->fe->monitor_uri_len != 0) &&\n\t\t     (s->fe->monitor_uri_len == msg->sl.rq.u_l) &&\n\t\t     !memcmp(msg->sol + msg->sl.rq.u,\n\t\t\t     s->fe->monitor_uri,\n\t\t\t     s->fe->monitor_uri_len))) {\n\t\t\/*\n\t\t * We have found the monitor URI\n\t\t *\/\n\t\tstruct acl_cond *cond;\n\n\t\ts->flags |= SN_MONITOR;\n\n\t\t\/* Check if we want to fail this monitor request or not *\/\n\t\tlist_for_each_entry(cond, &s->fe->mon_fail_cond, list) {\n\t\t\tint ret = acl_exec_cond(cond, s->fe, s, txn, ACL_DIR_REQ);\n\n\t\t\tret = acl_pass(ret);\n\t\t\tif (cond->pol == ACL_COND_UNLESS)\n\t\t\t\tret = !ret;\n\n\t\t\tif (ret) {\n\t\t\t\t\/* we fail this request, let's return 503 service unavail *\/\n\t\t\t\ttxn->status = 503;\n\t\t\t\tstream_int_retnclose(req->prod, error_message(s, HTTP_ERR_503));\n\t\t\t\tgoto return_prx_cond;\n\t\t\t}\n\t\t}\n\n\t\t\/* nothing to fail, let's reply normaly *\/\n\t\ttxn->status = 200;\n\t\tstream_int_retnclose(req->prod, error_message(s, HTTP_ERR_200));\n\t\tgoto return_prx_cond;\n\t}\n\n\t\/*\n\t * 3: Maybe we have to copy the original REQURI for the logs ?\n\t * Note: we cannot log anymore if the request has been\n\t * classified as invalid.\n\t *\/\n\tif (unlikely(s->logs.logwait & LW_REQ)) {\n\t\t\/* we have a complete HTTP request that we must log *\/\n\t\tif ((txn->uri = pool_alloc2(pool2_requri)) != NULL) {\n\t\t\tint urilen = msg->sl.rq.l;\n\n\t\t\tif (urilen >= REQURI_LEN)\n\t\t\t\turilen = REQURI_LEN - 1;\n\t\t\tmemcpy(txn->uri, &req->data[msg->som], urilen);\n\t\t\ttxn->uri[urilen] = 0;\n\n\t\t\tif (!(s->logs.logwait &= ~LW_REQ))\n\t\t\t\ts->do_log(s);\n\t\t} else {\n\t\t\tAlert(\"HTTP logging : out of memory.\\n\");\n\t\t}\n\t}\n\n\t\/* 4. We may have to convert HTTP\/0.9 requests to HTTP\/1.0 *\/\n\tif (unlikely(msg->sl.rq.v_l == 0) && !http_upgrade_v09_to_v10(req, msg, txn))\n\t\tgoto return_bad_req;\n\n\t\/* ... and check if the request is HTTP\/1.1 or above *\/\n\tif ((msg->sl.rq.v_l == 8) &&\n\t    ((msg->sol[msg->sl.rq.v + 5] > '1') ||\n\t     ((msg->sol[msg->sl.rq.v + 5] == '1') &&\n\t      (msg->sol[msg->sl.rq.v + 7] >= '1'))))\n\t\ttxn->flags |= TX_REQ_VER_11;\n\n\t\/* \"connection\" has not been parsed yet *\/\n\ttxn->flags &= ~(TX_HDR_CONN_PRS | TX_HDR_CONN_CLO | TX_HDR_CONN_KAL);\n\n\t\/* if the frontend has \"option http-use-proxy-header\", we'll check if\n\t * we have what looks like a proxied connection instead of a connection,\n\t * and in this case set the TX_USE_PX_CONN flag to use Proxy-connection.\n\t * Note that this is *not* RFC-compliant, however browsers and proxies\n\t * happen to do that despite being non-standard :-(\n\t * We consider that a request not beginning with either '\/' or '*' is\n\t * a proxied connection, which covers both \"scheme:\/\/location\" and\n\t * CONNECT ip:port.\n\t *\/\n\tif ((s->fe->options2 & PR_O2_USE_PXHDR) &&\n\t    msg->sol[msg->sl.rq.u] != '\/' && msg->sol[msg->sl.rq.u] != '*')\n\t\ttxn->flags |= TX_USE_PX_CONN;\n\n\t\/* transfer length unknown*\/\n\ttxn->flags &= ~TX_REQ_XFER_LEN;\n\n\t\/* 5: we may need to capture headers *\/\n\tif (unlikely((s->logs.logwait & LW_REQHDR) && txn->req.cap))\n\t\tcapture_headers(msg->sol, &txn->hdr_idx,\n\t\t\t\ttxn->req.cap, s->fe->req_cap);\n\n\t\/* 6: determine the transfer-length.\n\t * According to RFC2616 #4.4, amended by the HTTPbis working group,\n\t * the presence of a message-body in a REQUEST and its transfer length\n\t * must be determined that way (in order of precedence) :\n\t *   1. The presence of a message-body in a request is signaled by the\n\t *      inclusion of a Content-Length or Transfer-Encoding header field\n\t *      in the request's header fields.  When a request message contains\n\t *      both a message-body of non-zero length and a method that does\n\t *      not define any semantics for that request message-body, then an\n\t *      origin server SHOULD either ignore the message-body or respond\n\t *      with an appropriate error message (e.g., 413).  A proxy or\n\t *      gateway, when presented the same request, SHOULD either forward\n\t *      the request inbound with the message- body or ignore the\n\t *      message-body when determining a response.\n\t *\n\t *   2. If a Transfer-Encoding header field (Section 9.7) is present\n\t *      and the \"chunked\" transfer-coding (Section 6.2) is used, the\n\t *      transfer-length is defined by the use of this transfer-coding.\n\t *      If a Transfer-Encoding header field is present and the \"chunked\"\n\t *      transfer-coding is not present, the transfer-length is defined\n\t *      by the sender closing the connection.\n\t *\n\t *   3. If a Content-Length header field is present, its decimal value in\n\t *      OCTETs represents both the entity-length and the transfer-length.\n\t *      If a message is received with both a Transfer-Encoding header\n\t *      field and a Content-Length header field, the latter MUST be ignored.\n\t *\n\t *   4. By the server closing the connection. (Closing the connection\n\t *      cannot be used to indicate the end of a request body, since that\n\t *      would leave no possibility for the server to send back a response.)\n\t *\n\t *   Whenever a transfer-coding is applied to a message-body, the set of\n\t *   transfer-codings MUST include \"chunked\", unless the message indicates\n\t *   it is terminated by closing the connection.  When the \"chunked\"\n\t *   transfer-coding is used, it MUST be the last transfer-coding applied\n\t *   to the message-body.\n\t *\/\n\n\tuse_close_only = 0;\n\tctx.idx = 0;\n\t\/* set TE_CHNK and XFER_LEN only if \"chunked\" is seen last *\/\n\twhile ((txn->flags & TX_REQ_VER_11) &&\n\t       http_find_header2(\"Transfer-Encoding\", 17, msg->sol, &txn->hdr_idx, &ctx)) {\n\t\tif (ctx.vlen == 7 && strncasecmp(ctx.line + ctx.val, \"chunked\", 7) == 0)\n\t\t\ttxn->flags |= (TX_REQ_TE_CHNK | TX_REQ_XFER_LEN);\n\t\telse if (txn->flags & TX_REQ_TE_CHNK) {\n\t\t\t\/* bad transfer-encoding (chunked followed by something else) *\/\n\t\t\tuse_close_only = 1;\n\t\t\ttxn->flags &= ~(TX_REQ_TE_CHNK | TX_REQ_XFER_LEN);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tctx.idx = 0;\n\twhile (!(txn->flags & TX_REQ_TE_CHNK) && !use_close_only &&\n\t       http_find_header2(\"Content-Length\", 14, msg->sol, &txn->hdr_idx, &ctx)) {\n\t\tsigned long long cl;\n\n\t\tif (!ctx.vlen) {\n\t\t\tmsg->err_pos = ctx.line + ctx.val - req->data;\n\t\t\tgoto return_bad_req;\n\t\t}\n\n\t\tif (strl2llrc(ctx.line + ctx.val, ctx.vlen, &cl)) {\n\t\t\tmsg->err_pos = ctx.line + ctx.val - req->data;\n\t\t\tgoto return_bad_req; \/* parse failure *\/\n\t\t}\n\n\t\tif (cl < 0) {\n\t\t\tmsg->err_pos = ctx.line + ctx.val - req->data;\n\t\t\tgoto return_bad_req;\n\t\t}\n\n\t\tif ((txn->flags & TX_REQ_CNT_LEN) && (msg->chunk_len != cl)) {\n\t\t\tmsg->err_pos = ctx.line + ctx.val - req->data;\n\t\t\tgoto return_bad_req; \/* already specified, was different *\/\n\t\t}\n\n\t\ttxn->flags |= TX_REQ_CNT_LEN | TX_REQ_XFER_LEN;\n\t\tmsg->body_len = msg->chunk_len = cl;\n\t}\n\n\t\/* bodyless requests have a known length *\/\n\tif (!use_close_only)\n\t\ttxn->flags |= TX_REQ_XFER_LEN;\n\n\t\/* end of job, return OK *\/\n\treq->analysers &= ~an_bit;\n\treq->analyse_exp = TICK_ETERNITY;\n\treturn 1;\n\n return_bad_req:\n\t\/* We centralize bad requests processing here *\/\n\tif (unlikely(msg->msg_state == HTTP_MSG_ERROR) || msg->err_pos >= 0) {\n\t\t\/* we detected a parsing error. We want to archive this request\n\t\t * in the dedicated proxy area for later troubleshooting.\n\t\t *\/\n\t\thttp_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe);\n\t}\n\n\ttxn->req.msg_state = HTTP_MSG_ERROR;\n\ttxn->status = 400;\n\tstream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));\n\n\ts->fe->counters.failed_req++;\n\tif (s->listener->counters)\n\t\ts->listener->counters->failed_req++;\n\n return_prx_cond:\n\tif (!(s->flags & SN_ERR_MASK))\n\t\ts->flags |= SN_ERR_PRXCOND;\n\tif (!(s->flags & SN_FINST_MASK))\n\t\ts->flags |= SN_FINST_R;\n\n\treq->analysers = 0;\n\treq->analyse_exp = TICK_ETERNITY;\n\treturn 0;\n}","target":0,"code_token_length":5387,"total_token_length":5623,"max_tokens_setting":6144}
+{"idx":342602,"func":"int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,\n\n                          AVPacket *avpkt)\n\n{\n\n    AVFrame     *frame = data;\n\n    const uint8_t *buf = avpkt->data;\n\n    int buf_size       = avpkt->size;\n\n    MJpegDecodeContext *s = avctx->priv_data;\n\n    const uint8_t *buf_end, *buf_ptr;\n\n    const uint8_t *unescaped_buf_ptr;\n\n    int hshift, vshift;\n\n    int unescaped_buf_size;\n\n    int start_code;\n\n    int i, index;\n\n    int ret = 0;\n\n    int is16bit;\n\n\n\n    av_dict_free(&s->exif_metadata);\n\n    av_freep(&s->stereo3d);\n\n    s->adobe_transform = -1;\n\n\n\n    buf_ptr = buf;\n\n    buf_end = buf + buf_size;\n\n    while (buf_ptr < buf_end) {\n\n        \/* find start next marker *\/\n\n        start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end,\n\n                                          &unescaped_buf_ptr,\n\n                                          &unescaped_buf_size);\n\n        \/* EOF *\/\n\n        if (start_code < 0) {\n\n            break;\n\n        } else if (unescaped_buf_size > INT_MAX \/ 8) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"MJPEG packet 0x%x too big (%d\/%d), corrupt data?\\n\",\n\n                   start_code, unescaped_buf_size, buf_size);\n\n            return AVERROR_INVALIDDATA;\n\n        }\n\n        av_log(avctx, AV_LOG_DEBUG, \"marker=%x avail_size_in_buf=%\"PTRDIFF_SPECIFIER\"\\n\",\n\n               start_code, buf_end - buf_ptr);\n\n\n\n        ret = init_get_bits8(&s->gb, unescaped_buf_ptr, unescaped_buf_size);\n\n\n\n        if (ret < 0) {\n\n            av_log(avctx, AV_LOG_ERROR, \"invalid buffer\\n\");\n\n            goto fail;\n\n        }\n\n\n\n        s->start_code = start_code;\n\n        if (s->avctx->debug & FF_DEBUG_STARTCODE)\n\n            av_log(avctx, AV_LOG_DEBUG, \"startcode: %X\\n\", start_code);\n\n\n\n        \/* process markers *\/\n\n        if (start_code >= 0xd0 && start_code <= 0xd7)\n\n            av_log(avctx, AV_LOG_DEBUG,\n\n                   \"restart marker: %d\\n\", start_code & 0x0f);\n\n            \/* APP fields *\/\n\n        else if (start_code >= APP0 && start_code <= APP15)\n\n            mjpeg_decode_app(s);\n\n            \/* Comment *\/\n\n        else if (start_code == COM)\n\n            mjpeg_decode_com(s);\n\n\n\n        ret = -1;\n\n\n\n        if (!CONFIG_JPEGLS_DECODER &&\n\n            (start_code == SOF48 || start_code == LSE)) {\n\n            av_log(avctx, AV_LOG_ERROR, \"JPEG-LS support not enabled.\\n\");\n\n            return AVERROR(ENOSYS);\n\n        }\n\n\n\n        if (avctx->skip_frame == AVDISCARD_ALL) {\n\n            switch(start_code) {\n\n            case SOF0:\n\n            case SOF1:\n\n            case SOF2:\n\n            case SOF3:\n\n            case SOF48:\n\n            case SOI:\n\n            case SOS:\n\n            case EOI:\n\n                break;\n\n            default:\n\n                goto skip;\n\n            }\n\n        }\n\n\n\n        switch (start_code) {\n\n        case SOI:\n\n            s->restart_interval = 0;\n\n            s->restart_count    = 0;\n\n            \/* nothing to do on SOI *\/\n\n            break;\n\n        case DQT:\n\n            ff_mjpeg_decode_dqt(s);\n\n            break;\n\n        case DHT:\n\n            if ((ret = ff_mjpeg_decode_dht(s)) < 0) {\n\n                av_log(avctx, AV_LOG_ERROR, \"huffman table decode error\\n\");\n\n                goto fail;\n\n            }\n\n            break;\n\n        case SOF0:\n\n        case SOF1:\n\n            s->lossless    = 0;\n\n            s->ls          = 0;\n\n            s->progressive = 0;\n\n            if ((ret = ff_mjpeg_decode_sof(s)) < 0)\n\n                goto fail;\n\n            break;\n\n        case SOF2:\n\n            s->lossless    = 0;\n\n            s->ls          = 0;\n\n            s->progressive = 1;\n\n            if ((ret = ff_mjpeg_decode_sof(s)) < 0)\n\n                goto fail;\n\n            break;\n\n        case SOF3:\n\n            s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;\n\n            s->lossless    = 1;\n\n            s->ls          = 0;\n\n            s->progressive = 0;\n\n            if ((ret = ff_mjpeg_decode_sof(s)) < 0)\n\n                goto fail;\n\n            break;\n\n        case SOF48:\n\n            s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;\n\n            s->lossless    = 1;\n\n            s->ls          = 1;\n\n            s->progressive = 0;\n\n            if ((ret = ff_mjpeg_decode_sof(s)) < 0)\n\n                goto fail;\n\n            break;\n\n        case LSE:\n\n            if (!CONFIG_JPEGLS_DECODER ||\n\n                (ret = ff_jpegls_decode_lse(s)) < 0)\n\n                goto fail;\n\n            break;\n\n        case EOI:\n\neoi_parser:\n\n            s->cur_scan = 0;\n\n            if (!s->got_picture) {\n\n                av_log(avctx, AV_LOG_WARNING,\n\n                       \"Found EOI before any SOF, ignoring\\n\");\n\n                break;\n\n            }\n\n            if (s->interlaced) {\n\n                s->bottom_field ^= 1;\n\n                \/* if not bottom field, do not output image yet *\/\n\n                if (s->bottom_field == !s->interlace_polarity)\n\n                    break;\n\n            }\n\n            if (avctx->skip_frame == AVDISCARD_ALL) {\n\n                s->got_picture = 0;\n\n                goto the_end_no_picture;\n\n            }\n\n            if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)\n\n                return ret;\n\n            *got_frame = 1;\n\n            s->got_picture = 0;\n\n\n\n            if (!s->lossless) {\n\n                int qp = FFMAX3(s->qscale[0],\n\n                                s->qscale[1],\n\n                                s->qscale[2]);\n\n                int qpw = (s->width + 15) \/ 16;\n\n                AVBufferRef *qp_table_buf = av_buffer_alloc(qpw);\n\n                if (qp_table_buf) {\n\n                    memset(qp_table_buf->data, qp, qpw);\n\n                    av_frame_set_qp_table(data, qp_table_buf, 0, FF_QSCALE_TYPE_MPEG1);\n\n                }\n\n\n\n                if(avctx->debug & FF_DEBUG_QP)\n\n                    av_log(avctx, AV_LOG_DEBUG, \"QP: %d\\n\", qp);\n\n            }\n\n\n\n            goto the_end;\n\n        case SOS:\n\n            s->cur_scan++;\n\n            if (avctx->skip_frame == AVDISCARD_ALL)\n\n                break;\n\n\n\n            if ((ret = ff_mjpeg_decode_sos(s, NULL, 0, NULL)) < 0 &&\n\n                (avctx->err_recognition & AV_EF_EXPLODE))\n\n                goto fail;\n\n            break;\n\n        case DRI:\n\n            mjpeg_decode_dri(s);\n\n            break;\n\n        case SOF5:\n\n        case SOF6:\n\n        case SOF7:\n\n        case SOF9:\n\n        case SOF10:\n\n        case SOF11:\n\n        case SOF13:\n\n        case SOF14:\n\n        case SOF15:\n\n        case JPG:\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"mjpeg: unsupported coding type (%x)\\n\", start_code);\n\n            break;\n\n        }\n\n\n\nskip:\n\n        \/* eof process start code *\/\n\n        buf_ptr += (get_bits_count(&s->gb) + 7) \/ 8;\n\n        av_log(avctx, AV_LOG_DEBUG,\n\n               \"marker parser used %d bytes (%d bits)\\n\",\n\n               (get_bits_count(&s->gb) + 7) \/ 8, get_bits_count(&s->gb));\n\n    }\n\n    if (s->got_picture && s->cur_scan) {\n\n        av_log(avctx, AV_LOG_WARNING, \"EOI missing, emulating\\n\");\n\n        goto eoi_parser;\n\n    }\n\n    av_log(avctx, AV_LOG_FATAL, \"No JPEG data found in image\\n\");\n\n    return AVERROR_INVALIDDATA;\n\nfail:\n\n    s->got_picture = 0;\n\n    return ret;\n\nthe_end:\n\n\n\n    is16bit = av_pix_fmt_desc_get(s->avctx->pix_fmt)->comp[0].step > 1;\n\n\n\n    if (AV_RB32(s->upscale_h)) {\n\n        int p;\n\n        av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV444P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVJ440P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV440P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV420P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV420P16||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVA420P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVA420P16||\n\n                   avctx->pix_fmt == AV_PIX_FMT_GBRP     ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_GBRAP\n\n                  );\n\n        avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);\n\n        for (p = 0; p<4; p++) {\n\n            uint8_t *line = s->picture_ptr->data[p];\n\n            int w = s->width;\n\n            int h = s->height;\n\n            if (!s->upscale_h[p])\n\n                continue;\n\n            if (p==1 || p==2) {\n\n                w = AV_CEIL_RSHIFT(w, hshift);\n\n                h = AV_CEIL_RSHIFT(h, vshift);\n\n            }\n\n            if (s->upscale_v[p])\n\n                h = (h+1)>>1;\n\n            av_assert0(w > 0);\n\n            for (i = 0; i < h; i++) {\n\n                if (s->upscale_h[p] == 1) {\n\n                    if (is16bit) ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) \/ 2];\n\n                    else                      line[w - 1] = line[(w - 1) \/ 2];\n\n                    for (index = w - 2; index > 0; index--) {\n\n                        if (is16bit)\n\n                            ((uint16_t*)line)[index] = (((uint16_t*)line)[index \/ 2] + ((uint16_t*)line)[(index + 1) \/ 2]) >> 1;\n\n                        else\n\n                            line[index] = (line[index \/ 2] + line[(index + 1) \/ 2]) >> 1;\n\n                    }\n\n                } else if (s->upscale_h[p] == 2) {\n\n                    if (is16bit) {\n\n                        ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) \/ 3];\n\n                        if (w > 1)\n\n                            ((uint16_t*)line)[w - 2] = ((uint16_t*)line)[w - 1];\n\n                    } else {\n\n                        line[w - 1] = line[(w - 1) \/ 3];\n\n                        if (w > 1)\n\n                            line[w - 2] = line[w - 1];\n\n                    }\n\n                    for (index = w - 3; index > 0; index--) {\n\n                        line[index] = (line[index \/ 3] + line[(index + 1) \/ 3] + line[(index + 2) \/ 3] + 1) \/ 3;\n\n                    }\n\n                }\n\n                line += s->linesize[p];\n\n            }\n\n        }\n\n    }\n\n    if (AV_RB32(s->upscale_v)) {\n\n        int p;\n\n        av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV444P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV422P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV420P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUV440P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVJ440P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVA420P  ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_YUVA420P16||\n\n                   avctx->pix_fmt == AV_PIX_FMT_GBRP     ||\n\n                   avctx->pix_fmt == AV_PIX_FMT_GBRAP\n\n                   );\n\n        avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);\n\n        for (p = 0; p < 4; p++) {\n\n            uint8_t *dst;\n\n            int w = s->width;\n\n            int h = s->height;\n\n            if (!s->upscale_v[p])\n\n                continue;\n\n            if (p==1 || p==2) {\n\n                w = AV_CEIL_RSHIFT(w, hshift);\n\n                h = AV_CEIL_RSHIFT(h, vshift);\n\n            }\n\n            dst = &((uint8_t *)s->picture_ptr->data[p])[(h - 1) * s->linesize[p]];\n\n            for (i = h - 1; i; i--) {\n\n                uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[p])[i \/ 2 * s->linesize[p]];\n\n                uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[p])[(i + 1) \/ 2 * s->linesize[p]];\n\n                if (src1 == src2 || i == h - 1) {\n\n                    memcpy(dst, src1, w);\n\n                } else {\n\n                    for (index = 0; index < w; index++)\n\n                        dst[index] = (src1[index] + src2[index]) >> 1;\n\n                }\n\n                dst -= s->linesize[p];\n\n            }\n\n        }\n\n    }\n\n    if (s->flipped) {\n\n        int j;\n\n        avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);\n\n        for (index=0; index<4; index++) {\n\n            uint8_t *dst = s->picture_ptr->data[index];\n\n            int w = s->picture_ptr->width;\n\n            int h = s->picture_ptr->height;\n\n            if(index && index<3){\n\n                w = AV_CEIL_RSHIFT(w, hshift);\n\n                h = AV_CEIL_RSHIFT(h, vshift);\n\n            }\n\n            if(dst){\n\n                uint8_t *dst2 = dst + s->picture_ptr->linesize[index]*(h-1);\n\n                for (i=0; ipicture_ptr->linesize[index];\n\n                    dst2 -= s->picture_ptr->linesize[index];\n\n                }\n\n            }\n\n        }\n\n    }\n\n    if (s->adobe_transform == 0 && s->avctx->pix_fmt == AV_PIX_FMT_GBRAP) {\n\n        int w = s->picture_ptr->width;\n\n        int h = s->picture_ptr->height;\n\n        for (i=0; ipicture_ptr->data[index]\n\n                             + s->picture_ptr->linesize[index]*i;\n\n            }\n\n            for (j=0; j> 16;\n\n                dst[1][j] = b*257 >> 16;\n\n                dst[2][j] = r*257 >> 16;\n\n                dst[3][j] = 255;\n\n            }\n\n        }\n\n    }\n\n    if (s->adobe_transform == 2 && s->avctx->pix_fmt == AV_PIX_FMT_YUVA444P) {\n\n        int w = s->picture_ptr->width;\n\n        int h = s->picture_ptr->height;\n\n        for (i=0; ipicture_ptr->data[index]\n\n                             + s->picture_ptr->linesize[index]*i;\n\n            }\n\n            for (j=0; j> 16;\n\n                dst[1][j] = (g*257 >> 16) + 128;\n\n                dst[2][j] = (b*257 >> 16) + 128;\n\n                dst[3][j] = 255;\n\n            }\n\n        }\n\n    }\n\n\n\n    if (s->stereo3d) {\n\n        AVStereo3D *stereo = av_stereo3d_create_side_data(data);\n\n        if (stereo) {\n\n            stereo->type  = s->stereo3d->type;\n\n            stereo->flags = s->stereo3d->flags;\n\n        }\n\n        av_freep(&s->stereo3d);\n\n    }\n\n\n\n    av_dict_copy(avpriv_frame_get_metadatap(data), s->exif_metadata, 0);\n\n    av_dict_free(&s->exif_metadata);\n\n\n\nthe_end_no_picture:\n\n    av_log(avctx, AV_LOG_DEBUG, \"decode frame unused %\"PTRDIFF_SPECIFIER\" bytes\\n\",\n\n           buf_end - buf_ptr);\n\n\/\/  return buf_end - buf_ptr;\n\n    return buf_ptr - buf;\n\n}\n","target":1,"code_token_length":4167,"total_token_length":4403,"max_tokens_setting":6144}
+{"idx":184049,"func":"void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM(\n    GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,\n    GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,\n    GLbitfield mask, GLenum filter) {\n  const char* func_name = \"glBlitFramebufferCHROMIUM\";\n  DCHECK(!ShouldDeferReads() && !ShouldDeferDraws());\n\n  if (!CheckFramebufferValid(GetBoundDrawFramebuffer(),\n                             GetDrawFramebufferTarget(),\n                             GL_INVALID_FRAMEBUFFER_OPERATION, func_name)) {\n    return;\n  }\n\n  gfx::Size draw_size = GetBoundDrawFramebufferSize();\n\n  if (!CheckFramebufferValid(GetBoundReadFramebuffer(),\n                             GetReadFramebufferTarget(),\n                             GL_INVALID_FRAMEBUFFER_OPERATION, func_name)) {\n    return;\n  }\n\n  if (GetBoundFramebufferSamples(GL_DRAW_FRAMEBUFFER) > 0) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n                       \"destination framebuffer is multisampled\");\n    return;\n  }\n\n  GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER);\n  if (read_buffer_samples > 0 &&\n      (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n        \"src framebuffer is multisampled, but src\/dst regions are different\");\n    return;\n  }\n\n  GLbitfield mask_blit = mask;\n\n  bool read_framebuffer_miss_image = false;\n\n  enum FeedbackLoopState {\n    FeedbackLoopTrue,\n    FeedbackLoopFalse,\n    FeedbackLoopUnknown\n  };\n\n  FeedbackLoopState is_feedback_loop = FeedbackLoopUnknown;\n  Framebuffer* read_framebuffer =\n      framebuffer_state_.bound_read_framebuffer.get();\n  Framebuffer* draw_framebuffer =\n      framebuffer_state_.bound_draw_framebuffer.get();\n  if (!read_framebuffer && !draw_framebuffer) {\n    is_feedback_loop = FeedbackLoopTrue;\n  } else if (!read_framebuffer || !draw_framebuffer) {\n    is_feedback_loop = FeedbackLoopFalse;\n    if (read_framebuffer) {\n      if (((mask & GL_COLOR_BUFFER_BIT) != 0 &&\n          !GetBoundReadFramebufferInternalFormat()) ||\n          ((mask & GL_DEPTH_BUFFER_BIT) != 0 &&\n          !read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT) &&\n          BoundFramebufferHasDepthAttachment()) ||\n          ((mask & GL_STENCIL_BUFFER_BIT) != 0 &&\n          !read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT) &&\n          BoundFramebufferHasStencilAttachment())) {\n        read_framebuffer_miss_image = true;\n      }\n    }\n  } else {\n    DCHECK(read_framebuffer && draw_framebuffer);\n    if ((mask & GL_DEPTH_BUFFER_BIT) != 0) {\n      const Framebuffer::Attachment* depth_buffer_read =\n          read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);\n      const Framebuffer::Attachment* depth_buffer_draw =\n          draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);\n      if (!depth_buffer_draw || !depth_buffer_read) {\n        mask_blit &= ~GL_DEPTH_BUFFER_BIT;\n        if (depth_buffer_draw) {\n          read_framebuffer_miss_image = true;\n        }\n      } else if (depth_buffer_draw->IsSameAttachment(depth_buffer_read)) {\n        is_feedback_loop = FeedbackLoopTrue;\n      }\n    }\n    if ((mask & GL_STENCIL_BUFFER_BIT) != 0) {\n      const Framebuffer::Attachment* stencil_buffer_read =\n          read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);\n      const Framebuffer::Attachment* stencil_buffer_draw =\n          draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);\n      if (!stencil_buffer_draw || !stencil_buffer_read) {\n        mask_blit &= ~GL_STENCIL_BUFFER_BIT;\n        if (stencil_buffer_draw) {\n          read_framebuffer_miss_image = true;\n        }\n      } else if (stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) {\n        is_feedback_loop = FeedbackLoopTrue;\n      }\n    }\n  }\n\n  GLenum src_internal_format = GetBoundReadFramebufferInternalFormat();\n  GLenum src_type = GetBoundReadFramebufferTextureType();\n\n  bool read_buffer_has_srgb = GLES2Util::GetColorEncodingFromInternalFormat(\n                                  src_internal_format) == GL_SRGB;\n  bool draw_buffers_has_srgb = false;\n  if ((mask & GL_COLOR_BUFFER_BIT) != 0) {\n    bool is_src_signed_int =\n        GLES2Util::IsSignedIntegerFormat(src_internal_format);\n    bool is_src_unsigned_int =\n        GLES2Util::IsUnsignedIntegerFormat(src_internal_format);\n    DCHECK(!is_src_signed_int || !is_src_unsigned_int);\n\n    if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) {\n      LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n                         \"invalid filter for integer format\");\n      return;\n    }\n\n    GLenum src_sized_format =\n        GLES2Util::ConvertToSizedFormat(src_internal_format, src_type);\n    DCHECK(read_framebuffer || (is_feedback_loop != FeedbackLoopUnknown));\n    const Framebuffer::Attachment* read_buffer =\n        is_feedback_loop == FeedbackLoopUnknown ?\n        read_framebuffer->GetReadBufferAttachment() : nullptr;\n    bool draw_buffer_has_image = false;\n    for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {\n      GLenum dst_format = GetBoundColorDrawBufferInternalFormat(\n          static_cast(ii));\n      GLenum dst_type = GetBoundColorDrawBufferType(static_cast(ii));\n      if (dst_format == 0)\n        continue;\n      draw_buffer_has_image = true;\n      if (!src_internal_format) {\n        read_framebuffer_miss_image = true;\n      }\n      if (GLES2Util::GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB)\n        draw_buffers_has_srgb = true;\n      if (read_buffer_samples > 0 &&\n          (src_sized_format !=\n           GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) {\n        LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n                           \"src and dst formats differ for color\");\n        return;\n      }\n      bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format);\n      bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format);\n      DCHECK(!is_dst_signed_int || !is_dst_unsigned_int);\n      if (is_src_signed_int != is_dst_signed_int ||\n          is_src_unsigned_int != is_dst_unsigned_int) {\n        LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n                           \"incompatible src\/dst color formats\");\n        return;\n      }\n      if (is_feedback_loop == FeedbackLoopUnknown) {\n        GLenum attachment = static_cast(GL_COLOR_ATTACHMENT0 + ii);\n        DCHECK(draw_framebuffer);\n        const Framebuffer::Attachment* draw_buffer =\n            draw_framebuffer->GetAttachment(attachment);\n        if (!draw_buffer || !read_buffer) {\n          continue;\n        }\n        if (draw_buffer->IsSameAttachment(read_buffer)) {\n          is_feedback_loop = FeedbackLoopTrue;\n          break;\n        }\n      }\n    }\n    if (draw_framebuffer && !draw_buffer_has_image)\n      mask_blit &= ~GL_COLOR_BUFFER_BIT;\n  }\n  if (is_feedback_loop == FeedbackLoopTrue) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n        \"source buffer and destination buffers are identical\");\n    return;\n  }\n  if (read_framebuffer_miss_image == true) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n       \"The designated attachment point(s) in read framebuffer miss image\");\n    return;\n  }\n\n  if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) {\n    if (filter != GL_NEAREST) {\n      LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n                         \"invalid filter for depth\/stencil\");\n      return;\n    }\n  }\n\n  mask = mask_blit;\n  if (!mask)\n    return;\n\n  if (((mask & GL_DEPTH_BUFFER_BIT) != 0 &&\n      (GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) !=\n      GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER))) ||\n      ((mask & GL_STENCIL_BUFFER_BIT) != 0 &&\n      ((GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) !=\n      GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))))) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,\n                       \"src and dst formats differ for depth\/stencil\");\n    return;\n  }\n\n  base::CheckedNumeric src_width_temp = srcX1;\n  src_width_temp -= srcX0;\n  base::CheckedNumeric src_height_temp = srcY1;\n  src_height_temp -= srcY0;\n  base::CheckedNumeric dst_width_temp = dstX1;\n  dst_width_temp -= dstX0;\n  base::CheckedNumeric dst_height_temp = dstY1;\n  dst_height_temp -= dstY0;\n  if (!src_width_temp.Abs().IsValid() || !src_height_temp.Abs().IsValid() ||\n      !dst_width_temp.Abs().IsValid() || !dst_height_temp.Abs().IsValid()) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name,\n                       \"the width or height of src or dst region overflowed\");\n    return;\n  }\n\n  if (workarounds().adjust_src_dst_region_for_blitframebuffer) {\n    gfx::Size read_size = GetBoundReadFramebufferSize();\n    GLint src_x = srcX1 > srcX0 ? srcX0 : srcX1;\n    GLint src_y = srcY1 > srcY0 ? srcY0 : srcY1;\n    unsigned int src_width = base::checked_cast(\n        src_width_temp.Abs().ValueOrDefault(0));\n    unsigned int src_height = base::checked_cast(\n        src_height_temp.Abs().ValueOrDefault(0));\n\n    GLint dst_x = dstX1 > dstX0 ? dstX0 : dstX1;\n    GLint dst_y = dstY1 > dstY0 ? dstY0 : dstY1;\n    unsigned int dst_width = base::checked_cast(\n        dst_width_temp.Abs().ValueOrDefault(0));\n    unsigned int dst_height = base::checked_cast(\n        dst_height_temp.Abs().ValueOrDefault(0));\n\n    if (dst_width == 0 || src_width == 0 || dst_height == 0 ||\n        src_height == 0) {\n      return;\n    }\n\n    gfx::Rect src_bounds(0, 0, read_size.width(), read_size.height());\n    gfx::Rect src_region(src_x, src_y, src_width, src_height);\n\n    gfx::Rect dst_bounds(0, 0, draw_size.width(), draw_size.height());\n    gfx::Rect dst_region(dst_x, dst_y, dst_width, dst_height);\n\n    if (gfx::IntersectRects(dst_bounds, dst_region).IsEmpty()) {\n      return;\n    }\n\n    bool x_flipped = ((srcX1 > srcX0) && (dstX1 < dstX0)) ||\n                     ((srcX1 < srcX0) && (dstX1 > dstX0));\n    bool y_flipped = ((srcY1 > srcY0) && (dstY1 < dstY0)) ||\n                     ((srcY1 < srcY0) && (dstY1 > dstY0));\n\n    if (!dst_bounds.Contains(dst_region)) {\n\n      unsigned int dst_x_halvings = 0;\n      unsigned int dst_y_halvings = 0;\n      int dst_origin_x = dst_x;\n      int dst_origin_y = dst_y;\n\n      int dst_clipped_width = dst_region.width();\n      while (dst_clipped_width > 2 * dst_bounds.width()) {\n        dst_clipped_width = dst_clipped_width >> 1;\n        dst_x_halvings++;\n      }\n\n      int dst_clipped_height = dst_region.height();\n      while (dst_clipped_height > 2 * dst_bounds.height()) {\n        dst_clipped_height = dst_clipped_height >> 1;\n        dst_y_halvings++;\n      }\n\n\n      int left = dst_region.x();\n      int right = dst_region.right();\n      int top = dst_region.y();\n      int bottom = dst_region.bottom();\n\n      if (left >= 0 && left < dst_bounds.width()) {\n        dst_origin_x = dst_x;\n      } else if (right > 0 && right <= dst_bounds.width()) {\n        dst_origin_x = right - dst_clipped_width;\n      } else {\n        dst_origin_x = dst_x;\n      }\n\n      if (top >= 0 && top < dst_bounds.height()) {\n        dst_origin_y = dst_y;\n      } else if (bottom > 0 && bottom <= dst_bounds.height()) {\n        dst_origin_y = bottom - dst_clipped_height;\n      } else {\n        dst_origin_y = dst_y;\n      }\n\n      dst_region.SetRect(dst_origin_x, dst_origin_y, dst_clipped_width,\n                         dst_clipped_height);\n\n      base::CheckedNumeric checked_xoffset(dst_region.x() -\n                                                         dst_x);\n      base::CheckedNumeric checked_yoffset(dst_region.y() -\n                                                         dst_y);\n\n      if (x_flipped) {\n        checked_xoffset = (dst_x + dst_width - dst_region.right());\n      }\n      if (y_flipped) {\n        checked_yoffset = (dst_y + dst_height - dst_region.bottom());\n      }\n\n      unsigned int xoffset, yoffset;\n      if (!checked_xoffset.AssignIfValid(&xoffset) ||\n          !checked_yoffset.AssignIfValid(&yoffset)) {\n        NOTREACHED();\n        LOCAL_SET_GL_ERROR(\n            GL_INVALID_VALUE, func_name,\n            \"the width or height of src or dst region overflowed\");\n        return;\n      }\n\n      src_region.SetRect(src_x + (xoffset >> dst_x_halvings),\n                         src_y + (yoffset >> dst_y_halvings),\n                         src_region.width() >> dst_x_halvings,\n                         src_region.height() >> dst_y_halvings);\n\n      if (src_region.width() == 0) {\n        src_region.set_width(1);\n      }\n      if (src_region.height() == 0) {\n        src_region.set_height(1);\n      }\n    }\n\n    if (!src_bounds.Contains(src_region)) {\n      src_region.Intersect(src_bounds);\n      GLuint src_real_width = src_region.width();\n      GLuint src_real_height = src_region.height();\n      GLuint xoffset = src_region.x() - src_x;\n      GLuint yoffset = src_region.y() - src_y;\n      if (x_flipped) {\n        xoffset = src_x + src_width - src_region.x() - src_region.width();\n      }\n      if (y_flipped) {\n        yoffset = src_y + src_height - src_region.y() - src_region.height();\n      }\n\n      GLfloat dst_mapping_width =\n          static_cast(src_real_width) * dst_width \/ src_width;\n      GLfloat dst_mapping_height =\n          static_cast(src_real_height) * dst_height \/ src_height;\n      GLfloat dst_mapping_xoffset =\n          static_cast(xoffset) * dst_width \/ src_width;\n      GLfloat dst_mapping_yoffset =\n          static_cast(yoffset) * dst_height \/ src_height;\n\n      GLuint dst_mapping_x0 =\n          std::round(dst_x + dst_mapping_xoffset);\n      GLuint dst_mapping_y0 =\n          std::round(dst_y + dst_mapping_yoffset);\n\n      GLuint dst_mapping_x1 =\n          std::round(dst_x + dst_mapping_xoffset + dst_mapping_width);\n      GLuint dst_mapping_y1 =\n          std::round(dst_y + dst_mapping_yoffset + dst_mapping_height);\n\n      dst_region.SetRect(dst_mapping_x0, dst_mapping_y0,\n                         dst_mapping_x1 - dst_mapping_x0,\n                         dst_mapping_y1 - dst_mapping_y0);\n    }\n\n    srcX0 = srcX0 < srcX1 ? src_region.x() : src_region.right();\n    srcY0 = srcY0 < srcY1 ? src_region.y() : src_region.bottom();\n    srcX1 = srcX0 < srcX1 ? src_region.right() : src_region.x();\n    srcY1 = srcY0 < srcY1 ? src_region.bottom() : src_region.y();\n\n    dstX0 = dstX0 < dstX1 ? dst_region.x() : dst_region.right();\n    dstY0 = dstY0 < dstY1 ? dst_region.y() : dst_region.bottom();\n    dstX1 = dstX0 < dstX1 ? dst_region.right() : dst_region.x();\n    dstY1 = dstY0 < dstY1 ? dst_region.bottom() : dst_region.y();\n  }\n\n  bool enable_srgb =\n      (read_buffer_has_srgb || draw_buffers_has_srgb) &&\n      ((mask & GL_COLOR_BUFFER_BIT) != 0);\n  bool encode_srgb_only =\n      (draw_buffers_has_srgb && !read_buffer_has_srgb) &&\n      ((mask & GL_COLOR_BUFFER_BIT) != 0);\n  if (!enable_srgb ||\n      read_buffer_samples > 0 ||\n      !feature_info_->feature_flags().desktop_srgb_support ||\n      gl_version_info().IsAtLeastGL(4, 4) ||\n      (gl_version_info().IsAtLeastGL(4, 2) && encode_srgb_only)) {\n    if (enable_srgb && gl_version_info().IsAtLeastGL(4, 2)) {\n      state_.EnableDisableFramebufferSRGB(enable_srgb);\n    }\n\n    api()->glBlitFramebufferFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,\n                               dstY1, mask, filter);\n    return;\n  }\n\n  state_.EnableDisableFramebufferSRGB(true);\n  if (!InitializeSRGBConverter(func_name)) {\n    return;\n  }\n  GLenum src_format =\n      TextureManager::ExtractFormatFromStorageFormat(src_internal_format);\n  srgb_converter_->Blit(this, srcX0, srcY0, srcX1, srcY1,\n                        dstX0, dstY0, dstX1, dstY1,\n                        mask, filter,\n                        GetBoundReadFramebufferSize(),\n                        GetBoundReadFramebufferServiceId(),\n                        src_internal_format, src_format, src_type,\n                        GetBoundDrawFramebufferServiceId(),\n                        read_buffer_has_srgb, draw_buffers_has_srgb,\n                        state_.enable_flags.scissor_test);\n}\n","target":0,"code_token_length":3891,"total_token_length":4127,"max_tokens_setting":6144}
+{"idx":60342,"func":"define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)\n{\n    int\t\tj;\n    int\t\tc;\n    int\t\tsaved_did_emsg = FALSE;\n    char_u\t*name = name_arg;\n    int\t\tis_global = FALSE;\n    char_u\t*p;\n    char_u\t*arg;\n    char_u\t*whitep;\n    char_u\t*line_arg = NULL;\n    garray_T\tnewargs;\n    garray_T\targtypes;\n    garray_T\tdefault_args;\n    garray_T\tnewlines;\n    int\t\tvarargs = FALSE;\n    int\t\tflags = 0;\n    char_u\t*ret_type = NULL;\n    ufunc_T\t*fp = NULL;\n    int\t\tfp_allocated = FALSE;\n    int\t\tfree_fp = FALSE;\n    int\t\toverwrite = FALSE;\n    dictitem_T\t*v;\n    funcdict_T\tfudi;\n    static int\tfunc_nr = 0;\t    \/\/ number for nameless function\n    int\t\tparen;\n    hashitem_T\t*hi;\n    linenr_T\tsourcing_lnum_top;\n    int\t\tvim9script = in_vim9script();\n    imported_T\t*import = NULL;\n\n    \/*\n     * \":function\" without argument: list functions.\n     *\/\n    if (ends_excmd2(eap->cmd, eap->arg))\n    {\n\tif (!eap->skip)\n\t    list_functions(NULL);\n\tset_nextcmd(eap, eap->arg);\n\treturn NULL;\n    }\n\n    \/*\n     * \":function \/pat\": list functions matching pattern.\n     *\/\n    if (*eap->arg == '\/')\n    {\n\tp = skip_regexp(eap->arg + 1, '\/', TRUE);\n\tif (!eap->skip)\n\t{\n\t    regmatch_T\tregmatch;\n\n\t    c = *p;\n\t    *p = NUL;\n\t    regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC);\n\t    *p = c;\n\t    if (regmatch.regprog != NULL)\n\t    {\n\t\tregmatch.rm_ic = p_ic;\n\t\tlist_functions(®match);\n\t\tvim_regfree(regmatch.regprog);\n\t    }\n\t}\n\tif (*p == '\/')\n\t    ++p;\n\tset_nextcmd(eap, p);\n\treturn NULL;\n    }\n\n    ga_init(&newargs);\n    ga_init(&argtypes);\n    ga_init(&default_args);\n\n    \/*\n     * Get the function name.  There are these situations:\n     * func\t    normal function name\n     *\t\t    \"name\" == func, \"fudi.fd_dict\" == NULL\n     * dict.func    new dictionary entry\n     *\t\t    \"name\" == NULL, \"fudi.fd_dict\" set,\n     *\t\t    \"fudi.fd_di\" == NULL, \"fudi.fd_newkey\" == func\n     * dict.func    existing dict entry with a Funcref\n     *\t\t    \"name\" == func, \"fudi.fd_dict\" set,\n     *\t\t    \"fudi.fd_di\" set, \"fudi.fd_newkey\" == NULL\n     * dict.func    existing dict entry that's not a Funcref\n     *\t\t    \"name\" == NULL, \"fudi.fd_dict\" set,\n     *\t\t    \"fudi.fd_di\" set, \"fudi.fd_newkey\" == NULL\n     * s:func\t    script-local function name\n     * g:func\t    global function name, same as \"func\"\n     *\/\n    p = eap->arg;\n    if (name_arg != NULL)\n    {\n\t\/\/ nested function, argument is (args).\n\tparen = TRUE;\n\tCLEAR_FIELD(fudi);\n    }\n    else\n    {\n\tif (vim9script)\n\t{\n\t    if (p[0] == 's' && p[1] == ':')\n\t    {\n\t\tsemsg(_(e_cannot_use_s_colon_in_vim9_script_str), p);\n\t\treturn NULL;\n\t    }\n\t    p = to_name_end(p, TRUE);\n\t    if (*skipwhite(p) == '.' && vim_strchr(p, '(') != NULL)\n\t    {\n\t\tsemsg(_(e_cannot_define_dict_func_in_vim9_script_str),\n\t\t\t\t\t\t\t\t     eap->arg);\n\t\treturn NULL;\n\t    }\n\t    p = eap->arg;\n\t}\n\n\tname = save_function_name(&p, &is_global, eap->skip,\n\t\t\t\t\tTFN_NO_AUTOLOAD | TFN_NEW_FUNC, &fudi);\n\tparen = (vim_strchr(p, '(') != NULL);\n\tif (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip)\n\t{\n\t    \/*\n\t     * Return on an invalid expression in braces, unless the expression\n\t     * evaluation has been cancelled due to an aborting error, an\n\t     * interrupt, or an exception.\n\t     *\/\n\t    if (!aborting())\n\t    {\n\t\tif (!eap->skip && fudi.fd_newkey != NULL)\n\t\t    semsg(_(e_key_not_present_in_dictionary), fudi.fd_newkey);\n\t\tvim_free(fudi.fd_newkey);\n\t\treturn NULL;\n\t    }\n\t    else\n\t\teap->skip = TRUE;\n\t}\n\n\t\/\/ For \"export def FuncName()\" in an autoload script the function name\n\t\/\/ is stored with the legacy autoload name \"dir#script#FuncName\" so\n\t\/\/ that it can also be found in legacy script.\n\tif (is_export && name != NULL)\n\t{\n\t    char_u *prefixed = may_prefix_autoload(name);\n\n\t    if (prefixed != NULL && prefixed != name)\n\t    {\n\t\tvim_free(name);\n\t\tname = prefixed;\n\t    }\n\t}\n\telse if (paren && vim9script && name != NULL\n\t\t\t\t    && vim_strchr(name, AUTOLOAD_CHAR) != NULL)\n\t{\n\t    emsg(_(e_cannot_use_name_with_hash_in_vim9_script_use_export_instead));\n\t    goto ret_free;\n\t}\n    }\n\n    \/\/ An error in a function call during evaluation of an expression in magic\n    \/\/ braces should not cause the function not to be defined.\n    saved_did_emsg = did_emsg;\n    did_emsg = FALSE;\n\n    \/*\n     * \":function func\" with only function name: list function.\n     *\/\n    if (!paren)\n    {\n\tif (!ends_excmd(*skipwhite(p)))\n\t{\n\t    semsg(_(e_trailing_characters_str), p);\n\t    goto ret_free;\n\t}\n\tset_nextcmd(eap, p);\n\tif (eap->nextcmd != NULL)\n\t    *p = NUL;\n\tif (!eap->skip && !got_int)\n\t{\n\t    fp = find_func(name, is_global);\n\t    if (fp == NULL && ASCII_ISUPPER(*eap->arg))\n\t    {\n\t\tchar_u *up = untrans_function_name(name);\n\n\t\t\/\/ With Vim9 script the name was made script-local, if not\n\t\t\/\/ found try again with the original name.\n\t\tif (up != NULL)\n\t\t    fp = find_func(up, FALSE);\n\t    }\n\n\t    if (fp != NULL)\n\t    {\n\t\tlist_func_head(fp, TRUE);\n\t\tfor (j = 0; j < fp->uf_lines.ga_len && !got_int; ++j)\n\t\t{\n\t\t    if (FUNCLINE(fp, j) == NULL)\n\t\t\tcontinue;\n\t\t    msg_putchar('\\n');\n\t\t    msg_outnum((long)(j + 1));\n\t\t    if (j < 9)\n\t\t\tmsg_putchar(' ');\n\t\t    if (j < 99)\n\t\t\tmsg_putchar(' ');\n\t\t    msg_prt_line(FUNCLINE(fp, j), FALSE);\n\t\t    out_flush();\t\/\/ show a line at a time\n\t\t    ui_breakcheck();\n\t\t}\n\t\tif (!got_int)\n\t\t{\n\t\t    msg_putchar('\\n');\n\t\t    if (fp->uf_def_status != UF_NOT_COMPILED)\n\t\t\tmsg_puts(\"   enddef\");\n\t\t    else\n\t\t\tmsg_puts(\"   endfunction\");\n\t\t}\n\t    }\n\t    else\n\t\temsg_funcname(e_undefined_function_str, eap->arg);\n\t}\n\tgoto ret_free;\n    }\n\n    \/*\n     * \":function name(arg1, arg2)\" Define function.\n     *\/\n    p = skipwhite(p);\n    if (*p != '(')\n    {\n\tif (!eap->skip)\n\t{\n\t    semsg(_(e_missing_paren_str), eap->arg);\n\t    goto ret_free;\n\t}\n\t\/\/ attempt to continue by skipping some text\n\tif (vim_strchr(p, '(') != NULL)\n\t    p = vim_strchr(p, '(');\n    }\n\n    if ((vim9script || eap->cmdidx == CMD_def) && VIM_ISWHITE(p[-1]))\n    {\n\tsemsg(_(e_no_white_space_allowed_before_str_str), \"(\", p - 1);\n\tgoto ret_free;\n    }\n\n    \/\/ In Vim9 script only global functions can be redefined.\n    if (vim9script && eap->forceit && !is_global)\n    {\n\temsg(_(e_no_bang_allowed));\n\tgoto ret_free;\n    }\n\n    ga_init2(&newlines, sizeof(char_u *), 10);\n\n    if (!eap->skip && name_arg == NULL)\n    {\n\t\/\/ Check the name of the function.  Unless it's a dictionary function\n\t\/\/ (that we are overwriting).\n\tif (name != NULL)\n\t    arg = name;\n\telse\n\t    arg = fudi.fd_newkey;\n\tif (arg != NULL && (fudi.fd_di == NULL\n\t\t\t\t     || (fudi.fd_di->di_tv.v_type != VAR_FUNC\n\t\t\t\t && fudi.fd_di->di_tv.v_type != VAR_PARTIAL)))\n\t{\n\t    char_u  *name_base = arg;\n\t    int\t    i;\n\n\t    if (*arg == K_SPECIAL)\n\t    {\n\t\tname_base = vim_strchr(arg, '_');\n\t\tif (name_base == NULL)\n\t\t    name_base = arg + 3;\n\t\telse\n\t\t    ++name_base;\n\t    }\n\t    for (i = 0; name_base[i] != NUL && (i == 0\n\t\t\t\t\t? eval_isnamec1(name_base[i])\n\t\t\t\t\t: eval_isnamec(name_base[i])); ++i)\n\t\t;\n\t    if (name_base[i] != NUL)\n\t\temsg_funcname(e_invalid_argument_str, arg);\n\n\t    \/\/ In Vim9 script a function cannot have the same name as a\n\t    \/\/ variable.\n\t    if (vim9script && *arg == K_SPECIAL\n\t\t&& eval_variable(name_base, (int)STRLEN(name_base), 0, NULL,\n\t\t    NULL, EVAL_VAR_NOAUTOLOAD + EVAL_VAR_IMPORT\n\t\t\t\t\t\t     + EVAL_VAR_NO_FUNC) == OK)\n\t    {\n\t\tsemsg(_(e_redefining_script_item_str), name_base);\n\t\tgoto ret_free;\n\t    }\n\t}\n\t\/\/ Disallow using the g: dict.\n\tif (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE)\n\t{\n\t    emsg(_(e_cannot_use_g_here));\n\t    goto ret_free;\n\t}\n    }\n\n    \/\/ This may get more lines and make the pointers into the first line\n    \/\/ invalid.\n    ++p;\n    if (get_function_args(&p, ')', &newargs,\n\t\t\teap->cmdidx == CMD_def ? &argtypes : NULL, FALSE,\n\t\t\t NULL, &varargs, &default_args, eap->skip,\n\t\t\t eap, lines_to_free) == FAIL)\n\tgoto errret_2;\n    whitep = p;\n\n    if (eap->cmdidx == CMD_def)\n    {\n\t\/\/ find the return type: :def Func(): type\n\tif (*skipwhite(p) == ':')\n\t{\n\t    if (*p != ':')\n\t    {\n\t\tsemsg(_(e_no_white_space_allowed_before_colon_str), p);\n\t\tp = skipwhite(p);\n\t    }\n\t    else if (!IS_WHITE_OR_NUL(p[1]))\n\t\tsemsg(_(e_white_space_required_after_str_str), \":\", p);\n\t    ret_type = skipwhite(p + 1);\n\t    p = skip_type(ret_type, FALSE);\n\t    if (p > ret_type)\n\t    {\n\t\tret_type = vim_strnsave(ret_type, p - ret_type);\n\t\twhitep = p;\n\t\tp = skipwhite(p);\n\t    }\n\t    else\n\t    {\n\t\tsemsg(_(e_expected_type_str), ret_type);\n\t\tret_type = NULL;\n\t    }\n\t}\n\tp = skipwhite(p);\n    }\n    else\n\t\/\/ find extra arguments \"range\", \"dict\", \"abort\" and \"closure\"\n\tfor (;;)\n\t{\n\t    whitep = p;\n\t    p = skipwhite(p);\n\t    if (STRNCMP(p, \"range\", 5) == 0)\n\t    {\n\t\tflags |= FC_RANGE;\n\t\tp += 5;\n\t    }\n\t    else if (STRNCMP(p, \"dict\", 4) == 0)\n\t    {\n\t\tflags |= FC_DICT;\n\t\tp += 4;\n\t    }\n\t    else if (STRNCMP(p, \"abort\", 5) == 0)\n\t    {\n\t\tflags |= FC_ABORT;\n\t\tp += 5;\n\t    }\n\t    else if (STRNCMP(p, \"closure\", 7) == 0)\n\t    {\n\t\tflags |= FC_CLOSURE;\n\t\tp += 7;\n\t\tif (current_funccal == NULL)\n\t\t{\n\t\t    emsg_funcname(e_closure_function_should_not_be_at_top_level,\n\t\t\t    name == NULL ? (char_u *)\"\" : name);\n\t\t    goto erret;\n\t\t}\n\t    }\n\t    else\n\t\tbreak;\n\t}\n\n    \/\/ When there is a line break use what follows for the function body.\n    \/\/ Makes 'exe \"func Test()\\n...\\nendfunc\"' work.\n    if (*p == '\\n')\n\tline_arg = p + 1;\n    else if (*p != NUL\n\t    && !(*p == '\"' && (!vim9script || eap->cmdidx == CMD_function)\n\t\t\t\t\t\t     && eap->cmdidx != CMD_def)\n\t    && !(VIM_ISWHITE(*whitep) && *p == '#'\n\t\t\t\t     && (vim9script || eap->cmdidx == CMD_def))\n\t    && !eap->skip\n\t    && !did_emsg)\n\tsemsg(_(e_trailing_characters_str), p);\n\n    \/*\n     * Read the body of the function, until \"}\", \":endfunction\" or \":enddef\" is\n     * found.\n     *\/\n    if (KeyTyped)\n    {\n\t\/\/ Check if the function already exists, don't let the user type the\n\t\/\/ whole function before telling him it doesn't work!  For a script we\n\t\/\/ need to skip the body to be able to find what follows.\n\tif (!eap->skip && !eap->forceit)\n\t{\n\t    if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL)\n\t\temsg(_(e_dictionary_entry_already_exists));\n\t    else if (name != NULL && find_func(name, is_global) != NULL)\n\t\temsg_funcname(e_function_str_already_exists_add_bang_to_replace, name);\n\t}\n\n\tif (!eap->skip && did_emsg)\n\t    goto erret;\n\n\tmsg_putchar('\\n');\t    \/\/ don't overwrite the function name\n\tcmdline_row = msg_row;\n    }\n\n    \/\/ Save the starting line number.\n    sourcing_lnum_top = SOURCING_LNUM;\n\n    \/\/ Do not define the function when getting the body fails and when\n    \/\/ skipping.\n    if (get_function_body(eap, &newlines, line_arg, lines_to_free) == FAIL\n\t    || eap->skip)\n\tgoto erret;\n\n    \/*\n     * If there are no errors, add the function\n     *\/\n    if (fudi.fd_dict == NULL)\n    {\n\thashtab_T\t*ht;\n\tchar_u\t\t*find_name = name;\n\tint\t\tvar_conflict = FALSE;\n\tint\t\tffed_flags = is_global ? FFED_IS_GLOBAL : 0;\n\n\tv = find_var(name, &ht, TRUE);\n\tif (v != NULL && (vim9script || v->di_tv.v_type == VAR_FUNC))\n\t    var_conflict = TRUE;\n\n\tif (SCRIPT_ID_VALID(current_sctx.sc_sid))\n\t{\n\t    scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);\n\n\t    if (si->sn_autoload_prefix != NULL)\n\t    {\n\t\tif (is_export)\n\t\t{\n\t\t    find_name = name + STRLEN(si->sn_autoload_prefix);\n\t\t    v = find_var(find_name, &ht, TRUE);\n\t\t    if (v != NULL)\n\t\t\tvar_conflict = TRUE;\n\t\t    \/\/ Only check if the function already exists in the script,\n\t\t    \/\/ global functions can be shadowed.\n\t\t    ffed_flags |= FFED_NO_GLOBAL;\n\t\t}\n\t\telse\n\t\t{\n\t\t    char_u *prefixed = may_prefix_autoload(name);\n\n\t\t    if (prefixed != NULL && prefixed != name)\n\t\t    {\n\t\t\tv = find_var(prefixed, &ht, TRUE);\n\t\t\tif (v != NULL)\n\t\t\t    var_conflict = TRUE;\n\t\t\tvim_free(prefixed);\n\t\t    }\n\t\t}\n\t    }\n\t}\n\tif (var_conflict)\n\t{\n\t    emsg_funcname(e_function_name_conflicts_with_variable_str, name);\n\t    goto erret;\n\t}\n\n\tfp = find_func_even_dead(find_name, ffed_flags);\n\tif (vim9script)\n\t{\n\t    char_u *uname = untrans_function_name(name);\n\n\t    import = find_imported(uname == NULL ? name : uname, 0, FALSE);\n\t}\n\n\tif (fp != NULL || import != NULL)\n\t{\n\t    int dead = fp != NULL && (fp->uf_flags & FC_DEAD);\n\n\t    \/\/ Function can be replaced with \"function!\" and when sourcing the\n\t    \/\/ same script again, but only once.\n\t    \/\/ A name that is used by an import can not be overruled.\n\t    if (import != NULL\n\t\t    || (!dead && !eap->forceit\n\t\t\t&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid\n\t\t\t  || fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)))\n\t    {\n\t\tSOURCING_LNUM = sourcing_lnum_top;\n\t\tif (vim9script)\n\t\t    emsg_funcname(e_name_already_defined_str, name);\n\t\telse\n\t\t    emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name);\n\t\tgoto erret;\n\t    }\n\t    if (fp->uf_calls > 0)\n\t    {\n\t\temsg_funcname(\n\t\t\t    e_cannot_redefine_function_str_it_is_in_use, name);\n\t\tgoto erret;\n\t    }\n\t    if (fp->uf_refcount > 1)\n\t    {\n\t\t\/\/ This function is referenced somewhere, don't redefine it but\n\t\t\/\/ create a new one.\n\t\t--fp->uf_refcount;\n\t\tfp->uf_flags |= FC_REMOVED;\n\t\tfp = NULL;\n\t\toverwrite = TRUE;\n\t    }\n\t    else\n\t    {\n\t\tchar_u *exp_name = fp->uf_name_exp;\n\n\t\t\/\/ redefine existing function, keep the expanded name\n\t\tVIM_CLEAR(name);\n\t\tfp->uf_name_exp = NULL;\n\t\tfunc_clear_items(fp);\n\t\tfp->uf_name_exp = exp_name;\n\t\tfp->uf_flags &= ~FC_DEAD;\n#ifdef FEAT_PROFILE\n\t\tfp->uf_profiling = FALSE;\n\t\tfp->uf_prof_initialized = FALSE;\n#endif\n\t\tfp->uf_def_status = UF_NOT_COMPILED;\n\t    }\n\t}\n    }\n    else\n    {\n\tchar\tnumbuf[20];\n\n\tfp = NULL;\n\tif (fudi.fd_newkey == NULL && !eap->forceit)\n\t{\n\t    emsg(_(e_dictionary_entry_already_exists));\n\t    goto erret;\n\t}\n\tif (fudi.fd_di == NULL)\n\t{\n\t    \/\/ Can't add a function to a locked dictionary\n\t    if (value_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE))\n\t\tgoto erret;\n\t}\n\t    \/\/ Can't change an existing function if it is locked\n\telse if (value_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE))\n\t    goto erret;\n\n\t\/\/ Give the function a sequential number.  Can only be used with a\n\t\/\/ Funcref!\n\tvim_free(name);\n\tsprintf(numbuf, \"%d\", ++func_nr);\n\tname = vim_strsave((char_u *)numbuf);\n\tif (name == NULL)\n\t    goto erret;\n    }\n\n    if (fp == NULL)\n    {\n\tif (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL)\n\t{\n\t    int\t    slen, plen;\n\t    char_u  *scriptname;\n\n\t    \/\/ Check that the autoload name matches the script name.\n\t    j = FAIL;\n\t    if (SOURCING_NAME != NULL)\n\t    {\n\t\tscriptname = autoload_name(name);\n\t\tif (scriptname != NULL)\n\t\t{\n\t\t    p = vim_strchr(scriptname, '\/');\n\t\t    plen = (int)STRLEN(p);\n\t\t    slen = (int)STRLEN(SOURCING_NAME);\n\t\t    if (slen > plen && fnamecmp(p,\n\t\t\t\t\t    SOURCING_NAME + slen - plen) == 0)\n\t\t\tj = OK;\n\t\t    vim_free(scriptname);\n\t\t}\n\t    }\n\t    if (j == FAIL)\n\t    {\n\t\tlinenr_T save_lnum = SOURCING_LNUM;\n\n\t\tSOURCING_LNUM = sourcing_lnum_top;\n\t\tsemsg(_(e_function_name_does_not_match_script_file_name_str),\n\t\t\t\t\t\t\t\t\t name);\n\t\tSOURCING_LNUM = save_lnum;\n\t\tgoto erret;\n\t    }\n\t}\n\n\tfp = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);\n\tif (fp == NULL)\n\t    goto erret;\n\tfp_allocated = TRUE;\n\n\tif (fudi.fd_dict != NULL)\n\t{\n\t    if (fudi.fd_di == NULL)\n\t    {\n\t\t\/\/ add new dict entry\n\t\tfudi.fd_di = dictitem_alloc(fudi.fd_newkey);\n\t\tif (fudi.fd_di == NULL)\n\t\t{\n\t\t    vim_free(fp);\n\t\t    fp = NULL;\n\t\t    goto erret;\n\t\t}\n\t\tif (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL)\n\t\t{\n\t\t    vim_free(fudi.fd_di);\n\t\t    vim_free(fp);\n\t\t    fp = NULL;\n\t\t    goto erret;\n\t\t}\n\t    }\n\t    else\n\t\t\/\/ overwrite existing dict entry\n\t\tclear_tv(&fudi.fd_di->di_tv);\n\t    fudi.fd_di->di_tv.v_type = VAR_FUNC;\n\t    fudi.fd_di->di_tv.vval.v_string = vim_strsave(name);\n\n\t    \/\/ behave like \"dict\" was used\n\t    flags |= FC_DICT;\n\t}\n    }\n    fp->uf_args = newargs;\n    fp->uf_def_args = default_args;\n    fp->uf_ret_type = &t_any;\n    fp->uf_func_type = &t_func_any;\n\n    if (eap->cmdidx == CMD_def)\n    {\n\tint\t    lnum_save = SOURCING_LNUM;\n\tcstack_T    *cstack = eap->cstack;\n\n\tfp->uf_def_status = UF_TO_BE_COMPILED;\n\n\t\/\/ error messages are for the first function line\n\tSOURCING_LNUM = sourcing_lnum_top;\n\n\t\/\/ The function may use script variables from the context.\n\tfunction_using_block_scopes(fp, cstack);\n\n\tif (parse_argument_types(fp, &argtypes, varargs) == FAIL)\n\t{\n\t    SOURCING_LNUM = lnum_save;\n\t    free_fp = fp_allocated;\n\t    goto erret;\n\t}\n\tvarargs = FALSE;\n\n\t\/\/ parse the return type, if any\n\tif (parse_return_type(fp, ret_type) == FAIL)\n\t{\n\t    SOURCING_LNUM = lnum_save;\n\t    free_fp = fp_allocated;\n\t    goto erret;\n\t}\n\tSOURCING_LNUM = lnum_save;\n    }\n    else\n\tfp->uf_def_status = UF_NOT_COMPILED;\n\n    if (fp_allocated)\n    {\n\t\/\/ insert the new function in the function list\n\tset_ufunc_name(fp, name);\n\tif (overwrite)\n\t{\n\t    hi = hash_find(&func_hashtab, name);\n\t    hi->hi_key = UF2HIKEY(fp);\n\t}\n\telse if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL)\n\t{\n\t    free_fp = TRUE;\n\t    goto erret;\n\t}\n\tfp->uf_refcount = 1;\n    }\n\n    fp->uf_lines = newlines;\n    newlines.ga_data = NULL;\n    if ((flags & FC_CLOSURE) != 0)\n    {\n\tif (register_closure(fp) == FAIL)\n\t    goto erret;\n    }\n    else\n\tfp->uf_scoped = NULL;\n\n#ifdef FEAT_PROFILE\n    if (prof_def_func())\n\tfunc_do_profile(fp);\n#endif\n    fp->uf_varargs = varargs;\n    if (sandbox)\n\tflags |= FC_SANDBOX;\n    if (vim9script && !ASCII_ISUPPER(*fp->uf_name))\n\tflags |= FC_VIM9;\n    fp->uf_flags = flags;\n    fp->uf_calls = 0;\n    fp->uf_cleared = FALSE;\n    fp->uf_script_ctx = current_sctx;\n    fp->uf_script_ctx_version = current_sctx.sc_version;\n    fp->uf_script_ctx.sc_lnum += sourcing_lnum_top;\n    if (is_export)\n    {\n\tfp->uf_flags |= FC_EXPORT;\n\t\/\/ let ex_export() know the export worked.\n\tis_export = FALSE;\n    }\n\n    if (eap->cmdidx == CMD_def)\n\tset_function_type(fp);\n    else if (fp->uf_script_ctx.sc_version == SCRIPT_VERSION_VIM9)\n\t\/\/ :func does not use Vim9 script syntax, even in a Vim9 script file\n\tfp->uf_script_ctx.sc_version = SCRIPT_VERSION_MAX;\n\n    goto ret_free;\n\nerret:\n    ga_clear_strings(&newargs);\n    ga_clear_strings(&default_args);\n    if (fp != NULL)\n    {\n\tga_init(&fp->uf_args);\n\tga_init(&fp->uf_def_args);\n    }\nerrret_2:\n    ga_clear_strings(&newlines);\n    if (fp != NULL)\n\tVIM_CLEAR(fp->uf_arg_types);\n    if (free_fp)\n    {\n\tvim_free(fp);\n\tfp = NULL;\n    }\nret_free:\n    ga_clear_strings(&argtypes);\n    vim_free(fudi.fd_newkey);\n    if (name != name_arg)\n\tvim_free(name);\n    vim_free(ret_type);\n    did_emsg |= saved_did_emsg;\n\n    return fp;\n}","target":0,"code_token_length":5639,"total_token_length":5875,"max_tokens_setting":6144}
+{"idx":25821,"func":"void vp9_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint8_t * dst , ptrdiff_t stride , const uint8_t * above , const uint8_t * left ) {\n type ## _predictor ( dst , stride , size , above , left ) ;\n }\n # if CONFIG_VP9_HIGHBITDEPTH # define intra_pred_high_sized ( type , size ) void vp9_high_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint16_t * dst , ptrdiff_t stride , const uint16_t * above , const uint16_t * left , int bd ) {\n high_ ## type ## _predictor ( dst , stride , size , above , left , bd ) ;\n }\n # define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) intra_pred_high_sized ( type , 4 ) intra_pred_high_sized ( type , 8 ) intra_pred_high_sized ( type , 16 ) intra_pred_high_sized ( type , 32 ) # else # define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) # endif # if CONFIG_VP9_HIGHBITDEPTH static INLINE void high_d207_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n ( void ) above ;\n ( void ) bd ;\n for ( r = 0 ;\n r < bs - 1 ;\n ++ r ) {\n dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;\n }\n dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;\n dst ++ ;\n for ( r = 0 ;\n r < bs - 2 ;\n ++ r ) {\n dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;\n }\n dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;\n dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;\n dst ++ ;\n for ( c = 0 ;\n c < bs - 2 ;\n ++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;\n for ( r = bs - 2 ;\n r >= 0 ;\n -- r ) {\n for ( c = 0 ;\n c < bs - 2 ;\n ++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;\n }\n }\n static INLINE void high_d63_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n ( void ) left ;\n ( void ) bd ;\n for ( r = 0 ;\n r < bs ;\n ++ r ) {\n for ( c = 0 ;\n c < bs ;\n ++ c ) {\n dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r \/ 2 + c ] + above [ r \/ 2 + c + 1 ] * 2 + above [ r \/ 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r \/ 2 + c ] + above [ r \/ 2 + c + 1 ] , 1 ) ;\n }\n dst += stride ;\n }\n }\n static INLINE void high_d45_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n ( void ) left ;\n ( void ) bd ;\n for ( r = 0 ;\n r < bs ;\n ++ r ) {\n for ( c = 0 ;\n c < bs ;\n ++ c ) {\n dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;\n }\n dst += stride ;\n }\n }\n static INLINE void high_d117_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n ( void ) bd ;\n for ( c = 0 ;\n c < bs ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;\n dst += stride ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;\n dst += stride ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;\n for ( r = 3 ;\n r < bs ;\n ++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;\n for ( r = 2 ;\n r < bs ;\n ++ r ) {\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;\n dst += stride ;\n }\n }\n static INLINE void high_d135_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n ( void ) bd ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;\n dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;\n for ( r = 2 ;\n r < bs ;\n ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;\n dst += stride ;\n for ( r = 1 ;\n r < bs ;\n ++ r ) {\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;\n dst += stride ;\n }\n }\n static INLINE void high_d153_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n ( void ) bd ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;\n for ( r = 1 ;\n r < bs ;\n r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;\n dst ++ ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;\n dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;\n for ( r = 2 ;\n r < bs ;\n r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;\n dst ++ ;\n for ( c = 0 ;\n c < bs - 2 ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;\n dst += stride ;\n for ( r = 1 ;\n r < bs ;\n ++ r ) {\n for ( c = 0 ;\n c < bs - 2 ;\n c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;\n dst += stride ;\n }\n }\n static INLINE void high_v_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r ;\n ( void ) left ;\n ( void ) bd ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memcpy ( dst , above , bs * sizeof ( uint16_t ) ) ;\n dst += stride ;\n }\n }\n static INLINE void high_h_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r ;\n ( void ) above ;\n ( void ) bd ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset16 ( dst , left [ r ] , bs ) ;\n dst += stride ;\n }\n }\n static INLINE void high_tm_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r , c ;\n int ytop_left = above [ - 1 ] ;\n ( void ) bd ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n for ( c = 0 ;\n c < bs ;\n c ++ ) dst [ c ] = clip_pixel_high ( left [ r ] + above [ c ] - ytop_left , bd ) ;\n dst += stride ;\n }\n }\n static INLINE void high_dc_128_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int r ;\n ( void ) above ;\n ( void ) left ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset16 ( dst , 128 << ( bd - 8 ) , bs ) ;\n dst += stride ;\n }\n }\n static INLINE void high_dc_left_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int i , r , expected_dc , sum = 0 ;\n ( void ) above ;\n ( void ) bd ;\n for ( i = 0 ;\n i < bs ;\n i ++ ) sum += left [ i ] ;\n expected_dc = ( sum + ( bs >> 1 ) ) \/ bs ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset16 ( dst , expected_dc , bs ) ;\n dst += stride ;\n }\n }\n static INLINE void high_dc_top_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int i , r , expected_dc , sum = 0 ;\n ( void ) left ;\n ( void ) bd ;\n for ( i = 0 ;\n i < bs ;\n i ++ ) sum += above [ i ] ;\n expected_dc = ( sum + ( bs >> 1 ) ) \/ bs ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset16 ( dst , expected_dc , bs ) ;\n dst += stride ;\n }\n }\n static INLINE void high_dc_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {\n int i , r , expected_dc , sum = 0 ;\n const int count = 2 * bs ;\n ( void ) bd ;\n for ( i = 0 ;\n i < bs ;\n i ++ ) {\n sum += above [ i ] ;\n sum += left [ i ] ;\n }\n expected_dc = ( sum + ( count >> 1 ) ) \/ count ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset16 ( dst , expected_dc , bs ) ;\n dst += stride ;\n }\n }\n # endif static INLINE void d207_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n ( void ) above ;\n for ( r = 0 ;\n r < bs - 1 ;\n ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;\n dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;\n dst ++ ;\n for ( r = 0 ;\n r < bs - 2 ;\n ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;\n dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;\n dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;\n dst ++ ;\n for ( c = 0 ;\n c < bs - 2 ;\n ++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;\n for ( r = bs - 2 ;\n r >= 0 ;\n -- r ) for ( c = 0 ;\n c < bs - 2 ;\n ++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;\n }\n intra_pred_allsizes ( d207 ) static INLINE void d63_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n ( void ) left ;\n for ( r = 0 ;\n r < bs ;\n ++ r ) {\n for ( c = 0 ;\n c < bs ;\n ++ c ) dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r \/ 2 + c ] + above [ r \/ 2 + c + 1 ] * 2 + above [ r \/ 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r \/ 2 + c ] + above [ r \/ 2 + c + 1 ] , 1 ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( d63 ) static INLINE void d45_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n ( void ) left ;\n for ( r = 0 ;\n r < bs ;\n ++ r ) {\n for ( c = 0 ;\n c < bs ;\n ++ c ) dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( d45 ) static INLINE void d117_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n for ( c = 0 ;\n c < bs ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;\n dst += stride ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;\n dst += stride ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;\n for ( r = 3 ;\n r < bs ;\n ++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;\n for ( r = 2 ;\n r < bs ;\n ++ r ) {\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( d117 ) static INLINE void d135_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;\n dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;\n for ( r = 2 ;\n r < bs ;\n ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;\n dst += stride ;\n for ( r = 1 ;\n r < bs ;\n ++ r ) {\n for ( c = 1 ;\n c < bs ;\n c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( d135 ) static INLINE void d153_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;\n for ( r = 1 ;\n r < bs ;\n r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;\n dst ++ ;\n dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;\n dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;\n for ( r = 2 ;\n r < bs ;\n r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;\n dst ++ ;\n for ( c = 0 ;\n c < bs - 2 ;\n c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;\n dst += stride ;\n for ( r = 1 ;\n r < bs ;\n ++ r ) {\n for ( c = 0 ;\n c < bs - 2 ;\n c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( d153 ) static INLINE void v_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r ;\n ( void ) left ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memcpy ( dst , above , bs ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( v ) static INLINE void h_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r ;\n ( void ) above ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset ( dst , left [ r ] , bs ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( h ) static INLINE void tm_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r , c ;\n int ytop_left = above [ - 1 ] ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n for ( c = 0 ;\n c < bs ;\n c ++ ) dst [ c ] = clip_pixel ( left [ r ] + above [ c ] - ytop_left ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( tm ) static INLINE void dc_128_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int r ;\n ( void ) above ;\n ( void ) left ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset ( dst , 128 , bs ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( dc_128 ) static INLINE void dc_left_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int i , r , expected_dc , sum = 0 ;\n ( void ) above ;\n for ( i = 0 ;\n i < bs ;\n i ++ ) sum += left [ i ] ;\n expected_dc = ( sum + ( bs >> 1 ) ) \/ bs ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset ( dst , expected_dc , bs ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( dc_left ) static INLINE void dc_top_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int i , r , expected_dc , sum = 0 ;\n ( void ) left ;\n for ( i = 0 ;\n i < bs ;\n i ++ ) sum += above [ i ] ;\n expected_dc = ( sum + ( bs >> 1 ) ) \/ bs ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset ( dst , expected_dc , bs ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( dc_top ) static INLINE void dc_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {\n int i , r , expected_dc , sum = 0 ;\n const int count = 2 * bs ;\n for ( i = 0 ;\n i < bs ;\n i ++ ) {\n sum += above [ i ] ;\n sum += left [ i ] ;\n }\n expected_dc = ( sum + ( count >> 1 ) ) \/ count ;\n for ( r = 0 ;\n r < bs ;\n r ++ ) {\n vpx_memset ( dst , expected_dc , bs ) ;\n dst += stride ;\n }\n }\n intra_pred_allsizes ( dc )","target":0,"code_token_length":5405,"total_token_length":5641,"max_tokens_setting":6144}
+{"idx":351088,"func":"connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,\n                                           origin_circuit_t *circ,\n                                           crypt_path_t *cpath)\n{\n  socks_request_t *socks = conn->socks_request;\n  const or_options_t *options = get_options();\n  connection_t *base_conn = ENTRY_TO_CONN(conn);\n  time_t now = time(NULL);\n  rewrite_result_t rr;\n\n  \/* First we'll do the rewrite part.  Let's see if we get a reasonable\n   * answer.\n   *\/\n  memset(&rr, 0, sizeof(rr));\n  connection_ap_handshake_rewrite(conn,&rr);\n\n  if (rr.should_close) {\n    \/* connection_ap_handshake_rewrite told us to close the connection:\n     * either because it sent back an answer, or because it sent back an\n     * error *\/\n    connection_mark_unattached_ap(conn, rr.end_reason);\n    if (END_STREAM_REASON_DONE == (rr.end_reason & END_STREAM_REASON_MASK))\n      return 0;\n    else\n      return -1;\n  }\n\n  const time_t map_expires = rr.map_expires;\n  const int automap = rr.automap;\n  const addressmap_entry_source_t exit_source = rr.exit_source;\n\n  \/* Now see whether the hostname is bogus.  This could happen because of an\n   * onion hostname whose format we don't recognize. *\/\n  hostname_type_t addresstype;\n  if (!parse_extended_hostname(socks->address, &addresstype)) {\n    control_event_client_status(LOG_WARN, \"SOCKS_BAD_HOSTNAME HOSTNAME=%s\",\n                                escaped(socks->address));\n    if (addresstype == BAD_HOSTNAME) {\n      conn->socks_request->socks_extended_error_code = SOCKS5_HS_BAD_ADDRESS;\n    }\n    connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n    return -1;\n  }\n\n  \/* If this is a .exit hostname, strip off the .name.exit part, and\n   * see whether we're willing to connect there, and otherwise handle the\n   * .exit address.\n   *\n   * We'll set chosen_exit_name and\/or close the connection as appropriate.\n   *\/\n  if (addresstype == EXIT_HOSTNAME) {\n    \/* If StrictNodes is not set, then .exit overrides ExcludeNodes but\n     * not ExcludeExitNodes. *\/\n    routerset_t *excludeset = options->StrictNodes ?\n      options->ExcludeExitNodesUnion_ : options->ExcludeExitNodes;\n    const node_t *node = NULL;\n\n    \/* If this .exit was added by an AUTOMAP, then it came straight from\n     * a user.  That's not safe. *\/\n    if (exit_source == ADDRMAPSRC_AUTOMAP) {\n      \/* Whoops; this one is stale.  It must have gotten added earlier?\n       * (Probably this is not possible, since AllowDotExit no longer\n       * exists.) *\/\n      log_warn(LD_APP,\"Stale automapped address for '%s.exit'. Refusing.\",\n               safe_str_client(socks->address));\n      control_event_client_status(LOG_WARN, \"SOCKS_BAD_HOSTNAME HOSTNAME=%s\",\n                                  escaped(socks->address));\n      connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n      tor_assert_nonfatal_unreached();\n      return -1;\n    }\n\n    \/* Double-check to make sure there are no .exits coming from\n     * impossible\/weird sources. *\/\n    if (exit_source == ADDRMAPSRC_DNS || exit_source == ADDRMAPSRC_NONE) {\n      \/* It shouldn't be possible to get a .exit address from any of these\n       * sources. *\/\n      log_warn(LD_BUG,\"Address '%s.exit', with impossible source for the \"\n               \".exit part. Refusing.\",\n               safe_str_client(socks->address));\n      control_event_client_status(LOG_WARN, \"SOCKS_BAD_HOSTNAME HOSTNAME=%s\",\n                                  escaped(socks->address));\n      connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n      return -1;\n    }\n\n    tor_assert(!automap);\n\n    \/* Now, find the character before the .(name) part.\n     * (The \".exit\" part got stripped off by \"parse_extended_hostname\").\n     *\n     * We're going to put the exit name into conn->chosen_exit_name, and\n     * look up a node correspondingly. *\/\n    char *s = strrchr(socks->address,'.');\n    if (s) {\n      \/* The address was of the form \"(stuff).(name).exit *\/\n      if (s[1] != '\\0') {\n        \/* Looks like a real .exit one. *\/\n        conn->chosen_exit_name = tor_strdup(s+1);\n        node = node_get_by_nickname(conn->chosen_exit_name, 0);\n\n        if (exit_source == ADDRMAPSRC_TRACKEXIT) {\n          \/* We 5 tries before it expires the addressmap *\/\n          conn->chosen_exit_retries = TRACKHOSTEXITS_RETRIES;\n        }\n        *s = 0;\n      } else {\n        \/* Oops, the address was (stuff)..exit.  That's not okay. *\/\n        log_warn(LD_APP,\"Malformed exit address '%s.exit'. Refusing.\",\n                 safe_str_client(socks->address));\n        control_event_client_status(LOG_WARN, \"SOCKS_BAD_HOSTNAME HOSTNAME=%s\",\n                                    escaped(socks->address));\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n        return -1;\n      }\n    } else {\n      \/* It looks like they just asked for \"foo.exit\".  That's a special\n       * form that means (foo's address).foo.exit. *\/\n\n      conn->chosen_exit_name = tor_strdup(socks->address);\n      node = node_get_by_nickname(conn->chosen_exit_name, 0);\n      if (node) {\n        *socks->address = 0;\n        node_get_address_string(node, socks->address, sizeof(socks->address));\n      }\n    }\n\n    \/* Now make sure that the chosen exit exists... *\/\n    if (!node) {\n      log_warn(LD_APP,\n               \"Unrecognized relay in exit address '%s.exit'. Refusing.\",\n               safe_str_client(socks->address));\n      connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n      return -1;\n    }\n    \/* ...and make sure that it isn't excluded. *\/\n    if (routerset_contains_node(excludeset, node)) {\n      log_warn(LD_APP,\n               \"Excluded relay in exit address '%s.exit'. Refusing.\",\n               safe_str_client(socks->address));\n      connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n      return -1;\n    }\n    \/* XXXX-1090 Should we also allow foo.bar.exit if ExitNodes is set and\n       Bar is not listed in it?  I say yes, but our revised manpage branch\n       implies no. *\/\n  }\n\n  \/* Now, we handle everything that isn't a .onion address. *\/\n  if (addresstype != ONION_V3_HOSTNAME && addresstype != ONION_V2_HOSTNAME) {\n    \/* Not a hidden-service request.  It's either a hostname or an IP,\n     * possibly with a .exit that we stripped off.  We're going to check\n     * if we're allowed to connect\/resolve there, and then launch the\n     * appropriate request. *\/\n\n    \/* Check for funny characters in the address. *\/\n    if (address_is_invalid_destination(socks->address, 1)) {\n      control_event_client_status(LOG_WARN, \"SOCKS_BAD_HOSTNAME HOSTNAME=%s\",\n                                  escaped(socks->address));\n      log_warn(LD_APP,\n               \"Destination '%s' seems to be an invalid hostname. Failing.\",\n               safe_str_client(socks->address));\n      connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n      return -1;\n    }\n\n    \/* socks->address is a non-onion hostname or IP address.\n     * If we can't do any non-onion requests, refuse the connection.\n     * If we have a hostname but can't do DNS, refuse the connection.\n     * If we have an IP address, but we can't use that address family,\n     * refuse the connection.\n     *\n     * If we can do DNS requests, and we can use at least one address family,\n     * then we have to resolve the address first. Then we'll know if it\n     * resolves to a usable address family. *\/\n\n    \/* First, check if all non-onion traffic is disabled *\/\n    if (!conn->entry_cfg.dns_request && !conn->entry_cfg.ipv4_traffic\n        && !conn->entry_cfg.ipv6_traffic) {\n        log_warn(LD_APP, \"Refusing to connect to non-hidden-service hostname \"\n                 \"or IP address %s because Port has OnionTrafficOnly set (or \"\n                 \"NoDNSRequest, NoIPv4Traffic, and NoIPv6Traffic).\",\n                 safe_str_client(socks->address));\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n        return -1;\n    }\n\n    \/* Then check if we have a hostname or IP address, and whether DNS or\n     * the IP address family are permitted.  Reject if not. *\/\n    tor_addr_t dummy_addr;\n    int socks_family = tor_addr_parse(&dummy_addr, socks->address);\n    \/* family will be -1 for a non-onion hostname that's not an IP *\/\n    if (socks_family == -1) {\n      if (!conn->entry_cfg.dns_request) {\n        log_warn(LD_APP, \"Refusing to connect to hostname %s \"\n                 \"because Port has NoDNSRequest set.\",\n                 safe_str_client(socks->address));\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n        return -1;\n      }\n    } else if (socks_family == AF_INET) {\n      if (!conn->entry_cfg.ipv4_traffic) {\n        log_warn(LD_APP, \"Refusing to connect to IPv4 address %s because \"\n                 \"Port has NoIPv4Traffic set.\",\n                 safe_str_client(socks->address));\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n        return -1;\n      }\n    } else if (socks_family == AF_INET6) {\n      if (!conn->entry_cfg.ipv6_traffic) {\n        log_warn(LD_APP, \"Refusing to connect to IPv6 address %s because \"\n                 \"Port has NoIPv6Traffic set.\",\n                 safe_str_client(socks->address));\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n        return -1;\n      }\n    } else {\n      tor_assert_nonfatal_unreached_once();\n    }\n\n    \/* See if this is a hostname lookup that we can answer immediately.\n     * (For example, an attempt to look up the IP address for an IP address.)\n     *\/\n    if (socks->command == SOCKS_COMMAND_RESOLVE) {\n      tor_addr_t answer;\n      \/* Reply to resolves immediately if we can. *\/\n      if (tor_addr_parse(&answer, socks->address) >= 0) {\/* is it an IP? *\/\n        \/* remember _what_ is supposed to have been resolved. *\/\n        strlcpy(socks->address, rr.orig_address, sizeof(socks->address));\n        connection_ap_handshake_socks_resolved_addr(conn, &answer, -1,\n                                                    map_expires);\n        connection_mark_unattached_ap(conn,\n                                END_STREAM_REASON_DONE |\n                                END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);\n        return 0;\n      }\n      tor_assert(!automap);\n      rep_hist_note_used_resolve(now); \/* help predict this next time *\/\n    } else if (socks->command == SOCKS_COMMAND_CONNECT) {\n      \/* Now see if this is a connect request that we can reject immediately *\/\n\n      tor_assert(!automap);\n      \/* Don't allow connections to port 0. *\/\n      if (socks->port == 0) {\n        log_notice(LD_APP,\"Application asked to connect to port 0. Refusing.\");\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n        return -1;\n      }\n      \/* You can't make connections to internal addresses, by default.\n       * Exceptions are begindir requests (where the address is meaningless),\n       * or cases where you've hand-configured a particular exit, thereby\n       * making the local address meaningful. *\/\n      if (options->ClientRejectInternalAddresses &&\n          !conn->use_begindir && !conn->chosen_exit_name && !circ) {\n        \/* If we reach this point then we don't want to allow internal\n         * addresses.  Check if we got one. *\/\n        tor_addr_t addr;\n        if (tor_addr_hostname_is_local(socks->address) ||\n            (tor_addr_parse(&addr, socks->address) >= 0 &&\n             tor_addr_is_internal(&addr, 0))) {\n          \/* If this is an explicit private address with no chosen exit node,\n           * then we really don't want to try to connect to it.  That's\n           * probably an error. *\/\n          if (conn->is_transparent_ap) {\n#define WARN_INTRVL_LOOP 300\n            static ratelim_t loop_warn_limit = RATELIM_INIT(WARN_INTRVL_LOOP);\n            char *m;\n            if ((m = rate_limit_log(&loop_warn_limit, approx_time()))) {\n              log_warn(LD_NET,\n                       \"Rejecting request for anonymous connection to private \"\n                       \"address %s on a TransPort or NATDPort.  Possible loop \"\n                       \"in your NAT rules?%s\", safe_str_client(socks->address),\n                       m);\n              tor_free(m);\n            }\n          } else {\n#define WARN_INTRVL_PRIV 300\n            static ratelim_t priv_warn_limit = RATELIM_INIT(WARN_INTRVL_PRIV);\n            char *m;\n            if ((m = rate_limit_log(&priv_warn_limit, approx_time()))) {\n              log_warn(LD_NET,\n                       \"Rejecting SOCKS request for anonymous connection to \"\n                       \"private address %s.%s\",\n                       safe_str_client(socks->address),m);\n              tor_free(m);\n            }\n          }\n          connection_mark_unattached_ap(conn, END_STREAM_REASON_PRIVATE_ADDR);\n          return -1;\n        }\n      } \/* end \"if we should check for internal addresses\" *\/\n\n      \/* Okay.  We're still doing a CONNECT, and it wasn't a private\n       * address.  Here we do special handling for literal IP addresses,\n       * to see if we should reject this preemptively, and to set up\n       * fields in conn->entry_cfg to tell the exit what AF we want. *\/\n      {\n        tor_addr_t addr;\n        \/* XXX Duplicate call to tor_addr_parse. *\/\n        if (tor_addr_parse(&addr, socks->address) >= 0) {\n          \/* If we reach this point, it's an IPv4 or an IPv6 address. *\/\n          sa_family_t family = tor_addr_family(&addr);\n\n          if ((family == AF_INET && ! conn->entry_cfg.ipv4_traffic) ||\n              (family == AF_INET6 && ! conn->entry_cfg.ipv6_traffic)) {\n            \/* You can't do an IPv4 address on a v6-only socks listener,\n             * or vice versa. *\/\n            log_warn(LD_NET, \"Rejecting SOCKS request for an IP address \"\n                     \"family that this listener does not support.\");\n            connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n            return -1;\n          } else if (family == AF_INET6 && socks->socks_version == 4) {\n            \/* You can't make a socks4 request to an IPv6 address. Socks4\n             * doesn't support that. *\/\n            log_warn(LD_NET, \"Rejecting SOCKS4 request for an IPv6 address.\");\n            connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n            return -1;\n          } else if (socks->socks_version == 4 &&\n                     !conn->entry_cfg.ipv4_traffic) {\n            \/* You can't do any kind of Socks4 request when IPv4 is forbidden.\n             *\n             * XXX raise this check outside the enclosing block? *\/\n            log_warn(LD_NET, \"Rejecting SOCKS4 request on a listener with \"\n                     \"no IPv4 traffic supported.\");\n            connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);\n            return -1;\n          } else if (family == AF_INET6) {\n            \/* Tell the exit: we won't accept any ipv4 connection to an IPv6\n             * address. *\/\n            conn->entry_cfg.ipv4_traffic = 0;\n          } else if (family == AF_INET) {\n            \/* Tell the exit: we won't accept any ipv6 connection to an IPv4\n             * address. *\/\n            conn->entry_cfg.ipv6_traffic = 0;\n          }\n\n          \/* Next, yet another check: we know it's a direct IP address. Is it\n           * the IP address of a known relay and its ORPort, or of a directory\n           * authority and its OR or Dir Port? If so, and if a consensus param\n           * says to, then exit relays will refuse this request (see ticket\n           * 2667 for details). Let's just refuse it locally right now, to\n           * save time and network load but also to give the user a more\n           * useful log message. *\/\n          if (!network_reentry_is_allowed() &&\n              nodelist_reentry_contains(&addr, socks->port)) {\n            log_warn(LD_APP, \"Not attempting connection to %s:%d because \"\n                     \"the network would reject it. Are you trying to send \"\n                     \"Tor traffic over Tor? This traffic can be harmful to \"\n                     \"the Tor network. If you really need it, try using \"\n                     \"a bridge as a workaround.\",\n                     safe_str_client(socks->address), socks->port);\n            connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n            return -1;\n          }\n        }\n      }\n\n      \/* we never allow IPv6 answers on socks4. (TODO: Is this smart?) *\/\n      if (socks->socks_version == 4)\n        conn->entry_cfg.ipv6_traffic = 0;\n\n      \/* Still handling CONNECT. Now, check for exit enclaves.  (Which we\n       * don't do on BEGIN_DIR, or when there is a chosen exit.)\n       *\n       * TODO: Should we remove this?  Exit enclaves are nutty and don't\n       * work very well\n       *\/\n      if (!conn->use_begindir && !conn->chosen_exit_name && !circ) {\n        \/* see if we can find a suitable enclave exit *\/\n        const node_t *r =\n          router_find_exact_exit_enclave(socks->address, socks->port);\n        if (r) {\n          log_info(LD_APP,\n                   \"Redirecting address %s to exit at enclave router %s\",\n                   safe_str_client(socks->address), node_describe(r));\n          \/* use the hex digest, not nickname, in case there are two\n             routers with this nickname *\/\n          conn->chosen_exit_name =\n            tor_strdup(hex_str(r->identity, DIGEST_LEN));\n          conn->chosen_exit_optional = 1;\n        }\n      }\n\n      \/* Still handling CONNECT: warn or reject if it's using a dangerous\n       * port. *\/\n      if (!conn->use_begindir && !conn->chosen_exit_name && !circ)\n        if (consider_plaintext_ports(conn, socks->port) < 0)\n          return -1;\n\n      \/* Remember the port so that we will predict that more requests\n         there will happen in the future. *\/\n      if (!conn->use_begindir) {\n        \/* help predict this next time *\/\n        rep_hist_note_used_port(now, socks->port);\n      }\n    } else if (socks->command == SOCKS_COMMAND_RESOLVE_PTR) {\n      rep_hist_note_used_resolve(now); \/* help predict this next time *\/\n      \/* no extra processing needed *\/\n    } else {\n      \/* We should only be doing CONNECT, RESOLVE, or RESOLVE_PTR! *\/\n      tor_fragile_assert();\n    }\n\n    \/* Okay. At this point we've set chosen_exit_name if needed, rewritten the\n     * address, and decided not to reject it for any number of reasons. Now\n     * mark the connection as waiting for a circuit, and try to attach it!\n     *\/\n    base_conn->state = AP_CONN_STATE_CIRCUIT_WAIT;\n\n    \/* If we were given a circuit to attach to, try to attach. Otherwise,\n     * try to find a good one and attach to that. *\/\n    int rv;\n    if (circ) {\n      rv = connection_ap_handshake_attach_chosen_circuit(conn, circ, cpath);\n    } else {\n      \/* We'll try to attach it at the next event loop, or whenever\n       * we call connection_ap_attach_pending() *\/\n      connection_ap_mark_as_pending_circuit(conn);\n      rv = 0;\n    }\n\n    \/* If the above function returned 0 then we're waiting for a circuit.\n     * if it returned 1, we're attached.  Both are okay.  But if it returned\n     * -1, there was an error, so make sure the connection is marked, and\n     * return -1. *\/\n    if (rv < 0) {\n      if (!base_conn->marked_for_close)\n        connection_mark_unattached_ap(conn, END_STREAM_REASON_CANT_ATTACH);\n      return -1;\n    }\n\n    return 0;\n  } else {\n    \/* If we get here, it's a request for a .onion address! *\/\n\n    \/* We don't support v2 onions anymore. Log a warning and bail. *\/\n    if (addresstype == ONION_V2_HOSTNAME) {\n      log_warn(LD_PROTOCOL, \"Tried to connect to a v2 onion address, but this \"\n               \"version of Tor no longer supports them. Please encourage the \"\n               \"site operator to upgrade. For more information see \"\n               \"https:\/\/blog.torproject.org\/v2-deprecation-timeline.\");\n      control_event_client_status(LOG_WARN, \"SOCKS_BAD_HOSTNAME HOSTNAME=%s\",\n                                  escaped(socks->address));\n      \/* Send back the 0xF6 extended code indicating a bad hostname. This is\n       * mostly so Tor Browser can make a proper UX with regards to v2\n       * addresses. *\/\n      conn->socks_request->socks_extended_error_code = SOCKS5_HS_BAD_ADDRESS;\n      connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);\n      return -1;\n    }\n\n    tor_assert(addresstype == ONION_V3_HOSTNAME);\n    tor_assert(!automap);\n    return connection_ap_handle_onion(conn, socks, circ);\n  }\n\n  return 0; \/* unreached but keeps the compiler happy *\/\n}","target":1,"code_token_length":4893,"total_token_length":5129,"max_tokens_setting":6144}
+{"idx":39756,"func":"void ap_lua_load_request_lmodule(lua_State *L, apr_pool_t *p)\n{\n\n    apr_hash_t *dispatch = apr_hash_make(p);\n\n    apr_hash_set(dispatch, \"puts\", APR_HASH_KEY_STRING,\n                 makefun(&req_puts, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"write\", APR_HASH_KEY_STRING,\n                 makefun(&req_write, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"document_root\", APR_HASH_KEY_STRING,\n                 makefun(&req_document_root, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"context_prefix\", APR_HASH_KEY_STRING,\n                 makefun(&req_context_prefix, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"context_document_root\", APR_HASH_KEY_STRING,\n                 makefun(&req_context_document_root, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"parseargs\", APR_HASH_KEY_STRING,\n                 makefun(&req_parseargs, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"parsebody\", APR_HASH_KEY_STRING,\n                 makefun(&req_parsebody, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"debug\", APR_HASH_KEY_STRING,\n                 makefun(&req_debug, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"info\", APR_HASH_KEY_STRING,\n                 makefun(&req_info, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"notice\", APR_HASH_KEY_STRING,\n                 makefun(&req_notice, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"warn\", APR_HASH_KEY_STRING,\n                 makefun(&req_warn, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"err\", APR_HASH_KEY_STRING,\n                 makefun(&req_err, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"crit\", APR_HASH_KEY_STRING,\n                 makefun(&req_crit, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"alert\", APR_HASH_KEY_STRING,\n                 makefun(&req_alert, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"emerg\", APR_HASH_KEY_STRING,\n                 makefun(&req_emerg, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace1\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace1, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace2\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace2, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace3\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace3, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace4\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace4, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace5\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace5, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace6\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace6, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace7\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace7, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"trace8\", APR_HASH_KEY_STRING,\n                 makefun(&req_trace8, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"add_output_filter\", APR_HASH_KEY_STRING,\n                 makefun(&req_add_output_filter, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"construct_url\", APR_HASH_KEY_STRING,\n                 makefun(&req_construct_url, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"escape_html\", APR_HASH_KEY_STRING,\n                 makefun(&req_escape_html, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"ssl_var_lookup\", APR_HASH_KEY_STRING,\n                 makefun(&req_ssl_var_lookup, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"is_https\", APR_HASH_KEY_STRING,\n                 makefun(&req_ssl_is_https_field, APL_REQ_FUNTYPE_BOOLEAN, p));\n    apr_hash_set(dispatch, \"assbackwards\", APR_HASH_KEY_STRING,\n                 makefun(&req_assbackwards_field, APL_REQ_FUNTYPE_BOOLEAN, p));\n    apr_hash_set(dispatch, \"status\", APR_HASH_KEY_STRING,\n                 makefun(&req_status_field, APL_REQ_FUNTYPE_INT, p));\n    apr_hash_set(dispatch, \"protocol\", APR_HASH_KEY_STRING,\n                 makefun(&req_protocol_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"range\", APR_HASH_KEY_STRING,\n                 makefun(&req_range_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"content_type\", APR_HASH_KEY_STRING,\n                 makefun(&req_content_type_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"content_encoding\", APR_HASH_KEY_STRING,\n                 makefun(&req_content_encoding_field, APL_REQ_FUNTYPE_STRING,\n                         p));\n    apr_hash_set(dispatch, \"ap_auth_type\", APR_HASH_KEY_STRING,\n                 makefun(&req_ap_auth_type_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"unparsed_uri\", APR_HASH_KEY_STRING,\n                 makefun(&req_unparsed_uri_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"user\", APR_HASH_KEY_STRING,\n                 makefun(&req_user_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"filename\", APR_HASH_KEY_STRING,\n                 makefun(&req_filename_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"canonical_filename\", APR_HASH_KEY_STRING,\n                 makefun(&req_canonical_filename_field,\n                         APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"path_info\", APR_HASH_KEY_STRING,\n                 makefun(&req_path_info_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"args\", APR_HASH_KEY_STRING,\n                 makefun(&req_args_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"handler\", APR_HASH_KEY_STRING,\n                 makefun(&req_handler_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"hostname\", APR_HASH_KEY_STRING,\n                 makefun(&req_hostname_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"uri\", APR_HASH_KEY_STRING,\n                 makefun(&req_uri_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"the_request\", APR_HASH_KEY_STRING,\n                 makefun(&req_the_request_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"log_id\", APR_HASH_KEY_STRING,\n                 makefun(&req_log_id_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"useragent_ip\", APR_HASH_KEY_STRING,\n                 makefun(&req_useragent_ip_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"method\", APR_HASH_KEY_STRING,\n                 makefun(&req_method_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"proxyreq\", APR_HASH_KEY_STRING,\n                 makefun(&req_proxyreq_field, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"headers_in\", APR_HASH_KEY_STRING,\n                 makefun(&req_headers_in, APL_REQ_FUNTYPE_TABLE, p));\n    apr_hash_set(dispatch, \"headers_out\", APR_HASH_KEY_STRING,\n                 makefun(&req_headers_out, APL_REQ_FUNTYPE_TABLE, p));\n    apr_hash_set(dispatch, \"err_headers_out\", APR_HASH_KEY_STRING,\n                 makefun(&req_err_headers_out, APL_REQ_FUNTYPE_TABLE, p));\n    apr_hash_set(dispatch, \"notes\", APR_HASH_KEY_STRING,\n                 makefun(&req_notes, APL_REQ_FUNTYPE_TABLE, p));\n    apr_hash_set(dispatch, \"subprocess_env\", APR_HASH_KEY_STRING,\n                 makefun(&req_subprocess_env, APL_REQ_FUNTYPE_TABLE, p));\n    apr_hash_set(dispatch, \"flush\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_rflush, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"port\", APR_HASH_KEY_STRING,\n                 makefun(&req_ap_get_server_port, APL_REQ_FUNTYPE_INT, p));\n    apr_hash_set(dispatch, \"banner\", APR_HASH_KEY_STRING,\n                 makefun(&ap_get_server_banner, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"options\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_options, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"allowoverrides\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_allowoverrides, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"started\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_started, APL_REQ_FUNTYPE_INT, p));\n    apr_hash_set(dispatch, \"basic_auth_pw\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_basic_auth_pw, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"limit_req_body\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_limit_req_body, APL_REQ_FUNTYPE_INT, p));\n    apr_hash_set(dispatch, \"server_built\", APR_HASH_KEY_STRING,\n                 makefun(&ap_get_server_built, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"is_initial_req\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_is_initial_req, APL_REQ_FUNTYPE_BOOLEAN, p));\n    apr_hash_set(dispatch, \"remaining\", APR_HASH_KEY_STRING,\n                 makefun(&req_remaining_field, APL_REQ_FUNTYPE_INT, p));\n    apr_hash_set(dispatch, \"some_auth_required\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_some_auth_required, APL_REQ_FUNTYPE_BOOLEAN, p));\n    apr_hash_set(dispatch, \"server_name\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_get_server_name, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"auth_name\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_auth_name, APL_REQ_FUNTYPE_STRING, p));\n    apr_hash_set(dispatch, \"sendfile\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_sendfile, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"dbacquire\", APR_HASH_KEY_STRING,\n                 makefun(&lua_db_acquire, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"stat\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_stat, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"get_direntries\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_getdir, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"regex\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_regex, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"usleep\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_usleep, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"base64_encode\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_b64encode, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"base64_decode\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_b64decode, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"md5\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_md5, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"sha1\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_sha1, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"htpassword\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_htpassword, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"touch\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_touch, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"mkdir\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_mkdir, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"mkrdir\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_mkrdir, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"rmdir\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_rmdir, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"date_parse_rfc\", APR_HASH_KEY_STRING,\n                 makefun(&lua_apr_date_parse_rfc, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"escape\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_escape, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"unescape\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_unescape, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"mpm_query\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_mpm_query, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"expr\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_expr, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"scoreboard_process\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_scoreboard_process, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"scoreboard_worker\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_scoreboard_worker, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"clock\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_clock, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"requestbody\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_requestbody, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"add_input_filter\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_add_input_filter, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"module_info\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_module_info, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"loaded_modules\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_loaded_modules, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"runtime_dir_relative\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_runtime_dir_relative, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"server_info\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_server_info, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"set_document_root\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_set_document_root, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"set_context_info\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_set_context_info, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"os_escape_path\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_os_escape_path, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"escape_logitem\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_escape_logitem, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"strcmp_match\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_strcmp_match, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"set_keepalive\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_set_keepalive, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"make_etag\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_make_etag, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"send_interim_response\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_send_interim_response, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"custom_response\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_custom_response, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"exists_config_define\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_exists_config_define, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"state_query\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_state_query, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"get_server_name_for_url\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_get_server_name_for_url, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"ivm_get\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ivm_get, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"ivm_set\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ivm_set, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"getcookie\", APR_HASH_KEY_STRING,\n                 makefun(&lua_get_cookie, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"setcookie\", APR_HASH_KEY_STRING,\n                 makefun(&lua_set_cookie, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"wsupgrade\", APR_HASH_KEY_STRING,\n                 makefun(&lua_websocket_greet, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"wsread\", APR_HASH_KEY_STRING,\n                 makefun(&lua_websocket_read, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"wspeek\", APR_HASH_KEY_STRING,\n                 makefun(&lua_websocket_peek, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"wswrite\", APR_HASH_KEY_STRING,\n                 makefun(&lua_websocket_write, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"wsclose\", APR_HASH_KEY_STRING,\n                 makefun(&lua_websocket_close, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"wsping\", APR_HASH_KEY_STRING,\n                 makefun(&lua_websocket_ping, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"config\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_get_config, APL_REQ_FUNTYPE_LUACFUN, p));\n    apr_hash_set(dispatch, \"activeconfig\", APR_HASH_KEY_STRING,\n                 makefun(&lua_ap_get_active_config, APL_REQ_FUNTYPE_LUACFUN, p));\n    lua_pushlightuserdata(L, dispatch);\n    lua_setfield(L, LUA_REGISTRYINDEX, \"Apache2.Request.dispatch\");\n\n    luaL_newmetatable(L, \"Apache2.Request\");    \/* [metatable] *\/\n    lua_pushvalue(L, -1);\n\n    lua_setfield(L, -2, \"__index\");\n    luaL_register(L, NULL, request_methods);    \/* [metatable] *\/\n\n    lua_pop(L, 2);\n\n    luaL_newmetatable(L, \"Apache2.Connection\"); \/* [metatable] *\/\n    lua_pushvalue(L, -1);\n\n    lua_setfield(L, -2, \"__index\");\n    luaL_register(L, NULL, connection_methods); \/* [metatable] *\/\n\n    lua_pop(L, 2);\n\n    luaL_newmetatable(L, \"Apache2.Server\");     \/* [metatable] *\/\n    lua_pushvalue(L, -1);\n\n    lua_setfield(L, -2, \"__index\");\n    luaL_register(L, NULL, server_methods);     \/* [metatable] *\/\n\n    lua_pop(L, 2);\n\n}","target":0,"code_token_length":4473,"total_token_length":4709,"max_tokens_setting":6144}
+{"idx":4546,"func":"static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  MagickSizeType\n    number_pixels;\n\n  MemoryInfo\n    *pixel_info;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *p;\n\n  SGIInfo\n    iris_info;\n\n  size_t\n    bytes_per_pixel,\n    quantum;\n\n  ssize_t\n    count,\n    y,\n    z;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read SGI raster header.\n  *\/\n  iris_info.magic=ReadBlobMSBShort(image);\n  do\n  {\n    \/*\n      Verify SGI identifier.\n    *\/\n    if (iris_info.magic != 0x01DA)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    iris_info.storage=(unsigned char) ReadBlobByte(image);\n    switch (iris_info.storage)\n    {\n      case 0x00: image->compression=NoCompression; break;\n      case 0x01: image->compression=RLECompression; break;\n      default:\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    }\n    iris_info.bytes_per_pixel=(unsigned char) ReadBlobByte(image);\n    if ((iris_info.bytes_per_pixel == 0) || (iris_info.bytes_per_pixel > 2))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    iris_info.dimension=ReadBlobMSBShort(image);\n    iris_info.columns=ReadBlobMSBShort(image);\n    iris_info.rows=ReadBlobMSBShort(image);\n    iris_info.depth=ReadBlobMSBShort(image);\n    if ((iris_info.depth == 0) || (iris_info.depth > 4))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    iris_info.minimum_value=ReadBlobMSBLong(image);\n    iris_info.maximum_value=ReadBlobMSBLong(image);\n    iris_info.sans=ReadBlobMSBLong(image);\n    (void) ReadBlob(image,sizeof(iris_info.name),(unsigned char *)\n      iris_info.name);\n    iris_info.name[sizeof(iris_info.name)-1]='\\0';\n    if (*iris_info.name != '\\0')\n      (void) SetImageProperty(image,\"label\",iris_info.name,exception);\n    iris_info.pixel_format=ReadBlobMSBLong(image);\n    if (iris_info.pixel_format != 0)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    count=ReadBlob(image,sizeof(iris_info.filler),iris_info.filler);\n    (void) count;\n    image->columns=iris_info.columns;\n    image->rows=iris_info.rows;\n    image->depth=(size_t) MagickMin(iris_info.depth,MAGICKCORE_QUANTUM_DEPTH);\n    if (iris_info.pixel_format == 0)\n      image->depth=(size_t) MagickMin((size_t) 8*iris_info.bytes_per_pixel,\n        MAGICKCORE_QUANTUM_DEPTH);\n    if (iris_info.depth < 3)\n      {\n        image->storage_class=PseudoClass;\n        image->colors=iris_info.bytes_per_pixel > 1 ? 65535 : 256;\n      }\n    if (EOFBlob(image) != MagickFalse)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((image_info->ping != MagickFalse)  && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      return(DestroyImageList(image));\n    \/*\n      Allocate SGI pixels.\n    *\/\n    bytes_per_pixel=(size_t) iris_info.bytes_per_pixel;\n    number_pixels=(MagickSizeType) iris_info.columns*iris_info.rows;\n    if ((4*bytes_per_pixel*number_pixels) != ((MagickSizeType) (size_t)\n        (4*bytes_per_pixel*number_pixels)))\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixel_info=AcquireVirtualMemory(iris_info.columns,iris_info.rows*4*\n      bytes_per_pixel*sizeof(*pixels));\n    if (pixel_info == (MemoryInfo *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    if ((int) iris_info.storage != 0x01)\n      {\n        unsigned char\n          *scanline;\n\n        \/*\n          Read standard image format.\n        *\/\n        scanline=(unsigned char *) AcquireQuantumMemory(iris_info.columns,\n          bytes_per_pixel*sizeof(*scanline));\n        if (scanline == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        for (z=0; z < (ssize_t) iris_info.depth; z++)\n        {\n          p=pixels+bytes_per_pixel*z;\n          for (y=0; y < (ssize_t) iris_info.rows; y++)\n          {\n            count=ReadBlob(image,bytes_per_pixel*iris_info.columns,scanline);\n            if (EOFBlob(image) != MagickFalse)\n              break;\n            if (bytes_per_pixel == 2)\n              for (x=0; x < (ssize_t) iris_info.columns; x++)\n              {\n                *p=scanline[2*x];\n                *(p+1)=scanline[2*x+1];\n                p+=8;\n              }\n            else\n              for (x=0; x < (ssize_t) iris_info.columns; x++)\n              {\n                *p=scanline[x];\n                p+=4;\n              }\n          }\n        }\n        scanline=(unsigned char *) RelinquishMagickMemory(scanline);\n      }\n    else\n      {\n        MemoryInfo\n          *packet_info;\n\n        size_t\n          *runlength;\n\n        ssize_t\n          offset,\n          *offsets;\n\n        unsigned char\n          *packets;\n\n        unsigned int\n          data_order;\n\n        \/*\n          Read runlength-encoded image format.\n        *\/\n        offsets=(ssize_t *) AcquireQuantumMemory((size_t) iris_info.rows,\n          iris_info.depth*sizeof(*offsets));\n        runlength=(size_t *) AcquireQuantumMemory(iris_info.rows,\n          iris_info.depth*sizeof(*runlength));\n        packet_info=AcquireVirtualMemory((size_t) iris_info.columns+10UL,4UL*\n          sizeof(*packets));\n        if ((offsets == (ssize_t *) NULL) ||\n            (runlength == (size_t *) NULL) ||\n            (packet_info == (MemoryInfo *) NULL))\n          {\n            if (offsets == (ssize_t *) NULL)\n              offsets=(ssize_t *) RelinquishMagickMemory(offsets);\n            if (runlength == (size_t *) NULL)\n              runlength=(size_t *) RelinquishMagickMemory(runlength);\n            if (packet_info == (MemoryInfo *) NULL)\n              packet_info=RelinquishVirtualMemory(packet_info);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n        packets=(unsigned char *) GetVirtualMemoryBlob(packet_info);\n        for (i=0; i < (ssize_t) (iris_info.rows*iris_info.depth); i++)\n          offsets[i]=ReadBlobMSBSignedLong(image);\n        for (i=0; i < (ssize_t) (iris_info.rows*iris_info.depth); i++)\n        {\n          runlength[i]=ReadBlobMSBLong(image);\n          if (runlength[i] > (4*(size_t) iris_info.columns+10))\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n        }\n        \/*\n          Check data order.\n        *\/\n        offset=0;\n        data_order=0;\n        for (y=0; ((y < (ssize_t) iris_info.rows) && (data_order == 0)); y++)\n          for (z=0; ((z < (ssize_t) iris_info.depth) && (data_order == 0)); z++)\n          {\n            if (offsets[y+z*iris_info.rows] < offset)\n              data_order=1;\n            offset=offsets[y+z*iris_info.rows];\n          }\n        offset=(ssize_t) TellBlob(image);\n        if (data_order == 1)\n          {\n            for (z=0; z < (ssize_t) iris_info.depth; z++)\n            {\n              p=pixels;\n              for (y=0; y < (ssize_t) iris_info.rows; y++)\n              {\n                if (offset != offsets[y+z*iris_info.rows])\n                  {\n                    offset=offsets[y+z*iris_info.rows];\n                    offset=(ssize_t) SeekBlob(image,(ssize_t) offset,SEEK_SET);\n                  }\n                count=ReadBlob(image,(size_t) runlength[y+z*iris_info.rows],\n                  packets);\n                if (EOFBlob(image) != MagickFalse)\n                  break;\n                offset+=(ssize_t) runlength[y+z*iris_info.rows];\n                status=SGIDecode(bytes_per_pixel,(ssize_t)\n                  (runlength[y+z*iris_info.rows]\/bytes_per_pixel),packets,\n                  1L*iris_info.columns,p+bytes_per_pixel*z);\n                if (status == MagickFalse)\n                  ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n                p+=(iris_info.columns*4*bytes_per_pixel);\n              }\n            }\n          }\n        else\n          {\n            MagickOffsetType\n              position;\n           \n            position=TellBlob(image);\n            p=pixels;\n            for (y=0; y < (ssize_t) iris_info.rows; y++)\n            {\n              for (z=0; z < (ssize_t) iris_info.depth; z++)\n              {\n                if (offset != offsets[y+z*iris_info.rows])\n                  {\n                    offset=offsets[y+z*iris_info.rows];\n                    offset=(ssize_t) SeekBlob(image,(ssize_t) offset,SEEK_SET);\n                  }\n                count=ReadBlob(image,(size_t) runlength[y+z*iris_info.rows],\n                  packets);\n                if (EOFBlob(image) != MagickFalse)\n                  break;\n                offset+=(ssize_t) runlength[y+z*iris_info.rows];\n                status=SGIDecode(bytes_per_pixel,(ssize_t)\n                  (runlength[y+z*iris_info.rows]\/bytes_per_pixel),packets,\n                  1L*iris_info.columns,p+bytes_per_pixel*z);\n                if (status == MagickFalse)\n                  ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n              }\n              p+=(iris_info.columns*4*bytes_per_pixel);\n            }\n            offset=(ssize_t) SeekBlob(image,position,SEEK_SET);\n          }\n        packet_info=RelinquishVirtualMemory(packet_info);\n        runlength=(size_t *) RelinquishMagickMemory(runlength);\n        offsets=(ssize_t *) RelinquishMagickMemory(offsets);\n      }\n    \/*\n      Initialize image structure.\n    *\/\n    image->alpha_trait=iris_info.depth == 4 ? BlendPixelTrait : \n      UndefinedPixelTrait;\n    image->columns=iris_info.columns;\n    image->rows=iris_info.rows;\n    \/*\n      Convert SGI raster image to pixel packets.\n    *\/\n    if (image->storage_class == DirectClass)\n      {\n        \/*\n          Convert SGI image to DirectClass pixel packets.\n        *\/\n        if (bytes_per_pixel == 2)\n          {\n            for (y=0; y < (ssize_t) image->rows; y++)\n            {\n              p=pixels+(image->rows-y-1)*8*image->columns;\n              q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n              if (q == (Quantum *) NULL)\n                break;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                SetPixelRed(image,ScaleShortToQuantum((unsigned short)\n                  ((*(p+0) << 8) | (*(p+1)))),q);\n                SetPixelGreen(image,ScaleShortToQuantum((unsigned short)\n                  ((*(p+2) << 8) | (*(p+3)))),q);\n                SetPixelBlue(image,ScaleShortToQuantum((unsigned short)\n                  ((*(p+4) << 8) | (*(p+5)))),q);\n                SetPixelAlpha(image,OpaqueAlpha,q);\n                if (image->alpha_trait != UndefinedPixelTrait)\n                  SetPixelAlpha(image,ScaleShortToQuantum((unsigned short)\n                    ((*(p+6) << 8) | (*(p+7)))),q);\n                p+=8;\n                q+=GetPixelChannels(image);\n              }\n              if (SyncAuthenticPixels(image,exception) == MagickFalse)\n                break;\n              if (image->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                    y,image->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n          }\n        else\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            p=pixels+(image->rows-y-1)*4*image->columns;\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              SetPixelRed(image,ScaleCharToQuantum(*p),q);\n              SetPixelGreen(image,ScaleCharToQuantum(*(p+1)),q);\n              SetPixelBlue(image,ScaleCharToQuantum(*(p+2)),q);\n              SetPixelAlpha(image,OpaqueAlpha,q);\n              if (image->alpha_trait != UndefinedPixelTrait)\n                SetPixelAlpha(image,ScaleCharToQuantum(*(p+3)),q);\n              p+=4;\n              q+=GetPixelChannels(image);\n            }\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                  image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n      }\n    else\n      {\n        \/*\n          Create grayscale map.\n        *\/\n        if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        \/*\n          Convert SGI image to PseudoClass pixel packets.\n        *\/\n        if (bytes_per_pixel == 2)\n          {\n            for (y=0; y < (ssize_t) image->rows; y++)\n            {\n              p=pixels+(image->rows-y-1)*8*image->columns;\n              q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n              if (q == (Quantum *) NULL)\n                break;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                quantum=(*p << 8);\n                quantum|=(*(p+1));\n                SetPixelIndex(image,(Quantum) quantum,q);\n                p+=8;\n                q+=GetPixelChannels(image);\n              }\n              if (SyncAuthenticPixels(image,exception) == MagickFalse)\n                break;\n              if (image->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                    y,image->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n          }\n        else\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            p=pixels+(image->rows-y-1)*4*image->columns;\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              SetPixelIndex(image,*p,q);\n              p+=4;\n              q+=GetPixelChannels(image);\n            }\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n        (void) SyncImage(image,exception);\n      }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    iris_info.magic=ReadBlobMSBShort(image);\n    if (iris_info.magic == 0x01DA)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image,exception);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            image=DestroyImageList(image);\n            return((Image *) NULL);\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (iris_info.magic == 0x01DA);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":3949,"total_token_length":4185,"max_tokens_setting":6144}
+{"idx":117667,"func":"tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_t tile){\n\n\tuint16 edge=0;\n\ttsize_t written=0;\n\tunsigned char* buffer=NULL;\n\ttsize_t bufferoffset=0;\n\tunsigned char* samplebuffer=NULL;\n\ttsize_t samplebufferoffset=0;\n\ttsize_t read=0;\n\tuint16 i=0;\n\tttile_t tilecount=0;\n\t\/* tsize_t tilesize=0; *\/\n\tttile_t septilecount=0;\n\ttsize_t septilesize=0;\n#ifdef JPEG_SUPPORT\n\tunsigned char* jpt;\n\tfloat* xfloatp;\n\tuint32 xuint32=0;\n#endif\n\n\t\/* Fail if prior error (in particular, can't trust tiff_datasize) *\/\n\tif (t2p->t2p_error != T2P_ERR_OK)\n\t\treturn(0);\n\n\tedge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);\n\tedge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);\n\n\tif( (t2p->pdf_transcode == T2P_TRANSCODE_RAW) && ((edge == 0)\n#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)\n\t\t|| (t2p->pdf_compression == T2P_COMPRESS_JPEG)\n#endif\n\t)\n\t){\n#ifdef CCITT_SUPPORT\n\t\tif(t2p->pdf_compression == T2P_COMPRESS_G4){\n\t\t\tbuffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(buffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %lu bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image_tile, %s\", \n\t\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tTIFFReadRawTile(input, tile, (tdata_t) buffer, t2p->tiff_datasize);\n\t\t\tif (t2p->tiff_fillorder==FILLORDER_LSB2MSB){\n\t\t\t\t\tTIFFReverseBits(buffer, t2p->tiff_datasize);\n\t\t\t}\n\t\t\tt2pWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize);\n\t\t\t_TIFFfree(buffer);\n\t\t\treturn(t2p->tiff_datasize);\n\t\t}\n#endif\n#ifdef ZIP_SUPPORT\n\t\tif(t2p->pdf_compression == T2P_COMPRESS_ZIP){\n\t\t\tbuffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(buffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %lu bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image_tile, %s\", \n\t\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tTIFFReadRawTile(input, tile, (tdata_t) buffer, t2p->tiff_datasize);\n\t\t\tif (t2p->tiff_fillorder==FILLORDER_LSB2MSB){\n\t\t\t\t\tTIFFReverseBits(buffer, t2p->tiff_datasize);\n\t\t\t}\n\t\t\tt2pWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize);\n\t\t\t_TIFFfree(buffer);\n\t\t\treturn(t2p->tiff_datasize);\n\t\t}\n#endif\n#ifdef OJPEG_SUPPORT\n\t\tif(t2p->tiff_compression == COMPRESSION_OJPEG){\n\t\t\tif(! t2p->pdf_ojpegdata){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for OJPEG image %s with \"\n                                        \"bad tables\", \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tbuffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(buffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %lu bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image, %s\", \n\t\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\t_TIFFmemcpy(buffer, t2p->pdf_ojpegdata, t2p->pdf_ojpegdatalength);\n\t\t\tif(edge!=0){\n\t\t\t\tif(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile)){\n\t\t\t\t\tbuffer[7]=\n\t\t\t\t\t\t(t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength >> 8) & 0xff;\n\t\t\t\t\tbuffer[8]=\n\t\t\t\t\t\t(t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength ) & 0xff;\n\t\t\t\t}\n\t\t\t\tif(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile)){\n\t\t\t\t\tbuffer[9]=\n\t\t\t\t\t\t(t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth >> 8) & 0xff;\n\t\t\t\t\tbuffer[10]=\n\t\t\t\t\t\t(t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth ) & 0xff;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbufferoffset=t2p->pdf_ojpegdatalength;\n\t\t\tbufferoffset+=TIFFReadRawTile(input, \n\t\t\t\t\ttile, \n\t\t\t\t\t(tdata_t) &(((unsigned char*)buffer)[bufferoffset]), \n\t\t\t\t\t-1);\n\t\t\t((unsigned char*)buffer)[bufferoffset++]=0xff;\n\t\t\t((unsigned char*)buffer)[bufferoffset++]=0xd9;\n\t\t\tt2pWriteFile(output, (tdata_t) buffer, bufferoffset);\n\t\t\t_TIFFfree(buffer);\n\t\t\treturn(bufferoffset);\n\t\t}\n#endif\n#ifdef JPEG_SUPPORT\n\t\tif(t2p->tiff_compression == COMPRESSION_JPEG){\n\t\t\tunsigned char table_end[2];\n\t\t\tuint32 count = 0;\n\t\t\tbuffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(buffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate \" TIFF_SIZE_FORMAT \" bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image_tile, %s\", \n                                          (TIFF_SIZE_T) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tif(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) {\n\t\t\t\tif (count > 0) {\n\t\t\t\t\t_TIFFmemcpy(buffer, jpt, count);\n\t\t\t\t\tbufferoffset += count - 2;\n\t\t\t\t\ttable_end[0] = buffer[bufferoffset-2];\n\t\t\t\t\ttable_end[1] = buffer[bufferoffset-1];\n\t\t\t\t}\n\t\t\t\tif (count > 0) {\n\t\t\t\t\txuint32 = bufferoffset;\n\t\t\t\t\tbufferoffset += TIFFReadRawTile(\n\t\t\t\t\t\tinput, \n\t\t\t\t\t\ttile, \n\t\t\t\t\t\t(tdata_t) &(((unsigned char*)buffer)[bufferoffset-2]), \n\t\t\t\t\t\t-1);\n\t\t\t\t\t\tbuffer[xuint32-2]=table_end[0];\n\t\t\t\t\t\tbuffer[xuint32-1]=table_end[1];\n\t\t\t\t} else {\n\t\t\t\t\tbufferoffset += TIFFReadRawTile(\n\t\t\t\t\t\tinput, \n\t\t\t\t\t\ttile, \n\t\t\t\t\t\t(tdata_t) &(((unsigned char*)buffer)[bufferoffset]), \n\t\t\t\t\t\t-1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tt2pWriteFile(output, (tdata_t) buffer, bufferoffset);\n\t\t\t_TIFFfree(buffer);\n\t\t\treturn(bufferoffset);\n\t\t}\n#endif\n\t\t(void)0;\n\t}\n\n\tif(t2p->pdf_sample==T2P_SAMPLE_NOTHING){\n\t\tbuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\tif(buffer==NULL){\n\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\"Can't allocate %lu bytes of memory for \"\n                                \"t2p_readwrite_pdf_image_tile, %s\", \n\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\tTIFFFileName(input));\n\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\treturn(0);\n\t\t}\n\n\t\tread = TIFFReadEncodedTile(\n\t\t\tinput, \n\t\t\ttile, \n\t\t\t(tdata_t) &buffer[bufferoffset], \n\t\t\tt2p->tiff_datasize);\n\t\tif(read==-1){\n\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\"Error on decoding tile %u of %s\", \n\t\t\t\ttile, \n\t\t\t\tTIFFFileName(input));\n\t\t\t_TIFFfree(buffer);\n\t\t\tt2p->t2p_error=T2P_ERR_ERROR;\n\t\t\treturn(0);\n\t\t}\n\n\t} else {\n\n\t\tif(t2p->pdf_sample == T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG){\n\t\t\tseptilesize=TIFFTileSize(input);\n\t\t\tseptilecount=TIFFNumberOfTiles(input);\n\t\t\t\/* tilesize=septilesize*t2p->tiff_samplesperpixel; *\/\n\t\t\ttilecount=septilecount\/t2p->tiff_samplesperpixel;\n\t\t\tbuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(buffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %lu bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image_tile, %s\", \n\t\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tsamplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(samplebuffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %lu bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image_tile, %s\", \n\t\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tsamplebufferoffset=0;\n\t\t\tfor(i=0;itiff_samplesperpixel;i++){\n\t\t\t\tread = \n\t\t\t\t\tTIFFReadEncodedTile(input, \n\t\t\t\t\t\ttile + i*tilecount, \n\t\t\t\t\t\t(tdata_t) &(samplebuffer[samplebufferoffset]), \n\t\t\t\t\t\tseptilesize);\n\t\t\t\tif(read==-1){\n\t\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\t\"Error on decoding tile %u of %s\", \n\t\t\t\t\t\ttile + i*tilecount, \n\t\t\t\t\t\tTIFFFileName(input));\n\t\t\t\t\t\t_TIFFfree(samplebuffer);\n\t\t\t\t\t\t_TIFFfree(buffer);\n\t\t\t\t\tt2p->t2p_error=T2P_ERR_ERROR;\n\t\t\t\t\treturn(0);\n\t\t\t\t}\n\t\t\t\tsamplebufferoffset+=read;\n\t\t\t}\n\t\t\tt2p_sample_planar_separate_to_contig(\n\t\t\t\tt2p,\n\t\t\t\t&(buffer[bufferoffset]),\n\t\t\t\tsamplebuffer, \n\t\t\t\tsamplebufferoffset); \n\t\t\tbufferoffset+=samplebufferoffset;\n\t\t\t_TIFFfree(samplebuffer);\n\t\t}\n\n\t\tif(buffer==NULL){\n\t\t\tbuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);\n\t\t\tif(buffer==NULL){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %lu bytes of memory \"\n                                        \"for t2p_readwrite_pdf_image_tile, %s\", \n\t\t\t\t\t(unsigned long) t2p->tiff_datasize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\tread = TIFFReadEncodedTile(\n\t\t\t\tinput, \n\t\t\t\ttile, \n\t\t\t\t(tdata_t) &buffer[bufferoffset], \n\t\t\t\tt2p->tiff_datasize);\n\t\t\tif(read==-1){\n\t\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\t\"Error on decoding tile %u of %s\", \n\t\t\t\t\ttile, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\t_TIFFfree(buffer);\n\t\t\t\tt2p->t2p_error=T2P_ERR_ERROR;\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t}\n\n\t\tif(t2p->pdf_sample & T2P_SAMPLE_RGBA_TO_RGB){\n\t\t\tt2p->tiff_datasize=t2p_sample_rgba_to_rgb(\n\t\t\t\t(tdata_t)buffer, \n\t\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth\n\t\t\t\t*t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);\n\t\t}\n\n\t\tif(t2p->pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB){\n\t\t\tt2p->tiff_datasize=t2p_sample_rgbaa_to_rgb(\n\t\t\t\t(tdata_t)buffer, \n\t\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth\n\t\t\t\t*t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);\n\t\t}\n\n\t\tif(t2p->pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB){\n\t\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t\t\"No support for YCbCr to RGB in tile for %s\", \n\t\t\t\tTIFFFileName(input));\n\t\t\t_TIFFfree(buffer);\n\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\treturn(0);\n\t\t}\n\n\t\tif(t2p->pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED){\n\t\t\tt2p->tiff_datasize=t2p_sample_lab_signed_to_unsigned(\n\t\t\t\t(tdata_t)buffer, \n\t\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth\n\t\t\t\t*t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);\n\t\t}\n\t}\n\n\tif(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) != 0){\n\t\tt2p_tile_collapse_left(\n\t\t\tbuffer, \n\t\t\tTIFFTileRowSize(input),\n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth,\n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);\n\t}\n\n\n\tt2p_disable(output);\n\tTIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric);\n\tTIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample);\n\tTIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel);\n\tif(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) == 0){\n\t\tTIFFSetField(\n\t\t\toutput, \n\t\t\tTIFFTAG_IMAGEWIDTH, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth);\n\t} else {\n\t\tTIFFSetField(\n\t\t\toutput, \n\t\t\tTIFFTAG_IMAGEWIDTH, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth);\n\t}\n\tif(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile) == 0){\n\t\tTIFFSetField(\n\t\t\toutput, \n\t\t\tTIFFTAG_IMAGELENGTH, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);\n\t\tTIFFSetField(\n\t\t\toutput, \n\t\t\tTIFFTAG_ROWSPERSTRIP, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);\n\t} else {\n\t\tTIFFSetField(\n\t\t\toutput, \n\t\t\tTIFFTAG_IMAGELENGTH, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);\n\t\tTIFFSetField(\n\t\t\toutput, \n\t\t\tTIFFTAG_ROWSPERSTRIP, \n\t\t\tt2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);\n\t}\n\tTIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);\n\tTIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);\n\n\tswitch(t2p->pdf_compression){\n\tcase T2P_COMPRESS_NONE:\n\t\tTIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_NONE);\n\t\tbreak;\n#ifdef CCITT_SUPPORT\n\tcase T2P_COMPRESS_G4:\n\t\tTIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4);\n\t\tbreak;\n#endif\n#ifdef JPEG_SUPPORT\n\tcase T2P_COMPRESS_JPEG:\n\t\tif (t2p->tiff_photometric==PHOTOMETRIC_YCBCR) {\n\t\t\tuint16 hor = 0, ver = 0;\n\t\t\tif (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver)!=0) {\n\t\t\t\tif (hor != 0 && ver != 0) {\n\t\t\t\t\tTIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, &xfloatp)!=0){\n\t\t\t\tTIFFSetField(output, TIFFTAG_REFERENCEBLACKWHITE, xfloatp);\n\t\t\t}\n\t\t}\n\t\tTIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_JPEG);\n\t\tTIFFSetField(output, TIFFTAG_JPEGTABLESMODE, 0); \/* JPEGTABLESMODE_NONE *\/\n\t\tif(t2p->pdf_colorspace & (T2P_CS_RGB | T2P_CS_LAB)){\n\t\t\tTIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR);\n\t\t\tif(t2p->tiff_photometric != PHOTOMETRIC_YCBCR){\n\t\t\t\tTIFFSetField(output, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);\n\t\t\t} else {\n\t\t\t\tTIFFSetField(output, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW);\n\t\t\t}\n\t\t}\n\t\tif(t2p->pdf_colorspace & T2P_CS_GRAY){\n\t\t\t(void)0;\n\t\t}\n\t\tif(t2p->pdf_colorspace & T2P_CS_CMYK){\n\t\t\t(void)0;\n\t\t}\n\t\tif(t2p->pdf_defaultcompressionquality != 0){\n\t\t\tTIFFSetField(output, \n\t\t\t\tTIFFTAG_JPEGQUALITY, \n\t\t\t\tt2p->pdf_defaultcompressionquality);\n\t\t}\n\t\tbreak;\n#endif\n#ifdef ZIP_SUPPORT\n\tcase T2P_COMPRESS_ZIP:\n\t\tTIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);\n\t\tif(t2p->pdf_defaultcompressionquality%100 != 0){\n\t\t\tTIFFSetField(output, \n\t\t\t\tTIFFTAG_PREDICTOR, \n\t\t\t\tt2p->pdf_defaultcompressionquality % 100);\n\t\t}\n\t\tif(t2p->pdf_defaultcompressionquality\/100 != 0){\n\t\t\tTIFFSetField(output, \n\t\t\t\tTIFFTAG_ZIPQUALITY, \n\t\t\t\t(t2p->pdf_defaultcompressionquality \/ 100));\n\t\t}\n\t\tbreak;\n#endif\n\tdefault:\n\t\tbreak;\n\t}\n\n\tt2p_enable(output);\n\tt2p->outputwritten = 0;\n\tbufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t) 0, buffer,\n\t\t\t\t\t     TIFFStripSize(output)); \n\tif (buffer != NULL) {\n\t\t_TIFFfree(buffer);\n\t\tbuffer = NULL;\n\t}\n\tif (bufferoffset == -1) {\n\t\tTIFFError(TIFF2PDF_MODULE, \n\t\t\t  \"Error writing encoded tile to output PDF %s\", \n\t\t\t  TIFFFileName(output));\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\treturn(0);\n\t}\n\t\n\twritten = t2p->outputwritten;\n\t\n\treturn(written);\n}","target":0,"code_token_length":4428,"total_token_length":4664,"max_tokens_setting":6144}
+{"idx":12770,"func":"int ssl3_accept(SSL *s)\n\t{\n\tBUF_MEM *buf;\n\tunsigned long alg_k,Time=(unsigned long)time(NULL);\n\tvoid (*cb)(const SSL *ssl,int type,int val)=NULL;\n\tint ret= -1;\n\tint new_state,state,skip=0;\n\n\tRAND_add(&Time,sizeof(Time),0);\n\tERR_clear_error();\n\tclear_sys_error();\n\n\tif (s->info_callback != NULL)\n\t\tcb=s->info_callback;\n\telse if (s->ctx->info_callback != NULL)\n\t\tcb=s->ctx->info_callback;\n\n\t\/* init things to blank *\/\n\ts->in_handshake++;\n\tif (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);\n\n\tif (s->cert == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_ACCEPT,SSL_R_NO_CERTIFICATE_SET);\n\t\treturn(-1);\n\t\t}\n\n#ifndef OPENSSL_NO_HEARTBEATS\n\t\/* If we're awaiting a HeartbeatResponse, pretend we\n\t * already got and don't await it anymore, because\n\t * Heartbeats don't make sense during handshakes anyway.\n\t *\/\n\tif (s->tlsext_hb_pending)\n\t\t{\n\t\ts->tlsext_hb_pending = 0;\n\t\ts->tlsext_hb_seq++;\n\t\t}\n#endif\n\n\tfor (;;)\n\t\t{\n\t\tstate=s->state;\n\n\t\tswitch (s->state)\n\t\t\t{\n\t\tcase SSL_ST_RENEGOTIATE:\n\t\t\ts->renegotiate=1;\n\t\t\t\/* s->state=SSL_ST_ACCEPT; *\/\n\n\t\tcase SSL_ST_BEFORE:\n\t\tcase SSL_ST_ACCEPT:\n\t\tcase SSL_ST_BEFORE|SSL_ST_ACCEPT:\n\t\tcase SSL_ST_OK|SSL_ST_ACCEPT:\n\n\t\t\ts->server=1;\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);\n\n\t\t\tif ((s->version>>8) != 3)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);\n\t\t\t\treturn -1;\n\t\t\t\t}\n\n\t\t\tif (!ssl_security(s, SSL_SECOP_VERSION, 0,\n\t\t\t\t\t\t\ts->version, NULL))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_ACCEPT, SSL_R_VERSION_TOO_LOW);\n\t\t\t\treturn -1;\n\t\t\t\t}\n\n\t\t\ts->type=SSL_ST_ACCEPT;\n\n\t\t\tif (s->init_buf == NULL)\n\t\t\t\t{\n\t\t\t\tif ((buf=BUF_MEM_new()) == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tif (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))\n\t\t\t\t\t{\n\t\t\t\t\tBUF_MEM_free(buf);\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\ts->init_buf=buf;\n\t\t\t\t}\n\n\t\t\tif (!ssl3_setup_buffers(s))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\ts->init_num=0;\n\t\t\ts->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY;\n\t\t\ts->s3->flags &= ~SSL3_FLAGS_CCS_OK;\n\t\t\t\/* Should have been reset by ssl3_get_finished, too. *\/\n\t\t\ts->s3->change_cipher_spec = 0;\n\n\t\t\tif (s->state != SSL_ST_RENEGOTIATE)\n\t\t\t\t{\n\t\t\t\t\/* Ok, we now need to push on a buffering BIO so that\n\t\t\t\t * the output is sent in a way that TCP likes :-)\n\t\t\t\t *\/\n\t\t\t\tif (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; }\n\t\t\t\t\n\t\t\t\tssl3_init_finished_mac(s);\n\t\t\t\ts->state=SSL3_ST_SR_CLNT_HELLO_A;\n\t\t\t\ts->ctx->stats.sess_accept++;\n\t\t\t\t}\n\t\t\telse if (!s->s3->send_connection_binding &&\n\t\t\t\t!(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))\n\t\t\t\t{\n\t\t\t\t\/* Server attempting to renegotiate with\n\t\t\t\t * client that doesn't support secure\n\t\t\t\t * renegotiation.\n\t\t\t\t *\/\n\t\t\t\tSSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);\n\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE);\n\t\t\t\tret = -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t\/* s->state == SSL_ST_RENEGOTIATE,\n\t\t\t\t * we will just send a HelloRequest *\/\n\t\t\t\ts->ctx->stats.sess_accept_renegotiate++;\n\t\t\t\ts->state=SSL3_ST_SW_HELLO_REQ_A;\n\t\t\t\t}\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_HELLO_REQ_A:\n\t\tcase SSL3_ST_SW_HELLO_REQ_B:\n\n\t\t\ts->shutdown=0;\n\t\t\tret=ssl3_send_hello_request(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->s3->tmp.next_state=SSL3_ST_SW_HELLO_REQ_C;\n\t\t\ts->state=SSL3_ST_SW_FLUSH;\n\t\t\ts->init_num=0;\n\n\t\t\tssl3_init_finished_mac(s);\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_HELLO_REQ_C:\n\t\t\ts->state=SSL_ST_OK;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SR_CLNT_HELLO_A:\n\t\tcase SSL3_ST_SR_CLNT_HELLO_B:\n\t\tcase SSL3_ST_SR_CLNT_HELLO_C:\n\n\t\t\tret=ssl3_get_client_hello(s);\n\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_SRP\n\t\t\ts->state = SSL3_ST_SR_CLNT_HELLO_D;\n\t\tcase SSL3_ST_SR_CLNT_HELLO_D:\n\t\t\t{\n\t\t\tint al;\n\t\t\tif ((ret = ssl_check_srp_ext_ClientHello(s,&al))  < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\/* callback indicates firther work to be done *\/\n\t\t\t\t\ts->rwstate=SSL_X509_LOOKUP;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\tif (ret != SSL_ERROR_NONE)\n\t\t\t\t{\n\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,al);\t\n\t\t\t\t\/* This is not really an error but the only means to\n                                   for a client to detect whether srp is supported. *\/\n \t\t\t\t   if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) \t\n\t\t\t\t\tSSLerr(SSL_F_SSL3_ACCEPT,SSL_R_CLIENTHELLO_TLSEXT);\t\t\t\n\t\t\t\tret = SSL_TLSEXT_ERR_ALERT_FATAL;\t\t\t\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\t\n\t\t\t\t}\n\t\t\t}\n#endif\t\t\n\t\t\t\n\t\t\ts->renegotiate = 2;\n\t\t\ts->state=SSL3_ST_SW_SRVR_HELLO_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_SRVR_HELLO_A:\n\t\tcase SSL3_ST_SW_SRVR_HELLO_B:\n\t\t\tret=ssl3_send_server_hello(s);\n\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\tif (s->hit)\n\t\t\t\t{\n\t\t\t\tif (s->tlsext_ticket_expected)\n\t\t\t\t\ts->state=SSL3_ST_SW_SESSION_TICKET_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_SW_CHANGE_A;\n\t\t\t\t}\n#else\n\t\t\tif (s->hit)\n\t\t\t\t\ts->state=SSL3_ST_SW_CHANGE_A;\n#endif\n\t\t\telse\n\t\t\t\t\ts->state = SSL3_ST_SW_CERT_A;\n\t\t\ts->init_num = 0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_CERT_A:\n\t\tcase SSL3_ST_SW_CERT_B:\n\t\t\t\/* Check if it is anon DH or anon ECDH, *\/\n\t\t\t\/* normal PSK or KRB5 or SRP *\/\n\t\t\tif (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aKRB5|SSL_aSRP))\n\t\t\t\t&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK))\n\t\t\t\t{\n\t\t\t\tret=ssl3_send_server_certificate(s);\n\t\t\t\tif (ret <= 0) goto end;\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\t\tif (s->tlsext_status_expected)\n\t\t\t\t\ts->state=SSL3_ST_SW_CERT_STATUS_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_SW_KEY_EXCH_A;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tskip = 1;\n\t\t\t\ts->state=SSL3_ST_SW_KEY_EXCH_A;\n\t\t\t\t}\n#else\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tskip=1;\n\n\t\t\ts->state=SSL3_ST_SW_KEY_EXCH_A;\n#endif\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_KEY_EXCH_A:\n \t\tcase SSL3_ST_SW_KEY_EXCH_B:\n \t\t\talg_k = s->s3->tmp.new_cipher->algorithm_mkey;\n \n\t\t\t\/* clear this, it may get reset by\n\t\t\t * send_server_key_exchange *\/\n\t\t\tif ((s->options & SSL_OP_EPHEMERAL_RSA)\n#ifndef OPENSSL_NO_KRB5\n\t\t\t\t&& !(alg_k & SSL_kKRB5)\n#endif \/* OPENSSL_NO_KRB5 *\/\n\t\t\t\t)\n\t\t\t\t\/* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key\n\t\t\t\t * even when forbidden by protocol specs\n\t\t\t\t * (handshake may fail as clients are not required to\n\t\t\t\t * be able to handle this) *\/\n\t\t\t\ts->s3->tmp.use_rsa_tmp=1;\n\t\t\telse\n\t\t\t\ts->s3->tmp.use_rsa_tmp=0;\n \n \n \t\t\t\/* only send if a DH key exchange, fortezza or\n\t\t\t * RSA but we have a sign only certificate\n\t\t\t *\n\t\t\t * PSK: may send PSK identity hints\n\t\t\t *\n\t\t\t * For ECC ciphersuites, we send a serverKeyExchange\n\t\t\t * message only if the cipher suite is either\n\t\t\t * ECDH-anon or ECDHE. In other cases, the\n \t\t\t * server certificate contains the server's\n \t\t\t * public key for key exchange.\n \t\t\t *\/\n\t\t\tif (s->s3->tmp.use_rsa_tmp\n \t\t\t\/* PSK: send ServerKeyExchange if PSK identity\n \t\t\t * hint if provided *\/\n #ifndef OPENSSL_NO_PSK\n\t\t\t    || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint)\n#endif\n#ifndef OPENSSL_NO_SRP\n\t\t\t    \/* SRP: send ServerKeyExchange *\/\n\t\t\t    || (alg_k & SSL_kSRP)\n#endif\n\t\t\t    || (alg_k & SSL_kDHE)\n\t\t\t    || (alg_k & SSL_kECDHE)\n\t\t\t    || ((alg_k & SSL_kRSA)\n\t\t\t\t&& (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL\n\t\t\t\t    || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)\n\t\t\t\t\t&& EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)\n\t\t\t\t\t)\n\t\t\t\t    )\n\t\t\t\t)\n\t\t\t    )\n\t\t\t\t{\n\t\t\t\tret=ssl3_send_server_key_exchange(s);\n\t\t\t\tif (ret <= 0) goto end;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tskip=1;\n\n\t\t\ts->state=SSL3_ST_SW_CERT_REQ_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_CERT_REQ_A:\n\t\tcase SSL3_ST_SW_CERT_REQ_B:\n\t\t\tif (\/* don't request cert unless asked for it: *\/\n\t\t\t\t!(s->verify_mode & SSL_VERIFY_PEER) ||\n\t\t\t\t\/* if SSL_VERIFY_CLIENT_ONCE is set,\n\t\t\t\t * don't request cert during re-negotiation: *\/\n\t\t\t\t((s->session->peer != NULL) &&\n\t\t\t\t (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||\n\t\t\t\t\/* never request cert in anonymous ciphersuites\n\t\t\t\t * (see section \"Certificate request\" in SSL 3 drafts\n\t\t\t\t * and in RFC 2246): *\/\n\t\t\t\t((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&\n\t\t\t\t \/* ... except when the application insists on verification\n\t\t\t\t  * (against the specs, but s3_clnt.c accepts this for SSL 3) *\/\n\t\t\t\t !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||\n\t\t\t\t \/* never request cert in Kerberos ciphersuites *\/\n\t\t\t\t(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) ||\n\t\t\t\t\/* don't request certificate for SRP auth *\/\n\t\t\t\t(s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP)\n\t\t\t\t\/* With normal PSK Certificates and\n\t\t\t\t * Certificate Requests are omitted *\/\n\t\t\t\t|| (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK))\n\t\t\t\t{\n\t\t\t\t\/* no cert request *\/\n\t\t\t\tskip=1;\n\t\t\t\ts->s3->tmp.cert_request=0;\n\t\t\t\ts->state=SSL3_ST_SW_SRVR_DONE_A;\n\t\t\t\tif (s->s3->handshake_buffer)\n\t\t\t\t\tif (!ssl3_digest_cached_records(s))\n\t\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\ts->s3->tmp.cert_request=1;\n\t\t\t\tret=ssl3_send_certificate_request(s);\n\t\t\t\tif (ret <= 0) goto end;\n#ifndef NETSCAPE_HANG_BUG\n\t\t\t\ts->state=SSL3_ST_SW_SRVR_DONE_A;\n#else\n\t\t\t\ts->state=SSL3_ST_SW_FLUSH;\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_SR_CERT_A;\n#endif\n\t\t\t\ts->init_num=0;\n\t\t\t\t}\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_SRVR_DONE_A:\n\t\tcase SSL3_ST_SW_SRVR_DONE_B:\n\t\t\tret=ssl3_send_server_done(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->s3->tmp.next_state=SSL3_ST_SR_CERT_A;\n\t\t\ts->state=SSL3_ST_SW_FLUSH;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\t\t\n\t\tcase SSL3_ST_SW_FLUSH:\n\n\t\t\t\/* This code originally checked to see if\n\t\t\t * any data was pending using BIO_CTRL_INFO\n\t\t\t * and then flushed. This caused problems\n\t\t\t * as documented in PR#1939. The proposed\n\t\t\t * fix doesn't completely resolve this issue\n\t\t\t * as buggy implementations of BIO_CTRL_PENDING\n\t\t\t * still exist. So instead we just flush\n\t\t\t * unconditionally.\n\t\t\t *\/\n\n\t\t\ts->rwstate=SSL_WRITING;\n\t\t\tif (BIO_flush(s->wbio) <= 0)\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\ts->rwstate=SSL_NOTHING;\n\n\t\t\ts->state=s->s3->tmp.next_state;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SR_CERT_A:\n\t\tcase SSL3_ST_SR_CERT_B:\n\t\t\tif (s->s3->tmp.cert_request)\n\t\t\t\t{\n\t\t\t\tret=ssl3_get_client_certificate(s);\n\t\t\t\tif (ret <= 0) goto end;\n\t\t\t\t}\n\t\t\ts->init_num=0;\n\t\t\ts->state=SSL3_ST_SR_KEY_EXCH_A;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SR_KEY_EXCH_A:\n\t\tcase SSL3_ST_SR_KEY_EXCH_B:\n\t\t\tret=ssl3_get_client_key_exchange(s);\n\t\t\tif (ret <= 0)\n\t\t\t\tgoto end;\n\t\t\tif (ret == 2)\n\t\t\t\t{\n\t\t\t\t\/* For the ECDH ciphersuites when\n\t\t\t\t * the client sends its ECDH pub key in\n\t\t\t\t * a certificate, the CertificateVerify\n\t\t\t\t * message is not sent.\n\t\t\t\t * Also for GOST ciphersuites when\n\t\t\t\t * the client uses its key from the certificate\n\t\t\t\t * for key exchange.\n\t\t\t\t *\/\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n\t\t\t\ts->state=SSL3_ST_SR_FINISHED_A;\n#else\n\t\t\t\tif (s->s3->next_proto_neg_seen)\n\t\t\t\t\ts->state=SSL3_ST_SR_NEXT_PROTO_A;\n\t\t\t\telse\n\t\t\t\t\ts->state=SSL3_ST_SR_FINISHED_A;\n#endif\n\t\t\t\ts->init_num = 0;\n\t\t\t\t}\n\t\t\telse if (SSL_USE_SIGALGS(s))\n\t\t\t\t{\n\t\t\t\ts->state=SSL3_ST_SR_CERT_VRFY_A;\n\t\t\t\ts->init_num=0;\n\t\t\t\tif (!s->session->peer)\n\t\t\t\t\tbreak;\n\t\t\t\t\/* For sigalgs freeze the handshake buffer\n\t\t\t\t * at this point and digest cached records.\n\t\t\t\t *\/\n\t\t\t\tif (!s->s3->handshake_buffer)\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_ACCEPT,ERR_R_INTERNAL_ERROR);\n\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\t\t\t\ts->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;\n\t\t\t\tif (!ssl3_digest_cached_records(s))\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tint offset=0;\n\t\t\t\tint dgst_num;\n\n\t\t\t\ts->state=SSL3_ST_SR_CERT_VRFY_A;\n\t\t\t\ts->init_num=0;\n\n\t\t\t\t\/* We need to get hashes here so if there is\n\t\t\t\t * a client cert, it can be verified\n\t\t\t\t * FIXME - digest processing for CertificateVerify\n\t\t\t\t * should be generalized. But it is next step\n\t\t\t\t *\/\n\t\t\t\tif (s->s3->handshake_buffer)\n\t\t\t\t\tif (!ssl3_digest_cached_records(s))\n\t\t\t\t\t\treturn -1;\n\t\t\t\tfor (dgst_num=0; dgst_nums3->handshake_dgst[dgst_num]) \n\t\t\t\t\t\t{\n\t\t\t\t\t\tint dgst_size;\n\n\t\t\t\t\t\ts->method->ssl3_enc->cert_verify_mac(s,EVP_MD_CTX_type(s->s3->handshake_dgst[dgst_num]),&(s->s3->tmp.cert_verify_md[offset]));\n\t\t\t\t\t\tdgst_size=EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]);\n\t\t\t\t\t\tif (dgst_size < 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tret = -1;\n\t\t\t\t\t\t\tgoto end;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\toffset+=dgst_size;\n\t\t\t\t\t\t}\t\t\n\t\t\t\t}\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SR_CERT_VRFY_A:\n\t\tcase SSL3_ST_SR_CERT_VRFY_B:\n\t\t\t\/*\n\t\t\t * This *should* be the first time we enable CCS, but be\n\t\t\t * extra careful about surrounding code changes. We need\n\t\t\t * to set this here because we don't know if we're\n\t\t\t * expecting a CertificateVerify or not.\n\t\t\t *\/\n\t\t\tif (!s->s3->change_cipher_spec)\n\t\t\t\ts->s3->flags |= SSL3_FLAGS_CCS_OK;\n\t\t\t\/* we should decide if we expected this one *\/\n\t\t\tret=ssl3_get_cert_verify(s);\n\t\t\tif (ret <= 0) goto end;\n\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n\t\t\ts->state=SSL3_ST_SR_FINISHED_A;\n#else\n\t\t\tif (s->s3->next_proto_neg_seen)\n\t\t\t\ts->state=SSL3_ST_SR_NEXT_PROTO_A;\n\t\t\telse\n\t\t\t\ts->state=SSL3_ST_SR_FINISHED_A;\n#endif\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)\n\t\tcase SSL3_ST_SR_NEXT_PROTO_A:\n\t\tcase SSL3_ST_SR_NEXT_PROTO_B:\n\t\t\t\/*\n\t\t\t * Enable CCS for resumed handshakes with NPN.\n\t\t\t * In a full handshake with NPN, we end up here through\n\t\t\t * SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was\n\t\t\t * already set. Receiving a CCS clears the flag, so make\n\t\t\t * sure not to re-enable it to ban duplicates.\n\t\t\t * s->s3->change_cipher_spec is set when a CCS is\n\t\t\t * processed in s3_pkt.c, and remains set until\n\t\t\t * the client's Finished message is read.\n\t\t\t *\/\n\t\t\tif (!s->s3->change_cipher_spec)\n\t\t\t\ts->s3->flags |= SSL3_FLAGS_CCS_OK;\n\n\t\t\tret=ssl3_get_next_proto(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->init_num = 0;\n\t\t\ts->state=SSL3_ST_SR_FINISHED_A;\n\t\t\tbreak;\n#endif\n\n\t\tcase SSL3_ST_SR_FINISHED_A:\n\t\tcase SSL3_ST_SR_FINISHED_B:\n\t\t\t\/*\n\t\t\t * Enable CCS for resumed handshakes without NPN.\n\t\t\t * In a full handshake, we end up here through\n\t\t\t * SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was\n\t\t\t * already set. Receiving a CCS clears the flag, so make\n\t\t\t * sure not to re-enable it to ban duplicates.\n\t\t\t * s->s3->change_cipher_spec is set when a CCS is\n\t\t\t * processed in s3_pkt.c, and remains set until\n\t\t\t * the client's Finished message is read.\n\t\t\t *\/\n\t\t\tif (!s->s3->change_cipher_spec)\n\t\t\t\ts->s3->flags |= SSL3_FLAGS_CCS_OK;\n\t\t\tret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A,\n\t\t\t\tSSL3_ST_SR_FINISHED_B);\n\t\t\tif (ret <= 0) goto end;\n\t\t\tif (s->hit)\n\t\t\t\ts->state=SSL_ST_OK;\n#ifndef OPENSSL_NO_TLSEXT\n\t\t\telse if (s->tlsext_ticket_expected)\n\t\t\t\ts->state=SSL3_ST_SW_SESSION_TICKET_A;\n#endif\n\t\t\telse\n\t\t\t\ts->state=SSL3_ST_SW_CHANGE_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n#ifndef OPENSSL_NO_TLSEXT\n\t\tcase SSL3_ST_SW_SESSION_TICKET_A:\n\t\tcase SSL3_ST_SW_SESSION_TICKET_B:\n\t\t\tret=ssl3_send_newsession_ticket(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_SW_CHANGE_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_CERT_STATUS_A:\n\t\tcase SSL3_ST_SW_CERT_STATUS_B:\n\t\t\tret=ssl3_send_cert_status(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_SW_KEY_EXCH_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n#endif\n\n\t\tcase SSL3_ST_SW_CHANGE_A:\n\t\tcase SSL3_ST_SW_CHANGE_B:\n\n\t\t\ts->session->cipher=s->s3->tmp.new_cipher;\n\t\t\tif (!s->method->ssl3_enc->setup_key_block(s))\n\t\t\t\t{ ret= -1; goto end; }\n\n\t\t\tret=ssl3_send_change_cipher_spec(s,\n\t\t\t\tSSL3_ST_SW_CHANGE_A,SSL3_ST_SW_CHANGE_B);\n\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_SW_FINISHED_A;\n\t\t\ts->init_num=0;\n\n\t\t\tif (!s->method->ssl3_enc->change_cipher_state(s,\n\t\t\t\tSSL3_CHANGE_CIPHER_SERVER_WRITE))\n\t\t\t\t{\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\n\t\t\tbreak;\n\n\t\tcase SSL3_ST_SW_FINISHED_A:\n\t\tcase SSL3_ST_SW_FINISHED_B:\n\t\t\tret=ssl3_send_finished(s,\n\t\t\t\tSSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B,\n\t\t\t\ts->method->ssl3_enc->server_finished_label,\n\t\t\t\ts->method->ssl3_enc->server_finished_label_len);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL3_ST_SW_FLUSH;\n\t\t\tif (s->hit)\n\t\t\t\t{\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n\t\t\t\ts->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A;\n#else\n\t\t\t\tif (s->s3->next_proto_neg_seen)\n\t\t\t\t\t{\n\t\t\t\t\ts->s3->tmp.next_state=SSL3_ST_SR_NEXT_PROTO_A;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\ts->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A;\n#endif\n\t\t\t\t}\n\t\t\telse\n\t\t\t\ts->s3->tmp.next_state=SSL_ST_OK;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\n\t\tcase SSL_ST_OK:\n\t\t\t\/* clean a few things up *\/\n\t\t\tssl3_cleanup_key_block(s);\n\n\t\t\tBUF_MEM_free(s->init_buf);\n\t\t\ts->init_buf=NULL;\n\n\t\t\t\/* remove buffering on output *\/\n\t\t\tssl_free_wbio_buffer(s);\n\n\t\t\ts->init_num=0;\n\n\t\t\tif (s->renegotiate == 2) \/* skipped if we just sent a HelloRequest *\/\n\t\t\t\t{\n\t\t\t\ts->renegotiate=0;\n\t\t\t\ts->new_session=0;\n\t\t\t\t\n\t\t\t\tssl_update_cache(s,SSL_SESS_CACHE_SERVER);\n\t\t\t\t\n\t\t\t\ts->ctx->stats.sess_accept_good++;\n\t\t\t\t\/* s->server=1; *\/\n\t\t\t\ts->handshake_func=ssl3_accept;\n\n\t\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);\n\t\t\t\t}\n\t\t\t\n\t\t\tret = 1;\n\t\t\tgoto end;\n\t\t\t\/* break; *\/\n\n\t\tdefault:\n\t\t\tSSLerr(SSL_F_SSL3_ACCEPT,SSL_R_UNKNOWN_STATE);\n\t\t\tret= -1;\n\t\t\tgoto end;\n\t\t\t\/* break; *\/\n\t\t\t}\n\t\t\n\t\tif (!s->s3->tmp.reuse_message && !skip)\n\t\t\t{\n\t\t\tif (s->debug)\n\t\t\t\t{\n\t\t\t\tif ((ret=BIO_flush(s->wbio)) <= 0)\n\t\t\t\t\tgoto end;\n\t\t\t\t}\n\n\n\t\t\tif ((cb != NULL) && (s->state != state))\n\t\t\t\t{\n\t\t\t\tnew_state=s->state;\n\t\t\t\ts->state=state;\n\t\t\t\tcb(s,SSL_CB_ACCEPT_LOOP,1);\n\t\t\t\ts->state=new_state;\n\t\t\t\t}\n\t\t\t}\n\t\tskip=0;\n\t\t}\n","target":1,"code_token_length":5504,"total_token_length":5740,"max_tokens_setting":6144}
+{"idx":12189,"func":"WORD32 ihevcd_decode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op)\n{\n    WORD32 ret = IV_SUCCESS;\n codec_t *ps_codec = (codec_t *)(ps_codec_obj->pv_codec_handle);\n ivd_video_decode_ip_t *ps_dec_ip;\n ivd_video_decode_op_t *ps_dec_op;\n\n    WORD32 proc_idx = 0;\n    WORD32 prev_proc_idx = 0;\n\n \/* Initialize error code *\/\n    ps_codec->i4_error_code = 0;\n\n    ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip;\n    ps_dec_op = (ivd_video_decode_op_t *)pv_api_op;\n\n {\n        UWORD32 u4_size = ps_dec_op->u4_size;\n        memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t));\n        ps_dec_op->u4_size = u4_size; \/\/Restore size field\n }\n if(ps_codec->i4_init_done != 1)\n {\n        ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR;\n        ps_dec_op->u4_error_code |= IHEVCD_INIT_NOT_DONE;\n return IV_FAIL;\n }\n\n if(ps_codec->u4_pic_cnt >= NUM_FRAMES_LIMIT)\n {\n        ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR;\n        ps_dec_op->u4_error_code |= IHEVCD_NUM_FRAMES_LIMIT_REACHED;\n return IV_FAIL;\n }\n\n \/* If reset flag is set, flush the existing buffers *\/\n if(ps_codec->i4_reset_flag)\n {\n        ps_codec->i4_flush_mode = 1;\n }\n\n \/*Data memory barries instruction,so that bitstream write by the application is complete*\/\n \/* In case the decoder is not in flush mode check for input buffer validity *\/\n if(0 == ps_codec->i4_flush_mode)\n {\n if(ps_dec_ip->pv_stream_buffer == NULL)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL;\n return IV_FAIL;\n }\n if(ps_dec_ip->u4_num_Bytes <= MIN_START_CODE_LEN)\n {\n if((WORD32)ps_dec_ip->u4_num_Bytes > 0)\n                ps_dec_op->u4_num_bytes_consumed = ps_dec_ip->u4_num_Bytes;\n else\n                ps_dec_op->u4_num_bytes_consumed = 0;\n\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV;\n return IV_FAIL;\n\n }\n }\n\n#ifdef APPLY_CONCEALMENT\n {\n        WORD32 num_mbs;\n\n        num_mbs = (ps_codec->i4_wd * ps_codec->i4_ht + 255) >> 8;\n \/* Reset MB Count at the beginning of every process call *\/\n        ps_codec->mb_count = 0;\n        memset(ps_codec->mb_map, 0, ((num_mbs + 7) >> 3));\n }\n#endif\n\n if(0 == ps_codec->i4_share_disp_buf && ps_codec->i4_header_mode == 0)\n {\n        UWORD32 i;\n if(ps_dec_ip->s_out_buffer.u4_num_bufs == 0)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS;\n return IV_FAIL;\n }\n\n for(i = 0; i < ps_dec_ip->s_out_buffer.u4_num_bufs; i++)\n {\n if(ps_dec_ip->s_out_buffer.pu1_bufs[i] == NULL)\n {\n                ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n                ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL;\n return IV_FAIL;\n }\n\n if(ps_dec_ip->s_out_buffer.u4_min_out_buf_size[i] == 0)\n {\n                ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n                ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUF_SIZE;\n return IV_FAIL;\n }\n }\n }\n\n    ps_codec->ps_out_buffer = &ps_dec_ip->s_out_buffer;\n    ps_codec->u4_ts = ps_dec_ip->u4_ts;\n if(ps_codec->i4_flush_mode)\n {\n\n        ps_dec_op->u4_pic_wd = ps_codec->i4_disp_wd;\n        ps_dec_op->u4_pic_ht = ps_codec->i4_disp_ht;\n\n        ps_dec_op->u4_new_seq = 0;\n\n        ps_codec->ps_disp_buf = (pic_buf_t *)ihevc_disp_mgr_get(\n (disp_mgr_t *)ps_codec->pv_disp_buf_mgr, &ps_codec->i4_disp_buf_id);\n \/* In case of non-shared mode, then convert\/copy the frame to output buffer *\/\n \/* Only if the codec is in non-shared mode or in shared mode but needs 420P output *\/\n if((ps_codec->ps_disp_buf)\n && ((0 == ps_codec->i4_share_disp_buf)\n || (IV_YUV_420P\n == ps_codec->e_chroma_fmt)))\n {\n\n process_ctxt_t *ps_proc = &ps_codec->as_process[prev_proc_idx];\n if(0 == ps_proc->i4_init_done)\n {\n                ihevcd_init_proc_ctxt(ps_proc, 0);\n }\n\n \/* Set remaining number of rows to be processed *\/\n            ret = ihevcd_fmt_conv(ps_codec, &ps_codec->as_process[prev_proc_idx],\n                                  ps_dec_ip->s_out_buffer.pu1_bufs[0],\n                                  ps_dec_ip->s_out_buffer.pu1_bufs[1],\n                                  ps_dec_ip->s_out_buffer.pu1_bufs[2], 0,\n                                  ps_codec->i4_disp_ht);\n\n            ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr,\n                                  ps_codec->i4_disp_buf_id, BUF_MGR_DISP);\n }\n\n        ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op);\n\n if(1 == ps_dec_op->u4_output_present)\n {\n            WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD;\n            WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT;\n\n if(ypos < 0)\n                ypos = 0;\n\n if(xpos < 0)\n                xpos = 0;\n\n            INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0],\n                        ps_dec_ip->s_out_buffer.pu1_bufs[1],\n                        ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd,\n                        xpos,\n                        ypos,\n                        ps_codec->e_chroma_fmt,\n                        ps_codec->i4_disp_wd,\n                        ps_codec->i4_disp_ht);\n }\n\n\n if(NULL == ps_codec->ps_disp_buf)\n {\n \/* If in flush mode and there are no more buffers to flush,\n             * check for the reset flag and reset the decoder *\/\n if(ps_codec->i4_reset_flag)\n {\n                ihevcd_init(ps_codec);\n }\n return (IV_FAIL);\n }\n\n return (IV_SUCCESS);\n\n }\n \/* In case of shared mode, check if there is a free buffer for reconstruction *\/\n if((0 == ps_codec->i4_header_mode) && (1 == ps_codec->i4_share_disp_buf))\n {\n        WORD32 buf_status;\n        buf_status = 1;\n if(ps_codec->pv_pic_buf_mgr)\n            buf_status = ihevc_buf_mgr_check_free((buf_mgr_t *)ps_codec->pv_pic_buf_mgr);\n\n \/* If there is no free buffer, then return with an error code *\/\n if(0 == buf_status)\n {\n            ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;\n            ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n return IV_FAIL;\n }\n }\n    ps_codec->i4_bytes_remaining = ps_dec_ip->u4_num_Bytes;\n    ps_codec->pu1_inp_bitsbuf = (UWORD8 *)ps_dec_ip->pv_stream_buffer;\n    ps_codec->s_parse.i4_end_of_frame = 0;\n\n    ps_codec->i4_pic_present = 0;\n    ps_codec->i4_slice_error = 0;\n    ps_codec->ps_disp_buf = NULL;\n\n if(ps_codec->i4_num_cores > 1)\n {\n        ithread_set_affinity(0);\n }\n while(MIN_START_CODE_LEN < ps_codec->i4_bytes_remaining)\n {\n        WORD32 nal_len;\n        WORD32 nal_ofst;\n        WORD32 bits_len;\n\n if(ps_codec->i4_slice_error)\n {\n slice_header_t *ps_slice_hdr_next = ps_codec->s_parse.ps_slice_hdr_base + (ps_codec->s_parse.i4_cur_slice_idx & (MAX_SLICE_HDR_CNT - 1));\n            WORD32 next_slice_addr = ps_slice_hdr_next->i2_ctb_x +\n                            ps_slice_hdr_next->i2_ctb_y * ps_codec->s_parse.ps_sps->i2_pic_wd_in_ctb;\n if(ps_codec->s_parse.i4_next_ctb_indx == next_slice_addr)\n                ps_codec->i4_slice_error = 0;\n }\n\n if(ps_codec->pu1_bitsbuf_dynamic)\n {\n            ps_codec->pu1_bitsbuf = ps_codec->pu1_bitsbuf_dynamic;\n            ps_codec->u4_bitsbuf_size = ps_codec->u4_bitsbuf_size_dynamic;\n }\n else\n {\n            ps_codec->pu1_bitsbuf = ps_codec->pu1_bitsbuf_static;\n            ps_codec->u4_bitsbuf_size = ps_codec->u4_bitsbuf_size_static;\n }\n\n        nal_ofst = ihevcd_nal_search_start_code(ps_codec->pu1_inp_bitsbuf,\n                                                ps_codec->i4_bytes_remaining);\n\n        ps_codec->i4_nal_ofst = nal_ofst;\n {\n            WORD32 bytes_remaining = ps_codec->i4_bytes_remaining - nal_ofst;\n\n            bytes_remaining = MIN((UWORD32)bytes_remaining, ps_codec->u4_bitsbuf_size);\n            ihevcd_nal_remv_emuln_bytes(ps_codec->pu1_inp_bitsbuf + nal_ofst,\n                                        ps_codec->pu1_bitsbuf,\n                                        bytes_remaining,\n &nal_len, &bits_len);\n\n \/* Decoder may read upto 8 extra bytes at the end of frame *\/\n \/* These are not used, but still set them to zero to avoid uninitialized reads *\/\n if(bits_len < (WORD32)(ps_codec->u4_bitsbuf_size - 8))\n {\n                memset(ps_codec->pu1_bitsbuf + bits_len, 0, 2 * sizeof(UWORD32));\n }\n }\n \/* This may be used to update the offsets for tiles and entropy sync row offsets *\/\n        ps_codec->i4_num_emln_bytes = nal_len - bits_len;\n        ps_codec->i4_nal_len = nal_len;\n\n        ihevcd_bits_init(&ps_codec->s_parse.s_bitstrm, ps_codec->pu1_bitsbuf,\n                         bits_len);\n\n        ret = ihevcd_nal_unit(ps_codec);\n\n \/* If the frame is incomplete and\n         * the bytes remaining is zero or a header is received,\n         * complete the frame treating it to be in error *\/\n if(ps_codec->i4_pic_present &&\n (ps_codec->s_parse.i4_next_ctb_indx != ps_codec->s_parse.ps_sps->i4_pic_size_in_ctb))\n {\n if((ps_codec->i4_bytes_remaining - (nal_len + nal_ofst) <= MIN_START_CODE_LEN) ||\n (ps_codec->i4_header_in_slice_mode))\n {\n slice_header_t *ps_slice_hdr_next;\n\n                ps_codec->s_parse.i4_cur_slice_idx--;\n if(ps_codec->s_parse.i4_cur_slice_idx < 0)\n                    ps_codec->s_parse.i4_cur_slice_idx = 0;\n\n                ps_slice_hdr_next = ps_codec->s_parse.ps_slice_hdr_base + ((ps_codec->s_parse.i4_cur_slice_idx + 1) & (MAX_SLICE_HDR_CNT - 1));\n                ps_slice_hdr_next->i2_ctb_x = 0;\n                ps_slice_hdr_next->i2_ctb_y = ps_codec->s_parse.ps_sps->i2_pic_ht_in_ctb;\n                ps_codec->i4_slice_error = 1;\n continue;\n }\n }\n\n \n         if(IHEVCD_IGNORE_SLICE == ret)\n         {\n             ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len);\n             ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len);\n \n continue;\n }\n\n if((IVD_RES_CHANGED == ret) ||\n (IHEVCD_UNSUPPORTED_DIMENSIONS == ret))\n {\n break;\n }\n\n \/* Update bytes remaining and bytes consumed and input bitstream pointer *\/\n \/* Do not consume the NAL in the following cases *\/\n \/* Slice header reached during header decode mode *\/\n \/* TODO: Next picture's slice reached *\/\n if(ret != IHEVCD_SLICE_IN_HEADER_MODE)\n {\n if((0 == ps_codec->i4_slice_error) ||\n (ps_codec->i4_bytes_remaining - (nal_len + nal_ofst) <= MIN_START_CODE_LEN))\n {\n                ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len);\n                ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len);\n }\n if(ret != IHEVCD_SUCCESS)\n break;\n\n if(ps_codec->s_parse.i4_end_of_frame)\n break;\n }\n else\n {\n            ret = IHEVCD_SUCCESS;\n break;\n }\n\n \/* Allocate dynamic bitstream buffer once SPS is decoded *\/\n if((ps_codec->u4_allocate_dynamic_done == 0) && ps_codec->i4_sps_done)\n {\n            WORD32 ret;\n            ret = ihevcd_allocate_dynamic_bufs(ps_codec);\n if(ret != IV_SUCCESS)\n {\n \/* Free any dynamic buffers that are allocated *\/\n                ihevcd_free_dynamic_bufs(ps_codec);\n                ps_codec->i4_error_code = IVD_MEM_ALLOC_FAILED;\n                ps_dec_op->u4_error_code |= 1 << IVD_FATALERROR;\n                ps_dec_op->u4_error_code |= IVD_MEM_ALLOC_FAILED;\n\n return IV_FAIL;\n }\n }\n\n        BREAK_AFTER_SLICE_NAL();\n }\n\n if((ps_codec->u4_pic_cnt == 0) && (ret != IHEVCD_SUCCESS))\n {\n        ps_codec->i4_error_code = ret;\n\n        ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op);\n return IV_FAIL;\n }\n\n if(1 == ps_codec->i4_pic_present)\n {\n        WORD32 i;\n sps_t *ps_sps = ps_codec->s_parse.ps_sps;\n        ps_codec->i4_first_pic_done = 1;\n\n \/*TODO temporary fix: end_of_frame is checked before adding format conversion to job queue         *\/\n if(ps_codec->i4_num_cores > 1 && ps_codec->s_parse.i4_end_of_frame)\n {\n\n \/* Add job queue for format conversion \/ frame copy for each ctb row *\/\n \/* Only if the codec is in non-shared mode or in shared mode but needs 420P output *\/\n process_ctxt_t *ps_proc;\n\n \/* i4_num_cores - 1 contexts are currently being used by other threads *\/\n            ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1];\n\n if((ps_codec->ps_disp_buf) &&\n ((0 == ps_codec->i4_share_disp_buf) || (IV_YUV_420P == ps_codec->e_chroma_fmt)))\n {\n \/* If format conversion jobs were not issued in pic_init() add them here *\/\n if((0 == ps_codec->u4_enable_fmt_conv_ahead) ||\n (ps_codec->i4_disp_buf_id == ps_proc->i4_cur_pic_buf_id))\n for(i = 0; i < ps_sps->i2_pic_ht_in_ctb; i++)\n {\n proc_job_t s_job;\n                        IHEVCD_ERROR_T ret;\n                        s_job.i4_cmd = CMD_FMTCONV;\n                        s_job.i2_ctb_cnt = 0;\n                        s_job.i2_ctb_x = 0;\n                        s_job.i2_ctb_y = i;\n                        s_job.i2_slice_idx = 0;\n                        s_job.i4_tu_coeff_data_ofst = 0;\n                        ret = ihevcd_jobq_queue((jobq_t *)ps_codec->s_parse.pv_proc_jobq,\n &s_job, sizeof(proc_job_t), 1);\n if(ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS)\n return (WORD32)ret;\n }\n }\n \/* Reached end of frame : Signal terminate *\/\n \/* The terminate flag is checked only after all the jobs are dequeued *\/\n            ret = ihevcd_jobq_terminate((jobq_t *)ps_codec->s_parse.pv_proc_jobq);\n\n while(1)\n {\n                IHEVCD_ERROR_T ret;\n proc_job_t s_job;\n process_ctxt_t *ps_proc;\n\n \/* i4_num_cores - 1 contexts are currently being used by other threads *\/\n                ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1];\n\n                ret = ihevcd_jobq_dequeue((jobq_t *)ps_proc->pv_proc_jobq, &s_job,\n sizeof(proc_job_t), 1);\n if((IHEVCD_ERROR_T)IHEVCD_SUCCESS != ret)\n break;\n\n                ps_proc->i4_ctb_cnt = s_job.i2_ctb_cnt;\n                ps_proc->i4_ctb_x = s_job.i2_ctb_x;\n                ps_proc->i4_ctb_y = s_job.i2_ctb_y;\n                ps_proc->i4_cur_slice_idx = s_job.i2_slice_idx;\n\n if(CMD_PROCESS == s_job.i4_cmd)\n {\n                    ihevcd_init_proc_ctxt(ps_proc, s_job.i4_tu_coeff_data_ofst);\n\n                    ihevcd_process(ps_proc);\n }\n else if(CMD_FMTCONV == s_job.i4_cmd)\n {\n sps_t *ps_sps = ps_codec->s_parse.ps_sps;\n                    WORD32 num_rows = 1 << ps_sps->i1_log2_ctb_size;\n if(0 == ps_proc->i4_init_done)\n {\n                        ihevcd_init_proc_ctxt(ps_proc, 0);\n }\n\n                    num_rows = MIN(num_rows, (ps_codec->i4_disp_ht - (s_job.i2_ctb_y << ps_sps->i1_log2_ctb_size)));\n if(num_rows < 0)\n                        num_rows = 0;\n\n                    ihevcd_fmt_conv(ps_codec, ps_proc,\n                                    ps_dec_ip->s_out_buffer.pu1_bufs[0],\n                                    ps_dec_ip->s_out_buffer.pu1_bufs[1],\n                                    ps_dec_ip->s_out_buffer.pu1_bufs[2],\n                                    s_job.i2_ctb_y << ps_sps->i1_log2_ctb_size,\n                                    num_rows);\n }\n }\n }\n \/* In case of non-shared mode and while running in single core mode, then convert\/copy the frame to output buffer *\/\n \/* Only if the codec is in non-shared mode or in shared mode but needs 420P output *\/\n else if((ps_codec->ps_disp_buf) && ((0 == ps_codec->i4_share_disp_buf) ||\n (IV_YUV_420P == ps_codec->e_chroma_fmt)) &&\n (ps_codec->s_parse.i4_end_of_frame))\n {\n process_ctxt_t *ps_proc = &ps_codec->as_process[proc_idx];\n \/* Set remaining number of rows to be processed *\/\n            ps_codec->s_fmt_conv.i4_num_rows = ps_codec->i4_disp_ht\n - ps_codec->s_fmt_conv.i4_cur_row;\n if(0 == ps_proc->i4_init_done)\n {\n                ihevcd_init_proc_ctxt(ps_proc, 0);\n }\n\n if(ps_codec->s_fmt_conv.i4_num_rows < 0)\n                ps_codec->s_fmt_conv.i4_num_rows = 0;\n\n            ret = ihevcd_fmt_conv(ps_codec, ps_proc,\n                                  ps_dec_ip->s_out_buffer.pu1_bufs[0],\n                                  ps_dec_ip->s_out_buffer.pu1_bufs[1],\n                                  ps_dec_ip->s_out_buffer.pu1_bufs[2],\n                                  ps_codec->s_fmt_conv.i4_cur_row,\n                                  ps_codec->s_fmt_conv.i4_num_rows);\n            ps_codec->s_fmt_conv.i4_cur_row += ps_codec->s_fmt_conv.i4_num_rows;\n\n }\n\n\n        DEBUG_DUMP_MV_MAP(ps_codec);\n\n \/* Mark MV Buf as needed for reference *\/\n        ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_mv_buf_mgr,\n                                 ps_codec->as_process[proc_idx].i4_cur_mv_bank_buf_id,\n                                 BUF_MGR_REF);\n\n \/* Mark pic buf as needed for reference *\/\n        ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr,\n                                 ps_codec->as_process[proc_idx].i4_cur_pic_buf_id,\n                                 BUF_MGR_REF);\n\n \/* Mark pic buf as needed for display *\/\n        ihevc_buf_mgr_set_status((buf_mgr_t *)ps_codec->pv_pic_buf_mgr,\n                                 ps_codec->as_process[proc_idx].i4_cur_pic_buf_id,\n                                 BUF_MGR_DISP);\n\n \/* Insert the current picture as short term reference *\/\n        ihevc_dpb_mgr_insert_ref((dpb_mgr_t *)ps_codec->pv_dpb_mgr,\n                                 ps_codec->as_process[proc_idx].ps_cur_pic,\n                                 ps_codec->as_process[proc_idx].i4_cur_pic_buf_id);\n\n \/* If a frame was displayed (in non-shared mode), then release it from display manager *\/\n if((0 == ps_codec->i4_share_disp_buf) && (ps_codec->ps_disp_buf))\n            ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_pic_buf_mgr,\n                                  ps_codec->i4_disp_buf_id, BUF_MGR_DISP);\n\n \/* Wait for threads *\/\n for(i = 0; i < (ps_codec->i4_num_cores - 1); i++)\n {\n if(ps_codec->ai4_process_thread_created[i])\n {\n                ithread_join(ps_codec->apv_process_thread_handle[i], NULL);\n                ps_codec->ai4_process_thread_created[i] = 0;\n }\n }\n\n        DEBUG_VALIDATE_PADDED_REGION(&ps_codec->as_process[proc_idx]);\n if(ps_codec->u4_pic_cnt > 0)\n {\n            DEBUG_DUMP_PIC_PU(ps_codec);\n }\n        DEBUG_DUMP_PIC_BUFFERS(ps_codec);\n\n \/* Increment the number of pictures decoded *\/\n        ps_codec->u4_pic_cnt++;\n }\n    ihevcd_fill_outargs(ps_codec, ps_dec_ip, ps_dec_op);\n\n if(1 == ps_dec_op->u4_output_present)\n {\n        WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD;\n        WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT;\n\n if(ypos < 0)\n            ypos = 0;\n\n if(xpos < 0)\n            xpos = 0;\n\n        INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0],\n                    ps_dec_ip->s_out_buffer.pu1_bufs[1],\n                    ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd,\n                    xpos,\n                    ypos,\n                    ps_codec->e_chroma_fmt,\n                    ps_codec->i4_disp_wd,\n                    ps_codec->i4_disp_ht);\n }\n\n\n return ret;\n}\n","target":1,"code_token_length":5047,"total_token_length":5283,"max_tokens_setting":6144}
+{"idx":509735,"func":"static uint get_table_structure(char *table, char *db, char *table_type,\n                                char *ignore_flag)\n{\n  my_bool    init=0, delayed, write_data, complete_insert;\n  my_ulonglong num_fields;\n  char       *result_table, *opt_quoted_table;\n  const char *insert_option;\n  char\t     name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];\n  char       table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];\n  const char *show_fields_stmt= \"SELECT `COLUMN_NAME` AS `Field`, \"\n                                \"`COLUMN_TYPE` AS `Type`, \"\n                                \"`IS_NULLABLE` AS `Null`, \"\n                                \"`COLUMN_KEY` AS `Key`, \"\n                                \"`COLUMN_DEFAULT` AS `Default`, \"\n                                \"`EXTRA` AS `Extra`, \"\n                                \"`COLUMN_COMMENT` AS `Comment` \"\n                                \"FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE \"\n                                \"TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'\";\n  FILE       *sql_file= md_result_file;\n  int        len;\n  my_bool    is_log_table;\n  MYSQL_RES  *result;\n  MYSQL_ROW  row;\n  DBUG_ENTER(\"get_table_structure\");\n  DBUG_PRINT(\"enter\", (\"db: %s  table: %s\", db, table));\n\n  *ignore_flag= check_if_ignore_table(table, table_type);\n\n  delayed= opt_delayed;\n  if (delayed && (*ignore_flag & IGNORE_INSERT_DELAYED))\n  {\n    delayed= 0;\n    verbose_msg(\"-- Warning: Unable to use delayed inserts for table '%s' \"\n                \"because it's of type %s\\n\", table, table_type);\n  }\n\n  complete_insert= 0;\n  if ((write_data= !(*ignore_flag & IGNORE_DATA)))\n  {\n    complete_insert= opt_complete_insert;\n    if (!insert_pat_inited)\n    {\n      insert_pat_inited= 1;\n      init_dynamic_string_checked(&insert_pat, \"\", 1024, 1024);\n    }\n    else\n      dynstr_set_checked(&insert_pat, \"\");\n  }\n\n  insert_option= ((delayed && opt_ignore) ? \" DELAYED IGNORE \" :\n                  delayed ? \" DELAYED \" : opt_ignore ? \" IGNORE \" : \"\");\n\n  verbose_msg(\"-- Retrieving table structure for table %s...\\n\", table);\n\n  len= my_snprintf(query_buff, sizeof(query_buff),\n                   \"SET SQL_QUOTE_SHOW_CREATE=%d\",\n                   (opt_quoted || opt_keywords));\n  if (!create_options)\n    strmov(query_buff+len,\n           \"\/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') *\/\");\n\n  result_table=     quote_name(table, table_buff, 1);\n  opt_quoted_table= quote_name(table, table_buff2, 0);\n\n  if (opt_order_by_primary)\n    order_by= primary_key_fields(result_table);\n\n  if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff))\n  {\n    \/* using SHOW CREATE statement *\/\n    if (!opt_no_create_info)\n    {\n      \/* Make an sql-file, if path was given iow. option -T was given *\/\n      char buff[20+FN_REFLEN];\n      MYSQL_FIELD *field;\n\n      my_snprintf(buff, sizeof(buff), \"show create table %s\", result_table);\n\n      if (switch_character_set_results(mysql, \"binary\") ||\n          mysql_query_with_error_report(mysql, &result, buff) ||\n          switch_character_set_results(mysql, default_charset))\n        DBUG_RETURN(0);\n\n      if (path)\n      {\n        if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))\n          DBUG_RETURN(0);\n\n        write_header(sql_file, db);\n      }\n\n      if (strcmp (table_type, \"VIEW\") == 0)         \/* view *\/\n        print_comment(sql_file, 0,\n                      \"\\n--\\n-- Temporary table structure for view %s\\n--\\n\\n\",\n                      fix_for_comment(result_table));\n      else\n        print_comment(sql_file, 0,\n                      \"\\n--\\n-- Table structure for table %s\\n--\\n\\n\",\n                      fix_for_comment(result_table));\n\n      if (opt_drop)\n      {\n      \/*\n        Even if the \"table\" is a view, we do a DROP TABLE here.  The\n        view-specific code below fills in the DROP VIEW.\n        We will skip the DROP TABLE for general_log and slow_log, since\n        those stmts will fail, in case we apply dump by enabling logging.\n       *\/\n        if (!general_log_or_slow_log_tables(db, table))\n          fprintf(sql_file, \"DROP TABLE IF EXISTS %s;\\n\",\n                  opt_quoted_table);\n        check_io(sql_file);\n      }\n\n      field= mysql_fetch_field_direct(result, 0);\n      if (strcmp(field->name, \"View\") == 0)\n      {\n        char *scv_buff= NULL;\n        my_ulonglong n_cols;\n\n        verbose_msg(\"-- It's a view, create dummy table for view\\n\");\n\n        \/* save \"show create\" statement for later *\/\n        if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))\n          scv_buff= my_strdup(scv_buff, MYF(0));\n\n        mysql_free_result(result);\n\n        \/*\n          Create a table with the same name as the view and with columns of\n          the same name in order to satisfy views that depend on this view.\n          The table will be removed when the actual view is created.\n\n          The properties of each column, are not preserved in this temporary\n          table, because they are not necessary.\n\n          This will not be necessary once we can determine dependencies\n          between views and can simply dump them in the appropriate order.\n        *\/\n        my_snprintf(query_buff, sizeof(query_buff),\n                    \"SHOW FIELDS FROM %s\", result_table);\n        if (switch_character_set_results(mysql, \"binary\") ||\n            mysql_query_with_error_report(mysql, &result, query_buff) ||\n            switch_character_set_results(mysql, default_charset))\n        {\n          \/*\n            View references invalid or privileged table\/col\/fun (err 1356),\n            so we cannot create a stand-in table.  Be defensive and dump\n            a comment with the view's 'show create' statement. (Bug #17371)\n          *\/\n\n          if (mysql_errno(mysql) == ER_VIEW_INVALID)\n            fprintf(sql_file, \"\\n-- failed on view %s: %s\\n\\n\", result_table, scv_buff ? scv_buff : \"\");\n\n          my_free(scv_buff);\n\n          DBUG_RETURN(0);\n        }\n        else\n          my_free(scv_buff);\n\n        n_cols= mysql_num_rows(result);\n        if (0 != n_cols)\n        {\n\n          \/*\n            The actual formula is based on the column names and how the .FRM\n            files are stored and is too volatile to be repeated here.\n            Thus we simply warn the user if the columns exceed a limit we\n            know works most of the time.\n          *\/\n          if (n_cols >= 1000)\n            fprintf(stderr,\n                    \"-- Warning: Creating a stand-in table for view %s may\"\n                    \" fail when replaying the dump file produced because \"\n                    \"of the number of columns exceeding 1000. Exercise \"\n                    \"caution when replaying the produced dump file.\\n\", \n                    table);\n          if (opt_drop)\n          {\n            \/*\n              We have already dropped any table of the same name above, so\n              here we just drop the view.\n            *\/\n\n            fprintf(sql_file, \"\/*!50001 DROP VIEW IF EXISTS %s*\/;\\n\",\n                    opt_quoted_table);\n            check_io(sql_file);\n          }\n\n          fprintf(sql_file,\n                  \"SET @saved_cs_client     = @@character_set_client;\\n\"\n                  \"SET character_set_client = utf8;\\n\"\n                  \"\/*!50001 CREATE TABLE %s (\\n\",\n                  result_table);\n\n          \/*\n            Get first row, following loop will prepend comma - keeps from\n            having to know if the row being printed is last to determine if\n            there should be a _trailing_ comma.\n          *\/\n\n          row= mysql_fetch_row(result);\n\n          \/*\n            The actual column type doesn't matter anyway, since the table will\n            be dropped at run time.\n            We do tinyint to avoid hitting the row size limit.\n          *\/\n          fprintf(sql_file, \"  %s tinyint NOT NULL\",\n                  quote_name(row[0], name_buff, 0));\n\n          while((row= mysql_fetch_row(result)))\n          {\n            \/* col name, col type *\/\n            fprintf(sql_file, \",\\n  %s tinyint NOT NULL\",\n                    quote_name(row[0], name_buff, 0));\n          }\n\n          \/*\n            Stand-in tables are always MyISAM tables as the default\n            engine might have a column-limit that's lower than the\n            number of columns in the view, and MyISAM support is\n            guaranteed to be in the server anyway.\n          *\/\n          fprintf(sql_file,\n                  \"\\n) ENGINE=MyISAM *\/;\\n\"\n                  \"SET character_set_client = @saved_cs_client;\\n\");\n\n          check_io(sql_file);\n        }\n\n        mysql_free_result(result);\n\n        if (path)\n          my_fclose(sql_file, MYF(MY_WME));\n\n        seen_views= 1;\n        DBUG_RETURN(0);\n      }\n\n      row= mysql_fetch_row(result);\n\n      is_log_table= general_log_or_slow_log_tables(db, table);\n      if (is_log_table)\n        row[1]+= 13; \/* strlen(\"CREATE TABLE \")= 13 *\/\n      if (opt_compatible_mode & 3)\n      {\n        fprintf(sql_file,\n                is_log_table ? \"CREATE TABLE IF NOT EXISTS %s;\\n\" : \"%s;\\n\",\n                row[1]);\n      }\n      else\n      {\n        fprintf(sql_file,\n                \"\/*!40101 SET @saved_cs_client     = @@character_set_client *\/;\\n\"\n                \"\/*!40101 SET character_set_client = utf8 *\/;\\n\"\n                \"%s%s;\\n\"\n                \"\/*!40101 SET character_set_client = @saved_cs_client *\/;\\n\",\n                is_log_table ? \"CREATE TABLE IF NOT EXISTS \" : \"\",\n                row[1]);\n      }\n\n      check_io(sql_file);\n      mysql_free_result(result);\n    }\n    my_snprintf(query_buff, sizeof(query_buff), \"show fields from %s\",\n                result_table);\n    if (mysql_query_with_error_report(mysql, &result, query_buff))\n    {\n      if (path)\n        my_fclose(sql_file, MYF(MY_WME));\n      DBUG_RETURN(0);\n    }\n\n    \/*\n      If write_data is true, then we build up insert statements for\n      the table's data. Note: in subsequent lines of code, this test\n      will have to be performed each time we are appending to\n      insert_pat.\n    *\/\n    if (write_data)\n    {\n      if (opt_replace_into)\n        dynstr_append_checked(&insert_pat, \"REPLACE \");\n      else\n        dynstr_append_checked(&insert_pat, \"INSERT \");\n      dynstr_append_checked(&insert_pat, insert_option);\n      dynstr_append_checked(&insert_pat, \"INTO \");\n      dynstr_append_checked(&insert_pat, opt_quoted_table);\n      if (complete_insert)\n      {\n        dynstr_append_checked(&insert_pat, \" (\");\n      }\n      else\n      {\n        dynstr_append_checked(&insert_pat, \" VALUES \");\n        if (!extended_insert)\n          dynstr_append_checked(&insert_pat, \"(\");\n      }\n    }\n\n    while ((row= mysql_fetch_row(result)))\n    {\n      if (complete_insert)\n      {\n        if (init)\n        {\n          dynstr_append_checked(&insert_pat, \", \");\n        }\n        init=1;\n        dynstr_append_checked(&insert_pat,\n                      quote_name(row[SHOW_FIELDNAME], name_buff, 0));\n      }\n    }\n    num_fields= mysql_num_rows(result);\n    mysql_free_result(result);\n  }\n  else\n  {\n    verbose_msg(\"%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\\n\",\n                my_progname_short, mysql_error(mysql));\n\n    my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);\n\n    if (mysql_query_with_error_report(mysql, &result, query_buff))\n      DBUG_RETURN(0);\n\n    \/* Make an sql-file, if path was given iow. option -T was given *\/\n    if (!opt_no_create_info)\n    {\n      if (path)\n      {\n        if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))\n          DBUG_RETURN(0);\n        write_header(sql_file, db);\n      }\n\n      print_comment(sql_file, 0,\n                    \"\\n--\\n-- Table structure for table %s\\n--\\n\\n\",\n                    fix_for_comment(result_table));\n      if (opt_drop)\n        fprintf(sql_file, \"DROP TABLE IF EXISTS %s;\\n\", result_table);\n      if (!opt_xml)\n        fprintf(sql_file, \"CREATE TABLE %s (\\n\", result_table);\n      else\n        print_xml_tag(sql_file, \"\\t\", \"\\n\", \"table_structure\", \"name=\", table, \n                NullS);\n      check_io(sql_file);\n    }\n\n    if (write_data)\n    {\n      if (opt_replace_into)\n        dynstr_append_checked(&insert_pat, \"REPLACE \");\n      else\n        dynstr_append_checked(&insert_pat, \"INSERT \");\n      dynstr_append_checked(&insert_pat, insert_option);\n      dynstr_append_checked(&insert_pat, \"INTO \");\n      dynstr_append_checked(&insert_pat, result_table);\n      if (complete_insert)\n        dynstr_append_checked(&insert_pat, \" (\");\n      else\n      {\n        dynstr_append_checked(&insert_pat, \" VALUES \");\n        if (!extended_insert)\n          dynstr_append_checked(&insert_pat, \"(\");\n      }\n    }\n\n    while ((row= mysql_fetch_row(result)))\n    {\n      ulong *lengths= mysql_fetch_lengths(result);\n      if (init)\n      {\n        if (!opt_xml && !opt_no_create_info)\n        {\n          fputs(\",\\n\",sql_file);\n          check_io(sql_file);\n        }\n        if (complete_insert)\n          dynstr_append_checked(&insert_pat, \", \");\n      }\n      init=1;\n      if (complete_insert)\n        dynstr_append_checked(&insert_pat,\n                      quote_name(row[SHOW_FIELDNAME], name_buff, 0));\n      if (!opt_no_create_info)\n      {\n        if (opt_xml)\n        {\n          print_xml_row(sql_file, \"field\", result, &row, NullS);\n          continue;\n        }\n\n        if (opt_keywords)\n          fprintf(sql_file, \"  %s.%s %s\", result_table,\n                  quote_name(row[SHOW_FIELDNAME],name_buff, 0),\n                  row[SHOW_TYPE]);\n        else\n          fprintf(sql_file, \"  %s %s\", quote_name(row[SHOW_FIELDNAME],\n                                                  name_buff, 0),\n                  row[SHOW_TYPE]);\n        if (row[SHOW_DEFAULT])\n        {\n          fputs(\" DEFAULT \", sql_file);\n          unescape(sql_file, row[SHOW_DEFAULT], lengths[SHOW_DEFAULT]);\n        }\n        if (!row[SHOW_NULL][0])\n          fputs(\" NOT NULL\", sql_file);\n        if (row[SHOW_EXTRA][0])\n          fprintf(sql_file, \" %s\",row[SHOW_EXTRA]);\n        check_io(sql_file);\n      }\n    }\n    num_fields= mysql_num_rows(result);\n    mysql_free_result(result);\n    if (!opt_no_create_info)\n    {\n      \/* Make an sql-file, if path was given iow. option -T was given *\/\n      char buff[20+FN_REFLEN];\n      uint keynr,primary_key;\n      my_snprintf(buff, sizeof(buff), \"show keys from %s\", result_table);\n      if (mysql_query_with_error_report(mysql, &result, buff))\n      {\n        if (mysql_errno(mysql) == ER_WRONG_OBJECT)\n        {\n          \/* it is VIEW *\/\n          fputs(\"\\t\\t\\n\", sql_file);\n          goto continue_xml;\n        }\n        fprintf(stderr, \"%s: Can't get keys for table %s (%s)\\n\",\n                my_progname_short, result_table, mysql_error(mysql));\n        if (path)\n          my_fclose(sql_file, MYF(MY_WME));\n        DBUG_RETURN(0);\n      }\n\n      \/* Find first which key is primary key *\/\n      keynr=0;\n      primary_key=INT_MAX;\n      while ((row= mysql_fetch_row(result)))\n      {\n        if (atoi(row[3]) == 1)\n        {\n          keynr++;\n#ifdef FORCE_PRIMARY_KEY\n          if (atoi(row[1]) == 0 && primary_key == INT_MAX)\n            primary_key=keynr;\n#endif\n          if (!strcmp(row[2],\"PRIMARY\"))\n          {\n            primary_key=keynr;\n            break;\n          }\n        }\n      }\n      mysql_data_seek(result,0);\n      keynr=0;\n      while ((row= mysql_fetch_row(result)))\n      {\n        if (opt_xml)\n        {\n          print_xml_row(sql_file, \"key\", result, &row, NullS);\n          continue;\n        }\n\n        if (atoi(row[3]) == 1)\n        {\n          if (keynr++)\n            putc(')', sql_file);\n          if (atoi(row[1]))       \/* Test if duplicate key *\/\n            \/* Duplicate allowed *\/\n            fprintf(sql_file, \",\\n  KEY %s (\",quote_name(row[2],name_buff,0));\n          else if (keynr == primary_key)\n            fputs(\",\\n  PRIMARY KEY (\",sql_file); \/* First UNIQUE is primary *\/\n          else\n            fprintf(sql_file, \",\\n  UNIQUE %s (\",quote_name(row[2],name_buff,\n                                                            0));\n        }\n        else\n          putc(',', sql_file);\n        fputs(quote_name(row[4], name_buff, 0), sql_file);\n        if (row[7])\n          fprintf(sql_file, \" (%s)\",row[7]);      \/* Sub key *\/\n        check_io(sql_file);\n      }\n      mysql_free_result(result);\n      if (!opt_xml)\n      {\n        if (keynr)\n          putc(')', sql_file);\n        fputs(\"\\n)\",sql_file);\n        check_io(sql_file);\n      }\n\n      \/* Get MySQL specific create options *\/\n      if (create_options)\n      {\n        char show_name_buff[NAME_LEN*2+2+24];\n\n        \/* Check memory for quote_for_like() *\/\n        my_snprintf(buff, sizeof(buff), \"show table status like %s\",\n                    quote_for_like(table, show_name_buff));\n\n        if (mysql_query_with_error_report(mysql, &result, buff))\n        {\n          if (mysql_errno(mysql) != ER_PARSE_ERROR)\n          {                                     \/* If old MySQL version *\/\n            verbose_msg(\"-- Warning: Couldn't get status information for \" \\\n                        \"table %s (%s)\\n\", result_table,mysql_error(mysql));\n          }\n        }\n        else if (!(row= mysql_fetch_row(result)))\n        {\n          fprintf(stderr,\n                  \"Error: Couldn't read status information for table %s (%s)\\n\",\n                  result_table,mysql_error(mysql));\n        }\n        else\n        {\n          if (opt_xml)\n            print_xml_row(sql_file, \"options\", result, &row, NullS);\n          else\n          {\n            fputs(\"\/*!\",sql_file);\n            print_value(sql_file,result,row,\"engine=\",\"Engine\",0);\n            print_value(sql_file,result,row,\"\",\"Create_options\",0);\n            print_value(sql_file,result,row,\"comment=\",\"Comment\",1);\n            fputs(\" *\/\",sql_file);\n            check_io(sql_file);\n          }\n        }\n        mysql_free_result(result);              \/* Is always safe to free *\/\n      }\ncontinue_xml:\n      if (!opt_xml)\n        fputs(\";\\n\", sql_file);\n      else\n        fputs(\"\\t<\/table_structure>\\n\", sql_file);\n      check_io(sql_file);\n    }\n  }\n  if (complete_insert)\n  {\n    dynstr_append_checked(&insert_pat, \") VALUES \");\n    if (!extended_insert)\n      dynstr_append_checked(&insert_pat, \"(\");\n  }\n  if (sql_file != md_result_file)\n  {\n    fputs(\"\\n\", sql_file);\n    write_footer(sql_file);\n    my_fclose(sql_file, MYF(MY_WME));\n  }\n  DBUG_RETURN((uint) num_fields);\n} \/* get_table_structure *\/","target":0,"code_token_length":4365,"total_token_length":4601,"max_tokens_setting":6144}
+{"idx":496456,"func":"transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)\n{\n\tIndexStmt  *index;\n\tList\t   *notnullcmds = NIL;\n\tListCell   *lc;\n\n\tindex = makeNode(IndexStmt);\n\n\tindex->unique = (constraint->contype != CONSTR_EXCLUSION);\n\tindex->primary = (constraint->contype == CONSTR_PRIMARY);\n\tif (index->primary)\n\t{\n\t\tif (cxt->pkey != NULL)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_INVALID_TABLE_DEFINITION),\n\t\t\t\t\t errmsg(\"multiple primary keys for table \\\"%s\\\" are not allowed\",\n\t\t\t\t\t\t\tcxt->relation->relname),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\t\tcxt->pkey = index;\n\n\t\t\/*\n\t\t * In ALTER TABLE case, a primary index might already exist, but\n\t\t * DefineIndex will check for it.\n\t\t *\/\n\t}\n\tindex->isconstraint = true;\n\tindex->deferrable = constraint->deferrable;\n\tindex->initdeferred = constraint->initdeferred;\n\n\tif (constraint->conname != NULL)\n\t\tindex->idxname = pstrdup(constraint->conname);\n\telse\n\t\tindex->idxname = NULL;\t\/* DefineIndex will choose name *\/\n\n\tindex->relation = cxt->relation;\n\tindex->accessMethod = constraint->access_method ? constraint->access_method : DEFAULT_INDEX_TYPE;\n\tindex->options = constraint->options;\n\tindex->tableSpace = constraint->indexspace;\n\tindex->whereClause = constraint->where_clause;\n\tindex->indexParams = NIL;\n\tindex->indexIncludingParams = NIL;\n\tindex->excludeOpNames = NIL;\n\tindex->idxcomment = NULL;\n\tindex->indexOid = InvalidOid;\n\tindex->oldNode = InvalidOid;\n\tindex->transformed = false;\n\tindex->concurrent = false;\n\tindex->if_not_exists = false;\n\tindex->reset_default_tblspc = constraint->reset_default_tblspc;\n\n\t\/*\n\t * If it's ALTER TABLE ADD CONSTRAINT USING INDEX, look up the index and\n\t * verify it's usable, then extract the implied column name list.  (We\n\t * will not actually need the column name list at runtime, but we need it\n\t * now to check for duplicate column entries below.)\n\t *\/\n\tif (constraint->indexname != NULL)\n\t{\n\t\tchar\t   *index_name = constraint->indexname;\n\t\tRelation\theap_rel = cxt->rel;\n\t\tOid\t\t\tindex_oid;\n\t\tRelation\tindex_rel;\n\t\tForm_pg_index index_form;\n\t\toidvector  *indclass;\n\t\tDatum\t\tindclassDatum;\n\t\tbool\t\tisnull;\n\t\tint\t\t\ti;\n\n\t\t\/* Grammar should not allow this with explicit column list *\/\n\t\tAssert(constraint->keys == NIL);\n\n\t\t\/* Grammar should only allow PRIMARY and UNIQUE constraints *\/\n\t\tAssert(constraint->contype == CONSTR_PRIMARY ||\n\t\t\t   constraint->contype == CONSTR_UNIQUE);\n\n\t\t\/* Must be ALTER, not CREATE, but grammar doesn't enforce that *\/\n\t\tif (!cxt->isalter)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t\t errmsg(\"cannot use an existing index in CREATE TABLE\"),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/* Look for the index in the same schema as the table *\/\n\t\tindex_oid = get_relname_relid(index_name, RelationGetNamespace(heap_rel));\n\n\t\tif (!OidIsValid(index_oid))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_OBJECT),\n\t\t\t\t\t errmsg(\"index \\\"%s\\\" does not exist\", index_name),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/* Open the index (this will throw an error if it is not an index) *\/\n\t\tindex_rel = index_open(index_oid, AccessShareLock);\n\t\tindex_form = index_rel->rd_index;\n\n\t\t\/* Check that it does not have an associated constraint already *\/\n\t\tif (OidIsValid(get_index_constraint(index_oid)))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),\n\t\t\t\t\t errmsg(\"index \\\"%s\\\" is already associated with a constraint\",\n\t\t\t\t\t\t\tindex_name),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/* Perform validity checks on the index *\/\n\t\tif (index_form->indrelid != RelationGetRelid(heap_rel))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),\n\t\t\t\t\t errmsg(\"index \\\"%s\\\" does not belong to table \\\"%s\\\"\",\n\t\t\t\t\t\t\tindex_name, RelationGetRelationName(heap_rel)),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\tif (!index_form->indisvalid)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),\n\t\t\t\t\t errmsg(\"index \\\"%s\\\" is not valid\", index_name),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\tif (!index_form->indisunique)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t errmsg(\"\\\"%s\\\" is not a unique index\", index_name),\n\t\t\t\t\t errdetail(\"Cannot create a primary key or unique constraint using such an index.\"),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\tif (RelationGetIndexExpressions(index_rel) != NIL)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t errmsg(\"index \\\"%s\\\" contains expressions\", index_name),\n\t\t\t\t\t errdetail(\"Cannot create a primary key or unique constraint using such an index.\"),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\tif (RelationGetIndexPredicate(index_rel) != NIL)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t errmsg(\"\\\"%s\\\" is a partial index\", index_name),\n\t\t\t\t\t errdetail(\"Cannot create a primary key or unique constraint using such an index.\"),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/*\n\t\t * It's probably unsafe to change a deferred index to non-deferred. (A\n\t\t * non-constraint index couldn't be deferred anyway, so this case\n\t\t * should never occur; no need to sweat, but let's check it.)\n\t\t *\/\n\t\tif (!index_form->indimmediate && !constraint->deferrable)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t errmsg(\"\\\"%s\\\" is a deferrable index\", index_name),\n\t\t\t\t\t errdetail(\"Cannot create a non-deferrable constraint using a deferrable index.\"),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/*\n\t\t * Insist on it being a btree.  That's the only kind that supports\n\t\t * uniqueness at the moment anyway; but we must have an index that\n\t\t * exactly matches what you'd get from plain ADD CONSTRAINT syntax,\n\t\t * else dump and reload will produce a different index (breaking\n\t\t * pg_upgrade in particular).\n\t\t *\/\n\t\tif (index_rel->rd_rel->relam != get_index_am_oid(DEFAULT_INDEX_TYPE, false))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t errmsg(\"index \\\"%s\\\" is not a btree\", index_name),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/* Must get indclass the hard way *\/\n\t\tindclassDatum = SysCacheGetAttr(INDEXRELID, index_rel->rd_indextuple,\n\t\t\t\t\t\t\t\t\t\tAnum_pg_index_indclass, &isnull);\n\t\tAssert(!isnull);\n\t\tindclass = (oidvector *) DatumGetPointer(indclassDatum);\n\n\t\tfor (i = 0; i < index_form->indnatts; i++)\n\t\t{\n\t\t\tint16\t\tattnum = index_form->indkey.values[i];\n\t\t\tconst FormData_pg_attribute *attform;\n\t\t\tchar\t   *attname;\n\t\t\tOid\t\t\tdefopclass;\n\n\t\t\t\/*\n\t\t\t * We shouldn't see attnum == 0 here, since we already rejected\n\t\t\t * expression indexes.  If we do, SystemAttributeDefinition will\n\t\t\t * throw an error.\n\t\t\t *\/\n\t\t\tif (attnum > 0)\n\t\t\t{\n\t\t\t\tAssert(attnum <= heap_rel->rd_att->natts);\n\t\t\t\tattform = TupleDescAttr(heap_rel->rd_att, attnum - 1);\n\t\t\t}\n\t\t\telse\n\t\t\t\tattform = SystemAttributeDefinition(attnum);\n\t\t\tattname = pstrdup(NameStr(attform->attname));\n\n\t\t\tif (i < index_form->indnkeyatts)\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Insist on default opclass and sort options.  While the\n\t\t\t\t * index would still work as a constraint with non-default\n\t\t\t\t * settings, it might not provide exactly the same uniqueness\n\t\t\t\t * semantics as you'd get from a normally-created constraint;\n\t\t\t\t * and there's also the dump\/reload problem mentioned above.\n\t\t\t\t *\/\n\t\t\t\tdefopclass = GetDefaultOpClass(attform->atttypid,\n\t\t\t\t\t\t\t\t\t\t\t   index_rel->rd_rel->relam);\n\t\t\t\tif (indclass->values[i] != defopclass ||\n\t\t\t\t\tindex_rel->rd_indoption[i] != 0)\n\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t\t\t errmsg(\"index \\\"%s\\\" column number %d does not have default sorting behavior\", index_name, i + 1),\n\t\t\t\t\t\t\t errdetail(\"Cannot create a primary key or unique constraint using such an index.\"),\n\t\t\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\t\tconstraint->keys = lappend(constraint->keys, makeString(attname));\n\t\t\t}\n\t\t\telse\n\t\t\t\tconstraint->including = lappend(constraint->including, makeString(attname));\n\t\t}\n\n\t\t\/* Close the index relation but keep the lock *\/\n\t\trelation_close(index_rel, NoLock);\n\n\t\tindex->indexOid = index_oid;\n\t}\n\n\t\/*\n\t * If it's an EXCLUDE constraint, the grammar returns a list of pairs of\n\t * IndexElems and operator names.  We have to break that apart into\n\t * separate lists.\n\t *\/\n\tif (constraint->contype == CONSTR_EXCLUSION)\n\t{\n\t\tforeach(lc, constraint->exclusions)\n\t\t{\n\t\t\tList\t   *pair = (List *) lfirst(lc);\n\t\t\tIndexElem  *elem;\n\t\t\tList\t   *opname;\n\n\t\t\tAssert(list_length(pair) == 2);\n\t\t\telem = linitial_node(IndexElem, pair);\n\t\t\topname = lsecond_node(List, pair);\n\n\t\t\tindex->indexParams = lappend(index->indexParams, elem);\n\t\t\tindex->excludeOpNames = lappend(index->excludeOpNames, opname);\n\t\t}\n\t}\n\n\t\/*\n\t * For UNIQUE and PRIMARY KEY, we just have a list of column names.\n\t *\n\t * Make sure referenced keys exist.  If we are making a PRIMARY KEY index,\n\t * also make sure they are NOT NULL.\n\t *\/\n\telse\n\t{\n\t\tforeach(lc, constraint->keys)\n\t\t{\n\t\t\tchar\t   *key = strVal(lfirst(lc));\n\t\t\tbool\t\tfound = false;\n\t\t\tbool\t\tforced_not_null = false;\n\t\t\tColumnDef  *column = NULL;\n\t\t\tListCell   *columns;\n\t\t\tIndexElem  *iparam;\n\n\t\t\t\/* Make sure referenced column exists. *\/\n\t\t\tforeach(columns, cxt->columns)\n\t\t\t{\n\t\t\t\tcolumn = castNode(ColumnDef, lfirst(columns));\n\t\t\t\tif (strcmp(column->colname, key) == 0)\n\t\t\t\t{\n\t\t\t\t\tfound = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (found)\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * column is defined in the new table.  For PRIMARY KEY, we\n\t\t\t\t * can apply the NOT NULL constraint cheaply here ... unless\n\t\t\t\t * the column is marked is_from_type, in which case marking it\n\t\t\t\t * here would be ineffective (see MergeAttributes).\n\t\t\t\t *\/\n\t\t\t\tif (constraint->contype == CONSTR_PRIMARY &&\n\t\t\t\t\t!column->is_from_type)\n\t\t\t\t{\n\t\t\t\t\tcolumn->is_not_null = true;\n\t\t\t\t\tforced_not_null = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (SystemAttributeByName(key) != NULL)\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * column will be a system column in the new table, so accept\n\t\t\t\t * it. System columns can't ever be null, so no need to worry\n\t\t\t\t * about PRIMARY\/NOT NULL constraint.\n\t\t\t\t *\/\n\t\t\t\tfound = true;\n\t\t\t}\n\t\t\telse if (cxt->inhRelations)\n\t\t\t{\n\t\t\t\t\/* try inherited tables *\/\n\t\t\t\tListCell   *inher;\n\n\t\t\t\tforeach(inher, cxt->inhRelations)\n\t\t\t\t{\n\t\t\t\t\tRangeVar   *inh = castNode(RangeVar, lfirst(inher));\n\t\t\t\t\tRelation\trel;\n\t\t\t\t\tint\t\t\tcount;\n\n\t\t\t\t\trel = table_openrv(inh, AccessShareLock);\n\t\t\t\t\t\/* check user requested inheritance from valid relkind *\/\n\t\t\t\t\tif (rel->rd_rel->relkind != RELKIND_RELATION &&\n\t\t\t\t\t\trel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&\n\t\t\t\t\t\trel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)\n\t\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t\t\t\t errmsg(\"inherited relation \\\"%s\\\" is not a table or foreign table\",\n\t\t\t\t\t\t\t\t\t\tinh->relname)));\n\t\t\t\t\tfor (count = 0; count < rel->rd_att->natts; count++)\n\t\t\t\t\t{\n\t\t\t\t\t\tForm_pg_attribute inhattr = TupleDescAttr(rel->rd_att,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  count);\n\t\t\t\t\t\tchar\t   *inhname = NameStr(inhattr->attname);\n\n\t\t\t\t\t\tif (inhattr->attisdropped)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (strcmp(key, inhname) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfound = true;\n\n\t\t\t\t\t\t\t\/*\n\t\t\t\t\t\t\t * It's tempting to set forced_not_null if the\n\t\t\t\t\t\t\t * parent column is already NOT NULL, but that\n\t\t\t\t\t\t\t * seems unsafe because the column's NOT NULL\n\t\t\t\t\t\t\t * marking might disappear between now and\n\t\t\t\t\t\t\t * execution.  Do the runtime check to be safe.\n\t\t\t\t\t\t\t *\/\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttable_close(rel, NoLock);\n\t\t\t\t\tif (found)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * In the ALTER TABLE case, don't complain about index keys not\n\t\t\t * created in the command; they may well exist already.\n\t\t\t * DefineIndex will complain about them if not.\n\t\t\t *\/\n\t\t\tif (!found && !cxt->isalter)\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_COLUMN),\n\t\t\t\t\t\t errmsg(\"column \\\"%s\\\" named in key does not exist\", key),\n\t\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\t\/* Check for PRIMARY KEY(foo, foo) *\/\n\t\t\tforeach(columns, index->indexParams)\n\t\t\t{\n\t\t\t\tiparam = (IndexElem *) lfirst(columns);\n\t\t\t\tif (iparam->name && strcmp(key, iparam->name) == 0)\n\t\t\t\t{\n\t\t\t\t\tif (index->primary)\n\t\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t\t(errcode(ERRCODE_DUPLICATE_COLUMN),\n\t\t\t\t\t\t\t\t errmsg(\"column \\\"%s\\\" appears twice in primary key constraint\",\n\t\t\t\t\t\t\t\t\t\tkey),\n\t\t\t\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\t\t\t\t\telse\n\t\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t\t(errcode(ERRCODE_DUPLICATE_COLUMN),\n\t\t\t\t\t\t\t\t errmsg(\"column \\\"%s\\\" appears twice in unique constraint\",\n\t\t\t\t\t\t\t\t\t\tkey),\n\t\t\t\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/* OK, add it to the index definition *\/\n\t\t\tiparam = makeNode(IndexElem);\n\t\t\tiparam->name = pstrdup(key);\n\t\t\tiparam->expr = NULL;\n\t\t\tiparam->indexcolname = NULL;\n\t\t\tiparam->collation = NIL;\n\t\t\tiparam->opclass = NIL;\n\t\t\tiparam->ordering = SORTBY_DEFAULT;\n\t\t\tiparam->nulls_ordering = SORTBY_NULLS_DEFAULT;\n\t\t\tindex->indexParams = lappend(index->indexParams, iparam);\n\n\t\t\t\/*\n\t\t\t * For a primary-key column, also create an item for ALTER TABLE\n\t\t\t * SET NOT NULL if we couldn't ensure it via is_not_null above.\n\t\t\t *\/\n\t\t\tif (constraint->contype == CONSTR_PRIMARY && !forced_not_null)\n\t\t\t{\n\t\t\t\tAlterTableCmd *notnullcmd = makeNode(AlterTableCmd);\n\n\t\t\t\tnotnullcmd->subtype = AT_SetNotNull;\n\t\t\t\tnotnullcmd->name = pstrdup(key);\n\t\t\t\tnotnullcmds = lappend(notnullcmds, notnullcmd);\n\t\t\t}\n\t\t}\n\t}\n\n\t\/*\n\t * Add included columns to index definition.  This is much like the\n\t * simple-column-name-list code above, except that we don't worry about\n\t * NOT NULL marking; included columns in a primary key should not be\n\t * forced NOT NULL.  We don't complain about duplicate columns, either,\n\t * though maybe we should?\n\t *\/\n\tforeach(lc, constraint->including)\n\t{\n\t\tchar\t   *key = strVal(lfirst(lc));\n\t\tbool\t\tfound = false;\n\t\tColumnDef  *column = NULL;\n\t\tListCell   *columns;\n\t\tIndexElem  *iparam;\n\n\t\tforeach(columns, cxt->columns)\n\t\t{\n\t\t\tcolumn = lfirst_node(ColumnDef, columns);\n\t\t\tif (strcmp(column->colname, key) == 0)\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!found)\n\t\t{\n\t\t\tif (SystemAttributeByName(key) != NULL)\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * column will be a system column in the new table, so accept\n\t\t\t\t * it.\n\t\t\t\t *\/\n\t\t\t\tfound = true;\n\t\t\t}\n\t\t\telse if (cxt->inhRelations)\n\t\t\t{\n\t\t\t\t\/* try inherited tables *\/\n\t\t\t\tListCell   *inher;\n\n\t\t\t\tforeach(inher, cxt->inhRelations)\n\t\t\t\t{\n\t\t\t\t\tRangeVar   *inh = lfirst_node(RangeVar, inher);\n\t\t\t\t\tRelation\trel;\n\t\t\t\t\tint\t\t\tcount;\n\n\t\t\t\t\trel = table_openrv(inh, AccessShareLock);\n\t\t\t\t\t\/* check user requested inheritance from valid relkind *\/\n\t\t\t\t\tif (rel->rd_rel->relkind != RELKIND_RELATION &&\n\t\t\t\t\t\trel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&\n\t\t\t\t\t\trel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)\n\t\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t\t\t\t\t errmsg(\"inherited relation \\\"%s\\\" is not a table or foreign table\",\n\t\t\t\t\t\t\t\t\t\tinh->relname)));\n\t\t\t\t\tfor (count = 0; count < rel->rd_att->natts; count++)\n\t\t\t\t\t{\n\t\t\t\t\t\tForm_pg_attribute inhattr = TupleDescAttr(rel->rd_att,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  count);\n\t\t\t\t\t\tchar\t   *inhname = NameStr(inhattr->attname);\n\n\t\t\t\t\t\tif (inhattr->attisdropped)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (strcmp(key, inhname) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttable_close(rel, NoLock);\n\t\t\t\t\tif (found)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/*\n\t\t * In the ALTER TABLE case, don't complain about index keys not\n\t\t * created in the command; they may well exist already. DefineIndex\n\t\t * will complain about them if not.\n\t\t *\/\n\t\tif (!found && !cxt->isalter)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_COLUMN),\n\t\t\t\t\t errmsg(\"column \\\"%s\\\" named in key does not exist\", key),\n\t\t\t\t\t parser_errposition(cxt->pstate, constraint->location)));\n\n\t\t\/* OK, add it to the index definition *\/\n\t\tiparam = makeNode(IndexElem);\n\t\tiparam->name = pstrdup(key);\n\t\tiparam->expr = NULL;\n\t\tiparam->indexcolname = NULL;\n\t\tiparam->collation = NIL;\n\t\tiparam->opclass = NIL;\n\t\tindex->indexIncludingParams = lappend(index->indexIncludingParams, iparam);\n\t}\n\n\t\/*\n\t * If we found anything that requires run-time SET NOT NULL, build a full\n\t * ALTER TABLE command for that and add it to cxt->alist.\n\t *\/\n\tif (notnullcmds)\n\t{\n\t\tAlterTableStmt *alterstmt = makeNode(AlterTableStmt);\n\n\t\talterstmt->relation = copyObject(cxt->relation);\n\t\talterstmt->cmds = notnullcmds;\n\t\talterstmt->relkind = OBJECT_TABLE;\n\t\talterstmt->missing_ok = false;\n\n\t\tcxt->alist = lappend(cxt->alist, alterstmt);\n\t}\n\n\treturn index;\n}","target":0,"code_token_length":4403,"total_token_length":4639,"max_tokens_setting":6144}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..775bd5614128d6bdd537521a295727d2b106bdee
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5d51783d91bf2265273448cb8839b00ea04877e20e440729e86f90b48e1e0b19
+size 769770
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..babedbf78c68b40b2a8832e649f915ed926991f7
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.jsonl
@@ -0,0 +1,2089 @@
+{"idx":447858,"func":"SendDeviceLedFBs(DeviceIntPtr dev,\n                 int class, int id, unsigned wantLength, ClientPtr client)\n{\n    int length = 0;\n\n    if (class == XkbDfltXIClass) {\n        if (dev->kbdfeed)\n            class = KbdFeedbackClass;\n        else if (dev->leds)\n            class = LedFeedbackClass;\n    }\n    if ((dev->kbdfeed) &&\n        ((class == KbdFeedbackClass) || (class == XkbAllXIClasses))) {\n        KbdFeedbackPtr kf;\n\n        for (kf = dev->kbdfeed; (kf); kf = kf->next) {\n            if ((id == XkbAllXIIds) || (id == XkbDfltXIId) ||\n                (id == kf->ctrl.id)) {\n                length += SendDeviceLedInfo(kf->xkb_sli, client);\n                if (id != XkbAllXIIds)\n                    break;\n            }\n        }\n    }\n    if ((dev->leds) &&\n        ((class == LedFeedbackClass) || (class == XkbAllXIClasses))) {\n        LedFeedbackPtr lf;\n\n        for (lf = dev->leds; (lf); lf = lf->next) {\n            if ((id == XkbAllXIIds) || (id == XkbDfltXIId) ||\n                (id == lf->ctrl.id)) {\n                length += SendDeviceLedInfo(lf->xkb_sli, client);\n                if (id != XkbAllXIIds)\n                    break;\n            }\n        }\n    }\n    if (length == wantLength)\n        return Success;\n    else\n        return BadLength;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":52647,"func":"static int ext4_delete_entry(handle_t *handle,\n\t\t\t     struct inode *dir,\n\t\t\t     struct ext4_dir_entry_2 *de_del,\n\t\t\t     struct buffer_head *bh)\n{\n\tint err, csum_size = 0;\n\n\tif (ext4_has_inline_data(dir)) {\n\t\tint has_inline_data = 1;\n\t\terr = ext4_delete_inline_entry(handle, dir, de_del, bh,\n\t\t\t\t\t       &has_inline_data);\n\t\tif (has_inline_data)\n\t\t\treturn err;\n\t}\n\n\tif (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb,\n\t\t\t\t       EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))\n\t\tcsum_size = sizeof(struct ext4_dir_entry_tail);\n\n\tBUFFER_TRACE(bh, \"get_write_access\");\n\terr = ext4_journal_get_write_access(handle, bh);\n\tif (unlikely(err))\n\t\tgoto out;\n\n\terr = ext4_generic_delete_entry(handle, dir, de_del,\n\t\t\t\t\tbh, bh->b_data,\n\t\t\t\t\tdir->i_sb->s_blocksize, csum_size);\n\tif (err)\n\t\tgoto out;\n\n\tBUFFER_TRACE(bh, \"call ext4_handle_dirty_metadata\");\n\terr = ext4_handle_dirty_dirent_node(handle, dir, bh);\n\tif (unlikely(err))\n\t\tgoto out;\n\n\treturn 0;\nout:\n\tif (err != -ENOENT)\n\t\text4_std_error(dir->i_sb, err);\n\treturn err;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":189251,"func":"void GLES2DecoderWithShaderTestBase::SetUp() {\n  GLES2DecoderTestBase::SetUp();\n\n  {\n    static AttribInfo attribs[] = {\n      { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },\n      { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, },\n      { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },\n    };\n    static UniformInfo uniforms[] = {\n      { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1Location, },\n      { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2Location, },\n      { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3Location, },\n    };\n    SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),\n                client_program_id_, kServiceProgramId,\n                client_vertex_shader_id_, kServiceVertexShaderId,\n                client_fragment_shader_id_, kServiceFragmentShaderId);\n  }\n\n  {\n    EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))\n        .Times(1)\n        .RetiresOnSaturation();\n    UseProgram cmd;\n    cmd.Init(client_program_id_);\n    EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));\n  }\n}\n","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":239664,"func":"void Browser::TabSelectedAt(TabContentsWrapper* old_contents,\n                            TabContentsWrapper* new_contents,\n                            int index,\n                            bool user_gesture) {\n  if (old_contents == new_contents)\n    return;\n\n  if (user_gesture && new_contents->tab_contents()->crashed_status() ==\n        base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {\n    const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();\n    if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) {\n      Reload(CURRENT_TAB);\n      return;\n    }\n  }\n\n  if (!chrome_updater_factory_.empty() && old_contents)\n    ProcessPendingUIUpdates();\n\n  UpdateToolbar(true);\n\n  UpdateReloadStopState(new_contents->tab_contents()->is_loading(), true);\n\n  UpdateCommandsForTabState();\n\n  StatusBubble* status_bubble = GetStatusBubble();\n  if (status_bubble) {\n    status_bubble->Hide();\n\n    status_bubble->SetStatus(GetSelectedTabContentsWrapper()->GetStatusText());\n  }\n\n  if (HasFindBarController()) {\n    find_bar_controller_->ChangeTabContents(new_contents);\n    find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);\n  }\n\n  if (profile_->HasSessionService()) {\n    SessionService* session_service = profile_->GetSessionService();\n    if (session_service && !tab_handler_->GetTabStripModel()->closing_all()) {\n      session_service->SetSelectedTabInWindow(\n          session_id(), tab_handler_->GetTabStripModel()->active_index());\n    }\n  }\n}\n","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":479813,"func":"    CImg get_label(const bool is_high_connectivity=false, const Tfloat tolerance=0,\n                           const bool is_L2_norm=true) const {\n      if (is_empty()) return CImg();\n\n      \/\/ Create neighborhood tables.\n      int dx[13], dy[13], dz[13], nb = 0;\n      dx[nb] = 1; dy[nb] = 0; dz[nb++] = 0;\n      dx[nb] = 0; dy[nb] = 1; dz[nb++] = 0;\n      if (is_high_connectivity) {\n        dx[nb] = 1; dy[nb] = 1; dz[nb++] = 0;\n        dx[nb] = 1; dy[nb] = -1; dz[nb++] = 0;\n      }\n      if (_depth>1) { \/\/ 3D version\n        dx[nb] = 0; dy[nb] = 0; dz[nb++]=1;\n        if (is_high_connectivity) {\n          dx[nb] = 1; dy[nb] = 1; dz[nb++] = -1;\n          dx[nb] = 1; dy[nb] = 0; dz[nb++] = -1;\n          dx[nb] = 1; dy[nb] = -1; dz[nb++] = -1;\n          dx[nb] = 0; dy[nb] = 1; dz[nb++] = -1;\n\n          dx[nb] = 0; dy[nb] = 1; dz[nb++] = 1;\n          dx[nb] = 1; dy[nb] = -1; dz[nb++] = 1;\n          dx[nb] = 1; dy[nb] = 0; dz[nb++] = 1;\n          dx[nb] = 1; dy[nb] = 1; dz[nb++] = 1;\n        }\n      }\n      return _label(nb,dx,dy,dz,tolerance,is_L2_norm);\n    }","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":397024,"func":"wc_ucs_to_iso2022(wc_uint32 ucs)\n{\n    wc_table *t;\n    wc_wchar_t cc;\n    int f;\n\n    if (ucs <= WC_C_UCS2_END) {\n\tfor (f = 0; f <= WC_F_CS96_END - WC_F_ISO_BASE; f++) {\n\t    t = &ucs_cs96_table[f];\n\t    if (t->map == NULL)\n\t\tcontinue;\n\t    cc = wc_ucs_to_any((wc_uint16)ucs, t);\n\t    if (!WC_CCS_IS_UNKNOWN(cc.ccs))\n\t\treturn cc;\n\t}\n\tfor (f = 0; f <= WC_F_CS94_END - WC_F_ISO_BASE; f++) {\n\t    t = &ucs_cs94_table[f];\n\t    if (t->map == NULL)\n\t\tcontinue;\n\t    cc = wc_ucs_to_any((wc_uint16)ucs, t);\n\t    if (!WC_CCS_IS_UNKNOWN(cc.ccs))\n\t\treturn cc;\n\t}\n\tfor (f = 0; f <= WC_F_CS942_END - WC_F_ISO_BASE; f++) {\n\t    t = &ucs_cs942_table[f];\n\t    if (t->map == NULL)\n\t\tcontinue;\n\t    cc = wc_ucs_to_any((wc_uint16)ucs, t);\n\t    if (!WC_CCS_IS_UNKNOWN(cc.ccs))\n\t\treturn cc;\n\t}\n    }\n    cc.ccs = WC_CCS_UNKNOWN;\n    return cc;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":365888,"func":"xmlHashGrow(xmlHashTablePtr table, int size) {\n    unsigned long key;\n    int oldsize, i;\n    xmlHashEntryPtr iter, next;\n    struct _xmlHashEntry *oldtable;\n#ifdef DEBUG_GROW\n    unsigned long nbElem = 0;\n#endif\n  \n    if (table == NULL)\n\treturn(-1);\n    if (size < 8)\n        return(-1);\n    if (size > 8 * 2048)\n\treturn(-1);\n\n    oldsize = table->size;\n    oldtable = table->table;\n    if (oldtable == NULL)\n        return(-1);\n  \n    table->table = xmlMalloc(size * sizeof(xmlHashEntry));\n    if (table->table == NULL) {\n\ttable->table = oldtable;\n\treturn(-1);\n    }\n    memset(table->table, 0, size * sizeof(xmlHashEntry));\n    table->size = size;\n\n    \/*\tIf the two loops are merged, there would be situations where\n\ta new entry needs to allocated and data copied into it from \n\tthe main table. So instead, we run through the array twice, first\n\tcopying all the elements in the main array (where we can't get\n\tconflicts) and then the rest, so we only free (and don't allocate)\n    *\/\n    for (i = 0; i < oldsize; i++) {\n\tif (oldtable[i].valid == 0) \n\t    continue;\n\tkey = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,\n\t\t\t\toldtable[i].name3);\n\tmemcpy(&(table->table[key]), &(oldtable[i]), sizeof(xmlHashEntry));\n\ttable->table[key].next = NULL;\n    }\n\n    for (i = 0; i < oldsize; i++) {\n\titer = oldtable[i].next;\n\twhile (iter) {\n\t    next = iter->next;\n\n\t    \/*\n\t     * put back the entry in the new table\n\t     *\/\n\n\t    key = xmlHashComputeKey(table, iter->name, iter->name2,\n\t\t                    iter->name3);\n\t    if (table->table[key].valid == 0) {\n\t\tmemcpy(&(table->table[key]), iter, sizeof(xmlHashEntry));\n\t\ttable->table[key].next = NULL;\n\t\txmlFree(iter);\n\t    } else {\n\t    \titer->next = table->table[key].next;\n\t    \ttable->table[key].next = iter;\n\t    }\n\n#ifdef DEBUG_GROW\n\t    nbElem++;\n#endif\n\n\t    iter = next;\n\t}\n    }\n\n    xmlFree(oldtable);\n\n#ifdef DEBUG_GROW\n    xmlGenericError(xmlGenericErrorContext,\n\t    \"xmlHashGrow : from %d to %d, %d elems\\n\", oldsize, size, nbElem);\n#endif\n\n    return(0);\n}","target":0,"code_token_length":580,"total_token_length":816,"max_tokens_setting":1024}
+{"idx":508667,"func":"static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,\n                            int skcontlen, const ASN1_ITEM *item,\n                            int do_sort, int iclass)\n{\n    int i;\n    ASN1_VALUE *skitem;\n    unsigned char *tmpdat = NULL, *p = NULL;\n    DER_ENC *derlst = NULL, *tder;\n    if (do_sort) {\n        \/* Don't need to sort less than 2 items *\/\n        if (sk_ASN1_VALUE_num(sk) < 2)\n            do_sort = 0;\n        else {\n            derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk)\n                                    * sizeof(*derlst));\n            if (!derlst)\n                return 0;\n            tmpdat = OPENSSL_malloc(skcontlen);\n            if (!tmpdat) {\n                OPENSSL_free(derlst);\n                return 0;\n            }\n        }\n    }\n    \/* If not sorting just output each item *\/\n    if (!do_sort) {\n        for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {\n            skitem = sk_ASN1_VALUE_value(sk, i);\n            ASN1_item_ex_i2d(&skitem, out, item, -1, iclass);\n        }\n        return 1;\n    }\n    p = tmpdat;\n\n    \/* Doing sort: build up a list of each member's DER encoding *\/\n    for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {\n        skitem = sk_ASN1_VALUE_value(sk, i);\n        tder->data = p;\n        tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass);\n        tder->field = skitem;\n    }\n\n    \/* Now sort them *\/\n    qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);\n    \/* Output sorted DER encoding *\/\n    p = *out;\n    for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {\n        memcpy(p, tder->data, tder->length);\n        p += tder->length;\n    }\n    *out = p;\n    \/* If do_sort is 2 then reorder the STACK *\/\n    if (do_sort == 2) {\n        for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)\n            (void)sk_ASN1_VALUE_set(sk, i, tder->field);\n    }\n    OPENSSL_free(derlst);\n    OPENSSL_free(tmpdat);\n    return 1;\n}","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":37220,"func":"UnicodeString::getTerminatedBuffer() {\n  if(!isWritable()) {\n    return nullptr;\n  }\n  UChar *array = getArrayStart();\n  int32_t len = length();\n  if(len < getCapacity()) {\n    if(fUnion.fFields.fLengthAndFlags & kBufferIsReadonly) {\n      \/\/ If leninput)) {\n        apr_socket_t *socket = NULL;\n        apr_time_t save_timeout = -1;\n        \n        if (block) {\n            socket = ap_get_conn_socket(session->c);\n            if (socket) {\n                apr_socket_timeout_get(socket, &save_timeout);\n                apr_socket_timeout_set(socket, timeout);\n            }\n            else {\n                \/* cannot block on timeout *\/\n                ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, session->c, APLOGNO(03379)\n                              \"h2_proxy_session(%s): unable to get conn socket\", \n                              session->id);\n                return APR_ENOTIMPL;\n            }\n        }\n        \n        status = ap_get_brigade(session->c->input_filters, session->input, \n                                AP_MODE_READBYTES, \n                                block? APR_BLOCK_READ : APR_NONBLOCK_READ, \n                                64 * 1024);\n        ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, session->c, \n                      \"h2_proxy_session(%s): read from conn\", session->id);\n        if (socket && save_timeout != -1) {\n            apr_socket_timeout_set(socket, save_timeout);\n        }\n    }\n    \n    if (status == APR_SUCCESS) {\n        status = feed_brigade(session, session->input);\n    }\n    else if (APR_STATUS_IS_TIMEUP(status)) {\n        \/* nop *\/\n    }\n    else if (!APR_STATUS_IS_EAGAIN(status)) {\n        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, APLOGNO(03380)\n                      \"h2_proxy_session(%s): read error\", session->id);\n        dispatch_event(session, H2_PROXYS_EV_CONN_ERROR, status, NULL);\n    }\n\n    return status;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":161760,"func":"void CLASS phase_one_flat_field (int is_float, int nc)\n{\n  ushort head[8];\n  unsigned wide, y, x, c, rend, cend, row, col;\n  float *mrow, num, mult[4];\n\n  read_shorts (head, 8);\n  wide = head[2] \/ head[4];\n  mrow = (float *) calloc (nc*wide, sizeof *mrow);\n  merror (mrow, \"phase_one_flat_field()\");\n  for (y=0; y < head[3] \/ head[5]; y++) {\n    for (x=0; x < wide; x++)\n      for (c=0; c < nc; c+=2) {\n\tnum = is_float ? getreal(11) : get2()\/32768.0;\n\tif (y==0) mrow[c*wide+x] = num;\n\telse mrow[(c+1)*wide+x] = (num - mrow[c*wide+x]) \/ head[5];\n      }\n    if (y==0) continue;\n    rend = head[1] + y*head[5];\n    for (row = rend-head[5]; row < raw_height && row < rend; row++) {\n      for (x=1; x < wide; x++) {\n\tfor (c=0; c < nc; c+=2) {\n\t  mult[c] = mrow[c*wide+x-1];\n\t  mult[c+1] = (mrow[c*wide+x] - mult[c]) \/ head[4];\n\t}\n\tcend = head[0] + x*head[4];\n\tfor (col = cend-head[4]; col < raw_width && col < cend; col++) {\n\t  c = nc > 2 ? FC(row-top_margin,col-left_margin) : 0;\n\t  if (!(c & 1)) {\n\t    c = RAW(row,col) * mult[c];\n\t    RAW(row,col) = LIM(c,0,65535);\n\t  }\n\t  for (c=0; c < nc; c+=2)\n\t    mult[c] += mult[c+1];\n\t}\n      }\n      for (x=0; x < wide; x++)\n\tfor (c=0; c < nc; c+=2)\n\t  mrow[c*wide+x] += mrow[(c+1)*wide+x];\n    }\n  }\n  free (mrow);\n}","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":240406,"func":"void Splash::dumpXPath(SplashXPath *path) {\n  int i;\n\n  for (i = 0; i < path->length; ++i) {\n    printf(\"  %4d: x0=%8.2f y0=%8.2f x1=%8.2f y1=%8.2f %s%s%s%s%s%s%s\\n\",\n\t   i, (double)path->segs[i].x0, (double)path->segs[i].y0,\n\t   (double)path->segs[i].x1, (double)path->segs[i].y1,\n\t   (path->segs[i].flags\t& splashXPathFirst) ? \"F\" : \" \",\n\t   (path->segs[i].flags\t& splashXPathLast) ? \"L\" : \" \",\n\t   (path->segs[i].flags\t& splashXPathEnd0) ? \"0\" : \" \",\n\t   (path->segs[i].flags\t& splashXPathEnd1) ? \"1\" : \" \",\n\t   (path->segs[i].flags\t& splashXPathHoriz) ? \"H\" : \" \",\n\t   (path->segs[i].flags\t& splashXPathVert) ? \"V\" : \" \",\n\t   (path->segs[i].flags\t& splashXPathFlip) ? \"P\" : \" \");\n  }\n}\n","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":367937,"func":"int pgmraw_to_fits (char *pgmfile, char *fitsfile)\n\n{FITS_FILE *fitsout = NULL;\n FILE *pgmin = NULL;\n FITS_HDU_LIST *hdu;\n char buffer[1024];\n int width, height, numbytes, maxbytes;\n int retval = -1;\n\n fitsout = fits_open (fitsfile, \"w\");\n if (fitsout == NULL) goto err_return;\n\n pgmin = g_fopen (pgmfile, \"r\");\n if (pgmin == NULL) goto err_return;\n\n \/* Read signature of PGM file *\/\n if (fgets (buffer, sizeof (buffer), pgmin) == NULL) goto err_return;\n if ((buffer[0] != 'P') || (buffer[1] != '5')) goto err_return;\n\n \/* Skip comments upto width\/height *\/\n do\n {\n   if (fgets (buffer, sizeof (buffer), pgmin) == NULL) goto err_return;\n } while (buffer[0] == '#');\n\n if (sscanf (buffer, \"%d%d\", &width, &height) != 2) goto err_return;\n if ((width < 1) || (height < 1)) goto err_return;\n\n \/* Skip comments upto maxval *\/\n do\n {\n   if (fgets (buffer, sizeof (buffer), pgmin) == NULL) goto err_return;\n } while (buffer[0] == '#');\n \/* Ignore maxval *\/\n\n hdu = fits_add_hdu (fitsout);     \/* Create a HDU for the FITS file *\/\n if (hdu == NULL) goto err_return;\n\n hdu->used.simple = 1;         \/* Set proper values *\/\n hdu->bitpix = 8;\n hdu->naxis = 2;\n hdu->naxisn[0] = width;\n hdu->naxisn[1] = height;\n hdu->used.datamin = 1;\n hdu->datamin = 0.0;\n hdu->used.datamax = 1;\n hdu->datamax = 255.0;\n hdu->used.bzero = 1;\n hdu->bzero = 0.0;\n hdu->used.bscale = 1;\n hdu->bscale = 1.0;\n\n fits_add_card (hdu, \"\");\n fits_add_card (hdu, \"HISTORY THIS FITS FILE WAS GENERATED BY FITSRW\\\n USING PGMRAW_TO_FITS\");\n\n \/* Write the header. Blocking is done automatically *\/\n if (fits_write_header (fitsout, hdu) < 0) goto err_return;\n\n \/* The primary array plus blocking must be written manually *\/\n numbytes = width * height;\n\n while (numbytes > 0)\n {\n   maxbytes = sizeof (buffer);\n   if (maxbytes > numbytes) maxbytes = numbytes;\n\n   if (fread (buffer, 1, maxbytes, pgmin) != maxbytes) goto err_return;\n   if (fwrite (buffer, 1, maxbytes, fitsout->fp) != maxbytes) goto err_return;\n\n   numbytes -= maxbytes;\n }\n\n \/* Do blocking *\/\n numbytes = (width * height) % FITS_RECORD_SIZE;\n if (numbytes)\n {\n   while (numbytes++ < FITS_RECORD_SIZE)\n     if (putc (0, fitsout->fp) == EOF) goto err_return;\n }\n retval = 0;\n\nerr_return:\n\n if (fitsout) fits_close (fitsout);\n if (pgmin) fclose (pgmin);\n\n return (retval);\n}","target":0,"code_token_length":744,"total_token_length":980,"max_tokens_setting":1024}
+{"idx":349562,"func":"HiiGetDatabaseInfo(\r\n  IN CONST EFI_HII_DATABASE_PROTOCOL        *This\r\n  )\r\n{\r\n  EFI_STATUS                          Status;\r\n  EFI_HII_PACKAGE_LIST_HEADER         *DatabaseInfo;\r\n  UINTN                               DatabaseInfoSize;\r\n\r\n  DatabaseInfo         = NULL;\r\n  DatabaseInfoSize     = 0;\r\n\r\n  \/\/\r\n  \/\/ Get HiiDatabase information.\r\n  \/\/\r\n  Status = HiiExportPackageLists(This, NULL, &DatabaseInfoSize, DatabaseInfo);\r\n\r\n  ASSERT(Status == EFI_BUFFER_TOO_SMALL);\r\n\r\n  if(DatabaseInfoSize > gDatabaseInfoSize ) {\r\n    \/\/\r\n    \/\/ Do 25% overallocation to minimize the number of memory allocations after ReadyToBoot.\r\n    \/\/ Since lots of allocation after ReadyToBoot may change memory map and cause S4 resume issue.\r\n    \/\/\r\n    gDatabaseInfoSize = DatabaseInfoSize + (DatabaseInfoSize >> 2);\r\n    if (gRTDatabaseInfoBuffer != NULL){\r\n      FreePool(gRTDatabaseInfoBuffer);\r\n      DEBUG ((DEBUG_WARN, \"[HiiDatabase]: Memory allocation is required after ReadyToBoot, which may change memory map and cause S4 resume issue.\\n\"));\r\n    }\r\n    gRTDatabaseInfoBuffer = AllocateRuntimeZeroPool (gDatabaseInfoSize);\r\n    if (gRTDatabaseInfoBuffer == NULL){\r\n      DEBUG ((DEBUG_ERROR, \"[HiiDatabase]: No enough memory resource to store the HiiDatabase info.\\n\"));\r\n      return EFI_OUT_OF_RESOURCES;\r\n    }\r\n  } else {\r\n    ZeroMem(gRTDatabaseInfoBuffer,gDatabaseInfoSize);\r\n  }\r\n  Status = HiiExportPackageLists(This, NULL, &DatabaseInfoSize, gRTDatabaseInfoBuffer);\r\n  ASSERT_EFI_ERROR (Status);\r\n  gBS->InstallConfigurationTable (&gEfiHiiDatabaseProtocolGuid, gRTDatabaseInfoBuffer);\r\n\r\n  return EFI_SUCCESS;\r\n\r\n}\r","target":1,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":392738,"func":"xmlGzfileOpen_real (const char *filename) {\n    const char *path = NULL;\n    gzFile fd;\n\n    if (!strcmp(filename, \"-\")) {\n        int duped_fd = dup(fileno(stdin));\n        fd = gzdopen(duped_fd, \"rb\");\n        if (fd == Z_NULL && duped_fd >= 0) {\n            close(duped_fd);  \/* gzdOpen() does not close on failure *\/\n        }\n\n\treturn((void *) fd);\n    }\n\n    if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST \"file:\/\/localhost\/\", 17))\n#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)\n\tpath = &filename[17];\n#else\n\tpath = &filename[16];\n#endif\n    else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST \"file:\/\/\/\", 8)) {\n#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)\n\tpath = &filename[8];\n#else\n\tpath = &filename[7];\n#endif\n    } else\n\tpath = filename;\n\n    if (path == NULL)\n\treturn(NULL);\n    if (!xmlCheckFilename(path))\n        return(NULL);\n\n#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)\n    fd = xmlWrapGzOpen(path, \"rb\");\n#else\n    fd = gzopen(path, \"rb\");\n#endif\n    return((void *) fd);\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":363738,"func":"compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,\n\t\t\t    unsigned int *size, const char *name,\n\t\t\t    struct xt_table_info *newinfo, unsigned char *base)\n{\n\tstruct xt_entry_target *t;\n\tstruct xt_target *target;\n\tstruct ip6t_entry *de;\n\tunsigned int origsize;\n\tint ret, h;\n\tstruct xt_entry_match *ematch;\n\n\tret = 0;\n\torigsize = *size;\n\tde = (struct ip6t_entry *)*dstptr;\n\tmemcpy(de, e, sizeof(struct ip6t_entry));\n\tmemcpy(&de->counters, &e->counters, sizeof(e->counters));\n\n\t*dstptr += sizeof(struct ip6t_entry);\n\t*size += sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry);\n\n\txt_ematch_foreach(ematch, e) {\n\t\tret = xt_compat_match_from_user(ematch, dstptr, size);\n\t\tif (ret != 0)\n\t\t\treturn ret;\n\t}\n\tde->target_offset = e->target_offset - (origsize - *size);\n\tt = compat_ip6t_get_target(e);\n\ttarget = t->u.kernel.target;\n\txt_compat_target_from_user(t, dstptr, size);\n\n\tde->next_offset = e->next_offset - (origsize - *size);\n\tfor (h = 0; h < NF_INET_NUMHOOKS; h++) {\n\t\tif ((unsigned char *)de - base < newinfo->hook_entry[h])\n\t\t\tnewinfo->hook_entry[h] -= origsize - *size;\n\t\tif ((unsigned char *)de - base < newinfo->underflow[h])\n\t\t\tnewinfo->underflow[h] -= origsize - *size;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":293305,"func":"\t\tvoid CWebServer::Cmd_AddSceneCode(WebEmSession & session, const request& req, Json::Value &root)\n\t\t{\n\t\t\tif (session.rights != 2)\n\t\t\t{\n\t\t\t\tsession.reply_status = reply::forbidden;\n\t\t\t\treturn; \/\/Only admin user allowed\n\t\t\t}\n\n\t\t\tstd::string sceneidx = request::findValue(&req, \"sceneidx\");\n\t\t\tstd::string idx = request::findValue(&req, \"idx\");\n\t\t\tstd::string cmnd = request::findValue(&req, \"cmnd\");\n\t\t\tif (\n\t\t\t\t(sceneidx.empty()) ||\n\t\t\t\t(idx.empty()) ||\n\t\t\t\t(cmnd.empty())\n\t\t\t\t)\n\t\t\t\treturn;\n\t\t\troot[\"status\"] = \"OK\";\n\t\t\troot[\"title\"] = \"AddSceneCode\";\n\n\t\t\t\/\/First check if we do not already have this device as activation code\n\t\t\tstd::vector > result;\n\t\t\tresult = m_sql.safe_query(\"SELECT Activators, SceneType FROM Scenes WHERE (ID==%q)\", sceneidx.c_str());\n\t\t\tif (result.empty())\n\t\t\t\treturn;\n\t\t\tstd::string Activators = result[0][0];\n\t\t\tunsigned char scenetype = atoi(result[0][1].c_str());\n\n\t\t\tif (!Activators.empty())\n\t\t\t{\n\t\t\t\t\/\/Get Activator device names\n\t\t\t\tstd::vector arrayActivators;\n\t\t\t\tStringSplit(Activators, \";\", arrayActivators);\n\t\t\t\tfor (const auto & ittAct : arrayActivators)\n\t\t\t\t{\n\t\t\t\t\tstd::string sCodeCmd = ittAct;\n\n\t\t\t\t\tstd::vector arrayCode;\n\t\t\t\t\tStringSplit(sCodeCmd, \":\", arrayCode);\n\n\t\t\t\t\tstd::string sID = arrayCode[0];\n\t\t\t\t\tstd::string sCode = \"\";\n\t\t\t\t\tif (arrayCode.size() == 2)\n\t\t\t\t\t{\n\t\t\t\t\t\tsCode = arrayCode[1];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sID == idx)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (scenetype == 1)\n\t\t\t\t\t\t\treturn; \/\/Group does not work with separate codes, so already there\n\t\t\t\t\t\tif (sCode == cmnd)\n\t\t\t\t\t\t\treturn; \/\/same code, already there!\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!Activators.empty())\n\t\t\t\tActivators += \";\";\n\t\t\tActivators += idx;\n\t\t\tif (scenetype == 0)\n\t\t\t{\n\t\t\t\tActivators += \":\" + cmnd;\n\t\t\t}\n\t\t\tm_sql.safe_query(\"UPDATE Scenes SET Activators='%q' WHERE (ID==%q)\", Activators.c_str(), sceneidx.c_str());\n\t\t}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":460552,"func":"int slap_sasl_regexp_rewrite_config(\n\t\tconst char\t*fname,\n\t\tint\t\tlineno,\n\t\tconst char\t*match,\n\t\tconst char\t*replace,\n\t\tconst char\t*context )\n{\n\tint\trc;\n\tchar\t*argvRule[] = { \"rewriteRule\", NULL, NULL, \":@\", NULL };\n\n\t\/* init at first call *\/\n\tif ( sasl_rwinfo == NULL ) {\n\t\tchar *argvEngine[] = { \"rewriteEngine\", \"on\", NULL };\n\t\tchar *argvContext[] = { \"rewriteContext\", NULL, NULL };\n\n\t\t\/* initialize rewrite engine *\/\n \t\tsasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );\n\n\t\t\/* switch on rewrite engine *\/\n \t\trc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvEngine );\n \t\tif (rc != LDAP_SUCCESS) {\n\t\t\treturn rc;\n\t\t}\n\n\t\t\/* create generic authid context *\/\n\t\targvContext[1] = AUTHID_CONTEXT;\n \t\trc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvContext );\n \t\tif (rc != LDAP_SUCCESS) {\n\t\t\treturn rc;\n\t\t}\n\t}\n\n\targvRule[1] = (char *)match;\n\targvRule[2] = (char *)replace;\n \trc = rewrite_parse( sasl_rwinfo, fname, lineno, 4, argvRule );\n\n\treturn rc;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":264174,"func":"static void ftrace_shutdown(struct ftrace_ops *ops, int command)\n{\n\tbool hash_disable = true;\n\n\tif (unlikely(ftrace_disabled))\n\t\treturn;\n\n\tftrace_start_up--;\n\t\/*\n\t * Just warn in case of unbalance, no need to kill ftrace, it's not\n\t * critical but the ftrace_call callers may be never nopped again after\n\t * further ftrace uses.\n\t *\/\n\tWARN_ON_ONCE(ftrace_start_up < 0);\n\n\tif (ops->flags & FTRACE_OPS_FL_GLOBAL) {\n\t\tops = &global_ops;\n\t\tglobal_start_up--;\n\t\tWARN_ON_ONCE(global_start_up < 0);\n\t\t\/* Don't update hash if global still has users *\/\n\t\tif (global_start_up) {\n\t\t\tWARN_ON_ONCE(!ftrace_start_up);\n\t\t\thash_disable = false;\n\t\t}\n\t}\n\n\tif (hash_disable)\n\t\tftrace_hash_rec_disable(ops, 1);\n\n\tif (ops != &global_ops || !global_start_up)\n\t\tops->flags &= ~FTRACE_OPS_FL_ENABLED;\n\n\tcommand |= FTRACE_UPDATE_CALLS;\n\n\tif (saved_ftrace_func != ftrace_trace_function) {\n\t\tsaved_ftrace_func = ftrace_trace_function;\n\t\tcommand |= FTRACE_UPDATE_TRACE_FUNC;\n\t}\n\n\tif (!command || !ftrace_enabled)\n\t\treturn;\n\n\tftrace_run_update_code(command);\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":262454,"func":"R_API RBinJavaAttrInfo *r_bin_java_line_number_table_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0;\n\tut64 curpos, offset = 0;\n\tRBinJavaLineNumberAttribute *lnattr;\n\tif (sz < 6) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\toffset += 6;\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_LINE_NUMBER_TABLE_ATTR;\n\tattr->info.line_number_table_attr.line_number_table_length = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.line_number_table_attr.line_number_table = r_list_newf (free);\n\n\tut32 linenum_len = attr->info.line_number_table_attr.line_number_table_length;\n\tRList *linenum_list = attr->info.line_number_table_attr.line_number_table;\n\tfor (i = 0; i < linenum_len; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\t\/\/ eprintf (\"%\"PFMT64x\" %\"PFMT64x\"\\n\", curpos, sz);\n\t\t\/\/ XXX if (curpos + 8 >= sz) break;\n\t\tlnattr = R_NEW0 (RBinJavaLineNumberAttribute);\n\t\tif (!lnattr) {\n\t\t\tbreak;\n\t\t}\n\t\t\/\/ wtf it works\n\t\tif (offset - 2 > sz) {\n\t\t\tR_FREE (lnattr);\n\t\t\tbreak;\n\t\t}\n\t\tlnattr->start_pc = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlnattr->line_number = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlnattr->file_offset = curpos;\n\t\tlnattr->size = 4;\n\t\tr_list_append (linenum_list, lnattr);\n\t}\n\tattr->size = offset;\n\treturn attr;\n}","target":0,"code_token_length":446,"total_token_length":682,"max_tokens_setting":1024}
+{"idx":452845,"func":"WandExport PixelIterator *NewPixelIterator(MagickWand *wand)\n{\n  const char\n    *quantum;\n\n  ExceptionInfo\n    *exception;\n\n  Image\n    *image;\n\n  PixelIterator\n    *iterator;\n\n  size_t\n    depth;\n\n  CacheView\n    *view;\n\n  depth=MAGICKCORE_QUANTUM_DEPTH;\n  quantum=GetMagickQuantumDepth(&depth);\n  if (depth != MAGICKCORE_QUANTUM_DEPTH)\n    ThrowWandFatalException(WandError,\"QuantumDepthMismatch\",quantum);\n  assert(wand != (MagickWand *) NULL);\n  image=GetImageFromMagickWand(wand);\n  if (image == (Image *) NULL)\n    return((PixelIterator *) NULL);\n  exception=AcquireExceptionInfo();\n  view=AcquireVirtualCacheView(image,exception);\n  if (view == (CacheView *) NULL)\n    return((PixelIterator *) NULL);\n  iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));\n  if (iterator == (PixelIterator *) NULL)\n    ThrowWandFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\",\n      GetExceptionMessage(errno));\n  (void) memset(iterator,0,sizeof(*iterator));\n  iterator->id=AcquireWandId();\n  (void) FormatLocaleString(iterator->name,MagickPathExtent,\"%s-%.20g\",\n    PixelIteratorId,(double) iterator->id);\n  iterator->exception=exception;\n  iterator->view=view;\n  SetGeometry(image,&iterator->region);\n  iterator->region.width=image->columns;\n  iterator->region.height=image->rows;\n  iterator->region.x=0;\n  iterator->region.y=0;\n  iterator->pixel_wands=NewPixelWands(iterator->region.width);\n  iterator->y=0;\n  iterator->debug=IsEventLogging();\n  if (iterator->debug != MagickFalse)\n    (void) LogMagickEvent(WandEvent,GetMagickModule(),\"%s\",iterator->name);\n  iterator->signature=MagickWandSignature;\n  return(iterator);\n}","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":23935,"func":"static void flush_packet ( AVFormatContext * s ) {\n ASFContext * asf = s -> priv_data ;\n int packet_hdr_size , packet_filled_size ;\n av_assert0 ( asf -> packet_timestamp_end >= asf -> packet_timestamp_start ) ;\n if ( asf -> is_streamed ) put_chunk ( s , 0x4424 , s -> packet_size , 0 ) ;\n packet_hdr_size = put_payload_parsing_info ( s , asf -> packet_timestamp_start , asf -> packet_timestamp_end - asf -> packet_timestamp_start , asf -> packet_nb_payloads , asf -> packet_size_left ) ;\n packet_filled_size = PACKET_SIZE - asf -> packet_size_left ;\n av_assert0 ( packet_hdr_size <= asf -> packet_size_left ) ;\n memset ( asf -> packet_buf + packet_filled_size , 0 , asf -> packet_size_left ) ;\n avio_write ( s -> pb , asf -> packet_buf , s -> packet_size - packet_hdr_size ) ;\n avio_flush ( s -> pb ) ;\n asf -> nb_packets ++ ;\n asf -> packet_nb_payloads = 0 ;\n asf -> packet_timestamp_start = - 1 ;\n asf -> packet_timestamp_end = - 1 ;\n ffio_init_context ( & asf -> pb , asf -> packet_buf , s -> packet_size , 1 , NULL , NULL , NULL , NULL ) ;\n }","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":495823,"func":"void gf_av1_reset_state(AV1State *state, Bool is_destroy)\n{\n\tGF_List *l1, *l2;\n\n\tif (state->frame_state.header_obus) {\n\t\twhile (gf_list_count(state->frame_state.header_obus)) {\n\t\t\tGF_AV1_OBUArrayEntry *a = (GF_AV1_OBUArrayEntry*)gf_list_pop_back(state->frame_state.header_obus);\n\t\t\tif (a->obu) gf_free(a->obu);\n\t\t\tgf_free(a);\n\t\t}\n\t}\n\n\tif (state->frame_state.frame_obus) {\n\t\twhile (gf_list_count(state->frame_state.frame_obus)) {\n\t\t\tGF_AV1_OBUArrayEntry *a = (GF_AV1_OBUArrayEntry*)gf_list_pop_back(state->frame_state.frame_obus);\n\t\t\tif (a->obu) gf_free(a->obu);\n\t\t\tgf_free(a);\n\t\t}\n\t}\n\tl1 = state->frame_state.frame_obus;\n\tl2 = state->frame_state.header_obus;\n\tmemset(&state->frame_state, 0, sizeof(AV1StateFrame));\n\tstate->frame_state.is_first_frame = GF_TRUE;\n\n\tif (is_destroy) {\n\t\tgf_list_del(l1);\n\t\tgf_list_del(l2);\n\t\tif (state->bs) {\n\t\t\tu32 size, asize=0;\n\t\t\tu8 *ptr=NULL;\n\t\t\t\/\/detach BS internal buffer\n\t\t\tgf_bs_get_content_no_truncate(state->bs, &ptr, &size, &asize);\n\t\t\t\/\/avoid double free, cf issue 1893\n\t\t\tif (ptr != state->frame_obus) {\n\t\t\t\tgf_free(ptr);\n\t\t\t}\n\t\t\tif (state->frame_obus) {\n\t\t\t\tgf_free(state->frame_obus);\n\t\t\t\tstate->frame_obus = NULL;\n\t\t\t\tstate->frame_obus_alloc = 0;\n\t\t\t}\n\t\t\tgf_bs_del(state->bs);\n\t\t}\n\t\tstate->bs = NULL;\n\t}\n\telse {\n\t\tstate->frame_state.frame_obus = l1;\n\t\tstate->frame_state.header_obus = l2;\n\t\tif (state->bs)\n\t\t\tgf_bs_seek(state->bs, 0);\n\t}\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":265546,"func":"int callback_glewlwyd_check_user_profile_valid (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  char * session_uid;\n  json_t * j_user;\n  int ret, res;\n  \n  if ((session_uid = get_session_id(config, request)) != NULL) {\n    j_user = get_current_user_for_session(config, session_uid);\n    if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, \"user\"), \"enabled\") == json_true()) {\n      if ((res = is_scope_list_valid_for_session(config, config->profile_scope, session_uid)) == G_OK) {\n        if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, \"user\")), (void (*)(void *))&json_decref) != U_OK) {\n          ret = U_CALLBACK_ERROR;\n        } else {\n          ret = U_CALLBACK_IGNORE;\n        }\n      } else {\n        if (res == G_ERROR) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_check_user_session - Error is_scope_list_valid_for_session\");\n        }\n        ret = U_CALLBACK_UNAUTHORIZED;\n      }\n    } else {\n      ret = U_CALLBACK_UNAUTHORIZED;\n    }\n    json_decref(j_user);\n  } else {\n    ret = U_CALLBACK_UNAUTHORIZED;\n  }\n  o_free(session_uid);\n  return ret;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":298950,"func":"rs_filter_set_recursive(RSFilter *filter, ...)\n{\n\tva_list ap;\n\tgchar *property_name;\n\tRSFilter *current_filter;\n\tGParamSpec *spec;\n\tRSFilter *first_seen_here = NULL;\n\tGTypeValueTable *table = NULL;\n\tGType type = 0;\n\tunion CValue {\n\t\tgint     v_int;\n\t\tglong    v_long;\n\t\tgint64   v_int64;\n\t\tgdouble  v_double;\n\t\tgpointer v_pointer;\n\t} value;\n\n\tg_return_if_fail(RS_IS_FILTER(filter));\n\n\tva_start(ap, filter);\n\n\t\/* Loop through all properties *\/\n\twhile ((property_name = va_arg(ap, gchar *)))\n\t{\n\t\t\/* We set table to NULL for every property to indicate that we (again)\n\t\t * have an \"unknown\" type *\/\n\t\ttable = NULL;\n\n\t\tcurrent_filter = filter;\n\t\t\/* Iterate through all filters previous to filter *\/\n\t\tdo {\n\t\t\tif ((spec = g_object_class_find_property(G_OBJECT_GET_CLASS(current_filter), property_name)))\n\t\t\t\tif (spec->flags & G_PARAM_WRITABLE)\n\t\t\t\t{\n\t\t\t\t\t\/* If we got no GTypeValueTable at this point, we aquire\n\t\t\t\t\t * one. We rely on all filters using the same type for all\n\t\t\t\t\t * properties equally named *\/\n\t\t\t\t\tif (!table)\n\t\t\t\t\t{\n\t\t\t\t\t\tfirst_seen_here = current_filter;\n\t\t\t\t\t\ttype = spec->value_type;\n\t\t\t\t\t\ttable = g_type_value_table_peek(type);\n\n\t\t\t\t\t\t\/* If we have no valuetable, we're screwed, bail out *\/\n\t\t\t\t\t\tif (!table)\n\t\t\t\t\t\t\tg_error(\"No GTypeValueTable found for '%s'\", g_type_name(type));\n\n\t\t\t\t\t\tswitch (table->collect_format[0])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 'i': value.v_int = va_arg(ap, gint); break;\n\t\t\t\t\t\t\tcase 'l': value.v_long = va_arg(ap, glong); break;\n\t\t\t\t\t\t\tcase 'd': value.v_double = va_arg(ap, gdouble); break;\n\t\t\t\t\t\t\tcase 'p': value.v_pointer = va_arg(ap, gpointer); break;\n\t\t\t\t\t\t\tdefault: g_error(\"Don't know how to collect for '%s'\", g_type_name(type)); break;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (table)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* We try to catch cases where different filters use\n\t\t\t\t\t\t * the same property name for different types *\/\n\t\t\t\t\t\tif (type != spec->value_type)\n\t\t\t\t\t\t\tg_warning(\"Diverging types found for property '%s' (on filter '%s' and '%s')\",\n\t\t\t\t\t\t\t\tproperty_name,\n\t\t\t\t\t\t\t\tRS_FILTER_NAME(first_seen_here),\n\t\t\t\t\t\t\t\tRS_FILTER_NAME(current_filter));\n\n\t\t\t\t\t\tswitch (table->collect_format[0])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 'i': g_object_set(current_filter, property_name, value.v_int, NULL); break;\n\t\t\t\t\t\t\tcase 'l': g_object_set(current_filter, property_name, value.v_long, NULL); break;\n\t\t\t\t\t\t\tcase 'd': g_object_set(current_filter, property_name, value.v_double, NULL); break;\n\t\t\t\t\t\t\tcase 'p': g_object_set(current_filter, property_name, value.v_pointer, NULL); break;\n\t\t\t\t\t\t\tdefault: break;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t} while (RS_IS_FILTER(current_filter = current_filter->previous));\n\t\tif (!table)\n\t\t{\n\/\/\t\t\tg_warning(\"Property: %s could not be found in filter chain. Skipping further properties\", property_name);\n\t\t\tva_end(ap);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tva_end(ap);\n}","target":0,"code_token_length":730,"total_token_length":966,"max_tokens_setting":1024}
+{"idx":289293,"func":"void nautilus_file_operations_copy ( GList * files , GArray * relative_item_points , GFile * target_dir , GtkWindow * parent_window , NautilusCopyCallback done_callback , gpointer done_callback_data ) {\n GTask * task ;\n CopyMoveJob * job ;\n job = op_job_new ( CopyMoveJob , parent_window ) ;\n job -> desktop_location = nautilus_get_desktop_location ( ) ;\n job -> done_callback = done_callback ;\n job -> done_callback_data = done_callback_data ;\n job -> files = g_list_copy_deep ( files , ( GCopyFunc ) g_object_ref , NULL ) ;\n job -> destination = g_object_ref ( target_dir ) ;\n nautilus_progress_info_set_destination ( ( ( CommonJob * ) job ) -> progress , target_dir ) ;\n if ( relative_item_points != NULL && relative_item_points -> len > 0 ) {\n job -> icon_positions = g_memdup ( relative_item_points -> data , sizeof ( GdkPoint ) * relative_item_points -> len ) ;\n job -> n_icon_positions = relative_item_points -> len ;\n }\n job -> debuting_files = g_hash_table_new_full ( g_file_hash , ( GEqualFunc ) g_file_equal , g_object_unref , NULL ) ;\n inhibit_power_manager ( ( CommonJob * ) job , _ ( \"Copying Files\" ) ) ;\n if ( ! nautilus_file_undo_manager_is_operating ( ) ) {\n GFile * src_dir ;\n src_dir = g_file_get_parent ( files -> data ) ;\n job -> common . undo_info = nautilus_file_undo_info_ext_new ( NAUTILUS_FILE_UNDO_OP_COPY , g_list_length ( files ) , src_dir , target_dir ) ;\n g_object_unref ( src_dir ) ;\n }\n task = g_task_new ( NULL , job -> common . cancellable , copy_task_done , job ) ;\n g_task_set_task_data ( task , job , NULL ) ;\n g_task_run_in_thread ( task , copy_task_thread_func ) ;\n g_object_unref ( task ) ;\n }","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":444758,"func":"TEST_P(DownstreamProtocolIntegrationTest, TestTwoFiltersDecodeHeadersReturnsStopAll) {\n  config_helper_.addFilter(R\"EOF(\nname: decode-headers-return-stop-all-filter\n)EOF\");\n  config_helper_.addFilter(R\"EOF(\nname: decode-headers-return-stop-all-filter\n)EOF\");\n  config_helper_.addFilter(R\"EOF(\nname: passthrough-filter\n)EOF\");\n\n  initialize();\n  codec_client_ = makeHttpConnection(lookupPort(\"http\"));\n\n  \/\/ Sends a request with headers and data.\n  changeHeadersForStopAllTests(default_request_headers_, false);\n  auto encoder_decoder = codec_client_->startRequest(default_request_headers_);\n  request_encoder_ = &encoder_decoder.first;\n  auto response = std::move(encoder_decoder.second);\n  for (int i = 0; i < count_ - 1; i++) {\n    codec_client_->sendData(*request_encoder_, size_, false);\n  }\n  codec_client_->sendData(*request_encoder_, size_, true);\n  waitForNextUpstreamRequest();\n\n  upstream_request_->encodeHeaders(default_response_headers_, true);\n  response->waitForEndStream();\n  ASSERT_TRUE(response->complete());\n  EXPECT_EQ(count_ * size_ + added_decoded_data_size_, upstream_request_->bodyLength());\n  EXPECT_EQ(true, upstream_request_->complete());\n\n  \/\/ Sends a request with headers, data, and trailers.\n  auto encoder_decoder_2 = codec_client_->startRequest(default_request_headers_);\n  request_encoder_ = &encoder_decoder_2.first;\n  response = std::move(encoder_decoder_2.second);\n  for (int i = 0; i < count_; i++) {\n    codec_client_->sendData(*request_encoder_, size_, false);\n  }\n  Http::TestRequestTrailerMapImpl request_trailers{{\"trailer\", \"trailer\"}};\n  codec_client_->sendTrailers(*request_encoder_, request_trailers);\n  waitForNextUpstreamRequest();\n\n  upstream_request_->encodeHeaders(default_response_headers_, true);\n  response->waitForEndStream();\n  verifyUpStreamRequestAfterStopAllFilter();\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":425348,"func":"static void quirk_ioat_snb_local_iommu(struct pci_dev *pdev)\n{\n\tstruct dmar_drhd_unit *drhd;\n\tu32 vtbar;\n\tint rc;\n\n\t\/* We know that this device on this chipset has its own IOMMU.\n\t * If we find it under a different IOMMU, then the BIOS is lying\n\t * to us. Hope that the IOMMU for this device is actually\n\t * disabled, and it needs no translation...\n\t *\/\n\trc = pci_bus_read_config_dword(pdev->bus, PCI_DEVFN(0, 0), 0xb0, &vtbar);\n\tif (rc) {\n\t\t\/* \"can't\" happen *\/\n\t\tdev_info(&pdev->dev, \"failed to run vt-d quirk\\n\");\n\t\treturn;\n\t}\n\tvtbar &= 0xffff0000;\n\n\t\/* we know that the this iommu should be at offset 0xa000 from vtbar *\/\n\tdrhd = dmar_find_matched_drhd_unit(pdev);\n\tif (WARN_TAINT_ONCE(!drhd || drhd->reg_base_addr - vtbar != 0xa000,\n\t\t\t    TAINT_FIRMWARE_WORKAROUND,\n\t\t\t    \"BIOS assigned incorrect VT-d unit for Intel(R) QuickData Technology device\\n\"))\n\t\tpdev->dev.archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":457673,"func":"int __close_range(unsigned fd, unsigned max_fd, unsigned int flags)\n{\n\tunsigned int cur_max;\n\tstruct task_struct *me = current;\n\tstruct files_struct *cur_fds = me->files, *fds = NULL;\n\n\tif (flags & ~CLOSE_RANGE_UNSHARE)\n\t\treturn -EINVAL;\n\n\tif (fd > max_fd)\n\t\treturn -EINVAL;\n\n\trcu_read_lock();\n\tcur_max = files_fdtable(cur_fds)->max_fds;\n\trcu_read_unlock();\n\n\t\/* cap to last valid index into fdtable *\/\n\tcur_max--;\n\n\tif (flags & CLOSE_RANGE_UNSHARE) {\n\t\tint ret;\n\t\tunsigned int max_unshare_fds = NR_OPEN_MAX;\n\n\t\t\/*\n\t\t * If the requested range is greater than the current maximum,\n\t\t * we're closing everything so only copy all file descriptors\n\t\t * beneath the lowest file descriptor.\n\t\t *\/\n\t\tif (max_fd >= cur_max)\n\t\t\tmax_unshare_fds = fd;\n\n\t\tret = unshare_fd(CLONE_FILES, max_unshare_fds, &fds);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/*\n\t\t * We used to share our file descriptor table, and have now\n\t\t * created a private one, make sure we're using it below.\n\t\t *\/\n\t\tif (fds)\n\t\t\tswap(cur_fds, fds);\n\t}\n\n\tmax_fd = min(max_fd, cur_max);\n\twhile (fd <= max_fd) {\n\t\tstruct file *file;\n\n\t\tfile = pick_file(cur_fds, fd++);\n\t\tif (!file)\n\t\t\tcontinue;\n\n\t\tfilp_close(file, cur_fds);\n\t\tcond_resched();\n\t}\n\n\tif (fds) {\n\t\t\/*\n\t\t * We're done closing the files we were supposed to. Time to install\n\t\t * the new file descriptor table and drop the old one.\n\t\t *\/\n\t\ttask_lock(me);\n\t\tme->files = cur_fds;\n\t\ttask_unlock(me);\n\t\tput_files_struct(fds);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":84332,"func":"static void wmv2_idct_row(short * b)\n\n{\n\n    int s1, s2;\n\n    int a0, a1, a2, a3, a4, a5, a6, a7;\n\n\n\n    \/* step 1 *\/\n\n    a1 = W1 * b[1] + W7 * b[7];\n\n    a7 = W7 * b[1] - W1 * b[7];\n\n    a5 = W5 * b[5] + W3 * b[3];\n\n    a3 = W3 * b[5] - W5 * b[3];\n\n    a2 = W2 * b[2] + W6 * b[6];\n\n    a6 = W6 * b[2] - W2 * b[6];\n\n    a0 = W0 * b[0] + W0 * b[4];\n\n    a4 = W0 * b[0] - W0 * b[4];\n\n\n\n    \/* step 2 *\/\n\n    s1 = (181 * (a1 - a5 + a7 - a3) + 128) >> 8; \/\/ 1, 3, 5, 7\n\n    s2 = (181 * (a1 - a5 - a7 + a3) + 128) >> 8;\n\n\n\n    \/* step 3 *\/\n\n    b[0] = (a0 + a2 + a1 + a5 + (1 << 7)) >> 8;\n\n    b[1] = (a4 + a6 + s1      + (1 << 7)) >> 8;\n\n    b[2] = (a4 - a6 + s2      + (1 << 7)) >> 8;\n\n    b[3] = (a0 - a2 + a7 + a3 + (1 << 7)) >> 8;\n\n    b[4] = (a0 - a2 - a7 - a3 + (1 << 7)) >> 8;\n\n    b[5] = (a4 - a6 - s2      + (1 << 7)) >> 8;\n\n    b[6] = (a4 + a6 - s1      + (1 << 7)) >> 8;\n\n    b[7] = (a0 + a2 - a1 - a5 + (1 << 7)) >> 8;\n\n}\n","target":1,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":356745,"func":"static int jpc_encrawrefpass(jpc_bitstream_t *out, int bitpos, int vcausalflag, jas_matrix_t *flags,\n  jas_matrix_t *data, int term, long *nmsedec)\n{\n\tint i;\n\tint j;\n\tint k;\n\tint one;\n\tint vscanlen;\n\tint width;\n\tint height;\n\tint frowstep;\n\tint drowstep;\n\tint fstripestep;\n\tint dstripestep;\n\tjpc_fix_t *fstripestart;\n\tjpc_fix_t *dstripestart;\n\tjpc_fix_t *fvscanstart;\n\tjpc_fix_t *dvscanstart;\n\tjpc_fix_t *dp;\n\tjpc_fix_t *fp;\n\n\t*nmsedec = 0;\n\twidth = jas_matrix_numcols(data);\n\theight = jas_matrix_numrows(data);\n\tfrowstep = jas_matrix_rowstep(flags);\n\tdrowstep = jas_matrix_rowstep(data);\n\tfstripestep = frowstep << 2;\n\tdstripestep = drowstep << 2;\n\n\tone = 1 << (bitpos + JPC_NUMEXTRABITS);\n\n\tfstripestart = jas_matrix_getref(flags, 1, 1);\n\tdstripestart = jas_matrix_getref(data, 0, 0);\n\tfor (i = height; i > 0; i -= 4, fstripestart += fstripestep,\n\t  dstripestart += dstripestep) {\n\t\tfvscanstart = fstripestart;\n\t\tdvscanstart = dstripestart;\n\t\tvscanlen = JAS_MIN(i, 4);\n\t\tfor (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {\n\t\t\tfp = fvscanstart;\n\t\t\tdp = dvscanstart;\n\t\t\tk = vscanlen;\n\n\t\t\trawrefpass_step(fp, dp, bitpos, one, nmsedec,\n\t\t\t  out, vcausalflag);\n\t\t\tif (--k <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfp += frowstep;\n\t\t\tdp += drowstep;\n\t\t\trawrefpass_step(fp, dp, bitpos, one, nmsedec,\n\t\t\t  out, vcausalflag);\n\t\t\tif (--k <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfp += frowstep;\n\t\t\tdp += drowstep;\n\t\t\trawrefpass_step(fp, dp, bitpos, one, nmsedec,\n\t\t\t  out, vcausalflag);\n\t\t\tif (--k <= 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfp += frowstep;\n\t\t\tdp += drowstep;\n\t\t\trawrefpass_step(fp, dp, bitpos, one, nmsedec,\n\t\t\t  out, vcausalflag);\n\n\t\t}\n\t}\n\n\tif (term) {\n\t\tjpc_bitstream_outalign(out, 0x2a);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":316506,"func":"void ide_exec_cmd(IDEBus *bus, uint32_t val)\n{\n    IDEState *s;\n    bool complete;\n\n#if defined(DEBUG_IDE)\n    printf(\"ide: CMD=%02x\\n\", val);\n#endif\n    s = idebus_active_if(bus);\n    \/* ignore commands to non existent slave *\/\n    if (s != bus->ifs && !s->blk) {\n        return;\n    }\n\n    \/* Only DEVICE RESET is allowed while BSY or\/and DRQ are set *\/\n    if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)\n        return;\n\n    if (!ide_cmd_permitted(s, val)) {\n        ide_abort_command(s);\n        ide_set_irq(s->bus);\n        return;\n    }\n\n    s->status = READY_STAT | BUSY_STAT;\n    s->error = 0;\n    s->io_buffer_offset = 0;\n\n    complete = ide_cmd_table[val].handler(s, val);\n    if (complete) {\n        s->status &= ~BUSY_STAT;\n        assert(!!s->error == !!(s->status & ERR_STAT));\n\n        if ((ide_cmd_table[val].flags & SET_DSC) && !s->error) {\n            s->status |= SEEK_STAT;\n        }\n\n        ide_cmd_done(s);\n        ide_set_irq(s->bus);\n    }\n}\n","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":356146,"func":"generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov,\n\t\tunsigned long *nr_segs, loff_t pos, loff_t *ppos,\n\t\tsize_t count, size_t ocount)\n{\n\tstruct file\t*file = iocb->ki_filp;\n\tstruct address_space *mapping = file->f_mapping;\n\tstruct inode\t*inode = mapping->host;\n\tssize_t\t\twritten;\n\tsize_t\t\twrite_len;\n\tpgoff_t\t\tend;\n\n\tif (count != ocount)\n\t\t*nr_segs = iov_shorten((struct iovec *)iov, *nr_segs, count);\n\n\t\/*\n\t * Unmap all mmappings of the file up-front.\n\t *\n\t * This will cause any pte dirty bits to be propagated into the\n\t * pageframes for the subsequent filemap_write_and_wait().\n\t *\/\n\twrite_len = iov_length(iov, *nr_segs);\n\tend = (pos + write_len - 1) >> PAGE_CACHE_SHIFT;\n\tif (mapping_mapped(mapping))\n\t\tunmap_mapping_range(mapping, pos, write_len, 0);\n\n\twritten = filemap_write_and_wait(mapping);\n\tif (written)\n\t\tgoto out;\n\n\t\/*\n\t * After a write we want buffered reads to be sure to go to disk to get\n\t * the new data.  We invalidate clean cached page from the region we're\n\t * about to write.  We do this *before* the write so that we can return\n\t * -EIO without clobbering -EIOCBQUEUED from ->direct_IO().\n\t *\/\n\tif (mapping->nrpages) {\n\t\twritten = invalidate_inode_pages2_range(mapping,\n\t\t\t\t\tpos >> PAGE_CACHE_SHIFT, end);\n\t\tif (written)\n\t\t\tgoto out;\n\t}\n\n\twritten = mapping->a_ops->direct_IO(WRITE, iocb, iov, pos, *nr_segs);\n\n\t\/*\n\t * Finally, try again to invalidate clean pages which might have been\n\t * cached by non-direct readahead, or faulted in by get_user_pages()\n\t * if the source of the write was an mmap'ed region of the file\n\t * we're writing.  Either one is a pretty crazy thing to do,\n\t * so we don't support it 100%.  If this invalidation\n\t * fails, tough, the write still worked...\n\t *\/\n\tif (mapping->nrpages) {\n\t\tinvalidate_inode_pages2_range(mapping,\n\t\t\t\t\t      pos >> PAGE_CACHE_SHIFT, end);\n\t}\n\n\tif (written > 0) {\n\t\tloff_t end = pos + written;\n\t\tif (end > i_size_read(inode) && !S_ISBLK(inode->i_mode)) {\n\t\t\ti_size_write(inode,  end);\n\t\t\tmark_inode_dirty(inode);\n\t\t}\n\t\t*ppos = end;\n\t}\n\n\t\/*\n\t * Sync the fs metadata but not the minor inode changes and\n\t * of course not the data as we did direct DMA for the IO.\n\t * i_mutex is held, which protects generic_osync_inode() from\n\t * livelocking.  AIO O_DIRECT ops attempt to sync metadata here.\n\t *\/\nout:\n\tif ((written >= 0 || written == -EIOCBQUEUED) &&\n\t    ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {\n\t\tint err = generic_osync_inode(inode, mapping, OSYNC_METADATA);\n\t\tif (err < 0)\n\t\t\twritten = err;\n\t}\n\treturn written;\n}","target":0,"code_token_length":739,"total_token_length":975,"max_tokens_setting":1024}
+{"idx":381978,"func":"bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,\n                  char const *trans, char gc1, char gc2,\n                  unsigned char const *d1, kwset_t kwset)\n{\n  char const *tp = *tpp;\n  int d = len, skip = 0;\n\n  while (true)\n    {\n      int i = 2;\n      if (tr (trans, tp[-2]) == gc2)\n        {\n          while (++i <= d)\n            if (tr (trans, tp[-i]) != tr (trans, sp[-i]))\n              break;\n          if (i > d)\n            {\n              for (i = d + skip + 1; i <= len; ++i)\n                if (tr (trans, tp[-i]) != tr (trans, sp[-i]))\n                  break;\n              if (i > len)\n                {\n                  *tpp = tp - len;\n                  return true;\n                }\n            }\n        }\n\n      tp += d = kwset->shift[i - 2];\n      if (tp > ep)\n        break;\n      if (tr (trans, tp[-1]) != gc1)\n        {\n          if (d1)\n            tp += d1[U(tp[-1])];\n          break;\n        }\n      skip = i - 1;\n    }\n\n  *tpp = tp;\n  return false;\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":324168,"func":"static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {\n\n    ByteIOContext *pb = s->pb;\n\n    pkt_type_t pkt_type;\n\n    int pkt_len;\n\n    while (!url_feof(pb)) {\n\n        int track_type, track_id, ret;\n\n        int field_nr;\n\n        if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {\n\n            if (!url_feof(pb))\n\n                av_log(s, AV_LOG_ERROR, \"GXF: sync lost\\n\");\n\n            return -1;\n\n        }\n\n        if (pkt_type == PKT_FLT) {\n\n            gxf_read_index(s, pkt_len);\n\n            continue;\n\n        }\n\n        if (pkt_type != PKT_MEDIA) {\n\n            url_fskip(pb, pkt_len);\n\n            continue;\n\n        }\n\n        if (pkt_len < 16) {\n\n            av_log(s, AV_LOG_ERROR, \"GXF: invalid media packet length\\n\");\n\n            continue;\n\n        }\n\n        pkt_len -= 16;\n\n        track_type = get_byte(pb);\n\n        track_id = get_byte(pb);\n\n        field_nr = get_be32(pb);\n\n        get_be32(pb); \/\/ field information\n\n        get_be32(pb); \/\/ \"timeline\" field number\n\n        get_byte(pb); \/\/ flags\n\n        get_byte(pb); \/\/ reserved\n\n        \/\/ NOTE: there is also data length information in the\n\n        \/\/ field information, it might be better to take this into account\n\n        \/\/ as well.\n\n        ret = av_get_packet(pb, pkt, pkt_len);\n\n        pkt->stream_index = get_sindex(s, track_id, track_type);\n\n        pkt->dts = field_nr;\n\n        return ret;\n\n    }\n\n    return AVERROR(EIO);\n\n}\n","target":1,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":146895,"func":"static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)\n{\n    const char *errmsg;\n    const char *endp = ap_strrchr_c(arg, '>');\n    int old_overrides = cmd->override;\n    char *old_path = cmd->path;\n    core_dir_config *conf;\n    ap_regex_t *r = NULL;\n    const command_rec *thiscmd = cmd->cmd;\n    ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool);\n    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);\n    if (err != NULL) {\n        return err;\n    }\n\n    if (endp == NULL) {\n        return unclosed_directive(cmd);\n    }\n\n    arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);\n\n    if (!arg[0]) {\n        return missing_container_arg(cmd);\n    }\n\n    cmd->path = ap_getword_conf(cmd->pool, &arg);\n    cmd->override = OR_ALL|ACCESS_CONF;\n\n    if (thiscmd->cmd_data) { \/*  *\/\n        r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);\n        if (!r) {\n            return \"Regex could not be compiled\";\n        }\n    }\n    else if (!strcmp(cmd->path, \"~\")) {\n        cmd->path = ap_getword_conf(cmd->pool, &arg);\n        r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);\n        if (!r) {\n            return \"Regex could not be compiled\";\n        }\n    }\n\n    \/* initialize our config and fetch it *\/\n    conf = ap_set_config_vectors(cmd->server, new_url_conf, cmd->path,\n                                 &core_module, cmd->pool);\n\n    errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf);\n    if (errmsg != NULL)\n        return errmsg;\n\n    conf->d = apr_pstrdup(cmd->pool, cmd->path);     \/* No mangling, please *\/\n    conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;\n    conf->r = r;\n\n    if (r) {\n        conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));\n        ap_regname(r, conf->refs, AP_REG_MATCH, 1);\n    }\n\n    ap_add_per_url_conf(cmd->server, new_url_conf);\n\n    if (*arg != '\\0') {\n        return apr_pstrcat(cmd->pool, \"Multiple \", thiscmd->name,\n                           \"> arguments not (yet) supported.\", NULL);\n    }\n\n    cmd->path = old_path;\n    cmd->override = old_overrides;\n\n    return NULL;\n}","target":0,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":415284,"func":"real_new_secrets (NMVpnServicePlugin *plugin,\n                  NMConnection *connection,\n                  GError **error)\n{\n\tNMVPNCPluginPrivate *priv = NM_VPNC_PLUGIN_GET_PRIVATE (plugin);\n\tNMSettingVpn *s_vpn;\n\tconst char *secret;\n\n\tif (!interactive_available || !priv->interactive) {\n\t\tg_set_error_literal (error,\n\t\t                     NM_VPN_PLUGIN_ERROR,\n\t\t                     NM_VPN_PLUGIN_ERROR_FAILED,\n\t\t                     _(\"Could not use new secrets as interactive mode is disabled.\"));\n\t\treturn FALSE;\n\t}\n\n\ts_vpn = nm_connection_get_setting_vpn (connection);\n\tif (!s_vpn) {\n\t\tg_set_error_literal (error,\n\t\t                     NM_VPN_PLUGIN_ERROR,\n\t\t                     NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,\n\t\t                     _(\"Could not process the request because the VPN connection settings were invalid.\"));\n\t\treturn FALSE;\n\t}\n\n\tif (!priv->pending_auth) {\n\t\tg_set_error_literal (error,\n\t\t                     NM_VPN_PLUGIN_ERROR,\n\t\t                     NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,\n\t\t                     _(\"Could not process the request because no pending authentication is required.\"));\n\t\treturn FALSE;\n\t}\n\n\t_LOGD (\"VPN received new secrets; sending to '%s' vpnc stdin\", priv->pending_auth);\n\n\tsecret = nm_setting_vpn_get_secret (s_vpn, priv->pending_auth);\n\tif (!secret) {\n\t\tg_set_error (error,\n\t\t             NM_VPN_PLUGIN_ERROR,\n\t\t             NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,\n\t\t             _(\"Could not process the request because the requested info \u201c%s\u201d was not provided.\"),\n\t\t             priv->pending_auth);\n\t\treturn FALSE;\n\t}\n\n\t\/* Ignoring secret flags here; if vpnc requested the item, we must provide it *\/\n\twrite_config_option (priv->infd, \"%s\", secret);\n\n\tpriv->pending_auth = NULL;\n\treturn TRUE;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":393969,"func":"static int sched_copy_attr(struct sched_attr __user *uattr,\n\t\t\t   struct sched_attr *attr)\n{\n\tu32 size;\n\tint ret;\n\n\tif (!access_ok(VERIFY_WRITE, uattr, SCHED_ATTR_SIZE_VER0))\n\t\treturn -EFAULT;\n\n\t\/*\n\t * zero the full structure, so that a short copy will be nice.\n\t *\/\n\tmemset(attr, 0, sizeof(*attr));\n\n\tret = get_user(size, &uattr->size);\n\tif (ret)\n\t\treturn ret;\n\n\tif (size > PAGE_SIZE)\t\/* silly large *\/\n\t\tgoto err_size;\n\n\tif (!size)\t\t\/* abi compat *\/\n\t\tsize = SCHED_ATTR_SIZE_VER0;\n\n\tif (size < SCHED_ATTR_SIZE_VER0)\n\t\tgoto err_size;\n\n\t\/*\n\t * If we're handed a bigger struct than we know of,\n\t * ensure all the unknown bits are 0 - i.e. new\n\t * user-space does not rely on any kernel feature\n\t * extensions we dont know about yet.\n\t *\/\n\tif (size > sizeof(*attr)) {\n\t\tunsigned char __user *addr;\n\t\tunsigned char __user *end;\n\t\tunsigned char val;\n\n\t\taddr = (void __user *)uattr + sizeof(*attr);\n\t\tend  = (void __user *)uattr + size;\n\n\t\tfor (; addr < end; addr++) {\n\t\t\tret = get_user(val, addr);\n\t\t\tif (ret)\n\t\t\t\treturn ret;\n\t\t\tif (val)\n\t\t\t\tgoto err_size;\n\t\t}\n\t\tsize = sizeof(*attr);\n\t}\n\n\tret = copy_from_user(attr, uattr, size);\n\tif (ret)\n\t\treturn -EFAULT;\n\n\t\/*\n\t * XXX: do we want to be lenient like existing syscalls; or do we want\n\t * to be strict and return an error on out-of-bounds values?\n\t *\/\n\tattr->sched_nice = clamp(attr->sched_nice, MIN_NICE, MAX_NICE);\n\n\treturn 0;\n\nerr_size:\n\tput_user(sizeof(*attr), &uattr->size);\n\treturn -E2BIG;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":152753,"func":"inline size_t PrecedenceClimbing::parse_expression(const char *s, size_t n,\n                                                   SemanticValues &sv,\n                                                   Context &c, any &dt,\n                                                   size_t min_prec) const {\n  auto len = atom_->parse(s, n, sv, c, dt);\n  if (fail(len)) { return len; }\n\n  std::string tok;\n  auto &rule = get_reference_for_binop(c);\n  auto action = rule.action;\n\n  rule.action = [&](SemanticValues &sv2, any &dt2) -> any {\n    tok = sv2.token();\n    if (action) {\n      return action(sv2, dt2);\n    } else if (!sv2.empty()) {\n      return sv2[0];\n    }\n    return any();\n  };\n  auto action_se = make_scope_exit([&]() { rule.action = action; });\n\n  auto save_error_pos = c.error_pos;\n\n  auto i = len;\n  while (i < n) {\n    std::vector save_values(sv.begin(), sv.end());\n    auto save_tokens = sv.tokens;\n\n    auto chv = c.push();\n    auto chl = binop_->parse(s + i, n - i, chv, c, dt);\n    c.pop();\n\n    if (fail(chl)) {\n      c.error_pos = save_error_pos;\n      break;\n    }\n\n    auto it = info_.find(tok);\n    if (it == info_.end()) { break; }\n\n    auto level = std::get<0>(it->second);\n    auto assoc = std::get<1>(it->second);\n\n    if (level < min_prec) { break; }\n\n    sv.emplace_back(std::move(chv[0]));\n    i += chl;\n\n    auto next_min_prec = level;\n    if (assoc == 'L') { next_min_prec = level + 1; }\n\n    chv = c.push();\n    chl = parse_expression(s + i, n - i, chv, c, dt, next_min_prec);\n    c.pop();\n\n    if (fail(chl)) {\n      sv.assign(save_values.begin(), save_values.end());\n      sv.tokens = save_tokens;\n      c.error_pos = save_error_pos;\n      break;\n    }\n\n    sv.emplace_back(std::move(chv[0]));\n    i += chl;\n\n    any val;\n    if (rule_.action) {\n      sv.s_ = s;\n      sv.n_ = i;\n      val = rule_.action(sv, dt);\n    } else if (!sv.empty()) {\n      val = sv[0];\n    }\n    sv.clear();\n    sv.emplace_back(std::move(val));\n  }\n\n  return i;\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":427719,"func":"static void rtreeCheckNode(\n  RtreeCheck *pCheck,\n  int iDepth,                     \/* Depth of iNode (0==leaf) *\/\n  u8 *aParent,                    \/* Buffer containing parent coords *\/\n  i64 iNode                       \/* Node to check *\/\n){\n  u8 *aNode = 0;\n  int nNode = 0;\n\n  assert( iNode==1 || aParent!=0 );\n  assert( pCheck->nDim>0 );\n\n  aNode = rtreeCheckGetNode(pCheck, iNode, &nNode);\n  if( aNode ){\n    if( nNode<4 ){\n      rtreeCheckAppendMsg(pCheck, \n          \"Node %lld is too small (%d bytes)\", iNode, nNode\n      );\n    }else{\n      int nCell;                  \/* Number of cells on page *\/\n      int i;                      \/* Used to iterate through cells *\/\n      if( aParent==0 ){\n        iDepth = readInt16(aNode);\n        if( iDepth>RTREE_MAX_DEPTH ){\n          rtreeCheckAppendMsg(pCheck, \"Rtree depth out of range (%d)\", iDepth);\n          sqlite3_free(aNode);\n          return;\n        }\n      }\n      nCell = readInt16(&aNode[2]);\n      if( (4 + nCell*(8 + pCheck->nDim*2*4))>nNode ){\n        rtreeCheckAppendMsg(pCheck, \n            \"Node %lld is too small for cell count of %d (%d bytes)\", \n            iNode, nCell, nNode\n        );\n      }else{\n        for(i=0; inDim*2*4)];\n          i64 iVal = readInt64(pCell);\n          rtreeCheckCellCoord(pCheck, iNode, i, &pCell[8], aParent);\n\n          if( iDepth>0 ){\n            rtreeCheckMapping(pCheck, 0, iVal, iNode);\n            rtreeCheckNode(pCheck, iDepth-1, &pCell[8], iVal);\n            pCheck->nNonLeaf++;\n          }else{\n            rtreeCheckMapping(pCheck, 1, iVal, iNode);\n            pCheck->nLeaf++;\n          }\n        }\n      }\n    }\n    sqlite3_free(aNode);\n  }\n}","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":275429,"func":"BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)\n{\n\tint    width, height;\n\tuint8_t   *filedata = NULL;\n\tuint8_t    *argb = NULL;\n\tunsigned char   *read, *temp;\n\tsize_t size = 0, n;\n\tgdImagePtr im;\n\tint x, y;\n\tuint8_t *p;\n\n\tdo {\n\t\ttemp = gdRealloc(filedata, size+GD_WEBP_ALLOC_STEP);\n\t\tif (temp) {\n\t\t\tfiledata = temp;\n\t\t\tread = temp + size;\n\t\t} else {\n\t\t\tif (filedata) {\n\t\t\t\tgdFree(filedata);\n\t\t\t}\n\t\t\tgd_error(\"WebP decode: realloc failed\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tn = gdGetBuf(read, GD_WEBP_ALLOC_STEP, infile);\n\t\tif (n>0 && n!=EOF) {\n\t\t\tsize += n;\n\t\t}\n\t} while (n>0 && n!=EOF);\n\n\tif (WebPGetInfo(filedata,size, &width, &height) == 0) {\n\t\tgd_error(\"gd-webp cannot get webp info\");\n\t\tgdFree(temp);\n\t\treturn NULL;\n\t}\n\n\tim = gdImageCreateTrueColor(width, height);\n\tif (!im) {\n\t\tgdFree(temp);\n\t\treturn NULL;\n\t}\n\targb = WebPDecodeARGB(filedata, size, &width, &height);\n\tif (!argb) {\n\t\tgd_error(\"gd-webp cannot allocate temporary buffer\");\n\t\tgdFree(temp);\n\t\tgdImageDestroy(im);\n\t\treturn NULL;\n\t}\n\tfor (y = 0, p = argb;  y < height; y++) {\n\t\tfor (x = 0; x < width; x++) {\n\t\t\tregister uint8_t a = gdAlphaMax - (*(p++) >> 1);\n\t\t\tregister uint8_t r = *(p++);\n\t\t\tregister uint8_t g = *(p++);\n\t\t\tregister uint8_t b = *(p++);\n\t\t\tim->tpixels[y][x] = gdTrueColorAlpha(r, g, b, a);\n\t\t}\n\t}\n\t\/* do not use gdFree here, in case gdFree\/alloc is mapped to something else than libc *\/\n\tfree(argb);\n\tgdFree(temp);\n\tim->saveAlphaFlag = 1;\n\treturn im;\n}\n","target":0,"code_token_length":498,"total_token_length":734,"max_tokens_setting":1024}
+{"idx":59076,"func":"static ssize_t clear_refs_write(struct file *file, const char __user *buf,\n\t\t\t\tsize_t count, loff_t *ppos)\n{\n\tstruct task_struct *task;\n\tchar buffer[PROC_NUMBUF];\n\tstruct mm_struct *mm;\n\tstruct vm_area_struct *vma;\n\tlong type;\n\n\tmemset(buffer, 0, sizeof(buffer));\n\tif (count > sizeof(buffer) - 1)\n\t\tcount = sizeof(buffer) - 1;\n\tif (copy_from_user(buffer, buf, count))\n\t\treturn -EFAULT;\n\tif (strict_strtol(strstrip(buffer), 10, &type))\n\t\treturn -EINVAL;\n\tif (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)\n\t\treturn -EINVAL;\n\ttask = get_proc_task(file->f_path.dentry->d_inode);\n\tif (!task)\n\t\treturn -ESRCH;\n\tmm = get_task_mm(task);\n\tif (mm) {\n\t\tstruct mm_walk clear_refs_walk = {\n\t\t\t.pmd_entry = clear_refs_pte_range,\n\t\t\t.mm = mm,\n\t\t};\n\t\tdown_read(&mm->mmap_sem);\n\t\tfor (vma = mm->mmap; vma; vma = vma->vm_next) {\n\t\t\tclear_refs_walk.private = vma;\n\t\t\tif (is_vm_hugetlb_page(vma))\n\t\t\t\tcontinue;\n\t\t\t\/*\n\t\t\t * Writing 1 to \/proc\/pid\/clear_refs affects all pages.\n\t\t\t *\n\t\t\t * Writing 2 to \/proc\/pid\/clear_refs only affects\n\t\t\t * Anonymous pages.\n\t\t\t *\n\t\t\t * Writing 3 to \/proc\/pid\/clear_refs only affects file\n\t\t\t * mapped pages.\n\t\t\t *\/\n\t\t\tif (type == CLEAR_REFS_ANON && vma->vm_file)\n\t\t\t\tcontinue;\n\t\t\tif (type == CLEAR_REFS_MAPPED && !vma->vm_file)\n\t\t\t\tcontinue;\n\t\t\twalk_page_range(vma->vm_start, vma->vm_end,\n\t\t\t\t\t&clear_refs_walk);\n\t\t}\n\t\tflush_tlb_mm(mm);\n\t\tup_read(&mm->mmap_sem);\n\t\tmmput(mm);\n\t}\n\tput_task_struct(task);\n\n\treturn count;\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":281046,"func":"SAPI_API void sapi_activate(TSRMLS_D)\n{\n\tzend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);\n\tSG(sapi_headers).send_default_content_type = 1;\n\n\t\/*\n\tSG(sapi_headers).http_response_code = 200;\n\t*\/\n\tSG(sapi_headers).http_status_line = NULL;\n\tSG(sapi_headers).mimetype = NULL;\n\tSG(headers_sent) = 0;\n\tSG(callback_run) = 0;\n\tSG(callback_func) = NULL;\n\tSG(read_post_bytes) = 0;\n\tSG(request_info).post_data = NULL;\n\tSG(request_info).raw_post_data = NULL;\n\tSG(request_info).current_user = NULL;\n\tSG(request_info).current_user_length = 0;\n\tSG(request_info).no_headers = 0;\n\tSG(request_info).post_entry = NULL;\n\tSG(request_info).proto_num = 1000; \/* Default to HTTP 1.0 *\/\n\tSG(global_request_time) = 0;\n\n\t\/* It's possible to override this general case in the activate() callback, if necessary. *\/\n\tif (SG(request_info).request_method && !strcmp(SG(request_info).request_method, \"HEAD\")) {\n\t\tSG(request_info).headers_only = 1;\n\t} else {\n\t\tSG(request_info).headers_only = 0;\n\t}\n\tSG(rfc1867_uploaded_files) = NULL;\n\n\t\/* Handle request method *\/\n\tif (SG(server_context)) {\n\t\tif (PG(enable_post_data_reading) && SG(request_info).request_method) {\n\t\t\tif (SG(request_info).content_type && !strcmp(SG(request_info).request_method, \"POST\")) {\n\t\t\t\t\/* HTTP POST may contain form data to be processed into variables\n\t\t\t\t * depending on given content type *\/\n\t\t\t\tsapi_read_post_data(TSRMLS_C);\n\t\t\t} else {\n\t\t\t\t\/* Any other method with content payload will fill $HTTP_RAW_POST_DATA \n\t\t\t\t * if it is enabled by always_populate_raw_post_data. \n\t\t\t\t * It's up to the webserver to decide whether to allow a method or not. *\/\n\t\t\t\tSG(request_info).content_type_dup = NULL;\n\t\t\t\tif (sapi_module.default_post_reader) {\n\t\t\t\t\tsapi_module.default_post_reader(TSRMLS_C);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tSG(request_info).content_type_dup = NULL;\n\t\t}\n\n\t\t\/* Cookies *\/\n\t\tSG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);\n\n\t\tif (sapi_module.activate) {\n\t\t\tsapi_module.activate(TSRMLS_C);\n\t\t}\n\t}\n\tif (sapi_module.input_filter_init) {\n\t\tsapi_module.input_filter_init(TSRMLS_C);\n\t}\n}\n","target":0,"code_token_length":598,"total_token_length":834,"max_tokens_setting":1024}
+{"idx":10214,"func":"image_transform_mod_end(PNG_CONST image_transform *this, image_pixel *that,\n    png_const_structp pp, PNG_CONST transform_display *display)\n {\n   PNG_CONST unsigned int scale = (1U<sample_depth)-1;\n \n    UNUSED(this)\n    UNUSED(pp)\n   UNUSED(display)\n\n \/* At the end recalculate the digitized red green and blue values according\n    * to the current sample_depth of the pixel.\n    *\n    * The sample value is simply scaled to the maximum, checking for over\n    * and underflow (which can both happen for some image transforms,\n    * including simple size scaling, though libpng doesn't do that at present.\n\n     *\/\n    that->red = sample_scale(that->redf, scale);\n \n    \/* The error value is increased, at the end, according to the lowest sBIT\n     * value seen.  Common sense tells us that the intermediate integer\n     * representations are no more accurate than +\/- 0.5 in the integral values,\n    * the sBIT allows the implementation to be worse than this.  In addition the\n    * PNG specification actually permits any error within the range (-1..+1),\n    * but that is ignored here.  Instead the final digitized value is compared,\n    * below to the digitized value of the error limits - this has the net effect\n    * of allowing (almost) +\/-1 in the output value.  It's difficult to see how\n    * any algorithm that digitizes intermediate results can be more accurate.\n    *\/\n   that->rede += 1.\/(2*((1U<red_sBIT)-1));\n\n\n    if (that->colour_type & PNG_COLOR_MASK_COLOR)\n    {\n       that->green = sample_scale(that->greenf, scale);\n       that->blue = sample_scale(that->bluef, scale);\n       that->greene += 1.\/(2*((1U<green_sBIT)-1));\n       that->bluee += 1.\/(2*((1U<blue_sBIT)-1));\n    }\n else\n {\n      that->blue = that->green = that->red;\n      that->bluef = that->greenf = that->redf;\n      that->bluee = that->greene = that->rede;\n }\n\n if ((that->colour_type & PNG_COLOR_MASK_ALPHA) ||\n      that->colour_type == PNG_COLOR_TYPE_PALETTE)\n {\n      that->alpha = sample_scale(that->alphaf, scale);\n      that->alphae += 1.\/(2*((1U<alpha_sBIT)-1));\n }\n\n    else\n    {\n       that->alpha = scale; \/* opaque *\/\n      that->alpha = 1;     \/* Override this. *\/\n       that->alphae = 0;    \/* It's exact ;-) *\/\n    }\n }\n","target":1,"code_token_length":589,"total_token_length":825,"max_tokens_setting":1024}
+{"idx":15248,"func":"static int nextch ( IO * wrapper ) {\n int ch ;\n _IO * io = wrapper -> top ;\n static const char * foguvec [ ] = {\n \"moveto \" , \"rlineto \" , \"rrcurveto \" , \" \" , \" \" , \"Cache \" , \"10 div setlinewidth \" , \"ShowInt \" , \" \" , \" \" , \" \" , \" \" , \"FillStroke \" , \" \" , \" \" , \"SetWid \" , \"100 mul add \" , \"togNS_ \" , \" \" , \"closepath \" , \" \" , \"SG \" }\n ;\n while ( io != NULL ) {\n if ( io -> backedup != EOF ) {\n ch = io -> backedup ;\n io -> backedup = EOF ;\n return ( ch ) ;\n }\n else if ( io -> ps != NULL ) {\n if ( ( ch = getc ( io -> ps ) ) != EOF ) return ( ch ) ;\n }\n else if ( io -> fog != NULL ) {\n if ( io -> macro != NULL && * io -> macro != '\\0' ) return ( * ( io -> macro ++ ) ) ;\n ch = getfoghex ( io ) ;\n if ( ch >= 233 ) {\n io -> macro = foguvec [ ch - 233 ] ;\n return ( * ( io -> macro ++ ) ) ;\n }\n else if ( ch != EOF && ch < 200 ) {\n sprintf ( io -> fogbuf , \"%d \" , ch - 100 ) ;\n io -> macro = io -> fogbuf ;\n return ( * ( io -> macro ++ ) ) ;\n }\n else if ( ch != EOF ) {\n sprintf ( io -> fogbuf , \"%d %s \" , ch - 233 + 17 , io -> fogns ? \"2 exch exp 3 1 roll 100 mul add mul\" : \"100 mul add\" ) ;\n io -> macro = io -> fogbuf ;\n return ( * ( io -> macro ++ ) ) ;\n }\n }\n else {\n if ( ( ch = * ( io -> macro ++ ) ) != '\\0' ) return ( ch ) ;\n if ( -- io -> cnt > 0 ) {\n io -> macro = io -> start ;\n return ( nextch ( wrapper ) ) ;\n }\n }\n wrapper -> top = io -> prev ;\n if ( io -> isstopped ) wrapper -> endedstopped = true ;\n if ( io -> start != NULL ) free ( io -> start ) ;\n io -> start = NULL ;\n free ( io ) ;\n io = wrapper -> top ;\n }\n return ( EOF ) ;\n }","target":0,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":280429,"func":"void ProcessCommitResponseCommand::ProcessCommitResponse(\n    SyncSession* session) {\n  ScopedDirLookup dir(session->context()->directory_manager(),\n                      session->context()->account_name());\n  if (!dir.good()) {\n    LOG(ERROR) << \"Scoped dir lookup failed!\";\n    return;\n  }\n\n  StatusController* status = session->status_controller();\n  const ClientToServerResponse& response(status->commit_response());\n  const CommitResponse& cr = response.commit();\n  const sync_pb::CommitMessage& commit_message =\n      status->commit_message().commit();\n\n  int transient_error_commits = 0;\n  int conflicting_commits = 0;\n  int error_commits = 0;\n  int successes = 0;\n  set conflicting_new_folder_ids;\n  set deleted_folders;\n  ConflictProgress* conflict_progress = status->mutable_conflict_progress();\n  OrderedCommitSet::Projection proj = status->commit_id_projection();\n  if (!proj.empty()) { \/\/ Scope for WriteTransaction.\n    WriteTransaction trans(FROM_HERE, SYNCER, dir);\n    for (size_t i = 0; i < proj.size(); i++) {\n      CommitResponse::ResponseType response_type =\n          ProcessSingleCommitResponse(&trans, cr.entryresponse(proj[i]),\n                                      commit_message.entries(proj[i]),\n                                      status->GetCommitIdAt(proj[i]),\n                                      &conflicting_new_folder_ids,\n                                      &deleted_folders);\n      switch (response_type) {\n        case CommitResponse::INVALID_MESSAGE:\n          ++error_commits;\n          break;\n        case CommitResponse::CONFLICT:\n          ++conflicting_commits;\n          conflict_progress->AddConflictingItemById(\n              status->GetCommitIdAt(proj[i]));\n          break;\n        case CommitResponse::SUCCESS:\n          ++successes;\n          if (status->GetCommitIdModelTypeAt(proj[i]) == syncable::BOOKMARKS)\n            status->increment_num_successful_bookmark_commits();\n          status->increment_num_successful_commits();\n          break;\n        case CommitResponse::OVER_QUOTA:\n        case CommitResponse::RETRY:\n        case CommitResponse::TRANSIENT_ERROR:\n          ++transient_error_commits;\n          break;\n        default:\n          LOG(FATAL) << \"Bad return from ProcessSingleCommitResponse\";\n      }\n    }\n  }\n\n  status->increment_num_conflicting_commits_by(conflicting_commits);\n  if (0 == successes) {\n    status->increment_num_consecutive_transient_error_commits_by(\n        transient_error_commits);\n    status->increment_num_consecutive_errors_by(transient_error_commits);\n  } else {\n    status->set_num_consecutive_transient_error_commits(0);\n    status->set_num_consecutive_errors(0);\n  }\n  int commit_count = static_cast(proj.size());\n  if (commit_count != (conflicting_commits + error_commits +\n                       transient_error_commits)) {\n    ResetErrorCounters(status);\n  }\n  SyncerUtil::MarkDeletedChildrenSynced(dir, &deleted_folders);\n\n  return;\n}\n","target":0,"code_token_length":628,"total_token_length":864,"max_tokens_setting":1024}
+{"idx":390107,"func":"\nMYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)\n{\n  MYSQL_RES *result;\n  DBUG_ENTER(\"mysql_store_result\");\n\n  if (!mysql->fields)\n    DBUG_RETURN(0);\n  if (mysql->status != MYSQL_STATUS_GET_RESULT)\n  {\n    set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);\n    DBUG_RETURN(0);\n  }\n  mysql->status=MYSQL_STATUS_READY;\t\t\/* server is ready *\/\n  if (!(result=(MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+\n\t\t\t\t\t      sizeof(ulong) *\n\t\t\t\t\t      mysql->field_count),\n\t\t\t\t      MYF(MY_WME | MY_ZEROFILL))))\n  {\n    set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);\n    DBUG_RETURN(0);\n  }\n  result->methods= mysql->methods;\n  result->eof=1;\t\t\t\t\/* Marker for buffered *\/\n  result->lengths=(ulong*) (result+1);\n  if (!(result->data=\n\t(*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count)))\n  {\n    my_free(result);\n    DBUG_RETURN(0);\n  }\n  mysql->affected_rows= result->row_count= result->data->rows;\n  result->data_cursor=\tresult->data->data;\n  result->fields=\tmysql->fields;\n  result->field_alloc=\tmysql->field_alloc;\n  result->field_count=\tmysql->field_count;\n  \/* The rest of result members is bzeroed in malloc *\/\n  mysql->fields=0;\t\t\t\t\/* fields is now in result *\/\n  clear_alloc_root(&mysql->field_alloc);\n  \/* just in case this was mistakenly called after mysql_stmt_execute() *\/\n  mysql->unbuffered_fetch_owner= 0;\n  DBUG_RETURN(result);\t\t\t\t\/* Data fetched *\/","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":410939,"func":"sort_page_names (gconstpointer a,\n                 gconstpointer b)\n{\n\tconst char *name_1, *name_2;\n\tgchar *key_1, *key_2;\n\tgboolean sort_last_1, sort_last_2;\n\tint compare;\n\n\tname_1 = * (const char **) a;\n\tname_2 = * (const char **) b;\n\n\t#define SORT_LAST_CHAR1 '.'\n\t#define SORT_LAST_CHAR2 '#'\n\n\tsort_last_1 = name_1[0] == SORT_LAST_CHAR1 || name_1[0] == SORT_LAST_CHAR2;\n\tsort_last_2 = name_2[0] == SORT_LAST_CHAR1 || name_2[0] == SORT_LAST_CHAR2;\n\n\t#undef SORT_LAST_CHAR1\n\t#undef SORT_LAST_CHAR2\n\n\tif (sort_last_1 && !sort_last_2)\n\t{\n\t\tcompare = +1;\n\t}\n\telse if (!sort_last_1 && sort_last_2)\n\t{\n\t\tcompare = -1;\n\t} \n\telse\n\t{\n\t\tkey_1 = g_utf8_collate_key_for_filename (name_1, -1);\n\t\tkey_2 = g_utf8_collate_key_for_filename (name_2, -1);\n\n\t\tcompare = strcmp (key_1, key_2);\n\n\t\tg_free (key_1);\n\t\tg_free (key_2);\n\t}\n\n\treturn compare;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":438774,"func":"push_glob(VALUE ary, VALUE str, VALUE base, int flags)\n{\n    struct glob_args args;\n    int fd;\n    rb_encoding *enc = rb_enc_get(str);\n\n#if defined _WIN32 || defined __APPLE__\n    str = rb_str_encode_ospath(str);\n#endif\n    if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII)\n\tenc = rb_filesystem_encoding();\n    if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII)\n\tenc = rb_ascii8bit_encoding();\n    flags |= GLOB_VERBOSE;\n    args.func = push_pattern;\n    args.value = ary;\n    args.enc = enc;\n    args.base = 0;\n    fd = AT_FDCWD;\n    if (!NIL_P(base)) {\n\tif (!RB_TYPE_P(base, T_STRING) || !rb_enc_check(str, base)) {\n\t    struct dir_data *dirp = DATA_PTR(base);\n\t    if (!dirp->dir) dir_closed();\n#ifdef HAVE_DIRFD\n\t    if ((fd = dirfd(dirp->dir)) == -1)\n\t\trb_sys_fail_path(dir_inspect(base));\n#endif\n\t    base = dirp->path;\n\t}\n\targs.base = RSTRING_PTR(base);\n    }\n#if defined _WIN32 || defined __APPLE__\n    enc = rb_utf8_encoding();\n#endif\n\n    return ruby_glob0(RSTRING_PTR(str), fd, args.base, flags, &rb_glob_funcs,\n\t\t      (VALUE)&args, enc);\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":467166,"func":"int RGWHandler_REST_SWIFT::postauth_init()\n{\n  struct req_init_state* t = &s->init_state;\n\n  \/* XXX Stub this until Swift Auth sets account into URL. *\/\n  s->bucket_tenant = s->user->user_id.tenant;\n  s->bucket_name = t->url_bucket;\n\n  dout(10) << \"s->object=\" <<\n    (!s->object.empty() ? s->object : rgw_obj_key(\"\"))\n           << \" s->bucket=\"\n\t   << rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name)\n\t   << dendl;\n\n  int ret;\n  ret = rgw_validate_tenant_name(s->bucket_tenant);\n  if (ret)\n    return ret;\n  ret = validate_bucket_name(s->bucket_name);\n  if (ret)\n    return ret;\n  ret = validate_object_name(s->object.name);\n  if (ret)\n    return ret;\n\n  if (!t->src_bucket.empty()) {\n    \/*\n     * We don't allow cross-tenant copy at present. It requires account\n     * names in the URL for Swift.\n     *\/\n    s->src_tenant_name = s->user->user_id.tenant;\n    s->src_bucket_name = t->src_bucket;\n\n    ret = validate_bucket_name(s->src_bucket_name);\n    if (ret < 0) {\n      return ret;\n    }\n    ret = validate_object_name(s->src_object.name);\n    if (ret < 0) {\n      return ret;\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":395523,"func":"static void usage(void)\n{\n  DBUG_ENTER(\"usage\");\n  if (!(default_charset_info= get_charset_by_csname(default_character_set_name,\n\t\t\t\t\t           MY_CS_PRIMARY,\n\t\t\t\t\t\t   MYF(MY_WME))))\n    exit(1);\n  if (!default_collation_name)\n    default_collation_name= (char*) default_charset_info->name;\n  print_version();\n  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE(\"2000\"));\n  puts(\"Starts the MySQL database server.\\n\");\n  printf(\"Usage: %s [OPTIONS]\\n\", my_progname);\n  if (!opt_verbose)\n    puts(\"\\nFor more help options (several pages), use mysqld --verbose --help.\");\n  else\n  {\n#ifdef __WIN__\n  puts(\"NT and Win32 specific options:\\n\\\n  --install                     Install the default service (NT).\\n\\\n  --install-manual              Install the default service started manually (NT).\\n\\\n  --install service_name        Install an optional service (NT).\\n\\\n  --install-manual service_name Install an optional service started manually (NT).\\n\\\n  --remove                      Remove the default service from the service list (NT).\\n\\\n  --remove service_name         Remove the service_name from the service list (NT).\\n\\\n  --enable-named-pipe           Only to be used for the default server (NT).\\n\\\n  --standalone                  Dummy option to start as a standalone server (NT).\\\n\");\n  puts(\"\");\n#endif\n  print_defaults(MYSQL_CONFIG_NAME,load_default_groups);\n  puts(\"\");\n  set_ports();\n\n  \/* Print out all the options including plugin supplied options *\/\n  print_help();\n\n  if (! plugins_are_initialized)\n  {\n    puts(\"\\n\\\nPlugins have parameters that are not reflected in this list\\n\\\nbecause execution stopped before plugins were initialized.\");\n  }\n\n  puts(\"\\n\\\nTo see what values a running MySQL server is using, type\\n\\\n'mysqladmin variables' instead of 'mysqld --verbose --help'.\");\n  }\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":95920,"func":"static struct kvm_memslots *install_new_memslots(struct kvm *kvm,\n\t\tint as_id, struct kvm_memslots *slots)\n{\n\tstruct kvm_memslots *old_memslots = __kvm_memslots(kvm, as_id);\n\n\t\/*\n\t * Set the low bit in the generation, which disables SPTE caching\n\t * until the end of synchronize_srcu_expedited.\n\t *\/\n\tWARN_ON(old_memslots->generation & 1);\n\tslots->generation = old_memslots->generation + 1;\n\n\trcu_assign_pointer(kvm->memslots[as_id], slots);\n\tsynchronize_srcu_expedited(&kvm->srcu);\n\n\t\/*\n\t * Increment the new memslot generation a second time. This prevents\n\t * vm exits that race with memslot updates from caching a memslot\n\t * generation that will (potentially) be valid forever.\n\t *\n\t * Generations must be unique even across address spaces.  We do not need\n\t * a global counter for that, instead the generation space is evenly split\n\t * across address spaces.  For example, with two address spaces, address\n\t * space 0 will use generations 0, 4, 8, ... while * address space 1 will\n\t * use generations 2, 6, 10, 14, ...\n\t *\/\n\tslots->generation += KVM_ADDRESS_SPACE_NUM * 2 - 1;\n\n\tkvm_arch_memslots_updated(kvm, slots);\n\n\treturn old_memslots;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":5371,"func":"bool Unpack::ProcessDecoded(UnpackThreadData &D)\n{\n  UnpackDecodedItem *Item=D.Decoded,*Border=D.Decoded+D.DecodedSize;\n  while (ItemDestUnpSize)\n        return false;\n    }\n\n    if (Item->Type==UNPDT_LITERAL)\n    {\n#if defined(LITTLE_ENDIAN) && defined(ALLOW_MISALIGNED)\n      if (Item->Length==3 && UnpPtrLiteral;\n        UnpPtr+=4;\n      }\n      else\n#endif\n        for (uint I=0;I<=Item->Length;I++)\n          Window[UnpPtr++ & MaxWinMask]=Item->Literal[I];\n    }\n    else\n      if (Item->Type==UNPDT_MATCH)\n      {\n        InsertOldDist(Item->Distance);\n        LastLength=Item->Length;\n        CopyString(Item->Length,Item->Distance);\n      }\n      else\n        if (Item->Type==UNPDT_REP)\n        {\n          uint Distance=OldDist[Item->Distance];\n          for (uint I=Item->Distance;I>0;I--)\n            OldDist[I]=OldDist[I-1];\n          OldDist[0]=Distance;\n          LastLength=Item->Length;\n          CopyString(Item->Length,Distance);\n        }\n        else\n          if (Item->Type==UNPDT_FULLREP)\n          {\n            if (LastLength!=0)\n              CopyString(LastLength,OldDist[0]);\n          }\n          else\n            if (Item->Type==UNPDT_FILTER)\n            {\n              UnpackFilter Filter;\n              \n              Filter.Type=(byte)Item->Length;\n              Filter.BlockStart=Item->Distance;\n\n              Item++;\n\n              Filter.Channels=(byte)Item->Length;\n              Filter.BlockLength=Item->Distance;\n\n              AddFilter(Filter);\n            }\n    Item++;\n  }\n  return true;\n}","target":1,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":174020,"func":"xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode,\n\t     xmlNodePtr target, xmlAttrPtr attr)\n{\n    xmlAttrPtr copy;\n    xmlChar *value;\n\n    if (attr == NULL)\n\treturn(NULL);\n\n    if (target->type != XML_ELEMENT_NODE) {\n\txsltTransformError(ctxt, NULL, invocNode,\n\t    \"Cannot add an attribute node to a non-element node.\\n\");\n\treturn(NULL);\n    }\n\n    if (target->children != NULL) {\n\txsltTransformError(ctxt, NULL, invocNode,\n\t    \"Attribute nodes must be added before \"\n\t    \"any child nodes to an element.\\n\");\n\treturn(NULL);\n    }\n\n    value = xmlNodeListGetString(attr->doc, attr->children, 1);\n    if (attr->ns != NULL) {\n\txmlNsPtr ns;\n\n\tns = xsltGetSpecialNamespace(ctxt, invocNode,\n\t    attr->ns->href, attr->ns->prefix, target);\n\tif (ns == NULL) {\n\t    xsltTransformError(ctxt, NULL, invocNode,\n\t\t\"Namespace fixup error: Failed to acquire an in-scope \"\n\t\t\"namespace binding of the copied attribute '{%s}%s'.\\n\",\n\t\tattr->ns->href, attr->name);\n\t    \/*\n\t    * TODO: Should we just stop here?\n\t    *\/\n\t}\n\t\/*\n\t* Note that xmlSetNsProp() will take care of duplicates\n\t* and assigns the new namespace even to a duplicate.\n\t*\/\n\tcopy = xmlSetNsProp(target, ns, attr->name, value);\n    } else {\n\tcopy = xmlSetNsProp(target, NULL, attr->name, value);\n    }\n    if (value != NULL)\n\txmlFree(value);\n\n    if (copy == NULL)\n\treturn(NULL);\n\n#if 0\n    \/*\n    * NOTE: This was optimized according to bug #342695.\n    * TODO: Can this further be optimized, if source and target\n    *  share the same dict and attr->children is just 1 text node\n    *  which is in the dict? How probable is such a case?\n    *\/\n    \/*\n    * TODO: Do we need to create an empty text node if the value\n    *  is the empty string?\n    *\/\n    value = xmlNodeListGetString(attr->doc, attr->children, 1);\n    if (value != NULL) {\n\ttxtNode = xmlNewDocText(target->doc, NULL);\n\tif (txtNode == NULL)\n\t    return(NULL);\n\tif ((target->doc != NULL) &&\n\t    (target->doc->dict != NULL))\n\t{\n\t    txtNode->content =\n\t\t(xmlChar *) xmlDictLookup(target->doc->dict,\n\t\t    BAD_CAST value, -1);\n\t    xmlFree(value);\n\t} else\n\t    txtNode->content = value;\n\tcopy->children = txtNode;\n    }\n#endif\n\n    return(copy);\n}\n","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":387567,"func":"get_one_option(int optid, const struct my_option *opt __attribute__((unused)),\n               char *argument)\n{\n  DBUG_ENTER(\"get_one_option\");\n  switch(optid) {\n#ifdef __NETWARE__\n  case OPT_AUTO_CLOSE:\n    setscreenmode(SCR_AUTOCLOSE_ON_EXIT);\n    break;\n#endif\n  case 'v':\n    verbose++;\n    break;\n  case 'p':\n    if (argument == disabled_my_option)\n      argument= (char*) \"\";\t\t\t\/* Don't require password *\/\n    if (argument)\n    {\n      char *start= argument;\n      my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));\n      opt_password= my_strdup(argument,MYF(MY_FAE));\n      while (*argument) *argument++= 'x';\t\t\/* Destroy argument *\/\n      if (*start)\n        start[1]= 0;\t\t\t\t\/* Cut length of argument *\/\n      tty_password= 0;\n    }\n    else\n      tty_password= 1;\n    break;\n  case 'W':\n#ifdef __WIN__\n    opt_protocol= MYSQL_PROTOCOL_PIPE;\n#endif\n    break;\n  case OPT_MYSQL_PROTOCOL:\n    opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,\n                                    opt->name);\n    break;\n  case '#':\n    DBUG_PUSH(argument ? argument : default_dbug_option);\n    debug_check_flag= 1;\n    break;\n  case OPT_SLAP_CSV:\n    if (!argument)\n      argument= (char *)\"-\"; \/* use stdout *\/\n    opt_csv_str= argument;\n    break;\n#include \n  case 'V':\n    print_version();\n    exit(0);\n    break;\n  case '?':\n  case 'I':\t\t\t\t\t\/* Info *\/\n    usage();\n    exit(0);\n  }\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":38679,"func":"    JavascriptArray *JavascriptArray::GetArrayForArrayOrObjectWithArray(\n        const Var var,\n        bool *const isObjectWithArrayRef,\n        TypeId *const arrayTypeIdRef)\n    {\n        \/\/ This is a helper function used by jitted code. The array checks done here match the array checks done by jitted code\n        \/\/ (see Lowerer::GenerateArrayTest) to minimize bailouts.\n\n        Assert(var);\n        Assert(isObjectWithArrayRef);\n        Assert(arrayTypeIdRef);\n\n        *isObjectWithArrayRef = false;\n        *arrayTypeIdRef = TypeIds_Undefined;\n\n        if(!RecyclableObject::Is(var))\n        {\n            return nullptr;\n        }\n\n        JavascriptArray *array = nullptr;\n        INT_PTR vtable = VirtualTableInfoBase::GetVirtualTable(var);\n        if(vtable == VirtualTableInfo::Address)\n        {\n            ArrayObject* objectArray = DynamicObject::FromVar(var)->GetObjectArray();\n            array = (objectArray && Is(objectArray)) ? FromVar(objectArray) : nullptr;\n            if(!array)\n            {\n                return nullptr;\n            }\n            *isObjectWithArrayRef = true;\n            vtable = VirtualTableInfoBase::GetVirtualTable(array);\n        }\n\n        if(vtable == VirtualTableInfo::Address)\n        {\n            *arrayTypeIdRef = TypeIds_Array;\n        }\n        else if(vtable == VirtualTableInfo::Address)\n        {\n            *arrayTypeIdRef = TypeIds_NativeIntArray;\n        }\n        else if(vtable == VirtualTableInfo::Address)\n        {\n            *arrayTypeIdRef = TypeIds_NativeFloatArray;\n        }\n        else\n        {\n            return nullptr;\n        }\n\n        if(!array)\n        {\n            array = FromVar(var);\n        }\n        return array;\n    }","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":98052,"func":"static void out_string(conn *c, const char *str) {\n    size_t len;\n\n    assert(c != NULL);\n\n    if (c->noreply) {\n        if (settings.verbose > 1)\n            fprintf(stderr, \">%d NOREPLY %s\\n\", c->sfd, str);\n        c->noreply = false;\n        conn_set_state(c, conn_new_cmd);\n        return;\n    }\n\n    if (settings.verbose > 1)\n        fprintf(stderr, \">%d %s\\n\", c->sfd, str);\n\n    \/* Nuke a partial output... *\/\n    c->msgcurr = 0;\n    c->msgused = 0;\n    c->iovused = 0;\n    add_msghdr(c);\n\n    len = strlen(str);\n    if ((len + 2) > c->wsize) {\n        \/* ought to be always enough. just fail for simplicity *\/\n        str = \"SERVER_ERROR output line too long\";\n        len = strlen(str);\n    }\n\n    memcpy(c->wbuf, str, len);\n    memcpy(c->wbuf + len, \"\\r\\n\", 2);\n    c->wbytes = len + 2;\n    c->wcurr = c->wbuf;\n\n    conn_set_state(c, conn_write);\n    c->write_and_go = conn_new_cmd;\n    return;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":364227,"func":"ExtendSolidArea(rfbClientPtr cl,\n                int x,\n                int y,\n                int w,\n                int h,\n                uint32_t colorValue,\n                int *x_ptr,\n                int *y_ptr,\n                int *w_ptr,\n                int *h_ptr)\n{\n    int cx, cy;\n\n    \/* Try to extend the area upwards. *\/\n    for ( cy = *y_ptr - 1;\n          cy >= y && CheckSolidTile(cl, *x_ptr, cy, *w_ptr, 1, &colorValue, TRUE);\n          cy-- );\n    *h_ptr += *y_ptr - (cy + 1);\n    *y_ptr = cy + 1;\n\n    \/* ... downwards. *\/\n    for ( cy = *y_ptr + *h_ptr;\n          cy < y + h &&\n              CheckSolidTile(cl, *x_ptr, cy, *w_ptr, 1, &colorValue, TRUE);\n          cy++ );\n    *h_ptr += cy - (*y_ptr + *h_ptr);\n\n    \/* ... to the left. *\/\n    for ( cx = *x_ptr - 1;\n          cx >= x && CheckSolidTile(cl, cx, *y_ptr, 1, *h_ptr, &colorValue, TRUE);\n          cx-- );\n    *w_ptr += *x_ptr - (cx + 1);\n    *x_ptr = cx + 1;\n\n    \/* ... to the right. *\/\n    for ( cx = *x_ptr + *w_ptr;\n          cx < x + w &&\n              CheckSolidTile(cl, cx, *y_ptr, 1, *h_ptr, &colorValue, TRUE);\n          cx++ );\n    *w_ptr += cx - (*x_ptr + *w_ptr);\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":229091,"func":"void CL_Disconnect( qboolean showMainMenu ) {\n\tif ( !com_cl_running || !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\n\tCvar_Set(\"r_uiFullScreen\", \"1\");\n\n\tif ( clc.demorecording ) {\n\t\tCL_StopRecord_f ();\n\t}\n\n\tif (clc.download) {\n\t\tFS_FCloseFile( clc.download );\n\t\tclc.download = 0;\n\t}\n\t*clc.downloadTempName = *clc.downloadName = 0;\n\tCvar_Set( \"cl_downloadName\", \"\" );\n\n#ifdef USE_MUMBLE\n\tif (cl_useMumble->integer && mumble_islinked()) {\n\t\tCom_Printf(\"Mumble: Unlinking from Mumble application\\n\");\n\t\tmumble_unlink();\n\t}\n#endif\n\n#ifdef USE_VOIP\n\tif (cl_voipSend->integer) {\n\t\tint tmp = cl_voipUseVAD->integer;\n\t\tcl_voipUseVAD->integer = 0;  \/\/ disable this for a moment.\n\t\tclc.voipOutgoingDataSize = 0;  \/\/ dump any pending VoIP transmission.\n\t\tCvar_Set(\"cl_voipSend\", \"0\");\n\t\tCL_CaptureVoip();  \/\/ clean up any state...\n\t\tcl_voipUseVAD->integer = tmp;\n\t}\n\n\tif (clc.voipCodecInitialized) {\n\t\tint i;\n\t\topus_encoder_destroy(clc.opusEncoder);\n\t\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\t\topus_decoder_destroy(clc.opusDecoder[i]);\n\t\t}\n\t\tclc.voipCodecInitialized = qfalse;\n\t}\n\tCmd_RemoveCommand (\"voip\");\n#endif\n\n\tif ( clc.demofile ) {\n\t\tFS_FCloseFile( clc.demofile );\n\t\tclc.demofile = 0;\n\t}\n\n\tif ( uivm && showMainMenu ) {\n\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );\n\t}\n\n\tSCR_StopCinematic ();\n\tS_ClearSoundBuffer();\n\n\tif ( clc.state >= CA_CONNECTED ) {\n\t\tCL_AddReliableCommand(\"disconnect\", qtrue);\n\t\tCL_WritePacket();\n\t\tCL_WritePacket();\n\t\tCL_WritePacket();\n\t}\n\t\n\tFS_PureServerSetLoadedPaks(\"\", \"\");\n\tFS_PureServerSetReferencedPaks( \"\", \"\" );\n\t\n\tCL_ClearState ();\n\n\tCom_Memset( &clc, 0, sizeof( clc ) );\n\n\tclc.state = CA_DISCONNECTED;\n\n\tCvar_Set( \"sv_cheats\", \"1\" );\n\n\tcl_connectedToPureServer = qfalse;\n\n#ifdef USE_VOIP\n\tclc.voipEnabled = qfalse;\n#endif\n\n\tif( CL_VideoRecording( ) ) {\n\t\tSCR_UpdateScreen( );\n\t\tCL_CloseAVI( );\n\t}\n\n\tCL_UpdateGUID( NULL, 0 );\n\n\tif(!noGameRestart)\n\t\tCL_OldGame();\n\telse\n\t\tnoGameRestart = qfalse;\n}\n","target":0,"code_token_length":637,"total_token_length":873,"max_tokens_setting":1024}
+{"idx":53384,"func":"static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,\n\t\tbool modify, bool restore)\n{\n\tconst struct usb_ss_ep_comp_descriptor *comp_desc;\n\tconst struct usb_endpoint_descriptor *desc;\n\tstruct dwc3_gadget_ep_cmd_params params;\n\n\tif (dev_WARN_ONCE(dwc->dev, modify && restore,\n\t\t\t\t\t\"Can't modify and restore\\n\"))\n\t\treturn -EINVAL;\n\n\tcomp_desc = dep->endpoint.comp_desc;\n\tdesc = dep->endpoint.desc;\n\n\tmemset(¶ms, 0x00, sizeof(params));\n\n\tparams.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc))\n\t\t| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc));\n\n\t\/* Burst size is only needed in SuperSpeed mode *\/\n\tif (dwc->gadget.speed >= USB_SPEED_SUPER) {\n\t\tu32 burst = dep->endpoint.maxburst;\n\t\tparams.param0 |= DWC3_DEPCFG_BURST_SIZE(burst - 1);\n\t}\n\n\tif (modify) {\n\t\tparams.param0 |= DWC3_DEPCFG_ACTION_MODIFY;\n\t} else if (restore) {\n\t\tparams.param0 |= DWC3_DEPCFG_ACTION_RESTORE;\n\t\tparams.param2 |= dep->saved_state;\n\t} else {\n\t\tparams.param0 |= DWC3_DEPCFG_ACTION_INIT;\n\t}\n\n\tif (usb_endpoint_xfer_control(desc))\n\t\tparams.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN;\n\n\tif (dep->number <= 1 || usb_endpoint_xfer_isoc(desc))\n\t\tparams.param1 |= DWC3_DEPCFG_XFER_NOT_READY_EN;\n\n\tif (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) {\n\t\tparams.param1 |= DWC3_DEPCFG_STREAM_CAPABLE\n\t\t\t| DWC3_DEPCFG_STREAM_EVENT_EN;\n\t\tdep->stream_capable = true;\n\t}\n\n\tif (!usb_endpoint_xfer_control(desc))\n\t\tparams.param1 |= DWC3_DEPCFG_XFER_IN_PROGRESS_EN;\n\n\t\/*\n\t * We are doing 1:1 mapping for endpoints, meaning\n\t * Physical Endpoints 2 maps to Logical Endpoint 2 and\n\t * so on. We consider the direction bit as part of the physical\n\t * endpoint number. So USB endpoint 0x81 is 0x03.\n\t *\/\n\tparams.param1 |= DWC3_DEPCFG_EP_NUMBER(dep->number);\n\n\t\/*\n\t * We must use the lower 16 TX FIFOs even though\n\t * HW might have more\n\t *\/\n\tif (dep->direction)\n\t\tparams.param0 |= DWC3_DEPCFG_FIFO_NUMBER(dep->number >> 1);\n\n\tif (desc->bInterval) {\n\t\tparams.param1 |= DWC3_DEPCFG_BINTERVAL_M1(desc->bInterval - 1);\n\t\tdep->interval = 1 << (desc->bInterval - 1);\n\t}\n\n\treturn dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, ¶ms);\n}","target":0,"code_token_length":640,"total_token_length":876,"max_tokens_setting":1024}
+{"idx":442024,"func":"vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,\n\t\t\tint main_fd __rte_unused)\n{\n\tstruct virtio_net *dev = *pdev;\n\tint fd = msg->fds[0];\n\tuint64_t size, off;\n\tvoid *addr;\n\n\tif (validate_msg_fds(msg, 1) != 0)\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\n\tif (fd < 0) {\n\t\tVHOST_LOG_CONFIG(ERR, \"invalid log fd: %d\\n\", fd);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tif (msg->size != sizeof(VhostUserLog)) {\n\t\tVHOST_LOG_CONFIG(ERR,\n\t\t\t\"invalid log base msg size: %\"PRId32\" != %d\\n\",\n\t\t\tmsg->size, (int)sizeof(VhostUserLog));\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tsize = msg->payload.log.mmap_size;\n\toff  = msg->payload.log.mmap_offset;\n\n\t\/* Check for mmap size and offset overflow. *\/\n\tif (off >= -size) {\n\t\tVHOST_LOG_CONFIG(ERR,\n\t\t\t\"log offset %#\"PRIx64\" and log size %#\"PRIx64\" overflow\\n\",\n\t\t\toff, size);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tVHOST_LOG_CONFIG(INFO,\n\t\t\"log mmap size: %\"PRId64\", offset: %\"PRId64\"\\n\",\n\t\tsize, off);\n\n\t\/*\n\t * mmap from 0 to workaround a hugepage mmap bug: mmap will\n\t * fail when offset is not page size aligned.\n\t *\/\n\taddr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);\n\tclose(fd);\n\tif (addr == MAP_FAILED) {\n\t\tVHOST_LOG_CONFIG(ERR, \"mmap log base failed!\\n\");\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\t\/*\n\t * Free previously mapped log memory on occasionally\n\t * multiple VHOST_USER_SET_LOG_BASE.\n\t *\/\n\tif (dev->log_addr) {\n\t\tmunmap((void *)(uintptr_t)dev->log_addr, dev->log_size);\n\t}\n\tdev->log_addr = (uint64_t)(uintptr_t)addr;\n\tdev->log_base = dev->log_addr + off;\n\tdev->log_size = size;\n\n\t\/*\n\t * The spec is not clear about it (yet), but QEMU doesn't expect\n\t * any payload in the reply.\n\t *\/\n\tmsg->size = 0;\n\tmsg->fd_num = 0;\n\n\treturn RTE_VHOST_MSG_RESULT_REPLY;\n}","target":0,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":459187,"func":"MagickExport void ConvertRGBToHCLp(const Quantum red,const Quantum green,\n  const Quantum blue,double *hue,double *chroma,double *luma)\n{\n  double\n    b,\n    c,\n    g,\n    h,\n    max,\n    r;\n\n  \/*\n    Convert RGB to HCLp colorspace.\n  *\/\n  assert(hue != (double *) NULL);\n  assert(chroma != (double *) NULL);\n  assert(luma != (double *) NULL);\n  r=(double) red;\n  g=(double) green;\n  b=(double) blue;\n  max=MagickMax(r,MagickMax(g,b));\n  c=max-(double) MagickMin(r,MagickMin(g,b));\n  h=0.0;\n  if (fabs(c) < MagickEpsilon)\n    h=0.0;\n  else\n    if (red == (Quantum) max)\n      h=fmod((g-b)\/c+6.0,6.0);\n    else\n      if (green == (Quantum) max)\n        h=((b-r)\/c)+2.0;\n      else\n        if (blue == (Quantum) max)\n          h=((r-g)\/c)+4.0;\n  *hue=(h\/6.0);\n  *chroma=QuantumScale*c;\n  *luma=QuantumScale*(0.298839*r+0.586811*g+0.114350*b);\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":23888,"func":"static gboolean k12_dump_finish ( wtap_dumper * wdh , int * err ) {\n k12_dump_t * k12 = ( k12_dump_t * ) wdh -> priv ;\n union {\n guint8 b [ sizeof ( guint32 ) ] ;\n guint32 u ;\n }\n d ;\n if ( ! wtap_dump_file_write ( wdh , k12_eof , 2 , err ) ) return FALSE ;\n k12 -> file_len += 2 ;\n if ( wtap_dump_file_seek ( wdh , K12_FILE_HDR_FILE_SIZE , SEEK_SET , err ) == - 1 ) return FALSE ;\n d . u = g_htonl ( k12 -> file_len ) ;\n if ( ! wtap_dump_file_write ( wdh , d . b , 4 , err ) ) return FALSE ;\n if ( wtap_dump_file_seek ( wdh , K12_FILE_HDR_PAGE_SIZE , SEEK_SET , err ) == - 1 ) return FALSE ;\n d . u = g_htonl ( 8192 ) ;\n if ( ! wtap_dump_file_write ( wdh , d . b , 4 , err ) ) return FALSE ;\n if ( wtap_dump_file_seek ( wdh , K12_FILE_HDR_RECORD_COUNT_1 , SEEK_SET , err ) == - 1 ) return FALSE ;\n d . u = g_htonl ( k12 -> num_of_records ) ;\n if ( ! wtap_dump_file_write ( wdh , d . b , 4 , err ) ) return FALSE ;\n if ( wtap_dump_file_seek ( wdh , K12_FILE_HDR_RECORD_COUNT_2 , SEEK_SET , err ) == - 1 ) return FALSE ;\n d . u = g_htonl ( k12 -> num_of_records ) ;\n if ( ! wtap_dump_file_write ( wdh , d . b , 4 , err ) ) return FALSE ;\n return TRUE ;\n }","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":335658,"func":"static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)\n\n{\n\n    unsigned int crc;\n\n    unsigned char packet[TS_PACKET_SIZE];\n\n    const unsigned char *buf_ptr;\n\n    unsigned char *q;\n\n    int first, b, len1, left;\n\n\n\n    crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),\n\n                            -1, buf, len - 4));\n\n\n\n    buf[len - 4] = (crc >> 24) & 0xff;\n\n    buf[len - 3] = (crc >> 16) & 0xff;\n\n    buf[len - 2] = (crc >>  8) & 0xff;\n\n    buf[len - 1] =  crc        & 0xff;\n\n\n\n    \/* send each packet *\/\n\n    buf_ptr = buf;\n\n    while (len > 0) {\n\n        first = buf == buf_ptr;\n\n        q     = packet;\n\n        *q++  = 0x47;\n\n        b     = s->pid >> 8;\n\n        if (first)\n\n            b |= 0x40;\n\n        *q++  = b;\n\n        *q++  = s->pid;\n\n        s->cc = s->cc + 1 & 0xf;\n\n        *q++  = 0x10 | s->cc;\n\n\n\n\n\n\n\n        if (first)\n\n            *q++ = 0; \/* 0 offset *\/\n\n        len1 = TS_PACKET_SIZE - (q - packet);\n\n        if (len1 > len)\n\n            len1 = len;\n\n        memcpy(q, buf_ptr, len1);\n\n        q += len1;\n\n        \/* add known padding data *\/\n\n        left = TS_PACKET_SIZE - (q - packet);\n\n        if (left > 0)\n\n            memset(q, 0xff, left);\n\n\n\n        s->write_packet(s, packet);\n\n\n\n        buf_ptr += len1;\n\n        len     -= len1;\n\n","target":1,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":132219,"func":"static void process_stats_conns(ADD_STAT add_stats, void *c) {\n    int i;\n    char key_str[STAT_KEY_LEN];\n    char val_str[STAT_VAL_LEN];\n    size_t extras_len = sizeof(\"unix:\") + sizeof(\"65535\");\n    char addr[MAXPATHLEN + extras_len];\n    char svr_addr[MAXPATHLEN + extras_len];\n    int klen = 0, vlen = 0;\n\n    assert(add_stats);\n\n    for (i = 0; i < max_fds; i++) {\n        if (conns[i]) {\n            \/* This is safe to do unlocked because conns are never freed; the\n             * worst that'll happen will be a minor inconsistency in the\n             * output -- not worth the complexity of the locking that'd be\n             * required to prevent it.\n             *\/\n            if (IS_UDP(conns[i]->transport)) {\n                APPEND_NUM_STAT(i, \"UDP\", \"%s\", \"UDP\");\n            }\n            if (conns[i]->state != conn_closed) {\n                conn_to_str(conns[i], addr, svr_addr);\n\n                APPEND_NUM_STAT(i, \"addr\", \"%s\", addr);\n                if (conns[i]->state != conn_listening &&\n                    !(IS_UDP(conns[i]->transport) && conns[i]->state == conn_read)) {\n                    APPEND_NUM_STAT(i, \"listen_addr\", \"%s\", svr_addr);\n                }\n                APPEND_NUM_STAT(i, \"state\", \"%s\",\n                        state_text(conns[i]->state));\n                APPEND_NUM_STAT(i, \"secs_since_last_cmd\", \"%d\",\n                        current_time - conns[i]->last_cmd_time);\n            }\n        }\n    }\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":389794,"func":"void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)\n{\n    RAMBlock *block;\n    ram_addr_t offset;\n    int flags;\n    void *area, *vaddr;\n\n    QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {\n        offset = addr - block->offset;\n        if (offset < block->max_length) {\n            vaddr = ramblock_ptr(block, offset);\n            if (block->flags & RAM_PREALLOC) {\n                ;\n            } else if (xen_enabled()) {\n                abort();\n            } else {\n                flags = MAP_FIXED;\n                if (block->fd >= 0) {\n                    flags |= (block->flags & RAM_SHARED ?\n                              MAP_SHARED : MAP_PRIVATE);\n                    area = mmap(vaddr, length, PROT_READ | PROT_WRITE,\n                                flags, block->fd, offset);\n                } else {\n                    \/*\n                     * Remap needs to match alloc.  Accelerators that\n                     * set phys_mem_alloc never remap.  If they did,\n                     * we'd need a remap hook here.\n                     *\/\n                    assert(phys_mem_alloc == qemu_anon_ram_alloc);\n\n                    flags |= MAP_PRIVATE | MAP_ANONYMOUS;\n                    area = mmap(vaddr, length, PROT_READ | PROT_WRITE,\n                                flags, -1, 0);\n                }\n                if (area != vaddr) {\n                    fprintf(stderr, \"Could not remap addr: \"\n                            RAM_ADDR_FMT \"@\" RAM_ADDR_FMT \"\\n\",\n                            length, addr);\n                    exit(1);\n                }\n                memory_try_enable_merging(vaddr, length);\n                qemu_ram_setup_dump(vaddr, length);\n            }\n        }\n    }\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":13020,"func":"gst_vorbis_tag_add_coverart (GstTagList * tags, const gchar * img_data_base64,\n     gint base64_len)\n {\n   GstBuffer *img;\n  guchar *img_data;\n   gsize img_len;\n   guint save = 0;\n   gint state = 0;\n \n   if (base64_len < 2)\n     goto not_enough_data;\n \n  img_data = g_try_malloc0 (base64_len * 3 \/ 4);\n  if (img_data == NULL)\n    goto alloc_failed;\n  img_len = g_base64_decode_step (img_data_base64, base64_len, img_data,\n      &state, &save);\n \n   if (img_len == 0)\n     goto decode_failed;\n \n  img = gst_tag_image_data_to_image_buffer (img_data, img_len,\n       GST_TAG_IMAGE_TYPE_NONE);\n \n   if (img == NULL)\n  gst_tag_list_add (tags, GST_TAG_MERGE_APPEND,\n      GST_TAG_PREVIEW_IMAGE, img, NULL);\n\n       GST_TAG_PREVIEW_IMAGE, img, NULL);\n \n   gst_buffer_unref (img);\n  g_free (img_data);\n   return;\n \n \/* ERRORS *\/\n  {\n    GST_WARNING (\"COVERART tag with too little base64-encoded data\");\n     GST_WARNING (\"COVERART tag with too little base64-encoded data\");\n     return;\n   }\nalloc_failed:\n  {\n    GST_WARNING (\"Couldn't allocate enough memory to decode COVERART tag\");\n    return;\n  }\n decode_failed:\n   {\n    GST_WARNING (\"Couldn't decode bas64 image data from COVERART tag\");\n    g_free (img_data);\n     return;\n   }\n convert_failed:\n   {\n     GST_WARNING (\"Couldn't extract image or image type from COVERART tag\");\n    g_free (img_data);\n     return;\n   }\n }\n","target":1,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":353410,"func":"dtls1_buffer_message(SSL *s, int is_ccs)\n\t{\n\tpitem *item;\n\thm_fragment *frag;\n\tunsigned char seq64be[8];\n\n\t\/* this function is called immediately after a message has \n\t * been serialized *\/\n\tOPENSSL_assert(s->init_off == 0);\n\n\tfrag = dtls1_hm_fragment_new(s->init_num);\n\n\tmemcpy(frag->fragment, s->init_buf->data, s->init_num);\n\n\tif ( is_ccs)\n\t\t{\n\t\tOPENSSL_assert(s->d1->w_msg_hdr.msg_len + \n\t\t\t       ((s->version==DTLS1_VERSION)?DTLS1_CCS_HEADER_LENGTH:3) == (unsigned int)s->init_num);\n\t\t}\n\telse\n\t\t{\n\t\tOPENSSL_assert(s->d1->w_msg_hdr.msg_len + \n\t\t\tDTLS1_HM_HEADER_LENGTH == (unsigned int)s->init_num);\n\t\t}\n\n\tfrag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len;\n\tfrag->msg_header.seq = s->d1->w_msg_hdr.seq;\n\tfrag->msg_header.type = s->d1->w_msg_hdr.type;\n\tfrag->msg_header.frag_off = 0;\n\tfrag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len;\n\tfrag->msg_header.is_ccs = is_ccs;\n\n\t\/* save current state*\/\n\tfrag->msg_header.saved_retransmit_state.enc_write_ctx = s->enc_write_ctx;\n\tfrag->msg_header.saved_retransmit_state.write_hash = s->write_hash;\n\tfrag->msg_header.saved_retransmit_state.compress = s->compress;\n\tfrag->msg_header.saved_retransmit_state.session = s->session;\n\tfrag->msg_header.saved_retransmit_state.epoch = s->d1->w_epoch;\n\t\n\tmemset(seq64be,0,sizeof(seq64be));\n\tseq64be[6] = (unsigned char)(dtls1_get_queue_priority(frag->msg_header.seq,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  frag->msg_header.is_ccs)>>8);\n\tseq64be[7] = (unsigned char)(dtls1_get_queue_priority(frag->msg_header.seq,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  frag->msg_header.is_ccs));\n\n\titem = pitem_new(seq64be, frag);\n\tif ( item == NULL)\n\t\t{\n\t\tdtls1_hm_fragment_free(frag);\n\t\treturn 0;\n\t\t}\n\n#if 0\n\tfprintf( stderr, \"buffered messge: \\ttype = %xx\\n\", msg_buf->type);\n\tfprintf( stderr, \"\\t\\t\\t\\t\\tlen = %d\\n\", msg_buf->len);\n\tfprintf( stderr, \"\\t\\t\\t\\t\\tseq_num = %d\\n\", msg_buf->seq_num);\n#endif\n\n\tpqueue_insert(s->d1->sent_messages, item);\n\treturn 1;\n\t}","target":1,"code_token_length":613,"total_token_length":849,"max_tokens_setting":1024}
+{"idx":29881,"func":"static inline void get_limits ( MpegEncContext * s , int x , int y ) {\n MotionEstContext * const c = & s -> me ;\n int range = c -> avctx -> me_range >> ( 1 + ! ! ( c -> flags & FLAG_QPEL ) ) ;\n if ( s -> unrestricted_mv ) {\n c -> xmin = - x - 16 ;\n c -> ymin = - y - 16 ;\n c -> xmax = - x + s -> mb_width * 16 ;\n c -> ymax = - y + s -> mb_height * 16 ;\n }\n else if ( s -> out_format == FMT_H261 ) {\n c -> xmin = ( x > 15 ) ? - 15 : 0 ;\n c -> ymin = ( y > 15 ) ? - 15 : 0 ;\n c -> xmax = ( x < s -> mb_width * 16 - 16 ) ? 15 : 0 ;\n c -> ymax = ( y < s -> mb_height * 16 - 16 ) ? 15 : 0 ;\n }\n else {\n c -> xmin = - x ;\n c -> ymin = - y ;\n c -> xmax = - x + s -> mb_width * 16 - 16 ;\n c -> ymax = - y + s -> mb_height * 16 - 16 ;\n }\n if ( range ) {\n c -> xmin = FFMAX ( c -> xmin , - range ) ;\n c -> xmax = FFMIN ( c -> xmax , range ) ;\n c -> ymin = FFMAX ( c -> ymin , - range ) ;\n c -> ymax = FFMIN ( c -> ymax , range ) ;\n }\n }","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":93141,"func":"static void TIFFIgnoreTags(TIFF *tiff)\n{\n  char\n    *q;\n\n  const char\n    *p,\n    *tags;\n\n  Image\n   *image;\n\n  register ssize_t\n    i;\n\n  size_t\n    count;\n\n  TIFFFieldInfo\n    *ignore;\n\n  if (TIFFGetReadProc(tiff) != TIFFReadBlob)\n    return;\n  image=(Image *)TIFFClientdata(tiff);\n  tags=GetImageArtifact(image,\"tiff:ignore-tags\");\n  if (tags == (const char *) NULL)\n    return;\n  count=0;\n  p=tags;\n  while (*p != '\\0')\n  {\n    while ((isspace((int) ((unsigned char) *p)) != 0))\n      p++;\n\n    (void) strtol(p,&q,10);\n    if (p == q)\n      return;\n\n    p=q;\n    count++;\n\n    while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))\n      p++;\n  }\n  if (count == 0)\n    return;\n  i=0;\n  p=tags;\n  ignore=(TIFFFieldInfo *) AcquireQuantumMemory(count,sizeof(*ignore));\n  if (ignore == (TIFFFieldInfo *) NULL)\n    return;\n  \/*\n    This also sets field_bit to 0 (FIELD_IGNORE).\n  *\/\n  (void) memset(ignore,0,count*sizeof(*ignore));\n  while (*p != '\\0')\n  {\n    while ((isspace((int) ((unsigned char) *p)) != 0))\n      p++;\n\n    ignore[i].field_tag=(ttag_t) strtol(p,&q,10);\n\n    p=q;\n    i++;\n\n    while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))\n      p++;\n  }\n  (void) TIFFMergeFieldInfo(tiff,ignore,(uint32) count);\n  ignore=(TIFFFieldInfo *) RelinquishMagickMemory(ignore);\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":214354,"func":"bool PrintRenderFrameHelper::PrintPagesNative(blink::WebLocalFrame* frame,\n                                              int page_count) {\n  const PrintMsg_PrintPages_Params& params = *print_pages_params_;\n  const PrintMsg_Print_Params& print_params = params.params;\n\n  std::vector printed_pages = GetPrintedPages(params, page_count);\n  if (printed_pages.empty())\n    return false;\n\n  PdfMetafileSkia metafile(print_params.printed_doc_type);\n  CHECK(metafile.Init());\n\n  PrintHostMsg_DidPrintDocument_Params page_params;\n  PrintPageInternal(print_params, printed_pages[0], page_count, frame,\n                    &metafile, &page_params.page_size,\n                    &page_params.content_area);\n  for (size_t i = 1; i < printed_pages.size(); ++i) {\n    PrintPageInternal(print_params, printed_pages[i], page_count, frame,\n                      &metafile, nullptr, nullptr);\n  }\n\n  FinishFramePrinting();\n\n  metafile.FinishDocument();\n\n  if (!CopyMetafileDataToSharedMem(metafile,\n                                   &page_params.metafile_data_handle)) {\n    return false;\n  }\n\n  page_params.data_size = metafile.GetDataSize();\n  page_params.document_cookie = print_params.document_cookie;\n#if defined(OS_WIN)\n  page_params.physical_offsets = printer_printable_area_.origin();\n#endif\n  Send(new PrintHostMsg_DidPrintDocument(routing_id(), page_params));\n  return true;\n}\n","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":276500,"func":"void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {\n  TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(\n      &state_, target);\n  if (!texture_ref ||\n      !texture_manager()->CanGenerateMipmaps(texture_ref)) {\n    LOCAL_SET_GL_ERROR(\n        GL_INVALID_OPERATION, \"glGenerateMipmap\", \"Can not generate mips\");\n    return;\n  }\n\n  if (target == GL_TEXTURE_CUBE_MAP) {\n    for (int i = 0; i < 6; ++i) {\n      GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;\n      if (!texture_manager()->ClearTextureLevel(this, texture_ref, face, 0)) {\n        LOCAL_SET_GL_ERROR(\n            GL_OUT_OF_MEMORY, \"glGenerateMipmap\", \"dimensions too big\");\n        return;\n      }\n    }\n  } else {\n    if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, 0)) {\n      LOCAL_SET_GL_ERROR(\n          GL_OUT_OF_MEMORY, \"glGenerateMipmap\", \"dimensions too big\");\n      return;\n    }\n  }\n\n  LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(\"glGenerateMipmap\");\n  if (workarounds().set_texture_filter_before_generating_mipmap) {\n    glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);\n  }\n  glGenerateMipmapEXT(target);\n  if (workarounds().set_texture_filter_before_generating_mipmap) {\n    glTexParameteri(target, GL_TEXTURE_MIN_FILTER,\n                    texture_ref->texture()->min_filter());\n  }\n  GLenum error = LOCAL_PEEK_GL_ERROR(\"glGenerateMipmap\");\n  if (error == GL_NO_ERROR) {\n    texture_manager()->MarkMipmapsGenerated(texture_ref);\n  }\n}\n","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":339589,"func":"static int decode_bdlt(uint8_t *frame, int width, int height,\n\n                       const uint8_t *src, const uint8_t *src_end)\n\n{\n\n    const uint8_t *frame_end = frame + width * height;\n\n    uint8_t *line_ptr;\n\n    int count, lines, segments;\n\n\n\n    count = bytestream_get_le16(&src);\n\n    if (count >= height || width * count < 0)\n\n        return -1;\n\n    frame += width * count;\n\n    lines = bytestream_get_le16(&src);\n\n    if (frame + lines * width > frame_end || src >= src_end)\n\n        return -1;\n\n\n\n    while (lines--) {\n\n        line_ptr = frame;\n\n        frame += width;\n\n        segments = *src++;\n\n        while (segments--) {\n\n            if (src_end - src < 3)\n\n                return -1;\n\n            line_ptr += *src++;\n\n            if (line_ptr >= frame)\n\n                return -1;\n\n            count = (int8_t)*src++;\n\n            if (count >= 0) {\n\n                if (line_ptr + count > frame || src_end - src < count)\n\n                    return -1;\n\n                bytestream_get_buffer(&src, line_ptr, count);\n\n            } else {\n\n                count = -count;\n\n                if (line_ptr + count > frame || src >= src_end)\n\n                    return -1;\n\n                memset(line_ptr, *src++, count);\n\n            }\n\n            line_ptr += count;\n\n        }\n\n    }\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":396830,"func":"  STATIC void GC_CALLBACK GC_default_on_abort(const char *msg)\n  {\n    GC_find_leak = FALSE; \/* disable at-exit GC_gcollect()  *\/\n\n    if (msg != NULL) {\n#     if defined(MSWIN32)\n        GC_win32_MessageBoxA(msg, \"Fatal error in GC\", MB_ICONERROR | MB_OK);\n        \/* Also duplicate msg to GC log file.   *\/\n#     endif\n\n#   ifndef GC_ANDROID_LOG\n      \/* Avoid calling GC_err_printf() here, as GC_on_abort() could be  *\/\n      \/* called from it.  Note 1: this is not an atomic output.         *\/\n      \/* Note 2: possible write errors are ignored.                     *\/\n#     if defined(THREADS) && defined(GC_ASSERTIONS) \\\n         && (defined(MSWIN32) || defined(MSWINCE))\n        if (!GC_write_disabled)\n#     endif\n      {\n        if (WRITE(GC_stderr, (void *)msg, strlen(msg)) >= 0)\n          (void)WRITE(GC_stderr, (void *)(\"\\n\"), 1);\n      }\n#   else\n      __android_log_assert(\"*\" \/* cond *\/, GC_ANDROID_LOG_TAG, \"%s\\n\", msg);\n#   endif\n    }\n\n#   if !defined(NO_DEBUGGING) && !defined(GC_ANDROID_LOG)\n      if (GETENV(\"GC_LOOP_ON_ABORT\") != NULL) {\n            \/* In many cases it's easier to debug a running process.    *\/\n            \/* It's arguably nicer to sleep, but that makes it harder   *\/\n            \/* to look at the thread if the debugger doesn't know much  *\/\n            \/* about threads.                                           *\/\n            for(;;) {\n              \/* Empty *\/\n            }\n      }\n#   endif\n  }","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":491437,"func":"fetch_alt_indirect_string (dwarf_vma offset)\n{\n  separate_info * i;\n\n  if (! do_follow_links)\n    return \"\";\n\n  if (first_separate_info == NULL)\n    return _(\"\");\n\n  for (i = first_separate_info; i != NULL; i = i->next)\n    {\n      struct dwarf_section * section;\n      const char *           ret;\n\n      if (! load_debug_section (separate_debug_str, i->handle))\n\tcontinue;\n\n      section = &debug_displays [separate_debug_str].section;\n\n      if (section->start == NULL)\n\tcontinue;\n\n      if (offset >= section->size)\n\tcontinue;\n\n      ret = (const char *) (section->start + offset);\n      \/* Unfortunately we cannot rely upon the .debug_str section ending with a\n\t NUL byte.  Since our caller is expecting to receive a well formed C\n\t string we test for the lack of a terminating byte here.  *\/\n      if (strnlen ((const char *) ret, section->size - offset)\n\t  == section->size - offset)\n\treturn _(\"\");\n\n      return ret;\n    }\n\n  warn (_(\"DW_FORM_GNU_strp_alt offset (%s) too big or no string sections available\\n\"),\n\tdwarf_vmatoa (\"x\", offset));\n  return _(\"\");\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":422858,"func":"int ioat_probe(struct ioatdma_device *device)\n{\n\tint err = -ENODEV;\n\tstruct dma_device *dma = &device->common;\n\tstruct pci_dev *pdev = device->pdev;\n\tstruct device *dev = &pdev->dev;\n\n\t\/* DMA coherent memory pool for DMA descriptor allocations *\/\n\tdevice->dma_pool = pci_pool_create(\"dma_desc_pool\", pdev,\n\t\t\t\t\t   sizeof(struct ioat_dma_descriptor),\n\t\t\t\t\t   64, 0);\n\tif (!device->dma_pool) {\n\t\terr = -ENOMEM;\n\t\tgoto err_dma_pool;\n\t}\n\n\tdevice->completion_pool = pci_pool_create(\"completion_pool\", pdev,\n\t\t\t\t\t\t  sizeof(u64), SMP_CACHE_BYTES,\n\t\t\t\t\t\t  SMP_CACHE_BYTES);\n\n\tif (!device->completion_pool) {\n\t\terr = -ENOMEM;\n\t\tgoto err_completion_pool;\n\t}\n\n\tdevice->enumerate_channels(device);\n\n\tdma_cap_set(DMA_MEMCPY, dma->cap_mask);\n\tdma->dev = &pdev->dev;\n\n\tif (!dma->chancnt) {\n\t\tdev_err(dev, \"channel enumeration error\\n\");\n\t\tgoto err_setup_interrupts;\n\t}\n\n\terr = ioat_dma_setup_interrupts(device);\n\tif (err)\n\t\tgoto err_setup_interrupts;\n\n\terr = device->self_test(device);\n\tif (err)\n\t\tgoto err_self_test;\n\n\treturn 0;\n\nerr_self_test:\n\tioat_disable_interrupts(device);\nerr_setup_interrupts:\n\tpci_pool_destroy(device->completion_pool);\nerr_completion_pool:\n\tpci_pool_destroy(device->dma_pool);\nerr_dma_pool:\n\treturn err;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":213593,"func":"WebView* RenderViewImpl::createView(\n    WebFrame* creator,\n    const WebURLRequest& request,\n    const WebWindowFeatures& features,\n    const WebString& frame_name,\n    WebNavigationPolicy policy) {\n  if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups)\n    return NULL;\n\n  ViewHostMsg_CreateWindow_Params params;\n  params.opener_id = routing_id_;\n  params.user_gesture = creator->isProcessingUserGesture();\n  params.window_container_type = WindowFeaturesToContainerType(features);\n  params.session_storage_namespace_id = session_storage_namespace_id_;\n  params.frame_name = frame_name;\n  params.opener_frame_id = creator->identifier();\n  params.opener_url = creator->document().url();\n  params.opener_security_origin =\n      creator->document().securityOrigin().toString().utf8();\n  params.opener_suppressed = creator->willSuppressOpenerInNewFrame();\n  params.disposition = NavigationPolicyToDisposition(policy);\n  if (!request.isNull())\n    params.target_url = request.url();\n\n  int32 routing_id = MSG_ROUTING_NONE;\n  int32 surface_id = 0;\n  int64 cloned_session_storage_namespace_id;\n\n  RenderThread::Get()->Send(\n      new ViewHostMsg_CreateWindow(params,\n                                   &routing_id,\n                                   &surface_id,\n                                   &cloned_session_storage_namespace_id));\n  if (routing_id == MSG_ROUTING_NONE)\n    return NULL;\n\n  RenderViewImpl* view = RenderViewImpl::Create(\n      0,\n      routing_id_,\n      renderer_preferences_,\n      webkit_preferences_,\n      shared_popup_counter_,\n      routing_id,\n      surface_id,\n      cloned_session_storage_namespace_id,\n      frame_name,\n      1,\n      screen_info_);\n  view->opened_by_user_gesture_ = params.user_gesture;\n\n  view->opener_suppressed_ = params.opener_suppressed;\n\n  GURL creator_url(creator->document().securityOrigin().toString().utf8());\n  if (!creator_url.is_valid() || !creator_url.IsStandard())\n    creator_url = GURL();\n  view->creator_url_ = creator_url;\n\n  view->alternate_error_page_url_ = alternate_error_page_url_;\n\n  return view->webview();\n}\n","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":300116,"func":"inline void Mean(const tflite::MeanParams& op_params,\n                 const RuntimeShape& unextended_input_shape,\n                 const uint8_t* input_data, int32 input_zero_point,\n                 float input_scale, const RuntimeShape& unextended_output_shape,\n                 uint8_t* output_data, int32 output_zero_point,\n                 float output_scale, CpuBackendContext* cpu_backend_context) {\n  ruy::profiler::ScopeLabel label(\"Mean4D\/Uint8\");\n  \/\/ Current implementation only supports dimension equals 4 and simultaneous\n  \/\/ reduction over width and height.\n  TFLITE_CHECK_EQ(unextended_input_shape.DimensionsCount(), 4);\n  TFLITE_CHECK_LE(unextended_output_shape.DimensionsCount(), 4);\n  const RuntimeShape input_shape =\n      RuntimeShape::ExtendedShape(4, unextended_input_shape);\n  const RuntimeShape output_shape =\n      RuntimeShape::ExtendedShape(4, unextended_output_shape);\n  const int output_height = output_shape.Dims(1);\n  const int output_width = output_shape.Dims(2);\n  const int output_depth = output_shape.Dims(3);\n\n  TFLITE_CHECK_EQ(op_params.axis_count, 2);\n  TFLITE_CHECK((op_params.axis[0] == 1 && op_params.axis[1] == 2) ||\n               (op_params.axis[0] == 2 && op_params.axis[1] == 1));\n  TFLITE_CHECK_EQ(output_height, 1);\n  TFLITE_CHECK_EQ(output_width, 1);\n\n  const int input_height = input_shape.Dims(1);\n  const int input_width = input_shape.Dims(2);\n  const float num_elements_in_axis = input_width * input_height;\n\n  float temp = input_zero_point * input_scale \/ output_scale;\n  temp = temp > 0 ? temp + 0.5f : temp - 0.5f;\n  int32_t bias = output_zero_point - static_cast(temp);\n  float real_scale = input_scale \/ (num_elements_in_axis * output_scale);\n\n  int32 multiplier, shift;\n  QuantizeMultiplier(real_scale, &multiplier, &shift);\n\n  constexpr int kMinDepthPerThread = 8;\n  int thread_count = output_depth \/ kMinDepthPerThread;\n  thread_count = thread_count > 0 ? thread_count : 1;\n  const int capped_thread_count =\n      std::min(thread_count, cpu_backend_context->max_num_threads());\n\n  if (capped_thread_count == 1) {\n    MeanImpl(op_params, input_shape, input_data, multiplier, shift, bias,\n             output_shape, output_data, 0, output_depth);\n  } else {\n    \/\/ Instead parallel for batch, we loop for the output_depth since batch\n    \/\/ is typical 1.\n    std::vector tasks;\n    \/\/ TODO(b\/131746020) don't create new heap allocations every time.\n    \/\/ At least we make it a single heap allocation by using reserve().\n    tasks.reserve(capped_thread_count);\n    int depth_start = 0;\n    for (int i = 0; i < capped_thread_count; ++i) {\n      \/\/ Try to distribute the tasks as even as possible.\n      int depth_end = depth_start +\n                      (output_depth - depth_start) \/ (capped_thread_count - i);\n      tasks.emplace_back(op_params, input_shape, input_data, multiplier, shift,\n                         bias, output_shape, output_data, depth_start,\n                         depth_end);\n      depth_start = depth_end;\n    }\n    cpu_backend_threadpool::Execute(tasks.size(), tasks.data(),\n                                    cpu_backend_context);\n  }\n}","target":0,"code_token_length":783,"total_token_length":1019,"max_tokens_setting":1024}
+{"idx":4495,"func":"error_t enc624j600UpdateMacAddrFilter(NetInterface *interface)\n{\n   uint_t i;\n   uint_t k;\n   uint32_t crc;\n   uint16_t hashTable[4];\n   MacFilterEntry *entry;\n\n   \/\/Debug message\n   TRACE_DEBUG(\"Updating MAC filter...\\r\\n\");\n\n   \/\/Clear hash table\n   osMemset(hashTable, 0, sizeof(hashTable));\n\n   \/\/The MAC address filter contains the list of MAC addresses to accept\n   \/\/when receiving an Ethernet frame\n   for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)\n   {\n      \/\/Point to the current entry\n      entry = &interface->macAddrFilter[i];\n\n      \/\/Valid entry?\n      if(entry->refCount > 0)\n      {\n         \/\/Compute CRC over the current MAC address\n         crc = enc624j600CalcCrc(&entry->addr, sizeof(MacAddr));\n         \/\/Calculate the corresponding index in the table\n         k = (crc >> 23) & 0x3F;\n         \/\/Update hash table contents\n         hashTable[k \/ 16] |= (1 << (k % 16));\n      }\n   }\n\n   \/\/Write the hash table to the ENC624J600 controller\n   enc624j600WriteReg(interface, ENC624J600_REG_EHT1, hashTable[0]);\n   enc624j600WriteReg(interface, ENC624J600_REG_EHT2, hashTable[1]);\n   enc624j600WriteReg(interface, ENC624J600_REG_EHT3, hashTable[2]);\n   enc624j600WriteReg(interface, ENC624J600_REG_EHT4, hashTable[3]);\n\n   \/\/Debug message\n   TRACE_DEBUG(\"  EHT1 = %04\" PRIX16 \"\\r\\n\", enc624j600ReadReg(interface, ENC624J600_REG_EHT1));\n   TRACE_DEBUG(\"  EHT2 = %04\" PRIX16 \"\\r\\n\", enc624j600ReadReg(interface, ENC624J600_REG_EHT2));\n   TRACE_DEBUG(\"  EHT3 = %04\" PRIX16 \"\\r\\n\", enc624j600ReadReg(interface, ENC624J600_REG_EHT3));\n   TRACE_DEBUG(\"  EHT4 = %04\" PRIX16 \"\\r\\n\", enc624j600ReadReg(interface, ENC624J600_REG_EHT4));\n\n   \/\/Successful processing\n   return NO_ERROR;\n}","target":1,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":316509,"func":"long Segment::ParseCues(long long off, long long& pos, long& len) {\n if (m_pCues)\n return 0; \/\/ success\n\n if (off < 0)\n return -1;\n\n long long total, avail;\n\n const int status = m_pReader->Length(&total, &avail);\n\n if (status < 0) \/\/ error\n return status;\n\n  assert((total < 0) || (avail <= total));\n\n  pos = m_start + off;\n\n if ((total < 0) || (pos >= total))\n return 1; \/\/ don't bother parsing cues\n\n const long long element_start = pos;\n const long long segment_stop = (m_size < 0) ? -1 : m_start + m_size;\n\n if ((pos + 1) > avail) {\n    len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n long long result = GetUIntLength(m_pReader, pos, len);\n\n if (result < 0) \/\/ error\n return static_cast(result);\n\n if (result > 0) \/\/ underflow (weird)\n {\n    len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n if ((segment_stop >= 0) && ((pos + len) > segment_stop))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long idpos = pos;\n\n const long long id = ReadID(m_pReader, idpos, len);\n\n if (id != 0x0C53BB6B) \/\/ Cues ID\n return E_FILE_FORMAT_INVALID;\n\n  pos += len; \/\/ consume ID\n  assert((segment_stop < 0) || (pos <= segment_stop));\n\n\n if ((pos + 1) > avail) {\n    len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n  result = GetUIntLength(m_pReader, pos, len);\n\n if (result < 0) \/\/ error\n return static_cast(result);\n\n if (result > 0) \/\/ underflow (weird)\n {\n    len = 1;\n return E_BUFFER_NOT_FULL;\n }\n\n if ((segment_stop >= 0) && ((pos + len) > segment_stop))\n return E_FILE_FORMAT_INVALID;\n\n if ((pos + len) > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long size = ReadUInt(m_pReader, pos, len);\n\n if (size < 0) \/\/ error\n return static_cast(size);\n\n if (size == 0) \/\/ weird, although technically not illegal\n return 1; \/\/ done\n\n  pos += len; \/\/ consume length of size of element\n  assert((segment_stop < 0) || (pos <= segment_stop));\n\n\n const long long element_stop = pos + size;\n\n if ((segment_stop >= 0) && (element_stop > segment_stop))\n return E_FILE_FORMAT_INVALID;\n\n if ((total >= 0) && (element_stop > total))\n return 1; \/\/ don't bother parsing anymore\n\n  len = static_cast(size);\n\n if (element_stop > avail)\n return E_BUFFER_NOT_FULL;\n\n const long long element_size = element_stop - element_start;\n\n  m_pCues =\n new (std::nothrow) Cues(this, pos, size, element_start, element_size);\n if (m_pCues == NULL)\n return -1;\n\n return 0; \/\/ success\n}\n","target":0,"code_token_length":697,"total_token_length":933,"max_tokens_setting":1024}
+{"idx":449965,"func":"int LUKS2_get_data_size(struct luks2_hdr *hdr, uint64_t *size, bool *dynamic)\n{\n\tint sector_size;\n\tjson_object *jobj_segments, *jobj_size;\n\tuint64_t tmp = 0;\n\n\tif (!size || !json_object_object_get_ex(hdr->jobj, \"segments\", &jobj_segments))\n\t\treturn -EINVAL;\n\n\tjson_object_object_foreach(jobj_segments, key, val) {\n\t\tUNUSED(key);\n\t\tif (json_segment_is_backup(val))\n\t\t\tcontinue;\n\n\t\tjson_object_object_get_ex(val, \"size\", &jobj_size);\n\t\tif (!strcmp(json_object_get_string(jobj_size), \"dynamic\")) {\n\t\t\tsector_size = json_segment_get_sector_size(val);\n\t\t\t\/* last dynamic segment must have at least one sector in size *\/\n\t\t\tif (tmp)\n\t\t\t\t*size = tmp + (sector_size > 0 ? sector_size : SECTOR_SIZE);\n\t\t\telse\n\t\t\t\t*size = 0;\n\t\t\tif (dynamic)\n\t\t\t\t*dynamic = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\ttmp += crypt_jobj_get_uint64(jobj_size);\n\t}\n\n\t\/* impossible, real device size must not be zero *\/\n\tif (!tmp)\n\t\treturn -EINVAL;\n\n\t*size = tmp;\n\tif (dynamic)\n\t\t*dynamic = false;\n\treturn 0;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":319546,"func":"void gic_complete_irq(GICState *s, int cpu, int irq)\n\n{\n\n    int update = 0;\n\n    int cm = 1 << cpu;\n\n    DPRINTF(\"EOI %d\\n\", irq);\n\n    if (irq >= s->num_irq) {\n\n        \/* This handles two cases:\n\n         * 1. If software writes the ID of a spurious interrupt [ie 1023]\n\n         * to the GICC_EOIR, the GIC ignores that write.\n\n         * 2. If software writes the number of a non-existent interrupt\n\n         * this must be a subcase of \"value written does not match the last\n\n         * valid interrupt value read from the Interrupt Acknowledge\n\n         * register\" and so this is UNPREDICTABLE. We choose to ignore it.\n\n         *\/\n\n        return;\n\n    }\n\n    if (s->running_irq[cpu] == 1023)\n\n        return; \/* No active IRQ.  *\/\n\n\n\n    if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {\n\n        \/* Mark level triggered interrupts as pending if they are still\n\n           raised.  *\/\n\n        if (!GIC_TEST_EDGE_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)\n\n            && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {\n\n            DPRINTF(\"Set %d pending mask %x\\n\", irq, cm);\n\n            GIC_SET_PENDING(irq, cm);\n\n            update = 1;\n\n        }\n\n    }\n\n\n\n    if (irq != s->running_irq[cpu]) {\n\n        \/* Complete an IRQ that is not currently running.  *\/\n\n        int tmp = s->running_irq[cpu];\n\n        while (s->last_active[tmp][cpu] != 1023) {\n\n            if (s->last_active[tmp][cpu] == irq) {\n\n                s->last_active[tmp][cpu] = s->last_active[irq][cpu];\n\n                break;\n\n            }\n\n            tmp = s->last_active[tmp][cpu];\n\n        }\n\n        if (update) {\n\n            gic_update(s);\n\n        }\n\n    } else {\n\n        \/* Complete the current running IRQ.  *\/\n\n        gic_set_running_irq(s, cpu, s->last_active[s->running_irq[cpu]][cpu]);\n\n    }\n\n}\n","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":320792,"func":"void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)\n\n{\n\n    RAMBlock *block;\n\n    ram_addr_t offset;\n\n    int flags;\n\n    void *area, *vaddr;\n\n\n\n    QLIST_FOREACH(block, &ram_list.blocks, next) {\n\n        offset = addr - block->offset;\n\n        if (offset < block->length) {\n\n            vaddr = block->host + offset;\n\n            if (block->flags & RAM_PREALLOC_MASK) {\n\n                ;\n\n            } else {\n\n                flags = MAP_FIXED;\n\n                munmap(vaddr, length);\n\n                if (mem_path) {\n\n#if defined(__linux__) && !defined(TARGET_S390X)\n\n                    if (block->fd) {\n\n#ifdef MAP_POPULATE\n\n                        flags |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :\n\n                            MAP_PRIVATE;\n\n\n                        flags |= MAP_PRIVATE;\n\n#endif\n\n                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,\n\n                                    flags, block->fd, offset);\n\n                    } else {\n\n                        flags |= MAP_PRIVATE | MAP_ANONYMOUS;\n\n                        area = mmap(vaddr, length, PROT_READ | PROT_WRITE,\n\n                                    flags, -1, 0);\n\n                    }\n\n\n\n#endif\n\n                } else {\n\n#if defined(TARGET_S390X) && defined(CONFIG_KVM)\n\n                    flags |= MAP_SHARED | MAP_ANONYMOUS;\n\n                    area = mmap(vaddr, length, PROT_EXEC|PROT_READ|PROT_WRITE,\n\n                                flags, -1, 0);\n\n\n                    flags |= MAP_PRIVATE | MAP_ANONYMOUS;\n\n                    area = mmap(vaddr, length, PROT_READ | PROT_WRITE,\n\n                                flags, -1, 0);\n\n#endif\n\n                }\n\n                if (area != vaddr) {\n\n                    fprintf(stderr, \"Could not remap addr: %lx@%lx\\n\",\n\n                            length, addr);\n\n                    exit(1);\n\n                }\n\n                qemu_madvise(vaddr, length, QEMU_MADV_MERGEABLE);\n\n            }\n\n            return;\n\n        }\n\n    }\n\n}","target":1,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":246312,"func":"void AutofillManager::OnFormSubmittedImpl(const FormData& form,\n                                          bool known_success,\n                                          SubmissionSource source,\n                                          base::TimeTicks timestamp) {\n  if (source == SubmissionSource::PROBABLY_FORM_SUBMITTED)\n    return;\n\n  std::unique_ptr submitted_form = ValidateSubmittedForm(form);\n  if (!submitted_form) {\n    autocomplete_history_manager_->OnWillSubmitForm(form);\n    return;\n  }\n\n  FormData form_for_autocomplete = submitted_form->ToFormData();\n  for (size_t i = 0; i < submitted_form->field_count(); ++i) {\n    if (submitted_form->field(i)->Type().GetStorableType() ==\n        CREDIT_CARD_VERIFICATION_CODE) {\n      form_for_autocomplete.fields[i].should_autocomplete = false;\n    }\n  }\n  autocomplete_history_manager_->OnWillSubmitForm(form_for_autocomplete);\n\n  address_form_event_logger_->OnWillSubmitForm();\n  if (IsCreditCardAutofillEnabled())\n    credit_card_form_event_logger_->OnWillSubmitForm();\n\n  MaybeStartVoteUploadProcess(std::move(submitted_form), timestamp,\n                              \/*observed_submission=*\/true);\n\n  submitted_form = ValidateSubmittedForm(form);\n  DCHECK(submitted_form);\n  if (!submitted_form)\n    return;\n\n  CreditCard credit_card =\n      form_data_importer_->ExtractCreditCardFromForm(*submitted_form);\n  AutofillMetrics::CardNumberStatus card_number_status =\n      GetCardNumberStatus(credit_card);\n\n  address_form_event_logger_->OnFormSubmitted(\/*force_logging=*\/false,\n                                              card_number_status);\n  if (IsCreditCardAutofillEnabled())\n    credit_card_form_event_logger_->OnFormSubmitted(enable_ablation_logging_,\n                                                    card_number_status);\n\n  if (!submitted_form->IsAutofillable())\n    return;\n\n  form_data_importer_->ImportFormData(*submitted_form,\n                                      IsCreditCardAutofillEnabled());\n}\n","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":238033,"func":"Frame* FrameLoader::createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest& request, const WindowFeatures& features, bool& created)\n{ \n    ASSERT(!features.dialog || request.frameName().isEmpty());\n\n    if (!request.frameName().isEmpty() && request.frameName() != \"_blank\") {\n        Frame* frame = frameLoaderForFrameLookup->frame()->tree()->find(request.frameName());\n        if (frame && shouldAllowNavigation(frame)) {\n            if (!request.resourceRequest().url().isEmpty())\n                frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer);\n            if (Page* page = frame->page())\n                page->chrome()->focus();\n            created = false;\n            return frame;\n        }\n    }\n    \n    FrameLoadRequest requestWithReferrer = request;\n    requestWithReferrer.resourceRequest().setHTTPReferrer(m_outgoingReferrer);\n    addHTTPOriginIfNeeded(requestWithReferrer.resourceRequest(), outgoingOrigin());\n\n    Page* oldPage = m_frame->page();\n    if (!oldPage)\n        return 0;\n        \n    Page* page = oldPage->chrome()->createWindow(m_frame, requestWithReferrer, features);\n    if (!page)\n        return 0;\n\n    Frame* frame = page->mainFrame();\n    if (request.frameName() != \"_blank\")\n        frame->tree()->setName(request.frameName());\n\n    page->chrome()->setToolbarsVisible(features.toolBarVisible || features.locationBarVisible);\n    page->chrome()->setStatusbarVisible(features.statusBarVisible);\n    page->chrome()->setScrollbarsVisible(features.scrollbarsVisible);\n    page->chrome()->setMenubarVisible(features.menuBarVisible);\n    page->chrome()->setResizable(features.resizable);\n\n\n    FloatRect windowRect = page->chrome()->windowRect();\n    FloatSize pageSize = page->chrome()->pageRect().size();\n    if (features.xSet)\n        windowRect.setX(features.x);\n    if (features.ySet)\n        windowRect.setY(features.y);\n    if (features.widthSet)\n        windowRect.setWidth(features.width + (windowRect.width() - pageSize.width()));\n    if (features.heightSet)\n        windowRect.setHeight(features.height + (windowRect.height() - pageSize.height()));\n    page->chrome()->setWindowRect(windowRect);\n\n    page->chrome()->show();\n\n    created = true;\n    return frame;\n}\n","target":0,"code_token_length":497,"total_token_length":733,"max_tokens_setting":1024}
+{"idx":421274,"func":"static NOINLINE void send_inform(struct dhcp_packet *oldpacket)\n{\n\tstruct dhcp_packet packet;\n\n\t\/* \"If a client has obtained a network address through some other means\n\t * (e.g., manual configuration), it may use a DHCPINFORM request message\n\t * to obtain other local configuration parameters.  Servers receiving a\n\t * DHCPINFORM message construct a DHCPACK message with any local\n\t * configuration parameters appropriate for the client without:\n\t * allocating a new address, checking for an existing binding, filling\n\t * in 'yiaddr' or including lease time parameters.  The servers SHOULD\n\t * unicast the DHCPACK reply to the address given in the 'ciaddr' field\n\t * of the DHCPINFORM message.\n\t * ...\n\t * The server responds to a DHCPINFORM message by sending a DHCPACK\n\t * message directly to the address given in the 'ciaddr' field\n\t * of the DHCPINFORM message.  The server MUST NOT send a lease\n\t * expiration time to the client and SHOULD NOT fill in 'yiaddr'.\"\n\t *\/\n\/\/TODO: do a few sanity checks: is ciaddr set?\n\/\/Better yet: is ciaddr == IP source addr?\n\tinit_packet(&packet, oldpacket, DHCPACK);\n\tadd_server_options(&packet);\n\n\tsend_packet(&packet, \/*force_bcast:*\/ 0);\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":157793,"func":"static int can_handle_new_request(RADIUS_PACKET *packet,\n\t\t\t\t  RADCLIENT *client,\n\t\t\t\t  struct main_config_t *root)\n{\n\t\/*\n\t *\tCount the total number of requests, to see if\n\t *\tthere are too many.  If so, return with an\n\t *\terror.\n\t *\/\n\tif (root->max_requests) {\n\t\tint request_count = fr_packet_list_num_elements(pl);\n\n\t\t\/*\n\t\t *\tThis is a new request.  Let's see if\n\t\t *\tit makes us go over our configured\n\t\t *\tbounds.\n\t\t *\/\n\t\tif (request_count > root->max_requests) {\n\t\t\tradlog(L_ERR, \"Dropping request (%d is too many): \"\n\t\t\t       \"from client %s port %d - ID: %d\", request_count,\n\t\t\t       client->shortname,\n\t\t\t       packet->src_port, packet->id);\n\t\t\tradlog(L_INFO, \"WARNING: Please check the configuration file.\\n\"\n\t\t\t       \"\\tThe value for 'max_requests' is probably set too low.\\n\");\n\t\t\treturn 0;\n\t\t} \/* else there were a small number of requests *\/\n\t} \/* else there was no configured limit for requests *\/\n\n\t\/*\n\t *\tFIXME: Add per-client checks.  If one client is sending\n\t *\ttoo many packets, start discarding them.\n\t *\n\t *\tWe increment the counters here, and decrement them\n\t *\twhen the response is sent... somewhere in this file.\n\t *\/\n\n\t\/*\n\t *\tFUTURE: Add checks for system load.  If the system is\n\t *\tbusy, start dropping requests...\n\t *\n\t *\tWe can probably keep some statistics ourselves...  if\n\t *\tthere are more requests coming in than we can handle,\n\t *\tstart dropping some.\n\t *\/\n\n\treturn 1;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":20909,"func":"static int x ( struct vcache * avc , int afun , struct vrequest * areq , \\ struct afs_pdata * ain , struct afs_pdata * aout , \\ afs_ucred_t * * acred ) DECL_PIOCTL ( PGetFID ) ;\n DECL_PIOCTL ( PSetAcl ) ;\n DECL_PIOCTL ( PStoreBehind ) ;\n DECL_PIOCTL ( PGCPAGs ) ;\n DECL_PIOCTL ( PGetAcl ) ;\n DECL_PIOCTL ( PNoop ) ;\n DECL_PIOCTL ( PBogus ) ;\n DECL_PIOCTL ( PGetFileCell ) ;\n DECL_PIOCTL ( PGetWSCell ) ;\n DECL_PIOCTL ( PGetUserCell ) ;\n DECL_PIOCTL ( PSetTokens ) ;\n DECL_PIOCTL ( PGetVolumeStatus ) ;\n DECL_PIOCTL ( PSetVolumeStatus ) ;\n DECL_PIOCTL ( PFlush ) ;\n DECL_PIOCTL ( PNewStatMount ) ;\n DECL_PIOCTL ( PGetTokens ) ;\n DECL_PIOCTL ( PUnlog ) ;\n DECL_PIOCTL ( PMariner ) ;\n DECL_PIOCTL ( PCheckServers ) ;\n DECL_PIOCTL ( PCheckVolNames ) ;\n DECL_PIOCTL ( PCheckAuth ) ;\n DECL_PIOCTL ( PFindVolume ) ;\n DECL_PIOCTL ( PViceAccess ) ;\n DECL_PIOCTL ( PSetCacheSize ) ;\n DECL_PIOCTL ( PGetCacheSize ) ;\n DECL_PIOCTL ( PRemoveCallBack ) ;\n DECL_PIOCTL ( PNewCell ) ;\n DECL_PIOCTL ( PNewAlias ) ;\n DECL_PIOCTL ( PListCells ) ;\n DECL_PIOCTL ( PListAliases ) ;\n DECL_PIOCTL ( PRemoveMount ) ;\n DECL_PIOCTL ( PGetCellStatus ) ;\n DECL_PIOCTL ( PSetCellStatus ) ;\n DECL_PIOCTL ( PFlushVolumeData ) ;\n DECL_PIOCTL ( PFlushAllVolumeData ) ;\n DECL_PIOCTL ( PGetVnodeXStatus ) ;\n DECL_PIOCTL ( PGetVnodeXStatus2 ) ;\n DECL_PIOCTL ( PSetSysName ) ;\n DECL_PIOCTL ( PSetSPrefs ) ;\n DECL_PIOCTL ( PSetSPrefs33 ) ;\n DECL_PIOCTL ( PGetSPrefs ) ;\n DECL_PIOCTL ( PExportAfs ) ;\n DECL_PIOCTL ( PGag ) ;\n DECL_PIOCTL ( PTwiddleRx ) ;\n DECL_PIOCTL ( PGetInitParams ) ;\n DECL_PIOCTL ( PGetRxkcrypt ) ;\n DECL_PIOCTL ( PSetRxkcrypt ) ;\n DECL_PIOCTL ( PGetCPrefs ) ;\n DECL_PIOCTL ( PSetCPrefs ) ;\n DECL_PIOCTL ( PFlushMount ) ;\n DECL_PIOCTL ( PRxStatProc )","target":0,"code_token_length":594,"total_token_length":830,"max_tokens_setting":1024}
+{"idx":279870,"func":"static void spl_array_set_array(zval *object, spl_array_object *intern, zval **array, long ar_flags, int just_array TSRMLS_DC) {\n\n\tif (Z_TYPE_PP(array) == IS_ARRAY) {\n\t\tSEPARATE_ZVAL_IF_NOT_REF(array);\n\t}\n\n\tif (Z_TYPE_PP(array) == IS_OBJECT && (Z_OBJ_HT_PP(array) == &spl_handler_ArrayObject || Z_OBJ_HT_PP(array) == &spl_handler_ArrayIterator)) {\n\t\tzval_ptr_dtor(&intern->array);\n\t\tif (just_array)\t{\n\t\t\tspl_array_object *other = (spl_array_object*)zend_object_store_get_object(*array TSRMLS_CC);\n\t\t\tar_flags = other->ar_flags & ~SPL_ARRAY_INT_MASK;\n\t\t}\n\t\tar_flags |= SPL_ARRAY_USE_OTHER;\n\t\tintern->array = *array;\n\t} else {\n\t\tif (Z_TYPE_PP(array) != IS_OBJECT && Z_TYPE_PP(array) != IS_ARRAY) {\n\t\t\tzend_throw_exception(spl_ce_InvalidArgumentException, \"Passed variable is not an array or object, using empty array instead\", 0 TSRMLS_CC);\n\t\t\treturn;\n\t\t}\n\t\tzval_ptr_dtor(&intern->array);\n\t\tintern->array = *array;\n\t}\n\tif (object == *array) {\n\t\tintern->ar_flags |= SPL_ARRAY_IS_SELF;\n\t\tintern->ar_flags &= ~SPL_ARRAY_USE_OTHER;\n\t} else {\n\t\tintern->ar_flags &= ~SPL_ARRAY_IS_SELF;\n\t}\n\tintern->ar_flags |= ar_flags;\n\tZ_ADDREF_P(intern->array);\n\tif (Z_TYPE_PP(array) == IS_OBJECT) {\n\t\tzend_object_get_properties_t handler = Z_OBJ_HANDLER_PP(array, get_properties);\n\t\tif ((handler != std_object_handlers.get_properties && handler != spl_array_get_properties)\n\t\t|| !spl_array_get_hash_table(intern, 0 TSRMLS_CC)) {\n\t\t\tzend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, \"Overloaded object of type %s is not compatible with %s\", Z_OBJCE_PP(array)->name, intern->std.ce->name);\n\t\t}\n\t}\n\n\tspl_array_rewind(intern TSRMLS_CC);\n}\n","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":356640,"func":"submit_page_section(struct dio *dio, struct page *page,\n\t\tunsigned offset, unsigned len, sector_t blocknr)\n{\n\tint ret = 0;\n\n\tif (dio->rw & WRITE) {\n\t\t\/*\n\t\t * Read accounting is performed in submit_bio()\n\t\t *\/\n\t\ttask_io_account_write(len);\n\t}\n\n\t\/*\n\t * Can we just grow the current page's presence in the dio?\n\t *\/\n\tif (\t(dio->cur_page == page) &&\n\t\t(dio->cur_page_offset + dio->cur_page_len == offset) &&\n\t\t(dio->cur_page_block +\n\t\t\t(dio->cur_page_len >> dio->blkbits) == blocknr)) {\n\t\tdio->cur_page_len += len;\n\n\t\t\/*\n\t\t * If dio->boundary then we want to schedule the IO now to\n\t\t * avoid metadata seeks.\n\t\t *\/\n\t\tif (dio->boundary) {\n\t\t\tret = dio_send_cur_page(dio);\n\t\t\tpage_cache_release(dio->cur_page);\n\t\t\tdio->cur_page = NULL;\n\t\t}\n\t\tgoto out;\n\t}\n\n\t\/*\n\t * If there's a deferred page already there then send it.\n\t *\/\n\tif (dio->cur_page) {\n\t\tret = dio_send_cur_page(dio);\n\t\tpage_cache_release(dio->cur_page);\n\t\tdio->cur_page = NULL;\n\t\tif (ret)\n\t\t\tgoto out;\n\t}\n\n\tpage_cache_get(page);\t\t\/* It is in dio *\/\n\tdio->cur_page = page;\n\tdio->cur_page_offset = offset;\n\tdio->cur_page_len = len;\n\tdio->cur_page_block = blocknr;\nout:\n\treturn ret;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":151661,"func":"static int xemaclite_open(struct net_device *dev)\n{\n\tstruct net_local *lp = netdev_priv(dev);\n\tint retval;\n\n\t\/* Just to be safe, stop the device first *\/\n\txemaclite_disable_interrupts(lp);\n\n\tif (lp->phy_node) {\n\t\tu32 bmcr;\n\n\t\tlp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,\n\t\t\t\t\t     xemaclite_adjust_link, 0,\n\t\t\t\t\t     PHY_INTERFACE_MODE_MII);\n\t\tif (!lp->phy_dev) {\n\t\t\tdev_err(&lp->ndev->dev, \"of_phy_connect() failed\\n\");\n\t\t\treturn -ENODEV;\n\t\t}\n\n\t\t\/* EmacLite doesn't support giga-bit speeds *\/\n\t\tphy_set_max_speed(lp->phy_dev, SPEED_100);\n\n\t\t\/* Don't advertise 1000BASE-T Full\/Half duplex speeds *\/\n\t\tphy_write(lp->phy_dev, MII_CTRL1000, 0);\n\n\t\t\/* Advertise only 10 and 100mbps full\/half duplex speeds *\/\n\t\tphy_write(lp->phy_dev, MII_ADVERTISE, ADVERTISE_ALL |\n\t\t\t  ADVERTISE_CSMA);\n\n\t\t\/* Restart auto negotiation *\/\n\t\tbmcr = phy_read(lp->phy_dev, MII_BMCR);\n\t\tbmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);\n\t\tphy_write(lp->phy_dev, MII_BMCR, bmcr);\n\n\t\tphy_start(lp->phy_dev);\n\t}\n\n\t\/* Set the MAC address each time opened *\/\n\txemaclite_update_address(lp, dev->dev_addr);\n\n\t\/* Grab the IRQ *\/\n\tretval = request_irq(dev->irq, xemaclite_interrupt, 0, dev->name, dev);\n\tif (retval) {\n\t\tdev_err(&lp->ndev->dev, \"Could not allocate interrupt %d\\n\",\n\t\t\tdev->irq);\n\t\tif (lp->phy_dev)\n\t\t\tphy_disconnect(lp->phy_dev);\n\t\tlp->phy_dev = NULL;\n\n\t\treturn retval;\n\t}\n\n\t\/* Enable Interrupts *\/\n\txemaclite_enable_interrupts(lp);\n\n\t\/* We're ready to go *\/\n\tnetif_start_queue(dev);\n\n\treturn 0;\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":83063,"func":"static int set_array_info(struct mddev *mddev, mdu_array_info_t *info)\n{\n\n\tif (info->raid_disks == 0) {\n\t\t\/* just setting version number for superblock loading *\/\n\t\tif (info->major_version < 0 ||\n\t\t    info->major_version >= ARRAY_SIZE(super_types) ||\n\t\t    super_types[info->major_version].name == NULL) {\n\t\t\t\/* maybe try to auto-load a module? *\/\n\t\t\tprintk(KERN_INFO\n\t\t\t\t\"md: superblock version %d not known\\n\",\n\t\t\t\tinfo->major_version);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tmddev->major_version = info->major_version;\n\t\tmddev->minor_version = info->minor_version;\n\t\tmddev->patch_version = info->patch_version;\n\t\tmddev->persistent = !info->not_persistent;\n\t\t\/* ensure mddev_put doesn't delete this now that there\n\t\t * is some minimal configuration.\n\t\t *\/\n\t\tmddev->ctime         = get_seconds();\n\t\treturn 0;\n\t}\n\tmddev->major_version = MD_MAJOR_VERSION;\n\tmddev->minor_version = MD_MINOR_VERSION;\n\tmddev->patch_version = MD_PATCHLEVEL_VERSION;\n\tmddev->ctime         = get_seconds();\n\n\tmddev->level         = info->level;\n\tmddev->clevel[0]     = 0;\n\tmddev->dev_sectors   = 2 * (sector_t)info->size;\n\tmddev->raid_disks    = info->raid_disks;\n\t\/* don't set md_minor, it is determined by which \/dev\/md* was\n\t * openned\n\t *\/\n\tif (info->state & (1<recovery_cp = MaxSector;\n\telse\n\t\tmddev->recovery_cp = 0;\n\tmddev->persistent    = ! info->not_persistent;\n\tmddev->external\t     = 0;\n\n\tmddev->layout        = info->layout;\n\tmddev->chunk_sectors = info->chunk_size >> 9;\n\n\tmddev->max_disks     = MD_SB_DISKS;\n\n\tif (mddev->persistent)\n\t\tmddev->flags         = 0;\n\tset_bit(MD_CHANGE_DEVS, &mddev->flags);\n\n\tmddev->bitmap_info.default_offset = MD_SB_BYTES >> 9;\n\tmddev->bitmap_info.default_space = 64*2 - (MD_SB_BYTES >> 9);\n\tmddev->bitmap_info.offset = 0;\n\n\tmddev->reshape_position = MaxSector;\n\n\t\/*\n\t * Generate a 128 bit UUID\n\t *\/\n\tget_random_bytes(mddev->uuid, 16);\n\n\tmddev->new_level = mddev->level;\n\tmddev->new_chunk_sectors = mddev->chunk_sectors;\n\tmddev->new_layout = mddev->layout;\n\tmddev->delta_disks = 0;\n\tmddev->reshape_backwards = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":612,"total_token_length":848,"max_tokens_setting":1024}
+{"idx":218436,"func":"void smp_br_process_pairing_command(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {\n uint8_t* p = p_data->p_data;\n  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(p_cb->pairing_bda);\n\n  SMP_TRACE_DEBUG(\"%s\", __func__);\n \/* rejecting BR pairing request over non-SC BR link *\/\n if (!p_dev_rec->new_encryption_key_is_p256 && p_cb->role == HCI_ROLE_SLAVE) {\n    tSMP_INT_DATA smp_int_data;\n    smp_int_data.status = SMP_XTRANS_DERIVE_NOT_ALLOW;\n    smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data);\n return;\n }\n\n \/* erase all keys if it is slave proc pairing req*\/\n if (p_dev_rec && (p_cb->role == HCI_ROLE_SLAVE))\n    btm_sec_clear_ble_keys(p_dev_rec);\n\n  p_cb->flags |= SMP_PAIR_FLAG_ENC_AFTER_PAIR;\n\n  STREAM_TO_UINT8(p_cb->peer_io_caps, p);\n  STREAM_TO_UINT8(p_cb->peer_oob_flag, p);\n  STREAM_TO_UINT8(p_cb->peer_auth_req, p);\n  STREAM_TO_UINT8(p_cb->peer_enc_size, p);\n  STREAM_TO_UINT8(p_cb->peer_i_key, p);\n  STREAM_TO_UINT8(p_cb->peer_r_key, p);\n\n if (smp_command_has_invalid_parameters(p_cb)) {\n    tSMP_INT_DATA smp_int_data;\n    smp_int_data.status = SMP_INVALID_PARAMETERS;\n    smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data);\n return;\n }\n\n \/* peer (master) started pairing sending Pairing Request *\/\n \/* or being master device always use received i\/r key as keys to distribute *\/\n  p_cb->local_i_key = p_cb->peer_i_key;\n  p_cb->local_r_key = p_cb->peer_r_key;\n\n if (p_cb->role == HCI_ROLE_SLAVE) {\n    p_dev_rec->new_encryption_key_is_p256 = false;\n \/* shortcut to skip Security Grant step *\/\n    p_cb->cb_evt = SMP_BR_KEYS_REQ_EVT;\n } else {\n \/* Master receives pairing response *\/\n    SMP_TRACE_DEBUG(\n \"%s master rcvs valid PAIRING RESPONSE.\"\n \" Supposed to move to key distribution phase. \",\n        __func__);\n }\n\n \/* auth_req received via BR\/EDR SM channel is set to 0,\n     but everything derived\/exchanged has to be saved *\/\n  p_cb->peer_auth_req |= SMP_AUTH_BOND;\n  p_cb->loc_auth_req |= SMP_AUTH_BOND;\n}\n","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":131021,"func":"ex_tabs(exarg_T *eap UNUSED)\n{\n    tabpage_T\t*tp;\n    win_T\t*wp;\n    int\t\ttabcount = 1;\n\n    msg_start();\n    msg_scroll = TRUE;\n    for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next)\n    {\n\tmsg_putchar('\\n');\n\tvim_snprintf((char *)IObuff, IOSIZE, _(\"Tab page %d\"), tabcount++);\n\tmsg_outtrans_attr(IObuff, HL_ATTR(HLF_T));\n\tout_flush();\t    \/* output one line at a time *\/\n\tui_breakcheck();\n\n\tif (tp  == curtab)\n\t    wp = firstwin;\n\telse\n\t    wp = tp->tp_firstwin;\n\tfor ( ; wp != NULL && !got_int; wp = wp->w_next)\n\t{\n\t    msg_putchar('\\n');\n\t    msg_putchar(wp == curwin ? '>' : ' ');\n\t    msg_putchar(' ');\n\t    msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');\n\t    msg_putchar(' ');\n\t    if (buf_spname(wp->w_buffer) != NULL)\n\t\tvim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1);\n\t    else\n\t\thome_replace(wp->w_buffer, wp->w_buffer->b_fname,\n\t\t\t\t\t\t\tIObuff, IOSIZE, TRUE);\n\t    msg_outtrans(IObuff);\n\t    out_flush();\t    \/* output one line at a time *\/\n\t    ui_breakcheck();\n\t}\n    }\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":348107,"func":"int dns_read_name(unsigned char *buffer, unsigned char *bufend,\n\t\t  unsigned char *name, char *destination, int dest_len,\n\t\t  int *offset)\n{\n\tint nb_bytes = 0, n = 0;\n\tint label_len;\n\tunsigned char *reader = name;\n\tchar *dest = destination;\n\n\twhile (1) {\n\t\t\/* Name compression is in use *\/\n\t\tif ((*reader & 0xc0) == 0xc0) {\n\t\t\t\/* Must point BEFORE current position *\/\n\t\t\tif ((buffer + reader[1]) > reader)\n\t\t\t\tgoto err;\n\n\t\t\tn = dns_read_name(buffer, bufend, buffer + reader[1],\n\t\t\t\t\t  dest, dest_len - nb_bytes, offset);\n\t\t\tif (n == 0)\n\t\t\t\tgoto err;\n\n\t\t\tdest     += n;\n\t\t\tnb_bytes += n;\n\t\t\tgoto out;\n\t\t}\n\n\t\tlabel_len = *reader;\n\t\tif (label_len == 0)\n\t\t\tgoto out;\n\n\t\t\/* Check if:\n\t\t *  - we won't read outside the buffer\n\t\t *  - there is enough place in the destination\n\t\t *\/\n\t\tif ((reader + label_len >= bufend) || (nb_bytes + label_len >= dest_len))\n\t\t\tgoto err;\n\n\t\t\/* +1 to take label len + label string *\/\n\t\tlabel_len++;\n\n\t\tmemcpy(dest, reader, label_len);\n\n\t\tdest     += label_len;\n\t\tnb_bytes += label_len;\n\t\treader   += label_len;\n\t}\n\n  out:\n\t\/* offset computation:\n\t * parse from  until finding either NULL or a pointer \"c0xx\"\n\t *\/\n\treader  = name;\n\t*offset = 0;\n\twhile (reader < bufend) {\n\t\tif ((reader[0] & 0xc0) == 0xc0) {\n\t\t\t*offset += 2;\n\t\t\tbreak;\n\t\t}\n\t\telse if (*reader == 0) {\n\t\t\t*offset += 1;\n\t\t\tbreak;\n\t\t}\n\t\t*offset += 1;\n\t\t++reader;\n\t}\n\treturn nb_bytes;\n\n  err:\n\treturn 0;\n}","target":1,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":119605,"func":"void trace_printk_init_buffers(void)\n{\n\tif (buffers_allocated)\n\t\treturn;\n\n\tif (alloc_percpu_trace_buffer())\n\t\treturn;\n\n\t\/* trace_printk() is for debug use only. Don't use it in production. *\/\n\n\tpr_warn(\"\\n\");\n\tpr_warn(\"**********************************************************\\n\");\n\tpr_warn(\"**   NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE   **\\n\");\n\tpr_warn(\"**                                                      **\\n\");\n\tpr_warn(\"** trace_printk() being used. Allocating extra memory.  **\\n\");\n\tpr_warn(\"**                                                      **\\n\");\n\tpr_warn(\"** This means that this is a DEBUG kernel and it is     **\\n\");\n\tpr_warn(\"** unsafe for production use.                           **\\n\");\n\tpr_warn(\"**                                                      **\\n\");\n\tpr_warn(\"** If you see this message and you are not debugging    **\\n\");\n\tpr_warn(\"** the kernel, report this immediately to your vendor!  **\\n\");\n\tpr_warn(\"**                                                      **\\n\");\n\tpr_warn(\"**   NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE   **\\n\");\n\tpr_warn(\"**********************************************************\\n\");\n\n\t\/* Expand the buffers to set size *\/\n\ttracing_update_buffers();\n\n\tbuffers_allocated = 1;\n\n\t\/*\n\t * trace_printk_init_buffers() can be called by modules.\n\t * If that happens, then we need to start cmdline recording\n\t * directly here. If the global_trace.buffer is already\n\t * allocated here, then this was called by module code.\n\t *\/\n\tif (global_trace.trace_buffer.buffer)\n\t\ttracing_start_cmdline_record();\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":346232,"func":"static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, size_t length, size_t displacement TSRMLS_DC)\n{\n\tunsigned exif_value_2a, offset_of_ifd;\n\n\t\/* set the thumbnail stuff to nothing so we can test to see if they get set up *\/\n\tif (memcmp(CharBuf, \"II\", 2) == 0) {\n\t\tImageInfo->motorola_intel = 0;\n\t} else if (memcmp(CharBuf, \"MM\", 2) == 0) {\n\t\tImageInfo->motorola_intel = 1;\n\t} else {\n\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Invalid TIFF alignment marker\");\n\t\treturn;\n\t}\n\n\t\/* Check the next two values for correctness. *\/\n\texif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel);\n\toffset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel);\n\tif ( exif_value_2a != 0x2a || offset_of_ifd < 0x08) {\n\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Invalid TIFF start (1)\");\n\t\treturn;\n\t}\n\tif (offset_of_ifd > length) {\n\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Invalid IFD start\");\n\t\treturn;\n\t}\n\n\tImageInfo->sections_found |= FOUND_IFD0;\n\t\/* First directory starts at offset 8. Offsets starts at 0. *\/\n\texif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, CharBuf, length\/*-14*\/, displacement, SECTION_IFD0 TSRMLS_CC);\n\n#ifdef EXIF_DEBUG\n\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Process TIFF in JPEG done\");\n#endif\n\n\t\/* Compute the CCD width, in milimeters. *\/\n\tif (ImageInfo->FocalplaneXRes != 0) {\n\t\tImageInfo->CCDWidth = (float)(ImageInfo->ExifImageWidth * ImageInfo->FocalplaneUnits \/ ImageInfo->FocalplaneXRes);\n\t}\n}","target":1,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":323255,"func":"static int compat_decode(AVCodecContext *avctx, AVFrame *frame,\n\n                         int *got_frame, AVPacket *pkt)\n\n{\n\n    AVCodecInternal *avci = avctx->internal;\n\n    int ret;\n\n\n\n    av_assert0(avci->compat_decode_consumed == 0);\n\n\n\n    *got_frame = 0;\n\n    avci->compat_decode = 1;\n\n\n\n    if (avci->compat_decode_partial_size > 0 &&\n\n        avci->compat_decode_partial_size != pkt->size) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"Got unexpected packet size after a partial decode\\n\");\n\n        ret = AVERROR(EINVAL);\n\n        goto finish;\n\n    }\n\n\n\n    if (!avci->compat_decode_partial_size) {\n\n        ret = avcodec_send_packet(avctx, pkt);\n\n        if (ret == AVERROR_EOF)\n\n            ret = 0;\n\n        else if (ret == AVERROR(EAGAIN)) {\n\n            \/* we fully drain all the output in each decode call, so this should not\n\n             * ever happen *\/\n\n            ret = AVERROR_BUG;\n\n            goto finish;\n\n        } else if (ret < 0)\n\n            goto finish;\n\n    }\n\n\n\n    while (ret >= 0) {\n\n        ret = avcodec_receive_frame(avctx, frame);\n\n        if (ret < 0) {\n\n            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)\n\n                ret = 0;\n\n            goto finish;\n\n        }\n\n\n\n        if (frame != avci->compat_decode_frame) {\n\n            if (!avctx->refcounted_frames) {\n\n                ret = unrefcount_frame(avci, frame);\n\n                if (ret < 0)\n\n                    goto finish;\n\n            }\n\n\n\n            *got_frame = 1;\n\n            frame = avci->compat_decode_frame;\n\n        } else {\n\n            if (!avci->compat_decode_warned) {\n\n                av_log(avctx, AV_LOG_WARNING, \"The deprecated avcodec_decode_* \"\n\n                       \"API cannot return all the frames for this decoder. \"\n\n                       \"Some frames will be dropped. Update your code to the \"\n\n                       \"new decoding API to fix this.\\n\");\n\n                avci->compat_decode_warned = 1;\n\n            }\n\n        }\n\n\n\n        if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size))\n\n            break;\n\n    }\n\n\n\nfinish:\n\n    if (ret == 0) {\n\n        \/* if there are any bsfs then assume full packet is always consumed *\/\n\n        if (avctx->codec->bsfs)\n\n            ret = pkt->size;\n\n        else\n\n            ret = FFMIN(avci->compat_decode_consumed, pkt->size);\n\n    }\n\n    avci->compat_decode_consumed = 0;\n\n    avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;\n\n\n\n    return ret;\n\n}\n","target":1,"code_token_length":606,"total_token_length":842,"max_tokens_setting":1024}
+{"idx":252581,"func":"bool HTMLFormElement::LayoutObjectIsNeeded(const ComputedStyle& style) {\n  if (!was_demoted_)\n    return HTMLElement::LayoutObjectIsNeeded(style);\n\n  ContainerNode* node = parentNode();\n  if (!node || !node->GetLayoutObject())\n    return HTMLElement::LayoutObjectIsNeeded(style);\n  LayoutObject* parent_layout_object = node->GetLayoutObject();\n  bool parent_is_table_element_part =\n      (parent_layout_object->IsTable() && IsHTMLTableElement(*node)) ||\n      (parent_layout_object->IsTableRow() && IsHTMLTableRowElement(*node)) ||\n      (parent_layout_object->IsTableSection() && node->HasTagName(tbodyTag)) ||\n      (parent_layout_object->IsLayoutTableCol() && node->HasTagName(colTag)) ||\n      (parent_layout_object->IsTableCell() && IsHTMLTableRowElement(*node));\n\n  if (!parent_is_table_element_part)\n    return true;\n\n  EDisplay display = style.Display();\n  bool form_is_table_part =\n      display == EDisplay::kTable || display == EDisplay::kInlineTable ||\n      display == EDisplay::kTableRowGroup ||\n      display == EDisplay::kTableHeaderGroup ||\n      display == EDisplay::kTableFooterGroup ||\n      display == EDisplay::kTableRow ||\n      display == EDisplay::kTableColumnGroup ||\n      display == EDisplay::kTableColumn || display == EDisplay::kTableCell ||\n      display == EDisplay::kTableCaption;\n\n  return form_is_table_part;\n}\n","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":301473,"func":"void *Sys_LoadGameDll( const char *name, GetModuleAPIProc **moduleAPI )\n{\n\tvoid\t*libHandle = NULL;\n\tchar\tfilename[MAX_OSPATH];\n\n\tCom_sprintf (filename, sizeof(filename), \"%s\" ARCH_STRING DLL_EXT, name);\n\n#if defined(_DEBUG)\n\tlibHandle = Sys_LoadLibrary( filename );\n\tif ( !libHandle )\n#endif\n\t{\n\t\tUnpackDLLResult unpackResult = Sys_UnpackDLL(filename);\n\t\tif ( !unpackResult.succeeded )\n\t\t{\n\t\t\tif ( Sys_DLLNeedsUnpacking() )\n\t\t\t{\n\t\t\t\tFreeUnpackDLLResult(&unpackResult);\n\t\t\t\tCom_DPrintf( \"Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\\n\", filename );\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlibHandle = Sys_LoadLibrary(unpackResult.tempDLLPath);\n\t\t}\n\n\t\tFreeUnpackDLLResult(&unpackResult);\n\n\t\tif ( !libHandle )\n\t\t{\n#if defined(MACOS_X) && !defined(_JK2EXE)\n\t\t\t\/\/First, look for the old-style mac .bundle that's inside a pk3\n\t\t\t\/\/It's actually zipped, and the zipfile has the same name as 'name'\n\t\t\tlibHandle = Sys_LoadMachOBundle( name );\n#endif\n\n\t\t\tif (!libHandle) {\n\t\t\t\tchar *basepath = Cvar_VariableString( \"fs_basepath\" );\n\t\t\t\tchar *homepath = Cvar_VariableString( \"fs_homepath\" );\n\t\t\t\tchar *cdpath = Cvar_VariableString( \"fs_cdpath\" );\n\t\t\t\tchar *gamedir = Cvar_VariableString( \"fs_game\" );\n#ifdef MACOS_X\n\t\t\t\tchar *apppath = Cvar_VariableString( \"fs_apppath\" );\n#endif\n\n\t\t\t\tconst char *searchPaths[] = {\n\t\t\t\t\thomepath,\n#ifdef MACOS_X\n\t\t\t\t\tapppath,\n#endif\n\t\t\t\t\tbasepath,\n\t\t\t\t\tcdpath,\n\t\t\t\t};\n\t\t\t\tsize_t numPaths = ARRAY_LEN( searchPaths );\n\n\t\t\t\tlibHandle = Sys_LoadDllFromPaths( filename, gamedir, searchPaths, numPaths, SEARCH_PATH_BASE | SEARCH_PATH_MOD, __FUNCTION__ );\n\t\t\t\tif ( !libHandle )\n\t\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n\n\t*moduleAPI = (GetModuleAPIProc *)Sys_LoadFunction( libHandle, \"GetModuleAPI\" );\n\tif ( !*moduleAPI ) {\n\t\tCom_DPrintf ( \"Sys_LoadGameDll(%s) failed to find GetModuleAPI function:\\n...%s!\\n\", name, Sys_LibraryError() );\n\t\tSys_UnloadLibrary( libHandle );\n\t\treturn NULL;\n\t}\n\n\treturn libHandle;\n}","target":0,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":249520,"func":"error::Error GLES2DecoderImpl::HandleResizeCHROMIUM(uint32 immediate_data_size,\n                                                    const void* cmd_data) {\n  const gles2::cmds::ResizeCHROMIUM& c =\n      *static_cast(cmd_data);\n  if (!offscreen_target_frame_buffer_.get() && surface_->DeferDraws())\n    return error::kDeferCommandUntilLater;\n\n  GLuint width = static_cast(c.width);\n  GLuint height = static_cast(c.height);\n  GLfloat scale_factor = c.scale_factor;\n  TRACE_EVENT2(\"gpu\", \"glResizeChromium\", \"width\", width, \"height\", height);\n\n  width = std::max(1U, width);\n  height = std::max(1U, height);\n\n#if defined(OS_POSIX) && !defined(OS_MACOSX) && \\\n    !defined(UI_COMPOSITOR_IMAGE_TRANSPORT)\n  glFinish();\n#endif\n  bool is_offscreen = !!offscreen_target_frame_buffer_.get();\n  if (is_offscreen) {\n    if (!ResizeOffscreenFrameBuffer(gfx::Size(width, height))) {\n      LOG(ERROR) << \"GLES2DecoderImpl: Context lost because \"\n                 << \"ResizeOffscreenFrameBuffer failed.\";\n      return error::kLostContext;\n    }\n  }\n\n  if (!resize_callback_.is_null()) {\n    resize_callback_.Run(gfx::Size(width, height), scale_factor);\n    DCHECK(context_->IsCurrent(surface_.get()));\n    if (!context_->IsCurrent(surface_.get())) {\n      LOG(ERROR) << \"GLES2DecoderImpl: Context lost because context no longer \"\n                 << \"current after resize callback.\";\n      return error::kLostContext;\n    }\n  }\n\n  return error::kNoError;\n}\n","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":83737,"func":"struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags,\n\t\t\t\t       int noblock, int *err)\n{\n\tint error;\n\tstruct sk_buff *skb;\n\tlong timeo;\n\n\ttimeo = sock_rcvtimeo(sk, noblock);\n\n\tpr_debug(\"%s: timeo:%ld, max:%ld\\n\", __func__, timeo,\n\t\t MAX_SCHEDULE_TIMEOUT);\n\n\tdo {\n\t\t\/* Again only user level code calls this function,\n\t\t * so nothing interrupt level\n\t\t * will suddenly eat the receive_queue.\n\t\t *\n\t\t *  Look at current nfs client by the way...\n\t\t *  However, this function was correct in any case. 8)\n\t\t *\/\n\t\tif (flags & MSG_PEEK) {\n\t\t\tskb = skb_peek(&sk->sk_receive_queue);\n\t\t\tif (skb)\n\t\t\t\trefcount_inc(&skb->users);\n\t\t} else {\n\t\t\tskb = __skb_dequeue(&sk->sk_receive_queue);\n\t\t}\n\n\t\tif (skb)\n\t\t\treturn skb;\n\n\t\t\/* Caller is allowed not to check sk->sk_err before calling. *\/\n\t\terror = sock_error(sk);\n\t\tif (error)\n\t\t\tgoto no_packet;\n\n\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\tbreak;\n\n\t\tif (sk_can_busy_loop(sk)) {\n\t\t\tsk_busy_loop(sk, noblock);\n\n\t\t\tif (!skb_queue_empty(&sk->sk_receive_queue))\n\t\t\t\tcontinue;\n\t\t}\n\n\t\t\/* User doesn't want to wait.  *\/\n\t\terror = -EAGAIN;\n\t\tif (!timeo)\n\t\t\tgoto no_packet;\n\t} while (sctp_wait_for_packet(sk, err, &timeo) == 0);\n\n\treturn NULL;\n\nno_packet:\n\t*err = error;\n\treturn NULL;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":40978,"func":"_handel_muc_user(xmpp_stanza_t *const stanza)\n{\n    xmpp_ctx_t *ctx = connection_get_ctx();\n    xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);\n    const char *room = xmpp_stanza_get_from(stanza);\n\n    if (!room) {\n        log_warning(\"Message received with no from attribute, ignoring\");\n        return;\n    }\n\n    \/\/ XEP-0045\n    xmpp_stanza_t *invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE);\n    if (!invite) {\n        return;\n    }\n\n    const char *invitor_jid = xmpp_stanza_get_from(invite);\n    if (!invitor_jid) {\n        log_warning(\"Chat room invite received with no from attribute\");\n        return;\n    }\n\n    Jid *jidp = jid_create(invitor_jid);\n    if (!jidp) {\n        return;\n    }\n    char *invitor = jidp->barejid;\n\n    char *reason = NULL;\n    xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON);\n    if (reason_st) {\n        reason = xmpp_stanza_get_text(reason_st);\n    }\n\n    char *password = NULL;\n    xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD);\n    if (password_st) {\n        password = xmpp_stanza_get_text(password_st);\n    }\n\n    sv_ev_room_invite(INVITE_MEDIATED, invitor, room, reason, password);\n    jid_destroy(jidp);\n    if (reason) {\n        xmpp_free(ctx, reason);\n    }\n    if (password) {\n        xmpp_free(ctx, password);\n    }\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":425646,"func":"CreatePageTable (\r\n  VOID\r\n  )\r\n{\r\n  RETURN_STATUS           Status;\r\n  UINTN                   PhysicalAddressBits;\r\n  UINTN                   NumberOfEntries;\r\n  PAGE_ATTRIBUTE          TopLevelPageAttr;\r\n  UINTN                   PageTable;\r\n  PAGE_ATTRIBUTE          MaxMemoryPage;\r\n  UINTN                   Index;\r\n  UINT64                  AddressEncMask;\r\n  UINT64                  *PageEntry;\r\n  EFI_PHYSICAL_ADDRESS    PhysicalAddress;\r\n\r\n  TopLevelPageAttr = (PAGE_ATTRIBUTE)GetPageTableTopLevelType ();\r\n  PhysicalAddressBits = GetPhysicalAddressWidth ();\r\n  NumberOfEntries = (UINTN)1 << (PhysicalAddressBits -\r\n                                 mPageAttributeTable[TopLevelPageAttr].AddressBitOffset);\r\n\r\n  PageTable = (UINTN) AllocatePageTableMemory (1);\r\n  if (PageTable == 0) {\r\n    return 0;\r\n  }\r\n\r\n  AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask);\r\n  AddressEncMask &= mPageAttributeTable[TopLevelPageAttr].AddressMask;\r\n  MaxMemoryPage = GetMaxMemoryPage (TopLevelPageAttr);\r\n  PageEntry = (UINT64 *)PageTable;\r\n\r\n  PhysicalAddress = 0;\r\n  for (Index = 0; Index < NumberOfEntries; ++Index) {\r\n    *PageEntry = PhysicalAddress | AddressEncMask | PAGE_ATTRIBUTE_BITS;\r\n\r\n    \/\/\r\n    \/\/ Split the top page table down to the maximum page size supported\r\n    \/\/\r\n    if (MaxMemoryPage < TopLevelPageAttr) {\r\n      Status = SplitPage(PageEntry, TopLevelPageAttr, MaxMemoryPage, TRUE);\r\n      ASSERT_EFI_ERROR (Status);\r\n    }\r\n\r\n    if (TopLevelPageAttr == Page1G) {\r\n      \/\/\r\n      \/\/ PDPTE[2:1] (PAE Paging) must be 0. SplitPage() might change them to 1.\r\n      \/\/\r\n      *PageEntry &= ~(UINT64)(IA32_PG_RW | IA32_PG_U);\r\n    }\r\n\r\n    PageEntry += 1;\r\n    PhysicalAddress += mPageAttributeTable[TopLevelPageAttr].Length;\r\n  }\r\n\r\n\r\n  return PageTable;\r\n}\r","target":0,"code_token_length":448,"total_token_length":684,"max_tokens_setting":1024}
+{"idx":152214,"func":"decoding_fgets(char *s, int size, struct tok_state *tok)\n{\n    char *line = NULL;\n    int badchar = 0;\n    for (;;) {\n        if (tok->decoding_state == STATE_NORMAL) {\n            \/* We already have a codec associated with\n               this input. *\/\n            line = fp_readl(s, size, tok);\n            break;\n        } else if (tok->decoding_state == STATE_RAW) {\n            \/* We want a 'raw' read. *\/\n            line = Py_UniversalNewlineFgets(s, size,\n                                            tok->fp, NULL);\n            break;\n        } else {\n            \/* We have not yet determined the encoding.\n               If an encoding is found, use the file-pointer\n               reader functions from now on. *\/\n            if (!check_bom(fp_getc, fp_ungetc, fp_setreadl, tok))\n                return error_ret(tok);\n            assert(tok->decoding_state != STATE_INIT);\n        }\n    }\n    if (line != NULL && tok->lineno < 2 && !tok->read_coding_spec) {\n        if (!check_coding_spec(line, strlen(line), tok, fp_setreadl)) {\n            return error_ret(tok);\n        }\n    }\n#ifndef PGEN\n    \/* The default encoding is UTF-8, so make sure we don't have any\n       non-UTF-8 sequences in it. *\/\n    if (line && !tok->encoding) {\n        unsigned char *c;\n        int length;\n        for (c = (unsigned char *)line; *c; c += length)\n            if (!(length = valid_utf8(c))) {\n                badchar = *c;\n                break;\n            }\n    }\n    if (badchar) {\n        \/* Need to add 1 to the line number, since this line\n           has not been counted, yet.  *\/\n        PyErr_Format(PyExc_SyntaxError,\n                \"Non-UTF-8 code starting with '\\\\x%.2x' \"\n                \"in file %U on line %i, \"\n                \"but no encoding declared; \"\n                \"see http:\/\/python.org\/dev\/peps\/pep-0263\/ for details\",\n                badchar, tok->filename, tok->lineno + 1);\n        return error_ret(tok);\n    }\n#endif\n    return line;\n}","target":0,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":402696,"func":"pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)\n{\n\tpgd_t *pgd;\n\tpud_t *pud;\n\tpmd_t *pmd;\n#ifdef CONFIG_HUGETLB_SUPER_PAGES\n\tpte_t *pte;\n#endif\n\n\t\/* Get the top-level page table entry. *\/\n\tpgd = (pgd_t *)get_pte((pte_t *)mm->pgd, pgd_index(addr), 0);\n\n\t\/* We don't have four levels. *\/\n\tpud = pud_offset(pgd, addr);\n#ifndef __PAGETABLE_PUD_FOLDED\n# error support fourth page table level\n#endif\n\tif (!pud_present(*pud))\n\t\treturn NULL;\n\n\t\/* Check for an L0 huge PTE, if we have three levels. *\/\n#ifndef __PAGETABLE_PMD_FOLDED\n\tif (pud_huge(*pud))\n\t\treturn (pte_t *)pud;\n\n\tpmd = (pmd_t *)get_pte((pte_t *)pud_page_vaddr(*pud),\n\t\t\t       pmd_index(addr), 1);\n\tif (!pmd_present(*pmd))\n\t\treturn NULL;\n#else\n\tpmd = pmd_offset(pud, addr);\n#endif\n\n\t\/* Check for an L1 huge PTE. *\/\n\tif (pmd_huge(*pmd))\n\t\treturn (pte_t *)pmd;\n\n#ifdef CONFIG_HUGETLB_SUPER_PAGES\n\t\/* Check for an L2 huge PTE. *\/\n\tpte = get_pte((pte_t *)pmd_page_vaddr(*pmd), pte_index(addr), 2);\n\tif (!pte_present(*pte))\n\t\treturn NULL;\n\tif (pte_super(*pte))\n\t\treturn pte;\n#endif\n\n\treturn NULL;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":371012,"func":"guestfs___check_netbsd_root (guestfs_h *g, struct inspect_fs *fs)\n{\n\n  if (guestfs_exists (g, \"\/etc\/release\") > 0) {\n    char *major, *minor;\n    if (parse_release_file (g, fs, \"\/etc\/release\") == -1)\n      return -1;\n\n    if (match2 (g, fs->product_name, re_netbsd, &major, &minor)) {\n      fs->type = OS_TYPE_NETBSD;\n      fs->major_version = guestfs___parse_unsigned_int (g, major);\n      free (major);\n      if (fs->major_version == -1) {\n        free (minor);\n        return -1;\n      }\n      fs->minor_version = guestfs___parse_unsigned_int (g, minor);\n      free (minor);\n      if (fs->minor_version == -1)\n        return -1;\n    }\n  } else {\n    return -1;\n  }\n\n  \/* Determine the architecture. *\/\n  check_architecture (g, fs);\n\n  \/* We already know \/etc\/fstab exists because it's part of the test above. *\/\n  const char *configfiles[] = { \"\/etc\/fstab\", NULL };\n  if (inspect_with_augeas (g, fs, configfiles, check_fstab) == -1)\n    return -1;\n\n  \/* Determine hostname. *\/\n  if (check_hostname_unix (g, fs) == -1)\n    return -1;\n\n  return 0;\n}","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":418551,"func":"vm_fault_t vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,\n\t\t\tpmd_t *pmd, pfn_t pfn, bool write)\n{\n\tpgprot_t pgprot = vma->vm_page_prot;\n\tpgtable_t pgtable = NULL;\n\t\/*\n\t * If we had pmd_special, we could avoid all these restrictions,\n\t * but we need to be consistent with PTEs and architectures that\n\t * can't support a 'special' bit.\n\t *\/\n\tBUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) &&\n\t\t\t!pfn_t_devmap(pfn));\n\tBUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) ==\n\t\t\t\t\t\t(VM_PFNMAP|VM_MIXEDMAP));\n\tBUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags));\n\n\tif (addr < vma->vm_start || addr >= vma->vm_end)\n\t\treturn VM_FAULT_SIGBUS;\n\n\tif (arch_needs_pgtable_deposit()) {\n\t\tpgtable = pte_alloc_one(vma->vm_mm, addr);\n\t\tif (!pgtable)\n\t\t\treturn VM_FAULT_OOM;\n\t}\n\n\ttrack_pfn_insert(vma, &pgprot, pfn);\n\n\tinsert_pfn_pmd(vma, addr, pmd, pfn, pgprot, write, pgtable);\n\treturn VM_FAULT_NOPAGE;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":187907,"func":"static void S_AL_NewLoopMaster(src_t *rmSource, qboolean iskilled)\n{\n\tint index;\n\tsrc_t *curSource = NULL;\n\talSfx_t *curSfx;\n\t\n\tcurSfx = &knownSfx[rmSource->sfx];\n\n\tif(rmSource->isPlaying)\n\t\tcurSfx->loopActiveCnt--;\n\tif(iskilled)\n\t\tcurSfx->loopCnt--;\n\t\n\tif(curSfx->loopCnt)\n\t{\n\t\tif(rmSource->priority == SRCPRI_ENTITY)\n\t\t{\n\t\t\tif(!iskilled && rmSource->isPlaying)\n\t\t\t{\n\t\t\t\tS_AL_SaveLoopPos(rmSource, rmSource->alSource);\n\t\t\t}\n\t\t}\n\t\telse if(rmSource == &srcList[curSfx->masterLoopSrc])\n\t\t{\n\t\t\tint firstInactive = -1;\n\n\t\n\t\t\tif(iskilled || curSfx->loopActiveCnt)\n\t\t\t{\n\t\t\t\tfor(index = 0; index < srcCount; index++)\n\t\t\t\t{\n\t\t\t\t\tcurSource = &srcList[index];\n\t\n\t\t\t\t\tif(curSource->sfx == rmSource->sfx && curSource != rmSource &&\n\t\t\t\t\t   curSource->isActive && curSource->isLooping && curSource->priority == SRCPRI_AMBIENT)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(curSource->isPlaying)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcurSfx->masterLoopSrc = index;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(firstInactive < 0)\n\t\t\t\t\t\t\tfirstInactive = index;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t\tif(!curSfx->loopActiveCnt)\n\t\t\t{\n\t\t\t\tif(firstInactive < 0)\n\t\t\t\t{\n\t\t\t\t\tif(iskilled)\n\t\t\t\t\t{\n\t\t\t\t\t\tcurSfx->masterLoopSrc = -1;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tcurSource = rmSource;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tcurSource = &srcList[firstInactive];\n\n\t\t\t\tif(rmSource->isPlaying)\n\t\t\t\t{\n\t\t\t\t\tS_AL_SaveLoopPos(curSource, rmSource->alSource);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcurSource->lastTimePos = rmSource->lastTimePos;\n\t\t\t\t\tcurSource->lastSampleTime = rmSource->lastSampleTime;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t\tcurSfx->masterLoopSrc = -1;\n}\n","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":40029,"func":"nfsd4_decode_layoutcommit(struct nfsd4_compoundargs *argp,\n\t\tstruct nfsd4_layoutcommit *lcp)\n{\n\tDECODE_HEAD;\n\tu32 timechange;\n\n\tREAD_BUF(20);\n\tp = xdr_decode_hyper(p, &lcp->lc_seg.offset);\n\tp = xdr_decode_hyper(p, &lcp->lc_seg.length);\n\tlcp->lc_reclaim = be32_to_cpup(p++);\n\n\tstatus = nfsd4_decode_stateid(argp, &lcp->lc_sid);\n\tif (status)\n\t\treturn status;\n\n\tREAD_BUF(4);\n\tlcp->lc_newoffset = be32_to_cpup(p++);\n\tif (lcp->lc_newoffset) {\n\t\tREAD_BUF(8);\n\t\tp = xdr_decode_hyper(p, &lcp->lc_last_wr);\n\t} else\n\t\tlcp->lc_last_wr = 0;\n\tREAD_BUF(4);\n\ttimechange = be32_to_cpup(p++);\n\tif (timechange) {\n\t\tstatus = nfsd4_decode_time(argp, &lcp->lc_mtime);\n\t\tif (status)\n\t\t\treturn status;\n\t} else {\n\t\tlcp->lc_mtime.tv_nsec = UTIME_NOW;\n\t}\n\tREAD_BUF(8);\n\tlcp->lc_layout_type = be32_to_cpup(p++);\n\n\t\/*\n\t * Save the layout update in XDR format and let the layout driver deal\n\t * with it later.\n\t *\/\n\tlcp->lc_up_len = be32_to_cpup(p++);\n\tif (lcp->lc_up_len > 0) {\n\t\tREAD_BUF(lcp->lc_up_len);\n\t\tREADMEM(lcp->lc_up_layout, lcp->lc_up_len);\n\t}\n\n\tDECODE_TAIL;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":378778,"func":"static int get_external_ip(struct in_addr *ip)\n{\n\tint sock;\n\tstruct addrinfo *addr;\n\tint res;\n\tconst char *getstr = \"GET \/ip\/ HTTP\/1.0\\r\\n\"\n\t\t\/* HTTP 1.0 to avoid chunked transfer coding *\/\n\t\t\"Host: api.externalip.net\\r\\n\\r\\n\";\n\tchar buf[512];\n\tchar *b;\n\tint len;\n\n\tres = getaddrinfo(\"api.externalip.net\", \"80\", NULL, &addr);\n\tif (res < 0) return 1;\n\n\tsock = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);\n\tif (sock < 0) {\n\t\tfreeaddrinfo(addr);\n\t\treturn 2;\n\t}\n\n\tres = connect(sock, addr->ai_addr, addr->ai_addrlen);\n\tfreeaddrinfo(addr);\n\tif (res < 0) return 3;\n\n\tres = write(sock, getstr, strlen(getstr));\n\tif (res != strlen(getstr)) return 4;\n\n\t\/* Zero buf before receiving, leave at least one zero at the end *\/\n\tmemset(buf, 0, sizeof(buf));\n\tres = read(sock, buf, sizeof(buf) - 1);\n\tif (res < 0) return 5;\n\tlen = res;\n\n\tres = close(sock);\n\tif (res < 0) return 6;\n\n\tb = buf;\n\twhile (len > 9) {\n\t\t\/* Look for split between headers and data *\/\n\t\tif (strncmp(\"\\r\\n\\r\\n\", b, 4) == 0) break;\n\t\tb++;\n\t\tlen--;\n\t}\n\tif (len < 10) return 7;\n\tb += 4;\n\n\tres = inet_aton(b, ip);\n\treturn (res == 0);\n}","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":513367,"func":"ProcessInput2(ibuf, ilen)\nchar *ibuf;\nint ilen;\n{\n  char *s;\n  int ch, slen;\n  struct action *ktabp;\n\n  debug1(\"ProcessInput2: %d bytes\\n\", ilen);\n  while (ilen && display)\n    {\n      debug1(\" - ilen now %d bytes\\n\", ilen);\n      flayer = D_forecv->c_layer;\n      fore = D_fore;\n      slen = ilen;\n      s = ibuf;\n      if (!D_ESCseen)\n\t{\n\t  while (ilen > 0)\n\t    {\n\t      if ((unsigned char)*s++ == D_user->u_Esc)\n\t\tbreak;\n\t      ilen--;\n\t    }\n\t  slen -= ilen;\n\t  if (slen)\n\t    DoProcess(fore, &ibuf, &slen, 0);\n\t  if (--ilen == 0)\n\t    {\n\t      D_ESCseen = ktab;\n\t      WindowChanged(fore, 'E');\n\t    }\n\t}\n      if (ilen <= 0)\n        return;\n      ktabp = D_ESCseen ? D_ESCseen : ktab;\n      if (D_ESCseen)\n        {\n          D_ESCseen = 0;\n          WindowChanged(fore, 'E');\n        }\n      ch = (unsigned char)*s;\n\n      \/* \n       * As users have different esc characters, but a common ktab[],\n       * we fold back the users esc and meta-esc key to the Default keys\n       * that can be looked up in the ktab[]. grmbl. jw.\n       * XXX: make ktab[] a per user thing.\n       *\/\n      if (ch == D_user->u_Esc) \n        ch = DefaultEsc;\n      else if (ch == D_user->u_MetaEsc) \n        ch = DefaultMetaEsc;\n\n      if (ch >= 0)\n        DoAction(&ktabp[ch], ch);\n      ibuf = (char *)(s + 1);\n      ilen--;\n    }\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":194430,"func":"unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,\n                                   const unsigned char* image, unsigned w, unsigned h,\n                                   const LodePNGColorMode* mode_in)\n{\n  LodePNGColorProfile prof;\n  unsigned error = 0;\n  unsigned i, n, palettebits, grey_ok, palette_ok;\n\n  lodepng_color_profile_init(&prof);\n  error = get_color_profile(&prof, image, w, h, mode_in);\n  if(error) return error;\n  mode_out->key_defined = 0;\n\n  if(prof.key && w * h <= 16) prof.alpha = 1; \/*too few pixels to justify tRNS chunk overhead*\/\n  grey_ok = !prof.colored && !prof.alpha; \/*grey without alpha, with potentially low bits*\/\n  n = prof.numcolors;\n  palettebits = n <= 2 ? 1 : (n <= 4 ? 2 : (n <= 16 ? 4 : 8));\n  palette_ok = n <= 256 && (n * 2 < w * h) && prof.bits <= 8;\n  if(w * h < n * 2) palette_ok = 0; \/*don't add palette overhead if image has only a few pixels*\/\n  if(grey_ok && prof.bits <= palettebits) palette_ok = 0; \/*grey is less overhead*\/\n\n  if(palette_ok)\n  {\n    unsigned char* p = prof.palette;\n    lodepng_palette_clear(mode_out); \/*remove potential earlier palette*\/\n    for(i = 0; i < prof.numcolors; i++)\n    {\n      error = lodepng_palette_add(mode_out, p[i * 4 + 0], p[i * 4 + 1], p[i * 4 + 2], p[i * 4 + 3]);\n      if(error) break;\n    }\n\n    mode_out->colortype = LCT_PALETTE;\n    mode_out->bitdepth = palettebits;\n\n    if(mode_in->colortype == LCT_PALETTE && mode_in->palettesize >= mode_out->palettesize\n        && mode_in->bitdepth == mode_out->bitdepth)\n    {\n      \/*If input should have same palette colors, keep original to preserve its order and prevent conversion*\/\n      lodepng_color_mode_cleanup(mode_out);\n      lodepng_color_mode_copy(mode_out, mode_in);\n    }\n  }\n  else \/*8-bit or 16-bit per channel*\/\n  {\n    mode_out->bitdepth = prof.bits;\n    mode_out->colortype = prof.alpha ? (prof.colored ? LCT_RGBA : LCT_GREY_ALPHA)\n                                     : (prof.colored ? LCT_RGB : LCT_GREY);\n\n    if(prof.key && !prof.alpha)\n    {\n      unsigned mask = (1u << mode_out->bitdepth) - 1u; \/*profile always uses 16-bit, mask converts it*\/\n      mode_out->key_r = prof.key_r & mask;\n      mode_out->key_g = prof.key_g & mask;\n      mode_out->key_b = prof.key_b & mask;\n      mode_out->key_defined = 1;\n    }\n  }\n\n  return error;\n}\n","target":0,"code_token_length":682,"total_token_length":918,"max_tokens_setting":1024}
+{"idx":497092,"func":"static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,\n                                   enum RawDataBlockType type, int elem_id,\n                                   enum CouplingPoint coupling_point,\n                                   void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))\n{\n    int i, c;\n\n    for (i = 0; i < MAX_ELEM_ID; i++) {\n        ChannelElement *cce = ac->che[TYPE_CCE][i];\n        int index = 0;\n\n        if (cce && cce->coup.coupling_point == coupling_point) {\n            ChannelCoupling *coup = &cce->coup;\n\n            for (c = 0; c <= coup->num_coupled; c++) {\n                if (coup->type[c] == type && coup->id_select[c] == elem_id) {\n                    if (coup->ch_select[c] != 1) {\n                        apply_coupling_method(ac, &cc->ch[0], cce, index);\n                        if (coup->ch_select[c] != 0)\n                            index++;\n                    }\n                    if (coup->ch_select[c] != 2)\n                        apply_coupling_method(ac, &cc->ch[1], cce, index++);\n                } else\n                    index += 1 + (coup->ch_select[c] == 3);\n            }\n        }\n    }\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":115079,"func":"static inline void find_entity_for_char(\n\tunsigned int k,\n\tenum entity_charset charset,\n\tconst entity_stage1_row *table,\n\tconst unsigned char **entity,\n\tsize_t *entity_len,\n\tunsigned char *old,\n\tsize_t oldlen,\n\tsize_t *cursor)\n{\n\tunsigned stage1_idx = ENT_STAGE1_INDEX(k);\n\tconst entity_stage3_row *c;\n\n\tif (stage1_idx > 0x1D) {\n\t\t*entity     = NULL;\n\t\t*entity_len = 0;\n\t\treturn;\n\t}\n\n\tc = &table[stage1_idx][ENT_STAGE2_INDEX(k)][ENT_STAGE3_INDEX(k)];\n\n\tif (!c->ambiguous) {\n\t\t*entity     = (const unsigned char *)c->data.ent.entity;\n\t\t*entity_len = c->data.ent.entity_len;\n\t} else {\n\t\t\/* peek at next char *\/\n\t\tsize_t\t cursor_before\t= *cursor;\n\t\tint\t\t status\t\t\t= SUCCESS;\n\t\tunsigned next_char;\n\n\t\tif (!(*cursor < oldlen))\n\t\t\tgoto no_suitable_2nd;\n\n\t\tnext_char = get_next_char(charset, old, oldlen, cursor, &status);\n\n\t\tif (status == FAILURE)\n\t\t\tgoto no_suitable_2nd;\n\n\t\t{\n\t\t\tconst entity_multicodepoint_row *s, *e;\n\n\t\t\ts = &c->data.multicodepoint_table[1];\n\t\t\te = s - 1 + c->data.multicodepoint_table[0].leading_entry.size;\n\t\t\t\/* we could do a binary search but it's not worth it since we have\n\t\t\t * at most two entries... *\/\n\t\t\tfor ( ; s <= e; s++) {\n\t\t\t\tif (s->normal_entry.second_cp == next_char) {\n\t\t\t\t\t*entity     = s->normal_entry.entity;\n\t\t\t\t\t*entity_len = s->normal_entry.entity_len;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\nno_suitable_2nd:\n\t\t*cursor = cursor_before;\n\t\t*entity = (const unsigned char *)\n\t\t\tc->data.multicodepoint_table[0].leading_entry.default_entity;\n\t\t*entity_len = c->data.multicodepoint_table[0].leading_entry.default_entity_len;\n\t}\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":408660,"func":"static int netlink_dump(struct sock *sk)\n{\n\tstruct netlink_sock *nlk = nlk_sk(sk);\n\tstruct netlink_callback *cb;\n\tstruct sk_buff *skb = NULL;\n\tstruct nlmsghdr *nlh;\n\tstruct module *module;\n\tint err = -ENOBUFS;\n\tint alloc_min_size;\n\tint alloc_size;\n\n\tmutex_lock(nlk->cb_mutex);\n\tif (!nlk->cb_running) {\n\t\terr = -EINVAL;\n\t\tgoto errout_skb;\n\t}\n\n\tif (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)\n\t\tgoto errout_skb;\n\n\t\/* NLMSG_GOODSIZE is small to avoid high order allocations being\n\t * required, but it makes sense to _attempt_ a 16K bytes allocation\n\t * to reduce number of system calls on dump operations, if user\n\t * ever provided a big enough buffer.\n\t *\/\n\tcb = &nlk->cb;\n\talloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);\n\n\tif (alloc_min_size < nlk->max_recvmsg_len) {\n\t\talloc_size = nlk->max_recvmsg_len;\n\t\tskb = alloc_skb(alloc_size,\n\t\t\t\t(GFP_KERNEL & ~__GFP_DIRECT_RECLAIM) |\n\t\t\t\t__GFP_NOWARN | __GFP_NORETRY);\n\t}\n\tif (!skb) {\n\t\talloc_size = alloc_min_size;\n\t\tskb = alloc_skb(alloc_size, GFP_KERNEL);\n\t}\n\tif (!skb)\n\t\tgoto errout_skb;\n\n\t\/* Trim skb to allocated size. User is expected to provide buffer as\n\t * large as max(min_dump_alloc, 16KiB (mac_recvmsg_len capped at\n\t * netlink_recvmsg())). dump will pack as many smaller messages as\n\t * could fit within the allocated skb. skb is typically allocated\n\t * with larger space than required (could be as much as near 2x the\n\t * requested size with align to next power of 2 approach). Allowing\n\t * dump to use the excess space makes it difficult for a user to have a\n\t * reasonable static buffer based on the expected largest dump of a\n\t * single netdev. The outcome is MSG_TRUNC error.\n\t *\/\n\tskb_reserve(skb, skb_tailroom(skb) - alloc_size);\n\tnetlink_skb_set_owner_r(skb, sk);\n\n\tif (nlk->dump_done_errno > 0)\n\t\tnlk->dump_done_errno = cb->dump(skb, cb);\n\n\tif (nlk->dump_done_errno > 0 ||\n\t    skb_tailroom(skb) < nlmsg_total_size(sizeof(nlk->dump_done_errno))) {\n\t\tmutex_unlock(nlk->cb_mutex);\n\n\t\tif (sk_filter(sk, skb))\n\t\t\tkfree_skb(skb);\n\t\telse\n\t\t\t__netlink_sendskb(sk, skb);\n\t\treturn 0;\n\t}\n\n\tnlh = nlmsg_put_answer(skb, cb, NLMSG_DONE,\n\t\t\t       sizeof(nlk->dump_done_errno), NLM_F_MULTI);\n\tif (WARN_ON(!nlh))\n\t\tgoto errout_skb;\n\n\tnl_dump_check_consistent(cb, nlh);\n\n\tmemcpy(nlmsg_data(nlh), &nlk->dump_done_errno,\n\t       sizeof(nlk->dump_done_errno));\n\n\tif (sk_filter(sk, skb))\n\t\tkfree_skb(skb);\n\telse\n\t\t__netlink_sendskb(sk, skb);\n\n\tif (cb->done)\n\t\tcb->done(cb);\n\n\tnlk->cb_running = false;\n\tmodule = cb->module;\n\tskb = cb->skb;\n\tmutex_unlock(nlk->cb_mutex);\n\tmodule_put(module);\n\tconsume_skb(skb);\n\treturn 0;\n\nerrout_skb:\n\tmutex_unlock(nlk->cb_mutex);\n\tkfree_skb(skb);\n\treturn err;\n}","target":0,"code_token_length":784,"total_token_length":1020,"max_tokens_setting":1024}
+{"idx":415795,"func":"char *lxc_string_replace(const char *needle, const char *replacement, const char *haystack)\n{\n\tssize_t len = -1, saved_len = -1;\n\tchar *result = NULL;\n\tsize_t replacement_len = strlen(replacement);\n\tsize_t needle_len = strlen(needle);\n\n\t\/* should be executed exactly twice *\/\n\twhile (len == -1 || result == NULL) {\n\t\tchar *p;\n\t\tchar *last_p;\n\t\tssize_t part_len;\n\n\t\tif (len != -1) {\n\t\t\tresult = calloc(1, len + 1);\n\t\t\tif (!result)\n\t\t\t\treturn NULL;\n\t\t\tsaved_len = len;\n\t\t}\n\n\t\tlen = 0;\n\n\t\tfor (last_p = (char *)haystack, p = strstr(last_p, needle); p; last_p = p, p = strstr(last_p, needle)) {\n\t\t\tpart_len = (ssize_t)(p - last_p);\n\t\t\tif (result && part_len > 0)\n\t\t\t\tmemcpy(&result[len], last_p, part_len);\n\t\t\tlen += part_len;\n\t\t\tif (result && replacement_len > 0)\n\t\t\t\tmemcpy(&result[len], replacement, replacement_len);\n\t\t\tlen += replacement_len;\n\t\t\tp += needle_len;\n\t\t}\n\t\tpart_len = strlen(last_p);\n\t\tif (result && part_len > 0)\n\t\t\tmemcpy(&result[len], last_p, part_len);\n\t\tlen += part_len;\n\t}\n\n\t\/* make sure we did the same thing twice,\n\t * once for calculating length, the other\n\t * time for copying data *\/\n\tif (saved_len != len) {\n\t\tfree(result);\n\t\treturn NULL;\n\t}\n\t\/* make sure we didn't overwrite any buffer,\n\t * due to calloc the string should be 0-terminated *\/\n\tif (result[len] != '\\0') {\n\t\tfree(result);\n\t\treturn NULL;\n\t}\n\n\treturn result;\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":147276,"func":"static bool check_noproxy(const char *name, const char *no_proxy)\n{\n  \/* no_proxy=domain1.dom,host.domain2.dom\n   *   (a comma-separated list of hosts which should\n   *   not be proxied, or an asterisk to override\n   *   all proxy variables)\n   *\/\n  if(no_proxy && no_proxy[0]) {\n    size_t tok_start;\n    size_t tok_end;\n    const char *separator = \", \";\n    size_t no_proxy_len;\n    size_t namelen;\n    char *endptr;\n    if(strcasecompare(\"*\", no_proxy)) {\n      return TRUE;\n    }\n\n    \/* NO_PROXY was specified and it wasn't just an asterisk *\/\n\n    no_proxy_len = strlen(no_proxy);\n    if(name[0] == '[') {\n      \/* IPv6 numerical address *\/\n      endptr = strchr(name, ']');\n      if(!endptr)\n        return FALSE;\n      name++;\n      namelen = endptr - name;\n    }\n    else\n      namelen = strlen(name);\n\n    for(tok_start = 0; tok_start < no_proxy_len; tok_start = tok_end + 1) {\n      while(tok_start < no_proxy_len &&\n            strchr(separator, no_proxy[tok_start]) != NULL) {\n        \/* Look for the beginning of the token. *\/\n        ++tok_start;\n      }\n\n      if(tok_start == no_proxy_len)\n        break; \/* It was all trailing separator chars, no more tokens. *\/\n\n      for(tok_end = tok_start; tok_end < no_proxy_len &&\n            strchr(separator, no_proxy[tok_end]) == NULL; ++tok_end)\n        \/* Look for the end of the token. *\/\n        ;\n\n      \/* To match previous behaviour, where it was necessary to specify\n       * \".local.com\" to prevent matching \"notlocal.com\", we will leave\n       * the '.' off.\n       *\/\n      if(no_proxy[tok_start] == '.')\n        ++tok_start;\n\n      if((tok_end - tok_start) <= namelen) {\n        \/* Match the last part of the name to the domain we are checking. *\/\n        const char *checkn = name + namelen - (tok_end - tok_start);\n        if(strncasecompare(no_proxy + tok_start, checkn,\n                           tok_end - tok_start)) {\n          if((tok_end - tok_start) == namelen || *(checkn - 1) == '.') {\n            \/* We either have an exact match, or the previous character is a .\n             * so it is within the same domain, so no proxy for this host.\n             *\/\n            return TRUE;\n          }\n        }\n      } \/* if((tok_end - tok_start) <= namelen) *\/\n    } \/* for(tok_start = 0; tok_start < no_proxy_len;\n         tok_start = tok_end + 1) *\/\n  } \/* NO_PROXY was specified and it wasn't just an asterisk *\/\n\n  return FALSE;\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":72850,"func":"__hw_perf_event_init(struct perf_event *event)\n{\n\tstruct arm_pmu *armpmu = to_arm_pmu(event->pmu);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tint mapping, err;\n\n\tmapping = armpmu->map_event(event);\n\n\tif (mapping < 0) {\n\t\tpr_debug(\"event %x:%llx not supported\\n\", event->attr.type,\n\t\t\t event->attr.config);\n\t\treturn mapping;\n\t}\n\n\t\/*\n\t * We don't assign an index until we actually place the event onto\n\t * hardware. Use -1 to signify that we haven't decided where to put it\n\t * yet. For SMP systems, each core has it's own PMU so we can't do any\n\t * clever allocation or constraints checking at this point.\n\t *\/\n\thwc->idx\t\t= -1;\n\thwc->config_base\t= 0;\n\thwc->config\t\t= 0;\n\thwc->event_base\t\t= 0;\n\n\t\/*\n\t * Check whether we need to exclude the counter from certain modes.\n\t *\/\n\tif ((!armpmu->set_event_filter ||\n\t     armpmu->set_event_filter(hwc, &event->attr)) &&\n\t     event_requires_mode_exclusion(&event->attr)) {\n\t\tpr_debug(\"ARM performance counters do not support mode exclusion\\n\");\n\t\treturn -EPERM;\n\t}\n\n\t\/*\n\t * Store the event encoding into the config_base field.\n\t *\/\n\thwc->config_base\t    |= (unsigned long)mapping;\n\n\tif (!hwc->sample_period) {\n\t\t\/*\n\t\t * For non-sampling runs, limit the sample_period to half\n\t\t * of the counter width. That way, the new counter value\n\t\t * is far less likely to overtake the previous one unless\n\t\t * you have some serious IRQ latency issues.\n\t\t *\/\n\t\thwc->sample_period  = armpmu->max_period >> 1;\n\t\thwc->last_period    = hwc->sample_period;\n\t\tlocal64_set(&hwc->period_left, hwc->sample_period);\n\t}\n\n\terr = 0;\n\tif (event->group_leader != event) {\n\t\terr = validate_group(event);\n\t\tif (err)\n\t\t\treturn -EINVAL;\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":515479,"func":"Http2Session::Callbacks::Callbacks(bool kHasGetPaddingCallback) {\n  nghttp2_session_callbacks* callbacks_;\n  CHECK_EQ(nghttp2_session_callbacks_new(&callbacks_), 0);\n  callbacks.reset(callbacks_);\n\n  nghttp2_session_callbacks_set_on_begin_headers_callback(\n    callbacks_, OnBeginHeadersCallback);\n  nghttp2_session_callbacks_set_on_header_callback2(\n    callbacks_, OnHeaderCallback);\n  nghttp2_session_callbacks_set_on_frame_recv_callback(\n    callbacks_, OnFrameReceive);\n  nghttp2_session_callbacks_set_on_stream_close_callback(\n    callbacks_, OnStreamClose);\n  nghttp2_session_callbacks_set_on_data_chunk_recv_callback(\n    callbacks_, OnDataChunkReceived);\n  nghttp2_session_callbacks_set_on_frame_not_send_callback(\n    callbacks_, OnFrameNotSent);\n  nghttp2_session_callbacks_set_on_invalid_header_callback2(\n    callbacks_, OnInvalidHeader);\n  nghttp2_session_callbacks_set_error_callback(\n    callbacks_, OnNghttpError);\n  nghttp2_session_callbacks_set_send_data_callback(\n    callbacks_, OnSendData);\n  nghttp2_session_callbacks_set_on_invalid_frame_recv_callback(\n    callbacks_, OnInvalidFrame);\n  nghttp2_session_callbacks_set_on_frame_send_callback(\n    callbacks_, OnFrameSent);\n\n  if (kHasGetPaddingCallback) {\n    nghttp2_session_callbacks_set_select_padding_callback(\n      callbacks_, OnSelectPadding);\n  }\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":190615,"func":"static zend_object_value spl_heap_object_new_ex(zend_class_entry *class_type, spl_heap_object **obj, zval *orig, int clone_orig TSRMLS_DC) \/* {{{ *\/\n{\n\tzend_object_value  retval;\n\tspl_heap_object   *intern;\n\tzend_class_entry  *parent = class_type;\n\tint                inherited = 0;\n\n\tintern = ecalloc(1, sizeof(spl_heap_object));\n\t*obj = intern;\n\tALLOC_INIT_ZVAL(intern->retval);\n\n\tzend_object_std_init(&intern->std, class_type TSRMLS_CC);\n\tobject_properties_init(&intern->std, class_type);\n\n\tintern->flags      = 0;\n\tintern->fptr_cmp   = NULL;\n\tintern->debug_info = NULL;\n\n\tif (orig) {\n\t\tspl_heap_object *other = (spl_heap_object*)zend_object_store_get_object(orig TSRMLS_CC);\n\t\tintern->ce_get_iterator = other->ce_get_iterator;\n\n\t\tif (clone_orig) {\n\t\t\tint i;\n\t\t\tintern->heap = spl_ptr_heap_clone(other->heap TSRMLS_CC);\n\t\t\tfor (i = 0; i < intern->heap->count; ++i) {\n\t\t\t\tif (intern->heap->elements[i]) {\n\t\t\t\t\tZ_ADDREF_P((zval *)intern->heap->elements[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tintern->heap = other->heap;\n\t\t}\n\n\t\tintern->flags = other->flags;\n\t} else {\n\t\tintern->heap = spl_ptr_heap_init(spl_ptr_heap_zval_max_cmp, spl_ptr_heap_zval_ctor, spl_ptr_heap_zval_dtor);\n\t}\n\n\tretval.handlers = &spl_handler_SplHeap;\n\n\twhile (parent) {\n\t\tif (parent == spl_ce_SplPriorityQueue) {\n\t\t\tintern->heap->cmp = spl_ptr_pqueue_zval_cmp;\n\t\t\tintern->flags     = SPL_PQUEUE_EXTR_DATA;\n\t\t\tretval.handlers   = &spl_handler_SplPriorityQueue;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (parent == spl_ce_SplMinHeap) {\n\t\t\tintern->heap->cmp = spl_ptr_heap_zval_min_cmp;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (parent == spl_ce_SplMaxHeap) {\n\t\t\tintern->heap->cmp = spl_ptr_heap_zval_max_cmp;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (parent == spl_ce_SplHeap) {\n\t\t\tbreak;\n\t\t}\n\n\t\tparent = parent->parent;\n\t\tinherited = 1;\n\t}\n\n\tretval.handle   = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, spl_heap_object_free_storage, NULL TSRMLS_CC);\n\n\tif (!parent) { \/* this must never happen *\/\n\t\tphp_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, \"Internal compiler error, Class is not child of SplHeap\");\n\t}\n\n\tif (inherited) {\n\t\tzend_hash_find(&class_type->function_table, \"compare\",    sizeof(\"compare\"),    (void **) &intern->fptr_cmp);\n\t\tif (intern->fptr_cmp->common.scope == parent) {\n\t\t\tintern->fptr_cmp = NULL;\n\t\t}\n\t\tzend_hash_find(&class_type->function_table, \"count\",        sizeof(\"count\"),        (void **) &intern->fptr_count);\n\t\tif (intern->fptr_count->common.scope == parent) {\n\t\t\tintern->fptr_count = NULL;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\/* }}} *\/\n","target":0,"code_token_length":731,"total_token_length":967,"max_tokens_setting":1024}
+{"idx":436447,"func":"static void dualshock4_set_leds_from_id(struct sony_sc *sc)\n{\n\t\/* The first 4 color\/index entries match what the PS4 assigns *\/\n\tstatic const u8 color_code[7][3] = {\n\t\t\t\/* Blue   *\/\t{ 0x00, 0x00, 0x40 },\n\t\t\t\/* Red\t  *\/\t{ 0x40, 0x00, 0x00 },\n\t\t\t\/* Green  *\/\t{ 0x00, 0x40, 0x00 },\n\t\t\t\/* Pink   *\/\t{ 0x20, 0x00, 0x20 },\n\t\t\t\/* Orange *\/\t{ 0x02, 0x01, 0x00 },\n\t\t\t\/* Teal   *\/\t{ 0x00, 0x01, 0x01 },\n\t\t\t\/* White  *\/\t{ 0x01, 0x01, 0x01 }\n\t};\n\n\tint id = sc->device_id;\n\n\tBUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0]));\n\n\tif (id < 0)\n\t\treturn;\n\n\tid %= 7;\n\tmemcpy(sc->led_state, color_code[id], sizeof(color_code[id]));\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":299490,"func":"mime_list_callback (GObject      *source_object,\n                    GAsyncResult *res,\n                    gpointer      user_data)\n{\n    MimeListState *state;\n    NautilusDirectory *directory;\n    GError *error;\n    GList *files, *l;\n    GFileInfo *info;\n\n    state = user_data;\n    directory = state->directory;\n\n    if (g_cancellable_is_cancelled (state->cancellable))\n    {\n        \/* Operation was cancelled. Bail out *\/\n        directory->details->mime_list_in_progress = NULL;\n\n        async_job_end (directory, \"MIME list\");\n        nautilus_directory_async_state_changed (directory);\n\n        mime_list_state_free (state);\n\n        return;\n    }\n\n    g_assert (directory->details->mime_list_in_progress != NULL);\n    g_assert (directory->details->mime_list_in_progress == state);\n\n    error = NULL;\n    files = g_file_enumerator_next_files_finish (state->enumerator,\n                                                 res, &error);\n\n    for (l = files; l != NULL; l = l->next)\n    {\n        info = l->data;\n        mime_list_one (state, info);\n        g_object_unref (info);\n    }\n\n    if (files == NULL)\n    {\n        mime_list_done (state, error != NULL);\n        mime_list_state_free (state);\n    }\n    else\n    {\n        g_file_enumerator_next_files_async (state->enumerator,\n                                            DIRECTORY_LOAD_ITEMS_PER_CALLBACK,\n                                            G_PRIORITY_DEFAULT,\n                                            state->cancellable,\n                                            mime_list_callback,\n                                            state);\n    }\n\n    g_list_free (files);\n\n    if (error)\n    {\n        g_error_free (error);\n    }\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":26315,"func":"static int jbig2_decode_generic_template0_unopt ( Jbig2Ctx * ctx , Jbig2Segment * segment , const Jbig2GenericRegionParams * params , Jbig2ArithState * as , Jbig2Image * image , Jbig2ArithCx * GB_stats ) {\n const int GBW = image -> width ;\n const int GBH = image -> height ;\n uint32_t CONTEXT ;\n int x , y ;\n bool bit ;\n for ( y = 0 ;\n y < GBH ;\n y ++ ) {\n for ( x = 0 ;\n x < GBW ;\n x ++ ) {\n CONTEXT = 0 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 1 , y ) << 0 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 2 , y ) << 1 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 3 , y ) << 2 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 4 , y ) << 3 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + params -> gbat [ 0 ] , y + params -> gbat [ 1 ] ) << 4 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + 2 , y - 1 ) << 5 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + 1 , y - 1 ) << 6 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + 0 , y - 1 ) << 7 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 1 , y - 1 ) << 8 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 2 , y - 1 ) << 9 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + params -> gbat [ 2 ] , y + params -> gbat [ 3 ] ) << 10 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + params -> gbat [ 4 ] , y + params -> gbat [ 5 ] ) << 11 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + 1 , y - 2 ) << 12 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + 0 , y - 2 ) << 13 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x - 1 , y - 2 ) << 14 ;\n CONTEXT |= jbig2_image_get_pixel ( image , x + params -> gbat [ 6 ] , y + params -> gbat [ 7 ] ) << 15 ;\n bit = jbig2_arith_decode ( as , & GB_stats [ CONTEXT ] ) ;\n if ( bit < 0 ) return - 1 ;\n jbig2_image_set_pixel ( image , x , y , bit ) ;\n }\n }\n return 0 ;\n }","target":0,"code_token_length":628,"total_token_length":864,"max_tokens_setting":1024}
+{"idx":32139,"func":"static struct fdtable * alloc_fdtable(unsigned int nr)\n{\n\tstruct fdtable *fdt;\n\tvoid *data;\n\n\t\/*\n\t * Figure out how many fds we actually want to support in this fdtable.\n\t * Allocation steps are keyed to the size of the fdarray, since it\n\t * grows far faster than any of the other dynamic data. We try to fit\n\t * the fdarray into comfortable page-tuned chunks: starting at 1024B\n\t * and growing in powers of two from there on.\n\t *\/\n\tnr \/= (1024 \/ sizeof(struct file *));\n\tnr = roundup_pow_of_two(nr + 1);\n\tnr *= (1024 \/ sizeof(struct file *));\n\t\/*\n\t * Note that this can drive nr *below* what we had passed if sysctl_nr_open\n\t * had been set lower between the check in expand_files() and here.  Deal\n\t * with that in caller, it's cheaper that way.\n\t *\n\t * We make sure that nr remains a multiple of BITS_PER_LONG - otherwise\n\t * bitmaps handling below becomes unpleasant, to put it mildly...\n\t *\/\n\tif (unlikely(nr > sysctl_nr_open))\n\t\tnr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1;\n\n\tfdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT);\n\tif (!fdt)\n\t\tgoto out;\n\tfdt->max_fds = nr;\n\tdata = kvmalloc_array(nr, sizeof(struct file *), GFP_KERNEL_ACCOUNT);\n\tif (!data)\n\t\tgoto out_fdt;\n\tfdt->fd = data;\n\n\tdata = kvmalloc(max_t(size_t,\n\t\t\t\t 2 * nr \/ BITS_PER_BYTE + BITBIT_SIZE(nr), L1_CACHE_BYTES),\n\t\t\t\t GFP_KERNEL_ACCOUNT);\n\tif (!data)\n\t\tgoto out_arr;\n\tfdt->open_fds = data;\n\tdata += nr \/ BITS_PER_BYTE;\n\tfdt->close_on_exec = data;\n\tdata += nr \/ BITS_PER_BYTE;\n\tfdt->full_fds_bits = data;\n\n\treturn fdt;\n\nout_arr:\n\tkvfree(fdt->fd);\nout_fdt:\n\tkfree(fdt);\nout:\n\treturn NULL;\n}","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":275146,"func":"void QtBuiltinBundlePage::registerNavigatorQtObject(JSGlobalContextRef context)\n{\n    static JSStringRef postMessageName = JSStringCreateWithUTF8CString(\"postMessage\");\n    static JSStringRef navigatorName = JSStringCreateWithUTF8CString(\"navigator\");\n    static JSStringRef qtName = JSStringCreateWithUTF8CString(\"qt\");\n\n    if (m_navigatorQtObject)\n        JSValueUnprotect(context, m_navigatorQtObject);\n    m_navigatorQtObject = JSObjectMake(context, navigatorQtObjectClass(), this);\n    JSValueProtect(context, m_navigatorQtObject);\n\n    JSObjectRef postMessage = JSObjectMakeFunctionWithCallback(context, postMessageName, qt_postMessageCallback);\n    JSObjectSetProperty(context, m_navigatorQtObject, postMessageName, postMessage, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, 0);\n\n    JSValueRef navigatorValue = JSObjectGetProperty(context, JSContextGetGlobalObject(context), navigatorName, 0);\n    if (!JSValueIsObject(context, navigatorValue))\n        return;\n    JSObjectRef navigatorObject = JSValueToObject(context, navigatorValue, 0);\n    JSObjectSetProperty(context, navigatorObject, qtName, m_navigatorQtObject, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly, 0);\n}\n","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":342591,"func":"static void virtio_setup(uint64_t dev_info)\n\n{\n\n    struct schib schib;\n\n    int ssid;\n\n    bool found = false;\n\n    uint16_t dev_no;\n\n\n\n    \/*\n\n     * We unconditionally enable mss support. In every sane configuration,\n\n     * this will succeed; and even if it doesn't, stsch_err() can deal\n\n     * with the consequences.\n\n     *\/\n\n    enable_mss_facility();\n\n\n\n    if (dev_info != -1) {\n\n        dev_no = dev_info & 0xffff;\n\n        debug_print_int(\"device no. \", dev_no);\n\n        blk_schid.ssid = (dev_info >> 16) & 0x3;\n\n        debug_print_int(\"ssid \", blk_schid.ssid);\n\n        found = find_dev(&schib, dev_no);\n\n    } else {\n\n        for (ssid = 0; ssid < 0x3; ssid++) {\n\n            blk_schid.ssid = ssid;\n\n            found = find_dev(&schib, -1);\n\n            if (found) {\n\n                break;\n\n            }\n\n        }\n\n    }\n\n\n\n    if (!found) {\n\n        virtio_panic(\"No virtio-blk device found!\\n\");\n\n    }\n\n\n\n    virtio_setup_block(blk_schid);\n\n\n\n    if (!virtio_ipl_disk_is_valid()) {\n\n        virtio_panic(\"No valid hard disk detected.\\n\");\n\n    }\n\n}\n","target":1,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":273662,"func":"hfs_make_badblockfile(HFS_INFO * hfs, TSK_FS_FILE * fs_file)\n{\n    TSK_FS_ATTR *fs_attr;\n    unsigned char dummy1, dummy2;\n    uint64_t dummy3;\n    uint8_t result;\n\n    if (tsk_verbose)\n        tsk_fprintf(stderr,\n            \"hfs_make_badblockfile: Making virtual badblock file\\n\");\n\n    if (hfs_make_specialbase(fs_file)) {\n        error_returned(\" - hfs_make_badblockfile\");\n        return 1;\n    }\n\n    fs_file->meta->addr = HFS_BAD_BLOCK_FILE_ID;\n    strncpy(fs_file->meta->name2->name, HFS_BAD_BLOCK_FILE_NAME,\n        TSK_FS_META_NAME_LIST_NSIZE);\n\n    fs_file->meta->size = 0;\n\n    if ((fs_attr =\n            tsk_fs_attrlist_getnew(fs_file->meta->attr,\n                TSK_FS_ATTR_NONRES)) == NULL) {\n        error_returned(\" - hfs_make_badblockfile\");\n        return 1;\n    }\n\n    \/\/ add the run to the file.\n    if (tsk_fs_attr_set_run(fs_file, fs_attr, NULL, NULL,\n            TSK_FS_ATTR_TYPE_DEFAULT, HFS_FS_ATTR_ID_DATA,\n            fs_file->meta->size, fs_file->meta->size, fs_file->meta->size,\n            0, 0)) {\n        error_returned(\" - hfs_make_badblockfile\");\n        return 1;\n    }\n\n    \/\/ see if file has additional runs\n    if (hfs_ext_find_extent_record_attr(hfs, HFS_BAD_BLOCK_FILE_ID,\n            fs_attr, TRUE)) {\n        error_returned(\" - hfs_make_badblockfile\");\n        fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR;\n        return 1;\n    }\n\n    \/* @@@ We have a chicken and egg problem here...  The current design of\n     * fs_attr_set() requires the size to be set, but we dont' know the size\n     * until we look into the extents file (which adds to an attribute...).\n     * This does not seem to be the best design...  neeed a way to test this. *\/\n    fs_file->meta->size = fs_attr->nrd.initsize;\n    fs_attr->size = fs_file->meta->size;\n    fs_attr->nrd.allocsize = fs_file->meta->size;\n\n    result = hfs_load_extended_attrs(fs_file, &dummy1, &dummy2, &dummy3);\n    if (result != 0) {\n        if (tsk_verbose)\n            tsk_fprintf(stderr,\n                \"WARNING: Extended attributes failed to load for the BadBlocks file.\\n\");\n        tsk_error_reset();\n    }\n\n    fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED;\n    return 0;\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":146121,"func":"  void initialize() override {\n    setMaxRequestHeadersKb(60);\n    setMaxRequestHeadersCount(100);\n    envoy::config::route::v3::RetryPolicy retry_policy;\n\n    auto pass_through = config_helper_.createVirtualHost(\"pass.through.internal.redirect\");\n    config_helper_.addVirtualHost(pass_through);\n\n    auto handle = config_helper_.createVirtualHost(\"handle.internal.redirect\");\n    handle.mutable_routes(0)->set_name(\"redirect\");\n    handle.mutable_routes(0)->mutable_route()->mutable_internal_redirect_policy();\n    config_helper_.addVirtualHost(handle);\n\n    auto handle_max_3_hop =\n        config_helper_.createVirtualHost(\"handle.internal.redirect.max.three.hop\");\n    handle_max_3_hop.mutable_routes(0)->set_name(\"max_three_hop\");\n    handle_max_3_hop.mutable_routes(0)->mutable_route()->mutable_internal_redirect_policy();\n    handle_max_3_hop.mutable_routes(0)\n        ->mutable_route()\n        ->mutable_internal_redirect_policy()\n        ->mutable_max_internal_redirects()\n        ->set_value(3);\n    config_helper_.addVirtualHost(handle_max_3_hop);\n\n    auto handle_by_direct_response = config_helper_.createVirtualHost(\"handle.direct.response\");\n    handle_by_direct_response.mutable_routes(0)->set_name(\"direct_response\");\n    handle_by_direct_response.mutable_routes(0)->mutable_direct_response()->set_status(204);\n    handle_by_direct_response.mutable_routes(0)\n        ->mutable_direct_response()\n        ->mutable_body()\n        ->set_inline_string(EMPTY_STRING);\n    config_helper_.addVirtualHost(handle_by_direct_response);\n\n    HttpProtocolIntegrationTest::initialize();\n  }","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":179727,"func":"ofputil_put_ofp11_table_stats(const struct ofputil_table_stats *stats,\n                              const struct ofputil_table_features *features,\n                              struct ofpbuf *buf)\n{\n    struct mf_bitmap wc = wild_or_nonmatchable_fields(features);\n    struct ofp11_table_stats *out;\n\n    out = ofpbuf_put_zeros(buf, sizeof *out);\n    out->table_id = features->table_id;\n    ovs_strlcpy(out->name, features->name, sizeof out->name);\n    out->wildcards = mf_bitmap_to_of11(&wc);\n    out->match = mf_bitmap_to_of11(&features->match);\n    out->instructions = ovsinst_bitmap_to_openflow(\n        features->nonmiss.instructions, OFP11_VERSION);\n    out->write_actions = ofpact_bitmap_to_openflow(\n        features->nonmiss.write.ofpacts, OFP11_VERSION);\n    out->apply_actions = ofpact_bitmap_to_openflow(\n        features->nonmiss.apply.ofpacts, OFP11_VERSION);\n    out->config = htonl(features->miss_config);\n    out->max_entries = htonl(features->max_entries);\n    out->active_count = htonl(stats->active_count);\n    out->lookup_count = htonll(stats->lookup_count);\n    out->matched_count = htonll(stats->matched_count);\n}\n","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":93005,"func":"void CL_LocalServers_f( void ) {\n\tchar\t\t*message;\n\tint\t\t\ti, j;\n\tnetadr_t\tto;\n\n\tCom_Printf( \"Scanning for servers on the local network...\\n\");\n\n\t\/\/ reset the list, waiting for response\n\tcls.numlocalservers = 0;\n\tcls.pingUpdateSource = AS_LOCAL;\n\n\tfor (i = 0; i < MAX_OTHER_SERVERS; i++) {\n\t\tqboolean b = cls.localServers[i].visible;\n\t\tCom_Memset(&cls.localServers[i], 0, sizeof(cls.localServers[i]));\n\t\tcls.localServers[i].visible = b;\n\t}\n\tCom_Memset( &to, 0, sizeof( to ) );\n\n\t\/\/ The 'xxx' in the message is a challenge that will be echoed back\n\t\/\/ by the server.  We don't care about that here, but master servers\n\t\/\/ can use that to prevent spoofed server responses from invalid ip\n\tmessage = \"\\377\\377\\377\\377getinfo xxx\";\n\n\t\/\/ send each message twice in case one is dropped\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\t\/\/ send a broadcast packet on each server port\n\t\t\/\/ we support multiple server ports so a single machine\n\t\t\/\/ can nicely run multiple servers\n\t\tfor ( j = 0 ; j < NUM_SERVER_PORTS ; j++ ) {\n\t\t\tto.port = BigShort( (short)(PORT_SERVER + j) );\n\n\t\t\tto.type = NA_BROADCAST;\n\t\t\tNET_SendPacket( NS_CLIENT, strlen( message ), message, to );\n\t\t\tto.type = NA_MULTICAST6;\n\t\t\tNET_SendPacket( NS_CLIENT, strlen( message ), message, to );\n\t\t}\n\t}\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":27417,"func":"static void cluster_all_databases ( bool verbose , const char * maintenance_db , const char * host , const char * port , const char * username , enum trivalue prompt_password , const char * progname , bool echo , bool quiet ) {\n PGconn * conn ;\n PGresult * result ;\n PQExpBufferData connstr ;\n int i ;\n conn = connectMaintenanceDatabase ( maintenance_db , host , port , username , prompt_password , progname ) ;\n result = executeQuery ( conn , \"SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;\n\" , progname , echo ) ;\n PQfinish ( conn ) ;\n initPQExpBuffer ( & connstr ) ;\n for ( i = 0 ;\n i < PQntuples ( result ) ;\n i ++ ) {\n char * dbname = PQgetvalue ( result , i , 0 ) ;\n if ( ! quiet ) {\n printf ( _ ( \"%s: clustering database \\\"%s\\\"\\n\" ) , progname , dbname ) ;\n fflush ( stdout ) ;\n }\n resetPQExpBuffer ( & connstr ) ;\n appendPQExpBuffer ( & connstr , \"dbname=\" ) ;\n appendConnStrVal ( & connstr , dbname ) ;\n cluster_one_database ( connstr . data , verbose , NULL , host , port , username , prompt_password , progname , echo ) ;\n }\n termPQExpBuffer ( & connstr ) ;\n PQclear ( result ) ;\n }","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":433023,"func":"v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,\n\t\t      unsigned int flags)\n{\n\tumode_t mode;\n\tstruct v9fs_inode *v9inode = V9FS_I(inode);\n\n\tif ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {\n\t\tinode->i_atime.tv_sec = stat->st_atime_sec;\n\t\tinode->i_atime.tv_nsec = stat->st_atime_nsec;\n\t\tinode->i_mtime.tv_sec = stat->st_mtime_sec;\n\t\tinode->i_mtime.tv_nsec = stat->st_mtime_nsec;\n\t\tinode->i_ctime.tv_sec = stat->st_ctime_sec;\n\t\tinode->i_ctime.tv_nsec = stat->st_ctime_nsec;\n\t\tinode->i_uid = stat->st_uid;\n\t\tinode->i_gid = stat->st_gid;\n\t\tset_nlink(inode, stat->st_nlink);\n\n\t\tmode = stat->st_mode & S_IALLUGO;\n\t\tmode |= inode->i_mode & ~S_IALLUGO;\n\t\tinode->i_mode = mode;\n\n\t\tif (!(flags & V9FS_STAT2INODE_KEEP_ISIZE))\n\t\t\tv9fs_i_size_write(inode, stat->st_size);\n\t\tinode->i_blocks = stat->st_blocks;\n\t} else {\n\t\tif (stat->st_result_mask & P9_STATS_ATIME) {\n\t\t\tinode->i_atime.tv_sec = stat->st_atime_sec;\n\t\t\tinode->i_atime.tv_nsec = stat->st_atime_nsec;\n\t\t}\n\t\tif (stat->st_result_mask & P9_STATS_MTIME) {\n\t\t\tinode->i_mtime.tv_sec = stat->st_mtime_sec;\n\t\t\tinode->i_mtime.tv_nsec = stat->st_mtime_nsec;\n\t\t}\n\t\tif (stat->st_result_mask & P9_STATS_CTIME) {\n\t\t\tinode->i_ctime.tv_sec = stat->st_ctime_sec;\n\t\t\tinode->i_ctime.tv_nsec = stat->st_ctime_nsec;\n\t\t}\n\t\tif (stat->st_result_mask & P9_STATS_UID)\n\t\t\tinode->i_uid = stat->st_uid;\n\t\tif (stat->st_result_mask & P9_STATS_GID)\n\t\t\tinode->i_gid = stat->st_gid;\n\t\tif (stat->st_result_mask & P9_STATS_NLINK)\n\t\t\tset_nlink(inode, stat->st_nlink);\n\t\tif (stat->st_result_mask & P9_STATS_MODE) {\n\t\t\tinode->i_mode = stat->st_mode;\n\t\t\tif ((S_ISBLK(inode->i_mode)) ||\n\t\t\t\t\t\t(S_ISCHR(inode->i_mode)))\n\t\t\t\tinit_special_inode(inode, inode->i_mode,\n\t\t\t\t\t\t\t\tinode->i_rdev);\n\t\t}\n\t\tif (stat->st_result_mask & P9_STATS_RDEV)\n\t\t\tinode->i_rdev = new_decode_dev(stat->st_rdev);\n\t\tif (!(flags & V9FS_STAT2INODE_KEEP_ISIZE) &&\n\t\t    stat->st_result_mask & P9_STATS_SIZE)\n\t\t\tv9fs_i_size_write(inode, stat->st_size);\n\t\tif (stat->st_result_mask & P9_STATS_BLOCKS)\n\t\t\tinode->i_blocks = stat->st_blocks;\n\t}\n\tif (stat->st_result_mask & P9_STATS_GEN)\n\t\tinode->i_generation = stat->st_gen;\n\n\t\/* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION\n\t * because the inode structure does not have fields for them.\n\t *\/\n\tv9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR;\n}","target":0,"code_token_length":775,"total_token_length":1011,"max_tokens_setting":1024}
+{"idx":358184,"func":"static int nfs4_init_client(struct nfs_client *clp,\n\t\tint proto, int timeo, int retrans,\n\t\tconst char *ip_addr,\n\t\trpc_authflavor_t authflavour)\n{\n\tint error;\n\n\tif (clp->cl_cons_state == NFS_CS_READY) {\n\t\t\/* the client is initialised already *\/\n\t\tdprintk(\"<-- nfs4_init_client() = 0 [already %p]\\n\", clp);\n\t\treturn 0;\n\t}\n\n\t\/* Check NFS protocol revision and initialize RPC op vector *\/\n\tclp->rpc_ops = &nfs_v4_clientops;\n\n\terror = nfs_create_rpc_client(clp, proto, timeo, retrans, authflavour,\n\t\t\t\t\tRPC_CLNT_CREATE_DISCRTRY);\n\tif (error < 0)\n\t\tgoto error;\n\tmemcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));\n\n\terror = nfs_idmap_new(clp);\n\tif (error < 0) {\n\t\tdprintk(\"%s: failed to create idmapper. Error = %d\\n\",\n\t\t\t__FUNCTION__, error);\n\t\tgoto error;\n\t}\n\t__set_bit(NFS_CS_IDMAP, &clp->cl_res_state);\n\n\tnfs_mark_client_ready(clp, NFS_CS_READY);\n\treturn 0;\n\nerror:\n\tnfs_mark_client_ready(clp, error);\n\tdprintk(\"<-- nfs4_init_client() = xerror %d\\n\", error);\n\treturn error;\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":134924,"func":"get_option_value(\n    char_u\t*name,\n    long\t*numval,\n    char_u\t**stringval,\t    \/\/ NULL when only checking existence\n    int\t\topt_flags)\n{\n    int\t\topt_idx;\n    char_u\t*varp;\n\n    opt_idx = findoption(name);\n    if (opt_idx < 0)\t\t    \/\/ option not in the table\n    {\n\tint key;\n\n\tif (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'\n\t\t\t\t  && (key = find_key_option(name, FALSE)) != 0)\n\t{\n\t    char_u key_name[2];\n\t    char_u *p;\n\n\t    \/\/ check for a terminal option\n\t    if (key < 0)\n\t    {\n\t\tkey_name[0] = KEY2TERMCAP0(key);\n\t\tkey_name[1] = KEY2TERMCAP1(key);\n\t    }\n\t    else\n\t    {\n\t\tkey_name[0] = KS_KEY;\n\t\tkey_name[1] = (key & 0xff);\n\t    }\n\t    p = find_termcode(key_name);\n\t    if (p != NULL)\n\t    {\n\t\tif (stringval != NULL)\n\t\t    *stringval = vim_strsave(p);\n\t\treturn gov_string;\n\t    }\n\t}\n\treturn gov_unknown;\n    }\n\n    varp = get_varp_scope(&(options[opt_idx]), opt_flags);\n\n    if (options[opt_idx].flags & P_STRING)\n    {\n\tif (varp == NULL)\t\t    \/\/ hidden option\n\t    return gov_hidden_string;\n\tif (stringval != NULL)\n\t{\n#ifdef FEAT_CRYPT\n\t    \/\/ never return the value of the crypt key\n\t    if ((char_u **)varp == &curbuf->b_p_key\n\t\t\t\t\t\t&& **(char_u **)(varp) != NUL)\n\t\t*stringval = vim_strsave((char_u *)\"*****\");\n\t    else\n#endif\n\t\t*stringval = vim_strsave(*(char_u **)(varp));\n\t}\n\treturn gov_string;\n    }\n\n    if (varp == NULL)\t\t    \/\/ hidden option\n\treturn (options[opt_idx].flags & P_NUM)\n\t\t\t\t\t ? gov_hidden_number : gov_hidden_bool;\n    if (options[opt_idx].flags & P_NUM)\n\t*numval = *(long *)varp;\n    else\n    {\n\t\/\/ Special case: 'modified' is b_changed, but we also want to consider\n\t\/\/ it set when 'ff' or 'fenc' changed.\n\tif ((int *)varp == &curbuf->b_changed)\n\t    *numval = curbufIsChanged();\n\telse\n\t    *numval = (long) *(int *)varp;\n    }\n    return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool;\n}","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":90866,"func":"static struct sock *ncp_connection_hack(struct ipx_interface *intrfc,\n\t\t\t\t\tstruct ipxhdr *ipx)\n{\n\t\/* The packet's target is a NCP connection handler. We want to hand it\n\t * to the correct socket directly within the kernel, so that the\n\t * mars_nwe packet distribution process does not have to do it. Here we\n\t * only care about NCP and BURST packets.\n\t *\n\t * You might call this a hack, but believe me, you do not want a\n\t * complete NCP layer in the kernel, and this is VERY fast as well. *\/\n\tstruct sock *sk = NULL;\n\tint connection = 0;\n\tu8 *ncphdr = (u8 *)(ipx + 1);\n\n\tif (*ncphdr == 0x22 && *(ncphdr + 1) == 0x22) \/* NCP request *\/\n\t\tconnection = (((int) *(ncphdr + 5)) << 8) | (int) *(ncphdr + 3);\n\telse if (*ncphdr == 0x77 && *(ncphdr + 1) == 0x77) \/* BURST packet *\/\n\t\tconnection = (((int) *(ncphdr + 9)) << 8) | (int) *(ncphdr + 8);\n\n\tif (connection) {\n\t\t\/* Now we have to look for a special NCP connection handling\n\t\t * socket. Only these sockets have ipx_ncp_conn != 0, set by\n\t\t * SIOCIPXNCPCONN. *\/\n\t\tspin_lock_bh(&intrfc->if_sklist_lock);\n\t\tsk_for_each(sk, &intrfc->if_sklist)\n\t\t\tif (ipx_sk(sk)->ipx_ncp_conn == connection) {\n\t\t\t\tsock_hold(sk);\n\t\t\t\tgoto found;\n\t\t\t}\n\t\tsk = NULL;\n\tfound:\n\t\tspin_unlock_bh(&intrfc->if_sklist_lock);\n\t}\n\treturn sk;\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":313184,"func":"handle_meter_request(struct ofconn *ofconn, const struct ofp_header *request,\n                     enum ofptype type)\n{\n    struct ofproto *ofproto = ofconn_get_ofproto(ofconn);\n    struct ovs_list replies;\n    uint64_t bands_stub[256 \/ 8];\n    struct ofpbuf bands;\n    uint32_t meter_id, first, last;\n\n    ofputil_decode_meter_request(request, &meter_id);\n\n    if (meter_id == OFPM13_ALL) {\n        first = 1;\n        last = ofproto->meter_features.max_meters;\n    } else {\n        if (!meter_id || meter_id > ofproto->meter_features.max_meters ||\n            !ofproto->meters[meter_id]) {\n            return OFPERR_OFPMMFC_UNKNOWN_METER;\n        }\n        first = last = meter_id;\n    }\n\n    ofpbuf_use_stub(&bands, bands_stub, sizeof bands_stub);\n    ofpmp_init(&replies, request);\n\n    for (meter_id = first; meter_id <= last; ++meter_id) {\n        struct meter *meter = ofproto->meters[meter_id];\n        if (!meter) {\n            continue; \/* Skip non-existing meters. *\/\n        }\n        if (type == OFPTYPE_METER_STATS_REQUEST) {\n            struct ofputil_meter_stats stats;\n\n            stats.meter_id = meter_id;\n\n            \/* Provider sets the packet and byte counts, we do the rest. *\/\n            stats.flow_count = ovs_list_size(&meter->rules);\n            calc_duration(meter->created, time_msec(),\n                          &stats.duration_sec, &stats.duration_nsec);\n            stats.n_bands = meter->n_bands;\n            ofpbuf_clear(&bands);\n            stats.bands\n                = ofpbuf_put_uninit(&bands,\n                                    meter->n_bands * sizeof *stats.bands);\n\n            if (!ofproto->ofproto_class->meter_get(ofproto,\n                                                   meter->provider_meter_id,\n                                                   &stats)) {\n                ofputil_append_meter_stats(&replies, &stats);\n            }\n        } else { \/* type == OFPTYPE_METER_CONFIG_REQUEST *\/\n            struct ofputil_meter_config config;\n\n            config.meter_id = meter_id;\n            config.flags = meter->flags;\n            config.n_bands = meter->n_bands;\n            config.bands = meter->bands;\n            ofputil_append_meter_config(&replies, &config);\n        }\n    }\n\n    ofconn_send_replies(ofconn, &replies);\n    ofpbuf_uninit(&bands);\n    return 0;\n}\n","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":325696,"func":"CPUPPCState *cpu_ppc_init(void)\n\n{\n\n    CPUPPCState *env;\n\n\n\n    cpu_exec_init();\n\n\n\n    env = qemu_mallocz(sizeof(CPUPPCState));\n\n    if (!env)\n\n        return NULL;\n\n#if !defined(CONFIG_USER_ONLY) && defined (USE_OPEN_FIRMWARE)\n\n    setup_machine(env, 0);\n\n#else\n\n\/\/    env->spr[PVR] = 0; \/* Basic PPC *\/\n\n    env->spr[PVR] = 0x00080100; \/* G3 CPU *\/\n\n\/\/    env->spr[PVR] = 0x00083100; \/* MPC755 (G3 embedded) *\/\n\n\/\/    env->spr[PVR] = 0x00070100; \/* IBM 750FX *\/\n\n#endif\n\n    tlb_flush(env, 1);\n\n#if defined (DO_SINGLE_STEP)\n\n    \/* Single step trace mode *\/\n\n    msr_se = 1;\n\n#endif\n\n    msr_fp = 1; \/* Allow floating point exceptions *\/\n\n    msr_me = 1; \/* Allow machine check exceptions  *\/\n\n#if defined(CONFIG_USER_ONLY)\n\n    msr_pr = 1;\n\n    cpu_ppc_register(env, 0x00080000);\n\n#else\n\n    env->nip = 0xFFFFFFFC;\n\n#endif\n\n    env->access_type = ACCESS_INT;\n\n    cpu_single_env = env;\n\n    return env;\n\n}\n","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":178657,"func":"void WebContentsImpl::RequestToLockMouse(\n    RenderWidgetHostImpl* render_widget_host,\n    bool user_gesture,\n    bool last_unlocked_by_target,\n    bool privileged) {\n  for (WebContentsImpl* current = this; current;\n       current = current->GetOuterWebContents()) {\n    if (current->mouse_lock_widget_) {\n      render_widget_host->GotResponseToLockMouseRequest(false);\n      return;\n    }\n  }\n\n  if (privileged) {\n    DCHECK(!GetOuterWebContents());\n    mouse_lock_widget_ = render_widget_host;\n    render_widget_host->GotResponseToLockMouseRequest(true);\n    return;\n  }\n\n  bool widget_in_frame_tree = false;\n  for (FrameTreeNode* node : frame_tree_.Nodes()) {\n    if (node->current_frame_host()->GetRenderWidgetHost() ==\n        render_widget_host) {\n      widget_in_frame_tree = true;\n      break;\n    }\n  }\n\n  if (widget_in_frame_tree && delegate_) {\n    for (WebContentsImpl* current = this; current;\n         current = current->GetOuterWebContents()) {\n      current->mouse_lock_widget_ = render_widget_host;\n    }\n\n    delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target);\n  } else {\n    render_widget_host->GotResponseToLockMouseRequest(false);\n  }\n}\n","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":432012,"func":"void tcp_send_ack(struct sock *sk)\n{\n\tstruct sk_buff *buff;\n\n\t\/* If we have been reset, we may not send again. *\/\n\tif (sk->sk_state == TCP_CLOSE)\n\t\treturn;\n\n\ttcp_ca_event(sk, CA_EVENT_NON_DELAYED_ACK);\n\n\t\/* We are not putting this on the write queue, so\n\t * tcp_transmit_skb() will set the ownership to this\n\t * sock.\n\t *\/\n\tbuff = alloc_skb(MAX_TCP_HEADER,\n\t\t\t sk_gfp_mask(sk, GFP_ATOMIC | __GFP_NOWARN));\n\tif (unlikely(!buff)) {\n\t\tinet_csk_schedule_ack(sk);\n\t\tinet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN;\n\t\tinet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,\n\t\t\t\t\t  TCP_DELACK_MAX, TCP_RTO_MAX);\n\t\treturn;\n\t}\n\n\t\/* Reserve space for headers and prepare control bits. *\/\n\tskb_reserve(buff, MAX_TCP_HEADER);\n\ttcp_init_nondata_skb(buff, tcp_acceptable_seq(sk), TCPHDR_ACK);\n\n\t\/* We do not want pure acks influencing TCP Small Queues or fq\/pacing\n\t * too much.\n\t * SKB_TRUESIZE(max(1 .. 66, MAX_TCP_HEADER)) is unfortunately ~784\n\t *\/\n\tskb_set_tcp_pure_ack(buff);\n\n\t\/* Send it off, this clears delayed acks for us. *\/\n\ttcp_transmit_skb(sk, buff, 0, (__force gfp_t)0);\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":41766,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& input_sizes = context->input(0);\n    const Tensor& filter = context->input(1);\n    const Tensor& out_backprop = context->input(2);\n\n    TensorShape input_shape;\n    OP_REQUIRES_OK(context,\n                   Conv2DBackpropComputeInputShape(input_sizes, filter.shape(),\n                                                   out_backprop.shape(),\n                                                   data_format_, &input_shape));\n\n    Tensor* in_backprop = nullptr;\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(0, input_shape, &in_backprop));\n\n    \/\/ If there is nothing to compute, return.\n    if (input_shape.num_elements() == 0) {\n      return;\n    }\n\n    \/\/ For now we take the stride from the second and third dimensions only (we\n    \/\/ do not support striding on the batch or depth dimension).\n    const int stride_rows = GetTensorDim(strides_, data_format_, 'H');\n    const int stride_cols = GetTensorDim(strides_, data_format_, 'W');\n    const int dilation_rows = GetTensorDim(dilations_, data_format_, 'H');\n    const int dilation_cols = GetTensorDim(dilations_, data_format_, 'W');\n\n    VLOG(2) << \"Conv2DBackpropInput:\"\n            << \" input: \" << input_shape.DebugString()\n            << \" filter:\" << filter.shape().DebugString()\n            << \" out_backprop: \" << out_backprop.shape().DebugString()\n            << \" strides: [\" << stride_rows << \", \" << stride_cols << \"]\"\n            << \" dilations: [\" << dilation_rows << \", \" << dilation_cols << \"]\";\n\n    LaunchConv2DBackpropInputOp launch;\n    launch(context, use_cudnn_, cudnn_use_autotune_, out_backprop, filter,\n           dilation_rows, dilation_cols, stride_rows, stride_cols, padding_,\n           explicit_paddings_, in_backprop, data_format_);\n  }","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":310974,"func":"dhcpv4_print(netdissect_options *ndo,\n             const u_char *cp, u_int length, int indent)\n{\n    u_int i, t;\n    const u_char *tlv, *value;\n    uint8_t type, optlen;\n\n    i = 0;\n    while (i < length) {\n        if (i + 2 > length)\n            return -1;\n        tlv = cp + i;\n        type = (uint8_t)tlv[0];\n        optlen = (uint8_t)tlv[1];\n        value = tlv + 2;\n\n        ND_PRINT((ndo, \"\\n\"));\n        for (t = indent; t > 0; t--)\n            ND_PRINT((ndo, \"\\t\"));\n\n        ND_PRINT((ndo, \"%s\", tok2str(dh4opt_str, \"Unknown\", type)));\n        ND_PRINT((ndo,\" (%u)\", optlen + 2 ));\n        if (i + 2 + optlen > length)\n            return -1;\n\n        switch (type) {\n        case DH4OPT_DNS_SERVERS:\n        case DH4OPT_NTP_SERVERS: {\n            if (optlen < 4 || optlen % 4 != 0) {\n                return -1;\n            }\n            for (t = 0; t < optlen; t += 4)\n                ND_PRINT((ndo, \" %s\", ipaddr_string(ndo, value + t)));\n        }\n            break;\n        case DH4OPT_DOMAIN_SEARCH: {\n            const u_char *tp = value;\n            while (tp < value + optlen) {\n                ND_PRINT((ndo, \" \"));\n                if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL)\n                    return -1;\n            }\n        }\n            break;\n        }\n\n        i += 2 + optlen;\n    }\n    return 0;\n}\n","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":103378,"func":"int cil_gen_tunif(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)\n{\n\tenum cil_syntax syntax[] = {\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_STRING | CIL_SYN_LIST,\n\t\tCIL_SYN_LIST,\n\t\tCIL_SYN_LIST | CIL_SYN_END,\n\t\tCIL_SYN_END\n\t};\n\tint syntax_len = sizeof(syntax)\/sizeof(*syntax);\n\tstruct cil_tunableif *tif = NULL;\n\tstruct cil_tree_node *next = NULL;\n\tint rc = SEPOL_ERR;\n\n\tif (db == NULL || parse_current == NULL || ast_node == NULL) {\n\t\tgoto exit;\n\t}\n\n\trc = __cil_verify_syntax(parse_current, syntax, syntax_len);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tcil_tunif_init(&tif);\n\n\trc = cil_gen_expr(parse_current->next, CIL_TUNABLE, &tif->str_expr);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\trc = cil_verify_conditional_blocks(parse_current->next->next);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\t\/* Destroying expr tree *\/\n\tnext = parse_current->next->next;\n\tcil_tree_subtree_destroy(parse_current->next);\n\tparse_current->next = next;\n\n\tast_node->flavor = CIL_TUNABLEIF;\n\tast_node->data = tif;\n\n\treturn SEPOL_OK;\n\nexit:\n\tcil_tree_log(parse_current, CIL_ERR, \"Bad tunableif declaration\");\n\tcil_destroy_tunif(tif);\n\treturn rc;\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":493232,"func":"RemoveStatisticsById(Oid statsOid)\n{\n\tRelation\trelation;\n\tHeapTuple\ttup;\n\tForm_pg_statistic_ext statext;\n\tOid\t\t\trelid;\n\n\t\/*\n\t * First delete the pg_statistic_ext_data tuple holding the actual\n\t * statistical data.\n\t *\/\n\trelation = table_open(StatisticExtDataRelationId, RowExclusiveLock);\n\n\ttup = SearchSysCache1(STATEXTDATASTXOID, ObjectIdGetDatum(statsOid));\n\n\tif (!HeapTupleIsValid(tup)) \/* should not happen *\/\n\t\telog(ERROR, \"cache lookup failed for statistics data %u\", statsOid);\n\n\tCatalogTupleDelete(relation, &tup->t_self);\n\n\tReleaseSysCache(tup);\n\n\ttable_close(relation, RowExclusiveLock);\n\n\t\/*\n\t * Delete the pg_statistic_ext tuple.  Also send out a cache inval on the\n\t * associated table, so that dependent plans will be rebuilt.\n\t *\/\n\trelation = table_open(StatisticExtRelationId, RowExclusiveLock);\n\n\ttup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statsOid));\n\n\tif (!HeapTupleIsValid(tup)) \/* should not happen *\/\n\t\telog(ERROR, \"cache lookup failed for statistics object %u\", statsOid);\n\n\tstatext = (Form_pg_statistic_ext) GETSTRUCT(tup);\n\trelid = statext->stxrelid;\n\n\tCacheInvalidateRelcacheByRelid(relid);\n\n\tCatalogTupleDelete(relation, &tup->t_self);\n\n\tReleaseSysCache(tup);\n\n\ttable_close(relation, RowExclusiveLock);\n}","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":261228,"func":"static void __fput(struct file *file)\n{\n\tstruct dentry *dentry = file->f_path.dentry;\n\tstruct vfsmount *mnt = file->f_path.mnt;\n\tstruct inode *inode = file->f_inode;\n\n\tmight_sleep();\n\n\tfsnotify_close(file);\n\t\/*\n\t * The function eventpoll_release() should be the first called\n\t * in the file cleanup chain.\n\t *\/\n\teventpoll_release(file);\n\tlocks_remove_flock(file);\n\n\tif (unlikely(file->f_flags & FASYNC)) {\n\t\tif (file->f_op->fasync)\n\t\t\tfile->f_op->fasync(-1, file, 0);\n\t}\n\tima_file_free(file);\n\tif (file->f_op->release)\n\t\tfile->f_op->release(inode, file);\n\tsecurity_file_free(file);\n\tif (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL &&\n\t\t     !(file->f_mode & FMODE_PATH))) {\n\t\tcdev_put(inode->i_cdev);\n\t}\n\tfops_put(file->f_op);\n\tput_pid(file->f_owner.pid);\n\tif ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)\n\t\ti_readcount_dec(inode);\n\tif (file->f_mode & FMODE_WRITE)\n\t\tdrop_file_write_access(file);\n\tfile->f_path.dentry = NULL;\n\tfile->f_path.mnt = NULL;\n\tfile->f_inode = NULL;\n\tfile_free(file);\n\tdput(dentry);\n\tmntput(mnt);\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":92149,"func":"RefPtr MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill)\n{\n    InterruptDisabler disabler;\n    RefPtr page = find_free_user_physical_page();\n\n    if (!page) {\n        if (m_user_physical_regions.is_empty()) {\n            kprintf(\"MM: no user physical regions available (?)\\n\");\n        }\n\n        for_each_vmobject([&](auto& vmobject) {\n            if (vmobject.is_purgeable()) {\n                auto& purgeable_vmobject = static_cast(vmobject);\n                int purged_page_count = purgeable_vmobject.purge_with_interrupts_disabled({});\n                if (purged_page_count) {\n                    kprintf(\"MM: Purge saved the day! Purged %d pages from PurgeableVMObject{%p}\\n\", purged_page_count, &purgeable_vmobject);\n                    page = find_free_user_physical_page();\n                    ASSERT(page);\n                    return IterationDecision::Break;\n                }\n            }\n            return IterationDecision::Continue;\n        });\n\n        if (!page) {\n            kprintf(\"MM: no user physical pages available\\n\");\n            ASSERT_NOT_REACHED();\n            return {};\n        }\n    }\n\n#ifdef MM_DEBUG\n    dbgprintf(\"MM: allocate_user_physical_page vending P%p\\n\", page->paddr().get());\n#endif\n\n    if (should_zero_fill == ShouldZeroFill::Yes) {\n        auto* ptr = (u32*)quickmap_page(*page);\n        fast_u32_fill(ptr, 0, PAGE_SIZE \/ sizeof(u32));\n        unquickmap_page();\n    }\n\n    ++m_user_physical_pages_used;\n    return page;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":177011,"func":"static char **GetTransformTokens(void *context,const char *text,\n  int *number_tokens)\n{\n  char\n    **tokens;\n\n  register const char\n    *p,\n    *q;\n\n  register ssize_t\n    i;\n\n  SVGInfo\n    *svg_info;\n\n  svg_info=(SVGInfo *) context;\n  *number_tokens=0;\n  if (text == (const char *) NULL)\n    return((char **) NULL);\n  \/*\n    Determine the number of arguments.\n  *\/\n  for (p=text; *p != '\\0'; p++)\n  {\n    if (*p == '(')\n      (*number_tokens)+=2;\n  }\n  tokens=(char **) AcquireQuantumMemory(*number_tokens+2UL,sizeof(*tokens));\n  if (tokens == (char **) NULL)\n    {\n      (void) ThrowMagickException(svg_info->exception,GetMagickModule(),\n        ResourceLimitError,\"MemoryAllocationFailed\",\"`%s'\",text);\n      return((char **) NULL);\n    }\n  \/*\n    Convert string to an ASCII list.\n  *\/\n  i=0;\n  p=text;\n  for (q=p; *q != '\\0'; q++)\n  {\n    if ((*q != '(') && (*q != ')') && (*q != '\\0'))\n      continue;\n    tokens[i]=AcquireString(p);\n    (void) CopyMagickString(tokens[i],p,(size_t) (q-p+1));\n    StripString(tokens[i++]);\n    p=q+1;\n  }\n  tokens[i]=AcquireString(p);\n  (void) CopyMagickString(tokens[i],p,(size_t) (q-p+1));\n  StripString(tokens[i++]);\n  tokens[i]=(char *) NULL;\n  return(tokens);\n}\n","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":325850,"func":"static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,\n\n                            const char *model, const char *name,\n\n                            const char *ifname, const char *script,\n\n                            const char *downscript, const char *vhostfdname,\n\n                            int vnet_hdr, int fd)\n\n{\n\n    TAPState *s;\n\n\n\n    s = net_tap_fd_init(peer, model, name, fd, vnet_hdr);\n\n    if (!s) {\n\n        close(fd);\n\n        return -1;\n\n    }\n\n\n\n    if (tap_set_sndbuf(s->fd, tap) < 0) {\n\n        return -1;\n\n    }\n\n\n\n    if (tap->has_fd || tap->has_fds) {\n\n        snprintf(s->nc.info_str, sizeof(s->nc.info_str), \"fd=%d\", fd);\n\n    } else if (tap->has_helper) {\n\n        snprintf(s->nc.info_str, sizeof(s->nc.info_str), \"helper=%s\",\n\n                 tap->helper);\n\n    } else {\n\n        snprintf(s->nc.info_str, sizeof(s->nc.info_str),\n\n                 \"ifname=%s,script=%s,downscript=%s\", ifname, script,\n\n                 downscript);\n\n\n\n        if (strcmp(downscript, \"no\") != 0) {\n\n            snprintf(s->down_script, sizeof(s->down_script), \"%s\", downscript);\n\n            snprintf(s->down_script_arg, sizeof(s->down_script_arg),\n\n                     \"%s\", ifname);\n\n        }\n\n    }\n\n\n\n    if (tap->has_vhost ? tap->vhost :\n\n        vhostfdname || (tap->has_vhostforce && tap->vhostforce)) {\n\n        int vhostfd;\n\n\n\n        if (tap->has_vhostfd) {\n\n            vhostfd = monitor_handle_fd_param(cur_mon, vhostfdname);\n\n            if (vhostfd == -1) {\n\n                return -1;\n\n            }\n\n        } else {\n\n            vhostfd = -1;\n\n        }\n\n\n\n        s->vhost_net = vhost_net_init(&s->nc, vhostfd,\n\n                                      tap->has_vhostforce && tap->vhostforce);\n\n        if (!s->vhost_net) {\n\n            error_report(\"vhost-net requested but could not be initialized\");\n\n            return -1;\n\n        }\n\n    } else if (tap->has_vhostfd || tap->has_vhostfds) {\n\n        error_report(\"vhostfd= is not valid without vhost\");\n\n        return -1;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":395909,"func":"_gnutls_session_cert_type_supported(gnutls_session_t session,\n\t\t\t\t    gnutls_certificate_type_t cert_type)\n{\n\tunsigned i;\n\tunsigned cert_found = 0;\n\tgnutls_certificate_credentials_t cred;\n\n\tif (session->security_parameters.entity == GNUTLS_SERVER) {\n\t\tcred = (gnutls_certificate_credentials_t)\n\t\t    _gnutls_get_cred(session, GNUTLS_CRD_CERTIFICATE);\n\n\t\tif (cred == NULL)\n\t\t\treturn GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;\n\n\t\tif (cred->get_cert_callback == NULL && cred->get_cert_callback2 == NULL) {\n\t\t\tfor (i = 0; i < cred->ncerts; i++) {\n\t\t\t\tif (cred->certs[i].cert_list[0].type ==\n\t\t\t\t    cert_type) {\n\t\t\t\t\tcert_found = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (cert_found == 0)\n\t\t\t\t\/* no certificate is of that type.\n\t\t\t\t *\/\n\t\t\t\treturn\n\t\t\t\t    GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;\n\t\t}\n\t}\n\n\tif (session->internals.priorities.cert_type.algorithms == 0\n\t    && cert_type == DEFAULT_CERT_TYPE)\n\t\treturn 0;\n\n\tfor (i = 0; i < session->internals.priorities.cert_type.algorithms;\n\t     i++) {\n\t\tif (session->internals.priorities.cert_type.priority[i] ==\n\t\t    cert_type) {\n\t\t\treturn 0;\t\/* ok *\/\n\t\t}\n\t}\n\n\treturn GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":351773,"func":"CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* \/*par*\/ )\n{\n    \/\/ if (exec) logln((UnicodeString)\"TestSuite NumberFormatRegressionTest\");\n    switch (index) {\n        CASE(0,test4100311);\n        CASE(1,test4074758);\n        CASE(2,test4028518);\n        CASE(3,test4031502);\n        CASE(4,test4035301);\n        CASE(5,test4040996);\n        CASE(6,test4051765);\n        CASE(7,test4061476);\n        CASE(8,test4070502);\n        CASE(9,test4071197);\n        CASE(10,test4071385);\n        CASE(11,test4073929);\n        CASE(12,test4083167);\n        CASE(13,test4086724);\n        CASE(14,test4095407);\n        CASE(15,test4096231);\n        CASE(16,test4096539);\n        CASE(17,test41003112);\n        CASE(18,test4103271);\n        CASE(19,test4106136);\n        CASE(20,test4108764);\n        CASE(21,test4114578);\n        CASE(22,test4118384);\n        CASE(23,test4125881);\n        CASE(24,test4125892);\n        CASE(25,test4141665);\n        CASE(26,test4142933);\n        CASE(27,test4145158);\n        CASE(28,test4145983);\n        CASE(29,test4147269);\n\n        CASE(30,Test4149677);\n        CASE(31,Test4162587);\n        CASE(32,Test4165343);\n        CASE(33,Test4166109);\n        CASE(34,Test4167060);\n        CASE(35,Test4197699);\n        CASE(36,TestJ81);\n        CASE(37,TestJ438);\n        CASE(38,TestLeapFieldDifference);\n        CASE(39,TestMalaysianInstance);\n        CASE(40,test4059654);\n        CASE(41,test4092362);\n        CASE(42,TestWeekShift);\n        CASE(43,TestTimeZoneTransitionAdd);\n        CASE(44,TestDeprecates);\n        CASE(45,TestT5555);\n        CASE(46,TestT6745);\n        CASE(47,TestT8057);\n        CASE(48,TestT8596);\n        CASE(49,Test9019);\n        CASE(50,TestT9452);\n        CASE(51,TestT11632);\n    default: name = \"\"; break;\n    }\n}","target":1,"code_token_length":765,"total_token_length":1001,"max_tokens_setting":1024}
+{"idx":458224,"func":"void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t\n        *parameters)\n{\n    if (parameters) {\n        memset(parameters, 0, sizeof(opj_cparameters_t));\n        \/* default coding parameters *\/\n        parameters->cp_cinema = OPJ_OFF; \/* DEPRECATED *\/\n        parameters->rsiz = OPJ_PROFILE_NONE;\n        parameters->max_comp_size = 0;\n        parameters->numresolution = OPJ_COMP_PARAM_DEFAULT_NUMRESOLUTION;\n        parameters->cp_rsiz = OPJ_STD_RSIZ; \/* DEPRECATED *\/\n        parameters->cblockw_init = OPJ_COMP_PARAM_DEFAULT_CBLOCKW;\n        parameters->cblockh_init = OPJ_COMP_PARAM_DEFAULT_CBLOCKH;\n        parameters->prog_order = OPJ_COMP_PARAM_DEFAULT_PROG_ORDER;\n        parameters->roi_compno = -1;        \/* no ROI *\/\n        parameters->subsampling_dx = 1;\n        parameters->subsampling_dy = 1;\n        parameters->tp_on = 0;\n        parameters->decod_format = -1;\n        parameters->cod_format = -1;\n        parameters->tcp_rates[0] = 0;\n        parameters->tcp_numlayers = 0;\n        parameters->cp_disto_alloc = 0;\n        parameters->cp_fixed_alloc = 0;\n        parameters->cp_fixed_quality = 0;\n        parameters->jpip_on = OPJ_FALSE;\n        \/* UniPG>> *\/\n#ifdef USE_JPWL\n        parameters->jpwl_epc_on = OPJ_FALSE;\n        parameters->jpwl_hprot_MH = -1; \/* -1 means unassigned *\/\n        {\n            int i;\n            for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {\n                parameters->jpwl_hprot_TPH_tileno[i] = -1; \/* unassigned *\/\n                parameters->jpwl_hprot_TPH[i] = 0; \/* absent *\/\n            }\n        };\n        {\n            int i;\n            for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {\n                parameters->jpwl_pprot_tileno[i] = -1; \/* unassigned *\/\n                parameters->jpwl_pprot_packno[i] = -1; \/* unassigned *\/\n                parameters->jpwl_pprot[i] = 0; \/* absent *\/\n            }\n        };\n        parameters->jpwl_sens_size = 0; \/* 0 means no ESD *\/\n        parameters->jpwl_sens_addr = 0; \/* 0 means auto *\/\n        parameters->jpwl_sens_range = 0; \/* 0 means packet *\/\n        parameters->jpwl_sens_MH = -1; \/* -1 means unassigned *\/\n        {\n            int i;\n            for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {\n                parameters->jpwl_sens_TPH_tileno[i] = -1; \/* unassigned *\/\n                parameters->jpwl_sens_TPH[i] = -1; \/* absent *\/\n            }\n        };\n#endif \/* USE_JPWL *\/\n        \/* < 0)\n {\n ++argv;\n if (argc > 1 && strcmp(*argv, \"-l\") == 0)\n {\n --argc;\n         command.limit = atoi(*++argv);\n }\n\n else\n {\n         fprintf(stderr, \"unknown argument %s\\n\", *argv);\n return 1;\n }\n }\n\n   control.cnumber = 0;\n   control.check_state = start;\n   control.at_start = 1;\n   control.cdigits_in_state = 0;\n   control.limit = command.limit;\n   control.state = 0;\n   control.is_negative = 0;\n   control.is_zero = 1;\n   control.number_was_valid = 0;\n\n   result = check_all_characters(&command, control);\n\n   printf(\"checkfp: %s: checked %d,%.3d,%.3d,%.3d strings (%d invalid)\\n\",\n      result ? \"pass\" : \"FAIL\", command.cmillions \/ 1000,\n      command.cmillions % 1000, command.ctimes \/ 1000, command.ctimes % 1000,\n      command.cinvalid);\n\n return result;\n}\n","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":160887,"func":"int CLASS ljpeg_start (struct jhead *jh, int info_only)\n{\n  int c, tag;\n  ushort len;\n  uchar data[0x10000];\n  const uchar *dp;\n\n  memset (jh, 0, sizeof *jh);\n  jh->restart = INT_MAX;\n  fread (data, 2, 1, ifp);\n  if (data[1] != 0xd8) return 0;\n  do {\n    fread (data, 2, 2, ifp);\n    tag =  data[0] << 8 | data[1];\n    len = (data[2] << 8 | data[3]) - 2;\n    if (tag <= 0xff00) return 0;\n    fread (data, 1, len, ifp);\n    switch (tag) {\n      case 0xffc3:\n\tjh->sraw = ((data[7] >> 4) * (data[7] & 15) - 1) & 3;\n      case 0xffc0:\n\tjh->bits = data[0];\n\tjh->high = data[1] << 8 | data[2];\n\tjh->wide = data[3] << 8 | data[4];\n\tjh->clrs = data[5] + jh->sraw;\n\tif (len == 9 && !dng_version) getc(ifp);\n\tbreak;\n      case 0xffc4:\n\tif (info_only) break;\n\tfor (dp = data; dp < data+len && (c = *dp++) < 4; )\n\t  jh->free[c] = jh->huff[c] = make_decoder_ref (&dp);\n\tbreak;\n      case 0xffda:\n\tjh->psv = data[1+data[0]*2];\n\tjh->bits -= data[3+data[0]*2] & 15;\n\tbreak;\n      case 0xffdd:\n\tjh->restart = data[0] << 8 | data[1];\n    }\n  } while (tag != 0xffda);\n  if (info_only) return 1;\n  if (jh->clrs > 6 || !jh->huff[0]) return 0;\n  FORC(5) if (!jh->huff[c+1]) jh->huff[c+1] = jh->huff[c];\n  if (jh->sraw) {\n    FORC(4)        jh->huff[2+c] = jh->huff[1];\n    FORC(jh->sraw) jh->huff[1+c] = jh->huff[0];\n  }\n  jh->row = (ushort *) calloc (jh->wide*jh->clrs, 4);\n  merror (jh->row, \"ljpeg_start()\");\n  return zero_after_ff = 1;\n}","target":0,"code_token_length":631,"total_token_length":867,"max_tokens_setting":1024}
+{"idx":95235,"func":"static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,\n\t\t\t\t\tstruct page *parent, int start)\n{\n\tstruct page *page;\n\tint err;\n\n\tif (!nid)\n\t\treturn ERR_PTR(-ENOENT);\n\tf2fs_bug_on(sbi, check_nid_range(sbi, nid));\nrepeat:\n\tpage = f2fs_grab_cache_page(NODE_MAPPING(sbi), nid, false);\n\tif (!page)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\terr = read_node_page(page, 0);\n\tif (err < 0) {\n\t\tf2fs_put_page(page, 1);\n\t\treturn ERR_PTR(err);\n\t} else if (err == LOCKED_PAGE) {\n\t\tgoto page_hit;\n\t}\n\n\tif (parent)\n\t\tra_node_pages(parent, start + 1, MAX_RA_NODE);\n\n\tlock_page(page);\n\n\tif (unlikely(page->mapping != NODE_MAPPING(sbi))) {\n\t\tf2fs_put_page(page, 1);\n\t\tgoto repeat;\n\t}\n\n\tif (unlikely(!PageUptodate(page)))\n\t\tgoto out_err;\npage_hit:\n\tif(unlikely(nid != nid_of_node(page))) {\n\t\tf2fs_bug_on(sbi, 1);\n\t\tClearPageUptodate(page);\nout_err:\n\t\tf2fs_put_page(page, 1);\n\t\treturn ERR_PTR(-EIO);\n\t}\n\treturn page;\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":343504,"func":"int __udp_lib_get_port(struct sock *sk, unsigned short snum,\n\t\t       struct hlist_head udptable[], int *port_rover,\n\t\t       int (*saddr_comp)(const struct sock *sk1,\n\t\t\t\t\t const struct sock *sk2 )    )\n{\n\tstruct hlist_node *node;\n\tstruct hlist_head *head;\n\tstruct sock *sk2;\n\tint    error = 1;\n\n\twrite_lock_bh(&udp_hash_lock);\n\tif (snum == 0) {\n\t\tint best_size_so_far, best, result, i;\n\n\t\tif (*port_rover > sysctl_local_port_range[1] ||\n\t\t    *port_rover < sysctl_local_port_range[0])\n\t\t\t*port_rover = sysctl_local_port_range[0];\n\t\tbest_size_so_far = 32767;\n\t\tbest = result = *port_rover;\n\t\tfor (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {\n\t\t\tint size;\n\n\t\t\thead = &udptable[result & (UDP_HTABLE_SIZE - 1)];\n\t\t\tif (hlist_empty(head)) {\n\t\t\t\tif (result > sysctl_local_port_range[1])\n\t\t\t\t\tresult = sysctl_local_port_range[0] +\n\t\t\t\t\t\t((result - sysctl_local_port_range[0]) &\n\t\t\t\t\t\t (UDP_HTABLE_SIZE - 1));\n\t\t\t\tgoto gotit;\n\t\t\t}\n\t\t\tsize = 0;\n\t\t\tsk_for_each(sk2, node, head) {\n\t\t\t\tif (++size >= best_size_so_far)\n\t\t\t\t\tgoto next;\n\t\t\t}\n\t\t\tbest_size_so_far = size;\n\t\t\tbest = result;\n\t\tnext:\n\t\t\t;\n\t\t}\n\t\tresult = best;\n\t\tfor (i = 0; i < (1 << 16) \/ UDP_HTABLE_SIZE;\n\t\t     i++, result += UDP_HTABLE_SIZE) {\n\t\t\tif (result > sysctl_local_port_range[1])\n\t\t\t\tresult = sysctl_local_port_range[0]\n\t\t\t\t\t+ ((result - sysctl_local_port_range[0]) &\n\t\t\t\t\t   (UDP_HTABLE_SIZE - 1));\n\t\t\tif (! __udp_lib_lport_inuse(result, udptable))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (i >= (1 << 16) \/ UDP_HTABLE_SIZE)\n\t\t\tgoto fail;\ngotit:\n\t\t*port_rover = snum = result;\n\t} else {\n\t\thead = &udptable[snum & (UDP_HTABLE_SIZE - 1)];\n\n\t\tsk_for_each(sk2, node, head)\n\t\t\tif (sk2->sk_hash == snum                             &&\n\t\t\t    sk2 != sk                                        &&\n\t\t\t    (!sk2->sk_reuse        || !sk->sk_reuse)         &&\n\t\t\t    (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if\n\t\t\t     || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&\n\t\t\t    (*saddr_comp)(sk, sk2)                             )\n\t\t\t\tgoto fail;\n\t}\n\tinet_sk(sk)->num = snum;\n\tsk->sk_hash = snum;\n\tif (sk_unhashed(sk)) {\n\t\thead = &udptable[snum & (UDP_HTABLE_SIZE - 1)];\n\t\tsk_add_node(sk, head);\n\t\tsock_prot_inc_use(sk->sk_prot);\n\t}\n\terror = 0;\nfail:\n\twrite_unlock_bh(&udp_hash_lock);\n\treturn error;\n}","target":1,"code_token_length":709,"total_token_length":945,"max_tokens_setting":1024}
+{"idx":160135,"func":"test_userpass_cookie_check (Test *test,\n                            gconstpointer data)\n{\n  GAsyncResult *result = NULL;\n  CockpitWebService *service;\n  CockpitWebService *prev_service;\n  CockpitCreds *creds;\n  CockpitCreds *prev_creds;\n  JsonObject *response = NULL;\n  GError *error = NULL;\n  GHashTable *headers;\n\n  headers = mock_auth_basic_header (\"me\", \"this is the password\");\n  g_hash_table_insert (headers, g_strdup (\"X-Authorize\"), g_strdup (\"password\"));\n  cockpit_auth_login_async (test->auth, \"\/cockpit\/\", NULL, headers, on_ready_get_result, &result);\n  g_hash_table_unref (headers);\n\n  while (result == NULL)\n    g_main_context_iteration (NULL, TRUE);\n\n  headers = web_socket_util_new_headers ();\n  response = cockpit_auth_login_finish (test->auth, result, NULL, headers, &error);\n  g_assert_no_error (error);\n\n  \/* Get the service *\/\n  mock_auth_include_cookie_as_if_client (headers, headers, \"cockpit\");\n  service = cockpit_auth_check_cookie (test->auth, \"\/cockpit\", headers);\n\n  g_object_unref (result);\n  g_assert (service != NULL);\n  g_assert (response != NULL);\n\n  creds = cockpit_web_service_get_creds (service);\n  g_assert_cmpstr (\"me\", ==, cockpit_creds_get_user (creds));\n  g_assert_cmpstr (\"cockpit\", ==, cockpit_creds_get_application (creds));\n  g_assert_cmpstr (\"this is the password\", ==, g_bytes_get_data (cockpit_creds_get_password (creds), NULL));\n\n  prev_service = service;\n  g_object_unref (service);\n  service = NULL;\n\n  prev_creds = creds;\n  creds = NULL;\n\n  mock_auth_include_cookie_as_if_client (headers, headers, \"cockpit\");\n\n  service = cockpit_auth_check_cookie (test->auth, \"\/cockpit\", headers);\n  g_assert (prev_service == service);\n\n  creds = cockpit_web_service_get_creds (service);\n  g_assert (prev_creds == creds);\n\n  g_assert_cmpstr (\"me\", ==, cockpit_creds_get_user (creds));\n  g_assert_cmpstr (\"this is the password\", ==, g_bytes_get_data (cockpit_creds_get_password (creds), NULL));\n\n  g_hash_table_destroy (headers);\n  g_object_unref (service);\n  json_object_unref (response);\n}","target":0,"code_token_length":513,"total_token_length":749,"max_tokens_setting":1024}
+{"idx":278192,"func":"status_t ATSParser::parseAdaptationField(ABitReader *br, unsigned PID) {\n unsigned adaptation_field_length = br->getBits(8);\n\n if (adaptation_field_length > 0) {\n if (adaptation_field_length * 8 > br->numBitsLeft()) {\n            ALOGV(\"Adaptation field should be included in a single TS packet.\");\n return ERROR_MALFORMED;\n }\n\n unsigned discontinuity_indicator = br->getBits(1);\n\n if (discontinuity_indicator) {\n            ALOGV(\"PID 0x%04x: discontinuity_indicator = 1 (!!!)\", PID);\n }\n\n        br->skipBits(2);\n unsigned PCR_flag = br->getBits(1);\n\n size_t numBitsRead = 4;\n\n if (PCR_flag) {\n if (adaptation_field_length * 8 < 52) {\n return ERROR_MALFORMED;\n }\n            br->skipBits(4);\n uint64_t PCR_base = br->getBits(32);\n            PCR_base = (PCR_base << 1) | br->getBits(1);\n\n            br->skipBits(6);\n unsigned PCR_ext = br->getBits(9);\n\n size_t byteOffsetFromStartOfTSPacket =\n (188 - br->numBitsLeft() \/ 8);\n\n uint64_t PCR = PCR_base * 300 + PCR_ext;\n\n            ALOGV(\"PID 0x%04x: PCR = 0x%016\" PRIx64 \" (%.2f)\",\n                  PID, PCR, PCR \/ 27E6);\n\n size_t byteOffsetFromStart =\n                mNumTSPacketsParsed * 188 + byteOffsetFromStartOfTSPacket;\n\n for (size_t i = 0; i < mPrograms.size(); ++i) {\n                updatePCR(PID, PCR, byteOffsetFromStart);\n }\n\n            numBitsRead += 52;\n }\n\n        br->skipBits(adaptation_field_length * 8 - numBitsRead);\n }\n return OK;\n}\n","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":67360,"func":"static void dma_cache_maint_page(struct page *page, unsigned long offset,\n\tsize_t size, enum dma_data_direction dir,\n\tvoid (*op)(const void *, size_t, int))\n{\n\tunsigned long pfn;\n\tsize_t left = size;\n\n\tpfn = page_to_pfn(page) + offset \/ PAGE_SIZE;\n\toffset %= PAGE_SIZE;\n\n\t\/*\n\t * A single sg entry may refer to multiple physically contiguous\n\t * pages.  But we still need to process highmem pages individually.\n\t * If highmem is not configured then the bulk of this loop gets\n\t * optimized out.\n\t *\/\n\tdo {\n\t\tsize_t len = left;\n\t\tvoid *vaddr;\n\n\t\tpage = pfn_to_page(pfn);\n\n\t\tif (PageHighMem(page)) {\n\t\t\tif (len + offset > PAGE_SIZE)\n\t\t\t\tlen = PAGE_SIZE - offset;\n\n\t\t\tif (cache_is_vipt_nonaliasing()) {\n\t\t\t\tvaddr = kmap_atomic(page);\n\t\t\t\top(vaddr + offset, len, dir);\n\t\t\t\tkunmap_atomic(vaddr);\n\t\t\t} else {\n\t\t\t\tvaddr = kmap_high_get(page);\n\t\t\t\tif (vaddr) {\n\t\t\t\t\top(vaddr + offset, len, dir);\n\t\t\t\t\tkunmap_high(page);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tvaddr = page_address(page) + offset;\n\t\t\top(vaddr, len, dir);\n\t\t}\n\t\toffset = 0;\n\t\tpfn++;\n\t\tleft -= len;\n\t} while (left);\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":332546,"func":"static int vdi_co_read(BlockDriverState *bs,\n\n        int64_t sector_num, uint8_t *buf, int nb_sectors)\n\n{\n\n    BDRVVdiState *s = bs->opaque;\n\n    uint32_t bmap_entry;\n\n    uint32_t block_index;\n\n    uint32_t sector_in_block;\n\n    uint32_t n_sectors;\n\n    int ret;\n\n\n\n    logout(\"\\n\");\n\n\n\nrestart:\n\n    block_index = sector_num \/ s->block_sectors;\n\n    sector_in_block = sector_num % s->block_sectors;\n\n    n_sectors = s->block_sectors - sector_in_block;\n\n    if (n_sectors > nb_sectors) {\n\n        n_sectors = nb_sectors;\n\n    }\n\n\n\n    logout(\"will read %u sectors starting at sector %\" PRIu64 \"\\n\",\n\n           n_sectors, sector_num);\n\n\n\n    \/* prepare next AIO request *\/\n\n    bmap_entry = le32_to_cpu(s->bmap[block_index]);\n\n    if (!VDI_IS_ALLOCATED(bmap_entry)) {\n\n        \/* Block not allocated, return zeros, no need to wait. *\/\n\n        memset(buf, 0, n_sectors * SECTOR_SIZE);\n\n        ret = 0;\n\n    } else {\n\n        uint64_t offset = s->header.offset_data \/ SECTOR_SIZE +\n\n                          (uint64_t)bmap_entry * s->block_sectors +\n\n                          sector_in_block;\n\n        ret = bdrv_read(bs->file, offset, buf, n_sectors);\n\n    }\n\n    logout(\"%u sectors read\\n\", n_sectors);\n\n\n\n    nb_sectors -= n_sectors;\n\n    sector_num += n_sectors;\n\n    buf += n_sectors * SECTOR_SIZE;\n\n\n\n    if (ret >= 0 && nb_sectors > 0) {\n\n        goto restart;\n\n    }\n\n\n\n    return ret;\n\n}\n","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":135391,"func":"int sdma_send_txreq(struct sdma_engine *sde,\n\t\t    struct iowait_work *wait,\n\t\t    struct sdma_txreq *tx,\n\t\t    bool pkts_sent)\n{\n\tint ret = 0;\n\tu16 tail;\n\tunsigned long flags;\n\n\t\/* user should have supplied entire packet *\/\n\tif (unlikely(tx->tlen))\n\t\treturn -EINVAL;\n\ttx->wait = iowait_ioww_to_iow(wait);\n\tspin_lock_irqsave(&sde->tail_lock, flags);\nretry:\n\tif (unlikely(!__sdma_running(sde)))\n\t\tgoto unlock_noconn;\n\tif (unlikely(tx->num_desc > sde->desc_avail))\n\t\tgoto nodesc;\n\ttail = submit_tx(sde, tx);\n\tif (wait)\n\t\tiowait_sdma_inc(iowait_ioww_to_iow(wait));\n\tsdma_update_tail(sde, tail);\nunlock:\n\tspin_unlock_irqrestore(&sde->tail_lock, flags);\n\treturn ret;\nunlock_noconn:\n\tif (wait)\n\t\tiowait_sdma_inc(iowait_ioww_to_iow(wait));\n\ttx->next_descq_idx = 0;\n#ifdef CONFIG_HFI1_DEBUG_SDMA_ORDER\n\ttx->sn = sde->tail_sn++;\n\ttrace_hfi1_sdma_in_sn(sde, tx->sn);\n#endif\n\tspin_lock(&sde->flushlist_lock);\n\tlist_add_tail(&tx->list, &sde->flushlist);\n\tspin_unlock(&sde->flushlist_lock);\n\tiowait_inc_wait_count(wait, tx->num_desc);\n\tqueue_work_on(sde->cpu, system_highpri_wq, &sde->flush_worker);\n\tret = -ECOMM;\n\tgoto unlock;\nnodesc:\n\tret = sdma_check_progress(sde, wait, tx, pkts_sent);\n\tif (ret == -EAGAIN) {\n\t\tret = 0;\n\t\tgoto retry;\n\t}\n\tsde->descq_full_count++;\n\tgoto unlock;\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":262120,"func":"pixSetLowContrast(PIX     *pixs1,\n                  PIX     *pixs2,\n                  l_int32  mindiff)\n{\nl_int32    i, j, w, h, d, wpl, val1, val2, found;\nl_uint32  *data1, *data2, *line1, *line2;\n\n    PROCNAME(\"pixSetLowContrast\");\n\n    if (!pixs1 || !pixs2)\n        return ERROR_INT(\"pixs1 and pixs2 not both defined\", procName, 1);\n    if (pixSizesEqual(pixs1, pixs2) == 0)\n        return ERROR_INT(\"pixs1 and pixs2 not equal size\", procName, 1);\n    pixGetDimensions(pixs1, &w, &h, &d);\n    if (d != 8)\n        return ERROR_INT(\"depth not 8 bpp\", procName, 1);\n    if (mindiff > 254) return 0;\n\n    data1 = pixGetData(pixs1);\n    data2 = pixGetData(pixs2);\n    wpl = pixGetWpl(pixs1);\n    found = 0;  \/* init to not finding any diffs >= mindiff *\/\n    for (i = 0; i < h; i++) {\n        line1 = data1 + i * wpl;\n        line2 = data2 + i * wpl;\n        for (j = 0; j < w; j++) {\n            val1 = GET_DATA_BYTE(line1, j);\n            val2 = GET_DATA_BYTE(line2, j);\n            if (L_ABS(val1 - val2) >= mindiff) {\n                found = 1;\n                break;\n            }\n        }\n        if (found) break;\n    }\n    if (!found) {\n        L_WARNING(\"no pixel pair diffs as large as mindiff\\n\", procName);\n        pixClearAll(pixs1);\n        pixClearAll(pixs2);\n        return 1;\n    }\n\n    for (i = 0; i < h; i++) {\n        line1 = data1 + i * wpl;\n        line2 = data2 + i * wpl;\n        for (j = 0; j < w; j++) {\n            val1 = GET_DATA_BYTE(line1, j);\n            val2 = GET_DATA_BYTE(line2, j);\n            if (L_ABS(val1 - val2) < mindiff) {\n                SET_DATA_BYTE(line1, j, 0);\n                SET_DATA_BYTE(line2, j, 0);\n            }\n        }\n    }\n\n    return 0;\n}","target":0,"code_token_length":569,"total_token_length":805,"max_tokens_setting":1024}
+{"idx":359586,"func":"get_tip_for_vpn (NMActiveConnection *active, NMVPNConnectionState state, NMApplet *applet)\n{\n\tNMConnectionScope scope;\n\tchar *tip = NULL;\n\tconst char *path, *id = NULL;\n\tGSList *iter, *list;\n\n\tscope = nm_active_connection_get_scope (active);\n\tpath = nm_active_connection_get_connection (active);\n\tg_return_val_if_fail (path != NULL, NULL);\n\n\tlist = applet_get_all_connections (applet);\n\tfor (iter = list; iter; iter = g_slist_next (iter)) {\n\t\tNMConnection *candidate = NM_CONNECTION (iter->data);\n\t\tNMSettingConnection *s_con;\n\n\t\tif (   (nm_connection_get_scope (candidate) == scope)\n\t\t    && !strcmp (nm_connection_get_path (candidate), path)) {\n\t\t\ts_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));\n\t\t\tid = nm_setting_connection_get_id (s_con);\n\t\t\tbreak;\n\t\t}\n\t}\n\tg_slist_free (list);\n\n\tif (!id)\n\t\treturn NULL;\n\n\tswitch (state) {\n\tcase NM_VPN_CONNECTION_STATE_CONNECT:\n\tcase NM_VPN_CONNECTION_STATE_PREPARE:\n\t\ttip = g_strdup_printf (_(\"Starting VPN connection '%s'...\"), id);\n\t\tbreak;\n\tcase NM_VPN_CONNECTION_STATE_NEED_AUTH:\n\t\ttip = g_strdup_printf (_(\"User authentication required for VPN connection '%s'...\"), id);\n\t\tbreak;\n\tcase NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:\n\t\ttip = g_strdup_printf (_(\"Requesting a VPN address for '%s'...\"), id);\n\t\tbreak;\n\tcase NM_VPN_CONNECTION_STATE_ACTIVATED:\n\t\ttip = g_strdup_printf (_(\"VPN connection '%s' active\"), id);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn tip;\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":350531,"func":"    Status explain(OperationContext* opCtx,\n                   const OpMsgRequest& request,\n                   ExplainOptions::Verbosity verbosity,\n                   rpc::ReplyBuilderInterface* result) const override {\n        std::string dbname = request.getDatabase().toString();\n        const BSONObj& cmdObj = request.body;\n        \/\/ Acquire locks and resolve possible UUID. The RAII object is optional, because in the case\n        \/\/ of a view, the locks need to be released.\n        boost::optional ctx;\n        ctx.emplace(opCtx,\n                    CommandHelpers::parseNsOrUUID(dbname, cmdObj),\n                    AutoGetCollection::ViewMode::kViewsPermitted);\n        const auto nss = ctx->getNss();\n\n        const ExtensionsCallbackReal extensionsCallback(opCtx, &nss);\n        auto parsedDistinct =\n            uassertStatusOK(ParsedDistinct::parse(opCtx, nss, cmdObj, extensionsCallback, true));\n\n        if (ctx->getView()) {\n            \/\/ Relinquish locks. The aggregation command will re-acquire them.\n            ctx.reset();\n\n            auto viewAggregation = parsedDistinct.asAggregationCommand();\n            if (!viewAggregation.isOK()) {\n                return viewAggregation.getStatus();\n            }\n\n            auto viewAggRequest =\n                AggregationRequest::parseFromBSON(nss, viewAggregation.getValue(), verbosity);\n            if (!viewAggRequest.isOK()) {\n                return viewAggRequest.getStatus();\n            }\n\n            return runAggregate(\n                opCtx, nss, viewAggRequest.getValue(), viewAggregation.getValue(), result);\n        }\n\n        Collection* const collection = ctx->getCollection();\n\n        auto executor = uassertStatusOK(\n            getExecutorDistinct(opCtx, collection, QueryPlannerParams::DEFAULT, &parsedDistinct));\n\n        auto bodyBuilder = result->getBodyBuilder();\n        Explain::explainStages(executor.get(), collection, verbosity, &bodyBuilder);\n        return Status::OK();\n    }","target":1,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":307215,"func":"int ShellBrowserMain(const content::MainFunctionParams& parameters) {\n  bool layout_test_mode =\n      CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree);\n  base::ScopedTempDir browser_context_path_for_layout_tests;\n\n  if (layout_test_mode) {\n    CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir());\n    CHECK(!browser_context_path_for_layout_tests.path().MaybeAsASCII().empty());\n    CommandLine::ForCurrentProcess()->AppendSwitchASCII(\n        switches::kContentShellDataPath,\n        browser_context_path_for_layout_tests.path().MaybeAsASCII());\n  }\n\n  scoped_ptr main_runner_(\n      content::BrowserMainRunner::Create());\n\n  int exit_code = main_runner_->Initialize(parameters);\n\n  if (exit_code >= 0)\n    return exit_code;\n\n  if (CommandLine::ForCurrentProcess()->HasSwitch(\n        switches::kCheckLayoutTestSysDeps)) {\n    MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());\n    main_runner_->Run();\n    main_runner_->Shutdown();\n    return 0;\n  }\n\n  if (layout_test_mode) {\n    content::WebKitTestController test_controller;\n    std::string test_string;\n    CommandLine::StringVector args =\n        CommandLine::ForCurrentProcess()->GetArgs();\n    size_t command_line_position = 0;\n    bool ran_at_least_once = false;\n\n#if defined(OS_ANDROID)\n    std::cout << \"#READY\\n\";\n     std::cout.flush();\n #endif\n \n    FilePath original_cwd;\n    {\n      \/\/ We're outside of the message loop here, and this is a test.\n      base::ThreadRestrictions::ScopedAllowIO allow_io;\n      file_util::GetCurrentDirectory(&original_cwd);\n    }\n\n     while (GetNextTest(args, &command_line_position, &test_string)) {\n       if (test_string.empty())\n         continue;\n      if (test_string == \"QUIT\")\n        break;\n\n      bool enable_pixel_dumps;\n      std::string pixel_hash;\n      FilePath cwd;\n      GURL test_url = GetURLForLayoutTest(\n          test_string, &cwd, &enable_pixel_dumps, &pixel_hash);\n      if (!content::WebKitTestController::Get()->PrepareForLayoutTest(\n              test_url, cwd, enable_pixel_dumps, pixel_hash)) {\n        break;\n      }\n\n       ran_at_least_once = true;\n       main_runner_->Run();\n \n      {\n        \/\/ We're outside of the message loop here, and this is a test.\n        base::ThreadRestrictions::ScopedAllowIO allow_io;\n        file_util::SetCurrentDirectory(original_cwd);\n      }\n\n       if (!content::WebKitTestController::Get()->ResetAfterLayoutTest())\n         break;\n     }\n    if (!ran_at_least_once) {\n      MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());\n      main_runner_->Run();\n    }\n    exit_code = 0;\n  } else {\n    exit_code = main_runner_->Run();\n  }\n\n  main_runner_->Shutdown();\n\n  return exit_code;\n}\n","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":70221,"func":"void __ext4_error_inode(struct inode *inode, const char *function,\n\t\t\tunsigned int line, ext4_fsblk_t block,\n\t\t\tconst char *fmt, ...)\n{\n\tva_list args;\n\tstruct va_format vaf;\n\tstruct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;\n\n\tes->s_last_error_ino = cpu_to_le32(inode->i_ino);\n\tes->s_last_error_block = cpu_to_le64(block);\n\tif (ext4_error_ratelimit(inode->i_sb)) {\n\t\tva_start(args, fmt);\n\t\tvaf.fmt = fmt;\n\t\tvaf.va = &args;\n\t\tif (block)\n\t\t\tprintk(KERN_CRIT \"EXT4-fs error (device %s): %s:%d: \"\n\t\t\t       \"inode #%lu: block %llu: comm %s: %pV\\n\",\n\t\t\t       inode->i_sb->s_id, function, line, inode->i_ino,\n\t\t\t       block, current->comm, &vaf);\n\t\telse\n\t\t\tprintk(KERN_CRIT \"EXT4-fs error (device %s): %s:%d: \"\n\t\t\t       \"inode #%lu: comm %s: %pV\\n\",\n\t\t\t       inode->i_sb->s_id, function, line, inode->i_ino,\n\t\t\t       current->comm, &vaf);\n\t\tva_end(args);\n\t}\n\tsave_error_info(inode->i_sb, function, line);\n\text4_handle_error(inode->i_sb);\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":214753,"func":"gsicc_get_srcprofile(gsicc_colorbuffer_t data_cs,\n                     gs_graphics_type_tag_t graphics_type_tag,\n                     cmm_srcgtag_profile_t *srcgtag_profile,\n                     cmm_profile_t **profile, gsicc_rendering_param_t *render_cond)\n{\n    (*profile) = NULL;\n    (*render_cond).rendering_intent = gsPERCEPTUAL;\n    switch (graphics_type_tag & ~GS_DEVICE_ENCODES_TAGS) {\n        case GS_UNKNOWN_TAG:\n        case GS_UNTOUCHED_TAG:\n        default:\n            break;\n        case GS_PATH_TAG:\n            if (data_cs == gsRGB) {\n                (*profile) = srcgtag_profile->rgb_profiles[gsSRC_GRAPPRO];\n                *render_cond = srcgtag_profile->rgb_rend_cond[gsSRC_GRAPPRO];\n            } else if (data_cs == gsCMYK) {\n                (*profile) = srcgtag_profile->cmyk_profiles[gsSRC_GRAPPRO];\n                *render_cond = srcgtag_profile->cmyk_rend_cond[gsSRC_GRAPPRO];\n            } else if (data_cs == gsGRAY) {\n                (*profile) = srcgtag_profile->gray_profiles[gsSRC_GRAPPRO];\n                *render_cond = srcgtag_profile->gray_rend_cond[gsSRC_GRAPPRO];\n            }\n            break;\n        case GS_IMAGE_TAG:\n            if (data_cs == gsRGB) {\n                (*profile) = srcgtag_profile->rgb_profiles[gsSRC_IMAGPRO];\n                *render_cond = srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO];\n            } else if (data_cs == gsCMYK) {\n                (*profile) = srcgtag_profile->cmyk_profiles[gsSRC_IMAGPRO];\n                *render_cond = srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO];\n            } else if (data_cs == gsGRAY) {\n                (*profile) = srcgtag_profile->gray_profiles[gsSRC_IMAGPRO];\n                *render_cond = srcgtag_profile->gray_rend_cond[gsSRC_IMAGPRO];\n            }\n            break;\n        case GS_TEXT_TAG:\n            if (data_cs == gsRGB) {\n                (*profile) = srcgtag_profile->rgb_profiles[gsSRC_TEXTPRO];\n                *render_cond = srcgtag_profile->rgb_rend_cond[gsSRC_TEXTPRO];\n            } else if (data_cs == gsCMYK) {\n                (*profile) = srcgtag_profile->cmyk_profiles[gsSRC_TEXTPRO];\n                *render_cond = srcgtag_profile->cmyk_rend_cond[gsSRC_TEXTPRO];\n            } else if (data_cs == gsGRAY) {\n                (*profile) = srcgtag_profile->gray_profiles[gsSRC_TEXTPRO];\n                *render_cond = srcgtag_profile->gray_rend_cond[gsSRC_TEXTPRO];\n            }\n            break;\n        }\n}\n","target":0,"code_token_length":629,"total_token_length":865,"max_tokens_setting":1024}
+{"idx":395653,"func":"int manager_load_unit_prepare(\n                Manager *m,\n                const char *name,\n                const char *path,\n                sd_bus_error *e,\n                Unit **_ret) {\n\n        Unit *ret;\n        UnitType t;\n        int r;\n\n        assert(m);\n        assert(name || path);\n\n        \/* This will prepare the unit for loading, but not actually\n         * load anything from disk. *\/\n\n        if (path && !is_path(path))\n                return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, \"Path %s is not absolute.\", path);\n\n        if (!name)\n                name = basename(path);\n\n        t = unit_name_to_type(name);\n\n        if (t == _UNIT_TYPE_INVALID || !unit_name_is_valid(name, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) {\n                if (unit_name_is_valid(name, UNIT_NAME_TEMPLATE))\n                        return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, \"Unit name %s is missing the instance name.\", name);\n\n                return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, \"Unit name %s is not valid.\", name);\n        }\n\n        ret = manager_get_unit(m, name);\n        if (ret) {\n                *_ret = ret;\n                return 1;\n        }\n\n        ret = unit_new(m, unit_vtable[t]->object_size);\n        if (!ret)\n                return -ENOMEM;\n\n        if (path) {\n                ret->fragment_path = strdup(path);\n                if (!ret->fragment_path) {\n                        unit_free(ret);\n                        return -ENOMEM;\n                }\n        }\n\n        r = unit_add_name(ret, name);\n        if (r < 0) {\n                unit_free(ret);\n                return r;\n        }\n\n        unit_add_to_load_queue(ret);\n        unit_add_to_dbus_queue(ret);\n        unit_add_to_gc_queue(ret);\n\n        if (_ret)\n                *_ret = ret;\n\n        return 0;\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":153800,"func":"BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,\n                                    const OPAQUE_RECT_ORDER* opaque_rect)\n{\n\tBYTE byte;\n\tint inf = update_approximate_opaque_rect_order(orderInfo, opaque_rect);\n\n\tif (!Stream_EnsureRemainingCapacity(s, inf))\n\t\treturn FALSE;\n\n\t\/\/ TODO: Color format conversion\n\torderInfo->fieldFlags = 0;\n\torderInfo->fieldFlags |= ORDER_FIELD_01;\n\tupdate_write_coord(s, opaque_rect->nLeftRect);\n\torderInfo->fieldFlags |= ORDER_FIELD_02;\n\tupdate_write_coord(s, opaque_rect->nTopRect);\n\torderInfo->fieldFlags |= ORDER_FIELD_03;\n\tupdate_write_coord(s, opaque_rect->nWidth);\n\torderInfo->fieldFlags |= ORDER_FIELD_04;\n\tupdate_write_coord(s, opaque_rect->nHeight);\n\torderInfo->fieldFlags |= ORDER_FIELD_05;\n\tbyte = opaque_rect->color & 0x000000FF;\n\tStream_Write_UINT8(s, byte);\n\torderInfo->fieldFlags |= ORDER_FIELD_06;\n\tbyte = (opaque_rect->color & 0x0000FF00) >> 8;\n\tStream_Write_UINT8(s, byte);\n\torderInfo->fieldFlags |= ORDER_FIELD_07;\n\tbyte = (opaque_rect->color & 0x00FF0000) >> 16;\n\tStream_Write_UINT8(s, byte);\n\treturn TRUE;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":342147,"func":"static int int_pow(int i, int *exp_ptr)\n\n{\n\n    int e, er, eq, j;\n\n    int a, a1;\n\n    \n\n    \/* renormalize *\/\n\n    a = i;\n\n    e = POW_FRAC_BITS;\n\n    while (a < (1 << (POW_FRAC_BITS - 1))) {\n\n        a = a << 1;\n\n        e--;\n\n    }\n\n    a -= (1 << POW_FRAC_BITS);\n\n    a1 = 0;\n\n    for(j = DEV_ORDER - 1; j >= 0; j--)\n\n        a1 = POW_MULL(a, dev_4_3_coefs[j] + a1);\n\n    a = (1 << POW_FRAC_BITS) + a1;\n\n    \/* exponent compute (exact) *\/\n\n    e = e * 4;\n\n    er = e % 3;\n\n    eq = e \/ 3;\n\n    a = POW_MULL(a, pow_mult3[er]);\n\n    while (a >= 2 * POW_FRAC_ONE) {\n\n        a = a >> 1;\n\n        eq++;\n\n    }\n\n    \/* convert to float *\/\n\n    while (a < POW_FRAC_ONE) {\n\n        a = a << 1;\n\n        eq--;\n\n    }\n\n    \/* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE *\/\n\n#if (POW_FRAC_BITS - 1) > FRAC_BITS\n\n    a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS);\n\n    \/* correct overflow *\/\n\n    if (a >= 2 * (1 << FRAC_BITS)) {\n\n        a = a >> 1;\n\n        eq++;\n\n    }\n\n#endif\n\n    *exp_ptr = eq;\n\n    return a;\n\n}\n","target":1,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":42355,"func":"static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc,\n\t\t\t\t   struct nfs_entry *entry,\n\t\t\t\t   struct page **xdr_pages,\n\t\t\t\t   unsigned int buflen,\n\t\t\t\t   struct page **arrays,\n\t\t\t\t   size_t narrays)\n{\n\tstruct address_space *mapping = desc->file->f_mapping;\n\tstruct xdr_stream stream;\n\tstruct xdr_buf buf;\n\tstruct page *scratch, *new, *page = *arrays;\n\tint status;\n\n\tscratch = alloc_page(GFP_KERNEL);\n\tif (scratch == NULL)\n\t\treturn -ENOMEM;\n\n\txdr_init_decode_pages(&stream, &buf, xdr_pages, buflen);\n\txdr_set_scratch_page(&stream, scratch);\n\n\tdo {\n\t\tif (entry->fattr->label)\n\t\t\tentry->fattr->label->len = NFS4_MAXLABELLEN;\n\n\t\tstatus = xdr_decode(desc, entry, &stream);\n\t\tif (status != 0)\n\t\t\tbreak;\n\n\t\tif (desc->plus)\n\t\t\tnfs_prime_dcache(file_dentry(desc->file), entry,\n\t\t\t\t\tdesc->dir_verifier);\n\n\t\tstatus = nfs_readdir_add_to_array(entry, page);\n\t\tif (status != -ENOSPC)\n\t\t\tcontinue;\n\n\t\tif (page->mapping != mapping) {\n\t\t\tif (!--narrays)\n\t\t\t\tbreak;\n\t\t\tnew = nfs_readdir_page_array_alloc(entry->prev_cookie,\n\t\t\t\t\t\t\t   GFP_KERNEL);\n\t\t\tif (!new)\n\t\t\t\tbreak;\n\t\t\tarrays++;\n\t\t\t*arrays = page = new;\n\t\t} else {\n\t\t\tnew = nfs_readdir_page_get_next(mapping,\n\t\t\t\t\t\t\tpage->index + 1,\n\t\t\t\t\t\t\tentry->prev_cookie);\n\t\t\tif (!new)\n\t\t\t\tbreak;\n\t\t\tif (page != *arrays)\n\t\t\t\tnfs_readdir_page_unlock_and_put(page);\n\t\t\tpage = new;\n\t\t}\n\t\tstatus = nfs_readdir_add_to_array(entry, page);\n\t} while (!status && !entry->eof);\n\n\tswitch (status) {\n\tcase -EBADCOOKIE:\n\t\tif (entry->eof) {\n\t\t\tnfs_readdir_page_set_eof(page);\n\t\t\tstatus = 0;\n\t\t}\n\t\tbreak;\n\tcase -ENOSPC:\n\tcase -EAGAIN:\n\t\tstatus = 0;\n\t\tbreak;\n\t}\n\n\tif (page != *arrays)\n\t\tnfs_readdir_page_unlock_and_put(page);\n\n\tput_page(scratch);\n\treturn status;\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":172501,"func":"Browser::~Browser() {\n  registrar_.RemoveAll();\n  extension_registry_observer_.RemoveAll();\n\n  DCHECK(tab_strip_model_->empty());\n  tab_strip_model_->RemoveObserver(this);\n  bubble_manager_.reset();\n\n  command_controller_.reset();\n  BrowserList::RemoveBrowser(this);\n\n  int num_downloads;\n  if (!browser_defaults::kBrowserAliveWithNoWindows &&\n      OkToCloseWithInProgressDownloads(&num_downloads) ==\n          DOWNLOAD_CLOSE_BROWSER_SHUTDOWN) {\n    DownloadCoreService::CancelAllDownloads();\n  }\n\n  SessionService* session_service =\n      SessionServiceFactory::GetForProfile(profile_);\n  if (session_service)\n    session_service->WindowClosed(session_id_);\n\n  sessions::TabRestoreService* tab_restore_service =\n      TabRestoreServiceFactory::GetForProfile(profile());\n  if (tab_restore_service)\n    tab_restore_service->BrowserClosed(live_tab_context());\n\n  profile_pref_registrar_.RemoveAll();\n\n  extension_window_controller_.reset();\n\n  instant_controller_.reset();\n\n  if (profile_->IsOffTheRecord() &&\n      profile_->GetOriginalProfile()->HasOffTheRecordProfile() &&\n      profile_->GetOriginalProfile()->GetOffTheRecordProfile() == profile_ &&\n      !BrowserList::IsIncognitoSessionActiveForProfile(profile_) &&\n      !profile_->GetOriginalProfile()->IsSystemProfile()) {\n    if (profile_->IsGuestSession()) {\n#if !defined(OS_CHROMEOS)\n      profiles::RemoveBrowsingDataForProfile(profile_->GetPath());\n#endif\n    } else {\n#if BUILDFLAG(ENABLE_PRINT_PREVIEW)\n      g_browser_process->background_printing_manager()\n          ->DeletePreviewContentsForBrowserContext(profile_);\n#endif\n      ProfileDestroyer::DestroyProfileWhenAppropriate(profile_);\n    }\n  }\n\n  if (select_file_dialog_.get())\n    select_file_dialog_->ListenerDestroyed();\n}\n","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":409797,"func":"static int\n__skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len,\n\t       unsigned int recursion_level)\n{\n\tint start = skb_headlen(skb);\n\tint i, copy = start - offset;\n\tstruct sk_buff *frag_iter;\n\tint elt = 0;\n\n\tif (unlikely(recursion_level >= 24))\n\t\treturn -EMSGSIZE;\n\n\tif (copy > 0) {\n\t\tif (copy > len)\n\t\t\tcopy = len;\n\t\tsg_set_buf(sg, skb->data + offset, copy);\n\t\telt++;\n\t\tif ((len -= copy) == 0)\n\t\t\treturn elt;\n\t\toffset += copy;\n\t}\n\n\tfor (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {\n\t\tint end;\n\n\t\tWARN_ON(start > offset + len);\n\n\t\tend = start + skb_frag_size(&skb_shinfo(skb)->frags[i]);\n\t\tif ((copy = end - offset) > 0) {\n\t\t\tskb_frag_t *frag = &skb_shinfo(skb)->frags[i];\n\t\t\tif (unlikely(elt && sg_is_last(&sg[elt - 1])))\n\t\t\t\treturn -EMSGSIZE;\n\n\t\t\tif (copy > len)\n\t\t\t\tcopy = len;\n\t\t\tsg_set_page(&sg[elt], skb_frag_page(frag), copy,\n\t\t\t\t\tfrag->page_offset+offset-start);\n\t\t\telt++;\n\t\t\tif (!(len -= copy))\n\t\t\t\treturn elt;\n\t\t\toffset += copy;\n\t\t}\n\t\tstart = end;\n\t}\n\n\tskb_walk_frags(skb, frag_iter) {\n\t\tint end, ret;\n\n\t\tWARN_ON(start > offset + len);\n\n\t\tend = start + frag_iter->len;\n\t\tif ((copy = end - offset) > 0) {\n\t\t\tif (unlikely(elt && sg_is_last(&sg[elt - 1])))\n\t\t\t\treturn -EMSGSIZE;\n\n\t\t\tif (copy > len)\n\t\t\t\tcopy = len;\n\t\t\tret = __skb_to_sgvec(frag_iter, sg+elt, offset - start,\n\t\t\t\t\t      copy, recursion_level + 1);\n\t\t\tif (unlikely(ret < 0))\n\t\t\t\treturn ret;\n\t\t\telt += ret;\n\t\t\tif ((len -= copy) == 0)\n\t\t\t\treturn elt;\n\t\t\toffset += copy;\n\t\t}\n\t\tstart = end;\n\t}\n\tBUG_ON(len);\n\treturn elt;","target":0,"code_token_length":496,"total_token_length":732,"max_tokens_setting":1024}
+{"idx":111599,"func":"static int descriptors_changed(struct usb_device *udev,\n\t\tstruct usb_device_descriptor *old_device_descriptor,\n\t\tstruct usb_host_bos *old_bos)\n{\n\tint\t\tchanged = 0;\n\tunsigned\tindex;\n\tunsigned\tserial_len = 0;\n\tunsigned\tlen;\n\tunsigned\told_length;\n\tint\t\tlength;\n\tchar\t\t*buf;\n\n\tif (memcmp(&udev->descriptor, old_device_descriptor,\n\t\t\tsizeof(*old_device_descriptor)) != 0)\n\t\treturn 1;\n\n\tif ((old_bos && !udev->bos) || (!old_bos && udev->bos))\n\t\treturn 1;\n\tif (udev->bos) {\n\t\tlen = le16_to_cpu(udev->bos->desc->wTotalLength);\n\t\tif (len != le16_to_cpu(old_bos->desc->wTotalLength))\n\t\t\treturn 1;\n\t\tif (memcmp(udev->bos->desc, old_bos->desc, len))\n\t\t\treturn 1;\n\t}\n\n\t\/* Since the idVendor, idProduct, and bcdDevice values in the\n\t * device descriptor haven't changed, we will assume the\n\t * Manufacturer and Product strings haven't changed either.\n\t * But the SerialNumber string could be different (e.g., a\n\t * different flash card of the same brand).\n\t *\/\n\tif (udev->serial)\n\t\tserial_len = strlen(udev->serial) + 1;\n\n\tlen = serial_len;\n\tfor (index = 0; index < udev->descriptor.bNumConfigurations; index++) {\n\t\told_length = le16_to_cpu(udev->config[index].desc.wTotalLength);\n\t\tlen = max(len, old_length);\n\t}\n\n\tbuf = kmalloc(len, GFP_NOIO);\n\tif (!buf)\n\t\t\/* assume the worst *\/\n\t\treturn 1;\n\n\tfor (index = 0; index < udev->descriptor.bNumConfigurations; index++) {\n\t\told_length = le16_to_cpu(udev->config[index].desc.wTotalLength);\n\t\tlength = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf,\n\t\t\t\told_length);\n\t\tif (length != old_length) {\n\t\t\tdev_dbg(&udev->dev, \"config index %d, error %d\\n\",\n\t\t\t\t\tindex, length);\n\t\t\tchanged = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif (memcmp(buf, udev->rawdescriptors[index], old_length)\n\t\t\t\t!= 0) {\n\t\t\tdev_dbg(&udev->dev, \"config index %d changed (#%d)\\n\",\n\t\t\t\tindex,\n\t\t\t\t((struct usb_config_descriptor *) buf)->\n\t\t\t\t\tbConfigurationValue);\n\t\t\tchanged = 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!changed && serial_len) {\n\t\tlength = usb_string(udev, udev->descriptor.iSerialNumber,\n\t\t\t\tbuf, serial_len);\n\t\tif (length + 1 != serial_len) {\n\t\t\tdev_dbg(&udev->dev, \"serial string error %d\\n\",\n\t\t\t\t\tlength);\n\t\t\tchanged = 1;\n\t\t} else if (memcmp(buf, udev->serial, length) != 0) {\n\t\t\tdev_dbg(&udev->dev, \"serial string changed\\n\");\n\t\t\tchanged = 1;\n\t\t}\n\t}\n\n\tkfree(buf);\n\treturn changed;\n}","target":0,"code_token_length":682,"total_token_length":918,"max_tokens_setting":1024}
+{"idx":388034,"func":"start_conversation (GdmSession *self,\n                    const char *service_name)\n{\n        GdmSessionConversation *conversation;\n        char                   *job_name;\n\n        conversation = g_new0 (GdmSessionConversation, 1);\n        conversation->session = g_object_ref (self);\n        conversation->service_name = g_strdup (service_name);\n        conversation->worker_pid = -1;\n        conversation->job = gdm_session_worker_job_new ();\n        gdm_session_worker_job_set_server_address (conversation->job,\n                                                   g_dbus_server_get_client_address (self->priv->worker_server));\n        gdm_session_worker_job_set_for_reauth (conversation->job,\n                                               self->priv->verification_mode == GDM_SESSION_VERIFICATION_MODE_REAUTHENTICATE);\n\n        if (self->priv->conversation_environment != NULL) {\n                gdm_session_worker_job_set_environment (conversation->job,\n                                                        (const char * const *)\n                                                        self->priv->conversation_environment);\n\n        }\n        g_signal_connect (conversation->job,\n                          \"started\",\n                          G_CALLBACK (worker_started),\n                          conversation);\n        g_signal_connect (conversation->job,\n                          \"exited\",\n                          G_CALLBACK (worker_exited),\n                          conversation);\n        g_signal_connect (conversation->job,\n                          \"died\",\n                          G_CALLBACK (worker_died),\n                          conversation);\n\n        job_name = g_strdup_printf (\"gdm-session-worker [pam\/%s]\", service_name);\n        if (!gdm_session_worker_job_start (conversation->job, job_name)) {\n                g_object_unref (conversation->job);\n                g_free (conversation->service_name);\n                g_free (conversation);\n                g_free (job_name);\n                return NULL;\n        }\n\n        g_free (job_name);\n\n        conversation->worker_pid = gdm_session_worker_job_get_pid (conversation->job);\n\n        return conversation;\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":433111,"func":"static int read_rindex_entry(struct gfs2_inode *ip)\n{\n\tstruct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);\n\tconst unsigned bsize = sdp->sd_sb.sb_bsize;\n\tloff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex);\n\tstruct gfs2_rindex buf;\n\tint error;\n\tstruct gfs2_rgrpd *rgd;\n\n\tif (pos >= i_size_read(&ip->i_inode))\n\t\treturn 1;\n\n\terror = gfs2_internal_read(ip, (char *)&buf, &pos,\n\t\t\t\t   sizeof(struct gfs2_rindex));\n\n\tif (error != sizeof(struct gfs2_rindex))\n\t\treturn (error == 0) ? 1 : error;\n\n\trgd = kmem_cache_zalloc(gfs2_rgrpd_cachep, GFP_NOFS);\n\terror = -ENOMEM;\n\tif (!rgd)\n\t\treturn error;\n\n\trgd->rd_sbd = sdp;\n\trgd->rd_addr = be64_to_cpu(buf.ri_addr);\n\trgd->rd_length = be32_to_cpu(buf.ri_length);\n\trgd->rd_data0 = be64_to_cpu(buf.ri_data0);\n\trgd->rd_data = be32_to_cpu(buf.ri_data);\n\trgd->rd_bitbytes = be32_to_cpu(buf.ri_bitbytes);\n\tspin_lock_init(&rgd->rd_rsspin);\n\n\terror = compute_bitstructs(rgd);\n\tif (error)\n\t\tgoto fail;\n\n\terror = gfs2_glock_get(sdp, rgd->rd_addr,\n\t\t\t       &gfs2_rgrp_glops, CREATE, &rgd->rd_gl);\n\tif (error)\n\t\tgoto fail;\n\n\trgd->rd_rgl = (struct gfs2_rgrp_lvb *)rgd->rd_gl->gl_lksb.sb_lvbptr;\n\trgd->rd_flags &= ~(GFS2_RDF_UPTODATE | GFS2_RDF_PREFERRED);\n\tif (rgd->rd_data > sdp->sd_max_rg_data)\n\t\tsdp->sd_max_rg_data = rgd->rd_data;\n\tspin_lock(&sdp->sd_rindex_spin);\n\terror = rgd_insert(rgd);\n\tspin_unlock(&sdp->sd_rindex_spin);\n\tif (!error) {\n\t\trgd->rd_gl->gl_object = rgd;\n\t\trgd->rd_gl->gl_vm.start = (rgd->rd_addr * bsize) & PAGE_MASK;\n\t\trgd->rd_gl->gl_vm.end = PAGE_ALIGN((rgd->rd_addr +\n\t\t\t\t\t\t    rgd->rd_length) * bsize) - 1;\n\t\treturn 0;\n\t}\n\n\terror = 0; \/* someone else read in the rgrp; free it and ignore it *\/\n\tgfs2_glock_put(rgd->rd_gl);\n\nfail:\n\tkfree(rgd->rd_bits);\n\trgd->rd_bits = NULL;\n\tkmem_cache_free(gfs2_rgrpd_cachep, rgd);\n\treturn error;\n}","target":0,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":425054,"func":"void acquire_daemonlock(int closeflag) {\n\tstatic int fd = -1;\n\tchar buf[3 * MAX_FNAME];\n\tconst char *pidfile;\n\tchar *ep;\n\tlong otherpid = -1;\n\tssize_t num, len;\n\tpid_t pid = getpid();\n\n\tif (closeflag) {\n\t\t\/* close stashed fd for child so we don't leak it. *\/\n\t\tif (fd != -1) {\n\t\t\tclose(fd);\n\t\t\tfd = -1;\n\t\t}\n\t\t\/* and restore default sig handlers so we don't remove pid file if killed *\/\n\t\tsignal(SIGINT,SIG_DFL);\n\t\tsignal(SIGTERM,SIG_DFL);\n\t\treturn;\n\t}\n\n\tif (NoFork == 1)\n\t\treturn; \/\/move along, nothing to do here...\n\n\tif (fd == -1) {\n\t\tpidfile = _PATH_CRON_PID;\n\t\t\/* Initial mode is 0600 to prevent flock() race\/DoS. *\/\n\t\tif ((fd = open(pidfile, O_RDWR | O_CREAT, 0600)) == -1) {\n\t\t\tint save_errno = errno;\n\t\t\tsprintf(buf, \"can't open or create %s\", pidfile);\n\t\t\tfprintf(stderr, \"%s: %s: %s\\n\", ProgramName, buf,\n\t\t\t\tstrerror(save_errno));\n\t\t\tlog_it(\"CRON\", pid, \"DEATH\", buf, save_errno);\n\t\t\texit(ERROR_EXIT);\n\t\t}\n\n\t\tif (trylock_file(fd) < OK) {\n\t\t\tint save_errno = errno;\n\n\t\t\tmemset(buf, 0, sizeof (buf));\n\t\t\tif ((num = read(fd, buf, sizeof (buf) - 1)) > 0 &&\n\t\t\t\t(otherpid = strtol(buf, &ep, 10)) > 0 &&\n\t\t\t\tep != buf && *ep == '\\n' && otherpid != LONG_MAX) {\n\t\t\t\tsnprintf(buf, sizeof (buf),\n\t\t\t\t\t\"can't lock %s, otherpid may be %ld\", pidfile, otherpid);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsnprintf(buf, sizeof (buf),\n\t\t\t\t\t\"can't lock %s, otherpid unknown\", pidfile);\n\t\t\t}\n\t\t\tfprintf(stderr, \"%s: %s: %s\\n\", ProgramName, buf,\n\t\t\t\tstrerror(save_errno));\n\t\t\tlog_it(\"CRON\", pid, \"DEATH\", buf, save_errno);\n\t\t\texit(ERROR_EXIT);\n\t\t}\n\t\t(void) fchmod(fd, 0644);\n\t\t(void) fcntl(fd, F_SETFD, 1);\n\t}\n#if !defined(HAVE_FLOCK)\n\telse {\n\t\t\/* Racy but better than nothing, just hope the parent exits *\/\n\t\tsleep(0);\n\t\ttrylock_file(fd);\t\n\t}\n#endif\n\n\tsprintf(buf, \"%ld\\n\", (long) pid);\n\t(void) lseek(fd, (off_t) 0, SEEK_SET);\n\tlen = (ssize_t)strlen(buf);\n\tif ((num = write(fd, buf, (size_t)len)) != len)\n\t\tlog_it(\"CRON\", pid, \"ERROR\", \"write() failed\", errno);\n\telse {\n\t\tif (ftruncate(fd, num) == -1)\n\t\t\tlog_it(\"CRON\", pid, \"ERROR\", \"ftruncate() failed\", errno);\n\t}\n\n\t\/* abandon fd even though the file is open. we need to keep\n\t * it open and locked, but we don't need the handles elsewhere.\n\t *\/\n}","target":0,"code_token_length":726,"total_token_length":962,"max_tokens_setting":1024}
+{"idx":486104,"func":"static int fprintf_utab_fs(FILE *f, struct libmnt_fs *fs)\n{\n\tchar *p;\n\tint rc = 0;\n\n\tassert(fs);\n\tassert(f);\n\n\tif (!fs || !f)\n\t\treturn -EINVAL;\n\n\tp = mangle(mnt_fs_get_source(fs));\n\tif (p) {\n\t\trc = fprintf(f, \"SRC=%s \", p);\n\t\tfree(p);\n\t}\n\tif (rc >= 0) {\n\t\tp = mangle(mnt_fs_get_target(fs));\n\t\tif (p) {\n\t\t\trc = fprintf(f, \"TARGET=%s \", p);\n\t\t\tfree(p);\n\t\t}\n\t}\n\tif (rc >= 0) {\n\t\tp = mangle(mnt_fs_get_root(fs));\n\t\tif (p) {\n\t\t\trc = fprintf(f, \"ROOT=%s \", p);\n\t\t\tfree(p);\n\t\t}\n\t}\n\tif (rc >= 0) {\n\t\tp = mangle(mnt_fs_get_bindsrc(fs));\n\t\tif (p) {\n\t\t\trc = fprintf(f, \"BINDSRC=%s \", p);\n\t\t\tfree(p);\n\t\t}\n\t}\n\tif (rc >= 0) {\n\t\tp = mangle(mnt_fs_get_attributes(fs));\n\t\tif (p) {\n\t\t\trc = fprintf(f, \"ATTRS=%s \", p);\n\t\t\tfree(p);\n\t\t}\n\t}\n\tif (rc >= 0) {\n\t\tp = mangle(mnt_fs_get_user_options(fs));\n\t\tif (p) {\n\t\t\trc = fprintf(f, \"OPTS=%s\", p);\n\t\t\tfree(p);\n\t\t}\n\t}\n\tif (rc >= 0)\n\t\trc = fprintf(f, \"\\n\");\n\n\tif (rc > 0)\n\t\trc = 0;\t\/* success *\/\n\treturn rc;\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":230083,"func":"qtdemux_tag_add_blob (GNode * node, GstQTDemux * demux)\n{\n  gint len;\n  guint8 *data;\n  GstBuffer *buf;\n  gchar *media_type, *style;\n  GstCaps *caps;\n\n  data = node->data;\n  len = QT_UINT32 (data);\n  buf = gst_buffer_new_and_alloc (len);\n  memcpy (GST_BUFFER_DATA (buf), data, len);\n\n  \/* heuristic to determine style of tag *\/\n  if (QT_FOURCC (data + 4) == FOURCC_____ ||\n      (len > 8 + 12 && QT_FOURCC (data + 12) == FOURCC_data))\n    style = \"itunes\";\n  else if (demux->major_brand == GST_MAKE_FOURCC ('q', 't', ' ', ' '))\n    style = \"quicktime\";\n  \/* fall back to assuming iso\/3gp tag style *\/\n  else\n    style = \"iso\";\n\n  media_type = g_strdup_printf (\"application\/x-gst-qt-%c%c%c%c-tag\",\n      g_ascii_tolower (data[4]), g_ascii_tolower (data[5]),\n      g_ascii_tolower (data[6]), g_ascii_tolower (data[7]));\n  caps = gst_caps_new_simple (media_type, \"style\", G_TYPE_STRING, style, NULL);\n  gst_buffer_set_caps (buf, caps);\n  gst_caps_unref (caps);\n  g_free (media_type);\n\n  GST_DEBUG_OBJECT (demux, \"adding private tag; size %d, caps %\" GST_PTR_FORMAT,\n      GST_BUFFER_SIZE (buf), caps);\n\n  gst_tag_list_add (demux->tag_list, GST_TAG_MERGE_APPEND,\n      GST_QT_DEMUX_PRIVATE_TAG, buf, NULL);\n  gst_buffer_unref (buf);\n}\n","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":195735,"func":"bool DrawingBuffer::Initialize(const IntSize& size, bool use_multisampling) {\n  ScopedStateRestorer scoped_state_restorer(this);\n\n  if (gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {\n    return false;\n  }\n\n  gl_->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_);\n\n  int max_sample_count = 0;\n  anti_aliasing_mode_ = kNone;\n  if (use_multisampling) {\n    gl_->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &max_sample_count);\n    anti_aliasing_mode_ = kMSAAExplicitResolve;\n    if (extensions_util_->SupportsExtension(\n            \"GL_EXT_multisampled_render_to_texture\")) {\n      anti_aliasing_mode_ = kMSAAImplicitResolve;\n    } else if (extensions_util_->SupportsExtension(\n                   \"GL_CHROMIUM_screen_space_antialiasing\")) {\n      anti_aliasing_mode_ = kScreenSpaceAntialiasing;\n    }\n  }\n   storage_texture_supported_ =\n      (webgl_version_ > kWebGL1 ||\n        extensions_util_->SupportsExtension(\"GL_EXT_texture_storage\")) &&\n       anti_aliasing_mode_ == kScreenSpaceAntialiasing;\n   sample_count_ = std::min(4, max_sample_count);\n\n  state_restorer_->SetFramebufferBindingDirty();\n  gl_->GenFramebuffers(1, &fbo_);\n  gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);\n  if (WantExplicitResolve()) {\n    gl_->GenFramebuffers(1, &multisample_fbo_);\n    gl_->BindFramebuffer(GL_FRAMEBUFFER, multisample_fbo_);\n    gl_->GenRenderbuffers(1, &multisample_renderbuffer_);\n  }\n  if (!ResizeFramebufferInternal(size))\n    return false;\n\n  if (depth_stencil_buffer_) {\n    DCHECK(WantDepthOrStencil());\n    has_implicit_stencil_buffer_ = !want_stencil_;\n  }\n\n  if (gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {\n    return false;\n  }\n\n  return true;\n}\n","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":402305,"func":"static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v)\n{\n    XHCIInterrupter *intr;\n    dma_addr_t erdp;\n    unsigned int dp_idx;\n\n    if (v >= xhci->numintrs) {\n        DPRINTF(\"intr nr out of range (%d >= %d)\\n\", v, xhci->numintrs);\n        return;\n    }\n    intr = &xhci->intr[v];\n\n    if (intr->er_full) {\n        DPRINTF(\"xhci_event(): ER full, queueing\\n\");\n        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {\n            DPRINTF(\"xhci: event queue full, dropping event!\\n\");\n            return;\n        }\n        intr->ev_buffer[intr->ev_buffer_put++] = *event;\n        if (intr->ev_buffer_put == EV_QUEUE) {\n            intr->ev_buffer_put = 0;\n        }\n        return;\n    }\n\n    erdp = xhci_addr64(intr->erdp_low, intr->erdp_high);\n    if (erdp < intr->er_start ||\n        erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) {\n        DPRINTF(\"xhci: ERDP out of bounds: \"DMA_ADDR_FMT\"\\n\", erdp);\n        DPRINTF(\"xhci: ER[%d] at \"DMA_ADDR_FMT\" len %d\\n\",\n                v, intr->er_start, intr->er_size);\n        xhci_die(xhci);\n        return;\n    }\n\n    dp_idx = (erdp - intr->er_start) \/ TRB_SIZE;\n    assert(dp_idx < intr->er_size);\n\n    if ((intr->er_ep_idx+1) % intr->er_size == dp_idx) {\n        DPRINTF(\"xhci_event(): ER full, queueing\\n\");\n#ifndef ER_FULL_HACK\n        XHCIEvent full = {ER_HOST_CONTROLLER, CC_EVENT_RING_FULL_ERROR};\n        xhci_write_event(xhci, &full);\n#endif\n        intr->er_full = 1;\n        if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) {\n            DPRINTF(\"xhci: event queue full, dropping event!\\n\");\n            return;\n        }\n        intr->ev_buffer[intr->ev_buffer_put++] = *event;\n        if (intr->ev_buffer_put == EV_QUEUE) {\n            intr->ev_buffer_put = 0;\n        }\n    } else {\n        xhci_write_event(xhci, event, v);\n    }\n\n    xhci_intr_raise(xhci, v);\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":517943,"func":"bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,\n                                                 const char *fname,\n                                                 Item **args, uint nargs,\n                                                 uint flags, int item_sep)\n{\n  THD *thd= current_thd;\n  if (thd->lex->is_ps_or_view_context_analysis())\n    return false;\n  Item **arg, *safe_args[2]= {NULL, NULL};\n\n  \/*\n    For better error reporting: save the first and the second argument.\n    We need this only if the the number of args is 3 or 2:\n    - for a longer argument list, \"Illegal mix of collations\"\n      doesn't display each argument's characteristics.\n    - if nargs is 1, then this error cannot happen.\n  *\/\n  if (nargs >=2 && nargs <= 3)\n  {\n    safe_args[0]= args[0];\n    safe_args[1]= args[item_sep];\n  }\n\n  bool res= FALSE;\n  uint i;\n\n  DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare());\n\n  for (i= 0, arg= args; i < nargs; i++, arg+= item_sep)\n  {\n    Item* conv= (*arg)->safe_charset_converter(thd, coll.collation);\n    if (conv == *arg)\n      continue;\n\n    if (!conv)\n    {\n      if (nargs >=2 && nargs <= 3)\n      {\n        \/* restore the original arguments for better error message *\/\n        args[0]= safe_args[0];\n        args[item_sep]= safe_args[1];\n      }\n      my_coll_agg_error(args, nargs, fname, item_sep);\n      res= TRUE;\n      break; \/\/ we cannot return here, we need to restore \"arena\".\n    }\n\n    thd->change_item_tree(arg, conv);\n\n    if (conv->fix_fields(thd, arg))\n    {\n      res= TRUE;\n      break; \/\/ we cannot return here, we need to restore \"arena\".\n    }\n  }\n  return res;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":498984,"func":"static RzList *parse_format(RzCore *core, char *fmt) {\n\tif (!fmt || !*fmt) {\n\t\treturn NULL;\n\t}\n\tRzList *ret = rz_list_new();\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tSdb *s = core->analysis->sdb_fmts;\n\tconst char *spec = rz_config_get(core->config, \"analysis.types.spec\");\n\tchar arr[10] = { 0 };\n\tchar *ptr = strchr(fmt, '%');\n\tfmt[strlen(fmt) - 1] = '\\0';\n\twhile (ptr) {\n\t\tptr++;\n\t\t\/\/ strip [width] specifier\n\t\twhile (IS_DIGIT(*ptr)) {\n\t\t\tptr++;\n\t\t}\n\t\trz_str_ncpy(arr, ptr, sizeof(arr) - 1);\n\t\tchar *tmp = arr;\n\t\twhile (tmp && (IS_LOWER(*tmp) || IS_UPPER(*tmp))) {\n\t\t\ttmp++;\n\t\t}\n\t\t*tmp = '\\0';\n\t\tconst char *query = sdb_fmt(\"spec.%s.%s\", spec, arr);\n\t\tchar *type = (char *)sdb_const_get(s, query, 0);\n\t\tif (type) {\n\t\t\trz_list_append(ret, type);\n\t\t}\n\t\tptr = strchr(ptr, '%');\n\t}\n\treturn ret;\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":321900,"func":"static int v9fs_synth_name_to_path(FsContext *ctx, V9fsPath *dir_path,\n\n                                   const char *name, V9fsPath *target)\n\n{\n\n    V9fsSynthNode *node;\n\n    V9fsSynthNode *dir_node;\n\n\n\n    \/* \".\" and \"..\" are not allowed *\/\n\n    if (!strcmp(name, \".\") || !strcmp(name, \"..\")) {\n\n        errno = EINVAL;\n\n        return -1;\n\n\n\n    }\n\n    if (!dir_path) {\n\n        dir_node = &v9fs_synth_root;\n\n    } else {\n\n        dir_node = *(V9fsSynthNode **)dir_path->data;\n\n    }\n\n    if (!strcmp(name, \"\/\")) {\n\n        node = dir_node;\n\n        goto out;\n\n    }\n\n    \/* search for the name in the childern *\/\n\n    rcu_read_lock();\n\n    QLIST_FOREACH(node, &dir_node->child, sibling) {\n\n        if (!strcmp(node->name, name)) {\n\n            break;\n\n        }\n\n    }\n\n    rcu_read_unlock();\n\n\n\n    if (!node) {\n\n        errno = ENOENT;\n\n        return -1;\n\n    }\n\nout:\n\n    \/* Copy the node pointer to fid *\/\n\n    target->data = g_malloc(sizeof(void *));\n\n    memcpy(target->data, &node, sizeof(void *));\n\n    target->size = sizeof(void *);\n\n    return 0;\n\n}\n","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":101758,"func":"bool CIRCNetwork::Connect() {\n    if (!GetIRCConnectEnabled() || m_pIRCSock || !HasServers()) return false;\n\n    CServer* pServer = GetNextServer();\n    if (!pServer) return false;\n\n    if (CZNC::Get().GetServerThrottle(pServer->GetName())) {\n        \/\/ Can't connect right now, schedule retry later\n        CZNC::Get().AddNetworkToQueue(this);\n        return false;\n    }\n\n    CZNC::Get().AddServerThrottle(pServer->GetName());\n\n    bool bSSL = pServer->IsSSL();\n#ifndef HAVE_LIBSSL\n    if (bSSL) {\n        PutStatus(\n            t_f(\"Cannot connect to {1}, because ZNC is not compiled with SSL \"\n                \"support.\")(pServer->GetString(false)));\n        CZNC::Get().AddNetworkToQueue(this);\n        return false;\n    }\n#endif\n\n    CIRCSock* pIRCSock = new CIRCSock(this);\n    pIRCSock->SetPass(pServer->GetPass());\n    pIRCSock->SetSSLTrustedPeerFingerprints(m_ssTrustedFingerprints);\n    pIRCSock->SetTrustAllCerts(GetTrustAllCerts());\n    pIRCSock->SetTrustPKI(GetTrustPKI());\n\n    DEBUG(\"Connecting user\/network [\" << m_pUser->GetUserName() << \"\/\"\n                                      << m_sName << \"]\");\n\n    bool bAbort = false;\n    NETWORKMODULECALL(OnIRCConnecting(pIRCSock), m_pUser, this, nullptr,\n                      &bAbort);\n    if (bAbort) {\n        DEBUG(\"Some module aborted the connection attempt\");\n        PutStatus(t_s(\"Some module aborted the connection attempt\"));\n        delete pIRCSock;\n        CZNC::Get().AddNetworkToQueue(this);\n        return false;\n    }\n\n    CString sSockName = \"IRC::\" + m_pUser->GetUserName() + \"::\" + m_sName;\n    CZNC::Get().GetManager().Connect(pServer->GetName(), pServer->GetPort(),\n                                     sSockName, 120, bSSL, GetBindHost(),\n                                     pIRCSock);\n\n    return true;\n}","target":0,"code_token_length":465,"total_token_length":701,"max_tokens_setting":1024}
+{"idx":134496,"func":"void ar6000_dtimexpiry_event(struct ar6_softc *ar)\n{\n    bool isMcastQueued = false;\n    struct sk_buff *skb = NULL;\n\n    \/* If there are no associated STAs, ignore the DTIM expiry event.\n     * There can be potential race conditions where the last associated\n     * STA may disconnect & before the host could clear the 'Indicate DTIM'\n     * request to the firmware, the firmware would have just indicated a DTIM\n     * expiry event. The race is between 'clear DTIM expiry cmd' going\n     * from the host to the firmware & the DTIM expiry event happening from\n     * the firmware to the host.\n     *\/\n    if (ar->sta_list_index == 0) {\n        return;\n    }\n\n    A_MUTEX_LOCK(&ar->mcastpsqLock);\n    isMcastQueued = A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq);\n    A_MUTEX_UNLOCK(&ar->mcastpsqLock);\n\n    A_ASSERT(isMcastQueued == false);\n\n    \/* Flush the mcast psq to the target *\/\n    \/* Set the STA flag to DTIMExpired, so that the frame will go out *\/\n    ar->DTIMExpired = true;\n\n    A_MUTEX_LOCK(&ar->mcastpsqLock);\n    while (!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) {\n        skb = A_NETBUF_DEQUEUE(&ar->mcastpsq);\n        A_MUTEX_UNLOCK(&ar->mcastpsqLock);\n\n        ar6000_data_tx(skb, ar->arNetDev);\n\n        A_MUTEX_LOCK(&ar->mcastpsqLock);\n    }\n    A_MUTEX_UNLOCK(&ar->mcastpsqLock);\n\n    \/* Reset the DTIMExpired flag back to 0 *\/\n    ar->DTIMExpired = false;\n\n    \/* Clear the LSB of the BitMapCtl field of the TIM IE *\/\n    wmi_set_pvb_cmd(ar->arWmi, MCAST_AID, 0);\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":273434,"func":"static int vdbeRecordCompareString(\n  int nKey1, const void *pKey1, \/* Left key *\/\n  UnpackedRecord *pPKey2        \/* Right key *\/\n){\n  const u8 *aKey1 = (const u8*)pKey1;\n  int serial_type;\n  int res;\n\n  assert( pPKey2->aMem[0].flags & MEM_Str );\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  getVarint32(&aKey1[1], serial_type);\n  if( serial_type<12 ){\n    res = pPKey2->r1;      \/* (pKey1\/nKey1) is a number or a null *\/\n  }else if( !(serial_type & 0x01) ){ \n    res = pPKey2->r2;      \/* (pKey1\/nKey1) is a blob *\/\n  }else{\n    int nCmp;\n    int nStr;\n    int szHdr = aKey1[0];\n\n    nStr = (serial_type-12) \/ 2;\n    if( (szHdr + nStr) > nKey1 ){\n      pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n      return 0;    \/* Corruption *\/\n    }\n    nCmp = MIN( pPKey2->aMem[0].n, nStr );\n    res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);\n\n    if( res>0 ){\n      res = pPKey2->r2;\n    }else if( res<0 ){\n      res = pPKey2->r1;\n    }else{\n      res = nStr - pPKey2->aMem[0].n;\n      if( res==0 ){\n        if( pPKey2->nField>1 ){\n          res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n        }else{\n          res = pPKey2->default_rc;\n          pPKey2->eqSeen = 1;\n        }\n      }else if( res>0 ){\n        res = pPKey2->r2;\n      }else{\n        res = pPKey2->r1;\n      }\n    }\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)\n       || CORRUPT_DB\n       || pPKey2->pKeyInfo->db->mallocFailed\n  );\n  return res;\n}","target":0,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":406262,"func":"COMPAT_SYSCALL_DEFINE5(waitid,\n\t\tint, which, compat_pid_t, pid,\n\t\tstruct compat_siginfo __user *, infop, int, options,\n\t\tstruct compat_rusage __user *, uru)\n{\n\tstruct rusage ru;\n\tstruct waitid_info info = {.status = 0};\n\tlong err = kernel_waitid(which, pid, &info, options, uru ? &ru : NULL);\n\tint signo = 0;\n\tif (err > 0) {\n\t\tsigno = SIGCHLD;\n\t\terr = 0;\n\t\tif (uru) {\n\t\t\t\/* kernel_waitid() overwrites everything in ru *\/\n\t\t\tif (COMPAT_USE_64BIT_TIME)\n\t\t\t\terr = copy_to_user(uru, &ru, sizeof(ru));\n\t\t\telse\n\t\t\t\terr = put_compat_rusage(&ru, uru);\n\t\t\tif (err)\n\t\t\t\treturn -EFAULT;\n\t\t}\n\t}\n\n\tif (!infop)\n\t\treturn err;\n\n\tif (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))\n\t\tgoto Efault;\n\n\tuser_access_begin();\n\tunsafe_put_user(signo, &infop->si_signo, Efault);\n\tunsafe_put_user(0, &infop->si_errno, Efault);\n\tunsafe_put_user(info.cause, &infop->si_code, Efault);\n\tunsafe_put_user(info.pid, &infop->si_pid, Efault);\n\tunsafe_put_user(info.uid, &infop->si_uid, Efault);\n\tunsafe_put_user(info.status, &infop->si_status, Efault);\n\tuser_access_end();\n\treturn err;\nEfault:\n\tuser_access_end();\n\treturn -EFAULT;\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":342331,"func":"static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,\n\n                                 struct image_info *info)\n\n{\n\n    abi_ulong stack_base, size, error;\n\n    int i;\n\n\n\n    \/* Create enough stack to hold everything.  If we don't use\n\n     * it for args, we'll use it for something else...\n\n     *\/\n\n    size = guest_stack_size;\n\n    if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE)\n\n        size = MAX_ARG_PAGES*TARGET_PAGE_SIZE;\n\n    error = target_mmap(0,\n\n                        size + qemu_host_page_size,\n\n                        PROT_READ | PROT_WRITE,\n\n                        MAP_PRIVATE | MAP_ANONYMOUS,\n\n                        -1, 0);\n\n    if (error == -1) {\n\n        perror(\"stk mmap\");\n\n        exit(-1);\n\n    }\n\n    \/* we reserve one extra page at the top of the stack as guard *\/\n\n    target_mprotect(error + size, qemu_host_page_size, PROT_NONE);\n\n\n\n    info->stack_limit = error;\n\n    stack_base = error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE;\n\n    p += stack_base;\n\n\n\n    for (i = 0 ; i < MAX_ARG_PAGES ; i++) {\n\n        if (bprm->page[i]) {\n\n            info->rss++;\n\n            \/* FIXME - check return value of memcpy_to_target() for failure *\/\n\n            memcpy_to_target(stack_base, bprm->page[i], TARGET_PAGE_SIZE);\n\n            free(bprm->page[i]);\n\n        }\n\n        stack_base += TARGET_PAGE_SIZE;\n\n    }\n\n    return p;\n\n}\n","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":437493,"func":"static int io_accept(struct io_kiocb *req, const struct io_uring_sqe *sqe,\n\t\t     struct io_kiocb **nxt, bool force_nonblock)\n{\n#if defined(CONFIG_NET)\n\tstruct sockaddr __user *addr;\n\tint __user *addr_len;\n\tunsigned file_flags;\n\tint flags, ret;\n\n\tif (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->off || sqe->len || sqe->buf_index)\n\t\treturn -EINVAL;\n\n\taddr = (struct sockaddr __user *) (unsigned long) READ_ONCE(sqe->addr);\n\taddr_len = (int __user *) (unsigned long) READ_ONCE(sqe->addr2);\n\tflags = READ_ONCE(sqe->accept_flags);\n\tfile_flags = force_nonblock ? O_NONBLOCK : 0;\n\n\tret = __sys_accept4_file(req->file, file_flags, addr, addr_len, flags);\n\tif (ret == -EAGAIN && force_nonblock) {\n\t\treq->work.flags |= IO_WQ_WORK_NEEDS_FILES;\n\t\treturn -EAGAIN;\n\t}\n\tif (ret == -ERESTARTSYS)\n\t\tret = -EINTR;\n\tif (ret < 0 && (req->flags & REQ_F_LINK))\n\t\treq->flags |= REQ_F_FAIL_LINK;\n\tio_cqring_add_event(req, ret);\n\tio_put_req_find_next(req, nxt);\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":321007,"func":"static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)\n\n{\n\n    AVFrame *frame_current, *frame_ref;\n\n    VP56mb mb_type;\n\n    VP56Frame ref_frame;\n\n    int b, ab, b_max, plane, off;\n\n\n\n    if (s->framep[VP56_FRAME_CURRENT]->key_frame)\n\n        mb_type = VP56_MB_INTRA;\n\n    else\n\n        mb_type = vp56_decode_mv(s, row, col);\n\n    ref_frame = vp56_reference_frame[mb_type];\n\n\n\n    s->dsp.clear_blocks(*s->block_coeff);\n\n\n\n    s->parse_coeff(s);\n\n\n\n    vp56_add_predictors_dc(s, ref_frame);\n\n\n\n    frame_current = s->framep[VP56_FRAME_CURRENT];\n\n    frame_ref = s->framep[ref_frame];\n\n    if (mb_type != VP56_MB_INTRA && !frame_ref->data[0])\n\n        return;\n\n\n\n    ab = 6*is_alpha;\n\n    b_max = 6 - 2*is_alpha;\n\n\n\n    switch (mb_type) {\n\n        case VP56_MB_INTRA:\n\n            for (b=0; bdsp.idct_put(frame_current->data[plane] + s->block_offset[b],\n\n                                s->stride[plane], s->block_coeff[b]);\n\n            }\n\n            break;\n\n\n\n        case VP56_MB_INTER_NOVEC_PF:\n\n        case VP56_MB_INTER_NOVEC_GF:\n\n            for (b=0; bblock_offset[b];\n\n                s->dsp.put_pixels_tab[1][0](frame_current->data[plane] + off,\n\n                                            frame_ref->data[plane] + off,\n\n                                            s->stride[plane], 8);\n\n                s->dsp.idct_add(frame_current->data[plane] + off,\n\n                                s->stride[plane], s->block_coeff[b]);\n\n            }\n\n            break;\n\n\n\n        case VP56_MB_INTER_DELTA_PF:\n\n        case VP56_MB_INTER_V1_PF:\n\n        case VP56_MB_INTER_V2_PF:\n\n        case VP56_MB_INTER_DELTA_GF:\n\n        case VP56_MB_INTER_4V:\n\n        case VP56_MB_INTER_V1_GF:\n\n        case VP56_MB_INTER_V2_GF:\n\n            for (b=0; bdata[plane], s->stride[plane],\n\n                        16*col+x_off, 16*row+y_off);\n\n                s->dsp.idct_add(frame_current->data[plane] + s->block_offset[b],\n\n                                s->stride[plane], s->block_coeff[b]);\n\n            }\n\n            break;\n\n    }\n\n}\n","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":376228,"func":"void sctp_assoc_update_retran_path(struct sctp_association *asoc)\n{\n\tstruct sctp_transport *t, *next;\n\tstruct list_head *head = &asoc->peer.transport_addr_list;\n\tstruct list_head *pos;\n\n\t\/* Find the next transport in a round-robin fashion. *\/\n\tt = asoc->peer.retran_path;\n\tpos = &t->transports;\n\tnext = NULL;\n\n\twhile (1) {\n\t\t\/* Skip the head. *\/\n\t\tif (pos->next == head)\n\t\t\tpos = head->next;\n\t\telse\n\t\t\tpos = pos->next;\n\n\t\tt = list_entry(pos, struct sctp_transport, transports);\n\n\t\t\/* Try to find an active transport. *\/\n\n\t\tif ((t->state == SCTP_ACTIVE) ||\n\t\t    (t->state == SCTP_UNKNOWN)) {\n\t\t\tbreak;\n\t\t} else {\n\t\t\t\/* Keep track of the next transport in case\n\t\t\t * we don't find any active transport.\n\t\t\t *\/\n\t\t\tif (!next)\n\t\t\t\tnext = t;\n\t\t}\n\n\t\t\/* We have exhausted the list, but didn't find any\n\t\t * other active transports.  If so, use the next\n\t\t * transport.\n\t\t *\/\n\t\tif (t == asoc->peer.retran_path) {\n\t\t\tt = next;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tasoc->peer.retran_path = t;\n\n\tSCTP_DEBUG_PRINTK_IPADDR(\"sctp_assoc_update_retran_path:association\"\n\t\t\t\t \" %p addr: \",\n\t\t\t\t \" port: %d\\n\",\n\t\t\t\t asoc,\n\t\t\t\t (&t->ipaddr),\n\t\t\t\t ntohs(t->ipaddr.v4.sin_port));\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":473493,"func":"int nsim_bpf_init(struct netdevsim *ns)\n{\n\tstruct dentry *ddir = ns->nsim_dev_port->ddir;\n\tint err;\n\n\terr = bpf_offload_dev_netdev_register(ns->nsim_dev->bpf_dev,\n\t\t\t\t\t      ns->netdev);\n\tif (err)\n\t\treturn err;\n\n\tdebugfs_create_u32(\"bpf_offloaded_id\", 0400, ddir,\n\t\t\t   &ns->bpf_offloaded_id);\n\n\tns->bpf_tc_accept = true;\n\tdebugfs_create_bool(\"bpf_tc_accept\", 0600, ddir,\n\t\t\t    &ns->bpf_tc_accept);\n\tdebugfs_create_bool(\"bpf_tc_non_bound_accept\", 0600, ddir,\n\t\t\t    &ns->bpf_tc_non_bound_accept);\n\tns->bpf_xdpdrv_accept = true;\n\tdebugfs_create_bool(\"bpf_xdpdrv_accept\", 0600, ddir,\n\t\t\t    &ns->bpf_xdpdrv_accept);\n\tns->bpf_xdpoffload_accept = true;\n\tdebugfs_create_bool(\"bpf_xdpoffload_accept\", 0600, ddir,\n\t\t\t    &ns->bpf_xdpoffload_accept);\n\n\tns->bpf_map_accept = true;\n\tdebugfs_create_bool(\"bpf_map_accept\", 0600, ddir,\n\t\t\t    &ns->bpf_map_accept);\n\n\treturn 0;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":495850,"func":"static int extract_url (const char *url, int default_port,\n                        struct request_s *request)\n{\n        char *p;\n        int port;\n\n        \/* Split the URL on the slash to separate host from path *\/\n        p = strchr (url, '\/');\n        if (p != NULL) {\n                int len;\n                len = p - url;\n                request->host = (char *) safemalloc (len + 1);\n                memcpy (request->host, url, len);\n                request->host[len] = '\\0';\n                request->path = safestrdup (p);\n        } else {\n                request->host = safestrdup (url);\n                request->path = safestrdup (\"\/\");\n        }\n\n        if (!request->host || !request->path)\n                goto ERROR_EXIT;\n\n        \/* Remove the username\/password if they're present *\/\n        strip_username_password (request->host);\n\n        \/* Find a proper port in www.site.com:8001 URLs *\/\n        port = strip_return_port (request->host);\n        request->port = (port != 0) ? port : default_port;\n\n        \/* Remove any surrounding '[' and ']' from IPv6 literals *\/\n        p = strrchr (request->host, ']');\n        if (p && (*(request->host) == '[')) {\n                memmove(request->host, request->host + 1,\n                        strlen(request->host) - 2);\n                *p = '\\0';\n                p--;\n                *p = '\\0';\n        }\n\n        return 0;\n\nERROR_EXIT:\n        if (request->host)\n                safefree (request->host);\n        if (request->path)\n                safefree (request->path);\n\n        return -1;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":15577,"func":"static void authenticate ( const struct passwd * pw ) {\n const struct passwd * lpw = NULL ;\n const char * cp , * srvname = NULL ;\n int retval ;\n switch ( su_mode ) {\n case SU_MODE : srvname = simulate_login ? PAM_SRVNAME_SU_L : PAM_SRVNAME_SU ;\n break ;\n case RUNUSER_MODE : srvname = simulate_login ? PAM_SRVNAME_RUNUSER_L : PAM_SRVNAME_RUNUSER ;\n break ;\n default : abort ( ) ;\n break ;\n }\n retval = pam_start ( srvname , pw -> pw_name , & conv , & pamh ) ;\n if ( is_pam_failure ( retval ) ) goto done ;\n if ( isatty ( 0 ) && ( cp = ttyname ( 0 ) ) != NULL ) {\n const char * tty ;\n if ( strncmp ( cp , \"\/dev\/\" , 5 ) == 0 ) tty = cp + 5 ;\n else tty = cp ;\n retval = pam_set_item ( pamh , PAM_TTY , tty ) ;\n if ( is_pam_failure ( retval ) ) goto done ;\n }\n lpw = current_getpwuid ( ) ;\n if ( lpw && lpw -> pw_name ) {\n retval = pam_set_item ( pamh , PAM_RUSER , ( const void * ) lpw -> pw_name ) ;\n if ( is_pam_failure ( retval ) ) goto done ;\n }\n if ( su_mode == RUNUSER_MODE ) {\n if ( restricted ) errx ( EXIT_FAILURE , _ ( \"may not be used by non-root users\" ) ) ;\n return ;\n }\n retval = pam_authenticate ( pamh , 0 ) ;\n if ( is_pam_failure ( retval ) ) goto done ;\n retval = pam_acct_mgmt ( pamh , 0 ) ;\n if ( retval == PAM_NEW_AUTHTOK_REQD ) {\n retval = pam_chauthtok ( pamh , PAM_CHANGE_EXPIRED_AUTHTOK ) ;\n }\n done : log_syslog ( pw , ! is_pam_failure ( retval ) ) ;\n if ( is_pam_failure ( retval ) ) {\n const char * msg ;\n log_btmp ( pw ) ;\n msg = pam_strerror ( pamh , retval ) ;\n pam_end ( pamh , retval ) ;\n sleep ( getlogindefs_num ( \"FAIL_DELAY\" , 1 ) ) ;\n errx ( EXIT_FAILURE , \"%s\" , msg ? msg : _ ( \"incorrect password\" ) ) ;\n }\n }","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":30786,"func":"static void ac3_decode_transform_coeffs_ch ( AC3DecodeContext * s , int ch_index , mant_groups * m ) {\n int start_freq = s -> start_freq [ ch_index ] ;\n int end_freq = s -> end_freq [ ch_index ] ;\n uint8_t * baps = s -> bap [ ch_index ] ;\n int8_t * exps = s -> dexps [ ch_index ] ;\n int * coeffs = s -> fixed_coeffs [ ch_index ] ;\n int dither = ( ch_index == CPL_CH ) || s -> dither_flag [ ch_index ] ;\n GetBitContext * gbc = & s -> gbc ;\n int freq ;\n for ( freq = start_freq ;\n freq < end_freq ;\n freq ++ ) {\n int bap = baps [ freq ] ;\n int mantissa ;\n switch ( bap ) {\n case 0 : if ( dither ) mantissa = ( av_lfg_get ( & s -> dith_state ) \/ 362 ) - 5932275 ;\n else mantissa = 0 ;\n break ;\n case 1 : if ( m -> b1 ) {\n m -> b1 -- ;\n mantissa = m -> b1_mant [ m -> b1 ] ;\n }\n else {\n int bits = get_bits ( gbc , 5 ) ;\n mantissa = b1_mantissas [ bits ] [ 0 ] ;\n m -> b1_mant [ 1 ] = b1_mantissas [ bits ] [ 1 ] ;\n m -> b1_mant [ 0 ] = b1_mantissas [ bits ] [ 2 ] ;\n m -> b1 = 2 ;\n }\n break ;\n case 2 : if ( m -> b2 ) {\n m -> b2 -- ;\n mantissa = m -> b2_mant [ m -> b2 ] ;\n }\n else {\n int bits = get_bits ( gbc , 7 ) ;\n mantissa = b2_mantissas [ bits ] [ 0 ] ;\n m -> b2_mant [ 1 ] = b2_mantissas [ bits ] [ 1 ] ;\n m -> b2_mant [ 0 ] = b2_mantissas [ bits ] [ 2 ] ;\n m -> b2 = 2 ;\n }\n break ;\n case 3 : mantissa = b3_mantissas [ get_bits ( gbc , 3 ) ] ;\n break ;\n case 4 : if ( m -> b4 ) {\n m -> b4 = 0 ;\n mantissa = m -> b4_mant ;\n }\n else {\n int bits = get_bits ( gbc , 7 ) ;\n mantissa = b4_mantissas [ bits ] [ 0 ] ;\n m -> b4_mant = b4_mantissas [ bits ] [ 1 ] ;\n m -> b4 = 1 ;\n }\n break ;\n case 5 : mantissa = b5_mantissas [ get_bits ( gbc , 4 ) ] ;\n break ;\n default : mantissa = get_sbits ( gbc , quantization_tab [ bap ] ) ;\n mantissa <<= 24 - quantization_tab [ bap ] ;\n break ;\n }\n coeffs [ freq ] = mantissa >> exps [ freq ] ;\n }\n }","target":0,"code_token_length":673,"total_token_length":909,"max_tokens_setting":1024}
+{"idx":505750,"func":"rsvg_acquire_data_data (const char *uri,\n                        const char *base_uri, \n                        char **out_mime_type,\n                        gsize *out_len,\n                        GError **error)\n{\n    const char *comma, *start, *end;\n    char *mime_type;\n    char *data;\n    gsize data_len;\n    gboolean base64 = FALSE;\n\n    g_assert (out_len != NULL);\n    g_assert (strncmp (uri, \"data:\", 5) == 0);\n\n    mime_type = NULL;\n    start = uri + 5;\n    comma = strchr (start, ',');\n\n    if (comma && comma != start) {\n        \/* Deal with MIME type \/ params *\/\n        if (comma > start + BASE64_INDICATOR_LEN && \n            !g_ascii_strncasecmp (comma - BASE64_INDICATOR_LEN, BASE64_INDICATOR, BASE64_INDICATOR_LEN)) {\n            end = comma - BASE64_INDICATOR_LEN;\n            base64 = TRUE;\n        } else {\n            end = comma;\n        }\n\n        if (end != start) {\n            mime_type = uri_decoded_copy (start, end - start);\n        }\n    }\n\n    if (comma)\n        start = comma + 1;\n\n    if (*start) {\n        data = uri_decoded_copy (start, strlen (start));\n\n        if (base64)\n            data = g_base64_decode_inplace ((char*) data, &data_len);\n        else\n            data_len = strlen ((const char *) data);\n    } else {\n        data = NULL;\n        data_len = 0;\n    }\n\n    if (out_mime_type)\n        *out_mime_type = mime_type;\n    else\n        g_free (mime_type);\n\n    *out_len = data_len;\n    return data;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":403020,"func":"ptp_unpack_OI (PTPParams *params, unsigned char* data, PTPObjectInfo *oi, unsigned int len)\n{\n\tuint8_t filenamelen;\n\tuint8_t capturedatelen;\n\tchar *capture_date;\n\n\tif (len < PTP_oi_SequenceNumber)\n\t\treturn;\n\n\toi->Filename = oi->Keywords = NULL;\n\n\t\/* FIXME: also handle length with all the strings at the end *\/\n\toi->StorageID=dtoh32a(&data[PTP_oi_StorageID]);\n\toi->ObjectFormat=dtoh16a(&data[PTP_oi_ObjectFormat]);\n\toi->ProtectionStatus=dtoh16a(&data[PTP_oi_ProtectionStatus]);\n\toi->ObjectCompressedSize=dtoh32a(&data[PTP_oi_ObjectCompressedSize]);\n\n\t\/* Stupid Samsung Galaxy developers emit a 64bit objectcompressedsize *\/\n\tif ((data[PTP_oi_filenamelen] == 0) && (data[PTP_oi_filenamelen+4] != 0)) {\n\t\tparams->ocs64 = 1;\n\t\tdata += 4;\n\t}\n\toi->ThumbFormat=dtoh16a(&data[PTP_oi_ThumbFormat]);\n\toi->ThumbCompressedSize=dtoh32a(&data[PTP_oi_ThumbCompressedSize]);\n\toi->ThumbPixWidth=dtoh32a(&data[PTP_oi_ThumbPixWidth]);\n\toi->ThumbPixHeight=dtoh32a(&data[PTP_oi_ThumbPixHeight]);\n\toi->ImagePixWidth=dtoh32a(&data[PTP_oi_ImagePixWidth]);\n\toi->ImagePixHeight=dtoh32a(&data[PTP_oi_ImagePixHeight]);\n\toi->ImageBitDepth=dtoh32a(&data[PTP_oi_ImageBitDepth]);\n\toi->ParentObject=dtoh32a(&data[PTP_oi_ParentObject]);\n\toi->AssociationType=dtoh16a(&data[PTP_oi_AssociationType]);\n\toi->AssociationDesc=dtoh32a(&data[PTP_oi_AssociationDesc]);\n\toi->SequenceNumber=dtoh32a(&data[PTP_oi_SequenceNumber]);\n\n\toi->Filename= ptp_unpack_string(params, data, PTP_oi_filenamelen, len, &filenamelen);\n\n\tcapture_date = ptp_unpack_string(params, data,\n\t\tPTP_oi_filenamelen+filenamelen*2+1, len, &capturedatelen);\n\t\/* subset of ISO 8601, without '.s' tenths of second and \n\t * time zone\n\t *\/\n\toi->CaptureDate = ptp_unpack_PTPTIME(capture_date);\n\tfree(capture_date);\n\n\t\/* now the modification date ... *\/\n\tcapture_date = ptp_unpack_string(params, data,\n\t\tPTP_oi_filenamelen+filenamelen*2\n\t\t+capturedatelen*2+2, len, &capturedatelen);\n\toi->ModificationDate = ptp_unpack_PTPTIME(capture_date);\n\tfree(capture_date);\n}","target":0,"code_token_length":707,"total_token_length":943,"max_tokens_setting":1024}
+{"idx":396481,"func":"dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)\n{\n\tstatic const char str[] = \"double fault\";\n\tstruct task_struct *tsk = current;\n\n#ifdef CONFIG_X86_ESPFIX64\n\textern unsigned char native_irq_return_iret[];\n\n\t\/*\n\t * If IRET takes a non-IST fault on the espfix64 stack, then we\n\t * end up promoting it to a doublefault.  In that case, modify\n\t * the stack to make it look like we just entered the #GP\n\t * handler from user space, similar to bad_iret.\n\t *\n\t * No need for ist_enter here because we don't use RCU.\n\t *\/\n\tif (((long)regs->sp >> PGDIR_SHIFT) == ESPFIX_PGD_ENTRY &&\n\t\tregs->cs == __KERNEL_CS &&\n\t\tregs->ip == (unsigned long)native_irq_return_iret)\n\t{\n\t\tstruct pt_regs *normal_regs = task_pt_regs(current);\n\n\t\t\/* Fake a #GP(0) from userspace. *\/\n\t\tmemmove(&normal_regs->ip, (void *)regs->sp, 5*8);\n\t\tnormal_regs->orig_ax = 0;  \/* Missing (lost) #GP error code *\/\n\t\tregs->ip = (unsigned long)general_protection;\n\t\tregs->sp = (unsigned long)&normal_regs->orig_ax;\n\n\t\treturn;\n\t}\n#endif\n\n\tist_enter(regs);\n\tnotify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);\n\n\ttsk->thread.error_code = error_code;\n\ttsk->thread.trap_nr = X86_TRAP_DF;\n\n#ifdef CONFIG_DOUBLEFAULT\n\tdf_debug(regs, error_code);\n#endif\n\t\/*\n\t * This is always a kernel trap and never fixable (and thus must\n\t * never return).\n\t *\/\n\tfor (;;)\n\t\tdie(str, regs, error_code);\n}","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":164709,"func":"void PaintLayerScrollableArea::InvalidatePaintForScrollOffsetChange() {\n  InvalidatePaintForStickyDescendants();\n\n  auto* box = GetLayoutBox();\n  auto* frame_view = box->GetFrameView();\n  frame_view->InvalidateBackgroundAttachmentFixedDescendantsOnScroll(*box);\n\n  if (box->IsLayoutView() && frame_view->HasViewportConstrainedObjects() &&\n      !frame_view->InvalidateViewportConstrainedObjects()) {\n    box->SetShouldDoFullPaintInvalidation();\n    box->SetSubtreeShouldCheckForPaintInvalidation();\n  }\n\n  if (Layer()->EnclosingPaginationLayer())\n    box->SetSubtreeShouldCheckForPaintInvalidation();\n\n  bool background_paint_in_graphics_layer = true;\n  bool background_paint_in_scrolling_contents = false;\n  if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||\n      UsesCompositedScrolling()) {\n    auto background_paint_location = box->GetBackgroundPaintLocation();\n    background_paint_in_graphics_layer =\n        background_paint_location & kBackgroundPaintInGraphicsLayer;\n    background_paint_in_scrolling_contents =\n        background_paint_location & kBackgroundPaintInScrollingContents;\n  }\n\n  auto background_layers = box->StyleRef().BackgroundLayers();\n  if ((background_layers.AnyLayerHasLocalAttachmentImage() &&\n       background_paint_in_graphics_layer) ||\n      (background_layers.AnyLayerHasDefaultAttachmentImage() &&\n       background_paint_in_scrolling_contents))\n    box->SetBackgroundNeedsFullPaintInvalidation();\n\n  if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||\n      !UsesCompositedScrolling())\n    Layer()->SetNeedsRepaint();\n}\n","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":471555,"func":"void luaLdbLineHook(lua_State *lua, lua_Debug *ar) {\n    lua_getstack(lua,0,ar);\n    lua_getinfo(lua,\"Sl\",ar);\n    ldb.currentline = ar->currentline;\n\n    int bp = ldbIsBreakpoint(ldb.currentline) || ldb.luabp;\n    int timeout = 0;\n\n    \/* Events outside our script are not interesting. *\/\n    if(strstr(ar->short_src,\"user_script\") == NULL) return;\n\n    \/* Check if a timeout occurred. *\/\n    if (ar->event == LUA_HOOKCOUNT && ldb.step == 0 && bp == 0) {\n        mstime_t elapsed = mstime() - server.lua_time_start;\n        mstime_t timelimit = server.lua_time_limit ?\n                             server.lua_time_limit : 5000;\n        if (elapsed >= timelimit) {\n            timeout = 1;\n            ldb.step = 1;\n        } else {\n            return; \/* No timeout, ignore the COUNT event. *\/\n        }\n    }\n\n    if (ldb.step || bp) {\n        char *reason = \"step over\";\n        if (bp) reason = ldb.luabp ? \"redis.breakpoint() called\" :\n                                     \"break point\";\n        else if (timeout) reason = \"timeout reached, infinite loop?\";\n        ldb.step = 0;\n        ldb.luabp = 0;\n        ldbLog(sdscatprintf(sdsempty(),\n            \"* Stopped at %d, stop reason = %s\",\n            ldb.currentline, reason));\n        ldbLogSourceLine(ldb.currentline);\n        ldbSendLogs();\n        if (ldbRepl(lua) == C_ERR && timeout) {\n            \/* If the client closed the connection and we have a timeout\n             * connection, let's kill the script otherwise the process\n             * will remain blocked indefinitely. *\/\n            lua_pushstring(lua, \"timeout during Lua debugging with client closing connection\");\n            lua_error(lua);\n        }\n        server.lua_time_start = mstime();\n    }\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":84907,"func":"ex_align(exarg_T *eap)\n{\n    pos_T\tsave_curpos;\n    int\t\tlen;\n    int\t\tindent = 0;\n    int\t\tnew_indent;\n    int\t\thas_tab;\n    int\t\twidth;\n\n#ifdef FEAT_RIGHTLEFT\n    if (curwin->w_p_rl)\n    {\n\t\/* switch left and right aligning *\/\n\tif (eap->cmdidx == CMD_right)\n\t    eap->cmdidx = CMD_left;\n\telse if (eap->cmdidx == CMD_left)\n\t    eap->cmdidx = CMD_right;\n    }\n#endif\n\n    width = atoi((char *)eap->arg);\n    save_curpos = curwin->w_cursor;\n    if (eap->cmdidx == CMD_left)    \/* width is used for new indent *\/\n    {\n\tif (width >= 0)\n\t    indent = width;\n    }\n    else\n    {\n\t\/*\n\t * if 'textwidth' set, use it\n\t * else if 'wrapmargin' set, use it\n\t * if invalid value, use 80\n\t *\/\n\tif (width <= 0)\n\t    width = curbuf->b_p_tw;\n\tif (width == 0 && curbuf->b_p_wm > 0)\n\t    width = curwin->w_width - curbuf->b_p_wm;\n\tif (width <= 0)\n\t    width = 80;\n    }\n\n    if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL)\n\treturn;\n\n    for (curwin->w_cursor.lnum = eap->line1;\n\t\t curwin->w_cursor.lnum <= eap->line2; ++curwin->w_cursor.lnum)\n    {\n\tif (eap->cmdidx == CMD_left)\t\t\/* left align *\/\n\t    new_indent = indent;\n\telse\n\t{\n\t    has_tab = FALSE;\t\/* avoid uninit warnings *\/\n\t    len = linelen(eap->cmdidx == CMD_right ? &has_tab\n\t\t\t\t\t\t   : NULL) - get_indent();\n\n\t    if (len <= 0)\t\t\t\/* skip blank lines *\/\n\t\tcontinue;\n\n\t    if (eap->cmdidx == CMD_center)\n\t\tnew_indent = (width - len) \/ 2;\n\t    else\n\t    {\n\t\tnew_indent = width - len;\t\/* right align *\/\n\n\t\t\/*\n\t\t * Make sure that embedded TABs don't make the text go too far\n\t\t * to the right.\n\t\t *\/\n\t\tif (has_tab)\n\t\t    while (new_indent > 0)\n\t\t    {\n\t\t\t(void)set_indent(new_indent, 0);\n\t\t\tif (linelen(NULL) <= width)\n\t\t\t{\n\t\t\t    \/*\n\t\t\t     * Now try to move the line as much as possible to\n\t\t\t     * the right.  Stop when it moves too far.\n\t\t\t     *\/\n\t\t\t    do\n\t\t\t\t(void)set_indent(++new_indent, 0);\n\t\t\t    while (linelen(NULL) <= width);\n\t\t\t    --new_indent;\n\t\t\t    break;\n\t\t\t}\n\t\t\t--new_indent;\n\t\t    }\n\t    }\n\t}\n\tif (new_indent < 0)\n\t    new_indent = 0;\n\t(void)set_indent(new_indent, 0);\t\t\/* set indent *\/\n    }\n    changed_lines(eap->line1, 0, eap->line2 + 1, 0L);\n    curwin->w_cursor = save_curpos;\n    beginline(BL_WHITE | BL_FIX);\n}","target":0,"code_token_length":733,"total_token_length":969,"max_tokens_setting":1024}
+{"idx":99759,"func":"SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,\n\t  unsigned int *nbytes, char **buf, int *buf_type)\n{\n\tstruct smb_rqst rqst;\n\tint resp_buftype, rc = -EACCES;\n\tstruct smb2_read_plain_req *req = NULL;\n\tstruct smb2_read_rsp *rsp = NULL;\n\tstruct kvec iov[1];\n\tstruct kvec rsp_iov;\n\tunsigned int total_len;\n\tint flags = CIFS_LOG_ERROR;\n\tstruct cifs_ses *ses = io_parms->tcon->ses;\n\n\t*nbytes = 0;\n\trc = smb2_new_read_req((void **)&req, &total_len, io_parms, NULL, 0, 0);\n\tif (rc)\n\t\treturn rc;\n\n\tif (smb3_encryption_required(io_parms->tcon))\n\t\tflags |= CIFS_TRANSFORM_REQ;\n\n\tiov[0].iov_base = (char *)req;\n\tiov[0].iov_len = total_len;\n\n\tmemset(&rqst, 0, sizeof(struct smb_rqst));\n\trqst.rq_iov = iov;\n\trqst.rq_nvec = 1;\n\n\trc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);\n\trsp = (struct smb2_read_rsp *)rsp_iov.iov_base;\n\n\tif (rc) {\n\t\tif (rc != -ENODATA) {\n\t\t\tcifs_stats_fail_inc(io_parms->tcon, SMB2_READ_HE);\n\t\t\tcifs_dbg(VFS, \"Send error in read = %d\\n\", rc);\n\t\t\ttrace_smb3_read_err(xid, req->PersistentFileId,\n\t\t\t\t\t    io_parms->tcon->tid, ses->Suid,\n\t\t\t\t\t    io_parms->offset, io_parms->length,\n\t\t\t\t\t    rc);\n\t\t} else\n\t\t\ttrace_smb3_read_done(xid, req->PersistentFileId,\n\t\t\t\t    io_parms->tcon->tid, ses->Suid,\n\t\t\t\t    io_parms->offset, 0);\n\t\tfree_rsp_buf(resp_buftype, rsp_iov.iov_base);\n\t\treturn rc == -ENODATA ? 0 : rc;\n\t} else\n\t\ttrace_smb3_read_done(xid, req->PersistentFileId,\n\t\t\t\t    io_parms->tcon->tid, ses->Suid,\n\t\t\t\t    io_parms->offset, io_parms->length);\n\n\tcifs_small_buf_release(req);\n\n\t*nbytes = le32_to_cpu(rsp->DataLength);\n\tif ((*nbytes > CIFS_MAX_MSGSIZE) ||\n\t    (*nbytes > io_parms->length)) {\n\t\tcifs_dbg(FYI, \"bad length %d for count %d\\n\",\n\t\t\t *nbytes, io_parms->length);\n\t\trc = -EIO;\n\t\t*nbytes = 0;\n\t}\n\n\tif (*buf) {\n\t\tmemcpy(*buf, (char *)rsp + rsp->DataOffset, *nbytes);\n\t\tfree_rsp_buf(resp_buftype, rsp_iov.iov_base);\n\t} else if (resp_buftype != CIFS_NO_BUFFER) {\n\t\t*buf = rsp_iov.iov_base;\n\t\tif (resp_buftype == CIFS_SMALL_BUFFER)\n\t\t\t*buf_type = CIFS_SMALL_BUFFER;\n\t\telse if (resp_buftype == CIFS_LARGE_BUFFER)\n\t\t\t*buf_type = CIFS_LARGE_BUFFER;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":717,"total_token_length":953,"max_tokens_setting":1024}
+{"idx":86531,"func":"TEST_P(SslSocketTest, DownstreamNotReadySslSocket) {\n  Stats::TestUtil::TestStore stats_store;\n  NiceMock local_info;\n  testing::NiceMock factory_context;\n  NiceMock init_manager;\n  NiceMock dispatcher;\n  EXPECT_CALL(factory_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher));\n  EXPECT_CALL(factory_context, localInfo()).WillOnce(ReturnRef(local_info));\n  EXPECT_CALL(factory_context, stats()).WillOnce(ReturnRef(stats_store));\n  EXPECT_CALL(factory_context, initManager()).WillRepeatedly(ReturnRef(init_manager));\n\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  auto sds_secret_configs =\n      tls_context.mutable_common_tls_context()->mutable_tls_certificate_sds_secret_configs()->Add();\n  sds_secret_configs->set_name(\"abc.com\");\n  sds_secret_configs->mutable_sds_config();\n  auto server_cfg = std::make_unique(tls_context, factory_context);\n  EXPECT_TRUE(server_cfg->tlsCertificates().empty());\n  EXPECT_FALSE(server_cfg->isReady());\n\n  ContextManagerImpl manager(time_system_);\n  ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager, stats_store,\n                                                   std::vector{});\n  auto transport_socket = server_ssl_socket_factory.createTransportSocket(nullptr);\n  EXPECT_FALSE(transport_socket->startSecureTransport());                                  \/\/ Noop\n  transport_socket->configureInitialCongestionWindow(200, std::chrono::microseconds(223)); \/\/ Noop\n  EXPECT_EQ(EMPTY_STRING, transport_socket->protocol());\n  EXPECT_EQ(nullptr, transport_socket->ssl());\n  EXPECT_EQ(true, transport_socket->canFlushClose());\n  Buffer::OwnedImpl buffer;\n  Network::IoResult result = transport_socket->doRead(buffer);\n  EXPECT_EQ(Network::PostIoAction::Close, result.action_);\n  result = transport_socket->doWrite(buffer, true);\n  EXPECT_EQ(Network::PostIoAction::Close, result.action_);\n  EXPECT_EQ(\"TLS error: Secret is not supplied by SDS\", transport_socket->failureReason());\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":490762,"func":"static int flv_write_trailer(AVFormatContext *s)\n{\n    int64_t file_size;\n\n    AVIOContext *pb = s->pb;\n    FLVContext *flv = s->priv_data;\n    int i;\n\n    \/* Add EOS tag *\/\n    for (i = 0; i < s->nb_streams; i++) {\n        AVCodecContext *enc = s->streams[i]->codec;\n        FLVStreamContext *sc = s->streams[i]->priv_data;\n        if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&\n                (enc->codec_id == AV_CODEC_ID_H264 || enc->codec_id == AV_CODEC_ID_MPEG4))\n            put_avc_eos_tag(pb, sc->last_ts);\n    }\n\n    file_size = avio_tell(pb);\n\n    \/* update information *\/\n    if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0)\n        av_log(s, AV_LOG_WARNING, \"Failed to update header with correct duration.\\n\");\n    else\n        put_amf_double(pb, flv->duration \/ (double)1000);\n    if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0)\n        av_log(s, AV_LOG_WARNING, \"Failed to update header with correct filesize.\\n\");\n    else\n        put_amf_double(pb, file_size);\n\n    avio_seek(pb, file_size, SEEK_SET);\n    return 0;\n}","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":453676,"func":"numericStringNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\t\/* removal all spaces *\/\n\tchar *p, *q;\n\n\tassert( !BER_BVISEMPTY( val ) );\n\n\tnormalized->bv_val = slap_sl_malloc( val->bv_len + 1, ctx );\n\n\tp = val->bv_val;\n\tq = normalized->bv_val;\n\n\twhile ( *p ) {\n\t\tif ( ASCII_SPACE( *p ) ) {\n\t\t\t\/* Ignore whitespace *\/\n\t\t\tp++;\n\t\t} else {\n\t\t\t*q++ = *p++;\n\t\t}\n\t}\n\n\t\/* we should have copied no more than is in val *\/\n\tassert( (q - normalized->bv_val) <= (p - val->bv_val) );\n\n\t\/* null terminate *\/\n\t*q = '\\0';\n\n\tnormalized->bv_len = q - normalized->bv_val;\n\n\tif( BER_BVISEMPTY( normalized ) ) {\n\t\tnormalized->bv_val = slap_sl_realloc( normalized->bv_val, 2, ctx );\n\t\tnormalized->bv_val[0] = ' ';\n\t\tnormalized->bv_val[1] = '\\0';\n\t\tnormalized->bv_len = 1;\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":399642,"func":"static bool start_flush_work(struct work_struct *work, struct wq_barrier *barr)\n{\n\tstruct worker *worker = NULL;\n\tstruct worker_pool *pool;\n\tstruct pool_workqueue *pwq;\n\n\tmight_sleep();\n\n\tlocal_irq_disable();\n\tpool = get_work_pool(work);\n\tif (!pool) {\n\t\tlocal_irq_enable();\n\t\treturn false;\n\t}\n\n\tspin_lock(&pool->lock);\n\t\/* see the comment in try_to_grab_pending() with the same code *\/\n\tpwq = get_work_pwq(work);\n\tif (pwq) {\n\t\tif (unlikely(pwq->pool != pool))\n\t\t\tgoto already_gone;\n\t} else {\n\t\tworker = find_worker_executing_work(pool, work);\n\t\tif (!worker)\n\t\t\tgoto already_gone;\n\t\tpwq = worker->current_pwq;\n\t}\n\n\tcheck_flush_dependency(pwq->wq, work);\n\n\tinsert_wq_barrier(pwq, barr, work, worker);\n\tspin_unlock_irq(&pool->lock);\n\n\t\/*\n\t * If @max_active is 1 or rescuer is in use, flushing another work\n\t * item on the same workqueue may lead to deadlock.  Make sure the\n\t * flusher is not running on the same workqueue by verifying write\n\t * access.\n\t *\/\n\tif (pwq->wq->saved_max_active == 1 || pwq->wq->rescuer)\n\t\tlock_map_acquire(&pwq->wq->lockdep_map);\n\telse\n\t\tlock_map_acquire_read(&pwq->wq->lockdep_map);\n\tlock_map_release(&pwq->wq->lockdep_map);\n\n\treturn true;\nalready_gone:\n\tspin_unlock_irq(&pool->lock);\n\treturn false;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":23059,"func":"int write_command_to_file ( char * cmd ) {\n char * buffer ;\n char * ip_address ;\n int dummy ;\n char * p ;\n FILE * fp ;\n struct stat statbuf ;\n char error_string [ MAX_INPUT_BUFFER ] ;\n if ( ! cmd || ! * cmd || strchr ( cmd , '\\n' ) ) return ERROR ;\n if ( stat ( command_file , & statbuf ) ) {\n snprintf ( error_string , sizeof ( error_string ) , \"Error: Could not stat() command file '%s'!\" , command_file ) ;\n error_string [ sizeof ( error_string ) - 1 ] = '\\x0' ;\n print_generic_error_message ( error_string , \"The external command file may be missing, Icinga may not be running, and\/or Icinga may not be checking external commands.\" , 2 ) ;\n return ERROR ;\n }\n fp = fopen ( command_file , \"w\" ) ;\n if ( fp == NULL ) {\n snprintf ( error_string , sizeof ( error_string ) , \"Error: Could not open command file '%s' for update!\" , command_file ) ;\n error_string [ sizeof ( error_string ) - 1 ] = '\\x0' ;\n print_generic_error_message ( error_string , \"The permissions on the external command file and\/or directory may be incorrect. Read the FAQs on how to setup proper permissions.\" , 2 ) ;\n return ERROR ;\n }\n if ( use_logging == TRUE ) {\n p = strchr ( cmd , ']' ) ;\n if ( p != NULL ) p += 2 ;\n else p = & cmd [ 0 ] ;\n ip_address = strdup ( getenv ( \"REMOTE_ADDR\" ) ) ;\n dummy = asprintf ( & buffer , \"EXTERNAL COMMAND: %s;\n%s;\n%s\" , current_authdata . username , ( ip_address != NULL ) ? ip_address : \"unknown remote address\" , p ) ;\n write_to_cgi_log ( buffer ) ;\n if ( enforce_comments_on_actions == TRUE ) {\n my_free ( buffer ) ;\n dummy = asprintf ( & buffer , \"FORCED COMMENT: %s;\n%s;\n%s;\n%s\" , current_authdata . username , ( ip_address != NULL ) ? ip_address : \"unknown remote address\" , comment_author , comment_data ) ;\n write_to_cgi_log ( buffer ) ;\n }\n my_free ( buffer ) ;\n }\n fprintf ( fp , \"%s\\n\" , cmd ) ;\n fflush ( fp ) ;\n fclose ( fp ) ;\n return OK ;\n }","target":0,"code_token_length":499,"total_token_length":735,"max_tokens_setting":1024}
+{"idx":290356,"func":"static int imc_decode_frame(AVCodecContext *avctx, void *data,\n\n                            int *got_frame_ptr, AVPacket *avpkt)\n\n{\n\n    AVFrame *frame     = data;\n\n    const uint8_t *buf = avpkt->data;\n\n    int buf_size = avpkt->size;\n\n    int ret, i;\n\n\n\n    IMCContext *q = avctx->priv_data;\n\n\n\n    LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE \/ 2]);\n\n\n\n    if (buf_size < IMC_BLOCK_SIZE * avctx->channels) {\n\n        av_log(avctx, AV_LOG_ERROR, \"frame too small!\\n\");\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    \/* get output buffer *\/\n\n    frame->nb_samples = COEFFS;\n\n    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)\n\n        return ret;\n\n\n\n    for (i = 0; i < avctx->channels; i++) {\n\n        q->out_samples = (float *)frame->extended_data[i];\n\n\n\n        q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE \/ 2);\n\n\n\n        init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);\n\n\n\n        buf += IMC_BLOCK_SIZE;\n\n\n\n        if ((ret = imc_decode_block(avctx, q, i)) < 0)\n\n            return ret;\n\n    }\n\n\n\n    if (avctx->channels == 2) {\n\n        q->fdsp.butterflies_float((float *)frame->extended_data[0],\n\n                                  (float *)frame->extended_data[1], COEFFS);\n\n    }\n\n\n\n    *got_frame_ptr = 1;\n\n\n\n    return IMC_BLOCK_SIZE * avctx->channels;\n\n}\n","target":1,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":98786,"func":"findfilendir(\n    typval_T\t*argvars UNUSED,\n    typval_T\t*rettv,\n    int\t\tfind_what UNUSED)\n{\n#ifdef FEAT_SEARCHPATH\n    char_u\t*fname;\n    char_u\t*fresult = NULL;\n    char_u\t*path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path;\n    char_u\t*p;\n    char_u\tpathbuf[NUMBUFLEN];\n    int\t\tcount = 1;\n    int\t\tfirst = TRUE;\n    int\t\terror = FALSE;\n#endif\n\n    rettv->vval.v_string = NULL;\n    rettv->v_type = VAR_STRING;\n    if (in_vim9script()\n\t    && (check_for_nonempty_string_arg(argvars, 0) == FAIL\n\t\t|| check_for_opt_string_arg(argvars, 1) == FAIL\n\t\t|| (argvars[1].v_type != VAR_UNKNOWN\n\t\t    && check_for_opt_number_arg(argvars, 2) == FAIL)))\n\treturn;\n\n#ifdef FEAT_SEARCHPATH\n    fname = tv_get_string(&argvars[0]);\n\n    if (argvars[1].v_type != VAR_UNKNOWN)\n    {\n\tp = tv_get_string_buf_chk(&argvars[1], pathbuf);\n\tif (p == NULL)\n\t    error = TRUE;\n\telse\n\t{\n\t    if (*p != NUL)\n\t\tpath = p;\n\n\t    if (argvars[2].v_type != VAR_UNKNOWN)\n\t\tcount = (int)tv_get_number_chk(&argvars[2], &error);\n\t}\n    }\n\n    if (count < 0 && rettv_list_alloc(rettv) == FAIL)\n\terror = TRUE;\n\n    if (*fname != NUL && !error)\n    {\n\tdo\n\t{\n\t    if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST)\n\t\tvim_free(fresult);\n\t    fresult = find_file_in_path_option(first ? fname : NULL,\n\t\t\t\t\t       first ? (int)STRLEN(fname) : 0,\n\t\t\t\t\t0, first, path,\n\t\t\t\t\tfind_what,\n\t\t\t\t\tcurbuf->b_ffname,\n\t\t\t\t\tfind_what == FINDFILE_DIR\n\t\t\t\t\t    ? (char_u *)\"\" : curbuf->b_p_sua);\n\t    first = FALSE;\n\n\t    if (fresult != NULL && rettv->v_type == VAR_LIST)\n\t\tlist_append_string(rettv->vval.v_list, fresult, -1);\n\n\t} while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL);\n    }\n\n    if (rettv->v_type == VAR_STRING)\n\trettv->vval.v_string = fresult;\n#endif\n}","target":0,"code_token_length":569,"total_token_length":805,"max_tokens_setting":1024}
+{"idx":394631,"func":"wb_set_offset(struct archive_write *a, int64_t off)\n{\n\tstruct iso9660 *iso9660 = (struct iso9660 *)a->format_data;\n\tint64_t used, ext_bytes;\n\n\tif (iso9660->wbuff_type != WB_TO_TEMP) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t    \"Internal Programing error: iso9660:wb_set_offset()\");\n\t\treturn (ARCHIVE_FATAL);\n\t}\n\n\tused = sizeof(iso9660->wbuff) - iso9660->wbuff_remaining;\n\tif (iso9660->wbuff_offset + used > iso9660->wbuff_tail)\n\t\tiso9660->wbuff_tail = iso9660->wbuff_offset + used;\n\tif (iso9660->wbuff_offset < iso9660->wbuff_written) {\n\t\tif (used > 0 &&\n\t\t    write_to_temp(a, iso9660->wbuff, (size_t)used) != ARCHIVE_OK)\n\t\t\treturn (ARCHIVE_FATAL);\n\t\tiso9660->wbuff_offset = iso9660->wbuff_written;\n\t\tlseek(iso9660->temp_fd, iso9660->wbuff_offset, SEEK_SET);\n\t\tiso9660->wbuff_remaining = sizeof(iso9660->wbuff);\n\t\tused = 0;\n\t}\n\tif (off < iso9660->wbuff_offset) {\n\t\t\/*\n\t\t * Write out waiting data.\n\t\t *\/\n\t\tif (used > 0) {\n\t\t\tif (wb_write_out(a) != ARCHIVE_OK)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tlseek(iso9660->temp_fd, off, SEEK_SET);\n\t\tiso9660->wbuff_offset = off;\n\t\tiso9660->wbuff_remaining = sizeof(iso9660->wbuff);\n\t} else if (off <= iso9660->wbuff_tail) {\n\t\tiso9660->wbuff_remaining = (size_t)\n\t\t    (sizeof(iso9660->wbuff) - (off - iso9660->wbuff_offset));\n\t} else {\n\t\text_bytes = off - iso9660->wbuff_tail;\n\t\tiso9660->wbuff_remaining = (size_t)(sizeof(iso9660->wbuff)\n\t\t   - (iso9660->wbuff_tail - iso9660->wbuff_offset));\n\t\twhile (ext_bytes >= (int64_t)iso9660->wbuff_remaining) {\n\t\t\tif (write_null(a, (size_t)iso9660->wbuff_remaining)\n\t\t\t    != ARCHIVE_OK)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\text_bytes -= iso9660->wbuff_remaining;\n\t\t}\n\t\tif (ext_bytes > 0) {\n\t\t\tif (write_null(a, (size_t)ext_bytes) != ARCHIVE_OK)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t}\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":694,"total_token_length":930,"max_tokens_setting":1024}
+{"idx":472050,"func":"static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info)\n{\n   stbi_uc version;\n   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8')\n      return stbi__err(\"not GIF\", \"Corrupt GIF\");\n\n   version = stbi__get8(s);\n   if (version != '7' && version != '9')    return stbi__err(\"not GIF\", \"Corrupt GIF\");\n   if (stbi__get8(s) != 'a')                return stbi__err(\"not GIF\", \"Corrupt GIF\");\n\n   stbi__g_failure_reason = \"\";\n   g->w = stbi__get16le(s);\n   g->h = stbi__get16le(s);\n   g->flags = stbi__get8(s);\n   g->bgindex = stbi__get8(s);\n   g->ratio = stbi__get8(s);\n   g->transparent = -1;\n\n   if (g->w > STBI_MAX_DIMENSIONS) return stbi__err(\"too large\",\"Very large image (corrupt?)\");\n   if (g->h > STBI_MAX_DIMENSIONS) return stbi__err(\"too large\",\"Very large image (corrupt?)\");\n\n   if (comp != 0) *comp = 4;  \/\/ can't actually tell whether it's 3 or 4 until we parse the comments\n\n   if (is_info) return 1;\n\n   if (g->flags & 0x80)\n      stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1);\n\n   return 1;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":481663,"func":"static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net,\n\t\t\t\t    u32 portid, u32 seq, int event,\n\t\t\t\t    u32 flags, int family,\n\t\t\t\t    const struct nft_table *table,\n\t\t\t\t    const struct nft_chain *chain,\n\t\t\t\t    const struct nft_rule *rule, u64 handle)\n{\n\tstruct nlmsghdr *nlh;\n\tconst struct nft_expr *expr, *next;\n\tstruct nlattr *list;\n\tu16 type = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event);\n\n\tnlh = nfnl_msg_put(skb, portid, seq, type, flags, family, NFNETLINK_V0,\n\t\t\t   nft_base_seq(net));\n\tif (!nlh)\n\t\tgoto nla_put_failure;\n\n\tif (nla_put_string(skb, NFTA_RULE_TABLE, table->name))\n\t\tgoto nla_put_failure;\n\tif (nla_put_string(skb, NFTA_RULE_CHAIN, chain->name))\n\t\tgoto nla_put_failure;\n\tif (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle),\n\t\t\t NFTA_RULE_PAD))\n\t\tgoto nla_put_failure;\n\n\tif (event != NFT_MSG_DELRULE && handle) {\n\t\tif (nla_put_be64(skb, NFTA_RULE_POSITION, cpu_to_be64(handle),\n\t\t\t\t NFTA_RULE_PAD))\n\t\t\tgoto nla_put_failure;\n\t}\n\n\tif (chain->flags & NFT_CHAIN_HW_OFFLOAD)\n\t\tnft_flow_rule_stats(chain, rule);\n\n\tlist = nla_nest_start_noflag(skb, NFTA_RULE_EXPRESSIONS);\n\tif (list == NULL)\n\t\tgoto nla_put_failure;\n\tnft_rule_for_each_expr(expr, next, rule) {\n\t\tif (nft_expr_dump(skb, NFTA_LIST_ELEM, expr) < 0)\n\t\t\tgoto nla_put_failure;\n\t}\n\tnla_nest_end(skb, list);\n\n\tif (rule->udata) {\n\t\tstruct nft_userdata *udata = nft_userdata(rule);\n\t\tif (nla_put(skb, NFTA_RULE_USERDATA, udata->len + 1,\n\t\t\t    udata->data) < 0)\n\t\t\tgoto nla_put_failure;\n\t}\n\n\tnlmsg_end(skb, nlh);\n\treturn 0;\n\nnla_put_failure:\n\tnlmsg_trim(skb, nlh);\n\treturn -1;\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":151831,"func":"Perl_reg_numbered_buff_length(pTHX_ REGEXP * const r, const SV * const sv,\n                              const I32 paren)\n{\n    struct regexp *const rx = ReANY(r);\n    I32 i;\n    I32 s1, t1;\n\n    PERL_ARGS_ASSERT_REG_NUMBERED_BUFF_LENGTH;\n\n    if (   paren == RX_BUFF_IDX_CARET_PREMATCH\n        || paren == RX_BUFF_IDX_CARET_FULLMATCH\n        || paren == RX_BUFF_IDX_CARET_POSTMATCH\n    )\n    {\n        bool keepcopy = cBOOL(rx->extflags & RXf_PMf_KEEPCOPY);\n        if (!keepcopy) {\n            \/* on something like\n             *    $r = qr\/...\/;\n             *    \/$qr\/p;\n             * the KEEPCOPY is set on the PMOP rather than the regex *\/\n            if (PL_curpm && r == PM_GETRE(PL_curpm))\n                 keepcopy = cBOOL(PL_curpm->op_pmflags & PMf_KEEPCOPY);\n        }\n        if (!keepcopy)\n            goto warn_undef;\n    }\n\n    \/* Some of this code was originally in C in F *\/\n    switch (paren) {\n      case RX_BUFF_IDX_CARET_PREMATCH: \/* ${^PREMATCH} *\/\n      case RX_BUFF_IDX_PREMATCH:       \/* $` *\/\n        if (rx->offs[0].start != -1) {\n\t\t\ti = rx->offs[0].start;\n\t\t\tif (i > 0) {\n\t\t\t\ts1 = 0;\n\t\t\t\tt1 = i;\n\t\t\t\tgoto getlen;\n\t\t\t}\n\t    }\n        return 0;\n\n      case RX_BUFF_IDX_CARET_POSTMATCH: \/* ${^POSTMATCH} *\/\n      case RX_BUFF_IDX_POSTMATCH:       \/* $' *\/\n\t    if (rx->offs[0].end != -1) {\n\t\t\ti = rx->sublen - rx->offs[0].end;\n\t\t\tif (i > 0) {\n\t\t\t\ts1 = rx->offs[0].end;\n\t\t\t\tt1 = rx->sublen;\n\t\t\t\tgoto getlen;\n\t\t\t}\n\t    }\n        return 0;\n\n      default: \/* $& \/ ${^MATCH}, $1, $2, ... *\/\n\t    if (paren <= (I32)rx->nparens &&\n            (s1 = rx->offs[paren].start) != -1 &&\n            (t1 = rx->offs[paren].end) != -1)\n\t    {\n            i = t1 - s1;\n            goto getlen;\n        } else {\n          warn_undef:\n            if (ckWARN(WARN_UNINITIALIZED))\n                report_uninit((const SV *)sv);\n            return 0;\n        }\n    }\n  getlen:\n    if (i > 0 && RXp_MATCH_UTF8(rx)) {\n        const char * const s = rx->subbeg - rx->suboffset + s1;\n        const U8 *ep;\n        STRLEN el;\n\n        i = t1 - s1;\n        if (is_utf8_string_loclen((U8*)s, i, &ep, &el))\n\t\t\ti = el;\n    }\n    return i;\n}","target":0,"code_token_length":690,"total_token_length":926,"max_tokens_setting":1024}
+{"idx":245575,"func":"void parseVorbisComment(\n const sp &fileMeta, const char *comment, size_t commentLength)\n{\n struct {\n const char *const mTag;\n uint32_t mKey;\n } kMap[] = {\n { \"TITLE\", kKeyTitle },\n { \"ARTIST\", kKeyArtist },\n { \"ALBUMARTIST\", kKeyAlbumArtist },\n { \"ALBUM ARTIST\", kKeyAlbumArtist },\n { \"COMPILATION\", kKeyCompilation },\n { \"ALBUM\", kKeyAlbum },\n { \"COMPOSER\", kKeyComposer },\n { \"GENRE\", kKeyGenre },\n { \"AUTHOR\", kKeyAuthor },\n { \"TRACKNUMBER\", kKeyCDTrackNumber },\n { \"DISCNUMBER\", kKeyDiscNumber },\n { \"DATE\", kKeyDate },\n { \"YEAR\", kKeyYear },\n { \"LYRICIST\", kKeyWriter },\n { \"METADATA_BLOCK_PICTURE\", kKeyAlbumArt },\n { \"ANDROID_LOOP\", kKeyAutoLoop },\n };\n\n for (size_t j = 0; j < sizeof(kMap) \/ sizeof(kMap[0]); ++j) {\n size_t tagLen = strlen(kMap[j].mTag);\n if (!strncasecmp(kMap[j].mTag, comment, tagLen)\n && comment[tagLen] == '=') {\n if (kMap[j].mKey == kKeyAlbumArt) {\n                    extractAlbumArt(\n                            fileMeta,\n &comment[tagLen + 1],\n                            commentLength - tagLen - 1);\n } else if (kMap[j].mKey == kKeyAutoLoop) {\n if (!strcasecmp(&comment[tagLen + 1], \"true\")) {\n                        fileMeta->setInt32(kKeyAutoLoop, true);\n }\n } else {\n                    fileMeta->setCString(kMap[j].mKey, &comment[tagLen + 1]);\n }\n }\n }\n\n}\n","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":106497,"func":"TEST_P(TcpTunnelingIntegrationTest, BasicUsePost) {\n  \/\/ Enable using POST.\n  config_helper_.addConfigModifier([&](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void {\n    envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy proxy_config;\n    proxy_config.set_stat_prefix(\"tcp_stats\");\n    proxy_config.set_cluster(\"cluster_0\");\n    proxy_config.mutable_tunneling_config()->set_hostname(\"host.com:80\");\n    proxy_config.mutable_tunneling_config()->set_use_post(true);\n\n    auto* listeners = bootstrap.mutable_static_resources()->mutable_listeners();\n    for (auto& listener : *listeners) {\n      if (listener.name() != \"tcp_proxy\") {\n        continue;\n      }\n      auto* filter_chain = listener.mutable_filter_chains(0);\n      auto* filter = filter_chain->mutable_filters(0);\n      filter->mutable_typed_config()->PackFrom(proxy_config);\n      break;\n    }\n  });\n\n  initialize();\n\n  \/\/ Start a connection, and verify the upgrade headers are received upstream.\n  tcp_client_ = makeTcpConnection(lookupPort(\"tcp_proxy\"));\n  ASSERT_TRUE(fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, fake_upstream_connection_));\n  ASSERT_TRUE(fake_upstream_connection_->waitForNewStream(*dispatcher_, upstream_request_));\n  ASSERT_TRUE(upstream_request_->waitForHeadersComplete());\n  EXPECT_EQ(upstream_request_->headers().get(Http::Headers::get().Method)[0]->value(), \"POST\");\n\n  \/\/ Send upgrade headers downstream, fully establishing the connection.\n  upstream_request_->encodeHeaders(default_response_headers_, false);\n\n  sendBidiData(fake_upstream_connection_);\n  closeConnection(fake_upstream_connection_);\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":286873,"func":"static void m5206_mbar_writew(void *opaque, target_phys_addr_t offset,\n\n                              uint32_t value)\n\n{\n\n    m5206_mbar_state *s = (m5206_mbar_state *)opaque;\n\n    int width;\n\n    offset &= 0x3ff;\n\n    if (offset >= 0x200) {\n\n        hw_error(\"Bad MBAR write offset 0x%x\", (int)offset);\n\n    }\n\n    width = m5206_mbar_width[offset >> 2];\n\n    if (width > 2) {\n\n        uint32_t tmp;\n\n        tmp = m5206_mbar_readl(opaque, offset & ~3);\n\n        if (offset & 3) {\n\n            tmp = (tmp & 0xffff0000) | value;\n\n        } else {\n\n            tmp = (tmp & 0x0000ffff) | (value << 16);\n\n        }\n\n        m5206_mbar_writel(opaque, offset & ~3, tmp);\n\n        return;\n\n    } else if (width < 2) {\n\n        m5206_mbar_writeb(opaque, offset, value >> 8);\n\n        m5206_mbar_writeb(opaque, offset + 1, value & 0xff);\n\n        return;\n\n    }\n\n    m5206_mbar_write(s, offset, value, 2);\n\n}\n","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":414306,"func":"GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)\n{\n    PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pslpi, ptr;\n    DWORD length;\n    GuestLogicalProcessorList *head, **link;\n    Error *local_err = NULL;\n    int64_t current;\n\n    ptr = pslpi = NULL;\n    length = 0;\n    current = 0;\n    head = NULL;\n    link = &head;\n\n    if ((GetLogicalProcessorInformation(pslpi, &length) == FALSE) &&\n        (GetLastError() == ERROR_INSUFFICIENT_BUFFER) &&\n        (length > sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION))) {\n        ptr = pslpi = g_malloc0(length);\n        if (GetLogicalProcessorInformation(pslpi, &length) == FALSE) {\n            error_setg(&local_err, \"Failed to get processor information: %d\",\n                       (int)GetLastError());\n        }\n    } else {\n        error_setg(&local_err,\n                   \"Failed to get processor information buffer length: %d\",\n                   (int)GetLastError());\n    }\n\n    while ((local_err == NULL) && (length > 0)) {\n        if (pslpi->Relationship == RelationProcessorCore) {\n            ULONG_PTR cpu_bits = pslpi->ProcessorMask;\n\n            while (cpu_bits > 0) {\n                if (!!(cpu_bits & 1)) {\n                    GuestLogicalProcessor *vcpu;\n                    GuestLogicalProcessorList *entry;\n\n                    vcpu = g_malloc0(sizeof *vcpu);\n                    vcpu->logical_id = current++;\n                    vcpu->online = true;\n                    vcpu->has_can_offline = true;\n\n                    entry = g_malloc0(sizeof *entry);\n                    entry->value = vcpu;\n\n                    *link = entry;\n                    link = &entry->next;\n                }\n                cpu_bits >>= 1;\n            }\n        }\n        length -= sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);\n        pslpi++; \/* next entry *\/\n    }\n\n    g_free(ptr);\n\n    if (local_err == NULL) {\n        if (head != NULL) {\n            return head;\n        }\n        \/* there's no guest with zero VCPUs *\/\n        error_setg(&local_err, \"Guest reported zero VCPUs\");\n    }\n\n    qapi_free_GuestLogicalProcessorList(head);\n    error_propagate(errp, local_err);\n    return NULL;\n}","target":0,"code_token_length":502,"total_token_length":738,"max_tokens_setting":1024}
+{"idx":488869,"func":"static gboolean avdtp_parse_resp(struct avdtp *session,\n\t\t\t\t\tstruct avdtp_stream *stream,\n\t\t\t\t\tuint8_t transaction, uint8_t signal_id,\n\t\t\t\t\tvoid *buf, int size)\n{\n\tstruct pending_req *next;\n\tconst char *get_all = \"\";\n\n\tif (session->prio_queue)\n\t\tnext = session->prio_queue->data;\n\telse if (session->req_queue)\n\t\tnext = session->req_queue->data;\n\telse\n\t\tnext = NULL;\n\n\tswitch (signal_id) {\n\tcase AVDTP_DISCOVER:\n\t\tDBG(\"DISCOVER request succeeded\");\n\t\treturn avdtp_discover_resp(session, buf, size);\n\tcase AVDTP_GET_ALL_CAPABILITIES:\n\t\tget_all = \"ALL_\";\n\t\t\/* fall through *\/\n\tcase AVDTP_GET_CAPABILITIES:\n\t\tDBG(\"GET_%sCAPABILITIES request succeeded\", get_all);\n\t\tif (!avdtp_get_capabilities_resp(session, buf, size))\n\t\t\treturn FALSE;\n\t\tif (!(next && (next->signal_id == AVDTP_GET_CAPABILITIES ||\n\t\t\t\tnext->signal_id == AVDTP_GET_ALL_CAPABILITIES)))\n\t\t\tfinalize_discovery(session, 0);\n\t\treturn TRUE;\n\t}\n\n\t\/* The remaining commands require an existing stream so bail out\n\t * here if the stream got unexpectedly disconnected *\/\n\tif (!stream) {\n\t\tDBG(\"AVDTP: stream was closed while waiting for reply\");\n\t\treturn TRUE;\n\t}\n\n\tswitch (signal_id) {\n\tcase AVDTP_SET_CONFIGURATION:\n\t\tDBG(\"SET_CONFIGURATION request succeeded\");\n\t\treturn avdtp_set_configuration_resp(session, stream,\n\t\t\t\t\t\t\t\tbuf, size);\n\tcase AVDTP_RECONFIGURE:\n\t\tDBG(\"RECONFIGURE request succeeded\");\n\t\treturn avdtp_reconfigure_resp(session, stream, buf, size);\n\tcase AVDTP_OPEN:\n\t\tDBG(\"OPEN request succeeded\");\n\t\treturn avdtp_open_resp(session, stream, buf, size);\n\tcase AVDTP_SUSPEND:\n\t\tDBG(\"SUSPEND request succeeded\");\n\t\treturn avdtp_suspend_resp(session, stream, buf, size);\n\tcase AVDTP_START:\n\t\tDBG(\"START request succeeded\");\n\t\treturn avdtp_start_resp(session, stream, buf, size);\n\tcase AVDTP_CLOSE:\n\t\tDBG(\"CLOSE request succeeded\");\n\t\treturn avdtp_close_resp(session, stream, buf, size);\n\tcase AVDTP_ABORT:\n\t\tDBG(\"ABORT request succeeded\");\n\t\treturn avdtp_abort_resp(session, stream, buf, size);\n\tcase AVDTP_DELAY_REPORT:\n\t\tDBG(\"DELAY_REPORT request succeeded\");\n\t\treturn avdtp_delay_report_resp(session, stream, buf, size);\n\t}\n\n\terror(\"Unknown signal id in accept response: %u\", signal_id);\n\treturn TRUE;\n}","target":0,"code_token_length":569,"total_token_length":805,"max_tokens_setting":1024}
+{"idx":220657,"func":"CoreEnterLeaveEvent(DeviceIntPtr mouse,\n                    int type,\n                    int mode, int detail, WindowPtr pWin, Window child)\n{\n    xEvent event = {\n        .u.u.type = type,\n        .u.u.detail = detail\n    };\n    WindowPtr focus;\n    DeviceIntPtr keybd;\n    GrabPtr grab = mouse->deviceGrab.grab;\n    Mask mask;\n\n    keybd = GetMaster(mouse, KEYBOARD_OR_FLOAT);\n\n    if ((pWin == mouse->valuator->motionHintWindow) &&\n        (detail != NotifyInferior))\n        mouse->valuator->motionHintWindow = NullWindow;\n    if (grab) {\n        mask = (pWin == grab->window) ? grab->eventMask : 0;\n        if (grab->ownerEvents)\n            mask |= EventMaskForClient(pWin, rClient(grab));\n    }\n    else {\n        mask = pWin->eventMask | wOtherEventMasks(pWin);\n    }\n\n    event.u.enterLeave.time = currentTime.milliseconds;\n    event.u.enterLeave.rootX = mouse->spriteInfo->sprite->hot.x;\n    event.u.enterLeave.rootY = mouse->spriteInfo->sprite->hot.y;\n    \/* Counts on the same initial structure of crossing & button events! *\/\n    FixUpEventFromWindow(mouse->spriteInfo->sprite, &event, pWin, None, FALSE);\n    \/* Enter\/Leave events always set child *\/\n    event.u.enterLeave.child = child;\n    event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?\n        ELFlagSameScreen : 0;\n    event.u.enterLeave.state =\n        mouse->button ? (mouse->button->state & 0x1f00) : 0;\n    if (keybd)\n        event.u.enterLeave.state |=\n            XkbGrabStateFromRec(&keybd->key->xkbInfo->state);\n    event.u.enterLeave.mode = mode;\n    focus = (keybd) ? keybd->focus->win : None;\n    if ((focus != NoneWin) &&\n        ((pWin == focus) || (focus == PointerRootWin) || IsParent(focus, pWin)))\n        event.u.enterLeave.flags |= ELFlagFocus;\n\n    if ((mask & GetEventFilter(mouse, &event))) {\n        if (grab)\n            TryClientEvents(rClient(grab), mouse, &event, 1, mask,\n                            GetEventFilter(mouse, &event), grab);\n        else\n            DeliverEventsToWindow(mouse, pWin, &event, 1,\n                                  GetEventFilter(mouse, &event), NullGrab);\n    }\n\n    if ((type == EnterNotify) && (mask & KeymapStateMask)) {\n        xKeymapEvent ke = {\n            .type = KeymapNotify\n        };\n        ClientPtr client = grab ? rClient(grab) : wClient(pWin);\n        int rc;\n\n        rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);\n        if (rc == Success)\n            memcpy((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);\n\n        if (grab)\n            TryClientEvents(rClient(grab), keybd, (xEvent *) &ke, 1,\n                            mask, KeymapStateMask, grab);\n        else\n            DeliverEventsToWindow(mouse, pWin, (xEvent *) &ke, 1,\n                                  KeymapStateMask, NullGrab);\n    }\n}\n","target":0,"code_token_length":730,"total_token_length":966,"max_tokens_setting":1024}
+{"idx":447472,"func":"smtp_set_error (CamelSmtpTransport *transport,\n\t\tCamelStreamBuffer *istream,\n                const gchar *respbuf,\n                GCancellable *cancellable,\n                GError **error)\n{\n\tconst gchar *token, *rbuf = respbuf;\n\tgchar *buffer = NULL;\n\tGString *string;\n\n\tg_return_if_fail (respbuf != NULL);\n\n\tstring = g_string_new (\"\");\n\tdo {\n\t\tif (transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)\n\t\t\ttoken = smtp_next_token (rbuf + 4);\n\t\telse\n\t\t\ttoken = rbuf + 4;\n\n\t\tif (*token == '\\0') {\n\t\t\tg_free (buffer);\n\t\t\tg_string_free (string, TRUE);\n\t\t\tgoto fake_status_code;\n\t\t}\n\n\t\tg_string_append (string, token);\n\t\tif (*(rbuf + 3) == '-') {\n\t\t\tg_free (buffer);\n\t\t\tbuffer = camel_stream_buffer_read_line (istream, cancellable, NULL);\n\t\t\td (fprintf (stderr, \"[SMTP] received: %s\\n\", buffer ? buffer : \"(null)\"));\n\t\t\tg_string_append_c (string, '\\n');\n\t\t} else {\n\t\t\tg_free (buffer);\n\t\t\tbuffer = NULL;\n\t\t}\n\n\t\trbuf = buffer;\n\t} while (rbuf);\n\n\tconvert_to_local (string);\n\tif (!(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES) && string->len) {\n\t\tstring->str = g_strstrip (string->str);\n\t\tstring->len = strlen (string->str);\n\n\t\tif (!string->len) {\n\t\t\tg_string_free (string, TRUE);\n\t\t\tgoto fake_status_code;\n\t\t}\n\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR,\n\t\t\tCAMEL_ERROR_GENERIC,\n\t\t\t\"%s\", string->str);\n\n\t\tg_string_free (string, TRUE);\n\t} else {\n\t\tbuffer = smtp_decode_status_code (string->str, string->len);\n\t\tg_string_free (string, TRUE);\n\t\tif (!buffer)\n\t\t\tgoto fake_status_code;\n\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR,\n\t\t\tCAMEL_ERROR_GENERIC,\n\t\t\t\"%s\", buffer);\n\n\t\tg_free (buffer);\n\t}\n\n\treturn;\n\nfake_status_code:\n\tg_set_error (\n\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\"%s\", smtp_error_string (atoi (respbuf)));\n}","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":254140,"func":"void AXLayoutObject::setSelection(const AXRange& selection) {\n  if (!getLayoutObject() || !selection.isValid())\n    return;\n\n  AXObject* anchorObject =\n      selection.anchorObject ? selection.anchorObject.get() : this;\n  AXObject* focusObject =\n      selection.focusObject ? selection.focusObject.get() : this;\n\n  if (!isValidSelectionBound(anchorObject) ||\n      !isValidSelectionBound(focusObject)) {\n    return;\n  }\n\n  if (anchorObject == focusObject &&\n      anchorObject->getLayoutObject()->isTextControl()) {\n    TextControlElement* textControl =\n        toLayoutTextControl(anchorObject->getLayoutObject())\n            ->textControlElement();\n    if (selection.anchorOffset <= selection.focusOffset) {\n      textControl->setSelectionRange(selection.anchorOffset,\n                                     selection.focusOffset,\n                                     SelectionHasForwardDirection);\n    } else {\n      textControl->setSelectionRange(selection.focusOffset,\n                                     selection.anchorOffset,\n                                     SelectionHasBackwardDirection);\n    }\n    return;\n  }\n\n  LocalFrame* frame = getLayoutObject()->frame();\n  if (!frame)\n    return;\n\n  frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();\n\n  VisiblePosition anchorVisiblePosition =\n      toVisiblePosition(anchorObject, selection.anchorOffset);\n  VisiblePosition focusVisiblePosition =\n      toVisiblePosition(focusObject, selection.focusOffset);\n  if (anchorVisiblePosition.isNull() || focusVisiblePosition.isNull())\n    return;\n\n  frame->selection().setSelection(\n      SelectionInDOMTree::Builder()\n          .collapse(anchorVisiblePosition.toPositionWithAffinity())\n          .extend(focusVisiblePosition.deepEquivalent())\n          .build());\n}\n","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":345747,"func":"PHP_HASH_API void PHP_HAVAL224Final(unsigned char *digest, PHP_HAVAL_CTX * context)\n{\n\tunsigned char bits[10];\n\tunsigned int index, padLen;\n\n\t\/* Version, Passes, and Digest Length *\/\n\tbits[0] =\t(PHP_HASH_HAVAL_VERSION & 0x07) |\n\t\t\t\t((context->passes & 0x07) << 3) |\n\t\t\t\t((context->output & 0x03) << 6);\n\tbits[1] = (context->output >> 2);\n\n\t\/* Save number of bits *\/\n\tEncode(bits + 2, context->count, 8);\n\n\t\/* Pad out to 118 mod 128.\n\t *\/\n\tindex = (unsigned int) ((context->count[0] >> 3) & 0x3f);\n\tpadLen = (index < 118) ? (118 - index) : (246 - index);\n\tPHP_HAVALUpdate(context, PADDING, padLen);\n\n\t\/* Append version, passes, digest length, and message length *\/\n\tPHP_HAVALUpdate(context, bits, 10);\n\n\t\/* Store state in digest *\/\n\tcontext->state[6] +=  context->state[7]        & 0x0000000F;\n\tcontext->state[5] += (context->state[7] >>  4) & 0x0000001F;\n\tcontext->state[4] += (context->state[7] >>  9) & 0x0000000F;\n\tcontext->state[3] += (context->state[7] >> 13) & 0x0000001F;\n\tcontext->state[2] += (context->state[7] >> 18) & 0x0000000F;\n\tcontext->state[1] += (context->state[7] >> 22) & 0x0000001F;\n\tcontext->state[0] += (context->state[7] >> 27) & 0x0000001F;\n\tEncode(digest, context->state, 28);\n\n\t\/* Zeroize sensitive information.\n\t *\/\n\tmemset((unsigned char*) context, 0, sizeof(*context));\n}","target":1,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":230758,"func":"encode_REG_MOVE(const struct ofpact_reg_move *move,\n                enum ofp_version ofp_version, struct ofpbuf *out)\n{\n    \/* For OpenFlow 1.3, the choice of ONFACT_RAW13_COPY_FIELD versus\n     * NXAST_RAW_REG_MOVE is somewhat difficult.  Neither one is guaranteed to\n     * be supported by every OpenFlow 1.3 implementation.  It would be ideal to\n     * probe for support.  Until we have that ability, we currently prefer\n     * NXAST_RAW_REG_MOVE for backward compatibility with older Open vSwitch\n     * versions.  *\/\n    size_t start_ofs = out->size;\n    if (ofp_version >= OFP15_VERSION) {\n        struct ofp15_action_copy_field *copy = put_OFPAT15_COPY_FIELD(out);\n        copy->n_bits = htons(move->dst.n_bits);\n        copy->src_offset = htons(move->src.ofs);\n        copy->dst_offset = htons(move->dst.ofs);\n        out->size = out->size - sizeof copy->pad2;\n        nx_put_mff_header(out, move->src.field, ofp_version, false);\n        nx_put_mff_header(out, move->dst.field, ofp_version, false);\n    } else if (ofp_version == OFP13_VERSION\n               && move->ofpact.raw == ONFACT_RAW13_COPY_FIELD) {\n        struct onf_action_copy_field *copy = put_ONFACT13_COPY_FIELD(out);\n        copy->n_bits = htons(move->dst.n_bits);\n        copy->src_offset = htons(move->src.ofs);\n        copy->dst_offset = htons(move->dst.ofs);\n        out->size = out->size - sizeof copy->pad3;\n        nx_put_mff_header(out, move->src.field, ofp_version, false);\n        nx_put_mff_header(out, move->dst.field, ofp_version, false);\n    } else {\n        struct nx_action_reg_move *narm = put_NXAST_REG_MOVE(out);\n        narm->n_bits = htons(move->dst.n_bits);\n        narm->src_ofs = htons(move->src.ofs);\n        narm->dst_ofs = htons(move->dst.ofs);\n        nx_put_mff_header(out, move->src.field, 0, false);\n        nx_put_mff_header(out, move->dst.field, 0, false);\n    }\n    pad_ofpat(out, start_ofs);\n}\n","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":158011,"func":"static void pci_basic(gconstpointer data)\n\n{\n\n    QVirtioPCIDevice *dev;\n\n    QPCIBus *bus;\n\n    QVirtQueuePCI *tx, *rx;\n\n    QGuestAllocator *alloc;\n\n    void (*func) (QVirtioDevice *dev,\n\n                  QGuestAllocator *alloc,\n\n                  QVirtQueue *rvq,\n\n                  QVirtQueue *tvq,\n\n                  int socket) = data;\n\n    int sv[2], ret;\n\n\n\n    ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv);\n\n    g_assert_cmpint(ret, !=, -1);\n\n\n\n    bus = pci_test_start(sv[1]);\n\n    dev = virtio_net_pci_init(bus, PCI_SLOT);\n\n\n\n    alloc = pc_alloc_init();\n\n    rx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, 0);\n\n    tx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, alloc, 1);\n\n\n\n    driver_init(&dev->vdev);\n\n    func(&dev->vdev, alloc, &rx->vq, &tx->vq, sv[0]);\n\n\n\n    \/* End test *\/\n\n    close(sv[0]);\n\n    qvirtqueue_cleanup(dev->vdev.bus, &tx->vq, alloc);\n\n    qvirtqueue_cleanup(dev->vdev.bus, &rx->vq, alloc);\n\n    pc_alloc_uninit(alloc);\n\n    qvirtio_pci_device_disable(dev);\n\n    g_free(dev->pdev);\n\n    g_free(dev);\n\n    qpci_free_pc(bus);\n\n    test_end();\n\n}\n","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":435434,"func":"int proppatch_principalname(xmlNodePtr prop, unsigned set,\n                          struct proppatch_ctx *pctx,\n                          struct propstat propstat[],\n                          void *rock __attribute__((unused)))\n{\n    struct mailbox *mailbox = pctx->mailbox;\n    struct mailbox *calhomeset = NULL;\n\n    if (pctx->txn->req_tgt.namespace->id == URL_NS_PRINCIPAL) {\n        \/* We have been storing CUAS on cal-home-set, NOT INBOX *\/\n        char *mboxname = caldav_mboxname(pctx->txn->req_tgt.userid, NULL);\n        int r = 0;\n\n        if (!mailbox || strcmp(mboxname, mailbox->name)) {\n            r = mailbox_open_iwl(mboxname, &calhomeset);\n            if (!r) pctx->mailbox = calhomeset;\n        }\n        free(mboxname);\n\n        if (r) {\n            xml_add_prop(HTTP_SERVER_ERROR, pctx->ns[NS_DAV],\n                         &propstat[PROPSTAT_ERROR],\n                         prop->name, prop->ns, NULL, 0);\n            *pctx->ret = HTTP_SERVER_ERROR;\n            return 0;\n        }\n    }\n    else {\n        \/* shouldn't happen!  Internal server error 'r' us *\/\n        *pctx->ret = HTTP_SERVER_ERROR;\n        return 0;\n    }\n\n    \/* Make sure this is on a collection and the user has admin rights *\/\n    if (pctx->txn->req_tgt.resource ||\n        !(cyrus_acl_myrights(httpd_authstate, pctx->mailbox->acl) & DACL_ADMIN)) {\n        xml_add_prop(HTTP_FORBIDDEN, pctx->ns[NS_DAV],\n                     &propstat[PROPSTAT_FORBID],\n                     prop->name, prop->ns, NULL, 0);\n\n        *pctx->ret = HTTP_FORBIDDEN;\n    }\n    else {\n        char *value = NULL;\n\n        if (set) {\n            value = (char *) xmlNodeGetContent(prop);\n        }\n\n        proppatch_todb(prop, set, pctx, propstat, (void *) value);\n        free(value);\n    }\n\n    if (calhomeset) {\n        mailbox_close(&calhomeset);\n        pctx->mailbox = mailbox;\n    }\n\n    return 0;\n}","target":0,"code_token_length":487,"total_token_length":723,"max_tokens_setting":1024}
+{"idx":487783,"func":"static void ext4_mb_show_ac(struct ext4_allocation_context *ac)\n{\n\tstruct super_block *sb = ac->ac_sb;\n\n\tif (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)\n\t\treturn;\n\n\tmb_debug(sb, \"Can't allocate:\"\n\t\t\t\" Allocation context details:\");\n\tmb_debug(sb, \"status %u flags 0x%x\",\n\t\t\tac->ac_status, ac->ac_flags);\n\tmb_debug(sb, \"orig %lu\/%lu\/%lu@%lu, \"\n\t\t\t\"goal %lu\/%lu\/%lu@%lu, \"\n\t\t\t\"best %lu\/%lu\/%lu@%lu cr %d\",\n\t\t\t(unsigned long)ac->ac_o_ex.fe_group,\n\t\t\t(unsigned long)ac->ac_o_ex.fe_start,\n\t\t\t(unsigned long)ac->ac_o_ex.fe_len,\n\t\t\t(unsigned long)ac->ac_o_ex.fe_logical,\n\t\t\t(unsigned long)ac->ac_g_ex.fe_group,\n\t\t\t(unsigned long)ac->ac_g_ex.fe_start,\n\t\t\t(unsigned long)ac->ac_g_ex.fe_len,\n\t\t\t(unsigned long)ac->ac_g_ex.fe_logical,\n\t\t\t(unsigned long)ac->ac_b_ex.fe_group,\n\t\t\t(unsigned long)ac->ac_b_ex.fe_start,\n\t\t\t(unsigned long)ac->ac_b_ex.fe_len,\n\t\t\t(unsigned long)ac->ac_b_ex.fe_logical,\n\t\t\t(int)ac->ac_criteria);\n\tmb_debug(sb, \"%u found\", ac->ac_found);\n\text4_mb_show_pa(sb);\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":123731,"func":"check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,\n\t\t\t\t  struct xt_table_info *newinfo,\n\t\t\t\t  unsigned int *size,\n\t\t\t\t  const unsigned char *base,\n\t\t\t\t  const unsigned char *limit)\n{\n\tstruct xt_entry_match *ematch;\n\tstruct xt_entry_target *t;\n\tstruct xt_target *target;\n\tunsigned int entry_offset;\n\tunsigned int j;\n\tint ret, off;\n\n\tif ((unsigned long)e % __alignof__(struct compat_ip6t_entry) != 0 ||\n\t    (unsigned char *)e + sizeof(struct compat_ip6t_entry) >= limit ||\n\t    (unsigned char *)e + e->next_offset > limit)\n\t\treturn -EINVAL;\n\n\tif (e->next_offset < sizeof(struct compat_ip6t_entry) +\n\t\t\t     sizeof(struct compat_xt_entry_target))\n\t\treturn -EINVAL;\n\n\tif (!ip6_checkentry(&e->ipv6))\n\t\treturn -EINVAL;\n\n\tret = xt_compat_check_entry_offsets(e, e->elems,\n\t\t\t\t\t    e->target_offset, e->next_offset);\n\tif (ret)\n\t\treturn ret;\n\n\toff = sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry);\n\tentry_offset = (void *)e - (void *)base;\n\tj = 0;\n\txt_ematch_foreach(ematch, e) {\n\t\tret = compat_find_calc_match(ematch, &e->ipv6, &off);\n\t\tif (ret != 0)\n\t\t\tgoto release_matches;\n\t\t++j;\n\t}\n\n\tt = compat_ip6t_get_target(e);\n\ttarget = xt_request_find_target(NFPROTO_IPV6, t->u.user.name,\n\t\t\t\t\tt->u.user.revision);\n\tif (IS_ERR(target)) {\n\t\tret = PTR_ERR(target);\n\t\tgoto release_matches;\n\t}\n\tt->u.kernel.target = target;\n\n\toff += xt_compat_target_offset(target);\n\t*size += off;\n\tret = xt_compat_add_offset(AF_INET6, entry_offset, off);\n\tif (ret)\n\t\tgoto out;\n\n\treturn 0;\n\nout:\n\tmodule_put(t->u.kernel.target->me);\nrelease_matches:\n\txt_ematch_foreach(ematch, e) {\n\t\tif (j-- == 0)\n\t\t\tbreak;\n\t\tmodule_put(ematch->u.kernel.match->me);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":369941,"func":"static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,\n\t\t\t\t      struct ipv6_devconf *devconf, u32 portid,\n\t\t\t\t      u32 seq, int event, unsigned int flags,\n\t\t\t\t      int type)\n{\n\tstruct nlmsghdr  *nlh;\n\tstruct netconfmsg *ncm;\n\n\tnlh = nlmsg_put(skb, portid, seq, event, sizeof(struct netconfmsg),\n\t\t\tflags);\n\tif (nlh == NULL)\n\t\treturn -EMSGSIZE;\n\n\tncm = nlmsg_data(nlh);\n\tncm->ncm_family = AF_INET6;\n\n\tif (nla_put_s32(skb, NETCONFA_IFINDEX, ifindex) < 0)\n\t\tgoto nla_put_failure;\n\n\t\/* type -1 is used for ALL *\/\n\tif ((type == -1 || type == NETCONFA_FORWARDING) &&\n\t    nla_put_s32(skb, NETCONFA_FORWARDING, devconf->forwarding) < 0)\n\t\tgoto nla_put_failure;\n#ifdef CONFIG_IPV6_MROUTE\n\tif ((type == -1 || type == NETCONFA_MC_FORWARDING) &&\n\t    nla_put_s32(skb, NETCONFA_MC_FORWARDING,\n\t\t\tdevconf->mc_forwarding) < 0)\n\t\tgoto nla_put_failure;\n#endif\n\treturn nlmsg_end(skb, nlh);\n\nnla_put_failure:\n\tnlmsg_cancel(skb, nlh);\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":444676,"func":"TEST_F(HttpConnectionManagerImplTest, RouteShouldUseNormalizedHost) {\n  setup(false, \"\");\n  \/\/ Enable port removal\n  strip_matching_port_ = true;\n  const std::string original_host = \"host:443\";\n  const std::string normalized_host = \"host\";\n\n  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> Http::Status {\n    RequestDecoder* decoder = &conn_manager_->newStream(response_encoder_);\n    RequestHeaderMapPtr headers{new TestRequestHeaderMapImpl{\n        {\":authority\", original_host}, {\":path\", \"\/\"}, {\":method\", \"GET\"}}};\n    decoder->decodeHeaders(std::move(headers), true);\n    return Http::okStatus();\n  }));\n\n  const std::string fake_cluster_name = \"fake_cluster\";\n\n  std::shared_ptr fake_cluster =\n      std::make_shared>();\n  std::shared_ptr route = std::make_shared>();\n  EXPECT_CALL(route->route_entry_, clusterName()).WillRepeatedly(ReturnRef(fake_cluster_name));\n\n  EXPECT_CALL(*route_config_provider_.route_config_, route(_, _, _, _))\n      .WillOnce(Invoke([&](const Router::RouteCallback&, const Http::RequestHeaderMap& header_map,\n                           const StreamInfo::StreamInfo&, uint64_t) {\n        EXPECT_EQ(normalized_host, header_map.getHostValue());\n        return route;\n      }));\n  EXPECT_CALL(filter_factory_, createFilterChain(_))\n      .WillOnce(Invoke([&](FilterChainFactoryCallbacks&) -> void {}));\n\n  \/\/ Kick off the incoming data.\n  Buffer::OwnedImpl fake_input(\"1234\");\n  conn_manager_->onData(fake_input, false);\n}","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":146673,"func":"static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx)\n{\n\tconst unsigned long *fields[] = {\n\t\tshadow_read_write_fields,\n\t\tshadow_read_only_fields\n\t};\n\tconst int max_fields[] = {\n\t\tmax_shadow_read_write_fields,\n\t\tmax_shadow_read_only_fields\n\t};\n\tint i, q;\n\tunsigned long field;\n\tu64 field_value = 0;\n\tstruct vmcs *shadow_vmcs = vmx->nested.current_shadow_vmcs;\n\n\tvmcs_load(shadow_vmcs);\n\n\tfor (q = 0; q < ARRAY_SIZE(fields); q++) {\n\t\tfor (i = 0; i < max_fields[q]; i++) {\n\t\t\tfield = fields[q][i];\n\t\t\tvmcs12_read_any(&vmx->vcpu, field, &field_value);\n\n\t\t\tswitch (vmcs_field_type(field)) {\n\t\t\tcase VMCS_FIELD_TYPE_U16:\n\t\t\t\tvmcs_write16(field, (u16)field_value);\n\t\t\t\tbreak;\n\t\t\tcase VMCS_FIELD_TYPE_U32:\n\t\t\t\tvmcs_write32(field, (u32)field_value);\n\t\t\t\tbreak;\n\t\t\tcase VMCS_FIELD_TYPE_U64:\n\t\t\t\tvmcs_write64(field, (u64)field_value);\n\t\t\t\tbreak;\n\t\t\tcase VMCS_FIELD_TYPE_NATURAL_WIDTH:\n\t\t\t\tvmcs_writel(field, (long)field_value);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tvmcs_clear(shadow_vmcs);\n\tvmcs_load(vmx->loaded_vmcs->vmcs);\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":142121,"func":"static int del_dac(struct task_struct *child, int slot)\n{\n\tif (slot == 1) {\n\t\tif ((dbcr_dac(child) & (DBCR_DAC1R | DBCR_DAC1W)) == 0)\n\t\t\treturn -ENOENT;\n\n\t\tchild->thread.debug.dac1 = 0;\n\t\tdbcr_dac(child) &= ~(DBCR_DAC1R | DBCR_DAC1W);\n#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE\n\t\tif (child->thread.debug.dbcr2 & DBCR2_DAC12MODE) {\n\t\t\tchild->thread.debug.dac2 = 0;\n\t\t\tchild->thread.debug.dbcr2 &= ~DBCR2_DAC12MODE;\n\t\t}\n\t\tchild->thread.debug.dbcr2 &= ~(DBCR2_DVC1M | DBCR2_DVC1BE);\n#endif\n#if CONFIG_PPC_ADV_DEBUG_DVCS > 0\n\t\tchild->thread.debug.dvc1 = 0;\n#endif\n\t} else if (slot == 2) {\n\t\tif ((dbcr_dac(child) & (DBCR_DAC2R | DBCR_DAC2W)) == 0)\n\t\t\treturn -ENOENT;\n\n#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE\n\t\tif (child->thread.debug.dbcr2 & DBCR2_DAC12MODE)\n\t\t\t\/* Part of a range *\/\n\t\t\treturn -EINVAL;\n\t\tchild->thread.debug.dbcr2 &= ~(DBCR2_DVC2M | DBCR2_DVC2BE);\n#endif\n#if CONFIG_PPC_ADV_DEBUG_DVCS > 0\n\t\tchild->thread.debug.dvc2 = 0;\n#endif\n\t\tchild->thread.debug.dac2 = 0;\n\t\tdbcr_dac(child) &= ~(DBCR_DAC2R | DBCR_DAC2W);\n\t} else\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":110612,"func":"static int ast_write_header(AVFormatContext *s)\n\n{\n\n    ASTMuxContext *ast = s->priv_data;\n\n    AVIOContext *pb = s->pb;\n\n    AVCodecContext *enc;\n\n    unsigned int codec_tag;\n\n\n\n    if (s->nb_streams == 1) {\n\n        enc = s->streams[0]->codec;\n\n    } else {\n\n        av_log(s, AV_LOG_ERROR, \"only one stream is supported\\n\");\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {\n\n        av_log(s, AV_LOG_ERROR, \"muxing ADPCM AFC is not implemented\\n\");\n\n        return AVERROR_PATCHWELCOME;\n\n    }\n\n\n\n    codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);\n\n    if (!codec_tag) {\n\n        av_log(s, AV_LOG_ERROR, \"unsupported codec\\n\");\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) {\n\n        av_log(s, AV_LOG_ERROR, \"loopend can't be less or equal to loopstart\\n\");\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    \/* Convert milliseconds to samples *\/\n\n    CHECK_LOOP(start)\n\n    CHECK_LOOP(end)\n\n\n\n    ffio_wfourcc(pb, \"STRM\");\n\n\n\n    ast->size = avio_tell(pb);\n\n    avio_wb32(pb, 0); \/* File size minus header *\/\n\n    avio_wb16(pb, codec_tag);\n\n    avio_wb16(pb, 16); \/* Bit depth *\/\n\n    avio_wb16(pb, enc->channels);\n\n    avio_wb16(pb, 0xFFFF);\n\n    avio_wb32(pb, enc->sample_rate);\n\n\n\n    ast->samples = avio_tell(pb);\n\n    avio_wb32(pb, 0); \/* Number of samples *\/\n\n    avio_wb32(pb, 0); \/* Loopstart *\/\n\n    avio_wb32(pb, 0); \/* Loopend *\/\n\n    avio_wb32(pb, 0); \/* Size of first block *\/\n\n\n\n    \/* Unknown *\/\n\n    avio_wb32(pb, 0);\n\n    avio_wl32(pb, 0x7F);\n\n    avio_wb64(pb, 0);\n\n    avio_wb64(pb, 0);\n\n    avio_wb32(pb, 0);\n\n\n\n    avio_flush(pb);\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":135447,"func":"static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)\n{\n\tint ret = -ENOPROTOOPT;\n#ifdef CONFIG_NETDEVICES\n\tstruct net *net = sock_net(sk);\n\tchar devname[IFNAMSIZ];\n\tint index;\n\n\t\/* Sorry... *\/\n\tret = -EPERM;\n\tif (!capable(CAP_NET_RAW))\n\t\tgoto out;\n\n\tret = -EINVAL;\n\tif (optlen < 0)\n\t\tgoto out;\n\n\t\/* Bind this socket to a particular device like \"eth0\",\n\t * as specified in the passed interface name. If the\n\t * name is \"\" or the option length is zero the socket\n\t * is not bound.\n\t *\/\n\tif (optlen > IFNAMSIZ - 1)\n\t\toptlen = IFNAMSIZ - 1;\n\tmemset(devname, 0, sizeof(devname));\n\n\tret = -EFAULT;\n\tif (copy_from_user(devname, optval, optlen))\n\t\tgoto out;\n\n\tindex = 0;\n\tif (devname[0] != '\\0') {\n\t\tstruct net_device *dev;\n\n\t\trcu_read_lock();\n\t\tdev = dev_get_by_name_rcu(net, devname);\n\t\tif (dev)\n\t\t\tindex = dev->ifindex;\n\t\trcu_read_unlock();\n\t\tret = -ENODEV;\n\t\tif (!dev)\n\t\t\tgoto out;\n\t}\n\n\tlock_sock(sk);\n\tsk->sk_bound_dev_if = index;\n\tsk_dst_reset(sk);\n\trelease_sock(sk);\n\n\tret = 0;\n\nout:\n#endif\n\n\treturn ret;\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":315208,"func":"gfx::Rect OverlayWindowViews::CalculateAndUpdateWindowBounds() {\n  gfx::Rect work_area =\n      display::Screen::GetScreen()\n          ->GetDisplayNearestWindow(\n              controller_->GetInitiatorWebContents()->GetTopLevelNativeWindow())\n          .work_area();\n\n  max_size_ = gfx::Size(work_area.width() \/ 2, work_area.height() \/ 2);\n\n  min_size_ = kMinWindowSize;\n\n  gfx::Size window_size = window_bounds_.size();\n  if (!has_been_shown_) {\n    window_size = gfx::Size(work_area.width() \/ 5, work_area.height() \/ 5);\n    window_size.set_width(std::min(\n        max_size_.width(), std::max(min_size_.width(), window_size.width())));\n    window_size.set_height(\n        std::min(max_size_.height(),\n                 std::max(min_size_.height(), window_size.height())));\n  }\n\n  if (!window_size.IsEmpty() && !natural_size_.IsEmpty()) {\n    float aspect_ratio = (float)natural_size_.width() \/ natural_size_.height();\n\n    gfx::Rect window_rect(GetBounds().origin(), window_size);\n    views::WindowResizeUtils::SizeRectToAspectRatio(\n        views::HitTest::kBottomRight, aspect_ratio, min_size_, max_size_,\n        &window_rect);\n    window_size.SetSize(window_rect.width(), window_rect.height());\n\n    UpdateLayerBoundsWithLetterboxing(window_size);\n  }\n\n  gfx::Point origin = window_bounds_.origin();\n\n  int window_diff_width = work_area.right() - window_size.width();\n  int window_diff_height = work_area.bottom() - window_size.height();\n\n  int buffer = (window_diff_width + window_diff_height) \/ 2 * 0.02;\n\n  gfx::Point default_origin =\n      gfx::Point(window_diff_width - buffer, window_diff_height - buffer);\n\n  if (has_been_shown_) {\n    origin.SetToMin(default_origin);\n  } else {\n    origin = default_origin;\n  }\n\n  window_bounds_ = gfx::Rect(origin, window_size);\n  return window_bounds_;\n}\n","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":372803,"func":"parse_auto_key_locate (char *options)\n{\n  char *tok;\n\n  while ((tok = optsep (&options)))\n    {\n      struct akl *akl, *check, *last = NULL;\n      int dupe = 0;\n\n      if (tok[0] == '\\0')\n\tcontinue;\n\n      akl = xmalloc_clear (sizeof (*akl));\n\n      if (ascii_strcasecmp (tok, \"nodefault\") == 0)\n\takl->type = AKL_NODEFAULT;\n      else if (ascii_strcasecmp (tok, \"local\") == 0)\n\takl->type = AKL_LOCAL;\n      else if (ascii_strcasecmp (tok, \"ldap\") == 0)\n\takl->type = AKL_LDAP;\n      else if (ascii_strcasecmp (tok, \"keyserver\") == 0)\n\takl->type = AKL_KEYSERVER;\n#ifdef USE_DNS_CERT\n      else if (ascii_strcasecmp (tok, \"cert\") == 0)\n\takl->type = AKL_CERT;\n#endif\n#ifdef USE_DNS_PKA\n      else if (ascii_strcasecmp (tok, \"pka\") == 0)\n\takl->type = AKL_PKA;\n#endif\n      else if ((akl->spec = parse_keyserver_uri (tok, 1, NULL, 0)))\n\takl->type = AKL_SPEC;\n      else\n\t{\n\t  free_akl (akl);\n\t  return 0;\n\t}\n\n      \/* We must maintain the order the user gave us *\/\n      for (check = opt.auto_key_locate; check;\n\t   last = check, check = check->next)\n\t{\n\t  \/* Check for duplicates *\/\n\t  if (check->type == akl->type\n\t      && (akl->type != AKL_SPEC\n\t\t  || (akl->type == AKL_SPEC\n\t\t      && strcmp (check->spec->uri, akl->spec->uri) == 0)))\n\t    {\n\t      dupe = 1;\n\t      free_akl (akl);\n\t      break;\n\t    }\n\t}\n\n      if (!dupe)\n\t{\n\t  if (last)\n\t    last->next = akl;\n\t  else\n\t    opt.auto_key_locate = akl;\n\t}\n    }\n\n  return 1;\n}","target":0,"code_token_length":486,"total_token_length":722,"max_tokens_setting":1024}
+{"idx":135088,"func":"const Model* ModelBuilder::BuildModel(\n    std::initializer_list inputs,\n    std::initializer_list outputs,\n    size_t num_subgraph_inputs) {\n  \/\/ Model schema requires an empty buffer at idx 0.\n  size_t buffer_size = 1 + ModelBuilder::nbr_of_metadata_buffers_;\n  flatbuffers::Offset buffers[kMaxMetadataBuffers];\n  buffers[0] = tflite::CreateBuffer(*builder_);\n\n  \/\/ Place the metadata buffers first in the buffer since the indices for them\n  \/\/ have already been set in AddMetadata()\n  for (int i = 1; i < ModelBuilder::nbr_of_metadata_buffers_ + 1; ++i) {\n    buffers[i] = metadata_buffers_[i - 1];\n  }\n\n  \/\/ TFLM only supports single subgraph.\n  constexpr size_t subgraphs_size = 1;\n\n  \/\/ Find out number of subgraph inputs.\n  if (num_subgraph_inputs == 0) {\n    \/\/ This is the default case.\n    num_subgraph_inputs = inputs.size();\n  } else {\n    \/\/ A non-zero value of num_subgraph_inputs means that some of\n    \/\/ the operator input tensors are not subgraph inputs.\n    TFLITE_DCHECK(num_subgraph_inputs < inputs.size());\n  }\n\n  const flatbuffers::Offset subgraphs[subgraphs_size] = {\n      tflite::CreateSubGraph(\n          *builder_, builder_->CreateVector(tensors_, next_tensor_id_),\n          builder_->CreateVector(inputs.begin(), num_subgraph_inputs),\n          builder_->CreateVector(outputs.begin(), outputs.size()),\n          builder_->CreateVector(operators_, next_operator_id_),\n          builder_->CreateString(\"test_subgraph\"))};\n\n  flatbuffers::Offset model_offset;\n  if (ModelBuilder::nbr_of_metadata_buffers_ > 0) {\n    model_offset = tflite::CreateModel(\n        *builder_, 0,\n        builder_->CreateVector(operator_codes_, next_operator_code_id_),\n        builder_->CreateVector(subgraphs, subgraphs_size),\n        builder_->CreateString(\"teset_model\"),\n        builder_->CreateVector(buffers, buffer_size), 0,\n        builder_->CreateVector(metadata_,\n                               ModelBuilder::nbr_of_metadata_buffers_));\n  } else {\n    model_offset = tflite::CreateModel(\n        *builder_, 0,\n        builder_->CreateVector(operator_codes_, next_operator_code_id_),\n        builder_->CreateVector(subgraphs, subgraphs_size),\n        builder_->CreateString(\"teset_model\"),\n        builder_->CreateVector(buffers, buffer_size));\n  }\n\n  tflite::FinishModelBuffer(*builder_, model_offset);\n  void* model_pointer = builder_->GetBufferPointer();\n  const Model* model = flatbuffers::GetRoot(model_pointer);\n  return model;\n}","target":0,"code_token_length":597,"total_token_length":833,"max_tokens_setting":1024}
+{"idx":31548,"func":"static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con,\n\t\t\t\t   struct rtrs_clt_io_req *req,\n\t\t\t\t   struct rtrs_rbuf *rbuf, bool fr_en,\n\t\t\t\t   u32 size, u32 imm, struct ib_send_wr *wr,\n\t\t\t\t   struct ib_send_wr *tail)\n{\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\tstruct ib_sge *sge = req->sge;\n\tenum ib_send_flags flags;\n\tstruct scatterlist *sg;\n\tsize_t num_sge;\n\tint i;\n\tstruct ib_send_wr *ptail = NULL;\n\n\tif (fr_en) {\n\t\ti = 0;\n\t\tsge[i].addr   = req->mr->iova;\n\t\tsge[i].length = req->mr->length;\n\t\tsge[i].lkey   = req->mr->lkey;\n\t\ti++;\n\t\tnum_sge = 2;\n\t\tptail = tail;\n\t} else {\n\t\tfor_each_sg(req->sglist, sg, req->sg_cnt, i) {\n\t\t\tsge[i].addr   = sg_dma_address(sg);\n\t\t\tsge[i].length = sg_dma_len(sg);\n\t\t\tsge[i].lkey   = clt_path->s.dev->ib_pd->local_dma_lkey;\n\t\t}\n\t\tnum_sge = 1 + req->sg_cnt;\n\t}\n\tsge[i].addr   = req->iu->dma_addr;\n\tsge[i].length = size;\n\tsge[i].lkey   = clt_path->s.dev->ib_pd->local_dma_lkey;\n\n\t\/*\n\t * From time to time we have to post signalled sends,\n\t * or send queue will fill up and only QP reset can help.\n\t *\/\n\tflags = atomic_inc_return(&con->c.wr_cnt) % clt_path->s.signal_interval ?\n\t\t\t0 : IB_SEND_SIGNALED;\n\n\tib_dma_sync_single_for_device(clt_path->s.dev->ib_dev,\n\t\t\t\t      req->iu->dma_addr,\n\t\t\t\t      size, DMA_TO_DEVICE);\n\n\treturn rtrs_iu_post_rdma_write_imm(&con->c, req->iu, sge, num_sge,\n\t\t\t\t\t    rbuf->rkey, rbuf->addr, imm,\n\t\t\t\t\t    flags, wr, ptail);\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":45060,"func":"error_t webSocketFormatErrorResponse(WebSocket *webSocket,\n   uint_t statusCode, const char_t *message)\n{\n   uint_t i;\n   size_t length;\n   char_t *p;\n   WebSocketFrameContext *txContext;\n\n   \/\/HTML response template\n   static const char_t template[] =\n      \"\\r\\n\"\n      \"\\r\\n\"\n      \"Error %03d<\/title><\/head>\\r\\n\"\n      \"<body>\\r\\n\"\n      \"<h2>Error %03d<\/h2>\\r\\n\"\n      \"<p>%s<\/p>\\r\\n\"\n      \"<\/body>\\r\\n\"\n      \"<\/html>\\r\\n\";\n\n   \/\/Point to the TX context\n   txContext = &webSocket->txContext;\n   \/\/Point to the buffer where to format the client's handshake\n   p = (char_t *) txContext->buffer;\n\n   \/\/The first line of a response message is the Status-Line, consisting\n   \/\/of the protocol version followed by a numeric status code and its\n   \/\/associated textual phrase\n   p += osSprintf(p, \"HTTP\/%u.%u %u \", MSB(webSocket->handshakeContext.version),\n      LSB(webSocket->handshakeContext.version), statusCode);\n\n   \/\/Retrieve the Reason-Phrase that corresponds to the Status-Code\n   for(i = 0; i < arraysize(statusCodeList); i++)\n   {\n      \/\/Check the status code\n      if(statusCodeList[i].value == statusCode)\n      {\n         \/\/Append the textual phrase to the Status-Line\n         p += osSprintf(p, statusCodeList[i].message);\n         \/\/Break the loop and continue processing\n         break;\n      }\n   }\n\n   \/\/Properly terminate the Status-Line\n   p += osSprintf(p, \"\\r\\n\");\n\n   \/\/Content type\n   p += osSprintf(p, \"Content-Type: %s\\r\\n\", \"text\/html\");\n\n   \/\/Compute the length of the response\n   length = osStrlen(template) + osStrlen(message) - 4;\n   \/\/Set Content-Length field\n   p += osSprintf(p, \"Content-Length: %\" PRIuSIZE \"\\r\\n\", length);\n\n   \/\/Terminate the header with an empty line\n   p += osSprintf(p, \"\\r\\n\");\n\n   \/\/Format HTML response\n   p += osSprintf(p, template, statusCode, statusCode, message);\n\n   \/\/Rewind to the beginning of the buffer\n   txContext->bufferPos = 0;\n   \/\/Update the number of data buffered but not yet sent\n   txContext->bufferLen = osStrlen((char_t *) txContext->buffer);\n\n   \/\/Successful processing\n   return NO_ERROR;\n}","target":0,"code_token_length":572,"total_token_length":808,"max_tokens_setting":1024}
+{"idx":176072,"func":"CheckUserAuthorization(void)\n{\n#ifdef USE_PAM\n    static struct pam_conv conv = {\n\tmisc_conv,\n\tNULL\n    };\n\n    pam_handle_t *pamh = NULL;\n    struct passwd *pw;\n    int retval;\n\n    if (getuid() != geteuid()) {\n\tpw = getpwuid(getuid());\n\tif (pw == NULL)\n\t    FatalError(\"getpwuid() failed for uid %d\\n\", getuid());\n\n\tretval = pam_start(\"xserver\", pw->pw_name, &conv, &pamh);\n\tif (retval != PAM_SUCCESS)\n\t    FatalError(\"pam_start() failed.\\n\"\n\t\t\t\"\\tMissing or mangled PAM config file or module?\\n\");\n\n\tretval = pam_authenticate(pamh, 0);\n\tif (retval != PAM_SUCCESS) {\n\t    pam_end(pamh, retval);\n\t    FatalError(\"PAM authentication failed, cannot start X server.\\n\"\n\t\t\t\"\\tPerhaps you do not have console ownership?\\n\");\n\t}\n\n\tretval = pam_acct_mgmt(pamh, 0);\n\tif (retval != PAM_SUCCESS) {\n\t    pam_end(pamh, retval);\n\t    FatalError(\"PAM authentication failed, cannot start X server.\\n\"\n\t\t\t\"\\tPerhaps you do not have console ownership?\\n\");\n\t}\n\n\t\/* this is not a session, so do not do session management *\/\n\tpam_end(pamh, PAM_SUCCESS);\n    }\n#endif\n}\n","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":381555,"func":"HttpTransact::HandleResponse(State* s)\n{\n  DebugTxn(\"http_trans\", \"[HttpTransact::HandleResponse]\");\n  DebugTxn(\"http_seq\", \"[HttpTransact::HandleResponse] Response received\");\n\n  s->source = SOURCE_HTTP_ORIGIN_SERVER;\n  s->response_received_time = ink_cluster_time();\n  ink_assert(s->response_received_time >= s->request_sent_time);\n  s->current.now = s->response_received_time;\n\n  DebugTxn(\"http_trans\", \"[HandleResponse] response_received_time: %\" PRId64, (int64_t)s->response_received_time);\n  if (!s->cop_test_page)\n    DUMP_HEADER(\"http_hdrs\", &s->hdr_info.server_response, s->state_machine_id, \"Incoming O.S. Response\");\n\n  HTTP_INCREMENT_TRANS_STAT(http_incoming_responses_stat);\n\n  ink_release_assert(s->current.request_to != UNDEFINED_LOOKUP);\n  if (s->cache_info.action != CACHE_DO_WRITE) {\n    ink_release_assert(s->cache_info.action != CACHE_DO_LOOKUP);\n    ink_release_assert(s->cache_info.action != CACHE_DO_SERVE);\n    ink_release_assert(s->cache_info.action != CACHE_PREPARE_TO_DELETE);\n    ink_release_assert(s->cache_info.action != CACHE_PREPARE_TO_UPDATE);\n    ink_release_assert(s->cache_info.action != CACHE_PREPARE_TO_WRITE);\n  }\n\n  if (!is_response_valid(s, &s->hdr_info.server_response)) {\n    DebugTxn(\"http_seq\", \"[HttpTransact::HandleResponse] Response not valid\");\n  } else {\n    DebugTxn(\"http_seq\", \"[HttpTransact::HandleResponse] Response valid\");\n    initialize_state_variables_from_response(s, &s->hdr_info.server_response);\n  }\n\n  switch (s->current.request_to) {\n  case ICP_SUGGESTED_HOST:\n    handle_response_from_icp_suggested_host(s);\n    break;\n  case PARENT_PROXY:\n    handle_response_from_parent(s);\n    break;\n  case ORIGIN_SERVER:\n    handle_response_from_server(s);\n    break;\n  default:\n    ink_assert(!(\"s->current.request_to is not ICP, P.P. or O.S. - hmmm.\"));\n    break;\n  }\n\n  return;\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":513825,"func":"napi_status napi_get_all_property_names(napi_env env,\n                                        napi_value object,\n                                        napi_key_collection_mode key_mode,\n                                        napi_key_filter key_filter,\n                                        napi_key_conversion key_conversion,\n                                        napi_value* result) {\n  NAPI_PREAMBLE(env);\n  CHECK_ARG(env, result);\n\n  v8::Local<v8::Context> context = env->context();\n  v8::Local<v8::Object> obj;\n  CHECK_TO_OBJECT(env, context, obj, object);\n\n  v8::PropertyFilter filter = v8::PropertyFilter::ALL_PROPERTIES;\n  if (key_filter & napi_key_writable) {\n    filter =\n        static_cast<v8::PropertyFilter>(filter |\n                                        v8::PropertyFilter::ONLY_WRITABLE);\n  }\n  if (key_filter & napi_key_enumerable) {\n    filter =\n        static_cast<v8::PropertyFilter>(filter |\n                                        v8::PropertyFilter::ONLY_ENUMERABLE);\n  }\n  if (key_filter & napi_key_configurable) {\n    filter =\n        static_cast<v8::PropertyFilter>(filter |\n                                        v8::PropertyFilter::ONLY_WRITABLE);\n  }\n  if (key_filter & napi_key_skip_strings) {\n    filter =\n        static_cast<v8::PropertyFilter>(filter |\n                                        v8::PropertyFilter::SKIP_STRINGS);\n  }\n  if (key_filter & napi_key_skip_symbols) {\n    filter =\n        static_cast<v8::PropertyFilter>(filter |\n                                        v8::PropertyFilter::SKIP_SYMBOLS);\n  }\n  v8::KeyCollectionMode collection_mode;\n  v8::KeyConversionMode conversion_mode;\n\n  switch (key_mode) {\n    case napi_key_include_prototypes:\n      collection_mode = v8::KeyCollectionMode::kIncludePrototypes;\n      break;\n    case napi_key_own_only:\n      collection_mode = v8::KeyCollectionMode::kOwnOnly;\n      break;\n    default:\n      return napi_set_last_error(env, napi_invalid_arg);\n  }\n\n  switch (key_conversion) {\n    case napi_key_keep_numbers:\n      conversion_mode = v8::KeyConversionMode::kKeepNumbers;\n      break;\n    case napi_key_numbers_to_strings:\n      conversion_mode = v8::KeyConversionMode::kConvertToString;\n      break;\n    default:\n      return napi_set_last_error(env, napi_invalid_arg);\n  }\n\n  v8::MaybeLocal<v8::Array> maybe_all_propertynames =\n      obj->GetPropertyNames(context,\n                            collection_mode,\n                            filter,\n                            v8::IndexFilter::kIncludeIndices,\n                            conversion_mode);\n\n  CHECK_MAYBE_EMPTY_WITH_PREAMBLE(\n      env, maybe_all_propertynames, napi_generic_failure);\n\n  *result =\n      v8impl::JsValueFromV8LocalValue(maybe_all_propertynames.ToLocalChecked());\n  return GET_RETURN_STATUS(env);\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":173257,"func":"bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const\n{\n    if (!layoutObject())\n        return false;\n\n    LayoutObject* o = layoutObject();\n    if (!o->isInline() || o->isReplaced()) {\n        point = o->localToAbsolute(FloatPoint(), UseTransforms);\n        return true;\n    }\n\n    while (o) {\n        LayoutObject* p = o;\n        if (LayoutObject* oFirstChild = o->slowFirstChild()) {\n            o = oFirstChild;\n        } else if (o->nextSibling()) {\n            o = o->nextSibling();\n        } else {\n            LayoutObject* next = nullptr;\n            while (!next && o->parent()) {\n                o = o->parent();\n                next = o->nextSibling();\n            }\n            o = next;\n\n            if (!o)\n                break;\n        }\n        ASSERT(o);\n\n        if (!o->isInline() || o->isReplaced()) {\n            point = o->localToAbsolute(FloatPoint(), UseTransforms);\n            return true;\n        }\n\n        if (p->node() && p->node() == this && o->isText() && !o->isBR() && !toLayoutText(o)->hasTextBoxes()) {\n        } else if ((o->isText() && !o->isBR()) || o->isReplaced()) {\n            point = FloatPoint();\n            if (o->isText() && toLayoutText(o)->firstTextBox()) {\n                point.move(toLayoutText(o)->linesBoundingBox().x(), toLayoutText(o)->firstTextBox()->root().lineTop().toFloat());\n                point = o->localToAbsolute(point, UseTransforms);\n            } else if (o->isBox()) {\n                LayoutBox* box = toLayoutBox(o);\n                point.moveBy(box->location());\n                point = o->container()->localToAbsolute(point, UseTransforms);\n            }\n            return true;\n        }\n    }\n\n    if (!o && document().view()) {\n        point = FloatPoint(0, document().view()->contentsHeight());\n        return true;\n    }\n    return false;\n}\n","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":127944,"func":"process_brushcache(STREAM s, uint16 flags)\n{\n\tUNUSED(flags);\n\tBRUSHDATA brush_data;\n\tuint8 cache_idx, colour_code, width, height, size, type;\n\tuint8 *comp_brush;\n\tint index;\n\tint Bpp;\n\n\tin_uint8(s, cache_idx);\n\tin_uint8(s, colour_code);\n\tin_uint8(s, width);\n\tin_uint8(s, height);\n\tin_uint8(s, type);\t\/* type, 0x8x = cached *\/\n\tin_uint8(s, size);\n\n\tlogger(Graphics, Debug, \"process_brushcache(), idx=%d, wd=%d, ht=%d, type=0x%x sz=%d\",\n\t       cache_idx, width, height, type, size);\n\n\tif ((width == 8) && (height == 8))\n\t{\n\t\tif (colour_code == 1)\n\t\t{\n\t\t\tbrush_data.colour_code = 1;\n\t\t\tbrush_data.data_size = 8;\n\t\t\tbrush_data.data = xmalloc(8);\n\t\t\tif (size == 8)\n\t\t\t{\n\t\t\t\t\/* read it bottom up *\/\n\t\t\t\tfor (index = 7; index >= 0; index--)\n\t\t\t\t{\n\t\t\t\t\tin_uint8(s, brush_data.data[index]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tlogger(Graphics, Warning,\n\t\t\t\t       \"process_brushcache(), incompatible brush, colour_code %d size %d\",\n\t\t\t\t       colour_code, size);\n\t\t\t}\n\t\t\tcache_put_brush_data(1, cache_idx, &brush_data);\n\t\t}\n\t\telse if ((colour_code >= 3) && (colour_code <= 6))\n\t\t{\n\t\t\tBpp = colour_code - 2;\n\t\t\tbrush_data.colour_code = colour_code;\n\t\t\tbrush_data.data_size = 8 * 8 * Bpp;\n\t\t\tbrush_data.data = xmalloc(8 * 8 * Bpp);\n\t\t\tif (size == 16 + 4 * Bpp)\n\t\t\t{\n\t\t\t\tin_uint8p(s, comp_brush, 16 + 4 * Bpp);\n\t\t\t\tprocess_compressed_8x8_brush_data(comp_brush, brush_data.data, Bpp);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tin_uint8a(s, brush_data.data, 8 * 8 * Bpp);\n\t\t\t}\n\t\t\tcache_put_brush_data(colour_code, cache_idx, &brush_data);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlogger(Graphics, Warning,\n\t\t\t       \"process_brushcache(), incompatible brush, colour_code %d size %d\",\n\t\t\t       colour_code, size);\n\t\t}\n\t}\n\telse\n\t{\n\t\tlogger(Graphics, Warning,\n\t\t       \"process_brushcache(), incompatible brush, width height %d %d\", width,\n\t\t       height);\n\t}\n}","target":0,"code_token_length":591,"total_token_length":827,"max_tokens_setting":1024}
+{"idx":274999,"func":"cockpit_auth_steal_authorization (GHashTable *headers,\n                                  GIOStream *connection,\n                                  gchar **ret_type,\n                                  gchar **ret_conversation)\n{\n  char *type = NULL;\n  gchar *ret = NULL;\n  gchar *line;\n  gpointer key;\n\n  g_assert (headers != NULL);\n  g_assert (ret_conversation != NULL);\n  g_assert (ret_type != NULL);\n\n  \/* Avoid copying as it can contain passwords *\/\n  if (g_hash_table_lookup_extended (headers, \"Authorization\", &key, (gpointer *)&line))\n    {\n      g_hash_table_steal (headers, \"Authorization\");\n      g_free (key);\n    }\n  else\n    {\n      \/*\n       * If we don't yet know that Negotiate authentication is possible\n       * or not, then we ask our session to try to do Negotiate auth\n       * but without any input data.\n       *\/\n      if (gssapi_available != 0)\n        line = g_strdup (\"Negotiate\");\n      else\n        return NULL;\n    }\n\n  \/* Dig out the authorization type *\/\n  if (!cockpit_authorize_type (line, &type))\n    goto out;\n\n  \/* If this is a conversation, get that part out too *\/\n  if (g_str_equal (type, \"x-conversation\"))\n    {\n      if (!cockpit_authorize_subject (line, ret_conversation))\n        goto out;\n    }\n\n  \/*\n   * So for negotiate authentication, conversation happens on a\n   * single connection. Yes that's right, GSSAPI, NTLM, and all\n   * those nice mechanisms are keep-alive based, not HTTP request based.\n   *\/\n  else if (g_str_equal (type, \"negotiate\"))\n    {\n      \/* Resume an already running conversation? *\/\n      if (ret_conversation && connection)\n        *ret_conversation = g_strdup (g_object_get_data (G_OBJECT (connection), type));\n    }\n\n\n  if (ret_type)\n    {\n      *ret_type = type;\n      type = NULL;\n    }\n\n  ret = line;\n  line = NULL;\n\nout:\n  g_free (line);\n  g_free (type);\n  return ret;\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":328478,"func":"static void xenfb_guest_copy(struct XenFB *xenfb, int x, int y, int w, int h)\n\n{\n\n    DisplaySurface *surface = qemu_console_surface(xenfb->c.con);\n\n    int line, oops = 0;\n\n    int bpp = surface_bits_per_pixel(surface);\n\n    int linesize = surface_stride(surface);\n\n    uint8_t *data = surface_data(surface);\n\n\n\n    if (!is_buffer_shared(surface)) {\n\n        switch (xenfb->depth) {\n\n        case 8:\n\n            if (bpp == 16) {\n\n                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);\n\n            } else if (bpp == 32) {\n\n                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);\n\n            } else {\n\n                oops = 1;\n\n            }\n\n            break;\n\n        case 24:\n\n            if (bpp == 16) {\n\n                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);\n\n            } else if (bpp == 32) {\n\n                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);\n\n            } else {\n\n                oops = 1;\n\n            }\n\n            break;\n\n        default:\n\n            oops = 1;\n\n\t}\n\n    }\n\n    if (oops) \/* should not happen *\/\n\n        xen_pv_printf(&xenfb->c.xendev, 0, \"%s: oops: convert %d -> %d bpp?\\n\",\n\n                      __FUNCTION__, xenfb->depth, bpp);\n\n\n\n    dpy_gfx_update(xenfb->c.con, x, y, w, h);\n\n}\n","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":446500,"func":"virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,\n                                          virDomainHostdevSubsysSCSIPtr scsisrc)\n{\n    bool got_address = false, got_adapter = false;\n    xmlNodePtr cur;\n    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;\n    g_autofree char *bus = NULL;\n    g_autofree char *target = NULL;\n    g_autofree char *unit = NULL;\n\n    cur = sourcenode->children;\n    while (cur != NULL) {\n        if (cur->type == XML_ELEMENT_NODE) {\n            if (virXMLNodeNameEqual(cur, \"address\")) {\n                if (got_address) {\n                    virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                                   _(\"more than one source addresses is \"\n                                     \"specified for scsi hostdev\"));\n                    return -1;\n                }\n\n                if (!(bus = virXMLPropString(cur, \"bus\")) ||\n                    !(target = virXMLPropString(cur, \"target\")) ||\n                    !(unit = virXMLPropString(cur, \"unit\"))) {\n                    virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                                   _(\"'bus', 'target', and 'unit' must be specified \"\n                                     \"for scsi hostdev source address\"));\n                    return -1;\n                }\n\n                if (virStrToLong_uip(bus, NULL, 0, &scsihostsrc->bus) < 0) {\n                    virReportError(VIR_ERR_INTERNAL_ERROR,\n                                   _(\"cannot parse bus '%s'\"), bus);\n                    return -1;\n                }\n\n                if (virStrToLong_uip(target, NULL, 0,\n                                    &scsihostsrc->target) < 0) {\n                    virReportError(VIR_ERR_INTERNAL_ERROR,\n                                   _(\"cannot parse target '%s'\"), target);\n                    return -1;\n                }\n\n                if (virStrToLong_ullp(unit, NULL, 0, &scsihostsrc->unit) < 0) {\n                    virReportError(VIR_ERR_INTERNAL_ERROR,\n                                   _(\"cannot parse unit '%s'\"), unit);\n                    return -1;\n                }\n\n                got_address = true;\n            } else if (virXMLNodeNameEqual(cur, \"adapter\")) {\n                if (got_adapter) {\n                    virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                                   _(\"more than one adapters is specified \"\n                                     \"for scsi hostdev source\"));\n                    return -1;\n                }\n                if (!(scsihostsrc->adapter = virXMLPropString(cur, \"name\"))) {\n                    virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                                   _(\"'adapter' must be specified for scsi hostdev source\"));\n                    return -1;\n                }\n\n                got_adapter = true;\n            } else {\n                virReportError(VIR_ERR_XML_ERROR,\n                               _(\"unsupported element '%s' of scsi hostdev source\"),\n                               cur->name);\n                return -1;\n            }\n        }\n        cur = cur->next;\n    }\n\n    if (!got_address || !got_adapter) {\n        virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                       _(\"'adapter' and 'address' must be specified for scsi \"\n                         \"hostdev source\"));\n        return -1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":698,"total_token_length":934,"max_tokens_setting":1024}
+{"idx":77718,"func":"load_inst(UnpicklerObject *self)\n{\n    PyObject *cls = NULL;\n    PyObject *args = NULL;\n    PyObject *obj = NULL;\n    PyObject *module_name;\n    PyObject *class_name;\n    Py_ssize_t len;\n    Py_ssize_t i;\n    char *s;\n\n    if ((i = marker(self)) < 0)\n        return -1;\n    if ((len = _Unpickler_Readline(self, &s)) < 0)\n        return -1;\n    if (len < 2)\n        return bad_readline();\n\n    \/* Here it is safe to use PyUnicode_DecodeASCII(), even though non-ASCII\n       identifiers are permitted in Python 3.0, since the INST opcode is only\n       supported by older protocols on Python 2.x. *\/\n    module_name = PyUnicode_DecodeASCII(s, len - 1, \"strict\");\n    if (module_name == NULL)\n        return -1;\n\n    if ((len = _Unpickler_Readline(self, &s)) >= 0) {\n        if (len < 2) {\n            Py_DECREF(module_name);\n            return bad_readline();\n        }\n        class_name = PyUnicode_DecodeASCII(s, len - 1, \"strict\");\n        if (class_name != NULL) {\n            cls = find_class(self, module_name, class_name);\n            Py_DECREF(class_name);\n        }\n    }\n    Py_DECREF(module_name);\n\n    if (cls == NULL)\n        return -1;\n\n    if ((args = Pdata_poptuple(self->stack, i)) != NULL) {\n        obj = instantiate(cls, args);\n        Py_DECREF(args);\n    }\n    Py_DECREF(cls);\n\n    if (obj == NULL)\n        return -1;\n\n    PDATA_PUSH(self->stack, obj, -1);\n    return 0;\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":346999,"func":"radix__arch_get_unmapped_area_topdown(struct file *filp,\n\t\t\t\t     const unsigned long addr0,\n\t\t\t\t     const unsigned long len,\n\t\t\t\t     const unsigned long pgoff,\n\t\t\t\t     const unsigned long flags)\n{\n\tstruct vm_area_struct *vma;\n\tstruct mm_struct *mm = current->mm;\n\tunsigned long addr = addr0;\n\tstruct vm_unmapped_area_info info;\n\n\tif (unlikely(addr > mm->context.addr_limit &&\n\t\t     mm->context.addr_limit != TASK_SIZE))\n\t\tmm->context.addr_limit = TASK_SIZE;\n\n\t\/* requested length too big for entire address space *\/\n\tif (len > mm->task_size - mmap_min_addr)\n\t\treturn -ENOMEM;\n\n\tif (flags & MAP_FIXED)\n\t\treturn addr;\n\n\t\/* requesting a specific address *\/\n\tif (addr) {\n\t\taddr = PAGE_ALIGN(addr);\n\t\tvma = find_vma(mm, addr);\n\t\tif (mm->task_size - len >= addr && addr >= mmap_min_addr &&\n\t\t\t\t(!vma || addr + len <= vma->vm_start))\n\t\t\treturn addr;\n\t}\n\n\tinfo.flags = VM_UNMAPPED_AREA_TOPDOWN;\n\tinfo.length = len;\n\tinfo.low_limit = max(PAGE_SIZE, mmap_min_addr);\n\tinfo.high_limit = mm->mmap_base;\n\tinfo.align_mask = 0;\n\n\tif (addr > DEFAULT_MAP_WINDOW)\n\t\tinfo.high_limit += mm->context.addr_limit - DEFAULT_MAP_WINDOW;\n\n\taddr = vm_unmapped_area(&info);\n\tif (!(addr & ~PAGE_MASK))\n\t\treturn addr;\n\tVM_BUG_ON(addr != -ENOMEM);\n\n\t\/*\n\t * A failed mmap() very likely causes application failure,\n\t * so fall back to the bottom-up function here. This scenario\n\t * can happen with large stack limits and large mmap()\n\t * allocations.\n\t *\/\n\treturn radix__arch_get_unmapped_area(filp, addr0, len, pgoff, flags);\n}","target":1,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":338302,"func":"static int do_sendv_recvv(int sockfd, struct iovec *iov, int len, int offset,\n\n                          int do_sendv)\n\n{\n\n    int ret, diff, iovlen;\n\n    struct iovec *last_iov;\n\n\n\n    \/* last_iov is inclusive, so count from one.  *\/\n\n    iovlen = 1;\n\n    last_iov = iov;\n\n    len += offset;\n\n\n\n    while (last_iov->iov_len < len) {\n\n        len -= last_iov->iov_len;\n\n\n\n        last_iov++;\n\n        iovlen++;\n\n    }\n\n\n\n    diff = last_iov->iov_len - len;\n\n    last_iov->iov_len -= diff;\n\n\n\n    while (iov->iov_len <= offset) {\n\n        offset -= iov->iov_len;\n\n\n\n        iov++;\n\n        iovlen--;\n\n    }\n\n\n\n    iov->iov_base = (char *) iov->iov_base + offset;\n\n    iov->iov_len -= offset;\n\n\n\n    {\n\n#if defined CONFIG_IOVEC && defined CONFIG_POSIX\n\n        struct msghdr msg;\n\n        memset(&msg, 0, sizeof(msg));\n\n        msg.msg_iov = iov;\n\n        msg.msg_iovlen = iovlen;\n\n\n\n        do {\n\n            if (do_sendv) {\n\n                ret = sendmsg(sockfd, &msg, 0);\n\n            } else {\n\n                ret = recvmsg(sockfd, &msg, 0);\n\n            }\n\n        } while (ret == -1 && errno == EINTR);\n\n#else\n\n        struct iovec *p = iov;\n\n        ret = 0;\n\n        while (iovlen > 0) {\n\n            int rc;\n\n            if (do_sendv) {\n\n                rc = send(sockfd, p->iov_base, p->iov_len, 0);\n\n            } else {\n\n                rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0);\n\n            }\n\n            if (rc == -1) {\n\n                if (errno == EINTR) {\n\n                    continue;\n\n                }\n\n                if (ret == 0) {\n\n                    ret = -1;\n\n                }\n\n                break;\n\n            }\n\n            if (rc == 0) {\n\n                break;\n\n            }\n\n            ret += rc;\n\n            iovlen--, p++;\n\n        }\n\n#endif\n\n    }\n\n\n\n    \/* Undo the changes above *\/\n\n    iov->iov_base = (char *) iov->iov_base - offset;\n\n    iov->iov_len += offset;\n\n    last_iov->iov_len += diff;\n\n    return ret;\n\n}\n","target":1,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":166181,"func":"  void BasicFindMainFallbackResponse(bool drop_from_working_set) {\n    PushNextTask(base::BindOnce(\n        &AppCacheStorageImplTest::Verify_BasicFindMainFallbackResponse,\n        base::Unretained(this)));\n\n    MakeCacheAndGroup(kManifestUrl, 2, 1, true);\n    cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1));\n    cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2));\n    cache_->fallback_namespaces_.push_back(AppCacheNamespace(\n        APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespace2, kEntryUrl2, false));\n    cache_->fallback_namespaces_.push_back(AppCacheNamespace(\n        APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl, false));\n    AppCacheDatabase::CacheRecord cache_record;\n    std::vector<AppCacheDatabase::EntryRecord> entries;\n    std::vector<AppCacheDatabase::NamespaceRecord> intercepts;\n    std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;\n    std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;\n    cache_->ToDatabaseRecords(group_.get(), &cache_record, &entries,\n                              &intercepts, &fallbacks, &whitelists);\n\n    for (const auto& entry : entries) {\n      if (entry.url != kDefaultEntryUrl)\n        EXPECT_TRUE(database()->InsertEntry(&entry));\n    }\n\n    EXPECT_TRUE(database()->InsertNamespaceRecords(fallbacks));\n    EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists));\n    if (drop_from_working_set) {\n      EXPECT_TRUE(cache_->HasOneRef());\n      cache_ = nullptr;\n      EXPECT_TRUE(group_->HasOneRef());\n      group_ = nullptr;\n    }\n\n    storage()->FindResponseForMainRequest(kFallbackTestUrl, GURL(), delegate());\n    EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);\n  }\n","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":493241,"func":"transformIndexConstraints(CreateStmtContext *cxt)\n{\n\tIndexStmt  *index;\n\tList\t   *indexlist = NIL;\n\tList\t   *finalindexlist = NIL;\n\tListCell   *lc;\n\n\t\/*\n\t * Run through the constraints that need to generate an index. For PRIMARY\n\t * KEY, mark each column as NOT NULL and create an index. For UNIQUE or\n\t * EXCLUDE, create an index as for PRIMARY KEY, but do not insist on NOT\n\t * NULL.\n\t *\/\n\tforeach(lc, cxt->ixconstraints)\n\t{\n\t\tConstraint *constraint = lfirst_node(Constraint, lc);\n\n\t\tAssert(constraint->contype == CONSTR_PRIMARY ||\n\t\t\t   constraint->contype == CONSTR_UNIQUE ||\n\t\t\t   constraint->contype == CONSTR_EXCLUSION);\n\n\t\tindex = transformIndexConstraint(constraint, cxt);\n\n\t\tindexlist = lappend(indexlist, index);\n\t}\n\n\t\/*\n\t * Scan the index list and remove any redundant index specifications. This\n\t * can happen if, for instance, the user writes UNIQUE PRIMARY KEY. A\n\t * strict reading of SQL would suggest raising an error instead, but that\n\t * strikes me as too anal-retentive. - tgl 2001-02-14\n\t *\n\t * XXX in ALTER TABLE case, it'd be nice to look for duplicate\n\t * pre-existing indexes, too.\n\t *\/\n\tif (cxt->pkey != NULL)\n\t{\n\t\t\/* Make sure we keep the PKEY index in preference to others... *\/\n\t\tfinalindexlist = list_make1(cxt->pkey);\n\t}\n\n\tforeach(lc, indexlist)\n\t{\n\t\tbool\t\tkeep = true;\n\t\tListCell   *k;\n\n\t\tindex = lfirst(lc);\n\n\t\t\/* if it's pkey, it's already in finalindexlist *\/\n\t\tif (index == cxt->pkey)\n\t\t\tcontinue;\n\n\t\tforeach(k, finalindexlist)\n\t\t{\n\t\t\tIndexStmt  *priorindex = lfirst(k);\n\n\t\t\tif (equal(index->indexParams, priorindex->indexParams) &&\n\t\t\t\tequal(index->indexIncludingParams, priorindex->indexIncludingParams) &&\n\t\t\t\tequal(index->whereClause, priorindex->whereClause) &&\n\t\t\t\tequal(index->excludeOpNames, priorindex->excludeOpNames) &&\n\t\t\t\tstrcmp(index->accessMethod, priorindex->accessMethod) == 0 &&\n\t\t\t\tindex->deferrable == priorindex->deferrable &&\n\t\t\t\tindex->initdeferred == priorindex->initdeferred)\n\t\t\t{\n\t\t\t\tpriorindex->unique |= index->unique;\n\n\t\t\t\t\/*\n\t\t\t\t * If the prior index is as yet unnamed, and this one is\n\t\t\t\t * named, then transfer the name to the prior index. This\n\t\t\t\t * ensures that if we have named and unnamed constraints,\n\t\t\t\t * we'll use (at least one of) the names for the index.\n\t\t\t\t *\/\n\t\t\t\tif (priorindex->idxname == NULL)\n\t\t\t\t\tpriorindex->idxname = index->idxname;\n\t\t\t\tkeep = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (keep)\n\t\t\tfinalindexlist = lappend(finalindexlist, index);\n\t}\n\n\t\/*\n\t * Now append all the IndexStmts to cxt->alist.  If we generated an ALTER\n\t * TABLE SET NOT NULL statement to support a primary key, it's already in\n\t * cxt->alist.\n\t *\/\n\tcxt->alist = list_concat(cxt->alist, finalindexlist);\n}","target":0,"code_token_length":743,"total_token_length":979,"max_tokens_setting":1024}
+{"idx":196978,"func":"void Gfx::go(GBool topLevel) {\n  Object obj;\n  Object args[maxArgs];\n  int numArgs, i;\n  int lastAbortCheck;\n\n  pushStateGuard();\n  updateLevel = lastAbortCheck = 0;\n  numArgs = 0;\n  parser->getObj(&obj);\n  while (!obj.isEOF()) {\n    commandAborted = gFalse;\n\n    if (obj.isCmd()) {\n      if (printCommands) {\n\tobj.print(stdout);\n\tfor (i = 0; i < numArgs; ++i) {\n\t  printf(\" \");\n\t  args[i].print(stdout);\n\t}\n\tprintf(\"\\n\");\n\tfflush(stdout);\n      }\n      GooTimer timer;\n\n      execOp(&obj, args, numArgs);\n\n      if (profileCommands) {\n\tGooHash *hash;\n\n\thash = out->getProfileHash ();\n\tif (hash) {\n\t  GooString *cmd_g;\n\t  ProfileData *data_p;\n\n\t  cmd_g = new GooString (obj.getCmd());\n\t  data_p = (ProfileData *)hash->lookup (cmd_g);\n\t  if (data_p == NULL) {\n\t    data_p = new ProfileData();\n\t    hash->add (cmd_g, data_p);\n\t  }\n\t  \n\t  data_p->addElement(timer.getElapsed ());\n\t}\n      }\n      obj.free();\n      for (i = 0; i < numArgs; ++i)\n\targs[i].free();\n      numArgs = 0;\n\n      if (++updateLevel >= 20000) {\n\tout->dump();\n\tupdateLevel = 0;\n      }\n\n      if (commandAborted) {\n\tcommandAborted = gFalse;\n\tbreak;\n      }\n\n      if (abortCheckCbk) {\n\tif (updateLevel - lastAbortCheck > 10) {\n\t  if ((*abortCheckCbk)(abortCheckCbkData)) {\n\t    break;\n\t  }\n\t  lastAbortCheck = updateLevel;\n\t}\n      }\n\n    } else if (numArgs < maxArgs) {\n      args[numArgs++] = obj;\n\n    } else {\n      error(getPos(), \"Too many args in content stream\");\n      if (printCommands) {\n\tprintf(\"throwing away arg: \");\n\tobj.print(stdout);\n\tprintf(\"\\n\");\n\tfflush(stdout);\n      }\n      obj.free();\n    }\n\n    parser->getObj(&obj);\n  }\n  obj.free();\n\n  if (numArgs > 0) {\n    error(getPos(), \"Leftover args in content stream\");\n    if (printCommands) {\n      printf(\"%d leftovers:\", numArgs);\n      for (i = 0; i < numArgs; ++i) {\n\tprintf(\" \");\n\targs[i].print(stdout);\n      }\n      printf(\"\\n\");\n      fflush(stdout);\n    }\n    for (i = 0; i < numArgs; ++i)\n      args[i].free();\n  }\n\n  popStateGuard();\n\n  if (topLevel && updateLevel > 0) {\n    out->dump();\n  }\n}\n","target":0,"code_token_length":612,"total_token_length":848,"max_tokens_setting":1024}
+{"idx":366914,"func":"static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)\n{\n\tstruct k_sigaction ka;\n\tsiginfo_t info;\n\tint signr;\n\n\t\/*\n\t * We want the common case to go fast, which\n\t * is why we may in certain cases get here from\n\t * kernel mode. Just return without doing anything\n\t * if so.\n\t *\/\n\tif (!user_mode(regs))\n\t\treturn 0;\n\n\tif (try_to_freeze())\n\t\tgoto no_signal;\n\n\tsingle_step_clear(current);\n\n\tsignr = get_signal_to_deliver(&info, &ka, regs, NULL);\n\tif (signr > 0) {\n\t\thandle_signal(signr, &ka, &info, oldset, regs, syscall);\n\t\tsingle_step_set(current);\n\t\treturn 1;\n\t}\n\n no_signal:\n\t\/*\n\t * No signal to deliver to the process - restart the syscall.\n\t *\/\n\tif (syscall) {\n\t\tif (regs->ARM_r0 == -ERESTART_RESTARTBLOCK) {\n\t\t\tif (thumb_mode(regs)) {\n\t\t\t\tregs->ARM_r7 = __NR_restart_syscall - __NR_SYSCALL_BASE;\n\t\t\t\tregs->ARM_pc -= 2;\n\t\t\t} else {\n#if defined(CONFIG_AEABI) && !defined(CONFIG_OABI_COMPAT)\n\t\t\t\tregs->ARM_r7 = __NR_restart_syscall;\n\t\t\t\tregs->ARM_pc -= 4;\n#else\n\t\t\t\tu32 __user *usp;\n\t\t\t\tu32 swival = __NR_restart_syscall;\n\n\t\t\t\tregs->ARM_sp -= 12;\n\t\t\t\tusp = (u32 __user *)regs->ARM_sp;\n\n\t\t\t\t\/*\n\t\t\t\t * Either we supports OABI only, or we have\n\t\t\t\t * EABI with the OABI compat layer enabled.\n\t\t\t\t * In the later case we don't know if user\n\t\t\t\t * space is EABI or not, and if not we must\n\t\t\t\t * not clobber r7.  Always using the OABI\n\t\t\t\t * syscall solves that issue and works for\n\t\t\t\t * all those cases.\n\t\t\t\t *\/\n\t\t\t\tswival = swival - __NR_SYSCALL_BASE + __NR_OABI_SYSCALL_BASE;\n\n\t\t\t\tput_user(regs->ARM_pc, &usp[0]);\n\t\t\t\t\/* swi __NR_restart_syscall *\/\n\t\t\t\tput_user(0xef000000 | swival, &usp[1]);\n\t\t\t\t\/* ldr\tpc, [sp], #12 *\/\n\t\t\t\tput_user(0xe49df00c, &usp[2]);\n\n\t\t\t\tflush_icache_range((unsigned long)usp,\n\t\t\t\t\t\t   (unsigned long)(usp + 3));\n\n\t\t\t\tregs->ARM_pc = regs->ARM_sp + 4;\n#endif\n\t\t\t}\n\t\t}\n\t\tif (regs->ARM_r0 == -ERESTARTNOHAND ||\n\t\t    regs->ARM_r0 == -ERESTARTSYS ||\n\t\t    regs->ARM_r0 == -ERESTARTNOINTR) {\n\t\t\tsetup_syscall_restart(regs);\n\t\t}\n\t}\n\tsingle_step_set(current);\n\treturn 0;\n}","target":0,"code_token_length":651,"total_token_length":887,"max_tokens_setting":1024}
+{"idx":294698,"func":"R_API int r_str_binstr2bin(const char *str, ut8 *out, int outlen) {\n\tint n, i, j, k, ret, len;\n\tlen = strlen (str);\n\tfor (n = i = 0; i < len; i += 8) {\n\t\tret = 0;\n\t\twhile (str[i]==' ') {\n\t\t\tstr++;\n\t\t}\n\t\tif (i + 7 < len) {\n\t\t\tfor (k = 0, j = i + 7; j >= i; j--, k++) {\n\t\t\t\t\/\/ INVERSE for (k=0,j=i; j<i+8; j++,k++) {\n\t\t\t\tif (str[j] == ' ') {\n\t\t\t\t\t\/\/k--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\/\/\t\tprintf (\"---> j=%d (%c) (%02x)\\n\", j, str[j], str[j]);\n\t\t\t\tif (str[j] == '1') {\n\t\t\t\t\tret|=1 << k;\n\t\t\t\t} else if (str[j] != '0') {\n\t\t\t\t\treturn n;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\/\/\tprintf (\"-======> %02x\\n\", ret);\n\t\tout[n++] = ret;\n\t\tif (n == outlen) {\n\t\t\treturn n;\n\t\t}\n\t}\n\treturn n;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":106696,"func":"static int userauth_list (lua_State *L, int status, lua_KContext ctx) {\n    char *auth_list = NULL;\n    struct ssh_userdata *state = NULL;\n    const char *username = luaL_checkstring(L, 2);\n\n    state = (struct ssh_userdata *) nseU_checkudata(L, 1, SSH2_UDATA, \"ssh2\");\n    assert(state->session != NULL);\n\n    while ((auth_list = libssh2_userauth_list(state->session, username, lua_rawlen(L, 2))) == NULL\n        && libssh2_session_last_errno(state->session) == LIBSSH2_ERROR_EAGAIN) {\n        luaL_getmetafield(L, 1, \"filter\");\n        lua_pushvalue(L, 1);\n\n        assert(lua_status(L) == LUA_OK);\n        lua_callk(L, 1, 0, 0, userauth_list);\n    }\n\n    if (auth_list) {\n        const char *auth = strtok(auth_list, \",\");\n        lua_newtable(L);\n        do {\n            lua_pushstring(L, auth);\n            lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);\n        }\n        while ((auth = strtok(NULL, \",\")));\n\n        \/\/libssh2_free(state->session, (void *)auth_list);\n    }\n    else if (libssh2_userauth_authenticated(state->session)) {\n        lua_pushliteral(L, \"none_auth\");\n    }\n    else {\n        return ssh_error(L, state->session, \"userauth_list\");\n    }\n\n    return 1;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":137699,"func":"TEST_F(RouterTest, RetryRequestDuringBodyTrailerBetweenAttempts) {\n  Buffer::OwnedImpl decoding_buffer;\n  EXPECT_CALL(callbacks_, decodingBuffer()).WillRepeatedly(Return(&decoding_buffer));\n  EXPECT_CALL(callbacks_, addDecodedData(_, true))\n      .WillRepeatedly(Invoke([&](Buffer::Instance& data, bool) { decoding_buffer.move(data); }));\n\n  NiceMock<Http::MockRequestEncoder> encoder1;\n  Http::ResponseDecoder* response_decoder = nullptr;\n  expectNewStreamWithImmediateEncoder(encoder1, &response_decoder, Http::Protocol::Http10);\n\n  Http::TestRequestHeaderMapImpl headers{\n      {\"x-envoy-retry-on\", \"5xx\"}, {\"x-envoy-internal\", \"true\"}, {\"myheader\", \"present\"}};\n  HttpTestUtility::addDefaultHeaders(headers);\n  router_.decodeHeaders(headers, false);\n  const std::string body1(\"body1\");\n  Buffer::OwnedImpl buf1(body1);\n  EXPECT_CALL(*router_.retry_state_, enabled()).WillOnce(Return(true));\n  router_.decodeData(buf1, false);\n\n  router_.retry_state_->expectResetRetry();\n  encoder1.stream_.resetStream(Http::StreamResetReason::RemoteReset);\n\n  \/\/ Complete request while there is no upstream request.\n  Http::TestRequestTrailerMapImpl trailers{{\"some\", \"trailer\"}};\n  router_.decodeTrailers(trailers);\n\n  NiceMock<Http::MockRequestEncoder> encoder2;\n  expectNewStreamWithImmediateEncoder(encoder2, &response_decoder, Http::Protocol::Http10);\n\n  EXPECT_CALL(encoder2, encodeHeaders(HeaderHasValueRef(\"myheader\", \"present\"), false));\n  EXPECT_CALL(encoder2, encodeData(BufferStringEqual(body1), false));\n  EXPECT_CALL(encoder2, encodeTrailers(HeaderMapEqualRef(&trailers)));\n  router_.retry_state_->callback_();\n  EXPECT_EQ(2U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n  EXPECT_TRUE(verifyHostUpstreamStats(0, 1));\n\n  \/\/ Send successful response, verify success.\n  Http::ResponseHeaderMapPtr response_headers(\n      new Http::TestResponseHeaderMapImpl({{\":status\", \"200\"}}));\n  EXPECT_CALL(callbacks_, encodeHeaders_(_, _))\n      .WillOnce(Invoke([&](Http::ResponseHeaderMap& headers, bool) -> void {\n        EXPECT_EQ(headers.Status()->value(), \"200\");\n      }));\n  response_decoder->decodeHeaders(std::move(response_headers), true);\n  EXPECT_TRUE(verifyHostUpstreamStats(1, 1));\n}","target":0,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":19159,"func":"static ossl_inline unsigned long lh_ ## type ## _num_items ( LHASH_OF ( type ) * lh ) {\n return OPENSSL_LH_num_items ( ( OPENSSL_LHASH * ) lh ) ;\n }\n static ossl_inline void lh_ ## type ## _node_stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {\n OPENSSL_LH_node_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;\n }\n static ossl_inline void lh_ ## type ## _node_usage_stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {\n OPENSSL_LH_node_usage_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;\n }\n static ossl_inline void lh_ ## type ## _stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {\n OPENSSL_LH_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;\n }\n static ossl_inline unsigned long lh_ ## type ## _get_down_load ( LHASH_OF ( type ) * lh ) {\n return OPENSSL_LH_get_down_load ( ( OPENSSL_LHASH * ) lh ) ;\n }\n static ossl_inline void lh_ ## type ## _set_down_load ( LHASH_OF ( type ) * lh , unsigned long dl ) {\n OPENSSL_LH_set_down_load ( ( OPENSSL_LHASH * ) lh , dl ) ;\n }\n static ossl_inline void lh_ ## type ## _doall ( LHASH_OF ( type ) * lh , void ( * doall ) ( type * ) ) {\n OPENSSL_LH_doall ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNC ) doall ) ;\n }\n LHASH_OF ( type ) # define IMPLEMENT_LHASH_DOALL_ARG_CONST ( type , argtype ) int_implement_lhash_doall ( type , argtype , const type ) # define IMPLEMENT_LHASH_DOALL_ARG ( type , argtype ) int_implement_lhash_doall ( type , argtype , type ) # define int_implement_lhash_doall ( type , argtype , cbargtype ) static ossl_inline void lh_ ## type ## _doall_ ## argtype ( LHASH_OF ( type ) * lh , void ( * fn ) ( cbargtype * , argtype * ) , argtype * arg ) {\n OPENSSL_LH_doall_arg ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNCARG ) fn , ( void * ) arg ) ;\n }\n LHASH_OF ( type ) DEFINE_LHASH_OF ( OPENSSL_STRING ) ;\n # ifdef _MSC_VER # pragma warning ( push ) # pragma warning ( disable : 4090 ) # endif DEFINE_LHASH_OF ( OPENSSL_CSTRING )","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":135211,"func":"static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)\n{\n    static const uint8_t bcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\n    static const uint8_t vlan[] = {0x81, 0x00};\n    uint8_t *ptr = (uint8_t *)buf;\n    int i;\n\n    if (n->promisc)\n        return 1;\n\n    ptr += n->host_hdr_len;\n\n    if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {\n        int vid = lduw_be_p(ptr + 14) & 0xfff;\n        if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f))))\n            return 0;\n    }\n\n    if (ptr[0] & 1) { \/\/ multicast\n        if (!memcmp(ptr, bcast, sizeof(bcast))) {\n            return !n->nobcast;\n        } else if (n->nomulti) {\n            return 0;\n        } else if (n->allmulti || n->mac_table.multi_overflow) {\n            return 1;\n        }\n\n        for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) {\n            if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN)) {\n                return 1;\n            }\n        }\n    } else { \/\/ unicast\n        if (n->nouni) {\n            return 0;\n        } else if (n->alluni || n->mac_table.uni_overflow) {\n            return 1;\n        } else if (!memcmp(ptr, n->mac, ETH_ALEN)) {\n            return 1;\n        }\n\n        for (i = 0; i < n->mac_table.first_multi; i++) {\n            if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN)) {\n                return 1;\n            }\n        }\n    }\n\n    return 0;\n}","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":79827,"func":"xfs_attr3_rmt_write_verify(\n\tstruct xfs_buf\t*bp)\n{\n\tstruct xfs_mount *mp = bp->b_target->bt_mount;\n\tstruct xfs_buf_log_item\t*bip = bp->b_fspriv;\n\tchar\t\t*ptr;\n\tint\t\tlen;\n\txfs_daddr_t\tbno;\n\n\t\/* no verification of non-crc buffers *\/\n\tif (!xfs_sb_version_hascrc(&mp->m_sb))\n\t\treturn;\n\n\tptr = bp->b_addr;\n\tbno = bp->b_bn;\n\tlen = BBTOB(bp->b_length);\n\tASSERT(len >= XFS_LBSIZE(mp));\n\n\twhile (len > 0) {\n\t\tif (!xfs_attr3_rmt_verify(mp, ptr, XFS_LBSIZE(mp), bno)) {\n\t\t\txfs_buf_ioerror(bp, EFSCORRUPTED);\n\t\t\txfs_verifier_error(bp);\n\t\t\treturn;\n\t\t}\n\t\tif (bip) {\n\t\t\tstruct xfs_attr3_rmt_hdr *rmt;\n\n\t\t\trmt = (struct xfs_attr3_rmt_hdr *)ptr;\n\t\t\trmt->rm_lsn = cpu_to_be64(bip->bli_item.li_lsn);\n\t\t}\n\t\txfs_update_cksum(ptr, XFS_LBSIZE(mp), XFS_ATTR3_RMT_CRC_OFF);\n\n\t\tlen -= XFS_LBSIZE(mp);\n\t\tptr += XFS_LBSIZE(mp);\n\t\tbno += mp->m_bsize;\n\t}\n\tASSERT(len == 0);\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":270484,"func":"int cil_gen_userrange(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)\n{\n\tenum cil_syntax syntax[] = {\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_STRING | CIL_SYN_LIST,\n\t\tCIL_SYN_END\n\t};\n\tint syntax_len = sizeof(syntax)\/sizeof(*syntax);\n\tstruct cil_userrange *userrange = NULL;\n\tint rc = SEPOL_ERR;\n\n\tif (db == NULL || parse_current == NULL || ast_node == NULL) {\n\t\tgoto exit;\n\t}\n\n\trc = __cil_verify_syntax(parse_current, syntax, syntax_len);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tcil_userrange_init(&userrange);\n\n\tuserrange->user_str = parse_current->next->data;\n\n\tif (parse_current->next->next->cl_head == NULL) {\n\t\tuserrange->range_str = parse_current->next->next->data;\n\t} else {\n\t\tcil_levelrange_init(&userrange->range);\n\n\t\trc = cil_fill_levelrange(parse_current->next->next->cl_head, userrange->range);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\t}\n\n\tast_node->data = userrange;\n\tast_node->flavor = CIL_USERRANGE;\n\n\treturn SEPOL_OK;\n\nexit:\n\tcil_tree_log(parse_current, CIL_ERR, \"Bad userrange declaration\");\n\tcil_destroy_userrange(userrange);\n\treturn rc;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":517674,"func":"static void update_maria_group_commit(MYSQL_THD thd,\n                                      struct st_mysql_sys_var *var,\n                                      void *var_ptr, const void *save)\n{\n  ulong value= (ulong)*((long *)var_ptr);\n  DBUG_ENTER(\"update_maria_group_commit\");\n  DBUG_PRINT(\"enter\", (\"old value: %lu  new value %lu  rate %lu\",\n                       value, (ulong)(*(long *)save),\n                       maria_group_commit_interval));\n  \/* old value *\/\n  switch (value) {\n  case TRANSLOG_GCOMMIT_NONE:\n    break;\n  case TRANSLOG_GCOMMIT_HARD:\n    translog_hard_group_commit(FALSE);\n    break;\n  case TRANSLOG_GCOMMIT_SOFT:\n    translog_soft_sync(FALSE);\n    if (maria_group_commit_interval)\n      translog_soft_sync_end();\n    break;\n  default:\n    DBUG_ASSERT(0); \/* impossible *\/\n  }\n  value= *(ulong *)var_ptr= (ulong)(*(long *)save);\n  translog_sync();\n  \/* new value *\/\n  switch (value) {\n  case TRANSLOG_GCOMMIT_NONE:\n    break;\n  case TRANSLOG_GCOMMIT_HARD:\n    translog_hard_group_commit(TRUE);\n    break;\n  case TRANSLOG_GCOMMIT_SOFT:\n    translog_soft_sync(TRUE);\n    \/* variable change made under global lock so we can just read it *\/\n    if (maria_group_commit_interval)\n      translog_soft_sync_start();\n    break;\n  default:\n    DBUG_ASSERT(0); \/* impossible *\/\n  }\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":28877,"func":"static void truespeech_read_frame ( TSContext * dec , const uint8_t * input ) {\n GetBitContext gb ;\n dec -> dsp . bswap_buf ( ( uint32_t * ) dec -> buffer , ( const uint32_t * ) input , 8 ) ;\n init_get_bits ( & gb , dec -> buffer , 32 * 8 ) ;\n dec -> vector [ 7 ] = ts_codebook [ 7 ] [ get_bits ( & gb , 3 ) ] ;\n dec -> vector [ 6 ] = ts_codebook [ 6 ] [ get_bits ( & gb , 3 ) ] ;\n dec -> vector [ 5 ] = ts_codebook [ 5 ] [ get_bits ( & gb , 3 ) ] ;\n dec -> vector [ 4 ] = ts_codebook [ 4 ] [ get_bits ( & gb , 4 ) ] ;\n dec -> vector [ 3 ] = ts_codebook [ 3 ] [ get_bits ( & gb , 4 ) ] ;\n dec -> vector [ 2 ] = ts_codebook [ 2 ] [ get_bits ( & gb , 4 ) ] ;\n dec -> vector [ 1 ] = ts_codebook [ 1 ] [ get_bits ( & gb , 5 ) ] ;\n dec -> vector [ 0 ] = ts_codebook [ 0 ] [ get_bits ( & gb , 5 ) ] ;\n dec -> flag = get_bits1 ( & gb ) ;\n dec -> offset1 [ 0 ] = get_bits ( & gb , 4 ) << 4 ;\n dec -> offset2 [ 3 ] = get_bits ( & gb , 7 ) ;\n dec -> offset2 [ 2 ] = get_bits ( & gb , 7 ) ;\n dec -> offset2 [ 1 ] = get_bits ( & gb , 7 ) ;\n dec -> offset2 [ 0 ] = get_bits ( & gb , 7 ) ;\n dec -> offset1 [ 1 ] = get_bits ( & gb , 4 ) ;\n dec -> pulseval [ 1 ] = get_bits ( & gb , 14 ) ;\n dec -> pulseval [ 0 ] = get_bits ( & gb , 14 ) ;\n dec -> offset1 [ 1 ] |= get_bits ( & gb , 4 ) << 4 ;\n dec -> pulseval [ 3 ] = get_bits ( & gb , 14 ) ;\n dec -> pulseval [ 2 ] = get_bits ( & gb , 14 ) ;\n dec -> offset1 [ 0 ] |= get_bits1 ( & gb ) ;\n dec -> pulsepos [ 0 ] = get_bits_long ( & gb , 27 ) ;\n dec -> pulseoff [ 0 ] = get_bits ( & gb , 4 ) ;\n dec -> offset1 [ 0 ] |= get_bits1 ( & gb ) << 1 ;\n dec -> pulsepos [ 1 ] = get_bits_long ( & gb , 27 ) ;\n dec -> pulseoff [ 1 ] = get_bits ( & gb , 4 ) ;\n dec -> offset1 [ 0 ] |= get_bits1 ( & gb ) << 2 ;\n dec -> pulsepos [ 2 ] = get_bits_long ( & gb , 27 ) ;\n dec -> pulseoff [ 2 ] = get_bits ( & gb , 4 ) ;\n dec -> offset1 [ 0 ] |= get_bits1 ( & gb ) << 3 ;\n dec -> pulsepos [ 3 ] = get_bits_long ( & gb , 27 ) ;\n dec -> pulseoff [ 3 ] = get_bits ( & gb , 4 ) ;\n }","target":0,"code_token_length":763,"total_token_length":999,"max_tokens_setting":1024}
+{"idx":284659,"func":"static int AppLayerProtoDetectTest06(void)\n{\n    AppLayerProtoDetectUnittestCtxBackup();\n    AppLayerProtoDetectSetup();\n\n    uint8_t l7data[] = \"220 Welcome to the OISF FTP server\\r\\n\";\n    const char *buf;\n    int r = 0;\n    Flow f;\n    AppProto pm_results[ALPROTO_MAX];\n    AppLayerProtoDetectThreadCtx *alpd_tctx;\n\n    memset(&f, 0x00, sizeof(f));\n    f.protomap = FlowGetProtoMapping(IPPROTO_TCP);\n\n    buf = \"HTTP\";\n    AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);\n    buf = \"220 \";\n    AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_FTP, buf, 4, 0, STREAM_TOCLIENT);\n\n    AppLayerProtoDetectPrepareState();\n    \/* AppLayerProtoDetectGetCtxThread() should be called post AppLayerProtoDetectPrepareState(), since\n     * it sets internal structures which depends on the above function. *\/\n    alpd_tctx = AppLayerProtoDetectGetCtxThread();\n\n    if (alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[0].max_pat_id != 0) {\n        printf(\"alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[0].max_pat_id != 0\\n\");\n        goto end;\n    }\n    if (alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].max_pat_id != 2) {\n        printf(\"alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].max_pat_id != 2\\n\");\n        goto end;\n    }\n\n    if (alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[0].map != NULL) {\n        printf(\"alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[0].map != NULL\\n\");\n        goto end;\n    }\n    if (alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].map == NULL) {\n        printf(\"alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].map != NULL\\n\");\n        goto end;\n    }\n\n    if (alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].map[0]->alproto != ALPROTO_FTP) {\n        printf(\"alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].map[0].alproto != ALPROTO_FTP\\n\");\n        goto end;\n    }\n    if (alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].map[1]->alproto != ALPROTO_HTTP) {\n        printf(\"alpd_ctx.ctx_ipp[FLOW_PROTO_TCP].ctx_pm[1].map[1].alproto != ALPROTO_HTTP\\n\");\n        goto end;\n    }\n\n    uint32_t cnt = AppLayerProtoDetectPMGetProto(alpd_tctx,\n                                                 &f,\n                                                 l7data, sizeof(l7data),\n                                                 STREAM_TOCLIENT,\n                                                 IPPROTO_TCP,\n                                                 pm_results);\n    if (cnt != 1 && pm_results[0] != ALPROTO_FTP) {\n        printf(\"cnt != 1 && pm_results[0] != AlPROTO_FTP\\n\");\n        goto end;\n    }\n\n    r = 1;\n\n end:\n    if (alpd_tctx != NULL)\n        AppLayerProtoDetectDestroyCtxThread(alpd_tctx);\n    AppLayerProtoDetectDeSetup();\n    AppLayerProtoDetectUnittestCtxRestore();\n    return r;\n}\n","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":408530,"func":"bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)\n{\n    int c;\n    Py_ssize_t len_a, len_b;\n    Py_ssize_t min_len;\n    PyObject *result;\n    int rc;\n\n    \/* Make sure both arguments are strings. *\/\n    if (!(PyBytes_Check(a) && PyBytes_Check(b))) {\n        if (Py_BytesWarningFlag && (op == Py_EQ || op == Py_NE)) {\n            rc = PyObject_IsInstance((PyObject*)a,\n                                     (PyObject*)&PyUnicode_Type);\n            if (!rc)\n                rc = PyObject_IsInstance((PyObject*)b,\n                                         (PyObject*)&PyUnicode_Type);\n            if (rc < 0)\n                return NULL;\n            if (rc) {\n                if (PyErr_WarnEx(PyExc_BytesWarning,\n                                 \"Comparison between bytes and string\", 1))\n                    return NULL;\n            }\n            else {\n                rc = PyObject_IsInstance((PyObject*)a,\n                                         (PyObject*)&PyLong_Type);\n                if (!rc)\n                    rc = PyObject_IsInstance((PyObject*)b,\n                                             (PyObject*)&PyLong_Type);\n                if (rc < 0)\n                    return NULL;\n                if (rc) {\n                    if (PyErr_WarnEx(PyExc_BytesWarning,\n                                     \"Comparison between bytes and int\", 1))\n                        return NULL;\n                }\n            }\n        }\n        result = Py_NotImplemented;\n    }\n    else if (a == b) {\n        switch (op) {\n        case Py_EQ:\n        case Py_LE:\n        case Py_GE:\n            \/* a string is equal to itself *\/\n            result = Py_True;\n            break;\n        case Py_NE:\n        case Py_LT:\n        case Py_GT:\n            result = Py_False;\n            break;\n        default:\n            PyErr_BadArgument();\n            return NULL;\n        }\n    }\n    else if (op == Py_EQ || op == Py_NE) {\n        int eq = bytes_compare_eq(a, b);\n        eq ^= (op == Py_NE);\n        result = eq ? Py_True : Py_False;\n    }\n    else {\n        len_a = Py_SIZE(a);\n        len_b = Py_SIZE(b);\n        min_len = Py_MIN(len_a, len_b);\n        if (min_len > 0) {\n            c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);\n            if (c == 0)\n                c = memcmp(a->ob_sval, b->ob_sval, min_len);\n        }\n        else\n            c = 0;\n        if (c == 0)\n            c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;\n        switch (op) {\n        case Py_LT: c = c <  0; break;\n        case Py_LE: c = c <= 0; break;\n        case Py_GT: c = c >  0; break;\n        case Py_GE: c = c >= 0; break;\n        default:\n            PyErr_BadArgument();\n            return NULL;\n        }\n        result = c ? Py_True : Py_False;\n    }\n\n    Py_INCREF(result);\n    return result;\n}","target":0,"code_token_length":681,"total_token_length":917,"max_tokens_setting":1024}
+{"idx":295771,"func":"dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) {\n  HASH_TABLE_ITER iter;\n  hashTableIterInit(&iter, &(p->elementTypes));\n  for (;;) {\n    ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);\n    if (! e)\n      break;\n    if (e->allocDefaultAtts != 0)\n      ms->free_fcn(e->defaultAtts);\n  }\n  hashTableClear(&(p->generalEntities));\n#ifdef XML_DTD\n  p->paramEntityRead = XML_FALSE;\n  hashTableClear(&(p->paramEntities));\n#endif \/* XML_DTD *\/\n  hashTableClear(&(p->elementTypes));\n  hashTableClear(&(p->attributeIds));\n  hashTableClear(&(p->prefixes));\n  poolClear(&(p->pool));\n  poolClear(&(p->entityValuePool));\n  p->defaultPrefix.name = NULL;\n  p->defaultPrefix.binding = NULL;\n\n  p->in_eldecl = XML_FALSE;\n\n  ms->free_fcn(p->scaffIndex);\n  p->scaffIndex = NULL;\n  ms->free_fcn(p->scaffold);\n  p->scaffold = NULL;\n\n  p->scaffLevel = 0;\n  p->scaffSize = 0;\n  p->scaffCount = 0;\n  p->contentStringLen = 0;\n\n  p->keepProcessing = XML_TRUE;\n  p->hasParamEntityRefs = XML_FALSE;\n  p->standalone = XML_FALSE;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":281538,"func":"void WebContentsImpl::LoadingStateChanged(bool to_different_document,\n                                          bool due_to_interstitial,\n                                          LoadNotificationDetails* details) {\n  if (ShowingInterstitialPage() && interstitial_page_->pause_throbber() &&\n      !due_to_interstitial) {\n    return;\n  }\n\n  bool is_loading = IsLoading();\n\n  if (!is_loading) {\n    load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE,\n                                          base::string16());\n    load_state_host_.clear();\n    upload_size_ = 0;\n    upload_position_ = 0;\n  }\n\n  GetRenderManager()->SetIsLoading(is_loading);\n\n  waiting_for_response_ = is_loading;\n  is_load_to_different_document_ = to_different_document;\n\n  if (delegate_)\n    delegate_->LoadingStateChanged(this, to_different_document);\n  NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD);\n\n  std::string url = (details ? details->url.possibly_invalid_spec() : \"NULL\");\n  if (is_loading) {\n    TRACE_EVENT_ASYNC_BEGIN2(\"browser,navigation\", \"WebContentsImpl Loading\",\n                             this, \"URL\", url, \"Main FrameTreeNode id\",\n                             GetFrameTree()->root()->frame_tree_node_id());\n    for (auto& observer : observers_)\n      observer.DidStartLoading();\n  } else {\n    TRACE_EVENT_ASYNC_END1(\"browser,navigation\", \"WebContentsImpl Loading\",\n                           this, \"URL\", url);\n    for (auto& observer : observers_)\n      observer.DidStopLoading();\n  }\n\n  int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP;\n  NotificationDetails det = NotificationService::NoDetails();\n  if (details)\n      det = Details<LoadNotificationDetails>(details);\n  NotificationService::current()->Notify(\n      type, Source<NavigationController>(&controller_), det);\n}\n","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":401903,"func":"ZEND_VM_HOT_HANDLER(129, ZEND_DO_ICALL, ANY, ANY, SPEC(RETVAL))\n{\n\tUSE_OPLINE\n\tzend_execute_data *call = EX(call);\n\tzend_function *fbc = call->func;\n\tzval *ret;\n\tzval retval;\n\n\tSAVE_OPLINE();\n\tEX(call) = call->prev_execute_data;\n\n\tcall->prev_execute_data = execute_data;\n\tEG(current_execute_data) = call;\n\n\tret = RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : &retval;\n\tZVAL_NULL(ret);\n\n\tfbc->internal_function.handler(call, ret);\n\n#if ZEND_DEBUG\n\tif (!EG(exception) && call->func) {\n\t\tZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||\n\t\t\tzend_verify_internal_return_type(call->func, ret));\n\t\tZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)\n\t\t\t? Z_ISREF_P(ret) : !Z_ISREF_P(ret));\n\t}\n#endif\n\n\tEG(current_execute_data) = execute_data;\n\tzend_vm_stack_free_args(call);\n\tzend_vm_stack_free_call_frame(call);\n\n\tif (!RETURN_VALUE_USED(opline)) {\n\t\ti_zval_ptr_dtor(ret);\n\t}\n\n\tif (UNEXPECTED(EG(exception) != NULL)) {\n\t\tzend_rethrow_exception(execute_data);\n\t\tHANDLE_EXCEPTION();\n\t}\n\n\tZEND_VM_SET_OPCODE(opline + 1);\n\tZEND_VM_CONTINUE();\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":16717,"func":"static inline int rsvp_class_to_filter_num ( int classnum ) {\n switch ( classnum ) {\n case RSVP_CLASS_SESSION : case RSVP_CLASS_HOP : case RSVP_CLASS_INTEGRITY : case RSVP_CLASS_TIME_VALUES : case RSVP_CLASS_ERROR : case RSVP_CLASS_SCOPE : case RSVP_CLASS_STYLE : case RSVP_CLASS_FLOWSPEC : case RSVP_CLASS_FILTER_SPEC : case RSVP_CLASS_SENDER_TEMPLATE : case RSVP_CLASS_SENDER_TSPEC : case RSVP_CLASS_ADSPEC : case RSVP_CLASS_POLICY : case RSVP_CLASS_CONFIRM : case RSVP_CLASS_LABEL : case RSVP_CLASS_LABEL_REQUEST : case RSVP_CLASS_HELLO : case RSVP_CLASS_EXPLICIT_ROUTE : case RSVP_CLASS_RECORD_ROUTE : case RSVP_CLASS_MESSAGE_ID : case RSVP_CLASS_MESSAGE_ID_ACK : case RSVP_CLASS_MESSAGE_ID_LIST : return classnum + RSVPF_OBJECT ;\n break ;\n case RSVP_CLASS_RECOVERY_LABEL : case RSVP_CLASS_UPSTREAM_LABEL : case RSVP_CLASS_LABEL_SET : case RSVP_CLASS_PROTECTION : return RSVPF_RECOVERY_LABEL + ( classnum - RSVP_CLASS_RECOVERY_LABEL ) ;\n case RSVP_CLASS_SUGGESTED_LABEL : case RSVP_CLASS_ACCEPTABLE_LABEL_SET : case RSVP_CLASS_RESTART_CAP : return RSVPF_SUGGESTED_LABEL + ( classnum - RSVP_CLASS_SUGGESTED_LABEL ) ;\n case RSVP_CLASS_LINK_CAP : return RSVPF_LINK_CAP ;\n case RSVP_CLASS_DIFFSERV : return RSVPF_DIFFSERV ;\n case RSVP_CLASS_CLASSTYPE : return RSVPF_DSTE ;\n case RSVP_CLASS_NOTIFY_REQUEST : return RSVPF_NOTIFY_REQUEST ;\n case RSVP_CLASS_ADMIN_STATUS : return RSVPF_ADMIN_STATUS ;\n case RSVP_CLASS_LSP_ATTRIBUTES : return RSVPF_LSP_ATTRIBUTES ;\n case RSVP_CLASS_ASSOCIATION : return RSVPF_ASSOCIATION ;\n case RSVP_CLASS_CALL_ATTRIBUTES : return RSVPF_CALL_ATTRIBUTES ;\n case RSVP_CLASS_SESSION_ATTRIBUTE : return RSVPF_SESSION_ATTRIBUTE ;\n case RSVP_CLASS_GENERALIZED_UNI : return RSVPF_GENERALIZED_UNI ;\n case RSVP_CLASS_CALL_ID : return RSVPF_CALL_ID ;\n case RSVP_CLASS_3GPP2_OBJECT : return RSVPF_3GPP2_OBJECT ;\n case RSVP_CLASS_DCLASS : return RSVPF_DCLASS ;\n case RSVP_CLASS_LSP_TUNNEL_IF_ID : return RSVPF_LSP_TUNNEL_IF_ID ;\n case RSVP_CLASS_EXCLUDE_ROUTE : return RSVPF_EXCLUDE_ROUTE ;\n case RSVP_CLASS_JUNIPER_PROPERTIES : return RSVPF_JUNIPER ;\n case RSVP_CLASS_VENDOR_PRIVATE_1 : case RSVP_CLASS_VENDOR_PRIVATE_2 : case RSVP_CLASS_VENDOR_PRIVATE_3 : case RSVP_CLASS_VENDOR_PRIVATE_4 : case RSVP_CLASS_VENDOR_PRIVATE_5 : case RSVP_CLASS_VENDOR_PRIVATE_6 : case RSVP_CLASS_VENDOR_PRIVATE_7 : case RSVP_CLASS_VENDOR_PRIVATE_8 : case RSVP_CLASS_VENDOR_PRIVATE_9 : case RSVP_CLASS_VENDOR_PRIVATE_10 : case RSVP_CLASS_VENDOR_PRIVATE_11 : case RSVP_CLASS_VENDOR_PRIVATE_12 : return RSVPF_PRIVATE_OBJ ;\n default : return RSVPF_UNKNOWN_OBJ ;\n }\n }","target":0,"code_token_length":597,"total_token_length":833,"max_tokens_setting":1024}
+{"idx":241881,"func":"addToGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid, afs_int32 *cid)\n{\n    afs_int32 code;\n    struct ubik_trans *tt;\n    afs_int32 tempu;\n    afs_int32 tempg;\n    struct prentry tentry;\n    struct prentry uentry;\n\n    code = Initdb();\n    if (code != PRSUCCESS)\n\treturn code;\n    if (gid == ANYUSERID || gid == AUTHUSERID)\n\treturn PRPERM;\n    if (aid == ANONYMOUSID)\n\treturn PRPERM;\n    code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);\n    if (code)\n\treturn code;\n    code = ubik_SetLock(tt, 1, 1, LOCKWRITE);\n    if (code)\n\tABORT_WITH(tt, code);\n    code = read_DbHeader(tt);\n    if (code)\n\tABORT_WITH(tt, code);\n\n    code = WhoIsThis(call, tt, cid);\n    if (code)\n\tABORT_WITH(tt, PRPERM);\n    tempu = FindByID(tt, aid);\n    if (!tempu)\n\tABORT_WITH(tt, PRNOENT);\n    memset(&uentry, 0, sizeof(uentry));\n    code = pr_ReadEntry(tt, 0, tempu, &uentry);\n    if (code != 0)\n\tABORT_WITH(tt, code);\n\n#if !defined(SUPERGROUPS)\n    \/* we don't allow groups as members of groups at present *\/\n    if (uentry.flags & PRGRP)\n\tABORT_WITH(tt, PRNOTUSER);\n#endif\n\n    tempg = FindByID(tt, gid);\n    if (!tempg)\n\tABORT_WITH(tt, PRNOENT);\n    code = pr_ReadEntry(tt, 0, tempg, &tentry);\n    if (code != 0)\n\tABORT_WITH(tt, code);\n    \/* make sure that this is a group *\/\n    if (!(tentry.flags & PRGRP))\n\tABORT_WITH(tt, PRNOTGROUP);\n    if (!AccessOK(tt, *cid, &tentry, PRP_ADD_MEM, PRP_ADD_ANY))\n\tABORT_WITH(tt, PRPERM);\n\n    code = AddToEntry(tt, &tentry, tempg, aid);\n    if (code != PRSUCCESS)\n\tABORT_WITH(tt, code);\n\n#if defined(SUPERGROUPS)\n    if (uentry.flags & PRGRP)\n\tcode = AddToSGEntry(tt, &uentry, tempu, gid);\t\/* mod group to be in sg *\/\n    else\n#endif\n\t\/* now, modify the user's entry as well *\/\n\tcode = AddToEntry(tt, &uentry, tempu, gid);\n    if (code != PRSUCCESS)\n\tABORT_WITH(tt, code);\n    code = ubik_EndTrans(tt);\n    if (code)\n\treturn code;\n    return PRSUCCESS;\n}\n","target":0,"code_token_length":626,"total_token_length":862,"max_tokens_setting":1024}
+{"idx":487822,"func":"static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)\n{\n\tint order, added = 0, lg_prealloc_count = 1;\n\tstruct super_block *sb = ac->ac_sb;\n\tstruct ext4_locality_group *lg = ac->ac_lg;\n\tstruct ext4_prealloc_space *tmp_pa, *pa = ac->ac_pa;\n\n\torder = fls(pa->pa_free) - 1;\n\tif (order > PREALLOC_TB_SIZE - 1)\n\t\t\/* The max size of hash table is PREALLOC_TB_SIZE *\/\n\t\torder = PREALLOC_TB_SIZE - 1;\n\t\/* Add the prealloc space to lg *\/\n\tspin_lock(&lg->lg_prealloc_lock);\n\tlist_for_each_entry_rcu(tmp_pa, &lg->lg_prealloc_list[order],\n\t\t\t\tpa_inode_list,\n\t\t\t\tlockdep_is_held(&lg->lg_prealloc_lock)) {\n\t\tspin_lock(&tmp_pa->pa_lock);\n\t\tif (tmp_pa->pa_deleted) {\n\t\t\tspin_unlock(&tmp_pa->pa_lock);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!added && pa->pa_free < tmp_pa->pa_free) {\n\t\t\t\/* Add to the tail of the previous entry *\/\n\t\t\tlist_add_tail_rcu(&pa->pa_inode_list,\n\t\t\t\t\t\t&tmp_pa->pa_inode_list);\n\t\t\tadded = 1;\n\t\t\t\/*\n\t\t\t * we want to count the total\n\t\t\t * number of entries in the list\n\t\t\t *\/\n\t\t}\n\t\tspin_unlock(&tmp_pa->pa_lock);\n\t\tlg_prealloc_count++;\n\t}\n\tif (!added)\n\t\tlist_add_tail_rcu(&pa->pa_inode_list,\n\t\t\t\t\t&lg->lg_prealloc_list[order]);\n\tspin_unlock(&lg->lg_prealloc_lock);\n\n\t\/* Now trim the list to be not more than 8 elements *\/\n\tif (lg_prealloc_count > 8) {\n\t\text4_mb_discard_lg_preallocations(sb, lg,\n\t\t\t\t\t\t  order, lg_prealloc_count);\n\t\treturn;\n\t}\n\treturn ;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":168070,"func":"  TT_Load_Context( TT_ExecContext  exec,\n                   TT_Face         face,\n                   TT_Size         size )\n  {\n    FT_Int          i;\n    FT_ULong        tmp;\n    TT_MaxProfile*  maxp;\n    FT_Error        error;\n\n\n    exec->face = face;\n    maxp       = &face->max_profile;\n    exec->size = size;\n\n    if ( size )\n    {\n      exec->numFDefs   = size->num_function_defs;\n      exec->maxFDefs   = size->max_function_defs;\n      exec->numIDefs   = size->num_instruction_defs;\n      exec->maxIDefs   = size->max_instruction_defs;\n      exec->FDefs      = size->function_defs;\n      exec->IDefs      = size->instruction_defs;\n      exec->pointSize  = size->point_size;\n      exec->tt_metrics = size->ttmetrics;\n      exec->metrics    = *size->metrics;\n\n      exec->maxFunc    = size->max_func;\n      exec->maxIns     = size->max_ins;\n\n      for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )\n        exec->codeRangeTable[i] = size->codeRangeTable[i];\n\n      \/* set graphics state *\/\n      exec->GS = size->GS;\n\n      exec->cvtSize = size->cvt_size;\n      exec->cvt     = size->cvt;\n\n      exec->storeSize = size->storage_size;\n      exec->storage   = size->storage;\n\n      exec->twilight  = size->twilight;\n\n      \/* In case of multi-threading it can happen that the old size object *\/\n      \/* no longer exists, thus we must clear all glyph zone references.   *\/\n      FT_ZERO( &exec->zp0 );\n      exec->zp1 = exec->zp0;\n      exec->zp2 = exec->zp0;\n    }\n\n    \/* XXX: We reserve a little more elements on the stack to deal safely *\/\n    \/*      with broken fonts like arialbs, courbs, timesbs, etc.         *\/\n    tmp = (FT_ULong)exec->stackSize;\n    error = Update_Max( exec->memory,\n                        &tmp,\n                        sizeof ( FT_F26Dot6 ),\n                        (void*)&exec->stack,\n                        maxp->maxStackElements + 32 );\n    exec->stackSize = (FT_Long)tmp;\n    if ( error )\n      return error;\n\n    tmp = exec->glyphSize;\n    error = Update_Max( exec->memory,\n                        &tmp,\n                        sizeof ( FT_Byte ),\n                        (void*)&exec->glyphIns,\n                        maxp->maxSizeOfInstructions );\n    exec->glyphSize = (FT_UShort)tmp;\n    if ( error )\n      return error;\n\n    exec->pts.n_points   = 0;\n    exec->pts.n_contours = 0;\n\n    exec->zp1 = exec->pts;\n    exec->zp2 = exec->pts;\n    exec->zp0 = exec->pts;\n\n    exec->instruction_trap = FALSE;\n\n    return FT_Err_Ok;\n  }\n","target":0,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":163977,"func":"bool RenderBlock::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutState)\n{\n    LayoutUnit lineDelta = logicalHeight() - layoutState.endLineLogicalTop();\n\n    bool paginated = view()->layoutState() && view()->layoutState()->isPaginated();\n    if (paginated && layoutState.flowThread()) {\n        for (RootInlineBox* lineBox = layoutState.endLine(); lineBox; lineBox = lineBox->nextRootBox()) {\n            if (paginated) {\n                LayoutUnit oldPaginationStrut = lineBox->paginationStrut();\n                lineDelta -= oldPaginationStrut;\n                adjustLinePositionForPagination(lineBox, lineDelta, layoutState.flowThread());\n                lineBox->setPaginationStrut(oldPaginationStrut);\n            }\n            if (lineWidthForPaginatedLineChanged(lineBox, lineDelta, layoutState.flowThread()))\n                return false;\n        }\n    }\n\n    if (!lineDelta || !m_floatingObjects)\n        return true;\n\n    LayoutUnit logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop());\n\n    RootInlineBox* lastLine = layoutState.endLine();\n    while (RootInlineBox* nextLine = lastLine->nextRootBox())\n        lastLine = nextLine;\n\n    LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue(lineDelta);\n\n    const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();\n    FloatingObjectSetIterator end = floatingObjectSet.end();\n    for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {\n        FloatingObject* f = *it;\n        if (f->logicalBottom(isHorizontalWritingMode()) >= logicalTop && f->logicalBottom(isHorizontalWritingMode()) < logicalBottom)\n            return false;\n    }\n\n    return true;\n}\n","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":466578,"func":"TEST_F(HttpConnectionManagerImplTest, 100ContinueResponse) {\n  proxy_100_continue_ = true;\n  setup(false, \"envoy-custom-server\", false);\n\n  \/\/ Store the basic request encoder during filter chain setup.\n  std::shared_ptr<MockStreamDecoderFilter> filter(new NiceMock<MockStreamDecoderFilter>());\n\n  EXPECT_CALL(*filter, decodeHeaders(_, true))\n      .WillRepeatedly(Invoke([&](RequestHeaderMap& headers, bool) -> FilterHeadersStatus {\n        EXPECT_NE(nullptr, headers.ForwardedFor());\n        EXPECT_EQ(\"http\", headers.getForwardedProtoValue());\n        return FilterHeadersStatus::StopIteration;\n      }));\n\n  EXPECT_CALL(*filter, setDecoderFilterCallbacks(_));\n\n  EXPECT_CALL(filter_factory_, createFilterChain(_))\n      .WillRepeatedly(Invoke([&](FilterChainFactoryCallbacks& callbacks) -> void {\n        callbacks.addStreamDecoderFilter(filter);\n      }));\n\n  EXPECT_CALL(filter_callbacks_.connection_.dispatcher_, deferredDelete_(_));\n\n  \/\/ When dispatch is called on the codec, we pretend to get a new stream and then fire a headers\n  \/\/ only request into it. Then we respond into the filter.\n  EXPECT_CALL(*codec_, dispatch(_))\n      .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> Http::Status {\n        decoder_ = &conn_manager_->newStream(response_encoder_);\n\n        \/\/ Test not charging stats on the second call.\n        RequestHeaderMapPtr headers{new TestRequestHeaderMapImpl{\n            {\":authority\", \"host\"}, {\":path\", \"\/\"}, {\":method\", \"GET\"}}};\n        decoder_->decodeHeaders(std::move(headers), true);\n\n        ResponseHeaderMapPtr continue_headers{new TestResponseHeaderMapImpl{{\":status\", \"100\"}}};\n        filter->callbacks_->encode100ContinueHeaders(std::move(continue_headers));\n        ResponseHeaderMapPtr response_headers{new TestResponseHeaderMapImpl{{\":status\", \"200\"}}};\n        filter->callbacks_->streamInfo().setResponseCodeDetails(\"\");\n        filter->callbacks_->encodeHeaders(std::move(response_headers), true, \"details\");\n\n        data.drain(4);\n        return Http::okStatus();\n      }));\n\n  \/\/ Kick off the incoming data.\n  Buffer::OwnedImpl fake_input(\"1234\");\n  conn_manager_->onData(fake_input, false);\n\n  EXPECT_EQ(1U, stats_.named_.downstream_rq_1xx_.value());\n  EXPECT_EQ(1U, listener_stats_.downstream_rq_1xx_.value());\n  EXPECT_EQ(1U, stats_.named_.downstream_rq_2xx_.value());\n  EXPECT_EQ(1U, listener_stats_.downstream_rq_2xx_.value());\n  EXPECT_EQ(2U, stats_.named_.downstream_rq_completed_.value());\n  EXPECT_EQ(2U, listener_stats_.downstream_rq_completed_.value());\n}","target":0,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":298959,"func":"Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32*level, u32 *batteryLifeTime, u32 *batteryFullLifeTime)\n{\n#if defined(_WIN32_WCE)\n\tSYSTEM_POWER_STATUS_EX sps;\n\tGetSystemPowerStatusEx(&sps, 0);\n\tif (onBattery) *onBattery = sps.ACLineStatus ? 0 : 1;\n\tif (onCharge) *onCharge = (sps.BatteryFlag & BATTERY_FLAG_CHARGING) ? 1 : 0;\n\tif (level) *level = sps.BatteryLifePercent;\n\tif (batteryLifeTime) *batteryLifeTime = sps.BatteryLifeTime;\n\tif (batteryFullLifeTime) *batteryFullLifeTime = sps.BatteryFullLifeTime;\n#elif defined(WIN32)\n\tSYSTEM_POWER_STATUS sps;\n\tGetSystemPowerStatus(&sps);\n\tif (onBattery) *onBattery = sps.ACLineStatus ? GF_FALSE : GF_TRUE;\n\tif (onCharge) *onCharge = (sps.BatteryFlag & BATTERY_FLAG_CHARGING) ? 1 : 0;\n\tif (level) *level = sps.BatteryLifePercent;\n\tif (batteryLifeTime) *batteryLifeTime = sps.BatteryLifeTime;\n\tif (batteryFullLifeTime) *batteryFullLifeTime = sps.BatteryFullLifeTime;\n#endif\n\treturn GF_TRUE;\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":420805,"func":"http_open (http_t *r_hd, http_req_t reqtype, const char *url,\n           const char *httphost,\n           const char *auth, unsigned int flags, const char *proxy,\n           http_session_t session, const char *srvtag, strlist_t headers)\n{\n  gpg_error_t err;\n  http_t hd;\n\n  *r_hd = NULL;\n\n  if (!(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST))\n    return gpg_err_make (default_errsource, GPG_ERR_INV_ARG);\n\n  \/* Create the handle. *\/\n  hd = xtrycalloc (1, sizeof *hd);\n  if (!hd)\n    return gpg_error_from_syserror ();\n  hd->magic = HTTP_CONTEXT_MAGIC;\n  hd->req_type = reqtype;\n  hd->flags = flags;\n  hd->session = http_session_ref (session);\n\n  err = parse_uri (&hd->uri, url, 0, !!(flags & HTTP_FLAG_FORCE_TLS));\n  if (!err)\n    err = send_request (hd, httphost, auth, proxy, srvtag,\n                        hd->session? hd->session->connect_timeout : 0,\n                        headers);\n\n  if (err)\n    {\n      my_socket_unref (hd->sock, NULL, NULL);\n      if (hd->fp_read)\n        es_fclose (hd->fp_read);\n      if (hd->fp_write)\n        es_fclose (hd->fp_write);\n      http_session_unref (hd->session);\n      xfree (hd);\n    }\n  else\n    *r_hd = hd;\n  return err;\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":272398,"func":"static void sdma_desc_avail(struct sdma_engine *sde, uint avail)\n{\n\tstruct iowait *wait, *nw, *twait;\n\tstruct iowait *waits[SDMA_WAIT_BATCH_SIZE];\n\tuint i, n = 0, seq, tidx = 0;\n\n#ifdef CONFIG_SDMA_VERBOSITY\n\tdd_dev_err(sde->dd, \"CONFIG SDMA(%u) %s:%d %s()\\n\", sde->this_idx,\n\t\t   slashstrip(__FILE__), __LINE__, __func__);\n\tdd_dev_err(sde->dd, \"avail: %u\\n\", avail);\n#endif\n\n\tdo {\n\t\tseq = read_seqbegin(&sde->waitlock);\n\t\tif (!list_empty(&sde->dmawait)) {\n\t\t\t\/* at least one item *\/\n\t\t\twrite_seqlock(&sde->waitlock);\n\t\t\t\/* Harvest waiters wanting DMA descriptors *\/\n\t\t\tlist_for_each_entry_safe(\n\t\t\t\t\twait,\n\t\t\t\t\tnw,\n\t\t\t\t\t&sde->dmawait,\n\t\t\t\t\tlist) {\n\t\t\t\tu32 num_desc;\n\n\t\t\t\tif (!wait->wakeup)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (n == ARRAY_SIZE(waits))\n\t\t\t\t\tbreak;\n\t\t\t\tiowait_init_priority(wait);\n\t\t\t\tnum_desc = iowait_get_all_desc(wait);\n\t\t\t\tif (num_desc > avail)\n\t\t\t\t\tbreak;\n\t\t\t\tavail -= num_desc;\n\t\t\t\t\/* Find the top-priority wait memeber *\/\n\t\t\t\tif (n) {\n\t\t\t\t\ttwait = waits[tidx];\n\t\t\t\t\ttidx =\n\t\t\t\t\t    iowait_priority_update_top(wait,\n\t\t\t\t\t\t\t\t       twait,\n\t\t\t\t\t\t\t\t       n,\n\t\t\t\t\t\t\t\t       tidx);\n\t\t\t\t}\n\t\t\t\tlist_del_init(&wait->list);\n\t\t\t\twaits[n++] = wait;\n\t\t\t}\n\t\t\twrite_sequnlock(&sde->waitlock);\n\t\t\tbreak;\n\t\t}\n\t} while (read_seqretry(&sde->waitlock, seq));\n\n\t\/* Schedule the top-priority entry first *\/\n\tif (n)\n\t\twaits[tidx]->wakeup(waits[tidx], SDMA_AVAIL_REASON);\n\n\tfor (i = 0; i < n; i++)\n\t\tif (i != tidx)\n\t\t\twaits[i]->wakeup(waits[i], SDMA_AVAIL_REASON);\n}","target":0,"code_token_length":465,"total_token_length":701,"max_tokens_setting":1024}
+{"idx":121485,"func":"SpoolssReplyOpenPrinter_r(tvbuff_t *tvb, int offset,\n\t\t\t\t     packet_info *pinfo, proto_tree *tree,\n\t\t\t\t     dcerpc_info *di, guint8 *drep _U_)\n{\n\tdcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data;\n\te_ctx_hnd policy_hnd;\n\tproto_item *hnd_item;\n\tguint32 status;\n\n\t\/* Parse packet *\/\n\n\toffset = dissect_nt_policy_hnd(\n\t\ttvb, offset, pinfo, tree, di, drep, hf_hnd, &policy_hnd, &hnd_item,\n\t\tTRUE, FALSE);\n\n\toffset = dissect_doserror(\n\t\ttvb, offset, pinfo, tree, di, drep, hf_rc, &status);\n\n\tif( status == 0 ){\n\t\tconst char *pol_name;\n\n\t\tif (dcv->se_data){\n\t\t\tpol_name = wmem_strdup_printf(wmem_packet_scope(),\n\t\t\t\t\"ReplyOpenPrinter(%s)\", (char *)dcv->se_data);\n\t\t} else {\n\t\t\tpol_name = \"Unknown ReplyOpenPrinter() handle\";\n\t\t}\n\t\tif(!pinfo->fd->flags.visited){\n\t\t\tdcerpc_store_polhnd_name(&policy_hnd, pinfo, pol_name);\n\t\t}\n\n\t\tif(hnd_item)\n\t\t\tproto_item_append_text(hnd_item, \": %s\", pol_name);\n\t}\n\n\treturn offset;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":332239,"func":"static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,\n\n                             const AVFrame *pict, int *got_packet)\n\n{\n\n    SVQ1EncContext *const s = avctx->priv_data;\n\n    AVFrame *const p        = avctx->coded_frame;\n\n    int i, ret;\n\n\n\n    if (!pkt->data &&\n\n        (ret = av_new_packet(pkt, s->y_block_width * s->y_block_height *\n\n                             MAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE)) < 0) {\n\n        av_log(avctx, AV_LOG_ERROR, \"Error getting output packet.\\n\");\n\n        return ret;\n\n    }\n\n\n\n    if (avctx->pix_fmt != AV_PIX_FMT_YUV410P) {\n\n        av_log(avctx, AV_LOG_ERROR, \"unsupported pixel format\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (!s->current_picture->data[0]) {\n\n        ret = ff_get_buffer(avctx, s->current_picture, 0);\n\n        if (ret < 0)\n\n            return ret;\n\n    }\n\n    if (!s->last_picture->data[0]) {\n\n        ret = ff_get_buffer(avctx, s->last_picture, 0);\n\n        if (ret < 0)\n\n            return ret;\n\n    }\n\n    if (!s->scratchbuf) {\n\n        s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 2);\n\n        if (!s->scratchbuf)\n\n            return AVERROR(ENOMEM);\n\n    }\n\n\n\n    FFSWAP(AVFrame*, s->current_picture, s->last_picture);\n\n\n\n    init_put_bits(&s->pb, pkt->data, pkt->size);\n\n\n\n    p->pict_type = avctx->gop_size && avctx->frame_number % avctx->gop_size ?\n\n                   AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;\n\n    p->key_frame = p->pict_type == AV_PICTURE_TYPE_I;\n\n    p->quality   = pict->quality;\n\n\n\n    svq1_write_header(s, p->pict_type);\n\n    for (i = 0; i < 3; i++)\n\n        if (svq1_encode_plane(s, i,\n\n                              pict->data[i],\n\n                              s->last_picture->data[i],\n\n                              s->current_picture->data[i],\n\n                              s->frame_width  \/ (i ? 4 : 1),\n\n                              s->frame_height \/ (i ? 4 : 1),\n\n                              pict->linesize[i],\n\n                              s->current_picture->linesize[i]) < 0)\n\n            return -1;\n\n\n\n    \/\/ avpriv_align_put_bits(&s->pb);\n\n    while (put_bits_count(&s->pb) & 31)\n\n        put_bits(&s->pb, 1, 0);\n\n\n\n    flush_put_bits(&s->pb);\n\n\n\n    pkt->size = put_bits_count(&s->pb) \/ 8;\n\n    if (p->pict_type == AV_PICTURE_TYPE_I)\n\n        pkt->flags |= AV_PKT_FLAG_KEY;\n\n    *got_packet = 1;\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":653,"total_token_length":889,"max_tokens_setting":1024}
+{"idx":447508,"func":"smtp_rset (CamelSmtpTransport *transport,\n\t   CamelStreamBuffer *istream,\n\t   CamelStream *ostream,\n           GCancellable *cancellable,\n           GError **error)\n{\n\t\/* we are going to reset the smtp server (just to be nice) *\/\n\tgchar *cmdbuf, *respbuf = NULL;\n\n\tcmdbuf = g_strdup (\"RSET\\r\\n\");\n\n\td (fprintf (stderr, \"[SMTP] sending: %s\", cmdbuf));\n\n\tif (camel_stream_write_string (ostream, cmdbuf, cancellable, error) == -1) {\n\t\tg_free (cmdbuf);\n\t\tg_prefix_error (error, _(\"RSET command failed: \"));\n\t\tcamel_service_disconnect_sync (\n\t\t\tCAMEL_SERVICE (transport),\n\t\t\tFALSE, cancellable, NULL);\n\t\treturn FALSE;\n\t}\n\tg_free (cmdbuf);\n\n\tdo {\n\t\t\/* Check for \"250\" *\/\n\t\tg_free (respbuf);\n\t\trespbuf = camel_stream_buffer_read_line (istream, cancellable, error);\n\t\td (fprintf (stderr, \"[SMTP] received: %s\\n\", respbuf ? respbuf : \"(null)\"));\n\t\tif (respbuf == NULL) {\n\t\t\tg_prefix_error (error, _(\"RSET command failed: \"));\n\t\t\tcamel_service_disconnect_sync (\n\t\t\t\tCAMEL_SERVICE (transport),\n\t\t\t\tFALSE, cancellable, NULL);\n\t\t\treturn FALSE;\n\t\t}\n\t\tif (strncmp (respbuf, \"250\", 3) != 0) {\n\t\t\tsmtp_set_error (transport, istream, respbuf, cancellable, error);\n\t\t\tg_prefix_error (error, _(\"RSET command failed: \"));\n\t\t\tg_free (respbuf);\n\t\t\treturn FALSE;\n\t\t}\n\t} while (*(respbuf+3) == '-'); \/* if we got \"250-\" then loop again *\/\n\tg_free (respbuf);\n\n\treturn TRUE;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":414674,"func":"ext4_find_extent(struct inode *inode, ext4_lblk_t block,\n\t\t struct ext4_ext_path **orig_path, int flags)\n{\n\tstruct ext4_extent_header *eh;\n\tstruct buffer_head *bh;\n\tstruct ext4_ext_path *path = orig_path ? *orig_path : NULL;\n\tshort int depth, i, ppos = 0;\n\tint ret;\n\n\teh = ext_inode_hdr(inode);\n\tdepth = ext_depth(inode);\n\tif (depth < 0 || depth > EXT4_MAX_EXTENT_DEPTH) {\n\t\tEXT4_ERROR_INODE(inode, \"inode has invalid extent depth: %d\",\n\t\t\t\t depth);\n\t\tret = -EFSCORRUPTED;\n\t\tgoto err;\n\t}\n\n\tif (path) {\n\t\text4_ext_drop_refs(path);\n\t\tif (depth > path[0].p_maxdepth) {\n\t\t\tkfree(path);\n\t\t\t*orig_path = path = NULL;\n\t\t}\n\t}\n\tif (!path) {\n\t\t\/* account possible depth increase *\/\n\t\tpath = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),\n\t\t\t\tGFP_NOFS);\n\t\tif (unlikely(!path))\n\t\t\treturn ERR_PTR(-ENOMEM);\n\t\tpath[0].p_maxdepth = depth + 1;\n\t}\n\tpath[0].p_hdr = eh;\n\tpath[0].p_bh = NULL;\n\n\ti = depth;\n\t\/* walk through the tree *\/\n\twhile (i) {\n\t\text_debug(\"depth %d: num %d, max %d\\n\",\n\t\t\t  ppos, le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max));\n\n\t\text4_ext_binsearch_idx(inode, path + ppos, block);\n\t\tpath[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx);\n\t\tpath[ppos].p_depth = i;\n\t\tpath[ppos].p_ext = NULL;\n\n\t\tbh = read_extent_tree_block(inode, path[ppos].p_block, --i,\n\t\t\t\t\t    flags);\n\t\tif (IS_ERR(bh)) {\n\t\t\tret = PTR_ERR(bh);\n\t\t\tgoto err;\n\t\t}\n\n\t\teh = ext_block_hdr(bh);\n\t\tppos++;\n\t\tpath[ppos].p_bh = bh;\n\t\tpath[ppos].p_hdr = eh;\n\t}\n\n\tpath[ppos].p_depth = i;\n\tpath[ppos].p_ext = NULL;\n\tpath[ppos].p_idx = NULL;\n\n\t\/* find extent *\/\n\text4_ext_binsearch(inode, path + ppos, block);\n\t\/* if not an empty leaf *\/\n\tif (path[ppos].p_ext)\n\t\tpath[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);\n\n\text4_ext_show_path(inode, path);\n\n\treturn path;\n\nerr:\n\text4_ext_drop_refs(path);\n\tkfree(path);\n\tif (orig_path)\n\t\t*orig_path = NULL;\n\treturn ERR_PTR(ret);\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":371420,"func":"void ZrtpStateClass::evWaitConfirm2(void) {\n\n    DEBUGOUT((cout << \"Checking for match in WaitConfirm2.\\n\"));\n\n    char *msg, first, secondLast, last;\n    uint8_t *pkt;\n    uint32_t errorCode = 0;\n\n    if (event->type == ZrtpPacket) {\n        pkt = event->packet;\n        msg = (char *)pkt + 4;\n\n        first = tolower(*msg);\n        secondLast = tolower(*(msg+6));\n        last = tolower(*(msg+7));\n\n        \/*\n         * DHPart2 or Commit in multi stream mode:\n         * - resend Confirm1 packet\n         * - stay in state\n         *\/\n        if ((first == 'd' && secondLast == '2') || (multiStream && (first == 'c' && last == ' '))) {\n            if (!parent->sendPacketZRTP(sentPacket)) {\n                sendFailed();             \/\/ returns to state Initial\n            }\n            return;\n        }\n        \/*\n         * Confirm2:\n         * - prepare ConfAck\n         * - switch on security (SRTP)\n         * - switch to SecureState\n         *\/\n        if (first == 'c' && last == '2') {\n            ZrtpPacketConfirm cpkt(pkt);\n            ZrtpPacketConf2Ack* confack = parent->prepareConf2Ack(&cpkt, &errorCode);\n\n            \/\/ Something went wrong during processing of the confirm2 packet\n            if (confack == NULL) {\n                sendErrorPacket(errorCode);\n                return;\n            }\n            sentPacket = static_cast<ZrtpPacketBase *>(confack);\n\n            if (!parent->sendPacketZRTP(sentPacket)) {\n                sendFailed();             \/\/ returns to state Initial\n                return;\n            }\n            if (!parent->srtpSecretsReady(ForReceiver) || !parent->srtpSecretsReady(ForSender))  {\n                parent->sendInfo(Severe, CriticalSWError);\n                sendErrorPacket(CriticalSWError);\n                return;\n            }\n            nextState(SecureState);\n            parent->sendInfo(Info, InfoSecureStateOn);\n        }\n    }\n    else {  \/\/ unknown Event type for this state (covers Error and ZrtpClose)\n        if (event->type != ZrtpClose) {\n            parent->zrtpNegotiationFailed(Severe, SevereProtocolError);\n        }\n        sentPacket = NULL;\n        nextState(Initial);\n    }\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":418742,"func":"amgtar_selfcheck(\n    application_argument_t *argument)\n{\n    char *option;\n\n    if (argument->dle.disk) {\n\tchar *qdisk = quote_string(argument->dle.disk);\n\tfprintf(stdout, \"OK disk %s\\n\", qdisk);\n\tamfree(qdisk);\n    }\n\n    printf(\"OK amgtar version %s\\n\", VERSION);\n    amgtar_build_exinclude(&argument->dle, 1, NULL, NULL, NULL, NULL);\n\n    printf(\"OK amgtar\\n\");\n\n\n    if ((option = validate_command_options(argument))) {\n\tfprintf(stdout, \"ERROR [Invalid '%s' COMMAND-OPTIONS\\n\", option);\n    }\n\n    if (gnutar_path) {\n\tchar *gnutar_realpath = NULL;\n\tif (check_file(gnutar_path, X_OK) &&\n\t    check_exec_for_suid(\"GNUTAR_PATH\", gnutar_path, stdout, &gnutar_realpath)) {\n\t    char *gtar_version;\n\t    GPtrArray *argv_ptr = g_ptr_array_new();\n\n\t    g_ptr_array_add(argv_ptr, gnutar_realpath);\n\t    g_ptr_array_add(argv_ptr, \"--version\");\n\t    g_ptr_array_add(argv_ptr, NULL);\n\n\t    gtar_version = get_first_line(argv_ptr);\n\t    if (gtar_version) {\n\t\tchar *gv;\n\t\tfor (gv = gtar_version; *gv && !g_ascii_isdigit(*gv); gv++);\n\t\tprintf(\"OK amgtar gtar-version %s\\n\", gv);\n\t    } else {\n\t\tprintf(_(\"ERROR [Can't get %s version]\\n\"), gnutar_realpath);\n\t    }\n\n\t    g_ptr_array_free(argv_ptr, TRUE);\n\t    amfree(gtar_version);\n\t}\n\tamfree(gnutar_realpath);\n    } else {\n\tprintf(_(\"ERROR [GNUTAR program not available]\\n\"));\n    }\n    if (gnutar_listdir && strlen(gnutar_listdir) == 0)\n\tgnutar_listdir = NULL;\n    if (gnutar_listdir) {\n\tcheck_dir(gnutar_listdir, R_OK|W_OK);\n    } else {\n\tprintf(_(\"ERROR [No GNUTAR-LISTDIR]\\n\"));\n    }\n\n    set_root_privs(1);\n    if (gnutar_directory) {\n\tcheck_dir(gnutar_directory, R_OK);\n    } else if (argument->dle.device) {\n\tcheck_dir(argument->dle.device, R_OK);\n    }\n    if (argument->calcsize) {\n\tchar *calcsize = vstralloc(amlibexecdir, \"\/\", \"calcsize\", NULL);\n\tcheck_file(calcsize, X_OK);\n\tcheck_suid(calcsize);\n\tamfree(calcsize);\n    }\n    set_root_privs(0);\n}","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":138394,"func":"point_inside(Point *p, int npts, Point *plist)\n{\n\tdouble\t\tx0,\n\t\t\t\ty0;\n\tdouble\t\tprev_x,\n\t\t\t\tprev_y;\n\tint\t\t\ti = 0;\n\tdouble\t\tx,\n\t\t\t\ty;\n\tint\t\t\tcross,\n\t\t\t\ttotal_cross = 0;\n\n\tif (npts <= 0)\n\t\treturn 0;\n\n\t\/* compute first polygon point relative to single point *\/\n\tx0 = plist[0].x - p->x;\n\ty0 = plist[0].y - p->y;\n\n\tprev_x = x0;\n\tprev_y = y0;\n\t\/* loop over polygon points and aggregate total_cross *\/\n\tfor (i = 1; i < npts; i++)\n\t{\n\t\t\/* compute next polygon point relative to single point *\/\n\t\tx = plist[i].x - p->x;\n\t\ty = plist[i].y - p->y;\n\n\t\t\/* compute previous to current point crossing *\/\n\t\tif ((cross = lseg_crossing(x, y, prev_x, prev_y)) == POINT_ON_POLYGON)\n\t\t\treturn 2;\n\t\ttotal_cross += cross;\n\n\t\tprev_x = x;\n\t\tprev_y = y;\n\t}\n\n\t\/* now do the first point *\/\n\tif ((cross = lseg_crossing(x0, y0, prev_x, prev_y)) == POINT_ON_POLYGON)\n\t\treturn 2;\n\ttotal_cross += cross;\n\n\tif (total_cross != 0)\n\t\treturn 1;\n\treturn 0;\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":124875,"func":"static int doport3(const int protocol)\n{\n    struct sockaddr_storage dataconn;  \/* his endpoint *\/\n\n# ifndef NON_ROOT_FTP\n    static const in_port_t portlist[] = FTP_ACTIVE_SOURCE_PORTS;\n    const in_port_t *portlistpnt = portlist;\n# else\n    static const in_port_t portlist[] = { 0U };\n    const in_port_t *portlistpnt = portlist;\n# endif\n    int on;\n\n# ifndef NON_ROOT_FTP\n    disablesignals();\n    seteuid((uid_t) 0);\n# endif\n    if ((datafd = socket(protocol, SOCK_STREAM, IPPROTO_TCP)) == -1) {\n        data_socket_error:\n# ifndef NON_ROOT_FTP\n        if (seteuid(authresult.uid) != 0) {\n            _EXIT(EXIT_FAILURE);\n        }\n        enablesignals();\n# endif\n        (void) close(datafd);\n        datafd = -1;\n        error(425, MSG_CANT_CREATE_DATA_SOCKET);\n\n        return -1;\n    }\n    on = 1;\n# ifdef SO_REUSEPORT\n    (void) setsockopt(datafd, SOL_SOCKET, SO_REUSEPORT,\n                      (char *) &on, sizeof on);\n# else\n    (void) setsockopt(datafd, SOL_SOCKET, SO_REUSEADDR,\n                      (char *) &on, sizeof on);\n# endif\n    memcpy(&dataconn, &ctrlconn, sizeof dataconn);\n    for (;;) {\n        if (STORAGE_FAMILY(dataconn) == AF_INET6) {\n            STORAGE_PORT6(dataconn) = htons(*portlistpnt);\n        } else {\n            STORAGE_PORT(dataconn) = htons(*portlistpnt);\n        }\n        if (bind(datafd, (struct sockaddr *) &dataconn,\n                 STORAGE_LEN(dataconn)) == 0) {\n            break;\n        }\n# ifdef USE_ONLY_FIXED_DATA_PORT\n        (void) sleep(1U);\n# else\n        if (*portlistpnt == (in_port_t) 0U) {\n            goto data_socket_error;\n        }\n        portlistpnt++;\n# endif\n    }\n# ifndef NON_ROOT_FTP\n    if (seteuid(authresult.uid) != 0) {\n        _EXIT(EXIT_FAILURE);\n    }\n    enablesignals();\n# endif\n\n    return 0;\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":463758,"func":"void intel_pmu_pebs_enable(struct perf_event *event)\n{\n\tstruct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tstruct debug_store *ds = cpuc->ds;\n\n\thwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;\n\n\tcpuc->pebs_enabled |= 1ULL << hwc->idx;\n\n\tif ((event->hw.flags & PERF_X86_EVENT_PEBS_LDLAT) && (x86_pmu.version < 5))\n\t\tcpuc->pebs_enabled |= 1ULL << (hwc->idx + 32);\n\telse if (event->hw.flags & PERF_X86_EVENT_PEBS_ST)\n\t\tcpuc->pebs_enabled |= 1ULL << 63;\n\n\tif (x86_pmu.intel_cap.pebs_baseline) {\n\t\thwc->config |= ICL_EVENTSEL_ADAPTIVE;\n\t\tif (cpuc->pebs_data_cfg != cpuc->active_pebs_data_cfg) {\n\t\t\twrmsrl(MSR_PEBS_DATA_CFG, cpuc->pebs_data_cfg);\n\t\t\tcpuc->active_pebs_data_cfg = cpuc->pebs_data_cfg;\n\t\t}\n\t}\n\n\t\/*\n\t * Use auto-reload if possible to save a MSR write in the PMI.\n\t * This must be done in pmu::start(), because PERF_EVENT_IOC_PERIOD.\n\t *\/\n\tif (hwc->flags & PERF_X86_EVENT_AUTO_RELOAD) {\n\t\tunsigned int idx = hwc->idx;\n\n\t\tif (idx >= INTEL_PMC_IDX_FIXED)\n\t\t\tidx = MAX_PEBS_EVENTS + (idx - INTEL_PMC_IDX_FIXED);\n\t\tds->pebs_event_reset[idx] =\n\t\t\t(u64)(-hwc->sample_period) & x86_pmu.cntval_mask;\n\t} else {\n\t\tds->pebs_event_reset[hwc->idx] = 0;\n\t}\n\n\tintel_pmu_pebs_via_pt_enable(event);\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":441424,"func":"void RGWPostObj_ObjStore_S3::send_response()\n{\n  if (op_ret == 0 && parts.count(\"success_action_redirect\")) {\n    string redirect;\n\n    part_str(parts, \"success_action_redirect\", &redirect);\n\n    string tenant;\n    string bucket;\n    string key;\n    string etag_str = \"\\\"\";\n\n    etag_str.append(etag);\n    etag_str.append(\"\\\"\");\n\n    string etag_url;\n\n    url_encode(s->bucket_tenant, tenant); \/* surely overkill, but cheap *\/\n    url_encode(s->bucket_name, bucket);\n    url_encode(s->object.name, key);\n    url_encode(etag_str, etag_url);\n\n    if (!s->bucket_tenant.empty()) {\n      \/*\n       * What we really would like is to quaily the bucket name, so\n       * that the client could simply copy it and paste into next request.\n       * Unfortunately, in S3 we cannot know if the client will decide\n       * to come through DNS, with \"bucket.tenant\" sytanx, or through\n       * URL with \"tenant\\bucket\" syntax. Therefore, we provide the\n       * tenant separately.\n       *\/\n      redirect.append(\"?tenant=\");\n      redirect.append(tenant);\n      redirect.append(\"&bucket=\");\n      redirect.append(bucket);\n    } else {\n      redirect.append(\"?bucket=\");\n      redirect.append(bucket);\n    }\n    redirect.append(\"&key=\");\n    redirect.append(key);\n    redirect.append(\"&etag=\");\n    redirect.append(etag_url);\n\n    int r = check_utf8(redirect.c_str(), redirect.size());\n    if (r < 0) {\n      op_ret = r;\n      goto done;\n    }\n    dump_redirect(s, redirect);\n    op_ret = STATUS_REDIRECT;\n  } else if (op_ret == 0 && parts.count(\"success_action_status\")) {\n    string status_string;\n    uint32_t status_int;\n\n    part_str(parts, \"success_action_status\", &status_string);\n\n    int r = stringtoul(status_string, &status_int);\n    if (r < 0) {\n      op_ret = r;\n      goto done;\n    }\n\n    switch (status_int) {\n      case 200:\n\tbreak;\n      case 201:\n\top_ret = STATUS_CREATED;\n\tbreak;\n      default:\n\top_ret = STATUS_NO_CONTENT;\n\tbreak;\n    }\n  } else if (! op_ret) {\n    op_ret = STATUS_NO_CONTENT;\n  }\n\ndone:\n  if (op_ret == STATUS_CREATED) {\n    for (auto &it : crypt_http_responses)\n      dump_header(s, it.first, it.second);\n    s->formatter->open_object_section(\"PostResponse\");\n    if (g_conf->rgw_dns_name.length())\n      s->formatter->dump_format(\"Location\", \"%s\/%s\",\n\t\t\t\ts->info.script_uri.c_str(),\n\t\t\t\ts->object.name.c_str());\n    if (!s->bucket_tenant.empty())\n      s->formatter->dump_string(\"Tenant\", s->bucket_tenant);\n    s->formatter->dump_string(\"Bucket\", s->bucket_name);\n    s->formatter->dump_string(\"Key\", s->object.name);\n    s->formatter->close_section();\n  }\n  s->err.message = err_msg;\n  set_req_state_err(s, op_ret);\n  dump_errno(s);\n  if (op_ret >= 0) {\n    dump_content_length(s, s->formatter->get_len());\n  }\n  end_header(s, this);\n  if (op_ret != STATUS_CREATED)\n    return;\n\n  rgw_flush_formatter_and_reset(s, s->formatter);\n}","target":0,"code_token_length":741,"total_token_length":977,"max_tokens_setting":1024}
+{"idx":136445,"func":"juniper_mlppp_print(netdissect_options *ndo,\n                    const struct pcap_pkthdr *h, register const u_char *p)\n{\n        struct juniper_l2info_t l2info;\n\n        l2info.pictype = DLT_JUNIPER_MLPPP;\n        if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n            return l2info.header_len;\n\n        \/* suppress Bundle-ID if frame was captured on a child-link\n         * best indicator if the cookie looks like a proto *\/\n        if (ndo->ndo_eflag &&\n            EXTRACT_16BITS(&l2info.cookie) != PPP_OSI &&\n            EXTRACT_16BITS(&l2info.cookie) !=  (PPP_ADDRESS << 8 | PPP_CONTROL))\n            ND_PRINT((ndo, \"Bundle-ID %u: \", l2info.bundle));\n\n        p+=l2info.header_len;\n\n        \/* first try the LSQ protos *\/\n        switch(l2info.proto) {\n        case JUNIPER_LSQ_L3_PROTO_IPV4:\n            \/* IP traffic going to the RE would not have a cookie\n             * -> this must be incoming IS-IS over PPP\n             *\/\n            if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR))\n                ppp_print(ndo, p, l2info.length);\n            else\n                ip_print(ndo, p, l2info.length);\n            return l2info.header_len;\n        case JUNIPER_LSQ_L3_PROTO_IPV6:\n            ip6_print(ndo, p,l2info.length);\n            return l2info.header_len;\n        case JUNIPER_LSQ_L3_PROTO_MPLS:\n            mpls_print(ndo, p, l2info.length);\n            return l2info.header_len;\n        case JUNIPER_LSQ_L3_PROTO_ISO:\n            isoclns_print(ndo, p, l2info.length);\n            return l2info.header_len;\n        default:\n            break;\n        }\n\n        \/* zero length cookie ? *\/\n        switch (EXTRACT_16BITS(&l2info.cookie)) {\n        case PPP_OSI:\n            ppp_print(ndo, p - 2, l2info.length + 2);\n            break;\n        case (PPP_ADDRESS << 8 | PPP_CONTROL): \/* fall through *\/\n        default:\n            ppp_print(ndo, p, l2info.length);\n            break;\n        }\n\n        return l2info.header_len;\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":378811,"func":"static SC_HTMLState sc_html_parse_tag(SC_HTMLParser *parser)\n{\n\tgchar buf[SC_HTMLBUFSIZE];\n\tSC_HTMLTag *tag;\n\n\tsc_html_get_parenthesis(parser, buf, sizeof(buf));\n\n\ttag = sc_html_get_tag(buf);\n\n\tparser->state = SC_HTML_UNKNOWN;\n\tif (!tag) return SC_HTML_UNKNOWN;\n\n\tif (!strcmp(tag->name, \"br\")) {\n\t\tparser->space = FALSE;\n\t\tsc_html_append_char(parser, '\\n');\n\t\tparser->state = SC_HTML_BR;\n\t} else if (!strcmp(tag->name, \"a\")) {\n\t\tGList *cur;\n\t\tfor (cur = tag->attr; cur != NULL; cur = cur->next) {\n\t\t\tif (cur->data && !strcmp(((SC_HTMLAttr *)cur->data)->name, \"href\")) {\n\t\t\t\tg_free(parser->href);\n\t\t\t\tparser->href = g_strdup(((SC_HTMLAttr *)cur->data)->value);\n\t\t\t\tdecode_href(parser);\n\t\t\t\tparser->state = SC_HTML_HREF_BEG;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(tag->name, \"\/a\")) {\n\t\tparser->state = SC_HTML_HREF;\n\t} else if (!strcmp(tag->name, \"p\")) {\n\t\tparser->space = FALSE;\n\t\tif (!parser->empty_line) {\n\t\t\tparser->space = FALSE;\n\t\t\tif (!parser->newline) sc_html_append_char(parser, '\\n');\n\t\t\tsc_html_append_char(parser, '\\n');\n\t\t}\n\t\tparser->state = SC_HTML_PAR;\n\t} else if (!strcmp(tag->name, \"pre\")) {\n\t\tparser->pre = TRUE;\n\t\tparser->state = SC_HTML_PRE;\n\t} else if (!strcmp(tag->name, \"\/pre\")) {\n\t\tparser->pre = FALSE;\n\t\tparser->state = SC_HTML_NORMAL;\n\t} else if (!strcmp(tag->name, \"hr\")) {\n\t\tif (!parser->newline) {\n\t\t\tparser->space = FALSE;\n\t\t\tsc_html_append_char(parser, '\\n');\n\t\t}\n\t\tsc_html_append_str(parser, HR_STR \"\\n\", -1);\n\t\tparser->state = SC_HTML_HR;\n\t} else if (!strcmp(tag->name, \"div\")    ||\n\t\t   !strcmp(tag->name, \"ul\")     ||\n\t\t   !strcmp(tag->name, \"li\")     ||\n\t\t   !strcmp(tag->name, \"table\")  ||\n\t\t   !strcmp(tag->name, \"tr\")     ||\n\t\t   (tag->name[0] == 'h' && g_ascii_isdigit(tag->name[1]))) {\n\t\tif (!parser->newline) {\n\t\t\tparser->space = FALSE;\n\t\t\tsc_html_append_char(parser, '\\n');\n\t\t}\n\t\tparser->state = SC_HTML_NORMAL;\n\t} else if (!strcmp(tag->name, \"\/table\") ||\n\t\t   (tag->name[0] == '\/' &&\n\t\t    tag->name[1] == 'h' &&\n\t\t    g_ascii_isdigit(tag->name[1]))) {\n\t\tif (!parser->empty_line) {\n\t\t\tparser->space = FALSE;\n\t\t\tif (!parser->newline) sc_html_append_char(parser, '\\n');\n\t\t\tsc_html_append_char(parser, '\\n');\n\t\t}\n\t\tparser->state = SC_HTML_NORMAL;\n\t} else if (!strcmp(tag->name, \"\/div\")   ||\n\t\t   !strcmp(tag->name, \"\/ul\")    ||\n\t\t   !strcmp(tag->name, \"\/li\")) {\n\t\tif (!parser->newline) {\n\t\t\tparser->space = FALSE;\n\t\t\tsc_html_append_char(parser, '\\n');\n\t\t}\n\t\tparser->state = SC_HTML_NORMAL;\n\t\t\t}\n\n\tsc_html_free_tag(tag);\n\n\treturn parser->state;\n}","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":224752,"func":"XvImageFormatValues * XvMCListSubpictureTypes (\n  Display * dpy,\n  XvPortID port,\n  int surface_type_id,\n  int *count_return\n)\n{\n    XExtDisplayInfo *info = xvmc_find_display(dpy);\n    xvmcListSubpictureTypesReply rep;\n    xvmcListSubpictureTypesReq  *req;\n    XvImageFormatValues *ret = NULL;\n\n\n    *count_return = 0;\n\n    XvMCCheckExtension (dpy, info, NULL);\n\n\n    LockDisplay (dpy);\n    XvMCGetReq (ListSubpictureTypes, req);\n    req->port = port;\n    req->surface_type_id = surface_type_id;\n    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {\n        UnlockDisplay (dpy);\n        SyncHandle ();\n        return NULL;\n    }\n\n    if(rep.num > 0) {\n        if (rep.num < (INT_MAX \/ sizeof(XvImageFormatValues)))\n            ret = Xmalloc(rep.num * sizeof(XvImageFormatValues));\n\n        if(ret) {\n            xvImageFormatInfo Info;\n            int i;\n\n            *count_return = rep.num;\n\n            for(i = 0; i < rep.num; i++) {\n              _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);\n              ret[i].id = Info.id;\n              ret[i].type = Info.type;\n              ret[i].byte_order = Info.byte_order;\n              memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);\n              ret[i].bits_per_pixel = Info.bpp;\n              ret[i].format = Info.format;\n              ret[i].num_planes = Info.num_planes;\n              ret[i].depth = Info.depth;\n              ret[i].red_mask = Info.red_mask;\n              ret[i].green_mask = Info.green_mask;\n              ret[i].blue_mask = Info.blue_mask;\n              ret[i].y_sample_bits = Info.y_sample_bits;\n              ret[i].u_sample_bits = Info.u_sample_bits;\n              ret[i].v_sample_bits = Info.v_sample_bits;\n              ret[i].horz_y_period = Info.horz_y_period;\n              ret[i].horz_u_period = Info.horz_u_period;\n              ret[i].horz_v_period = Info.horz_v_period;\n              ret[i].vert_y_period = Info.vert_y_period;\n              ret[i].vert_u_period = Info.vert_u_period;\n              ret[i].vert_v_period = Info.vert_v_period;\n              memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);\n              ret[i].scanline_order = Info.scanline_order;\n            }\n        } else\n\t   _XEatDataWords(dpy, rep.length);\n    }\n\n    UnlockDisplay (dpy);\n    SyncHandle ();\n    return ret;\n}\n","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":416503,"func":"c_pdf14trans_is_closing(const gs_composite_t * composite_action, gs_composite_t ** ppcte,\n                        gx_device *dev)\n{\n    gs_pdf14trans_t *pct0 = (gs_pdf14trans_t *)composite_action;\n    int op0 = pct0->params.pdf14_op;\n\n    switch (op0) {\n        default: return_error(gs_error_unregistered); \/* Must not happen. *\/\n        case PDF14_PUSH_DEVICE:\n            return COMP_ENQUEUE;\n        case PDF14_ABORT_DEVICE:\n            return COMP_ENQUEUE;\n        case PDF14_POP_DEVICE:\n            if (*ppcte == NULL)\n                return COMP_ENQUEUE;\n            else {\n                gs_compositor_closing_state state = find_opening_op(PDF14_PUSH_DEVICE, ppcte, COMP_EXEC_IDLE);\n\n                if (state == COMP_EXEC_IDLE)\n                    return COMP_DROP_QUEUE;\n                return state;\n            }\n        case PDF14_BEGIN_TRANS_GROUP:\n            return COMP_ENQUEUE;\n        case PDF14_END_TRANS_GROUP:\n        case PDF14_END_TRANS_TEXT_GROUP:\n            if (*ppcte == NULL)\n                return COMP_EXEC_QUEUE;\n            return find_opening_op(PDF14_BEGIN_TRANS_GROUP, ppcte, COMP_MARK_IDLE);\n        case PDF14_BEGIN_TRANS_MASK:\n            return COMP_ENQUEUE;\n        case PDF14_PUSH_TRANS_STATE:\n            return COMP_ENQUEUE;\n        case PDF14_POP_TRANS_STATE:\n            return COMP_ENQUEUE;\n        case PDF14_PUSH_SMASK_COLOR:\n            return COMP_ENQUEUE;\n            break;\n        case PDF14_POP_SMASK_COLOR:\n            return COMP_ENQUEUE;\n            break;\n        case PDF14_END_TRANS_MASK:\n            if (*ppcte == NULL)\n                return COMP_EXEC_QUEUE;\n            return find_opening_op(PDF14_BEGIN_TRANS_MASK, ppcte, COMP_MARK_IDLE);\n        case PDF14_SET_BLEND_PARAMS:\n            if (*ppcte == NULL)\n                return COMP_ENQUEUE;\n            \/* hack : ignore csel - here it is always zero : *\/\n            return find_same_op(composite_action, PDF14_SET_BLEND_PARAMS, ppcte);\n    }\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":307612,"func":"CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const RenderLayer* layer) const\n{\n    RenderObject* renderer = layer->renderer();\n    CompositingReasons directReasons = CompositingReasonNone;\n\n    if (requiresCompositingForTransform(renderer))\n        directReasons |= CompositingReason3DTransform;\n\n    if (requiresCompositingForVideo(renderer))\n        directReasons |= CompositingReasonVideo;\n    else if (requiresCompositingForCanvas(renderer))\n        directReasons |= CompositingReasonCanvas;\n    else if (requiresCompositingForPlugin(renderer))\n        directReasons |= CompositingReasonPlugin;\n    else if (requiresCompositingForFrame(renderer))\n        directReasons |= CompositingReasonIFrame;\n\n    if (requiresCompositingForBackfaceVisibilityHidden(renderer))\n        directReasons |= CompositingReasonBackfaceVisibilityHidden;\n\n    if (requiresCompositingForAnimation(renderer))\n        directReasons |= CompositingReasonAnimation;\n\n    if (requiresCompositingForTransition(renderer))\n        directReasons |= CompositingReasonAnimation;\n\n    if (requiresCompositingForFilters(renderer))\n        directReasons |= CompositingReasonFilters;\n\n    if (requiresCompositingForPosition(renderer, layer))\n        directReasons |= renderer->style()->position() == FixedPosition ? CompositingReasonPositionFixed : CompositingReasonPositionSticky;\n\n    if (requiresCompositingForOverflowScrolling(layer))\n        directReasons |= CompositingReasonOverflowScrollingTouch;\n\n    if (requiresCompositingForOverflowScrollingParent(layer))\n        directReasons |= CompositingReasonOverflowScrollingParent;\n\n    if (requiresCompositingForOutOfFlowClipping(layer))\n        directReasons |= CompositingReasonOutOfFlowClipping;\n\n    return directReasons;\n}\n","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":230818,"func":"bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) {\n size_t oldSize = mSize;\n\n size_t offset = 0;\n while (mSize >= 10 && offset <= mSize - 10) {\n if (!memcmp(&mData[offset], \"\\0\\0\\0\\0\", 4)) {\n break;\n }\n\n size_t dataSize;\n if (iTunesHack) {\n            dataSize = U32_AT(&mData[offset + 4]);\n } else if (!ParseSyncsafeInteger(&mData[offset + 4], &dataSize)) {\n return false;\n }\n\n if (dataSize > mSize - 10 - offset) {\n return false;\n }\n\n uint16_t flags = U16_AT(&mData[offset + 8]);\n uint16_t prevFlags = flags;\n\n if (flags & 1) {\n\n if (mSize < 14 || mSize - 14 < offset || dataSize < 4) {\n return false;\n }\n            memmove(&mData[offset + 10], &mData[offset + 14], mSize - offset - 14);\n            mSize -= 4;\n            dataSize -= 4;\n\n            flags &= ~1;\n }\n\n if ((flags & 2) && (dataSize >= 2)) {\n\n size_t readOffset = offset + 11;\n size_t writeOffset = offset + 11;\n for (size_t i = 0; i + 1 < dataSize; ++i) {\n if (mData[readOffset - 1] == 0xff\n && mData[readOffset] == 0x00) {\n ++readOffset;\n\n                     --mSize;\n                     --dataSize;\n                 }\n                if (i + 1 < dataSize) {\n                    \/\/ Only move data if there's actually something to move.\n                    \/\/ This handles the special case of the data being only [0xff, 0x00]\n                    \/\/ which should be converted to just 0xff if unsynchronization is on.\n                    mData[writeOffset++] = mData[readOffset++];\n                }\n             }\n             if (readOffset <= oldSize) {\n                memmove(&mData[writeOffset], &mData[readOffset], oldSize - readOffset);\n } else {\n                ALOGE(\"b\/34618607 (%zu %zu %zu %zu)\", readOffset, writeOffset, oldSize, mSize);\n                android_errorWriteLog(0x534e4554, \"34618607\");\n }\n\n }\n        flags &= ~2;\n if (flags != prevFlags || iTunesHack) {\n WriteSyncsafeInteger(&mData[offset + 4], dataSize);\n            mData[offset + 8] = flags >> 8;\n            mData[offset + 9] = flags & 0xff;\n }\n\n        offset += 10 + dataSize;\n }\n\n    memset(&mData[mSize], 0, oldSize - mSize);\n\n return true;\n}\n","target":0,"code_token_length":631,"total_token_length":867,"max_tokens_setting":1024}
+{"idx":218350,"func":"static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc)\n{\n    desc->ReadOnlyPrototype();\n\n    v8::Local<v8::Signature> defaultSignature;\n    defaultSignature = configureTemplate(desc, \"Float64Array\", V8ArrayBufferView::GetTemplate(), V8Float64Array::internalFieldCount,\n        0, 0,\n        0, 0);\n    UNUSED_PARAM(defaultSignature); \/\/ In some cases, it will not be used.\n    desc->SetCallHandler(V8Float64Array::constructorCallback);\n    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();\n    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();\n    UNUSED_PARAM(instance); \/\/ In some cases, it will not be used.\n    UNUSED_PARAM(proto); \/\/ In some cases, it will not be used.\n    \n\n    const int fooArgc = 1;\n    v8::Handle<v8::FunctionTemplate> fooArgv[fooArgc] = { V8Float32Array::GetRawTemplate() };\n    v8::Handle<v8::Signature> fooSignature = v8::Signature::New(desc, fooArgc, fooArgv);\n    proto->Set(v8::String::New(\"foo\"), v8::FunctionTemplate::New(Float64ArrayV8Internal::fooCallback, v8::Handle<v8::Value>(), fooSignature));\n\n    desc->Set(getToStringName(), getToStringTemplate());\n    return desc;\n}\n","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":190231,"func":"Tab::Tab(TabController* controller)\n    : controller_(controller),\n      title_(new views::Label()),\n      title_animation_(this) {\n  DCHECK(controller);\n\n  tab_style_ = TabStyleViews::CreateForTab(this);\n\n  set_notify_enter_exit_on_child(true);\n\n  SetID(VIEW_ID_TAB);\n\n  SetBorder(views::CreateEmptyBorder(tab_style()->GetContentsInsets()));\n\n  title_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);\n  title_->SetElideBehavior(gfx::FADE_TAIL);\n  title_->SetHandlesTooltips(false);\n  title_->SetAutoColorReadabilityEnabled(false);\n  title_->SetText(CoreTabHelper::GetDefaultTitle());\n  AddChildView(title_);\n\n  SetEventTargeter(std::make_unique<views::ViewTargeter>(this));\n\n  icon_ = new TabIcon;\n  AddChildView(icon_);\n\n  alert_indicator_ = new AlertIndicator(this);\n  AddChildView(alert_indicator_);\n\n  close_button_ = new TabCloseButton(\n      this, base::BindRepeating(&TabController::OnMouseEventInTab,\n                                base::Unretained(controller_)));\n  AddChildView(close_button_);\n  close_button_->AddObserver(this);\n\n  set_context_menu_controller(this);\n\n  title_animation_.SetDuration(base::TimeDelta::FromMilliseconds(100));\n\n  SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);\n  focus_ring_ = views::FocusRing::Install(this);\n}\n","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":153777,"func":"stack_double(int is_alloca, char** arg_alloc_base,\n             StackType** arg_stk_base, StackType** arg_stk_end, StackType** arg_stk,\n             MatchArg* msa)\n{\n  unsigned int n;\n  int used;\n  size_t size;\n  size_t new_size;\n  char* alloc_base;\n  char* new_alloc_base;\n  StackType *stk_base, *stk_end, *stk;\n\n  alloc_base = *arg_alloc_base;\n  stk_base = *arg_stk_base;\n  stk_end  = *arg_stk_end;\n  stk      = *arg_stk;\n\n  n = (unsigned int )(stk_end - stk_base);\n  size = sizeof(StackIndex) * msa->ptr_num + sizeof(StackType) * n;\n  n *= 2;\n  new_size = sizeof(StackIndex) * msa->ptr_num + sizeof(StackType) * n;\n  if (is_alloca != 0) {\n    new_alloc_base = (char* )xmalloc(new_size);\n    if (IS_NULL(new_alloc_base)) {\n      STACK_SAVE;\n      return ONIGERR_MEMORY;\n    }\n    xmemcpy(new_alloc_base, alloc_base, size);\n  }\n  else {\n    if (msa->match_stack_limit != 0 && n > msa->match_stack_limit) {\n      if ((unsigned int )(stk_end - stk_base) == msa->match_stack_limit)\n        return ONIGERR_MATCH_STACK_LIMIT_OVER;\n      else\n        n = msa->match_stack_limit;\n    }\n    new_alloc_base = (char* )xrealloc(alloc_base, new_size);\n    if (IS_NULL(new_alloc_base)) {\n      STACK_SAVE;\n      return ONIGERR_MEMORY;\n    }\n  }\n\n  alloc_base = new_alloc_base;\n  used = (int )(stk - stk_base);\n  *arg_alloc_base = alloc_base;\n  *arg_stk_base   = (StackType* )(alloc_base\n                                  + (sizeof(StackIndex) * msa->ptr_num));\n  *arg_stk      = *arg_stk_base + used;\n  *arg_stk_end  = *arg_stk_base + n;\n  return 0;\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":381480,"func":"set_debug (void)\n{\n  int numok = (debug_level && digitp (debug_level));\n  int numlvl = numok? atoi (debug_level) : 0;\n\n  if (!debug_level)\n    ;\n  else if (!strcmp (debug_level, \"none\") || (numok && numlvl < 1))\n    opt.debug = 0;\n  else if (!strcmp (debug_level, \"basic\") || (numok && numlvl <= 2))\n    opt.debug = DBG_ASSUAN_VALUE;\n  else if (!strcmp (debug_level, \"advanced\") || (numok && numlvl <= 5))\n    opt.debug = DBG_ASSUAN_VALUE|DBG_X509_VALUE;\n  else if (!strcmp (debug_level, \"expert\")  || (numok && numlvl <= 8))\n    opt.debug = (DBG_ASSUAN_VALUE|DBG_X509_VALUE\n                 |DBG_CACHE_VALUE|DBG_CRYPTO_VALUE);\n  else if (!strcmp (debug_level, \"guru\") || numok)\n    {\n      opt.debug = ~0;\n      \/* Unless the \"guru\" string has been used we don't want to allow\n         hashing debugging.  The rationale is that people tend to\n         select the highest debug value and would then clutter their\n         disk with debug files which may reveal confidential data.  *\/\n      if (numok)\n        opt.debug &= ~(DBG_HASHING_VALUE);\n    }\n  else\n    {\n      log_error (_(\"invalid debug-level '%s' given\\n\"), debug_level);\n      gpgsm_exit (2);\n    }\n\n  opt.debug |= debug_value;\n\n  if (opt.debug && !opt.verbose)\n    opt.verbose = 1;\n  if (opt.debug)\n    opt.quiet = 0;\n\n  if (opt.debug & DBG_MPI_VALUE)\n    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 2);\n  if (opt.debug & DBG_CRYPTO_VALUE )\n    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1);\n  gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);\n\n  if (opt.debug)\n    log_info (\"enabled debug flags:%s%s%s%s%s%s%s%s\\n\",\n              (opt.debug & DBG_X509_VALUE   )? \" x509\":\"\",\n              (opt.debug & DBG_MPI_VALUE    )? \" mpi\":\"\",\n              (opt.debug & DBG_CRYPTO_VALUE )? \" crypto\":\"\",\n              (opt.debug & DBG_MEMORY_VALUE )? \" memory\":\"\",\n              (opt.debug & DBG_CACHE_VALUE  )? \" cache\":\"\",\n              (opt.debug & DBG_MEMSTAT_VALUE)? \" memstat\":\"\",\n              (opt.debug & DBG_HASHING_VALUE)? \" hashing\":\"\",\n              (opt.debug & DBG_ASSUAN_VALUE )? \" assuan\":\"\" );\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":412022,"func":"relpTcpSetRemHost(relpTcp_t *pThis, struct sockaddr *pAddr)\n{\n\trelpEngine_t *pEngine;\n\tint error;\n\tunsigned char szIP[NI_MAXHOST] = \"\";\n\tunsigned char szHname[NI_MAXHOST] = \"\";\n\tstruct addrinfo hints, *res;\n\tsize_t len;\n\t\n\tENTER_RELPFUNC;\n\tRELPOBJ_assert(pThis, Tcp);\n\tpEngine = pThis->pEngine;\n\tassert(pAddr != NULL);\n\n\terror = getnameinfo(pAddr, SALEN(pAddr), (char*)szIP, sizeof(szIP), NULL, 0, NI_NUMERICHOST);\n\tif(error) {\n\t\tpThis->pEngine->dbgprint(\"Malformed from address %s\\n\", gai_strerror(error));\n\t\tstrcpy((char*)szHname, \"???\");\n\t\tstrcpy((char*)szIP, \"???\");\n\t\tABORT_FINALIZE(RELP_RET_INVALID_HNAME);\n\t}\n\n\tif(pEngine->bEnableDns) {\n\t\terror = getnameinfo(pAddr, SALEN(pAddr), (char*)szHname, sizeof(szHname), NULL, 0, NI_NAMEREQD);\n\t\tif(error == 0) {\n\t\t\tmemset (&hints, 0, sizeof (struct addrinfo));\n\t\t\thints.ai_flags = AI_NUMERICHOST;\n\t\t\thints.ai_socktype = SOCK_STREAM;\n\t\t\t\/* we now do a lookup once again. This one should fail,\n\t\t\t * because we should not have obtained a non-numeric address. If\n\t\t\t * we got a numeric one, someone messed with DNS!\n\t\t\t *\/\n\t\t\tif(getaddrinfo((char*)szHname, NULL, &hints, &res) == 0) {\n\t\t\t\tfreeaddrinfo (res);\n\t\t\t\t\/* OK, we know we have evil, so let's indicate this to our caller *\/\n\t\t\t\tsnprintf((char*)szHname, NI_MAXHOST, \"[MALICIOUS:IP=%s]\", szIP);\n\t\t\t\tpEngine->dbgprint(\"Malicious PTR record, IP = \\\"%s\\\" HOST = \\\"%s\\\"\", szIP, szHname);\n\t\t\t\tiRet = RELP_RET_MALICIOUS_HNAME;\n\t\t\t}\n\t\t} else {\n\t\t\tstrcpy((char*)szHname, (char*)szIP);\n\t\t}\n\t} else {\n\t\tstrcpy((char*)szHname, (char*)szIP);\n\t}\n\n\t\/* We now have the names, so now let's allocate memory and store them permanently.\n\t * (side note: we may hold on to these values for quite a while, thus we trim their\n\t * memory consumption)\n\t *\/\n\tlen = strlen((char*)szIP) + 1; \/* +1 for \\0 byte *\/\n\tif((pThis->pRemHostIP = malloc(len)) == NULL)\n\t\tABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY);\n\tmemcpy(pThis->pRemHostIP, szIP, len);\n\n\tlen = strlen((char*)szHname) + 1; \/* +1 for \\0 byte *\/\n\tif((pThis->pRemHostName = malloc(len)) == NULL) {\n\t\tfree(pThis->pRemHostIP); \/* prevent leak *\/\n\t\tpThis->pRemHostIP = NULL;\n\t\tABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY);\n\t}\n\tmemcpy(pThis->pRemHostName, szHname, len);\n\nfinalize_it:\n\tLEAVE_RELPFUNC;\n}","target":0,"code_token_length":717,"total_token_length":953,"max_tokens_setting":1024}
+{"idx":358943,"func":"static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,\n\t\t\t u32 pid, u32 seq, u16 flags, int event)\n{\n\tstruct tcmsg *tcm;\n\tstruct nlmsghdr  *nlh;\n\tunsigned char *b = skb_tail_pointer(skb);\n\tstruct gnet_dump d;\n\n\tnlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);\n\ttcm = NLMSG_DATA(nlh);\n\ttcm->tcm_family = AF_UNSPEC;\n\ttcm->tcm__pad1 = 0;\n\ttcm->tcm__pad2 = 0;\n\ttcm->tcm_ifindex = qdisc_dev(q)->ifindex;\n\ttcm->tcm_parent = clid;\n\ttcm->tcm_handle = q->handle;\n\ttcm->tcm_info = atomic_read(&q->refcnt);\n\tNLA_PUT_STRING(skb, TCA_KIND, q->ops->id);\n\tif (q->ops->dump && q->ops->dump(q, skb) < 0)\n\t\tgoto nla_put_failure;\n\tq->qstats.qlen = q->q.qlen;\n\n\tif (q->stab && qdisc_dump_stab(skb, q->stab) < 0)\n\t\tgoto nla_put_failure;\n\n\tif (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, TCA_XSTATS,\n\t\t\t\t\t qdisc_root_sleeping_lock(q), &d) < 0)\n\t\tgoto nla_put_failure;\n\n\tif (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0)\n\t\tgoto nla_put_failure;\n\n\tif (gnet_stats_copy_basic(&d, &q->bstats) < 0 ||\n\t    gnet_stats_copy_rate_est(&d, &q->rate_est) < 0 ||\n\t    gnet_stats_copy_queue(&d, &q->qstats) < 0)\n\t\tgoto nla_put_failure;\n\n\tif (gnet_stats_finish_copy(&d) < 0)\n\t\tgoto nla_put_failure;\n\n\tnlh->nlmsg_len = skb_tail_pointer(skb) - b;\n\treturn skb->len;\n\nnlmsg_failure:\nnla_put_failure:\n\tnlmsg_trim(skb, b);\n\treturn -1;\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":331353,"func":"static int enable_write_target(BDRVVVFATState *s, Error **errp)\n\n{\n\n    BlockDriver *bdrv_qcow;\n\n    QEMUOptionParameter *options;\n\n    int ret;\n\n    int size = sector2cluster(s, s->sector_count);\n\n    s->used_clusters = calloc(size, 1);\n\n\n\n    array_init(&(s->commits), sizeof(commit_t));\n\n\n\n    s->qcow_filename = g_malloc(1024);\n\n    ret = get_tmp_filename(s->qcow_filename, 1024);\n\n    if (ret < 0) {\n\n        error_setg_errno(errp, -ret, \"can't create temporary file\");\n\n        goto err;\n\n    }\n\n\n\n    bdrv_qcow = bdrv_find_format(\"qcow\");\n\n    options = parse_option_parameters(\"\", bdrv_qcow->create_options, NULL);\n\n    set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512);\n\n    set_option_parameter(options, BLOCK_OPT_BACKING_FILE, \"fat:\");\n\n\n\n    ret = bdrv_create(bdrv_qcow, s->qcow_filename, options, errp);\n\n\n    if (ret < 0) {\n\n        goto err;\n\n    }\n\n\n\n    s->qcow = NULL;\n\n    ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL,\n\n                    BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,\n\n                    bdrv_qcow, errp);\n\n    if (ret < 0) {\n\n        goto err;\n\n    }\n\n\n\n#ifndef _WIN32\n\n    unlink(s->qcow_filename);\n\n#endif\n\n\n\n    bdrv_set_backing_hd(s->bs, bdrv_new(\"\", &error_abort));\n\n    s->bs->backing_hd->drv = &vvfat_write_target;\n\n    s->bs->backing_hd->opaque = g_malloc(sizeof(void*));\n\n    *(void**)s->bs->backing_hd->opaque = s;\n\n\n\n    return 0;\n\n\n\nerr:\n\n    g_free(s->qcow_filename);\n\n    s->qcow_filename = NULL;\n\n    return ret;\n\n}","target":1,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":59262,"func":"static int update_eth_regs_async(pegasus_t *pegasus)\n{\n\tint ret = -ENOMEM;\n\tstruct urb *async_urb;\n\tstruct usb_ctrlrequest *req;\n\n\treq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);\n\tif (req == NULL)\n\t\treturn ret;\n\n\tasync_urb = usb_alloc_urb(0, GFP_ATOMIC);\n\tif (async_urb == NULL) {\n\t\tkfree(req);\n\t\treturn ret;\n\t}\n\treq->bRequestType = PEGASUS_REQT_WRITE;\n\treq->bRequest = PEGASUS_REQ_SET_REGS;\n\treq->wValue = cpu_to_le16(0);\n\treq->wIndex = cpu_to_le16(EthCtrl0);\n\treq->wLength = cpu_to_le16(3);\n\n\tusb_fill_control_urb(async_urb, pegasus->usb,\n\t\t\t     usb_sndctrlpipe(pegasus->usb, 0), (void *)req,\n\t\t\t     pegasus->eth_regs, 3, async_ctrl_callback, req);\n\n\tret = usb_submit_urb(async_urb, GFP_ATOMIC);\n\tif (ret) {\n\t\tif (ret == -ENODEV)\n\t\t\tnetif_device_detach(pegasus->net);\n\t\tnetif_err(pegasus, drv, pegasus->net,\n\t\t\t  \"%s returned %d\\n\", __func__, ret);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":196660,"func":"get_reply_key_win(krb5_context context,\n\t\t  const krb5_data *content,\n\t\t  unsigned nonce,\n\t\t  krb5_keyblock **key)\n{\n    ReplyKeyPack_Win2k key_pack;\n    krb5_error_code ret;\n    size_t size;\n\n    ret = decode_ReplyKeyPack_Win2k(content->data,\n\t\t\t\t    content->length,\n\t\t\t\t    &key_pack,\n\t\t\t\t    &size);\n    if (ret) {\n\tkrb5_set_error_message(context, ret,\n\t\t\t       N_(\"PKINIT decoding reply key failed\", \"\"));\n\tfree_ReplyKeyPack_Win2k(&key_pack);\n\treturn ret;\n    }\n\n    if ((unsigned)key_pack.nonce != nonce) {\n\tkrb5_set_error_message(context, ret,\n\t\t\t       N_(\"PKINIT enckey nonce is wrong\", \"\"));\n\tfree_ReplyKeyPack_Win2k(&key_pack);\n\treturn KRB5KRB_AP_ERR_MODIFIED;\n    }\n\n    *key = malloc (sizeof (**key));\n    if (*key == NULL) {\n\tfree_ReplyKeyPack_Win2k(&key_pack);\n\treturn krb5_enomem(context);\n    }\n\n    ret = copy_EncryptionKey(&key_pack.replyKey, *key);\n    free_ReplyKeyPack_Win2k(&key_pack);\n    if (ret) {\n\tkrb5_set_error_message(context, ret,\n\t\t\t       N_(\"PKINIT failed copying reply key\", \"\"));\n\tfree(*key);\n\t*key = NULL;\n    }\n\n    return ret;\n}\n","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":259061,"func":"static int l_session_open (lua_State *L) {\n    int rc;\n    ssh_userdata *state = NULL;\n\n    luaL_checkinteger(L, 2);\n    lua_settop(L, 2);\n\n    state = (ssh_userdata *)lua_newuserdata(L, sizeof(ssh_userdata)); \/* index 3 *\/\n\n    assert(lua_gettop(L) == 3);\n    state->session = NULL;\n    state->sp[0] = -1;\n    state->sp[1] = -1;\n    lua_pushvalue(L, lua_upvalueindex(1)); \/* metatable *\/\n    lua_setmetatable(L, 3);\n\n    lua_newtable(L);\n    lua_setuservalue(L, 3);\n    lua_getuservalue(L, 3); \/* index 4 - a table associated with userdata*\/\n    assert(lua_gettop(L) == 4);\n\n    state->session = libssh2_session_init();\n\n    if (state->session == NULL) {\n        \/\/ A session could not be created because of memory limit\n        return nseU_safeerror(L, \"trying to initiate session\");\n    }\n\n    libssh2_session_set_blocking(state->session, 0);\n\n    if (make_socketpair(state->sp, 1) == -1)\n        return nseU_safeerror(L, \"trying to create socketpair\");\n\n#ifdef WIN32\n    unsigned long s_mode = 1; \/\/ non-blocking\n\n    rc = ioctlsocket(state->sp[1], FIONBIO, (unsigned long *)&s_mode);\n    if (rc != NO_ERROR)\n        return nseU_safeerror(L, \"%s\", strerror(errno));\n#else\n    \/\/ get file descriptor flags\n    rc = fcntl(state->sp[1], F_GETFD);\n    if (rc == -1)\n        return nseU_safeerror(L, \"%s\", strerror(errno));\n\n    \/\/ add non-blocking flag and update file descriptor flags\n    rc |= O_NONBLOCK;\n    rc = fcntl(state->sp[1], F_SETFL, rc);\n    if (rc == -1)\n        return nseU_safeerror(L, \"%s\", strerror(errno));\n#endif\n\n    lua_getglobal(L, \"nmap\");\n    lua_getfield(L, -1, \"new_socket\");\n    lua_replace(L, -2);\n    lua_call(L, 0, 1);\n    lua_setfield(L, 4, \"sock\");\n    lua_pushliteral(L, \"\");\n    lua_setfield(L, 4, \"sp_buff\");\n    assert(lua_gettop(L) == 4);\n\n    lua_getfield(L, 4, \"sock\");\n    lua_getfield(L, -1, \"connect\");\n    lua_insert(L, -2); \/* swap *\/\n    lua_pushvalue(L, 1);\n    lua_pushvalue(L, 2);\n    lua_callk(L, 3, 2, 3, finish_session_open);\n    return finish_session_open(L,0,0);\n}","target":0,"code_token_length":619,"total_token_length":855,"max_tokens_setting":1024}
+{"idx":204037,"func":"  static views::View* AddPaddedTitleCard(views::View* view,\n                                         TitleCard* title_card,\n                                         int width) {\n    views::View* titled_view = new views::View();\n    views::GridLayout* layout = titled_view->SetLayoutManager(\n        std::make_unique<views::GridLayout>(titled_view));\n\n    ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();\n    const gfx::Insets dialog_insets =\n        provider->GetInsetsMetric(views::INSETS_DIALOG);\n    views::ColumnSet* columns = layout->AddColumnSet(0);\n    columns->AddPaddingColumn(1.0, dialog_insets.left());\n    int available_width = width - dialog_insets.width();\n    columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,\n                       views::GridLayout::kFixedSize, views::GridLayout::FIXED,\n                       available_width, available_width);\n    columns->AddPaddingColumn(1.0, dialog_insets.right());\n    layout->AddColumnSet(1)->AddColumn(\n        views::GridLayout::FILL, views::GridLayout::FILL,\n        views::GridLayout::kFixedSize, views::GridLayout::FIXED, width, width);\n\n    layout->StartRowWithPadding(1.0, 0, views::GridLayout::kFixedSize,\n                                kVerticalSpacing);\n    layout->AddView(title_card);\n    layout->StartRowWithPadding(1.0, 1.0, views::GridLayout::kFixedSize,\n                                kVerticalSpacing);\n    layout->AddView(new views::Separator());\n\n    layout->StartRow(1.0, 1.0);\n    layout->AddView(view);\n\n    return titled_view;\n  }\n","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":489427,"func":"GF_Err nhmldump_process(GF_Filter *filter)\n{\n\tGF_NHMLDumpCtx *ctx = gf_filter_get_udta(filter);\n\tGF_FilterPacket *pck;\n\tchar *data;\n\tu32 pck_size;\n\n\tif (!ctx->side_streams_config) {\n\t\treturn nhmldump_config_side_stream(filter, ctx);\n\t}\n\n\tpck = gf_filter_pid_get_packet(ctx->ipid);\n\tif (!pck) {\n\t\tif (gf_filter_pid_is_eos(ctx->ipid)) {\n\t\t\tif (ctx->bs_w && ctx->szRootName) {\n\t\t\t\tchar nhml[1024];\n\t\t\t\tu32 size;\n\t\t\t\tgf_bs_reassign_buffer(ctx->bs_w, ctx->nhml_buffer, ctx->nhml_buffer_size);\n\t\t\t\tsprintf(nhml, \"<\/%s>\\n\", ctx->szRootName);\n\t\t\t\tgf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));\n\n\t\t\t\tgf_bs_get_content_no_truncate(ctx->bs_w, &ctx->nhml_buffer, &size, &ctx->nhml_buffer_size);\n\n\t\t\t\tif (ctx->filep) {\n\t\t\t\t\tgf_fwrite(ctx->nhml_buffer, size, ctx->filep);\n\t\t\t\t} else {\n\t\t\t\t\tGF_FilterPacket *dst_pck;\n\t\t\t\t\tu8 *output;\n\t\t\t\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid_nhml, size, &output);\n\t\t\t\t\tif (dst_pck) {\n\t\t\t\t\t\tmemcpy(output, ctx->nhml_buffer, size);\n\t\t\t\t\t\tgf_filter_pck_set_framing(dst_pck, GF_FALSE, GF_TRUE);\n\t\t\t\t\t\tgf_filter_pck_send(dst_pck);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tctx->szRootName = NULL;\n\t\t\t}\n\t\t\tif (ctx->opid_nhml) gf_filter_pid_set_eos(ctx->opid_nhml);\n\t\t\tif (ctx->opid_mdia) gf_filter_pid_set_eos(ctx->opid_mdia);\n\t\t\tif (ctx->opid_info) gf_filter_pid_set_eos(ctx->opid_info);\n\t\t\treturn GF_EOS;\n\t\t}\n\t\treturn GF_OK;\n\t}\n\n\tif (!ctx->bs_w) ctx->bs_w = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\telse gf_bs_reassign_buffer(ctx->bs_w, ctx->nhml_buffer, ctx->nhml_buffer_size);\n\n\tif (ctx->first) {\n\t\tnhmldump_send_header(ctx);\n\t\tgf_bs_reassign_buffer(ctx->bs_w, ctx->nhml_buffer, ctx->nhml_buffer_size);\n\t}\n\n\t\/\/get media data\n\tdata = (char *) gf_filter_pck_get_data(pck, &pck_size);\n\n\t\/\/send data\n\tif (ctx->is_dims) {\n\t\tnhmldump_send_dims(ctx, data, pck_size, pck);\n\t} else {\n\t\tnhmldump_send_frame(ctx, data, pck_size, pck);\n\t}\n\tctx->first = GF_FALSE;\n\n\n\tif (ctx->exporter) {\n\t\tu32 timescale = gf_filter_pck_get_timescale(pck);\n\t\tu64 ts = gf_filter_pck_get_cts(pck);\n\t\tgf_set_progress(\"Exporting\", ts*ctx->duration.den, ctx->duration.num*timescale);\n\t}\n\n\tgf_filter_pid_drop_packet(ctx->ipid);\n\n\treturn GF_OK;\n}","target":0,"code_token_length":723,"total_token_length":959,"max_tokens_setting":1024}
+{"idx":244817,"func":"mcid_char_imp(fz_context *ctx, pdf_filter_processor *p, tag_record *tr, int uni, int remove)\n{\n\tif (tr->mcid_obj == NULL)\n\t\t\/* No object, or already deleted *\/\n\t\treturn;\n\n\tif (remove)\n\t{\n\t\t\/* Remove the expanded abbreviation, if there is one. *\/\n\t\tpdf_dict_del(ctx, tr->mcid_obj, PDF_NAME(E));\n                \/* Remove the structure title, if there is one. *\/\n                pdf_dict_del(ctx, tr->mcid_obj, PDF_NAME(T));\n        }\n\n        \/* Edit the Alt string *\/\n        walk_string(ctx, uni, remove, &tr->alt);\n        \/* Edit the ActualText string *\/\n        walk_string(ctx, uni, remove, &tr->actualtext);\n\n        \/* If we're removing a character, and either of the strings\n         * haven't matched up to what we were expecting, then just\n         * delete the whole string. *\/\n\telse if (tr->alt.pos >= 0 || tr->actualtext.pos >= 0)\n\t{\n\t\t\/* The strings are making sense so far *\/\n\t\tremove = 0;\n                \/* The strings are making sense so far *\/\n                remove = 0;\n        }\n\n        if (remove)\n        {\n                \/* Anything else we have to err on the side of caution and\n\t\tif (tr->alt.pos == -1)\n\t\t\tpdf_dict_del(ctx, tr->mcid_obj, PDF_NAME(Alt));\n\t\tpdf_drop_obj(ctx, tr->mcid_obj);\n\t\ttr->mcid_obj = NULL;\n\t\tfz_free(ctx, tr->alt.utf8);\n\t\ttr->alt.utf8 = NULL;\n\t\tfz_free(ctx, tr->actualtext.utf8);\n\t\ttr->actualtext.utf8 = NULL;\n\t}\n}\n","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":129415,"func":"void CLASS sony_arw2_load_raw()\n{\n  uchar *data, *dp;\n  ushort pix[16];\n  int row, col, val, max, min, imax, imin, sh, bit, i;\n\n  data = (uchar *) malloc (raw_width);\n  merror (data, \"sony_arw2_load_raw()\");\n  for (row=0; row < height; row++) {\n    fread (data, 1, raw_width, ifp);\n    for (dp=data, col=0; col < raw_width-30; dp+=16) {\n      max = 0x7ff & (val = sget4(dp));\n      min = 0x7ff & val >> 11;\n      imax = 0x0f & val >> 22;\n      imin = 0x0f & val >> 26;\n      for (sh=0; sh < 4 && 0x80 << sh <= max-min; sh++);\n      for (bit=30, i=0; i < 16; i++)\n\tif      (i == imax) pix[i] = max;\n\telse if (i == imin) pix[i] = min;\n\telse {\n\t  pix[i] = ((sget2(dp+(bit >> 3)) >> (bit & 7) & 0x7f) << sh) + min;\n\t  if (pix[i] > 0x7ff) pix[i] = 0x7ff;\n\t  bit += 7;\n\t}\n      for (i=0; i < 16; i++, col+=2)\n\tif (col < width) BAYER(row,col) = curve[pix[i] << 1] >> 2;\n      col -= col & 1 ? 1:31;\n    }\n  }\n  free (data);\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":25101,"func":"static int ir2_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {\n Ir2Context * const s = avctx -> priv_data ;\n const uint8_t * buf = avpkt -> data ;\n int buf_size = avpkt -> size ;\n AVFrame * picture = data ;\n AVFrame * const p = & s -> picture ;\n int start , ret ;\n if ( ( ret = ff_reget_buffer ( avctx , p ) ) < 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"reget_buffer() failed\\n\" ) ;\n return ret ;\n }\n start = 48 ;\n if ( start >= buf_size ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"input buffer size too small (%d)\\n\" , buf_size ) ;\n return AVERROR_INVALIDDATA ;\n }\n s -> decode_delta = buf [ 18 ] ;\n # ifndef BITSTREAM_READER_LE for ( i = 0 ;\n i < buf_size ;\n i ++ ) buf [ i ] = ff_reverse [ buf [ i ] ] ;\n # endif init_get_bits ( & s -> gb , buf + start , ( buf_size - start ) * 8 ) ;\n if ( s -> decode_delta ) {\n if ( ( ret = ir2_decode_plane ( s , avctx -> width , avctx -> height , s -> picture . data [ 0 ] , s -> picture . linesize [ 0 ] , ir2_luma_table ) ) < 0 ) return ret ;\n if ( ( ret = ir2_decode_plane ( s , avctx -> width >> 2 , avctx -> height >> 2 , s -> picture . data [ 2 ] , s -> picture . linesize [ 2 ] , ir2_luma_table ) ) < 0 ) return ret ;\n if ( ( ret = ir2_decode_plane ( s , avctx -> width >> 2 , avctx -> height >> 2 , s -> picture . data [ 1 ] , s -> picture . linesize [ 1 ] , ir2_luma_table ) ) < 0 ) return ret ;\n }\n else {\n if ( ( ret = ir2_decode_plane_inter ( s , avctx -> width , avctx -> height , s -> picture . data [ 0 ] , s -> picture . linesize [ 0 ] , ir2_luma_table ) ) < 0 ) return ret ;\n if ( ( ret = ir2_decode_plane_inter ( s , avctx -> width >> 2 , avctx -> height >> 2 , s -> picture . data [ 2 ] , s -> picture . linesize [ 2 ] , ir2_luma_table ) ) < 0 ) return ret ;\n if ( ( ret = ir2_decode_plane_inter ( s , avctx -> width >> 2 , avctx -> height >> 2 , s -> picture . data [ 1 ] , s -> picture . linesize [ 1 ] , ir2_luma_table ) ) < 0 ) return ret ;\n }\n if ( ( ret = av_frame_ref ( picture , & s -> picture ) ) < 0 ) return ret ;\n * got_frame = 1 ;\n return buf_size ;\n }","target":0,"code_token_length":674,"total_token_length":910,"max_tokens_setting":1024}
+{"idx":227479,"func":"static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde, \n\t\t\t      uint16_t flags, void *private_data)\n{\n\tstruct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);\n\tstruct ctdb_tcp *ctcp = talloc_get_type(ctdb->private_data, struct ctdb_tcp);\n\tctdb_sock_addr addr;\n\tsocklen_t len;\n\tint fd, nodeid;\n\tstruct ctdb_incoming *in;\n\tint one = 1;\n\tconst char *incoming_node;\n\n\tmemset(&addr, 0, sizeof(addr));\n\tlen = sizeof(addr);\n\tfd = accept(ctcp->listen_fd, (struct sockaddr *)&addr, &len);\n\tif (fd == -1) return;\n\n\tincoming_node = ctdb_addr_to_str(&addr);\n\tnodeid = ctdb_ip_to_nodeid(ctdb, incoming_node);\n\n\tif (nodeid == -1) {\n\t\tDEBUG(DEBUG_ERR, (\"Refused connection from unknown node %s\\n\", incoming_node));\n\t\tclose(fd);\n\t\treturn;\n\t}\n\n\tin = talloc_zero(ctcp, struct ctdb_incoming);\n\tin->fd = fd;\n\tin->ctdb = ctdb;\n\n\tset_nonblocking(in->fd);\n\tset_close_on_exec(in->fd);\n\n\tDEBUG(DEBUG_DEBUG, (__location__ \" Created SOCKET FD:%d to incoming ctdb connection\\n\", fd));\n\n        setsockopt(in->fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one));\n\n\tin->queue = ctdb_queue_setup(ctdb, in, in->fd, CTDB_TCP_ALIGNMENT, \n\t\t\t\t     ctdb_tcp_read_cb, in, \"ctdbd-%s\", incoming_node);\n}\n","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":496897,"func":"int mempool_create_with_shared_mem(\n    size_t pool_item_size, size_t pool_initial_size, size_t pool_expansion_size,\n    func_mem_available_callback_type mem_get_free_space_func,\n    func_mark_mem_used_callback_type mem_mark_used_space_func,\n    func_mark_mem_free_callback_type mem_mark_free_space_func,\n    func_log_callback_type log_callback_func, int flags,\n    MemoryPoolHandle *p_handle) {\n  int rc = 0;\n  struct mempool *pool = NULL;\n  if (mem_get_free_space_func == NULL || mem_mark_used_space_func == NULL ||\n      mem_mark_free_space_func == NULL || p_handle == NULL) {\n    return S3_MEMPOOL_INVALID_ARG;\n  }\n\n  if (pool_initial_size > mem_get_free_space_func()) {\n    return S3_MEMPOOL_THRESHOLD_EXCEEDED;\n  }\n\n  rc = mempool_create(pool_item_size, pool_initial_size, pool_expansion_size, 0,\n                      log_callback_func, flags, p_handle);\n  if (rc != 0) {\n    return rc;\n  }\n\n  pool = (struct mempool *)*p_handle;\n\n  pool->mem_get_free_space_func = mem_get_free_space_func;\n  pool->mem_mark_used_space_func = mem_mark_used_space_func;\n  pool->mem_mark_free_space_func = mem_mark_free_space_func;\n\n  \/* Explicitly mark used space, since mempool_create -> freelist_allocate\n     dont have the function callbacks set. *\/\n  pool->mem_mark_used_space_func(pool->total_bufs_allocated_by_pool *\n                                 pool->mempool_item_size);\n\n  return 0;\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":356962,"func":"sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,\n\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\tvoid *arg,\n\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sk_buff *skb = chunk->skb;\n\tsctp_chunkhdr_t *ch;\n\t__u8 *ch_end;\n\tint ootb_shut_ack = 0;\n\n\tSCTP_INC_STATS(SCTP_MIB_OUTOFBLUES);\n\n\tch = (sctp_chunkhdr_t *) chunk->chunk_hdr;\n\tdo {\n\t\t\/* Report violation if the chunk is less then minimal *\/\n\t\tif (ntohs(ch->length) < sizeof(sctp_chunkhdr_t))\n\t\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\t\t\/* Now that we know we at least have a chunk header,\n\t\t * do things that are type appropriate.\n\t\t *\/\n\t\tif (SCTP_CID_SHUTDOWN_ACK == ch->type)\n\t\t\tootb_shut_ack = 1;\n\n\t\t\/* RFC 2960, Section 3.3.7\n\t\t *   Moreover, under any circumstances, an endpoint that\n\t\t *   receives an ABORT  MUST NOT respond to that ABORT by\n\t\t *   sending an ABORT of its own.\n\t\t *\/\n\t\tif (SCTP_CID_ABORT == ch->type)\n\t\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\t\/* Report violation if chunk len overflows *\/\n\t\tch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));\n\t\tif (ch_end > skb_tail_pointer(skb))\n\t\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\t\tch = (sctp_chunkhdr_t *) ch_end;\n\t} while (ch_end < skb_tail_pointer(skb));\n\n\tif (ootb_shut_ack)\n\t\treturn sctp_sf_shut_8_4_5(ep, asoc, type, arg, commands);\n\telse\n\t\treturn sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":144126,"func":"sctp_disposition_t sctp_sf_beat_8_3(struct net *net,\n\t\t\t\t    const struct sctp_endpoint *ep,\n\t\t\t\t    const struct sctp_association *asoc,\n\t\t\t\t    const sctp_subtype_t type,\n\t\t\t\t    void *arg,\n\t\t\t\t    sctp_cmd_seq_t *commands)\n{\n\tsctp_paramhdr_t *param_hdr;\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sctp_chunk *reply;\n\tsize_t paylen = 0;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the HEARTBEAT chunk has a valid length. *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_heartbeat_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(net, ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\t\/* 8.3 The receiver of the HEARTBEAT should immediately\n\t * respond with a HEARTBEAT ACK that contains the Heartbeat\n\t * Information field copied from the received HEARTBEAT chunk.\n\t *\/\n\tchunk->subh.hb_hdr = (sctp_heartbeathdr_t *) chunk->skb->data;\n\tparam_hdr = (sctp_paramhdr_t *) chunk->subh.hb_hdr;\n\tpaylen = ntohs(chunk->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);\n\n\tif (ntohs(param_hdr->length) > paylen)\n\t\treturn sctp_sf_violation_paramlen(net, ep, asoc, type, arg,\n\t\t\t\t\t\t  param_hdr, commands);\n\n\tif (!pskb_pull(chunk->skb, paylen))\n\t\tgoto nomem;\n\n\treply = sctp_make_heartbeat_ack(asoc, chunk, param_hdr, paylen);\n\tif (!reply)\n\t\tgoto nomem;\n\n\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply));\n\treturn SCTP_DISPOSITION_CONSUME;\n\nnomem:\n\treturn SCTP_DISPOSITION_NOMEM;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":213054,"func":"static Eina_Bool _ewk_frame_contents_set_internal(Ewk_Frame_Smart_Data* smartData, const char* contents, size_t contentsSize, const char* mimeType, const char* encoding, const char* baseUri, const char* unreachableUri)\n{\n    size_t length = strlen(contents);\n    if (contentsSize < 1 || contentsSize > length)\n        contentsSize = length;\n    if (!mimeType)\n        mimeType = \"text\/html\";\n    if (!encoding)\n        encoding = \"UTF-8\";\n    if (!baseUri)\n        baseUri = \"about:blank\";\n\n    WebCore::KURL baseKURL(WebCore::KURL(), WTF::String::fromUTF8(baseUri));\n    WebCore::KURL unreachableKURL;\n    if (unreachableUri)\n        unreachableKURL = WebCore::KURL(WebCore::KURL(), WTF::String::fromUTF8(unreachableUri));\n    else\n        unreachableKURL = WebCore::KURL();\n\n    WTF::RefPtr<WebCore::SharedBuffer> buffer = WebCore::SharedBuffer::create(contents, contentsSize);\n    WebCore::SubstituteData substituteData\n        (buffer.release(),\n        WTF::String::fromUTF8(mimeType),\n        WTF::String::fromUTF8(encoding),\n        baseKURL, unreachableKURL);\n    WebCore::ResourceRequest request(baseKURL);\n\n    smartData->frame->loader()->load(request, substituteData, false);\n    return true;\n}\n","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":330501,"func":"static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,\n\n    int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)\n\n{\n\n    BlockDriver *drv = bs->drv;\n\n    QEMUIOVector qiov;\n\n    struct iovec iov = {0};\n\n    int ret = 0;\n\n\n\n    int max_write_zeroes = bs->bl.max_write_zeroes ?\n\n                           bs->bl.max_write_zeroes : MAX_WRITE_ZEROES_DEFAULT;\n\n\n\n    while (nb_sectors > 0 && !ret) {\n\n        int num = nb_sectors;\n\n\n\n        \/* Align request.  Block drivers can expect the \"bulk\" of the request\n\n         * to be aligned.\n\n         *\/\n\n        if (bs->bl.write_zeroes_alignment\n\n            && num > bs->bl.write_zeroes_alignment) {\n\n            if (sector_num % bs->bl.write_zeroes_alignment != 0) {\n\n                \/* Make a small request up to the first aligned sector.  *\/\n\n                num = bs->bl.write_zeroes_alignment;\n\n                num -= sector_num % bs->bl.write_zeroes_alignment;\n\n            } else if ((sector_num + num) % bs->bl.write_zeroes_alignment != 0) {\n\n                \/* Shorten the request to the last aligned sector.  num cannot\n\n                 * underflow because num > bs->bl.write_zeroes_alignment.\n\n                 *\/\n\n                num -= (sector_num + num) % bs->bl.write_zeroes_alignment;\n\n            }\n\n        }\n\n\n\n        \/* limit request size *\/\n\n        if (num > max_write_zeroes) {\n\n            num = max_write_zeroes;\n\n        }\n\n\n\n        ret = -ENOTSUP;\n\n        \/* First try the efficient write zeroes operation *\/\n\n        if (drv->bdrv_co_write_zeroes) {\n\n            ret = drv->bdrv_co_write_zeroes(bs, sector_num, num, flags);\n\n        }\n\n\n\n        if (ret == -ENOTSUP) {\n\n            \/* Fall back to bounce buffer if write zeroes is unsupported *\/\n\n            iov.iov_len = num * BDRV_SECTOR_SIZE;\n\n            if (iov.iov_base == NULL) {\n\n                iov.iov_base = qemu_blockalign(bs, num * BDRV_SECTOR_SIZE);\n\n                memset(iov.iov_base, 0, num * BDRV_SECTOR_SIZE);\n\n            }\n\n            qemu_iovec_init_external(&qiov, &iov, 1);\n\n\n\n            ret = drv->bdrv_co_writev(bs, sector_num, num, &qiov);\n\n\n\n            \/* Keep bounce buffer around if it is big enough for all\n\n             * all future requests.\n\n             *\/\n\n            if (num < max_write_zeroes) {\n\n                qemu_vfree(iov.iov_base);\n\n                iov.iov_base = NULL;\n\n            }\n\n        }\n\n\n\n        sector_num += num;\n\n        nb_sectors -= num;\n\n    }\n\n\n\n    qemu_vfree(iov.iov_base);\n\n    return ret;\n\n}\n","target":1,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":435453,"func":"static int xml_add_ns(xmlNodePtr req, xmlNsPtr *respNs, xmlNodePtr root)\n{\n    for (; req; req = req->next) {\n        if (req->type == XML_ELEMENT_NODE) {\n            xmlNsPtr nsDef;\n\n            for (nsDef = req->nsDef; nsDef; nsDef = nsDef->next) {\n                if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_DAV))\n                    ensure_ns(respNs, NS_DAV, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_CALDAV))\n                    ensure_ns(respNs, NS_CALDAV, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_CARDDAV))\n                    ensure_ns(respNs, NS_CARDDAV, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_CS))\n                    ensure_ns(respNs, NS_CS, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_MECOM))\n                    ensure_ns(respNs, NS_MECOM, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_MOBME))\n                    ensure_ns(respNs, NS_MOBME, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else if (!xmlStrcmp(nsDef->href, BAD_CAST XML_NS_CYRUS))\n                    ensure_ns(respNs, NS_CYRUS, root,\n                              (const char *) nsDef->href,\n                              (const char *) nsDef->prefix);\n                else\n                    xmlNewNs(root, nsDef->href, nsDef->prefix);\n            }\n        }\n\n        xml_add_ns(req->children, respNs, root);\n    }\n\n    \/* XXX  check for errors *\/\n    return 0;\n}","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":321129,"func":"target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)\n\n{\n\n    uint8_t *pde_ptr, *pte_ptr;\n\n    uint32_t pde, pte, paddr, page_offset, page_size;\n\n\n\n    if (!(env->cr[0] & CR0_PG_MASK)) {\n\n        pte = addr;\n\n        page_size = 4096;\n\n    } else {\n\n        \/* page directory entry *\/\n\n        pde_ptr = phys_ram_base + \n\n            (((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask);\n\n        pde = ldl_raw(pde_ptr);\n\n        if (!(pde & PG_PRESENT_MASK)) \n\n            return -1;\n\n        if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {\n\n            pte = pde & ~0x003ff000; \/* align to 4MB *\/\n\n            page_size = 4096 * 1024;\n\n        } else {\n\n            \/* page directory entry *\/\n\n            pte_ptr = phys_ram_base + \n\n                (((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask);\n\n            pte = ldl_raw(pte_ptr);\n\n            if (!(pte & PG_PRESENT_MASK))\n\n                return -1;\n\n            page_size = 4096;\n\n        }\n\n    }\n\n    pte = pte & a20_mask;\n\n    page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);\n\n    paddr = (pte & TARGET_PAGE_MASK) + page_offset;\n\n    return paddr;\n\n}\n","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":200976,"func":"void WebContentsImpl::DidFailProvisionalLoadWithError(\n    RenderViewHost* render_view_host,\n    const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) {\n  VLOG(1) << \"Failed Provisional Load: \" << params.url.possibly_invalid_spec()\n          << \", error_code: \" << params.error_code\n          << \", error_description: \" << params.error_description\n          << \", is_main_frame: \" << params.is_main_frame\n          << \", showing_repost_interstitial: \" <<\n            params.showing_repost_interstitial\n          << \", frame_id: \" << params.frame_id;\n  GURL validated_url(params.url);\n  RenderProcessHost* render_process_host =\n      render_view_host->GetProcess();\n  RenderViewHost::FilterURL(render_process_host, false, &validated_url);\n\n  if (net::ERR_ABORTED == params.error_code) {\n    if (ShowingInterstitialPage()) {\n      LOG(WARNING) << \"Discarding message during interstitial.\";\n      return;\n    }\n\n    render_manager_.RendererAbortedProvisionalLoad(render_view_host);\n  }\n\n  if (controller_.GetPendingEntry() != controller_.GetVisibleEntry())\n    controller_.DiscardPendingEntry();\n\n  FOR_EACH_OBSERVER(WebContentsObserver,\n                    observers_,\n                    DidFailProvisionalLoad(params.frame_id,\n                                           params.is_main_frame,\n                                           validated_url,\n                                           params.error_code,\n                                           params.error_description,\n                                           render_view_host));\n}\n","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":139689,"func":"static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb)\n{\n\tu8 dsap, ssap, ptype;\n\n\tptype = nfc_llcp_ptype(skb);\n\tdsap = nfc_llcp_dsap(skb);\n\tssap = nfc_llcp_ssap(skb);\n\n\tpr_debug(\"ptype 0x%x dsap 0x%x ssap 0x%x\\n\", ptype, dsap, ssap);\n\n\tif (ptype != LLCP_PDU_SYMM)\n\t\tprint_hex_dump_debug(\"LLCP Rx: \", DUMP_PREFIX_OFFSET, 16, 1,\n\t\t\t\t     skb->data, skb->len, true);\n\n\tswitch (ptype) {\n\tcase LLCP_PDU_SYMM:\n\t\tpr_debug(\"SYMM\\n\");\n\t\tbreak;\n\n\tcase LLCP_PDU_UI:\n\t\tpr_debug(\"UI\\n\");\n\t\tnfc_llcp_recv_ui(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_CONNECT:\n\t\tpr_debug(\"CONNECT\\n\");\n\t\tnfc_llcp_recv_connect(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_DISC:\n\t\tpr_debug(\"DISC\\n\");\n\t\tnfc_llcp_recv_disc(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_CC:\n\t\tpr_debug(\"CC\\n\");\n\t\tnfc_llcp_recv_cc(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_DM:\n\t\tpr_debug(\"DM\\n\");\n\t\tnfc_llcp_recv_dm(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_SNL:\n\t\tpr_debug(\"SNL\\n\");\n\t\tnfc_llcp_recv_snl(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_I:\n\tcase LLCP_PDU_RR:\n\tcase LLCP_PDU_RNR:\n\t\tpr_debug(\"I frame\\n\");\n\t\tnfc_llcp_recv_hdlc(local, skb);\n\t\tbreak;\n\n\tcase LLCP_PDU_AGF:\n\t\tpr_debug(\"AGF frame\\n\");\n\t\tnfc_llcp_recv_agf(local, skb);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":229459,"func":"void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM(\n    GLenum target, GLsizei width, GLsizei height,\n    GLuint io_surface_id, GLuint plane) {\n#if defined(OS_MACOSX)\n  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {\n    SetGLError(GL_INVALID_OPERATION,\n               \"glTexImageIOSurface2DCHROMIUM: only supported on desktop GL.\");\n    return;\n  }\n\n  IOSurfaceSupport* surface_support = IOSurfaceSupport::Initialize();\n  if (!surface_support) {\n    SetGLError(GL_INVALID_OPERATION,\n               \"glTexImageIOSurface2DCHROMIUM: only supported on 10.6.\");\n    return;\n  }\n\n  if (target != GL_TEXTURE_RECTANGLE_ARB) {\n    SetGLError(\n        GL_INVALID_OPERATION,\n        \"glTexImageIOSurface2DCHROMIUM: requires TEXTURE_RECTANGLE_ARB target\");\n    return;\n  }\n\n  TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);\n  if (!info) {\n    SetGLError(GL_INVALID_OPERATION,\n               \"glTexImageIOSurface2DCHROMIUM: no rectangle texture bound\");\n    return;\n  }\n  if (info == texture_manager()->GetDefaultTextureInfo(target)) {\n    SetGLError(GL_INVALID_OPERATION,\n               \"glTexImageIOSurface2DCHROMIUM: can't bind default texture\");\n    return;\n  }\n\n  CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id);\n  if (!surface) {\n    SetGLError(GL_INVALID_OPERATION,\n               \"glTexImageIOSurface2DCHROMIUM: no IOSurface with the given ID\");\n    return;\n  }\n\n  ReleaseIOSurfaceForTexture(info->service_id());\n\n  texture_to_io_surface_map_.insert(\n      std::make_pair(info->service_id(), surface));\n\n  CGLContextObj context =\n      static_cast<CGLContextObj>(context_->GetHandle());\n\n  CGLError err = surface_support->CGLTexImageIOSurface2D(\n      context,\n      target,\n      GL_RGBA,\n      width,\n      height,\n      GL_BGRA,\n      GL_UNSIGNED_INT_8_8_8_8_REV,\n      surface,\n      plane);\n\n  if (err != kCGLNoError) {\n    SetGLError(\n        GL_INVALID_OPERATION,\n        \"glTexImageIOSurface2DCHROMIUM: error in CGLTexImageIOSurface2D\");\n    return;\n  }\n\n  texture_manager()->SetLevelInfo(\n      info, target, 0, GL_RGBA, width, height, 1, 0,\n      GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true);\n\n#else\n  SetGLError(GL_INVALID_OPERATION,\n             \"glTexImageIOSurface2DCHROMIUM: not supported.\");\n#endif\n}\n","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":477127,"func":"void iov_iter_revert(struct iov_iter *i, size_t unroll)\n{\n\tif (!unroll)\n\t\treturn;\n\tif (WARN_ON(unroll > MAX_RW_COUNT))\n\t\treturn;\n\ti->count += unroll;\n\tif (unlikely(iov_iter_is_pipe(i))) {\n\t\tstruct pipe_inode_info *pipe = i->pipe;\n\t\tunsigned int p_mask = pipe->ring_size - 1;\n\t\tunsigned int i_head = i->head;\n\t\tsize_t off = i->iov_offset;\n\t\twhile (1) {\n\t\t\tstruct pipe_buffer *b = &pipe->bufs[i_head & p_mask];\n\t\t\tsize_t n = off - b->offset;\n\t\t\tif (unroll < n) {\n\t\t\t\toff -= unroll;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tunroll -= n;\n\t\t\tif (!unroll && i_head == i->start_head) {\n\t\t\t\toff = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ti_head--;\n\t\t\tb = &pipe->bufs[i_head & p_mask];\n\t\t\toff = b->offset + b->len;\n\t\t}\n\t\ti->iov_offset = off;\n\t\ti->head = i_head;\n\t\tpipe_truncate(i);\n\t\treturn;\n\t}\n\tif (unlikely(iov_iter_is_discard(i)))\n\t\treturn;\n\tif (unroll <= i->iov_offset) {\n\t\ti->iov_offset -= unroll;\n\t\treturn;\n\t}\n\tunroll -= i->iov_offset;\n\tif (iov_iter_is_xarray(i)) {\n\t\tBUG(); \/* We should never go beyond the start of the specified\n\t\t\t* range since we might then be straying into pages that\n\t\t\t* aren't pinned.\n\t\t\t*\/\n\t} else if (iov_iter_is_bvec(i)) {\n\t\tconst struct bio_vec *bvec = i->bvec;\n\t\twhile (1) {\n\t\t\tsize_t n = (--bvec)->bv_len;\n\t\t\ti->nr_segs++;\n\t\t\tif (unroll <= n) {\n\t\t\t\ti->bvec = bvec;\n\t\t\t\ti->iov_offset = n - unroll;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tunroll -= n;\n\t\t}\n\t} else { \/* same logics for iovec and kvec *\/\n\t\tconst struct iovec *iov = i->iov;\n\t\twhile (1) {\n\t\t\tsize_t n = (--iov)->iov_len;\n\t\t\ti->nr_segs++;\n\t\t\tif (unroll <= n) {\n\t\t\t\ti->iov = iov;\n\t\t\t\ti->iov_offset = n - unroll;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tunroll -= n;\n\t\t}\n\t}\n}","target":0,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":340599,"func":"void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)\n\n{\n\n    QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);\n\n    QXLCursor *cursor;\n\n    QEMUCursor *c;\n\n\n\n    if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {\n\n        return;\n\n    }\n\n\n\n    if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {\n\n        fprintf(stderr, \"%s\", __FUNCTION__);\n\n        qxl_log_cmd_cursor(qxl, cmd, ext->group_id);\n\n        fprintf(stderr, \"\\n\");\n\n    }\n\n    switch (cmd->type) {\n\n    case QXL_CURSOR_SET:\n\n        cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);\n\n        if (cursor->chunk.data_size != cursor->data_size) {\n\n            fprintf(stderr, \"%s: multiple chunks\\n\", __FUNCTION__);\n\n            return;\n\n        }\n\n        c = qxl_cursor(qxl, cursor);\n\n        if (c == NULL) {\n\n            c = cursor_builtin_left_ptr();\n\n        }\n\n        qemu_mutex_lock(&qxl->ssd.lock);\n\n        if (qxl->ssd.cursor) {\n\n            cursor_put(qxl->ssd.cursor);\n\n        }\n\n        qxl->ssd.cursor = c;\n\n        qxl->ssd.mouse_x = cmd->u.set.position.x;\n\n        qxl->ssd.mouse_y = cmd->u.set.position.y;\n\n        qemu_mutex_unlock(&qxl->ssd.lock);\n\n        break;\n\n    case QXL_CURSOR_MOVE:\n\n        qemu_mutex_lock(&qxl->ssd.lock);\n\n        qxl->ssd.mouse_x = cmd->u.position.x;\n\n        qxl->ssd.mouse_y = cmd->u.position.y;\n\n        qemu_mutex_unlock(&qxl->ssd.lock);\n\n        break;\n\n    }\n\n}\n","target":0,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":371731,"func":"get_dir_list_from_path (FrWindow *window,\n\t      \t\tchar     *path)\n{\n\tchar  *dirname;\n\tint    dirname_l;\n\tGList *list = NULL;\n\tint    i;\n\n\tif (path[strlen (path) - 1] != '\/')\n\t\tdirname = g_strconcat (path, \"\/\", NULL);\n\telse\n\t\tdirname = g_strdup (path);\n\tdirname_l = strlen (dirname);\n\tfor (i = 0; i < window->archive->files->len; i++) {\n\t\tFileData *fd = g_ptr_array_index (window->archive->files, i);\n\t\tgboolean  matches = FALSE;\n\n#ifdef DEBUG_GET_DIR_LIST_FROM_PATH\n\t\tg_print (\"%s <=> %s (%d)\\n\", dirname, fd->full_path, dirname_l);\n#endif\n\n\t\tif (fd->dir) {\n\t\t\tint full_path_l = strlen (fd->full_path);\n\t\t\tif ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l) == 0))\n\t\t\t\t\/* example: dirname is '\/path\/to\/dir\/' and fd->full_path is '\/path\/to\/dir' *\/\n\t\t\t\tmatches = TRUE;\n\t\t\telse if (strcmp (dirname, fd->full_path) == 0)\n\t\t\t\tmatches = TRUE;\n\t\t}\n\n\t\tif (! matches && strncmp (dirname, fd->full_path, dirname_l) == 0) {\n\t\t\tmatches = TRUE;\n\t\t}\n\n\t\tif (matches) {\n#ifdef DEBUG_GET_DIR_LIST_FROM_PATH\n\t\t\tg_print (\"`-> OK\\n\");\n#endif\n\t\t\tlist = g_list_prepend (list, g_strdup (fd->original_path));\n\t\t}\n\t}\n\tg_free (dirname);\n\n\treturn g_list_reverse (list);\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":93004,"func":"_Unpickler_ReadFromFile(UnpicklerObject *self, Py_ssize_t n)\n{\n    PyObject *data;\n    Py_ssize_t read_size;\n\n    assert(self->read != NULL);\n\n    if (_Unpickler_SkipConsumed(self) < 0)\n        return -1;\n\n    if (n == READ_WHOLE_LINE) {\n        data = _PyObject_CallNoArg(self->readline);\n    }\n    else {\n        PyObject *len;\n        \/* Prefetch some data without advancing the file pointer, if possible *\/\n        if (self->peek && n < PREFETCH) {\n            len = PyLong_FromSsize_t(PREFETCH);\n            if (len == NULL)\n                return -1;\n            data = _Pickle_FastCall(self->peek, len);\n            if (data == NULL) {\n                if (!PyErr_ExceptionMatches(PyExc_NotImplementedError))\n                    return -1;\n                \/* peek() is probably not supported by the given file object *\/\n                PyErr_Clear();\n                Py_CLEAR(self->peek);\n            }\n            else {\n                read_size = _Unpickler_SetStringInput(self, data);\n                Py_DECREF(data);\n                self->prefetched_idx = 0;\n                if (n <= read_size)\n                    return n;\n            }\n        }\n        len = PyLong_FromSsize_t(n);\n        if (len == NULL)\n            return -1;\n        data = _Pickle_FastCall(self->read, len);\n    }\n    if (data == NULL)\n        return -1;\n\n    read_size = _Unpickler_SetStringInput(self, data);\n    Py_DECREF(data);\n    return read_size;\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":348572,"func":"void JPXStream::init()\n{\n  Object oLen, cspace, smaskInData;\n  if (getDict()) {\n    oLen = getDict()->lookup(\"Length\");\n    cspace = getDict()->lookup(\"ColorSpace\");\n    smaskInData = getDict()->lookup(\"SMaskInData\");\n  }\n\n  int bufSize = BUFFER_INITIAL_SIZE;\n  if (oLen.isInt()) bufSize = oLen.getInt();\n\n  bool indexed = false;\n  if (cspace.isArray() && cspace.arrayGetLength() > 0) {\n    const Object cstype = cspace.arrayGet(0);\n    if (cstype.isName(\"Indexed\")) indexed = true;\n  }\n\n  priv->smaskInData = 0;\n  if (smaskInData.isInt()) priv->smaskInData = smaskInData.getInt();\n\n  int length = 0;\n  unsigned char *buf = str->toUnsignedChars(&length, bufSize);\n  priv->init2(OPJ_CODEC_JP2, buf, length, indexed);\n  gfree(buf);\n\n  if (priv->image) {\n    int numComps = (priv->image) ? priv->image->numcomps : 1;\n    int alpha = 0;\n    if (priv->image) {\n      if (priv->image->color_space == OPJ_CLRSPC_SRGB && numComps == 4) { numComps = 3; alpha = 1; }\n      else if (priv->image->color_space == OPJ_CLRSPC_SYCC && numComps == 4) { numComps = 3; alpha = 1; }\n      else if (numComps == 2) { numComps = 1; alpha = 1; }\n      else if (numComps > 4) { numComps = 4; alpha = 1; }\n      else { alpha = 0; }\n    }\n    priv->npixels = priv->image->comps[0].w * priv->image->comps[0].h;\n    priv->ncomps = priv->image->numcomps;\n    if (alpha == 1 && priv->smaskInData == 0) priv->ncomps--;\n    for (int component = 0; component < priv->ncomps; component++) {\n      if (priv->image->comps[component].data == nullptr) {\n        close();\n        break;\n      }\n      unsigned char *cdata = (unsigned char *)priv->image->comps[component].data;\n      int adjust = 0;\n      int depth = priv->image->comps[component].prec;\n      if (priv->image->comps[component].prec > 8)\n\tadjust = priv->image->comps[component].prec - 8;\n      int sgndcorr = 0;\n      if (priv->image->comps[component].sgnd)\n\tsgndcorr = 1 << (priv->image->comps[0].prec - 1);\n      for (int i = 0; i < priv->npixels; i++) {\n\tint r = priv->image->comps[component].data[i];\n\t*(cdata++) = adjustComp(r, adjust, depth, sgndcorr, indexed);\n      }\n    }\n  } else {\n    priv->npixels = 0;\n  }\n\n  priv->counter = 0;\n  priv->ccounter = 0;\n  priv->inited = true;\n}","target":1,"code_token_length":750,"total_token_length":986,"max_tokens_setting":1024}
+{"idx":467560,"func":"EXPORTED int annotatemore_msg_lookup(const char *mboxname, uint32_t uid, const char *entry,\n                                     const char *userid, struct buf *value)\n{\n    char key[MAX_MAILBOX_PATH+1];\n    size_t keylen, datalen;\n    int r;\n    const char *data;\n    annotate_db_t *d = NULL;\n    struct annotate_metadata mdata;\n\n    init_internal();\n\n    r = _annotate_getdb(mboxname, uid, 0, &d);\n    if (r)\n        return (r == CYRUSDB_NOTFOUND ? 0 : r);\n\n    keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key));\n\n    do {\n        r = cyrusdb_fetch(d->db, key, keylen, &data, &datalen, tid(d));\n    } while (r == CYRUSDB_AGAIN);\n\n    if (!r && data) {\n        r = split_attribs(data, datalen, value, &mdata);\n        if (!r) {\n            \/* Force a copy, in case the putdb() call destroys\n             * the per-db data area that @data points to.  *\/\n            buf_cstring(value);\n        }\n        if (mdata.flags & ANNOTATE_FLAG_DELETED) {\n            buf_free(value);\n            r = CYRUSDB_NOTFOUND;\n        }\n    }\n    if (r == CYRUSDB_NOTFOUND) r = 0;\n\n    annotate_putdb(&d);\n    return r;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":84830,"func":"int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,\n\t\t\t const struct nlmsghdr *nlh,\n\t\t\t struct netlink_dump_control *control)\n{\n\tstruct netlink_callback *cb;\n\tstruct sock *sk;\n\tstruct netlink_sock *nlk;\n\tint ret;\n\n\tatomic_inc(&skb->users);\n\n\tsk = netlink_lookup(sock_net(ssk), ssk->sk_protocol, NETLINK_CB(skb).portid);\n\tif (sk == NULL) {\n\t\tret = -ECONNREFUSED;\n\t\tgoto error_free;\n\t}\n\n\tnlk = nlk_sk(sk);\n\tmutex_lock(nlk->cb_mutex);\n\t\/* A dump is in progress... *\/\n\tif (nlk->cb_running) {\n\t\tret = -EBUSY;\n\t\tgoto error_unlock;\n\t}\n\t\/* add reference of module which cb->dump belongs to *\/\n\tif (!try_module_get(control->module)) {\n\t\tret = -EPROTONOSUPPORT;\n\t\tgoto error_unlock;\n\t}\n\n\tcb = &nlk->cb;\n\tmemset(cb, 0, sizeof(*cb));\n\tcb->start = control->start;\n\tcb->dump = control->dump;\n\tcb->done = control->done;\n\tcb->nlh = nlh;\n\tcb->data = control->data;\n\tcb->module = control->module;\n\tcb->min_dump_alloc = control->min_dump_alloc;\n\tcb->skb = skb;\n\n\tnlk->cb_running = true;\n\n\tmutex_unlock(nlk->cb_mutex);\n\n\tif (cb->start)\n\t\tcb->start(cb);\n\n\tret = netlink_dump(sk);\n\tsock_put(sk);\n\n\tif (ret)\n\t\treturn ret;\n\n\t\/* We successfully started a dump, by returning -EINTR we\n\t * signal not to send ACK even if it was requested.\n\t *\/\n\treturn -EINTR;\n\nerror_unlock:\n\tsock_put(sk);\n\tmutex_unlock(nlk->cb_mutex);\nerror_free:\n\tkfree_skb(skb);\n\treturn ret;\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":413476,"func":"static void _slurm_rpc_dump_node_single(slurm_msg_t * msg)\n{\n\tDEF_TIMERS;\n\tchar *dump;\n\tint dump_size;\n\tslurm_msg_t response_msg;\n\tnode_info_single_msg_t *node_req_msg =\n\t\t(node_info_single_msg_t *) msg->data;\n\t\/* Locks: Read config, read node, read part (for part_is_visible) *\/\n\tslurmctld_lock_t node_write_lock = {\n\t\tREAD_LOCK, NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };\n\tuid_t uid = g_slurm_auth_get_uid(msg->auth_cred,\n\t\t\t\t\t slurmctld_config.auth_info);\n\n\tSTART_TIMER;\n\tdebug3(\"Processing RPC: REQUEST_NODE_INFO_SINGLE from uid=%d\", uid);\n\n\tif ((slurmctld_conf.private_data & PRIVATE_DATA_NODES) &&\n\t    (!validate_operator(uid))) {\n\t\terror(\"Security violation, REQUEST_NODE_INFO_SINGLE RPC from \"\n\t\t      \"uid=%d\", uid);\n\t\tslurm_send_rc_msg(msg, ESLURM_ACCESS_DENIED);\n\t\treturn;\n\t}\n\n\tlock_slurmctld(node_write_lock);\n\n#if 0\n\t\/* This function updates each node's alloc_cpus count and too slow for\n\t * our use here. Node write lock is needed if this function is used *\/\n\tselect_g_select_nodeinfo_set_all();\n#endif\n\tpack_one_node(&dump, &dump_size, node_req_msg->show_flags,\n\t\t      uid, node_req_msg->node_name, msg->protocol_version);\n\tunlock_slurmctld(node_write_lock);\n\tEND_TIMER2(\"_slurm_rpc_dump_node_single\");\n#if 0\n\tinfo(\"_slurm_rpc_dump_node_single, name=%s size=%d %s\",\n\t     node_req_msg->node_name, dump_size, TIME_STR);\n#endif\n\n\t\/* init response_msg structure *\/\n\tslurm_msg_t_init(&response_msg);\n\tresponse_msg.flags = msg->flags;\n\tresponse_msg.protocol_version = msg->protocol_version;\n\tresponse_msg.address = msg->address;\n\tresponse_msg.conn = msg->conn;\n\tresponse_msg.msg_type = RESPONSE_NODE_INFO;\n\tresponse_msg.data = dump;\n\tresponse_msg.data_size = dump_size;\n\n\t\/* send message *\/\n\tslurm_send_node_msg(msg->conn_fd, &response_msg);\n\txfree(dump);\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":461457,"func":"static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *path,\n                                       const char *basename,\n                                       const struct stat *stbuf,\n                                       V9fsStat *v9stat)\n{\n    int err;\n\n    memset(v9stat, 0, sizeof(*v9stat));\n\n    err = stat_to_qid(pdu, stbuf, &v9stat->qid);\n    if (err < 0) {\n        return err;\n    }\n    v9stat->mode = stat_to_v9mode(stbuf);\n    v9stat->atime = stbuf->st_atime;\n    v9stat->mtime = stbuf->st_mtime;\n    v9stat->length = stbuf->st_size;\n\n    v9fs_string_free(&v9stat->uid);\n    v9fs_string_free(&v9stat->gid);\n    v9fs_string_free(&v9stat->muid);\n\n    v9stat->n_uid = stbuf->st_uid;\n    v9stat->n_gid = stbuf->st_gid;\n    v9stat->n_muid = 0;\n\n    v9fs_string_free(&v9stat->extension);\n\n    if (v9stat->mode & P9_STAT_MODE_SYMLINK) {\n        err = v9fs_co_readlink(pdu, path, &v9stat->extension);\n        if (err < 0) {\n            return err;\n        }\n    } else if (v9stat->mode & P9_STAT_MODE_DEVICE) {\n        v9fs_string_sprintf(&v9stat->extension, \"%c %u %u\",\n                S_ISCHR(stbuf->st_mode) ? 'c' : 'b',\n                major(stbuf->st_rdev), minor(stbuf->st_rdev));\n    } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) {\n        v9fs_string_sprintf(&v9stat->extension, \"%s %lu\",\n                \"HARDLINKCOUNT\", (unsigned long)stbuf->st_nlink);\n    }\n\n    v9fs_string_sprintf(&v9stat->name, \"%s\", basename);\n\n    v9stat->size = 61 +\n        v9fs_string_size(&v9stat->name) +\n        v9fs_string_size(&v9stat->uid) +\n        v9fs_string_size(&v9stat->gid) +\n        v9fs_string_size(&v9stat->muid) +\n        v9fs_string_size(&v9stat->extension);\n    return 0;\n}","target":0,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":111812,"func":"static void digi_close(struct usb_serial_port *port)\n{\n\tDEFINE_WAIT(wait);\n\tint ret;\n\tunsigned char buf[32];\n\tstruct digi_port *priv = usb_get_serial_port_data(port);\n\n\tmutex_lock(&port->serial->disc_mutex);\n\t\/* if disconnected, just clear flags *\/\n\tif (port->serial->disconnected)\n\t\tgoto exit;\n\n\t\/* FIXME: Transmit idle belongs in the wait_unti_sent path *\/\n\tdigi_transmit_idle(port, DIGI_CLOSE_TIMEOUT);\n\n\t\/* disable input flow control *\/\n\tbuf[0] = DIGI_CMD_SET_INPUT_FLOW_CONTROL;\n\tbuf[1] = priv->dp_port_num;\n\tbuf[2] = DIGI_DISABLE;\n\tbuf[3] = 0;\n\n\t\/* disable output flow control *\/\n\tbuf[4] = DIGI_CMD_SET_OUTPUT_FLOW_CONTROL;\n\tbuf[5] = priv->dp_port_num;\n\tbuf[6] = DIGI_DISABLE;\n\tbuf[7] = 0;\n\n\t\/* disable reading modem signals automatically *\/\n\tbuf[8] = DIGI_CMD_READ_INPUT_SIGNALS;\n\tbuf[9] = priv->dp_port_num;\n\tbuf[10] = DIGI_DISABLE;\n\tbuf[11] = 0;\n\n\t\/* disable receive *\/\n\tbuf[12] = DIGI_CMD_RECEIVE_ENABLE;\n\tbuf[13] = priv->dp_port_num;\n\tbuf[14] = DIGI_DISABLE;\n\tbuf[15] = 0;\n\n\t\/* flush fifos *\/\n\tbuf[16] = DIGI_CMD_IFLUSH_FIFO;\n\tbuf[17] = priv->dp_port_num;\n\tbuf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;\n\tbuf[19] = 0;\n\n\tret = digi_write_oob_command(port, buf, 20, 0);\n\tif (ret != 0)\n\t\tdev_dbg(&port->dev, \"digi_close: write oob failed, ret=%d\\n\",\n\t\t\t\t\t\t\t\t\tret);\n\t\/* wait for final commands on oob port to complete *\/\n\tprepare_to_wait(&priv->dp_flush_wait, &wait,\n\t\t\tTASK_INTERRUPTIBLE);\n\tschedule_timeout(DIGI_CLOSE_TIMEOUT);\n\tfinish_wait(&priv->dp_flush_wait, &wait);\n\n\t\/* shutdown any outstanding bulk writes *\/\n\tusb_kill_urb(port->write_urb);\nexit:\n\tspin_lock_irq(&priv->dp_port_lock);\n\tpriv->dp_write_urb_in_use = 0;\n\twake_up_interruptible(&priv->dp_close_wait);\n\tspin_unlock_irq(&priv->dp_port_lock);\n\tmutex_unlock(&port->serial->disc_mutex);\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":33543,"func":"entry_guards_note_guard_success(guard_selection_t *gs,\n                                entry_guard_t *guard,\n                                unsigned old_state)\n{\n  tor_assert(gs);\n\n  \/* Save this, since we're about to overwrite it. *\/\n  const time_t last_time_on_internet = gs->last_time_on_internet;\n  gs->last_time_on_internet = approx_time();\n\n  guard->is_reachable = GUARD_REACHABLE_YES;\n  guard->failing_since = 0;\n  guard->is_pending = 0;\n  if (guard->is_filtered_guard)\n    guard->is_usable_filtered_guard = 1;\n\n  if (guard->confirmed_idx < 0) {\n    make_guard_confirmed(gs, guard);\n    if (!gs->primary_guards_up_to_date)\n      entry_guards_update_primary(gs);\n  }\n\n  unsigned new_state;\n  switch (old_state) {\n    case GUARD_CIRC_STATE_COMPLETE:\n    case GUARD_CIRC_STATE_USABLE_ON_COMPLETION:\n      new_state = GUARD_CIRC_STATE_COMPLETE;\n      break;\n    default:\n      tor_assert_nonfatal_unreached();\n      \/* Fall through. *\/\n    case GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD:\n      if (guard->is_primary) {\n        \/* XXXX #20832 -- I don't actually like this logic. It seems to make\n         * us a little more susceptible to evil-ISP attacks.  The mitigations\n         * I'm thinking of, however, aren't local to this point, so I'll leave\n         * it alone. *\/\n        \/* This guard may have become primary by virtue of being confirmed.\n         * If so, the circuit for it is now complete.\n         *\/\n        new_state = GUARD_CIRC_STATE_COMPLETE;\n      } else {\n        new_state = GUARD_CIRC_STATE_WAITING_FOR_BETTER_GUARD;\n      }\n      break;\n  }\n\n  if (! guard->is_primary) {\n    if (last_time_on_internet + get_internet_likely_down_interval()\n        < approx_time()) {\n      mark_primary_guards_maybe_reachable(gs);\n    }\n  }\n\n  log_info(LD_GUARD, \"Recorded success for %s%sguard %s\",\n           guard->is_primary?\"primary \":\"\",\n           guard->confirmed_idx>=0?\"confirmed \":\"\",\n           entry_guard_describe(guard));\n\n  return new_state;\n}","target":0,"code_token_length":505,"total_token_length":741,"max_tokens_setting":1024}
+{"idx":64059,"func":"static int send_mpa_reply(struct iwch_ep *ep, const void *pdata, u8 plen)\n{\n\tint mpalen;\n\tstruct tx_data_wr *req;\n\tstruct mpa_message *mpa;\n\tint len;\n\tstruct sk_buff *skb;\n\n\tPDBG(\"%s ep %p plen %d\\n\", __func__, ep, plen);\n\n\tmpalen = sizeof(*mpa) + plen;\n\n\tskb = get_skb(NULL, mpalen + sizeof(*req), GFP_KERNEL);\n\tif (!skb) {\n\t\tprintk(KERN_ERR MOD \"%s - cannot alloc skb!\\n\", __func__);\n\t\treturn -ENOMEM;\n\t}\n\tskb->priority = CPL_PRIORITY_DATA;\n\tskb_reserve(skb, sizeof(*req));\n\tmpa = (struct mpa_message *) skb_put(skb, mpalen);\n\tmemset(mpa, 0, sizeof(*mpa));\n\tmemcpy(mpa->key, MPA_KEY_REP, sizeof(mpa->key));\n\tmpa->flags = (ep->mpa_attr.crc_enabled ? MPA_CRC : 0) |\n\t\t     (markers_enabled ? MPA_MARKERS : 0);\n\tmpa->revision = mpa_rev;\n\tmpa->private_data_size = htons(plen);\n\tif (plen)\n\t\tmemcpy(mpa->private_data, pdata, plen);\n\n\t\/*\n\t * Reference the mpa skb.  This ensures the data area\n\t * will remain in memory until the hw acks the tx.\n\t * Function tx_ack() will deref it.\n\t *\/\n\tskb_get(skb);\n\tset_arp_failure_handler(skb, arp_failure_discard);\n\tskb_reset_transport_header(skb);\n\tlen = skb->len;\n\treq = (struct tx_data_wr *) skb_push(skb, sizeof(*req));\n\treq->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);\n\treq->wr_lo = htonl(V_WR_TID(ep->hwtid));\n\treq->len = htonl(len);\n\treq->param = htonl(V_TX_PORT(ep->l2t->smt_idx) |\n\t\t\t   V_TX_SNDBUF(snd_win>>15));\n\treq->flags = htonl(F_TX_INIT);\n\treq->sndseq = htonl(ep->snd_seq);\n\tep->mpa_skb = skb;\n\tstate_set(&ep->com, MPA_REP_SENT);\n\treturn iwch_l2t_send(ep->com.tdev, skb, ep->l2t);\n}","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":325290,"func":"void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome)\n\n{\n\n    const ARMCPRegInfo *ri = rip;\n\n    int target_el;\n\n\n\n    if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14\n\n        && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {\n\n        raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env));\n\n    }\n\n\n\n    if (!ri->accessfn) {\n\n        return;\n\n    }\n\n\n\n    switch (ri->accessfn(env, ri)) {\n\n    case CP_ACCESS_OK:\n\n        return;\n\n    case CP_ACCESS_TRAP:\n\n        target_el = exception_target_el(env);\n\n        break;\n\n    case CP_ACCESS_TRAP_EL2:\n\n        \/* Requesting a trap to EL2 when we're in EL3 or S-EL0\/1 is\n\n         * a bug in the access function.\n\n         *\/\n\n        assert(!arm_is_secure(env) && !arm_current_el(env) == 3);\n\n        target_el = 2;\n\n        break;\n\n    case CP_ACCESS_TRAP_EL3:\n\n        target_el = 3;\n\n        break;\n\n    case CP_ACCESS_TRAP_UNCATEGORIZED:\n\n        target_el = exception_target_el(env);\n\n        syndrome = syn_uncategorized();\n\n        break;\n\n    default:\n\n        g_assert_not_reached();\n\n    }\n\n\n\n    raise_exception(env, EXCP_UDEF, syndrome, target_el);\n\n}\n","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":237683,"func":"FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data)\n{\n\tFLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data;\n\n if(\n#if FLAC__HAS_OGG\n \/* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC *\/\n !decoder->private_->is_ogg &&\n#endif\n\t\tdecoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data)\n ) {\n *bytes = 0;\n\t\tdecoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;\n return false;\n }\n else if(*bytes > 0) {\n \/* While seeking, it is possible for our seek to land in the\n\t\t * middle of audio data that looks exactly like a frame header\n\t\t * from a future version of an encoder.  When that happens, our\n\t\t * error callback will get an\n\t\t * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its\n\t\t * unparseable_frame_count.  But there is a remote possibility\n\t\t * that it is properly synced at such a \"future-codec frame\",\n\t\t * so to make sure, we wait to see many \"unparseable\" errors in\n\t\t * a row before bailing out.\n\t\t *\/\n if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) {\n\t\t\tdecoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;\n return false;\n }\n else {\n const FLAC__StreamDecoderReadStatus status =\n#if FLAC__HAS_OGG\n\t\t\t\tdecoder->private_->is_ogg?\n\t\t\t\tread_callback_ogg_aspect_(decoder, buffer, bytes) :\n#endif\n\t\t\t\tdecoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data)\n ;\n if(status == FLAC__STREAM_DECODER_READ_STATUS_ABORT) {\n\t\t\t\tdecoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;\n return false;\n }\n else if(*bytes == 0) {\n if(\n\t\t\t\t\tstatus == FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM ||\n (\n#if FLAC__HAS_OGG\n \/* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC *\/\n !decoder->private_->is_ogg &&\n#endif\n\t\t\t\t\t\tdecoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data)\n )\n ) {\n\t\t\t\t\tdecoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;\n return false;\n }\n else\n return true;\n }\n else\n return true;\n }\n }\n else {\n \/* abort to avoid a deadlock *\/\n\t\tdecoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;\n return false;\n }\n \/* [1] @@@ HACK NOTE: The end-of-stream checking has to be hacked around\n\t * for Ogg FLAC.  This is because the ogg decoder aspect can lose sync\n\t * and at the same time hit the end of the stream (for example, seeking\n\t * to a point that is after the beginning of the last Ogg page).  There\n\t * is no way to report an Ogg sync loss through the callbacks (see note\n\t * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0.\n\t * So to keep the decoder from stopping at this point we gate the call\n\t * to the eof_callback and let the Ogg decoder aspect set the\n\t * end-of-stream state when it is needed.\n\t *\/\n}\n","target":0,"code_token_length":758,"total_token_length":994,"max_tokens_setting":1024}
+{"idx":57474,"func":"static int config_buf(struct usb_configuration *config,\n\t\tenum usb_device_speed speed, void *buf, u8 type)\n{\n\tstruct usb_config_descriptor\t*c = buf;\n\tvoid\t\t\t\t*next = buf + USB_DT_CONFIG_SIZE;\n\tint\t\t\t\tlen;\n\tstruct usb_function\t\t*f;\n\tint\t\t\t\tstatus;\n\n\tlen = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE;\n\t\/* write the config descriptor *\/\n\tc = buf;\n\tc->bLength = USB_DT_CONFIG_SIZE;\n\tc->bDescriptorType = type;\n\t\/* wTotalLength is written later *\/\n\tc->bNumInterfaces = config->next_interface_id;\n\tc->bConfigurationValue = config->bConfigurationValue;\n\tc->iConfiguration = config->iConfiguration;\n\tc->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;\n\tc->bMaxPower = encode_bMaxPower(speed, config);\n\n\t\/* There may be e.g. OTG descriptors *\/\n\tif (config->descriptors) {\n\t\tstatus = usb_descriptor_fillbuf(next, len,\n\t\t\t\tconfig->descriptors);\n\t\tif (status < 0)\n\t\t\treturn status;\n\t\tlen -= status;\n\t\tnext += status;\n\t}\n\n\t\/* add each function's descriptors *\/\n\tlist_for_each_entry(f, &config->functions, list) {\n\t\tstruct usb_descriptor_header **descriptors;\n\n\t\tdescriptors = function_descriptors(f, speed);\n\t\tif (!descriptors)\n\t\t\tcontinue;\n\t\tstatus = usb_descriptor_fillbuf(next, len,\n\t\t\t(const struct usb_descriptor_header **) descriptors);\n\t\tif (status < 0)\n\t\t\treturn status;\n\t\tlen -= status;\n\t\tnext += status;\n\t}\n\n\tlen = next - buf;\n\tc->wTotalLength = cpu_to_le16(len);\n\treturn len;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":396784,"func":"static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz,\n                            int kind, unsigned flags)\n{\n    word descr;\n#   ifdef MARK_BIT_PER_GRANULE\n      size_t granules;\n\n      if (byte_sz > MAXOBJBYTES)\n        flags |= LARGE_BLOCK;\n#   endif\n#   ifdef ENABLE_DISCLAIM\n      if (GC_obj_kinds[kind].ok_disclaim_proc)\n        flags |= HAS_DISCLAIM;\n      if (GC_obj_kinds[kind].ok_mark_unconditionally)\n        flags |= MARK_UNCONDITIONALLY;\n#   endif\n\n    \/* Set size, kind and mark proc fields *\/\n      hhdr -> hb_sz = byte_sz;\n      hhdr -> hb_obj_kind = (unsigned char)kind;\n      hhdr -> hb_flags = (unsigned char)flags;\n      hhdr -> hb_block = block;\n      descr = GC_obj_kinds[kind].ok_descriptor;\n      if (GC_obj_kinds[kind].ok_relocate_descr) descr += byte_sz;\n      hhdr -> hb_descr = descr;\n\n#   ifdef MARK_BIT_PER_OBJ\n     \/* Set hb_inv_sz as portably as possible.                          *\/\n     \/* We set it to the smallest value such that sz * inv_sz > 2**32    *\/\n     \/* This may be more precision than necessary.                      *\/\n      if (byte_sz > MAXOBJBYTES) {\n         hhdr -> hb_inv_sz = LARGE_INV_SZ;\n      } else {\n        word inv_sz;\n\n#       if CPP_WORDSZ == 64\n          inv_sz = ((word)1 << 32)\/byte_sz;\n          if (((inv_sz*byte_sz) >> 32) == 0) ++inv_sz;\n#       else  \/* 32 bit words *\/\n          GC_ASSERT(byte_sz >= 4);\n          inv_sz = ((unsigned)1 << 31)\/byte_sz;\n          inv_sz *= 2;\n          while (inv_sz*byte_sz > byte_sz) ++inv_sz;\n#       endif\n        hhdr -> hb_inv_sz = inv_sz;\n      }\n#   else \/* MARK_BIT_PER_GRANULE *\/\n      granules = BYTES_TO_GRANULES(byte_sz);\n      if (EXPECT(!GC_add_map_entry(granules), FALSE)) {\n        \/* Make it look like a valid block. *\/\n        hhdr -> hb_sz = HBLKSIZE;\n        hhdr -> hb_descr = 0;\n        hhdr -> hb_flags |= LARGE_BLOCK;\n        hhdr -> hb_map = 0;\n        return FALSE;\n      }\n      hhdr -> hb_map = GC_obj_map[(hhdr -> hb_flags & LARGE_BLOCK) != 0 ?\n                                    0 : granules];\n#   endif \/* MARK_BIT_PER_GRANULE *\/\n\n    \/* Clear mark bits *\/\n    GC_clear_hdr_marks(hhdr);\n\n    hhdr -> hb_last_reclaimed = (unsigned short)GC_gc_no;\n    return(TRUE);\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":363492,"func":"irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf)\n{\n    int rc;\n    \n    if (!server)\n    {\n        weechat_printf (NULL,\n                        _(\"%s%s: sending data to server: null pointer (please \"\n                          \"report problem to developers)\"),\n                        weechat_prefix (\"error\"), IRC_PLUGIN_NAME);\n        return 0;\n    }\n\n    if (size_buf <= 0)\n    {\n        weechat_printf (server->buffer,\n                        _(\"%s%s: sending data to server: empty buffer (please \"\n                          \"report problem to developers)\"),\n                        weechat_prefix (\"error\"), IRC_PLUGIN_NAME);\n        return 0;\n    }\n    \n#ifdef HAVE_GNUTLS\n    if (server->ssl_connected)\n        rc = gnutls_record_send (server->gnutls_sess, buffer, size_buf);\n    else\n#endif\n        rc = send (server->sock, buffer, size_buf, 0);\n    \n    if (rc < 0)\n    {\n#ifdef HAVE_GNUTLS\n        if (server->ssl_connected)\n        {\n            weechat_printf (server->buffer,\n                            _(\"%s%s: sending data to server: %d %s\"),\n                            weechat_prefix (\"error\"), IRC_PLUGIN_NAME,\n                            rc,\n                            gnutls_strerror (rc));\n        }\n        else\n#endif\n        {\n            weechat_printf (server->buffer,\n                            _(\"%s%s: sending data to server: %d %s\"),\n                            weechat_prefix (\"error\"), IRC_PLUGIN_NAME,\n                            errno,\n                            strerror (errno));\n        }\n    }\n    \n    return rc;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":96670,"func":"compile_return(char_u *arg, int check_return_type, int legacy, cctx_T *cctx)\n{\n    char_u\t*p = arg;\n    type_T\t*stack_type;\n\n    if (*p != NUL && *p != '|' && *p != '\\n')\n    {\n\t\/\/ For a lambda, \"return expr\" is always used, also when \"expr\" results\n\t\/\/ in a void.\n\tif (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID\n\t\t&& (cctx->ctx_ufunc->uf_flags & FC_LAMBDA) == 0)\n\t{\n\t    emsg(_(e_returning_value_in_function_without_return_type));\n\t    return NULL;\n\t}\n\tif (legacy)\n\t{\n\t    int save_flags = cmdmod.cmod_flags;\n\n\t    generate_LEGACY_EVAL(cctx, p);\n\t    if (need_type(&t_any, cctx->ctx_ufunc->uf_ret_type, -1,\n\t\t\t\t\t\t0, cctx, FALSE, FALSE) == FAIL)\n\t\treturn NULL;\n\t    cmdmod.cmod_flags |= CMOD_LEGACY;\n\t    (void)skip_expr(&p, NULL);\n\t    cmdmod.cmod_flags = save_flags;\n\t}\n\telse\n\t{\n\t    \/\/ compile return argument into instructions\n\t    if (compile_expr0(&p, cctx) == FAIL)\n\t\treturn NULL;\n\t}\n\n\tif (cctx->ctx_skip != SKIP_YES)\n\t{\n\t    \/\/ \"check_return_type\" with uf_ret_type set to &t_unknown is used\n\t    \/\/ for an inline function without a specified return type.  Set the\n\t    \/\/ return type here.\n\t    stack_type = get_type_on_stack(cctx, 0);\n\t    if ((check_return_type && (cctx->ctx_ufunc->uf_ret_type == NULL\n\t\t\t\t|| cctx->ctx_ufunc->uf_ret_type == &t_unknown))\n\t\t    || (!check_return_type\n\t\t\t\t&& cctx->ctx_ufunc->uf_ret_type == &t_unknown))\n\t    {\n\t\tcctx->ctx_ufunc->uf_ret_type = stack_type;\n\t    }\n\t    else\n\t    {\n\t\tif (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,\n\t\t\t\t\t\t0, cctx, FALSE, FALSE) == FAIL)\n\t\t    return NULL;\n\t    }\n\t}\n    }\n    else\n    {\n\t\/\/ \"check_return_type\" cannot be TRUE, only used for a lambda which\n\t\/\/ always has an argument.\n\tif (cctx->ctx_ufunc->uf_ret_type->tt_type != VAR_VOID\n\t\t&& cctx->ctx_ufunc->uf_ret_type->tt_type != VAR_UNKNOWN)\n\t{\n\t    emsg(_(e_missing_return_value));\n\t    return NULL;\n\t}\n\n\t\/\/ No argument, return zero.\n\tgenerate_PUSHNR(cctx, 0);\n    }\n\n    \/\/ Undo any command modifiers.\n    generate_undo_cmdmods(cctx);\n\n    if (cctx->ctx_skip != SKIP_YES && generate_instr(cctx, ISN_RETURN) == NULL)\n\treturn NULL;\n\n    \/\/ \"return val | endif\" is possible\n    return skipwhite(p);\n}","target":0,"code_token_length":667,"total_token_length":903,"max_tokens_setting":1024}
+{"idx":496557,"func":"void SNC_io_parser<EW>::read_items(int plus01) {\n\n  typename std::vector<Vertex_iterator>::iterator vi;\n  for(vi=Vertex_of.begin(); vi!=Vertex_of.end(); ++vi) {\n    if (!read_vertex<K>(*vi))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in node line\"<<std::endl;\n      return;\n    }\n  }\n\n  typename std::vector<Halfedge_iterator>::iterator ei;\n  for(ei=Edge_of.begin(); ei!=Edge_of.end(); ++ei) {\n    if (!read_edge<K>(*ei))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in edge line\"<<std::endl;\n      return;\n    }\n  }\n\n  typedef typename std::vector<Halffacet_iterator>::iterator vhf_iterator;\n  vhf_iterator fi;\n  for(fi=Halffacet_of.begin(); fi!=Halffacet_of.end(); ++fi) {\n    if (!read_facet<K>(*fi))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in facet line\"<<std::endl;\n      return;\n    }\n  }\n  typename std::vector<Volume_iterator>::iterator ci;\n  for(ci=Volume_of.begin()+plus01; ci!=Volume_of.end(); ++ci) {\n    if (!read_volume(*ci))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in volume line\"<<std::endl;\n      return;\n    }\n  }\n  typename std::vector<SHalfedge_iterator>::iterator sei;\n  for(sei=SEdge_of.begin(); sei!=SEdge_of.end(); ++sei) {\n    if (!read_sedge<K>(*sei))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in sedge line\"<<std::endl;\n      return;\n    }\n  }\n  typename std::vector<SHalfloop_iterator>::iterator sli;\n  for(sli=SLoop_of.begin(); sli!=SLoop_of.end(); ++sli) {\n    if (!read_sloop<K>(*sli))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in sloop line\"<<std::endl;\n      return;\n    }\n  }\n  typename std::vector<SFace_iterator>::iterator sfi;\n  for(sfi=SFace_of.begin(); sfi!=SFace_of.end(); ++sfi) {\n    if (!read_sface(*sfi))\n    {\n      std::cerr<<\"SNC_io_parser::read: error in sface line\"<<std::endl;\n      return;\n    }\n  }\n\n  SNC_constructor C(*this->sncp());\n  C.assign_indices();\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":153873,"func":"static GF_Err parse_track_action_params(char *string, TrackAction *action)\n{\n\tchar *param = string;\n\tif (!action || !string) return GF_BAD_PARAM;\n\n\twhile (param) {\n\t\tparam = gf_url_colon_suffix(param);\n\t\tif (param) {\n\t\t\t*param = 0;\n\t\t\tparam++;\n#ifndef GPAC_DISABLE_MEDIA_EXPORT\n\t\t\tif (!strncmp(\"vttnomerge\", param, 10)) {\n\t\t\t\taction->dump_type |= GF_EXPORT_WEBVTT_NOMERGE;\n\t\t\t} else if (!strncmp(\"layer\", param, 5)) {\n\t\t\t\taction->dump_type |= GF_EXPORT_SVC_LAYER;\n\t\t\t} else if (!strncmp(\"full\", param, 4)) {\n\t\t\t\taction->dump_type |= GF_EXPORT_NHML_FULL;\n\t\t\t} else if (!strncmp(\"embedded\", param, 8)) {\n\t\t\t\taction->dump_type |= GF_EXPORT_WEBVTT_META_EMBEDDED;\n\t\t\t} else if (!strncmp(\"output=\", param, 7)) {\n\t\t\t\taction->out_name = gf_strdup(param+7);\n\t\t\t} else if (!strncmp(\"src=\", param, 4)) {\n\t\t\t\taction->src_name = gf_strdup(param+4);\n\t\t\t} else if (!strncmp(\"box=\", param, 4)) {\n\t\t\t\taction->src_name = gf_strdup(param+4);\n\t\t\t\taction->sample_num = 1;\n\t\t\t} else if (!strncmp(\"type=\", param, 4)) {\n\t\t\t\taction->udta_type = GF_4CC(param[5], param[6], param[7], param[8]);\n\t\t\t} else if (action->dump_type == GF_EXPORT_RAW_SAMPLES) {\n\t\t\t\taction->sample_num = atoi(param);\n\t\t\t}\n#endif\n\t\t}\n\t}\n\tif (!strcmp(string, \"*\")) {\n\t\taction->trackID = (u32) -1;\n\t} else {\n\t\taction->trackID = atoi(string);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":305180,"func":"SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,\n\t   u64 persistent_fid, u64 volatile_fid)\n{\n\tstruct smb2_close_req *req;\n\tstruct smb2_close_rsp *rsp;\n\tstruct TCP_Server_Info *server;\n\tstruct cifs_ses *ses = tcon->ses;\n\tstruct kvec iov[1];\n\tint resp_buftype;\n\tint rc = 0;\n\n\tcifs_dbg(FYI, \"Close\\n\");\n\n\tif (ses && (ses->server))\n\t\tserver = ses->server;\n\telse\n\t\treturn -EIO;\n\n\trc = small_smb2_init(SMB2_CLOSE, tcon, (void **) &req);\n\tif (rc)\n\t\treturn rc;\n\n\treq->PersistentFileId = persistent_fid;\n\treq->VolatileFileId = volatile_fid;\n\n\tiov[0].iov_base = (char *)req;\n\t\/* 4 for rfc1002 length field *\/\n\tiov[0].iov_len = get_rfc1002_length(req) + 4;\n\n\trc = SendReceive2(xid, ses, iov, 1, &resp_buftype, 0);\n\trsp = (struct smb2_close_rsp *)iov[0].iov_base;\n\n\tif (rc != 0) {\n\t\tif (tcon)\n\t\t\tcifs_stats_fail_inc(tcon, SMB2_CLOSE_HE);\n\t\tgoto close_exit;\n\t}\n\n\t\/* BB FIXME - decode close response, update inode for caching *\/\n\nclose_exit:\n\tfree_rsp_buf(resp_buftype, rsp);\n\treturn rc;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":356322,"func":"static int add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)\n{\n\tstruct commit_list *parent = commit->parents;\n\tunsigned left_flag;\n\n\tif (commit->object.flags & ADDED)\n\t\treturn 0;\n\tcommit->object.flags |= ADDED;\n\n\t\/*\n\t * If the commit is uninteresting, don't try to\n\t * prune parents - we want the maximal uninteresting\n\t * set.\n\t *\n\t * Normally we haven't parsed the parent\n\t * yet, so we won't have a parent of a parent\n\t * here. However, it may turn out that we've\n\t * reached this commit some other way (where it\n\t * wasn't uninteresting), in which case we need\n\t * to mark its parents recursively too..\n\t *\/\n\tif (commit->object.flags & UNINTERESTING) {\n\t\twhile (parent) {\n\t\t\tstruct commit *p = parent->item;\n\t\t\tparent = parent->next;\n\t\t\tif (parse_commit(p) < 0)\n\t\t\t\treturn -1;\n\t\t\tp->object.flags |= UNINTERESTING;\n\t\t\tif (p->parents)\n\t\t\t\tmark_parents_uninteresting(p);\n\t\t\tif (p->object.flags & SEEN)\n\t\t\t\tcontinue;\n\t\t\tp->object.flags |= SEEN;\n\t\t\tinsert_by_date(p, list);\n\t\t}\n\t\treturn 0;\n\t}\n\n\t\/*\n\t * Ok, the commit wasn't uninteresting. Try to\n\t * simplify the commit history and find the parent\n\t * that has no differences in the path set if one exists.\n\t *\/\n\ttry_to_simplify_commit(revs, commit);\n\n\tif (revs->no_walk)\n\t\treturn 0;\n\n\tleft_flag = (commit->object.flags & SYMMETRIC_LEFT);\n\n\tfor (parent = commit->parents; parent; parent = parent->next) {\n\t\tstruct commit *p = parent->item;\n\n\t\tif (parse_commit(p) < 0)\n\t\t\treturn -1;\n\t\tp->object.flags |= left_flag;\n\t\tif (!(p->object.flags & SEEN)) {\n\t\t\tp->object.flags |= SEEN;\n\t\t\tinsert_by_date(p, list);\n\t\t}\n\t\tif(revs->first_parent_only)\n\t\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":102273,"func":"static int nntp_mbox_sync(struct Mailbox *m, int *index_hint)\n{\n  if (!m)\n    return -1;\n\n  struct NntpMboxData *mdata = m->mdata;\n  int rc;\n\n  \/* check for new articles *\/\n  mdata->adata->check_time = 0;\n  rc = check_mailbox(m);\n  if (rc)\n    return rc;\n\n#ifdef USE_HCACHE\n  mdata->last_cached = 0;\n  header_cache_t *hc = nntp_hcache_open(mdata);\n#endif\n\n  for (int i = 0; i < m->msg_count; i++)\n  {\n    struct Email *e = m->emails[i];\n    if (!e)\n      break;\n\n    char buf[16];\n\n    snprintf(buf, sizeof(buf), ANUM, nntp_edata_get(e)->article_num);\n    if (mdata->bcache && e->deleted)\n    {\n      mutt_debug(LL_DEBUG2, \"mutt_bcache_del %s\\n\", buf);\n      mutt_bcache_del(mdata->bcache, buf);\n    }\n\n#ifdef USE_HCACHE\n    if (hc && (e->changed || e->deleted))\n    {\n      if (e->deleted && !e->read)\n        mdata->unread--;\n      mutt_debug(LL_DEBUG2, \"mutt_hcache_store %s\\n\", buf);\n      mutt_hcache_store(hc, buf, strlen(buf), e, 0);\n    }\n#endif\n  }\n\n#ifdef USE_HCACHE\n  if (hc)\n  {\n    mutt_hcache_close(hc);\n    mdata->last_cached = mdata->last_loaded;\n  }\n#endif\n\n  \/* save .newsrc entries *\/\n  nntp_newsrc_gen_entries(m);\n  nntp_newsrc_update(mdata->adata);\n  nntp_newsrc_close(mdata->adata);\n  return 0;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":6372,"func":"static int oidc_request_post_preserved_restore(request_rec *r,\n\t\tconst char *original_url) {\n\n\toidc_debug(r, \"enter: original_url=%s\", original_url);\n\n\tconst char *method = \"postOnLoad\";\n\tconst char *script =\n\t\t\tapr_psprintf(r->pool,\n\t\t\t\t\t\"    <script type=\\\"text\/javascript\\\">\\n\"\n\t\t\t\t\t\"      function str_decode(string) {\\n\"\n\t\t\t\t\t\"        try {\\n\"\n\t\t\t\t\t\"          result = decodeURIComponent(string);\\n\"\n\t\t\t\t\t\"        } catch (e) {\\n\"\n\t\t\t\t\t\"          result =  unescape(string);\\n\"\n\t\t\t\t\t\"        }\\n\"\n\t\t\t\t\t\"        return result;\\n\"\n\t\t\t\t\t\"      }\\n\"\n\t\t\t\t\t\"      function %s() {\\n\"\n\t\t\t\t\t\"        var mod_auth_openidc_preserve_post_params = JSON.parse(sessionStorage.getItem('mod_auth_openidc_preserve_post_params'));\\n\"\n\t\t\t\t\t\"\t\t sessionStorage.removeItem('mod_auth_openidc_preserve_post_params');\\n\"\n\t\t\t\t\t\"        for (var key in mod_auth_openidc_preserve_post_params) {\\n\"\n\t\t\t\t\t\"          var input = document.createElement(\\\"input\\\");\\n\"\n\t\t\t\t\t\"          input.name = str_decode(key);\\n\"\n\t\t\t\t\t\"          input.value = str_decode(mod_auth_openidc_preserve_post_params[key]);\\n\"\n\t\t\t\t\t\"          input.type = \\\"hidden\\\";\\n\"\n\t\t\t\t\t\"          document.forms[0].appendChild(input);\\n\"\n\t\t\t\t\t\"        }\\n\"\n\t\t\t\t\t\"        document.forms[0].action = '%s';\\n\"\n\t\t\t\t\t\"        document.forms[0].submit();\\n\"\n\t\t\t\t\t\"      }\\n\"\n\t\t\t\t\t\"    <\/script>\\n\", method, original_url);\n\n\tconst char *body = \"    <p>Restoring...<\/p>\\n\"\n\t\t\t\"    <form method=\\\"post\\\"><\/form>\\n\";\n\n\treturn oidc_util_html_send(r, \"Restoring...\", script, method, body,\n\t\t\tOK);\n}","target":1,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":143313,"func":"static int php_mb_parse_encoding_array(const Array& array,\n                                       mbfl_encoding ***return_list,\n                                       int *return_size, int persistent) {\n  int n, l, size, bauto,ret = 1;\n  mbfl_encoding *encoding;\n  mbfl_no_encoding *src;\n  mbfl_encoding **list, **entry;\n\n  list = nullptr;\n  mbfl_no_encoding *identify_list = MBSTRG(default_detect_order_list);\n  int identify_list_size = MBSTRG(default_detect_order_list_size);\n\n  size = array.size() + identify_list_size;\n  list = (mbfl_encoding **)calloc(size, sizeof(mbfl_encoding*));\n  if (list != nullptr) {\n    entry = list;\n    bauto = 0;\n    n = 0;\n    for (ArrayIter iter(array); iter; ++iter) {\n      auto const hash_entry = iter.second().toString();\n      if (strcasecmp(hash_entry.data(), \"auto\") == 0) {\n        if (!bauto) {\n          bauto = 1;\n          l = identify_list_size;\n          src = identify_list;\n          for (int j = 0; j < l; j++) {\n            *entry++ = (mbfl_encoding*) mbfl_no2encoding(*src++);\n            n++;\n          }\n        }\n      } else {\n        encoding = (mbfl_encoding*) mbfl_name2encoding(hash_entry.data());\n        if (encoding != nullptr) {\n          *entry++ = encoding;\n          n++;\n        } else {\n          ret = 0;\n        }\n      }\n    }\n    if (n > 0) {\n      if (return_list) {\n        *return_list = list;\n      } else {\n        free(list);\n      }\n    } else {\n      free(list);\n      if (return_list) {\n        *return_list = nullptr;\n      }\n      ret = 0;\n    }\n    if (return_size) {\n      *return_size = n;\n    }\n  } else {\n    if (return_list) {\n      *return_list = nullptr;\n    }\n    if (return_size) {\n      *return_size = 0;\n    }\n    ret = 0;\n  }\n  return ret;\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":451808,"func":"static int rbd_try_acquire_lock(struct rbd_device *rbd_dev)\n{\n\tint ret;\n\n\tdown_read(&rbd_dev->lock_rwsem);\n\tdout(\"%s rbd_dev %p read lock_state %d\\n\", __func__, rbd_dev,\n\t     rbd_dev->lock_state);\n\tif (__rbd_is_lock_owner(rbd_dev)) {\n\t\tup_read(&rbd_dev->lock_rwsem);\n\t\treturn 0;\n\t}\n\n\tup_read(&rbd_dev->lock_rwsem);\n\tdown_write(&rbd_dev->lock_rwsem);\n\tdout(\"%s rbd_dev %p write lock_state %d\\n\", __func__, rbd_dev,\n\t     rbd_dev->lock_state);\n\tif (__rbd_is_lock_owner(rbd_dev)) {\n\t\tup_write(&rbd_dev->lock_rwsem);\n\t\treturn 0;\n\t}\n\n\tret = rbd_try_lock(rbd_dev);\n\tif (ret < 0) {\n\t\trbd_warn(rbd_dev, \"failed to lock header: %d\", ret);\n\t\tif (ret == -EBLACKLISTED)\n\t\t\tgoto out;\n\n\t\tret = 1; \/* request lock anyway *\/\n\t}\n\tif (ret > 0) {\n\t\tup_write(&rbd_dev->lock_rwsem);\n\t\treturn ret;\n\t}\n\n\trbd_assert(rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED);\n\trbd_assert(list_empty(&rbd_dev->running_list));\n\n\tret = rbd_post_acquire_action(rbd_dev);\n\tif (ret) {\n\t\trbd_warn(rbd_dev, \"post-acquire action failed: %d\", ret);\n\t\t\/*\n\t\t * Can't stay in RBD_LOCK_STATE_LOCKED because\n\t\t * rbd_lock_add_request() would let the request through,\n\t\t * assuming that e.g. object map is locked and loaded.\n\t\t *\/\n\t\trbd_unlock(rbd_dev);\n\t}\n\nout:\n\twake_lock_waiters(rbd_dev, ret);\n\tup_write(&rbd_dev->lock_rwsem);\n\treturn ret;\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":364556,"func":"static void nntp_reset(void)\n{\n    int i;\n\n    proc_cleanup();\n\n    \/* close local mailbox *\/\n    if (group_state)\n\tindex_close(&group_state);\n\n    \/* close backend connections *\/\n    i = 0;\n    while (backend_cached && backend_cached[i]) {\n\tproxy_downserver(backend_cached[i]);\n\tfree(backend_cached[i]->context);\n\tfree(backend_cached[i]);\n\ti++;\n    }\n    if (backend_cached) free(backend_cached);\n    backend_cached = NULL;\n    backend_current = NULL;\n\n    if (nntp_in) {\n\tprot_NONBLOCK(nntp_in);\n\tprot_fill(nntp_in);\n\t\n\tprot_free(nntp_in);\n    }\n\n    if (nntp_out) {\n\tprot_flush(nntp_out);\n\tprot_free(nntp_out);\n    }\n    \n    nntp_in = nntp_out = NULL;\n\n    if (protin) protgroup_reset(protin);\n\n#ifdef HAVE_SSL\n    if (tls_conn) {\n\ttls_reset_servertls(&tls_conn);\n\ttls_conn = NULL;\n    }\n#endif\n\n    cyrus_reset_stdio();\n\n    strcpy(nntp_clienthost, \"[local]\");\n    if (nntp_logfd != -1) {\n\tclose(nntp_logfd);\n\tnntp_logfd = -1;\n    }\n    if (nntp_userid != NULL) {\n\tfree(nntp_userid);\n\tnntp_userid = NULL;\n    }\n    if (nntp_authstate) {\n\tauth_freestate(nntp_authstate);\n\tnntp_authstate = NULL;\n    }\n    if (nntp_saslconn) {\n\tsasl_dispose(&nntp_saslconn);\n\tnntp_saslconn = NULL;\n    }\n    nntp_starttls_done = 0;\n\n    if(saslprops.iplocalport) {\n       free(saslprops.iplocalport);\n       saslprops.iplocalport = NULL;\n    }\n    if(saslprops.ipremoteport) {\n       free(saslprops.ipremoteport);\n       saslprops.ipremoteport = NULL;\n    }\n    if(saslprops.authid) {\n       free(saslprops.authid);\n       saslprops.authid = NULL;\n    }\n    saslprops.ssf = 0;\n\n    nntp_exists = 0;\n    nntp_current = 0;\n    did_capabilities = 0;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":413575,"func":"_rpc_reboot(slurm_msg_t *msg)\n{\n\tchar *reboot_program, *cmd = NULL, *sp;\n\treboot_msg_t *reboot_msg;\n\tslurm_ctl_conf_t *cfg;\n\tuid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred,\n\t\t\t\t\t     conf->auth_info);\n\tint exit_code;\n\n\tif (!_slurm_authorized_user(req_uid))\n\t\terror(\"Security violation, reboot RPC from uid %d\",\n\t\t      req_uid);\n\telse {\n\t\tcfg = slurm_conf_lock();\n\t\treboot_program = cfg->reboot_program;\n\t\tif (reboot_program) {\n\t\t\tsp = strchr(reboot_program, ' ');\n\t\t\tif (sp)\n\t\t\t\tsp = xstrndup(reboot_program,\n\t\t\t\t\t      (sp - reboot_program));\n\t\t\telse\n\t\t\t\tsp = xstrdup(reboot_program);\n\t\t\treboot_msg = (reboot_msg_t *) msg->data;\n\t\t\tif (reboot_msg && reboot_msg->features) {\n\t\t\t\t\/*\n\t\t\t\t * Run reboot_program with only arguments given\n\t\t\t\t * in reboot_msg->features.\n\t\t\t\t *\/\n\t\t\t\tinfo(\"Node reboot request with features %s being processed\",\n\t\t\t\t     reboot_msg->features);\n\t\t\t\t(void) node_features_g_node_set(\n\t\t\t\t\t\treboot_msg->features);\n\t\t\t\tif (reboot_msg->features[0]) {\n\t\t\t\t\txstrfmtcat(cmd, \"%s %s\",\n\t\t\t\t\t\t   sp, reboot_msg->features);\n\t\t\t\t} else {\n\t\t\t\t\tcmd = xstrdup(sp);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t\/* Run reboot_program verbatim *\/\n\t\t\t\tcmd = xstrdup(reboot_program);\n\t\t\t\tinfo(\"Node reboot request being processed\");\n\t\t\t}\n\t\t\tif (access(sp, R_OK | X_OK) < 0)\n\t\t\t\terror(\"Cannot run RebootProgram [%s]: %m\", sp);\n\t\t\telse if ((exit_code = system(cmd)))\n\t\t\t\terror(\"system(%s) returned %d\", reboot_program,\n\t\t\t\t      exit_code);\n\t\t\txfree(sp);\n\t\t\txfree(cmd);\n\t\t} else\n\t\t\terror(\"RebootProgram isn't defined in config\");\n\t\tslurm_conf_unlock();\n\t}\n\n\t\/* Never return a message, slurmctld does not expect one *\/\n\t\/* slurm_send_rc_msg(msg, rc); *\/\n}","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":291902,"func":"bool ValuesFromConstNode(const NodeDef& node, std::vector<T>* values) {\n  if (node.op() != \"Const\") {\n    return false;\n  }\n\n  if (node.attr().count(\"dtype\") == 0 || node.attr().count(\"value\") == 0 ||\n      node.attr().at(\"dtype\").type() != DataTypeToEnum<T>::value) {\n    return false;\n  }\n\n  \/\/ TensorProto represents the content of the tensor in either <type>_val or\n  \/\/ tensor_content.\n  const TensorProto& tensor = node.attr().at(\"value\").tensor();\n  typename checkpoint::SaveTypeTraits<T>::RepeatedField* tensor_values =\n      checkpoint::MutableTensorProtoData<T>(const_cast<TensorProto*>(&tensor));\n\n  if (!tensor_values->empty() && tensor.has_tensor_shape()) {\n    \/\/ When tensor_shape is set, theoretically the representation of the data\n    \/\/ could be compressed. So, before copying values to the returned vector,\n    \/\/ make sure no compression happens.\n    const TensorShapeProto& shape = tensor.tensor_shape();\n    if (shape.dim_size() == 1 && shape.dim(0).size() == tensor_values->size()) {\n      values->insert(values->end(), tensor_values->begin(),\n                     tensor_values->end());\n      return true;\n    }\n  }\n\n  const auto tensor_content_size = tensor.tensor_content().size();\n  if (tensor_content_size > 0) {\n    CHECK_EQ(0, tensor_content_size % sizeof(T))\n        << \"tensor_content_size (\" << tensor_content_size\n        << \") is not a multiple of \" << sizeof(T);\n    values->resize(tensor_content_size \/ sizeof(T));\n    port::CopyToArray(tensor.tensor_content(),\n                      reinterpret_cast<char*>(values->data()));\n    return true;\n  }\n\n  return false;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":273454,"func":"static void mark_ptr_not_null_reg(struct bpf_reg_state *reg)\n{\n\tswitch (reg->type) {\n\tcase PTR_TO_MAP_VALUE_OR_NULL: {\n\t\tconst struct bpf_map *map = reg->map_ptr;\n\n\t\tif (map->inner_map_meta) {\n\t\t\treg->type = CONST_PTR_TO_MAP;\n\t\t\treg->map_ptr = map->inner_map_meta;\n\t\t} else if (map->map_type == BPF_MAP_TYPE_XSKMAP) {\n\t\t\treg->type = PTR_TO_XDP_SOCK;\n\t\t} else if (map->map_type == BPF_MAP_TYPE_SOCKMAP ||\n\t\t\t   map->map_type == BPF_MAP_TYPE_SOCKHASH) {\n\t\t\treg->type = PTR_TO_SOCKET;\n\t\t} else {\n\t\t\treg->type = PTR_TO_MAP_VALUE;\n\t\t}\n\t\tbreak;\n\t}\n\tcase PTR_TO_SOCKET_OR_NULL:\n\t\treg->type = PTR_TO_SOCKET;\n\t\tbreak;\n\tcase PTR_TO_SOCK_COMMON_OR_NULL:\n\t\treg->type = PTR_TO_SOCK_COMMON;\n\t\tbreak;\n\tcase PTR_TO_TCP_SOCK_OR_NULL:\n\t\treg->type = PTR_TO_TCP_SOCK;\n\t\tbreak;\n\tcase PTR_TO_BTF_ID_OR_NULL:\n\t\treg->type = PTR_TO_BTF_ID;\n\t\tbreak;\n\tcase PTR_TO_MEM_OR_NULL:\n\t\treg->type = PTR_TO_MEM;\n\t\tbreak;\n\tcase PTR_TO_RDONLY_BUF_OR_NULL:\n\t\treg->type = PTR_TO_RDONLY_BUF;\n\t\tbreak;\n\tcase PTR_TO_RDWR_BUF_OR_NULL:\n\t\treg->type = PTR_TO_RDWR_BUF;\n\t\tbreak;\n\tdefault:\n\t\tWARN_ONCE(1, \"unknown nullable register type\");\n\t}\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":488783,"func":"static gboolean avdtp_parse_cmd(struct avdtp *session, uint8_t transaction,\n\t\t\t\tuint8_t signal_id, void *buf, int size)\n{\n\tswitch (signal_id) {\n\tcase AVDTP_DISCOVER:\n\t\tDBG(\"Received DISCOVER_CMD\");\n\t\treturn avdtp_discover_cmd(session, transaction, buf, size);\n\tcase AVDTP_GET_CAPABILITIES:\n\t\tDBG(\"Received  GET_CAPABILITIES_CMD\");\n\t\treturn avdtp_getcap_cmd(session, transaction, buf, size,\n\t\t\t\t\t\t\t\t\tFALSE);\n\tcase AVDTP_GET_ALL_CAPABILITIES:\n\t\tDBG(\"Received  GET_ALL_CAPABILITIES_CMD\");\n\t\treturn avdtp_getcap_cmd(session, transaction, buf, size, TRUE);\n\tcase AVDTP_SET_CONFIGURATION:\n\t\tDBG(\"Received SET_CONFIGURATION_CMD\");\n\t\treturn avdtp_setconf_cmd(session, transaction, buf, size);\n\tcase AVDTP_GET_CONFIGURATION:\n\t\tDBG(\"Received GET_CONFIGURATION_CMD\");\n\t\treturn avdtp_getconf_cmd(session, transaction, buf, size);\n\tcase AVDTP_RECONFIGURE:\n\t\tDBG(\"Received RECONFIGURE_CMD\");\n\t\treturn avdtp_reconf_cmd(session, transaction, buf, size);\n\tcase AVDTP_OPEN:\n\t\tDBG(\"Received OPEN_CMD\");\n\t\treturn avdtp_open_cmd(session, transaction, buf, size);\n\tcase AVDTP_START:\n\t\tDBG(\"Received START_CMD\");\n\t\treturn avdtp_start_cmd(session, transaction, buf, size);\n\tcase AVDTP_CLOSE:\n\t\tDBG(\"Received CLOSE_CMD\");\n\t\treturn avdtp_close_cmd(session, transaction, buf, size);\n\tcase AVDTP_SUSPEND:\n\t\tDBG(\"Received SUSPEND_CMD\");\n\t\treturn avdtp_suspend_cmd(session, transaction, buf, size);\n\tcase AVDTP_ABORT:\n\t\tDBG(\"Received ABORT_CMD\");\n\t\treturn avdtp_abort_cmd(session, transaction, buf, size);\n\tcase AVDTP_SECURITY_CONTROL:\n\t\tDBG(\"Received SECURITY_CONTROL_CMD\");\n\t\treturn avdtp_secctl_cmd(session, transaction, buf, size);\n\tcase AVDTP_DELAY_REPORT:\n\t\tDBG(\"Received DELAY_REPORT_CMD\");\n\t\treturn avdtp_delayreport_cmd(session, transaction, buf, size);\n\tdefault:\n\t\tDBG(\"Received unknown request id %u\", signal_id);\n\t\treturn avdtp_unknown_cmd(session, transaction, signal_id);\n\t}\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":257821,"func":"static int nntp_mbox_sync ( struct Context * ctx , int * index_hint ) {\n struct NntpData * nntp_data = ctx -> data ;\n int rc ;\n # ifdef USE_HCACHE header_cache_t * hc = NULL ;\n # endif nntp_data -> nserv -> check_time = 0 ;\n rc = check_mailbox ( ctx ) ;\n if ( rc ) return rc ;\n # ifdef USE_HCACHE nntp_data -> last_cached = 0 ;\n hc = nntp_hcache_open ( nntp_data ) ;\n # endif for ( int i = 0 ;\n i < ctx -> msgcount ;\n i ++ ) {\n struct Header * hdr = ctx -> hdrs [ i ] ;\n char buf [ 16 ] ;\n snprintf ( buf , sizeof ( buf ) , \"%d\" , NHDR ( hdr ) -> article_num ) ;\n if ( nntp_data -> bcache && hdr -> deleted ) {\n mutt_debug ( 2 , \"mutt_bcache_del %s\\n\" , buf ) ;\n mutt_bcache_del ( nntp_data -> bcache , buf ) ;\n }\n # ifdef USE_HCACHE if ( hc && ( hdr -> changed || hdr -> deleted ) ) {\n if ( hdr -> deleted && ! hdr -> read ) nntp_data -> unread -- ;\n mutt_debug ( 2 , \"mutt_hcache_store %s\\n\" , buf ) ;\n mutt_hcache_store ( hc , buf , strlen ( buf ) , hdr , 0 ) ;\n }\n # endif }\n # ifdef USE_HCACHE if ( hc ) {\n mutt_hcache_close ( hc ) ;\n nntp_data -> last_cached = nntp_data -> last_loaded ;\n }\n # endif nntp_newsrc_gen_entries ( ctx ) ;\n nntp_newsrc_update ( nntp_data -> nserv ) ;\n nntp_newsrc_close ( nntp_data -> nserv ) ;\n return 0 ;\n }","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":254885,"func":"static int spl_filesystem_file_read_csv ( spl_filesystem_object * intern , char delimiter , char enclosure , char escape , zval * return_value TSRMLS_DC ) {\n int ret = SUCCESS ;\n do {\n ret = spl_filesystem_file_read ( intern , 1 TSRMLS_CC ) ;\n }\n while ( ret == SUCCESS && ! intern -> u . file . current_line_len && SPL_HAS_FLAG ( intern -> flags , SPL_FILE_OBJECT_SKIP_EMPTY ) ) ;\n if ( ret == SUCCESS ) {\n size_t buf_len = intern -> u . file . current_line_len ;\n char * buf = estrndup ( intern -> u . file . current_line , buf_len ) ;\n if ( intern -> u . file . current_zval ) {\n zval_ptr_dtor ( & intern -> u . file . current_zval ) ;\n }\n ALLOC_INIT_ZVAL ( intern -> u . file . current_zval ) ;\n php_fgetcsv ( intern -> u . file . stream , delimiter , enclosure , escape , buf_len , buf , intern -> u . file . current_zval TSRMLS_CC ) ;\n if ( return_value ) {\n if ( Z_TYPE_P ( return_value ) != IS_NULL ) {\n zval_dtor ( return_value ) ;\n ZVAL_NULL ( return_value ) ;\n }\n ZVAL_ZVAL ( return_value , intern -> u . file . current_zval , 1 , 0 ) ;\n }\n }\n return ret ;\n }","target":1,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":433583,"func":"static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num,\n\t\t\t    const struct fw_desc *section)\n{\n\tu8 *v_addr;\n\tdma_addr_t p_addr;\n\tu32 offset, chunk_sz = min_t(u32, FH_MEM_TB_MAX_LENGTH, section->len);\n\tint ret = 0;\n\n\tIWL_DEBUG_FW(trans, \"[%d] uCode section being loaded...\\n\",\n\t\t     section_num);\n\n\tv_addr = dma_alloc_coherent(trans->dev, chunk_sz, &p_addr,\n\t\t\t\t    GFP_KERNEL | __GFP_NOWARN);\n\tif (!v_addr) {\n\t\tIWL_DEBUG_INFO(trans, \"Falling back to small chunks of DMA\\n\");\n\t\tchunk_sz = PAGE_SIZE;\n\t\tv_addr = dma_alloc_coherent(trans->dev, chunk_sz,\n\t\t\t\t\t    &p_addr, GFP_KERNEL);\n\t\tif (!v_addr)\n\t\t\treturn -ENOMEM;\n\t}\n\n\tfor (offset = 0; offset < section->len; offset += chunk_sz) {\n\t\tu32 copy_size, dst_addr;\n\t\tbool extended_addr = false;\n\n\t\tcopy_size = min_t(u32, chunk_sz, section->len - offset);\n\t\tdst_addr = section->offset + offset;\n\n\t\tif (dst_addr >= IWL_FW_MEM_EXTENDED_START &&\n\t\t    dst_addr <= IWL_FW_MEM_EXTENDED_END)\n\t\t\textended_addr = true;\n\n\t\tif (extended_addr)\n\t\t\tiwl_set_bits_prph(trans, LMPM_CHICK,\n\t\t\t\t\t  LMPM_CHICK_EXTENDED_ADDR_SPACE);\n\n\t\tmemcpy(v_addr, (u8 *)section->data + offset, copy_size);\n\t\tret = iwl_pcie_load_firmware_chunk(trans, dst_addr, p_addr,\n\t\t\t\t\t\t   copy_size);\n\n\t\tif (extended_addr)\n\t\t\tiwl_clear_bits_prph(trans, LMPM_CHICK,\n\t\t\t\t\t    LMPM_CHICK_EXTENDED_ADDR_SPACE);\n\n\t\tif (ret) {\n\t\t\tIWL_ERR(trans,\n\t\t\t\t\"Could not load the [%d] uCode section\\n\",\n\t\t\t\tsection_num);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tdma_free_coherent(trans->dev, chunk_sz, v_addr, p_addr);\n\treturn ret;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":469299,"func":"int xfrm_dev_state_flush(struct net *net, struct net_device *dev, bool task_valid)\n{\n\tint i, err = 0, cnt = 0;\n\n\tspin_lock_bh(&net->xfrm.xfrm_state_lock);\n\terr = xfrm_dev_state_flush_secctx_check(net, dev, task_valid);\n\tif (err)\n\t\tgoto out;\n\n\terr = -ESRCH;\n\tfor (i = 0; i <= net->xfrm.state_hmask; i++) {\n\t\tstruct xfrm_state *x;\n\t\tstruct xfrm_state_offload *xso;\nrestart:\n\t\thlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {\n\t\t\txso = &x->xso;\n\n\t\t\tif (!xfrm_state_kern(x) && xso->dev == dev) {\n\t\t\t\txfrm_state_hold(x);\n\t\t\t\tspin_unlock_bh(&net->xfrm.xfrm_state_lock);\n\n\t\t\t\terr = xfrm_state_delete(x);\n\t\t\t\txfrm_audit_state_delete(x, err ? 0 : 1,\n\t\t\t\t\t\t\ttask_valid);\n\t\t\t\txfrm_state_put(x);\n\t\t\t\tif (!err)\n\t\t\t\t\tcnt++;\n\n\t\t\t\tspin_lock_bh(&net->xfrm.xfrm_state_lock);\n\t\t\t\tgoto restart;\n\t\t\t}\n\t\t}\n\t}\n\tif (cnt)\n\t\terr = 0;\n\nout:\n\tspin_unlock_bh(&net->xfrm.xfrm_state_lock);\n\treturn err;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":145847,"func":"static int check_bpf_snprintf_call(struct bpf_verifier_env *env,\n\t\t\t\t   struct bpf_reg_state *regs)\n{\n\tstruct bpf_reg_state *fmt_reg = ®s[BPF_REG_3];\n\tstruct bpf_reg_state *data_len_reg = ®s[BPF_REG_5];\n\tstruct bpf_map *fmt_map = fmt_reg->map_ptr;\n\tint err, fmt_map_off, num_args;\n\tu64 fmt_addr;\n\tchar *fmt;\n\n\t\/* data must be an array of u64 *\/\n\tif (data_len_reg->var_off.value % 8)\n\t\treturn -EINVAL;\n\tnum_args = data_len_reg->var_off.value \/ 8;\n\n\t\/* fmt being ARG_PTR_TO_CONST_STR guarantees that var_off is const\n\t * and map_direct_value_addr is set.\n\t *\/\n\tfmt_map_off = fmt_reg->off + fmt_reg->var_off.value;\n\terr = fmt_map->ops->map_direct_value_addr(fmt_map, &fmt_addr,\n\t\t\t\t\t\t  fmt_map_off);\n\tif (err) {\n\t\tverbose(env, \"verifier bug\\n\");\n\t\treturn -EFAULT;\n\t}\n\tfmt = (char *)(long)fmt_addr + fmt_map_off;\n\n\t\/* We are also guaranteed that fmt+fmt_map_off is NULL terminated, we\n\t * can focus on validating the format specifiers.\n\t *\/\n\terr = bpf_bprintf_prepare(fmt, UINT_MAX, NULL, NULL, num_args);\n\tif (err < 0)\n\t\tverbose(env, \"Invalid format string\\n\");\n\n\treturn err;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":31721,"func":"static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,\n\t\t\t   struct pid *pid, struct task_struct *task)\n{\n\tunsigned int i;\n\tunsigned long flags;\n\n\tstruct rlimit rlim[RLIM_NLIMITS];\n\n\tif (!lock_task_sighand(task, &flags))\n\t\treturn 0;\n\tmemcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS);\n\tunlock_task_sighand(task, &flags);\n\n\t\/*\n\t * print the file header\n\t *\/\n       seq_printf(m, \"%-25s %-20s %-20s %-10s\\n\",\n\t\t  \"Limit\", \"Soft Limit\", \"Hard Limit\", \"Units\");\n\n\tfor (i = 0; i < RLIM_NLIMITS; i++) {\n\t\tif (rlim[i].rlim_cur == RLIM_INFINITY)\n\t\t\tseq_printf(m, \"%-25s %-20s \",\n\t\t\t\t   lnames[i].name, \"unlimited\");\n\t\telse\n\t\t\tseq_printf(m, \"%-25s %-20lu \",\n\t\t\t\t   lnames[i].name, rlim[i].rlim_cur);\n\n\t\tif (rlim[i].rlim_max == RLIM_INFINITY)\n\t\t\tseq_printf(m, \"%-20s \", \"unlimited\");\n\t\telse\n\t\t\tseq_printf(m, \"%-20lu \", rlim[i].rlim_max);\n\n\t\tif (lnames[i].unit)\n\t\t\tseq_printf(m, \"%-10s\\n\", lnames[i].unit);\n\t\telse\n\t\t\tseq_putc(m, '\\n');\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":522874,"func":"static int rc4_hmac_md5_set_ctx_params(void *vctx, const OSSL_PARAM params[])\n{\n    PROV_RC4_HMAC_MD5_CTX *ctx = (PROV_RC4_HMAC_MD5_CTX *)vctx;\n    const OSSL_PARAM *p;\n    size_t sz;\n\n    if (params == NULL)\n        return 1;\n\n    p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN);\n    if (p != NULL) {\n        if (!OSSL_PARAM_get_size_t(p, &sz)) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);\n            return 0;\n        }\n        if (ctx->base.keylen != sz) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);\n            return 0;\n        }\n    }\n\n    p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_IVLEN);\n    if (p != NULL) {\n        if (!OSSL_PARAM_get_size_t(p, &sz)) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);\n            return 0;\n        }\n        if (ctx->base.ivlen != sz) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);\n            return 0;\n        }\n    }\n\n    p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_TLS1_AAD);\n    if (p != NULL) {\n        if (p->data_type != OSSL_PARAM_OCTET_STRING) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);\n            return 0;\n        }\n        sz = GET_HW(ctx)->tls_init(&ctx->base, p->data, p->data_size);\n        if (sz == 0) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DATA);\n            return 0;\n        }\n        ctx->tls_aad_pad_sz = sz;\n    }\n    p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_MAC_KEY);\n    if (p != NULL) {\n        if (p->data_type != OSSL_PARAM_OCTET_STRING) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);\n            return 0;\n        }\n        GET_HW(ctx)->init_mackey(&ctx->base, p->data, p->data_size);\n    }\n    p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_TLS_VERSION);\n    if (p != NULL) {\n        if (!OSSL_PARAM_get_uint(p, &ctx->base.tlsversion)) {\n            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);\n            return 0;\n        }\n    }\n\n    return 1;\n}","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":379886,"func":"static int ZEND_FASTCALL  ZEND_FETCH_OBJ_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op1;\n\tzval *property = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);\n\tzval **container = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_RW TSRMLS_CC);\n\n\tif (0) {\n\t\tMAKE_REAL_ZVAL_PTR(property);\n\t}\n\tif (IS_CV == IS_VAR && !container) {\n\t\tzend_error_noreturn(E_ERROR, \"Cannot use string offset as an object\");\n\t}\n\tzend_fetch_property_address(&EX_T(opline->result.u.var), container, property, BP_VAR_RW TSRMLS_CC);\n\tif (0) {\n\t\tzval_ptr_dtor(&property);\n\t} else {\n\n\t}\n\tif (IS_CV == IS_VAR && 0 &&\n\t    READY_TO_DESTROY(free_op1.var)) {\n\t\tAI_USE_PTR(EX_T(opline->result.u.var).var);\n\t\tif (!PZVAL_IS_REF(*EX_T(opline->result.u.var).var.ptr_ptr) &&\n\t\t    Z_REFCOUNT_PP(EX_T(opline->result.u.var).var.ptr_ptr) > 2) {\n\t\t\tSEPARATE_ZVAL(EX_T(opline->result.u.var).var.ptr_ptr);\n\t\t}\n\t}\n\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":144435,"func":"COMPS_HSList* comps_mrtree_keys(COMPS_MRTree * rt) {\n    COMPS_HSList *tmplist, *tmp_subnodes, *ret;\n    COMPS_HSListItem *it;\n    struct Pair {\n        COMPS_HSList * subnodes;\n        char * key;\n        char added;\n    } *pair, *parent_pair;\n\n    pair = malloc(sizeof(struct Pair));\n    pair->subnodes = rt->subnodes;\n    pair->key = NULL;\n    pair->added = 0;\n\n    tmplist = comps_hslist_create();\n    comps_hslist_init(tmplist, NULL, NULL, &free);\n    ret = comps_hslist_create();\n    comps_hslist_init(ret, NULL, NULL, &free);\n    comps_hslist_append(tmplist, pair, 0);\n\n    while (tmplist->first != NULL) {\n        it = tmplist->first;\n        comps_hslist_remove(tmplist, tmplist->first);\n        tmp_subnodes = ((struct Pair*)it->data)->subnodes;\n        parent_pair = (struct Pair*) it->data;\n        free(it);\n\n        for (it = tmp_subnodes->first; it != NULL; it=it->next) {\n            pair = malloc(sizeof(struct Pair));\n            pair->subnodes = ((COMPS_MRTreeData*)it->data)->subnodes;\n            pair->added = 0;\n\n            if (parent_pair->key != NULL) {\n                pair->key =\n                    malloc(sizeof(char)\n                           * (strlen(((COMPS_MRTreeData*)it->data)->key)\n                           + strlen(parent_pair->key) + 1));\n                memcpy(pair->key, parent_pair->key,\n                       sizeof(char) * strlen(parent_pair->key));\n                memcpy(pair->key+strlen(parent_pair->key),\n                       ((COMPS_MRTreeData*)it->data)->key,\n                       sizeof(char)*(strlen(((COMPS_MRTreeData*)it->data)->key)+1));\n            } else {\n                pair->key = malloc(sizeof(char)*\n                                (strlen(((COMPS_MRTreeData*)it->data)->key) +\n                                1));\n                memcpy(pair->key, ((COMPS_MRTreeData*)it->data)->key,\n                       sizeof(char)*(strlen(((COMPS_MRTreeData*)it->data)->key)+1));\n            }\n            \/* current node has data *\/\n            if (((COMPS_MRTreeData*)it->data)->data->first != NULL) {\n                \/\/printf(\"data not null for |%s|\\n\", pair->key);\n                comps_hslist_append(ret, pair->key, 0);\n                pair->added = 1;\n                if (((COMPS_MRTreeData*)it->data)->subnodes->first != NULL) {\n\/\/                    printf(\"subnodes found\\b\");\n                    comps_hslist_append(tmplist, pair, 0);\n                } else {\n                    free(pair);\n                }\n            \/* current node hasn't data *\/\n            } else {\n                if (((COMPS_MRTreeData*)it->data)->subnodes->first) {\n                    comps_hslist_append(tmplist, pair, 0);\n                } else {\n                    free(pair->key);\n                    free(pair);\n                }\n            }\n        }\n        if (parent_pair->added == 0)\n            free(parent_pair->key);\n        free(parent_pair);\n    }\n    comps_hslist_destroy(&tmplist);\n    return ret;\n}","target":0,"code_token_length":717,"total_token_length":953,"max_tokens_setting":1024}
+{"idx":12514,"func":" void WebSocketExperimentRunner::DoLoop() {\n   if (next_state_ == STATE_NONE) {\n     if (task_.get()) {\n      AddRef();  \/\/ Release in OnTaskCompleted.\n       task_->Cancel();\n     }\n     return;\n  }\n\n  State state = next_state_;\n  task_state_ = STATE_NONE;\n  next_state_ = STATE_NONE;\n\n  switch (state) {\n    case STATE_IDLE:\n      task_.reset();\n      next_state_ = STATE_RUN_WS;\n      ChromeThread::PostDelayedTask(\n          ChromeThread::IO,\n          FROM_HERE,\n          NewRunnableMethod(this, &WebSocketExperimentRunner::DoLoop),\n          config_.next_delay_ms);\n      break;\n    case STATE_RUN_WS:\n    case STATE_RUN_WSS:\n    case STATE_RUN_WS_NODEFAULT_PORT:\n    case STATE_RUN_WS_DRAFT75:\n    case STATE_RUN_WSS_DRAFT75:\n    case STATE_RUN_WS_NODEFAULT_PORT_DRAFT75:\n      task_.reset(new WebSocketExperimentTask(\n          config_.ws_config[state - STATE_RUN_WS], &task_callback_));\n      task_state_ = state;\n      if (static_cast<State>(state + 1) == NUM_STATES)\n        next_state_ = STATE_IDLE;\n      else\n        next_state_ = static_cast<State>(state + 1);\n      break;\n    default:\n      NOTREACHED();\n      break;\n  }\n  if (task_.get())\n    task_->Run();\n }\n","target":1,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":288025,"func":"void FileManagerBrowserTestBase::SetUpCommandLine(\n    base::CommandLine* command_line) {\n  command_line->AppendSwitch(switches::kDisableAudioOutput);\n\n  if (!GetRequiresStartupBrowser()) {\n    command_line->AppendSwitch(switches::kNoStartupWindow);\n\n    set_exit_when_last_browser_closes(false);\n  }\n\n  if (IsGuestModeTest()) {\n    command_line->AppendSwitch(chromeos::switches::kGuestSession);\n    command_line->AppendSwitchNative(chromeos::switches::kLoginUser, \"$guest\");\n    command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, \"user\");\n    command_line->AppendSwitch(switches::kIncognito);\n    set_chromeos_user_ = false;\n  }\n\n  if (IsIncognitoModeTest()) {\n     command_line->AppendSwitch(switches::kIncognito);\n   }\n \n   std::vector<base::Feature> enabled_features;\n   std::vector<base::Feature> disabled_features;\n \n  if (!IsGuestModeTest()) {\n    enabled_features.emplace_back(features::kCrostini);\n  }\n\n  if (!IsNativeSmbTest()) {\n    disabled_features.emplace_back(features::kNativeSmb);\n  }\n\n  if (IsDriveFsTest()) {\n    enabled_features.emplace_back(chromeos::features::kDriveFs);\n  } else {\n    disabled_features.emplace_back(chromeos::features::kDriveFs);\n  }\n\n  if (IsMyFilesVolume()) {\n    enabled_features.emplace_back(chromeos::features::kMyFilesVolume);\n  } else {\n    disabled_features.emplace_back(chromeos::features::kMyFilesVolume);\n  }\n\n  if (IsArcTest()) {\n    arc::SetArcAvailableCommandLineForTesting(command_line);\n  }\n\n  if (IsDocumentsProviderTest()) {\n    enabled_features.emplace_back(\n        arc::kEnableDocumentsProviderInFilesAppFeature);\n  } else {\n    disabled_features.emplace_back(\n        arc::kEnableDocumentsProviderInFilesAppFeature);\n  }\n\n  feature_list_.InitWithFeatures(enabled_features, disabled_features);\n\n  extensions::ExtensionApiTest::SetUpCommandLine(command_line);\n}\n","target":1,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":5211,"func":"TEE_Result syscall_authenc_init(unsigned long state, const void *nonce,\n\t\t\tsize_t nonce_len, size_t tag_len,\n\t\t\tsize_t aad_len, size_t payload_len)\n{\n\tTEE_Result res;\n\tstruct tee_cryp_state *cs;\n\tstruct tee_ta_session *sess;\n\tstruct tee_obj *o;\n\tstruct tee_cryp_obj_secret *key;\n\n\tres = tee_ta_get_current_session(&sess);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tres = tee_mmu_check_access_rights(to_user_ta_ctx(sess->ctx),\n\t\t\t\t\t  TEE_MEMORY_ACCESS_READ |\n\t\t\t\t\t  TEE_MEMORY_ACCESS_ANY_OWNER,\n\t\t\t\t\t  (uaddr_t)nonce, nonce_len);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tres = tee_svc_cryp_get_state(sess, tee_svc_uref_to_vaddr(state), &cs);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tres = tee_obj_get(to_user_ta_ctx(sess->ctx), cs->key1, &o);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\tif ((o->info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) == 0)\n\t\treturn TEE_ERROR_BAD_PARAMETERS;\n\n\tkey = o->attr;\n\tres = crypto_authenc_init(cs->ctx, cs->algo, cs->mode,\n\t\t\t\t  (uint8_t *)(key + 1), key->key_size,\n\t\t\t\t  nonce, nonce_len, tag_len, aad_len,\n\t\t\t\t  payload_len);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tcs->ctx_finalize = (tee_cryp_ctx_finalize_func_t)crypto_authenc_final;\n\treturn TEE_SUCCESS;\n}","target":1,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":425082,"func":"static int init_lookup(void)\n{\n    int v, s, h;\n\n    \/* These ones are constant *\/\n    lookup_colors[0] = CACA_BLACK;\n    lookup_colors[1] = CACA_DARKGRAY;\n    lookup_colors[2] = CACA_LIGHTGRAY;\n    lookup_colors[3] = CACA_WHITE;\n\n    \/* These ones will be overwritten *\/\n    lookup_colors[4] = CACA_MAGENTA;\n    lookup_colors[5] = CACA_LIGHTMAGENTA;\n    lookup_colors[6] = CACA_RED;\n    lookup_colors[7] = CACA_LIGHTRED;\n\n    for(v = 0; v < LOOKUP_VAL; v++)\n        for(s = 0; s < LOOKUP_SAT; s++)\n            for(h = 0; h < LOOKUP_HUE; h++)\n    {\n        int i, distbg, distfg, dist;\n        int val, sat, hue;\n        uint8_t outbg, outfg;\n\n        val = 0xfff * v \/ (LOOKUP_VAL - 1);\n        sat = 0xfff * s \/ (LOOKUP_SAT - 1);\n        hue = 0xfff * h \/ (LOOKUP_HUE - 1);\n\n        \/* Initialise distances to the distance between pure black HSV\n         * coordinates and our white colour (3) *\/\n        outbg = outfg = 3;\n        distbg = distfg = HSV_DISTANCE(0, 0, 0, 3);\n\n        \/* Calculate distances to eight major colour values and store the\n         * two nearest points in our lookup table. *\/\n        for(i = 0; i < 8; i++)\n        {\n            dist = HSV_DISTANCE(hue, sat, val, i);\n            if(dist <= distbg)\n            {\n                outfg = outbg;\n                distfg = distbg;\n                outbg = i;\n                distbg = dist;\n            }\n            else if(dist <= distfg)\n            {\n                outfg = i;\n                distfg = dist;\n            }\n        }\n\n        hsv_distances[v][s][h] = (outfg << 4) | outbg;\n    }\n\n    return 0;\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":96955,"func":"static int semctl_nolock(struct ipc_namespace *ns, int semid,\n\t\t\t int cmd, int version, void __user *p)\n{\n\tint err;\n\tstruct sem_array *sma;\n\n\tswitch(cmd) {\n\tcase IPC_INFO:\n\tcase SEM_INFO:\n\t{\n\t\tstruct seminfo seminfo;\n\t\tint max_id;\n\n\t\terr = security_sem_semctl(NULL, cmd);\n\t\tif (err)\n\t\t\treturn err;\n\t\t\n\t\tmemset(&seminfo,0,sizeof(seminfo));\n\t\tseminfo.semmni = ns->sc_semmni;\n\t\tseminfo.semmns = ns->sc_semmns;\n\t\tseminfo.semmsl = ns->sc_semmsl;\n\t\tseminfo.semopm = ns->sc_semopm;\n\t\tseminfo.semvmx = SEMVMX;\n\t\tseminfo.semmnu = SEMMNU;\n\t\tseminfo.semmap = SEMMAP;\n\t\tseminfo.semume = SEMUME;\n\t\tdown_read(&sem_ids(ns).rw_mutex);\n\t\tif (cmd == SEM_INFO) {\n\t\t\tseminfo.semusz = sem_ids(ns).in_use;\n\t\t\tseminfo.semaem = ns->used_sems;\n\t\t} else {\n\t\t\tseminfo.semusz = SEMUSZ;\n\t\t\tseminfo.semaem = SEMAEM;\n\t\t}\n\t\tmax_id = ipc_get_maxid(&sem_ids(ns));\n\t\tup_read(&sem_ids(ns).rw_mutex);\n\t\tif (copy_to_user(p, &seminfo, sizeof(struct seminfo))) \n\t\t\treturn -EFAULT;\n\t\treturn (max_id < 0) ? 0: max_id;\n\t}\n\tcase IPC_STAT:\n\tcase SEM_STAT:\n\t{\n\t\tstruct semid64_ds tbuf;\n\t\tint id = 0;\n\n\t\tmemset(&tbuf, 0, sizeof(tbuf));\n\n\t\tif (cmd == SEM_STAT) {\n\t\t\trcu_read_lock();\n\t\t\tsma = sem_obtain_object(ns, semid);\n\t\t\tif (IS_ERR(sma)) {\n\t\t\t\terr = PTR_ERR(sma);\n\t\t\t\tgoto out_unlock;\n\t\t\t}\n\t\t\tid = sma->sem_perm.id;\n\t\t} else {\n\t\t\trcu_read_lock();\n\t\t\tsma = sem_obtain_object_check(ns, semid);\n\t\t\tif (IS_ERR(sma)) {\n\t\t\t\terr = PTR_ERR(sma);\n\t\t\t\tgoto out_unlock;\n\t\t\t}\n\t\t}\n\n\t\terr = -EACCES;\n\t\tif (ipcperms(ns, &sma->sem_perm, S_IRUGO))\n\t\t\tgoto out_unlock;\n\n\t\terr = security_sem_semctl(sma, cmd);\n\t\tif (err)\n\t\t\tgoto out_unlock;\n\n\t\tkernel_to_ipc64_perm(&sma->sem_perm, &tbuf.sem_perm);\n\t\ttbuf.sem_otime  = sma->sem_otime;\n\t\ttbuf.sem_ctime  = sma->sem_ctime;\n\t\ttbuf.sem_nsems  = sma->sem_nsems;\n\t\trcu_read_unlock();\n\t\tif (copy_semid_to_user(p, &tbuf, version))\n\t\t\treturn -EFAULT;\n\t\treturn id;\n\t}\n\tdefault:\n\t\treturn -EINVAL;\n\t}\nout_unlock:\n\trcu_read_unlock();\n\treturn err;\n}","target":0,"code_token_length":685,"total_token_length":921,"max_tokens_setting":1024}
+{"idx":439616,"func":"decodeModifyOtherKeys(int c)\n{\n    char_u  *p = typebuf.tb_buf + typebuf.tb_off;\n    int\t    idx;\n    int\t    form = 0;\n    int\t    argidx = 0;\n    int\t    arg[2] = {0, 0};\n\n    \/\/ Recognize:\n    \/\/ form 0: {lead}{key};{modifier}u\n    \/\/ form 1: {lead}27;{modifier};{key}~\n    if ((c == CSI || (c == ESC && *p == '[')) && typebuf.tb_len >= 4)\n    {\n\tidx = (*p == '[');\n\tif (p[idx] == '2' && p[idx + 1] == '7' && p[idx + 2] == ';')\n\t{\n\t    form = 1;\n\t    idx += 3;\n\t}\n\twhile (idx < typebuf.tb_len && argidx < 2)\n\t{\n\t    if (p[idx] == ';')\n\t\t++argidx;\n\t    else if (VIM_ISDIGIT(p[idx]))\n\t\targ[argidx] = arg[argidx] * 10 + (p[idx] - '0');\n\t    else\n\t\tbreak;\n\t    ++idx;\n\t}\n\tif (idx < typebuf.tb_len\n\t\t&& p[idx] == (form == 1 ? '~' : 'u')\n\t\t&& argidx == 1)\n\t{\n\t    \/\/ Match, consume the code.\n\t    typebuf.tb_off += idx + 1;\n\t    typebuf.tb_len -= idx + 1;\n\n\t    mod_mask = decode_modifiers(arg[!form]);\n\t    c = merge_modifyOtherKeys(arg[form]);\n\t}\n    }\n\n    return c;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":293662,"func":"__read_extent_tree_block(const char *function, unsigned int line,\n\t\t\t struct inode *inode, ext4_fsblk_t pblk, int depth,\n\t\t\t int flags)\n{\n\tstruct buffer_head\t\t*bh;\n\tint\t\t\t\terr;\n\n\tbh = sb_getblk(inode->i_sb, pblk);\n\tif (unlikely(!bh))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tif (!bh_uptodate_or_lock(bh)) {\n\t\ttrace_ext4_ext_load_extent(inode, pblk, _RET_IP_);\n\t\terr = bh_submit_read(bh);\n\t\tif (err < 0)\n\t\t\tgoto errout;\n\t}\n\tif (buffer_verified(bh) && !(flags & EXT4_EX_FORCE_CACHE))\n\t\treturn bh;\n\terr = __ext4_ext_check(function, line, inode,\n\t\t\t       ext_block_hdr(bh), depth, pblk);\n\tif (err)\n\t\tgoto errout;\n\tset_buffer_verified(bh);\n\t\/*\n\t * If this is a leaf block, cache all of its entries\n\t *\/\n\tif (!(flags & EXT4_EX_NOCACHE) && depth == 0) {\n\t\tstruct ext4_extent_header *eh = ext_block_hdr(bh);\n\t\tstruct ext4_extent *ex = EXT_FIRST_EXTENT(eh);\n\t\text4_lblk_t prev = 0;\n\t\tint i;\n\n\t\tfor (i = le16_to_cpu(eh->eh_entries); i > 0; i--, ex++) {\n\t\t\tunsigned int status = EXTENT_STATUS_WRITTEN;\n\t\t\text4_lblk_t lblk = le32_to_cpu(ex->ee_block);\n\t\t\tint len = ext4_ext_get_actual_len(ex);\n\n\t\t\tif (prev && (prev != lblk))\n\t\t\t\text4_es_cache_extent(inode, prev,\n\t\t\t\t\t\t     lblk - prev, ~0,\n\t\t\t\t\t\t     EXTENT_STATUS_HOLE);\n\n\t\t\tif (ext4_ext_is_unwritten(ex))\n\t\t\t\tstatus = EXTENT_STATUS_UNWRITTEN;\n\t\t\text4_es_cache_extent(inode, lblk, len,\n\t\t\t\t\t     ext4_ext_pblock(ex), status);\n\t\t\tprev = lblk + len;\n\t\t}\n\t}\n\treturn bh;\nerrout:\n\tput_bh(bh);\n\treturn ERR_PTR(err);\n\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":45584,"func":"int bcf_add_id(const bcf_hdr_t *hdr, bcf1_t *line, const char *id)\n{\n    if ( !id ) return 0;\n    if ( !(line->unpacked & BCF_UN_STR) ) bcf_unpack(line, BCF_UN_STR);\n\n    kstring_t tmp;\n    tmp.l = 0; tmp.s = line->d.id; tmp.m = line->d.m_id;\n\n    int len = strlen(id);\n    char *dst = line->d.id;\n    while ( *dst && (dst=strstr(dst,id)) )\n    {\n        if ( dst[len]!=0 && dst[len]!=';' ) dst++;              \/\/ a prefix, not a match\n        else if ( dst==line->d.id || dst[-1]==';' ) return 0;   \/\/ already present\n        dst++;  \/\/ a suffix, not a match\n    }\n    if ( line->d.id && (line->d.id[0]!='.' || line->d.id[1]) )\n    {\n        tmp.l = strlen(line->d.id);\n        kputc(';',&tmp);\n    }\n    kputs(id,&tmp);\n\n    line->d.id = tmp.s; line->d.m_id = tmp.m;\n    line->d.shared_dirty |= BCF1_DIRTY_ID;\n    return 0;\n\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":386707,"func":"static guint parse_rle_data_grayscale(TGAContext *ctx)\n{\n\tTGAColor tone;\n\tguint rle_num, raw_num;\n\tguchar *s, tag;\n\tguint n;\n\n\tg_return_val_if_fail(ctx->in->size > 0, 0);\n\ts = ctx->in->data;\n\n\tfor (n = 0; n < ctx->in->size; ) {\n\t\ttag = *s;\n\t\ts++, n++;\n\t\tif (tag & 0x80) {\n\t\t\tif (n + (ctx->pbuf->n_channels == 4 ? 2 : 1) >= ctx->in->size) {\n\t\t\t\treturn --n;\n\t\t\t} else {\n\t\t\t\trle_num = (tag & 0x7f) + 1;\n\t\t\t\ttone.r = tone.g = tone.b = *s;\n\t\t\t\ts++, n++;\n\t\t\t\tif (ctx->pbuf->n_channels == 4) {\n\t\t\t\t\ttone.a = *s++;\n\t\t\t\t\tn++;\n\t\t\t\t}\n\t\t\t\twrite_rle_data(ctx, &tone, &rle_num);\n\t\t\t\tif (ctx->pbuf_bytes_done == ctx->pbuf_bytes) {\n\t\t\t\t\tctx->done = TRUE;\n\t\t\t\t\treturn n;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\traw_num = tag + 1;\n\t\t\tif (n + raw_num * (ctx->pbuf->n_channels == 4 ? 2 : 1) >= ctx->in->size) {\n\t\t\t\treturn --n;\n\t\t\t} else {\n\t\t\t\tfor (; raw_num; raw_num--) {\n\t\t\t\t\tctx->pptr[0] = ctx->pptr[1] = ctx->pptr[2] = *s;\n\t\t\t\t\ts++, n++;\n\t\t\t\t\tif (ctx->pbuf->n_channels == 4) {\n\t\t\t\t\t\tctx->pptr[3] = *s++;\n\t\t\t\t\t\tn++;\n\t\t\t\t\t}\n\t\t\t\t\tctx->pptr += ctx->pbuf->n_channels;\n\t\t\t\t\tctx->pbuf_bytes_done += ctx->pbuf->n_channels;\n\t\t\t\t\tif (ctx->pbuf_bytes_done == ctx->pbuf_bytes) {\n\t\t\t\t\t\tctx->done = TRUE;\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (ctx->pbuf_bytes_done == ctx->pbuf_bytes)\n\t\tctx->done = TRUE;\n\treturn n;\n}","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":377500,"func":"get_hostfile_hostname_ipaddr(char *hostname, struct sockaddr *hostaddr,\n    u_short port, char **hostfile_hostname, char **hostfile_ipaddr)\n{\n\tchar ntop[NI_MAXHOST];\n\tsocklen_t addrlen;\n\n\tswitch (hostaddr == NULL ? -1 : hostaddr->sa_family) {\n\tcase -1:\n\t\taddrlen = 0;\n\t\tbreak;\n\tcase AF_INET:\n\t\taddrlen = sizeof(struct sockaddr_in);\n\t\tbreak;\n\tcase AF_INET6:\n\t\taddrlen = sizeof(struct sockaddr_in6);\n\t\tbreak;\n\tdefault:\n\t\taddrlen = sizeof(struct sockaddr);\n\t\tbreak;\n\t}\n\n\t\/*\n\t * We don't have the remote ip-address for connections\n\t * using a proxy command\n\t *\/\n\tif (hostfile_ipaddr != NULL) {\n\t\tif (options.proxy_command == NULL) {\n\t\t\tif (getnameinfo(hostaddr, addrlen,\n\t\t\t    ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST) != 0)\n\t\t\tfatal(\"check_host_key: getnameinfo failed\");\n\t\t\t*hostfile_ipaddr = put_host_port(ntop, port);\n\t\t} else {\n\t\t\t*hostfile_ipaddr = xstrdup(\"<no hostip for proxy \"\n\t\t\t    \"command>\");\n\t\t}\n\t}\n\n\t\/*\n\t * Allow the user to record the key under a different name or\n\t * differentiate a non-standard port.  This is useful for ssh\n\t * tunneling over forwarded connections or if you run multiple\n\t * sshd's on different ports on the same machine.\n\t *\/\n\tif (hostfile_hostname != NULL) {\n\t\tif (options.host_key_alias != NULL) {\n\t\t\t*hostfile_hostname = xstrdup(options.host_key_alias);\n\t\t\tdebug(\"using hostkeyalias: %s\", *hostfile_hostname);\n\t\t} else {\n\t\t\t*hostfile_hostname = put_host_port(hostname, port);\n\t\t}\n\t}\n}","target":0,"code_token_length":403,"total_token_length":639,"max_tokens_setting":1024}
+{"idx":387359,"func":"sys_info(\n\tsockaddr_u *srcadr,\n\tendpt *inter,\n\tstruct req_pkt *inpkt\n\t)\n{\n\tregister struct info_sys *is;\n\n\tis = (struct info_sys *)prepare_pkt(srcadr, inter, inpkt,\n\t    v6sizeof(struct info_sys));\n\n\tif (sys_peer) {\n\t\tif (IS_IPV4(&sys_peer->srcadr)) {\n\t\t\tis->peer = NSRCADR(&sys_peer->srcadr);\n\t\t\tif (client_v6_capable)\n\t\t\t\tis->v6_flag = 0;\n\t\t} else if (client_v6_capable) {\n\t\t\tis->peer6 = SOCK_ADDR6(&sys_peer->srcadr);\n\t\t\tis->v6_flag = 1;\n\t\t}\n\t\tis->peer_mode = sys_peer->hmode;\n\t} else {\n\t\tis->peer = 0;\n\t\tif (client_v6_capable) {\n\t\t\tis->v6_flag = 0;\n\t\t}\n\t\tis->peer_mode = 0;\n\t}\n\n\tis->leap = sys_leap;\n\tis->stratum = sys_stratum;\n\tis->precision = sys_precision;\n\tis->rootdelay = htonl(DTOFP(sys_rootdelay));\n\tis->rootdispersion = htonl(DTOUFP(sys_rootdisp));\n\tis->frequency = htonl(DTOFP(sys_jitter));\n\tis->stability = htonl(DTOUFP(clock_stability * 1e6));\n\tis->refid = sys_refid;\n\tHTONL_FP(&sys_reftime, &is->reftime);\n\n\tis->poll = sys_poll;\n\t\n\tis->flags = 0;\n\tif (sys_authenticate)\n\t\tis->flags |= INFO_FLAG_AUTHENTICATE;\n\tif (sys_bclient)\n\t\tis->flags |= INFO_FLAG_BCLIENT;\n#ifdef REFCLOCK\n\tif (cal_enable)\n\t\tis->flags |= INFO_FLAG_CAL;\n#endif \/* REFCLOCK *\/\n\tif (kern_enable)\n\t\tis->flags |= INFO_FLAG_KERNEL;\n\tif (mon_enabled != MON_OFF)\n\t\tis->flags |= INFO_FLAG_MONITOR;\n\tif (ntp_enable)\n\t\tis->flags |= INFO_FLAG_NTP;\n\tif (hardpps_enable)\n\t\tis->flags |= INFO_FLAG_PPS_SYNC;\n\tif (stats_control)\n\t\tis->flags |= INFO_FLAG_FILEGEN;\n\tis->bdelay = HTONS_FP(DTOFP(sys_bdelay));\n\tHTONL_UF(sys_authdelay.l_uf, &is->authdelay);\n\t(void) more_pkt();\n\tflush_pkt();\n}","target":0,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":369901,"func":"xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,\n                     xmlEntityPtr ent, size_t replacement)\n{\n    size_t consumed = 0;\n\n    if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE))\n        return (0);\n    if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)\n        return (1);\n    if (replacement != 0) {\n\tif (replacement < XML_MAX_TEXT_LENGTH)\n\t    return(0);\n\n        \/*\n\t * If the volume of entity copy reaches 10 times the\n\t * amount of parsed data and over the large text threshold\n\t * then that's very likely to be an abuse.\n\t *\/\n        if (ctxt->input != NULL) {\n\t    consumed = ctxt->input->consumed +\n\t               (ctxt->input->cur - ctxt->input->base);\n\t}\n        consumed += ctxt->sizeentities;\n\n        if (replacement < XML_PARSER_NON_LINEAR * consumed)\n\t    return(0);\n    } else if (size != 0) {\n        \/*\n         * Do the check based on the replacement size of the entity\n         *\/\n        if (size < XML_PARSER_BIG_ENTITY)\n\t    return(0);\n\n        \/*\n         * A limit on the amount of text data reasonably used\n         *\/\n        if (ctxt->input != NULL) {\n            consumed = ctxt->input->consumed +\n                (ctxt->input->cur - ctxt->input->base);\n        }\n        consumed += ctxt->sizeentities;\n\n        if ((size < XML_PARSER_NON_LINEAR * consumed) &&\n\t    (ctxt->nbentities * 3 < XML_PARSER_NON_LINEAR * consumed))\n            return (0);\n    } else if (ent != NULL) {\n        \/*\n         * use the number of parsed entities in the replacement\n         *\/\n        size = ent->checked;\n\n        \/*\n         * The amount of data parsed counting entities size only once\n         *\/\n        if (ctxt->input != NULL) {\n            consumed = ctxt->input->consumed +\n                (ctxt->input->cur - ctxt->input->base);\n        }\n        consumed += ctxt->sizeentities;\n\n        \/*\n         * Check the density of entities for the amount of data\n\t * knowing an entity reference will take at least 3 bytes\n         *\/\n        if (size * 3 < consumed * XML_PARSER_NON_LINEAR)\n            return (0);\n    } else {\n        \/*\n         * strange we got no data for checking just return\n         *\/\n        return (0);\n    }\n    xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);\n    return (1);\n}","target":0,"code_token_length":536,"total_token_length":772,"max_tokens_setting":1024}
+{"idx":475651,"func":"static void nft_commit_notify(struct net *net, u32 portid)\n{\n\tstruct nftables_pernet *nft_net = nft_pernet(net);\n\tstruct sk_buff *batch_skb = NULL, *nskb, *skb;\n\tunsigned char *data;\n\tint len;\n\n\tlist_for_each_entry_safe(skb, nskb, &nft_net->notify_list, list) {\n\t\tif (!batch_skb) {\nnew_batch:\n\t\t\tbatch_skb = skb;\n\t\t\tlen = NLMSG_GOODSIZE - skb->len;\n\t\t\tlist_del(&skb->list);\n\t\t\tcontinue;\n\t\t}\n\t\tlen -= skb->len;\n\t\tif (len > 0 && NFT_CB(skb).report == NFT_CB(batch_skb).report) {\n\t\t\tdata = skb_put(batch_skb, skb->len);\n\t\t\tmemcpy(data, skb->data, skb->len);\n\t\t\tlist_del(&skb->list);\n\t\t\tkfree_skb(skb);\n\t\t\tcontinue;\n\t\t}\n\t\tnfnetlink_send(batch_skb, net, portid, NFNLGRP_NFTABLES,\n\t\t\t       NFT_CB(batch_skb).report, GFP_KERNEL);\n\t\tgoto new_batch;\n\t}\n\n\tif (batch_skb) {\n\t\tnfnetlink_send(batch_skb, net, portid, NFNLGRP_NFTABLES,\n\t\t\t       NFT_CB(batch_skb).report, GFP_KERNEL);\n\t}\n\n\tWARN_ON_ONCE(!list_empty(&nft_net->notify_list));\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":394797,"func":"CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) \/* {{{ *\/\n{\n\tcwd_state new_state;\n\tchar cwd[MAXPATHLEN];\n\n\t\/* realpath(\"\") returns CWD *\/\n\tif (!*path) {\n\t\tnew_state.cwd = (char*)malloc(1);\n\t\tif (new_state.cwd == NULL) {\n\t\t\treturn NULL;\n\t\t}\n\t\tnew_state.cwd[0] = '\\0';\n\t\tnew_state.cwd_length = 0;\n\t\tif (VCWD_GETCWD(cwd, MAXPATHLEN)) {\n\t\t\tpath = cwd;\n\t\t}\n\t} else if (!IS_ABSOLUTE_PATH(path, strlen(path)) &&\n\t\t\t\t\tVCWD_GETCWD(cwd, MAXPATHLEN)) {\n\t\tnew_state.cwd = strdup(cwd);\n\t\tnew_state.cwd_length = strlen(cwd);\n\t} else {\n\t\tnew_state.cwd = (char*)malloc(1);\n\t\tif (new_state.cwd == NULL) {\n\t\t\treturn NULL;\n\t\t}\n\t\tnew_state.cwd[0] = '\\0';\n\t\tnew_state.cwd_length = 0;\n\t}\n\n\tif (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) {\n\t\tfree(new_state.cwd);\n\t\treturn NULL;\n\t}\n\n\tif (real_path) {\n\t\tint copy_len = new_state.cwd_length>MAXPATHLEN-1 ? MAXPATHLEN-1 : new_state.cwd_length;\n\t\tmemcpy(real_path, new_state.cwd, copy_len);\n\t\treal_path[copy_len] = '\\0';\n\t\tfree(new_state.cwd);\n\t\treturn real_path;\n\t} else {\n\t\treturn new_state.cwd;\n\t}\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":173434,"func":"cmd_http_sendhex(CMD_ARGS)\n{\n\tstruct http *hp;\n\tchar buf[3], *q;\n\tuint8_t *p;\n\tint i, j, l;\n\n\t(void)cmd;\n\t(void)vl;\n\tCAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);\n\tAN(av[1]);\n\tAZ(av[2]);\n\tl = strlen(av[1]) \/ 2;\n\tp = malloc(l);\n\tAN(p);\n\tq = av[1];\n\tfor (i = 0; i < l; i++) {\n\t\twhile (vct_issp(*q))\n\t\t\tq++;\n\t\tif (*q == '\\0')\n\t\t\tbreak;\n\t\tmemcpy(buf, q, 2);\n\t\tq += 2;\n\t\tbuf[2] = '\\0';\n\t\tif (!vct_ishex(buf[0]) || !vct_ishex(buf[1]))\n\t\t\tvtc_log(hp->vl, 0, \"Illegal Hex char \\\"%c%c\\\"\",\n\t\t\t    buf[0], buf[1]);\n\t\tp[i] = (uint8_t)strtoul(buf, NULL, 16);\n\t}\n\tvtc_hexdump(hp->vl, 4, \"sendhex\", (void*)p, i);\n\tj = write(hp->fd, p, i);\n\tassert(j == i);\n\tfree(p);\n\n}\n","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":506359,"func":"static int tls1_set_shared_sigalgs(SSL *s)\n\t{\n\tconst unsigned char *pref, *allow, *conf;\n\tsize_t preflen, allowlen, conflen;\n\tsize_t nmatch;\n\tTLS_SIGALGS *salgs = NULL;\n\tCERT *c = s->cert;\n\tunsigned int is_suiteb = tls1_suiteb(s);\n\tif (c->shared_sigalgs)\n\t\t{\n\t\tOPENSSL_free(c->shared_sigalgs);\n\t\tc->shared_sigalgs = NULL;\n\t\t}\n\t\/* If client use client signature algorithms if not NULL *\/\n\tif (!s->server && c->client_sigalgs && !is_suiteb)\n\t\t{\n\t\tconf = c->client_sigalgs;\n\t\tconflen = c->client_sigalgslen;\n\t\t}\n\telse if (c->conf_sigalgs && !is_suiteb)\n\t\t{\n\t\tconf = c->conf_sigalgs;\n\t\tconflen = c->conf_sigalgslen;\n\t\t}\n\telse\n\t\tconflen = tls12_get_psigalgs(s, &conf);\n\tif(s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || is_suiteb)\n\t\t{\n\t\tpref = conf;\n\t\tpreflen = conflen;\n\t\tallow = c->peer_sigalgs;\n\t\tallowlen = c->peer_sigalgslen;\n\t\t}\n\telse\n\t\t{\n\t\tallow = conf;\n\t\tallowlen = conflen;\n\t\tpref = c->peer_sigalgs;\n\t\tpreflen = c->peer_sigalgslen;\n\t\t}\n\tnmatch = tls12_shared_sigalgs(s, NULL, pref, preflen, allow, allowlen);\n\tif (!nmatch)\n\t\treturn 1;\n\tsalgs = OPENSSL_malloc(nmatch * sizeof(TLS_SIGALGS));\n\tif (!salgs)\n\t\treturn 0;\n\tnmatch = tls12_shared_sigalgs(s, salgs, pref, preflen, allow, allowlen);\n\tc->shared_sigalgs = salgs;\n\tc->shared_sigalgslen = nmatch;\n\treturn 1;\n\t}","target":0,"code_token_length":452,"total_token_length":688,"max_tokens_setting":1024}
+{"idx":197748,"func":"void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle,\n                                    const gfx::Size& desired_size) {\n  if (!webwidget_ || dib_handle == TransportDIB::DefaultHandleValue())\n    return;\n\n  if (webwidget_->size().isEmpty() ||\n      desired_size.IsEmpty()) {\n    Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_,\n                                         dib_handle,\n                                         desired_size));\n    return;\n  }\n\n  scoped_ptr<TransportDIB> paint_at_scale_buffer(TransportDIB::Map(dib_handle));\n\n  DCHECK(paint_at_scale_buffer.get());\n  if (!paint_at_scale_buffer.get())\n    return;\n\n  webwidget_->layout();\n\n  gfx::Size canvas_size = webwidget_->size();\n  float x_scale = static_cast<float>(desired_size.width()) \/\n                  static_cast<float>(canvas_size.width());\n   float y_scale = static_cast<float>(desired_size.height()) \/\n                   static_cast<float>(canvas_size.height());\n \n  gfx::Rect orig_bounds(canvas_size);\n   canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale));\n   canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale));\n  gfx::Rect bounds(canvas_size);\n \n   scoped_ptr<skia::PlatformCanvas> canvas(\n       paint_at_scale_buffer->GetPlatformCanvas(canvas_size.width(),\n                                               canvas_size.height()));\n  if (!canvas.get()) {\n    NOTREACHED();\n    return;\n  }\n\n  DCHECK_EQ(bounds.width(), canvas->getDevice()->width());\n  DCHECK_EQ(bounds.height(), canvas->getDevice()->height());\n  bounds.set_width(canvas->getDevice()->width());\n  bounds.set_height(canvas->getDevice()->height());\n\n  canvas->save();\n  canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));\n\n  PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());\n  canvas->restore();\n\n  Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, dib_handle, bounds.size()));\n}\n","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":193244,"func":"static inline u32 nfsd4_getattr_rsize(struct svc_rqst *rqstp,\n\t\t\t\t      struct nfsd4_op *op)\n{\n\tu32 *bmap = op->u.getattr.ga_bmval;\n\tu32 bmap0 = bmap[0], bmap1 = bmap[1], bmap2 = bmap[2];\n\tu32 ret = 0;\n\n\tif (bmap0 & FATTR4_WORD0_ACL)\n\t\treturn svc_max_payload(rqstp);\n\tif (bmap0 & FATTR4_WORD0_FS_LOCATIONS)\n\t\treturn svc_max_payload(rqstp);\n\n\tif (bmap1 & FATTR4_WORD1_OWNER) {\n\t\tret += IDMAP_NAMESZ + 4;\n\t\tbmap1 &= ~FATTR4_WORD1_OWNER;\n\t}\n\tif (bmap1 & FATTR4_WORD1_OWNER_GROUP) {\n\t\tret += IDMAP_NAMESZ + 4;\n\t\tbmap1 &= ~FATTR4_WORD1_OWNER_GROUP;\n\t}\n\tif (bmap0 & FATTR4_WORD0_FILEHANDLE) {\n\t\tret += NFS4_FHSIZE + 4;\n\t\tbmap0 &= ~FATTR4_WORD0_FILEHANDLE;\n\t}\n\tif (bmap2 & FATTR4_WORD2_SECURITY_LABEL) {\n\t\tret += NFS4_MAXLABELLEN + 12;\n\t\tbmap2 &= ~FATTR4_WORD2_SECURITY_LABEL;\n\t}\n\t\/*\n\t * Largest of remaining attributes are 16 bytes (e.g.,\n\t * supported_attributes)\n\t *\/\n\tret += 16 * (hweight32(bmap0) + hweight32(bmap1) + hweight32(bmap2));\n\t\/* bitmask, length *\/\n\tret += 20;\n\treturn ret;\n}\n","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":325653,"func":"int coroutine_fn bdrv_co_flush(BlockDriverState *bs)\n{\n    int ret;\n    BdrvTrackedRequest req;\n    if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) ||\n        bdrv_is_sg(bs)) {\n        return 0;\n    }\n    tracked_request_begin(&req, bs, 0, 0, BDRV_TRACKED_FLUSH);\n    int current_gen = bs->write_gen;\n    \/* Wait until any previous flushes are completed *\/\n    while (bs->flush_started_gen != bs->flushed_gen) {\n        qemu_co_queue_wait(&bs->flush_queue);\n    }\n    bs->flush_started_gen = current_gen;\n    \/* Write back all layers by calling one driver function *\/\n    if (bs->drv->bdrv_co_flush) {\n        ret = bs->drv->bdrv_co_flush(bs);\n        goto out;\n    }\n    \/* Write back cached data to the OS even with cache=unsafe *\/\n    BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS);\n    if (bs->drv->bdrv_co_flush_to_os) {\n        ret = bs->drv->bdrv_co_flush_to_os(bs);\n        if (ret < 0) {\n            goto out;\n        }\n    }\n    \/* But don't actually force it to the disk with cache=unsafe *\/\n    if (bs->open_flags & BDRV_O_NO_FLUSH) {\n        goto flush_parent;\n    }\n    \/* Check if we really need to flush anything *\/\n    if (bs->flushed_gen == current_gen) {\n        goto flush_parent;\n    }\n    BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_DISK);\n    if (bs->drv->bdrv_co_flush_to_disk) {\n        ret = bs->drv->bdrv_co_flush_to_disk(bs);\n    } else if (bs->drv->bdrv_aio_flush) {\n        BlockAIOCB *acb;\n        CoroutineIOCompletion co = {\n            .coroutine = qemu_coroutine_self(),\n        };\n        acb = bs->drv->bdrv_aio_flush(bs, bdrv_co_io_em_complete, &co);\n        if (acb == NULL) {\n            ret = -EIO;\n        } else {\n            qemu_coroutine_yield();\n            ret = co.ret;\n        }\n    } else {\n        \/*\n         * Some block drivers always operate in either writethrough or unsafe\n         * mode and don't support bdrv_flush therefore. Usually qemu doesn't\n         * know how the server works (because the behaviour is hardcoded or\n         * depends on server-side configuration), so we can't ensure that\n         * everything is safe on disk. Returning an error doesn't work because\n         * that would break guests even if the server operates in writethrough\n         * mode.\n         *\n         * Let's hope the user knows what he's doing.\n         *\/\n        ret = 0;\n    }\n    if (ret < 0) {\n        goto out;\n    }\n    \/* Now flush the underlying protocol.  It will also have BDRV_O_NO_FLUSH\n     * in the case of cache=unsafe, so there are no useless flushes.\n     *\/\nflush_parent:\n    ret = bs->file ? bdrv_co_flush(bs->file->bs) : 0;\nout:\n    \/* Notify any pending flushes that we have completed *\/\n    bs->flushed_gen = current_gen;\n    qemu_co_queue_restart_all(&bs->flush_queue);\n    tracked_request_end(&req);\n    return ret;\n}","target":1,"code_token_length":737,"total_token_length":973,"max_tokens_setting":1024}
+{"idx":8364,"func":"reg_match_visual(void)\n{\n    pos_T\ttop, bot;\n    linenr_T    lnum;\n    colnr_T\tcol;\n    win_T\t*wp = rex.reg_win == NULL ? curwin : rex.reg_win;\n    int\t\tmode;\n    colnr_T\tstart, end;\n    colnr_T\tstart2, end2;\n    colnr_T\tcols;\n    colnr_T\tcurswant;\n\n    \/\/ Check if the buffer is the current buffer.\n    if (rex.reg_buf != curbuf || VIsual.lnum == 0)\n\treturn FALSE;\n\n    if (VIsual_active)\n    {\n\tif (LT_POS(VIsual, wp->w_cursor))\n\t{\n\t    top = VIsual;\n\t    bot = wp->w_cursor;\n\t}\n\telse\n\t{\n\t    top = wp->w_cursor;\n\t    bot = VIsual;\n\t}\n\tmode = VIsual_mode;\n\tcurswant = wp->w_curswant;\n    }\n    else\n    {\n\tif (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end))\n\t{\n\t    top = curbuf->b_visual.vi_start;\n\t    bot = curbuf->b_visual.vi_end;\n\t}\n\telse\n\t{\n\t    top = curbuf->b_visual.vi_end;\n\t    bot = curbuf->b_visual.vi_start;\n\t}\n\tmode = curbuf->b_visual.vi_mode;\n\tcurswant = curbuf->b_visual.vi_curswant;\n    }\n    lnum = rex.lnum + rex.reg_firstlnum;\n    if (lnum < top.lnum || lnum > bot.lnum)\n\treturn FALSE;\n\n    if (mode == 'v')\n    {\n\tcol = (colnr_T)(rex.input - rex.line);\n\tif ((lnum == top.lnum && col < top.col)\n\t\t|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))\n\t    return FALSE;\n    }\n    else if (mode == Ctrl_V)\n    {\n\tgetvvcol(wp, &top, &start, NULL, &end);\n\tgetvvcol(wp, &bot, &start2, NULL, &end2);\n\tif (start2 < start)\n\t    start = start2;\n\tif (end2 > end)\n\t    end = end2;\n\tif (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)\n\t    end = MAXCOL;\n\tcols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));\n\tif (cols < start || cols > end - (*p_sel == 'e'))\n\t    return FALSE;\n    }\n    return TRUE;\n}","target":1,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":211524,"func":"void BrowserMainParts::PreMainMessageLoopRun() {\n  device::GeolocationProvider::SetGeolocationDelegate(\n      new GeolocationDelegate());\n\n  media::AudioManager::SetGlobalAppName(\n      BrowserPlatformIntegration::GetInstance()->GetApplicationName());\n\n  if (CanUseSharedGLContext()) {\n    scoped_refptr<GLContextDependent> share_context =\n        BrowserPlatformIntegration::GetInstance()->GetGLShareContext();\n    if (share_context) {\n      gl_share_context_ = GLContextDependent::CloneFrom(share_context.get());\n      gpu::oxide_shim::SetGLShareGroup(gl_share_context_->share_group());\n    }\n  }\n\n#if defined(ENABLE_HYBRIS_CAMERA)\n  VideoCaptureDeviceHybris::Initialize();\n#endif\n\n  gpu::GPUInfo gpu_info;\n  gpu::CollectInfoResult rv = gpu::CollectContextGraphicsInfo(&gpu_info);\n  switch (rv) {\n    case gpu::kCollectInfoFatalFailure:\n      LOG(ERROR) << \"gpu::CollectContextGraphicsInfo failed\";\n      break;\n    case gpu::kCollectInfoNone:\n      NOTREACHED();\n      break;\n    default:\n      break;\n  }\n  content::GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info);\n\n  CompositorUtils::GetInstance()->Initialize(gl_share_context_.get());\n  net::NetModule::SetResourceProvider(NetResourceProvider);\n\n  lifecycle_observer_.reset(new LifecycleObserver());\n  render_process_initializer_.reset(new RenderProcessInitializer());\n}\n","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":25309,"func":"static void insert_to_graph_t38 ( voip_calls_tapinfo_t * tapinfo _U_ , packet_info * pinfo , const gchar * frame_label , const gchar * comment , guint16 call_num , address * src_addr , address * dst_addr , guint16 line_style , guint32 frame_num ) {\n seq_analysis_item_t * gai , * new_gai ;\n GList * list ;\n guint item_num ;\n gboolean inserted ;\n gchar time_str [ COL_MAX_LEN ] ;\n new_gai = ( seq_analysis_item_t * ) g_malloc ( sizeof ( seq_analysis_item_t ) ) ;\n new_gai -> fd = packet_list_get_row_data ( frame_num ) ;\n COPY_ADDRESS ( & ( new_gai -> src_addr ) , src_addr ) ;\n COPY_ADDRESS ( & ( new_gai -> dst_addr ) , dst_addr ) ;\n new_gai -> port_src = pinfo -> srcport ;\n new_gai -> port_dst = pinfo -> destport ;\n if ( frame_label != NULL ) new_gai -> frame_label = g_strdup ( frame_label ) ;\n else new_gai -> frame_label = g_strdup ( \"\" ) ;\n if ( comment != NULL ) new_gai -> comment = g_strdup ( comment ) ;\n else new_gai -> comment = g_strdup ( \"\" ) ;\n new_gai -> conv_num = call_num ;\n new_gai -> line_style = line_style ;\n set_fd_time ( cfile . epan , new_gai -> fd , time_str ) ;\n new_gai -> time_str = g_strdup ( time_str ) ;\n new_gai -> display = FALSE ;\n item_num = 0 ;\n inserted = FALSE ;\n list = g_list_first ( tapinfo -> graph_analysis -> list ) ;\n while ( list ) {\n gai = ( seq_analysis_item_t * ) list -> data ;\n if ( gai -> fd -> num > frame_num ) {\n the_tapinfo_struct . graph_analysis -> list = g_list_insert ( the_tapinfo_struct . graph_analysis -> list , new_gai , item_num ) ;\n g_hash_table_insert ( tapinfo -> graph_analysis -> ht , & new_gai -> fd -> num , new_gai ) ;\n inserted = TRUE ;\n break ;\n }\n list = g_list_next ( list ) ;\n item_num ++ ;\n }\n if ( ! inserted ) {\n tapinfo -> graph_analysis -> list = g_list_prepend ( tapinfo -> graph_analysis -> list , new_gai ) ;\n g_hash_table_insert ( tapinfo -> graph_analysis -> ht , & new_gai -> fd -> num , new_gai ) ;\n }\n }","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":234474,"func":"PHP_FUNCTION(openssl_encrypt)\n{\n\tzend_bool raw_output = 0;\n\tchar *data, *method, *password, *iv = \"\";\n\tint data_len, method_len, password_len, iv_len = 0, max_iv_len;\n\tconst EVP_CIPHER *cipher_type;\n\tEVP_CIPHER_CTX cipher_ctx;\n\tint i = 0, outlen, keylen;\n\tunsigned char *outbuf, *key;\n\tzend_bool free_iv;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"sss|bs\", &data, &data_len, &method, &method_len, &password, &password_len, &raw_output, &iv, &iv_len) == FAILURE) {\n\t\treturn;\n\t}\n\tcipher_type = EVP_get_cipherbyname(method);\n\tif (!cipher_type) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown cipher algorithm\");\n\t\tRETURN_FALSE;\n\t}\n\n\tkeylen = EVP_CIPHER_key_length(cipher_type);\n\tif (keylen > password_len) {\n\t\tkey = emalloc(keylen);\n\t\tmemset(key, 0, keylen);\n\t\tmemcpy(key, password, password_len);\n\t} else {\n\t\tkey = (unsigned char*)password;\n\t}\n\n\tmax_iv_len = EVP_CIPHER_iv_length(cipher_type);\n\tif (iv_len <= 0 && max_iv_len > 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Using an empty Initialization Vector (iv) is potentially insecure and not recommended\");\n\t}\n\tfree_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len TSRMLS_CC);\n\n\toutlen = data_len + EVP_CIPHER_block_size(cipher_type);\n\toutbuf = emalloc(outlen + 1);\n\n\tEVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);\n\tif (password_len > keylen) {\n\t\tEVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len);\n\t}\n\tEVP_EncryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv);\n\tif (data_len > 0) {\n\t\tEVP_EncryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len);\n\t}\n\toutlen = i;\n\tif (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) {\n\t\toutlen += i;\n\t\tif (raw_output) {\n\t\t\toutbuf[outlen] = '\\0';\n\t\t\tRETVAL_STRINGL((char *)outbuf, outlen, 0);\n\t\t} else {\n\t\t\tint base64_str_len;\n\t\t\tchar *base64_str;\n\n\t\t\tbase64_str = (char*)php_base64_encode(outbuf, outlen, &base64_str_len);\n\t\t\tefree(outbuf);\n\t\t\tRETVAL_STRINGL(base64_str, base64_str_len, 0);\n\t\t}\n\t} else {\n\t\tefree(outbuf);\n\t\tRETVAL_FALSE;\n\t}\n\tif (key != (unsigned char*)password) {\n\t\tefree(key);\n\t}\n\tif (free_iv) {\n\t\tefree(iv);\n\t}\n\tEVP_CIPHER_CTX_cleanup(&cipher_ctx);\n}\n","target":0,"code_token_length":669,"total_token_length":905,"max_tokens_setting":1024}
+{"idx":171193,"func":"void WebLocalFrameImpl::ReportContentSecurityPolicyViolation(\n    const blink::WebContentSecurityPolicyViolation& violation) {\n  AddMessageToConsole(blink::WebConsoleMessage(\n      WebConsoleMessage::kLevelError, violation.console_message,\n      violation.source_location.url, violation.source_location.line_number,\n      violation.source_location.column_number));\n\n  std::unique_ptr<SourceLocation> source_location = SourceLocation::Create(\n      violation.source_location.url, violation.source_location.line_number,\n      violation.source_location.column_number, nullptr);\n\n  DCHECK(GetFrame() && GetFrame()->GetDocument());\n  Document* document = GetFrame()->GetDocument();\n  Vector<String> report_endpoints;\n  for (const WebString& end_point : violation.report_endpoints)\n    report_endpoints.push_back(end_point);\n  document->GetContentSecurityPolicy()->ReportViolation(\n      violation.directive, \/* directiveText *\/\n      ContentSecurityPolicy::GetDirectiveType(\n          violation.effective_directive), \/* effectiveType *\/\n      violation.console_message,          \/* consoleMessage *\/\n      violation.blocked_url,              \/* blockedUrl *\/\n      report_endpoints,                   \/* reportEndpoints *\/\n      false,                              \/* don't use the reporting api yet*\/\n      violation.header,                   \/* header *\/\n      static_cast<ContentSecurityPolicyHeaderType>(violation.disposition),\n      ContentSecurityPolicy::ViolationType::kURLViolation, \/* ViolationType *\/\n      std::move(source_location), nullptr,                 \/* LocalFrame *\/\n      violation.after_redirect ? RedirectStatus::kFollowedRedirect\n                               : RedirectStatus::kNoRedirect,\n      nullptr); \/* Element *\/\n}\n","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":137250,"func":"static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,\n\t\t\t\t\t       struct kvm_vcpu_events *events)\n{\n\tprocess_nmi(vcpu);\n\tevents->exception.injected =\n\t\tvcpu->arch.exception.pending &&\n\t\t!kvm_exception_is_soft(vcpu->arch.exception.nr);\n\tevents->exception.nr = vcpu->arch.exception.nr;\n\tevents->exception.has_error_code = vcpu->arch.exception.has_error_code;\n\tevents->exception.pad = 0;\n\tevents->exception.error_code = vcpu->arch.exception.error_code;\n\n\tevents->interrupt.injected =\n\t\tvcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft;\n\tevents->interrupt.nr = vcpu->arch.interrupt.nr;\n\tevents->interrupt.soft = 0;\n\tevents->interrupt.shadow =\n\t\tkvm_x86_ops->get_interrupt_shadow(vcpu,\n\t\t\tKVM_X86_SHADOW_INT_MOV_SS | KVM_X86_SHADOW_INT_STI);\n\n\tevents->nmi.injected = vcpu->arch.nmi_injected;\n\tevents->nmi.pending = vcpu->arch.nmi_pending != 0;\n\tevents->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu);\n\tevents->nmi.pad = 0;\n\n\tevents->sipi_vector = 0; \/* never valid when reporting to user space *\/\n\n\tevents->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING\n\t\t\t | KVM_VCPUEVENT_VALID_SHADOW);\n\tmemset(&events->reserved, 0, sizeof(events->reserved));\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":77219,"func":"inline int ArgMaxVector(const int8_t* input_data, int size) {\n  int32_t max_index = 0;\n  int8_t max_value = input_data[0];\n  int32_t i = 0;\n#ifdef USE_NEON\n  constexpr int VECTOR_SIZE = 16;\n  if (size >= VECTOR_SIZE) {\n    int8x16_t max_value_s8x16;\n    for (; i <= size - VECTOR_SIZE; i += VECTOR_SIZE) {\n      max_value_s8x16 = vld1q_s8(input_data + i);\n      int8_t max_from_vec;\n#ifdef __aarch64__\n      max_from_vec = vmaxvq_s8(max_value_s8x16);\n#else   \/\/ 32 bit\n      int8x8_t max_val_s8x8 =\n          vpmax_s8(vget_low_s8(max_value_s8x16), vget_high_s8(max_value_s8x16));\n      max_val_s8x8 = vpmax_s8(max_val_s8x8, max_val_s8x8);\n      max_val_s8x8 = vpmax_s8(max_val_s8x8, max_val_s8x8);\n      max_val_s8x8 = vpmax_s8(max_val_s8x8, max_val_s8x8);\n      max_from_vec = vget_lane_s8(max_val_s8x8, 0);\n#endif  \/\/ __aarch64__\n      if (max_from_vec > max_value) {\n        max_value = max_from_vec;\n        max_index = i;\n      }\n    }\n  }\n  for (int start_idx = max_index; start_idx < max_index + VECTOR_SIZE;\n       start_idx++) {\n    if (input_data[start_idx] == max_value) {\n      max_index = start_idx;\n      break;\n    }\n  }\n\n#endif  \/\/ USE_NEON\n  \/\/ Leftover loop.\n  for (; i < size; ++i) {\n    const int8_t curr_value = input_data[i];\n    if (curr_value > max_value) {\n      max_value = curr_value;\n      max_index = i;\n    }\n  }\n\n  return max_index;\n}","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":371885,"func":"fr_window_open_extracted_files (OpenFilesData *odata)\n{\n\tGList               *file_list = odata->cdata->file_list;\n\tGFile               *first_file;\n\tconst char          *first_mime_type;\n\tGAppInfo            *app;\n\tGList               *files_to_open = NULL;\n\tGdkAppLaunchContext *context;\n\tgboolean             result;\n\tGError              *error = NULL;\n\n\tg_return_val_if_fail (file_list != NULL, FALSE);\n\n\tfirst_file = G_FILE (file_list->data);\n\tif (first_file == NULL)\n\t\treturn FALSE;\n\n\tif (! odata->window->archive->read_only)\n\t\tmonitor_extracted_files (odata);\n\n\tif (odata->ask_application) {\n\t\tdlg_open_with (odata->window, file_list);\n\t\treturn FALSE;\n\t}\n\n\tfirst_mime_type = _g_file_get_mime_type (first_file, FALSE);\n\tapp = g_app_info_get_default_for_type (first_mime_type, FALSE);\n\n\tif (app == NULL) {\n\t\tdlg_open_with (odata->window, file_list);\n\t\treturn FALSE;\n\t}\n\n\tfiles_to_open = g_list_append (files_to_open, g_file_get_uri (first_file));\n\n\tif (g_app_info_supports_files (app)) {\n\t\tGList *scan;\n\n\t\tfor (scan = file_list->next; scan; scan = scan->next) {\n\t\t\tGFile      *file = G_FILE (scan->data);\n\t\t\tconst char *mime_type;\n\n\t\t\tmime_type = _g_file_get_mime_type (file, FALSE);\n\t\t\tif (mime_type == NULL)\n\t\t\t\tcontinue;\n\n\t\t\tif (strcmp (mime_type, first_mime_type) == 0) {\n\t\t\t\tfiles_to_open = g_list_append (files_to_open, g_file_get_uri (file));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tGAppInfo *app2;\n\n\t\t\t\tapp2 = g_app_info_get_default_for_type (mime_type, FALSE);\n\t\t\t\tif (g_app_info_equal (app, app2))\n\t\t\t\t\tfiles_to_open = g_list_append (files_to_open, g_file_get_uri (file));\n\t\t\t\tg_object_unref (app2);\n\t\t\t}\n\t\t}\n\t}\n\n\tcontext = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (odata->window)));\n\tgdk_app_launch_context_set_screen (context, gtk_widget_get_screen (GTK_WIDGET (odata->window)));\n\tgdk_app_launch_context_set_timestamp (context, 0);\n\tresult = g_app_info_launch_uris (app, files_to_open, G_APP_LAUNCH_CONTEXT (context), &error);\n\tif (! result) {\n\t\t_gtk_error_dialog_run (GTK_WINDOW (odata->window),\n\t\t\t\t       _(\"Could not perform the operation\"),\n\t\t\t\t       \"%s\",\n\t\t\t\t       error->message);\n\t\tg_clear_error (&error);\n\t}\n\n\tg_object_unref (context);\n\tg_object_unref (app);\n\t_g_string_list_free (files_to_open);\n\n\treturn result;\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":441369,"func":"int RGWHandler_REST_S3::init(RGWRados *store, struct req_state *s,\n                             rgw::io::BasicClient *cio)\n{\n  int ret;\n\n  s->dialect = \"s3\";\n\n  ret = rgw_validate_tenant_name(s->bucket_tenant);\n  if (ret)\n    return ret;\n  bool relaxed_names = s->cct->_conf->rgw_relaxed_s3_bucket_names;\n  if (!s->bucket_name.empty()) {\n    ret = valid_s3_bucket_name(s->bucket_name, relaxed_names);\n    if (ret)\n      return ret;\n    ret = validate_object_name(s->object.name);\n    if (ret)\n      return ret;\n  }\n\n  const char *cacl = s->info.env->get(\"HTTP_X_AMZ_ACL\");\n  if (cacl)\n    s->canned_acl = cacl;\n\n  s->has_acl_header = s->info.env->exists_prefix(\"HTTP_X_AMZ_GRANT\");\n\n  const char *copy_source = s->info.env->get(\"HTTP_X_AMZ_COPY_SOURCE\");\n  if (copy_source &&\n      (! s->info.env->get(\"HTTP_X_AMZ_COPY_SOURCE_RANGE\")) &&\n      (! s->info.args.exists(\"uploadId\"))) {\n\n    ret = RGWCopyObj::parse_copy_location(copy_source,\n                                          s->init_state.src_bucket,\n                                          s->src_object);\n    if (!ret) {\n      ldout(s->cct, 0) << \"failed to parse copy location\" << dendl;\n      return -EINVAL; \/\/ XXX why not -ERR_INVALID_BUCKET_NAME or -ERR_BAD_URL?\n    }\n  }\n\n  const char *sc = s->info.env->get(\"HTTP_X_AMZ_STORAGE_CLASS\");\n  if (sc) {\n    s->info.storage_class = sc;\n  }\n\n  return RGWHandler_REST::init(store, s, cio);\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":308721,"func":"Response InspectorNetworkAgent::replayXHR(const String& request_id) {\n  String actual_request_id = request_id;\n\n  XHRReplayData* xhr_replay_data = resources_data_->XhrReplayData(request_id);\n  if (!xhr_replay_data)\n    return Response::Error(\"Given id does not correspond to XHR\");\n\n  ExecutionContext* execution_context = xhr_replay_data->GetExecutionContext();\n  if (execution_context->IsContextDestroyed()) {\n    resources_data_->SetXHRReplayData(request_id, 0);\n    return Response::Error(\"Document is already detached\");\n  }\n\n  XMLHttpRequest* xhr = XMLHttpRequest::Create(execution_context);\n\n  execution_context->RemoveURLFromMemoryCache(xhr_replay_data->Url());\n\n  xhr->open(xhr_replay_data->Method(), xhr_replay_data->Url(),\n            xhr_replay_data->Async(), IGNORE_EXCEPTION_FOR_TESTING);\n  if (xhr_replay_data->IncludeCredentials())\n    xhr->setWithCredentials(true, IGNORE_EXCEPTION_FOR_TESTING);\n  for (const auto& header : xhr_replay_data->Headers()) {\n    xhr->setRequestHeader(header.key, header.value,\n                          IGNORE_EXCEPTION_FOR_TESTING);\n  }\n  xhr->SendForInspectorXHRReplay(xhr_replay_data->FormData(),\n                                 IGNORE_EXCEPTION_FOR_TESTING);\n\n  replay_xhrs_.insert(xhr);\n  return Response::OK();\n}\n","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":436354,"func":"code_to_mbc(OnigCodePoint code, UChar *buf)\n{\n#define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80)\n#define UTF8_TRAIL0(code)        (UChar )(((code) & 0x3f) | 0x80)\n\n  if ((code & 0xffffff80) == 0) {\n    *buf = (UChar )code;\n    return 1;\n  }\n  else {\n    UChar *p = buf;\n\n    if ((code & 0xfffff800) == 0) {\n      *p++ = (UChar )(((code>>6)& 0x1f) | 0xc0);\n    }\n    else if ((code & 0xffff0000) == 0) {\n      *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);\n      *p++ = UTF8_TRAILS(code, 6);\n    }\n    else if ((code & 0xffe00000) == 0) {\n      *p++ = (UChar )(((code>>18) & 0x07) | 0xf0);\n      *p++ = UTF8_TRAILS(code, 12);\n      *p++ = UTF8_TRAILS(code,  6);\n    }\n    else if ((code & 0xfc000000) == 0) {\n      *p++ = (UChar )(((code>>24) & 0x03) | 0xf8);\n      *p++ = UTF8_TRAILS(code, 18);\n      *p++ = UTF8_TRAILS(code, 12);\n      *p++ = UTF8_TRAILS(code,  6);\n    }\n    else if ((code & 0x80000000) == 0) {\n      *p++ = (UChar )(((code>>30) & 0x01) | 0xfc);\n      *p++ = UTF8_TRAILS(code, 24);\n      *p++ = UTF8_TRAILS(code, 18);\n      *p++ = UTF8_TRAILS(code, 12);\n      *p++ = UTF8_TRAILS(code,  6);\n    }\n#ifdef USE_INVALID_CODE_SCHEME\n    else if (code == INVALID_CODE_FE) {\n      *p = 0xfe;\n      return 1;\n    }\n    else if (code == INVALID_CODE_FF) {\n      *p = 0xff;\n      return 1;\n    }\n#endif\n    else {\n      return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;\n    }\n\n    *p++ = UTF8_TRAIL0(code);\n    return p - buf;\n  }\n}","target":0,"code_token_length":633,"total_token_length":869,"max_tokens_setting":1024}
+{"idx":423132,"func":"static int ioat1_enumerate_channels(struct ioatdma_device *device)\n{\n\tu8 xfercap_scale;\n\tu32 xfercap;\n\tint i;\n\tstruct ioat_dma_chan *ioat;\n\tstruct device *dev = &device->pdev->dev;\n\tstruct dma_device *dma = &device->common;\n\n\tINIT_LIST_HEAD(&dma->channels);\n\tdma->chancnt = readb(device->reg_base + IOAT_CHANCNT_OFFSET);\n\tdma->chancnt &= 0x1f; \/* bits [4:0] valid *\/\n\tif (dma->chancnt > ARRAY_SIZE(device->idx)) {\n\t\tdev_warn(dev, \"(%d) exceeds max supported channels (%zu)\\n\",\n\t\t\t dma->chancnt, ARRAY_SIZE(device->idx));\n\t\tdma->chancnt = ARRAY_SIZE(device->idx);\n\t}\n\txfercap_scale = readb(device->reg_base + IOAT_XFERCAP_OFFSET);\n\txfercap_scale &= 0x1f; \/* bits [4:0] valid *\/\n\txfercap = (xfercap_scale == 0 ? -1 : (1UL << xfercap_scale));\n\tdev_dbg(dev, \"%s: xfercap = %d\\n\", __func__, xfercap);\n\n#ifdef  CONFIG_I7300_IDLE_IOAT_CHANNEL\n\tif (i7300_idle_platform_probe(NULL, NULL, 1) == 0)\n\t\tdma->chancnt--;\n#endif\n\tfor (i = 0; i < dma->chancnt; i++) {\n\t\tioat = devm_kzalloc(dev, sizeof(*ioat), GFP_KERNEL);\n\t\tif (!ioat)\n\t\t\tbreak;\n\n\t\tioat_init_channel(device, &ioat->base, i);\n\t\tioat->xfercap = xfercap;\n\t\tspin_lock_init(&ioat->desc_lock);\n\t\tINIT_LIST_HEAD(&ioat->free_desc);\n\t\tINIT_LIST_HEAD(&ioat->used_desc);\n\t}\n\tdma->chancnt = i;\n\treturn i;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":267094,"func":"static int ndp_sock_recv(struct ndp *ndp)\n{\n\tstruct ndp_msg *msg;\n\tenum ndp_msg_type msg_type;\n\tsize_t len;\n\tint err;\n\n\tmsg = ndp_msg_alloc();\n\tif (!msg)\n\t\treturn -ENOMEM;\n\n\tlen = ndp_msg_payload_maxlen(msg);\n\terr = myrecvfrom6(ndp->sock, msg->buf, &len, 0,\n\t\t\t  &msg->addrto, &msg->ifindex, &msg->hoplimit);\n\tif (err) {\n\t\terr(ndp, \"Failed to receive message\");\n\t\tgoto free_msg;\n\t}\n\tdbg(ndp, \"rcvd from: %s, ifindex: %u, hoplimit: %d\",\n\t\t str_in6_addr(&msg->addrto), msg->ifindex, msg->hoplimit);\n\n\tif (msg->hoplimit != 255) {\n\t\twarn(ndp, \"ignoring packet with bad hop limit (%d)\", msg->hoplimit);\n\t\terr = 0;\n\t\tgoto free_msg;\n\t}\n\n\tif (len < sizeof(*msg->icmp6_hdr)) {\n\t\twarn(ndp, \"rcvd icmp6 packet too short (%luB)\", len);\n\t\terr = 0;\n\t\tgoto free_msg;\n\t}\n\terr = ndp_msg_type_by_raw_type(&msg_type, msg->icmp6_hdr->icmp6_type);\n\tif (err) {\n\t\terr = 0;\n\t\tgoto free_msg;\n\t}\n\tndp_msg_init(msg, msg_type);\n\tndp_msg_payload_len_set(msg, len);\n\n\tif (!ndp_msg_check_valid(msg)) {\n\t\twarn(ndp, \"rcvd invalid ND message\");\n\t\terr = 0;\n\t\tgoto free_msg;\n\t}\n\n\tdbg(ndp, \"rcvd %s, len: %zuB\",\n\t\t ndp_msg_type_info(msg_type)->strabbr, len);\n\n\tif (!ndp_msg_check_opts(msg)) {\n\t\terr = 0;\n\t\tgoto free_msg;\n\t}\n\n\terr = ndp_call_handlers(ndp, msg);;\n\nfree_msg:\n\tndp_msg_destroy(msg);\n\treturn err;\n}","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":119778,"func":"int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,\n\t\t       int plus)\n{\n\tuint32_t bitmap[3] = {0};\n\tuint32_t len;\n\t__be32 *p = xdr_inline_decode(xdr, 4);\n\tif (unlikely(!p))\n\t\tgoto out_overflow;\n\tif (*p == xdr_zero) {\n\t\tp = xdr_inline_decode(xdr, 4);\n\t\tif (unlikely(!p))\n\t\t\tgoto out_overflow;\n\t\tif (*p == xdr_zero)\n\t\t\treturn -EAGAIN;\n\t\tentry->eof = 1;\n\t\treturn -EBADCOOKIE;\n\t}\n\n\tp = xdr_inline_decode(xdr, 12);\n\tif (unlikely(!p))\n\t\tgoto out_overflow;\n\tentry->prev_cookie = entry->cookie;\n\tp = xdr_decode_hyper(p, &entry->cookie);\n\tentry->len = be32_to_cpup(p);\n\n\tp = xdr_inline_decode(xdr, entry->len);\n\tif (unlikely(!p))\n\t\tgoto out_overflow;\n\tentry->name = (const char *) p;\n\n\t\/*\n\t * In case the server doesn't return an inode number,\n\t * we fake one here.  (We don't use inode number 0,\n\t * since glibc seems to choke on it...)\n\t *\/\n\tentry->ino = 1;\n\tentry->fattr->valid = 0;\n\n\tif (decode_attr_bitmap(xdr, bitmap) < 0)\n\t\tgoto out_overflow;\n\n\tif (decode_attr_length(xdr, &len, &p) < 0)\n\t\tgoto out_overflow;\n\n\tif (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,\n\t\t\t\t\tentry->server, 1) < 0)\n\t\tgoto out_overflow;\n\tif (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)\n\t\tentry->ino = entry->fattr->mounted_on_fileid;\n\telse if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)\n\t\tentry->ino = entry->fattr->fileid;\n\n\tentry->d_type = DT_UNKNOWN;\n\tif (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)\n\t\tentry->d_type = nfs_umode_to_dtype(entry->fattr->mode);\n\n\treturn 0;\n\nout_overflow:\n\tprint_overflow_msg(__func__, xdr);\n\treturn -EAGAIN;\n}","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":355906,"func":"int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address)\n{\n\tpgtable_t new = pte_alloc_one(mm, address);\n\tif (!new)\n\t\treturn -ENOMEM;\n\n\t\/*\n\t * Ensure all pte setup (eg. pte page lock and page clearing) are\n\t * visible before the pte is made visible to other CPUs by being\n\t * put into page tables.\n\t *\n\t * The other side of the story is the pointer chasing in the page\n\t * table walking code (when walking the page table without locking;\n\t * ie. most of the time). Fortunately, these data accesses consist\n\t * of a chain of data-dependent loads, meaning most CPUs (alpha\n\t * being the notable exception) will already guarantee loads are\n\t * seen in-order. See the alpha page table accessors for the\n\t * smp_read_barrier_depends() barriers in page table walking code.\n\t *\/\n\tsmp_wmb(); \/* Could be smp_wmb__xxx(before|after)_spin_lock *\/\n\n\tspin_lock(&mm->page_table_lock);\n\tif (!pmd_present(*pmd)) {\t\/* Has another populated it ? *\/\n\t\tmm->nr_ptes++;\n\t\tpmd_populate(mm, pmd, new);\n\t\tnew = NULL;\n\t}\n\tspin_unlock(&mm->page_table_lock);\n\tif (new)\n\t\tpte_free(mm, new);\n\treturn 0;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":241395,"func":"int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len TSRMLS_DC) \/* {{{ *\/\n{\n\tphar_entry_info entry = {0};\n\tphp_stream_statbuf ssb;\n\tint is_phar;\n\tconst char *err;\n\n\tif (phar_path_check(&path, &path_len, &err) > pcr_is_ok) {\n\t\treturn FAILURE;\n\t}\n\n\tif (path_len >= sizeof(\".phar\")-1 && !memcmp(path, \".phar\", sizeof(\".phar\")-1)) {\n\t\t\/* no creating magic phar files by mounting them *\/\n\t\treturn FAILURE;\n\t}\n\n\tis_phar = (filename_len > 7 && !memcmp(filename, \"phar:\/\/\", 7));\n\n\tentry.phar = phar;\n\tentry.filename = estrndup(path, path_len);\n#ifdef PHP_WIN32\n\tphar_unixify_path_separators(entry.filename, path_len);\n#endif\n\tentry.filename_len = path_len;\n\tif (is_phar) {\n\t\tentry.tmp = estrndup(filename, filename_len);\n\t} else {\n\t\tentry.tmp = expand_filepath(filename, NULL TSRMLS_CC);\n\t\tif (!entry.tmp) {\n\t\t\tentry.tmp = estrndup(filename, filename_len);\n\t\t}\n\t}\n#if PHP_API_VERSION < 20100412\n\tif (PG(safe_mode) && !is_phar && (!php_checkuid(entry.tmp, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {\n\t\tefree(entry.tmp);\n\t\tefree(entry.filename);\n\t\treturn FAILURE;\n\t}\n#endif\n\tfilename = entry.tmp;\n\n\t\/* only check openbasedir for files, not for phar streams *\/\n\tif (!is_phar && php_check_open_basedir(filename TSRMLS_CC)) {\n\t\tefree(entry.tmp);\n\t\tefree(entry.filename);\n\t\treturn FAILURE;\n\t}\n\n\tentry.is_mounted = 1;\n\tentry.is_crc_checked = 1;\n\tentry.fp_type = PHAR_TMP;\n\n\tif (SUCCESS != php_stream_stat_path(filename, &ssb)) {\n\t\tefree(entry.tmp);\n\t\tefree(entry.filename);\n\t\treturn FAILURE;\n\t}\n\n\tif (ssb.sb.st_mode & S_IFDIR) {\n\t\tentry.is_dir = 1;\n\t\tif (SUCCESS != zend_hash_add(&phar->mounted_dirs, entry.filename, path_len, (void *)&(entry.filename), sizeof(char *), NULL)) {\n\t\t\t\/* directory already mounted *\/\n\t\t\tefree(entry.tmp);\n\t\t\tefree(entry.filename);\n\t\t\treturn FAILURE;\n\t\t}\n\t} else {\n\t\tentry.is_dir = 0;\n\t\tentry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size;\n\t}\n\n\tentry.flags = ssb.sb.st_mode;\n\n\tif (SUCCESS == zend_hash_add(&phar->manifest, entry.filename, path_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {\n\t\treturn SUCCESS;\n\t}\n\n\tefree(entry.tmp);\n\tefree(entry.filename);\n\treturn FAILURE;\n}\n\/* }}} *\/\n","target":0,"code_token_length":638,"total_token_length":874,"max_tokens_setting":1024}
+{"idx":431786,"func":"    bool run(OperationContext* txn,\n             const string& dbname,\n             BSONObj& cmdObj,\n             int options,\n             string& errmsg,\n             BSONObjBuilder& result) {\n        RoleName roleName;\n        PrivilegeVector privilegesToRemove;\n        Status status = auth::parseAndValidateRolePrivilegeManipulationCommands(\n            cmdObj, \"revokePrivilegesFromRole\", dbname, &roleName, &privilegesToRemove);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n\n        ServiceContext* serviceContext = txn->getClient()->getServiceContext();\n        stdx::lock_guard<stdx::mutex> lk(getAuthzDataMutex(serviceContext));\n\n        AuthorizationManager* authzManager = AuthorizationManager::get(serviceContext);\n        status = requireAuthSchemaVersion26Final(txn, authzManager);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n\n        if (RoleGraph::isBuiltinRole(roleName)) {\n            return appendCommandStatus(\n                result,\n                Status(ErrorCodes::InvalidRoleModification,\n                       str::stream() << roleName.getFullName()\n                                     << \" is a built-in role and cannot be modified.\"));\n        }\n\n        BSONObj roleDoc;\n        status = authzManager->getRoleDescription(\n            txn, roleName, PrivilegeFormat::kShowSeparate, &roleDoc);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n\n        PrivilegeVector privileges;\n        status = auth::parseAndValidatePrivilegeArray(BSONArray(roleDoc[\"privileges\"].Obj()),\n                                                      &privileges);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n\n        for (PrivilegeVector::iterator itToRm = privilegesToRemove.begin();\n             itToRm != privilegesToRemove.end();\n             ++itToRm) {\n            for (PrivilegeVector::iterator curIt = privileges.begin(); curIt != privileges.end();\n                 ++curIt) {\n                if (curIt->getResourcePattern() == itToRm->getResourcePattern()) {\n                    curIt->removeActions(itToRm->getActions());\n                    if (curIt->getActions().empty()) {\n                        privileges.erase(curIt);\n                    }\n                    break;\n                }\n            }\n        }\n\n        \/\/ Build up update modifier object to $set privileges.\n        mutablebson::Document updateObj;\n        mutablebson::Element setElement = updateObj.makeElementObject(\"$set\");\n        status = updateObj.root().pushBack(setElement);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n        mutablebson::Element privilegesElement = updateObj.makeElementArray(\"privileges\");\n        status = setElement.pushBack(privilegesElement);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n        status = authzManager->getBSONForPrivileges(privileges, privilegesElement);\n        if (!status.isOK()) {\n            return appendCommandStatus(result, status);\n        }\n\n        audit::logRevokePrivilegesFromRole(Client::getCurrent(), roleName, privilegesToRemove);\n\n        BSONObjBuilder updateBSONBuilder;\n        updateObj.writeTo(&updateBSONBuilder);\n        status = updateRoleDocument(txn, roleName, updateBSONBuilder.done());\n        \/\/ Must invalidate even on bad status - what if the write succeeded but the GLE failed?\n        authzManager->invalidateUserCache();\n        return appendCommandStatus(result, status);\n    }","target":0,"code_token_length":727,"total_token_length":963,"max_tokens_setting":1024}
+{"idx":489778,"func":"GF_Err fdpa_box_dump(GF_Box *a, FILE * trace)\n{\n\tu32 i;\n\tGF_FDpacketBox *ptr = (GF_FDpacketBox *) a;\n\tif (!a) return GF_BAD_PARAM;\n\n\tgf_isom_box_dump_start(a, \"FDpacketBox\", trace);\n\tgf_fprintf(trace, \"sender_current_time_present=\\\"%d\\\" expected_residual_time_present=\\\"%d\\\" session_close_bit=\\\"%d\\\" object_close_bit=\\\"%d\\\" transport_object_identifier=\\\"%d\\\">\\n\", ptr->info.sender_current_time_present, ptr->info.expected_residual_time_present, ptr->info.session_close_bit, ptr->info.object_close_bit, ptr->info.transport_object_identifier);\n\n\tfor (i=0; i<ptr->header_ext_count; i++) {\n\t\tgf_fprintf(trace, \"<FDHeaderExt type=\\\"%d\\\"\", ptr->headers[i].header_extension_type);\n\t\tif (ptr->headers[i].header_extension_type > 127) {\n\t\t\tdump_data_attribute(trace, \"content\", (char *) ptr->headers[i].content, 3);\n\t\t} else if (ptr->headers[i].data_length) {\n\t\t\tdump_data_attribute(trace, \"data\", ptr->headers[i].data, ptr->headers[i].data_length);\n\t\t}\n\t\tgf_fprintf(trace, \"\/>\\n\");\n\t}\n\tif (!ptr->size) {\n\t\tgf_fprintf(trace, \"<FDHeaderExt type=\\\"\\\" content=\\\"\\\" data=\\\"\\\"\/>\\n\");\n\t}\n\tgf_isom_box_dump_done(\"FDpacketBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":215224,"func":"static void update_rq_clock_task(struct rq *rq, s64 delta)\n{\n\/*\n * In theory, the compile should just see 0 here, and optimize out the call\n * to sched_rt_avg_update. But I don't trust it...\n *\/\n#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)\n\ts64 steal = 0, irq_delta = 0;\n#endif\n#ifdef CONFIG_IRQ_TIME_ACCOUNTING\n\tirq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;\n\n\t\/*\n\t * Since irq_time is only updated on {soft,}irq_exit, we might run into\n\t * this case when a previous update_rq_clock() happened inside a\n\t * {soft,}irq region.\n\t *\n\t * When this happens, we stop ->clock_task and only update the\n\t * prev_irq_time stamp to account for the part that fit, so that a next\n\t * update will consume the rest. This ensures ->clock_task is\n\t * monotonic.\n\t *\n\t * It does however cause some slight miss-attribution of {soft,}irq\n\t * time, a more accurate solution would be to update the irq_time using\n\t * the current rq->clock timestamp, except that would require using\n\t * atomic ops.\n\t *\/\n\tif (irq_delta > delta)\n\t\tirq_delta = delta;\n\n\trq->prev_irq_time += irq_delta;\n\tdelta -= irq_delta;\n#endif\n#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING\n\tif (static_key_false((¶virt_steal_rq_enabled))) {\n\t\tsteal = paravirt_steal_clock(cpu_of(rq));\n\t\tsteal -= rq->prev_steal_time_rq;\n\n\t\tif (unlikely(steal > delta))\n\t\t\tsteal = delta;\n\n\t\trq->prev_steal_time_rq += steal;\n\t\tdelta -= steal;\n\t}\n#endif\n\n\trq->clock_task += delta;\n\n#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)\n\tif ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))\n\t\tsched_rt_avg_update(rq, irq_delta + steal);\n#endif\n}\n","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":131958,"func":"static int au1200fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green,\n\tunsigned blue, unsigned transp, struct fb_info *fbi)\n{\n\tvolatile u32 *palette = lcd->palette;\n\tu32 value;\n\n\tif (regno > (AU1200_LCD_NBR_PALETTE_ENTRIES - 1))\n\t\treturn -EINVAL;\n\n\tif (fbi->var.grayscale) {\n\t\t\/* Convert color to grayscale *\/\n\t\tred = green = blue =\n\t\t\t(19595 * red + 38470 * green + 7471 * blue) >> 16;\n\t}\n\n\tif (fbi->fix.visual == FB_VISUAL_TRUECOLOR) {\n\t\t\/* Place color in the pseudopalette *\/\n\t\tif (regno > 16)\n\t\t\treturn -EINVAL;\n\n\t\tpalette = (u32*) fbi->pseudo_palette;\n\n\t\tred   >>= (16 - fbi->var.red.length);\n\t\tgreen >>= (16 - fbi->var.green.length);\n\t\tblue  >>= (16 - fbi->var.blue.length);\n\n\t\tvalue = (red   << fbi->var.red.offset) \t|\n\t\t\t(green << fbi->var.green.offset)|\n\t\t\t(blue  << fbi->var.blue.offset);\n\t\tvalue &= 0xFFFF;\n\n\t} else if (1 \/*FIX!!! panel_is_active(fbdev->panel)*\/) {\n\t\t\/* COLOR TFT PALLETTIZED (use RGB 565) *\/\n\t\tvalue = (red & 0xF800)|((green >> 5) &\n\t\t\t\t0x07E0)|((blue >> 11) & 0x001F);\n\t\tvalue &= 0xFFFF;\n\n\t} else if (0 \/*panel_is_color(fbdev->panel)*\/) {\n\t\t\/* COLOR STN MODE *\/\n\t\tvalue = 0x1234;\n\t\tvalue &= 0xFFF;\n\t} else {\n\t\t\/* MONOCHROME MODE *\/\n\t\tvalue = (green >> 12) & 0x000F;\n\t\tvalue &= 0xF;\n\t}\n\n\tpalette[regno] = value;\n\n\treturn 0;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":96645,"func":"smb2_new_read_req(struct kvec *iov, struct cifs_io_parms *io_parms,\n\t\t  unsigned int remaining_bytes, int request_type)\n{\n\tint rc = -EACCES;\n\tstruct smb2_read_req *req = NULL;\n\n\trc = small_smb2_init(SMB2_READ, io_parms->tcon, (void **) &req);\n\tif (rc)\n\t\treturn rc;\n\tif (io_parms->tcon->ses->server == NULL)\n\t\treturn -ECONNABORTED;\n\n\treq->hdr.ProcessId = cpu_to_le32(io_parms->pid);\n\n\treq->PersistentFileId = io_parms->persistent_fid;\n\treq->VolatileFileId = io_parms->volatile_fid;\n\treq->ReadChannelInfoOffset = 0; \/* reserved *\/\n\treq->ReadChannelInfoLength = 0; \/* reserved *\/\n\treq->Channel = 0; \/* reserved *\/\n\treq->MinimumCount = 0;\n\treq->Length = cpu_to_le32(io_parms->length);\n\treq->Offset = cpu_to_le64(io_parms->offset);\n\n\tif (request_type & CHAINED_REQUEST) {\n\t\tif (!(request_type & END_OF_CHAIN)) {\n\t\t\t\/* 4 for rfc1002 length field *\/\n\t\t\treq->hdr.NextCommand =\n\t\t\t\tcpu_to_le32(get_rfc1002_length(req) + 4);\n\t\t} else \/* END_OF_CHAIN *\/\n\t\t\treq->hdr.NextCommand = 0;\n\t\tif (request_type & RELATED_REQUEST) {\n\t\t\treq->hdr.Flags |= SMB2_FLAGS_RELATED_OPERATIONS;\n\t\t\t\/*\n\t\t\t * Related requests use info from previous read request\n\t\t\t * in chain.\n\t\t\t *\/\n\t\t\treq->hdr.SessionId = 0xFFFFFFFF;\n\t\t\treq->hdr.TreeId = 0xFFFFFFFF;\n\t\t\treq->PersistentFileId = 0xFFFFFFFF;\n\t\t\treq->VolatileFileId = 0xFFFFFFFF;\n\t\t}\n\t}\n\tif (remaining_bytes > io_parms->length)\n\t\treq->RemainingBytes = cpu_to_le32(remaining_bytes);\n\telse\n\t\treq->RemainingBytes = 0;\n\n\tiov[0].iov_base = (char *)req;\n\t\/* 4 for rfc1002 length field *\/\n\tiov[0].iov_len = get_rfc1002_length(req) + 4;\n\treturn rc;\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":25146,"func":"static int phar_tar_process_metadata ( phar_entry_info * entry , php_stream * fp TSRMLS_DC ) {\n char * metadata ;\n size_t save = php_stream_tell ( fp ) , read ;\n phar_entry_info * mentry ;\n metadata = ( char * ) safe_emalloc ( 1 , entry -> uncompressed_filesize , 1 ) ;\n read = php_stream_read ( fp , metadata , entry -> uncompressed_filesize ) ;\n if ( read != entry -> uncompressed_filesize ) {\n efree ( metadata ) ;\n php_stream_seek ( fp , save , SEEK_SET ) ;\n return FAILURE ;\n }\n if ( phar_parse_metadata ( & metadata , & entry -> metadata , entry -> uncompressed_filesize TSRMLS_CC ) == FAILURE ) {\n efree ( metadata ) ;\n php_stream_seek ( fp , save , SEEK_SET ) ;\n return FAILURE ;\n }\n if ( entry -> filename_len == sizeof ( \".phar\/.metadata.bin\" ) - 1 && ! memcmp ( entry -> filename , \".phar\/.metadata.bin\" , sizeof ( \".phar\/.metadata.bin\" ) - 1 ) ) {\n entry -> phar -> metadata = entry -> metadata ;\n entry -> metadata = NULL ;\n }\n else if ( entry -> filename_len >= sizeof ( \".phar\/.metadata\/\" ) + sizeof ( \"\/.metadata.bin\" ) - 1 && SUCCESS == zend_hash_find ( & ( entry -> phar -> manifest ) , entry -> filename + sizeof ( \".phar\/.metadata\/\" ) - 1 , entry -> filename_len - ( sizeof ( \"\/.metadata.bin\" ) - 1 + sizeof ( \".phar\/.metadata\/\" ) - 1 ) , ( void * ) & mentry ) ) {\n mentry -> metadata = entry -> metadata ;\n entry -> metadata = NULL ;\n }\n efree ( metadata ) ;\n php_stream_seek ( fp , save , SEEK_SET ) ;\n return SUCCESS ;\n }","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":417006,"func":"int ovl_permission(struct inode *inode, int mask)\n{\n\tstruct ovl_entry *oe = inode->i_private;\n\tbool is_upper;\n\tstruct dentry *realdentry = ovl_entry_real(oe, &is_upper);\n\tstruct inode *realinode;\n\tconst struct cred *old_cred;\n\tint err;\n\n\tif (ovl_is_default_permissions(inode)) {\n\t\tstruct kstat stat;\n\t\tstruct path realpath = { .dentry = realdentry };\n\n\t\tif (mask & MAY_NOT_BLOCK)\n\t\t\treturn -ECHILD;\n\n\t\trealpath.mnt = ovl_entry_mnt_real(oe, inode, is_upper);\n\n\t\terr = vfs_getattr(&realpath, &stat);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif ((stat.mode ^ inode->i_mode) & S_IFMT)\n\t\t\treturn -ESTALE;\n\n\t\tinode->i_mode = stat.mode;\n\t\tinode->i_uid = stat.uid;\n\t\tinode->i_gid = stat.gid;\n\n\t\treturn generic_permission(inode, mask);\n\t}\n\n\t\/* Careful in RCU walk mode *\/\n\trealinode = d_inode_rcu(realdentry);\n\tif (!realinode) {\n\t\tWARN_ON(!(mask & MAY_NOT_BLOCK));\n\t\treturn -ENOENT;\n\t}\n\n\tif (mask & MAY_WRITE) {\n\t\tumode_t mode = realinode->i_mode;\n\n\t\t\/*\n\t\t * Writes will always be redirected to upper layer, so\n\t\t * ignore lower layer being read-only.\n\t\t *\n\t\t * If the overlay itself is read-only then proceed\n\t\t * with the permission check, don't return EROFS.\n\t\t * This will only happen if this is the lower layer of\n\t\t * another overlayfs.\n\t\t *\n\t\t * If upper fs becomes read-only after the overlay was\n\t\t * constructed return EROFS to prevent modification of\n\t\t * upper layer.\n\t\t *\/\n\t\tif (is_upper && !IS_RDONLY(inode) && IS_RDONLY(realinode) &&\n\t\t    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))\n\t\t\treturn -EROFS;\n\t}\n\n\t\/*\n\t * Check overlay inode with the creds of task and underlying inode\n\t * with creds of mounter\n\t *\/\n\terr = generic_permission(inode, mask);\n\tif (err)\n\t\treturn err;\n\n\told_cred = ovl_override_creds(inode->i_sb);\n\terr = __inode_permission(realinode, mask);\n\trevert_creds(old_cred);\n\n\treturn err;\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":179474,"func":"InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(\n    ScrollState* scroll_state,\n    InputHandler::ScrollInputType type) {\n  ScrollStatus scroll_status;\n  scroll_status.main_thread_scrolling_reasons =\n      MainThreadScrollingReason::kNotScrollingOnMain;\n  TRACE_EVENT0(\"cc\", \"LayerTreeHostImpl::ScrollBegin\");\n\n  ScrollNode* scrolling_node = nullptr;\n  bool scroll_on_main_thread = false;\n\n  if (scroll_state->is_in_inertial_phase())\n    scrolling_node = CurrentlyScrollingNode();\n\n  if (!scrolling_node) {\n    ClearCurrentlyScrollingNode();\n\n    gfx::Point viewport_point(scroll_state->position_x(),\n                              scroll_state->position_y());\n\n    gfx::PointF device_viewport_point = gfx::ScalePoint(\n        gfx::PointF(viewport_point), active_tree_->device_scale_factor());\n    LayerImpl* layer_impl =\n        active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);\n\n    if (layer_impl) {\n      if (!IsInitialScrollHitTestReliable(layer_impl, device_viewport_point)) {\n        scroll_status.thread = SCROLL_UNKNOWN;\n        scroll_status.main_thread_scrolling_reasons =\n            MainThreadScrollingReason::kFailedHitTest;\n        return scroll_status;\n      }\n    }\n\n    auto* scrolling_layer = FindScrollLayerForDeviceViewportPoint(\n        device_viewport_point, type, layer_impl, &scroll_on_main_thread,\n        &scroll_status.main_thread_scrolling_reasons);\n    ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;\n    scrolling_node =\n        scrolling_layer ? scroll_tree.Node(scrolling_layer->scroll_tree_index())\n                        : nullptr;\n  }\n\n  if (scroll_on_main_thread) {\n    RecordCompositorSlowScrollMetric(type, MAIN_THREAD);\n\n    scroll_status.thread = SCROLL_ON_MAIN_THREAD;\n    return scroll_status;\n  } else if (scrolling_node) {\n    scroll_affects_scroll_handler_ = active_tree_->have_scroll_event_handlers();\n  }\n\n  return ScrollBeginImpl(scroll_state, scrolling_node, type);\n}\n","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":323652,"func":"static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n    __asm__ volatile(\n\n        \"movq \"MANGLE(bm01010101)\", %%mm4           \\n\\t\"\n\n        \"mov                    %0, %%\"REG_a\"       \\n\\t\"\n\n        \"1:                                         \\n\\t\"\n\n        \"movq    (%1, %%\"REG_a\",4), %%mm0           \\n\\t\"\n\n        \"movq   8(%1, %%\"REG_a\",4), %%mm1           \\n\\t\"\n\n        \"pand                %%mm4, %%mm0           \\n\\t\"\n\n        \"pand                %%mm4, %%mm1           \\n\\t\"\n\n        \"packuswb            %%mm1, %%mm0           \\n\\t\"\n\n        \"movq                %%mm0, %%mm1           \\n\\t\"\n\n        \"psrlw                  $8, %%mm0           \\n\\t\"\n\n        \"pand                %%mm4, %%mm1           \\n\\t\"\n\n        \"packuswb            %%mm0, %%mm0           \\n\\t\"\n\n        \"packuswb            %%mm1, %%mm1           \\n\\t\"\n\n        \"movd                %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\n        \"movd                %%mm1, (%2, %%\"REG_a\") \\n\\t\"\n\n        \"add                    $4, %%\"REG_a\"       \\n\\t\"\n\n        \" js                    1b                  \\n\\t\"\n\n        : : \"g\" ((x86_reg)-width), \"r\" (src1+width*4), \"r\" (dstU+width), \"r\" (dstV+width)\n\n        : \"%\"REG_a\n\n    );\n\n#else\n\n    int i;\n\n    for (i=0; i<width; i++) {\n\n        dstU[i]= src1[4*i + 0];\n\n        dstV[i]= src1[4*i + 2];\n\n    }\n\n#endif\n\n    assert(src1 == src2);\n\n}\n","target":0,"code_token_length":487,"total_token_length":723,"max_tokens_setting":1024}
+{"idx":331736,"func":"void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,\n\n                         unsigned long vga_ram_offset, int vga_ram_size)\n\n{\n\n    PCICirrusVGAState *d;\n\n    uint8_t *pci_conf;\n\n    CirrusVGAState *s;\n\n    int device_id;\n\n\n\n    device_id = CIRRUS_ID_CLGD5446;\n\n\n\n    \/* setup PCI configuration registers *\/\n\n    d = (PCICirrusVGAState *)pci_register_device(bus, \"Cirrus VGA\",\n\n                                                 sizeof(PCICirrusVGAState),\n\n                                                 -1, NULL, NULL);\n\n    pci_conf = d->dev.config;\n\n    pci_conf[0x00] = (uint8_t) (PCI_VENDOR_CIRRUS & 0xff);\n\n    pci_conf[0x01] = (uint8_t) (PCI_VENDOR_CIRRUS >> 8);\n\n    pci_conf[0x02] = (uint8_t) (device_id & 0xff);\n\n    pci_conf[0x03] = (uint8_t) (device_id >> 8);\n\n    pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;\n\n    pci_conf[0x0a] = PCI_CLASS_SUB_VGA;\n\n    pci_conf[0x0b] = PCI_CLASS_BASE_DISPLAY;\n\n    pci_conf[0x0e] = PCI_CLASS_HEADERTYPE_00h;\n\n\n\n    \/* setup VGA *\/\n\n    s = &d->cirrus_vga;\n\n    vga_common_init((VGAState *)s,\n\n                    ds, vga_ram_base, vga_ram_offset, vga_ram_size);\n\n    cirrus_init_common(s, device_id, 1);\n\n\n\n    s->console = graphic_console_init(s->ds, s->update, s->invalidate,\n\n                                      s->screen_dump, s->text_update, s);\n\n\n\n    s->pci_dev = (PCIDevice *)d;\n\n\n\n    \/* setup memory space *\/\n\n    \/* memory #0 LFB *\/\n\n    \/* memory #1 memory-mapped I\/O *\/\n\n    \/* XXX: s->vram_size must be a power of two *\/\n\n    pci_register_io_region((PCIDevice *)d, 0, 0x2000000,\n\n\t\t\t   PCI_ADDRESS_SPACE_MEM_PREFETCH, cirrus_pci_lfb_map);\n\n    if (device_id == CIRRUS_ID_CLGD5446) {\n\n        pci_register_io_region((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,\n\n                               PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);\n\n    }\n\n    \/* XXX: ROM BIOS *\/\n\n}\n","target":0,"code_token_length":567,"total_token_length":803,"max_tokens_setting":1024}
+{"idx":5268,"func":"  void operator()(const CPUDevice& d, typename TTypes<T, 4>::ConstTensor input,\n                  typename TTypes<T, 3>::ConstTensor filter,\n                  typename TTypes<T, 4>::ConstTensor out_backprop,\n                  int stride_rows, int stride_cols, int rate_rows,\n                  int rate_cols, int pad_top, int pad_left,\n                  typename TTypes<T, 4>::Tensor in_backprop) {\n    const int batch = input.dimension(0);\n    const int input_rows = input.dimension(1);\n    const int input_cols = input.dimension(2);\n    const int depth = input.dimension(3);\n\n    const int filter_rows = filter.dimension(0);\n    const int filter_cols = filter.dimension(1);\n\n    const int output_rows = out_backprop.dimension(1);\n    const int output_cols = out_backprop.dimension(2);\n\n    \/\/ Initialize gradient with all zeros.\n    in_backprop.setZero();\n\n    \/\/ This is a reference implementation, likely to be slow.\n    \/\/ TODO(gpapan): Write multi-threaded implementation.\n    \/\/ In the case of multiple argmax branches, we only back-propagate along the\n    \/\/ last branch, i.e., the one with largest value of `h * filter_cols + w`,\n    \/\/ similarly to the max-pooling backward routines.\n    for (int b = 0; b < batch; ++b) {\n      for (int h_out = 0; h_out < output_rows; ++h_out) {\n        int h_beg = h_out * stride_rows - pad_top;\n        for (int w_out = 0; w_out < output_cols; ++w_out) {\n          int w_beg = w_out * stride_cols - pad_left;\n          for (int d = 0; d < depth; ++d) {\n            T cur_val = Eigen::NumTraits<T>::lowest();\n            int h_in_max = (h_beg < 0) ? 0 : h_beg;\n            int w_in_max = (w_beg < 0) ? 0 : w_beg;\n            for (int h = 0; h < filter_rows; ++h) {\n              const int h_in = h_beg + h * rate_rows;\n              if (h_in >= 0 && h_in < input_rows) {\n                for (int w = 0; w < filter_cols; ++w) {\n                  const int w_in = w_beg + w * rate_cols;\n                  if (w_in >= 0 && w_in < input_cols) {\n                    const T val = input(b, h_in, w_in, d) + filter(h, w, d);\n                    if (val > cur_val) {\n                      cur_val = val;\n                      h_in_max = h_in;\n                      w_in_max = w_in;\n                    }\n                  }\n                }\n              }\n            }\n            in_backprop(b, h_in_max, w_in_max, d) +=\n                out_backprop(b, h_out, w_out, d);\n          }\n        }\n      }\n    }\n  }","target":1,"code_token_length":633,"total_token_length":869,"max_tokens_setting":1024}
+{"idx":87134,"func":"static void simplify_merges(struct rev_info *revs)\n{\n\tstruct commit_list *list, *next;\n\tstruct commit_list *yet_to_do, **tail;\n\tstruct commit *commit;\n\n\tif (!revs->prune)\n\t\treturn;\n\n\t\/* feed the list reversed *\/\n\tyet_to_do = NULL;\n\tfor (list = revs->commits; list; list = next) {\n\t\tcommit = list->item;\n\t\tnext = list->next;\n\t\t\/*\n\t\t * Do not free(list) here yet; the original list\n\t\t * is used later in this function.\n\t\t *\/\n\t\tcommit_list_insert(commit, &yet_to_do);\n\t}\n\twhile (yet_to_do) {\n\t\tlist = yet_to_do;\n\t\tyet_to_do = NULL;\n\t\ttail = &yet_to_do;\n\t\twhile (list) {\n\t\t\tcommit = pop_commit(&list);\n\t\t\ttail = simplify_one(revs, commit, tail);\n\t\t}\n\t}\n\n\t\/* clean up the result, removing the simplified ones *\/\n\tlist = revs->commits;\n\trevs->commits = NULL;\n\ttail = &revs->commits;\n\twhile (list) {\n\t\tstruct merge_simplify_state *st;\n\n\t\tcommit = pop_commit(&list);\n\t\tst = locate_simplify_state(revs, commit);\n\t\tif (st->simplified == commit)\n\t\t\ttail = &commit_list_insert(commit, tail)->next;\n\t}\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":113609,"func":"static int hfsplus_cat_build_record(hfsplus_cat_entry *entry,\n\t\tu32 cnid, struct inode *inode)\n{\n\tstruct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);\n\n\tif (S_ISDIR(inode->i_mode)) {\n\t\tstruct hfsplus_cat_folder *folder;\n\n\t\tfolder = &entry->folder;\n\t\tmemset(folder, 0, sizeof(*folder));\n\t\tfolder->type = cpu_to_be16(HFSPLUS_FOLDER);\n\t\tfolder->id = cpu_to_be32(inode->i_ino);\n\t\tHFSPLUS_I(inode)->create_date =\n\t\t\tfolder->create_date =\n\t\t\tfolder->content_mod_date =\n\t\t\tfolder->attribute_mod_date =\n\t\t\tfolder->access_date = hfsp_now2mt();\n\t\thfsplus_cat_set_perms(inode, &folder->permissions);\n\t\tif (inode == sbi->hidden_dir)\n\t\t\t\/* invisible and namelocked *\/\n\t\t\tfolder->user_info.frFlags = cpu_to_be16(0x5000);\n\t\treturn sizeof(*folder);\n\t} else {\n\t\tstruct hfsplus_cat_file *file;\n\n\t\tfile = &entry->file;\n\t\tmemset(file, 0, sizeof(*file));\n\t\tfile->type = cpu_to_be16(HFSPLUS_FILE);\n\t\tfile->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS);\n\t\tfile->id = cpu_to_be32(cnid);\n\t\tHFSPLUS_I(inode)->create_date =\n\t\t\tfile->create_date =\n\t\t\tfile->content_mod_date =\n\t\t\tfile->attribute_mod_date =\n\t\t\tfile->access_date = hfsp_now2mt();\n\t\tif (cnid == inode->i_ino) {\n\t\t\thfsplus_cat_set_perms(inode, &file->permissions);\n\t\t\tif (S_ISLNK(inode->i_mode)) {\n\t\t\t\tfile->user_info.fdType =\n\t\t\t\t\tcpu_to_be32(HFSP_SYMLINK_TYPE);\n\t\t\t\tfile->user_info.fdCreator =\n\t\t\t\t\tcpu_to_be32(HFSP_SYMLINK_CREATOR);\n\t\t\t} else {\n\t\t\t\tfile->user_info.fdType =\n\t\t\t\t\tcpu_to_be32(sbi->type);\n\t\t\t\tfile->user_info.fdCreator =\n\t\t\t\t\tcpu_to_be32(sbi->creator);\n\t\t\t}\n\t\t\tif (HFSPLUS_FLG_IMMUTABLE &\n\t\t\t\t\t(file->permissions.rootflags |\n\t\t\t\t\tfile->permissions.userflags))\n\t\t\t\tfile->flags |=\n\t\t\t\t\tcpu_to_be16(HFSPLUS_FILE_LOCKED);\n\t\t} else {\n\t\t\tfile->user_info.fdType =\n\t\t\t\tcpu_to_be32(HFSP_HARDLINK_TYPE);\n\t\t\tfile->user_info.fdCreator =\n\t\t\t\tcpu_to_be32(HFSP_HFSPLUS_CREATOR);\n\t\t\tfile->user_info.fdFlags =\n\t\t\t\tcpu_to_be16(0x100);\n\t\t\tfile->create_date =\n\t\t\t\tHFSPLUS_I(sbi->hidden_dir)->create_date;\n\t\t\tfile->permissions.dev =\n\t\t\t\tcpu_to_be32(HFSPLUS_I(inode)->linkid);\n\t\t}\n\t\treturn sizeof(*file);\n\t}\n}","target":0,"code_token_length":650,"total_token_length":886,"max_tokens_setting":1024}
+{"idx":323046,"func":"ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,\n\n                               MemoryRegion ram_memories[],\n\n                               hwaddr ram_bases[],\n\n                               hwaddr ram_sizes[],\n\n                               const unsigned int sdram_bank_sizes[])\n\n{\n\n    ram_addr_t size_left = ram_size;\n\n    ram_addr_t base = 0;\n\n    int i;\n\n    int j;\n\n\n\n    for (i = 0; i < nr_banks; i++) {\n\n        for (j = 0; sdram_bank_sizes[j] != 0; j++) {\n\n            unsigned int bank_size = sdram_bank_sizes[j];\n\n\n\n            if (bank_size <= size_left) {\n\n                char name[32];\n\n                snprintf(name, sizeof(name), \"ppc4xx.sdram%d\", i);\n\n                memory_region_allocate_system_memory(&ram_memories[i], NULL,\n\n                                                     name, bank_size);\n\n                ram_bases[i] = base;\n\n                ram_sizes[i] = bank_size;\n\n                base += bank_size;\n\n                size_left -= bank_size;\n\n                break;\n\n            }\n\n        }\n\n\n\n        if (!size_left) {\n\n            \/* No need to use the remaining banks. *\/\n\n            break;\n\n        }\n\n    }\n\n\n\n    ram_size -= size_left;\n\n    if (size_left)\n\n        printf(\"Truncating memory to %d MiB to fit SDRAM controller limits.\\n\",\n\n               (int)(ram_size >> 20));\n\n\n\n    return ram_size;\n\n}\n","target":1,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":391636,"func":"xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {\n    xmlNsPtr def;\n    xmlChar prefix[50];\n    int counter = 1;\n\n    if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) {\n#ifdef DEBUG_TREE\n        xmlGenericError(xmlGenericErrorContext,\n\t\t\"xmlNewReconciliedNs : tree == NULL\\n\");\n#endif\n\treturn(NULL);\n    }\n    if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {\n#ifdef DEBUG_TREE\n        xmlGenericError(xmlGenericErrorContext,\n\t\t\"xmlNewReconciliedNs : ns == NULL\\n\");\n#endif\n\treturn(NULL);\n    }\n    \/*\n     * Search an existing namespace definition inherited.\n     *\/\n    def = xmlSearchNsByHref(doc, tree, ns->href);\n    if (def != NULL)\n        return(def);\n\n    \/*\n     * Find a close prefix which is not already in use.\n     * Let's strip namespace prefixes longer than 20 chars !\n     *\/\n    if (ns->prefix == NULL)\n\tsnprintf((char *) prefix, sizeof(prefix), \"default\");\n    else\n\tsnprintf((char *) prefix, sizeof(prefix), \"%.20s\", (char *)ns->prefix);\n\n    def = xmlSearchNs(doc, tree, prefix);\n    while (def != NULL) {\n        if (counter > 1000) return(NULL);\n\tif (ns->prefix == NULL)\n\t    snprintf((char *) prefix, sizeof(prefix), \"default%d\", counter++);\n\telse\n\t    snprintf((char *) prefix, sizeof(prefix), \"%.20s%d\",\n\t\t(char *)ns->prefix, counter++);\n\tdef = xmlSearchNs(doc, tree, prefix);\n    }\n\n    \/*\n     * OK, now we are ready to create a new one.\n     *\/\n    def = xmlNewNs(tree, ns->href, prefix);\n    return(def);\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":323666,"func":"static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order,\n\n                                  uint64_t param, uint64_t *status_reg)\n\n{\n\n    SigpInfo si = {\n\n        .param = param,\n\n        .status_reg = status_reg,\n\n    };\n\n\n\n    \/* cpu available? *\/\n\n    if (dst_cpu == NULL) {\n\n        return SIGP_CC_NOT_OPERATIONAL;\n\n    }\n\n\n\n    \/* only resets can break pending orders *\/\n\n    if (dst_cpu->env.sigp_order != 0 &&\n\n        order != SIGP_CPU_RESET &&\n\n        order != SIGP_INITIAL_CPU_RESET) {\n\n        return SIGP_CC_BUSY;\n\n    }\n\n\n\n    switch (order) {\n\n    case SIGP_START:\n\n        run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_STOP:\n\n        run_on_cpu(CPU(dst_cpu), sigp_stop, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_RESTART:\n\n        run_on_cpu(CPU(dst_cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_STOP_STORE_STATUS:\n\n        run_on_cpu(CPU(dst_cpu), sigp_stop_and_store_status, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_STORE_STATUS_ADDR:\n\n        run_on_cpu(CPU(dst_cpu), sigp_store_status_at_address, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_STORE_ADTL_STATUS:\n\n        run_on_cpu(CPU(dst_cpu), sigp_store_adtl_status, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_SET_PREFIX:\n\n        run_on_cpu(CPU(dst_cpu), sigp_set_prefix, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_INITIAL_CPU_RESET:\n\n        run_on_cpu(CPU(dst_cpu), sigp_initial_cpu_reset, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    case SIGP_CPU_RESET:\n\n        run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si));\n\n        break;\n\n    default:\n\n        set_sigp_status(&si, SIGP_STAT_INVALID_ORDER);\n\n    }\n\n\n\n    return si.cc;\n\n}\n","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":319448,"func":"void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,\n\n                               int64_t bps_wr,\n\n                               int64_t iops,\n\n                               int64_t iops_rd,\n\n                               int64_t iops_wr,\n\n                               bool has_bps_max,\n\n                               int64_t bps_max,\n\n                               bool has_bps_rd_max,\n\n                               int64_t bps_rd_max,\n\n                               bool has_bps_wr_max,\n\n                               int64_t bps_wr_max,\n\n                               bool has_iops_max,\n\n                               int64_t iops_max,\n\n                               bool has_iops_rd_max,\n\n                               int64_t iops_rd_max,\n\n                               bool has_iops_wr_max,\n\n                               int64_t iops_wr_max,\n\n                               bool has_iops_size,\n\n                               int64_t iops_size, Error **errp)\n\n{\n\n    ThrottleConfig cfg;\n\n    BlockDriverState *bs;\n\n\n\n\n    bs = bdrv_find(device);\n\n    if (!bs) {\n\n        error_set(errp, QERR_DEVICE_NOT_FOUND, device);\n\n        return;\n\n    }\n\n\n\n    memset(&cfg, 0, sizeof(cfg));\n\n    cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;\n\n    cfg.buckets[THROTTLE_BPS_READ].avg  = bps_rd;\n\n    cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;\n\n\n\n    cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;\n\n    cfg.buckets[THROTTLE_OPS_READ].avg  = iops_rd;\n\n    cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;\n\n\n\n    if (has_bps_max) {\n\n        cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;\n\n    }\n\n    if (has_bps_rd_max) {\n\n        cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;\n\n    }\n\n    if (has_bps_wr_max) {\n\n        cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;\n\n    }\n\n    if (has_iops_max) {\n\n        cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;\n\n    }\n\n    if (has_iops_rd_max) {\n\n        cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;\n\n    }\n\n    if (has_iops_wr_max) {\n\n        cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;\n\n    }\n\n\n\n    if (has_iops_size) {\n\n        cfg.op_size = iops_size;\n\n    }\n\n\n\n    if (!check_throttle_config(&cfg, errp)) {\n\n        return;\n\n    }\n\n\n\n    aio_context = bdrv_get_aio_context(bs);\n\n    aio_context_acquire(aio_context);\n\n\n\n    if (!bs->io_limits_enabled && throttle_enabled(&cfg)) {\n\n        bdrv_io_limits_enable(bs);\n\n    } else if (bs->io_limits_enabled && !throttle_enabled(&cfg)) {\n\n        bdrv_io_limits_disable(bs);\n\n    }\n\n\n\n    if (bs->io_limits_enabled) {\n\n        bdrv_set_io_limits(bs, &cfg);\n\n    }\n\n\n\n    aio_context_release(aio_context);\n\n}","target":1,"code_token_length":691,"total_token_length":927,"max_tokens_setting":1024}
+{"idx":262898,"func":"getroom(\n    spellinfo_T *spin,\n    size_t\tlen,\t\t\/* length needed *\/\n    int\t\talign)\t\t\/* align for pointer *\/\n{\n    char_u\t*p;\n    sblock_T\t*bl = spin->si_blocks;\n\n    if (align && bl != NULL)\n\t\/* Round size up for alignment.  On some systems structures need to be\n\t * aligned to the size of a pointer (e.g., SPARC). *\/\n\tbl->sb_used = (bl->sb_used + sizeof(char *) - 1)\n\t\t\t\t\t\t      & ~(sizeof(char *) - 1);\n\n    if (bl == NULL || bl->sb_used + len > SBLOCKSIZE)\n    {\n\tif (len >= SBLOCKSIZE)\n\t    bl = NULL;\n\telse\n\t    \/* Allocate a block of memory. It is not freed until much later. *\/\n\t    bl = (sblock_T *)alloc_clear(\n\t\t\t\t   (unsigned)(sizeof(sblock_T) + SBLOCKSIZE));\n\tif (bl == NULL)\n\t{\n\t    if (!spin->si_did_emsg)\n\t    {\n\t\tEMSG(_(\"E845: Insufficient memory, word list will be incomplete\"));\n\t\tspin->si_did_emsg = TRUE;\n\t    }\n\t    return NULL;\n\t}\n\tbl->sb_next = spin->si_blocks;\n\tspin->si_blocks = bl;\n\tbl->sb_used = 0;\n\t++spin->si_blocks_cnt;\n    }\n\n    p = bl->sb_data + bl->sb_used;\n    bl->sb_used += (int)len;\n\n    return p;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":231953,"func":"std::string ChromeContentRendererClient::GetNavigationErrorHtml(\n    const WebURLRequest& failed_request,\n    const WebURLError& error) {\n  GURL failed_url = error.unreachableURL;\n  std::string html;\n  const Extension* extension = NULL;\n\n  int resource_id;\n  DictionaryValue error_strings;\n  if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme))\n    extension = extension_dispatcher_->extensions()->GetByURL(failed_url);\n  if (extension) {\n    LocalizedError::GetAppErrorStrings(error, failed_url, extension,\n                                       &error_strings);\n\n    resource_id = IDR_ERROR_APP_HTML;\n  } else {\n    if (error.domain == WebString::fromUTF8(net::kErrorDomain) &&\n        error.reason == net::ERR_CACHE_MISS &&\n        EqualsASCII(failed_request.httpMethod(), \"POST\")) {\n      LocalizedError::GetFormRepostStrings(failed_url, &error_strings);\n    } else {\n      LocalizedError::GetStrings(error, &error_strings);\n    }\n    resource_id = IDR_NET_ERROR_HTML;\n  }\n\n  const base::StringPiece template_html(\n      ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));\n  if (template_html.empty()) {\n    NOTREACHED() << \"unable to load template. ID: \" << resource_id;\n  } else {\n    html = jstemplate_builder::GetTemplatesHtml(\n        template_html, &error_strings, \"t\");\n  }\n\n  return html;\n}\n","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":836,"func":"static void _LMBCSToUnicodeWithOffsets ( UConverterToUnicodeArgs * args , UErrorCode * err ) {\n char LMBCS [ ULMBCS_CHARSIZE_MAX ] ;\n UChar uniChar ;\n const char * saveSource ;\n const char * pStartLMBCS = args -> source ;\n const char * errSource = NULL ;\n int8_t savebytes = 0 ;\n while ( U_SUCCESS ( * err ) && args -> sourceLimit > args -> source && args -> targetLimit > args -> target ) {\n saveSource = args -> source ;\n if ( args -> converter -> toULength ) {\n const char * saveSourceLimit ;\n size_t size_old = args -> converter -> toULength ;\n size_t size_new_maybe_1 = sizeof ( LMBCS ) - size_old ;\n size_t size_new_maybe_2 = args -> sourceLimit - args -> source ;\n size_t size_new = ( size_new_maybe_1 < size_new_maybe_2 ) ? size_new_maybe_1 : size_new_maybe_2 ;\n uprv_memcpy ( LMBCS , args -> converter -> toUBytes , size_old ) ;\n uprv_memcpy ( LMBCS + size_old , args -> source , size_new ) ;\n saveSourceLimit = args -> sourceLimit ;\n args -> source = errSource = LMBCS ;\n args -> sourceLimit = LMBCS + size_old + size_new ;\n savebytes = ( int8_t ) ( size_old + size_new ) ;\n uniChar = ( UChar ) _LMBCSGetNextUCharWorker ( args , err ) ;\n args -> source = saveSource + ( ( args -> source - LMBCS ) - size_old ) ;\n args -> sourceLimit = saveSourceLimit ;\n if ( * err == U_TRUNCATED_CHAR_FOUND ) {\n args -> converter -> toULength = savebytes ;\n uprv_memcpy ( args -> converter -> toUBytes , LMBCS , savebytes ) ;\n args -> source = args -> sourceLimit ;\n * err = U_ZERO_ERROR ;\n return ;\n }\n else {\n args -> converter -> toULength = 0 ;\n }\n }\n else {\n errSource = saveSource ;\n uniChar = ( UChar ) _LMBCSGetNextUCharWorker ( args , err ) ;\n savebytes = ( int8_t ) ( args -> source - saveSource ) ;\n }\n if ( U_SUCCESS ( * err ) ) {\n if ( uniChar < 0xfffe ) {\n * ( args -> target ) ++ = uniChar ;\n if ( args -> offsets ) {\n * ( args -> offsets ) ++ = ( int32_t ) ( saveSource - pStartLMBCS ) ;\n }\n }\n else if ( uniChar == 0xfffe ) {\n * err = U_INVALID_CHAR_FOUND ;\n }\n else {\n * err = U_ILLEGAL_CHAR_FOUND ;\n }\n }\n }\n if ( U_SUCCESS ( * err ) && args -> sourceLimit > args -> source && args -> targetLimit <= args -> target ) {\n * err = U_BUFFER_OVERFLOW_ERROR ;\n }\n else if ( U_FAILURE ( * err ) ) {\n args -> converter -> toULength = savebytes ;\n if ( savebytes > 0 ) {\n uprv_memcpy ( args -> converter -> toUBytes , errSource , savebytes ) ;\n }\n if ( * err == U_TRUNCATED_CHAR_FOUND ) {\n * err = U_ZERO_ERROR ;\n }\n }\n }","target":1,"code_token_length":697,"total_token_length":933,"max_tokens_setting":1024}
+{"idx":408896,"func":"page_objects_sort(fz_context *ctx, page_objects *po)\n{\n\tint i, j;\n\tint n = po->len;\n\n\t\/* Step 1: Make a heap *\/\n\t\/* Invariant: Valid heap in [0..i), unsorted elements in [i..n) *\/\n\tfor (i = 1; i < n; i++)\n\t{\n\t\t\/* Now bubble backwards to maintain heap invariant *\/\n\t\tj = i;\n\t\twhile (j != 0)\n\t\t{\n\t\t\tint tmp;\n\t\t\tint k = (j-1)>>1;\n\t\t\tif (po->object[k] >= po->object[j])\n\t\t\t\tbreak;\n\t\t\ttmp = po->object[k];\n\t\t\tpo->object[k] = po->object[j];\n\t\t\tpo->object[j] = tmp;\n\t\t\tj = k;\n\t\t}\n\t}\n\n\t\/* Step 2: Heap sort *\/\n\t\/* Invariant: valid heap in [0..i), sorted list in [i..n) *\/\n\t\/* Initially: i = n *\/\n\tfor (i = n-1; i > 0; i--)\n\t{\n\t\t\/* Swap the maximum (0th) element from the page_objects into its place\n\t\t * in the sorted list (position i). *\/\n\t\tint tmp = po->object[0];\n\t\tpo->object[0] = po->object[i];\n\t\tpo->object[i] = tmp;\n\t\t\/* Now, the page_objects is invalid because the 0th element is out\n\t\t * of place. Bubble it until the page_objects is valid. *\/\n\t\tj = 0;\n\t\twhile (1)\n\t\t{\n\t\t\t\/* Children are k and k+1 *\/\n\t\t\tint k = (j+1)*2-1;\n\t\t\t\/* If both children out of the page_objects, we're done *\/\n\t\t\tif (k > i-1)\n\t\t\t\tbreak;\n\t\t\t\/* If both are in the page_objects, pick the larger one *\/\n\t\t\tif (k < i-1 && po->object[k] < po->object[k+1])\n\t\t\t\tk++;\n\t\t\t\/* If j is bigger than k (i.e. both of its children),\n\t\t\t * we're done *\/\n\t\t\tif (po->object[j] > po->object[k])\n\t\t\t\tbreak;\n\t\t\ttmp = po->object[k];\n\t\t\tpo->object[k] = po->object[j];\n\t\t\tpo->object[j] = tmp;\n\t\t\tj = k;\n\t\t}\n\t}\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":168474,"func":"g_verify_token_header(gss_OID_const mech,\n\t\t    unsigned int *body_size,\n\t\t    unsigned char **buf_in,\n\t\t    int tok_type,\n\t\t    unsigned int toksize)\n{\n\tunsigned char *buf = *buf_in;\n\tint seqsize;\n\tgss_OID_desc toid;\n\tint ret = 0;\n\tunsigned int bytes;\n\n\tif (toksize-- < 1)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\tif (*buf++ != HEADER_ID)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\tif ((seqsize = gssint_get_der_length(&buf, toksize, &bytes)) < 0)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\tif ((seqsize + bytes) != toksize)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\tif (toksize-- < 1)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\n\tif (*buf++ != MECH_OID)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\tif (toksize-- < 1)\n\t\treturn (G_BAD_TOK_HEADER);\n\n\ttoid.length = *buf++;\n\n\tif (toksize < toid.length)\n\t\treturn (G_BAD_TOK_HEADER);\n\telse\n\t\ttoksize -= toid.length;\n\n\ttoid.elements = buf;\n\tbuf += toid.length;\n\n\tif (!g_OID_equal(&toid, mech))\n\t\tret = G_WRONG_MECH;\n\n\t\/*\n\t * G_WRONG_MECH is not returned immediately because it's more important\n\t * to return G_BAD_TOK_HEADER if the token header is in fact bad\n\t *\/\n\tif (toksize < 2)\n\t\treturn (G_BAD_TOK_HEADER);\n\telse\n\t\ttoksize -= 2;\n\n\tif (!ret) {\n\t\t*buf_in = buf;\n\t\t*body_size = toksize;\n\t}\n\n\treturn (ret);\n}\n","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":216848,"func":"static bool verify_vbr_checksum(struct exfat_dev* dev, void* sector,\n\t\toff_t sector_size)\n{\n\tuint32_t vbr_checksum;\n\tint i;\n\n\tif (exfat_pread(dev, sector, sector_size, 0) < 0)\n\t{\n\t\texfat_error(\"failed to read boot sector\");\n\t\treturn false;\n\t}\n\tvbr_checksum = exfat_vbr_start_checksum(sector, sector_size);\n\tfor (i = 1; i < 11; i++)\n\t{\n\t\tif (exfat_pread(dev, sector, sector_size, i * sector_size) < 0)\n\t\t{\n\t\t\texfat_error(\"failed to read VBR sector\");\n\t\t\treturn false;\n\t\t}\n\t\tvbr_checksum = exfat_vbr_add_checksum(sector, sector_size,\n\t\t\t\tvbr_checksum);\n\t}\n\tif (exfat_pread(dev, sector, sector_size, i * sector_size) < 0)\n\t{\n\t\texfat_error(\"failed to read VBR checksum sector\");\n\t\treturn false;\n\t}\n\tfor (i = 0; i < sector_size \/ sizeof(vbr_checksum); i++)\n\t\tif (le32_to_cpu(((const le32_t*) sector)[i]) != vbr_checksum)\n\t\t{\n\t\t\texfat_error(\"invalid VBR checksum 0x%x (expected 0x%x)\",\n\t\t\t\t\tle32_to_cpu(((const le32_t*) sector)[i]), vbr_checksum);\n\t\t\treturn false;\n\t\t}\n\treturn true;\n}\n","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":260192,"func":"void RemoteDevicePropertiesWidget::update(const RemoteFsDevice::Details &d, bool create, bool isConnected)\n{\n    int t=d.isLocalFile() ? Type_File : Type_SshFs;\n    setEnabled(d.isLocalFile() || !isConnected);\n    infoLabel->setVisible(create);\n    orig=d;\n    name->setText(d.name);\n    sshPort->setValue(22);\n\n    connectionNote->setVisible(!d.isLocalFile() && isConnected);\n    sshFolder->setText(QString());\n    sshHost->setText(QString());\n    sshUser->setText(QString());\n    fileFolder->setText(QString());\n\n    switch (t) {\n    case Type_SshFs: {\n        sshFolder->setText(d.url.path());\n        if (0!=d.url.port()) {\n            sshPort->setValue(d.url.port());\n        }\n        sshHost->setText(d.url.host());\n        sshUser->setText(d.url.userName());\n        sshExtra->setText(d.extraOptions);\n        break;\n    }\n    case Type_File:\n        fileFolder->setText(d.url.path());\n        break;\n    }\n\n    name->setEnabled(d.isLocalFile() || !isConnected);\n\n    connect(type, SIGNAL(currentIndexChanged(int)), this, SLOT(setType()));\n    for (int i=1; i<type->count(); ++i) {\n        if (type->itemData(i).toInt()==t) {\n            type->setCurrentIndex(i);\n            stackedWidget->setCurrentIndex(i);\n            break;\n        }\n    }\n    connect(name, SIGNAL(textChanged(const QString &)), this, SLOT(checkSaveable()));\n    connect(sshHost, SIGNAL(textChanged(const QString &)), this, SLOT(checkSaveable()));\n    connect(sshUser, SIGNAL(textChanged(const QString &)), this, SLOT(checkSaveable()));\n    connect(sshFolder, SIGNAL(textChanged(const QString &)), this, SLOT(checkSaveable()));\n    connect(sshPort, SIGNAL(valueChanged(int)), this, SLOT(checkSaveable()));\n    connect(sshExtra, SIGNAL(textChanged(const QString &)), this, SLOT(checkSaveable()));\n    connect(fileFolder, SIGNAL(textChanged(const QString &)), this, SLOT(checkSaveable()));\n    modified=false;\n    setType();\n    checkSaveable();\n}","target":0,"code_token_length":448,"total_token_length":684,"max_tokens_setting":1024}
+{"idx":52082,"func":"static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl,\n                                         unsigned char *buf,\n                                         size_t len )\n{\n    int ret;\n    mbedtls_ssl_session session;\n\n    mbedtls_ssl_session_init( &session );\n\n    if( ssl->conf->f_ticket_parse == NULL ||\n        ssl->conf->f_ticket_write == NULL )\n    {\n        return( 0 );\n    }\n\n    \/* Remember the client asked us to send a new ticket *\/\n    ssl->handshake->new_session_ticket = 1;\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ticket length: %d\", len ) );\n\n    if( len == 0 )\n        return( 0 );\n\n#if defined(MBEDTLS_SSL_RENEGOTIATION)\n    if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ticket rejected: renegotiating\" ) );\n        return( 0 );\n    }\n#endif \/* MBEDTLS_SSL_RENEGOTIATION *\/\n\n    \/*\n     * Failures are ok: just ignore the ticket and proceed.\n     *\/\n    if( ( ret = ssl->conf->f_ticket_parse( ssl->conf->p_ticket, &session,\n                                           buf, len ) ) != 0 )\n    {\n        mbedtls_ssl_session_free( &session );\n\n        if( ret == MBEDTLS_ERR_SSL_INVALID_MAC )\n            MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ticket is not authentic\" ) );\n        else if( ret == MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED )\n            MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ticket is expired\" ) );\n        else\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_ticket_parse\", ret );\n\n        return( 0 );\n    }\n\n    \/*\n     * Keep the session ID sent by the client, since we MUST send it back to\n     * inform them we're accepting the ticket  (RFC 5077 section 3.4)\n     *\/\n    session.id_len = ssl->session_negotiate->id_len;\n    memcpy( &session.id, ssl->session_negotiate->id, session.id_len );\n\n    mbedtls_ssl_session_free( ssl->session_negotiate );\n    memcpy( ssl->session_negotiate, &session, sizeof( mbedtls_ssl_session ) );\n\n    \/* Zeroize instead of free as we copied the content *\/\n    mbedtls_zeroize( &session, sizeof( mbedtls_ssl_session ) );\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"session successfully restored from ticket\" ) );\n\n    ssl->handshake->resume = 1;\n\n    \/* Don't send a new ticket after all, this one is OK *\/\n    ssl->handshake->new_session_ticket = 0;\n\n    return( 0 );\n}","target":0,"code_token_length":587,"total_token_length":823,"max_tokens_setting":1024}
+{"idx":82640,"func":"and_code_range_buf(BBuf* bbuf1, int not1, BBuf* bbuf2, int not2, BBuf** pbuf)\n{\n  int r;\n  OnigCodePoint i, j, n1, n2, *data1, *data2;\n  OnigCodePoint from, to, from1, to1, from2, to2;\n\n  *pbuf = (BBuf* )NULL;\n  if (IS_NULL(bbuf1)) {\n    if (not1 != 0 && IS_NOT_NULL(bbuf2)) \/* not1 != 0 -> not2 == 0 *\/\n      return bbuf_clone(pbuf, bbuf2);\n    return 0;\n  }\n  else if (IS_NULL(bbuf2)) {\n    if (not2 != 0)\n      return bbuf_clone(pbuf, bbuf1);\n    return 0;\n  }\n\n  if (not1 != 0)\n    SWAP_BB_NOT(bbuf1, not1, bbuf2, not2);\n\n  data1 = (OnigCodePoint* )(bbuf1->p);\n  data2 = (OnigCodePoint* )(bbuf2->p);\n  GET_CODE_POINT(n1, data1);\n  GET_CODE_POINT(n2, data2);\n  data1++;\n  data2++;\n\n  if (not2 == 0 && not1 == 0) { \/* 1 AND 2 *\/\n    for (i = 0; i < n1; i++) {\n      from1 = data1[i*2];\n      to1   = data1[i*2+1];\n      for (j = 0; j < n2; j++) {\n        from2 = data2[j*2];\n        to2   = data2[j*2+1];\n        if (from2 > to1) break;\n        if (to2 < from1) continue;\n        from = MAX(from1, from2);\n        to   = MIN(to1, to2);\n        r = add_code_range_to_buf(pbuf, from, to);\n        if (r != 0) return r;\n      }\n    }\n  }\n  else if (not1 == 0) { \/* 1 AND (not 2) *\/\n    for (i = 0; i < n1; i++) {\n      from1 = data1[i*2];\n      to1   = data1[i*2+1];\n      r = and_code_range1(pbuf, from1, to1, data2, n2);\n      if (r != 0) return r;\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":218225,"func":"size_t mptsas_config_sas_io_unit_1(MPTSASState *s, uint8_t **data, int address)\n{\n    size_t size = MPTSAS_CONFIG_PACK_EXT(1, MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT, 0x07,\n                                         \"*w*w*w*wb*b*b*b\"\n                                         repl(MPTSAS_NUM_PORTS, \"*s12\"),\n                                         MPTSAS_NUM_PORTS);\n\n    if (data) {\n        size_t ofs = size - MPTSAS_NUM_PORTS * MPTSAS_CONFIG_SAS_IO_UNIT_1_SIZE;\n        int i;\n\n        for (i = 0; i < MPTSAS_NUM_PORTS; i++) {\n            SCSIDevice *dev = mptsas_phy_get_device(s, i, NULL, NULL);\n            fill(*data + ofs, MPTSAS_CONFIG_SAS_IO_UNIT_1_SIZE,\n                 \"bbbblww\", i, 0, 0,\n                 (MPI_SAS_IOUNIT0_RATE_3_0 << 4) | MPI_SAS_IOUNIT0_RATE_1_5,\n                 (dev\n                  ? MPI_SAS_DEVICE_INFO_END_DEVICE | MPI_SAS_DEVICE_INFO_SSP_TARGET\n                  : MPI_SAS_DEVICE_INFO_NO_DEVICE),\n                 0, 0);\n            ofs += MPTSAS_CONFIG_SAS_IO_UNIT_1_SIZE;\n        }\n        assert(ofs == size);\n    }\n    return size;\n}\n","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":335801,"func":"static void vhost_dev_sync_region(struct vhost_dev *dev,\n\n                                  uint64_t mfirst, uint64_t mlast,\n\n                                  uint64_t rfirst, uint64_t rlast)\n\n{\n\n    uint64_t start = MAX(mfirst, rfirst);\n\n    uint64_t end = MIN(mlast, rlast);\n\n    vhost_log_chunk_t *from = dev->log + start \/ VHOST_LOG_CHUNK;\n\n    vhost_log_chunk_t *to = dev->log + end \/ VHOST_LOG_CHUNK + 1;\n\n    uint64_t addr = (start \/ VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;\n\n\n\n    assert(end \/ VHOST_LOG_CHUNK < dev->log_size);\n\n    assert(start \/ VHOST_LOG_CHUNK < dev->log_size);\n\n    if (end < start) {\n\n        return;\n\n    }\n\n    for (;from < to; ++from) {\n\n        vhost_log_chunk_t log;\n\n        int bit;\n\n        \/* We first check with non-atomic: much cheaper,\n\n         * and we expect non-dirty to be the common case. *\/\n\n        if (!*from) {\n\n            addr += VHOST_LOG_CHUNK;\n\n            continue;\n\n        }\n\n        \/* Data must be read atomically. We don't really\n\n         * need the barrier semantics of __sync\n\n         * builtins, but it's easier to use them than\n\n         * roll our own. *\/\n\n        log = __sync_fetch_and_and(from, 0);\n\n        while ((bit = sizeof(log) > sizeof(int) ?\n\n                ffsll(log) : ffs(log))) {\n\n            bit -= 1;\n\n            cpu_physical_memory_set_dirty(addr + bit * VHOST_LOG_PAGE);\n\n            log &= ~(0x1ull << bit);\n\n        }\n\n        addr += VHOST_LOG_CHUNK;\n\n    }\n\n}\n","target":1,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":466323,"func":"TEST_P(DownstreamProtocolIntegrationTest, TestEncodeHeadersReturnsStopAllWatermark) {\n  \/\/ Metadata is not supported in QUICHE.\n  EXCLUDE_DOWNSTREAM_HTTP3\n  config_helper_.addFilter(R\"EOF(\nname: encode-headers-return-stop-all-filter\n)EOF\");\n  config_helper_.addConfigModifier(\n      [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&\n              hcm) -> void { hcm.mutable_http2_protocol_options()->set_allow_metadata(true); });\n\n  \/\/ Sets initial stream window to min value to make the upstream sensitive to a low watermark.\n  config_helper_.addConfigModifier(\n      [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&\n              hcm) -> void {\n        hcm.mutable_http2_protocol_options()->mutable_initial_stream_window_size()->set_value(\n            ::Envoy::Http2::Utility::OptionsLimits::MIN_INITIAL_STREAM_WINDOW_SIZE);\n      });\n\n  initialize();\n  codec_client_ = makeHttpConnection(lookupPort(\"http\"));\n\n  \/\/ Upstream responds with headers, data and trailers.\n  auto response = codec_client_->makeRequestWithBody(default_request_headers_, 10);\n  waitForNextUpstreamRequest();\n\n  changeHeadersForStopAllTests(default_response_headers_, true);\n  upstream_request_->encodeHeaders(default_response_headers_, false);\n  for (int i = 0; i < count_ - 1; i++) {\n    upstream_request_->encodeData(size_, false);\n  }\n  \/\/ Gives buffer 1s to react to buffer limit.\n  absl::SleepFor(absl::Seconds(1));\n  upstream_request_->encodeData(size_, false);\n  Http::TestResponseTrailerMapImpl response_trailers{{\"response\", \"trailer\"}};\n  upstream_request_->encodeTrailers(response_trailers);\n\n  ASSERT_TRUE(response->waitForEndStream());\n  ASSERT_TRUE(response->complete());\n  \/\/ Data is added in encodeData for all protocols, and encodeTrailers for HTTP\/2 and above.\n  int times_added = (upstreamProtocol() == FakeHttpConnection::Type::HTTP1 ||\n                     downstreamProtocol() == Http::CodecClient::Type::HTTP1)\n                        ? 1\n                        : 2;\n  if (downstreamProtocol() == Http::CodecClient::Type::HTTP1 &&\n      upstreamProtocol() == FakeHttpConnection::Type::HTTP3) {\n    \/\/ TODO(alyssawilk) Figure out why the bytes mismatch with the test expectation below.\n    return;\n  }\n  EXPECT_EQ(count_ * size_ + added_decoded_data_size_ * times_added, response->body().size());\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":299664,"func":"static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)\n{\n\tstruct btrfs_fs_info *fs_info = trans->fs_info;\n\tstruct list_head *dirty_bgs = &trans->transaction->dirty_bgs;\n\tstruct list_head *io_bgs = &trans->transaction->io_bgs;\n\tstruct list_head *next;\n\tstruct extent_buffer *eb;\n\tint ret;\n\n\teb = btrfs_lock_root_node(fs_info->tree_root);\n\tret = btrfs_cow_block(trans, fs_info->tree_root, eb, NULL,\n\t\t\t      0, &eb, BTRFS_NESTING_COW);\n\tbtrfs_tree_unlock(eb);\n\tfree_extent_buffer(eb);\n\n\tif (ret)\n\t\treturn ret;\n\n\tret = btrfs_run_dev_stats(trans);\n\tif (ret)\n\t\treturn ret;\n\tret = btrfs_run_dev_replace(trans);\n\tif (ret)\n\t\treturn ret;\n\tret = btrfs_run_qgroups(trans);\n\tif (ret)\n\t\treturn ret;\n\n\tret = btrfs_setup_space_cache(trans);\n\tif (ret)\n\t\treturn ret;\n\nagain:\n\twhile (!list_empty(&fs_info->dirty_cowonly_roots)) {\n\t\tstruct btrfs_root *root;\n\t\tnext = fs_info->dirty_cowonly_roots.next;\n\t\tlist_del_init(next);\n\t\troot = list_entry(next, struct btrfs_root, dirty_list);\n\t\tclear_bit(BTRFS_ROOT_DIRTY, &root->state);\n\n\t\tif (root != fs_info->extent_root)\n\t\t\tlist_add_tail(&root->dirty_list,\n\t\t\t\t      &trans->transaction->switch_commits);\n\t\tret = update_cowonly_root(trans, root);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\t\/* Now flush any delayed refs generated by updating all of the roots *\/\n\tret = btrfs_run_delayed_refs(trans, (unsigned long)-1);\n\tif (ret)\n\t\treturn ret;\n\n\twhile (!list_empty(dirty_bgs) || !list_empty(io_bgs)) {\n\t\tret = btrfs_write_dirty_block_groups(trans);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/*\n\t\t * We're writing the dirty block groups, which could generate\n\t\t * delayed refs, which could generate more dirty block groups,\n\t\t * so we want to keep this flushing in this loop to make sure\n\t\t * everything gets run.\n\t\t *\/\n\t\tret = btrfs_run_delayed_refs(trans, (unsigned long)-1);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tif (!list_empty(&fs_info->dirty_cowonly_roots))\n\t\tgoto again;\n\n\tlist_add_tail(&fs_info->extent_root->dirty_list,\n\t\t      &trans->transaction->switch_commits);\n\n\t\/* Update dev-replace pointer once everything is committed *\/\n\tfs_info->dev_replace.committed_cursor_left =\n\t\tfs_info->dev_replace.cursor_left_last_write_of_item;\n\n\treturn 0;\n}","target":0,"code_token_length":591,"total_token_length":827,"max_tokens_setting":1024}
+{"idx":424108,"func":"static int bus_append_unit_property(sd_bus_message *m, const char *field, const char *eq) {\n        ConditionType t = _CONDITION_TYPE_INVALID;\n        bool is_condition = false;\n        int r;\n\n        if (STR_IN_SET(field,\n                       \"Description\", \"SourcePath\", \"OnFailureJobMode\",\n                       \"JobTimeoutAction\", \"JobTimeoutRebootArgument\",\n                       \"StartLimitAction\", \"FailureAction\", \"SuccessAction\",\n                       \"RebootArgument\", \"CollectMode\"))\n\n                return bus_append_string(m, field, eq);\n\n        if (STR_IN_SET(field,\n                       \"StopWhenUnneeded\", \"RefuseManualStart\", \"RefuseManualStop\",\n                       \"AllowIsolate\", \"IgnoreOnIsolate\", \"DefaultDependencies\"))\n\n                return bus_append_parse_boolean(m, field, eq);\n\n        if (STR_IN_SET(field, \"JobTimeoutSec\", \"JobRunningTimeoutSec\", \"StartLimitIntervalSec\"))\n\n                return bus_append_parse_sec_rename(m, field, eq);\n\n        if (streq(field, \"StartLimitBurst\"))\n\n                return bus_append_safe_atou(m, field, eq);\n\n        if (STR_IN_SET(field, \"SuccessActionExitStatus\", \"FailureActionExitStatus\")) {\n\n                if (isempty(eq))\n                        r = sd_bus_message_append(m, \"(sv)\", field, \"i\", -1);\n                else {\n                        uint8_t u;\n\n                        r = safe_atou8(eq, &u);\n                        if (r < 0)\n                                return log_error_errno(r, \"Failed to parse %s=%s\", field, eq);\n\n                        r = sd_bus_message_append(m, \"(sv)\", field, \"i\", (int) u);\n                }\n                if (r < 0)\n                        return bus_log_create_error(r);\n\n                return 1;\n        }\n\n        if (unit_dependency_from_string(field) >= 0 ||\n            STR_IN_SET(field, \"Documentation\", \"RequiresMountsFor\"))\n\n                return bus_append_strv(m, field, eq, EXTRACT_QUOTES);\n\n        t = condition_type_from_string(field);\n        if (t >= 0)\n                is_condition = true;\n        else\n                t = assert_type_from_string(field);\n        if (t >= 0) {\n                if (isempty(eq))\n                        r = sd_bus_message_append(m, \"(sv)\", is_condition ? \"Conditions\" : \"Asserts\", \"a(sbbs)\", 0);\n                else {\n                        const char *p = eq;\n                        int trigger, negate;\n\n                        trigger = *p == '|';\n                        if (trigger)\n                                p++;\n\n                        negate = *p == '!';\n                        if (negate)\n                                p++;\n\n                        r = sd_bus_message_append(m, \"(sv)\", is_condition ? \"Conditions\" : \"Asserts\", \"a(sbbs)\", 1,\n                                                  field, trigger, negate, p);\n                }\n                if (r < 0)\n                        return bus_log_create_error(r);\n\n                return 1;\n        }\n\n        return 0;\n}","target":0,"code_token_length":622,"total_token_length":858,"max_tokens_setting":1024}
+{"idx":184262,"func":"bool omx_video::execute_flush_all(void)\n{\n unsigned long p1 = 0; \/\/ Parameter - 1\n unsigned long p2 = 0; \/\/ Parameter - 2\n unsigned long ident = 0;\n bool bRet = true;\n\n    DEBUG_PRINT_LOW(\"execute_flush_all\");\n\n \/*Generate EBD for all Buffers in the ETBq*\/\n    pthread_mutex_lock(&m_lock);\n while (m_etb_q.m_size) {\n        m_etb_q.pop_entry(&p1,&p2,&ident);\n if (ident == OMX_COMPONENT_GENERATE_ETB) {\n            pending_input_buffers++;\n            empty_buffer_done(&m_cmp,(OMX_BUFFERHEADERTYPE *)p2);\n } else if (ident == OMX_COMPONENT_GENERATE_EBD) {\n            empty_buffer_done(&m_cmp,(OMX_BUFFERHEADERTYPE *)p1);\n } else if(ident == OMX_COMPONENT_GENERATE_ETB_OPQ) {\n            m_pCallbacks.EmptyBufferDone(&m_cmp,m_app_data,(OMX_BUFFERHEADERTYPE *)p2);\n }\n }\n if(mUseProxyColorFormat) {\n if(psource_frame) {\n            m_pCallbacks.EmptyBufferDone(&m_cmp,m_app_data,psource_frame);\n            psource_frame = NULL;\n }\n while(m_opq_meta_q.m_size) {\n unsigned long p1,p2,id;\n            m_opq_meta_q.pop_entry(&p1,&p2,&id);\n            m_pCallbacks.EmptyBufferDone(&m_cmp,m_app_data,\n (OMX_BUFFERHEADERTYPE  *)p1);\n }\n if(pdest_frame){\n            m_opq_pmem_q.insert_entry((unsigned long)pdest_frame,0,0);\n            pdest_frame = NULL;\n }\n }\n\n \/*Generate FBD for all Buffers in the FTBq*\/\n    DEBUG_PRINT_LOW(\"execute_output_flush\");\n while (m_ftb_q.m_size) {\n        m_ftb_q.pop_entry(&p1,&p2,&ident);\n\n if (ident == OMX_COMPONENT_GENERATE_FTB ) {\n            pending_output_buffers++;\n            fill_buffer_done(&m_cmp,(OMX_BUFFERHEADERTYPE *)p2);\n } else if (ident == OMX_COMPONENT_GENERATE_FBD) {\n            fill_buffer_done(&m_cmp,(OMX_BUFFERHEADERTYPE *)p1);\n }\n }\n\n    pthread_mutex_unlock(&m_lock);\n\n \/*Check if there are buffers with the Driver*\/\n if (dev_flush(PORT_INDEX_BOTH)) {\n        DEBUG_PRINT_ERROR(\"ERROR: dev_flush() Failed\");\n return false;\n }\n return bRet;\n}\n","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":94238,"func":"static int watchdog_nmi_enable(int cpu)\n{\n\tstruct perf_event_attr *wd_attr;\n\tstruct perf_event *event = per_cpu(watchdog_ev, cpu);\n\n\t\/* is it already setup and enabled? *\/\n\tif (event && event->state > PERF_EVENT_STATE_OFF)\n\t\tgoto out;\n\n\t\/* it is setup but not enabled *\/\n\tif (event != NULL)\n\t\tgoto out_enable;\n\n\twd_attr = &wd_hw_attr;\n\twd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);\n\thw_nmi_watchdog_set_attr(wd_attr);\n\n\t\/* Try to register using hardware perf events *\/\n\tevent = perf_event_create_kernel_counter(wd_attr, cpu, NULL, watchdog_overflow_callback);\n\tif (!IS_ERR(event)) {\n\t\tprintk(KERN_INFO \"NMI watchdog enabled, takes one hw-pmu counter.\\n\");\n\t\tgoto out_save;\n\t}\n\n\n\t\/* vary the KERN level based on the returned errno *\/\n\tif (PTR_ERR(event) == -EOPNOTSUPP)\n\t\tprintk(KERN_INFO \"NMI watchdog disabled (cpu%i): not supported (no LAPIC?)\\n\", cpu);\n\telse if (PTR_ERR(event) == -ENOENT)\n\t\tprintk(KERN_WARNING \"NMI watchdog disabled (cpu%i): hardware events not enabled\\n\", cpu);\n\telse\n\t\tprintk(KERN_ERR \"NMI watchdog disabled (cpu%i): unable to create perf event: %ld\\n\", cpu, PTR_ERR(event));\n\treturn PTR_ERR(event);\n\n\t\/* success path *\/\nout_save:\n\tper_cpu(watchdog_ev, cpu) = event;\nout_enable:\n\tperf_event_enable(per_cpu(watchdog_ev, cpu));\nout:\n\treturn 0;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":152161,"func":"archive_read_format_iso9660_bid(struct archive_read *a, int best_bid)\n{\n\tstruct iso9660 *iso9660;\n\tssize_t bytes_read;\n\tconst unsigned char *p;\n\tint seenTerminator;\n\n\t\/* If there's already a better bid than we can ever\n\t   make, don't bother testing. *\/\n\tif (best_bid > 48)\n\t\treturn (-1);\n\n\tiso9660 = (struct iso9660 *)(a->format->data);\n\n\t\/*\n\t * Skip the first 32k (reserved area) and get the first\n\t * 8 sectors of the volume descriptor table.  Of course,\n\t * if the I\/O layer gives us more, we'll take it.\n\t *\/\n#define RESERVED_AREA\t(SYSTEM_AREA_BLOCK * LOGICAL_BLOCK_SIZE)\n\tp = __archive_read_ahead(a,\n\t    RESERVED_AREA + 8 * LOGICAL_BLOCK_SIZE,\n\t    &bytes_read);\n\tif (p == NULL)\n\t    return (-1);\n\n\t\/* Skip the reserved area. *\/\n\tbytes_read -= RESERVED_AREA;\n\tp += RESERVED_AREA;\n\n\t\/* Check each volume descriptor. *\/\n\tseenTerminator = 0;\n\tfor (; bytes_read > LOGICAL_BLOCK_SIZE;\n\t    bytes_read -= LOGICAL_BLOCK_SIZE, p += LOGICAL_BLOCK_SIZE) {\n\t\t\/* Do not handle undefined Volume Descriptor Type. *\/\n\t\tif (p[0] >= 4 && p[0] <= 254)\n\t\t\treturn (0);\n\t\t\/* Standard Identifier must be \"CD001\" *\/\n\t\tif (memcmp(p + 1, \"CD001\", 5) != 0)\n\t\t\treturn (0);\n\t\tif (isPVD(iso9660, p))\n\t\t\tcontinue;\n\t\tif (!iso9660->joliet.location) {\n\t\t\tif (isJolietSVD(iso9660, p))\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (isBootRecord(iso9660, p))\n\t\t\tcontinue;\n\t\tif (isEVD(iso9660, p))\n\t\t\tcontinue;\n\t\tif (isSVD(iso9660, p))\n\t\t\tcontinue;\n\t\tif (isVolumePartition(iso9660, p))\n\t\t\tcontinue;\n\t\tif (isVDSetTerminator(iso9660, p)) {\n\t\t\tseenTerminator = 1;\n\t\t\tbreak;\n\t\t}\n\t\treturn (0);\n\t}\n\t\/*\n\t * ISO 9660 format must have Primary Volume Descriptor and\n\t * Volume Descriptor Set Terminator.\n\t *\/\n\tif (seenTerminator && iso9660->primary.location > 16)\n\t\treturn (48);\n\n\t\/* We didn't find a valid PVD; return a bid of zero. *\/\n\treturn (0);\n}","target":0,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":271268,"func":"MagickExport MemoryInfo *AcquireVirtualMemory(const size_t count,\n  const size_t quantum)\n{\n  MemoryInfo\n    *memory_info;\n\n  size_t\n    length;\n\n  length=count*quantum;\n  if ((count == 0) || (quantum != (length\/count)))\n    {\n      errno=ENOMEM;\n      return((MemoryInfo *) NULL);\n    }\n  memory_info=(MemoryInfo *) MagickAssumeAligned(AcquireAlignedMemory(1,\n    sizeof(*memory_info)));\n  if (memory_info == (MemoryInfo *) NULL)\n    ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n  (void) ResetMagickMemory(memory_info,0,sizeof(*memory_info));\n  memory_info->length=length;\n  memory_info->signature=MagickSignature;\n  if (AcquireMagickResource(MemoryResource,length) != MagickFalse)\n    {\n      memory_info->blob=AcquireAlignedMemory(1,length);\n      if (memory_info->blob != NULL)\n        memory_info->type=AlignedVirtualMemory;\n      else\n        RelinquishMagickResource(MemoryResource,length);\n    }\n  if ((memory_info->blob == NULL) &&\n      (AcquireMagickResource(MapResource,length) != MagickFalse))\n    {\n      \/*\n        Heap memory failed, try anonymous memory mapping.\n      *\/\n      memory_info->blob=MapBlob(-1,IOMode,0,length);\n      if (memory_info->blob != NULL)\n        memory_info->type=MapVirtualMemory;\n      else\n        RelinquishMagickResource(MapResource,length);\n    }\n  if ((memory_info->blob == NULL) &&\n      (AcquireMagickResource(DiskResource,length) != MagickFalse))\n    {\n      int\n        file;\n\n      \/*\n        Anonymous memory mapping failed, try file-backed memory mapping.\n      *\/\n      file=AcquireUniqueFileResource(memory_info->filename);\n      if (file == -1)\n        RelinquishMagickResource(DiskResource,length);\n      else\n        {\n          if ((lseek(file,length-1,SEEK_SET) < 0) || (write(file,\"\",1) != 1))\n            RelinquishMagickResource(DiskResource,length);\n          else\n            {\n              if (AcquireMagickResource(MapResource,length) == MagickFalse)\n                RelinquishMagickResource(DiskResource,length);\n              else\n                {\n                  memory_info->blob=MapBlob(file,IOMode,0,length);\n                  if (memory_info->blob != NULL)\n                    memory_info->type=MapVirtualMemory;\n                  else\n                    {\n                      RelinquishMagickResource(MapResource,length);\n                      RelinquishMagickResource(DiskResource,length);\n                    }\n                }\n            }\n          (void) close(file);\n        }\n    }\n  if (memory_info->blob == NULL)\n    {\n      memory_info->blob=AcquireMagickMemory(length);\n      if (memory_info->blob != NULL)\n        memory_info->type=UnalignedVirtualMemory;\n    }\n  if (memory_info->blob == NULL)\n    memory_info=RelinquishVirtualMemory(memory_info);\n  return(memory_info);\n}","target":0,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":180740,"func":"void OmniboxViewViews::OnGestureEvent(ui::GestureEvent* event) {\n  if (!HasFocus() && event->type() == ui::ET_GESTURE_TAP_DOWN) {\n    select_all_on_gesture_tap_ = true;\n\n    saved_selection_for_focus_change_ = gfx::Range::InvalidRange();\n  }\n\n  views::Textfield::OnGestureEvent(event);\n\n  if (select_all_on_gesture_tap_ && event->type() == ui::ET_GESTURE_TAP) {\n    SelectAllForUserGesture();\n    if (location_bar_view_)\n      location_bar_view_->omnibox_page_action_icon_container_view()\n          ->UpdatePageActionIcon(PageActionIconType::kSendTabToSelf);\n  }\n\n  if (event->type() == ui::ET_GESTURE_TAP ||\n      event->type() == ui::ET_GESTURE_TAP_CANCEL ||\n      event->type() == ui::ET_GESTURE_TWO_FINGER_TAP ||\n      event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||\n      event->type() == ui::ET_GESTURE_PINCH_BEGIN ||\n      event->type() == ui::ET_GESTURE_LONG_PRESS ||\n      event->type() == ui::ET_GESTURE_LONG_TAP) {\n    select_all_on_gesture_tap_ = false;\n  }\n}\n","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":475100,"func":"void vrend_renderer_get_meminfo(struct vrend_context *ctx, uint32_t res_handle)\n{\n   struct vrend_resource *res;\n   struct virgl_memory_info *info;\n\n   res = vrend_renderer_ctx_res_lookup(ctx, res_handle);\n   if (!res) {\n      vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);\n      return;\n   }\n\n   info = (struct virgl_memory_info *)res->iov->iov_base;\n\n   if (has_feature(feat_nvx_gpu_memory_info)) {\n         GLint i;\n         glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &i);\n         info->total_device_memory = i;\n         glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &i);\n         info->total_staging_memory = i - info->total_device_memory;\n         glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &i);\n         info->nr_device_memory_evictions = i;\n         glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &i);\n         info->device_memory_evicted = i;\n      }\n\n   if (has_feature(feat_ati_meminfo)) {\n      GLint i[4];\n      glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, i);\n      info->avail_device_memory = i[0];\n      info->avail_staging_memory = i[2];\n   }\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":244418,"func":"IV_API_CALL_STATUS_T ihevcd_cxa_api_function(iv_obj_t *ps_handle,\n void *pv_api_ip,\n void *pv_api_op)\n{\n    WORD32 command;\n    UWORD32 *pu4_ptr_cmd;\n    WORD32 ret = 0;\n    IV_API_CALL_STATUS_T e_status;\n    e_status = api_check_struct_sanity(ps_handle, pv_api_ip, pv_api_op);\n\n if(e_status != IV_SUCCESS)\n {\n        DEBUG(\"error code = %d\\n\", *((UWORD32 *)pv_api_op + 1));\n return IV_FAIL;\n }\n\n    pu4_ptr_cmd = (UWORD32 *)pv_api_ip;\n    pu4_ptr_cmd++;\n\n    command = *pu4_ptr_cmd;\n\n switch(command)\n {\n case IVD_CMD_CREATE:\n            ret = ihevcd_create(ps_handle, (void *)pv_api_ip, (void *)pv_api_op);\n break;\n case IVD_CMD_DELETE:\n            ret = ihevcd_delete(ps_handle, (void *)pv_api_ip, (void *)pv_api_op);\n break;\n\n case IVD_CMD_VIDEO_DECODE:\n            ret = ihevcd_decode(ps_handle, (void *)pv_api_ip, (void *)pv_api_op);\n break;\n\n case IVD_CMD_GET_DISPLAY_FRAME:\n break;\n\n case IVD_CMD_SET_DISPLAY_FRAME:\n            ret = ihevcd_set_display_frame(ps_handle, (void *)pv_api_ip,\n (void *)pv_api_op);\n\n break;\n\n case IVD_CMD_REL_DISPLAY_FRAME:\n            ret = ihevcd_rel_display_frame(ps_handle, (void *)pv_api_ip,\n (void *)pv_api_op);\n break;\n\n case IVD_CMD_VIDEO_CTL:\n            ret = ihevcd_ctl(ps_handle, (void *)pv_api_ip, (void *)pv_api_op);\n break;\n default:\n            ret = IV_FAIL;\n break;\n }\n\n return (IV_API_CALL_STATUS_T)ret;\n}\n","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":327497,"func":"static void gic_set_irq(void *opaque, int irq, int level)\n\n{\n\n    \/* Meaning of the 'irq' parameter:\n\n     *  [0..N-1] : external interrupts\n\n     *  [N..N+31] : PPI (internal) interrupts for CPU 0\n\n     *  [N+32..N+63] : PPI (internal interrupts for CPU 1\n\n     *  ...\n\n     *\/\n\n    GICState *s = (GICState *)opaque;\n\n    int cm, target;\n\n    if (irq < (s->num_irq - GIC_INTERNAL)) {\n\n        \/* The first external input line is internal interrupt 32.  *\/\n\n        cm = ALL_CPU_MASK;\n\n        irq += GIC_INTERNAL;\n\n        target = GIC_TARGET(irq);\n\n    } else {\n\n        int cpu;\n\n        irq -= (s->num_irq - GIC_INTERNAL);\n\n        cpu = irq \/ GIC_INTERNAL;\n\n        irq %= GIC_INTERNAL;\n\n        cm = 1 << cpu;\n\n        target = cm;\n\n    }\n\n\n\n    assert(irq >= GIC_NR_SGIS);\n\n\n\n    if (level == GIC_TEST_LEVEL(irq, cm)) {\n\n        return;\n\n    }\n\n\n\n    if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {\n\n        gic_set_irq_11mpcore(s, irq, level, cm, target);\n\n    } else {\n\n        gic_set_irq_generic(s, irq, level, cm, target);\n\n    }\n\n\n\n\n    gic_update(s);\n\n}","target":1,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":239134,"func":"void ExtensionPrefs::MakePathsRelative() {\n  const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);\n  if (!dict || dict->empty())\n    return;\n\n  std::set<std::string> absolute_keys;\n  for (DictionaryValue::key_iterator i = dict->begin_keys();\n       i != dict->end_keys(); ++i) {\n    DictionaryValue* extension_dict = NULL;\n    if (!dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict))\n      continue;\n    int location_value;\n    if (extension_dict->GetInteger(kPrefLocation, &location_value) &&\n        location_value == Extension::LOAD) {\n      continue;\n    }\n    FilePath::StringType path_string;\n    if (!extension_dict->GetString(kPrefPath, &path_string))\n      continue;\n    FilePath path(path_string);\n    if (path.IsAbsolute())\n      absolute_keys.insert(*i);\n  }\n  if (absolute_keys.empty())\n    return;\n\n  DictionaryPrefUpdate update(prefs_, kExtensionsPref);\n  const DictionaryValue* update_dict = update.Get();\n  for (std::set<std::string>::iterator i = absolute_keys.begin();\n       i != absolute_keys.end(); ++i) {\n    DictionaryValue* extension_dict = NULL;\n    update_dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict);\n    FilePath::StringType path_string;\n    extension_dict->GetString(kPrefPath, &path_string);\n    FilePath path(path_string);\n    extension_dict->SetString(kPrefPath,\n        MakePathRelative(install_directory_, path));\n  }\n  SavePrefs();\n}\n","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":191775,"func":"void WT_VoiceFilter (S_FILTER_CONTROL *pFilter, S_WT_INT_FRAME *pWTIntFrame)\n{\n    EAS_PCM *pAudioBuffer;\n    EAS_I32 k;\n    EAS_I32 b1;\n    EAS_I32 b2;\n    EAS_I32 z1;\n    EAS_I32 z2;\n    EAS_I32 acc0;\n    EAS_I32 acc1;\n    EAS_I32 numSamples;\n\n \/* initialize some local variables *\/\n\n     numSamples = pWTIntFrame->numSamples;\n     if (numSamples <= 0) {\n         ALOGE(\"b\/26366256\");\n        android_errorWriteLog(0x534e4554, \"26366256\");\n         return;\n     }\n     pAudioBuffer = pWTIntFrame->pAudioBuffer;\n\n    z1 = pFilter->z1;\n    z2 = pFilter->z2;\n    b1 = -pWTIntFrame->frame.b1;\n\n \/*lint -e{702} <avoid divide> *\/\n    b2 = -pWTIntFrame->frame.b2 >> 1;\n\n \/*lint -e{702} <avoid divide> *\/\n    k = pWTIntFrame->frame.k >> 1;\n\n while (numSamples--)\n {\n\n \/* do filter calculations *\/\n        acc0 = *pAudioBuffer;\n        acc1 = z1 * b1;\n        acc1 += z2 * b2;\n        acc0 = acc1 + k * acc0;\n        z2 = z1;\n\n \/*lint -e{702} <avoid divide> *\/\n        z1 = acc0 >> 14;\n *pAudioBuffer++ = (EAS_I16) z1;\n }\n\n \/* save delay values     *\/\n    pFilter->z1 = (EAS_I16) z1;\n    pFilter->z2 = (EAS_I16) z2;\n}\n","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":69330,"func":"TEST(AsyncSSLSocketTest, SSLHandshakeValidationFailure) {\n  EventBase eventBase;\n  auto clientCtx = std::make_shared<SSLContext>();\n  auto dfServerCtx = std::make_shared<SSLContext>();\n\n  NetworkSocket fds[2];\n  getfds(fds);\n  getctx(clientCtx, dfServerCtx);\n\n  clientCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::VERIFY);\n  dfServerCtx->setVerificationOption(SSLContext::SSLVerifyPeerEnum::VERIFY);\n\n  AsyncSSLSocket::UniquePtr clientSock(\n      new AsyncSSLSocket(clientCtx, &eventBase, fds[0], false));\n  AsyncSSLSocket::UniquePtr serverSock(\n      new AsyncSSLSocket(dfServerCtx, &eventBase, fds[1], true));\n\n  SSLHandshakeClient client(std::move(clientSock), true, false);\n  clientCtx->loadTrustedCertificates(kTestCA);\n\n  SSLHandshakeServer server(std::move(serverSock), true, true);\n\n  eventBase.loop();\n\n  EXPECT_TRUE(client.handshakeVerify_);\n  EXPECT_TRUE(!client.handshakeSuccess_);\n  EXPECT_TRUE(client.handshakeError_);\n  EXPECT_LE(0, client.handshakeTime.count());\n  EXPECT_TRUE(!server.handshakeVerify_);\n  EXPECT_TRUE(!server.handshakeSuccess_);\n  EXPECT_TRUE(server.handshakeError_);\n  EXPECT_LE(0, server.handshakeTime.count());\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":67661,"func":"TEST_F(HttpConnectionManagerImplTest, TestSrdsCrossScopeReroute) {\n  setup(false, \"\", true, true);\n\n  std::shared_ptr<Router::MockConfig> route_config1 =\n      std::make_shared<NiceMock<Router::MockConfig>>();\n  std::shared_ptr<Router::MockConfig> route_config2 =\n      std::make_shared<NiceMock<Router::MockConfig>>();\n  std::shared_ptr<Router::MockRoute> route1 = std::make_shared<NiceMock<Router::MockRoute>>();\n  std::shared_ptr<Router::MockRoute> route2 = std::make_shared<NiceMock<Router::MockRoute>>();\n  EXPECT_CALL(*route_config1, route(_, _)).WillRepeatedly(Return(route1));\n  EXPECT_CALL(*route_config2, route(_, _)).WillRepeatedly(Return(route2));\n  EXPECT_CALL(*static_cast<const Router::MockScopedConfig*>(\n                  scopedRouteConfigProvider()->config<Router::ScopedConfig>().get()),\n              getRouteConfig(_))\n      \/\/ 1. Snap scoped route config;\n      \/\/ 2. refreshCachedRoute (both in decodeHeaders(headers,end_stream);\n      \/\/ 3. then refreshCachedRoute triggered by decoder_filters_[1]->callbacks_->route().\n      .Times(3)\n      .WillRepeatedly(Invoke([&](const HeaderMap& headers) -> Router::ConfigConstSharedPtr {\n        auto& test_headers = static_cast<const TestHeaderMapImpl&>(headers);\n        if (test_headers.get_(\"scope_key\") == \"foo\") {\n          return route_config1;\n        }\n        return route_config2;\n      }));\n  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void {\n    StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_);\n    HeaderMapPtr headers{new TestHeaderMapImpl{\n        {\":authority\", \"host\"}, {\":method\", \"GET\"}, {\"scope_key\", \"foo\"}, {\":path\", \"\/foo\"}}};\n    decoder->decodeHeaders(std::move(headers), false);\n    data.drain(4);\n  }));\n  setupFilterChain(2, 0);\n  EXPECT_CALL(*decoder_filters_[0], decodeHeaders(_, false))\n      .WillOnce(Invoke([&](Http::HeaderMap& headers, bool) -> FilterHeadersStatus {\n        EXPECT_EQ(route1, decoder_filters_[0]->callbacks_->route());\n        auto& test_headers = static_cast<TestHeaderMapImpl&>(headers);\n        \/\/ Clear cached route and change scope key to \"bar\".\n        decoder_filters_[0]->callbacks_->clearRouteCache();\n        test_headers.remove(\"scope_key\");\n        test_headers.addCopy(\"scope_key\", \"bar\");\n        return FilterHeadersStatus::Continue;\n      }));\n  EXPECT_CALL(*decoder_filters_[1], decodeHeaders(_, false))\n      .WillOnce(Invoke([&](Http::HeaderMap& headers, bool) -> FilterHeadersStatus {\n        auto& test_headers = static_cast<TestHeaderMapImpl&>(headers);\n        EXPECT_EQ(test_headers.get_(\"scope_key\"), \"bar\");\n        \/\/ Route now switched to route2 as header \"scope_key\" has changed.\n        EXPECT_EQ(route2, decoder_filters_[1]->callbacks_->route());\n        EXPECT_EQ(route2->routeEntry(), decoder_filters_[1]->callbacks_->streamInfo().routeEntry());\n        return FilterHeadersStatus::StopIteration;\n      }));\n\n  Buffer::OwnedImpl fake_input(\"1234\");\n  conn_manager_->onData(fake_input, false);\n}","target":0,"code_token_length":724,"total_token_length":960,"max_tokens_setting":1024}
+{"idx":499210,"func":"static void intra_prediction_unit_default_value(HEVCContext *s,\n                                                int x0, int y0,\n                                                int log2_cb_size)\n{\n    HEVCLocalContext *lc = &s->HEVClc;\n    int pb_size          = 1 << log2_cb_size;\n    int size_in_pus      = pb_size >> s->sps->log2_min_pu_size;\n    int min_pu_width     = s->sps->min_pu_width;\n    MvField *tab_mvf     = s->ref->tab_mvf;\n    int x_pu             = x0 >> s->sps->log2_min_pu_size;\n    int y_pu             = y0 >> s->sps->log2_min_pu_size;\n    int j, k;\n\n    if (size_in_pus == 0)\n        size_in_pus = 1;\n    for (j = 0; j < size_in_pus; j++) {\n        memset(&s->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus);\n        for (k = 0; k < size_in_pus; k++)\n            tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].is_intra = lc->cu.pred_mode == MODE_INTRA;\n    }\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":172020,"func":"extern \"C\" int EffectCreate(const effect_uuid_t *uuid,\n int32_t             sessionId __unused,\n int32_t             ioId __unused,\n effect_handle_t *pHandle){\n int ret;\n int i;\n int length = sizeof(gDescriptors) \/ sizeof(const effect_descriptor_t *);\n const effect_descriptor_t *desc;\n\n    ALOGV(\"\\t\\nEffectCreate start\");\n\n if (pHandle == NULL || uuid == NULL){\n        ALOGV(\"\\tLVM_ERROR : EffectCreate() called with NULL pointer\");\n return -EINVAL;\n }\n\n for (i = 0; i < length; i++) {\n        desc = gDescriptors[i];\n if (memcmp(uuid, &desc->uuid, sizeof(effect_uuid_t))\n == 0) {\n            ALOGV(\"\\tEffectCreate - UUID matched Reverb type %d, UUID = %x\", i, desc->uuid.timeLow);\n break;\n }\n }\n\n if (i == length) {\n return -ENOENT;\n }\n\n ReverbContext *pContext = new ReverbContext;\n\n    pContext->itfe      = &gReverbInterface;\n    pContext->hInstance = NULL;\n\n    pContext->auxiliary = false;\n if ((desc->flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY){\n        pContext->auxiliary = true;\n        ALOGV(\"\\tEffectCreate - AUX\");\n }else{\n        ALOGV(\"\\tEffectCreate - INS\");\n }\n\n    pContext->preset = false;\n if (memcmp(&desc->type, SL_IID_PRESETREVERB, sizeof(effect_uuid_t)) == 0) {\n        pContext->preset = true;\n        pContext->curPreset = REVERB_PRESET_LAST + 1;\n        pContext->nextPreset = REVERB_DEFAULT_PRESET;\n        ALOGV(\"\\tEffectCreate - PRESET\");\n }else{\n        ALOGV(\"\\tEffectCreate - ENVIRONMENTAL\");\n }\n\n    ALOGV(\"\\tEffectCreate - Calling Reverb_init\");\n    ret = Reverb_init(pContext);\n\n if (ret < 0){\n        ALOGV(\"\\tLVM_ERROR : EffectCreate() init failed\");\n delete pContext;\n return ret;\n }\n\n *pHandle = (effect_handle_t)pContext;\n\n #ifdef LVM_PCM\n    pContext->PcmInPtr = NULL;\n    pContext->PcmOutPtr = NULL;\n\n    pContext->PcmInPtr = fopen(\"\/data\/tmp\/reverb_pcm_in.pcm\", \"w\");\n    pContext->PcmOutPtr = fopen(\"\/data\/tmp\/reverb_pcm_out.pcm\", \"w\");\n\n if((pContext->PcmInPtr == NULL)||\n (pContext->PcmOutPtr == NULL)){\n return -EINVAL;\n }\n #endif\n\n\n    pContext->InFrames32 = (LVM_INT32 *)malloc(LVREV_MAX_FRAME_SIZE * sizeof(LVM_INT32) * 2);\n    pContext->OutFrames32 = (LVM_INT32 *)malloc(LVREV_MAX_FRAME_SIZE * sizeof(LVM_INT32) * 2);\n\n    ALOGV(\"\\tEffectCreate %p, size %d\", pContext, sizeof(ReverbContext));\n    ALOGV(\"\\tEffectCreate end\\n\");\n return 0;\n} \/* end EffectCreate *\/\n","target":0,"code_token_length":678,"total_token_length":914,"max_tokens_setting":1024}
+{"idx":135290,"func":"CIFSSMBQFSDeviceInfo(const int xid, struct cifs_tcon *tcon)\n{\n\/* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO *\/\n\tTRANSACTION2_QFSI_REQ *pSMB = NULL;\n\tTRANSACTION2_QFSI_RSP *pSMBr = NULL;\n\tFILE_SYSTEM_DEVICE_INFO *response_data;\n\tint rc = 0;\n\tint bytes_returned = 0;\n\t__u16 params, byte_count;\n\n\tcFYI(1, \"In QFSDeviceInfo\");\nQFSDeviceRetry:\n\trc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,\n\t\t      (void **) &pSMBr);\n\tif (rc)\n\t\treturn rc;\n\n\tparams = 2;\t\/* level *\/\n\tpSMB->TotalDataCount = 0;\n\tpSMB->MaxParameterCount = cpu_to_le16(2);\n\t\/* BB find exact max SMB PDU from sess structure BB *\/\n\tpSMB->MaxDataCount = cpu_to_le16(1000);\n\tpSMB->MaxSetupCount = 0;\n\tpSMB->Reserved = 0;\n\tpSMB->Flags = 0;\n\tpSMB->Timeout = 0;\n\tpSMB->Reserved2 = 0;\n\tbyte_count = params + 1 \/* pad *\/ ;\n\tpSMB->TotalParameterCount = cpu_to_le16(params);\n\tpSMB->ParameterCount = pSMB->TotalParameterCount;\n\tpSMB->ParameterOffset = cpu_to_le16(offsetof(\n\t\tstruct smb_com_transaction2_qfsi_req, InformationLevel) - 4);\n\n\tpSMB->DataCount = 0;\n\tpSMB->DataOffset = 0;\n\tpSMB->SetupCount = 1;\n\tpSMB->Reserved3 = 0;\n\tpSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION);\n\tpSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_DEVICE_INFO);\n\tinc_rfc1001_len(pSMB, byte_count);\n\tpSMB->ByteCount = cpu_to_le16(byte_count);\n\n\trc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,\n\t\t\t (struct smb_hdr *) pSMBr, &bytes_returned, 0);\n\tif (rc) {\n\t\tcFYI(1, \"Send error in QFSDeviceInfo = %d\", rc);\n\t} else {\t\t\/* decode response *\/\n\t\trc = validate_t2((struct smb_t2_rsp *)pSMBr);\n\n\t\tif (rc || get_bcc(&pSMBr->hdr) <\n\t\t\t  sizeof(FILE_SYSTEM_DEVICE_INFO))\n\t\t\trc = -EIO;\t\/* bad smb *\/\n\t\telse {\n\t\t\t__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);\n\t\t\tresponse_data =\n\t\t\t    (FILE_SYSTEM_DEVICE_INFO *)\n\t\t\t\t(((char *) &pSMBr->hdr.Protocol) +\n\t\t\t\t data_offset);\n\t\t\tmemcpy(&tcon->fsDevInfo, response_data,\n\t\t\t       sizeof(FILE_SYSTEM_DEVICE_INFO));\n\t\t}\n\t}\n\tcifs_buf_release(pSMB);\n\n\tif (rc == -EAGAIN)\n\t\tgoto QFSDeviceRetry;\n\n\treturn rc;\n}","target":0,"code_token_length":690,"total_token_length":926,"max_tokens_setting":1024}
+{"idx":128850,"func":"TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module)\n{\n\tTIFFDirectory *td = &tif->tif_dir;\n\tuint64* new_stripoffset;\n\tuint64* new_stripbytecount;\n\n\tassert(td->td_planarconfig == PLANARCONFIG_CONTIG);\n\tnew_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset,\n\t\t(td->td_nstrips + delta) * sizeof (uint64));\n\tnew_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount,\n\t\t(td->td_nstrips + delta) * sizeof (uint64));\n\tif (new_stripoffset == NULL || new_stripbytecount == NULL) {\n\t\tif (new_stripoffset)\n\t\t\t_TIFFfree(new_stripoffset);\n\t\tif (new_stripbytecount)\n\t\t\t_TIFFfree(new_stripbytecount);\n\t\ttd->td_nstrips = 0;\n\t\tTIFFErrorExt(tif->tif_clientdata, module, \"No space to expand strip arrays\");\n\t\treturn (0);\n\t}\n\ttd->td_stripoffset = new_stripoffset;\n\ttd->td_stripbytecount = new_stripbytecount;\n\t_TIFFmemset(td->td_stripoffset + td->td_nstrips,\n\t\t    0, delta*sizeof (uint64));\n\t_TIFFmemset(td->td_stripbytecount + td->td_nstrips,\n\t\t    0, delta*sizeof (uint64));\n\ttd->td_nstrips += delta;\n        tif->tif_flags |= TIFF_DIRTYDIRECT;\n\n\treturn (1);\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":83942,"func":"static OPJ_BOOL opj_j2k_write_mco(opj_j2k_t *p_j2k,\n                                  struct opj_stream_private *p_stream,\n                                  struct opj_event_mgr * p_manager\n                                 )\n{\n    OPJ_BYTE * l_current_data = 00;\n    OPJ_UINT32 l_mco_size;\n    opj_tcp_t * l_tcp = 00;\n    opj_simple_mcc_decorrelation_data_t * l_mcc_record;\n    OPJ_UINT32 i;\n\n    \/* preconditions *\/\n    assert(p_j2k != 00);\n    assert(p_manager != 00);\n    assert(p_stream != 00);\n\n    l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);\n\n    l_mco_size = 5 + l_tcp->m_nb_mcc_records;\n    if (l_mco_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {\n\n        OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(\n                                             p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mco_size);\n        if (! new_header_tile_data) {\n            opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);\n            p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;\n            p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;\n            opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to write MCO marker\\n\");\n            return OPJ_FALSE;\n        }\n        p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;\n        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mco_size;\n    }\n    l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;\n\n\n    opj_write_bytes(l_current_data, J2K_MS_MCO, 2);                 \/* MCO *\/\n    l_current_data += 2;\n\n    opj_write_bytes(l_current_data, l_mco_size - 2, 2);             \/* Lmco *\/\n    l_current_data += 2;\n\n    opj_write_bytes(l_current_data, l_tcp->m_nb_mcc_records,\n                    1);    \/* Nmco : only one transform stage*\/\n    ++l_current_data;\n\n    l_mcc_record = l_tcp->m_mcc_records;\n    for (i = 0; i < l_tcp->m_nb_mcc_records; ++i) {\n        opj_write_bytes(l_current_data, l_mcc_record->m_index,\n                        1); \/* Imco -> use the mcc indicated by 1*\/\n        ++l_current_data;\n        ++l_mcc_record;\n    }\n\n    if (opj_stream_write_data(p_stream,\n                              p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mco_size,\n                              p_manager) != l_mco_size) {\n        return OPJ_FALSE;\n    }\n\n    return OPJ_TRUE;\n}","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":43164,"func":"TEST_F(SecretManagerImplTest, SdsDynamicSecretUpdateSuccess) {\n  Server::MockInstance server;\n  SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_));\n\n  NiceMock<Server::Configuration::MockTransportSocketFactoryContext> secret_context;\n\n  envoy::config::core::v3::ConfigSource config_source;\n  NiceMock<LocalInfo::MockLocalInfo> local_info;\n  NiceMock<Random::MockRandomGenerator> random;\n  Stats::IsolatedStoreImpl stats;\n  NiceMock<Init::MockManager> init_manager;\n  NiceMock<Init::ExpectableWatcherImpl> init_watcher;\n  Init::TargetHandlePtr init_target_handle;\n  EXPECT_CALL(init_manager, add(_))\n      .WillOnce(Invoke([&init_target_handle](const Init::Target& target) {\n        init_target_handle = target.createHandle(\"test\");\n      }));\n  EXPECT_CALL(secret_context, stats()).WillOnce(ReturnRef(stats));\n  EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager));\n  EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(*dispatcher_));\n  EXPECT_CALL(secret_context, localInfo()).WillOnce(ReturnRef(local_info));\n  EXPECT_CALL(secret_context, api()).WillRepeatedly(ReturnRef(*api_));\n\n  auto secret_provider =\n      secret_manager->findOrCreateTlsCertificateProvider(config_source, \"abc.com\", secret_context);\n  const std::string yaml =\n      R\"EOF(\nname: \"abc.com\"\ntls_certificate:\n  certificate_chain:\n    filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_cert.pem\"\n  private_key:\n    filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_key.pem\"\n)EOF\";\n  envoy::extensions::transport_sockets::tls::v3::Secret typed_secret;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), typed_secret);\n  const auto decoded_resources = TestUtility::decodeResources({typed_secret});\n  init_target_handle->initialize(init_watcher);\n  secret_context.cluster_manager_.subscription_factory_.callbacks_->onConfigUpdate(\n      decoded_resources.refvec_, \"\");\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext> ctx;\n  Ssl::TlsCertificateConfigImpl tls_config(*secret_provider->secret(), ctx, *api_);\n  const std::string cert_pem =\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_cert.pem\";\n  EXPECT_EQ(TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(cert_pem)),\n            tls_config.certificateChain());\n  const std::string key_pem =\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_key.pem\";\n  EXPECT_EQ(TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(key_pem)),\n            tls_config.privateKey());\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":262659,"func":"void send_fragments(unsigned char *packet, int packet_len, unsigned char *iv, unsigned char *keystream, int fragsize, int ska)\n{\n    int t, u;\n    int data_size;\n    unsigned char frag[32+fragsize];\n    int pack_size;\n    int header_size=24;\n\n    data_size = packet_len-header_size;\n    packet[23] = (rand() % 0xFF);\n\n    for (t=0; t+=fragsize;)\n    {\n\n    \/\/Copy header\n        memcpy(frag, packet, header_size);\n\n    \/\/Copy IV + KeyIndex\n        memcpy(frag+header_size, iv, 4);\n\n    \/\/Copy data\n        if(fragsize <= packet_len-(header_size+t-fragsize))\n            memcpy(frag+header_size+4, packet+header_size+t-fragsize, fragsize);\n        else\n            memcpy(frag+header_size+4, packet+header_size+t-fragsize, packet_len-(header_size+t-fragsize));\n\n    \/\/Make ToDS frame\n        if(!ska)\n        {\n            frag[1] |= 1;\n            frag[1] &= 253;\n        }\n\n    \/\/Set fragment bit\n        if (t< data_size) frag[1] |= 4;\n        if (t>=data_size) frag[1] &= 251;\n\n    \/\/Fragment number\n        frag[22] = 0;\n        for (u=t; u-=fragsize;)\n        {\n            frag[22] += 1;\n        }\n\/\/        frag[23] = 0;\n\n    \/\/Calculate packet length\n        if(fragsize <= packet_len-(header_size+t-fragsize))\n            pack_size = header_size + 4 + fragsize;\n        else\n            pack_size = header_size + 4 + (packet_len-(header_size+t-fragsize));\n\n    \/\/Add ICV\n        add_icv(frag, pack_size, header_size + 4);\n        pack_size += 4;\n\n    \/\/Encrypt\n        xor_keystream(frag + header_size + 4, keystream, fragsize+4);\n\n    \/\/Send\n        send_packet(frag, pack_size);\n        if (t<data_size)usleep(100);\n\n        if (t>=data_size) break;\n    }\n\n}","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":254771,"func":"static UChar32 T_UConverter_getNextUChar_UTF32_LE ( UConverterToUnicodeArgs * args , UErrorCode * err ) {\n const uint8_t * mySource ;\n UChar32 myUChar ;\n int32_t length ;\n mySource = ( const uint8_t * ) args -> source ;\n if ( mySource >= ( const uint8_t * ) args -> sourceLimit ) {\n * err = U_INDEX_OUTOFBOUNDS_ERROR ;\n return 0xffff ;\n }\n length = ( int32_t ) ( ( const uint8_t * ) args -> sourceLimit - mySource ) ;\n if ( length < 4 ) {\n uprv_memcpy ( args -> converter -> toUBytes , mySource , length ) ;\n args -> converter -> toULength = ( int8_t ) length ;\n args -> source = ( const char * ) ( mySource + length ) ;\n * err = U_TRUNCATED_CHAR_FOUND ;\n return 0xffff ;\n }\n myUChar = ( ( UChar32 ) mySource [ 3 ] << 24 ) | ( ( UChar32 ) mySource [ 2 ] << 16 ) | ( ( UChar32 ) mySource [ 1 ] << 8 ) | ( ( UChar32 ) mySource [ 0 ] ) ;\n args -> source = ( const char * ) ( mySource + 4 ) ;\n if ( ( uint32_t ) myUChar <= MAXIMUM_UTF && ! U_IS_SURROGATE ( myUChar ) ) {\n return myUChar ;\n }\n uprv_memcpy ( args -> converter -> toUBytes , mySource , 4 ) ;\n args -> converter -> toULength = 4 ;\n * err = U_ILLEGAL_CHAR_FOUND ;\n return 0xffff ;\n }","target":1,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":22787,"func":"static HashTable * spl_dllist_object_get_debug_info ( zval * obj , int * is_temp TSRMLS_DC ) {\n spl_dllist_object * intern = ( spl_dllist_object * ) zend_object_store_get_object ( obj TSRMLS_CC ) ;\n spl_ptr_llist_element * current = intern -> llist -> head , * next ;\n zval * tmp , zrv , * dllist_array ;\n char * pnstr ;\n int pnlen ;\n int i = 0 ;\n * is_temp = 0 ;\n if ( intern -> debug_info == NULL ) {\n ALLOC_HASHTABLE ( intern -> debug_info ) ;\n zend_hash_init ( intern -> debug_info , 1 , NULL , ZVAL_PTR_DTOR , 0 ) ;\n }\n if ( intern -> debug_info -> nApplyCount == 0 ) {\n INIT_PZVAL ( & zrv ) ;\n Z_ARRVAL ( zrv ) = intern -> debug_info ;\n if ( ! intern -> std . properties ) {\n rebuild_object_properties ( & intern -> std ) ;\n }\n zend_hash_copy ( intern -> debug_info , intern -> std . properties , ( copy_ctor_func_t ) zval_add_ref , ( void * ) & tmp , sizeof ( zval * ) ) ;\n pnstr = spl_gen_private_prop_name ( spl_ce_SplDoublyLinkedList , \"flags\" , sizeof ( \"flags\" ) - 1 , & pnlen TSRMLS_CC ) ;\n add_assoc_long_ex ( & zrv , pnstr , pnlen + 1 , intern -> flags ) ;\n efree ( pnstr ) ;\n ALLOC_INIT_ZVAL ( dllist_array ) ;\n array_init ( dllist_array ) ;\n while ( current ) {\n next = current -> next ;\n add_index_zval ( dllist_array , i , ( zval * ) current -> data ) ;\n Z_ADDREF_P ( current -> data ) ;\n i ++ ;\n current = next ;\n }\n pnstr = spl_gen_private_prop_name ( spl_ce_SplDoublyLinkedList , \"dllist\" , sizeof ( \"dllist\" ) - 1 , & pnlen TSRMLS_CC ) ;\n add_assoc_zval_ex ( & zrv , pnstr , pnlen + 1 , dllist_array ) ;\n efree ( pnstr ) ;\n }\n return intern -> debug_info ;\n }","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":32094,"func":"read_passphrase_hash (const char *passphrase_file,\n\t\t      const md_kt_t *digest,\n\t\t      uint8_t *output,\n\t\t      int len)\n{\n  unsigned int outlen = 0;\n  md_ctx_t md;\n\n  ASSERT (len >= md_kt_size(digest));\n  memset (output, 0, len);\n\n  md_ctx_init(&md, digest);\n\n  \/* read passphrase file *\/\n  {\n    const int min_passphrase_size = 8;\n    uint8_t buf[64];\n    int total_size = 0;\n    int fd = platform_open (passphrase_file, O_RDONLY, 0);\n\n    if (fd == -1)\n      msg (M_ERR, \"Cannot open passphrase file: '%s'\", passphrase_file);\n\n    for (;;)\n      {\n\tint size = read (fd, buf, sizeof (buf));\n\tif (size == 0)\n\t  break;\n\tif (size == -1)\n\t  msg (M_ERR, \"Read error on passphrase file: '%s'\",\n\t       passphrase_file);\n\tmd_ctx_update(&md, buf, size);\n\ttotal_size += size;\n      }\n    close (fd);\n\n    warn_if_group_others_accessible (passphrase_file);\n\n    if (total_size < min_passphrase_size)\n      msg (M_FATAL,\n\t   \"Passphrase file '%s' is too small (must have at least %d characters)\",\n\t   passphrase_file, min_passphrase_size);\n  }\n  md_ctx_final(&md, output);\n  md_ctx_cleanup(&md);\n  return md_kt_size(digest);\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":516845,"func":"Item_func_between::add_key_fields(JOIN *join, KEY_FIELD **key_fields,\n                                  uint *and_level, table_map usable_tables,\n                                  SARGABLE_PARAM **sargables)\n{\n  \/*\n    Build list of possible keys for 'a BETWEEN low AND high'.\n    It is handled similar to the equivalent condition \n    'a >= low AND a <= high':\n  *\/\n  Item_field *field_item;\n  bool equal_func= false;\n  uint num_values= 2;\n\n  bool binary_cmp= (args[0]->real_item()->type() == Item::FIELD_ITEM)\n        ? ((Item_field*) args[0]->real_item())->field->binary()\n        : true;\n  \/*\n    Additional optimization: If 'low = high':\n    Handle as if the condition was \"t.key = low\".\n  *\/\n  if (!negated && args[1]->eq(args[2], binary_cmp))\n  {\n    equal_func= true;\n    num_values= 1;\n  }\n\n  \/*\n    Append keys for 'field <cmp> value[]' if the\n    condition is of the form::\n    '<field> BETWEEN value[1] AND value[2]'\n  *\/\n  if (is_local_field(args[0]))\n  {\n    field_item= (Item_field *) (args[0]->real_item());\n    add_key_equal_fields(join, key_fields, *and_level, this,\n                         field_item, equal_func, &args[1],\n                         num_values, usable_tables, sargables);\n  }\n  \/*\n    Append keys for 'value[0] <cmp> field' if the\n    condition is of the form:\n    'value[0] BETWEEN field1 AND field2'\n  *\/\n  for (uint i= 1; i <= num_values; i++)\n  {\n    if (is_local_field(args[i]))\n    {\n      field_item= (Item_field *) (args[i]->real_item());\n      add_key_equal_fields(join, key_fields, *and_level, this,\n                           field_item, equal_func, args,\n                           1, usable_tables, sargables);\n    }\n  }\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":317048,"func":"static MagickBooleanType WriteRGFImage(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  int\n    bit;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    x;\n\n  ssize_t\n    y;\n\n  unsigned char\n    byte;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickSignature);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  (void) TransformImageColorspace(image,sRGBColorspace);\n  if((image->columns > 255L) || (image->rows > 255L))\n    ThrowWriterException(ImageError,\"Dimensions must be less than 255x255\");\n  \/*\n    Write header (just the image dimensions)\n  *\/\n  (void) WriteBlobByte(image,image->columns & 0xff);\n  (void) WriteBlobByte(image,image->rows & 0xff);\n  \/*\n    Convert MIFF to bit pixels.\n  *\/\n  (void) SetImageType(image,BilevelType);\n  x=0;\n  y=0;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n    if (p == (const PixelPacket *) NULL)\n      break;\n    bit=0;\n    byte=0;\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      byte>>=1;\n      if (GetPixelLuma(image,p) < (QuantumRange\/2))\n        byte|=0x80;\n      bit++;\n      if (bit == 8)\n        {\n          \/*\n            Write a bitmap byte to the image file.\n          *\/\n       \t  (void) WriteBlobByte(image,byte);\n          bit=0;\n          byte=0;\n        }\n      p++;\n    }\n    if (bit != 0)\n      (void) WriteBlobByte(image,byte);\n    status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n      image->rows);\n    if (status == MagickFalse)\n      break;\n  }\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}\n","target":0,"code_token_length":588,"total_token_length":824,"max_tokens_setting":1024}
+{"idx":330162,"func":"static void dump_aml_files(test_data *data, bool rebuild)\n\n{\n\n    AcpiSdtTable *sdt;\n\n    GError *error = NULL;\n\n    gchar *aml_file = NULL;\n\n    gint fd;\n\n    ssize_t ret;\n\n    int i;\n\n\n\n    for (i = 0; i < data->tables->len; ++i) {\n\n        const char *ext = data->variant ? data->variant : \"\";\n\n        sdt = &g_array_index(data->tables, AcpiSdtTable, i);\n\n        g_assert(sdt->aml);\n\n\n\n        if (rebuild) {\n\n            uint32_t signature = cpu_to_le32(sdt->header.signature);\n\n            aml_file = g_strdup_printf(\"%s\/%s\/%.4s%s\", data_dir, data->machine,\n\n                                       (gchar *)&signature, ext);\n\n            fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,\n\n                        S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);\n\n        } else {\n\n            fd = g_file_open_tmp(\"aml-XXXXXX\", &sdt->aml_file, &error);\n\n            g_assert_no_error(error);\n\n        }\n\n        g_assert(fd >= 0);\n\n\n\n        ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader));\n\n        g_assert(ret == sizeof(AcpiTableHeader));\n\n        ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);\n\n        g_assert(ret == sdt->aml_len);\n\n\n\n        close(fd);\n\n\n\n        if (aml_file) {\n\n            g_free(aml_file);\n\n        }\n\n    }\n\n}\n","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":330972,"func":"static void scsi_read_complete(void * opaque, int ret)\n\n{\n\n    SCSIGenericReq *r = (SCSIGenericReq *)opaque;\n\n    SCSIDevice *s = r->req.dev;\n\n    int len;\n\n\n\n    r->req.aiocb = NULL;\n\n    if (ret || r->req.io_canceled) {\n\n        scsi_command_complete(r, ret);\n\n        return;\n\n    }\n\n    len = r->io_header.dxfer_len - r->io_header.resid;\n\n    DPRINTF(\"Data ready tag=0x%x len=%d\\n\", r->req.tag, len);\n\n\n\n    r->len = -1;\n\n    if (len == 0) {\n\n        scsi_command_complete(r, 0);\n\n    } else {\n\n        \/* Snoop READ CAPACITY output to set the blocksize.  *\/\n\n        if (r->req.cmd.buf[0] == READ_CAPACITY_10 &&\n\n            (ldl_be_p(&r->buf[0]) != 0xffffffffU || s->max_lba == 0)) {\n\n            s->blocksize = ldl_be_p(&r->buf[4]);\n\n            s->max_lba = ldl_be_p(&r->buf[0]) & 0xffffffffULL;\n\n        } else if (r->req.cmd.buf[0] == SERVICE_ACTION_IN_16 &&\n\n                   (r->req.cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) {\n\n            s->blocksize = ldl_be_p(&r->buf[8]);\n\n            s->max_lba = ldq_be_p(&r->buf[0]);\n\n        }\n\n        bdrv_set_guest_block_size(s->conf.bs, s->blocksize);\n\n\n\n        scsi_req_data(&r->req, len);\n\n        scsi_req_unref(&r->req);\n\n    }\n\n}\n","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":325664,"func":"static int qemu_savevm_state(QEMUFile *f)\n\n{\n\n    SaveStateEntry *se;\n\n    int len, ret;\n\n    int64_t cur_pos, len_pos, total_len_pos;\n\n\n\n    qemu_put_be32(f, QEMU_VM_FILE_MAGIC);\n\n    qemu_put_be32(f, QEMU_VM_FILE_VERSION);\n\n    total_len_pos = qemu_ftell(f);\n\n    qemu_put_be64(f, 0); \/* total size *\/\n\n\n\n    for(se = first_se; se != NULL; se = se->next) {\n\n\tif (se->save_state == NULL)\n\n\t    \/* this one has a loader only, for backwards compatibility *\/\n\n\t    continue;\n\n\n\n        \/* ID string *\/\n\n        len = strlen(se->idstr);\n\n        qemu_put_byte(f, len);\n\n        qemu_put_buffer(f, (uint8_t *)se->idstr, len);\n\n\n\n        qemu_put_be32(f, se->instance_id);\n\n        qemu_put_be32(f, se->version_id);\n\n\n\n        \/* record size: filled later *\/\n\n        len_pos = qemu_ftell(f);\n\n        qemu_put_be32(f, 0);\n\n        se->save_state(f, se->opaque);\n\n\n\n        \/* fill record size *\/\n\n        cur_pos = qemu_ftell(f);\n\n        len = cur_pos - len_pos - 4;\n\n        qemu_fseek(f, len_pos, SEEK_SET);\n\n        qemu_put_be32(f, len);\n\n        qemu_fseek(f, cur_pos, SEEK_SET);\n\n    }\n\n    cur_pos = qemu_ftell(f);\n\n    qemu_fseek(f, total_len_pos, SEEK_SET);\n\n    qemu_put_be64(f, cur_pos - total_len_pos - 8);\n\n    qemu_fseek(f, cur_pos, SEEK_SET);\n\n\n\n    ret = 0;\n\n    return ret;\n\n}\n","target":1,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":137162,"func":"void __fastcall TExternalConsole::Print(UnicodeString Str, bool FromBeginning, bool Error)\r\n{\r\n  \/\/ need to do at least one iteration, even when Str is empty (new line)\r\n  do\r\n  {\r\n    TConsoleCommStruct * CommStruct = GetCommStruct();\r\n    try\r\n    {\r\n      size_t MaxLen = LENOF(CommStruct->PrintEvent.Message) - 1;\r\n      UnicodeString Piece = Str.SubString(1, MaxLen);\r\n      Str.Delete(1, MaxLen);\r\n\r\n      CommStruct->Event = TConsoleCommStruct::PRINT;\r\n      wcscpy(CommStruct->PrintEvent.Message, Piece.c_str());\r\n      CommStruct->PrintEvent.FromBeginning = FromBeginning;\r\n      CommStruct->PrintEvent.Error = Error;\r\n\r\n      \/\/ In the next iteration we need to append never overwrite.\r\n      \/\/ Note that this won't work properly for disk\/pipe outputs,\r\n      \/\/ when the next line is also FromBeginning,\r\n      \/\/ as !FromBeginning print effectively commits previous FromBeginning print.\r\n      \/\/ On the other hand, FromBeginning print is always initiated by us,\r\n      \/\/ and it's not likely we ever issue print over 10 KB.\r\n      FromBeginning = false;\r\n    }\r\n    __finally\r\n    {\r\n      FreeCommStruct(CommStruct);\r\n    }\r\n\r\n    SendEvent(INFINITE);\r\n  }\r\n  while (!Str.IsEmpty());\r\n}\r","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":293264,"func":"\nvoid\ncrm_diff_update(const char *event, xmlNode * msg)\n{\n    int rc = -1;\n    long now = time(NULL);\n    const char *op = NULL;\n\n    print_dot();\n\n    if (current_cib != NULL) {\n        xmlNode *cib_last = current_cib;\n        current_cib = NULL;\n\n        rc = cib_apply_patch_event(msg, cib_last, ¤t_cib, LOG_DEBUG);\n        free_xml(cib_last);\n\n        switch(rc) {\n            case pcmk_err_diff_resync:\n            case pcmk_err_diff_failed:\n                crm_warn(\"[%s] %s Patch aborted: %s (%d)\", event, op, pcmk_strerror(rc), rc);\n            case pcmk_ok:\n                break;\n            default:\n                crm_warn(\"[%s] %s ABORTED: %s (%d)\", event, op, pcmk_strerror(rc), rc);\n                return;\n        }\n    }\n\n    if (current_cib == NULL) {\n        current_cib = get_cib_copy(cib);\n    }\n\n    if (crm_mail_to || snmp_target || external_agent) {\n        \/* Process operation updates *\/\n        xmlXPathObject *xpathObj =\n            xpath_search(msg,\n                         \"\/\/\" F_CIB_UPDATE_RESULT \"\/\/\" XML_TAG_DIFF_ADDED \"\/\/\" XML_LRM_TAG_RSC_OP);\n        if (xpathObj && xpathObj->nodesetval->nodeNr > 0) {\n            int lpc = 0, max = xpathObj->nodesetval->nodeNr;\n\n            for (lpc = 0; lpc < max; lpc++) {\n                xmlNode *rsc_op = getXpathResult(xpathObj, lpc);\n\n                handle_rsc_op(rsc_op);\n            }\n        }\n        if (xpathObj) {\n            xmlXPathFreeObject(xpathObj);\n        }\n    }\n\n    if ((now - last_refresh) > (reconnect_msec \/ 1000)) {\n        \/* Force a refresh *\/\n        mon_refresh_display(NULL);\n\n    } else {\n        mainloop_set_trigger(refresh_trigger);","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":264431,"func":"replace_param(char *buf, size_t max_len, char **multiline_ptr_ptr)\n{\n\tchar *cur_pos = buf;\n\tsize_t len_used = strlen(buf);\n\tdef_t *def;\n\tchar *s, *d, *e;\n\tssize_t i;\n\tsize_t extra_braces;\n\tsize_t replacing_len;\n\tchar *next_ptr = NULL;\n\tbool found_defn = false;\n\tchar *multiline_ptr = *multiline_ptr_ptr;\n\n\twhile ((cur_pos = strchr(cur_pos, '$')) && cur_pos[1] != '\\0') {\n\t\tif ((def = find_definition(cur_pos + 1, 0, false))) {\n\t\t\tfound_defn = true;\n\t\t\textra_braces = cur_pos[1] == BOB[0] ? 2 : 0;\n\t\t\tnext_ptr = multiline_ptr;\n\n\t\t\t\/* We are in a multiline expansion, and now have another\n\t\t\t * one, so save the previous state on the multiline stack *\/\n\t\t\tif (def->multiline && multiline_ptr) {\n\t\t\t\tif (!LIST_EXISTS(multiline_stack))\n\t\t\t\t\tmultiline_stack = alloc_list(NULL, NULL);\n\t\t\t\tlist_add(multiline_stack, multiline_ptr);\n\t\t\t}\n\n\t\t\tif (def->fn) {\n\t\t\t\t\/* This is a standard definition that uses a function for the replacement text *\/\n\t\t\t\tif (def->value)\n\t\t\t\t\tFREE(def->value);\n\t\t\t\tdef->value = (*def->fn)();\n\t\t\t\tdef->value_len = strlen(def->value);\n\t\t\t}\n\n\t\t\t\/* Ensure there is enough room to replace $PARAM or ${PARAM} with value *\/\n\t\t\tif (def->multiline) {\n\t\t\t\treplacing_len = strcspn(def->value, DEF_LINE_END);\n\t\t\t\tnext_ptr = def->value + replacing_len + 1;\n\t\t\t\tmultiline_ptr = next_ptr;\n\t\t\t}\n\t\t\telse\n\t\t\t\treplacing_len = def->value_len;\n\n\t\t\tif (len_used + replacing_len - (def->name_len + 1 + extra_braces) >= max_len) {\n\t\t\t\tlog_message(LOG_INFO, \"Parameter substitution on line '%s' would exceed maximum line length\", buf);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tif (def->name_len + 1 + extra_braces != replacing_len) {\n\t\t\t\t\/* We need to move the existing text *\/\n\t\t\t\tif (def->name_len + 1 + extra_braces < replacing_len) {\n\t\t\t\t\t\/* We are lengthening the buf text *\/\n\t\t\t\t\ts = cur_pos + strlen(cur_pos);\n\t\t\t\t\td = s - (def->name_len + 1 + extra_braces) + replacing_len;\n\t\t\t\t\te = cur_pos;\n\t\t\t\t\ti = -1;\n\t\t\t\t} else {\n\t\t\t\t\t\/* We are shortening the buf text *\/\n\t\t\t\t\ts = cur_pos + (def->name_len + 1 + extra_braces) - replacing_len;\n\t\t\t\t\td = cur_pos;\n\t\t\t\t\te = cur_pos + strlen(cur_pos);\n\t\t\t\t\ti = 1;\n\t\t\t\t}\n\n\t\t\t\tdo {\n\t\t\t\t\t*d = *s;\n\t\t\t\t\tif (s == e)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\td += i;\n\t\t\t\t\ts += i;\n\t\t\t\t} while (true);\n\n\t\t\t\tlen_used = len_used + replacing_len - (def->name_len + 1 + extra_braces);\n\t\t\t}\n\n\t\t\t\/* Now copy the replacement text *\/\n\t\t\tstrncpy(cur_pos, def->value, replacing_len);\n\n\t\t\tif (def->value[strspn(def->value, \" \\t\")] == '~')\n\t\t\t\tbreak;\n\t\t}\n\t\telse\n\t\t\tcur_pos++;\n\t}\n\n\t\/* If we did a replacement, update the multiline_ptr *\/\n\tif (found_defn)\n\t\t*multiline_ptr_ptr = next_ptr;\n\n\treturn found_defn;\n}","target":0,"code_token_length":767,"total_token_length":1003,"max_tokens_setting":1024}
+{"idx":394640,"func":"isoent_traverse_tree(struct archive_write *a, struct vdd* vdd)\n{\n\tstruct iso9660 *iso9660 = a->format_data;\n\tstruct isoent *np;\n\tstruct idr idr;\n\tint depth;\n\tint r;\n\tint (*genid)(struct archive_write *, struct isoent *, struct idr *);\n\n\tidr_init(iso9660, vdd, &idr);\n\tnp = vdd->rootent;\n\tdepth = 0;\n\tif (vdd->vdd_type == VDD_JOLIET)\n\t\tgenid = isoent_gen_joliet_identifier;\n\telse\n\t\tgenid = isoent_gen_iso9660_identifier;\n\tdo {\n\t\tif (np->virtual &&\n\t\t    !archive_entry_mtime_is_set(np->file->entry)) {\n\t\t\t\/* Set properly times to virtual directory *\/\n\t\t\tarchive_entry_set_mtime(np->file->entry,\n\t\t\t    iso9660->birth_time, 0);\n\t\t\tarchive_entry_set_atime(np->file->entry,\n\t\t\t    iso9660->birth_time, 0);\n\t\t\tarchive_entry_set_ctime(np->file->entry,\n\t\t\t    iso9660->birth_time, 0);\n\t\t}\n\t\tif (np->children.first != NULL) {\n\t\t\tif (vdd->vdd_type != VDD_JOLIET &&\n\t\t\t    !iso9660->opt.rr && depth + 1 >= vdd->max_depth) {\n\t\t\t\tif (np->children.cnt > 0)\n\t\t\t\t\tiso9660->directories_too_deep = np;\n\t\t\t} else {\n\t\t\t\t\/* Generate Identifier *\/\n\t\t\t\tr = genid(a, np, &idr);\n\t\t\t\tif (r < 0)\n\t\t\t\t\tgoto exit_traverse_tree;\n\t\t\t\tr = isoent_make_sorted_files(a, np, &idr);\n\t\t\t\tif (r < 0)\n\t\t\t\t\tgoto exit_traverse_tree;\n\n\t\t\t\tif (np->subdirs.first != NULL &&\n\t\t\t\t    depth + 1 < vdd->max_depth) {\n\t\t\t\t\t\/* Enter to sub directories. *\/\n\t\t\t\t\tnp = np->subdirs.first;\n\t\t\t\t\tdepth++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\twhile (np != np->parent) {\n\t\t\tif (np->drnext == NULL) {\n\t\t\t\t\/* Return to the parent directory. *\/\n\t\t\t\tnp = np->parent;\n\t\t\t\tdepth--;\n\t\t\t} else {\n\t\t\t\tnp = np->drnext;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} while (np != np->parent);\n\n\tr = ARCHIVE_OK;\nexit_traverse_tree:\n\tidr_cleanup(&idr);\n\n\treturn (r);\n}","target":0,"code_token_length":568,"total_token_length":804,"max_tokens_setting":1024}
+{"idx":499184,"func":"static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,\n                             AVPacket *avpkt)\n{\n    int ret;\n    HEVCContext *s = avctx->priv_data;\n\n    if (!avpkt->size) {\n        ret = ff_hevc_output_frame(s, data, 1);\n        if (ret < 0)\n            return ret;\n\n        *got_output = ret;\n        return 0;\n    }\n\n    s->ref = NULL;\n    ret    = decode_nal_units(s, avpkt->data, avpkt->size);\n    if (ret < 0)\n        return ret;\n\n    \/* verify the SEI checksum *\/\n    if (avctx->err_recognition & AV_EF_CRCCHECK && s->is_decoded &&\n        s->is_md5) {\n        ret = verify_md5(s, s->ref->frame);\n        if (ret < 0 && avctx->err_recognition & AV_EF_EXPLODE) {\n            ff_hevc_unref_frame(s, s->ref, ~0);\n            return ret;\n        }\n    }\n    s->is_md5 = 0;\n\n    if (s->is_decoded) {\n        av_log(avctx, AV_LOG_DEBUG, \"Decoded frame with POC %d.\\n\", s->poc);\n        s->is_decoded = 0;\n    }\n\n    if (s->output_frame->buf[0]) {\n        av_frame_move_ref(data, s->output_frame);\n        *got_output = 1;\n    }\n\n    return avpkt->size;\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":108482,"func":"error_t rza1EthUpdateMacAddrFilter(NetInterface *interface)\n{\n   uint_t i;\n   volatile uint32_t *addrHigh;\n   volatile uint32_t *addrLow;\n   MacFilterEntry *entry;\n\n   \/\/Debug message\n   TRACE_DEBUG(\"Updating MAC filter...\\r\\n\");\n\n   \/\/Set the upper 32 bits of the MAC address\n   ETHER.MAHR0 = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |\n      (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];\n\n   \/\/Set the lower 16 bits of the MAC address\n   ETHER.MALR0 = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];\n\n   \/\/The MAC address filter contains the list of MAC addresses to accept\n   \/\/when receiving an Ethernet frame\n   for(i = 0; i < MAC_ADDR_FILTER_SIZE && i < 32; i++)\n   {\n      \/\/Point to the current entry\n      entry = &interface->macAddrFilter[i];\n\n      \/\/Valid entry?\n      if(entry->refCount > 0)\n      {\n         \/\/Debug message\n         TRACE_DEBUG(\"  %s\\r\\n\", macAddrToString(&entry->addr, NULL));\n\n         \/\/Point to the CAM entry registers\n         addrHigh = ÐER.TSU_ADRH0 + 2 * i;\n         addrLow = ÐER.TSU_ADRL0 + 2 * i;\n\n         \/\/The contents of the CAM entry table registers cannot be\n         \/\/modified while the ADSBSY flag is set\n         while((ETHER.TSU_ADSBSY & ETHER_TSU_ADSBSY_ADSBSY) != 0)\n         {\n         }\n\n         \/\/Set the upper 32 bits of the MAC address\n         *addrHigh = (entry->addr.b[0] << 24) | (entry->addr.b[1] << 16) |\n            (entry->addr.b[2] << 8) | entry->addr.b[3];\n\n         \/\/Wait for the ADSBSY flag to be cleared\n         while((ETHER.TSU_ADSBSY & ETHER_TSU_ADSBSY_ADSBSY) != 0)\n         {\n         }\n\n         \/\/Set the lower 16 bits of the MAC address\n         *addrLow = (entry->addr.b[4] << 8) | entry->addr.b[5];\n\n         \/\/Enable the CAM entry\n         ETHER.TSU_TEN |= 1 << (31 - i);\n      }\n      else\n      {\n         \/\/Disable the CAM entry\n         ETHER.TSU_TEN &= ~(1 << (31 - i));\n      }\n   }\n\n   \/\/Successful processing\n   return NO_ERROR;\n}","target":0,"code_token_length":615,"total_token_length":851,"max_tokens_setting":1024}
+{"idx":468538,"func":"ConnStateData::getSslContextDone(Security::ContextPointer &ctx)\n{\n    if (port->secure.generateHostCertificates && !ctx) {\n        debugs(33, 2, \"Failed to generate TLS context for \" << tlsConnectHostOrIp);\n    }\n\n    \/\/ If generated ssl context = NULL, try to use static ssl context.\n    if (!ctx) {\n        if (!port->secure.staticContext) {\n            debugs(83, DBG_IMPORTANT, \"Closing \" << clientConnection->remote << \" as lacking TLS context\");\n            clientConnection->close();\n            return;\n        } else {\n            debugs(33, 5, \"Using static TLS context.\");\n            ctx = port->secure.staticContext;\n        }\n    }\n\n    if (!httpsCreate(this, ctx))\n        return;\n\n    \/\/ bumped intercepted conns should already have Config.Timeout.request set\n    \/\/ but forwarded connections may only have Config.Timeout.lifetime. [Re]set\n    \/\/ to make sure the connection does not get stuck on non-SSL clients.\n    resetReadTimeout(Config.Timeout.request);\n\n    switchedToHttps_ = true;\n\n    auto ssl = fd_table[clientConnection->fd].ssl.get();\n    BIO *b = SSL_get_rbio(ssl);\n    Ssl::ClientBio *bio = static_cast<Ssl::ClientBio *>(BIO_get_data(b));\n    bio->setReadBufData(inBuf);\n    inBuf.clear();\n    clientNegotiateSSL(clientConnection->fd, this);\n}","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":412846,"func":"xfs_bmap_one_block(\n\txfs_inode_t\t*ip,\t\t\/* incore inode *\/\n\tint\t\twhichfork)\t\/* data or attr fork *\/\n{\n\txfs_ifork_t\t*ifp;\t\t\/* inode fork pointer *\/\n\tint\t\trval;\t\t\/* return value *\/\n\txfs_bmbt_irec_t\ts;\t\t\/* internal version of extent *\/\n\tstruct xfs_iext_cursor icur;\n\n#ifndef DEBUG\n\tif (whichfork == XFS_DATA_FORK)\n\t\treturn XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize;\n#endif\t\/* !DEBUG *\/\n\tif (XFS_IFORK_NEXTENTS(ip, whichfork) != 1)\n\t\treturn 0;\n\tif (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)\n\t\treturn 0;\n\tifp = XFS_IFORK_PTR(ip, whichfork);\n\tASSERT(ifp->if_flags & XFS_IFEXTENTS);\n\txfs_iext_first(ifp, &icur);\n\txfs_iext_get_extent(ifp, &icur, &s);\n\trval = s.br_startoff == 0 && s.br_blockcount == 1;\n\tif (rval && whichfork == XFS_DATA_FORK)\n\t\tASSERT(XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize);\n\treturn rval;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":300002,"func":"static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,\n                      mode_t mode, struct fuse_file_info *fi)\n{\n    int fd;\n    struct lo_data *lo = lo_data(req);\n    struct lo_inode *parent_inode;\n    struct fuse_entry_param e;\n    int err;\n    struct lo_cred old = {};\n\n    fuse_log(FUSE_LOG_DEBUG, \"lo_create(parent=%\" PRIu64 \", name=%s)\\n\", parent,\n             name);\n\n    if (!is_safe_path_component(name)) {\n        fuse_reply_err(req, EINVAL);\n        return;\n    }\n\n    parent_inode = lo_inode(req, parent);\n    if (!parent_inode) {\n        fuse_reply_err(req, EBADF);\n        return;\n    }\n\n    err = lo_change_cred(req, &old);\n    if (err) {\n        goto out;\n    }\n\n    update_open_flags(lo->writeback, lo->allow_direct_io, fi);\n\n    fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,\n                mode);\n    err = fd == -1 ? errno : 0;\n    lo_restore_cred(&old);\n\n    if (!err) {\n        ssize_t fh;\n\n        pthread_mutex_lock(&lo->mutex);\n        fh = lo_add_fd_mapping(req, fd);\n        pthread_mutex_unlock(&lo->mutex);\n        if (fh == -1) {\n            close(fd);\n            err = ENOMEM;\n            goto out;\n        }\n\n        fi->fh = fh;\n        err = lo_do_lookup(req, parent, name, &e);\n    }\n    if (lo->cache == CACHE_NONE) {\n        fi->direct_io = 1;\n    } else if (lo->cache == CACHE_ALWAYS) {\n        fi->keep_cache = 1;\n    }\n\nout:\n    lo_inode_put(lo, &parent_inode);\n\n    if (err) {\n        fuse_reply_err(req, err);\n    } else {\n        fuse_reply_create(req, &e, fi);\n    }\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":250571,"func":"util_getpass (char **lineptr, size_t *len, FILE *stream)\n{\n#define MAX_PASS_SIZE\t128\n\tchar *buf;\n\tsize_t i;\n\tint ch = 0;\n#ifndef _WIN32\n\tstruct termios old, new;\n\n\tfflush(stdout);\n\tif (tcgetattr (fileno (stdout), &old) != 0)\n\t\treturn -1;\n\tnew = old;\n\tnew.c_lflag &= ~ECHO;\n\tif (tcsetattr (fileno (stdout), TCSAFLUSH, &new) != 0)\n\t\treturn -1;\n#endif\n\n\tbuf = calloc(1, MAX_PASS_SIZE);\n\tif (!buf)\n\t\treturn -1;\n\n\tfor (i = 0; i < MAX_PASS_SIZE - 1; i++) {\n#ifndef _WIN32\n\t\tch = getchar();\n#else\n\t\tch = _getch();\n#endif\n\t\tif (ch == 0 || ch == 3)\n\t\t\tbreak;\n\t\tif (ch == '\\n' || ch == '\\r')\n\t\t\tbreak;\n\n\t\tbuf[i] = (char) ch;\n\t}\n#ifndef _WIN32\n\ttcsetattr (fileno (stdout), TCSAFLUSH, &old);\n\tfputs(\"\\n\", stdout);\n#endif\n\tif (ch == 0 || ch == 3) {\n\t\tfree(buf);\n\t\treturn -1;\n\t}\n\n\tif (*lineptr && (!len || *len < i+1)) {\n\t\tfree(*lineptr);\n\t\t*lineptr = NULL;\n\t}\n\n\tif (*lineptr) {\n\t\tmemcpy(*lineptr,buf,i+1);\n\t\tmemset(buf, 0, MAX_PASS_SIZE);\n\t\tfree(buf);\n\t} else {\n\t\t*lineptr = buf;\n\t\tif (len)\n\t\t\t*len = MAX_PASS_SIZE;\n\t}\n\treturn i;\n}\n","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":30006,"func":"static int dtls1_process_out_of_seq_message ( SSL * s , struct hm_header_st * msg_hdr , int * ok ) {\n int i = - 1 ;\n hm_fragment * frag = NULL ;\n pitem * item = NULL ;\n unsigned char seq64be [ 8 ] ;\n unsigned long frag_len = msg_hdr -> frag_len ;\n if ( ( msg_hdr -> frag_off + frag_len ) > msg_hdr -> msg_len ) goto err ;\n memset ( seq64be , 0 , sizeof ( seq64be ) ) ;\n seq64be [ 6 ] = ( unsigned char ) ( msg_hdr -> seq >> 8 ) ;\n seq64be [ 7 ] = ( unsigned char ) msg_hdr -> seq ;\n item = pqueue_find ( s -> d1 -> buffered_messages , seq64be ) ;\n if ( item != NULL && frag_len < msg_hdr -> msg_len ) item = NULL ;\n if ( msg_hdr -> seq <= s -> d1 -> handshake_read_seq || msg_hdr -> seq > s -> d1 -> handshake_read_seq + 10 || item != NULL || ( s -> d1 -> handshake_read_seq == 0 && msg_hdr -> type == SSL3_MT_FINISHED ) ) {\n unsigned char devnull [ 256 ] ;\n while ( frag_len ) {\n i = s -> method -> ssl_read_bytes ( s , SSL3_RT_HANDSHAKE , devnull , frag_len > sizeof ( devnull ) ? sizeof ( devnull ) : frag_len , 0 ) ;\n if ( i <= 0 ) goto err ;\n frag_len -= i ;\n }\n }\n else {\n if ( frag_len && frag_len < msg_hdr -> msg_len ) return dtls1_reassemble_fragment ( s , msg_hdr , ok ) ;\n frag = dtls1_hm_fragment_new ( frag_len , 0 ) ;\n if ( frag == NULL ) goto err ;\n memcpy ( & ( frag -> msg_header ) , msg_hdr , sizeof ( * msg_hdr ) ) ;\n if ( frag_len ) {\n i = s -> method -> ssl_read_bytes ( s , SSL3_RT_HANDSHAKE , frag -> fragment , frag_len , 0 ) ;\n if ( i <= 0 || ( unsigned long ) i != frag_len ) goto err ;\n }\n memset ( seq64be , 0 , sizeof ( seq64be ) ) ;\n seq64be [ 6 ] = ( unsigned char ) ( msg_hdr -> seq >> 8 ) ;\n seq64be [ 7 ] = ( unsigned char ) ( msg_hdr -> seq ) ;\n item = pitem_new ( seq64be , frag ) ;\n if ( item == NULL ) goto err ;\n pqueue_insert ( s -> d1 -> buffered_messages , item ) ;\n }\n return DTLS1_HM_FRAGMENT_RETRY ;\n err : if ( frag != NULL ) dtls1_hm_fragment_free ( frag ) ;\n if ( item != NULL ) OPENSSL_free ( item ) ;\n * ok = 0 ;\n return i ;\n }","target":0,"code_token_length":621,"total_token_length":857,"max_tokens_setting":1024}
+{"idx":434975,"func":"DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,\n                                 unsigned long jpegSize, unsigned char *dstBuf,\n                                 int width, int pad, int height, int flags)\n{\n  unsigned char *dstPlanes[3];\n  int pw0, ph0, strides[3], retval = -1, jpegSubsamp = -1;\n  int i, jpegwidth, jpegheight, scaledw, scaledh;\n\n  GET_DINSTANCE(handle);\n  this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;\n\n  if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || width < 0 ||\n      pad < 1 || !IS_POW2(pad) || height < 0)\n    THROW(\"tjDecompressToYUV2(): Invalid argument\");\n\n  if (setjmp(this->jerr.setjmp_buffer)) {\n    \/* If we get here, the JPEG code has signaled an error. *\/\n    return -1;\n  }\n\n  jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);\n  jpeg_read_header(dinfo, TRUE);\n  jpegSubsamp = getSubsamp(dinfo);\n  if (jpegSubsamp < 0)\n    THROW(\"tjDecompressToYUV2(): Could not determine subsampling type for JPEG image\");\n\n  jpegwidth = dinfo->image_width;  jpegheight = dinfo->image_height;\n  if (width == 0) width = jpegwidth;\n  if (height == 0) height = jpegheight;\n\n  for (i = 0; i < NUMSF; i++) {\n    scaledw = TJSCALED(jpegwidth, sf[i]);\n    scaledh = TJSCALED(jpegheight, sf[i]);\n    if (scaledw <= width && scaledh <= height)\n      break;\n  }\n  if (i >= NUMSF)\n    THROW(\"tjDecompressToYUV2(): Could not scale down to desired image dimensions\");\n\n  pw0 = tjPlaneWidth(0, width, jpegSubsamp);\n  ph0 = tjPlaneHeight(0, height, jpegSubsamp);\n  dstPlanes[0] = dstBuf;\n  strides[0] = PAD(pw0, pad);\n  if (jpegSubsamp == TJSAMP_GRAY) {\n    strides[1] = strides[2] = 0;\n    dstPlanes[1] = dstPlanes[2] = NULL;\n  } else {\n    int pw1 = tjPlaneWidth(1, width, jpegSubsamp);\n    int ph1 = tjPlaneHeight(1, height, jpegSubsamp);\n\n    strides[1] = strides[2] = PAD(pw1, pad);\n    dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;\n    dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;\n  }\n\n  this->headerRead = 1;\n  return tjDecompressToYUVPlanes(handle, jpegBuf, jpegSize, dstPlanes, width,\n                                 strides, height, flags);\n\nbailout:\n  this->jerr.stopOnWarning = FALSE;\n  return retval;\n}","target":0,"code_token_length":698,"total_token_length":934,"max_tokens_setting":1024}
+{"idx":295524,"func":"static ssize_t bm_register_write(struct file *file, const char __user *buffer,\n\t\t\t       size_t count, loff_t *ppos)\n{\n\tNode *e;\n\tstruct inode *inode;\n\tstruct dentry *root, *dentry;\n\tstruct super_block *sb = file->f_path.dentry->d_sb;\n\tint err = 0;\n\n\te = create_entry(buffer, count);\n\n\tif (IS_ERR(e))\n\t\treturn PTR_ERR(e);\n\n\troot = dget(sb->s_root);\n\tmutex_lock(&root->d_inode->i_mutex);\n\tdentry = lookup_one_len(e->name, root, strlen(e->name));\n\terr = PTR_ERR(dentry);\n\tif (IS_ERR(dentry))\n\t\tgoto out;\n\n\terr = -EEXIST;\n\tif (dentry->d_inode)\n\t\tgoto out2;\n\n\tinode = bm_get_inode(sb, S_IFREG | 0644);\n\n\terr = -ENOMEM;\n\tif (!inode)\n\t\tgoto out2;\n\n\terr = simple_pin_fs(&bm_fs_type, &bm_mnt, &entry_count);\n\tif (err) {\n\t\tiput(inode);\n\t\tinode = NULL;\n\t\tgoto out2;\n\t}\n\n\te->dentry = dget(dentry);\n\tinode->i_private = e;\n\tinode->i_fop = &bm_entry_operations;\n\n\td_instantiate(dentry, inode);\n\twrite_lock(&entries_lock);\n\tlist_add(&e->list, &entries);\n\twrite_unlock(&entries_lock);\n\n\terr = 0;\nout2:\n\tdput(dentry);\nout:\n\tmutex_unlock(&root->d_inode->i_mutex);\n\tdput(root);\n\n\tif (err) {\n\t\tkfree(e);\n\t\treturn -EINVAL;\n\t}\n\treturn count;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":332126,"func":"static void parse_numa_node(NumaNodeOptions *node, QemuOpts *opts, Error **errp)\n\n{\n\n    uint16_t nodenr;\n\n    uint16List *cpus = NULL;\n\n\n\n    if (node->has_nodeid) {\n\n        nodenr = node->nodeid;\n\n    } else {\n\n        nodenr = nb_numa_nodes;\n\n    }\n\n\n\n    if (nodenr >= MAX_NODES) {\n\n        error_setg(errp, \"Max number of NUMA nodes reached: %\"\n\n                   PRIu16 \"\", nodenr);\n\n        return;\n\n    }\n\n\n\n    if (numa_info[nodenr].present) {\n\n        error_setg(errp, \"Duplicate NUMA nodeid: %\" PRIu16, nodenr);\n\n        return;\n\n    }\n\n\n\n    for (cpus = node->cpus; cpus; cpus = cpus->next) {\n\n        if (cpus->value >= max_cpus) {\n\n            error_setg(errp,\n\n                       \"CPU index (%\" PRIu16 \")\"\n\n                       \" should be smaller than maxcpus (%d)\",\n\n                       cpus->value, max_cpus);\n\n            return;\n\n        }\n\n        bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);\n\n    }\n\n\n\n    if (node->has_mem && node->has_memdev) {\n\n        error_setg(errp, \"qemu: cannot specify both mem= and memdev=\");\n\n        return;\n\n    }\n\n\n\n    if (have_memdevs == -1) {\n\n        have_memdevs = node->has_memdev;\n\n    }\n\n    if (node->has_memdev != have_memdevs) {\n\n        error_setg(errp, \"qemu: memdev option must be specified for either \"\n\n                   \"all or no nodes\");\n\n        return;\n\n    }\n\n\n\n    if (node->has_mem) {\n\n        uint64_t mem_size = node->mem;\n\n        const char *mem_str = qemu_opt_get(opts, \"mem\");\n\n        \/* Fix up legacy suffix-less format *\/\n\n        if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {\n\n            mem_size <<= 20;\n\n        }\n\n        numa_info[nodenr].node_mem = mem_size;\n\n    }\n\n    if (node->has_memdev) {\n\n        Object *o;\n\n        o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL);\n\n        if (!o) {\n\n            error_setg(errp, \"memdev=%s is ambiguous\", node->memdev);\n\n            return;\n\n        }\n\n\n\n        object_ref(o);\n\n        numa_info[nodenr].node_mem = object_property_get_int(o, \"size\", NULL);\n\n        numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);\n\n    }\n\n    numa_info[nodenr].present = true;\n\n    max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);\n\n}\n","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":7077,"func":"static int br_multicast_add_group(struct net_bridge *br,\n\t\t\t\t  struct net_bridge_port *port,\n\t\t\t\t  struct br_ip *group)\n{\n\tstruct net_bridge_mdb_entry *mp;\n\tstruct net_bridge_port_group *p;\n\tstruct net_bridge_port_group __rcu **pp;\n\tunsigned long now = jiffies;\n\tint err;\n\n\tspin_lock(&br->multicast_lock);\n\tif (!netif_running(br->dev) ||\n\t    (port && port->state == BR_STATE_DISABLED))\n\t\tgoto out;\n\n\tmp = br_multicast_new_group(br, port, group);\n\terr = PTR_ERR(mp);\n\tif (IS_ERR(mp))\n\t\tgoto err;\n\n\tif (!port) {\n\t\thlist_add_head(&mp->mglist, &br->mglist);\n\t\tmod_timer(&mp->timer, now + br->multicast_membership_interval);\n\t\tgoto out;\n\t}\n\n\tfor (pp = &mp->ports;\n\t     (p = mlock_dereference(*pp, br)) != NULL;\n\t     pp = &p->next) {\n\t\tif (p->port == port)\n\t\t\tgoto found;\n\t\tif ((unsigned long)p->port < (unsigned long)port)\n\t\t\tbreak;\n\t}\n\n\tp = kzalloc(sizeof(*p), GFP_ATOMIC);\n\terr = -ENOMEM;\n\tif (unlikely(!p))\n\t\tgoto err;\n\n\tp->addr = *group;\n\tp->port = port;\n\tp->next = *pp;\n\thlist_add_head(&p->mglist, &port->mglist);\n\tsetup_timer(&p->timer, br_multicast_port_group_expired,\n\t\t    (unsigned long)p);\n\tsetup_timer(&p->query_timer, br_multicast_port_group_query_expired,\n\t\t    (unsigned long)p);\n\n\trcu_assign_pointer(*pp, p);\n\nfound:\n\tmod_timer(&p->timer, now + br->multicast_membership_interval);\nout:\n\terr = 0;\n\nerr:\n\tspin_unlock(&br->multicast_lock);\n\treturn err;\n}","target":1,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":501555,"func":"TEST_F(HttpHealthCheckerImplTest, SuccessWithMultipleHosts) {\n  setupNoServiceValidationHC();\n  EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)).Times(2);\n\n  cluster_->prioritySet().getMockHostSet(0)->hosts_ = {\n      makeTestHost(cluster_->info_, \"tcp:\/\/127.0.0.1:80\", simTime()),\n      makeTestHost(cluster_->info_, \"tcp:\/\/127.0.0.1:81\", simTime())};\n  cluster_->info_->stats().upstream_cx_total_.inc();\n  cluster_->info_->stats().upstream_cx_total_.inc();\n  expectSessionCreate();\n  expectStreamCreate(0);\n  EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _));\n  expectSessionCreate();\n  expectStreamCreate(1);\n  EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_, _));\n  health_checker_->start();\n\n  EXPECT_CALL(runtime_.snapshot_, getInteger(\"health_check.max_interval\", _)).Times(2);\n  EXPECT_CALL(runtime_.snapshot_, getInteger(\"health_check.min_interval\", _))\n      .Times(2)\n      .WillRepeatedly(Return(45000));\n  EXPECT_CALL(*test_sessions_[0]->interval_timer_,\n              enableTimer(std::chrono::milliseconds(45000), _));\n  EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer());\n  EXPECT_CALL(*test_sessions_[1]->interval_timer_,\n              enableTimer(std::chrono::milliseconds(45000), _));\n  EXPECT_CALL(*test_sessions_[1]->timeout_timer_, disableTimer());\n  respond(0, \"200\", false, false, true);\n  respond(1, \"200\", false, false, true);\n  EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health());\n  EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[1]->health());\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":95958,"func":"TiledInputFile::initialize ()\n{\n    \/\/ fix bad types in header (arises when a tool built against an older version of\n    \/\/ OpenEXR converts a scanline image to tiled)\n    \/\/ only applies when file is a single part, regular image, tiled file\n    \/\/\n    if(!isMultiPart(_data->version) &&\n       !isNonImage(_data->version) && \n       isTiled(_data->version) && \n       _data->header.hasType() )\n    {\n        _data->header.setType(TILEDIMAGE);\n    }\n    \n    if (_data->partNumber == -1)\n    {\n        if (!isTiled (_data->version))\n            throw IEX_NAMESPACE::ArgExc (\"Expected a tiled file but the file is not tiled.\");\n        \n    }\n    else\n    {\n        if(_data->header.hasType() && _data->header.type()!=TILEDIMAGE)\n        {\n            throw IEX_NAMESPACE::ArgExc (\"TiledInputFile used for non-tiledimage part.\");\n        }\n    }\n    \n    _data->header.sanityCheck (true);\n\n    _data->tileDesc = _data->header.tileDescription();\n    _data->lineOrder = _data->header.lineOrder();\n\n    \/\/\n    \/\/ Save the dataWindow information\n    \/\/\n    \n    const Box2i &dataWindow = _data->header.dataWindow();\n    _data->minX = dataWindow.min.x;\n    _data->maxX = dataWindow.max.x;\n    _data->minY = dataWindow.min.y;\n    _data->maxY = dataWindow.max.y;\n\n    \/\/\n    \/\/ Precompute level and tile information to speed up utility functions\n    \/\/\n\n    precalculateTileInfo (_data->tileDesc,\n\t\t\t  _data->minX, _data->maxX,\n\t\t\t  _data->minY, _data->maxY,\n\t\t\t  _data->numXTiles, _data->numYTiles,\n\t\t\t  _data->numXLevels, _data->numYLevels);    \n\n    _data->bytesPerPixel = calculateBytesPerPixel (_data->header);\n\n    _data->maxBytesPerTileLine = _data->bytesPerPixel * _data->tileDesc.xSize;\n\n    _data->tileBufferSize = _data->maxBytesPerTileLine * _data->tileDesc.ySize;\n\n    \/\/\n    \/\/ Create all the TileBuffers and allocate their internal buffers\n    \/\/\n\n    for (size_t i = 0; i < _data->tileBuffers.size(); i++)\n    {\n        _data->tileBuffers[i] = new TileBuffer (newTileCompressor\n\t\t\t\t\t\t  (_data->header.compression(),\n\t\t\t\t\t\t   _data->maxBytesPerTileLine,\n\t\t\t\t\t\t   _data->tileDesc.ySize,\n\t\t\t\t\t\t   _data->header));\n\n        if (!_data->_streamData->is->isMemoryMapped ())\n            _data->tileBuffers[i]->buffer = new char [_data->tileBufferSize];\n    }\n\n    _data->tileOffsets = TileOffsets (_data->tileDesc.mode,\n\t\t\t\t      _data->numXLevels,\n\t\t\t\t      _data->numYLevels,\n\t\t\t\t      _data->numXTiles,\n\t\t\t\t      _data->numYTiles);\n}","target":0,"code_token_length":658,"total_token_length":894,"max_tokens_setting":1024}
+{"idx":330419,"func":"static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {\n\n    AVStream *st = s->streams[pkt->stream_index];\n\n    int i, ret;\n\n\n\n    if (!(s->flags & AVFMT_FLAG_AUTO_BSF))\n\n        return 1;\n\n\n\n    if (s->oformat->check_bitstream) {\n\n        if (!st->internal->bitstream_checked) {\n\n            if ((ret = s->oformat->check_bitstream(s, pkt)) < 0)\n\n                return ret;\n\n            else if (ret == 1)\n\n                st->internal->bitstream_checked = 1;\n\n        }\n\n    }\n\n\n\n#if FF_API_LAVF_MERGE_SD\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n    if (st->internal->nb_bsfcs) {\n\n        ret = av_packet_split_side_data(pkt);\n\n        if (ret < 0)\n\n            av_log(s, AV_LOG_WARNING, \"Failed to split side data before bitstream filter\\n\");\n\n    }\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n    for (i = 0; i < st->internal->nb_bsfcs; i++) {\n\n        AVBSFContext *ctx = st->internal->bsfcs[i];\n\n        if (i > 0) {\n\n            AVBSFContext* prev_ctx = st->internal->bsfcs[i - 1];\n\n            if (prev_ctx->par_out->extradata_size != ctx->par_in->extradata_size) {\n\n                if ((ret = avcodec_parameters_copy(ctx->par_in, prev_ctx->par_out)) < 0)\n\n                    return ret;\n\n            }\n\n        }\n\n        \/\/ TODO: when any bitstream filter requires flushing at EOF, we'll need to\n\n        \/\/ flush each stream's BSF chain on write_trailer.\n\n        if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) {\n\n            av_log(ctx, AV_LOG_ERROR,\n\n                    \"Failed to send packet to filter %s for stream %d\\n\",\n\n                    ctx->filter->name, pkt->stream_index);\n\n            return ret;\n\n        }\n\n        \/\/ TODO: when any automatically-added bitstream filter is generating multiple\n\n        \/\/ output packets for a single input one, we'll need to call this in a loop\n\n        \/\/ and write each output packet.\n\n        if ((ret = av_bsf_receive_packet(ctx, pkt)) < 0) {\n\n            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)\n\n                return 0;\n\n            av_log(ctx, AV_LOG_ERROR,\n\n                    \"Failed to send packet to filter %s for stream %d\\n\",\n\n                    ctx->filter->name, pkt->stream_index);\n\n            return ret;\n\n        }\n\n        if (i == st->internal->nb_bsfcs - 1) {\n\n            if (ctx->par_out->extradata_size != st->codecpar->extradata_size) {\n\n                if ((ret = avcodec_parameters_copy(st->codecpar, ctx->par_out)) < 0)\n\n                    return ret;\n\n            }\n\n        }\n\n    }\n\n    return 1;\n\n}\n","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":272622,"func":"f_str2nr(typval_T *argvars, typval_T *rettv)\n{\n    int\t\tbase = 10;\n    char_u\t*p;\n    varnumber_T\tn;\n    int\t\twhat;\n    int\t\tisneg;\n\n    if (argvars[1].v_type != VAR_UNKNOWN)\n    {\n\tbase = (int)tv_get_number(&argvars[1]);\n\tif (base != 2 && base != 8 && base != 10 && base != 16)\n\t{\n\t    emsg(_(e_invarg));\n\t    return;\n\t}\n    }\n\n    p = skipwhite(tv_get_string(&argvars[0]));\n    isneg = (*p == '-');\n    if (*p == '+' || *p == '-')\n\tp = skipwhite(p + 1);\n    switch (base)\n    {\n\tcase 2: what = STR2NR_BIN + STR2NR_FORCE; break;\n\tcase 8: what = STR2NR_OCT + STR2NR_FORCE; break;\n\tcase 16: what = STR2NR_HEX + STR2NR_FORCE; break;\n\tdefault: what = 0;\n    }\n    vim_str2nr(p, NULL, NULL, what, &n, NULL, 0);\n    if (isneg)\n\trettv->vval.v_number = -n;\n    else\n\trettv->vval.v_number = n;\n\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":259277,"func":"static int get_passwd_by_systemd(const char *prompt, char *input, int capacity)\n{\n\tint fd[2];\n\tpid_t pid;\n\tint offs = 0;\n\tint rc = 1;\n\n\tif (pipe(fd) == -1) {\n\t\tfprintf(stderr, \"Failed to create pipe: %s\\n\", strerror(errno));\n\t\treturn 1;\n\t}\n\n\tpid = fork();\n\tif (pid == -1) {\n\t\tfprintf(stderr, \"Unable to fork: %s\\n\", strerror(errno));\n\t\tclose(fd[0]);\n\t\tclose(fd[1]);\n\t\treturn 1;\n\t}\n\tif (pid == 0) {\n\t\tclose(fd[0]);\n\t\tdup2(fd[1], STDOUT_FILENO);\n\t\tif (execlp(\"systemd-ask-password\", \"systemd-ask-password\", prompt, NULL) == -1) {\n\t\t\tfprintf(stderr, \"Failed to execute systemd-ask-password: %s\\n\",\n\t\t\t\tstrerror(errno));\n\t\t}\n\t\texit(1);\n\t}\n\n\tclose(fd[1]);\n\tfor (;;) {\n\t\tif (offs+1 >= capacity) {\n\t\t\tfprintf(stderr, \"Password too long.\\n\");\n\t\t\tkill(pid, SIGTERM);\n\t\t\trc = 1;\n\t\t\tbreak;\n\t\t}\n\t\trc = read(fd[0], input + offs, capacity - offs);\n\t\tif (rc == -1) {\n\t\t\tfprintf(stderr, \"Failed to read from pipe: %s\\n\", strerror(errno));\n\t\t\trc = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif (!rc)\n\t\t\tbreak;\n\t\toffs += rc;\n\t\tinput[offs] = '\\0';\n\t}\n\tif (wait(&rc) == -1) {\n\t\tfprintf(stderr, \"Failed to wait child: %s\\n\", strerror(errno));\n\t\trc = 1;\n\t\tgoto out;\n\t}\n\tif (!WIFEXITED(rc) || WEXITSTATUS(rc)) {\n\t\trc = 1;\n\t\tgoto out;\n\t}\n\n\trc = 0;\n\nout:\n\tclose(fd[0]);\n\treturn rc;\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":502601,"func":"int HevcSpsUnit::scaling_list_data()\n{\n    for (int sizeId = 0; sizeId < 4; sizeId++)\n    {\n        for (int matrixId = 0; matrixId < 6; matrixId += (sizeId == 3) ? 3 : 1)\n        {\n            bool flag = m_reader.getBit();\n            if (!flag)\n            {\n                unsigned scaling_list_pred_matrix_id_delta = extractUEGolombCode();\n                if (scaling_list_pred_matrix_id_delta > 5)\n                    return 1;\n            }\n            else\n            {\n                int nextCoef = 8;\n                int coefNum = FFMIN(64, (1 << (4 + (sizeId << 1))));\n                if (sizeId > 1)\n                {\n                    int scaling_list_dc_coef_minus8 = extractSEGolombCode();\n                    nextCoef = scaling_list_dc_coef_minus8 + 8;\n                    if (nextCoef < 1 || nextCoef > 255)\n                        return 1;\n                }\n                for (int i = 0; i < coefNum; i++)\n                {\n                    int scaling_list_delta_coef = extractSEGolombCode();\n                    if (scaling_list_delta_coef < -128 || scaling_list_delta_coef > 127)\n                        return 1;\n                    nextCoef = (nextCoef + scaling_list_delta_coef + 256) % 256;\n                    \/\/ ScalingList[ sizeId ][ matrixId ][ i ] = nextCoef;\n                }\n            }\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":97255,"func":"static int __init init_f2fs_fs(void)\n{\n\tint err;\n\n\tf2fs_build_trace_ios();\n\n\terr = init_inodecache();\n\tif (err)\n\t\tgoto fail;\n\terr = create_node_manager_caches();\n\tif (err)\n\t\tgoto free_inodecache;\n\terr = create_segment_manager_caches();\n\tif (err)\n\t\tgoto free_node_manager_caches;\n\terr = create_checkpoint_caches();\n\tif (err)\n\t\tgoto free_segment_manager_caches;\n\terr = create_extent_cache();\n\tif (err)\n\t\tgoto free_checkpoint_caches;\n\terr = f2fs_init_sysfs();\n\tif (err)\n\t\tgoto free_extent_cache;\n\terr = register_shrinker(&f2fs_shrinker_info);\n\tif (err)\n\t\tgoto free_sysfs;\n\terr = register_filesystem(&f2fs_fs_type);\n\tif (err)\n\t\tgoto free_shrinker;\n\terr = f2fs_create_root_stats();\n\tif (err)\n\t\tgoto free_filesystem;\n\treturn 0;\n\nfree_filesystem:\n\tunregister_filesystem(&f2fs_fs_type);\nfree_shrinker:\n\tunregister_shrinker(&f2fs_shrinker_info);\nfree_sysfs:\n\tf2fs_exit_sysfs();\nfree_extent_cache:\n\tdestroy_extent_cache();\nfree_checkpoint_caches:\n\tdestroy_checkpoint_caches();\nfree_segment_manager_caches:\n\tdestroy_segment_manager_caches();\nfree_node_manager_caches:\n\tdestroy_node_manager_caches();\nfree_inodecache:\n\tdestroy_inodecache();\nfail:\n\treturn err;\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":165731,"func":"static bool parse_args(int argc, char **argv) {\n while (1) {\n int option_index = 0;\n int c = getopt_long_only(argc, argv, \"\", long_options, &option_index);\n if (c != 0)\n break;\n\n switch (c) {\n case 0:\n if (option_index == 0) {\n if (!string_to_bdaddr(optarg, &bt_remote_bdaddr)) {\n return false;\n }\n }\n if (option_index == 1) {\n          discover = true;\n }\n if (option_index == 2) {\n          discoverable = true;\n }\n if (option_index == 3) {\n          timeout_in_sec = atoi(optarg);\n }\n if (option_index == 4) {\n          bond  = true;\n }\n if (option_index == 5) {\n          up = true;\n }\n if (option_index == 6) {\n          f_verbose++;\n }\n if (option_index == 7) {\n          get_name = true;\n }\n if (option_index == 8) {\n          bd_name = (char *)optarg;\n          set_name = true;\n }\n if (option_index == 9) {\n          sco_listen = true;\n }\n if (option_index == 10) {\n          sco_connect = true;\n }\n break;\n\n default:\n        fprintf(stderr, \"?? getopt returned character code 0%o ??\\n\", c);\n }\n }\n\n if (optind < argc) {\n    fprintf(stderr, \"non-option ARGV-elements: \");\n while (optind < argc)\n      fprintf(stderr, \"%s \", argv[optind++]);\n    fprintf(stderr, \"\\n\");\n return false;\n }\n return true;\n}\n","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":291786,"func":"messageSetMimeType(message *mess, const char *type)\n{\n#ifdef\tCL_THREAD_SAFE\n\tstatic pthread_mutex_t mime_mutex = PTHREAD_MUTEX_INITIALIZER;\n#endif\n\tconst struct mime_map *m;\n\tint typeval;\n\tstatic table_t *mime_table;\n\n\tassert(mess != NULL);\n\tif(type == NULL) {\n\t\tcli_dbgmsg(\"Empty content-type field\\n\");\n\t\treturn 0;\n\t}\n\n\tcli_dbgmsg(\"messageSetMimeType: '%s'\\n\", type);\n\n\t\/* Ignore leading spaces *\/\n\twhile(!isalpha(*type))\n\t\tif(*type++ == '\\0')\n\t\t\treturn 0;\n\n#ifdef\tCL_THREAD_SAFE\n\tpthread_mutex_lock(&mime_mutex);\n#endif\n\tif(mime_table == NULL) {\n\t\tmime_table = tableCreate();\n\t\tif(mime_table == NULL) {\n#ifdef\tCL_THREAD_SAFE\n\t\t\tpthread_mutex_unlock(&mime_mutex);\n#endif\n\t\t\treturn 0;\n\t\t}\n\n\t\tfor(m = mime_map; m->string; m++)\n\t\t\tif(!tableInsert(mime_table, m->string, m->type)) {\n\t\t\t\ttableDestroy(mime_table);\n\t\t\t\tmime_table = NULL;\n#ifdef\tCL_THREAD_SAFE\n\t\t\t\tpthread_mutex_unlock(&mime_mutex);\n#endif\n\t\t\t\treturn 0;\n\t\t\t}\n\t}\n#ifdef\tCL_THREAD_SAFE\n\tpthread_mutex_unlock(&mime_mutex);\n#endif\n\n\ttypeval = tableFind(mime_table, type);\n\n\tif(typeval != -1) {\n\t\tmess->mimeType = (mime_type)typeval;\n\t\treturn 1;\n\t}\n\tif(mess->mimeType == NOMIME) {\n\t\tif(strncasecmp(type, \"x-\", 2) == 0)\n\t\t\tmess->mimeType = MEXTENSION;\n\t\telse {\n\t\t\t\/*\n\t\t\t * Force scanning of strange messages\n\t\t\t *\/\n\t\t\tif(strcasecmp(type, \"plain\") == 0) {\n\t\t\t\tcli_dbgmsg(\"Incorrect MIME type: `plain', set to Text\\n\");\n\t\t\t\tmess->mimeType = TEXT;\n\t\t\t} else {\n\t\t\t\t\/*\n\t\t\t\t * Don't handle broken e-mail probably sending\n\t\t\t\t *\tContent-Type: plain\/text\n\t\t\t\t * instead of\n\t\t\t\t *\tContent-Type: text\/plain\n\t\t\t\t * as an attachment\n\t\t\t\t *\/\n\t\t\t\tint highestSimil = 0, t = -1;\n\t\t\t\tconst char *closest = NULL;\n\n\t\t\t\tfor(m = mime_map; m->string; m++) {\n\t\t\t\t\tconst int s = simil(m->string, type);\n\n\t\t\t\t\tif(s > highestSimil) {\n\t\t\t\t\t\thighestSimil = s;\n\t\t\t\t\t\tclosest = m->string;\n\t\t\t\t\t\tt = m->type;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(highestSimil >= 50) {\n\t\t\t\t\tcli_dbgmsg(\"Unknown MIME type \\\"%s\\\" - guessing as %s (%d%% certainty)\\n\",\n\t\t\t\t\t\ttype, closest,\n\t\t\t\t\t\thighestSimil);\n\t\t\t\t\tmess->mimeType = (mime_type)t;\n\t\t\t\t} else {\n\t\t\t\t\tcli_dbgmsg(\"Unknown MIME type: `%s', set to Application - if you believe this file contains a virus, submit it to www.clamav.net\\n\", type);\n\t\t\t\t\tmess->mimeType = APPLICATION;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn 1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":90533,"func":"void _yr_re_print_node(\n    RE_NODE* re_node)\n{\n  int i;\n\n  if (re_node == NULL)\n    return;\n\n  switch(re_node->type)\n  {\n  case RE_NODE_ALT:\n    printf(\"Alt(\");\n    _yr_re_print_node(re_node->left);\n    printf(\", \");\n    _yr_re_print_node(re_node->right);\n    printf(\")\");\n    break;\n\n  case RE_NODE_CONCAT:\n    printf(\"Cat(\");\n    _yr_re_print_node(re_node->left);\n    printf(\", \");\n    _yr_re_print_node(re_node->right);\n    printf(\")\");\n    break;\n\n  case RE_NODE_STAR:\n    printf(\"Star(\");\n    _yr_re_print_node(re_node->left);\n    printf(\")\");\n    break;\n\n  case RE_NODE_PLUS:\n    printf(\"Plus(\");\n    _yr_re_print_node(re_node->left);\n    printf(\")\");\n    break;\n\n  case RE_NODE_LITERAL:\n    printf(\"Lit(%02X)\", re_node->value);\n    break;\n\n  case RE_NODE_MASKED_LITERAL:\n    printf(\"MaskedLit(%02X,%02X)\", re_node->value, re_node->mask);\n    break;\n\n  case RE_NODE_WORD_CHAR:\n    printf(\"WordChar\");\n    break;\n\n  case RE_NODE_NON_WORD_CHAR:\n    printf(\"NonWordChar\");\n    break;\n\n  case RE_NODE_SPACE:\n    printf(\"Space\");\n    break;\n\n  case RE_NODE_NON_SPACE:\n    printf(\"NonSpace\");\n    break;\n\n  case RE_NODE_DIGIT:\n    printf(\"Digit\");\n    break;\n\n  case RE_NODE_NON_DIGIT:\n    printf(\"NonDigit\");\n    break;\n\n  case RE_NODE_ANY:\n    printf(\"Any\");\n    break;\n\n  case RE_NODE_RANGE:\n    printf(\"Range(%d-%d, \", re_node->start, re_node->end);\n    _yr_re_print_node(re_node->left);\n    printf(\")\");\n    break;\n\n  case RE_NODE_CLASS:\n    printf(\"Class(\");\n    for (i = 0; i < 256; i++)\n      if (CHAR_IN_CLASS(i, re_node->class_vector))\n        printf(\"%02X,\", i);\n    printf(\")\");\n    break;\n\n  default:\n    printf(\"???\");\n    break;\n  }\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":129816,"func":"static MagickBooleanType ReadPSDChannelPixels(Image *image,\n  const size_t channels,const size_t row,const ssize_t type,\n  const unsigned char *pixels,ExceptionInfo *exception)\n{\n  Quantum\n    pixel;\n\n  register const unsigned char\n    *p;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    x;\n\n  size_t\n    packet_size;\n\n  unsigned short\n    nibble;\n\n  p=pixels;\n  q=GetAuthenticPixels(image,0,row,image->columns,1,exception);\n  if (q == (Quantum *) NULL)\n    return MagickFalse;\n  packet_size=GetPSDPacketSize(image);\n  for (x=0; x < (ssize_t) image->columns; x++)\n  {\n    if (packet_size == 1)\n      pixel=ScaleCharToQuantum(*p++);\n    else\n      {\n        p=PushShortPixel(MSBEndian,p,&nibble);\n        pixel=ScaleShortToQuantum(nibble);\n      }\n    if (image->depth > 1)\n      {\n        SetPSDPixel(image,channels,type,packet_size,pixel,q,exception);\n        q+=GetPixelChannels(image);\n      }\n    else\n      {\n        ssize_t\n          bit,\n          number_bits;\n      \n        number_bits=image->columns-x;\n        if (number_bits > 8)\n          number_bits=8;\n        for (bit = 0; bit < number_bits; bit++)\n        {\n          SetPSDPixel(image,channels,type,packet_size,(((unsigned char) pixel)\n            & (0x01 << (7-bit))) != 0 ? 0 : QuantumRange,q,exception);\n          q+=GetPixelChannels(image);\n          x++;\n        }\n        if (x != (ssize_t) image->columns)\n          x--;\n        continue;\n      }\n  }\n  return(SyncAuthenticPixels(image,exception));\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":461454,"func":"static int stat_to_qid(V9fsPDU *pdu, const struct stat *stbuf, V9fsQID *qidp)\n{\n    int err;\n    size_t size;\n\n    if (pdu->s->ctx.export_flags & V9FS_REMAP_INODES) {\n        \/* map inode+device to qid path (fast path) *\/\n        err = qid_path_suffixmap(pdu, stbuf, &qidp->path);\n        if (err == -ENFILE) {\n            \/* fast path didn't work, fall back to full map *\/\n            err = qid_path_fullmap(pdu, stbuf, &qidp->path);\n        }\n        if (err) {\n            return err;\n        }\n    } else {\n        if (pdu->s->dev_id != stbuf->st_dev) {\n            if (pdu->s->ctx.export_flags & V9FS_FORBID_MULTIDEVS) {\n                error_report_once(\n                    \"9p: Multiple devices detected in same VirtFS export. \"\n                    \"Access of guest to additional devices is (partly) \"\n                    \"denied due to virtfs option 'multidevs=forbid' being \"\n                    \"effective.\"\n                );\n                return -ENODEV;\n            } else {\n                warn_report_once(\n                    \"9p: Multiple devices detected in same VirtFS export, \"\n                    \"which might lead to file ID collisions and severe \"\n                    \"misbehaviours on guest! You should either use a \"\n                    \"separate export for each device shared from host or \"\n                    \"use virtfs option 'multidevs=remap'!\"\n                );\n            }\n        }\n        memset(&qidp->path, 0, sizeof(qidp->path));\n        size = MIN(sizeof(stbuf->st_ino), sizeof(qidp->path));\n        memcpy(&qidp->path, &stbuf->st_ino, size);\n    }\n\n    qidp->version = stbuf->st_mtime ^ (stbuf->st_size << 8);\n    qidp->type = 0;\n    if (S_ISDIR(stbuf->st_mode)) {\n        qidp->type |= P9_QID_TYPE_DIR;\n    }\n    if (S_ISLNK(stbuf->st_mode)) {\n        qidp->type |= P9_QID_TYPE_SYMLINK;\n    }\n\n    return 0;\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":88983,"func":"static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,\n\t\t\t\t  nodemask_t *nodes)\n{\n\tstruct mempolicy *policy;\n\n\tpr_debug(\"setting mode %d flags %d nodes[0] %lx\\n\",\n\t\t mode, flags, nodes ? nodes_addr(*nodes)[0] : NUMA_NO_NODE);\n\n\tif (mode == MPOL_DEFAULT) {\n\t\tif (nodes && !nodes_empty(*nodes))\n\t\t\treturn ERR_PTR(-EINVAL);\n\t\treturn NULL;\n\t}\n\tVM_BUG_ON(!nodes);\n\n\t\/*\n\t * MPOL_PREFERRED cannot be used with MPOL_F_STATIC_NODES or\n\t * MPOL_F_RELATIVE_NODES if the nodemask is empty (local allocation).\n\t * All other modes require a valid pointer to a non-empty nodemask.\n\t *\/\n\tif (mode == MPOL_PREFERRED) {\n\t\tif (nodes_empty(*nodes)) {\n\t\t\tif (((flags & MPOL_F_STATIC_NODES) ||\n\t\t\t     (flags & MPOL_F_RELATIVE_NODES)))\n\t\t\t\treturn ERR_PTR(-EINVAL);\n\t\t}\n\t} else if (mode == MPOL_LOCAL) {\n\t\tif (!nodes_empty(*nodes) ||\n\t\t    (flags & MPOL_F_STATIC_NODES) ||\n\t\t    (flags & MPOL_F_RELATIVE_NODES))\n\t\t\treturn ERR_PTR(-EINVAL);\n\t\tmode = MPOL_PREFERRED;\n\t} else if (nodes_empty(*nodes))\n\t\treturn ERR_PTR(-EINVAL);\n\tpolicy = kmem_cache_alloc(policy_cache, GFP_KERNEL);\n\tif (!policy)\n\t\treturn ERR_PTR(-ENOMEM);\n\tatomic_set(&policy->refcnt, 1);\n\tpolicy->mode = mode;\n\tpolicy->flags = flags;\n\n\treturn policy;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":472889,"func":"static int hw_atl_utils_init_ucp(struct aq_hw_s *self,\n\t\t\t\t const struct aq_hw_caps_s *aq_hw_caps)\n{\n\tint err = 0;\n\n\tif (!aq_hw_read_reg(self, 0x370U)) {\n\t\tunsigned int rnd = 0U;\n\t\tunsigned int ucp_0x370 = 0U;\n\n\t\tget_random_bytes(&rnd, sizeof(unsigned int));\n\n\t\tucp_0x370 = 0x02020202U | (0xFEFEFEFEU & rnd);\n\t\taq_hw_write_reg(self, HW_ATL_UCP_0X370_REG, ucp_0x370);\n\t}\n\n\thw_atl_reg_glb_cpu_scratch_scp_set(self, 0x00000000U, 25U);\n\n\t\/* check 10 times by 1ms *\/\n\terr = readx_poll_timeout_atomic(hw_atl_scrpad25_get,\n\t\t\t\t\tself, self->mbox_addr,\n\t\t\t\t\tself->mbox_addr != 0U,\n\t\t\t\t\t1000U, 10000U);\n\terr = readx_poll_timeout_atomic(aq_fw1x_rpc_get, self,\n\t\t\t\t\tself->rpc_addr,\n\t\t\t\t\tself->rpc_addr != 0U,\n\t\t\t\t\t1000U, 100000U);\n\n\treturn err;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":40572,"func":"static int recheck_discard_flags(AVFormatContext *s, int first)\n{\n    HLSContext *c = s->priv_data;\n    int i, changed = 0;\n\n    \/* Check if any new streams are needed *\/\n    for (i = 0; i < c->n_playlists; i++)\n        c->playlists[i]->cur_needed = 0;\n\n    for (i = 0; i < s->nb_streams; i++) {\n        AVStream *st = s->streams[i];\n        struct playlist *pls = c->playlists[s->streams[i]->id];\n        if (st->discard < AVDISCARD_ALL)\n            pls->cur_needed = 1;\n    }\n    for (i = 0; i < c->n_playlists; i++) {\n        struct playlist *pls = c->playlists[i];\n        if (pls->cur_needed && !pls->needed) {\n            pls->needed = 1;\n            changed = 1;\n            pls->cur_seq_no = select_cur_seq_no(c, pls);\n            pls->pb.eof_reached = 0;\n            if (c->cur_timestamp != AV_NOPTS_VALUE) {\n                \/* catch up *\/\n                pls->seek_timestamp = c->cur_timestamp;\n                pls->seek_flags = AVSEEK_FLAG_ANY;\n                pls->seek_stream_index = -1;\n            }\n            av_log(s, AV_LOG_INFO, \"Now receiving playlist %d, segment %d\\n\", i, pls->cur_seq_no);\n        } else if (first && !pls->cur_needed && pls->needed) {\n            if (pls->input)\n                ff_format_io_close(pls->parent, &pls->input);\n            pls->needed = 0;\n            changed = 1;\n            av_log(s, AV_LOG_INFO, \"No longer receiving playlist %d\\n\", i);\n        }\n    }\n    return changed;\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":422998,"func":"\nstatic int process_backlog(struct napi_struct *napi, int quota)\n{\n\tint work = 0;\n\tstruct softnet_data *sd = container_of(napi, struct softnet_data, backlog);\n\n#ifdef CONFIG_RPS\n\t\/* Check if we have pending ipi, its better to send them now,\n\t * not waiting net_rx_action() end.\n\t *\/\n\tif (sd->rps_ipi_list) {\n\t\tlocal_irq_disable();\n\t\tnet_rps_action_and_irq_enable(sd);\n\t}\n#endif\n\tnapi->weight = weight_p;\n\tlocal_irq_disable();\n\twhile (work < quota) {\n\t\tstruct sk_buff *skb;\n\t\tunsigned int qlen;\n\n\t\twhile ((skb = __skb_dequeue(&sd->process_queue))) {\n\t\t\tlocal_irq_enable();\n\t\t\t__netif_receive_skb(skb);\n\t\t\tlocal_irq_disable();\n\t\t\tinput_queue_head_incr(sd);\n\t\t\tif (++work >= quota) {\n\t\t\t\tlocal_irq_enable();\n\t\t\t\treturn work;\n\t\t\t}\n\t\t}\n\n\t\trps_lock(sd);\n\t\tqlen = skb_queue_len(&sd->input_pkt_queue);\n\t\tif (qlen)\n\t\t\tskb_queue_splice_tail_init(&sd->input_pkt_queue,\n\t\t\t\t\t\t   &sd->process_queue);\n\n\t\tif (qlen < quota - work) {\n\t\t\t\/*\n\t\t\t * Inline a custom version of __napi_complete().\n\t\t\t * only current cpu owns and manipulates this napi,\n\t\t\t * and NAPI_STATE_SCHED is the only possible flag set on backlog.\n\t\t\t * we can use a plain write instead of clear_bit(),\n\t\t\t * and we dont need an smp_mb() memory barrier.\n\t\t\t *\/\n\t\t\tlist_del(&napi->poll_list);\n\t\t\tnapi->state = 0;\n\n\t\t\tquota = work + qlen;\n\t\t}\n\t\trps_unlock(sd);\n\t}\n\tlocal_irq_enable();\n\n\treturn work;","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":510707,"func":"bool ha_partition::initialize_partition(MEM_ROOT *mem_root)\n{\n  handler **file_array, *file;\n  ulonglong check_table_flags;\n  DBUG_ENTER(\"ha_partition::initialize_partition\");\n\n  if (m_create_handler)\n  {\n    m_tot_parts= m_part_info->get_tot_partitions();\n    DBUG_ASSERT(m_tot_parts > 0);\n    if (new_handlers_from_part_info(mem_root))\n      DBUG_RETURN(1);\n  }\n  else if (!table_share || !table_share->normalized_path.str)\n  {\n    \/*\n      Called with dummy table share (delete, rename and alter table).\n      Don't need to set-up anything.\n    *\/\n    DBUG_RETURN(0);\n  }\n  else if (get_from_handler_file(table_share->normalized_path.str,\n                                 mem_root, false))\n  {\n    my_error(ER_FAILED_READ_FROM_PAR_FILE, MYF(0));\n    DBUG_RETURN(1);\n  }\n  \/*\n    We create all underlying table handlers here. We do it in this special\n    method to be able to report allocation errors.\n\n    Set up primary_key_is_clustered and\n    has_transactions since they are called often in all kinds of places,\n    other parameters are calculated on demand.\n    Verify that all partitions have the same table_flags.\n  *\/\n  check_table_flags= m_file[0]->ha_table_flags();\n  m_pkey_is_clustered= TRUE;\n  file_array= m_file;\n  do\n  {\n    file= *file_array;\n    if (!file->primary_key_is_clustered())\n      m_pkey_is_clustered= FALSE;\n    if (check_table_flags != file->ha_table_flags())\n    {\n      my_error(ER_MIX_HANDLER_ERROR, MYF(0));\n      DBUG_RETURN(1);\n    }\n  } while (*(++file_array));\n  m_handler_status= handler_initialized;\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":81926,"func":"hfs_cat_read_thread_record(HFS_INFO * hfs, TSK_OFF_T off,\n    hfs_thread * thread)\n{\n    TSK_FS_INFO *fs = (TSK_FS_INFO *) & (hfs->fs_info);\n    uint16_t uni_len;\n    ssize_t cnt;\n\n    memset(thread, 0, sizeof(hfs_thread));\n    cnt = tsk_fs_attr_read(hfs->catalog_attr, off, (char *) thread, 10, 0);\n    if (cnt != 10) {\n        if (cnt >= 0) {\n            tsk_error_reset();\n            tsk_error_set_errno(TSK_ERR_FS_READ);\n        }\n        tsk_error_set_errstr2\n            (\"hfs_cat_read_thread_record: Error reading catalog offset %\"\n            PRIuOFF \" (header)\", off);\n        return 1;\n    }\n\n    if ((tsk_getu16(fs->endian, thread->rec_type) != HFS_FOLDER_THREAD)\n        && (tsk_getu16(fs->endian, thread->rec_type) != HFS_FILE_THREAD)) {\n        tsk_error_set_errno(TSK_ERR_FS_GENFS);\n        tsk_error_set_errstr\n            (\"hfs_cat_read_thread_record: unexpected record type %\" PRIu16,\n            tsk_getu16(fs->endian, thread->rec_type));\n        return 1;\n    }\n\n    uni_len = tsk_getu16(fs->endian, thread->name.length);\n\n    if (uni_len > 255) {\n        tsk_error_set_errno(TSK_ERR_FS_INODE_COR);\n        tsk_error_set_errstr\n            (\"hfs_cat_read_thread_record: invalid string length (%\" PRIu16\n            \")\", uni_len);\n        return 1;\n    }\n\n    cnt =\n        tsk_fs_attr_read(hfs->catalog_attr, off + 10,\n        (char *) thread->name.unicode, uni_len * 2, 0);\n    if (cnt != uni_len * 2) {\n        if (cnt >= 0) {\n            tsk_error_reset();\n            tsk_error_set_errno(TSK_ERR_FS_READ);\n        }\n        tsk_error_set_errstr2\n            (\"hfs_cat_read_thread_record: Error reading catalog offset %\"\n            PRIuOFF \" (name)\", off + 10);\n        return 1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":514,"total_token_length":750,"max_tokens_setting":1024}
+{"idx":493547,"func":"HIDDEN int mailbox_changequotaroot(struct mailbox *mailbox,\n                                   const char *root, int silent)\n{\n    int r = 0;\n    int res;\n    quota_t quota_usage[QUOTA_NUMRESOURCES];\n\n    mailbox_get_usage(mailbox, quota_usage);\n\n    if (mailbox->h.quotaroot) {\n        quota_t quota_diff[QUOTA_NUMRESOURCES];\n\n        if (root) {\n            size_t len = strlen(root);\n            if (strlen(mailbox->h.quotaroot) >= len && !strncmp(mailbox->h.quotaroot, root, len) &&\n                (mailbox->h.quotaroot[len] == '\\0' || mailbox->h.quotaroot[len] == '.')) {\n                    \/* Part of a child quota root - skip *\/\n                    goto done;\n            }\n        }\n\n        \/* remove usage from the old quotaroot *\/\n        for (res = 0; res < QUOTA_NUMRESOURCES ; res++) {\n            quota_diff[res] = -quota_usage[res];\n        }\n        r = quota_update_useds(mailbox->h.quotaroot, quota_diff,\n                               mailbox_name(mailbox), silent);\n    }\n\n    \/* update (or set) the quotaroot *\/\n    mailbox_set_quotaroot(mailbox, root);\n\n    if (root) {\n        \/* update the new quota root *\/\n        r = quota_update_useds(root, quota_usage, mailbox_name(mailbox), silent);\n    }\n\n  done:\n    return r;\n}","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":355127,"func":"static int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,\n\t\t\tstruct splice_desc *sd)\n{\n\tstruct file *file = sd->u.file;\n\tstruct address_space *mapping = file->f_mapping;\n\tunsigned int offset, this_len;\n\tstruct page *page;\n\tvoid *fsdata;\n\tint ret;\n\n\t\/*\n\t * make sure the data in this buffer is uptodate\n\t *\/\n\tret = buf->ops->confirm(pipe, buf);\n\tif (unlikely(ret))\n\t\treturn ret;\n\n\toffset = sd->pos & ~PAGE_CACHE_MASK;\n\n\tthis_len = sd->len;\n\tif (this_len + offset > PAGE_CACHE_SIZE)\n\t\tthis_len = PAGE_CACHE_SIZE - offset;\n\n\tret = pagecache_write_begin(file, mapping, sd->pos, this_len,\n\t\t\t\tAOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);\n\tif (unlikely(ret))\n\t\tgoto out;\n\n\tif (buf->page != page) {\n\t\t\/*\n\t\t * Careful, ->map() uses KM_USER0!\n\t\t *\/\n\t\tchar *src = buf->ops->map(pipe, buf, 1);\n\t\tchar *dst = kmap_atomic(page, KM_USER1);\n\n\t\tmemcpy(dst + offset, src + buf->offset, this_len);\n\t\tflush_dcache_page(page);\n\t\tkunmap_atomic(dst, KM_USER1);\n\t\tbuf->ops->unmap(pipe, buf, src);\n\t}\n\tret = pagecache_write_end(file, mapping, sd->pos, this_len, this_len,\n\t\t\t\tpage, fsdata);\nout:\n\treturn ret;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":231119,"func":"GahpClient::condor_job_stage_in(const char *schedd_name, ClassAd *job_ad)\n{\n\tstatic const char* command = \"CONDOR_JOB_STAGE_IN\";\n\n\tMyString ad_string;\n\n\tif  (server->m_commands_supported->contains_anycase(command)==FALSE) {\n\t\treturn GAHPCLIENT_COMMAND_NOT_SUPPORTED;\n\t}\n\n\tif (!schedd_name) schedd_name=NULLSTRING;\n\tif (!job_ad) {\n\t\tad_string=NULLSTRING;\n\t} else {\n\t\tif ( useXMLClassads ) {\n\t\t\tClassAdXMLUnparser unparser;\n\t\t\tunparser.SetUseCompactSpacing( true );\n\t\t\tunparser.SetOutputType( false );\n\t\t\tunparser.SetOutputTargetType( false );\n\t\t\tunparser.Unparse( job_ad, ad_string );\n\t\t} else {\n\t\t\tNewClassAdUnparser unparser;\n\t\t\tunparser.SetUseCompactSpacing( true );\n\t\t\tunparser.SetOutputType( false );\n\t\t\tunparser.SetOutputTargetType( false );\n\t\t\tunparser.Unparse( job_ad, ad_string );\n\t\t}\n\t}\n\tstd::string reqline;\n\tchar *esc1 = strdup( escapeGahpString(schedd_name) );\n\tchar *esc2 = strdup( escapeGahpString(ad_string.Value()) );\n\tint x = sprintf(reqline, \"%s %s\", esc1, esc2);\n\tfree( esc1 );\n\tfree( esc2 );\n\tASSERT( x > 0 );\n\tconst char *buf = reqline.c_str();\n\n\tif ( !is_pending(command,buf) ) {\n\t\tif ( m_mode == results_only ) {\n\t\t\treturn GAHPCLIENT_COMMAND_NOT_SUBMITTED;\n\t\t}\n\t\tnow_pending(command,buf,deleg_proxy);\n\t}\n\n\t\t\n\tGahp_Args* result = get_pending_result(command,buf);\n\tif ( result ) {\n\t\tif (result->argc != 3) {\n\t\t\tEXCEPT(\"Bad %s Result\",command);\n\t\t}\n\t\tint rc = 1;\n\t\tif ( result->argv[1][0] == 'S' ) {\n\t\t\trc = 0;\n\t\t}\n\t\tif ( strcasecmp(result->argv[2], NULLSTRING) ) {\n\t\t\terror_string = result->argv[2];\n\t\t} else {\n\t\t\terror_string = \"\";\n\t\t}\n\t\tdelete result;\n\t\treturn rc;\n\t}\n\n\tif ( check_pending_timeout(command,buf) ) {\n\t\tsprintf( error_string, \"%s timed out\", command );\n\t\treturn GAHPCLIENT_COMMAND_TIMED_OUT;\n\t}\n\n\treturn GAHPCLIENT_COMMAND_PENDING;\n}\n","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":82721,"func":"vim_regexec_string(\n    regmatch_T\t*rmp,\n    char_u\t*line,  \/\/ string to match against\n    colnr_T\tcol,    \/\/ column to start looking for match\n    int\t\tnl)\n{\n    int\t\tresult;\n    regexec_T\trex_save;\n    int\t\trex_in_use_save = rex_in_use;\n\n    \/\/ Cannot use the same prog recursively, it contains state.\n    if (rmp->regprog->re_in_use)\n    {\n\temsg(_(e_cannot_use_pattern_recursively));\n\treturn FALSE;\n    }\n    rmp->regprog->re_in_use = TRUE;\n\n    if (rex_in_use)\n\t\/\/ Being called recursively, save the state.\n\trex_save = rex;\n    rex_in_use = TRUE;\n\n    rex.reg_startp = NULL;\n    rex.reg_endp = NULL;\n    rex.reg_startpos = NULL;\n    rex.reg_endpos = NULL;\n\n    result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl);\n    rmp->regprog->re_in_use = FALSE;\n\n    \/\/ NFA engine aborted because it's very slow.\n    if (rmp->regprog->re_engine == AUTOMATIC_ENGINE\n\t\t\t\t\t       && result == NFA_TOO_EXPENSIVE)\n    {\n\tint    save_p_re = p_re;\n\tint    re_flags = rmp->regprog->re_flags;\n\tchar_u *pat = vim_strsave(((nfa_regprog_T *)rmp->regprog)->pattern);\n\n\tp_re = BACKTRACKING_ENGINE;\n\tvim_regfree(rmp->regprog);\n\tif (pat != NULL)\n\t{\n#ifdef FEAT_EVAL\n\t    report_re_switch(pat);\n#endif\n\t    rmp->regprog = vim_regcomp(pat, re_flags);\n\t    if (rmp->regprog != NULL)\n\t    {\n\t\trmp->regprog->re_in_use = TRUE;\n\t\tresult = rmp->regprog->engine->regexec_nl(rmp, line, col, nl);\n\t\trmp->regprog->re_in_use = FALSE;\n\t    }\n\t    vim_free(pat);\n\t}\n\n\tp_re = save_p_re;\n    }\n\n    rex_in_use = rex_in_use_save;\n    if (rex_in_use)\n\trex = rex_save;\n\n    return result > 0;\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":106098,"func":"TRIO_PUBLIC trio_pointer_t trio_register TRIO_ARGS2((callback, name), trio_callback_t callback,\n                                                    TRIO_CONST char* name)\n{\n\ttrio_userdef_t* def;\n\ttrio_userdef_t* prev = NULL;\n\n\tif (callback == NULL)\n\t\treturn NULL;\n\n\tif (name)\n\t{\n\t\t\/* Handle built-in namespaces *\/\n\t\tif (name[0] == ':')\n\t\t{\n\t\t\tif (trio_equal(name, \":enter\"))\n\t\t\t{\n\t\t\t\tinternalEnterCriticalRegion = callback;\n\t\t\t}\n\t\t\telse if (trio_equal(name, \":leave\"))\n\t\t\t{\n\t\t\t\tinternalLeaveCriticalRegion = callback;\n\t\t\t}\n\t\t\treturn NULL;\n\t\t}\n\n\t\t\/* Bail out if namespace is too long *\/\n\t\tif (trio_length_max(name, MAX_USER_NAME) >= MAX_USER_NAME)\n\t\t\treturn NULL;\n\n\t\t\/* Bail out if namespace already is registered *\/\n\t\tdef = TrioFindNamespace(name, &prev);\n\t\tif (def)\n\t\t\treturn NULL;\n\t}\n\n\tdef = (trio_userdef_t*)TRIO_MALLOC(sizeof(trio_userdef_t));\n\tif (def)\n\t{\n\t\tif (internalEnterCriticalRegion)\n\t\t\t(void)internalEnterCriticalRegion(NULL);\n\n\t\tif (name)\n\t\t{\n\t\t\t\/* Link into internal list *\/\n\t\t\tif (prev == NULL)\n\t\t\t\tinternalUserDef = def;\n\t\t\telse\n\t\t\t\tprev->next = def;\n\t\t}\n\t\t\/* Initialize *\/\n\t\tdef->callback = callback;\n\t\tdef->name = (name == NULL) ? NULL : trio_duplicate(name);\n\t\tdef->next = NULL;\n\n\t\tif (internalLeaveCriticalRegion)\n\t\t\t(void)internalLeaveCriticalRegion(NULL);\n\t}\n\treturn (trio_pointer_t)def;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":112932,"func":"static atomic_t *load_sipi_vector(struct mp_params *mp_params)\n{\n\tstruct rmodule sipi_mod;\n\tint module_size;\n\tint num_msrs;\n\tstruct sipi_params *sp;\n\tchar *mod_loc = (void *)sipi_vector_location;\n\tconst int loc_size = sipi_vector_location_size;\n\tatomic_t *ap_count = NULL;\n\n\tif (rmodule_parse(&_binary_sipi_vector_start, &sipi_mod)) {\n\t\tprintk(BIOS_CRIT, \"Unable to parse sipi module.\\n\");\n\t\treturn ap_count;\n\t}\n\n\tif (rmodule_entry_offset(&sipi_mod) != 0) {\n\t\tprintk(BIOS_CRIT, \"SIPI module entry offset is not 0!\\n\");\n\t\treturn ap_count;\n\t}\n\n\tif (rmodule_load_alignment(&sipi_mod) != 4096) {\n\t\tprintk(BIOS_CRIT, \"SIPI module load alignment(%d) != 4096.\\n\",\n\t\t       rmodule_load_alignment(&sipi_mod));\n\t\treturn ap_count;\n\t}\n\n\tmodule_size = rmodule_memory_size(&sipi_mod);\n\n\t\/* Align to 4 bytes. *\/\n\tmodule_size = ALIGN_UP(module_size, 4);\n\n\tif (module_size > loc_size) {\n\t\tprintk(BIOS_CRIT, \"SIPI module size (%d) > region size (%d).\\n\",\n\t\t       module_size, loc_size);\n\t\treturn ap_count;\n\t}\n\n\tnum_msrs = save_bsp_msrs(&mod_loc[module_size], loc_size - module_size);\n\n\tif (num_msrs < 0) {\n\t\tprintk(BIOS_CRIT, \"Error mirroring BSP's msrs.\\n\");\n\t\treturn ap_count;\n\t}\n\n\tif (rmodule_load(mod_loc, &sipi_mod)) {\n\t\tprintk(BIOS_CRIT, \"Unable to load SIPI module.\\n\");\n\t\treturn ap_count;\n\t}\n\n\tsp = rmodule_parameters(&sipi_mod);\n\n\tif (sp == NULL) {\n\t\tprintk(BIOS_CRIT, \"SIPI module has no parameters.\\n\");\n\t\treturn ap_count;\n\t}\n\n\tsetup_default_sipi_vector_params(sp);\n\t\/* Setup MSR table. *\/\n\tsp->msr_table_ptr = (uint32_t)&mod_loc[module_size];\n\tsp->msr_count = num_msrs;\n\t\/* Provide pointer to microcode patch. *\/\n\tsp->microcode_ptr = (uint32_t)mp_params->microcode_pointer;\n\t\/* Pass on ability to load microcode in parallel. *\/\n\tif (mp_params->parallel_microcode_load)\n\t\tsp->microcode_lock = 0;\n\telse\n\t\tsp->microcode_lock = ~0;\n\tsp->c_handler = (uint32_t)&ap_init;\n\tap_count = &sp->ap_count;\n\tatomic_set(ap_count, 0);\n\n\treturn ap_count;\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":80395,"func":"db_dict_field_find(const char *data, void *context,\n\t\t   const char **value_r,\n\t\t   const char **error_r ATTR_UNUSED)\n{\n\tstruct db_dict_value_iter *iter = context;\n\tstruct db_dict_iter_key *key;\n\tconst char *name, *value, *dotname = strchr(data, '.');\n\tstring_t *tmpstr;\n\n\t*value_r = NULL;\n\n\tif (dotname != NULL)\n\t\tdata = t_strdup_until(data, dotname++);\n\tkey = db_dict_iter_find_key(iter, data);\n\tif (key == NULL)\n\t\treturn 1;\n\n\tswitch (key->key->parsed_format) {\n\tcase DB_DICT_VALUE_FORMAT_VALUE:\n\t\t*value_r = dotname != NULL ? NULL :\n\t\t\t(key->value == NULL ? \"\" : key->value);\n\t\treturn 1;\n\tcase DB_DICT_VALUE_FORMAT_JSON:\n\t\tif (dotname == NULL)\n\t\t\treturn 1;\n\t\tdb_dict_value_iter_json_init(iter, key->value);\n\t\t*value_r = \"\";\n\t\ttmpstr = t_str_new(64);\n\t\twhile (db_dict_value_iter_json_next(iter, tmpstr, &name, &value)) {\n\t\t\tif (strcmp(name, dotname) == 0) {\n\t\t\t\t*value_r = t_strdup(value);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t(void)json_parser_deinit(&iter->json_parser, &iter->error);\n\t\treturn 1;\n\t}\n\ti_unreached();\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":194838,"func":"int FileTransfer::InvokeFileTransferPlugin(CondorError &e, const char* source, const char* dest, const char* proxy_filename) {\n\n\tif (plugin_table == NULL) {\n\t\tdprintf(D_FULLDEBUG, \"FILETRANSFER: No plugin table defined! (request was %s)\\n\", source);\n\t\te.pushf(\"FILETRANSFER\", 1, \"No plugin table defined (request was %s)\", source);\n\t\treturn GET_FILE_PLUGIN_FAILED;\n\t}\n\n\n\tchar *URL = NULL;\n\n\tif(IsUrl(dest)) {\n\t\tURL = const_cast<char*>(dest);\n\t\tdprintf(D_FULLDEBUG, \"FILETRANSFER: using destination to determine plugin type: %s\\n\", dest);\n\t} else {\n\t\tURL = const_cast<char*>(source);\n\t\tdprintf(D_FULLDEBUG, \"FILETRANSFER: using source to determine plugin type: %s\\n\", source);\n\t}\n\n\tconst char* colon = strchr(URL, ':');\n\n\tif (!colon) {\n\t\te.pushf(\"FILETRANSFER\", 1, \"Specified URL does not contain a ':' (%s)\", URL);\n\t\treturn GET_FILE_PLUGIN_FAILED;\n\t}\n\n\tchar* method = (char*) malloc(1 + (colon-URL));\n\tstrncpy(method, URL, (colon-URL));\n\tmethod[(colon-URL)] = '\\0';\n\n\n\tMyString plugin;\n\n\tif (plugin_table->lookup((MyString)method, plugin)) {\n\t\te.pushf(\"FILETRANSFER\", 1, \"FILETRANSFER: plugin for type %s not found!\", method);\n\t\tdprintf (D_FULLDEBUG, \"FILETRANSFER: plugin for type %s not found!\\n\", method);\n\t\tfree(method);\n\t\treturn GET_FILE_PLUGIN_FAILED;\n\t}\n\n\t\n\/*\t\n\tif (absolute_path_check() ) {\n\t\tdprintf(D_ALWAYS, \"FILETRANSFER: NOT invoking malformed plugin named \\\"%s\\\"\\n\", plugin.Value());\n\t\tFAIL();\n\t}\n*\/\n\n\tEnv plugin_env;\n\n\tplugin_env.Import();\n\n\tif (proxy_filename && *proxy_filename) {\n\t\tplugin_env.SetEnv(\"X509_USER_PROXY\",proxy_filename);\n\t\tdprintf(D_FULLDEBUG, \"FILETRANSFER: setting X509_USER_PROXY env to %s\\n\", proxy_filename);\n\t}\n\n\tArgList plugin_args;\n\tplugin_args.AppendArg(plugin.Value());\n\tplugin_args.AppendArg(source);\n\tplugin_args.AppendArg(dest);\n\tdprintf(D_FULLDEBUG, \"FILETRANSFER: invoking: %s %s %s\\n\", plugin.Value(), source, dest);\n\n\tFILE* plugin_pipe = my_popen(plugin_args, \"r\", FALSE, &plugin_env);\n\tint plugin_status = my_pclose(plugin_pipe);\n\n\tdprintf (D_ALWAYS, \"FILETRANSFER: plugin returned %i\\n\", plugin_status);\n\n\tfree(method);\n\n\tif (plugin_status != 0) {\n\t\te.pushf(\"FILETRANSFER\", 1, \"non-zero exit(%i) from %s\\n\", plugin_status, plugin.Value());\n\t\treturn GET_FILE_PLUGIN_FAILED;\n\t}\n\n\treturn 0;\n}\n","target":0,"code_token_length":615,"total_token_length":851,"max_tokens_setting":1024}
+{"idx":125820,"func":"static int _recursive_rmdir(char *dirname, dev_t pdev,\n\t\t\t    const char *exclude, int level, bool onedev)\n{\n\tstruct dirent dirent, *direntp;\n\tDIR *dir;\n\tint ret, failed=0;\n\tchar pathname[MAXPATHLEN];\n\tbool hadexclude = false;\n\n\tdir = opendir(dirname);\n\tif (!dir) {\n\t\tERROR(\"%s: failed to open %s\", __func__, dirname);\n\t\treturn -1;\n\t}\n\n\twhile (!readdir_r(dir, &dirent, &direntp)) {\n\t\tstruct stat mystat;\n\t\tint rc;\n\n\t\tif (!direntp)\n\t\t\tbreak;\n\n\t\tif (!strcmp(direntp->d_name, \".\") ||\n\t\t    !strcmp(direntp->d_name, \"..\"))\n\t\t\tcontinue;\n\n\t\trc = snprintf(pathname, MAXPATHLEN, \"%s\/%s\", dirname, direntp->d_name);\n\t\tif (rc < 0 || rc >= MAXPATHLEN) {\n\t\t\tERROR(\"pathname too long\");\n\t\t\tfailed=1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!level && exclude && !strcmp(direntp->d_name, exclude)) {\n\t\t\tret = rmdir(pathname);\n\t\t\tif (ret < 0) {\n\t\t\t\tswitch(errno) {\n\t\t\t\tcase ENOTEMPTY:\n\t\t\t\t\tINFO(\"Not deleting snapshot %s\", pathname);\n\t\t\t\t\thadexclude = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ENOTDIR:\n\t\t\t\t\tret = unlink(pathname);\n\t\t\t\t\tif (ret)\n\t\t\t\t\t\tINFO(\"%s: failed to remove %s\", __func__, pathname);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tSYSERROR(\"%s: failed to rmdir %s\", __func__, pathname);\n\t\t\t\t\tfailed = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tret = lstat(pathname, &mystat);\n\t\tif (ret) {\n\t\t\tERROR(\"%s: failed to stat %s\", __func__, pathname);\n\t\t\tfailed = 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (onedev && mystat.st_dev != pdev) {\n\t\t\t\/* TODO should we be checking \/proc\/self\/mountinfo for\n\t\t\t * pathname and not doing this if found? *\/\n\t\t\tif (btrfs_try_remove_subvol(pathname))\n\t\t\t\tINFO(\"Removed btrfs subvolume at %s\\n\", pathname);\n\t\t\tcontinue;\n\t\t}\n\t\tif (S_ISDIR(mystat.st_mode)) {\n\t\t\tif (_recursive_rmdir(pathname, pdev, exclude, level+1, onedev) < 0)\n\t\t\t\tfailed=1;\n\t\t} else {\n\t\t\tif (unlink(pathname) < 0) {\n\t\t\t\tSYSERROR(\"%s: failed to delete %s\", __func__, pathname);\n\t\t\t\tfailed=1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (rmdir(dirname) < 0 && !btrfs_try_remove_subvol(dirname) && !hadexclude) {\n\t\tERROR(\"%s: failed to delete %s\", __func__, dirname);\n\t\tfailed=1;\n\t}\n\n\tret = closedir(dir);\n\tif (ret) {\n\t\tERROR(\"%s: failed to close directory %s\", __func__, dirname);\n\t\tfailed=1;\n\t}\n\n\treturn failed ? -1 : 0;\n}","target":0,"code_token_length":681,"total_token_length":917,"max_tokens_setting":1024}
+{"idx":42611,"func":"static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){\n  Index *pIndex = pLoop->u.btree.pIndex;\n  u16 nEq = pLoop->u.btree.nEq;\n  u16 nSkip = pLoop->nSkip;\n  int i, j;\n\n  if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;\n  sqlite3_str_append(pStr, \" (\", 2);\n  for(i=0; i<nEq; i++){\n    const char *z = explainIndexColumnName(pIndex, i);\n    if( i ) sqlite3_str_append(pStr, \" AND \", 5);\n    sqlite3_str_appendf(pStr, i>=nSkip ? \"%s=?\" : \"ANY(%s)\", z);\n  }\n\n  j = i;\n  if( pLoop->wsFlags&WHERE_BTM_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, \">\");\n    i = 1;\n  }\n  if( pLoop->wsFlags&WHERE_TOP_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, \"<\");\n  }\n  sqlite3_str_append(pStr, \")\", 1);\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":414099,"func":"func_exists (struct _ESExp *f,\n             gint argc,\n             struct _ESExpResult **argv,\n             gpointer data)\n{\n\tEBookBackendLDAPSExpData *ldap_data = data;\n\tESExpResult *r;\n\n\tif (argc == 1\n\t    && argv[0]->type == ESEXP_RES_STRING) {\n\t\tgchar *propname = argv[0]->value.string;\n\n\t\tif (!strcmp (propname, \"x-evolution-any-field\")) {\n\t\t\tgint i;\n\t\t\tGString *big_query;\n\t\t\tgchar *match_str;\n\n\t\t\tmatch_str = g_strdup (\"=*)\");\n\n\t\t\tbig_query = g_string_sized_new (G_N_ELEMENTS (prop_info) * 7);\n\t\t\tg_string_append (big_query, \"(|\");\n\t\t\tfor (i = 0; i < G_N_ELEMENTS (prop_info); i++) {\n\t\t\t\tif (!(prop_info[i].prop_type & PROP_WRITE_ONLY) &&\n\t\t\t\t    (ldap_data->bl->priv->evolutionPersonSupported ||\n\t\t\t\t     !(prop_info[i].prop_type & PROP_EVOLVE)) &&\n\t\t\t\t    (ldap_data->bl->priv->calEntrySupported ||\n\t\t\t\t     !(prop_info[i].prop_type & PROP_CALENTRY))) {\n\t\t\t\t\tg_string_append (big_query, \"(\");\n\t\t\t\t\tg_string_append (big_query, prop_info[i].ldap_attr);\n\t\t\t\t\tg_string_append (big_query, match_str);\n\t\t\t\t}\n\t\t\t}\n\t\t\tg_string_append (big_query, \")\");\n\n\t\t\tldap_data->list = g_list_prepend (ldap_data->list, g_string_free (big_query, FALSE));\n\n\t\t\tg_free (match_str);\n\t\t}\n\t\telse {\n\t\t\tconst gchar *ldap_attr = query_prop_to_ldap (propname, ldap_data->bl->priv->evolutionPersonSupported, ldap_data->bl->priv->calEntrySupported);\n\n\t\t\tif (ldap_attr)\n\t\t\t\tldap_data->list = g_list_prepend (\n\t\t\t\t\tldap_data->list,\n\t\t\t\t\tg_strdup_printf (\n\t\t\t\t\t\t\"(%s=*)\", ldap_attr));\n\t\t}\n\t}\n\n\tr = e_sexp_result_new (f, ESEXP_RES_BOOL);\n\tr->value.boolean = FALSE;\n\n\treturn r;\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":68304,"func":"int scan_dir_tree(LOGBOOK *lbs, const char *dir, char **file_list, int *n) {\n   int index, n_files;\n   char str[MAX_PATH_LENGTH];\n   char *fl, *p;\n\n   fl = NULL;\n   n_files = ss_file_find(dir, \"*\", &fl);\n   if (n_files == 0) {\n      if (fl)\n         xfree(fl);\n      return 0;\n   }\n\n   if (*file_list == NULL)\n      *file_list = (char *) xmalloc(n_files * MAX_PATH_LENGTH);\n   else\n      *file_list = (char *) xrealloc(*file_list, ((*n) + n_files) * MAX_PATH_LENGTH);\n\n   \/* go through all files *\/\n   for (index = 0; index < n_files; index++) {\n      if (fnmatch1(\"??????a.log\", &fl[index * MAX_PATH_LENGTH]) == 0) {\n         p = *file_list + ((*n) * MAX_PATH_LENGTH);\n         strlcpy(p, dir, MAX_PATH_LENGTH);\n         if (p[strlen(p) - 1] != DIR_SEPARATOR)\n            strlcat(p, DIR_SEPARATOR_STR, MAX_PATH_LENGTH);\n         strlcat(p, fl + index * MAX_PATH_LENGTH, MAX_PATH_LENGTH);\n         (*n)++;\n      }\n   }\n\n   \/* go through all sub-directories *\/\n   for (index = 0; index < n_files; index++) {\n      if (fnmatch1(\"????\", &fl[index * MAX_PATH_LENGTH]) == 0 ||\n          fnmatch1(\"??\", &fl[index * MAX_PATH_LENGTH]) == 0) {\n         if (strieq(fl + index * MAX_PATH_LENGTH, \"..\"))\n            continue;\n         strlcpy(str, dir, sizeof(str));\n         if (str[strlen(str) - 1] != DIR_SEPARATOR)\n            strlcat(str, DIR_SEPARATOR_STR, sizeof(str));\n         strlcat(str, fl + index * MAX_PATH_LENGTH, sizeof(str));\n         scan_dir_tree(lbs, str, file_list, n);\n      }\n   }\n\n   if (fl)\n      xfree(fl);\n\n   return *n;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":43255,"func":"static int compand_drain(AVFilterLink *outlink)\n\n{\n\n    AVFilterContext *ctx = outlink->src;\n\n    CompandContext *s    = ctx->priv;\n\n    const int channels   = outlink->channels;\n\n    AVFrame *frame       = NULL;\n\n    int chan, i, dindex;\n\n\n\n    \/* 2048 is to limit output frame size during drain *\/\n\n    frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->delay_count));\n\n    if (!frame)\n\n        return AVERROR(ENOMEM);\n\n    frame->pts = s->pts;\n\n    s->pts += av_rescale_q(frame->nb_samples,\n\n            (AVRational){ 1, outlink->sample_rate }, outlink->time_base);\n\n\n\n\n    for (chan = 0; chan < channels; chan++) {\n\n        AVFrame *delay_frame = s->delay_frame;\n\n        double *dbuf = (double *)delay_frame->extended_data[chan];\n\n        double *dst = (double *)frame->extended_data[chan];\n\n        ChanParam *cp = &s->channels[chan];\n\n\n\n        dindex = s->delay_index;\n\n        for (i = 0; i < frame->nb_samples; i++) {\n\n            dst[i] = av_clipd(dbuf[dindex] * get_volume(s, cp->volume),\n\n                    -1, 1);\n\n            dindex = MOD(dindex + 1, s->delay_samples);\n\n        }\n\n    }\n\n    s->delay_count -= frame->nb_samples;\n\n    s->delay_index = dindex;\n\n\n\n    return ff_filter_frame(outlink, frame);\n\n}","target":1,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":311282,"func":"static CompositeOperator PSDBlendModeToCompositeOperator(const char *mode)\n{\n  if (mode == (const char *) NULL)\n    return(OverCompositeOp);\n  if (LocaleNCompare(mode,\"norm\",4) == 0)\n    return(OverCompositeOp);\n  if (LocaleNCompare(mode,\"mul \",4) == 0)\n    return(MultiplyCompositeOp);\n  if (LocaleNCompare(mode,\"diss\",4) == 0)\n    return(DissolveCompositeOp);\n  if (LocaleNCompare(mode,\"diff\",4) == 0)\n    return(DifferenceCompositeOp);\n  if (LocaleNCompare(mode,\"dark\",4) == 0)\n    return(DarkenCompositeOp);\n  if (LocaleNCompare(mode,\"lite\",4) == 0)\n    return(LightenCompositeOp);\n  if (LocaleNCompare(mode,\"hue \",4) == 0)\n    return(HueCompositeOp);\n  if (LocaleNCompare(mode,\"sat \",4) == 0)\n    return(SaturateCompositeOp);\n  if (LocaleNCompare(mode,\"colr\",4) == 0)\n    return(ColorizeCompositeOp);\n  if (LocaleNCompare(mode,\"lum \",4) == 0)\n    return(LuminizeCompositeOp);\n  if (LocaleNCompare(mode,\"scrn\",4) == 0)\n    return(ScreenCompositeOp);\n  if (LocaleNCompare(mode,\"over\",4) == 0)\n    return(OverlayCompositeOp);\n  if (LocaleNCompare(mode,\"hLit\",4) == 0)\n    return(HardLightCompositeOp);\n  if (LocaleNCompare(mode,\"sLit\",4) == 0)\n    return(SoftLightCompositeOp);\n  if (LocaleNCompare(mode,\"smud\",4) == 0)\n    return(ExclusionCompositeOp);\n  if (LocaleNCompare(mode,\"div \",4) == 0)\n    return(ColorDodgeCompositeOp);\n  if (LocaleNCompare(mode,\"idiv\",4) == 0)\n    return(ColorBurnCompositeOp);\n  if (LocaleNCompare(mode,\"lbrn\",4) == 0)\n    return(LinearBurnCompositeOp);\n  if (LocaleNCompare(mode,\"lddg\",4) == 0)\n    return(LinearDodgeCompositeOp);\n  if (LocaleNCompare(mode,\"lLit\",4) == 0)\n    return(LinearLightCompositeOp);\n  if (LocaleNCompare(mode,\"vLit\",4) == 0)\n    return(VividLightCompositeOp);\n  if (LocaleNCompare(mode,\"pLit\",4) == 0)\n    return(PinLightCompositeOp);\n  if (LocaleNCompare(mode,\"hMix\",4) == 0)\n    return(HardMixCompositeOp);\n  return(OverCompositeOp);\n}\n","target":0,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":359307,"func":"struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,\n                                    char *name, int ovr, int bind, int *err)\n{\n\tstruct tc_action *a;\n\tstruct tc_action_ops *a_o;\n\tchar act_name[IFNAMSIZ];\n\tstruct rtattr *tb[TCA_ACT_MAX+1];\n\tstruct rtattr *kind;\n\n\t*err = -EINVAL;\n\n\tif (name == NULL) {\n\t\tif (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0)\n\t\t\tgoto err_out;\n\t\tkind = tb[TCA_ACT_KIND-1];\n\t\tif (kind == NULL)\n\t\t\tgoto err_out;\n\t\tif (rtattr_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)\n\t\t\tgoto err_out;\n\t} else {\n\t\tif (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)\n\t\t\tgoto err_out;\n\t}\n\n\ta_o = tc_lookup_action_n(act_name);\n\tif (a_o == NULL) {\n#ifdef CONFIG_KMOD\n\t\trtnl_unlock();\n\t\trequest_module(act_name);\n\t\trtnl_lock();\n\n\t\ta_o = tc_lookup_action_n(act_name);\n\n\t\t\/* We dropped the RTNL semaphore in order to\n\t\t * perform the module load.  So, even if we\n\t\t * succeeded in loading the module we have to\n\t\t * tell the caller to replay the request.  We\n\t\t * indicate this using -EAGAIN.\n\t\t *\/\n\t\tif (a_o != NULL) {\n\t\t\t*err = -EAGAIN;\n\t\t\tgoto err_mod;\n\t\t}\n#endif\n\t\tgoto err_out;\n\t}\n\n\t*err = -ENOMEM;\n\ta = kmalloc(sizeof(*a), GFP_KERNEL);\n\tif (a == NULL)\n\t\tgoto err_mod;\n\tmemset(a, 0, sizeof(*a));\n\n\t\/* backward compatibility for policer *\/\n\tif (name == NULL)\n\t\t*err = a_o->init(tb[TCA_ACT_OPTIONS-1], est, a, ovr, bind);\n\telse\n\t\t*err = a_o->init(rta, est, a, ovr, bind);\n\tif (*err < 0)\n\t\tgoto err_free;\n\n\t\/* module count goes up only when brand new policy is created\n\t   if it exists and is only bound to in a_o->init() then\n\t   ACT_P_CREATED is not returned (a zero is).\n\t*\/\n\tif (*err != ACT_P_CREATED)\n\t\tmodule_put(a_o->owner);\n\ta->ops = a_o;\n\tDPRINTK(\"tcf_action_init_1: successfull %s\\n\", act_name);\n\n\t*err = 0;\n\treturn a;\n\nerr_free:\n\tkfree(a);\nerr_mod:\n\tmodule_put(a_o->owner);\nerr_out:\n\treturn NULL;\n}","target":0,"code_token_length":591,"total_token_length":827,"max_tokens_setting":1024}
+{"idx":250985,"func":"        StateBase* serializeProperties(bool ignoreIndexed, Serializer& serializer)\n        {\n            while (m_index < m_propertyNames->Length()) {\n                if (!m_nameDone) {\n                    v8::Local<v8::Value> propertyName = m_propertyNames->Get(m_index);\n                    if (StateBase* newState = serializer.checkException(this))\n                        return newState;\n                    if (propertyName.IsEmpty())\n                        return serializer.handleError(InputError, \"Empty property names cannot be cloned.\", this);\n                    bool hasStringProperty = propertyName->IsString() && composite()->HasRealNamedProperty(propertyName.As<v8::String>());\n                    if (StateBase* newState = serializer.checkException(this))\n                        return newState;\n                    bool hasIndexedProperty = !hasStringProperty && propertyName->IsUint32() && composite()->HasRealIndexedProperty(propertyName->Uint32Value());\n                    if (StateBase* newState = serializer.checkException(this))\n                        return newState;\n                    if (hasStringProperty || (hasIndexedProperty && !ignoreIndexed)) {\n                        m_propertyName = propertyName;\n                    } else {\n                        ++m_index;\n                        continue;\n                    }\n                }\n                ASSERT(!m_propertyName.IsEmpty());\n                if (!m_nameDone) {\n                    m_nameDone = true;\n                    if (StateBase* newState = serializer.doSerialize(m_propertyName, this))\n                        return newState;\n                }\n                v8::Local<v8::Value> value = composite()->Get(m_propertyName);\n                if (StateBase* newState = serializer.checkException(this))\n                    return newState;\n                m_nameDone = false;\n                m_propertyName.Clear();\n                ++m_index;\n                ++m_numSerializedProperties;\n                if (StateBase* newState = serializer.doSerialize(value, this))\n                    return newState;\n            }\n            return objectDone(m_numSerializedProperties, serializer);\n        }\n","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":20500,"func":"static int add_array_entry ( const char * loc_name , zval * hash_arr , char * key_name TSRMLS_DC ) {\n char * key_value = NULL ;\n char * cur_key_name = NULL ;\n char * token = NULL ;\n char * last_ptr = NULL ;\n int result = 0 ;\n int cur_result = 0 ;\n int cnt = 0 ;\n if ( strcmp ( key_name , LOC_PRIVATE_TAG ) == 0 ) {\n key_value = get_private_subtags ( loc_name ) ;\n result = 1 ;\n }\n else {\n key_value = get_icu_value_internal ( loc_name , key_name , & result , 1 ) ;\n }\n if ( ( strcmp ( key_name , LOC_PRIVATE_TAG ) == 0 ) || ( strcmp ( key_name , LOC_VARIANT_TAG ) == 0 ) ) {\n if ( result > 0 && key_value ) {\n token = php_strtok_r ( key_value , DELIMITER , & last_ptr ) ;\n if ( cur_key_name ) {\n efree ( cur_key_name ) ;\n }\n cur_key_name = ( char * ) ecalloc ( 25 , 25 ) ;\n sprintf ( cur_key_name , \"%s%d\" , key_name , cnt ++ ) ;\n add_assoc_string ( hash_arr , cur_key_name , token , TRUE ) ;\n while ( ( token = php_strtok_r ( NULL , DELIMITER , & last_ptr ) ) && ( strlen ( token ) > 1 ) ) {\n sprintf ( cur_key_name , \"%s%d\" , key_name , cnt ++ ) ;\n add_assoc_string ( hash_arr , cur_key_name , token , TRUE ) ;\n }\n }\n }\n else {\n if ( result == 1 ) {\n add_assoc_string ( hash_arr , key_name , key_value , TRUE ) ;\n cur_result = 1 ;\n }\n }\n if ( cur_key_name ) {\n efree ( cur_key_name ) ;\n }\n if ( key_value ) {\n efree ( key_value ) ;\n }\n return cur_result ;\n }","target":0,"code_token_length":403,"total_token_length":639,"max_tokens_setting":1024}
+{"idx":385687,"func":"ftp_mdtm(ftpbuf_t *ftp, const char *path)\n{\n\ttime_t\t\tstamp;\n\tstruct tm\t*gmt, tmbuf;\n\tstruct tm\ttm;\n\tchar\t\t*ptr;\n\tint\t\tn;\n\n\tif (ftp == NULL) {\n\t\treturn -1;\n\t}\n\tif (!ftp_putcmd(ftp, \"MDTM\", path)) {\n\t\treturn -1;\n\t}\n\tif (!ftp_getresp(ftp) || ftp->resp != 213) {\n\t\treturn -1;\n\t}\n\t\/* parse out the timestamp *\/\n\tfor (ptr = ftp->inbuf; *ptr && !isdigit(*ptr); ptr++);\n\tn = sscanf(ptr, \"%4u%2u%2u%2u%2u%2u\", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec);\n\tif (n != 6) {\n\t\treturn -1;\n\t}\n\ttm.tm_year -= 1900;\n\ttm.tm_mon--;\n\ttm.tm_isdst = -1;\n\n\t\/* figure out the GMT offset *\/\n\tstamp = time(NULL);\n\tgmt = php_gmtime_r(&stamp, &tmbuf);\n\tif (!gmt) {\n\t\treturn -1;\n\t}\n\tgmt->tm_isdst = -1;\n\n\t\/* apply the GMT offset *\/\n\ttm.tm_sec += stamp - mktime(gmt);\n\ttm.tm_isdst = gmt->tm_isdst;\n\n\tstamp = mktime(&tm);\n\n\treturn stamp;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":127839,"func":"static int zipfileDeflate(\n  const u8 *aIn, int nIn,         \/* Input *\/\n  u8 **ppOut, int *pnOut,         \/* Output *\/\n  char **pzErr                    \/* OUT: Error message *\/\n){\n  int rc = SQLITE_OK;\n  sqlite3_int64 nAlloc;\n  z_stream str;\n  u8 *aOut;\n\n  memset(&str, 0, sizeof(str));\n  str.next_in = (Bytef*)aIn;\n  str.avail_in = nIn;\n  deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);\n\n  nAlloc = deflateBound(&str, nIn);\n  aOut = (u8*)sqlite3_malloc64(nAlloc);\n  if( aOut==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    int res;\n    str.next_out = aOut;\n    str.avail_out = nAlloc;\n    res = deflate(&str, Z_FINISH);\n    if( res==Z_STREAM_END ){\n      *ppOut = aOut;\n      *pnOut = (int)str.total_out;\n    }else{\n      sqlite3_free(aOut);\n      *pzErr = sqlite3_mprintf(\"zipfile: deflate() error\");\n      rc = SQLITE_ERROR;\n    }\n    deflateEnd(&str);\n  }\n\n  return rc;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":364820,"func":"_parse_env_file(pam_handle_t *pamh, int ctrl, const char *file)\n{\n    int retval=PAM_SUCCESS, i, t;\n    char buffer[BUF_SIZE], *key, *mark;\n    FILE *conf;\n\n    D((\"Env file name is: %s\", file));\n\n    if ((conf = fopen(file,\"r\")) == NULL) {\n      pam_syslog(pamh, LOG_ERR, \"Unable to open env file: %s: %m\", file);\n      return PAM_IGNORE;\n    }\n\n    while (_assemble_line(conf, buffer, BUF_SIZE) > 0) {\n\tD((\"Read line: %s\", buffer));\n\tkey = buffer;\n\n\t\/* skip leading white space *\/\n\tkey += strspn(key, \" \\n\\t\");\n\n\t\/* skip blanks lines and comments *\/\n\tif (key[0] == '#')\n\t    continue;\n\n\t\/* skip over \"export \" if present so we can be compat with\n\t   bash type declarations *\/\n\tif (strncmp(key, \"export \", (size_t) 7) == 0)\n\t    key += 7;\n\n\t\/* now find the end of value *\/\n\tmark = key;\n\twhile(mark[0] != '\\n' && mark[0] != '#' && mark[0] != '\\0')\n\t    mark++;\n\tif (mark[0] != '\\0')\n\t    mark[0] = '\\0';\n\n       \/*\n\t* sanity check, the key must be alpha-numeric\n\t*\/\n\n\tfor ( i = 0 ; key[i] != '=' && key[i] != '\\0' ; i++ )\n\t    if (!isalnum(key[i]) && key[i] != '_') {\n\t\tpam_syslog(pamh, LOG_ERR,\n\t\t           \"non-alphanumeric key '%s' in %s', ignoring\",\n\t\t           key, file);\n\t\tbreak;\n\t    }\n\t\/* non-alphanumeric key, ignore this line *\/\n\tif (key[i] != '=' && key[i] != '\\0')\n\t    continue;\n\n\t\/* now we try to be smart about quotes around the value,\n\t   but not too smart, we can't get all fancy with escaped\n\t   values like bash *\/\n\tif (key[i] == '=' && (key[++i] == '\\\"' || key[i] == '\\'')) {\n\t    for ( t = i+1 ; key[t] != '\\0' ; t++)\n\t\tif (key[t] != '\\\"' && key[t] != '\\'')\n\t\t    key[i++] = key[t];\n\t\telse if (key[t+1] != '\\0')\n\t\t    key[i++] = key[t];\n\t    key[i] = '\\0';\n\t}\n\n\t\/* if this is a request to delete a variable, check that it's\n\t   actually set first, so we don't get a vague error back from\n\t   pam_putenv() *\/\n\tfor (i = 0; key[i] != '=' && key[i] != '\\0'; i++);\n\n\tif (key[i] == '\\0' && !pam_getenv(pamh,key))\n\t    continue;\n\n\t\/* set the env var, if it fails, we break out of the loop *\/\n\tretval = pam_putenv(pamh, key);\n\tif (retval != PAM_SUCCESS) {\n\t    D((\"error setting env \\\"%s\\\"\", key));\n\t    break;\n\t} else if (ctrl & PAM_DEBUG_ARG) {\n\t    pam_syslog(pamh, LOG_DEBUG,\n\t\t       \"pam_putenv(\\\"%s\\\")\", key);\n\t}\n    }\n\n    (void) fclose(conf);\n\n    \/* tidy up *\/\n    D((\"Exit.\"));\n    return retval;\n}","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":330593,"func":"static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int buf_size, const uint8_t *filename, int filename_size)\n\n{\n\n    const uint8_t *buf_end = buf + buf_size;\n\n\n\n    while(buf + 48 <= buf_end) {\n\n        int dir_length, name_size, first_sector, depth;\n\n        uint64_t file_length;\n\n        const uint8_t *name;\n\n        if (ff_guidcmp(buf, dir_entry_guid)) {\n\n            av_log(s, AV_LOG_ERROR, \"unknown guid \"FF_PRI_GUID\", expected dir_entry_guid; \"\n\n                   \"remaining directory entries ignored\\n\", FF_ARG_GUID(buf));\n\n            break;\n\n        }\n\n        dir_length  = AV_RL16(buf + 16);\n\n        file_length = AV_RL64(buf + 24);\n\n        name_size   = 2 * AV_RL32(buf + 32);\n\n        if (buf + 48 + name_size > buf_end) {\n\n            av_log(s, AV_LOG_ERROR, \"filename exceeds buffer size; remaining directory entries ignored\\n\");\n\n            break;\n\n        }\n\n        first_sector = AV_RL32(buf + 40 + name_size);\n\n        depth        = AV_RL32(buf + 44 + name_size);\n\n\n\n        \/* compare file name; test optional null terminator *\/\n\n        name = buf + 40;\n\n        if (name_size >= filename_size &&\n\n            !memcmp(name, filename, filename_size) &&\n\n            (name_size < filename_size + 2 || !AV_RN16(name + filename_size)))\n\n            return wtvfile_open_sector(first_sector, file_length, depth, s);\n\n\n\n        buf += dir_length;\n\n    }\n\n    return 0;\n\n}\n","target":1,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":145992,"func":"GF_Err traf_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_TrackFragmentBox *ptr = (GF_TrackFragmentBox *) s;\n\n\t\/\/Header first\n\tgf_isom_check_position(s, (GF_Box *)ptr->tfhd, &pos);\n\tgf_isom_check_position_list(s, ptr->sub_samples, &pos);\n\n\tgf_isom_check_position(s, (GF_Box *)ptr->tfdt, &pos);\n\tgf_isom_check_position_list(s, ptr->sampleGroupsDescription, &pos);\n\tgf_isom_check_position_list(s, ptr->sampleGroups, &pos);\n\tgf_isom_check_position_list(s, ptr->sai_sizes, &pos);\n\tgf_isom_check_position_list(s, ptr->sai_offsets, &pos);\n\n\tgf_isom_check_position(s, (GF_Box *)ptr->sample_encryption, &pos);\n\n\tgf_isom_check_position_list(s, ptr->TrackRuns, &pos);\n\n\t\/\/when sdtp is present (smooth-like) write it after the trun box\n\tgf_isom_check_position(s, (GF_Box *)ptr->sdtp, &pos);\n\n\t\/\/tfxd should be last ...\n\tif (ptr->tfxd)\n\t\tgf_isom_check_position(s, (GF_Box *)ptr->tfxd, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":346602,"func":"GC_INNER ptr_t GC_alloc_large(size_t lb, int k, unsigned flags)\n{\n    struct hblk * h;\n    word n_blocks;\n    ptr_t result;\n    GC_bool retry = FALSE;\n\n    GC_ASSERT(I_HOLD_LOCK());\n    lb = ROUNDUP_GRANULE_SIZE(lb);\n    n_blocks = OBJ_SZ_TO_BLOCKS(lb);\n    if (!EXPECT(GC_is_initialized, TRUE)) {\n      DCL_LOCK_STATE;\n      UNLOCK(); \/* just to unset GC_lock_holder *\/\n      GC_init();\n      LOCK();\n    }\n    \/* Do our share of marking work *\/\n        if (GC_incremental && !GC_dont_gc)\n            GC_collect_a_little_inner((int)n_blocks);\n    h = GC_allochblk(lb, k, flags);\n#   ifdef USE_MUNMAP\n        if (0 == h) {\n            GC_merge_unmapped();\n            h = GC_allochblk(lb, k, flags);\n        }\n#   endif\n    while (0 == h && GC_collect_or_expand(n_blocks, flags != 0, retry)) {\n        h = GC_allochblk(lb, k, flags);\n        retry = TRUE;\n    }\n    if (h == 0) {\n        result = 0;\n    } else {\n        size_t total_bytes = n_blocks * HBLKSIZE;\n        if (n_blocks > 1) {\n            GC_large_allocd_bytes += total_bytes;\n            if (GC_large_allocd_bytes > GC_max_large_allocd_bytes)\n                GC_max_large_allocd_bytes = GC_large_allocd_bytes;\n        }\n        \/* FIXME: Do we need some way to reset GC_max_large_allocd_bytes? *\/\n        result = h -> hb_body;\n    }\n    return result;\n}","target":1,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":379146,"func":"long do_mount(const char *dev_name, const char *dir_name,\n\t\tconst char *type_page, unsigned long flags, void *data_page)\n{\n\tstruct path path;\n\tint retval = 0;\n\tint mnt_flags = 0;\n\n\t\/* Discard magic *\/\n\tif ((flags & MS_MGC_MSK) == MS_MGC_VAL)\n\t\tflags &= ~MS_MGC_MSK;\n\n\t\/* Basic sanity checks *\/\n\n\tif (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE))\n\t\treturn -EINVAL;\n\n\tif (data_page)\n\t\t((char *)data_page)[PAGE_SIZE - 1] = 0;\n\n\t\/* ... and get the mountpoint *\/\n\tretval = kern_path(dir_name, LOOKUP_FOLLOW, &path);\n\tif (retval)\n\t\treturn retval;\n\n\tretval = security_sb_mount(dev_name, &path,\n\t\t\t\t   type_page, flags, data_page);\n\tif (!retval && !may_mount())\n\t\tretval = -EPERM;\n\tif (retval)\n\t\tgoto dput_out;\n\n\t\/* Default to relatime unless overriden *\/\n\tif (!(flags & MS_NOATIME))\n\t\tmnt_flags |= MNT_RELATIME;\n\n\t\/* Separate the per-mountpoint flags *\/\n\tif (flags & MS_NOSUID)\n\t\tmnt_flags |= MNT_NOSUID;\n\tif (flags & MS_NODEV)\n\t\tmnt_flags |= MNT_NODEV;\n\tif (flags & MS_NOEXEC)\n\t\tmnt_flags |= MNT_NOEXEC;\n\tif (flags & MS_NOATIME)\n\t\tmnt_flags |= MNT_NOATIME;\n\tif (flags & MS_NODIRATIME)\n\t\tmnt_flags |= MNT_NODIRATIME;\n\tif (flags & MS_STRICTATIME)\n\t\tmnt_flags &= ~(MNT_RELATIME | MNT_NOATIME);\n\tif (flags & MS_RDONLY)\n\t\tmnt_flags |= MNT_READONLY;\n\n\t\/* The default atime for remount is preservation *\/\n\tif ((flags & MS_REMOUNT) &&\n\t    ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME |\n\t\t       MS_STRICTATIME)) == 0)) {\n\t\tmnt_flags &= ~MNT_ATIME_MASK;\n\t\tmnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK;\n\t}\n\n\tflags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |\n\t\t   MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |\n\t\t   MS_STRICTATIME);\n\n\tif (flags & MS_REMOUNT)\n\t\tretval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,\n\t\t\t\t    data_page);\n\telse if (flags & MS_BIND)\n\t\tretval = do_loopback(&path, dev_name, flags & MS_REC);\n\telse if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))\n\t\tretval = do_change_type(&path, flags);\n\telse if (flags & MS_MOVE)\n\t\tretval = do_move_mount(&path, dev_name);\n\telse\n\t\tretval = do_new_mount(&path, type_page, flags, mnt_flags,\n\t\t\t\t      dev_name, data_page);\ndput_out:\n\tpath_put(&path);\n\treturn retval;\n}","target":0,"code_token_length":688,"total_token_length":924,"max_tokens_setting":1024}
+{"idx":52732,"func":"GF_Err saiz_dump(GF_Box *a, FILE * trace)\n{\n\tu32 i;\n\tGF_SampleAuxiliaryInfoSizeBox *ptr = (GF_SampleAuxiliaryInfoSizeBox*) a;\n\tif (!a) return GF_BAD_PARAM;\n\n\tgf_isom_box_dump_start(a, \"SampleAuxiliaryInfoSizeBox\", trace);\n\n\tfprintf(trace, \"default_sample_info_size=\\\"%d\\\" sample_count=\\\"%d\\\"\", ptr->default_sample_info_size, ptr->sample_count);\n\tif (ptr->flags & 1) {\n\t\tif (isalnum(ptr->aux_info_type>>24)) {\n\t\t\tfprintf(trace, \" aux_info_type=\\\"%s\\\" aux_info_type_parameter=\\\"%d\\\"\", gf_4cc_to_str(ptr->aux_info_type), ptr->aux_info_type_parameter);\n\t\t} else {\n\t\t\tfprintf(trace, \" aux_info_type=\\\"%d\\\" aux_info_type_parameter=\\\"%d\\\"\", ptr->aux_info_type, ptr->aux_info_type_parameter);\n\t\t}\n\t}\n\tfprintf(trace, \">\\n\");\n\tif (ptr->default_sample_info_size==0) {\n\t\tfor (i=0; i<ptr->sample_count; i++) {\n\t\t\tfprintf(trace, \"<SAISize size=\\\"%d\\\" \/>\\n\", ptr->sample_info_size[i]);\n\t\t}\n\t}\n\tif (!ptr->size) {\n\t\t\tfprintf(trace, \"<SAISize size=\\\"\\\" \/>\\n\");\n\t}\n\tgf_isom_box_dump_done(\"SampleAuxiliaryInfoSizeBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":378555,"func":"static PyObject *Adapter_start_response(AdapterObject *self, PyObject *args)\n{\n    const char *status = NULL;\n    PyObject *headers = NULL;\n    PyObject *exc_info = NULL;\n\n    PyObject *item = NULL;\n    PyObject *latin_item = NULL;\n\n    char* value = NULL;\n\n    if (!self->r) {\n        PyErr_SetString(PyExc_RuntimeError, \"request object has expired\");\n        return NULL;\n    }\n\n    if (!PyArg_ParseTuple(args, \"OO|O:start_response\",\n        &item, &headers, &exc_info)) {\n        return NULL;\n    }\n\n#if PY_MAJOR_VERSION >= 3\n    if (PyUnicode_Check(item)) {\n        latin_item = PyUnicode_AsLatin1String(item);\n        if (!latin_item) {\n            PyErr_Format(PyExc_TypeError, \"expected byte string object for \"\n                         \"status, value containing non 'latin-1' characters \"\n                         \"found\");\n            return NULL;\n        }\n\n        item = latin_item;\n    }\n#endif\n\n    if (!PyString_Check(item)) {\n        PyErr_Format(PyExc_TypeError, \"expected byte string object for \"\n                     \"status, value of type %.200s found\",\n                     item->ob_type->tp_name);\n        Py_XDECREF(latin_item);\n        return NULL;\n    }\n\n    status = PyString_AsString(item);\n\n    if (!PyList_Check(headers)) {\n        PyErr_SetString(PyExc_TypeError, \"response headers must be a list\");\n        Py_XDECREF(latin_item);\n        return NULL;\n    }\n\n    if (exc_info && exc_info != Py_None) {\n        if (self->status_line && !self->headers) {\n            PyObject *type = NULL;\n            PyObject *value = NULL;\n            PyObject *traceback = NULL;\n\n            if (!PyArg_ParseTuple(exc_info, \"OOO\", &type,\n                                  &value, &traceback)) {\n                Py_XDECREF(latin_item);\n                return NULL;\n            }\n\n            Py_INCREF(type);\n            Py_INCREF(value);\n            Py_INCREF(traceback);\n\n            PyErr_Restore(type, value, traceback);\n\n            Py_XDECREF(latin_item);\n\n            return NULL;\n        }\n    }\n    else if (self->status_line && !self->headers) {\n        PyErr_SetString(PyExc_RuntimeError, \"headers have already been sent\");\n        Py_XDECREF(latin_item);\n        return NULL;\n    }\n\n    self->status_line = apr_pstrdup(self->r->pool, status);\n\n    value = ap_getword(self->r->pool, &status, ' ');\n\n    errno = 0;\n    self->status = strtol(value, &value, 10);\n\n    if (*value || errno == ERANGE) {\n        PyErr_SetString(PyExc_TypeError, \"status value is not an integer\");\n        Py_XDECREF(latin_item);\n        return NULL;\n    }\n\n    if (!*status) {\n        PyErr_SetString(PyExc_ValueError, \"status message was not supplied\");\n        Py_XDECREF(latin_item);\n        return NULL;\n    }\n\n    Py_XDECREF(self->headers);\n\n    self->headers = headers;\n\n    Py_INCREF(self->headers);\n\n    Py_XDECREF(latin_item);\n\n    return PyObject_GetAttrString((PyObject *)self, \"write\");\n}","target":0,"code_token_length":667,"total_token_length":903,"max_tokens_setting":1024}
+{"idx":60492,"func":"static int encode_public_key(RSA *rsa, u8 *key, size_t *keysize)\n{\n\tu8 buf[1024], *p = buf;\n\tu8 bnbuf[256];\n\tint base = 0;\n\tint r;\n\tconst BIGNUM *rsa_n, *rsa_e;\n\n\tswitch (RSA_bits(rsa)) {\n\tcase 512:\n\t\tbase = 32;\n\t\tbreak;\n\tcase 768:\n\t\tbase = 48;\n\t\tbreak;\n\tcase 1024:\n\t\tbase = 64;\n\t\tbreak;\n\tcase 2048:\n\t\tbase = 128;\n\t\tbreak;\n\t}\n\tif (base == 0) {\n\t\tfprintf(stderr, \"Key length invalid.\\n\");\n\t\treturn 2;\n\t}\n\t*p++ = (5 * base + 7) >> 8;\n\t*p++ = (5 * base + 7) & 0xFF;\n\t*p++ = opt_key_num;\n\n\tRSA_get0_key(rsa, &rsa_n, &rsa_e, NULL);\n\tr = bn2cf(rsa_n, bnbuf);\n\tif (r != 2*base) {\n\t\tfprintf(stderr, \"Invalid public key.\\n\");\n\t\treturn 2;\n\t}\n\tmemcpy(p, bnbuf, 2*base);\n\tp += 2*base;\n\n\tmemset(p, 0, base);\n\tp += base;\n\n\tmemset(bnbuf, 0, 2*base);\n\tmemcpy(p, bnbuf, 2*base);\n\tp += 2*base;\n\tr = bn2cf(rsa_e, bnbuf);\n\tmemcpy(p, bnbuf, 4);\n\tp += 4;\n\n\tmemcpy(key, buf, p - buf);\n\t*keysize = p - buf;\n\n\treturn 0;\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":164066,"func":"void _php_curl_verify_handlers(php_curl *ch, int reporterror) \/* {{{ *\/\n{\n\tphp_stream *stream;\n\tif (!ch || !ch->handlers) {\n\t\treturn;\n\t}\n\n\tif (!Z_ISUNDEF(ch->handlers->std_err)) {\n\t\tstream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());\n\t\tif (stream == NULL) {\n\t\t\tif (reporterror) {\n\t\t\t\tphp_error_docref(NULL, E_WARNING, \"CURLOPT_STDERR resource has gone away, resetting to stderr\");\n\t\t\t}\n\t\t\tzval_ptr_dtor(&ch->handlers->std_err);\n\t\t\tZVAL_UNDEF(&ch->handlers->std_err);\n\n\t\t\tcurl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr);\n\t\t}\n\t}\n\tif (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {\n\t\tstream = zend_fetch_resource(&ch->handlers->read->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());\n\t\tif (stream == NULL) {\n\t\t\tif (reporterror) {\n\t\t\t\tphp_error_docref(NULL, E_WARNING, \"CURLOPT_INFILE resource has gone away, resetting to default\");\n\t\t\t}\n\t\t\tzval_ptr_dtor(&ch->handlers->read->stream);\n\t\t\tZVAL_UNDEF(&ch->handlers->read->stream);\n\t\t\tch->handlers->read->res = NULL;\n\t\t\tch->handlers->read->fp = 0;\n\n\t\t\tcurl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);\n\t\t}\n\t}\n\tif (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {\n\t\tstream = zend_fetch_resource(&ch->handlers->write_header->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());\n\t\tif (stream == NULL) {\n\t\t\tif (reporterror) {\n\t\t\t\tphp_error_docref(NULL, E_WARNING, \"CURLOPT_WRITEHEADER resource has gone away, resetting to default\");\n\t\t\t}\n\t\t\tzval_ptr_dtor(&ch->handlers->write_header->stream);\n\t\t\tZVAL_UNDEF(&ch->handlers->write_header->stream);\n\t\t\tch->handlers->write_header->fp = 0;\n\n\t\t\tch->handlers->write_header->method = PHP_CURL_IGNORE;\n\t\t\tcurl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);\n\t\t}\n\t}\n\tif (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {\n\t\tstream = zend_fetch_resource(&ch->handlers->write->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());\n\t\tif (stream == NULL) {\n\t\t\tif (reporterror) {\n\t\t\t\tphp_error_docref(NULL, E_WARNING, \"CURLOPT_FILE resource has gone away, resetting to default\");\n\t\t\t}\n\t\t\tzval_ptr_dtor(&ch->handlers->write->stream);\n\t\t\tZVAL_UNDEF(&ch->handlers->write->stream);\n\t\t\tch->handlers->write->fp = 0;\n\n\t\t\tch->handlers->write->method = PHP_CURL_STDOUT;\n\t\t\tcurl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);\n\t\t}\n\t}\n\treturn ;\n}\n\/* }}} *\/\n","target":0,"code_token_length":720,"total_token_length":956,"max_tokens_setting":1024}
+{"idx":409212,"func":"static js_Ast *primary(js_State *J)\n{\n\tjs_Ast *a;\n\n\tif (J->lookahead == TK_IDENTIFIER) {\n\t\ta = jsP_newstrnode(J, EXP_IDENTIFIER, J->text);\n\t\tjsP_next(J);\n\t\treturn a;\n\t}\n\tif (J->lookahead == TK_STRING) {\n\t\ta = jsP_newstrnode(J, EXP_STRING, J->text);\n\t\tjsP_next(J);\n\t\treturn a;\n\t}\n\tif (J->lookahead == TK_REGEXP) {\n\t\ta = jsP_newstrnode(J, EXP_REGEXP, J->text);\n\t\ta->number = J->number;\n\t\tjsP_next(J);\n\t\treturn a;\n\t}\n\tif (J->lookahead == TK_NUMBER) {\n\t\ta = jsP_newnumnode(J, EXP_NUMBER, J->number);\n\t\tjsP_next(J);\n\t\treturn a;\n\t}\n\n\tif (jsP_accept(J, TK_THIS)) return EXP0(THIS);\n\tif (jsP_accept(J, TK_NULL)) return EXP0(NULL);\n\tif (jsP_accept(J, TK_TRUE)) return EXP0(TRUE);\n\tif (jsP_accept(J, TK_FALSE)) return EXP0(FALSE);\n\tif (jsP_accept(J, '{')) { a = EXP1(OBJECT, objectliteral(J)); jsP_expect(J, '}'); return a; }\n\tif (jsP_accept(J, '[')) { a = EXP1(ARRAY, arrayliteral(J)); jsP_expect(J, ']'); return a; }\n\tif (jsP_accept(J, '(')) { a = expression(J, 0); jsP_expect(J, ')'); return a; }\n\n\tjsP_error(J, \"unexpected token in expression: %s\", jsY_tokenstring(J->lookahead));\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":146991,"func":"TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n  TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n  TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n  const TfLiteTensor* input;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n  const TfLiteTensor* size;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kSizeTensor, &size));\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context,\n                    GetOutputSafe(context, node, kOutputTensor, &output));\n\n  \/\/ TODO(ahentz): Our current implementations rely on the inputs being 4D.\n  TF_LITE_ENSURE_EQ(context, NumDimensions(input), 4);\n  TF_LITE_ENSURE_EQ(context, NumDimensions(size), 1);\n\n  TF_LITE_ENSURE_EQ(context, size->type, kTfLiteInt32);\n  \/\/ ResizeBilinear creates a float tensor even when the input is made of\n  \/\/ integers.\n  output->type = input->type;\n\n  if (!IsConstantTensor(size)) {\n    SetTensorToDynamic(output);\n    return kTfLiteOk;\n  }\n\n  \/\/ Ensure params are valid.\n  auto* params =\n      reinterpret_cast<TfLiteResizeBilinearParams*>(node->builtin_data);\n  if (params->half_pixel_centers && params->align_corners) {\n    context->ReportError(\n        context, \"If half_pixel_centers is True, align_corners must be False.\");\n    return kTfLiteError;\n  }\n\n  return ResizeOutputTensor(context, input, size, output);\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":16258,"func":"void mime_field_name_value_set ( HdrHeap * heap , MIMEHdrImpl * mh , MIMEField * field , int16_t name_wks_idx_or_neg1 , const char * name , int name_length , const char * value , int value_length , int n_v_raw_printable , int n_v_raw_length , bool must_copy_strings ) {\n unsigned int n_v_raw_pad = n_v_raw_length - ( name_length + value_length ) ;\n ink_assert ( field -> m_readiness == MIME_FIELD_SLOT_READINESS_DETACHED ) ;\n if ( must_copy_strings ) {\n mime_field_name_set ( heap , mh , field , name_wks_idx_or_neg1 , name , name_length , true ) ;\n mime_field_value_set ( heap , mh , field , value , value_length , true ) ;\n }\n else {\n field -> m_wks_idx = name_wks_idx_or_neg1 ;\n field -> m_ptr_name = name ;\n field -> m_ptr_value = value ;\n field -> m_len_name = name_length ;\n field -> m_len_value = value_length ;\n if ( n_v_raw_printable && ( n_v_raw_pad <= 7 ) ) {\n field -> m_n_v_raw_printable = n_v_raw_printable ;\n field -> m_n_v_raw_printable_pad = n_v_raw_pad ;\n }\n else {\n field -> m_n_v_raw_printable = 0 ;\n }\n if ( ( name_wks_idx_or_neg1 == MIME_WKSIDX_CACHE_CONTROL ) || ( name_wks_idx_or_neg1 == MIME_WKSIDX_PRAGMA ) ) {\n field -> m_flags |= MIME_FIELD_SLOT_FLAGS_COOKED ;\n }\n if ( field -> is_live ( ) && field -> is_cooked ( ) ) {\n mh -> recompute_cooked_stuff ( field ) ;\n }\n }\n }","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":10677,"func":"PHP_FUNCTION(locale_get_all_variants)\n{\n\tconst char*  \tloc_name        = NULL;\n\tint    \t\tloc_name_len    = 0;\n\n\tint\tresult\t\t= 0;\n\tchar*\ttoken\t\t= NULL;\n\tchar*\tvariant\t\t= NULL;\n \tchar*\tsaved_ptr\t= NULL;\n \n \tintl_error_reset( NULL TSRMLS_CC );\n \tif(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, \"s\",\n \t&loc_name, &loc_name_len ) == FAILURE)\n \t{\n\t\tintl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,\n\t     \"locale_parse: unable to parse input params\", 0 TSRMLS_CC );\n\n\t\tRETURN_FALSE;\n\t}\n\n\tif(loc_name_len == 0) {\n\t\tloc_name = intl_locale_get_default(TSRMLS_C);\n\t}\n\n\n \tarray_init( return_value );\n \n \t\/* If the locale is grandfathered, stop, no variants *\/\n\tif( findOffset( LOC_GRANDFATHERED , loc_name ) >=  0 ){ \n \t\t\/* (\"Grandfathered Tag. No variants.\"); *\/\n \t}\n\telse {\t\n \t\/* Call ICU variant *\/\n \t\tvariant = get_icu_value_internal( loc_name , LOC_VARIANT_TAG , &result ,0);\n \t\tif( result > 0 && variant){\n \t\t\t\/* Tokenize on the \"_\" or \"-\" *\/\n\t\t\ttoken = php_strtok_r( variant , DELIMITER , &saved_ptr);\t\n \t\t\tadd_next_index_stringl( return_value, token , strlen(token) ,TRUE );\n \t\t\t\/* tokenize on the \"_\" or \"-\" and stop  at singleton if any\t*\/\n \t\t\twhile( (token = php_strtok_r(NULL , DELIMITER, &saved_ptr)) && (strlen(token)>1) ){\n \t\t\t\tadd_next_index_stringl( return_value, token , strlen(token) ,TRUE );\n\t\t\t}\n\t\t}\n\t\tif( variant ){\n \t\t\tefree( variant );\n \t\t}\n \t}\n \n }\n","target":1,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":25221,"func":"static void useNonBlockingConnectTimeout ( socket_handle_t sock ) {\n int res_snd ;\n int res_rcv ;\n # ifdef _WIN32 const DWORD socket_timeout = SOCKET_RW_TIMEOUT_MS ;\n unsigned long non_blocking = 1 ;\n res_snd = setsockopt ( sock , SOL_SOCKET , SO_SNDTIMEO , ( const char * ) & socket_timeout , sizeof ( socket_timeout ) ) ;\n res_rcv = setsockopt ( sock , SOL_SOCKET , SO_RCVTIMEO , ( const char * ) & socket_timeout , sizeof ( socket_timeout ) ) ;\n ioctlsocket ( sock , FIONBIO , & non_blocking ) ;\n # else const struct timeval socket_timeout = {\n . tv_sec = SOCKET_RW_TIMEOUT_MS \/ 1000 , . tv_usec = ( SOCKET_RW_TIMEOUT_MS % 1000 ) * 1000 }\n ;\n res_snd = setsockopt ( sock , SOL_SOCKET , SO_SNDTIMEO , & socket_timeout , sizeof ( socket_timeout ) ) ;\n res_rcv = setsockopt ( sock , SOL_SOCKET , SO_RCVTIMEO , & socket_timeout , sizeof ( socket_timeout ) ) ;\n # endif if ( res_snd != 0 ) g_debug ( \"Can't set socket timeout, using default\" ) ;\n if ( res_rcv != 0 ) g_debug ( \"Can't set socket timeout, using default\" ) ;\n }","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":131131,"func":"static int lxc_cgroupfs_enter(struct cgroup_process_info *info, pid_t pid, bool enter_sub)\n{\n\tchar pid_buf[32];\n\tchar *cgroup_tasks_fn;\n\tint r;\n\tstruct cgroup_process_info *info_ptr;\n\n\tsnprintf(pid_buf, 32, \"%lu\", (unsigned long)pid);\n\tfor (info_ptr = info; info_ptr; info_ptr = info_ptr->next) {\n\t\tchar *cgroup_path = (enter_sub && info_ptr->cgroup_path_sub) ?\n\t\t\tinfo_ptr->cgroup_path_sub :\n\t\t\tinfo_ptr->cgroup_path;\n\n\t\tif (!info_ptr->designated_mount_point) {\n\t\t\tinfo_ptr->designated_mount_point = lxc_cgroup_find_mount_point(info_ptr->hierarchy, cgroup_path, true);\n\t\t\tif (!info_ptr->designated_mount_point) {\n\t\t\t\tSYSERROR(\"Could not add pid %lu to cgroup %s: internal error (couldn't find any writable mountpoint to cgroup filesystem)\", (unsigned long)pid, cgroup_path);\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\n\t\tcgroup_tasks_fn = cgroup_to_absolute_path(info_ptr->designated_mount_point, cgroup_path, \"\/tasks\");\n\t\tif (!cgroup_tasks_fn) {\n\t\t\tSYSERROR(\"Could not add pid %lu to cgroup %s: internal error\", (unsigned long)pid, cgroup_path);\n\t\t\treturn -1;\n\t\t}\n\n\t\tr = lxc_write_to_file(cgroup_tasks_fn, pid_buf, strlen(pid_buf), false);\n\t\tfree(cgroup_tasks_fn);\n\t\tif (r < 0) {\n\t\t\tSYSERROR(\"Could not add pid %lu to cgroup %s: internal error\", (unsigned long)pid, cgroup_path);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":177609,"func":"DataPipeConsumerDispatcher::Deserialize(const void* data,\n                                        size_t num_bytes,\n                                        const ports::PortName* ports,\n                                        size_t num_ports,\n                                        PlatformHandle* handles,\n                                        size_t num_handles) {\n  if (num_ports != 1 || num_handles != 1 ||\n      num_bytes != sizeof(SerializedState)) {\n    return nullptr;\n  }\n \n   const SerializedState* state = static_cast<const SerializedState*>(data);\n   if (!state->options.capacity_num_bytes || !state->options.element_num_bytes ||\n      state->options.capacity_num_bytes < state->options.element_num_bytes ||\n      state->read_offset >= state->options.capacity_num_bytes ||\n      state->bytes_available > state->options.capacity_num_bytes) {\n     return nullptr;\n   }\n \n  NodeController* node_controller = Core::Get()->GetNodeController();\n  ports::PortRef port;\n  if (node_controller->node()->GetPort(ports[0], &port) != ports::OK)\n    return nullptr;\n\n  auto region_handle = CreateSharedMemoryRegionHandleFromPlatformHandles(\n      std::move(handles[0]), PlatformHandle());\n  auto region = base::subtle::PlatformSharedMemoryRegion::Take(\n      std::move(region_handle),\n      base::subtle::PlatformSharedMemoryRegion::Mode::kUnsafe,\n      state->options.capacity_num_bytes,\n      base::UnguessableToken::Deserialize(state->buffer_guid_high,\n                                          state->buffer_guid_low));\n  auto ring_buffer =\n      base::UnsafeSharedMemoryRegion::Deserialize(std::move(region));\n  if (!ring_buffer.IsValid()) {\n    DLOG(ERROR) << \"Failed to deserialize shared buffer handle.\";\n    return nullptr;\n  }\n\n  scoped_refptr<DataPipeConsumerDispatcher> dispatcher =\n      new DataPipeConsumerDispatcher(node_controller, port,\n                                     std::move(ring_buffer), state->options,\n                                     state->pipe_id);\n\n  {\n    base::AutoLock lock(dispatcher->lock_);\n    dispatcher->read_offset_ = state->read_offset;\n    dispatcher->bytes_available_ = state->bytes_available;\n    dispatcher->new_data_available_ = state->bytes_available > 0;\n     dispatcher->peer_closed_ = state->flags & kFlagPeerClosed;\n     if (!dispatcher->InitializeNoLock())\n       return nullptr;\n    if (state->options.capacity_num_bytes >\n        dispatcher->ring_buffer_mapping_.mapped_size()) {\n      return nullptr;\n    }\n     dispatcher->UpdateSignalsStateNoLock();\n   }\n \n  return dispatcher;\n}\n","target":0,"code_token_length":515,"total_token_length":751,"max_tokens_setting":1024}
+{"idx":228157,"func":"static void __mem_cgroup_clear_mc(void)\n{\n\tstruct mem_cgroup *from = mc.from;\n\tstruct mem_cgroup *to = mc.to;\n\n\t\/* we must uncharge all the leftover precharges from mc.to *\/\n\tif (mc.precharge) {\n\t\t__mem_cgroup_cancel_charge(mc.to, mc.precharge);\n\t\tmc.precharge = 0;\n\t}\n\t\/*\n\t * we didn't uncharge from mc.from at mem_cgroup_move_account(), so\n\t * we must uncharge here.\n\t *\/\n\tif (mc.moved_charge) {\n\t\t__mem_cgroup_cancel_charge(mc.from, mc.moved_charge);\n\t\tmc.moved_charge = 0;\n\t}\n\t\/* we must fixup refcnts and charges *\/\n\tif (mc.moved_swap) {\n\t\t\/* uncharge swap account from the old cgroup *\/\n\t\tif (!mem_cgroup_is_root(mc.from))\n\t\t\tres_counter_uncharge(&mc.from->memsw,\n\t\t\t\t\t\tPAGE_SIZE * mc.moved_swap);\n\t\t__mem_cgroup_put(mc.from, mc.moved_swap);\n\n\t\tif (!mem_cgroup_is_root(mc.to)) {\n\t\t\t\/*\n\t\t\t * we charged both to->res and to->memsw, so we should\n\t\t\t * uncharge to->res.\n\t\t\t *\/\n\t\t\tres_counter_uncharge(&mc.to->res,\n\t\t\t\t\t\tPAGE_SIZE * mc.moved_swap);\n\t\t}\n\t\t\/* we've already done mem_cgroup_get(mc.to) *\/\n\t\tmc.moved_swap = 0;\n\t}\n\tmemcg_oom_recover(from);\n\tmemcg_oom_recover(to);\n\twake_up_all(&mc.waitq);\n}\n","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":40204,"func":"Status OpLevelCostEstimator::PredictNaryOp(const OpContext& op_context,\n                                           NodeCosts* node_costs) const {\n  const auto& op_info = op_context.op_info;\n  bool found_unknown_shapes = false;\n  \/\/ Calculate the largest known tensor size across all inputs and output.\n  int64_t op_count = CalculateLargestInputCount(op_info, &found_unknown_shapes);\n  \/\/ If output shape is available, try to use the element count calculated from\n  \/\/ that.\n  if (op_info.outputs_size() > 0) {\n    op_count = std::max(\n        op_count,\n        CalculateTensorElementCount(op_info.outputs(0), &found_unknown_shapes));\n  }\n  \/\/ Also calculate the output shape possibly resulting from broadcasting.\n  \/\/ Note that the some Nary ops (such as AddN) do not support broadcasting,\n  \/\/ but we're including this here for completeness.\n  if (op_info.inputs_size() >= 2) {\n    op_count = std::max(op_count, CwiseOutputElementCount(op_info));\n  }\n\n  \/\/ Nary ops perform one operation for every element in every input tensor.\n  op_count *= op_info.inputs_size() - 1;\n\n  const auto sum_cost = Eigen::internal::functor_traits<\n      Eigen::internal::scalar_sum_op<float>>::Cost;\n  return PredictDefaultNodeCosts(op_count * sum_cost, op_context,\n                                 &found_unknown_shapes, node_costs);\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":388989,"func":"struct file_list *flist_new(int flags, char *msg)\n{\n\tstruct file_list *flist;\n\n\tif (!(flist = new0(struct file_list)))\n\t\tout_of_memory(msg);\n\n\tif (flags & FLIST_TEMP) {\n\t\tif (!(flist->file_pool = pool_create(SMALL_EXTENT, 0,\n\t\t\t\t\t\t     out_of_memory,\n\t\t\t\t\t\t     POOL_INTERN)))\n\t\t\tout_of_memory(msg);\n\t} else {\n\t\t\/* This is a doubly linked list with prev looping back to\n\t\t * the end of the list, but the last next pointer is NULL. *\/\n\t\tif (!first_flist) {\n\t\t\tflist->file_pool = pool_create(NORMAL_EXTENT, 0,\n\t\t\t\t\t\t       out_of_memory,\n\t\t\t\t\t\t       POOL_INTERN);\n\t\t\tif (!flist->file_pool)\n\t\t\t\tout_of_memory(msg);\n\n\t\t\tflist->ndx_start = flist->flist_num = inc_recurse ? 1 : 0;\n\n\t\t\tfirst_flist = cur_flist = flist->prev = flist;\n\t\t} else {\n\t\t\tstruct file_list *prev = first_flist->prev;\n\n\t\t\tflist->file_pool = first_flist->file_pool;\n\n\t\t\tflist->ndx_start = prev->ndx_start + prev->used + 1;\n\t\t\tflist->flist_num = prev->flist_num + 1;\n\n\t\t\tflist->prev = prev;\n\t\t\tprev->next = first_flist->prev = flist;\n\t\t}\n\t\tflist->pool_boundary = pool_boundary(flist->file_pool, 0);\n\t\tflist_cnt++;\n\t}\n\n\treturn flist;\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":508199,"func":"static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path,\n\t\t\t\tSTACK_OF(CONF_VALUE) *headers,\n\t\t\t\tOCSP_REQUEST *req, int req_timeout)\n\t{\n\tint fd;\n\tint rv;\n\tint i;\n\tOCSP_REQ_CTX *ctx = NULL;\n\tOCSP_RESPONSE *rsp = NULL;\n\tfd_set confds;\n\tstruct timeval tv;\n\n\tif (req_timeout != -1)\n\t\tBIO_set_nbio(cbio, 1);\n\n\trv = BIO_do_connect(cbio);\n\n\tif ((rv <= 0) && ((req_timeout == -1) || !BIO_should_retry(cbio)))\n\t\t{\n\t\tBIO_puts(err, \"Error connecting BIO\\n\");\n\t\treturn NULL;\n\t\t}\n\n\tif (BIO_get_fd(cbio, &fd) <= 0)\n\t\t{\n\t\tBIO_puts(err, \"Can't get connection fd\\n\");\n\t\tgoto err;\n\t\t}\n\n\tif (req_timeout != -1 && rv <= 0)\n\t\t{\n\t\tFD_ZERO(&confds);\n\t\topenssl_fdset(fd, &confds);\n\t\ttv.tv_usec = 0;\n\t\ttv.tv_sec = req_timeout;\n\t\trv = select(fd + 1, NULL, (void *)&confds, NULL, &tv);\n\t\tif (rv == 0)\n\t\t\t{\n\t\t\tBIO_puts(err, \"Timeout on connect\\n\");\n\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\n\n\tctx = OCSP_sendreq_new(cbio, path, NULL, -1);\n\tif (!ctx)\n\t\treturn NULL;\n\n\tfor (i = 0; i < sk_CONF_VALUE_num(headers); i++)\n\t\t{\n\t\tCONF_VALUE *hdr = sk_CONF_VALUE_value(headers, i);\n\t\tif (!OCSP_REQ_CTX_add1_header(ctx, hdr->name, hdr->value))\n\t\t\tgoto err;\n\t\t}\n\n\tif (!OCSP_REQ_CTX_set1_req(ctx, req))\n\t\tgoto err;\n\t\n\tfor (;;)\n\t\t{\n\t\trv = OCSP_sendreq_nbio(&rsp, ctx);\n\t\tif (rv != -1)\n\t\t\tbreak;\n\t\tif (req_timeout == -1)\n\t\t\tcontinue;\n\t\tFD_ZERO(&confds);\n\t\topenssl_fdset(fd, &confds);\n\t\ttv.tv_usec = 0;\n\t\ttv.tv_sec = req_timeout;\n\t\tif (BIO_should_read(cbio))\n\t\t\trv = select(fd + 1, (void *)&confds, NULL, NULL, &tv);\n\t\telse if (BIO_should_write(cbio))\n\t\t\trv = select(fd + 1, NULL, (void *)&confds, NULL, &tv);\n\t\telse\n\t\t\t{\n\t\t\tBIO_puts(err, \"Unexpected retry condition\\n\");\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (rv == 0)\n\t\t\t{\n\t\t\tBIO_puts(err, \"Timeout on request\\n\");\n\t\t\tbreak;\n\t\t\t}\n\t\tif (rv == -1)\n\t\t\t{\n\t\t\tBIO_puts(err, \"Select error\\n\");\n\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\terr:\n\tif (ctx)\n\t\tOCSP_REQ_CTX_free(ctx);\n\n\treturn rsp;\n\t}","target":0,"code_token_length":657,"total_token_length":893,"max_tokens_setting":1024}
+{"idx":309439,"func":"void NavigationControllerImpl::Reload(ReloadType reload_type,\n                                      bool check_for_repost) {\n  if (transient_entry_index_ != -1) {\n    NavigationEntryImpl* transient_entry = GetTransientEntry();\n    if (!transient_entry)\n      return;\n    LoadURL(transient_entry->GetURL(),\n            Referrer(),\n            ui::PAGE_TRANSITION_RELOAD,\n            transient_entry->extra_headers());\n    return;\n  }\n\n  NavigationEntryImpl* entry = NULL;\n  int current_index = -1;\n\n  if (IsInitialNavigation() && pending_entry_) {\n    entry = pending_entry_;\n    current_index = pending_entry_index_;\n  } else {\n    DiscardNonCommittedEntriesInternal();\n    current_index = GetCurrentEntryIndex();\n    if (current_index != -1) {\n      entry = GetEntryAtIndex(current_index);\n    }\n  }\n\n  if (!entry)\n    return;\n\n  if (last_committed_reload_type_ != ReloadType::NONE) {\n    DCHECK(!last_committed_reload_time_.is_null());\n    base::Time now =\n        time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run());\n    DCHECK_GT(now, last_committed_reload_time_);\n    if (!last_committed_reload_time_.is_null() &&\n        now > last_committed_reload_time_) {\n      base::TimeDelta delta = now - last_committed_reload_time_;\n      UMA_HISTOGRAM_MEDIUM_TIMES(\"Navigation.Reload.ReloadToReloadDuration\",\n                                 delta);\n      if (last_committed_reload_type_ == ReloadType::NORMAL) {\n        UMA_HISTOGRAM_MEDIUM_TIMES(\n            \"Navigation.Reload.ReloadMainResourceToReloadDuration\", delta);\n      }\n    }\n  }\n\n  entry->set_reload_type(reload_type);\n\n  if (g_check_for_repost && check_for_repost &&\n      entry->GetHasPostData()) {\n    delegate_->NotifyBeforeFormRepostWarningShow();\n\n    pending_reload_ = reload_type;\n    delegate_->ActivateAndShowRepostFormWarningDialog();\n  } else {\n    if (!IsInitialNavigation())\n      DiscardNonCommittedEntriesInternal();\n\n    SiteInstanceImpl* site_instance = entry->site_instance();\n    bool is_for_guests_only = site_instance && site_instance->HasProcess() &&\n        site_instance->GetProcess()->IsForGuestsOnly();\n    if (!is_for_guests_only && site_instance &&\n        site_instance->HasWrongProcessForURL(entry->GetURL())) {\n      NavigationEntryImpl* nav_entry = NavigationEntryImpl::FromNavigationEntry(\n          CreateNavigationEntry(\n              entry->GetURL(), entry->GetReferrer(), entry->GetTransitionType(),\n              false, entry->extra_headers(), browser_context_).release());\n\n      reload_type = ReloadType::NONE;\n\n      nav_entry->set_should_replace_entry(true);\n      pending_entry_ = nav_entry;\n      DCHECK_EQ(-1, pending_entry_index_);\n    } else {\n      pending_entry_ = entry;\n      pending_entry_index_ = current_index;\n\n      pending_entry_->SetTitle(base::string16());\n\n      pending_entry_->SetTransitionType(ui::PAGE_TRANSITION_RELOAD);\n    }\n\n    NavigateToPendingEntry(reload_type);\n  }\n}\n","target":0,"code_token_length":658,"total_token_length":894,"max_tokens_setting":1024}
+{"idx":203332,"func":"void GLES2DecoderImpl::DoCompressedTexSubImage2D(\n  GLenum target,\n  GLint level,\n  GLint xoffset,\n  GLint yoffset,\n  GLsizei width,\n  GLsizei height,\n  GLenum format,\n  GLsizei image_size,\n  const void * data) {\n  TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);\n  if (!info) {\n    SetGLError(GL_INVALID_OPERATION,\n               \"glCompressedTexSubImage2D: unknown texture for target\");\n    return;\n  }\n  GLenum type = 0;\n  GLenum internal_format = 0;\n  if (!info->GetLevelType(target, level, &type, &internal_format)) {\n    SetGLError(\n        GL_INVALID_OPERATION,\n        \"glCompressdTexSubImage2D: level does not exist.\");\n    return;\n  }\n  if (internal_format != format) {\n    SetGLError(\n        GL_INVALID_OPERATION,\n        \"glCompressdTexSubImage2D: format does not match internal format.\");\n    return;\n  }\n  if (!info->ValidForTexture(\n      target, level, xoffset, yoffset, width, height, format, type)) {\n    SetGLError(GL_INVALID_VALUE,\n               \"glCompressdTexSubImage2D: bad dimensions.\");\n    return;\n  }\n  glCompressedTexSubImage2D(\n      target, level, xoffset, yoffset, width, height, format, image_size, data);\n}\n","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":67461,"func":"static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,\n                               PKCS7_RECIP_INFO *ri, EVP_PKEY *pkey)\n{\n    EVP_PKEY_CTX *pctx = NULL;\n    unsigned char *ek = NULL;\n    size_t eklen;\n\n    int ret = -1;\n\n    pctx = EVP_PKEY_CTX_new(pkey, NULL);\n    if (!pctx)\n        return -1;\n\n    if (EVP_PKEY_decrypt_init(pctx) <= 0)\n        goto err;\n\n    if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DECRYPT,\n                          EVP_PKEY_CTRL_PKCS7_DECRYPT, 0, ri) <= 0) {\n        PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, PKCS7_R_CTRL_ERROR);\n        goto err;\n    }\n\n    if (EVP_PKEY_decrypt(pctx, NULL, &eklen,\n                         ri->enc_key->data, ri->enc_key->length) <= 0)\n        goto err;\n\n    ek = OPENSSL_malloc(eklen);\n\n    if (ek == NULL) {\n        PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    if (EVP_PKEY_decrypt(pctx, ek, &eklen,\n                         ri->enc_key->data, ri->enc_key->length) <= 0) {\n        ret = 0;\n        PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_EVP_LIB);\n        goto err;\n    }\n\n    ret = 1;\n\n    OPENSSL_clear_free(*pek, *peklen);\n    *pek = ek;\n    *peklen = eklen;\n\n err:\n    EVP_PKEY_CTX_free(pctx);\n    if (!ret)\n        OPENSSL_free(ek);\n\n    return ret;\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":101900,"func":"static int pnm_gethdr(jas_stream_t *in, pnm_hdr_t *hdr)\n{\n\tint_fast32_t maxval;\n\tint_fast32_t width;\n\tint_fast32_t height;\n\tint type;\n\n\tif (pnm_getint16(in, &hdr->magic) || pnm_getsintstr(in, &width) ||\n\t  pnm_getsintstr(in, &height)) {\n\t\treturn -1;\n\t}\n\thdr->width = width;\n\thdr->height = height;\n\tif ((type = pnm_type(hdr->magic)) == PNM_TYPE_INVALID) {\n\t\treturn -1;\n\t}\n\tif (type != PNM_TYPE_PBM) {\n\t\tif (pnm_getsintstr(in, &maxval)) {\n\t\t\treturn -1;\n\t\t}\n\t} else {\n\t\tmaxval = 1;\n\t}\n\tif (maxval < 0) {\n\t\thdr->maxval = -maxval;\n\t\thdr->sgnd = true;\n\t} else {\n\t\thdr->maxval = maxval;\n\t\thdr->sgnd = false;\n\t}\n\n\tswitch (type) {\n\tcase PNM_TYPE_PBM:\n\tcase PNM_TYPE_PGM:\n\t\thdr->numcmpts = 1;\n\t\tbreak;\n\tcase PNM_TYPE_PPM:\n\t\thdr->numcmpts = 3;\n\t\tbreak;\n\tdefault:\n\t\tabort();\n\t\tbreak;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":400861,"func":"ref_param_begin_read_collection(gs_param_list * plist, gs_param_name pkey,\n                                gs_param_dict * pvalue,\n                                gs_param_collection_type_t coll_type)\n{\n    iparam_list *const iplist = (iparam_list *) plist;\n    iparam_loc loc;\n    bool int_keys = coll_type != 0;\n    int code = ref_param_read(iplist, pkey, &loc, -1);\n    dict_param_list *dlist;\n\n    if (code != 0)\n        return code;\n    dlist = (dict_param_list *)\n        gs_alloc_bytes(plist->memory, size_of(dict_param_list),\n                       \"ref_param_begin_read_collection\");\n    if (dlist == 0)\n        return_error(gs_error_VMerror);\n    if (r_has_type(loc.pvalue, t_dictionary)) {\n        code = dict_param_list_read(dlist, loc.pvalue, NULL, false,\n                                    iplist->ref_memory);\n        dlist->int_keys = int_keys;\n        if (code >= 0)\n            pvalue->size = dict_length(loc.pvalue);\n    } else if (int_keys && r_is_array(loc.pvalue)) {\n        code = array_indexed_param_list_read(dlist, loc.pvalue, NULL, false,\n                                             iplist->ref_memory);\n        if (code >= 0)\n            pvalue->size = r_size(loc.pvalue);\n    } else\n        code = gs_note_error(gs_error_typecheck);\n    if (code < 0) {\n        gs_free_object(plist->memory, dlist, \"ref_param_begin_write_collection\");\n        return iparam_note_error(loc, code);\n    }\n    pvalue->list = (gs_param_list *) dlist;\n    return 0;\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":31753,"func":"static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,\n\t\t\t\t  ext4_lblk_t len, loff_t new_size,\n\t\t\t\t  int flags, int mode)\n{\n\tstruct inode *inode = file_inode(file);\n\thandle_t *handle;\n\tint ret = 0;\n\tint ret2 = 0;\n\tint retries = 0;\n\tint depth = 0;\n\tstruct ext4_map_blocks map;\n\tunsigned int credits;\n\tloff_t epos;\n\n\tmap.m_lblk = offset;\n\tmap.m_len = len;\n\t\/*\n\t * Don't normalize the request if it can fit in one extent so\n\t * that it doesn't get unnecessarily split into multiple\n\t * extents.\n\t *\/\n\tif (len <= EXT_UNWRITTEN_MAX_LEN)\n\t\tflags |= EXT4_GET_BLOCKS_NO_NORMALIZE;\n\n\t\/* Wait all existing dio workers, newcomers will block on i_mutex *\/\n\text4_inode_block_unlocked_dio(inode);\n\tinode_dio_wait(inode);\n\n\t\/*\n\t * credits to insert 1 extent into extent tree\n\t *\/\n\tcredits = ext4_chunk_trans_blocks(inode, len);\n\t\/*\n\t * We can only call ext_depth() on extent based inodes\n\t *\/\n\tif (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))\n\t\tdepth = ext_depth(inode);\n\telse\n\t\tdepth = -1;\n\nretry:\n\twhile (ret >= 0 && len) {\n\t\t\/*\n\t\t * Recalculate credits when extent tree depth changes.\n\t\t *\/\n\t\tif (depth >= 0 && depth != ext_depth(inode)) {\n\t\t\tcredits = ext4_chunk_trans_blocks(inode, len);\n\t\t\tdepth = ext_depth(inode);\n\t\t}\n\n\t\thandle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,\n\t\t\t\t\t    credits);\n\t\tif (IS_ERR(handle)) {\n\t\t\tret = PTR_ERR(handle);\n\t\t\tbreak;\n\t\t}\n\t\tret = ext4_map_blocks(handle, inode, &map, flags);\n\t\tif (ret <= 0) {\n\t\t\text4_debug(\"inode #%lu: block %u: len %u: \"\n\t\t\t\t   \"ext4_ext_map_blocks returned %d\",\n\t\t\t\t   inode->i_ino, map.m_lblk,\n\t\t\t\t   map.m_len, ret);\n\t\t\text4_mark_inode_dirty(handle, inode);\n\t\t\tret2 = ext4_journal_stop(handle);\n\t\t\tbreak;\n\t\t}\n\t\tmap.m_lblk += ret;\n\t\tmap.m_len = len = len - ret;\n\t\tepos = (loff_t)map.m_lblk << inode->i_blkbits;\n\t\tinode->i_ctime = ext4_current_time(inode);\n\t\tif (new_size) {\n\t\t\tif (epos > new_size)\n\t\t\t\tepos = new_size;\n\t\t\tif (ext4_update_inode_size(inode, epos) & 0x1)\n\t\t\t\tinode->i_mtime = inode->i_ctime;\n\t\t} else {\n\t\t\tif (epos > inode->i_size)\n\t\t\t\text4_set_inode_flag(inode,\n\t\t\t\t\t\t    EXT4_INODE_EOFBLOCKS);\n\t\t}\n\t\text4_mark_inode_dirty(handle, inode);\n\t\tret2 = ext4_journal_stop(handle);\n\t\tif (ret2)\n\t\t\tbreak;\n\t}\n\tif (ret == -ENOSPC &&\n\t\t\text4_should_retry_alloc(inode->i_sb, &retries)) {\n\t\tret = 0;\n\t\tgoto retry;\n\t}\n\n\text4_inode_resume_unlocked_dio(inode);\n\n\treturn ret > 0 ? ret2 : ret;\n}","target":0,"code_token_length":719,"total_token_length":955,"max_tokens_setting":1024}
+{"idx":11794,"func":"aspath_put (struct stream *s, struct aspath *as, int use32bit )\n{\n  struct assegment *seg = as->segments;\n  size_t bytes = 0;\n  \n  if (!seg || seg->length == 0)\n    return 0;\n  \n  if (seg)\n    {\n      \/*\n       * Hey, what do we do when we have > STREAM_WRITABLE(s) here?\n       * At the moment, we would write out a partial aspath, and our peer\n       * will complain and drop the session :-\/\n       *\n       * The general assumption here is that many things tested will\n       * never happen.  And, in real live, up to now, they have not.\n       *\/\n      while (seg && (ASSEGMENT_LEN(seg, use32bit) <= STREAM_WRITEABLE(s)))\n        {\n          struct assegment *next = seg->next;\n          int written = 0;\n          int asns_packed = 0;\n          size_t lenp;\n          \n          \/* Overlength segments have to be split up *\/\n          while ( (seg->length - written) > AS_SEGMENT_MAX)\n            {\n               assegment_header_put (s, seg->type, AS_SEGMENT_MAX);\n               assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);\n               written += AS_SEGMENT_MAX;\n              bytes += ASSEGMENT_SIZE (written, use32bit);\n             }\n           \n           \/* write the final segment, probably is also the first *\/\n          lenp = assegment_header_put (s, seg->type, seg->length - written);\n          assegment_data_put (s, (seg->as + written), seg->length - written, \n                              use32bit);\n          \n          \/* Sequence-type segments can be 'packed' together\n           * Case of a segment which was overlength and split up\n           * will be missed here, but that doesn't matter.\n           *\/\n          while (next && ASSEGMENTS_PACKABLE (seg, next))\n            {\n              \/* NB: We should never normally get here given we\n               * normalise aspath data when parse them. However, better\n               * safe than sorry. We potentially could call\n               * assegment_normalise here instead, but it's cheaper and\n               * easier to do it on the fly here rather than go through\n               * the segment list twice every time we write out\n               * aspath's.\n               *\/\n              \n              \/* Next segment's data can fit in this one *\/\n              assegment_data_put (s, next->as, next->length, use32bit);\n              \n              \/* update the length of the segment header *\/\n\t      stream_putc_at (s, lenp, seg->length - written + next->length);\n              asns_packed += next->length;\n               \n\t      next = next->next;\n\t    }\n          \n          bytes += ASSEGMENT_SIZE (seg->length - written + asns_packed, \n\t\t\t\t   use32bit);\n          seg = next;\n        }\n    }\n  return bytes;\n}\n","target":1,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":407500,"func":"static int theme_read(THEME_REC *theme, const char *path)\n{\n\tCONFIG_REC *config;\n\tTHEME_READ_REC rec;\n        char *str;\n\n\tconfig = config_open(path, -1) ;\n\tif (config == NULL) {\n\t\t\/* didn't exist or no access? *\/\n\t\tstr = g_strdup_printf(\"Error reading theme file %s: %s\",\n\t\t\t\t      path, g_strerror(errno));\n\t\tread_error(str);\n\t\tg_free(str);\n\t\treturn FALSE;\n\t}\n\n\tif (path == NULL)\n\t\tconfig_parse_data(config, default_theme, \"internal\");\n        else\n\t\tconfig_parse(config);\n\n\tif (config_last_error(config) != NULL) {\n\t\tstr = g_strdup_printf(\"Ignored errors in theme %s:\\n%s\",\n\t\t\t\t      theme->name, config_last_error(config));\n\t\tread_error(str);\n                g_free(str);\n\t}\n\n\ttheme->default_color =\n\t\tconfig_get_int(config, NULL, \"default_color\", -1);\n\ttheme->info_eol = config_get_bool(config, NULL, \"info_eol\", FALSE);\n\n\ttheme_read_replaces(config, theme);\n\n\tif (path != NULL)\n\t\ttheme_copy_abstracts(theme, internal_theme);\n\ttheme_read_abstracts(config, theme);\n\n\trec.theme = theme;\n\trec.config = config;\n\tg_hash_table_foreach(default_formats,\n\t\t\t     (GHFunc) theme_read_modules, &rec);\n\tconfig_close(config);\n\n        return TRUE;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":316515,"func":"void FoFiType1C::getFontMatrix(double *mat) {\n  int i;\n\n  if (topDict.firstOp == 0x0c1e && privateDicts[0].hasFontMatrix) {\n    if (topDict.hasFontMatrix) {\n      mat[0] = topDict.fontMatrix[0] * privateDicts[0].fontMatrix[0] +\n\t       topDict.fontMatrix[1] * privateDicts[0].fontMatrix[2];\n      mat[1] = topDict.fontMatrix[0] * privateDicts[0].fontMatrix[1] +\n               topDict.fontMatrix[1] * privateDicts[0].fontMatrix[3];\n      mat[2] = topDict.fontMatrix[2] * privateDicts[0].fontMatrix[0] +\n\t       topDict.fontMatrix[3] * privateDicts[0].fontMatrix[2];\n      mat[3] = topDict.fontMatrix[2] * privateDicts[0].fontMatrix[1] +\n\t       topDict.fontMatrix[3] * privateDicts[0].fontMatrix[3];\n      mat[4] = topDict.fontMatrix[4] * privateDicts[0].fontMatrix[0] +\n\t       topDict.fontMatrix[5] * privateDicts[0].fontMatrix[2];\n      mat[5] = topDict.fontMatrix[4] * privateDicts[0].fontMatrix[1] +\n\t       topDict.fontMatrix[5] * privateDicts[0].fontMatrix[3];\n    } else {\n      for (i = 0; i < 6; ++i) {\n\tmat[i] = privateDicts[0].fontMatrix[i];\n      }\n    }\n  } else {\n    for (i = 0; i < 6; ++i) {\n      mat[i] = topDict.fontMatrix[i];\n    }\n  }\n}\n","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":348081,"func":"static int iccdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr)\n{\n    int components, i, code = 0;\n    ref *tempref, ICCdict, valref;\n\n    code = array_get(imemory, space, 1, &ICCdict);\n    if (code < 0)\n        return code;\n    code = dict_find_string(&ICCdict, \"N\", &tempref);\n    if (code < 0)\n        return code;\n    if (code == 0)\n        return gs_note_error(gs_error_undefined);\n    components = tempref->value.intval;\n    code = dict_find_string(&ICCdict, \"Range\", &tempref);\n    if (code > 0 && !r_has_type(tempref, t_null)) {\n        for (i=0;i<components * 2;i++) {\n            code = array_get(imemory, tempref, i, &valref);\n            if (code < 0)\n                return code;\n            if (r_has_type(&valref, t_integer))\n                ptr[i * 2] = (float)valref.value.intval;\n            else\n                ptr[i * 2] = valref.value.realval;\n        }\n    } else {\n        for (i=0;i<components;i++) {\n            ptr[i * 2] = 0;\n            ptr[(i * 2) + 1] = 1;\n        }\n    }\n    return 0;\n}","target":1,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":402821,"func":"poolGrow(STRING_POOL *pool)\n{\n  if (pool->freeBlocks) {\n    if (pool->start == 0) {\n      pool->blocks = pool->freeBlocks;\n      pool->freeBlocks = pool->freeBlocks->next;\n      pool->blocks->next = NULL;\n      pool->start = pool->blocks->s;\n      pool->end = pool->start + pool->blocks->size;\n      pool->ptr = pool->start;\n      return XML_TRUE;\n    }\n    if (pool->end - pool->start < pool->freeBlocks->size) {\n      BLOCK *tem = pool->freeBlocks->next;\n      pool->freeBlocks->next = pool->blocks;\n      pool->blocks = pool->freeBlocks;\n      pool->freeBlocks = tem;\n      memcpy(pool->blocks->s, pool->start,\n             (pool->end - pool->start) * sizeof(XML_Char));\n      pool->ptr = pool->blocks->s + (pool->ptr - pool->start);\n      pool->start = pool->blocks->s;\n      pool->end = pool->start + pool->blocks->size;\n      return XML_TRUE;\n    }\n  }\n  if (pool->blocks && pool->start == pool->blocks->s) {\n    BLOCK *temp;\n    int blockSize = (int)((unsigned)(pool->end - pool->start)*2U);\n    size_t bytesToAllocate;\n\n    if (blockSize < 0)\n      return XML_FALSE;\n\n    bytesToAllocate = poolBytesToAllocateFor(blockSize);\n    if (bytesToAllocate == 0)\n      return XML_FALSE;\n\n    temp = (BLOCK *)\n      pool->mem->realloc_fcn(pool->blocks, (unsigned)bytesToAllocate);\n    if (temp == NULL)\n      return XML_FALSE;\n    pool->blocks = temp;\n    pool->blocks->size = blockSize;\n    pool->ptr = pool->blocks->s + (pool->ptr - pool->start);\n    pool->start = pool->blocks->s;\n    pool->end = pool->start + blockSize;\n  }\n  else {\n    BLOCK *tem;\n    int blockSize = (int)(pool->end - pool->start);\n    size_t bytesToAllocate;\n\n    if (blockSize < 0)\n      return XML_FALSE;\n\n    if (blockSize < INIT_BLOCK_SIZE)\n      blockSize = INIT_BLOCK_SIZE;\n    else {\n      \/* Detect overflow, avoiding _signed_ overflow undefined behavior *\/\n      if ((int)((unsigned)blockSize * 2U) < 0) {\n        return XML_FALSE;\n      }\n      blockSize *= 2;\n    }\n\n    bytesToAllocate = poolBytesToAllocateFor(blockSize);\n    if (bytesToAllocate == 0)\n      return XML_FALSE;\n\n    tem = (BLOCK *)pool->mem->malloc_fcn(bytesToAllocate);\n    if (!tem)\n      return XML_FALSE;\n    tem->size = blockSize;\n    tem->next = pool->blocks;\n    pool->blocks = tem;\n    if (pool->ptr != pool->start)\n      memcpy(tem->s, pool->start,\n             (pool->ptr - pool->start) * sizeof(XML_Char));\n    pool->ptr = tem->s + (pool->ptr - pool->start);\n    pool->start = tem->s;\n    pool->end = tem->s + blockSize;\n  }\n  return XML_TRUE;\n}","target":0,"code_token_length":707,"total_token_length":943,"max_tokens_setting":1024}
+{"idx":313915,"func":"void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) {\n\tchar\t*s;\n\tchar\tinfo[MAX_INFO_STRING];\n\tint\ti, l, score, ping;\n\tint\tlen;\n\tserverStatus_t *serverStatus;\n\n\tserverStatus = NULL;\n\tfor ( i = 0; i < MAX_SERVERSTATUSREQUESTS; i++ ) {\n\t\tif ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) {\n\t\t\tserverStatus = &cl_serverStatusList[i];\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( !serverStatus ) {\n\t\treturn;\n\t}\n\n\ts = MSG_ReadStringLine( msg );\n\n\tlen = 0;\n\tCom_sprintf( &serverStatus->string[len], sizeof( serverStatus->string ) - len, \"%s\", s );\n\n\tif ( serverStatus->print ) {\n\t\tCom_Printf( \"Server settings:\\n\" );\n\t\twhile ( *s ) {\n\t\t\tfor ( i = 0; i < 2 && *s; i++ ) {\n\t\t\t\tif ( *s == '\\\\' ) {\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t\tl = 0;\n\t\t\t\twhile ( *s ) {\n\t\t\t\t\tinfo[l++] = *s;\n\t\t\t\t\tif ( l >= MAX_INFO_STRING - 1 ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\ts++;\n\t\t\t\t\tif ( *s == '\\\\' ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tinfo[l] = '\\0';\n\t\t\t\tif ( i ) {\n\t\t\t\t\tCom_Printf( \"%s\\n\", info );\n\t\t\t\t} else {\n\t\t\t\t\tCom_Printf( \"%-24s\", info );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlen = strlen( serverStatus->string );\n\tCom_sprintf( &serverStatus->string[len], sizeof( serverStatus->string ) - len, \"\\\\\" );\n\n\tif ( serverStatus->print ) {\n\t\tCom_Printf( \"\\nPlayers:\\n\" );\n\t\tCom_Printf( \"num: score: ping: name:\\n\" );\n\t}\n\tfor ( i = 0, s = MSG_ReadStringLine( msg ); *s; s = MSG_ReadStringLine( msg ), i++ ) {\n\n\t\tlen = strlen( serverStatus->string );\n\t\tCom_sprintf( &serverStatus->string[len], sizeof( serverStatus->string ) - len, \"\\\\%s\", s );\n\n\t\tif ( serverStatus->print ) {\n\t\t\tscore = ping = 0;\n\t\t\tsscanf( s, \"%d %d\", &score, &ping );\n\t\t\ts = strchr( s, ' ' );\n\t\t\tif ( s ) {\n\t\t\t\ts = strchr( s + 1, ' ' );\n\t\t\t}\n\t\t\tif ( s ) {\n\t\t\t\ts++;\n\t\t\t} else {\n\t\t\t\ts = \"unknown\";\n\t\t\t}\n\t\t\tCom_Printf( \"%-2d   %-3d    %-3d   %s\\n\", i, score, ping, s );\n\t\t}\n\t}\n\tlen = strlen( serverStatus->string );\n\tCom_sprintf( &serverStatus->string[len], sizeof( serverStatus->string ) - len, \"\\\\\" );\n\n\tserverStatus->time = Com_Milliseconds();\n\tserverStatus->address = from;\n\tserverStatus->pending = qfalse;\n\tif (serverStatus->print) {\n\t\tserverStatus->retrieved = qtrue;\n\t}\n}\n","target":0,"code_token_length":686,"total_token_length":922,"max_tokens_setting":1024}
+{"idx":20946,"func":"static void read_intra_frame_mode_info ( VP9_COMMON * const cm , MACROBLOCKD * const xd , int mi_row , int mi_col , vp9_reader * r ) {\n MODE_INFO * const mi = xd -> mi [ 0 ] . src_mi ;\n MB_MODE_INFO * const mbmi = & mi -> mbmi ;\n const MODE_INFO * above_mi = xd -> mi [ - cm -> mi_stride ] . src_mi ;\n const MODE_INFO * left_mi = xd -> left_available ? xd -> mi [ - 1 ] . src_mi : NULL ;\n const BLOCK_SIZE bsize = mbmi -> sb_type ;\n int i ;\n mbmi -> segment_id = read_intra_segment_id ( cm , xd , mi_row , mi_col , r ) ;\n mbmi -> skip = read_skip ( cm , xd , mbmi -> segment_id , r ) ;\n mbmi -> tx_size = read_tx_size ( cm , xd , cm -> tx_mode , bsize , 1 , r ) ;\n mbmi -> ref_frame [ 0 ] = INTRA_FRAME ;\n mbmi -> ref_frame [ 1 ] = NONE ;\n switch ( bsize ) {\n case BLOCK_4X4 : for ( i = 0 ;\n i < 4 ;\n ++ i ) mi -> bmi [ i ] . as_mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , i ) ) ;\n mbmi -> mode = mi -> bmi [ 3 ] . as_mode ;\n break ;\n case BLOCK_4X8 : mi -> bmi [ 0 ] . as_mode = mi -> bmi [ 2 ] . as_mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ;\n mi -> bmi [ 1 ] . as_mode = mi -> bmi [ 3 ] . as_mode = mbmi -> mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 1 ) ) ;\n break ;\n case BLOCK_8X4 : mi -> bmi [ 0 ] . as_mode = mi -> bmi [ 1 ] . as_mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ;\n mi -> bmi [ 2 ] . as_mode = mi -> bmi [ 3 ] . as_mode = mbmi -> mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 2 ) ) ;\n break ;\n default : mbmi -> mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ;\n }\n mbmi -> uv_mode = read_intra_mode ( r , vp9_kf_uv_mode_prob [ mbmi -> mode ] ) ;\n }","target":0,"code_token_length":590,"total_token_length":826,"max_tokens_setting":1024}
+{"idx":347372,"func":"int ZipStreamBuf::readFromDevice(char* buffer, std::streamsize length)\n{\n\tif (!_ptrBuf) return 0; \/\/ directory entry\n\t_ptrBuf->read(buffer, length);\n\tint cnt = static_cast<int>(_ptrBuf->gcount());\n\tif (cnt > 0)\n\t{\n\t\t_crc32.update(buffer, cnt);\n\t}\n\telse\n\t{\n\t\tif (_crc32.checksum() != _expectedCrc32)\n\t\t{\n\t\t\tif (_checkCRC)\n\t\t\t\tthrow ZipException(\"CRC failure\");\n\t\t\telse\n\t\t\t{\n\t\t\t\t\/\/ the CRC value is written directly after the data block\n\t\t\t\t\/\/ parse it directly from the input stream\n\t\t\t\tZipDataInfo nfo(*_pIstr, false);\n\t\t\t\t\/\/ now push back the header to the stream, so that the ZipLocalFileHeader can read it\n\t\t\t\tPoco::Int32 size = static_cast<Poco::Int32>(nfo.getFullHeaderSize());\n\t\t\t\t_expectedCrc32 = nfo.getCRC32();\n\t\t\t\tconst char* rawHeader = nfo.getRawHeader();\n\t\t\t\t_pIstr->seekg(-size, std::ios::cur);\n\t\t\t\tif (!_pIstr->good()) throw Poco::IOException(\"Failed to seek on input stream\");\n\t\t\t\tif (!crcValid())\n\t\t\t\t\tthrow ZipException(\"CRC failure\");\n\t\t\t}\n\t\t}\n\t}\n\treturn cnt;\n}","target":1,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":440596,"func":"static struct rtable *geneve_get_v4_rt(struct sk_buff *skb,\n\t\t\t\t       struct net_device *dev,\n\t\t\t\t       struct geneve_sock *gs4,\n\t\t\t\t       struct flowi4 *fl4,\n\t\t\t\t       const struct ip_tunnel_info *info)\n{\n\tbool use_cache = ip_tunnel_dst_cache_usable(skb, info);\n\tstruct geneve_dev *geneve = netdev_priv(dev);\n\tstruct dst_cache *dst_cache;\n\tstruct rtable *rt = NULL;\n\t__u8 tos;\n\n\tif (!gs4)\n\t\treturn ERR_PTR(-EIO);\n\n\tmemset(fl4, 0, sizeof(*fl4));\n\tfl4->flowi4_mark = skb->mark;\n\tfl4->flowi4_proto = IPPROTO_UDP;\n\tfl4->daddr = info->key.u.ipv4.dst;\n\tfl4->saddr = info->key.u.ipv4.src;\n\n\ttos = info->key.tos;\n\tif ((tos == 1) && !geneve->collect_md) {\n\t\ttos = ip_tunnel_get_dsfield(ip_hdr(skb), skb);\n\t\tuse_cache = false;\n\t}\n\tfl4->flowi4_tos = RT_TOS(tos);\n\n\tdst_cache = (struct dst_cache *)&info->dst_cache;\n\tif (use_cache) {\n\t\trt = dst_cache_get_ip4(dst_cache, &fl4->saddr);\n\t\tif (rt)\n\t\t\treturn rt;\n\t}\n\trt = ip_route_output_key(geneve->net, fl4);\n\tif (IS_ERR(rt)) {\n\t\tnetdev_dbg(dev, \"no route to %pI4\\n\", &fl4->daddr);\n\t\treturn ERR_PTR(-ENETUNREACH);\n\t}\n\tif (rt->dst.dev == dev) { \/* is this necessary? *\/\n\t\tnetdev_dbg(dev, \"circular route to %pI4\\n\", &fl4->daddr);\n\t\tip_rt_put(rt);\n\t\treturn ERR_PTR(-ELOOP);\n\t}\n\tif (use_cache)\n\t\tdst_cache_set_ip4(dst_cache, &rt->dst, fl4->saddr);\n\treturn rt;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":284464,"func":"construct_le_tlv(struct sc_apdu *apdu, unsigned char *apdu_buf, size_t data_tlv_len,\n\t\tunsigned char *le_tlv, size_t * le_tlv_len, const unsigned char key_type)\n{\n\tsize_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);\n\n\t*(apdu_buf + block_size + data_tlv_len) = 0x97;\n\tif (apdu->le > 0x7F) {\n\t\t\/* Le' > 0x7E, use extended APDU *\/\n\t\t*(apdu_buf + block_size + data_tlv_len + 1) = 2;\n\t\t*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)(apdu->le \/ 0x100);\n\t\t*(apdu_buf + block_size + data_tlv_len + 3) = (unsigned char)(apdu->le % 0x100);\n\t\tmemcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 4);\n\t\t*le_tlv_len = 4;\n\t}\n\telse {\n\t\t*(apdu_buf + block_size + data_tlv_len + 1) = 1;\n\t\t*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)apdu->le;\n\t\tmemcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 3);\n\t\t*le_tlv_len = 3;\n\t}\n\treturn 0;\n}\n","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":156881,"func":"SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)\n{\n\tint read_bytes;\n\tint allocated_bytes=SAPI_POST_BLOCK_SIZE+1;\n\n\tif ((SG(post_max_size) > 0) && (SG(request_info).content_length > SG(post_max_size))) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"POST Content-Length of %ld bytes exceeds the limit of %ld bytes\",\n\t\t\t\t\tSG(request_info).content_length, SG(post_max_size));\n\t\treturn;\n\t}\n\tSG(request_info).post_data = emalloc(allocated_bytes);\n\n\tfor (;;) {\n\t\tread_bytes = sapi_module.read_post(SG(request_info).post_data+SG(read_post_bytes), SAPI_POST_BLOCK_SIZE TSRMLS_CC);\n\t\tif (read_bytes<=0) {\n\t\t\tbreak;\n\t\t}\n\t\tSG(read_post_bytes) += read_bytes;\n\t\tif ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Actual POST length does not match Content-Length, and exceeds %ld bytes\", SG(post_max_size));\n\t\t\tbreak;\n\t\t}\n\t\tif (read_bytes < SAPI_POST_BLOCK_SIZE) {\n\t\t\tbreak;\n\t\t}\n\t\tif (SG(read_post_bytes)+SAPI_POST_BLOCK_SIZE >= allocated_bytes) {\n\t\t\tallocated_bytes = SG(read_post_bytes)+SAPI_POST_BLOCK_SIZE+1;\n\t\t\tSG(request_info).post_data = erealloc(SG(request_info).post_data, allocated_bytes);\n\t\t}\n\t}\n\tSG(request_info).post_data[SG(read_post_bytes)] = 0;  \/* terminating NULL *\/\n\tSG(request_info).post_data_length = SG(read_post_bytes);\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":253445,"func":"AddGPUScreen(Bool (*pfnInit) (ScreenPtr \/*pScreen *\/ ,\n                              int \/*argc *\/ ,\n                              char **      \/*argv *\/\n                              ),\n             int argc, char **argv)\n{\n    int i;\n    ScreenPtr pScreen;\n    Bool ret;\n\n    i = screenInfo.numGPUScreens;\n    if (i == MAXGPUSCREENS)\n        return -1;\n\n    pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec));\n    if (!pScreen)\n        return -1;\n\n    ret = init_screen(pScreen, i, TRUE);\n    if (ret != 0) {\n        free(pScreen);\n        return ret;\n    }\n\n    \/* This is where screen specific stuff gets initialized.  Load the\n       screen structure, call the hardware, whatever.\n       This is also where the default colormap should be allocated and\n       also pixel values for blackPixel, whitePixel, and the cursor\n       Note that InitScreen is NOT allowed to modify argc, argv, or\n       any of the strings pointed to by argv.  They may be passed to\n       multiple screens.\n     *\/\n    screenInfo.gpuscreens[i] = pScreen;\n    screenInfo.numGPUScreens++;\n    if (!(*pfnInit) (pScreen, argc, argv)) {\n        dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);\n        free(pScreen);\n        screenInfo.numGPUScreens--;\n        return -1;\n    }\n\n    update_desktop_dimensions();\n\n    \/*\n     * We cannot register the Screen PRIVATE_CURSOR key if cursors are already\n     * created, because dix\/privates.c does not have relocation code for\n     * PRIVATE_CURSOR. Once this is fixed the if() can be removed and we can\n     * register the Screen PRIVATE_CURSOR key unconditionally.\n     *\/\n    if (!dixPrivatesCreated(PRIVATE_CURSOR))\n        dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen,\n                                    PRIVATE_CURSOR, 0);\n\n    return i;\n}\n","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":28086,"func":"static void decode_band_structure ( GetBitContext * gbc , int blk , int eac3 , int ecpl , int start_subband , int end_subband , const uint8_t * default_band_struct , int * num_bands , uint8_t * band_sizes ) {\n int subbnd , bnd , n_subbands , n_bands = 0 ;\n uint8_t bnd_sz [ 22 ] ;\n uint8_t coded_band_struct [ 22 ] ;\n const uint8_t * band_struct ;\n n_subbands = end_subband - start_subband ;\n if ( ! eac3 || get_bits1 ( gbc ) ) {\n for ( subbnd = 0 ;\n subbnd < n_subbands - 1 ;\n subbnd ++ ) {\n coded_band_struct [ subbnd ] = get_bits1 ( gbc ) ;\n }\n band_struct = coded_band_struct ;\n }\n else if ( ! blk ) {\n band_struct = & default_band_struct [ start_subband + 1 ] ;\n }\n else {\n return ;\n }\n if ( num_bands || band_sizes ) {\n n_bands = n_subbands ;\n bnd_sz [ 0 ] = ecpl ? 6 : 12 ;\n for ( bnd = 0 , subbnd = 1 ;\n subbnd < n_subbands ;\n subbnd ++ ) {\n int subbnd_size = ( ecpl && subbnd < 4 ) ? 6 : 12 ;\n if ( band_struct [ subbnd - 1 ] ) {\n n_bands -- ;\n bnd_sz [ bnd ] += subbnd_size ;\n }\n else {\n bnd_sz [ ++ bnd ] = subbnd_size ;\n }\n }\n }\n if ( num_bands ) * num_bands = n_bands ;\n if ( band_sizes ) memcpy ( band_sizes , bnd_sz , n_bands ) ;\n }","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":349069,"func":"TEST_F(ConnectionHandlerTest, TransportProtocolCustom) {\n  TestListener* test_listener = addListener(1, true, false, \"test_listener\");\n  Network::MockListener* listener = new Network::MockListener();\n  Network::ListenerCallbacks* listener_callbacks;\n  EXPECT_CALL(dispatcher_, createListener_(_, _, _))\n      .WillOnce(\n          Invoke([&](Network::Socket&, Network::ListenerCallbacks& cb, bool) -> Network::Listener* {\n            listener_callbacks = &cb;\n            return listener;\n          }));\n  EXPECT_CALL(test_listener->socket_, localAddress());\n  handler_->addListener(*test_listener);\n\n  Network::MockListenerFilter* test_filter = new Network::MockListenerFilter();\n  EXPECT_CALL(factory_, createListenerFilterChain(_))\n      .WillRepeatedly(Invoke([&](Network::ListenerFilterManager& manager) -> bool {\n        manager.addAcceptFilter(Network::ListenerFilterPtr{test_filter});\n        return true;\n      }));\n  absl::string_view dummy = \"dummy\";\n  EXPECT_CALL(*test_filter, onAccept(_))\n      .WillOnce(Invoke([&](Network::ListenerFilterCallbacks& cb) -> Network::FilterStatus {\n        cb.socket().setDetectedTransportProtocol(dummy);\n        return Network::FilterStatus::Continue;\n      }));\n  Network::MockConnectionSocket* accepted_socket = new NiceMock<Network::MockConnectionSocket>();\n  EXPECT_CALL(*accepted_socket, setDetectedTransportProtocol(dummy));\n  EXPECT_CALL(*accepted_socket, detectedTransportProtocol()).WillOnce(Return(dummy));\n  EXPECT_CALL(manager_, findFilterChain(_)).WillOnce(Return(nullptr));\n  listener_callbacks->onAccept(Network::ConnectionSocketPtr{accepted_socket});\n\n  EXPECT_CALL(*listener, onDestroy());\n}","target":1,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":303066,"func":"lldpd_send(struct lldpd_hardware *hardware)\n{\n\tstruct lldpd *cfg = hardware->h_cfg;\n\tstruct lldpd_port *port;\n\tint i, sent;\n\n\tif (cfg->g_config.c_receiveonly || cfg->g_config.c_paused) return;\n\tif (hardware->h_lport.p_disable_tx) return;\n\tif ((hardware->h_flags & IFF_RUNNING) == 0)\n\t\treturn;\n\n\tlog_debug(\"send\", \"send PDU on %s\", hardware->h_ifname);\n\tsent = 0;\n\tfor (i=0; cfg->g_protocols[i].mode != 0; i++) {\n\t\tif (!cfg->g_protocols[i].enabled)\n\t\t\tcontinue;\n\t\t\/* We send only if we have at least one remote system\n\t\t * speaking this protocol or if the protocol is forced *\/\n\t\tif (cfg->g_protocols[i].enabled > 1) {\n\t\t\tcfg->g_protocols[i].send(cfg, hardware);\n\t\t\tsent++;\n\t\t\tcontinue;\n\t\t}\n\t\tTAILQ_FOREACH(port, &hardware->h_rports, p_entries) {\n\t\t\t\/* If this remote port is disabled, we don't\n\t\t\t * consider it *\/\n\t\t\tif (port->p_hidden_out)\n\t\t\t\tcontinue;\n\t\t\tif (port->p_protocol ==\n\t\t\t    cfg->g_protocols[i].mode) {\n\t\t\t\tTRACE(LLDPD_FRAME_SEND(hardware->h_ifname,\n\t\t\t\t\tcfg->g_protocols[i].name));\n\t\t\t\tlog_debug(\"send\", \"send PDU on %s with protocol %s\",\n\t\t\t\t    hardware->h_ifname,\n\t\t\t\t    cfg->g_protocols[i].name);\n\t\t\t\tcfg->g_protocols[i].send(cfg,\n\t\t\t\t    hardware);\n\t\t\t\tsent++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!sent) {\n\t\t\/* Nothing was sent for this port, let's speak the first\n\t\t * available protocol. *\/\n\t\tfor (i = 0; cfg->g_protocols[i].mode != 0; i++) {\n\t\t\tif (!cfg->g_protocols[i].enabled) continue;\n\t\t\tTRACE(LLDPD_FRAME_SEND(hardware->h_ifname,\n\t\t\t\tcfg->g_protocols[i].name));\n\t\t\tlog_debug(\"send\", \"fallback to protocol %s for %s\",\n\t\t\t    cfg->g_protocols[i].name, hardware->h_ifname);\n\t\t\tcfg->g_protocols[i].send(cfg,\n\t\t\t    hardware);\n\t\t\tbreak;\n\t\t}\n\t\tif (cfg->g_protocols[i].mode == 0)\n\t\t\tlog_warnx(\"send\", \"no protocol enabled, dunno what to send\");\n\t}\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":133304,"func":"gstd_accept(int fd, char **display_creds, char **export_name, char **mech)\n{\n\tgss_name_t\t client;\n\tgss_OID\t\t mech_oid;\n\tstruct gstd_tok *tok;\n\tgss_ctx_id_t\t ctx = GSS_C_NO_CONTEXT;\n\tgss_buffer_desc\t in, out;\n\tOM_uint32\t maj, min;\n\tint\t\t ret;\n\n\t*display_creds = NULL;\n\t*export_name = NULL;\n\tout.length = 0;\n\tin.length = 0;\n\tread_packet(fd, &in, 60000, 1);\nagain:\n\twhile ((ret = read_packet(fd, &in, 60000, 0)) == -2)\n\t\t;\n\n\tif (ret < 1)\n\t\treturn NULL;\n\n\tmaj = gss_accept_sec_context(&min, &ctx, GSS_C_NO_CREDENTIAL,\n\t    &in, GSS_C_NO_CHANNEL_BINDINGS, &client, &mech_oid, &out, NULL,\n\t    NULL, NULL);\n\n\tgss_release_buffer(&min, &in);\n\n\tif (out.length && write_packet(fd, &out)) {\n\t\tgss_release_buffer(&min, &out);\n\t\treturn NULL;\n\t}\n\tgss_release_buffer(&min, &out);\n\n\tGSTD_GSS_ERROR(maj, min, NULL, \"gss_accept_sec_context\");\n\n\tif (maj & GSS_S_CONTINUE_NEEDED)\n\t\tgoto again;\n\n\t*display_creds = gstd_get_display_name(client);\n\t*export_name = gstd_get_export_name(client);\n\t*mech = gstd_get_mech(mech_oid);\n\n\tgss_release_name(&min, &client);\n\tSETUP_GSTD_TOK(tok, ctx, fd, \"gstd_accept\");\n\treturn tok;\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":328529,"func":"static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx)\n\n{\n\n    uint64_t mfindex;\n\n\n\n    DPRINTF(\"xhci_submit(slotid=%d,epid=%d)\\n\", xfer->slotid, xfer->epid);\n\n\n\n    xfer->in_xfer = epctx->type>>2;\n\n\n\n    switch(epctx->type) {\n\n    case ET_INTR_OUT:\n\n    case ET_INTR_IN:\n\n        xfer->pkts = 0;\n\n        xfer->iso_xfer = false;\n\n        xfer->timed_xfer = true;\n\n        mfindex = xhci_mfindex_get(xhci);\n\n        xhci_calc_intr_kick(xhci, xfer, epctx, mfindex);\n\n        xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex);\n\n        if (xfer->running_retry) {\n\n            return -1;\n\n        }\n\n        break;\n\n    case ET_BULK_OUT:\n\n    case ET_BULK_IN:\n\n        xfer->pkts = 0;\n\n        xfer->iso_xfer = false;\n\n        xfer->timed_xfer = false;\n\n        break;\n\n    case ET_ISO_OUT:\n\n    case ET_ISO_IN:\n\n        xfer->pkts = 1;\n\n        xfer->iso_xfer = true;\n\n        xfer->timed_xfer = true;\n\n        mfindex = xhci_mfindex_get(xhci);\n\n        xhci_calc_iso_kick(xhci, xfer, epctx, mfindex);\n\n        xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex);\n\n        if (xfer->running_retry) {\n\n            return -1;\n\n        }\n\n        break;\n\n    default:\n\n        trace_usb_xhci_unimplemented(\"endpoint type\", epctx->type);\n\n        return -1;\n\n    }\n\n\n\n    if (xhci_setup_packet(xfer) < 0) {\n\n        return -1;\n\n    }\n\n    usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);\n\n\n\n    xhci_try_complete_packet(xfer);\n\n    if (!xfer->running_async && !xfer->running_retry) {\n\n        xhci_kick_epctx(xfer->epctx, xfer->streamid);\n\n    }\n\n    return 0;\n\n}\n","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":354162,"func":"bool TABLE::vcol_fix_exprs(THD *thd)\n{\n  if (pos_in_table_list->placeholder() || !s->vcols_need_refixing ||\n      pos_in_table_list->lock_type < TL_WRITE_ALLOW_WRITE)\n    return false;\n\n  DBUG_ASSERT(pos_in_table_list != thd->lex->first_not_own_table());\n\n  bool result= true;\n  Security_context *save_security_ctx= thd->security_ctx;\n  Query_arena *stmt_backup= thd->stmt_arena;\n  if (thd->stmt_arena->is_conventional())\n    thd->stmt_arena= expr_arena;\n\n  if (pos_in_table_list->security_ctx)\n    thd->security_ctx= pos_in_table_list->security_ctx;\n\n\n  for (Field **vf= vfield; vf && *vf; vf++)\n    if ((*vf)->vcol_info->fix_session_expr(thd))\n      goto end;\n\n  for (Field **df= default_field; df && *df; df++)\n    if ((*df)->default_value &&\n        (*df)->default_value->fix_session_expr(thd))\n      goto end;\n\n  for (Virtual_column_info **cc= check_constraints; cc && *cc; cc++)\n    if ((*cc)->fix_session_expr(thd))\n      goto end;\n\n  result= false;\n\nend:\n  thd->security_ctx= save_security_ctx;\n  thd->stmt_arena= stmt_backup;\n\n  return result;\n}","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":471939,"func":"sds sdsResize(sds s, size_t size) {\n    void *sh, *newsh;\n    char type, oldtype = s[-1] & SDS_TYPE_MASK;\n    int hdrlen, oldhdrlen = sdsHdrSize(oldtype);\n    size_t len = sdslen(s);\n    sh = (char*)s-oldhdrlen;\n\n    \/* Return ASAP if the size is already good. *\/\n    if (sdsalloc(s) == size) return s;\n\n    \/* Truncate len if needed. *\/\n    if (size < len) len = size;\n\n    \/* Check what would be the minimum SDS header that is just good enough to\n     * fit this string. *\/\n    type = sdsReqType(size);\n    \/* Don't use type 5, it is not good for strings that are resized. *\/\n    if (type == SDS_TYPE_5) type = SDS_TYPE_8;\n    hdrlen = sdsHdrSize(type);\n\n    \/* If the type is the same, or can hold the size in it with low overhead\n     * (larger than SDS_TYPE_8), we just realloc(), letting the allocator\n     * to do the copy only if really needed. Otherwise if the change is\n     * huge, we manually reallocate the string to use the different header\n     * type. *\/\n    if (oldtype==type || (type < oldtype && type > SDS_TYPE_8)) {\n        newsh = s_realloc(sh, oldhdrlen+size+1);\n        if (newsh == NULL) return NULL;\n        s = (char*)newsh+oldhdrlen;\n    } else {\n        newsh = s_malloc(hdrlen+size+1);\n        if (newsh == NULL) return NULL;\n        memcpy((char*)newsh+hdrlen, s, len);\n        s_free(sh);\n        s = (char*)newsh+hdrlen;\n        s[-1] = type;\n    }\n    s[len] = 0;\n    sdssetlen(s, len);\n    sdssetalloc(s, size);\n    return s;\n}","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":397812,"func":"png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,\n    png_const_charp name, png_uint_32 profile_length)\n{\n   if (!icc_check_length(png_ptr, colorspace, name, profile_length))\n      return 0;\n\n   \/* This needs to be here because the 'normal' check is in\n    * png_decompress_chunk, yet this happens after the attempt to\n    * png_malloc_base the required data.  We only need this on read; on write\n    * the caller supplies the profile buffer so libpng doesn't allocate it.  See\n    * the call to icc_check_length below (the write case).\n    *\/\n#  ifdef PNG_SET_USER_LIMITS_SUPPORTED\n      else if (png_ptr->user_chunk_malloc_max > 0 &&\n               png_ptr->user_chunk_malloc_max < profile_length)\n         return png_icc_profile_error(png_ptr, colorspace, name, profile_length,\n             \"exceeds application limits\");\n#  elif PNG_USER_CHUNK_MALLOC_MAX > 0\n      else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length)\n         return png_icc_profile_error(png_ptr, colorspace, name, profile_length,\n             \"exceeds libpng limits\");\n#  else \/* !SET_USER_LIMITS *\/\n      \/* This will get compiled out on all 32-bit and better systems. *\/\n      else if (PNG_SIZE_MAX < profile_length)\n         return png_icc_profile_error(png_ptr, colorspace, name, profile_length,\n             \"exceeds system limits\");\n#  endif \/* !SET_USER_LIMITS *\/\n\n   return 1;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":11751,"func":"static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,\n  MagickOffsetType PS_Offset,ssize_t PS_Size,ExceptionInfo *exception)\n{\n  char\n    postscript_file[MaxTextExtent];\n\n  const MagicInfo\n    *magic_info;\n\n  FILE\n    *ps_file;\n\n  ImageInfo\n    *clone_info;\n\n  Image\n    *image2;\n\n  unsigned char\n    magick[2*MaxTextExtent];\n\n\n  if ((clone_info=CloneImageInfo(image_info)) == NULL)\n    return(image);\n  clone_info->blob=(void *) NULL;\n  clone_info->length=0;\n\n  \/* Obtain temporary file *\/\n  (void) AcquireUniqueFilename(postscript_file);\n  ps_file=fopen_utf8(postscript_file,\"wb\");\n  if (ps_file == (FILE *) NULL)\n    goto FINISH;\n\n  \/* Copy postscript to temporary file *\/\n  (void) SeekBlob(image,PS_Offset,SEEK_SET);\n  (void) ReadBlob(image, 2*MaxTextExtent, magick);\n\n  (void) SeekBlob(image,PS_Offset,SEEK_SET);\n  while(PS_Size-- > 0)\n    {\n      (void) fputc(ReadBlobByte(image),ps_file);\n    }\n  (void) fclose(ps_file);\n\n    \/* Detect file format - Check magic.mgk configuration file. *\/\n  magic_info=GetMagicInfo(magick,2*MaxTextExtent,exception);\n  if(magic_info == (const MagicInfo *) NULL) goto FINISH_UNL;\n  \/*     printf(\"Detected:%s  \\n\",magic_info->name); *\/\n   if(exception->severity != UndefinedException) goto FINISH_UNL;\n   if(magic_info->name == (char *) NULL) goto FINISH_UNL;\n \n  (void) CopyMagickMemory(clone_info->magick,magic_info->name,MaxTextExtent);\n \n     \/* Read nested image *\/\n   \/*FormatString(clone_info->filename,\"%s:%s\",magic_info->name,postscript_file);*\/\n  FormatLocaleString(clone_info->filename,MaxTextExtent,\"%s\",postscript_file);\n  image2=ReadImage(clone_info,exception);\n\n  if (!image2)\n    goto FINISH_UNL;\n\n  \/*\n    Replace current image with new image while copying base image\n    attributes.\n  *\/\n  (void) CopyMagickMemory(image2->filename,image->filename,MaxTextExtent);\n  (void) CopyMagickMemory(image2->magick_filename,image->magick_filename,MaxTextExtent);\n  (void) CopyMagickMemory(image2->magick,image->magick,MaxTextExtent);\n  image2->depth=image->depth;\n  DestroyBlob(image2);\n  image2->blob=ReferenceBlob(image->blob);\n\n  if ((image->rows == 0) || (image->columns == 0))\n    DeleteImageFromList(&image);\n\n  AppendImageToList(&image,image2);\n\n FINISH_UNL:\n  (void) RelinquishUniqueFileResource(postscript_file);\n FINISH:\n  DestroyImageInfo(clone_info);\n  return(image);\n}\n","target":1,"code_token_length":656,"total_token_length":892,"max_tokens_setting":1024}
+{"idx":321464,"func":"static void init_proc_750fx (CPUPPCState *env)\n\n{\n\n    gen_spr_ne_601(env);\n\n    gen_spr_7xx(env);\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_L2CR, \"L2CR\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, NULL,\n\n                 0x00000000);\n\n    \/* Time base *\/\n\n    gen_tbl(env);\n\n    \/* Thermal management *\/\n\n    gen_spr_thrm(env);\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_750_THRM4, \"THRM4\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* Hardware implementation registers *\/\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_HID0, \"HID0\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_HID1, \"HID1\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_750FX_HID2, \"HID2\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* Memory management *\/\n\n    gen_low_BATs(env);\n\n    \/* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs *\/\n\n    gen_high_BATs(env);\n\n    init_excp_7x0(env);\n\n    env->dcache_line_size = 32;\n\n    env->icache_line_size = 32;\n\n    \/* Allocate hardware IRQ controller *\/\n\n    ppc6xx_irq_init(env);\n\n}\n","target":1,"code_token_length":448,"total_token_length":684,"max_tokens_setting":1024}
+{"idx":174422,"func":"void Document::setDomain(const String& newDomain, ExceptionState& exceptionState)\n{\n    UseCounter::count(*this, UseCounter::DocumentSetDomain);\n\n    if (isSandboxed(SandboxDocumentDomain)) {\n        exceptionState.throwSecurityError(\"Assignment is forbidden for sandboxed iframes.\");\n        return;\n    }\n\n    if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(getSecurityOrigin()->protocol())) {\n        exceptionState.throwSecurityError(\"Assignment is forbidden for the '\" + getSecurityOrigin()->protocol() + \"' scheme.\");\n        return;\n    }\n\n    if (newDomain.isEmpty()) {\n        exceptionState.throwSecurityError(\"'\" + newDomain + \"' is an empty domain.\");\n        return;\n    }\n\n    OriginAccessEntry accessEntry(getSecurityOrigin()->protocol(), newDomain, OriginAccessEntry::AllowSubdomains);\n    OriginAccessEntry::MatchResult result = accessEntry.matchesOrigin(*getSecurityOrigin());\n    if (result == OriginAccessEntry::DoesNotMatchOrigin) {\n        exceptionState.throwSecurityError(\"'\" + newDomain + \"' is not a suffix of '\" + domain() + \"'.\");\n        return;\n    }\n\n    if (result == OriginAccessEntry::MatchesOriginButIsPublicSuffix) {\n        exceptionState.throwSecurityError(\"'\" + newDomain + \"' is a top-level domain.\");\n        return;\n    }\n\n    getSecurityOrigin()->setDomainFromDOM(newDomain);\n    if (m_frame)\n        m_frame->script().updateSecurityOrigin(getSecurityOrigin());\n}\n","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":319935,"func":"static int qemu_rbd_set_conf(rados_t cluster, const char *conf)\n\n{\n\n    char *p, *buf;\n\n    char name[RBD_MAX_CONF_NAME_SIZE];\n\n    char value[RBD_MAX_CONF_VAL_SIZE];\n\n    int ret = 0;\n\n\n\n    buf = g_strdup(conf);\n\n    p = buf;\n\n\n\n    while (p) {\n\n        ret = qemu_rbd_next_tok(name, sizeof(name), p,\n\n                                '=', \"conf option name\", &p);\n\n        if (ret < 0) {\n\n            break;\n\n        }\n\n\n\n        if (!p) {\n\n            error_report(\"conf option %s has no value\", name);\n\n            ret = -EINVAL;\n\n            break;\n\n        }\n\n\n\n        ret = qemu_rbd_next_tok(value, sizeof(value), p,\n\n                                ':', \"conf option value\", &p);\n\n        if (ret < 0) {\n\n            break;\n\n        }\n\n\n\n        if (strcmp(name, \"conf\")) {\n\n            ret = rados_conf_set(cluster, name, value);\n\n            if (ret < 0) {\n\n                error_report(\"invalid conf option %s\", name);\n\n                ret = -EINVAL;\n\n                break;\n\n            }\n\n        } else {\n\n            ret = rados_conf_read_file(cluster, value);\n\n            if (ret < 0) {\n\n                error_report(\"error reading conf file %s\", value);\n\n                break;\n\n            }\n\n        }\n\n    }\n\n\n\n    g_free(buf);\n\n    return ret;\n\n}\n","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":3843,"func":"error_t tja1101Init(NetInterface *interface)\n{\n   uint16_t value;\n\n   \/\/Debug message\n   TRACE_INFO(\"Initializing TJA1101...\\r\\n\");\n\n   \/\/Undefined PHY address?\n   if(interface->phyAddr >= 32)\n   {\n      \/\/Use the default address\n      interface->phyAddr = TJA1101_PHY_ADDR;\n   }\n\n   \/\/Initialize serial management interface\n   if(interface->smiDriver != NULL)\n   {\n      interface->smiDriver->init();\n   }\n\n   \/\/Initialize external interrupt line driver\n   if(interface->extIntDriver != NULL)\n   {\n      interface->extIntDriver->init();\n   }\n\n   \/\/Reset PHY transceiver\n   tja1101WritePhyReg(interface, TJA1101_BASIC_CTRL,\n      TJA1101_BASIC_CTRL_RESET);\n\n   \/\/Wait for the reset to complete\n   while(tja1101ReadPhyReg(interface, TJA1101_BASIC_CTRL) &\n      TJA1101_BASIC_CTRL_RESET)\n   {\n   }\n\n   \/\/Dump PHY registers for debugging purpose\n   tja1101DumpPhyReg(interface);\n\n   \/\/Enable configuration register access\n   value = tja1101ReadPhyReg(interface, TJA1101_EXTENDED_CTRL);\n   value |= TJA1101_EXTENDED_CTRL_CONFIG_EN;\n   tja1101WritePhyReg(interface, TJA1101_EXTENDED_CTRL, value);\n\n   \/\/Select RMII mode (25MHz XTAL)\n   value = tja1101ReadPhyReg(interface, TJA1101_CONFIG1);\n   value &= ~TJA1101_CONFIG1_MII_MODE;\n   value |= TJA1101_CONFIG1_MII_MODE_RMII_25MHZ;\n   tja1101WritePhyReg(interface, TJA1101_CONFIG1, value);\n\n   \/\/The PHY is configured for autonomous operation\n   value = tja1101ReadPhyReg(interface, TJA1101_COMM_CTRL);\n   value |= TJA1101_COMM_CTRL_AUTO_OP;\n   tja1101WritePhyReg(interface, TJA1101_COMM_CTRL, value);\n\n   \/\/Force the TCP\/IP stack to poll the link state at startup\n   interface->phyEvent = TRUE;\n   \/\/Notify the TCP\/IP stack of the event\n   osSetEvent(&netEvent);\n\n   \/\/Successful initialization\n   return NO_ERROR;\n}","target":1,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":330119,"func":"static int vc1t_read_header(AVFormatContext *s,\n\n                           AVFormatParameters *ap)\n\n{\n\n    ByteIOContext *pb = s->pb;\n\n    AVStream *st;\n\n    int fps, frames;\n\n\n\n    frames = get_le24(pb);\n\n    if(get_byte(pb) != 0xC5 || get_le32(pb) != 4)\n\n        return -1;\n\n\n\n    \/* init video codec *\/\n\n    st = av_new_stream(s, 0);\n\n    if (!st)\n\n        return -1;\n\n\n\n    st->codec->codec_type = CODEC_TYPE_VIDEO;\n\n    st->codec->codec_id = CODEC_ID_WMV3;\n\n\n\n    st->codec->extradata = av_malloc(VC1_EXTRADATA_SIZE);\n\n    st->codec->extradata_size = VC1_EXTRADATA_SIZE;\n\n    get_buffer(pb, st->codec->extradata, VC1_EXTRADATA_SIZE);\n\n    st->codec->height = get_le32(pb);\n\n    st->codec->width = get_le32(pb);\n\n    if(get_le32(pb) != 0xC)\n\n        return -1;\n\n    url_fskip(pb, 8);\n\n    fps = get_le32(pb);\n\n    if(fps == -1)\n\n        av_set_pts_info(st, 32, 1, 1000);\n\n    else{\n\n        av_set_pts_info(st, 24, 1, fps);\n\n        st->duration = frames;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":53651,"func":"static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)\n{\n\tswitch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) {\n\tcase INET_ECN_NOT_ECT:\n\t\t\/* Funny extension: if ECT is not set on a segment,\n\t\t * and we already seen ECT on a previous segment,\n\t\t * it is probably a retransmit.\n\t\t *\/\n\t\tif (tp->ecn_flags & TCP_ECN_SEEN)\n\t\t\ttcp_enter_quickack_mode((struct sock *)tp);\n\t\tbreak;\n\tcase INET_ECN_CE:\n\t\tif (tcp_ca_needs_ecn((struct sock *)tp))\n\t\t\ttcp_ca_event((struct sock *)tp, CA_EVENT_ECN_IS_CE);\n\n\t\tif (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {\n\t\t\t\/* Better not delay acks, sender can have a very low cwnd *\/\n\t\t\ttcp_enter_quickack_mode((struct sock *)tp);\n\t\t\ttp->ecn_flags |= TCP_ECN_DEMAND_CWR;\n\t\t}\n\t\ttp->ecn_flags |= TCP_ECN_SEEN;\n\t\tbreak;\n\tdefault:\n\t\tif (tcp_ca_needs_ecn((struct sock *)tp))\n\t\t\ttcp_ca_event((struct sock *)tp, CA_EVENT_ECN_NO_CE);\n\t\ttp->ecn_flags |= TCP_ECN_SEEN;\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":108863,"func":"mailimf_name_val_pair_parse(const char * message, size_t length,\n\t\t\t    size_t * indx,\n\t\t\t    struct mailimf_name_val_pair ** result)\n{\n  size_t cur_token;\n  char * item_name;\n  struct mailimf_item_value * item_value;\n  struct mailimf_name_val_pair * name_val_pair;\n  int r;\n  int res;\n\n  cur_token = * indx;\n\n  r = mailimf_cfws_parse(message, length, &cur_token);\n  if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {\n    res = r;\n    goto err;\n  }\n  \n  r = mailimf_item_name_parse(message, length, &cur_token, &item_name);\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto err;\n  }\n\n  r = mailimf_cfws_parse(message, length, &cur_token);\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto free_item_name;\n  }\n\n  r = mailimf_item_value_parse(message, length, &cur_token, &item_value);\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto free_item_name;\n  }\n\n  name_val_pair = mailimf_name_val_pair_new(item_name, item_value);\n  if (name_val_pair == NULL) {\n    res = MAILIMF_ERROR_MEMORY;\n    goto free_item_value;\n  }\n\n  * result = name_val_pair;\n  * indx = cur_token;\n\n  return MAILIMF_NO_ERROR;\n\n free_item_value:\n  mailimf_item_value_free(item_value);\n free_item_name:\n  mailimf_item_name_free(item_name);\n err:\n  return res;\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":397244,"func":"static void ehci_trace_usbsts(uint32_t mask, int state)\n{\n    \/* interrupts *\/\n    if (mask & USBSTS_INT) {\n        trace_usb_ehci_usbsts(\"INT\", state);\n    }\n    if (mask & USBSTS_ERRINT) {\n        trace_usb_ehci_usbsts(\"ERRINT\", state);\n    }\n    if (mask & USBSTS_PCD) {\n        trace_usb_ehci_usbsts(\"PCD\", state);\n    }\n    if (mask & USBSTS_FLR) {\n        trace_usb_ehci_usbsts(\"FLR\", state);\n    }\n    if (mask & USBSTS_HSE) {\n        trace_usb_ehci_usbsts(\"HSE\", state);\n    }\n    if (mask & USBSTS_IAA) {\n        trace_usb_ehci_usbsts(\"IAA\", state);\n    }\n\n    \/* status *\/\n    if (mask & USBSTS_HALT) {\n        trace_usb_ehci_usbsts(\"HALT\", state);\n    }\n    if (mask & USBSTS_REC) {\n        trace_usb_ehci_usbsts(\"REC\", state);\n    }\n    if (mask & USBSTS_PSS) {\n        trace_usb_ehci_usbsts(\"PSS\", state);\n    }\n    if (mask & USBSTS_ASS) {\n        trace_usb_ehci_usbsts(\"ASS\", state);\n    }\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":65637,"func":"static int coolkey_select_file(sc_card_t *card, const sc_path_t *in_path, sc_file_t **file_out)\n{\n\tint r;\n\tstruct sc_file *file = NULL;\n\tcoolkey_private_data_t * priv = COOLKEY_DATA(card);\n\tunsigned long object_id;\n\n\tassert(card != NULL && in_path != NULL);\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);\n\n\tif (in_path->len != 4) {\n\t\treturn SC_ERROR_OBJECT_NOT_FOUND;\n\t}\n\tr = coolkey_select_applet(card);\n\tif (r != SC_SUCCESS) {\n\t\treturn r;\n\t}\n\tobject_id = bebytes2ulong(in_path->value);\n\tpriv->obj = coolkey_find_object_by_id(&priv->objects_list, object_id);\n\tif (priv->obj == NULL) {\n\t\treturn SC_ERROR_OBJECT_NOT_FOUND;\n\t}\n\n\tpriv->key_id = COOLKEY_INVALID_KEY;\n\tif (coolkey_class(object_id) == COOLKEY_KEY_CLASS) {\n\t\tpriv->key_id = coolkey_get_key_id(object_id);\n\t}\n\tif (file_out) {\n\t\tfile = sc_file_new();\n\t\tif (file == NULL)\n\t\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);\n\t\tfile->path = *in_path;\n\t\t\/* this could be like the FCI *\/\n\t\tfile->type =  SC_PATH_TYPE_FILE_ID;\n\t\tfile->shareable = 0;\n\t\tfile->ef_structure = 0;\n\t\tfile->size = priv->obj->length;\n\t\t*file_out = file;\n\t}\n\n\treturn SC_SUCCESS;\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":329609,"func":"static void verdex_init(ram_addr_t ram_size, int vga_ram_size,\n\n                const char *boot_device,\n\n                const char *kernel_filename, const char *kernel_cmdline,\n\n                const char *initrd_filename, const char *cpu_model)\n\n{\n\n    struct pxa2xx_state_s *cpu;\n\n    int index;\n\n\n\n    uint32_t verdex_rom = 0x02000000;\n\n    uint32_t verdex_ram = 0x10000000;\n\n\n\n    if (ram_size < (verdex_ram + verdex_rom + PXA2XX_INTERNAL_SIZE)) {\n\n        fprintf(stderr, \"This platform requires %i bytes of memory\\n\",\n\n                verdex_ram + verdex_rom + PXA2XX_INTERNAL_SIZE);\n\n        exit(1);\n\n    }\n\n\n\n    cpu = pxa270_init(verdex_ram, cpu_model ?: \"pxa270-c0\");\n\n\n\n    index = drive_get_index(IF_PFLASH, 0, 0);\n\n    if (index == -1) {\n\n        fprintf(stderr, \"A flash image must be given with the \"\n\n                \"'pflash' parameter\\n\");\n\n        exit(1);\n\n    }\n\n\n\n    if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(verdex_rom),\n\n            drives_table[index].bdrv, sector_len, verdex_rom \/ sector_len,\n\n            2, 0, 0, 0, 0)) {\n\n        fprintf(stderr, \"qemu: Error registering flash memory.\\n\");\n\n        exit(1);\n\n    }\n\n\n\n    cpu->env->regs[15] = 0x00000000;\n\n\n\n    \/* Interrupt line of NIC is connected to GPIO line 99 *\/\n\n    smc91c111_init(&nd_table[0], 0x04000300,\n\n                    pxa2xx_gpio_in_get(cpu->gpio)[99]);\n\n}\n","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":179626,"func":"void SoftVorbis::initPorts() {\n    OMX_PARAM_PORTDEFINITIONTYPE def;\n InitOMXParams(&def);\n\n    def.nPortIndex = 0;\n    def.eDir = OMX_DirInput;\n    def.nBufferCountMin = kNumBuffers;\n    def.nBufferCountActual = def.nBufferCountMin;\n    def.nBufferSize = 8192;\n    def.bEnabled = OMX_TRUE;\n    def.bPopulated = OMX_FALSE;\n    def.eDomain = OMX_PortDomainAudio;\n    def.bBuffersContiguous = OMX_FALSE;\n    def.nBufferAlignment = 1;\n\n    def.format.audio.cMIMEType =\n const_cast<char *>(MEDIA_MIMETYPE_AUDIO_VORBIS);\n\n    def.format.audio.pNativeRender = NULL;\n    def.format.audio.bFlagErrorConcealment = OMX_FALSE;\n    def.format.audio.eEncoding = OMX_AUDIO_CodingVORBIS;\n\n    addPort(def);\n\n    def.nPortIndex = 1;\n    def.eDir = OMX_DirOutput;\n    def.nBufferCountMin = kNumBuffers;\n    def.nBufferCountActual = def.nBufferCountMin;\n    def.nBufferSize = kMaxNumSamplesPerBuffer * sizeof(int16_t);\n    def.bEnabled = OMX_TRUE;\n    def.bPopulated = OMX_FALSE;\n    def.eDomain = OMX_PortDomainAudio;\n    def.bBuffersContiguous = OMX_FALSE;\n    def.nBufferAlignment = 2;\n\n    def.format.audio.cMIMEType = const_cast<char *>(\"audio\/raw\");\n    def.format.audio.pNativeRender = NULL;\n    def.format.audio.bFlagErrorConcealment = OMX_FALSE;\n    def.format.audio.eEncoding = OMX_AUDIO_CodingPCM;\n\n    addPort(def);\n}\n","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":399043,"func":"bash_servicename_completion_function (text, state)\n     const char *text;\n     int state;\n{\n#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GETSERVENT)\n  return ((char *)NULL);\n#else\n  static char *sname = (char *)NULL;\n  static struct servent *srvent;\n  static int snamelen, firstc;\n  char *value;\n  char **alist, *aentry;\n  int afound;\n\n  if (state == 0)\n    {\n      FREE (sname);\n      firstc = *text;\n\n      sname = savestring (text);\n      snamelen = strlen (sname);\n      setservent (0);\n    }\n\n  while (srvent = getservent ())\n    {\n      afound = 0;\n      if (snamelen == 0 || (STREQN (sname, srvent->s_name, snamelen)))\n\tbreak;\n      \/* Not primary, check aliases *\/\n      for (alist = srvent->s_aliases; *alist; alist++)\n\t{\n\t  aentry = *alist;\n\t  if (STREQN (sname, aentry, snamelen))\n\t    {\n\t      afound = 1;\n\t      break;\n\t    }\n\t}\n\n      if (afound)\n\tbreak;\n    }\n\n  if (srvent == 0)\n    {\n      endservent ();\n      return ((char *)NULL);\n    }\n\n  value = afound ? savestring (aentry) : savestring (srvent->s_name);\n  return value;\n#endif\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":191458,"func":"dissect_rpcap_filterbpf_insn (tvbuff_t *tvb, packet_info *pinfo _U_,\n                              proto_tree *parent_tree, gint offset)\n{\n  proto_tree *tree, *code_tree;\n  proto_item *ti, *code_ti;\n  guint8 inst_class;\n\n  ti = proto_tree_add_item (parent_tree, hf_filterbpf_insn, tvb, offset, 8, ENC_NA);\n  tree = proto_item_add_subtree (ti, ett_filterbpf_insn);\n\n  code_ti = proto_tree_add_item (tree, hf_code, tvb, offset, 2, ENC_BIG_ENDIAN);\n  code_tree = proto_item_add_subtree (code_ti, ett_filterbpf_insn_code);\n  proto_tree_add_item (code_tree, hf_code_class, tvb, offset, 2, ENC_BIG_ENDIAN);\n  inst_class = tvb_get_guint8 (tvb, offset + 1) & 0x07;\n  proto_item_append_text (ti, \": %s\", val_to_str_const (inst_class, bpf_class, \"\"));\n  switch (inst_class) {\n  case 0x00: \/* ld *\/\n  case 0x01: \/* ldx *\/\n    proto_tree_add_item (code_tree, hf_code_ld_size, tvb, offset, 2, ENC_BIG_ENDIAN);\n    proto_tree_add_item (code_tree, hf_code_ld_mode, tvb, offset, 2, ENC_BIG_ENDIAN);\n    break;\n  case 0x04: \/* alu *\/\n    proto_tree_add_item (code_tree, hf_code_src, tvb, offset, 2, ENC_BIG_ENDIAN);\n    proto_tree_add_item (code_tree, hf_code_alu_op, tvb, offset, 2, ENC_BIG_ENDIAN);\n    break;\n  case 0x05: \/* jmp *\/\n    proto_tree_add_item (code_tree, hf_code_src, tvb, offset, 2, ENC_BIG_ENDIAN);\n    proto_tree_add_item (code_tree, hf_code_jmp_op, tvb, offset, 2, ENC_BIG_ENDIAN);\n    break;\n  case 0x06: \/* ret *\/\n    proto_tree_add_item (code_tree, hf_code_rval, tvb, offset, 2, ENC_BIG_ENDIAN);\n    break;\n  case 0x07: \/* misc *\/\n    proto_tree_add_item (code_tree, hf_code_misc_op, tvb, offset, 2, ENC_BIG_ENDIAN);\n    break;\n  default:\n    proto_tree_add_item (code_tree, hf_code_fields, tvb, offset, 2, ENC_BIG_ENDIAN);\n    break;\n  }\n  offset += 2;\n\n  proto_tree_add_item (tree, hf_jt, tvb, offset, 1, ENC_BIG_ENDIAN);\n  offset += 1;\n\n  proto_tree_add_item (tree, hf_jf, tvb, offset, 1, ENC_BIG_ENDIAN);\n  offset += 1;\n\n  proto_tree_add_item (tree, hf_instr_value, tvb, offset, 4, ENC_BIG_ENDIAN);\n  offset += 4;\n\n  return offset;\n}\n","target":0,"code_token_length":645,"total_token_length":881,"max_tokens_setting":1024}
+{"idx":208836,"func":"void IndexedDBDatabase::SetIndexKeys(\n    IndexedDBTransaction* transaction,\n    int64_t object_store_id,\n    std::unique_ptr<IndexedDBKey> primary_key,\n    const std::vector<IndexedDBIndexKeys>& index_keys) {\n  DCHECK(transaction);\n  IDB_TRACE1(\"IndexedDBDatabase::SetIndexKeys\", \"txn.id\", transaction->id());\n  DCHECK_EQ(transaction->mode(), blink::kWebIDBTransactionModeVersionChange);\n\n  IndexedDBBackingStore::RecordIdentifier record_identifier;\n  bool found = false;\n  Status s = backing_store_->KeyExistsInObjectStore(\n      transaction->BackingStoreTransaction(), metadata_.id, object_store_id,\n      *primary_key, &record_identifier, &found);\n  if (!s.ok()) {\n    ReportErrorWithDetails(s, \"Internal error setting index keys.\");\n    return;\n  }\n  if (!found) {\n    transaction->Abort(IndexedDBDatabaseError(\n        blink::kWebIDBDatabaseExceptionUnknownError,\n        \"Internal error setting index keys for object store.\"));\n    return;\n  }\n\n  std::vector<std::unique_ptr<IndexWriter>> index_writers;\n  base::string16 error_message;\n  bool obeys_constraints = false;\n  DCHECK(metadata_.object_stores.find(object_store_id) !=\n         metadata_.object_stores.end());\n  const IndexedDBObjectStoreMetadata& object_store_metadata =\n      metadata_.object_stores[object_store_id];\n  bool backing_store_success = MakeIndexWriters(transaction,\n                                                backing_store_.get(),\n                                                id(),\n                                                object_store_metadata,\n                                                *primary_key,\n                                                false,\n                                                index_keys,\n                                                &index_writers,\n                                                &error_message,\n                                                &obeys_constraints);\n  if (!backing_store_success) {\n    transaction->Abort(IndexedDBDatabaseError(\n        blink::kWebIDBDatabaseExceptionUnknownError,\n        \"Internal error: backing store error updating index keys.\"));\n    return;\n  }\n  if (!obeys_constraints) {\n    transaction->Abort(IndexedDBDatabaseError(\n        blink::kWebIDBDatabaseExceptionConstraintError, error_message));\n    return;\n  }\n\n  for (const auto& writer : index_writers) {\n    writer->WriteIndexKeys(record_identifier, backing_store_.get(),\n                           transaction->BackingStoreTransaction(), id(),\n                           object_store_id);\n  }\n}\n","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":356402,"func":"static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)\n{\n\tstruct diff_options diff_opts;\n\tstruct diff_queue_struct *q = &diff_queued_diff;\n\tstruct diff_filepair *choice;\n\tconst char *paths[1];\n\tint i;\n\n\t\/* Remove the file creation entry from the diff queue, and remember it *\/\n\tchoice = q->queue[0];\n\tq->nr = 0;\n\n\tdiff_setup(&diff_opts);\n\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n\tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n\tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n\tdiff_opts.single_follow = opt->paths[0];\n\tdiff_opts.break_opt = opt->break_opt;\n\tpaths[0] = NULL;\n\tdiff_tree_setup_paths(paths, &diff_opts);\n\tif (diff_setup_done(&diff_opts) < 0)\n\t\tdie(\"unable to set up diff options to follow renames\");\n\tdiff_tree(t1, t2, base, &diff_opts);\n\tdiffcore_std(&diff_opts);\n\tdiff_tree_release_paths(&diff_opts);\n\n\t\/* Go through the new set of filepairing, and see if we find a more interesting one *\/\n\tfor (i = 0; i < q->nr; i++) {\n\t\tstruct diff_filepair *p = q->queue[i];\n\n\t\t\/*\n\t\t * Found a source? Not only do we use that for the new\n\t\t * diff_queued_diff, we will also use that as the path in\n\t\t * the future!\n\t\t *\/\n\t\tif ((p->status == 'R' || p->status == 'C') && !strcmp(p->two->path, opt->paths[0])) {\n\t\t\t\/* Switch the file-pairs around *\/\n\t\t\tq->queue[i] = choice;\n\t\t\tchoice = p;\n\n\t\t\t\/* Update the path we use from now on.. *\/\n\t\t\tdiff_tree_release_paths(opt);\n\t\t\topt->paths[0] = xstrdup(p->one->path);\n\t\t\tdiff_tree_setup_paths(opt->paths, opt);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/*\n\t * Then, discard all the non-relevane file pairs...\n\t *\/\n\tfor (i = 0; i < q->nr; i++) {\n\t\tstruct diff_filepair *p = q->queue[i];\n\t\tdiff_free_filepair(p);\n\t}\n\n\t\/*\n\t * .. and re-instate the one we want (which might be either the\n\t * original one, or the rename\/copy we found)\n\t *\/\n\tq->queue[0] = choice;\n\tq->nr = 1;\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":58837,"func":"size_t HTTP2Codec::generateTrailers(folly::IOBufQueue& writeBuf,\n                                    StreamID stream,\n                                    const HTTPHeaders& trailers) {\n  VLOG(4) << \"generating TRAILERS for stream=\" << stream;\n  std::vector<compress::Header> allHeaders;\n  CodecUtil::appendHeaders(trailers, allHeaders, HTTP_HEADER_NONE);\n\n  HTTPHeaderSize size;\n  auto out = encodeHeaders(trailers, allHeaders, &size);\n\n  IOBufQueue queue(IOBufQueue::cacheChainLength());\n  queue.append(std::move(out));\n  auto maxFrameSize = maxSendFrameSize();\n  if (queue.chainLength() > 0) {\n    folly::Optional<http2::PriorityUpdate> pri;\n    auto remainingFrameSize = maxFrameSize;\n    auto chunk = queue.split(std::min(remainingFrameSize, queue.chainLength()));\n    bool endHeaders = queue.chainLength() == 0;\n    generateHeaderCallbackWrapper(stream,\n                                  http2::FrameType::HEADERS,\n                                  http2::writeHeaders(writeBuf,\n                                                      std::move(chunk),\n                                                      stream,\n                                                      pri,\n                                                      http2::kNoPadding,\n                                                      true \/*eom*\/,\n                                                      endHeaders));\n\n    if (!endHeaders) {\n      generateContinuation(writeBuf, queue, stream, maxFrameSize);\n    }\n  }\n\n  return size.compressed;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":239990,"func":"pax_dump_header_0 (struct tar_sparse_file *file)\n{\n  off_t block_ordinal = current_block_ordinal ();\n  union block *blk;\n  size_t i;\n  char nbuf[UINTMAX_STRSIZE_BOUND];\n  struct sp_array *map = file->stat_info->sparse_map;\n  char *save_file_name = NULL;\n\n  \/* Store the real file size *\/\n  xheader_store (\"GNU.sparse.size\", file->stat_info, NULL);\n  xheader_store (\"GNU.sparse.numblocks\", file->stat_info, NULL);\n\n  if (xheader_keyword_deleted_p (\"GNU.sparse.map\")\n      || tar_sparse_minor == 0)\n    {\n      for (i = 0; i < file->stat_info->sparse_map_avail; i++)\n\t{\n\t  xheader_store (\"GNU.sparse.offset\", file->stat_info, &i);\n\t  xheader_store (\"GNU.sparse.numbytes\", file->stat_info, &i);\n\t}\n    }\n  else\n    {\n      xheader_store (\"GNU.sparse.name\", file->stat_info, NULL);\n      save_file_name = file->stat_info->file_name;\n      file->stat_info->file_name = xheader_format_name (file->stat_info,\n\t\t\t\t\t       \"%d\/GNUSparseFile.%p\/%f\", 0);\n\n      xheader_string_begin (&file->stat_info->xhdr);\n      for (i = 0; i < file->stat_info->sparse_map_avail; i++)\n\t{\n\t  if (i)\n\t    xheader_string_add (&file->stat_info->xhdr, \",\");\n\t  xheader_string_add (&file->stat_info->xhdr,\n\t\t\t      umaxtostr (map[i].offset, nbuf));\n\t  xheader_string_add (&file->stat_info->xhdr, \",\");\n\t  xheader_string_add (&file->stat_info->xhdr,\n\t\t\t      umaxtostr (map[i].numbytes, nbuf));\n\t}\n      if (!xheader_string_end (&file->stat_info->xhdr,\n\t\t\t       \"GNU.sparse.map\"))\n\t{\n\t  free (file->stat_info->file_name);\n\t  file->stat_info->file_name = save_file_name;\n\t  return false;\n\t}\n    }\n  blk = pax_start_header (file->stat_info);\n  finish_header (file->stat_info, blk, block_ordinal);\n  if (save_file_name)\n    {\n      free (file->stat_info->file_name);\n      file->stat_info->file_name = save_file_name;\n    }\n  return true;\n}\n","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":128870,"func":"TfLiteStatus EvalFloat(const TfLiteTensor* input,\n                       const TfLiteTensor* input_weights,\n                       const TfLiteTensor* recurrent_weights,\n                       const TfLiteTensor* bias,\n                       const TfLiteSequenceRNNParams* params,\n                       TfLiteTensor* hidden_state, TfLiteTensor* output) {\n  \/\/ Initialize the pointer bias.\n  const float* bias_ptr = GetTensorData<float>(bias);\n\n  const bool time_major = params->time_major;\n  const int batch_size =\n      (time_major) ? input->dims->data[1] : input->dims->data[0];\n  const int max_time =\n      (time_major) ? input->dims->data[0] : input->dims->data[1];\n  const int num_units = input_weights->dims->data[0];\n  const int input_size = input->dims->data[2];\n\n  \/\/ Initialize input_weights and recurrent_weights.\n  const float* input_weights_ptr = GetTensorData<float>(input_weights);\n  const float* recurrent_weights_ptr = GetTensorData<float>(recurrent_weights);\n\n  if (time_major) {\n    \/\/ Initialize the pointer to hidden state.\n    float* hidden_state_ptr_batch = GetTensorData<float>(hidden_state);\n    \/\/ Unroll the sequence and use batch operations for efficiency.\n    for (int s = 0; s < max_time; s++) {\n      \/\/ Initialize the pointer to input and output.\n      const float* input_ptr_batch =\n          GetTensorData<float>(input) + s * input_size * batch_size;\n      float* output_ptr_batch =\n          GetTensorData<float>(output) + s * num_units * batch_size;\n\n      kernel_utils::RnnBatchStep(\n          input_ptr_batch, input_weights_ptr, recurrent_weights_ptr, bias_ptr,\n          input_size, num_units, batch_size, num_units, params->activation,\n          hidden_state_ptr_batch, output_ptr_batch);\n    }\n  } else {\n    \/\/ For each batch\n    for (int b = 0; b < batch_size; b++) {\n      \/\/ Initialize the pointer to hidden state.\n      float* hidden_state_ptr_batch =\n          GetTensorData<float>(hidden_state) + b * num_units;\n      for (int s = 0; s < max_time; s++) {\n        \/\/ Initialize the pointer to input and output.\n        const float* input_ptr_batch = GetTensorData<float>(input) +\n                                       b * input_size * max_time +\n                                       s * input_size;\n        float* output_ptr_batch = GetTensorData<float>(output) +\n                                  b * num_units * max_time + s * num_units;\n\n        kernel_utils::RnnBatchStep(\n            input_ptr_batch, input_weights_ptr, recurrent_weights_ptr, bias_ptr,\n            input_size, num_units, \/*batch_size=*\/1, num_units,\n            params->activation, hidden_state_ptr_batch, output_ptr_batch);\n      }\n    }\n  }\n  return kTfLiteOk;\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":475147,"func":"static bool check_iov_bounds(struct vrend_resource *res,\n                             const struct vrend_transfer_info *info,\n                             const struct iovec *iov, int num_iovs)\n{\n   GLuint transfer_size;\n   GLuint iovsize = vrend_get_iovec_size(iov, num_iovs);\n   GLuint valid_stride, valid_layer_stride;\n\n   \/* If the transfer specifies a stride, verify that it's at least as large as\n    * the minimum required for the transfer. If no stride is specified use the\n    * image stride for the specified level.\n    *\/\n   if (info->stride) {\n      GLuint min_stride = util_format_get_stride(res->base.format, info->box->width);\n      if (info->stride < min_stride)\n         return false;\n      valid_stride = info->stride;\n   } else {\n      valid_stride = util_format_get_stride(res->base.format,\n                                            u_minify(res->base.width0, info->level));\n   }\n\n   \/* If the transfer specifies a layer_stride, verify that it's at least as\n    * large as the minimum required for the transfer. If no layer_stride is\n    * specified use the image layer_stride for the specified level.\n    *\/\n   if (info->layer_stride) {\n      GLuint min_layer_stride = util_format_get_2d_size(res->base.format,\n                                                        valid_stride,\n                                                        info->box->height);\n      if (info->layer_stride < min_layer_stride)\n         return false;\n      valid_layer_stride = info->layer_stride;\n   } else {\n      valid_layer_stride =\n         util_format_get_2d_size(res->base.format, valid_stride,\n                                 u_minify(res->base.height0, info->level));\n   }\n\n   \/* Calculate the size required for the transferred data, based on the\n    * calculated or provided strides, and ensure that the iov, starting at the\n    * specified offset, is able to hold at least that size.\n    *\/\n   transfer_size = vrend_transfer_size(res, info,\n                                       valid_stride,\n                                       valid_layer_stride);\n   if (iovsize < info->offset)\n      return false;\n   if (iovsize < transfer_size)\n      return false;\n   if (iovsize < info->offset + transfer_size)\n      return false;\n\n   return true;\n}","target":0,"code_token_length":473,"total_token_length":709,"max_tokens_setting":1024}
+{"idx":508063,"func":"int test_exp(BIO *bp, BN_CTX *ctx)\n{\n    BIGNUM *a, *b, *d, *e, *one;\n    int i;\n\n    a = BN_new();\n    b = BN_new();\n    d = BN_new();\n    e = BN_new();\n    one = BN_new();\n    BN_one(one);\n\n    for (i = 0; i < num2; i++) {\n        BN_bntest_rand(a, 20 + i * 5, 0, 0);\n        BN_bntest_rand(b, 2 + i, 0, 0);\n\n        if (BN_exp(d, a, b, ctx) <= 0)\n            return (0);\n\n        if (bp != NULL) {\n            if (!results) {\n                BN_print(bp, a);\n                BIO_puts(bp, \" ^ \");\n                BN_print(bp, b);\n                BIO_puts(bp, \" - \");\n            }\n            BN_print(bp, d);\n            BIO_puts(bp, \"\\n\");\n        }\n        BN_one(e);\n        for (; !BN_is_zero(b); BN_sub(b, b, one))\n            BN_mul(e, e, a, ctx);\n        BN_sub(e, e, d);\n        if (!BN_is_zero(e)) {\n            fprintf(stderr, \"Exponentiation test failed!\\n\");\n            return 0;\n        }\n    }\n    BN_free(a);\n    BN_free(b);\n    BN_free(d);\n    BN_free(e);\n    BN_free(one);\n    return (1);\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":159156,"func":"static int add_file_info(struct augeas *aug, const char *node,\n                         struct lens *lens, const char *lens_name,\n                         const char *filename, bool force_reload) {\n    struct tree *file, *tree;\n    char *tmp = NULL;\n    int r;\n    char *path = NULL;\n    int result = -1;\n\n    if (lens == NULL)\n        return -1;\n\n    r = pathjoin(&path, 2, AUGEAS_META_TREE, node);\n    ERR_NOMEM(r < 0, aug);\n\n    file = tree_fpath_cr(aug, path);\n    ERR_BAIL(aug);\n\n    \/* Set 'path' *\/\n    tree = tree_child_cr(file, s_path);\n    ERR_NOMEM(tree == NULL, aug);\n    r = tree_set_value(tree, node);\n    ERR_NOMEM(r < 0, aug);\n\n    \/* Set 'mtime' *\/\n    if (force_reload) {\n        tmp = strdup(\"0\");\n        ERR_NOMEM(tmp == NULL, aug);\n    } else {\n        tmp = mtime_as_string(aug, filename);\n        ERR_BAIL(aug);\n    }\n    tree = tree_child_cr(file, s_mtime);\n    ERR_NOMEM(tree == NULL, aug);\n    tree_store_value(tree, &tmp);\n\n    \/* Set 'lens\/info' *\/\n    tmp = format_info(lens->info);\n    ERR_NOMEM(tmp == NULL, aug);\n    tree = tree_path_cr(file, 2, s_lens, s_info);\n    ERR_NOMEM(tree == NULL, aug);\n    r = tree_set_value(tree, tmp);\n    ERR_NOMEM(r < 0, aug);\n    FREE(tmp);\n\n    \/* Set 'lens' *\/\n    tree = tree->parent;\n    r = tree_set_value(tree, lens_name);\n    ERR_NOMEM(r < 0, aug);\n\n    tree_clean(file);\n\n    result = 0;\n error:\n    free(path);\n    free(tmp);\n    return result;\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":23396,"func":"static ssize_t virtio_net_receive ( VLANClientState * nc , const uint8_t * buf , size_t size ) {\n VirtIONet * n = DO_UPCAST ( NICState , nc , nc ) -> opaque ;\n struct virtio_net_hdr_mrg_rxbuf * mhdr = NULL ;\n size_t guest_hdr_len , offset , i , host_hdr_len ;\n if ( ! virtio_net_can_receive ( & n -> nic -> nc ) ) return - 1 ;\n guest_hdr_len = n -> mergeable_rx_bufs ? sizeof ( struct virtio_net_hdr_mrg_rxbuf ) : sizeof ( struct virtio_net_hdr ) ;\n host_hdr_len = n -> has_vnet_hdr ? sizeof ( struct virtio_net_hdr ) : 0 ;\n if ( ! virtio_net_has_buffers ( n , size + guest_hdr_len - host_hdr_len ) ) return 0 ;\n if ( ! receive_filter ( n , buf , size ) ) return size ;\n offset = i = 0 ;\n while ( offset < size ) {\n VirtQueueElement elem ;\n int len , total ;\n struct iovec sg [ VIRTQUEUE_MAX_SIZE ] ;\n total = 0 ;\n if ( virtqueue_pop ( n -> rx_vq , & elem ) == 0 ) {\n if ( i == 0 ) return - 1 ;\n error_report ( \"virtio-net unexpected empty queue: \" \"i %zd mergeable %d offset %zd, size %zd, \" \"guest hdr len %zd, host hdr len %zd guest features 0x%x\" , i , n -> mergeable_rx_bufs , offset , size , guest_hdr_len , host_hdr_len , n -> vdev . guest_features ) ;\n exit ( 1 ) ;\n }\n if ( elem . in_num < 1 ) {\n error_report ( \"virtio-net receive queue contains no in buffers\" ) ;\n exit ( 1 ) ;\n }\n if ( ! n -> mergeable_rx_bufs && elem . in_sg [ 0 ] . iov_len != guest_hdr_len ) {\n error_report ( \"virtio-net header not in first element\" ) ;\n exit ( 1 ) ;\n }\n memcpy ( & sg , & elem . in_sg [ 0 ] , sizeof ( sg [ 0 ] ) * elem . in_num ) ;\n if ( i == 0 ) {\n if ( n -> mergeable_rx_bufs ) mhdr = ( struct virtio_net_hdr_mrg_rxbuf * ) sg [ 0 ] . iov_base ;\n offset += receive_header ( n , sg , elem . in_num , buf + offset , size - offset , guest_hdr_len ) ;\n total += guest_hdr_len ;\n }\n len = iov_from_buf ( sg , elem . in_num , 0 , buf + offset , size - offset ) ;\n total += len ;\n offset += len ;\n if ( ! n -> mergeable_rx_bufs && offset < size ) {\n # if 0 error_report ( \"virtio-net truncated non-mergeable packet: \" \"i %zd mergeable %d offset %zd, size %zd, \" \"guest hdr len %zd, host hdr len %zd\" , i , n -> mergeable_rx_bufs , offset , size , guest_hdr_len , host_hdr_len ) ;\n # endif return size ;\n }\n virtqueue_fill ( n -> rx_vq , & elem , total , i ++ ) ;\n }\n if ( mhdr ) {\n stw_p ( & mhdr -> num_buffers , i ) ;\n }\n virtqueue_flush ( n -> rx_vq , i ) ;\n virtio_notify ( & n -> vdev , n -> rx_vq ) ;\n return size ;\n }","target":0,"code_token_length":750,"total_token_length":986,"max_tokens_setting":1024}
+{"idx":41399,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& data = context->input(0);\n    const Tensor& segment_ids = context->input(1);\n    const Tensor& num_segments = context->input(2);\n    if (!UnsortedSegmentReductionDoValidation(this, context, data, segment_ids,\n                                              num_segments)) {\n      return;\n    }\n    const auto segment_flat = segment_ids.flat<Index>();\n    const int64 output_rows = internal::SubtleMustCopy(static_cast<int64>(\n        num_segments.dtype() == DT_INT32 ? num_segments.scalar<int32>()()\n                                         : num_segments.scalar<int64>()()));\n    OP_REQUIRES(context, output_rows >= 0,\n                errors::InvalidArgument(\"Input num_segments == \", output_rows,\n                                        \" must not be negative.\"));\n    TensorShape output_shape;\n    output_shape.AddDim(output_rows);\n    for (int i = segment_ids.dims(); i < data.dims(); i++) {\n      output_shape.AddDim(data.dim_size(i));\n    }\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));\n    auto output_flat = output->flat_outer_dims<T>();\n    auto data_flat = data.flat_inner_outer_dims<T, 2>(segment_ids.dims() - 1);\n    reduction_functor_(context, segment_ids.shape(), segment_flat, data_flat,\n                       output_flat);\n  }","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":458001,"func":"struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)\n{\n\tstruct tty_struct *tty;\n\n\ttty = kzalloc(sizeof(*tty), GFP_KERNEL);\n\tif (!tty)\n\t\treturn NULL;\n\n\tkref_init(&tty->kref);\n\ttty->magic = TTY_MAGIC;\n\tif (tty_ldisc_init(tty)) {\n\t\tkfree(tty);\n\t\treturn NULL;\n\t}\n\ttty->session = NULL;\n\ttty->pgrp = NULL;\n\tmutex_init(&tty->legacy_mutex);\n\tmutex_init(&tty->throttle_mutex);\n\tinit_rwsem(&tty->termios_rwsem);\n\tmutex_init(&tty->winsize_mutex);\n\tinit_ldsem(&tty->ldisc_sem);\n\tinit_waitqueue_head(&tty->write_wait);\n\tinit_waitqueue_head(&tty->read_wait);\n\tINIT_WORK(&tty->hangup_work, do_tty_hangup);\n\tmutex_init(&tty->atomic_write_lock);\n\tspin_lock_init(&tty->ctrl_lock);\n\tspin_lock_init(&tty->flow_lock);\n\tspin_lock_init(&tty->files_lock);\n\tINIT_LIST_HEAD(&tty->tty_files);\n\tINIT_WORK(&tty->SAK_work, do_SAK_work);\n\n\ttty->driver = driver;\n\ttty->ops = driver->ops;\n\ttty->index = idx;\n\ttty_line_name(driver, idx, tty->name);\n\ttty->dev = tty_get_device(tty);\n\n\treturn tty;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":407546,"func":"ldns_str2rdf_str(ldns_rdf **rd, const char *str)\n{\n\tuint8_t *data, *dp, ch = 0;\n\tsize_t length;\n\n\t\/* Worst case space requirement. We'll realloc to actual size later. *\/\n\tdp = data = LDNS_XMALLOC(uint8_t, strlen(str) > 255 ? 256 : (strlen(str) + 1));\n\tif (! data) {\n\t\treturn LDNS_STATUS_MEM_ERR;\n\t}\n\n\t\/* Fill data (up to 255 characters) *\/\n\twhile (parse_char(&ch, &str)) {\n\t\tif (dp - data >= 255) {\n\t\t\tLDNS_FREE(data);\n\t\t\treturn LDNS_STATUS_INVALID_STR;\n\t\t}\n\t\t*++dp = ch;\n\t}\n\tif (! str) {\n\t\treturn LDNS_STATUS_SYNTAX_BAD_ESCAPE;\n\t}\n\tlength = (size_t)(dp - data);\n\t\/* Fix last length byte *\/\n\tdata[0] = (uint8_t)length;\n\n\t\/* Lose the overmeasure *\/\n\tdata = LDNS_XREALLOC(dp = data, uint8_t, length + 1);\n\tif (! data) {\n\t\tLDNS_FREE(dp);\n\t\treturn LDNS_STATUS_MEM_ERR;\n\t}\n\n\t\/* Create rdf *\/\n\t*rd = ldns_rdf_new(LDNS_RDF_TYPE_STR, length + 1, data);\n\tif (! *rd) {\n\t\tLDNS_FREE(data);\n\t\treturn LDNS_STATUS_MEM_ERR;\n\t}\n\treturn LDNS_STATUS_OK;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":224728,"func":"parse_inline_image(fz_context *ctx, pdf_csi *csi, fz_stream *stm)\n{\n\tpdf_document *doc = csi->doc;\n\tpdf_obj *rdb = csi->rdb;\n\tpdf_obj *obj = NULL;\n\tfz_image *img = NULL;\n\tint ch, found;\n\n\tfz_var(obj);\n\tfz_var(img);\n\n\tfz_try(ctx)\n\t{\n\t\tobj = pdf_parse_dict(ctx, doc, stm, &doc->lexbuf.base);\n\n\t\t\/* read whitespace after ID keyword *\/\n\t\tch = fz_read_byte(ctx, stm);\n\t\tif (ch == '\\r')\n\t\t\tif (fz_peek_byte(ctx, stm) == '\\n')\n\t\t\t\tfz_read_byte(ctx, stm);\n\n\t\timg = pdf_load_inline_image(ctx, doc, rdb, obj, stm);\n\n\t\t\/* find EI *\/\n\t\tfound = 0;\n\t\tch = fz_read_byte(ctx, stm);\n\t\tdo\n\t\t{\n\t\t\twhile (ch != 'E' && ch != EOF)\n\t\t\t\tch = fz_read_byte(ctx, stm);\n\t\t\tif (ch == 'E')\n\t\t\t{\n\t\t\t\tch = fz_read_byte(ctx, stm);\n\t\t\t\tif (ch == 'I')\n\t\t\t\t{\n\t\t\t\t\tch = fz_peek_byte(ctx, stm);\n\t\t\t\t\tif (ch == ' ' || ch <= 32 || ch == EOF || ch == '<' || ch == '\/')\n\t\t\t\t\t{\n\t\t\t\t\t\tfound = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} while (ch != EOF);\n\t\tif (!found)\n\t\t\tfz_throw(ctx, FZ_ERROR_SYNTAX, \"syntax error after inline image\");\n\t}\n\tfz_always(ctx)\n\t{\n\t\tpdf_drop_obj(ctx, obj);\n\t}\n\tfz_catch(ctx)\n\t{\n\t\tfz_drop_image(ctx, img);\n\t\tfz_rethrow(ctx);\n\t}\n\n\treturn img;\n}\n","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":401930,"func":"ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) \/* {{{ *\/\n{\n\tint op1_val, op2_val;\n\n\tdo {\n\t\tif (Z_TYPE_P(op1) == IS_FALSE) {\n\t\t\top1_val = 0;\n\t\t} else if (EXPECTED(Z_TYPE_P(op1) == IS_TRUE)) {\n\t\t\top1_val = 1;\n\t\t} else {\n\t\t\tif (Z_ISREF_P(op1)) {\n\t\t\t\top1 = Z_REFVAL_P(op1);\n\t\t\t\tif (Z_TYPE_P(op1) == IS_FALSE) {\n\t\t\t\t\top1_val = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (EXPECTED(Z_TYPE_P(op1) == IS_TRUE)) {\n\t\t\t\t\top1_val = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BOOL_XOR, boolean_xor_function);\n\t\t\top1_val = zval_is_true(op1);\n\t\t}\n\t} while (0);\n\tdo {\n\t\tif (Z_TYPE_P(op2) == IS_FALSE) {\n\t\t\top2_val = 0;\n\t\t} else if (EXPECTED(Z_TYPE_P(op2) == IS_TRUE)) {\n\t\t\top2_val = 1;\n\t\t} else {\n\t\t\tif (Z_ISREF_P(op2)) {\n\t\t\t\top2 = Z_REFVAL_P(op2);\n\t\t\t\tif (Z_TYPE_P(op2) == IS_FALSE) {\n\t\t\t\t\top2_val = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (EXPECTED(Z_TYPE_P(op2) == IS_TRUE)) {\n\t\t\t\t\top2_val = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BOOL_XOR);\n\t\t\top2_val = zval_is_true(op2);\n\t\t}\n\t} while (0);\n\n\tZVAL_BOOL(result, op1_val ^ op2_val);\n\treturn SUCCESS;\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":366080,"func":"_gnutls_cert_get_issuer_dn (gnutls_pcert_st * cert, gnutls_datum_t * odn)\n{\n  ASN1_TYPE dn;\n  int len, result;\n  int start, end;\n\n  if ((result = asn1_create_element\n       (_gnutls_get_pkix (), \"PKIX1.Certificate\", &dn)) != ASN1_SUCCESS)\n    {\n      gnutls_assert ();\n      return _gnutls_asn2err (result);\n    }\n\n  result = asn1_der_decoding (&dn, cert->cert.data, cert->cert.size, NULL);\n  if (result != ASN1_SUCCESS)\n    {\n      \/* couldn't decode DER *\/\n      gnutls_assert ();\n      asn1_delete_structure (&dn);\n      return _gnutls_asn2err (result);\n    }\n\n  result = asn1_der_decoding_startEnd (dn, cert->cert.data, cert->cert.size,\n                                       \"tbsCertificate.issuer\", &start, &end);\n\n  if (result != ASN1_SUCCESS)\n    {\n      \/* couldn't decode DER *\/\n      gnutls_assert ();\n      asn1_delete_structure (&dn);\n      return _gnutls_asn2err (result);\n    }\n  asn1_delete_structure (&dn);\n\n  len = end - start + 1;\n\n  odn->size = len;\n  odn->data = &cert->cert.data[start];\n\n  return 0;\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":360403,"func":"should_skip_file (NautilusDirectory *directory, GFileInfo *info)\n{\n\tstatic gboolean show_hidden_files_changed_callback_installed = FALSE;\n\tstatic gboolean show_backup_files_changed_callback_installed = FALSE;\n\n\t\/* Add the callback once for the life of our process *\/\n\tif (!show_hidden_files_changed_callback_installed) {\n\t\teel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,\n\t\t\t\t\t      show_hidden_files_changed_callback,\n\t\t\t\t\t      NULL);\n\t\tshow_hidden_files_changed_callback_installed = TRUE;\n\t\t\n\t\t\/* Peek for the first time *\/\n\t\tshow_hidden_files_changed_callback (NULL);\n\t}\n\n\t\/* Add the callback once for the life of our process *\/\n\tif (!show_backup_files_changed_callback_installed) {\n\t\teel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,\n\t\t\t\t\t      show_backup_files_changed_callback,\n\t\t\t\t\t      NULL);\n\t\tshow_backup_files_changed_callback_installed = TRUE;\n\t\t\n\t\t\/* Peek for the first time *\/\n\t\tshow_backup_files_changed_callback (NULL);\n\t}\n\n\tif (!show_hidden_files &&\n\t    (g_file_info_get_is_hidden (info) ||\n\t     (directory != NULL && directory->details->hidden_file_hash != NULL &&\n\t      g_hash_table_lookup (directory->details->hidden_file_hash,\n\t\t\t\t   g_file_info_get_name (info)) != NULL))) {\n\t\treturn TRUE;\n\t}\n\t\n\tif (!show_backup_files && g_file_info_get_is_backup (info)) {\n\t\treturn TRUE;\n\t}\n\n\treturn FALSE;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":74645,"func":"R_API int extract_type_value(const char *arg_str, char **output) {\n\tut8 found_one = 0, array_cnt = 0;\n\tut32 len = 0, consumed = 0;\n\tchar *str = NULL;\n\tif (!arg_str || !output) {\n\t\treturn 0;\n\t}\n\tif (output && *output && *output != NULL) {\n\t\tR_FREE (*output);\n\t}\n\twhile (arg_str && *arg_str && !found_one) {\n\t\tlen = 1;\n\t\t\/\/ handle the end of an object\n\t\tswitch (*arg_str) {\n\t\tcase 'V':\n\t\t\tstr = get_type_value_str (\"void\", array_cnt);\n\t\t\tbreak;\n\t\tcase 'J':\n\t\t\tstr = get_type_value_str (\"long\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'I':\n\t\t\tstr = get_type_value_str (\"int\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'D':\n\t\t\tstr = get_type_value_str (\"double\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'F':\n\t\t\tstr = get_type_value_str (\"float\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'B':\n\t\t\tstr = get_type_value_str (\"byte\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'C':\n\t\t\tstr = get_type_value_str (\"char\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'Z':\n\t\t\tstr = get_type_value_str (\"boolean\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase 'S':\n\t\t\tstr = get_type_value_str (\"short\", array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase '[':\n\t\t\tarray_cnt++;\n\t\t\tbreak;\n\t\tcase 'L':\n\t\t\tlen = r_bin_java_extract_reference_name (arg_str, &str, array_cnt);\n\t\t\tarray_cnt = 0;\n\t\t\tbreak;\n\t\tcase '(':\n\t\t\tstr = strdup (\"(\");\n\t\t\tbreak;\n\t\tcase ')':\n\t\t\tstr = strdup (\")\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn 0;\n\t\t}\n\t\tif (len < 1) {\n\t\t\tbreak;\n\t\t}\n\t\tconsumed += len;\n\t\targ_str += len;\n\t\tif (str) {\n\t\t\t*output = str;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn consumed;\n}","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":284768,"func":"bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {\n  if (!renderer_initialized())\n    return false;\n\n  if (owner_delegate_ && owner_delegate_->OnMessageReceived(msg))\n    return true;\n\n  bool handled = true;\n  IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostImpl, msg)\n    IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone)\n    IPC_MESSAGE_HANDLER(FrameHostMsg_HittestData, OnHittestData)\n    IPC_MESSAGE_HANDLER(InputHostMsg_QueueSyntheticGesture,\n                        OnQueueSyntheticGesture)\n    IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,\n                        OnImeCancelComposition)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK,\n                        OnUpdateScreenRectsAck)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText)\n    IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame,\n                                OnSwapCompositorFrame(msg))\n    IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged,\n                        OnTextInputStateChanged)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup,\n                        OnShowDisambiguationPopup)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged,\n                        OnSelectionBoundsChanged)\n#if defined(OS_WIN)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated,\n                        OnWindowlessPluginDummyWindowCreated)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed,\n                        OnWindowlessPluginDummyWindowDestroyed)\n#endif\n    IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,\n                        OnImeCompositionRangeChanged)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstPaintAfterLoad,\n                        OnFirstPaintAfterLoad)\n    IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardCompositorProto,\n                        OnForwardCompositorProto)\n    IPC_MESSAGE_UNHANDLED(handled = false)\n  IPC_END_MESSAGE_MAP()\n\n  if (!handled && input_router_ && input_router_->OnMessageReceived(msg))\n    return true;\n\n  if (!handled && view_ && view_->OnMessageReceived(msg))\n    return true;\n\n  return handled;\n}\n","target":0,"code_token_length":529,"total_token_length":765,"max_tokens_setting":1024}
+{"idx":506114,"func":"BIGNUM *bn_expand2(BIGNUM *b, int words)\n\t{\n\tbn_check_top(b);\n\n\tif (words > b->dmax)\n\t\t{\n\t\tBN_ULONG *a = bn_expand_internal(b, words);\n\t\tif(!a) return NULL;\n\t\tif(b->d) OPENSSL_free(b->d);\n\t\tb->d=a;\n\t\tb->dmax=words;\n\t\t}\n\n\/* None of this should be necessary because of what b->top means! *\/\n#if 0\n\t\/* NB: bn_wexpand() calls this only if the BIGNUM really has to grow *\/\n\tif (b->top < b->dmax)\n\t\t{\n\t\tint i;\n\t\tBN_ULONG *A = &(b->d[b->top]);\n\t\tfor (i=(b->dmax - b->top)>>3; i>0; i--,A+=8)\n\t\t\t{\n\t\t\tA[0]=0; A[1]=0; A[2]=0; A[3]=0;\n\t\t\tA[4]=0; A[5]=0; A[6]=0; A[7]=0;\n\t\t\t}\n\t\tfor (i=(b->dmax - b->top)&7; i>0; i--,A++)\n\t\t\tA[0]=0;\n\t\tassert(A == &(b->d[b->dmax]));\n\t\t}\n#endif\n\tbn_check_top(b);\n\treturn b;\n\t}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":129318,"func":"cherokee_validator_ldap_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)\n{\n\tret_t                            ret;\n\tcherokee_list_t                 *i;\n\tcherokee_validator_ldap_props_t *props;\n\n\tUNUSED(srv);\n\n\tif (*_props == NULL) {\n\t\tCHEROKEE_NEW_STRUCT (n, validator_ldap_props);\n\n\t\tcherokee_validator_props_init_base (VALIDATOR_PROPS(n), MODULE_PROPS_FREE(props_free));\n\n\t\tn->port = LDAP_DEFAULT_PORT;\n\t\tn->tls  = false;\n\n\t\tcherokee_buffer_init (&n->server);\n\t\tcherokee_buffer_init (&n->binddn);\n\t\tcherokee_buffer_init (&n->bindpw);\n\t\tcherokee_buffer_init (&n->basedn);\n\t\tcherokee_buffer_init (&n->filter);\n\t\tcherokee_buffer_init (&n->ca_file);\n\n\t\t*_props = MODULE_PROPS(n);\n\t}\n\n\tprops = PROP_LDAP(*_props);\n\n\tcherokee_config_node_foreach (i, conf) {\n\t\tcherokee_config_node_t *subconf = CONFIG_NODE(i);\n\n\t\tif (equal_buf_str (&subconf->key, \"server\")) {\n\t\t\tcherokee_buffer_add_buffer (&props->server, &subconf->val);\n\n\t\t} else if (equal_buf_str (&subconf->key, \"port\")) {\n\t\t\tret = cherokee_atoi (subconf->val.buf, &props->port);\n\t\t\tif (ret != ret_ok) return ret_error;\n\n\t\t} else if (equal_buf_str (&subconf->key, \"bind_dn\")) {\n\t\t\tcherokee_buffer_add_buffer (&props->binddn, &subconf->val);\n\n\t\t} else if (equal_buf_str (&subconf->key, \"bind_pw\")) {\n\t\t\tcherokee_buffer_add_buffer (&props->bindpw, &subconf->val);\n\n\t\t} else if (equal_buf_str (&subconf->key, \"base_dn\")) {\n\t\t\tcherokee_buffer_add_buffer (&props->basedn, &subconf->val);\n\n\t\t} else if (equal_buf_str (&subconf->key, \"filter\")) {\n\t\t\tcherokee_buffer_add_buffer (&props->filter, &subconf->val);\n\n\t\t} else if (equal_buf_str (&subconf->key, \"tls\")) {\n\t\t\tret = cherokee_atob (subconf->val.buf, &props->tls);\n\t\t\tif (ret != ret_ok) return ret_error;\n\n\t\t} else if (equal_buf_str (&subconf->key, \"ca_file\")) {\n\t\t\tcherokee_buffer_add_buffer (&props->ca_file, &subconf->val);\n\n\t\t} else if (equal_buf_str (&subconf->key, \"methods\") ||\n\t\t           equal_buf_str (&subconf->key, \"realm\")   ||\n\t\t           equal_buf_str (&subconf->key, \"users\")) {\n\t\t\t\/* Handled in validator.c\n\t\t\t *\/\n\t\t} else {\n\t\t\tLOG_WARNING (CHEROKEE_ERROR_VALIDATOR_LDAP_KEY, subconf->key.buf);\n\t\t}\n\t}\n\n\t\/* Checks\n\t *\/\n\tif (cherokee_buffer_is_empty (&props->basedn)) {\n\t\tLOG_ERROR (CHEROKEE_ERROR_VALIDATOR_LDAP_PROPERTY, \"base_dn\");\n\t\treturn ret_error;\n\t}\n\n\tif (cherokee_buffer_is_empty (&props->server)) {\n\t\tLOG_ERROR (CHEROKEE_ERROR_VALIDATOR_LDAP_PROPERTY, \"server\");\n\t\treturn ret_error;\n\t}\n\n\tif ((cherokee_buffer_is_empty (&props->bindpw) &&\n\t     (! cherokee_buffer_is_empty (&props->basedn))))\n\t{\n\t\tLOG_ERROR_S (CHEROKEE_ERROR_VALIDATOR_LDAP_SECURITY);\n\t\treturn ret_error;\n\t}\n\n\treturn ret_ok;\n}","target":0,"code_token_length":787,"total_token_length":1023,"max_tokens_setting":1024}
+{"idx":273849,"func":"static void icall_aulevel_handler(struct icall *icall, struct list *levell, void *arg)\n{\n\tstruct wcall *wcall = arg;\n\tstruct calling_instance *inst = wcall ? wcall->inst : NULL;\n\tchar *json_str = NULL;\n\tchar *info_str = NULL;\n\tuint64_t now;\n\tint err = 0;\n\n\tif (!WCALL_VALID(wcall)) {\n\t\twarning(\"wcall(%p): icall_aulevel_handler wcall not valid\\n\",\n\t\t\twcall);\n\t\treturn;\n\t}\n\n\tinfo(\"icall_aulevel_handler(%p): %d levels\\n\", wcall, list_count(levell));\n\t\n\tif (!inst->active_speakerh)\n\t\treturn;\n\t\n\terr = audio_level_json(levell,\n\t\t\t       inst->userid, inst->clientid,\n\t\t\t       &json_str, &info_str);\n\tif (err) {\n\t\twarning(\"icall_aulevel_handler(%p): could not create json\\n\", wcall);\n\t\treturn;\n\t}\n\t\t\n\tinfo(APITAG \"wcall(%p): calling active_speakerh:%p with: %s\\n\",\n\t     wcall, inst->clients_reqh, info_str);\n\tnow = tmr_jiffies();\n\t\n\tinst->active_speakerh(inst2wuser(inst), wcall->convid, json_str, inst->arg);\n\t\n\tinfo(APITAG \"wcall(%p): active_speakerh took %llu ms\\n\",\n\t     wcall, tmr_jiffies() - now);\n\n\tmem_deref(json_str);\n\tmem_deref(info_str);\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":250378,"func":" static int _make_words(char *l,long n,ogg_uint32_t *r,long quantvals,\n                       codebook *b, oggpack_buffer *opb,int maptype){\n   long i,j,count=0;\n   long top=0;\n   ogg_uint32_t marker[MARKER_SIZE];\n\n if (n<1)\n return 1;\n\n if(n<2){\n    r[0]=0x80000000;\n }else{\n    memset(marker,0,sizeof(marker));\n\n for(i=0;i<n;i++){\n long length=l[i];\n if(length){\n if (length < 0 || length >= MARKER_SIZE) {\n\n           ALOGE(\"b\/23881715\");\n           return 1;\n         }\n        ogg_uint32_t entry=marker[length];\n        long chase=0;\n        if(count && !entry)return -1; \/* overpopulated tree! *\/\n \n        \/* chase the tree as far as it's already populated, fill in past *\/\n        for(j=0;j<length-1;j++){\n          int bit=(entry>>(length-j-1))&1;\n          if(chase>=top){\n            if (chase < 0 || chase >= n) return 1;\n            top++;\n            r[chase*2]=top;\n            r[chase*2+1]=0;\n          }else\n            if (chase < 0 || chase >= n || chase*2+bit > n*2+1) return 1;\n            if(!r[chase*2+bit])\n              r[chase*2+bit]=top;\n          chase=r[chase*2+bit];\n          if (chase < 0 || chase >= n) return 1;\n        }\n        {\n          int bit=(entry>>(length-j-1))&1;\n          if(chase>=top){\n            top++;\n            r[chase*2+1]=0;\n          }\n          r[chase*2+bit]= decpack(i,count++,quantvals,b,opb,maptype) |\n            0x80000000;\n        }\n \n        \/* Look to see if the next shorter marker points to the node\n           above. if so, update it and repeat.  *\/\n        for(j=length;j>0;j--){\n          if(marker[j]&1){\n            marker[j]=marker[j-1]<<1;\n            break;\n          }\n          marker[j]++;\n        }\n \n        \/* prune the tree; the implicit invariant says all the longer\n           markers were dangling from our just-taken node.  Dangle them\n           from our *new* node. *\/\n        for(j=length+1;j<MARKER_SIZE;j++)\n          if((marker[j]>>1) == entry){\n            entry=marker[j];\n            marker[j]=marker[j-1]<<1;\n          }else\n            break;\n       }\n     }\n   }\n\n \/* sanity check the huffman tree; an underpopulated tree must be\n     rejected. The only exception is the one-node pseudo-nil tree,\n     which appears to be underpopulated because the tree doesn't\n     really exist; there's only one possible 'codeword' or zero bits,\n     but the above tree-gen code doesn't mark that. *\/\n if(b->used_entries != 1){\n for(i=1;i<MARKER_SIZE;i++)\n if(marker[i] & (0xffffffffUL>>(32-i))){\n return 1;\n }\n }\n\n\n return 0;\n\n }\n","target":0,"code_token_length":730,"total_token_length":966,"max_tokens_setting":1024}
+{"idx":469600,"func":"mat_copy(const char* src, const char* dst)\n{\n    size_t len;\n    char buf[BUFSIZ] = {'\\0'};\n    FILE* in = NULL;\n    FILE* out = NULL;\n\n#if defined(_WIN32) && defined(_MSC_VER)\n    {\n        wchar_t* wname = utf82u(src);\n        if ( NULL != wname ) {\n            in = _wfopen(wname, L\"rb\");\n            free(wname);\n        }\n    }\n#else\n    in = fopen(src, \"rb\");\n#endif\n    if ( in == NULL ) {\n        Mat_Critical(\"Cannot open file \\\"%s\\\" for reading.\", src);\n        return -1;\n    }\n\n#if defined(_WIN32) && defined(_MSC_VER)\n    {\n        wchar_t* wname = utf82u(dst);\n        if ( NULL != wname ) {\n            out = _wfopen(wname, L\"wb\");\n            free(wname);\n        }\n    }\n#else\n    out = fopen(dst, \"wb\");\n#endif\n    if ( out == NULL ) {\n        fclose(in);\n        Mat_Critical(\"Cannot open file \\\"%s\\\" for writing.\", dst);\n        return -1;\n    }\n\n    while ( (len = fread(buf, sizeof(char), BUFSIZ, in)) > 0 ) {\n        if ( len != fwrite(buf, sizeof(char), len, out) ) {\n            fclose(in);\n            fclose(out);\n            Mat_Critical(\"Error writing to file \\\"%s\\\".\", dst);\n            return -1;\n        }\n    }\n    fclose(in);\n    fclose(out);\n    return 0;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":11407,"func":"Packet *PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent,\n                             uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto,\n                             PacketQueue *pq)\n{\n    int ret;\n\n    SCEnter();\n\n    \/* get us a packet *\/\n    Packet *p = PacketGetFromQueueOrAlloc();\n    if (unlikely(p == NULL)) {\n        SCReturnPtr(NULL, \"Packet\");\n    }\n\n    \/* copy packet and set lenght, proto *\/\n    PacketCopyData(p, pkt, len);\n    p->recursion_level = parent->recursion_level + 1;\n    p->ts.tv_sec = parent->ts.tv_sec;\n    p->ts.tv_usec = parent->ts.tv_usec;\n    p->datalink = DLT_RAW;\n    p->tenant_id = parent->tenant_id;\n\n    \/* set the root ptr to the lowest layer *\/\n    if (parent->root != NULL)\n        p->root = parent->root;\n    else\n        p->root = parent;\n\n    \/* tell new packet it's part of a tunnel *\/\n    SET_TUNNEL_PKT(p);\n\n     ret = DecodeTunnel(tv, dtv, p, GET_PKT_DATA(p),\n                        GET_PKT_LEN(p), pq, proto);\n \n    if (unlikely(ret != TM_ECODE_OK)) {\n        \/* Not a tunnel packet, just a pseudo packet *\/\n         p->root = NULL;\n         UNSET_TUNNEL_PKT(p);\n         TmqhOutputPacketpool(tv, p);\n        SCReturnPtr(NULL, \"Packet\");\n    }\n\n\n    \/* tell parent packet it's part of a tunnel *\/\n    SET_TUNNEL_PKT(parent);\n\n    \/* increment tunnel packet refcnt in the root packet *\/\n    TUNNEL_INCR_PKT_TPR(p);\n\n    \/* disable payload (not packet) inspection on the parent, as the payload\n     * is the packet we will now run through the system separately. We do\n     * check it against the ip\/port\/other header checks though *\/\n    DecodeSetNoPayloadInspectionFlag(parent);\n    SCReturnPtr(p, \"Packet\");\n}\n","target":1,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":75916,"func":"static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,\n\t\t\t\t    struct tcp_fastopen_cookie *cookie)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *data = tp->syn_data ? tcp_write_queue_head(sk) : NULL;\n\tu16 mss = tp->rx_opt.mss_clamp, try_exp = 0;\n\tbool syn_drop = false;\n\n\tif (mss == tp->rx_opt.user_mss) {\n\t\tstruct tcp_options_received opt;\n\n\t\t\/* Get original SYNACK MSS value if user MSS sets mss_clamp *\/\n\t\ttcp_clear_options(&opt);\n\t\topt.user_mss = opt.mss_clamp = 0;\n\t\ttcp_parse_options(synack, &opt, 0, NULL);\n\t\tmss = opt.mss_clamp;\n\t}\n\n\tif (!tp->syn_fastopen) {\n\t\t\/* Ignore an unsolicited cookie *\/\n\t\tcookie->len = -1;\n\t} else if (tp->total_retrans) {\n\t\t\/* SYN timed out and the SYN-ACK neither has a cookie nor\n\t\t * acknowledges data. Presumably the remote received only\n\t\t * the retransmitted (regular) SYNs: either the original\n\t\t * SYN-data or the corresponding SYN-ACK was dropped.\n\t\t *\/\n\t\tsyn_drop = (cookie->len < 0 && data);\n\t} else if (cookie->len < 0 && !tp->syn_data) {\n\t\t\/* We requested a cookie but didn't get it. If we did not use\n\t\t * the (old) exp opt format then try so next time (try_exp=1).\n\t\t * Otherwise we go back to use the RFC7413 opt (try_exp=2).\n\t\t *\/\n\t\ttry_exp = tp->syn_fastopen_exp ? 2 : 1;\n\t}\n\n\ttcp_fastopen_cache_set(sk, mss, cookie, syn_drop, try_exp);\n\n\tif (data) { \/* Retransmit unacked data in SYN *\/\n\t\ttcp_for_write_queue_from(data, sk) {\n\t\t\tif (data == tcp_send_head(sk) ||\n\t\t\t    __tcp_retransmit_skb(sk, data, 1))\n\t\t\t\tbreak;\n\t\t}\n\t\ttcp_rearm_rto(sk);\n\t\tNET_INC_STATS(sock_net(sk),\n\t\t\t\tLINUX_MIB_TCPFASTOPENACTIVEFAIL);\n\t\treturn true;\n\t}\n\ttp->syn_data_acked = tp->syn_data;\n\tif (tp->syn_data_acked)\n\t\tNET_INC_STATS(sock_net(sk),\n\t\t\t\tLINUX_MIB_TCPFASTOPENACTIVE);\n\n\ttcp_fastopen_add_skb(sk, synack);\n\n\treturn false;\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":372260,"func":"void jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)\r\n{\r\n  jpeg_saved_marker_ptr marker;\r\n\r\n  \/* In the current implementation, we don't actually need to examine the\r\n   * option flag here; we just copy everything that got saved.\r\n   * But to avoid confusion, we do not output JFIF and Adobe APP14 markers\r\n   * if the encoder library already wrote one.\r\n   *\/\r\n  for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {\r\n\r\n    if (dstinfo->write_JFIF_header &&\r\n        marker->marker == JPEG_APP0 &&\r\n        marker->data_length >= 5 &&\r\n        GETJOCTET(marker->data[0]) == 0x4A &&\r\n        GETJOCTET(marker->data[1]) == 0x46 &&\r\n        GETJOCTET(marker->data[2]) == 0x49 &&\r\n        GETJOCTET(marker->data[3]) == 0x46 &&\r\n        GETJOCTET(marker->data[4]) == 0)\r\n                          continue;         \/* reject duplicate JFIF *\/\r\n\r\n    if (dstinfo->write_Adobe_marker &&\r\n        marker->marker == JPEG_APP0+14 &&\r\n        marker->data_length >= 5 &&\r\n        GETJOCTET(marker->data[0]) == 0x41 &&\r\n        GETJOCTET(marker->data[1]) == 0x64 &&\r\n        GETJOCTET(marker->data[2]) == 0x6F &&\r\n        GETJOCTET(marker->data[3]) == 0x62 &&\r\n        GETJOCTET(marker->data[4]) == 0x65)\r\n                         continue;         \/* reject duplicate Adobe *\/\r\n\r\n     jpeg_write_marker(dstinfo, marker->marker,\r\n                       marker->data, marker->data_length);\r\n  }\r\n}\r","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":337829,"func":"static int parse_dsd_diin(AVFormatContext *s, AVStream *st, uint64_t eof)\n\n{\n\n    AVIOContext *pb = s->pb;\n\n\n\n    while (avio_tell(pb) + 12 <= eof) {\n\n        uint32_t tag      = avio_rl32(pb);\n\n        uint64_t size     = avio_rb64(pb);\n\n        uint64_t orig_pos = avio_tell(pb);\n\n        const char * metadata_tag = NULL;\n\n\n\n        switch(tag) {\n\n        case MKTAG('D','I','A','R'): metadata_tag = \"artist\"; break;\n\n        case MKTAG('D','I','T','I'): metadata_tag = \"title\";  break;\n\n        }\n\n\n\n        if (metadata_tag && size > 4) {\n\n            unsigned int tag_size = avio_rb32(pb);\n\n            int ret = get_metadata(s, metadata_tag, FFMIN(tag_size, size - 4));\n\n            if (ret < 0) {\n\n                av_log(s, AV_LOG_ERROR, \"cannot allocate metadata tag %s!\\n\", metadata_tag);\n\n                return ret;\n\n            }\n\n        }\n\n\n\n        avio_skip(pb, size - (avio_tell(pb) - orig_pos) + (size & 1));\n\n    }\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":420679,"func":"static int h2c_handle_settings(struct h2c *h2c)\n{\n\tunsigned int offset;\n\tint error;\n\n\tif (h2c->dff & H2_F_SETTINGS_ACK) {\n\t\tif (h2c->dfl) {\n\t\t\terror = H2_ERR_FRAME_SIZE_ERROR;\n\t\t\tgoto fail;\n\t\t}\n\t\treturn 1;\n\t}\n\n\tif (h2c->dsi != 0) {\n\t\terror = H2_ERR_PROTOCOL_ERROR;\n\t\tgoto fail;\n\t}\n\n\tif (h2c->dfl % 6) {\n\t\terror = H2_ERR_FRAME_SIZE_ERROR;\n\t\tgoto fail;\n\t}\n\n\t\/* that's the limit we can process *\/\n\tif (h2c->dfl > global.tune.bufsize) {\n\t\terror = H2_ERR_FRAME_SIZE_ERROR;\n\t\tgoto fail;\n\t}\n\n\t\/* process full frame only *\/\n\tif (b_data(&h2c->dbuf) < h2c->dfl)\n\t\treturn 0;\n\n\t\/* parse the frame *\/\n\tfor (offset = 0; offset < h2c->dfl; offset += 6) {\n\t\tuint16_t type = h2_get_n16(&h2c->dbuf, offset);\n\t\tint32_t  arg  = h2_get_n32(&h2c->dbuf, offset + 2);\n\n\t\tswitch (type) {\n\t\tcase H2_SETTINGS_INITIAL_WINDOW_SIZE:\n\t\t\t\/* we need to update all existing streams with the\n\t\t\t * difference from the previous iws.\n\t\t\t *\/\n\t\t\tif (arg < 0) { \/\/ RFC7540#6.5.2\n\t\t\t\terror = H2_ERR_FLOW_CONTROL_ERROR;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\th2c_update_all_ws(h2c, arg - h2c->miw);\n\t\t\th2c->miw = arg;\n\t\t\tbreak;\n\t\tcase H2_SETTINGS_MAX_FRAME_SIZE:\n\t\t\tif (arg < 16384 || arg > 16777215) { \/\/ RFC7540#6.5.2\n\t\t\t\terror = H2_ERR_PROTOCOL_ERROR;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\th2c->mfs = arg;\n\t\t\tbreak;\n\t\tcase H2_SETTINGS_ENABLE_PUSH:\n\t\t\tif (arg < 0 || arg > 1) { \/\/ RFC7540#6.5.2\n\t\t\t\terror = H2_ERR_PROTOCOL_ERROR;\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* need to ACK this frame now *\/\n\th2c->st0 = H2_CS_FRAME_A;\n\treturn 1;\n fail:\n\tsess_log(h2c->conn->owner);\n\th2c_error(h2c, error);\n\treturn 0;\n}","target":0,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":124054,"func":"static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm, void __user *argp)\n{\n\tstruct kvm_msr_filter __user *user_msr_filter = argp;\n\tstruct kvm_x86_msr_filter *new_filter, *old_filter;\n\tstruct kvm_msr_filter filter;\n\tbool default_allow;\n\tbool empty = true;\n\tint r = 0;\n\tu32 i;\n\n\tif (copy_from_user(&filter, user_msr_filter, sizeof(filter)))\n\t\treturn -EFAULT;\n\n\tfor (i = 0; i < ARRAY_SIZE(filter.ranges); i++)\n\t\tempty &= !filter.ranges[i].nmsrs;\n\n\tdefault_allow = !(filter.flags & KVM_MSR_FILTER_DEFAULT_DENY);\n\tif (empty && !default_allow)\n\t\treturn -EINVAL;\n\n\tnew_filter = kvm_alloc_msr_filter(default_allow);\n\tif (!new_filter)\n\t\treturn -ENOMEM;\n\n\tfor (i = 0; i < ARRAY_SIZE(filter.ranges); i++) {\n\t\tr = kvm_add_msr_filter(new_filter, &filter.ranges[i]);\n\t\tif (r) {\n\t\t\tkvm_free_msr_filter(new_filter);\n\t\t\treturn r;\n\t\t}\n\t}\n\n\tmutex_lock(&kvm->lock);\n\n\t\/* The per-VM filter is protected by kvm->lock... *\/\n\told_filter = srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1);\n\n\trcu_assign_pointer(kvm->arch.msr_filter, new_filter);\n\tsynchronize_srcu(&kvm->srcu);\n\n\tkvm_free_msr_filter(old_filter);\n\n\tkvm_make_all_cpus_request(kvm, KVM_REQ_MSR_FILTER_CHANGED);\n\tmutex_unlock(&kvm->lock);\n\n\treturn 0;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":496837,"func":"TEST_P(Security, BuiltinAuthenticationAndCryptoPlugin_besteffort_submessage_large_string)\n{\n    PubSubReader<StringType> reader(TEST_TOPIC_NAME);\n    PubSubWriter<StringType> writer(TEST_TOPIC_NAME);\n\n    PropertyPolicy pub_part_property_policy, sub_part_property_policy,\n            pub_property_policy, sub_property_policy;\n\n    sub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.plugin\",\n            \"builtin.PKI-DH\"));\n    sub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.builtin.PKI-DH.identity_ca\",\n            \"file:\/\/\" + std::string(certs_path) + \"\/maincacert.pem\"));\n    sub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.builtin.PKI-DH.identity_certificate\",\n            \"file:\/\/\" + std::string(certs_path) + \"\/mainsubcert.pem\"));\n    sub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.builtin.PKI-DH.private_key\",\n            \"file:\/\/\" + std::string(certs_path) + \"\/mainsubkey.pem\"));\n    sub_part_property_policy.properties().emplace_back(Property(\"dds.sec.crypto.plugin\",\n            \"builtin.AES-GCM-GMAC\"));\n    sub_property_policy.properties().emplace_back(\"rtps.endpoint.submessage_protection_kind\", \"ENCRYPT\");\n\n    reader.history_depth(10).\n            property_policy(sub_part_property_policy).\n            entity_property_policy(sub_property_policy).init();\n\n    ASSERT_TRUE(reader.isInitialized());\n\n    pub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.plugin\",\n            \"builtin.PKI-DH\"));\n    pub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.builtin.PKI-DH.identity_ca\",\n            \"file:\/\/\" + std::string(certs_path) + \"\/maincacert.pem\"));\n    pub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.builtin.PKI-DH.identity_certificate\",\n            \"file:\/\/\" + std::string(certs_path) + \"\/mainpubcert.pem\"));\n    pub_part_property_policy.properties().emplace_back(Property(\"dds.sec.auth.builtin.PKI-DH.private_key\",\n            \"file:\/\/\" + std::string(certs_path) + \"\/mainpubkey.pem\"));\n    pub_part_property_policy.properties().emplace_back(Property(\"dds.sec.crypto.plugin\",\n            \"builtin.AES-GCM-GMAC\"));\n    pub_property_policy.properties().emplace_back(\"rtps.endpoint.submessage_protection_kind\", \"ENCRYPT\");\n\n    writer.history_depth(10).\n            reliability(eprosima::fastrtps::BEST_EFFORT_RELIABILITY_QOS).\n            property_policy(pub_part_property_policy).\n            entity_property_policy(pub_property_policy).init();\n\n    ASSERT_TRUE(writer.isInitialized());\n\n    \/\/ Wait for authorization\n    reader.waitAuthorized();\n    writer.waitAuthorized();\n\n    \/\/ Wait for discovery.\n    writer.wait_discovery();\n    reader.wait_discovery();\n\n    auto data = default_large_string_data_generator();\n\n    reader.startReception(data);\n\n    \/\/ Send data\n    writer.send(data);\n    \/\/ In this test all data should be sent.\n    ASSERT_TRUE(data.empty());\n    \/\/ Block reader until reception finished or timeout.\n    reader.block_for_at_least(2);\n}","target":0,"code_token_length":648,"total_token_length":884,"max_tokens_setting":1024}
+{"idx":389362,"func":"PHP_FUNCTION(xmlrpc_encode_request)\n{\n\tXMLRPC_REQUEST xRequest = NULL;\n\tchar *outBuf;\n\tzval *vals, *out_opts = NULL;\n\tchar *method = NULL;\n\tsize_t method_len;\n\tphp_output_options out;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"s!z|a\", &method, &method_len, &vals, &out_opts) == FAILURE) {\n\t\treturn;\n\t}\n\n\tset_output_options(&out, out_opts ? out_opts : 0);\n\n\tif (USED_RET()) {\n\t\txRequest = XMLRPC_RequestNew();\n\n\t\tif (xRequest) {\n\t\t\tXMLRPC_RequestSetOutputOptions(xRequest, &out.xmlrpc_out);\n\t\t\tif (method == NULL) {\n\t\t\t\tXMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response);\n\t\t\t} else {\n\t\t\t\tXMLRPC_RequestSetMethodName(xRequest, method);\n\t\t\t\tXMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call);\n\t\t\t}\n\t\t\tif (Z_TYPE_P(vals) != IS_NULL) {\n\t\t\t\tXMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(vals));\n\t\t\t}\n\n\t\t\toutBuf = XMLRPC_REQUEST_ToXML(xRequest, 0);\n\t\t\tif (outBuf) {\n\t\t\t\tRETVAL_STRING(outBuf);\n\t\t\t\tfree(outBuf);\n\t\t\t}\n\t\t\tXMLRPC_RequestFree(xRequest, 1);\n\t\t}\n\t}\n\n\tif (strcmp(out.xmlrpc_out.xml_elem_opts.encoding, ENCODING_DEFAULT) != 0) {\n\t\tefree((char *)out.xmlrpc_out.xml_elem_opts.encoding);\n\t}\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":415723,"func":"int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args)\n{\n\tstruct printf_spec spec = {0};\n\tchar *str, *end;\n\n\tstr = (char *)bin_buf;\n\tend = (char *)(bin_buf + size);\n\n#define save_arg(type)\t\t\t\t\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\t\\\n\tif (sizeof(type) == 8) {\t\t\t\t\t\\\n\t\tunsigned long long value;\t\t\t\t\\\n\t\tstr = PTR_ALIGN(str, sizeof(u32));\t\t\t\\\n\t\tvalue = va_arg(args, unsigned long long);\t\t\\\n\t\tif (str + sizeof(type) <= end) {\t\t\t\\\n\t\t\t*(u32 *)str = *(u32 *)&value;\t\t\t\\\n\t\t\t*(u32 *)(str + 4) = *((u32 *)&value + 1);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} else {\t\t\t\t\t\t\t\\\n\t\tunsigned long value;\t\t\t\t\t\\\n\t\tstr = PTR_ALIGN(str, sizeof(type));\t\t\t\\\n\t\tvalue = va_arg(args, int);\t\t\t\t\\\n\t\tif (str + sizeof(type) <= end)\t\t\t\t\\\n\t\t\t*(typeof(type) *)str = (type)value;\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\tstr += sizeof(type);\t\t\t\t\t\t\\\n} while (0)\n\n\twhile (*fmt) {\n\t\tint read = format_decode(fmt, &spec);\n\n\t\tfmt += read;\n\n\t\tswitch (spec.type) {\n\t\tcase FORMAT_TYPE_NONE:\n\t\tcase FORMAT_TYPE_PERCENT_CHAR:\n\t\t\tbreak;\n\t\tcase FORMAT_TYPE_INVALID:\n\t\t\tgoto out;\n\n\t\tcase FORMAT_TYPE_WIDTH:\n\t\tcase FORMAT_TYPE_PRECISION:\n\t\t\tsave_arg(int);\n\t\t\tbreak;\n\n\t\tcase FORMAT_TYPE_CHAR:\n\t\t\tsave_arg(char);\n\t\t\tbreak;\n\n\t\tcase FORMAT_TYPE_STR: {\n\t\t\tconst char *save_str = va_arg(args, char *);\n\t\t\tsize_t len;\n\n\t\t\tif ((unsigned long)save_str > (unsigned long)-PAGE_SIZE\n\t\t\t\t\t|| (unsigned long)save_str < PAGE_SIZE)\n\t\t\t\tsave_str = \"(null)\";\n\t\t\tlen = strlen(save_str) + 1;\n\t\t\tif (str + len < end)\n\t\t\t\tmemcpy(str, save_str, len);\n\t\t\tstr += len;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase FORMAT_TYPE_PTR:\n\t\t\tsave_arg(void *);\n\t\t\t\/* skip all alphanumeric pointer suffixes *\/\n\t\t\twhile (isalnum(*fmt))\n\t\t\t\tfmt++;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tswitch (spec.type) {\n\n\t\t\tcase FORMAT_TYPE_LONG_LONG:\n\t\t\t\tsave_arg(long long);\n\t\t\t\tbreak;\n\t\t\tcase FORMAT_TYPE_ULONG:\n\t\t\tcase FORMAT_TYPE_LONG:\n\t\t\t\tsave_arg(unsigned long);\n\t\t\t\tbreak;\n\t\t\tcase FORMAT_TYPE_SIZE_T:\n\t\t\t\tsave_arg(size_t);\n\t\t\t\tbreak;\n\t\t\tcase FORMAT_TYPE_PTRDIFF:\n\t\t\t\tsave_arg(ptrdiff_t);\n\t\t\t\tbreak;\n\t\t\tcase FORMAT_TYPE_UBYTE:\n\t\t\tcase FORMAT_TYPE_BYTE:\n\t\t\t\tsave_arg(char);\n\t\t\t\tbreak;\n\t\t\tcase FORMAT_TYPE_USHORT:\n\t\t\tcase FORMAT_TYPE_SHORT:\n\t\t\t\tsave_arg(short);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tsave_arg(int);\n\t\t\t}\n\t\t}\n\t}\n\nout:\n\treturn (u32 *)(PTR_ALIGN(str, sizeof(u32))) - bin_buf;\n#undef save_arg\n}","target":0,"code_token_length":666,"total_token_length":902,"max_tokens_setting":1024}
+{"idx":322202,"func":"static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)\n\n{\n\n    AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);\n\n    AVFilterContext *ctx = inlink->dst;\n\n    OverlayContext *over = ctx->priv;\n\n    av_unused AVFilterLink *outlink = ctx->outputs[0];\n\n\n\n    inlink->dst->outputs[0]->out_buf = outpicref;\n\n    outpicref->pts = av_rescale_q(outpicref->pts, ctx->inputs[MAIN]->time_base,\n\n                                  ctx->outputs[0]->time_base);\n\n\n\n    if (!over->overpicref || over->overpicref->pts < outpicref->pts) {\n\n        if (!over->overpicref_next)\n\n            avfilter_request_frame(ctx->inputs[OVERLAY]);\n\n\n\n        if (over->overpicref && over->overpicref_next &&\n\n            over->overpicref_next->pts <= outpicref->pts) {\n\n            avfilter_unref_buffer(over->overpicref);\n\n            over->overpicref = over->overpicref_next;\n\n            over->overpicref_next = NULL;\n\n        }\n\n    }\n\n\n\n    av_dlog(ctx, \"main_pts:%s main_pts_time:%s\",\n\n            av_ts2str(outpicref->pts), av_ts2timestr(outpicref->pts, &outlink->time_base));\n\n    if (over->overpicref)\n\n        av_dlog(ctx, \" over_pts:%s over_pts_time:%s\",\n\n                av_ts2str(over->overpicref->pts), av_ts2timestr(over->overpicref->pts, &outlink->time_base));\n\n    av_dlog(ctx, \"\\n\");\n\n\n\n    avfilter_start_frame(inlink->dst->outputs[0], outpicref);\n\n}\n","target":1,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":238720,"func":"void CSoundFile::ExtraFinePortamentoDown(ModChannel *pChn, ModCommand::PARAM param) const\n{\n\tif(GetType() == MOD_TYPE_XM)\n\t{\n\t\tif(param) pChn->nOldExtraFinePortaUpDown = (pChn->nOldExtraFinePortaUpDown & 0xF0) | (param & 0x0F); else param = (pChn->nOldExtraFinePortaUpDown & 0x0F);\n\t} else if(GetType() == MOD_TYPE_MT2)\n\t{\n\t\tif(param) pChn->nOldFinePortaUpDown = param; else param = pChn->nOldFinePortaUpDown;\n\t}\n\n\tif(pChn->isFirstTick)\n\t{\n\t\tif ((pChn->nPeriod) && (param))\n\t\t{\n\t\t\tif(m_SongFlags[SONG_LINEARSLIDES] && GetType() != MOD_TYPE_XM)\n\t\t\t{\n\t\t\t\tint oldPeriod = pChn->nPeriod;\n\t\t\t\tpChn->nPeriod = Util::muldivr(pChn->nPeriod, GetFineLinearSlideDownTable(this, param & 0x0F), 65536);\n\t\t\t\tif(oldPeriod == pChn->nPeriod) pChn->nPeriod--;\n\t\t\t} else\n\t\t\t{\n\t\t\t\tpChn->nPeriod += (int)(param);\n\t\t\t\tif (pChn->nPeriod > 0xFFFF) pChn->nPeriod = 0xFFFF;\n\t\t\t}\n\t\t}\n\t}\n}\n","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":376337,"func":"int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,\n\t\t  const struct in6_addr *gwaddr)\n{\n\tstruct net *net = dev_net(dev);\n\tstruct route_info *rinfo = (struct route_info *) opt;\n\tstruct in6_addr prefix_buf, *prefix;\n\tunsigned int pref;\n\tunsigned long lifetime;\n\tstruct rt6_info *rt;\n\n\tif (len < sizeof(struct route_info)) {\n\t\treturn -EINVAL;\n\t}\n\n\t\/* Sanity check for prefix_len and length *\/\n\tif (rinfo->length > 3) {\n\t\treturn -EINVAL;\n\t} else if (rinfo->prefix_len > 128) {\n\t\treturn -EINVAL;\n\t} else if (rinfo->prefix_len > 64) {\n\t\tif (rinfo->length < 2) {\n\t\t\treturn -EINVAL;\n\t\t}\n\t} else if (rinfo->prefix_len > 0) {\n\t\tif (rinfo->length < 1) {\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\tpref = rinfo->route_pref;\n\tif (pref == ICMPV6_ROUTER_PREF_INVALID)\n\t\treturn -EINVAL;\n\n\tlifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ);\n\n\tif (rinfo->length == 3)\n\t\tprefix = (struct in6_addr *)rinfo->prefix;\n\telse {\n\t\t\/* this function is safe *\/\n\t\tipv6_addr_prefix(&prefix_buf,\n\t\t\t\t (struct in6_addr *)rinfo->prefix,\n\t\t\t\t rinfo->prefix_len);\n\t\tprefix = &prefix_buf;\n\t}\n\n\tif (rinfo->prefix_len == 0)\n\t\trt = rt6_get_dflt_router(gwaddr, dev);\n\telse\n\t\trt = rt6_get_route_info(net, prefix, rinfo->prefix_len,\n\t\t\t\t\tgwaddr, dev->ifindex);\n\n\tif (rt && !lifetime) {\n\t\tip6_del_rt(rt);\n\t\trt = NULL;\n\t}\n\n\tif (!rt && lifetime)\n\t\trt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr, dev->ifindex,\n\t\t\t\t\tpref);\n\telse if (rt)\n\t\trt->rt6i_flags = RTF_ROUTEINFO |\n\t\t\t\t (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);\n\n\tif (rt) {\n\t\tif (!addrconf_finite_timeout(lifetime))\n\t\t\trt6_clean_expires(rt);\n\t\telse\n\t\t\trt6_set_expires(rt, jiffies + HZ * lifetime);\n\n\t\tip6_rt_put(rt);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":326762,"func":"static int decode_ext_header(Wmv2Context *w){\n\n    MpegEncContext * const s= &w->s;\n\n    GetBitContext gb;\n\n    int fps;\n\n    int code;\n\n\n\n    if(s->avctx->extradata_size<4) return -1;\n\n\n\n    init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);\n\n\n\n    fps                = get_bits(&gb, 5);\n\n    s->bit_rate        = get_bits(&gb, 11)*1024;\n\n    w->mspel_bit       = get_bits1(&gb);\n\n    w->flag3           = get_bits1(&gb);\n\n    w->abt_flag        = get_bits1(&gb);\n\n    w->j_type_bit      = get_bits1(&gb);\n\n    w->top_left_mv_flag= get_bits1(&gb);\n\n    w->per_mb_rl_bit   = get_bits1(&gb);\n\n    code               = get_bits(&gb, 3);\n\n\n\n    if(code==0) return -1;\n\n\n\n    s->slice_height = s->mb_height \/ code;\n\n\n\n    if(s->avctx->debug&FF_DEBUG_PICT_INFO){\n\n        av_log(s->avctx, AV_LOG_DEBUG, \"fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, flag3:%d, slices:%d\\n\",\n\n        fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, w->flag3,\n\n        code);\n\n    }\n\n    return 0;\n\n}\n","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":334117,"func":"static void test_visitor_in_native_list_number(TestInputVisitorData *data,\n\n                                               const void *unused)\n\n{\n\n    UserDefNativeListUnion *cvalue = NULL;\n\n    numberList *elem = NULL;\n\n    Error *err = NULL;\n\n    Visitor *v;\n\n    GString *gstr_list = g_string_new(\"\");\n\n    GString *gstr_union = g_string_new(\"\");\n\n    int i;\n\n\n\n    for (i = 0; i < 32; i++) {\n\n        g_string_append_printf(gstr_list, \"%f\", (double)i \/ 3);\n\n        if (i != 31) {\n\n            g_string_append(gstr_list, \", \");\n\n        }\n\n    }\n\n    g_string_append_printf(gstr_union,  \"{ 'type': 'number', 'data': [ %s ] }\",\n\n                           gstr_list->str);\n\n    v = visitor_input_test_init_raw(data,  gstr_union->str);\n\n\n\n    visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err);\n\n    g_assert(err == NULL);\n\n    g_assert(cvalue != NULL);\n\n    g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER);\n\n\n\n    for (i = 0, elem = cvalue->u.number; elem; elem = elem->next, i++) {\n\n        GString *double_expected = g_string_new(\"\");\n\n        GString *double_actual = g_string_new(\"\");\n\n\n\n        g_string_printf(double_expected, \"%.6f\", (double)i \/ 3);\n\n        g_string_printf(double_actual, \"%.6f\", elem->value);\n\n        g_assert_cmpstr(double_expected->str, ==, double_actual->str);\n\n\n\n        g_string_free(double_expected, true);\n\n        g_string_free(double_actual, true);\n\n    }\n\n\n\n    g_string_free(gstr_union, true);\n\n    g_string_free(gstr_list, true);\n\n    qapi_free_UserDefNativeListUnion(cvalue);\n\n}\n","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":67308,"func":"static void xen_netbk_tx_submit(struct xen_netbk *netbk)\n{\n\tstruct gnttab_copy *gop = netbk->tx_copy_ops;\n\tstruct sk_buff *skb;\n\n\twhile ((skb = __skb_dequeue(&netbk->tx_queue)) != NULL) {\n\t\tstruct xen_netif_tx_request *txp;\n\t\tstruct xenvif *vif;\n\t\tu16 pending_idx;\n\t\tunsigned data_len;\n\n\t\tpending_idx = *((u16 *)skb->data);\n\t\tvif = netbk->pending_tx_info[pending_idx].vif;\n\t\ttxp = &netbk->pending_tx_info[pending_idx].req;\n\n\t\t\/* Check the remap error code. *\/\n\t\tif (unlikely(xen_netbk_tx_check_gop(netbk, skb, &gop))) {\n\t\t\tnetdev_dbg(vif->dev, \"netback grant failed.\\n\");\n\t\t\tskb_shinfo(skb)->nr_frags = 0;\n\t\t\tkfree_skb(skb);\n\t\t\tcontinue;\n\t\t}\n\n\t\tdata_len = skb->len;\n\t\tmemcpy(skb->data,\n\t\t       (void *)(idx_to_kaddr(netbk, pending_idx)|txp->offset),\n\t\t       data_len);\n\t\tif (data_len < txp->size) {\n\t\t\t\/* Append the packet payload as a fragment. *\/\n\t\t\ttxp->offset += data_len;\n\t\t\ttxp->size -= data_len;\n\t\t} else {\n\t\t\t\/* Schedule a response immediately. *\/\n\t\t\txen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);\n\t\t}\n\n\t\tif (txp->flags & XEN_NETTXF_csum_blank)\n\t\t\tskb->ip_summed = CHECKSUM_PARTIAL;\n\t\telse if (txp->flags & XEN_NETTXF_data_validated)\n\t\t\tskb->ip_summed = CHECKSUM_UNNECESSARY;\n\n\t\txen_netbk_fill_frags(netbk, skb);\n\n\t\t\/*\n\t\t * If the initial fragment was < PKT_PROT_LEN then\n\t\t * pull through some bytes from the other fragments to\n\t\t * increase the linear region to PKT_PROT_LEN bytes.\n\t\t *\/\n\t\tif (skb_headlen(skb) < PKT_PROT_LEN && skb_is_nonlinear(skb)) {\n\t\t\tint target = min_t(int, skb->len, PKT_PROT_LEN);\n\t\t\t__pskb_pull_tail(skb, target - skb_headlen(skb));\n\t\t}\n\n\t\tskb->dev      = vif->dev;\n\t\tskb->protocol = eth_type_trans(skb, skb->dev);\n\n\t\tif (checksum_setup(vif, skb)) {\n\t\t\tnetdev_dbg(vif->dev,\n\t\t\t\t   \"Can't setup checksum in net_tx_action\\n\");\n\t\t\tkfree_skb(skb);\n\t\t\tcontinue;\n\t\t}\n\n\t\tvif->dev->stats.rx_bytes += skb->len;\n\t\tvif->dev->stats.rx_packets++;\n\n\t\txenvif_receive_skb(vif, skb);\n\t}\n}","target":0,"code_token_length":618,"total_token_length":854,"max_tokens_setting":1024}
+{"idx":8864,"func":"trustedGenDkgSecretAES(int *errStatus, char *errString, uint8_t *encrypted_dkg_secret, uint32_t *enc_len, size_t _t) {\n    LOG_INFO(__FUNCTION__);\n    INIT_ERROR_STATE\n\n    CHECK_STATE(encrypted_dkg_secret);\n\n    SAFE_CHAR_BUF(dkg_secret, DKG_BUFER_LENGTH);\n\n    int status = gen_dkg_poly(dkg_secret, _t);\n\n    CHECK_STATUS(\"gen_dkg_poly failed\")\n\n    status = AES_encrypt(dkg_secret, encrypted_dkg_secret, 3 * BUF_LEN);\n\n    CHECK_STATUS(\"SGX AES encrypt DKG poly failed\");\n\n    *enc_len = strlen(dkg_secret) + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE;\n\n    SAFE_CHAR_BUF(decr_dkg_secret, DKG_BUFER_LENGTH);\n\n    status = AES_decrypt(encrypted_dkg_secret, *enc_len, decr_dkg_secret,\n                         DKG_BUFER_LENGTH);\n\n    CHECK_STATUS(\"aes decrypt dkg poly failed\");\n\n    if (strcmp(dkg_secret, decr_dkg_secret) != 0) {\n        snprintf(errString, BUF_LEN,\n                 \"encrypted poly is not equal to decrypted poly\");\n        LOG_ERROR(errString);\n        *errStatus = -333;\n        goto clean;\n    }\n\n    SET_SUCCESS\n    clean:\n    ;\n    LOG_INFO(__FUNCTION__ );\n    LOG_INFO(\"SGX call completed\");\n}","target":1,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":57416,"func":"void Hub::connect(std::string uri, void *user, int timeoutMs, Group<CLIENT> *eh) {\n    if (!eh) {\n        eh = (Group<CLIENT> *) this;\n    }\n\n    int offset = 0;\n    std::string protocol = uri.substr(offset, uri.find(\":\/\/\")), hostname, portStr, path;\n    if ((offset += protocol.length() + 3) < uri.length()) {\n        hostname = uri.substr(offset, uri.find_first_of(\":\/\", offset) - offset);\n\n        offset += hostname.length();\n        if (uri[offset] == ':') {\n            offset++;\n            portStr = uri.substr(offset, uri.find(\"\/\", offset) - offset);\n        }\n\n        offset += portStr.length();\n        if (uri[offset] == '\/') {\n            path = uri.substr(++offset);\n        }\n    }\n\n    if (hostname.length()) {\n        int port = 80;\n        bool secure = false;\n        if (protocol == \"wss\") {\n            port = 443;\n            secure = true;\n        } else if (protocol != \"ws\") {\n            eh->errorHandler(user);\n        }\n\n        if (portStr.length()) {\n            port = stoi(portStr);\n        }\n\n        uS::SocketData socketData((uS::NodeData *) eh);\n        HTTPSocket<CLIENT>::Data *httpSocketData = new HTTPSocket<CLIENT>::Data(&socketData);\n\n        httpSocketData->host = hostname;\n        httpSocketData->path = path;\n        httpSocketData->httpUser = user;\n\n        uS::Socket s = uS::Node::connect<onClientConnection>(hostname.c_str(), port, secure, httpSocketData);\n        if (s) {\n            s.startTimeout<HTTPSocket<CLIENT>::onEnd>(timeoutMs);\n        }\n    } else {\n        eh->errorHandler(user);\n    }\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":432758,"func":"http1_splitline(struct http *hp, struct http_conn *htc, const int *hf,\n    unsigned maxhdr)\n{\n\tchar *p, *q;\n\tint i;\n\n\tassert(hf == HTTP1_Req || hf == HTTP1_Resp);\n\tCHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);\n\tCHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);\n\tassert(htc->rxbuf_e >= htc->rxbuf_b);\n\n\tAZ(hp->hd[hf[0]].b);\n\tAZ(hp->hd[hf[1]].b);\n\tAZ(hp->hd[hf[2]].b);\n\n\t\/* Skip leading LWS *\/\n\tfor (p = htc->rxbuf_b ; vct_islws(*p); p++)\n\t\tcontinue;\n\thp->hd[hf[0]].b = p;\n\n\t\/* First field cannot contain SP or CTL *\/\n\tfor (; !vct_issp(*p); p++) {\n\t\tif (vct_isctl(*p))\n\t\t\treturn (400);\n\t}\n\thp->hd[hf[0]].e = p;\n\tassert(Tlen(hp->hd[hf[0]]));\n\t*p++ = '\\0';\n\n\t\/* Skip SP *\/\n\tfor (; vct_issp(*p); p++) {\n\t\tif (vct_isctl(*p))\n\t\t\treturn (400);\n\t}\n\thp->hd[hf[1]].b = p;\n\n\t\/* Second field cannot contain LWS or CTL *\/\n\tfor (; !vct_islws(*p); p++) {\n\t\tif (vct_isctl(*p))\n\t\t\treturn (400);\n\t}\n\thp->hd[hf[1]].e = p;\n\tif (!Tlen(hp->hd[hf[1]]))\n\t\treturn (400);\n\n\t\/* Skip SP *\/\n\tq = p;\n\tfor (; vct_issp(*p); p++) {\n\t\tif (vct_isctl(*p))\n\t\t\treturn (400);\n\t}\n\tif (q < p)\n\t\t*q = '\\0';\t\/* Nul guard for the 2nd field. If q == p\n\t\t\t\t * (the third optional field is not\n\t\t\t\t * present), the last nul guard will\n\t\t\t\t * cover this field. *\/\n\n\t\/* Third field is optional and cannot contain CTL except TAB *\/\n\tq = p;\n\tfor (; p < htc->rxbuf_e && !vct_iscrlf(p, htc->rxbuf_e); p++) {\n\t\tif (vct_isctl(*p) && !vct_issp(*p))\n\t\t\treturn (400);\n\t}\n\tif (p > q) {\n\t\thp->hd[hf[2]].b = q;\n\t\thp->hd[hf[2]].e = p;\n\t}\n\n\t\/* Skip CRLF *\/\n\ti = vct_iscrlf(p, htc->rxbuf_e);\n\tif (!i)\n\t\treturn (400);\n\t*p = '\\0';\n\tp += i;\n\n\thttp_Proto(hp);\n\n\treturn (http1_dissect_hdrs(hp, p, htc, maxhdr));\n}","target":0,"code_token_length":658,"total_token_length":894,"max_tokens_setting":1024}
+{"idx":219029,"func":"void Document::InitSecurityContext(const DocumentInit& initializer) {\n  DCHECK(!GetSecurityOrigin());\n\n  if (!initializer.HasSecurityContext()) {\n    cookie_url_ = KURL(g_empty_string);\n    SetSecurityOrigin(SecurityOrigin::CreateUniqueOpaque());\n    InitContentSecurityPolicy();\n    ApplyFeaturePolicy({});\n    return;\n  }\n\n  SandboxFlags sandbox_flags = initializer.GetSandboxFlags();\n  if (fetcher_->Archive()) {\n    sandbox_flags |=\n        kSandboxAll &\n        ~(kSandboxPopups | kSandboxPropagatesToAuxiliaryBrowsingContexts);\n  }\n  EnforceSandboxFlags(sandbox_flags);\n  SetInsecureRequestPolicy(initializer.GetInsecureRequestPolicy());\n  if (initializer.InsecureNavigationsToUpgrade()) {\n    for (auto to_upgrade : *initializer.InsecureNavigationsToUpgrade())\n      AddInsecureNavigationUpgrade(to_upgrade);\n  }\n\n  ContentSecurityPolicy* policy_to_inherit = nullptr;\n\n  if (IsSandboxed(kSandboxOrigin)) {\n    cookie_url_ = url_;\n    scoped_refptr<SecurityOrigin> security_origin =\n        SecurityOrigin::CreateUniqueOpaque();\n    Document* owner = initializer.OwnerDocument();\n    if (owner) {\n      if (owner->GetSecurityOrigin()->IsPotentiallyTrustworthy())\n        security_origin->SetOpaqueOriginIsPotentiallyTrustworthy(true);\n      if (owner->GetSecurityOrigin()->CanLoadLocalResources())\n        security_origin->GrantLoadLocalResources();\n      policy_to_inherit = owner->GetContentSecurityPolicy();\n    }\n    SetSecurityOrigin(std::move(security_origin));\n  } else if (Document* owner = initializer.OwnerDocument()) {\n    cookie_url_ = owner->CookieURL();\n    SetSecurityOrigin(owner->GetMutableSecurityOrigin());\n    policy_to_inherit = owner->GetContentSecurityPolicy();\n  } else {\n    cookie_url_ = url_;\n    SetSecurityOrigin(SecurityOrigin::Create(url_));\n  }\n\n  if (initializer.IsHostedInReservedIPRange()) {\n    SetAddressSpace(GetSecurityOrigin()->IsLocalhost()\n                        ? mojom::IPAddressSpace::kLocal\n                        : mojom::IPAddressSpace::kPrivate);\n  } else if (GetSecurityOrigin()->IsLocal()) {\n    SetAddressSpace(mojom::IPAddressSpace::kLocal);\n  } else {\n    SetAddressSpace(mojom::IPAddressSpace::kPublic);\n  }\n\n  if (ImportsController()) {\n    SetContentSecurityPolicy(\n        ImportsController()->Master()->GetContentSecurityPolicy());\n  } else {\n    InitContentSecurityPolicy(nullptr, policy_to_inherit);\n  }\n\n  if (Settings* settings = initializer.GetSettings()) {\n    if (!settings->GetWebSecurityEnabled()) {\n      GetMutableSecurityOrigin()->GrantUniversalAccess();\n    } else if (GetSecurityOrigin()->IsLocal()) {\n      if (settings->GetAllowUniversalAccessFromFileURLs()) {\n        GetMutableSecurityOrigin()->GrantUniversalAccess();\n      } else if (!settings->GetAllowFileAccessFromFileURLs()) {\n        GetMutableSecurityOrigin()->BlockLocalAccessFromLocalOrigin();\n      }\n    }\n  }\n\n  if (GetSecurityOrigin()->IsOpaque() &&\n      SecurityOrigin::Create(url_)->IsPotentiallyTrustworthy())\n    GetMutableSecurityOrigin()->SetOpaqueOriginIsPotentiallyTrustworthy(true);\n\n  ApplyFeaturePolicy({});\n\n  InitSecureContextState();\n}\n","target":0,"code_token_length":697,"total_token_length":933,"max_tokens_setting":1024}
+{"idx":407462,"func":"void irc_servers_init(void)\n{\n\tsettings_add_choice(\"servers\", \"rejoin_channels_on_reconnect\", 1, \"off;on;auto\");\n\tsettings_add_str(\"misc\", \"usermode\", DEFAULT_USER_MODE);\n\tsettings_add_str(\"misc\", \"split_line_start\", \"\");\n\tsettings_add_str(\"misc\", \"split_line_end\", \"\");\n\tsettings_add_bool(\"misc\", \"split_line_on_space\", TRUE);\n\tsettings_add_time(\"flood\", \"cmd_queue_speed\", DEFAULT_CMD_QUEUE_SPEED);\n\tsettings_add_int(\"flood\", \"cmds_max_at_once\", DEFAULT_CMDS_MAX_AT_ONCE);\n\n\tcmd_tag = -1;\n\n\tsignal_add_first(\"server connected\", (SIGNAL_FUNC) sig_connected);\n\tsignal_add_last(\"server disconnected\", (SIGNAL_FUNC) sig_disconnected);\n\tsignal_add_last(\"server quit\", (SIGNAL_FUNC) sig_server_quit);\n\tsignal_add(\"event 001\", (SIGNAL_FUNC) event_connected);\n\tsignal_add(\"event 004\", (SIGNAL_FUNC) event_server_info);\n\tsignal_add(\"event 005\", (SIGNAL_FUNC) event_isupport);\n\tsignal_add(\"event 375\", (SIGNAL_FUNC) event_motd);\n\tsignal_add_last(\"event 376\", (SIGNAL_FUNC) event_end_of_motd);\n\tsignal_add_last(\"event 422\", (SIGNAL_FUNC) event_end_of_motd); \/* no motd *\/\n\tsignal_add(\"event 254\", (SIGNAL_FUNC) event_channels_formed);\n\tsignal_add(\"event 396\", (SIGNAL_FUNC) event_hosthidden);\n\tsignal_add(\"event 465\", (SIGNAL_FUNC) event_server_banned);\n\tsignal_add(\"event error\", (SIGNAL_FUNC) event_error);\n\tsignal_add(\"event ping\", (SIGNAL_FUNC) event_ping);\n\tsignal_add(\"event empty\", (SIGNAL_FUNC) event_empty);\n\n\tirc_servers_setup_init();\n\tirc_servers_reconnect_init();\n\tservers_redirect_init();\n\tservers_idle_init();\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":439758,"func":"static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest,\n\t\t\t\t    SplashColorPtr blend, SplashColorMode cm) {\n  int i;\n\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n    }\n  }\n#endif\n  {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      blend[i] = dest[i] + src[i] - (2 * dest[i] * src[i]) \/ 255;\n    }\n  }\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n      blend[i] = 255 - blend[i];\n    }\n  }\n  if (cm == splashModeDeviceN8) {\n    for (i = 4; i < splashColorModeNComps[cm]; ++i) {\n      if (dest[i] == 0 && src[i] == 0)\n        blend[i] = 0;\n    }\n  }\n#endif\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":21865,"func":"static int x ( struct vcache * avc , int afun , struct vrequest * areq , \\ struct afs_pdata * ain , struct afs_pdata * aout , \\ afs_ucred_t * * acred ) DECL_PIOCTL ( PGetFID ) ;\n DECL_PIOCTL ( PSetAcl ) ;\n DECL_PIOCTL ( PStoreBehind ) ;\n DECL_PIOCTL ( PGCPAGs ) ;\n DECL_PIOCTL ( PGetAcl ) ;\n DECL_PIOCTL ( PNoop ) ;\n DECL_PIOCTL ( PBogus ) ;\n DECL_PIOCTL ( PGetFileCell ) ;\n DECL_PIOCTL ( PGetWSCell ) ;\n DECL_PIOCTL ( PGetUserCell ) ;\n DECL_PIOCTL ( PSetTokens ) ;\n DECL_PIOCTL ( PGetVolumeStatus ) ;\n DECL_PIOCTL ( PSetVolumeStatus ) ;\n DECL_PIOCTL ( PFlush ) ;\n DECL_PIOCTL ( PNewStatMount ) ;\n DECL_PIOCTL ( PGetTokens ) ;\n DECL_PIOCTL ( PUnlog ) ;\n DECL_PIOCTL ( PMariner ) ;\n DECL_PIOCTL ( PCheckServers ) ;\n DECL_PIOCTL ( PCheckVolNames ) ;\n DECL_PIOCTL ( PCheckAuth ) ;\n DECL_PIOCTL ( PFindVolume ) ;\n DECL_PIOCTL ( PViceAccess ) ;\n DECL_PIOCTL ( PSetCacheSize ) ;\n DECL_PIOCTL ( PGetCacheSize ) ;\n DECL_PIOCTL ( PRemoveCallBack ) ;\n DECL_PIOCTL ( PNewCell ) ;\n DECL_PIOCTL ( PNewAlias ) ;\n DECL_PIOCTL ( PListCells )","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":381801,"func":"comparetup_heap(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)\n{\n\tSortSupport sortKey = state->sortKeys;\n\tHeapTupleData ltup;\n\tHeapTupleData rtup;\n\tTupleDesc\ttupDesc;\n\tint\t\t\tnkey;\n\tint32\t\tcompare;\n\tAttrNumber\tattno;\n\tDatum\t\tdatum1,\n\t\t\t\tdatum2;\n\tbool\t\tisnull1,\n\t\t\t\tisnull2;\n\n\n\t\/* Compare the leading sort key *\/\n\tcompare = ApplySortComparator(a->datum1, a->isnull1,\n\t\t\t\t\t\t\t\t  b->datum1, b->isnull1,\n\t\t\t\t\t\t\t\t  sortKey);\n\tif (compare != 0)\n\t\treturn compare;\n\n\t\/* Compare additional sort keys *\/\n\tltup.t_len = ((MinimalTuple) a->tuple)->t_len + MINIMAL_TUPLE_OFFSET;\n\tltup.t_data = (HeapTupleHeader) ((char *) a->tuple - MINIMAL_TUPLE_OFFSET);\n\trtup.t_len = ((MinimalTuple) b->tuple)->t_len + MINIMAL_TUPLE_OFFSET;\n\trtup.t_data = (HeapTupleHeader) ((char *) b->tuple - MINIMAL_TUPLE_OFFSET);\n\ttupDesc = state->tupDesc;\n\n\tif (sortKey->abbrev_converter)\n\t{\n\t\tattno = sortKey->ssup_attno;\n\n\t\tdatum1 = heap_getattr(<up, attno, tupDesc, &isnull1);\n\t\tdatum2 = heap_getattr(&rtup, attno, tupDesc, &isnull2);\n\n\t\tcompare = ApplySortAbbrevFullComparator(datum1, isnull1,\n\t\t\t\t\t\t\t\t\t\t\t\tdatum2, isnull2,\n\t\t\t\t\t\t\t\t\t\t\t\tsortKey);\n\t\tif (compare != 0)\n\t\t\treturn compare;\n\t}\n\n\tsortKey++;\n\tfor (nkey = 1; nkey < state->nKeys; nkey++, sortKey++)\n\t{\n\t\tattno = sortKey->ssup_attno;\n\n\t\tdatum1 = heap_getattr(<up, attno, tupDesc, &isnull1);\n\t\tdatum2 = heap_getattr(&rtup, attno, tupDesc, &isnull2);\n\n\t\tcompare = ApplySortComparator(datum1, isnull1,\n\t\t\t\t\t\t\t\t\t  datum2, isnull2,\n\t\t\t\t\t\t\t\t\t  sortKey);\n\t\tif (compare != 0)\n\t\t\treturn compare;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":104806,"func":"char * get_fru_area_str(uint8_t * data, uint32_t * offset)\n{\n\tstatic const char bcd_plus[] = \"0123456789 -.:,_\";\n\tchar * str;\n\tint len, off, size, i, j, k, typecode, char_idx;\n\tunion {\n\t\tuint32_t bits;\n\t\tchar chars[4];\n\t} u;\n\n\tsize = 0;\n\toff = *offset;\n\n\t\/* bits 6:7 contain format *\/\n\ttypecode = ((data[off] & 0xC0) >> 6);\n\n\t\/\/ printf(\"Typecode:%i\\n\", typecode);\n\t\/* bits 0:5 contain length *\/\n\tlen = data[off++];\n\tlen &= 0x3f;\n\n\tswitch (typecode) {\n\tcase 0:           \/* 00b: binary\/unspecified *\/\n\tcase 1:           \/* 01b: BCD plus *\/\n\t\t\/* hex dump or BCD -> 2x length *\/\n\t\tsize = (len * 2);\n\t\tbreak;\n\tcase 2:           \/* 10b: 6-bit ASCII *\/\n\t\t\/* 4 chars per group of 1-3 bytes *\/\n\t\tsize = (((len * 4 + 2) \/ 3) & ~3);\n\t\tbreak;\n\tcase 3:           \/* 11b: 8-bit ASCII *\/\n\t\t\/* no length adjustment *\/\n\t\tsize = len;\n\t\tbreak;\n\t}\n\n\tif (size < 1) {\n\t\t*offset = off;\n\t\treturn NULL;\n\t}\n\tstr = malloc(size+1);\n\tif (!str)\n\t\treturn NULL;\n\tmemset(str, 0, size+1);\n\n\tif (size == 0) {\n\t\tstr[0] = '\\0';\n\t\t*offset = off;\n\t\treturn str;\n\t}\n\n\tswitch (typecode) {\n\tcase 0:        \/* Binary *\/\n\t\tstrncpy(str, buf2str(&data[off], len), size);\n\t\tbreak;\n\n\tcase 1:        \/* BCD plus *\/\n\t\tfor (k = 0; k < size; k++)\n\t\t\tstr[k] = bcd_plus[((data[off + k \/ 2] >> ((k % 2) ? 0 : 4)) & 0x0f)];\n\t\tstr[k] = '\\0';\n\t\tbreak;\n\n\tcase 2:        \/* 6-bit ASCII *\/\n\t\tfor (i = j = 0; i < len; i += 3) {\n\t\t\tu.bits = 0;\n\t\t\tk = ((len - i) < 3 ? (len - i) : 3);\n#if WORDS_BIGENDIAN\n\t\t\tu.chars[3] = data[off+i];\n\t\t\tu.chars[2] = (k > 1 ? data[off+i+1] : 0);\n\t\t\tu.chars[1] = (k > 2 ? data[off+i+2] : 0);\n\t\t\tchar_idx = 3;\n#else\n\t\t\tmemcpy((void *)&u.bits, &data[off+i], k);\n\t\t\tchar_idx = 0;\n#endif\n\t\t\tfor (k=0; k<4; k++) {\n\t\t\t\tstr[j++] = ((u.chars[char_idx] & 0x3f) + 0x20);\n\t\t\t\tu.bits >>= 6;\n\t\t\t}\n\t\t}\n\t\tstr[j] = '\\0';\n\t\tbreak;\n\n\tcase 3:\n\t\tmemcpy(str, &data[off], size);\n\t\tstr[size] = '\\0';\n\t\tbreak;\n\t}\n\n\toff += len;\n\t*offset = off;\n\n\treturn str;\n}","target":0,"code_token_length":760,"total_token_length":996,"max_tokens_setting":1024}
+{"idx":34108,"func":"static int handle_NPP_Destroy(rpc_connection_t *connection)\n{\n  D(bug(\"handle_NPP_Destroy\\n\"));\n\n  int error;\n  PluginInstance *plugin;\n  error = rpc_method_get_args(connection,\n\t\t\t\t\t\t\t  RPC_TYPE_NPW_PLUGIN_INSTANCE, &plugin,\n\t\t\t\t\t\t\t  RPC_TYPE_INVALID);\n\n  if (error != RPC_ERROR_NO_ERROR) {\n\tnpw_perror(\"NPP_Destroy() get args\", error);\n\treturn error;\n  }\n\n  NPSavedData *save_area = NULL;\n  NPError ret = NPERR_NO_ERROR;\n  \/* Take a ref for the rpc_method_send_reply; otherwise the\n   * rpc_connection_unref in g_NPP_Destroy_Now may cause a slight\n   * nuisance. *\/\n  rpc_connection_ref(connection);\n  if (!rpc_method_in_invoke(connection)) {\n\t\/* The plugin is not on the stack; it's safe to call this. *\/\n\tD(bug(\"NPP_Destroy is fine.\\n\"));\n\tret = g_NPP_Destroy_Now(plugin, &save_area);\n  } else {\n\t\/* It is not safe to call NPP_Destroy right now. Delay it until we\n\t * return to the event loop.\n\t *\n\t * NOTE: This means that the browser never sees the real return\n\t * value of NPP_Destroy; the NPSavedData will be discarded, and any\n\t * error code will be ignored. *\/\n    D(bug(\"NPP_Destroy raced; delaying it to get a clean stack.\\n\"));\n\tdelayed_destroys_add(plugin);\n  }\n\n  error = rpc_method_send_reply(connection,\n\t\t\t\t\t\t\t\tRPC_TYPE_INT32, ret,\n\t\t\t\t\t\t\t\tRPC_TYPE_NP_SAVED_DATA, save_area,\n\t\t\t\t\t\t\t\tRPC_TYPE_INVALID);\n  if (save_area) {\n    if (save_area->buf)\n      NPN_MemFree(save_area->buf);\n    NPN_MemFree(save_area);\n  }\n\n  rpc_connection_unref(connection);\n  return error;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":12062,"func":" int test_sqr(BIO *bp, BN_CTX *ctx)\n \t{\n\tBIGNUM a,c,d,e;\n\tint i;\n \n\tBN_init(&a);\n\tBN_init(&c);\n\tBN_init(&d);\n\tBN_init(&e);\n \n \tfor (i=0; i<num0; i++)\n \t\t{\n\t\tBN_bntest_rand(&a,40+i*10,0,0);\n\t\ta.neg=rand_neg();\n\t\tBN_sqr(&c,&a,ctx);\n \t\tif (bp != NULL)\n \t\t\t{\n \t\t\tif (!results)\n \t\t\t\t{\n\t\t\t\tBN_print(bp,&a);\n \t\t\t\tBIO_puts(bp,\" * \");\n\t\t\t\tBN_print(bp,&a);\n \t\t\t\tBIO_puts(bp,\" - \");\n \t\t\t\t}\n\t\t\tBN_print(bp,&c);\n \t\t\tBIO_puts(bp,\"\\n\");\n \t\t\t}\n\t\tBN_div(&d,&e,&c,&a,ctx);\n\t\tBN_sub(&d,&d,&a);\n\t\tif(!BN_is_zero(&d) || !BN_is_zero(&e))\n\t\t    {\n\t\t    fprintf(stderr,\"Square test failed!\\n\");\n\t\t    return 0;\n\t\t    }\n \t\t}\n\tBN_free(&a);\n\tBN_free(&c);\n\tBN_free(&d);\n\tBN_free(&e);\n\treturn(1);\n \t}\n","target":1,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":192848,"func":"IV_API_CALL_STATUS_T impeg2d_api_function (iv_obj_t *ps_dechdl, void *pv_api_ip,void *pv_api_op)\n{\n    WORD32 i4_cmd;\n    IV_API_CALL_STATUS_T u4_error_code;\n    UWORD32 *pu4_api_ip;\n\n    u4_error_code = impeg2d_api_check_struct_sanity(ps_dechdl,pv_api_ip,pv_api_op);\n if(IV_SUCCESS != u4_error_code)\n {\n return u4_error_code;\n }\n\n\n    pu4_api_ip  = (UWORD32 *)pv_api_ip;\n    i4_cmd = *(pu4_api_ip + 1);\n\n switch(i4_cmd)\n {\n\n case IV_CMD_GET_NUM_MEM_REC:\n        u4_error_code = impeg2d_api_num_mem_rec((void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IV_CMD_FILL_NUM_MEM_REC:\n        u4_error_code = impeg2d_api_fill_mem_rec((void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IV_CMD_INIT:\n        u4_error_code = impeg2d_api_init(ps_dechdl,(void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IVD_CMD_SET_DISPLAY_FRAME:\n        u4_error_code = impeg2d_api_set_display_frame(ps_dechdl,(void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IVD_CMD_REL_DISPLAY_FRAME:\n        u4_error_code = impeg2d_api_rel_display_frame(ps_dechdl,(void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IVD_CMD_VIDEO_DECODE:\n        u4_error_code = impeg2d_api_entity(ps_dechdl, (void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IV_CMD_RETRIEVE_MEMREC:\n        u4_error_code = impeg2d_api_retrieve_mem_rec(ps_dechdl,(void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n case IVD_CMD_VIDEO_CTL:\n        u4_error_code = impeg2d_api_ctl(ps_dechdl,(void *)pv_api_ip,(void *)pv_api_op);\n break;\n\n default:\n break;\n }\n\n return(u4_error_code);\n\n}\n","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":159576,"func":"STATIC void\nS_ssc_finalize(pTHX_ RExC_state_t *pRExC_state, regnode_ssc *ssc)\n{\n    \/* The inversion list in the SSC is marked mortal; now we need a more\n     * permanent copy, which is stored the same way that is done in a regular\n     * ANYOF node, with the first NUM_ANYOF_CODE_POINTS code points in a bit\n     * map *\/\n\n    SV* invlist = invlist_clone(ssc->invlist, NULL);\n\n    PERL_ARGS_ASSERT_SSC_FINALIZE;\n\n    assert(is_ANYOF_SYNTHETIC(ssc));\n\n    \/* The code in this file assumes that all but these flags aren't relevant\n     * to the SSC, except SSC_MATCHES_EMPTY_STRING, which should be cleared\n     * by the time we reach here *\/\n    assert(! (ANYOF_FLAGS(ssc)\n        & ~( ANYOF_COMMON_FLAGS\n            |ANYOF_SHARED_d_MATCHES_ALL_NON_UTF8_NON_ASCII_non_d_WARN_SUPER\n            |ANYOF_SHARED_d_UPPER_LATIN1_UTF8_STRING_MATCHES_non_d_RUNTIME_USER_PROP)));\n\n    populate_ANYOF_from_invlist( (regnode *) ssc, &invlist);\n\n    set_ANYOF_arg(pRExC_state, (regnode *) ssc, invlist, NULL, NULL);\n\n    \/* Make sure is clone-safe *\/\n    ssc->invlist = NULL;\n\n    if (ANYOF_POSIXL_SSC_TEST_ANY_SET(ssc)) {\n        ANYOF_FLAGS(ssc) |= ANYOF_MATCHES_POSIXL;\n        OP(ssc) = ANYOFPOSIXL;\n    }\n    else if (RExC_contains_locale) {\n        OP(ssc) = ANYOFL;\n    }\n\n    assert(! (ANYOF_FLAGS(ssc) & ANYOF_LOCALE_FLAGS) || RExC_contains_locale);","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":150618,"func":"static void ext4_map_blocks_es_recheck(handle_t *handle,\n\t\t\t\t       struct inode *inode,\n\t\t\t\t       struct ext4_map_blocks *es_map,\n\t\t\t\t       struct ext4_map_blocks *map,\n\t\t\t\t       int flags)\n{\n\tint retval;\n\n\tmap->m_flags = 0;\n\t\/*\n\t * There is a race window that the result is not the same.\n\t * e.g. xfstests #223 when dioread_nolock enables.  The reason\n\t * is that we lookup a block mapping in extent status tree with\n\t * out taking i_data_sem.  So at the time the unwritten extent\n\t * could be converted.\n\t *\/\n\tif (!(flags & EXT4_GET_BLOCKS_NO_LOCK))\n\t\tdown_read(&EXT4_I(inode)->i_data_sem);\n\tif (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {\n\t\tretval = ext4_ext_map_blocks(handle, inode, map, flags &\n\t\t\t\t\t     EXT4_GET_BLOCKS_KEEP_SIZE);\n\t} else {\n\t\tretval = ext4_ind_map_blocks(handle, inode, map, flags &\n\t\t\t\t\t     EXT4_GET_BLOCKS_KEEP_SIZE);\n\t}\n\tif (!(flags & EXT4_GET_BLOCKS_NO_LOCK))\n\t\tup_read((&EXT4_I(inode)->i_data_sem));\n\n\t\/*\n\t * We don't check m_len because extent will be collpased in status\n\t * tree.  So the m_len might not equal.\n\t *\/\n\tif (es_map->m_lblk != map->m_lblk ||\n\t    es_map->m_flags != map->m_flags ||\n\t    es_map->m_pblk != map->m_pblk) {\n\t\tprintk(\"ES cache assertion failed for inode: %lu \"\n\t\t       \"es_cached ex [%d\/%d\/%llu\/%x] != \"\n\t\t       \"found ex [%d\/%d\/%llu\/%x] retval %d flags %x\\n\",\n\t\t       inode->i_ino, es_map->m_lblk, es_map->m_len,\n\t\t       es_map->m_pblk, es_map->m_flags, map->m_lblk,\n\t\t       map->m_len, map->m_pblk, map->m_flags,\n\t\t       retval, flags);\n\t}\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":28043,"func":"static void super_block_uvrd ( const VP9_COMP * cpi , MACROBLOCK * x , int * rate , int64_t * distortion , int * skippable , int64_t * sse , BLOCK_SIZE bsize , int64_t ref_best_rd ) {\n MACROBLOCKD * const xd = & x -> e_mbd ;\n MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] . src_mi -> mbmi ;\n const TX_SIZE uv_tx_size = get_uv_tx_size ( mbmi , & xd -> plane [ 1 ] ) ;\n int plane ;\n int pnrate = 0 , pnskip = 1 ;\n int64_t pndist = 0 , pnsse = 0 ;\n if ( ref_best_rd < 0 ) goto term ;\n if ( is_inter_block ( mbmi ) ) {\n int plane ;\n for ( plane = 1 ;\n plane < MAX_MB_PLANE ;\n ++ plane ) vp9_subtract_plane ( x , bsize , plane ) ;\n }\n * rate = 0 ;\n * distortion = 0 ;\n * sse = 0 ;\n * skippable = 1 ;\n for ( plane = 1 ;\n plane < MAX_MB_PLANE ;\n ++ plane ) {\n txfm_rd_in_plane ( x , & pnrate , & pndist , & pnskip , & pnsse , ref_best_rd , plane , bsize , uv_tx_size , cpi -> sf . use_fast_coef_costing ) ;\n if ( pnrate == INT_MAX ) goto term ;\n * rate += pnrate ;\n * distortion += pndist ;\n * sse += pnsse ;\n * skippable &= pnskip ;\n }\n return ;\n term : * rate = INT_MAX ;\n * distortion = INT64_MAX ;\n * sse = INT64_MAX ;\n * skippable = 0 ;\n return ;\n }","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":412572,"func":"pk_transaction_repo_enable (PkTransaction *transaction,\n\t\t\t    GVariant *params,\n\t\t\t    GDBusMethodInvocation *context)\n{\n\tgboolean ret;\n\tconst gchar *repo_id;\n\tgboolean enabled;\n\tg_autoptr(GError) error = NULL;\n\n\tg_return_if_fail (PK_IS_TRANSACTION (transaction));\n\tg_return_if_fail (transaction->priv->tid != NULL);\n\n\tg_variant_get (params, \"(&sb)\",\n\t\t       &repo_id,\n\t\t       &enabled);\n\n\tg_debug (\"RepoEnable method called: %s, %i\", repo_id, enabled);\n\n\t\/* not implemented yet *\/\n\tif (!pk_backend_is_implemented (transaction->priv->backend,\n\t\t\t\t\tPK_ROLE_ENUM_REPO_ENABLE)) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_NOT_SUPPORTED,\n\t\t\t     \"RepoEnable not supported by backend\");\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* check for sanity *\/\n\tret = pk_transaction_strvalidate (repo_id, &error);\n\tif (!ret) {\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* save so we can run later *\/\n\ttransaction->priv->cached_repo_id = g_strdup (repo_id);\n\ttransaction->priv->cached_enabled = enabled;\n\tpk_transaction_set_role (transaction, PK_ROLE_ENUM_REPO_ENABLE);\n\n\t\/* try to get authorization *\/\n\tret = pk_transaction_obtain_authorization (transaction,\n\t\t\t\t\t\t   PK_ROLE_ENUM_REPO_ENABLE,\n\t\t\t\t\t\t   &error);\n\tif (!ret) {\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\nout:\n\tpk_transaction_dbus_return (context, error);\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":128587,"func":"void FVMarkHintsOutOfDate(SplineChar *sc) {\n    int i, j;\n    int pos;\n    FontView *fv;\n\n    if ( sc->parent->onlybitmaps || sc->parent->multilayer || sc->parent->strokedfont )\nreturn;\n    for ( fv = (FontView *) (sc->parent->fv); fv!=NULL; fv=(FontView *) (fv->b.nextsame) ) {\n\tif ( fv->b.sf!=sc->parent )\t\t\/* Can happen in CID fonts if char's parent is not currently active *\/\n    continue;\n\tif ( sc->layers[fv->b.active_layer].order2 )\n    continue;\n\tif ( fv->v==NULL || fv->colcnt==0 )\t\/* Can happen in scripts *\/\n    continue;\n\tfor ( pos=0; pos<fv->b.map->enccount; ++pos ) if ( fv->b.map->map[pos]==sc->orig_pos ) {\n\t    i = pos \/ fv->colcnt;\n\t    j = pos - i*fv->colcnt;\n\t    i -= fv->rowoff;\n \/* Normally we should be checking against fv->rowcnt (rather than <=rowcnt) *\/\n \/*  but every now and then the WM forces us to use a window size which doesn't *\/\n \/*  fit our expectations (maximized view) and we must be prepared for half *\/\n \/*  lines *\/\n\t    if ( i>=0 && i<=fv->rowcnt ) {\n\t\tGRect r;\n\t\tr.x = j*fv->cbw+1; r.width = fv->cbw-1;\n\t\tr.y = i*fv->cbh+1; r.height = fv->lab_height-1;\n\t\tGDrawDrawLine(fv->v,r.x,r.y,r.x,r.y+r.height-1,fvhintingneededcol);\n\t\tGDrawDrawLine(fv->v,r.x+1,r.y,r.x+1,r.y+r.height-1,fvhintingneededcol);\n\t\tGDrawDrawLine(fv->v,r.x+r.width-1,r.y,r.x+r.width-1,r.y+r.height-1,fvhintingneededcol);\n\t\tGDrawDrawLine(fv->v,r.x+r.width-2,r.y,r.x+r.width-2,r.y+r.height-1,fvhintingneededcol);\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":498,"total_token_length":734,"max_tokens_setting":1024}
+{"idx":492983,"func":"static int ssl_compress_buf( mbedtls_ssl_context *ssl )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n    unsigned char *msg_post = ssl->out_msg;\n    ptrdiff_t bytes_written = ssl->out_msg - ssl->out_buf;\n    size_t len_pre = ssl->out_msglen;\n    unsigned char *msg_pre = ssl->compress_buf;\n#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)\n    size_t out_buf_len = ssl->out_buf_len;\n#else\n    size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN;\n#endif\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> compress buf\" ) );\n\n    if( len_pre == 0 )\n        return( 0 );\n\n    memcpy( msg_pre, ssl->out_msg, len_pre );\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"before compression: msglen = %\" MBEDTLS_PRINTF_SIZET \", \",\n                   ssl->out_msglen ) );\n\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"before compression: output payload\",\n                   ssl->out_msg, ssl->out_msglen );\n\n    ssl->transform_out->ctx_deflate.next_in = msg_pre;\n    ssl->transform_out->ctx_deflate.avail_in = len_pre;\n    ssl->transform_out->ctx_deflate.next_out = msg_post;\n    ssl->transform_out->ctx_deflate.avail_out = out_buf_len - bytes_written;\n\n    ret = deflate( &ssl->transform_out->ctx_deflate, Z_SYNC_FLUSH );\n    if( ret != Z_OK )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"failed to perform compression (%d)\", ret ) );\n        return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED );\n    }\n\n    ssl->out_msglen = out_buf_len -\n                      ssl->transform_out->ctx_deflate.avail_out - bytes_written;\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"after compression: msglen = %\" MBEDTLS_PRINTF_SIZET \", \",\n                   ssl->out_msglen ) );\n\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"after compression: output payload\",\n                   ssl->out_msg, ssl->out_msglen );\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= compress buf\" ) );\n\n    return( 0 );\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":102110,"func":"static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,\n\t\t\t\t   struct file *file,\n\t\t\t\t   const char __user *userbuf, size_t count,\n\t\t\t\t   loff_t *ppos)\n{\n\tstruct cmd_ds_802_11_subscribe_event *events;\n\tstruct mrvl_ie_thresholds *tlv;\n\tstruct lbs_private *priv = file->private_data;\n\tssize_t buf_size;\n\tint value, freq, new_mask;\n\tuint16_t curr_mask;\n\tchar *buf;\n\tint ret;\n\n\tbuf = (char *)get_zeroed_page(GFP_KERNEL);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tbuf_size = min(count, len - 1);\n\tif (copy_from_user(buf, userbuf, buf_size)) {\n\t\tret = -EFAULT;\n\t\tgoto out_page;\n\t}\n\tret = sscanf(buf, \"%d %d %d\", &value, &freq, &new_mask);\n\tif (ret != 3) {\n\t\tret = -EINVAL;\n\t\tgoto out_page;\n\t}\n\tevents = kzalloc(sizeof(*events), GFP_KERNEL);\n\tif (!events) {\n\t\tret = -ENOMEM;\n\t\tgoto out_page;\n\t}\n\n\tevents->hdr.size = cpu_to_le16(sizeof(*events));\n\tevents->action = cpu_to_le16(CMD_ACT_GET);\n\n\tret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);\n\tif (ret)\n\t\tgoto out_events;\n\n\tcurr_mask = le16_to_cpu(events->events);\n\n\tif (new_mask)\n\t\tnew_mask = curr_mask | event_mask;\n\telse\n\t\tnew_mask = curr_mask & ~event_mask;\n\n\t\/* Now everything is set and we can send stuff down to the firmware *\/\n\n\ttlv = (void *)events->tlv;\n\n\tevents->action = cpu_to_le16(CMD_ACT_SET);\n\tevents->events = cpu_to_le16(new_mask);\n\ttlv->header.type = cpu_to_le16(tlv_type);\n\ttlv->header.len = cpu_to_le16(sizeof(*tlv) - sizeof(tlv->header));\n\ttlv->value = value;\n\tif (tlv_type != TLV_TYPE_BCNMISS)\n\t\ttlv->freq = freq;\n\n\t\/* The command header, the action, the event mask, and one TLV *\/\n\tevents->hdr.size = cpu_to_le16(sizeof(events->hdr) + 4 + sizeof(*tlv));\n\n\tret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);\n\n\tif (!ret)\n\t\tret = count;\n out_events:\n\tkfree(events);\n out_page:\n\tfree_page((unsigned long)buf);\n\treturn ret;\n}","target":0,"code_token_length":558,"total_token_length":794,"max_tokens_setting":1024}
+{"idx":14790,"func":"status_t OMXNodeInstance::emptyBuffer(\n        OMX::buffer_id buffer,\n        OMX_U32 rangeOffset, OMX_U32 rangeLength,\n\n         OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) {\n     Mutex::Autolock autoLock(mLock);\n \n     OMX_BUFFERHEADERTYPE *header = findBufferHeader(buffer, kPortIndexInput);\n     if (header == NULL) {\n         ALOGE(\"b\/25884056\");\n return BAD_VALUE;\n }\n BufferMeta *buffer_meta =\n static_cast<BufferMeta *>(header->pAppPrivate);\n    sp<ABuffer> backup = buffer_meta->getBuffer(header, true \/* backup *\/, false \/* limit *\/);\n    sp<ABuffer> codec = buffer_meta->getBuffer(header, false \/* backup *\/, false \/* limit *\/);\n\n if (mMetadataType[kPortIndexInput] == kMetadataBufferTypeGrallocSource\n && backup->capacity() >= sizeof(VideoNativeMetadata)\n && codec->capacity() >= sizeof(VideoGrallocMetadata)\n && ((VideoNativeMetadata *)backup->base())->eType\n == kMetadataBufferTypeANWBuffer) {\n VideoNativeMetadata &backupMeta = *(VideoNativeMetadata *)backup->base();\n VideoGrallocMetadata &codecMeta = *(VideoGrallocMetadata *)codec->base();\n        CLOG_BUFFER(emptyBuffer, \"converting ANWB %p to handle %p\",\n                backupMeta.pBuffer, backupMeta.pBuffer->handle);\n        codecMeta.pHandle = backupMeta.pBuffer != NULL ? backupMeta.pBuffer->handle : NULL;\n        codecMeta.eType = kMetadataBufferTypeGrallocSource;\n        header->nFilledLen = rangeLength ? sizeof(codecMeta) : 0;\n        header->nOffset = 0;\n } else {\n if (rangeOffset > header->nAllocLen\n || rangeLength > header->nAllocLen - rangeOffset) {\n            CLOG_ERROR(emptyBuffer, OMX_ErrorBadParameter, FULL_BUFFER(NULL, header, fenceFd));\n if (fenceFd >= 0) {\n ::close(fenceFd);\n }\n return BAD_VALUE;\n }\n        header->nFilledLen = rangeLength;\n        header->nOffset = rangeOffset;\n\n        buffer_meta->CopyToOMX(header);\n }\n\n return emptyBuffer_l(header, flags, timestamp, (intptr_t)buffer, fenceFd);\n}\n","target":1,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":52770,"func":"static void process_bin_stat(conn *c) {\n    char *subcommand = binary_get_key(c);\n    size_t nkey = c->binary_header.request.keylen;\n\n    if (settings.verbose > 1) {\n        int ii;\n        fprintf(stderr, \"<%d STATS \", c->sfd);\n        for (ii = 0; ii < nkey; ++ii) {\n            fprintf(stderr, \"%c\", subcommand[ii]);\n        }\n        fprintf(stderr, \"\\n\");\n    }\n\n    if (nkey == 0) {\n        \/* request all statistics *\/\n        server_stats(&append_stats, c);\n        (void)get_stats(NULL, 0, &append_stats, c);\n    } else if (strncmp(subcommand, \"reset\", 5) == 0) {\n        stats_reset();\n    } else if (strncmp(subcommand, \"settings\", 8) == 0) {\n        process_stat_settings(&append_stats, c);\n    } else if (strncmp(subcommand, \"detail\", 6) == 0) {\n        char *subcmd_pos = subcommand + 6;\n        if (strncmp(subcmd_pos, \" dump\", 5) == 0) {\n            int len;\n            char *dump_buf = stats_prefix_dump(&len);\n            if (dump_buf == NULL || len <= 0) {\n                write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0);\n                return ;\n            } else {\n                append_stats(\"detailed\", strlen(\"detailed\"), dump_buf, len, c);\n                free(dump_buf);\n            }\n        } else if (strncmp(subcmd_pos, \" on\", 3) == 0) {\n            settings.detail_enabled = 1;\n        } else if (strncmp(subcmd_pos, \" off\", 4) == 0) {\n            settings.detail_enabled = 0;\n        } else {\n            write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0);\n            return;\n        }\n    } else {\n        if (get_stats(subcommand, nkey, &append_stats, c)) {\n            if (c->stats.buffer == NULL) {\n                write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0);\n            } else {\n                write_and_free(c, c->stats.buffer, c->stats.offset);\n                c->stats.buffer = NULL;\n            }\n        } else {\n            write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0);\n        }\n\n        return;\n    }\n\n    \/* Append termination package and start the transfer *\/\n    append_stats(NULL, 0, NULL, 0, c);\n    if (c->stats.buffer == NULL) {\n        write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0);\n    } else {\n        write_and_free(c, c->stats.buffer, c->stats.offset);\n        c->stats.buffer = NULL;\n    }\n}","target":0,"code_token_length":605,"total_token_length":841,"max_tokens_setting":1024}
+{"idx":156685,"func":"tune_quant(Node* node, regex_t* reg, int state, ScanEnv* env)\n{\n  int r;\n  QuantNode* qn = QUANT_(node);\n  Node* body = NODE_BODY(node);\n\n  if ((state & IN_REAL_REPEAT) != 0) {\n    NODE_STATUS_ADD(node, IN_REAL_REPEAT);\n  }\n  if ((state & IN_MULTI_ENTRY) != 0) {\n    NODE_STATUS_ADD(node, IN_MULTI_ENTRY);\n  }\n\n  if (IS_INFINITE_REPEAT(qn->upper) || qn->upper >= 1) {\n    OnigLen d = node_min_byte_len(body, env);\n    if (d == 0) {\n#ifdef USE_STUBBORN_CHECK_CAPTURES_IN_EMPTY_REPEAT\n      qn->emptiness = quantifiers_memory_node_info(body);\n#else\n      qn->emptiness = BODY_MAY_BE_EMPTY;\n#endif\n    }\n  }\n\n  if (IS_INFINITE_REPEAT(qn->upper) || qn->upper >= 2)\n    state |= IN_REAL_REPEAT;\n  if (qn->lower != qn->upper)\n    state |= IN_VAR_REPEAT;\n\n  r = tune_tree(body, reg, state, env);\n  if (r != 0) return r;\n\n  \/* expand string *\/\n#define EXPAND_STRING_MAX_LENGTH  100\n  if (NODE_TYPE(body) == NODE_STRING) {\n    if (!IS_INFINITE_REPEAT(qn->lower) && qn->lower == qn->upper &&\n        qn->lower > 1 && qn->lower <= EXPAND_STRING_MAX_LENGTH) {\n      int len = NODE_STRING_LEN(body);\n\n      if (len * qn->lower <= EXPAND_STRING_MAX_LENGTH) {\n        int i, n = qn->lower;\n        node_conv_to_str_node(node, body);\n        for (i = 0; i < n; i++) {\n          r = node_str_node_cat(node, body);\n          if (r != 0) return r;\n        }\n        onig_node_free(body);\n        return r;\n      }\n    }\n  }\n\n  if (qn->greedy && (qn->emptiness == BODY_IS_NOT_EMPTY)) {\n    if (NODE_TYPE(body) == NODE_QUANT) {\n      QuantNode* tqn = QUANT_(body);\n      if (IS_NOT_NULL(tqn->head_exact)) {\n        qn->head_exact  = tqn->head_exact;\n        tqn->head_exact = NULL;\n      }\n    }\n    else {\n      qn->head_exact = get_tree_head_literal(NODE_BODY(node), 1, reg);\n    }\n  }\n\n  return r;\n}","target":0,"code_token_length":555,"total_token_length":791,"max_tokens_setting":1024}
+{"idx":206289,"func":"String DOMWindow::CrossDomainAccessErrorMessage(\n    const LocalDOMWindow* calling_window) const {\n  if (!calling_window || !calling_window->document() || !GetFrame())\n    return String();\n\n  const KURL& calling_window_url = calling_window->document()->Url();\n  if (calling_window_url.IsNull())\n    return String();\n\n  const SecurityOrigin* active_origin =\n      calling_window->document()->GetSecurityOrigin();\n  const SecurityOrigin* target_origin =\n      GetFrame()->GetSecurityContext()->GetSecurityOrigin();\n  DCHECK(GetFrame()->IsRemoteFrame() ||\n         !active_origin->CanAccess(target_origin));\n\n  String message = \"Blocked a frame with origin \\\"\" +\n                   active_origin->ToString() +\n                   \"\\\" from accessing a frame with origin \\\"\" +\n                   target_origin->ToString() + \"\\\". \";\n\n  KURL active_url = calling_window->document()->Url();\n  KURL target_url = IsLocalDOMWindow()\n                        ? blink::ToLocalDOMWindow(this)->document()->Url()\n                        : KURL(NullURL(), target_origin->ToString());\n  if (GetFrame()->GetSecurityContext()->IsSandboxed(kSandboxOrigin) ||\n      calling_window->document()->IsSandboxed(kSandboxOrigin)) {\n    message = \"Blocked a frame at \\\"\" +\n              SecurityOrigin::Create(active_url)->ToString() +\n              \"\\\" from accessing a frame at \\\"\" +\n              SecurityOrigin::Create(target_url)->ToString() + \"\\\". \";\n    if (GetFrame()->GetSecurityContext()->IsSandboxed(kSandboxOrigin) &&\n        calling_window->document()->IsSandboxed(kSandboxOrigin))\n      return \"Sandbox access violation: \" + message +\n             \" Both frames are sandboxed and lack the \\\"allow-same-origin\\\" \"\n             \"flag.\";\n    if (GetFrame()->GetSecurityContext()->IsSandboxed(kSandboxOrigin))\n      return \"Sandbox access violation: \" + message +\n             \" The frame being accessed is sandboxed and lacks the \"\n             \"\\\"allow-same-origin\\\" flag.\";\n    return \"Sandbox access violation: \" + message +\n           \" The frame requesting access is sandboxed and lacks the \"\n           \"\\\"allow-same-origin\\\" flag.\";\n  }\n\n  if (target_origin->Protocol() != active_origin->Protocol())\n    return message + \" The frame requesting access has a protocol of \\\"\" +\n           active_url.Protocol() +\n           \"\\\", the frame being accessed has a protocol of \\\"\" +\n           target_url.Protocol() + \"\\\". Protocols must match.\\n\";\n\n  if (target_origin->DomainWasSetInDOM() && active_origin->DomainWasSetInDOM())\n    return message +\n           \"The frame requesting access set \\\"document.domain\\\" to \\\"\" +\n           active_origin->Domain() +\n           \"\\\", the frame being accessed set it to \\\"\" +\n           target_origin->Domain() +\n           \"\\\". Both must set \\\"document.domain\\\" to the same value to allow \"\n           \"access.\";\n  if (active_origin->DomainWasSetInDOM())\n    return message +\n           \"The frame requesting access set \\\"document.domain\\\" to \\\"\" +\n           active_origin->Domain() +\n           \"\\\", but the frame being accessed did not. Both must set \"\n           \"\\\"document.domain\\\" to the same value to allow access.\";\n  if (target_origin->DomainWasSetInDOM())\n    return message + \"The frame being accessed set \\\"document.domain\\\" to \\\"\" +\n           target_origin->Domain() +\n           \"\\\", but the frame requesting access did not. Both must set \"\n           \"\\\"document.domain\\\" to the same value to allow access.\";\n\n  return message + \"Protocols, domains, and ports must match.\";\n}\n","target":0,"code_token_length":744,"total_token_length":980,"max_tokens_setting":1024}
+{"idx":344368,"func":"goa_http_client_check (GoaHttpClient       *client,\n                       const gchar         *uri,\n                       const gchar         *username,\n                       const gchar         *password,\n                       GCancellable        *cancellable,\n                       GAsyncReadyCallback  callback,\n                       gpointer             user_data)\n{\n  CheckData *data;\n  CheckAuthData *auth;\n  SoupLogger *logger;\n\n  g_return_if_fail (GOA_IS_HTTP_CLIENT (client));\n  g_return_if_fail (uri != NULL || uri[0] != '\\0');\n  g_return_if_fail (username != NULL || username[0] != '\\0');\n  g_return_if_fail (password != NULL || password[0] != '\\0');\n  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));\n\n  data = g_slice_new0 (CheckData);\n  data->res = g_simple_async_result_new (G_OBJECT (client), callback, user_data, goa_http_client_check);\n  data->session = soup_session_async_new_with_options (SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,\n                                                       NULL);\n  logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);\n  soup_logger_set_printer (logger, http_client_log_printer, NULL, NULL);\n  soup_session_add_feature (data->session, SOUP_SESSION_FEATURE (logger));\n  g_object_unref (logger);\n\n  data->msg = soup_message_new (SOUP_METHOD_GET, uri);\n  soup_message_headers_append (data->msg->request_headers, \"Connection\", \"close\");\n\n  if (cancellable != NULL)\n    {\n      data->cancellable = g_object_ref (cancellable);\n      data->cancellable_id = g_cancellable_connect (data->cancellable,\n                                                    G_CALLBACK (http_client_check_cancelled_cb),\n                                                    data,\n                                                    NULL);\n      g_simple_async_result_set_check_cancellable (data->res, data->cancellable);\n    }\n\n  auth = g_slice_new0 (CheckAuthData);\n  auth->username = g_strdup (username);\n  auth->password = g_strdup (password);\n  g_signal_connect_data (data->session,\n                         \"authenticate\",\n                         G_CALLBACK (http_client_authenticate),\n                         auth,\n                         http_client_check_auth_data_free,\n                         0);\n\n  soup_session_queue_message (data->session, data->msg, http_client_check_response_cb, data);\n}","target":1,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":496862,"func":"ReturnCode_t DataWriterImpl::check_qos(\n        const DataWriterQos& qos)\n{\n    if (qos.durability().kind == PERSISTENT_DURABILITY_QOS)\n    {\n        logError(RTPS_QOS_CHECK, \"PERSISTENT Durability not supported\");\n        return ReturnCode_t::RETCODE_UNSUPPORTED;\n    }\n    if (qos.destination_order().kind == BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS)\n    {\n        logError(RTPS_QOS_CHECK, \"BY SOURCE TIMESTAMP DestinationOrder not supported\");\n        return ReturnCode_t::RETCODE_UNSUPPORTED;\n    }\n    if (qos.reliability().kind == BEST_EFFORT_RELIABILITY_QOS && qos.ownership().kind == EXCLUSIVE_OWNERSHIP_QOS)\n    {\n        logError(RTPS_QOS_CHECK, \"BEST_EFFORT incompatible with EXCLUSIVE ownership\");\n        return ReturnCode_t::RETCODE_INCONSISTENT_POLICY;\n    }\n    if (qos.liveliness().kind == AUTOMATIC_LIVELINESS_QOS ||\n            qos.liveliness().kind == MANUAL_BY_PARTICIPANT_LIVELINESS_QOS)\n    {\n        if (qos.liveliness().lease_duration < eprosima::fastrtps::c_TimeInfinite &&\n                qos.liveliness().lease_duration <= qos.liveliness().announcement_period)\n        {\n            logError(RTPS_QOS_CHECK, \"WRITERQOS: LeaseDuration <= announcement period.\");\n            return ReturnCode_t::RETCODE_INCONSISTENT_POLICY;\n        }\n    }\n    return ReturnCode_t::RETCODE_OK;\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":409843,"func":"\nvoid sock_zerocopy_callback(struct ubuf_info *uarg, bool success)\n{\n\tstruct sk_buff *tail, *skb = skb_from_uarg(uarg);\n\tstruct sock_exterr_skb *serr;\n\tstruct sock *sk = skb->sk;\n\tstruct sk_buff_head *q;\n\tunsigned long flags;\n\tu32 lo, hi;\n\tu16 len;\n\n\tmm_unaccount_pinned_pages(&uarg->mmp);\n\n\t\/* if !len, there was only 1 call, and it was aborted\n\t * so do not queue a completion notification\n\t *\/\n\tif (!uarg->len || sock_flag(sk, SOCK_DEAD))\n\t\tgoto release;\n\n\tlen = uarg->len;\n\tlo = uarg->id;\n\thi = uarg->id + len - 1;\n\n\tserr = SKB_EXT_ERR(skb);\n\tmemset(serr, 0, sizeof(*serr));\n\tserr->ee.ee_errno = 0;\n\tserr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY;\n\tserr->ee.ee_data = hi;\n\tserr->ee.ee_info = lo;\n\tif (!success)\n\t\tserr->ee.ee_code |= SO_EE_CODE_ZEROCOPY_COPIED;\n\n\tq = &sk->sk_error_queue;\n\tspin_lock_irqsave(&q->lock, flags);\n\ttail = skb_peek_tail(q);\n\tif (!tail || SKB_EXT_ERR(tail)->ee.ee_origin != SO_EE_ORIGIN_ZEROCOPY ||\n\t    !skb_zerocopy_notify_extend(tail, lo, len)) {\n\t\t__skb_queue_tail(q, skb);\n\t\tskb = NULL;\n\t}\n\tspin_unlock_irqrestore(&q->lock, flags);\n\n\tsk->sk_error_report(sk);\n\nrelease:\n\tconsume_skb(skb);\n\tsock_put(sk);","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":506525,"func":"long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))\n\t{\n\tCERT *cert;\n\n\tcert=ctx->cert;\n\n\tswitch (cmd)\n\t\t{\n#ifndef OPENSSL_NO_RSA\n\tcase SSL_CTRL_SET_TMP_RSA_CB:\n\t\t{\n\t\tcert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;\n\t\t}\n\t\tbreak;\n#endif\n#ifndef OPENSSL_NO_DH\n\tcase SSL_CTRL_SET_TMP_DH_CB:\n\t\t{\n\t\tcert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;\n\t\t}\n\t\tbreak;\n#endif\n#ifndef OPENSSL_NO_ECDH\n\tcase SSL_CTRL_SET_TMP_ECDH_CB:\n\t\t{\n\t\tcert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;\n\t\t}\n\t\tbreak;\n#endif\n#ifndef OPENSSL_NO_TLSEXT\n\tcase SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:\n\t\tctx->tlsext_servername_callback=(int (*)(SSL *,int *,void *))fp;\n\t\tbreak;\n\n#ifdef TLSEXT_TYPE_opaque_prf_input\n\tcase SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB:\n\t\tctx->tlsext_opaque_prf_input_callback = (int (*)(SSL *,void *, size_t, void *))fp;\n\t\tbreak;\n#endif\n\n\tcase SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:\n\t\tctx->tlsext_status_cb=(int (*)(SSL *,void *))fp;\n\t\tbreak;\n\n\tcase SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:\n\t\tctx->tlsext_ticket_key_cb=(int (*)(SSL *,unsigned char  *,\n\t\t\t\t\t\tunsigned char *,\n\t\t\t\t\t\tEVP_CIPHER_CTX *,\n\t\t\t\t\t\tHMAC_CTX *, int))fp;\n\t\tbreak;\n\n#ifndef OPENSSL_NO_SRP\n\tcase SSL_CTRL_SET_SRP_VERIFY_PARAM_CB:\n\t\tctx->srp_ctx.srp_Mask|=SSL_kSRP;\n\t\tctx->srp_ctx.SRP_verify_param_callback=(int (*)(SSL *,void *))fp;\n\t\tbreak;\n\tcase SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB:\n\t\tctx->srp_ctx.srp_Mask|=SSL_kSRP;\n\t\tctx->srp_ctx.TLS_ext_srp_username_callback=(int (*)(SSL *,int *,void *))fp;\n\t\tbreak;\n\tcase SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB:\n\t\tctx->srp_ctx.srp_Mask|=SSL_kSRP;\n\t\tctx->srp_ctx.SRP_give_srp_client_pwd_callback=(char *(*)(SSL *,void *))fp;\n\t\tbreak;\n\tcase SSL_CTRL_SET_TLS_EXT_SRP_MISSING_CLIENT_USERNAME_CB:\n\t\tctx->srp_ctx.srp_Mask|=SSL_kSRP;\n\t\tctx->srp_ctx.SRP_TLS_ext_missing_srp_client_username_callback=(char *(*)(SSL *,void *))fp;\n\t\tbreak;\n#endif\n#endif\n\tcase SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:\n\t\t{\n\t\tctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\treturn(0);\n\t\t}\n\treturn(1);\n\t}","target":0,"code_token_length":656,"total_token_length":892,"max_tokens_setting":1024}
+{"idx":513322,"func":"CallRewrite(y, xs, xe, doit)\nint y, xs, xe, doit;\n{\n  struct canvas *cv, *cvlist, *cvlnext;\n  struct viewport *vp;\n  struct layer *oldflayer;\n  int cost;\n\n  debug3(\"CallRewrite %d %d %d\\n\", y, xs, xe);\n  ASSERT(display);\n  ASSERT(xe >= xs);\n\n  vp = 0;\n  for (cv = D_cvlist; cv; cv = cv->c_next)\n    {\n      if (y < cv->c_ys || y > cv->c_ye || xe < cv->c_xs || xs > cv->c_xe)\n\tcontinue;\n      for (vp = cv->c_vplist; vp; vp = vp->v_next)\n\tif (y >= vp->v_ys && y <= vp->v_ye && xe >= vp->v_xs && xs <= vp->v_xe)\n\t  break;\n      if (vp)\n\tbreak;\n    }\n  if (doit)\n    {\n      oldflayer = flayer;\n      flayer = cv->c_layer;\n      cvlist = flayer->l_cvlist;\n      cvlnext = cv->c_lnext;\n      flayer->l_cvlist = cv;\n      cv->c_lnext = 0;\n      LayRewrite(y - vp->v_yoff, xs - vp->v_xoff, xe - vp->v_xoff, &D_rend, 1);\n      flayer->l_cvlist = cvlist;\n      cv->c_lnext = cvlnext;\n      flayer = oldflayer;\n      return 0;\n    }\n  if (cv == 0 || cv->c_layer == 0)\n    return EXPENSIVE;\t\/* not found or nothing on it *\/\n  if (xs < vp->v_xs || xe > vp->v_xe)\n    return EXPENSIVE;\t\/* crosses viewport boundaries *\/\n  if (y - vp->v_yoff < 0 || y - vp->v_yoff >= cv->c_layer->l_height)\n    return EXPENSIVE;\t\/* line not on layer *\/\n  if (xs - vp->v_xoff < 0 || xe - vp->v_xoff >= cv->c_layer->l_width)\n    return EXPENSIVE;\t\/* line not on layer *\/\n#ifdef UTF8\n  if (D_encoding == UTF8)\n    D_rend.font = 0;\n#endif\n  oldflayer = flayer;\n  flayer = cv->c_layer;\n  debug3(\"Calling Rewrite %d %d %d\\n\", y - vp->v_yoff, xs - vp->v_xoff, xe - vp->v_xoff);\n  cost = LayRewrite(y - vp->v_yoff, xs - vp->v_xoff, xe - vp->v_xoff, &D_rend, 0);\n  flayer = oldflayer;\n  if (D_insert)\n    cost += D_EIcost + D_IMcost;\n  return cost;\n}","target":0,"code_token_length":648,"total_token_length":884,"max_tokens_setting":1024}
+{"idx":268318,"func":"int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error) \/* {{{ *\/\n{\n\tphar_entry_info *link;\n\n\tif (FAILURE == phar_open_entry_fp(source, error, 1)) {\n\t\treturn FAILURE;\n\t}\n\n\tif (dest->link) {\n\t\tefree(dest->link);\n\t\tdest->link = NULL;\n\t\tdest->tar_type = (dest->is_tar ? TAR_FILE : '\\0');\n\t}\n\n\tdest->fp_type = PHAR_MOD;\n\tdest->offset = 0;\n\tdest->is_modified = 1;\n\tdest->fp = php_stream_fopen_tmpfile();\n\tif (dest->fp == NULL) {\n\t\tspprintf(error, 0, \"phar error: unable to create temporary file\");\n\t\treturn EOF;\n\t}\n\tphar_seek_efp(source, 0, SEEK_SET, 0, 1);\n\tlink = phar_get_link_source(source);\n\n\tif (!link) {\n\t\tlink = source;\n\t}\n\n\tif (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), dest->fp, link->uncompressed_filesize, NULL)) {\n\t\tphp_stream_close(dest->fp);\n\t\tdest->fp_type = PHAR_FP;\n\t\tif (error) {\n\t\t\tspprintf(error, 4096, \"phar error: unable to copy contents of file \\\"%s\\\" to \\\"%s\\\" in phar archive \\\"%s\\\"\", source->filename, dest->filename, source->phar->fname);\n\t\t}\n\t\treturn FAILURE;\n\t}\n\n\treturn SUCCESS;\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":116348,"func":"findtags_in_help_init(findtags_state_T *st)\n{\n    int\t\ti;\n    char_u\t*s;\n\n    \/\/ Keep 'en' as the language if the file extension is '.txt'\n    if (st->is_txt)\n\tSTRCPY(st->help_lang, \"en\");\n    else\n    {\n\t\/\/ Prefer help tags according to 'helplang'.  Put the two-letter\n\t\/\/ language name in help_lang[].\n\ti = (int)STRLEN(st->tag_fname);\n\tif (i > 3 && st->tag_fname[i - 3] == '-')\n\t    vim_strncpy(st->help_lang, st->tag_fname + i - 2, 2);\n\telse\n\t    STRCPY(st->help_lang, \"en\");\n    }\n    \/\/ When searching for a specific language skip tags files for other\n    \/\/ languages.\n    if (st->help_lang_find != NULL\n\t    && STRICMP(st->help_lang, st->help_lang_find) != 0)\n\treturn FALSE;\n\n    \/\/ For CTRL-] in a help file prefer a match with the same language.\n    if ((st->flags & TAG_KEEP_LANG)\n\t    && st->help_lang_find == NULL\n\t    && curbuf->b_fname != NULL\n\t    && (i = (int)STRLEN(curbuf->b_fname)) > 4\n\t    && curbuf->b_fname[i - 1] == 'x'\n\t    && curbuf->b_fname[i - 4] == '.'\n\t    && STRNICMP(curbuf->b_fname + i - 3, st->help_lang, 2) == 0)\n\tst->help_pri = 0;\n    else\n    {\n\t\/\/ search for the language in 'helplang'\n\tst->help_pri = 1;\n\tfor (s = p_hlg; *s != NUL; ++s)\n\t{\n\t    if (STRNICMP(s, st->help_lang, 2) == 0)\n\t\tbreak;\n\t    ++st->help_pri;\n\t    if ((s = vim_strchr(s, ',')) == NULL)\n\t\tbreak;\n\t}\n\tif (s == NULL || *s == NUL)\n\t{\n\t    \/\/ Language not in 'helplang': use last, prefer English, unless\n\t    \/\/ found already.\n\t    ++st->help_pri;\n\t    if (STRICMP(st->help_lang, \"en\") != 0)\n\t\t++st->help_pri;\n\t}\n    }\n\n    return TRUE;\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":128328,"func":"TEST_F(SecretManagerImplTest, ConfigDumpHandlerStaticValidationContext) {\n  Server::MockInstance server;\n  auto secret_manager = std::make_unique<SecretManagerImpl>(config_tracker_);\n  time_system_.setSystemTime(std::chrono::milliseconds(1234567891234));\n  NiceMock<Server::Configuration::MockTransportSocketFactoryContext> secret_context;\n  envoy::config::core::v3::ConfigSource config_source;\n  NiceMock<LocalInfo::MockLocalInfo> local_info;\n  NiceMock<Event::MockDispatcher> dispatcher;\n  NiceMock<Random::MockRandomGenerator> random;\n  Stats::IsolatedStoreImpl stats;\n  NiceMock<Init::MockManager> init_manager;\n  NiceMock<Init::ExpectableWatcherImpl> init_watcher;\n  Init::TargetHandlePtr init_target_handle;\n  EXPECT_CALL(init_manager, add(_))\n      .WillRepeatedly(Invoke([&init_target_handle](const Init::Target& target) {\n        init_target_handle = target.createHandle(\"test\");\n      }));\n  EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats));\n  EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager));\n  EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher));\n  EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info));\n\n  const std::string validation_context =\n      R\"EOF(\nname: \"abc.com.validation\"\nvalidation_context:\n  trusted_ca:\n    inline_string: \"DUMMY_INLINE_STRING_TRUSTED_CA\"\n)EOF\";\n  envoy::extensions::transport_sockets::tls::v3::Secret validation_secret;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(validation_context), validation_secret);\n  secret_manager->addStaticSecret(validation_secret);\n  const std::string expected_config_dump = R\"EOF(\nstatic_secrets:\n- name: \"abc.com.validation\"\n  secret:\n    \"@type\": type.googleapis.com\/envoy.extensions.transport_sockets.tls.v3.Secret\n    name: \"abc.com.validation\"\n    validation_context:\n      trusted_ca:\n        inline_string: \"DUMMY_INLINE_STRING_TRUSTED_CA\"\n)EOF\";\n  checkConfigDump(expected_config_dump);\n  StrictMock<MockStringMatcher> mock_matcher;\n  EXPECT_CALL(mock_matcher, match(\"abc.com.validation\")).WillOnce(Return(false));\n  checkConfigDump(\"{}\", mock_matcher);\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":345148,"func":"PHP_FUNCTION(chmod)\n{\n\tchar *filename;\n\tint filename_len;\n\tlong mode;\n\tint ret;\n\tmode_t imode;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"sl\", &filename, &filename_len, &mode) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (PG(safe_mode) &&(!php_checkuid(filename, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS))) {\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* Check the basedir *\/\n\tif (php_check_open_basedir(filename TSRMLS_CC)) {\n\t\tRETURN_FALSE;\n\t}\n\n\timode = (mode_t) mode;\n\t\/* In safe mode, do not allow to setuid files.\n\t * Setuiding files could allow users to gain privileges\n\t * that safe mode doesn't give them. *\/\n\n\tif (PG(safe_mode)) {\n\t\tphp_stream_statbuf ssb;\n\t\tif (php_stream_stat_path_ex(filename, 0, &ssb, NULL)) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"stat failed for %s\", filename);\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\tif ((imode & 04000) != 0 && (ssb.sb.st_mode & 04000) == 0) {\n\t\t\timode ^= 04000;\n\t\t}\n\t\tif ((imode & 02000) != 0 && (ssb.sb.st_mode & 02000) == 0) {\n\t\t\timode ^= 02000;\n\t\t}\n\t\tif ((imode & 01000) != 0 && (ssb.sb.st_mode & 01000) == 0) {\n\t\t\timode ^= 01000;\n\t\t}\n\t}\n\n\tret = VCWD_CHMOD(filename, imode);\n\tif (ret == -1) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"%s\", strerror(errno));\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_TRUE;\n}","target":1,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":382981,"func":"build_enter_admin_pin_prompt (app_t app, char **r_prompt)\n{\n  void *relptr;\n  unsigned char *value;\n  size_t valuelen;\n  int remaining;\n  char *prompt;\n\n  *r_prompt = NULL;\n\n  relptr = get_one_do (app, 0x00C4, &value, &valuelen, NULL);\n  if (!relptr || valuelen < 7)\n    {\n      log_error (_(\"error retrieving CHV status from card\\n\"));\n      xfree (relptr);\n      return gpg_error (GPG_ERR_CARD);\n    }\n  if (value[6] == 0)\n    {\n      log_info (_(\"card is permanently locked!\\n\"));\n      xfree (relptr);\n      return gpg_error (GPG_ERR_BAD_PIN);\n    }\n  remaining = value[6];\n  xfree (relptr);\n\n  log_info(_(\"%d Admin PIN attempts remaining before card\"\n             \" is permanently locked\\n\"), remaining);\n\n  if (remaining < 3)\n    {\n      \/* TRANSLATORS: Do not translate the \"|A|\" prefix but keep it at\n         the start of the string.  Use %%0A to force a linefeed.  *\/\n      prompt = xtryasprintf (_(\"|A|Please enter the Admin PIN%%0A\"\n                               \"[remaining attempts: %d]\"), remaining);\n    }\n  else\n    prompt = xtrystrdup (_(\"|A|Please enter the Admin PIN\"));\n\n  if (!prompt)\n    return gpg_error_from_syserror ();\n\n  *r_prompt = prompt;\n  return 0;\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":435112,"func":"psutil_proc_memory_info(PyObject *self, PyObject *args) {\n    HANDLE hProcess;\n    DWORD pid;\n#if (_WIN32_WINNT >= 0x0501)  \/\/ Windows XP with SP2\n    PROCESS_MEMORY_COUNTERS_EX cnt;\n#else\n    PROCESS_MEMORY_COUNTERS cnt;\n#endif\n    SIZE_T private = 0;\n\n    if (! PyArg_ParseTuple(args, \"l\", &pid))\n        return NULL;\n\n    hProcess = psutil_handle_from_pid(pid, PROCESS_QUERY_LIMITED_INFORMATION);\n    if (NULL == hProcess)\n        return NULL;\n\n    if (! GetProcessMemoryInfo(hProcess, (PPROCESS_MEMORY_COUNTERS)&cnt,\n                               sizeof(cnt))) {\n        PyErr_SetFromWindowsErr(0);\n        CloseHandle(hProcess);\n        return NULL;\n    }\n\n#if (_WIN32_WINNT >= 0x0501)  \/\/ Windows XP with SP2\n    private = cnt.PrivateUsage;\n#endif\n\n    CloseHandle(hProcess);\n\n    \/\/ PROCESS_MEMORY_COUNTERS values are defined as SIZE_T which on 64bits\n    \/\/ is an (unsigned long long) and on 32bits is an (unsigned int).\n    \/\/ \"_WIN64\" is defined if we're running a 64bit Python interpreter not\n    \/\/ exclusively if the *system* is 64bit.\n#if defined(_WIN64)\n    return Py_BuildValue(\n        \"(kKKKKKKKKK)\",\n        cnt.PageFaultCount,  \/\/ unsigned long\n        (unsigned long long)cnt.PeakWorkingSetSize,\n        (unsigned long long)cnt.WorkingSetSize,\n        (unsigned long long)cnt.QuotaPeakPagedPoolUsage,\n        (unsigned long long)cnt.QuotaPagedPoolUsage,\n        (unsigned long long)cnt.QuotaPeakNonPagedPoolUsage,\n        (unsigned long long)cnt.QuotaNonPagedPoolUsage,\n        (unsigned long long)cnt.PagefileUsage,\n        (unsigned long long)cnt.PeakPagefileUsage,\n        (unsigned long long)private);\n#else\n    return Py_BuildValue(\n        \"(kIIIIIIIII)\",\n        cnt.PageFaultCount,    \/\/ unsigned long\n        (unsigned int)cnt.PeakWorkingSetSize,\n        (unsigned int)cnt.WorkingSetSize,\n        (unsigned int)cnt.QuotaPeakPagedPoolUsage,\n        (unsigned int)cnt.QuotaPagedPoolUsage,\n        (unsigned int)cnt.QuotaPeakNonPagedPoolUsage,\n        (unsigned int)cnt.QuotaNonPagedPoolUsage,\n        (unsigned int)cnt.PagefileUsage,\n        (unsigned int)cnt.PeakPagefileUsage,\n        (unsigned int)private);\n#endif\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":44311,"func":"static void unpack_14(const uint8_t b[14], uint16_t s[16])\n{\n    unsigned short shift = (b[ 2] >> 2) & 15;\n    unsigned short bias = (0x20 << shift);\n    int i;\n\n    s[ 0] = (b[0] << 8) | b[1];\n\n    s[ 4] = s[ 0] + ((((b[ 2] << 4) | (b[ 3] >> 4)) & 0x3f) << shift) - bias;\n    s[ 8] = s[ 4] + ((((b[ 3] << 2) | (b[ 4] >> 6)) & 0x3f) << shift) - bias;\n    s[12] = s[ 8] +   ((b[ 4]                       & 0x3f) << shift) - bias;\n\n    s[ 1] = s[ 0] +   ((b[ 5] >> 2)                         << shift) - bias;\n    s[ 5] = s[ 4] + ((((b[ 5] << 4) | (b[ 6] >> 4)) & 0x3f) << shift) - bias;\n    s[ 9] = s[ 8] + ((((b[ 6] << 2) | (b[ 7] >> 6)) & 0x3f) << shift) - bias;\n    s[13] = s[12] +   ((b[ 7]                       & 0x3f) << shift) - bias;\n\n    s[ 2] = s[ 1] +   ((b[ 8] >> 2)                         << shift) - bias;\n    s[ 6] = s[ 5] + ((((b[ 8] << 4) | (b[ 9] >> 4)) & 0x3f) << shift) - bias;\n    s[10] = s[ 9] + ((((b[ 9] << 2) | (b[10] >> 6)) & 0x3f) << shift) - bias;\n    s[14] = s[13] +   ((b[10]                       & 0x3f) << shift) - bias;\n\n    s[ 3] = s[ 2] +   ((b[11] >> 2)                         << shift) - bias;\n    s[ 7] = s[ 6] + ((((b[11] << 4) | (b[12] >> 4)) & 0x3f) << shift) - bias;\n    s[11] = s[10] + ((((b[12] << 2) | (b[13] >> 6)) & 0x3f) << shift) - bias;\n    s[15] = s[14] +   ((b[13]                       & 0x3f) << shift) - bias;\n\n    for (i = 0; i < 16; ++i) {\n        if (s[i] & 0x8000)\n            s[i] &= 0x7fff;\n        else\n            s[i] = ~s[i];\n    }\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":14299,"func":"uint64_t esp_reg_read(ESPState *s, uint32_t saddr)\n{\n    uint32_t old_val;\n\n     trace_esp_mem_readb(saddr, s->rregs[saddr]);\n     switch (saddr) {\n     case ESP_FIFO:\n        if (s->ti_size > 0) {\n             s->ti_size--;\n            if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {\n                \/* Data out.  *\/\n                qemu_log_mask(LOG_UNIMP,\n                              \"esp: PIO data read not implemented\\n\");\n                s->rregs[ESP_FIFO] = 0;\n            } else {\n                s->rregs[ESP_FIFO] = s->ti_buf[s->ti_rptr++];\n            }\n             esp_raise_irq(s);\n         }\n        if (s->ti_size == 0) {\n             s->ti_rptr = 0;\n             s->ti_wptr = 0;\n         }\n            s->ti_wptr = 0;\n        }\n        break;\n    case ESP_RINTR:\n        \/* Clear sequence step, interrupt register and all status bits\n           except TC *\/\n        old_val = s->rregs[ESP_RINTR];\n        s->rregs[ESP_RINTR] = 0;\n        s->rregs[ESP_RSTAT] &= ~STAT_TC;\n        s->rregs[ESP_RSEQ] = SEQ_CD;\n        esp_lower_irq(s);\n\n        return old_val;\n    case ESP_TCHI:\n        \/* Return the unique id if the value has never been written *\/\n        if (!s->tchi_written) {\n            return s->chip_id;\n        }\n    default:\n        break;\n    }\n","target":1,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":397026,"func":"wc_ucs_to_any(wc_uint32 ucs, wc_table *t)\n{\n    wc_wchar_t cc;\n    wc_map *map;\n\n    if (t && t->map && ucs && ucs <= WC_C_UCS2_END) {\n\tmap = wc_map_search((wc_uint16)ucs, t->map, t->n);\n\tif (map)\n\t    return t->conv(t->ccs, map->code2);\n    }\n    if (t && (ucs & ~0xFFFF) == WC_C_UCS4_PLANE2) {\n\tif (t->ccs == WC_CCS_JIS_X_0213_1)\n\t    map = wc_map_search((wc_uint16)(ucs & 0xffff),\n\t\tucs_p2_jisx02131_map, N_ucs_p2_jisx02131_map);\n\telse if (t->ccs == WC_CCS_JIS_X_0213_2)\n\t    map = wc_map_search((wc_uint16)(ucs & 0xffff),\n\t\tucs_p2_jisx02132_map, N_ucs_p2_jisx02132_map);\n\telse if (t->ccs == WC_CCS_HKSCS ||\n\t\t t->ccs == WC_CCS_HKSCS_1 || t->ccs == WC_CCS_HKSCS_2)\n\t    map = wc_map_search((wc_uint16)(ucs & 0xffff),\n\t\tucs_p2_hkscs_map, N_ucs_p2_hkscs_map);\n\telse\n\t    map = NULL;\n\tif (map)\n\t    return t->conv(t->ccs, map->code2);\n    }\n    cc.ccs = WC_CCS_UNKNOWN;\n    cc.code = 0;\n    return cc;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":128184,"func":"GF_Err moov_on_child_box(GF_Box *s, GF_Box *a)\n{\n\tGF_MovieBox *ptr = (GF_MovieBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_IODS:\n\t\tif (ptr->iods) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->iods = (GF_ObjectDescriptorBox *)a;\n\t\t\/\/if no IOD, delete the box\n\t\tif (!ptr->iods->descriptor) {\n\t\t\tptr->iods = NULL;\n\t\t\tgf_isom_box_del_parent(&s->child_boxes, a);\n\t\t}\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_MVHD:\n\t\tif (ptr->mvhd) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->mvhd = (GF_MovieHeaderBox *)a;\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_UDTA:\n\t\tif (ptr->udta) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->udta = (GF_UserDataBox *)a;\n\t\treturn GF_OK;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\tcase GF_ISOM_BOX_TYPE_MVEX:\n\t\tif (ptr->mvex) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->mvex = (GF_MovieExtendsBox *)a;\n\t\tptr->mvex->mov = ptr->mov;\n\t\treturn GF_OK;\n#endif\n\n\tcase GF_ISOM_BOX_TYPE_META:\n\t\tif (ptr->meta) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\tptr->meta = (GF_MetaBox *)a;\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_TRAK:\n\t\t\/\/set our pointer to this obj\n\t\t((GF_TrackBox *)a)->moov = ptr;\n\t\treturn gf_list_add(ptr->trackList, a);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":379783,"func":"static int ZEND_FASTCALL  ZEND_FETCH_OBJ_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op1, free_op2, free_res;\n\tzval **container = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);\n\tzval *property = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);\n\n\tif (IS_VAR == IS_CV) {\n\t\tif (container != &EG(uninitialized_zval_ptr)) {\n\t\t\tSEPARATE_ZVAL_IF_NOT_REF(container);\n\t\t}\n\t}\n\tif (1) {\n\t\tMAKE_REAL_ZVAL_PTR(property);\n\t}\n\tif (IS_VAR == IS_VAR && !container) {\n\t\tzend_error_noreturn(E_ERROR, \"Cannot use string offset as an object\");\n\t}\n\tzend_fetch_property_address(&EX_T(opline->result.u.var), container, property, BP_VAR_UNSET TSRMLS_CC);\n\tif (1) {\n\t\tzval_ptr_dtor(&property);\n\t} else {\n\t\tzval_dtor(free_op2.var);\n\t}\n\tif (IS_VAR == IS_VAR && (free_op1.var != NULL) &&\n\t    READY_TO_DESTROY(free_op1.var)) {\n\t\tAI_USE_PTR(EX_T(opline->result.u.var).var);\n\t\tif (!PZVAL_IS_REF(*EX_T(opline->result.u.var).var.ptr_ptr) &&\n\t\t    Z_REFCOUNT_PP(EX_T(opline->result.u.var).var.ptr_ptr) > 2) {\n\t\t\tSEPARATE_ZVAL(EX_T(opline->result.u.var).var.ptr_ptr);\n\t\t}\n\t}\n\tif (free_op1.var) {zval_ptr_dtor(&free_op1.var);};\n\n\tPZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res);\n\tif (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) {\n\t\tSEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr);\n\t}\n\tPZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr);\n\tFREE_OP_VAR_PTR(free_res);\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":315891,"func":"check_data_region (struct tar_sparse_file *file, size_t i)\n{\n  off_t size_left;\n\n  if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))\n    return false;\n  size_left = file->stat_info->sparse_map[i].numbytes;\n  mv_size_left (file->stat_info->archive_file_size - file->dumped_size);\n\n  while (size_left > 0)\n    {\n      size_t bytes_read;\n      size_t rdsize = (size_left > BLOCKSIZE) ? BLOCKSIZE : size_left;\n      char diff_buffer[BLOCKSIZE];\n\n      union block *blk = find_next_block ();\n      if (!blk)\n\t{\n\t  ERROR ((0, 0, _(\"Unexpected EOF in archive\")));\n\t  return false;\n\t}\n      set_next_block_after (blk);\n      file->dumped_size += BLOCKSIZE;      \n      bytes_read = safe_read (file->fd, diff_buffer, rdsize);\n      if (bytes_read == SAFE_READ_ERROR)\n\t{\n          read_diag_details (file->stat_info->orig_file_name,\n\t\t\t     (file->stat_info->sparse_map[i].offset\n\t\t\t      + file->stat_info->sparse_map[i].numbytes\n\t\t\t      - size_left),\n\t\t\t     rdsize);\n\t  return false;\n\t}\n      else if (bytes_read == 0)\n\t{\n\t  report_difference (¤t_stat_info, _(\"Size differs\"));\n\t  return false;\n\t}\n      size_left -= bytes_read;\n      mv_size_left (file->stat_info->archive_file_size - file->dumped_size);\n      if (memcmp (blk->buffer, diff_buffer, rdsize))\n\t{\n\t  report_difference (file->stat_info, _(\"Contents differ\"));\n\t  return false;\n\t}\n    }\n  return true;\n}\n","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":421523,"func":"process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, RD_BOOL delta)\n{\n\tint index, next, data;\n\tuint8 flags = 0;\n\tPEN pen;\n\tRD_POINT *points;\n\n\tif (present & 0x01)\n\t\trdp_in_coord(s, &os->x, delta);\n\n\tif (present & 0x02)\n\t\trdp_in_coord(s, &os->y, delta);\n\n\tif (present & 0x04)\n\t\tin_uint8(s, os->opcode);\n\n\tif (present & 0x10)\n\t\trdp_in_colour(s, &os->fgcolour);\n\n\tif (present & 0x20)\n\t\tin_uint8(s, os->lines);\n\n\tif (present & 0x40)\n\t{\n\t\tin_uint8(s, os->datasize);\n\t\tin_uint8a(s, os->data, os->datasize);\n\t}\n\n\tDEBUG((\"POLYLINE(x=%d,y=%d,op=0x%x,fg=0x%x,n=%d,sz=%d)\\n\",\n\t       os->x, os->y, os->opcode, os->fgcolour, os->lines, os->datasize));\n\n\tDEBUG((\"Data: \"));\n\n\tfor (index = 0; index < os->datasize; index++)\n\t\tDEBUG((\"%02x \", os->data[index]));\n\n\tDEBUG((\"\\n\"));\n\n\tif (os->opcode < 0x01 || os->opcode > 0x10)\n\t{\n\t\terror(\"bad ROP2 0x%x\\n\", os->opcode);\n\t\treturn;\n\t}\n\n\tpoints = (RD_POINT *) xmalloc((os->lines + 1) * sizeof(RD_POINT));\n\tmemset(points, 0, (os->lines + 1) * sizeof(RD_POINT));\n\n\tpoints[0].x = os->x;\n\tpoints[0].y = os->y;\n\tpen.style = pen.width = 0;\n\tpen.colour = os->fgcolour;\n\n\tindex = 0;\n\tdata = ((os->lines - 1) \/ 4) + 1;\n\tfor (next = 1; (next <= os->lines) && (data < os->datasize); next++)\n\t{\n\t\tif ((next - 1) % 4 == 0)\n\t\t\tflags = os->data[index++];\n\n\t\tif (~flags & 0x80)\n\t\t\tpoints[next].x = parse_delta(os->data, &data);\n\n\t\tif (~flags & 0x40)\n\t\t\tpoints[next].y = parse_delta(os->data, &data);\n\n\t\tflags <<= 2;\n\t}\n\n\tif (next - 1 == os->lines)\n\t\tui_polyline(os->opcode - 1, points, os->lines + 1, &pen);\n\telse\n\t\terror(\"polyline parse error\\n\");\n\n\txfree(points);\n}","target":0,"code_token_length":613,"total_token_length":849,"max_tokens_setting":1024}
+{"idx":164045,"func":"static void cmd_sort(char *tag, int usinguid)\n{\n    int c;\n    struct sortcrit *sortcrit = NULL;\n    struct searchargs *searchargs = NULL;\n    clock_t start = clock();\n    char mytime[100];\n    int n;\n\n    if (backend_current) {\n        \/* remote mailbox *\/\n        const char *cmd = usinguid ? \"UID Sort\" : \"Sort\";\n\n        prot_printf(backend_current->out, \"%s %s \", tag, cmd);\n        if (!pipe_command(backend_current, 65536)) {\n            pipe_including_tag(backend_current, tag, 0);\n        }\n        return;\n    }\n\n    \/* local mailbox *\/\n    c = getsortcriteria(tag, &sortcrit);\n    if (c == EOF) goto error;\n\n    searchargs = new_searchargs(tag, GETSEARCH_CHARSET_FIRST,\n                                &imapd_namespace, imapd_userid, imapd_authstate,\n                                imapd_userisadmin || imapd_userisproxyadmin);\n    if (imapd_id.quirks & QUIRK_SEARCHFUZZY)\n        searchargs->fuzzy_depth++;\n    c = get_search_program(imapd_in, imapd_out, searchargs);\n    if (c == EOF) goto error;\n\n    if (c == '\\r') c = prot_getc(imapd_in);\n    if (c != '\\n') {\n        prot_printf(imapd_out,\n                    \"%s BAD Unexpected extra arguments to Sort\\r\\n\", tag);\n        goto error;\n    }\n\n    n = index_sort(imapd_index, sortcrit, searchargs, usinguid);\n    snprintf(mytime, sizeof(mytime), \"%2.3f\",\n             (clock() - start) \/ (double) CLOCKS_PER_SEC);\n    if (CONFIG_TIMING_VERBOSE) {\n        char *s = sortcrit_as_string(sortcrit);\n        syslog(LOG_DEBUG, \"SORT (%s) processing time: %d msg in %s sec\",\n               s, n, mytime);\n        free(s);\n    }\n    prot_printf(imapd_out, \"%s OK %s (%d msgs in %s secs)\\r\\n\", tag,\n                error_message(IMAP_OK_COMPLETED), n, mytime);\n\n    freesortcrit(sortcrit);\n    freesearchargs(searchargs);\n    return;\n\nerror:\n    eatline(imapd_in, (c == EOF ? ' ' : c));\n    freesortcrit(sortcrit);\n    freesearchargs(searchargs);\n}\n","target":0,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":473779,"func":"static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,\n\t\t\t\t       struct ieee80211_channel *channel,\n\t\t\t\t       struct ieee80211_mgmt *mgmt,\n\t\t\t\t       const u8 *country_ie, u8 country_ie_len,\n\t\t\t\t       const u8 *pwr_constr_ie,\n\t\t\t\t       const u8 *cisco_dtpc_ie)\n{\n\tbool has_80211h_pwr = false, has_cisco_pwr = false;\n\tint chan_pwr = 0, pwr_reduction_80211h = 0;\n\tint pwr_level_cisco, pwr_level_80211h;\n\tint new_ap_level;\n\t__le16 capab = mgmt->u.probe_resp.capab_info;\n\n\tif (country_ie &&\n\t    (capab & cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT) ||\n\t     capab & cpu_to_le16(WLAN_CAPABILITY_RADIO_MEASURE))) {\n\t\thas_80211h_pwr = ieee80211_find_80211h_pwr_constr(\n\t\t\tsdata, channel, country_ie, country_ie_len,\n\t\t\tpwr_constr_ie, &chan_pwr, &pwr_reduction_80211h);\n\t\tpwr_level_80211h =\n\t\t\tmax_t(int, 0, chan_pwr - pwr_reduction_80211h);\n\t}\n\n\tif (cisco_dtpc_ie) {\n\t\tieee80211_find_cisco_dtpc(\n\t\t\tsdata, channel, cisco_dtpc_ie, &pwr_level_cisco);\n\t\thas_cisco_pwr = true;\n\t}\n\n\tif (!has_80211h_pwr && !has_cisco_pwr)\n\t\treturn 0;\n\n\t\/* If we have both 802.11h and Cisco DTPC, apply both limits\n\t * by picking the smallest of the two power levels advertised.\n\t *\/\n\tif (has_80211h_pwr &&\n\t    (!has_cisco_pwr || pwr_level_80211h <= pwr_level_cisco)) {\n\t\tnew_ap_level = pwr_level_80211h;\n\n\t\tif (sdata->ap_power_level == new_ap_level)\n\t\t\treturn 0;\n\n\t\tsdata_dbg(sdata,\n\t\t\t  \"Limiting TX power to %d (%d - %d) dBm as advertised by %pM\\n\",\n\t\t\t  pwr_level_80211h, chan_pwr, pwr_reduction_80211h,\n\t\t\t  sdata->u.mgd.bssid);\n\t} else {  \/* has_cisco_pwr is always true here. *\/\n\t\tnew_ap_level = pwr_level_cisco;\n\n\t\tif (sdata->ap_power_level == new_ap_level)\n\t\t\treturn 0;\n\n\t\tsdata_dbg(sdata,\n\t\t\t  \"Limiting TX power to %d dBm as advertised by %pM\\n\",\n\t\t\t  pwr_level_cisco, sdata->u.mgd.bssid);\n\t}\n\n\tsdata->ap_power_level = new_ap_level;\n\tif (__ieee80211_recalc_txpower(sdata))\n\t\treturn BSS_CHANGED_TXPOWER;\n\treturn 0;\n}","target":0,"code_token_length":721,"total_token_length":957,"max_tokens_setting":1024}
+{"idx":90416,"func":"static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)\n{\n\tpvc_device *pvc = dev->ml_priv;\n\n\tif (pvc->state.active) {\n\t\tif (dev->type == ARPHRD_ETHER) {\n\t\t\tint pad = ETH_ZLEN - skb->len;\n\t\t\tif (pad > 0) { \/* Pad the frame with zeros *\/\n\t\t\t\tint len = skb->len;\n\t\t\t\tif (skb_tailroom(skb) < pad)\n\t\t\t\t\tif (pskb_expand_head(skb, 0, pad,\n\t\t\t\t\t\t\t     GFP_ATOMIC)) {\n\t\t\t\t\t\tdev->stats.tx_dropped++;\n\t\t\t\t\t\tdev_kfree_skb(skb);\n\t\t\t\t\t\treturn NETDEV_TX_OK;\n\t\t\t\t\t}\n\t\t\t\tskb_put(skb, pad);\n\t\t\t\tmemset(skb->data + len, 0, pad);\n\t\t\t}\n\t\t\tskb->protocol = cpu_to_be16(ETH_P_802_3);\n\t\t}\n\t\tif (!fr_hard_header(&skb, pvc->dlci)) {\n\t\t\tdev->stats.tx_bytes += skb->len;\n\t\t\tdev->stats.tx_packets++;\n\t\t\tif (pvc->state.fecn) \/* TX Congestion counter *\/\n\t\t\t\tdev->stats.tx_compressed++;\n\t\t\tskb->dev = pvc->frad;\n\t\t\tdev_queue_xmit(skb);\n\t\t\treturn NETDEV_TX_OK;\n\t\t}\n\t}\n\n\tdev->stats.tx_dropped++;\n\tdev_kfree_skb(skb);\n\treturn NETDEV_TX_OK;\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":261881,"func":"_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)\n{\n    log_debug(\"Message stanza handler fired\");\n\n    char *text;\n    size_t text_size;\n    xmpp_stanza_to_text(stanza, &text, &text_size);\n    gboolean cont = plugins_on_message_stanza_receive(text);\n    xmpp_free(connection_get_ctx(), text);\n    if (!cont) {\n        return 1;\n    }\n\n    const char *type = xmpp_stanza_get_type(stanza);\n\n    if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {\n        _handle_error(stanza);\n    }\n\n    if (g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0) {\n        _handle_groupchat(stanza);\n    }\n\n    xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);\n    if (mucuser) {\n        _handel_muc_user(stanza);\n    }\n\n    xmpp_stanza_t *conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);\n    if (conference) {\n        _handle_conference(stanza);\n    }\n\n    xmpp_stanza_t *captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA);\n    if (captcha) {\n        _handle_captcha(stanza);\n    }\n\n    xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);\n    if (receipts) {\n        _handle_receipt_received(stanza);\n    }\n\n    _handle_chat(stanza);\n\n    return 1;\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":206902,"func":"void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)\n{\n\tint i;\n\tint lx, ly;\n\ttypedef void (*image_line)(gdImagePtr im, int x1, int y1, int x2, int y2, int color);\n\timage_line draw_line;\n\n\tif (n <= 0) {\n\t\treturn;\n\t}\n\n\t\/* Let it be known that we are drawing a polygon so that the opacity\n\t * mask doesn't get cleared after each line.\n\t *\/\n\tif (c == gdAntiAliased) {\n\t\tim->AA_polygon = 1;\n\t}\n\n\tif ( im->antialias) {\n\t\tdraw_line = gdImageAALine;\n\t} else {\n\t\tdraw_line = gdImageLine;\n\t}\n\tlx = p->x;\n\tly = p->y;\n\tdraw_line(im, lx, ly, p[n - 1].x, p[n - 1].y, c);\n\tfor (i = 1; i < n; i++) {\n\t\tp++;\n\t\tdraw_line(im, lx, ly, p->x, p->y, c);\n\t\tlx = p->x;\n\t\tly = p->y;\n\t}\n\n\tif (c == gdAntiAliased) {\n\t\tim->AA_polygon = 0;\n\t\tgdImageAABlend(im);\n\t}\n}\n","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":143243,"func":"file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)\n{\n\tif (!(m->flag & UNSIGNED)) {\n\t\tswitch(m->type) {\n\t\t\/*\n\t\t * Do not remove the casts below.  They are\n\t\t * vital.  When later compared with the data,\n\t\t * the sign extension must have happened.\n\t\t *\/\n\t\tcase FILE_BYTE:\n\t\t\tv = (signed char) v;\n\t\t\tbreak;\n\t\tcase FILE_SHORT:\n\t\tcase FILE_BESHORT:\n\t\tcase FILE_LESHORT:\n\t\t\tv = (short) v;\n\t\t\tbreak;\n\t\tcase FILE_DATE:\n\t\tcase FILE_BEDATE:\n\t\tcase FILE_LEDATE:\n\t\tcase FILE_MEDATE:\n\t\tcase FILE_LDATE:\n\t\tcase FILE_BELDATE:\n\t\tcase FILE_LELDATE:\n\t\tcase FILE_MELDATE:\n\t\tcase FILE_LONG:\n\t\tcase FILE_BELONG:\n\t\tcase FILE_LELONG:\n\t\tcase FILE_MELONG:\n\t\tcase FILE_FLOAT:\n\t\tcase FILE_BEFLOAT:\n\t\tcase FILE_LEFLOAT:\n\t\t\tv = (int32_t) v;\n\t\t\tbreak;\n\t\tcase FILE_QUAD:\n\t\tcase FILE_BEQUAD:\n\t\tcase FILE_LEQUAD:\n\t\tcase FILE_QDATE:\n\t\tcase FILE_QLDATE:\n\t\tcase FILE_QWDATE:\n\t\tcase FILE_BEQDATE:\n\t\tcase FILE_BEQLDATE:\n\t\tcase FILE_BEQWDATE:\n\t\tcase FILE_LEQDATE:\n\t\tcase FILE_LEQLDATE:\n\t\tcase FILE_LEQWDATE:\n\t\tcase FILE_DOUBLE:\n\t\tcase FILE_BEDOUBLE:\n\t\tcase FILE_LEDOUBLE:\n\t\t\tv = (int64_t) v;\n\t\t\tbreak;\n\t\tcase FILE_STRING:\n\t\tcase FILE_PSTRING:\n\t\tcase FILE_BESTRING16:\n\t\tcase FILE_LESTRING16:\n\t\tcase FILE_REGEX:\n\t\tcase FILE_SEARCH:\n\t\tcase FILE_DEFAULT:\n\t\tcase FILE_INDIRECT:\n\t\tcase FILE_NAME:\n\t\tcase FILE_USE:\n\t\tcase FILE_CLEAR:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (ms->flags & MAGIC_CHECK)\n\t\t\t    file_magwarn(ms, \"cannot happen: m->type=%d\\n\",\n\t\t\t\t    m->type);\n\t\t\treturn ~0U;\n\t\t}\n\t}\n\treturn v;\n}","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":137656,"func":"static int set_offload(struct tun_struct *tun, unsigned long arg)\n{\n\tnetdev_features_t features = 0;\n\n\tif (arg & TUN_F_CSUM) {\n\t\tfeatures |= NETIF_F_HW_CSUM;\n\t\targ &= ~TUN_F_CSUM;\n\n\t\tif (arg & (TUN_F_TSO4|TUN_F_TSO6)) {\n\t\t\tif (arg & TUN_F_TSO_ECN) {\n\t\t\t\tfeatures |= NETIF_F_TSO_ECN;\n\t\t\t\targ &= ~TUN_F_TSO_ECN;\n\t\t\t}\n\t\t\tif (arg & TUN_F_TSO4)\n\t\t\t\tfeatures |= NETIF_F_TSO;\n\t\t\tif (arg & TUN_F_TSO6)\n\t\t\t\tfeatures |= NETIF_F_TSO6;\n\t\t\targ &= ~(TUN_F_TSO4|TUN_F_TSO6);\n\t\t}\n\n\t\tif (arg & TUN_F_UFO) {\n\t\t\tfeatures |= NETIF_F_UFO;\n\t\t\targ &= ~TUN_F_UFO;\n\t\t}\n\t}\n\n\t\/* This gives the user a way to test for new features in future by\n\t * trying to set them. *\/\n\tif (arg)\n\t\treturn -EINVAL;\n\n\ttun->set_features = features;\n\tnetdev_update_features(tun->dev);\n\n\treturn 0;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":195334,"func":"static unsigned deflateNoCompression(ucvector* out, const unsigned char* data, size_t datasize)\n{\n  \/*non compressed deflate block data: 1 bit BFINAL,2 bits BTYPE,(5 bits): it jumps to start of next byte,\n  2 bytes LEN, 2 bytes NLEN, LEN bytes literal DATA*\/\n\n  size_t i, j, numdeflateblocks = (datasize + 65534) \/ 65535;\n  unsigned datapos = 0;\n  for(i = 0; i < numdeflateblocks; i++)\n  {\n    unsigned BFINAL, BTYPE, LEN, NLEN;\n    unsigned char firstbyte;\n\n    BFINAL = (i == numdeflateblocks - 1);\n    BTYPE = 0;\n\n    firstbyte = (unsigned char)(BFINAL + ((BTYPE & 1) << 1) + ((BTYPE & 2) << 1));\n    if (!ucvector_push_back(out, firstbyte)) return 83;\n\n    LEN = 65535;\n    if(datasize - datapos < 65535) LEN = (unsigned)datasize - datapos;\n    NLEN = 65535 - LEN;\n\n    if (!ucvector_push_back(out, (unsigned char)(LEN % 256))) return 83;\n    if (!ucvector_push_back(out, (unsigned char)(LEN \/ 256))) return 83;\n    if (!ucvector_push_back(out, (unsigned char)(NLEN % 256))) return 83;\n    if (!ucvector_push_back(out, (unsigned char)(NLEN \/ 256))) return 83;\n\n    \/*Decompressed data*\/\n    for(j = 0; j < 65535 && datapos < datasize; j++)\n    {\n      if (!ucvector_push_back(out, data[datapos++])) return 83;\n    }\n  }\n\n  return 0;\n}\n","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":427659,"func":"static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){\n  int rc = SQLITE_OK;\n  RtreeNode *pChild = pLeaf;\n  while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){\n    int rc2 = SQLITE_OK;          \/* sqlite3_reset() return code *\/\n    sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);\n    rc = sqlite3_step(pRtree->pReadParent);\n    if( rc==SQLITE_ROW ){\n      RtreeNode *pTest;           \/* Used to test for reference loops *\/\n      i64 iNode;                  \/* Node number of parent node *\/\n\n      \/* Before setting pChild->pParent, test that we are not creating a\n      ** loop of references (as we would if, say, pChild==pParent). We don't\n      ** want to do this as it leads to a memory leak when trying to delete\n      ** the referenced counted node structures.\n      *\/\n      iNode = sqlite3_column_int64(pRtree->pReadParent, 0);\n      for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);\n      if( !pTest ){\n        rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);\n      }\n    }\n    rc = sqlite3_reset(pRtree->pReadParent);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK && !pChild->pParent ){\n      RTREE_IS_CORRUPT(pRtree);\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n    pChild = pChild->pParent;\n  }\n  return rc;\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":259205,"func":"flatpak_appstream_xml_root_to_data (FlatpakXml *appstream_root,\n                                    GBytes    **uncompressed,\n                                    GBytes    **compressed,\n                                    GError    **error)\n{\n  g_autoptr(GString) xml = NULL;\n  g_autoptr(GZlibCompressor) compressor = NULL;\n  g_autoptr(GOutputStream) out2 = NULL;\n  g_autoptr(GOutputStream) out = NULL;\n\n  flatpak_xml_add (appstream_root->first_child, flatpak_xml_new_text (\"\\n\"));\n\n  xml = g_string_new (\"\");\n  flatpak_xml_to_string (appstream_root, xml);\n\n  if (compressed)\n    {\n      compressor = g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP, -1);\n      out = g_memory_output_stream_new_resizable ();\n      out2 = g_converter_output_stream_new (out, G_CONVERTER (compressor));\n      if (!g_output_stream_write_all (out2, xml->str, xml->len,\n                                      NULL, NULL, error))\n        return FALSE;\n      if (!g_output_stream_close (out2, NULL, error))\n        return FALSE;\n    }\n\n  if (uncompressed)\n    *uncompressed = g_string_free_to_bytes (g_steal_pointer (&xml));\n\n  if (compressed)\n    *compressed = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out));\n\n  return TRUE;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":34452,"func":"static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page)\n{\n\tint page_lru;\n\n\tVM_BUG_ON_PAGE(compound_order(page) && !PageTransHuge(page), page);\n\n\t\/* Avoid migrating to a node that is nearly full *\/\n\tif (!migrate_balanced_pgdat(pgdat, 1UL << compound_order(page)))\n\t\treturn 0;\n\n\tif (isolate_lru_page(page))\n\t\treturn 0;\n\n\t\/*\n\t * migrate_misplaced_transhuge_page() skips page migration's usual\n\t * check on page_count(), so we must do it here, now that the page\n\t * has been isolated: a GUP pin, or any other pin, prevents migration.\n\t * The expected page count is 3: 1 for page's mapcount and 1 for the\n\t * caller's pin and 1 for the reference taken by isolate_lru_page().\n\t *\/\n\tif (PageTransHuge(page) && page_count(page) != 3) {\n\t\tputback_lru_page(page);\n\t\treturn 0;\n\t}\n\n\tpage_lru = page_is_file_cache(page);\n\tmod_zone_page_state(page_zone(page), NR_ISOLATED_ANON + page_lru,\n\t\t\t\thpage_nr_pages(page));\n\n\t\/*\n\t * Isolating the page has taken another reference, so the\n\t * caller's reference can be safely dropped without the page\n\t * disappearing underneath us during migration.\n\t *\/\n\tput_page(page);\n\treturn 1;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":303116,"func":"void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1,\n                   uint8_t *dst2, ThreadFrame *ref, const VP56mv *mv,\n                   int x_off, int y_off, int block_w, int block_h,\n                   int width, int height, ptrdiff_t linesize,\n                   vp8_mc_func mc_func[3][3])\n{\n    uint8_t *src1 = ref->f->data[1], *src2 = ref->f->data[2];\n\n    if (AV_RN32A(mv)) {\n        int mx = mv->x & 7, mx_idx = subpel_idx[0][mx];\n        int my = mv->y & 7, my_idx = subpel_idx[0][my];\n\n        x_off += mv->x >> 3;\n        y_off += mv->y >> 3;\n\n        \/\/ edge emulation\n        src1 += y_off * linesize + x_off;\n        src2 += y_off * linesize + x_off;\n        ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 3, 0);\n        if (x_off < mx_idx || x_off >= width  - block_w - subpel_idx[2][mx] ||\n            y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {\n            s->vdsp.emulated_edge_mc(td->edge_emu_buffer,\n                                     src1 - my_idx * linesize - mx_idx,\n                                     EDGE_EMU_LINESIZE, linesize,\n                                     block_w + subpel_idx[1][mx],\n                                     block_h + subpel_idx[1][my],\n                                     x_off - mx_idx, y_off - my_idx, width, height);\n            src1 = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;\n            mc_func[my_idx][mx_idx](dst1, linesize, src1, EDGE_EMU_LINESIZE, block_h, mx, my);\n\n            s->vdsp.emulated_edge_mc(td->edge_emu_buffer,\n                                     src2 - my_idx * linesize - mx_idx,\n                                     EDGE_EMU_LINESIZE, linesize,\n                                     block_w + subpel_idx[1][mx],\n                                     block_h + subpel_idx[1][my],\n                                     x_off - mx_idx, y_off - my_idx, width, height);\n            src2 = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;\n            mc_func[my_idx][mx_idx](dst2, linesize, src2, EDGE_EMU_LINESIZE, block_h, mx, my);\n        } else {\n            mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);\n            mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);\n        }\n    } else {\n        ff_thread_await_progress(ref, (3 + y_off + block_h) >> 3, 0);\n        mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);\n        mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);\n    }\n}","target":0,"code_token_length":753,"total_token_length":989,"max_tokens_setting":1024}
+{"idx":357676,"func":"long do_fork(unsigned long clone_flags,\n\t      unsigned long stack_start,\n\t      struct pt_regs *regs,\n\t      unsigned long stack_size,\n\t      int __user *parent_tidptr,\n\t      int __user *child_tidptr)\n{\n\tstruct task_struct *p;\n\tint trace = 0;\n\tlong nr;\n\n\t\/*\n\t * Do some preliminary argument and permissions checking before we\n\t * actually start allocating stuff\n\t *\/\n\tif (clone_flags & CLONE_NEWUSER) {\n\t\tif (clone_flags & CLONE_THREAD)\n\t\t\treturn -EINVAL;\n\t\t\/* hopefully this check will go away when userns support is\n\t\t * complete\n\t\t *\/\n\t\tif (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||\n\t\t\t\t!capable(CAP_SETGID))\n\t\t\treturn -EPERM;\n\t}\n\n\t\/*\n\t * We hope to recycle these flags after 2.6.26\n\t *\/\n\tif (unlikely(clone_flags & CLONE_STOPPED)) {\n\t\tstatic int __read_mostly count = 100;\n\n\t\tif (count > 0 && printk_ratelimit()) {\n\t\t\tchar comm[TASK_COMM_LEN];\n\n\t\t\tcount--;\n\t\t\tprintk(KERN_INFO \"fork(): process `%s' used deprecated \"\n\t\t\t\t\t\"clone flags 0x%lx\\n\",\n\t\t\t\tget_task_comm(comm, current),\n\t\t\t\tclone_flags & CLONE_STOPPED);\n\t\t}\n\t}\n\n\t\/*\n\t * When called from kernel_thread, don't do user tracing stuff.\n\t *\/\n\tif (likely(user_mode(regs)))\n\t\ttrace = tracehook_prepare_clone(clone_flags);\n\n\tp = copy_process(clone_flags, stack_start, regs, stack_size,\n\t\t\t child_tidptr, NULL, trace);\n\t\/*\n\t * Do this prior waking up the new thread - the thread pointer\n\t * might get invalid after that point, if the thread exits quickly.\n\t *\/\n\tif (!IS_ERR(p)) {\n\t\tstruct completion vfork;\n\n\t\ttrace_sched_process_fork(current, p);\n\n\t\tnr = task_pid_vnr(p);\n\n\t\tif (clone_flags & CLONE_PARENT_SETTID)\n\t\t\tput_user(nr, parent_tidptr);\n\n\t\tif (clone_flags & CLONE_VFORK) {\n\t\t\tp->vfork_done = &vfork;\n\t\t\tinit_completion(&vfork);\n\t\t}\n\n\t\taudit_finish_fork(p);\n\t\ttracehook_report_clone(trace, regs, clone_flags, nr, p);\n\n\t\t\/*\n\t\t * We set PF_STARTING at creation in case tracing wants to\n\t\t * use this to distinguish a fully live task from one that\n\t\t * hasn't gotten to tracehook_report_clone() yet.  Now we\n\t\t * clear it and set the child going.\n\t\t *\/\n\t\tp->flags &= ~PF_STARTING;\n\n\t\tif (unlikely(clone_flags & CLONE_STOPPED)) {\n\t\t\t\/*\n\t\t\t * We'll start up with an immediate SIGSTOP.\n\t\t\t *\/\n\t\t\tsigaddset(&p->pending.signal, SIGSTOP);\n\t\t\tset_tsk_thread_flag(p, TIF_SIGPENDING);\n\t\t\t__set_task_state(p, TASK_STOPPED);\n\t\t} else {\n\t\t\twake_up_new_task(p, clone_flags);\n\t\t}\n\n\t\ttracehook_report_clone_complete(trace, regs,\n\t\t\t\t\t\tclone_flags, nr, p);\n\n\t\tif (clone_flags & CLONE_VFORK) {\n\t\t\tfreezer_do_not_count();\n\t\t\twait_for_completion(&vfork);\n\t\t\tfreezer_count();\n\t\t\ttracehook_report_vfork_done(p, nr);\n\t\t}\n\t} else {\n\t\tnr = PTR_ERR(p);\n\t}\n\treturn nr;\n}","target":0,"code_token_length":741,"total_token_length":977,"max_tokens_setting":1024}
+{"idx":57582,"func":"mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,\n\t\t\t\t     struct mwifiex_private **priv, int *tid)\n{\n\tstruct mwifiex_private *priv_tmp;\n\tstruct mwifiex_ra_list_tbl *ptr;\n\tstruct mwifiex_tid_tbl *tid_ptr;\n\tatomic_t *hqp;\n\tint i, j;\n\n\t\/* check the BSS with highest priority first *\/\n\tfor (j = adapter->priv_num - 1; j >= 0; --j) {\n\t\t\/* iterate over BSS with the equal priority *\/\n\t\tlist_for_each_entry(adapter->bss_prio_tbl[j].bss_prio_cur,\n\t\t\t\t    &adapter->bss_prio_tbl[j].bss_prio_head,\n\t\t\t\t    list) {\n\ntry_again:\n\t\t\tpriv_tmp = adapter->bss_prio_tbl[j].bss_prio_cur->priv;\n\n\t\t\tif (((priv_tmp->bss_mode != NL80211_IFTYPE_ADHOC) &&\n\t\t\t     !priv_tmp->port_open) ||\n\t\t\t    (atomic_read(&priv_tmp->wmm.tx_pkts_queued) == 0))\n\t\t\t\tcontinue;\n\n\t\t\tif (adapter->if_ops.is_port_ready &&\n\t\t\t    !adapter->if_ops.is_port_ready(priv_tmp))\n\t\t\t\tcontinue;\n\n\t\t\t\/* iterate over the WMM queues of the BSS *\/\n\t\t\thqp = &priv_tmp->wmm.highest_queued_prio;\n\t\t\tfor (i = atomic_read(hqp); i >= LOW_PRIO_TID; --i) {\n\n\t\t\t\tspin_lock_bh(&priv_tmp->wmm.ra_list_spinlock);\n\n\t\t\t\ttid_ptr = &(priv_tmp)->wmm.\n\t\t\t\t\ttid_tbl_ptr[tos_to_tid[i]];\n\n\t\t\t\t\/* iterate over receiver addresses *\/\n\t\t\t\tlist_for_each_entry(ptr, &tid_ptr->ra_list,\n\t\t\t\t\t\t    list) {\n\n\t\t\t\t\tif (!ptr->tx_paused &&\n\t\t\t\t\t    !skb_queue_empty(&ptr->skb_head))\n\t\t\t\t\t\t\/* holds both locks *\/\n\t\t\t\t\t\tgoto found;\n\t\t\t\t}\n\n\t\t\t\tspin_unlock_bh(&priv_tmp->wmm.ra_list_spinlock);\n\t\t\t}\n\n\t\t\tif (atomic_read(&priv_tmp->wmm.tx_pkts_queued) != 0) {\n\t\t\t\tatomic_set(&priv_tmp->wmm.highest_queued_prio,\n\t\t\t\t\t   HIGH_PRIO_TID);\n\t\t\t\t\/* Iterate current private once more, since\n\t\t\t\t * there still exist packets in data queue\n\t\t\t\t *\/\n\t\t\t\tgoto try_again;\n\t\t\t} else\n\t\t\t\tatomic_set(&priv_tmp->wmm.highest_queued_prio,\n\t\t\t\t\t   NO_PKT_PRIO_TID);\n\t\t}\n\t}\n\n\treturn NULL;\n\nfound:\n\t\/* holds ra_list_spinlock *\/\n\tif (atomic_read(hqp) > i)\n\t\tatomic_set(hqp, i);\n\tspin_unlock_bh(&priv_tmp->wmm.ra_list_spinlock);\n\n\t*priv = priv_tmp;\n\t*tid = tos_to_tid[i];\n\n\treturn ptr;\n}","target":0,"code_token_length":605,"total_token_length":841,"max_tokens_setting":1024}
+{"idx":193384,"func":"ProcPseudoramiXQueryScreens(ClientPtr client)\n{\n    \/* REQUEST(xXineramaQueryScreensReq); *\/\n    xXineramaQueryScreensReply rep;\n\n    DEBUG_LOG(\"noPseudoramiXExtension=%d, pseudoramiXNumScreens=%d\\n\",\n              noPseudoramiXExtension,\n              pseudoramiXNumScreens);\n\n    REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);\n\n    rep.type = X_Reply;\n    rep.sequenceNumber = client->sequence;\n    rep.number = noPseudoramiXExtension ? 0 : pseudoramiXNumScreens;\n    rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);\n    if (client->swapped) {\n        swaps(&rep.sequenceNumber);\n        swapl(&rep.length);\n        swapl(&rep.number);\n    }\n    WriteToClient(client, sizeof(xXineramaQueryScreensReply),&rep);\n\n    if (!noPseudoramiXExtension) {\n        xXineramaScreenInfo scratch;\n        int i;\n\n        for (i = 0; i < pseudoramiXNumScreens; i++) {\n            scratch.x_org = pseudoramiXScreens[i].x;\n            scratch.y_org = pseudoramiXScreens[i].y;\n            scratch.width = pseudoramiXScreens[i].w;\n            scratch.height = pseudoramiXScreens[i].h;\n\n            if (client->swapped) {\n                swaps(&scratch.x_org);\n                swaps(&scratch.y_org);\n                swaps(&scratch.width);\n                swaps(&scratch.height);\n            }\n            WriteToClient(client, sz_XineramaScreenInfo,&scratch);\n        }\n    }\n\n    return Success;\n}\n","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":150384,"func":"\tResult negotiateSpawn(NegotiationDetails &details) {\n\t\tTRACE_POINT();\n\t\tdetails.spawnStartTime = SystemTime::getUsec();\n\t\tdetails.gupid = integerToHex(SystemTime::get() \/ 60) + \"-\" +\n\t\t\tconfig->randomGenerator->generateAsciiString(10);\n\t\tdetails.timeout = details.options->startTimeout * 1000;\n\n\t\tstring result;\n\t\ttry {\n\t\t\tresult = readMessageLine(details);\n\t\t} catch (const SystemException &e) {\n\t\t\tthrowAppSpawnException(\"An error occurred while starting the \"\n\t\t\t\t\"web application. There was an I\/O error while reading its \"\n\t\t\t\t\"handshake message: \" + e.sys(),\n\t\t\t\tSpawnException::APP_STARTUP_PROTOCOL_ERROR,\n\t\t\t\tdetails);\n\t\t} catch (const TimeoutException &) {\n\t\t\tthrowAppSpawnException(\"An error occurred while starting the \"\n\t\t\t\t\"web application: it did not write a handshake message in time.\",\n\t\t\t\tSpawnException::APP_STARTUP_TIMEOUT,\n\t\t\t\tdetails);\n\t\t}\n\n\t\tprotocol_begin:\n\t\tif (result == \"I have control 1.0\\n\") {\n\t\t\tUPDATE_TRACE_POINT();\n\t\t\tsendSpawnRequest(details);\n\t\t\ttry {\n\t\t\t\tresult = readMessageLine(details);\n\t\t\t} catch (const SystemException &e) {\n\t\t\t\tthrowAppSpawnException(\"An error occurred while starting the \"\n\t\t\t\t\t\"web application. There was an I\/O error while reading its \"\n\t\t\t\t\t\"startup response: \" + e.sys(),\n\t\t\t\t\tSpawnException::APP_STARTUP_PROTOCOL_ERROR,\n\t\t\t\t\tdetails);\n\t\t\t} catch (const TimeoutException &) {\n\t\t\t\tthrowAppSpawnException(\"An error occurred while starting the \"\n\t\t\t\t\t\"web application: it did not write a startup response in time. \"\n\t\t\t\t\t\"If your app needs more time to start you can increase the \"\n\t\t\t\t\t\"Passenger start timeout config option.\",\n\t\t\t\t\tSpawnException::APP_STARTUP_TIMEOUT,\n\t\t\t\t\tdetails);\n\t\t\t}\n\t\t\tif (result == \"Ready\\n\") {\n\t\t\t\treturn handleSpawnResponse(details);\n\t\t\t} else if (result == \"Error\\n\") {\n\t\t\t\thandleSpawnErrorResponse(details);\n\t\t\t} else if (result == \"I have control 1.0\\n\") {\n\t\t\t\tgoto protocol_begin;\n\t\t\t} else {\n\t\t\t\thandleInvalidSpawnResponseType(result, details);\n\t\t\t}\n\t\t} else {\n\t\t\tUPDATE_TRACE_POINT();\n\t\t\tif (result == \"Error\\n\") {\n\t\t\t\thandleSpawnErrorResponse(details);\n\t\t\t} else {\n\t\t\t\thandleInvalidSpawnResponseType(result, details);\n\t\t\t}\n\t\t}\n\t\treturn Result(); \/\/ Never reached.\n\t}","target":0,"code_token_length":546,"total_token_length":782,"max_tokens_setting":1024}
+{"idx":8815,"func":"  void operator()(const CPUDevice& d, typename TTypes<T, 4>::ConstTensor input,\n                  typename TTypes<T, 3>::ConstTensor filter,\n                  typename TTypes<T, 4>::ConstTensor out_backprop,\n                  int stride_rows, int stride_cols, int rate_rows,\n                  int rate_cols, int pad_top, int pad_left,\n                  typename TTypes<T, 3>::Tensor filter_backprop) {\n    const int batch = input.dimension(0);\n    const int input_rows = input.dimension(1);\n    const int input_cols = input.dimension(2);\n    const int depth = input.dimension(3);\n\n    const int filter_rows = filter.dimension(0);\n    const int filter_cols = filter.dimension(1);\n\n    const int output_rows = out_backprop.dimension(1);\n    const int output_cols = out_backprop.dimension(2);\n\n    \/\/ Initialize gradient with all zeros.\n    filter_backprop.setZero();\n\n    \/\/ This is a reference implementation, likely to be slow.\n    \/\/ TODO(gpapan): Write multi-threaded implementation.\n    \/\/ In the case of multiple argmax branches, we only back-propagate along the\n    \/\/ last branch, i.e., the one with largest value of `h * filter_cols + w`,\n    \/\/ similarly to the max-pooling backward routines.\n    for (int b = 0; b < batch; ++b) {\n      for (int h_out = 0; h_out < output_rows; ++h_out) {\n        int h_beg = h_out * stride_rows - pad_top;\n        for (int w_out = 0; w_out < output_cols; ++w_out) {\n          int w_beg = w_out * stride_cols - pad_left;\n          for (int d = 0; d < depth; ++d) {\n            T cur_val = Eigen::NumTraits<T>::lowest();\n            int h_max = 0;\n            int w_max = 0;\n            for (int h = 0; h < filter_rows; ++h) {\n              const int h_in = h_beg + h * rate_rows;\n              if (h_in >= 0 && h_in < input_rows) {\n                for (int w = 0; w < filter_cols; ++w) {\n                  const int w_in = w_beg + w * rate_cols;\n                  if (w_in >= 0 && w_in < input_cols) {\n                    const T val = input(b, h_in, w_in, d) + filter(h, w, d);\n                    if (val > cur_val) {\n                      cur_val = val;\n                      h_max = h;\n                      w_max = w;\n                    }\n                  }\n                }\n              }\n            }\n            filter_backprop(h_max, w_max, d) +=\n                out_backprop(b, h_out, w_out, d);\n          }\n        }\n      }\n    }\n  }","target":1,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":210482,"func":"bool TabsUpdateFunction::UpdateURL(const std::string& url_string,\n                                   int tab_id,\n                                   std::string* error) {\n  GURL url =\n      ExtensionTabUtil::ResolvePossiblyRelativeURL(url_string, extension());\n\n  if (!url.is_valid()) {\n    *error = ErrorUtils::FormatErrorMessage(tabs_constants::kInvalidUrlError,\n                                            url_string);\n    return false;\n  }\n\n  if (ExtensionTabUtil::IsKillURL(url)) {\n    *error = tabs_constants::kNoCrashBrowserError;\n    return false;\n  }\n\n  const bool is_javascript_scheme = url.SchemeIs(url::kJavaScriptScheme);\n  UMA_HISTOGRAM_BOOLEAN(\"Extensions.ApiTabUpdateJavascript\",\n                        is_javascript_scheme);\n  if (is_javascript_scheme) {\n    *error = tabs_constants::kJavaScriptUrlsNotAllowedInTabsUpdate;\n    return false;\n  }\n\n  bool use_renderer_initiated = false;\n  if (extension() && extension()->id() == extension_misc::kPdfExtensionId)\n    use_renderer_initiated = true;\n  NavigationController::LoadURLParams load_params(url);\n  load_params.is_renderer_initiated = use_renderer_initiated;\n  web_contents_->GetController().LoadURLWithParams(load_params);\n\n  DCHECK_EQ(url,\n            web_contents_->GetController().GetPendingEntry()->GetVirtualURL());\n\n  return true;\n}\n","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":502855,"func":"promptexpand(char *s, int ns, char *rs, char *Rs, zattr *txtchangep)\n{\n    struct buf_vars new_vars;\n\n    if(!s)\n\treturn ztrdup(\"\");\n\n    if ((termflags & TERM_UNKNOWN) && (unset(INTERACTIVE)))\n        init_term();\n\n    if (isset(PROMPTSUBST)) {\n\tint olderr = errflag;\n\tint oldval = lastval;\n\n\ts = dupstring(s);\n\tif (!parsestr(&s))\n\t    singsub(&s);\n\t\/*\n\t * We don't need the special Nularg hack here and we're\n\t * going to be using Nularg for other things.\n\t *\/\n\tif (*s == Nularg && s[1] == '\\0')\n\t    *s = '\\0';\n\n\t\/*\n\t * Ignore errors and status change in prompt substitution.\n\t * However, keep any user interrupt error that occurred.\n\t *\/\n\terrflag = olderr | (errflag & ERRFLAG_INT);\n\tlastval = oldval;\n    }\n\n    memset(&new_vars, 0, sizeof(new_vars));\n    new_vars.last = bv;\n    bv = &new_vars;\n\n    new_vars.rstring = rs;\n    new_vars.Rstring = Rs;\n    new_vars.fm = s;\n    new_vars.bufspc = 256;\n    new_vars.bp = new_vars.bufline = new_vars.buf = zshcalloc(new_vars.bufspc);\n    new_vars.bp1 = NULL;\n    new_vars.truncwidth = 0;\n\n    putpromptchar(1, '\\0', txtchangep);\n    addbufspc(2);\n    if (new_vars.dontcount)\n\t*new_vars.bp++ = Outpar;\n    *new_vars.bp = '\\0';\n    if (!ns) {\n\t\/* If zero, Inpar, Outpar and Nularg should be removed. *\/\n\tfor (new_vars.bp = new_vars.buf; *new_vars.bp; ) {\n\t    if (*new_vars.bp == Meta)\n\t\tnew_vars.bp += 2;\n\t    else if (*new_vars.bp == Inpar || *new_vars.bp == Outpar ||\n\t\t     *new_vars.bp == Nularg)\n\t\tchuck(new_vars.bp);\n\t    else\n\t\tnew_vars.bp++;\n\t}\n    }\n\n    bv = new_vars.last;\n\n    return new_vars.buf;\n}","target":0,"code_token_length":486,"total_token_length":722,"max_tokens_setting":1024}
+{"idx":64747,"func":"BGD_DECLARE(int) gdImageColorReplaceCallback (gdImagePtr im, gdCallbackImageColor callback)\n{\n\tint c, d, n = 0;\n\n\tif (!callback) {\n\t\treturn 0;\n\t}\n\tif (im->trueColor) {\n\t\tregister int x, y;\n\n\t\tfor (y = im->cy1; y <= im->cy2; y++) {\n\t\t\tfor (x = im->cx1; x <= im->cx2; x++) {\n\t\t\t\tc = gdImageTrueColorPixel(im, x, y);\n\t\t\t\tif ( (d = callback(im, c)) != c) {\n\t\t\t\t\tgdImageSetPixel(im, x, y, d);\n\t\t\t\t\tn++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else { \/* palette *\/\n\t\tint *sarr, *darr;\n\t\tint k, len = 0;\n\n\t\tsarr = (int *)gdCalloc(im->colorsTotal, sizeof(int));\n\t\tif (!sarr) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (c = 0; c < im->colorsTotal; c++) {\n\t\t\tif (!im->open[c]) {\n\t\t\t\tsarr[len++] = c;\n\t\t\t}\n\t\t}\n\t\tdarr = (int *)gdCalloc(len, sizeof(int));\n\t\tif (!darr) {\n\t\t\tgdFree(sarr);\n\t\t\treturn -1;\n\t\t}\n\t\tfor (k = 0; k < len; k++) {\n\t\t\tdarr[k] = callback(im, sarr[k]);\n\t\t}\n\t\tn = gdImageColorReplaceArray(im, k, sarr, darr);\n\t\tgdFree(darr);\n\t\tgdFree(sarr);\n\t}\n\treturn n;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":424515,"func":"print_optimize_info(FILE* f, regex_t* reg)\n{\n  static const char* on[] = { \"NONE\", \"EXACT\", \"EXACT_BM\", \"EXACT_BM_NOT_REV\",\n                              \"EXACT_IC\", \"MAP\" };\n\n  fprintf(f, \"optimize: %s\\n\", on[reg->optimize]);\n  fprintf(f, \"  anchor: \"); print_anchor(f, reg->anchor);\n  if ((reg->anchor & ANCHOR_END_BUF_MASK) != 0)\n    print_distance_range(f, reg->anchor_dmin, reg->anchor_dmax);\n  fprintf(f, \"\\n\");\n\n  if (reg->optimize) {\n    fprintf(f, \"  sub anchor: \"); print_anchor(f, reg->sub_anchor);\n    fprintf(f, \"\\n\");\n  }\n  fprintf(f, \"\\n\");\n\n  if (reg->exact) {\n    UChar *p;\n    fprintf(f, \"exact: [\");\n    for (p = reg->exact; p < reg->exact_end; p++) {\n      fputc(*p, f);\n    }\n    fprintf(f, \"]: length: %d\\n\", (reg->exact_end - reg->exact));\n  }\n  else if (reg->optimize & ONIG_OPTIMIZE_MAP) {\n    int c, i, n = 0;\n\n    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)\n      if (reg->map[i]) n++;\n\n    fprintf(f, \"map: n=%d\\n\", n);\n    if (n > 0) {\n      c = 0;\n      fputc('[', f);\n      for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {\n\tif (reg->map[i] != 0) {\n          if (c > 0)  fputs(\", \", f);\n          c++;\n          if (ONIGENC_MBC_MAXLEN(reg->enc) == 1 &&\n              ONIGENC_IS_CODE_PRINT(reg->enc, (OnigCodePoint )i))\n            fputc(i, f);\n          else\n            fprintf(f, \"%d\", i);\n        }\n      }\n      fprintf(f, \"]\\n\");\n    }\n  }\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":47719,"func":"static int cm_drep_handler(struct cm_work *work)\n{\n\tstruct cm_id_private *cm_id_priv;\n\tstruct cm_drep_msg *drep_msg;\n\tint ret;\n\n\tdrep_msg = (struct cm_drep_msg *)work->mad_recv_wc->recv_buf.mad;\n\tcm_id_priv = cm_acquire_id(drep_msg->remote_comm_id,\n\t\t\t\t   drep_msg->local_comm_id);\n\tif (!cm_id_priv)\n\t\treturn -EINVAL;\n\n\twork->cm_event.private_data = &drep_msg->private_data;\n\n\tspin_lock_irq(&cm_id_priv->lock);\n\tif (cm_id_priv->id.state != IB_CM_DREQ_SENT &&\n\t    cm_id_priv->id.state != IB_CM_DREQ_RCVD) {\n\t\tspin_unlock_irq(&cm_id_priv->lock);\n\t\tgoto out;\n\t}\n\tcm_enter_timewait(cm_id_priv);\n\n\tib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);\n\tret = atomic_inc_and_test(&cm_id_priv->work_count);\n\tif (!ret)\n\t\tlist_add_tail(&work->list, &cm_id_priv->work_list);\n\tspin_unlock_irq(&cm_id_priv->lock);\n\n\tif (ret)\n\t\tcm_process_work(cm_id_priv, work);\n\telse\n\t\tcm_deref_id(cm_id_priv);\n\treturn 0;\nout:\n\tcm_deref_id(cm_id_priv);\n\treturn -EINVAL;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":345731,"func":"PS_SERIALIZER_DECODE_FUNC(php) \/* {{{ *\/\n{\n\tconst char *p, *q;\n\tchar *name;\n\tconst char *endptr = val + vallen;\n\tzval *current;\n\tint namelen;\n\tint has_value;\n\tphp_unserialize_data_t var_hash;\n\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\n\tp = val;\n\n\twhile (p < endptr) {\n\t\tzval **tmp;\n\t\tq = p;\n\t\twhile (*q != PS_DELIMITER) {\n\t\t\tif (++q >= endptr) goto break_outer_loop;\n\t\t}\n\t\tif (p[0] == PS_UNDEF_MARKER) {\n\t\t\tp++;\n\t\t\thas_value = 0;\n\t\t} else {\n\t\t\thas_value = 1;\n\t\t}\n\n\t\tnamelen = q - p;\n\t\tname = estrndup(p, namelen);\n\t\tq++;\n\n\t\tif (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void **) &tmp) == SUCCESS) {\n\t\t\tif ((Z_TYPE_PP(tmp) == IS_ARRAY && Z_ARRVAL_PP(tmp) == &EG(symbol_table)) || *tmp == PS(http_session_vars)) {\n\t\t\t\tgoto skip;\n\t\t\t}\n\t\t}\n\n\t\tif (has_value) {\n\t\t\tALLOC_INIT_ZVAL(current);\n\t\t\tif (php_var_unserialize(¤t, (const unsigned char **) &q, (const unsigned char *) endptr, &var_hash TSRMLS_CC)) {\n\t\t\t\tphp_set_session_var(name, namelen, current, &var_hash  TSRMLS_CC);\n\t\t\t}\n\t\t\tzval_ptr_dtor(¤t);\n\t\t}\n\t\tPS_ADD_VARL(name, namelen);\nskip:\n\t\tefree(name);\n\n\t\tp = q;\n\t}\nbreak_outer_loop:\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\n\treturn SUCCESS;\n}","target":1,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":452646,"func":"void MonClient::handle_monmap(MMonMap *m)\n{\n  ldout(cct, 10) << __func__ << \" \" << *m << dendl;\n  auto con_addrs = m->get_source_addrs();\n  string old_name = monmap.get_name(con_addrs);\n\n  \/\/ NOTE: we're not paying attention to the epoch, here.\n  auto p = m->monmapbl.cbegin();\n  decode(monmap, p);\n\n  ldout(cct, 10) << \" got monmap \" << monmap.epoch\n\t\t << \" from mon.\" << old_name\n\t\t << \" (according to old e\" << monmap.get_epoch() << \")\"\n \t\t << dendl;\n  ldout(cct, 10) << \"dump:\\n\";\n  monmap.print(*_dout);\n  *_dout << dendl;\n\n  if (old_name.size() == 0) {\n    ldout(cct,10) << \" can't identify which mon we were connected to\" << dendl;\n    _reopen_session();\n  } else {\n    int new_rank = monmap.get_rank(m->get_source_addr());\n    if (new_rank < 0) {\n      ldout(cct, 10) << \"mon.\" << new_rank << \" at \" << m->get_source_addrs()\n\t\t     << \" went away\" << dendl;\n      \/\/ can't find the mon we were talking to (above)\n      _reopen_session();\n    } else if (messenger->should_use_msgr2() &&\n\t       monmap.get_addrs(new_rank).has_msgr2() &&\n\t       !con_addrs.has_msgr2()) {\n      ldout(cct,1) << \" mon.\" << new_rank << \" has (v2) addrs \"\n\t\t   << monmap.get_addrs(new_rank) << \" but i'm connected to \"\n\t\t   << con_addrs << \", reconnecting\" << dendl;\n      _reopen_session();\n    }\n  }\n\n  cct->set_mon_addrs(monmap);\n\n  sub.got(\"monmap\", monmap.get_epoch());\n  map_cond.Signal();\n  want_monmap = false;\n\n  if (authenticate_err == 1) {\n    _finish_auth(0);\n  }\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":293181,"func":"static int do_recv_XKeyEvent(rpc_message_t *message, XEvent *xevent)\n{\n  int32_t x, y, x_root, y_root, same_screen;\n  uint32_t root, subwindow, time, state, keycode;\n  int error;\n  if ((error = do_recv_XAnyEvent(message, xevent)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_uint32(message, &root)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_uint32(message, &subwindow)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_uint32(message, &time)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_int32(message, &x)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_int32(message, &y)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_int32(message, &x_root)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_int32(message, &y_root)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_uint32(message, &state)) < 0)\n\treturn error; \n  if ((error = rpc_message_recv_uint32(message, &keycode)) < 0)\n\treturn error;\n  if ((error = rpc_message_recv_int32(message, &same_screen)) < 0)\n\treturn error;\n  xevent->xkey.root = root;\n  xevent->xkey.subwindow = subwindow;\n  xevent->xkey.time = time;\n  xevent->xkey.x = x;\n  xevent->xkey.y = y;\n  xevent->xkey.x_root = x_root;\n  xevent->xkey.y_root = y_root;\n  xevent->xkey.state = state;\n  xevent->xkey.keycode = keycode;\n  xevent->xkey.same_screen = same_screen;\n  return RPC_ERROR_NO_ERROR;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":41913,"func":"static unsigned long keyring_get_key_chunk(const void *data, int level)\n{\n\tconst struct keyring_index_key *index_key = data;\n\tunsigned long chunk = 0;\n\tlong offset = 0;\n\tint desc_len = index_key->desc_len, n = sizeof(chunk);\n\n\tlevel \/= ASSOC_ARRAY_KEY_CHUNK_SIZE;\n\tswitch (level) {\n\tcase 0:\n\t\treturn hash_key_type_and_desc(index_key);\n\tcase 1:\n\t\treturn ((unsigned long)index_key->type << 8) | desc_len;\n\tcase 2:\n\t\tif (desc_len == 0)\n\t\t\treturn (u8)((unsigned long)index_key->type >>\n\t\t\t\t    (ASSOC_ARRAY_KEY_CHUNK_SIZE - 8));\n\t\tn--;\n\t\toffset = 1;\n\tdefault:\n\t\toffset += sizeof(chunk) - 1;\n\t\toffset += (level - 3) * sizeof(chunk);\n\t\tif (offset >= desc_len)\n\t\t\treturn 0;\n\t\tdesc_len -= offset;\n\t\tif (desc_len > n)\n\t\t\tdesc_len = n;\n\t\toffset += desc_len;\n\t\tdo {\n\t\t\tchunk <<= 8;\n\t\t\tchunk |= ((u8*)index_key->description)[--offset];\n\t\t} while (--desc_len > 0);\n\n\t\tif (level == 2) {\n\t\t\tchunk <<= 8;\n\t\t\tchunk |= (u8)((unsigned long)index_key->type >>\n\t\t\t\t      (ASSOC_ARRAY_KEY_CHUNK_SIZE - 8));\n\t\t}\n\t\treturn chunk;\n\t}\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":47453,"func":"static void i40e_link_event(struct i40e_pf *pf)\n{\n\tstruct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];\n\tu8 new_link_speed, old_link_speed;\n\ti40e_status status;\n\tbool new_link, old_link;\n\n\t\/* set this to force the get_link_status call to refresh state *\/\n\tpf->hw.phy.get_link_info = true;\n\told_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP);\n\tstatus = i40e_get_link_status(&pf->hw, &new_link);\n\n\t\/* On success, disable temp link polling *\/\n\tif (status == I40E_SUCCESS) {\n\t\tclear_bit(__I40E_TEMP_LINK_POLLING, pf->state);\n\t} else {\n\t\t\/* Enable link polling temporarily until i40e_get_link_status\n\t\t * returns I40E_SUCCESS\n\t\t *\/\n\t\tset_bit(__I40E_TEMP_LINK_POLLING, pf->state);\n\t\tdev_dbg(&pf->pdev->dev, \"couldn't get link state, status: %d\\n\",\n\t\t\tstatus);\n\t\treturn;\n\t}\n\n\told_link_speed = pf->hw.phy.link_info_old.link_speed;\n\tnew_link_speed = pf->hw.phy.link_info.link_speed;\n\n\tif (new_link == old_link &&\n\t    new_link_speed == old_link_speed &&\n\t    (test_bit(__I40E_VSI_DOWN, vsi->state) ||\n\t     new_link == netif_carrier_ok(vsi->netdev)))\n\t\treturn;\n\n\ti40e_print_link_message(vsi, new_link);\n\n\t\/* Notify the base of the switch tree connected to\n\t * the link.  Floating VEBs are not notified.\n\t *\/\n\tif (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb])\n\t\ti40e_veb_link_event(pf->veb[pf->lan_veb], new_link);\n\telse\n\t\ti40e_vsi_link_event(vsi, new_link);\n\n\tif (pf->vf)\n\t\ti40e_vc_notify_link_state(pf);\n\n\tif (pf->flags & I40E_FLAG_PTP)\n\t\ti40e_ptp_set_increment(pf);\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":135284,"func":"f_fullcommand(typval_T *argvars, typval_T *rettv)\n{\n    exarg_T  ea;\n    char_u   *name;\n    char_u   *p;\n\n    rettv->v_type = VAR_STRING;\n    rettv->vval.v_string = NULL;\n\n    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)\n\treturn;\n\n    name = argvars[0].vval.v_string;\n    if (name == NULL)\n\treturn;\n\n    while (*name == ':')\n\tname++;\n    name = skip_range(name, TRUE, NULL);\n\n    ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;\n    ea.cmdidx = (cmdidx_T)0;\n    ea.addr_count = 0;\n    p = find_ex_command(&ea, NULL, NULL, NULL);\n    if (p == NULL || ea.cmdidx == CMD_SIZE)\n\treturn;\n    if (in_vim9script())\n    {\n\tint\t     res;\n\n\t++emsg_silent;\n\tres = not_in_vim9(&ea);\n\t--emsg_silent;\n\n\tif (res == FAIL)\n\t    return;\n    }\n\n    rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)\n\t\t\t\t ? get_user_command_name(ea.useridx, ea.cmdidx)\n\t\t\t\t : cmdnames[ea.cmdidx].cmd_name);\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":92505,"func":"iperf_send(struct iperf_test *test, fd_set *write_setP)\n{\n    register int multisend, r, streams_active;\n    register struct iperf_stream *sp;\n    struct timeval now;\n\n    \/* Can we do multisend mode? *\/\n    if (test->settings->burst != 0)\n        multisend = test->settings->burst;\n    else if (test->settings->rate == 0)\n        multisend = test->multisend;\n    else\n        multisend = 1;\t\/* nope *\/\n\n    for (; multisend > 0; --multisend) {\n\tif (test->settings->rate != 0 && test->settings->burst == 0)\n\t    gettimeofday(&now, NULL);\n\tstreams_active = 0;\n\tSLIST_FOREACH(sp, &test->streams, streams) {\n\t    if (sp->green_light &&\n\t        (write_setP == NULL || FD_ISSET(sp->socket, write_setP))) {\n\t\tif ((r = sp->snd(sp)) < 0) {\n\t\t    if (r == NET_SOFTERROR)\n\t\t\tbreak;\n\t\t    i_errno = IESTREAMWRITE;\n\t\t    return r;\n\t\t}\n\t\tstreams_active = 1;\n\t\ttest->bytes_sent += r;\n\t\t++test->blocks_sent;\n\t\tif (test->settings->rate != 0 && test->settings->burst == 0)\n\t\t    iperf_check_throttle(sp, &now);\n\t\tif (multisend > 1 && test->settings->bytes != 0 && test->bytes_sent >= test->settings->bytes)\n\t\t    break;\n\t\tif (multisend > 1 && test->settings->blocks != 0 && test->blocks_sent >= test->settings->blocks)\n\t\t    break;\n\t    }\n\t}\n\tif (!streams_active)\n\t    break;\n    }\n    if (test->settings->burst != 0) {\n\tgettimeofday(&now, NULL);\n\tSLIST_FOREACH(sp, &test->streams, streams)\n\t    iperf_check_throttle(sp, &now);\n    }\n    if (write_setP != NULL)\n\tSLIST_FOREACH(sp, &test->streams, streams)\n\t    if (FD_ISSET(sp->socket, write_setP))\n\t\tFD_CLR(sp->socket, write_setP);\n\n    return 0;\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":108443,"func":"encode_REG_MOVE(const struct ofpact_reg_move *move,\n                enum ofp_version ofp_version, struct ofpbuf *out)\n{\n    \/* For OpenFlow 1.3, the choice of ONFACT_RAW13_COPY_FIELD versus\n     * NXAST_RAW_REG_MOVE is somewhat difficult.  Neither one is guaranteed to\n     * be supported by every OpenFlow 1.3 implementation.  It would be ideal to\n     * probe for support.  Until we have that ability, we currently prefer\n     * NXAST_RAW_REG_MOVE for backward compatibility with older Open vSwitch\n     * versions.  *\/\n    size_t start_ofs = out->size;\n    if (ofp_version >= OFP15_VERSION) {\n        struct ofp15_action_copy_field *copy = put_OFPAT15_COPY_FIELD(out);\n        copy->n_bits = htons(move->dst.n_bits);\n        copy->src_offset = htons(move->src.ofs);\n        copy->dst_offset = htons(move->dst.ofs);\n        out->size = out->size - sizeof copy->pad2;\n        nx_put_mff_header(out, move->src.field, ofp_version, false);\n        nx_put_mff_header(out, move->dst.field, ofp_version, false);\n    } else if (ofp_version == OFP13_VERSION\n               && move->ofpact.raw == ONFACT_RAW13_COPY_FIELD) {\n        struct onf_action_copy_field *copy = put_ONFACT13_COPY_FIELD(out);\n        copy->n_bits = htons(move->dst.n_bits);\n        copy->src_offset = htons(move->src.ofs);\n        copy->dst_offset = htons(move->dst.ofs);\n        out->size = out->size - sizeof copy->pad3;\n        nx_put_mff_header(out, move->src.field, ofp_version, false);\n        nx_put_mff_header(out, move->dst.field, ofp_version, false);\n    } else {\n        struct nx_action_reg_move *narm = put_NXAST_REG_MOVE(out);\n        narm->n_bits = htons(move->dst.n_bits);\n        narm->src_ofs = htons(move->src.ofs);\n        narm->dst_ofs = htons(move->dst.ofs);\n        nx_put_mff_header(out, move->src.field, 0, false);\n        nx_put_mff_header(out, move->dst.field, 0, false);\n    }\n    pad_ofpat(out, start_ofs);\n}","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":33775,"func":"static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,\n\t\t\t\t struct cgroup_map_cb *cb)\n{\n\tstruct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont);\n\tstruct mcs_total_stat mystat;\n\tint i;\n\n\tmemset(&mystat, 0, sizeof(mystat));\n\tmem_cgroup_get_local_stat(mem_cont, &mystat);\n\n\n\tfor (i = 0; i < NR_MCS_STAT; i++) {\n\t\tif (i == MCS_SWAP && !do_swap_account)\n\t\t\tcontinue;\n\t\tcb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);\n\t}\n\n\t\/* Hierarchical information *\/\n\t{\n\t\tunsigned long long limit, memsw_limit;\n\t\tmemcg_get_hierarchical_limit(mem_cont, &limit, &memsw_limit);\n\t\tcb->fill(cb, \"hierarchical_memory_limit\", limit);\n\t\tif (do_swap_account)\n\t\t\tcb->fill(cb, \"hierarchical_memsw_limit\", memsw_limit);\n\t}\n\n\tmemset(&mystat, 0, sizeof(mystat));\n\tmem_cgroup_get_total_stat(mem_cont, &mystat);\n\tfor (i = 0; i < NR_MCS_STAT; i++) {\n\t\tif (i == MCS_SWAP && !do_swap_account)\n\t\t\tcontinue;\n\t\tcb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);\n\t}\n\n#ifdef CONFIG_DEBUG_VM\n\t{\n\t\tint nid, zid;\n\t\tstruct mem_cgroup_per_zone *mz;\n\t\tunsigned long recent_rotated[2] = {0, 0};\n\t\tunsigned long recent_scanned[2] = {0, 0};\n\n\t\tfor_each_online_node(nid)\n\t\t\tfor (zid = 0; zid < MAX_NR_ZONES; zid++) {\n\t\t\t\tmz = mem_cgroup_zoneinfo(mem_cont, nid, zid);\n\n\t\t\t\trecent_rotated[0] +=\n\t\t\t\t\tmz->reclaim_stat.recent_rotated[0];\n\t\t\t\trecent_rotated[1] +=\n\t\t\t\t\tmz->reclaim_stat.recent_rotated[1];\n\t\t\t\trecent_scanned[0] +=\n\t\t\t\t\tmz->reclaim_stat.recent_scanned[0];\n\t\t\t\trecent_scanned[1] +=\n\t\t\t\t\tmz->reclaim_stat.recent_scanned[1];\n\t\t\t}\n\t\tcb->fill(cb, \"recent_rotated_anon\", recent_rotated[0]);\n\t\tcb->fill(cb, \"recent_rotated_file\", recent_rotated[1]);\n\t\tcb->fill(cb, \"recent_scanned_anon\", recent_scanned[0]);\n\t\tcb->fill(cb, \"recent_scanned_file\", recent_scanned[1]);\n\t}\n#endif\n\n\treturn 0;\n}","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":414405,"func":"static void findHotKeys(void) {\n    redisReply *keys, *reply;\n    unsigned long long counters[HOTKEYS_SAMPLE] = {0};\n    sds hotkeys[HOTKEYS_SAMPLE] = {NULL};\n    unsigned long long sampled = 0, total_keys, *freqs = NULL, it = 0;\n    unsigned int arrsize = 0, i, k;\n    double pct;\n\n    \/* Total keys pre scanning *\/\n    total_keys = getDbSize();\n\n    \/* Status message *\/\n    printf(\"\\n# Scanning the entire keyspace to find hot keys as well as\\n\");\n    printf(\"# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec\\n\");\n    printf(\"# per 100 SCAN commands (not usually needed).\\n\\n\");\n\n    \/* SCAN loop *\/\n    do {\n        \/* Calculate approximate percentage completion *\/\n        pct = 100 * (double)sampled\/total_keys;\n\n        \/* Grab some keys and point to the keys array *\/\n        reply = sendScan(&it);\n        keys  = reply->element[1];\n\n        \/* Reallocate our freqs array if we need to *\/\n        if(keys->elements > arrsize) {\n            freqs = zrealloc(freqs, sizeof(unsigned long long)*keys->elements);\n\n            if(!freqs) {\n                fprintf(stderr, \"Failed to allocate storage for keys!\\n\");\n                exit(1);\n            }\n\n            arrsize = keys->elements;\n        }\n\n        getKeyFreqs(keys, freqs);\n\n        \/* Now update our stats *\/\n        for(i=0;i<keys->elements;i++) {\n            sampled++;\n            \/* Update overall progress *\/\n            if(sampled % 1000000 == 0) {\n                printf(\"[%05.2f%%] Sampled %llu keys so far\\n\", pct, sampled);\n            }\n\n            \/* Use eviction pool here *\/\n            k = 0;\n            while (k < HOTKEYS_SAMPLE && freqs[i] > counters[k]) k++;\n            if (k == 0) continue;\n            k--;\n            if (k == 0 || counters[k] == 0) {\n                sdsfree(hotkeys[k]);\n            } else {\n                sdsfree(hotkeys[0]);\n                memmove(counters,counters+1,sizeof(counters[0])*k);\n                memmove(hotkeys,hotkeys+1,sizeof(hotkeys[0])*k);\n            }\n            counters[k] = freqs[i];\n            hotkeys[k] = sdsnew(keys->element[i]->str);\n            printf(\n               \"[%05.2f%%] Hot key '%s' found so far with counter %llu\\n\",\n               pct, keys->element[i]->str, freqs[i]);\n        }\n\n        \/* Sleep if we've been directed to do so *\/\n        if(sampled && (sampled %100) == 0 && config.interval) {\n            usleep(config.interval);\n        }\n\n        freeReplyObject(reply);\n    } while(it != 0);\n\n    if (freqs) zfree(freqs);\n\n    \/* We're done *\/\n    printf(\"\\n-------- summary -------\\n\\n\");\n\n    printf(\"Sampled %llu keys in the keyspace!\\n\", sampled);\n\n    for (i=1; i<= HOTKEYS_SAMPLE; i++) {\n        k = HOTKEYS_SAMPLE - i;\n        if(counters[k]>0) {\n            printf(\"hot key found with counter: %llu\\tkeyname: %s\\n\", counters[k], hotkeys[k]);\n            sdsfree(hotkeys[k]);\n        }\n    }\n\n    exit(0);\n}","target":0,"code_token_length":766,"total_token_length":1002,"max_tokens_setting":1024}
+{"idx":289620,"func":"int vp9_find_best_sub_pixel_tree ( const MACROBLOCK * x , MV * bestmv , const MV * ref_mv , int allow_hp , int error_per_bit , const vp9_variance_fn_ptr_t * vfp , int forced_stop , int iters_per_step , int * sad_list , int * mvjcost , int * mvcost [ 2 ] , int * distortion , unsigned int * sse1 , const uint8_t * second_pred , int w , int h ) {\n SETUP_SUBPEL_SEARCH ;\n ( void ) sad_list ;\n FIRST_LEVEL_CHECKS ;\n if ( halfiters > 1 ) {\n SECOND_LEVEL_CHECKS ;\n }\n tr = br ;\n tc = bc ;\n if ( forced_stop != 2 ) {\n hstep >>= 1 ;\n FIRST_LEVEL_CHECKS ;\n if ( quarteriters > 1 ) {\n SECOND_LEVEL_CHECKS ;\n }\n tr = br ;\n tc = bc ;\n }\n if ( allow_hp && vp9_use_mv_hp ( ref_mv ) && forced_stop == 0 ) {\n hstep >>= 1 ;\n FIRST_LEVEL_CHECKS ;\n if ( eighthiters > 1 ) {\n SECOND_LEVEL_CHECKS ;\n }\n tr = br ;\n tc = bc ;\n }\n ( void ) tr ;\n ( void ) tc ;\n bestmv -> row = br ;\n bestmv -> col = bc ;\n if ( ( abs ( bestmv -> col - ref_mv -> col ) > ( MAX_FULL_PEL_VAL << 3 ) ) || ( abs ( bestmv -> row - ref_mv -> row ) > ( MAX_FULL_PEL_VAL << 3 ) ) ) return INT_MAX ;\n return besterr ;\n }","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":1507,"func":"static void gx_ttfReader__Read ( ttfReader * self , void * p , int n ) {\n gx_ttfReader * r = ( gx_ttfReader * ) self ;\n const byte * q ;\n if ( ! r -> error ) {\n if ( r -> extra_glyph_index != - 1 ) {\n q = r -> glyph_data . bits . data + r -> pos ;\n r -> error = ( r -> glyph_data . bits . size - r -> pos < n ? gs_note_error ( gs_error_invalidfont ) : 0 ) ;\n if ( r -> error == 0 ) memcpy ( p , q , n ) ;\n }\n else {\n unsigned int cnt ;\n for ( cnt = 0 ;\n cnt < ( uint ) n ;\n cnt += r -> error ) {\n r -> error = r -> pfont -> data . string_proc ( r -> pfont , ( ulong ) r -> pos + cnt , ( ulong ) n - cnt , & q ) ;\n if ( r -> error < 0 ) break ;\n else if ( r -> error == 0 ) {\n memcpy ( ( char * ) p + cnt , q , n - cnt ) ;\n break ;\n }\n else {\n memcpy ( ( char * ) p + cnt , q , r -> error ) ;\n }\n }\n }\n }\n if ( r -> error ) {\n memset ( p , 0 , n ) ;\n return ;\n }\n r -> pos += n ;\n }","target":1,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":355882,"func":"int vmtruncate(struct inode * inode, loff_t offset)\n{\n\tif (inode->i_size < offset) {\n\t\tunsigned long limit;\n\n\t\tlimit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;\n\t\tif (limit != RLIM_INFINITY && offset > limit)\n\t\t\tgoto out_sig;\n\t\tif (offset > inode->i_sb->s_maxbytes)\n\t\t\tgoto out_big;\n\t\ti_size_write(inode, offset);\n\t} else {\n\t\tstruct address_space *mapping = inode->i_mapping;\n\n\t\t\/*\n\t\t * truncation of in-use swapfiles is disallowed - it would\n\t\t * cause subsequent swapout to scribble on the now-freed\n\t\t * blocks.\n\t\t *\/\n\t\tif (IS_SWAPFILE(inode))\n\t\t\treturn -ETXTBSY;\n\t\ti_size_write(inode, offset);\n\n\t\t\/*\n\t\t * unmap_mapping_range is called twice, first simply for\n\t\t * efficiency so that truncate_inode_pages does fewer\n\t\t * single-page unmaps.  However after this first call, and\n\t\t * before truncate_inode_pages finishes, it is possible for\n\t\t * private pages to be COWed, which remain after\n\t\t * truncate_inode_pages finishes, hence the second\n\t\t * unmap_mapping_range call must be made for correctness.\n\t\t *\/\n\t\tunmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);\n\t\ttruncate_inode_pages(mapping, offset);\n\t\tunmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);\n\t}\n\n\tif (inode->i_op && inode->i_op->truncate)\n\t\tinode->i_op->truncate(inode);\n\treturn 0;\n\nout_sig:\n\tsend_sig(SIGXFSZ, current, 0);\nout_big:\n\treturn -EFBIG;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":323081,"func":"vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)\n\n{\n\n    PK11SlotInfo *slot;\n\n    unsigned char *pin_string = NULL;\n\n    int i;\n\n    SECStatus rv;\n\n\n\n    if (!nss_emul_init) {\n\n        return VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED;\n\n    }\n\n    slot = vcard_emul_card_get_slot(card);\n\n     \/* We depend on the PKCS #11 module internal login state here because we\n\n      * create a separate process to handle each guest instance. If we needed\n\n      * to handle multiple guests from one process, then we would need to keep\n\n      * a lot of extra state in our card structure\n\n      * *\/\n\n    pin_string = g_malloc(pin_len+1);\n\n    memcpy(pin_string, pin, pin_len);\n\n    pin_string[pin_len] = 0;\n\n\n\n    \/* handle CAC expanded pins correctly *\/\n\n    for (i = pin_len-1; i >= 0 && (pin_string[i] == 0xff); i--) {\n\n        pin_string[i] = 0;\n\n    }\n\n\n\n    rv = PK11_Authenticate(slot, PR_FALSE, pin_string);\n\n    memset(pin_string, 0, pin_len);  \/* don't let the pin hang around in memory\n\n                                        to be snooped *\/\n\n    g_free(pin_string);\n\n    if (rv == SECSuccess) {\n\n        return VCARD7816_STATUS_SUCCESS;\n\n    }\n\n    \/* map the error from port get error *\/\n\n    return VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED;\n\n}\n","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":97491,"func":"static opj_pi_iterator_t * opj_pi_create(const opj_image_t *image,\n        const opj_cp_t *cp,\n        OPJ_UINT32 tileno)\n{\n    \/* loop*\/\n    OPJ_UINT32 pino, compno;\n    \/* number of poc in the p_pi*\/\n    OPJ_UINT32 l_poc_bound;\n\n    \/* pointers to tile coding parameters and components.*\/\n    opj_pi_iterator_t *l_pi = 00;\n    opj_tcp_t *tcp = 00;\n    const opj_tccp_t *tccp = 00;\n\n    \/* current packet iterator being allocated*\/\n    opj_pi_iterator_t *l_current_pi = 00;\n\n    \/* preconditions in debug*\/\n    assert(cp != 00);\n    assert(image != 00);\n    assert(tileno < cp->tw * cp->th);\n\n    \/* initializations*\/\n    tcp = &cp->tcps[tileno];\n    l_poc_bound = tcp->numpocs + 1;\n\n    \/* memory allocations*\/\n    l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound),\n                                           sizeof(opj_pi_iterator_t));\n    if (!l_pi) {\n        return NULL;\n    }\n\n    l_current_pi = l_pi;\n    for (pino = 0; pino < l_poc_bound ; ++pino) {\n\n        l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps,\n                              sizeof(opj_pi_comp_t));\n        if (! l_current_pi->comps) {\n            opj_pi_destroy(l_pi, l_poc_bound);\n            return NULL;\n        }\n\n        l_current_pi->numcomps = image->numcomps;\n\n        for (compno = 0; compno < image->numcomps; ++compno) {\n            opj_pi_comp_t *comp = &l_current_pi->comps[compno];\n\n            tccp = &tcp->tccps[compno];\n\n            comp->resolutions = (opj_pi_resolution_t*) opj_calloc(tccp->numresolutions,\n                                sizeof(opj_pi_resolution_t));\n            if (!comp->resolutions) {\n                opj_pi_destroy(l_pi, l_poc_bound);\n                return 00;\n            }\n\n            comp->numresolutions = tccp->numresolutions;\n        }\n        ++l_current_pi;\n    }\n    return l_pi;\n}","target":0,"code_token_length":527,"total_token_length":763,"max_tokens_setting":1024}
+{"idx":114278,"func":"PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout)\n{\n\tif (TIMESTAMP_NOT_FINITE(*tin))\n\t\t*tout = *tin;\n\n\n\telse\n\t{\n\t\tif (span->month != 0)\n\t\t{\n\t\t\tstruct tm\ttt,\n\t\t\t\t\t   *tm = &tt;\n\t\t\tfsec_t\t\tfsec;\n\n\n\t\t\tif (timestamp2tm(*tin, NULL, tm, &fsec, NULL) != 0)\n\t\t\t\treturn -1;\n\t\t\ttm->tm_mon += span->month;\n\t\t\tif (tm->tm_mon > MONTHS_PER_YEAR)\n\t\t\t{\n\t\t\t\ttm->tm_year += (tm->tm_mon - 1) \/ MONTHS_PER_YEAR;\n\t\t\t\ttm->tm_mon = (tm->tm_mon - 1) % MONTHS_PER_YEAR + 1;\n\t\t\t}\n\t\t\telse if (tm->tm_mon < 1)\n\t\t\t{\n\t\t\t\ttm->tm_year += tm->tm_mon \/ MONTHS_PER_YEAR - 1;\n\t\t\t\ttm->tm_mon = tm->tm_mon % MONTHS_PER_YEAR + MONTHS_PER_YEAR;\n\t\t\t}\n\n\n\t\t\t\/* adjust for end of month boundary problems... *\/\n\t\t\tif (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1])\n\t\t\t\ttm->tm_mday = (day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]);\n\n\n\t\t\tif (tm2timestamp(tm, fsec, NULL, tin) != 0)\n\t\t\t\treturn -1;\n\t\t}\n\n\n\t\t*tin += span->time;\n\t\t*tout = *tin;\n\t}\n\treturn 0;\n\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":495455,"func":"njs_string_prototype_to_lower_case(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    size_t             size, length;\n    u_char             *p;\n    uint32_t           code;\n    njs_int_t          ret;\n    const u_char       *s, *end;\n    njs_string_prop_t  string;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    (void) njs_string_prop(&string, njs_argument(args, 0));\n\n    if (njs_is_byte_or_ascii_string(&string)) {\n\n        p = njs_string_alloc(vm, &vm->retval, string.size, string.length);\n        if (njs_slow_path(p == NULL)) {\n            return NJS_ERROR;\n        }\n\n        s = string.start;\n        size = string.size;\n\n        while (size != 0) {\n            *p++ = njs_lower_case(*s++);\n            size--;\n        }\n\n    } else {\n        \/* UTF-8 string. *\/\n        s = string.start;\n        end = s + string.size;\n        length = string.length;\n\n        size = 0;\n\n        while (length != 0) {\n            code = njs_utf8_lower_case(&s, end);\n            size += njs_utf8_size(code);\n            length--;\n        }\n\n        p = njs_string_alloc(vm, &vm->retval, size, string.length);\n        if (njs_slow_path(p == NULL)) {\n            return NJS_ERROR;\n        }\n\n        s = string.start;\n        length = string.length;\n\n        while (length != 0) {\n            code = njs_utf8_lower_case(&s, end);\n            p = njs_utf8_encode(p, code);\n            length--;\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":82313,"func":"int gdImageCompare (gdImagePtr im1, gdImagePtr im2)\n{\n\tint x, y;\n\tint p1, p2;\n\tint cmpStatus = 0;\n\tint sx, sy;\n\n\tif (im1->interlace != im2->interlace) {\n\t\tcmpStatus |= GD_CMP_INTERLACE;\n\t}\n\n\tif (im1->transparent != im2->transparent) {\n\t\tcmpStatus |= GD_CMP_TRANSPARENT;\n\t}\n\n\tif (im1->trueColor != im2->trueColor) {\n\t\tcmpStatus |= GD_CMP_TRUECOLOR;\n\t}\n\n\tsx = im1->sx;\n\tif (im1->sx != im2->sx) {\n\t\tcmpStatus |= GD_CMP_SIZE_X + GD_CMP_IMAGE;\n\t\tif (im2->sx < im1->sx) {\n\t\t\tsx = im2->sx;\n\t\t}\n\t}\n\n\tsy = im1->sy;\n\tif (im1->sy != im2->sy) {\n\t\tcmpStatus |= GD_CMP_SIZE_Y + GD_CMP_IMAGE;\n\t\tif (im2->sy < im1->sy) {\n\t\t\tsy = im2->sy;\n\t\t}\n\t}\n\n\tif (im1->colorsTotal != im2->colorsTotal) {\n\t\tcmpStatus |= GD_CMP_NUM_COLORS;\n\t}\n\n\tfor (y = 0; y < sy; y++) {\n\t\tfor (x = 0; x < sx; x++) {\n\t\t\tp1 = im1->trueColor ? gdImageTrueColorPixel(im1, x, y) : gdImagePalettePixel(im1, x, y);\n\t\t\tp2 = im2->trueColor ? gdImageTrueColorPixel(im2, x, y) : gdImagePalettePixel(im2, x, y);\n\n\t\t\tif (gdImageRed(im1, p1) != gdImageRed(im2, p2)) {\n\t\t\t\tcmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (gdImageGreen(im1, p1) != gdImageGreen(im2, p2)) {\n\t\t\t\tcmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (gdImageBlue(im1, p1) != gdImageBlue(im2, p2)) {\n\t\t\t\tcmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;\n\t\t\t\tbreak;\n\t\t\t}\n#if 0\n\t\t\t\/* Soon we'll add alpha channel to palettes *\/\n\t\t\tif (gdImageAlpha(im1, p1) != gdImageAlpha(im2, p2)) {\n\t\t\t\tcmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;\n\t\t\t\tbreak;\n\t\t\t}\n#endif\n\t\t}\n\t\tif (cmpStatus & GD_CMP_COLOR) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn cmpStatus;\n}","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":334986,"func":"static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst, int width, int height) {\n\n    unsigned char *dst_end = dst + width*height;\n\n    int size,size1,size2,offset,run;\n\n    unsigned char *dst_start = dst;\n\n\n\n    if (src[0] & 0x01)\n\n        src += 5;\n\n    else\n\n        src += 2;\n\n\n\n    if (src+3>src_end)\n\n        return -1;\n\n    size = AV_RB24(src);\n\n    src += 3;\n\n\n\n    while(size>0 && src<src_end) {\n\n\n\n        \/* determine size1 and size2 *\/\n\n        size1 = (src[0] & 3);\n\n        if ( src[0] & 0x80 ) {  \/\/ 1\n\n            if (src[0] & 0x40 ) {  \/\/ 11\n\n                if ( src[0] & 0x20 ) {  \/\/ 111\n\n                    if ( src[0] < 0xFC )  \/\/ !(111111)\n\n                        size1 = (((src[0] & 31) + 1) << 2);\n\n                    src++;\n\n                    size2 = 0;\n\n                } else {  \/\/ 110\n\n                    offset = ((src[0] & 0x10) << 12) + AV_RB16(&src[1]) + 1;\n\n                    size2 = ((src[0] & 0xC) << 6) + src[3] + 5;\n\n                    src += 4;\n\n                }\n\n            } else {  \/\/ 10\n\n                size1 = ( ( src[1] & 0xC0) >> 6 );\n\n                offset = (AV_RB16(&src[1]) & 0x3FFF) + 1;\n\n                size2 = (src[0] & 0x3F) + 4;\n\n                src += 3;\n\n            }\n\n        } else {  \/\/ 0\n\n            offset = ((src[0] & 0x60) << 3) + src[1] + 1;\n\n            size2 = ((src[0] & 0x1C) >> 2) + 3;\n\n            src += 2;\n\n        }\n\n\n\n\n\n        \/* fetch strip from src *\/\n\n        if (size1>src_end-src)\n\n            break;\n\n\n\n        if (size1>0) {\n\n            size -= size1;\n\n            run = FFMIN(size1, dst_end-dst);\n\n            memcpy(dst, src, run);\n\n            dst += run;\n\n            src += run;\n\n        }\n\n\n\n        if (size2>0) {\n\n            if (dst-dst_start<offset)\n\n                return 0;\n\n            size -= size2;\n\n            run = FFMIN(size2, dst_end-dst);\n\n            av_memcpy_backptr(dst, offset, run);\n\n            dst += run;\n\n        }\n\n    }\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":303286,"func":"static void DumpVirtIOFeatures(PPARANDIS_ADAPTER pContext)\n{\n    static const struct {  ULONG bitmask;  PCHAR Name; } Features[] =\n    {\n\n        {VIRTIO_NET_F_CSUM, \"VIRTIO_NET_F_CSUM\" },\n        {VIRTIO_NET_F_GUEST_CSUM, \"VIRTIO_NET_F_GUEST_CSUM\" },\n        {VIRTIO_NET_F_MAC, \"VIRTIO_NET_F_MAC\" },\n        {VIRTIO_NET_F_GSO, \"VIRTIO_NET_F_GSO\" },\n        {VIRTIO_NET_F_GUEST_TSO4, \"VIRTIO_NET_F_GUEST_TSO4\"},\n        {VIRTIO_NET_F_GUEST_TSO6, \"VIRTIO_NET_F_GUEST_TSO6\"},\n        {VIRTIO_NET_F_GUEST_ECN, \"VIRTIO_NET_F_GUEST_ECN\"},\n        {VIRTIO_NET_F_GUEST_UFO, \"VIRTIO_NET_F_GUEST_UFO\"},\n        {VIRTIO_NET_F_HOST_TSO4, \"VIRTIO_NET_F_HOST_TSO4\"},\n        {VIRTIO_NET_F_HOST_TSO6, \"VIRTIO_NET_F_HOST_TSO6\"},\n        {VIRTIO_NET_F_HOST_ECN, \"VIRTIO_NET_F_HOST_ECN\"},\n        {VIRTIO_NET_F_HOST_UFO, \"VIRTIO_NET_F_HOST_UFO\"},\n        {VIRTIO_NET_F_MRG_RXBUF, \"VIRTIO_NET_F_MRG_RXBUF\"},\n        {VIRTIO_NET_F_STATUS, \"VIRTIO_NET_F_STATUS\"},\n        {VIRTIO_NET_F_CTRL_VQ, \"VIRTIO_NET_F_CTRL_VQ\"},\n        {VIRTIO_NET_F_CTRL_RX, \"VIRTIO_NET_F_CTRL_RX\"},\n        {VIRTIO_NET_F_CTRL_VLAN, \"VIRTIO_NET_F_CTRL_VLAN\"},\n        {VIRTIO_NET_F_CTRL_RX_EXTRA, \"VIRTIO_NET_F_CTRL_RX_EXTRA\"},\n        {VIRTIO_NET_F_CTRL_MAC_ADDR, \"VIRTIO_NET_F_CTRL_MAC_ADDR\"},\n        {VIRTIO_F_INDIRECT, \"VIRTIO_F_INDIRECT\"},\n        {VIRTIO_F_ANY_LAYOUT, \"VIRTIO_F_ANY_LAYOUT\"},\n        { VIRTIO_RING_F_EVENT_IDX, \"VIRTIO_RING_F_EVENT_IDX\" },\n    };\n    UINT i;\n    for (i = 0; i < sizeof(Features)\/sizeof(Features[0]); ++i)\n    {\n        if (VirtIOIsFeatureEnabled(pContext->u32HostFeatures, Features[i].bitmask))\n        {\n            DPrintf(0, (\"VirtIO Host Feature %s\\n\", Features[i].Name));\n        }\n    }\n}","target":0,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":91555,"func":"void CLASS stretch()\n{\n  ushort newdim, (*img)[4], *pix0, *pix1;\n  int row, col, c;\n  double rc, frac;\n\n  if (pixel_aspect == 1) return;\n  dcraw_message (DCRAW_VERBOSE,_(\"Stretching the image...\\n\"));\n  if (pixel_aspect < 1) {\n    newdim = height \/ pixel_aspect + 0.5;\n    img = (ushort (*)[4]) calloc (width*newdim, sizeof *img);\n    merror (img, \"stretch()\");\n    for (rc=row=0; row < newdim; row++, rc+=pixel_aspect) {\n      frac = rc - (c = rc);\n      pix0 = pix1 = image[c*width];\n      if (c+1 < height) pix1 += width*4;\n      for (col=0; col < width; col++, pix0+=4, pix1+=4)\n\tFORCC img[row*width+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;\n    }\n    height = newdim;\n  } else {\n    newdim = width * pixel_aspect + 0.5;\n    img = (ushort (*)[4]) calloc (height*newdim, sizeof *img);\n    merror (img, \"stretch()\");\n    for (rc=col=0; col < newdim; col++, rc+=1\/pixel_aspect) {\n      frac = rc - (c = rc);\n      pix0 = pix1 = image[c];\n      if (c+1 < width) pix1 += 4;\n      for (row=0; row < height; row++, pix0+=width*4, pix1+=width*4)\n\tFORCC img[row*newdim+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;\n    }\n    width = newdim;\n  }\n  free (image);\n  image = img;\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":358139,"func":"int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,\n\t\t     filldir_t filldir)\n{\n\tstruct file\t*file = desc->file;\n\tstruct inode\t*inode = file->f_path.dentry->d_inode;\n\tstruct rpc_cred\t*cred = nfs_file_cred(file);\n\tstruct page\t*page = NULL;\n\tint\t\tstatus;\n\tunsigned long\ttimestamp;\n\n\tdfprintk(DIRCACHE, \"NFS: uncached_readdir() searching for cookie %Lu\\n\",\n\t\t\t(unsigned long long)*desc->dir_cookie);\n\n\tpage = alloc_page(GFP_HIGHUSER);\n\tif (!page) {\n\t\tstatus = -ENOMEM;\n\t\tgoto out;\n\t}\n\ttimestamp = jiffies;\n\tdesc->error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, *desc->dir_cookie,\n\t\t\t\t\t\tpage,\n\t\t\t\t\t\tNFS_SERVER(inode)->dtsize,\n\t\t\t\t\t\tdesc->plus);\n\tspin_lock(&inode->i_lock);\n\tNFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;\n\tspin_unlock(&inode->i_lock);\n\tdesc->page = page;\n\tdesc->ptr = kmap(page);\t\t\/* matching kunmap in nfs_do_filldir *\/\n\tif (desc->error >= 0) {\n\t\tdesc->timestamp = timestamp;\n\t\tdesc->timestamp_valid = 1;\n\t\tif ((status = dir_decode(desc)) == 0)\n\t\t\tdesc->entry->prev_cookie = *desc->dir_cookie;\n\t} else\n\t\tstatus = -EIO;\n\tif (status < 0)\n\t\tgoto out_release;\n\n\tstatus = nfs_do_filldir(desc, dirent, filldir);\n\n\t\/* Reset read descriptor so it searches the page cache from\n\t * the start upon the next call to readdir_search_pagecache() *\/\n\tdesc->page_index = 0;\n\tdesc->entry->cookie = desc->entry->prev_cookie = 0;\n\tdesc->entry->eof = 0;\n out:\n\tdfprintk(DIRCACHE, \"NFS: %s: returns %d\\n\",\n\t\t\t__FUNCTION__, status);\n\treturn status;\n out_release:\n\tdir_page_release(desc);\n\tgoto out;\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":448858,"func":"art_pdf_knockout_composite_pixel_alpha_8(byte *gs_restrict backdrop, byte tos_shape, byte *gs_restrict dst,\n                        const byte *gs_restrict src, int n_chan, gs_blend_mode_t blend_mode,\n                        const pdf14_nonseparable_blending_procs_t * pblend_procs,\n                        pdf14_device *p14dev)\n{\n    byte a_b, a_s;\n    unsigned int a_r;\n    int tmp;\n    int src_scale;\n    int c_b, c_s;\n    int i;\n\n    a_s = src[n_chan];\n    a_b = backdrop[n_chan];\n    if (a_s == 0) {\n        \/* source alpha is zero, if we have a src shape value there then copy\n           the backdrop, else leave it alone *\/\n        if (tos_shape)\n           memcpy(dst, backdrop, n_chan + 1);\n        return;\n    }\n\n    \/* In this case a_s is not zero *\/\n    if (a_b == 0) {\n        \/* backdrop alpha is zero but not source alpha, just copy source pixels and\n           avoid computation. *\/\n        memcpy(dst, src, n_chan + 1);\n        return;\n    }\n\n    \/* Result alpha is Union of backdrop and source alpha *\/\n    tmp = (0xff - a_b) * (0xff - a_s) + 0x80;\n    a_r = 0xff - (((tmp >> 8) + tmp) >> 8);\n    \/* todo: verify that a_r is nonzero in all cases *\/\n\n    \/* Compute a_s \/ a_r in 16.16 format *\/\n    src_scale = ((a_s << 16) + (a_r >> 1)) \/ a_r;\n\n    if (blend_mode == BLEND_MODE_Normal) {\n        \/* Do simple compositing of source over backdrop *\/\n        for (i = 0; i < n_chan; i++) {\n            c_s = src[i];\n            c_b = backdrop[i];\n            tmp = (c_b << 16) + src_scale * (c_s - c_b) + 0x8000;\n            dst[i] = tmp >> 16;\n        }\n    } else {\n        \/* Do compositing with blending *\/\n        byte blend[ART_MAX_CHAN];\n\n        art_blend_pixel_8(blend, backdrop, src, n_chan, blend_mode, pblend_procs,\n                        p14dev);\n        for (i = 0; i < n_chan; i++) {\n            int c_bl;\t\t\/* Result of blend function *\/\n            int c_mix;\t\t\/* Blend result mixed with source color *\/\n\n            c_s = src[i];\n            c_b = backdrop[i];\n            c_bl = blend[i];\n            tmp = a_b * (c_bl - ((int)c_s)) + 0x80;\n            c_mix = c_s + (((tmp >> 8) + tmp) >> 8);\n            tmp = (c_b << 16) + src_scale * (c_mix - c_b) + 0x8000;\n            dst[i] = tmp >> 16;\n        }\n    }\n    dst[n_chan] = a_r;\n}","target":0,"code_token_length":671,"total_token_length":907,"max_tokens_setting":1024}
+{"idx":495489,"func":"njs_string_instance_length(njs_vm_t *vm, njs_object_prop_t *prop,\n    njs_value_t *value, njs_value_t *setval, njs_value_t *retval)\n{\n    size_t              size;\n    uintptr_t           length;\n    njs_object_t        *proto;\n    njs_object_value_t  *ov;\n\n    \/*\n     * This getter can be called for string primitive, String object,\n     * String.prototype.  The zero should be returned for the latter case.\n     *\/\n    length = 0;\n\n    if (njs_slow_path(njs_is_object(value))) {\n        proto = njs_object(value);\n\n        do {\n            if (njs_fast_path(proto->type == NJS_OBJECT_VALUE)) {\n                break;\n            }\n\n            proto = proto->__proto__;\n        } while (proto != NULL);\n\n        if (proto != NULL) {\n            ov = (njs_object_value_t *) proto;\n            value = &ov->value;\n        }\n    }\n\n    if (njs_is_string(value)) {\n        size = value->short_string.size;\n        length = value->short_string.length;\n\n        if (size == NJS_STRING_LONG) {\n            size = value->long_string.size;\n            length = value->long_string.data->length;\n        }\n\n        length = (length == 0) ? size : length;\n    }\n\n    njs_set_number(retval, length);\n\n    njs_release(vm, value);\n\n    return NJS_OK;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":399385,"func":"static int kthread(void *_create)\n{\n\t\/* Copy data: it's on kthread's stack *\/\n\tstruct kthread_create_info *create = _create;\n\tint (*threadfn)(void *data) = create->threadfn;\n\tvoid *data = create->data;\n\tstruct completion *done;\n\tstruct kthread *self;\n\tint ret;\n\n\tself = kmalloc(sizeof(*self), GFP_KERNEL);\n\tset_kthread_struct(self);\n\n\t\/* If user was SIGKILLed, I release the structure. *\/\n\tdone = xchg(&create->done, NULL);\n\tif (!done) {\n\t\tkfree(create);\n\t\tdo_exit(-EINTR);\n\t}\n\n\tif (!self) {\n\t\tcreate->result = ERR_PTR(-ENOMEM);\n\t\tcomplete(done);\n\t\tdo_exit(-ENOMEM);\n\t}\n\n\tself->flags = 0;\n\tself->data = data;\n\tinit_completion(&self->exited);\n\tinit_completion(&self->parked);\n\tcurrent->vfork_done = &self->exited;\n\n\t\/* OK, tell user we're spawned, wait for stop or wakeup *\/\n\t__set_current_state(TASK_UNINTERRUPTIBLE);\n\tcreate->result = current;\n\tcomplete(done);\n\tschedule();\n\n\tret = -EINTR;\n\tif (!test_bit(KTHREAD_SHOULD_STOP, &self->flags)) {\n\t\t__kthread_parkme(self);\n\t\tret = threadfn(data);\n\t}\n\tdo_exit(ret);\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":273234,"func":"static journal_t *ext4_get_journal(struct super_block *sb,\n\t\t\t\t   unsigned int journal_inum)\n{\n\tstruct inode *journal_inode;\n\tjournal_t *journal;\n\n\tBUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));\n\n\t\/* First, test for the existence of a valid inode on disk.  Bad\n\t * things happen if we iget() an unused inode, as the subsequent\n\t * iput() will try to delete it. *\/\n\n\tjournal_inode = ext4_iget(sb, journal_inum);\n\tif (IS_ERR(journal_inode)) {\n\t\text4_msg(sb, KERN_ERR, \"no journal found\");\n\t\treturn NULL;\n\t}\n\tif (!journal_inode->i_nlink) {\n\t\tmake_bad_inode(journal_inode);\n\t\tiput(journal_inode);\n\t\text4_msg(sb, KERN_ERR, \"journal inode is deleted\");\n\t\treturn NULL;\n\t}\n\n\tjbd_debug(2, \"Journal inode found at %p: %lld bytes\\n\",\n\t\t  journal_inode, journal_inode->i_size);\n\tif (!S_ISREG(journal_inode->i_mode)) {\n\t\text4_msg(sb, KERN_ERR, \"invalid journal inode\");\n\t\tiput(journal_inode);\n\t\treturn NULL;\n\t}\n\n\tjournal = jbd2_journal_init_inode(journal_inode);\n\tif (!journal) {\n\t\text4_msg(sb, KERN_ERR, \"Could not load journal inode\");\n\t\tiput(journal_inode);\n\t\treturn NULL;\n\t}\n\tjournal->j_private = sb;\n\text4_init_journal_params(sb, journal);\n\treturn journal;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":388229,"func":"static noinline int btrfs_mksubvol(struct path *parent,\n\t\t\t\t   char *name, int namelen,\n\t\t\t\t   struct btrfs_root *snap_src,\n\t\t\t\t   u64 *async_transid, bool readonly,\n\t\t\t\t   struct btrfs_qgroup_inherit *inherit)\n{\n\tstruct inode *dir  = d_inode(parent->dentry);\n\tstruct dentry *dentry;\n\tint error;\n\n\terror = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT);\n\tif (error == -EINTR)\n\t\treturn error;\n\n\tdentry = lookup_one_len(name, parent->dentry, namelen);\n\terror = PTR_ERR(dentry);\n\tif (IS_ERR(dentry))\n\t\tgoto out_unlock;\n\n\terror = -EEXIST;\n\tif (d_really_is_positive(dentry))\n\t\tgoto out_dput;\n\n\terror = btrfs_may_create(dir, dentry);\n\tif (error)\n\t\tgoto out_dput;\n\n\t\/*\n\t * even if this name doesn't exist, we may get hash collisions.\n\t * check for them now when we can safely fail\n\t *\/\n\terror = btrfs_check_dir_item_collision(BTRFS_I(dir)->root,\n\t\t\t\t\t       dir->i_ino, name,\n\t\t\t\t\t       namelen);\n\tif (error)\n\t\tgoto out_dput;\n\n\tdown_read(&BTRFS_I(dir)->root->fs_info->subvol_sem);\n\n\tif (btrfs_root_refs(&BTRFS_I(dir)->root->root_item) == 0)\n\t\tgoto out_up_read;\n\n\tif (snap_src) {\n\t\terror = create_snapshot(snap_src, dir, dentry, name, namelen,\n\t\t\t\t\tasync_transid, readonly, inherit);\n\t} else {\n\t\terror = create_subvol(dir, dentry, name, namelen,\n\t\t\t\t      async_transid, inherit);\n\t}\n\tif (!error)\n\t\tfsnotify_mkdir(dir, dentry);\nout_up_read:\n\tup_read(&BTRFS_I(dir)->root->fs_info->subvol_sem);\nout_dput:\n\tdput(dentry);\nout_unlock:\n\tmutex_unlock(&dir->i_mutex);\n\treturn error;\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":262457,"func":"error_t mqttSnClientProcessEvents(MqttSnClientContext *context,\n   systime_t timeout)\n{\n   error_t error;\n   systime_t d;\n   systime_t startTime;\n   systime_t currentTime;\n   IpAddr ipAddr;\n   uint16_t port;\n\n   \/\/Flush buffer\n   context->message.length = 0;\n\n   \/\/Save current time\n   currentTime = osGetSystemTime();\n   startTime = currentTime;\n\n   \/\/Initialize status code\n   error = NO_ERROR;\n\n   \/\/Process events\n   do\n   {\n      \/\/Maximum time to wait for an incoming datagram\n      if(timeCompare(startTime + timeout, currentTime) > 0)\n         d = startTime + timeout - currentTime;\n      else\n         d = 0;\n\n      \/\/Limit the delay\n      d = MIN(d, MQTT_SN_CLIENT_TICK_INTERVAL);\n\n      \/\/Wait for an incoming datagram\n      error = mqttSnClientReceiveDatagram(context, &ipAddr, &port,\n         context->message.buffer, MQTT_SN_MAX_MSG_SIZE,\n         &context->message.length, d);\n\n      \/\/Get current time\n      currentTime = osGetSystemTime();\n\n      \/\/Any datagram received?\n      if(error == NO_ERROR)\n      {\n         \/\/Terminate the payload with a NULL character\n         context->message.buffer[context->message.length] = '\\0';\n\n         \/\/Process the received MQTT-SN message\n         mqttSnClientProcessMessage(context, &context->message, &ipAddr, port);\n      }\n      else if(error == ERROR_WOULD_BLOCK || error == ERROR_TIMEOUT)\n      {\n         \/\/No datagram has been received\n         error = NO_ERROR;\n      }\n      else\n      {\n         \/\/A communication error has occurred\n      }\n\n      \/\/Check status code\n      if(!error)\n      {\n         \/\/A keep-alive value of zero has the effect of turning off the keep\n         \/\/alive mechanism\n         if(context->keepAlive != 0)\n         {\n            \/\/Make sure the MQTT-SN client is connected\n            if(context->state == MQTT_SN_CLIENT_STATE_ACTIVE ||\n               context->state == MQTT_SN_CLIENT_STATE_SENDING_REQ ||\n               context->state == MQTT_SN_CLIENT_STATE_RESP_RECEIVED)\n            {\n               \/\/Check whether the keep-alive timer has expired\n               if(timeCompare(currentTime, context->keepAliveTimestamp +\n                  context->keepAlive) >= 0)\n               {\n                  \/\/Check retransmission counter\n                  if(context->keepAliveCounter < MQTT_SN_CLIENT_MAX_KEEP_ALIVE_PROBES)\n                  {\n                     \/\/Send a PINGREQ message to the gateway\n                     error = mqttSnClientSendPingReq(context);\n\n                     \/\/Increment retransmission counter\n                     context->keepAliveCounter++;\n                  }\n                  else\n                  {\n                     \/\/If a client does not receive a PINGRESP from the gateway\n                     \/\/even after multiple retransmissions of the PINGREQ message,\n                     \/\/then the gateway is considered offline\n                     context->state = MQTT_SN_CLIENT_STATE_DISCONNECTING;\n\n                     \/\/The connection is lost\n                     error = ERROR_NOT_CONNECTED;\n                  }\n               }\n            }\n         }\n      }\n\n      \/\/Check whether the timeout has elapsed\n   } while(error == NO_ERROR && context->message.length == 0 && d > 0);\n\n   \/\/Return status code\n   return error;\n}","target":0,"code_token_length":685,"total_token_length":921,"max_tokens_setting":1024}
+{"idx":518154,"func":"void Item_string::print(String *str, enum_query_type query_type)\n{\n  const bool print_introducer=\n    !(query_type & QT_WITHOUT_INTRODUCERS) && is_cs_specified();\n  if (print_introducer)\n  {\n    str->append('_');\n    str->append(collation.collation->csname);\n  }\n\n  str->append('\\'');\n\n  if (query_type & QT_TO_SYSTEM_CHARSET)\n  {\n    if (print_introducer)\n    {\n      \/*\n        Because we wrote an introducer, we must print str_value in its\n        charset, and the resulting bytes must not be changed until they\n        reach the end client.\n        But the caller is asking for system_charset_info, and may later\n        convert into character_set_results. That means two conversions: we\n        must ensure that they don't change our printed bytes.\n        So we print str_value in the least common denominator of the three\n        charsets involved: ASCII. Non-ASCII characters are printed as \\xFF\n        sequences (which is ASCII too). This way, our bytes will not be\n        changed.\n      *\/\n      ErrConvString tmp(str_value.ptr(), str_value.length(), &my_charset_bin);\n      str->append(tmp.ptr());\n    }\n    else\n    {\n      str_value.print(str, system_charset_info);\n    }\n  }\n  else\n  {\n    \/*\n      We're restoring a parse-able statement from an Item tree.\n      Make sure to revert character set conversions that previously\n      happened in the parser when Item_string was created.\n    *\/\n    if (print_introducer)\n    {\n      \/*\n        Print the string as is, without conversion:\n        Strings with introducers are not converted in the parser.\n      *\/\n      str_value.print(str);\n    }\n    else\n    {\n      \/*\n        Print the string with conversion.\n        Strings without introducers are converted in the parser,\n        from character_set_client to character_set_connection.\n\n        When restoring a CREATE VIEW statement,\n        - str_value.charsets() contains parse time character_set_connection\n        - str->charset() contains parse time character_set_client\n        So we convert the string back from parse-time character_set_connection\n        to parse time character_set_client.\n\n        In some cases, e.g. SHOW PROCEDURE CODE, it's also possible\n        that str->charset() is \"utf8mb3\" instead of parse time\n        character_set_client. In these cases we convert\n        here from the parse-time character_set_connection to utf8mb3.\n\n        QQ: perhaps the code behind SHOW PROCEDURE CODE should\n        also request the result in the parse-time character_set_client\n        (like the code restoring CREATE VIEW statements does),\n        rather than in utf8mb3:\n        - utf8mb3 does not work well with non-BMP characters (e.g. emoji).\n        - Simply changing utf8mb3 to utf8mb4 will not fully help:\n          some character sets have unassigned characters,\n          they get lost during during cs->utf8mb4->cs round trip.\n      *\/\n      str_value.print_with_conversion(str, str->charset());\n    }\n  }\n\n  str->append('\\'');\n}","target":0,"code_token_length":663,"total_token_length":899,"max_tokens_setting":1024}
+{"idx":184915,"func":"void LoginDisplayHostWebUI::OnStartSignInScreen(\n    const LoginScreenContext& context) {\n  DisableKeyboardOverscroll();\n\n  restore_path_ = RESTORE_SIGN_IN;\n  is_showing_login_ = true;\n  if (features::IsAshInBrowserProcess())\n    finalize_animation_type_ = ANIMATION_WORKSPACE;\n\n  if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) {\n    VLOG(1) << \"Login WebUI >> sign in postponed\";\n    return;\n  }\n  VLOG(1) << \"Login WebUI >> sign in\";\n\n  if (!login_window_) {\n    TRACE_EVENT_ASYNC_BEGIN0(\"ui\", \"ShowLoginWebUI\", kShowLoginWebUIid);\n    TRACE_EVENT_ASYNC_STEP_INTO0(\"ui\", \"ShowLoginWebUI\", kShowLoginWebUIid,\n                                 \"StartSignInScreen\");\n    BootTimesRecorder::Get()->RecordCurrentStats(\"login-start-signin-screen\");\n    LoadURL(GURL(kLoginURL));\n  }\n\n  DVLOG(1) << \"Starting sign in screen\";\n  CreateExistingUserController();\n\n  if (!signin_screen_controller_.get()) {\n    signin_screen_controller_.reset(new SignInScreenController(GetOobeUI()));\n  }\n\n  oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered();\n  SetOobeProgressBarVisible(oobe_progress_bar_visible_);\n  existing_user_controller_->Init(user_manager::UserManager::Get()->GetUsers());\n\n  CHECK(login_display_);\n  GetOobeUI()->ShowSigninScreen(context, login_display_.get(),\n                                login_display_.get());\n  TRACE_EVENT_ASYNC_STEP_INTO0(\"ui\", \"ShowLoginWebUI\", kShowLoginWebUIid,\n                               \"WaitForScreenStateInitialize\");\n\n  BootTimesRecorder::Get()->RecordCurrentStats(\n      \"login-wait-for-signin-state-initialize\");\n}\n","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":292546,"func":"static void iwl_fwrt_dump_txf(struct iwl_fw_runtime *fwrt,\n\t\t\t      struct iwl_fw_error_dump_data **dump_data,\n\t\t\t      int size, u32 offset, int fifo_num)\n{\n\tstruct iwl_fw_error_dump_fifo *fifo_hdr;\n\tu32 *fifo_data;\n\tu32 fifo_len;\n\tint i;\n\n\tfifo_hdr = (void *)(*dump_data)->data;\n\tfifo_data = (void *)fifo_hdr->data;\n\tfifo_len = size;\n\n\t\/* No need to try to read the data if the length is 0 *\/\n\tif (fifo_len == 0)\n\t\treturn;\n\n\t\/* Add a TLV for the FIFO *\/\n\t(*dump_data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXF);\n\t(*dump_data)->len = cpu_to_le32(fifo_len + sizeof(*fifo_hdr));\n\n\tfifo_hdr->fifo_num = cpu_to_le32(fifo_num);\n\tfifo_hdr->available_bytes =\n\t\tcpu_to_le32(iwl_trans_read_prph(fwrt->trans,\n\t\t\t\t\t\tTXF_FIFO_ITEM_CNT + offset));\n\tfifo_hdr->wr_ptr =\n\t\tcpu_to_le32(iwl_trans_read_prph(fwrt->trans,\n\t\t\t\t\t\tTXF_WR_PTR + offset));\n\tfifo_hdr->rd_ptr =\n\t\tcpu_to_le32(iwl_trans_read_prph(fwrt->trans,\n\t\t\t\t\t\tTXF_RD_PTR + offset));\n\tfifo_hdr->fence_ptr =\n\t\tcpu_to_le32(iwl_trans_read_prph(fwrt->trans,\n\t\t\t\t\t\tTXF_FENCE_PTR + offset));\n\tfifo_hdr->fence_mode =\n\t\tcpu_to_le32(iwl_trans_read_prph(fwrt->trans,\n\t\t\t\t\t\tTXF_LOCK_FENCE + offset));\n\n\t\/* Set the TXF_READ_MODIFY_ADDR to TXF_WR_PTR *\/\n\tiwl_trans_write_prph(fwrt->trans, TXF_READ_MODIFY_ADDR + offset,\n\t\t\t     TXF_WR_PTR + offset);\n\n\t\/* Dummy-read to advance the read pointer to the head *\/\n\tiwl_trans_read_prph(fwrt->trans, TXF_READ_MODIFY_DATA + offset);\n\n\t\/* Read FIFO *\/\n\tfifo_len \/= sizeof(u32); \/* Size in DWORDS *\/\n\tfor (i = 0; i < fifo_len; i++)\n\t\tfifo_data[i] = iwl_trans_read_prph(fwrt->trans,\n\t\t\t\t\t\t  TXF_READ_MODIFY_DATA +\n\t\t\t\t\t\t  offset);\n\t*dump_data = iwl_fw_error_next_data(*dump_data);\n}","target":0,"code_token_length":526,"total_token_length":762,"max_tokens_setting":1024}
+{"idx":87401,"func":"static inline void updateIntersectMapHelper(const req::ptr<c_Map>& mp,\n                                            const Cell c,\n                                            int pos,\n                                            TypedValue* strTv,\n                                            bool convertIntLikeStrs) {\n  if (c.m_type == KindOfInt64) {\n    auto val = mp->get(c.m_data.num);\n    if (val && val->m_data.num == pos) {\n      assert(val->m_type == KindOfInt64);\n      ++val->m_data.num;\n    }\n  } else {\n    StringData* s;\n    if (LIKELY(isStringType(c.m_type))) {\n      s = c.m_data.pstr;\n    } else {\n      s = tvCastToString(&c);\n      decRefStr(strTv->m_data.pstr);\n      strTv->m_data.pstr = s;\n    }\n    int64_t n;\n    if (convertIntLikeStrs && s->isStrictlyInteger(n)) {\n      auto val = mp->get(n);\n      if (val && val->m_data.num == pos) {\n        assert(val->m_type == KindOfInt64);\n        ++val->m_data.num;\n      }\n    } else {\n      auto val = mp->get(s);\n      if (val && val->m_data.num == pos) {\n        assert(val->m_type == KindOfInt64);\n        ++val->m_data.num;\n      }\n    }\n  }\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":337953,"func":"static int pix_norm1_c(uint8_t * pix, int line_size)\n\n{\n\n    int s, i, j;\n\n    uint32_t *sq = ff_squareTbl + 256;\n\n\n\n    s = 0;\n\n    for (i = 0; i < 16; i++) {\n\n        for (j = 0; j < 16; j += 8) {\n\n#if 0\n\n            s += sq[pix[0]];\n\n            s += sq[pix[1]];\n\n            s += sq[pix[2]];\n\n            s += sq[pix[3]];\n\n            s += sq[pix[4]];\n\n            s += sq[pix[5]];\n\n            s += sq[pix[6]];\n\n            s += sq[pix[7]];\n\n#else\n\n#if LONG_MAX > 2147483647\n\n            register uint64_t x=*(uint64_t*)pix;\n\n            s += sq[x&0xff];\n\n            s += sq[(x>>8)&0xff];\n\n            s += sq[(x>>16)&0xff];\n\n            s += sq[(x>>24)&0xff];\n\n            s += sq[(x>>32)&0xff];\n\n            s += sq[(x>>40)&0xff];\n\n            s += sq[(x>>48)&0xff];\n\n            s += sq[(x>>56)&0xff];\n\n#else\n\n            register uint32_t x=*(uint32_t*)pix;\n\n            s += sq[x&0xff];\n\n            s += sq[(x>>8)&0xff];\n\n            s += sq[(x>>16)&0xff];\n\n            s += sq[(x>>24)&0xff];\n\n            x=*(uint32_t*)(pix+4);\n\n            s += sq[x&0xff];\n\n            s += sq[(x>>8)&0xff];\n\n            s += sq[(x>>16)&0xff];\n\n            s += sq[(x>>24)&0xff];\n\n#endif\n\n#endif\n\n            pix += 8;\n\n        }\n\n        pix += line_size - 16;\n\n    }\n\n    return s;\n\n}\n","target":0,"code_token_length":448,"total_token_length":684,"max_tokens_setting":1024}
+{"idx":90471,"func":"static int trusted_update(struct key *key, struct key_preparsed_payload *prep)\n{\n\tstruct trusted_key_payload *p;\n\tstruct trusted_key_payload *new_p;\n\tstruct trusted_key_options *new_o;\n\tsize_t datalen = prep->datalen;\n\tchar *datablob;\n\tint ret = 0;\n\n\tif (test_bit(KEY_FLAG_NEGATIVE, &key->flags))\n\t\treturn -ENOKEY;\n\tp = key->payload.data[0];\n\tif (!p->migratable)\n\t\treturn -EPERM;\n\tif (datalen <= 0 || datalen > 32767 || !prep->data)\n\t\treturn -EINVAL;\n\n\tdatablob = kmalloc(datalen + 1, GFP_KERNEL);\n\tif (!datablob)\n\t\treturn -ENOMEM;\n\tnew_o = trusted_options_alloc();\n\tif (!new_o) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tnew_p = trusted_payload_alloc(key);\n\tif (!new_p) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tmemcpy(datablob, prep->data, datalen);\n\tdatablob[datalen] = '\\0';\n\tret = datablob_parse(datablob, new_p, new_o);\n\tif (ret != Opt_update) {\n\t\tret = -EINVAL;\n\t\tkfree(new_p);\n\t\tgoto out;\n\t}\n\n\tif (!new_o->keyhandle) {\n\t\tret = -EINVAL;\n\t\tkfree(new_p);\n\t\tgoto out;\n\t}\n\n\t\/* copy old key values, and reseal with new pcrs *\/\n\tnew_p->migratable = p->migratable;\n\tnew_p->key_len = p->key_len;\n\tmemcpy(new_p->key, p->key, p->key_len);\n\tdump_payload(p);\n\tdump_payload(new_p);\n\n\tret = key_seal(new_p, new_o);\n\tif (ret < 0) {\n\t\tpr_info(\"trusted_key: key_seal failed (%d)\\n\", ret);\n\t\tkfree(new_p);\n\t\tgoto out;\n\t}\n\tif (new_o->pcrlock) {\n\t\tret = pcrlock(new_o->pcrlock);\n\t\tif (ret < 0) {\n\t\t\tpr_info(\"trusted_key: pcrlock failed (%d)\\n\", ret);\n\t\t\tkfree(new_p);\n\t\t\tgoto out;\n\t\t}\n\t}\n\trcu_assign_keypointer(key, new_p);\n\tcall_rcu(&p->rcu, trusted_rcu_free);\nout:\n\tkfree(datablob);\n\tkfree(new_o);\n\treturn ret;\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":390092,"func":"static void cli_flush_use_result(MYSQL *mysql, my_bool flush_all_results)\n{\n  \/* Clear the current execution status *\/\n  DBUG_ENTER(\"cli_flush_use_result\");\n  DBUG_PRINT(\"warning\",(\"Not all packets read, clearing them\"));\n\n  if (flush_one_result(mysql))\n    DBUG_VOID_RETURN;                           \/* An error occurred *\/\n\n  if (! flush_all_results)\n    DBUG_VOID_RETURN;\n\n  while (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)\n  {\n    my_bool is_ok_packet;\n    if (opt_flush_ok_packet(mysql, &is_ok_packet))\n      DBUG_VOID_RETURN;                         \/* An error occurred. *\/\n    if (is_ok_packet)\n    {\n      \/*\n        Indeed what we got from network was an OK packet, and we\n        know that OK is the last one in a multi-result-set, so\n        just return.\n      *\/\n      DBUG_VOID_RETURN;\n    }\n    \/*\n      It's a result set, not an OK packet. A result set contains\n      of two result set subsequences: field metadata, terminated\n      with EOF packet, and result set data, again terminated with\n      EOF packet. Read and flush them.\n    *\/\n    if (flush_one_result(mysql) || flush_one_result(mysql))\n      DBUG_VOID_RETURN;                         \/* An error occurred. *\/\n  }\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":493303,"func":"int av_get_exact_bits_per_sample(enum AVCodecID codec_id)\n{\n    switch (codec_id) {\n    case AV_CODEC_ID_8SVX_EXP:\n    case AV_CODEC_ID_8SVX_FIB:\n    case AV_CODEC_ID_ADPCM_CT:\n    case AV_CODEC_ID_ADPCM_IMA_APC:\n    case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:\n    case AV_CODEC_ID_ADPCM_IMA_OKI:\n    case AV_CODEC_ID_ADPCM_IMA_WS:\n    case AV_CODEC_ID_ADPCM_G722:\n    case AV_CODEC_ID_ADPCM_YAMAHA:\n        return 4;\n    case AV_CODEC_ID_PCM_ALAW:\n    case AV_CODEC_ID_PCM_MULAW:\n    case AV_CODEC_ID_PCM_S8:\n    case AV_CODEC_ID_PCM_S8_PLANAR:\n    case AV_CODEC_ID_PCM_U8:\n    case AV_CODEC_ID_PCM_ZORK:\n        return 8;\n    case AV_CODEC_ID_PCM_S16BE:\n    case AV_CODEC_ID_PCM_S16BE_PLANAR:\n    case AV_CODEC_ID_PCM_S16LE:\n    case AV_CODEC_ID_PCM_S16LE_PLANAR:\n    case AV_CODEC_ID_PCM_U16BE:\n    case AV_CODEC_ID_PCM_U16LE:\n        return 16;\n    case AV_CODEC_ID_PCM_S24DAUD:\n    case AV_CODEC_ID_PCM_S24BE:\n    case AV_CODEC_ID_PCM_S24LE:\n    case AV_CODEC_ID_PCM_S24LE_PLANAR:\n    case AV_CODEC_ID_PCM_U24BE:\n    case AV_CODEC_ID_PCM_U24LE:\n        return 24;\n    case AV_CODEC_ID_PCM_S32BE:\n    case AV_CODEC_ID_PCM_S32LE:\n    case AV_CODEC_ID_PCM_S32LE_PLANAR:\n    case AV_CODEC_ID_PCM_U32BE:\n    case AV_CODEC_ID_PCM_U32LE:\n    case AV_CODEC_ID_PCM_F32BE:\n    case AV_CODEC_ID_PCM_F32LE:\n        return 32;\n    case AV_CODEC_ID_PCM_F64BE:\n    case AV_CODEC_ID_PCM_F64LE:\n        return 64;\n    default:\n        return 0;\n    }\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":363347,"func":"xsltSystemPropertyFunction(xmlXPathParserContextPtr ctxt, int nargs){\n    xmlXPathObjectPtr obj;\n    xmlChar *prefix, *name;\n    const xmlChar *nsURI = NULL;\n\n    if (nargs != 1) {\n\txsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,\n\t\t\"system-property() : expects one string arg\\n\");\n\tctxt->error = XPATH_INVALID_ARITY;\n\treturn;\n    }\n    if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {\n\txsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,\n\t    \"system-property() : invalid arg expecting a string\\n\");\n\tctxt->error = XPATH_INVALID_TYPE;\n\treturn;\n    }\n    obj = valuePop(ctxt);\n    if (obj->stringval == NULL) {\n\tvaluePush(ctxt, xmlXPathNewString((const xmlChar *)\"\"));\n    } else {\n\tname = xmlSplitQName2(obj->stringval, &prefix);\n\tif (name == NULL) {\n\t    name = xmlStrdup(obj->stringval);\n\t} else {\n\t    nsURI = xmlXPathNsLookup(ctxt->context, prefix);\n\t    if (nsURI == NULL) {\n\t\txsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,\n\t\t    \"system-property() : prefix %s is not bound\\n\", prefix);\n\t    }\n\t}\n\n\tif (xmlStrEqual(nsURI, XSLT_NAMESPACE)) {\n#ifdef DOCBOOK_XSL_HACK\n\t    if (xmlStrEqual(name, (const xmlChar *)\"vendor\")) {\n\t\txsltStylesheetPtr sheet;\n\t\txsltTransformContextPtr tctxt;\n\n\t\ttctxt = xsltXPathGetTransformContext(ctxt);\n\t\tif ((tctxt != NULL) && (tctxt->inst != NULL) &&\n\t\t    (xmlStrEqual(tctxt->inst->name, BAD_CAST \"variable\")) &&\n\t\t    (tctxt->inst->parent != NULL) &&\n\t\t    (xmlStrEqual(tctxt->inst->parent->name,\n\t\t\t\t BAD_CAST \"template\")))\n\t\t    sheet = tctxt->style;\n\t\telse\n\t\t    sheet = NULL;\n\t\tif ((sheet != NULL) && (sheet->doc != NULL) &&\n\t\t    (sheet->doc->URL != NULL) &&\n\t\t    (xmlStrstr(sheet->doc->URL,\n\t\t\t       (const xmlChar *)\"chunk\") != NULL)) {\n\t\t    valuePush(ctxt, xmlXPathNewString(\n\t\t\t(const xmlChar *)\"libxslt (SAXON 6.2 compatible)\"));\n\n\t\t} else {\n\t\t    valuePush(ctxt, xmlXPathNewString(\n\t\t\t(const xmlChar *)XSLT_DEFAULT_VENDOR));\n\t\t}\n\t    } else\n#else\n\t    if (xmlStrEqual(name, (const xmlChar *)\"vendor\")) {\n\t\tvaluePush(ctxt, xmlXPathNewString(\n\t\t\t  (const xmlChar *)XSLT_DEFAULT_VENDOR));\n\t    } else\n#endif\n\t    if (xmlStrEqual(name, (const xmlChar *)\"version\")) {\n\t\tvaluePush(ctxt, xmlXPathNewString(\n\t\t    (const xmlChar *)XSLT_DEFAULT_VERSION));\n\t    } else if (xmlStrEqual(name, (const xmlChar *)\"vendor-url\")) {\n\t\tvaluePush(ctxt, xmlXPathNewString(\n\t\t    (const xmlChar *)XSLT_DEFAULT_URL));\n\t    } else {\n\t\tvaluePush(ctxt, xmlXPathNewString((const xmlChar *)\"\"));\n\t    }\n\t}\n\tif (name != NULL)\n\t    xmlFree(name);\n\tif (prefix != NULL)\n\t    xmlFree(prefix);\n    }\n    xmlXPathFreeObject(obj);\n}","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":6898,"func":"void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new)\n{\n    unsigned char *data = NULL;\n    int size;\n    loff_t offs;\n\n    if (new == -1)\n\tnew = FAT_EOF(fs);\n    else if ((long)new == -2)\n\tnew = FAT_BAD(fs);\n    switch (fs->fat_bits) {\n    case 12:\n\tdata = fs->fat + cluster * 3 \/ 2;\n\toffs = fs->fat_start + cluster * 3 \/ 2;\n\tif (cluster & 1) {\n\t    FAT_ENTRY prevEntry;\n\t    get_fat(&prevEntry, fs->fat, cluster - 1, fs);\n\t    data[0] = ((new & 0xf) << 4) | (prevEntry.value >> 8);\n\t    data[1] = new >> 4;\n\t} else {\n\t    FAT_ENTRY subseqEntry;\n\t    if (cluster != fs->clusters - 1)\n\t\tget_fat(&subseqEntry, fs->fat, cluster + 1, fs);\n\t    else\n\t\tsubseqEntry.value = 0;\n\t    data[0] = new & 0xff;\n\t    data[1] = (new >> 8) | ((0xff & subseqEntry.value) << 4);\n\t}\n\tsize = 2;\n\tbreak;\n    case 16:\n\tdata = fs->fat + cluster * 2;\n\toffs = fs->fat_start + cluster * 2;\n\t*(unsigned short *)data = htole16(new);\n\tsize = 2;\n\tbreak;\n    case 32:\n\t{\n\t    FAT_ENTRY curEntry;\n\t    get_fat(&curEntry, fs->fat, cluster, fs);\n\n\t    data = fs->fat + cluster * 4;\n\t    offs = fs->fat_start + cluster * 4;\n\t    \/* According to M$, the high 4 bits of a FAT32 entry are reserved and\n\t     * are not part of the cluster number. So we never touch them. *\/\n\t    *(uint32_t *)data = htole32((new & 0xfffffff) |\n\t\t\t\t\t     (curEntry.reserved << 28));\n\t    size = 4;\n\t}\n\tbreak;\n    default:\n\tdie(\"Bad FAT entry size: %d bits.\", fs->fat_bits);\n    }\n    fs_write(offs, size, data);\n    if (fs->nfats > 1) {\n\tfs_write(offs + fs->fat_size, size, data);\n    }\n}","target":1,"code_token_length":536,"total_token_length":772,"max_tokens_setting":1024}
+{"idx":165936,"func":"ofputil_append_table_features_reply(const struct ofputil_table_features *tf,\n                                    struct ovs_list *replies)\n{\n    struct ofpbuf *reply = ofpbuf_from_list(ovs_list_back(replies));\n    enum ofp_version version = ofpmp_version(replies);\n    size_t start_ofs = reply->size;\n    struct ofp13_table_features *otf;\n\n    otf = ofpbuf_put_zeros(reply, sizeof *otf);\n    otf->table_id = tf->table_id;\n    ovs_strlcpy(otf->name, tf->name, sizeof otf->name);\n    otf->metadata_match = tf->metadata_match;\n    otf->metadata_write = tf->metadata_write;\n    if (version >= OFP14_VERSION) {\n        if (tf->supports_eviction) {\n            otf->capabilities |= htonl(OFPTC14_EVICTION);\n        }\n        if (tf->supports_vacancy_events) {\n            otf->capabilities |= htonl(OFPTC14_VACANCY_EVENTS);\n        }\n    }\n    otf->max_entries = htonl(tf->max_entries);\n\n    put_table_instruction_features(reply, &tf->nonmiss, 0, version);\n    put_table_instruction_features(reply, &tf->miss, 1, version);\n\n    put_fields_property(reply, &tf->match, &tf->mask,\n                        OFPTFPT13_MATCH, version);\n    put_fields_property(reply, &tf->wildcard, NULL,\n                        OFPTFPT13_WILDCARDS, version);\n\n    otf = ofpbuf_at_assert(reply, start_ofs, sizeof *otf);\n    otf->length = htons(reply->size - start_ofs);\n    ofpmp_postappend(replies, start_ofs);\n}\n","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":352168,"func":"static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)\n{\n\tstruct bpf_insn_aux_data *aux = cur_aux(env);\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tstruct bpf_reg_state *dst_reg;\n\tstruct bpf_map *map;\n\tint err;\n\n\tif (BPF_SIZE(insn->code) != BPF_DW) {\n\t\tverbose(env, \"invalid BPF_LD_IMM insn\\n\");\n\t\treturn -EINVAL;\n\t}\n\tif (insn->off != 0) {\n\t\tverbose(env, \"BPF_LD_IMM64 uses reserved fields\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\terr = check_reg_arg(env, insn->dst_reg, DST_OP);\n\tif (err)\n\t\treturn err;\n\n\tdst_reg = ®s[insn->dst_reg];\n\tif (insn->src_reg == 0) {\n\t\tu64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;\n\n\t\tdst_reg->type = SCALAR_VALUE;\n\t\t__mark_reg_known(®s[insn->dst_reg], imm);\n\t\treturn 0;\n\t}\n\n\tif (insn->src_reg == BPF_PSEUDO_BTF_ID) {\n\t\tmark_reg_known_zero(env, regs, insn->dst_reg);\n\n\t\tdst_reg->type = aux->btf_var.reg_type;\n\t\tswitch (dst_reg->type) {\n\t\tcase PTR_TO_MEM:\n\t\t\tdst_reg->mem_size = aux->btf_var.mem_size;\n\t\t\tbreak;\n\t\tcase PTR_TO_BTF_ID:\n\t\tcase PTR_TO_PERCPU_BTF_ID:\n\t\t\tdst_reg->btf = aux->btf_var.btf;\n\t\t\tdst_reg->btf_id = aux->btf_var.btf_id;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\t\treturn -EFAULT;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tif (insn->src_reg == BPF_PSEUDO_FUNC) {\n\t\tstruct bpf_prog_aux *aux = env->prog->aux;\n\t\tu32 subprogno = find_subprog(env,\n\t\t\t\t\t     env->insn_idx + insn->imm + 1);\n\n\t\tif (!aux->func_info) {\n\t\t\tverbose(env, \"missing btf func_info\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (aux->func_info_aux[subprogno].linkage != BTF_FUNC_STATIC) {\n\t\t\tverbose(env, \"callback function not static\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tdst_reg->type = PTR_TO_FUNC;\n\t\tdst_reg->subprogno = subprogno;\n\t\treturn 0;\n\t}\n\n\tmap = env->used_maps[aux->map_index];\n\tmark_reg_known_zero(env, regs, insn->dst_reg);\n\tdst_reg->map_ptr = map;\n\n\tif (insn->src_reg == BPF_PSEUDO_MAP_VALUE ||\n\t    insn->src_reg == BPF_PSEUDO_MAP_IDX_VALUE) {\n\t\tdst_reg->type = PTR_TO_MAP_VALUE;\n\t\tdst_reg->off = aux->map_off;\n\t\tif (map_value_has_spin_lock(map))\n\t\t\tdst_reg->id = ++env->id_gen;\n\t} else if (insn->src_reg == BPF_PSEUDO_MAP_FD ||\n\t\t   insn->src_reg == BPF_PSEUDO_MAP_IDX) {\n\t\tdst_reg->type = CONST_PTR_TO_MAP;\n\t} else {\n\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":1,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":171025,"func":"void ProfileSyncService::OnExperimentsChanged(\n    const browser_sync::Experiments& experiments) {\n  if (current_experiments.Matches(experiments))\n    return;\n\n  if (migrator_.get() &&\n      migrator_->state() != browser_sync::BackendMigrator::IDLE) {\n    DVLOG(1) << \"Dropping OnExperimentsChanged due to migrator busy.\";\n    return;\n  }\n \n   const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes();\n   syncable::ModelTypeSet to_add;\n   const syncable::ModelTypeSet to_register =\n       Difference(to_add, registered_types);\n   DVLOG(2) << \"OnExperimentsChanged called with types: \"\n           << syncable::ModelTypeSetToString(to_add);\n  DVLOG(2) << \"Enabling types: \" << syncable::ModelTypeSetToString(to_register);\n\n  for (syncable::ModelTypeSet::Iterator it = to_register.First();\n       it.Good(); it.Inc()) {\n    RegisterNewDataType(it.Get());\n#if !defined(OS_ANDROID)\n    std::string experiment_name = GetExperimentNameForDataType(it.Get());\n    if (experiment_name.empty())\n      continue;\n    about_flags::SetExperimentEnabled(g_browser_process->local_state(),\n                                      experiment_name,\n                                      true);\n#endif  \/\/ !defined(OS_ANDROID)\n  }\n\n  if (sync_prefs_.HasKeepEverythingSynced()) {\n    sync_prefs_.SetPreferredDataTypes(registered_types, registered_types);\n\n    if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) {\n      DVLOG(1) << \"Dynamically enabling new datatypes: \"\n               << syncable::ModelTypeSetToString(to_register);\n      OnMigrationNeededForTypes(to_register);\n    }\n  }\n\n  if (experiments.sync_tab_favicons) {\n    DVLOG(1) << \"Enabling syncing of tab favicons.\";\n    about_flags::SetExperimentEnabled(g_browser_process->local_state(),\n                                      \"sync-tab-favicons\",\n                                      true);\n  }\n\n  current_experiments = experiments;\n}\n","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":472632,"func":"static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)\n{\n    NvmeNamespace *ns = req->ns;\n    NvmeDsmCmd *dsm = (NvmeDsmCmd *) &req->cmd;\n    uint32_t attr = le32_to_cpu(dsm->attributes);\n    uint32_t nr = (le32_to_cpu(dsm->nr) & 0xff) + 1;\n    uint16_t status = NVME_SUCCESS;\n\n    trace_pci_nvme_dsm(nr, attr);\n\n    if (attr & NVME_DSMGMT_AD) {\n        NvmeDSMAIOCB *iocb = blk_aio_get(&nvme_dsm_aiocb_info, ns->blkconf.blk,\n                                         nvme_misc_cb, req);\n\n        iocb->req = req;\n        iocb->bh = qemu_bh_new(nvme_dsm_bh, iocb);\n        iocb->ret = 0;\n        iocb->range = g_new(NvmeDsmRange, nr);\n        iocb->nr = nr;\n        iocb->idx = 0;\n\n        status = nvme_h2c(n, (uint8_t *)iocb->range, sizeof(NvmeDsmRange) * nr,\n                          req);\n        if (status) {\n            return status;\n        }\n\n        req->aiocb = &iocb->common;\n        nvme_dsm_cb(iocb, 0);\n\n        return NVME_NO_COMPLETE;\n    }\n\n    return status;\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":484223,"func":"mlx5_rxq_initialize(struct mlx5_rxq_data *rxq)\n{\n\tconst unsigned int wqe_n = 1 << rxq->elts_n;\n\tunsigned int i;\n\n\tfor (i = 0; (i != wqe_n); ++i) {\n\t\tvolatile struct mlx5_wqe_data_seg *scat;\n\t\tuintptr_t addr;\n\t\tuint32_t byte_count;\n\n\t\tif (mlx5_rxq_mprq_enabled(rxq)) {\n\t\t\tstruct mlx5_mprq_buf *buf = (*rxq->mprq_bufs)[i];\n\n\t\t\tscat = &((volatile struct mlx5_wqe_mprq *)\n\t\t\t\trxq->wqes)[i].dseg;\n\t\t\taddr = (uintptr_t)mlx5_mprq_buf_addr\n\t\t\t\t\t(buf, (1 << rxq->log_strd_num));\n\t\t\tbyte_count = (1 << rxq->log_strd_sz) *\n\t\t\t\t     (1 << rxq->log_strd_num);\n\t\t} else {\n\t\t\tstruct rte_mbuf *buf = (*rxq->elts)[i];\n\n\t\t\tscat = &((volatile struct mlx5_wqe_data_seg *)\n\t\t\t\t\trxq->wqes)[i];\n\t\t\taddr = rte_pktmbuf_mtod(buf, uintptr_t);\n\t\t\tbyte_count = DATA_LEN(buf);\n\t\t}\n\t\t\/* scat->addr must be able to store a pointer. *\/\n\t\tassert(sizeof(scat->addr) >= sizeof(uintptr_t));\n\t\t*scat = (struct mlx5_wqe_data_seg){\n\t\t\t.addr = rte_cpu_to_be_64(addr),\n\t\t\t.byte_count = rte_cpu_to_be_32(byte_count),\n\t\t\t.lkey = mlx5_rx_addr2mr(rxq, addr),\n\t\t};\n\t}\n\trxq->consumed_strd = 0;\n\trxq->decompressed = 0;\n\trxq->rq_pi = 0;\n\trxq->zip = (struct rxq_zip){\n\t\t.ai = 0,\n\t};\n\t\/* Update doorbell counter. *\/\n\trxq->rq_ci = wqe_n >> rxq->sges_n;\n\trte_cio_wmb();\n\t*rxq->rq_db = rte_cpu_to_be_32(rxq->rq_ci);\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":433818,"func":"ec_mulm_25519 (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx)\n{\n  mpi_ptr_t wp, up, vp;\n  mpi_size_t wsize = LIMB_SIZE_25519;\n  mpi_limb_t n[LIMB_SIZE_25519*2];\n  mpi_limb_t m[LIMB_SIZE_25519+1];\n  mpi_limb_t cy;\n  int msb;\n\n  (void)ctx;\n  if (w->nlimbs != wsize || u->nlimbs != wsize || v->nlimbs != wsize)\n    log_bug (\"mulm_25519: different sizes\\n\");\n\n  up = u->d;\n  vp = v->d;\n  wp = w->d;\n\n  _gcry_mpih_mul_n (n, up, vp, wsize);\n  memcpy (wp, n, wsize * BYTES_PER_MPI_LIMB);\n  wp[LIMB_SIZE_25519-1] &= ~((mpi_limb_t)1 << (255 % BITS_PER_MPI_LIMB));\n\n  memcpy (m, n+LIMB_SIZE_25519-1, (wsize+1) * BYTES_PER_MPI_LIMB);\n  _gcry_mpih_rshift (m, m, LIMB_SIZE_25519+1, (255 % BITS_PER_MPI_LIMB));\n\n  memcpy (n, m, wsize * BYTES_PER_MPI_LIMB);\n  cy = _gcry_mpih_lshift (m, m, LIMB_SIZE_25519, 4);\n  m[LIMB_SIZE_25519] = cy;\n  cy = _gcry_mpih_add_n (m, m, n, wsize);\n  m[LIMB_SIZE_25519] += cy;\n  cy = _gcry_mpih_add_n (m, m, n, wsize);\n  m[LIMB_SIZE_25519] += cy;\n  cy = _gcry_mpih_add_n (m, m, n, wsize);\n  m[LIMB_SIZE_25519] += cy;\n\n  cy = _gcry_mpih_add_n (wp, wp, m, wsize);\n  m[LIMB_SIZE_25519] += cy;\n\n  memset (m, 0, wsize * BYTES_PER_MPI_LIMB);\n  msb = (wp[LIMB_SIZE_25519-1] >> (255 % BITS_PER_MPI_LIMB));\n  m[0] = (m[LIMB_SIZE_25519] * 2 + msb) * 19;\n  wp[LIMB_SIZE_25519-1] &= ~((mpi_limb_t)1 << (255 % BITS_PER_MPI_LIMB));\n  _gcry_mpih_add_n (wp, wp, m, wsize);\n\n  m[0] = 0;\n  cy = _gcry_mpih_sub_n (wp, wp, ctx->p->d, wsize);\n  mpih_set_cond (m, ctx->p->d, wsize, (cy != 0UL));\n  _gcry_mpih_add_n (wp, wp, m, wsize);\n}","target":0,"code_token_length":752,"total_token_length":988,"max_tokens_setting":1024}
+{"idx":1690,"func":"static char * * create_argv_command ( struct rule * rule , struct process * process , struct iovec * * argv ) {\n size_t count , i , j , stdin_arg ;\n char * * req_argv = NULL ;\n const char * program ;\n for ( count = 0 ;\n argv [ count ] != NULL ;\n count ++ ) ;\n if ( rule -> sudo_user == NULL ) req_argv = xcalloc ( count + 1 , sizeof ( char * ) ) ;\n else req_argv = xcalloc ( count + 5 , sizeof ( char * ) ) ;\n if ( rule -> sudo_user != NULL ) {\n req_argv [ 0 ] = xstrdup ( PATH_SUDO ) ;\n req_argv [ 1 ] = xstrdup ( \"-u\" ) ;\n req_argv [ 2 ] = xstrdup ( rule -> sudo_user ) ;\n req_argv [ 3 ] = xstrdup ( \"--\" ) ;\n req_argv [ 4 ] = rule -> program ;\n j = 5 ;\n }\n else {\n program = strrchr ( rule -> program , '\/' ) ;\n if ( program == NULL ) program = rule -> program ;\n else program ++ ;\n req_argv [ 0 ] = xstrdup ( program ) ;\n j = 1 ;\n }\n if ( rule -> stdin_arg == - 1 ) stdin_arg = count - 1 ;\n else stdin_arg = ( size_t ) rule -> stdin_arg ;\n for ( i = 1 ;\n i < count ;\n i ++ ) {\n const char * data = argv [ i ] -> iov_base ;\n size_t length = argv [ i ] -> iov_len ;\n if ( i == stdin_arg ) {\n process -> input = evbuffer_new ( ) ;\n if ( process -> input == NULL ) die ( \"internal error: cannot create input buffer\" ) ;\n if ( evbuffer_add ( process -> input , data , length ) < 0 ) die ( \"internal error: cannot add data to input buffer\" ) ;\n continue ;\n }\n if ( length == 0 ) req_argv [ j ] = xstrdup ( \"\" ) ;\n else req_argv [ j ] = xstrndup ( data , length ) ;\n j ++ ;\n }\n req_argv [ j ] = NULL ;\n return req_argv ;\n }","target":1,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":144908,"func":"count_more_files_callback (GObject      *source_object,\n                           GAsyncResult *res,\n                           gpointer      user_data)\n{\n    DirectoryCountState *state;\n    NautilusDirectory *directory;\n    GError *error;\n    GList *files;\n\n    state = user_data;\n    directory = state->directory;\n\n    if (g_cancellable_is_cancelled (state->cancellable))\n    {\n        \/* Operation was cancelled. Bail out *\/\n\n        async_job_end (directory, \"directory count\");\n        nautilus_directory_async_state_changed (directory);\n\n        directory_count_state_free (state);\n\n        return;\n    }\n\n    g_assert (directory->details->count_in_progress != NULL);\n    g_assert (directory->details->count_in_progress == state);\n\n    error = NULL;\n    files = g_file_enumerator_next_files_finish (state->enumerator,\n                                                 res, &error);\n\n    state->file_count += count_non_skipped_files (files);\n\n    if (files == NULL)\n    {\n        count_children_done (directory, state->count_file,\n                             TRUE, state->file_count);\n        directory_count_state_free (state);\n    }\n    else\n    {\n        g_file_enumerator_next_files_async (state->enumerator,\n                                            DIRECTORY_LOAD_ITEMS_PER_CALLBACK,\n                                            G_PRIORITY_DEFAULT,\n                                            state->cancellable,\n                                            count_more_files_callback,\n                                            state);\n    }\n\n    g_list_free_full (files, g_object_unref);\n\n    if (error)\n    {\n        g_error_free (error);\n    }\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":499343,"func":"TEST_F(RouterTest, UpstreamPerTryTimeout) {\n  NiceMock<Http::MockRequestEncoder> encoder;\n  Http::ResponseDecoder* response_decoder = nullptr;\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _))\n      .WillOnce(Invoke(\n          [&](Http::ResponseDecoder& decoder,\n              Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* {\n            response_decoder = &decoder;\n            callbacks.onPoolReady(encoder, cm_.thread_local_cluster_.conn_pool_.host_,\n                                  upstream_stream_info_, Http::Protocol::Http10);\n            return nullptr;\n          }));\n  EXPECT_CALL(callbacks_.stream_info_, onUpstreamHostSelected(_))\n      .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void {\n        EXPECT_EQ(host_address_, host->address());\n      }));\n\n  Http::TestRequestHeaderMapImpl headers{{\"x-envoy-internal\", \"true\"},\n                                         {\"x-envoy-upstream-rq-per-try-timeout-ms\", \"5\"}};\n  HttpTestUtility::addDefaultHeaders(headers);\n  router_.decodeHeaders(headers, false);\n\n  \/\/ We verify that both timeouts are started after decodeData(_, true) is called. This\n  \/\/ verifies that we are not starting the initial per try timeout on the first onPoolReady.\n  expectPerTryTimerCreate();\n  expectResponseTimerCreate();\n\n  Buffer::OwnedImpl data;\n  router_.decodeData(data, true);\n  EXPECT_EQ(1U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n\n  EXPECT_CALL(callbacks_.stream_info_,\n              setResponseFlag(StreamInfo::ResponseFlag::UpstreamRequestTimeout));\n  EXPECT_CALL(encoder.stream_, resetStream(Http::StreamResetReason::LocalReset));\n  Http::TestResponseHeaderMapImpl response_headers{\n      {\":status\", \"504\"}, {\"content-length\", \"24\"}, {\"content-type\", \"text\/plain\"}};\n  EXPECT_CALL(callbacks_, encodeHeaders_(HeaderMapEqualRef(&response_headers), false));\n  EXPECT_CALL(callbacks_, encodeData(_, true));\n  EXPECT_CALL(\n      cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,\n      putResult(Upstream::Outlier::Result::LocalOriginTimeout, absl::optional<uint64_t>(504)));\n  per_try_timeout_->invokeCallback();\n\n  EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_\n                    .counter(\"upstream_rq_per_try_timeout\")\n                    .value());\n  EXPECT_EQ(1UL, cm_.thread_local_cluster_.conn_pool_.host_->stats().rq_timeout_.value());\n  EXPECT_TRUE(verifyHostUpstreamStats(0, 1));\n}","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":327400,"func":"static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)\n\n{\n\n    \/* We create a standalone GIC *\/\n\n    DeviceState *gicdev;\n\n    SysBusDevice *gicbusdev;\n\n    const char *gictype;\n\n    int i;\n\n\n\n    gictype = (type == 3) ? gicv3_class_name() : gic_class_name();\n\n\n\n    gicdev = qdev_create(NULL, gictype);\n\n    qdev_prop_set_uint32(gicdev, \"revision\", type);\n\n    qdev_prop_set_uint32(gicdev, \"num-cpu\", smp_cpus);\n\n    \/* Note that the num-irq property counts both internal and external\n\n     * interrupts; there are always 32 of the former (mandated by GIC spec).\n\n     *\/\n\n    qdev_prop_set_uint32(gicdev, \"num-irq\", NUM_IRQS + 32);\n\n    if (!kvm_irqchip_in_kernel()) {\n\n        qdev_prop_set_bit(gicdev, \"has-security-extensions\", secure);\n\n    }\n\n    qdev_init_nofail(gicdev);\n\n    gicbusdev = SYS_BUS_DEVICE(gicdev);\n\n    sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);\n\n    if (type == 3) {\n\n        sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_REDIST].base);\n\n    } else {\n\n        sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);\n\n    }\n\n\n\n    \/* Wire the outputs from each CPU's generic timer to the\n\n     * appropriate GIC PPI inputs, and the GIC's IRQ output to\n\n     * the CPU's IRQ input.\n\n     *\/\n\n    for (i = 0; i < smp_cpus; i++) {\n\n        DeviceState *cpudev = DEVICE(qemu_get_cpu(i));\n\n        int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;\n\n        int irq;\n\n        \/* Mapping from the output timer irq lines from the CPU to the\n\n         * GIC PPI inputs we use for the virt board.\n\n         *\/\n\n        const int timer_irq[] = {\n\n            [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,\n\n            [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ,\n\n            [GTIMER_HYP]  = ARCH_TIMER_NS_EL2_IRQ,\n\n            [GTIMER_SEC]  = ARCH_TIMER_S_EL1_IRQ,\n\n        };\n\n\n\n        for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {\n\n            qdev_connect_gpio_out(cpudev, irq,\n\n                                  qdev_get_gpio_in(gicdev,\n\n                                                   ppibase + timer_irq[irq]));\n\n        }\n\n\n\n        sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));\n\n        sysbus_connect_irq(gicbusdev, i + smp_cpus,\n\n                           qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));\n\n    }\n\n\n\n    for (i = 0; i < NUM_IRQS; i++) {\n\n        pic[i] = qdev_get_gpio_in(gicdev, i);\n\n    }\n\n\n\n    fdt_add_gic_node(vbi, type);\n\n\n\n    if (type == 3) {\n\n        create_its(vbi, gicdev);\n\n    } else {\n\n        create_v2m(vbi, pic);\n\n    }\n\n}\n","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":502242,"func":"WERROR dns_common_extract(struct ldb_context *samdb,\n\t\t\t  const struct ldb_message_element *el,\n\t\t\t  TALLOC_CTX *mem_ctx,\n\t\t\t  struct dnsp_DnssrvRpcRecord **records,\n\t\t\t  uint16_t *num_records)\n{\n\tuint16_t ri;\n\tstruct dnsp_DnssrvRpcRecord *recs;\n\n\t*records = NULL;\n\t*num_records = 0;\n\n\trecs = talloc_zero_array(mem_ctx, struct dnsp_DnssrvRpcRecord,\n\t\t\t\t el->num_values);\n\tif (recs == NULL) {\n\t\treturn WERR_NOT_ENOUGH_MEMORY;\n\t}\n\tfor (ri = 0; ri < el->num_values; ri++) {\n\t\tbool am_rodc;\n\t\tint ret;\n\t\tconst char *dnsHostName = NULL;\n\t\tstruct ldb_val *v = &el->values[ri];\n\t\tenum ndr_err_code ndr_err;\n\t\tndr_err = ndr_pull_struct_blob(v, recs, &recs[ri],\n\t\t\t\t(ndr_pull_flags_fn_t)ndr_pull_dnsp_DnssrvRpcRecord);\n\t\tif (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {\n\t\t\tTALLOC_FREE(recs);\n\t\t\tDEBUG(0, (\"Failed to grab dnsp_DnssrvRpcRecord\\n\"));\n\t\t\treturn DNS_ERR(SERVER_FAILURE);\n\t\t}\n\n\t\t\/*\n\t\t * In AD, except on an RODC (where we should list a random RWDC,\n\t\t * we should over-stamp the MNAME with our own hostname\n\t\t *\/\n\t\tif (recs[ri].wType != DNS_TYPE_SOA) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tret = samdb_rodc(samdb, &am_rodc);\n\t\tif (ret != LDB_SUCCESS) {\n\t\t\tDEBUG(0, (\"Failed to confirm we are not an RODC: %s\\n\",\n\t\t\t\t  ldb_errstring(samdb)));\n\t\t\treturn DNS_ERR(SERVER_FAILURE);\n\t\t}\n\n\t\tif (am_rodc) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tret = samdb_dns_host_name(samdb, &dnsHostName);\n\t\tif (ret != LDB_SUCCESS || dnsHostName == NULL) {\n\t\t\tDEBUG(0, (\"Failed to get dnsHostName from rootDSE\"));\n\t\t\treturn DNS_ERR(SERVER_FAILURE);\n\t\t}\n\n\t\trecs[ri].data.soa.mname = talloc_strdup(recs, dnsHostName);\n\t}\n\n\t*records = recs;\n\t*num_records = el->num_values;\n\treturn WERR_OK;\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":364574,"func":"int service_init(int argc __attribute__((unused)),\n\t\t char **argv __attribute__((unused)),\n\t\t char **envp __attribute__((unused)))\n{\n    int opt;\n    const char *prefix;\n\n    initialize_nntp_error_table();\n\n    if (geteuid() == 0) fatal(\"must run as the Cyrus user\", EC_USAGE);\n    setproctitle_init(argc, argv, envp);\n\n    \/* set signal handlers *\/\n    signals_set_shutdown(&shut_down);\n    signal(SIGPIPE, SIG_IGN);\n\n    \/* load the SASL plugins *\/\n    global_sasl_init(1, 1, mysasl_cb);\n\n    if ((prefix = config_getstring(IMAPOPT_NEWSPREFIX)))\n\tsnprintf(newsprefix, sizeof(newsprefix), \"%s.\", prefix);\n\n    newsgroups = split_wildmats((char *) config_getstring(IMAPOPT_NEWSGROUPS));\n\n    \/* initialize duplicate delivery database *\/\n    if (duplicate_init(NULL, 0) != 0) {\n\tsyslog(LOG_ERR, \n\t       \"unable to init duplicate delivery database\\n\");\n\tfatal(\"unable to init duplicate delivery database\", EC_SOFTWARE);\n    }\n\n    \/* open the mboxlist, we'll need it for real work *\/\n    mboxlist_init(0);\n    mboxlist_open(NULL);\n\n    \/* open the quota db, we'll need it for expunge *\/\n    quotadb_init(0);\n    quotadb_open(NULL);\n\n    \/* open the user deny db *\/\n    denydb_init(0);\n    denydb_open(NULL);\n\n    \/* setup for sending IMAP IDLE notifications *\/\n    idle_enabled();\n\n    while ((opt = getopt(argc, argv, \"srfp:\")) != EOF) {\n\tswitch(opt) {\n\tcase 's': \/* nntps (do starttls right away) *\/\n\t    nntps = 1;\n\t    if (!tls_enabled()) {\n\t\tsyslog(LOG_ERR, \"nntps: required OpenSSL options not present\");\n\t\tfatal(\"nntps: required OpenSSL options not present\",\n\t\t      EC_CONFIG);\n\t    }\n\t    break;\n\n\tcase 'r': \/* enter reader-only mode *\/\n\t    nntp_capa = MODE_READ;\n\t    break;\n\n\tcase 'f': \/* enter feeder-only mode *\/\n\t    nntp_capa = MODE_FEED;\n\t    break;\n\n\tcase 'p': \/* external protection *\/\n\t    extprops_ssf = atoi(optarg);\n\t    break;\n\n\tdefault:\n\t    usage();\n\t}\n    }\n\n    \/* Initialize the annotatemore extention *\/\n    annotatemore_init(NULL, NULL);\n    annotatemore_open();\n\n    newsmaster = (char *) config_getstring(IMAPOPT_NEWSMASTER);\n    newsmaster_authstate = auth_newstate(newsmaster);\n\n    singleinstance = config_getswitch(IMAPOPT_SINGLEINSTANCESTORE);\n\n    \/* Create a protgroup for input from the client and selected backend *\/\n    protin = protgroup_new(2);\n\n    return 0;\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":395123,"func":"vmxnet3_io_bar1_read(void *opaque, hwaddr addr, unsigned size)\n{\n        VMXNET3State *s = opaque;\n        uint64_t ret = 0;\n\n        switch (addr) {\n        \/* Vmxnet3 Revision Report Selection *\/\n        case VMXNET3_REG_VRRS:\n            VMW_CBPRN(\"Read BAR1 [VMXNET3_REG_VRRS], size %d\", size);\n            ret = VMXNET3_DEVICE_REVISION;\n            break;\n\n        \/* UPT Version Report Selection *\/\n        case VMXNET3_REG_UVRS:\n            VMW_CBPRN(\"Read BAR1 [VMXNET3_REG_UVRS], size %d\", size);\n            ret = VMXNET3_UPT_REVISION;\n            break;\n\n        \/* Command *\/\n        case VMXNET3_REG_CMD:\n            VMW_CBPRN(\"Read BAR1 [VMXNET3_REG_CMD], size %d\", size);\n            ret = vmxnet3_get_command_status(s);\n            break;\n\n        \/* MAC Address Low *\/\n        case VMXNET3_REG_MACL:\n            VMW_CBPRN(\"Read BAR1 [VMXNET3_REG_MACL], size %d\", size);\n            ret = vmxnet3_get_mac_low(&s->conf.macaddr);\n            break;\n\n        \/* MAC Address High *\/\n        case VMXNET3_REG_MACH:\n            VMW_CBPRN(\"Read BAR1 [VMXNET3_REG_MACH], size %d\", size);\n            ret = vmxnet3_get_mac_high(&s->conf.macaddr);\n            break;\n\n        \/*\n         * Interrupt Cause Register\n         * Used for legacy interrupts only so interrupt index always 0\n         *\/\n        case VMXNET3_REG_ICR:\n            VMW_CBPRN(\"Read BAR1 [VMXNET3_REG_ICR], size %d\", size);\n            if (vmxnet3_interrupt_asserted(s, 0)) {\n                vmxnet3_clear_interrupt(s, 0);\n                ret = true;\n            } else {\n                ret = false;\n            }\n            break;\n\n        default:\n            VMW_CBPRN(\"Unknow read BAR1[%\" PRIx64 \"], %d bytes\", addr, size);\n            break;\n        }\n\n        return ret;\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":191186,"func":"bool LaunchBrowser(const CommandLine& command_line, Profile* profile,\n                   const std::wstring& cur_dir, bool process_startup,\n                   int* return_code, BrowserInit* browser_init) {\n  in_startup = process_startup;\n  DCHECK(profile);\n\n  if (command_line.HasSwitch(switches::kIncognito))\n    profile = profile->GetOffTheRecordProfile();\n\n  BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, browser_init);\n  bool launched = lwp.Launch(profile, process_startup);\n  in_startup = false;\n\n  if (!launched) {\n    LOG(ERROR) << \"launch error\";\n    if (return_code)\n      *return_code = ResultCodes::INVALID_CMDLINE_URL;\n    return false;\n  }\n\n#if defined(OS_CHROMEOS)\n  TabOverviewMessageListener::instance();\n\n  const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();\n  if (parsed_command_line.HasSwitch(switches::kEnableGView)) {\n    chromeos::GViewRequestInterceptor::GetGViewRequestInterceptor();\n  }\n  if (process_startup) {\n    chromeos::MountLibrary* lib = chromeos::MountLibrary::Get();\n    chromeos::USBMountObserver* observe = chromeos::USBMountObserver::Get();\n    observe->set_profile(profile);\n    lib->AddObserver(observe);\n  }\n#endif\n  return true;\n}\n","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":490438,"func":"static GFINLINE void check_filter_error(GF_Filter *filter, GF_Err e, Bool for_reconnection)\n{\n\tGF_Err out_e = e;\n\tBool kill_filter = GF_FALSE;\n\tif (e>GF_OK) e = GF_OK;\n\telse if (e==GF_IP_NETWORK_EMPTY) e = GF_OK;\n\n\tif (e) {\n\t\tu64 diff;\n\t\tfilter->session->last_process_error = e;\n\n\t\tfilter->nb_errors ++;\n\t\tif (!filter->nb_consecutive_errors) filter->time_at_first_error = gf_sys_clock_high_res();\n\n\t\tfilter->nb_consecutive_errors ++;\n\t\tif (filter->nb_pck_io && !filter->session->in_final_flush)\n\t\t\tfilter->nb_consecutive_errors = 0;\n\t\t\/\/give it at most one second\n\t\tdiff = gf_sys_clock_high_res() - filter->time_at_first_error;\n\t\tif (diff >= 1000000) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"[Filter] %s in error \/ not responding properly: %d consecutive errors in \"LLU\" us with no packet discarded or sent\\n\\tdiscarding all inputs and notifying end of stream on all outputs\\n\", filter->name, filter->nb_consecutive_errors, diff));\n\t\t\tkill_filter = GF_TRUE;\n\t\t}\n\t} else {\n\t\tif ((!filter->nb_pck_io && filter->pending_packets && (filter->nb_pids_playing>0) && !gf_filter_connections_pending(filter)) || for_reconnection) {\n\t\t\tif (!filter->nb_consecutive_errors)\n\t\t\t\tfilter->time_at_first_error = gf_sys_clock_high_res();\n\t\t\tfilter->nb_consecutive_errors++;\n\n\t\t\tout_e = GF_SERVICE_ERROR;\n\t\t\tif (filter->nb_consecutive_errors >= 100000) {\n\t\t\t\tif (for_reconnection) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"[Filter] %s not responding properly: %d consecutive attempts at reconfiguring\\n\\tdiscarding all inputs and notifying end of stream on all outputs\\n\", filter->name, filter->nb_consecutive_errors));\n\t\t\t\t} else if (!filter->session->in_final_flush) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"[Filter] %s not responding properly: %d consecutive process with no packet discarded or sent, but %d packets pending\\n\\tdiscarding all inputs and notifying end of stream on all outputs\\n\", filter->name, filter->nb_consecutive_errors, filter->pending_packets));\n\t\t\t\t} else {\n\t\t\t\t\tout_e = GF_OK;\n\t\t\t\t}\n\t\t\t\tkill_filter = GF_TRUE;\n\t\t\t}\n\t\t} else {\n\t\t\tfilter->nb_consecutive_errors = 0;\n\t\t\tfilter->nb_pck_io = 0;\n\t\t}\n\t}\n\n\tif (kill_filter) {\n\t\tu32 i;\n\t\tgf_mx_p(filter->tasks_mx);\n\t\tfor (i=0; i<filter->num_input_pids; i++) {\n\t\t\tGF_FilterPidInst *pidi = gf_list_get(filter->input_pids, i);\n\t\t\tgf_filter_pid_set_discard((GF_FilterPid *)pidi, GF_TRUE);\n\t\t}\n\t\tfor (i=0; i<filter->num_output_pids; i++) {\n\t\t\tGF_FilterPid *pid = gf_list_get(filter->output_pids, i);\n\t\t\tgf_filter_pid_set_eos(pid);\n\t\t}\n\t\tgf_mx_v(filter->tasks_mx);\n\t\tfilter->session->last_process_error = out_e;\n\t\tfilter->disabled = GF_TRUE;\n\t}\n}","target":0,"code_token_length":762,"total_token_length":998,"max_tokens_setting":1024}
+{"idx":179140,"func":"ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)\n{\n\tphp_stream\t*tmpstream = NULL;\n\tdatabuf_t\t*data = NULL;\n\tchar\t\t*ptr;\n\tint\t\tch, lastch;\n\tsize_t\t\tsize, rcvd;\n\tsize_t\t\tlines;\n\tchar\t\t**ret = NULL;\n\tchar\t\t**entry;\n\tchar\t\t*text;\n\n\n\tif ((tmpstream = php_stream_fopen_tmpfile()) == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unable to create temporary file.  Check permissions in temporary files directory.\");\n\t\treturn NULL;\n\t}\n\n\tif (!ftp_type(ftp, FTPTYPE_ASCII)) {\n\t\tgoto bail;\n\t}\n\n\tif ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {\n\t\tgoto bail;\n\t}\n\tftp->data = data;\n\n\tif (!ftp_putcmd(ftp, cmd, path)) {\n\t\tgoto bail;\n\t}\n\tif (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125 && ftp->resp != 226)) {\n\t\tgoto bail;\n\t}\n\n\t\/* some servers don't open a ftp-data connection if the directory is empty *\/\n\tif (ftp->resp == 226) {\n\t\tftp->data = data_close(ftp, data);\n\t\tphp_stream_close(tmpstream);\n\t\treturn ecalloc(1, sizeof(char*));\n\t}\n\n\t\/* pull data buffer into tmpfile *\/\n\tif ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) {\n\t\tgoto bail;\n\t}\n\tsize = 0;\n\tlines = 0;\n\tlastch = 0;\n\twhile ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) {\n\t\tif (rcvd == -1 || rcvd > ((size_t)(-1))-size) {\n\t\t\tgoto bail;\n\t\t}\n\n\t\tphp_stream_write(tmpstream, data->buf, rcvd);\n\n\t\tsize += rcvd;\n                for (ptr = data->buf; rcvd; rcvd--, ptr++) {\n                        if (*ptr == '\\n' && lastch == '\\r') {\n                                lines++;\n                        }\n                        lastch = *ptr;\n                }\n\t\t\tlastch = *ptr;\n\t\t}\n\t}\n","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":146490,"func":"int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC,\n                        program_config *pce_out)\n{\n    program_config pce;\n\n    \/* 1024 or 960 *\/\n    mp4ASC->frameLengthFlag = faad_get1bit(ld\n        DEBUGVAR(1,138,\"GASpecificConfig(): FrameLengthFlag\"));\n#ifndef ALLOW_SMALL_FRAMELENGTH\n    if (mp4ASC->frameLengthFlag == 1)\n        return -3;\n#endif\n\n    mp4ASC->dependsOnCoreCoder = faad_get1bit(ld\n        DEBUGVAR(1,139,\"GASpecificConfig(): DependsOnCoreCoder\"));\n    if (mp4ASC->dependsOnCoreCoder == 1)\n    {\n        mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14\n            DEBUGVAR(1,140,\"GASpecificConfig(): CoreCoderDelay\"));\n    }\n\n    mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,\"GASpecificConfig(): ExtensionFlag\"));\n    if (mp4ASC->channelsConfiguration == 0)\n    {\n        if (program_config_element(&pce, ld))\n            return -3;\n        \/\/mp4ASC->channelsConfiguration = pce.channels;\n\n        if (pce_out != NULL)\n            memcpy(pce_out, &pce, sizeof(program_config));\n\n        \/*\n        if (pce.num_valid_cc_elements)\n            return -3;\n        *\/\n    }\n\n#ifdef ERROR_RESILIENCE\n    if (mp4ASC->extensionFlag == 1)\n    {\n        \/* Error resilience not supported yet *\/\n        if (mp4ASC->objectTypeIndex >= ER_OBJECT_START)\n        {\n            mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld\n                DEBUGVAR(1,144,\"GASpecificConfig(): aacSectionDataResilienceFlag\"));\n            mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld\n                DEBUGVAR(1,145,\"GASpecificConfig(): aacScalefactorDataResilienceFlag\"));\n            mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld\n                DEBUGVAR(1,146,\"GASpecificConfig(): aacSpectralDataResilienceFlag\"));\n        }\n        \/* 1 bit: extensionFlag3 *\/\n        faad_getbits(ld, 1);\n\t}\n#endif\n\n    return 0;\n}","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":434416,"func":"static int do_insert_tree(struct quota_handle *h, struct dquot *dquot,\n\t\t\t  unsigned int * treeblk, int depth)\n{\n\tdqbuf_t buf;\n\tint newson = 0, newact = 0;\n\t__le32 *ref;\n\tunsigned int newblk;\n\tint ret = 0;\n\n\tlog_debug(\"inserting in tree: treeblk=%u, depth=%d\", *treeblk, depth);\n\tbuf = getdqbuf();\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tif (!*treeblk) {\n\t\tret = get_free_dqblk(h);\n\t\tif (ret < 0)\n\t\t\tgoto out_buf;\n\t\t*treeblk = ret;\n\t\tmemset(buf, 0, QT_BLKSIZE);\n\t\tnewact = 1;\n\t} else {\n\t\tread_blk(h, *treeblk, buf);\n\t}\n\n\tref = (__le32 *) buf;\n\tnewblk = ext2fs_le32_to_cpu(ref[get_index(dquot->dq_id, depth)]);\n\tif (!newblk)\n\t\tnewson = 1;\n\tif (depth == QT_TREEDEPTH - 1) {\n\t\tif (newblk)\n\t\t\tlog_err(\"Inserting already present quota entry \"\n\t\t\t\t\"(block %u).\",\n\t\t\t\tref[get_index(dquot->dq_id, depth)]);\n\t\tnewblk = find_free_dqentry(h, dquot, &ret);\n\t} else {\n\t\tret = do_insert_tree(h, dquot, &newblk, depth + 1);\n\t}\n\n\tif (newson && ret >= 0) {\n\t\tref[get_index(dquot->dq_id, depth)] =\n\t\t\text2fs_cpu_to_le32(newblk);\n\t\twrite_blk(h, *treeblk, buf);\n\t} else if (newact && ret < 0) {\n\t\tput_free_dqblk(h, buf, *treeblk);\n\t}\n\nout_buf:\n\tfreedqbuf(buf);\n\treturn ret;\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":514167,"func":"_fill_a8_lerp_spans (void *abstract_renderer, int y, int h,\n\t\t     const cairo_half_open_span_t *spans, unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (likely(h == 1)) {\n\tdo {\n\t    uint8_t a = mul8_8 (spans[0].coverage, r->bpp);\n\t    if (a) {\n\t\tint len = spans[1].x - spans[0].x;\n\t\tuint8_t *d = r->u.fill.data + r->u.fill.stride*y + spans[0].x;\n\t\tuint16_t p = (uint16_t)a * r->u.fill.pixel + 0x7f;\n\t\tuint16_t ia = ~a;\n\t\twhile (len-- > 0) {\n\t\t    uint16_t t = *d*ia + p;\n\t\t    *d++ = (t + (t>>8)) >> 8;\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    } else {\n\tdo {\n\t    uint8_t a = mul8_8 (spans[0].coverage, r->bpp);\n\t    if (a) {\n\t\tint yy = y, hh = h;\n\t\tuint16_t p = (uint16_t)a * r->u.fill.pixel + 0x7f;\n\t\tuint16_t ia = ~a;\n\t\tdo {\n\t\t    int len = spans[1].x - spans[0].x;\n\t\t    uint8_t *d = r->u.fill.data + r->u.fill.stride*yy + spans[0].x;\n\t\t    while (len-- > 0) {\n\t\t\tuint16_t t = *d*ia + p;\n\t\t\t*d++ = (t + (t>>8)) >> 8;\n\t\t    }\n\t\t    yy++;\n\t\t} while (--hh);\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":98413,"func":"static int jpc_siz_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate,\n  jas_stream_t *in)\n{\n\tjpc_siz_t *siz = &ms->parms.siz;\n\tunsigned int i;\n\tuint_fast8_t tmp;\n\n\t\/* Eliminate compiler warning about unused variables. *\/\n\tcstate = 0;\n\n\tif (jpc_getuint16(in, &siz->caps) ||\n\t  jpc_getuint32(in, &siz->width) ||\n\t  jpc_getuint32(in, &siz->height) ||\n\t  jpc_getuint32(in, &siz->xoff) ||\n\t  jpc_getuint32(in, &siz->yoff) ||\n\t  jpc_getuint32(in, &siz->tilewidth) ||\n\t  jpc_getuint32(in, &siz->tileheight) ||\n\t  jpc_getuint32(in, &siz->tilexoff) ||\n\t  jpc_getuint32(in, &siz->tileyoff) ||\n\t  jpc_getuint16(in, &siz->numcomps)) {\n\t\treturn -1;\n\t}\n\tif (!siz->width || !siz->height || !siz->tilewidth ||\n\t  !siz->tileheight || !siz->numcomps) {\n\t\treturn -1;\n\t}\n\tif (!(siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t)))) {\n\t\treturn -1;\n\t}\n\tfor (i = 0; i < siz->numcomps; ++i) {\n\t\tif (jpc_getuint8(in, &tmp) ||\n\t\t  jpc_getuint8(in, &siz->comps[i].hsamp) ||\n\t\t  jpc_getuint8(in, &siz->comps[i].vsamp)) {\n\t\t\tjas_free(siz->comps);\n\t\t\treturn -1;\n\t\t}\n\t\tif (siz->comps[i].hsamp == 0 || siz->comps[i].hsamp > 255) {\n\t\t\tjas_eprintf(\"invalid XRsiz value %d\\n\", siz->comps[i].hsamp);\n\t\t\tjas_free(siz->comps);\n\t\t\treturn -1;\n\t\t}\n\t\tif (siz->comps[i].vsamp == 0 || siz->comps[i].vsamp > 255) {\n\t\t\tjas_eprintf(\"invalid YRsiz value %d\\n\", siz->comps[i].vsamp);\n\t\t\tjas_free(siz->comps);\n\t\t\treturn -1;\n\t\t}\n\t\tsiz->comps[i].sgnd = (tmp >> 7) & 1;\n\t\tsiz->comps[i].prec = (tmp & 0x7f) + 1;\n\t}\n\tif (jas_stream_eof(in)) {\n\t\tjas_free(siz->comps);\n\t\treturn -1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":646,"total_token_length":882,"max_tokens_setting":1024}
+{"idx":370461,"func":"int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend)\n{\n\tstruct uri_auth *uri_auth = backend->uri_auth;\n\tstruct http_msg *msg = &txn->req;\n\tconst char *uri = msg->chn->buf->p+ msg->sl.rq.u;\n\tconst char *h;\n\n\tif (!uri_auth)\n\t\treturn 0;\n\n\tif (txn->meth != HTTP_METH_GET && txn->meth != HTTP_METH_HEAD && txn->meth != HTTP_METH_POST)\n\t\treturn 0;\n\n\tmemset(&si->applet.ctx.stats, 0, sizeof(si->applet.ctx.stats));\n\tsi->applet.ctx.stats.st_code = STAT_STATUS_INIT;\n\tsi->applet.ctx.stats.flags |= STAT_FMT_HTML; \/* assume HTML mode by default *\/\n\n\t\/* check URI size *\/\n\tif (uri_auth->uri_len > msg->sl.rq.u_l)\n\t\treturn 0;\n\n\th = uri;\n\tif (memcmp(h, uri_auth->uri_prefix, uri_auth->uri_len) != 0)\n\t\treturn 0;\n\n\th += uri_auth->uri_len;\n\twhile (h <= uri + msg->sl.rq.u_l - 3) {\n\t\tif (memcmp(h, \";up\", 3) == 0) {\n\t\t\tsi->applet.ctx.stats.flags |= STAT_HIDE_DOWN;\n\t\t\tbreak;\n\t\t}\n\t\th++;\n\t}\n\n\tif (uri_auth->refresh) {\n\t\th = uri + uri_auth->uri_len;\n\t\twhile (h <= uri + msg->sl.rq.u_l - 10) {\n\t\t\tif (memcmp(h, \";norefresh\", 10) == 0) {\n\t\t\t\tsi->applet.ctx.stats.flags |= STAT_NO_REFRESH;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\th++;\n\t\t}\n\t}\n\n\th = uri + uri_auth->uri_len;\n\twhile (h <= uri + msg->sl.rq.u_l - 4) {\n\t\tif (memcmp(h, \";csv\", 4) == 0) {\n\t\t\tsi->applet.ctx.stats.flags &= ~STAT_FMT_HTML;\n\t\t\tbreak;\n\t\t}\n\t\th++;\n\t}\n\n\th = uri + uri_auth->uri_len;\n\twhile (h <= uri + msg->sl.rq.u_l - 8) {\n\t\tif (memcmp(h, \";st=\", 4) == 0) {\n\t\t\tint i;\n\t\t\th += 4;\n\t\t\tsi->applet.ctx.stats.st_code = STAT_STATUS_UNKN;\n\t\t\tfor (i = STAT_STATUS_INIT + 1; i < STAT_STATUS_SIZE; i++) {\n\t\t\t\tif (strncmp(stat_status_codes[i], h, 4) == 0) {\n\t\t\t\t\tsi->applet.ctx.stats.st_code = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\th++;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":240906,"func":"static MagickBooleanType SkipDXTMipmaps(Image *image,DDSInfo *dds_info,\n  int texel_size,ExceptionInfo *exception)\n{\n  register ssize_t\n    i;\n\n  MagickOffsetType\n    offset;\n\n  size_t\n    h,\n    w;\n\n  \/*\n    Only skip mipmaps for textures and cube maps\n  *\/\n  if (EOFBlob(image) != MagickFalse)\n    {\n      ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n        image->filename);\n      return(MagickFalse);\n    }\n  if (dds_info->ddscaps1 & DDSCAPS_MIPMAP\n      && (dds_info->ddscaps1 & DDSCAPS_TEXTURE\n          || dds_info->ddscaps2 & DDSCAPS2_CUBEMAP))\n    {\n      w = DIV2(dds_info->width);\n      h = DIV2(dds_info->height);\n\n      \/*\n        Mipmapcount includes the main image, so start from one\n      *\/\n      for (i = 1; (i < (ssize_t) dds_info->mipmapcount) && w && h; i++)\n      {\n        offset = (MagickOffsetType) ((w + 3) \/ 4) * ((h + 3) \/ 4) * texel_size;\n        if (SeekBlob(image,offset,SEEK_CUR) < 0)\n          break;\n        w = DIV2(w);\n        h = DIV2(h);\n      }\n    }\n  return(MagickTrue);\n}\n","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":391159,"func":"init_ecdh(SSL_CTX * sctx, host_item * host)\n{\nEC_KEY * ecdh;\nuschar * exp_curve;\nint nid;\nBOOL rv;\n\n#ifdef OPENSSL_NO_ECDH\nreturn TRUE;\n#else\n\nif (host)\t\/* No ECDH setup for clients, only for servers *\/\n  return TRUE;\n\n# ifndef EXIM_HAVE_ECDH\nDEBUG(D_tls)\n  debug_printf(\"No OpenSSL API to define ECDH parameters, skipping\\n\");\nreturn TRUE;\n# else\n\nif (!expand_check(tls_eccurve, US\"tls_eccurve\", &exp_curve))\n  return FALSE;\nif (!exp_curve || !*exp_curve)\n  return TRUE;\n\n#  ifdef EXIM_HAVE_OPENSSL_ECDH_AUTO\n\/* check if new enough library to support auto ECDH temp key parameter selection *\/\nif (Ustrcmp(exp_curve, \"auto\") == 0)\n  {\n  DEBUG(D_tls) debug_printf(\n    \"ECDH temp key parameter settings: OpenSSL 1.2+ autoselection\\n\");\n  SSL_CTX_set_ecdh_auto(sctx, 1);\n  return TRUE;\n  }\n#  endif\n\nDEBUG(D_tls) debug_printf(\"ECDH: curve '%s'\\n\", exp_curve);\nif (  (nid = OBJ_sn2nid       (CCS exp_curve)) == NID_undef\n#   ifdef EXIM_HAVE_OPENSSL_EC_NIST2NID\n   && (nid = EC_curve_nist2nid(CCS exp_curve)) == NID_undef\n#   endif\n   )\n  {\n  tls_error(string_sprintf(\"Unknown curve name tls_eccurve '%s'\",\n      exp_curve),\n    host, NULL);\n  return FALSE;\n  }\n\nif (!(ecdh = EC_KEY_new_by_curve_name(nid)))\n  {\n  tls_error(\"Unable to create ec curve\", host, NULL);\n  return FALSE;\n  }\n\n\/* The \"tmp\" in the name here refers to setting a temporary key\nnot to the stability of the interface. *\/\n\nif ((rv = SSL_CTX_set_tmp_ecdh(sctx, ecdh) == 0))\n  tls_error(string_sprintf(\"Error enabling '%s' curve\", exp_curve), host, NULL);\nelse\n  DEBUG(D_tls) debug_printf(\"ECDH: enabled '%s' curve\\n\", exp_curve);\n\nEC_KEY_free(ecdh);\nreturn !rv;\n\n# endif\t\/*EXIM_HAVE_ECDH*\/\n#endif \/*OPENSSL_NO_ECDH*\/\n}","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":429621,"func":"MagickExport Image *NewMagickImage(const ImageInfo *image_info,\n  const size_t width,const size_t height,const PixelInfo *background,\n  ExceptionInfo *exception)\n{\n  CacheView\n    *image_view;\n\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    y;\n\n  assert(image_info != (const ImageInfo *) NULL);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"...\");\n  assert(image_info->signature == MagickCoreSignature);\n  assert(background != (const PixelInfo *) NULL);\n  image=AcquireImage(image_info,exception);\n  image->columns=width;\n  image->rows=height;\n  image->colorspace=background->colorspace;\n  image->alpha_trait=background->alpha_trait;\n  image->fuzz=background->fuzz;\n  image->depth=background->depth;\n  status=MagickTrue;\n  image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n  #pragma omp parallel for schedule(static) shared(status) \\\n    magick_number_threads(image,image,image->rows,1)\n#endif\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    register Quantum\n      *magick_restrict q;\n\n    register ssize_t\n      x;\n\n    if (status == MagickFalse)\n      continue;\n    q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      {\n        status=MagickFalse;\n        continue;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      SetPixelViaPixelInfo(image,background,q);\n      q+=GetPixelChannels(image);\n    }\n    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n      status=MagickFalse;\n  }\n  image_view=DestroyCacheView(image_view);\n  if (status == MagickFalse)\n    image=DestroyImage(image);\n  return(image);\n}","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":67851,"func":"static pgoff_t shmem_seek_hole_data(struct address_space *mapping,\n\t\t\t\t    pgoff_t index, pgoff_t end, int whence)\n{\n\tstruct page *page;\n\tstruct pagevec pvec;\n\tpgoff_t indices[PAGEVEC_SIZE];\n\tbool done = false;\n\tint i;\n\n\tpagevec_init(&pvec, 0);\n\tpvec.nr = 1;\t\t\/* start small: we may be there already *\/\n\twhile (!done) {\n\t\tpvec.nr = shmem_find_get_pages_and_swap(mapping, index,\n\t\t\t\t\tpvec.nr, pvec.pages, indices);\n\t\tif (!pvec.nr) {\n\t\t\tif (whence == SEEK_DATA)\n\t\t\t\tindex = end;\n\t\t\tbreak;\n\t\t}\n\t\tfor (i = 0; i < pvec.nr; i++, index++) {\n\t\t\tif (index < indices[i]) {\n\t\t\t\tif (whence == SEEK_HOLE) {\n\t\t\t\t\tdone = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindex = indices[i];\n\t\t\t}\n\t\t\tpage = pvec.pages[i];\n\t\t\tif (page && !radix_tree_exceptional_entry(page)) {\n\t\t\t\tif (!PageUptodate(page))\n\t\t\t\t\tpage = NULL;\n\t\t\t}\n\t\t\tif (index >= end ||\n\t\t\t    (page && whence == SEEK_DATA) ||\n\t\t\t    (!page && whence == SEEK_HOLE)) {\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tshmem_deswap_pagevec(&pvec);\n\t\tpagevec_release(&pvec);\n\t\tpvec.nr = PAGEVEC_SIZE;\n\t\tcond_resched();\n\t}\n\treturn index;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":206200,"func":"PHP_FUNCTION(openssl_csr_export_to_file)\n{\n\tX509_REQ * csr;\n\tzval * zcsr = NULL;\n\tzend_bool notext = 1;\n\tchar * filename = NULL;\n\tsize_t filename_len;\n\tBIO * bio_out;\n\tzend_resource *csr_resource;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"rp|b\", &zcsr, &filename, &filename_len, ¬ext) == FAILURE) {\n\t\treturn;\n\t}\n\tRETVAL_FALSE;\n\n\tcsr = php_openssl_csr_from_zval(zcsr, 0, &csr_resource);\n\tif (csr == NULL) {\n\t\tphp_error_docref(NULL, E_WARNING, \"cannot get CSR from parameter 1\");\n\t\treturn;\n\t}\n\n\tif (php_openssl_open_base_dir_chk(filename)) {\n\t\treturn;\n\t}\n\n\tbio_out = BIO_new_file(filename, \"w\");\n\tif (bio_out != NULL) {\n\t\tif (!notext && !X509_REQ_print(bio_out, csr)) {\n\t\t\tphp_openssl_store_errors();\n\t\t}\n\t\tif (!PEM_write_bio_X509_REQ(bio_out, csr)) {\n\t\t\tphp_error_docref(NULL, E_WARNING, \"error writing PEM to file %s\", filename);\n\t\t\tphp_openssl_store_errors();\n\t\t} else {\n\t\t\tRETVAL_TRUE;\n\t\t}\n\t\tBIO_free(bio_out);\n\t} else {\n\t\tphp_openssl_store_errors();\n\t\tphp_error_docref(NULL, E_WARNING, \"error opening file %s\", filename);\n\t}\n\n\tif (csr_resource == NULL && csr != NULL) {\n\t\tX509_REQ_free(csr);\n\t}\n}\n","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":517970,"func":"void make_used_partitions_str(MEM_ROOT *alloc,\n                              partition_info *part_info,\n                              String *parts_str,\n                              String_list &used_partitions_list)\n{\n  parts_str->length(0);\n  partition_element *pe;\n  uint partition_id= 0;\n  List_iterator<partition_element> it(part_info->partitions);\n  \n  if (part_info->is_sub_partitioned())\n  {\n    partition_element *head_pe;\n    while ((head_pe= it++))\n    {\n      List_iterator<partition_element> it2(head_pe->subpartitions);\n      while ((pe= it2++))\n      {\n        if (bitmap_is_set(&part_info->read_partitions, partition_id))\n        {\n          if (parts_str->length())\n            parts_str->append(',');\n          uint index= parts_str->length();\n          parts_str->append(head_pe->partition_name,\n                           strlen(head_pe->partition_name),\n                           system_charset_info);\n          parts_str->append('_');\n          parts_str->append(pe->partition_name,\n                           strlen(pe->partition_name),\n                           system_charset_info);\n          used_partitions_list.append_str(alloc, parts_str->ptr() + index);\n        }\n        partition_id++;\n      }\n    }\n  }\n  else\n  {\n    while ((pe= it++))\n    {\n      if (bitmap_is_set(&part_info->read_partitions, partition_id))\n      {\n        if (parts_str->length())\n          parts_str->append(',');\n        used_partitions_list.append_str(alloc, pe->partition_name);\n        parts_str->append(pe->partition_name, strlen(pe->partition_name),\n                         system_charset_info);\n      }\n      partition_id++;\n    }\n  }\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":99353,"func":"void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)\n{\n\t\/* Address WBINVD may be executed by guest *\/\n\tif (need_emulate_wbinvd(vcpu)) {\n\t\tif (kvm_x86_ops->has_wbinvd_exit())\n\t\t\tcpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask);\n\t\telse if (vcpu->cpu != -1 && vcpu->cpu != cpu)\n\t\t\tsmp_call_function_single(vcpu->cpu,\n\t\t\t\t\twbinvd_ipi, NULL, 1);\n\t}\n\n\tkvm_x86_ops->vcpu_load(vcpu, cpu);\n\n\t\/* Apply any externally detected TSC adjustments (due to suspend) *\/\n\tif (unlikely(vcpu->arch.tsc_offset_adjustment)) {\n\t\tadjust_tsc_offset_host(vcpu, vcpu->arch.tsc_offset_adjustment);\n\t\tvcpu->arch.tsc_offset_adjustment = 0;\n\t\tkvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);\n\t}\n\n\tif (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) {\n\t\ts64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 :\n\t\t\t\tnative_read_tsc() - vcpu->arch.last_host_tsc;\n\t\tif (tsc_delta < 0)\n\t\t\tmark_tsc_unstable(\"KVM discovered backwards TSC\");\n\t\tif (check_tsc_unstable()) {\n\t\t\tu64 offset = kvm_x86_ops->compute_tsc_offset(vcpu,\n\t\t\t\t\t\tvcpu->arch.last_guest_tsc);\n\t\t\tkvm_x86_ops->write_tsc_offset(vcpu, offset);\n\t\t\tvcpu->arch.tsc_catchup = 1;\n\t\t}\n\t\t\/*\n\t\t * On a host with synchronized TSC, there is no need to update\n\t\t * kvmclock on vcpu->cpu migration\n\t\t *\/\n\t\tif (!vcpu->kvm->arch.use_master_clock || vcpu->cpu == -1)\n\t\t\tkvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu);\n\t\tif (vcpu->cpu != cpu)\n\t\t\tkvm_migrate_timers(vcpu);\n\t\tvcpu->cpu = cpu;\n\t}\n\n\taccumulate_steal_time(vcpu);\n\tkvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":66947,"func":"static MagickBooleanType IsBoundsCleared(const Image *image1,\n  const Image *image2,RectangleInfo *bounds,ExceptionInfo *exception)\n{\n  register const PixelPacket\n    *p,\n    *q;\n\n  register ssize_t\n    x;\n\n  ssize_t\n    y;\n\n  if (bounds->x < 0)\n    return(MagickFalse);\n  for (y=0; y < (ssize_t) bounds->height; y++)\n  {\n    p=GetVirtualPixels(image1,bounds->x,bounds->y+y,bounds->width,1,\n      exception);\n    q=GetVirtualPixels(image2,bounds->x,bounds->y+y,bounds->width,1,\n      exception);\n    if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))\n      break;\n    for (x=0; x < (ssize_t) bounds->width; x++)\n    {\n      if ((GetPixelOpacity(p) <= (Quantum) (QuantumRange\/2)) &&\n          (GetPixelOpacity(q) > (Quantum) (QuantumRange\/2)))\n        break;\n      p++;\n      q++;\n    }\n    if (x < (ssize_t) bounds->width)\n      break;\n  }\n  return(y < (ssize_t) bounds->height ? MagickTrue : MagickFalse);\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":234517,"func":"DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent\n                      *pEvents, int count, Mask filter, GrabPtr grab)\n{\n    int deliveries = 0, nondeliveries = 0;\n    ClientPtr client = NullClient;\n    Mask deliveryMask = 0;      \/* If a grab occurs due to a button press, then\n                                   this mask is the mask of the grab. *\/\n    int type = pEvents->u.u.type;\n\n    \/* Deliver to window owner *\/\n    if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0) {\n        enum EventDeliveryState rc;\n\n        rc = DeliverToWindowOwner(pDev, pWin, pEvents, count, filter, grab);\n\n        switch (rc) {\n        case EVENT_SKIP:\n            return 0;\n        case EVENT_REJECTED:\n            nondeliveries--;\n            break;\n        case EVENT_DELIVERED:\n            \/* We delivered to the owner, with our event mask *\/\n            deliveries++;\n            client = wClient(pWin);\n            deliveryMask = pWin->eventMask;\n            break;\n        case EVENT_NOT_DELIVERED:\n            break;\n        }\n    }\n\n    \/* CantBeFiltered means only window owner gets the event *\/\n    if (filter != CantBeFiltered) {\n        enum EventDeliveryState rc;\n\n        rc = DeliverEventToWindowMask(pDev, pWin, pEvents, count, filter,\n                                      grab, &client, &deliveryMask);\n\n        switch (rc) {\n        case EVENT_SKIP:\n            return 0;\n        case EVENT_REJECTED:\n            nondeliveries--;\n            break;\n        case EVENT_DELIVERED:\n            deliveries++;\n            break;\n        case EVENT_NOT_DELIVERED:\n            break;\n        }\n    }\n\n    if (deliveries) {\n        \/*\n         * Note that since core events are delivered first, an implicit grab may\n         * be activated on a core grab, stopping the XI events.\n         *\/\n        if (!grab &&\n            ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))\n            \/* grab activated *\/ ;\n        else if (type == MotionNotify)\n            pDev->valuator->motionHintWindow = pWin;\n        else if (type == DeviceMotionNotify || type == DeviceButtonPress)\n            CheckDeviceGrabAndHintWindow(pWin, type,\n                                         (deviceKeyButtonPointer *) pEvents,\n                                         grab, client, deliveryMask);\n        return deliveries;\n    }\n    return nondeliveries;\n}\n","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":271689,"func":"char *FLTGetFeatureIdCommonExpression(FilterEncodingNode *psFilterNode, layerObj *lp)\n{\n  char *pszExpression = NULL;\n  int nTokens = 0, i=0, bString=0;\n  char **tokens = NULL;\n  const char *pszAttribute=NULL;\n\n#if defined(USE_WMS_SVR) || defined(USE_WFS_SVR) || defined(USE_WCS_SVR) || defined(USE_SOS_SVR)\n  if (psFilterNode->pszValue) {\n    pszAttribute = msOWSLookupMetadata(&(lp->metadata), \"OFG\", \"featureid\");\n    if (pszAttribute) {\n      tokens = msStringSplit(psFilterNode->pszValue,',', &nTokens);\n      if (tokens && nTokens > 0) {\n        for (i=0; i<nTokens; i++) {\n          char *pszTmp = NULL;\n          int bufferSize = 0;\n          const char* pszId = tokens[i];\n          const char* pszDot = strchr(pszId, '.');\n          if( pszDot )\n            pszId = pszDot + 1;\n\n          if (i == 0) {\n            if(FLTIsNumeric(pszId) == MS_FALSE)\n              bString = 1;\n          }\n\n          if (bString) {\n            bufferSize = 11+strlen(pszId)+strlen(pszAttribute)+1;\n            pszTmp = (char *)msSmallMalloc(bufferSize);\n            snprintf(pszTmp, bufferSize, \"(\\\"[%s]\\\" ==\\\"%s\\\")\" , pszAttribute, pszId);\n          } else {\n            bufferSize = 8+strlen(pszId)+strlen(pszAttribute)+1;\n            pszTmp = (char *)msSmallMalloc(bufferSize);\n            snprintf(pszTmp, bufferSize, \"([%s] == %s)\" , pszAttribute, pszId);\n          }\n\n          if (pszExpression != NULL)\n            pszExpression = msStringConcatenate(pszExpression, \" OR \");\n          else\n            pszExpression = msStringConcatenate(pszExpression, \"(\");\n          pszExpression = msStringConcatenate(pszExpression, pszTmp);\n          msFree(pszTmp);\n        }\n\n        msFreeCharArray(tokens, nTokens);\n      }\n    }\n\n    \/* opening and closing brackets are needed for mapserver expressions *\/\n    if (pszExpression)\n      pszExpression = msStringConcatenate(pszExpression, \")\");\n  }\n#endif\n\n  return pszExpression;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":327559,"func":"static void gd_connect_signals(GtkDisplayState *s)\n\n{\n\n    g_signal_connect(s->show_tabs_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_show_tabs), s);\n\n\n\n    g_signal_connect(s->window, \"key-press-event\",\n\n                     G_CALLBACK(gd_window_key_event), s);\n\n    g_signal_connect(s->window, \"delete-event\",\n\n                     G_CALLBACK(gd_window_close), s);\n\n\n\n#if GTK_CHECK_VERSION(3, 0, 0)\n\n    g_signal_connect(s->drawing_area, \"draw\",\n\n                     G_CALLBACK(gd_draw_event), s);\n\n#else\n\n    g_signal_connect(s->drawing_area, \"expose-event\",\n\n                     G_CALLBACK(gd_expose_event), s);\n\n#endif\n\n    g_signal_connect(s->drawing_area, \"motion-notify-event\",\n\n                     G_CALLBACK(gd_motion_event), s);\n\n    g_signal_connect(s->drawing_area, \"button-press-event\",\n\n                     G_CALLBACK(gd_button_event), s);\n\n    g_signal_connect(s->drawing_area, \"button-release-event\",\n\n                     G_CALLBACK(gd_button_event), s);\n\n    g_signal_connect(s->drawing_area, \"scroll-event\",\n\n                     G_CALLBACK(gd_scroll_event), s);\n\n    g_signal_connect(s->drawing_area, \"key-press-event\",\n\n                     G_CALLBACK(gd_key_event), s);\n\n    g_signal_connect(s->drawing_area, \"key-release-event\",\n\n                     G_CALLBACK(gd_key_event), s);\n\n\n\n    g_signal_connect(s->pause_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_pause), s);\n\n    g_signal_connect(s->reset_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_reset), s);\n\n    g_signal_connect(s->powerdown_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_powerdown), s);\n\n    g_signal_connect(s->quit_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_quit), s);\n\n    g_signal_connect(s->full_screen_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_full_screen), s);\n\n    g_signal_connect(s->zoom_in_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_zoom_in), s);\n\n    g_signal_connect(s->zoom_out_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_zoom_out), s);\n\n    g_signal_connect(s->zoom_fixed_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_zoom_fixed), s);\n\n    g_signal_connect(s->zoom_fit_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_zoom_fit), s);\n\n    g_signal_connect(s->vga_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_switch_vc), s);\n\n    g_signal_connect(s->grab_item, \"activate\",\n\n                     G_CALLBACK(gd_menu_grab_input), s);\n\n    g_signal_connect(s->notebook, \"switch-page\",\n\n                     G_CALLBACK(gd_change_page), s);\n\n    g_signal_connect(s->drawing_area, \"enter-notify-event\",\n\n                     G_CALLBACK(gd_enter_event), s);\n\n    g_signal_connect(s->drawing_area, \"leave-notify-event\",\n\n                     G_CALLBACK(gd_leave_event), s);\n\n    g_signal_connect(s->drawing_area, \"focus-out-event\",\n\n                     G_CALLBACK(gd_focus_out_event), s);\n\n}\n","target":0,"code_token_length":650,"total_token_length":886,"max_tokens_setting":1024}
+{"idx":507461,"func":"int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n\t\t\t     X509_STORE *store, X509 **signer_out)\n\t{\n\tSTACK_OF(PKCS7_SIGNER_INFO) *sinfos = NULL;\n\tPKCS7_SIGNER_INFO *si;\n\tSTACK_OF(X509) *signers = NULL;\n\tX509\t*signer;\n\tSTACK_OF(X509) *chain = NULL;\n\tchar\tbuf[4096];\n\tint\ti, j = 0, ret = 0;\n\tBIO\t*p7bio = NULL;\n\n\t\/* Some sanity checks first. *\/\n\tif (!token)\n\t\t{\n\t\tTSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_INVALID_NULL_POINTER);\n\t\tgoto err;\n\t\t}\n\n\t\/* Check for the correct content type *\/\n\tif(!PKCS7_type_is_signed(token))\n\t\t{\n\t\tTSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_WRONG_CONTENT_TYPE);\n\t\tgoto err;\n\t\t}\n\n\t\/* Check if there is one and only one signer. *\/\n\tsinfos = PKCS7_get_signer_info(token);\n\tif (!sinfos || sk_PKCS7_SIGNER_INFO_num(sinfos) != 1)\n\t\t{\n\t\tTSerr(TS_F_TS_RESP_VERIFY_SIGNATURE,\n\t\t      TS_R_THERE_MUST_BE_ONE_SIGNER);\n\t\tgoto err;\n\t\t}\n\tsi = sk_PKCS7_SIGNER_INFO_value(sinfos, 0);\n\n\t\/* Check for no content: no data to verify signature. *\/\n\tif (PKCS7_get_detached(token))\n\t\t{\n\t\tTSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_NO_CONTENT);\n\t\tgoto err;\n\t\t}\n\t\n\t\/* Get hold of the signer certificate, search only internal\n\t   certificates if it was requested. *\/\n\tsigners = PKCS7_get0_signers(token, certs, 0);\n\tif (!signers || sk_X509_num(signers) != 1) goto err;\n\tsigner = sk_X509_value(signers, 0);\n\n\t\/* Now verify the certificate. *\/\n\tif (!TS_verify_cert(store, certs, signer, &chain)) goto err;\n\n\t\/* Check if the signer certificate is consistent with the\n\t   ESS extension. *\/\n\tif (!TS_check_signing_certs(si, chain)) goto err;\n\n\t\/* Creating the message digest. *\/\n\tp7bio = PKCS7_dataInit(token, NULL);\n\n\t\/* We now have to 'read' from p7bio to calculate digests etc. *\/\n\twhile ((i = BIO_read(p7bio,buf,sizeof(buf))) > 0);\n\n\t\/* Verifying the signature. *\/\n\tj = PKCS7_signatureVerify(p7bio, token, si, signer);\n\tif (j <= 0)\n\t\t{\n\t\tTSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_SIGNATURE_FAILURE);\n\t\tgoto err;\n\t\t}\n\n\t\/* Return the signer certificate if needed. *\/\n\tif (signer_out)\n\t\t{\n\t\t*signer_out = signer;\n\t\tCRYPTO_add(&signer->references, 1, CRYPTO_LOCK_X509);\n\t\t}\n\n\tret = 1;\n\n err:\n\tBIO_free_all(p7bio);\n\tsk_X509_pop_free(chain, X509_free);\n\tsk_X509_free(signers);\n\n\treturn ret;\n\t}","target":0,"code_token_length":718,"total_token_length":954,"max_tokens_setting":1024}
+{"idx":7453,"func":"static int rose_parse_national(unsigned char *p, struct rose_facilities_struct *facilities, int len)\n{\n\tunsigned char *pt;\n\tunsigned char l, lg, n = 0;\n\tint fac_national_digis_received = 0;\n\n\tdo {\n\t\tswitch (*p & 0xC0) {\n\t\tcase 0x00:\n\t\t\tp   += 2;\n\t\t\tn   += 2;\n\t\t\tlen -= 2;\n\t\t\tbreak;\n\n\t\tcase 0x40:\n\t\t\tif (*p == FAC_NATIONAL_RAND)\n\t\t\t\tfacilities->rand = ((p[1] << 8) & 0xFF00) + ((p[2] << 0) & 0x00FF);\n\t\t\tp   += 3;\n\t\t\tn   += 3;\n\t\t\tlen -= 3;\n\t\t\tbreak;\n\n\t\tcase 0x80:\n\t\t\tp   += 4;\n\t\t\tn   += 4;\n\t\t\tlen -= 4;\n\t\t\tbreak;\n\n\t\tcase 0xC0:\n\t\t\tl = p[1];\n\t\t\tif (*p == FAC_NATIONAL_DEST_DIGI) {\n\t\t\t\tif (!fac_national_digis_received) {\n\t\t\t\t\tmemcpy(&facilities->source_digis[0], p + 2, AX25_ADDR_LEN);\n\t\t\t\t\tfacilities->source_ndigis = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_SRC_DIGI) {\n\t\t\t\tif (!fac_national_digis_received) {\n\t\t\t\t\tmemcpy(&facilities->dest_digis[0], p + 2, AX25_ADDR_LEN);\n\t\t\t\t\tfacilities->dest_ndigis = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_FAIL_CALL) {\n\t\t\t\tmemcpy(&facilities->fail_call, p + 2, AX25_ADDR_LEN);\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_FAIL_ADD) {\n\t\t\t\tmemcpy(&facilities->fail_addr, p + 3, ROSE_ADDR_LEN);\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_DIGIS) {\n\t\t\t\tfac_national_digis_received = 1;\n\t\t\t\tfacilities->source_ndigis = 0;\n\t\t\t\tfacilities->dest_ndigis   = 0;\n\t\t\t\tfor (pt = p + 2, lg = 0 ; lg < l ; pt += AX25_ADDR_LEN, lg += AX25_ADDR_LEN) {\n\t\t\t\t\tif (pt[6] & AX25_HBIT) {\n\t\t\t\t\t\tif (facilities->dest_ndigis >= ROSE_MAX_DIGIS)\n\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\tmemcpy(&facilities->dest_digis[facilities->dest_ndigis++], pt, AX25_ADDR_LEN);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (facilities->source_ndigis >= ROSE_MAX_DIGIS)\n\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\tmemcpy(&facilities->source_digis[facilities->source_ndigis++], pt, AX25_ADDR_LEN);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tp   += l + 2;\n\t\t\tn   += l + 2;\n\t\t\tlen -= l + 2;\n\t\t\tbreak;\n\t\t}\n\t} while (*p != 0x00 && len > 0);\n\n\treturn n;\n}","target":1,"code_token_length":703,"total_token_length":939,"max_tokens_setting":1024}
+{"idx":134223,"func":"void EvalQuantizedPerChannel(TfLiteContext* context, TfLiteNode* node,\n                             TfLiteConvParams* params, const OpData& data,\n                             const TfLiteEvalTensor* input,\n                             const TfLiteEvalTensor* filter,\n                             const TfLiteEvalTensor* bias,\n                             TfLiteEvalTensor* output,\n                             TfLiteEvalTensor* im2col) {\n  \/\/ TODO(b\/154032858): Investigate removing extra copies.\n  ConvParams op_params;\n  op_params.input_offset = -data.input_zero_point;\n  op_params.output_offset = data.output_zero_point;\n  op_params.stride_height = params->stride_height;\n  op_params.stride_width = params->stride_width;\n  op_params.dilation_height_factor = params->dilation_height_factor;\n  op_params.dilation_width_factor = params->dilation_width_factor;\n  op_params.padding_values.height = data.padding.height;\n  op_params.padding_values.width = data.padding.width;\n  op_params.quantized_activation_min = data.output_activation_min;\n  op_params.quantized_activation_max = data.output_activation_max;\n\n  reference_integer_ops::ConvPerChannel(\n      op_params, data.per_channel_output_multiplier,\n      data.per_channel_output_shift, tflite::micro::GetTensorShape(input),\n      tflite::micro::GetTensorData<int8_t>(input),\n      tflite::micro::GetTensorShape(filter),\n      tflite::micro::GetTensorData<int8_t>(filter),\n      tflite::micro::GetTensorShape(bias),\n      tflite::micro::GetTensorData<int32_t>(bias),\n      tflite::micro::GetTensorShape(output),\n      tflite::micro::GetTensorData<int8_t>(output));\n}","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":178344,"func":"static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)\n{\n\tzval *IM, *POINTS;\n\tlong NPOINTS, COL;\n\tzval **var = NULL;\n\tgdImagePtr im;\n\tgdPointPtr points;\n\tint npoints, col, nelem, i;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rall\", &IM, &POINTS, &NPOINTS, &COL) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\n\tnpoints = NPOINTS;\n\tcol = COL;\n\n\tnelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS));\n\tif (nelem < 6) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"You must have at least 3 points in your array\");\n\t\tRETURN_FALSE;\n\t}\n\tif (npoints <= 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"You must give a positive number of points\");\n\t\tRETURN_FALSE;\n\t}\n\tif (nelem < npoints * 2) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Trying to use %d points in array with only %d points\", npoints, nelem\/2);\n\t\tRETURN_FALSE;\n\t}\n\n\tpoints = (gdPointPtr) safe_emalloc(npoints, sizeof(gdPoint), 0);\n\n\tfor (i = 0; i < npoints; i++) {\n\t\tif (zend_hash_index_find(Z_ARRVAL_P(POINTS), (i * 2), (void **) &var) == SUCCESS) {\n\t\t\tif (Z_TYPE_PP(var) != IS_LONG) {\n\t\t\t\tzval lval;\n\t\t\t\tlval = **var;\n\t\t\t\tzval_copy_ctor(&lval);\n\t\t\t\tconvert_to_long(&lval);\n\t\t\t\tpoints[i].x = Z_LVAL(lval);\n\t\t\t} else {\n\t\t\t\tpoints[i].x = Z_LVAL_PP(var);\n\t\t\t}\n\t\t}\n\t\tif (zend_hash_index_find(Z_ARRVAL_P(POINTS), (i * 2) + 1, (void **) &var) == SUCCESS) {\n\t\t\tif (Z_TYPE_PP(var) != IS_LONG) {\n\t\t\t\tzval lval;\n\t\t\t\tlval = **var;\n\t\t\t\tzval_copy_ctor(&lval);\n\t\t\t\tconvert_to_long(&lval);\n\t\t\t\tpoints[i].y = Z_LVAL(lval);\n\t\t\t} else {\n\t\t\t\tpoints[i].y = Z_LVAL_PP(var);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (filled) {\n\t\tgdImageFilledPolygon(im, points, npoints, col);\n\t} else {\n\t\tgdImagePolygon(im, points, npoints, col);\n\t}\n\n\tefree(points);\n\tRETURN_TRUE;\n}\n","target":0,"code_token_length":587,"total_token_length":823,"max_tokens_setting":1024}
+{"idx":82773,"func":"static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception)\n{\n\tstruct nfs_client *clp = server->nfs_client;\n\tstruct nfs4_state *state = exception->state;\n\tint ret = errorcode;\n\n\texception->retry = 0;\n\tswitch(errorcode) {\n\t\tcase 0:\n\t\t\treturn 0;\n\t\tcase -NFS4ERR_ADMIN_REVOKED:\n\t\tcase -NFS4ERR_BAD_STATEID:\n\t\tcase -NFS4ERR_OPENMODE:\n\t\t\tif (state == NULL)\n\t\t\t\tbreak;\n\t\t\tnfs4_state_mark_reclaim_nograce(clp, state);\n\t\tcase -NFS4ERR_STALE_CLIENTID:\n\t\tcase -NFS4ERR_STALE_STATEID:\n\t\tcase -NFS4ERR_EXPIRED:\n\t\t\tnfs4_schedule_state_recovery(clp);\n\t\t\tret = nfs4_wait_clnt_recover(clp);\n\t\t\tif (ret == 0)\n\t\t\t\texception->retry = 1;\n\t\t\tbreak;\n\t\tcase -NFS4ERR_FILE_OPEN:\n\t\tcase -NFS4ERR_GRACE:\n\t\tcase -NFS4ERR_DELAY:\n\t\t\tret = nfs4_delay(server->client, &exception->timeout);\n\t\t\tif (ret != 0)\n\t\t\t\tbreak;\n\t\tcase -NFS4ERR_OLD_STATEID:\n\t\t\texception->retry = 1;\n\t}\n\t\/* We failed to handle the error *\/\n\treturn nfs4_map_errors(ret);\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":152174,"func":"static int construct_alloc_key(struct keyring_search_context *ctx,\n\t\t\t       struct key *dest_keyring,\n\t\t\t       unsigned long flags,\n\t\t\t       struct key_user *user,\n\t\t\t       struct key **_key)\n{\n\tstruct assoc_array_edit *edit;\n\tstruct key *key;\n\tkey_perm_t perm;\n\tkey_ref_t key_ref;\n\tint ret;\n\n\tkenter(\"%s,%s,,,\",\n\t       ctx->index_key.type->name, ctx->index_key.description);\n\n\t*_key = NULL;\n\tmutex_lock(&user->cons_lock);\n\n\tperm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR;\n\tperm |= KEY_USR_VIEW;\n\tif (ctx->index_key.type->read)\n\t\tperm |= KEY_POS_READ;\n\tif (ctx->index_key.type == &key_type_keyring ||\n\t    ctx->index_key.type->update)\n\t\tperm |= KEY_POS_WRITE;\n\n\tkey = key_alloc(ctx->index_key.type, ctx->index_key.description,\n\t\t\tctx->cred->fsuid, ctx->cred->fsgid, ctx->cred,\n\t\t\tperm, flags);\n\tif (IS_ERR(key))\n\t\tgoto alloc_failed;\n\n\tset_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags);\n\n\tif (dest_keyring) {\n\t\tret = __key_link_begin(dest_keyring, &ctx->index_key, &edit);\n\t\tif (ret < 0)\n\t\t\tgoto link_prealloc_failed;\n\t}\n\n\t\/* attach the key to the destination keyring under lock, but we do need\n\t * to do another check just in case someone beat us to it whilst we\n\t * waited for locks *\/\n\tmutex_lock(&key_construction_mutex);\n\n\tkey_ref = search_process_keyrings(ctx);\n\tif (!IS_ERR(key_ref))\n\t\tgoto key_already_present;\n\n\tif (dest_keyring)\n\t\t__key_link(key, &edit);\n\n\tmutex_unlock(&key_construction_mutex);\n\tif (dest_keyring)\n\t\t__key_link_end(dest_keyring, &ctx->index_key, edit);\n\tmutex_unlock(&user->cons_lock);\n\t*_key = key;\n\tkleave(\" = 0 [%d]\", key_serial(key));\n\treturn 0;\n\n\t\/* the key is now present - we tell the caller that we found it by\n\t * returning -EINPROGRESS  *\/\nkey_already_present:\n\tkey_put(key);\n\tmutex_unlock(&key_construction_mutex);\n\tkey = key_ref_to_ptr(key_ref);\n\tif (dest_keyring) {\n\t\tret = __key_link_check_live_key(dest_keyring, key);\n\t\tif (ret == 0)\n\t\t\t__key_link(key, &edit);\n\t\t__key_link_end(dest_keyring, &ctx->index_key, edit);\n\t\tif (ret < 0)\n\t\t\tgoto link_check_failed;\n\t}\n\tmutex_unlock(&user->cons_lock);\n\t*_key = key;\n\tkleave(\" = -EINPROGRESS [%d]\", key_serial(key));\n\treturn -EINPROGRESS;\n\nlink_check_failed:\n\tmutex_unlock(&user->cons_lock);\n\tkey_put(key);\n\tkleave(\" = %d [linkcheck]\", ret);\n\treturn ret;\n\nlink_prealloc_failed:\n\tmutex_unlock(&user->cons_lock);\n\tkleave(\" = %d [prelink]\", ret);\n\treturn ret;\n\nalloc_failed:\n\tmutex_unlock(&user->cons_lock);\n\tkleave(\" = %ld\", PTR_ERR(key));\n\treturn PTR_ERR(key);\n}","target":0,"code_token_length":693,"total_token_length":929,"max_tokens_setting":1024}
+{"idx":18652,"func":"static void dumpUserConfig ( PGconn * conn , const char * username ) {\n PQExpBuffer buf = createPQExpBuffer ( ) ;\n int count = 1 ;\n for ( ;\n ;\n ) {\n PGresult * res ;\n if ( server_version >= 90000 ) printfPQExpBuffer ( buf , \"SELECT setconfig[%d] FROM pg_db_role_setting WHERE \" \"setdatabase = 0 AND setrole = \" \"(SELECT oid FROM pg_authid WHERE rolname = \" , count ) ;\n else if ( server_version >= 80100 ) printfPQExpBuffer ( buf , \"SELECT rolconfig[%d] FROM pg_authid WHERE rolname = \" , count ) ;\n else printfPQExpBuffer ( buf , \"SELECT useconfig[%d] FROM pg_shadow WHERE usename = \" , count ) ;\n appendStringLiteralConn ( buf , username , conn ) ;\n if ( server_version >= 90000 ) appendPQExpBufferChar ( buf , ')' ) ;\n res = executeQuery ( conn , buf -> data ) ;\n if ( PQntuples ( res ) == 1 && ! PQgetisnull ( res , 0 , 0 ) ) {\n makeAlterConfigCommand ( conn , PQgetvalue ( res , 0 , 0 ) , \"ROLE\" , username , NULL , NULL ) ;\n PQclear ( res ) ;\n count ++ ;\n }\n else {\n PQclear ( res ) ;\n break ;\n }\n }\n destroyPQExpBuffer ( buf ) ;\n }","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":323225,"func":"static inline FFAMediaCodec *codec_create(int method, const char *arg)\n\n{\n\n    int ret = -1;\n\n    JNIEnv *env = NULL;\n\n    FFAMediaCodec *codec = NULL;\n\n    jstring jarg = NULL;\n\n    jobject object = NULL;\n\n    jmethodID create_id = NULL;\n\n\n\n    codec = av_mallocz(sizeof(FFAMediaCodec));\n\n    if (!codec) {\n\n        return NULL;\n\n\n    codec->class = &amediacodec_class;\n\n\n\n    env = ff_jni_get_env(codec);\n\n    if (!env) {\n\n        av_freep(&codec);\n\n        return NULL;\n\n\n\n\n    if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {\n\n        goto fail;\n\n\n\n\n    jarg = ff_jni_utf_chars_to_jstring(env, arg, codec);\n\n    if (!jarg) {\n\n        goto fail;\n\n\n\n\n    switch (method) {\n\n    case CREATE_CODEC_BY_NAME:   create_id = codec->jfields.create_by_codec_name_id;   break;\n\n    case CREATE_DECODER_BY_TYPE: create_id = codec->jfields.create_decoder_by_type_id; break;\n\n    case CREATE_ENCODER_BY_TYPE: create_id = codec->jfields.create_encoder_by_type_id; break;\n\n    default:\n\n        av_assert0(0);\n\n\n\n\n    object = (*env)->CallStaticObjectMethod(env,\n\n                                            codec->jfields.mediacodec_class,\n\n                                            create_id,\n\n                                            jarg);\n\n    if (ff_jni_exception_check(env, 1, codec) < 0) {\n\n        goto fail;\n\n\n\n\n    codec->object = (*env)->NewGlobalRef(env, object);\n\n    if (!codec->object) {\n\n        goto fail;\n\n\n\n\n    if (codec_init_static_fields(codec) < 0) {\n\n        goto fail;\n\n\n\n\n    if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {\n\n        codec->has_get_i_o_buffer = 1;\n\n\n\n\n    ret = 0;\n\nfail:\n\n    if (jarg) {\n\n        (*env)->DeleteLocalRef(env, jarg);\n\n\n\n\n    if (object) {\n\n        (*env)->DeleteLocalRef(env, object);\n\n\n\n\n    if (ret < 0) {\n\n\n\n\n        ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);\n\n        av_freep(&codec);\n\n\n\n\n    return codec;\n","target":1,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":397267,"func":"static void ehci_execute_complete(EHCIQueue *q)\n{\n    EHCIPacket *p = QTAILQ_FIRST(&q->packets);\n    uint32_t tbytes;\n\n    assert(p != NULL);\n    assert(p->qtdaddr == q->qtdaddr);\n    assert(p->async == EHCI_ASYNC_INITIALIZED ||\n           p->async == EHCI_ASYNC_FINISHED);\n\n    DPRINTF(\"execute_complete: qhaddr 0x%x, next 0x%x, qtdaddr 0x%x, \"\n            \"status %d, actual_length %d\\n\",\n            q->qhaddr, q->qh.next, q->qtdaddr,\n            p->packet.status, p->packet.actual_length);\n\n    switch (p->packet.status) {\n    case USB_RET_SUCCESS:\n        break;\n    case USB_RET_IOERROR:\n    case USB_RET_NODEV:\n        q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR);\n        set_field(&q->qh.token, 0, QTD_TOKEN_CERR);\n        ehci_raise_irq(q->ehci, USBSTS_ERRINT);\n        break;\n    case USB_RET_STALL:\n        q->qh.token |= QTD_TOKEN_HALT;\n        ehci_raise_irq(q->ehci, USBSTS_ERRINT);\n        break;\n    case USB_RET_NAK:\n        set_field(&q->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT);\n        return; \/* We're not done yet with this transaction *\/\n    case USB_RET_BABBLE:\n        q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);\n        ehci_raise_irq(q->ehci, USBSTS_ERRINT);\n        break;\n    default:\n        \/* should not be triggerable *\/\n        fprintf(stderr, \"USB invalid response %d\\n\", p->packet.status);\n        g_assert_not_reached();\n        break;\n    }\n\n    \/* TODO check 4.12 for splits *\/\n    tbytes = get_field(q->qh.token, QTD_TOKEN_TBYTES);\n    if (tbytes && p->pid == USB_TOKEN_IN) {\n        tbytes -= p->packet.actual_length;\n        if (tbytes) {\n            \/* 4.15.1.2 must raise int on a short input packet *\/\n            ehci_raise_irq(q->ehci, USBSTS_INT);\n            if (q->async) {\n                q->ehci->int_req_by_async = true;\n            }\n        }\n    } else {\n        tbytes = 0;\n    }\n    DPRINTF(\"updating tbytes to %d\\n\", tbytes);\n    set_field(&q->qh.token, tbytes, QTD_TOKEN_TBYTES);\n\n    ehci_finish_transfer(q, p->packet.actual_length);\n    usb_packet_unmap(&p->packet, &p->sgl);\n    qemu_sglist_destroy(&p->sgl);\n    p->async = EHCI_ASYNC_NONE;\n\n    q->qh.token ^= QTD_TOKEN_DTOGGLE;\n    q->qh.token &= ~QTD_TOKEN_ACTIVE;\n\n    if (q->qh.token & QTD_TOKEN_IOC) {\n        ehci_raise_irq(q->ehci, USBSTS_INT);\n        if (q->async) {\n            q->ehci->int_req_by_async = true;\n        }\n    }\n}","target":0,"code_token_length":704,"total_token_length":940,"max_tokens_setting":1024}
+{"idx":308068,"func":"  FTC_SNode_New( FTC_SNode  *psnode,\n                 FTC_GQuery  gquery,\n                 FTC_Cache   cache )\n  {\n    FT_Memory   memory = cache->memory;\n    FT_Error    error;\n    FTC_SNode   snode  = NULL;\n    FT_UInt     gindex = gquery->gindex;\n    FTC_Family  family = gquery->family;\n\n    FTC_SFamilyClass  clazz = FTC_CACHE__SFAMILY_CLASS( cache );\n    FT_UInt           total;\n    FT_UInt           node_count;\n\n\n    total = clazz->family_get_count( family, cache->manager );\n    if ( total == 0 || gindex >= total )\n    {\n      error = FT_THROW( Invalid_Argument );\n      goto Exit;\n    }\n\n    if ( !FT_NEW( snode ) )\n    {\n      FT_UInt  count, start;\n\n\n      start = gindex - ( gindex % FTC_SBIT_ITEMS_PER_NODE );\n      count = total - start;\n      if ( count > FTC_SBIT_ITEMS_PER_NODE )\n        count = FTC_SBIT_ITEMS_PER_NODE;\n\n      FTC_GNode_Init( FTC_GNODE( snode ), start, family );\n\n      snode->count = count;\n      for ( node_count = 0; node_count < count; node_count++ )\n      {\n        snode->sbits[node_count].width = 255;\n      }\n\n      error = ftc_snode_load( snode,\n                              cache->manager,\n                              gindex,\n                              NULL );\n      if ( error )\n      {\n        FTC_SNode_Free( snode, cache );\n        snode = NULL;\n      }\n    }\n\n  Exit:\n    *psnode = snode;\n    return error;\n  }\n","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":214573,"func":"int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,\n\t\t\t\t      struct kvm_dirty_log *log)\n{\n\tint r;\n\tstruct kvm_memory_slot *memslot;\n\tunsigned long n, nr_dirty_pages;\n\n\tmutex_lock(&kvm->slots_lock);\n\n\tr = -EINVAL;\n\tif (log->slot >= KVM_MEMORY_SLOTS)\n\t\tgoto out;\n\n\tmemslot = id_to_memslot(kvm->memslots, log->slot);\n\tr = -ENOENT;\n\tif (!memslot->dirty_bitmap)\n\t\tgoto out;\n\n\tn = kvm_dirty_bitmap_bytes(memslot);\n\tnr_dirty_pages = memslot->nr_dirty_pages;\n\n\t\/* If nothing is dirty, don't bother messing with page tables. *\/\n\tif (nr_dirty_pages) {\n\t\tstruct kvm_memslots *slots, *old_slots;\n\t\tunsigned long *dirty_bitmap, *dirty_bitmap_head;\n\n\t\tdirty_bitmap = memslot->dirty_bitmap;\n\t\tdirty_bitmap_head = memslot->dirty_bitmap_head;\n\t\tif (dirty_bitmap == dirty_bitmap_head)\n\t\t\tdirty_bitmap_head += n \/ sizeof(long);\n\t\tmemset(dirty_bitmap_head, 0, n);\n\n\t\tr = -ENOMEM;\n\t\tslots = kmemdup(kvm->memslots, sizeof(*kvm->memslots), GFP_KERNEL);\n\t\tif (!slots)\n\t\t\tgoto out;\n\n\t\tmemslot = id_to_memslot(slots, log->slot);\n\t\tmemslot->nr_dirty_pages = 0;\n\t\tmemslot->dirty_bitmap = dirty_bitmap_head;\n\t\tupdate_memslots(slots, NULL);\n\n\t\told_slots = kvm->memslots;\n\t\trcu_assign_pointer(kvm->memslots, slots);\n\t\tsynchronize_srcu_expedited(&kvm->srcu);\n\t\tkfree(old_slots);\n\n\t\twrite_protect_slot(kvm, memslot, dirty_bitmap, nr_dirty_pages);\n\n\t\tr = -EFAULT;\n\t\tif (copy_to_user(log->dirty_bitmap, dirty_bitmap, n))\n\t\t\tgoto out;\n\t} else {\n\t\tr = -EFAULT;\n\t\tif (clear_user(log->dirty_bitmap, n))\n\t\t\tgoto out;\n\t}\n\n\tr = 0;\nout:\n\tmutex_unlock(&kvm->slots_lock);\n\treturn r;\n}\n","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":352886,"func":"static int check_reg_type(struct bpf_verifier_env *env, u32 regno,\n\t\t\t  enum bpf_arg_type arg_type,\n\t\t\t  const u32 *arg_btf_id)\n{\n\tstruct bpf_reg_state *regs = cur_regs(env), *reg = ®s[regno];\n\tenum bpf_reg_type expected, type = reg->type;\n\tconst struct bpf_reg_types *compatible;\n\tint i, j;\n\n\tcompatible = compatible_reg_types[base_type(arg_type)];\n\tif (!compatible) {\n\t\tverbose(env, \"verifier internal error: unsupported arg type %d\\n\", arg_type);\n\t\treturn -EFAULT;\n\t}\n\n\tfor (i = 0; i < ARRAY_SIZE(compatible->types); i++) {\n\t\texpected = compatible->types[i];\n\t\tif (expected == NOT_INIT)\n\t\t\tbreak;\n\n\t\tif (type == expected)\n\t\t\tgoto found;\n\t}\n\n\tverbose(env, \"R%d type=%s expected=\", regno, reg_type_str(env, type));\n\tfor (j = 0; j + 1 < i; j++)\n\t\tverbose(env, \"%s, \", reg_type_str(env, compatible->types[j]));\n\tverbose(env, \"%s\\n\", reg_type_str(env, compatible->types[j]));\n\treturn -EACCES;\n\nfound:\n\tif (type == PTR_TO_BTF_ID) {\n\t\tif (!arg_btf_id) {\n\t\t\tif (!compatible->btf_id) {\n\t\t\t\tverbose(env, \"verifier internal error: missing arg compatible BTF ID\\n\");\n\t\t\t\treturn -EFAULT;\n\t\t\t}\n\t\t\targ_btf_id = compatible->btf_id;\n\t\t}\n\n\t\tif (!btf_struct_ids_match(&env->log, reg->btf, reg->btf_id, reg->off,\n\t\t\t\t\t  btf_vmlinux, *arg_btf_id)) {\n\t\t\tverbose(env, \"R%d is of type %s but %s is expected\\n\",\n\t\t\t\tregno, kernel_type_name(reg->btf, reg->btf_id),\n\t\t\t\tkernel_type_name(btf_vmlinux, *arg_btf_id));\n\t\t\treturn -EACCES;\n\t\t}\n\n\t\tif (!tnum_is_const(reg->var_off) || reg->var_off.value) {\n\t\t\tverbose(env, \"R%d is a pointer to in-kernel struct with non-zero offset\\n\",\n\t\t\t\tregno);\n\t\t\treturn -EACCES;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":1,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":318648,"func":"static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,\n                                    const uint8_t *src, const uint8_t *src_end,\n                                    int width, int esc_count)\n{\n    int i = 0;\n    int count;\n    uint8_t zero_run = 0;\n    const uint8_t *src_start = src;\n    uint8_t mask1 = -(esc_count < 2);\n    uint8_t mask2 = -(esc_count < 3);\n    uint8_t *end = dst + (width - 2);\noutput_zeros:\n    if (l->zeros_rem) {\n        count = FFMIN(l->zeros_rem, width - i);\n        if (end - dst < count) {\n            av_log(l->avctx, AV_LOG_ERROR, \"Too many zeros remaining.\\n\");\n            return AVERROR_INVALIDDATA;\n        }\n        memset(dst, 0, count);\n        l->zeros_rem -= count;\n        dst += count;\n    }\n    while (dst < end) {\n        i = 0;\n        while (!zero_run && dst + i < end) {\n            i++;\n            if (i+2 >= src_end - src)\n                return AVERROR_INVALIDDATA;\n            zero_run =\n                !(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));\n        }\n        if (zero_run) {\n            zero_run = 0;\n            i += esc_count;\n            memcpy(dst, src, i);\n            dst += i;\n            l->zeros_rem = lag_calc_zero_run(src[i]);\n            src += i + 1;\n            goto output_zeros;\n        } else {\n            memcpy(dst, src, i);\n            src += i;\n            dst += i;\n        }\n    }\n    return  src - src_start;\n}","target":1,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":199698,"func":"void GLES2DecoderImpl::DoRenderbufferStorageMultisampleCHROMIUM(\n    GLenum target, GLsizei samples, GLenum internalformat,\n    GLsizei width, GLsizei height) {\n  Renderbuffer* renderbuffer = GetRenderbufferInfoForTarget(GL_RENDERBUFFER);\n  if (!renderbuffer) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,\n                       \"glRenderbufferStorageMultisampleCHROMIUM\",\n                       \"no renderbuffer bound\");\n    return;\n  }\n\n  if (!ValidateRenderbufferStorageMultisample(\n      samples, internalformat, width, height)) {\n    return;\n  }\n\n  GLenum impl_format =\n      renderbuffer_manager()->InternalRenderbufferFormatToImplFormat(\n          internalformat);\n  LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(\n      \"glRenderbufferStorageMultisampleCHROMIUM\");\n  RenderbufferStorageMultisampleWithWorkaround(target, samples, impl_format,\n                                               width, height, kDoNotForce);\n  GLenum error =\n      LOCAL_PEEK_GL_ERROR(\"glRenderbufferStorageMultisampleCHROMIUM\");\n  if (error == GL_NO_ERROR) {\n    if (workarounds().validate_multisample_buffer_allocation) {\n      if (!VerifyMultisampleRenderbufferIntegrity(\n          renderbuffer->service_id(), impl_format)) {\n        LOCAL_SET_GL_ERROR(\n            GL_OUT_OF_MEMORY,\n            \"glRenderbufferStorageMultisampleCHROMIUM\", \"out of memory\");\n        return;\n      }\n    }\n\n    renderbuffer_manager()->SetInfoAndInvalidate(renderbuffer, samples,\n                                                 internalformat, width, height);\n  }\n}\n","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":359788,"func":"utils_mac_valid (const struct ether_addr *addr)\n{\n\tguint8 invalid1[ETH_ALEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\n\tguint8 invalid2[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\n\tguint8 invalid3[ETH_ALEN] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x44};\n\tguint8 invalid4[ETH_ALEN] = {0x00, 0x30, 0xb4, 0x00, 0x00, 0x00}; \/* prism54 dummy MAC *\/\n\n\tg_return_val_if_fail (addr != NULL, FALSE);\n\n\t\/* Compare the AP address the card has with invalid ethernet MAC addresses. *\/\n\tif (!memcmp (addr->ether_addr_octet, &invalid1, ETH_ALEN))\n\t\treturn FALSE;\n\n\tif (!memcmp (addr->ether_addr_octet, &invalid2, ETH_ALEN))\n\t\treturn FALSE;\n\n\tif (!memcmp (addr->ether_addr_octet, &invalid3, ETH_ALEN))\n\t\treturn FALSE;\n\n\tif (!memcmp (addr->ether_addr_octet, &invalid4, ETH_ALEN))\n\t\treturn FALSE;\n\n\tif (addr->ether_addr_octet[0] & 1) \/* Multicast addresses *\/\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":90415,"func":"static OPJ_BOOL opj_j2k_write_mct_record(opj_j2k_t *p_j2k,\n        opj_mct_data_t * p_mct_record,\n        struct opj_stream_private *p_stream,\n        struct opj_event_mgr * p_manager)\n{\n    OPJ_UINT32 l_mct_size;\n    OPJ_BYTE * l_current_data = 00;\n    OPJ_UINT32 l_tmp;\n\n    \/* preconditions *\/\n    assert(p_j2k != 00);\n    assert(p_manager != 00);\n    assert(p_stream != 00);\n\n    l_mct_size = 10 + p_mct_record->m_data_size;\n\n    if (l_mct_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {\n        OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(\n                                             p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mct_size);\n        if (! new_header_tile_data) {\n            opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);\n            p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;\n            p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;\n            opj_event_msg(p_manager, EVT_ERROR, \"Not enough memory to write MCT marker\\n\");\n            return OPJ_FALSE;\n        }\n        p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;\n        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mct_size;\n    }\n\n    l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;\n\n    opj_write_bytes(l_current_data, J2K_MS_MCT,\n                    2);                                   \/* MCT *\/\n    l_current_data += 2;\n\n    opj_write_bytes(l_current_data, l_mct_size - 2,\n                    2);                                 \/* Lmct *\/\n    l_current_data += 2;\n\n    opj_write_bytes(l_current_data, 0,\n                    2);                                                    \/* Zmct *\/\n    l_current_data += 2;\n\n    \/* only one marker atm *\/\n    l_tmp = (p_mct_record->m_index & 0xff) | (p_mct_record->m_array_type << 8) |\n            (p_mct_record->m_element_type << 10);\n\n    opj_write_bytes(l_current_data, l_tmp, 2);\n    l_current_data += 2;\n\n    opj_write_bytes(l_current_data, 0,\n                    2);                                                    \/* Ymct *\/\n    l_current_data += 2;\n\n    memcpy(l_current_data, p_mct_record->m_data, p_mct_record->m_data_size);\n\n    if (opj_stream_write_data(p_stream,\n                              p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mct_size,\n                              p_manager) != l_mct_size) {\n        return OPJ_FALSE;\n    }\n\n    return OPJ_TRUE;\n}","target":0,"code_token_length":658,"total_token_length":894,"max_tokens_setting":1024}
+{"idx":338207,"func":"static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)\n\n{\n\n    int size;\n\n    char *path;\n\n    void *ptr;\n\n    char name[32];\n\n    const VMStateDescription *vmsd;\n\n\n\n    if (!pdev->romfile)\n\n        return 0;\n\n    if (strlen(pdev->romfile) == 0)\n\n        return 0;\n\n\n\n    if (!pdev->rom_bar) {\n\n        \/*\n\n         * Load rom via fw_cfg instead of creating a rom bar,\n\n         * for 0.11 compatibility.\n\n         *\/\n\n        int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);\n\n        if (class == 0x0300) {\n\n            rom_add_vga(pdev->romfile);\n\n        } else {\n\n            rom_add_option(pdev->romfile, -1);\n\n        }\n\n        return 0;\n\n    }\n\n\n\n    path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);\n\n    if (path == NULL) {\n\n        path = g_strdup(pdev->romfile);\n\n    }\n\n\n\n    size = get_image_size(path);\n\n    if (size < 0) {\n\n        error_report(\"%s: failed to find romfile \\\"%s\\\"\",\n\n                     __FUNCTION__, pdev->romfile);\n\n        g_free(path);\n\n        return -1;\n\n    }\n\n    if (size & (size - 1)) {\n\n        size = 1 << qemu_fls(size);\n\n    }\n\n\n\n    vmsd = qdev_get_vmsd(DEVICE(pdev));\n\n\n\n    if (vmsd) {\n\n        snprintf(name, sizeof(name), \"%s.rom\", vmsd->name);\n\n    } else {\n\n        snprintf(name, sizeof(name), \"%s.rom\", object_get_typename(OBJECT(pdev)));\n\n    }\n\n    pdev->has_rom = true;\n\n    memory_region_init_ram(&pdev->rom, name, size);\n\n    vmstate_register_ram(&pdev->rom, &pdev->qdev);\n\n    ptr = memory_region_get_ram_ptr(&pdev->rom);\n\n    load_image(path, ptr);\n\n    g_free(path);\n\n\n\n    if (is_default_rom) {\n\n        \/* Only the default rom images will be patched (if needed). *\/\n\n        pci_patch_ids(pdev, ptr, size);\n\n    }\n\n\n\n    qemu_put_ram_ptr(ptr);\n\n\n\n    pci_register_bar(pdev, PCI_ROM_SLOT, 0, &pdev->rom);\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":498,"total_token_length":734,"max_tokens_setting":1024}
+{"idx":415750,"func":"static char *find_line(char *buf_start, char *buf_end, char *name,\n\t\t       char *net_type, char *net_link, char *net_dev,\n\t\t       bool *owner, bool *found, bool *keep)\n{\n\tchar *end_of_line, *end_of_word, *line;\n\n\twhile (buf_start < buf_end) {\n\t\tsize_t len;\n\t\tchar netdev_name[IFNAMSIZ];\n\n\t\t*found = false;\n\t\t*keep = true;\n\t\t*owner = false;\n\n\t\tend_of_line = get_eol(buf_start, buf_end);\n\t\tif (end_of_line >= buf_end)\n\t\t\treturn NULL;\n\n\t\tline = buf_start;\n\t\tif (*buf_start == '#')\n\t\t\tgoto next;\n\n\t\twhile ((buf_start < buf_end) && isblank(*buf_start))\n\t\t\tbuf_start++;\n\n\t\t\/* Check whether the line contains the caller's name. *\/\n\t\tend_of_word = get_eow(buf_start, buf_end);\n\t\t\/* corrupt db *\/\n\t\tif (!end_of_word)\n\t\t\treturn NULL;\n\n\t\tif (strncmp(buf_start, name, strlen(name)))\n\t\t\t*found = false;\n\n\t\t*owner = true;\n\n\t\tbuf_start = end_of_word + 1;\n\t\twhile ((buf_start < buf_end) && isblank(*buf_start))\n\t\t\tbuf_start++;\n\n\t\t\/* Check whether line is of the right network type. *\/\n\t\tend_of_word = get_eow(buf_start, buf_end);\n\t\t\/* corrupt db *\/\n\t\tif (!end_of_word)\n\t\t\treturn NULL;\n\n\t\tif (strncmp(buf_start, net_type, strlen(net_type)))\n\t\t\t*found = false;\n\n\t\tbuf_start = end_of_word + 1;\n\t\twhile ((buf_start < buf_end) && isblank(*buf_start))\n\t\t\tbuf_start++;\n\n\t\t\/* Check whether line is contains the right link. *\/\n\t\tend_of_word = get_eow(buf_start, buf_end);\n\t\t\/* corrupt db *\/\n\t\tif (!end_of_word)\n\t\t\treturn NULL;\n\n\t\tif (strncmp(buf_start, net_link, strlen(net_link)))\n\t\t\t*found = false;\n\n\t\tbuf_start = end_of_word + 1;\n\t\twhile ((buf_start < buf_end) && isblank(*buf_start))\n\t\t\tbuf_start++;\n\n\t\t\/* Check whether line contains the right network device. *\/\n\t\tend_of_word = get_eow(buf_start, buf_end);\n\t\t\/* corrupt db *\/\n\t\tif (!end_of_word)\n\t\t\treturn NULL;\n\n\t\tlen = end_of_word - buf_start;\n\t\t\/* corrupt db *\/\n\t\tif (len >= IFNAMSIZ)\n\t\t\treturn NULL;\n\n\t\tmemcpy(netdev_name, buf_start, len);\n\t\tnetdev_name[len] = '\\0';\n\t\t*keep = lxc_nic_exists(netdev_name);\n\n\t\tif (net_dev && !strcmp(netdev_name, net_dev))\n\t\t\t*found = true;\n\n\t\treturn line;\n\n\tnext:\n\t\tbuf_start = end_of_line + 1;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":624,"total_token_length":860,"max_tokens_setting":1024}
+{"idx":371857,"func":"fr_archive_progress_cb (FrArchive *archive,\n\t\t        double     fraction,\n\t\t        FrWindow  *window)\n{\n\twindow->priv->progress_pulse = (fraction < 0.0);\n\tif (! window->priv->progress_pulse) {\n\t\tfraction = CLAMP (fraction, 0.0, 1.0);\n\t\tif (window->priv->progress_dialog != NULL)\n\t\t\tgtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->pd_progress_bar), fraction);\n\t\tgtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress_bar), fraction);\n\n\t\tif ((archive != NULL) && (fr_archive_progress_get_total_files (archive) > 0)) {\n\t\t\tchar *message = NULL;\n\t\t\tint   remaining_files;\n\n\t\t\tremaining_files = fr_archive_progress_get_total_files (archive) - fr_archive_progress_get_completed_files (archive);\n\n\t\t\tswitch (window->priv->action) {\n\t\t\tcase FR_ACTION_ADDING_FILES:\n\t\t\tcase FR_ACTION_EXTRACTING_FILES:\n\t\t\tcase FR_ACTION_DELETING_FILES:\n\t\t\tcase FR_ACTION_UPDATING_FILES:\n\t\t\t\tif (remaining_files > 0)\n\t\t\t\t\tmessage = g_strdup_printf (ngettext (\"%d file remaining\",\n\t\t\t\t\t\t\t\t\t     \"%'d files remaining\",\n\t\t\t\t\t\t\t\t\t     remaining_files), remaining_files);\n\t\t\t\telse\n\t\t\t\t\tmessage = g_strdup (_(\"Please wait\u2026\"));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (message != NULL) {\n\t\t\t\tfr_archive_message (archive, message);\n\t\t\t\tg_free (message);\n\t\t\t}\n\t\t}\n\n\t\tif (fraction == 1.0)\n\t\t\tgtk_widget_hide (window->priv->pd_progress_box);\n\t\telse\n\t\t\tgtk_widget_show (window->priv->pd_progress_box);\n\n\t\twindow->priv->pd_last_fraction = fraction;\n\n\t\tg_signal_emit (G_OBJECT (window),\n\t\t\t       fr_window_signals[PROGRESS],\n\t\t\t       0,\n\t\t\t       window->priv->pd_last_fraction,\n\t\t\t       window->priv->pd_last_message);\n\n#ifdef LOG_PROGRESS\n\t\tg_print (\"progress > %2.2f\\n\", fraction);\n#endif\n\t}\n\treturn TRUE;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":52917,"func":"static URI_INLINE const URI_CHAR * URI_FUNC(ParsePathAbsNoLeadSlash)(\n\t\tURI_TYPE(ParserState) * state, const URI_CHAR * first,\n\t\tconst URI_CHAR * afterLast, UriMemoryManager * memory) {\n\tif (first >= afterLast) {\n\t\treturn afterLast;\n\t}\n\n\tswitch (*first) {\n\tcase _UT('!'):\n\tcase _UT('$'):\n\tcase _UT('%'):\n\tcase _UT('&'):\n\tcase _UT('('):\n\tcase _UT(')'):\n\tcase _UT('-'):\n\tcase _UT('*'):\n\tcase _UT(','):\n\tcase _UT('.'):\n\tcase _UT(':'):\n\tcase _UT(';'):\n\tcase _UT('@'):\n\tcase _UT('\\''):\n\tcase _UT('_'):\n\tcase _UT('~'):\n\tcase _UT('+'):\n\tcase _UT('='):\n\tcase URI_SET_DIGIT:\n\tcase URI_SET_ALPHA:\n\t\t{\n\t\t\tconst URI_CHAR * const afterSegmentNz\n\t\t\t\t\t= URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);\n\t\t\tif (afterSegmentNz == NULL) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz, memory)) { \/* SEGMENT BOTH *\/\n\t\t\t\tURI_FUNC(StopMalloc)(state, memory);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treturn URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);\n\t\t}\n\n\tdefault:\n\t\treturn first;\n\t}\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":440459,"func":"static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)\n{\n\tstruct vxlan_dev *vxlan;\n\tstruct vxlan_sock *sock4;\n#if IS_ENABLED(CONFIG_IPV6)\n\tstruct vxlan_sock *sock6;\n#endif\n\tunsigned short family = dev->default_dst.remote_ip.sa.sa_family;\n\n\tsock4 = rtnl_dereference(dev->vn4_sock);\n\n\t\/* The vxlan_sock is only used by dev, leaving group has\n\t * no effect on other vxlan devices.\n\t *\/\n\tif (family == AF_INET && sock4 && refcount_read(&sock4->refcnt) == 1)\n\t\treturn false;\n#if IS_ENABLED(CONFIG_IPV6)\n\tsock6 = rtnl_dereference(dev->vn6_sock);\n\tif (family == AF_INET6 && sock6 && refcount_read(&sock6->refcnt) == 1)\n\t\treturn false;\n#endif\n\n\tlist_for_each_entry(vxlan, &vn->vxlan_list, next) {\n\t\tif (!netif_running(vxlan->dev) || vxlan == dev)\n\t\t\tcontinue;\n\n\t\tif (family == AF_INET &&\n\t\t    rtnl_dereference(vxlan->vn4_sock) != sock4)\n\t\t\tcontinue;\n#if IS_ENABLED(CONFIG_IPV6)\n\t\tif (family == AF_INET6 &&\n\t\t    rtnl_dereference(vxlan->vn6_sock) != sock6)\n\t\t\tcontinue;\n#endif\n\n\t\tif (!vxlan_addr_equal(&vxlan->default_dst.remote_ip,\n\t\t\t\t      &dev->default_dst.remote_ip))\n\t\t\tcontinue;\n\n\t\tif (vxlan->default_dst.remote_ifindex !=\n\t\t    dev->default_dst.remote_ifindex)\n\t\t\tcontinue;\n\n\t\treturn true;\n\t}\n\n\treturn false;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":271368,"func":"void jpc_qmfb_split_row(jpc_fix_t *a, int numcols, int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numcols, 1);\n\tjpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];\n\tjpc_fix_t *buf = splitbuf;\n\tregister jpc_fix_t *srcptr;\n\tregister jpc_fix_t *dstptr;\n\tregister int n;\n\tregister int m;\n\tint hstartcol;\n\n\t\/* Get a buffer. *\/\n\tif (bufsize > QMFB_SPLITBUFSIZE) {\n\t\tif (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {\n\t\t\t\/* We have no choice but to commit suicide in this case. *\/\n\t\t\tabort();\n\t\t}\n\t}\n\n\tif (numcols >= 2) {\n\t\thstartcol = (numcols + 1 - parity) >> 1;\n\t\t\/\/ ORIGINAL (WRONG): m = (parity) ? hstartcol : (numcols - hstartcol);\n\t\tm = numcols - hstartcol;\n\n\t\t\/* Save the samples destined for the highpass channel. *\/\n\t\tn = m;\n\t\tdstptr = buf;\n\t\tsrcptr = &a[1 - parity];\n\t\twhile (n-- > 0) {\n\t\t\t*dstptr = *srcptr;\n\t\t\t++dstptr;\n\t\t\tsrcptr += 2;\n\t\t}\n\t\t\/* Copy the appropriate samples into the lowpass channel. *\/\n\t\tdstptr = &a[1 - parity];\n\t\tsrcptr = &a[2 - parity];\n\t\tn = numcols - m - (!parity);\n\t\twhile (n-- > 0) {\n\t\t\t*dstptr = *srcptr;\n\t\t\t++dstptr;\n\t\t\tsrcptr += 2;\n\t\t}\n\t\t\/* Copy the saved samples into the highpass channel. *\/\n\t\tdstptr = &a[hstartcol];\n\t\tsrcptr = buf;\n\t\tn = m;\n\t\twhile (n-- > 0) {\n\t\t\t*dstptr = *srcptr;\n\t\t\t++dstptr;\n\t\t\t++srcptr;\n\t\t}\n\t}\n\n\t\/* If the split buffer was allocated on the heap, free this memory. *\/\n\tif (buf != splitbuf) {\n\t\tjas_free(buf);\n\t}\n\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":492895,"func":"static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,\n\t\tstruct iov_iter *iter, gfp_t gfp_mask)\n{\n\tstruct bio_map_data *bmd;\n\tstruct page *page;\n\tstruct bio *bio;\n\tint i = 0, ret;\n\tint nr_pages;\n\tunsigned int len = iter->count;\n\tunsigned int offset = map_data ? offset_in_page(map_data->offset) : 0;\n\n\tbmd = bio_alloc_map_data(iter, gfp_mask);\n\tif (!bmd)\n\t\treturn -ENOMEM;\n\n\t\/*\n\t * We need to do a deep copy of the iov_iter including the iovecs.\n\t * The caller provided iov might point to an on-stack or otherwise\n\t * shortlived one.\n\t *\/\n\tbmd->is_our_pages = !map_data;\n\tbmd->is_null_mapped = (map_data && map_data->null_mapped);\n\n\tnr_pages = bio_max_segs(DIV_ROUND_UP(offset + len, PAGE_SIZE));\n\n\tret = -ENOMEM;\n\tbio = bio_kmalloc(gfp_mask, nr_pages);\n\tif (!bio)\n\t\tgoto out_bmd;\n\tbio->bi_opf |= req_op(rq);\n\n\tif (map_data) {\n\t\tnr_pages = 1 << map_data->page_order;\n\t\ti = map_data->offset \/ PAGE_SIZE;\n\t}\n\twhile (len) {\n\t\tunsigned int bytes = PAGE_SIZE;\n\n\t\tbytes -= offset;\n\n\t\tif (bytes > len)\n\t\t\tbytes = len;\n\n\t\tif (map_data) {\n\t\t\tif (i == map_data->nr_entries * nr_pages) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto cleanup;\n\t\t\t}\n\n\t\t\tpage = map_data->pages[i \/ nr_pages];\n\t\t\tpage += (i % nr_pages);\n\n\t\t\ti++;\n\t\t} else {\n\t\t\tpage = alloc_page(GFP_NOIO | gfp_mask);\n\t\t\tif (!page) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto cleanup;\n\t\t\t}\n\t\t}\n\n\t\tif (bio_add_pc_page(rq->q, bio, page, bytes, offset) < bytes) {\n\t\t\tif (!map_data)\n\t\t\t\t__free_page(page);\n\t\t\tbreak;\n\t\t}\n\n\t\tlen -= bytes;\n\t\toffset = 0;\n\t}\n\n\tif (map_data)\n\t\tmap_data->offset += bio->bi_iter.bi_size;\n\n\t\/*\n\t * success\n\t *\/\n\tif ((iov_iter_rw(iter) == WRITE &&\n\t     (!map_data || !map_data->null_mapped)) ||\n\t    (map_data && map_data->from_user)) {\n\t\tret = bio_copy_from_iter(bio, iter);\n\t\tif (ret)\n\t\t\tgoto cleanup;\n\t} else {\n\t\tif (bmd->is_our_pages)\n\t\t\tzero_fill_bio(bio);\n\t\tiov_iter_advance(iter, bio->bi_iter.bi_size);\n\t}\n\n\tbio->bi_private = bmd;\n\n\tret = blk_rq_append_bio(rq, bio);\n\tif (ret)\n\t\tgoto cleanup;\n\treturn 0;\ncleanup:\n\tif (!map_data)\n\t\tbio_free_pages(bio);\n\tbio_put(bio);\nout_bmd:\n\tkfree(bmd);\n\treturn ret;\n}","target":0,"code_token_length":653,"total_token_length":889,"max_tokens_setting":1024}
+{"idx":523925,"func":"auth_request_lookup_credentials_finish(enum passdb_result result,\n\t\t\t\t\tconst unsigned char *credentials,\n\t\t\t\t\tsize_t size,\n\t\t\t\t\tstruct auth_request *request)\n{\n\tconst char *error;\n\n\tif (passdb_template_export(request->passdb->override_fields_tmpl,\n\t\t\t\t   request, &error) < 0) {\n\t\te_error(authdb_event(request),\n\t\t\t\"Failed to expand override_fields: %s\", error);\n\t\tresult = PASSDB_RESULT_INTERNAL_FAILURE;\n\t}\n\tif (!auth_request_handle_passdb_callback(&result, request)) {\n\t\t\/* try next passdb *\/\n\t\tif (request->fields.skip_password_check &&\n\t\t    request->fields.delayed_credentials == NULL && size > 0) {\n\t\t\t\/* passdb continue* rule after a successful lookup.\n\t\t\t   remember these credentials and use them later on. *\/\n\t\t\tauth_request_set_delayed_credentials(request,\n\t\t\t\tcredentials, size);\n\t\t}\n\t\tauth_request_lookup_credentials(request,\n\t\t\trequest->wanted_credentials_scheme,\n\t\t  \trequest->private_callback.lookup_credentials);\n\t} else {\n\t\tif (request->fields.delayed_credentials != NULL && size == 0) {\n\t\t\t\/* we did multiple passdb lookups, but the last one\n\t\t\t   didn't provide any credentials (e.g. just wanted to\n\t\t\t   add some extra fields). so use the first passdb's\n\t\t\t   credentials instead. *\/\n\t\t\tcredentials = request->fields.delayed_credentials;\n\t\t\tsize = request->fields.delayed_credentials_size;\n\t\t}\n\t\tif (request->set->debug_passwords &&\n\t\t    result == PASSDB_RESULT_OK) {\n\t\t\te_debug(authdb_event(request),\n\t\t\t\t\"Credentials: %s\",\n\t\t\t\tbinary_to_hex(credentials, size));\n\t\t}\n\t\tif (result == PASSDB_RESULT_SCHEME_NOT_AVAILABLE &&\n\t\t    request->passdbs_seen_user_unknown) {\n\t\t\t\/* one of the passdbs accepted the scheme,\n\t\t\t   but the user was unknown there *\/\n\t\t\tresult = PASSDB_RESULT_USER_UNKNOWN;\n\t\t}\n\t\trequest->passdb_result = result;\n\t\trequest->private_callback.\n\t\t\tlookup_credentials(result, credentials, size, request);\n\t}\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":295996,"func":"static int oidc_handle_logout(request_rec *r, oidc_cfg *c,\n\t\toidc_session_t *session) {\n\n\toidc_provider_t *provider = NULL;\n\t\/* pickup the command or URL where the user wants to go after logout *\/\n\tchar *url = NULL;\n\tchar *error_str = NULL;\n\tchar *error_description = NULL;\n\n\toidc_util_get_request_parameter(r, OIDC_REDIRECT_URI_REQUEST_LOGOUT, &url);\n\n\toidc_debug(r, \"enter (url=%s)\", url);\n\n\tif (oidc_is_front_channel_logout(url)) {\n\t\treturn oidc_handle_logout_request(r, c, session, url);\n\t} else if (oidc_is_back_channel_logout(url)) {\n\t\treturn oidc_handle_logout_backchannel(r, c);\n\t}\n\n\tif ((url == NULL) || (apr_strnatcmp(url, \"\") == 0)) {\n\n\t\turl = c->default_slo_url;\n\n\t} else {\n\n\t\t\/* do input validation on the logout parameter value *\/\n\t\tif (oidc_validate_redirect_url(r, c, url, TRUE, &error_str,\n\t\t\t\t&error_description) == FALSE) {\n\t\t\treturn oidc_util_html_send_error(r, c->error_template, error_str,\n\t\t\t\t\terror_description,\n\t\t\t\t\tHTTP_BAD_REQUEST);\n\t\t}\n\t}\n\n\toidc_get_provider_from_session(r, c, session, &provider);\n\n\tif ((provider != NULL) && (provider->end_session_endpoint != NULL)) {\n\n\t\tconst char *id_token_hint = oidc_session_get_idtoken(r, session);\n\n\t\tchar *logout_request = apr_pstrdup(r->pool,\n\t\t\t\tprovider->end_session_endpoint);\n\t\tif (id_token_hint != NULL) {\n\t\t\tlogout_request = apr_psprintf(r->pool, \"%s%sid_token_hint=%s\",\n\t\t\t\t\tlogout_request, strchr(logout_request ? logout_request : \"\",\n\t\t\t\t\t\t\tOIDC_CHAR_QUERY) != NULL ?\n\t\t\t\t\t\t\t\t\tOIDC_STR_AMP :\n\t\t\t\t\t\t\t\t\tOIDC_STR_QUERY,\n\t\t\t\t\t\t\t\t\toidc_util_escape_string(r, id_token_hint));\n\t\t}\n\n\t\tif (url != NULL) {\n\t\t\tlogout_request = apr_psprintf(r->pool,\n\t\t\t\t\t\"%s%spost_logout_redirect_uri=%s\", logout_request,\n\t\t\t\t\tstrchr(logout_request ? logout_request : \"\",\n\t\t\t\t\t\t\tOIDC_CHAR_QUERY) != NULL ?\n\t\t\t\t\t\t\t\t\tOIDC_STR_AMP :\n\t\t\t\t\t\t\t\t\tOIDC_STR_QUERY,\n\t\t\t\t\t\t\t\t\toidc_util_escape_string(r, url));\n\t\t}\n\t\turl = logout_request;\n\t}\n\n\treturn oidc_handle_logout_request(r, c, session, url);\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":477308,"func":"static int ax88179_chk_eee(struct usbnet *dev)\n{\n\tstruct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };\n\tstruct ax88179_data *priv = (struct ax88179_data *)dev->data;\n\n\tmii_ethtool_gset(&dev->mii, &ecmd);\n\n\tif (ecmd.duplex & DUPLEX_FULL) {\n\t\tint eee_lp, eee_cap, eee_adv;\n\t\tu32 lp, cap, adv, supported = 0;\n\n\t\teee_cap = ax88179_phy_read_mmd_indirect(dev,\n\t\t\t\t\t\t\tMDIO_PCS_EEE_ABLE,\n\t\t\t\t\t\t\tMDIO_MMD_PCS);\n\t\tif (eee_cap < 0) {\n\t\t\tpriv->eee_active = 0;\n\t\t\treturn false;\n\t\t}\n\n\t\tcap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);\n\t\tif (!cap) {\n\t\t\tpriv->eee_active = 0;\n\t\t\treturn false;\n\t\t}\n\n\t\teee_lp = ax88179_phy_read_mmd_indirect(dev,\n\t\t\t\t\t\t       MDIO_AN_EEE_LPABLE,\n\t\t\t\t\t\t       MDIO_MMD_AN);\n\t\tif (eee_lp < 0) {\n\t\t\tpriv->eee_active = 0;\n\t\t\treturn false;\n\t\t}\n\n\t\teee_adv = ax88179_phy_read_mmd_indirect(dev,\n\t\t\t\t\t\t\tMDIO_AN_EEE_ADV,\n\t\t\t\t\t\t\tMDIO_MMD_AN);\n\n\t\tif (eee_adv < 0) {\n\t\t\tpriv->eee_active = 0;\n\t\t\treturn false;\n\t\t}\n\n\t\tadv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);\n\t\tlp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);\n\t\tsupported = (ecmd.speed == SPEED_1000) ?\n\t\t\t     SUPPORTED_1000baseT_Full :\n\t\t\t     SUPPORTED_100baseT_Full;\n\n\t\tif (!(lp & adv & supported)) {\n\t\t\tpriv->eee_active = 0;\n\t\t\treturn false;\n\t\t}\n\n\t\tpriv->eee_active = 1;\n\t\treturn true;\n\t}\n\n\tpriv->eee_active = 0;\n\treturn false;\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":227656,"func":"horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op,\n\tuint16 *ToLinear16)\n{\n    register unsigned int  cr, cg, cb, ca, mask;\n\n    if (n >= stride) {\n\tmask = CODE_MASK;\n\tif (stride == 3) {\n\t    op[0] = ToLinear16[cr = (wp[0] & mask)];\n\t    op[1] = ToLinear16[cg = (wp[1] & mask)];\n\t    op[2] = ToLinear16[cb = (wp[2] & mask)];\n\t    n -= 3;\n\t    while (n > 0) {\n\t\twp += 3;\n\t\top += 3;\n\t\tn -= 3;\n\t\top[0] = ToLinear16[(cr += wp[0]) & mask];\n\t\top[1] = ToLinear16[(cg += wp[1]) & mask];\n\t\top[2] = ToLinear16[(cb += wp[2]) & mask];\n\t    }\n\t} else if (stride == 4) {\n\t    op[0] = ToLinear16[cr = (wp[0] & mask)];\n\t    op[1] = ToLinear16[cg = (wp[1] & mask)];\n\t    op[2] = ToLinear16[cb = (wp[2] & mask)];\n\t    op[3] = ToLinear16[ca = (wp[3] & mask)];\n\t    n -= 4;\n\t    while (n > 0) {\n\t\twp += 4;\n\t\top += 4;\n\t\tn -= 4;\n\t\top[0] = ToLinear16[(cr += wp[0]) & mask];\n\t\top[1] = ToLinear16[(cg += wp[1]) & mask];\n\t\top[2] = ToLinear16[(cb += wp[2]) & mask];\n\t\top[3] = ToLinear16[(ca += wp[3]) & mask];\n\t    }\n\t} else {\n\t    REPEAT(stride, *op = ToLinear16[*wp&mask]; wp++; op++)\n\t    n -= stride;\n\t    while (n > 0) {\n\t\tREPEAT(stride,\n\t\t    wp[stride] += *wp; *op = ToLinear16[*wp&mask]; wp++; op++)\n\t\tn -= stride;\n\t    }\n\t}\n    }\n}\n","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":303768,"func":"static BOOL update_read_polyline_order(wStream* s, const ORDER_INFO* orderInfo,\n                                       POLYLINE_ORDER* polyline)\n{\n\tUINT16 word;\n\tUINT32 new_num = polyline->numDeltaEntries;\n\tORDER_FIELD_COORD(1, polyline->xStart);\n\tORDER_FIELD_COORD(2, polyline->yStart);\n\tORDER_FIELD_BYTE(3, polyline->bRop2);\n\tORDER_FIELD_UINT16(4, word);\n\tORDER_FIELD_COLOR(orderInfo, s, 5, &polyline->penColor);\n\tORDER_FIELD_BYTE(6, new_num);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_07)\n\t{\n\t\tDELTA_POINT* new_points;\n\n\t\tif (new_num == 0)\n\t\t\treturn FALSE;\n\n\t\tif (Stream_GetRemainingLength(s) < 1)\n\t\t{\n\t\t\tWLog_ERR(TAG, \"Stream_GetRemainingLength(s) < 1\");\n\t\t\treturn FALSE;\n\t\t}\n\n\t\tStream_Read_UINT8(s, polyline->cbData);\n\t\tnew_points = (DELTA_POINT*)realloc(polyline->points, sizeof(DELTA_POINT) * new_num);\n\n\t\tif (!new_points)\n\t\t{\n\t\t\tWLog_ERR(TAG, \"realloc(%\" PRIu32 \") failed\", new_num);\n\t\t\treturn FALSE;\n\t\t}\n\n\t\tpolyline->points = new_points;\n\t\tpolyline->numDeltaEntries = new_num;\n\t\treturn update_read_delta_points(s, polyline->points, polyline->numDeltaEntries,\n\t\t                                polyline->xStart, polyline->yStart);\n\t}\n\n\treturn TRUE;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":411299,"func":"    **\/\n    CImg<T>& RGBtoXYZ(const bool use_D65=true) {\n      if (_spectrum!=3)\n        throw CImgInstanceException(_cimg_instance\n                                    \"RGBtoXYZ(): Instance is not a RGB image.\",\n                                    cimg_instance);\n\n      T *p1 = data(0,0,0,0), *p2 = data(0,0,0,1), *p3 = data(0,0,0,2);\n      const ulongT whd = (ulongT)_width*_height*_depth;\n      cimg_pragma_openmp(parallel for cimg_openmp_if(whd>=2048))\n      for (ulongT N = 0; N<whd; ++N) {\n        const Tfloat\n          R = (Tfloat)p1[N]\/255,\n          G = (Tfloat)p2[N]\/255,\n          B = (Tfloat)p3[N]\/255;\n        if (use_D65) { \/\/ D65\n          p1[N] = (T)(0.4124564*R + 0.3575761*G + 0.1804375*B);\n          p2[N] = (T)(0.2126729*R + 0.7151522*G + 0.0721750*B);\n          p3[N] = (T)(0.0193339*R + 0.1191920*G + 0.9503041*B);\n        } else { \/\/ D50\n          p1[N] = (T)(0.43603516*R + 0.38511658*G + 0.14305115*B);\n          p2[N] = (T)(0.22248840*R + 0.71690369*G + 0.06060791*B);\n          p3[N] = (T)(0.01391602*R + 0.09706116*G + 0.71392822*B);\n        }\n      }\n      return *this;","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":75154,"func":"void gf_media_get_sample_average_infos(GF_ISOFile *file, u32 Track, u32 *avgSize, u32 *MaxSize, u32 *TimeDelta, u32 *maxCTSDelta, u32 *const_duration, u32 *bandwidth)\n{\n\tu32 i, count, ts_diff;\n\tu64 prevTS, tdelta;\n\tDouble bw;\n\tGF_ISOSample *samp;\n\n\t*avgSize = *MaxSize = 0;\n\t*TimeDelta = 0;\n\t*maxCTSDelta = 0;\n\tbw = 0;\n\tprevTS = 0;\n\ttdelta = 0;\n\n\tcount = gf_isom_get_sample_count(file, Track);\n\tif (!count) return;\n\t*const_duration = 0;\n\n\tfor (i=0; i<count; i++) {\n\t\tsamp = gf_isom_get_sample_info(file, Track, i+1, NULL, NULL);\n\t\tif (!samp) break;\n\t\t\n\t\t\/\/get the size\n\t\t*avgSize += samp->dataLength;\n\t\tif (*MaxSize < samp->dataLength) *MaxSize = samp->dataLength;\n\t\tts_diff = (u32) (samp->DTS+samp->CTS_Offset - prevTS);\n\t\t\/\/get the time\n\t\ttdelta += ts_diff;\n\n\t\tif (i==1) {\n\t\t\t*const_duration = ts_diff;\n\t\t} else if ( (i<count-1) && (*const_duration != ts_diff) ) {\n\t\t\t*const_duration = 0;\n\t\t}\n\n\t\tprevTS = samp->DTS+samp->CTS_Offset;\n\t\tbw += 8*samp->dataLength;\n\n\t\t\/\/get the CTS delta\n\t\tif ((samp->CTS_Offset>=0) && ((u32)samp->CTS_Offset > *maxCTSDelta))\n\t\t\t*maxCTSDelta = samp->CTS_Offset;\n\t\tgf_isom_sample_del(&samp);\n\t}\n\tif (count>1) *TimeDelta = (u32) (tdelta\/ (count-1) );\n\telse *TimeDelta = (u32) tdelta;\n\t*avgSize \/= count;\n\tbw *= gf_isom_get_media_timescale(file, Track);\n\tbw \/= (s64) gf_isom_get_media_duration(file, Track);\n\tbw \/= 1000;\n\t(*bandwidth) = (u32) (bw+0.5);\n\n\t\/\/delta is NOT an average, we need to know exactly how many bits are\n\t\/\/needed to encode CTS-DTS for ANY samples\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":485857,"func":"sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,\n\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\tvoid *arg,\n\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sk_buff *skb = chunk->skb;\n\tsctp_chunkhdr_t *ch;\n\t__u8 *ch_end;\n\tint ootb_shut_ack = 0;\n\n\tSCTP_INC_STATS(SCTP_MIB_OUTOFBLUES);\n\n\tch = (sctp_chunkhdr_t *) chunk->chunk_hdr;\n\tdo {\n\t\t\/* Break out if chunk length is less then minimal. *\/\n\t\tif (ntohs(ch->length) < sizeof(sctp_chunkhdr_t))\n\t\t\tbreak;\n\n\t\tch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));\n\t\tif (ch_end > skb->tail)\n\t\t\tbreak;\n\n\t\tif (SCTP_CID_SHUTDOWN_ACK == ch->type)\n\t\t\tootb_shut_ack = 1;\n\n\t\t\/* RFC 2960, Section 3.3.7\n\t\t *   Moreover, under any circumstances, an endpoint that\n\t\t *   receives an ABORT  MUST NOT respond to that ABORT by\n\t\t *   sending an ABORT of its own.\n\t\t *\/\n\t\tif (SCTP_CID_ABORT == ch->type)\n\t\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\t\t\t\n\t\tch = (sctp_chunkhdr_t *) ch_end;\n\t} while (ch_end < skb->tail);\n\n\tif (ootb_shut_ack)\n\t\tsctp_sf_shut_8_4_5(ep, asoc, type, arg, commands);\n\telse\n\t\tsctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);\n\n\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":423023,"func":"void __init tcp_init(void)\n{\n\tstruct sk_buff *skb = NULL;\n\tunsigned long limit;\n\tint max_rshare, max_wshare, cnt;\n\tunsigned int i;\n\n\tBUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb));\n\n\tpercpu_counter_init(&tcp_sockets_allocated, 0);\n\tpercpu_counter_init(&tcp_orphan_count, 0);\n\ttcp_hashinfo.bind_bucket_cachep =\n\t\tkmem_cache_create(\"tcp_bind_bucket\",\n\t\t\t\t  sizeof(struct inet_bind_bucket), 0,\n\t\t\t\t  SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);\n\n\t\/* Size and allocate the main established and bind bucket\n\t * hash tables.\n\t *\n\t * The methodology is similar to that of the buffer cache.\n\t *\/\n\ttcp_hashinfo.ehash =\n\t\talloc_large_system_hash(\"TCP established\",\n\t\t\t\t\tsizeof(struct inet_ehash_bucket),\n\t\t\t\t\tthash_entries,\n\t\t\t\t\t17, \/* one slot per 128 KB of memory *\/\n\t\t\t\t\t0,\n\t\t\t\t\tNULL,\n\t\t\t\t\t&tcp_hashinfo.ehash_mask,\n\t\t\t\t\t0,\n\t\t\t\t\tthash_entries ? 0 : 512 * 1024);\n\tfor (i = 0; i <= tcp_hashinfo.ehash_mask; i++)\n\t\tINIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].chain, i);\n\n\tif (inet_ehash_locks_alloc(&tcp_hashinfo))\n\t\tpanic(\"TCP: failed to alloc ehash_locks\");\n\ttcp_hashinfo.bhash =\n\t\talloc_large_system_hash(\"TCP bind\",\n\t\t\t\t\tsizeof(struct inet_bind_hashbucket),\n\t\t\t\t\ttcp_hashinfo.ehash_mask + 1,\n\t\t\t\t\t17, \/* one slot per 128 KB of memory *\/\n\t\t\t\t\t0,\n\t\t\t\t\t&tcp_hashinfo.bhash_size,\n\t\t\t\t\tNULL,\n\t\t\t\t\t0,\n\t\t\t\t\t64 * 1024);\n\ttcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;\n\tfor (i = 0; i < tcp_hashinfo.bhash_size; i++) {\n\t\tspin_lock_init(&tcp_hashinfo.bhash[i].lock);\n\t\tINIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);\n\t}\n\n\n\tcnt = tcp_hashinfo.ehash_mask + 1;\n\n\ttcp_death_row.sysctl_max_tw_buckets = cnt \/ 2;\n\tsysctl_tcp_max_orphans = cnt \/ 2;\n\tsysctl_max_syn_backlog = max(128, cnt \/ 256);\n\n\ttcp_init_mem();\n\t\/* Set per-socket limits to no more than 1\/128 the pressure threshold *\/\n\tlimit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);\n\tmax_wshare = min(4UL*1024*1024, limit);\n\tmax_rshare = min(6UL*1024*1024, limit);\n\n\tsysctl_tcp_wmem[0] = SK_MEM_QUANTUM;\n\tsysctl_tcp_wmem[1] = 16*1024;\n\tsysctl_tcp_wmem[2] = max(64*1024, max_wshare);\n\n\tsysctl_tcp_rmem[0] = SK_MEM_QUANTUM;\n\tsysctl_tcp_rmem[1] = 87380;\n\tsysctl_tcp_rmem[2] = max(87380, max_rshare);\n\n\tpr_info(\"Hash tables configured (established %u bind %u)\\n\",\n\t\ttcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);\n\n\ttcp_metrics_init();\n\n\ttcp_register_congestion_control(&tcp_reno);\n\n\ttcp_tasklet_init();\n}","target":0,"code_token_length":778,"total_token_length":1014,"max_tokens_setting":1024}
+{"idx":441458,"func":"void RGWPutObj_ObjStore_S3::send_response()\n{\n  if (op_ret) {\n    set_req_state_err(s, op_ret);\n    dump_errno(s);\n  } else {\n    if (s->cct->_conf->rgw_s3_success_create_obj_status) {\n      op_ret = get_success_retcode(\n\ts->cct->_conf->rgw_s3_success_create_obj_status);\n      set_req_state_err(s, op_ret);\n    }\n    if (copy_source.empty()) {\n      dump_errno(s);\n      dump_etag(s, etag);\n      dump_content_length(s, 0);\n      dump_header_if_nonempty(s, \"x-amz-version-id\", version_id);\n      for (auto &it : crypt_http_responses)\n        dump_header(s, it.first, it.second);\n    } else {\n      dump_errno(s);\n      dump_header_if_nonempty(s, \"x-amz-version-id\", version_id);\n      end_header(s, this, \"application\/xml\");\n      dump_start(s);\n      struct tm tmp;\n      utime_t ut(mtime);\n      time_t secs = (time_t)ut.sec();\n      gmtime_r(&secs, &tmp);\n      char buf[TIME_BUF_SIZE];\n      s->formatter->open_object_section_in_ns(\"CopyPartResult\",\n          \"http:\/\/s3.amazonaws.com\/doc\/2006-03-01\/\");\n      if (strftime(buf, sizeof(buf), \"%Y-%m-%dT%T.000Z\", &tmp) > 0) {\n        s->formatter->dump_string(\"LastModified\", buf);\n      }\n      s->formatter->dump_string(\"ETag\", etag);\n      s->formatter->close_section();\n      rgw_flush_formatter_and_reset(s, s->formatter);\n      return;\n    }\n  }\n  if (s->system_request && !real_clock::is_zero(mtime)) {\n    dump_epoch_header(s, \"Rgwx-Mtime\", mtime);\n  }\n  end_header(s, this);\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":482030,"func":"static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,\n\t\t\t    size_t count, loff_t *ppos)\n{\n\tunsigned long p = *ppos;\n\n\tu32 *buffer, *src;\n\tu32 __iomem *dst;\n\tint c, i, cnt = 0, err = 0;\n\tunsigned long total_size;\n\n\tif (!info || !info->screen_base)\n\t\treturn -ENODEV;\n\n\tif (info->state != FBINFO_STATE_RUNNING)\n\t\treturn -EPERM;\n\n\ttotal_size = info->screen_size;\n\n\tif (total_size == 0)\n\t\ttotal_size = info->fix.smem_len;\n\n\tif (p > total_size)\n\t\treturn -EFBIG;\n\n\tif (count > total_size) {\n\t\terr = -EFBIG;\n\t\tcount = total_size;\n\t}\n\n\tif (count + p > total_size) {\n\t\tif (!err)\n\t\t\terr = -ENOSPC;\n\n\t\tcount = total_size - p;\n\t}\n\n\tbuffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\tdst = (u32 __iomem *)(info->screen_base + p);\n\n\tif (info->fbops->fb_sync)\n\t\tinfo->fbops->fb_sync(info);\n\n\twhile (count) {\n\t\tc = (count > PAGE_SIZE) ? PAGE_SIZE : count;\n\t\tsrc = buffer;\n\n\t\tif (copy_from_user(src, buf, c)) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (i = c >> 2; i--;) {\n\t\t\tfb_writel(big_swap(*src), dst++);\n\t\t\tsrc++;\n\t\t}\n\t\tif (c & 3) {\n\t\t\tu8 *src8 = (u8 *)src;\n\t\t\tu8 __iomem *dst8 = (u8 __iomem *)dst;\n\n\t\t\tfor (i = c & 3; i--;) {\n\t\t\t\tif (i & 1) {\n\t\t\t\t\tfb_writeb(*src8++, ++dst8);\n\t\t\t\t} else {\n\t\t\t\t\tfb_writeb(*src8++, --dst8);\n\t\t\t\t\tdst8 += 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdst = (u32 __iomem *)dst8;\n\t\t}\n\n\t\t*ppos += c;\n\t\tbuf += c;\n\t\tcnt += c;\n\t\tcount -= c;\n\t}\n\n\tkfree(buffer);\n\n\treturn (cnt) ? cnt : err;\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":2511,"func":"static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,\n\t\t\t\t u64 chunk_offset, u64 devid,\n\t\t\t\t u64 physical_offset, u64 physical_len)\n{\n\tstruct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree;\n\tstruct extent_map *em;\n\tstruct map_lookup *map;\n\tstruct btrfs_device *dev;\n\tu64 stripe_len;\n\tbool found = false;\n\tint ret = 0;\n\tint i;\n\n\tread_lock(&em_tree->lock);\n\tem = lookup_extent_mapping(em_tree, chunk_offset, 1);\n\tread_unlock(&em_tree->lock);\n\n\tif (!em) {\n\t\tbtrfs_err(fs_info,\n\"dev extent physical offset %llu on devid %llu doesn't have corresponding chunk\",\n\t\t\t  physical_offset, devid);\n\t\tret = -EUCLEAN;\n\t\tgoto out;\n\t}\n\n\tmap = em->map_lookup;\n\tstripe_len = calc_stripe_length(map->type, em->len, map->num_stripes);\n\tif (physical_len != stripe_len) {\n\t\tbtrfs_err(fs_info,\n\"dev extent physical offset %llu on devid %llu length doesn't match chunk %llu, have %llu expect %llu\",\n\t\t\t  physical_offset, devid, em->start, physical_len,\n\t\t\t  stripe_len);\n\t\tret = -EUCLEAN;\n\t\tgoto out;\n\t}\n\n\tfor (i = 0; i < map->num_stripes; i++) {\n\t\tif (map->stripes[i].dev->devid == devid &&\n\t\t    map->stripes[i].physical == physical_offset) {\n\t\t\tfound = true;\n\t\t\tif (map->verified_stripes >= map->num_stripes) {\n\t\t\t\tbtrfs_err(fs_info,\n\t\t\t\t\"too many dev extents for chunk %llu found\",\n\t\t\t\t\t  em->start);\n\t\t\t\tret = -EUCLEAN;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tmap->verified_stripes++;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!found) {\n\t\tbtrfs_err(fs_info,\n\t\"dev extent physical offset %llu devid %llu has no corresponding chunk\",\n\t\t\tphysical_offset, devid);\n\t\tret = -EUCLEAN;\n\t}\n\n\t\/* Make sure no dev extent is beyond device bondary *\/\n\tdev = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL);\n\tif (!dev) {\n\t\tbtrfs_err(fs_info, \"failed to find devid %llu\", devid);\n\t\tret = -EUCLEAN;\n\t\tgoto out;\n\t}\n\n\t\/* It's possible this device is a dummy for seed device *\/\n\tif (dev->disk_total_bytes == 0) {\n\t\tdev = find_device(fs_info->fs_devices->seed, devid, NULL);\n\t\tif (!dev) {\n\t\t\tbtrfs_err(fs_info, \"failed to find seed devid %llu\",\n\t\t\t\t  devid);\n\t\t\tret = -EUCLEAN;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tif (physical_offset + physical_len > dev->disk_total_bytes) {\n\t\tbtrfs_err(fs_info,\n\"dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu\",\n\t\t\t  devid, physical_offset, physical_len,\n\t\t\t  dev->disk_total_bytes);\n\t\tret = -EUCLEAN;\n\t\tgoto out;\n\t}\nout:\n\tfree_extent_map(em);\n\treturn ret;\n}","target":1,"code_token_length":697,"total_token_length":933,"max_tokens_setting":1024}
+{"idx":290078,"func":"static afs_int32 isAMemberOf ( struct rx_call * call , afs_int32 uid , afs_int32 gid , afs_int32 * flag , afs_int32 * cid ) {\n afs_int32 code ;\n struct ubik_trans * tt ;\n code = Initdb ( ) ;\n if ( code != PRSUCCESS ) return code ;\n code = ubik_BeginTransReadAny ( dbase , UBIK_READTRANS , & tt ) ;\n if ( code ) return code ;\n code = ubik_SetLock ( tt , 1 , 1 , LOCKREAD ) ;\n if ( code ) ABORT_WITH ( tt , code ) ;\n code = read_DbHeader ( tt ) ;\n if ( code ) ABORT_WITH ( tt , code ) ;\n {\n afs_int32 uloc = FindByID ( tt , uid ) ;\n afs_int32 gloc = FindByID ( tt , gid ) ;\n struct prentry uentry , gentry ;\n if ( ! uloc || ! gloc ) ABORT_WITH ( tt , PRNOENT ) ;\n code = WhoIsThis ( call , tt , cid ) ;\n if ( code ) ABORT_WITH ( tt , PRPERM ) ;\n code = pr_ReadEntry ( tt , 0 , uloc , & uentry ) ;\n if ( code ) ABORT_WITH ( tt , code ) ;\n code = pr_ReadEntry ( tt , 0 , gloc , & gentry ) ;\n if ( code ) ABORT_WITH ( tt , code ) ;\n # if ! defined ( SUPERGROUPS ) if ( ( uentry . flags & PRGRP ) || ! ( gentry . flags & PRGRP ) ) ABORT_WITH ( tt , PRBADARG ) ;\n # else if ( ! ( gentry . flags & PRGRP ) ) ABORT_WITH ( tt , PRBADARG ) ;\n # endif if ( ! AccessOK ( tt , * cid , & uentry , 0 , PRP_MEMBER_ANY ) && ! AccessOK ( tt , * cid , & gentry , PRP_MEMBER_MEM , PRP_MEMBER_ANY ) ) ABORT_WITH ( tt , PRPERM ) ;\n }\n * flag = IsAMemberOf ( tt , uid , gid ) ;\n code = ubik_EndTrans ( tt ) ;\n return code ;\n }","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":422044,"func":"mail_config_ews_autodiscover_run_cb (GObject *source_object,\n                                     GAsyncResult *result,\n                                     gpointer user_data)\n{\n\tAsyncContext *async_context = user_data;\n\tEMailConfigEwsAutodiscover *autodiscover;\n\tEAlertSink *alert_sink;\n\tGError *error = NULL;\n\tEMailConfigServiceBackend *backend;\n\tCamelSettings *settings;\n\n\tautodiscover = async_context->autodiscover;\n\talert_sink = e_activity_get_alert_sink (async_context->activity);\n\n\tmail_config_ews_autodiscover_finish (E_MAIL_CONFIG_EWS_AUTODISCOVER (source_object), result, &error);\n\n\tbackend = e_mail_config_ews_autodiscover_get_backend (autodiscover);\n\tsettings = e_mail_config_service_backend_get_settings (backend);\n\t\/*\n\t * And unstop since we are back to the main thread.\n\t *\/\n\tg_object_thaw_notify (G_OBJECT (settings));\n\n\tif (e_activity_handle_cancellation (async_context->activity, error)) {\n\t\t\/* Do nothing, just free the error below *\/\n\t} else if (g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) &&\n\t\t   async_context->certificate_pem && *async_context->certificate_pem && async_context->certificate_errors) {\n\t\tETrustPromptResponse response;\n\t\tGtkWidget *parent;\n\t\tconst gchar *host;\n\n\t\tparent = gtk_widget_get_toplevel (GTK_WIDGET (autodiscover));\n\t\tif (!GTK_IS_WINDOW (parent))\n\t\t\tparent = NULL;\n\n\t\thost = camel_network_settings_get_host (CAMEL_NETWORK_SETTINGS (settings));\n\n\t\tresponse = e_trust_prompt_run_modal (parent ? GTK_WINDOW (parent) : NULL,\n\t\t\tE_SOURCE_EXTENSION_COLLECTION, _(\"Exchange Web Services\"),\n\t\t\thost, async_context->certificate_pem, async_context->certificate_errors,\n\t\t\terror->message);\n\n\t\tg_clear_error (&error);\n\n\t\tif (response != E_TRUST_PROMPT_RESPONSE_UNKNOWN) {\n\t\t\tGTlsCertificate *certificate;\n\n\t\t\tcertificate = g_tls_certificate_new_from_pem (async_context->certificate_pem, -1, &error);\n\t\t\tif (certificate) {\n\t\t\t\tESourceWebdav *extension_webdav;\n\n\t\t\t\textension_webdav = e_source_get_extension (async_context->source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);\n\n\t\t\t\te_source_webdav_update_ssl_trust (extension_webdav, host, certificate, response);\n\n\t\t\t\tg_object_unref (certificate);\n\t\t\t}\n\n\t\t\tif (error) {\n\t\t\t\te_alert_submit (\n\t\t\t\t\talert_sink,\n\t\t\t\t\t\"ews:autodiscovery-error\",\n\t\t\t\t\terror->message, NULL);\n\t\t\t}\n\t\t}\n\n\t\tif (response == E_TRUST_PROMPT_RESPONSE_ACCEPT ||\n\t\t    response == E_TRUST_PROMPT_RESPONSE_ACCEPT_TEMPORARILY) {\n\t\t\tmail_config_ews_autodiscover_run (autodiscover);\n\t\t}\n\t} else if (error != NULL) {\n\t\te_alert_submit (\n\t\t\talert_sink,\n\t\t\t\"ews:autodiscovery-error\",\n\t\t\terror->message, NULL);\n\t}\n\n\tgtk_widget_set_sensitive (GTK_WIDGET (autodiscover), TRUE);\n\n\tg_clear_error (&error);\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":314983,"func":"poppler_page_get_form_field_mapping (PopplerPage *page)\n{\n  GList *map_list = NULL;\n  FormPageWidgets *forms;\n  gint i;\n  \n  g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL);\n\n  forms = page->page->getPageWidgets ();\n  if (forms == NULL)\n    return NULL;\n  \n  for (i = 0; i < forms->getNumWidgets (); i++) {\n    PopplerFormFieldMapping *mapping;\n    FormWidget *field;\n\n    mapping = poppler_form_field_mapping_new ();\n    \n    field = forms->getWidget (i);\n\n    mapping->field = _poppler_form_field_new (page->document, field);\n    field->getRect (&(mapping->area.x1), &(mapping->area.y1),\n\t\t    &(mapping->area.x2), &(mapping->area.y2));\n\n    mapping->area.x1 -= page->page->getCropBox()->x1;\n    mapping->area.x2 -= page->page->getCropBox()->x1;\n    mapping->area.y1 -= page->page->getCropBox()->y1;\n    mapping->area.y2 -= page->page->getCropBox()->y1;\n    \n    map_list = g_list_prepend (map_list, mapping);\n  }\n  \n  return map_list;\n}\n","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":426141,"func":"qb_ipcc_us_disconnect(struct qb_ipcc_connection *c)\n{\n\tmunmap(c->request.u.us.shared_data, SHM_CONTROL_SIZE);\n\tunlink(c->request.u.us.shared_file_name);\n\n\tif (use_filesystem_sockets()) {\n\t\tstruct sockaddr_un un_addr;\n\t\tsocklen_t un_addr_len = sizeof(struct sockaddr_un);\n\t\tchar *base_name;\n\t\tchar sock_name[PATH_MAX];\n\t\tsize_t length;\n\t\tif (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {\n\t\t\tlength = strlen(un_addr.sun_path);\n\t\t\tbase_name = strndup(un_addr.sun_path,\n\t\t\t\t\t    length - \/* strlen(\"-response\") *\/ 9);\n\t\t\tqb_util_log(LOG_DEBUG, \"unlinking socket bound files with base_name=%s length=%d\",base_name,length);\n\t\t\tsnprintf(sock_name,PATH_MAX,\"%s-%s\",base_name,\"request\");\n\t\t\tqb_util_log(LOG_DEBUG, \"unlink sock_name=%s\",sock_name);\n\t\t\tunlink(sock_name);\n\t\t\tsnprintf(sock_name,PATH_MAX,\"%s-%s\",base_name,\"event\");\n\t\t\tqb_util_log(LOG_DEBUG, \"unlink sock_name=%s\",sock_name);\n\t\t\tunlink(sock_name);\n\t\t\tsnprintf(sock_name,PATH_MAX,\"%s-%s\",base_name,\"event-tx\");\n\t\t\tqb_util_log(LOG_DEBUG, \"unlink sock_name=%s\",sock_name);\n\t\t\tunlink(sock_name);\n\t\t\tsnprintf(sock_name,PATH_MAX,\"%s-%s\",base_name,\"response\");\n\t\t\tqb_util_log(LOG_DEBUG, \"unlink sock_name=%s\",sock_name);\n\t\t\tunlink(sock_name);\n\t\t\tfree(base_name);\n\t\t}\n\t}\n\tqb_ipcc_us_sock_close(c->event.u.us.sock);\n\tqb_ipcc_us_sock_close(c->request.u.us.sock);\n\tqb_ipcc_us_sock_close(c->setup.u.us.sock);\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":523271,"func":"bool LEX::sp_for_loop_cursor_declarations(THD *thd,\n                                          Lex_for_loop_st *loop,\n                                          const LEX_CSTRING *index,\n                                          const Lex_for_loop_bounds_st &bounds)\n{\n  Item *item= bounds.m_index->get_item();\n  Item_splocal *item_splocal;\n  Item_field *item_field;\n  Item_func_sp *item_func_sp= NULL;\n  LEX_CSTRING name;\n  uint coffs, param_count= 0;\n  const sp_pcursor *pcursor;\n  DBUG_ENTER(\"LEX::sp_for_loop_cursor_declarations\");\n\n  if ((item_splocal= item->get_item_splocal()))\n    name= item_splocal->m_name;\n  else if ((item_field= item->type() == Item::FIELD_ITEM ?\n                        static_cast<Item_field *>(item) : NULL) &&\n           item_field->table_name == NULL)\n    name= item_field->field_name;\n  else if (item->type() == Item::FUNC_ITEM &&\n           static_cast<Item_func*>(item)->functype() == Item_func::FUNC_SP &&\n           !static_cast<Item_func_sp*>(item)->get_sp_name()->m_explicit_name)\n  {\n    \/*\n      When a FOR LOOP for a cursor with parameters is parsed:\n        FOR index IN cursor(1,2,3) LOOP\n          statements;\n        END LOOP;\n      the parser scans \"cursor(1,2,3)\" using the \"expr\" rule,\n      so it thinks that cursor(1,2,3) is a stored function call.\n      It's not easy to implement this without using \"expr\" because\n      of grammar conflicts.\n      As a side effect, the Item_func_sp and its arguments in the parentheses\n      belong to the same LEX. This is different from an explicit\n      \"OPEN cursor(1,2,3)\" where every expression belongs to a separate LEX.\n    *\/\n    item_func_sp= static_cast<Item_func_sp*>(item);\n    name= item_func_sp->get_sp_name()->m_name;\n    param_count= item_func_sp->argument_count();\n  }\n  else\n  {\n    thd->parse_error();\n    DBUG_RETURN(true);\n  }\n  if (unlikely(!(pcursor= spcont->find_cursor_with_error(&name, &coffs,\n                                                         false)) ||\n               pcursor->check_param_count_with_error(param_count)))\n    DBUG_RETURN(true);\n\n  if (!(loop->m_index= sp_add_for_loop_cursor_variable(thd, index,\n                                                       pcursor, coffs,\n                                                       bounds.m_index,\n                                                       item_func_sp)))\n    DBUG_RETURN(true);\n  loop->m_target_bound= NULL;\n  loop->m_direction= bounds.m_direction;\n  loop->m_cursor_offset= coffs;\n  loop->m_implicit_cursor= bounds.m_implicit_cursor;\n  DBUG_RETURN(false);\n}","target":0,"code_token_length":596,"total_token_length":832,"max_tokens_setting":1024}
+{"idx":435695,"func":"set_optimize_exact(regex_t* reg, OptExact* e)\n{\n  int r;\n\n  if (e->len == 0) return 0;\n\n  if (e->ignore_case) {\n    reg->exact = (UChar* )xmalloc(e->len);\n    CHECK_NULL_RETURN_MEMERR(reg->exact);\n    xmemcpy(reg->exact, e->s, e->len);\n    reg->exact_end = reg->exact + e->len;\n    reg->optimize = OPTIMIZE_STR_IC;\n  }\n  else {\n    int allow_reverse;\n\n    reg->exact = onigenc_strdup(reg->enc, e->s, e->s + e->len);\n    CHECK_NULL_RETURN_MEMERR(reg->exact);\n    reg->exact_end = reg->exact + e->len;\n\n    allow_reverse =\n      ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);\n\n    if (e->len >= 3 || (e->len >= 2 && allow_reverse)) {\n#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM\n      r = set_sunday_quick_search_skip_table(reg->exact, reg->exact_end,\n                                             reg->enc, reg->map,\n                                             &(reg->map_offset));\n#else\n      r = set_bmh_search_skip_table(reg->exact, reg->exact_end,\n                                    reg->enc, reg->map);\n#endif\n      if (r != 0) return r;\n\n      reg->optimize = (allow_reverse != 0\n                       ? OPTIMIZE_STR_FAST\n                       : OPTIMIZE_STR_FAST_STEP_FORWARD);\n    }\n    else {\n      reg->optimize = OPTIMIZE_STR;\n    }\n  }\n\n  reg->dmin = e->mmd.min;\n  reg->dmax = e->mmd.max;\n\n  if (reg->dmin != INFINITE_LEN) {\n    reg->threshold_len = reg->dmin + (int )(reg->exact_end - reg->exact);\n  }\n\n  return 0;\n}","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":511755,"func":"rl_on_new_line_with_prompt ()\n{\n  int prompt_size, i, l, real_screenwidth, newlines;\n  char *prompt_last_line, *lprompt;\n\n  \/* Initialize visible_line and invisible_line to ensure that they can hold\n     the already-displayed prompt. *\/\n  prompt_size = strlen (rl_prompt) + 1;\n  init_line_structures (prompt_size);\n\n  \/* Make sure the line structures hold the already-displayed prompt for\n     redisplay. *\/\n  lprompt = local_prompt ? local_prompt : rl_prompt;\n  strcpy (visible_line, lprompt);\n  strcpy (invisible_line, lprompt);\n\n  \/* If the prompt contains newlines, take the last tail. *\/\n  prompt_last_line = strrchr (rl_prompt, '\\n');\n  if (!prompt_last_line)\n    prompt_last_line = rl_prompt;\n\n  l = strlen (prompt_last_line);\n  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)\n    _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1);\t\/* XXX *\/\n  else\n    _rl_last_c_pos = l;\n\n  \/* Dissect prompt_last_line into screen lines. Note that here we have\n     to use the real screenwidth. Readline's notion of screenwidth might be\n     one less, see terminal.c. *\/\n  real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1);\n  _rl_last_v_pos = l \/ real_screenwidth;\n  \/* If the prompt length is a multiple of real_screenwidth, we don't know\n     whether the cursor is at the end of the last line, or already at the\n     beginning of the next line. Output a newline just to be safe. *\/\n  if (l > 0 && (l % real_screenwidth) == 0)\n    _rl_output_some_chars (\"\\n\", 1);\n  last_lmargin = 0;\n\n  newlines = 0; i = 0;\n  while (i <= l)\n    {\n      _rl_vis_botlin = newlines;\n      vis_lbreaks[newlines++] = i;\n      i += real_screenwidth;\n    }\n  vis_lbreaks[newlines] = l;\n  visible_wrap_offset = 0;\n\n  rl_display_prompt = rl_prompt;\t\/* XXX - make sure it's set *\/\n\n  return 0;\n}","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":292895,"func":"static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){\n  Vdbe *v = 0;\n  int iLimit = 0;\n  int iOffset;\n  int n;\n  Expr *pLimit = p->pLimit;\n\n  if( p->iLimit ) return;\n\n  \/* \n  ** \"LIMIT -1\" always shows all rows.  There is some\n  ** controversy about what the correct behavior should be.\n  ** The current implementation interprets \"LIMIT 0\" to mean\n  ** no rows.\n  *\/\n  if( pLimit ){\n    assert( pLimit->op==TK_LIMIT );\n    assert( pLimit->pLeft!=0 );\n    p->iLimit = iLimit = ++pParse->nMem;\n    v = sqlite3GetVdbe(pParse);\n    assert( v!=0 );\n    if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){\n      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);\n      VdbeComment((v, \"LIMIT counter\"));\n      if( n==0 ){\n        sqlite3VdbeGoto(v, iBreak);\n      }else if( n>=0 && p->nSelectRow>sqlite3LogEst((u64)n) ){\n        p->nSelectRow = sqlite3LogEst((u64)n);\n        p->selFlags |= SF_FixedLimit;\n      }\n    }else{\n      sqlite3ExprCode(pParse, pLimit->pLeft, iLimit);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);\n      VdbeComment((v, \"LIMIT counter\"));\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);\n    }\n    if( pLimit->pRight ){\n      p->iOffset = iOffset = ++pParse->nMem;\n      pParse->nMem++;   \/* Allocate an extra register for limit+offset *\/\n      sqlite3ExprCode(pParse, pLimit->pRight, iOffset);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); VdbeCoverage(v);\n      VdbeComment((v, \"OFFSET counter\"));\n      sqlite3VdbeAddOp3(v, OP_OffsetLimit, iLimit, iOffset+1, iOffset);\n      VdbeComment((v, \"LIMIT+OFFSET\"));\n    }\n  }\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":24113,"func":"static int32_t offsetTOCPrefixBinarySearch ( const char * s , const char * names , const UDataOffsetTOCEntry * toc , int32_t count ) {\n int32_t start = 0 ;\n int32_t limit = count ;\n int32_t startPrefixLength = 0 ;\n int32_t limitPrefixLength = 0 ;\n if ( count == 0 ) {\n return - 1 ;\n }\n if ( 0 == strcmpAfterPrefix ( s , names + toc [ 0 ] . nameOffset , & startPrefixLength ) ) {\n return 0 ;\n }\n ++ start ;\n -- limit ;\n if ( 0 == strcmpAfterPrefix ( s , names + toc [ limit ] . nameOffset , & limitPrefixLength ) ) {\n return limit ;\n }\n while ( start < limit ) {\n int32_t i = ( start + limit ) \/ 2 ;\n int32_t prefixLength = MIN ( startPrefixLength , limitPrefixLength ) ;\n int32_t cmp = strcmpAfterPrefix ( s , names + toc [ i ] . nameOffset , & prefixLength ) ;\n if ( cmp < 0 ) {\n limit = i ;\n limitPrefixLength = prefixLength ;\n }\n else if ( cmp == 0 ) {\n return i ;\n }\n else {\n start = i + 1 ;\n startPrefixLength = prefixLength ;\n }\n }\n return - 1 ;\n }","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":407544,"func":"ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit)\n{\n\tint c, lc;\n\tint p; \/* 0 -> no parenthese seen, >0 nr of ( seen *\/\n\tint com, quoted;\n\tchar *t;\n\tsize_t i;\n\tconst char *d;\n\tconst char *del;\n\n\t\/* standard delimiters *\/\n\tif (!delim) {\n\t\t\/* from isspace(3) *\/\n\t\tdel = LDNS_PARSE_NORMAL;\n\t} else {\n\t\tdel = delim;\n\t}\n\n\tp = 0;\n\ti = 0;\n\tcom = 0;\n\tquoted = 0;\n\tt = token;\n\tlc = 0;\n\tif (del[0] == '\"') {\n\t\tquoted = 1;\n\t}\n\n\twhile ((c = ldns_bgetc(b)) != EOF) {\n\t\tif (c == '\\r') \/* carriage return *\/\n\t\t\tc = ' ';\n\t\tif (c == '(' && lc != '\\\\' && !quoted) {\n\t\t\t\/* this only counts for non-comments *\/\n\t\t\tif (com == 0) {\n\t\t\t\tp++;\n\t\t\t}\n\t\t\tlc = c;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (c == ')' && lc != '\\\\' && !quoted) {\n\t\t\t\/* this only counts for non-comments *\/\n\t\t\tif (com == 0) {\n\t\t\t\tp--;\n\t\t\t}\n\t\t\tlc = c;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (p < 0) {\n\t\t\t\/* more ) then ( *\/\n\t\t\t*t = '\\0';\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* do something with comments ; *\/\n\t\tif (c == ';' && quoted == 0) {\n\t\t\tif (lc != '\\\\') {\n\t\t\t\tcom = 1;\n\t\t\t}\n\t\t}\n\t\tif (c == '\"' && com == 0 && lc != '\\\\') {\n\t\t\tquoted = 1 - quoted;\n\t\t}\n\n\t\tif (c == '\\n' && com != 0) {\n\t\t\t\/* comments *\/\n\t\t\tcom = 0;\n\t\t\t*t = ' ';\n\t\t\tlc = c;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (com == 1) {\n\t\t\t*t = ' ';\n\t\t\tlc = c;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (c == '\\n' && p != 0) {\n\t\t\t\/* in parentheses *\/\n\t\t\t*t++ = ' ';\n\t\t\tlc = c;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* check if we hit the delim *\/\n\t\tfor (d = del; *d; d++) {\n                        if (c == *d && lc != '\\\\' && p == 0) {\n\t\t\t\tgoto tokenread;\n                        }\n\t\t}\n\n\t\ti++;\n\t\tif (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {\n\t\t\t*t = '\\0';\n\t\t\treturn -1;\n\t\t}\n\t\t*t++ = c;\n\n\t\tif (c == '\\\\' && lc == '\\\\') {\n\t\t\tlc = 0;\n\t\t} else {\n\t\t\tlc = c;\n\t\t}\n\t}\n\t*t = '\\0';\n\tif (i == 0) {\n\t\t\/* nothing read *\/\n\t\treturn -1;\n\t}\n\tif (p != 0) {\n\t\treturn -1;\n\t}\n\treturn (ssize_t)i;\n\ntokenread:\n\tif(*del == '\"') \/* do not skip over quotes, they are significant *\/\n\t\tldns_bskipcs(b, del+1);\n\telse\tldns_bskipcs(b, del);\n\t*t = '\\0';\n\n\tif (p != 0) {\n\t\treturn -1;\n\t}\n\treturn (ssize_t)i;\n}","target":0,"code_token_length":768,"total_token_length":1004,"max_tokens_setting":1024}
+{"idx":53229,"func":"static int lookup_fast(struct nameidata *nd,\n\t\t       struct path *path, struct inode **inode,\n\t\t       unsigned *seqp)\n{\n\tstruct vfsmount *mnt = nd->path.mnt;\n\tstruct dentry *dentry, *parent = nd->path.dentry;\n\tint status = 1;\n\tint err;\n\n\t\/*\n\t * Rename seqlock is not required here because in the off chance\n\t * of a false negative due to a concurrent rename, the caller is\n\t * going to fall back to non-racy lookup.\n\t *\/\n\tif (nd->flags & LOOKUP_RCU) {\n\t\tunsigned seq;\n\t\tbool negative;\n\t\tdentry = __d_lookup_rcu(parent, &nd->last, &seq);\n\t\tif (unlikely(!dentry)) {\n\t\t\tif (unlazy_walk(nd))\n\t\t\t\treturn -ECHILD;\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/*\n\t\t * This sequence count validates that the inode matches\n\t\t * the dentry name information from lookup.\n\t\t *\/\n\t\t*inode = d_backing_inode(dentry);\n\t\tnegative = d_is_negative(dentry);\n\t\tif (unlikely(read_seqcount_retry(&dentry->d_seq, seq)))\n\t\t\treturn -ECHILD;\n\n\t\t\/*\n\t\t * This sequence count validates that the parent had no\n\t\t * changes while we did the lookup of the dentry above.\n\t\t *\n\t\t * The memory barrier in read_seqcount_begin of child is\n\t\t *  enough, we can use __read_seqcount_retry here.\n\t\t *\/\n\t\tif (unlikely(__read_seqcount_retry(&parent->d_seq, nd->seq)))\n\t\t\treturn -ECHILD;\n\n\t\t*seqp = seq;\n\t\tstatus = d_revalidate(dentry, nd->flags);\n\t\tif (likely(status > 0)) {\n\t\t\t\/*\n\t\t\t * Note: do negative dentry check after revalidation in\n\t\t\t * case that drops it.\n\t\t\t *\/\n\t\t\tif (unlikely(negative))\n\t\t\t\treturn -ENOENT;\n\t\t\tpath->mnt = mnt;\n\t\t\tpath->dentry = dentry;\n\t\t\tif (likely(__follow_mount_rcu(nd, path, inode, seqp)))\n\t\t\t\treturn 1;\n\t\t}\n\t\tif (unlazy_child(nd, dentry, seq))\n\t\t\treturn -ECHILD;\n\t\tif (unlikely(status == -ECHILD))\n\t\t\t\/* we'd been told to redo it in non-rcu mode *\/\n\t\t\tstatus = d_revalidate(dentry, nd->flags);\n\t} else {\n\t\tdentry = __d_lookup(parent, &nd->last);\n\t\tif (unlikely(!dentry))\n\t\t\treturn 0;\n\t\tstatus = d_revalidate(dentry, nd->flags);\n\t}\n\tif (unlikely(status <= 0)) {\n\t\tif (!status)\n\t\t\td_invalidate(dentry);\n\t\tdput(dentry);\n\t\treturn status;\n\t}\n\n\tpath->mnt = mnt;\n\tpath->dentry = dentry;\n\terr = follow_managed(path, nd);\n\tif (likely(err > 0))\n\t\t*inode = d_backing_inode(path->dentry);\n\treturn err;\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":355,"func":"void xps_begin_opacity ( xps_document * doc , const fz_matrix * ctm , const fz_rect * area , char * base_uri , xps_resource * dict , char * opacity_att , fz_xml * opacity_mask_tag ) {\n float opacity ;\n if ( ! opacity_att && ! opacity_mask_tag ) return ;\n opacity = 1 ;\n if ( opacity_att ) opacity = fz_atof ( opacity_att ) ;\n if ( opacity_mask_tag && ! strcmp ( fz_xml_tag ( opacity_mask_tag ) , \"SolidColorBrush\" ) ) {\n char * scb_opacity_att = fz_xml_att ( opacity_mask_tag , \"Opacity\" ) ;\n char * scb_color_att = fz_xml_att ( opacity_mask_tag , \"Color\" ) ;\n if ( scb_opacity_att ) opacity = opacity * fz_atof ( scb_opacity_att ) ;\n if ( scb_color_att ) {\n fz_colorspace * colorspace ;\n float samples [ 32 ] ;\n xps_parse_color ( doc , base_uri , scb_color_att , & colorspace , samples ) ;\n opacity = opacity * samples [ 0 ] ;\n }\n opacity_mask_tag = NULL ;\n }\n if ( doc -> opacity_top + 1 < nelem ( doc -> opacity ) ) {\n doc -> opacity [ doc -> opacity_top + 1 ] = doc -> opacity [ doc -> opacity_top ] * opacity ;\n doc -> opacity_top ++ ;\n }\n if ( opacity_mask_tag ) {\n fz_begin_mask ( doc -> dev , area , 0 , NULL , NULL ) ;\n xps_parse_brush ( doc , ctm , area , base_uri , dict , opacity_mask_tag ) ;\n fz_end_mask ( doc -> dev ) ;\n }\n }","target":1,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":186949,"func":"zend_bool php_openssl_pkey_init_and_assign_rsa(EVP_PKEY *pkey, RSA *rsa, zval *data)\n{\n\tBIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;\n\n\tOPENSSL_PKEY_SET_BN(data, n);\n\tOPENSSL_PKEY_SET_BN(data, e);\n\tOPENSSL_PKEY_SET_BN(data, d);\n\tif (!n || !d || !RSA_set0_key(rsa, n, e, d)) {\n\t\treturn 0;\n\t}\n\n\tOPENSSL_PKEY_SET_BN(data, p);\n\tOPENSSL_PKEY_SET_BN(data, q);\n\tif ((p || q) && !RSA_set0_factors(rsa, p, q)) {\n\t\treturn 0;\n\t}\n\n\tOPENSSL_PKEY_SET_BN(data, dmp1);\n\tOPENSSL_PKEY_SET_BN(data, dmq1);\n\tOPENSSL_PKEY_SET_BN(data, iqmp);\n\tif ((dmp1 || dmq1 || iqmp) && !RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp)) {\n\t\treturn 0;\n\t}\n\n\tif (!EVP_PKEY_assign_RSA(pkey, rsa)) {\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}\n","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":342370,"func":"int ff_snow_frame_start(SnowContext *s){\n\n   AVFrame tmp;\n\n   int i, ret;\n\n   int w= s->avctx->width; \/\/FIXME round up to x16 ?\n\n   int h= s->avctx->height;\n\n\n\n    if (s->current_picture.data[0] && !(s->avctx->flags&CODEC_FLAG_EMU_EDGE)) {\n\n        s->dsp.draw_edges(s->current_picture.data[0],\n\n                          s->current_picture.linesize[0], w   , h   ,\n\n                          EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | EDGE_BOTTOM);\n\n        s->dsp.draw_edges(s->current_picture.data[1],\n\n                          s->current_picture.linesize[1], w>>s->chroma_h_shift, h>>s->chroma_v_shift,\n\n                          EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);\n\n        s->dsp.draw_edges(s->current_picture.data[2],\n\n                          s->current_picture.linesize[2], w>>s->chroma_h_shift, h>>s->chroma_v_shift,\n\n                          EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);\n\n    }\n\n\n\n    ff_snow_release_buffer(s->avctx);\n\n\n\n    av_frame_move_ref(&tmp, &s->last_picture[s->max_ref_frames-1]);\n\n    for(i=s->max_ref_frames-1; i>0; i--)\n\n        av_frame_move_ref(&s->last_picture[i], &s->last_picture[i-1]);\n\n    memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4);\n\n    if(USE_HALFPEL_PLANE && s->current_picture.data[0])\n\n        halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture);\n\n    av_frame_move_ref(&s->last_picture[0], &s->current_picture);\n\n    av_frame_move_ref(&s->current_picture, &tmp);\n\n\n\n    if(s->keyframe){\n\n        s->ref_frames= 0;\n\n    }else{\n\n        int i;\n\n        for(i=0; i<s->max_ref_frames && s->last_picture[i].data[0]; i++)\n\n            if(i && s->last_picture[i-1].key_frame)\n\n                break;\n\n        s->ref_frames= i;\n\n        if(s->ref_frames==0){\n\n            av_log(s->avctx,AV_LOG_ERROR, \"No reference frames\\n\");\n\n            return -1;\n\n        }\n\n    }\n\n\n\n    if ((ret = ff_get_buffer(s->avctx, &s->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0)\n\n        return ret;\n\n\n\n    s->current_picture.key_frame= s->keyframe;\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":608,"total_token_length":844,"max_tokens_setting":1024}
+{"idx":165720,"func":"GBool DCTStream::readBaselineSOF() {\n  int length;\n  int prec;\n  int i;\n  int c;\n\n  length = read16();\n  prec = str->getChar();\n  height = read16();\n  width = read16();\n  numComps = str->getChar();\n  if (numComps <= 0 || numComps > 4) {\n    error(errSyntaxError, getPos(), \"Bad number of components in DCT stream\");\n    numComps = 0;\n    return gFalse;\n  }\n  if (prec != 8) {\n    error(errSyntaxError, getPos(), \"Bad DCT precision {0:d}\", prec);\n    return gFalse;\n  }\n  for (i = 0; i < numComps; ++i) {\n    compInfo[i].id = str->getChar();\n    c = str->getChar();\n    compInfo[i].hSample = (c >> 4) & 0x0f;\n    compInfo[i].vSample = c & 0x0f;\n    compInfo[i].quantTable = str->getChar();\n    if (compInfo[i].hSample < 1 || compInfo[i].hSample > 4 ||\n\tcompInfo[i].vSample < 1 || compInfo[i].vSample > 4) {\n      error(errSyntaxError, getPos(), \"Bad DCT sampling factor\");\n      return gFalse;\n    }\n    if (compInfo[i].quantTable < 0 || compInfo[i].quantTable > 3) {\n      error(errSyntaxError, getPos(), \"Bad DCT quant table selector\");\n      return gFalse;\n    }\n  }\n  progressive = gFalse;\n  return gTrue;\n}\n","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":492682,"func":"static int check_return_code(struct bpf_verifier_env *env)\n{\n\tstruct tnum enforce_attach_type_range = tnum_unknown;\n\tconst struct bpf_prog *prog = env->prog;\n\tstruct bpf_reg_state *reg;\n\tstruct tnum range = tnum_range(0, 1);\n\tint err;\n\n\t\/* The struct_ops func-ptr's return type could be \"void\" *\/\n\tif (env->prog->type == BPF_PROG_TYPE_STRUCT_OPS &&\n\t    !prog->aux->attach_func_proto->type)\n\t\treturn 0;\n\n\t\/* eBPF calling convetion is such that R0 is used\n\t * to return the value from eBPF program.\n\t * Make sure that it's readable at this time\n\t * of bpf_exit, which means that program wrote\n\t * something into it earlier\n\t *\/\n\terr = check_reg_arg(env, BPF_REG_0, SRC_OP);\n\tif (err)\n\t\treturn err;\n\n\tif (is_pointer_value(env, BPF_REG_0)) {\n\t\tverbose(env, \"R0 leaks addr as return value\\n\");\n\t\treturn -EACCES;\n\t}\n\n\tswitch (env->prog->type) {\n\tcase BPF_PROG_TYPE_CGROUP_SOCK_ADDR:\n\t\tif (env->prog->expected_attach_type == BPF_CGROUP_UDP4_RECVMSG ||\n\t\t    env->prog->expected_attach_type == BPF_CGROUP_UDP6_RECVMSG)\n\t\t\trange = tnum_range(1, 1);\n\t\tbreak;\n\tcase BPF_PROG_TYPE_CGROUP_SKB:\n\t\tif (env->prog->expected_attach_type == BPF_CGROUP_INET_EGRESS) {\n\t\t\trange = tnum_range(0, 3);\n\t\t\tenforce_attach_type_range = tnum_range(2, 3);\n\t\t}\n\t\tbreak;\n\tcase BPF_PROG_TYPE_CGROUP_SOCK:\n\tcase BPF_PROG_TYPE_SOCK_OPS:\n\tcase BPF_PROG_TYPE_CGROUP_DEVICE:\n\tcase BPF_PROG_TYPE_CGROUP_SYSCTL:\n\tcase BPF_PROG_TYPE_CGROUP_SOCKOPT:\n\t\tbreak;\n\tcase BPF_PROG_TYPE_RAW_TRACEPOINT:\n\t\tif (!env->prog->aux->attach_btf_id)\n\t\t\treturn 0;\n\t\trange = tnum_const(0);\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\treg = cur_regs(env) + BPF_REG_0;\n\tif (reg->type != SCALAR_VALUE) {\n\t\tverbose(env, \"At program exit the register R0 is not a known value (%s)\\n\",\n\t\t\treg_type_str[reg->type]);\n\t\treturn -EINVAL;\n\t}\n\n\tif (!tnum_in(range, reg->var_off)) {\n\t\tchar tn_buf[48];\n\n\t\tverbose(env, \"At program exit the register R0 \");\n\t\tif (!tnum_is_unknown(reg->var_off)) {\n\t\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\t\tverbose(env, \"has value %s\", tn_buf);\n\t\t} else {\n\t\t\tverbose(env, \"has unknown scalar value\");\n\t\t}\n\t\ttnum_strn(tn_buf, sizeof(tn_buf), range);\n\t\tverbose(env, \" should have been in %s\\n\", tn_buf);\n\t\treturn -EINVAL;\n\t}\n\n\tif (!tnum_is_unknown(enforce_attach_type_range) &&\n\t    tnum_in(enforce_attach_type_range, reg->var_off))\n\t\tenv->prog->enforce_expected_attach_type = 1;\n\treturn 0;\n}","target":0,"code_token_length":739,"total_token_length":975,"max_tokens_setting":1024}
+{"idx":414862,"func":"MagickExport MagickBooleanType AnimateImages(const ImageInfo *image_info,\n  Image *images)\n{\n  char\n    *argv[1];\n\n  Display\n    *display;\n\n  MagickStatusType\n    status;\n\n  XrmDatabase\n    resource_database;\n\n  XResourceInfo\n    resource_info;\n\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(images != (Image *) NULL);\n  assert(images->signature == MagickCoreSignature);\n  if (images->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",images->filename);\n  display=XOpenDisplay(image_info->server_name);\n  if (display == (Display *) NULL)\n    {\n      (void) ThrowMagickException(&images->exception,GetMagickModule(),\n        XServerError,\"UnableToOpenXServer\",\"`%s'\",XDisplayName(\n        image_info->server_name));\n      return(MagickFalse);\n    }\n  if (images->exception.severity != UndefinedException)\n    CatchException(&images->exception);\n  (void) XSetErrorHandler(XError);\n  resource_database=XGetResourceDatabase(display,GetClientName());\n  (void) memset(&resource_info,0,sizeof(XResourceInfo));\n  XGetResourceInfo(image_info,resource_database,GetClientName(),&resource_info);\n  if (image_info->page != (char *) NULL)\n    resource_info.image_geometry=AcquireString(image_info->page);\n  resource_info.immutable=MagickTrue;\n  argv[0]=AcquireString(GetClientName());\n  (void) XAnimateImages(display,&resource_info,argv,1,images);\n  (void) SetErrorHandler((ErrorHandler) NULL);\n  (void) SetWarningHandler((WarningHandler) NULL);\n  argv[0]=DestroyString(argv[0]);\n  (void) XCloseDisplay(display);\n  XDestroyResourceInfo(&resource_info);\n  status=images->exception.severity == UndefinedException ?\n    MagickTrue : MagickFalse;\n  return(status != 0 ? MagickTrue : MagickFalse);\n}","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":153532,"func":"static int megasas_reset_bus_host(struct scsi_cmnd *scmd)\n{\n\tint ret;\n\tstruct megasas_instance *instance;\n\n\tinstance = (struct megasas_instance *)scmd->device->host->hostdata;\n\n\tscmd_printk(KERN_INFO, scmd,\n\t\t\"Controller reset is requested due to IO timeout\\n\"\n\t\t\"SCSI command pointer: (%p)\\t SCSI host state: %d\\t\"\n\t\t\" SCSI host busy: %d\\t FW outstanding: %d\\n\",\n\t\tscmd, scmd->device->host->shost_state,\n\t\tscsi_host_busy(scmd->device->host),\n\t\tatomic_read(&instance->fw_outstanding));\n\n\t\/*\n\t * First wait for all commands to complete\n\t *\/\n\tif (instance->adapter_type == MFI_SERIES) {\n\t\tret = megasas_generic_reset(scmd);\n\t} else {\n\t\tstruct megasas_cmd_fusion *cmd;\n\t\tcmd = (struct megasas_cmd_fusion *)scmd->SCp.ptr;\n\t\tif (cmd)\n\t\t\tmegasas_dump_frame(cmd->io_request,\n\t\t\t\tMEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE);\n\t\tret = megasas_reset_fusion(scmd->device->host,\n\t\t\t\tSCSIIO_TIMEOUT_OCR);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":272926,"func":"static int UnpackWPGRaster(Image *image,int bpp,ExceptionInfo *exception)\n{\n  int\n    x,\n    y,\n    i;\n\n  unsigned char\n    bbuf,\n    *BImgBuff,\n    RunCount;\n\n  ssize_t\n    ldblk;\n\n  x=0;\n  y=0;\n\n  ldblk=(ssize_t) ((bpp*image->columns+7)\/8);\n  BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk,\n    8*sizeof(*BImgBuff));\n  if(BImgBuff==NULL) return(-2);\n\n  while(y<(ssize_t) image->rows)\n    {\n      int\n        c;\n\n      c=ReadBlobByte(image);\n      if (c == EOF)\n        break;\n      bbuf=(unsigned char) c;\n      RunCount=bbuf & 0x7F;\n      if(bbuf & 0x80)\n        {\n          if(RunCount)  \/* repeat next byte runcount * *\/\n            {\n              bbuf=ReadBlobByte(image);\n              for(i=0;i<(int) RunCount;i++) InsertByte(bbuf);\n            }\n          else {  \/* read next byte as RunCount; repeat 0xFF runcount* *\/\n            c=ReadBlobByte(image);\n            if (c < 0)\n              break;\n            RunCount=(unsigned char) c;\n            for(i=0;i<(int) RunCount;i++) InsertByte(0xFF);\n          }\n        }\n      else {\n        if(RunCount)   \/* next runcount byte are readed directly *\/\n          {\n            for(i=0;i < (int) RunCount;i++)\n              {\n                bbuf=ReadBlobByte(image);\n                InsertByte(bbuf);\n              }\n          }\n        else {  \/* repeat previous line runcount* *\/\n          c=ReadBlobByte(image);\n          if (c < 0)\n            break;\n          RunCount=(unsigned char) c;\n          if(x) {    \/* attempt to duplicate row from x position: *\/\n            \/* I do not know what to do here *\/\n            BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);\n            return(-3);\n          }\n          for(i=0;i < (int) RunCount;i++)\n            {\n              x=0;\n              y++;    \/* Here I need to duplicate previous row RUNCOUNT* *\/\n              if(y<2) continue;\n              if(y>(ssize_t) image->rows)\n                {\n                  BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);\n                  return(-4);\n                }\n              InsertRow(image,BImgBuff,y-1,bpp,exception);\n            }\n        }\n      }\n    }\n  BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);\n  return(y <(ssize_t) image->rows ? -5 : 0);\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":249372,"func":"void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(\n    ProfileSyncService* pss) {\n  if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {\n    pss->RegisterDataTypeController(\n        new ExtensionDataTypeController(syncer::APPS, this, profile_, pss));\n  }\n\n  if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) {\n    pss->RegisterDataTypeController(\n        new ExtensionDataTypeController(syncer::EXTENSIONS,\n                                        this, profile_, pss));\n  }\n\n  if (!command_line_->HasSwitch(switches::kDisableSyncPreferences)) {\n    pss->RegisterDataTypeController(\n        new UIDataTypeController(syncer::PREFERENCES, this, profile_, pss));\n  }\n\n#if defined(ENABLE_THEMES)\n  if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) {\n    pss->RegisterDataTypeController(\n        new ThemeDataTypeController(this, profile_, pss));\n  }\n#endif\n\n  if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) {\n    pss->RegisterDataTypeController(\n        new SearchEngineDataTypeController(this, profile_, pss));\n  }\n\n  if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) {\n    pss->RegisterDataTypeController(\n        new ExtensionSettingDataTypeController(\n            syncer::EXTENSION_SETTINGS, this, profile_, pss));\n  }\n\n  if (!command_line_->HasSwitch(switches::kDisableSyncAppSettings)) {\n    pss->RegisterDataTypeController(\n        new ExtensionSettingDataTypeController(\n            syncer::APP_SETTINGS, this, profile_, pss));\n  }\n \n  chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();\n  if (!command_line_->HasSwitch(switches::kDisableSyncSyncedNotifications)) {\n    if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||\n        channel == chrome::VersionInfo::CHANNEL_CANARY ||\n        channel == chrome::VersionInfo::CHANNEL_DEV) {\n      pss->RegisterDataTypeController(\n          new UIDataTypeController(\n              syncer::SYNCED_NOTIFICATIONS, this, profile_, pss));\n    }\n   }\n \n #if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS)\n  if (!command_line_->HasSwitch(switches::kDisableSyncDictionary)) {\n    pss->RegisterDataTypeController(\n        new UIDataTypeController(syncer::DICTIONARY, this, profile_, pss));\n  }\n#endif\n\n}\n","target":0,"code_token_length":534,"total_token_length":770,"max_tokens_setting":1024}
+{"idx":240139,"func":"static bool need_wrongsec_check(struct svc_rqst *rqstp)\n{\n\tstruct nfsd4_compoundres *resp = rqstp->rq_resp;\n\tstruct nfsd4_compoundargs *argp = rqstp->rq_argp;\n\tstruct nfsd4_op *this = &argp->ops[resp->opcnt - 1];\n\tstruct nfsd4_op *next = &argp->ops[resp->opcnt];\n\tstruct nfsd4_operation *thisd;\n\tstruct nfsd4_operation *nextd;\n\n\tthisd = OPDESC(this);\n\t\/*\n\t * Most ops check wronsec on our own; only the putfh-like ops\n\t * have special rules.\n\t *\/\n\tif (!(thisd->op_flags & OP_IS_PUTFH_LIKE))\n\t\treturn false;\n\t\/*\n\t * rfc 5661 2.6.3.1.1.6: don't bother erroring out a\n\t * put-filehandle operation if we're not going to use the\n\t * result:\n\t *\/\n\tif (argp->opcnt == resp->opcnt)\n\t\treturn false;\n\tif (next->opnum == OP_ILLEGAL)\n\t\treturn false;\n\tnextd = OPDESC(next);\n\t\/*\n\t * Rest of 2.6.3.1.1: certain operations will return WRONGSEC\n\t * errors themselves as necessary; others should check for them\n\t * now:\n\t *\/\n\treturn !(nextd->op_flags & OP_HANDLES_WRONGSEC);\n}\n","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":477579,"func":"static int sixpack_ioctl(struct tty_struct *tty, unsigned int cmd,\n\t\tunsigned long arg)\n{\n\tstruct sixpack *sp = sp_get(tty);\n\tstruct net_device *dev;\n\tunsigned int tmp, err;\n\n\tif (!sp)\n\t\treturn -ENXIO;\n\tdev = sp->dev;\n\n\tswitch(cmd) {\n\tcase SIOCGIFNAME:\n\t\terr = copy_to_user((void __user *) arg, dev->name,\n\t\t                   strlen(dev->name) + 1) ? -EFAULT : 0;\n\t\tbreak;\n\n\tcase SIOCGIFENCAP:\n\t\terr = put_user(0, (int __user *) arg);\n\t\tbreak;\n\n\tcase SIOCSIFENCAP:\n\t\tif (get_user(tmp, (int __user *) arg)) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tsp->mode = tmp;\n\t\tdev->addr_len        = AX25_ADDR_LEN;\n\t\tdev->hard_header_len = AX25_KISS_HEADER_LEN +\n\t\t                       AX25_MAX_HEADER_LEN + 3;\n\t\tdev->type            = ARPHRD_AX25;\n\n\t\terr = 0;\n\t\tbreak;\n\n\tcase SIOCSIFHWADDR: {\n\t\t\tchar addr[AX25_ADDR_LEN];\n\n\t\t\tif (copy_from_user(&addr,\n\t\t\t\t\t   (void __user *)arg, AX25_ADDR_LEN)) {\n\t\t\t\terr = -EFAULT;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tnetif_tx_lock_bh(dev);\n\t\t\t__dev_addr_set(dev, &addr, AX25_ADDR_LEN);\n\t\t\tnetif_tx_unlock_bh(dev);\n\t\t\terr = 0;\n\t\t\tbreak;\n\t\t}\n\tdefault:\n\t\terr = tty_mode_ioctl(tty, cmd, arg);\n\t}\n\n\tsp_put(sp);\n\n\treturn err;\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":490168,"func":"pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)\n{\n\tsc_apdu_t\tapdu;\n\tint\t\tr;\n\n\tLOG_FUNC_CALLED(card->ctx);\n\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, tag >> 8, tag);\n\tapdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;\n\tapdu.resp = buf;\n\tapdu.resplen = buf_len;\n\n\tr = sc_transmit_apdu(card, &apdu);\n\tLOG_TEST_RET(card->ctx, r, \"APDU transmit failed\");\n\n\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\n\t\/* For Gnuk card, if there is no certificate, it returns error instead of empty data.\n\t * So, for this case, we ignore error and consider success *\/\n\tif (r == SC_ERROR_DATA_OBJECT_NOT_FOUND && card->type == SC_CARD_TYPE_OPENPGP_GNUK\n        && (tag == DO_CERT || tag == DO_PRIV1 || tag == DO_PRIV2 || tag == DO_PRIV3 || tag == DO_PRIV4)) {\n\t\tr = SC_SUCCESS;\n\t\tapdu.resplen = 0;\n\t}\n\tLOG_TEST_RET(card->ctx, r, \"Card returned error\");\n\n\tLOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":232652,"func":"void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target,\n    const GLbyte* data, GLuint client_id) {\n  TRACE_EVENT2(\"gpu\", \"GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM\",\n      \"context\", logger_.GetLogPrefix(),\n      \"mailbox[0]\", static_cast<unsigned char>(data[0]));\n  const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);\n  DLOG_IF(ERROR, !mailbox.Verify()) << \"CreateAndConsumeTextureCHROMIUM was \"\n                                       \"passed a mailbox that was not \"\n                                       \"generated by GenMailboxCHROMIUM.\";\n\n  TextureRef* texture_ref = GetTexture(client_id);\n  if (texture_ref) {\n    LOCAL_SET_GL_ERROR(\n        GL_INVALID_OPERATION,\n        \"glCreateAndConsumeTextureCHROMIUM\", \"client id already in use\");\n    return;\n  }\n  Texture* texture = group_->mailbox_manager()->ConsumeTexture(mailbox);\n  if (!texture) {\n    LOCAL_SET_GL_ERROR(\n        GL_INVALID_OPERATION,\n        \"glCreateAndConsumeTextureCHROMIUM\", \"invalid mailbox name\");\n    return;\n  }\n  if (texture->target() != target) {\n    LOCAL_SET_GL_ERROR(\n        GL_INVALID_OPERATION,\n        \"glCreateAndConsumeTextureCHROMIUM\", \"invalid target\");\n    return;\n  }\n\n  texture_ref = texture_manager()->Consume(client_id, texture);\n}\n","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":56766,"func":"static void scalar_min_max_mul(struct bpf_reg_state *dst_reg,\n\t\t\t       struct bpf_reg_state *src_reg)\n{\n\ts64 smin_val = src_reg->smin_value;\n\tu64 umin_val = src_reg->umin_value;\n\tu64 umax_val = src_reg->umax_value;\n\n\tif (smin_val < 0 || dst_reg->smin_value < 0) {\n\t\t\/* Ain't nobody got time to multiply that sign *\/\n\t\t__mark_reg64_unbounded(dst_reg);\n\t\treturn;\n\t}\n\t\/* Both values are positive, so we can work with unsigned and\n\t * copy the result to signed (unless it exceeds S64_MAX).\n\t *\/\n\tif (umax_val > U32_MAX || dst_reg->umax_value > U32_MAX) {\n\t\t\/* Potential overflow, we know nothing *\/\n\t\t__mark_reg64_unbounded(dst_reg);\n\t\treturn;\n\t}\n\tdst_reg->umin_value *= umin_val;\n\tdst_reg->umax_value *= umax_val;\n\tif (dst_reg->umax_value > S64_MAX) {\n\t\t\/* Overflow possible, we know nothing *\/\n\t\tdst_reg->smin_value = S64_MIN;\n\t\tdst_reg->smax_value = S64_MAX;\n\t} else {\n\t\tdst_reg->smin_value = dst_reg->umin_value;\n\t\tdst_reg->smax_value = dst_reg->umax_value;\n\t}\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":111392,"func":"static avifBool avifParseItemPropertiesBox(avifMeta * meta, const uint8_t * raw, size_t rawLen)\n{\n    BEGIN_STREAM(s, raw, rawLen);\n\n    avifBoxHeader ipcoHeader;\n    CHECK(avifROStreamReadBoxHeader(&s, &ipcoHeader));\n    if (memcmp(ipcoHeader.type, \"ipco\", 4) != 0) {\n        return AVIF_FALSE;\n    }\n\n    \/\/ Read all item properties inside of ItemPropertyContainerBox\n    CHECK(avifParseItemPropertyContainerBox(&meta->properties, avifROStreamCurrent(&s), ipcoHeader.size));\n    CHECK(avifROStreamSkip(&s, ipcoHeader.size));\n\n    \/\/ Now read all ItemPropertyAssociation until the end of the box, and make associations\n    while (avifROStreamHasBytesLeft(&s, 1)) {\n        avifBoxHeader ipmaHeader;\n        CHECK(avifROStreamReadBoxHeader(&s, &ipmaHeader));\n\n        if (!memcmp(ipmaHeader.type, \"ipma\", 4)) {\n            CHECK(avifParseItemPropertyAssociation(meta, avifROStreamCurrent(&s), ipmaHeader.size));\n        } else {\n            \/\/ These must all be type ipma\n            return AVIF_FALSE;\n        }\n\n        CHECK(avifROStreamSkip(&s, ipmaHeader.size));\n    }\n    return AVIF_TRUE;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":113220,"func":"static int l2tp_ip_recvmsg(struct sock *sk, struct msghdr *msg,\n\t\t\t   size_t len, int noblock, int flags, int *addr_len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tsize_t copied = 0;\n\tint err = -EOPNOTSUPP;\n\tDECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name);\n\tstruct sk_buff *skb;\n\n\tif (flags & MSG_OOB)\n\t\tgoto out;\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\terr = skb_copy_datagram_msg(skb, 0, msg, copied);\n\tif (err)\n\t\tgoto done;\n\n\tsock_recv_timestamp(msg, sk, skb);\n\n\t\/* Copy the address. *\/\n\tif (sin) {\n\t\tsin->sin_family = AF_INET;\n\t\tsin->sin_addr.s_addr = ip_hdr(skb)->saddr;\n\t\tsin->sin_port = 0;\n\t\tmemset(&sin->sin_zero, 0, sizeof(sin->sin_zero));\n\t\t*addr_len = sizeof(*sin);\n\t}\n\tif (inet->cmsg_flags)\n\t\tip_cmsg_recv(msg, skb);\n\tif (flags & MSG_TRUNC)\n\t\tcopied = skb->len;\ndone:\n\tskb_free_datagram(sk, skb);\nout:\n\treturn err ? err : copied;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":386710,"func":"static gboolean parse_rle_data(TGAContext *ctx, GError **err)\n{\n\tguint rows = 0;\n\tguint count = 0;\n\tguint bytes_done_before = ctx->pbuf_bytes_done;\n\n\tif (ctx->hdr->type == TGA_TYPE_RLE_PSEUDOCOLOR)\n\t\tcount = parse_rle_data_pseudocolor(ctx);\n\telse if (ctx->hdr->type == TGA_TYPE_RLE_TRUECOLOR)\n\t\tcount = parse_rle_data_truecolor(ctx);\n\telse if (ctx->hdr->type == TGA_TYPE_RLE_GRAYSCALE)\n\t\tcount = parse_rle_data_grayscale(ctx);\n\n\tif (ctx->hdr->flags & TGA_ORIGIN_RIGHT) {\n\t\tguchar *row = ctx->pbuf->pixels + (bytes_done_before \/ ctx->pbuf->rowstride) * ctx->pbuf->rowstride;\n\t\tguchar *row_after = ctx->pbuf->pixels + (ctx->pbuf_bytes_done \/ ctx->pbuf->rowstride) * ctx->pbuf->rowstride;\n\t\tfor (; row < row_after; row += ctx->pbuf->rowstride)\n\t\t\tpixbuf_flip_row (ctx->pbuf, row);\n\t}\n\n\tctx->in = io_buffer_free_segment(ctx->in, count, err);\n\tif (!ctx->in)\n\t\treturn FALSE;\n\n\tif (ctx->done) {\n\t\t\/* FIXME doing the vertical flipping afterwards is not\n\t\t * perfect, but doing it during the rle decoding in place\n\t\t * is considerably more work. \n\t\t *\/\n\t\tif (!(ctx->hdr->flags & TGA_ORIGIN_UPPER)) {\n\t\t\tpixbuf_flip_vertically (ctx->pbuf);\n\t\t\tctx->hdr->flags |= TGA_ORIGIN_UPPER;\n\t\t}\n\n\t}\n\t\t\n\trows = ctx->pbuf_bytes_done \/ ctx->pbuf->rowstride - bytes_done_before \/ ctx->pbuf->rowstride;\n\tif (ctx->ufunc)\n\t\t(*ctx->ufunc) (ctx->pbuf, 0, bytes_done_before \/ ctx->pbuf->rowstride,\n\t\t\t       ctx->pbuf->width, rows,\n\t\t\t       ctx->udata);\n\n\treturn TRUE;\n}","target":0,"code_token_length":456,"total_token_length":692,"max_tokens_setting":1024}
+{"idx":5758,"func":"static int kvm_ioctl_create_device(struct kvm *kvm,\n\t\t\t\t   struct kvm_create_device *cd)\n{\n\tstruct kvm_device_ops *ops = NULL;\n\tstruct kvm_device *dev;\n\tbool test = cd->flags & KVM_CREATE_DEVICE_TEST;\n\tint ret;\n\n\tif (cd->type >= ARRAY_SIZE(kvm_device_ops_table))\n\t\treturn -ENODEV;\n\n\tops = kvm_device_ops_table[cd->type];\n\tif (ops == NULL)\n\t\treturn -ENODEV;\n\n\tif (test)\n\t\treturn 0;\n\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev)\n\t\treturn -ENOMEM;\n\n\tdev->ops = ops;\n\tdev->kvm = kvm;\n\n\tmutex_lock(&kvm->lock);\n\tret = ops->create(dev, cd->type);\n\tif (ret < 0) {\n\t\tmutex_unlock(&kvm->lock);\n\t\tkfree(dev);\n\t\treturn ret;\n\t}\n\tlist_add(&dev->vm_node, &kvm->devices);\n\tmutex_unlock(&kvm->lock);\n\n\tif (ops->init)\n\t\tops->init(dev);\n\n\tret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);\n\tif (ret < 0) {\n\t\tmutex_lock(&kvm->lock);\n\t\tlist_del(&dev->vm_node);\n\t\tmutex_unlock(&kvm->lock);\n\t\tops->destroy(dev);\n\t\treturn ret;\n\t}\n\n\tkvm_get_kvm(kvm);\n\tcd->fd = ret;\n\treturn 0;\n}","target":1,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":43704,"func":"void PrintGeneralUsage()\n{\n\tu32 i=0;\n\tgf_sys_format_help(helpout, help_flags, \"# General Options\\n\"\n\t\t\"MP4Box is a multimedia packager, with a vast number of functionalities: conversion, splitting, hinting, dumping, DASH-ing, encryption, transcoding and others.\\n\"\n\t\t\"MP4Box provides a large set of options, classified by categories (see [-h]()). These options do not follow any particular ordering.\\n\"\n\t\t\"  \\n\"\n\t\t\"By default, MP4Box rewrites the input file. You can change this behavior by using the [-out]() option.\\n\"\n\t\t\"MP4Box stores by default the file with 0.5 second interleaving and meta-data (`moov` ...) at the beginning, making it suitable for HTTP download-and-play. This may however takes longer to store the file, use [-flat]() to change this behavior.\\n\"\n\t\t\"  \\n\"\n\t\t\"MP4Box usually generates a temporary file when creating a new IsoMedia file. The location of this temporary file is OS-dependent, and it may happen that the drive\/partition the temporary file is created on has not enough space or no write access. In such a case, you can specify a temporary file location with [-tmp]().\\n\"\n\t\t\"  \\n\"\n\t\t\"Option values:\\n\"\n\t\t\"Unless specified otherwise, an option of type `integer` expects a trackID value following it.\"\n\t\t\"An option of type `boolean` expects no following value.\"\n\t\t\"Note: Track operations identify tracks through their ID (usually referred to as tkID in the help), not their order.\\n\"\n\t\t\"  \\n\"\n\t);\n\n\n\twhile (m4b_gen_args[i].name) {\n\t\tGF_GPACArg *arg = (GF_GPACArg *) &m4b_gen_args[i];\n\t\ti++;\n\t\tgf_sys_print_arg(helpout, help_flags, arg, \"mp4box-gen\");\n\t}\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":50801,"func":"QPDFWriter::writeStandard()\n{\n    if (this->deterministic_id)\n    {\n        pushMD5Pipeline();\n    }\n\n    \/\/ Start writing\n\n    writeHeader();\n    writeString(this->extra_header_text);\n\n    if (this->preserve_unreferenced_objects)\n    {\n        QTC::TC(\"qpdf\", \"QPDFWriter preserve unreferenced standard\");\n        std::vector<QPDFObjectHandle> all = this->pdf.getAllObjects();\n        for (std::vector<QPDFObjectHandle>::iterator iter = all.begin();\n             iter != all.end(); ++iter)\n        {\n            enqueueObject(*iter);\n        }\n    }\n\n    \/\/ Put root first on queue.\n    QPDFObjectHandle trailer = getTrimmedTrailer();\n    enqueueObject(trailer.getKey(\"\/Root\"));\n\n    \/\/ Next place any other objects referenced from the trailer\n    \/\/ dictionary into the queue, handling direct objects recursively.\n    \/\/ Root is already there, so enqueuing it a second time is a\n    \/\/ no-op.\n    std::set<std::string> keys = trailer.getKeys();\n    for (std::set<std::string>::iterator iter = keys.begin();\n\t iter != keys.end(); ++iter)\n    {\n\tenqueueObject(trailer.getKey(*iter));\n    }\n\n    \/\/ Now start walking queue, output each object\n    while (this->object_queue.size())\n    {\n\tQPDFObjectHandle cur_object = this->object_queue.front();\n\tthis->object_queue.pop_front();\n\twriteObject(cur_object);\n    }\n\n    \/\/ Write out the encryption dictionary, if any\n    if (this->encrypted)\n    {\n\twriteEncryptionDictionary();\n    }\n\n    \/\/ Now write out xref.  next_objid is now the number of objects.\n    qpdf_offset_t xref_offset = this->pipeline->getCount();\n    if (this->object_stream_to_objects.empty())\n    {\n\t\/\/ Write regular cross-reference table\n\twriteXRefTable(t_normal, 0, this->next_objid - 1, this->next_objid);\n    }\n    else\n    {\n\t\/\/ Write cross-reference stream.\n\tint xref_id = this->next_objid++;\n\twriteXRefStream(xref_id, xref_id, xref_offset, t_normal,\n\t\t\t0, this->next_objid - 1, this->next_objid);\n    }\n    writeString(\"startxref\\n\");\n    writeString(QUtil::int_to_string(xref_offset));\n    writeString(\"\\n%%EOF\\n\");\n\n    if (this->deterministic_id)\n    {\n\tQTC::TC(\"qpdf\", \"QPDFWriter standard deterministic ID\",\n                this->object_stream_to_objects.empty() ? 0 : 1);\n        popPipelineStack();\n        assert(this->md5_pipeline == 0);\n    }\n}","target":0,"code_token_length":577,"total_token_length":813,"max_tokens_setting":1024}
+{"idx":381894,"func":"ExecGetTriggerResultRel(EState *estate, Oid relid)\n{\n\tResultRelInfo *rInfo;\n\tint\t\t\tnr;\n\tListCell   *l;\n\tRelation\trel;\n\tMemoryContext oldcontext;\n\n\t\/* First, search through the query result relations *\/\n\trInfo = estate->es_result_relations;\n\tnr = estate->es_num_result_relations;\n\twhile (nr > 0)\n\t{\n\t\tif (RelationGetRelid(rInfo->ri_RelationDesc) == relid)\n\t\t\treturn rInfo;\n\t\trInfo++;\n\t\tnr--;\n\t}\n\t\/* Nope, but maybe we already made an extra ResultRelInfo for it *\/\n\tforeach(l, estate->es_trig_target_relations)\n\t{\n\t\trInfo = (ResultRelInfo *) lfirst(l);\n\t\tif (RelationGetRelid(rInfo->ri_RelationDesc) == relid)\n\t\t\treturn rInfo;\n\t}\n\t\/* Nope, so we need a new one *\/\n\n\t\/*\n\t * Open the target relation's relcache entry.  We assume that an\n\t * appropriate lock is still held by the backend from whenever the trigger\n\t * event got queued, so we need take no new lock here.  Also, we need not\n\t * recheck the relkind, so no need for CheckValidResultRel.\n\t *\/\n\trel = heap_open(relid, NoLock);\n\n\t\/*\n\t * Make the new entry in the right context.\n\t *\/\n\toldcontext = MemoryContextSwitchTo(estate->es_query_cxt);\n\trInfo = makeNode(ResultRelInfo);\n\tInitResultRelInfo(rInfo,\n\t\t\t\t\t  rel,\n\t\t\t\t\t  0,\t\t\/* dummy rangetable index *\/\n\t\t\t\t\t  estate->es_instrument);\n\testate->es_trig_target_relations =\n\t\tlappend(estate->es_trig_target_relations, rInfo);\n\tMemoryContextSwitchTo(oldcontext);\n\n\t\/*\n\t * Currently, we don't need any index information in ResultRelInfos used\n\t * only for triggers, so no need to call ExecOpenIndices.\n\t *\/\n\n\treturn rInfo;\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":357532,"func":"bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)\n{\n\tstruct request_queue *q = bd->queue;\n\tstruct request *rq, *next_rq = NULL;\n\tint ret, rw;\n\tunsigned int dxfer_len;\n\tvoid *dxferp = NULL;\n\n\tdprintk(\"map hdr %llx\/%u %llx\/%u\\n\", (unsigned long long) hdr->dout_xferp,\n\t\thdr->dout_xfer_len, (unsigned long long) hdr->din_xferp,\n\t\thdr->din_xfer_len);\n\n\tret = bsg_validate_sgv4_hdr(q, hdr, &rw);\n\tif (ret)\n\t\treturn ERR_PTR(ret);\n\n\t\/*\n\t * map scatter-gather elements seperately and string them to request\n\t *\/\n\trq = blk_get_request(q, rw, GFP_KERNEL);\n\tif (!rq)\n\t\treturn ERR_PTR(-ENOMEM);\n\tret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm);\n\tif (ret)\n\t\tgoto out;\n\n\tif (rw == WRITE && hdr->din_xfer_len) {\n\t\tif (!test_bit(QUEUE_FLAG_BIDI, &q->queue_flags)) {\n\t\t\tret = -EOPNOTSUPP;\n\t\t\tgoto out;\n\t\t}\n\n\t\tnext_rq = blk_get_request(q, READ, GFP_KERNEL);\n\t\tif (!next_rq) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t\trq->next_rq = next_rq;\n\t\tnext_rq->cmd_type = rq->cmd_type;\n\n\t\tdxferp = (void*)(unsigned long)hdr->din_xferp;\n\t\tret =  blk_rq_map_user(q, next_rq, NULL, dxferp,\n\t\t\t\t       hdr->din_xfer_len, GFP_KERNEL);\n\t\tif (ret)\n\t\t\tgoto out;\n\t}\n\n\tif (hdr->dout_xfer_len) {\n\t\tdxfer_len = hdr->dout_xfer_len;\n\t\tdxferp = (void*)(unsigned long)hdr->dout_xferp;\n\t} else if (hdr->din_xfer_len) {\n\t\tdxfer_len = hdr->din_xfer_len;\n\t\tdxferp = (void*)(unsigned long)hdr->din_xferp;\n\t} else\n\t\tdxfer_len = 0;\n\n\tif (dxfer_len) {\n\t\tret = blk_rq_map_user(q, rq, NULL, dxferp, dxfer_len,\n\t\t\t\t      GFP_KERNEL);\n\t\tif (ret)\n\t\t\tgoto out;\n\t}\n\treturn rq;\nout:\n\tif (rq->cmd != rq->__cmd)\n\t\tkfree(rq->cmd);\n\tblk_put_request(rq);\n\tif (next_rq) {\n\t\tblk_rq_unmap_user(next_rq->bio);\n\t\tblk_put_request(next_rq);\n\t}\n\treturn ERR_PTR(ret);\n}","target":0,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":65559,"func":"static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)\n{\n\tstruct ipxhdr *ipx = ipx_hdr(skb);\n\tint rc = 0;\n\n\tipxitf_hold(intrfc);\n\n\t\/* See if we should update our network number *\/\n\tif (!intrfc->if_netnum) \/* net number of intrfc not known yet *\/\n\t\tipxitf_discover_netnum(intrfc, skb);\n\n\tIPX_SKB_CB(skb)->last_hop.index = -1;\n\tif (ipx->ipx_type == IPX_TYPE_PPROP) {\n\t\trc = ipxitf_pprop(intrfc, skb);\n\t\tif (rc)\n\t\t\tgoto out_free_skb;\n\t}\n\n\t\/* local processing follows *\/\n\tif (!IPX_SKB_CB(skb)->ipx_dest_net)\n\t\tIPX_SKB_CB(skb)->ipx_dest_net = intrfc->if_netnum;\n\tif (!IPX_SKB_CB(skb)->ipx_source_net)\n\t\tIPX_SKB_CB(skb)->ipx_source_net = intrfc->if_netnum;\n\n\t\/* it doesn't make sense to route a pprop packet, there's no meaning\n\t * in the ipx_dest_net for such packets *\/\n\tif (ipx->ipx_type != IPX_TYPE_PPROP &&\n\t    intrfc->if_netnum != IPX_SKB_CB(skb)->ipx_dest_net) {\n\t\t\/* We only route point-to-point packets. *\/\n\t\tif (skb->pkt_type == PACKET_HOST) {\n\t\t\tskb = skb_unshare(skb, GFP_ATOMIC);\n\t\t\tif (skb)\n\t\t\t\trc = ipxrtr_route_skb(skb);\n\t\t\tgoto out_intrfc;\n\t\t}\n\n\t\tgoto out_free_skb;\n\t}\n\n\t\/* see if we should keep it *\/\n\tif (!memcmp(ipx_broadcast_node, ipx->ipx_dest.node, IPX_NODE_LEN) ||\n\t    !memcmp(intrfc->if_node, ipx->ipx_dest.node, IPX_NODE_LEN)) {\n\t\trc = ipxitf_demux_socket(intrfc, skb, 0);\n\t\tgoto out_intrfc;\n\t}\n\n\t\/* we couldn't pawn it off so unload it *\/\nout_free_skb:\n\tkfree_skb(skb);\nout_intrfc:\n\tipxitf_put(intrfc);\n\treturn rc;\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":322763,"func":"static void create_cps(MaltaState *s, const char *cpu_model,\n\n                       qemu_irq *cbus_irq, qemu_irq *i8259_irq)\n\n{\n\n    Error *err = NULL;\n\n    s->cps = g_new0(MIPSCPSState, 1);\n\n\n\n    object_initialize(s->cps, sizeof(MIPSCPSState), TYPE_MIPS_CPS);\n\n    qdev_set_parent_bus(DEVICE(s->cps), sysbus_get_default());\n\n\n\n    object_property_set_str(OBJECT(s->cps), cpu_model, \"cpu-model\", &err);\n\n    object_property_set_int(OBJECT(s->cps), smp_cpus, \"num-vp\", &err);\n\n    object_property_set_bool(OBJECT(s->cps), true, \"realized\", &err);\n\n    if (err != NULL) {\n\n        error_report(\"%s\", error_get_pretty(err));\n\n        exit(1);\n\n    }\n\n\n\n    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->cps), 0, 0, 1);\n\n\n\n    \/* FIXME: When GIC is present then we should use GIC's IRQ 3.\n\n       Until then CPS exposes CPU's IRQs thus use the default IRQ 2. *\/\n\n    *i8259_irq = get_cps_irq(s->cps, 2);\n\n    *cbus_irq = NULL;\n\n}\n","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":345544,"func":"get_one_option(int optid, const struct my_option *opt,\n               char *argument)\n{\n  my_bool add_option= TRUE;\n\n  switch (optid) {\n\n  case '?':\n    printf(\"%s  Ver %s Distrib %s, for %s (%s)\\n\",\n           my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);\n    puts(ORACLE_WELCOME_COPYRIGHT_NOTICE(\"2000\"));\n    puts(\"MySQL utility for upgrading databases to new MySQL versions.\\n\");\n    my_print_help(my_long_options);\n    exit(0);\n    break;\n\n  case '#':\n    DBUG_PUSH(argument ? argument : default_dbug_option);\n    add_option= FALSE;\n    debug_check_flag= 1;\n    break;\n\n  case 'p':\n    if (argument == disabled_my_option)\n      argument= (char*) \"\";\t\t\t\/* Don't require password *\/\n    tty_password= 1;\n    add_option= FALSE;\n    if (argument)\n    {\n      \/* Add password to ds_args before overwriting the arg with x's *\/\n      add_one_option(&ds_args, opt, argument);\n      while (*argument)\n        *argument++= 'x';                       \/* Destroy argument *\/\n      tty_password= 0;\n    }\n    break;\n\n  case 't':\n    strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir));\n    add_option= FALSE;\n    break;\n\n  case 'b': \/* --basedir   *\/\n  case 'd': \/* --datadir   *\/\n    fprintf(stderr, \"%s: the '--%s' option is always ignored\\n\",\n            my_progname, optid == 'b' ? \"basedir\" : \"datadir\");\n    \/* FALLTHROUGH *\/\n\n  case 'k':                                     \/* --version-check *\/\n  case 'v': \/* --verbose   *\/\n  case 'f': \/* --force     *\/\n  case 's':                                     \/* --upgrade-system-tables *\/\n  case OPT_WRITE_BINLOG:                        \/* --write-binlog *\/\n    add_option= FALSE;\n    break;\n\n  case 'h': \/* --host *\/\n  case 'W': \/* --pipe *\/\n  case 'P': \/* --port *\/\n  case 'S': \/* --socket *\/\n  case OPT_MYSQL_PROTOCOL: \/* --protocol *\/\n  case OPT_SHARED_MEMORY_BASE_NAME: \/* --shared-memory-base-name *\/\n  case OPT_PLUGIN_DIR:                          \/* --plugin-dir *\/\n  case OPT_DEFAULT_AUTH:                        \/* --default-auth *\/\n    add_one_option(&conn_args, opt, argument);\n    break;\n  }\n\n  if (add_option)\n  {\n    \/*\n      This is an option that is accpted by mysql_upgrade just so\n      it can be passed on to \"mysql\" and \"mysqlcheck\"\n      Save it in the ds_args string\n    *\/\n    add_one_option(&ds_args, opt, argument);\n  }\n  return 0;\n}","target":1,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":173007,"func":"IHEVCD_ERROR_T ihevcd_get_tile_pos(pps_t *ps_pps,\n sps_t *ps_sps,\n                                   WORD32 ctb_x,\n                                   WORD32 ctb_y,\n                                   WORD32 *pi4_ctb_tile_x,\n                                   WORD32 *pi4_ctb_tile_y,\n                                   WORD32 *pi4_tile_idx)\n{\n\n tile_t *ps_tile_tmp;\n    WORD32 i;\n    WORD32 tile_row, tile_col;\n\n if(ctb_x < 0 || ctb_y < 0)\n {\n *pi4_ctb_tile_x = 0;\n *pi4_ctb_tile_y = 0;\n *pi4_tile_idx = 0;\n\n return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;\n }\n\n    tile_row = 0;\n    tile_col = 0;\n    ps_tile_tmp = ps_pps->ps_tile;\n if(0 == ps_pps->i1_tiles_enabled_flag)\n {\n *pi4_ctb_tile_x = ctb_x;\n *pi4_ctb_tile_y = ctb_y;\n *pi4_tile_idx = 0;\n }\n else\n {\n for(i = 0; i < ps_pps->i1_num_tile_columns; i++)\n {\n            WORD16 next_tile_ctb_x;\n            ps_tile_tmp = ps_pps->ps_tile + i; \/\/* ps_pps->i1_num_tile_rows;\n if((ps_pps->i1_num_tile_columns - 1) == i)\n {\n                next_tile_ctb_x = ps_sps->i2_pic_wd_in_ctb;\n }\n else\n {\n tile_t *ps_tile_next_tmp;\n                ps_tile_next_tmp = ps_pps->ps_tile + i + 1;\n                next_tile_ctb_x = ps_tile_next_tmp->u1_pos_x;\n }\n if((ctb_x >= ps_tile_tmp->u1_pos_x) && (ctb_x < next_tile_ctb_x))\n {\n                tile_col = i;\n break;\n }\n }\n *pi4_ctb_tile_x = ctb_x - ps_tile_tmp->u1_pos_x;\n\n for(i = 0; i < ps_pps->i1_num_tile_rows; i++)\n {\n            WORD16 next_tile_ctb_y;\n            ps_tile_tmp = ps_pps->ps_tile + i * ps_pps->i1_num_tile_columns;\n if((ps_pps->i1_num_tile_rows - 1) == i)\n {\n                next_tile_ctb_y = ps_sps->i2_pic_ht_in_ctb;\n }\n else\n {\n tile_t *ps_tile_next_tmp;\n                ps_tile_next_tmp = ps_pps->ps_tile + ((i + 1) * ps_pps->i1_num_tile_columns);\n                next_tile_ctb_y = ps_tile_next_tmp->u1_pos_y;\n }\n if((ctb_y >= ps_tile_tmp->u1_pos_y) && (ctb_y < next_tile_ctb_y))\n {\n                tile_row = i;\n break;\n }\n\n }\n *pi4_ctb_tile_y = ctb_y - ps_tile_tmp->u1_pos_y;\n *pi4_tile_idx = tile_row * ps_pps->i1_num_tile_columns\n + tile_col;\n }\n return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;\n}\n","target":0,"code_token_length":697,"total_token_length":933,"max_tokens_setting":1024}
+{"idx":494831,"func":"  v8::Local<v8::Promise> ExecuteJavaScriptInIsolatedWorld(\n      gin::Arguments* gin_args,\n      int world_id,\n      const std::vector<gin_helper::Dictionary>& scripts) {\n    gin_helper::Arguments* args = static_cast<gin_helper::Arguments*>(gin_args);\n\n    v8::Isolate* isolate = args->isolate();\n    gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);\n    v8::Local<v8::Promise> handle = promise.GetHandle();\n\n    content::RenderFrame* render_frame;\n    std::string error_msg;\n    if (!MaybeGetRenderFrame(&error_msg, \"executeJavaScriptInIsolatedWorld\",\n                             &render_frame)) {\n      promise.RejectWithErrorMessage(error_msg);\n      return handle;\n    }\n\n    bool has_user_gesture = false;\n    args->GetNext(&has_user_gesture);\n\n    blink::WebLocalFrame::ScriptExecutionType scriptExecutionType =\n        blink::WebLocalFrame::kSynchronous;\n    args->GetNext(&scriptExecutionType);\n\n    ScriptExecutionCallback::CompletionCallback completion_callback;\n    args->GetNext(&completion_callback);\n\n    std::vector<blink::WebScriptSource> sources;\n    sources.reserve(scripts.size());\n\n    for (const auto& script : scripts) {\n      std::u16string code;\n      std::u16string url;\n      int start_line = 1;\n      script.Get(\"url\", &url);\n      script.Get(\"startLine\", &start_line);\n\n      if (!script.Get(\"code\", &code)) {\n        const char error_message[] = \"Invalid 'code'\";\n        if (!completion_callback.is_null()) {\n          std::move(completion_callback)\n              .Run(v8::Undefined(isolate),\n                   v8::Exception::Error(\n                       v8::String::NewFromUtf8(isolate, error_message)\n                           .ToLocalChecked()));\n        }\n        promise.RejectWithErrorMessage(error_message);\n        return handle;\n      }\n\n      sources.emplace_back(blink::WebString::FromUTF16(code),\n                           blink::WebURL(GURL(url)), start_line);\n    }\n\n    render_frame->GetWebFrame()->RequestExecuteScript(\n        world_id, base::make_span(sources), has_user_gesture,\n        scriptExecutionType,\n        new ScriptExecutionCallback(std::move(promise),\n                                    std::move(completion_callback)),\n        blink::BackForwardCacheAware::kPossiblyDisallow);\n\n    return handle;\n  }","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":154390,"func":"void CLASS sinar_4shot_load_raw()\n{\n  ushort *pixel;\n  unsigned shot, row, col, r, c;\n\n  if (raw_image)\n  {\n    shot = LIM(shot_select, 1, 4) - 1;\n    fseek(ifp, data_offset + shot * 4, SEEK_SET);\n    fseek(ifp, get4(), SEEK_SET);\n    unpacked_load_raw();\n    return;\n  }\n  pixel = (ushort *)calloc(raw_width, sizeof *pixel);\n  merror(pixel, \"sinar_4shot_load_raw()\");\n#ifdef LIBRAW_LIBRARY_BUILD\n  try\n  {\n#endif\n    for (shot = 0; shot < 4; shot++)\n    {\n#ifdef LIBRAW_LIBRARY_BUILD\n      checkCancel();\n#endif\n      fseek(ifp, data_offset + shot * 4, SEEK_SET);\n      fseek(ifp, get4(), SEEK_SET);\n      for (row = 0; row < raw_height; row++)\n      {\n        read_shorts(pixel, raw_width);\n        if ((r = row - top_margin - (shot >> 1 & 1)) >= height)\n          continue;\n        for (col = 0; col < raw_width; col++)\n        {\n          if ((c = col - left_margin - (shot & 1)) >= width)\n            continue;\n          image[r * width + c][(row & 1) * 3 ^ (~col & 1)] = pixel[col];\n        }\n      }\n    }\n#ifdef LIBRAW_LIBRARY_BUILD\n  }\n  catch (...)\n  {\n    free(pixel);\n    throw;\n  }\n#endif\n  free(pixel);\n  mix_green = 1;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":62038,"func":"static BOOL autodetect_recv_bandwidth_measure_results(rdpRdp* rdp, wStream* s,\n                                                      AUTODETECT_RSP_PDU* autodetectRspPdu)\n{\n\tBOOL success = TRUE;\n\n\tif (autodetectRspPdu->headerLength != 0x0E)\n\t\treturn FALSE;\n\n\tWLog_VRB(AUTODETECT_TAG, \"received Bandwidth Measure Results PDU\");\n\tif (Stream_GetRemainingLength(s) < 8)\n\t\treturn -1;\n\tStream_Read_UINT32(s, rdp->autodetect->bandwidthMeasureTimeDelta); \/* timeDelta (4 bytes) *\/\n\tStream_Read_UINT32(s, rdp->autodetect->bandwidthMeasureByteCount); \/* byteCount (4 bytes) *\/\n\n\tif (rdp->autodetect->bandwidthMeasureTimeDelta > 0)\n\t\trdp->autodetect->netCharBandwidth = rdp->autodetect->bandwidthMeasureByteCount * 8 \/\n\t\t                                    rdp->autodetect->bandwidthMeasureTimeDelta;\n\telse\n\t\trdp->autodetect->netCharBandwidth = 0;\n\n\tIFCALLRET(rdp->autodetect->BandwidthMeasureResults, success, rdp->context,\n\t          autodetectRspPdu->sequenceNumber);\n\treturn success;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":53776,"func":"pj_status_t pj_ssl_sock_ossl_test_send_buf(pj_pool_t *pool)\n{\n    enum { MAX_CHUNK_NUM = 20 };\n    unsigned chunk_size, chunk_cnt, i;\n    write_data_t *wdata[MAX_CHUNK_NUM] = {0};\n    pj_time_val now;\n    pj_ssl_sock_t *ssock = NULL;\n    pj_ssl_sock_param param;\n    pj_status_t status;\n\n    pj_gettimeofday(&now);\n    pj_srand((unsigned)now.sec);\n\n    pj_ssl_sock_param_default(¶m);\n    status = pj_ssl_sock_create(pool, ¶m, &ssock);\n    if (status != PJ_SUCCESS) {\n\treturn status;\n    }\n\n    if (ssock->send_buf.max_len == 0) {\n\tssock->send_buf.buf = (char*)\n\t\t\t      pj_pool_alloc(ssock->pool, \n\t\t\t\t\t    ssock->param.send_buffer_size);\n\tssock->send_buf.max_len = ssock->param.send_buffer_size;\n\tssock->send_buf.start = ssock->send_buf.buf;\n\tssock->send_buf.len = 0;\n    }\n\n    chunk_size = ssock->param.send_buffer_size \/ MAX_CHUNK_NUM \/ 2;\n    chunk_cnt = 0;\n    for (i = 0; i < MAX_CHUNK_NUM; i++) {\n\twdata[i] = alloc_send_data(ssock, pj_rand() % chunk_size + 321);\n\tif (wdata[i])\n\t    chunk_cnt++;\n\telse\n\t    break;\n    }\n\n    while (chunk_cnt) {\n\ti = pj_rand() % MAX_CHUNK_NUM;\n\tif (wdata[i]) {\n\t    free_send_data(ssock, wdata[i]);\n\t    wdata[i] = NULL;\n\t    chunk_cnt--;\n\t}\n    }\n\n    if (ssock->send_buf.len != 0)\n\tstatus = PJ_EBUG;\n\n    pj_ssl_sock_close(ssock);\n    return status;\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":14895,"func":"vpx_codec_err_t vp9_parse_superframe_index ( const uint8_t * data , size_t data_sz , uint32_t sizes [ 8 ] , int * count , vpx_decrypt_cb decrypt_cb , void * decrypt_state ) {\n uint8_t marker ;\n assert ( data_sz ) ;\n marker = read_marker ( decrypt_cb , decrypt_state , data + data_sz - 1 ) ;\n * count = 0 ;\n if ( ( marker & 0xe0 ) == 0xc0 ) {\n const uint32_t frames = ( marker & 0x7 ) + 1 ;\n const uint32_t mag = ( ( marker >> 3 ) & 0x3 ) + 1 ;\n const size_t index_sz = 2 + mag * frames ;\n if ( data_sz < index_sz ) return VPX_CODEC_CORRUPT_FRAME ;\n {\n const uint8_t marker2 = read_marker ( decrypt_cb , decrypt_state , data + data_sz - index_sz ) ;\n if ( marker != marker2 ) return VPX_CODEC_CORRUPT_FRAME ;\n }\n {\n uint32_t i , j ;\n const uint8_t * x = & data [ data_sz - index_sz + 1 ] ;\n uint8_t clear_buffer [ 32 ] ;\n assert ( sizeof ( clear_buffer ) >= frames * mag ) ;\n if ( decrypt_cb ) {\n decrypt_cb ( decrypt_state , x , clear_buffer , frames * mag ) ;\n x = clear_buffer ;\n }\n for ( i = 0 ;\n i < frames ;\n ++ i ) {\n uint32_t this_sz = 0 ;\n for ( j = 0 ;\n j < mag ;\n ++ j ) this_sz |= ( * x ++ ) << ( j * 8 ) ;\n sizes [ i ] = this_sz ;\n }\n * count = frames ;\n }\n }\n return VPX_CODEC_OK ;\n }","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":456371,"func":"int search_binary_handler(struct linux_binprm *bprm)\n{\n\tbool need_retry = IS_ENABLED(CONFIG_MODULES);\n\tstruct linux_binfmt *fmt;\n\tint retval;\n\n\t\/* This allows 4 levels of binfmt rewrites before failing hard. *\/\n\tif (bprm->recursion_depth > 5)\n\t\treturn -ELOOP;\n\n\tretval = security_bprm_check(bprm);\n\tif (retval)\n\t\treturn retval;\n\n\tretval = -ENOENT;\n retry:\n\tread_lock(&binfmt_lock);\n\tlist_for_each_entry(fmt, &formats, lh) {\n\t\tif (!try_module_get(fmt->module))\n\t\t\tcontinue;\n\t\tread_unlock(&binfmt_lock);\n\n\t\tbprm->recursion_depth++;\n\t\tretval = fmt->load_binary(bprm);\n\t\tbprm->recursion_depth--;\n\n\t\tread_lock(&binfmt_lock);\n\t\tput_binfmt(fmt);\n\t\tif (retval < 0 && !bprm->mm) {\n\t\t\t\/* we got to flush_old_exec() and failed after it *\/\n\t\t\tread_unlock(&binfmt_lock);\n\t\t\tforce_sigsegv(SIGSEGV);\n\t\t\treturn retval;\n\t\t}\n\t\tif (retval != -ENOEXEC || !bprm->file) {\n\t\t\tread_unlock(&binfmt_lock);\n\t\t\treturn retval;\n\t\t}\n\t}\n\tread_unlock(&binfmt_lock);\n\n\tif (need_retry) {\n\t\tif (printable(bprm->buf[0]) && printable(bprm->buf[1]) &&\n\t\t    printable(bprm->buf[2]) && printable(bprm->buf[3]))\n\t\t\treturn retval;\n\t\tif (request_module(\"binfmt-%04x\", *(ushort *)(bprm->buf + 2)) < 0)\n\t\t\treturn retval;\n\t\tneed_retry = false;\n\t\tgoto retry;\n\t}\n\n\treturn retval;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":436443,"func":"static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp,\n\tu8 feature_index, u8 char_index, char *device_name, int len_buf)\n{\n\tstruct hidpp_report response;\n\tint ret, i;\n\tint count;\n\n\tret = hidpp_send_fap_command_sync(hidpp, feature_index,\n\t\tCMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME, &char_index, 1,\n\t\t&response);\n\n\tif (ret > 0) {\n\t\thid_err(hidpp->hid_dev, \"%s: received protocol error 0x%02x\\n\",\n\t\t\t__func__, ret);\n\t\treturn -EPROTO;\n\t}\n\tif (ret)\n\t\treturn ret;\n\n\tswitch (response.report_id) {\n\tcase REPORT_ID_HIDPP_VERY_LONG:\n\t\tcount = hidpp->very_long_report_length - 4;\n\t\tbreak;\n\tcase REPORT_ID_HIDPP_LONG:\n\t\tcount = HIDPP_REPORT_LONG_LENGTH - 4;\n\t\tbreak;\n\tcase REPORT_ID_HIDPP_SHORT:\n\t\tcount = HIDPP_REPORT_SHORT_LENGTH - 4;\n\t\tbreak;\n\tdefault:\n\t\treturn -EPROTO;\n\t}\n\n\tif (len_buf < count)\n\t\tcount = len_buf;\n\n\tfor (i = 0; i < count; i++)\n\t\tdevice_name[i] = response.fap.params[i];\n\n\treturn count;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":342478,"func":"static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s)\n\n{\n\n    CURLState *state = NULL;\n\n    int i, j;\n\n\n\n    do {\n\n        for (i=0; i<CURL_NUM_STATES; i++) {\n\n            for (j=0; j<CURL_NUM_ACB; j++)\n\n                if (s->states[i].acb[j])\n\n                    continue;\n\n            if (s->states[i].in_use)\n\n                continue;\n\n\n\n            state = &s->states[i];\n\n            state->in_use = 1;\n\n            break;\n\n        }\n\n        if (!state) {\n\n            qemu_mutex_unlock(&s->mutex);\n\n            aio_poll(bdrv_get_aio_context(bs), true);\n\n            qemu_mutex_lock(&s->mutex);\n\n        }\n\n    } while(!state);\n\n\n\n    if (!state->curl) {\n\n        state->curl = curl_easy_init();\n\n        if (!state->curl) {\n\n            return NULL;\n\n        }\n\n        curl_easy_setopt(state->curl, CURLOPT_URL, s->url);\n\n        curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,\n\n                         (long) s->sslverify);\n\n        if (s->cookie) {\n\n            curl_easy_setopt(state->curl, CURLOPT_COOKIE, s->cookie);\n\n        }\n\n        curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, (long)s->timeout);\n\n        curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,\n\n                         (void *)curl_read_cb);\n\n        curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);\n\n        curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);\n\n        curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);\n\n        curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);\n\n        curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);\n\n        curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);\n\n        curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);\n\n\n\n        if (s->username) {\n\n            curl_easy_setopt(state->curl, CURLOPT_USERNAME, s->username);\n\n        }\n\n        if (s->password) {\n\n            curl_easy_setopt(state->curl, CURLOPT_PASSWORD, s->password);\n\n        }\n\n        if (s->proxyusername) {\n\n            curl_easy_setopt(state->curl,\n\n                             CURLOPT_PROXYUSERNAME, s->proxyusername);\n\n        }\n\n        if (s->proxypassword) {\n\n            curl_easy_setopt(state->curl,\n\n                             CURLOPT_PROXYPASSWORD, s->proxypassword);\n\n        }\n\n\n\n        \/* Restrict supported protocols to avoid security issues in the more\n\n         * obscure protocols.  For example, do not allow POP3\/SMTP\/IMAP see\n\n         * CVE-2013-0249.\n\n         *\n\n         * Restricting protocols is only supported from 7.19.4 upwards.\n\n         *\/\n\n#if LIBCURL_VERSION_NUM >= 0x071304\n\n        curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);\n\n        curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);\n\n#endif\n\n\n\n#ifdef DEBUG_VERBOSE\n\n        curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);\n\n#endif\n\n    }\n\n\n\n    QLIST_INIT(&state->sockets);\n\n    state->s = s;\n\n\n\n    return state;\n\n}\n","target":1,"code_token_length":694,"total_token_length":930,"max_tokens_setting":1024}
+{"idx":80372,"func":"MOBI_RET mobi_load_reclist(MOBIData *m, FILE *file) {\n    if (m == NULL) {\n        debug_print(\"%s\", \"Mobi structure not initialized\\n\");\n        return MOBI_INIT_FAILED;\n    }\n    if (!file) {\n        debug_print(\"%s\", \"File not ready\\n\");\n        return MOBI_FILE_NOT_FOUND;\n    }\n    m->rec = calloc(1, sizeof(MOBIPdbRecord));\n    if (m->rec == NULL) {\n        debug_print(\"%s\", \"Memory allocation for pdb record failed\\n\");\n        return MOBI_MALLOC_FAILED;\n    }\n    MOBIPdbRecord *curr = m->rec;\n    for (int i = 0; i < m->ph->rec_count; i++) {\n        MOBIBuffer *buf = mobi_buffer_init(PALMDB_RECORD_INFO_SIZE);\n        if (buf == NULL) {\n            debug_print(\"%s\\n\", \"Memory allocation failed\");\n            return MOBI_MALLOC_FAILED;\n        }\n        const size_t len = fread(buf->data, 1, PALMDB_RECORD_INFO_SIZE, file);\n        if (len != PALMDB_RECORD_INFO_SIZE) {\n            mobi_buffer_free(buf);\n            return MOBI_DATA_CORRUPT;\n        }\n        if (i > 0) {\n            curr->next = calloc(1, sizeof(MOBIPdbRecord));\n            if (curr->next == NULL) {\n                debug_print(\"%s\", \"Memory allocation for pdb record failed\\n\");\n                mobi_buffer_free(buf);\n                return MOBI_MALLOC_FAILED;\n            }\n            curr = curr->next;\n        }\n        curr->offset = mobi_buffer_get32(buf);\n        curr->attributes = mobi_buffer_get8(buf);\n        const uint8_t h = mobi_buffer_get8(buf);\n        const uint16_t l = mobi_buffer_get16(buf);\n        curr->uid =  (uint32_t) h << 16 | l;\n        curr->next = NULL;\n        mobi_buffer_free(buf);\n    }\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":85658,"func":"bgp_attr_ext_communities(struct bgp_attr_parser_args *args)\n{\n\tstruct peer *const peer = args->peer;\n\tstruct attr *const attr = args->attr;\n\tconst bgp_size_t length = args->length;\n\tuint8_t sticky = 0;\n\n\tif (length == 0) {\n\t\tattr->ecommunity = NULL;\n\t\t\/* Empty extcomm doesn't seem to be invalid per se *\/\n\t\treturn BGP_ATTR_PARSE_PROCEED;\n\t}\n\n\tattr->ecommunity =\n\t\tecommunity_parse((uint8_t *)stream_pnt(peer->curr), length);\n\t\/* XXX: fix ecommunity_parse to use stream API *\/\n\tstream_forward_getp(peer->curr, length);\n\n\tif (!attr->ecommunity)\n\t\treturn bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,\n\t\t\t\t\t  args->total);\n\n\tattr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);\n\n\t\/* Extract MAC mobility sequence number, if any. *\/\n\tattr->mm_seqnum = bgp_attr_mac_mobility_seqnum(attr, &sticky);\n\tattr->sticky = sticky;\n\n\t\/* Check if this is a Gateway MAC-IP advertisement *\/\n\tattr->default_gw = bgp_attr_default_gw(attr);\n\n\t\/* Handle scenario where router flag ecommunity is not\n\t * set but default gw ext community is present.\n\t * Use default gateway, set and propogate R-bit.\n\t *\/\n\tif (attr->default_gw)\n\t\tattr->router_flag = 1;\n\n\t\/* Check EVPN Neighbor advertisement flags, R-bit *\/\n\tbgp_attr_evpn_na_flag(attr, &attr->router_flag);\n\n\t\/* Extract the Rmac, if any *\/\n\tbgp_attr_rmac(attr, &attr->rmac);\n\n\treturn BGP_ATTR_PARSE_PROCEED;\n}","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":76643,"func":"int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt)\n{\n\tint rc;\n\tstruct mntent *m;\n\n\tif (!fs || !mnt)\n\t\treturn -EINVAL;\n\n\tm = *mnt;\n\tif (!m) {\n\t\tm = calloc(1, sizeof(*m));\n\t\tif (!m)\n\t\t\treturn -ENOMEM;\n\t}\n\n\tif ((rc = update_str(&m->mnt_fsname, mnt_fs_get_source(fs))))\n\t\tgoto err;\n\tif ((rc = update_str(&m->mnt_dir, mnt_fs_get_target(fs))))\n\t\tgoto err;\n\tif ((rc = update_str(&m->mnt_type, mnt_fs_get_fstype(fs))))\n\t\tgoto err;\n\n\terrno = 0;\n\tm->mnt_opts = mnt_fs_strdup_options(fs);\n\tif (!m->mnt_opts && errno) {\n\t\trc = -errno;\n\t\tgoto err;\n\t}\n\n\tm->mnt_freq = mnt_fs_get_freq(fs);\n\tm->mnt_passno = mnt_fs_get_passno(fs);\n\n\tif (!m->mnt_fsname) {\n\t\tm->mnt_fsname = strdup(\"none\");\n\t\tif (!m->mnt_fsname)\n\t\t\tgoto err;\n\t}\n\t*mnt = m;\n\n\treturn 0;\nerr:\n\tif (m != *mnt)\n\t\tmnt_free_mntent(m);\n\treturn rc;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":3578,"func":"static int oidc_handle_session_management_iframe_rp(request_rec *r, oidc_cfg *c,\n\t\toidc_session_t *session, const char *client_id,\n\t\tconst char *check_session_iframe) {\n\n\toidc_debug(r, \"enter\");\n\n\tconst char *java_script =\n\t\t\t\"    <script type=\\\"text\/javascript\\\">\\n\"\n\t\t\t\"      var targetOrigin  = '%s';\\n\"\n\t\t\t\"      var message = '%s' + ' ' + '%s';\\n\"\n\t\t\t\"\t   var timerID;\\n\"\n\t\t\t\"\\n\"\n\t\t\t\"      function checkSession() {\\n\"\n\t\t\t\"        console.debug('checkSession: posting ' + message + ' to ' + targetOrigin);\\n\"\n\t\t\t\"        var win = window.parent.document.getElementById('%s').contentWindow;\\n\"\n\t\t\t\"        win.postMessage( message, targetOrigin);\\n\"\n\t\t\t\"      }\\n\"\n\t\t\t\"\\n\"\n\t\t\t\"      function setTimer() {\\n\"\n\t\t\t\"        checkSession();\\n\"\n\t\t\t\"        timerID = setInterval('checkSession()', %s);\\n\"\n\t\t\t\"      }\\n\"\n\t\t\t\"\\n\"\n\t\t\t\"      function receiveMessage(e) {\\n\"\n\t\t\t\"        console.debug('receiveMessage: ' + e.data + ' from ' + e.origin);\\n\"\n\t\t\t\"        if (e.origin !== targetOrigin ) {\\n\"\n\t\t\t\"          console.debug('receiveMessage: cross-site scripting attack?');\\n\"\n\t\t\t\"          return;\\n\"\n\t\t\t\"        }\\n\"\n\t\t\t\"        if (e.data != 'unchanged') {\\n\"\n\t\t\t\"          clearInterval(timerID);\\n\"\n\t\t\t\"          if (e.data == 'changed') {\\n\"\n\t\t\t\"\t\t     window.location.href = '%s?session=check';\\n\"\n\t\t\t\"          } else {\\n\"\n\t\t\t\"\t\t     window.location.href = '%s?session=logout';\\n\"\n\t\t\t\"          }\\n\"\n\t\t\t\"        }\\n\"\n\t\t\t\"      }\\n\"\n\t\t\t\"\\n\"\n\t\t\t\"      window.addEventListener('message', receiveMessage, false);\\n\"\n\t\t\t\"\\n\"\n\t\t\t\"    <\/script>\\n\";\n\n\t\/* determine the origin for the check_session_iframe endpoint *\/\n\tchar *origin = apr_pstrdup(r->pool, check_session_iframe);\n\tapr_uri_t uri;\n\tapr_uri_parse(r->pool, check_session_iframe, &uri);\n\tchar *p = strstr(origin, uri.path);\n\t*p = '\\0';\n\n\t\/* the element identifier for the OP iframe *\/\n\tconst char *op_iframe_id = \"openidc-op\";\n\n\t\/* restore the OP session_state from the session *\/\n\tconst char *session_state = oidc_session_get_session_state(r, session);\n\tif (session_state == NULL) {\n\t\toidc_warn(r,\n\t\t\t\t\"no session_state found in the session; the OP does probably not support session management!?\");\n\t\treturn DONE;\n\t}\n\n\tchar *s_poll_interval = NULL;\n\toidc_util_get_request_parameter(r, \"poll\", &s_poll_interval);\n\tif (s_poll_interval == NULL)\n\t\ts_poll_interval = \"3000\";\n\n\tconst char *redirect_uri = oidc_get_redirect_uri(r, c);\n\tjava_script = apr_psprintf(r->pool, java_script, origin, client_id,\n\t\t\tsession_state, op_iframe_id, s_poll_interval, redirect_uri,\n\t\t\tredirect_uri);\n\n\treturn oidc_util_html_send(r, NULL, java_script, \"setTimer\", NULL, DONE);\n}","target":1,"code_token_length":760,"total_token_length":996,"max_tokens_setting":1024}
+{"idx":422654,"func":"e_ews_connection_get_folder (EEwsConnection *cnc,\n                             gint pri,\n                             const gchar *folder_shape,\n                             const EEwsAdditionalProps *add_props,\n                             GSList *folder_ids,\n                             GCancellable *cancellable,\n                             GAsyncReadyCallback callback,\n                             gpointer user_data)\n{\n\tESoapMessage *msg;\n\tGSimpleAsyncResult *simple;\n\tEwsAsyncData *async_data;\n\n\tg_return_if_fail (cnc != NULL);\n\n\tmsg = e_ews_message_new_with_header (\n\t\t\tcnc->priv->settings,\n\t\t\tcnc->priv->uri,\n\t\t\tcnc->priv->impersonate_user,\n\t\t\t\"GetFolder\",\n\t\t\tNULL,\n\t\t\tNULL,\n\t\t\tcnc->priv->version,\n\t\t\tE_EWS_EXCHANGE_2007_SP1,\n\t\t\tTRUE,\n\t\t\tTRUE);\n\n\te_soap_message_start_element (msg, \"FolderShape\", \"messages\", NULL);\n\te_ews_message_write_string_parameter (msg, \"BaseShape\", NULL, folder_shape);\n\n\tews_append_additional_props_to_msg (msg, add_props);\n\te_soap_message_end_element (msg);\n\n\tif (folder_ids) {\n\t\te_soap_message_start_element (msg, \"FolderIds\", \"messages\", NULL);\n\t\tews_append_folder_ids_to_msg (msg, cnc->priv->email, folder_ids);\n\t\te_soap_message_end_element (msg);\n\t}\n\n\te_ews_message_write_footer (msg);\n\n\tsimple = g_simple_async_result_new (\n\t\tG_OBJECT (cnc), callback, user_data,\n\t\te_ews_connection_get_folder);\n\n\tasync_data = g_new0 (EwsAsyncData, 1);\n\tasync_data->cnc = cnc;\n\tg_simple_async_result_set_op_res_gpointer (\n\t\tsimple, async_data, (GDestroyNotify) async_data_free);\n\n\te_ews_connection_queue_request (\n\t\tcnc, msg, get_folder_response_cb,\n\t\tpri, cancellable, simple);\n\n\tg_object_unref (simple);\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":295544,"func":"R_API RConfigNode* r_config_set_i(RConfig *cfg, const char *name, const ut64 i) {\n\tchar buf[128], *ov = NULL;\n\tif (!cfg || !name) {\n\t\treturn NULL;\n\t}\n\tRConfigNode *node = r_config_node_get (cfg, name);\n\tif (node) {\n\t\tif (node->flags & CN_RO) {\n\t\t\tnode = NULL;\n\t\t\tgoto beach;\n\t\t}\n\t\tif (node->value) {\n\t\t\tov = strdup (node->value);\n\t\t\tif (!ov) {\n\t\t\t\tnode = NULL;\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t\tfree (node->value);\n\t\t}\n\t\tif (node->flags & CN_BOOL) {\n\t\t\tnode->value = strdup (r_str_bool (i));\n\t\t} else {\n\t\t\tsnprintf (buf, sizeof (buf) - 1, \"%\" PFMT64d, i);\n\t\t\tnode->value = strdup (buf);\n\t\t}\n\t\tif (!node->value) {\n\t\t\tnode = NULL;\n\t\t\tgoto beach;\n\t\t}\n\t\t\/\/node->flags = CN_RW | CN_INT;\n\t\tnode->i_value = i;\n\t} else {\n\t\tif (!cfg->lock) {\n\t\t\tif (i < 1024) {\n\t\t\t\tsnprintf (buf, sizeof (buf), \"%\" PFMT64d \"\", i);\n\t\t\t} else {\n\t\t\t\tsnprintf (buf, sizeof (buf), \"0x%08\" PFMT64x \"\", i);\n\t\t\t}\n\t\t\tnode = r_config_node_new (name, buf);\n\t\t\tif (!node) {\n\t\t\t\tnode = NULL;\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t\tnode->flags = CN_RW | CN_OFFT;\n\t\t\tnode->i_value = i;\n\t\t\tif (cfg->ht) {\n\t\t\t\tht_insert (cfg->ht, node->name, node);\n\t\t\t}\n\t\t\tif (cfg->nodes) {\n\t\t\t\tr_list_append (cfg->nodes, node);\n\t\t\t\tcfg->n_nodes++;\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"(locked: no new keys can be created (%s))\\n\", name);\n\t\t}\n\t}\n\n\tif (node && node->setter) {\n\t\tut64 oi = node->i_value;\n\t\tint ret = node->setter (cfg->user, node);\n\t\tif (!ret) {\n\t\t\tnode->i_value = oi;\n\t\t\tfree (node->value);\n\t\t\tnode->value = strdup (ov? ov: \"\");\n\t\t}\n\t}\nbeach:\n\tfree (ov);\n\treturn node;\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":55242,"func":"  explicit MaxPoolingOp(OpKernelConstruction* context) : OpKernel(context) {\n    string data_format;\n    auto status = context->GetAttr(\"data_format\", &data_format);\n    if (status.ok()) {\n      OP_REQUIRES(context, FormatFromString(data_format, &data_format_),\n                  errors::InvalidArgument(\"Invalid data format\"));\n      OP_REQUIRES(\n          context, data_format_ == FORMAT_NHWC,\n          errors::InvalidArgument(\"Default MaxPoolingOp only supports NHWC \",\n                                  \"on device type \",\n                                  DeviceTypeString(context->device_type())));\n    } else {\n      data_format_ = FORMAT_NHWC;\n    }\n    OP_REQUIRES_OK(context, context->GetAttr(\"ksize\", &ksize_));\n    OP_REQUIRES(context, ksize_.size() == 4,\n                errors::InvalidArgument(\"Sliding window ksize field must \"\n                                        \"specify 4 dimensions\"));\n    for (int i = 0; i < ksize_.size(); ++i) {\n      OP_REQUIRES(context, ksize_[i] > 0,\n                  errors::InvalidArgument(\"Sliding window ksize for dimension \",\n                                          i, \" was zero.\"));\n    }\n    OP_REQUIRES_OK(context, context->GetAttr(\"strides\", &stride_));\n    OP_REQUIRES(context, stride_.size() == 4,\n                errors::InvalidArgument(\"Sliding window stride field must \"\n                                        \"specify 4 dimensions\"));\n    OP_REQUIRES_OK(context, context->GetAttr(\"padding\", &padding_));\n    if (padding_ == Padding::EXPLICIT) {\n      OP_REQUIRES_OK(\n          context, context->GetAttr(\"explicit_paddings\", &explicit_paddings_));\n    }\n    OP_REQUIRES(context, ksize_[0] == 1 && stride_[0] == 1,\n                errors::Unimplemented(\n                    \"Pooling is not yet supported on the batch dimension.\"));\n  }","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":339289,"func":"static void bmdma_map(PCIDevice *pci_dev, int region_num,\n\n                    pcibus_t addr, pcibus_t size, int type)\n\n{\n\n    PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, pci_dev);\n\n    int i;\n\n\n\n    for(i = 0;i < 2; i++) {\n\n        BMDMAState *bm = &d->bmdma[i];\n\n        d->bus[i].bmdma = bm;\n\n        bm->bus = d->bus+i;\n\n\n        qemu_add_vm_change_state_handler(ide_dma_restart_cb, bm);\n\n\n\n        register_ioport_write(addr, 1, 1, bmdma_cmd_writeb, bm);\n\n\n\n        register_ioport_write(addr + 1, 3, 1, bmdma_writeb, bm);\n\n        register_ioport_read(addr, 4, 1, bmdma_readb, bm);\n\n\n\n        register_ioport_write(addr + 4, 4, 1, bmdma_addr_writeb, bm);\n\n        register_ioport_read(addr + 4, 4, 1, bmdma_addr_readb, bm);\n\n        register_ioport_write(addr + 4, 4, 2, bmdma_addr_writew, bm);\n\n        register_ioport_read(addr + 4, 4, 2, bmdma_addr_readw, bm);\n\n        register_ioport_write(addr + 4, 4, 4, bmdma_addr_writel, bm);\n\n        register_ioport_read(addr + 4, 4, 4, bmdma_addr_readl, bm);\n\n        addr += 8;\n\n    }\n\n}","target":1,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":64864,"func":"static int tg3_init_rings(struct tg3 *tp)\n{\n\tint i;\n\n\t\/* Free up all the SKBs. *\/\n\ttg3_free_rings(tp);\n\n\tfor (i = 0; i < tp->irq_cnt; i++) {\n\t\tstruct tg3_napi *tnapi = &tp->napi[i];\n\n\t\ttnapi->last_tag = 0;\n\t\ttnapi->last_irq_tag = 0;\n\t\ttnapi->hw_status->status = 0;\n\t\ttnapi->hw_status->status_tag = 0;\n\t\tmemset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE);\n\n\t\ttnapi->tx_prod = 0;\n\t\ttnapi->tx_cons = 0;\n\t\tif (tnapi->tx_ring)\n\t\t\tmemset(tnapi->tx_ring, 0, TG3_TX_RING_BYTES);\n\n\t\ttnapi->rx_rcb_ptr = 0;\n\t\tif (tnapi->rx_rcb)\n\t\t\tmemset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));\n\n\t\tif (tg3_rx_prodring_alloc(tp, &tnapi->prodring)) {\n\t\t\ttg3_free_rings(tp);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":44972,"func":"TEST_F(HttpConnectionManagerImplTest, UnderlyingConnectionWatermarksUnwoundWithLazyCreation) {\n  setup(false, \"\");\n\n  \/\/ Make sure codec_ is created.\n  EXPECT_CALL(*codec_, dispatch(_));\n  Buffer::OwnedImpl fake_input(\"\");\n  conn_manager_->onData(fake_input, false);\n\n  \/\/ Mark the connection manger as backed up before the stream is created.\n  ASSERT_EQ(decoder_filters_.size(), 0);\n  EXPECT_CALL(*codec_, onUnderlyingConnectionAboveWriteBufferHighWatermark());\n  conn_manager_->onAboveWriteBufferHighWatermark();\n\n  \/\/ Create the stream. Defer the creation of the filter chain by not sending\n  \/\/ complete headers.\n  StreamDecoder* decoder;\n  {\n    setUpBufferLimits();\n    EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void {\n      decoder = &conn_manager_->newStream(response_encoder_);\n      \/\/ Call the high buffer callbacks as the codecs do.\n      stream_callbacks_->onAboveWriteBufferHighWatermark();\n    }));\n\n    \/\/ Send fake data to kick off newStream being created.\n    Buffer::OwnedImpl fake_input2(\"asdf\");\n    conn_manager_->onData(fake_input2, false);\n  }\n\n  \/\/ Now before the filter chain is created, fire the low watermark callbacks\n  \/\/ and ensure it is passed down to the stream.\n  ASSERT(stream_callbacks_ != nullptr);\n  EXPECT_CALL(*codec_, onUnderlyingConnectionBelowWriteBufferLowWatermark())\n      .WillOnce(Invoke([&]() -> void { stream_callbacks_->onBelowWriteBufferLowWatermark(); }));\n  conn_manager_->onBelowWriteBufferLowWatermark();\n\n  \/\/ Now set up the filter chain by sending full headers. The filters should\n  \/\/ not get any watermark callbacks.\n  {\n    setupFilterChain(2, 2);\n    EXPECT_CALL(filter_callbacks_.connection_, aboveHighWatermark()).Times(0);\n    EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void {\n      HeaderMapPtr headers{\n          new TestHeaderMapImpl{{\":authority\", \"host\"}, {\":path\", \"\/\"}, {\":method\", \"GET\"}}};\n      decoder->decodeHeaders(std::move(headers), true);\n    }));\n    EXPECT_CALL(*decoder_filters_[0], decodeHeaders(_, true))\n        .WillOnce(InvokeWithoutArgs([&]() -> FilterHeadersStatus {\n          Buffer::OwnedImpl data(\"hello\");\n          decoder_filters_[0]->callbacks_->addDecodedData(data, true);\n          return FilterHeadersStatus::Continue;\n        }));\n    EXPECT_CALL(*decoder_filters_[0], decodeComplete());\n    sendRequestHeadersAndData();\n    ASSERT_GE(decoder_filters_.size(), 1);\n    MockDownstreamWatermarkCallbacks callbacks;\n    EXPECT_CALL(callbacks, onAboveWriteBufferHighWatermark()).Times(0);\n    EXPECT_CALL(callbacks, onBelowWriteBufferLowWatermark()).Times(0);\n    decoder_filters_[0]->callbacks_->addDownstreamWatermarkCallbacks(callbacks);\n  }\n}","target":0,"code_token_length":625,"total_token_length":861,"max_tokens_setting":1024}
+{"idx":148369,"func":"\t__releases(rq->lock)\n{\n\tstruct mm_struct *mm = rq->prev_mm;\n\tlong prev_state;\n\n\trq->prev_mm = NULL;\n\n\t\/*\n\t * A task struct has one reference for the use as \"current\".\n\t * If a task dies, then it sets TASK_DEAD in tsk->state and calls\n\t * schedule one last time. The schedule call will never return, and\n\t * the scheduled task must drop that reference.\n\t * The test for TASK_DEAD must occur while the runqueue locks are\n\t * still held, otherwise prev could be scheduled on another cpu, die\n\t * there before we look at prev->state, and then the reference would\n\t * be dropped twice.\n\t *\t\tManfred Spraul <manfred@colorfullife.com>\n\t *\/\n\tprev_state = prev->state;\n\tvtime_task_switch(prev);\n\tfinish_arch_switch(prev);\n\tperf_event_task_sched_in(prev, current);\n\tfinish_lock_switch(rq, prev);\n\tfinish_arch_post_lock_switch();\n\n\tfire_sched_in_preempt_notifiers(current);\n\tif (mm)\n\t\tmmdrop(mm);\n\tif (unlikely(prev_state == TASK_DEAD)) {\n\t\ttask_numa_free(prev);\n\n\t\tif (prev->sched_class->task_dead)\n\t\t\tprev->sched_class->task_dead(prev);\n\n\t\t\/*\n\t\t * Remove function-return probe instances associated with this\n\t\t * task and put them back on the free list.\n\t\t *\/\n\t\tkprobe_flush_task(prev);\n\t\tput_task_struct(prev);\n\t}\n\n\ttick_nohz_task_switch(current);\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":61660,"func":"int callback_glewlwyd_set_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) {\n  struct config_elements * config = (struct config_elements *)client_data;\n  json_t * j_module, * j_module_valid, * j_search_module;\n  \n  j_search_module = get_client_module(config, u_map_get(request->map_url, \"name\"));\n  if (check_result_value(j_search_module, G_OK)) {\n    j_module = ulfius_get_json_body_request(request, NULL);\n    if (j_module != NULL) {\n      json_object_del(j_module, \"enabled\");\n      j_module_valid = is_client_module_valid(config, j_module, 0);\n      if (check_result_value(j_module_valid, G_OK)) {\n        if (set_client_module(config, u_map_get(request->map_url, \"name\"), j_module) != G_OK) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_client_module - Error set_client_module\");\n          response->status = 500;\n        } else {\n          y_log_message(Y_LOG_LEVEL_INFO, \"Event - Client backend module '%s' updated\", u_map_get(request->map_url, \"name\"));\n        }\n      } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) {\n        if (json_object_get(j_module_valid, \"error\") != NULL) {\n          ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, \"error\"));\n        } else {\n          response->status = 400;\n        }\n      } else if (!check_result_value(j_module_valid, G_OK)) {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_client_module - Error is_client_module_valid\");\n        response->status = 500;\n      }\n      json_decref(j_module_valid);\n    } else {\n      response->status = 400;\n    }\n    json_decref(j_module);\n  } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_client_module - Error get_client_module\");\n    response->status = 500;\n  }\n  json_decref(j_search_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":45378,"func":"ipmi_fru_upg_ekeying(struct ipmi_intf *intf, char *pFileName, uint8_t fruId)\n{\n\tstruct fru_info fruInfo = {0};\n\tuint8_t *buf = NULL;\n\tuint32_t offFruMultiRec = 0;\n\tuint32_t fruMultiRecSize = 0;\n\tuint32_t offFileMultiRec = 0;\n\tuint32_t fileMultiRecSize = 0;\n\tint rc = 0;\n\n\tif (!pFileName) {\n\t\tlprintf(LOG_ERR, \"File expected, but none given.\");\n\t\tERR_EXIT;\n\t}\n\tif (ipmi_fru_get_multirec_location_from_fru(intf, fruId, &fruInfo,\n\t\t\t\t\t\t\t&offFruMultiRec, &fruMultiRecSize) != 0) {\n\t\tlprintf(LOG_ERR, \"Failed to get multirec location from FRU.\");\n\t\tERR_EXIT;\n\t}\n\tlprintf(LOG_DEBUG, \"FRU Size        : %lu\\n\", fruMultiRecSize);\n\tlprintf(LOG_DEBUG, \"Multi Rec offset: %lu\\n\", offFruMultiRec);\n\tif (ipmi_fru_get_multirec_size_from_file(pFileName, &fileMultiRecSize,\n\t\t\t\t&offFileMultiRec) != 0) {\n\t\tlprintf(LOG_ERR, \"Failed to get multirec size from file '%s'.\", pFileName);\n\t\tERR_EXIT;\n\t}\n\tbuf = malloc(fileMultiRecSize);\n\tif (!buf) {\n\t\tlprintf(LOG_ERR, \"ipmitool: malloc failure\");\n\t\tERR_EXIT;\n\t}\n\tif (ipmi_fru_get_multirec_from_file(pFileName, buf, fileMultiRecSize,\n\t\t\t\toffFileMultiRec) != 0) {\n\t\tlprintf(LOG_ERR, \"Failed to get multirec from file '%s'.\", pFileName);\n\t\tERR_EXIT;\n\t}\n\tif (ipmi_fru_get_adjust_size_from_buffer(buf, &fileMultiRecSize) != 0) {\n\t\tlprintf(LOG_ERR, \"Failed to adjust size from buffer.\");\n\t\tERR_EXIT;\n\t}\n\tif (write_fru_area(intf, &fruInfo, fruId, 0, offFruMultiRec,\n\t\t\t\tfileMultiRecSize, buf) != 0) {\n\t\tlprintf(LOG_ERR, \"Failed to write FRU area.\");\n\t\tERR_EXIT;\n\t}\n\n\tlprintf(LOG_INFO, \"Done upgrading Ekey.\");\n\nexit:\n\tfree_n(&buf);\n\n\treturn rc;\n}","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":437971,"func":"long long ReadUInt(IMkvReader* pReader, long long pos, long& len) {\n  if (!pReader || pos < 0)\n    return E_FILE_FORMAT_INVALID;\n\n  len = 1;\n  unsigned char b;\n  int status = pReader->Read(pos, 1, &b);\n\n  if (status < 0)  \/\/ error or underflow\n    return status;\n\n  if (status > 0)  \/\/ interpreted as \"underflow\"\n    return E_BUFFER_NOT_FULL;\n\n  if (b == 0)  \/\/ we can't handle u-int values larger than 8 bytes\n    return E_FILE_FORMAT_INVALID;\n\n  unsigned char m = 0x80;\n\n  while (!(b & m)) {\n    m >>= 1;\n    ++len;\n  }\n\n  long long result = b & (~m);\n  ++pos;\n\n  for (int i = 1; i < len; ++i) {\n    status = pReader->Read(pos, 1, &b);\n\n    if (status < 0) {\n      len = 1;\n      return status;\n    }\n\n    if (status > 0) {\n      len = 1;\n      return E_BUFFER_NOT_FULL;\n    }\n\n    result <<= 8;\n    result |= b;\n\n    ++pos;\n  }\n\n  return result;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":104311,"func":"nautilus_file_operations_copy (GList                *files,\n                               GArray               *relative_item_points,\n                               GFile                *target_dir,\n                               GtkWindow            *parent_window,\n                               NautilusCopyCallback  done_callback,\n                               gpointer              done_callback_data)\n{\n    GTask *task;\n    CopyMoveJob *job;\n\n    job = op_job_new (CopyMoveJob, parent_window);\n    job->desktop_location = nautilus_get_desktop_location ();\n    job->done_callback = done_callback;\n    job->done_callback_data = done_callback_data;\n    job->files = g_list_copy_deep (files, (GCopyFunc) g_object_ref, NULL);\n    job->destination = g_object_ref (target_dir);\n    \/* Need to indicate the destination for the operation notification open\n     * button. *\/\n    nautilus_progress_info_set_destination (((CommonJob *) job)->progress, target_dir);\n    if (relative_item_points != NULL &&\n        relative_item_points->len > 0)\n    {\n        job->icon_positions =\n            g_memdup (relative_item_points->data,\n                      sizeof (GdkPoint) * relative_item_points->len);\n        job->n_icon_positions = relative_item_points->len;\n    }\n    job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);\n\n    inhibit_power_manager ((CommonJob *) job, _(\"Copying Files\"));\n\n    if (!nautilus_file_undo_manager_is_operating ())\n    {\n        GFile *src_dir;\n\n        src_dir = g_file_get_parent (files->data);\n        job->common.undo_info = nautilus_file_undo_info_ext_new (NAUTILUS_FILE_UNDO_OP_COPY,\n                                                                 g_list_length (files),\n                                                                 src_dir, target_dir);\n\n        g_object_unref (src_dir);\n    }\n\n    task = g_task_new (NULL, job->common.cancellable, copy_task_done, job);\n    g_task_set_task_data (task, job, NULL);\n    g_task_run_in_thread (task, copy_task_thread_func);\n    g_object_unref (task);\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":203076,"func":"static unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)\n{\n  unsigned i;\n  if(color->colortype == LCT_PALETTE)\n  {\n    \/*error: more alpha values given than there are palette entries*\/\n    if(chunkLength > color->palettesize) return 38;\n\n    for(i = 0; i < chunkLength; i++) color->palette[4 * i + 3] = data[i];\n  }\n  else if(color->colortype == LCT_GREY)\n  {\n    \/*error: this chunk must be 2 bytes for greyscale image*\/\n    if(chunkLength != 2) return 30;\n\n    color->key_defined = 1;\n    color->key_r = color->key_g = color->key_b = 256u * data[0] + data[1];\n  }\n  else if(color->colortype == LCT_RGB)\n  {\n    \/*error: this chunk must be 6 bytes for RGB image*\/\n    if(chunkLength != 6) return 41;\n\n    color->key_defined = 1;\n    color->key_r = 256u * data[0] + data[1];\n    color->key_g = 256u * data[2] + data[3];\n    color->key_b = 256u * data[4] + data[5];\n  }\n  else return 42; \/*error: tRNS chunk not allowed for other color models*\/\n\n  return 0; \/* OK *\/\n}\n","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":383482,"func":"void precompute_partition_info_sums_(\n\tconst FLAC__int32 residual[],\n\tFLAC__uint64 abs_residual_partition_sums[],\n\tunsigned residual_samples,\n\tunsigned predictor_order,\n\tunsigned min_partition_order,\n\tunsigned max_partition_order,\n\tunsigned bps\n)\n{\n\tconst unsigned default_partition_samples = (residual_samples + predictor_order) >> max_partition_order;\n\tunsigned partitions = 1u << max_partition_order;\n\n\tFLAC__ASSERT(default_partition_samples > predictor_order);\n\n\t\/* first do max_partition_order *\/\n\t{\n\t\tunsigned partition, residual_sample, end = (unsigned)(-(int)predictor_order);\n\t\t\/* WATCHOUT: \"+ bps + FLAC__MAX_EXTRA_RESIDUAL_BPS\" is the maximum\n\t\t * assumed size of the average residual magnitude *\/\n\t\tif(FLAC__bitmath_ilog2(default_partition_samples) + bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < 32) {\n\t\t\tFLAC__uint32 abs_residual_partition_sum;\n\n\t\t\tfor(partition = residual_sample = 0; partition < partitions; partition++) {\n\t\t\t\tend += default_partition_samples;\n\t\t\t\tabs_residual_partition_sum = 0;\n\t\t\t\tfor( ; residual_sample < end; residual_sample++)\n\t\t\t\t\tabs_residual_partition_sum += abs(residual[residual_sample]); \/* abs(INT_MIN) is undefined, but if the residual is INT_MIN we have bigger problems *\/\n\t\t\t\tabs_residual_partition_sums[partition] = abs_residual_partition_sum;\n\t\t\t}\n\t\t}\n\t\telse { \/* have to pessimistically use 64 bits for accumulator *\/\n\t\t\tFLAC__uint64 abs_residual_partition_sum;\n\n\t\t\tfor(partition = residual_sample = 0; partition < partitions; partition++) {\n\t\t\t\tend += default_partition_samples;\n\t\t\t\tabs_residual_partition_sum = 0;\n\t\t\t\tfor( ; residual_sample < end; residual_sample++)\n\t\t\t\t\tabs_residual_partition_sum += abs(residual[residual_sample]); \/* abs(INT_MIN) is undefined, but if the residual is INT_MIN we have bigger problems *\/\n\t\t\t\tabs_residual_partition_sums[partition] = abs_residual_partition_sum;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* now merge partitions for lower orders *\/\n\t{\n\t\tunsigned from_partition = 0, to_partition = partitions;\n\t\tint partition_order;\n\t\tfor(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) {\n\t\t\tunsigned i;\n\t\t\tpartitions >>= 1;\n\t\t\tfor(i = 0; i < partitions; i++) {\n\t\t\t\tabs_residual_partition_sums[to_partition++] =\n\t\t\t\t\tabs_residual_partition_sums[from_partition  ] +\n\t\t\t\t\tabs_residual_partition_sums[from_partition+1];\n\t\t\t\tfrom_partition += 2;\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":6209,"func":"print_attr_string(netdissect_options *ndo,\n                  register const u_char *data, u_int length, u_short attr_code)\n{\n   register u_int i;\n\n   ND_TCHECK2(data[0],length);\n\n   switch(attr_code)\n   {\n      case TUNNEL_PASS:\n           if (length < 3)\n           {\n              ND_PRINT((ndo, \"%s\", tstr));\n              return;\n           }\n           if (*data && (*data <=0x1F) )\n              ND_PRINT((ndo, \"Tag[%u] \", *data));\n           else\n              ND_PRINT((ndo, \"Tag[Unused] \"));\n           data++;\n           length--;\n           ND_PRINT((ndo, \"Salt %u \", EXTRACT_16BITS(data)));\n           data+=2;\n           length-=2;\n        break;\n      case TUNNEL_CLIENT_END:\n      case TUNNEL_SERVER_END:\n      case TUNNEL_PRIV_GROUP:\n      case TUNNEL_ASSIGN_ID:\n      case TUNNEL_CLIENT_AUTH:\n      case TUNNEL_SERVER_AUTH:\n           if (*data <= 0x1F)\n           {\n              if (length < 1)\n              {\n                 ND_PRINT((ndo, \"%s\", tstr));\n                 return;\n              }\n              if (*data)\n                ND_PRINT((ndo, \"Tag[%u] \", *data));\n              else\n                ND_PRINT((ndo, \"Tag[Unused] \"));\n              data++;\n              length--;\n           }\n        break;\n      case EGRESS_VLAN_NAME:\n           ND_PRINT((ndo, \"%s (0x%02x) \",\n                  tok2str(rfc4675_tagged,\"Unknown tag\",*data),\n                  *data));\n           data++;\n           length--;\n        break;\n   }\n\n   for (i=0; *data && i < length ; i++, data++)\n       ND_PRINT((ndo, \"%c\", (*data < 32 || *data > 126) ? '.' : *data));\n\n   return;\n\n   trunc:\n      ND_PRINT((ndo, \"%s\", tstr));\n}","target":1,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":423333,"func":"int tcp_disconnect(struct sock *sk, int flags)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint err = 0;\n\tint old_state = sk->sk_state;\n\n\tif (old_state != TCP_CLOSE)\n\t\ttcp_set_state(sk, TCP_CLOSE);\n\n\t\/* ABORT function of RFC793 *\/\n\tif (old_state == TCP_LISTEN) {\n\t\tinet_csk_listen_stop(sk);\n\t} else if (unlikely(tp->repair)) {\n\t\tsk->sk_err = ECONNABORTED;\n\t} else if (tcp_need_reset(old_state) ||\n\t\t   (tp->snd_nxt != tp->write_seq &&\n\t\t    (1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK))) {\n\t\t\/* The last check adjusts for discrepancy of Linux wrt. RFC\n\t\t * states\n\t\t *\/\n\t\ttcp_send_active_reset(sk, gfp_any());\n\t\tsk->sk_err = ECONNRESET;\n\t} else if (old_state == TCP_SYN_SENT)\n\t\tsk->sk_err = ECONNRESET;\n\n\ttcp_clear_xmit_timers(sk);\n\t__skb_queue_purge(&sk->sk_receive_queue);\n\ttcp_write_queue_purge(sk);\n\t__skb_queue_purge(&tp->out_of_order_queue);\n\n\tinet->inet_dport = 0;\n\n\tif (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))\n\t\tinet_reset_saddr(sk);\n\n\tsk->sk_shutdown = 0;\n\tsock_reset_flag(sk, SOCK_DONE);\n\ttp->srtt = 0;\n\tif ((tp->write_seq += tp->max_window + 2) == 0)\n\t\ttp->write_seq = 1;\n\ticsk->icsk_backoff = 0;\n\ttp->snd_cwnd = 2;\n\ticsk->icsk_probes_out = 0;\n\ttp->packets_out = 0;\n\ttp->snd_ssthresh = TCP_INFINITE_SSTHRESH;\n\ttp->snd_cwnd_cnt = 0;\n\ttp->window_clamp = 0;\n\ttcp_set_ca_state(sk, TCP_CA_Open);\n\ttcp_clear_retrans(tp);\n\tinet_csk_delack_init(sk);\n\ttcp_init_send_head(sk);\n\tmemset(&tp->rx_opt, 0, sizeof(tp->rx_opt));\n\t__sk_dst_reset(sk);\n\n\tWARN_ON(inet->inet_num && !icsk->icsk_bind_hash);\n\n\tsk->sk_error_report(sk);\n\treturn err;\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":202547,"func":" bool FrameworkListener::onDataAvailable(SocketClient *c) {\n char buffer[CMD_BUF_SIZE];\n int len;\n\n    len = TEMP_FAILURE_RETRY(read(c->getSocket(), buffer, sizeof(buffer)));\n\n     if (len < 0) {\n         SLOGE(\"read() failed (%s)\", strerror(errno));\n         return false;\n    } else if (!len) {\n         return false;\n    } else if (buffer[len-1] != '\\0') {\n         SLOGW(\"String is not zero-terminated\");\n        android_errorWriteLog(0x534e4554, \"29831647\");\n        c->sendMsg(500, \"Command too large for buffer\", false);\n        mSkipToNextNullByte = true;\n        return false;\n    }\n \n     int offset = 0;\n     int i;\n\n\n     for (i = 0; i < len; i++) {\n         if (buffer[i] == '\\0') {\n             \/* IMPORTANT: dispatchCommand() expects a zero-terminated string *\/\n            if (mSkipToNextNullByte) {\n                mSkipToNextNullByte = false;\n            } else {\n                dispatchCommand(c, buffer + offset);\n            }\n             offset = i + 1;\n         }\n     }\n \n    mSkipToNextNullByte = false;\n     return true;\n }\n","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":318887,"func":"static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)\n\n{\n\n    if (s->RxBufAddr + size > s->RxBufferSize)\n\n    {\n\n        int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize);\n\n\n\n        \/* write packet data *\/\n\n        if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s))\n\n        {\n\n            DEBUG_PRINT((\">>> RTL8139: rx packet wrapped in buffer at %d\\n\", size-wrapped));\n\n\n\n            if (size > wrapped)\n\n            {\n\n                cpu_physical_memory_write( s->RxBuf + s->RxBufAddr,\n\n                                           buf, size-wrapped );\n\n            }\n\n\n\n            \/* reset buffer pointer *\/\n\n            s->RxBufAddr = 0;\n\n\n\n            cpu_physical_memory_write( s->RxBuf + s->RxBufAddr,\n\n                                       buf + (size-wrapped), wrapped );\n\n\n\n            s->RxBufAddr = wrapped;\n\n\n\n            return;\n\n        }\n\n    }\n\n\n\n    \/* non-wrapping path or overwrapping enabled *\/\n\n    cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size );\n\n\n\n    s->RxBufAddr += size;\n\n}\n","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":117062,"func":"mailimf_sender_parse(const char * message, size_t length,\n\t\t     size_t * indx, struct mailimf_sender ** result)\n{\n  struct mailimf_mailbox * mb;\n  struct mailimf_sender * sender;\n  size_t cur_token;\n  int r;\n  int res;\n\n  cur_token = * indx;\n\n  r = mailimf_token_case_insensitive_parse(message, length,\n\t\t\t\t\t   &cur_token, \"Sender\");\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto err;\n  }\n\n  r = mailimf_colon_parse(message, length, &cur_token);\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto err;\n  }\n\n  r = mailimf_mailbox_parse(message, length, &cur_token, &mb);\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto err;\n  }\n\n  r = mailimf_unstrict_crlf_parse(message, length, &cur_token);\n  if (r != MAILIMF_NO_ERROR) {\n    res = r;\n    goto free_mb;\n  }\n\n  sender = mailimf_sender_new(mb);\n  if (sender == NULL) {\n    res = MAILIMF_ERROR_MEMORY;\n    goto free_mb;\n  }\n\n  * result = sender;\n  * indx = cur_token;\n\n  return MAILIMF_NO_ERROR;\n\n free_mb:\n  mailimf_mailbox_free(mb);\n err:\n  return res;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":162256,"func":"DEFINE_TEST(test_read_format_rar5_multiarchive_solid_skip_all_but_first)\n{\n\tconst char* reffiles[] = {\n\t\t\"test_read_format_rar5_multiarchive_solid.part01.rar\",\n\t\t\"test_read_format_rar5_multiarchive_solid.part02.rar\",\n\t\t\"test_read_format_rar5_multiarchive_solid.part03.rar\",\n\t\t\"test_read_format_rar5_multiarchive_solid.part04.rar\",\n\t\tNULL\n\t};\n\n\tPROLOGUE_MULTI(reffiles);\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"cebula.txt\", archive_entry_pathname(ae));\n\tassertA(0 == extract_one(a, ae, 0x7E5EC49E));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test1.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test2.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test3.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test4.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test5.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test6.bin\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"elf-Linux-ARMv7-ls\", archive_entry_pathname(ae));\n\tassertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));\n\tEPILOGUE();\n}","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":389353,"func":"int set_zval_xmlrpc_type(zval* value, XMLRPC_VALUE_TYPE newtype) \/* {{{ *\/\n{\n\tint bSuccess = FAILURE;\n\n\t\/* we only really care about strings because they can represent\n\t * base64 and datetime.  all other types have corresponding php types\n\t *\/\n\tif (Z_TYPE_P(value) == IS_STRING) {\n\t\tif (newtype == xmlrpc_base64 || newtype == xmlrpc_datetime) {\n\t\t\tconst char* typestr = xmlrpc_type_as_str(newtype, xmlrpc_vector_none);\n\t\t\tzval type;\n\n\t\t\tZVAL_STRING(&type, typestr);\n\n\t\t\tif (newtype == xmlrpc_datetime) {\n\t\t\t\tXMLRPC_VALUE v = XMLRPC_CreateValueDateTime_ISO8601(NULL, Z_STRVAL_P(value));\n\t\t\t\tif (v) {\n\t\t\t\t\ttime_t timestamp = (time_t) php_parse_date((char *)XMLRPC_GetValueDateTime_ISO8601(v), NULL);\n\t\t\t\t\tif (timestamp != -1) {\n\t\t\t\t\t\tzval ztimestamp;\n\n\t\t\t\t\t\tZVAL_LONG(&ztimestamp, timestamp);\n\n\t\t\t\t\t\tconvert_to_object(value);\n\t\t\t\t\t\tif (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1, &type)) {\n\t\t\t\t\t\t\tbSuccess = (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_VALUE_TS_ATTR, sizeof(OBJECT_VALUE_TS_ATTR) - 1, &ztimestamp) != NULL)? SUCCESS : FAILURE;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzval_ptr_dtor(&type);\n\t\t\t\t\t}\n\t\t\t\t\tXMLRPC_CleanupValue(v);\n\t\t\t\t} else {\n\t\t\t\t\tzval_ptr_dtor(&type);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconvert_to_object(value);\n\t\t\t\tbSuccess = (zend_hash_str_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1, &type) != NULL)? SUCCESS : FAILURE;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn bSuccess;\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":262813,"func":"static void nalu_merge_ps(GF_BitStream *ps_bs, Bool rewrite_start_codes, u32 nal_unit_size_field, GF_MPEGVisualSampleEntryBox *entry, Bool is_hevc)\n{\n\tu32 i, count;\n\tif (is_hevc) {\n\t\tif (entry->hevc_config) {\n\t\t\tcount = gf_list_count(entry->hevc_config->config->param_array);\n\t\t\tfor (i=0; i<count; i++) {\n\t\t\t\tGF_HEVCParamArray *ar = (GF_HEVCParamArray*)gf_list_get(entry->hevc_config->config->param_array, i);\n\t\t\t\trewrite_nalus_list(ar->nalus, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t\t}\n\t\t}\n\t\tif (entry->lhvc_config) {\n\t\t\tcount = gf_list_count(entry->lhvc_config->config->param_array);\n\t\t\tfor (i=0; i<count; i++) {\n\t\t\t\tGF_HEVCParamArray *ar = (GF_HEVCParamArray*)gf_list_get(entry->lhvc_config->config->param_array, i);\n\t\t\t\trewrite_nalus_list(ar->nalus, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (entry->avc_config) {\n\t\t\trewrite_nalus_list(entry->avc_config->config->sequenceParameterSets, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t\trewrite_nalus_list(entry->avc_config->config->sequenceParameterSetExtensions, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t\trewrite_nalus_list(entry->avc_config->config->pictureParameterSets, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t}\n\n\t\t\/*add svc config *\/\n\t\tif (entry->svc_config) {\n\t\t\trewrite_nalus_list(entry->svc_config->config->sequenceParameterSets, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t\trewrite_nalus_list(entry->svc_config->config->pictureParameterSets, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t}\n\t\t\/*add mvc config *\/\n\t\tif (entry->mvc_config) {\n\t\t\trewrite_nalus_list(entry->mvc_config->config->sequenceParameterSets, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t\trewrite_nalus_list(entry->mvc_config->config->pictureParameterSets, ps_bs, rewrite_start_codes, nal_unit_size_field);\n\t\t}\n\t}\n}","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":241033,"func":"PHP_FUNCTION(pg_lo_unlink)\n{\n\tzval *pgsql_link = NULL;\n\tlong oid_long;\n\tchar *oid_string, *end_ptr;\n\tint oid_strlen;\n\tPGconn *pgsql;\n\tOid oid;\n\tint id = -1;\n\tint argc = ZEND_NUM_ARGS();\n\n\t\/* accept string type since Oid type is unsigned int *\/\n\tif (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,\n\t\t\t\t\t\t\t\t \"rs\", &pgsql_link, &oid_string, &oid_strlen) == SUCCESS) {\n\t\toid = (Oid)strtoul(oid_string, &end_ptr, 10);\n\t\tif ((oid_string+oid_strlen) != end_ptr) {\n\t\t\t\/* wrong integer format *\/\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Wrong OID value passed\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\t}\n\telse if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,\n\t\t\t\t\t\t\t\t \"rl\", &pgsql_link, &oid_long) == SUCCESS) {\n\t\tif (oid_long <= InvalidOid) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Invalid OID specified\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\toid = (Oid)oid_long;\n\t}\n\telse if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,\n\t\t\t\t\t\t\t\t \"s\", &oid_string, &oid_strlen) == SUCCESS) {\n\t\toid = (Oid)strtoul(oid_string, &end_ptr, 10);\n\t\tif ((oid_string+oid_strlen) != end_ptr) {\n\t\t\t\/* wrong integer format *\/\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Wrong OID value passed\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\tid = PGG(default_link);\n\t\tCHECK_DEFAULT_LINK(id);\n\t}\n\telse if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,\n\t\t\t\t\t\t\t\t \"l\", &oid_long) == SUCCESS) {\n\t\tif (oid_long <= InvalidOid) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Invalid OID is specified\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\toid = (Oid)oid_long;\n\t\tid = PGG(default_link);\n\t\tCHECK_DEFAULT_LINK(id);\n\t}\n\telse {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Requires 1 or 2 arguments\");\n\t\tRETURN_FALSE;\n\t}\n\tif (pgsql_link == NULL && id == -1) {\n\t\tRETURN_FALSE;\n\t}\n\n\tZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, \"PostgreSQL link\", le_link, le_plink);\n\n\tif (lo_unlink(pgsql, oid) == -1) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unable to delete PostgreSQL large object %u\", oid);\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_TRUE;\n}\n","target":0,"code_token_length":605,"total_token_length":841,"max_tokens_setting":1024}
+{"idx":299469,"func":"static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt,\n\t\t\t\tenum compat_mwt compat_mwt,\n\t\t\t\tstruct ebt_entries_buf_state *state,\n\t\t\t\tconst unsigned char *base)\n{\n\tchar name[EBT_FUNCTION_MAXNAMELEN];\n\tstruct xt_match *match;\n\tstruct xt_target *wt;\n\tvoid *dst = NULL;\n\tint off, pad = 0;\n\tunsigned int size_kern, match_size = mwt->match_size;\n\n\tstrlcpy(name, mwt->u.name, sizeof(name));\n\n\tif (state->buf_kern_start)\n\t\tdst = state->buf_kern_start + state->buf_kern_offset;\n\n\tswitch (compat_mwt) {\n\tcase EBT_COMPAT_MATCH:\n\t\tmatch = xt_request_find_match(NFPROTO_BRIDGE, name, 0);\n\t\tif (IS_ERR(match))\n\t\t\treturn PTR_ERR(match);\n\n\t\toff = ebt_compat_match_offset(match, match_size);\n\t\tif (dst) {\n\t\t\tif (match->compat_from_user)\n\t\t\t\tmatch->compat_from_user(dst, mwt->data);\n\t\t\telse\n\t\t\t\tmemcpy(dst, mwt->data, match_size);\n\t\t}\n\n\t\tsize_kern = match->matchsize;\n\t\tif (unlikely(size_kern == -1))\n\t\t\tsize_kern = match_size;\n\t\tmodule_put(match->me);\n\t\tbreak;\n\tcase EBT_COMPAT_WATCHER: \/* fallthrough *\/\n\tcase EBT_COMPAT_TARGET:\n\t\twt = xt_request_find_target(NFPROTO_BRIDGE, name, 0);\n\t\tif (IS_ERR(wt))\n\t\t\treturn PTR_ERR(wt);\n\t\toff = xt_compat_target_offset(wt);\n\n\t\tif (dst) {\n\t\t\tif (wt->compat_from_user)\n\t\t\t\twt->compat_from_user(dst, mwt->data);\n\t\t\telse\n\t\t\t\tmemcpy(dst, mwt->data, match_size);\n\t\t}\n\n\t\tsize_kern = wt->targetsize;\n\t\tmodule_put(wt->me);\n\t\tbreak;\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tstate->buf_kern_offset += match_size + off;\n\tstate->buf_user_offset += match_size;\n\tpad = XT_ALIGN(size_kern) - size_kern;\n\n\tif (pad > 0 && dst) {\n\t\tif (WARN_ON(state->buf_kern_len <= pad))\n\t\t\treturn -EINVAL;\n\t\tif (WARN_ON(state->buf_kern_offset - (match_size + off) + size_kern > state->buf_kern_len - pad))\n\t\t\treturn -EINVAL;\n\t\tmemset(dst + size_kern, 0, pad);\n\t}\n\treturn off + match_size;\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":14430,"func":"TabStyle::TabColors GM2TabStyle::CalculateColors() const {\n  const ui::ThemeProvider* theme_provider = tab_->GetThemeProvider();\n\n  constexpr float kMinimumActiveContrastRatio = 6.05f;\n  constexpr float kMinimumInactiveContrastRatio = 4.61f;\n  constexpr float kMinimumHoveredContrastRatio = 5.02f;\n  constexpr float kMinimumPressedContrastRatio = 4.41f;\n\n  float expected_opacity = 0.0f;\n  if (tab_->IsActive()) {\n    expected_opacity = 1.0f;\n  } else if (tab_->IsSelected()) {\n    expected_opacity = kSelectedTabOpacity;\n  } else if (tab_->mouse_hovered()) {\n     expected_opacity = GetHoverOpacity();\n   }\n   const SkColor bg_color = color_utils::AlphaBlend(\n      tab_->controller()->GetTabBackgroundColor(TAB_ACTIVE),\n      tab_->controller()->GetTabBackgroundColor(TAB_INACTIVE),\n       expected_opacity);\n \n   SkColor title_color = tab_->controller()->GetTabForegroundColor(\n      expected_opacity > 0.5f ? TAB_ACTIVE : TAB_INACTIVE, bg_color);\n  title_color = color_utils::GetColorWithMinimumContrast(title_color, bg_color);\n\n  const SkColor base_hovered_color = theme_provider->GetColor(\n      ThemeProperties::COLOR_TAB_CLOSE_BUTTON_BACKGROUND_HOVER);\n  const SkColor base_pressed_color = theme_provider->GetColor(\n      ThemeProperties::COLOR_TAB_CLOSE_BUTTON_BACKGROUND_PRESSED);\n\n  const auto get_color_for_contrast_ratio = [](SkColor fg_color,\n                                               SkColor bg_color,\n                                               float contrast_ratio) {\n    const SkAlpha blend_alpha = color_utils::GetBlendValueWithMinimumContrast(\n        bg_color, fg_color, bg_color, contrast_ratio);\n    return color_utils::AlphaBlend(fg_color, bg_color, blend_alpha);\n  };\n\n  const SkColor generated_icon_color = get_color_for_contrast_ratio(\n      title_color, bg_color,\n      tab_->IsActive() ? kMinimumActiveContrastRatio\n                       : kMinimumInactiveContrastRatio);\n  const SkColor generated_hovered_color = get_color_for_contrast_ratio(\n      base_hovered_color, bg_color, kMinimumHoveredContrastRatio);\n  const SkColor generated_pressed_color = get_color_for_contrast_ratio(\n      base_pressed_color, bg_color, kMinimumPressedContrastRatio);\n\n  const SkColor generated_hovered_icon_color =\n      color_utils::GetColorWithMinimumContrast(title_color,\n                                               generated_hovered_color);\n  const SkColor generated_pressed_icon_color =\n      color_utils::GetColorWithMinimumContrast(title_color,\n                                               generated_pressed_color);\n\n  return {bg_color,\n          title_color,\n          generated_icon_color,\n          generated_hovered_icon_color,\n          generated_pressed_icon_color,\n          generated_hovered_color,\n          generated_pressed_color};\n}\n","target":1,"code_token_length":599,"total_token_length":835,"max_tokens_setting":1024}
+{"idx":266407,"func":"sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,\n\t\t size_t count, int blocking, int read_only, int sg_io_owned,\n\t\t Sg_request **o_srp)\n{\n\tint k;\n\tSg_request *srp;\n\tsg_io_hdr_t *hp;\n\tunsigned char cmnd[SG_MAX_CDB_SIZE];\n\tint timeout;\n\tunsigned long ul_timeout;\n\n\tif (count < SZ_SG_IO_HDR)\n\t\treturn -EINVAL;\n\tif (!access_ok(VERIFY_READ, buf, count))\n\t\treturn -EFAULT; \/* protects following copy_from_user()s + get_user()s *\/\n\n\tsfp->cmd_q = 1;\t\/* when sg_io_hdr seen, set command queuing on *\/\n\tif (!(srp = sg_add_request(sfp))) {\n\t\tSCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp,\n\t\t\t\t\t      \"sg_new_write: queue full\\n\"));\n\t\treturn -EDOM;\n\t}\n\tsrp->sg_io_owned = sg_io_owned;\n\thp = &srp->header;\n\tif (__copy_from_user(hp, buf, SZ_SG_IO_HDR)) {\n\t\tsg_remove_request(sfp, srp);\n\t\treturn -EFAULT;\n\t}\n\tif (hp->interface_id != 'S') {\n\t\tsg_remove_request(sfp, srp);\n\t\treturn -ENOSYS;\n\t}\n\tif (hp->flags & SG_FLAG_MMAP_IO) {\n\t\tif (hp->dxfer_len > sfp->reserve.bufflen) {\n\t\t\tsg_remove_request(sfp, srp);\n\t\t\treturn -ENOMEM;\t\/* MMAP_IO size must fit in reserve buffer *\/\n\t\t}\n\t\tif (hp->flags & SG_FLAG_DIRECT_IO) {\n\t\t\tsg_remove_request(sfp, srp);\n\t\t\treturn -EINVAL;\t\/* either MMAP_IO or DIRECT_IO (not both) *\/\n\t\t}\n\t\tif (sfp->res_in_use) {\n\t\t\tsg_remove_request(sfp, srp);\n\t\t\treturn -EBUSY;\t\/* reserve buffer already being used *\/\n\t\t}\n\t}\n\tul_timeout = msecs_to_jiffies(srp->header.timeout);\n\ttimeout = (ul_timeout < INT_MAX) ? ul_timeout : INT_MAX;\n\tif ((!hp->cmdp) || (hp->cmd_len < 6) || (hp->cmd_len > sizeof (cmnd))) {\n\t\tsg_remove_request(sfp, srp);\n\t\treturn -EMSGSIZE;\n\t}\n\tif (!access_ok(VERIFY_READ, hp->cmdp, hp->cmd_len)) {\n\t\tsg_remove_request(sfp, srp);\n\t\treturn -EFAULT;\t\/* protects following copy_from_user()s + get_user()s *\/\n\t}\n\tif (__copy_from_user(cmnd, hp->cmdp, hp->cmd_len)) {\n\t\tsg_remove_request(sfp, srp);\n\t\treturn -EFAULT;\n\t}\n\tif (read_only && sg_allow_access(file, cmnd)) {\n\t\tsg_remove_request(sfp, srp);\n\t\treturn -EPERM;\n\t}\n\tk = sg_common_write(sfp, srp, cmnd, timeout, blocking);\n\tif (k < 0)\n\t\treturn k;\n\tif (o_srp)\n\t\t*o_srp = srp;\n\treturn count;\n}","target":0,"code_token_length":693,"total_token_length":929,"max_tokens_setting":1024}
+{"idx":196987,"func":"DEFINE_TRACE(Document)\n{\n#if ENABLE(OILPAN)\n    visitor->trace(m_importsController);\n    visitor->trace(m_docType);\n    visitor->trace(m_implementation);\n    visitor->trace(m_autofocusElement);\n    visitor->trace(m_focusedElement);\n    visitor->trace(m_hoverNode);\n    visitor->trace(m_activeHoverElement);\n    visitor->trace(m_documentElement);\n    visitor->trace(m_titleElement);\n    visitor->trace(m_axObjectCache);\n    visitor->trace(m_markers);\n    visitor->trace(m_cssTarget);\n    visitor->trace(m_currentScriptStack);\n    visitor->trace(m_scriptRunner);\n    visitor->trace(m_listsInvalidatedAtDocument);\n    for (int i = 0; i < numNodeListInvalidationTypes; ++i)\n        visitor->trace(m_nodeLists[i]);\n    visitor->trace(m_topLayerElements);\n    visitor->trace(m_elemSheet);\n    visitor->trace(m_nodeIterators);\n    visitor->trace(m_ranges);\n    visitor->trace(m_styleEngine);\n    visitor->trace(m_formController);\n    visitor->trace(m_visitedLinkState);\n    visitor->trace(m_frame);\n    visitor->trace(m_domWindow);\n    visitor->trace(m_fetcher);\n    visitor->trace(m_parser);\n    visitor->trace(m_contextFeatures);\n    visitor->trace(m_styleSheetList);\n    visitor->trace(m_documentTiming);\n    visitor->trace(m_mediaQueryMatcher);\n    visitor->trace(m_scriptedAnimationController);\n    visitor->trace(m_scriptedIdleTaskController);\n    visitor->trace(m_taskRunner);\n    visitor->trace(m_textAutosizer);\n    visitor->trace(m_registrationContext);\n    visitor->trace(m_customElementMicrotaskRunQueue);\n    visitor->trace(m_elementDataCache);\n    visitor->trace(m_associatedFormControls);\n    visitor->trace(m_useElementsNeedingUpdate);\n    visitor->trace(m_layerUpdateSVGFilterElements);\n    visitor->trace(m_timers);\n    visitor->trace(m_templateDocument);\n    visitor->trace(m_templateDocumentHost);\n    visitor->trace(m_visibilityObservers);\n    visitor->trace(m_userActionElements);\n    visitor->trace(m_svgExtensions);\n    visitor->trace(m_timeline);\n    visitor->trace(m_compositorPendingAnimations);\n    visitor->trace(m_contextDocument);\n    visitor->trace(m_canvasFontCache);\n    visitor->trace(m_intersectionObserverController);\n    visitor->trace(m_intersectionObserverData);\n    WillBeHeapSupplementable<Document>::trace(visitor);\n#endif\n    TreeScope::trace(visitor);\n    ContainerNode::trace(visitor);\n    ExecutionContext::trace(visitor);\n    DocumentLifecycleNotifier::trace(visitor);\n    SecurityContext::trace(visitor);\n}\n","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":117699,"func":"list_item_verbose(struct cpio *cpio, struct archive_entry *entry)\n{\n\tchar\t\t\t size[32];\n\tchar\t\t\t date[32];\n\tchar\t\t\t uids[16], gids[16];\n\tconst char \t\t*uname, *gname;\n\tFILE\t\t\t*out = stdout;\n\tconst char\t\t*fmt;\n\ttime_t\t\t\t mtime;\n\tstatic time_t\t\t now;\n\n\tif (!now)\n\t\ttime(&now);\n\n\tif (cpio->option_numeric_uid_gid) {\n\t\t\/* Format numeric uid\/gid for display. *\/\n\t\tstrcpy(uids, cpio_i64toa(archive_entry_uid(entry)));\n\t\tuname = uids;\n\t\tstrcpy(gids, cpio_i64toa(archive_entry_gid(entry)));\n\t\tgname = gids;\n\t} else {\n\t\t\/* Use uname if it's present, else lookup name from uid. *\/\n\t\tuname = archive_entry_uname(entry);\n\t\tif (uname == NULL)\n\t\t\tuname = lookup_uname(cpio, (uid_t)archive_entry_uid(entry));\n\t\t\/* Use gname if it's present, else lookup name from gid. *\/\n\t\tgname = archive_entry_gname(entry);\n\t\tif (gname == NULL)\n\t\t\tgname = lookup_gname(cpio, (uid_t)archive_entry_gid(entry));\n\t}\n\n\t\/* Print device number or file size. *\/\n\tif (archive_entry_filetype(entry) == AE_IFCHR\n\t    || archive_entry_filetype(entry) == AE_IFBLK) {\n\t\tsnprintf(size, sizeof(size), \"%lu,%lu\",\n\t\t    (unsigned long)archive_entry_rdevmajor(entry),\n\t\t    (unsigned long)archive_entry_rdevminor(entry));\n\t} else {\n\t\tstrcpy(size, cpio_i64toa(archive_entry_size(entry)));\n\t}\n\n\t\/* Format the time using 'ls -l' conventions. *\/\n\tmtime = archive_entry_mtime(entry);\n#if defined(_WIN32) && !defined(__CYGWIN__)\n\t\/* Windows' strftime function does not support %e format. *\/\n\tif (mtime - now > 365*86400\/2\n\t\t|| mtime - now < -365*86400\/2)\n\t\tfmt = cpio->day_first ? \"%d %b  %Y\" : \"%b %d  %Y\";\n\telse\n\t\tfmt = cpio->day_first ? \"%d %b %H:%M\" : \"%b %d %H:%M\";\n#else\n\tif (mtime - now > 365*86400\/2\n\t\t|| mtime - now < -365*86400\/2)\n\t\tfmt = cpio->day_first ? \"%e %b  %Y\" : \"%b %e  %Y\";\n\telse\n\t\tfmt = cpio->day_first ? \"%e %b %H:%M\" : \"%b %e %H:%M\";\n#endif\n\tstrftime(date, sizeof(date), fmt, localtime(&mtime));\n\n\tfprintf(out, \"%s%3d %-8s %-8s %8s %12s %s\",\n\t    archive_entry_strmode(entry),\n\t    archive_entry_nlink(entry),\n\t    uname, gname, size, date,\n\t    archive_entry_pathname(entry));\n\n\t\/* Extra information for links. *\/\n\tif (archive_entry_hardlink(entry)) \/* Hard link *\/\n\t\tfprintf(out, \" link to %s\", archive_entry_hardlink(entry));\n\telse if (archive_entry_symlink(entry)) \/* Symbolic link *\/\n\t\tfprintf(out, \" -> %s\", archive_entry_symlink(entry));\n\tfprintf(out, \"\\n\");\n}","target":0,"code_token_length":759,"total_token_length":995,"max_tokens_setting":1024}
+{"idx":135918,"func":"void VectorAddition(OpKernelContext* context, const quint8* x_data, float min_x,\n                    float max_x, const quint8* y_data, float min_y, float max_y,\n                    int64 num_elements, float output_min, float output_max,\n                    qint32* output) {\n  const float x_0_float = QuantizedToFloat<quint8>(0, min_x, max_x);\n  const float x_1_float = QuantizedToFloat<quint8>(1, min_x, max_x);\n  const int64 x_0_int64 =\n      FloatToQuantizedUnclamped<qint32>(x_0_float, output_min, output_max);\n  const int64 x_1_int64 =\n      FloatToQuantizedUnclamped<qint32>(x_1_float, output_min, output_max);\n  const int32 x_mult_int32 = x_1_int64 - x_0_int64;\n\n  const float y_0_float = QuantizedToFloat<quint8>(0, min_y, max_y);\n  const float y_1_float = QuantizedToFloat<quint8>(1, min_y, max_y);\n  const int64 y_0_int64 =\n      FloatToQuantizedUnclamped<qint32>(y_0_float, output_min, output_max);\n  const int64 y_1_int64 =\n      FloatToQuantizedUnclamped<qint32>(y_1_float, output_min, output_max);\n  const int32 y_mult_int32 = y_1_int64 - y_0_int64;\n\n  const int64 lowest_quantized =\n      static_cast<int64>(Eigen::NumTraits<qint32>::lowest());\n  const int64 highest_quantized =\n      static_cast<int64>(Eigen::NumTraits<qint32>::highest());\n\n  for (int i = 0; i < num_elements; ++i) {\n    const int64 x_value = static_cast<int64>(x_data[i]);\n    int64 x_in_output_range_64 = x_0_int64 + (x_value * x_mult_int32);\n    x_in_output_range_64 = std::max(x_in_output_range_64, lowest_quantized);\n    x_in_output_range_64 = std::min(x_in_output_range_64, highest_quantized);\n    const int32 x_in_output_range = static_cast<int32>(x_in_output_range_64);\n\n    const int64 y_value = static_cast<int64>(y_data[i]);\n    int64 y_in_output_range_64 = y_0_int64 + (y_value * y_mult_int32);\n    y_in_output_range_64 = std::max(y_in_output_range_64, lowest_quantized);\n    y_in_output_range_64 = std::min(y_in_output_range_64, highest_quantized);\n    const int32 y_in_output_range = static_cast<int32>(y_in_output_range_64);\n\n    output[i] = x_in_output_range + y_in_output_range;\n  }\n}","target":0,"code_token_length":692,"total_token_length":928,"max_tokens_setting":1024}
+{"idx":490132,"func":"gpk_compute_crycks(sc_card_t *card, sc_apdu_t *apdu,\n\t\t\tu8 *crycks1)\n{\n\tstruct gpk_private_data *priv = DRVDATA(card);\n\tu8\t\tin[8], out[8], block[64];\n\tunsigned int\tlen = 0, i;\n\tint             r = SC_SUCCESS, outl;\n\tEVP_CIPHER_CTX  *ctx = NULL;\n\n\tctx = EVP_CIPHER_CTX_new();\n\tif (ctx == NULL)\n\t\treturn SC_ERROR_INTERNAL;\n\n\n\t\/* Fill block with 0x00 and then with the data. *\/\n\tmemset(block, 0x00, sizeof(block));\n\tblock[len++] = apdu->cla;\n\tblock[len++] = apdu->ins;\n\tblock[len++] = apdu->p1;\n\tblock[len++] = apdu->p2;\n\tblock[len++] = apdu->lc + 3;\n\tif ((i = apdu->datalen) + len > sizeof(block))\n\t\ti = sizeof(block) - len;\n\tmemcpy(block+len, apdu->data, i);\n\tlen += i;\n\n\t\/* Set IV *\/\n\tmemset(in, 0x00, 8);\n\n\tEVP_EncryptInit_ex(ctx, EVP_des_ede_cbc(), NULL, priv->key, in);\n\tfor (i = 0; i < len; i += 8) {\n\t\tif (!EVP_EncryptUpdate(ctx, out, &outl, &block[i], 8)) {\n\t\t\tr = SC_ERROR_INTERNAL;\n\t\t\tbreak;\n\t\t}\n\t}\n\tEVP_CIPHER_CTX_free(ctx);\n\n\tmemcpy((u8 *) (apdu->data + apdu->datalen), out + 5, 3);\n\tapdu->datalen += 3;\n\tapdu->lc += 3;\n\tapdu->le += 3;\n\tif (crycks1)\n\t\tmemcpy(crycks1, out, 3);\n\tsc_mem_clear(in, sizeof(in));\n\tsc_mem_clear(out, sizeof(out));\n\tsc_mem_clear(block, sizeof(block));\n\treturn r;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":227499,"func":"static void InsertComplexFloatRow(float *p, int y, Image * image, double MinVal,\n                                  double MaxVal)\n{\n  ExceptionInfo\n    *exception;\n\n  double f;\n  int x;\n  register PixelPacket *q;\n\n  if (MinVal == 0)\n    MinVal = -1;\n  if (MaxVal == 0)\n    MaxVal = 1;\n\n  exception=(&image->exception);\n  q = QueueAuthenticPixels(image, 0, y, image->columns, 1,exception);\n  if (q == (PixelPacket *) NULL)\n    return;\n  for (x = 0; x < (ssize_t) image->columns; x++)\n  {\n    if (*p > 0)\n    {\n      f = (*p \/ MaxVal) * (QuantumRange - GetPixelRed(q));\n      if (f + GetPixelRed(q) > QuantumRange)\n        SetPixelRed(q,QuantumRange);\n      else\n        SetPixelRed(q,GetPixelRed(q)+(int) f);\n      if ((int) f \/ 2.0 > GetPixelGreen(q))\n        {\n          SetPixelGreen(q,0);\n          SetPixelBlue(q,0);\n        }\n      else\n        {\n          SetPixelBlue(q,GetPixelBlue(q)-(int) (f\/2.0));\n          SetPixelGreen(q,GetPixelBlue(q));\n        }\n    }\n    if (*p < 0)\n    {\n      f = (*p \/ MaxVal) * (QuantumRange - GetPixelBlue(q));\n      if (f + GetPixelBlue(q) > QuantumRange)\n        SetPixelBlue(q,QuantumRange);\n      else\n        SetPixelBlue(q,GetPixelBlue(q)+(int) f);\n      if ((int) f \/ 2.0 > q->green)\n        {\n          SetPixelGreen(q,0);\n          SetPixelRed(q,0);\n        }\n      else\n        {\n          SetPixelRed(q,GetPixelRed(q)-(int) (f\/2.0));\n          SetPixelGreen(q,GetPixelRed(q));\n        }\n    }\n    p++;\n    q++;\n  }\n  if (!SyncAuthenticPixels(image,exception))\n    return;\n  return;\n}\n","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":515002,"func":"find_seek_offset_time (GstRMDemux * rmdemux, GstClockTime time)\n{\n  int i, n_stream;\n  gboolean ret = FALSE;\n  GSList *cur;\n  GstClockTime earliest = GST_CLOCK_TIME_NONE;\n\n  n_stream = 0;\n  for (cur = rmdemux->streams; cur; cur = cur->next, n_stream++) {\n    GstRMDemuxStream *stream = cur->data;\n\n    \/* Search backwards through this stream's index until we find the first\n     * timestamp before our target time *\/\n    for (i = stream->index_length - 1; i >= 0; i--) {\n      if (stream->index[i].timestamp <= time) {\n        \/* Set the seek_offset for the stream so we don't bother parsing it\n         * until we've passed that point *\/\n        stream->seek_offset = stream->index[i].offset;\n\n        \/* If it's also the earliest timestamp we've seen of all streams, then\n         * that's our target!\n         *\/\n        if (earliest == GST_CLOCK_TIME_NONE ||\n            stream->index[i].timestamp < earliest) {\n          earliest = stream->index[i].timestamp;\n          rmdemux->offset = stream->index[i].offset;\n          GST_DEBUG_OBJECT (rmdemux,\n              \"We're looking for %\" GST_TIME_FORMAT\n              \" and we found that stream %d has the latest index at %\"\n              GST_TIME_FORMAT, GST_TIME_ARGS (rmdemux->segment.start), n_stream,\n              GST_TIME_ARGS (earliest));\n        }\n\n        ret = TRUE;\n\n        break;\n      }\n    }\n    stream->discont = TRUE;\n  }\n  return ret;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":302403,"func":"static void xemaclite_aligned_read(u32 *src_ptr, u8 *dest_ptr,\n\t\t\t\t   unsigned length)\n{\n\tu16 *to_u16_ptr, *from_u16_ptr;\n\tu32 *from_u32_ptr;\n\tu32 align_buffer;\n\n\tfrom_u32_ptr = src_ptr;\n\tto_u16_ptr = (u16 *)dest_ptr;\n\n\tfor (; length > 3; length -= 4) {\n\t\t\/* Copy each word into the temporary buffer *\/\n\t\talign_buffer = *from_u32_ptr++;\n\t\tfrom_u16_ptr = (u16 *)&align_buffer;\n\n\t\t\/* Read data from source *\/\n\t\t*to_u16_ptr++ = *from_u16_ptr++;\n\t\t*to_u16_ptr++ = *from_u16_ptr++;\n\t}\n\n\tif (length) {\n\t\tu8 *to_u8_ptr, *from_u8_ptr;\n\n\t\t\/* Set up to read the remaining data *\/\n\t\tto_u8_ptr = (u8 *)to_u16_ptr;\n\t\talign_buffer = *from_u32_ptr++;\n\t\tfrom_u8_ptr = (u8 *)&align_buffer;\n\n\t\t\/* Read the remaining data *\/\n\t\tfor (; length > 0; length--)\n\t\t\t*to_u8_ptr = *from_u8_ptr;\n\t}\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":364375,"func":"static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requested)\n{\n\tstruct dhcp_packet packet;\n\tstruct in_addr addr;\n\n\/*\n * RFC 2131 4.3.2 DHCPREQUEST message\n * ...\n * If the DHCPREQUEST message contains a 'server identifier'\n * option, the message is in response to a DHCPOFFER message.\n * Otherwise, the message is a request to verify or extend an\n * existing lease. If the client uses a 'client identifier'\n * in a DHCPREQUEST message, it MUST use that same 'client identifier'\n * in all subsequent messages. If the client included a list\n * of requested parameters in a DHCPDISCOVER message, it MUST\n * include that list in all subsequent messages.\n *\/\n\t\/* Fill in: op, htype, hlen, cookie, chaddr fields,\n\t * random xid field (we override it below),\n\t * client-id option (unless -C), message type option:\n\t *\/\n\tinit_packet(&packet, DHCPREQUEST);\n\n\tpacket.xid = xid;\n\tudhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested);\n\n\tudhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);\n\n\t\/* Add options: maxsize,\n\t * optionally: hostname, fqdn, vendorclass,\n\t * \"param req\" option according to -O, and options specified with -x\n\t *\/\n\tadd_client_options(&packet);\n\n\taddr.s_addr = requested;\n\tbb_info_msg(\"Sending select for %s...\", inet_ntoa(addr));\n\treturn raw_bcast_from_client_config_ifindex(&packet);\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":240257,"func":"pdf_drop_document_imp(fz_context *ctx, pdf_document *doc)\n{\n\tint i;\n\n\tfz_defer_reap_start(ctx);\n\n\t\/* Type3 glyphs in the glyph cache can contain pdf_obj pointers\n\t * that we are about to destroy. Simplest solution is to bin the\n\t * glyph cache at this point. *\/\n\tfz_try(ctx)\n\t\tfz_purge_glyph_cache(ctx);\n\tfz_catch(ctx)\n\t{\n\t\t\/* Swallow error, but continue dropping *\/\n\t}\n\n\tpdf_drop_js(ctx, doc->js);\n\n\tpdf_drop_xref_sections(ctx, doc);\n\tfz_free(ctx, doc->xref_index);\n\n\tpdf_drop_obj(ctx, doc->focus_obj);\n\tfz_drop_stream(ctx, doc->file);\n\tpdf_drop_crypt(ctx, doc->crypt);\n\n\tpdf_drop_obj(ctx, doc->linear_obj);\n\tif (doc->linear_page_refs)\n\t{\n\t\tfor (i=0; i < doc->linear_page_count; i++)\n\t\t\tpdf_drop_obj(ctx, doc->linear_page_refs[i]);\n\n\t\tfz_free(ctx, doc->linear_page_refs);\n\t}\n\n\tfz_free(ctx, doc->hint_page);\n\tfz_free(ctx, doc->hint_shared_ref);\n\tfz_free(ctx, doc->hint_shared);\n\tfz_free(ctx, doc->hint_obj_offsets);\n\n\tfor (i=0; i < doc->num_type3_fonts; i++)\n\t{\n\t\tfz_try(ctx)\n\t\t\tfz_decouple_type3_font(ctx, doc->type3_fonts[i], (void *)doc);\n\t\tfz_always(ctx)\n\t\t\tfz_drop_font(ctx, doc->type3_fonts[i]);\n\t\tfz_catch(ctx)\n\t\t{\n\t\t\t\/* Swallow error, but continue dropping *\/\n\t\t}\n\t}\n\n\tfz_free(ctx, doc->type3_fonts);\n\n\tpdf_drop_ocg(ctx, doc);\n\tpdf_drop_portfolio(ctx, doc);\n\n\tpdf_empty_store(ctx, doc);\n\n\tpdf_lexbuf_fin(ctx, &doc->lexbuf.base);\n\n\tpdf_drop_resource_tables(ctx, doc);\n\n\tfz_drop_colorspace(ctx, doc->oi);\n\n\tfor (i = 0; i < doc->orphans_count; i++)\n\t\tpdf_drop_obj(ctx, doc->orphans[i]);\n\n\tfz_free(ctx, doc->orphans);\n\n\tfz_free(ctx, doc->rev_page_map);\n\n\tfz_defer_reap_end(ctx);\n}\n","target":0,"code_token_length":500,"total_token_length":736,"max_tokens_setting":1024}
+{"idx":290164,"func":"static void start_monitoring_file_list ( NautilusDirectory * directory ) {\n DirectoryLoadState * state ;\n if ( ! directory -> details -> file_list_monitored ) {\n g_assert ( ! directory -> details -> directory_load_in_progress ) ;\n directory -> details -> file_list_monitored = TRUE ;\n nautilus_file_list_ref ( directory -> details -> file_list ) ;\n }\n if ( directory -> details -> directory_loaded || directory -> details -> directory_load_in_progress != NULL ) {\n return ;\n }\n if ( ! async_job_start ( directory , \"file list\" ) ) {\n return ;\n }\n mark_all_files_unconfirmed ( directory ) ;\n state = g_new0 ( DirectoryLoadState , 1 ) ;\n state -> directory = directory ;\n state -> cancellable = g_cancellable_new ( ) ;\n state -> load_mime_list_hash = istr_set_new ( ) ;\n state -> load_file_count = 0 ;\n g_assert ( directory -> details -> location != NULL ) ;\n state -> load_directory_file = nautilus_directory_get_corresponding_file ( directory ) ;\n state -> load_directory_file -> details -> loading_directory = TRUE ;\n # ifdef DEBUG_LOAD_DIRECTORY g_message ( \"load_directory called to monitor file list of %p\" , directory -> details -> location ) ;\n # endif directory -> details -> directory_load_in_progress = state ;\n g_file_enumerate_children_async ( directory -> details -> location , NAUTILUS_FILE_DEFAULT_ATTRIBUTES , 0 , G_PRIORITY_DEFAULT , state -> cancellable , enumerate_children_callback , state ) ;\n }","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":107814,"func":"static int get_appcontext_input_count_offset(void)\n{\n#define low_offset\t\toffsetof(struct _XtAppStruct, __maxed__nfds)\n#define high_offset\t\toffsetof(struct _XtAppStruct, __maybe__input_max)\n#define n_offsets_max\t(high_offset - low_offset)\/2\n  int i, ofs, n_offsets = 0;\n  int offsets[n_offsets_max] = { 0, };\n\n#define n_inputs_max\t4 \/* number of refinements\/input sources *\/\n  int fd, id, n_inputs = 0;\n  struct { int fd, id; } inputs[n_inputs_max] = { 0, };\n\n  if ((fd = open(\"\/dev\/null\", O_WRONLY)) < 0)\n\treturn 0;\n  if ((id = add_appcontext_input(fd, 0)) < 0) {\n\tclose(fd);\n\treturn 0;\n  }\n  inputs[n_inputs].fd = fd;\n  inputs[n_inputs].id = id;\n  n_inputs++;\n\n  for (ofs = low_offset; ofs < high_offset; ofs += 2) {\n\tif (get_appcontext_input_count_at(ofs) == 1)\n\t  offsets[n_offsets++] = ofs;\n  }\n\n  while (n_inputs < n_inputs_max) {\n\tif ((fd = open(\"\/dev\/null\", O_WRONLY)) < 0)\n\t  break;\n\tif ((id = add_appcontext_input(fd, n_inputs)) < 0) {\n\t  close(fd);\n\t  break;\n\t}\n\tinputs[n_inputs].fd = fd;\n\tinputs[n_inputs].id = id;\n\tn_inputs++;\n\n\tint n = 0;\n\tfor (i = 0; i < n_offsets; i++) {\n\t  if (get_appcontext_input_count_at(offsets[i]) == n_inputs)\n\t\toffsets[n++] = offsets[i];\n\t}\n\tfor (i = n; i < n_offsets; i++)\n\t  offsets[i] = 0;\n\tn_offsets = n;\n  }\n\n  for (i = 0; i < n_inputs; i++) {\n\tXtRemoveInput(inputs[i].id);\n\tclose(inputs[i].fd);\n  }\n\n  if (n_offsets == 1)\n\treturn offsets[0];\n\n#undef n_fds_max\n#undef n_offsets_max\n#undef high_offset\n#undef low_offset\n  return 0;\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":130584,"func":"static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_vmx *vmx = to_vmx(vcpu);\n\tenum emulation_result err = EMULATE_DONE;\n\tint ret = 1;\n\tu32 cpu_exec_ctrl;\n\tbool intr_window_requested;\n\tunsigned count = 130;\n\n\tcpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);\n\tintr_window_requested = cpu_exec_ctrl & CPU_BASED_VIRTUAL_INTR_PENDING;\n\n\twhile (vmx->emulation_required && count-- != 0) {\n\t\tif (intr_window_requested && vmx_interrupt_allowed(vcpu))\n\t\t\treturn handle_interrupt_window(&vmx->vcpu);\n\n\t\tif (kvm_test_request(KVM_REQ_EVENT, vcpu))\n\t\t\treturn 1;\n\n\t\terr = emulate_instruction(vcpu, EMULTYPE_NO_REEXECUTE);\n\n\t\tif (err == EMULATE_USER_EXIT) {\n\t\t\t++vcpu->stat.mmio_exits;\n\t\t\tret = 0;\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (err != EMULATE_DONE) {\n\t\t\tvcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;\n\t\t\tvcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;\n\t\t\tvcpu->run->internal.ndata = 0;\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (vcpu->arch.halt_request) {\n\t\t\tvcpu->arch.halt_request = 0;\n\t\t\tret = kvm_vcpu_halt(vcpu);\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (signal_pending(current))\n\t\t\tgoto out;\n\t\tif (need_resched())\n\t\t\tschedule();\n\t}\n\nout:\n\treturn ret;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":30234,"func":"void read_embedded_server_arguments ( const char * name ) {\n char argument [ 1024 ] , buff [ FN_REFLEN ] , * str = 0 ;\n FILE * file ;\n if ( ! test_if_hard_path ( name ) ) {\n strxmov ( buff , opt_basedir , name , NullS ) ;\n name = buff ;\n }\n fn_format ( buff , name , \"\" , \"\" , MY_UNPACK_FILENAME ) ;\n if ( ! embedded_server_arg_count ) {\n embedded_server_arg_count = 1 ;\n embedded_server_args [ 0 ] = ( char * ) \"\" ;\n }\n if ( ! ( file = my_fopen ( buff , O_RDONLY | FILE_BINARY , MYF ( MY_WME ) ) ) ) die ( \"Failed to open file '%s'\" , buff ) ;\n while ( embedded_server_arg_count < MAX_EMBEDDED_SERVER_ARGS && ( str = fgets ( argument , sizeof ( argument ) , file ) ) ) {\n * ( strend ( str ) - 1 ) = 0 ;\n if ( ! ( embedded_server_args [ embedded_server_arg_count ] = ( char * ) my_strdup ( str , MYF ( MY_WME ) ) ) ) {\n my_fclose ( file , MYF ( 0 ) ) ;\n die ( \"Out of memory\" ) ;\n }\n embedded_server_arg_count ++ ;\n }\n my_fclose ( file , MYF ( 0 ) ) ;\n if ( str ) die ( \"Too many arguments in option file: %s\" , name ) ;\n return ;\n }","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":413501,"func":"static void _slurm_rpc_resv_delete(slurm_msg_t * msg)\n{\n\t\/* init *\/\n\tint error_code = SLURM_SUCCESS;\n\tDEF_TIMERS;\n\treservation_name_msg_t *resv_desc_ptr = (reservation_name_msg_t *)\n\t\tmsg->data;\n\t\/* Locks: read job, write node *\/\n\tslurmctld_lock_t node_write_lock = {\n\t\tNO_LOCK, READ_LOCK, WRITE_LOCK, NO_LOCK, NO_LOCK };\n\tuid_t uid = g_slurm_auth_get_uid(msg->auth_cred,\n\t\t\t\t\t slurmctld_config.auth_info);\n\n\tSTART_TIMER;\n\tdebug2(\"Processing RPC: REQUEST_DELETE_RESERVATION from uid=%d\", uid);\n\tif (!validate_operator(uid)) {\n\t\terror_code = ESLURM_USER_ID_MISSING;\n\t\terror(\"Security violation, DELETE_RESERVATION RPC from uid=%d\",\n\t\t      uid);\n\t} else if (!resv_desc_ptr->name) {\n\t\terror_code = ESLURM_INVALID_PARTITION_NAME;\n\t\terror(\"Invalid DELETE_RESERVATION RPC from uid=%d, name is null\",\n\t\t      uid);\n\t}\n\n\tif (error_code == SLURM_SUCCESS) {\n\t\t\/* do RPC call *\/\n\t\tlock_slurmctld(node_write_lock);\n\t\terror_code = delete_resv(resv_desc_ptr);\n\t\tunlock_slurmctld(node_write_lock);\n\t\tEND_TIMER2(\"_slurm_rpc_resv_delete\");\n\t}\n\n\t\/* return result *\/\n\tif (error_code) {\n\t\tinfo(\"_slurm_rpc_delete_reservation partition=%s: %s\",\n\t\t     resv_desc_ptr->name, slurm_strerror(error_code));\n\t\tslurm_send_rc_msg(msg, error_code);\n\t} else {\n\t\tinfo(\"_slurm_rpc_delete_reservation complete for %s %s\",\n\t\t     resv_desc_ptr->name, TIME_STR);\n\t\tslurm_send_rc_msg(msg, SLURM_SUCCESS);\n\n\t\tqueue_job_scheduler();\n\t}\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":9342,"func":"png_get_copyright(png_structp png_ptr)\n{\n   PNG_UNUSED(png_ptr)  \/* Silence compiler warning about unused png_ptr *\/\n#ifdef PNG_STRING_COPYRIGHT\n      return PNG_STRING_COPYRIGHT\n #else\n #ifdef __STDC__\n    return ((png_charp) PNG_STRING_NEWLINE \\\n     \"libpng version 1.2.52 - November 20, 2014\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1998-2014 Glenn Randers-Pehrson\" PNG_STRING_NEWLINE \\\n      \"Copyright (c) 1996-1997 Andreas Dilger\" PNG_STRING_NEWLINE \\\n      \"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\" \\\n      PNG_STRING_NEWLINE);\n #else\n      return ((png_charp) \"libpng version 1.2.52 - November 20, 2014\\\n      Copyright (c) 1998-2014 Glenn Randers-Pehrson\\\n       Copyright (c) 1996-1997 Andreas Dilger\\\n       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\");\n #endif\n#endif\n}\n","target":1,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":219469,"func":"void CSoundFile::MidiPortamento(CHANNELINDEX nChn, int param, bool doFineSlides)\n{\n\tint actualParam = mpt::abs(param);\n\tint pitchBend = 0;\n\n\n\tif(doFineSlides && actualParam >= 0xE0 && !m_playBehaviour[kOldMIDIPitchBends])\n\t{\n\t\tif(m_PlayState.Chn[nChn].isFirstTick)\n\t\t{\n\t\t\tpitchBend = (actualParam & 0x0F) * sgn(param);\n\t\t\tif(actualParam >= 0xF0)\n\t\t\t{\n\t\t\t\tpitchBend *= 4;\n\t\t\t}\n\t\t}\n\t} else if(!m_PlayState.Chn[nChn].isFirstTick || m_playBehaviour[kOldMIDIPitchBends])\n\t{\n\t\tpitchBend = param * 4;\n\t}\n\n\tif(pitchBend)\n\t{\n#ifndef NO_PLUGINS\n\t\tIMixPlugin *plugin = GetChannelInstrumentPlugin(nChn);\n\t\tif(plugin != nullptr)\n\t\t{\n\t\t\tint8 pwd = 13;\t\/\/ Early OpenMPT legacy... Actually it's not *exactly* 13, but close enough...\n\t\t\tif(m_PlayState.Chn[nChn].pModInstrument != nullptr)\n\t\t\t{\n\t\t\t\tpwd = m_PlayState.Chn[nChn].pModInstrument->midiPWD;\n\t\t\t}\n\t\t\tplugin->MidiPitchBend(GetBestMidiChannel(nChn), pitchBend, pwd);\n\t\t}\n#endif \/\/ NO_PLUGINS\n\t}\n}\n","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":80771,"func":"void t2p_free(T2P* t2p)\n{\n\tint i = 0;\n\n\tif (t2p != NULL) {\n\t\tif(t2p->pdf_xrefoffsets != NULL){\n\t\t\t_TIFFfree( (tdata_t) t2p->pdf_xrefoffsets);\n\t\t}\n\t\tif(t2p->tiff_pages != NULL){\n\t\t\t_TIFFfree( (tdata_t) t2p->tiff_pages);\n\t\t}\n\t\tfor(i=0;i<t2p->tiff_pagecount;i++){\n\t\t\tif(t2p->tiff_tiles[i].tiles_tiles != NULL){\n\t\t\t\t_TIFFfree( (tdata_t) t2p->tiff_tiles[i].tiles_tiles);\n\t\t\t}\n\t\t}\n\t\tif(t2p->tiff_tiles != NULL){\n\t\t\t_TIFFfree( (tdata_t) t2p->tiff_tiles);\n\t\t}\n\t\tif(t2p->pdf_palette != NULL){\n\t\t\t_TIFFfree( (tdata_t) t2p->pdf_palette);\n\t\t}\n#ifdef OJPEG_SUPPORT\n\t\tif(t2p->pdf_ojpegdata != NULL){\n\t\t\t_TIFFfree( (tdata_t) t2p->pdf_ojpegdata);\n\t\t}\n#endif\n\t\t_TIFFfree( (tdata_t) t2p );\n\t}\n\n\treturn;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":260326,"func":"void check_ndpi_udp_flow_func(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow,\n                              NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {\n  void *func = NULL;\n  u_int32_t a;\n  u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx;\n  int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId;\n  NDPI_PROTOCOL_BITMASK detection_bitmask;\n\n  NDPI_SAVE_AS_BITMASK(detection_bitmask, flow->packet.detected_protocol_stack[0]);\n\n  if((proto_id != NDPI_PROTOCOL_UNKNOWN) &&\n     NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,\n\t\t\t  ndpi_str->callback_buffer[proto_index].excluded_protocol_bitmask) == 0 &&\n     NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer[proto_index].detection_bitmask, detection_bitmask) != 0 &&\n     (ndpi_str->callback_buffer[proto_index].ndpi_selection_bitmask & *ndpi_selection_packet) ==\n     ndpi_str->callback_buffer[proto_index].ndpi_selection_bitmask) {\n    if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) &&\n       (ndpi_str->proto_defaults[flow->guessed_protocol_id].func != NULL))\n      ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow),\n\tfunc = ndpi_str->proto_defaults[flow->guessed_protocol_id].func;\n  }\n\n  if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {\n    for (a = 0; a < ndpi_str->callback_buffer_size_udp; a++) {\n      if((func != ndpi_str->callback_buffer_udp[a].func) &&\n\t (ndpi_str->callback_buffer_udp[a].ndpi_selection_bitmask & *ndpi_selection_packet) ==\n\t ndpi_str->callback_buffer_udp[a].ndpi_selection_bitmask &&\n\t NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,\n\t\t\t      ndpi_str->callback_buffer_udp[a].excluded_protocol_bitmask) == 0 &&\n\t NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_udp[a].detection_bitmask, detection_bitmask) != 0) {\n\tndpi_str->callback_buffer_udp[a].func(ndpi_str, flow);\n\n\t\/\/ NDPI_LOG_DBG(ndpi_str, \"[UDP,CALL] dissector of protocol as callback_buffer idx =  %d\\n\",a);\n\tif(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)\n\t  break; \/* Stop after detecting the first protocol *\/\n      } else if(_ndpi_debug_callbacks)\n\tNDPI_LOG_DBG2(ndpi_str, \"[UDP,SKIP] dissector of protocol as callback_buffer idx =  %d\\n\", a);\n    }\n  }\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":498501,"func":"TEST_F(RouterTest, RetryUpstreamReset) {\n  NiceMock<Http::MockRequestEncoder> encoder1;\n  Http::ResponseDecoder* response_decoder = nullptr;\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _))\n      .WillOnce(Invoke(\n          [&](Http::ResponseDecoder& decoder,\n              Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* {\n            response_decoder = &decoder;\n            callbacks.onPoolReady(encoder1, cm_.thread_local_cluster_.conn_pool_.host_,\n                                  upstream_stream_info_, Http::Protocol::Http10);\n            return nullptr;\n          }));\n  expectResponseTimerCreate();\n\n  Http::TestRequestHeaderMapImpl headers{{\"x-envoy-retry-on\", \"5xx\"}, {\"x-envoy-internal\", \"true\"}};\n  HttpTestUtility::addDefaultHeaders(headers);\n  router_.decodeHeaders(headers, false);\n  EXPECT_CALL(*router_.retry_state_, enabled()).WillOnce(Return(true));\n  EXPECT_CALL(callbacks_, addDecodedData(_, _));\n  Buffer::OwnedImpl body(\"test body\");\n  router_.decodeData(body, true);\n  EXPECT_EQ(1U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n\n  router_.retry_state_->expectResetRetry();\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,\n              putResult(Upstream::Outlier::Result::LocalOriginConnectFailed, _));\n  encoder1.stream_.resetStream(Http::StreamResetReason::RemoteReset);\n\n  \/\/ We expect this reset to kick off a new request.\n  NiceMock<Http::MockRequestEncoder> encoder2;\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _))\n      .WillOnce(Invoke(\n          [&](Http::ResponseDecoder& decoder,\n              Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* {\n            response_decoder = &decoder;\n            EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,\n                        putResult(Upstream::Outlier::Result::LocalOriginConnectSuccess,\n                                  absl::optional<uint64_t>(absl::nullopt)));\n            callbacks.onPoolReady(encoder2, cm_.thread_local_cluster_.conn_pool_.host_,\n                                  upstream_stream_info_, Http::Protocol::Http10);\n            return nullptr;\n          }));\n  router_.retry_state_->callback_();\n  EXPECT_EQ(2U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n  EXPECT_TRUE(verifyHostUpstreamStats(0, 1));\n\n  \/\/ Normal response.\n  EXPECT_CALL(*router_.retry_state_, shouldRetryHeaders(_, _)).WillOnce(Return(RetryStatus::No));\n  Http::ResponseHeaderMapPtr response_headers(\n      new Http::TestResponseHeaderMapImpl{{\":status\", \"200\"}});\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,\n              putHttpResponseCode(200));\n  response_decoder->decodeHeaders(std::move(response_headers), true);\n  EXPECT_TRUE(verifyHostUpstreamStats(1, 1));\n}","target":0,"code_token_length":670,"total_token_length":906,"max_tokens_setting":1024}
+{"idx":257258,"func":"static int calc_slice_sizes ( VC2EncContext * s ) {\n int i , j , slice_x , slice_y , bytes_left = 0 ;\n int bytes_top [ SLICE_REDIST_TOTAL ] = {\n 0 }\n ;\n int64_t total_bytes_needed = 0 ;\n int slice_redist_range = FFMIN ( SLICE_REDIST_TOTAL , s -> num_x * s -> num_y ) ;\n SliceArgs * enc_args = s -> slice_args ;\n SliceArgs * top_loc [ SLICE_REDIST_TOTAL ] = {\n NULL }\n ;\n init_quant_matrix ( s ) ;\n for ( slice_y = 0 ;\n slice_y < s -> num_y ;\n slice_y ++ ) {\n for ( slice_x = 0 ;\n slice_x < s -> num_x ;\n slice_x ++ ) {\n SliceArgs * args = & enc_args [ s -> num_x * slice_y + slice_x ] ;\n args -> ctx = s ;\n args -> x = slice_x ;\n args -> y = slice_y ;\n args -> bits_ceil = s -> slice_max_bytes << 3 ;\n args -> bits_floor = s -> slice_min_bytes << 3 ;\n memset ( args -> cache , 0 , s -> q_ceil * sizeof ( * args -> cache ) ) ;\n }\n }\n s -> avctx -> execute ( s -> avctx , rate_control , enc_args , NULL , s -> num_x * s -> num_y , sizeof ( SliceArgs ) ) ;\n for ( i = 0 ;\n i < s -> num_x * s -> num_y ;\n i ++ ) {\n SliceArgs * args = & enc_args [ i ] ;\n bytes_left += s -> slice_max_bytes - args -> bytes ;\n for ( j = 0 ;\n j < slice_redist_range ;\n j ++ ) {\n if ( args -> bytes > bytes_top [ j ] ) {\n bytes_top [ j ] = args -> bytes ;\n top_loc [ j ] = args ;\n break ;\n }\n }\n }\n while ( 1 ) {\n int distributed = 0 ;\n for ( i = 0 ;\n i < slice_redist_range ;\n i ++ ) {\n SliceArgs * args ;\n int bits , bytes , diff , prev_bytes , new_idx ;\n if ( bytes_left <= 0 ) break ;\n if ( ! top_loc [ i ] || ! top_loc [ i ] -> quant_idx ) break ;\n args = top_loc [ i ] ;\n prev_bytes = args -> bytes ;\n new_idx = FFMAX ( args -> quant_idx - 1 , 0 ) ;\n bits = count_hq_slice ( args , new_idx ) ;\n bytes = SSIZE_ROUND ( bits >> 3 ) ;\n diff = bytes - prev_bytes ;\n if ( ( bytes_left - diff ) > 0 ) {\n args -> quant_idx = new_idx ;\n args -> bytes = bytes ;\n bytes_left -= diff ;\n distributed ++ ;\n }\n }\n if ( ! distributed ) break ;\n }\n for ( i = 0 ;\n i < s -> num_x * s -> num_y ;\n i ++ ) {\n SliceArgs * args = & enc_args [ i ] ;\n total_bytes_needed += args -> bytes ;\n s -> q_avg = ( s -> q_avg + args -> quant_idx ) \/ 2 ;\n }\n return total_bytes_needed ;\n }","target":0,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":138568,"func":"static int compat_getdrvstat(int drive, bool poll,\n\t\t\t    struct compat_floppy_drive_struct __user *arg)\n{\n\tstruct compat_floppy_drive_struct v;\n\n\tmemset(&v, 0, sizeof(struct compat_floppy_drive_struct));\n\tmutex_lock(&floppy_mutex);\n\n\tif (poll) {\n\t\tif (lock_fdc(drive))\n\t\t\tgoto Eintr;\n\t\tif (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)\n\t\t\tgoto Eintr;\n\t\tprocess_fd_request();\n\t}\n\tv.spinup_date = UDRS->spinup_date;\n\tv.select_date = UDRS->select_date;\n\tv.first_read_date = UDRS->first_read_date;\n\tv.probed_format = UDRS->probed_format;\n\tv.track = UDRS->track;\n\tv.maxblock = UDRS->maxblock;\n\tv.maxtrack = UDRS->maxtrack;\n\tv.generation = UDRS->generation;\n\tv.keep_data = UDRS->keep_data;\n\tv.fd_ref = UDRS->fd_ref;\n\tv.fd_device = UDRS->fd_device;\n\tv.last_checked = UDRS->last_checked;\n\tv.dmabuf = (uintptr_t)UDRS->dmabuf;\n\tv.bufblocks = UDRS->bufblocks;\n\tmutex_unlock(&floppy_mutex);\n\n\tif (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_struct)))\n\t\treturn -EFAULT;\n\treturn 0;\nEintr:\n\tmutex_unlock(&floppy_mutex);\n\treturn -EINTR;\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":119893,"func":"static int try_open_file(Jsi_Interp *interp, FileObj *udf, Jsi_Value *args)\n{\n    int ret = JSI_ERROR;\n    fileObjErase(udf);\n    \/\/ TODO: stdin, stdout, stderr, etc.\n    Jsi_Value *fname = Jsi_ValueArrayIndex(interp, args, 0);\n    if (fname && Jsi_ValueIsString(interp, fname)) {\n        Jsi_Value *vmode = Jsi_ValueArrayIndex(interp, args, 1);\n        const char *mode = NULL;\n        const char *fstr = Jsi_ValueString(interp, fname, NULL);\n        if (vmode && Jsi_ValueIsString(interp,vmode)) {\n            mode = Jsi_ValueString(interp, vmode, NULL);\n        }\n        int writ = (mode && (Jsi_Strchr(mode,'w')||Jsi_Strchr(mode,'+')));\n        int aflag = (writ ? JSI_INTACCESS_WRITE : JSI_INTACCESS_READ);\n        if (interp->isSafe && Jsi_InterpAccess(interp, fname, aflag) != JSI_OK)\n            return Jsi_LogError(\"Safe open failed\");\n        char *rmode = Jsi_Strdup(mode ? mode : \"r\");\n        Jsi_Channel chan = Jsi_Open(interp, fname, rmode);\n        if (chan) {\n            udf->chan = chan;\n            udf->fname = fname;\n            udf->interp = interp;\n            Jsi_IncrRefCount(interp, fname);\n            udf->filename = Jsi_Strdup(fstr);\n            udf->mode = Jsi_Strdup(rmode);\n            ret = JSI_OK;\n        }\n        Jsi_Free(rmode);\n    }\n    return ret;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":175564,"func":"bool InputMethodIBus::DispatchKeyEvent(const base::NativeEvent& native_event) {\n  DCHECK(native_event && (native_event->type == KeyPress ||\n                          native_event->type == KeyRelease));\n  DCHECK(system_toplevel_window_focused());\n\n  uint32 ibus_keyval = 0;\n  uint32 ibus_keycode = 0;\n  uint32 ibus_state = 0;\n  IBusKeyEventFromNativeKeyEvent(\n      native_event,\n      &ibus_keyval, &ibus_keycode, &ibus_state);\n\n  if (!context_focused_ || !GetEngine() ||\n      GetTextInputType() == TEXT_INPUT_TYPE_PASSWORD ) {\n    if (native_event->type == KeyPress) {\n      if (ExecuteCharacterComposer(ibus_keyval, ibus_keycode, ibus_state)) {\n        ProcessKeyEventPostIME(native_event, ibus_state, true);\n        return true;\n      }\n      ProcessUnfilteredKeyPressEvent(native_event, ibus_state);\n    } else {\n      DispatchKeyEventPostIME(native_event);\n    }\n    return true;\n  }\n\n  pending_key_events_.insert(current_keyevent_id_);\n\n  XEvent* event = new XEvent;\n  *event = *native_event;\n  GetEngine()->ProcessKeyEvent(\n      ibus_keyval,\n      ibus_keycode,\n      ibus_state,\n      base::Bind(&InputMethodIBus::ProcessKeyEventDone,\n                 weak_ptr_factory_.GetWeakPtr(),\n                 current_keyevent_id_,\n                 base::Owned(event),  \/\/ Pass the ownership of |event|.\n                 ibus_keyval,\n                 ibus_keycode,\n                 ibus_state));\n\n  ++current_keyevent_id_;\n\n  suppress_next_result_ = false;\n  return true;\n}\n","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":485840,"func":"sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep,\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\t\tvoid *arg,\n\t\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sctp_ulpevent *ev;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the ERROR chunk has a valid length. *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\twhile (chunk->chunk_end > chunk->skb->data) {\n\t\tev = sctp_ulpevent_make_remote_error(asoc, chunk, 0,\n\t\t\t\t\t\t     GFP_ATOMIC);\n\t\tif (!ev)\n\t\t\tgoto nomem;\n\n\t\tif (!sctp_add_cmd(commands, SCTP_CMD_EVENT_ULP,\n\t\t\t\t  SCTP_ULPEVENT(ev))) {\n\t\t\tsctp_ulpevent_free(ev);\n\t\t\tgoto nomem;\n\t\t}\n\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,\n\t\t\t\tSCTP_CHUNK(chunk));\t\n\t}\n\treturn SCTP_DISPOSITION_CONSUME;\n\nnomem:\n\treturn SCTP_DISPOSITION_NOMEM;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":401262,"func":"static void macsec_changelink_common(struct net_device *dev,\n\t\t\t\t     struct nlattr *data[])\n{\n\tstruct macsec_secy *secy;\n\tstruct macsec_tx_sc *tx_sc;\n\n\tsecy = &macsec_priv(dev)->secy;\n\ttx_sc = &secy->tx_sc;\n\n\tif (data[IFLA_MACSEC_ENCODING_SA]) {\n\t\tstruct macsec_tx_sa *tx_sa;\n\n\t\ttx_sc->encoding_sa = nla_get_u8(data[IFLA_MACSEC_ENCODING_SA]);\n\t\ttx_sa = rtnl_dereference(tx_sc->sa[tx_sc->encoding_sa]);\n\n\t\tsecy->operational = tx_sa && tx_sa->active;\n\t}\n\n\tif (data[IFLA_MACSEC_WINDOW])\n\t\tsecy->replay_window = nla_get_u32(data[IFLA_MACSEC_WINDOW]);\n\n\tif (data[IFLA_MACSEC_ENCRYPT])\n\t\ttx_sc->encrypt = !!nla_get_u8(data[IFLA_MACSEC_ENCRYPT]);\n\n\tif (data[IFLA_MACSEC_PROTECT])\n\t\tsecy->protect_frames = !!nla_get_u8(data[IFLA_MACSEC_PROTECT]);\n\n\tif (data[IFLA_MACSEC_INC_SCI])\n\t\ttx_sc->send_sci = !!nla_get_u8(data[IFLA_MACSEC_INC_SCI]);\n\n\tif (data[IFLA_MACSEC_ES])\n\t\ttx_sc->end_station = !!nla_get_u8(data[IFLA_MACSEC_ES]);\n\n\tif (data[IFLA_MACSEC_SCB])\n\t\ttx_sc->scb = !!nla_get_u8(data[IFLA_MACSEC_SCB]);\n\n\tif (data[IFLA_MACSEC_REPLAY_PROTECT])\n\t\tsecy->replay_protect = !!nla_get_u8(data[IFLA_MACSEC_REPLAY_PROTECT]);\n\n\tif (data[IFLA_MACSEC_VALIDATION])\n\t\tsecy->validate_frames = nla_get_u8(data[IFLA_MACSEC_VALIDATION]);\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":353411,"func":"dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)\n{\n\tint i=-1;\n\thm_fragment *frag = NULL;\n\tpitem *item = NULL;\n\tunsigned char seq64be[8];\n\tunsigned long frag_len = msg_hdr->frag_len;\n\n\tif ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len)\n\t\tgoto err;\n\n\t\/* Try to find item in queue, to prevent duplicate entries *\/\n\tmemset(seq64be,0,sizeof(seq64be));\n\tseq64be[6] = (unsigned char) (msg_hdr->seq>>8);\n\tseq64be[7] = (unsigned char) msg_hdr->seq;\n\titem = pqueue_find(s->d1->buffered_messages, seq64be);\n\t\n\t\/* Discard the message if sequence number was already there, is\n\t * too far in the future, already in the queue or if we received\n\t * a FINISHED before the SERVER_HELLO, which then must be a stale\n\t * retransmit.\n\t *\/\n\tif (msg_hdr->seq <= s->d1->handshake_read_seq ||\n\t\tmsg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||\n\t\t(s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))\n\t\t{\n\t\tunsigned char devnull [256];\n\n\t\twhile (frag_len)\n\t\t\t{\n\t\t\ti = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,\n\t\t\t\tdevnull,\n\t\t\t\tfrag_len>sizeof(devnull)?sizeof(devnull):frag_len,0);\n\t\t\tif (i<=0) goto err;\n\t\t\tfrag_len -= i;\n\t\t\t}\n\t\t}\n\n\tif (frag_len)\n\t\t{\n\t\tfrag = dtls1_hm_fragment_new(frag_len);\n\t\tif ( frag == NULL)\n\t\t\tgoto err;\n\n\t\tmemcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));\n\n\t\t\/* read the body of the fragment (header has already been read *\/\n\t\ti = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,\n\t\t\tfrag->fragment,frag_len,0);\n\t\tif (i<=0 || (unsigned long)i!=frag_len)\n\t\t\tgoto err;\n\n\t\tmemset(seq64be,0,sizeof(seq64be));\n\t\tseq64be[6] = (unsigned char)(msg_hdr->seq>>8);\n\t\tseq64be[7] = (unsigned char)(msg_hdr->seq);\n\n\t\titem = pitem_new(seq64be, frag);\n\t\tif ( item == NULL)\n\t\t\tgoto err;\n\n\t\tpqueue_insert(s->d1->buffered_messages, item);\n\t\t}\n\n\treturn DTLS1_HM_FRAGMENT_RETRY;\n\nerr:\n\tif ( frag != NULL) dtls1_hm_fragment_free(frag);\n\tif ( item != NULL) OPENSSL_free(item);\n\t*ok = 0;\n\treturn i;\n\t}","target":1,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":332020,"func":"static void gic_complete_irq(gic_state * s, int cpu, int irq)\n\n{\n\n    int update = 0;\n\n    int cm = 1 << cpu;\n\n    DPRINTF(\"EOI %d\\n\", irq);\n\n    if (s->running_irq[cpu] == 1023)\n\n        return; \/* No active IRQ.  *\/\n\n    if (irq != 1023) {\n\n        \/* Mark level triggered interrupts as pending if they are still\n\n           raised.  *\/\n\n        if (!GIC_TEST_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)\n\n                && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {\n\n            DPRINTF(\"Set %d pending mask %x\\n\", irq, cm);\n\n            GIC_SET_PENDING(irq, cm);\n\n            update = 1;\n\n        }\n\n    }\n\n    if (irq != s->running_irq[cpu]) {\n\n        \/* Complete an IRQ that is not currently running.  *\/\n\n        int tmp = s->running_irq[cpu];\n\n        while (s->last_active[tmp][cpu] != 1023) {\n\n            if (s->last_active[tmp][cpu] == irq) {\n\n                s->last_active[tmp][cpu] = s->last_active[irq][cpu];\n\n                break;\n\n            }\n\n            tmp = s->last_active[tmp][cpu];\n\n        }\n\n        if (update) {\n\n            gic_update(s);\n\n        }\n\n    } else {\n\n        \/* Complete the current running IRQ.  *\/\n\n        gic_set_running_irq(s, cpu, s->last_active[s->running_irq[cpu]][cpu]);\n\n    }\n\n}\n","target":1,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":503238,"func":"TEST_F(OptimizePipeline, InternalizeProjectAndPushdownAddFields) {\n    auto unpackSpecObj = fromjson(\n        \"{$_internalUnpackBucket: { exclude: [], timeField: 'time', metaField: 'myMeta', \"\n        \"bucketMaxSpanSeconds: 3600}}\");\n    auto projectSpecObj = fromjson(\"{$project: {x: true, y: true, myMeta: true}}\");\n    auto addFieldsSpec = fromjson(\"{$addFields: {newMeta: '$myMeta.a'}}\");\n\n    auto pipeline =\n        Pipeline::parse(makeVector(unpackSpecObj, projectSpecObj, addFieldsSpec), getExpCtx());\n\n    pipeline->optimizePipeline();\n\n    \/\/ We should internalize the $project and push down the $addFields.\n    auto serialized = pipeline->serializeToBson();\n    ASSERT_EQ(2u, serialized.size());\n    ASSERT_BSONOBJ_EQ(fromjson(\"{$addFields: {newMeta: '$meta.a'}}\"), serialized[0]);\n    ASSERT_BSONOBJ_EQ(fromjson(\"{$_internalUnpackBucket: { include: ['_id', 'newMeta', 'x', 'y', \"\n                               \"'myMeta'], timeField: 'time', metaField: 'myMeta', \"\n                               \"bucketMaxSpanSeconds: 3600, computedMetaProjFields: ['newMeta']}}\"),\n                      serialized[1]);\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":16576,"func":"static ActivationAction get_executable_text_file_action ( GtkWindow * parent_window , NautilusFile * file ) {\n GtkDialog * dialog ;\n char * file_name ;\n char * prompt ;\n char * detail ;\n int preferences_value ;\n int response ;\n g_assert ( nautilus_file_contains_text ( file ) ) ;\n preferences_value = g_settings_get_enum ( nautilus_preferences , NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION ) ;\n switch ( preferences_value ) {\n case NAUTILUS_EXECUTABLE_TEXT_LAUNCH : {\n return ACTIVATION_ACTION_LAUNCH ;\n }\n case NAUTILUS_EXECUTABLE_TEXT_DISPLAY : {\n return ACTIVATION_ACTION_OPEN_IN_APPLICATION ;\n }\n case NAUTILUS_EXECUTABLE_TEXT_ASK : {\n }\n break ;\n default : g_warning ( \"Unknown value %d for NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION\" , preferences_value ) ;\n }\n file_name = nautilus_file_get_display_name ( file ) ;\n prompt = g_strdup_printf ( _ ( \"Do you want to run \u201c%s\u201d, or display its contents?\" ) , file_name ) ;\n detail = g_strdup_printf ( _ ( \"\u201c%s\u201d is an executable text file.\" ) , file_name ) ;\n g_free ( file_name ) ;\n dialog = eel_create_question_dialog ( prompt , detail , _ ( \"Run in _Terminal\" ) , RESPONSE_RUN_IN_TERMINAL , _ ( \"_Display\" ) , RESPONSE_DISPLAY , parent_window ) ;\n gtk_dialog_add_button ( dialog , _ ( \"_Cancel\" ) , GTK_RESPONSE_CANCEL ) ;\n gtk_dialog_add_button ( dialog , _ ( \"_Run\" ) , RESPONSE_RUN ) ;\n gtk_dialog_set_default_response ( dialog , GTK_RESPONSE_CANCEL ) ;\n gtk_widget_show ( GTK_WIDGET ( dialog ) ) ;\n g_free ( prompt ) ;\n g_free ( detail ) ;\n response = gtk_dialog_run ( dialog ) ;\n gtk_widget_destroy ( GTK_WIDGET ( dialog ) ) ;\n switch ( response ) {\n case RESPONSE_RUN : {\n return ACTIVATION_ACTION_LAUNCH ;\n }\n case RESPONSE_RUN_IN_TERMINAL : {\n return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL ;\n }\n case RESPONSE_DISPLAY : {\n return ACTIVATION_ACTION_OPEN_IN_APPLICATION ;\n }\n default : return ACTIVATION_ACTION_DO_NOTHING ;\n }\n }","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":439063,"func":"static void SFDDumpAnchorPoints(FILE *sfd,AnchorPoint *ap) {\n    if (ap==NULL) {\n\treturn;\n    }\n\n    for ( ; ap!=NULL; ap=ap->next )\n    {\n\tfprintf( sfd, \"AnchorPoint: \" );\n\tSFDDumpUTF7Str(sfd,ap->anchor->name);\n\tputc(' ',sfd);\n\tfprintf( sfd, \"%g %g %s %d\",\n\t\t(double) ap->me.x, (double) ap->me.y,\n\t\tap->type==at_centry ? \"entry\" :\n\t\tap->type==at_cexit ? \"exit\" :\n\t\tap->type==at_mark ? \"mark\" :\n\t\tap->type==at_basechar ? \"basechar\" :\n\t\tap->type==at_baselig ? \"baselig\" : \"basemark\",\n\t\tap->lig_index );\n\tif ( ap->xadjust.corrections!=NULL || ap->yadjust.corrections!=NULL ) {\n\t    putc(' ',sfd);\n\t    SFDDumpDeviceTable(sfd,&ap->xadjust);\n\t    putc(' ',sfd);\n\t    SFDDumpDeviceTable(sfd,&ap->yadjust);\n\t} else\n\tif ( ap->has_ttf_pt )\n\t    fprintf( sfd, \" %d\", ap->ttf_pt_index );\n\tputc('\\n',sfd);\n    }\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":492912,"func":"static void ssl_write_cid_ext( mbedtls_ssl_context *ssl,\n                               unsigned char *buf,\n                               size_t *olen )\n{\n    unsigned char *p = buf;\n    size_t ext_len;\n    const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN;\n\n    *olen = 0;\n\n    \/* Skip writing the extension if we don't want to use it or if\n     * the client hasn't offered it. *\/\n    if( ssl->handshake->cid_in_use == MBEDTLS_SSL_CID_DISABLED )\n        return;\n\n    \/* ssl->own_cid_len is at most MBEDTLS_SSL_CID_IN_LEN_MAX\n     * which is at most 255, so the increment cannot overflow. *\/\n    if( end < p || (size_t)( end - p ) < (unsigned)( ssl->own_cid_len + 5 ) )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"buffer too small\" ) );\n        return;\n    }\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"server hello, adding CID extension\" ) );\n\n    \/*\n     * Quoting draft-ietf-tls-dtls-connection-id-05\n     * https:\/\/tools.ietf.org\/html\/draft-ietf-tls-dtls-connection-id-05\n     *\n     *   struct {\n     *      opaque cid<0..2^8-1>;\n     *   } ConnectionId;\n    *\/\n    MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_CID, p, 0 );\n    p += 2;\n    ext_len = (size_t) ssl->own_cid_len + 1;\n    MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 );\n    p += 2;\n\n    *p++ = (uint8_t) ssl->own_cid_len;\n    memcpy( p, ssl->own_cid, ssl->own_cid_len );\n\n    *olen = ssl->own_cid_len + 5;\n}","target":0,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":345512,"func":"static void fix_hostname(struct SessionHandle *data,\n                         struct connectdata *conn, struct hostname *host)\n{\n  size_t len;\n\n#ifndef USE_LIBIDN\n  (void)data;\n  (void)conn;\n#elif defined(CURL_DISABLE_VERBOSE_STRINGS)\n  (void)conn;\n#endif\n\n  \/* set the name we use to display the host name *\/\n  host->dispname = host->name;\n\n  len = strlen(host->name);\n  if(host->name[len-1] == '.')\n    \/* strip off a single trailing dot if present, primarily for SNI but\n       there's no use for it *\/\n    host->name[len-1]=0;\n\n  if(!is_ASCII_name(host->name)) {\n#ifdef USE_LIBIDN\n  \/*************************************************************\n   * Check name for non-ASCII and convert hostname to ACE form.\n   *************************************************************\/\n  if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {\n    char *ace_hostname = NULL;\n    int rc = idna_to_ascii_lz(host->name, &ace_hostname, 0);\n    infof (data, \"Input domain encoded as `%s'\\n\",\n           stringprep_locale_charset ());\n    if(rc != IDNA_SUCCESS)\n      infof(data, \"Failed to convert %s to ACE; %s\\n\",\n            host->name, Curl_idn_strerror(conn, rc));\n    else {\n      \/* tld_check_name() displays a warning if the host name contains\n         \"illegal\" characters for this TLD *\/\n      (void)tld_check_name(data, ace_hostname);\n\n      host->encalloc = ace_hostname;\n      \/* change the name pointer to point to the encoded hostname *\/\n      host->name = host->encalloc;\n    }\n  }\n#elif defined(USE_WIN32_IDN)\n  \/*************************************************************\n   * Check name for non-ASCII and convert hostname to ACE form.\n   *************************************************************\/\n    char *ace_hostname = NULL;\n    int rc = curl_win32_idn_to_ascii(host->name, &ace_hostname);\n    if(rc == 0)\n      infof(data, \"Failed to convert %s to ACE;\\n\",\n            host->name);\n    else {\n      host->encalloc = ace_hostname;\n      \/* change the name pointer to point to the encoded hostname *\/\n      host->name = host->encalloc;\n    }\n#else\n    infof(data, \"IDN support not present, can't parse Unicode domains\\n\");\n#endif\n  }\n}","target":1,"code_token_length":515,"total_token_length":751,"max_tokens_setting":1024}
+{"idx":142571,"func":"static int decode_level2_header(LHAFileHeader **header, LHAInputStream *stream)\n{\n\tunsigned int header_len;\n\n\theader_len = lha_decode_uint16(&RAW_DATA(header, 0));\n\n\tif (header_len < LEVEL_2_HEADER_LEN) {\n\t\treturn 0;\n\t}\n\n\t\/\/ Read the full header.\n\n\tif (!extend_raw_data(header, stream,\n\t                     header_len - RAW_DATA_LEN(header))) {\n\t\treturn 0;\n\t}\n\n\t\/\/ Compression method:\n\n\tmemcpy((*header)->compress_method, &RAW_DATA(header, 2), 5);\n\t(*header)->compress_method[5] = '\\0';\n\n\t\/\/ File lengths:\n\n\t(*header)->compressed_length = lha_decode_uint32(&RAW_DATA(header, 7));\n\t(*header)->length = lha_decode_uint32(&RAW_DATA(header, 11));\n\n\t\/\/ Timestamp. Unlike level 0\/1, this is a Unix-style timestamp.\n\n\t(*header)->timestamp = lha_decode_uint32(&RAW_DATA(header, 15));\n\n\t\/\/ CRC.\n\n\t(*header)->crc = lha_decode_uint16(&RAW_DATA(header, 21));\n\n\t\/\/ OS type:\n\n\t(*header)->os_type = RAW_DATA(header, 23);\n\n\t\/\/ LHA for OS-9\/68k generates broken level 2 archives: the header\n\t\/\/ length field is the length of the remainder of the header, not\n\t\/\/ the complete header length. As a result it's two bytes too\n\t\/\/ short. We can use the OS type field to detect these archives\n\t\/\/ and compensate.\n\n\tif ((*header)->os_type == LHA_OS_TYPE_OS9_68K) {\n\t\tif (!extend_raw_data(header, stream, 2)) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif (!decode_extended_headers(header, 24)) {\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":32862,"func":"OPJ_UINT32 opj_tcd_get_decoded_tile_size ( opj_tcd_t *p_tcd )\n{\n        OPJ_UINT32 i;\n        OPJ_UINT32 l_data_size = 0;\n        opj_image_comp_t * l_img_comp = 00;\n        opj_tcd_tilecomp_t * l_tile_comp = 00;\n        opj_tcd_resolution_t * l_res = 00;\n        OPJ_UINT32 l_size_comp, l_remaining;\n\n        l_tile_comp = p_tcd->tcd_image->tiles->comps;\n        l_img_comp = p_tcd->image->comps;\n\n        for (i=0;i<p_tcd->image->numcomps;++i) {\n                l_size_comp = l_img_comp->prec >> 3; \/*(\/ 8)*\/\n                l_remaining = l_img_comp->prec & 7;  \/* (%8) *\/\n\n                if(l_remaining) {\n                        ++l_size_comp;\n                }\n\n                if (l_size_comp == 3) {\n                        l_size_comp = 4;\n                }\n\n                l_res = l_tile_comp->resolutions + l_tile_comp->minimum_num_resolutions - 1;\n                l_data_size += l_size_comp * (OPJ_UINT32)((l_res->x1 - l_res->x0) * (l_res->y1 - l_res->y0));\n                ++l_img_comp;\n                ++l_tile_comp;\n        }\n\n        return l_data_size;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":102226,"func":"int snd_interval_ratnum(struct snd_interval *i,\n\t\t\tunsigned int rats_count, const struct snd_ratnum *rats,\n\t\t\tunsigned int *nump, unsigned int *denp)\n{\n\tunsigned int best_num, best_den;\n\tint best_diff;\n\tunsigned int k;\n\tstruct snd_interval t;\n\tint err;\n\tunsigned int result_num, result_den;\n\tint result_diff;\n\n\tbest_num = best_den = best_diff = 0;\n\tfor (k = 0; k < rats_count; ++k) {\n\t\tunsigned int num = rats[k].num;\n\t\tunsigned int den;\n\t\tunsigned int q = i->min;\n\t\tint diff;\n\t\tif (q == 0)\n\t\t\tq = 1;\n\t\tden = div_up(num, q);\n\t\tif (den < rats[k].den_min)\n\t\t\tcontinue;\n\t\tif (den > rats[k].den_max)\n\t\t\tden = rats[k].den_max;\n\t\telse {\n\t\t\tunsigned int r;\n\t\t\tr = (den - rats[k].den_min) % rats[k].den_step;\n\t\t\tif (r != 0)\n\t\t\t\tden -= r;\n\t\t}\n\t\tdiff = num - q * den;\n\t\tif (diff < 0)\n\t\t\tdiff = -diff;\n\t\tif (best_num == 0 ||\n\t\t    diff * best_den < best_diff * den) {\n\t\t\tbest_diff = diff;\n\t\t\tbest_den = den;\n\t\t\tbest_num = num;\n\t\t}\n\t}\n\tif (best_den == 0) {\n\t\ti->empty = 1;\n\t\treturn -EINVAL;\n\t}\n\tt.min = div_down(best_num, best_den);\n\tt.openmin = !!(best_num % best_den);\n\t\n\tresult_num = best_num;\n\tresult_diff = best_diff;\n\tresult_den = best_den;\n\tbest_num = best_den = best_diff = 0;\n\tfor (k = 0; k < rats_count; ++k) {\n\t\tunsigned int num = rats[k].num;\n\t\tunsigned int den;\n\t\tunsigned int q = i->max;\n\t\tint diff;\n\t\tif (q == 0) {\n\t\t\ti->empty = 1;\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tden = div_down(num, q);\n\t\tif (den > rats[k].den_max)\n\t\t\tcontinue;\n\t\tif (den < rats[k].den_min)\n\t\t\tden = rats[k].den_min;\n\t\telse {\n\t\t\tunsigned int r;\n\t\t\tr = (den - rats[k].den_min) % rats[k].den_step;\n\t\t\tif (r != 0)\n\t\t\t\tden += rats[k].den_step - r;\n\t\t}\n\t\tdiff = q * den - num;\n\t\tif (diff < 0)\n\t\t\tdiff = -diff;\n\t\tif (best_num == 0 ||\n\t\t    diff * best_den < best_diff * den) {\n\t\t\tbest_diff = diff;\n\t\t\tbest_den = den;\n\t\t\tbest_num = num;\n\t\t}\n\t}\n\tif (best_den == 0) {\n\t\ti->empty = 1;\n\t\treturn -EINVAL;\n\t}\n\tt.max = div_up(best_num, best_den);\n\tt.openmax = !!(best_num % best_den);\n\tt.integer = 0;\n\terr = snd_interval_refine(i, &t);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (snd_interval_single(i)) {\n\t\tif (best_diff * result_den < result_diff * best_den) {\n\t\t\tresult_num = best_num;\n\t\t\tresult_den = best_den;\n\t\t}\n\t\tif (nump)\n\t\t\t*nump = result_num;\n\t\tif (denp)\n\t\t\t*denp = result_den;\n\t}\n\treturn err;\n}","target":0,"code_token_length":761,"total_token_length":997,"max_tokens_setting":1024}
+{"idx":484440,"func":"int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tu64 old_efer = vcpu->arch.efer;\n\tvcpu->arch.efer = efer;\n\n\tif (!npt_enabled) {\n\t\t\/* Shadow paging assumes NX to be available.  *\/\n\t\tefer |= EFER_NX;\n\n\t\tif (!(efer & EFER_LMA))\n\t\t\tefer &= ~EFER_LME;\n\t}\n\n\tif ((old_efer & EFER_SVME) != (efer & EFER_SVME)) {\n\t\tif (!(efer & EFER_SVME)) {\n\t\t\tsvm_leave_nested(vcpu);\n\t\t\tsvm_set_gif(svm, true);\n\t\t\t\/* #GP intercept is still needed for vmware backdoor *\/\n\t\t\tif (!enable_vmware_backdoor)\n\t\t\t\tclr_exception_intercept(svm, GP_VECTOR);\n\n\t\t\t\/*\n\t\t\t * Free the nested guest state, unless we are in SMM.\n\t\t\t * In this case we will return to the nested guest\n\t\t\t * as soon as we leave SMM.\n\t\t\t *\/\n\t\t\tif (!is_smm(vcpu))\n\t\t\t\tsvm_free_nested(svm);\n\n\t\t} else {\n\t\t\tint ret = svm_allocate_nested(svm);\n\n\t\t\tif (ret) {\n\t\t\t\tvcpu->arch.efer = old_efer;\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Never intercept #GP for SEV guests, KVM can't\n\t\t\t * decrypt guest memory to workaround the erratum.\n\t\t\t *\/\n\t\t\tif (svm_gp_erratum_intercept && !sev_guest(vcpu->kvm))\n\t\t\t\tset_exception_intercept(svm, GP_VECTOR);\n\t\t}\n\t}\n\n\tsvm->vmcb->save.efer = efer | EFER_SVME;\n\tvmcb_mark_dirty(svm->vmcb, VMCB_CR);\n\treturn 0;\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":112582,"func":"static int create_pin_file(const sc_path_t *inpath, int chv, const char *key_id)\n{\n\tchar prompt[40], *pin, *puk;\n\tchar buf[30], *p = buf;\n\tsc_path_t file_id, path;\n\tsc_file_t *file;\n\tsize_t len;\n\tint r;\n\n\tfile_id = *inpath;\n\tif (file_id.len < 2)\n\t\treturn -1;\n\tif (chv == 1)\n\t\tsc_format_path(\"I0000\", &file_id);\n\telse if (chv == 2)\n\t\tsc_format_path(\"I0100\", &file_id);\n\telse\n\t\treturn -1;\n\tr = sc_select_file(card, inpath, NULL);\n\tif (r)\n\t\treturn -1;\n\tr = sc_select_file(card, &file_id, NULL);\n\tif (r == 0)\n\t\treturn 0;\n\n\tsprintf(prompt, \"Please enter CHV%d%s: \", chv, key_id);\n\tpin = getpin(prompt);\n\tif (pin == NULL)\n\t\treturn -1;\n\n\tsprintf(prompt, \"Please enter PUK for CHV%d%s: \", chv, key_id);\n\tpuk = getpin(prompt);\n\tif (puk == NULL) {\n\t\tfree(pin);\n\t\treturn -1;\n\t}\n\n\tmemset(p, 0xFF, 3);\n\tp += 3;\n\tmemcpy(p, pin, 8);\n\tp += 8;\n\t*p++ = opt_pin_attempts;\n\t*p++ = opt_pin_attempts;\n\tmemcpy(p, puk, 8);\n\tp += 8;\n\t*p++ = opt_puk_attempts;\n\t*p++ = opt_puk_attempts;\n\tlen = p - buf;\n\n\tfree(pin);\n\tfree(puk);\n\n\tfile = sc_file_new();\n\tfile->type = SC_FILE_TYPE_WORKING_EF;\n\tfile->ef_structure = SC_FILE_EF_TRANSPARENT;\n\tsc_file_add_acl_entry(file, SC_AC_OP_READ, SC_AC_NEVER, SC_AC_KEY_REF_NONE);\n\tif (inpath->len == 2 && inpath->value[0] == 0x3F &&\n\t    inpath->value[1] == 0x00)\n\t\tsc_file_add_acl_entry(file, SC_AC_OP_UPDATE, SC_AC_AUT, 1);\n\telse\n\t\tsc_file_add_acl_entry(file, SC_AC_OP_UPDATE, SC_AC_CHV, 2);\n\n\tsc_file_add_acl_entry(file, SC_AC_OP_INVALIDATE, SC_AC_AUT, 1);\n\tsc_file_add_acl_entry(file, SC_AC_OP_REHABILITATE, SC_AC_AUT, 1);\n\tfile->size = len;\n\tfile->id = (file_id.value[0] << 8) | file_id.value[1];\n\tr = sc_create_file(card, file);\n\tsc_file_free(file);\n\tif (r) {\n\t\tfprintf(stderr, \"PIN file creation failed: %s\\n\", sc_strerror(r));\n\t\treturn r;\n\t}\n\tpath = *inpath;\n\tsc_append_path(&path, &file_id);\n\tr = sc_select_file(card, &path, NULL);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select created PIN file: %s\\n\", sc_strerror(r));\n\t\treturn r;\n\t}\n\tr = sc_update_binary(card, 0, (const u8 *) buf, len, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to update created PIN file: %s\\n\", sc_strerror(r));\n\t\treturn r;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":732,"total_token_length":968,"max_tokens_setting":1024}
+{"idx":448180,"func":"int netns_identify_pid(const char *pidstr, char *name, int len)\n{\n\tchar net_path[PATH_MAX];\n\tint netns;\n\tstruct stat netst;\n\tDIR *dir;\n\tstruct dirent *entry;\n\n\tname[0] = '\\0';\n\n\tsnprintf(net_path, sizeof(net_path), \"\/proc\/%s\/ns\/net\", pidstr);\n\tnetns = open(net_path, O_RDONLY);\n\tif (netns < 0) {\n\t\tfprintf(stderr, \"Cannot open network namespace: %s\\n\",\n\t\t\tstrerror(errno));\n\t\treturn -1;\n\t}\n\tif (fstat(netns, &netst) < 0) {\n\t\tfprintf(stderr, \"Stat of netns failed: %s\\n\",\n\t\t\tstrerror(errno));\n\t\treturn -1;\n\t}\n\tdir = opendir(NETNS_RUN_DIR);\n\tif (!dir) {\n\t\t\/* Succeed treat a missing directory as an empty directory *\/\n\t\tif (errno == ENOENT)\n\t\t\treturn 0;\n\n\t\tfprintf(stderr, \"Failed to open directory %s:%s\\n\",\n\t\t\tNETNS_RUN_DIR, strerror(errno));\n\t\treturn -1;\n\t}\n\n\twhile ((entry = readdir(dir))) {\n\t\tchar name_path[PATH_MAX];\n\t\tstruct stat st;\n\n\t\tif (strcmp(entry->d_name, \".\") == 0)\n\t\t\tcontinue;\n\t\tif (strcmp(entry->d_name, \"..\") == 0)\n\t\t\tcontinue;\n\n\t\tsnprintf(name_path, sizeof(name_path), \"%s\/%s\",\tNETNS_RUN_DIR,\n\t\t\tentry->d_name);\n\n\t\tif (stat(name_path, &st) != 0)\n\t\t\tcontinue;\n\n\t\tif ((st.st_dev == netst.st_dev) &&\n\t\t    (st.st_ino == netst.st_ino)) {\n\t\t\tstrlcpy(name, entry->d_name, len);\n\t\t}\n\t}\n\tclosedir(dir);\n\treturn 0;\n\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":245221,"func":"ofputil_decode_ofp11_table_stats(struct ofpbuf *msg,\n                                 struct ofputil_table_stats *stats,\n                                 struct ofputil_table_features *features)\n{\n    struct ofp11_table_stats *ots;\n\n    ots = ofpbuf_try_pull(msg, sizeof *ots);\n    if (!ots) {\n        return OFPERR_OFPBRC_BAD_LEN;\n    }\n\n    features->table_id = ots->table_id;\n    ovs_strlcpy(features->name, ots->name, sizeof features->name);\n    features->max_entries = ntohl(ots->max_entries);\n    features->nonmiss.instructions = ovsinst_bitmap_from_openflow(\n        ots->instructions, OFP11_VERSION);\n    features->nonmiss.write.ofpacts = ofpact_bitmap_from_openflow(\n        ots->write_actions, OFP11_VERSION);\n    features->nonmiss.apply.ofpacts = ofpact_bitmap_from_openflow(\n        ots->write_actions, OFP11_VERSION);\n    features->miss = features->nonmiss;\n    features->miss_config = ofputil_decode_table_miss(ots->config,\n                                                      OFP11_VERSION);\n    features->match = mf_bitmap_from_of11(ots->match);\n    features->wildcard = mf_bitmap_from_of11(ots->wildcards);\n    bitmap_or(features->match.bm, features->wildcard.bm, MFF_N_IDS);\n\n    stats->table_id = ots->table_id;\n    stats->active_count = ntohl(ots->active_count);\n    stats->lookup_count = ntohll(ots->lookup_count);\n    stats->matched_count = ntohll(ots->matched_count);\n\n    return 0;\n}\n","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":262130,"func":"njs_generate_cond_expression_true(njs_vm_t *vm, njs_generator_t *generator,\n    njs_parser_node_t *node)\n{\n    njs_int_t          ret;\n    njs_jump_off_t     jump_offset;\n    njs_parser_node_t  *branch;\n    njs_vmcode_move_t  *move;\n    njs_vmcode_jump_t  *jump;\n\n    branch = node->right;\n\n    \/*\n     * Branches usually uses node->index as destination, however,\n     * if branch expression is a literal, variable or assignment,\n     * then a MOVE operation is required.\n     *\/\n\n    if (node->index != branch->left->index) {\n        njs_generate_code_move(generator, move, node->index,\n                               branch->left->index, node);\n    }\n\n    ret = njs_generate_node_index_release(vm, generator, branch->left);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    njs_generate_code_jump(generator, jump, 0);\n    jump_offset = njs_code_offset(generator, jump);\n\n    njs_code_set_jump_offset(generator, njs_vmcode_cond_jump_t,\n                             *((njs_jump_off_t *) generator->context));\n\n    njs_generator_next(generator, njs_generate, branch->right);\n\n    return njs_generator_after(vm, generator,\n                               njs_queue_first(&generator->stack), node,\n                               njs_generate_cond_expression_false,\n                               &jump_offset, sizeof(njs_jump_off_t));\n}","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":328546,"func":"static int xen_remove_from_physmap(XenIOState *state,\n\n                                   hwaddr start_addr,\n\n                                   ram_addr_t size)\n\n{\n\n    unsigned long i = 0;\n\n    int rc = 0;\n\n    XenPhysmap *physmap = NULL;\n\n    hwaddr phys_offset = 0;\n\n\n\n    physmap = get_physmapping(state, start_addr, size);\n\n    if (physmap == NULL) {\n\n        return -1;\n\n    }\n\n\n\n    phys_offset = physmap->phys_offset;\n\n    size = physmap->size;\n\n\n\n    DPRINTF(\"unmapping vram to %\"HWADDR_PRIx\" - %\"HWADDR_PRIx\", at \"\n\n            \"%\"HWADDR_PRIx\"\\n\", start_addr, start_addr + size, phys_offset);\n\n\n\n    size >>= TARGET_PAGE_BITS;\n\n    start_addr >>= TARGET_PAGE_BITS;\n\n    phys_offset >>= TARGET_PAGE_BITS;\n\n    for (i = 0; i < size; i++) {\n\n        unsigned long idx = start_addr + i;\n\n        xen_pfn_t gpfn = phys_offset + i;\n\n\n\n        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);\n\n        if (rc) {\n\n            fprintf(stderr, \"add_to_physmap MFN %\"PRI_xen_pfn\" to PFN %\"\n\n                    PRI_xen_pfn\" failed: %d\\n\", idx, gpfn, rc);\n\n            return -rc;\n\n        }\n\n    }\n\n\n\n    QLIST_REMOVE(physmap, list);\n\n    if (state->log_for_dirtybit == physmap) {\n\n        state->log_for_dirtybit = NULL;\n\n    }\n\n    g_free(physmap);\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":432581,"func":"bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsigned subcode, byte *data, unsigned len)\n{\n  byte argbuf[256+16], *t = argbuf;\n  unsigned i;\n\n  \/* Don't report Cease messages generated by myself *\/\n  if (code == 6 && class == BE_BGP_TX)\n    return;\n\n  \/* Reset shutdown message *\/\n  if ((code == 6) && ((subcode == 2) || (subcode == 4)))\n    proto_set_message(&p->p, NULL, 0);\n\n  if (len)\n    {\n      \/* Bad peer AS - we would like to print the AS *\/\n      if ((code == 2) && (subcode == 2) && ((len == 2) || (len == 4)))\n\t{\n\t  t += bsprintf(t, \": %u\", (len == 2) ? get_u16(data) : get_u32(data));\n\t  goto done;\n\t}\n\n      \/* RFC 8203 - shutdown communication *\/\n      if (((code == 6) && ((subcode == 2) || (subcode == 4))))\n\tif (bgp_handle_message(p, data, len, &t))\n\t  goto done;\n\n      *t++ = ':';\n      *t++ = ' ';\n      if (len > 16)\n\tlen = 16;\n      for (i=0; i<len; i++)\n\tt += bsprintf(t, \"%02x\", data[i]);\n    }\n\ndone:\n  *t = 0;\n  const byte *dsc = bgp_error_dsc(code, subcode);\n  log(L_REMOTE \"%s: %s: %s%s\", p->p.name, msg, dsc, argbuf);\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":294922,"func":"static uint8_t spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld,\n                             int16_t *spectral_data)\n{\n    int8_t i;\n    uint8_t g;\n    uint16_t inc, k, p = 0;\n    uint8_t groups = 0;\n    uint8_t sect_cb;\n    uint8_t result;\n    uint16_t nshort = hDecoder->frameLength\/8;\n\n#ifdef PROFILE\n    int64_t count = faad_get_ts();\n#endif\n\n    for(g = 0; g < ics->num_window_groups; g++)\n    {\n        p = groups*nshort;\n\n        for (i = 0; i < ics->num_sec[g]; i++)\n        {\n            sect_cb = ics->sect_cb[g][i];\n\n            inc = (sect_cb >= FIRST_PAIR_HCB) ? 2 : 4;\n\n            switch (sect_cb)\n            {\n            case ZERO_HCB:\n            case NOISE_HCB:\n            case INTENSITY_HCB:\n            case INTENSITY_HCB2:\n\/\/#define SD_PRINT\n#ifdef SD_PRINT\n                {\n                    int j;\n                    for (j = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; j < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; j++)\n                    {\n                        printf(\"%d\\n\", 0);\n                    }\n                }\n#endif\n\/\/#define SFBO_PRINT\n#ifdef SFBO_PRINT\n                printf(\"%d\\n\", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);\n#endif\n                p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] -\n                    ics->sect_sfb_offset[g][ics->sect_start[g][i]]);\n                break;\n            default:\n#ifdef SFBO_PRINT\n                printf(\"%d\\n\", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);\n#endif\n                for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]];\n                     k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc)\n                {\n                    if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0)\n                        return result;\n#ifdef SD_PRINT\n                    {\n                        int j;\n                        for (j = p; j < p+inc; j++)\n                        {\n                            printf(\"%d\\n\", spectral_data[j]);\n                        }\n                    }\n#endif\n                    p += inc;\n                }\n                break;\n            }\n        }\n        groups += ics->window_group_length[g];\n    }\n\n#ifdef PROFILE\n    count = faad_get_ts() - count;\n    hDecoder->spectral_cycles += count;\n#endif\n\n    return 0;\n}","target":0,"code_token_length":599,"total_token_length":835,"max_tokens_setting":1024}
+{"idx":368663,"func":"dir_split_resource_into_fingerprints(const char *resource,\n                                     smartlist_t *fp_out, int *compressed_out,\n                                     int flags)\n{\n  const int decode_hex = flags & DSR_HEX;\n  const int decode_base64 = flags & DSR_BASE64;\n  const int digests_are_256 = flags & DSR_DIGEST256;\n  const int sort_uniq = flags & DSR_SORT_UNIQ;\n\n  const int digest_len = digests_are_256 ? DIGEST256_LEN : DIGEST_LEN;\n  const int hex_digest_len = digests_are_256 ?\n    HEX_DIGEST256_LEN : HEX_DIGEST_LEN;\n  const int base64_digest_len = digests_are_256 ?\n    BASE64_DIGEST256_LEN : BASE64_DIGEST_LEN;\n  smartlist_t *fp_tmp = smartlist_create();\n\n  tor_assert(!(decode_hex && decode_base64));\n  tor_assert(fp_out);\n\n  smartlist_split_string(fp_tmp, resource, decode_base64?\"-\":\"+\", 0, 0);\n  if (compressed_out)\n    *compressed_out = 0;\n  if (smartlist_len(fp_tmp)) {\n    char *last = smartlist_get(fp_tmp,smartlist_len(fp_tmp)-1);\n    size_t last_len = strlen(last);\n    if (last_len > 2 && !strcmp(last+last_len-2, \".z\")) {\n      last[last_len-2] = '\\0';\n      if (compressed_out)\n        *compressed_out = 1;\n    }\n  }\n  if (decode_hex || decode_base64) {\n    const size_t encoded_len = decode_hex ? hex_digest_len : base64_digest_len;\n    int i;\n    char *cp, *d = NULL;\n    for (i = 0; i < smartlist_len(fp_tmp); ++i) {\n      cp = smartlist_get(fp_tmp, i);\n      if (strlen(cp) != encoded_len) {\n        log_info(LD_DIR,\n                 \"Skipping digest %s with non-standard length.\", escaped(cp));\n        smartlist_del_keeporder(fp_tmp, i--);\n        goto again;\n      }\n      d = tor_malloc_zero(digest_len);\n      if (decode_hex ?\n          (base16_decode(d, digest_len, cp, hex_digest_len)<0) :\n          (base64_decode(d, digest_len, cp, base64_digest_len)<0)) {\n          log_info(LD_DIR, \"Skipping non-decodable digest %s\", escaped(cp));\n          smartlist_del_keeporder(fp_tmp, i--);\n          goto again;\n      }\n      smartlist_set(fp_tmp, i, d);\n      d = NULL;\n    again:\n      tor_free(cp);\n      tor_free(d);\n    }\n  }\n  if (sort_uniq) {\n    if (decode_hex || decode_base64) {\n      if (digests_are_256) {\n        smartlist_sort_digests256(fp_tmp);\n        smartlist_uniq_digests256(fp_tmp);\n      } else {\n        smartlist_sort_digests(fp_tmp);\n        smartlist_uniq_digests(fp_tmp);\n      }\n    } else {\n      smartlist_sort_strings(fp_tmp);\n      smartlist_uniq_strings(fp_tmp);\n    }\n  }\n  smartlist_add_all(fp_out, fp_tmp);\n  smartlist_free(fp_tmp);\n  return 0;\n}","target":0,"code_token_length":722,"total_token_length":958,"max_tokens_setting":1024}
+{"idx":27966,"func":"int kvm_arch_handle_exit ( CPUState * cs , struct kvm_run * run ) {\n X86CPU * cpu = X86_CPU ( cs ) ;\n uint64_t code ;\n int ret ;\n switch ( run -> exit_reason ) {\n case KVM_EXIT_HLT : DPRINTF ( \"handle_hlt\\n\" ) ;\n qemu_mutex_lock_iothread ( ) ;\n ret = kvm_handle_halt ( cpu ) ;\n qemu_mutex_unlock_iothread ( ) ;\n break ;\n case KVM_EXIT_SET_TPR : ret = 0 ;\n break ;\n case KVM_EXIT_TPR_ACCESS : qemu_mutex_lock_iothread ( ) ;\n ret = kvm_handle_tpr_access ( cpu ) ;\n qemu_mutex_unlock_iothread ( ) ;\n break ;\n case KVM_EXIT_FAIL_ENTRY : code = run -> fail_entry . hardware_entry_failure_reason ;\n fprintf ( stderr , \"KVM: entry failed, hardware error 0x%\" PRIx64 \"\\n\" , code ) ;\n if ( host_supports_vmx ( ) && code == VMX_INVALID_GUEST_STATE ) {\n fprintf ( stderr , \"\\nIf you're running a guest on an Intel machine without \" \"unrestricted mode\\n\" \"support, the failure can be most likely due to the guest \" \"entering an invalid\\n\" \"state for Intel VT. For example, the guest maybe running \" \"in big real mode\\n\" \"which is not supported on less recent Intel processors.\" \"\\n\\n\" ) ;\n }\n ret = - 1 ;\n break ;\n case KVM_EXIT_EXCEPTION : fprintf ( stderr , \"KVM: exception %d exit (error code 0x%x)\\n\" , run -> ex . exception , run -> ex . error_code ) ;\n ret = - 1 ;\n break ;\n case KVM_EXIT_DEBUG : DPRINTF ( \"kvm_exit_debug\\n\" ) ;\n qemu_mutex_lock_iothread ( ) ;\n ret = kvm_handle_debug ( cpu , & run -> debug . arch ) ;\n qemu_mutex_unlock_iothread ( ) ;\n break ;\n case KVM_EXIT_HYPERV : ret = kvm_hv_handle_exit ( cpu , & run -> hyperv ) ;\n break ;\n case KVM_EXIT_IOAPIC_EOI : ioapic_eoi_broadcast ( run -> eoi . vector ) ;\n ret = 0 ;\n break ;\n default : fprintf ( stderr , \"KVM: unknown exit reason %d\\n\" , run -> exit_reason ) ;\n ret = - 1 ;\n break ;\n }\n return ret ;\n }","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":86022,"func":"static int tcos_list_files(sc_card_t *card, u8 *buf, size_t buflen)\n{\n\tsc_context_t *ctx;\n\tsc_apdu_t apdu;\n\tu8 rbuf[SC_MAX_APDU_BUFFER_SIZE], p1;\n\tint r, count = 0;\n\n\tassert(card != NULL);\n\tctx = card->ctx;\n\n\tfor (p1=1; p1<=2; p1++) {\n\t\tsc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xAA, p1, 0);\n\t\tapdu.cla = 0x80;\n\t\tapdu.resp = rbuf;\n\t\tapdu.resplen = sizeof(rbuf);\n\t\tapdu.le = 256;\n\t\tr = sc_transmit_apdu(card, &apdu);\n\t\tSC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\t\tif (apdu.sw1==0x6A && (apdu.sw2==0x82 || apdu.sw2==0x88)) continue;\n\t\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\t\tSC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, \"List Dir failed\");\n\t\tif (apdu.resplen > buflen) return SC_ERROR_BUFFER_TOO_SMALL;\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\n\t\t\t \"got %\"SC_FORMAT_LEN_SIZE_T\"u %s-FileIDs\\n\",\n\t\t\t apdu.resplen \/ 2, p1 == 1 ? \"DF\" : \"EF\");\n\n\t\tmemcpy(buf, apdu.resp, apdu.resplen);\n\t\tbuf += apdu.resplen;\n\t\tbuflen -= apdu.resplen;\n\t\tcount += apdu.resplen;\n\t}\n\treturn count;\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":453947,"func":"TEST(ExpressionPowTest, LargeExponentValuesWithBaseOfNegativeOne) {\n    assertExpectedResults(\"$pow\",\n                          {\n                              {{Value(-1), Value(-1)}, Value(-1)},\n                              {{Value(-1), Value(-2)}, Value(1)},\n                              {{Value(-1), Value(-3)}, Value(-1)},\n\n                              {{Value(-1LL), Value(0LL)}, Value(1LL)},\n                              {{Value(-1LL), Value(-1LL)}, Value(-1LL)},\n                              {{Value(-1LL), Value(-2LL)}, Value(1LL)},\n                              {{Value(-1LL), Value(-3LL)}, Value(-1LL)},\n                              {{Value(-1LL), Value(-4LL)}, Value(1LL)},\n                              {{Value(-1LL), Value(-5LL)}, Value(-1LL)},\n\n                              {{Value(-1LL), Value(-61LL)}, Value(-1LL)},\n                              {{Value(-1LL), Value(61LL)}, Value(-1LL)},\n\n                              {{Value(-1LL), Value(-62LL)}, Value(1LL)},\n                              {{Value(-1LL), Value(62LL)}, Value(1LL)},\n\n                              {{Value(-1LL), Value(-101LL)}, Value(-1LL)},\n                              {{Value(-1LL), Value(-102LL)}, Value(1LL)},\n\n                              \/\/ Use a value large enough that will make the test hang for a\n                              \/\/ considerable amount of time if a loop is used to compute the\n                              \/\/ answer.\n                              {{Value(-1LL), Value(63234673905128LL)}, Value(1LL)},\n                              {{Value(-1LL), Value(-63234673905128LL)}, Value(1LL)},\n\n                              {{Value(-1LL), Value(63234673905127LL)}, Value(-1LL)},\n                              {{Value(-1LL), Value(-63234673905127LL)}, Value(-1LL)},\n                          });\n}","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":522787,"func":"void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab, \n                                table_map last_remaining_tables, \n                                bool first_alt, uint no_jbuf_before,\n                                double *outer_rec_count, double *reopt_cost)\n{\n  double cost, rec_count;\n  table_map reopt_remaining_tables= last_remaining_tables;\n  uint i;\n  THD *thd= join->thd;\n  Json_writer_temp_disable trace_wo_join_buffering(thd);\n\n  if (first_tab > join->const_tables)\n  {\n    cost=      join->positions[first_tab - 1].prefix_cost.total_cost();\n    rec_count= join->positions[first_tab - 1].prefix_record_count;\n  }\n  else\n  {\n    cost= 0.0;\n    rec_count= 1;\n  }\n\n  *outer_rec_count= rec_count;\n  for (i= first_tab; i <= last_tab; i++)\n    reopt_remaining_tables |= join->positions[i].table->table->map;\n  \n  \/*\n    best_access_path() optimization depends on the value of \n    join->cur_sj_inner_tables. Our goal in this function is to do a\n    re-optimization with disabled join buffering, but no other changes.\n    In order to achieve this, cur_sj_inner_tables needs have the same \n    value it had during the original invocations of best_access_path. \n\n    We know that this function, optimize_wo_join_buffering() is called to\n    re-optimize semi-join join order range, which allows to conclude that \n    the \"original\" value of cur_sj_inner_tables was 0.\n  *\/\n  table_map save_cur_sj_inner_tables= join->cur_sj_inner_tables;\n  join->cur_sj_inner_tables= 0;\n\n  for (i= first_tab; i <= last_tab; i++)\n  {\n    JOIN_TAB *rs= join->positions[i].table;\n    POSITION pos, loose_scan_pos;\n\n    if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer)\n    {\n      \/* Find the best access method that would not use join buffering *\/\n      best_access_path(join, rs, reopt_remaining_tables,\n                       join->positions, i,\n                       TRUE, rec_count,\n                       &pos, &loose_scan_pos);\n    }\n    else \n      pos= join->positions[i];\n\n    if ((i == first_tab && first_alt))\n      pos= loose_scan_pos;\n\n    reopt_remaining_tables &= ~rs->table->map;\n    rec_count= COST_MULT(rec_count, pos.records_read);\n    cost= COST_ADD(cost, pos.read_time);\n    cost= COST_ADD(cost, rec_count \/ (double) TIME_FOR_COMPARE);\n    \/\/TODO: take into account join condition selectivity here\n    double pushdown_cond_selectivity= 1.0;\n    table_map real_table_bit= rs->table->map;\n    if (join->thd->variables.optimizer_use_condition_selectivity > 1)\n    {\n      pushdown_cond_selectivity= table_cond_selectivity(join, i, rs,\n                                                        reopt_remaining_tables &\n                                                        ~real_table_bit);\n    }\n    (*outer_rec_count) *= pushdown_cond_selectivity;\n    if (!rs->emb_sj_nest)\n      *outer_rec_count= COST_MULT(*outer_rec_count, pos.records_read);\n\n  }\n  join->cur_sj_inner_tables= save_cur_sj_inner_tables;\n\n  *reopt_cost= cost;\n}","target":0,"code_token_length":732,"total_token_length":968,"max_tokens_setting":1024}
+{"idx":216274,"func":"error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(\n    uint32_t immediate_data_size,\n    const volatile void* cmd_data) {\n  const volatile gles2::cmds::PostSubBufferCHROMIUM& c =\n      *static_cast<const volatile gles2::cmds::PostSubBufferCHROMIUM*>(\n          cmd_data);\n  TRACE_EVENT0(\"gpu\", \"GLES2DecoderImpl::HandlePostSubBufferCHROMIUM\");\n  if (!supports_post_sub_buffer_) {\n    LOCAL_SET_GL_ERROR(\n        GL_INVALID_OPERATION,\n        \"glPostSubBufferCHROMIUM\", \"command not supported by surface\");\n    return error::kNoError;\n  }\n  bool is_tracing;\n  TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT(\"gpu.debug\"),\n                                     &is_tracing);\n  if (is_tracing) {\n    bool is_offscreen = !!offscreen_target_frame_buffer_.get();\n    ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId());\n    gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer(\n        is_offscreen ? offscreen_size_ : surface_->GetSize());\n  }\n\n  ClearScheduleCALayerState();\n\n  if (supports_async_swap_) {\n    TRACE_EVENT_ASYNC_BEGIN0(\"gpu\", \"AsyncSwapBuffers\", c.swap_id());\n\n    client()->OnSwapBuffers(c.swap_id(), c.flags);\n    surface_->PostSubBufferAsync(\n        c.x, c.y, c.width, c.height,\n        base::BindOnce(&GLES2DecoderImpl::FinishAsyncSwapBuffers,\n                       weak_ptr_factory_.GetWeakPtr(), c.swap_id()),\n        base::DoNothing());\n  } else {\n    client()->OnSwapBuffers(c.swap_id(), c.flags);\n    FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height,\n                                              base::DoNothing()));\n  }\n\n  return error::kNoError;\n}\n","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":110418,"func":"static void WriteOneChannel(const PSDInfo *psd_info,const ImageInfo *image_info,\n  Image *image,Image *next_image,unsigned char *compact_pixels,\n  const QuantumType quantum_type,const MagickBooleanType compression_flag,\n  ExceptionInfo *exception)\n{\n  int\n    y;\n\n  MagickBooleanType\n    monochrome;\n\n  QuantumInfo\n    *quantum_info;\n\n  register const Quantum\n    *p;\n\n  register ssize_t\n    i;\n\n  size_t\n    length,\n    packet_size;\n\n  unsigned char\n    *pixels;\n\n  (void) psd_info;\n  if ((compression_flag != MagickFalse) &&\n      (next_image->compression != RLECompression))\n    (void) WriteBlobMSBShort(image,0);\n  if (next_image->depth > 8)\n    next_image->depth=16;\n  monochrome=IsImageMonochrome(image) && (image->depth == 1) ?\n    MagickTrue : MagickFalse;\n  packet_size=next_image->depth > 8UL ? 2UL : 1UL;\n  (void) packet_size;\n  quantum_info=AcquireQuantumInfo(image_info,image);\n  pixels=(unsigned char *) GetQuantumPixels(quantum_info);\n  for (y=0; y < (ssize_t) next_image->rows; y++)\n  {\n    p=GetVirtualPixels(next_image,0,y,next_image->columns,1,exception);\n    if (p == (const Quantum *) NULL)\n      break;\n    length=ExportQuantumPixels(next_image,(CacheView *) NULL,quantum_info,\n      quantum_type,pixels,exception);\n    if (monochrome != MagickFalse)\n      for (i=0; i < (ssize_t) length; i++)\n        pixels[i]=(~pixels[i]);\n    if (next_image->compression != RLECompression)\n      (void) WriteBlob(image,length,pixels);\n    else\n      {\n        length=PSDPackbitsEncodeImage(image,length,pixels,compact_pixels,\n          exception);\n        (void) WriteBlob(image,length,compact_pixels);\n      }\n  }\n  quantum_info=DestroyQuantumInfo(quantum_info);\n}","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":413149,"func":"get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n\/* This version is for reading 16-bit pixels *\/\n{\n  tga_source_ptr source = (tga_source_ptr) sinfo;\n  register int t;\n  register JSAMPROW ptr;\n  register JDIMENSION col;\n\n  ptr = source->pub.buffer[0];\n  for (col = cinfo->image_width; col > 0; col--) {\n    (*source->read_pixel) (source); \/* Load next pixel into tga_pixel *\/\n    t = UCH(source->tga_pixel[0]);\n    t += UCH(source->tga_pixel[1]) << 8;\n    \/* We expand 5 bit data to 8 bit sample width.\n     * The format of the 16-bit (LSB first) input word is\n     *     xRRRRRGGGGGBBBBB\n     *\/\n    ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F];\n    t >>= 5;\n    ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F];\n    t >>= 5;\n    ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F];\n    ptr += 3;\n  }\n  return 1;\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":363570,"func":"hook_process_child (struct t_hook *hook_process)\n{\n    char *exec_args[4] = { \"sh\", \"-c\", NULL, NULL };\n    \n    \/*\n     * close stdin, so that process will fail to read stdin (process reading\n     * stdin should not be run inside WeeChat!)\n     *\/\n    close (STDIN_FILENO);\n    \n    \/* redirect stdout\/stderr to pipe (so that father process can read them) *\/\n    close (HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDOUT]));\n    close (HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDERR]));\n    if (dup2 (HOOK_PROCESS(hook_process, child_write[HOOK_PROCESS_STDOUT]),\n              STDOUT_FILENO) < 0)\n    {\n        _exit (EXIT_FAILURE);\n    }\n    if (dup2 (HOOK_PROCESS(hook_process, child_write[HOOK_PROCESS_STDERR]),\n              STDERR_FILENO) < 0)\n    {\n        _exit (EXIT_FAILURE);\n    }\n    \n    \/* launch command *\/\n    exec_args[2] = HOOK_PROCESS(hook_process, command);\n    execvp (exec_args[0], exec_args);\n    \n    \/* should not be executed if execvp was ok *\/\n    fprintf (stderr, \"Error with command '%s'\\n\",\n             HOOK_PROCESS(hook_process, command));\n    _exit (EXIT_FAILURE);\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":9947,"func":"char **XListExtensions(\n    register Display *dpy,\n    int *nextensions)\t\/* RETURN *\/\n{\n\txListExtensionsReply rep;\n\tchar **list = NULL;\n\tchar *ch = NULL;\n\tchar *chend;\n\tint count = 0;\n\tregister unsigned i;\n\tregister int length;\n\t_X_UNUSED register xReq *req;\n\tunsigned long rlen = 0;\n\n\tLockDisplay(dpy);\n\tGetEmptyReq (ListExtensions, req);\n\n\tif (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {\n\t    UnlockDisplay(dpy);\n\t    SyncHandle();\n\t    return (char **) NULL;\n\t}\n\n\tif (rep.nExtensions) {\n\t    list = Xmalloc (rep.nExtensions * sizeof (char *));\n\t    if (rep.length > 0 && rep.length < (INT_MAX >> 2)) {\n\t\trlen = rep.length << 2;\n\t\tch = Xmalloc (rlen + 1);\n                \/* +1 to leave room for last null-terminator *\/\n\t    }\n\n\t    if ((!list) || (!ch)) {\n\t\tXfree(list);\n\t\tXfree(ch);\n\t\t_XEatDataWords(dpy, rep.length);\n\t\tUnlockDisplay(dpy);\n\t\tSyncHandle();\n\t\treturn (char **) NULL;\n\t    }\n\n\t    _XReadPad (dpy, ch, rlen);\n \t    \/*\n \t     * unpack into null terminated strings.\n \t     *\/\n\t    chend = ch + (rlen + 1);\n \t    length = *ch;\n \t    for (i = 0; i < rep.nExtensions; i++) {\n \t\tif (ch + length < chend) {\n \t\t    list[i] = ch+1;  \/* skip over length *\/\n \t\t    ch += length + 1; \/* find next length ... *\/\n\t\t    if (ch <= chend) {\n\t\t\tlength = *ch;\n\t\t\t*ch = '\\0'; \/* and replace with null-termination *\/\n\t\t\tcount++;\n\t\t    } else {\n\t\t\tlist[i] = NULL;\n\t\t    }\n \t\t} else\n \t\t    list[i] = NULL;\n \t    }\n\t\t    }\n\t\t} else\n","target":1,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":296320,"func":"static avifBool avifParseItemInfoEntry(avifMeta * meta, const uint8_t * raw, size_t rawLen)\n{\n    BEGIN_STREAM(s, raw, rawLen);\n\n    CHECK(avifROStreamReadAndEnforceVersion(&s, 2)); \/\/ TODO: support version > 2? 2+ is required for item_type\n\n    uint16_t itemID;                                      \/\/ unsigned int(16) item_ID;\n    CHECK(avifROStreamReadU16(&s, &itemID));              \/\/\n    uint16_t itemProtectionIndex;                         \/\/ unsigned int(16) item_protection_index;\n    CHECK(avifROStreamReadU16(&s, &itemProtectionIndex)); \/\/\n    uint8_t itemType[4];                                  \/\/ unsigned int(32) item_type;\n    CHECK(avifROStreamRead(&s, itemType, 4));             \/\/\n\n    avifContentType contentType;\n    if (!memcmp(itemType, \"mime\", 4)) {\n        CHECK(avifROStreamReadString(&s, NULL, 0));                                   \/\/ string item_name; (skipped)\n        CHECK(avifROStreamReadString(&s, contentType.contentType, CONTENTTYPE_SIZE)); \/\/ string content_type;\n    } else {\n        memset(&contentType, 0, sizeof(contentType));\n    }\n\n    avifDecoderItem * item = avifMetaFindItem(meta, itemID);\n    if (!item) {\n        return AVIF_FALSE;\n    }\n\n    memcpy(item->type, itemType, sizeof(itemType));\n    memcpy(&item->contentType, &contentType, sizeof(contentType));\n    return AVIF_TRUE;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":224014,"func":"xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {\n    if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);\n    if (cur == NULL) {\n\tif (ctxt->context->node == NULL) return(NULL);\n\tswitch (ctxt->context->node->type) {\n            case XML_ELEMENT_NODE:\n            case XML_TEXT_NODE:\n            case XML_CDATA_SECTION_NODE:\n            case XML_ENTITY_REF_NODE:\n            case XML_ENTITY_NODE:\n            case XML_PI_NODE:\n            case XML_COMMENT_NODE:\n            case XML_NOTATION_NODE:\n            case XML_DTD_NODE:\n\t\treturn(ctxt->context->node->children);\n            case XML_DOCUMENT_NODE:\n            case XML_DOCUMENT_TYPE_NODE:\n            case XML_DOCUMENT_FRAG_NODE:\n            case XML_HTML_DOCUMENT_NODE:\n#ifdef LIBXML_DOCB_ENABLED\n\t    case XML_DOCB_DOCUMENT_NODE:\n#endif\n\t\treturn(((xmlDocPtr) ctxt->context->node)->children);\n\t    case XML_ELEMENT_DECL:\n\t    case XML_ATTRIBUTE_DECL:\n\t    case XML_ENTITY_DECL:\n            case XML_ATTRIBUTE_NODE:\n\t    case XML_NAMESPACE_DECL:\n\t    case XML_XINCLUDE_START:\n\t    case XML_XINCLUDE_END:\n\t\treturn(NULL);\n\t}\n\treturn(NULL);\n    }\n    if ((cur->type == XML_DOCUMENT_NODE) ||\n        (cur->type == XML_HTML_DOCUMENT_NODE))\n\treturn(NULL);\n    return(cur->next);\n}\n","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":78181,"func":"static int ASNToHexString(const byte* input, word32* inOutIdx, char** out,\n                          word32 inSz, void* heap, int heapType)\n{\n    int len;\n    int i;\n    char* str;\n    word32 localIdx;\n    byte   tag;\n\n    if (*inOutIdx >= inSz) {\n        return BUFFER_E;\n    }\n\n    localIdx = *inOutIdx;\n    if (GetASNTag(input, &localIdx, &tag, inSz) == 0 && tag == ASN_INTEGER) {\n        if (GetASNInt(input, inOutIdx, &len, inSz) < 0)\n            return ASN_PARSE_E;\n    }\n    else {\n        if (GetOctetString(input, inOutIdx, &len, inSz) < 0)\n            return ASN_PARSE_E;\n    }\n\n    str = (char*)XMALLOC(len * 2 + 1, heap, heapType);\n    if (str == NULL) {\n        return MEMORY_E;\n    }\n\n    for (i=0; i<len; i++)\n        ByteToHex(input[*inOutIdx + i], str + i*2);\n    str[len*2] = '\\0';\n\n    *inOutIdx += len;\n    *out = str;\n\n    (void)heap;\n    (void)heapType;\n\n    return 0;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":220048,"func":"MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle,\nMojoResult UnwrapSharedMemoryHandle(\n    ScopedSharedBufferHandle handle,\n    base::SharedMemoryHandle* memory_handle,\n    size_t* size,\n    UnwrappedSharedMemoryHandleProtection* protection) {\n   if (!handle.is_valid())\n     return MOJO_RESULT_INVALID_ARGUMENT;\n   MojoPlatformHandle platform_handle;\n  platform_handle.struct_size = sizeof(MojoPlatformHandle);\n\n  MojoPlatformSharedBufferHandleFlags flags;\n  size_t num_bytes;\n  MojoSharedBufferGuid mojo_guid;\n  MojoResult result = MojoUnwrapPlatformSharedBufferHandle(\n      handle.release().value(), &platform_handle, &num_bytes, &mojo_guid,\n      &flags);\n  if (result != MOJO_RESULT_OK)\n    return result;\n\n   if (size)\n     *size = num_bytes;\n \n  if (protection) {\n    *protection =\n        flags & MOJO_PLATFORM_SHARED_BUFFER_HANDLE_FLAG_HANDLE_IS_READ_ONLY\n            ? UnwrappedSharedMemoryHandleProtection::kReadOnly\n            : UnwrappedSharedMemoryHandleProtection::kReadWrite;\n  }\n \n   base::UnguessableToken guid =\n       base::UnguessableToken::Deserialize(mojo_guid.high, mojo_guid.low);\n#if defined(OS_MACOSX) && !defined(OS_IOS)\n  DCHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);\n  *memory_handle = base::SharedMemoryHandle(\n      static_cast<mach_port_t>(platform_handle.value), num_bytes, guid);\n#elif defined(OS_FUCHSIA)\n  DCHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FUCHSIA_HANDLE);\n  *memory_handle = base::SharedMemoryHandle(\n      static_cast<zx_handle_t>(platform_handle.value), num_bytes, guid);\n#elif defined(OS_POSIX)\n  DCHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR);\n  *memory_handle = base::SharedMemoryHandle(\n      base::FileDescriptor(static_cast<int>(platform_handle.value), false),\n      num_bytes, guid);\n#elif defined(OS_WIN)\n  DCHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE);\n  *memory_handle = base::SharedMemoryHandle(\n      reinterpret_cast<HANDLE>(platform_handle.value), num_bytes, guid);\n#endif\n\n  return MOJO_RESULT_OK;\n}\n","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":438624,"func":"logical_ring_default_vfuncs(struct intel_engine_cs *engine)\n{\n\t\/* Default vfuncs which can be overriden by each engine. *\/\n\n\tengine->destroy = execlists_destroy;\n\tengine->resume = execlists_resume;\n\n\tengine->reset.prepare = execlists_reset_prepare;\n\tengine->reset.reset = execlists_reset;\n\tengine->reset.finish = execlists_reset_finish;\n\n\tengine->cops = &execlists_context_ops;\n\tengine->request_alloc = execlists_request_alloc;\n\n\tengine->emit_flush = gen8_emit_flush;\n\tengine->emit_init_breadcrumb = gen8_emit_init_breadcrumb;\n\tengine->emit_fini_breadcrumb = gen8_emit_fini_breadcrumb;\n\tif (INTEL_GEN(engine->i915) >= 12)\n\t\tengine->emit_fini_breadcrumb = gen12_emit_fini_breadcrumb;\n\n\tengine->set_default_submission = intel_execlists_set_default_submission;\n\n\tif (INTEL_GEN(engine->i915) < 11) {\n\t\tengine->irq_enable = gen8_logical_ring_enable_irq;\n\t\tengine->irq_disable = gen8_logical_ring_disable_irq;\n\t} else {\n\t\t\/*\n\t\t * TODO: On Gen11 interrupt masks need to be clear\n\t\t * to allow C6 entry. Keep interrupts enabled at\n\t\t * and take the hit of generating extra interrupts\n\t\t * until a more refined solution exists.\n\t\t *\/\n\t}\n\tif (IS_GEN(engine->i915, 8))\n\t\tengine->emit_bb_start = gen8_emit_bb_start;\n\telse\n\t\tengine->emit_bb_start = gen9_emit_bb_start;\n}","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":386621,"func":"static void php_getimagesize_from_stream(php_stream *stream, zval **info, INTERNAL_FUNCTION_PARAMETERS) \/* {{{ *\/\n{\n\tchar *temp;\n\tint itype = 0;\n\tstruct gfxinfo *result = NULL;\n\n\tif (!stream) {\n\t\tRETURN_FALSE;\n\t}\n\n\titype = php_getimagetype(stream, NULL TSRMLS_CC);\n\tswitch( itype) {\n\t\tcase IMAGE_FILETYPE_GIF:\n\t\t\tresult = php_handle_gif(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_JPEG:\n\t\t\tif (info) {\n\t\t\t\tresult = php_handle_jpeg(stream, *info TSRMLS_CC);\n\t\t\t} else {\n\t\t\t\tresult = php_handle_jpeg(stream, NULL TSRMLS_CC);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_PNG:\n\t\t\tresult = php_handle_png(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_SWF:\n\t\t\tresult = php_handle_swf(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_SWC:\n#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)\n\t\t\tresult = php_handle_swc(stream TSRMLS_CC);\n#else\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled\");\n#endif\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_PSD:\n\t\t\tresult = php_handle_psd(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_BMP:\n\t\t\tresult = php_handle_bmp(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_TIFF_II:\n\t\t\tresult = php_handle_tiff(stream, NULL, 0 TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_TIFF_MM:\n\t\t\tresult = php_handle_tiff(stream, NULL, 1 TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_JPC:\n\t\t\tresult = php_handle_jpc(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_JP2:\n\t\t\tresult = php_handle_jp2(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_IFF:\n\t\t\tresult = php_handle_iff(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_WBMP:\n\t\t\tresult = php_handle_wbmp(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_XBM:\n\t\t\tresult = php_handle_xbm(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tcase IMAGE_FILETYPE_ICO:\n\t\t\tresult = php_handle_ico(stream TSRMLS_CC);\n\t\t\tbreak;\n\t\tdefault:\n\t\tcase IMAGE_FILETYPE_UNKNOWN:\n\t\t\tbreak;\n\t}\n\n\tif (result) {\n\t\tarray_init(return_value);\n\t\tadd_index_long(return_value, 0, result->width);\n\t\tadd_index_long(return_value, 1, result->height);\n\t\tadd_index_long(return_value, 2, itype);\n\t\tspprintf(&temp, 0, \"width=\\\"%d\\\" height=\\\"%d\\\"\", result->width, result->height);\n\t\tadd_index_string(return_value, 3, temp, 0);\n\n\t\tif (result->bits != 0) {\n\t\t\tadd_assoc_long(return_value, \"bits\", result->bits);\n\t\t}\n\t\tif (result->channels != 0) {\n\t\t\tadd_assoc_long(return_value, \"channels\", result->channels);\n\t\t}\n\t\tadd_assoc_string(return_value, \"mime\", (char*)php_image_type_to_mime_type(itype), 1);\n\t\tefree(result);\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":714,"total_token_length":950,"max_tokens_setting":1024}
+{"idx":95004,"func":"static void add_bin_header(conn *c, uint16_t err, uint8_t hdr_len, uint16_t key_len, uint32_t body_len) {\n    protocol_binary_response_header* header;\n\n    assert(c);\n\n    c->msgcurr = 0;\n    c->msgused = 0;\n    c->iovused = 0;\n    if (add_msghdr(c) != 0) {\n        \/* XXX:  out_string is inappropriate here *\/\n        out_string(c, \"SERVER_ERROR out of memory\");\n        return;\n    }\n\n    header = (protocol_binary_response_header *)c->wbuf;\n\n    header->response.magic = (uint8_t)PROTOCOL_BINARY_RES;\n    header->response.opcode = c->binary_header.request.opcode;\n    header->response.keylen = (uint16_t)htons(key_len);\n\n    header->response.extlen = (uint8_t)hdr_len;\n    header->response.datatype = (uint8_t)PROTOCOL_BINARY_RAW_BYTES;\n    header->response.status = (uint16_t)htons(err);\n\n    header->response.bodylen = htonl(body_len);\n    header->response.opaque = c->opaque;\n    header->response.cas = htonll(c->cas);\n\n    if (settings.verbose > 1) {\n        int ii;\n        fprintf(stderr, \">%d Writing bin response:\", c->sfd);\n        for (ii = 0; ii < sizeof(header->bytes); ++ii) {\n            if (ii % 4 == 0) {\n                fprintf(stderr, \"\\n>%d  \", c->sfd);\n            }\n            fprintf(stderr, \" 0x%02x\", header->bytes[ii]);\n        }\n        fprintf(stderr, \"\\n\");\n    }\n\n    add_iov(c, c->wbuf, sizeof(header->response));\n}","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":265702,"func":"xmlFreeAttribute(xmlAttributePtr attr) {\n    xmlDictPtr dict;\n\n    if (attr == NULL) return;\n    if (attr->doc != NULL)\n\tdict = attr->doc->dict;\n    else\n\tdict = NULL;\n    xmlUnlinkNode((xmlNodePtr) attr);\n    if (attr->tree != NULL)\n        xmlFreeEnumeration(attr->tree);\n    if (dict) {\n        if ((attr->elem != NULL) && (!xmlDictOwns(dict, attr->elem)))\n\t    xmlFree((xmlChar *) attr->elem);\n        if ((attr->name != NULL) && (!xmlDictOwns(dict, attr->name)))\n\t    xmlFree((xmlChar *) attr->name);\n        if ((attr->prefix != NULL) && (!xmlDictOwns(dict, attr->prefix)))\n\t    xmlFree((xmlChar *) attr->prefix);\n        if ((attr->defaultValue != NULL) &&\n\t    (!xmlDictOwns(dict, attr->defaultValue)))\n\t    xmlFree((xmlChar *) attr->defaultValue);\n    } else {\n\tif (attr->elem != NULL)\n\t    xmlFree((xmlChar *) attr->elem);\n\tif (attr->name != NULL)\n\t    xmlFree((xmlChar *) attr->name);\n\tif (attr->defaultValue != NULL)\n\t    xmlFree((xmlChar *) attr->defaultValue);\n\tif (attr->prefix != NULL)\n\t    xmlFree((xmlChar *) attr->prefix);\n    }\n    xmlFree(attr);\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":493393,"func":"EXPORTED int mailbox_annotation_writemask(struct mailbox *mailbox, uint32_t uid,\n                                          const char *entry, const char *userid,\n                                          const struct buf *value)\n{\n    annotate_state_t *state = NULL;\n    int r = 0;\n    struct buf oldvalue = BUF_INITIALIZER;\n\n    \/* we don't lookupmask here - because we want to still write the value as the\n     * user's own value rather than the masked value, regardless of whether they\n     * have the same content *\/\n    annotatemore_msg_lookup(mailbox, uid, entry, userid, &oldvalue);\n    if (oldvalue.len == value->len && (!value->len || !memcmp(oldvalue.s, value->s, value->len)))\n        goto done;\n\n    struct index_record record;\n    memset(&record, 0, sizeof(struct index_record));\n    r = mailbox_find_index_record(mailbox, uid, &record);\n    if (r) goto done;\n\n    r = mailbox_get_annotate_state(mailbox, uid, &state);\n    if (r) goto done;\n\n    r = annotate_state_writemask(state, entry, userid, value);\n    if (r) goto done;\n\n    \/* need to touch the modseq *\/\n    r = mailbox_rewrite_index_record(mailbox, &record);\n    if (r) goto done;\n\ndone:\n    buf_free(&oldvalue);\n    return r;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":78914,"func":"static void prb_close_block(struct tpacket_kbdq_core *pkc1,\n\t\tstruct tpacket_block_desc *pbd1,\n\t\tstruct packet_sock *po, unsigned int stat)\n{\n\t__u32 status = TP_STATUS_USER | stat;\n\n\tstruct tpacket3_hdr *last_pkt;\n\tstruct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1;\n\n\tif (po->stats.stats3.tp_drops)\n\t\tstatus |= TP_STATUS_LOSING;\n\n\tlast_pkt = (struct tpacket3_hdr *)pkc1->prev;\n\tlast_pkt->tp_next_offset = 0;\n\n\t\/* Get the ts of the last pkt *\/\n\tif (BLOCK_NUM_PKTS(pbd1)) {\n\t\th1->ts_last_pkt.ts_sec = last_pkt->tp_sec;\n\t\th1->ts_last_pkt.ts_nsec\t= last_pkt->tp_nsec;\n\t} else {\n\t\t\/* Ok, we tmo'd - so get the current time *\/\n\t\tstruct timespec ts;\n\t\tgetnstimeofday(&ts);\n\t\th1->ts_last_pkt.ts_sec = ts.tv_sec;\n\t\th1->ts_last_pkt.ts_nsec\t= ts.tv_nsec;\n\t}\n\n\tsmp_wmb();\n\n\t\/* Flush the block *\/\n\tprb_flush_block(pkc1, pbd1, status);\n\n\tpkc1->kactive_blk_num = GET_NEXT_PRB_BLK_NUM(pkc1);\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":244641,"func":"init_params()\n{\n\tSpool = param(\"SPOOL\");\n    if( Spool == NULL ) {\n        EXCEPT( \"SPOOL not specified in config file\\n\" );\n    }\n\n\tLog = param(\"LOG\");\n    if( Log == NULL ) {\n        EXCEPT( \"LOG not specified in config file\\n\" );\n    }\n\n\tDaemonSockDir = param(\"DAEMON_SOCKET_DIR\");\n\tif( DaemonSockDir == NULL ) {\n\t\tEXCEPT(\"DAEMON_SOCKET_DIR not defined\\n\");\n\t}\n\n\tchar *Execute = param(\"EXECUTE\");\n\tif( Execute ) {\n\t\tExecuteDirs.append(Execute);\n\t\tfree(Execute);\n\t\tExecute = NULL;\n\t}\n\tExtArray<ParamValue> *params = param_all();\n\tfor( int p=params->length(); p--; ) {\n\t\tchar const *name = (*params)[p].name.Value();\n\t\tchar *tail = NULL;\n\t\tif( strncasecmp( name, \"SLOT\", 4 ) != 0 ) continue;\n\t\tstrtol( name+4, &tail, 10 );\n\t\tif( tail <= name || strcasecmp( tail, \"_EXECUTE\" ) != 0 ) continue;\n\n\t\tExecute = param(name);\n\t\tif( Execute ) {\n\t\t\tif( !ExecuteDirs.contains( Execute ) ) {\n\t\t\t\tExecuteDirs.append( Execute );\n\t\t\t}\n\t\t\tfree( Execute );\n\t\t}\n\t}\n\tdelete params;\n\n    if( (PreenAdmin = param(\"PREEN_ADMIN\")) == NULL ) {\n\t\tif( (PreenAdmin = param(\"CONDOR_ADMIN\")) == NULL ) {\n\t\t\tEXCEPT( \"CONDOR_ADMIN not specified in config file\" );\n\t\t}\n    }\n\n\tValidSpoolFiles = param(\"VALID_SPOOL_FILES\");\n\n\tInvalidLogFiles = param(\"INVALID_LOG_FILES\");\n\n\tif( (MailPrg = param(\"MAIL\")) == NULL ) {\n\t\tEXCEPT ( \"MAIL not specified in config file\" );\n\t}\n}\n","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":202619,"func":"int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind,\n                   const char *version, const char *serial, const char *model,\n                   uint64_t wwn,\n                   uint32_t cylinders, uint32_t heads, uint32_t secs,\n                   int chs_trans)\n{\n    uint64_t nb_sectors;\n\n    s->blk = blk;\n    s->drive_kind = kind;\n\n    blk_get_geometry(blk, &nb_sectors);\n    s->cylinders = cylinders;\n    s->heads = heads;\n    s->sectors = secs;\n    s->chs_trans = chs_trans;\n    s->nb_sectors = nb_sectors;\n    s->wwn = wwn;\n    \/* The SMART values should be preserved across power cycles\n       but they aren't.  *\/\n    s->smart_enabled = 1;\n    s->smart_autosave = 1;\n    s->smart_errors = 0;\n    s->smart_selftest_count = 0;\n    if (kind == IDE_CD) {\n        blk_set_dev_ops(blk, &ide_cd_block_ops, s);\n        blk_set_guest_block_size(blk, 2048);\n    } else {\n        if (!blk_is_inserted(s->blk)) {\n            error_report(\"Device needs media, but drive is empty\");\n            return -1;\n        }\n        if (blk_is_read_only(blk)) {\n            error_report(\"Can't use a read-only drive\");\n            return -1;\n        }\n        blk_set_dev_ops(blk, &ide_hd_block_ops, s);\n    }\n    if (serial) {\n        pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), serial);\n    } else {\n        snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),\n                 \"QM%05d\", s->drive_serial);\n    }\n    if (model) {\n        pstrcpy(s->drive_model_str, sizeof(s->drive_model_str), model);\n    } else {\n        switch (kind) {\n        case IDE_CD:\n            strcpy(s->drive_model_str, \"QEMU DVD-ROM\");\n            break;\n        case IDE_CFATA:\n            strcpy(s->drive_model_str, \"QEMU MICRODRIVE\");\n            break;\n        default:\n            strcpy(s->drive_model_str, \"QEMU HARDDISK\");\n            break;\n        }\n    }\n\n    if (version) {\n        pstrcpy(s->version, sizeof(s->version), version);\n    } else {\n        pstrcpy(s->version, sizeof(s->version), qemu_get_version());\n    }\n\n    ide_reset(s);\n    blk_iostatus_enable(blk);\n    return 0;\n}\n","target":0,"code_token_length":569,"total_token_length":805,"max_tokens_setting":1024}
+{"idx":88406,"func":"privsep_preauth_child(void)\n{\n\tgid_t gidset[1];\n\tstruct passwd *pw;\n\n\t\/* Enable challenge-response authentication for privilege separation *\/\n\tprivsep_challenge_enable();\n\n#ifdef GSSAPI\n\t\/* Cache supported mechanism OIDs for later use *\/\n\tif (options.gss_authentication)\n\t\tssh_gssapi_prepare_supported_oids();\n#endif\n\n\t\/* Demote the private keys to public keys. *\/\n\tdemote_sensitive_data();\n\n\t\/* Demote the child *\/\n\tif (getuid() == 0 || geteuid() == 0) {\n\t\tif ((pw = getpwnam(SSH_PRIVSEP_USER)) == NULL)\n\t\t\tfatal(\"Privilege separation user %s does not exist\",\n\t\t\t    SSH_PRIVSEP_USER);\n\t\texplicit_bzero(pw->pw_passwd, strlen(pw->pw_passwd));\n\t\tendpwent();\n\n\t\t\/* Change our root directory *\/\n\t\tif (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1)\n\t\t\tfatal(\"chroot(\\\"%s\\\"): %s\", _PATH_PRIVSEP_CHROOT_DIR,\n\t\t\t    strerror(errno));\n\t\tif (chdir(\"\/\") == -1)\n\t\t\tfatal(\"chdir(\\\"\/\\\"): %s\", strerror(errno));\n\n\t\t\/*\n\t\t * Drop our privileges\n\t\t * NB. Can't use setusercontext() after chroot.\n\t\t *\/\n\t\tdebug3(\"privsep user:group %u:%u\", (u_int)pw->pw_uid,\n\t\t    (u_int)pw->pw_gid);\n\t\tgidset[0] = pw->pw_gid;\n\t\tif (setgroups(1, gidset) < 0)\n\t\t\tfatal(\"setgroups: %.100s\", strerror(errno));\n\t\tpermanently_set_uid(pw);\n\t}\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":271721,"func":"static ut32 decodeBitMasks(ut32 imm) {\n\t\/\/ get element size\n\tint size = 32;\n\t\/\/ determine rot to make element be 0^m 1^n\n\tut32 cto, i;\n\tut32 mask = ((ut64) - 1LL) >> (64 - size);\n\n\tif (isShiftedMask (imm)) {\n\t\ti = countTrailingZeros (imm);\n\t\tcto = countTrailingOnes (imm >> i);\n\t} else {\n\t\timm |= ~mask;\n\t\tif (!isShiftedMask (imm)) {\n\t\t\treturn UT32_MAX;\n\t\t}\n\n\t\tut32 clo = countLeadingOnes (imm);\n\t\ti = 64 - clo;\n\t\tcto = clo + countTrailingOnes (imm) - (64 - size);\n\t}\n\n\t\/\/ Encode in Immr the number of RORs it would take to get *from* 0^m 1^n\n\t\/\/ to our target value, where I is the number of RORs to go the opposite\n\t\/\/ direction\n\tut32 immr = (size - i) & (size - 1);\n\t\/\/ If size has a 1 in the n'th bit, create a value that has zeroes in\n\t\/\/ bits [0, n] and ones above that.\n\tut64 nimms = ~(size - 1) << 1;\n\t\/\/ Or the cto value into the low bits, which must be below the Nth bit\n\t\/\/ bit mentioned above.\n\tnimms |= (cto - 1);\n\t\/\/ Extract and toggle seventh bit to make N field.\n\tut32 n = ((nimms >> 6) & 1) ^ 1;\n\tut64 encoding = (n << 12) | (immr << 6) | (nimms & 0x3f);\n\treturn encoding;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":370701,"func":"static void process_delete_command(conn *c, token_t *tokens, const size_t ntokens) {\n    char *key;\n    size_t nkey;\n    item *it;\n\n    assert(c != NULL);\n\n    if (ntokens > 3) {\n        bool hold_is_zero = strcmp(tokens[KEY_TOKEN+1].value, \"0\") == 0;\n        bool sets_noreply = set_noreply_maybe(c, tokens, ntokens);\n        bool valid = (ntokens == 4 && (hold_is_zero || sets_noreply))\n            || (ntokens == 5 && hold_is_zero && sets_noreply);\n        if (!valid) {\n            out_string(c, \"CLIENT_ERROR bad command line format.  \"\n                       \"Usage: delete <key> [noreply]\");\n            return;\n        }\n    }\n\n\n    key = tokens[KEY_TOKEN].value;\n    nkey = tokens[KEY_TOKEN].length;\n\n    if(nkey > KEY_MAX_LENGTH) {\n        out_string(c, \"CLIENT_ERROR bad command line format\");\n        return;\n    }\n\n    if (settings.detail_enabled) {\n        stats_prefix_record_delete(key, nkey);\n    }\n\n    it = item_get(key, nkey);\n    if (it) {\n        MEMCACHED_COMMAND_DELETE(c->sfd, ITEM_key(it), it->nkey);\n\n        pthread_mutex_lock(&c->thread->stats.mutex);\n        c->thread->stats.slab_stats[it->slabs_clsid].delete_hits++;\n        pthread_mutex_unlock(&c->thread->stats.mutex);\n\n        item_unlink(it);\n        item_remove(it);      \/* release our reference *\/\n        out_string(c, \"DELETED\");\n    } else {\n        pthread_mutex_lock(&c->thread->stats.mutex);\n        c->thread->stats.delete_misses++;\n        pthread_mutex_unlock(&c->thread->stats.mutex);\n\n        out_string(c, \"NOT_FOUND\");\n    }\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":10855,"func":"bool FrameSelection::SetSelectionDeprecated(\n    const SelectionInDOMTree& passed_selection,\n    const SetSelectionData& options) {\n  DCHECK(IsAvailable());\n  passed_selection.AssertValidFor(GetDocument());\n\n  SelectionInDOMTree::Builder builder(passed_selection);\n  if (ShouldAlwaysUseDirectionalSelection(frame_))\n    builder.SetIsDirectional(true);\n  SelectionInDOMTree new_selection = builder.Build();\n  if (granularity_strategy_ && !options.DoNotClearStrategy())\n    granularity_strategy_->Clear();\n  granularity_ = options.Granularity();\n\n  if (options.ShouldCloseTyping())\n    TypingCommand::CloseTyping(frame_);\n\n  if (options.ShouldClearTypingStyle())\n    frame_->GetEditor().ClearTypingStyle();\n \n   const SelectionInDOMTree old_selection_in_dom_tree =\n       selection_editor_->GetSelectionInDOMTree();\n  if (old_selection_in_dom_tree == new_selection)\n     return false;\n  selection_editor_->SetSelection(new_selection);\n   ScheduleVisualUpdateForPaintInvalidationIfNeeded();\n \n   const Document& current_document = GetDocument();\n  frame_->GetEditor().RespondToChangedSelection(\n      old_selection_in_dom_tree.ComputeStartPosition(),\n      options.ShouldCloseTyping() ? TypingContinuation::kEnd\n                                  : TypingContinuation::kContinue);\n  DCHECK_EQ(current_document, GetDocument());\n  return true;\n}\n","target":1,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":136382,"func":"inline int web_client_api_request_single_chart(RRDHOST *host, struct web_client *w, char *url, void callback(RRDSET *st, BUFFER *buf)) {\n    int ret = 400;\n    char *chart = NULL;\n\n    buffer_flush(w->response.data);\n\n    while(url) {\n        char *value = mystrsep(&url, \"?&\");\n        if(!value || !*value) continue;\n\n        char *name = mystrsep(&value, \"=\");\n        if(!name || !*name) continue;\n        if(!value || !*value) continue;\n\n        \/\/ name and value are now the parameters\n        \/\/ they are not null and not empty\n\n        if(!strcmp(name, \"chart\")) chart = value;\n        \/\/else {\n        \/\/\/ buffer_sprintf(w->response.data, \"Unknown parameter '%s' in request.\", name);\n        \/\/  goto cleanup;\n        \/\/}\n    }\n\n    if(!chart || !*chart) {\n        buffer_sprintf(w->response.data, \"No chart id is given at the request.\");\n        goto cleanup;\n    }\n\n    RRDSET *st = rrdset_find(host, chart);\n    if(!st) st = rrdset_find_byname(host, chart);\n    if(!st) {\n        buffer_strcat(w->response.data, \"Chart is not found: \");\n        buffer_strcat_htmlescape(w->response.data, chart);\n        ret = 404;\n        goto cleanup;\n    }\n\n    w->response.data->contenttype = CT_APPLICATION_JSON;\n    st->last_accessed_time = now_realtime_sec();\n    callback(st, w->response.data);\n    return 200;\n\n    cleanup:\n    return ret;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":102546,"func":"    void SGeometry_PropertyScanner::open(int container_id)\n    {\n        \/\/ First check for container_id, if variable doesn't exist error out\n        if(nc_inq_var(this->nc, container_id, nullptr, nullptr, nullptr, nullptr, nullptr) != NC_NOERR)\n        {\n            return;    \/\/ change to exception\n        }\n\n        \/\/ Now exists, see what variables refer to this one\n        \/\/ First get name of this container\n        char contname[NC_MAX_NAME + 1];\n        memset(contname, 0, NC_MAX_NAME + 1);\n        if(nc_inq_varname(this->nc, container_id, contname) != NC_NOERR)\n        {\n            return;\n        }\n\n        \/\/ Then scan throughout the netcdfDataset if those variables geometry_container\n        \/\/ atrribute matches the container\n        int varCount = 0;\n        if(nc_inq_nvars(this->nc, &varCount) != NC_NOERR)\n        {\n            return;\n        }\n\n        for(int curr = 0; curr < varCount; curr++)\n        {\n            size_t contname2_len = 0;\n            \n            \/\/ First find container length, and make buf that size in chars\n            if(nc_inq_attlen(this->nc, curr, CF_SG_GEOMETRY, &contname2_len) != NC_NOERR)\n            {\n                \/\/ not a geometry variable, continue\n                continue;\n            }\n\n            \/\/ Also if present but empty, go on\n            if(contname2_len == 0) continue;\n\n            \/\/ Otherwise, geometry: see what container it has\n            char buf[NC_MAX_CHAR + 1];\n            memset(buf, 0, NC_MAX_CHAR + 1);\n\n            if(nc_get_att_text(this->nc, curr, CF_SG_GEOMETRY, buf)!= NC_NOERR)\n            {\n                continue;\n            }\n\n            \/\/ If matches, then establish a reference by placing this variable's data in both vectors\n            if(!strcmp(contname, buf))\n            {\n                char property_name[NC_MAX_NAME];\n                nc_inq_varname(this->nc, curr, property_name);\n                \n                std::string n(property_name);\n                v_ids.push_back(curr);\n                v_headers.push_back(n);\n            }\n        }\n    }","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":493775,"func":"static void rename_open_files(connection_struct *conn,\n\t\t\t      struct share_mode_lock *lck,\n\t\t\t      struct file_id id,\n\t\t\t      uint32_t orig_name_hash,\n\t\t\t      const struct smb_filename *smb_fname_dst)\n{\n\tfiles_struct *fsp;\n\tbool did_rename = False;\n\tNTSTATUS status;\n\tuint32_t new_name_hash = 0;\n\n\tfor(fsp = file_find_di_first(conn->sconn, id, false); fsp;\n\t    fsp = file_find_di_next(fsp, false)) {\n\t\tSMB_STRUCT_STAT fsp_orig_sbuf;\n\t\tstruct file_id_buf idbuf;\n\t\t\/* fsp_name is a relative path under the fsp. To change this for other\n\t\t   sharepaths we need to manipulate relative paths. *\/\n\t\t\/* TODO - create the absolute path and manipulate the newname\n\t\t   relative to the sharepath. *\/\n\t\tif (!strequal(fsp->conn->connectpath, conn->connectpath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (fsp->name_hash != orig_name_hash) {\n\t\t\tcontinue;\n\t\t}\n\t\tDBG_DEBUG(\"renaming file %s \"\n\t\t\t  \"(file_id %s) from %s -> %s\\n\",\n\t\t\t  fsp_fnum_dbg(fsp),\n\t\t\t  file_id_str_buf(fsp->file_id, &idbuf),\n\t\t\t  fsp_str_dbg(fsp),\n\t\t\t  smb_fname_str_dbg(smb_fname_dst));\n\n\t\t\/*\n\t\t * The incoming smb_fname_dst here has an\n\t\t * invalid stat struct (it must not have\n\t\t * existed for the rename to succeed).\n\t\t * Preserve the existing stat from the\n\t\t * open fsp after fsp_set_smb_fname()\n\t\t * overwrites with the invalid stat.\n\t\t *\n\t\t * We will do an fstat before returning\n\t\t * any of this metadata to the client anyway.\n\t\t *\/\n\t\tfsp_orig_sbuf = fsp->fsp_name->st;\n\t\tstatus = fsp_set_smb_fname(fsp, smb_fname_dst);\n\t\tif (NT_STATUS_IS_OK(status)) {\n\t\t\tdid_rename = True;\n\t\t\tnew_name_hash = fsp->name_hash;\n\t\t\t\/* Restore existing stat. *\/\n\t\t\tfsp->fsp_name->st = fsp_orig_sbuf;\n\t\t}\n\t}\n\n\tif (!did_rename) {\n\t\tstruct file_id_buf idbuf;\n\t\tDBG_DEBUG(\"no open files on file_id %s \"\n\t\t\t  \"for %s\\n\",\n\t\t\t  file_id_str_buf(id, &idbuf),\n\t\t\t  smb_fname_str_dbg(smb_fname_dst));\n\t}\n\n\t\/* Send messages to all smbd's (not ourself) that the name has changed. *\/\n\trename_share_filename(conn->sconn->msg_ctx, lck, id, conn->connectpath,\n\t\t\t      orig_name_hash, new_name_hash,\n\t\t\t      smb_fname_dst);\n\n}","target":0,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":410758,"func":"static char *expand_escapes(const char *line, SERVER_REC *server,\n\t\t\t    WI_ITEM_REC *item)\n{\n\tchar *ptr, *ret;\n\tconst char *prev;\n\tint chr;\n\n\tprev = line;\n\tret = ptr = g_malloc(strlen(line)+1);\n\tfor (; *line != '\\0'; line++) {\n\t\tif (*line != '\\\\') {\n\t\t\t*ptr++ = *line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tline++;\n\t\tif (*line == '\\0') {\n\t\t\t*ptr++ = '\\\\';\n\t\t\tbreak;\n\t\t}\n\n\t\tchr = expand_escape(&line);\n\t\tif (chr == '\\r' || chr == '\\n') {\n\t\t\t\/* newline .. we need to send another \"send text\"\n\t\t\t   event to handle it (or actually the text before\n\t\t\t   the newline..) *\/\n\t\t\tif (prev != line) {\n\t\t\t\tchar *prev_line = g_strndup(prev, (line - prev) - 1);\n\t\t\t\tevent_text(prev_line, server, item);\n\t\t\t\tg_free(prev_line);\n\t\t\t\tprev = line + 1;\n\t\t\t\tptr = ret;\n\t\t\t}\n\t\t} else if (chr != -1) {\n                        \/* escaping went ok *\/\n\t\t\t*ptr++ = chr;\n\t\t} else {\n                        \/* unknown escape, add it as-is *\/\n\t\t\t*ptr++ = '\\\\';\n\t\t\t*ptr++ = *line;\n\t\t}\n\t}\n\n\t*ptr = '\\0';\n\treturn ret;\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":422459,"func":"ews_connection_gather_auth_methods_cb (SoupMessage *message,\n\t\t\t\t       GSimpleAsyncResult *simple)\n{\n\tEwsAsyncData *async_data;\n\tconst gchar *auths_lst;\n\tgboolean has_bearer = FALSE;\n\tgchar **auths;\n\tgint ii;\n\n\tasync_data = g_simple_async_result_get_op_res_gpointer (simple);\n\n\tg_return_if_fail (async_data != NULL);\n\n\tauths_lst = soup_message_headers_get_list (message->response_headers, \"WWW-Authenticate\");\n\tif (!auths_lst)\n\t\treturn;\n\n\tauths = g_strsplit (auths_lst, \",\", -1);\n\tfor (ii = 0; auths && auths[ii]; ii++) {\n\t\tgchar *auth, *space;\n\n\t\tauth = g_strstrip (g_strdup (auths[ii]));\n\t\tif (auth && *auth) {\n\t\t\tspace = strchr (auth, ' ');\n\t\t\tif (space)\n\t\t\t\t*space = '\\0';\n\n\t\t\thas_bearer = has_bearer || g_ascii_strcasecmp (auth, \"Bearer\") == 0;\n\t\t\tasync_data->items = g_slist_prepend (async_data->items, auth);\n\t\t} else {\n\t\t\tg_free (auth);\n\t\t}\n\t}\n\n\tg_strfreev (auths);\n\n\tif (!has_bearer) {\n\t\t\/* Special-case Office365 OAuth2, because outlook.office365.com doesn't advertise Bearer *\/\n\t\tSoupURI *suri;\n\n\t\tsuri = soup_message_get_uri (message);\n\t\tif (suri && soup_uri_get_host (suri) &&\n\t\t    g_ascii_strcasecmp (soup_uri_get_host (suri), \"outlook.office365.com\") == 0) {\n\t\t\tasync_data->items = g_slist_prepend (async_data->items, g_strdup (\"Bearer\"));\n\t\t}\n\t}\n\n\tg_object_set_data (G_OBJECT (simple), EWS_OBJECT_KEY_AUTHS_GATHERED, GINT_TO_POINTER (1));\n\n\tsoup_message_set_status_full (message, SOUP_STATUS_CANCELLED, \"EWS auths gathered\");\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":449017,"func":"UTI_StringToIP(const char *addr, IPAddr *ip)\n{\n#ifdef FEAT_IPV6\n  struct in_addr in4;\n  struct in6_addr in6;\n\n  if (inet_pton(AF_INET, addr, &in4) > 0) {\n    ip->family = IPADDR_INET4;\n    ip->_pad = 0;\n    ip->addr.in4 = ntohl(in4.s_addr);\n    return 1;\n  }\n\n  if (inet_pton(AF_INET6, addr, &in6) > 0) {\n    ip->family = IPADDR_INET6;\n    ip->_pad = 0;\n    memcpy(ip->addr.in6, in6.s6_addr, sizeof (ip->addr.in6));\n    return 1;\n  }\n#else\n  unsigned long a, b, c, d, n;\n\n  n = sscanf(addr, \"%lu.%lu.%lu.%lu\", &a, &b, &c, &d);\n  if (n == 4) {\n    ip->family = IPADDR_INET4;\n    ip->_pad = 0;\n    ip->addr.in4 = ((a & 0xff) << 24) | ((b & 0xff) << 16) | \n                   ((c & 0xff) << 8) | (d & 0xff);\n    return 1;\n  }\n#endif\n\n  return 0;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":401839,"func":"ZEND_VM_HANDLER(128, ZEND_INIT_DYNAMIC_CALL, ANY, CONST|TMPVAR|CV, NUM)\n{\n\tUSE_OPLINE\n\tzend_free_op free_op2;\n\tzval *function_name;\n\tzend_execute_data *call;\n\n\tSAVE_OPLINE();\n\tfunction_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);\n\nZEND_VM_C_LABEL(try_function_name):\n\tif (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {\n\t\tcall = zend_init_dynamic_call_string(Z_STR_P(function_name), opline->extended_value);\n\t} else if (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT)) {\n\t\tcall = zend_init_dynamic_call_object(function_name, opline->extended_value);\n\t} else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY)) {\n\t\tcall = zend_init_dynamic_call_array(Z_ARRVAL_P(function_name), opline->extended_value);\n\t} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(function_name) == IS_REFERENCE)) {\n\t\tfunction_name = Z_REFVAL_P(function_name);\n\t\tZEND_VM_C_GOTO(try_function_name);\n\t} else {\n\t\tif (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {\n\t\t\tZVAL_UNDEFINED_OP2();\n\t\t\tif (UNEXPECTED(EG(exception) != NULL)) {\n\t\t\t\tHANDLE_EXCEPTION();\n\t\t\t}\n\t\t}\n\t\tzend_throw_error(NULL, \"Function name must be a string\");\n\t\tcall = NULL;\n\t}\n\n\tFREE_OP2();\n\tif (UNEXPECTED(!call)) {\n\t\tHANDLE_EXCEPTION();\n\t}\n\n\tif (OP2_TYPE & (IS_VAR|IS_TMP_VAR)) {\n\t\tif (UNEXPECTED(EG(exception))) {\n\t\t\tif (call) {\n\t\t\t\t if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {\n\t\t\t\t\tzend_string_release_ex(call->func->common.function_name, 0);\n\t\t\t\t\tzend_free_trampoline(call->func);\n\t\t\t\t}\n\t\t\t\tzend_vm_stack_free_call_frame(call);\n\t\t\t}\n\t\t\tHANDLE_EXCEPTION();\n\t\t}\n\t}\n\n\tcall->prev_execute_data = EX(call);\n\tEX(call) = call;\n\n\tZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();\n}","target":0,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":346632,"func":"windows_icon_typefind (GstTypeFind * find, gpointer user_data)\n{\n  const guint8 *data;\n  gint64 datalen;\n  guint16 type, nimages;\n  gint32 size, offset;\n\n  datalen = gst_type_find_get_length (find);\n  if ((data = gst_type_find_peek (find, 0, 6)) == NULL)\n    return;\n\n  \/* header - simple and not enough to rely on it alone *\/\n  if (GST_READ_UINT16_LE (data) != 0)\n    return;\n  type = GST_READ_UINT16_LE (data + 2);\n  if (type != 1 && type != 2)\n    return;\n  nimages = GST_READ_UINT16_LE (data + 4);\n  if (nimages == 0)             \/* we can assume we can't have an empty image file ? *\/\n    return;\n\n  \/* first image *\/\n  if (data[6 + 3] != 0)\n    return;\n  if (type == 1) {\n    guint16 planes = GST_READ_UINT16_LE (data + 6 + 4);\n    if (planes > 1)\n      return;\n  }\n  size = GST_READ_UINT32_LE (data + 6 + 8);\n  offset = GST_READ_UINT32_LE (data + 6 + 12);\n  if (offset < 0 || size <= 0 || size >= datalen || offset >= datalen\n      || size + offset > datalen)\n    return;\n\n  gst_type_find_suggest_simple (find, GST_TYPE_FIND_NEARLY_CERTAIN,\n      \"image\/x-icon\", NULL);\n}","target":1,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":114964,"func":"static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,\n\t\t\t\t     struct pipe_buffer *buf)\n{\n\tstruct page *page = buf->page;\n\tstruct address_space *mapping;\n\n\tlock_page(page);\n\n\tmapping = page_mapping(page);\n\tif (mapping) {\n\t\tWARN_ON(!PageUptodate(page));\n\n\t\t\/*\n\t\t * At least for ext2 with nobh option, we need to wait on\n\t\t * writeback completing on this page, since we'll remove it\n\t\t * from the pagecache.  Otherwise truncate wont wait on the\n\t\t * page, allowing the disk blocks to be reused by someone else\n\t\t * before we actually wrote our data to them. fs corruption\n\t\t * ensues.\n\t\t *\/\n\t\twait_on_page_writeback(page);\n\n\t\tif (page_has_private(page) &&\n\t\t    !try_to_release_page(page, GFP_KERNEL))\n\t\t\tgoto out_unlock;\n\n\t\t\/*\n\t\t * If we succeeded in removing the mapping, set LRU flag\n\t\t * and return good.\n\t\t *\/\n\t\tif (remove_mapping(mapping, page)) {\n\t\t\tbuf->flags |= PIPE_BUF_FLAG_LRU;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t\/*\n\t * Raced with truncate or failed to remove page from current\n\t * address space, unlock and return failure.\n\t *\/\nout_unlock:\n\tunlock_page(page);\n\treturn 1;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":241219,"func":"void ResourceLoader::DidReceiveResponse(\n    const WebURLResponse& web_url_response,\n    std::unique_ptr<WebDataConsumerHandle> handle) {\n  DCHECK(!web_url_response.IsNull());\n\n  Resource::Type resource_type = resource_->GetType();\n\n  const ResourceRequest& initial_request = resource_->GetResourceRequest();\n  WebURLRequest::RequestContext request_context =\n      initial_request.GetRequestContext();\n  WebURLRequest::FetchRequestMode fetch_request_mode =\n      initial_request.GetFetchRequestMode();\n\n  const ResourceLoaderOptions& options = resource_->Options();\n\n  const ResourceResponse& response = web_url_response.ToResourceResponse();\n\n  StringBuilder cors_error_msg;\n  resource_->SetCORSStatus(DetermineCORSStatus(response, cors_error_msg));\n\n  if (response.WasFetchedViaServiceWorker()) {\n    if (options.cors_handling_by_resource_fetcher ==\n            kEnableCORSHandlingByResourceFetcher &&\n        fetch_request_mode == WebURLRequest::kFetchRequestModeCORS &&\n        response.WasFallbackRequiredByServiceWorker()) {\n      ResourceRequest last_request = resource_->LastResourceRequest();\n      DCHECK_EQ(last_request.GetServiceWorkerMode(),\n                WebURLRequest::ServiceWorkerMode::kAll);\n      if (!Context().ShouldLoadNewResource(resource_type)) {\n        HandleError(ResourceError::CancelledError(response.Url()));\n        return;\n      }\n      last_request.SetServiceWorkerMode(\n          WebURLRequest::ServiceWorkerMode::kForeign);\n      Restart(last_request);\n      return;\n    }\n\n    const KURL& original_url = response.OriginalURLViaServiceWorker();\n    if (!original_url.IsEmpty()) {\n      Context().CheckCSPForRequest(\n          request_context, original_url, options,\n          SecurityViolationReportingPolicy::kReport,\n          ResourceRequest::RedirectStatus::kFollowedRedirect);\n\n      ResourceRequestBlockedReason blocked_reason = Context().CanRequest(\n          resource_type, initial_request, original_url, options,\n          SecurityViolationReportingPolicy::kReport,\n          FetchParameters::kUseDefaultOriginRestrictionForType,\n          ResourceRequest::RedirectStatus::kFollowedRedirect);\n      if (blocked_reason != ResourceRequestBlockedReason::kNone) {\n        HandleError(ResourceError::CancelledDueToAccessCheckError(\n            original_url, blocked_reason));\n        return;\n      }\n    }\n  } else if (options.cors_handling_by_resource_fetcher ==\n                 kEnableCORSHandlingByResourceFetcher &&\n             fetch_request_mode == WebURLRequest::kFetchRequestModeCORS) {\n    if (!resource_->IsSameOriginOrCORSSuccessful()) {\n      if (!resource_->IsUnusedPreload())\n        Context().AddErrorConsoleMessage(cors_error_msg.ToString(),\n                                         FetchContext::kJSSource);\n\n      HandleError(ResourceError::CancelledDueToAccessCheckError(\n          response.Url(), ResourceRequestBlockedReason::kOther));\n      return;\n    }\n  }\n\n  Context().DispatchDidReceiveResponse(\n      resource_->Identifier(), response, initial_request.GetFrameType(),\n      request_context, resource_,\n      FetchContext::ResourceResponseType::kNotFromMemoryCache);\n\n  resource_->ResponseReceived(response, std::move(handle));\n  if (!resource_->Loader())\n    return;\n\n  if (response.HttpStatusCode() >= 400 &&\n      !resource_->ShouldIgnoreHTTPStatusCodeErrors())\n    HandleError(ResourceError::CancelledError(response.Url()));\n}\n","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":396353,"func":"poolGrow(STRING_POOL *pool)\n{\n  if (pool->freeBlocks) {\n    if (pool->start == 0) {\n      pool->blocks = pool->freeBlocks;\n      pool->freeBlocks = pool->freeBlocks->next;\n      pool->blocks->next = NULL;\n      pool->start = pool->blocks->s;\n      pool->end = pool->start + pool->blocks->size;\n      pool->ptr = pool->start;\n      return XML_TRUE;\n    }\n    if (pool->end - pool->start < pool->freeBlocks->size) {\n      BLOCK *tem = pool->freeBlocks->next;\n      pool->freeBlocks->next = pool->blocks;\n      pool->blocks = pool->freeBlocks;\n      pool->freeBlocks = tem;\n      memcpy(pool->blocks->s, pool->start,\n             (pool->end - pool->start) * sizeof(XML_Char));\n      pool->ptr = pool->blocks->s + (pool->ptr - pool->start);\n      pool->start = pool->blocks->s;\n      pool->end = pool->start + pool->blocks->size;\n      return XML_TRUE;\n    }\n  }\n  if (pool->blocks && pool->start == pool->blocks->s) {\n    BLOCK *temp;\n    int blockSize = (int)((unsigned)(pool->end - pool->start)*2U);\n\n    if (blockSize < 0)\n      return XML_FALSE;\n\n    temp = (BLOCK *)\n      pool->mem->realloc_fcn(pool->blocks,\n                             (offsetof(BLOCK, s)\n                              + blockSize * sizeof(XML_Char)));\n    if (temp == NULL)\n      return XML_FALSE;\n    pool->blocks = temp;\n    pool->blocks->size = blockSize;\n    pool->ptr = pool->blocks->s + (pool->ptr - pool->start);\n    pool->start = pool->blocks->s;\n    pool->end = pool->start + blockSize;\n  }\n  else {\n    BLOCK *tem;\n    int blockSize = (int)(pool->end - pool->start);\n\n    if (blockSize < 0)\n      return XML_FALSE;\n\n    if (blockSize < INIT_BLOCK_SIZE)\n      blockSize = INIT_BLOCK_SIZE;\n    else\n      blockSize *= 2;\n    tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s)\n                                        + blockSize * sizeof(XML_Char));\n    if (!tem)\n      return XML_FALSE;\n    tem->size = blockSize;\n    tem->next = pool->blocks;\n    pool->blocks = tem;\n    if (pool->ptr != pool->start)\n      memcpy(tem->s, pool->start,\n             (pool->ptr - pool->start) * sizeof(XML_Char));\n    pool->ptr = tem->s + (pool->ptr - pool->start);\n    pool->start = tem->s;\n    pool->end = tem->s + blockSize;\n  }\n  return XML_TRUE;\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":25210,"func":"int parse_args ( int argc , char * * argv ) {\n if ( load_defaults ( \"my\" , load_default_groups , & argc , & argv ) ) exit ( 1 ) ;\n default_argv = argv ;\n if ( ( handle_options ( & argc , & argv , my_long_options , get_one_option ) ) ) exit ( 1 ) ;\n if ( argc > 1 ) {\n usage ( ) ;\n exit ( 1 ) ;\n }\n if ( argc == 1 ) opt_db = * argv ;\n if ( tty_password ) opt_pass = get_tty_password ( NullS ) ;\n if ( debug_info_flag ) my_end_arg = MY_CHECK_ERROR | MY_GIVE_INFO ;\n if ( debug_check_flag ) my_end_arg |= MY_CHECK_ERROR ;\n if ( global_subst != NULL ) {\n char * comma = strstr ( global_subst , \",\" ) ;\n if ( comma == NULL ) die ( \"wrong --global-subst, must be X,Y\" ) ;\n memcpy ( global_subst_from , global_subst , ( comma - global_subst ) ) ;\n global_subst_from [ comma - global_subst ] = 0 ;\n memcpy ( global_subst_to , comma + 1 , strlen ( comma ) ) ;\n }\n if ( ! opt_suite_dir ) opt_suite_dir = \".\/\" ;\n suite_dir_len = strlen ( opt_suite_dir ) ;\n overlay_dir_len = opt_overlay_dir ? strlen ( opt_overlay_dir ) : 0 ;\n if ( ! record ) {\n if ( result_file_name && access ( result_file_name , F_OK ) != 0 ) die ( \"The specified result file '%s' does not exist\" , result_file_name ) ;\n }\n return 0 ;\n }","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":226290,"func":"void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, RenderStyle* style, const Font& font, bool background)\n{\n    if (!renderer()->node())\n        return;\n\n    Vector<DocumentMarker> markers = renderer()->document()->markers()->markersForNode(renderer()->node());\n    Vector<DocumentMarker>::iterator markerIt = markers.begin();\n\n    for ( ; markerIt != markers.end(); markerIt++) {\n        const DocumentMarker& marker = *markerIt;\n        \n        switch (marker.type) {\n            case DocumentMarker::Grammar:\n            case DocumentMarker::Spelling:\n            case DocumentMarker::Replacement:\n            case DocumentMarker::CorrectionIndicator:\n            case DocumentMarker::RejectedCorrection:\n                if (background)\n                    continue;\n                break;\n            case DocumentMarker::TextMatch:\n                if (!background)\n                    continue;\n                break;\n            \n            default:\n                ASSERT_NOT_REACHED();\n        }\n\n        if (marker.endOffset <= start())\n            continue;\n        \n        if (marker.startOffset > end())\n            break;\n        \n        switch (marker.type) {\n            case DocumentMarker::Spelling:\n                paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false);\n                break;\n            case DocumentMarker::Grammar:\n                paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, true);\n                break;\n            case DocumentMarker::TextMatch:\n                paintTextMatchMarker(pt, tx, ty, marker, style, font);\n                break;\n            case DocumentMarker::CorrectionIndicator:\n                computeRectForReplacementMarker(tx, ty, marker, style, font);\n                paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false);\n                break;\n            case DocumentMarker::Replacement:\n            case DocumentMarker::RejectedCorrection:\n                break;\n            default:\n                ASSERT_NOT_REACHED();\n        }\n\n    }\n}\n","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":298734,"func":"static SDL_INLINE void BG_Blended_Color(const TTF_Image *image, Uint32 *destination, Sint32 srcskip, Uint32 dstskip, Uint8 fg_alpha)\n{\n    const Uint32 *src   = (Uint32 *)image->buffer;\n    Uint32      *dst    = destination;\n    Uint32       width  = image->width;\n    Uint32       height = image->rows;\n\n    if (fg_alpha == 0) { \/* SDL_ALPHA_OPAQUE *\/\n        while (height--) {\n            \/* *INDENT-OFF* *\/\n            DUFFS_LOOP4(\n                *dst++ = *src++;\n            , width);\n            \/* *INDENT-ON* *\/\n            src = (const Uint32 *)((const Uint8 *)src + srcskip);\n            dst = (Uint32 *)((Uint8 *)dst + dstskip);\n        }\n    } else {\n        Uint32 alpha;\n        Uint32 tmp;\n\n        while (height--) {\n            \/* *INDENT-OFF* *\/\n            DUFFS_LOOP4(\n                    tmp = *src++;\n                    alpha = tmp >> 24;\n                    tmp &= ~0xFF000000;\n                    alpha = fg_alpha * alpha;\n                    alpha =  DIVIDE_BY_255(alpha) << 24;\n                    *dst++ = tmp | alpha\n                    , width);\n            \/* *INDENT-ON* *\/\n            src = (const Uint32 *)((const Uint8 *)src + srcskip);\n            dst = (Uint32 *)((Uint8 *)dst + dstskip);\n        }\n    }\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":12786,"func":"static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)\n{\n\twhile (elements-- > 0) {\n\t\tzval *key, *data, **old_data;\n\n\t\tALLOC_INIT_ZVAL(key);\n\n\t\tif (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {\n\t\t\tzval_dtor(key);\n\t\t\tFREE_ZVAL(key);\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (Z_TYPE_P(key) != IS_LONG && Z_TYPE_P(key) != IS_STRING) {\n\t\t\tzval_dtor(key);\n\t\t\tFREE_ZVAL(key);\n\t\t\treturn 0;\n\t\t}\n\n\t\tALLOC_INIT_ZVAL(data);\n\n\t\tif (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {\n\t\t\tzval_dtor(key);\n\t\t\tFREE_ZVAL(key);\n\t\t\tzval_dtor(data);\n\t\t\tFREE_ZVAL(data);\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (!objprops) {\n\t\t\tswitch (Z_TYPE_P(key)) {\n\t\t\tcase IS_LONG:\n\t\t\t\tif (zend_hash_index_find(ht, Z_LVAL_P(key), (void **)&old_data)==SUCCESS) {\n\t\t\t\t\tvar_push_dtor(var_hash, old_data);\n\t\t\t\t}\n\t\t\t\tzend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);\n\t\t\t\tbreak;\n\t\t\tcase IS_STRING:\n\t\t\t\tif (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {\n\t\t\t\t\tvar_push_dtor(var_hash, old_data);\n\t\t\t\t}\n\t\t\t\tzend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);\n\t\t\t\tbreak;\n\t\t\t}\n                } else {\n                        \/* object properties should include no integers *\/\n                        convert_to_string(key);\n                        zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,\n                                        sizeof data, NULL);\n                }\n\n\t\tif (elements && *(*p-1) != ';' && *(*p-1) != '}') {\n\t\t\t(*p)--;\n\t\t\treturn 0;\n\t\t}\n\t}\n","target":1,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":166702,"func":"int CountFilesCreatedAfter(const FilePath& path,\n                           const base::Time& comparison_time) {\n  base::ThreadRestrictions::AssertIOAllowed();\n  int file_count = 0;\n\n  DIR* dir = opendir(path.value().c_str());\n  if (dir) {\n#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_BSD) && \\\n    !defined(OS_SOLARIS) && !defined(OS_ANDROID)\n  #error Port warning: depending on the definition of struct dirent, \\\n         additional space for pathname may be needed\n#endif\n    struct dirent ent_buf;\n    struct dirent* ent;\n    while (readdir_r(dir, &ent_buf, &ent) == 0 && ent) {\n      if ((strcmp(ent->d_name, \".\") == 0) ||\n          (strcmp(ent->d_name, \"..\") == 0))\n        continue;\n\n      stat_wrapper_t st;\n      int test = CallStat(path.Append(ent->d_name).value().c_str(), &st);\n      if (test != 0) {\n        DPLOG(ERROR) << \"stat64 failed\";\n        continue;\n      }\n      if (static_cast<time_t>(st.st_ctime) >= comparison_time.ToTimeT())\n        ++file_count;\n    }\n    closedir(dir);\n  }\n  return file_count;\n}\n","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":173944,"func":"status_t ACodec::allocateOutputBuffersFromNativeWindow() {\n    OMX_U32 bufferCount, bufferSize, minUndequeuedBuffers;\n status_t err = configureOutputBuffersFromNativeWindow(\n &bufferCount, &bufferSize, &minUndequeuedBuffers);\n if (err != 0)\n return err;\n    mNumUndequeuedBuffers = minUndequeuedBuffers;\n\n if (!storingMetadataInDecodedBuffers()) {\n static_cast<Surface*>(mNativeWindow.get())\n ->getIGraphicBufferProducer()->allowAllocation(true);\n }\n\n    ALOGV(\"[%s] Allocating %u buffers from a native window of size %u on \"\n \"output port\",\n         mComponentName.c_str(), bufferCount, bufferSize);\n\n for (OMX_U32 i = 0; i < bufferCount; i++) {\n ANativeWindowBuffer *buf;\n int fenceFd;\n        err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf, &fenceFd);\n if (err != 0) {\n            ALOGE(\"dequeueBuffer failed: %s (%d)\", strerror(-err), -err);\n break;\n }\n\n        sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(buf, false));\n BufferInfo info;\n        info.mStatus = BufferInfo::OWNED_BY_US;\n        info.mFenceFd = fenceFd;\n        info.mIsReadFence = false;\n        info.mRenderInfo = NULL;\n        info.mData = new ABuffer(NULL \/* data *\/, bufferSize \/* capacity *\/);\n        info.mGraphicBuffer = graphicBuffer;\n        mBuffers[kPortIndexOutput].push(info);\n\n        IOMX::buffer_id bufferId;\n        err = mOMX->useGraphicBuffer(mNode, kPortIndexOutput, graphicBuffer,\n &bufferId);\n if (err != 0) {\n            ALOGE(\"registering GraphicBuffer %u with OMX IL component failed: \"\n \"%d\", i, err);\n break;\n }\n\n        mBuffers[kPortIndexOutput].editItemAt(i).mBufferID = bufferId;\n\n        ALOGV(\"[%s] Registered graphic buffer with ID %u (pointer = %p)\",\n             mComponentName.c_str(),\n             bufferId, graphicBuffer.get());\n }\n\n    OMX_U32 cancelStart;\n    OMX_U32 cancelEnd;\n\n if (err != 0) {\n        cancelStart = 0;\n        cancelEnd = mBuffers[kPortIndexOutput].size();\n } else {\n        cancelStart = bufferCount - minUndequeuedBuffers;\n        cancelEnd = bufferCount;\n }\n\n for (OMX_U32 i = cancelStart; i < cancelEnd; i++) {\n BufferInfo *info = &mBuffers[kPortIndexOutput].editItemAt(i);\n if (info->mStatus == BufferInfo::OWNED_BY_US) {\n status_t error = cancelBufferToNativeWindow(info);\n if (err == 0) {\n                err = error;\n }\n }\n }\n\n if (!storingMetadataInDecodedBuffers()) {\n static_cast<Surface*>(mNativeWindow.get())\n ->getIGraphicBufferProducer()->allowAllocation(false);\n }\n\n return err;\n}\n","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":396051,"func":"word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)\n{\n    Source source(encoded, sz);\n\n    if (source.next() != (SEQUENCE | CONSTRUCTED)) {\n        source.SetError(SEQUENCE_E);\n        return 0;\n    }\n\n    GetLength(source);  \/\/ total\n\n    \/\/ r\n    if (source.next() != INTEGER) {\n        source.SetError(INTEGER_E);\n        return 0;\n    }\n    word32 rLen = GetLength(source);\n    if (rLen != 20) {\n        while (rLen > 20 && source.remaining() > 0) {  \/\/ zero's at front, eat\n            source.next();\n            --rLen;\n        }\n        if (rLen < 20) { \/\/ add zero's to front so 20 bytes\n            word32 tmpLen = rLen;\n            while (tmpLen < 20) {\n            decoded[0] = 0;\n            decoded++;\n                tmpLen++;\n        }\n        }\n    }\n    memcpy(decoded, source.get_buffer() + source.get_index(), rLen);\n    source.advance(rLen);\n\n    \/\/ s\n    if (source.next() != INTEGER) {\n        source.SetError(INTEGER_E);\n        return 0;\n    }\n    word32 sLen = GetLength(source);\n    if (sLen != 20) {\n        while (sLen > 20 && source.remaining() > 0) {\n            source.next();          \/\/ zero's at front, eat\n            --sLen;\n        }\n        if (sLen < 20) { \/\/ add zero's to front so 20 bytes\n            word32 tmpLen = sLen;\n            while (tmpLen < 20) {\n                decoded[rLen] = 0;\n            decoded++;\n                tmpLen++;\n        }\n        }\n    }\n    memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen);\n    source.advance(sLen);\n\n    return 40;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":408572,"func":"int finish_transfer(const char *fname, const char *fnametmp,\n\t\t    const char *fnamecmp, const char *partialptr,\n\t\t    struct file_struct *file, int ok_to_set_time,\n\t\t    int overwriting_basis)\n{\n\tint ret;\n\tconst char *temp_copy_name = partialptr && *partialptr != '\/' ? partialptr : NULL;\n\n\tif (inplace) {\n\t\tif (DEBUG_GTE(RECV, 1))\n\t\t\trprintf(FINFO, \"finishing %s\\n\", fname);\n\t\tfnametmp = fname;\n\t\tgoto do_set_file_attrs;\n\t}\n\n\tif (make_backups > 0 && overwriting_basis) {\n\t\tint ok = make_backup(fname, False);\n\t\tif (!ok)\n\t\t\texit_cleanup(RERR_FILEIO);\n\t\tif (ok == 1 && fnamecmp == fname)\n\t\t\tfnamecmp = get_backup_name(fname);\n\t}\n\n\t\/* Change permissions before putting the file into place. *\/\n\tset_file_attrs(fnametmp, file, NULL, fnamecmp,\n\t\t       ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);\n\n\t\/* move tmp file over real file *\/\n\tif (DEBUG_GTE(RECV, 1))\n\t\trprintf(FINFO, \"renaming %s to %s\\n\", fnametmp, fname);\n\tret = robust_rename(fnametmp, fname, temp_copy_name, file->mode);\n\tif (ret < 0) {\n\t\trsyserr(FERROR_XFER, errno, \"%s %s -> \\\"%s\\\"\",\n\t\t\tret == -2 ? \"copy\" : \"rename\",\n\t\t\tfull_fname(fnametmp), fname);\n\t\tif (!partialptr || (ret == -2 && temp_copy_name)\n\t\t || robust_rename(fnametmp, partialptr, NULL, file->mode) < 0)\n\t\t\tdo_unlink(fnametmp);\n\t\treturn 0;\n\t}\n\tif (ret == 0) {\n\t\t\/* The file was moved into place (not copied), so it's done. *\/\n\t\treturn 1;\n\t}\n\t\/* The file was copied, so tweak the perms of the copied file.  If it\n\t * was copied to partialptr, move it into its final destination. *\/\n\tfnametmp = temp_copy_name ? temp_copy_name : fname;\n\n  do_set_file_attrs:\n\tset_file_attrs(fnametmp, file, NULL, fnamecmp,\n\t\t       ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);\n\n\tif (temp_copy_name) {\n\t\tif (do_rename(fnametmp, fname) < 0) {\n\t\t\trsyserr(FERROR_XFER, errno, \"rename %s -> \\\"%s\\\"\",\n\t\t\t\tfull_fname(fnametmp), fname);\n\t\t\treturn 0;\n\t\t}\n\t\thandle_partial_dir(temp_copy_name, PDIR_DELETE);\n\t}\n\treturn 1;\n}","target":0,"code_token_length":594,"total_token_length":830,"max_tokens_setting":1024}
+{"idx":11401,"func":" bool SeekHead::ParseEntry(IMkvReader* pReader, long long start, long long size_,\n                           Entry* pEntry) {\n   if (size_ <= 0)\n return false;\n\n long long pos = start;\n const long long stop = start + size_;\n\n long len;\n\n \n \n  const long long seekIdId = ReadUInt(pReader, pos, len);\n \n   if (seekIdId != 0x13AB)  \/\/ SeekID ID\n     return false;\n\n if ((pos + len) > stop)\n return false;\n\n  pos += len; \/\/ consume SeekID id\n\n const long long seekIdSize = ReadUInt(pReader, pos, len);\n\n if (seekIdSize <= 0)\n return false;\n\n if ((pos + len) > stop)\n return false;\n\n  pos += len; \/\/ consume size of field\n\n if ((pos + seekIdSize) > stop)\n return false;\n\n\n  pEntry->id = ReadUInt(pReader, pos, len); \/\/ payload\n\n if (pEntry->id <= 0)\n return false;\n\n if (len != seekIdSize)\n return false;\n\n  pos += seekIdSize; \/\/ consume SeekID payload\n\n const long long seekPosId = ReadUInt(pReader, pos, len);\n\n if (seekPosId != 0x13AC) \/\/ SeekPos ID\n return false;\n\n if ((pos + len) > stop)\n return false;\n\n  pos += len; \/\/ consume id\n\n const long long seekPosSize = ReadUInt(pReader, pos, len);\n\n if (seekPosSize <= 0)\n return false;\n\n if ((pos + len) > stop)\n return false;\n\n  pos += len; \/\/ consume size\n\n if ((pos + seekPosSize) > stop)\n return false;\n\n  pEntry->pos = UnserializeUInt(pReader, pos, seekPosSize);\n\n if (pEntry->pos < 0)\n return false;\n\n  pos += seekPosSize; \/\/ consume payload\n\n if (pos != stop)\n return false;\n\n \n   return true;\n }\n","target":1,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":407802,"func":"int seccomp_load_syscall_filter_set(uint32_t default_action, const SyscallFilterSet *set, uint32_t action) {\n        uint32_t arch;\n        int r;\n\n        assert(set);\n\n        \/* The one-stop solution: allocate a seccomp object, add the specified filter to it, and apply it. Once for\n         * earch local arch. *\/\n\n        SECCOMP_FOREACH_LOCAL_ARCH(arch) {\n                _cleanup_(seccomp_releasep) scmp_filter_ctx seccomp = NULL;\n\n                log_debug(\"Operating on architecture: %s\", seccomp_arch_to_string(arch));\n\n                r = seccomp_init_for_arch(&seccomp, arch, default_action);\n                if (r < 0)\n                        return r;\n\n                r = seccomp_add_syscall_filter_set(seccomp, set, action, NULL);\n                if (r < 0) {\n                        log_debug_errno(r, \"Failed to add filter set, ignoring: %m\");\n                        continue;\n                }\n\n                r = seccomp_load(seccomp);\n                if (IN_SET(r, -EPERM, -EACCES))\n                        return r;\n                if (r < 0)\n                        log_debug_errno(r, \"Failed to install filter set for architecture %s, skipping: %m\", seccomp_arch_to_string(arch));\n        }\n\n        return 0;\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":10175,"func":" PrintingContext::Result PrintingContext::AskUserForSettings(\n    HWND window,\n     int max_pages,\n     bool has_selection) {\n  DCHECK(window);\n   DCHECK(!in_print_job_);\n   dialog_box_dismissed_ = false;\n  PRINTDLGEX dialog_options = { sizeof(PRINTDLGEX) };\n  dialog_options.hwndOwner = window;\n  dialog_options.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE  |\n                         PD_NOCURRENTPAGE | PD_HIDEPRINTTOFILE;\n  if (!has_selection)\n    dialog_options.Flags |= PD_NOSELECTION;\n\n  PRINTPAGERANGE ranges[32];\n  dialog_options.nStartPage = START_PAGE_GENERAL;\n  if (max_pages) {\n    memset(ranges, 0, sizeof(ranges));\n    ranges[0].nFromPage = 1;\n    ranges[0].nToPage = max_pages;\n    dialog_options.nPageRanges = 1;\n    dialog_options.nMaxPageRanges = arraysize(ranges);\n    dialog_options.nMinPage = 1;\n    dialog_options.nMaxPage = max_pages;\n    dialog_options.lpPageRanges = ranges;\n  } else {\n    dialog_options.Flags |= PD_NOPAGENUMS;\n  }\n\n  {\n    if (PrintDlgEx(&dialog_options) != S_OK) {\n      ResetSettings();\n      return FAILED;\n    }\n  }\n  return ParseDialogResultEx(dialog_options);\n}\n","target":1,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":129983,"func":"static void BF_encode(char *dst, const BF_word *src, int size)\n{\n  const unsigned char *sptr = (const unsigned char *)src;\n  const unsigned char *end = sptr + size;\n  unsigned char *dptr = (unsigned char *)dst;\n  unsigned int c1, c2;\n\n  do {\n    c1 = *sptr++;\n    *dptr++ = BF_itoa64[c1 >> 2];\n    c1 = (c1 & 0x03) << 4;\n    if (sptr >= end) {\n      *dptr++ = BF_itoa64[c1];\n      break;\n    }\n\n    c2 = *sptr++;\n    c1 |= c2 >> 4;\n    *dptr++ = BF_itoa64[c1];\n    c1 = (c2 & 0x0f) << 2;\n    if (sptr >= end) {\n      *dptr++ = BF_itoa64[c1];\n      break;\n    }\n\n    c2 = *sptr++;\n    c1 |= c2 >> 6;\n    *dptr++ = BF_itoa64[c1];\n    *dptr++ = BF_itoa64[c2 & 0x3f];\n  } while (sptr < end);\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":97202,"func":"GF_ISOMVVCType gf_isom_get_vvc_type(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex)\n{\n\tu32 type;\n\tGF_TrackBox *trak;\n\tGF_MPEGVisualSampleEntryBox *entry;\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !trak->Media || !DescriptionIndex) return GF_ISOM_VVCTYPE_NONE;\n\tif (!gf_isom_is_video_handler_type(trak->Media->handler->handlerType))\n\t\treturn GF_ISOM_VVCTYPE_NONE;\n\tentry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex-1);\n\tif (!entry) return GF_ISOM_VVCTYPE_NONE;\n\tif (entry->internal_type != GF_ISOM_SAMPLE_ENTRY_VIDEO) return GF_ISOM_VVCTYPE_NONE;\n\ttype = entry->type;\n\n\tif (type == GF_ISOM_BOX_TYPE_ENCV) {\n\t\tGF_ProtectionSchemeInfoBox *sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_SINF);\n\t\tif (sinf && sinf->original_format) type = sinf->original_format->data_format;\n\t}\n\telse if (type == GF_ISOM_BOX_TYPE_RESV) {\n\t\tif (entry->rinf && entry->rinf->original_format) type = entry->rinf->original_format->data_format;\n\t}\n\n\tswitch (type) {\n\tcase GF_ISOM_BOX_TYPE_VVC1:\n\tcase GF_ISOM_BOX_TYPE_VVI1:\n\t\treturn GF_ISOM_VVCTYPE_ONLY;\n\tcase GF_ISOM_SUBTYPE_VVS1:\n\t\treturn GF_ISOM_VVCTYPE_SUBPIC;\n\tcase GF_ISOM_SUBTYPE_VVCN:\n\t\treturn GF_ISOM_VVCTYPE_NVCL;\n\tdefault:\n\t\treturn GF_ISOM_VVCTYPE_NONE;\n\t}\n\treturn GF_ISOM_VVCTYPE_NONE;\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":355462,"func":"static void check_preempt_wakeup(struct rq *rq, struct task_struct *p)\n{\n\tstruct task_struct *curr = rq->curr;\n\tstruct cfs_rq *cfs_rq = task_cfs_rq(curr);\n\tstruct sched_entity *se = &curr->se, *pse = &p->se;\n\tunsigned long gran;\n\n\tif (unlikely(rt_prio(p->prio))) {\n\t\tupdate_rq_clock(rq);\n\t\tupdate_curr(cfs_rq);\n\t\tresched_task(curr);\n\t\treturn;\n\t}\n\n\tcfs_rq_of(pse)->next = pse;\n\n\t\/*\n\t * Batch tasks do not preempt (their preemption is driven by\n\t * the tick):\n\t *\/\n\tif (unlikely(p->policy == SCHED_BATCH))\n\t\treturn;\n\n\tif (!sched_feat(WAKEUP_PREEMPT))\n\t\treturn;\n\n\twhile (!is_same_group(se, pse)) {\n\t\tse = parent_entity(se);\n\t\tpse = parent_entity(pse);\n\t}\n\n\tgran = sysctl_sched_wakeup_granularity;\n\t\/*\n\t * More easily preempt - nice tasks, while not making\n\t * it harder for + nice tasks.\n\t *\/\n\tif (unlikely(se->load.weight > NICE_0_LOAD))\n\t\tgran = calc_delta_fair(gran, &se->load);\n\n\tif (pse->vruntime + gran < se->vruntime)\n\t\tresched_task(curr);\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":50693,"func":"    \/\/! Convert pixel values from CMY to CMYK color spaces \\newinstance.\n    CImg<Tuchar> get_CMYtoCMYK() const {\n      if (_spectrum!=3)\n        throw CImgInstanceException(_cimg_instance\n                                    \"CMYtoCMYK(): Instance is not a CMY image.\",\n                                    cimg_instance);\n\n      CImg<Tfloat> res(_width,_height,_depth,4);\n      const T *ps1 = data(0,0,0,0), *ps2 = data(0,0,0,1), *ps3 = data(0,0,0,2);\n      Tfloat *pd1 = res.data(0,0,0,0), *pd2 = res.data(0,0,0,1), *pd3 = res.data(0,0,0,2), *pd4 = res.data(0,0,0,3);\n      const longT whd = (longT)width()*height()*depth();\n      cimg_pragma_openmp(parallel for cimg_openmp_if_size(whd,1024))\n      for (longT N = 0; N<whd; ++N) {\n        Tfloat\n\t  C = (Tfloat)ps1[N],\n\t  M = (Tfloat)ps2[N],\n\t  Y = (Tfloat)ps3[N],\n\t  K = cimg::min(C,M,Y);\n\tif (K>=255) C = M = Y = 0;\n\telse { const Tfloat K1 = 255 - K; C = 255*(C - K)\/K1; M = 255*(M - K)\/K1; Y = 255*(Y - K)\/K1; }\n        pd1[N] = (Tfloat)cimg::cut(C,0,255),\n        pd2[N] = (Tfloat)cimg::cut(M,0,255),\n        pd3[N] = (Tfloat)cimg::cut(Y,0,255),\n        pd4[N] = (Tfloat)cimg::cut(K,0,255);\n      }\n      return res;","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":325036,"func":"static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,\n\n                           const uint8_t *src, int size, int width, int lines)\n\n{\n\n    int i, ret = 0;\n\n    int line;\n\n    uint8_t *src2 = av_malloc((unsigned)size +\n\n                              AV_INPUT_BUFFER_PADDING_SIZE);\n\n\n\n    if (!src2) {\n\n        av_log(s->avctx, AV_LOG_ERROR,\n\n               \"Error allocating temporary buffer\\n\");\n\n        return AVERROR(ENOMEM);\n\n    }\n\n\n\n    if (!s->fill_order) {\n\n        memcpy(src2, src, size);\n\n    } else {\n\n        for (i = 0; i < size; i++)\n\n            src2[i] = ff_reverse[src[i]];\n\n    }\n\n    memset(src2 + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);\n\n    ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,\n\n                          s->compr, s->fax_opts);\n\n    if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)\n\n        for (line = 0; line < lines; line++) {\n\n            horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);\n\n            dst += stride;\n\n        }\n\n    av_free(src2);\n\n    return ret;\n\n}\n","target":1,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":419873,"func":"   Return a list of subscribed mailboxes *\/\nPHP_FUNCTION(imap_lsub)\n{\n\tzval *streamind;\n\tzend_string *ref, *pat;\n\tpils *imap_le_struct;\n\tSTRINGLIST *cur=NIL;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"rSS\", &streamind, &ref, &pat) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), \"imap\", le_imap)) == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* set flag for normal, old mailbox list *\/\n\tIMAPG(folderlist_style) = FLIST_ARRAY;\n\n\tIMAPG(imap_sfolders) = NIL;\n\tmail_lsub(imap_le_struct->imap_stream, ZSTR_VAL(ref), ZSTR_VAL(pat));\n\tif (IMAPG(imap_sfolders) == NIL) {\n\t\tRETURN_FALSE;\n\t}\n\n\tarray_init(return_value);\n\tcur=IMAPG(imap_sfolders);\n\twhile (cur != NIL) {\n\t\tadd_next_index_string(return_value, (char*)cur->LTEXT);\n\t\tcur=cur->next;\n\t}\n\tmail_free_stringlist (&IMAPG(imap_sfolders));\n\tIMAPG(imap_sfolders) = IMAPG(imap_sfolders_tail) = NIL;","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":392817,"func":"xmlSchemaFree(xmlSchemaPtr schema)\n{\n    if (schema == NULL)\n        return;\n    \/* @volatiles is not used anymore :-\/ *\/\n    if (schema->volatiles != NULL)\n\tTODO\n    \/*\n    * Note that those slots are not responsible for freeing\n    * schema components anymore; this will now be done by\n    * the schema buckets.\n    *\/\n    if (schema->notaDecl != NULL)\n        xmlHashFree(schema->notaDecl, NULL);\n    if (schema->attrDecl != NULL)\n        xmlHashFree(schema->attrDecl, NULL);\n    if (schema->attrgrpDecl != NULL)\n        xmlHashFree(schema->attrgrpDecl, NULL);\n    if (schema->elemDecl != NULL)\n        xmlHashFree(schema->elemDecl, NULL);\n    if (schema->typeDecl != NULL)\n        xmlHashFree(schema->typeDecl, NULL);\n    if (schema->groupDecl != NULL)\n        xmlHashFree(schema->groupDecl, NULL);\n    if (schema->idcDef != NULL)\n        xmlHashFree(schema->idcDef, NULL);\n\n    if (schema->schemasImports != NULL)\n\txmlHashFree(schema->schemasImports,\n\t\t    (xmlHashDeallocator) xmlSchemaBucketFree);\n    if (schema->includes != NULL) {\n\txmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes;\n\tint i;\n\tfor (i = 0; i < list->nbItems; i++) {\n\t    xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);\n\t}\n\txmlSchemaItemListFree(list);\n    }\n    if (schema->annot != NULL)\n        xmlSchemaFreeAnnot(schema->annot);\n    \/* Never free the doc here, since this will be done by the buckets. *\/\n\n    xmlDictFree(schema->dict);\n    xmlFree(schema);\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":297117,"func":"int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,\n\t\t\tstruct ib_cm_sidr_req_param *param)\n{\n\tstruct cm_id_private *cm_id_priv;\n\tstruct ib_mad_send_buf *msg;\n\tunsigned long flags;\n\tint ret;\n\n\tif (!param->path || (param->private_data &&\n\t     param->private_data_len > IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE))\n\t\treturn -EINVAL;\n\n\tcm_id_priv = container_of(cm_id, struct cm_id_private, id);\n\tret = cm_init_av_by_path(param->path, &cm_id_priv->av);\n\tif (ret)\n\t\tgoto out;\n\n\tcm_id->service_id = param->service_id;\n\tcm_id->service_mask = ~cpu_to_be64(0);\n\tcm_id_priv->timeout_ms = param->timeout_ms;\n\tcm_id_priv->max_cm_retries = param->max_cm_retries;\n\tret = cm_alloc_msg(cm_id_priv, &msg);\n\tif (ret)\n\t\tgoto out;\n\n\tcm_format_sidr_req((struct cm_sidr_req_msg *) msg->mad, cm_id_priv,\n\t\t\t   param);\n\tmsg->timeout_ms = cm_id_priv->timeout_ms;\n\tmsg->context[1] = (void *) (unsigned long) IB_CM_SIDR_REQ_SENT;\n\n\tspin_lock_irqsave(&cm_id_priv->lock, flags);\n\tif (cm_id->state == IB_CM_IDLE)\n\t\tret = ib_post_send_mad(msg, NULL);\n\telse\n\t\tret = -EINVAL;\n\n\tif (ret) {\n\t\tspin_unlock_irqrestore(&cm_id_priv->lock, flags);\n\t\tcm_free_msg(msg);\n\t\tgoto out;\n\t}\n\tcm_id->state = IB_CM_SIDR_REQ_SENT;\n\tcm_id_priv->msg = msg;\n\tspin_unlock_irqrestore(&cm_id_priv->lock, flags);\nout:\n\treturn ret;\n}","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":424330,"func":"static void merge_dependencies(Unit *u, Unit *other, const char *other_id, UnitDependency d) {\n        Iterator i;\n        Unit *back;\n        void *v;\n        int r;\n\n        \/* Merges all dependencies of type 'd' of the unit 'other' into the deps of the unit 'u' *\/\n\n        assert(u);\n        assert(other);\n        assert(d < _UNIT_DEPENDENCY_MAX);\n\n        \/* Fix backwards pointers. Let's iterate through all dependendent units of the other unit. *\/\n        HASHMAP_FOREACH_KEY(v, back, other->dependencies[d], i) {\n                UnitDependency k;\n\n                \/* Let's now iterate through the dependencies of that dependencies of the other units, looking for\n                 * pointers back, and let's fix them up, to instead point to 'u'. *\/\n\n                for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++) {\n                        if (back == u) {\n                                \/* Do not add dependencies between u and itself. *\/\n                                if (hashmap_remove(back->dependencies[k], other))\n                                        maybe_warn_about_dependency(u, other_id, k);\n                        } else {\n                                UnitDependencyInfo di_u, di_other, di_merged;\n\n                                \/* Let's drop this dependency between \"back\" and \"other\", and let's create it between\n                                 * \"back\" and \"u\" instead. Let's merge the bit masks of the dependency we are moving,\n                                 * and any such dependency which might already exist *\/\n\n                                di_other.data = hashmap_get(back->dependencies[k], other);\n                                if (!di_other.data)\n                                        continue; \/* dependency isn't set, let's try the next one *\/\n\n                                di_u.data = hashmap_get(back->dependencies[k], u);\n\n                                di_merged = (UnitDependencyInfo) {\n                                        .origin_mask = di_u.origin_mask | di_other.origin_mask,\n                                        .destination_mask = di_u.destination_mask | di_other.destination_mask,\n                                };\n\n                                r = hashmap_remove_and_replace(back->dependencies[k], other, u, di_merged.data);\n                                if (r < 0)\n                                        log_warning_errno(r, \"Failed to remove\/replace: back=%s other=%s u=%s: %m\", back->id, other_id, u->id);\n                                assert(r >= 0);\n\n                                \/* assert_se(hashmap_remove_and_replace(back->dependencies[k], other, u, di_merged.data) >= 0); *\/\n                        }\n                }\n\n        }\n\n        \/* Also do not move dependencies on u to itself *\/\n        back = hashmap_remove(other->dependencies[d], u);\n        if (back)\n                maybe_warn_about_dependency(u, other_id, d);\n\n        \/* The move cannot fail. The caller must have performed a reservation. *\/\n        assert_se(hashmap_complete_move(&u->dependencies[d], &other->dependencies[d]) == 0);\n\n        other->dependencies[d] = hashmap_free(other->dependencies[d]);\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":415731,"func":"flags(void)\n{\n\tunsigned long flags;\n\tgfp_t gfp;\n\tchar *cmp_buffer;\n\n\tflags = 0;\n\ttest(\"\", \"%pGp\", &flags);\n\n\t\/* Page flags should filter the zone id *\/\n\tflags = 1UL << NR_PAGEFLAGS;\n\ttest(\"\", \"%pGp\", &flags);\n\n\tflags |= 1UL << PG_uptodate | 1UL << PG_dirty | 1UL << PG_lru\n\t\t| 1UL << PG_active | 1UL << PG_swapbacked;\n\ttest(\"uptodate|dirty|lru|active|swapbacked\", \"%pGp\", &flags);\n\n\n\tflags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC\n\t\t\t| VM_DENYWRITE;\n\ttest(\"read|exec|mayread|maywrite|mayexec|denywrite\", \"%pGv\", &flags);\n\n\tgfp = GFP_TRANSHUGE;\n\ttest(\"GFP_TRANSHUGE\", \"%pGg\", &gfp);\n\n\tgfp = GFP_ATOMIC|__GFP_DMA;\n\ttest(\"GFP_ATOMIC|GFP_DMA\", \"%pGg\", &gfp);\n\n\tgfp = __GFP_ATOMIC;\n\ttest(\"__GFP_ATOMIC\", \"%pGg\", &gfp);\n\n\tcmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL);\n\tif (!cmp_buffer)\n\t\treturn;\n\n\t\/* Any flags not translated by the table should remain numeric *\/\n\tgfp = ~__GFP_BITS_MASK;\n\tsnprintf(cmp_buffer, BUF_SIZE, \"%#lx\", (unsigned long) gfp);\n\ttest(cmp_buffer, \"%pGg\", &gfp);\n\n\tsnprintf(cmp_buffer, BUF_SIZE, \"__GFP_ATOMIC|%#lx\",\n\t\t\t\t\t\t\t(unsigned long) gfp);\n\tgfp |= __GFP_ATOMIC;\n\ttest(cmp_buffer, \"%pGg\", &gfp);\n\n\tkfree(cmp_buffer);\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":64154,"func":"static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)\n{\n\tstruct cfg80211_registered_device *rdev = info->user_ptr[0];\n\tstruct net_device *dev = info->user_ptr[1];\n\tstruct bss_parameters params;\n\n\tmemset(¶ms, 0, sizeof(params));\n\t\/* default to not changing parameters *\/\n\tparams.use_cts_prot = -1;\n\tparams.use_short_preamble = -1;\n\tparams.use_short_slot_time = -1;\n\tparams.ap_isolate = -1;\n\tparams.ht_opmode = -1;\n\n\tif (info->attrs[NL80211_ATTR_BSS_CTS_PROT])\n\t\tparams.use_cts_prot =\n\t\t    nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]);\n\tif (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE])\n\t\tparams.use_short_preamble =\n\t\t    nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]);\n\tif (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])\n\t\tparams.use_short_slot_time =\n\t\t    nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);\n\tif (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {\n\t\tparams.basic_rates =\n\t\t\tnla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);\n\t\tparams.basic_rates_len =\n\t\t\tnla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);\n\t}\n\tif (info->attrs[NL80211_ATTR_AP_ISOLATE])\n\t\tparams.ap_isolate = !!nla_get_u8(info->attrs[NL80211_ATTR_AP_ISOLATE]);\n\tif (info->attrs[NL80211_ATTR_BSS_HT_OPMODE])\n\t\tparams.ht_opmode =\n\t\t\tnla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]);\n\n\tif (!rdev->ops->change_bss)\n\t\treturn -EOPNOTSUPP;\n\n\tif (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&\n\t    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)\n\t\treturn -EOPNOTSUPP;\n\n\treturn rdev->ops->change_bss(&rdev->wiphy, dev, ¶ms);\n}","target":0,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":420277,"func":"enqueueIoWork(epolld_t *epd, int dispatchInlineIfQueueFull) {\n\tio_req_t *n;\n\tint dispatchInline;\n\tDEFiRet;\n\t\n\tCHKmalloc(n = malloc(sizeof(io_req_t)));\n\tn->epd = epd;\n\t\n\tint inlineDispatchThreshold = DFLT_inlineDispatchThreshold * runModConf->wrkrMax;\n\tdispatchInline = 0;\n\t\n\tpthread_mutex_lock(&io_q.mut);\n\tif (dispatchInlineIfQueueFull && io_q.sz > inlineDispatchThreshold) {\n\t\tdispatchInline = 1;\n\t} else {\n\t\tSTAILQ_INSERT_TAIL(&io_q.q, n, link);\n\t\tio_q.sz++;\n\t\tSTATSCOUNTER_INC(io_q.ctrEnq, io_q.mutCtrEnq);\n\t\tSTATSCOUNTER_SETMAX_NOMUT(io_q.ctrMaxSz, io_q.sz);\n\t\tpthread_cond_signal(&io_q.wakeup_worker);\n\t}\n\tpthread_mutex_unlock(&io_q.mut);\n\n\tif (dispatchInline == 1) {\n\t\tfree(n);\n\t\tprocessWorkItem(epd);\n\t}\nfinalize_it:\n\tif (iRet != RS_RET_OK) {\n\t\tif (n == NULL) {\n\t\t\terrmsg.LogError(0, iRet, \"imptcp: couldn't allocate memory to enqueue io-request - ignored\");\n\t\t}\n\t}\n\tRETiRet;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":114789,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  auto* params = reinterpret_cast<TfLiteConvParams*>(node->builtin_data);\n\n  const TfLiteEvalTensor* input =\n      tflite::micro::GetEvalInput(context, node, kInputTensor);\n  const TfLiteEvalTensor* filter =\n      tflite::micro::GetEvalInput(context, node, kFilterTensor);\n  const TfLiteEvalTensor* bias =\n      (NumInputs(node) == 3)\n          ? tflite::micro::GetEvalInput(context, node, kBiasTensor)\n          : nullptr;\n  TfLiteEvalTensor* output =\n      tflite::micro::GetEvalOutput(context, node, kOutputTensor);\n\n  TFLITE_DCHECK(node->user_data != nullptr);\n  const OpData& data = *(static_cast<const OpData*>(node->user_data));\n\n  switch (input->type) {  \/\/ Already know in\/out types are same.\n    case kTfLiteFloat32:\n      EvalFloat(context, node, params, data, input, filter, bias, nullptr,\n                nullptr, output);\n      break;\n    case kTfLiteInt8:\n      EvalQuantizedPerChannel(context, node, params, data, input, filter, bias,\n                              output, nullptr);\n      break;\n    case kTfLiteUInt8:\n      EvalQuantized(context, node, params, data, input, filter, bias, nullptr,\n                    nullptr, output);\n      break;\n    default:\n      TF_LITE_KERNEL_LOG(context, \"Type %s (%d) not supported.\",\n                         TfLiteTypeGetName(input->type), input->type);\n      return kTfLiteError;\n  }\n  return kTfLiteOk;\n}","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":202971,"func":"static int mem_control_numa_stat_show(struct seq_file *m, void *arg)\n{\n\tint nid;\n\tunsigned long total_nr, file_nr, anon_nr, unevictable_nr;\n\tunsigned long node_nr;\n\tstruct cgroup *cont = m->private;\n\tstruct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont);\n\n\ttotal_nr = mem_cgroup_nr_lru_pages(mem_cont, LRU_ALL);\n\tseq_printf(m, \"total=%lu\", total_nr);\n\tfor_each_node_state(nid, N_HIGH_MEMORY) {\n\t\tnode_nr = mem_cgroup_node_nr_lru_pages(mem_cont, nid, LRU_ALL);\n\t\tseq_printf(m, \" N%d=%lu\", nid, node_nr);\n\t}\n\tseq_putc(m, '\\n');\n\n\tfile_nr = mem_cgroup_nr_lru_pages(mem_cont, LRU_ALL_FILE);\n\tseq_printf(m, \"file=%lu\", file_nr);\n\tfor_each_node_state(nid, N_HIGH_MEMORY) {\n\t\tnode_nr = mem_cgroup_node_nr_lru_pages(mem_cont, nid,\n\t\t\t\tLRU_ALL_FILE);\n\t\tseq_printf(m, \" N%d=%lu\", nid, node_nr);\n\t}\n\tseq_putc(m, '\\n');\n\n\tanon_nr = mem_cgroup_nr_lru_pages(mem_cont, LRU_ALL_ANON);\n\tseq_printf(m, \"anon=%lu\", anon_nr);\n\tfor_each_node_state(nid, N_HIGH_MEMORY) {\n\t\tnode_nr = mem_cgroup_node_nr_lru_pages(mem_cont, nid,\n\t\t\t\tLRU_ALL_ANON);\n\t\tseq_printf(m, \" N%d=%lu\", nid, node_nr);\n\t}\n\tseq_putc(m, '\\n');\n\n\tunevictable_nr = mem_cgroup_nr_lru_pages(mem_cont, BIT(LRU_UNEVICTABLE));\n\tseq_printf(m, \"unevictable=%lu\", unevictable_nr);\n\tfor_each_node_state(nid, N_HIGH_MEMORY) {\n\t\tnode_nr = mem_cgroup_node_nr_lru_pages(mem_cont, nid,\n\t\t\t\tBIT(LRU_UNEVICTABLE));\n\t\tseq_printf(m, \" N%d=%lu\", nid, node_nr);\n\t}\n\tseq_putc(m, '\\n');\n\treturn 0;\n}\n","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":401201,"func":"static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[])\n{\n\tu64 csid = MACSEC_DEFAULT_CIPHER_ID;\n\tu8 icv_len = DEFAULT_ICV_LEN;\n\tint flag;\n\tbool es, scb, sci;\n\n\tif (!data)\n\t\treturn 0;\n\n\tif (data[IFLA_MACSEC_CIPHER_SUITE])\n\t\tcsid = nla_get_u64(data[IFLA_MACSEC_CIPHER_SUITE]);\n\n\tif (data[IFLA_MACSEC_ICV_LEN]) {\n\t\ticv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);\n\t\tif (icv_len != DEFAULT_ICV_LEN) {\n\t\t\tchar dummy_key[DEFAULT_SAK_LEN] = { 0 };\n\t\t\tstruct crypto_aead *dummy_tfm;\n\n\t\t\tdummy_tfm = macsec_alloc_tfm(dummy_key,\n\t\t\t\t\t\t     DEFAULT_SAK_LEN,\n\t\t\t\t\t\t     icv_len);\n\t\t\tif (IS_ERR(dummy_tfm))\n\t\t\t\treturn PTR_ERR(dummy_tfm);\n\t\t\tcrypto_free_aead(dummy_tfm);\n\t\t}\n\t}\n\n\tswitch (csid) {\n\tcase MACSEC_DEFAULT_CIPHER_ID:\n\tcase MACSEC_DEFAULT_CIPHER_ALT:\n\t\tif (icv_len < MACSEC_MIN_ICV_LEN ||\n\t\t    icv_len > MACSEC_STD_ICV_LEN)\n\t\t\treturn -EINVAL;\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tif (data[IFLA_MACSEC_ENCODING_SA]) {\n\t\tif (nla_get_u8(data[IFLA_MACSEC_ENCODING_SA]) >= MACSEC_NUM_AN)\n\t\t\treturn -EINVAL;\n\t}\n\n\tfor (flag = IFLA_MACSEC_ENCODING_SA + 1;\n\t     flag < IFLA_MACSEC_VALIDATION;\n\t     flag++) {\n\t\tif (data[flag]) {\n\t\t\tif (nla_get_u8(data[flag]) > 1)\n\t\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\tes  = data[IFLA_MACSEC_ES] ? nla_get_u8(data[IFLA_MACSEC_ES]) : false;\n\tsci = data[IFLA_MACSEC_INC_SCI] ? nla_get_u8(data[IFLA_MACSEC_INC_SCI]) : false;\n\tscb = data[IFLA_MACSEC_SCB] ? nla_get_u8(data[IFLA_MACSEC_SCB]) : false;\n\n\tif ((sci && (scb || es)) || (scb && es))\n\t\treturn -EINVAL;\n\n\tif (data[IFLA_MACSEC_VALIDATION] &&\n\t    nla_get_u8(data[IFLA_MACSEC_VALIDATION]) > MACSEC_VALIDATE_MAX)\n\t\treturn -EINVAL;\n\n\tif ((data[IFLA_MACSEC_REPLAY_PROTECT] &&\n\t     nla_get_u8(data[IFLA_MACSEC_REPLAY_PROTECT])) &&\n\t    !data[IFLA_MACSEC_WINDOW])\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":255739,"func":"static void create_layer_surface(struct swaylock_surface *surface) {\n\tstruct swaylock_state *state = surface->state;\n\n\tsurface->image = select_image(state, surface);\n\n\tsurface->surface = wl_compositor_create_surface(state->compositor);\n\tassert(surface->surface);\n\n\tsurface->child = wl_compositor_create_surface(state->compositor);\n\tassert(surface->child);\n\tsurface->subsurface = wl_subcompositor_get_subsurface(state->subcompositor, surface->child, surface->surface);\n\tassert(surface->subsurface);\n\twl_subsurface_set_sync(surface->subsurface);\n\n\tsurface->layer_surface = zwlr_layer_shell_v1_get_layer_surface(\n\t\t\tstate->layer_shell, surface->surface, surface->output,\n\t\t\tZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, \"lockscreen\");\n\tassert(surface->layer_surface);\n\n\tzwlr_layer_surface_v1_set_size(surface->layer_surface, 0, 0);\n\tzwlr_layer_surface_v1_set_anchor(surface->layer_surface,\n\t\t\tZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |\n\t\t\tZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |\n\t\t\tZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |\n\t\t\tZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);\n\tzwlr_layer_surface_v1_set_exclusive_zone(surface->layer_surface, -1);\n\tzwlr_layer_surface_v1_set_keyboard_interactivity(\n\t\t\tsurface->layer_surface, true);\n\tzwlr_layer_surface_v1_add_listener(surface->layer_surface,\n\t\t\t&layer_surface_listener, surface);\n\n\tif (surface_is_opaque(surface) &&\n\t\t\tsurface->state->args.mode != BACKGROUND_MODE_CENTER &&\n\t\t\tsurface->state->args.mode != BACKGROUND_MODE_FIT) {\n\t\tstruct wl_region *region =\n\t\t\twl_compositor_create_region(surface->state->compositor);\n\t\twl_region_add(region, 0, 0, INT32_MAX, INT32_MAX);\n\t\twl_surface_set_opaque_region(surface->surface, region);\n\t\twl_region_destroy(region);\n\t}\n\n\twl_surface_commit(surface->surface);\n}","target":1,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":386417,"func":" *\/\nvoid\nxmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {\n    xmlXPathObjectPtr cur;\n\n    CHECK_ARITY(1);\n    if ((ctxt->value == NULL) ||\n\t((ctxt->value->type != XPATH_NODESET) &&\n\t (ctxt->value->type != XPATH_XSLT_TREE)))\n\tXP_ERROR(XPATH_INVALID_TYPE);\n    cur = valuePop(ctxt);\n\n    if ((cur == NULL) || (cur->nodesetval == NULL))\n\tvaluePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));\n    else if ((cur->type == XPATH_NODESET) || (cur->type == XPATH_XSLT_TREE)) {\n\tvaluePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,\n\t    (double) cur->nodesetval->nodeNr));\n    } else {\n\tif ((cur->nodesetval->nodeNr != 1) ||\n\t    (cur->nodesetval->nodeTab == NULL)) {\n\t    valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));\n\t} else {\n\t    xmlNodePtr tmp;\n\t    int i = 0;\n\n\t    tmp = cur->nodesetval->nodeTab[0];\n\t    if ((tmp != NULL) && (tmp->type != XML_NAMESPACE_DECL)) {\n\t\ttmp = tmp->children;\n\t\twhile (tmp != NULL) {\n\t\t    tmp = tmp->next;\n\t\t    i++;\n\t\t}\n\t    }\n\t    valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i));\n\t}\n    }","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":19085,"func":"static void vdpau_h264_set_reference_frames ( AVCodecContext * avctx ) {\n H264Context * const h = avctx -> priv_data ;\n AVVDPAUContext * hwctx = avctx -> hwaccel_context ;\n VdpPictureInfoH264 * info = & hwctx -> info . h264 ;\n int list ;\n VdpReferenceFrameH264 * rf = & info -> referenceFrames [ 0 ] ;\n # define H264_RF_COUNT FF_ARRAY_ELEMS ( info -> referenceFrames ) for ( list = 0 ;\n list < 2 ;\n ++ list ) {\n Picture * * lp = list ? h -> long_ref : h -> short_ref ;\n int i , ls = list ? 16 : h -> short_ref_count ;\n for ( i = 0 ;\n i < ls ;\n ++ i ) {\n Picture * pic = lp [ i ] ;\n VdpReferenceFrameH264 * rf2 ;\n VdpVideoSurface surface_ref ;\n int pic_frame_idx ;\n if ( ! pic || ! pic -> reference ) continue ;\n pic_frame_idx = pic -> long_ref ? pic -> pic_id : pic -> frame_num ;\n surface_ref = ff_vdpau_get_surface_id ( pic ) ;\n rf2 = & info -> referenceFrames [ 0 ] ;\n while ( rf2 != rf ) {\n if ( ( rf2 -> surface == surface_ref ) && ( rf2 -> is_long_term == pic -> long_ref ) && ( rf2 -> frame_idx == pic_frame_idx ) ) break ;\n ++ rf2 ;\n }\n if ( rf2 != rf ) {\n rf2 -> top_is_reference |= ( pic -> reference & PICT_TOP_FIELD ) ? VDP_TRUE : VDP_FALSE ;\n rf2 -> bottom_is_reference |= ( pic -> reference & PICT_BOTTOM_FIELD ) ? VDP_TRUE : VDP_FALSE ;\n continue ;\n }\n if ( rf >= & info -> referenceFrames [ H264_RF_COUNT ] ) continue ;\n vdpau_h264_set_rf ( rf , pic , pic -> reference ) ;\n ++ rf ;\n }\n }\n for ( ;\n rf < & info -> referenceFrames [ H264_RF_COUNT ] ;\n ++ rf ) vdpau_h264_clear_rf ( rf ) ;\n }","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":25684,"func":"void vp9_sad ## m ## x ## n ## x4d_c ( const uint8_t * src , int src_stride , const uint8_t * const refs [ ] , int ref_stride , unsigned int * sads ) {\n int i ;\n for ( i = 0 ;\n i < 4 ;\n ++ i ) sads [ i ] = vp9_sad ## m ## x ## n ## _c ( src , src_stride , refs [ i ] , ref_stride ) ;\n \\ }\n sadMxN ( 64 , 64 ) sadMxNxK ( 64 , 64 , 3 ) sadMxNxK ( 64 , 64 , 8 ) sadMxNx4D ( 64 , 64 ) sadMxN ( 64 , 32 ) sadMxNx4D ( 64 , 32 ) sadMxN ( 32 , 64 ) sadMxNx4D ( 32 , 64 ) sadMxN ( 32 , 32 ) sadMxNxK ( 32 , 32 , 3 ) sadMxNxK ( 32 , 32 , 8 ) sadMxNx4D ( 32 , 32 ) sadMxN ( 32 , 16 ) sadMxNx4D ( 32 , 16 ) sadMxN ( 16 , 32 ) sadMxNx4D ( 16 , 32 ) sadMxN ( 16 , 16 ) sadMxNxK ( 16 , 16 , 3 ) sadMxNxK ( 16 , 16 , 8 ) sadMxNx4D ( 16 , 16 ) sadMxN ( 16 , 8 ) sadMxNxK ( 16 , 8 , 3 ) sadMxNxK ( 16 , 8 , 8 ) sadMxNx4D ( 16 , 8 ) sadMxN ( 8 , 16 ) sadMxNxK ( 8 , 16 , 3 ) sadMxNxK ( 8 , 16 , 8 ) sadMxNx4D ( 8 , 16 ) sadMxN ( 8 , 8 ) sadMxNxK ( 8 , 8 , 3 ) sadMxNxK ( 8 , 8 , 8 ) sadMxNx4D ( 8 , 8 )","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":28083,"func":"static SchroFrame * CreateSchroFrameFromInputPic ( encoder_t * p_enc , picture_t * p_pic ) {\n encoder_sys_t * p_sys = p_enc -> p_sys ;\n SchroFrame * p_schroframe = schro_frame_new ( ) ;\n struct enc_picture_free_t * p_free ;\n if ( ! p_schroframe ) return NULL ;\n if ( ! p_pic ) return NULL ;\n p_schroframe -> format = SCHRO_FRAME_FORMAT_U8_420 ;\n if ( p_sys -> p_format -> chroma_format == SCHRO_CHROMA_422 ) {\n p_schroframe -> format = SCHRO_FRAME_FORMAT_U8_422 ;\n }\n else if ( p_sys -> p_format -> chroma_format == SCHRO_CHROMA_444 ) {\n p_schroframe -> format = SCHRO_FRAME_FORMAT_U8_444 ;\n }\n p_schroframe -> width = p_sys -> p_format -> width ;\n p_schroframe -> height = p_sys -> p_format -> height ;\n p_free = malloc ( sizeof ( * p_free ) ) ;\n if ( unlikely ( p_free == NULL ) ) {\n schro_frame_unref ( p_schroframe ) ;\n return NULL ;\n }\n p_free -> p_pic = p_pic ;\n p_free -> p_enc = p_enc ;\n schro_frame_set_free_callback ( p_schroframe , EncSchroFrameFree , p_free ) ;\n for ( int i = 0 ;\n i < 3 ;\n i ++ ) {\n p_schroframe -> components [ i ] . width = p_pic -> p [ i ] . i_visible_pitch ;\n p_schroframe -> components [ i ] . stride = p_pic -> p [ i ] . i_pitch ;\n p_schroframe -> components [ i ] . height = p_pic -> p [ i ] . i_visible_lines ;\n p_schroframe -> components [ i ] . length = p_pic -> p [ i ] . i_pitch * p_pic -> p [ i ] . i_lines ;\n p_schroframe -> components [ i ] . data = p_pic -> p [ i ] . p_pixels ;\n if ( i != 0 ) {\n p_schroframe -> components [ i ] . v_shift = SCHRO_FRAME_FORMAT_V_SHIFT ( p_schroframe -> format ) ;\n p_schroframe -> components [ i ] . h_shift = SCHRO_FRAME_FORMAT_H_SHIFT ( p_schroframe -> format ) ;\n }\n }\n return p_schroframe ;\n }","target":0,"code_token_length":531,"total_token_length":767,"max_tokens_setting":1024}
+{"idx":348352,"func":"void base64_encode_xmlrpc(struct buffer_st *b, const char *source, int length)\n{\n  int i, hiteof = 0;\n  int offset = 0;\n  int olen;\n\n  olen = 0;\n\n  buffer_new(b);\n\n  \/*\tFill dtable with character encodings.  *\/\n\n  for (i = 0; i < 26; i++) {\n    dtable[i] = 'A' + i;\n    dtable[26 + i] = 'a' + i;\n  }\n  for (i = 0; i < 10; i++) {\n    dtable[52 + i] = '0' + i;\n  }\n  dtable[62] = '+';\n  dtable[63] = '\/';\n\n  while (!hiteof) {\n    unsigned char igroup[3], ogroup[4];\n    int c, n;\n\n    igroup[0] = igroup[1] = igroup[2] = 0;\n    for (n = 0; n < 3; n++) {\n      c = *(source++);\n      offset++;\n      if (offset > length || offset <= 0) {\n\thiteof = 1;\n\tbreak;\n      }\n      igroup[n] = (unsigned char) c;\n    }\n    if (n > 0) {\n      ogroup[0] = dtable[igroup[0] >> 2];\n      ogroup[1] = dtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];\n      ogroup[2] = dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];\n      ogroup[3] = dtable[igroup[2] & 0x3F];\n\n      \/* Replace characters in output stream with \"=\" pad\n\t characters if fewer than three characters were\n\t read from the end of the input stream. *\/\n\n      if (n < 3) {\n\togroup[3] = '=';\n\tif (n < 2) {\n\t  ogroup[2] = '=';\n\t}\n      }\n      for (i = 0; i < 4; i++) {\n\tbuffer_add(b, ogroup[i]);\n\tif (!(b->offset % 72)) {\n\t  \/* buffer_add(b, '\\r'); *\/\n\t  buffer_add(b, '\\n');\n\t}\n      }\n    }\n  }\n  \/* buffer_add(b, '\\r'); *\/\n  buffer_add(b, '\\n');\n}","target":1,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":138156,"func":"pmcraid_init_ioadls(struct pmcraid_cmd *cmd, int sgcount)\n{\n\tstruct pmcraid_ioadl_desc *ioadl;\n\tstruct pmcraid_ioarcb *ioarcb = &cmd->ioa_cb->ioarcb;\n\tint ioadl_count = 0;\n\n\tif (ioarcb->add_cmd_param_length)\n\t\tioadl_count = DIV_ROUND_UP(ioarcb->add_cmd_param_length, 16);\n\tioarcb->ioadl_length =\n\t\tsizeof(struct pmcraid_ioadl_desc) * sgcount;\n\n\tif ((sgcount + ioadl_count) > (ARRAY_SIZE(ioarcb->add_data.u.ioadl))) {\n\t\t\/* external ioadls start at offset 0x80 from control_block\n\t\t * structure, re-using 24 out of 27 ioadls part of IOARCB.\n\t\t * It is necessary to indicate to firmware that driver is\n\t\t * using ioadls to be treated as external to IOARCB.\n\t\t *\/\n\t\tioarcb->ioarcb_bus_addr &= ~(0x1FULL);\n\t\tioarcb->ioadl_bus_addr =\n\t\t\tcpu_to_le64((cmd->ioa_cb_bus_addr) +\n\t\t\t\toffsetof(struct pmcraid_ioarcb,\n\t\t\t\t\tadd_data.u.ioadl[3]));\n\t\tioadl = &ioarcb->add_data.u.ioadl[3];\n\t} else {\n\t\tioarcb->ioadl_bus_addr =\n\t\t\tcpu_to_le64((cmd->ioa_cb_bus_addr) +\n\t\t\t\toffsetof(struct pmcraid_ioarcb,\n\t\t\t\t\tadd_data.u.ioadl[ioadl_count]));\n\n\t\tioadl = &ioarcb->add_data.u.ioadl[ioadl_count];\n\t\tioarcb->ioarcb_bus_addr |=\n\t\t\t\tDIV_ROUND_CLOSEST(sgcount + ioadl_count, 8);\n\t}\n\n\treturn ioadl;\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":344642,"func":"\tFileDescriptor connectToHelperAgent() {\n\t\tTRACE_POINT();\n\t\tFileDescriptor conn;\n\t\t\n\t\ttry {\n\t\t\tconn = connectToUnixServer(agentsStarter.getRequestSocketFilename());\n\t\t\twriteExact(conn, agentsStarter.getRequestSocketPassword());\n\t\t} catch (const SystemException &e) {\n\t\t\tif (e.code() == EPIPE || e.code() == ECONNREFUSED || e.code() == ENOENT) {\n\t\t\t\tUPDATE_TRACE_POINT();\n\t\t\t\tbool connected = false;\n\t\t\t\t\n\t\t\t\t\/\/ Maybe the helper agent crashed. First wait 50 ms.\n\t\t\t\tusleep(50000);\n\t\t\t\t\n\t\t\t\t\/\/ Then try to reconnect to the helper agent for the\n\t\t\t\t\/\/ next 5 seconds.\n\t\t\t\ttime_t deadline = time(NULL) + 5;\n\t\t\t\twhile (!connected && time(NULL) < deadline) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconn = connectToUnixServer(agentsStarter.getRequestSocketFilename());\n\t\t\t\t\t\twriteExact(conn, agentsStarter.getRequestSocketPassword());\n\t\t\t\t\t\tconnected = true;\n\t\t\t\t\t} catch (const SystemException &e) {\n\t\t\t\t\t\tif (e.code() == EPIPE || e.code() == ECONNREFUSED || e.code() == ENOENT) {\n\t\t\t\t\t\t\t\/\/ Looks like the helper agent hasn't been\n\t\t\t\t\t\t\t\/\/ restarted yet. Wait between 20 and 100 ms.\n\t\t\t\t\t\t\tusleep(20000 + rand() % 80000);\n\t\t\t\t\t\t\t\/\/ Don't care about thread-safety of rand()\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!connected) {\n\t\t\t\t\tUPDATE_TRACE_POINT();\n\t\t\t\t\tthrow IOException(\"Cannot connect to the helper agent\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t\treturn conn;\n\t}","target":1,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":322004,"func":"unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)\n\n{\n\n    int i, n, r, bit;\n\n    ElsRungNode *rung_node;\n\n\n\n    if (ctx->err)\n\n        return 0;\n\n\n\n    \/* decode unary prefix *\/\n\n    for (n = 0; n < ELS_EXPGOLOMB_LEN + 1; n++)\n\n        if (ff_els_decode_bit(ctx, &ur->prefix_rung[n]))\n\n            break;\n\n\n\n    \/* handle the error\/overflow case *\/\n\n    if (ctx->err || n >= ELS_EXPGOLOMB_LEN) {\n\n        ctx->err = AVERROR(EOVERFLOW);\n\n        return 0;\n\n    }\n\n\n\n    \/* handle the zero case *\/\n\n    if (!n)\n\n        return 0;\n\n\n\n    \/* initialize probability tree *\/\n\n    if (!ur->rem_rung_list) {\n\n        ur->rem_rung_list = av_realloc(NULL, RUNG_SPACE);\n\n        if (!ur->rem_rung_list) {\n\n            ctx->err = AVERROR(ENOMEM);\n\n            return 0;\n\n        }\n\n        memset(ur->rem_rung_list, 0, RUNG_SPACE);\n\n        ur->rung_list_size = RUNG_SPACE;\n\n        ur->avail_index    = ELS_EXPGOLOMB_LEN;\n\n    }\n\n\n\n    \/* decode the remainder *\/\n\n    for (i = 0, r = 0, bit = 0; i < n; i++) {\n\n        if (!i)\n\n            rung_node = &ur->rem_rung_list[n];\n\n        else {\n\n            if (!rung_node->next_index) {\n\n                if (ur->rung_list_size <= (ur->avail_index + 2) * sizeof(ElsRungNode)) {\n\n                    \/\/ remember rung_node position\n\n                    ptrdiff_t pos     = rung_node - ur->rem_rung_list;\n\n                    ur->rem_rung_list = av_realloc(ur->rem_rung_list,\n\n                                                   ur->rung_list_size +\n\n                                                   RUNG_SPACE);\n\n                    if (!ur->rem_rung_list) {\n\n                        av_free(ur->rem_rung_list);\n\n                        ctx->err = AVERROR(ENOMEM);\n\n                        return 0;\n\n                    }\n\n                    memset((uint8_t *) ur->rem_rung_list + ur->rung_list_size, 0,\n\n                           RUNG_SPACE);\n\n                    ur->rung_list_size += RUNG_SPACE;\n\n                    \/\/ restore rung_node position in the new list\n\n                    rung_node = &ur->rem_rung_list[pos];\n\n                }\n\n                rung_node->next_index = ur->avail_index;\n\n                ur->avail_index      += 2;\n\n            }\n\n            rung_node = &ur->rem_rung_list[rung_node->next_index + bit];\n\n        }\n\n\n\n        bit = ff_els_decode_bit(ctx, &rung_node->rung);\n\n        if (ctx->err)\n\n            return bit;\n\n\n\n        r = (r << 1) + bit;\n\n    }\n\n\n\n    return (1 << n) - 1 + r; \/* make value from exp golomb code *\/\n\n}\n","target":1,"code_token_length":649,"total_token_length":885,"max_tokens_setting":1024}
+{"idx":320690,"func":"static void e1000_reset(void *opaque)\n\n{\n\n    E1000State *d = opaque;\n\n\n\n\n\n    qemu_del_timer(d->autoneg_timer);\n\n    memset(d->phy_reg, 0, sizeof d->phy_reg);\n\n    memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init);\n\n    memset(d->mac_reg, 0, sizeof d->mac_reg);\n\n    memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init);\n\n    d->rxbuf_min_shift = 1;\n\n    memset(&d->tx, 0, sizeof d->tx);\n\n\n\n    if (d->nic->nc.link_down) {\n\n        e1000_link_down(d);\n\n    }\n\n\n\n    \/* Some guests expect pre-initialized RAH\/RAL (AddrValid flag + MACaddr) *\/\n\n    d->mac_reg[RA] = 0;\n\n    d->mac_reg[RA + 1] = E1000_RAH_AV;\n\n    for (i = 0; i < 4; i++) {\n\n        d->mac_reg[RA] |= macaddr[i] << (8 * i);\n\n        d->mac_reg[RA + 1] |= (i < 2) ? macaddr[i + 4] << (8 * i) : 0;\n\n    }\n\n}","target":1,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":453597,"func":"fill_boxes (void\t\t*_dst,\n\t    cairo_operator_t\t op,\n\t    const cairo_color_t\t*color,\n\t    cairo_boxes_t\t*boxes)\n{\n    cairo_image_surface_t *dst = _dst;\n    struct _cairo_boxes_chunk *chunk;\n    uint32_t pixel;\n    int i;\n\n    TRACE ((stderr, \"%s x %d\\n\", __FUNCTION__, boxes->num_boxes));\n\n    if (fill_reduces_to_source (op, color, dst) &&\n\tcolor_to_pixel (color, dst->pixman_format, &pixel))\n    {\n\tfor (chunk = &boxes->chunks; chunk; chunk = chunk->next) {\n\t    for (i = 0; i < chunk->count; i++) {\n\t\tint x = _cairo_fixed_integer_part (chunk->base[i].p1.x);\n\t\tint y = _cairo_fixed_integer_part (chunk->base[i].p1.y);\n\t\tint w = _cairo_fixed_integer_part (chunk->base[i].p2.x) - x;\n\t\tint h = _cairo_fixed_integer_part (chunk->base[i].p2.y) - y;\n\t\tpixman_fill ((uint32_t *) dst->data,\n\t\t\t     dst->stride \/ sizeof (uint32_t),\n\t\t\t     PIXMAN_FORMAT_BPP (dst->pixman_format),\n\t\t\t     x, y, w, h, pixel);\n\t    }\n\t}\n    }\n    else\n    {\n\tpixman_image_t *src = _pixman_image_for_color (color);\n\n\top = _pixman_operator (op);\n\tfor (chunk = &boxes->chunks; chunk; chunk = chunk->next) {\n\t    for (i = 0; i < chunk->count; i++) {\n\t\tint x1 = _cairo_fixed_integer_part (chunk->base[i].p1.x);\n\t\tint y1 = _cairo_fixed_integer_part (chunk->base[i].p1.y);\n\t\tint x2 = _cairo_fixed_integer_part (chunk->base[i].p2.x);\n\t\tint y2 = _cairo_fixed_integer_part (chunk->base[i].p2.y);\n\t\tpixman_image_composite32 (op,\n\t\t\t\t\t  src, NULL, dst->pixman_image,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x1, y1,\n\t\t\t\t\t  x2-x1, y2-y1);\n\t    }\n\t}\n\n\tpixman_image_unref (src);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":136067,"func":"static long snd_seq_ioctl(struct file *file, unsigned int cmd,\n\t\t\t  unsigned long arg)\n{\n\tstruct snd_seq_client *client = file->private_data;\n\t\/* To use kernel stack for ioctl data. *\/\n\tunion {\n\t\tint pversion;\n\t\tint client_id;\n\t\tstruct snd_seq_system_info\tsystem_info;\n\t\tstruct snd_seq_running_info\trunning_info;\n\t\tstruct snd_seq_client_info\tclient_info;\n\t\tstruct snd_seq_port_info\tport_info;\n\t\tstruct snd_seq_port_subscribe\tport_subscribe;\n\t\tstruct snd_seq_queue_info\tqueue_info;\n\t\tstruct snd_seq_queue_status\tqueue_status;\n\t\tstruct snd_seq_queue_tempo\ttempo;\n\t\tstruct snd_seq_queue_timer\tqueue_timer;\n\t\tstruct snd_seq_queue_client\tqueue_client;\n\t\tstruct snd_seq_client_pool\tclient_pool;\n\t\tstruct snd_seq_remove_events\tremove_events;\n\t\tstruct snd_seq_query_subs\tquery_subs;\n\t} buf;\n\tconst struct ioctl_handler *handler;\n\tunsigned long size;\n\tint err;\n\n\tif (snd_BUG_ON(!client))\n\t\treturn -ENXIO;\n\n\tfor (handler = ioctl_handlers; handler->cmd > 0; ++handler) {\n\t\tif (handler->cmd == cmd)\n\t\t\tbreak;\n\t}\n\tif (handler->cmd == 0)\n\t\treturn -ENOTTY;\n\n\tmemset(&buf, 0, sizeof(buf));\n\n\t\/*\n\t * All of ioctl commands for ALSA sequencer get an argument of size\n\t * within 13 bits. We can safely pick up the size from the command.\n\t *\/\n\tsize = _IOC_SIZE(handler->cmd);\n\tif (handler->cmd & IOC_IN) {\n\t\tif (copy_from_user(&buf, (const void __user *)arg, size))\n\t\t\treturn -EFAULT;\n\t}\n\n\terr = handler->func(client, &buf);\n\tif (err >= 0) {\n\t\t\/* Some commands includes a bug in 'dir' field. *\/\n\t\tif (handler->cmd == SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT ||\n\t\t    handler->cmd == SNDRV_SEQ_IOCTL_SET_CLIENT_POOL ||\n\t\t    (handler->cmd & IOC_OUT))\n\t\t\tif (copy_to_user((void __user *)arg, &buf, size))\n\t\t\t\treturn -EFAULT;\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":475739,"func":"static int nf_tables_delflowtable(struct sk_buff *skb,\n\t\t\t\t  const struct nfnl_info *info,\n\t\t\t\t  const struct nlattr * const nla[])\n{\n\tconst struct nfgenmsg *nfmsg = nlmsg_data(info->nlh);\n\tstruct netlink_ext_ack *extack = info->extack;\n\tu8 genmask = nft_genmask_next(info->net);\n\tint family = nfmsg->nfgen_family;\n\tstruct nft_flowtable *flowtable;\n\tstruct net *net = info->net;\n\tconst struct nlattr *attr;\n\tstruct nft_table *table;\n\tstruct nft_ctx ctx;\n\n\tif (!nla[NFTA_FLOWTABLE_TABLE] ||\n\t    (!nla[NFTA_FLOWTABLE_NAME] &&\n\t     !nla[NFTA_FLOWTABLE_HANDLE]))\n\t\treturn -EINVAL;\n\n\ttable = nft_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE], family,\n\t\t\t\t genmask, NETLINK_CB(skb).portid);\n\tif (IS_ERR(table)) {\n\t\tNL_SET_BAD_ATTR(extack, nla[NFTA_FLOWTABLE_TABLE]);\n\t\treturn PTR_ERR(table);\n\t}\n\n\tif (nla[NFTA_FLOWTABLE_HANDLE]) {\n\t\tattr = nla[NFTA_FLOWTABLE_HANDLE];\n\t\tflowtable = nft_flowtable_lookup_byhandle(table, attr, genmask);\n\t} else {\n\t\tattr = nla[NFTA_FLOWTABLE_NAME];\n\t\tflowtable = nft_flowtable_lookup(table, attr, genmask);\n\t}\n\n\tif (IS_ERR(flowtable)) {\n\t\tNL_SET_BAD_ATTR(extack, attr);\n\t\treturn PTR_ERR(flowtable);\n\t}\n\n\tnft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);\n\n\tif (nla[NFTA_FLOWTABLE_HOOK])\n\t\treturn nft_delflowtable_hook(&ctx, flowtable);\n\n\tif (flowtable->use > 0) {\n\t\tNL_SET_BAD_ATTR(extack, attr);\n\t\treturn -EBUSY;\n\t}\n\n\treturn nft_delflowtable(&ctx, flowtable);\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":41334,"func":"static int32_t next_hfs_char(const char **in, size_t *len)\n{\n\twhile (*len) {\n\t\tint32_t codepoint;\n\t\tint cp_len = git__utf8_iterate((const uint8_t *)(*in), (int)(*len), &codepoint);\n\t\tif (cp_len < 0)\n\t\t\treturn -1;\n\n\t\t(*in) += cp_len;\n\t\t(*len) -= cp_len;\n\n\t\t\/* these code points are ignored completely *\/\n\t\tswitch (codepoint) {\n\t\tcase 0x200c: \/* ZERO WIDTH NON-JOINER *\/\n\t\tcase 0x200d: \/* ZERO WIDTH JOINER *\/\n\t\tcase 0x200e: \/* LEFT-TO-RIGHT MARK *\/\n\t\tcase 0x200f: \/* RIGHT-TO-LEFT MARK *\/\n\t\tcase 0x202a: \/* LEFT-TO-RIGHT EMBEDDING *\/\n\t\tcase 0x202b: \/* RIGHT-TO-LEFT EMBEDDING *\/\n\t\tcase 0x202c: \/* POP DIRECTIONAL FORMATTING *\/\n\t\tcase 0x202d: \/* LEFT-TO-RIGHT OVERRIDE *\/\n\t\tcase 0x202e: \/* RIGHT-TO-LEFT OVERRIDE *\/\n\t\tcase 0x206a: \/* INHIBIT SYMMETRIC SWAPPING *\/\n\t\tcase 0x206b: \/* ACTIVATE SYMMETRIC SWAPPING *\/\n\t\tcase 0x206c: \/* INHIBIT ARABIC FORM SHAPING *\/\n\t\tcase 0x206d: \/* ACTIVATE ARABIC FORM SHAPING *\/\n\t\tcase 0x206e: \/* NATIONAL DIGIT SHAPES *\/\n\t\tcase 0x206f: \/* NOMINAL DIGIT SHAPES *\/\n\t\tcase 0xfeff: \/* ZERO WIDTH NO-BREAK SPACE *\/\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* fold into lowercase -- this will only fold characters in\n\t\t * the ASCII range, which is perfectly fine, because the\n\t\t * git folder name can only be composed of ascii characters\n\t\t *\/\n\t\treturn git__tolower(codepoint);\n\t}\n\treturn 0; \/* NULL byte -- end of string *\/\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":269594,"func":"ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t   u8 type, u8 code, int offset, __be32 info)\n{\n\tint rel_msg = 0;\n\tu8 rel_type = type;\n\tu8 rel_code = code;\n\t__u32 rel_info = ntohl(info);\n\tint err;\n\tstruct sk_buff *skb2;\n\tstruct iphdr *eiph;\n\tstruct flowi fl;\n\tstruct rtable *rt;\n\n\terr = ip6_tnl_err(skb, IPPROTO_IPIP, opt, &rel_type, &rel_code,\n\t\t\t  &rel_msg, &rel_info, offset);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (rel_msg == 0)\n\t\treturn 0;\n\n\tswitch (rel_type) {\n\tcase ICMPV6_DEST_UNREACH:\n\t\tif (rel_code != ICMPV6_ADDR_UNREACH)\n\t\t\treturn 0;\n\t\trel_type = ICMP_DEST_UNREACH;\n\t\trel_code = ICMP_HOST_UNREACH;\n\t\tbreak;\n\tcase ICMPV6_PKT_TOOBIG:\n\t\tif (rel_code != 0)\n\t\t\treturn 0;\n\t\trel_type = ICMP_DEST_UNREACH;\n\t\trel_code = ICMP_FRAG_NEEDED;\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\tif (!pskb_may_pull(skb, offset + sizeof(struct iphdr)))\n\t\treturn 0;\n\n\tskb2 = skb_clone(skb, GFP_ATOMIC);\n\tif (!skb2)\n\t\treturn 0;\n\n\tskb_dst_drop(skb2);\n\n\tskb_pull(skb2, offset);\n\tskb_reset_network_header(skb2);\n\teiph = ip_hdr(skb2);\n\n\t\/* Try to guess incoming interface *\/\n\tmemset(&fl, 0, sizeof(fl));\n\tfl.fl4_dst = eiph->saddr;\n\tfl.fl4_tos = RT_TOS(eiph->tos);\n\tfl.proto = IPPROTO_IPIP;\n\tif (ip_route_output_key(dev_net(skb->dev), &rt, &fl))\n\t\tgoto out;\n\n\tskb2->dev = rt->u.dst.dev;\n\n\t\/* route \"incoming\" packet *\/\n\tif (rt->rt_flags & RTCF_LOCAL) {\n\t\tip_rt_put(rt);\n\t\trt = NULL;\n\t\tfl.fl4_dst = eiph->daddr;\n\t\tfl.fl4_src = eiph->saddr;\n\t\tfl.fl4_tos = eiph->tos;\n\t\tif (ip_route_output_key(dev_net(skb->dev), &rt, &fl) ||\n\t\t    rt->u.dst.dev->type != ARPHRD_TUNNEL) {\n\t\t\tip_rt_put(rt);\n\t\t\tgoto out;\n\t\t}\n\t\tskb_dst_set(skb2, (struct dst_entry *)rt);\n\t} else {\n\t\tip_rt_put(rt);\n\t\tif (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos,\n\t\t\t\t   skb2->dev) ||\n\t\t    skb_dst(skb2)->dev->type != ARPHRD_TUNNEL)\n\t\t\tgoto out;\n\t}\n\n\t\/* change mtu on this route *\/\n\tif (rel_type == ICMP_DEST_UNREACH && rel_code == ICMP_FRAG_NEEDED) {\n\t\tif (rel_info > dst_mtu(skb_dst(skb2)))\n\t\t\tgoto out;\n\n\t\tskb_dst(skb2)->ops->update_pmtu(skb_dst(skb2), rel_info);\n\t}\n\n\ticmp_send(skb2, rel_type, rel_code, htonl(rel_info));\n\nout:\n\tkfree_skb(skb2);\n\treturn 0;\n}","target":0,"code_token_length":731,"total_token_length":967,"max_tokens_setting":1024}
+{"idx":372701,"func":"void CLASS phase_one_flat_field (int is_float, int nc)\n{\n  ushort head[8];\n  unsigned wide, y, x, c, rend, cend, row, col;\n  float *mrow, num, mult[4];\n\n  read_shorts (head, 8);\n  wide = head[2] \/ head[4];\n  mrow = (float *) calloc (nc*wide, sizeof *mrow);\n  merror (mrow, \"phase_one_flat_field()\");\n  for (y=0; y < head[3] \/ head[5]; y++) {\n    for (x=0; x < wide; x++)\n      for (c=0; c < nc; c+=2) {\n\tnum = is_float ? getreal(11) : get2()\/32768.0;\n\tif (y==0) mrow[c*wide+x] = num;\n\telse mrow[(c+1)*wide+x] = (num - mrow[c*wide+x]) \/ head[5];\n      }\n    if (y==0) continue;\n    rend = head[1]-top_margin + y*head[5];\n    for (row = rend-head[5]; row < height && row < rend; row++) {\n      for (x=1; x < wide; x++) {\n\tfor (c=0; c < nc; c+=2) {\n\t  mult[c] = mrow[c*wide+x-1];\n\t  mult[c+1] = (mrow[c*wide+x] - mult[c]) \/ head[4];\n\t}\n\tcend = head[0]-left_margin + x*head[4];\n\tfor (col = cend-head[4]; col < width && col < cend; col++) {\n\t  c = nc > 2 ? FC(row,col) : 0;\n\t  if (!(c & 1)) {\n\t    c = BAYER(row,col) * mult[c];\n\t    BAYER(row,col) = LIM(c,0,65535);\n\t  }\n\t  for (c=0; c < nc; c+=2)\n\t    mult[c] += mult[c+1];\n\t}\n      }\n      for (x=0; x < wide; x++)\n\tfor (c=0; c < nc; c+=2)\n\t  mrow[c*wide+x] += mrow[(c+1)*wide+x];\n    }\n  }\n  free (mrow);\n}","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":205258,"func":"static MegasasCmd *megasas_enqueue_frame(MegasasState *s,\n    hwaddr frame, uint64_t context, int count)\n{\n    PCIDevice *pcid = PCI_DEVICE(s);\n    MegasasCmd *cmd = NULL;\n    int frame_size = MFI_FRAME_SIZE * 16;\n    hwaddr frame_size_p = frame_size;\n    unsigned long index;\n\n    index = 0;\n    while (index < s->fw_cmds) {\n        index = find_next_zero_bit(s->frame_map, s->fw_cmds, index);\n        if (!s->frames[index].pa)\n            break;\n        \/* Busy frame found *\/\n        trace_megasas_qf_mapped(index);\n    }\n    if (index >= s->fw_cmds) {\n        \/* All frames busy *\/\n        trace_megasas_qf_busy(frame);\n        return NULL;\n    }\n    cmd = &s->frames[index];\n    set_bit(index, s->frame_map);\n    trace_megasas_qf_new(index, frame);\n\n    cmd->pa = frame;\n    \/* Map all possible frames *\/\n    cmd->frame = pci_dma_map(pcid, frame, &frame_size_p, 0);\n    if (frame_size_p != frame_size) {\n        trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame);\n        if (cmd->frame) {\n            megasas_unmap_frame(s, cmd);\n        }\n        s->event_count++;\n        return NULL;\n    }\n    cmd->pa_size = frame_size_p;\n    cmd->context = context;\n    if (!megasas_use_queue64(s)) {\n        cmd->context &= (uint64_t)0xFFFFFFFF;\n    }\n    cmd->count = count;\n    s->busy++;\n\n    if (s->consumer_pa) {\n        s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa);\n    }\n    trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context,\n                             s->reply_queue_head, s->reply_queue_tail, s->busy);\n\n    return cmd;\n}\n","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":20974,"func":"void mime_hdr_describe ( HdrHeapObjImpl * raw , bool recurse ) {\n MIMEFieldBlockImpl * fblock ;\n MIMEHdrImpl * obj = ( MIMEHdrImpl * ) raw ;\n Debug ( \"http\" , \"\\n\\t[PBITS: 0x%08X%08X, SLACC: 0x%04X%04X%04X%04X, HEADBLK: %p, TAILBLK: %p]\" , ( uint32_t ) ( ( obj -> m_presence_bits >> 32 ) & ( TOK_64_CONST ( 0xFFFFFFFF ) ) ) , ( uint32_t ) ( ( obj -> m_presence_bits >> 0 ) & ( TOK_64_CONST ( 0xFFFFFFFF ) ) ) , obj -> m_slot_accelerators [ 0 ] , obj -> m_slot_accelerators [ 1 ] , obj -> m_slot_accelerators [ 2 ] , obj -> m_slot_accelerators [ 3 ] , & ( obj -> m_first_fblock ) , obj -> m_fblock_list_tail ) ;\n Debug ( \"http\" , \"\\t[CBITS: 0x%08X, T_MAXAGE: %d, T_SMAXAGE: %d, T_MAXSTALE: %d, T_MINFRESH: %d, PNO$: %d]\" , obj -> m_cooked_stuff . m_cache_control . m_mask , obj -> m_cooked_stuff . m_cache_control . m_secs_max_age , obj -> m_cooked_stuff . m_cache_control . m_secs_s_maxage , obj -> m_cooked_stuff . m_cache_control . m_secs_max_stale , obj -> m_cooked_stuff . m_cache_control . m_secs_min_fresh , obj -> m_cooked_stuff . m_pragma . m_no_cache ) ;\n for ( fblock = & ( obj -> m_first_fblock ) ;\n fblock != nullptr ;\n fblock = fblock -> m_next ) {\n if ( recurse || ( fblock == & ( obj -> m_first_fblock ) ) ) {\n obj_describe ( ( HdrHeapObjImpl * ) fblock , recurse ) ;\n }\n }\n }","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":217289,"func":"int SSLClientSocketOpenSSL::DoPayloadRead() {\n  crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);\n\n  int rv;\n  if (pending_read_error_ != kNoPendingReadResult) {\n    rv = pending_read_error_;\n    pending_read_error_ = kNoPendingReadResult;\n    if (rv == 0) {\n      net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED,\n                                    rv, user_read_buf_->data());\n    }\n    return rv;\n  }\n\n  int total_bytes_read = 0;\n  do {\n    rv = SSL_read(ssl_, user_read_buf_->data() + total_bytes_read,\n                  user_read_buf_len_ - total_bytes_read);\n    if (rv > 0)\n      total_bytes_read += rv;\n  } while (total_bytes_read < user_read_buf_len_ && rv > 0);\n\n  if (total_bytes_read == user_read_buf_len_) {\n    rv = total_bytes_read;\n  } else {\n    int *next_result = &rv;\n    if (total_bytes_read > 0) {\n      pending_read_error_ = rv;\n      rv = total_bytes_read;\n      next_result = &pending_read_error_;\n    }\n\n    if (client_auth_cert_needed_) {\n      *next_result = ERR_SSL_CLIENT_AUTH_CERT_NEEDED;\n    } else if (*next_result < 0) {\n      int err = SSL_get_error(ssl_, *next_result);\n      *next_result = MapOpenSSLError(err, err_tracer);\n      if (rv > 0 && *next_result == ERR_IO_PENDING) {\n        *next_result = kNoPendingReadResult;\n      }\n    }\n  }\n\n  if (rv >= 0) {\n    net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv,\n                                  user_read_buf_->data());\n  }\n  return rv;\n}\n","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":347292,"func":"void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)\n{\n\tstruct map_struct *buf;\n\tOFF_T i, len = st_p->st_size;\n\tmd_context m;\n\tint32 remainder;\n\tint fd;\n\n\tmemset(sum, 0, MAX_DIGEST_LEN);\n\n\tfd = do_open(fname, O_RDONLY, 0);\n\tif (fd == -1)\n\t\treturn;\n\n\tbuf = map_file(fd, len, MAX_MAP_SIZE, CSUM_CHUNK);\n\n\tswitch (checksum_type) {\n\t  case CSUM_MD5:\n\t\tmd5_begin(&m);\n\n\t\tfor (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {\n\t\t\tmd5_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),\n\t\t\t\t   CSUM_CHUNK);\n\t\t}\n\n\t\tremainder = (int32)(len - i);\n\t\tif (remainder > 0)\n\t\t\tmd5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);\n\n\t\tmd5_result(&m, (uchar *)sum);\n\t\tbreak;\n\t  case CSUM_MD4:\n\t  case CSUM_MD4_OLD:\n\t  case CSUM_MD4_BUSTED:\n\t\tmdfour_begin(&m);\n\n\t\tfor (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {\n\t\t\tmdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),\n\t\t\t\t      CSUM_CHUNK);\n\t\t}\n\n\t\t\/* Prior to version 27 an incorrect MD4 checksum was computed\n\t\t * by failing to call mdfour_tail() for block sizes that\n\t\t * are multiples of 64.  This is fixed by calling mdfour_update()\n\t\t * even when there are no more bytes. *\/\n\t\tremainder = (int32)(len - i);\n\t\tif (remainder > 0 || checksum_type != CSUM_MD4_BUSTED)\n\t\t\tmdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);\n\n\t\tmdfour_result(&m, (uchar *)sum);\n\t\tbreak;\n\t  default:\n\t\trprintf(FERROR, \"invalid checksum-choice for the --checksum option (%d)\\n\", checksum_type);\n\t\texit_cleanup(RERR_UNSUPPORTED);\n\t}\n\n\tclose(fd);\n\tunmap_file(buf);\n}","target":1,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":199158,"func":"static int t_fromb64(unsigned char *a, const char *src)\n{\n    char *loc;\n    int i, j;\n    int size;\n\n    while (*src && (*src == ' ' || *src == '\\t' || *src == '\\n'))\n        ++src;\n    size = strlen(src);\n    i = 0;\n    while (i < size) {\n        loc = strchr(b64table, src[i]);\n        if (loc == (char *)0)\n            break;\n        else\n            a[i] = loc - b64table;\n        ++i;\n    }\n    \/* if nothing valid to process we have a zero length response *\/\n    if (i == 0)\n        return 0;\n    size = i;\n    i = size - 1;\n    j = size;\n    while (1) {\n        a[j] = a[i];\n        if (--i < 0)\n            break;\n        a[j] |= (a[i] & 3) << 6;\n        --j;\n        a[j] = (unsigned char)((a[i] & 0x3c) >> 2);\n        if (--i < 0)\n            break;\n        a[j] |= (a[i] & 0xf) << 4;\n        --j;\n        a[j] = (unsigned char)((a[i] & 0x30) >> 4);\n        if (--i < 0)\n            break;\n        a[j] |= (a[i] << 2);\n\n        a[--j] = 0;\n        if (--i < 0)\n            break;\n    }\n    while (a[j] == 0 && j <= size)\n        ++j;\n    i = 0;\n    while (j <= size)\n        a[i++] = a[j++];\n    return i;\n}\n","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":316143,"func":"void HTMLMediaElement::DidMoveToNewDocument(Document& old_document) {\n  BLINK_MEDIA_LOG << \"didMoveToNewDocument(\" << (void*)this << \")\";\n\n  load_timer_.MoveToNewTaskRunner(\n      GetDocument().GetTaskRunner(TaskType::kInternalMedia));\n  progress_event_timer_.MoveToNewTaskRunner(\n      GetDocument().GetTaskRunner(TaskType::kInternalMedia));\n  playback_progress_timer_.MoveToNewTaskRunner(\n      GetDocument().GetTaskRunner(TaskType::kInternalMedia));\n  audio_tracks_timer_.MoveToNewTaskRunner(\n      GetDocument().GetTaskRunner(TaskType::kInternalMedia));\n  if (viewport_intersection_observer_) {\n    ActivateViewportIntersectionMonitoring(false);\n    ActivateViewportIntersectionMonitoring(true);\n  }\n  deferred_load_timer_.MoveToNewTaskRunner(\n      GetDocument().GetTaskRunner(TaskType::kInternalMedia));\n  removed_from_document_timer_.MoveToNewTaskRunner(\n      GetDocument().GetTaskRunner(TaskType::kInternalMedia));\n\n  autoplay_policy_->DidMoveToNewDocument(old_document);\n\n  if (should_delay_load_event_) {\n    GetDocument().IncrementLoadEventDelayCount();\n  } else {\n    old_document.IncrementLoadEventDelayCount();\n  }\n\n  RemoveElementFromDocumentMap(this, &old_document);\n  AddElementToDocumentMap(this, &GetDocument());\n\n  ignore_preload_none_ = false;\n  InvokeLoadAlgorithm();\n\n  old_document.DecrementLoadEventDelayCount();\n\n  PausableObject::DidMoveToNewExecutionContext(&GetDocument());\n  HTMLElement::DidMoveToNewDocument(old_document);\n}\n","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":341887,"func":"static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0,\n\n                                 const int16_t *ubuf[2], const int16_t *bguf[2],\n\n                                 const int16_t *abuf0, uint8_t *dest,\n\n                                 int dstW, int uvalpha, int y)\n\n{\n\n    const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];\n\n    const int16_t *buf1= buf0; \/\/FIXME needed for RGB1\/BGR1\n\n\n\n    if (uvalpha < 2048) { \/\/ note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster\n\n        __asm__ volatile(\n\n            \"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)        \\n\\t\"\n\n            \"mov        %4, %%\"REG_b\"               \\n\\t\"\n\n            \"push %%\"REG_BP\"                        \\n\\t\"\n\n            YSCALEYUV2RGB1(%%REGBP, %5)\n\n            \"pxor    %%mm7, %%mm7                   \\n\\t\"\n\n            \/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 *\/\n\n#ifdef DITHER1XBPP\n\n            \"paddusb \"BLUE_DITHER\"(%5), %%mm2      \\n\\t\"\n\n            \"paddusb \"GREEN_DITHER\"(%5), %%mm4      \\n\\t\"\n\n            \"paddusb \"RED_DITHER\"(%5), %%mm5      \\n\\t\"\n\n#endif\n\n            WRITERGB16(%%REGb, 8280(%5), %%REGBP)\n\n            \"pop %%\"REG_BP\"                         \\n\\t\"\n\n            \"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"        \\n\\t\"\n\n            :: \"c\" (buf0), \"d\" (buf1), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\n               \"a\" (&c->redDither)\n\n        );\n\n    } else {\n\n        __asm__ volatile(\n\n            \"mov %%\"REG_b\", \"ESP_OFFSET\"(%5)        \\n\\t\"\n\n            \"mov        %4, %%\"REG_b\"               \\n\\t\"\n\n            \"push %%\"REG_BP\"                        \\n\\t\"\n\n            YSCALEYUV2RGB1b(%%REGBP, %5)\n\n            \"pxor    %%mm7, %%mm7                   \\n\\t\"\n\n            \/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 *\/\n\n#ifdef DITHER1XBPP\n\n            \"paddusb \"BLUE_DITHER\"(%5), %%mm2      \\n\\t\"\n\n            \"paddusb \"GREEN_DITHER\"(%5), %%mm4      \\n\\t\"\n\n            \"paddusb \"RED_DITHER\"(%5), %%mm5      \\n\\t\"\n\n#endif\n\n            WRITERGB16(%%REGb, 8280(%5), %%REGBP)\n\n            \"pop %%\"REG_BP\"                         \\n\\t\"\n\n            \"mov \"ESP_OFFSET\"(%5), %%\"REG_b\"        \\n\\t\"\n\n            :: \"c\" (buf0), \"d\" (buf1), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\n               \"a\" (&c->redDither)\n\n        );\n\n    }\n\n}\n","target":1,"code_token_length":759,"total_token_length":995,"max_tokens_setting":1024}
+{"idx":8822,"func":"static void jsiDumpInstr(Jsi_Interp *interp, jsi_Pstate *ps, Jsi_Value *_this,\n    jsi_TryList *trylist, jsi_OpCode *ip, Jsi_OpCodes *opcodes)\n{\n    int i;\n    char buf[200];\n    jsi_code_decode(interp, ip, ip - opcodes->codes, buf, sizeof(buf));\n    Jsi_Printf(interp, jsi_Stderr, \"%p: %-30.200s : THIS=%s, STACK=[\", ip, buf, jsi_evalprint(_this));\n    for (i = 0; i < interp->framePtr->Sp; ++i) {\n        Jsi_Printf(interp, jsi_Stderr, \"%s%s\", (i>0?\", \":\"\"), jsi_evalprint(_jsi_STACKIDX(i)));\n    }\n    Jsi_Printf(interp, jsi_Stderr, \"]\");\n    if (ip->fname) {\n        const char *fn = ip->fname,  *cp = Jsi_Strrchr(fn, '\/');\n        if (cp) fn = cp+1;\n        Jsi_Printf(interp, jsi_Stderr, \", %s:%d\", fn, ip->Line);\n    }\n    Jsi_Printf(interp, jsi_Stderr, \"\\n\");\n    jsi_TryList *tlt = trylist;\n    for (i = 0; tlt; tlt = tlt->next) i++;\n    if (ps->last_exception)\n        Jsi_Printf(interp, jsi_Stderr, \"TL: %d, excpt: %s\\n\", i, jsi_evalprint(ps->last_exception));\n}","target":1,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":125967,"func":"TEST_F(TestDelegate, TestCopyFromBuffer) {\n  delegate_ = std::unique_ptr<SimpleDelegate>(new SimpleDelegate({0, 1, 2}));\n  TfLiteDelegate* delegate = delegate_->get_tf_lite_delegate();\n  interpreter_->ModifyGraphWithDelegate(delegate);\n\n  constexpr int kOutputTensorIndex = 3;\n  TfLiteTensor* tensor = interpreter_->tensor(kOutputTensorIndex);\n  std::vector<float> floats = {1.0f, 2.0f, 3.0f};\n  memcpy(interpreter_->typed_tensor<float>(0), floats.data(),\n         floats.size() * sizeof(float));\n\n  memcpy(interpreter_->typed_tensor<float>(1), floats.data(),\n         floats.size() * sizeof(float));\n\n  \/\/ Before setting the buffer handle, the tensor's `delegate` is already set\n  \/\/ because it will be written by the delegate.\n  ASSERT_EQ(tensor->delegate, delegate);\n  ASSERT_EQ(tensor->buffer_handle, kTfLiteNullBufferHandle);\n\n  TfLiteBufferHandle handle = AllocateBufferHandle();\n  TfLiteStatus status =\n      interpreter_->SetBufferHandle(kOutputTensorIndex, handle, delegate);\n  interpreter_->Invoke();\n  ASSERT_EQ(status, kTfLiteOk);\n  EXPECT_EQ(tensor->delegate, delegate);\n  EXPECT_EQ(tensor->buffer_handle, handle);\n  for (int i = 0; i < tensor->dims->data[0]; ++i) {\n    ASSERT_EQ(tensor->data.f[i], 6.0f);\n  }\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":322531,"func":"static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,\n\n                                      int buf_size, AVSubtitle *sub)\n\n{\n\n    DVBSubContext *ctx = avctx->priv_data;\n\n    DVBSubDisplayDefinition *display_def = ctx->display_definition;\n\n\n\n    DVBSubRegion *region;\n\n    DVBSubRegionDisplay *display;\n\n    AVSubtitleRect *rect;\n\n    DVBSubCLUT *clut;\n\n    uint32_t *clut_table;\n\n    int i;\n\n    int offset_x=0, offset_y=0;\n\n\n\n    sub->rects = NULL;\n\n    sub->start_display_time = 0;\n\n    sub->end_display_time = ctx->time_out * 1000;\n\n    sub->format = 0;\n\n\n\n    if (display_def) {\n\n        offset_x = display_def->x;\n\n        offset_y = display_def->y;\n\n    }\n\n\n\n    sub->num_rects = ctx->display_list_size;\n\n    if (sub->num_rects <= 0)\n\n        return AVERROR_INVALIDDATA;\n\n\n\n    sub->rects = av_mallocz_array(sub->num_rects * sub->num_rects,\n\n                                  sizeof(*sub->rects));\n\n    if (!sub->rects)\n\n        return AVERROR(ENOMEM);\n\n\n\n    i = 0;\n\n\n\n    for (display = ctx->display_list; display; display = display->next) {\n\n        region = get_region(ctx, display->region_id);\n\n        rect = sub->rects[i];\n\n\n\n        if (!region)\n\n            continue;\n\n\n\n        rect->x = display->x_pos + offset_x;\n\n        rect->y = display->y_pos + offset_y;\n\n        rect->w = region->width;\n\n        rect->h = region->height;\n\n        rect->nb_colors = 16;\n\n        rect->type      = SUBTITLE_BITMAP;\n\n        rect->linesize[0] = region->width;\n\n\n\n        clut = get_clut(ctx, region->clut);\n\n\n\n        if (!clut)\n\n            clut = &default_clut;\n\n\n\n        switch (region->depth) {\n\n        case 2:\n\n            clut_table = clut->clut4;\n\n            break;\n\n        case 8:\n\n            clut_table = clut->clut256;\n\n            break;\n\n        case 4:\n\n        default:\n\n            clut_table = clut->clut16;\n\n            break;\n\n        }\n\n\n\n        rect->data[1] = av_mallocz(AVPALETTE_SIZE);\n\n        if (!rect->data[1]) {\n\n            av_free(sub->rects);\n\n            return AVERROR(ENOMEM);\n\n        }\n\n        memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));\n\n\n\n        rect->data[0] = av_malloc(region->buf_size);\n\n        if (!rect->data[0]) {\n\n            av_free(rect->data[1]);\n\n            av_free(sub->rects);\n\n            return AVERROR(ENOMEM);\n\n        }\n\n        memcpy(rect->data[0], region->pbuf, region->buf_size);\n\n\n\n#if FF_API_AVPICTURE\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n{\n\n        int j;\n\n        for (j = 0; j < 4; j++) {\n\n            rect->pict.data[j] = rect->data[j];\n\n            rect->pict.linesize[j] = rect->linesize[j];\n\n        }\n\n}\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n        i++;\n\n    }\n\n\n\n    sub->num_rects = i;\n\n\n\n#ifdef DEBUG\n\n    save_display_set(ctx);\n\n#endif\n\n\n\n    return 1;\n\n}\n","target":1,"code_token_length":756,"total_token_length":992,"max_tokens_setting":1024}
+{"idx":47316,"func":"static Jsi_RC CDataInfoCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n                              Jsi_Value **ret, Jsi_Func *funcPtr)\n{\n    UdcGet(cd, _this, funcPtr);\n    Jsi_StructSpec *sl = cd->sl;\n    Jsi_DString dStr= {};\n    const char *sptr = Jsi_DSPrintf(&dStr, \"{struct:\\\"%s\\\", label:\\\"%s\\\"}\", sl->name, cd->help?cd->help:\"\");\n    Jsi_RC rc = JSI_ERROR;\n    if (!sptr)\n        return Jsi_LogError(\"format failed\");\n    else\n        rc = Jsi_JSONParse(interp, sptr, ret, 0);\n    Jsi_DSFree(&dStr);\n    if (rc != JSI_OK)\n        return rc;\n    Jsi_Obj *sobj;\n    Jsi_Value *svalue;\n    if (cd->sf) {\n        sobj = Jsi_ObjNewType(interp, JSI_OT_ARRAY);\n        svalue = Jsi_ValueMakeObject(interp, NULL, sobj);\n        jsi_DumpOptionSpecs(interp, sobj,(Jsi_OptionSpec*) cd->sf);\n        sobj = (*ret)->d.obj;\n        Jsi_ObjInsert(interp, sobj, \"spec\", svalue, 0);\n    }\n    if (cd->slKey) {\n        sobj = Jsi_ObjNewType(interp, JSI_OT_ARRAY);\n        svalue = Jsi_ValueMakeObject(interp, NULL, sobj);\n        jsi_DumpOptionSpecs(interp, sobj, (Jsi_OptionSpec*)cd->slKey);\n        sobj = (*ret)->d.obj;\n        Jsi_ObjInsert(interp, sobj, \"keySpec\", svalue, 0);\n    }    return JSI_OK;\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":321422,"func":"xilinx_axienet_data_stream_push(StreamSlave *obj, uint8_t *buf, size_t size,\n\n                                uint32_t *hdr)\n\n{\n\n    XilinxAXIEnetStreamSlave *ds = XILINX_AXI_ENET_DATA_STREAM(obj);\n\n    XilinxAXIEnet *s = ds->enet;\n\n\n\n    \/* TX enable ?  *\/\n\n    if (!(s->tc & TC_TX)) {\n\n        return size;\n\n    }\n\n\n\n    \/* Jumbo or vlan sizes ?  *\/\n\n    if (!(s->tc & TC_JUM)) {\n\n        if (size > 1518 && size <= 1522 && !(s->tc & TC_VLAN)) {\n\n            return size;\n\n        }\n\n    }\n\n\n\n    if (hdr[0] & 1) {\n\n        unsigned int start_off = hdr[1] >> 16;\n\n        unsigned int write_off = hdr[1] & 0xffff;\n\n        uint32_t tmp_csum;\n\n        uint16_t csum;\n\n\n\n        tmp_csum = net_checksum_add(size - start_off,\n\n                                    (uint8_t *)buf + start_off);\n\n        \/* Accumulate the seed.  *\/\n\n        tmp_csum += hdr[2] & 0xffff;\n\n\n\n        \/* Fold the 32bit partial checksum.  *\/\n\n        csum = net_checksum_finish(tmp_csum);\n\n\n\n        \/* Writeback.  *\/\n\n        buf[write_off] = csum >> 8;\n\n        buf[write_off + 1] = csum & 0xff;\n\n    }\n\n\n\n    qemu_send_packet(qemu_get_queue(s->nic), buf, size);\n\n\n\n    s->stats.tx_bytes += size;\n\n    s->regs[R_IS] |= IS_TX_COMPLETE;\n\n    enet_update_irq(s);\n\n\n\n    return size;\n\n}\n","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":142495,"func":"static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)\n{\n    int s, i;\n    uint8_t *pix3 = pix2 + line_size;\n\n    s = 0;\n    for(i=0;i<h;i++) {\n        s += abs(pix1[0] - avg2(pix2[0], pix3[0]));\n        s += abs(pix1[1] - avg2(pix2[1], pix3[1]));\n        s += abs(pix1[2] - avg2(pix2[2], pix3[2]));\n        s += abs(pix1[3] - avg2(pix2[3], pix3[3]));\n        s += abs(pix1[4] - avg2(pix2[4], pix3[4]));\n        s += abs(pix1[5] - avg2(pix2[5], pix3[5]));\n        s += abs(pix1[6] - avg2(pix2[6], pix3[6]));\n        s += abs(pix1[7] - avg2(pix2[7], pix3[7]));\n        s += abs(pix1[8] - avg2(pix2[8], pix3[8]));\n        s += abs(pix1[9] - avg2(pix2[9], pix3[9]));\n        s += abs(pix1[10] - avg2(pix2[10], pix3[10]));\n        s += abs(pix1[11] - avg2(pix2[11], pix3[11]));\n        s += abs(pix1[12] - avg2(pix2[12], pix3[12]));\n        s += abs(pix1[13] - avg2(pix2[13], pix3[13]));\n        s += abs(pix1[14] - avg2(pix2[14], pix3[14]));\n        s += abs(pix1[15] - avg2(pix2[15], pix3[15]));\n        pix1 += line_size;\n        pix2 += line_size;\n        pix3 += line_size;\n    }\n    return s;\n}","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":496991,"func":"TF_LITE_MICRO_TEST(GatherNd_BatchedIndexingIntoRank3Tensor4) {\n  \/\/ For input_dims[], index_dims[], or output_dims[], element 0 is the\n  \/\/ number of dimensions in that array, not the actual dimension data.\n  int input_dims[] = {3, 3, 2, 3};\n  int index_dims[] = {3, 2, 2, 3};\n  const int32_t index_data[] = {0, 0, 1, 1, 0, 1, 1, 1, 2, 2, 1, 2};\n  const float input_data[] = {1.1, -1.2, 1.3,  -2.1, 2.2,  2.3,  \/\/\n                              3.1, 3.2,  -3.3, -4.1, -4.2, 4.3,  \/\/\n                              5.1, -5.2, 5.3,  6.1,  -6.2, 6.3};\n  const float golden_data[] = {-1.2, 3.2, 4.3, 6.3};\n  float output_data[4];\n  int output_dims[] = {2, 0, 0};\n  tflite::testing::TestGatherNd<float, int32_t>(\n      input_dims, input_data, index_dims, index_data, output_dims, output_data,\n      golden_data);\n}","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":35838,"func":"pixGetOuterBorderPta(PIX  *pixs,\n                     BOX  *box)\n{\nl_int32  allzero, x, y;\nBOX     *boxt;\nCCBORD  *ccb;\nPTA     *ptaloc, *ptad;\n\n    PROCNAME(\"pixGetOuterBorderPta\");\n\n    if (!pixs)\n        return (PTA *)ERROR_PTR(\"pixs not defined\", procName, NULL);\n    if (pixGetDepth(pixs) != 1)\n        return (PTA *)ERROR_PTR(\"pixs not binary\", procName, NULL);\n\n    pixZero(pixs, &allzero);\n    if (allzero)\n        return (PTA *)ERROR_PTR(\"pixs all 0\", procName, NULL);\n\n    if ((ccb = ccbCreate(pixs)) == NULL)\n        return (PTA *)ERROR_PTR(\"ccb not made\", procName, NULL);\n    if (!box)\n        boxt = boxCreate(0, 0, pixGetWidth(pixs), pixGetHeight(pixs));\n    else\n        boxt = boxClone(box);\n\n        \/* Get the exterior border in local coords *\/\n    pixGetOuterBorder(ccb, pixs, boxt);\n    if ((ptaloc = ptaaGetPta(ccb->local, 0, L_CLONE)) == NULL) {\n        ccbDestroy(&ccb);\n        boxDestroy(&boxt);\n        return (PTA *)ERROR_PTR(\"ptaloc not made\", procName, NULL);\n    }\n\n        \/* Transform to global coordinates, if they are given *\/\n    if (box) {\n        boxGetGeometry(box, &x, &y, NULL, NULL);\n        ptad = ptaTransform(ptaloc, x, y, 1.0, 1.0);\n    } else {\n        ptad = ptaClone(ptaloc);\n    }\n\n    ptaDestroy(&ptaloc);\n    boxDestroy(&boxt);\n    ccbDestroy(&ccb);\n    return ptad;\n}","target":0,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":424675,"func":"addToLibpath(const char *dir, BOOLEAN isPrepend)\n{\n#if defined(AIXPPC) || defined(J9ZOS390)\n\tchar *oldPath, *newPath;\n\tint rc, newSize;\n#if defined(J9ZOS390)\n\tchar *putenvPath;\n\tint putenvSize;\n#endif\n\n\toldPath = getenv(\"LIBPATH\");\n#ifdef DEBUG\n\tprintf(\"\\nLIBPATH before = %s\\n\", oldPath ? oldPath : \"<empty>\");\n#endif\n\tnewSize = (oldPath ? strlen(oldPath) : 0) + strlen(dir) + 2;  \/* 1 for :, 1 for \\0 terminator *\/\n\tnewPath = malloc(newSize);\n\n\tif(!newPath) {\n\t\tfprintf(stderr, \"addToLibpath malloc(%d) 1 failed, aborting\\n\", newSize);\n\t\tabort();\n\t}\n#if defined(AIXPPC)\n\tif (oldPath) {\n\t\tif (isPrepend) {\n\t\t\tstrcpy(newPath, dir);\n\t\t\tstrcat(newPath, \":\");\n\t\t\tstrcat(newPath, oldPath);\n\t\t} else {\n\t\t\tstrcpy(newPath, oldPath);\n\t\t\tstrcat(newPath, \":\");\n\t\t\tstrcat(newPath, dir);\n\t\t}\n\t} else {\n\t\tstrcpy(newPath, dir);\n\t}\n\n#else\n\t\/* ZOS doesn't like it when we pre-pend to LIBPATH *\/\n\tif (oldPath) {\n\t\tstrcpy(newPath, oldPath);\n\t\tstrcat(newPath, \":\");\n\t} else {\n\t\tnewPath[0] = '\\0';\n\t}\n\tstrcat(newPath, dir);\n#endif\n\n#if defined(J9ZOS390)\n\tputenvSize = newSize + strlen(\"LIBPATH=\");\n\tputenvPath = malloc(putenvSize);\n\tif(!putenvPath) {\n\t\tfprintf(stderr, \"addToLibpath malloc(%d) 2 failed, aborting\\n\", putenvSize);\n\t\tabort();\n\t}\n\n\tstrcpy(putenvPath,\"LIBPATH=\");\n\tstrcat(putenvPath, newPath);\n\trc = putenv(putenvPath);\n\tfree(putenvPath);\n#else\n\trc = setenv(\"LIBPATH\", newPath, 1);\n#endif\n\n#ifdef DEBUG\n\tprintf(\"\\nLIBPATH after = %s\\n\", getenv(\"LIBPATH\"));\n#endif\n\tfree(newPath);\n#endif\n}","target":0,"code_token_length":473,"total_token_length":709,"max_tokens_setting":1024}
+{"idx":178329,"func":"static int ecp_check_pubkey_sw( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt )\n{\n    int ret;\n    mbedtls_mpi YY, RHS;\n\n    \/* pt coordinates must be normalized for our checks *\/\n    if( mbedtls_mpi_cmp_int( &pt->X, 0 ) < 0 ||\n        mbedtls_mpi_cmp_int( &pt->Y, 0 ) < 0 ||\n        mbedtls_mpi_cmp_mpi( &pt->X, &grp->P ) >= 0 ||\n        mbedtls_mpi_cmp_mpi( &pt->Y, &grp->P ) >= 0 )\n        return( MBEDTLS_ERR_ECP_INVALID_KEY );\n\n    mbedtls_mpi_init( &YY ); mbedtls_mpi_init( &RHS );\n\n    \/*\n     * YY = Y^2\n     * RHS = X (X^2 + A) + B = X^3 + A X + B\n     *\/\n    MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &YY,  &pt->Y,   &pt->Y  ) );  MOD_MUL( YY  );\n    MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &RHS, &pt->X,   &pt->X  ) );  MOD_MUL( RHS );\n\n    \/* Special case for A = -3 *\/\n    if( grp->A.p == NULL )\n    {\n        MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &RHS, &RHS, 3       ) );  MOD_SUB( RHS );\n    }\n    else\n    {\n        MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &RHS, &RHS, &grp->A ) );  MOD_ADD( RHS );\n    }\n\n    MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &RHS, &RHS,     &pt->X  ) );  MOD_MUL( RHS );\n    MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &RHS, &RHS,     &grp->B ) );  MOD_ADD( RHS );\n\n    if( mbedtls_mpi_cmp_mpi( &YY, &RHS ) != 0 )\n        ret = MBEDTLS_ERR_ECP_INVALID_KEY;\n\ncleanup:\n\n    mbedtls_mpi_free( &YY ); mbedtls_mpi_free( &RHS );\n\n    return( ret );\n}\n","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":345534,"func":"htmlParseComment(htmlParserCtxtPtr ctxt) {\n    xmlChar *buf = NULL;\n    int len;\n    int size = HTML_PARSER_BUFFER_SIZE;\n    int q, ql;\n    int r, rl;\n    int cur, l;\n    xmlParserInputState state;\n\n    \/*\n     * Check that there is a comment right here.\n     *\/\n    if ((RAW != '<') || (NXT(1) != '!') ||\n        (NXT(2) != '-') || (NXT(3) != '-')) return;\n\n    state = ctxt->instate;\n    ctxt->instate = XML_PARSER_COMMENT;\n    SHRINK;\n    SKIP(4);\n    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));\n    if (buf == NULL) {\n        htmlErrMemory(ctxt, \"buffer allocation failed\\n\");\n\tctxt->instate = state;\n\treturn;\n    }\n    q = CUR_CHAR(ql);\n    NEXTL(ql);\n    r = CUR_CHAR(rl);\n    NEXTL(rl);\n    cur = CUR_CHAR(l);\n    len = 0;\n    while (IS_CHAR(cur) &&\n           ((cur != '>') ||\n\t    (r != '-') || (q != '-'))) {\n\tif (len + 5 >= size) {\n\t    xmlChar *tmp;\n\n\t    size *= 2;\n\t    tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));\n\t    if (tmp == NULL) {\n\t        xmlFree(buf);\n\t        htmlErrMemory(ctxt, \"growing buffer failed\\n\");\n\t\tctxt->instate = state;\n\t\treturn;\n\t    }\n\t    buf = tmp;\n\t}\n\tCOPY_BUF(ql,buf,len,q);\n\tq = r;\n\tql = rl;\n\tr = cur;\n\trl = l;\n\tNEXTL(l);\n\tcur = CUR_CHAR(l);\n\tif (cur == 0) {\n\t    SHRINK;\n\t    GROW;\n\t    cur = CUR_CHAR(l);\n\t}\n    }\n    buf[len] = 0;\n    if (!IS_CHAR(cur)) {\n\thtmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,\n\t             \"Comment not terminated \\n<!--%.50s\\n\", buf, NULL);\n\txmlFree(buf);\n    } else {\n        NEXT;\n\tif ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&\n\t    (!ctxt->disableSAX))\n\t    ctxt->sax->comment(ctxt->userData, buf);\n\txmlFree(buf);\n    }\n    ctxt->instate = state;\n}","target":1,"code_token_length":524,"total_token_length":760,"max_tokens_setting":1024}
+{"idx":345035,"func":"_asn1_get_octet_string (asn1_node node, const unsigned char *der, unsigned der_len, int *len)\n{\n  int len2, len3, counter, tot_len, indefinite;\n\n  counter = 0;\n\n  if (*(der - 1) & ASN1_CLASS_STRUCTURED)\n    {\n      tot_len = 0;\n      indefinite = asn1_get_length_der (der, der_len, &len3);\n      if (indefinite < -1)\n\treturn ASN1_DER_ERROR;\n\n      counter += len3;\n      if (indefinite >= 0)\n\tindefinite += len3;\n\n      while (1)\n\t{\n\t  if (counter > der_len)\n\t    return ASN1_DER_ERROR;\n\n\t  if (indefinite == -1)\n\t    {\n\t      if ((der[counter] == 0) && (der[counter + 1] == 0))\n\t\t{\n\t\t  counter += 2;\n\t\t  break;\n\t\t}\n\t    }\n\t  else if (counter >= indefinite)\n\t    break;\n\n\t  if (der[counter] != ASN1_TAG_OCTET_STRING)\n\t    return ASN1_DER_ERROR;\n\n\t  counter++;\n\n\t  len2 = asn1_get_length_der (der + counter, der_len - counter, &len3);\n\t  if (len2 <= 0)\n\t    return ASN1_DER_ERROR;\n\n\t  counter += len3 + len2;\n\t  tot_len += len2;\n\t}\n\n      \/* copy *\/\n      if (node)\n\t{\n\t  unsigned char temp[ASN1_MAX_LENGTH_SIZE];\n\t  int ret;\n\n\t  len2 = sizeof (temp);\n\n\t  asn1_length_der (tot_len, temp, &len2);\n\t  _asn1_set_value (node, temp, len2);\n\n\t  ret = _asn1_extract_der_octet (node, der, der_len);\n\t  if (ret != ASN1_SUCCESS)\n\t    return ret;\n\n\t}\n    }\n  else\n    {\t\t\t\t\/* NOT STRUCTURED *\/\n      len2 = asn1_get_length_der (der, der_len, &len3);\n      if (len2 < 0)\n\treturn ASN1_DER_ERROR;\n\n      counter = len3 + len2;\n      if (node)\n\t_asn1_set_value (node, der, counter);\n    }\n\n  *len = counter;\n  return ASN1_SUCCESS;\n\n}","target":1,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":170359,"func":"xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name,\n\t   const xmlChar *nameURI, const xmlChar *value) {\n    xmlNodeSetPtr ret;\n    xsltKeyTablePtr table;\n    int init_table = 0;\n\n    if ((ctxt == NULL) || (name == NULL) || (value == NULL) ||\n\t(ctxt->document == NULL))\n\treturn(NULL);\n\n#ifdef WITH_XSLT_DEBUG_KEYS\n    xsltGenericDebug(xsltGenericDebugContext,\n\t\"Get key %s, value %s\\n\", name, value);\n#endif\n\n    \/*\n     * keys are computed only on-demand on first key access for a document\n     *\/\n    if ((ctxt->document->nbKeysComputed < ctxt->nbKeys) &&\n        (ctxt->keyInitLevel == 0)) {\n        \/*\n\t * If non-recursive behaviour, just try to initialize all keys\n\t *\/\n\tif (xsltInitAllDocKeys(ctxt))\n\t    return(NULL);\n    }\n\nretry:\n    table = (xsltKeyTablePtr) ctxt->document->keys;\n    while (table != NULL) {\n\tif (((nameURI != NULL) == (table->nameURI != NULL)) &&\n\t    xmlStrEqual(table->name, name) &&\n\t    xmlStrEqual(table->nameURI, nameURI))\n\t{\n\t    ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value);\n\t    return(ret);\n\t}\n\ttable = table->next;\n    }\n\n    if ((ctxt->keyInitLevel != 0) && (init_table == 0)) {\n        \/*\n\t * Apparently one key is recursive and this one is needed,\n\t * initialize just it, that time and retry\n\t *\/\n        xsltInitDocKeyTable(ctxt, name, nameURI);\n\tinit_table = 1;\n\tgoto retry;\n    }\n\n    return(NULL);\n}\n","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":71012,"func":"void nntp_hcache_update(struct NntpData *nntp_data, header_cache_t *hc)\n{\n  char buf[16];\n  bool old = false;\n  void *hdata = NULL;\n  anum_t first = 0, last = 0;\n\n  if (!hc)\n    return;\n\n  \/* fetch previous values of first and last *\/\n  hdata = mutt_hcache_fetch_raw(hc, \"index\", 5);\n  if (hdata)\n  {\n    mutt_debug(2, \"mutt_hcache_fetch index: %s\\n\", (char *) hdata);\n    if (sscanf(hdata, ANUM \" \" ANUM, &first, &last) == 2)\n    {\n      old = true;\n      nntp_data->last_cached = last;\n\n      \/* clean removed headers from cache *\/\n      for (anum_t current = first; current <= last; current++)\n      {\n        if (current >= nntp_data->first_message && current <= nntp_data->last_message)\n          continue;\n\n        snprintf(buf, sizeof(buf), \"%u\", current);\n        mutt_debug(2, \"mutt_hcache_delete %s\\n\", buf);\n        mutt_hcache_delete(hc, buf, strlen(buf));\n      }\n    }\n    mutt_hcache_free(hc, &hdata);\n  }\n\n  \/* store current values of first and last *\/\n  if (!old || nntp_data->first_message != first || nntp_data->last_message != last)\n  {\n    snprintf(buf, sizeof(buf), \"%u %u\", nntp_data->first_message, nntp_data->last_message);\n    mutt_debug(2, \"mutt_hcache_store index: %s\\n\", buf);\n    mutt_hcache_store_raw(hc, \"index\", 5, buf, strlen(buf));\n  }\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":378917,"func":"int LZ4_loadDict (void* LZ4_dict, const char* dictionary, int dictSize)\n{\n    LZ4_stream_t_internal* dict = (LZ4_stream_t_internal*) LZ4_dict;\n    const BYTE* p = (const BYTE*)dictionary;\n    const BYTE* const dictEnd = p + dictSize;\n    const BYTE* base;\n\n    LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal));      \/* A compilation error here means LZ4_STREAMSIZE is not large enough *\/\n    if (dict->initCheck) MEM_INIT(dict, 0, sizeof(LZ4_stream_t_internal));   \/* Uninitialized structure detected *\/\n\n    if (dictSize < MINMATCH)\n    {\n        dict->dictionary = NULL;\n        dict->dictSize = 0;\n        return 1;\n    }\n\n    if (p <= dictEnd - 64 KB) p = dictEnd - 64 KB;\n    base = p - dict->currentOffset;\n    dict->dictionary = p;\n    dict->dictSize = (U32)(dictEnd - p);\n    dict->currentOffset += dict->dictSize;\n\n    while (p <= dictEnd-MINMATCH)\n    {\n        LZ4_putPosition(p, dict, byU32, base);\n        p+=3;\n    }\n\n    return 1;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":349041,"func":"static int report_block(struct dquot *dquot, unsigned int blk, char *bitmap,\n\t\t\tint (*process_dquot) (struct dquot *, void *),\n\t\t\tvoid *data)\n{\n\tstruct qtree_mem_dqinfo *info =\n\t\t\t&dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree;\n\tdqbuf_t buf = getdqbuf();\n\tstruct qt_disk_dqdbheader *dh;\n\tchar *ddata;\n\tint entries, i;\n\n\tif (!buf)\n\t\treturn 0;\n\n\tset_bit(bitmap, blk);\n\tread_blk(dquot->dq_h, blk, buf);\n\tdh = (struct qt_disk_dqdbheader *)buf;\n\tddata = buf + sizeof(struct qt_disk_dqdbheader);\n\tentries = ext2fs_le16_to_cpu(dh->dqdh_entries);\n\tfor (i = 0; i < qtree_dqstr_in_blk(info);\n\t\t\ti++, ddata += info->dqi_entry_size)\n\t\tif (!qtree_entry_unused(info, ddata)) {\n\t\t\tdquot->dq_dqb.u.v2_mdqb.dqb_off =\n\t\t\t\t(blk << QT_BLKSIZE_BITS) +\n\t\t\t\tsizeof(struct qt_disk_dqdbheader) +\n\t\t\t\ti * info->dqi_entry_size;\n\t\t\tinfo->dqi_ops->disk2mem_dqblk(dquot, ddata);\n\t\t\tif (process_dquot(dquot, data) < 0)\n\t\t\t\tbreak;\n\t\t}\n\tfreedqbuf(buf);\n\treturn entries;\n}","target":1,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":301066,"func":"static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\n#ifdef CONFIG_X86_64\n\tif (vcpu->arch.efer & EFER_LME) {\n\t\tif (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {\n\t\t\tvcpu->arch.efer |= EFER_LMA;\n\t\t\tsvm->vmcb->save.efer |= EFER_LMA | EFER_LME;\n\t\t}\n\n\t\tif (is_paging(vcpu) && !(cr0 & X86_CR0_PG)) {\n\t\t\tvcpu->arch.efer &= ~EFER_LMA;\n\t\t\tsvm->vmcb->save.efer &= ~(EFER_LMA | EFER_LME);\n\t\t}\n\t}\n#endif\n\tvcpu->arch.cr0 = cr0;\n\n\tif (!npt_enabled)\n\t\tcr0 |= X86_CR0_PG | X86_CR0_WP;\n\n\tif (!vcpu->fpu_active)\n\t\tcr0 |= X86_CR0_TS;\n\t\/*\n\t * re-enable caching here because the QEMU bios\n\t * does not do it - this results in some delay at\n\t * reboot\n\t *\/\n\tcr0 &= ~(X86_CR0_CD | X86_CR0_NW);\n\tsvm->vmcb->save.cr0 = cr0;\n\tmark_dirty(svm->vmcb, VMCB_CR);\n\tupdate_cr0_intercept(svm);\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":331055,"func":"static SocketAddressLegacy *sd_server_config(QDict *options, Error **errp)\n\n{\n\n    QDict *server = NULL;\n\n    QObject *crumpled_server = NULL;\n\n    Visitor *iv = NULL;\n\n    SocketAddress *saddr_flat = NULL;\n\n    SocketAddressLegacy *saddr = NULL;\n\n    Error *local_err = NULL;\n\n\n\n    qdict_extract_subqdict(options, &server, \"server.\");\n\n\n\n    crumpled_server = qdict_crumple(server, errp);\n\n    if (!crumpled_server) {\n\n        goto done;\n\n    }\n\n\n\n    \/*\n\n     * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive\n\n     * server.type=inet.  .to doesn't matter, it's ignored anyway.\n\n     * That's because when @options come from -blockdev or\n\n     * blockdev_add, members are typed according to the QAPI schema,\n\n     * but when they come from -drive, they're all QString.  The\n\n     * visitor expects the former.\n\n     *\/\n\n    iv = qobject_input_visitor_new(crumpled_server);\n\n    visit_type_SocketAddress(iv, NULL, &saddr_flat, &local_err);\n\n    if (local_err) {\n\n        error_propagate(errp, local_err);\n\n        goto done;\n\n    }\n\n\n\n    saddr = socket_address_crumple(saddr_flat);\n\n\n\ndone:\n\n    qapi_free_SocketAddress(saddr_flat);\n\n    visit_free(iv);\n\n    qobject_decref(crumpled_server);\n\n    QDECREF(server);\n\n    return saddr;\n\n}\n","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":372360,"func":"cmsHPROFILE CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint)\n{\n    cmsHPROFILE hProfile;\n    cmsPipeline* LUT = NULL;\n\n    hProfile = cmsCreateRGBProfileTHR(ContextID, WhitePoint == NULL ? cmsD50_xyY() : WhitePoint, NULL, NULL);\n    if (hProfile == NULL) return NULL;\n\n    cmsSetProfileVersion(hProfile, 2.1);\n\n    cmsSetDeviceClass(hProfile, cmsSigAbstractClass);\n    cmsSetColorSpace(hProfile,  cmsSigLabData);\n    cmsSetPCS(hProfile,         cmsSigLabData);\n\n    if (!SetTextTags(hProfile, L\"Lab identity built-in\")) return NULL;\n\n    \/\/ An identity LUT is all we need\n    LUT = cmsPipelineAlloc(ContextID, 3, 3);\n    if (LUT == NULL) goto Error;\n\n    if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCLut(ContextID, 3)))\n        goto Error;\n\n    if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, LUT)) goto Error;\n    cmsPipelineFree(LUT);\n\n    return hProfile;\n\nError:\n\n    if (LUT != NULL)\n        cmsPipelineFree(LUT);\n\n    if (hProfile != NULL)\n        cmsCloseProfile(hProfile);\n\n    return NULL;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":399286,"func":"*\/\nvoid mpvio_info(Vio *vio, MYSQL_PLUGIN_VIO_INFO *info)\n{\n  memset(info, 0, sizeof(*info));\n  switch (vio->type) {\n  case VIO_TYPE_TCPIP:\n    info->protocol= MYSQL_VIO_TCP;\n    info->socket= vio_fd(vio);\n    return;\n  case VIO_TYPE_SOCKET:\n    info->protocol= MYSQL_VIO_SOCKET;\n    info->socket= vio_fd(vio);\n    return;\n  case VIO_TYPE_SSL:\n    {\n      struct sockaddr addr;\n      socklen_t addrlen= sizeof(addr);\n      if (getsockname(vio_fd(vio), &addr, &addrlen))\n        return;\n      info->protocol= addr.sa_family == AF_UNIX ?\n        MYSQL_VIO_SOCKET : MYSQL_VIO_TCP;\n      info->socket= vio_fd(vio);\n      return;\n    }\n#ifdef _WIN32\n  case VIO_TYPE_NAMEDPIPE:\n    info->protocol= MYSQL_VIO_PIPE;\n    info->handle= vio->hPipe;\n    return;\n#ifdef HAVE_SMEM\n  case VIO_TYPE_SHARED_MEMORY:\n    info->protocol= MYSQL_VIO_MEMORY;\n    info->handle= vio->handle_file_map; \/* or what ? *\/\n    return;\n#endif\n#endif\n  default: DBUG_ASSERT(0);\n  }","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":337646,"func":"static inline int64_t get_sector_offset(BlockDriverState *bs,\n\n    int64_t sector_num, int write)\n\n{\n\n    BDRVVPCState *s = bs->opaque;\n\n    uint64_t offset = sector_num * 512;\n\n    uint64_t bitmap_offset, block_offset;\n\n    uint32_t pagetable_index, pageentry_index;\n\n\n\n    pagetable_index = offset \/ s->block_size;\n\n    pageentry_index = (offset % s->block_size) \/ 512;\n\n\n\n    if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff)\n\n        return -1; \/\/ not allocated\n\n\n\n    bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index];\n\n    block_offset = bitmap_offset + s->bitmap_size + (512 * pageentry_index);\n\n\n\n    \/\/ We must ensure that we don't write to any sectors which are marked as\n\n    \/\/ unused in the bitmap. We get away with setting all bits in the block\n\n    \/\/ bitmap each time we write to a new block. This might cause Virtual PC to\n\n    \/\/ miss sparse read optimization, but it's not a problem in terms of\n\n    \/\/ correctness.\n\n    if (write && (s->last_bitmap_offset != bitmap_offset)) {\n\n        uint8_t bitmap[s->bitmap_size];\n\n\n\n        s->last_bitmap_offset = bitmap_offset;\n\n        memset(bitmap, 0xff, s->bitmap_size);\n\n        bdrv_pwrite(bs->file, bitmap_offset, bitmap, s->bitmap_size);\n\n    }\n\n\n\n\/\/    printf(\"sector: %\" PRIx64 \", index: %x, offset: %x, bioff: %\" PRIx64 \", bloff: %\" PRIx64 \"\\n\",\n\n\/\/\tsector_num, pagetable_index, pageentry_index,\n\n\/\/\tbitmap_offset, block_offset);\n\n\n\n\/\/ disabled by reason\n\n#if 0\n\n#ifdef CACHE\n\n    if (bitmap_offset != s->last_bitmap)\n\n    {\n\n\tlseek(s->fd, bitmap_offset, SEEK_SET);\n\n\n\n\ts->last_bitmap = bitmap_offset;\n\n\n\n\t\/\/ Scary! Bitmap is stored as big endian 32bit entries,\n\n\t\/\/ while we used to look it up byte by byte\n\n\tread(s->fd, s->pageentry_u8, 512);\n\n\tfor (i = 0; i < 128; i++)\n\n\t    be32_to_cpus(&s->pageentry_u32[i]);\n\n    }\n\n\n\n    if ((s->pageentry_u8[pageentry_index \/ 8] >> (pageentry_index % 8)) & 1)\n\n\treturn -1;\n\n#else\n\n    lseek(s->fd, bitmap_offset + (pageentry_index \/ 8), SEEK_SET);\n\n\n\n    read(s->fd, &bitmap_entry, 1);\n\n\n\n    if ((bitmap_entry >> (pageentry_index % 8)) & 1)\n\n\treturn -1; \/\/ not allocated\n\n#endif\n\n#endif\n\n\n\n    return block_offset;\n\n}\n","target":1,"code_token_length":634,"total_token_length":870,"max_tokens_setting":1024}
+{"idx":149584,"func":"_Pickler_Write(PicklerObject *self, const char *s, Py_ssize_t data_len)\n{\n    Py_ssize_t i, n, required;\n    char *buffer;\n    int need_new_frame;\n\n    assert(s != NULL);\n    need_new_frame = (self->framing && self->frame_start == -1);\n\n    if (need_new_frame)\n        n = data_len + FRAME_HEADER_SIZE;\n    else\n        n = data_len;\n\n    required = self->output_len + n;\n    if (required > self->max_output_len) {\n        \/* Make place in buffer for the pickle chunk *\/\n        if (self->output_len >= PY_SSIZE_T_MAX \/ 2 - n) {\n            PyErr_NoMemory();\n            return -1;\n        }\n        self->max_output_len = (self->output_len + n) \/ 2 * 3;\n        if (_PyBytes_Resize(&self->output_buffer, self->max_output_len) < 0)\n            return -1;\n    }\n    buffer = PyBytes_AS_STRING(self->output_buffer);\n    if (need_new_frame) {\n        \/* Setup new frame *\/\n        Py_ssize_t frame_start = self->output_len;\n        self->frame_start = frame_start;\n        for (i = 0; i < FRAME_HEADER_SIZE; i++) {\n            \/* Write an invalid value, for debugging *\/\n            buffer[frame_start + i] = 0xFE;\n        }\n        self->output_len += FRAME_HEADER_SIZE;\n    }\n    if (data_len < 8) {\n        \/* This is faster than memcpy when the string is short. *\/\n        for (i = 0; i < data_len; i++) {\n            buffer[self->output_len + i] = s[i];\n        }\n    }\n    else {\n        memcpy(buffer + self->output_len, s, data_len);\n    }\n    self->output_len += data_len;\n    return data_len;\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":32921,"func":"char *charset_client2fs(const char * const string)\n{\n    char *output = NULL, *output_;\n    size_t inlen, outlen, outlen_;\n    \n    inlen = strlen(string);\n    outlen_ = outlen = inlen * (size_t) 4U + (size_t) 1U;\n    if (outlen <= inlen ||\n        (output_ = output = calloc(outlen, (size_t) 1U)) == NULL) {\n        die_mem();\n    }\n    if (utf8 > 0 && strcasecmp(charset_fs, \"utf-8\") != 0) {\n        if (iconv(iconv_fd_utf82fs, (char **) &string,\n                  &inlen, &output_, &outlen_) == (size_t) -1) {\n            strncpy(output, string, outlen);\n        }\n    } else if (utf8 <= 0 && strcasecmp(charset_fs, charset_client) != 0) {\n        if (iconv(iconv_fd_client2fs, (char **) &string,\n                  &inlen, &output_, &outlen_) == (size_t) -1) {\n            strncpy(output, string, outlen);\n        }\n    } else {\n        strncpy(output, string, outlen);\n    }\n    output[outlen - 1] = 0;    \n    \n    return output;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":516438,"func":"static int test_gf2m_modinv(void)\n{\n    BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;\n    int i, j, st = 0;\n\n    if (!TEST_ptr(a = BN_new())\n            || !TEST_ptr(b[0] = BN_new())\n            || !TEST_ptr(b[1] = BN_new())\n            || !TEST_ptr(c = BN_new())\n            || !TEST_ptr(d = BN_new()))\n        goto err;\n\n    if (!(TEST_true(BN_GF2m_arr2poly(p0, b[0]))\n            && TEST_true(BN_GF2m_arr2poly(p1, b[1]))))\n        goto err;\n\n    for (i = 0; i < NUM0; i++) {\n        if (!TEST_true(BN_bntest_rand(a, 512, 0, 0)))\n            goto err;\n        for (j = 0; j < 2; j++) {\n            if (!(TEST_true(BN_GF2m_mod_inv(c, a, b[j], ctx))\n                    && TEST_true(BN_GF2m_mod_mul(d, a, c, b[j], ctx))\n                    \/* Test that ((1\/a)*a) = 1. *\/\n                    && TEST_BN_eq_one(d)))\n                goto err;\n        }\n    }\n    st = 1;\n err:\n    BN_free(a);\n    BN_free(b[0]);\n    BN_free(b[1]);\n    BN_free(c);\n    BN_free(d);\n    return st;\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":176433,"func":"static void monitor_worker_process(int child_pid, const debugger_request_t& request) {\n struct timespec timeout = {.tv_sec = 10, .tv_nsec = 0 };\n if (should_attach_gdb(request)) {\n    timeout.tv_sec = INT_MAX;\n }\n\n sigset_t signal_set;\n  sigemptyset(&signal_set);\n  sigaddset(&signal_set, SIGCHLD);\n\n bool kill_worker = false;\n bool kill_target = false;\n bool kill_self = false;\n\n int status;\n siginfo_t siginfo;\n int signal = TEMP_FAILURE_RETRY(sigtimedwait(&signal_set, &siginfo, &timeout));\n if (signal == SIGCHLD) {\n pid_t rc = waitpid(-1, &status, WNOHANG | WUNTRACED);\n if (rc != child_pid) {\n      ALOGE(\"debuggerd: waitpid returned unexpected pid (%d), committing murder-suicide\", rc);\n\n if (WIFEXITED(status)) {\n        ALOGW(\"debuggerd: pid %d exited with status %d\", rc, WEXITSTATUS(status));\n } else if (WIFSIGNALED(status)) {\n        ALOGW(\"debuggerd: pid %d received signal %d\", rc, WTERMSIG(status));\n } else if (WIFSTOPPED(status)) {\n        ALOGW(\"debuggerd: pid %d stopped by signal %d\", rc, WSTOPSIG(status));\n } else if (WIFCONTINUED(status)) {\n        ALOGW(\"debuggerd: pid %d continued\", rc);\n }\n\n      kill_worker = true;\n      kill_target = true;\n      kill_self = true;\n } else if (WIFSIGNALED(status)) {\n      ALOGE(\"debuggerd: worker process %d terminated due to signal %d\", child_pid, WTERMSIG(status));\n      kill_worker = false;\n      kill_target = true;\n } else if (WIFSTOPPED(status)) {\n      ALOGE(\"debuggerd: worker process %d stopped due to signal %d\", child_pid, WSTOPSIG(status));\n      kill_worker = true;\n      kill_target = true;\n }\n } else {\n    ALOGE(\"debuggerd: worker process %d timed out\", child_pid);\n    kill_worker = true;\n    kill_target = true;\n }\n\n if (kill_worker) {\n if (kill(child_pid, SIGKILL) != 0) {\n      ALOGE(\"debuggerd: failed to kill worker process %d: %s\", child_pid, strerror(errno));\n } else {\n      waitpid(child_pid, &status, 0);\n }\n }\n\n int exit_signal = SIGCONT;\n if (kill_target && request.action == DEBUGGER_ACTION_CRASH) {\n    ALOGE(\"debuggerd: killing target %d\", request.pid);\n    exit_signal = SIGKILL;\n } else {\n    ALOGW(\"debuggerd: resuming target %d\", request.pid);\n }\n\n if (kill(request.pid, exit_signal) != 0) {\n    ALOGE(\"debuggerd: failed to send signal %d to target: %s\", exit_signal, strerror(errno));\n }\n\n if (kill_self) {\n    stop_signal_sender();\n    _exit(1);\n }\n}\n","target":0,"code_token_length":670,"total_token_length":906,"max_tokens_setting":1024}
+{"idx":50669,"func":"encode_attr_2(\n    Slapi_PBlock *pb,\n    BerElement *ber,\n    Slapi_Entry *e,\n    Slapi_ValueSet *vs,\n    int attrsonly,\n    const char *attribute_type,\n    const char *returned_type)\n{\n\n    char *attrs[2] = {NULL, NULL};\n    Slapi_Value *v;\n    int i = slapi_valueset_first_value(vs, &v);\n\n    if (i == -1) {\n        return (0);\n    }\n\n    attrs[0] = (char *)attribute_type;\n\n#if !defined(DISABLE_ACL_CHECK)\n    if (plugin_call_acl_plugin(pb, e, attrs, NULL, SLAPI_ACL_READ,\n                               ACLPLUGIN_ACCESS_READ_ON_ATTR, NULL) != LDAP_SUCCESS) {\n        return (0);\n    }\n#endif\n\n    if (ber_printf(ber, \"{s[\", returned_type ? returned_type : attribute_type) == -1) {\n        slapi_log_err(SLAPI_LOG_ERR, \"encode_attr_2\", \"ber_printf failed 4\\n\");\n        ber_free(ber, 1);\n        send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,\n                         \"ber_printf type\", 0, NULL);\n        return (-1);\n    }\n\n    if (!attrsonly) {\n        while (i != -1) {\n            if (ber_printf(ber, \"o\", v->bv.bv_val, v->bv.bv_len) == -1) {\n                slapi_log_err(SLAPI_LOG_ERR,\n                              \"encode_attr_2\", \"ber_printf failed 5\\n\");\n                ber_free(ber, 1);\n                send_ldap_result(pb, LDAP_OPERATIONS_ERROR,\n                                 NULL, \"ber_printf value\", 0, NULL);\n                return (-1);\n            }\n            i = slapi_valueset_next_value(vs, i, &v);\n        }\n    }\n\n    if (ber_printf(ber, \"]}\") == -1) {\n        slapi_log_err(SLAPI_LOG_ERR, \"encode_attr_2\", \"ber_printf failed 6\\n\");\n        ber_free(ber, 1);\n        send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,\n                         \"ber_printf type end\", 0, NULL);\n        return (-1);\n    }\n\n    return (0);\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":99531,"func":"MagickExport MagickBooleanType GetMultilineTypeMetrics(Image *image,\n  const DrawInfo *draw_info,TypeMetric *metrics)\n{\n  char\n    **textlist;\n\n  DrawInfo\n    *annotate_info;\n\n  MagickBooleanType\n    status;\n\n  register ssize_t\n    i;\n\n  TypeMetric\n    extent;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(draw_info != (DrawInfo *) NULL);\n  assert(draw_info->text != (char *) NULL);\n  assert(draw_info->signature == MagickCoreSignature);\n  if (*draw_info->text == '\\0')\n    return(MagickFalse);\n  annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);\n  annotate_info->text=DestroyString(annotate_info->text);\n  \/*\n    Convert newlines to multiple lines of text.\n  *\/\n  textlist=StringToList(draw_info->text);\n  if (textlist == (char **) NULL)\n    return(MagickFalse);\n  annotate_info->render=MagickFalse;\n  annotate_info->direction=UndefinedDirection;\n  (void) memset(metrics,0,sizeof(*metrics));\n  (void) memset(&extent,0,sizeof(extent));\n  \/*\n    Find the widest of the text lines.\n  *\/\n  annotate_info->text=textlist[0];\n  status=GetTypeMetrics(image,annotate_info,&extent);\n  *metrics=extent;\n  for (i=1; textlist[i] != (char *) NULL; i++)\n  {\n    annotate_info->text=textlist[i];\n    status=GetTypeMetrics(image,annotate_info,&extent);\n    if (extent.width > metrics->width)\n      *metrics=extent;\n  }\n  metrics->height=(double) (i*(size_t) (metrics->ascent-metrics->descent+0.5)+\n    (i-1)*draw_info->interline_spacing);\n  \/*\n    Relinquish resources.\n  *\/\n  annotate_info->text=(char *) NULL;\n  annotate_info=DestroyDrawInfo(annotate_info);\n  for (i=0; textlist[i] != (char *) NULL; i++)\n    textlist[i]=DestroyString(textlist[i]);\n  textlist=(char **) RelinquishMagickMemory(textlist);\n  return(status);\n}","target":0,"code_token_length":514,"total_token_length":750,"max_tokens_setting":1024}
+{"idx":196384,"func":"MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)\n{\n    int al;\n    unsigned int ticklen;\n    unsigned long ticket_lifetime_hint;\n\n    if (!PACKET_get_net_4(pkt, &ticket_lifetime_hint)\n        || !PACKET_get_net_2(pkt, &ticklen)\n        || PACKET_remaining(pkt) != ticklen) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n\n    \/* Server is allowed to change its mind and send an empty ticket. *\/\n    if (ticklen == 0)\n        return MSG_PROCESS_CONTINUE_READING;\n\n    if (s->session->session_id_length > 0) {\n        int i = s->session_ctx->session_cache_mode;\n        SSL_SESSION *new_sess;\n        \/*\n         * We reused an existing session, so we need to replace it with a new\n         * one\n         *\/\n        if (i & SSL_SESS_CACHE_CLIENT) {\n            \/*\n             * Remove the old session from the cache. We carry on if this fails\n             *\/\n            SSL_CTX_remove_session(s->session_ctx, s->session);\n        }\n\n        if ((new_sess = ssl_session_dup(s->session, 0)) == 0) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE);\n            goto f_err;\n        }\n\n        SSL_SESSION_free(s->session);\n        s->session = new_sess;\n    }\n\n    OPENSSL_free(s->session->tlsext_tick);\n    s->session->tlsext_ticklen = 0;\n\n    s->session->tlsext_tick = OPENSSL_malloc(ticklen);\n    if (s->session->tlsext_tick == NULL) {\n        SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!PACKET_copy_bytes(pkt, s->session->tlsext_tick, ticklen)) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n\n    s->session->tlsext_tick_lifetime_hint = ticket_lifetime_hint;\n    s->session->tlsext_ticklen = ticklen;\n    \/*\n     * There are two ways to detect a resumed ticket session. One is to set\n     * an appropriate session ID and then the server must return a match in\n     * ServerHello. This allows the normal client session ID matching to work\n     * and we know much earlier that the ticket has been accepted. The\n     * other way is to set zero length session ID when the ticket is\n     * presented and rely on the handshake to determine session resumption.\n     * We choose the former approach because this fits in with assumptions\n     * elsewhere in OpenSSL. The session ID is set to the SHA256 (or SHA1 is\n     * SHA256 is disabled) hash of the ticket.\n     *\/\n    if (!EVP_Digest(s->session->tlsext_tick, ticklen,\n                    s->session->session_id, &s->session->session_id_length,\n                    EVP_sha256(), NULL)) {\n        SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_EVP_LIB);\n        goto err;\n    }\n    return MSG_PROCESS_CONTINUE_READING;\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    ossl_statem_set_error(s);\n    return MSG_PROCESS_ERROR;\n}\n","target":0,"code_token_length":762,"total_token_length":998,"max_tokens_setting":1024}
+{"idx":54284,"func":"WC_INLINE static int fp_mul_comba_mulx(fp_int *A, fp_int *B, fp_int *C)\n\n{\n   int       ix, iy, iz, pa;\n   fp_int    *dst;\n#ifndef WOLFSSL_SMALL_STACK\n   fp_int    tmp[1];\n#else\n   fp_int    *tmp;\n#endif\n \n   \/* Variables used but not seen by cppcheck. *\/\n   (void)ix; (void)iy; (void)iz;\n\n#ifdef WOLFSSL_SMALL_STACK\n   tmp = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT);\n   if (tmp == NULL)\n       return FP_MEM;\n#endif\n\n   \/* get size of output and trim *\/\n   pa = A->used + B->used;\n   if (pa >= FP_SIZE) {\n      pa = FP_SIZE-1;\n   }\n\n   \/* Always take branch to use tmp variable. This avoids a cache attack for\n    * determining if C equals A *\/\n   if (1) {\n      fp_init(tmp);\n      dst = tmp;\n   }\n\n   TFM_INTEL_MUL_COMBA(A, B, dst) ;\n\n  dst->used = pa;\n  dst->sign = A->sign ^ B->sign;\n  fp_clamp(dst);\n  fp_copy(dst, C);\n\n#ifdef WOLFSSL_SMALL_STACK\n  XFREE(tmp, NULL, DYNAMIC_TYPE_BIGINT);\n#endif\n\n  return FP_OKAY;\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":4429,"func":"int imap_exec(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags)\n{\n  int rc;\n\n  rc = cmd_start(adata, cmdstr, flags);\n  if (rc < 0)\n  {\n    cmd_handle_fatal(adata);\n    return IMAP_EXEC_FATAL;\n  }\n\n  if (flags & IMAP_CMD_QUEUE)\n    return IMAP_EXEC_SUCCESS;\n\n  if ((flags & IMAP_CMD_POLL) && (C_ImapPollTimeout > 0) &&\n      ((mutt_socket_poll(adata->conn, C_ImapPollTimeout)) == 0))\n  {\n    mutt_error(_(\"Connection to %s timed out\"), adata->conn->account.host);\n    cmd_handle_fatal(adata);\n    return IMAP_EXEC_FATAL;\n  }\n\n  \/* Allow interruptions, particularly useful if there are network problems. *\/\n  mutt_sig_allow_interrupt(true);\n  do\n  {\n    rc = imap_cmd_step(adata);\n  } while (rc == IMAP_RES_CONTINUE);\n  mutt_sig_allow_interrupt(false);\n\n  if (rc == IMAP_RES_NO)\n    return IMAP_EXEC_ERROR;\n  if (rc != IMAP_RES_OK)\n  {\n    if (adata->status != IMAP_FATAL)\n      return IMAP_EXEC_ERROR;\n\n    mutt_debug(LL_DEBUG1, \"command failed: %s\\n\", adata->buf);\n    return IMAP_EXEC_FATAL;\n  }\n\n  return IMAP_EXEC_SUCCESS;\n}","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":252552,"func":"status_t BnSoundTriggerHwService::onTransact(\n uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)\n{\n switch(code) {\n\n         case LIST_MODULES: {\n             CHECK_INTERFACE(ISoundTriggerHwService, data, reply);\n             unsigned int numModulesReq = data.readInt32();\n            if (numModulesReq > MAX_ITEMS_PER_LIST) {\n                numModulesReq = MAX_ITEMS_PER_LIST;\n            }\n             unsigned int numModules = numModulesReq;\n             struct sound_trigger_module_descriptor *modules =\n                     (struct sound_trigger_module_descriptor *)calloc(numModulesReq,\n                                                    sizeof(struct sound_trigger_module_descriptor));\n            if (modules == NULL) {\n                reply->writeInt32(NO_MEMORY);\n                reply->writeInt32(0);\n                return NO_ERROR;\n            }\n             status_t status = listModules(modules, &numModules);\n             reply->writeInt32(status);\n             reply->writeInt32(numModules);\n            ALOGV(\"LIST_MODULES status %d got numModules %d\", status, numModules);\n\n if (status == NO_ERROR) {\n if (numModulesReq > numModules) {\n                    numModulesReq = numModules;\n }\n                reply->write(modules,\n                             numModulesReq * sizeof(struct sound_trigger_module_descriptor));\n }\n            free(modules);\n return NO_ERROR;\n }\n\n case ATTACH: {\n            CHECK_INTERFACE(ISoundTriggerHwService, data, reply);\n sound_trigger_module_handle_t handle;\n            data.read(&handle, sizeof(sound_trigger_module_handle_t));\n            sp<ISoundTriggerClient> client =\n                    interface_cast<ISoundTriggerClient>(data.readStrongBinder());\n            sp<ISoundTrigger> module;\n status_t status = attach(handle, client, module);\n            reply->writeInt32(status);\n if (module != 0) {\n                reply->writeInt32(1);\n                reply->writeStrongBinder(IInterface::asBinder(module));\n } else {\n                reply->writeInt32(0);\n }\n return NO_ERROR;\n } break;\n\n case SET_CAPTURE_STATE: {\n            CHECK_INTERFACE(ISoundTriggerHwService, data, reply);\n            reply->writeInt32(setCaptureState((bool)data.readInt32()));\n return NO_ERROR;\n } break;\n\n default:\n return BBinder::onTransact(code, data, reply, flags);\n }\n}\n","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":157741,"func":"lldpd_get_lsb_release() {\n\tstatic char release[1024];\n\tchar *const command[] = { \"lsb_release\", \"-s\", \"-d\", NULL };\n\tint pid, status, devnull, count;\n\tint pipefd[2];\n\n\tlog_debug(\"localchassis\", \"grab LSB release\");\n\n\tif (pipe(pipefd)) {\n\t\tlog_warn(\"localchassis\", \"unable to get a pair of pipes\");\n\t\treturn NULL;\n\t}\n\n\tpid = vfork();\n\tswitch (pid) {\n\tcase -1:\n\t\tlog_warn(\"localchassis\", \"unable to fork\");\n\t\treturn NULL;\n\tcase 0:\n\t\t\/* Child, exec lsb_release *\/\n\t\tclose(pipefd[0]);\n\t\tif ((devnull = open(\"\/dev\/null\", O_RDWR, 0)) != -1) {\n\t\t\tdup2(devnull, STDIN_FILENO);\n\t\t\tdup2(devnull, STDERR_FILENO);\n\t\t\tdup2(pipefd[1], STDOUT_FILENO);\n\t\t\tif (devnull > 2) close(devnull);\n\t\t\tif (pipefd[1] > 2) close(pipefd[1]);\n\t\t\texecvp(\"lsb_release\", command);\n\t\t}\n\t\t_exit(127);\n\t\tbreak;\n\tdefault:\n\t\t\/* Father, read the output from the children *\/\n\t\tclose(pipefd[1]);\n\t\tcount = 0;\n\t\tdo {\n\t\t\tstatus = read(pipefd[0], release+count, sizeof(release)-count);\n\t\t\tif ((status == -1) && (errno == EINTR)) continue;\n\t\t\tif (status > 0)\n\t\t\t\tcount += status;\n\t\t} while (count < sizeof(release) && (status > 0));\n\t\tif (status < 0) {\n\t\t\tlog_info(\"localchassis\", \"unable to read from lsb_release\");\n\t\t\tclose(pipefd[0]);\n\t\t\twaitpid(pid, &status, 0);\n\t\t\treturn NULL;\n\t\t}\n\t\tclose(pipefd[0]);\n\t\tif (count >= sizeof(release)) {\n\t\t\tlog_info(\"localchassis\", \"output of lsb_release is too large\");\n\t\t\twaitpid(pid, &status, 0);\n\t\t\treturn NULL;\n\t\t}\n\t\tstatus = -1;\n\t\tif (waitpid(pid, &status, 0) != pid)\n\t\t\treturn NULL;\n\t\tif (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {\n\t\t\tlog_info(\"localchassis\", \"lsb_release information not available\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (!count) {\n\t\t\tlog_info(\"localchassis\", \"lsb_release returned an empty string\");\n\t\t\treturn NULL;\n\t\t}\n\t\trelease[count] = '\\0';\n\t\treturn release;\n\t}\n\t\/* Should not be here *\/\n\treturn NULL;\n}","target":0,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":270237,"func":"void rds_conn_shutdown(struct rds_connection *conn)\n{\n\t\/* shut it down unless it's down already *\/\n\tif (!rds_conn_transition(conn, RDS_CONN_DOWN, RDS_CONN_DOWN)) {\n\t\t\/*\n\t\t * Quiesce the connection mgmt handlers before we start tearing\n\t\t * things down. We don't hold the mutex for the entire\n\t\t * duration of the shutdown operation, else we may be\n\t\t * deadlocking with the CM handler. Instead, the CM event\n\t\t * handler is supposed to check for state DISCONNECTING\n\t\t *\/\n\t\tmutex_lock(&conn->c_cm_lock);\n\t\tif (!rds_conn_transition(conn, RDS_CONN_UP, RDS_CONN_DISCONNECTING)\n\t\t && !rds_conn_transition(conn, RDS_CONN_ERROR, RDS_CONN_DISCONNECTING)) {\n\t\t\trds_conn_error(conn, \"shutdown called in state %d\\n\",\n\t\t\t\t\tatomic_read(&conn->c_state));\n\t\t\tmutex_unlock(&conn->c_cm_lock);\n\t\t\treturn;\n\t\t}\n\t\tmutex_unlock(&conn->c_cm_lock);\n\n\t\twait_event(conn->c_waitq,\n\t\t\t   !test_bit(RDS_IN_XMIT, &conn->c_flags));\n\t\twait_event(conn->c_waitq,\n\t\t\t   !test_bit(RDS_RECV_REFILL, &conn->c_flags));\n\n\t\tconn->c_trans->conn_shutdown(conn);\n\t\trds_conn_reset(conn);\n\n\t\tif (!rds_conn_transition(conn, RDS_CONN_DISCONNECTING, RDS_CONN_DOWN)) {\n\t\t\t\/* This can happen - eg when we're in the middle of tearing\n\t\t\t * down the connection, and someone unloads the rds module.\n\t\t\t * Quite reproduceable with loopback connections.\n\t\t\t * Mostly harmless.\n\t\t\t *\/\n\t\t\trds_conn_error(conn,\n\t\t\t\t\"%s: failed to transition to state DOWN, \"\n\t\t\t\t\"current state is %d\\n\",\n\t\t\t\t__func__,\n\t\t\t\tatomic_read(&conn->c_state));\n\t\t\treturn;\n\t\t}\n\t}\n\n\t\/* Then reconnect if it's still live.\n\t * The passive side of an IB loopback connection is never added\n\t * to the conn hash, so we never trigger a reconnect on this\n\t * conn - the reconnect is always triggered by the active peer. *\/\n\tcancel_delayed_work_sync(&conn->c_conn_w);\n\trcu_read_lock();\n\tif (!hlist_unhashed(&conn->c_hash_node)) {\n\t\trcu_read_unlock();\n\t\trds_queue_reconnect(conn);\n\t} else {\n\t\trcu_read_unlock();\n\t}\n}","target":0,"code_token_length":524,"total_token_length":760,"max_tokens_setting":1024}
+{"idx":472024,"func":"stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)\n{\n   unsigned int temp;\n   int c,k;\n\n   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);\n\n   \/\/ look at the top FAST_BITS and determine what symbol ID it is,\n   \/\/ if the code is <= FAST_BITS\n   c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);\n   k = h->fast[c];\n   if (k < 255) {\n      int s = h->size[k];\n      if (s > j->code_bits)\n         return -1;\n      j->code_buffer <<= s;\n      j->code_bits -= s;\n      return h->values[k];\n   }\n\n   \/\/ naive test is to shift the code_buffer down so k bits are\n   \/\/ valid, then test against maxcode. To speed this up, we've\n   \/\/ preshifted maxcode left so that it has (16-k) 0s at the\n   \/\/ end; in other words, regardless of the number of bits, it\n   \/\/ wants to be compared against something shifted to have 16;\n   \/\/ that way we don't need to shift inside the loop.\n   temp = j->code_buffer >> 16;\n   for (k=FAST_BITS+1 ; ; ++k)\n      if (temp < h->maxcode[k])\n         break;\n   if (k == 17) {\n      \/\/ error! code not found\n      j->code_bits -= 16;\n      return -1;\n   }\n\n   if (k > j->code_bits)\n      return -1;\n\n   \/\/ convert the huffman code to the symbol id\n   c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];\n   STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);\n\n   \/\/ convert the id to a symbol\n   j->code_bits -= k;\n   j->code_buffer <<= k;\n   return h->values[c];\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":270590,"func":"int cil_gen_ibpkeycon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)\n{\n\tenum cil_syntax syntax[] = {\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_STRING | CIL_SYN_LIST,\n\t\tCIL_SYN_STRING | CIL_SYN_LIST,\n\t\tCIL_SYN_END\n\t};\n\tint syntax_len = sizeof(syntax) \/ sizeof(*syntax);\n\tint rc = SEPOL_ERR;\n\tstruct cil_ibpkeycon *ibpkeycon = NULL;\n\n\tif (!parse_current || !ast_node)\n\t\tgoto exit;\n\n\trc = __cil_verify_syntax(parse_current, syntax, syntax_len);\n\tif (rc != SEPOL_OK)\n\t\tgoto exit;\n\n\tcil_ibpkeycon_init(&ibpkeycon);\n\n\tibpkeycon->subnet_prefix_str = parse_current->next->data;\n\n\tif (parse_current->next->next->cl_head) {\n\t\tif (parse_current->next->next->cl_head->next &&\n\t\t    !parse_current->next->next->cl_head->next->next) {\n\t\t\trc = cil_fill_integer(parse_current->next->next->cl_head, &ibpkeycon->pkey_low, 0);\n\t\t\tif (rc != SEPOL_OK) {\n\t\t\t\tcil_log(CIL_ERR, \"Improper ibpkey specified\\n\");\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t\trc = cil_fill_integer(parse_current->next->next->cl_head->next, &ibpkeycon->pkey_high, 0);\n\t\t\tif (rc != SEPOL_OK) {\n\t\t\t\tcil_log(CIL_ERR, \"Improper ibpkey specified\\n\");\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t} else {\n\t\t\tcil_log(CIL_ERR, \"Improper ibpkey range specified\\n\");\n\t\t\trc = SEPOL_ERR;\n\t\t\tgoto exit;\n\t\t}\n\t} else {\n\t\trc = cil_fill_integer(parse_current->next->next, &ibpkeycon->pkey_low, 0);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tcil_log(CIL_ERR, \"Improper ibpkey specified\\n\");\n\t\t\tgoto exit;\n\t\t}\n\t\tibpkeycon->pkey_high = ibpkeycon->pkey_low;\n\t}\n\n\tif (!parse_current->next->next->next->cl_head) {\n\t\tibpkeycon->context_str = parse_current->next->next->next->data;\n\t} else {\n\t\tcil_context_init(&ibpkeycon->context);\n\n\t\trc = cil_fill_context(parse_current->next->next->next->cl_head, ibpkeycon->context);\n\t\tif (rc != SEPOL_OK)\n\t\t\tgoto exit;\n\t}\n\n\tast_node->data = ibpkeycon;\n\tast_node->flavor = CIL_IBPKEYCON;\n\treturn SEPOL_OK;\n\nexit:\n\tcil_tree_log(parse_current, CIL_ERR, \"Bad ibpkeycon declaration\");\n\tcil_destroy_ibpkeycon(ibpkeycon);\n\n\treturn rc;\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":3765,"func":"SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)\n{\n\tint ufd;\n\tstruct timerfd_ctx *ctx;\n\n\t\/* Check the TFD_* constants for consistency.  *\/\n\tBUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);\n\tBUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK);\n\n\tif ((flags & ~TFD_CREATE_FLAGS) ||\n\t    (clockid != CLOCK_MONOTONIC &&\n\t     clockid != CLOCK_REALTIME &&\n\t     clockid != CLOCK_REALTIME_ALARM &&\n\t     clockid != CLOCK_BOOTTIME &&\n\t     clockid != CLOCK_BOOTTIME_ALARM))\n\t\treturn -EINVAL;\n\n\tif (!capable(CAP_WAKE_ALARM) &&\n\t    (clockid == CLOCK_REALTIME_ALARM ||\n\t     clockid == CLOCK_BOOTTIME_ALARM))\n\t\treturn -EPERM;\n\n\tctx = kzalloc(sizeof(*ctx), GFP_KERNEL);\n\tif (!ctx)\n\t\treturn -ENOMEM;\n\n\tinit_waitqueue_head(&ctx->wqh);\n\tctx->clockid = clockid;\n\n\tif (isalarm(ctx))\n\t\talarm_init(&ctx->t.alarm,\n\t\t\t   ctx->clockid == CLOCK_REALTIME_ALARM ?\n\t\t\t   ALARM_REALTIME : ALARM_BOOTTIME,\n\t\t\t   timerfd_alarmproc);\n\telse\n\t\thrtimer_init(&ctx->t.tmr, clockid, HRTIMER_MODE_ABS);\n\n\tctx->moffs = ktime_mono_to_real(0);\n\n\tufd = anon_inode_getfd(\"[timerfd]\", &timerfd_fops, ctx,\n\t\t\t       O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));\n\tif (ufd < 0)\n\t\tkfree(ctx);\n\n\treturn ufd;\n}","target":1,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":486493,"func":"static void v9fs_getattr(void *opaque)\n{\n    int32_t fid;\n    size_t offset = 7;\n    ssize_t retval = 0;\n    struct stat stbuf;\n    V9fsFidState *fidp;\n    uint64_t request_mask;\n    V9fsStatDotl v9stat_dotl;\n    V9fsPDU *pdu = opaque;\n    V9fsState *s = pdu->s;\n\n    retval = pdu_unmarshal(pdu, offset, \"dq\", &fid, &request_mask);\n    if (retval < 0) {\n        goto out_nofid;\n    }\n    trace_v9fs_getattr(pdu->tag, pdu->id, fid, request_mask);\n\n    fidp = get_fid(pdu, fid);\n    if (fidp == NULL) {\n        retval = -ENOENT;\n        goto out_nofid;\n    }\n    \/*\n     * Currently we only support BASIC fields in stat, so there is no\n     * need to look at request_mask.\n     *\/\n    retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf);\n    if (retval < 0) {\n        goto out;\n    }\n    stat_to_v9stat_dotl(s, &stbuf, &v9stat_dotl);\n\n    \/*  fill st_gen if requested and supported by underlying fs *\/\n    if (request_mask & P9_STATS_GEN) {\n        retval = v9fs_co_st_gen(pdu, &fidp->path, stbuf.st_mode, &v9stat_dotl);\n        switch (retval) {\n        case 0:\n            \/* we have valid st_gen: update result mask *\/\n            v9stat_dotl.st_result_mask |= P9_STATS_GEN;\n            break;\n        case -EINTR:\n            \/* request cancelled, e.g. by Tflush *\/\n            goto out;\n        default:\n            \/* failed to get st_gen: not fatal, ignore *\/\n            break;\n        }\n    }\n    retval = pdu_marshal(pdu, offset, \"A\", &v9stat_dotl);\n    if (retval < 0) {\n        goto out;\n    }\n    retval += offset;\n    trace_v9fs_getattr_return(pdu->tag, pdu->id, v9stat_dotl.st_result_mask,\n                              v9stat_dotl.st_mode, v9stat_dotl.st_uid,\n                              v9stat_dotl.st_gid);\nout:\n    put_fid(pdu, fidp);\nout_nofid:\n    pdu_complete(pdu, retval);\n}","target":0,"code_token_length":540,"total_token_length":776,"max_tokens_setting":1024}
+{"idx":426944,"func":"adv_error adv_png_read_iend(adv_fz* f, const unsigned char* data, unsigned data_size, unsigned type)\n{\n\tif (type == ADV_PNG_CN_IEND)\n\t\treturn 0;\n\n\t\/* ancillary bit. bit 5 of first byte. 0 (uppercase) = critical, 1 (lowercase) = ancillary. *\/\n\tif ((type & 0x20000000) == 0) {\n\t\tchar buf[4];\n\t\tbe_uint32_write(buf, type);\n\t\terror_unsupported_set(\"Unsupported critical chunk '%c%c%c%c'\", buf[0], buf[1], buf[2], buf[3]);\n\t\treturn -1;\n\t}\n\n\twhile (1) {\n\t\tunsigned char* ptr;\n\t\tunsigned ptr_size;\n\n\t\t\/* read next *\/\n\t\tif (adv_png_read_chunk(f, &ptr, &ptr_size, &type) != 0) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tfree(ptr);\n\n\t\tif (type == ADV_PNG_CN_IEND)\n\t\t\tbreak;\n\n\t\t\/* ancillary bit. bit 5 of first byte. 0 (uppercase) = critical, 1 (lowercase) = ancillary. *\/\n\t\tif ((type & 0x20000000) == 0) {\n\t\t\tchar buf[4];\n\t\t\tbe_uint32_write(buf, type);\n\t\t\terror_unsupported_set(\"Unsupported critical chunk '%c%c%c%c'\", buf[0], buf[1], buf[2], buf[3]);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":48220,"func":"static int tipc_getsockopt(struct socket *sock, int lvl, int opt,\n\t\t\t   char __user *ov, int __user *ol)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct tipc_service_range seq;\n\tint len, scope;\n\tu32 value;\n\tint res;\n\n\tif ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))\n\t\treturn put_user(0, ol);\n\tif (lvl != SOL_TIPC)\n\t\treturn -ENOPROTOOPT;\n\tres = get_user(len, ol);\n\tif (res)\n\t\treturn res;\n\n\tlock_sock(sk);\n\n\tswitch (opt) {\n\tcase TIPC_IMPORTANCE:\n\t\tvalue = tsk_importance(tsk);\n\t\tbreak;\n\tcase TIPC_SRC_DROPPABLE:\n\t\tvalue = tsk_unreliable(tsk);\n\t\tbreak;\n\tcase TIPC_DEST_DROPPABLE:\n\t\tvalue = tsk_unreturnable(tsk);\n\t\tbreak;\n\tcase TIPC_CONN_TIMEOUT:\n\t\tvalue = tsk->conn_timeout;\n\t\t\/* no need to set \"res\", since already 0 at this point *\/\n\t\tbreak;\n\tcase TIPC_NODE_RECVQ_DEPTH:\n\t\tvalue = 0; \/* was tipc_queue_size, now obsolete *\/\n\t\tbreak;\n\tcase TIPC_SOCK_RECVQ_DEPTH:\n\t\tvalue = skb_queue_len(&sk->sk_receive_queue);\n\t\tbreak;\n\tcase TIPC_SOCK_RECVQ_USED:\n\t\tvalue = sk_rmem_alloc_get(sk);\n\t\tbreak;\n\tcase TIPC_GROUP_JOIN:\n\t\tseq.type = 0;\n\t\tif (tsk->group)\n\t\t\ttipc_group_self(tsk->group, &seq, &scope);\n\t\tvalue = seq.type;\n\t\tbreak;\n\tdefault:\n\t\tres = -EINVAL;\n\t}\n\n\trelease_sock(sk);\n\n\tif (res)\n\t\treturn res;\t\/* \"get\" failed *\/\n\n\tif (len < sizeof(value))\n\t\treturn -EINVAL;\n\n\tif (copy_to_user(ov, &value, sizeof(value)))\n\t\treturn -EFAULT;\n\n\treturn put_user(sizeof(value), ol);\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":258230,"func":"static int tunnel_dns ( int tun_fd , int dns_fd , int bind_fd ) {\n struct query q ;\n int read ;\n int domain_len ;\n int inside_topdomain = 0 ;\n if ( ( read = read_dns ( dns_fd , tun_fd , & q ) ) <= 0 ) return 0 ;\n if ( debug >= 2 ) {\n fprintf ( stderr , \"RX: client %s, type %d, name %s\\n\" , format_addr ( & q . from , q . fromlen ) , q . type , q . name ) ;\n }\n domain_len = strlen ( q . name ) - strlen ( topdomain ) ;\n if ( domain_len >= 0 && ! strcasecmp ( q . name + domain_len , topdomain ) ) inside_topdomain = 1 ;\n if ( domain_len >= 1 && q . name [ domain_len - 1 ] != '.' ) inside_topdomain = 0 ;\n if ( inside_topdomain ) {\n if ( domain_len == 3 && q . type == T_A && ( q . name [ 0 ] == 'n' || q . name [ 0 ] == 'N' ) && ( q . name [ 1 ] == 's' || q . name [ 1 ] == 'S' ) && q . name [ 2 ] == '.' ) {\n handle_a_request ( dns_fd , & q , 0 ) ;\n return 0 ;\n }\n if ( domain_len == 4 && q . type == T_A && ( q . name [ 0 ] == 'w' || q . name [ 0 ] == 'W' ) && ( q . name [ 1 ] == 'w' || q . name [ 1 ] == 'W' ) && ( q . name [ 2 ] == 'w' || q . name [ 2 ] == 'W' ) && q . name [ 3 ] == '.' ) {\n handle_a_request ( dns_fd , & q , 1 ) ;\n return 0 ;\n }\n switch ( q . type ) {\n case T_NULL : case T_PRIVATE : case T_CNAME : case T_A : case T_MX : case T_SRV : case T_TXT : handle_null_request ( tun_fd , dns_fd , & q , domain_len ) ;\n break ;\n case T_NS : handle_ns_request ( dns_fd , & q ) ;\n break ;\n default : break ;\n }\n }\n else {\n if ( bind_fd ) {\n forward_query ( bind_fd , & q ) ;\n }\n }\n return 0 ;\n }","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":345857,"func":"do_restrict(\n\tsockaddr_u *srcadr,\n\tendpt *inter,\n\tstruct req_pkt *inpkt,\n\tint op\n\t)\n{\n\tchar *\t\t\tdatap;\n\tstruct conf_restrict\tcr;\n\tu_short\t\t\titems;\n\tsize_t\t\t\titem_sz;\n\tsockaddr_u\t\tmatchaddr;\n\tsockaddr_u\t\tmatchmask;\n\tint\t\t\tbad;\n\n\t\/*\n\t * Do a check of the flags to make sure that only\n\t * the NTPPORT flag is set, if any.  If not, complain\n\t * about it.  Note we are very picky here.\n\t *\/\n\titems = INFO_NITEMS(inpkt->err_nitems);\n\titem_sz = INFO_ITEMSIZE(inpkt->mbz_itemsize);\n\tdatap = inpkt->u.data;\n\tif (item_sz > sizeof(cr)) {\n\t\treq_ack(srcadr, inter, inpkt, INFO_ERR_FMT);\n\t\treturn;\n\t}\n\n\tbad = FALSE;\n\twhile (items-- > 0 && !bad) {\n\t\tmemcpy(&cr, datap, item_sz);\n\t\tcr.flags = ntohs(cr.flags);\n\t\tcr.mflags = ntohs(cr.mflags);\n\t\tif (~RESM_NTPONLY & cr.mflags)\n\t\t\tbad |= 1;\n\t\tif (~RES_ALLFLAGS & cr.flags)\n\t\t\tbad |= 2;\n\t\tif (INADDR_ANY != cr.mask) {\n\t\t\tif (client_v6_capable && cr.v6_flag) {\n\t\t\t\tif (IN6_IS_ADDR_UNSPECIFIED(&cr.addr6))\n\t\t\t\t\tbad |= 4;\n\t\t\t} else {\n\t\t\t\tif (INADDR_ANY == cr.addr)\n\t\t\t\t\tbad |= 8;\n\t\t\t}\n\t\t}\n\t\tdatap += item_sz;\n\t}\n\n\tif (bad) {\n\t\tmsyslog(LOG_ERR, \"do_restrict: bad = %#x\", bad);\n\t\treq_ack(srcadr, inter, inpkt, INFO_ERR_FMT);\n\t\treturn;\n\t}\n\n\t\/*\n\t * Looks okay, try it out\n\t *\/\n\tZERO_SOCK(&matchaddr);\n\tZERO_SOCK(&matchmask);\n\tdatap = inpkt->u.data;\n\n\twhile (items-- > 0) {\n\t\tmemcpy(&cr, datap, item_sz);\n\t\tcr.flags = ntohs(cr.flags);\n\t\tcr.mflags = ntohs(cr.mflags);\n\t\tif (client_v6_capable && cr.v6_flag) {\n\t\t\tAF(&matchaddr) = AF_INET6;\n\t\t\tAF(&matchmask) = AF_INET6;\n\t\t\tSOCK_ADDR6(&matchaddr) = cr.addr6;\n\t\t\tSOCK_ADDR6(&matchmask) = cr.mask6;\n\t\t} else {\n\t\t\tAF(&matchaddr) = AF_INET;\n\t\t\tAF(&matchmask) = AF_INET;\n\t\t\tNSRCADR(&matchaddr) = cr.addr;\n\t\t\tNSRCADR(&matchmask) = cr.mask;\n\t\t}\n\t\thack_restrict(op, &matchaddr, &matchmask, cr.mflags,\n\t\t\t      cr.flags, 0);\n\t\tdatap += item_sz;\n\t}\n\n\treq_ack(srcadr, inter, inpkt, INFO_OKAY);\n}","target":1,"code_token_length":645,"total_token_length":881,"max_tokens_setting":1024}
+{"idx":204592,"func":" int venc_dev::venc_input_log_buffers(OMX_BUFFERHEADERTYPE *pbuffer, int fd, int plane_offset) {\n    if (venc_handle->is_secure_session()) {\n        DEBUG_PRINT_ERROR(\"logging secure input buffers is not allowed!\");\n        return -1;\n    }\n\n     if (!m_debug.infile) {\n         int size = snprintf(m_debug.infile_name, PROPERTY_VALUE_MAX, \"%s\/input_enc_%lu_%lu_%p.yuv\",\n                             m_debug.log_loc, m_sVenc_cfg.input_width, m_sVenc_cfg.input_height, this);\n if ((size > PROPERTY_VALUE_MAX) && (size < 0)) {\n             DEBUG_PRINT_ERROR(\"Failed to open output file: %s for logging size:%d\",\n                                m_debug.infile_name, size);\n }\n        m_debug.infile = fopen (m_debug.infile_name, \"ab\");\n if (!m_debug.infile) {\n            DEBUG_PRINT_HIGH(\"Failed to open input file: %s for logging\", m_debug.infile_name);\n            m_debug.infile_name[0] = '\\0';\n return -1;\n }\n }\n if (m_debug.infile && pbuffer && pbuffer->nFilledLen) {\n unsigned long i, msize;\n int stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, m_sVenc_cfg.input_width);\n int scanlines = VENUS_Y_SCANLINES(COLOR_FMT_NV12, m_sVenc_cfg.input_height);\n unsigned char *pvirt,*ptemp;\n\n char *temp = (char *)pbuffer->pBuffer;\n\n        msize = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, m_sVenc_cfg.input_width, m_sVenc_cfg.input_height);\n if (metadatamode == 1) {\n            pvirt= (unsigned char *)mmap(NULL, msize, PROT_READ|PROT_WRITE,MAP_SHARED, fd, plane_offset);\n if (pvirt) {\n               ptemp = pvirt;\n for (i = 0; i < m_sVenc_cfg.input_height; i++) {\n                    fwrite(ptemp, m_sVenc_cfg.input_width, 1, m_debug.infile);\n                    ptemp += stride;\n }\n               ptemp = pvirt + (stride * scanlines);\n for(i = 0; i < m_sVenc_cfg.input_height\/2; i++) {\n                   fwrite(ptemp, m_sVenc_cfg.input_width, 1, m_debug.infile);\n                   ptemp += stride;\n }\n               munmap(pvirt, msize);\n } else if (pvirt == MAP_FAILED) {\n                 DEBUG_PRINT_ERROR(\"%s mmap failed\", __func__);\n return -1;\n }\n } else {\n for (i = 0; i < m_sVenc_cfg.input_height; i++) {\n                 fwrite(temp, m_sVenc_cfg.input_width, 1, m_debug.infile);\n                 temp += stride;\n }\n\n            temp = (char *)pbuffer->pBuffer + (stride * scanlines);\n\n for(i = 0; i < m_sVenc_cfg.input_height\/2; i++) {\n                fwrite(temp, m_sVenc_cfg.input_width, 1, m_debug.infile);\n                temp += stride;\n }\n }\n }\n return 0;\n}\n","target":0,"code_token_length":682,"total_token_length":918,"max_tokens_setting":1024}
+{"idx":326724,"func":"static int decode_value(SCPRContext *s, unsigned *cnt, unsigned maxc, unsigned step, unsigned *rval)\n\n{\n\n    GetByteContext *gb = &s->gb;\n\n    RangeCoder *rc = &s->rc;\n\n    unsigned totfr = cnt[maxc];\n\n    unsigned value;\n\n    unsigned c = 0, cumfr = 0, cnt_c = 0;\n\n    int i, ret;\n\n\n\n    if ((ret = s->get_freq(rc, totfr, &value)) < 0)\n\n        return ret;\n\n\n\n    while (c < maxc) {\n\n        cnt_c = cnt[c];\n\n        if (value >= cumfr + cnt_c)\n\n            cumfr += cnt_c;\n\n        else\n\n            break;\n\n        c++;\n\n    }\n\n    s->decode(gb, rc, cumfr, cnt_c, totfr);\n\n\n\n    cnt[c] = cnt_c + step;\n\n    totfr += step;\n\n    if (totfr > BOT) {\n\n        totfr = 0;\n\n        for (i = 0; i < maxc; i++) {\n\n            unsigned nc = (cnt[i] >> 1) + 1;\n\n            cnt[i] = nc;\n\n            totfr += nc;\n\n        }\n\n    }\n\n\n\n    cnt[maxc] = totfr;\n\n    *rval = c;\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":288778,"func":"static GstFlowReturn gst_asf_demux_process_advanced_mutual_exclusion ( GstASFDemux * demux , guint8 * data , guint64 size ) {\n ASFGuid guid ;\n guint16 num , i ;\n if ( size < 16 + 2 + ( 2 * 2 ) ) goto not_enough_data ;\n gst_asf_demux_get_guid ( & guid , & data , & size ) ;\n num = gst_asf_demux_get_uint16 ( & data , & size ) ;\n if ( num < 2 ) {\n GST_WARNING_OBJECT ( demux , \"nonsensical mutually exclusive streams count\" ) ;\n return GST_FLOW_OK ;\n }\n if ( size < ( num * sizeof ( guint16 ) ) ) goto not_enough_data ;\n for ( i = 0 ;\n i < num ;\n ++ i ) {\n guint8 mes ;\n mes = gst_asf_demux_get_uint16 ( & data , & size ) & 0x7f ;\n GST_LOG_OBJECT ( demux , \"mutually exclusive: stream %d\" , mes ) ;\n demux -> mut_ex_streams = g_slist_append ( demux -> mut_ex_streams , GINT_TO_POINTER ( mes ) ) ;\n }\n return GST_FLOW_OK ;\n not_enough_data : {\n GST_WARNING_OBJECT ( demux , \"short read parsing advanced mutual exclusion\" ) ;\n return GST_FLOW_OK ;\n }\n }","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":393533,"func":"xmlidDocTest(const char *filename,\n             const char *result,\n             const char *err,\n             int options) {\n\n    int res = 0;\n    int ret = 0;\n    char *temp;\n\n    xpathDocument = xmlReadFile(filename, NULL,\n                                options | XML_PARSE_DTDATTR | XML_PARSE_NOENT);\n    if (xpathDocument == NULL) {\n        fprintf(stderr, \"Failed to load %s\\n\", filename);\n\treturn(-1);\n    }\n\n    temp = resultFilename(filename, \"\", \".res\");\n    if (temp == NULL) {\n        fprintf(stderr, \"Out of memory\\n\");\n        fatalError();\n    }\n    xpathOutput = fopen(temp, \"wb\");\n    if (xpathOutput == NULL) {\n\tfprintf(stderr, \"failed to open output file %s\\n\", temp);\n        xmlFreeDoc(xpathDocument);\n        free(temp);\n\treturn(-1);\n    }\n\n    testXPath(\"id('bar')\", 0, 0);\n\n    fclose(xpathOutput);\n    if (result != NULL) {\n\tret = compareFiles(temp, result);\n\tif (ret) {\n\t    fprintf(stderr, \"Result for %s failed in %s\\n\", filename, result);\n\t    res = 1;\n\t}\n    }\n\n    if (temp != NULL) {\n        unlink(temp);\n        free(temp);\n    }\n    xmlFreeDoc(xpathDocument);\n\n    if (err != NULL) {\n\tret = compareFileMem(err, testErrors, testErrorsSize);\n\tif (ret != 0) {\n\t    fprintf(stderr, \"Error for %s failed\\n\", filename);\n\t    res = 1;\n\t}\n    }\n    return(res);\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":58997,"func":"void abst_box_del(GF_Box *s)\n{\n\tGF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s;\n\tif (ptr == NULL) return;\n\n\tif (ptr->movie_identifier)\n\t\tgf_free(ptr->movie_identifier);\n\tif (ptr->drm_data)\n\t\tgf_free(ptr->drm_data);\n\tif (ptr->meta_data)\n\t\tgf_free(ptr->meta_data);\n\n\twhile (gf_list_count(ptr->server_entry_table)) {\n\t\tgf_free(gf_list_get(ptr->server_entry_table, 0));\n\t\tgf_list_rem(ptr->server_entry_table, 0);\n\t}\n\tgf_list_del(ptr->server_entry_table);\n\n\twhile (gf_list_count(ptr->quality_entry_table)) {\n\t\tgf_free(gf_list_get(ptr->quality_entry_table, 0));\n\t\tgf_list_rem(ptr->quality_entry_table, 0);\n\t}\n\tgf_list_del(ptr->quality_entry_table);\n\n\n\twhile (gf_list_count(ptr->segment_run_table_entries)) {\n\t\tgf_isom_box_del((GF_Box *)gf_list_get(ptr->segment_run_table_entries, 0));\n\t\tgf_list_rem(ptr->segment_run_table_entries, 0);\n\t}\n\tgf_list_del(ptr->segment_run_table_entries);\n\n\twhile (gf_list_count(ptr->fragment_run_table_entries)) {\n\t\tgf_isom_box_del((GF_Box *)gf_list_get(ptr->fragment_run_table_entries, 0));\n\t\tgf_list_rem(ptr->fragment_run_table_entries, 0);\n\t}\n\tgf_list_del(ptr->fragment_run_table_entries);\n\n\tgf_free(ptr);\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":283402,"func":"static void OverloadedMethodLMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  scheduler::CooperativeSchedulingManager::Instance()->Safepoint();\n\n  bool is_arity_error = false;\n\n  switch (std::min(2, info.Length())) {\n    case 1:\n      if (info[0]->IsNumber()) {\n        OverloadedMethodL1Method(info);\n        return;\n      }\n      if (true) {\n        OverloadedMethodL2Method(info);\n        return;\n      }\n      if (true) {\n        OverloadedMethodL1Method(info);\n        return;\n      }\n      break;\n    case 2:\n      if (info[0]->IsNumber()) {\n        OverloadedMethodL1Method(info);\n        return;\n      }\n      if (true) {\n        OverloadedMethodL2Method(info);\n        return;\n      }\n      if (true) {\n        OverloadedMethodL1Method(info);\n        return;\n      }\n      break;\n    default:\n      is_arity_error = true;\n  }\n\n  ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, \"TestObject\", \"overloadedMethodL\");\n  if (is_arity_error) {\n    if (info.Length() < 1) {\n      exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));\n      return;\n    }\n  }\n  exception_state.ThrowTypeError(\"No function was found that matched the signature provided.\");\n}\n","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":357904,"func":"static int ext4_journalled_writepage(struct page *page,\n\t\t\t\tstruct writeback_control *wbc)\n{\n\tstruct inode *inode = page->mapping->host;\n\tloff_t size = i_size_read(inode);\n\tloff_t len;\n\n\ttrace_mark(ext4_journalled_writepage,\n\t\t   \"dev %s ino %lu page_index %lu\",\n\t\t   inode->i_sb->s_id, inode->i_ino, page->index);\n\tJ_ASSERT(PageLocked(page));\n\tif (page->index == size >> PAGE_CACHE_SHIFT)\n\t\tlen = size & ~PAGE_CACHE_MASK;\n\telse\n\t\tlen = PAGE_CACHE_SIZE;\n\n\tif (page_has_buffers(page)) {\n\t\t\/* if page has buffers it should all be mapped\n\t\t * and allocated. If there are not buffers attached\n\t\t * to the page we know the page is dirty but it lost\n\t\t * buffers. That means that at some moment in time\n\t\t * after write_begin() \/ write_end() has been called\n\t\t * all buffers have been clean and thus they must have been\n\t\t * written at least once. So they are all mapped and we can\n\t\t * happily proceed with mapping them and writing the page.\n\t\t *\/\n\t\tBUG_ON(walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,\n\t\t\t\t\text4_bh_unmapped_or_delay));\n\t}\n\n\tif (ext4_journal_current_handle())\n\t\tgoto no_write;\n\n\tif (PageChecked(page)) {\n\t\t\/*\n\t\t * It's mmapped pagecache.  Add buffers and journal it.  There\n\t\t * doesn't seem much point in redirtying the page here.\n\t\t *\/\n\t\tClearPageChecked(page);\n\t\treturn __ext4_journalled_writepage(page, wbc);\n\t} else {\n\t\t\/*\n\t\t * It may be a page full of checkpoint-mode buffers.  We don't\n\t\t * really know unless we go poke around in the buffer_heads.\n\t\t * But block_write_full_page will do the right thing.\n\t\t *\/\n\t\treturn block_write_full_page(page,\n\t\t\t\t\t\text4_normal_get_block_write,\n\t\t\t\t\t\twbc);\n\t}\nno_write:\n\tredirty_page_for_writepage(wbc, page);\n\tunlock_page(page);\n\treturn 0;\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":32465,"func":"static void build_mixer_unit_ctl(struct mixer_build *state,\n\t\t\t\t struct uac_mixer_unit_descriptor *desc,\n\t\t\t\t int in_pin, int in_ch, int unitid,\n\t\t\t\t struct usb_audio_term *iterm)\n{\n\tstruct usb_mixer_elem_info *cval;\n\tunsigned int num_outs = uac_mixer_unit_bNrChannels(desc);\n\tunsigned int i, len;\n\tstruct snd_kcontrol *kctl;\n\tconst struct usbmix_name_map *map;\n\n\tmap = find_map(state, unitid, 0);\n\tif (check_ignored_ctl(map))\n\t\treturn;\n\n\tcval = kzalloc(sizeof(*cval), GFP_KERNEL);\n\tif (!cval)\n\t\treturn;\n\n\tsnd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid);\n\tcval->control = in_ch + 1; \/* based on 1 *\/\n\tcval->val_type = USB_MIXER_S16;\n\tfor (i = 0; i < num_outs; i++) {\n\t\t__u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol);\n\n\t\tif (check_matrix_bitmap(c, in_ch, i, num_outs)) {\n\t\t\tcval->cmask |= (1 << i);\n\t\t\tcval->channels++;\n\t\t}\n\t}\n\n\t\/* get min\/max values *\/\n\tget_min_max(cval, 0);\n\n\tkctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);\n\tif (!kctl) {\n\t\tusb_audio_err(state->chip, \"cannot malloc kcontrol\\n\");\n\t\tkfree(cval);\n\t\treturn;\n\t}\n\tkctl->private_free = snd_usb_mixer_elem_free;\n\n\tlen = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));\n\tif (!len)\n\t\tlen = get_term_name(state, iterm, kctl->id.name,\n\t\t\t\t    sizeof(kctl->id.name), 0);\n\tif (!len)\n\t\tlen = sprintf(kctl->id.name, \"Mixer Source %d\", in_ch + 1);\n\tappend_ctl_name(kctl, \" Volume\");\n\n\tusb_audio_dbg(state->chip, \"[%d] MU [%s] ch = %d, val = %d\/%d\\n\",\n\t\t    cval->head.id, kctl->id.name, cval->channels, cval->min, cval->max);\n\tsnd_usb_mixer_add_control(&cval->head, kctl);\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":414403,"func":"static void getRDB(void) {\n    int s = context->fd;\n    int fd;\n    unsigned long long payload = sendSync(s);\n    char buf[4096];\n\n    fprintf(stderr,\"SYNC sent to master, writing %llu bytes to '%s'\\n\",\n        payload, config.rdb_filename);\n\n    \/* Write to file. *\/\n    if (!strcmp(config.rdb_filename,\"-\")) {\n        fd = STDOUT_FILENO;\n    } else {\n        fd = open(config.rdb_filename, O_CREAT|O_WRONLY, 0644);\n        if (fd == -1) {\n            fprintf(stderr, \"Error opening '%s': %s\\n\", config.rdb_filename,\n                strerror(errno));\n            exit(1);\n        }\n    }\n\n    while(payload) {\n        ssize_t nread, nwritten;\n\n        nread = read(s,buf,(payload > sizeof(buf)) ? sizeof(buf) : payload);\n        if (nread <= 0) {\n            fprintf(stderr,\"I\/O Error reading RDB payload from socket\\n\");\n            exit(1);\n        }\n        nwritten = write(fd, buf, nread);\n        if (nwritten != nread) {\n            fprintf(stderr,\"Error writing data to file: %s\\n\",\n                strerror(errno));\n            exit(1);\n        }\n        payload -= nread;\n    }\n    close(s); \/* Close the file descriptor ASAP as fsync() may take time. *\/\n    fsync(fd);\n    fprintf(stderr,\"Transfer finished with success.\\n\");\n    exit(0);\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":356193,"func":"static long do_rmdir(int dfd, const char __user *pathname)\n{\n\tint error = 0;\n\tchar * name;\n\tstruct dentry *dentry;\n\tstruct nameidata nd;\n\n\tname = getname(pathname);\n\tif(IS_ERR(name))\n\t\treturn PTR_ERR(name);\n\n\terror = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd);\n\tif (error)\n\t\tgoto exit;\n\n\tswitch(nd.last_type) {\n\t\tcase LAST_DOTDOT:\n\t\t\terror = -ENOTEMPTY;\n\t\t\tgoto exit1;\n\t\tcase LAST_DOT:\n\t\t\terror = -EINVAL;\n\t\t\tgoto exit1;\n\t\tcase LAST_ROOT:\n\t\t\terror = -EBUSY;\n\t\t\tgoto exit1;\n\t}\n\tmutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);\n\tdentry = lookup_hash(&nd);\n\terror = PTR_ERR(dentry);\n\tif (IS_ERR(dentry))\n\t\tgoto exit2;\n\terror = mnt_want_write(nd.path.mnt);\n\tif (error)\n\t\tgoto exit3;\n\terror = vfs_rmdir(nd.path.dentry->d_inode, dentry);\n\tmnt_drop_write(nd.path.mnt);\nexit3:\n\tdput(dentry);\nexit2:\n\tmutex_unlock(&nd.path.dentry->d_inode->i_mutex);\nexit1:\n\tpath_put(&nd.path);\nexit:\n\tputname(name);\n\treturn error;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":109531,"func":"static int loop(int fd)\n{\n\tvoid (*workfn) (int ci);\n\tvoid (*deadfn) (int ci);\n\tint rv, i;\n\n\trv = setup_transport();\n\tif (rv < 0)\n\t\tgoto fail;\n\n\trv = setup_ticket();\n\tif (rv < 0)\n\t\tgoto fail;\n\n\trv = write_daemon_state(fd, BOOTHD_STARTED);\n\tif (rv != 0) {\n\t\tlog_error(\"write daemon state %d to lockfile error %s: %s\",\n                      BOOTHD_STARTED, cl.lockfile, strerror(errno));\n\t\tgoto fail;\n\t}\n\n\tlog_info(\"BOOTH %s daemon started, node id is 0x%08X (%d).\",\n\t\ttype_to_string(local->type),\n\t\t\tlocal->site_id, local->site_id);\n\n\twhile (1) {\n\t\trv = poll(pollfds, client_maxi + 1, poll_timeout);\n\t\tif (rv == -1 && errno == EINTR)\n\t\t\tcontinue;\n\t\tif (rv < 0) {\n\t\t\tlog_error(\"poll failed: %s (%d)\", strerror(errno), errno);\n\t\t\tgoto fail;\n\t\t}\n\n\t\tfor (i = 0; i <= client_maxi; i++) {\n\t\t\tif (clients[i].fd < 0)\n\t\t\t\tcontinue;\n\n\t\t\tif (pollfds[i].revents & POLLIN) {\n\t\t\t\tworkfn = clients[i].workfn;\n\t\t\t\tif (workfn)\n\t\t\t\t\tworkfn(i);\n\t\t\t}\n\t\t\tif (pollfds[i].revents &\n\t\t\t\t\t(POLLERR | POLLHUP | POLLNVAL)) {\n\t\t\t\tdeadfn = clients[i].deadfn;\n\t\t\t\tif (deadfn)\n\t\t\t\t\tdeadfn(i);\n\t\t\t}\n\t\t}\n\n\t\tprocess_tickets();\n\n\t\tif (process_signals() != 0) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn 0;\n\nfail:\n\treturn -1;\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":481477,"func":"\nstatic void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc)\n{\n\tstruct file *file = prsrc->file;\n#if defined(CONFIG_UNIX)\n\tstruct sock *sock = ctx->ring_sock->sk;\n\tstruct sk_buff_head list, *head = &sock->sk_receive_queue;\n\tstruct sk_buff *skb;\n\tint i;\n\n\tif (!io_file_need_scm(file)) {\n\t\tfput(file);\n\t\treturn;\n\t}\n\n\t__skb_queue_head_init(&list);\n\n\t\/*\n\t * Find the skb that holds this file in its SCM_RIGHTS. When found,\n\t * remove this entry and rearrange the file array.\n\t *\/\n\tskb = skb_dequeue(head);\n\twhile (skb) {\n\t\tstruct scm_fp_list *fp;\n\n\t\tfp = UNIXCB(skb).fp;\n\t\tfor (i = 0; i < fp->count; i++) {\n\t\t\tint left;\n\n\t\t\tif (fp->fp[i] != file)\n\t\t\t\tcontinue;\n\n\t\t\tunix_notinflight(fp->user, fp->fp[i]);\n\t\t\tleft = fp->count - 1 - i;\n\t\t\tif (left) {\n\t\t\t\tmemmove(&fp->fp[i], &fp->fp[i + 1],\n\t\t\t\t\t\tleft * sizeof(struct file *));\n\t\t\t}\n\t\t\tfp->count--;\n\t\t\tif (!fp->count) {\n\t\t\t\tkfree_skb(skb);\n\t\t\t\tskb = NULL;\n\t\t\t} else {\n\t\t\t\t__skb_queue_tail(&list, skb);\n\t\t\t}\n\t\t\tfput(file);\n\t\t\tfile = NULL;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!file)\n\t\t\tbreak;\n\n\t\t__skb_queue_tail(&list, skb);\n\n\t\tskb = skb_dequeue(head);\n\t}\n\n\tif (skb_peek(&list)) {\n\t\tspin_lock_irq(&head->lock);\n\t\twhile ((skb = __skb_dequeue(&list)) != NULL)\n\t\t\t__skb_queue_tail(head, skb);\n\t\tspin_unlock_irq(&head->lock);\n\t}\n#else\n\tfput(file);\n#endif","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":354435,"func":"static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,\n\t\t\tstruct packet_type *pt)\n{\n\t\/* Expand any short form frames *\/\n\tif (skb->mac.raw[2] == 1) {\n\t\tstruct ddpehdr *ddp;\n\t\t\/* Find our address *\/\n\t\tstruct atalk_addr *ap = atalk_find_dev_addr(dev);\n\n\t\tif (!ap || skb->len < sizeof(struct ddpshdr))\n\t\t\tgoto freeit;\n\n\t\t\/* Don't mangle buffer if shared *\/\n\t\tif (!(skb = skb_share_check(skb, GFP_ATOMIC))) \n\t\t\treturn 0;\n\n\t\t\/*\n\t\t * The push leaves us with a ddephdr not an shdr, and\n\t\t * handily the port bytes in the right place preset.\n\t\t *\/\n\t\tddp = (struct ddpehdr *) skb_push(skb, sizeof(*ddp) - 4);\n\n\t\t\/* Now fill in the long header *\/\n\n\t \t\/*\n\t \t * These two first. The mac overlays the new source\/dest\n\t \t * network information so we MUST copy these before\n\t \t * we write the network numbers !\n\t \t *\/\n\n\t\tddp->deh_dnode = skb->mac.raw[0];     \/* From physical header *\/\n\t\tddp->deh_snode = skb->mac.raw[1];     \/* From physical header *\/\n\n\t\tddp->deh_dnet  = ap->s_net;\t\/* Network number *\/\n\t\tddp->deh_snet  = ap->s_net;\n\t\tddp->deh_sum   = 0;\t\t\/* No checksum *\/\n\t\t\/*\n\t\t * Not sure about this bit...\n\t\t *\/\n\t\tddp->deh_len   = skb->len;\n\t\tddp->deh_hops  = DDP_MAXHOPS;\t\/* Non routable, so force a drop\n\t\t\t\t\t\t   if we slip up later *\/\n\t\t\/* Mend the byte order *\/\n\t\t*((__u16 *)ddp) = htons(*((__u16 *)ddp));\n\t}\n\tskb->h.raw = skb->data;\n\n\treturn atalk_rcv(skb, dev, pt);\nfreeit:\n\tkfree_skb(skb);\n\treturn 0;\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":114627,"func":"static void cobject(JF, js_Ast *list)\n{\n\tjs_Ast *head = list;\n\n\twhile (list) {\n\t\tjs_Ast *kv = list->a;\n\t\tjs_Ast *prop = kv->a;\n\n\t\tif (prop->type == AST_IDENTIFIER || prop->type == EXP_STRING) {\n\t\t\temitline(J, F, prop);\n\t\t\temitstring(J, F, OP_STRING, prop->string);\n\t\t} else if (prop->type == EXP_NUMBER) {\n\t\t\temitline(J, F, prop);\n\t\t\temitnumber(J, F, prop->number);\n\t\t} else {\n\t\t\tjsC_error(J, prop, \"invalid property name in object initializer\");\n\t\t}\n\n\t\tif (F->strict)\n\t\t\tcheckdup(J, F, head, kv);\n\n\t\tswitch (kv->type) {\n\t\tdefault: \/* impossible *\/ break;\n\t\tcase EXP_PROP_VAL:\n\t\t\tcexp(J, F, kv->b);\n\t\t\temitline(J, F, kv);\n\t\t\temit(J, F, OP_INITPROP);\n\t\t\tbreak;\n\t\tcase EXP_PROP_GET:\n\t\t\temitfunction(J, F, newfun(J, prop->line, NULL, NULL, kv->c, 0, F->strict));\n\t\t\temitline(J, F, kv);\n\t\t\temit(J, F, OP_INITGETTER);\n\t\t\tbreak;\n\t\tcase EXP_PROP_SET:\n\t\t\temitfunction(J, F, newfun(J, prop->line, NULL, kv->b, kv->c, 0, F->strict));\n\t\t\temitline(J, F, kv);\n\t\t\temit(J, F, OP_INITSETTER);\n\t\t\tbreak;\n\t\t}\n\n\t\tlist = list->b;\n\t}\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":203343,"func":"jbig2_decode_generic_template1_TPGDON(Jbig2Ctx *ctx,\n                                      Jbig2Segment *segment,\n                                      const Jbig2GenericRegionParams *params, Jbig2ArithState *as, Jbig2Image *image, Jbig2ArithCx *GB_stats)\n{\n    const int GBW = image->width;\n    const int GBH = image->height;\n    uint32_t CONTEXT;\n    int x, y;\n    bool bit;\n    int LTP = 0;\n\n    for (y = 0; y < GBH; y++) {\n        bit = jbig2_arith_decode(as, &GB_stats[0x0795]);\n        if (bit < 0)\n                    return -1;\n        LTP ^= bit;\n        if (!LTP) {\n            for (x = 0; x < GBW; x++) {\n                CONTEXT = jbig2_image_get_pixel(image, x - 1, y);\n                CONTEXT |= jbig2_image_get_pixel(image, x - 2, y) << 1;\n                CONTEXT |= jbig2_image_get_pixel(image, x - 3, y) << 2;\n                CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[0], y + params->gbat[1]) << 3;\n                CONTEXT |= jbig2_image_get_pixel(image, x + 2, y - 1) << 4;\n                CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 1) << 5;\n                CONTEXT |= jbig2_image_get_pixel(image, x, y - 1) << 6;\n                CONTEXT |= jbig2_image_get_pixel(image, x - 1, y - 1) << 7;\n                CONTEXT |= jbig2_image_get_pixel(image, x - 2, y - 1) << 8;\n                CONTEXT |= jbig2_image_get_pixel(image, x + 2, y - 2) << 9;\n                CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 2) << 10;\n                CONTEXT |= jbig2_image_get_pixel(image, x, y - 2) << 11;\n                CONTEXT |= jbig2_image_get_pixel(image, x - 1, y - 2) << 12;\n                bit = jbig2_arith_decode(as, &GB_stats[CONTEXT]);\n                if (bit < 0)\n                            return -1;\n                jbig2_image_set_pixel(image, x, y, bit);\n            }\n        } else {\n            copy_prev_row(image, y);\n        }\n    }\n\n    return 0;\n}\n","target":0,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":255538,"func":"_PyMemoTable_ResizeTable(PyMemoTable *self, Py_ssize_t min_size)\n{\n    PyMemoEntry *oldtable = NULL;\n    PyMemoEntry *oldentry, *newentry;\n    Py_ssize_t new_size = MT_MINSIZE;\n    Py_ssize_t to_process;\n\n    assert(min_size > 0);\n\n    \/* Find the smallest valid table size >= min_size. *\/\n    while (new_size < min_size && new_size > 0)\n        new_size <<= 1;\n    if (new_size <= 0) {\n        PyErr_NoMemory();\n        return -1;\n    }\n    \/* new_size needs to be a power of two. *\/\n    assert((new_size & (new_size - 1)) == 0);\n\n    \/* Allocate new table. *\/\n    oldtable = self->mt_table;\n    self->mt_table = PyMem_NEW(PyMemoEntry, new_size);\n    if (self->mt_table == NULL) {\n        self->mt_table = oldtable;\n        PyErr_NoMemory();\n        return -1;\n    }\n    self->mt_allocated = new_size;\n    self->mt_mask = new_size - 1;\n    memset(self->mt_table, 0, sizeof(PyMemoEntry) * new_size);\n\n    \/* Copy entries from the old table. *\/\n    to_process = self->mt_used;\n    for (oldentry = oldtable; to_process > 0; oldentry++) {\n        if (oldentry->me_key != NULL) {\n            to_process--;\n            \/* newentry is a pointer to a chunk of the new\n               mt_table, so we're setting the key:value pair\n               in-place. *\/\n            newentry = _PyMemoTable_Lookup(self, oldentry->me_key);\n            newentry->me_key = oldentry->me_key;\n            newentry->me_value = oldentry->me_value;\n        }\n    }\n\n    \/* Deallocate the old table. *\/\n    PyMem_FREE(oldtable);\n    return 0;\n}","target":1,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":337677,"func":"static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int type,\n\n                                 Error **errp)\n\n{\n\n    int num_entries;\n\n    QemuOpts *opts = NULL;\n\n    QDict *sub_options;\n\n    const char *host;\n\n    const char *port;\n\n    char *str;\n\n    char *rados_str = NULL;\n\n    Error *local_err = NULL;\n\n    int i;\n\n\n\n    assert(type == RBD_MON_HOST);\n\n\n\n    num_entries = qdict_array_entries(options, prefix);\n\n\n\n    if (num_entries < 0) {\n\n        error_setg(errp, \"Parse error on RBD QDict array\");\n\n        return NULL;\n\n    }\n\n\n\n    for (i = 0; i < num_entries; i++) {\n\n        char *strbuf = NULL;\n\n        const char *value;\n\n        char *rados_str_tmp;\n\n\n\n        str = g_strdup_printf(\"%s%d.\", prefix, i);\n\n        qdict_extract_subqdict(options, &sub_options, str);\n\n        g_free(str);\n\n\n\n        opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);\n\n        qemu_opts_absorb_qdict(opts, sub_options, &local_err);\n\n        QDECREF(sub_options);\n\n        if (local_err) {\n\n            error_propagate(errp, local_err);\n\n            g_free(rados_str);\n\n            rados_str = NULL;\n\n            goto exit;\n\n        }\n\n\n\n        if (type == RBD_MON_HOST) {\n\n            host = qemu_opt_get(opts, \"host\");\n\n            port = qemu_opt_get(opts, \"port\");\n\n\n\n            value = host;\n\n            if (port) {\n\n                \/* check for ipv6 *\/\n\n                if (strchr(host, ':')) {\n\n                    strbuf = g_strdup_printf(\"[%s]:%s\", host, port);\n\n                } else {\n\n                    strbuf = g_strdup_printf(\"%s:%s\", host, port);\n\n                }\n\n                value = strbuf;\n\n            } else if (strchr(host, ':')) {\n\n                strbuf = g_strdup_printf(\"[%s]\", host);\n\n                value = strbuf;\n\n            }\n\n        } else {\n\n            abort();\n\n        }\n\n\n\n        \/* each iteration in the for loop will build upon the string, and if\n\n         * rados_str is NULL then it is our first pass *\/\n\n        if (rados_str) {\n\n            \/* separate options with ';', as that  is what rados_conf_set()\n\n             * requires *\/\n\n            rados_str_tmp = rados_str;\n\n            rados_str = g_strdup_printf(\"%s;%s\", rados_str_tmp, value);\n\n            g_free(rados_str_tmp);\n\n        } else {\n\n            rados_str = g_strdup(value);\n\n        }\n\n\n\n        g_free(strbuf);\n\n        qemu_opts_del(opts);\n\n        opts = NULL;\n\n    }\n\n\n\nexit:\n\n    qemu_opts_del(opts);\n\n    return rados_str;\n\n}\n","target":1,"code_token_length":587,"total_token_length":823,"max_tokens_setting":1024}
+{"idx":24306,"func":"static gpgme_error_t gpgsm_export_ext ( void * engine , const char * pattern [ ] , gpgme_export_mode_t mode , gpgme_data_t keydata , int use_armor ) {\n engine_gpgsm_t gpgsm = engine ;\n gpgme_error_t err = 0 ;\n char * line ;\n int length = 7 + 1 ;\n char * linep ;\n if ( ! gpgsm ) return gpg_error ( GPG_ERR_INV_VALUE ) ;\n if ( mode ) return gpg_error ( GPG_ERR_NOT_SUPPORTED ) ;\n if ( pattern && * pattern ) {\n const char * * pat = pattern ;\n while ( * pat ) {\n const char * patlet = * pat ;\n while ( * patlet ) {\n length ++ ;\n if ( * patlet == '%' || * patlet == ' ' || * patlet == '+' ) length += 2 ;\n patlet ++ ;\n }\n pat ++ ;\n length ++ ;\n }\n }\n line = malloc ( length ) ;\n if ( ! line ) return gpg_error_from_syserror ( ) ;\n strcpy ( line , \"EXPORT \" ) ;\n linep = & line [ 7 ] ;\n if ( pattern && * pattern ) {\n while ( * pattern ) {\n const char * patlet = * pattern ;\n while ( * patlet ) {\n switch ( * patlet ) {\n case '%' : * ( linep ++ ) = '%' ;\n * ( linep ++ ) = '2' ;\n * ( linep ++ ) = '5' ;\n break ;\n case ' ' : * ( linep ++ ) = '%' ;\n * ( linep ++ ) = '2' ;\n * ( linep ++ ) = '0' ;\n break ;\n case '+' : * ( linep ++ ) = '%' ;\n * ( linep ++ ) = '2' ;\n * ( linep ++ ) = 'B' ;\n break ;\n default : * ( linep ++ ) = * patlet ;\n break ;\n }\n patlet ++ ;\n }\n pattern ++ ;\n if ( * pattern ) * linep ++ = ' ' ;\n }\n }\n * linep = '\\0' ;\n gpgsm -> output_cb . data = keydata ;\n err = gpgsm_set_fd ( gpgsm , OUTPUT_FD , use_armor ? \"--armor\" : map_data_enc ( gpgsm -> output_cb . data ) ) ;\n if ( err ) return err ;\n gpgsm_clear_fd ( gpgsm , INPUT_FD ) ;\n gpgsm_clear_fd ( gpgsm , MESSAGE_FD ) ;\n gpgsm -> inline_data = NULL ;\n err = start ( gpgsm , line ) ;\n free ( line ) ;\n return err ;\n }","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":16293,"func":"static int parse_CAggregSpec ( tvbuff_t * tvb , int offset , proto_tree * parent_tree , proto_tree * pad_tree , const char * fmt , ... ) {\n proto_item * item ;\n proto_tree * tree ;\n va_list ap ;\n guint8 type ;\n guint32 ccAlias , idColumn ;\n const char * txt ;\n va_start ( ap , fmt ) ;\n txt = wmem_strdup_vprintf ( wmem_packet_scope ( ) , fmt , ap ) ;\n va_end ( ap ) ;\n tree = proto_tree_add_subtree ( parent_tree , tvb , offset , 0 , ett_CAggregSpec , & item , txt ) ;\n type = tvb_get_guint8 ( tvb , offset ) ;\n proto_tree_add_uint ( tree , hf_mswsp_caggregspec_type , tvb , offset , 1 , type ) ;\n proto_item_append_text ( item , \"type: %u\" , type ) ;\n offset += 1 ;\n offset = parse_padding ( tvb , offset , 4 , pad_tree , \"padding\" ) ;\n ccAlias = tvb_get_letohl ( tvb , offset ) ;\n proto_tree_add_uint ( tree , hf_mswsp_caggregspec_ccalias , tvb , offset , 1 , ccAlias ) ;\n offset += 4 ;\n proto_tree_add_item ( tree , hf_mswsp_caggregspec_alias , tvb , offset , 2 * ccAlias , ENC_LITTLE_ENDIAN | ENC_UCS_2 ) ;\n offset += 2 * ccAlias ;\n idColumn = tvb_get_letohl ( tvb , offset ) ;\n proto_tree_add_uint ( tree , hf_mswsp_caggregspec_idcolumn , tvb , offset , 1 , idColumn ) ;\n offset += 4 ;\n proto_item_set_end ( item , tvb , offset ) ;\n return offset ;\n }","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":213617,"func":"void RegistrationManager::TryRegisterId(const invalidation::ObjectId& id,\n                                        bool is_retry) {\n  DCHECK(CalledOnValidThread());\n  RegistrationStatusMap::const_iterator it = registration_statuses_.find(id);\n  if (it == registration_statuses_.end()) {\n    DLOG(FATAL) << \"TryRegisterId called on \" << ObjectIdToString(id)\n                << \" which is not in the registration map\";\n    return;\n  }\n  RegistrationStatus* status = it->second;\n  if (!status->enabled) {\n    return;\n  }\n  status->last_registration_attempt = base::Time::Now();\n  if (is_retry) {\n    DCHECK(!status->last_registration_request.is_null());\n    status->delay =\n        (status->last_registration_request -\n         status->last_registration_attempt) +\n        status->next_delay;\n    base::TimeDelta delay =\n        (status->delay <= base::TimeDelta()) ?\n        base::TimeDelta() : status->delay;\n    DVLOG(2) << \"Registering \"\n             << ObjectIdToString(id) << \" in \"\n             << delay.InMilliseconds() << \" ms\";\n    status->registration_timer.Stop();\n    status->registration_timer.Start(FROM_HERE,\n        delay, status, &RegistrationManager::RegistrationStatus::DoRegister);\n    double next_delay_seconds =\n        CalculateBackoff(static_cast<double>(status->next_delay.InSeconds()),\n                         kInitialRegistrationDelaySeconds,\n                         kMinRegistrationDelaySeconds,\n                         kMaxRegistrationDelaySeconds,\n                         kRegistrationDelayExponent,\n                         GetJitter(),\n                         kRegistrationDelayMaxJitter);\n    status->next_delay =\n        base::TimeDelta::FromSeconds(static_cast<int64>(next_delay_seconds));\n    DVLOG(2) << \"New next delay for \"\n             << ObjectIdToString(id) << \" is \"\n             << status->next_delay.InSeconds() << \" seconds\";\n  } else {\n    DVLOG(2) << \"Not a retry -- registering \"\n             << ObjectIdToString(id) << \" immediately\";\n    status->delay = base::TimeDelta();\n    status->next_delay = base::TimeDelta();\n    status->DoRegister();\n  }\n}\n","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":198289,"func":"void CSoundFile::InvertLoop(ModChannel *pChn)\n{\n\tif(GetType() != MOD_TYPE_MOD || pChn->nEFxSpeed == 0) return;\n\n\tModSample *pModSample = const_cast<ModSample *>(pChn->pModSample);\n\tif(pModSample == nullptr || !pModSample->HasSampleData() || !pModSample->uFlags[CHN_LOOP] || pModSample->uFlags[CHN_16BIT]) return;\n\n\tpChn->nEFxDelay += ModEFxTable[pChn->nEFxSpeed & 0x0F];\n\tif((pChn->nEFxDelay & 0x80) == 0) return; \/\/ only applied if the \"delay\" reaches 128\n\tpChn->nEFxDelay = 0;\n\n\tif (++pChn->nEFxOffset >= pModSample->nLoopEnd - pModSample->nLoopStart)\n\t\tpChn->nEFxOffset = 0;\n\n\tuint8 &sample = mpt::byte_cast<uint8 *>(pModSample->sampleb())[pModSample->nLoopStart + pChn->nEFxOffset];\n\tsample = ~sample;\n\tctrlSmp::PrecomputeLoops(*pModSample, *this, false);\n}\n","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":505763,"func":"void ssl3_free(SSL *s)\n\t{\n\tif(s == NULL)\n\t    return;\n\n#ifdef TLSEXT_TYPE_opaque_prf_input\n\tif (s->s3->client_opaque_prf_input != NULL)\n\t\tOPENSSL_free(s->s3->client_opaque_prf_input);\n\tif (s->s3->server_opaque_prf_input != NULL)\n\t\tOPENSSL_free(s->s3->server_opaque_prf_input);\n#endif\n\n\tssl3_cleanup_key_block(s);\n\tif (s->s3->rbuf.buf != NULL)\n\t\tssl3_release_read_buffer(s);\n\tif (s->s3->wbuf.buf != NULL)\n\t\tssl3_release_write_buffer(s);\n\tif (s->s3->rrec.comp != NULL)\n\t\tOPENSSL_free(s->s3->rrec.comp);\n#ifndef OPENSSL_NO_DH\n\tif (s->s3->tmp.dh != NULL)\n\t\tDH_free(s->s3->tmp.dh);\n#endif\n#ifndef OPENSSL_NO_ECDH\n\tif (s->s3->tmp.ecdh != NULL)\n\t\tEC_KEY_free(s->s3->tmp.ecdh);\n#endif\n\n\tif (s->s3->tmp.ca_names != NULL)\n\t\tsk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);\n\tif (s->s3->handshake_buffer) {\n\t\tBIO_free(s->s3->handshake_buffer);\n\t}\n\tif (s->s3->handshake_dgst) ssl3_free_digest_list(s);\n#ifndef OPENSSL_NO_SRP\n\tSSL_SRP_CTX_free(s);\n#endif\n\tOPENSSL_cleanse(s->s3,sizeof *s->s3);\n\tOPENSSL_free(s->s3);\n\ts->s3=NULL;\n\t}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":339707,"func":"static av_always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){\n\n    int i;\n\n    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\n\n\n\n    block[0] += 1<<(shift-1);\n\n\n\n    for(i=0; i<4; i++){\n\n        const int z0=  block[0 + block_stride*i]     +  block[2 + block_stride*i];\n\n        const int z1=  block[0 + block_stride*i]     -  block[2 + block_stride*i];\n\n        const int z2= (block[1 + block_stride*i]>>1) -  block[3 + block_stride*i];\n\n        const int z3=  block[1 + block_stride*i]     + (block[3 + block_stride*i]>>1);\n\n\n\n        block[0 + block_stride*i]= z0 + z3;\n\n        block[1 + block_stride*i]= z1 + z2;\n\n        block[2 + block_stride*i]= z1 - z2;\n\n        block[3 + block_stride*i]= z0 - z3;\n\n    }\n\n\n\n    for(i=0; i<4; i++){\n\n        const int z0=  block[i + block_stride*0]     +  block[i + block_stride*2];\n\n        const int z1=  block[i + block_stride*0]     -  block[i + block_stride*2];\n\n        const int z2= (block[i + block_stride*1]>>1) -  block[i + block_stride*3];\n\n        const int z3=  block[i + block_stride*1]     + (block[i + block_stride*3]>>1);\n\n\n\n        dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];\n\n        dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];\n\n        dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];\n\n        dst[i + 3*stride]= cm[ add*dst[i + 3*stride] + ((z0 - z3) >> shift) ];\n\n    }\n\n}\n","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":351826,"func":"Reprog *regcompx(void *(*alloc)(void *ctx, void *p, int n), void *ctx,\n\tconst char *pattern, int cflags, const char **errorp)\n{\n\tstruct cstate g;\n\tRenode *node;\n\tReinst *split, *jump;\n\tint i, n;\n\n\tg.pstart = NULL;\n\tg.prog = NULL;\n\n\tif (setjmp(g.kaboom)) {\n\t\tif (errorp) *errorp = g.error;\n\t\talloc(ctx, g.pstart, 0);\n\t\talloc(ctx, g.prog, 0);\n\t\treturn NULL;\n\t}\n\n\tg.prog = alloc(ctx, NULL, sizeof (Reprog));\n\tif (!g.prog)\n\t\tdie(&g, \"cannot allocate regular expression\");\n\tn = strlen(pattern) * 2;\n\tif (n > REG_MAXPROG)\n\t\tdie(&g, \"program too large\");\n\tif (n > 0) {\n\t\tg.pstart = g.pend = alloc(ctx, NULL, sizeof (Renode) * n);\n\t\tif (!g.pstart)\n\t\t\tdie(&g, \"cannot allocate regular expression parse list\");\n\t}\n\n\tg.source = pattern;\n\tg.ncclass = 0;\n\tg.nsub = 1;\n\tfor (i = 0; i < REG_MAXSUB; ++i)\n\t\tg.sub[i] = 0;\n\n\tg.prog->flags = cflags;\n\n\tnext(&g);\n\tnode = parsealt(&g);\n\tif (g.lookahead == ')')\n\t\tdie(&g, \"unmatched ')'\");\n\tif (g.lookahead != EOF)\n\t\tdie(&g, \"syntax error\");\n\n#ifdef TEST\n\tdumpnode(node);\n\tputchar('\\n');\n#endif\n\n\tn = 6 + count(&g, node);\n\tif (n < 0 || n > REG_MAXPROG)\n\t\tdie(&g, \"program too large\");\n\n\tg.prog->nsub = g.nsub;\n\tg.prog->start = g.prog->end = alloc(ctx, NULL, n * sizeof (Reinst));\n\tif (!g.prog->start)\n\t\tdie(&g, \"cannot allocate regular expression instruction list\");\n\n\tsplit = emit(g.prog, I_SPLIT);\n\tsplit->x = split + 3;\n\tsplit->y = split + 1;\n\temit(g.prog, I_ANYNL);\n\tjump = emit(g.prog, I_JUMP);\n\tjump->x = split;\n\temit(g.prog, I_LPAR);\n\tcompile(g.prog, node);\n\temit(g.prog, I_RPAR);\n\temit(g.prog, I_END);\n\n#ifdef TEST\n\tdumpprog(g.prog);\n#endif\n\n\talloc(ctx, g.pstart, 0);\n\n\tif (errorp) *errorp = NULL;\n\treturn g.prog;\n}","target":1,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":362182,"func":"  event_help( void )\n  {\n    grEvent  dummy_event;\n\n\n    FTDemo_Display_Clear( display );\n    grGotoxy( 0, 0 );\n    grSetMargin( 2, 1 );\n    grGotobitmap( display->bitmap );\n\n    grWriteln( \"FreeType Glyph Viewer - part of the FreeType test suite\" );\n    grLn();\n    grWriteln( \"This program is used to display all glyphs from one or\" );\n    grWriteln( \"several font files, with the FreeType library.\" );\n    grLn();\n    grWriteln( \"Use the following keys:\" );\n    grLn();\n    grWriteln( \"  F1, ?       display this help screen\" );\n    grLn();\n    grWriteln( \"  a           toggle anti-aliasing\" );\n    grWriteln( \"  b           toggle embedded bitmaps\" );\n    grWriteln( \"  c           toggle between cache modes\" );\n    grWriteln( \"  f           toggle forced auto-hinting\" );\n    grWriteln( \"  h           toggle outline hinting\" );\n    grWriteln( \"  l           toggle low precision rendering\" );\n    grLn();\n    grWriteln( \"  L           cycle through LCD modes\" );\n    grWriteln( \"  space       cycle through rendering modes\" );\n    grWriteln( \"  1-6         select rendering mode\" );\n    grLn();\n    grWriteln( \"  e, E        adjust emboldening\" );\n    grWriteln( \"  s, S        adjust slanting\" );\n    grLn();\n    grWriteln( \"  F           toggle custom LCD filter mode\" );\n    grWriteln( \"  [, ]        select custom LCD filter weight\" );\n    grWriteln( \"  -, +(=)     adjust selected custom LCD filter weight\" );\n    grLn();\n    grWriteln( \"  G           show gamma ramp\" );\n    grWriteln( \"  g, v        adjust gamma value\" );\n    grLn();\n    grWriteln( \"  p, n        select previous\/next font\" );\n    grLn();\n    grWriteln( \"  Up, Down    adjust pointsize by 1 unit\" );\n    grWriteln( \"  PgUp, PgDn  adjust pointsize by 10 units\" );\n    grLn();\n    grWriteln( \"  Left, Right adjust index by 1\" );\n    grWriteln( \"  F7, F8      adjust index by 10\" );\n    grWriteln( \"  F9, F10     adjust index by 100\" );\n    grWriteln( \"  F11, F12    adjust index by 1000\" );\n    grLn();\n    grWriteln( \"press any key to exit this help screen\" );\n\n    grRefreshSurface( display->surface );\n    grListenSurface( display->surface, gr_event_key, &dummy_event );\n  }","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":153429,"func":"void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){\n  Table *pNew;\n  Table *pTab;\n  int iDb;\n  int i;\n  int nAlloc;\n  sqlite3 *db = pParse->db;\n\n  \/* Look up the table being altered. *\/\n  assert( pParse->pNewTable==0 );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  if( db->mallocFailed ) goto exit_begin_add_column;\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_begin_add_column;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be altered\");\n    goto exit_begin_add_column;\n  }\n#endif\n\n  \/* Make sure this is not an attempt to ALTER a view. *\/\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a column to a view\");\n    goto exit_begin_add_column;\n  }\n  if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){\n    goto exit_begin_add_column;\n  }\n\n  sqlite3MayAbort(pParse);\n  assert( pTab->addColOffset>0 );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n  \/* Put a copy of the Table struct in Parse.pNewTable for the\n  ** sqlite3AddColumn() function and friends to modify.  But modify\n  ** the name by adding an \"sqlite_altertab_\" prefix.  By adding this\n  ** prefix, we insure that the name will not collide with an existing\n  ** table because user table are not allowed to have the \"sqlite_\"\n  ** prefix on their name.\n  *\/\n  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));\n  if( !pNew ) goto exit_begin_add_column;\n  pParse->pNewTable = pNew;\n  pNew->nTabRef = 1;\n  pNew->nCol = pTab->nCol;\n  assert( pNew->nCol>0 );\n  nAlloc = (((pNew->nCol-1)\/8)*8)+8;\n  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );\n  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);\n  pNew->zName = sqlite3MPrintf(db, \"sqlite_altertab_%s\", pTab->zName);\n  if( !pNew->aCol || !pNew->zName ){\n    assert( db->mallocFailed );\n    goto exit_begin_add_column;\n  }\n  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);\n  for(i=0; i<pNew->nCol; i++){\n    Column *pCol = &pNew->aCol[i];\n    pCol->zName = sqlite3DbStrDup(db, pCol->zName);\n    pCol->zColl = 0;\n    pCol->pDflt = 0;\n  }\n  pNew->pSchema = db->aDb[iDb].pSchema;\n  pNew->addColOffset = pTab->addColOffset;\n  pNew->nTabRef = 1;\n\nexit_begin_add_column:\n  sqlite3SrcListDelete(db, pSrc);\n  return;\n}","target":0,"code_token_length":759,"total_token_length":995,"max_tokens_setting":1024}
+{"idx":134143,"func":"void test_nghttp2_session_set_option(void) {\n  nghttp2_session *session;\n  nghttp2_session_callbacks callbacks;\n  nghttp2_option *option;\n  nghttp2_hd_deflater *deflater;\n  int rv;\n\n  memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));\n  callbacks.send_callback = null_send_callback;\n\n  \/* Test for nghttp2_option_set_no_auto_window_update *\/\n  nghttp2_option_new(&option);\n  nghttp2_option_set_no_auto_window_update(option, 1);\n\n  nghttp2_session_client_new2(&session, &callbacks, NULL, option);\n\n  CU_ASSERT(session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE);\n\n  nghttp2_session_del(session);\n  nghttp2_option_del(option);\n\n  \/* Test for nghttp2_option_set_peer_max_concurrent_streams *\/\n  nghttp2_option_new(&option);\n  nghttp2_option_set_peer_max_concurrent_streams(option, 100);\n\n  nghttp2_session_client_new2(&session, &callbacks, NULL, option);\n\n  CU_ASSERT(100 == session->remote_settings.max_concurrent_streams);\n  nghttp2_session_del(session);\n  nghttp2_option_del(option);\n\n  \/* Test for nghttp2_option_set_max_reserved_remote_streams *\/\n  nghttp2_option_new(&option);\n  nghttp2_option_set_max_reserved_remote_streams(option, 99);\n\n  nghttp2_session_client_new2(&session, &callbacks, NULL, option);\n\n  CU_ASSERT(99 == session->max_incoming_reserved_streams);\n  nghttp2_session_del(session);\n  nghttp2_option_del(option);\n\n  \/* Test for nghttp2_option_set_no_auto_ping_ack *\/\n  nghttp2_option_new(&option);\n  nghttp2_option_set_no_auto_ping_ack(option, 1);\n\n  nghttp2_session_client_new2(&session, &callbacks, NULL, option);\n\n  CU_ASSERT(session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_PING_ACK);\n\n  nghttp2_session_del(session);\n  nghttp2_option_del(option);\n\n  \/* Test for nghttp2_option_set_max_deflate_dynamic_table_size *\/\n  nghttp2_option_new(&option);\n  nghttp2_option_set_max_deflate_dynamic_table_size(option, 0);\n\n  nghttp2_session_client_new2(&session, &callbacks, NULL, option);\n\n  deflater = &session->hd_deflater;\n\n  rv = nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL);\n\n  CU_ASSERT(1 == rv);\n\n  rv = nghttp2_session_send(session);\n\n  CU_ASSERT(0 == rv);\n  CU_ASSERT(0 == deflater->deflate_hd_table_bufsize_max);\n  CU_ASSERT(0 == deflater->ctx.hd_table_bufsize);\n\n  nghttp2_session_del(session);\n  nghttp2_option_del(option);\n}","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":37492,"func":"TEST_F(RouterTest, RetryUpstream5xx) {\n  NiceMock<Http::MockRequestEncoder> encoder1;\n  Http::ResponseDecoder* response_decoder = nullptr;\n  expectNewStreamWithImmediateEncoder(encoder1, &response_decoder, Http::Protocol::Http10);\n\n  expectResponseTimerCreate();\n\n  Http::TestRequestHeaderMapImpl headers{{\"x-envoy-retry-on\", \"5xx\"}, {\"x-envoy-internal\", \"true\"}};\n  HttpTestUtility::addDefaultHeaders(headers);\n  router_.decodeHeaders(headers, true);\n  EXPECT_EQ(1U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n\n  \/\/ 5xx response.\n  router_.retry_state_->expectHeadersRetry();\n  Http::ResponseHeaderMapPtr response_headers1(\n      new Http::TestResponseHeaderMapImpl{{\":status\", \"503\"}});\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,\n              putHttpResponseCode(503));\n  response_decoder->decodeHeaders(std::move(response_headers1), true);\n  EXPECT_TRUE(verifyHostUpstreamStats(0, 1));\n\n  \/\/ We expect the 5xx response to kick off a new request.\n  EXPECT_CALL(encoder1.stream_, resetStream(_)).Times(0);\n  NiceMock<Http::MockRequestEncoder> encoder2;\n  expectNewStreamWithImmediateEncoder(encoder2, &response_decoder, Http::Protocol::Http10);\n\n  router_.retry_state_->callback_();\n  EXPECT_EQ(2U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n\n  \/\/ Normal response.\n  EXPECT_CALL(*router_.retry_state_, shouldRetryHeaders(_, _, _)).WillOnce(Return(RetryStatus::No));\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->health_checker_, setUnhealthy(_))\n      .Times(0);\n  Http::ResponseHeaderMapPtr response_headers2(\n      new Http::TestResponseHeaderMapImpl{{\":status\", \"200\"}});\n  EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,\n              putHttpResponseCode(200));\n  response_decoder->decodeHeaders(std::move(response_headers2), true);\n  EXPECT_TRUE(verifyHostUpstreamStats(1, 1));\n}","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":20474,"func":"int fill_schema_table_privileges ( THD * thd , TABLE_LIST * tables , COND * cond ) {\n # ifndef NO_EMBEDDED_ACCESS_CHECKS int error = 0 ;\n uint index ;\n char buff [ 100 ] ;\n TABLE * table = tables -> table ;\n bool no_global_access = check_access ( thd , SELECT_ACL , \"mysql\" , 0 , 1 , 1 , 0 ) ;\n char * curr_host = thd -> security_ctx -> priv_host_name ( ) ;\n DBUG_ENTER ( \"fill_schema_table_privileges\" ) ;\n rw_rdlock ( & LOCK_grant ) ;\n for ( index = 0 ;\n index < column_priv_hash . records ;\n index ++ ) {\n const char * user , * host , * is_grantable = \"YES\" ;\n GRANT_TABLE * grant_table = ( GRANT_TABLE * ) hash_element ( & column_priv_hash , index ) ;\n if ( ! ( user = grant_table -> user ) ) user = \"\" ;\n if ( ! ( host = grant_table -> host . hostname ) ) host = \"\" ;\n if ( no_global_access && ( strcmp ( thd -> security_ctx -> priv_user , user ) || my_strcasecmp ( system_charset_info , curr_host , host ) ) ) continue ;\n ulong table_access = grant_table -> privs ;\n if ( table_access ) {\n ulong test_access = table_access & ~ GRANT_ACL ;\n if ( ! test_access && grant_table -> cols ) continue ;\n if ( ! ( table_access & GRANT_ACL ) ) is_grantable = \"NO\" ;\n strxmov ( buff , \"'\" , user , \"'@'\" , host , \"'\" , NullS ) ;\n if ( ! test_access ) {\n if ( update_schema_privilege ( thd , table , buff , grant_table -> db , grant_table -> tname , 0 , 0 , STRING_WITH_LEN ( \"USAGE\" ) , is_grantable ) ) {\n error = 1 ;\n goto err ;\n }\n }\n else {\n ulong j ;\n int cnt ;\n for ( cnt = 0 , j = SELECT_ACL ;\n j <= TABLE_ACLS ;\n cnt ++ , j <<= 1 ) {\n if ( test_access & j ) {\n if ( update_schema_privilege ( thd , table , buff , grant_table -> db , grant_table -> tname , 0 , 0 , command_array [ cnt ] , command_lengths [ cnt ] , is_grantable ) ) {\n error = 1 ;\n goto err ;\n }\n }\n }\n }\n }\n }\n err : rw_unlock ( & LOCK_grant ) ;\n DBUG_RETURN ( error ) ;\n # else return ( 0 ) ;\n # endif }","target":0,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":347050,"func":"secret (gcry_mpi_t output, gcry_mpi_t input, RSA_secret_key *skey )\n{\n  \/* Remove superfluous leading zeroes from INPUT.  *\/\n  mpi_normalize (input);\n\n  if (!skey->p || !skey->q || !skey->u)\n    {\n      mpi_powm (output, input, skey->d, skey->n);\n    }\n  else\n    {\n      gcry_mpi_t m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );\n      gcry_mpi_t m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );\n      gcry_mpi_t h  = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );\n\n      \/* m1 = c ^ (d mod (p-1)) mod p *\/\n      mpi_sub_ui( h, skey->p, 1  );\n      mpi_fdiv_r( h, skey->d, h );\n      mpi_powm( m1, input, h, skey->p );\n      \/* m2 = c ^ (d mod (q-1)) mod q *\/\n      mpi_sub_ui( h, skey->q, 1  );\n      mpi_fdiv_r( h, skey->d, h );\n      mpi_powm( m2, input, h, skey->q );\n      \/* h = u * ( m2 - m1 ) mod q *\/\n      mpi_sub( h, m2, m1 );\n      if ( mpi_has_sign ( h ) )\n        mpi_add ( h, h, skey->q );\n      mpi_mulm( h, skey->u, h, skey->q );\n      \/* m = m1 + h * p *\/\n      mpi_mul ( h, h, skey->p );\n      mpi_add ( output, m1, h );\n\n      mpi_free ( h );\n      mpi_free ( m1 );\n      mpi_free ( m2 );\n    }\n}","target":1,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":84207,"func":"static struct fib6_node * fib6_lookup_1(struct fib6_node *root,\n\t\t\t\t\tstruct lookup_args *args)\n{\n\tstruct fib6_node *fn;\n\t__be32 dir;\n\n\tif (unlikely(args->offset == 0))\n\t\treturn NULL;\n\n\t\/*\n\t *\tDescend on a tree\n\t *\/\n\n\tfn = root;\n\n\tfor (;;) {\n\t\tstruct fib6_node *next;\n\n\t\tdir = addr_bit_set(args->addr, fn->fn_bit);\n\n\t\tnext = dir ? fn->right : fn->left;\n\n\t\tif (next) {\n\t\t\tfn = next;\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\n\twhile (fn) {\n\t\tif (FIB6_SUBTREE(fn) || fn->fn_flags & RTN_RTINFO) {\n\t\t\tstruct rt6key *key;\n\n\t\t\tkey = (struct rt6key *) ((u8 *) fn->leaf +\n\t\t\t\t\t\t args->offset);\n\n\t\t\tif (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) {\n#ifdef CONFIG_IPV6_SUBTREES\n\t\t\t\tif (fn->subtree) {\n\t\t\t\t\tstruct fib6_node *sfn;\n\t\t\t\t\tsfn = fib6_lookup_1(fn->subtree,\n\t\t\t\t\t\t\t    args + 1);\n\t\t\t\t\tif (!sfn)\n\t\t\t\t\t\tgoto backtrack;\n\t\t\t\t\tfn = sfn;\n\t\t\t\t}\n#endif\n\t\t\t\tif (fn->fn_flags & RTN_RTINFO)\n\t\t\t\t\treturn fn;\n\t\t\t}\n\t\t}\n#ifdef CONFIG_IPV6_SUBTREES\nbacktrack:\n#endif\n\t\tif (fn->fn_flags & RTN_ROOT)\n\t\t\tbreak;\n\n\t\tfn = fn->parent;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":102115,"func":"irda_queue_t *hashbin_get_next( hashbin_t *hashbin)\n{\n\tirda_queue_t* entry;\n\tint bin;\n\tint i;\n\n\tIRDA_ASSERT( hashbin != NULL, return NULL;);\n\tIRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);\n\n\tif ( hashbin->hb_current == NULL) {\n\t\tIRDA_ASSERT( hashbin->hb_current != NULL, return NULL;);\n\t\treturn NULL;\n\t}\n\tentry = hashbin->hb_current->q_next;\n\tbin = GET_HASHBIN( entry->q_hash);\n\n\t\/*\n\t *  Make sure that we are not back at the beginning of the queue\n\t *  again\n\t *\/\n\tif ( entry != hashbin->hb_queue[ bin ]) {\n\t\thashbin->hb_current = entry;\n\n\t\treturn entry;\n\t}\n\n\t\/*\n\t *  Check that this is not the last queue in hashbin\n\t *\/\n\tif ( bin >= HASHBIN_SIZE)\n\t\treturn NULL;\n\n\t\/*\n\t *  Move to next queue in hashbin\n\t *\/\n\tbin++;\n\tfor ( i = bin; i < HASHBIN_SIZE; i++ ) {\n\t\tentry = hashbin->hb_queue[ i];\n\t\tif ( entry) {\n\t\t\thashbin->hb_current = entry;\n\n\t\t\treturn entry;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":325250,"func":"static void net_socket_send(void *opaque)\n\n{\n\n    NetSocketState *s = opaque;\n\n    int l, size, err;\n\n    uint8_t buf1[4096];\n\n    const uint8_t *buf;\n\n\n\n    size = recv(s->fd, buf1, sizeof(buf1), 0);\n\n    if (size < 0) {\n\n        err = socket_error();\n\n        if (err != EWOULDBLOCK)\n\n            goto eoc;\n\n    } else if (size == 0) {\n\n        \/* end of connection *\/\n\n    eoc:\n\n        qemu_set_fd_handler(s->fd, NULL, NULL, NULL);\n\n        closesocket(s->fd);\n\n        return;\n\n    }\n\n    buf = buf1;\n\n    while (size > 0) {\n\n        \/* reassemble a packet from the network *\/\n\n        switch(s->state) {\n\n        case 0:\n\n            l = 4 - s->index;\n\n            if (l > size)\n\n                l = size;\n\n            memcpy(s->buf + s->index, buf, l);\n\n            buf += l;\n\n            size -= l;\n\n            s->index += l;\n\n            if (s->index == 4) {\n\n                \/* got length *\/\n\n                s->packet_len = ntohl(*(uint32_t *)s->buf);\n\n                s->index = 0;\n\n                s->state = 1;\n\n            }\n\n            break;\n\n        case 1:\n\n            l = s->packet_len - s->index;\n\n            if (l > size)\n\n                l = size;\n\n            memcpy(s->buf + s->index, buf, l);\n\n            s->index += l;\n\n            buf += l;\n\n            size -= l;\n\n            if (s->index >= s->packet_len) {\n\n                qemu_send_packet(s->vc, s->buf, s->packet_len);\n\n                s->index = 0;\n\n                s->state = 0;\n\n            }\n\n            break;\n\n        }\n\n    }\n\n}\n","target":1,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":209914,"func":"static float lite_font_stringwidth( wmfAPI* API, wmfFont* font, char* str)\n{\n#if 0\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  Image\n    *image = ddata->image;\n\n  DrawInfo\n    *draw_info;\n\n  TypeMetric\n    metrics;\n\n  float\n    stringwidth = 0;\n\n  double\n    orig_x_resolution,\n    orig_y_resolution;\n\n  ResolutionType\n    orig_resolution_units;\n\n  orig_x_resolution = image->x_resolution;\n  orig_y_resolution = image->y_resolution;\n  orig_resolution_units = image->units;\n\n  draw_info=ddata->draw_info;\n  if (draw_info == (const DrawInfo *) NULL)\n    return 0;\n\n  draw_info->font=WMF_FONT_PSNAME(font);\n  draw_info->pointsize=12;\n  draw_info->text=str;\n\n  image->x_resolution = 72;\n  image->y_resolution = 72;\n  image->units = PixelsPerInchResolution;\n\n  if (GetTypeMetrics(image, draw_info, &metrics) != MagickFalse)\n    stringwidth = ((metrics.width * 72)\/(image->x_resolution * draw_info->pointsize)); \/* *0.916348; *\/\n\n  draw_info->font=NULL;\n  draw_info->text=NULL;\n\n#if 0\n  printf(\"\\nlite_font_stringwidth\\n\");\n  printf(\"string                  = \\\"%s\\\"\\n\", str);\n  printf(\"WMF_FONT_NAME           = \\\"%s\\\"\\n\", WMF_FONT_NAME(font));\n  printf(\"WMF_FONT_PSNAME         = \\\"%s\\\"\\n\", WMF_FONT_PSNAME(font));\n  printf(\"stringwidth             = %g\\n\", stringwidth);\n  \/* printf(\"WMF_FONT_HEIGHT         = %i\\n\", (int)WMF_FONT_HEIGHT(font)); *\/\n  \/* printf(\"WMF_FONT_WIDTH          = %i\\n\", (int)WMF_FONT_WIDTH(font)); *\/\n  fflush(stdout);\n#endif\n\n  image->x_resolution = orig_x_resolution;\n  image->y_resolution = orig_y_resolution;\n  image->units = orig_resolution_units;\n\n  return stringwidth;\n#else\n  (void) API;\n  (void) font;\n  (void) str;\n\n  return 0;\n#endif\n}\n","target":0,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":296971,"func":"static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,\n\t\t\t   int len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_nfc *addr = (struct sockaddr_nfc *)_addr;\n\tstruct nfc_dev *dev;\n\tint rc = 0;\n\n\tpr_debug(\"sock=%p sk=%p flags=%d\\n\", sock, sk, flags);\n\n\tif (!addr || len < sizeof(struct sockaddr_nfc) ||\n\t    addr->sa_family != AF_NFC)\n\t\treturn -EINVAL;\n\n\tpr_debug(\"addr dev_idx=%u target_idx=%u protocol=%u\\n\",\n\t\t addr->dev_idx, addr->target_idx, addr->nfc_protocol);\n\n\tlock_sock(sk);\n\n\tif (sock->state == SS_CONNECTED) {\n\t\trc = -EISCONN;\n\t\tgoto error;\n\t}\n\n\tdev = nfc_get_device(addr->dev_idx);\n\tif (!dev) {\n\t\trc = -ENODEV;\n\t\tgoto error;\n\t}\n\n\tif (addr->target_idx > dev->target_next_idx - 1 ||\n\t    addr->target_idx < dev->target_next_idx - dev->n_targets) {\n\t\trc = -EINVAL;\n\t\tgoto error;\n\t}\n\n\trc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);\n\tif (rc)\n\t\tgoto put_dev;\n\n\tnfc_rawsock(sk)->dev = dev;\n\tnfc_rawsock(sk)->target_idx = addr->target_idx;\n\tsock->state = SS_CONNECTED;\n\tsk->sk_state = TCP_ESTABLISHED;\n\tsk->sk_state_change(sk);\n\n\trelease_sock(sk);\n\treturn 0;\n\nput_dev:\n\tnfc_put_device(dev);\nerror:\n\trelease_sock(sk);\n\treturn rc;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":416934,"func":"static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,\n\t\t\t   u32 session_id, u32 peer_session_id,\n\t\t\t   struct l2tp_session_cfg *cfg)\n{\n\tunsigned char name_assign_type;\n\tstruct net_device *dev;\n\tchar name[IFNAMSIZ];\n\tstruct l2tp_session *session;\n\tstruct l2tp_eth *priv;\n\tstruct l2tp_eth_sess *spriv;\n\tint rc;\n\tstruct l2tp_eth_net *pn;\n\n\tif (cfg->ifname) {\n\t\tstrlcpy(name, cfg->ifname, IFNAMSIZ);\n\t\tname_assign_type = NET_NAME_USER;\n\t} else {\n\t\tstrcpy(name, L2TP_ETH_DEV_NAME);\n\t\tname_assign_type = NET_NAME_ENUM;\n\t}\n\n\tsession = l2tp_session_create(sizeof(*spriv), tunnel, session_id,\n\t\t\t\t      peer_session_id, cfg);\n\tif (IS_ERR(session)) {\n\t\trc = PTR_ERR(session);\n\t\tgoto out;\n\t}\n\n\tdev = alloc_netdev(sizeof(*priv), name, name_assign_type,\n\t\t\t   l2tp_eth_dev_setup);\n\tif (!dev) {\n\t\trc = -ENOMEM;\n\t\tgoto out_del_session;\n\t}\n\n\tdev_net_set(dev, net);\n\tdev->min_mtu = 0;\n\tdev->max_mtu = ETH_MAX_MTU;\n\tl2tp_eth_adjust_mtu(tunnel, session, dev);\n\n\tpriv = netdev_priv(dev);\n\tpriv->dev = dev;\n\tpriv->session = session;\n\tINIT_LIST_HEAD(&priv->list);\n\n\tpriv->tunnel_sock = tunnel->sock;\n\tsession->recv_skb = l2tp_eth_dev_recv;\n\tsession->session_close = l2tp_eth_delete;\n#if IS_ENABLED(CONFIG_L2TP_DEBUGFS)\n\tsession->show = l2tp_eth_show;\n#endif\n\n\tspriv = l2tp_session_priv(session);\n\tspriv->dev = dev;\n\n\trc = register_netdev(dev);\n\tif (rc < 0)\n\t\tgoto out_del_dev;\n\n\t__module_get(THIS_MODULE);\n\t\/* Must be done after register_netdev() *\/\n\tstrlcpy(session->ifname, dev->name, IFNAMSIZ);\n\n\tdev_hold(dev);\n\tpn = l2tp_eth_pernet(dev_net(dev));\n\tspin_lock(&pn->l2tp_eth_lock);\n\tlist_add(&priv->list, &pn->l2tp_eth_dev_list);\n\tspin_unlock(&pn->l2tp_eth_lock);\n\n\treturn 0;\n\nout_del_dev:\n\tfree_netdev(dev);\n\tspriv->dev = NULL;\nout_del_session:\n\tl2tp_session_delete(session);\nout:\n\treturn rc;\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":16613,"func":"static int dsa_pub_encode ( X509_PUBKEY * pk , const EVP_PKEY * pkey ) {\n DSA * dsa ;\n int ptype ;\n unsigned char * penc = NULL ;\n int penclen ;\n ASN1_STRING * str = NULL ;\n ASN1_INTEGER * pubint = NULL ;\n dsa = pkey -> pkey . dsa ;\n if ( pkey -> save_parameters && dsa -> p && dsa -> q && dsa -> g ) {\n str = ASN1_STRING_new ( ) ;\n if ( str == NULL ) {\n DSAerr ( DSA_F_DSA_PUB_ENCODE , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n str -> length = i2d_DSAparams ( dsa , & str -> data ) ;\n if ( str -> length <= 0 ) {\n DSAerr ( DSA_F_DSA_PUB_ENCODE , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n ptype = V_ASN1_SEQUENCE ;\n }\n else ptype = V_ASN1_UNDEF ;\n pubint = BN_to_ASN1_INTEGER ( dsa -> pub_key , NULL ) ;\n if ( pubint == NULL ) {\n DSAerr ( DSA_F_DSA_PUB_ENCODE , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n penclen = i2d_ASN1_INTEGER ( pubint , & penc ) ;\n ASN1_INTEGER_free ( pubint ) ;\n if ( penclen <= 0 ) {\n DSAerr ( DSA_F_DSA_PUB_ENCODE , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n if ( X509_PUBKEY_set0_param ( pk , OBJ_nid2obj ( EVP_PKEY_DSA ) , ptype , str , penc , penclen ) ) return 1 ;\n err : OPENSSL_free ( penc ) ;\n ASN1_STRING_free ( str ) ;\n return 0 ;\n }","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":328292,"func":"static void vnc_connect(VncDisplay *vd, int csock,\n\n                        bool skipauth, bool websocket)\n\n{\n\n    VncState *vs = g_malloc0(sizeof(VncState));\n\n    int i;\n\n\n\n    vs->csock = csock;\n\n    vs->vd = vd;\n\n\n\n    if (skipauth) {\n\n\tvs->auth = VNC_AUTH_NONE;\n\n\tvs->subauth = VNC_AUTH_INVALID;\n\n    } else {\n\n        if (websocket) {\n\n            vs->auth = vd->ws_auth;\n\n            vs->subauth = VNC_AUTH_INVALID;\n\n        } else {\n\n            vs->auth = vd->auth;\n\n            vs->subauth = vd->subauth;\n\n        }\n\n    }\n\n    VNC_DEBUG(\"Client sock=%d ws=%d auth=%d subauth=%d\\n\",\n\n              csock, websocket, vs->auth, vs->subauth);\n\n\n\n    vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));\n\n    for (i = 0; i < VNC_STAT_ROWS; ++i) {\n\n        vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));\n\n    }\n\n\n\n    VNC_DEBUG(\"New client on socket %d\\n\", csock);\n\n    update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);\n\n    qemu_set_nonblock(vs->csock);\n\n#ifdef CONFIG_VNC_WS\n\n    if (websocket) {\n\n        vs->websocket = 1;\n\n#ifdef CONFIG_VNC_TLS\n\n        if (vd->ws_tls) {\n\n            qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs);\n\n        } else\n\n#endif \/* CONFIG_VNC_TLS *\/\n\n        {\n\n            qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs);\n\n        }\n\n    } else\n\n#endif \/* CONFIG_VNC_WS *\/\n\n    {\n\n        qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs);\n\n    }\n\n\n\n    vnc_client_cache_addr(vs);\n\n    vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED);\n\n    vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING);\n\n\n\n#ifdef CONFIG_VNC_WS\n\n    if (!vs->websocket)\n\n#endif\n\n    {\n\n        vnc_init_state(vs);\n\n    }\n\n\n\n    if (vd->num_connecting > vd->connections_limit) {\n\n        QTAILQ_FOREACH(vs, &vd->clients, next) {\n\n            if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) {\n\n                vnc_disconnect_start(vs);\n\n                return;\n\n            }\n\n        }\n\n    }\n\n}\n","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":8824,"func":"cib_recv_plaintext(int sock)\n{\n    char *buf = NULL;\n\n    ssize_t rc = 0;\n    ssize_t len = 0;\n    ssize_t chunk_size = 512;\n\n    buf = calloc(1, chunk_size);\n\n    while (1) {\n        errno = 0;\n        rc = read(sock, buf + len, chunk_size);\n        crm_trace(\"Got %d more bytes. errno=%d\", (int)rc, errno);\n\n        if (errno == EINTR || errno == EAGAIN) {\n            crm_trace(\"Retry: %d\", (int)rc);\n            if (rc > 0) {\n                len += rc;\n                buf = realloc(buf, len + chunk_size);\n                CRM_ASSERT(buf != NULL);\n            }\n\n        } else if (rc < 0) {\n            crm_perror(LOG_ERR, \"Error receiving message: %d\", (int)rc);\n            goto bail;\n\n        } else if (rc == chunk_size) {\n            len += rc;\n            chunk_size *= 2;\n            buf = realloc(buf, len + chunk_size);\n            crm_trace(\"Retry with %d more bytes\", (int)chunk_size);\n            CRM_ASSERT(buf != NULL);\n\n        } else if (buf[len + rc - 1] != 0) {\n            crm_trace(\"Last char is %d '%c'\", buf[len + rc - 1], buf[len + rc - 1]);\n            crm_trace(\"Retry with %d more bytes\", (int)chunk_size);\n            len += rc;\n            buf = realloc(buf, len + chunk_size);\n            CRM_ASSERT(buf != NULL);\n\n        } else {\n            return buf;\n        }\n    }\n  bail:\n    free(buf);\n    return NULL;\n\n}","target":1,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":61643,"func":"cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu)\n{\n    cmsMLU* NewMlu = NULL;\n\n    \/\/ Duplicating a NULL obtains a NULL\n    if (mlu == NULL) return NULL;\n\n    NewMlu = cmsMLUalloc(mlu ->ContextID, mlu ->UsedEntries);\n    if (NewMlu == NULL) return NULL;\n\n    \/\/ Should never happen\n    if (NewMlu ->AllocatedEntries < mlu ->UsedEntries)\n        goto Error;\n\n    \/\/ Sanitize...\n    if (NewMlu ->Entries == NULL || mlu ->Entries == NULL)  goto Error;\n\n    memmove(NewMlu ->Entries, mlu ->Entries, mlu ->UsedEntries * sizeof(_cmsMLUentry));\n    NewMlu ->UsedEntries = mlu ->UsedEntries;\n\n    \/\/ The MLU may be empty\n    if (mlu ->PoolUsed == 0) {\n        NewMlu ->MemPool = NULL;\n    }\n    else {\n        \/\/ It is not empty\n        NewMlu ->MemPool = _cmsMalloc(mlu ->ContextID, mlu ->PoolUsed);\n        if (NewMlu ->MemPool == NULL) goto Error;\n    }\n\n    NewMlu ->PoolSize = mlu ->PoolUsed;\n\n    if (NewMlu ->MemPool == NULL || mlu ->MemPool == NULL) goto Error;\n\n    memmove(NewMlu ->MemPool, mlu->MemPool, mlu ->PoolUsed);\n    NewMlu ->PoolUsed = mlu ->PoolUsed;\n\n    return NewMlu;\n\nError:\n\n    if (NewMlu != NULL) cmsMLUfree(NewMlu);\n    return NULL;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":394558,"func":"write_iso9660_data(struct archive_write *a, const void *buff, size_t s)\n{\n\tstruct iso9660 *iso9660 = a->format_data;\n\tsize_t ws;\n\n\tif (iso9660->temp_fd < 0) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t    \"Couldn't create temporary file\");\n\t\treturn (ARCHIVE_FATAL);\n\t}\n\n\tws = s;\n\tif (iso9660->need_multi_extent &&\n\t    (iso9660->cur_file->cur_content->size + ws) >=\n\t      (MULTI_EXTENT_SIZE - LOGICAL_BLOCK_SIZE)) {\n\t\tstruct content *con;\n\t\tsize_t ts;\n\n\t\tts = (size_t)(MULTI_EXTENT_SIZE - LOGICAL_BLOCK_SIZE -\n\t\t    iso9660->cur_file->cur_content->size);\n\n\t\tif (iso9660->zisofs.detect_magic)\n\t\t\tzisofs_detect_magic(a, buff, ts);\n\n\t\tif (iso9660->zisofs.making) {\n\t\t\tif (zisofs_write_to_temp(a, buff, ts) != ARCHIVE_OK)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t} else {\n\t\t\tif (wb_write_to_temp(a, buff, ts) != ARCHIVE_OK)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\tiso9660->cur_file->cur_content->size += ts;\n\t\t}\n\n\t\t\/* Write padding. *\/\n\t\tif (wb_write_padding_to_temp(a,\n\t\t    iso9660->cur_file->cur_content->size) != ARCHIVE_OK)\n\t\t\treturn (ARCHIVE_FATAL);\n\n\t\t\/* Compute the logical block number. *\/\n\t\tiso9660->cur_file->cur_content->blocks = (int)\n\t\t    ((iso9660->cur_file->cur_content->size\n\t\t     + LOGICAL_BLOCK_SIZE -1) >> LOGICAL_BLOCK_BITS);\n\n\t\t\/*\n\t\t * Make next extent.\n\t\t *\/\n\t\tws -= ts;\n\t\tbuff = (const void *)(((const unsigned char *)buff) + ts);\n\t\t\/* Make a content for next extent. *\/\n\t\tcon = calloc(1, sizeof(*con));\n\t\tif (con == NULL) {\n\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t    \"Can't allocate content data\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tcon->offset_of_temp = wb_offset(a);\n\t\tiso9660->cur_file->cur_content->next = con;\n\t\tiso9660->cur_file->cur_content = con;\n#ifdef HAVE_ZLIB_H\n\t\tiso9660->zisofs.block_offset = 0;\n#endif\n\t}\n\n\tif (iso9660->zisofs.detect_magic)\n\t\tzisofs_detect_magic(a, buff, ws);\n\n\tif (iso9660->zisofs.making) {\n\t\tif (zisofs_write_to_temp(a, buff, ws) != ARCHIVE_OK)\n\t\t\treturn (ARCHIVE_FATAL);\n\t} else {\n\t\tif (wb_write_to_temp(a, buff, ws) != ARCHIVE_OK)\n\t\t\treturn (ARCHIVE_FATAL);\n\t\tiso9660->cur_file->cur_content->size += ws;\n\t}\n\n\treturn (s);\n}","target":0,"code_token_length":702,"total_token_length":938,"max_tokens_setting":1024}
+{"idx":488907,"func":"static Bool ctxload_process_event(GF_Filter *filter, const GF_FilterEvent *com)\n{\n\tu32 count, i;\n\tCTXLoadPriv *priv = gf_filter_get_udta(filter);\n\t\/\/check for scene attach\n\tswitch (com->base.type) {\n\tcase GF_FEVT_PLAY:\n\t\t\/\/cancel play event, we work with full file\n\t\t\/\/TODO: animation stream in BT\n\t\tpriv->is_playing = GF_TRUE;\n\t\treturn GF_TRUE;\n\tcase GF_FEVT_ATTACH_SCENE:\n\t\tbreak;\n\tcase GF_FEVT_RESET_SCENE:\n\t\tgf_sm_load_done(&priv->load);\n\t\tif (priv->ctx) gf_sm_del(priv->ctx);\n\t\tpriv->ctx = NULL;\n\t\tpriv->load_flags = 3;\n\t\treturn GF_FALSE;\n\tdefault:\n\t\treturn GF_FALSE;\n\t}\n\tif (!com->attach_scene.on_pid) return GF_TRUE;\n\n\tcount = gf_filter_get_ipid_count(filter);\n\tfor (i=0; i<count; i++) {\n\t\tGF_FilterPid *ipid = gf_filter_get_ipid(filter, i);\n\t\tGF_FilterPid *opid = gf_filter_pid_get_udta(ipid);\n\t\t\/\/we found our pid, set it up\n\t\tif (opid == com->attach_scene.on_pid) {\n\t\t\tif (!priv->scene) {\n\t\t\t\tGF_ObjectManager *odm = com->attach_scene.object_manager;\n\t\t\t\tpriv->scene = odm->subscene ? odm->subscene : odm->parentscene;\n\t\t\t\tgf_sg_set_node_callback(priv->scene->graph, CTXLoad_NodeCallback);\n\n\t\t\t\tpriv->service_url = odm->scene_ns->url;\n\n\t\t\t\tif (!priv->ctx)\tCTXLoad_Setup(filter, priv);\n\n\t\t\t}\n\t\t\treturn GF_TRUE;\n\t\t}\n\t}\n\n\treturn GF_FALSE;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":389442,"func":"void cgit_print_docstart(void)\n{\n\tif (ctx.cfg.embedded) {\n\t\tif (ctx.cfg.header)\n\t\t\thtml_include(ctx.cfg.header);\n\t\treturn;\n\t}\n\n\tchar *host = cgit_hosturl();\n\thtml(cgit_doctype);\n\thtml(\"<html xmlns='http:\/\/www.w3.org\/1999\/xhtml' xml:lang='en' lang='en'>\\n\");\n\thtml(\"<head>\\n\");\n\thtml(\"<title>\");\n\thtml_txt(ctx.page.title);\n\thtml(\"<\/title>\\n\");\n\thtmlf(\"<meta name='generator' content='cgit %s'\/>\\n\", cgit_version);\n\tif (ctx.cfg.robots && *ctx.cfg.robots)\n\t\thtmlf(\"<meta name='robots' content='%s'\/>\\n\", ctx.cfg.robots);\n\thtml(\"<link rel='stylesheet' type='text\/css' href='\");\n\thtml_attr(ctx.cfg.css);\n\thtml(\"'\/>\\n\");\n\tif (ctx.cfg.favicon) {\n\t\thtml(\"<link rel='shortcut icon' href='\");\n\t\thtml_attr(ctx.cfg.favicon);\n\t\thtml(\"'\/>\\n\");\n\t}\n\tif (host && ctx.repo && ctx.qry.head) {\n\t\tchar *fileurl;\n\t\tstruct strbuf sb = STRBUF_INIT;\n\t\tstrbuf_addf(&sb, \"h=%s\", ctx.qry.head);\n\n\t\thtml(\"<link rel='alternate' title='Atom feed' href='\");\n\t\thtml(cgit_httpscheme());\n\t\thtml_attr(host);\n\t\tfileurl = cgit_fileurl(ctx.repo->url, \"atom\", ctx.qry.vpath,\n\t\t\t\t       sb.buf);\n\t\thtml_attr(fileurl);\n\t\thtml(\"' type='application\/atom+xml'\/>\\n\");\n\t\tstrbuf_release(&sb);\n\t\tfree(fileurl);\n\t}\n\tif (ctx.repo)\n\t\tcgit_add_clone_urls(print_rel_vcs_link);\n\tif (ctx.cfg.head_include)\n\t\thtml_include(ctx.cfg.head_include);\n\thtml(\"<\/head>\\n\");\n\thtml(\"<body>\\n\");\n\tif (ctx.cfg.header)\n\t\thtml_include(ctx.cfg.header);\n\tfree(host);\n}","target":0,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":32415,"func":"create_schema(MYSQL *mysql, const char *db, statement *stmt, \n              option_string *engine_stmt)\n{\n  char query[HUGE_STRING_LENGTH];\n  statement *ptr;\n  statement *after_create;\n  int len;\n  ulonglong count;\n  DBUG_ENTER(\"create_schema\");\n\n  len= snprintf(query, HUGE_STRING_LENGTH, \"CREATE SCHEMA `%s`\", db);\n\n  if (verbose >= 2)\n    printf(\"Loading Pre-data\\n\");\n\n  if (run_query(mysql, query, len))\n  {\n    fprintf(stderr,\"%s: Cannot create schema %s : %s\\n\", my_progname, db,\n            mysql_error(mysql));\n    exit(1);\n  }\n\n  if (opt_only_print)\n  {\n    printf(\"use %s;\\n\", db);\n  }\n  else\n  {\n    if (verbose >= 3)\n      printf(\"%s;\\n\", query);\n\n    if (mysql_select_db(mysql,  db))\n    {\n      fprintf(stderr,\"%s: Cannot select schema '%s': %s\\n\",my_progname, db,\n              mysql_error(mysql));\n      exit(1);\n    }\n  }\n\n  if (engine_stmt)\n  {\n    len= snprintf(query, HUGE_STRING_LENGTH, \"set storage_engine=`%s`\",\n                  engine_stmt->string);\n    if (run_query(mysql, query, len))\n    {\n      fprintf(stderr,\"%s: Cannot set default engine: %s\\n\", my_progname,\n              mysql_error(mysql));\n      exit(1);\n    }\n  }\n\n  count= 0;\n  after_create= stmt;\n\nlimit_not_met:\n  for (ptr= after_create; ptr && ptr->length; ptr= ptr->next, count++)\n  {\n    if (auto_generate_sql && ( auto_generate_sql_number == count))\n      break;\n\n    if (engine_stmt && engine_stmt->option && ptr->type == CREATE_TABLE_TYPE)\n    {\n      char buffer[HUGE_STRING_LENGTH];\n\n      snprintf(buffer, HUGE_STRING_LENGTH, \"%s %s\", ptr->string, \n               engine_stmt->option);\n      if (run_query(mysql, buffer, strlen(buffer)))\n      {\n        fprintf(stderr,\"%s: Cannot run query %.*s ERROR : %s\\n\",\n                my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));\n        exit(1);\n      }\n    }\n    else\n    {\n      if (run_query(mysql, ptr->string, ptr->length))\n      {\n        fprintf(stderr,\"%s: Cannot run query %.*s ERROR : %s\\n\",\n                my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));\n        exit(1);\n      }\n    }\n  }\n\n  if (auto_generate_sql && (auto_generate_sql_number > count ))\n  {\n    \/* Special case for auto create, we don't want to create tables twice *\/\n    after_create= stmt->next;\n    goto limit_not_met;\n  }\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":165005,"func":"AcpiNsExecModuleCode (\n    ACPI_OPERAND_OBJECT     *MethodObj,\n    ACPI_EVALUATE_INFO      *Info)\n{\n    ACPI_OPERAND_OBJECT     *ParentObj;\n    ACPI_NAMESPACE_NODE     *ParentNode;\n    ACPI_OBJECT_TYPE        Type;\n    ACPI_STATUS             Status;\n\n\n    ACPI_FUNCTION_TRACE (NsExecModuleCode);\n\n\n    \/*\n     * Get the parent node. We cheat by using the NextObject field\n     * of the method object descriptor.\n     *\/\n    ParentNode = ACPI_CAST_PTR (\n        ACPI_NAMESPACE_NODE, MethodObj->Method.NextObject);\n    Type = AcpiNsGetType (ParentNode);\n\n    \/*\n     * Get the region handler and save it in the method object. We may need\n     * this if an operation region declaration causes a _REG method to be run.\n     *\n     * We can't do this in AcpiPsLinkModuleCode because\n     * AcpiGbl_RootNode->Object is NULL at PASS1.\n     *\/\n    if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)\n    {\n        MethodObj->Method.Dispatch.Handler =\n            ParentNode->Object->Device.Handler;\n    }\n\n    \/* Must clear NextObject (AcpiNsAttachObject needs the field) *\/\n\n    MethodObj->Method.NextObject = NULL;\n\n    \/* Initialize the evaluation information block *\/\n\n    memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));\n    Info->PrefixNode = ParentNode;\n\n    \/*\n     * Get the currently attached parent object. Add a reference,\n     * because the ref count will be decreased when the method object\n     * is installed to the parent node.\n     *\/\n    ParentObj = AcpiNsGetAttachedObject (ParentNode);\n    if (ParentObj)\n    {\n        AcpiUtAddReference (ParentObj);\n    }\n\n    \/* Install the method (module-level code) in the parent node *\/\n\n    Status = AcpiNsAttachObject (ParentNode, MethodObj, ACPI_TYPE_METHOD);\n    if (ACPI_FAILURE (Status))\n    {\n        goto Exit;\n    }\n\n    \/* Execute the parent node as a control method *\/\n\n    Status = AcpiNsEvaluate (Info);\n\n    ACPI_DEBUG_PRINT ((ACPI_DB_INIT_NAMES,\n        \"Executed module-level code at %p\\n\",\n        MethodObj->Method.AmlStart));\n\n    \/* Delete a possible implicit return value (in slack mode) *\/\n\n    if (Info->ReturnObject)\n    {\n        AcpiUtRemoveReference (Info->ReturnObject);\n    }\n\n    \/* Detach the temporary method object *\/\n\n    AcpiNsDetachObject (ParentNode);\n\n    \/* Restore the original parent object *\/\n\n    if (ParentObj)\n    {\n        Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);\n    }\n    else\n    {\n        ParentNode->Type = (UINT8) Type;\n    }\n\nExit:\n    if (ParentObj)\n    {\n        AcpiUtRemoveReference (ParentObj);\n    }\n    return_VOID;\n}\n","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":29657,"func":"void config_nic_rules ( config_tree * ptree ) {\n nic_rule_node * curr_node ;\n sockaddr_u addr ;\n nic_rule_match match_type ;\n nic_rule_action action ;\n char * if_name ;\n char * pchSlash ;\n int prefixlen ;\n int addrbits ;\n curr_node = HEAD_PFIFO ( ptree -> nic_rules ) ;\n if ( curr_node != NULL && ( HAVE_OPT ( NOVIRTUALIPS ) || HAVE_OPT ( INTERFACE ) ) ) {\n msyslog ( LOG_ERR , \"interfaceic rules are not allowed with --interface (-I) or --novirtualips (-L)%s\" , ( input_from_file ) ? \", exiting\" : \"\" ) ;\n if ( input_from_file ) exit ( 1 ) ;\n else return ;\n }\n for ( ;\n curr_node != NULL ;\n curr_node = curr_node -> link ) {\n prefixlen = - 1 ;\n if_name = curr_node -> if_name ;\n if ( if_name != NULL ) if_name = estrdup ( if_name ) ;\n switch ( curr_node -> match_class ) {\n default : match_type = MATCH_ALL ;\n NTP_INSIST ( 0 ) ;\n break ;\n case 0 : NTP_INSIST ( if_name != NULL ) ;\n pchSlash = strchr ( if_name , '\/' ) ;\n if ( pchSlash != NULL ) * pchSlash = '\\0' ;\n if ( is_ip_address ( if_name , AF_UNSPEC , & addr ) ) {\n match_type = MATCH_IFADDR ;\n if ( pchSlash != NULL ) {\n sscanf ( pchSlash + 1 , \"%d\" , & prefixlen ) ;\n addrbits = 8 * SIZEOF_INADDR ( AF ( & addr ) ) ;\n prefixlen = max ( - 1 , prefixlen ) ;\n prefixlen = min ( prefixlen , addrbits ) ;\n }\n }\n else {\n match_type = MATCH_IFNAME ;\n if ( pchSlash != NULL ) * pchSlash = '\/' ;\n }\n break ;\n case T_All : match_type = MATCH_ALL ;\n break ;\n case T_Ipv4 : match_type = MATCH_IPV4 ;\n break ;\n case T_Ipv6 : match_type = MATCH_IPV6 ;\n break ;\n case T_Wildcard : match_type = MATCH_WILDCARD ;\n break ;\n }\n switch ( curr_node -> action ) {\n default : action = ACTION_LISTEN ;\n NTP_INSIST ( 0 ) ;\n break ;\n case T_Listen : action = ACTION_LISTEN ;\n break ;\n case T_Ignore : action = ACTION_IGNORE ;\n break ;\n case T_Drop : action = ACTION_DROP ;\n break ;\n }\n add_nic_rule ( match_type , if_name , prefixlen , action ) ;\n timer_interfacetimeout ( current_time + 2 ) ;\n if ( if_name != NULL ) free ( if_name ) ;\n }\n }","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":81611,"func":"static void dump_esp_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)\n{\n\tstruct sadb_prop *p;\n\tint i, k;\n\n\tp = (struct sadb_prop*)skb_put(skb, sizeof(struct sadb_prop));\n\tp->sadb_prop_len = sizeof(struct sadb_prop)\/8;\n\tp->sadb_prop_exttype = SADB_EXT_PROPOSAL;\n\tp->sadb_prop_replay = 32;\n\tmemset(p->sadb_prop_reserved, 0, sizeof(p->sadb_prop_reserved));\n\n\tfor (i=0; ; i++) {\n\t\tconst struct xfrm_algo_desc *ealg = xfrm_ealg_get_byidx(i);\n\t\tif (!ealg)\n\t\t\tbreak;\n\n\t\tif (!ealg->pfkey_supported)\n\t\t\tcontinue;\n\n\t\tif (!(ealg_tmpl_set(t, ealg) && ealg->available))\n\t\t\tcontinue;\n\n\t\tfor (k = 1; ; k++) {\n\t\t\tstruct sadb_comb *c;\n\t\t\tconst struct xfrm_algo_desc *aalg = xfrm_aalg_get_byidx(k);\n\t\t\tif (!aalg)\n\t\t\t\tbreak;\n\t\t\tif (!aalg->pfkey_supported)\n\t\t\t\tcontinue;\n\t\t\tif (!(aalg_tmpl_set(t, aalg) && aalg->available))\n\t\t\t\tcontinue;\n\t\t\tc = (struct sadb_comb*)skb_put(skb, sizeof(struct sadb_comb));\n\t\t\tmemset(c, 0, sizeof(*c));\n\t\t\tp->sadb_prop_len += sizeof(struct sadb_comb)\/8;\n\t\t\tc->sadb_comb_auth = aalg->desc.sadb_alg_id;\n\t\t\tc->sadb_comb_auth_minbits = aalg->desc.sadb_alg_minbits;\n\t\t\tc->sadb_comb_auth_maxbits = aalg->desc.sadb_alg_maxbits;\n\t\t\tc->sadb_comb_encrypt = ealg->desc.sadb_alg_id;\n\t\t\tc->sadb_comb_encrypt_minbits = ealg->desc.sadb_alg_minbits;\n\t\t\tc->sadb_comb_encrypt_maxbits = ealg->desc.sadb_alg_maxbits;\n\t\t\tc->sadb_comb_hard_addtime = 24*60*60;\n\t\t\tc->sadb_comb_soft_addtime = 20*60*60;\n\t\t\tc->sadb_comb_hard_usetime = 8*60*60;\n\t\t\tc->sadb_comb_soft_usetime = 7*60*60;\n\t\t}\n\t}\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":101187,"func":"static int http_buf_read(URLContext *h, uint8_t *buf, int size)\n{\n    HTTPContext *s = h->priv_data;\n    int len;\n    \/* read bytes from input buffer first *\/\n    len = s->buf_end - s->buf_ptr;\n    if (len > 0) {\n        if (len > size)\n            len = size;\n        memcpy(buf, s->buf_ptr, len);\n        s->buf_ptr += len;\n    } else {\n        uint64_t target_end = s->end_off ? s->end_off : s->filesize;\n        if ((!s->willclose || s->chunksize == UINT64_MAX) && s->off >= target_end)\n            return AVERROR_EOF;\n        len = ffurl_read(s->hd, buf, size);\n        if (!len && (!s->willclose || s->chunksize == UINT64_MAX) && s->off < target_end) {\n            av_log(h, AV_LOG_ERROR,\n                   \"Stream ends prematurely at %\"PRIu64\", should be %\"PRIu64\"\\n\",\n                   s->off, target_end\n                  );\n            return AVERROR(EIO);\n        }\n    }\n    if (len > 0) {\n        s->off += len;\n        if (s->chunksize > 0)\n            s->chunksize -= len;\n    }\n    return len;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":350242,"func":"static bool io_uring_cancel_files(struct io_ring_ctx *ctx,\n\t\t\t\t  struct files_struct *files)\n{\n\tif (list_empty_careful(&ctx->inflight_list))\n\t\treturn false;\n\n\tio_cancel_defer_files(ctx, files);\n\t\/* cancel all at once, should be faster than doing it one by one*\/\n\tio_wq_cancel_cb(ctx->io_wq, io_wq_files_match, files, true);\n\n\twhile (!list_empty_careful(&ctx->inflight_list)) {\n\t\tstruct io_kiocb *cancel_req = NULL, *req;\n\t\tDEFINE_WAIT(wait);\n\n\t\tspin_lock_irq(&ctx->inflight_lock);\n\t\tlist_for_each_entry(req, &ctx->inflight_list, inflight_entry) {\n\t\t\tif (req->work.files != files)\n\t\t\t\tcontinue;\n\t\t\t\/* req is being completed, ignore *\/\n\t\t\tif (!refcount_inc_not_zero(&req->refs))\n\t\t\t\tcontinue;\n\t\t\tcancel_req = req;\n\t\t\tbreak;\n\t\t}\n\t\tif (cancel_req)\n\t\t\tprepare_to_wait(&ctx->inflight_wait, &wait,\n\t\t\t\t\t\tTASK_UNINTERRUPTIBLE);\n\t\tspin_unlock_irq(&ctx->inflight_lock);\n\n\t\t\/* We need to keep going until we don't find a matching req *\/\n\t\tif (!cancel_req)\n\t\t\tbreak;\n\t\t\/* cancel this request, or head link requests *\/\n\t\tio_attempt_cancel(ctx, cancel_req);\n\t\tio_put_req(cancel_req);\n\t\t\/* cancellations _may_ trigger task work *\/\n\t\tio_run_task_work();\n\t\tschedule();\n\t\tfinish_wait(&ctx->inflight_wait, &wait);\n\t}\n\n\treturn true;\n}","target":1,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":426211,"func":"flatpak_run_get_minimal_env (gboolean devel)\n{\n  GPtrArray *env_array;\n  static const char * const copy[] = {\n    \"PWD\",\n    \"GDMSESSION\",\n    \"XDG_CURRENT_DESKTOP\",\n    \"XDG_SESSION_DESKTOP\",\n    \"DESKTOP_SESSION\",\n    \"EMAIL_ADDRESS\",\n    \"HOME\",\n    \"HOSTNAME\",\n    \"LOGNAME\",\n    \"REAL_NAME\",\n    \"TERM\",\n    \"USER\",\n    \"USERNAME\",\n  };\n  static const char * const copy_nodevel[] = {\n    \"LANG\",\n    \"LANGUAGE\",\n    \"LC_ALL\",\n    \"LC_ADDRESS\",\n    \"LC_COLLATE\",\n    \"LC_CTYPE\",\n    \"LC_IDENTIFICATION\",\n    \"LC_MEASUREMENT\",\n    \"LC_MESSAGES\",\n    \"LC_MONETARY\",\n    \"LC_NAME\",\n    \"LC_NUMERIC\",\n    \"LC_PAPER\",\n    \"LC_TELEPHONE\",\n    \"LC_TIME\",\n  };\n  int i;\n\n  env_array = g_ptr_array_new_with_free_func (g_free);\n\n  for (i = 0; i < G_N_ELEMENTS (default_exports); i++)\n    g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", default_exports[i].env, default_exports[i].val));\n\n  if (devel)\n    {\n      for (i = 0; i < G_N_ELEMENTS(devel_exports); i++)\n        g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", devel_exports[i].env, devel_exports[i].val));\n    }\n\n  for (i = 0; i < G_N_ELEMENTS (copy); i++)\n    {\n      const char *current = g_getenv (copy[i]);\n      if (current)\n        g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", copy[i], current));\n    }\n\n  if (!devel)\n    {\n      for (i = 0; i < G_N_ELEMENTS (copy_nodevel); i++)\n        {\n          const char *current = g_getenv (copy_nodevel[i]);\n          if (current)\n            g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", copy_nodevel[i], current));\n        }\n    }\n\n  g_ptr_array_add (env_array, NULL);\n  return (char **) g_ptr_array_free (env_array, FALSE);\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":98463,"func":"void ConnectionManagerImpl::onEvent(Network::ConnectionEvent event) {\n  if (event == Network::ConnectionEvent::LocalClose) {\n    stats_.named_.downstream_cx_destroy_local_.inc();\n  }\n\n  if (event == Network::ConnectionEvent::RemoteClose ||\n      event == Network::ConnectionEvent::LocalClose) {\n    if (event == Network::ConnectionEvent::RemoteClose) {\n      remote_close_ = true;\n      stats_.named_.downstream_cx_destroy_remote_.inc();\n    }\n    absl::string_view details =\n        event == Network::ConnectionEvent::RemoteClose\n            ? StreamInfo::ResponseCodeDetails::get().DownstreamRemoteDisconnect\n            : StreamInfo::ResponseCodeDetails::get().DownstreamLocalDisconnect;\n    \/\/ TODO(mattklein123): It is technically possible that something outside of the filter causes\n    \/\/ a local connection close, so we still guard against that here. A better solution would be to\n    \/\/ have some type of \"pre-close\" callback that we could hook for cleanup that would get called\n    \/\/ regardless of where local close is invoked from.\n    \/\/ NOTE: that this will cause doConnectionClose() to get called twice in the common local close\n    \/\/ cases, but the method protects against that.\n    \/\/ NOTE: In the case where a local close comes from outside the filter, this will cause any\n    \/\/ stream closures to increment remote close stats. We should do better here in the future,\n    \/\/ via the pre-close callback mentioned above.\n    doConnectionClose(absl::nullopt, absl::nullopt, details);\n  }\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":375648,"func":"reached_end_position(XLogRecPtr segendpos, uint32 timeline,\n\t\t\t\t\t bool segment_finished)\n{\n\tif (!has_xlogendptr)\n\t{\n#ifndef WIN32\n\t\tfd_set\t\tfds;\n\t\tstruct timeval tv;\n\t\tint\t\t\tr;\n\n\t\t\/*\n\t\t * Don't have the end pointer yet - check our pipe to see if it has\n\t\t * been sent yet.\n\t\t *\/\n\t\tFD_ZERO(&fds);\n\t\tFD_SET(bgpipe[0], &fds);\n\n\t\tMemSet(&tv, 0, sizeof(tv));\n\n\t\tr = select(bgpipe[0] + 1, &fds, NULL, NULL, &tv);\n\t\tif (r == 1)\n\t\t{\n\t\t\tchar\t\txlogend[64];\n\t\t\tuint32\t\thi,\n\t\t\t\t\t\tlo;\n\n\t\t\tMemSet(xlogend, 0, sizeof(xlogend));\n\t\t\tr = read(bgpipe[0], xlogend, sizeof(xlogend)-1);\n\t\t\tif (r < 0)\n\t\t\t{\n\t\t\t\tfprintf(stderr, _(\"%s: could not read from ready pipe: %s\\n\"),\n\t\t\t\t\t\tprogname, strerror(errno));\n\t\t\t\texit(1);\n\t\t\t}\n\n\t\t\tif (sscanf(xlogend, \"%X\/%X\", &hi, &lo) != 2)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\n\t\t\t\t  _(\"%s: could not parse transaction log location \\\"%s\\\"\\n\"),\n\t\t\t\t\t\tprogname, xlogend);\n\t\t\t\texit(1);\n\t\t\t}\n\t\t\txlogendptr = ((uint64) hi) << 32 | lo;\n\t\t\thas_xlogendptr = 1;\n\n\t\t\t\/*\n\t\t\t * Fall through to check if we've reached the point further\n\t\t\t * already.\n\t\t\t *\/\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\/*\n\t\t\t * No data received on the pipe means we don't know the end\n\t\t\t * position yet - so just say it's not time to stop yet.\n\t\t\t *\/\n\t\t\treturn false;\n\t\t}\n#else\n\n\t\t\/*\n\t\t * On win32, has_xlogendptr is set by the main thread, so if it's not\n\t\t * set here, we just go back and wait until it shows up.\n\t\t *\/\n\t\treturn false;\n#endif\n\t}\n\n\t\/*\n\t * At this point we have an end pointer, so compare it to the current\n\t * position to figure out if it's time to stop.\n\t *\/\n\tif (segendpos >= xlogendptr)\n\t\treturn true;\n\n\t\/*\n\t * Have end pointer, but haven't reached it yet - so tell the caller to\n\t * keep streaming.\n\t *\/\n\treturn false;\n}","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":9668,"func":"bool InputHandler::shouldRequestSpellCheckingOptionsForPoint(Platform::IntPoint& point, const Element* touchedElement, imf_sp_text_t& spellCheckingOptionRequest)\n {\n     if (!isActiveTextEdit())\n         return false;\n\n    Element* currentFocusElement = m_currentFocusElement.get();\n    if (!currentFocusElement || !currentFocusElement->isElementNode())\n        return false;\n\n    while (!currentFocusElement->isRootEditableElement()) {\n        Element* parentElement = currentFocusElement->parentElement();\n        if (!parentElement)\n            break;\n        currentFocusElement = parentElement;\n    }\n\n     if (touchedElement != currentFocusElement)\n         return false;\n \n    LayoutPoint contentPos(m_webPage->mapFromViewportToContents(point));\n     contentPos = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), m_webPage->focusedOrMainFrame(), roundedIntPoint(contentPos));\n \n     Document* document = currentFocusElement->document();\n    ASSERT(document);\n\n    RenderedDocumentMarker* marker = document->markers()->renderedMarkerContainingPoint(contentPos, DocumentMarker::Spelling);\n    if (!marker)\n        return false;\n\n    m_didSpellCheckWord = true;\n\n    spellCheckingOptionRequest.startTextPosition = marker->startOffset();\n    spellCheckingOptionRequest.endTextPosition = marker->endOffset();\n\n    m_spellCheckingOptionsRequest.startTextPosition = 0;\n    m_spellCheckingOptionsRequest.endTextPosition = 0;\n\n    SpellingLog(LogLevelInfo, \"InputHandler::shouldRequestSpellCheckingOptionsForPoint Found spelling marker at point %d, %d\\nMarker start %d end %d\",\n        point.x(), point.y(), spellCheckingOptionRequest.startTextPosition, spellCheckingOptionRequest.endTextPosition);\n\n    return true;\n}\n","target":1,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":199699,"func":"static int handle_mkdir(struct fuse* fuse, struct fuse_handler* handler,\n const struct fuse_in_header* hdr, const struct fuse_mkdir_in* req, const char* name)\n{\n struct node* parent_node;\n char parent_path[PATH_MAX];\n char child_path[PATH_MAX];\n const char* actual_name;\n\n    pthread_mutex_lock(&fuse->global->lock);\n    parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid,\n            parent_path, sizeof(parent_path));\n    TRACE(\"[%d] MKDIR %s 0%o @ %\"PRIx64\" (%s)\\n\", handler->token,\n            name, req->mode, hdr->nodeid, parent_node ? parent_node->name : \"?\");\n    pthread_mutex_unlock(&fuse->global->lock);\n\n if (!parent_node || !(actual_name = find_file_within(parent_path, name,\n            child_path, sizeof(child_path), 1))) {\n return -ENOENT;\n }\n if (!check_caller_access_to_name(fuse, hdr, parent_node, name, W_OK)) {\n return -EACCES;\n }\n    __u32 mode = (req->mode & (~0777)) | 0775;\n if (mkdir(child_path, mode) < 0) {\n return -errno;\n }\n\n \/* When creating \/Android\/data and \/Android\/obb, mark them as .nomedia *\/\n if (parent_node->perm == PERM_ANDROID && !strcasecmp(name, \"data\")) {\n char nomedia[PATH_MAX];\n        snprintf(nomedia, PATH_MAX, \"%s\/.nomedia\", child_path);\n if (touch(nomedia, 0664) != 0) {\n            ERROR(\"Failed to touch(%s): %s\\n\", nomedia, strerror(errno));\n return -ENOENT;\n }\n }\n if (parent_node->perm == PERM_ANDROID && !strcasecmp(name, \"obb\")) {\n char nomedia[PATH_MAX];\n        snprintf(nomedia, PATH_MAX, \"%s\/.nomedia\", fuse->global->obb_path);\n if (touch(nomedia, 0664) != 0) {\n            ERROR(\"Failed to touch(%s): %s\\n\", nomedia, strerror(errno));\n return -ENOENT;\n }\n }\n\n return fuse_reply_entry(fuse, hdr->unique, parent_node, name, actual_name, child_path);\n}\n","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":117216,"func":"static int _server_handle_m(libgdbr_t *g, int (*cmd_cb) (void*, const char*, char*, size_t), void *core_ptr) {\n\tint ret;\n\tut64 addr;\n\tint length;\n\tchar *buf1, *buf2, cmd[64];\n\tint buf1_len, buf2_len;\n\n\tif (send_ack (g) < 0) {\n\t\treturn -1;\n\t}\n\tg->data[g->data_len] = 0;\n\tsscanf (g->data, \"m%\"PFMT64x\",%d\", &addr, &length);\n\tif (g->data_len < 4 || !strchr (g->data, ',')) {\n\t\treturn send_msg (g, \"E01\");\n\t}\n\tbuf1_len = length;\n\tbuf2_len = length * 2 + 1;\n\tif (!(buf1 = malloc (buf1_len))) {\n\t\treturn -1;\n\t}\n\tif (!(buf2 = malloc (buf2_len))) {\n\t\tfree (buf1);\n\t\treturn -1;\n\t}\n\tmemset (buf2, 0, buf2_len);\n\tsnprintf (cmd, sizeof (cmd) - 1, \"m %\"PFMT64x\" %d\", addr, length);\n\tif ((buf1_len = cmd_cb (core_ptr, cmd, buf1, buf1_len)) < 0) {\n\t\tfree (buf1);\n\t\tfree (buf2);\n\t\tsend_msg (g, \"E01\");\n\t\treturn -1;\n\t}\n\tpack_hex (buf1, buf1_len, buf2);\n\tret = send_msg (g, buf2);\n\tfree (buf1);\n\tfree (buf2);\n\treturn ret;\n}","target":0,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":375272,"func":"RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal)\n{\n\tRelation\ttargetrelation;\n\tRelation\trelrelation;\t\/* for RELATION relation *\/\n\tHeapTuple\treltup;\n\tForm_pg_class relform;\n\tOid\t\t\tnamespaceId;\n\n\t\/*\n\t * Grab an exclusive lock on the target table, index, sequence or view,\n\t * which we will NOT release until end of transaction.\n\t *\/\n\ttargetrelation = relation_open(myrelid, AccessExclusiveLock);\n\tnamespaceId = RelationGetNamespace(targetrelation);\n\n\t\/*\n\t * Find relation's pg_class tuple, and make sure newrelname isn't in use.\n\t *\/\n\trelrelation = heap_open(RelationRelationId, RowExclusiveLock);\n\n\treltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));\n\tif (!HeapTupleIsValid(reltup))\t\t\/* shouldn't happen *\/\n\t\telog(ERROR, \"cache lookup failed for relation %u\", myrelid);\n\trelform = (Form_pg_class) GETSTRUCT(reltup);\n\n\tif (get_relname_relid(newrelname, namespaceId) != InvalidOid)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_DUPLICATE_TABLE),\n\t\t\t\t errmsg(\"relation \\\"%s\\\" already exists\",\n\t\t\t\t\t\tnewrelname)));\n\n\t\/*\n\t * Update pg_class tuple with new relname.\t(Scribbling on reltup is OK\n\t * because it's a copy...)\n\t *\/\n\tnamestrcpy(&(relform->relname), newrelname);\n\n\tsimple_heap_update(relrelation, &reltup->t_self, reltup);\n\n\t\/* keep the system catalog indexes current *\/\n\tCatalogUpdateIndexes(relrelation, reltup);\n\n\tInvokeObjectPostAlterHookArg(RelationRelationId, myrelid, 0,\n\t\t\t\t\t\t\t\t InvalidOid, is_internal);\n\n\theap_freetuple(reltup);\n\theap_close(relrelation, RowExclusiveLock);\n\n\t\/*\n\t * Also rename the associated type, if any.\n\t *\/\n\tif (OidIsValid(targetrelation->rd_rel->reltype))\n\t\tRenameTypeInternal(targetrelation->rd_rel->reltype,\n\t\t\t\t\t\t   newrelname, namespaceId);\n\n\t\/*\n\t * Also rename the associated constraint, if any.\n\t *\/\n\tif (targetrelation->rd_rel->relkind == RELKIND_INDEX)\n\t{\n\t\tOid\t\t\tconstraintId = get_index_constraint(myrelid);\n\n\t\tif (OidIsValid(constraintId))\n\t\t\tRenameConstraintById(constraintId, newrelname);\n\t}\n\n\t\/*\n\t * Close rel, but keep exclusive lock!\n\t *\/\n\trelation_close(targetrelation, NoLock);\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":216521,"func":"PHP_FUNCTION(stream_get_meta_data)\n{\n\tzval *arg1;\n\tphp_stream *stream;\n\tzval *newval;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"r\", &arg1) == FAILURE) {\n\t\treturn;\n\t}\n\tphp_stream_from_zval(stream, &arg1);\n\n\tarray_init(return_value);\n\n\tif (stream->wrapperdata) {\n\t\tMAKE_STD_ZVAL(newval);\n\t\tMAKE_COPY_ZVAL(&stream->wrapperdata, newval);\n\n\t\tadd_assoc_zval(return_value, \"wrapper_data\", newval);\n\t}\n\tif (stream->wrapper) {\n\t\tadd_assoc_string(return_value, \"wrapper_type\", (char *)stream->wrapper->wops->label, 1);\n\t}\n\tadd_assoc_string(return_value, \"stream_type\", (char *)stream->ops->label, 1);\n\n\tadd_assoc_string(return_value, \"mode\", stream->mode, 1);\n\n#if 0\t\/* TODO: needs updating for new filter API *\/\n\tif (stream->filterhead) {\n\t\tphp_stream_filter *filter;\n\n\t\tMAKE_STD_ZVAL(newval);\n\t\tarray_init(newval);\n\n\t\tfor (filter = stream->filterhead; filter != NULL; filter = filter->next) {\n\t\t\tadd_next_index_string(newval, (char *)filter->fops->label, 1);\n\t\t}\n\n\t\tadd_assoc_zval(return_value, \"filters\", newval);\n\t}\n#endif\n\n\tadd_assoc_long(return_value, \"unread_bytes\", stream->writepos - stream->readpos);\n\n\tadd_assoc_bool(return_value, \"seekable\", (stream->ops->seek) && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0);\n\tif (stream->orig_path) {\n\t\tadd_assoc_string(return_value, \"uri\", stream->orig_path, 1);\n\t}\n\n\tif (!php_stream_populate_meta_data(stream, return_value)) {\n\t\tadd_assoc_bool(return_value, \"timed_out\", 0);\n\t\tadd_assoc_bool(return_value, \"blocked\", 1);\n\t\tadd_assoc_bool(return_value, \"eof\", php_stream_eof(stream));\n\t}\n\n}\n","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":138930,"func":"static int futex_unlock_pi(u32 __user *uaddr, unsigned int flags)\n{\n\tstruct futex_hash_bucket *hb;\n\tstruct futex_q *this, *next;\n\tunion futex_key key = FUTEX_KEY_INIT;\n\tu32 uval, vpid = task_pid_vnr(current);\n\tint ret;\n\nretry:\n\tif (get_user(uval, uaddr))\n\t\treturn -EFAULT;\n\t\/*\n\t * We release only a lock we actually own:\n\t *\/\n\tif ((uval & FUTEX_TID_MASK) != vpid)\n\t\treturn -EPERM;\n\n\tret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, VERIFY_WRITE);\n\tif (unlikely(ret != 0))\n\t\tgoto out;\n\n\thb = hash_futex(&key);\n\tspin_lock(&hb->lock);\n\n\t\/*\n\t * To avoid races, try to do the TID -> 0 atomic transition\n\t * again. If it succeeds then we can return without waking\n\t * anyone else up:\n\t *\/\n\tif (!(uval & FUTEX_OWNER_DIED) &&\n\t    cmpxchg_futex_value_locked(&uval, uaddr, vpid, 0))\n\t\tgoto pi_faulted;\n\t\/*\n\t * Rare case: we managed to release the lock atomically,\n\t * no need to wake anyone else up:\n\t *\/\n\tif (unlikely(uval == vpid))\n\t\tgoto out_unlock;\n\n\t\/*\n\t * Ok, other tasks may need to be woken up - check waiters\n\t * and do the wakeup if necessary:\n\t *\/\n\tplist_for_each_entry_safe(this, next, &hb->chain, list) {\n\t\tif (!match_futex (&this->key, &key))\n\t\t\tcontinue;\n\t\tret = wake_futex_pi(uaddr, uval, this);\n\t\t\/*\n\t\t * The atomic access to the futex value\n\t\t * generated a pagefault, so retry the\n\t\t * user-access and the wakeup:\n\t\t *\/\n\t\tif (ret == -EFAULT)\n\t\t\tgoto pi_faulted;\n\t\tgoto out_unlock;\n\t}\n\t\/*\n\t * No waiters - kernel unlocks the futex:\n\t *\/\n\tif (!(uval & FUTEX_OWNER_DIED)) {\n\t\tret = unlock_futex_pi(uaddr, uval);\n\t\tif (ret == -EFAULT)\n\t\t\tgoto pi_faulted;\n\t}\n\nout_unlock:\n\tspin_unlock(&hb->lock);\n\tput_futex_key(&key);\n\nout:\n\treturn ret;\n\npi_faulted:\n\tspin_unlock(&hb->lock);\n\tput_futex_key(&key);\n\n\tret = fault_in_user_writeable(uaddr);\n\tif (!ret)\n\t\tgoto retry;\n\n\treturn ret;\n}","target":0,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":387173,"func":"static void vmxnet_tx_pkt_do_sw_csum(struct VmxnetTxPkt *pkt)\n{\n    struct iovec *iov = &pkt->vec[VMXNET_TX_PKT_L2HDR_FRAG];\n    uint32_t csum_cntr;\n    uint16_t csum = 0;\n    \/* num of iovec without vhdr *\/\n    uint32_t iov_len = pkt->payload_frags + VMXNET_TX_PKT_PL_START_FRAG - 1;\n    uint16_t csl;\n    struct ip_header *iphdr;\n    size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;\n\n    \/* Put zero to checksum field *\/\n    iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);\n\n    \/* Calculate L4 TCP\/UDP checksum *\/\n    csl = pkt->payload_len;\n\n    \/* data checksum *\/\n    csum_cntr =\n        net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl);\n    \/* add pseudo header to csum *\/\n    iphdr = pkt->vec[VMXNET_TX_PKT_L3HDR_FRAG].iov_base;\n    csum_cntr += eth_calc_pseudo_hdr_csum(iphdr, csl);\n\n    \/* Put the checksum obtained into the packet *\/\n    csum = cpu_to_be16(net_checksum_finish(csum_cntr));\n    iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":322834,"func":"static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)\n\n{\n\n#if COMPILE_TEMPLATE_MMX\n\n    __asm__ volatile(\n\n        \"movq \"MANGLE(bm01010101)\", %%mm4           \\n\\t\"\n\n        \"mov                    %0, %%\"REG_a\"       \\n\\t\"\n\n        \"1:                                         \\n\\t\"\n\n        \"movq    (%1, %%\"REG_a\",2), %%mm0           \\n\\t\"\n\n        \"movq   8(%1, %%\"REG_a\",2), %%mm1           \\n\\t\"\n\n        \"movq    (%2, %%\"REG_a\",2), %%mm2           \\n\\t\"\n\n        \"movq   8(%2, %%\"REG_a\",2), %%mm3           \\n\\t\"\n\n        \"pand                %%mm4, %%mm0           \\n\\t\"\n\n        \"pand                %%mm4, %%mm1           \\n\\t\"\n\n        \"pand                %%mm4, %%mm2           \\n\\t\"\n\n        \"pand                %%mm4, %%mm3           \\n\\t\"\n\n        \"packuswb            %%mm1, %%mm0           \\n\\t\"\n\n        \"packuswb            %%mm3, %%mm2           \\n\\t\"\n\n        \"movq                %%mm0, (%3, %%\"REG_a\") \\n\\t\"\n\n        \"movq                %%mm2, (%4, %%\"REG_a\") \\n\\t\"\n\n        \"add                    $8, %%\"REG_a\"       \\n\\t\"\n\n        \" js                    1b                  \\n\\t\"\n\n        : : \"g\" ((x86_reg)-width), \"r\" (src1+width*2), \"r\" (src2+width*2), \"r\" (dstU+width), \"r\" (dstV+width)\n\n        : \"%\"REG_a\n\n    );\n\n#else\n\n    int i;\n\n    for (i=0; i<width; i++) {\n\n        dstU[i]= src1[2*i];\n\n        dstV[i]= src2[2*i];\n\n    }\n\n#endif\n\n}\n","target":0,"code_token_length":496,"total_token_length":732,"max_tokens_setting":1024}
+{"idx":22205,"func":"static Selectivity prefix_selectivity ( PlannerInfo * root , VariableStatData * vardata , Oid vartype , Oid opfamily , Const * prefixcon ) {\n Selectivity prefixsel ;\n Oid cmpopr ;\n FmgrInfo opproc ;\n Const * greaterstrcon ;\n Selectivity eq_sel ;\n cmpopr = get_opfamily_member ( opfamily , vartype , vartype , BTGreaterEqualStrategyNumber ) ;\n if ( cmpopr == InvalidOid ) elog ( ERROR , \"no >= operator for opfamily %u\" , opfamily ) ;\n fmgr_info ( get_opcode ( cmpopr ) , & opproc ) ;\n prefixsel = ineq_histogram_selectivity ( root , vardata , & opproc , true , prefixcon -> constvalue , prefixcon -> consttype ) ;\n if ( prefixsel < 0.0 ) {\n return DEFAULT_MATCH_SEL ;\n }\n cmpopr = get_opfamily_member ( opfamily , vartype , vartype , BTLessStrategyNumber ) ;\n if ( cmpopr == InvalidOid ) elog ( ERROR , \"no < operator for opfamily %u\" , opfamily ) ;\n fmgr_info ( get_opcode ( cmpopr ) , & opproc ) ;\n greaterstrcon = make_greater_string ( prefixcon , & opproc , DEFAULT_COLLATION_OID ) ;\n if ( greaterstrcon ) {\n Selectivity topsel ;\n topsel = ineq_histogram_selectivity ( root , vardata , & opproc , false , greaterstrcon -> constvalue , greaterstrcon -> consttype ) ;\n Assert ( topsel >= 0.0 ) ;\n prefixsel = topsel + prefixsel - 1.0 ;\n }\n cmpopr = get_opfamily_member ( opfamily , vartype , vartype , BTEqualStrategyNumber ) ;\n if ( cmpopr == InvalidOid ) elog ( ERROR , \"no = operator for opfamily %u\" , opfamily ) ;\n eq_sel = var_eq_const ( vardata , cmpopr , prefixcon -> constvalue , false , true ) ;\n prefixsel = Max ( prefixsel , eq_sel ) ;\n return prefixsel ;\n }","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":145479,"func":"BOOL update_recv_pointer(rdpUpdate* update, wStream* s)\n{\n\tBOOL rc = FALSE;\n\tUINT16 messageType;\n\trdpContext* context = update->context;\n\trdpPointerUpdate* pointer = update->pointer;\n\n\tif (Stream_GetRemainingLength(s) < 2 + 2)\n\t\treturn FALSE;\n\n\tStream_Read_UINT16(s, messageType); \/* messageType (2 bytes) *\/\n\tStream_Seek_UINT16(s); \/* pad2Octets (2 bytes) *\/\n\n\tswitch (messageType)\n\t{\n\t\tcase PTR_MSG_TYPE_POSITION:\n\t\t\t{\n\t\t\t\tPOINTER_POSITION_UPDATE* pointer_position = update_read_pointer_position(update, s);\n\n\t\t\t\tif (pointer_position)\n\t\t\t\t{\n\t\t\t\t\trc = IFCALLRESULT(FALSE, pointer->PointerPosition, context, pointer_position);\n\t\t\t\t\tfree_pointer_position_update(context, pointer_position);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase PTR_MSG_TYPE_SYSTEM:\n\t\t\t{\n\t\t\t\tPOINTER_SYSTEM_UPDATE* pointer_system = update_read_pointer_system(update, s);\n\n\t\t\t\tif (pointer_system)\n\t\t\t\t{\n\t\t\t\t\trc = IFCALLRESULT(FALSE, pointer->PointerSystem, context, pointer_system);\n\t\t\t\t\tfree_pointer_system_update(context, pointer_system);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase PTR_MSG_TYPE_COLOR:\n\t\t\t{\n\t\t\t\tPOINTER_COLOR_UPDATE* pointer_color = update_read_pointer_color(update, s, 24);\n\n\t\t\t\tif (pointer_color)\n\t\t\t\t{\n\t\t\t\t\trc = IFCALLRESULT(FALSE, pointer->PointerColor, context, pointer_color);\n\t\t\t\t\tfree_pointer_color_update(context, pointer_color);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase PTR_MSG_TYPE_POINTER:\n\t\t\t{\n\t\t\t\tPOINTER_NEW_UPDATE* pointer_new = update_read_pointer_new(update, s);\n\n\t\t\t\tif (pointer_new)\n\t\t\t\t{\n\t\t\t\t\trc = IFCALLRESULT(FALSE, pointer->PointerNew, context, pointer_new);\n\t\t\t\t\tfree_pointer_new_update(context, pointer_new);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase PTR_MSG_TYPE_CACHED:\n\t\t\t{\n\t\t\t\tPOINTER_CACHED_UPDATE* pointer_cached = update_read_pointer_cached(update, s);\n\n\t\t\t\tif (pointer_cached)\n\t\t\t\t{\n\t\t\t\t\trc = IFCALLRESULT(FALSE, pointer->PointerCached, context, pointer_cached);\n\t\t\t\t\tfree_pointer_cached_update(context, pointer_cached);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":502,"total_token_length":738,"max_tokens_setting":1024}
+{"idx":505445,"func":"int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,\n\tunsigned int len)\n\t{\n\tint i;\n\n\/* XXXX *\/\n\tif ((s->s3->wpend_tot > (int)len)\n\t\t|| ((s->s3->wpend_buf != buf) &&\n\t\t\t!(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER))\n\t\t|| (s->s3->wpend_type != type))\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_WRITE_PENDING,SSL_R_BAD_WRITE_RETRY);\n\t\treturn(-1);\n\t\t}\n\n\tfor (;;)\n\t\t{\n\t\tclear_sys_error();\n\t\tif (s->wbio != NULL)\n\t\t\t{\n\t\t\ts->rwstate=SSL_WRITING;\n\t\t\ti=BIO_write(s->wbio,\n\t\t\t\t(char *)&(s->s3->wbuf.buf[s->s3->wbuf.offset]),\n\t\t\t\t(unsigned int)s->s3->wbuf.left);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_WRITE_PENDING,SSL_R_BIO_NOT_SET);\n\t\t\ti= -1;\n\t\t\t}\n\t\tif (i == s->s3->wbuf.left)\n\t\t\t{\n\t\t\ts->s3->wbuf.left=0;\n\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\treturn(s->s3->wpend_ret);\n\t\t\t}\n\t\telse if (i <= 0) {\n\t\t\tif (s->version == DTLS1_VERSION ||\n\t\t\t    s->version == DTLS1_BAD_VER) {\n\t\t\t\t\/* For DTLS, just drop it. That's kind of the whole\n\t\t\t\t   point in using a datagram service *\/\n\t\t\t\ts->s3->wbuf.left = 0;\n\t\t\t}\n\t\t\treturn(i);\n\t\t}\n\t\ts->s3->wbuf.offset+=i;\n\t\ts->s3->wbuf.left-=i;\n\t\t}\n\t}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":129479,"func":"TRIO_PRIVATE void TrioWriteString TRIO_ARGS5((self, string, flags, width, precision),\n                                             trio_class_t* self, TRIO_CONST char* string,\n                                             trio_flags_t flags, int width, int precision)\n{\n\tint length = 0;\n\tint ch;\n\n\tassert(VALID(self));\n\tassert(VALID(self->OutStream));\n\n\tif (string == NULL)\n\t{\n\t\tstring = internalNullString;\n\t\tlength = sizeof(internalNullString) - 1;\n#if TRIO_FEATURE_QUOTE\n\t\t\/* Disable quoting for the null pointer *\/\n\t\tflags &= (~FLAGS_QUOTE);\n#endif\n\t\twidth = 0;\n\t}\n\telse\n\t{\n\t\tif (precision <= 0)\n\t\t{\n\t\t\tlength = trio_length(string);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlength = trio_length_max(string, precision);\n\t\t}\n\t}\n\tif ((NO_PRECISION != precision) && (precision < length))\n\t{\n\t\tlength = precision;\n\t}\n\twidth -= length;\n\n#if TRIO_FEATURE_QUOTE\n\tif (flags & FLAGS_QUOTE)\n\t\tself->OutStream(self, CHAR_QUOTE);\n#endif\n\n\tif (!(flags & FLAGS_LEFTADJUST))\n\t{\n\t\twhile (width-- > 0)\n\t\t\tself->OutStream(self, CHAR_ADJUST);\n\t}\n\n\twhile (length-- > 0)\n\t{\n\t\t\/* The ctype parameters must be an unsigned char (or EOF) *\/\n\t\tch = (int)((unsigned char)(*string++));\n\t\tTrioWriteStringCharacter(self, ch, flags);\n\t}\n\n\tif (flags & FLAGS_LEFTADJUST)\n\t{\n\t\twhile (width-- > 0)\n\t\t\tself->OutStream(self, CHAR_ADJUST);\n\t}\n#if TRIO_FEATURE_QUOTE\n\tif (flags & FLAGS_QUOTE)\n\t\tself->OutStream(self, CHAR_QUOTE);\n#endif\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":256091,"func":"static int dnxhd_find_frame_end(DNXHDParserContext *dctx,\n                                const uint8_t *buf, int buf_size)\n{\n    ParseContext *pc = &dctx->pc;\n    uint64_t state = pc->state64;\n    int pic_found = pc->frame_start_found;\n    int i = 0;\n    int interlaced = dctx->interlaced;\n    int cur_field = dctx->cur_field;\n\n    if (!pic_found) {\n        for (i = 0; i < buf_size; i++) {\n            state = (state << 8) | buf[i];\n            if (ff_dnxhd_check_header_prefix(state & 0xffffffffff00LL) != 0) {\n                i++;\n                pic_found = 1;\n                interlaced = (state&2)>>1; \/* byte following the 5-byte header prefix *\/\n                cur_field = state&1;\n                dctx->cur_byte = 0;\n                dctx->remaining = 0;\n                break;\n            }\n        }\n    }\n\n    if (pic_found && !dctx->remaining) {\n        if (!buf_size) \/* EOF considered as end of frame *\/\n            return 0;\n        for (; i < buf_size; i++) {\n            dctx->cur_byte++;\n            state = (state << 8) | buf[i];\n\n            if (dctx->cur_byte == 24) {\n                dctx->h = (state >> 32) & 0xFFFF;\n            } else if (dctx->cur_byte == 26) {\n                 dctx->w = (state >> 32) & 0xFFFF;\n             } else if (dctx->cur_byte == 42) {\n                 int cid = (state >> 32) & 0xFFFFFFFF;\n \n                 if (cid <= 0)\n                     continue;\n \n                dctx->remaining = avpriv_dnxhd_get_frame_size(cid);\n                if (dctx->remaining <= 0) {\n                    dctx->remaining = dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h);\n                    if (dctx->remaining <= 0)\n                        return dctx->remaining;\n                 }\n                 if (buf_size - i >= dctx->remaining && (!dctx->interlaced || dctx->cur_field)) {\n                     int remaining = dctx->remaining;\n \n                    pc->frame_start_found = 0;\n                    pc->state64 = -1;\n                    dctx->interlaced = interlaced;\n                    dctx->cur_field = 0;\n                    dctx->cur_byte = 0;\n                    dctx->remaining = 0;\n                    return remaining;\n                } else {\n                    dctx->remaining -= buf_size;\n                }\n            }\n        }\n    } else if (pic_found) {\n        if (dctx->remaining > buf_size) {\n            dctx->remaining -= buf_size;\n        } else {\n            int remaining = dctx->remaining;\n\n            pc->frame_start_found = 0;\n            pc->state64 = -1;\n            dctx->interlaced = interlaced;\n            dctx->cur_field = 0;\n            dctx->cur_byte = 0;\n            dctx->remaining = 0;\n            return remaining;\n        }\n    }\n    pc->frame_start_found = pic_found;\n    pc->state64 = state;\n    dctx->interlaced = interlaced;\n    dctx->cur_field = cur_field;\n    return END_NOT_FOUND;\n}\n","target":1,"code_token_length":755,"total_token_length":991,"max_tokens_setting":1024}
+{"idx":453337,"func":"static void account_event(struct perf_event *event)\n{\n\tbool inc = false;\n\n\tif (event->parent)\n\t\treturn;\n\n\tif (event->attach_state & PERF_ATTACH_TASK)\n\t\tinc = true;\n\tif (event->attr.mmap || event->attr.mmap_data)\n\t\tatomic_inc(&nr_mmap_events);\n\tif (event->attr.comm)\n\t\tatomic_inc(&nr_comm_events);\n\tif (event->attr.namespaces)\n\t\tatomic_inc(&nr_namespaces_events);\n\tif (event->attr.cgroup)\n\t\tatomic_inc(&nr_cgroup_events);\n\tif (event->attr.task)\n\t\tatomic_inc(&nr_task_events);\n\tif (event->attr.freq)\n\t\taccount_freq_event();\n\tif (event->attr.context_switch) {\n\t\tatomic_inc(&nr_switch_events);\n\t\tinc = true;\n\t}\n\tif (has_branch_stack(event))\n\t\tinc = true;\n\tif (is_cgroup_event(event))\n\t\tinc = true;\n\tif (event->attr.ksymbol)\n\t\tatomic_inc(&nr_ksymbol_events);\n\tif (event->attr.bpf_event)\n\t\tatomic_inc(&nr_bpf_events);\n\tif (event->attr.text_poke)\n\t\tatomic_inc(&nr_text_poke_events);\n\n\tif (inc) {\n\t\t\/*\n\t\t * We need the mutex here because static_branch_enable()\n\t\t * must complete *before* the perf_sched_count increment\n\t\t * becomes visible.\n\t\t *\/\n\t\tif (atomic_inc_not_zero(&perf_sched_count))\n\t\t\tgoto enabled;\n\n\t\tmutex_lock(&perf_sched_mutex);\n\t\tif (!atomic_read(&perf_sched_count)) {\n\t\t\tstatic_branch_enable(&perf_sched_events);\n\t\t\t\/*\n\t\t\t * Guarantee that all CPUs observe they key change and\n\t\t\t * call the perf scheduling hooks before proceeding to\n\t\t\t * install events that need them.\n\t\t\t *\/\n\t\t\tsynchronize_rcu();\n\t\t}\n\t\t\/*\n\t\t * Now that we have waited for the sync_sched(), allow further\n\t\t * increments to by-pass the mutex.\n\t\t *\/\n\t\tatomic_inc(&perf_sched_count);\n\t\tmutex_unlock(&perf_sched_mutex);\n\t}\nenabled:\n\n\taccount_event_cpu(event, event->cpu);\n\n\taccount_pmu_sb_event(event);\n}","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":372138,"func":"static void call_nt_transact_notify_change(connection_struct *conn,\n\t\t\t\t\t   struct smb_request *req,\n\t\t\t\t\t   uint16 **ppsetup,\n\t\t\t\t\t   uint32 setup_count,\n\t\t\t\t\t   char **ppparams,\n\t\t\t\t\t   uint32 parameter_count,\n\t\t\t\t\t   char **ppdata, uint32 data_count,\n\t\t\t\t\t   uint32 max_data_count,\n\t\t\t\t\t   uint32 max_param_count)\n{\n\tuint16 *setup = *ppsetup;\n\tfiles_struct *fsp;\n\tuint32 filter;\n\tNTSTATUS status;\n\tbool recursive;\n\n\tif(setup_count < 6) {\n\t\treply_nterror(req, NT_STATUS_INVALID_PARAMETER);\n\t\treturn;\n\t}\n\n\tfsp = file_fsp(req, SVAL(setup,4));\n\tfilter = IVAL(setup, 0);\n\trecursive = (SVAL(setup, 6) != 0) ? True : False;\n\n\tDEBUG(3,(\"call_nt_transact_notify_change\\n\"));\n\n\tif(!fsp) {\n\t\treply_nterror(req, NT_STATUS_INVALID_HANDLE);\n\t\treturn;\n\t}\n\n\t{\n\t\tchar *filter_string;\n\n\t\tif (!(filter_string = notify_filter_string(NULL, filter))) {\n\t\t\treply_nterror(req,NT_STATUS_NO_MEMORY);\n\t\t\treturn;\n\t\t}\n\n\t\tDEBUG(3,(\"call_nt_transact_notify_change: notify change \"\n\t\t\t \"called on %s, filter = %s, recursive = %d\\n\",\n\t\t\t fsp_str_dbg(fsp), filter_string, recursive));\n\n\t\tTALLOC_FREE(filter_string);\n\t}\n\n\tif((!fsp->is_directory) || (conn != fsp->conn)) {\n\t\treply_nterror(req, NT_STATUS_INVALID_PARAMETER);\n\t\treturn;\n\t}\n\n\tif (fsp->notify == NULL) {\n\n\t\tstatus = change_notify_create(fsp, filter, recursive);\n\n\t\tif (!NT_STATUS_IS_OK(status)) {\n\t\t\tDEBUG(10, (\"change_notify_create returned %s\\n\",\n\t\t\t\t   nt_errstr(status)));\n\t\t\treply_nterror(req, status);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (fsp->notify->num_changes != 0) {\n\n\t\t\/*\n\t\t * We've got changes pending, respond immediately\n\t\t *\/\n\n\t\t\/*\n\t\t * TODO: write a torture test to check the filtering behaviour\n\t\t * here.\n\t\t *\/\n\n\t\tchange_notify_reply(req,\n\t\t\t\t    NT_STATUS_OK,\n\t\t\t\t    max_param_count,\n\t\t\t\t    fsp->notify,\n\t\t\t\t    smbd_smb1_notify_reply);\n\n\t\t\/*\n\t\t * change_notify_reply() above has independently sent its\n\t\t * results\n\t\t *\/\n\t\treturn;\n\t}\n\n\t\/*\n\t * No changes pending, queue the request\n\t *\/\n\n\tstatus = change_notify_add_request(req,\n\t\t\tmax_param_count,\n\t\t\tfilter,\n\t\t\trecursive, fsp,\n\t\t\tsmbd_smb1_notify_reply);\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\treply_nterror(req, status);\n\t}\n\treturn;\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":499170,"func":"static int sqfs_frag_lookup(u32 inode_fragment_index,\n\t\t\t    struct squashfs_fragment_block_entry *e)\n{\n\tu64 start, n_blks, src_len, table_offset, start_block;\n\tunsigned char *metadata_buffer, *metadata, *table;\n\tstruct squashfs_fragment_block_entry *entries;\n\tstruct squashfs_super_block *sblk = ctxt.sblk;\n\tunsigned long dest_len;\n\tint block, offset, ret;\n\tu16 header;\n\n\tmetadata_buffer = NULL;\n\tentries = NULL;\n\ttable = NULL;\n\n\tif (inode_fragment_index >= get_unaligned_le32(&sblk->fragments))\n\t\treturn -EINVAL;\n\n\tstart = get_unaligned_le64(&sblk->fragment_table_start) \/\n\t\tctxt.cur_dev->blksz;\n\tn_blks = sqfs_calc_n_blks(sblk->fragment_table_start,\n\t\t\t\t  sblk->export_table_start,\n\t\t\t\t  &table_offset);\n\n\t\/* Allocate a proper sized buffer to store the fragment index table *\/\n\ttable = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);\n\tif (!table) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tif (sqfs_disk_read(start, n_blks, table) < 0) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tblock = SQFS_FRAGMENT_INDEX(inode_fragment_index);\n\toffset = SQFS_FRAGMENT_INDEX_OFFSET(inode_fragment_index);\n\n\t\/*\n\t * Get the start offset of the metadata block that contains the right\n\t * fragment block entry\n\t *\/\n\tstart_block = get_unaligned_le64(table + table_offset + block *\n\t\t\t\t\t sizeof(u64));\n\n\tstart = start_block \/ ctxt.cur_dev->blksz;\n\tn_blks = sqfs_calc_n_blks(cpu_to_le64(start_block),\n\t\t\t\t  sblk->fragment_table_start, &table_offset);\n\n\tmetadata_buffer = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);\n\tif (!metadata_buffer) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tif (sqfs_disk_read(start, n_blks, metadata_buffer) < 0) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* Every metadata block starts with a 16-bit header *\/\n\theader = get_unaligned_le16(metadata_buffer + table_offset);\n\tmetadata = metadata_buffer + table_offset + SQFS_HEADER_SIZE;\n\n\tif (!metadata || !header) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tentries = malloc(SQFS_METADATA_BLOCK_SIZE);\n\tif (!entries) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tif (SQFS_COMPRESSED_METADATA(header)) {\n\t\tsrc_len = SQFS_METADATA_SIZE(header);\n\t\tdest_len = SQFS_METADATA_BLOCK_SIZE;\n\t\tret = sqfs_decompress(&ctxt, entries, &dest_len, metadata,\n\t\t\t\t      src_len);\n\t\tif (ret) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\t} else {\n\t\tmemcpy(entries, metadata, SQFS_METADATA_SIZE(header));\n\t}\n\n\t*e = entries[offset];\n\tret = SQFS_COMPRESSED_BLOCK(e->size);\n\nout:\n\tfree(entries);\n\tfree(metadata_buffer);\n\tfree(table);\n\n\treturn ret;\n}","target":0,"code_token_length":656,"total_token_length":892,"max_tokens_setting":1024}
+{"idx":15812,"func":"static gcry_err_code_t pubkey_decrypt ( int algorithm , gcry_mpi_t * result , gcry_mpi_t * data , gcry_mpi_t * skey , int flags ) {\n gcry_pk_spec_t * pubkey ;\n gcry_module_t module ;\n gcry_err_code_t rc ;\n int i ;\n * result = NULL ;\n if ( DBG_CIPHER && ! fips_mode ( ) ) {\n log_debug ( \"pubkey_decrypt: algo=%d\\n\" , algorithm ) ;\n for ( i = 0 ;\n i < pubkey_get_nskey ( algorithm ) ;\n i ++ ) log_mpidump ( \" skey\" , skey [ i ] ) ;\n for ( i = 0 ;\n i < pubkey_get_nenc ( algorithm ) ;\n i ++ ) log_mpidump ( \" data\" , data [ i ] ) ;\n }\n ath_mutex_lock ( & pubkeys_registered_lock ) ;\n module = _gcry_module_lookup_id ( pubkeys_registered , algorithm ) ;\n if ( module ) {\n pubkey = ( gcry_pk_spec_t * ) module -> spec ;\n rc = pubkey -> decrypt ( algorithm , result , data , skey , flags ) ;\n _gcry_module_release ( module ) ;\n goto ready ;\n }\n rc = GPG_ERR_PUBKEY_ALGO ;\n ready : ath_mutex_unlock ( & pubkeys_registered_lock ) ;\n if ( ! rc && DBG_CIPHER && ! fips_mode ( ) ) log_mpidump ( \" plain\" , * result ) ;\n return rc ;\n }","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":103249,"func":"  absl::Status Parse(const TfLiteNode* tflite_node,\n                     const TfLiteRegistration* registration,\n                     GraphFloat32* graph, ObjectReader* reader) final {\n    Node* node = graph->NewNode();\n    node->operation.type = ToString(OperationType::PAD);\n    RETURN_IF_ERROR(reader->AddInput(node, 0));\n    RETURN_IF_ERROR(reader->AddOutputs(node));\n\n    PadAttributes attr;\n    if (mirror_pad_) {\n      attr.type = PaddingContentType::REFLECT;\n    } else \/*zero pad*\/ {\n      attr.type = PaddingContentType::ZEROS;\n    }\n\n    Tensor<HW, DataType::INT32> paddings;\n    RETURN_IF_ERROR(reader->ReadTensor(1, &paddings));\n\n    if (paddings.shape.h == 4 && paddings.shape.w == 2) {\n      \/\/ 4x2 tensor with paddings.\n      attr.prepended = BHWC(paddings.data[0], paddings.data[2],\n                            paddings.data[4], paddings.data[6]);\n      attr.appended = BHWC(paddings.data[1], paddings.data[3], paddings.data[5],\n                           paddings.data[7]);\n    } else if (paddings.shape.h == 3 && paddings.shape.w == 2) {\n      \/\/ 3x2 tensor with paddings.\n      attr.prepended =\n          BHWC(1, paddings.data[0], paddings.data[2], paddings.data[4]);\n      attr.appended =\n          BHWC(1, paddings.data[1], paddings.data[3], paddings.data[5]);\n    } else {\n      \/\/ It shouldn't fail here since it's checked at IsSupported().\n      return absl::InvalidArgumentError(\n          \"Paddings tensor has unexpected shape.\");\n    }\n    node->operation.attributes = attr;\n    return absl::OkStatus();\n  }","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":508811,"func":"rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_data, const char *id)\n{\n    RsvgDrawingCtx\t\t*draw;\n    RsvgNodeSvg\t\t\t*root;\n    RsvgNode\t\t\t*node;\n    RsvgBbox\t\t\t bbox;\n    RsvgDimensionData    dimension_data;\n    cairo_surface_t\t\t*target = NULL;\n    cairo_t\t\t\t\t*cr = NULL;\n    gboolean\t\t\t ret = FALSE;\n\n    g_return_val_if_fail (handle, FALSE);\n    g_return_val_if_fail (position_data, FALSE);\n\n    \/* Short-cut when no id is given. *\/\n    if (NULL == id || '\\0' == *id) {\n        position_data->x = 0;\n        position_data->y = 0;\n        return TRUE;\n    }\n\n    memset (position_data, 0, sizeof (*position_data));\n    memset (&dimension_data, 0, sizeof (dimension_data));\n\n    node = rsvg_defs_lookup (handle->priv->defs, id);\n    if (!node) {\n        return FALSE;\n    } else if (node == handle->priv->treebase) {\n        \/* Root node. *\/\n        position_data->x = 0;\n        position_data->y = 0;\n        return TRUE;\n    }\n\n    root = (RsvgNodeSvg *) handle->priv->treebase;\n    if (!root)\n        return FALSE;\n\n    target = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1);\n    cr = cairo_create  (target);\n    draw = rsvg_cairo_new_drawing_ctx (cr, handle);\n    if (!draw)\n        goto bail;\n\n    while (node != NULL) {\n        draw->drawsub_stack = g_slist_prepend (draw->drawsub_stack, node);\n        node = node->parent;\n    }\n\n    rsvg_state_push (draw);\n    cairo_save (cr);\n\n    rsvg_node_draw (handle->priv->treebase, draw, 0);\n    bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;\n\n    cairo_restore (cr);\n    rsvg_state_pop (draw);\n    rsvg_drawing_ctx_free (draw);\n\n    position_data->x = bbox.rect.x;\n    position_data->y = bbox.rect.y;\n    dimension_data.width = bbox.rect.width;\n    dimension_data.height = bbox.rect.height;\n\n    dimension_data.em = dimension_data.width;\n    dimension_data.ex = dimension_data.height;\n\n    if (handle->priv->size_func)\n        (*handle->priv->size_func) (&dimension_data.width, &dimension_data.height,\n                                    handle->priv->user_data);\n\n    ret = TRUE;\n\nbail:\n    if (cr)\n        cairo_destroy (cr);\n    if (target)\n        cairo_surface_destroy (target);\n\n    return ret;\n}","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":125618,"func":"xfs_attr_shortform_allfit(\n\tstruct xfs_buf\t\t*bp,\n\tstruct xfs_inode\t*dp)\n{\n\tstruct xfs_attr_leafblock *leaf;\n\tstruct xfs_attr_leaf_entry *entry;\n\txfs_attr_leaf_name_local_t *name_loc;\n\tstruct xfs_attr3_icleaf_hdr leafhdr;\n\tint\t\t\tbytes;\n\tint\t\t\ti;\n\tstruct xfs_mount\t*mp = bp->b_target->bt_mount;\n\n\tleaf = bp->b_addr;\n\txfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf);\n\tentry = xfs_attr3_leaf_entryp(leaf);\n\n\tbytes = sizeof(struct xfs_attr_sf_hdr);\n\tfor (i = 0; i < leafhdr.count; entry++, i++) {\n\t\tif (entry->flags & XFS_ATTR_INCOMPLETE)\n\t\t\tcontinue;\t\t\/* don't copy partial entries *\/\n\t\tif (!(entry->flags & XFS_ATTR_LOCAL))\n\t\t\treturn 0;\n\t\tname_loc = xfs_attr3_leaf_name_local(leaf, i);\n\t\tif (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)\n\t\t\treturn 0;\n\t\tif (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)\n\t\t\treturn 0;\n\t\tbytes += sizeof(struct xfs_attr_sf_entry) - 1\n\t\t\t\t+ name_loc->namelen\n\t\t\t\t+ be16_to_cpu(name_loc->valuelen);\n\t}\n\tif ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&\n\t    (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&\n\t    (bytes == sizeof(struct xfs_attr_sf_hdr)))\n\t\treturn -1;\n\treturn xfs_attr_shortform_bytesfit(dp, bytes);\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":338141,"func":"static inline void vmsvga_update_rect(struct vmsvga_state_s *s,\n\n                                      int x, int y, int w, int h)\n\n{\n\n    DisplaySurface *surface = qemu_console_surface(s->vga.con);\n\n    int line;\n\n    int bypl;\n\n    int width;\n\n    int start;\n\n    uint8_t *src;\n\n    uint8_t *dst;\n\n\n\n    if (x < 0) {\n\n        fprintf(stderr, \"%s: update x was < 0 (%d)\\n\", __func__, x);\n\n        w += x;\n\n        x = 0;\n\n    }\n\n    if (w < 0) {\n\n        fprintf(stderr, \"%s: update w was < 0 (%d)\\n\", __func__, w);\n\n        w = 0;\n\n    }\n\n    if (x + w > surface_width(surface)) {\n\n        fprintf(stderr, \"%s: update width too large x: %d, w: %d\\n\",\n\n                __func__, x, w);\n\n        x = MIN(x, surface_width(surface));\n\n        w = surface_width(surface) - x;\n\n    }\n\n\n\n    if (y < 0) {\n\n        fprintf(stderr, \"%s: update y was < 0 (%d)\\n\",  __func__, y);\n\n        h += y;\n\n        y = 0;\n\n    }\n\n    if (h < 0) {\n\n        fprintf(stderr, \"%s: update h was < 0 (%d)\\n\",  __func__, h);\n\n        h = 0;\n\n    }\n\n    if (y + h > surface_height(surface)) {\n\n        fprintf(stderr, \"%s: update height too large y: %d, h: %d\\n\",\n\n                __func__, y, h);\n\n        y = MIN(y, surface_height(surface));\n\n        h = surface_height(surface) - y;\n\n    }\n\n\n\n    bypl = surface_stride(surface);\n\n    width = surface_bytes_per_pixel(surface) * w;\n\n    start = surface_bytes_per_pixel(surface) * x + bypl * y;\n\n    src = s->vga.vram_ptr + start;\n\n    dst = surface_data(surface) + start;\n\n\n\n    for (line = h; line > 0; line--, src += bypl, dst += bypl) {\n\n        memcpy(dst, src, width);\n\n    }\n\n    dpy_gfx_update(s->vga.con, x, y, w, h);\n\n}\n","target":1,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":401055,"func":"static int cirrus_vga_read_gr(CirrusVGAState * s, unsigned reg_index)\n{\n    switch (reg_index) {\n    case 0x00: \/\/ Standard VGA, BGCOLOR 0x000000ff\n        return s->cirrus_shadow_gr0;\n    case 0x01: \/\/ Standard VGA, FGCOLOR 0x000000ff\n        return s->cirrus_shadow_gr1;\n    case 0x02:\t\t\t\/\/ Standard VGA\n    case 0x03:\t\t\t\/\/ Standard VGA\n    case 0x04:\t\t\t\/\/ Standard VGA\n    case 0x06:\t\t\t\/\/ Standard VGA\n    case 0x07:\t\t\t\/\/ Standard VGA\n    case 0x08:\t\t\t\/\/ Standard VGA\n        return s->vga.gr[s->vga.gr_index];\n    case 0x05:\t\t\t\/\/ Standard VGA, Cirrus extended mode\n    default:\n\tbreak;\n    }\n\n    if (reg_index < 0x3a) {\n\treturn s->vga.gr[reg_index];\n    } else {\n#ifdef DEBUG_CIRRUS\n\tprintf(\"cirrus: inport gr_index %02x\\n\", reg_index);\n#endif\n\treturn 0xff;\n    }\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":109474,"func":"static int vcf_idx_init(htsFile *fp, bcf_hdr_t *h, int min_shift, const char *fnidx) {\n    int n_lvls, fmt;\n\n    if (min_shift == 0) {\n        min_shift = 14;\n        n_lvls = 5;\n        fmt = HTS_FMT_TBI;\n    } else {\n        \/\/ Set initial n_lvls to match tbx_index()\n        int starting_n_lvls = (TBX_MAX_SHIFT - min_shift + 2) \/ 3;\n        \/\/ Increase if necessary\n        n_lvls = idx_calc_n_lvls_ids(h, min_shift, starting_n_lvls, NULL);\n        fmt = HTS_FMT_CSI;\n    }\n\n    fp->idx = hts_idx_init(0, fmt, bgzf_tell(fp->fp.bgzf), min_shift, n_lvls);\n    if (!fp->idx) return -1;\n\n    \/\/ Tabix meta data, added even in CSI for VCF\n    uint8_t conf[4*7];\n    u32_to_le(TBX_VCF, conf+0);  \/\/ fmt\n    u32_to_le(1,       conf+4);  \/\/ name col\n    u32_to_le(2,       conf+8);  \/\/ beg col\n    u32_to_le(0,       conf+12); \/\/ end col\n    u32_to_le('#',     conf+16); \/\/ comment\n    u32_to_le(0,       conf+20); \/\/ n.skip\n    u32_to_le(0,       conf+24); \/\/ ref name len\n    if (hts_idx_set_meta(fp->idx, sizeof(conf)*sizeof(*conf), (uint8_t *)conf, 1) < 0) {\n        hts_idx_destroy(fp->idx);\n        fp->idx = NULL;\n        return -1;\n    }\n    fp->fnidx = fnidx;\n\n    return 0;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":502061,"func":"static int replmd_process_backlink(struct ldb_module *module, struct la_backlink *bl, struct ldb_request *parent)\n{\n\tstruct ldb_dn *target_dn, *source_dn;\n\tint ret;\n\tstruct ldb_context *ldb = ldb_module_get_ctx(module);\n\tstruct ldb_message *msg;\n\tTALLOC_CTX *frame = talloc_stackframe();\n\tchar *dn_string;\n\n\t\/*\n\t  - find DN of target\n\t  - find DN of source\n\t  - construct ldb_message\n              - either an add or a delete\n\t *\/\n\tret = dsdb_module_dn_by_guid(module, frame, &bl->target_guid, &target_dn, parent);\n\tif (ret != LDB_SUCCESS) {\n\t\tstruct GUID_txt_buf guid_str;\n\t\tDBG_WARNING(\"Failed to find target DN for linked attribute with GUID %s\\n\",\n\t\t\t    GUID_buf_string(&bl->target_guid, &guid_str));\n\t\tDBG_WARNING(\"Please run 'samba-tool dbcheck' to resolve any missing backlinks.\\n\");\n\t\ttalloc_free(frame);\n\t\treturn LDB_SUCCESS;\n\t}\n\n\tmsg = ldb_msg_new(frame);\n\tif (msg == NULL) {\n\t\tldb_module_oom(module);\n\t\ttalloc_free(frame);\n\t\treturn LDB_ERR_OPERATIONS_ERROR;\n\t}\n\n\tsource_dn = ldb_dn_copy(frame, bl->forward_dn);\n\tif (!source_dn) {\n\t\tldb_module_oom(module);\n\t\ttalloc_free(frame);\n\t\treturn LDB_ERR_OPERATIONS_ERROR;\n\t} else {\n\t\t\/* Filter down to the attributes we want in the backlink *\/\n\t\tconst char *accept[] = { \"GUID\", \"SID\", NULL };\n\t\tldb_dn_extended_filter(source_dn, accept);\n\t}\n\n\t\/* construct a ldb_message for adding\/deleting the backlink *\/\n\tmsg->dn = target_dn;\n\tdn_string = ldb_dn_get_extended_linearized(frame, bl->forward_dn, 1);\n\tif (!dn_string) {\n\t\tldb_module_oom(module);\n\t\ttalloc_free(frame);\n\t\treturn LDB_ERR_OPERATIONS_ERROR;\n\t}\n\tret = ldb_msg_add_steal_string(msg, bl->attr_name, dn_string);\n\tif (ret != LDB_SUCCESS) {\n\t\ttalloc_free(frame);\n\t\treturn ret;\n\t}\n\tmsg->elements[0].flags = bl->active?LDB_FLAG_MOD_ADD:LDB_FLAG_MOD_DELETE;\n\n\t\/* a backlink should never be single valued. Unfortunately the\n\t   exchange schema has a attribute\n\t   msExchBridgeheadedLocalConnectorsDNBL which is single\n\t   valued and a backlink. We need to cope with that by\n\t   ignoring the single value flag *\/\n\tmsg->elements[0].flags |= LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK;\n\n\tret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE, parent);\n\tif (ret == LDB_ERR_NO_SUCH_ATTRIBUTE && !bl->active) {\n\t\t\/* we allow LDB_ERR_NO_SUCH_ATTRIBUTE as success to\n\t\t   cope with possible corruption where the backlink has\n\t\t   already been removed *\/\n\t\tDEBUG(3,(\"WARNING: backlink from %s already removed from %s - %s\\n\",\n\t\t\t ldb_dn_get_linearized(target_dn),\n\t\t\t ldb_dn_get_linearized(source_dn),\n\t\t\t ldb_errstring(ldb)));\n\t\tret = LDB_SUCCESS;\n\t} else if (ret != LDB_SUCCESS) {\n\t\tldb_asprintf_errstring(ldb, \"Failed to %s backlink from %s to %s - %s\",\n\t\t\t\t       bl->active?\"add\":\"remove\",\n\t\t\t\t       ldb_dn_get_linearized(source_dn),\n\t\t\t\t       ldb_dn_get_linearized(target_dn),\n\t\t\t\t       ldb_errstring(ldb));\n\t\ttalloc_free(frame);\n\t\treturn ret;\n\t}\n\ttalloc_free(frame);\n\treturn ret;\n}","target":0,"code_token_length":772,"total_token_length":1008,"max_tokens_setting":1024}
+{"idx":402756,"func":"static MagickBooleanType ReadPSDChannelZip(Image *image,const size_t channels,\n  const ssize_t type,const PSDCompressionType compression,\n  const size_t compact_size,ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  register unsigned char\n    *p;\n\n  size_t\n    count,\n    length,\n    packet_size,\n    row_size;\n\n  ssize_t\n    y;\n\n  unsigned char\n    *compact_pixels,\n    *pixels;\n\n  z_stream\n    stream;\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n       \"      layer data is ZIP compressed\");\n\n  compact_pixels=(unsigned char *) AcquireQuantumMemory(compact_size,\n    sizeof(*compact_pixels));\n  if (compact_pixels == (unsigned char *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n\n  packet_size=GetPSDPacketSize(image);\n  row_size=image->columns*packet_size;\n  count=image->rows*row_size;\n\n  pixels=(unsigned char *) AcquireQuantumMemory(count,sizeof(*pixels));\n  if (pixels == (unsigned char *) NULL)\n    {\n      compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);\n      ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n        image->filename);\n    }\n\n  ResetMagickMemory(&stream,0,sizeof(stream));\n  stream.data_type=Z_BINARY;\n  (void) ReadBlob(image,compact_size,compact_pixels);\n\n  stream.next_in=(Bytef *)compact_pixels;\n  stream.avail_in=(uInt) compact_size;\n  stream.next_out=(Bytef *)pixels;\n  stream.avail_out=(uInt) count;\n\n  if (inflateInit(&stream) == Z_OK)\n    {\n      int\n        ret;\n\n      while (stream.avail_out > 0)\n      {\n        ret=inflate(&stream,Z_SYNC_FLUSH);\n        if ((ret != Z_OK) && (ret != Z_STREAM_END))\n          {\n            (void) inflateEnd(&stream);\n            compact_pixels=(unsigned char *) RelinquishMagickMemory(\n              compact_pixels);\n            pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n            return(MagickFalse);\n          }\n      }\n      (void) inflateEnd(&stream);\n    }\n\n  if (compression == ZipWithPrediction)\n  {\n     p=pixels;\n     while (count > 0)\n     {\n       length=image->columns;\n       while (--length)\n       {\n         if (packet_size == 2)\n           {\n             p[2]+=p[0]+((p[1]+p[3]) >> 8);\n             p[3]+=p[1];\n           }\n         else\n          *(p+1)+=*p;\n         p+=packet_size;\n       }\n       p+=packet_size;\n       count-=row_size;\n     }\n  }\n\n  status=MagickTrue;\n  p=pixels;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    status=ReadPSDChannelPixels(image,channels,y,type,p,exception);\n    if (status == MagickFalse)\n      break;\n\n    p+=row_size;\n  }\n\n  compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);\n  pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n  return(status);\n}","target":0,"code_token_length":710,"total_token_length":946,"max_tokens_setting":1024}
+{"idx":388586,"func":"static void qmp_query_auth(VncDisplay *vd, VncInfo2 *info)\n{\n    switch (vd->auth) {\n    case VNC_AUTH_VNC:\n        info->auth = VNC_PRIMARY_AUTH_VNC;\n        break;\n    case VNC_AUTH_RA2:\n        info->auth = VNC_PRIMARY_AUTH_RA2;\n        break;\n    case VNC_AUTH_RA2NE:\n        info->auth = VNC_PRIMARY_AUTH_RA2NE;\n        break;\n    case VNC_AUTH_TIGHT:\n        info->auth = VNC_PRIMARY_AUTH_TIGHT;\n        break;\n    case VNC_AUTH_ULTRA:\n        info->auth = VNC_PRIMARY_AUTH_ULTRA;\n        break;\n    case VNC_AUTH_TLS:\n        info->auth = VNC_PRIMARY_AUTH_TLS;\n        break;\n    case VNC_AUTH_VENCRYPT:\n        info->auth = VNC_PRIMARY_AUTH_VENCRYPT;\n        info->has_vencrypt = true;\n        switch (vd->subauth) {\n        case VNC_AUTH_VENCRYPT_PLAIN:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_PLAIN;\n            break;\n        case VNC_AUTH_VENCRYPT_TLSNONE:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_NONE;\n            break;\n        case VNC_AUTH_VENCRYPT_TLSVNC:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_VNC;\n            break;\n        case VNC_AUTH_VENCRYPT_TLSPLAIN:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_PLAIN;\n            break;\n        case VNC_AUTH_VENCRYPT_X509NONE:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_NONE;\n            break;\n        case VNC_AUTH_VENCRYPT_X509VNC:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_VNC;\n            break;\n        case VNC_AUTH_VENCRYPT_X509PLAIN:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_PLAIN;\n            break;\n        case VNC_AUTH_VENCRYPT_TLSSASL:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_SASL;\n            break;\n        case VNC_AUTH_VENCRYPT_X509SASL:\n            info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_SASL;\n            break;\n        default:\n            info->has_vencrypt = false;\n            break;\n        }\n        break;\n    case VNC_AUTH_SASL:\n        info->auth = VNC_PRIMARY_AUTH_SASL;\n        break;\n    case VNC_AUTH_NONE:\n    default:\n        info->auth = VNC_PRIMARY_AUTH_NONE;\n        break;\n    }\n}","target":0,"code_token_length":587,"total_token_length":823,"max_tokens_setting":1024}
+{"idx":257240,"func":"static void prep_NVRAM_init ( void ) {\n m48t59_t * nvram ;\n nvram = m48t59_init ( 8 , 0x0074 , NVRAM_SIZE ) ;\n NVRAM_set_word ( nvram , 0x00 , NVRAM_SIZE >> 10 ) ;\n NVRAM_set_byte ( nvram , 0x02 , 0x01 ) ;\n NVRAM_set_byte ( nvram , 0x03 , 0x01 ) ;\n NVRAM_set_byte ( nvram , 0x08 , 0x00 ) ;\n NVRAM_set_byte ( nvram , 0x09 , 'B' ) ;\n NVRAM_set_byte ( nvram , 0x0A , 0x00 ) ;\n NVRAM_set_byte ( nvram , 0x0B , 0x00 ) ;\n NVRAM_set_word ( nvram , 0x0C , 0x01 ) ;\n NVRAM_set_word ( nvram , 0x0E , 0x01 ) ;\n NVRAM_set_lword ( nvram , 0x20 , 0x00 ) ;\n NVRAM_set_lword ( nvram , 0x24 , 0x00 ) ;\n NVRAM_set_lword ( nvram , 0x28 , 0x00 ) ;\n NVRAM_set_crc ( nvram , 0x1C , 0x0C , 32 ) ;\n NVRAM_set_lword ( nvram , 0xC4 , 0x0100 ) ;\n NVRAM_set_lword ( nvram , 0xC8 , NVRAM_END - NVRAM_OSAREA_SIZE - NVRAM_CONFSIZE - 0x0100 ) ;\n NVRAM_set_lword ( nvram , 0xD4 , NVRAM_END - NVRAM_CONFSIZE ) ;\n NVRAM_set_lword ( nvram , 0xD8 , NVRAM_CONFSIZE ) ;\n NVRAM_set_lword ( nvram , 0xE8 , NVRAM_END - NVRAM_CONFSIZE - NVRAM_OSAREA_SIZE ) ;\n NVRAM_set_lword ( nvram , 0xEC , NVRAM_OSAREA_SIZE ) ;\n NVRAM_set_crc ( nvram , 0x04 , 0x00 , NVRAM_END - NVRAM_CONFSIZE - NVRAM_OSAREA_SIZE ) ;\n NVRAM_set_crc ( nvram , 0x06 , NVRAM_END - NVRAM_CONFSIZE , NVRAM_CONFSIZE ) ;\n }","target":0,"code_token_length":589,"total_token_length":825,"max_tokens_setting":1024}
+{"idx":335935,"func":"static void common_init(MpegEncContext * s)\n\n{\n\n    static int inited=0;\n\n\n\n    switch(s->msmpeg4_version){\n\n    case 1:\n\n    case 2:\n\n        s->y_dc_scale_table=\n\n        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;\n\n        break;\n\n    case 3:\n\n        if(s->workaround_bugs){\n\n            s->y_dc_scale_table= old_ff_y_dc_scale_table;\n\n            s->c_dc_scale_table= old_ff_c_dc_scale_table;\n\n        } else{\n\n            s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table;\n\n            s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;\n\n        }\n\n        break;\n\n    case 4:\n\n    case 5:\n\n        s->y_dc_scale_table= wmv1_y_dc_scale_table;\n\n        s->c_dc_scale_table= wmv1_c_dc_scale_table;\n\n        break;\n\n#if defined(CONFIG_WMV3_DECODER)||defined(CONFIG_VC1_DECODER)\n\n    case 6:\n\n        s->y_dc_scale_table= wmv3_dc_scale_table;\n\n        s->c_dc_scale_table= wmv3_dc_scale_table;\n\n        break;\n\n#endif\n\n\n\n    }\n\n\n\n\n\n    if(s->msmpeg4_version>=4){\n\n        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , wmv1_scantable[1]);\n\n        ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, wmv1_scantable[2]);\n\n        ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, wmv1_scantable[3]);\n\n        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , wmv1_scantable[0]);\n\n    }\n\n    \/\/Note the default tables are set in common_init in mpegvideo.c\n\n\n\n    if(!inited){\n\n        inited=1;\n\n\n\n        init_h263_dc_for_msmpeg4();\n\n    }\n\n}\n","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":80697,"func":"static void updatePortStats(struct port_stats **stats, u_int32_t port,\n\t\t\t    u_int32_t addr, u_int8_t version,\n                            u_int32_t num_pkts, u_int32_t num_bytes,\n                            const char *proto) {\n\n  struct port_stats *s = NULL;\n  int count = 0;\n\n  HASH_FIND_INT(*stats, &port, s);\n  if(s == NULL) {\n    s = (struct port_stats*)calloc(1, sizeof(struct port_stats));\n    if(!s) return;\n\n    s->port = port, s->num_pkts = num_pkts, s->num_bytes = num_bytes;\n    s->num_addr = 1, s->cumulative_addr = 1; s->num_flows = 1;\n\n    updateTopIpAddress(addr, version, proto, 1, s->top_ip_addrs, MAX_NUM_IP_ADDRESS);\n\n    s->addr_tree = (addr_node *) malloc(sizeof(addr_node));\n    if(!s->addr_tree) {\n      free(s);\n      return;\n    }\n\n    s->addr_tree->addr = addr;\n    s->addr_tree->version = version;\n    strncpy(s->addr_tree->proto, proto, sizeof(s->addr_tree->proto));\n    s->addr_tree->count = 1;\n    s->addr_tree->left = NULL;\n    s->addr_tree->right = NULL;\n\n    HASH_ADD_INT(*stats, port, s);\n  }\n  else{\n    count = updateIpTree(addr, version, &(*s).addr_tree, proto);\n\n    if(count == UPDATED_TREE) s->num_addr++;\n\n    if(count) {\n      s->cumulative_addr++;\n      updateTopIpAddress(addr, version, proto, count, s->top_ip_addrs, MAX_NUM_IP_ADDRESS);\n    }\n\n    s->num_pkts += num_pkts, s->num_bytes += num_bytes, s->num_flows++;\n  }\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":160178,"func":"cockpit_session_unref (gpointer data)\n{\n  CockpitSession *session = data;\n  CockpitCreds *creds;\n  GObject *object;\n\n  session->refs--;\n  if (session->refs > 0)\n    return;\n\n  cockpit_session_reset (data);\n\n  g_free (session->name);\n  g_free (session->cookie);\n\n  if (session->authorize)\n    json_object_unref (session->authorize);\n\n  if (session->transport)\n    {\n      if (session->control_sig)\n        g_signal_handler_disconnect (session->transport, session->control_sig);\n      if (session->close_sig)\n        g_signal_handler_disconnect (session->transport, session->close_sig);\n      g_object_unref (session->transport);\n    }\n\n  if (session->service)\n    {\n      creds = cockpit_web_service_get_creds (session->service);\n      object = G_OBJECT (session->service);\n      session->service = NULL;\n      if (creds)\n        cockpit_creds_poison (creds);\n      if (session->idling_sig)\n        g_signal_handler_disconnect (object, session->idling_sig);\n      if (session->destroy_sig)\n        g_signal_handler_disconnect (object, session->destroy_sig);\n      g_object_weak_unref (object, on_web_service_gone, session);\n      g_object_run_dispose (object);\n      g_object_unref (object);\n    }\n\n  if (session->timeout_tag)\n    g_source_remove (session->timeout_tag);\n\n  g_free (session);\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":200924,"func":"find_same_op(const gs_composite_t *composite_action, int my_op, gs_composite_t **ppcte)\n{\n    const gs_pdf14trans_t *pct0 = (gs_pdf14trans_t *)composite_action;\n    gs_composite_t *pct = *ppcte;\n\n    for (;;) {\n        if (pct->type->comp_id == GX_COMPOSITOR_PDF14_TRANS) {\n            gs_pdf14trans_t *pct_pdf14 = (gs_pdf14trans_t *)pct;\n\n            *ppcte = pct;\n            if (pct_pdf14->params.pdf14_op != my_op)\n                return COMP_ENQUEUE;\n            if (pct_pdf14->params.csel == pct0->params.csel) {\n                \/* If the new parameters completely replace the old ones\n                   then remove the old one from the queu *\/\n                if ((pct_pdf14->params.changed & pct0->params.changed) ==\n                    pct_pdf14->params.changed) {\n                    return COMP_REPLACE_CURR;\n                } else {\n                    return COMP_ENQUEUE;\n                }\n            }\n        } else\n            return COMP_ENQUEUE;\n        pct = pct->prev;\n        if (pct == NULL)\n            return COMP_ENQUEUE; \/* Not in queue. *\/\n    }\n}\n","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":357853,"func":"static int empty_dir(struct inode *inode)\n{\n\tunsigned int offset;\n\tstruct buffer_head *bh;\n\tstruct ext4_dir_entry_2 *de, *de1;\n\tstruct super_block *sb;\n\tint err = 0;\n\n\tsb = inode->i_sb;\n\tif (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) ||\n\t    !(bh = ext4_bread(NULL, inode, 0, 0, &err))) {\n\t\tif (err)\n\t\t\text4_error(inode->i_sb, __func__,\n\t\t\t\t   \"error %d reading directory #%lu offset 0\",\n\t\t\t\t   err, inode->i_ino);\n\t\telse\n\t\t\text4_warning(inode->i_sb, __func__,\n\t\t\t\t     \"bad directory (dir #%lu) - no data block\",\n\t\t\t\t     inode->i_ino);\n\t\treturn 1;\n\t}\n\tde = (struct ext4_dir_entry_2 *) bh->b_data;\n\tde1 = ext4_next_entry(de);\n\tif (le32_to_cpu(de->inode) != inode->i_ino ||\n\t\t\t!le32_to_cpu(de1->inode) ||\n\t\t\tstrcmp(\".\", de->name) ||\n\t\t\tstrcmp(\"..\", de1->name)) {\n\t\text4_warning(inode->i_sb, \"empty_dir\",\n\t\t\t     \"bad directory (dir #%lu) - no `.' or `..'\",\n\t\t\t     inode->i_ino);\n\t\tbrelse(bh);\n\t\treturn 1;\n\t}\n\toffset = ext4_rec_len_from_disk(de->rec_len) +\n\t\t ext4_rec_len_from_disk(de1->rec_len);\n\tde = ext4_next_entry(de1);\n\twhile (offset < inode->i_size) {\n\t\tif (!bh ||\n\t\t\t(void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {\n\t\t\terr = 0;\n\t\t\tbrelse(bh);\n\t\t\tbh = ext4_bread(NULL, inode,\n\t\t\t\toffset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err);\n\t\t\tif (!bh) {\n\t\t\t\tif (err)\n\t\t\t\t\text4_error(sb, __func__,\n\t\t\t\t\t\t   \"error %d reading directory\"\n\t\t\t\t\t\t   \" #%lu offset %u\",\n\t\t\t\t\t\t   err, inode->i_ino, offset);\n\t\t\t\toffset += sb->s_blocksize;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tde = (struct ext4_dir_entry_2 *) bh->b_data;\n\t\t}\n\t\tif (!ext4_check_dir_entry(\"empty_dir\", inode, de, bh, offset)) {\n\t\t\tde = (struct ext4_dir_entry_2 *)(bh->b_data +\n\t\t\t\t\t\t\t sb->s_blocksize);\n\t\t\toffset = (offset | (sb->s_blocksize - 1)) + 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (le32_to_cpu(de->inode)) {\n\t\t\tbrelse(bh);\n\t\t\treturn 0;\n\t\t}\n\t\toffset += ext4_rec_len_from_disk(de->rec_len);\n\t\tde = ext4_next_entry(de);\n\t}\n\tbrelse(bh);\n\treturn 1;\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":93912,"func":"briopt_check(win_T *wp)\n{\n    char_u\t*p;\n    int\t\tbri_shift = 0;\n    long\tbri_min = 20;\n    int\t\tbri_sbr = FALSE;\n\n    p = wp->w_p_briopt;\n    while (*p != NUL)\n    {\n\tif (STRNCMP(p, \"shift:\", 6) == 0\n\t\t && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))\n\t{\n\t    p += 6;\n\t    bri_shift = getdigits(&p);\n\t}\n\telse if (STRNCMP(p, \"min:\", 4) == 0 && VIM_ISDIGIT(p[4]))\n\t{\n\t    p += 4;\n\t    bri_min = getdigits(&p);\n\t}\n\telse if (STRNCMP(p, \"sbr\", 3) == 0)\n\t{\n\t    p += 3;\n\t    bri_sbr = TRUE;\n\t}\n\tif (*p != ',' && *p != NUL)\n\t    return FAIL;\n\tif (*p == ',')\n\t    ++p;\n    }\n\n    wp->w_p_brishift = bri_shift;\n    wp->w_p_brimin   = bri_min;\n    wp->w_p_brisbr   = bri_sbr;\n\n    return OK;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":102195,"func":"static int bin_pe_init_exports(struct PE_(r_bin_pe_obj_t)* bin) {\n\tPE_(image_data_directory) * data_dir_export = &bin->data_directory[PE_IMAGE_DIRECTORY_ENTRY_EXPORT];\n\tPE_DWord export_dir_paddr = bin_pe_rva_to_paddr (bin, data_dir_export->VirtualAddress);\n\tif (!export_dir_paddr) {\n\t\t\/\/ This export-dir-paddr should only appear in DLL files\n\t\t\/\/ bprintf (\"Warning: Cannot find the paddr of the export directory\\n\");\n\t\treturn false;\n\t}\n\t\/\/ sdb_setn (DB, \"hdr.exports_directory\", export_dir_paddr);\n\t\/\/ bprintf (\"Pexports paddr at 0x%\"PFMT64x\"\\n\", export_dir_paddr);\n\tif (!(bin->export_directory = malloc (sizeof(PE_(image_export_directory))))) {\n\t\tr_sys_perror (\"malloc (export directory)\");\n\t\treturn false;\n\t}\n\tif (r_buf_read_at (bin->b, export_dir_paddr, (ut8*) bin->export_directory, sizeof (PE_(image_export_directory))) == -1) {\n\t\tbprintf (\"Warning: read (export directory)\\n\");\n\t\tfree (bin->export_directory);\n\t\tbin->export_directory = NULL;\n\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":96798,"func":"R_API char *cmd_syscall_dostr(RCore *core, int n) {\n\tchar *res = NULL;\n\tint i;\n\tchar str[64];\n\tif (n == -1) {\n\t\tn = (int)r_debug_reg_get (core->dbg, \"oeax\");\n\t\tif (!n || n == -1) {\n\t\t\tconst char *a0 = r_reg_get_name (core->anal->reg, R_REG_NAME_SN);\n\t\t\tn = (int)r_debug_reg_get (core->dbg, a0);\n\t\t}\n\t}\n\tRSyscallItem *item = r_syscall_get (core->anal->syscall, n, -1);\n\tif (!item) {\n\t\tres = r_str_appendf (res, \"%d = unknown ()\", n);\n\t\treturn res;\n\t}\n\tres = r_str_appendf (res, \"%d = %s (\", item->num, item->name);\n\t\/\/ TODO: move this to r_syscall\n\t\/\/TODO replace the hardcoded CC with the sdb ones\n\tfor (i = 0; i < item->args; i++) {\n\t\t\/\/ XXX this is a hack to make syscall args work on x86-32 and x86-64\n\t\t\/\/ we need to shift sn first.. which is bad, but needs to be redesigned\n\t\tint regidx = i;\n\t\tif (core->assembler->bits == 32) {\n\t\t\tregidx++;\n\t\t}\n\t\tut64 arg = r_debug_arg_get (core->dbg, R_ANAL_CC_TYPE_FASTCALL, regidx);\n\t\t\/\/r_cons_printf (\"(%d:0x%\"PFMT64x\")\\n\", i, arg);\n\t\tif (item->sargs) {\n\t\t\tswitch (item->sargs[i]) {\n\t\t\tcase 'p': \/\/ pointer\n\t\t\t\tres = r_str_appendf (res, \"0x%08\" PFMT64x \"\", arg);\n\t\t\t\tbreak;\n\t\t\tcase 'i':\n\t\t\t\tres = r_str_appendf (res, \"%\" PFMT64d \"\", arg);\n\t\t\t\tbreak;\n\t\t\tcase 'z':\n\t\t\t\tmemset (str, 0, sizeof (str));\n\t\t\t\tr_io_read_at (core->io, arg, (ut8 *)str, sizeof (str) - 1);\n\t\t\t\tr_str_filter (str, strlen (str));\n\t\t\t\tres = r_str_appendf (res, \"\\\"%s\\\"\", str);\n\t\t\t\tbreak;\n\t\t\tcase 'Z': {\n\t\t\t\t\/\/TODO replace the hardcoded CC with the sdb ones\n\t\t\t\tut64 len = r_debug_arg_get (core->dbg, R_ANAL_CC_TYPE_FASTCALL, i + 2);\n\t\t\t\tlen = R_MIN (len + 1, sizeof (str) - 1);\n\t\t\t\tif (len == 0) {\n\t\t\t\t\tlen = 16; \/\/ override default\n\t\t\t\t}\n\t\t\t\t(void)r_io_read_at (core->io, arg, (ut8 *)str, len);\n\t\t\t\tstr[len] = 0;\n\t\t\t\tr_str_filter (str, -1);\n\t\t\t\tres = r_str_appendf (res, \"\\\"%s\\\"\", str);\n\t\t\t} break;\n\t\t\tdefault:\n\t\t\t\tres = r_str_appendf (res, \"0x%08\" PFMT64x \"\", arg);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tres = r_str_appendf (res, \"0x%08\" PFMT64x \"\", arg);\n\t\t}\n\t\tif (i + 1 < item->args) {\n\t\t\tres = r_str_appendf (res, \", \");\n\t\t}\n\t}\n\tr_syscall_item_free (item);\n\tres = r_str_appendf (res, \")\");\n\treturn res;\n}","target":0,"code_token_length":785,"total_token_length":1021,"max_tokens_setting":1024}
+{"idx":361399,"func":"static int generate_key(schema_id schema,\n\t\t\tconst char *password,\n\t\t\tstruct pbkdf2_params *kdf_params,\n\t\t\tstruct pbe_enc_params *enc_params,\n\t\t\tgnutls_datum_t * key)\n{\n    opaque rnd[2];\n    int ret;\n\n    \/* We should use the flags here to use different\n     * encryption algorithms etc. \n     *\/\n\n    if (schema == PKCS12_ARCFOUR_SHA1)\n\tenc_params->cipher = GNUTLS_CIPHER_ARCFOUR_128;\n    else if (schema == PKCS12_3DES_SHA1)\n\tenc_params->cipher = GNUTLS_CIPHER_3DES_CBC;\n    else if (schema == PKCS12_RC2_40_SHA1)\n\tenc_params->cipher = GNUTLS_CIPHER_RC2_40_CBC;\n\n    _gnutls_get_random(rnd, 2, GNUTLS_STRONG_RANDOM);\n\n    \/* generate salt *\/\n\n    if (schema == PBES2)\n\tkdf_params->salt_size =\n\t    MIN(sizeof(kdf_params->salt), (uint) (10 + (rnd[1] % 10)));\n    else\n\tkdf_params->salt_size = 8;\n\n    _gnutls_get_random(kdf_params->salt, kdf_params->salt_size,\n\t\t       GNUTLS_STRONG_RANDOM);\n\n    kdf_params->iter_count = 256 + rnd[0];\n    key->size = kdf_params->key_size =\n\tgnutls_cipher_get_key_size(enc_params->cipher);\n\n    enc_params->iv_size = _gnutls_cipher_get_iv_size(enc_params->cipher);\n\n    key->data = gnutls_secure_malloc(key->size);\n    if (key->data == NULL) {\n\tgnutls_assert();\n\treturn GNUTLS_E_MEMORY_ERROR;\n    }\n\n    \/* now generate the key. \n     *\/\n\n    if (schema == PBES2) {\n\n\tret = gc_pkcs5_pbkdf2_sha1(password, strlen(password),\n\t\t\t\t   kdf_params->salt, kdf_params->salt_size,\n\t\t\t\t   kdf_params->iter_count,\n\t\t\t\t   kdf_params->key_size, key->data);\n\tif (ret != GC_OK) {\n\t    gnutls_assert();\n\t    return GNUTLS_E_ENCRYPTION_FAILED;\n\t}\n\n\tif (enc_params->iv_size)\n\t    _gnutls_get_random(enc_params->iv, enc_params->iv_size,\n\t\t\t       GNUTLS_WEAK_RANDOM);\n\n    } else {\t\t\t\/* PKCS12 schemas *\/\n\tret =\n\t    _pkcs12_string_to_key(1 \/*KEY*\/, kdf_params->salt,\n\t\t\t\t  kdf_params->salt_size,\n\t\t\t\t  kdf_params->iter_count, password,\n\t\t\t\t  kdf_params->key_size, key->data);\n\tif (ret < 0) {\n\t    gnutls_assert();\n\t    return ret;\n\t}\n\n\t\/* Now generate the IV\n\t *\/\n\tif (enc_params->iv_size) {\n\t    ret =\n\t\t_pkcs12_string_to_key(2 \/*IV*\/, kdf_params->salt,\n\t\t\t\t      kdf_params->salt_size,\n\t\t\t\t      kdf_params->iter_count, password,\n\t\t\t\t      enc_params->iv_size, enc_params->iv);\n\t    if (ret < 0) {\n\t\tgnutls_assert();\n\t\treturn ret;\n\t    }\n\t}\n    }\n\n\n    return 0;\n}","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":87299,"func":"    template<typename t, typename tc>\n    CImg<T>& draw_axis(const CImg<t>& values_x, const int y,\n                       const tc *const color, const float opacity=1,\n                       const unsigned int pattern=~0U, const unsigned int font_height=13,\n                       const bool allow_zero=true, const float round_x=0) {\n      if (is_empty()) return *this;\n      const int yt = (y + 3 + font_height)<_height?y + 3:y - 2 - (int)font_height;\n      const int siz = (int)values_x.size() - 1;\n      CImg<charT> txt(32);\n      CImg<T> a_label;\n      if (siz<=0) { \/\/ Degenerated case\n        draw_line(0,y,_width - 1,y,color,opacity,pattern);\n        if (!siz) {\n          cimg_snprintf(txt,txt._width,\"%g\",round_x?cimg::round((double)*values_x,round_x):(double)*values_x);\n          a_label.assign().draw_text(0,0,txt,color,(tc*)0,opacity,font_height);\n          const int\n            _xt = (width() - a_label.width())\/2,\n            xt = _xt<3?3:_xt + a_label.width()>=width() - 2?width() - 3 - a_label.width():_xt;\n          draw_point(width()\/2,y - 1,color,opacity).draw_point(width()\/2,y + 1,color,opacity);\n          if (allow_zero || *txt!='0' || txt[1]!=0)\n            draw_text(xt,yt,txt,color,(tc*)0,opacity,font_height);\n        }\n      } else { \/\/ Regular case\n        if (values_x[0]<values_x[siz]) draw_arrow(0,y,_width - 1,y,color,opacity,30,5,pattern);\n        else draw_arrow(_width - 1,y,0,y,color,opacity,30,5,pattern);\n        cimg_foroff(values_x,x) {\n          cimg_snprintf(txt,txt._width,\"%g\",round_x?cimg::round((double)values_x(x),round_x):(double)values_x(x));\n          a_label.assign().draw_text(0,0,txt,color,(tc*)0,opacity,font_height);\n          const int\n            xi = (int)(x*(_width - 1)\/siz),\n            _xt = xi - a_label.width()\/2,\n            xt = _xt<3?3:_xt + a_label.width()>=width() - 2?width() - 3 - a_label.width():_xt;\n          draw_point(xi,y - 1,color,opacity).draw_point(xi,y + 1,color,opacity);\n          if (allow_zero || *txt!='0' || txt[1]!=0)\n            draw_text(xt,yt,txt,color,(tc*)0,opacity,font_height);\n        }\n      }\n      return *this;","target":0,"code_token_length":644,"total_token_length":880,"max_tokens_setting":1024}
+{"idx":3535,"func":"process(register int code, unsigned char** fill)\n{\n    int incode;\n    static unsigned char firstchar;\n\n    if (code == clear) {\n\tcodesize = datasize + 1;\n\tcodemask = (1 << codesize) - 1;\n\tavail = clear + 2;\n\toldcode = -1;\n\treturn 1;\n    }\n\n    if (oldcode == -1) {\n\t*(*fill)++ = suffix[code];\n\tfirstchar = oldcode = code;\n\treturn 1;\n    }\n    if (code > avail) {\n\tfprintf(stderr, \"code %d too large for %d\\n\", code, avail);\n\treturn 0; \n    }\n\n    incode = code;\n    if (code == avail) {      \/* the first code is always < avail *\/\n\t*stackp++ = firstchar;\n\tcode = oldcode;\n    }\n    while (code > clear) {\n\t*stackp++ = suffix[code];\n\tcode = prefix[code];\n    }\n\n    *stackp++ = firstchar = suffix[code];\n    prefix[avail] = oldcode;\n    suffix[avail] = firstchar;\n    avail++;\n\n    if (((avail & codemask) == 0) && (avail < 4096)) {\n\tcodesize++;\n\tcodemask += avail;\n    }\n    oldcode = incode;\n    do {\n\t*(*fill)++ = *--stackp;\n    } while (stackp > stack);\n    return 1;\n}","target":1,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":450514,"func":"static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,\n\t\tstruct nfs_open_context *ctx,\n\t\tstruct nfs4_lock_state *lsp,\n\t\tstruct nfs_seqid *seqid)\n{\n\tstruct nfs4_unlockdata *data;\n\tstruct rpc_message msg = {\n\t\t.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU],\n\t\t.rpc_cred = ctx->cred,\n\t};\n\tstruct rpc_task_setup task_setup_data = {\n\t\t.rpc_client = NFS_CLIENT(lsp->ls_state->inode),\n\t\t.rpc_message = &msg,\n\t\t.callback_ops = &nfs4_locku_ops,\n\t\t.workqueue = nfsiod_workqueue,\n\t\t.flags = RPC_TASK_ASYNC,\n\t};\n\n\tnfs4_state_protect(NFS_SERVER(lsp->ls_state->inode)->nfs_client,\n\t\tNFS_SP4_MACH_CRED_CLEANUP, &task_setup_data.rpc_client, &msg);\n\n\t\/* Ensure this is an unlock - when canceling a lock, the\n\t * canceled lock is passed in, and it won't be an unlock.\n\t *\/\n\tfl->fl_type = F_UNLCK;\n\tif (fl->fl_flags & FL_CLOSE)\n\t\tset_bit(NFS_CONTEXT_UNLOCK, &ctx->flags);\n\n\tdata = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid);\n\tif (data == NULL) {\n\t\tnfs_free_seqid(seqid);\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\n\tnfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1, 0);\n\tmsg.rpc_argp = &data->arg;\n\tmsg.rpc_resp = &data->res;\n\ttask_setup_data.callback_data = data;\n\treturn rpc_run_task(&task_setup_data);\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":512711,"func":"void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog,\n\t\t\t\tint firstPage, int lastPage,\n                                GBool duplexA) {\n  Page *page;\n  Dict *resDict;\n  Annots *annots;\n  Object obj1, obj2;\n  int pg, i;\n\n  if (mode == psModeForm) {\n    \/\/ swap the form and xpdf dicts\n    writePS(\"xpdf end begin dup begin\\n\");\n  } else {\n    writePS(\"xpdf begin\\n\");\n  }\n  for (pg = firstPage; pg <= lastPage; ++pg) {\n    page = doc->getPage(pg);\n    if (!page) {\n      error(-1, \"Failed writing resources for page %d\", pg);\n      continue;\n    }\n    if ((resDict = page->getResourceDict())) {\n      setupResources(resDict);\n    }\n    annots = new Annots(xref, catalog, page->getAnnots(&obj1));\n    obj1.free();\n    for (i = 0; i < annots->getNumAnnots(); ++i) {\n      if (annots->getAnnot(i)->getAppearance(&obj1)->isStream()) {\n\tobj1.streamGetDict()->lookup(\"Resources\", &obj2);\n\tif (obj2.isDict()) {\n\t  setupResources(obj2.getDict());\n\t}\n\tobj2.free();\n      }\n      obj1.free();\n    }\n    delete annots;\n  }\n  if (mode != psModeForm) {\n    if (mode != psModeEPS && !manualCtrl) {\n      writePSFmt(\"{0:d} {1:d} {2:s} pdfSetup\\n\",\n\t\t paperWidth, paperHeight, duplexA ? \"true\" : \"false\");\n    }\n#if OPI_SUPPORT\n    if (globalParams->getPSOPI()) {\n      writePS(\"\/opiMatrix matrix currentmatrix def\\n\");\n    }\n#endif\n  }\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":423695,"func":"dns__zone_updatesigs(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *version,\n\t\t     dst_key_t *zone_keys[], unsigned int nkeys,\n\t\t     dns_zone_t *zone, isc_stdtime_t inception,\n\t\t     isc_stdtime_t expire, isc_stdtime_t keyexpire,\n\t\t     isc_stdtime_t now, bool check_ksk,\n\t\t     bool keyset_kskonly, dns__zonediff_t *zonediff)\n{\n\tdns_difftuple_t *tuple;\n\tisc_result_t result;\n\n\twhile ((tuple = ISC_LIST_HEAD(diff->tuples)) != NULL) {\n\t\tisc_stdtime_t exp = expire;\n\n\t\tif (keyexpire != 0 &&\n\t\t    (tuple->rdata.type == dns_rdatatype_dnskey ||\n\t\t     tuple->rdata.type == dns_rdatatype_cdnskey ||\n\t\t     tuple->rdata.type == dns_rdatatype_cds))\n\t\t{\n\t\t\texp = keyexpire;\n\t\t}\n\n\t\tresult = del_sigs(zone, db, version, &tuple->name,\n\t\t\t\t  tuple->rdata.type, zonediff,\n\t\t\t\t  zone_keys, nkeys, now, false);\n\t\tif (result != ISC_R_SUCCESS) {\n\t\t\tdns_zone_log(zone, ISC_LOG_ERROR,\n\t\t\t\t     \"dns__zone_updatesigs:del_sigs -> %s\",\n\t\t\t\t     dns_result_totext(result));\n\t\t\treturn (result);\n\t\t}\n\t\tresult = add_sigs(db, version, &tuple->name,\n\t\t\t\t  tuple->rdata.type, zonediff->diff,\n\t\t\t\t  zone_keys, nkeys, zone->mctx, inception,\n\t\t\t\t  exp, check_ksk, keyset_kskonly);\n\t\tif (result != ISC_R_SUCCESS) {\n\t\t\tdns_zone_log(zone, ISC_LOG_ERROR,\n\t\t\t\t     \"dns__zone_updatesigs:add_sigs -> %s\",\n\t\t\t\t     dns_result_totext(result));\n\t\t\treturn (result);\n\t\t}\n\n\t\t\/*\n\t\t * Signature changes for all RRs with name tuple->name and type\n\t\t * tuple->rdata.type were appended to zonediff->diff.  Now we\n\t\t * remove all the \"raw\" changes with the same name and type\n\t\t * from diff (so that they are not processed by this loop\n\t\t * again) and append them to zonediff so that they get applied.\n\t\t *\/\n\t\tmove_matching_tuples(tuple, diff, zonediff->diff);\n\t}\n\treturn (ISC_R_SUCCESS);\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":21147,"func":"int qemuMonitorTextAddPCIHostDevice ( qemuMonitorPtr mon , virDomainDevicePCIAddress * hostAddr , virDomainDevicePCIAddress * guestAddr ) {\n char * cmd ;\n char * reply = NULL ;\n int ret = - 1 ;\n memset ( guestAddr , 0 , sizeof ( * guestAddr ) ) ;\n if ( virAsprintf ( & cmd , \"pci_add pci_addr=auto host host=%.2x:%.2x.%.1x\" , hostAddr -> bus , hostAddr -> slot , hostAddr -> function ) < 0 ) {\n virReportOOMError ( ) ;\n goto cleanup ;\n }\n if ( qemuMonitorHMPCommand ( mon , cmd , & reply ) < 0 ) {\n qemuReportError ( VIR_ERR_OPERATION_FAILED , \"%s\" , _ ( \"cannot attach host pci device\" ) ) ;\n goto cleanup ;\n }\n if ( strstr ( reply , \"invalid type: host\" ) ) {\n qemuReportError ( VIR_ERR_OPERATION_INVALID , \"%s\" , _ ( \"PCI device assignment is not supported by this version of qemu\" ) ) ;\n goto cleanup ;\n }\n if ( qemuMonitorTextParsePciAddReply ( mon , reply , guestAddr ) < 0 ) {\n qemuReportError ( VIR_ERR_OPERATION_FAILED , _ ( \"parsing pci_add reply failed: %s\" ) , reply ) ;\n goto cleanup ;\n }\n ret = 0 ;\n cleanup : VIR_FREE ( cmd ) ;\n VIR_FREE ( reply ) ;\n return ret ;\n }","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":247184,"func":"TransportDIB* BrowserRenderProcessHost::GetTransportDIB(\n    TransportDIB::Id dib_id) {\n  if (!TransportDIB::is_valid_id(dib_id))\n    return NULL;\n\n  const std::map<TransportDIB::Id, TransportDIB*>::iterator\n      i = cached_dibs_.find(dib_id);\n  if (i != cached_dibs_.end()) {\n    cached_dibs_cleaner_.Reset();\n    return i->second;\n  }\n\n  TransportDIB* dib = MapTransportDIB(dib_id);\n  if (!dib)\n    return NULL;\n\n  if (cached_dibs_.size() >= MAX_MAPPED_TRANSPORT_DIBS) {\n    std::map<TransportDIB::Id, TransportDIB*>::iterator smallest_iterator;\n    size_t smallest_size = std::numeric_limits<size_t>::max();\n\n    for (std::map<TransportDIB::Id, TransportDIB*>::iterator\n         i = cached_dibs_.begin(); i != cached_dibs_.end(); ++i) {\n      if (i->second->size() <= smallest_size) {\n        smallest_iterator = i;\n        smallest_size = i->second->size();\n      }\n    }\n\n    delete smallest_iterator->second;\n    cached_dibs_.erase(smallest_iterator);\n  }\n\n  cached_dibs_[dib_id] = dib;\n  cached_dibs_cleaner_.Reset();\n  return dib;\n}\n","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":514995,"func":"gst_rmdemux_parse_indx_data (GstRMDemux * rmdemux, const guint8 * data,\n    int length)\n{\n  int i;\n  int n;\n  GstRMDemuxIndex *index;\n\n  \/* The number of index records *\/\n  n = length \/ 14;\n\n  if (rmdemux->index_stream == NULL)\n    return;\n\n  \/* don't parse the index a second time when operating pull-based and\n   * reaching the end of the file *\/\n  if (rmdemux->index_stream->index_length > 0) {\n    GST_DEBUG_OBJECT (rmdemux, \"Already have an index for this stream\");\n    return;\n  }\n\n  index = g_malloc (sizeof (GstRMDemuxIndex) * n);\n  rmdemux->index_stream->index = index;\n  rmdemux->index_stream->index_length = n;\n\n  for (i = 0; i < n; i++) {\n    index[i].timestamp = RMDEMUX_GUINT32_GET (data + 2) * GST_MSECOND;\n    index[i].offset = RMDEMUX_GUINT32_GET (data + 6);\n\n    GST_DEBUG_OBJECT (rmdemux, \"Index found for timestamp=%f (at offset=%x)\",\n        gst_guint64_to_gdouble (index[i].timestamp) \/ GST_SECOND,\n        index[i].offset);\n    data += 14;\n  }\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":289965,"func":"static void estimate_block_intra ( int plane , int block , BLOCK_SIZE plane_bsize , TX_SIZE tx_size , void * arg ) {\n struct estimate_block_intra_args * const args = arg ;\n VP9_COMP * const cpi = args -> cpi ;\n MACROBLOCK * const x = args -> x ;\n MACROBLOCKD * const xd = & x -> e_mbd ;\n struct macroblock_plane * const p = & x -> plane [ 0 ] ;\n struct macroblockd_plane * const pd = & xd -> plane [ 0 ] ;\n const BLOCK_SIZE bsize_tx = txsize_to_bsize [ tx_size ] ;\n uint8_t * const src_buf_base = p -> src . buf ;\n uint8_t * const dst_buf_base = pd -> dst . buf ;\n const int src_stride = p -> src . stride ;\n const int dst_stride = pd -> dst . stride ;\n int i , j ;\n int rate ;\n int64_t dist ;\n unsigned int var_y , sse_y ;\n txfrm_block_to_raster_xy ( plane_bsize , tx_size , block , & i , & j ) ;\n assert ( plane == 0 ) ;\n ( void ) plane ;\n p -> src . buf = & src_buf_base [ 4 * ( j * src_stride + i ) ] ;\n pd -> dst . buf = & dst_buf_base [ 4 * ( j * dst_stride + i ) ] ;\n vp9_predict_intra_block ( xd , block >> ( 2 * tx_size ) , b_width_log2 ( plane_bsize ) , tx_size , args -> mode , p -> src . buf , src_stride , pd -> dst . buf , dst_stride , i , j , 0 ) ;\n model_rd_for_sb_y ( cpi , bsize_tx , x , xd , & rate , & dist , & var_y , & sse_y ) ;\n p -> src . buf = src_buf_base ;\n pd -> dst . buf = dst_buf_base ;\n args -> rate += rate ;\n args -> dist += dist ;\n }","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":125678,"func":"s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 *vui_flag_pos)\n{\n\tGF_BitStream *bs;\n\tchar *data_without_emulation_bytes = NULL;\n\tu32 data_without_emulation_bytes_size = 0;\n\ts32 sps_id= -1;\n\tu8 layer_id;\n\n\tif (vui_flag_pos) *vui_flag_pos = 0;\n\n\tdata_without_emulation_bytes_size = avc_emulation_bytes_remove_count(data, size);\n\tif (!data_without_emulation_bytes_size) {\n\t\tbs = gf_bs_new(data, size, GF_BITSTREAM_READ);\n\t} else {\n\t\t\/*still contains emulation bytes*\/\n\t\tdata_without_emulation_bytes = gf_malloc(size*sizeof(char));\n\t\tdata_without_emulation_bytes_size = avc_remove_emulation_bytes(data, data_without_emulation_bytes, size);\n\t\tbs = gf_bs_new(data_without_emulation_bytes, data_without_emulation_bytes_size, GF_BITSTREAM_READ);\n\t}\n\tif (!bs) goto exit;\n\tif (! hevc_parse_nal_header(bs, NULL, NULL, &layer_id)) goto exit;\n\tsps_id = gf_media_hevc_read_sps_bs(bs, hevc, layer_id, vui_flag_pos);\n\nexit:\n\tif (bs) gf_bs_del(bs);\n\tif (data_without_emulation_bytes) gf_free(data_without_emulation_bytes);\n\treturn sps_id;\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":383461,"func":"FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)\n{\n\tFLAC__bool error = false;\n\n\tFLAC__ASSERT(0 != encoder);\n\tFLAC__ASSERT(0 != encoder->private_);\n\tFLAC__ASSERT(0 != encoder->protected_);\n\n\tif(encoder->protected_->state == FLAC__STREAM_ENCODER_UNINITIALIZED)\n\t\treturn true;\n\n\tif(encoder->protected_->state == FLAC__STREAM_ENCODER_OK && !encoder->private_->is_being_deleted) {\n\t\tif(encoder->private_->current_sample_number != 0) {\n\t\t\tconst FLAC__bool is_fractional_block = encoder->protected_->blocksize != encoder->private_->current_sample_number;\n\t\t\tencoder->protected_->blocksize = encoder->private_->current_sample_number;\n\t\t\tif(!process_frame_(encoder, is_fractional_block, \/*is_last_block=*\/true))\n\t\t\t\terror = true;\n\t\t}\n\t}\n\n\tif(encoder->protected_->do_md5)\n\t\tFLAC__MD5Final(encoder->private_->streaminfo.data.stream_info.md5sum, &encoder->private_->md5context);\n\n\tif(!encoder->private_->is_being_deleted) {\n\t\tif(encoder->protected_->state == FLAC__STREAM_ENCODER_OK) {\n\t\t\tif(encoder->private_->seek_callback) {\n#if FLAC__HAS_OGG\n\t\t\t\tif(encoder->private_->is_ogg)\n\t\t\t\t\tupdate_ogg_metadata_(encoder);\n\t\t\t\telse\n#endif\n\t\t\t\tupdate_metadata_(encoder);\n\n\t\t\t\t\/* check if an error occurred while updating metadata *\/\n\t\t\t\tif(encoder->protected_->state != FLAC__STREAM_ENCODER_OK)\n\t\t\t\t\terror = true;\n\t\t\t}\n\t\t\tif(encoder->private_->metadata_callback)\n\t\t\t\tencoder->private_->metadata_callback(encoder, &encoder->private_->streaminfo, encoder->private_->client_data);\n\t\t}\n\n\t\tif(encoder->protected_->verify && 0 != encoder->private_->verify.decoder && !FLAC__stream_decoder_finish(encoder->private_->verify.decoder)) {\n\t\t\tif(!error)\n\t\t\t\tencoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA;\n\t\t\terror = true;\n\t\t}\n\t}\n\n\tif(0 != encoder->private_->file) {\n\t\tif(encoder->private_->file != stdout)\n\t\t\tfclose(encoder->private_->file);\n\t\tencoder->private_->file = 0;\n\t}\n\n#if FLAC__HAS_OGG\n\tif(encoder->private_->is_ogg)\n\t\tFLAC__ogg_encoder_aspect_finish(&encoder->protected_->ogg_encoder_aspect);\n#endif\n\n\tfree_(encoder);\n\tset_defaults_(encoder);\n\n\tif(!error)\n\t\tencoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;\n\n\treturn !error;\n}","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":77333,"func":"static enum_func_status\nphp_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len,\n\t\t\t\t\t\t\t\tchar *error, int error_buf_len,\n\t\t\t\t\t\t\t\tunsigned int *error_no, char *sqlstate TSRMLS_DC)\n{\n\tzend_uchar *p = buf;\n\tint error_msg_len= 0;\n\n\tDBG_ENTER(\"php_mysqlnd_read_error_from_line\");\n\n\t*error_no = CR_UNKNOWN_ERROR;\n\tmemcpy(sqlstate, unknown_sqlstate, MYSQLND_SQLSTATE_LENGTH);\n\n\tif (buf_len > 2) {\n\t\t*error_no = uint2korr(p);\n\t\tp+= 2;\n\t\t\/*\n\t\t  sqlstate is following. No need to check for buf_left_len as we checked > 2 above,\n\t\t  if it was >=2 then we would need a check\n\t\t*\/\n\t\tif (*p == '#') {\n\t\t\t++p;\n\t\t\tif ((buf_len - (p - buf)) >= MYSQLND_SQLSTATE_LENGTH) {\n\t\t\t\tmemcpy(sqlstate, p, MYSQLND_SQLSTATE_LENGTH);\n\t\t\t\tp+= MYSQLND_SQLSTATE_LENGTH;\n\t\t\t} else {\n\t\t\t\tgoto end;\n\t\t\t}\n\t\t}\n\t\tif ((buf_len - (p - buf)) > 0) {\n\t\t\terror_msg_len = MIN((int)((buf_len - (p - buf))), (int) (error_buf_len - 1));\n\t\t\tmemcpy(error, p, error_msg_len);\n\t\t}\n\t}\nend:\n\tsqlstate[MYSQLND_SQLSTATE_LENGTH] = '\\0';\n\terror[error_msg_len]= '\\0';\n\n\tDBG_RETURN(FAIL);","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":415471,"func":"int WavInFile::read(float *buffer, int maxElems)\r\n{\r\n    unsigned int afterDataRead;\r\n    int numBytes;\r\n    int numElems;\r\n    int bytesPerSample;\r\n\r\n    assert(buffer);\r\n\r\n    bytesPerSample = header.format.bits_per_sample \/ 8;\r\n    if ((bytesPerSample < 1) || (bytesPerSample > 4))\r\n    {\r\n        stringstream ss;\r\n        ss << \"\\nOnly 8\/16\/24\/32 bit sample WAV files supported. Can't open WAV file with \";\r\n        ss << (int)header.format.bits_per_sample;\r\n        ss << \" bit sample format. \";\r\n        ST_THROW_RT_ERROR(ss.str().c_str());\r\n    }\r\n\r\n    numBytes = maxElems * bytesPerSample;\r\n    afterDataRead = dataRead + numBytes;\r\n    if (afterDataRead > header.data.data_len) \r\n    {\r\n        \/\/ Don't read more samples than are marked available in header\r\n        numBytes = (int)header.data.data_len - (int)dataRead;\r\n        assert(numBytes >= 0);\r\n    }\r\n\r\n    \/\/ read raw data into temporary buffer\r\n    char *temp = (char*)getConvBuffer(numBytes);\r\n    numBytes = (int)fread(temp, 1, numBytes, fptr);\r\n    dataRead += numBytes;\r\n\r\n    numElems = numBytes \/ bytesPerSample;\r\n\r\n    \/\/ swap byte ordert & convert to float, depending on sample format\r\n    switch (bytesPerSample)\r\n    {\r\n        case 1:\r\n        {\r\n            unsigned char *temp2 = (unsigned char*)temp;\r\n            double conv = 1.0 \/ 128.0;\r\n            for (int i = 0; i < numElems; i ++)\r\n            {\r\n                buffer[i] = (float)(temp2[i] * conv - 1.0);\r\n            }\r\n            break;\r\n        }\r\n\r\n        case 2:\r\n        {\r\n            short *temp2 = (short*)temp;\r\n            double conv = 1.0 \/ 32768.0;\r\n            for (int i = 0; i < numElems; i ++)\r\n            {\r\n                short value = temp2[i];\r\n                buffer[i] = (float)(_swap16(value) * conv);\r\n            }\r\n            break;\r\n        }\r\n\r\n        case 3:\r\n        {\r\n            char *temp2 = (char *)temp;\r\n            double conv = 1.0 \/ 8388608.0;\r\n            for (int i = 0; i < numElems; i ++)\r\n            {\r\n                int value = *((int*)temp2);\r\n                value = _swap32(value) & 0x00ffffff;             \/\/ take 24 bits\r\n                value |= (value & 0x00800000) ? 0xff000000 : 0;  \/\/ extend minus sign bits\r\n                buffer[i] = (float)(value * conv);\r\n                temp2 += 3;\r\n            }\r\n            break;\r\n        }\r\n\r\n        case 4:\r\n        {\r\n            int *temp2 = (int *)temp;\r\n            double conv = 1.0 \/ 2147483648.0;\r\n            assert(sizeof(int) == 4);\r\n            for (int i = 0; i < numElems; i ++)\r\n            {\r\n                int value = temp2[i];\r\n                buffer[i] = (float)(_swap32(value) * conv);\r\n            }\r\n            break;\r\n        }\r\n    }\r\n\r\n    return numElems;\r\n}\r","target":0,"code_token_length":752,"total_token_length":988,"max_tokens_setting":1024}
+{"idx":329028,"func":"print_ipc_cmd(int cmd)\n\n{\n\n#define output_cmd(val) \\\n\nif( cmd == val ) { \\\n\n    gemu_log(#val); \\\n\n    return; \\\n\n}\n\n\n\n    cmd &= 0xff;\n\n\n\n    \/* General IPC commands *\/\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_SET );\n\n    output_cmd( IPC_STAT );\n\n    output_cmd( IPC_INFO );\n\n    \/* msgctl() commands *\/\n\n    #ifdef __USER_MISC\n\n    output_cmd( MSG_STAT );\n\n    output_cmd( MSG_INFO );\n\n    #endif\n\n    \/* shmctl() commands *\/\n\n    output_cmd( SHM_LOCK );\n\n    output_cmd( SHM_UNLOCK );\n\n    output_cmd( SHM_STAT );\n\n    output_cmd( SHM_INFO );\n\n    \/* semctl() commands *\/\n\n    output_cmd( GETPID );\n\n    output_cmd( GETVAL );\n\n    output_cmd( GETALL );\n\n    output_cmd( GETNCNT );\n\n    output_cmd( GETZCNT );\n\n    output_cmd( SETVAL );\n\n    output_cmd( SETALL );\n\n    output_cmd( SEM_STAT );\n\n    output_cmd( SEM_INFO );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n    output_cmd( IPC_RMID );\n\n\n\n    \/* Some value we don't recognize *\/\n\n    gemu_log(\"%d\",cmd);\n\n}\n","target":1,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":299019,"func":"static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si)\n{\n\tstruct {\n\t\t__le32 len;\n\t\tstruct brcmf_bss_info_le bss_le;\n\t} *buf;\n\tu16 capability;\n\tint err;\n\n\tbuf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL);\n\tif (!buf)\n\t\treturn;\n\n\tbuf->len = cpu_to_le32(WL_BSS_INFO_MAX);\n\terr = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO, buf,\n\t\t\t\t     WL_BSS_INFO_MAX);\n\tif (err) {\n\t\tbrcmf_err(\"Failed to get bss info (%d)\\n\", err);\n\t\treturn;\n\t}\n\tsi->filled |= BIT(NL80211_STA_INFO_BSS_PARAM);\n\tsi->bss_param.beacon_interval = le16_to_cpu(buf->bss_le.beacon_period);\n\tsi->bss_param.dtim_period = buf->bss_le.dtim_period;\n\tcapability = le16_to_cpu(buf->bss_le.capability);\n\tif (capability & IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT)\n\t\tsi->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;\n\tif (capability & WLAN_CAPABILITY_SHORT_PREAMBLE)\n\t\tsi->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;\n\tif (capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)\n\t\tsi->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":57805,"func":"R_API ut64 r_bin_java_code_attr_calc_size(RBinJavaAttrInfo *attr) {\n\tRListIter *iter;\n\t\/\/ RListIter *iter_tmp;\n\tut64 size = 0;\n\tif (attr) {\n\t\t\/\/ attr = r_bin_java_default_attr_new (buffer, sz, buf_offset);\n\t\tsize += 6;\n\t\t\/\/ attr->info.code_attr.max_stack = R_BIN_JAVA_USHORT (buffer, 0);\n\t\tsize += 2;\n\t\t\/\/ attr->info.code_attr.max_locals = R_BIN_JAVA_USHORT (buffer, 2);\n\t\tsize += 2;\n\t\t\/\/ attr->info.code_attr.code_length = R_BIN_JAVA_UINT (buffer, 4);\n\t\tsize += 2;\n\t\tif (attr->info.code_attr.code) {\n\t\t\tsize += attr->info.code_attr.code_length;\n\t\t}\n\t\t\/\/ attr->info.code_attr.exception_table_length =  R_BIN_JAVA_USHORT (buffer, offset);\n\t\tsize += 2;\n\t\t\/\/ RBinJavaExceptionEntry *exc_entry;\n\t\t\/\/ r_list_foreach_safe (attr->info.code_attr.exception_table, iter, iter_tmp, exc_entry) {\n\t\tr_list_foreach_iter (attr->info.code_attr.exception_table, iter) {\n\t\t\t\/\/ exc_entry->start_pc = R_BIN_JAVA_USHORT (buffer,offset);\n\t\t\tsize += 2;\n\t\t\t\/\/ exc_entry->end_pc = R_BIN_JAVA_USHORT (buffer,offset);\n\t\t\tsize += 2;\n\t\t\t\/\/ exc_entry->handler_pc = R_BIN_JAVA_USHORT (buffer,offset);\n\t\t\tsize += 2;\n\t\t\t\/\/ exc_entry->catch_type = R_BIN_JAVA_USHORT (buffer, offset);\n\t\t\tsize += 2;\n\t\t}\n\t\t\/\/ attr->info.code_attr.attributes_count = R_BIN_JAVA_USHORT (buffer, offset);\n\t\tsize += 2;\n\t\t\/\/ RBinJavaAttrInfo *_attr;\n\t\tif (attr->info.code_attr.attributes_count > 0) {\n\t\t\t\/\/ r_list_foreach_safe (attr->info.code_attr.attributes, iter, iter_tmp, _attr) {\n\t\t\tr_list_foreach_iter (attr->info.code_attr.attributes, iter) {\n\t\t\t\tsize += r_bin_java_attr_calc_size (attr);\n\t\t\t}\n\t\t}\n\t}\n\treturn size;\n}","target":0,"code_token_length":499,"total_token_length":735,"max_tokens_setting":1024}
+{"idx":173233,"func":"bgp_attr_aggregate_intern (struct bgp *bgp, u_char origin,\n\t\t\t   struct aspath *aspath,\n\t\t\t   struct community *community, int as_set)\n{\n  struct attr attr;\n  struct attr *new;\n  struct attr_extra *attre;\n\n  memset (&attr, 0, sizeof (struct attr));\n  attre = bgp_attr_extra_get (&attr);\n  \n  \/* Origin attribute. *\/\n  attr.origin = origin;\n  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);\n\n  \/* AS path attribute. *\/\n  if (aspath)\n    attr.aspath = aspath_intern (aspath);\n  else\n    attr.aspath = aspath_empty ();\n  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);\n\n  \/* Next hop attribute.  *\/\n  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);\n\n  if (community)\n    {\n      attr.community = community;\n      attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);\n    }\n\n  attre->weight = BGP_ATTR_DEFAULT_WEIGHT;\n#ifdef HAVE_IPV6\n  attre->mp_nexthop_len = IPV6_MAX_BYTELEN;\n#endif\n  if (! as_set)\n    attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);\n  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);\n  if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION))\n    attre->aggregator_as = bgp->confed_id;\n  else\n    attre->aggregator_as = bgp->as;\n  attre->aggregator_addr = bgp->router_id;\n\n  new = bgp_attr_intern (&attr);\n  bgp_attr_extra_free (&attr);\n  \n  aspath_unintern (&new->aspath);\n  return new;\n}\n","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":204821,"func":"void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) {\n  base::debug::SetCrashKeyValue(\"newframe_routing_id\",\n                                base::IntToString(params->routing_id));\n  base::debug::SetCrashKeyValue(\"newframe_proxy_id\",\n                                base::IntToString(params->proxy_routing_id));\n  base::debug::SetCrashKeyValue(\"newframe_opener_id\",\n                                base::IntToString(params->opener_routing_id));\n  base::debug::SetCrashKeyValue(\"newframe_parent_id\",\n                                base::IntToString(params->parent_routing_id));\n  base::debug::SetCrashKeyValue(\"newframe_widget_id\",\n                                base::IntToString(\n                                    params->widget_params->routing_id));\n  base::debug::SetCrashKeyValue(\"newframe_widget_hidden\",\n                                params->widget_params->hidden ? \"yes\" : \"no\");\n  base::debug::SetCrashKeyValue(\"newframe_replicated_origin\",\n                                params->replication_state.origin.Serialize());\n  CompositorDependencies* compositor_deps = this;\n  RenderFrameImpl::CreateFrame(\n      params->routing_id, std::move(params->interface_provider),\n      params->proxy_routing_id, params->opener_routing_id,\n      params->parent_routing_id, params->previous_sibling_routing_id,\n      params->devtools_frame_token, params->replication_state, compositor_deps,\n      *params->widget_params, params->frame_owner_properties);\n}\n","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":137177,"func":"int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)\n{\n\tstruct page *page = vmf->page;\n\tloff_t size;\n\tunsigned long len;\n\tint ret = -EINVAL;\n\tvoid *fsdata;\n\tstruct file *file = vma->vm_file;\n\tstruct inode *inode = file->f_path.dentry->d_inode;\n\tstruct address_space *mapping = inode->i_mapping;\n\n\t\/*\n\t * Get i_alloc_sem to stop truncates messing with the inode. We cannot\n\t * get i_mutex because we are already holding mmap_sem.\n\t *\/\n\tdown_read(&inode->i_alloc_sem);\n\tsize = i_size_read(inode);\n\tif (page->mapping != mapping || size <= page_offset(page)\n\t    || !PageUptodate(page)) {\n\t\t\/* page got truncated from under us? *\/\n\t\tgoto out_unlock;\n\t}\n\tret = 0;\n\tif (PageMappedToDisk(page))\n\t\tgoto out_unlock;\n\n\tif (page->index == size >> PAGE_CACHE_SHIFT)\n\t\tlen = size & ~PAGE_CACHE_MASK;\n\telse\n\t\tlen = PAGE_CACHE_SIZE;\n\n\tlock_page(page);\n\t\/*\n\t * return if we have all the buffers mapped. This avoid\n\t * the need to call write_begin\/write_end which does a\n\t * journal_start\/journal_stop which can block and take\n\t * long time\n\t *\/\n\tif (page_has_buffers(page)) {\n\t\tif (!walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,\n\t\t\t\t\text4_bh_unmapped)) {\n\t\t\tunlock_page(page);\n\t\t\tgoto out_unlock;\n\t\t}\n\t}\n\tunlock_page(page);\n\t\/*\n\t * OK, we need to fill the hole... Do write_begin write_end\n\t * to do block allocation\/reservation.We are not holding\n\t * inode.i__mutex here. That allow * parallel write_begin,\n\t * write_end call. lock_page prevent this from happening\n\t * on the same page though\n\t *\/\n\tret = mapping->a_ops->write_begin(file, mapping, page_offset(page),\n\t\t\tlen, AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);\n\tif (ret < 0)\n\t\tgoto out_unlock;\n\tret = mapping->a_ops->write_end(file, mapping, page_offset(page),\n\t\t\tlen, len, page, fsdata);\n\tif (ret < 0)\n\t\tgoto out_unlock;\n\tret = 0;\nout_unlock:\n\tif (ret)\n\t\tret = VM_FAULT_SIGBUS;\n\tup_read(&inode->i_alloc_sem);\n\treturn ret;\n}","target":0,"code_token_length":531,"total_token_length":767,"max_tokens_setting":1024}
+{"idx":104364,"func":"\nstatic u32 netif_receive_generic_xdp(struct sk_buff *skb,\n\t\t\t\t     struct bpf_prog *xdp_prog)\n{\n\tstruct xdp_buff xdp;\n\tu32 act = XDP_DROP;\n\tvoid *orig_data;\n\tint hlen, off;\n\tu32 mac_len;\n\n\t\/* Reinjected packets coming from act_mirred or similar should\n\t * not get XDP generic processing.\n\t *\/\n\tif (skb_cloned(skb))\n\t\treturn XDP_PASS;\n\n\tif (skb_linearize(skb))\n\t\tgoto do_drop;\n\n\t\/* The XDP program wants to see the packet starting at the MAC\n\t * header.\n\t *\/\n\tmac_len = skb->data - skb_mac_header(skb);\n\thlen = skb_headlen(skb) + mac_len;\n\txdp.data = skb->data - mac_len;\n\txdp.data_end = xdp.data + hlen;\n\txdp.data_hard_start = skb->data - skb_headroom(skb);\n\torig_data = xdp.data;\n\n\tact = bpf_prog_run_xdp(xdp_prog, &xdp);\n\n\toff = xdp.data - orig_data;\n\tif (off > 0)\n\t\t__skb_pull(skb, off);\n\telse if (off < 0)\n\t\t__skb_push(skb, -off);\n\tskb->mac_header += off;\n\n\tswitch (act) {\n\tcase XDP_REDIRECT:\n\tcase XDP_TX:\n\t\t__skb_push(skb, mac_len);\n\t\t\/* fall through *\/\n\tcase XDP_PASS:\n\t\tbreak;\n\n\tdefault:\n\t\tbpf_warn_invalid_xdp_action(act);\n\t\t\/* fall through *\/\n\tcase XDP_ABORTED:\n\t\ttrace_xdp_exception(skb->dev, xdp_prog, act);\n\t\t\/* fall through *\/\n\tcase XDP_DROP:\n\tdo_drop:\n\t\tkfree_skb(skb);\n\t\tbreak;\n\t}\n\n\treturn act;","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":33773,"func":"void ndpUpdateDefaultRouterList(NetInterface *interface)\n{\n   uint_t i;\n   bool_t flag;\n   systime_t time;\n   Ipv6RouterEntry *entry;\n\n   \/\/This flag will be set if any entry has been removed from\n   \/\/the Default Router List\n   flag = FALSE;\n\n   \/\/Get current time\n   time = osGetSystemTime();\n\n   \/\/Go through the Default Router List\n   for(i = 0; i < IPV6_ROUTER_LIST_SIZE; i++)\n   {\n      \/\/Point to the current entry\n      entry = &interface->ipv6Context.routerList[i];\n\n      \/\/Check the lifetime value\n      if(entry->lifetime > 0 && entry->lifetime < INFINITE_DELAY)\n      {\n         \/\/A node should retain entries in the Default Router List until\n         \/\/their lifetimes expire\n         if(timeCompare(time, entry->timestamp + entry->lifetime) >= 0)\n         {\n            \/\/Immediately time-out the entry\n            entry->addr = IPV6_UNSPECIFIED_ADDR;\n            entry->lifetime = 0;\n\n            \/\/Set flag\n            flag = TRUE;\n         }\n      }\n   }\n\n   \/\/Check whether an entry has been removed from the list\n   if(flag)\n   {\n      \/\/When removing an entry from the Default Router List, any entries\n      \/\/in the Destination Cache that go through that router must perform\n      \/\/next-hop determination again to select a new default router\n      ndpFlushDestCache(interface);\n   }\n}","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":112979,"func":"int __get_user_pages_fast(unsigned long start, int nr_pages, int write,\n\t\t\t  struct page **pages)\n{\n\tstruct mm_struct *mm = current->mm;\n\tunsigned long addr, len, end;\n\tunsigned long next, flags;\n\tpgd_t *pgdp;\n\tint nr = 0;\n\n\tstart &= PAGE_MASK;\n\taddr = start;\n\tlen = (unsigned long) nr_pages << PAGE_SHIFT;\n\tend = start + len;\n\n\tif (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,\n\t\t\t\t\tstart, len)))\n\t\treturn 0;\n\n\t\/*\n\t * Disable interrupts.  We use the nested form as we can already have\n\t * interrupts disabled by get_futex_key.\n\t *\n\t * With interrupts disabled, we block page table pages from being\n\t * freed from under us. See mmu_gather_tlb in asm-generic\/tlb.h\n\t * for more details.\n\t *\n\t * We do not adopt an rcu_read_lock(.) here as we also want to\n\t * block IPIs that come from THPs splitting.\n\t *\/\n\n\tlocal_irq_save(flags);\n\tpgdp = pgd_offset(mm, addr);\n\tdo {\n\t\tpgd_t pgd = READ_ONCE(*pgdp);\n\n\t\tnext = pgd_addr_end(addr, end);\n\t\tif (pgd_none(pgd))\n\t\t\tbreak;\n\t\tif (unlikely(pgd_huge(pgd))) {\n\t\t\tif (!gup_huge_pgd(pgd, pgdp, addr, next, write,\n\t\t\t\t\t  pages, &nr))\n\t\t\t\tbreak;\n\t\t} else if (unlikely(is_hugepd(__hugepd(pgd_val(pgd))))) {\n\t\t\tif (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr,\n\t\t\t\t\t PGDIR_SHIFT, next, write, pages, &nr))\n\t\t\t\tbreak;\n\t\t} else if (!gup_pud_range(pgd, addr, next, write, pages, &nr))\n\t\t\tbreak;\n\t} while (pgdp++, addr = next, addr != end);\n\tlocal_irq_restore(flags);\n\n\treturn nr;\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":431995,"func":"void tcp_wfree(struct sk_buff *skb)\n{\n\tstruct sock *sk = skb->sk;\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tunsigned long flags, nval, oval;\n\n\t\/* Keep one reference on sk_wmem_alloc.\n\t * Will be released by sk_free() from here or tcp_tasklet_func()\n\t *\/\n\tWARN_ON(refcount_sub_and_test(skb->truesize - 1, &sk->sk_wmem_alloc));\n\n\t\/* If this softirq is serviced by ksoftirqd, we are likely under stress.\n\t * Wait until our queues (qdisc + devices) are drained.\n\t * This gives :\n\t * - less callbacks to tcp_write_xmit(), reducing stress (batches)\n\t * - chance for incoming ACK (processed by another cpu maybe)\n\t *   to migrate this flow (skb->ooo_okay will be eventually set)\n\t *\/\n\tif (refcount_read(&sk->sk_wmem_alloc) >= SKB_TRUESIZE(1) && this_cpu_ksoftirqd() == current)\n\t\tgoto out;\n\n\tfor (oval = READ_ONCE(sk->sk_tsq_flags);; oval = nval) {\n\t\tstruct tsq_tasklet *tsq;\n\t\tbool empty;\n\n\t\tif (!(oval & TSQF_THROTTLED) || (oval & TSQF_QUEUED))\n\t\t\tgoto out;\n\n\t\tnval = (oval & ~TSQF_THROTTLED) | TSQF_QUEUED | TCPF_TSQ_DEFERRED;\n\t\tnval = cmpxchg(&sk->sk_tsq_flags, oval, nval);\n\t\tif (nval != oval)\n\t\t\tcontinue;\n\n\t\t\/* queue this socket to tasklet queue *\/\n\t\tlocal_irq_save(flags);\n\t\ttsq = this_cpu_ptr(&tsq_tasklet);\n\t\tempty = list_empty(&tsq->head);\n\t\tlist_add(&tp->tsq_node, &tsq->head);\n\t\tif (empty)\n\t\t\ttasklet_schedule(&tsq->tasklet);\n\t\tlocal_irq_restore(flags);\n\t\treturn;\n\t}\nout:\n\tsk_free(sk);\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":501815,"func":"get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,\n\t\t\t\t   const char *operatorName, Oid operatorNamespace,\n\t\t\t\t   Oid leftTypeId, Oid rightTypeId, bool isCommutator)\n{\n\tOid\t\t\tother_oid;\n\tbool\t\totherDefined;\n\tchar\t   *otherName;\n\tOid\t\t\totherNamespace;\n\tAclResult\taclresult;\n\n\tother_oid = OperatorLookup(otherOp,\n\t\t\t\t\t\t\t   otherLeftTypeId,\n\t\t\t\t\t\t\t   otherRightTypeId,\n\t\t\t\t\t\t\t   &otherDefined);\n\n\tif (OidIsValid(other_oid))\n\t{\n\t\t\/* other op already in catalogs *\/\n\t\treturn other_oid;\n\t}\n\n\totherNamespace = QualifiedNameGetCreationNamespace(otherOp,\n\t\t\t\t\t\t\t\t\t\t\t\t\t   &otherName);\n\n\tif (strcmp(otherName, operatorName) == 0 &&\n\t\totherNamespace == operatorNamespace &&\n\t\totherLeftTypeId == leftTypeId &&\n\t\totherRightTypeId == rightTypeId)\n\t{\n\t\t\/*\n\t\t * self-linkage to this operator; caller will fix later. Note that\n\t\t * only self-linkage for commutation makes sense.\n\t\t *\/\n\t\tif (!isCommutator)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),\n\t\t\t\t\t errmsg(\"operator cannot be its own negator or sort operator\")));\n\t\treturn InvalidOid;\n\t}\n\n\t\/* not in catalogs, different from operator, so make shell *\/\n\n\taclresult = pg_namespace_aclcheck(otherNamespace, GetUserId(),\n\t\t\t\t\t\t\t\t\t  ACL_CREATE);\n\tif (aclresult != ACLCHECK_OK)\n\t\taclcheck_error(aclresult, ACL_KIND_NAMESPACE,\n\t\t\t\t\t   get_namespace_name(otherNamespace));\n\n\tother_oid = OperatorShellMake(otherName,\n\t\t\t\t\t\t\t\t  otherNamespace,\n\t\t\t\t\t\t\t\t  otherLeftTypeId,\n\t\t\t\t\t\t\t\t  otherRightTypeId);\n\treturn other_oid;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":431990,"func":"static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,\n\t\t\t\tstruct tcp_out_options *opts,\n\t\t\t\tstruct tcp_md5sig_key **md5)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tunsigned int remaining = MAX_TCP_OPTION_SPACE;\n\tstruct tcp_fastopen_request *fastopen = tp->fastopen_req;\n\n#ifdef CONFIG_TCP_MD5SIG\n\t*md5 = tp->af_specific->md5_lookup(sk, sk);\n\tif (*md5) {\n\t\topts->options |= OPTION_MD5;\n\t\tremaining -= TCPOLEN_MD5SIG_ALIGNED;\n\t}\n#else\n\t*md5 = NULL;\n#endif\n\n\t\/* We always get an MSS option.  The option bytes which will be seen in\n\t * normal data packets should timestamps be used, must be in the MSS\n\t * advertised.  But we subtract them from tp->mss_cache so that\n\t * calculations in tcp_sendmsg are simpler etc.  So account for this\n\t * fact here if necessary.  If we don't do this correctly, as a\n\t * receiver we won't recognize data packets as being full sized when we\n\t * should, and thus we won't abide by the delayed ACK rules correctly.\n\t * SACKs don't matter, we never delay an ACK when we have any of those\n\t * going out.  *\/\n\topts->mss = tcp_advertise_mss(sk);\n\tremaining -= TCPOLEN_MSS_ALIGNED;\n\n\tif (likely(sock_net(sk)->ipv4.sysctl_tcp_timestamps && !*md5)) {\n\t\topts->options |= OPTION_TS;\n\t\topts->tsval = tcp_skb_timestamp(skb) + tp->tsoffset;\n\t\topts->tsecr = tp->rx_opt.ts_recent;\n\t\tremaining -= TCPOLEN_TSTAMP_ALIGNED;\n\t}\n\tif (likely(sock_net(sk)->ipv4.sysctl_tcp_window_scaling)) {\n\t\topts->ws = tp->rx_opt.rcv_wscale;\n\t\topts->options |= OPTION_WSCALE;\n\t\tremaining -= TCPOLEN_WSCALE_ALIGNED;\n\t}\n\tif (likely(sock_net(sk)->ipv4.sysctl_tcp_sack)) {\n\t\topts->options |= OPTION_SACK_ADVERTISE;\n\t\tif (unlikely(!(OPTION_TS & opts->options)))\n\t\t\tremaining -= TCPOLEN_SACKPERM_ALIGNED;\n\t}\n\n\tif (fastopen && fastopen->cookie.len >= 0) {\n\t\tu32 need = fastopen->cookie.len;\n\n\t\tneed += fastopen->cookie.exp ? TCPOLEN_EXP_FASTOPEN_BASE :\n\t\t\t\t\t       TCPOLEN_FASTOPEN_BASE;\n\t\tneed = (need + 3) & ~3U;  \/* Align to 32 bits *\/\n\t\tif (remaining >= need) {\n\t\t\topts->options |= OPTION_FAST_OPEN_COOKIE;\n\t\t\topts->fastopen_cookie = &fastopen->cookie;\n\t\t\tremaining -= need;\n\t\t\ttp->syn_fastopen = 1;\n\t\t\ttp->syn_fastopen_exp = fastopen->cookie.exp ? 1 : 0;\n\t\t}\n\t}\n\n\tsmc_set_option(tp, opts, &remaining);\n\n\treturn MAX_TCP_OPTION_SPACE - remaining;\n}","target":0,"code_token_length":662,"total_token_length":898,"max_tokens_setting":1024}
+{"idx":6419,"func":"isakmp_rfc3948_print(netdissect_options *ndo,\n\t\t     const u_char *bp, u_int length,\n\t\t     const u_char *bp2)\n{\n\n\tif(length == 1 && bp[0]==0xff) {\n\t\tND_PRINT((ndo, \"isakmp-nat-keep-alive\"));\n\t\treturn;\n\t}\n\n\tif(length < 4) {\n\t\tgoto trunc;\n\t}\n\n\t\/*\n\t * see if this is an IKE packet\n\t *\/\n\tif(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {\n\t\tND_PRINT((ndo, \"NONESP-encap: \"));\n\t\tisakmp_print(ndo, bp+4, length-4, bp2);\n\t\treturn;\n\t}\n\n\t\/* must be an ESP packet *\/\n\t{\n\t\tint nh, enh, padlen;\n\t\tint advance;\n\n\t\tND_PRINT((ndo, \"UDP-encap: \"));\n\n\t\tadvance = esp_print(ndo, bp, length, bp2, &enh, &padlen);\n\t\tif(advance <= 0)\n\t\t\treturn;\n\n\t\tbp += advance;\n\t\tlength -= advance + padlen;\n\t\tnh = enh & 0xff;\n\n\t\tip_print_inner(ndo, bp, length, nh, bp2);\n\t\treturn;\n\t}\n\ntrunc:\n\tND_PRINT((ndo,\"[|isakmp]\"));\n\treturn;\n}","target":1,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":51622,"func":"rpl_daoack_print(netdissect_options *ndo,\n                 const u_char *bp, u_int length)\n{\n        const struct nd_rpl_daoack *daoack = (const struct nd_rpl_daoack *)bp;\n        const char *dagid_str = \"<elided>\";\n\n        ND_TCHECK2(*daoack, ND_RPL_DAOACK_MIN_LEN);\n        if (length < ND_RPL_DAOACK_MIN_LEN)\n        \tgoto tooshort;\n\n        bp += ND_RPL_DAOACK_MIN_LEN;\n        length -= ND_RPL_DAOACK_MIN_LEN;\n        if(RPL_DAOACK_D(daoack->rpl_flags)) {\n                ND_TCHECK2(daoack->rpl_dagid, DAGID_LEN);\n                if (length < DAGID_LEN)\n                \tgoto tooshort;\n                dagid_str = ip6addr_string (ndo, daoack->rpl_dagid);\n                bp += DAGID_LEN;\n                length -= DAGID_LEN;\n        }\n\n        ND_PRINT((ndo, \" [dagid:%s,seq:%u,instance:%u,status:%u]\",\n                  dagid_str,\n                  daoack->rpl_daoseq,\n                  daoack->rpl_instanceid,\n                  daoack->rpl_status));\n\n        \/* no officially defined options for DAOACK, but print any we find *\/\n        if(ndo->ndo_vflag > 1) {\n                const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp;\n                rpl_dio_printopt(ndo, opt, length);\n        }\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo,\" [|dao-truncated]\"));\n\treturn;\n\ntooshort:\n\tND_PRINT((ndo,\" [|dao-length too short]\"));\n\treturn;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":202475,"func":"void Document::DispatchUnloadEvents() {\n  PluginScriptForbiddenScope forbid_plugin_destructor_scripting;\n  if (parser_)\n    parser_->StopParsing();\n\n  if (load_event_progress_ == kLoadEventNotRun)\n    return;\n\n  if (load_event_progress_ <= kUnloadEventInProgress) {\n    Element* current_focused_element = FocusedElement();\n    if (auto* input = ToHTMLInputElementOrNull(current_focused_element))\n      input->EndEditing();\n    if (load_event_progress_ < kPageHideInProgress) {\n      load_event_progress_ = kPageHideInProgress;\n      if (LocalDOMWindow* window = domWindow()) {\n        const double pagehide_event_start = MonotonicallyIncreasingTime();\n        window->DispatchEvent(\n            PageTransitionEvent::Create(EventTypeNames::pagehide, false), this);\n        const double pagehide_event_end = MonotonicallyIncreasingTime();\n        DEFINE_STATIC_LOCAL(\n            CustomCountHistogram, pagehide_histogram,\n            (\"DocumentEventTiming.PageHideDuration\", 0, 10000000, 50));\n        pagehide_histogram.Count((pagehide_event_end - pagehide_event_start) *\n                                 1000000.0);\n      }\n      if (!frame_)\n        return;\n\n      mojom::PageVisibilityState visibility_state = GetPageVisibilityState();\n      load_event_progress_ = kUnloadVisibilityChangeInProgress;\n      if (visibility_state != mojom::PageVisibilityState::kHidden) {\n        const double pagevisibility_hidden_event_start =\n            MonotonicallyIncreasingTime();\n        DispatchEvent(Event::CreateBubble(EventTypeNames::visibilitychange));\n        const double pagevisibility_hidden_event_end =\n            MonotonicallyIncreasingTime();\n        DEFINE_STATIC_LOCAL(CustomCountHistogram, pagevisibility_histogram,\n                            (\"DocumentEventTiming.PageVibilityHiddenDuration\",\n                             0, 10000000, 50));\n        pagevisibility_histogram.Count((pagevisibility_hidden_event_end -\n                                        pagevisibility_hidden_event_start) *\n                                       1000000.0);\n        DispatchEvent(\n            Event::CreateBubble(EventTypeNames::webkitvisibilitychange));\n      }\n      if (!frame_)\n        return;\n\n      DocumentLoader* document_loader =\n          frame_->Loader().GetProvisionalDocumentLoader();\n      load_event_progress_ = kUnloadEventInProgress;\n      Event* unload_event(Event::Create(EventTypeNames::unload));\n      if (document_loader && !document_loader->GetTiming().UnloadEventStart() &&\n          !document_loader->GetTiming().UnloadEventEnd()) {\n        DocumentLoadTiming& timing = document_loader->GetTiming();\n        DCHECK(timing.NavigationStart());\n        const double unload_event_start = MonotonicallyIncreasingTime();\n        timing.MarkUnloadEventStart(unload_event_start);\n        frame_->DomWindow()->DispatchEvent(unload_event, this);\n        const double unload_event_end = MonotonicallyIncreasingTime();\n        DEFINE_STATIC_LOCAL(\n            CustomCountHistogram, unload_histogram,\n            (\"DocumentEventTiming.UnloadDuration\", 0, 10000000, 50));\n        unload_histogram.Count((unload_event_end - unload_event_start) *\n                               1000000.0);\n        timing.MarkUnloadEventEnd(unload_event_end);\n      } else {\n        frame_->DomWindow()->DispatchEvent(unload_event, frame_->GetDocument());\n      }\n    }\n    load_event_progress_ = kUnloadEventHandled;\n  }\n\n  if (!frame_)\n    return;\n\n  bool keep_event_listeners =\n      frame_->Loader().GetProvisionalDocumentLoader() &&\n      frame_->ShouldReuseDefaultView(\n          frame_->Loader().GetProvisionalDocumentLoader()->Url());\n  if (!keep_event_listeners)\n    RemoveAllEventListenersRecursively();\n}\n","target":0,"code_token_length":782,"total_token_length":1018,"max_tokens_setting":1024}
+{"idx":66466,"func":"static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)\n{\n\tstruct vcpu_vmx *vmx = to_vmx(vcpu);\n\tbool already_loaded = vmx->loaded_vmcs->cpu == cpu;\n\n\tif (!already_loaded) {\n\t\tloaded_vmcs_clear(vmx->loaded_vmcs);\n\t\tlocal_irq_disable();\n\t\tcrash_disable_local_vmclear(cpu);\n\n\t\t\/*\n\t\t * Read loaded_vmcs->cpu should be before fetching\n\t\t * loaded_vmcs->loaded_vmcss_on_cpu_link.\n\t\t * See the comments in __loaded_vmcs_clear().\n\t\t *\/\n\t\tsmp_rmb();\n\n\t\tlist_add(&vmx->loaded_vmcs->loaded_vmcss_on_cpu_link,\n\t\t\t &per_cpu(loaded_vmcss_on_cpu, cpu));\n\t\tcrash_enable_local_vmclear(cpu);\n\t\tlocal_irq_enable();\n\t}\n\n\tif (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) {\n\t\tper_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs;\n\t\tvmcs_load(vmx->loaded_vmcs->vmcs);\n\t\tindirect_branch_prediction_barrier();\n\t}\n\n\tif (!already_loaded) {\n\t\tvoid *gdt = get_current_gdt_ro();\n\t\tunsigned long sysenter_esp;\n\n\t\tkvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);\n\n\t\t\/*\n\t\t * Linux uses per-cpu TSS and GDT, so set these when switching\n\t\t * processors.  See 22.2.4.\n\t\t *\/\n\t\tvmcs_writel(HOST_TR_BASE,\n\t\t\t    (unsigned long)&get_cpu_entry_area(cpu)->tss.x86_tss);\n\t\tvmcs_writel(HOST_GDTR_BASE, (unsigned long)gdt);   \/* 22.2.4 *\/\n\n\t\t\/*\n\t\t * VM exits change the host TR limit to 0x67 after a VM\n\t\t * exit.  This is okay, since 0x67 covers everything except\n\t\t * the IO bitmap and have have code to handle the IO bitmap\n\t\t * being lost after a VM exit.\n\t\t *\/\n\t\tBUILD_BUG_ON(IO_BITMAP_OFFSET - 1 != 0x67);\n\n\t\trdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);\n\t\tvmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); \/* 22.2.3 *\/\n\n\t\tvmx->loaded_vmcs->cpu = cpu;\n\t}\n\n\t\/* Setup TSC multiplier *\/\n\tif (kvm_has_tsc_control &&\n\t    vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio)\n\t\tdecache_tsc_multiplier(vmx);\n\n\tvmx_vcpu_pi_load(vcpu, cpu);\n\tvmx->host_pkru = read_pkru();\n\tvmx->host_debugctlmsr = get_debugctlmsr();\n}","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":142070,"func":"ParseNodePtr Parser::StaticCreateBinNode(OpCode nop, ParseNodePtr pnode1,\n                                   ParseNodePtr pnode2,ArenaAllocator* alloc)\n{\n    DebugOnly(VerifyNodeSize(nop, kcbPnBin));\n    ParseNodePtr pnode = (ParseNodePtr)alloc->Alloc(kcbPnBin);\n    InitNode(nop, pnode);\n\n    pnode->sxBin.pnodeNext = nullptr;\n    pnode->sxBin.pnode1 = pnode1;\n    pnode->sxBin.pnode2 = pnode2;\n\n    \/\/ Statically detect if the add is a concat\n    if (!PHASE_OFF1(Js::ByteCodeConcatExprOptPhase))\n    {\n        \/\/ We can't flatten the concat expression if the LHS is not a flatten concat already\n        \/\/ e.g.  a + (<str> + b)\n        \/\/      Side effect of ToStr(b) need to happen first before ToStr(a)\n        \/\/      If we flatten the concat expression, we will do ToStr(a) before ToStr(b)\n        if ((nop == knopAdd) && (pnode1->CanFlattenConcatExpr() || pnode2->nop == knopStr))\n        {\n            pnode->grfpn |= fpnCanFlattenConcatExpr;\n        }\n    }\n\n    return pnode;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":322878,"func":"static int rv30_decode_mb_info(RV34DecContext *r)\n\n{\n\n    static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };\n\n    static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };\n\n    MpegEncContext *s = &r->s;\n\n    GetBitContext *gb = &s->gb;\n\n    int code = svq3_get_ue_golomb(gb);\n\n\n\n    if(code > 11){\n\n        av_log(s->avctx, AV_LOG_ERROR, \"Incorrect MB type code\\n\");\n\n        return -1;\n\n    }\n\n    if(code > 5){\n\n        av_log(s->avctx, AV_LOG_ERROR, \"dquant needed\\n\");\n\n        code -= 6;\n\n    }\n\n    if(s->pict_type != AV_PICTURE_TYPE_B)\n\n        return rv30_p_types[code];\n\n    else\n\n        return rv30_b_types[code];\n\n}\n","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":121551,"func":"static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)\n{\n\tstruct io_ring_ctx *ctx;\n\tint i, hash_bits;\n\n\tctx = kzalloc(sizeof(*ctx), GFP_KERNEL);\n\tif (!ctx)\n\t\treturn NULL;\n\n\t\/*\n\t * Use 5 bits less than the max cq entries, that should give us around\n\t * 32 entries per hash list if totally full and uniformly spread.\n\t *\/\n\thash_bits = ilog2(p->cq_entries);\n\thash_bits -= 5;\n\tif (hash_bits <= 0)\n\t\thash_bits = 1;\n\tctx->cancel_hash_bits = hash_bits;\n\tctx->cancel_hash = kmalloc((1U << hash_bits) * sizeof(struct hlist_head),\n\t\t\t\t\tGFP_KERNEL);\n\tif (!ctx->cancel_hash)\n\t\tgoto err;\n\t__hash_init(ctx->cancel_hash, 1U << hash_bits);\n\n\tctx->dummy_ubuf = kzalloc(sizeof(*ctx->dummy_ubuf), GFP_KERNEL);\n\tif (!ctx->dummy_ubuf)\n\t\tgoto err;\n\t\/* set invalid range, so io_import_fixed() fails meeting it *\/\n\tctx->dummy_ubuf->ubuf = -1UL;\n\n\tctx->io_buffers = kcalloc(1U << IO_BUFFERS_HASH_BITS,\n\t\t\t\t\tsizeof(struct list_head), GFP_KERNEL);\n\tif (!ctx->io_buffers)\n\t\tgoto err;\n\tfor (i = 0; i < (1U << IO_BUFFERS_HASH_BITS); i++)\n\t\tINIT_LIST_HEAD(&ctx->io_buffers[i]);\n\n\tif (percpu_ref_init(&ctx->refs, io_ring_ctx_ref_free,\n\t\t\t    PERCPU_REF_ALLOW_REINIT, GFP_KERNEL))\n\t\tgoto err;\n\n\tctx->flags = p->flags;\n\tinit_waitqueue_head(&ctx->sqo_sq_wait);\n\tINIT_LIST_HEAD(&ctx->sqd_list);\n\tINIT_LIST_HEAD(&ctx->cq_overflow_list);\n\tINIT_LIST_HEAD(&ctx->io_buffers_cache);\n\tINIT_LIST_HEAD(&ctx->apoll_cache);\n\tinit_completion(&ctx->ref_comp);\n\txa_init_flags(&ctx->personalities, XA_FLAGS_ALLOC1);\n\tmutex_init(&ctx->uring_lock);\n\tinit_waitqueue_head(&ctx->cq_wait);\n\tspin_lock_init(&ctx->completion_lock);\n\tspin_lock_init(&ctx->timeout_lock);\n\tINIT_WQ_LIST(&ctx->iopoll_list);\n\tINIT_LIST_HEAD(&ctx->io_buffers_pages);\n\tINIT_LIST_HEAD(&ctx->io_buffers_comp);\n\tINIT_LIST_HEAD(&ctx->defer_list);\n\tINIT_LIST_HEAD(&ctx->timeout_list);\n\tINIT_LIST_HEAD(&ctx->ltimeout_list);\n\tspin_lock_init(&ctx->rsrc_ref_lock);\n\tINIT_LIST_HEAD(&ctx->rsrc_ref_list);\n\tINIT_DELAYED_WORK(&ctx->rsrc_put_work, io_rsrc_put_work);\n\tinit_llist_head(&ctx->rsrc_put_llist);\n\tINIT_LIST_HEAD(&ctx->tctx_list);\n\tctx->submit_state.free_list.next = NULL;\n\tINIT_WQ_LIST(&ctx->locked_free_list);\n\tINIT_DELAYED_WORK(&ctx->fallback_work, io_fallback_req_func);\n\tINIT_WQ_LIST(&ctx->submit_state.compl_reqs);\n\treturn ctx;\nerr:\n\tkfree(ctx->dummy_ubuf);\n\tkfree(ctx->cancel_hash);\n\tkfree(ctx->io_buffers);\n\tkfree(ctx);\n\treturn NULL;\n}","target":0,"code_token_length":688,"total_token_length":924,"max_tokens_setting":1024}
+{"idx":147050,"func":"static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)\n{\n\tstatic const struct {\n\t\tint cmd;\n\t\tint flags;\n\t\tioctl_fn fn;\n\t} _ioctls[] = {\n\t\t{DM_VERSION_CMD, 0, NULL}, \/* version is dealt with elsewhere *\/\n\t\t{DM_REMOVE_ALL_CMD, IOCTL_FLAGS_NO_PARAMS | IOCTL_FLAGS_ISSUE_GLOBAL_EVENT, remove_all},\n\t\t{DM_LIST_DEVICES_CMD, 0, list_devices},\n\n\t\t{DM_DEV_CREATE_CMD, IOCTL_FLAGS_NO_PARAMS | IOCTL_FLAGS_ISSUE_GLOBAL_EVENT, dev_create},\n\t\t{DM_DEV_REMOVE_CMD, IOCTL_FLAGS_NO_PARAMS | IOCTL_FLAGS_ISSUE_GLOBAL_EVENT, dev_remove},\n\t\t{DM_DEV_RENAME_CMD, IOCTL_FLAGS_ISSUE_GLOBAL_EVENT, dev_rename},\n\t\t{DM_DEV_SUSPEND_CMD, IOCTL_FLAGS_NO_PARAMS, dev_suspend},\n\t\t{DM_DEV_STATUS_CMD, IOCTL_FLAGS_NO_PARAMS, dev_status},\n\t\t{DM_DEV_WAIT_CMD, 0, dev_wait},\n\n\t\t{DM_TABLE_LOAD_CMD, 0, table_load},\n\t\t{DM_TABLE_CLEAR_CMD, IOCTL_FLAGS_NO_PARAMS, table_clear},\n\t\t{DM_TABLE_DEPS_CMD, 0, table_deps},\n\t\t{DM_TABLE_STATUS_CMD, 0, table_status},\n\n\t\t{DM_LIST_VERSIONS_CMD, 0, list_versions},\n\n\t\t{DM_TARGET_MSG_CMD, 0, target_message},\n\t\t{DM_DEV_SET_GEOMETRY_CMD, 0, dev_set_geometry},\n\t\t{DM_DEV_ARM_POLL, IOCTL_FLAGS_NO_PARAMS, dev_arm_poll},\n\t\t{DM_GET_TARGET_VERSION, 0, get_target_version},\n\t};\n\n\tif (unlikely(cmd >= ARRAY_SIZE(_ioctls)))\n\t\treturn NULL;\n\n\t*ioctl_flags = _ioctls[cmd].flags;\n\treturn _ioctls[cmd].fn;\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":16218,"func":"static int ptx_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {\n const uint8_t * buf = avpkt -> data ;\n const uint8_t * buf_end = avpkt -> data + avpkt -> size ;\n AVFrame * const p = data ;\n unsigned int offset , w , h , y , stride , bytes_per_pixel ;\n int ret ;\n uint8_t * ptr ;\n if ( buf_end - buf < 14 ) return AVERROR_INVALIDDATA ;\n offset = AV_RL16 ( buf ) ;\n w = AV_RL16 ( buf + 8 ) ;\n h = AV_RL16 ( buf + 10 ) ;\n bytes_per_pixel = AV_RL16 ( buf + 12 ) >> 3 ;\n if ( bytes_per_pixel != 2 ) {\n av_log_ask_for_sample ( avctx , \"Image format is not RGB15.\\n\" ) ;\n return AVERROR_PATCHWELCOME ;\n }\n avctx -> pix_fmt = AV_PIX_FMT_RGB555 ;\n if ( buf_end - buf < offset ) return AVERROR_INVALIDDATA ;\n if ( offset != 0x2c ) av_log_ask_for_sample ( avctx , \"offset != 0x2c\\n\" ) ;\n buf += offset ;\n if ( ( ret = av_image_check_size ( w , h , 0 , avctx ) ) < 0 ) return ret ;\n if ( w != avctx -> width || h != avctx -> height ) avcodec_set_dimensions ( avctx , w , h ) ;\n if ( ( ret = ff_get_buffer ( avctx , p , 0 ) ) < 0 ) {\n av_log ( avctx , AV_LOG_ERROR , \"get_buffer() failed\\n\" ) ;\n return ret ;\n }\n p -> pict_type = AV_PICTURE_TYPE_I ;\n ptr = p -> data [ 0 ] ;\n stride = p -> linesize [ 0 ] ;\n for ( y = 0 ;\n y < h && buf_end - buf >= w * bytes_per_pixel ;\n y ++ ) {\n # if HAVE_BIGENDIAN unsigned int x ;\n for ( x = 0 ;\n x < w * bytes_per_pixel ;\n x += bytes_per_pixel ) AV_WN16 ( ptr + x , AV_RL16 ( buf + x ) ) ;\n # else memcpy ( ptr , buf , w * bytes_per_pixel ) ;\n # endif ptr += stride ;\n buf += w * bytes_per_pixel ;\n }\n * got_frame = 1 ;\n if ( y < h ) {\n av_log ( avctx , AV_LOG_WARNING , \"incomplete packet\\n\" ) ;\n return avpkt -> size ;\n }\n return offset + w * h * bytes_per_pixel ;\n }","target":0,"code_token_length":568,"total_token_length":804,"max_tokens_setting":1024}
+{"idx":221231,"func":"static IMFSample* CreateInputSample(const uint8* stream, int size,\n                                    int min_size, int alignment) {\n  CHECK(stream);\n  CHECK_GT(size, 0);\n  base::win::ScopedComPtr<IMFSample> sample;\n  sample.Attach(CreateEmptySampleWithBuffer(std::max(min_size, size),\n                                            alignment));\n  RETURN_ON_FAILURE(sample, \"Failed to create empty sample\", NULL);\n\n  base::win::ScopedComPtr<IMFMediaBuffer> buffer;\n  HRESULT hr = sample->GetBufferByIndex(0, buffer.Receive());\n  RETURN_ON_HR_FAILURE(hr, \"Failed to get buffer from sample\", NULL);\n\n  DWORD max_length = 0;\n  DWORD current_length = 0;\n  uint8* destination = NULL;\n  hr = buffer->Lock(&destination, &max_length, ¤t_length);\n  RETURN_ON_HR_FAILURE(hr, \"Failed to lock buffer\", NULL);\n\n  CHECK_EQ(current_length, 0u);\n  CHECK_GE(static_cast<int>(max_length), size);\n  memcpy(destination, stream, size);\n\n  hr = buffer->Unlock();\n  RETURN_ON_HR_FAILURE(hr, \"Failed to unlock buffer\", NULL);\n\n  hr = buffer->SetCurrentLength(size);\n  RETURN_ON_HR_FAILURE(hr, \"Failed to set buffer length\", NULL);\n\n  return sample.Detach();\n}\n","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":249595,"func":"void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType frameLoadType,\n    HistoryItem* historyItem, HistoryLoadType historyLoadType)\n{\n    ASSERT(m_frame->document());\n\n    if (!m_frame->isNavigationAllowed())\n        return;\n\n    if (m_inStopAllLoaders)\n        return;\n\n    if (m_frame->page()->defersLoading() && isBackForwardLoadType(frameLoadType)) {\n        m_deferredHistoryLoad = DeferredHistoryLoad::create(passedRequest.resourceRequest(), historyItem, frameLoadType, historyLoadType);\n        return;\n    }\n\n    FrameLoadRequest request(passedRequest);\n    request.resourceRequest().setHasUserGesture(UserGestureIndicator::processingUserGesture());\n\n    if (!prepareRequestForThisFrame(request))\n        return;\n\n    Frame* targetFrame = request.form() ? nullptr : m_frame->findFrameForNavigation(AtomicString(request.frameName()), *m_frame);\n\n    if (isBackForwardLoadType(frameLoadType)) {\n        ASSERT(historyItem);\n        m_provisionalItem = historyItem;\n    }\n\n    if (targetFrame && targetFrame != m_frame) {\n        bool wasInSamePage = targetFrame->page() == m_frame->page();\n\n        request.setFrameName(\"_self\");\n        targetFrame->navigate(request);\n        Page* page = targetFrame->page();\n        if (!wasInSamePage && page)\n            page->chromeClient().focus();\n        return;\n    }\n\n    setReferrerForFrameRequest(request);\n\n    FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) ?\n        determineFrameLoadType(request) : frameLoadType;\n    NavigationPolicy policy = navigationPolicyForRequest(request);\n    if (shouldOpenInNewWindow(targetFrame, request, policy)) {\n        if (policy == NavigationPolicyDownload) {\n            client()->loadURLExternally(request.resourceRequest(), NavigationPolicyDownload, String(), false);\n        } else {\n            request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary);\n            createWindowForRequest(request, *m_frame, policy);\n        }\n        return;\n    }\n\n    const KURL& url = request.resourceRequest().url();\n    bool sameDocumentHistoryNavigation =\n        isBackForwardLoadType(newLoadType) && historyLoadType == HistorySameDocumentLoad;\n    bool sameDocumentNavigation = policy == NavigationPolicyCurrentTab\n        && shouldPerformFragmentNavigation(\n            request.form(), request.resourceRequest().httpMethod(), newLoadType, url);\n\n    if (sameDocumentHistoryNavigation || sameDocumentNavigation) {\n        ASSERT(historyItem || !sameDocumentHistoryNavigation);\n        RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigation ?\n            historyItem->stateObject() : nullptr;\n\n        if (!sameDocumentHistoryNavigation) {\n            m_documentLoader->setNavigationType(determineNavigationType(\n                newLoadType, false, request.triggeringEvent()));\n            if (shouldTreatURLAsSameAsCurrent(url))\n                newLoadType = FrameLoadTypeReplaceCurrentItem;\n        }\n\n        loadInSameDocument(url, stateObject, newLoadType, historyLoadType, request.clientRedirect(), request.originDocument());\n        return;\n    }\n\n    startLoad(request, newLoadType, policy);\n}\n","target":0,"code_token_length":671,"total_token_length":907,"max_tokens_setting":1024}
+{"idx":408853,"func":"void fli_read_color_2(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap, unsigned char *cmap)\n{\n\tunsigned short num_packets, cnt_packets, col_pos;\n\tnum_packets=fli_read_short(f);\n\tcol_pos=0;\n\tfor (cnt_packets=num_packets; cnt_packets>0; cnt_packets--) {\n\t\tunsigned short skip_col, num_col, col_cnt;\n\t\tskip_col=fli_read_char(f);\n\t\tnum_col=fli_read_char(f);\n\t\tif (num_col == 0) {\n\t\t\tfor (col_pos=0; col_pos<768; col_pos++) {\n\t\t\t\tcmap[col_pos]=fli_read_char(f);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tfor (col_cnt=skip_col; (col_cnt>0) && (col_pos<768); col_cnt--) {\n\t\t\tcmap[col_pos]=old_cmap[col_pos];col_pos++;\n\t\t\tcmap[col_pos]=old_cmap[col_pos];col_pos++;\n\t\t\tcmap[col_pos]=old_cmap[col_pos];col_pos++;\n\t\t}\n\t\tfor (col_cnt=num_col; (col_cnt>0) && (col_pos<768); col_cnt--) {\n\t\t\tcmap[col_pos++]=fli_read_char(f);\n\t\t\tcmap[col_pos++]=fli_read_char(f);\n\t\t\tcmap[col_pos++]=fli_read_char(f);\n\t\t}\n\t}\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":170463,"func":"PrintMsg_Print_Params CalculatePrintParamsForCss(\n    WebKit::WebFrame* frame,\n    int page_index,\n    const PrintMsg_Print_Params& page_params,\n    bool ignore_css_margins,\n    bool fit_to_page,\n    double* scale_factor) {\n  PrintMsg_Print_Params css_params = GetCssPrintParams(frame, page_index,\n                                                       page_params);\n\n  PrintMsg_Print_Params params = page_params;\n  EnsureOrientationMatches(css_params, ¶ms);\n\n  if (ignore_css_margins && fit_to_page)\n    return params;\n\n  PrintMsg_Print_Params result_params = css_params;\n  if (ignore_css_margins) {\n    result_params.margin_top = params.margin_top;\n    result_params.margin_left = params.margin_left;\n\n    DCHECK(!fit_to_page);\n    int default_margin_right = params.page_size.width() -\n        params.content_size.width() - params.margin_left;\n    int default_margin_bottom = params.page_size.height() -\n        params.content_size.height() - params.margin_top;\n    result_params.content_size = gfx::Size(\n        result_params.page_size.width() - result_params.margin_left -\n            default_margin_right,\n        result_params.page_size.height() - result_params.margin_top -\n            default_margin_bottom);\n  }\n\n  if (fit_to_page) {\n    double factor = FitPrintParamsToPage(params, &result_params);\n    if (scale_factor)\n      *scale_factor = factor;\n  }\n  return result_params;\n}\n","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":220206,"func":"static void spl_filesystem_dir_open(spl_filesystem_object* intern, char *path TSRMLS_DC)\n{\n\tint skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);\n\n\tintern->type = SPL_FS_DIR;\n\tintern->_path_len = strlen(path);\n\tintern->u.dir.dirp = php_stream_opendir(path, REPORT_ERRORS, FG(default_context));\n\n\tif (intern->_path_len > 1 && IS_SLASH_AT(path, intern->_path_len-1)) {\n\t\tintern->_path = estrndup(path, --intern->_path_len);\n\t} else {\n\t\tintern->_path = estrndup(path, intern->_path_len);\n\t}\n\tintern->u.dir.index = 0;\n\n\tif (EG(exception) || intern->u.dir.dirp == NULL) {\n\t\tintern->u.dir.entry.d_name[0] = '\\0';\n\t\tif (!EG(exception)) {\n\t\t\t\/* open failed w\/out notice (turned to exception due to EH_THROW) *\/\n\t\t\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0\n\t\t\t\tTSRMLS_CC, \"Failed to open directory \\\"%s\\\"\", path);\n\t\t}\n\t} else {\n\t\tdo {\n\t\t\tspl_filesystem_dir_read(intern TSRMLS_CC);\n\t\t} while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name));\n\t}\n}\n","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":23523,"func":"static int rv34_decode_inter_mb_header ( RV34DecContext * r , int8_t * intra_types ) {\n MpegEncContext * s = & r -> s ;\n GetBitContext * gb = & s -> gb ;\n int mb_pos = s -> mb_x + s -> mb_y * s -> mb_stride ;\n int i , t ;\n r -> block_type = r -> decode_mb_info ( r ) ;\n if ( r -> block_type == - 1 ) return - 1 ;\n s -> current_picture_ptr -> mb_type [ mb_pos ] = rv34_mb_type_to_lavc [ r -> block_type ] ;\n r -> mb_type [ mb_pos ] = r -> block_type ;\n if ( r -> block_type == RV34_MB_SKIP ) {\n if ( s -> pict_type == AV_PICTURE_TYPE_P ) r -> mb_type [ mb_pos ] = RV34_MB_P_16x16 ;\n if ( s -> pict_type == AV_PICTURE_TYPE_B ) r -> mb_type [ mb_pos ] = RV34_MB_B_DIRECT ;\n }\n r -> is16 = ! ! IS_INTRA16x16 ( s -> current_picture_ptr -> mb_type [ mb_pos ] ) ;\n rv34_decode_mv ( r , r -> block_type ) ;\n if ( r -> block_type == RV34_MB_SKIP ) {\n fill_rectangle ( intra_types , 4 , 4 , r -> intra_types_stride , 0 , sizeof ( intra_types [ 0 ] ) ) ;\n return 0 ;\n }\n r -> chroma_vlc = 1 ;\n r -> luma_vlc = 0 ;\n if ( IS_INTRA ( s -> current_picture_ptr -> mb_type [ mb_pos ] ) ) {\n if ( r -> is16 ) {\n t = get_bits ( gb , 2 ) ;\n fill_rectangle ( intra_types , 4 , 4 , r -> intra_types_stride , t , sizeof ( intra_types [ 0 ] ) ) ;\n r -> luma_vlc = 2 ;\n }\n else {\n if ( r -> decode_intra_types ( r , gb , intra_types ) < 0 ) return - 1 ;\n r -> luma_vlc = 1 ;\n }\n r -> chroma_vlc = 0 ;\n r -> cur_vlcs = choose_vlc_set ( r -> si . quant , r -> si . vlc_set , 0 ) ;\n }\n else {\n for ( i = 0 ;\n i < 16 ;\n i ++ ) intra_types [ ( i & 3 ) + ( i >> 2 ) * r -> intra_types_stride ] = 0 ;\n r -> cur_vlcs = choose_vlc_set ( r -> si . quant , r -> si . vlc_set , 1 ) ;\n if ( r -> mb_type [ mb_pos ] == RV34_MB_P_MIX16x16 ) {\n r -> is16 = 1 ;\n r -> chroma_vlc = 1 ;\n r -> luma_vlc = 2 ;\n r -> cur_vlcs = choose_vlc_set ( r -> si . quant , r -> si . vlc_set , 0 ) ;\n }\n }\n return rv34_decode_cbp ( gb , r -> cur_vlcs , r -> is16 ) ;\n }","target":0,"code_token_length":685,"total_token_length":921,"max_tokens_setting":1024}
+{"idx":140594,"func":"QPDF::resolve(int objid, int generation)\n{\n    \/\/ Check object cache before checking xref table.  This allows us\n    \/\/ to insert things into the object cache that don't actually\n    \/\/ exist in the file.\n    QPDFObjGen og(objid, generation);\n    if (this->m->resolving.count(og))\n    {\n        \/\/ This can happen if an object references itself directly or\n        \/\/ indirectly in some key that has to be resolved during\n        \/\/ object parsing, such as stream length.\n\tQTC::TC(\"qpdf\", \"QPDF recursion loop in resolve\");\n\twarn(QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(),\n\t\t     \"\", this->m->file->getLastOffset(),\n\t\t     \"loop detected resolving object \" +\n\t\t     QUtil::int_to_string(objid) + \" \" +\n\t\t     QUtil::int_to_string(generation)));\n        return new QPDF_Null;\n    }\n    ResolveRecorder rr(this, og);\n\n    if (! this->m->obj_cache.count(og))\n    {\n\tif (! this->m->xref_table.count(og))\n\t{\n\t    \/\/ PDF spec says unknown objects resolve to the null object.\n\t    return new QPDF_Null;\n\t}\n\n\tQPDFXRefEntry const& entry = this->m->xref_table[og];\n        bool success = false;\n        try\n        {\n            switch (entry.getType())\n            {\n              case 1:\n                {\n                    qpdf_offset_t offset = entry.getOffset();\n                    \/\/ Object stored in cache by readObjectAtOffset\n                    int aobjid;\n                    int ageneration;\n                    QPDFObjectHandle oh =\n                        readObjectAtOffset(true, offset, \"\", objid, generation,\n                                           aobjid, ageneration);\n                }\n                break;\n\n              case 2:\n                resolveObjectsInStream(entry.getObjStreamNumber());\n                break;\n\n              default:\n                throw QPDFExc(qpdf_e_damaged_pdf,\n                              this->m->file->getName(), \"\", 0,\n                              \"object \" +\n                              QUtil::int_to_string(objid) + \"\/\" +\n                              QUtil::int_to_string(generation) +\n                              \" has unexpected xref entry type\");\n            }\n            success = true;\n        }\n        catch (QPDFExc& e)\n        {\n            warn(e);\n        }\n        catch (std::exception& e)\n        {\n            warn(QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(), \"\", 0,\n                         \"object \" +\n                         QUtil::int_to_string(objid) + \"\/\" +\n                         QUtil::int_to_string(generation) +\n                         \": error reading object: \" + e.what()));\n        }\n        if (! success)\n        {\n            QTC::TC(\"qpdf\", \"QPDF resolve failure to null\");\n            QPDFObjectHandle oh = QPDFObjectHandle::newNull();\n            this->m->obj_cache[og] =\n                ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);\n        }\n    }\n\n    return this->m->obj_cache[og].object;\n}","target":0,"code_token_length":651,"total_token_length":887,"max_tokens_setting":1024}
+{"idx":139577,"func":"static int git_tcp_connect_sock(char *host, int flags)\n{\n\tstruct strbuf error_message = STRBUF_INIT;\n\tint sockfd = -1;\n\tconst char *port = STR(DEFAULT_GIT_PORT);\n\tchar *ep;\n\tstruct hostent *he;\n\tstruct sockaddr_in sa;\n\tchar **ap;\n\tunsigned int nport;\n\tint cnt;\n\n\tget_host_and_port(&host, &port);\n\n\tif (flags & CONNECT_VERBOSE)\n\t\tfprintf(stderr, _(\"Looking up %s ... \"), host);\n\n\the = gethostbyname(host);\n\tif (!he)\n\t\tdie(_(\"unable to look up %s (%s)\"), host, hstrerror(h_errno));\n\tnport = strtoul(port, &ep, 10);\n\tif ( ep == port || *ep ) {\n\t\t\/* Not numeric *\/\n\t\tstruct servent *se = getservbyname(port,\"tcp\");\n\t\tif ( !se )\n\t\t\tdie(_(\"unknown port %s\"), port);\n\t\tnport = se->s_port;\n\t}\n\n\tif (flags & CONNECT_VERBOSE)\n\t\t\/* TRANSLATORS: this is the end of \"Looking up %s ... \" *\/\n\t\tfprintf(stderr, _(\"done.\\nConnecting to %s (port %s) ... \"), host, port);\n\n\tfor (cnt = 0, ap = he->h_addr_list; *ap; ap++, cnt++) {\n\t\tmemset(&sa, 0, sizeof sa);\n\t\tsa.sin_family = he->h_addrtype;\n\t\tsa.sin_port = htons(nport);\n\t\tmemcpy(&sa.sin_addr, *ap, he->h_length);\n\n\t\tsockfd = socket(he->h_addrtype, SOCK_STREAM, 0);\n\t\tif ((sockfd < 0) ||\n\t\t    connect(sockfd, (struct sockaddr *)&sa, sizeof sa) < 0) {\n\t\t\tstrbuf_addf(&error_message, \"%s[%d: %s]: errno=%s\\n\",\n\t\t\t\thost,\n\t\t\t\tcnt,\n\t\t\t\tinet_ntoa(*(struct in_addr *)&sa.sin_addr),\n\t\t\t\tstrerror(errno));\n\t\t\tif (0 <= sockfd)\n\t\t\t\tclose(sockfd);\n\t\t\tsockfd = -1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (flags & CONNECT_VERBOSE)\n\t\t\tfprintf(stderr, \"%s \",\n\t\t\t\tinet_ntoa(*(struct in_addr *)&sa.sin_addr));\n\t\tbreak;\n\t}\n\n\tif (sockfd < 0)\n\t\tdie(_(\"unable to connect to %s:\\n%s\"), host, error_message.buf);\n\n\tenable_keepalive(sockfd);\n\n\tif (flags & CONNECT_VERBOSE)\n\t\t\/* TRANSLATORS: this is the end of \"Connecting to %s (port %s) ... \" *\/\n\t\tfprintf_ln(stderr, _(\"done.\"));\n\n\treturn sockfd;\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":354402,"func":"static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf)\n{\n\tif (sizeof ubuf->f_blocks == 4) {\n\t\tif ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) &\n\t\t    0xffffffff00000000ULL)\n\t\t\treturn -EOVERFLOW;\n\t\t\/* f_files and f_ffree may be -1; it's okay\n\t\t * to stuff that into 32 bits *\/\n\t\tif (kbuf->f_files != 0xffffffffffffffffULL\n\t\t && (kbuf->f_files & 0xffffffff00000000ULL))\n\t\t\treturn -EOVERFLOW;\n\t\tif (kbuf->f_ffree != 0xffffffffffffffffULL\n\t\t && (kbuf->f_ffree & 0xffffffff00000000ULL))\n\t\t\treturn -EOVERFLOW;\n\t}\n\tif (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||\n\t    __put_user(kbuf->f_type, &ubuf->f_type) ||\n\t    __put_user(kbuf->f_bsize, &ubuf->f_bsize) ||\n\t    __put_user(kbuf->f_blocks, &ubuf->f_blocks) ||\n\t    __put_user(kbuf->f_bfree, &ubuf->f_bfree) ||\n\t    __put_user(kbuf->f_bavail, &ubuf->f_bavail) ||\n\t    __put_user(kbuf->f_files, &ubuf->f_files) ||\n\t    __put_user(kbuf->f_ffree, &ubuf->f_ffree) ||\n\t    __put_user(kbuf->f_namelen, &ubuf->f_namelen) ||\n\t    __put_user(kbuf->f_fsid.val[0], &ubuf->f_fsid.val[0]) ||\n\t    __put_user(kbuf->f_fsid.val[1], &ubuf->f_fsid.val[1]) ||\n\t    __put_user(kbuf->f_frsize, &ubuf->f_frsize))\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":106177,"func":"void preproc_clean_run(void) {\n\tint max_pids=32769;\n\tint start_pid = 100;\n\t\/\/ extract real max_pids\n\tFILE *fp = fopen(\"\/proc\/sys\/kernel\/pid_max\", \"r\");\n\tif (fp) {\n\t\tint val;\n\t\tif (fscanf(fp, \"%d\", &val) == 1) {\n\t\t\tif (val > 4194304)\t\/\/ this is the max value supported on 64 bit Linux kernels\n\t\t\t\tval = 4194304;\n\t\t\tif (val >= max_pids)\n\t\t\t\tmax_pids = val + 1;\n\t\t}\n\t\tfclose(fp);\n\t}\n\tint *pidarr = malloc(max_pids * sizeof(int));\n\tif (!pidarr)\n\t\terrExit(\"malloc\");\n\n\tmemset(pidarr, 0, max_pids * sizeof(int));\n\n\t\/\/ open \/proc directory\n\tDIR *dir;\n\tif (!(dir = opendir(\"\/proc\"))) {\n\t\t\/\/ sleep 2 seconds and try again\n\t\tsleep(2);\n\t\tif (!(dir = opendir(\"\/proc\"))) {\n\t\t\tfprintf(stderr, \"Error: cannot open \/proc directory\\n\");\n\t\t\texit(1);\n\t\t}\n\t}\n\n\t\/\/ read \/proc and populate pidarr with all active processes\n\tstruct dirent *entry;\n\tchar *end;\n\twhile ((entry = readdir(dir)) != NULL) {\n\t\tpid_t pid = strtol(entry->d_name, &end, 10);\n\t\tpid %= max_pids;\n\t\tif (end == entry->d_name || *end)\n\t\t\tcontinue;\n\n\t\tif (pid < start_pid)\n\t\t\tcontinue;\n\t\tpidarr[pid] = 1;\n\t}\n\tclosedir(dir);\n\n\t\/\/ clean profile and name directories\n\tclean_dir(RUN_FIREJAIL_PROFILE_DIR, pidarr, start_pid, max_pids);\n\tclean_dir(RUN_FIREJAIL_NAME_DIR, pidarr, start_pid, max_pids);\n\n\tfree(pidarr);\n}","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":208663,"func":"void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,\n\t\t\t\t\t  int width, int height,\n\t\t\t\t\t  GfxImageColorMap *colorMap,\n\t\t\t\t\t  Stream *maskStr,\n\t\t\t\t\t  int maskWidth, int maskHeight,\n\t\t\t\t\t  GBool maskInvert)\n{\n  cairo_t *cr;\n  cairo_surface_t *surface;\n  double x1, y1, x2, y2;\n  double *ctm;\n  double mat[6];\n  CairoImage *image;\n\n  ctm = state->getCTM();\n  \n  mat[0] = ctm[0];\n  mat[1] = ctm[1];\n  mat[2] = -ctm[2];\n  mat[3] = -ctm[3];\n  mat[4] = ctm[2] + ctm[4];\n  mat[5] = ctm[3] + ctm[5];\n  x1 = mat[4];\n  y1 = mat[5];\n  x2 = x1 + width;\n  y2 = y1 + height;\n\n  image = new CairoImage (x1, y1, x2, y2);\n  saveImage (image);\n\n  if (imgDrawCbk && imgDrawCbk (numImages - 1, imgDrawCbkData)) {\n    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);\n    cr = cairo_create (surface);\n    setCairo (cr);\n    cairo_translate (cr, 0, height);\n    cairo_scale (cr, width, -height);\n    \n    CairoOutputDev::drawMaskedImage(state, ref, str, width, height, colorMap,\n\t\t\t\t    maskStr, maskWidth, maskHeight, maskInvert);\n    image->setImage (surface);\n    \n    setCairo (NULL);\n    cairo_surface_destroy (surface);\n    cairo_destroy (cr);\n  }\n}\n","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":286507,"func":"limit_bandwidth (wgint bytes, struct ptimer *timer)\n{\n  double delta_t = ptimer_read (timer) - limit_data.chunk_start;\n  double expected;\n\n  limit_data.chunk_bytes += bytes;\n\n  \/* Calculate the amount of time we expect downloading the chunk\n     should take.  If in reality it took less time, sleep to\n     compensate for the difference.  *\/\n  expected = (double) limit_data.chunk_bytes \/ opt.limit_rate;\n\n  if (expected > delta_t)\n    {\n      double slp = expected - delta_t + limit_data.sleep_adjust;\n      double t0, t1;\n      if (slp < 0.2)\n        {\n          DEBUGP ((\"deferring a %.2f ms sleep (%s\/%.2f).\\n\",\n                   slp * 1000, number_to_static_string (limit_data.chunk_bytes),\n                   delta_t));\n          return;\n        }\n      DEBUGP ((\"\\nsleeping %.2f ms for %s bytes, adjust %.2f ms\\n\",\n               slp * 1000, number_to_static_string (limit_data.chunk_bytes),\n               limit_data.sleep_adjust));\n\n      t0 = ptimer_read (timer);\n      xsleep (slp);\n      t1 = ptimer_measure (timer);\n\n      \/* Due to scheduling, we probably slept slightly longer (or\n         shorter) than desired.  Calculate the difference between the\n         desired and the actual sleep, and adjust the next sleep by\n         that amount.  *\/\n      limit_data.sleep_adjust = slp - (t1 - t0);\n      \/* If sleep_adjust is very large, it's likely due to suspension\n         and not clock inaccuracy.  Don't enforce those.  *\/\n      if (limit_data.sleep_adjust > 0.5)\n        limit_data.sleep_adjust = 0.5;\n      else if (limit_data.sleep_adjust < -0.5)\n        limit_data.sleep_adjust = -0.5;\n    }\n\n  limit_data.chunk_bytes = 0;\n  limit_data.chunk_start = ptimer_read (timer);\n}\n","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":419165,"func":"format_defaults_winlink(struct format_tree *ft, struct winlink *wl)\n{\n\tstruct client\t*c = ft->c;\n\tstruct session\t*s = wl->session;\n\tstruct window\t*w = wl->window;\n\tint\t\t flag;\n\tu_int\t\t ox, oy, sx, sy;\n\n\tif (ft->w == NULL)\n\t\tft->w = wl->window;\n\tft->wl = wl;\n\n\tformat_defaults_window(ft, w);\n\n\tif (c != NULL) {\n\t\tflag = tty_window_offset(&c->tty, &ox, &oy, &sx, &sy);\n\t\tformat_add(ft, \"window_bigger\", \"%d\", flag);\n\t\tif (flag) {\n\t\t\tformat_add(ft, \"window_offset_x\", \"%u\", ox);\n\t\t\tformat_add(ft, \"window_offset_y\", \"%u\", oy);\n\t\t}\n\t}\n\n\tformat_add(ft, \"window_index\", \"%d\", wl->idx);\n\tformat_add_cb(ft, \"window_stack_index\", format_cb_window_stack_index);\n\tformat_add(ft, \"window_flags\", \"%s\", window_printable_flags(wl));\n\tformat_add(ft, \"window_active\", \"%d\", wl == s->curw);\n\n\tformat_add(ft, \"window_bell_flag\", \"%d\",\n\t    !!(wl->flags & WINLINK_BELL));\n\tformat_add(ft, \"window_activity_flag\", \"%d\",\n\t    !!(wl->flags & WINLINK_ACTIVITY));\n\tformat_add(ft, \"window_silence_flag\", \"%d\",\n\t    !!(wl->flags & WINLINK_SILENCE));\n\tformat_add(ft, \"window_last_flag\", \"%d\",\n\t    !!(wl == TAILQ_FIRST(&s->lastw)));\n\tformat_add(ft, \"window_linked\", \"%d\", session_is_linked(s, wl->window));\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":440381,"func":"PS_SERIALIZER_DECODE_FUNC(php_binary) \/* {{{ *\/\n{\n\tconst char *p;\n\tconst char *endptr = val + vallen;\n\tint namelen;\n\tzend_string *name;\n\tphp_unserialize_data_t var_hash;\n\tzval *current, rv;\n\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\n\tfor (p = val; p < endptr; ) {\n\t\tnamelen = ((unsigned char)(*p)) & (~PS_BIN_UNDEF);\n\n\t\tif (namelen < 0 || namelen > PS_BIN_MAX || (p + namelen) >= endptr) {\n\t\t\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\t\t\treturn FAILURE;\n\t\t}\n\n\t\tname = zend_string_init(p + 1, namelen, 0);\n\t\tp += namelen + 1;\n\t\tcurrent = var_tmp_var(&var_hash);\n\n\t\tif (php_var_unserialize(current, (const unsigned char **) &p, (const unsigned char *) endptr, &var_hash)) {\n\t\t\tZVAL_PTR(&rv, current);\n\t\t\tphp_set_session_var(name, &rv, &var_hash);\n\t\t} else {\n\t\t\tzend_string_release(name);\n\t\t\tphp_session_normalize_vars();\n\t\t\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\t\t\treturn FAILURE;\n\t\t}\n\t\tzend_string_release(name);\n\t}\n\n\tphp_session_normalize_vars();\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\n\treturn SUCCESS;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":78050,"func":"userauth_pubkey(Authctxt *authctxt)\n{\n\tIdentity *id;\n\tint sent = 0;\n\n\twhile ((id = TAILQ_FIRST(&authctxt->keys))) {\n\t\tif (id->tried++)\n\t\t\treturn (0);\n\t\t\/* move key to the end of the queue *\/\n\t\tTAILQ_REMOVE(&authctxt->keys, id, next);\n\t\tTAILQ_INSERT_TAIL(&authctxt->keys, id, next);\n\t\t\/*\n\t\t * send a test message if we have the public key. for\n\t\t * encrypted keys we cannot do this and have to load the\n\t\t * private key instead\n\t\t *\/\n\t\tif (id->key != NULL) {\n\t\t\tif (try_identity(id)) {\n\t\t\t\tdebug(\"Offering %s public key: %s\",\n\t\t\t\t    key_type(id->key), id->filename);\n\t\t\t\tsent = send_pubkey_test(authctxt, id);\n\t\t\t}\n\t\t} else {\n\t\t\tdebug(\"Trying private key: %s\", id->filename);\n\t\t\tid->key = load_identity_file(id);\n\t\t\tif (id->key != NULL) {\n\t\t\t\tif (try_identity(id)) {\n\t\t\t\t\tid->isprivate = 1;\n\t\t\t\t\tsent = sign_and_send_pubkey(\n\t\t\t\t\t    authctxt, id);\n\t\t\t\t}\n\t\t\t\tkey_free(id->key);\n\t\t\t\tid->key = NULL;\n\t\t\t}\n\t\t}\n\t\tif (sent)\n\t\t\treturn (sent);\n\t}\n\treturn (0);\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":293923,"func":"static unsigned int comedi_poll(struct file *file, poll_table * wait)\n{\n\tunsigned int mask = 0;\n\tconst unsigned minor = iminor(file->f_dentry->d_inode);\n\tstruct comedi_device_file_info *dev_file_info =\n\t    comedi_get_device_file_info(minor);\n\tstruct comedi_device *dev = dev_file_info->device;\n\tstruct comedi_subdevice *read_subdev;\n\tstruct comedi_subdevice *write_subdev;\n\n\tmutex_lock(&dev->mutex);\n\tif (!dev->attached) {\n\t\tDPRINTK(\"no driver configured on comedi%i\\n\", dev->minor);\n\t\tmutex_unlock(&dev->mutex);\n\t\treturn 0;\n\t}\n\n\tmask = 0;\n\tread_subdev = comedi_get_read_subdevice(dev_file_info);\n\tif (read_subdev) {\n\t\tpoll_wait(file, &read_subdev->async->wait_head, wait);\n\t\tif (!read_subdev->busy\n\t\t    || comedi_buf_read_n_available(read_subdev->async) > 0\n\t\t    || !(comedi_get_subdevice_runflags(read_subdev) &\n\t\t\t SRF_RUNNING)) {\n\t\t\tmask |= POLLIN | POLLRDNORM;\n\t\t}\n\t}\n\twrite_subdev = comedi_get_write_subdevice(dev_file_info);\n\tif (write_subdev) {\n\t\tpoll_wait(file, &write_subdev->async->wait_head, wait);\n\t\tcomedi_buf_write_alloc(write_subdev->async,\n\t\t\t\t       write_subdev->async->prealloc_bufsz);\n\t\tif (!write_subdev->busy\n\t\t    || !(comedi_get_subdevice_runflags(write_subdev) &\n\t\t\t SRF_RUNNING)\n\t\t    || comedi_buf_write_n_allocated(write_subdev->async) >=\n\t\t    bytes_per_sample(write_subdev->async->subdevice)) {\n\t\t\tmask |= POLLOUT | POLLWRNORM;\n\t\t}\n\t}\n\n\tmutex_unlock(&dev->mutex);\n\treturn mask;\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":194455,"func":" void AudioRendererHost::OnCreateStream(\n     int stream_id, const media::AudioParameters& params, int input_channels) {\n   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));\n  \/\/ media::AudioParameters is validated in the deserializer.\n  if (input_channels < 0 ||\n      input_channels > media::limits::kMaxChannels ||\n      LookupById(stream_id) != NULL) {\n    SendErrorMessage(stream_id);\n    return;\n  }\n \n   media::AudioParameters audio_params(params);\n \n   int output_memory_size = AudioBus::CalculateMemorySize(audio_params);\n \n   int frames = audio_params.frames_per_buffer();\n   int input_memory_size =\n       AudioBus::CalculateMemorySize(input_channels, frames);\n \n   scoped_ptr<AudioEntry> entry(new AudioEntry());\n \n  uint32 io_buffer_size = output_memory_size + input_memory_size;\n\n  uint32 shared_memory_size =\n      media::TotalSharedMemorySizeInBytes(io_buffer_size);\n  if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) {\n    SendErrorMessage(stream_id);\n    return;\n  }\n\n  scoped_ptr<AudioSyncReader> reader(\n      new AudioSyncReader(&entry->shared_memory, params, input_channels));\n\n  if (!reader->Init()) {\n    SendErrorMessage(stream_id);\n    return;\n  }\n\n  entry->reader.reset(reader.release());\n  entry->controller = media::AudioOutputController::Create(\n      audio_manager_, this, audio_params, entry->reader.get());\n\n  if (!entry->controller) {\n    SendErrorMessage(stream_id);\n    return;\n  }\n\n  entry->stream_id = stream_id;\n  audio_entries_.insert(std::make_pair(stream_id, entry.release()));\n  if (media_observer_)\n    media_observer_->OnSetAudioStreamStatus(this, stream_id, \"created\");\n}\n","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":313181,"func":"static void WriteBodyHTMLTable( SQLHSTMT hStmt )\n{\n    SQLINTEGER      nCol                            = 0;\n    SQLSMALLINT     nColumns                        = 0;\n    SQLLEN          nIndicator                      = 0;\n    SQLTCHAR        szColumnValue[MAX_DATA_WIDTH+1];\n    SQLRETURN       nReturn                         = 0;\n    SQLRETURN       ret;\n\n    szColumnValue[ 0 ]  = 0;\n\n    if ( SQLNumResultCols( hStmt, &nColumns ) != SQL_SUCCESS )\n        nColumns = -1;\n\n    while ( (ret = SQLFetch( hStmt )) == SQL_SUCCESS ) \/* ROWS *\/\n    {\n        printf( \"<tr>\\n\" );\n\n        for ( nCol = 1; nCol <= nColumns; nCol++ ) \/* COLS *\/\n        {\n            printf( \"<td>\\n\" );\n            printf( \"<font face=Arial,Helvetica>\\n\" );\n\n            nReturn = SQLGetData( hStmt, nCol, SQL_C_WCHAR, (SQLPOINTER)szColumnValue, sizeof(szColumnValue), &nIndicator );\n            if ( nReturn == SQL_SUCCESS && nIndicator != SQL_NULL_DATA )\n            {\n                uc_to_ascii( szColumnValue );\n                fputs((char*) szColumnValue, stdout );\n            }\n            else if ( nReturn == SQL_ERROR )\n            {\n                ret = SQL_ERROR;\n                break;\n            }\n            else\n                printf( \"%s\\n\", \"\" );\n\n            printf( \"<\/font>\\n\" );\n            printf( \"<\/td>\\n\" );\n        }\n        if (ret != SQL_SUCCESS)\n            break;\n        printf( \"<\/tr>\\n\" );\n    }\n}\n","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":178556,"func":"static int adev_open(const hw_module_t* module, const char* name,\n hw_device_t** device)\n{\n struct a2dp_audio_device *adev;\n int ret;\n\n    INFO(\" adev_open in A2dp_hw module\");\n    FNLOG();\n\n if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)\n {\n        ERROR(\"interface %s not matching [%s]\", name, AUDIO_HARDWARE_INTERFACE);\n return -EINVAL;\n }\n\n    adev = calloc(1, sizeof(struct a2dp_audio_device));\n\n if (!adev)\n return -ENOMEM;\n\n    adev->device.common.tag = HARDWARE_DEVICE_TAG;\n    adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;\n    adev->device.common.module = (struct hw_module_t *) module;\n    adev->device.common.close = adev_close;\n\n    adev->device.init_check = adev_init_check;\n    adev->device.set_voice_volume = adev_set_voice_volume;\n    adev->device.set_master_volume = adev_set_master_volume;\n    adev->device.set_mode = adev_set_mode;\n    adev->device.set_mic_mute = adev_set_mic_mute;\n    adev->device.get_mic_mute = adev_get_mic_mute;\n    adev->device.set_parameters = adev_set_parameters;\n    adev->device.get_parameters = adev_get_parameters;\n    adev->device.get_input_buffer_size = adev_get_input_buffer_size;\n    adev->device.open_output_stream = adev_open_output_stream;\n    adev->device.close_output_stream = adev_close_output_stream;\n    adev->device.open_input_stream = adev_open_input_stream;\n    adev->device.close_input_stream = adev_close_input_stream;\n    adev->device.dump = adev_dump;\n\n    adev->output = NULL;\n\n\n *device = &adev->device.common;\n\n return 0;\n}\n","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":380940,"func":"static CURLcode parse_url_login(struct SessionHandle *data,\n                                struct connectdata *conn,\n                                char **user, char **passwd, char **options)\n{\n  CURLcode result = CURLE_OK;\n  char *userp = NULL;\n  char *passwdp = NULL;\n  char *optionsp = NULL;\n\n  \/* At this point, we're hoping all the other special cases have\n   * been taken care of, so conn->host.name is at most\n   *    [user[:password][;options]]@]hostname\n   *\n   * We need somewhere to put the embedded details, so do that first.\n   *\/\n\n  char *ptr = strchr(conn->host.name, '@');\n  char *login = conn->host.name;\n\n  DEBUGASSERT(!**user);\n  DEBUGASSERT(!**passwd);\n  DEBUGASSERT(!**options);\n\n  if(!ptr)\n    goto out;\n\n  \/* We will now try to extract the\n   * possible login information in a string like:\n   * ftp:\/\/user:password@ftp.my.site:8021\/README *\/\n  conn->host.name = ++ptr;\n\n  \/* So the hostname is sane.  Only bother interpreting the\n   * results if we could care.  It could still be wasted\n   * work because it might be overtaken by the programmatically\n   * set user\/passwd, but doing that first adds more cases here :-(\n   *\/\n\n  if(data->set.use_netrc == CURL_NETRC_REQUIRED)\n    goto out;\n\n  \/* We could use the login information in the URL so extract it *\/\n  result = parse_login_details(login, ptr - login - 1,\n                               &userp, &passwdp, &optionsp);\n  if(result)\n    goto out;\n\n  if(userp) {\n    char *newname;\n\n    \/* We have a user in the URL *\/\n    conn->bits.userpwd_in_url = TRUE;\n    conn->bits.user_passwd = TRUE; \/* enable user+password *\/\n\n    \/* Decode the user *\/\n    newname = curl_easy_unescape(data, userp, 0, NULL);\n    if(!newname) {\n      result = CURLE_OUT_OF_MEMORY;\n      goto out;\n    }\n\n    free(*user);\n    *user = newname;\n  }\n\n  if(passwdp) {\n    \/* We have a password in the URL so decode it *\/\n    char *newpasswd = curl_easy_unescape(data, passwdp, 0, NULL);\n    if(!newpasswd) {\n      result = CURLE_OUT_OF_MEMORY;\n      goto out;\n    }\n\n    free(*passwd);\n    *passwd = newpasswd;\n  }\n\n  if(optionsp) {\n    \/* We have an options list in the URL so decode it *\/\n    char *newoptions = curl_easy_unescape(data, optionsp, 0, NULL);\n    if(!newoptions) {\n      result = CURLE_OUT_OF_MEMORY;\n      goto out;\n    }\n\n    free(*options);\n    *options = newoptions;\n  }\n\n\n  out:\n\n  Curl_safefree(userp);\n  Curl_safefree(passwdp);\n  Curl_safefree(optionsp);\n\n  return result;\n}","target":0,"code_token_length":661,"total_token_length":897,"max_tokens_setting":1024}
+{"idx":33238,"func":"md_analyze_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode)\n{\n    int ret;\n\n    \/* Reset the previously collected stack of marks. *\/\n    ctx->n_marks = 0;\n\n    \/* Collect all marks. *\/\n    MD_CHECK(md_collect_marks(ctx, lines, n_lines, table_mode));\n\n    \/* We analyze marks in few groups to handle their precedence. *\/\n    \/* (1) Entities; code spans; autolinks; raw HTML. *\/\n    md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T(\"&\"));\n\n    \/* (2) Links. *\/\n    md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T(\"[]!\"));\n    MD_CHECK(md_resolve_links(ctx, lines, n_lines));\n    BRACKET_OPENERS.head = -1;\n    BRACKET_OPENERS.tail = -1;\n    ctx->unresolved_link_head = -1;\n    ctx->unresolved_link_tail = -1;\n\n    if(table_mode) {\n        \/* (3) Analyze table cell boundaries.\n         * Note we reset TABLECELLBOUNDARIES chain prior to the call md_analyze_marks(),\n         * not after, because caller may need it. *\/\n        MD_ASSERT(n_lines == 1);\n        TABLECELLBOUNDARIES.head = -1;\n        TABLECELLBOUNDARIES.tail = -1;\n        ctx->n_table_cell_boundaries = 0;\n        md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T(\"|\"));\n        return ret;\n    }\n\n    \/* (4) Emphasis and strong emphasis; permissive autolinks. *\/\n    md_analyze_link_contents(ctx, lines, n_lines, 0, ctx->n_marks);\n\nabort:\n    return ret;\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":89238,"func":"static void find_good_pkt_pointers(struct bpf_verifier_state *vstate,\n\t\t\t\t   struct bpf_reg_state *dst_reg,\n\t\t\t\t   enum bpf_reg_type type,\n\t\t\t\t   bool range_right_open)\n{\n\tu16 new_range;\n\tint i;\n\n\tif (dst_reg->off < 0 ||\n\t    (dst_reg->off == 0 && range_right_open))\n\t\t\/* This doesn't give us any range *\/\n\t\treturn;\n\n\tif (dst_reg->umax_value > MAX_PACKET_OFF ||\n\t    dst_reg->umax_value + dst_reg->off > MAX_PACKET_OFF)\n\t\t\/* Risk of overflow.  For instance, ptr + (1<<63) may be less\n\t\t * than pkt_end, but that's because it's also less than pkt.\n\t\t *\/\n\t\treturn;\n\n\tnew_range = dst_reg->off;\n\tif (range_right_open)\n\t\tnew_range--;\n\n\t\/* Examples for register markings:\n\t *\n\t * pkt_data in dst register:\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (r2 > pkt_end) goto <handle exception>\n\t *   <access okay>\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (r2 < pkt_end) goto <access okay>\n\t *   <handle exception>\n\t *\n\t *   Where:\n\t *     r2 == dst_reg, pkt_end == src_reg\n\t *     r2=pkt(id=n,off=8,r=0)\n\t *     r3=pkt(id=n,off=0,r=0)\n\t *\n\t * pkt_data in src register:\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (pkt_end >= r2) goto <access okay>\n\t *   <handle exception>\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (pkt_end <= r2) goto <handle exception>\n\t *   <access okay>\n\t *\n\t *   Where:\n\t *     pkt_end == dst_reg, r2 == src_reg\n\t *     r2=pkt(id=n,off=8,r=0)\n\t *     r3=pkt(id=n,off=0,r=0)\n\t *\n\t * Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8)\n\t * or r3=pkt(id=n,off=0,r=8-1), so that range of bytes [r3, r3 + 8)\n\t * and [r3, r3 + 8-1) respectively is safe to access depending on\n\t * the check.\n\t *\/\n\n\t\/* If our ids match, then we must have the same max_value.  And we\n\t * don't care about the other reg's fixed offset, since if it's too big\n\t * the range won't allow anything.\n\t * dst_reg->off is known < MAX_PACKET_OFF, therefore it fits in a u16.\n\t *\/\n\tfor (i = 0; i <= vstate->curframe; i++)\n\t\t__find_good_pkt_pointers(vstate->frame[i], dst_reg, type,\n\t\t\t\t\t new_range);\n}","target":0,"code_token_length":698,"total_token_length":934,"max_tokens_setting":1024}
+{"idx":439913,"func":"ipmi_lan_set_vlan_id(struct ipmi_intf *intf,  uint8_t chan, char *string)\n{\n\tstruct lan_param *p;\n\tuint8_t data[2];\n\tint rc = -1;\n\n\tif (!string) { \/* request to disable VLAN *\/\n\t\tlprintf(LOG_DEBUG, \"Get current VLAN ID from BMC.\");\n\t\tp = get_lan_param(intf, chan, IPMI_LANP_VLAN_ID);\n\t\tif (p && p->data && p->data_len > 1) {\n\t\t\tint id = ((p->data[1] & 0x0f) << 8) + p->data[0];\n\t\t\tif (IPMI_LANP_VLAN_DISABLE == id) {\n\t\t\t\tprintf(\"VLAN is already disabled for channel %\"\n\t\t\t\t       PRIu8 \"\\n\", chan);\n\t\t\t\trc = 0;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tif (!IPMI_LANP_IS_VLAN_VALID(id)) {\n\t\t\t\tlprintf(LOG_ERR,\n\t\t\t\t        \"Retrieved VLAN ID %i is out of \"\n\t\t\t\t        \"range <%d..%d>.\",\n\t\t\t\t        id,\n\t\t\t\t        IPMI_LANP_VLAN_ID_MIN,\n\t\t\t\t        IPMI_LANP_VLAN_ID_MAX);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tdata[0] = p->data[0];\n\t\t\tdata[1] = p->data[1] & 0x0F;\n\t\t} else {\n\t\t\tdata[0] = 0;\n\t\t\tdata[1] = 0;\n\t\t}\n\t}\n\telse {\n\t\tint id = 0;\n\t\tif (str2int(string, &id) != 0) {\n\t\t\tlprintf(LOG_ERR,\n\t\t\t        \"Given VLAN ID '%s' is invalid.\",\n\t\t\t        string);\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (!IPMI_LANP_IS_VLAN_VALID(id)) {\n\t\t\tlprintf(LOG_NOTICE,\n\t\t\t        \"VLAN ID must be between %d and %d.\",\n\t\t\t        IPMI_LANP_VLAN_ID_MIN,\n\t\t\t        IPMI_LANP_VLAN_ID_MAX);\n\t\t\tgoto out;\n\t\t}\n\t\telse {\n\t\t\tdata[0] = (uint8_t)id;\n\t\t\tdata[1] = (uint8_t)(id >> 8) | 0x80;\n\t\t}\n\t}\n\trc = set_lan_param(intf, chan, IPMI_LANP_VLAN_ID, data, 2);\n\nout:\n\treturn rc;\n}","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":114742,"func":"static int sctp_listen_start(struct sock *sk, int backlog)\n{\n\tstruct sctp_sock *sp = sctp_sk(sk);\n\tstruct sctp_endpoint *ep = sp->ep;\n\tstruct crypto_hash *tfm = NULL;\n\tchar alg[32];\n\n\t\/* Allocate HMAC for generating cookie. *\/\n\tif (!sp->hmac && sp->sctp_hmac_alg) {\n\t\tsprintf(alg, \"hmac(%s)\", sp->sctp_hmac_alg);\n\t\ttfm = crypto_alloc_hash(alg, 0, CRYPTO_ALG_ASYNC);\n\t\tif (IS_ERR(tfm)) {\n\t\t\tnet_info_ratelimited(\"failed to load transform for %s: %ld\\n\",\n\t\t\t\t\t     sp->sctp_hmac_alg, PTR_ERR(tfm));\n\t\t\treturn -ENOSYS;\n\t\t}\n\t\tsctp_sk(sk)->hmac = tfm;\n\t}\n\n\t\/*\n\t * If a bind() or sctp_bindx() is not called prior to a listen()\n\t * call that allows new associations to be accepted, the system\n\t * picks an ephemeral port and will choose an address set equivalent\n\t * to binding with a wildcard address.\n\t *\n\t * This is not currently spelled out in the SCTP sockets\n\t * extensions draft, but follows the practice as seen in TCP\n\t * sockets.\n\t *\n\t *\/\n\tsk->sk_state = SCTP_SS_LISTENING;\n\tif (!ep->base.bind_addr.port) {\n\t\tif (sctp_autobind(sk))\n\t\t\treturn -EAGAIN;\n\t} else {\n\t\tif (sctp_get_port(sk, inet_sk(sk)->inet_num)) {\n\t\t\tsk->sk_state = SCTP_SS_CLOSED;\n\t\t\treturn -EADDRINUSE;\n\t\t}\n\t}\n\n\tsk->sk_max_ack_backlog = backlog;\n\tsctp_hash_endpoint(ep);\n\treturn 0;\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":501603,"func":"TEST_F(HttpHealthCheckerImplTest, ServiceNameMismatch) {\n  setupServiceNameValidationHC(\"locations\");\n  EXPECT_CALL(event_logger_, logUnhealthy(_, _, _, true));\n  EXPECT_CALL(runtime_.snapshot_, featureEnabled(\"health_check.verify_cluster\", 100))\n      .WillOnce(Return(true));\n\n  EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed));\n  EXPECT_CALL(event_logger_, logEjectUnhealthy(_, _, _));\n\n  cluster_->prioritySet().getMockHostSet(0)->hosts_ = {\n      makeTestHost(cluster_->info_, \"tcp:\/\/127.0.0.1:80\", simTime())};\n  cluster_->info_->stats().upstream_cx_total_.inc();\n  expectSessionCreate();\n  expectStreamCreate(0);\n  EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _));\n  health_checker_->start();\n\n  EXPECT_CALL(runtime_.snapshot_, getInteger(\"health_check.max_interval\", _));\n  EXPECT_CALL(runtime_.snapshot_, getInteger(\"health_check.min_interval\", _))\n      .WillOnce(Return(45000));\n  EXPECT_CALL(*test_sessions_[0]->interval_timer_,\n              enableTimer(std::chrono::milliseconds(45000), _));\n  EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer());\n  absl::optional<std::string> health_checked_cluster(\"api-production-iad\");\n  respond(0, \"200\", false, false, true, false, health_checked_cluster);\n  EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet(\n      Host::HealthFlag::FAILED_ACTIVE_HC));\n  EXPECT_EQ(Host::Health::Unhealthy,\n            cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health());\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":185211,"func":"void SoftVideoDecoderOMXComponent::handlePortSettingsChange(\n bool *portWillReset, uint32_t width, uint32_t height,\n CropSettingsMode cropSettingsMode, bool fakeStride) {\n *portWillReset = false;\n bool sizeChanged = (width != mWidth || height != mHeight);\n bool updateCrop = (cropSettingsMode == kCropUnSet);\n bool cropChanged = (cropSettingsMode == kCropChanged);\n bool strideChanged = false;\n if (fakeStride) {\n        OMX_PARAM_PORTDEFINITIONTYPE *def = &editPortInfo(kOutputPortIndex)->mDef;\n if (def->format.video.nStride != (OMX_S32)width\n || def->format.video.nSliceHeight != (OMX_U32)height) {\n            strideChanged = true;\n }\n }\n\n if (sizeChanged || cropChanged || strideChanged) {\n        mWidth = width;\n        mHeight = height;\n\n if ((sizeChanged && !mIsAdaptive)\n || width > mAdaptiveMaxWidth\n || height > mAdaptiveMaxHeight) {\n if (mIsAdaptive) {\n if (width > mAdaptiveMaxWidth) {\n                    mAdaptiveMaxWidth = width;\n }\n if (height > mAdaptiveMaxHeight) {\n                    mAdaptiveMaxHeight = height;\n }\n }\n            updatePortDefinitions(updateCrop);\n            notify(OMX_EventPortSettingsChanged, kOutputPortIndex, 0, NULL);\n            mOutputPortSettingsChange = AWAITING_DISABLED;\n *portWillReset = true;\n } else {\n            updatePortDefinitions(updateCrop);\n\n if (fakeStride) {\n                OMX_PARAM_PORTDEFINITIONTYPE *def = &editPortInfo(kOutputPortIndex)->mDef;\n                def->format.video.nStride = mWidth;\n                def->format.video.nSliceHeight = mHeight;\n }\n\n            notify(OMX_EventPortSettingsChanged, kOutputPortIndex,\n                   OMX_IndexConfigCommonOutputCrop, NULL);\n }\n }\n}\n","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":447228,"func":"static int __init efisubsys_init(void)\n{\n\tint error;\n\n\tif (!efi_enabled(EFI_BOOT))\n\t\treturn 0;\n\n\t\/*\n\t * Since we process only one efi_runtime_service() at a time, an\n\t * ordered workqueue (which creates only one execution context)\n\t * should suffice all our needs.\n\t *\/\n\tefi_rts_wq = alloc_ordered_workqueue(\"efi_rts_wq\", 0);\n\tif (!efi_rts_wq) {\n\t\tpr_err(\"Creating efi_rts_wq failed, EFI runtime services disabled.\\n\");\n\t\tclear_bit(EFI_RUNTIME_SERVICES, &efi.flags);\n\t\treturn 0;\n\t}\n\n\t\/* We register the efi directory at \/sys\/firmware\/efi *\/\n\tefi_kobj = kobject_create_and_add(\"efi\", firmware_kobj);\n\tif (!efi_kobj) {\n\t\tpr_err(\"efi: Firmware registration failed.\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\terror = generic_ops_register();\n\tif (error)\n\t\tgoto err_put;\n\n\tif (efi_enabled(EFI_RUNTIME_SERVICES))\n\t\tefivar_ssdt_load();\n\n\terror = sysfs_create_group(efi_kobj, &efi_subsys_attr_group);\n\tif (error) {\n\t\tpr_err(\"efi: Sysfs attribute export failed with error %d.\\n\",\n\t\t       error);\n\t\tgoto err_unregister;\n\t}\n\n\terror = efi_runtime_map_init(efi_kobj);\n\tif (error)\n\t\tgoto err_remove_group;\n\n\t\/* and the standard mountpoint for efivarfs *\/\n\terror = sysfs_create_mount_point(efi_kobj, \"efivars\");\n\tif (error) {\n\t\tpr_err(\"efivars: Subsystem registration failed.\\n\");\n\t\tgoto err_remove_group;\n\t}\n\n\treturn 0;\n\nerr_remove_group:\n\tsysfs_remove_group(efi_kobj, &efi_subsys_attr_group);\nerr_unregister:\n\tgeneric_ops_unregister();\nerr_put:\n\tkobject_put(efi_kobj);\n\treturn error;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":145384,"func":"R_API int r_core_bin_set_env(RCore *r, RBinFile *binfile) {\n\tr_return_val_if_fail (r, false);\n\n\tRBinObject *binobj = binfile? binfile->o: NULL;\n\tRBinInfo *info = binobj? binobj->info: NULL;\n\tif (info) {\n\t\tint va = info->has_va;\n\t\tconst char *arch = info->arch;\n\t\tut16 bits = info->bits;\n\t\tut64 baseaddr = r_bin_get_baddr (r->bin);\n\t\tr_config_set_i (r->config, \"bin.baddr\", baseaddr);\n\t\tsdb_num_add (r->sdb, \"orig_baddr\", baseaddr, 0);\n\t\tr_config_set (r->config, \"asm.arch\", arch);\n\t\tr_config_set_i (r->config, \"asm.bits\", bits);\n\t\tr_config_set (r->config, \"anal.arch\", arch);\n\t\tif (info->cpu && *info->cpu) {\n\t\t\tr_config_set (r->config, \"anal.cpu\", info->cpu);\n\t\t} else {\n\t\t\tr_config_set (r->config, \"anal.cpu\", arch);\n\t\t}\n\t\tr_asm_use (r->assembler, arch);\n\t\tr_core_bin_info (r, R_CORE_BIN_ACC_ALL, R_MODE_SET, va, NULL, NULL);\n\t\tr_core_bin_set_cur (r, binfile);\n\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":495397,"func":"SSLNetVConnection::select_next_protocol(SSL *ssl, const unsigned char **out, unsigned char *outlen,\n                                        const unsigned char *in ATS_UNUSED, unsigned inlen ATS_UNUSED, void *)\n{\n  SSLNetVConnection *netvc = SSLNetVCAccess(ssl);\n  const unsigned char *npn = nullptr;\n  unsigned npnsz           = 0;\n\n  ink_release_assert(netvc != nullptr);\n  if (netvc->npnSet && netvc->npnSet->advertiseProtocols(&npn, &npnsz)) {\n    \/\/ SSL_select_next_proto chooses the first server-offered protocol that appears in the clients protocol set, ie. the\n    \/\/ server selects the protocol. This is a n^2 search, so it's preferable to keep the protocol set short.\n\n#if HAVE_SSL_SELECT_NEXT_PROTO\n    if (SSL_select_next_proto((unsigned char **)out, outlen, npn, npnsz, in, inlen) == OPENSSL_NPN_NEGOTIATED) {\n      Debug(\"ssl\", \"selected ALPN protocol %.*s\", (int)(*outlen), *out);\n      return SSL_TLSEXT_ERR_OK;\n    }\n#endif \/* HAVE_SSL_SELECT_NEXT_PROTO *\/\n  }\n\n  *out    = nullptr;\n  *outlen = 0;\n  return SSL_TLSEXT_ERR_NOACK;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":364335,"func":"xmlRegisterCharEncodingHandlersISO8859x (void) {\n    xmlNewCharEncodingHandler (\"ISO-8859-2\", ISO8859_2ToUTF8, UTF8ToISO8859_2);\n    xmlNewCharEncodingHandler (\"ISO-8859-3\", ISO8859_3ToUTF8, UTF8ToISO8859_3);\n    xmlNewCharEncodingHandler (\"ISO-8859-4\", ISO8859_4ToUTF8, UTF8ToISO8859_4);\n    xmlNewCharEncodingHandler (\"ISO-8859-5\", ISO8859_5ToUTF8, UTF8ToISO8859_5);\n    xmlNewCharEncodingHandler (\"ISO-8859-6\", ISO8859_6ToUTF8, UTF8ToISO8859_6);\n    xmlNewCharEncodingHandler (\"ISO-8859-7\", ISO8859_7ToUTF8, UTF8ToISO8859_7);\n    xmlNewCharEncodingHandler (\"ISO-8859-8\", ISO8859_8ToUTF8, UTF8ToISO8859_8);\n    xmlNewCharEncodingHandler (\"ISO-8859-9\", ISO8859_9ToUTF8, UTF8ToISO8859_9);\n    xmlNewCharEncodingHandler (\"ISO-8859-10\", ISO8859_10ToUTF8, UTF8ToISO8859_10);\n    xmlNewCharEncodingHandler (\"ISO-8859-11\", ISO8859_11ToUTF8, UTF8ToISO8859_11);\n    xmlNewCharEncodingHandler (\"ISO-8859-13\", ISO8859_13ToUTF8, UTF8ToISO8859_13);\n    xmlNewCharEncodingHandler (\"ISO-8859-14\", ISO8859_14ToUTF8, UTF8ToISO8859_14);\n    xmlNewCharEncodingHandler (\"ISO-8859-15\", ISO8859_15ToUTF8, UTF8ToISO8859_15);\n    xmlNewCharEncodingHandler (\"ISO-8859-16\", ISO8859_16ToUTF8, UTF8ToISO8859_16);\n}","target":0,"code_token_length":566,"total_token_length":802,"max_tokens_setting":1024}
+{"idx":45727,"func":"static OPJ_BOOL opj_j2k_end_encoding(opj_j2k_t *p_j2k,\n                                     struct opj_stream_private *p_stream,\n                                     struct opj_event_mgr * p_manager)\n{\n    \/* preconditions *\/\n    assert(p_j2k != 00);\n    assert(p_manager != 00);\n    assert(p_stream != 00);\n\n    OPJ_UNUSED(p_stream);\n    OPJ_UNUSED(p_manager);\n\n    opj_tcd_destroy(p_j2k->m_tcd);\n    p_j2k->m_tcd = 00;\n\n    if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {\n        opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);\n        p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 0;\n        p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 0;\n    }\n\n    if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) {\n        opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);\n        p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 0;\n    }\n\n    p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = 0;\n\n    return OPJ_TRUE;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":188722,"func":"png_check_cHRM_fixed(png_structp png_ptr,\n   png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,\n   png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,\n   png_fixed_point blue_x, png_fixed_point blue_y)\n{\n   int ret = 1;\n   unsigned long xy_hi,xy_lo,yx_hi,yx_lo;\n\n   png_debug(1, \"in function png_check_cHRM_fixed\");\n\n   if (png_ptr == NULL)\n      return 0;\n\n   if (white_x < 0 || white_y <= 0 ||\n         red_x < 0 ||   red_y <  0 ||\n       green_x < 0 || green_y <  0 ||\n        blue_x < 0 ||  blue_y <  0)\n   {\n      png_warning(png_ptr,\n        \"Ignoring attempt to set negative chromaticity value\");\n      ret = 0;\n   }\n   if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||\n       white_y > (png_fixed_point) PNG_UINT_31_MAX ||\n         red_x > (png_fixed_point) PNG_UINT_31_MAX ||\n         red_y > (png_fixed_point) PNG_UINT_31_MAX ||\n       green_x > (png_fixed_point) PNG_UINT_31_MAX ||\n       green_y > (png_fixed_point) PNG_UINT_31_MAX ||\n        blue_x > (png_fixed_point) PNG_UINT_31_MAX ||\n        blue_y > (png_fixed_point) PNG_UINT_31_MAX )\n   {\n      png_warning(png_ptr,\n        \"Ignoring attempt to set chromaticity value exceeding 21474.83\");\n      ret = 0;\n   }\n   if (white_x > 100000L - white_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM white point\");\n      ret = 0;\n   }\n   if (red_x > 100000L - red_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM red point\");\n      ret = 0;\n   }\n   if (green_x > 100000L - green_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM green point\");\n      ret = 0;\n   }\n   if (blue_x > 100000L - blue_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM blue point\");\n      ret = 0;\n   }\n\n   png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo);\n   png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo);\n\n   if (xy_hi == yx_hi && xy_lo == yx_lo)\n   {\n      png_warning(png_ptr,\n         \"Ignoring attempt to set cHRM RGB triangle with zero area\");\n      ret = 0;\n   }\n\n   return ret;\n}\n","target":0,"code_token_length":646,"total_token_length":882,"max_tokens_setting":1024}
+{"idx":335582,"func":"static void jump_to_IPL_code(uint64_t address)\n\n{\n\n    \/* store the subsystem information _after_ the bootmap was loaded *\/\n\n    write_subsystem_identification();\n\n    \/*\n\n     * The IPL PSW is at address 0. We also must not overwrite the\n\n     * content of non-BIOS memory after we loaded the guest, so we\n\n     * save the original content and restore it in jump_to_IPL_2.\n\n     *\/\n\n    ResetInfo *current = 0;\n\n\n\n    save = *current;\n\n    current->ipl_addr = (uint32_t) (uint64_t) &jump_to_IPL_2;\n\n    current->ipl_continue = address & 0x7fffffff;\n\n\n\n    debug_print_int(\"set IPL addr to\", current->ipl_continue);\n\n\n\n    \/* Ensure the guest output starts fresh *\/\n\n    sclp_print(\"\\n\");\n\n\n\n    \/*\n\n     * HACK ALERT.\n\n     * We use the load normal reset to keep r15 unchanged. jump_to_IPL_2\n\n     * can then use r15 as its stack pointer.\n\n     *\/\n\n    asm volatile(\"lghi 1,1\\n\\t\"\n\n                 \"diag 1,1,0x308\\n\\t\"\n\n                 : : : \"1\", \"memory\");\n\n    virtio_panic(\"\\n! IPL returns !\\n\");\n\n}\n","target":1,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":289273,"func":"IN_PROC_BROWSER_TEST_F ( FramebustBlockBrowserTest , ModelAllowsRedirection ) {\n const GURL blocked_urls [ ] = {\n GURL ( chrome : : kChromeUIHistoryURL ) , GURL ( chrome : : kChromeUISettingsURL ) , GURL ( chrome : : kChromeUIVersionURL ) , }\n ;\n auto * helper = GetFramebustTabHelper ( ) ;\n for ( const GURL & url : blocked_urls ) {\n helper -> AddBlockedUrl ( url , base : : BindOnce ( & FramebustBlockBrowserTest : : OnClick , base : : Unretained ( this ) ) ) ;\n }\n EXPECT_TRUE ( helper -> HasBlockedUrls ( ) ) ;\n ContentSettingFramebustBlockBubbleModel framebust_block_bubble_model ( browser ( ) -> content_setting_bubble_model_delegate ( ) , GetWebContents ( ) , browser ( ) -> profile ( ) ) ;\n EXPECT_FALSE ( clicked_index_ . has_value ( ) ) ;\n EXPECT_FALSE ( clicked_url_ . has_value ( ) ) ;\n content : : TestNavigationObserver observer ( GetWebContents ( ) ) ;\n framebust_block_bubble_model . OnListItemClicked ( 1 , ui : : EF_LEFT_MOUSE_BUTTON ) ;\n observer . Wait ( ) ;\n EXPECT_TRUE ( clicked_index_ . has_value ( ) ) ;\n EXPECT_TRUE ( clicked_url_ . has_value ( ) ) ;\n EXPECT_EQ ( 1u , clicked_index_ . value ( ) ) ;\n EXPECT_EQ ( GURL ( chrome : : kChromeUISettingsURL ) , clicked_url_ . value ( ) ) ;\n EXPECT_FALSE ( helper -> HasBlockedUrls ( ) ) ;\n EXPECT_EQ ( blocked_urls [ 1 ] , GetWebContents ( ) -> GetLastCommittedURL ( ) ) ;\n }","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":5927,"func":"int rose_parse_facilities(unsigned char *p,\n\tstruct rose_facilities_struct *facilities)\n{\n\tint facilities_len, len;\n\n\tfacilities_len = *p++;\n\n\tif (facilities_len == 0)\n\t\treturn 0;\n\n\twhile (facilities_len > 0) {\n\t\tif (*p == 0x00) {\n\t\t\tfacilities_len--;\n\t\t\tp++;\n\n\t\t\tswitch (*p) {\n\t\t\tcase FAC_NATIONAL:\t\t\/* National *\/\n\t\t\t\tlen = rose_parse_national(p + 1, facilities, facilities_len - 1);\n\t\t\t\tif (len < 0)\n\t\t\t\t\treturn 0;\n\t\t\t\tfacilities_len -= len + 1;\n\t\t\t\tp += len + 1;\n\t\t\t\tbreak;\n\n\t\t\tcase FAC_CCITT:\t\t\/* CCITT *\/\n\t\t\t\tlen = rose_parse_ccitt(p + 1, facilities, facilities_len - 1);\n\t\t\t\tif (len < 0)\n\t\t\t\t\treturn 0;\n\t\t\t\tfacilities_len -= len + 1;\n\t\t\t\tp += len + 1;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tprintk(KERN_DEBUG \"ROSE: rose_parse_facilities - unknown facilities family %02X\\n\", *p);\n\t\t\t\tfacilities_len--;\n\t\t\t\tp++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tbreak;\t\/* Error in facilities format *\/\n\t}\n\n\treturn 1;\n}","target":1,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":76878,"func":"static void cdc_ncm_fix_modulus(struct usbnet *dev)\n{\n\tstruct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];\n\tu32 val;\n\n\t\/*\n\t * verify that the structure alignment is:\n\t * - power of two\n\t * - not greater than the maximum transmit length\n\t * - not less than four bytes\n\t *\/\n\tval = ctx->tx_ndp_modulus;\n\n\tif ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||\n\t    (val != ((-val) & val)) || (val >= ctx->tx_max)) {\n\t\tdev_dbg(&dev->intf->dev, \"Using default alignment: 4 bytes\\n\");\n\t\tctx->tx_ndp_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;\n\t}\n\n\t\/*\n\t * verify that the payload alignment is:\n\t * - power of two\n\t * - not greater than the maximum transmit length\n\t * - not less than four bytes\n\t *\/\n\tval = ctx->tx_modulus;\n\n\tif ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||\n\t    (val != ((-val) & val)) || (val >= ctx->tx_max)) {\n\t\tdev_dbg(&dev->intf->dev, \"Using default transmit modulus: 4 bytes\\n\");\n\t\tctx->tx_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;\n\t}\n\n\t\/* verify the payload remainder *\/\n\tif (ctx->tx_remainder >= ctx->tx_modulus) {\n\t\tdev_dbg(&dev->intf->dev, \"Using default transmit remainder: 0 bytes\\n\");\n\t\tctx->tx_remainder = 0;\n\t}\n\n\t\/* adjust TX-remainder according to NCM specification. *\/\n\tctx->tx_remainder = ((ctx->tx_remainder - cdc_ncm_eth_hlen(dev)) &\n\t\t\t     (ctx->tx_modulus - 1));\n}","target":0,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":136482,"func":"dissect_usch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,\n                          int offset, struct fp_info *p_fp_info)\n{\n    gboolean is_control_frame;\n\n    \/* Header CRC *\/\n    proto_tree_add_item(tree, hf_fp_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN);\n\n    \/* Frame Type *\/\n    is_control_frame = tvb_get_guint8(tvb, offset) & 0x01;\n    proto_tree_add_item(tree, hf_fp_ft, tvb, offset, 1, ENC_BIG_ENDIAN);\n    offset++;\n\n    col_append_str(pinfo->cinfo, COL_INFO, is_control_frame ? \" [Control] \" : \" [Data] \");\n\n    if (is_control_frame) {\n        dissect_common_control(tvb, pinfo, tree, offset, p_fp_info);\n    }\n    else {\n        guint cfn;\n        guint16 rx_timing_deviation;\n        proto_item *rx_timing_deviation_ti;\n        guint header_length = 0;\n\n        \/* DATA *\/\n\n        \/* CFN *\/\n        cfn = tvb_get_guint8(tvb, offset);\n        proto_tree_add_item(tree, hf_fp_cfn, tvb, offset, 1, ENC_BIG_ENDIAN);\n        offset++;\n\n        col_append_fstr(pinfo->cinfo, COL_INFO, \"CFN=%03u \", cfn);\n\n        \/* TFI *\/\n        proto_tree_add_item(tree, hf_fp_usch_tfi, tvb, offset, 1, ENC_BIG_ENDIAN);\n        offset++;\n\n        \/* Rx Timing Deviation *\/\n        rx_timing_deviation = tvb_get_guint8(tvb, offset);\n        rx_timing_deviation_ti = proto_tree_add_item(tree, hf_fp_rx_timing_deviation,\n                                                     tvb, offset, 1, ENC_BIG_ENDIAN);\n        offset++;\n        header_length = offset;\n        \/* TB data *\/\n        offset = dissect_tb_data(tvb, pinfo, tree, offset, p_fp_info, NULL, NULL);\n\n        \/* QE *\/\n        proto_tree_add_item(tree, hf_fp_quality_estimate, tvb, offset, 1, ENC_BIG_ENDIAN);\n        offset++;\n\n        \/* CRCIs *\/\n        offset = dissect_crci_bits(tvb, pinfo, tree, p_fp_info, offset);\n\n        \/* New IEs *\/\n        if ((p_fp_info->release == 7) &&\n            (tvb_reported_length_remaining(tvb, offset) > 2)) {\n\n            guint8 flags = tvb_get_guint8(tvb, offset);\n            guint8 bits_extended = flags & 0x01;\n            offset++;\n\n            if (bits_extended) {\n                guint8 extra_bits = tvb_get_guint8(tvb, offset) & 0x03;\n                proto_item_append_text(rx_timing_deviation_ti,\n                                       \" (extended to %u)\",\n                                       (rx_timing_deviation << 2) | extra_bits);\n            }\n            offset++;\n        }\n\n        \/* Spare Extension and Payload CRC *\/\n        dissect_spare_extension_and_crc(tvb, pinfo, tree, 1, offset, header_length);\n    }\n}","target":0,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":291825,"func":"static int __commit_inmem_pages(struct inode *inode,\n\t\t\t\t\tstruct list_head *revoke_list)\n{\n\tstruct f2fs_sb_info *sbi = F2FS_I_SB(inode);\n\tstruct f2fs_inode_info *fi = F2FS_I(inode);\n\tstruct inmem_pages *cur, *tmp;\n\tstruct f2fs_io_info fio = {\n\t\t.sbi = sbi,\n\t\t.type = DATA,\n\t\t.op = REQ_OP_WRITE,\n\t\t.op_flags = REQ_SYNC | REQ_PRIO,\n\t\t.io_type = FS_DATA_IO,\n\t};\n\tpgoff_t last_idx = ULONG_MAX;\n\tint err = 0;\n\n\tlist_for_each_entry_safe(cur, tmp, &fi->inmem_pages, list) {\n\t\tstruct page *page = cur->page;\n\n\t\tlock_page(page);\n\t\tif (page->mapping == inode->i_mapping) {\n\t\t\ttrace_f2fs_commit_inmem_page(page, INMEM);\n\n\t\t\tset_page_dirty(page);\n\t\t\tf2fs_wait_on_page_writeback(page, DATA, true);\n\t\t\tif (clear_page_dirty_for_io(page)) {\n\t\t\t\tinode_dec_dirty_pages(inode);\n\t\t\t\tremove_dirty_inode(inode);\n\t\t\t}\nretry:\n\t\t\tfio.page = page;\n\t\t\tfio.old_blkaddr = NULL_ADDR;\n\t\t\tfio.encrypted_page = NULL;\n\t\t\tfio.need_lock = LOCK_DONE;\n\t\t\terr = do_write_data_page(&fio);\n\t\t\tif (err) {\n\t\t\t\tif (err == -ENOMEM) {\n\t\t\t\t\tcongestion_wait(BLK_RW_ASYNC, HZ\/50);\n\t\t\t\t\tcond_resched();\n\t\t\t\t\tgoto retry;\n\t\t\t\t}\n\t\t\t\tunlock_page(page);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\/* record old blkaddr for revoking *\/\n\t\t\tcur->old_addr = fio.old_blkaddr;\n\t\t\tlast_idx = page->index;\n\t\t}\n\t\tunlock_page(page);\n\t\tlist_move_tail(&cur->list, revoke_list);\n\t}\n\n\tif (last_idx != ULONG_MAX)\n\t\tf2fs_submit_merged_write_cond(sbi, inode, 0, last_idx, DATA);\n\n\tif (!err)\n\t\t__revoke_inmem_pages(inode, revoke_list, false, false);\n\n\treturn err;\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":23510,"func":"int vp9_full_pixel_diamond ( const VP9_COMP * cpi , MACROBLOCK * x , MV * mvp_full , int step_param , int sadpb , int further_steps , int do_refine , const vp9_variance_fn_ptr_t * fn_ptr , const MV * ref_mv , MV * dst_mv ) {\n MV temp_mv ;\n int thissme , n , num00 = 0 ;\n int bestsme = cpi -> diamond_search_sad ( x , & cpi -> ss_cfg , mvp_full , & temp_mv , step_param , sadpb , & n , fn_ptr , ref_mv ) ;\n if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_var ( x , & temp_mv , ref_mv , fn_ptr , 1 ) ;\n * dst_mv = temp_mv ;\n if ( n > further_steps ) do_refine = 0 ;\n while ( n < further_steps ) {\n ++ n ;\n if ( num00 ) {\n num00 -- ;\n }\n else {\n thissme = cpi -> diamond_search_sad ( x , & cpi -> ss_cfg , mvp_full , & temp_mv , step_param + n , sadpb , & num00 , fn_ptr , ref_mv ) ;\n if ( thissme < INT_MAX ) thissme = vp9_get_mvpred_var ( x , & temp_mv , ref_mv , fn_ptr , 1 ) ;\n if ( num00 > further_steps - n ) do_refine = 0 ;\n if ( thissme < bestsme ) {\n bestsme = thissme ;\n * dst_mv = temp_mv ;\n }\n }\n }\n if ( do_refine ) {\n const int search_range = 8 ;\n MV best_mv = * dst_mv ;\n thissme = cpi -> refining_search_sad ( x , & best_mv , sadpb , search_range , fn_ptr , ref_mv ) ;\n if ( thissme < INT_MAX ) thissme = vp9_get_mvpred_var ( x , & best_mv , ref_mv , fn_ptr , 1 ) ;\n if ( thissme < bestsme ) {\n bestsme = thissme ;\n * dst_mv = best_mv ;\n }\n }\n return bestsme ;\n }","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":244799,"func":"static int find_interface() {\n\tfd_set read_fds;\n\tstruct mt_packet data;\n\tstruct sockaddr_in myip;\n\tunsigned char emptymac[ETH_ALEN];\n\tint testsocket;\n\tstruct timeval timeout;\n\tint optval = 1;\n\tstruct net_interface *interface;\n\n\t\/* TODO: reread interfaces on HUP *\/\n\n\tbzero(emptymac, ETH_ALEN);\n\n\tif (net_get_interfaces(&interfaces) <= 0) {\n\t\tfprintf(stderr, _(\"Error: No suitable devices found\\n\"));\n\t\texit(1);\n\t}\n\n\tDL_FOREACH(interfaces, interface) {\n\t\t\/* Skip loopback interfaces *\/\n\t\tif (memcmp(\"lo\", interface->name, 2) == 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Initialize receiving socket on the device chosen *\/\n\t\tmyip.sin_family = AF_INET;\n\t\tmemcpy((void *)&myip.sin_addr, interface->ipv4_addr, IPV4_ALEN);\n\t\tmyip.sin_port = htons(sourceport);\n\n\t\t\/* Initialize socket and bind to udp port *\/\n\t\tif ((testsocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsetsockopt(testsocket, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval));\n\t\tsetsockopt(testsocket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));\n\n\t\tif (bind(testsocket, (struct sockaddr *)&myip, sizeof(struct sockaddr_in)) == -1) {\n\t\t\tclose(testsocket);\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Ensure that we have mac-address for this interface  *\/\n\t\tif (!interface->has_mac) {\n\t\t\tclose(testsocket);\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Set the global socket handle and source mac address for send_udp() *\/\n\t\tsend_socket = testsocket;\n\t\tmemcpy(srcmac, interface->mac_addr, ETH_ALEN);\n\t\tactive_interface = interface;\n\n\t\t\/* Send a SESSIONSTART message with the current device *\/\n\t\tinit_packet(&data, MT_PTYPE_SESSIONSTART, srcmac, dstmac, sessionkey, 0);\n\t\tsend_udp(&data, 0);\n\n\t\ttimeout.tv_sec = connect_timeout;\n\t\ttimeout.tv_usec = 0;\n\n\t\tFD_ZERO(&read_fds);\n\t\tFD_SET(insockfd, &read_fds);\n\t\tselect(insockfd + 1, &read_fds, NULL, NULL, &timeout);\n\t\tif (FD_ISSET(insockfd, &read_fds)) {\n\t\t\t\/* We got a response, this is the correct device to use *\/\n\t\t\treturn 1;\n\t\t}\n\n\t\tclose(testsocket);\n\t}\n\treturn 0;\n}\n","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":383854,"func":"PHP_METHOD(Phar, delete)\n{\n\tchar *fname;\n\tint fname_len;\n\tchar *error;\n\tphar_entry_info *entry;\n\tPHAR_ARCHIVE_OBJECT();\n\n\tif (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {\n\t\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,\n\t\t\t\"Cannot write out phar archive, phar is read-only\");\n\t\treturn;\n\t}\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &fname, &fname_len) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (phar_obj->arc.archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->arc.archive) TSRMLS_CC)) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, \"phar \\\"%s\\\" is persistent, unable to copy on write\", phar_obj->arc.archive->fname);\n\t\treturn;\n\t}\n\tif (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {\n\t\tif (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {\n\t\t\tif (entry->is_deleted) {\n\t\t\t\t\/* entry is deleted, but has not been flushed to disk yet *\/\n\t\t\t\tRETURN_TRUE;\n\t\t\t} else {\n\t\t\t\tentry->is_deleted = 1;\n\t\t\t\tentry->is_modified = 1;\n\t\t\t\tphar_obj->arc.archive->is_modified = 1;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \"Entry %s does not exist and cannot be deleted\", fname);\n\t\tRETURN_FALSE;\n\t}\n\n\tphar_flush(phar_obj->arc.archive, NULL, 0, 0, &error TSRMLS_CC);\n\tif (error) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, \"%s\", error);\n\t\tefree(error);\n\t}\n\n\tRETURN_TRUE;\n}","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":350127,"func":"void MongoStatusInfo::fromStatus(JSContext* cx, Status status, JS::MutableHandleValue value) {\n    auto scope = getScope(cx);\n\n    JS::RootedValue undef(cx);\n    undef.setUndefined();\n\n    JS::AutoValueArray<1> args(cx);\n    ValueReader(cx, args[0]).fromStringData(status.reason());\n    JS::RootedObject error(cx);\n    scope->getProto<ErrorInfo>().newInstance(args, &error);\n\n    JS::RootedObject thisv(cx);\n    scope->getProto<MongoStatusInfo>().newObjectWithProto(&thisv, error);\n    ObjectWrapper thisvObj(cx, thisv);\n    thisvObj.defineProperty(InternedString::code,\n                            JSPROP_ENUMERATE,\n                            smUtils::wrapConstrainedMethod<Functions::code, false, MongoStatusInfo>,\n                            nullptr);\n\n    thisvObj.defineProperty(\n        InternedString::reason,\n        JSPROP_ENUMERATE,\n        smUtils::wrapConstrainedMethod<Functions::reason, false, MongoStatusInfo>,\n        nullptr);\n\n    \/\/ We intentionally omit JSPROP_ENUMERATE to match how Error.prototype.stack is a non-enumerable\n    \/\/ property.\n    thisvObj.defineProperty(\n        InternedString::stack,\n        0,\n        smUtils::wrapConstrainedMethod<Functions::stack, false, MongoStatusInfo>,\n        nullptr);\n\n    JS_SetPrivate(thisv, scope->trackedNew<Status>(std::move(status)));\n\n    value.setObjectOrNull(thisv);\n}","target":1,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":463174,"func":"    Status explain(OperationContext* opCtx,\n                   const std::string& dbname,\n                   const BSONObj& cmdObj,\n                   ExplainOptions::Verbosity verbosity,\n                   BSONObjBuilder* out) const override {\n        const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj));\n        if (!nss.isValid()) {\n            return {ErrorCodes::InvalidNamespace,\n                    str::stream() << \"Invalid collection name: \" << nss.ns()};\n        }\n\n        \/\/ Parse the command BSON to a QueryRequest.\n        const bool isExplain = true;\n        auto qrStatus = QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain);\n        if (!qrStatus.isOK()) {\n            return qrStatus.getStatus();\n        }\n\n        \/\/ Finish the parsing step by using the QueryRequest to create a CanonicalQuery.\n\n        ExtensionsCallbackReal extensionsCallback(opCtx, &nss);\n        const boost::intrusive_ptr<ExpressionContext> expCtx;\n        auto statusWithCQ =\n            CanonicalQuery::canonicalize(opCtx,\n                                         std::move(qrStatus.getValue()),\n                                         expCtx,\n                                         extensionsCallback,\n                                         MatchExpressionParser::kAllowAllSpecialFeatures &\n                                             ~MatchExpressionParser::AllowedFeatures::kIsolated);\n        if (!statusWithCQ.isOK()) {\n            return statusWithCQ.getStatus();\n        }\n        std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());\n\n        \/\/ Acquire locks. If the namespace is a view, we release our locks and convert the query\n        \/\/ request into an aggregation command.\n        AutoGetCollectionOrViewForReadCommand ctx(opCtx, nss);\n        if (ctx.getView()) {\n            \/\/ Relinquish locks. The aggregation command will re-acquire them.\n            ctx.releaseLocksForView();\n\n            \/\/ Convert the find command into an aggregation using $match (and other stages, as\n            \/\/ necessary), if possible.\n            const auto& qr = cq->getQueryRequest();\n            auto viewAggregationCommand = qr.asAggregationCommand();\n            if (!viewAggregationCommand.isOK())\n                return viewAggregationCommand.getStatus();\n\n            \/\/ Create the agg request equivalent of the find operation, with the explain verbosity\n            \/\/ included.\n            auto aggRequest = AggregationRequest::parseFromBSON(\n                nss, viewAggregationCommand.getValue(), verbosity);\n            if (!aggRequest.isOK()) {\n                return aggRequest.getStatus();\n            }\n\n            try {\n                return runAggregate(\n                    opCtx, nss, aggRequest.getValue(), viewAggregationCommand.getValue(), *out);\n            } catch (DBException& error) {\n                if (error.code() == ErrorCodes::InvalidPipelineOperator) {\n                    return {ErrorCodes::InvalidPipelineOperator,\n                            str::stream() << \"Unsupported in view pipeline: \" << error.what()};\n                }\n                return error.toStatus();\n            }\n        }\n\n        \/\/ The collection may be NULL. If so, getExecutor() should handle it by returning an\n        \/\/ execution tree with an EOFStage.\n        Collection* collection = ctx.getCollection();\n\n        \/\/ We have a parsed query. Time to get the execution plan for it.\n        auto statusWithPlanExecutor =\n            getExecutorFind(opCtx, collection, nss, std::move(cq), PlanExecutor::YIELD_AUTO);\n        if (!statusWithPlanExecutor.isOK()) {\n            return statusWithPlanExecutor.getStatus();\n        }\n        auto exec = std::move(statusWithPlanExecutor.getValue());\n\n        \/\/ Got the execution tree. Explain it.\n        Explain::explainStages(exec.get(), collection, verbosity, out);\n        return Status::OK();\n    }","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":84630,"func":"static int filter_frame(AVFilterLink *inlink, AVFrame *in)\n{\n    AVFilterContext *ctx = inlink->dst;\n    BoxBlurContext *s = ctx->priv;\n    AVFilterLink *outlink = inlink->dst->outputs[0];\n    AVFrame *out;\n    int plane;\n    int cw = FF_CEIL_RSHIFT(inlink->w, s->hsub), ch = FF_CEIL_RSHIFT(in->height, s->vsub);\n    int w[4] = { inlink->w, cw, cw, inlink->w };\n    int h[4] = { in->height, ch, ch, in->height };\n\n    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);\n    if (!out) {\n        av_frame_free(&in);\n        return AVERROR(ENOMEM);\n    }\n    av_frame_copy_props(out, in);\n\n    for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++)\n        hblur(out->data[plane], out->linesize[plane],\n              in ->data[plane], in ->linesize[plane],\n              w[plane], h[plane], s->radius[plane], s->power[plane],\n              s->temp);\n\n    for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++)\n        vblur(out->data[plane], out->linesize[plane],\n              out->data[plane], out->linesize[plane],\n              w[plane], h[plane], s->radius[plane], s->power[plane],\n              s->temp);\n\n    av_frame_free(&in);\n\n    return ff_filter_frame(outlink, out);\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":433196,"func":"static int ad5755_probe(struct spi_device *spi)\n{\n\tenum ad5755_type type = spi_get_device_id(spi)->driver_data;\n\tconst struct ad5755_platform_data *pdata = dev_get_platdata(&spi->dev);\n\tstruct iio_dev *indio_dev;\n\tstruct ad5755_state *st;\n\tint ret;\n\n\tindio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));\n\tif (indio_dev == NULL) {\n\t\tdev_err(&spi->dev, \"Failed to allocate iio device\\n\");\n\t\treturn  -ENOMEM;\n\t}\n\n\tst = iio_priv(indio_dev);\n\tspi_set_drvdata(spi, indio_dev);\n\n\tst->chip_info = &ad5755_chip_info_tbl[type];\n\tst->spi = spi;\n\tst->pwr_down = 0xf;\n\n\tindio_dev->dev.parent = &spi->dev;\n\tindio_dev->name = spi_get_device_id(spi)->name;\n\tindio_dev->info = &ad5755_info;\n\tindio_dev->modes = INDIO_DIRECT_MODE;\n\tindio_dev->num_channels = AD5755_NUM_CHANNELS;\n\n\tif (spi->dev.of_node)\n\t\tpdata = ad5755_parse_dt(&spi->dev);\n\telse\n\t\tpdata = spi->dev.platform_data;\n\n\tif (!pdata) {\n\t\tdev_warn(&spi->dev, \"no platform data? using default\\n\");\n\t\tpdata = &ad5755_default_pdata;\n\t}\n\n\tret = ad5755_init_channels(indio_dev, pdata);\n\tif (ret)\n\t\treturn ret;\n\n\tret = ad5755_setup_pdata(indio_dev, pdata);\n\tif (ret)\n\t\treturn ret;\n\n\treturn devm_iio_device_register(&spi->dev, indio_dev);\n}","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":437642,"func":"static inline void spl_filesystem_object_get_file_name(spl_filesystem_object *intern) \/* {{{ *\/\n{\n\tchar slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '\/' : DEFAULT_SLASH;\n\n\tswitch (intern->type) {\n\t\tcase SPL_FS_INFO:\n\t\tcase SPL_FS_FILE:\n\t\t\tif (!intern->file_name) {\n\t\t\t\tphp_error_docref(NULL, E_ERROR, \"Object not initialized\");\n\t\t\t}\n\t\t\tbreak;\n\t\tcase SPL_FS_DIR:\n\t\t\t{\n\t\t\t\tsize_t path_len = 0;\n\t\t\t\tchar *path = spl_filesystem_object_get_path(intern, &path_len);\n\t\t\t\tif (intern->file_name) {\n\t\t\t\t\tefree(intern->file_name);\n\t\t\t\t}\n\t\t\t\t\/* if there is parent path, ammend it, otherwise just use the given path as is *\/\n\t\t\t\tif (path_len == 0) {\n\t\t\t\t\tintern->file_name_len = spprintf(\n\t\t\t\t\t\t&intern->file_name, 0, \"%s\", intern->u.dir.entry.d_name);\n\t\t\t\t} else {\n\t\t\t\t\tintern->file_name_len = spprintf(\n\t\t\t\t\t\t&intern->file_name, 0, \"%s%c%s\", path, slash, intern->u.dir.entry.d_name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t}\n} \/* }}} *\/","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":128499,"func":"set_buffer_environ(Buffer *buf)\n{\n    static Buffer *prev_buf = NULL;\n    static Line *prev_line = NULL;\n    static int prev_pos = -1;\n    Line *l;\n\n    if (buf == NULL)\n\treturn;\n    if (buf != prev_buf) {\n\tset_environ(\"W3M_SOURCEFILE\", buf->sourcefile);\n\tset_environ(\"W3M_FILENAME\", buf->filename);\n\tset_environ(\"W3M_TITLE\", buf->buffername);\n\tset_environ(\"W3M_URL\", parsedURL2Str(&buf->currentURL)->ptr);\n\tset_environ(\"W3M_TYPE\", buf->real_type ? buf->real_type : \"unknown\");\n#ifdef USE_M17N\n\tset_environ(\"W3M_CHARSET\", wc_ces_to_charset(buf->document_charset));\n#endif\n    }\n    l = buf->currentLine;\n    if (l && (buf != prev_buf || l != prev_line || buf->pos != prev_pos)) {\n\tAnchor *a;\n\tParsedURL pu;\n\tchar *s = GetWord(buf);\n\tset_environ(\"W3M_CURRENT_WORD\", s ? s : \"\");\n\ta = retrieveCurrentAnchor(buf);\n\tif (a) {\n\t    parseURL2(a->url, &pu, baseURL(buf));\n\t    set_environ(\"W3M_CURRENT_LINK\", parsedURL2Str(&pu)->ptr);\n\t}\n\telse\n\t    set_environ(\"W3M_CURRENT_LINK\", \"\");\n\ta = retrieveCurrentImg(buf);\n\tif (a) {\n\t    parseURL2(a->url, &pu, baseURL(buf));\n\t    set_environ(\"W3M_CURRENT_IMG\", parsedURL2Str(&pu)->ptr);\n\t}\n\telse\n\t    set_environ(\"W3M_CURRENT_IMG\", \"\");\n\ta = retrieveCurrentForm(buf);\n\tif (a)\n\t    set_environ(\"W3M_CURRENT_FORM\", form2str((FormItemList *)a->url));\n\telse\n\t    set_environ(\"W3M_CURRENT_FORM\", \"\");\n\tset_environ(\"W3M_CURRENT_LINE\", Sprintf(\"%ld\",\n\t\t\t\t\t\tl->real_linenumber)->ptr);\n\tset_environ(\"W3M_CURRENT_COLUMN\", Sprintf(\"%d\",\n\t\t\t\t\t\t  buf->currentColumn +\n\t\t\t\t\t\t  buf->cursorX + 1)->ptr);\n    }\n    else if (!l) {\n\tset_environ(\"W3M_CURRENT_WORD\", \"\");\n\tset_environ(\"W3M_CURRENT_LINK\", \"\");\n\tset_environ(\"W3M_CURRENT_IMG\", \"\");\n\tset_environ(\"W3M_CURRENT_FORM\", \"\");\n\tset_environ(\"W3M_CURRENT_LINE\", \"0\");\n\tset_environ(\"W3M_CURRENT_COLUMN\", \"0\");\n    }\n    prev_buf = buf;\n    prev_line = l;\n    prev_pos = buf->pos;\n}","target":0,"code_token_length":569,"total_token_length":805,"max_tokens_setting":1024}
+{"idx":409584,"func":"static int bnx2x_configure_ptp(struct bnx2x *bp)\n{\n\tint rc, port = BP_PORT(bp);\n\tu32 wb_data[2];\n\n\t\/* Reset PTP event detection rules - will be configured in the IOCTL *\/\n\tREG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :\n\t       NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7FF);\n\tREG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :\n\t       NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FFF);\n\tREG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_PARAM_MASK :\n\t       NIG_REG_P0_TLLH_PTP_PARAM_MASK, 0x7FF);\n\tREG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_RULE_MASK :\n\t       NIG_REG_P0_TLLH_PTP_RULE_MASK, 0x3FFF);\n\n\t\/* Disable PTP packets to host - will be configured in the IOCTL*\/\n\tREG_WR(bp, port ? NIG_REG_P1_LLH_PTP_TO_HOST :\n\t       NIG_REG_P0_LLH_PTP_TO_HOST, 0x0);\n\n\t\/* Enable the PTP feature *\/\n\tREG_WR(bp, port ? NIG_REG_P1_PTP_EN :\n\t       NIG_REG_P0_PTP_EN, 0x3F);\n\n\t\/* Enable the free-running counter *\/\n\twb_data[0] = 0;\n\twb_data[1] = 0;\n\tREG_WR_DMAE(bp, NIG_REG_TIMESYNC_GEN_REG + tsgen_ctrl, wb_data, 2);\n\n\t\/* Reset drift register (offset register is not reset) *\/\n\trc = bnx2x_send_reset_timesync_ramrod(bp);\n\tif (rc) {\n\t\tBNX2X_ERR(\"Failed to reset PHC drift register\\n\");\n\t\treturn -EFAULT;\n\t}\n\n\t\/* Reset possibly old timestamps *\/\n\tREG_WR(bp, port ? NIG_REG_P1_LLH_PTP_HOST_BUF_SEQID :\n\t       NIG_REG_P0_LLH_PTP_HOST_BUF_SEQID, 0x10000);\n\tREG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_BUF_SEQID :\n\t       NIG_REG_P0_TLLH_PTP_BUF_SEQID, 0x10000);\n\n\treturn 0;\n}","target":0,"code_token_length":502,"total_token_length":738,"max_tokens_setting":1024}
+{"idx":226651,"func":"bool ExecuteBrowserCommandObserver::CreateAndRegisterObserver(\n    AutomationProvider* automation,\n    Browser* browser,\n    int command,\n    IPC::Message* reply_message,\n    bool use_json_interface) {\n  bool result = true;\n  switch (command) {\n    case IDC_NEW_TAB: {\n      new NewTabObserver(automation, reply_message, use_json_interface);\n      break;\n    }\n    case IDC_NEW_WINDOW:\n    case IDC_NEW_INCOGNITO_WINDOW: {\n      BrowserOpenedNotificationObserver* observer =\n          new BrowserOpenedNotificationObserver(automation, reply_message,\n                                                use_json_interface);\n      observer->set_for_browser_command(true);\n      break;\n    }\n    case IDC_CLOSE_WINDOW: {\n      BrowserClosedNotificationObserver* observer =\n          new BrowserClosedNotificationObserver(browser, automation,\n                                                reply_message,\n                                                use_json_interface);\n      observer->set_for_browser_command(true);\n      break;\n    }\n    case IDC_CLOSE_TAB: {\n      TabClosedNotificationObserver* observer =\n          new TabClosedNotificationObserver(automation, true, reply_message,\n                                            use_json_interface);\n      observer->set_for_browser_command(true);\n      break;\n    }\n    case IDC_BACK:\n    case IDC_FORWARD:\n    case IDC_RELOAD: {\n      new NavigationNotificationObserver(\n          &chrome::GetActiveWebContents(browser)->GetController(),\n          automation, reply_message, 1, false, use_json_interface);\n      break;\n    }\n    default: {\n      ExecuteBrowserCommandObserver* observer =\n          new ExecuteBrowserCommandObserver(automation, reply_message,\n                                            use_json_interface);\n      if (!observer->Register(command)) {\n        observer->ReleaseReply();\n        delete observer;\n        result = false;\n      }\n      break;\n    }\n  }\n  return result;\n}\n","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":21930,"func":"static size_t qio_channel_websock_extract_headers ( QIOChannelWebsock * ioc , char * buffer , QIOChannelWebsockHTTPHeader * hdrs , size_t nhdrsalloc , Error * * errp ) {\n char * nl , * sep , * tmp ;\n size_t nhdrs = 0 ;\n nl = strstr ( buffer , QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM ) ;\n if ( ! nl ) {\n error_setg ( errp , \"Missing HTTP header delimiter\" ) ;\n goto bad_request ;\n }\n * nl = '\\0' ;\n tmp = strchr ( buffer , ' ' ) ;\n if ( ! tmp ) {\n error_setg ( errp , \"Missing HTTP path delimiter\" ) ;\n return 0 ;\n }\n * tmp = '\\0' ;\n if ( ! g_str_equal ( buffer , QIO_CHANNEL_WEBSOCK_HTTP_METHOD ) ) {\n error_setg ( errp , \"Unsupported HTTP method %s\" , buffer ) ;\n goto bad_request ;\n }\n buffer = tmp + 1 ;\n tmp = strchr ( buffer , ' ' ) ;\n if ( ! tmp ) {\n error_setg ( errp , \"Missing HTTP version delimiter\" ) ;\n goto bad_request ;\n }\n * tmp = '\\0' ;\n if ( ! g_str_equal ( buffer , QIO_CHANNEL_WEBSOCK_HTTP_PATH ) ) {\n qio_channel_websock_handshake_send_res_err ( ioc , QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_NOT_FOUND ) ;\n error_setg ( errp , \"Unexpected HTTP path %s\" , buffer ) ;\n return 0 ;\n }\n buffer = tmp + 1 ;\n if ( ! g_str_equal ( buffer , QIO_CHANNEL_WEBSOCK_HTTP_VERSION ) ) {\n error_setg ( errp , \"Unsupported HTTP version %s\" , buffer ) ;\n goto bad_request ;\n }\n buffer = nl + strlen ( QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM ) ;\n do {\n QIOChannelWebsockHTTPHeader * hdr ;\n nl = strstr ( buffer , QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM ) ;\n if ( nl ) {\n * nl = '\\0' ;\n }\n sep = strchr ( buffer , ':' ) ;\n if ( ! sep ) {\n error_setg ( errp , \"Malformed HTTP header\" ) ;\n goto bad_request ;\n }\n * sep = '\\0' ;\n sep ++ ;\n while ( * sep == ' ' ) {\n sep ++ ;\n }\n if ( nhdrs >= nhdrsalloc ) {\n error_setg ( errp , \"Too many HTTP headers\" ) ;\n goto bad_request ;\n }\n hdr = & hdrs [ nhdrs ++ ] ;\n hdr -> name = buffer ;\n hdr -> value = sep ;\n for ( tmp = hdr -> name ;\n * tmp ;\n tmp ++ ) {\n * tmp = g_ascii_tolower ( * tmp ) ;\n }\n if ( nl ) {\n buffer = nl + strlen ( QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM ) ;\n }\n }\n while ( nl != NULL ) ;\n return nhdrs ;\n bad_request : qio_channel_websock_handshake_send_res_err ( ioc , QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST ) ;\n return 0 ;\n }","target":0,"code_token_length":648,"total_token_length":884,"max_tokens_setting":1024}
+{"idx":114409,"func":"deep_count_more_files_callback (GObject      *source_object,\n                                GAsyncResult *res,\n                                gpointer      user_data)\n{\n    DeepCountState *state;\n    NautilusDirectory *directory;\n    GList *files, *l;\n    GFileInfo *info;\n\n    state = user_data;\n\n    if (state->directory == NULL)\n    {\n        \/* Operation was cancelled. Bail out *\/\n        deep_count_state_free (state);\n        return;\n    }\n\n    directory = nautilus_directory_ref (state->directory);\n\n    g_assert (directory->details->deep_count_in_progress != NULL);\n    g_assert (directory->details->deep_count_in_progress == state);\n\n    files = g_file_enumerator_next_files_finish (state->enumerator,\n                                                 res, NULL);\n\n    for (l = files; l != NULL; l = l->next)\n    {\n        info = l->data;\n        deep_count_one (state, info);\n        g_object_unref (info);\n    }\n\n    if (files == NULL)\n    {\n        g_file_enumerator_close_async (state->enumerator, 0, NULL, NULL, NULL);\n        g_object_unref (state->enumerator);\n        state->enumerator = NULL;\n\n        deep_count_next_dir (state);\n    }\n    else\n    {\n        g_file_enumerator_next_files_async (state->enumerator,\n                                            DIRECTORY_LOAD_ITEMS_PER_CALLBACK,\n                                            G_PRIORITY_LOW,\n                                            state->cancellable,\n                                            deep_count_more_files_callback,\n                                            state);\n    }\n\n    g_list_free (files);\n\n    nautilus_directory_unref (directory);\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":374430,"func":"get_call_expr_arg_stable(Node *expr, int argnum)\n{\n\tList\t   *args;\n\tNode\t   *arg;\n\n\tif (expr == NULL)\n\t\treturn false;\n\n\tif (IsA(expr, FuncExpr))\n\t\targs = ((FuncExpr *) expr)->args;\n\telse if (IsA(expr, OpExpr))\n\t\targs = ((OpExpr *) expr)->args;\n\telse if (IsA(expr, DistinctExpr))\n\t\targs = ((DistinctExpr *) expr)->args;\n\telse if (IsA(expr, ScalarArrayOpExpr))\n\t\targs = ((ScalarArrayOpExpr *) expr)->args;\n\telse if (IsA(expr, ArrayCoerceExpr))\n\t\targs = list_make1(((ArrayCoerceExpr *) expr)->arg);\n\telse if (IsA(expr, NullIfExpr))\n\t\targs = ((NullIfExpr *) expr)->args;\n\telse if (IsA(expr, WindowFunc))\n\t\targs = ((WindowFunc *) expr)->args;\n\telse\n\t\treturn false;\n\n\tif (argnum < 0 || argnum >= list_length(args))\n\t\treturn false;\n\n\targ = (Node *) list_nth(args, argnum);\n\n\t\/*\n\t * Either a true Const or an external Param will have a value that doesn't\n\t * change during the execution of the query.  In future we might want to\n\t * consider other cases too, e.g. now().\n\t *\/\n\tif (IsA(arg, Const))\n\t\treturn true;\n\tif (IsA(arg, Param) &&\n\t\t((Param *) arg)->paramkind == PARAM_EXTERN)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":444337,"func":"TEST_F(HttpConnectionManagerImplTest, UpstreamWatermarkCallbacks) {\n  setup(false, \"\");\n  setUpEncoderAndDecoder(false, false);\n  sendRequestHeadersAndData();\n\n  \/\/ Mimic the upstream connection backing up. The router would call\n  \/\/ onDecoderFilterAboveWriteBufferHighWatermark which should readDisable the stream and increment\n  \/\/ stats.\n  EXPECT_CALL(response_encoder_, getStream()).WillOnce(ReturnRef(stream_));\n  EXPECT_CALL(stream_, readDisable(true));\n  ASSERT(decoder_filters_[0]->callbacks_ != nullptr);\n  decoder_filters_[0]->callbacks_->onDecoderFilterAboveWriteBufferHighWatermark();\n  EXPECT_EQ(1U, stats_.named_.downstream_flow_control_paused_reading_total_.value());\n\n  \/\/ Resume the flow of data. When the router buffer drains it calls\n  \/\/ onDecoderFilterBelowWriteBufferLowWatermark which should re-enable reads on the stream.\n  EXPECT_CALL(response_encoder_, getStream()).WillOnce(ReturnRef(stream_));\n  EXPECT_CALL(stream_, readDisable(false));\n  ASSERT(decoder_filters_[0]->callbacks_ != nullptr);\n  decoder_filters_[0]->callbacks_->onDecoderFilterBelowWriteBufferLowWatermark();\n  EXPECT_EQ(1U, stats_.named_.downstream_flow_control_resumed_reading_total_.value());\n\n  \/\/ Backup upstream once again.\n  EXPECT_CALL(response_encoder_, getStream()).WillOnce(ReturnRef(stream_));\n  EXPECT_CALL(stream_, readDisable(true));\n  ASSERT(decoder_filters_[0]->callbacks_ != nullptr);\n  decoder_filters_[0]->callbacks_->onDecoderFilterAboveWriteBufferHighWatermark();\n  EXPECT_EQ(2U, stats_.named_.downstream_flow_control_paused_reading_total_.value());\n\n  \/\/ Send a full response.\n  EXPECT_CALL(*encoder_filters_[0], encodeHeaders(_, true));\n  EXPECT_CALL(*encoder_filters_[0], encodeComplete());\n  EXPECT_CALL(*encoder_filters_[1], encodeHeaders(_, true));\n  EXPECT_CALL(*encoder_filters_[1], encodeComplete());\n  EXPECT_CALL(response_encoder_, encodeHeaders(_, true));\n  expectOnDestroy();\n  decoder_filters_[1]->callbacks_->encodeHeaders(\n      ResponseHeaderMapPtr{new TestResponseHeaderMapImpl{{\":status\", \"200\"}}}, true);\n}","target":0,"code_token_length":460,"total_token_length":696,"max_tokens_setting":1024}
+{"idx":505449,"func":"static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,\n\t     const char *sender, int len, unsigned char *p)\n\t{\n\tunsigned int ret;\n\tint npad,n;\n\tunsigned int i;\n\tunsigned char md_buf[EVP_MAX_MD_SIZE];\n\tEVP_MD_CTX ctx;\n\n\tEVP_MD_CTX_init(&ctx);\n\tEVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);\n\tEVP_MD_CTX_copy_ex(&ctx,in_ctx);\n\n\tn=EVP_MD_CTX_size(&ctx);\n\tnpad=(48\/n)*n;\n\n\tif (sender != NULL)\n\t\tEVP_DigestUpdate(&ctx,sender,len);\n\tEVP_DigestUpdate(&ctx,s->session->master_key,\n\t\ts->session->master_key_length);\n\tEVP_DigestUpdate(&ctx,ssl3_pad_1,npad);\n\tEVP_DigestFinal_ex(&ctx,md_buf,&i);\n\n\tEVP_DigestInit_ex(&ctx,EVP_MD_CTX_md(&ctx), NULL);\n\tEVP_DigestUpdate(&ctx,s->session->master_key,\n\t\ts->session->master_key_length);\n\tEVP_DigestUpdate(&ctx,ssl3_pad_2,npad);\n\tEVP_DigestUpdate(&ctx,md_buf,i);\n\tEVP_DigestFinal_ex(&ctx,p,&ret);\n\n\tEVP_MD_CTX_cleanup(&ctx);\n\n\treturn((int)ret);\n\t}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":200654,"func":"void LayerTreeHost::PaintLayerContents(\n    const RenderSurfaceLayerList& render_surface_layer_list,\n    ResourceUpdateQueue* queue,\n    bool* did_paint_content,\n    bool* need_more_updates) {\n  OcclusionTracker<Layer> occlusion_tracker(\n      root_layer_->render_surface()->content_rect());\n  occlusion_tracker.set_minimum_tracking_size(\n      settings_.minimum_occlusion_tracking_size);\n\n  PrioritizeTextures(render_surface_layer_list);\n\n  in_paint_layer_contents_ = true;\n\n  typedef LayerIterator<Layer> LayerIteratorType;\n  LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list);\n  for (LayerIteratorType it =\n           LayerIteratorType::Begin(&render_surface_layer_list);\n       it != end;\n       ++it) {\n    occlusion_tracker.EnterLayer(it);\n\n    if (it.represents_target_render_surface()) {\n      PaintMasksForRenderSurface(\n          *it, queue, did_paint_content, need_more_updates);\n    } else if (it.represents_itself() && it->DrawsContent()) {\n      DCHECK(!it->paint_properties().bounds.IsEmpty());\n      *did_paint_content |= it->Update(queue, &occlusion_tracker);\n      *need_more_updates |= it->NeedMoreUpdates();\n    }\n\n    occlusion_tracker.LeaveLayer(it);\n  }\n\n  in_paint_layer_contents_ = false;\n}\n","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":232135,"func":" PHP_FUNCTION(locale_lookup)\n {\n\tchar*      \tfallback_loc  \t\t= NULL;\n\tint        \tfallback_loc_len\t= 0;\n\tconst char*    \tloc_range      \t\t= NULL;\n\tint        \tloc_range_len  \t\t= 0;\n\n\tzval*\t\tarr\t\t\t\t= NULL;\n\tHashTable*\thash_arr\t\t= NULL;\n\tzend_bool\tboolCanonical\t= 0;\n\tchar*\t \tresult\t\t\t=NULL;\n\n\tintl_error_reset( NULL TSRMLS_CC );\n\n\tif(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, \"as|bs\", &arr, &loc_range, &loc_range_len,\n\t\t&boolCanonical,\t&fallback_loc, &fallback_loc_len) == FAILURE) {\n\t\tintl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,\t\"locale_lookup: unable to parse input params\", 0 TSRMLS_CC );\n\t\tRETURN_FALSE;\n\t}\n\n\tif(loc_range_len == 0) {\n\t\tloc_range = intl_locale_get_default(TSRMLS_C);\n\t}\n\n\thash_arr = HASH_OF(arr);\n \n \tif( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ) {\n \t\tRETURN_EMPTY_STRING();\n\t}\n\n \tresult = lookup_loc_range(loc_range, hash_arr, boolCanonical TSRMLS_CC);\n \tif(result == NULL || result[0] == '\\0') {\n \t\tif( fallback_loc ) {\n\t\t\tresult = estrndup(fallback_loc, fallback_loc_len);\n\t\t} else {\n\t\t\tRETURN_EMPTY_STRING();\n\t\t}\n\t}\n\n\tRETVAL_STRINGL(result, strlen(result), 0);\n}\n","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":464064,"func":"ecc_ecdsa_sign (const struct ecc_curve *ecc,\n\t\tconst mp_limb_t *zp,\n\t\t\/* Random nonce, must be invertible mod ecc group\n\t\t   order. *\/\n\t\tconst mp_limb_t *kp,\n\t\tsize_t length, const uint8_t *digest,\n\t\tmp_limb_t *rp, mp_limb_t *sp,\n\t\tmp_limb_t *scratch)\n{\n#define P\t    scratch\n#define kinv\t    scratch\n#define hp\t    (scratch  + ecc->p.size) \/* NOTE: ecc->p.size + 1 limbs! *\/\n#define tp\t    (scratch + 2*ecc->p.size)\n  \/* Procedure, according to RFC 6090, \"KT-I\". q denotes the group\n     order.\n\n     1. k <-- uniformly random, 0 < k < q\n\n     2. R <-- (r_x, r_y) = k g\n\n     3. s1 <-- r_x mod q\n\n     4. s2 <-- (h + z*s1)\/k mod q.\n  *\/\n\n  ecc->mul_g (ecc, P, kp, P + 3*ecc->p.size);\n  \/* x coordinate only, modulo q *\/\n  ecc->h_to_a (ecc, 2, rp, P, P + 3*ecc->p.size);\n\n  \/* Invert k, uses up to 7 * ecc->p.size including scratch (for secp384). *\/\n  ecc->q.invert (&ecc->q, kinv, kp, tp);\n  \n  \/* Process hash digest *\/\n  ecc_hash (&ecc->q, hp, length, digest);\n\n  ecc_mod_mul (&ecc->q, tp, zp, rp, tp);\n  ecc_mod_add (&ecc->q, hp, hp, tp);\n  ecc_mod_mul_canonical (&ecc->q, sp, hp, kinv, tp);\n\n#undef P\n#undef hp\n#undef kinv\n#undef tp\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":461462,"func":"static void coroutine_fn v9fs_link(void *opaque)\n{\n    V9fsPDU *pdu = opaque;\n    int32_t dfid, oldfid;\n    V9fsFidState *dfidp, *oldfidp;\n    V9fsString name;\n    size_t offset = 7;\n    int err = 0;\n\n    v9fs_string_init(&name);\n    err = pdu_unmarshal(pdu, offset, \"dds\", &dfid, &oldfid, &name);\n    if (err < 0) {\n        goto out_nofid;\n    }\n    trace_v9fs_link(pdu->tag, pdu->id, dfid, oldfid, name.data);\n\n    if (name_is_illegal(name.data)) {\n        err = -ENOENT;\n        goto out_nofid;\n    }\n\n    if (!strcmp(\".\", name.data) || !strcmp(\"..\", name.data)) {\n        err = -EEXIST;\n        goto out_nofid;\n    }\n\n    dfidp = get_fid(pdu, dfid);\n    if (dfidp == NULL) {\n        err = -ENOENT;\n        goto out_nofid;\n    }\n\n    oldfidp = get_fid(pdu, oldfid);\n    if (oldfidp == NULL) {\n        err = -ENOENT;\n        goto out;\n    }\n    err = v9fs_co_link(pdu, oldfidp, dfidp, &name);\n    if (!err) {\n        err = offset;\n    }\n    put_fid(pdu, oldfidp);\nout:\n    put_fid(pdu, dfidp);\nout_nofid:\n    v9fs_string_free(&name);\n    pdu_complete(pdu, err);\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":156814,"func":"ves_icall_Type_GetInterfaces (MonoReflectionType* type)\n{\n\tMonoError error;\n\tMonoDomain *domain = mono_object_domain (type); \n\tMonoArray *intf;\n\tGPtrArray *ifaces = NULL;\n\tint i;\n\tMonoClass *class = mono_class_from_mono_type (type->type);\n\tMonoClass *parent;\n\tMonoBitSet *slots;\n\tMonoGenericContext *context = NULL;\n\n\tMONO_ARCH_SAVE_REGS;\n\n\tif (class->generic_class && class->generic_class->context.class_inst->is_open) {\n\t\tcontext = mono_class_get_context (class);\n\t\tclass = class->generic_class->container_class;\n\t}\n\n\tmono_class_setup_vtable (class);\n\n\tslots = mono_bitset_new (class->max_interface_id + 1, 0);\n\n\tfor (parent = class; parent; parent = parent->parent) {\n\t\tGPtrArray *tmp_ifaces = mono_class_get_implemented_interfaces (parent, &error);\n\t\tif (!mono_error_ok (&error)) {\n\t\t\tmono_bitset_free (slots);\n\t\t\tmono_error_raise_exception (&error);\n\t\t\treturn NULL;\n\t\t} else if (tmp_ifaces) {\n\t\t\tfor (i = 0; i < tmp_ifaces->len; ++i) {\n\t\t\t\tMonoClass *ic = g_ptr_array_index (tmp_ifaces, i);\n\n\t\t\t\tif (mono_bitset_test (slots, ic->interface_id))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tmono_bitset_set (slots, ic->interface_id);\n\t\t\t\tif (ifaces == NULL)\n\t\t\t\t\tifaces = g_ptr_array_new ();\n\t\t\t\tg_ptr_array_add (ifaces, ic);\n\t\t\t}\n\t\t\tg_ptr_array_free (tmp_ifaces, TRUE);\n\t\t}\n\t}\n\tmono_bitset_free (slots);\n\n\tif (!ifaces)\n\t\treturn mono_array_new_cached (domain, mono_defaults.monotype_class, 0);\n\t\t\n\tintf = mono_array_new_cached (domain, mono_defaults.monotype_class, ifaces->len);\n\tfor (i = 0; i < ifaces->len; ++i) {\n\t\tMonoClass *ic = g_ptr_array_index (ifaces, i);\n\t\tMonoType *ret = &ic->byval_arg, *inflated = NULL;\n\t\tif (context && ic->generic_class && ic->generic_class->context.class_inst->is_open)\n\t\t\tinflated = ret = mono_class_inflate_generic_type (ret, context);\n\t\t\n\t\tmono_array_setref (intf, i, mono_type_get_object (domain, ret));\n\t\tif (inflated)\n\t\t\tmono_metadata_free_type (inflated);\n\t}\n\tg_ptr_array_free (ifaces, TRUE);\n\n\treturn intf;\n}","target":0,"code_token_length":558,"total_token_length":794,"max_tokens_setting":1024}
+{"idx":28695,"func":"static int decode_residuals ( FLACContext * s , int32_t * decoded , int pred_order ) {\n int i , tmp , partition , method_type , rice_order ;\n int rice_bits , rice_esc ;\n int samples ;\n method_type = get_bits ( & s -> gb , 2 ) ;\n if ( method_type > 1 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"illegal residual coding method %d\\n\" , method_type ) ;\n return - 1 ;\n }\n rice_order = get_bits ( & s -> gb , 4 ) ;\n samples = s -> blocksize >> rice_order ;\n if ( pred_order > samples ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"invalid predictor order: %i > %i\\n\" , pred_order , samples ) ;\n return - 1 ;\n }\n rice_bits = 4 + method_type ;\n rice_esc = ( 1 << rice_bits ) - 1 ;\n decoded += pred_order ;\n i = pred_order ;\n for ( partition = 0 ;\n partition < ( 1 << rice_order ) ;\n partition ++ ) {\n tmp = get_bits ( & s -> gb , rice_bits ) ;\n if ( tmp == rice_esc ) {\n tmp = get_bits ( & s -> gb , 5 ) ;\n for ( ;\n i < samples ;\n i ++ ) * decoded ++ = get_sbits_long ( & s -> gb , tmp ) ;\n }\n else {\n for ( ;\n i < samples ;\n i ++ ) {\n * decoded ++ = get_sr_golomb_flac ( & s -> gb , tmp , INT_MAX , 0 ) ;\n }\n }\n i = 0 ;\n }\n return 0 ;\n }","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":335454,"func":"static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,\n\n                              int buf_size)\n\n{\n\n    int start_found, i;\n\n    uint32_t state;\n\n    ParseContext *pc = &pc1->pc;\n\n\n\n    start_found = pc->frame_start_found;\n\n    state       = pc->state;\n\n\n\n    i = 0;\n\n    if (!start_found) {\n\n        for (i = 0; i < buf_size; i++) {\n\n            state = (state << 8) | buf[i];\n\n            if (IS_MARKER(state, i, buf, buf_size)) {\n\n                if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {\n\n                    start_found     = 1;\n\n                    pc1->lastmarker = state;\n\n                    i++;\n\n                    break;\n\n                }\n\n            }\n\n        }\n\n    }\n\n    if (start_found) {\n\n        for (; i < buf_size; i++) {\n\n            pc1->size++;\n\n            state = (state << 8) | buf[i];\n\n            if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos)\n\n                pc1->hd_pos = pc1->size;\n\n            if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {\n\n                if (pc1->framesize > pc1->size)\n\n                    continue;\n\n                pc->frame_start_found = 0;\n\n                pc->state             = -1;\n\n                pc1->size             = 0;\n\n                return i - 3;\n\n            }\n\n        }\n\n    }\n\n    pc->frame_start_found = start_found;\n\n    pc->state             = state;\n\n    return END_NOT_FOUND;\n\n}\n","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":55954,"func":"apr_byte_t oidc_cache_mutex_destroy(server_rec *s, oidc_cache_mutex_t *m) {\n\n\tapr_status_t rv = APR_SUCCESS;\n\n\t\/\/ oidc_sdebug(s, \"enter: %d (m=%pp,s=%pp, p=%d)\", (m && m->sema) ? *m->sema : -1, m->mutex ? m->mutex : 0, s, m->is_parent);\n\n\tif (m->mutex != NULL) {\n\n\t\tapr_global_mutex_lock(m->mutex);\n\t\t(*m->sema)--;\n\t\t\/\/oidc_sdebug(s, \"semaphore: %d (m=%pp,s=%pp)\", *m->sema, m->mutex, s);\n\n\t\t\/\/ oidc_sdebug(s, \"processing: %d (m=%pp,s=%pp, p=%d)\", (m && m->sema) ? *m->sema : -1, m->mutex ? m->mutex : 0, s, m->is_parent);\n\n\t\tif ((m->shm != NULL) && (*m->sema == 0)) {\n\n\t\t\trv = apr_shm_destroy(m->shm);\n\t\t\toidc_sdebug(s, \"apr_shm_destroy for semaphore returned: %d\", rv);\n\t\t\tm->shm = NULL;\n\n\t\t\tapr_global_mutex_unlock(m->mutex);\n\n\t\t\trv = apr_global_mutex_destroy(m->mutex);\n\t\t\toidc_sdebug(s, \"apr_global_mutex_destroy returned :%d\", rv);\n\t\t\tm->mutex = NULL;\n\n\t\t\trv = APR_SUCCESS;\n\n\t\t} else {\n\n\t\t\tapr_global_mutex_unlock(m->mutex);\n\n\t\t}\n\t}\n\n\treturn rv;\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":482126,"func":"static void xennet_alloc_rx_buffers(struct netfront_queue *queue)\n{\n\tRING_IDX req_prod = queue->rx.req_prod_pvt;\n\tint notify;\n\tint err = 0;\n\n\tif (unlikely(!netif_carrier_ok(queue->info->netdev)))\n\t\treturn;\n\n\tfor (req_prod = queue->rx.req_prod_pvt;\n\t     req_prod - queue->rx.rsp_cons < NET_RX_RING_SIZE;\n\t     req_prod++) {\n\t\tstruct sk_buff *skb;\n\t\tunsigned short id;\n\t\tgrant_ref_t ref;\n\t\tstruct page *page;\n\t\tstruct xen_netif_rx_request *req;\n\n\t\tskb = xennet_alloc_one_rx_buffer(queue);\n\t\tif (!skb) {\n\t\t\terr = -ENOMEM;\n\t\t\tbreak;\n\t\t}\n\n\t\tid = xennet_rxidx(req_prod);\n\n\t\tBUG_ON(queue->rx_skbs[id]);\n\t\tqueue->rx_skbs[id] = skb;\n\n\t\tref = gnttab_claim_grant_reference(&queue->gref_rx_head);\n\t\tWARN_ON_ONCE(IS_ERR_VALUE((unsigned long)(int)ref));\n\t\tqueue->grant_rx_ref[id] = ref;\n\n\t\tpage = skb_frag_page(&skb_shinfo(skb)->frags[0]);\n\n\t\treq = RING_GET_REQUEST(&queue->rx, req_prod);\n\t\tgnttab_page_grant_foreign_access_ref_one(ref,\n\t\t\t\t\t\t\t queue->info->xbdev->otherend_id,\n\t\t\t\t\t\t\t page,\n\t\t\t\t\t\t\t 0);\n\t\treq->id = id;\n\t\treq->gref = ref;\n\t}\n\n\tqueue->rx.req_prod_pvt = req_prod;\n\n\t\/* Try again later if there are not enough requests or skb allocation\n\t * failed.\n\t * Enough requests is quantified as the sum of newly created slots and\n\t * the unconsumed slots at the backend.\n\t *\/\n\tif (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN ||\n\t    unlikely(err)) {\n\t\tmod_timer(&queue->rx_refill_timer, jiffies + (HZ\/10));\n\t\treturn;\n\t}\n\n\tRING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->rx, notify);\n\tif (notify)\n\t\tnotify_remote_via_irq(queue->rx_irq);\n}","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":150192,"func":"static void airo_print_status(const char *devname, u16 status)\n{\n\tu8 reason = status & 0xFF;\n\n\tswitch (status & 0xFF00) {\n\tcase STAT_NOBEACON:\n\t\tswitch (status) {\n\t\tcase STAT_NOBEACON:\n\t\t\tairo_print_dbg(devname, \"link lost (missed beacons)\");\n\t\t\tbreak;\n\t\tcase STAT_MAXRETRIES:\n\t\tcase STAT_MAXARL:\n\t\t\tairo_print_dbg(devname, \"link lost (max retries)\");\n\t\t\tbreak;\n\t\tcase STAT_FORCELOSS:\n\t\t\tairo_print_dbg(devname, \"link lost (local choice)\");\n\t\t\tbreak;\n\t\tcase STAT_TSFSYNC:\n\t\t\tairo_print_dbg(devname, \"link lost (TSF sync lost)\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tairo_print_dbg(devname, \"unknow status %x\\n\", status);\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tcase STAT_DEAUTH:\n\t\tairo_print_dbg(devname, \"deauthenticated (reason: %d)\", reason);\n\t\tbreak;\n\tcase STAT_DISASSOC:\n\t\tairo_print_dbg(devname, \"disassociated (reason: %d)\", reason);\n\t\tbreak;\n\tcase STAT_ASSOC_FAIL:\n\t\tairo_print_dbg(devname, \"association failed (reason: %d)\",\n\t\t\t       reason);\n\t\tbreak;\n\tcase STAT_AUTH_FAIL:\n\t\tairo_print_dbg(devname, \"authentication failed (reason: %d)\",\n\t\t\t       reason);\n\t\tbreak;\n\tcase STAT_ASSOC:\n\tcase STAT_REASSOC:\n\t\tbreak;\n\tdefault:\n\t\tairo_print_dbg(devname, \"unknow status %x\\n\", status);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":123195,"func":"static MagickBooleanType ReadPSDChannelPixels(Image *image,\n  const size_t channels,const size_t row,const ssize_t type,\n  const unsigned char *pixels,ExceptionInfo *exception)\n{\n  Quantum\n    pixel;\n\n  register const unsigned char\n    *p;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    x;\n\n  size_t\n    packet_size;\n\n  unsigned short\n    nibble;\n\n  p=pixels;\n  q=GetAuthenticPixels(image,0,row,image->columns,1,exception);\n  if (q == (Quantum *) NULL)\n    return MagickFalse;\n  packet_size=GetPSDPacketSize(image);\n  for (x=0; x < (ssize_t) image->columns; x++)\n  {\n    if (packet_size == 1)\n      pixel=ScaleCharToQuantum(*p++);\n    else\n      {\n        p=PushShortPixel(MSBEndian,p,&nibble);\n        pixel=ScaleShortToQuantum(nibble);\n      }\n    switch (type)\n    {\n      case -1:\n      {\n        SetPixelAlpha(image,pixel,q);\n        break;\n      }\n      case -2:\n      case 0:\n      {\n        SetPixelRed(image,pixel,q);\n        if (channels == 1 || type == -2)\n          SetPixelGray(image,pixel,q);\n        if (image->storage_class == PseudoClass)\n          {\n            if (packet_size == 1)\n              SetPixelIndex(image,ScaleQuantumToChar(pixel),q);\n            else\n              SetPixelIndex(image,ScaleQuantumToShort(pixel),q);\n            SetPixelViaPixelInfo(image,image->colormap+(ssize_t)\n              ConstrainColormapIndex(image,GetPixelIndex(image,q),exception),q);\n            if (image->depth == 1)\n              {\n                ssize_t\n                  bit,\n                  number_bits;\n  \n                number_bits=image->columns-x;\n                if (number_bits > 8)\n                  number_bits=8;\n                for (bit=0; bit < number_bits; bit++)\n                {\n                  SetPixelIndex(image,(((unsigned char) pixel) &\n                    (0x01 << (7-bit))) != 0 ? 0 : 255,q);\n                  SetPixelViaPixelInfo(image,image->colormap+(ssize_t)\n                    ConstrainColormapIndex(image,GetPixelIndex(image,q),\n                      exception),q);\n                  q+=GetPixelChannels(image);\n                  x++;\n                }\n                x--;\n                continue;\n              }\n          }\n        break;\n      }\n      case 1:\n      {\n        if (image->storage_class == PseudoClass)\n          SetPixelAlpha(image,pixel,q);\n        else\n          SetPixelGreen(image,pixel,q);\n        break;\n      }\n      case 2:\n      {\n        if (image->storage_class == PseudoClass)\n          SetPixelAlpha(image,pixel,q);\n        else\n          SetPixelBlue(image,pixel,q);\n        break;\n      }\n      case 3:\n      {\n        if (image->colorspace == CMYKColorspace)\n          SetPixelBlack(image,pixel,q);\n        else\n          if (image->alpha_trait != UndefinedPixelTrait)\n            SetPixelAlpha(image,pixel,q);\n        break;\n      }\n      case 4:\n      {\n        if ((IssRGBCompatibleColorspace(image->colorspace) != MagickFalse) &&\n            (channels > 3))\n          break;\n        if (image->alpha_trait != UndefinedPixelTrait)\n          SetPixelAlpha(image,pixel,q);\n        break;\n      }\n      default:\n        break;\n    }\n    q+=GetPixelChannels(image);\n  }\n  return(SyncAuthenticPixels(image,exception));\n}","target":0,"code_token_length":774,"total_token_length":1010,"max_tokens_setting":1024}
+{"idx":368858,"func":"void disconnect_server(PgSocket *server, bool notify, const char *reason, ...)\n{\n\tPgPool *pool = server->pool;\n\tPgSocket *client;\n\tstatic const uint8_t pkt_term[] = {'X', 0,0,0,4};\n\tint send_term = 1;\n\tusec_t now = get_cached_time();\n\tchar buf[128];\n\tva_list ap;\n\n\tva_start(ap, reason);\n\tvsnprintf(buf, sizeof(buf), reason, ap);\n\tva_end(ap);\n\treason = buf;\n\n\tif (cf_log_disconnections)\n\t\tslog_info(server, \"closing because: %s (age=%\" PRIu64 \")\", reason,\n\t\t\t  (now - server->connect_time) \/ USEC);\n\n\tswitch (server->state) {\n\tcase SV_ACTIVE:\n\t\tclient = server->link;\n\t\tif (client) {\n\t\t\tclient->link = NULL;\n\t\t\tserver->link = NULL;\n\t\t\tdisconnect_client(client, true, \"%s\", reason);\n\t\t}\n\t\tbreak;\n\tcase SV_TESTED:\n\tcase SV_USED:\n\tcase SV_IDLE:\n\t\tbreak;\n\tcase SV_LOGIN:\n\t\t\/*\n\t\t * usually disconnect means problems in startup phase,\n\t\t * except when sending cancel packet\n\t\t *\/\n\t\tif (!server->ready)\n\t\t\tpool->last_connect_failed = 1;\n\t\telse\n\t\t\tsend_term = 0;\n\t\tbreak;\n\tdefault:\n\t\tfatal(\"disconnect_server: bad server state (%d)\", server->state);\n\t}\n\n\tAssert(server->link == NULL);\n\n\t\/* notify server and close connection *\/\n\tif (send_term && notify) {\n\t\tif (!sbuf_answer(&server->sbuf, pkt_term, sizeof(pkt_term)))\n\t\t\t\/* ignore result *\/\n\t\t\tnotify = false;\n\t}\n\n\tif (server->dns_token) {\n\t\tadns_cancel(adns, server->dns_token);\n\t\tserver->dns_token = NULL;\n\t}\n\n\tchange_server_state(server, SV_JUSTFREE);\n\tif (!sbuf_close(&server->sbuf))\n\t\tlog_noise(\"sbuf_close failed, retry later\");\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":395805,"func":"gs_setdefaultgrayicc(const gs_gstate * pgs, gs_param_string * pval)\n{\n    int code;\n    char *pname;\n    int namelen = (pval->size)+1;\n    gs_memory_t *mem = pgs->memory;\n    bool not_initialized;\n\n    \/* Detect if this is our first time in here.  If so, then we need to\n       reset up the default gray color spaces that are in the graphic state\n       to be ICC based.  It was not possible to do it until after we get\n       the profile *\/\n    not_initialized = (pgs->icc_manager->default_gray == NULL);\n\n    pname = (char *)gs_alloc_bytes(mem, namelen,\n                             \"set_default_gray_icc\");\n    if (pname == NULL)\n        return_error(gs_error_VMerror);\n    memcpy(pname,pval->data,namelen-1);\n    pname[namelen-1] = 0;\n    code = gsicc_set_profile(pgs->icc_manager,\n        (const char*) pname, namelen, DEFAULT_GRAY);\n    gs_free_object(mem, pname,\n        \"set_default_gray_icc\");\n    if (code < 0)\n        return gs_throw(code, \"cannot find default gray icc profile\");\n    \/* if this is our first time in here then we need to properly install the\n       color spaces that were initialized in the graphic state at this time *\/\n    if (not_initialized) {\n        code = gsicc_init_gs_colors((gs_gstate*) pgs);\n    }\n    if (code < 0)\n        return gs_throw(code, \"error initializing gstate color spaces to icc\");\n    return code;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":79383,"func":"do_local_notify(xmlNode * notify_src, const char *client_id,\n                gboolean sync_reply, gboolean from_peer)\n{\n    \/* send callback to originating child *\/\n    cib_client_t *client_obj = NULL;\n    int local_rc = pcmk_ok;\n\n    if (client_id != NULL) {\n        client_obj = g_hash_table_lookup(client_list, client_id);\n    } else {\n        crm_trace(\"No client to sent the response to. F_CIB_CLIENTID not set.\");\n    }\n\n    if (client_obj == NULL) {\n        local_rc = -ECONNRESET;\n\n    } else {\n        int rid = 0;\n\n        if(sync_reply) {\n            if (client_obj->ipc) {\n                CRM_LOG_ASSERT(client_obj->request_id);\n\n                rid = client_obj->request_id;\n                client_obj->request_id = 0;\n\n                crm_trace(\"Sending response %d to %s %s\",\n                      rid, client_obj->name, from_peer?\"(originator of delegated request)\":\"\");\n            } else {\n                crm_trace(\"Sending response to %s %s\",\n                      client_obj->name, from_peer?\"(originator of delegated request)\":\"\");\n            }\n\n        } else {\n            crm_trace(\"Sending an event to %s %s\",\n                      client_obj->name, from_peer?\"(originator of delegated request)\":\"\");\n        }\n\n        if (client_obj->ipc && crm_ipcs_send(client_obj->ipc, rid, notify_src, !sync_reply) < 0) {\n            local_rc = -ENOMSG;\n\n#ifdef HAVE_GNUTLS_GNUTLS_H\n        } else if (client_obj->session) {\n            crm_send_remote_msg(client_obj->session, notify_src, client_obj->encrypted);\n#endif\n        } else if(client_obj->ipc == NULL) {\n            crm_err(\"Unknown transport for %s\", client_obj->name);\n        }\n    }\n\n    if (local_rc != pcmk_ok && client_obj != NULL) {\n        crm_warn(\"%sSync reply to %s failed: %s\",\n                 sync_reply ? \"\" : \"A-\",\n                 client_obj ? client_obj->name : \"<unknown>\", pcmk_strerror(local_rc));\n    }\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":401103,"func":"static void cirrus_get_offsets(VGACommonState *s1,\n                               uint32_t *pline_offset,\n                               uint32_t *pstart_addr,\n                               uint32_t *pline_compare)\n{\n    CirrusVGAState * s = container_of(s1, CirrusVGAState, vga);\n    uint32_t start_addr, line_offset, line_compare;\n\n    line_offset = s->vga.cr[0x13]\n\t| ((s->vga.cr[0x1b] & 0x10) << 4);\n    line_offset <<= 3;\n    *pline_offset = line_offset;\n\n    start_addr = (s->vga.cr[0x0c] << 8)\n\t| s->vga.cr[0x0d]\n\t| ((s->vga.cr[0x1b] & 0x01) << 16)\n\t| ((s->vga.cr[0x1b] & 0x0c) << 15)\n\t| ((s->vga.cr[0x1d] & 0x80) << 12);\n    *pstart_addr = start_addr;\n\n    line_compare = s->vga.cr[0x18] |\n        ((s->vga.cr[0x07] & 0x10) << 4) |\n        ((s->vga.cr[0x09] & 0x40) << 3);\n    *pline_compare = line_compare;\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":415665,"func":"char *ip4_string(char *p, const u8 *addr, const char *fmt)\n{\n\tint i;\n\tbool leading_zeros = (fmt[0] == 'i');\n\tint index;\n\tint step;\n\n\tswitch (fmt[2]) {\n\tcase 'h':\n#ifdef __BIG_ENDIAN\n\t\tindex = 0;\n\t\tstep = 1;\n#else\n\t\tindex = 3;\n\t\tstep = -1;\n#endif\n\t\tbreak;\n\tcase 'l':\n\t\tindex = 3;\n\t\tstep = -1;\n\t\tbreak;\n\tcase 'n':\n\tcase 'b':\n\tdefault:\n\t\tindex = 0;\n\t\tstep = 1;\n\t\tbreak;\n\t}\n\tfor (i = 0; i < 4; i++) {\n\t\tchar temp[4] __aligned(2);\t\/* hold each IP quad in reverse order *\/\n\t\tint digits = put_dec_trunc8(temp, addr[index]) - temp;\n\t\tif (leading_zeros) {\n\t\t\tif (digits < 3)\n\t\t\t\t*p++ = '0';\n\t\t\tif (digits < 2)\n\t\t\t\t*p++ = '0';\n\t\t}\n\t\t\/* reverse the digits in the quad *\/\n\t\twhile (digits--)\n\t\t\t*p++ = temp[digits];\n\t\tif (i < 3)\n\t\t\t*p++ = '.';\n\t\tindex += step;\n\t}\n\t*p = '\\0';\n\n\treturn p;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":151432,"func":"static void airo_handle_tx(struct airo_info *ai, u16 status)\n{\n\tint i, len = 0, index = -1;\n\tu16 fid;\n\n\tif (test_bit(FLAG_MPI, &ai->flags)) {\n\t\tunsigned long flags;\n\n\t\tif (status & EV_TXEXC)\n\t\t\tget_tx_error(ai, -1);\n\n\t\tspin_lock_irqsave(&ai->aux_lock, flags);\n\t\tif (!skb_queue_empty(&ai->txq)) {\n\t\t\tspin_unlock_irqrestore(&ai->aux_lock,flags);\n\t\t\tmpi_send_packet(ai->dev);\n\t\t} else {\n\t\t\tclear_bit(FLAG_PENDING_XMIT, &ai->flags);\n\t\t\tspin_unlock_irqrestore(&ai->aux_lock,flags);\n\t\t\tnetif_wake_queue(ai->dev);\n\t\t}\n\t\tOUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC));\n\t\treturn;\n\t}\n\n\tfid = IN4500(ai, TXCOMPLFID);\n\n\tfor(i = 0; i < MAX_FIDS; i++) {\n\t\tif ((ai->fids[i] & 0xffff) == fid) {\n\t\t\tlen = ai->fids[i] >> 16;\n\t\t\tindex = i;\n\t\t}\n\t}\n\n\tif (index != -1) {\n\t\tif (status & EV_TXEXC)\n\t\t\tget_tx_error(ai, index);\n\n\t\tOUT4500(ai, EVACK, status & (EV_TX | EV_TXEXC));\n\n\t\t\/* Set up to be used again *\/\n\t\tai->fids[index] &= 0xffff;\n\t\tif (index < MAX_FIDS \/ 2) {\n\t\t\tif (!test_bit(FLAG_PENDING_XMIT, &ai->flags))\n\t\t\t\tnetif_wake_queue(ai->dev);\n\t\t} else {\n\t\t\tif (!test_bit(FLAG_PENDING_XMIT11, &ai->flags))\n\t\t\t\tnetif_wake_queue(ai->wifidev);\n\t\t}\n\t} else {\n\t\tOUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC));\n\t\tairo_print_err(ai->dev->name, \"Unallocated FID was used to xmit\");\n\t}\n}","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":55193,"func":"static void lo_getlk(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi,\n                     struct flock *lock)\n{\n    struct lo_data *lo = lo_data(req);\n    struct lo_inode *inode;\n    struct lo_inode_plock *plock;\n    int ret, saverr = 0;\n\n    fuse_log(FUSE_LOG_DEBUG,\n             \"lo_getlk(ino=%\" PRIu64 \", flags=%d)\"\n             \" owner=0x%lx, l_type=%d l_start=0x%lx\"\n             \" l_len=0x%lx\\n\",\n             ino, fi->flags, fi->lock_owner, lock->l_type, lock->l_start,\n             lock->l_len);\n\n    inode = lo_inode(req, ino);\n    if (!inode) {\n        fuse_reply_err(req, EBADF);\n        return;\n    }\n\n    pthread_mutex_lock(&inode->plock_mutex);\n    plock =\n        lookup_create_plock_ctx(lo, inode, fi->lock_owner, lock->l_pid, &ret);\n    if (!plock) {\n        saverr = ret;\n        goto out;\n    }\n\n    ret = fcntl(plock->fd, F_OFD_GETLK, lock);\n    if (ret == -1) {\n        saverr = errno;\n    }\n\nout:\n    pthread_mutex_unlock(&inode->plock_mutex);\n    lo_inode_put(lo, &inode);\n\n    if (saverr) {\n        fuse_reply_err(req, saverr);\n    } else {\n        fuse_reply_lock(req, lock);\n    }\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":520307,"func":"int Item_param::save_in_field(Field *field, bool no_conversions)\n{\n  field->set_notnull();\n\n  \/*\n    There's no \"default\" intentionally, to make compiler complain\n    when adding a new XXX_VALUE value.\n    Garbage (e.g. in case of a memory overrun) is handled after the switch.\n  *\/\n  switch (state) {\n  case INT_VALUE:\n    return field->store(value.integer, unsigned_flag);\n  case REAL_VALUE:\n    return field->store(value.real);\n  case DECIMAL_VALUE:\n    return field->store_decimal(&decimal_value);\n  case TIME_VALUE:\n    field->store_time_dec(&value.time, decimals);\n    return 0;\n  case STRING_VALUE:\n  case LONG_DATA_VALUE:\n    return field->store(str_value.ptr(), str_value.length(),\n                        str_value.charset());\n  case NULL_VALUE:\n    return set_field_to_null_with_conversions(field, no_conversions);\n  case DEFAULT_VALUE:\n    return field->save_in_field_default_value(field->table->pos_in_table_list->\n                                              top_table() !=\n                                              field->table->pos_in_table_list);\n  case IGNORE_VALUE:\n    return field->save_in_field_ignore_value(field->table->pos_in_table_list->\n                                             top_table() !=\n                                             field->table->pos_in_table_list);\n  case NO_VALUE:\n    DBUG_ASSERT(0); \/\/ Should not be possible\n    return true;\n  }\n  DBUG_ASSERT(0); \/\/ Garbage\n  return 1;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":508288,"func":"static int check_purpose(X509_STORE_CTX *ctx, X509 *x, int purpose, int depth,\n                         int must_be_ca)\n{\n    int tr_ok = X509_TRUST_UNTRUSTED;\n\n    \/*\n     * For trusted certificates we want to see whether any auxiliary trust\n     * settings trump the purpose constraints.\n     *\n     * This is complicated by the fact that the trust ordinals in\n     * ctx->param->trust are entirely independent of the purpose ordinals in\n     * ctx->param->purpose!\n     *\n     * What connects them is their mutual initialization via calls from\n     * X509_STORE_CTX_set_default() into X509_VERIFY_PARAM_lookup() which sets\n     * related values of both param->trust and param->purpose.  It is however\n     * typically possible to infer associated trust values from a purpose value\n     * via the X509_PURPOSE API.\n     *\n     * Therefore, we can only check for trust overrides when the purpose we're\n     * checking is the same as ctx->param->purpose and ctx->param->trust is\n     * also set.\n     *\/\n    if (depth >= ctx->num_untrusted && purpose == ctx->param->purpose)\n        tr_ok = X509_check_trust(x, ctx->param->trust, X509_TRUST_NO_SS_COMPAT);\n\n    switch (tr_ok) {\n    case X509_TRUST_TRUSTED:\n        return 1;\n    case X509_TRUST_REJECTED:\n        break;\n    default:\n        switch (X509_check_purpose(x, purpose, must_be_ca > 0)) {\n        case 1:\n            return 1;\n        case 0:\n            break;\n        default:\n            if ((ctx->param->flags & X509_V_FLAG_X509_STRICT) == 0)\n                return 1;\n        }\n        break;\n    }\n\n    ctx->error = X509_V_ERR_INVALID_PURPOSE;\n    ctx->error_depth = depth;\n    ctx->current_cert = x;\n    return ctx->verify_cb(0, ctx);\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":462104,"func":"static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp)\n{\n    char *mac, *nd_id;\n    int idx, ret;\n    NICInfo *ni;\n    const char *type;\n\n    type = qemu_opt_get(opts, \"type\");\n    if (type && g_str_equal(type, \"none\")) {\n        return 0;    \/* Nothing to do, default_net is cleared in vl.c *\/\n    }\n\n    idx = nic_get_free_idx();\n    if (idx == -1 || nb_nics >= MAX_NICS) {\n        error_setg(errp, \"no more on-board\/default NIC slots available\");\n        return -1;\n    }\n\n    if (!type) {\n        qemu_opt_set(opts, \"type\", \"user\", &error_abort);\n    }\n\n    ni = &nd_table[idx];\n    memset(ni, 0, sizeof(*ni));\n    ni->model = qemu_opt_get_del(opts, \"model\");\n\n    \/* Create an ID if the user did not specify one *\/\n    nd_id = g_strdup(qemu_opts_id(opts));\n    if (!nd_id) {\n        nd_id = id_generate(ID_NET);\n        qemu_opts_set_id(opts, nd_id);\n    }\n\n    \/* Handle MAC address *\/\n    mac = qemu_opt_get_del(opts, \"mac\");\n    if (mac) {\n        ret = net_parse_macaddr(ni->macaddr.a, mac);\n        g_free(mac);\n        if (ret) {\n            error_setg(errp, \"invalid syntax for ethernet address\");\n            goto out;\n        }\n        if (is_multicast_ether_addr(ni->macaddr.a)) {\n            error_setg(errp, \"NIC cannot have multicast MAC address\");\n            ret = -1;\n            goto out;\n        }\n    }\n    qemu_macaddr_default_if_unset(&ni->macaddr);\n\n    ret = net_client_init(opts, true, errp);\n    if (ret == 0) {\n        ni->netdev = qemu_find_netdev(nd_id);\n        ni->used = true;\n        nb_nics++;\n    }\n\nout:\n    g_free(nd_id);\n    return ret;\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":229475,"func":"void gdImagePaletteCopy (gdImagePtr to, gdImagePtr from)\n{\n\tint i;\n\tint x, y, p;\n\tint xlate[256];\n\tif (to->trueColor || from->trueColor) {\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < 256; i++) {\n\t\txlate[i] = -1;\n\t}\n\n\tfor (y = 0; y < to->sy; y++) {\n\t\tfor (x = 0; x < to->sx; x++) {\n\t\t\tp = gdImageGetPixel(to, x, y);\n\t\t\tif (xlate[p] == -1) {\n\t\t\t\t\/* This ought to use HWB, but we don't have an alpha-aware version of that yet. *\/\n\t\t\t\txlate[p] = gdImageColorClosestAlpha (from, to->red[p], to->green[p], to->blue[p], to->alpha[p]);\n\t\t\t}\n\t\t\tgdImageSetPixel(to, x, y, xlate[p]);\n\t\t}\n\t}\n\n\tfor (i = 0; i < from->colorsTotal; i++) {\n\t\tto->red[i] = from->red[i];\n\t\tto->blue[i] = from->blue[i];\n\t\tto->green[i] = from->green[i];\n\t\tto->alpha[i] = from->alpha[i];\n\t\tto->open[i] = 0;\n\t}\n\n\tfor (i = from->colorsTotal; i < to->colorsTotal; i++) {\n\t\tto->open[i] = 1;\n\t}\n\n\tto->colorsTotal = from->colorsTotal;\n}\n","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":329371,"func":"static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)\n\n{\n\n    if(st->codec->codec_id == CODEC_ID_PROBE){\n\n        AVProbeData *pd = &st->probe_data;\n\n        av_log(s, AV_LOG_DEBUG, \"probing stream %d\\n\", st->index);\n\n        --st->probe_packets;\n\n\n\n        pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);\n\n        memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);\n\n        pd->buf_size += pkt->size;\n\n        memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);\n\n\n\n        if(av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){\n\n            \/\/FIXME we do not reduce score to 0 for the case of running out of buffer space in bytes\n\n            set_codec_from_probe_data(s, st, pd, st->probe_packets > 0 ? AVPROBE_SCORE_MAX\/4 : 0);\n\n            if(st->codec->codec_id != CODEC_ID_PROBE){\n\n                pd->buf_size=0;\n\n                av_freep(&pd->buf);\n\n                av_log(s, AV_LOG_DEBUG, \"probed stream %d\\n\", st->index);\n\n            }\n\n        }\n\n    }\n\n}\n","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":161893,"func":"  void generate_connection() {\n    Mutex::Locker l(lock);\n    if (!can_create_connection())\n      return ;\n\n    Messenger *server, *client;\n    {\n      boost::uniform_int<> choose(0, available_servers.size() - 1);\n      int index = choose(rng);\n      set<Messenger*>::iterator i = available_servers.begin();\n      for (; index > 0; --index, ++i) ;\n      server = *i;\n    }\n    {\n      boost::uniform_int<> choose(0, available_clients.size() - 1);\n      int index = choose(rng);\n      set<Messenger*>::iterator i = available_clients.begin();\n      for (; index > 0; --index, ++i) ;\n      client = *i;\n    }\n\n    pair<Messenger*, Messenger*> p;\n    {\n      boost::uniform_int<> choose(0, available_servers.size() - 1);\n      if (server->get_default_policy().server) {\n        p = make_pair(client, server);\n      } else {\n        ConnectionRef conn = client->get_connection(server->get_myinst());\n        if (available_connections.count(conn) || choose(rng) % 2)\n          p = make_pair(client, server);\n        else\n          p = make_pair(server, client);\n      }\n    }\n    ConnectionRef conn = p.first->get_connection(p.second->get_myinst());\n    available_connections[conn] = p;\n  }","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":336749,"func":"static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,\n\n                                  uint32_t size)\n\n{\n\n    Hnm4VideoContext *hnm = avctx->priv_data;\n\n    GetByteContext gb;\n\n    uint32_t writeoffset = 0, offset;\n\n    uint8_t tag, count, previous, delta;\n\n\n\n    bytestream2_init(&gb, src, size);\n\n\n\n    while (bytestream2_tell(&gb) < size) {\n\n        count = bytestream2_peek_byte(&gb) & 0x3F;\n\n        if (count == 0) {\n\n            tag = bytestream2_get_byte(&gb) & 0xC0;\n\n            tag = tag >> 6;\n\n            if (tag == 0) {\n\n                writeoffset += bytestream2_get_byte(&gb);\n\n            } else if (tag == 1) {\n\n                if (writeoffset + hnm->width >= hnm->width * hnm->height) {\n\n                    av_log(avctx, AV_LOG_ERROR, \"writeoffset out of bounds\\n\");\n\n                    break;\n\n                }\n\n                hnm->current[writeoffset]              = bytestream2_get_byte(&gb);\n\n                hnm->current[writeoffset + hnm->width] = bytestream2_get_byte(&gb);\n\n                writeoffset++;\n\n            } else if (tag == 2) {\n\n                writeoffset += hnm->width;\n\n            } else if (tag == 3) {\n\n                break;\n\n            }\n\n            if (writeoffset > hnm->width * hnm->height) {\n\n                av_log(avctx, AV_LOG_ERROR, \"writeoffset out of bounds\\n\");\n\n                break;\n\n            }\n\n        } else {\n\n            delta    = bytestream2_peek_byte(&gb) & 0x80;\n\n            previous = bytestream2_peek_byte(&gb) & 0x40;\n\n            bytestream2_skip(&gb, 1);\n\n\n\n            offset  = writeoffset;\n\n            offset += bytestream2_get_le16(&gb);\n\n\n\n            if (delta)\n\n                offset -= 0x10000;\n\n\n\n            if (offset + hnm->width + count >= hnm->width * hnm->height) {\n\n                av_log(avctx, AV_LOG_ERROR, \"Attempting to read out of bounds\\n\");\n\n                break;\n\n            } else if (writeoffset + hnm->width + count >= hnm->width * hnm->height) {\n\n                av_log(avctx, AV_LOG_ERROR, \"Attempting to write out of bounds\\n\");\n\n                break;\n\n            }\n\n\n\n            if (previous) {\n\n                while (count > 0) {\n\n                    hnm->current[writeoffset]              = hnm->previous[offset];\n\n                    hnm->current[writeoffset + hnm->width] = hnm->previous[offset + hnm->width];\n\n                    writeoffset++;\n\n                    offset++;\n\n                    count--;\n\n                }\n\n            } else {\n\n                while (count > 0) {\n\n                    hnm->current[writeoffset]              = hnm->current[offset];\n\n                    hnm->current[writeoffset + hnm->width] = hnm->current[offset + hnm->width];\n\n                    writeoffset++;\n\n                    offset++;\n\n                    count--;\n\n                }\n\n            }\n\n        }\n\n    }\n\n}\n","target":0,"code_token_length":698,"total_token_length":934,"max_tokens_setting":1024}
+{"idx":43871,"func":"static inline struct uffd_msg userfault_msg(unsigned long address,\n\t\t\t\t\t    unsigned int flags,\n\t\t\t\t\t    unsigned long reason,\n\t\t\t\t\t    unsigned int features)\n{\n\tstruct uffd_msg msg;\n\tmsg_init(&msg);\n\tmsg.event = UFFD_EVENT_PAGEFAULT;\n\tmsg.arg.pagefault.address = address;\n\tif (flags & FAULT_FLAG_WRITE)\n\t\t\/*\n\t\t * If UFFD_FEATURE_PAGEFAULT_FLAG_WP was set in the\n\t\t * uffdio_api.features and UFFD_PAGEFAULT_FLAG_WRITE\n\t\t * was not set in a UFFD_EVENT_PAGEFAULT, it means it\n\t\t * was a read fault, otherwise if set it means it's\n\t\t * a write fault.\n\t\t *\/\n\t\tmsg.arg.pagefault.flags |= UFFD_PAGEFAULT_FLAG_WRITE;\n\tif (reason & VM_UFFD_WP)\n\t\t\/*\n\t\t * If UFFD_FEATURE_PAGEFAULT_FLAG_WP was set in the\n\t\t * uffdio_api.features and UFFD_PAGEFAULT_FLAG_WP was\n\t\t * not set in a UFFD_EVENT_PAGEFAULT, it means it was\n\t\t * a missing fault, otherwise if set it means it's a\n\t\t * write protect fault.\n\t\t *\/\n\t\tmsg.arg.pagefault.flags |= UFFD_PAGEFAULT_FLAG_WP;\n\tif (features & UFFD_FEATURE_THREAD_ID)\n\t\tmsg.arg.pagefault.feat.ptid = task_pid_vnr(current);\n\treturn msg;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":472757,"func":"static void chrc_write_cb(struct gatt_db_attribute *attrib,\n\t\t\t\t\tunsigned int id, uint16_t offset,\n\t\t\t\t\tconst uint8_t *value, size_t len,\n\t\t\t\t\tuint8_t opcode, struct bt_att *att,\n\t\t\t\t\tvoid *user_data)\n{\n\tstruct external_chrc *chrc = user_data;\n\tstruct btd_device *device;\n\tstruct queue *queue;\n\tDBusMessageIter iter;\n\n\tif (chrc->attrib != attrib) {\n\t\terror(\"Write callback called with incorrect attribute\");\n\t\tgoto fail;\n\t}\n\n\tdevice = att_get_device(att);\n\tif (!device) {\n\t\terror(\"Unable to find device object\");\n\t\tgoto fail;\n\t}\n\n\tif (!(chrc->props & BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP))\n\t\tqueue = chrc->pending_writes;\n\telse\n\t\tqueue = NULL;\n\n\tif (opcode == BT_ATT_OP_PREP_WRITE_REQ) {\n\t\tif (!device_is_trusted(device) && !chrc->prep_authorized &&\n\t\t\t\t\t\tchrc->req_prep_authorization)\n\t\t\tsend_write(att, attrib, chrc->proxy, queue,\n\t\t\t\t\tid, value, len, offset,\n\t\t\t\t\ttrue, true);\n\t\telse\n\t\t\tgatt_db_attribute_write_result(attrib, id, 0);\n\n\t\treturn;\n\t}\n\n\tif (opcode == BT_ATT_OP_EXEC_WRITE_REQ)\n\t\tchrc->prep_authorized = false;\n\n\tif (chrc->write_io) {\n\t\tif (sock_io_send(chrc->write_io, value, len) < 0) {\n\t\t\terror(\"Unable to write: %s\", strerror(errno));\n\t\t\tgoto fail;\n\t\t}\n\n\t\tgatt_db_attribute_write_result(attrib, id, 0);\n\t\treturn;\n\t}\n\n\tif (g_dbus_proxy_get_property(chrc->proxy, \"WriteAcquired\", &iter)) {\n\t\tif (acquire_write(chrc, att, attrib, id, value, len))\n\t\t\treturn;\n\t}\n\n\tif (send_write(att, attrib, chrc->proxy, queue, id, value, len,\n\t\t\toffset, false, false))\n\t\treturn;\n\nfail:\n\tgatt_db_attribute_write_result(attrib, id, BT_ATT_ERROR_UNLIKELY);\n}","target":0,"code_token_length":452,"total_token_length":688,"max_tokens_setting":1024}
+{"idx":168276,"func":"status_t NuPlayer::GenericSource::dequeueAccessUnit(\n bool audio, sp<ABuffer> *accessUnit) {\n Track *track = audio ? &mAudioTrack : &mVideoTrack;\n\n if (track->mSource == NULL) {\n return -EWOULDBLOCK;\n }\n\n if (mIsWidevine && !audio) {\n        postReadBuffer(MEDIA_TRACK_TYPE_VIDEO);\n }\n\n status_t finalResult;\n if (!track->mPackets->hasBufferAvailable(&finalResult)) {\n return (finalResult == OK ? -EWOULDBLOCK : finalResult);\n }\n\n status_t result = track->mPackets->dequeueAccessUnit(accessUnit);\n\n if (!track->mPackets->hasBufferAvailable(&finalResult)) {\n        postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO);\n }\n\n if (result != OK) {\n if (mSubtitleTrack.mSource != NULL) {\n            mSubtitleTrack.mPackets->clear();\n            mFetchSubtitleDataGeneration++;\n }\n if (mTimedTextTrack.mSource != NULL) {\n            mTimedTextTrack.mPackets->clear();\n            mFetchTimedTextDataGeneration++;\n }\n return result;\n }\n\n int64_t timeUs;\n status_t eosResult; \/\/ ignored\n    CHECK((*accessUnit)->meta()->findInt64(\"timeUs\", &timeUs));\n\n if (mSubtitleTrack.mSource != NULL\n && !mSubtitleTrack.mPackets->hasBufferAvailable(&eosResult)) {\n        sp<AMessage> msg = new AMessage(kWhatFetchSubtitleData, id());\n        msg->setInt64(\"timeUs\", timeUs);\n        msg->setInt32(\"generation\", mFetchSubtitleDataGeneration);\n        msg->post();\n }\n\n if (mTimedTextTrack.mSource != NULL\n && !mTimedTextTrack.mPackets->hasBufferAvailable(&eosResult)) {\n        sp<AMessage> msg = new AMessage(kWhatFetchTimedTextData, id());\n        msg->setInt64(\"timeUs\", timeUs);\n        msg->setInt32(\"generation\", mFetchTimedTextDataGeneration);\n        msg->post();\n }\n\n return result;\n}\n","target":0,"code_token_length":456,"total_token_length":692,"max_tokens_setting":1024}
+{"idx":297154,"func":"static void read_by_type_read_complete_cb(struct gatt_db_attribute *attr,\n\t\t\t\t\t\tint err, const uint8_t *value,\n\t\t\t\t\t\tsize_t len, void *user_data)\n{\n\tstruct async_read_op *op = user_data;\n\tstruct bt_gatt_server *server = op->server;\n\tuint16_t mtu;\n\tuint16_t handle;\n\n\tmtu = bt_att_get_mtu(server->att);\n\thandle = gatt_db_attribute_get_handle(attr);\n\n\t\/* Terminate the operation if there was an error *\/\n\tif (err) {\n\t\tbt_att_chan_send_error_rsp(op->chan, BT_ATT_OP_READ_BY_TYPE_REQ,\n\t\t\t\t\t\t\t\thandle, err);\n\t\tasync_read_op_destroy(op);\n\t\treturn;\n\t}\n\n\tif (op->pdu_len == 0) {\n\t\top->value_len = MIN(MIN((unsigned) mtu - 4, 253), len);\n\t\top->pdu[0] = op->value_len + 2;\n\t\top->pdu_len++;\n\t} else if (len != op->value_len) {\n\t\top->done = true;\n\t\tgoto done;\n\t}\n\n\t\/* Stop if this would surpass the MTU *\/\n\tif (op->pdu_len + op->value_len + 2 > (unsigned) mtu - 1) {\n\t\top->done = true;\n\t\tgoto done;\n\t}\n\n\t\/* Encode the current value *\/\n\tput_le16(handle, op->pdu + op->pdu_len);\n\tmemcpy(op->pdu + op->pdu_len + 2, value, op->value_len);\n\n\top->pdu_len += op->value_len + 2;\n\n\tif (op->pdu_len == (unsigned) mtu - 1)\n\t\top->done = true;\n\ndone:\n\tprocess_read_by_type(op);\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":327561,"func":"static void scoop_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)\n\n{\n\n    ScoopInfo *s = (ScoopInfo *) opaque;\n\n    value &= 0xffff;\n\n\n\n    switch (addr) {\n\n    case SCOOP_MCR:\n\n        s->mcr = value;\n\n        break;\n\n    case SCOOP_CDR:\n\n        s->cdr = value;\n\n        break;\n\n    case SCOOP_CPR:\n\n        s->power = value;\n\n        if (value & 0x80)\n\n            s->power |= 0x8040;\n\n        break;\n\n    case SCOOP_CCR:\n\n        s->ccr = value;\n\n        break;\n\n    case SCOOP_IRR_IRM:\n\n        s->irr = value;\n\n        break;\n\n    case SCOOP_IMR:\n\n        s->imr = value;\n\n        break;\n\n    case SCOOP_ISR:\n\n        s->isr = value;\n\n        break;\n\n    case SCOOP_GPCR:\n\n        s->gpio_dir = value;\n\n        scoop_gpio_handler_update(s);\n\n        break;\n\n    case SCOOP_GPWR:\n\n    case SCOOP_GPRR:\t\/* GPRR is probably R\/O in real HW *\/\n\n        s->gpio_level = value & s->gpio_dir;\n\n        scoop_gpio_handler_update(s);\n\n        break;\n\n    default:\n\n        zaurus_printf(\"Bad register offset \" REG_FMT \"\\n\", (unsigned long)addr);\n\n    }\n\n}\n","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":468201,"func":"calipso_opt_insert(struct ipv6_opt_hdr *hop,\n\t\t   const struct calipso_doi *doi_def,\n\t\t   const struct netlbl_lsm_secattr *secattr)\n{\n\tunsigned int start, end, buf_len, pad, hop_len;\n\tstruct ipv6_opt_hdr *new;\n\tint ret_val;\n\n\tif (hop) {\n\t\thop_len = ipv6_optlen(hop);\n\t\tret_val = calipso_opt_find(hop, &start, &end);\n\t\tif (ret_val && ret_val != -ENOENT)\n\t\t\treturn ERR_PTR(ret_val);\n\t} else {\n\t\thop_len = 0;\n\t\tstart = sizeof(*hop);\n\t\tend = 0;\n\t}\n\n\tbuf_len = hop_len + start - end + CALIPSO_OPT_LEN_MAX_WITH_PAD;\n\tnew = kzalloc(buf_len, GFP_ATOMIC);\n\tif (!new)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tif (start > sizeof(*hop))\n\t\tmemcpy(new, hop, start);\n\tret_val = calipso_genopt((unsigned char *)new, start, buf_len, doi_def,\n\t\t\t\t secattr);\n\tif (ret_val < 0) {\n\t\tkfree(new);\n\t\treturn ERR_PTR(ret_val);\n\t}\n\n\tbuf_len = start + ret_val;\n\t\/* At this point buf_len aligns to 4n, so (buf_len & 4) pads to 8n *\/\n\tpad = ((buf_len & 4) + (end & 7)) & 7;\n\tcalipso_pad_write((unsigned char *)new, buf_len, pad);\n\tbuf_len += pad;\n\n\tif (end != hop_len) {\n\t\tmemcpy((char *)new + buf_len, (char *)hop + end, hop_len - end);\n\t\tbuf_len += hop_len - end;\n\t}\n\tnew->nexthdr = 0;\n\tnew->hdrlen = buf_len \/ 8 - 1;\n\n\treturn new;\n}","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":464199,"func":"nm_utils_kernel_cmdline_match_check(const char *const *proc_cmdline,\n                                    const char *const *patterns,\n                                    guint              num_patterns,\n                                    GError **          error)\n{\n    gboolean has_optional     = FALSE;\n    gboolean has_any_optional = FALSE;\n    guint    i;\n\n    for (i = 0; i < num_patterns; i++) {\n        const char *element      = patterns[i];\n        gboolean    is_inverted  = FALSE;\n        gboolean    is_mandatory = FALSE;\n        gboolean    match;\n        const char *p;\n\n        _pattern_parse(element, &p, &is_inverted, &is_mandatory);\n\n        match = _kernel_cmdline_match(proc_cmdline, p);\n        if (is_inverted)\n            match = !match;\n\n        if (is_mandatory) {\n            if (!match) {\n                nm_utils_error_set(error,\n                                   NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,\n                                   \"device does not satisfy match.kernel-command-line property %s\",\n                                   patterns[i]);\n                return FALSE;\n            }\n        } else {\n            has_any_optional = TRUE;\n            if (match)\n                has_optional = TRUE;\n        }\n    }\n\n    if (!has_optional && has_any_optional) {\n        nm_utils_error_set(error,\n                           NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,\n                           \"device does not satisfy any match.kernel-command-line property\");\n        return FALSE;\n    }\n\n    return TRUE;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":26212,"func":"int ff_msmpeg4_decode_motion ( MpegEncContext * s , int * mx_ptr , int * my_ptr ) {\n MVTable * mv ;\n int code , mx , my ;\n mv = & ff_mv_tables [ s -> mv_table_index ] ;\n code = get_vlc2 ( & s -> gb , mv -> vlc . table , MV_VLC_BITS , 2 ) ;\n if ( code < 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"illegal MV code at %d %d\\n\" , s -> mb_x , s -> mb_y ) ;\n return - 1 ;\n }\n if ( code == mv -> n ) {\n mx = get_bits ( & s -> gb , 6 ) ;\n my = get_bits ( & s -> gb , 6 ) ;\n }\n else {\n mx = mv -> table_mvx [ code ] ;\n my = mv -> table_mvy [ code ] ;\n }\n mx += * mx_ptr - 32 ;\n my += * my_ptr - 32 ;\n if ( mx <= - 64 ) mx += 64 ;\n else if ( mx >= 64 ) mx -= 64 ;\n if ( my <= - 64 ) my += 64 ;\n else if ( my >= 64 ) my -= 64 ;\n * mx_ptr = mx ;\n * my_ptr = my ;\n return 0 ;\n }","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":36898,"func":"static gdImagePtr _gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, int *fmt, int *ncx, int *ncy, t_chunk_info ** cidx)\n{\n\tgdImagePtr im;\n\n\tif (_gd2GetHeader (in, sx, sy, cs, vers, fmt, ncx, ncy, cidx) != 1) {\n\t\tGD2_DBG(php_gd_error(\"Bad GD2 header\"));\n\t\tgoto fail1;\n\t}\n\n\tif (gd2_truecolor(*fmt)) {\n\t\tim = gdImageCreateTrueColor(*sx, *sy);\n\t} else {\n\t\tim = gdImageCreate(*sx, *sy);\n\t}\n\tif (im == NULL) {\n\t\tGD2_DBG(php_gd_error(\"Could not create gdImage\"));\n\t\tgoto fail1;\n\t}\n\n\tif (!_gdGetColors(in, im, (*vers) == 2)) {\n\t\tGD2_DBG(php_gd_error(\"Could not read color palette\"));\n\t\tgoto fail2;\n\t}\n\tGD2_DBG(php_gd_error(\"Image palette completed: %d colours\", im->colorsTotal));\n\n\treturn im;\n\nfail2:\n\tgdImageDestroy(im);\n\treturn 0;\n\nfail1:\n\treturn 0;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":374420,"func":"plpgsql_inline_handler(PG_FUNCTION_ARGS)\n{\n\tInlineCodeBlock *codeblock = (InlineCodeBlock *) DatumGetPointer(PG_GETARG_DATUM(0));\n\tPLpgSQL_function *func;\n\tFunctionCallInfoData fake_fcinfo;\n\tFmgrInfo\tflinfo;\n\tEState\t   *simple_eval_estate;\n\tDatum\t\tretval;\n\tint\t\t\trc;\n\n\tAssert(IsA(codeblock, InlineCodeBlock));\n\n\t\/*\n\t * Connect to SPI manager\n\t *\/\n\tif ((rc = SPI_connect()) != SPI_OK_CONNECT)\n\t\telog(ERROR, \"SPI_connect failed: %s\", SPI_result_code_string(rc));\n\n\t\/* Compile the anonymous code block *\/\n\tfunc = plpgsql_compile_inline(codeblock->source_text);\n\n\t\/* Mark the function as busy, just pro forma *\/\n\tfunc->use_count++;\n\n\t\/*\n\t * Set up a fake fcinfo with just enough info to satisfy\n\t * plpgsql_exec_function().  In particular note that this sets things up\n\t * with no arguments passed.\n\t *\/\n\tMemSet(&fake_fcinfo, 0, sizeof(fake_fcinfo));\n\tMemSet(&flinfo, 0, sizeof(flinfo));\n\tfake_fcinfo.flinfo = &flinfo;\n\tflinfo.fn_oid = InvalidOid;\n\tflinfo.fn_mcxt = CurrentMemoryContext;\n\n\t\/* Create a private EState for simple-expression execution *\/\n\tsimple_eval_estate = CreateExecutorState();\n\n\t\/* And run the function *\/\n\tPG_TRY();\n\t{\n\t\tretval = plpgsql_exec_function(func, &fake_fcinfo, simple_eval_estate);\n\t}\n\tPG_CATCH();\n\t{\n\t\t\/*\n\t\t * We need to clean up what would otherwise be long-lived resources\n\t\t * accumulated by the failed DO block, principally cached plans for\n\t\t * statements (which can be flushed with plpgsql_free_function_memory)\n\t\t * and execution trees for simple expressions, which are in the\n\t\t * private EState.\n\t\t *\n\t\t * Before releasing the private EState, we must clean up any\n\t\t * simple_econtext_stack entries pointing into it, which we can do by\n\t\t * invoking the subxact callback.  (It will be called again later if\n\t\t * some outer control level does a subtransaction abort, but no harm\n\t\t * is done.)  We cheat a bit knowing that plpgsql_subxact_cb does not\n\t\t * pay attention to its parentSubid argument.\n\t\t *\/\n\t\tplpgsql_subxact_cb(SUBXACT_EVENT_ABORT_SUB,\n\t\t\t\t\t\t   GetCurrentSubTransactionId(),\n\t\t\t\t\t\t   0, NULL);\n\n\t\t\/* Clean up the private EState *\/\n\t\tFreeExecutorState(simple_eval_estate);\n\n\t\t\/* Function should now have no remaining use-counts ... *\/\n\t\tfunc->use_count--;\n\t\tAssert(func->use_count == 0);\n\n\t\t\/* ... so we can free subsidiary storage *\/\n\t\tplpgsql_free_function_memory(func);\n\n\t\t\/* And propagate the error *\/\n\t\tPG_RE_THROW();\n\t}\n\tPG_END_TRY();\n\n\t\/* Clean up the private EState *\/\n\tFreeExecutorState(simple_eval_estate);\n\n\t\/* Function should now have no remaining use-counts ... *\/\n\tfunc->use_count--;\n\tAssert(func->use_count == 0);\n\n\t\/* ... so we can free subsidiary storage *\/\n\tplpgsql_free_function_memory(func);\n\n\t\/*\n\t * Disconnect from SPI manager\n\t *\/\n\tif ((rc = SPI_finish()) != SPI_OK_FINISH)\n\t\telog(ERROR, \"SPI_finish failed: %s\", SPI_result_code_string(rc));\n\n\treturn retval;\n}","target":0,"code_token_length":730,"total_token_length":966,"max_tokens_setting":1024}
+{"idx":454790,"func":"Value ExpressionIndexOfCP::evaluate(const Document& root, Variables* variables) const {\n    Value stringArg = _children[0]->evaluate(root, variables);\n\n    if (stringArg.nullish()) {\n        return Value(BSONNULL);\n    }\n\n    uassert(40093,\n            str::stream() << \"$indexOfCP requires a string as the first argument, found: \"\n                          << typeName(stringArg.getType()),\n            stringArg.getType() == String);\n    const std::string& input = stringArg.getString();\n\n    Value tokenArg = _children[1]->evaluate(root, variables);\n    uassert(40094,\n            str::stream() << \"$indexOfCP requires a string as the second argument, found: \"\n                          << typeName(tokenArg.getType()),\n            tokenArg.getType() == String);\n    const std::string& token = tokenArg.getString();\n\n    size_t startCodePointIndex = 0;\n    if (_children.size() > 2) {\n        Value startIndexArg = _children[2]->evaluate(root, variables);\n        uassertIfNotIntegralAndNonNegative(startIndexArg, getOpName(), \"starting index\");\n        startCodePointIndex = static_cast<size_t>(startIndexArg.coerceToInt());\n    }\n\n    \/\/ Compute the length (in code points) of the input, and convert 'startCodePointIndex' to a byte\n    \/\/ index.\n    size_t codePointLength = 0;\n    size_t startByteIndex = 0;\n    for (size_t byteIx = 0; byteIx < input.size(); ++codePointLength) {\n        if (codePointLength == startCodePointIndex) {\n            \/\/ We have determined the byte at which our search will start.\n            startByteIndex = byteIx;\n        }\n\n        uassert(40095,\n                \"$indexOfCP found bad UTF-8 in the input\",\n                !str::isUTF8ContinuationByte(input[byteIx]));\n        byteIx += getCodePointLength(input[byteIx]);\n    }\n\n    size_t endCodePointIndex = codePointLength;\n    if (_children.size() > 3) {\n        Value endIndexArg = _children[3]->evaluate(root, variables);\n        uassertIfNotIntegralAndNonNegative(endIndexArg, getOpName(), \"ending index\");\n\n        \/\/ Don't let 'endCodePointIndex' exceed the number of code points in the string.\n        endCodePointIndex =\n            std::min(codePointLength, static_cast<size_t>(endIndexArg.coerceToInt()));\n    }\n\n    if (startByteIndex == 0 && input.empty() && token.empty()) {\n        \/\/ If we are finding the index of \"\" in the string \"\", the below loop will not loop, so we\n        \/\/ need a special case for this.\n        return Value(0);\n    }\n\n    \/\/ We must keep track of which byte, and which code point, we are examining, being careful not\n    \/\/ to overflow either the length of the string or the ending code point.\n\n    size_t currentCodePointIndex = startCodePointIndex;\n    for (size_t byteIx = startByteIndex; currentCodePointIndex < endCodePointIndex;\n         ++currentCodePointIndex) {\n        if (stringHasTokenAtIndex(byteIx, input, token)) {\n            return Value(static_cast<int>(currentCodePointIndex));\n        }\n        byteIx += getCodePointLength(input[byteIx]);\n    }\n\n    return Value(-1);\n}","target":0,"code_token_length":717,"total_token_length":953,"max_tokens_setting":1024}
+{"idx":36617,"func":"static int rfcomm_create_dev(struct sock *sk, void __user *arg)\n{\n\tstruct rfcomm_dev_req req;\n\tstruct rfcomm_dlc *dlc;\n\tint id;\n\n\tif (copy_from_user(&req, arg, sizeof(req)))\n\t\treturn -EFAULT;\n\n\tBT_DBG(\"sk %p dev_id %d flags 0x%x\", sk, req.dev_id, req.flags);\n\n\tif (req.flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN))\n\t\treturn -EPERM;\n\n\tif (req.flags & (1 << RFCOMM_REUSE_DLC)) {\n\t\t\/* Socket must be connected *\/\n\t\tif (sk->sk_state != BT_CONNECTED)\n\t\t\treturn -EBADFD;\n\n\t\tdlc = rfcomm_pi(sk)->dlc;\n\t\trfcomm_dlc_hold(dlc);\n\t} else {\n\t\tdlc = rfcomm_dlc_alloc(GFP_KERNEL);\n\t\tif (!dlc)\n\t\t\treturn -ENOMEM;\n\t}\n\n\tid = rfcomm_dev_add(&req, dlc);\n\tif (id < 0) {\n\t\trfcomm_dlc_put(dlc);\n\t\treturn id;\n\t}\n\n\tif (req.flags & (1 << RFCOMM_REUSE_DLC)) {\n\t\t\/* DLC is now used by device.\n\t\t * Socket must be disconnected *\/\n\t\tsk->sk_state = BT_CLOSED;\n\t}\n\n\treturn id;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":99244,"func":"int btrfs_run_dev_stats(struct btrfs_trans_handle *trans,\n\t\t\tstruct btrfs_fs_info *fs_info)\n{\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tstruct btrfs_device *device;\n\tint stats_cnt;\n\tint ret = 0;\n\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tlist_for_each_entry(device, &fs_devices->devices, dev_list) {\n\t\tstats_cnt = atomic_read(&device->dev_stats_ccnt);\n\t\tif (!device->dev_stats_valid || stats_cnt == 0)\n\t\t\tcontinue;\n\n\n\t\t\/*\n\t\t * There is a LOAD-LOAD control dependency between the value of\n\t\t * dev_stats_ccnt and updating the on-disk values which requires\n\t\t * reading the in-memory counters. Such control dependencies\n\t\t * require explicit read memory barriers.\n\t\t *\n\t\t * This memory barriers pairs with smp_mb__before_atomic in\n\t\t * btrfs_dev_stat_inc\/btrfs_dev_stat_set and with the full\n\t\t * barrier implied by atomic_xchg in\n\t\t * btrfs_dev_stats_read_and_reset\n\t\t *\/\n\t\tsmp_rmb();\n\n\t\tret = update_dev_stat_item(trans, device);\n\t\tif (!ret)\n\t\t\tatomic_sub(stats_cnt, &device->dev_stats_ccnt);\n\t}\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\treturn ret;\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":69653,"func":"md_process_line(MD_CTX* ctx, const MD_LINE_ANALYSIS** p_pivot_line, MD_LINE_ANALYSIS* line)\n{\n    const MD_LINE_ANALYSIS* pivot_line = *p_pivot_line;\n    int ret = 0;\n\n    \/* Blank line ends current leaf block. *\/\n    if(line->type == MD_LINE_BLANK) {\n        MD_CHECK(md_end_current_block(ctx));\n        *p_pivot_line = &md_dummy_blank_line;\n        return 0;\n    }\n\n    \/* Some line types form block on their own. *\/\n    if(line->type == MD_LINE_HR || line->type == MD_LINE_ATXHEADER) {\n        MD_CHECK(md_end_current_block(ctx));\n\n        \/* Add our single-line block. *\/\n        MD_CHECK(md_start_new_block(ctx, line));\n        MD_CHECK(md_add_line_into_current_block(ctx, line));\n        MD_CHECK(md_end_current_block(ctx));\n        *p_pivot_line = &md_dummy_blank_line;\n        return 0;\n    }\n\n    \/* MD_LINE_SETEXTUNDERLINE changes meaning of the current block and ends it. *\/\n    if(line->type == MD_LINE_SETEXTUNDERLINE) {\n        MD_ASSERT(ctx->current_block != NULL);\n        ctx->current_block->type = MD_BLOCK_H;\n        ctx->current_block->data = line->data;\n        ctx->current_block->flags |= MD_BLOCK_SETEXT_HEADER;\n        MD_CHECK(md_add_line_into_current_block(ctx, line));\n        MD_CHECK(md_end_current_block(ctx));\n        if(ctx->current_block == NULL) {\n            *p_pivot_line = &md_dummy_blank_line;\n        } else {\n            \/* This happens if we have consumed all the body as link ref. defs.\n             * and downgraded the underline into start of a new paragraph block. *\/\n            line->type = MD_LINE_TEXT;\n            *p_pivot_line = line;\n        }\n        return 0;\n    }\n\n    \/* MD_LINE_TABLEUNDERLINE changes meaning of the current block. *\/\n    if(line->type == MD_LINE_TABLEUNDERLINE) {\n        MD_ASSERT(ctx->current_block != NULL);\n        MD_ASSERT(ctx->current_block->n_lines == 1);\n        ctx->current_block->type = MD_BLOCK_TABLE;\n        ctx->current_block->data = line->data;\n        MD_ASSERT(pivot_line != &md_dummy_blank_line);\n        ((MD_LINE_ANALYSIS*)pivot_line)->type = MD_LINE_TABLE;\n        MD_CHECK(md_add_line_into_current_block(ctx, line));\n        return 0;\n    }\n\n    \/* The current block also ends if the line has different type. *\/\n    if(line->type != pivot_line->type)\n        MD_CHECK(md_end_current_block(ctx));\n\n    \/* The current line may start a new block. *\/\n    if(ctx->current_block == NULL) {\n        MD_CHECK(md_start_new_block(ctx, line));\n        *p_pivot_line = line;\n    }\n\n    \/* In all other cases the line is just a continuation of the current block. *\/\n    MD_CHECK(md_add_line_into_current_block(ctx, line));\n\nabort:\n    return ret;\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":230540,"func":"  static void  Ins_MDRP( INS_ARG )\n  {\n    Int         point;\n    TT_F26Dot6  distance,\n                org_dist;\n\n    point = (Int)args[0];\n\n    if ( BOUNDS( args[0], CUR.zp1.n_points ) ||\n         BOUNDS( CUR.GS.rp0, CUR.zp0.n_points) )\n    {\n        \/* Current version of FreeType silently ignores this out of bounds error\n         * and drops the instruction, see bug #691121\n      CUR.error = TT_Err_Invalid_Reference; *\/\n      return;\n    }\n\n    \/* XXX: Is there some undocumented feature while in the *\/\n    \/*      twilight zone?                                  *\/\n\n    org_dist = CUR_Func_dualproj( CUR.zp1.org_x[point] -\n                                    CUR.zp0.org_x[CUR.GS.rp0],\n                                  CUR.zp1.org_y[point] -\n                                    CUR.zp0.org_y[CUR.GS.rp0] );\n\n    \/* single width cutin test *\/\n\n    if ( ABS(org_dist) < CUR.GS.single_width_cutin )\n    {\n      if ( org_dist >= 0 )\n        org_dist = CUR.GS.single_width_value;\n      else\n        org_dist = -CUR.GS.single_width_value;\n    }\n\n    \/* round flag *\/\n\n    if ( (CUR.opcode & 4) != 0 )\n      distance = CUR_Func_round( org_dist,\n                                 CUR.metrics.compensations[CUR.opcode & 3] );\n    else\n      distance = Round_None( EXEC_ARGS\n                             org_dist,\n                             CUR.metrics.compensations[CUR.opcode & 3]  );\n\n    \/* minimum distance flag *\/\n\n    if ( (CUR.opcode & 8) != 0 )\n    {\n      if ( org_dist >= 0 )\n      {\n        if ( distance < CUR.GS.minimum_distance )\n          distance = CUR.GS.minimum_distance;\n      }\n      else\n      {\n        if ( distance > -CUR.GS.minimum_distance )\n          distance = -CUR.GS.minimum_distance;\n      }\n    }\n\n    \/* now move the point *\/\n\n    org_dist = CUR_Func_project( CUR.zp1.cur_x[point] -\n                                   CUR.zp0.cur_x[CUR.GS.rp0],\n                                 CUR.zp1.cur_y[point] -\n                                   CUR.zp0.cur_y[CUR.GS.rp0] );\n\n    CUR_Func_move( &CUR.zp1, point, distance - org_dist );\n\n    CUR.GS.rp1 = CUR.GS.rp0;\n    CUR.GS.rp2 = point;\n\n    if ( (CUR.opcode & 16) != 0 )\n      CUR.GS.rp0 = point;\n  }\n","target":0,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":207703,"func":"void TabHelper::DidNavigateMainFrame(\n    const content::LoadCommittedDetails& details,\n    const content::FrameNavigateParams& params) {\n  InvokeForContentRulesRegistries(\n      [this, &details, ¶ms](ContentRulesRegistry* registry) {\n    registry->DidNavigateMainFrame(web_contents(), details, params);\n  });\n\n  content::BrowserContext* context = web_contents()->GetBrowserContext();\n  ExtensionRegistry* registry = ExtensionRegistry::Get(context);\n  const ExtensionSet& enabled_extensions = registry->enabled_extensions();\n\n  if (util::IsNewBookmarkAppsEnabled()) {\n    Browser* browser = chrome::FindBrowserWithWebContents(web_contents());\n    if (browser && browser->is_app()) {\n      const Extension* extension = registry->GetExtensionById(\n          web_app::GetExtensionIdFromApplicationName(browser->app_name()),\n          ExtensionRegistry::EVERYTHING);\n      if (extension && AppLaunchInfo::GetFullLaunchURL(extension).is_valid())\n        SetExtensionApp(extension);\n    } else {\n      UpdateExtensionAppIcon(\n          enabled_extensions.GetExtensionOrAppByURL(params.url));\n    }\n  } else {\n    UpdateExtensionAppIcon(\n        enabled_extensions.GetExtensionOrAppByURL(params.url));\n  }\n\n  if (!details.is_in_page)\n    ExtensionActionAPI::Get(context)->ClearAllValuesForTab(web_contents());\n}\n","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":1162,"func":"static int decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {\n TM2Context * const l = avctx -> priv_data ;\n const uint8_t * buf = avpkt -> data ;\n int buf_size = avpkt -> size & ~ 3 ;\n AVFrame * const p = & l -> pic ;\n int offset = TM2_HEADER_SIZE ;\n int i , t , ret ;\n uint8_t * swbuf ;\n swbuf = av_malloc ( buf_size + FF_INPUT_BUFFER_PADDING_SIZE ) ;\n if ( ! swbuf ) {\n av_log ( avctx , AV_LOG_ERROR , \"Cannot allocate temporary buffer\\n\" ) ;\n return AVERROR ( ENOMEM ) ;\n }\n p -> reference = 1 ;\n p -> buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE ;\n if ( ( ret = avctx -> reget_buffer ( avctx , p ) ) < 0 ) {\n av_log ( avctx , AV_LOG_ERROR , \"get_buffer() failed\\n\" ) ;\n av_free ( swbuf ) ;\n return ret ;\n }\n l -> dsp . bswap_buf ( ( uint32_t * ) swbuf , ( const uint32_t * ) buf , buf_size >> 2 ) ;\n if ( ( ret = tm2_read_header ( l , swbuf ) ) < 0 ) {\n av_free ( swbuf ) ;\n return ret ;\n }\n for ( i = 0 ;\n i < TM2_NUM_STREAMS ;\n i ++ ) {\n if ( offset >= buf_size ) {\n av_free ( swbuf ) ;\n return AVERROR_INVALIDDATA ;\n }\n t = tm2_read_stream ( l , swbuf + offset , tm2_stream_order [ i ] , buf_size - offset ) ;\n if ( t < 0 ) {\n av_free ( swbuf ) ;\n return t ;\n }\n offset += t ;\n }\n p -> key_frame = tm2_decode_blocks ( l , p ) ;\n if ( p -> key_frame ) p -> pict_type = AV_PICTURE_TYPE_I ;\n else p -> pict_type = AV_PICTURE_TYPE_P ;\n l -> cur = ! l -> cur ;\n * got_frame = 1 ;\n * ( AVFrame * ) data = l -> pic ;\n av_free ( swbuf ) ;\n return buf_size ;\n }","target":1,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":355812,"func":"resume_copy_required_values (gnutls_session_t session)\n{\n  \/* get the new random values *\/\n  memcpy (session->internals.resumed_security_parameters.\n\t  server_random,\n\t  session->security_parameters.server_random, TLS_RANDOM_SIZE);\n  memcpy (session->internals.resumed_security_parameters.\n\t  client_random,\n\t  session->security_parameters.client_random, TLS_RANDOM_SIZE);\n\n  \/* keep the ciphersuite and compression \n   * That is because the client must see these in our\n   * hello message.\n   *\/\n  memcpy (session->security_parameters.current_cipher_suite.\n\t  suite,\n\t  session->internals.resumed_security_parameters.\n\t  current_cipher_suite.suite, 2);\n\n  session->internals.compression_method =\n    session->internals.resumed_security_parameters.read_compression_algorithm;\n  \/* or write_compression_algorithm\n   * they are the same\n   *\/\n\n  session->security_parameters.entity =\n    session->internals.resumed_security_parameters.entity;\n\n  _gnutls_set_current_version (session,\n\t\t\t       session->internals.\n\t\t\t       resumed_security_parameters.version);\n\n  session->security_parameters.cert_type =\n    session->internals.resumed_security_parameters.cert_type;\n\n  memcpy (session->security_parameters.session_id,\n\t  session->internals.resumed_security_parameters.\n\t  session_id, sizeof (session->security_parameters.session_id));\n  session->security_parameters.session_id_size =\n    session->internals.resumed_security_parameters.session_id_size;\n}","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":115684,"func":"gdImageBrushApply (gdImagePtr im, int x, int y)\n{\n\tint lx, ly;\n\tint hy;\n\tint hx;\n\tint x1, y1, x2, y2;\n\tint srcx, srcy;\n\tif (!im->brush) {\n\t\treturn;\n\t}\n\thy = gdImageSY (im->brush) \/ 2;\n\ty1 = y - hy;\n\ty2 = y1 + gdImageSY (im->brush);\n\thx = gdImageSX (im->brush) \/ 2;\n\tx1 = x - hx;\n\tx2 = x1 + gdImageSX (im->brush);\n\tsrcy = 0;\n\tif (im->trueColor) {\n\t\tif (im->brush->trueColor) {\n\t\t\tfor (ly = y1; (ly < y2); ly++) {\n\t\t\t\tsrcx = 0;\n\t\t\t\tfor (lx = x1; (lx < x2); lx++) {\n\t\t\t\t\tint p;\n\t\t\t\t\tp = gdImageGetTrueColorPixel (im->brush, srcx, srcy);\n\t\t\t\t\t\/* 2.0.9, Thomas Winzig: apply simple full transparency *\/\n\t\t\t\t\tif (p != gdImageGetTransparent (im->brush)) {\n\t\t\t\t\t\tgdImageSetPixel (im, lx, ly, p);\n\t\t\t\t\t}\n\t\t\t\t\tsrcx++;\n\t\t\t\t}\n\t\t\t\tsrcy++;\n\t\t\t}\n\t\t} else {\n\t\t\t\/* 2.0.12: Brush palette, image truecolor (thanks to Thorben Kundinger\n\t\t\t   for pointing out the issue) *\/\n\t\t\tfor (ly = y1; (ly < y2); ly++) {\n\t\t\t\tsrcx = 0;\n\t\t\t\tfor (lx = x1; (lx < x2); lx++) {\n\t\t\t\t\tint p, tc;\n\t\t\t\t\tp = gdImageGetPixel (im->brush, srcx, srcy);\n\t\t\t\t\ttc = gdImageGetTrueColorPixel (im->brush, srcx, srcy);\n\t\t\t\t\t\/* 2.0.9, Thomas Winzig: apply simple full transparency *\/\n\t\t\t\t\tif (p != gdImageGetTransparent (im->brush)) {\n\t\t\t\t\t\tgdImageSetPixel (im, lx, ly, tc);\n\t\t\t\t\t}\n\t\t\t\t\tsrcx++;\n\t\t\t\t}\n\t\t\t\tsrcy++;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (ly = y1; (ly < y2); ly++) {\n\t\t\tsrcx = 0;\n\t\t\tfor (lx = x1; (lx < x2); lx++) {\n\t\t\t\tint p;\n\t\t\t\tp = gdImageGetPixel (im->brush, srcx, srcy);\n\t\t\t\t\/* Allow for non-square brushes! *\/\n\t\t\t\tif (p != gdImageGetTransparent (im->brush)) {\n\t\t\t\t\t\/* Truecolor brush. Very slow\n\t\t\t\t\t   on a palette destination. *\/\n\t\t\t\t\tif (im->brush->trueColor) {\n\t\t\t\t\t\tgdImageSetPixel (im, lx, ly,\n\t\t\t\t\t\t                 gdImageColorResolveAlpha (im,\n\t\t\t\t\t\t                         gdTrueColorGetRed\n\t\t\t\t\t\t                         (p),\n\t\t\t\t\t\t                         gdTrueColorGetGreen\n\t\t\t\t\t\t                         (p),\n\t\t\t\t\t\t                         gdTrueColorGetBlue\n\t\t\t\t\t\t                         (p),\n\t\t\t\t\t\t                         gdTrueColorGetAlpha\n\t\t\t\t\t\t                         (p)));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgdImageSetPixel (im, lx, ly, im->brushColorMap[p]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsrcx++;\n\t\t\t}\n\t\t\tsrcy++;\n\t\t}\n\t}\n}","target":0,"code_token_length":723,"total_token_length":959,"max_tokens_setting":1024}
+{"idx":326401,"func":"static int replace_int_data_in_filename(char *buf, int buf_size, const char *filename, char placeholder, int64_t number)\n\n{\n\n    const char *p;\n\n    char *q, buf1[20], c;\n\n    int nd, len, addchar_count;\n\n    int found_count = 0;\n\n\n\n    q = buf;\n\n    p = filename;\n\n    for (;;) {\n\n        c = *p;\n\n        if (c == '\\0')\n\n            break;\n\n        if (c == '%' && *(p+1) == '%')  \/\/ %%\n\n            addchar_count = 2;\n\n        else if (c == '%' && (av_isdigit(*(p+1)) || *(p+1) == placeholder)) {\n\n            nd = 0;\n\n            addchar_count = 1;\n\n            while (av_isdigit(*(p + addchar_count))) {\n\n                nd = nd * 10 + *(p + addchar_count) - '0';\n\n                addchar_count++;\n\n            }\n\n\n\n            if (*(p + addchar_count) == placeholder) {\n\n                len = snprintf(buf1, sizeof(buf1), \"%0*\"PRId64, (number < 0) ? nd : nd++, number);\n\n                if (len < 1)  \/\/ returned error or empty buf1\n\n                    goto fail;\n\n                if ((q - buf + len) > buf_size - 1)\n\n                    goto fail;\n\n                memcpy(q, buf1, len);\n\n                q += len;\n\n                p += (addchar_count + 1);\n\n                addchar_count = 0;\n\n                found_count++;\n\n            }\n\n\n\n        } else\n\n            addchar_count = 1;\n\n\n\n        while (addchar_count--)\n\n            if ((q - buf) < buf_size - 1)\n\n                *q++ = *p++;\n\n            else\n\n                goto fail;\n\n    }\n\n    *q = '\\0';\n\n    return found_count;\n\nfail:\n\n    *q = '\\0';\n\n    return -1;\n\n}\n","target":0,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":329936,"func":"static int uhci_broadcast_packet(UHCIState *s, USBPacket *p)\n\n{\n\n    UHCIPort *port;\n\n    USBDevice *dev;\n\n    int i, ret;\n\n\n\n#ifdef DEBUG_PACKET\n\n    {\n\n        const char *pidstr;\n\n        switch(p->pid) {\n\n        case USB_TOKEN_SETUP: pidstr = \"SETUP\"; break;\n\n        case USB_TOKEN_IN: pidstr = \"IN\"; break;\n\n        case USB_TOKEN_OUT: pidstr = \"OUT\"; break;\n\n        default: pidstr = \"?\"; break;\n\n        }\n\n        printf(\"frame %d: pid=%s addr=0x%02x ep=%d len=%d\\n\",\n\n               s->frnum, pidstr, p->devaddr, p->devep, p->len);\n\n        if (p->pid != USB_TOKEN_IN) {\n\n            printf(\"     data_out=\");\n\n            for(i = 0; i < p->len; i++) {\n\n                printf(\" %02x\", p->data[i]);\n\n            }\n\n            printf(\"\\n\");\n\n        }\n\n    }\n\n#endif\n\n    for(i = 0; i < NB_PORTS; i++) {\n\n        port = &s->ports[i];\n\n        dev = port->port.dev;\n\n        if (dev && (port->ctrl & UHCI_PORT_EN)) {\n\n            ret = dev->handle_packet(dev, p);\n\n            if (ret != USB_RET_NODEV) {\n\n#ifdef DEBUG_PACKET\n\n                if (ret == USB_RET_ASYNC) {\n\n                    printf(\"usb-uhci: Async packet\\n\");\n\n                } else {\n\n                    printf(\"     ret=%d \", ret);\n\n                    if (p->pid == USB_TOKEN_IN && ret > 0) {\n\n                        printf(\"data_in=\");\n\n                        for(i = 0; i < ret; i++) {\n\n                            printf(\" %02x\", p->data[i]);\n\n                        }\n\n                    }\n\n                    printf(\"\\n\");\n\n                }\n\n#endif\n\n                return ret;\n\n            }\n\n        }\n\n    }\n\n    return USB_RET_NODEV;\n\n}\n","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":2636,"func":"SPL_METHOD(SplFileInfo, getLinkTarget)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tint ret;\n\tchar buff[MAXPATHLEN];\n\tzend_error_handling error_handling;\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tzend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);\n\n#if defined(PHP_WIN32) || HAVE_SYMLINK\n\tif (intern->file_name == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Empty filename\");\n\t\tRETURN_FALSE;\n\t} else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {\n\t\tchar expanded_path[MAXPATHLEN];\n\t\tif (!expand_filepath_with_mode(intern->file_name, expanded_path, NULL, 0, CWD_EXPAND  TSRMLS_CC)) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"No such file or directory\");\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\tret = php_sys_readlink(expanded_path, buff, MAXPATHLEN - 1);\n\t} else {\n\t\tret = php_sys_readlink(intern->file_name, buff,  MAXPATHLEN-1);\n\t}\n#else\n\tret = -1; \/* always fail if not implemented *\/\n#endif\n\n\tif (ret == -1) {\n\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, \"Unable to read link %s, error: %s\", intern->file_name, strerror(errno));\n\t\tRETVAL_FALSE;\n\t} else {\n\t\t\/* Append NULL to the end of the string *\/\n\t\tbuff[ret] = '\\0';\n\n\t\tRETVAL_STRINGL(buff, ret, 1);\n\t}\n\n\tzend_restore_error_handling(&error_handling TSRMLS_CC);\n}","target":1,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":474206,"func":"static int reencrypt_recovery_by_passphrase(struct crypt_device *cd,\n\tstruct luks2_hdr *hdr,\n\tint keyslot_old,\n\tint keyslot_new,\n\tconst char *passphrase,\n\tsize_t passphrase_size)\n{\n\tint r;\n\tcrypt_reencrypt_info ri;\n\tstruct crypt_lock_handle *reencrypt_lock;\n\n\tr = LUKS2_reencrypt_lock(cd, &reencrypt_lock);\n\tif (r) {\n\t\tif (r == -EBUSY)\n\t\t\tlog_err(cd, _(\"Reencryption in-progress. Cannot perform recovery.\"));\n\t\telse\n\t\t\tlog_err(cd, _(\"Failed to get reencryption lock.\"));\n\t\treturn r;\n\t}\n\n\tif ((r = crypt_load(cd, CRYPT_LUKS2, NULL))) {\n\t\tLUKS2_reencrypt_unlock(cd, reencrypt_lock);\n\t\treturn r;\n\t}\n\n\tri = LUKS2_reencrypt_status(hdr);\n\tif (ri == CRYPT_REENCRYPT_INVALID) {\n\t\tLUKS2_reencrypt_unlock(cd, reencrypt_lock);\n\t\treturn -EINVAL;\n\t}\n\n\tif (ri == CRYPT_REENCRYPT_CRASH) {\n\t\tr = LUKS2_reencrypt_locked_recovery_by_passphrase(cd, keyslot_old, keyslot_new,\n\t\t\t\tpassphrase, passphrase_size, 0, NULL);\n\t\tif (r < 0)\n\t\t\tlog_err(cd, _(\"LUKS2 reencryption recovery failed.\"));\n\t} else {\n\t\tlog_dbg(cd, \"No LUKS2 reencryption recovery needed.\");\n\t\tr = 0;\n\t}\n\n\tLUKS2_reencrypt_unlock(cd, reencrypt_lock);\n\treturn r;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":439396,"func":"static int cpia2_s_fmt_vid_cap(struct file *file, void *_fh,\n\t\t\t\t\tstruct v4l2_format *f)\n{\n\tstruct camera_data *cam = video_drvdata(file);\n\tint err, frame;\n\n\terr = cpia2_try_fmt_vid_cap(file, _fh, f);\n\tif(err != 0)\n\t\treturn err;\n\n\tcam->pixelformat = f->fmt.pix.pixelformat;\n\n\t\/* NOTE: This should be set to 1 for MJPEG, but some apps don't handle\n\t * the missing Huffman table properly. *\/\n\tcam->params.compression.inhibit_htables = 0;\n\t\t\/*f->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG;*\/\n\n\t\/* we set the video window to something smaller or equal to what\n\t * is requested by the user???\n\t *\/\n\tDBG(\"Requested width = %d, height = %d\\n\",\n\t    f->fmt.pix.width, f->fmt.pix.height);\n\tif (f->fmt.pix.width != cam->width ||\n\t    f->fmt.pix.height != cam->height) {\n\t\tcam->width = f->fmt.pix.width;\n\t\tcam->height = f->fmt.pix.height;\n\t\tcam->params.roi.width = f->fmt.pix.width;\n\t\tcam->params.roi.height = f->fmt.pix.height;\n\t\tcpia2_set_format(cam);\n\t}\n\n\tfor (frame = 0; frame < cam->num_frames; ++frame) {\n\t\tif (cam->buffers[frame].status == FRAME_READING)\n\t\t\tif ((err = sync(cam, frame)) < 0)\n\t\t\t\treturn err;\n\n\t\tcam->buffers[frame].status = FRAME_EMPTY;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":452005,"func":"static int rbd_dev_device_setup(struct rbd_device *rbd_dev)\n{\n\tint ret;\n\n\t\/* Record our major and minor device numbers. *\/\n\n\tif (!single_major) {\n\t\tret = register_blkdev(0, rbd_dev->name);\n\t\tif (ret < 0)\n\t\t\tgoto err_out_unlock;\n\n\t\trbd_dev->major = ret;\n\t\trbd_dev->minor = 0;\n\t} else {\n\t\trbd_dev->major = rbd_major;\n\t\trbd_dev->minor = rbd_dev_id_to_minor(rbd_dev->dev_id);\n\t}\n\n\t\/* Set up the blkdev mapping. *\/\n\n\tret = rbd_init_disk(rbd_dev);\n\tif (ret)\n\t\tgoto err_out_blkdev;\n\n\tset_capacity(rbd_dev->disk, rbd_dev->mapping.size \/ SECTOR_SIZE);\n\tset_disk_ro(rbd_dev->disk, rbd_is_ro(rbd_dev));\n\n\tret = dev_set_name(&rbd_dev->dev, \"%d\", rbd_dev->dev_id);\n\tif (ret)\n\t\tgoto err_out_disk;\n\n\tset_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);\n\tup_write(&rbd_dev->header_rwsem);\n\treturn 0;\n\nerr_out_disk:\n\trbd_free_disk(rbd_dev);\nerr_out_blkdev:\n\tif (!single_major)\n\t\tunregister_blkdev(rbd_dev->major, rbd_dev->name);\nerr_out_unlock:\n\tup_write(&rbd_dev->header_rwsem);\n\treturn ret;\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":129014,"func":"static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)\n{\n\tunsigned hw_argc;\n\tint ret;\n\tstruct dm_target *ti = m->ti;\n\n\tstatic struct dm_arg _args[] = {\n\t\t{0, 1024, \"invalid number of hardware handler args\"},\n\t};\n\n\tif (dm_read_arg_group(_args, as, &hw_argc, &ti->error))\n\t\treturn -EINVAL;\n\n\tif (!hw_argc)\n\t\treturn 0;\n\n\tm->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL);\n\trequest_module(\"scsi_dh_%s\", m->hw_handler_name);\n\tif (scsi_dh_handler_exist(m->hw_handler_name) == 0) {\n\t\tti->error = \"unknown hardware handler type\";\n\t\tret = -EINVAL;\n\t\tgoto fail;\n\t}\n\n\tif (hw_argc > 1) {\n\t\tchar *p;\n\t\tint i, j, len = 4;\n\n\t\tfor (i = 0; i <= hw_argc - 2; i++)\n\t\t\tlen += strlen(as->argv[i]) + 1;\n\t\tp = m->hw_handler_params = kzalloc(len, GFP_KERNEL);\n\t\tif (!p) {\n\t\t\tti->error = \"memory allocation failed\";\n\t\t\tret = -ENOMEM;\n\t\t\tgoto fail;\n\t\t}\n\t\tj = sprintf(p, \"%d\", hw_argc - 1);\n\t\tfor (i = 0, p+=j+1; i <= hw_argc - 2; i++, p+=j+1)\n\t\t\tj = sprintf(p, \"%s\", as->argv[i]);\n\t}\n\tdm_consume_args(as, hw_argc - 1);\n\n\treturn 0;\nfail:\n\tkfree(m->hw_handler_name);\n\tm->hw_handler_name = NULL;\n\treturn ret;\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":122152,"func":"int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,\n\t\t\t\t   loff_t offset, ssize_t len)\n{\n\tunsigned int max_blocks;\n\tint ret = 0;\n\tint ret2 = 0;\n\tstruct ext4_map_blocks map;\n\tunsigned int credits, blkbits = inode->i_blkbits;\n\n\tmap.m_lblk = offset >> blkbits;\n\tmax_blocks = EXT4_MAX_BLOCKS(len, offset, blkbits);\n\n\t\/*\n\t * This is somewhat ugly but the idea is clear: When transaction is\n\t * reserved, everything goes into it. Otherwise we rather start several\n\t * smaller transactions for conversion of each extent separately.\n\t *\/\n\tif (handle) {\n\t\thandle = ext4_journal_start_reserved(handle,\n\t\t\t\t\t\t     EXT4_HT_EXT_CONVERT);\n\t\tif (IS_ERR(handle))\n\t\t\treturn PTR_ERR(handle);\n\t\tcredits = 0;\n\t} else {\n\t\t\/*\n\t\t * credits to insert 1 extent into extent tree\n\t\t *\/\n\t\tcredits = ext4_chunk_trans_blocks(inode, max_blocks);\n\t}\n\twhile (ret >= 0 && ret < max_blocks) {\n\t\tmap.m_lblk += ret;\n\t\tmap.m_len = (max_blocks -= ret);\n\t\tif (credits) {\n\t\t\thandle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,\n\t\t\t\t\t\t    credits);\n\t\t\tif (IS_ERR(handle)) {\n\t\t\t\tret = PTR_ERR(handle);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tret = ext4_map_blocks(handle, inode, &map,\n\t\t\t\t      EXT4_GET_BLOCKS_IO_CONVERT_EXT);\n\t\tif (ret <= 0)\n\t\t\text4_warning(inode->i_sb,\n\t\t\t\t     \"inode #%lu: block %u: len %u: \"\n\t\t\t\t     \"ext4_ext_map_blocks returned %d\",\n\t\t\t\t     inode->i_ino, map.m_lblk,\n\t\t\t\t     map.m_len, ret);\n\t\text4_mark_inode_dirty(handle, inode);\n\t\tif (credits)\n\t\t\tret2 = ext4_journal_stop(handle);\n\t\tif (ret <= 0 || ret2)\n\t\t\tbreak;\n\t}\n\tif (!credits)\n\t\tret2 = ext4_journal_stop(handle);\n\treturn ret > 0 ? ret2 : ret;\n}","target":0,"code_token_length":448,"total_token_length":684,"max_tokens_setting":1024}
+{"idx":6365,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n  const TfLiteTensor* fft_length = GetInput(context, node, kFftLengthTensor);\n  const int32_t* fft_length_data = GetTensorData<int32_t>(fft_length);\n  TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n  if (output->type != kTfLiteComplex64) {\n    context->ReportError(context,\n                         \"Type '%s' for output is not supported by rfft2d.\",\n                         TfLiteTypeGetName(output->type));\n    return kTfLiteError;\n  }\n\n  \/\/ Resize the output tensor if the fft_length tensor is not constant.\n  \/\/ Otherwise, check if the output shape is correct.\n  if (!IsConstantTensor(fft_length)) {\n    TF_LITE_ENSURE_STATUS(ResizeOutputandTemporaryTensors(context, node));\n  } else {\n    int num_dims_output = NumDimensions(output);\n    const RuntimeShape output_shape = GetTensorShape(output);\n    TF_LITE_ENSURE_EQ(context, num_dims_output, NumDimensions(input));\n    TF_LITE_ENSURE(context, num_dims_output >= 2);\n    TF_LITE_ENSURE_EQ(context, output_shape.Dims(num_dims_output - 2),\n                      fft_length_data[0]);\n    TF_LITE_ENSURE_EQ(context, output_shape.Dims(num_dims_output - 1),\n                      fft_length_data[1] \/ 2 + 1);\n  }\n\n  return Rfft2dHelper(context, node);\n}","target":1,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":176610,"func":"static void classInitNative(JNIEnv* env, jclass clazz) {\n int err;\n hw_module_t* module;\n\n    jclass jniCallbackClass =\n        env->FindClass(\"com\/android\/bluetooth\/btservice\/JniCallbacks\");\n    sJniCallbacksField = env->GetFieldID(clazz, \"mJniCallbacks\",\n \"Lcom\/android\/bluetooth\/btservice\/JniCallbacks;\");\n\n    method_stateChangeCallback = env->GetMethodID(jniCallbackClass, \"stateChangeCallback\", \"(I)V\");\n\n    method_adapterPropertyChangedCallback = env->GetMethodID(jniCallbackClass,\n \"adapterPropertyChangedCallback\",\n \"([I[[B)V\");\n    method_discoveryStateChangeCallback = env->GetMethodID(jniCallbackClass,\n \"discoveryStateChangeCallback\", \"(I)V\");\n\n    method_devicePropertyChangedCallback = env->GetMethodID(jniCallbackClass,\n \"devicePropertyChangedCallback\",\n \"([B[I[[B)V\");\n    method_deviceFoundCallback = env->GetMethodID(jniCallbackClass, \"deviceFoundCallback\", \"([B)V\");\n    method_pinRequestCallback = env->GetMethodID(jniCallbackClass, \"pinRequestCallback\",\n \"([B[BIZ)V\");\n    method_sspRequestCallback = env->GetMethodID(jniCallbackClass, \"sspRequestCallback\",\n \"([B[BIII)V\");\n\n    method_bondStateChangeCallback = env->GetMethodID(jniCallbackClass,\n \"bondStateChangeCallback\", \"(I[BI)V\");\n\n    method_aclStateChangeCallback = env->GetMethodID(jniCallbackClass,\n \"aclStateChangeCallback\", \"(I[BI)V\");\n\n    method_setWakeAlarm = env->GetMethodID(clazz, \"setWakeAlarm\", \"(JZ)Z\");\n    method_acquireWakeLock = env->GetMethodID(clazz, \"acquireWakeLock\", \"(Ljava\/lang\/String;)Z\");\n    method_releaseWakeLock = env->GetMethodID(clazz, \"releaseWakeLock\", \"(Ljava\/lang\/String;)Z\");\n    method_energyInfo = env->GetMethodID(clazz, \"energyInfoCallback\", \"(IIJJJJ)V\");\n\n char value[PROPERTY_VALUE_MAX];\n    property_get(\"bluetooth.mock_stack\", value, \"\");\n\n const char *id = (strcmp(value, \"1\")? BT_STACK_MODULE_ID : BT_STACK_TEST_MODULE_ID);\n\n    err = hw_get_module(id, (hw_module_t const**)&module);\n\n if (err == 0) {\n hw_device_t* abstraction;\n        err = module->methods->open(module, id, &abstraction);\n if (err == 0) {\n bluetooth_module_t* btStack = (bluetooth_module_t *)abstraction;\n            sBluetoothInterface = btStack->get_bluetooth_interface();\n } else {\n           ALOGE(\"Error while opening Bluetooth library\");\n }\n } else {\n        ALOGE(\"No Bluetooth Library found\");\n }\n}\n","target":0,"code_token_length":572,"total_token_length":808,"max_tokens_setting":1024}
+{"idx":406028,"func":"ofputil_put_ofp14_table_desc(const struct ofputil_table_desc *td,\n                             struct ofpbuf *b, enum ofp_version version)\n{\n    struct ofp14_table_desc *otd;\n    struct ofp14_table_mod_prop_vacancy *otv;\n    size_t start_otd;\n\n    start_otd = b->size;\n    ofpbuf_put_zeros(b, sizeof *otd);\n\n    ofpprop_put_u32(b, OFPTMPT14_EVICTION, td->eviction_flags);\n\n    otv = ofpbuf_put_zeros(b, sizeof *otv);\n    otv->type = htons(OFPTMPT14_VACANCY);\n    otv->length = htons(sizeof *otv);\n    otv->vacancy_down = td->table_vacancy.vacancy_down;\n    otv->vacancy_up = td->table_vacancy.vacancy_up;\n    otv->vacancy = td->table_vacancy.vacancy;\n\n    otd = ofpbuf_at_assert(b, start_otd, sizeof *otd);\n    otd->length = htons(b->size - start_otd);\n    otd->table_id = td->table_id;\n    otd->config = ofputil_encode_table_config(OFPUTIL_TABLE_MISS_DEFAULT,\n                                              td->eviction, td->vacancy,\n                                              version);\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":440398,"func":"PHP_METHOD(Phar, unlinkArchive)\n{\n\tchar *fname, *error, *zname, *arch, *entry;\n\tsize_t fname_len;\n\tint zname_len, arch_len, entry_len;\n\tphar_archive_data *phar;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"p\", &fname, &fname_len) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (ZEND_SIZE_T_INT_OVFL(fname_len)) {\n\t\tRETURN_FALSE;\n\t}\n\tif (!fname_len) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown phar archive \\\"\\\"\");\n\t\treturn;\n\t}\n\n\tif (FAILURE == phar_open_from_filename(fname, (int)fname_len, NULL, 0, REPORT_ERRORS, &phar, &error)) {\n\t\tif (error) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown phar archive \\\"%s\\\": %s\", fname, error);\n\t\t\tefree(error);\n\t\t} else {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown phar archive \\\"%s\\\"\", fname);\n\t\t}\n\t\treturn;\n\t}\n\n\tzname = (char*)zend_get_executed_filename();\n\tzname_len = (int)strlen(zname);\n\n\tif (zname_len > 7 && !memcmp(zname, \"phar:\/\/\", 7) && SUCCESS == phar_split_fname(zname, zname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {\n\t\tif ((size_t)arch_len == fname_len && !memcmp(arch, fname, arch_len)) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar archive \\\"%s\\\" cannot be unlinked from within itself\", fname);\n\t\t\tefree(arch);\n\t\t\tefree(entry);\n\t\t\treturn;\n\t\t}\n\t\tefree(arch);\n\t\tefree(entry);\n\t}\n\n\tif (phar->is_persistent) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar archive \\\"%s\\\" is in phar.cache_list, cannot unlinkArchive()\", fname);\n\t\treturn;\n\t}\n\n\tif (phar->refcount) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar archive \\\"%s\\\" has open file handles or objects.  fclose() all file handles, and unset() all objects prior to calling unlinkArchive()\", fname);\n\t\treturn;\n\t}\n\n\tfname = estrndup(phar->fname, phar->fname_len);\n\n\t\/* invalidate phar cache *\/\n\tPHAR_G(last_phar) = NULL;\n\tPHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;\n\n\tphar_archive_delref(phar);\n\tunlink(fname);\n\tefree(fname);\n\tRETURN_TRUE;\n}","target":0,"code_token_length":612,"total_token_length":848,"max_tokens_setting":1024}
+{"idx":401355,"func":"static int rxrpc_krb5_decode_tagged_data(struct krb5_tagged_data *td,\n\t\t\t\t\t size_t max_data_size,\n\t\t\t\t\t const __be32 **_xdr,\n\t\t\t\t\t unsigned int *_toklen)\n{\n\tconst __be32 *xdr = *_xdr;\n\tunsigned int toklen = *_toklen, len, paddedlen;\n\n\t\/* there must be at least one tag and one length word *\/\n\tif (toklen <= 8)\n\t\treturn -EINVAL;\n\n\t_enter(\",%zu,{%x,%x},%u\",\n\t       max_data_size, ntohl(xdr[0]), ntohl(xdr[1]), toklen);\n\n\ttd->tag = ntohl(*xdr++);\n\tlen = ntohl(*xdr++);\n\ttoklen -= 8;\n\tif (len > max_data_size)\n\t\treturn -EINVAL;\n\tpaddedlen = (len + 3) & ~3;\n\tif (paddedlen > toklen)\n\t\treturn -EINVAL;\n\ttd->data_len = len;\n\n\tif (len > 0) {\n\t\ttd->data = kmemdup(xdr, len, GFP_KERNEL);\n\t\tif (!td->data)\n\t\t\treturn -ENOMEM;\n\t\ttoklen -= paddedlen;\n\t\txdr += paddedlen >> 2;\n\t}\n\n\t_debug(\"tag %x len %x\", td->tag, td->data_len);\n\n\t*_xdr = xdr;\n\t*_toklen = toklen;\n\t_leave(\" = 0 [toklen=%u]\", toklen);\n\treturn 0;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":127226,"func":"posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,\n\t\t   void *buffer, size_t size)\n{\n\tposix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer;\n\tposix_acl_xattr_entry *ext_entry;\n\tint real_size, n;\n\n\treal_size = posix_acl_xattr_size(acl->a_count);\n\tif (!buffer)\n\t\treturn real_size;\n\tif (real_size > size)\n\t\treturn -ERANGE;\n\n\text_entry = ext_acl->a_entries;\n\text_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);\n\n\tfor (n=0; n < acl->a_count; n++, ext_entry++) {\n\t\tconst struct posix_acl_entry *acl_e = &acl->a_entries[n];\n\t\text_entry->e_tag  = cpu_to_le16(acl_e->e_tag);\n\t\text_entry->e_perm = cpu_to_le16(acl_e->e_perm);\n\t\tswitch(acl_e->e_tag) {\n\t\tcase ACL_USER:\n\t\t\text_entry->e_id =\n\t\t\t\tcpu_to_le32(from_kuid(user_ns, acl_e->e_uid));\n\t\t\tbreak;\n\t\tcase ACL_GROUP:\n\t\t\text_entry->e_id =\n\t\t\t\tcpu_to_le32(from_kgid(user_ns, acl_e->e_gid));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\text_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn real_size;\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":220443,"func":"aspath_str2aspath (const char *str)\n{\n  enum as_token token = as_token_unknown;\n  u_short as_type;\n  u_long asno = 0;\n  struct aspath *aspath;\n  int needtype;\n\n  aspath = aspath_new ();\n\n  \/* We start default type as AS_SEQUENCE. *\/\n  as_type = AS_SEQUENCE;\n  needtype = 1;\n\n  while ((str = aspath_gettoken (str, &token, &asno)) != NULL)\n    {\n      switch (token)\n\t{\n\tcase as_token_asval:\n\t  if (needtype)\n\t    {\n\t      aspath_segment_add (aspath, as_type);\n\t      needtype = 0;\n\t    }\n\t  aspath_as_add (aspath, asno);\n\t  break;\n\tcase as_token_set_start:\n\t  as_type = AS_SET;\n\t  aspath_segment_add (aspath, as_type);\n\t  needtype = 0;\n\t  break;\n\tcase as_token_set_end:\n\t  as_type = AS_SEQUENCE;\n\t  needtype = 1;\n\t  break;\n\tcase as_token_confed_seq_start:\n\t  as_type = AS_CONFED_SEQUENCE;\n\t  aspath_segment_add (aspath, as_type);\n\t  needtype = 0;\n\t  break;\n\tcase as_token_confed_seq_end:\n\t  as_type = AS_SEQUENCE;\n\t  needtype = 1;\n\t  break;\n\tcase as_token_confed_set_start:\n\t  as_type = AS_CONFED_SET;\n\t  aspath_segment_add (aspath, as_type);\n\t  needtype = 0;\n\t  break;\n\tcase as_token_confed_set_end:\n\t  as_type = AS_SEQUENCE;\n\t  needtype = 1;\n\t  break;\n\tcase as_token_unknown:\n\tdefault:\n\t  aspath_free (aspath);\n\t  return NULL;\n\t}\n    }\n\n  aspath_make_str_count (aspath);\n\n  return aspath;\n}\n","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":108433,"func":"int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out,\n                            word32* outLen)\n{\n    int    ret = MP_OKAY;\n    word32 numlen;\n#ifndef WOLFSSL_ATECC508A\n#ifdef WOLFSSL_SMALL_STACK\n    byte*  buf;\n#else\n    byte   buf[ECC_BUFSIZE];\n#endif\n#endif \/* !WOLFSSL_ATECC508A *\/\n\n    if ((curve_idx < 0) || (wc_ecc_is_valid_idx(curve_idx) == 0))\n        return ECC_BAD_ARG_E;\n\n    \/* return length needed only *\/\n    if (point != NULL && out == NULL && outLen != NULL) {\n        numlen = ecc_sets[curve_idx].size;\n        *outLen = 1 + 2*numlen;\n        return LENGTH_ONLY_E;\n    }\n\n    if (point == NULL || out == NULL || outLen == NULL)\n        return ECC_BAD_ARG_E;\n\n    numlen = ecc_sets[curve_idx].size;\n\n    if (*outLen < (1 + 2*numlen)) {\n        *outLen = 1 + 2*numlen;\n        return BUFFER_E;\n    }\n\n#ifdef WOLFSSL_ATECC508A\n   \/* TODO: Implement equiv call to ATECC508A *\/\n   ret = BAD_COND_E;\n\n#else\n\n    \/* store byte point type *\/\n    out[0] = ECC_POINT_UNCOMP;\n\n#ifdef WOLFSSL_SMALL_STACK\n    buf = (byte*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_ECC_BUFFER);\n    if (buf == NULL)\n        return MEMORY_E;\n#endif\n\n    \/* pad and store x *\/\n    XMEMSET(buf, 0, ECC_BUFSIZE);\n    ret = mp_to_unsigned_bin(point->x, buf +\n                                 (numlen - mp_unsigned_bin_size(point->x)));\n    if (ret != MP_OKAY)\n        goto done;\n    XMEMCPY(out+1, buf, numlen);\n\n    \/* pad and store y *\/\n    XMEMSET(buf, 0, ECC_BUFSIZE);\n    ret = mp_to_unsigned_bin(point->y, buf +\n                                 (numlen - mp_unsigned_bin_size(point->y)));\n    if (ret != MP_OKAY)\n        goto done;\n    XMEMCPY(out+1+numlen, buf, numlen);\n\n    *outLen = 1 + 2*numlen;\n\ndone:\n#ifdef WOLFSSL_SMALL_STACK\n    XFREE(buf, NULL, DYNAMIC_TYPE_ECC_BUFFER);\n#endif\n#endif \/* WOLFSSL_ATECC508A *\/\n\n    return ret;\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":233018,"func":"mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)\n{\n\tstruct mem_cgroup *memcg, *parent;\n\tlong error = -ENOMEM;\n\tint node;\n\n\tmemcg = mem_cgroup_alloc();\n\tif (!memcg)\n\t\treturn ERR_PTR(error);\n\n\tfor_each_node(node)\n\t\tif (alloc_mem_cgroup_per_zone_info(memcg, node))\n\t\t\tgoto free_out;\n\n\t\/* root ? *\/\n\tif (cont->parent == NULL) {\n\t\tint cpu;\n\t\tenable_swap_cgroup();\n\t\tparent = NULL;\n\t\tif (mem_cgroup_soft_limit_tree_init())\n\t\t\tgoto free_out;\n\t\troot_mem_cgroup = memcg;\n\t\tfor_each_possible_cpu(cpu) {\n\t\t\tstruct memcg_stock_pcp *stock =\n\t\t\t\t\t\t&per_cpu(memcg_stock, cpu);\n\t\t\tINIT_WORK(&stock->work, drain_local_stock);\n\t\t}\n\t\thotcpu_notifier(memcg_cpu_hotplug_callback, 0);\n\t} else {\n\t\tparent = mem_cgroup_from_cont(cont->parent);\n\t\tmemcg->use_hierarchy = parent->use_hierarchy;\n\t\tmemcg->oom_kill_disable = parent->oom_kill_disable;\n\t}\n\n\tif (parent && parent->use_hierarchy) {\n\t\tres_counter_init(&memcg->res, &parent->res);\n\t\tres_counter_init(&memcg->memsw, &parent->memsw);\n\t\t\/*\n\t\t * We increment refcnt of the parent to ensure that we can\n\t\t * safely access it on res_counter_charge\/uncharge.\n\t\t * This refcnt will be decremented when freeing this\n\t\t * mem_cgroup(see mem_cgroup_put).\n\t\t *\/\n\t\tmem_cgroup_get(parent);\n\t} else {\n\t\tres_counter_init(&memcg->res, NULL);\n\t\tres_counter_init(&memcg->memsw, NULL);\n\t}\n\tmemcg->last_scanned_node = MAX_NUMNODES;\n\tINIT_LIST_HEAD(&memcg->oom_notify);\n\n\tif (parent)\n\t\tmemcg->swappiness = mem_cgroup_swappiness(parent);\n\tatomic_set(&memcg->refcnt, 1);\n\tmemcg->move_charge_at_immigrate = 0;\n\tmutex_init(&memcg->thresholds_lock);\n\treturn &memcg->css;\nfree_out:\n\t__mem_cgroup_free(memcg);\n\treturn ERR_PTR(error);\n}\n","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":182129,"func":"void DemangleSymbols(std::string* text) {\n\n#if defined(__GLIBCXX__) && !defined(__UCLIBC__)\n\n  std::string::size_type search_from = 0;\n  while (search_from < text->size()) {\n    std::string::size_type mangled_start =\n        text->find(kMangledSymbolPrefix, search_from);\n    if (mangled_start == std::string::npos) {\n      break;  \/\/ Mangled symbol not found.\n    }\n\n    std::string::size_type mangled_end =\n        text->find_first_not_of(kSymbolCharacters, mangled_start);\n    if (mangled_end == std::string::npos) {\n      mangled_end = text->size();\n    }\n    std::string mangled_symbol =\n        text->substr(mangled_start, mangled_end - mangled_start);\n\n    int status = 0;\n    scoped_ptr<char, base::FreeDeleter> demangled_symbol(\n        abi::__cxa_demangle(mangled_symbol.c_str(), NULL, 0, &status));\n    if (status == 0) {  \/\/ Demangling is successful.\n      text->erase(mangled_start, mangled_end - mangled_start);\n      text->insert(mangled_start, demangled_symbol.get());\n      search_from = mangled_start + strlen(demangled_symbol.get());\n    } else {\n      search_from = mangled_start + 2;\n    }\n  }\n\n#endif  \/\/ defined(__GLIBCXX__) && !defined(__UCLIBC__)\n}\n","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":363852,"func":"\tif(currRefCount == 0)\n\t{\n\t\t\/* DEV Debugging Only! dbgprintf(\"msgDestruct\\t0x%lx, RefCount now 0, doing DESTROY\\n\", (unsigned long)pThis); *\/\n\t\tif(pThis->pszRawMsg != pThis->szRawMsg)\n\t\t\tfree(pThis->pszRawMsg);\n\t\tfreeTAG(pThis);\n\t\tfreeHOSTNAME(pThis);\n\t\tif(pThis->pInputName != NULL)\n\t\t\tprop.Destruct(&pThis->pInputName);\n\t\tif((pThis->msgFlags & NEEDS_DNSRESOL) == 0) {\n\t\t\tif(pThis->rcvFrom.pRcvFrom != NULL)\n\t\t\t\tprop.Destruct(&pThis->rcvFrom.pRcvFrom);\n\t\t} else {\n\t\t\tfree(pThis->rcvFrom.pfrominet);\n\t\t}\n\t\tif(pThis->pRcvFromIP != NULL)\n\t\t\tprop.Destruct(&pThis->pRcvFromIP);\n\t\tfree(pThis->pszRcvdAt3164);\n\t\tfree(pThis->pszRcvdAt3339);\n\t\tfree(pThis->pszRcvdAt_MySQL);\n\t\tfree(pThis->pszRcvdAt_PgSQL);\n\t\tfree(pThis->pszTIMESTAMP_MySQL);\n\t\tfree(pThis->pszTIMESTAMP_PgSQL);\n\t\tif(pThis->pCSProgName != NULL)\n\t\t\trsCStrDestruct(&pThis->pCSProgName);\n\t\tif(pThis->pCSStrucData != NULL)\n\t\t\trsCStrDestruct(&pThis->pCSStrucData);\n\t\tif(pThis->pCSAPPNAME != NULL)\n\t\t\trsCStrDestruct(&pThis->pCSAPPNAME);\n\t\tif(pThis->pCSPROCID != NULL)\n\t\t\trsCStrDestruct(&pThis->pCSPROCID);\n\t\tif(pThis->pCSMSGID != NULL)\n\t\t\trsCStrDestruct(&pThis->pCSMSGID);\n#\tifndef HAVE_ATOMIC_BUILTINS\n\t\tMsgUnlock(pThis);\n# \tendif\n\t\tfuncDeleteMutex(pThis);\n\t\t\/* now we need to do our own optimization. Testing has shown that at least the glibc\n\t\t * malloc() subsystem returns memory to the OS far too late in our case. So we need\n\t\t * to help it a bit, by calling malloc_trim(), which will tell the alloc subsystem\n\t\t * to consolidate and return to the OS. We keep 128K for our use, as a safeguard\n\t\t * to too-frequent reallocs. But more importantly, we call this hook only every\n\t\t * 100,000 messages (which is an approximation, as we do not work with atomic\n\t\t * operations on the counter. --- rgerhards, 2009-06-22.\n\t\t *\/\n#\t\tif HAVE_MALLOC_TRIM\n\t\t{\t\/* standard C requires a new block for a new variable definition!\n\t\t\t * To simplify matters, we use modulo arithmetic and live with the fact\n\t\t\t * that we trim too often when the counter wraps.\n\t\t\t *\/\n\t\t\tstatic unsigned iTrimCtr = 1;\n\t\t\tcurrCnt = ATOMIC_INC_AND_FETCH_unsigned(&iTrimCtr, &mutTrimCtr);\n\t\t\tif(currCnt % 100000 == 0) {\n\t\t\t\tmalloc_trim(128*1024);\n\t\t\t}\n\t\t}\n#\t\tendif\n\t} else {","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":497911,"func":"static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    int ret;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    if ((uint64_t)atom.size > (1<<30))\n        return AVERROR_INVALIDDATA;\n\n    if (st->codecpar->codec_id == AV_CODEC_ID_QDM2 ||\n        st->codecpar->codec_id == AV_CODEC_ID_QDMC ||\n        st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {\n        \/\/ pass all frma atom to codec, needed at least for QDMC and QDM2\n        ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);\n        if (ret < 0)\n            return ret;\n    } else if (atom.size > 8) { \/* to read frma, esds atoms *\/\n        if (st->codecpar->codec_id == AV_CODEC_ID_ALAC && atom.size >= 24) {\n            uint64_t buffer;\n            ret = ffio_ensure_seekback(pb, 8);\n            if (ret < 0)\n                return ret;\n            buffer = avio_rb64(pb);\n            atom.size -= 8;\n            if (  (buffer & 0xFFFFFFFF) == MKBETAG('f','r','m','a')\n                && buffer >> 32 <= atom.size\n                && buffer >> 32 >= 8) {\n                avio_skip(pb, -8);\n                atom.size += 8;\n            } else if (!st->codecpar->extradata_size) {\n#define ALAC_EXTRADATA_SIZE 36\n                st->codecpar->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);\n                if (!st->codecpar->extradata)\n                    return AVERROR(ENOMEM);\n                st->codecpar->extradata_size = ALAC_EXTRADATA_SIZE;\n                AV_WB32(st->codecpar->extradata    , ALAC_EXTRADATA_SIZE);\n                AV_WB32(st->codecpar->extradata + 4, MKTAG('a','l','a','c'));\n                AV_WB64(st->codecpar->extradata + 12, buffer);\n                avio_read(pb, st->codecpar->extradata + 20, 16);\n                avio_skip(pb, atom.size - 24);\n                return 0;\n            }\n        }\n        if ((ret = mov_read_default(c, pb, atom)) < 0)\n            return ret;\n    } else\n        avio_skip(pb, atom.size);\n    return 0;\n}","target":0,"code_token_length":599,"total_token_length":835,"max_tokens_setting":1024}
+{"idx":323856,"func":"static int ram_save_iterate(QEMUFile *f, void *opaque)\n\n{\n\n    int ret;\n\n    int i;\n\n    int64_t t0;\n\n    int total_sent = 0;\n\n\n\n    qemu_mutex_lock_ramlist();\n\n\n\n    if (ram_list.version != last_version) {\n\n        reset_ram_globals();\n\n    }\n\n\n\n    ram_control_before_iterate(f, RAM_CONTROL_ROUND);\n\n\n\n    t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);\n\n    i = 0;\n\n    while ((ret = qemu_file_rate_limit(f)) == 0) {\n\n        int bytes_sent;\n\n\n\n        bytes_sent = ram_save_block(f, false);\n\n        \/* no more blocks to sent *\/\n\n        if (bytes_sent == 0) {\n\n            break;\n\n        }\n\n        total_sent += bytes_sent;\n\n        acct_info.iterations++;\n\n        check_guest_throttling();\n\n        \/* we want to check in the 1st loop, just in case it was the 1st time\n\n           and we had to sync the dirty bitmap.\n\n           qemu_get_clock_ns() is a bit expensive, so we only check each some\n\n           iterations\n\n        *\/\n\n        if ((i & 63) == 0) {\n\n            uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) \/ 1000000;\n\n            if (t1 > MAX_WAIT) {\n\n                DPRINTF(\"big wait: %\" PRIu64 \" milliseconds, %d iterations\\n\",\n\n                        t1, i);\n\n                break;\n\n            }\n\n        }\n\n        i++;\n\n    }\n\n\n\n    qemu_mutex_unlock_ramlist();\n\n\n\n    \/*\n\n     * Must occur before EOS (or any QEMUFile operation)\n\n     * because of RDMA protocol.\n\n     *\/\n\n    ram_control_after_iterate(f, RAM_CONTROL_ROUND);\n\n\n\n    if (ret < 0) {\n\n        bytes_transferred += total_sent;\n\n        return ret;\n\n    }\n\n\n\n    qemu_put_be64(f, RAM_SAVE_FLAG_EOS);\n\n    total_sent += 8;\n\n    bytes_transferred += total_sent;\n\n\n\n    return total_sent;\n\n}\n","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":17438,"func":"gpg_error_t keydb_search ( KEYDB_HANDLE hd , KEYDB_SEARCH_DESC * desc , size_t ndesc , size_t * descindex ) {\n gpg_error_t rc ;\n if ( descindex ) * descindex = 0 ;\n if ( ! hd ) return gpg_error ( GPG_ERR_INV_ARG ) ;\n if ( DBG_CLOCK ) log_clock ( \"keydb_search enter\" ) ;\n if ( DBG_CACHE ) dump_search_desc ( hd , \"keydb_search\" , desc , ndesc ) ;\n if ( ! hd -> no_caching && ndesc == 1 && ( desc [ 0 ] . mode == KEYDB_SEARCH_MODE_FPR20 || desc [ 0 ] . mode == KEYDB_SEARCH_MODE_FPR ) && keyblock_cache . state == KEYBLOCK_CACHE_FILLED && ! memcmp ( keyblock_cache . fpr , desc [ 0 ] . u . fpr , 20 ) ) {\n if ( DBG_CLOCK ) log_clock ( \"keydb_search leave (cached)\" ) ;\n return 0 ;\n }\n rc = - 1 ;\n while ( ( rc == - 1 || gpg_err_code ( rc ) == GPG_ERR_EOF ) && hd -> current >= 0 && hd -> current < hd -> used ) {\n switch ( hd -> active [ hd -> current ] . type ) {\n case KEYDB_RESOURCE_TYPE_NONE : BUG ( ) ;\n break ;\n case KEYDB_RESOURCE_TYPE_KEYRING : rc = keyring_search ( hd -> active [ hd -> current ] . u . kr , desc , ndesc , descindex ) ;\n break ;\n case KEYDB_RESOURCE_TYPE_KEYBOX : rc = keybox_search ( hd -> active [ hd -> current ] . u . kb , desc , ndesc , KEYBOX_BLOBTYPE_PGP , descindex , & hd -> skipped_long_blobs ) ;\n break ;\n }\n if ( rc == - 1 || gpg_err_code ( rc ) == GPG_ERR_EOF ) {\n hd -> current ++ ;\n }\n else if ( ! rc ) hd -> found = hd -> current ;\n }\n rc = ( ( rc == - 1 || gpg_err_code ( rc ) == GPG_ERR_EOF ) ? gpg_error ( GPG_ERR_NOT_FOUND ) : rc ) ;\n keyblock_cache_clear ( ) ;\n if ( ! hd -> no_caching && ! rc && ndesc == 1 && ( desc [ 0 ] . mode == KEYDB_SEARCH_MODE_FPR20 || desc [ 0 ] . mode == KEYDB_SEARCH_MODE_FPR ) ) {\n keyblock_cache . state = KEYBLOCK_CACHE_PREPARED ;\n memcpy ( keyblock_cache . fpr , desc [ 0 ] . u . fpr , 20 ) ;\n }\n if ( DBG_CLOCK ) log_clock ( rc ? \"keydb_search leave (not found)\" : \"keydb_search leave (found)\" ) ;\n return rc ;\n }","target":0,"code_token_length":596,"total_token_length":832,"max_tokens_setting":1024}
+{"idx":66867,"func":"int sfgets(void)\n{\n    struct pollfd pfd;\n    int pollret;\n    ssize_t readnb;\n    signed char seen_r = 0;\n    \n    if (scanned > (size_t) 0U) {       \/* support pipelining *\/\n        readnbd -= scanned;        \n        memmove(cmd, cmd + scanned, readnbd);   \/* safe *\/\n        scanned = (size_t) 0U;\n    }\n    pfd.fd = clientfd;\n#ifdef __APPLE_CC__\n    pfd.events = POLLIN | POLLERR | POLLHUP;\n#else\n    pfd.events = POLLIN | POLLPRI | POLLERR | POLLHUP;\n#endif\n    while (scanned < cmdsize) {\n        if (scanned >= readnbd) {      \/* nothing left in the buffer *\/\n            pfd.revents = 0;\n            while ((pollret = poll(&pfd, 1U, idletime * 1000UL)) < 0 &&\n                   errno == EINTR);\n            if (pollret == 0) {\n                return -1;\n            }\n            if (pollret <= 0 ||\n                (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {\n                return -2;\n            }\n            if ((pfd.revents & (POLLIN | POLLPRI)) == 0) {\n                continue;\n            }\n            if (readnbd >= cmdsize) {\n                break;\n            }\n#ifdef WITH_TLS\n            if (tls_cnx != NULL) {\n                while ((readnb = SSL_read\n                        (tls_cnx, cmd + readnbd, cmdsize - readnbd))\n                       < (ssize_t) 0 && errno == EINTR);\n            } else\n#endif\n            {\n                while ((readnb = read(clientfd, cmd + readnbd,\n                                      cmdsize - readnbd)) < (ssize_t) 0 &&\n                       errno == EINTR);\n            }\n            if (readnb <= (ssize_t) 0) {\n                return -2;\n            }\n            readnbd += readnb;\n            if (readnbd > cmdsize) {\n                return -2;\n            }\n        }\n#ifdef RFC_CONFORMANT_LINES\n        if (seen_r != 0) {\n#endif\n            if (cmd[scanned] == '\\n') {\n#ifndef RFC_CONFORMANT_LINES\n                if (seen_r != 0) {\n#endif\n                    cmd[scanned - 1U] = 0;\n#ifndef RFC_CONFORMANT_LINES\n                } else {\n                    cmd[scanned] = 0;\n                }\n#endif\n                if (++scanned >= readnbd) {   \/* non-pipelined command *\/\n                    scanned = readnbd = (size_t) 0U;\n                }\n                return 0;\n            }\n            seen_r = 0;\n#ifdef RFC_CONFORMANT_LINES\n        }\n#endif\n        if (ISCTRLCODE(cmd[scanned])) {\n            if (cmd[scanned] == '\\r') {\n                seen_r = 1;\n            }\n#ifdef RFC_CONFORMANT_PARSER                   \/* disabled by default, intentionnaly *\/\n            else if (cmd[scanned] == 0) {\n                cmd[scanned] = '\\n';\n            }\n#else\n            \/* replace control chars with _ *\/\n            cmd[scanned] = '_';                \n#endif\n        }\n        scanned++;\n    }\n    die(421, LOG_WARNING, MSG_LINE_TOO_LONG);   \/* don't remove this *\/\n    \n    return 0;                         \/* to please GCC *\/\n}","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":366258,"func":"static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,\n\t\t\t   struct mm_walk *walk)\n{\n\tstruct mem_size_stats *mss = walk->private;\n\tstruct vm_area_struct *vma = mss->vma;\n\tpte_t *pte;\n\tspinlock_t *ptl;\n\n\tspin_lock(&walk->mm->page_table_lock);\n\tif (pmd_trans_huge(*pmd)) {\n\t\tif (pmd_trans_splitting(*pmd)) {\n\t\t\tspin_unlock(&walk->mm->page_table_lock);\n\t\t\twait_split_huge_page(vma->anon_vma, pmd);\n\t\t} else {\n\t\t\tsmaps_pte_entry(*(pte_t *)pmd, addr,\n\t\t\t\t\tHPAGE_PMD_SIZE, walk);\n\t\t\tspin_unlock(&walk->mm->page_table_lock);\n\t\t\tmss->anonymous_thp += HPAGE_PMD_SIZE;\n\t\t\treturn 0;\n\t\t}\n\t} else {\n\t\tspin_unlock(&walk->mm->page_table_lock);\n\t}\n\n\tif (pmd_trans_unstable(pmd))\n\t\treturn 0;\n\t\/*\n\t * The mmap_sem held all the way back in m_start() is what\n\t * keeps khugepaged out of here and from collapsing things\n\t * in here.\n\t *\/\n\tpte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);\n\tfor (; addr != end; pte++, addr += PAGE_SIZE)\n\t\tsmaps_pte_entry(*pte, addr, PAGE_SIZE, walk);\n\tpte_unmap_unlock(pte - 1, ptl);\n\tcond_resched();\n\treturn 0;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":144526,"func":"void mips_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,\n\n                         int flags)\n\n{\n\n    MIPSCPU *cpu = MIPS_CPU(cs);\n\n    CPUMIPSState *env = &cpu->env;\n\n    int i;\n\n\n\n    cpu_fprintf(f, \"pc=0x\" TARGET_FMT_lx \" HI=0x\" TARGET_FMT_lx\n\n                \" LO=0x\" TARGET_FMT_lx \" ds %04x \"\n\n                TARGET_FMT_lx \" \" TARGET_FMT_ld \"\\n\",\n\n                env->active_tc.PC, env->active_tc.HI[0], env->active_tc.LO[0],\n\n                env->hflags, env->btarget, env->bcond);\n\n    for (i = 0; i < 32; i++) {\n\n        if ((i & 3) == 0)\n\n            cpu_fprintf(f, \"GPR%02d:\", i);\n\n        cpu_fprintf(f, \" %s \" TARGET_FMT_lx, regnames[i], env->active_tc.gpr[i]);\n\n        if ((i & 3) == 3)\n\n            cpu_fprintf(f, \"\\n\");\n\n    }\n\n\n\n    cpu_fprintf(f, \"CP0 Status  0x%08x Cause   0x%08x EPC    0x\" TARGET_FMT_lx \"\\n\",\n\n                env->CP0_Status, env->CP0_Cause, env->CP0_EPC);\n\n    cpu_fprintf(f, \"    Config0 0x%08x Config1 0x%08x LLAddr 0x%016\"\n\n                PRIx64 \"\\n\",\n\n                env->CP0_Config0, env->CP0_Config1, env->lladdr);\n\n    cpu_fprintf(f, \"    Config2 0x%08x Config3 0x%08x\\n\",\n\n                env->CP0_Config2, env->CP0_Config3);\n\n    cpu_fprintf(f, \"    Config4 0x%08x Config5 0x%08x\\n\",\n\n                env->CP0_Config4, env->CP0_Config5);\n\n    if (env->hflags & MIPS_HFLAG_FPU)\n\n        fpu_dump_state(env, f, cpu_fprintf, flags);\n\n#if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)\n\n    cpu_mips_check_sign_extensions(env, f, cpu_fprintf, flags);\n\n#endif\n\n}\n","target":1,"code_token_length":529,"total_token_length":765,"max_tokens_setting":1024}
+{"idx":364694,"func":"static int parserange(char *str, uint32_t *uid, uint32_t *last,\n\t\t      char **msgid, struct backend **ret)\n{\n    const char *p = NULL;\n    char *mboxname;\n    int r = 0;\n\n    *uid = 0;\n    if (last) *last = 0;\n    if (msgid) *msgid = NULL;\n    if (ret) *ret = NULL;\n\n    if (!str || !*str) {\n\t\/* no argument, use current article *\/\n\tif (backend_current) {\n\t    if (ret) *ret = backend_current;\n\t}\n\telse if (!group_state) goto noopengroup;\n\telse if (!nntp_current) goto nocurrent;\n\telse {\n\t    *uid = index_getuid(group_state, nntp_current);\n\t    if (last) *last = *uid;\n\t}\n    }\n    else if (*str == '<') {\n\t\/* message-id, find server and\/or mailbox *\/\n\tif (!msgid) goto badrange;\n\tif (!find_msgid(str, &mboxname, uid)) goto nomsgid;\n\n\t*msgid = str;\n\n\t\/* open group if its different from our current one *\/\n\tif (!group_state || strcmp(mboxname, group_state->mailbox->name)) {\n\t    if ((r = open_group(mboxname, 1, ret, NULL))) goto nomsgid;\n\t}\n    }\n    else if (backend_current)\n\t*ret = backend_current;\n    else if (!group_state) goto noopengroup;\n    else if (parseuint32(str, &p, uid) || uid == 0) goto badrange;\n    else if (p && *p) {\n\t\/* extra stuff, check for range *\/\n\tif (!last || (*p != '-')) goto badrange;\n\tif (*++p) {\n\t    if (parseuint32(p, NULL, last))\n\t\t*last = 0;\n\t}\n\telse\n\t    *last = UINT32_MAX;  \/* open range -> use highest possible UID *\/\n    }\n\n    if (last && !*last) *last = *uid;\n\n    return 0;\n\n  noopengroup:\n    prot_printf(nntp_out, \"412 No newsgroup selected\\r\\n\");\n    return -1;\n\n  nocurrent:\n    prot_printf(nntp_out, \"420 Current article number is invalid\\r\\n\");\n    return -1;\n\n  nomsgid:\n    prot_printf(nntp_out, \"430 No article found with that message-id\");\n    if (r) prot_printf(nntp_out, \" (%s)\", error_message(r));\n    prot_printf(nntp_out, \"\\r\\n\");\n    return -1;\n\n  badrange:\n    prot_printf(nntp_out, \"501 Bad message-id, message number, or range\\r\\n\");\n    return -1;\n}","target":0,"code_token_length":598,"total_token_length":834,"max_tokens_setting":1024}
+{"idx":286208,"func":"static uint64_t xhci_oper_read(void *ptr, hwaddr reg, unsigned size)\n{\n    XHCIState *xhci = ptr;\n    uint32_t ret;\n\n    switch (reg) {\n    case 0x00: \/* USBCMD *\/\n        ret = xhci->usbcmd;\n        break;\n    case 0x04: \/* USBSTS *\/\n        ret = xhci->usbsts;\n        break;\n    case 0x08: \/* PAGESIZE *\/\n        ret = 1; \/* 4KiB *\/\n        break;\n    case 0x14: \/* DNCTRL *\/\n        ret = xhci->dnctrl;\n        break;\n    case 0x18: \/* CRCR low *\/\n        ret = xhci->crcr_low & ~0xe;\n        break;\n    case 0x1c: \/* CRCR high *\/\n        ret = xhci->crcr_high;\n        break;\n    case 0x30: \/* DCBAAP low *\/\n        ret = xhci->dcbaap_low;\n        break;\n    case 0x34: \/* DCBAAP high *\/\n        ret = xhci->dcbaap_high;\n        break;\n    case 0x38: \/* CONFIG *\/\n        ret = xhci->config;\n        break;\n    default:\n        trace_usb_xhci_unimplemented(\"oper read\", reg);\n        ret = 0;\n    }\n\n    trace_usb_xhci_oper_read(reg, ret);\n    return ret;\n}\n","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":334726,"func":"static void handle_notify(EventNotifier *e)\n\n{\n\n    VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane,\n\n                                           host_notifier);\n\n\n\n    VirtQueueElement *elem;\n\n    VirtIOBlockReq *req;\n\n    int ret;\n\n    MultiReqBuffer mrb = {\n\n        .num_writes = 0,\n\n    };\n\n\n\n    event_notifier_test_and_clear(&s->host_notifier);\n\n    bdrv_io_plug(s->blk->conf.bs);\n\n    for (;;) {\n\n        \/* Disable guest->host notifies to avoid unnecessary vmexits *\/\n\n        vring_disable_notification(s->vdev, &s->vring);\n\n\n\n        for (;;) {\n\n            ret = vring_pop(s->vdev, &s->vring, &elem);\n\n            if (ret < 0) {\n\n                assert(elem == NULL);\n\n                break; \/* no more requests *\/\n\n            }\n\n\n\n            trace_virtio_blk_data_plane_process_request(s, elem->out_num,\n\n                                                        elem->in_num, elem->index);\n\n\n\n            req = g_slice_new(VirtIOBlockReq);\n\n            req->dev = VIRTIO_BLK(s->vdev);\n\n            req->elem = elem;\n\n            virtio_blk_handle_request(req, &mrb);\n\n        }\n\n\n\n        virtio_submit_multiwrite(s->blk->conf.bs, &mrb);\n\n\n\n        if (likely(ret == -EAGAIN)) { \/* vring emptied *\/\n\n            \/* Re-enable guest->host notifies and stop processing the vring.\n\n             * But if the guest has snuck in more descriptors, keep processing.\n\n             *\/\n\n            if (vring_enable_notification(s->vdev, &s->vring)) {\n\n                break;\n\n            }\n\n        } else { \/* fatal error *\/\n\n            break;\n\n        }\n\n    }\n\n    bdrv_io_unplug(s->blk->conf.bs);\n\n}\n","target":1,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":500149,"func":"ArgParser::argEncrypt()\n{\n    ++cur_arg;\n    if (cur_arg + 3 > argc)\n    {\n        if (this->bash_completion)\n        {\n            if (cur_arg == argc)\n            {\n                this->completions.insert(\"user-password\");\n            }\n            else if (cur_arg + 1 == argc)\n            {\n                this->completions.insert(\"owner-password\");\n            }\n            else if (cur_arg + 2 == argc)\n            {\n                this->completions.insert(\"40\");\n                this->completions.insert(\"128\");\n                this->completions.insert(\"256\");\n            }\n            return;\n        }\n        else\n        {\n            usage(\"insufficient arguments to --encrypt\");\n        }\n    }\n    o.user_password = argv[cur_arg++];\n    o.owner_password = argv[cur_arg++];\n    std::string len_str = argv[cur_arg];\n    if (len_str == \"40\")\n    {\n\to.keylen = 40;\n        this->option_table = &(this->encrypt40_option_table);\n    }\n    else if (len_str == \"128\")\n    {\n\to.keylen = 128;\n        this->option_table = &(this->encrypt128_option_table);\n    }\n    else if (len_str == \"256\")\n    {\n\to.keylen = 256;\n        o.use_aes = true;\n        this->option_table = &(this->encrypt256_option_table);\n    }\n    else\n    {\n\tusage(\"encryption key length must be 40, 128, or 256\");\n    }\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":460425,"func":"static bool mt_need_to_apply_feature(struct hid_device *hdev,\n\t\t\t\t     struct hid_field *field,\n\t\t\t\t     struct hid_usage *usage,\n\t\t\t\t     enum latency_mode latency,\n\t\t\t\t     bool surface_switch,\n\t\t\t\t     bool button_switch,\n\t\t\t\t     bool *inputmode_found)\n{\n\tstruct mt_device *td = hid_get_drvdata(hdev);\n\tstruct mt_class *cls = &td->mtclass;\n\tstruct hid_report *report = field->report;\n\tunsigned int index = usage->usage_index;\n\tchar *buf;\n\tu32 report_len;\n\tint max;\n\n\tswitch (usage->hid) {\n\tcase HID_DG_INPUTMODE:\n\t\t\/*\n\t\t * Some elan panels wrongly declare 2 input mode features,\n\t\t * and silently ignore when we set the value in the second\n\t\t * field. Skip the second feature and hope for the best.\n\t\t *\/\n\t\tif (*inputmode_found)\n\t\t\treturn false;\n\n\t\tif (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) {\n\t\t\treport_len = hid_report_len(report);\n\t\t\tbuf = hid_alloc_report_buf(report, GFP_KERNEL);\n\t\t\tif (!buf) {\n\t\t\t\thid_err(hdev,\n\t\t\t\t\t\"failed to allocate buffer for report\\n\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thid_hw_raw_request(hdev, report->id, buf, report_len,\n\t\t\t\t\t   HID_FEATURE_REPORT,\n\t\t\t\t\t   HID_REQ_GET_REPORT);\n\t\t\tkfree(buf);\n\t\t}\n\n\t\tfield->value[index] = td->inputmode_value;\n\t\t*inputmode_found = true;\n\t\treturn true;\n\n\tcase HID_DG_CONTACTMAX:\n\t\tif (cls->maxcontacts) {\n\t\t\tmax = min_t(int, field->logical_maximum,\n\t\t\t\t    cls->maxcontacts);\n\t\t\tif (field->value[index] != max) {\n\t\t\t\tfield->value[index] = max;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase HID_DG_LATENCYMODE:\n\t\tfield->value[index] = latency;\n\t\treturn true;\n\n\tcase HID_DG_SURFACESWITCH:\n\t\tfield->value[index] = surface_switch;\n\t\treturn true;\n\n\tcase HID_DG_BUTTONSWITCH:\n\t\tfield->value[index] = button_switch;\n\t\treturn true;\n\t}\n\n\treturn false; \/* no need to update the report *\/\n}","target":0,"code_token_length":460,"total_token_length":696,"max_tokens_setting":1024}
+{"idx":240125,"func":"CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags)\n{\n    CMS_ContentInfo *cms;\n    int i;\n\n    cms = CMS_ContentInfo_new();\n    if (cms == NULL || !CMS_SignedData_init(cms))\n        goto merr;\n    if (flags & CMS_ASCIICRLF\n        && !CMS_set1_eContentType(cms,\n                                  OBJ_nid2obj(NID_id_ct_asciiTextWithCRLF)))\n        goto err;\n\n    if (pkey && !CMS_add1_signer(cms, signcert, pkey, NULL, flags)) {\n        CMSerr(CMS_F_CMS_SIGN, CMS_R_ADD_SIGNER_ERROR);\n        goto err;\n    }\n\n    for (i = 0; i < sk_X509_num(certs); i++) {\n        X509 *x = sk_X509_value(certs, i);\n        if (!CMS_add1_cert(cms, x))\n            goto merr;\n    }\n\n    if (!(flags & CMS_DETACHED))\n        CMS_set_detached(cms, 0);\n\n    if ((flags & (CMS_STREAM | CMS_PARTIAL))\n        || CMS_final(cms, data, NULL, flags))\n        return cms;\n    else\n        goto err;\n\n merr:\n    CMSerr(CMS_F_CMS_SIGN, ERR_R_MALLOC_FAILURE);\n\n err:\n    CMS_ContentInfo_free(cms);\n    return NULL;\n}\n","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":296776,"func":"sendAssociationRQTCP(PRIVATE_NETWORKKEY ** \/*network*\/,\n                     DUL_ASSOCIATESERVICEPARAMETERS * params,\n                     PRIVATE_ASSOCIATIONKEY ** association)\n{\n    PRV_ASSOCIATEPDU\n    associateRequest;\n    unsigned char\n        buffer[4096],\n       *b;\n    unsigned long\n        length;\n    int\n        nbytes;\n\n    OFBitmanipTemplate<char>::zeroMem((char *)&associateRequest, sizeof(PRV_ASSOCIATEPDU)); \/\/ initialize PDU\n    \/\/ associateRequest.presentationContextList = NULL;\n    OFCondition cond = constructAssociatePDU(params, DUL_TYPEASSOCIATERQ,\n                                 &associateRequest);\n    if (cond.bad())\n    {\n        DCMNET_ERROR(cond.text());\n        return cond;\n    }\n    if (associateRequest.length + 6 <= sizeof(buffer))\n        b = buffer;\n    else {\n        b = (unsigned char*)malloc(size_t(associateRequest.length + 6));\n        if (b == NULL)  return EC_MemoryExhausted;\n    }\n    cond = streamAssociatePDU(&associateRequest, b,\n                              associateRequest.length + 6, &length);\n\n    if ((*association)->associatePDUFlag)\n    {\n      \/\/ copy A-ASSOCIATE-RQ PDU\n      (*association)->associatePDU = new char[length];\n      if ((*association)->associatePDU)\n      {\n        memcpy((*association)->associatePDU, b, (size_t) length);\n        (*association)->associatePDULength = length;\n      }\n    }\n\n    destroyPresentationContextList(&associateRequest.presentationContextList);\n    destroyUserInformationLists(&associateRequest.userInfo);\n    if (cond.bad())\n        return cond;\n\n    do {\n      nbytes = (*association)->connection ? (*association)->connection->write((char*)b, size_t(associateRequest.length + 6)) : 0;\n    } while (nbytes == -1 && OFStandard::getLastNetworkErrorCode().value() == DCMNET_EINTR);\n    if ((unsigned long) nbytes != associateRequest.length + 6)\n    {\n      OFString msg = \"TCP I\/O Error (\";\n      msg += OFStandard::getLastNetworkErrorCode().message();\n      msg += \") occurred in routine: sendAssociationRQTCP\";\n      return makeDcmnetCondition(DULC_TCPIOERROR, OF_error, msg.c_str());\n    }\n    if (b != buffer) free(b);\n    return EC_Normal;\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":3822,"func":"ast2obj_excepthandler(void* _o)\n{\n    excepthandler_ty o = (excepthandler_ty)_o;\n    PyObject *result = NULL, *value = NULL;\n    if (!o) {\n        Py_INCREF(Py_None);\n        return Py_None;\n    }\n\n    switch (o->kind) {\n    case ExceptHandler_kind:\n        result = PyType_GenericNew(ExceptHandler_type, NULL, NULL);\n        if (!result) goto failed;\n        value = ast2obj_expr(o->v.ExceptHandler.type);\n        if (!value) goto failed;\n        if (_PyObject_SetAttrId(result, &PyId_type, value) == -1)\n            goto failed;\n        Py_DECREF(value);\n        value = ast2obj_identifier(o->v.ExceptHandler.name);\n        if (!value) goto failed;\n        if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)\n            goto failed;\n        Py_DECREF(value);\n        value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt);\n        if (!value) goto failed;\n        if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)\n            goto failed;\n        Py_DECREF(value);\n        break;\n    }\n    value = ast2obj_int(o->lineno);\n    if (!value) goto failed;\n    if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)\n        goto failed;\n    Py_DECREF(value);\n    value = ast2obj_int(o->col_offset);\n    if (!value) goto failed;\n    if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)\n        goto failed;\n    Py_DECREF(value);\n    return result;\nfailed:\n    Py_XDECREF(value);\n    Py_XDECREF(result);\n    return NULL;\n}","target":1,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":186344,"func":"void SyncManager::SyncInternal::EncryptDataTypes(\n    const syncable::ModelTypeSet& encrypted_types) {\n  DCHECK(initialized_);\n  VLOG(1) << \"Attempting to encrypt datatypes \"\n          << syncable::ModelTypeSetToString(encrypted_types);\n\n  WriteTransaction trans(FROM_HERE, GetUserShare());\n  WriteNode node(&trans);\n  if (!node.InitByTagLookup(kNigoriTag)) {\n    NOTREACHED() << \"Unable to set encrypted datatypes because Nigori node not \"\n                 << \"found.\";\n    return;\n  }\n\n  Cryptographer* cryptographer = trans.GetCryptographer();\n\n  if (!cryptographer->is_ready()) {\n    VLOG(1) << \"Attempting to encrypt datatypes when cryptographer not \"\n            << \"initialized, prompting for passphrase.\";\n    ObserverList<SyncManager::Observer> temp_obs_list;\n    CopyObservers(&temp_obs_list);\n    FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,\n                      OnPassphraseRequired(sync_api::REASON_DECRYPTION));\n    return;\n  }\n\n  cryptographer->SetEncryptedTypes(encrypted_types);\n  sync_pb::NigoriSpecifics nigori;\n  nigori.CopyFrom(node.GetNigoriSpecifics());\n  cryptographer->UpdateNigoriFromEncryptedTypes(&nigori);\n  node.SetNigoriSpecifics(nigori);\n  allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes());\n\n  ReEncryptEverything(&trans);\n  return;\n}\n","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":463842,"func":"int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,\n\t\t\t  struct btrfs_path *p, u64 time_seq)\n{\n\tstruct btrfs_fs_info *fs_info = root->fs_info;\n\tstruct extent_buffer *b;\n\tint slot;\n\tint ret;\n\tint err;\n\tint level;\n\tint lowest_unlock = 1;\n\tu8 lowest_level = 0;\n\n\tlowest_level = p->lowest_level;\n\tWARN_ON(p->nodes[0] != NULL);\n\n\tif (p->search_commit_root) {\n\t\tBUG_ON(time_seq);\n\t\treturn btrfs_search_slot(NULL, root, key, p, 0, 0);\n\t}\n\nagain:\n\tb = get_old_root(root, time_seq);\n\tif (!b) {\n\t\tret = -EIO;\n\t\tgoto done;\n\t}\n\tlevel = btrfs_header_level(b);\n\tp->locks[level] = BTRFS_READ_LOCK;\n\n\twhile (b) {\n\t\tint dec = 0;\n\n\t\tlevel = btrfs_header_level(b);\n\t\tp->nodes[level] = b;\n\n\t\t\/*\n\t\t * we have a lock on b and as long as we aren't changing\n\t\t * the tree, there is no way to for the items in b to change.\n\t\t * It is safe to drop the lock on our parent before we\n\t\t * go through the expensive btree search on b.\n\t\t *\/\n\t\tbtrfs_unlock_up_safe(p, level + 1);\n\n\t\tret = btrfs_bin_search(b, key, &slot);\n\t\tif (ret < 0)\n\t\t\tgoto done;\n\n\t\tif (level == 0) {\n\t\t\tp->slots[level] = slot;\n\t\t\tunlock_up(p, level, lowest_unlock, 0, NULL);\n\t\t\tgoto done;\n\t\t}\n\n\t\tif (ret && slot > 0) {\n\t\t\tdec = 1;\n\t\t\tslot--;\n\t\t}\n\t\tp->slots[level] = slot;\n\t\tunlock_up(p, level, lowest_unlock, 0, NULL);\n\n\t\tif (level == lowest_level) {\n\t\t\tif (dec)\n\t\t\t\tp->slots[level]++;\n\t\t\tgoto done;\n\t\t}\n\n\t\terr = read_block_for_search(root, p, &b, level, slot, key);\n\t\tif (err == -EAGAIN)\n\t\t\tgoto again;\n\t\tif (err) {\n\t\t\tret = err;\n\t\t\tgoto done;\n\t\t}\n\n\t\tlevel = btrfs_header_level(b);\n\t\tbtrfs_tree_read_lock(b);\n\t\tb = tree_mod_log_rewind(fs_info, p, b, time_seq);\n\t\tif (!b) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto done;\n\t\t}\n\t\tp->locks[level] = BTRFS_READ_LOCK;\n\t\tp->nodes[level] = b;\n\t}\n\tret = 1;\ndone:\n\tif (ret < 0)\n\t\tbtrfs_release_path(p);\n\n\treturn ret;\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":486399,"func":"checkRequestAgainstDataset(\n    T_DIMSE_C_StoreRQ *req,     \/* original store request *\/\n    const char* fname,          \/* filename of dataset *\/\n    DcmDataset *dataSet,        \/* dataset to check *\/\n    T_DIMSE_C_StoreRSP *rsp,    \/* final store response *\/\n    OFBool opt_correctUIDPadding)\n{\n    DcmFileFormat ff;\n    if (dataSet == NULL)\n    {\n      \/* load the data from file *\/\n      if (ff.loadFile(fname).bad())\n      {\n        OFLOG_ERROR(dcmpsrcvLogger, \"Cannot open file: \" << fname);\n        rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;\n        return;\n      }\n      dataSet = ff.getDataset();\n    }\n\n    \/* which SOP class and SOP instance ? *\/\n    DIC_UI sopClass;\n    DIC_UI sopInstance;\n\n    if (!DU_findSOPClassAndInstanceInDataSet(dataSet, sopClass, sopInstance, opt_correctUIDPadding))\n    {\n      OFLOG_ERROR(dcmpsrcvLogger, \"Bad image file: \" << fname);\n      rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand;\n    }\n    else if (strcmp(sopClass, req->AffectedSOPClassUID) != 0)\n    {\n      rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass;\n    }\n    else if (strcmp(sopInstance, req->AffectedSOPInstanceUID) != 0)\n    {\n      rsp->DimseStatus = STATUS_STORE_Error_DataSetDoesNotMatchSOPClass;\n    }\n    else if (strcmp(sopClass, UID_GrayscaleSoftcopyPresentationStateStorage) == 0)\n    {\n      \/* we have received a presentation state. Check if we can parse it! *\/\n      DcmPresentationState pstate;\n      if (EC_Normal != pstate.read(*dataSet))\n      {\n        OFLOG_ERROR(dcmpsrcvLogger, \"Grayscale softcopy presentation state object cannot be displayed - rejected\");\n        rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand;\n      }\n    }\n    return;\n}","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":13287,"func":"find_insert(png_const_charp what, png_charp param)\n{\n   png_uint_32 chunk = 0;\n   png_charp parameter_list[1024];\n int i, nparams;\n\n \/* Assemble the chunk name *\/\n for (i=0; i<4; ++i)\n {\n char ch = what[i];\n\n if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))\n         chunk = (chunk << 8) + what[i];\n\n else\n break;\n }\n\n if (i < 4 || what[4] != 0)\n {\n      fprintf(stderr, \"makepng --insert \\\"%s\\\": invalid chunk name\\n\", what);\n      exit(1);\n }\n\n \/* Assemble the parameter list. *\/\n   nparams = find_parameters(what, param, parameter_list, 1024);\n\n#  define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d))\n\n switch (chunk)\n {\n case CHUNK(105,67,67,80): \/* iCCP *\/\n if (nparams == 2)\n return make_insert(what, insert_iCCP, nparams, parameter_list);\n break;\n\n case CHUNK(116,69,88,116): \/* tEXt *\/\n if (nparams == 2)\n return make_insert(what, insert_tEXt, nparams, parameter_list);\n break;\n\n case CHUNK(122,84,88,116): \/* zTXt *\/\n if (nparams == 2)\n return make_insert(what, insert_zTXt, nparams, parameter_list);\n break;\n\n case CHUNK(105,84,88,116): \/* iTXt *\/\n if (nparams == 4)\n return make_insert(what, insert_iTXt, nparams, parameter_list);\n break;\n\n case CHUNK(104,73,83,84): \/* hIST *\/\n if (nparams <= 256)\n\n             return make_insert(what, insert_hIST, nparams, parameter_list);\n          break;\n \n #if 0\n       case CHUNK(115,80,76,84):  \/* sPLT *\/\n          return make_insert(what, insert_sPLT, nparams, parameter_list);\n#endif\n\n default:\n         fprintf(stderr, \"makepng --insert \\\"%s\\\": unrecognized chunk name\\n\",\n            what);\n         exit(1);\n }\n\n   bad_parameter_count(what, nparams);\n\n    return NULL;\n }\n","target":1,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":386220,"func":"xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {\n#ifdef XSLT_REFACTORED\n    xsltStyleItemVariablePtr comp;\n#else\n    xsltStylePreCompPtr comp;\n#endif\n\n    if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))\n\treturn;\n\n#ifdef XSLT_REFACTORED\n    comp = (xsltStyleItemVariablePtr)\n\txsltNewStylePreComp(style, XSLT_FUNC_VARIABLE);\n#else\n    comp = xsltNewStylePreComp(style, XSLT_FUNC_VARIABLE);\n#endif\n\n    if (comp == NULL)\n\treturn;\n\n    inst->psvi = comp;\n    comp->inst = inst;\n    \/*\n     * The full template resolution can be done statically\n     *\/\n\n    \/*\n    * Attribute \"name\".\n    *\/\n    xsltGetQNameProperty(style, inst, BAD_CAST \"name\",\n\t1, &(comp->has_name), &(comp->ns), &(comp->name));\n    if (comp->ns)\n\tcomp->has_ns = 1;\n    \/*\n    * Attribute \"select\".\n    *\/\n    comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)\"select\",\n\t                        XSLT_NAMESPACE);\n    if (comp->select != NULL) {\n#ifndef XSLT_REFACTORED\n        xmlNodePtr cur;\n#endif\n\tcomp->comp = xsltXPathCompile(style, comp->select);\n\tif (comp->comp == NULL) {\n\t    xsltTransformError(NULL, style, inst,\n\t\t\"XSLT-variable: Failed to compile the XPath expression '%s'.\\n\",\n\t\tcomp->select);\n\t    style->errors++;\n\t}\n#ifdef XSLT_REFACTORED\n\tif (inst->children != NULL) {\n\t    xsltTransformError(NULL, style, inst,\n\t\t\"XSLT-variable: There must be no child nodes, since the \"\n\t\t\"attribute 'select' was specified.\\n\");\n\t    style->errors++;\n\t}\n#else\n        for (cur = inst->children; cur != NULL; cur = cur->next) {\n            if (cur->type != XML_COMMENT_NODE &&\n                (cur->type != XML_TEXT_NODE || !xsltIsBlank(cur->content)))\n            {\n                xsltTransformError(NULL, style, inst,\n                    \"XSLT-variable: There must be no child nodes, since the \"\n                    \"attribute 'select' was specified.\\n\");\n                style->errors++;\n            }\n        }\n#endif\n    }\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":298020,"func":"    template<typename t>\n    CImg<T>& _LU(CImg<t>& indx, bool& d) {\n      const int N = width();\n      int imax = 0;\n      CImg<Tfloat> vv(N);\n      indx.assign(N);\n      d = true;\n\n      bool return0 = false;\n      cimg_pragma_openmp(parallel for cimg_openmp_if(_width*_height>=512))\n      cimg_forX(*this,i) {\n        Tfloat vmax = 0;\n        cimg_forX(*this,j) {\n          const Tfloat tmp = cimg::abs((*this)(j,i));\n          if (tmp>vmax) vmax = tmp;\n        }\n        if (vmax==0) return0 = true; else vv[i] = 1\/vmax;\n      }\n      if (return0) { indx.fill(0); return fill(0); }\n\n      cimg_forX(*this,j) {\n        for (int i = 0; i<j; ++i) {\n          Tfloat sum = (*this)(j,i);\n          for (int k = 0; k<i; ++k) sum-=(*this)(k,i)*(*this)(j,k);\n          (*this)(j,i) = (T)sum;\n        }\n\n        Tfloat vmax = 0;\n        for (int i = j; i<width(); ++i) {\n          Tfloat sum = (*this)(j,i);\n          for (int k = 0; k<j; ++k) sum-=(*this)(k,i)*(*this)(j,k);\n          (*this)(j,i) = (T)sum;\n          const Tfloat tmp = vv[i]*cimg::abs(sum);\n          if (tmp>=vmax) { vmax = tmp; imax = i; }\n        }\n        if (j!=imax) {\n          cimg_forX(*this,k) cimg::swap((*this)(k,imax),(*this)(k,j));\n          d = !d;\n          vv[imax] = vv[j];\n        }\n        indx[j] = (t)imax;\n        if ((*this)(j,j)==0) (*this)(j,j) = (T)1e-20;\n        if (j<N) {\n          const Tfloat tmp = 1\/(Tfloat)(*this)(j,j);\n          for (int i = j + 1; i<N; ++i) (*this)(j,i) = (T)((*this)(j,i)*tmp);\n        }\n      }\n\n      return *this;","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":321685,"func":"static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)\n\n{\n\n    CharDriverState *chr;\n\n    PtyCharDriver *s;\n\n    struct termios tty;\n\n    const char *label;\n\n    int master_fd, slave_fd, len;\n\n#if defined(__OpenBSD__) || defined(__DragonFly__)\n\n    char pty_name[PATH_MAX];\n\n#define q_ptsname(x) pty_name\n\n#else\n\n    char *pty_name = NULL;\n\n#define q_ptsname(x) ptsname(x)\n\n#endif\n\n\n\n    if (openpty(&master_fd, &slave_fd, pty_name, NULL, NULL) < 0) {\n\n        return NULL;\n\n    }\n\n\n\n    \/* Set raw attributes on the pty. *\/\n\n    tcgetattr(slave_fd, &tty);\n\n    cfmakeraw(&tty);\n\n    tcsetattr(slave_fd, TCSAFLUSH, &tty);\n\n    close(slave_fd);\n\n\n\n    chr = g_malloc0(sizeof(CharDriverState));\n\n\n\n    len = strlen(q_ptsname(master_fd)) + 5;\n\n    chr->filename = g_malloc(len);\n\n    snprintf(chr->filename, len, \"pty:%s\", q_ptsname(master_fd));\n\n    qemu_opt_set(opts, \"path\", q_ptsname(master_fd));\n\n\n\n    label = qemu_opts_id(opts);\n\n    fprintf(stderr, \"char device redirected to %s%s%s%s\\n\",\n\n            q_ptsname(master_fd),\n\n            label ? \" (label \" : \"\",\n\n            label ? label      : \"\",\n\n            label ? \")\"        : \"\");\n\n\n\n    s = g_malloc0(sizeof(PtyCharDriver));\n\n    chr->opaque = s;\n\n    chr->chr_write = pty_chr_write;\n\n    chr->chr_update_read_handler = pty_chr_update_read_handler;\n\n    chr->chr_close = pty_chr_close;\n\n    chr->chr_add_watch = pty_chr_add_watch;\n\n\n\n    s->fd = io_channel_from_fd(master_fd);\n\n    s->timer_tag = 0;\n\n\n\n    return chr;\n\n}\n","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":69236,"func":"static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags)\n{\n\tDECLARE_WAITQUEUE(wait, current);\n\tstruct sock *sk = sock->sk, *nsk;\n\tlong timeo;\n\tint err = 0;\n\n\tlock_sock(sk);\n\n\tif (sk->sk_type != SOCK_STREAM) {\n\t\terr = -EINVAL;\n\t\tgoto done;\n\t}\n\n\ttimeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);\n\n\tBT_DBG(\"sk %p timeo %ld\", sk, timeo);\n\n\t\/* Wait for an incoming connection. (wake-one). *\/\n\tadd_wait_queue_exclusive(sk_sleep(sk), &wait);\n\twhile (1) {\n\t\tset_current_state(TASK_INTERRUPTIBLE);\n\n\t\tif (sk->sk_state != BT_LISTEN) {\n\t\t\terr = -EBADFD;\n\t\t\tbreak;\n\t\t}\n\n\t\tnsk = bt_accept_dequeue(sk, newsock);\n\t\tif (nsk)\n\t\t\tbreak;\n\n\t\tif (!timeo) {\n\t\t\terr = -EAGAIN;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (signal_pending(current)) {\n\t\t\terr = sock_intr_errno(timeo);\n\t\t\tbreak;\n\t\t}\n\n\t\trelease_sock(sk);\n\t\ttimeo = schedule_timeout(timeo);\n\t\tlock_sock(sk);\n\t}\n\t__set_current_state(TASK_RUNNING);\n\tremove_wait_queue(sk_sleep(sk), &wait);\n\n\tif (err)\n\t\tgoto done;\n\n\tnewsock->state = SS_CONNECTED;\n\n\tBT_DBG(\"new socket %p\", nsk);\n\ndone:\n\trelease_sock(sk);\n\treturn err;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":210758,"func":"void mwifiex_uap_set_channel(struct mwifiex_private *priv,\n\t\t\t     struct mwifiex_uap_bss_param *bss_cfg,\n\t\t\t     struct cfg80211_chan_def chandef)\n{\n\tu8 config_bands = 0, old_bands = priv->adapter->config_bands;\n\n\tpriv->bss_chandef = chandef;\n\n\tbss_cfg->channel = ieee80211_frequency_to_channel(\n\t\t\t\t\t\t     chandef.chan->center_freq);\n\n\t\/* Set appropriate bands *\/\n\tif (chandef.chan->band == NL80211_BAND_2GHZ) {\n\t\tbss_cfg->band_cfg = BAND_CONFIG_BG;\n\t\tconfig_bands = BAND_B | BAND_G;\n\n\t\tif (chandef.width > NL80211_CHAN_WIDTH_20_NOHT)\n\t\t\tconfig_bands |= BAND_GN;\n\t} else {\n\t\tbss_cfg->band_cfg = BAND_CONFIG_A;\n\t\tconfig_bands = BAND_A;\n\n\t\tif (chandef.width > NL80211_CHAN_WIDTH_20_NOHT)\n\t\t\tconfig_bands |= BAND_AN;\n\n\t\tif (chandef.width > NL80211_CHAN_WIDTH_40)\n\t\t\tconfig_bands |= BAND_AAC;\n\t}\n\n\tswitch (chandef.width) {\n\tcase NL80211_CHAN_WIDTH_5:\n\tcase NL80211_CHAN_WIDTH_10:\n\tcase NL80211_CHAN_WIDTH_20_NOHT:\n\tcase NL80211_CHAN_WIDTH_20:\n\t\tbreak;\n\tcase NL80211_CHAN_WIDTH_40:\n\t\tif (chandef.center_freq1 < chandef.chan->center_freq)\n\t\t\tbss_cfg->band_cfg |= MWIFIEX_SEC_CHAN_BELOW;\n\t\telse\n\t\t\tbss_cfg->band_cfg |= MWIFIEX_SEC_CHAN_ABOVE;\n\t\tbreak;\n\tcase NL80211_CHAN_WIDTH_80:\n\tcase NL80211_CHAN_WIDTH_80P80:\n\tcase NL80211_CHAN_WIDTH_160:\n\t\tbss_cfg->band_cfg |=\n\t\t    mwifiex_get_sec_chan_offset(bss_cfg->channel) << 4;\n\t\tbreak;\n\tdefault:\n\t\tmwifiex_dbg(priv->adapter,\n\t\t\t    WARN, \"Unknown channel width: %d\\n\",\n\t\t\t    chandef.width);\n\t\tbreak;\n\t}\n\n\tpriv->adapter->config_bands = config_bands;\n\n\tif (old_bands != config_bands) {\n\t\tmwifiex_send_domain_info_cmd_fw(priv->adapter->wiphy);\n\t\tmwifiex_dnld_txpwr_table(priv);\n\t}\n}\n","target":0,"code_token_length":576,"total_token_length":812,"max_tokens_setting":1024}
+{"idx":185929,"func":"static void coroutine_fn v9fs_readdir(void *opaque)\n{\n    int32_t fid;\n    V9fsFidState *fidp;\n    ssize_t retval = 0;\n    size_t offset = 7;\n    uint64_t initial_offset;\n    int32_t count;\n    uint32_t max_count;\n    V9fsPDU *pdu = opaque;\n\n    retval = pdu_unmarshal(pdu, offset, \"dqd\", &fid,\n                           &initial_offset, &max_count);\n    if (retval < 0) {\n        goto out_nofid;\n    }\n    trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count);\n\n    fidp = get_fid(pdu, fid);\n    if (fidp == NULL) {\n        retval = -EINVAL;\n        goto out_nofid;\n    }\n    if (!fidp->fs.dir.stream) {\n        retval = -EINVAL;\n        goto out;\n    }\n    if (initial_offset == 0) {\n        v9fs_co_rewinddir(pdu, fidp);\n    } else {\n        v9fs_co_seekdir(pdu, fidp, initial_offset);\n    }\n    count = v9fs_do_readdir(pdu, fidp, max_count);\n    if (count < 0) {\n        retval = count;\n        goto out;\n    }\n    retval = pdu_marshal(pdu, offset, \"d\", count);\n    if (retval < 0) {\n        goto out;\n    }\n    retval += count + offset;\n    trace_v9fs_readdir_return(pdu->tag, pdu->id, count, retval);\nout:\n    put_fid(pdu, fidp);\nout_nofid:\n    pdu_complete(pdu, retval);\n}\n","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":31473,"func":"close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf)\n{\n    if (obuf->anchor.url) {\n\tint i;\n\tchar *p = NULL;\n\tint is_erased = 0;\n\n\tfor (i = obuf->tag_sp - 1; i >= 0; i--) {\n\t    if (obuf->tag_stack[i]->cmd == HTML_A)\n\t\tbreak;\n\t}\n\tif (i < 0 && obuf->anchor.hseq > 0 && Strlastchar(obuf->line) == ' ') {\n\t    Strshrink(obuf->line, 1);\n\t    obuf->pos--;\n\t    is_erased = 1;\n\t}\n\n\tif (i >= 0 || (p = has_hidden_link(obuf, HTML_A))) {\n\t    if (obuf->anchor.hseq > 0) {\n\t\tHTMLlineproc1(ANSP, h_env);\n\t\tset_space_to_prevchar(obuf->prevchar);\n\t    }\n\t    else {\n\t\tif (i >= 0) {\n\t\t    obuf->tag_sp--;\n\t\t    bcopy(&obuf->tag_stack[i + 1], &obuf->tag_stack[i],\n\t\t\t  (obuf->tag_sp - i) * sizeof(struct cmdtable *));\n\t\t}\n\t\telse {\n\t\t    passthrough(obuf, p, 1);\n\t\t}\n\t\tbzero((void *)&obuf->anchor, sizeof(obuf->anchor));\n\t\treturn;\n\t    }\n\t    is_erased = 0;\n\t}\n\tif (is_erased) {\n\t    Strcat_char(obuf->line, ' ');\n\t    obuf->pos++;\n\t}\n\n\tpush_tag(obuf, \"<\/a>\", HTML_N_A);\n    }\n    bzero((void *)&obuf->anchor, sizeof(obuf->anchor));\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":94905,"func":"TEST_P(Http2CodecImplTest, ResponseDataFloodMitigationDisabled) {\n  Runtime::LoaderSingleton::getExisting()->mergeValues(\n      {{\"envoy.reloadable_features.http2_protocol_options.max_outbound_frames\", \"2147483647\"}});\n  initialize();\n\n  TestHeaderMapImpl request_headers;\n  HttpTestUtility::addDefaultHeaders(request_headers);\n  EXPECT_CALL(request_decoder_, decodeHeaders_(_, false));\n  request_encoder_->encodeHeaders(request_headers, false);\n\n  \/\/ +2 is to account for HEADERS and PING ACK, that is used to trigger mitigation\n  EXPECT_CALL(server_connection_, write(_, _))\n      .Times(Http2Settings::DEFAULT_MAX_OUTBOUND_FRAMES + 2);\n  EXPECT_CALL(response_decoder_, decodeHeaders_(_, false)).Times(1);\n  EXPECT_CALL(response_decoder_, decodeData(_, false))\n      .Times(Http2Settings::DEFAULT_MAX_OUTBOUND_FRAMES);\n  TestHeaderMapImpl response_headers{{\":status\", \"200\"}};\n  response_encoder_->encodeHeaders(response_headers, false);\n  \/\/ Account for the single HEADERS frame above\n  for (uint32_t i = 0; i < Http2Settings::DEFAULT_MAX_OUTBOUND_FRAMES; ++i) {\n    Buffer::OwnedImpl data(\"0\");\n    EXPECT_NO_THROW(response_encoder_->encodeData(data, false));\n  }\n  \/\/ Presently flood mitigation is done only when processing downstream data\n  \/\/ So we need to send stream from downstream client to trigger mitigation\n  EXPECT_EQ(0, nghttp2_submit_ping(client_->session(), NGHTTP2_FLAG_NONE, nullptr));\n  EXPECT_NO_THROW(client_->sendPendingFrames());\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":473770,"func":"ieee80211_process_tdls_channel_switch_resp(struct ieee80211_sub_if_data *sdata,\n\t\t\t\t\t   struct sk_buff *skb)\n{\n\tstruct ieee80211_local *local = sdata->local;\n\tstruct ieee802_11_elems elems;\n\tstruct sta_info *sta;\n\tstruct ieee80211_tdls_data *tf = (void *)skb->data;\n\tbool local_initiator;\n\tstruct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);\n\tint baselen = offsetof(typeof(*tf), u.chan_switch_resp.variable);\n\tstruct ieee80211_tdls_ch_sw_params params = {};\n\tint ret;\n\n\tparams.action_code = WLAN_TDLS_CHANNEL_SWITCH_RESPONSE;\n\tparams.timestamp = rx_status->device_timestamp;\n\n\tif (skb->len < baselen) {\n\t\ttdls_dbg(sdata, \"TDLS channel switch resp too short: %d\\n\",\n\t\t\t skb->len);\n\t\treturn -EINVAL;\n\t}\n\n\tmutex_lock(&local->sta_mtx);\n\tsta = sta_info_get(sdata, tf->sa);\n\tif (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) {\n\t\ttdls_dbg(sdata, \"TDLS chan switch from non-peer sta %pM\\n\",\n\t\t\t tf->sa);\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tparams.sta = &sta->sta;\n\tparams.status = le16_to_cpu(tf->u.chan_switch_resp.status_code);\n\tif (params.status != 0) {\n\t\tret = 0;\n\t\tgoto call_drv;\n\t}\n\n\tieee802_11_parse_elems(tf->u.chan_switch_resp.variable,\n\t\t\t       skb->len - baselen, false, &elems,\n\t\t\t       NULL, NULL);\n\tif (elems.parse_error) {\n\t\ttdls_dbg(sdata, \"Invalid IEs in TDLS channel switch resp\\n\");\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tif (!elems.ch_sw_timing || !elems.lnk_id) {\n\t\ttdls_dbg(sdata, \"TDLS channel switch resp - missing IEs\\n\");\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* validate the initiator is set correctly *\/\n\tlocal_initiator =\n\t\t!memcmp(elems.lnk_id->init_sta, sdata->vif.addr, ETH_ALEN);\n\tif (local_initiator == sta->sta.tdls_initiator) {\n\t\ttdls_dbg(sdata, \"TDLS chan switch invalid lnk-id initiator\\n\");\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tparams.switch_time = le16_to_cpu(elems.ch_sw_timing->switch_time);\n\tparams.switch_timeout = le16_to_cpu(elems.ch_sw_timing->switch_timeout);\n\n\tparams.tmpl_skb =\n\t\tieee80211_tdls_ch_sw_resp_tmpl_get(sta, ¶ms.ch_sw_tm_ie);\n\tif (!params.tmpl_skb) {\n\t\tret = -ENOENT;\n\t\tgoto out;\n\t}\n\n\tret = 0;\ncall_drv:\n\tdrv_tdls_recv_channel_switch(sdata->local, sdata, ¶ms);\n\n\ttdls_dbg(sdata,\n\t\t \"TDLS channel switch response received from %pM status %d\\n\",\n\t\t tf->sa, params.status);\n\nout:\n\tmutex_unlock(&local->sta_mtx);\n\tdev_kfree_skb_any(params.tmpl_skb);\n\treturn ret;\n}","target":0,"code_token_length":713,"total_token_length":949,"max_tokens_setting":1024}
+{"idx":434468,"func":"static unsigned int find_free_dqentry(struct quota_handle *h,\n\t\t\t\t      struct dquot *dquot, int *err)\n{\n\tint blk, i;\n\tstruct qt_disk_dqdbheader *dh;\n\tstruct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;\n\tchar *ddquot;\n\tdqbuf_t buf;\n\n\t*err = 0;\n\tbuf = getdqbuf();\n\tif (!buf) {\n\t\t*err = -ENOMEM;\n\t\treturn 0;\n\t}\n\n\tdh = (struct qt_disk_dqdbheader *)buf;\n\tif (info->dqi_free_entry) {\n\t\tblk = info->dqi_free_entry;\n\t\tread_blk(h, blk, buf);\n\t} else {\n\t\tblk = get_free_dqblk(h);\n\t\tif (blk < 0) {\n\t\t\tfreedqbuf(buf);\n\t\t\t*err = blk;\n\t\t\treturn 0;\n\t\t}\n\t\tmemset(buf, 0, QT_BLKSIZE);\n\t\tinfo->dqi_free_entry = blk;\n\t\tmark_quotafile_info_dirty(h);\n\t}\n\n\t\/* Block will be full? *\/\n\tif (ext2fs_le16_to_cpu(dh->dqdh_entries) + 1 >=\n\t    qtree_dqstr_in_blk(info))\n\t\tremove_free_dqentry(h, buf, blk);\n\n\tdh->dqdh_entries =\n\t\text2fs_cpu_to_le16(ext2fs_le16_to_cpu(dh->dqdh_entries) + 1);\n\t\/* Find free structure in block *\/\n\tddquot = buf + sizeof(struct qt_disk_dqdbheader);\n\tfor (i = 0;\n\t     i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot);\n\t     i++)\n\t\tddquot += info->dqi_entry_size;\n\n\tif (i == qtree_dqstr_in_blk(info))\n\t\tlog_err(\"find_free_dqentry(): Data block full unexpectedly.\");\n\n\twrite_blk(h, blk, buf);\n\tdquot->dq_dqb.u.v2_mdqb.dqb_off =\n\t\t(blk << QT_BLKSIZE_BITS) + sizeof(struct qt_disk_dqdbheader) +\n\t\ti * info->dqi_entry_size;\n\tfreedqbuf(buf);\n\treturn blk;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":421618,"func":"struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)\n{\n\tstruct bpf_map *inner_map, *inner_map_meta;\n\tu32 inner_map_meta_size;\n\tstruct fd f;\n\n\tf = fdget(inner_map_ufd);\n\tinner_map = __bpf_map_get(f);\n\tif (IS_ERR(inner_map))\n\t\treturn inner_map;\n\n\t\/* prog_array->owner_prog_type and owner_jited\n\t * is a runtime binding.  Doing static check alone\n\t * in the verifier is not enough.\n\t *\/\n\tif (inner_map->map_type == BPF_MAP_TYPE_PROG_ARRAY ||\n\t    inner_map->map_type == BPF_MAP_TYPE_CGROUP_STORAGE ||\n\t    inner_map->map_type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE) {\n\t\tfdput(f);\n\t\treturn ERR_PTR(-ENOTSUPP);\n\t}\n\n\t\/* Does not support >1 level map-in-map *\/\n\tif (inner_map->inner_map_meta) {\n\t\tfdput(f);\n\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\tinner_map_meta_size = sizeof(*inner_map_meta);\n\t\/* In some cases verifier needs to access beyond just base map. *\/\n\tif (inner_map->ops == &array_map_ops)\n\t\tinner_map_meta_size = sizeof(struct bpf_array);\n\n\tinner_map_meta = kzalloc(inner_map_meta_size, GFP_USER);\n\tif (!inner_map_meta) {\n\t\tfdput(f);\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\n\tinner_map_meta->map_type = inner_map->map_type;\n\tinner_map_meta->key_size = inner_map->key_size;\n\tinner_map_meta->value_size = inner_map->value_size;\n\tinner_map_meta->map_flags = inner_map->map_flags;\n\tinner_map_meta->max_entries = inner_map->max_entries;\n\n\t\/* Misc members not needed in bpf_map_meta_equal() check. *\/\n\tinner_map_meta->ops = inner_map->ops;\n\tif (inner_map->ops == &array_map_ops) {\n\t\tinner_map_meta->unpriv_array = inner_map->unpriv_array;\n\t\tcontainer_of(inner_map_meta, struct bpf_array, map)->index_mask =\n\t\t     container_of(inner_map, struct bpf_array, map)->index_mask;\n\t}\n\n\tfdput(f);\n\treturn inner_map_meta;\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":80833,"func":"static int ext4_unlink(struct inode *dir, struct dentry *dentry)\n{\n\tint retval;\n\tstruct inode *inode;\n\tstruct buffer_head *bh;\n\tstruct ext4_dir_entry_2 *de;\n\thandle_t *handle;\n\n\ttrace_ext4_unlink_enter(dir, dentry);\n\t\/* Initialize quotas before so that eventual writes go\n\t * in separate transaction *\/\n\tdquot_initialize(dir);\n\tdquot_initialize(dentry->d_inode);\n\n\thandle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));\n\tif (IS_ERR(handle))\n\t\treturn PTR_ERR(handle);\n\n\tif (IS_DIRSYNC(dir))\n\t\text4_handle_sync(handle);\n\n\tretval = -ENOENT;\n\tbh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);\n\tif (!bh)\n\t\tgoto end_unlink;\n\n\tinode = dentry->d_inode;\n\n\tretval = -EIO;\n\tif (le32_to_cpu(de->inode) != inode->i_ino)\n\t\tgoto end_unlink;\n\n\tif (!inode->i_nlink) {\n\t\text4_warning(inode->i_sb,\n\t\t\t     \"Deleting nonexistent file (%lu), %d\",\n\t\t\t     inode->i_ino, inode->i_nlink);\n\t\tset_nlink(inode, 1);\n\t}\n\tretval = ext4_delete_entry(handle, dir, de, bh);\n\tif (retval)\n\t\tgoto end_unlink;\n\tdir->i_ctime = dir->i_mtime = ext4_current_time(dir);\n\text4_update_dx_flag(dir);\n\text4_mark_inode_dirty(handle, dir);\n\tdrop_nlink(inode);\n\tif (!inode->i_nlink)\n\t\text4_orphan_add(handle, inode);\n\tinode->i_ctime = ext4_current_time(inode);\n\text4_mark_inode_dirty(handle, inode);\n\tretval = 0;\n\nend_unlink:\n\text4_journal_stop(handle);\n\tbrelse(bh);\n\ttrace_ext4_unlink_exit(dentry, retval);\n\treturn retval;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":208586,"func":"DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,\n       show_ip_bgp_vpnv4_all_neighbor_routes_cmd,\n       \"show ip bgp vpnv4 all neighbors A.B.C.D routes\",\n       SHOW_STR\n       IP_STR\n       BGP_STR\n       \"Display VPNv4 NLRI specific information\\n\"\n       \"Display information about all VPNv4 NLRIs\\n\"\n       \"Detailed information on TCP and BGP neighbor connections\\n\"\n       \"Neighbor to display information about\\n\"\n       \"Display routes learned from neighbor\\n\")\n{\n  union sockunion su;\n  struct peer *peer;\n  int ret;\n\n  ret = str2sockunion (argv[0], &su);\n  if (ret < 0)\n    {\n      vty_out (vty, \"Malformed address: %s%s\", argv[0], VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  peer = peer_lookup (NULL, &su);\n  if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])\n    {\n      vty_out (vty, \"%% No such neighbor or address family%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_neighbor, &su, 0);\n}\n","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":480288,"func":"\nstatic int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,\n\t\t\t const struct io_uring_sqe *sqe)\n{\n\tstruct io_submit_link *link = &ctx->submit_state.link;\n\tint ret;\n\n\tret = io_init_req(ctx, req, sqe);\n\tif (unlikely(ret)) {\nfail_req:\n\t\tif (link->head) {\n\t\t\t\/* fail even hard links since we don't submit *\/\n\t\t\treq_set_fail(link->head);\n\t\t\tio_req_complete_failed(link->head, -ECANCELED);\n\t\t\tlink->head = NULL;\n\t\t}\n\t\tio_req_complete_failed(req, ret);\n\t\treturn ret;\n\t}\n\n\tret = io_req_prep(req, sqe);\n\tif (unlikely(ret))\n\t\tgoto fail_req;\n\n\t\/* don't need @sqe from now on *\/\n\ttrace_io_uring_submit_sqe(ctx, req, req->opcode, req->user_data,\n\t\t\t\t  req->flags, true,\n\t\t\t\t  ctx->flags & IORING_SETUP_SQPOLL);\n\n\t\/*\n\t * If we already have a head request, queue this one for async\n\t * submittal once the head completes. If we don't have a head but\n\t * IOSQE_IO_LINK is set in the sqe, start a new head. This one will be\n\t * submitted sync once the chain is complete. If none of those\n\t * conditions are true (normal request), then just queue it.\n\t *\/\n\tif (link->head) {\n\t\tstruct io_kiocb *head = link->head;\n\n\t\tret = io_req_prep_async(req);\n\t\tif (unlikely(ret))\n\t\t\tgoto fail_req;\n\t\ttrace_io_uring_link(ctx, req, head);\n\t\tlink->last->link = req;\n\t\tlink->last = req;\n\n\t\t\/* last request of a link, enqueue the link *\/\n\t\tif (!(req->flags & (REQ_F_LINK | REQ_F_HARDLINK))) {\n\t\t\tlink->head = NULL;\n\t\t\tio_queue_sqe(head);\n\t\t}\n\t} else {\n\t\tif (req->flags & (REQ_F_LINK | REQ_F_HARDLINK)) {\n\t\t\tlink->head = req;\n\t\t\tlink->last = req;\n\t\t} else {\n\t\t\tio_queue_sqe(req);\n\t\t}\n\t}\n\n\treturn 0;","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":85531,"func":"ipf_v6_key_extract(struct dp_packet *pkt, ovs_be16 dl_type, uint16_t zone,\n                   struct ipf_list_key *key, uint16_t *start_data_byte,\n                   uint16_t *end_data_byte, bool *ff, bool *lf)\n{\n    const struct ovs_16aligned_ip6_hdr *l3 = dp_packet_l3(pkt);\n    uint8_t nw_frag = 0;\n    uint8_t nw_proto = l3->ip6_nxt;\n    const void *data = l3 + 1;\n    size_t datasize = dp_packet_l3_size(pkt) - sizeof *l3;\n    const struct ovs_16aligned_ip6_frag *frag_hdr = NULL;\n\n    parse_ipv6_ext_hdrs(&data, &datasize, &nw_proto, &nw_frag, &frag_hdr);\n    ovs_assert(nw_frag && frag_hdr);\n    ovs_be16 ip6f_offlg = frag_hdr->ip6f_offlg;\n    *start_data_byte = ntohs(ip6f_offlg & IP6F_OFF_MASK) +\n        sizeof (struct ovs_16aligned_ip6_frag);\n    *end_data_byte = *start_data_byte + dp_packet_l4_size(pkt) - 1;\n    *ff = ipf_is_first_v6_frag(ip6f_offlg);\n    *lf = ipf_is_last_v6_frag(ip6f_offlg);\n    memset(key, 0, sizeof *key);\n    key->ip_id = get_16aligned_be32(&frag_hdr->ip6f_ident);\n    key->dl_type = dl_type;\n    memcpy(&key->src_addr.ipv6, &l3->ip6_src, sizeof key->src_addr.ipv6);\n    \/* We are not supporting parsing of the routing header to use as the\n     * dst address part of the key. *\/\n    memcpy(&key->dst_addr.ipv6, &l3->ip6_dst, sizeof key->dst_addr.ipv6);\n    key->nw_proto = 0;   \/* Not used for key for V6. *\/\n    key->zone = zone;\n    key->recirc_id = pkt->md.recirc_id;\n}","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":490845,"func":"char *get_rule_prefix(filter_rule *rule, const char *pat, int for_xfer,\n\t\t      unsigned int *plen_ptr)\n{\n\tstatic char buf[MAX_RULE_PREFIX+1];\n\tchar *op = buf;\n\tint legal_len = for_xfer && protocol_version < 29 ? 1 : MAX_RULE_PREFIX-1;\n\n\tif (rule->rflags & FILTRULE_PERDIR_MERGE) {\n\t\tif (legal_len == 1)\n\t\t\treturn NULL;\n\t\t*op++ = ':';\n\t} else if (rule->rflags & FILTRULE_INCLUDE)\n\t\t*op++ = '+';\n\telse if (legal_len != 1\n\t    || ((*pat == '-' || *pat == '+') && pat[1] == ' '))\n\t\t*op++ = '-';\n\telse\n\t\tlegal_len = 0;\n\n\tif (rule->rflags & FILTRULE_ABS_PATH)\n\t\t*op++ = '\/';\n\tif (rule->rflags & FILTRULE_NEGATE)\n\t\t*op++ = '!';\n\tif (rule->rflags & FILTRULE_CVS_IGNORE)\n\t\t*op++ = 'C';\n\telse {\n\t\tif (rule->rflags & FILTRULE_NO_INHERIT)\n\t\t\t*op++ = 'n';\n\t\tif (rule->rflags & FILTRULE_WORD_SPLIT)\n\t\t\t*op++ = 'w';\n\t\tif (rule->rflags & FILTRULE_NO_PREFIXES) {\n\t\t\tif (rule->rflags & FILTRULE_INCLUDE)\n\t\t\t\t*op++ = '+';\n\t\t\telse\n\t\t\t\t*op++ = '-';\n\t\t}\n\t}\n\tif (rule->rflags & FILTRULE_EXCLUDE_SELF)\n\t\t*op++ = 'e';\n\tif (rule->rflags & FILTRULE_XATTR)\n\t\t*op++ = 'x';\n\tif (rule->rflags & FILTRULE_SENDER_SIDE\n\t    && (!for_xfer || protocol_version >= 29))\n\t\t*op++ = 's';\n\tif (rule->rflags & FILTRULE_RECEIVER_SIDE\n\t    && (!for_xfer || protocol_version >= 29\n\t     || (delete_excluded && am_sender)))\n\t\t*op++ = 'r';\n\tif (rule->rflags & FILTRULE_PERISHABLE) {\n\t\tif (!for_xfer || protocol_version >= 30)\n\t\t\t*op++ = 'p';\n\t\telse if (am_sender)\n\t\t\treturn NULL;\n\t}\n\tif (op - buf > legal_len)\n\t\treturn NULL;\n\tif (legal_len)\n\t\t*op++ = ' ';\n\t*op = '\\0';\n\tif (plen_ptr)\n\t\t*plen_ptr = op - buf;\n\treturn buf;\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":364002,"func":"int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)\n{\n\tint num_entries;\n\tsize_t i;\n\toff_t j;\n\tvoid *temp;\n\tstruct agp_bridge_data *bridge;\n\tint mask_type;\n\n\tbridge = mem->bridge;\n\tif (!bridge)\n\t\treturn -EINVAL;\n\n\tif (mem->page_count == 0)\n\t\treturn 0;\n\n\ttemp = bridge->current_size;\n\n\tswitch (bridge->driver->size_type) {\n\tcase U8_APER_SIZE:\n\t\tnum_entries = A_SIZE_8(temp)->num_entries;\n\t\tbreak;\n\tcase U16_APER_SIZE:\n\t\tnum_entries = A_SIZE_16(temp)->num_entries;\n\t\tbreak;\n\tcase U32_APER_SIZE:\n\t\tnum_entries = A_SIZE_32(temp)->num_entries;\n\t\tbreak;\n\tcase FIXED_APER_SIZE:\n\t\tnum_entries = A_SIZE_FIX(temp)->num_entries;\n\t\tbreak;\n\tcase LVL2_APER_SIZE:\n\t\t\/* The generic routines can't deal with 2 level gatt's *\/\n\t\treturn -EINVAL;\n\t\tbreak;\n\tdefault:\n\t\tnum_entries = 0;\n\t\tbreak;\n\t}\n\n\tnum_entries -= agp_memory_reserved\/PAGE_SIZE;\n\tif (num_entries < 0) num_entries = 0;\n\n\tif (type != mem->type)\n\t\treturn -EINVAL;\n\n\tmask_type = bridge->driver->agp_type_to_mask_type(bridge, type);\n\tif (mask_type != 0) {\n\t\t\/* The generic routines know nothing of memory types *\/\n\t\treturn -EINVAL;\n\t}\n\n\tif (((pg_start + mem->page_count) > num_entries) ||\n\t    ((pg_start + mem->page_count) < pg_start))\n\t\treturn -EINVAL;\n\n\tj = pg_start;\n\n\twhile (j < (pg_start + mem->page_count)) {\n\t\tif (!PGE_EMPTY(bridge, readl(bridge->gatt_table+j)))\n\t\t\treturn -EBUSY;\n\t\tj++;\n\t}\n\n\tif (!mem->is_flushed) {\n\t\tbridge->driver->cache_flush();\n\t\tmem->is_flushed = true;\n\t}\n\n\tfor (i = 0, j = pg_start; i < mem->page_count; i++, j++) {\n\t\twritel(bridge->driver->mask_memory(bridge,\n\t\t\t\t\t\t   page_to_phys(mem->pages[i]),\n\t\t\t\t\t\t   mask_type),\n\t\t       bridge->gatt_table+j);\n\t}\n\treadl(bridge->gatt_table+j-1);\t\/* PCI Posting. *\/\n\n\tbridge->driver->tlb_flush(mem);\n\treturn 0;\n}","target":0,"code_token_length":529,"total_token_length":765,"max_tokens_setting":1024}
+{"idx":403661,"func":"static void xfrm_hash_rebuild(struct work_struct *work)\n{\n\tstruct net *net = container_of(work, struct net,\n\t\t\t\t       xfrm.policy_hthresh.work);\n\tunsigned int hmask;\n\tstruct xfrm_policy *pol;\n\tstruct xfrm_policy *policy;\n\tstruct hlist_head *chain;\n\tstruct hlist_head *odst;\n\tstruct hlist_node *newpos;\n\tint i;\n\tint dir;\n\tunsigned seq;\n\tu8 lbits4, rbits4, lbits6, rbits6;\n\n\tmutex_lock(&hash_resize_mutex);\n\n\t\/* read selector prefixlen thresholds *\/\n\tdo {\n\t\tseq = read_seqbegin(&net->xfrm.policy_hthresh.lock);\n\n\t\tlbits4 = net->xfrm.policy_hthresh.lbits4;\n\t\trbits4 = net->xfrm.policy_hthresh.rbits4;\n\t\tlbits6 = net->xfrm.policy_hthresh.lbits6;\n\t\trbits6 = net->xfrm.policy_hthresh.rbits6;\n\t} while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq));\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\n\t\/* reset the bydst and inexact table in all directions *\/\n\tfor (dir = 0; dir < XFRM_POLICY_MAX; dir++) {\n\t\tINIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]);\n\t\thmask = net->xfrm.policy_bydst[dir].hmask;\n\t\todst = net->xfrm.policy_bydst[dir].table;\n\t\tfor (i = hmask; i >= 0; i--)\n\t\t\tINIT_HLIST_HEAD(odst + i);\n\t\tif ((dir & XFRM_POLICY_MASK) == XFRM_POLICY_OUT) {\n\t\t\t\/* dir out => dst = remote, src = local *\/\n\t\t\tnet->xfrm.policy_bydst[dir].dbits4 = rbits4;\n\t\t\tnet->xfrm.policy_bydst[dir].sbits4 = lbits4;\n\t\t\tnet->xfrm.policy_bydst[dir].dbits6 = rbits6;\n\t\t\tnet->xfrm.policy_bydst[dir].sbits6 = lbits6;\n\t\t} else {\n\t\t\t\/* dir in\/fwd => dst = local, src = remote *\/\n\t\t\tnet->xfrm.policy_bydst[dir].dbits4 = lbits4;\n\t\t\tnet->xfrm.policy_bydst[dir].sbits4 = rbits4;\n\t\t\tnet->xfrm.policy_bydst[dir].dbits6 = lbits6;\n\t\t\tnet->xfrm.policy_bydst[dir].sbits6 = rbits6;\n\t\t}\n\t}\n\n\t\/* re-insert all policies by order of creation *\/\n\tlist_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {\n\t\tif (xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) {\n\t\t\t\/* skip socket policies *\/\n\t\t\tcontinue;\n\t\t}\n\t\tnewpos = NULL;\n\t\tchain = policy_hash_bysel(net, &policy->selector,\n\t\t\t\t\t  policy->family,\n\t\t\t\t\t  xfrm_policy_id2dir(policy->index));\n\t\thlist_for_each_entry(pol, chain, bydst) {\n\t\t\tif (policy->priority >= pol->priority)\n\t\t\t\tnewpos = &pol->bydst;\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\t\tif (newpos)\n\t\t\thlist_add_behind(&policy->bydst, newpos);\n\t\telse\n\t\t\thlist_add_head(&policy->bydst, chain);\n\t}\n\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\n\tmutex_unlock(&hash_resize_mutex);\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":117648,"func":"static int check_stack_access_within_bounds(\n\t\tstruct bpf_verifier_env *env,\n\t\tint regno, int off, int access_size,\n\t\tenum stack_access_src src, enum bpf_access_type type)\n{\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tstruct bpf_reg_state *reg = regs + regno;\n\tstruct bpf_func_state *state = func(env, reg);\n\tint min_off, max_off;\n\tint err;\n\tchar *err_extra;\n\n\tif (src == ACCESS_HELPER)\n\t\t\/* We don't know if helpers are reading or writing (or both). *\/\n\t\terr_extra = \" indirect access to\";\n\telse if (type == BPF_READ)\n\t\terr_extra = \" read from\";\n\telse\n\t\terr_extra = \" write to\";\n\n\tif (tnum_is_const(reg->var_off)) {\n\t\tmin_off = reg->var_off.value + off;\n\t\tif (access_size > 0)\n\t\t\tmax_off = min_off + access_size - 1;\n\t\telse\n\t\t\tmax_off = min_off;\n\t} else {\n\t\tif (reg->smax_value >= BPF_MAX_VAR_OFF ||\n\t\t    reg->smin_value <= -BPF_MAX_VAR_OFF) {\n\t\t\tverbose(env, \"invalid unbounded variable-offset%s stack R%d\\n\",\n\t\t\t\terr_extra, regno);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tmin_off = reg->smin_value + off;\n\t\tif (access_size > 0)\n\t\t\tmax_off = reg->smax_value + off + access_size - 1;\n\t\telse\n\t\t\tmax_off = min_off;\n\t}\n\n\terr = check_stack_slot_within_bounds(min_off, state, type);\n\tif (!err)\n\t\terr = check_stack_slot_within_bounds(max_off, state, type);\n\n\tif (err) {\n\t\tif (tnum_is_const(reg->var_off)) {\n\t\t\tverbose(env, \"invalid%s stack R%d off=%d size=%d\\n\",\n\t\t\t\terr_extra, regno, off, access_size);\n\t\t} else {\n\t\t\tchar tn_buf[48];\n\n\t\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\t\tverbose(env, \"invalid variable-offset%s stack R%d var_off=%s size=%d\\n\",\n\t\t\t\terr_extra, regno, tn_buf, access_size);\n\t\t}\n\t}\n\treturn err;\n}","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":487763,"func":"__read_extent_tree_block(const char *function, unsigned int line,\n\t\t\t struct inode *inode, ext4_fsblk_t pblk, int depth,\n\t\t\t int flags)\n{\n\tstruct buffer_head\t\t*bh;\n\tint\t\t\t\terr;\n\tgfp_t\t\t\t\tgfp_flags = __GFP_MOVABLE | GFP_NOFS;\n\n\tif (flags & EXT4_EX_NOFAIL)\n\t\tgfp_flags |= __GFP_NOFAIL;\n\n\tbh = sb_getblk_gfp(inode->i_sb, pblk, gfp_flags);\n\tif (unlikely(!bh))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tif (!bh_uptodate_or_lock(bh)) {\n\t\ttrace_ext4_ext_load_extent(inode, pblk, _RET_IP_);\n\t\terr = bh_submit_read(bh);\n\t\tif (err < 0)\n\t\t\tgoto errout;\n\t}\n\tif (buffer_verified(bh) && !(flags & EXT4_EX_FORCE_CACHE))\n\t\treturn bh;\n\terr = __ext4_ext_check(function, line, inode,\n\t\t\t       ext_block_hdr(bh), depth, pblk);\n\tif (err)\n\t\tgoto errout;\n\tset_buffer_verified(bh);\n\t\/*\n\t * If this is a leaf block, cache all of its entries\n\t *\/\n\tif (!(flags & EXT4_EX_NOCACHE) && depth == 0) {\n\t\tstruct ext4_extent_header *eh = ext_block_hdr(bh);\n\t\text4_cache_extents(inode, eh);\n\t}\n\treturn bh;\nerrout:\n\tput_bh(bh);\n\treturn ERR_PTR(err);\n\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":497089,"func":"static void update_ltp(AACContext *ac, SingleChannelElement *sce)\n{\n    IndividualChannelStream *ics = &sce->ics;\n    float *saved     = sce->saved;\n    float *saved_ltp = sce->coeffs;\n    const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;\n    const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;\n    int i;\n\n    if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {\n        memcpy(saved_ltp,       saved, 512 * sizeof(float));\n        memset(saved_ltp + 576, 0,     448 * sizeof(float));\n        ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960,     &swindow[64],      64);\n        for (i = 0; i < 64; i++)\n            saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];\n    } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {\n        memcpy(saved_ltp,       ac->buf_mdct + 512, 448 * sizeof(float));\n        memset(saved_ltp + 576, 0,                  448 * sizeof(float));\n        ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960,     &swindow[64],      64);\n        for (i = 0; i < 64; i++)\n            saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];\n    } else { \/\/ LONG_STOP or ONLY_LONG\n        ac->fdsp.vector_fmul_reverse(saved_ltp,       ac->buf_mdct + 512,     &lwindow[512],     512);\n        for (i = 0; i < 512; i++)\n            saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i];\n    }\n\n    memcpy(sce->ltp_state,      sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state));\n    memcpy(sce->ltp_state+1024, sce->ret,            1024 * sizeof(*sce->ltp_state));\n    memcpy(sce->ltp_state+2048, saved_ltp,           1024 * sizeof(*sce->ltp_state));\n}","target":0,"code_token_length":650,"total_token_length":886,"max_tokens_setting":1024}
+{"idx":386454,"func":"\/* {{{ proto int strtotime(string time [, int now ])\n   Convert string representation of date and time to a timestamp *\/\nPHP_FUNCTION(strtotime)\n{\n\tchar *times, *initial_ts;\n\tint   time_len, error1, error2;\n\tstruct timelib_error_container *error;\n\tlong  preset_ts = 0, ts;\n\n\ttimelib_time *t, *now;\n\ttimelib_tzinfo *tzi;\n\n\ttzi = get_timezone_info(TSRMLS_C);\n\n\tif (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"sl\", ×, &time_len, &preset_ts) != FAILURE) {\n\t\t\/* We have an initial timestamp *\/\n\t\tnow = timelib_time_ctor();\n\n\t\tinitial_ts = emalloc(25);\n\t\tsnprintf(initial_ts, 24, \"@%ld UTC\", preset_ts);\n\t\tt = timelib_strtotime(initial_ts, strlen(initial_ts), NULL, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); \/* we ignore the error here, as this should never fail *\/\n\t\ttimelib_update_ts(t, tzi);\n\t\tnow->tz_info = tzi;\n\t\tnow->zone_type = TIMELIB_ZONETYPE_ID;\n\t\ttimelib_unixtime2local(now, t->sse);\n\t\ttimelib_time_dtor(t);\n\t\tefree(initial_ts);\n\t} else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s|l\", ×, &time_len, &preset_ts) != FAILURE) {\n\t\t\/* We have no initial timestamp *\/\n\t\tnow = timelib_time_ctor();\n\t\tnow->tz_info = tzi;\n\t\tnow->zone_type = TIMELIB_ZONETYPE_ID;\n\t\ttimelib_unixtime2local(now, (timelib_sll) time(NULL));\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (!time_len) {\n\t\ttimelib_time_dtor(now);\n\t\tRETURN_FALSE;\n\t}\n\n\tt = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);\n\terror1 = error->error_count;\n\ttimelib_error_container_dtor(error);\n\ttimelib_fill_holes(t, now, TIMELIB_NO_CLONE);\n\ttimelib_update_ts(t, tzi);\n\tts = timelib_date_to_int(t, &error2);\n\n\ttimelib_time_dtor(now);\n\ttimelib_time_dtor(t);\n\n\tif (error1 || error2) {\n\t\tRETURN_FALSE;\n\t} else {\n\t\tRETURN_LONG(ts);","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":207082,"func":"bool RenderThreadImpl::Send(IPC::Message* msg) {\n  bool pumping_events = false;\n  if (msg->is_sync()) {\n    if (msg->is_caller_pumping_messages()) {\n      pumping_events = true;\n    }\n  }\n\n  bool suspend_webkit_shared_timer = true;  \/\/ default value\n  std::swap(suspend_webkit_shared_timer, suspend_webkit_shared_timer_);\n\n  bool notify_webkit_of_modal_loop = true;  \/\/ default value\n  std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_);\n\n#if defined(ENABLE_PLUGINS)\n  int render_view_id = MSG_ROUTING_NONE;\n#endif\n\n  if (pumping_events) {\n    if (suspend_webkit_shared_timer)\n      webkit_platform_support_->SuspendSharedTimer();\n\n    if (notify_webkit_of_modal_loop)\n      WebView::willEnterModalLoop();\n#if defined(ENABLE_PLUGINS)\n    RenderViewImpl* render_view =\n        RenderViewImpl::FromRoutingID(msg->routing_id());\n    if (render_view) {\n      render_view_id = msg->routing_id();\n      PluginChannelHost::Broadcast(\n          new PluginMsg_SignalModalDialogEvent(render_view_id));\n    }\n#endif\n  }\n\n  bool rv = ChildThread::Send(msg);\n\n  if (pumping_events) {\n#if defined(ENABLE_PLUGINS)\n    if (render_view_id != MSG_ROUTING_NONE) {\n      PluginChannelHost::Broadcast(\n          new PluginMsg_ResetModalDialogEvent(render_view_id));\n    }\n#endif\n\n    if (notify_webkit_of_modal_loop)\n      WebView::didExitModalLoop();\n\n    if (suspend_webkit_shared_timer)\n      webkit_platform_support_->ResumeSharedTimer();\n  }\n\n  return rv;\n}\n","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":326852,"func":"static int parallels_open(BlockDriverState *bs, int flags)\n\n{\n\n    BDRVParallelsState *s = bs->opaque;\n\n    int i;\n\n    struct parallels_header ph;\n\n\n\n    bs->read_only = 1; \/\/ no write support yet\n\n\n\n    if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph))\n\n        goto fail;\n\n\n\n    if (memcmp(ph.magic, HEADER_MAGIC, 16) ||\n\n\t(le32_to_cpu(ph.version) != HEADER_VERSION)) {\n\n        goto fail;\n\n    }\n\n\n\n    bs->total_sectors = le32_to_cpu(ph.nb_sectors);\n\n\n\n    s->tracks = le32_to_cpu(ph.tracks);\n\n\n\n    s->catalog_size = le32_to_cpu(ph.catalog_entries);\n\n    s->catalog_bitmap = g_malloc(s->catalog_size * 4);\n\n    if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=\n\n\ts->catalog_size * 4)\n\n\tgoto fail;\n\n    for (i = 0; i < s->catalog_size; i++)\n\n\tle32_to_cpus(&s->catalog_bitmap[i]);\n\n\n\n    qemu_co_mutex_init(&s->lock);\n\n    return 0;\n\nfail:\n\n    if (s->catalog_bitmap)\n\n\tg_free(s->catalog_bitmap);\n\n    return -1;\n\n}\n","target":1,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":515172,"func":"static const char *start_cond_section(cmd_parms *cmd, void *mconfig, const char *arg)\n{\n    const char *endp = ap_strrchr_c(arg, '>');\n    int result, not = (arg[0] == '!');\n    test_cond_section_fn testfn = (test_cond_section_fn)cmd->info;\n    const char *arg1;\n\n    if (endp == NULL) {\n        return unclosed_directive(cmd);\n    }\n\n    arg = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg);\n\n    if (not) {\n        arg++;\n    }\n\n    arg1 = ap_getword_conf(cmd->temp_pool, &arg);\n\n    if (!arg1[0]) {\n        return missing_container_arg(cmd);\n    }\n\n    result = testfn(cmd, arg1);\n\n    if ((!not && result) || (not && !result)) {\n        ap_directive_t *parent = NULL;\n        ap_directive_t *current = NULL;\n        const char *retval;\n\n        retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,\n                                      ¤t, &parent, (char *)cmd->cmd->name);\n        *(ap_directive_t **)mconfig = current;\n        return retval;\n    }\n    else {\n        *(ap_directive_t **)mconfig = NULL;\n        return ap_soak_end_container(cmd, (char *)cmd->cmd->name);\n    }\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":117611,"func":"static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg,\n\t\t\t\t   struct zone *zone,\n\t\t\t\t   gfp_t gfp_mask,\n\t\t\t\t   unsigned long *total_scanned)\n{\n\tstruct mem_cgroup *victim = NULL;\n\tint total = 0;\n\tint loop = 0;\n\tunsigned long excess;\n\tunsigned long nr_scanned;\n\tstruct mem_cgroup_reclaim_cookie reclaim = {\n\t\t.zone = zone,\n\t\t.priority = 0,\n\t};\n\n\texcess = res_counter_soft_limit_excess(&root_memcg->res) >> PAGE_SHIFT;\n\n\twhile (1) {\n\t\tvictim = mem_cgroup_iter(root_memcg, victim, &reclaim);\n\t\tif (!victim) {\n\t\t\tloop++;\n\t\t\tif (loop >= 2) {\n\t\t\t\t\/*\n\t\t\t\t * If we have not been able to reclaim\n\t\t\t\t * anything, it might because there are\n\t\t\t\t * no reclaimable pages under this hierarchy\n\t\t\t\t *\/\n\t\t\t\tif (!total)\n\t\t\t\t\tbreak;\n\t\t\t\t\/*\n\t\t\t\t * We want to do more targeted reclaim.\n\t\t\t\t * excess >> 2 is not to excessive so as to\n\t\t\t\t * reclaim too much, nor too less that we keep\n\t\t\t\t * coming back to reclaim from this cgroup\n\t\t\t\t *\/\n\t\t\t\tif (total >= (excess >> 2) ||\n\t\t\t\t\t(loop > MEM_CGROUP_MAX_RECLAIM_LOOPS))\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (!mem_cgroup_reclaimable(victim, false))\n\t\t\tcontinue;\n\t\ttotal += mem_cgroup_shrink_node_zone(victim, gfp_mask, false,\n\t\t\t\t\t\t     zone, &nr_scanned);\n\t\t*total_scanned += nr_scanned;\n\t\tif (!res_counter_soft_limit_excess(&root_memcg->res))\n\t\t\tbreak;\n\t}\n\tmem_cgroup_iter_break(root_memcg, victim);\n\treturn total;\n}","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":143733,"func":"void ext4_da_update_reserve_space(struct inode *inode,\n\t\t\t\t\tint used, int quota_claim)\n{\n\tstruct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);\n\tstruct ext4_inode_info *ei = EXT4_I(inode);\n\tint mdb_free = 0, allocated_meta_blocks = 0;\n\n\tspin_lock(&ei->i_block_reservation_lock);\n\ttrace_ext4_da_update_reserve_space(inode, used);\n\tif (unlikely(used > ei->i_reserved_data_blocks)) {\n\t\text4_msg(inode->i_sb, KERN_NOTICE, \"%s: ino %lu, used %d \"\n\t\t\t \"with only %d reserved data blocks\\n\",\n\t\t\t __func__, inode->i_ino, used,\n\t\t\t ei->i_reserved_data_blocks);\n\t\tWARN_ON(1);\n\t\tused = ei->i_reserved_data_blocks;\n\t}\n\n\t\/* Update per-inode reservations *\/\n\tei->i_reserved_data_blocks -= used;\n\tused += ei->i_allocated_meta_blocks;\n\tei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks;\n\tallocated_meta_blocks = ei->i_allocated_meta_blocks;\n\tei->i_allocated_meta_blocks = 0;\n\tpercpu_counter_sub(&sbi->s_dirtyblocks_counter, used);\n\n\tif (ei->i_reserved_data_blocks == 0) {\n\t\t\/*\n\t\t * We can release all of the reserved metadata blocks\n\t\t * only when we have written all of the delayed\n\t\t * allocation blocks.\n\t\t *\/\n\t\tmdb_free = ei->i_reserved_meta_blocks;\n\t\tei->i_reserved_meta_blocks = 0;\n\t\tei->i_da_metadata_calc_len = 0;\n\t\tpercpu_counter_sub(&sbi->s_dirtyblocks_counter, mdb_free);\n\t}\n\tspin_unlock(&EXT4_I(inode)->i_block_reservation_lock);\n\n\t\/* Update quota subsystem *\/\n\tif (quota_claim) {\n\t\tvfs_dq_claim_block(inode, used);\n\t\tif (mdb_free)\n\t\t\tvfs_dq_release_reservation_block(inode, mdb_free);\n\t} else {\n\t\t\/*\n\t\t * We did fallocate with an offset that is already delayed\n\t\t * allocated. So on delayed allocated writeback we should\n\t\t * not update the quota for allocated blocks. But then\n\t\t * converting an fallocate region to initialized region would\n\t\t * have caused a metadata allocation. So claim quota for\n\t\t * that\n\t\t *\/\n\t\tif (allocated_meta_blocks)\n\t\t\tvfs_dq_claim_block(inode, allocated_meta_blocks);\n\t\tvfs_dq_release_reservation_block(inode, mdb_free + used);\n\t}\n\n\t\/*\n\t * If we have done all the pending block allocations and if\n\t * there aren't any writers on the inode, we can discard the\n\t * inode's preallocations.\n\t *\/\n\tif ((ei->i_reserved_data_blocks == 0) &&\n\t    (atomic_read(&inode->i_writecount) == 0))\n\t\text4_discard_preallocations(inode);\n}","target":0,"code_token_length":613,"total_token_length":849,"max_tokens_setting":1024}
+{"idx":376695,"func":"void HGlobalValueNumberer::ProcessLoopBlock(\n    HBasicBlock* block,\n    HBasicBlock* loop_header,\n    GVNFlagSet loop_kills,\n    GVNFlagSet* first_time_depends,\n    GVNFlagSet* first_time_changes) {\n  HBasicBlock* pre_header = loop_header->predecessors()->at(0);\n  GVNFlagSet depends_flags = HValue::ConvertChangesToDependsFlags(loop_kills);\n  TRACE_GVN_2(\"Loop invariant motion for B%d %s\\n\",\n              block->block_id(),\n              *GetGVNFlagsString(depends_flags));\n  HInstruction* instr = block->first();\n  while (instr != NULL) {\n    HInstruction* next = instr->next();\n    bool hoisted = false;\n    if (instr->CheckFlag(HValue::kUseGVN)) {\n      TRACE_GVN_4(\"Checking instruction %d (%s) %s. Loop %s\\n\",\n                  instr->id(),\n                  instr->Mnemonic(),\n                  *GetGVNFlagsString(instr->gvn_flags()),\n                  *GetGVNFlagsString(loop_kills));\n      bool can_hoist = !instr->gvn_flags().ContainsAnyOf(depends_flags);\n      if (can_hoist && !graph()->use_optimistic_licm()) {\n        can_hoist = block->IsLoopSuccessorDominator();\n      }\n\n      if (can_hoist) {\n        bool inputs_loop_invariant = true;\n        for (int i = 0; i < instr->OperandCount(); ++i) {\n          if (instr->OperandAt(i)->IsDefinedAfter(pre_header)) {\n            inputs_loop_invariant = false;\n          }\n        }\n\n        if (inputs_loop_invariant && ShouldMove(instr, loop_header)) {\n          TRACE_GVN_1(\"Hoisting loop invariant instruction %d\\n\", instr->id());\n          \/\/ Move the instruction out of the loop.\n          instr->Unlink();\n          instr->InsertBefore(pre_header->end());\n          if (instr->HasSideEffects()) removed_side_effects_ = true;\n          hoisted = true;\n        }\n      }\n    }\n    if (!hoisted) {\n      \/\/ If an instruction is not hoisted, we have to account for its side\n      \/\/ effects when hoisting later HTransitionElementsKind instructions.\n      GVNFlagSet previous_depends = *first_time_depends;\n      GVNFlagSet previous_changes = *first_time_changes;\n      first_time_depends->Add(instr->DependsOnFlags());\n      first_time_changes->Add(instr->ChangesFlags());\n      if (!(previous_depends == *first_time_depends)) {\n        TRACE_GVN_1(\"Updated first-time accumulated %s\\n\",\n                    *GetGVNFlagsString(*first_time_depends));\n      }\n      if (!(previous_changes == *first_time_changes)) {\n        TRACE_GVN_1(\"Updated first-time accumulated %s\\n\",\n                    *GetGVNFlagsString(*first_time_changes));\n      }\n    }\n    instr = next;\n  }\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":456300,"func":"int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)\n{\n    int ret = -1;\n\n    uint8_t *host_startaddr = rb->host + start;\n\n    if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) {\n        error_report(\"ram_block_discard_range: Unaligned start address: %p\",\n                     host_startaddr);\n        goto err;\n    }\n\n    if ((start + length) <= rb->used_length) {\n        bool need_madvise, need_fallocate;\n        if (!QEMU_IS_ALIGNED(length, rb->page_size)) {\n            error_report(\"ram_block_discard_range: Unaligned length: %zx\",\n                         length);\n            goto err;\n        }\n\n        errno = ENOTSUP; \/* If we are missing MADVISE etc *\/\n\n        \/* The logic here is messy;\n         *    madvise DONTNEED fails for hugepages\n         *    fallocate works on hugepages and shmem\n         *\/\n        need_madvise = (rb->page_size == qemu_host_page_size);\n        need_fallocate = rb->fd != -1;\n        if (need_fallocate) {\n            \/* For a file, this causes the area of the file to be zero'd\n             * if read, and for hugetlbfs also causes it to be unmapped\n             * so a userfault will trigger.\n             *\/\n#ifdef CONFIG_FALLOCATE_PUNCH_HOLE\n            ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,\n                            start, length);\n            if (ret) {\n                ret = -errno;\n                error_report(\"ram_block_discard_range: Failed to fallocate \"\n                             \"%s:%\" PRIx64 \" +%zx (%d)\",\n                             rb->idstr, start, length, ret);\n                goto err;\n            }\n#else\n            ret = -ENOSYS;\n            error_report(\"ram_block_discard_range: fallocate not available\/file\"\n                         \"%s:%\" PRIx64 \" +%zx (%d)\",\n                         rb->idstr, start, length, ret);\n            goto err;\n#endif\n        }\n        if (need_madvise) {\n            \/* For normal RAM this causes it to be unmapped,\n             * for shared memory it causes the local mapping to disappear\n             * and to fall back on the file contents (which we just\n             * fallocate'd away).\n             *\/\n#if defined(CONFIG_MADVISE)\n            ret =  madvise(host_startaddr, length, MADV_DONTNEED);\n            if (ret) {\n                ret = -errno;\n                error_report(\"ram_block_discard_range: Failed to discard range \"\n                             \"%s:%\" PRIx64 \" +%zx (%d)\",\n                             rb->idstr, start, length, ret);\n                goto err;\n            }\n#else\n            ret = -ENOSYS;\n            error_report(\"ram_block_discard_range: MADVISE not available\"\n                         \"%s:%\" PRIx64 \" +%zx (%d)\",\n                         rb->idstr, start, length, ret);\n            goto err;\n#endif\n        }\n        trace_ram_block_discard_range(rb->idstr, host_startaddr, length,\n                                      need_madvise, need_fallocate, ret);\n    } else {\n        error_report(\"ram_block_discard_range: Overrun block '%s' (%\" PRIu64\n                     \"\/%zx\/\" RAM_ADDR_FMT\")\",\n                     rb->idstr, start, length, rb->used_length);\n    }\n\nerr:\n    return ret;\n}","target":0,"code_token_length":757,"total_token_length":993,"max_tokens_setting":1024}
+{"idx":166184,"func":"static int cloop_open(BlockDriverState *bs, QDict *options, int flags,\n                      Error **errp)\n{\n    BDRVCloopState *s = bs->opaque;\n    uint32_t offsets_size, max_compressed_block_size = 1, i;\n    int ret;\n\n    bs->read_only = 1;\n\n    \/* read header *\/\n    ret = bdrv_pread(bs->file, 128, &s->block_size, 4);\n    if (ret < 0) {\n        return ret;\n    }\n    s->block_size = be32_to_cpu(s->block_size);\n    if (s->block_size % 512) {\n        error_setg(errp, \"block_size %u must be a multiple of 512\",\n                   s->block_size);\n        return -EINVAL;\n    }\n    if (s->block_size == 0) {\n        error_setg(errp, \"block_size cannot be zero\");\n        return -EINVAL;\n    }\n\n    \/* cloop's create_compressed_fs.c warns about block sizes beyond 256 KB but\n     * we can accept more.  Prevent ridiculous values like 4 GB - 1 since we\n     * need a buffer this big.\n     *\/\n    if (s->block_size > MAX_BLOCK_SIZE) {\n        error_setg(errp, \"block_size %u must be %u MB or less\",\n                   s->block_size,\n                   MAX_BLOCK_SIZE \/ (1024 * 1024));\n        return -EINVAL;\n    }\n\n    ret = bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4);\n    if (ret < 0) {\n        return ret;\n    }\n     s->n_blocks = be32_to_cpu(s->n_blocks);\n \n     \/* read offsets *\/\n    if (s->n_blocks > UINT32_MAX \/ sizeof(uint64_t)) {\n        \/* Prevent integer overflow *\/\n        error_setg(errp, \"n_blocks %u must be %zu or less\",\n                   s->n_blocks,\n                   UINT32_MAX \/ sizeof(uint64_t));\n        return -EINVAL;\n    }\n     offsets_size = s->n_blocks * sizeof(uint64_t);\n     s->offsets = g_malloc(offsets_size);\n        if (i > 0) {\n            uint32_t size = s->offsets[i] - s->offsets[i - 1];\n            if (size > max_compressed_block_size) {\n                max_compressed_block_size = size;\n            }\n        }\n    }\n","target":0,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":90848,"func":"static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)\n{\n\tstruct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;\n\tstruct smb_t2_rsp *pSMBt  = (struct smb_t2_rsp *)pTargetSMB;\n\tchar *data_area_of_target;\n\tchar *data_area_of_buf2;\n\tint remaining;\n\t__u16 byte_count, total_data_size, total_in_buf, total_in_buf2;\n\n\ttotal_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);\n\n\tif (total_data_size !=\n\t    get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount))\n\t\tcFYI(1, \"total data size of primary and secondary t2 differ\");\n\n\ttotal_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);\n\n\tremaining = total_data_size - total_in_buf;\n\n\tif (remaining < 0)\n\t\treturn -EINVAL;\n\n\tif (remaining == 0) \/* nothing to do, ignore *\/\n\t\treturn 0;\n\n\ttotal_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount);\n\tif (remaining < total_in_buf2) {\n\t\tcFYI(1, \"transact2 2nd response contains too much data\");\n\t}\n\n\t\/* find end of first SMB data area *\/\n\tdata_area_of_target = (char *)&pSMBt->hdr.Protocol +\n\t\t\t\tget_unaligned_le16(&pSMBt->t2_rsp.DataOffset);\n\t\/* validate target area *\/\n\n\tdata_area_of_buf2 = (char *)&pSMB2->hdr.Protocol +\n\t\t\t\tget_unaligned_le16(&pSMB2->t2_rsp.DataOffset);\n\n\tdata_area_of_target += total_in_buf;\n\n\t\/* copy second buffer into end of first buffer *\/\n\tmemcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);\n\ttotal_in_buf += total_in_buf2;\n\tput_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount);\n\tbyte_count = get_bcc_le(pTargetSMB);\n\tbyte_count += total_in_buf2;\n\tput_bcc_le(byte_count, pTargetSMB);\n\n\tbyte_count = pTargetSMB->smb_buf_length;\n\tbyte_count += total_in_buf2;\n\n\t\/* BB also add check that we are not beyond maximum buffer size *\/\n\n\tpTargetSMB->smb_buf_length = byte_count;\n\n\tif (remaining == total_in_buf2) {\n\t\tcFYI(1, \"found the last secondary response\");\n\t\treturn 0; \/* we are done *\/\n\t} else \/* more responses to go *\/\n\t\treturn 1;\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":321662,"func":"static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)\n\n{\n\n    sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));\n\n    CPUCore *cc = CPU_CORE(OBJECT(dev));\n\n    const char *typename = object_class_get_name(sc->cpu_class);\n\n    size_t size = object_type_get_instance_size(typename);\n\n    Error *local_err = NULL;\n\n    Object *obj;\n\n    int i;\n\n\n\n    sc->threads = g_malloc0(size * cc->nr_threads);\n\n    for (i = 0; i < cc->nr_threads; i++) {\n\n        char id[32];\n\n        void *obj = sc->threads + i * size;\n\n\n\n        object_initialize(obj, size, typename);\n\n        snprintf(id, sizeof(id), \"thread[%d]\", i);\n\n        object_property_add_child(OBJECT(sc), id, obj, &local_err);\n\n        if (local_err) {\n\n            goto err;\n\n        }\n\n\n    }\n\n    object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err);\n\n    if (local_err) {\n\n        goto err;\n\n    } else {\n\n        return;\n\n    }\n\n\n\nerr:\n\n    while (--i >= 0) {\n\n        obj = sc->threads + i * size;\n\n        object_unparent(obj);\n\n    }\n\n    g_free(sc->threads);\n\n    error_propagate(errp, local_err);\n\n}","target":1,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":345224,"func":"static int date_from_ISO8601 (const char *text, time_t * value) {\n   struct tm tm;\n   int n;\n   int i;\n   char buf[30];\n\t\n\n\tif (strchr (text, '-')) {\n\t\tchar *p = (char *) text, *p2 = buf;\n\t\twhile (p && *p) {\n\t\t\tif (*p != '-') {\n\t\t\t\t*p2 = *p;\n\t\t\t\tp2++;\n\t\t\t\tif (p2-buf >= sizeof(buf)) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp++;\n\t\t}\n\t\t\ttext = buf;\n\t}\n\n\n   tm.tm_isdst = -1;\n\n#define XMLRPC_IS_NUMBER(x) if (x < '0' || x > '9') return -1;\n\n   n = 1000;\n   tm.tm_year = 0;\n   for(i = 0; i < 4; i++) {\n      XMLRPC_IS_NUMBER(text[i])\n      tm.tm_year += (text[i]-'0')*n;\n      n \/= 10;\n   }\n   n = 10;\n   tm.tm_mon = 0;\n   for(i = 0; i < 2; i++) {\n      XMLRPC_IS_NUMBER(text[i])\n      tm.tm_mon += (text[i+4]-'0')*n;\n      n \/= 10;\n   }\n   tm.tm_mon --;\n\n   n = 10;\n   tm.tm_mday = 0;\n   for(i = 0; i < 2; i++) {\n      XMLRPC_IS_NUMBER(text[i])\n      tm.tm_mday += (text[i+6]-'0')*n;\n      n \/= 10;\n   }\n\n   n = 10;\n   tm.tm_hour = 0;\n   for(i = 0; i < 2; i++) {\n      XMLRPC_IS_NUMBER(text[i])\n      tm.tm_hour += (text[i+9]-'0')*n;\n      n \/= 10;\n   }\n\n   n = 10;\n   tm.tm_min = 0;\n   for(i = 0; i < 2; i++) {\n      XMLRPC_IS_NUMBER(text[i])\n      tm.tm_min += (text[i+12]-'0')*n;\n      n \/= 10;\n   }\n\n   n = 10;\n   tm.tm_sec = 0;\n   for(i = 0; i < 2; i++) {\n      XMLRPC_IS_NUMBER(text[i])\n      tm.tm_sec += (text[i+15]-'0')*n;\n      n \/= 10;\n   }\n\n   tm.tm_year -= 1900;\n\n   *value = mkgmtime(&tm);\n\n   return 0;\n\n}","target":1,"code_token_length":580,"total_token_length":816,"max_tokens_setting":1024}
+{"idx":80021,"func":"request_env(agooReq req, VALUE self) {\n    if (Qnil == (VALUE)req->env) {\n\tvolatile VALUE\tenv = rb_hash_new();\n\n\t\/\/ As described by\n\t\/\/ http:\/\/www.rubydoc.info\/github\/rack\/rack\/master\/file\/SPEC and\n\t\/\/ https:\/\/github.com\/rack\/rack\/blob\/master\/SPEC.\n\n\trb_hash_aset(env, request_method_val, req_method(req));\n\trb_hash_aset(env, script_name_val, req_script_name(req));\n\trb_hash_aset(env, path_info_val, req_path_info(req));\n\trb_hash_aset(env, query_string_val, req_query_string(req));\n\trb_hash_aset(env, remote_addr_val, req_remote_addr(req));\n\trb_hash_aset(env, server_port_val, req_server_port(req));\n\trb_hash_aset(env, server_name_val, req_server_name(req));\n\tfill_headers(req, env);\n\trb_hash_aset(env, rack_version_val, rack_version_val_val);\n\trb_hash_aset(env, rack_url_scheme_val, req_rack_url_scheme(req));\n\trb_hash_aset(env, rack_input_val, req_rack_input(req));\n\trb_hash_aset(env, rack_errors_val, req_rack_errors(req));\n\trb_hash_aset(env, rack_multithread_val, req_rack_multithread(req));\n\trb_hash_aset(env, rack_multiprocess_val, Qfalse);\n\trb_hash_aset(env, rack_run_once_val, Qfalse);\n\trb_hash_aset(env, rack_logger_val, req_rack_logger(req));\n\trb_hash_aset(env, rack_upgrade_val, req_rack_upgrade(req));\n\trb_hash_aset(env, rack_hijackq_val, Qtrue);\n\n\t\/\/ TBD should return IO on #call and set hijack_io on env object that\n\t\/\/  has a call method that wraps the req->res->con->sock then set the\n\t\/\/  sock to 0 or maybe con. mutex? env[rack.hijack_io] = IO.new(sock,\n\t\/\/  \"rw\") - maybe it works.\n\t\/\/\n\t\/\/ set a flag on con to indicate it has been hijacked\n\t\/\/ then set sock to 0 in con loop and destroy con\n\trb_hash_aset(env, rack_hijack_val, self);\n\trb_hash_aset(env, rack_hijack_io_val, Qnil);\n\n\tif (agoo_server.rack_early_hints) {\n\t    volatile VALUE\teh = agoo_early_hints_new(req);\n\n\t    rb_hash_aset(env, early_hints_val, eh);\n\t}\n\treq->env = (void*)env;\n    }\n    return (VALUE)req->env;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":43775,"func":"read_redo(int init, int old_redo)\n{\n    static buffblock_T\t*bp;\n    static char_u\t*p;\n    int\t\t\tc;\n    int\t\t\tn;\n    char_u\t\tbuf[MB_MAXBYTES + 1];\n    int\t\t\ti;\n\n    if (init)\n    {\n\tif (old_redo)\n\t    bp = old_redobuff.bh_first.b_next;\n\telse\n\t    bp = redobuff.bh_first.b_next;\n\tif (bp == NULL)\n\t    return FAIL;\n\tp = bp->b_str;\n\treturn OK;\n    }\n    if ((c = *p) != NUL)\n    {\n\t\/* Reverse the conversion done by add_char_buff() *\/\n\t\/* For a multi-byte character get all the bytes and return the\n\t * converted character. *\/\n\tif (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL))\n\t    n = MB_BYTE2LEN_CHECK(c);\n\telse\n\t    n = 1;\n\tfor (i = 0; ; ++i)\n\t{\n\t    if (c == K_SPECIAL) \/* special key or escaped K_SPECIAL *\/\n\t    {\n\t\tc = TO_SPECIAL(p[1], p[2]);\n\t\tp += 2;\n\t    }\n#ifdef FEAT_GUI\n\t    if (c == CSI)\t\/* escaped CSI *\/\n\t\tp += 2;\n#endif\n\t    if (*++p == NUL && bp->b_next != NULL)\n\t    {\n\t\tbp = bp->b_next;\n\t\tp = bp->b_str;\n\t    }\n\t    buf[i] = c;\n\t    if (i == n - 1)\t\/* last byte of a character *\/\n\t    {\n\t\tif (n != 1)\n\t\t    c = (*mb_ptr2char)(buf);\n\t\tbreak;\n\t    }\n\t    c = *p;\n\t    if (c == NUL)\t\/* cannot happen? *\/\n\t\tbreak;\n\t}\n    }\n\n    return c;\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":287040,"func":"int migrate_page_move_mapping(struct address_space *mapping,\n\t\tstruct page *newpage, struct page *page,\n\t\tstruct buffer_head *head, enum migrate_mode mode,\n\t\tint extra_count)\n{\n\tint expected_count = 1 + extra_count;\n\tvoid **pslot;\n\n\tif (!mapping) {\n\t\t\/* Anonymous page without mapping *\/\n\t\tif (page_count(page) != expected_count)\n\t\t\treturn -EAGAIN;\n\n\t\t\/* No turning back from here *\/\n\t\tset_page_memcg(newpage, page_memcg(page));\n\t\tnewpage->index = page->index;\n\t\tnewpage->mapping = page->mapping;\n\t\tif (PageSwapBacked(page))\n\t\t\tSetPageSwapBacked(newpage);\n\n\t\treturn MIGRATEPAGE_SUCCESS;\n\t}\n\n\tspin_lock_irq(&mapping->tree_lock);\n\n\tpslot = radix_tree_lookup_slot(&mapping->page_tree,\n \t\t\t\t\tpage_index(page));\n\n\texpected_count += 1 + page_has_private(page);\n\tif (page_count(page) != expected_count ||\n\t\tradix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) {\n\t\tspin_unlock_irq(&mapping->tree_lock);\n\t\treturn -EAGAIN;\n\t}\n\n\tif (!page_freeze_refs(page, expected_count)) {\n\t\tspin_unlock_irq(&mapping->tree_lock);\n\t\treturn -EAGAIN;\n\t}\n\n\t\/*\n\t * In the async migration case of moving a page with buffers, lock the\n\t * buffers using trylock before the mapping is moved. If the mapping\n\t * was moved, we later failed to lock the buffers and could not move\n\t * the mapping back due to an elevated page count, we would have to\n\t * block waiting on other references to be dropped.\n\t *\/\n\tif (mode == MIGRATE_ASYNC && head &&\n\t\t\t!buffer_migrate_lock_buffers(head, mode)) {\n\t\tpage_unfreeze_refs(page, expected_count);\n\t\tspin_unlock_irq(&mapping->tree_lock);\n\t\treturn -EAGAIN;\n\t}\n\n\t\/*\n\t * Now we know that no one else is looking at the page:\n\t * no turning back from here.\n\t *\/\n\tset_page_memcg(newpage, page_memcg(page));\n\tnewpage->index = page->index;\n\tnewpage->mapping = page->mapping;\n\tif (PageSwapBacked(page))\n\t\tSetPageSwapBacked(newpage);\n\n\tget_page(newpage);\t\/* add cache reference *\/\n\tif (PageSwapCache(page)) {\n\t\tSetPageSwapCache(newpage);\n\t\tset_page_private(newpage, page_private(page));\n\t}\n\n\tradix_tree_replace_slot(pslot, newpage);\n\n\t\/*\n\t * Drop cache reference from old page by unfreezing\n\t * to one less reference.\n\t * We know this isn't the last reference.\n\t *\/\n\tpage_unfreeze_refs(page, expected_count - 1);\n\n\t\/*\n\t * If moved to a different zone then also account\n\t * the page for that zone. Other VM counters will be\n\t * taken care of when we establish references to the\n\t * new page and drop references to the old page.\n\t *\n\t * Note that anonymous pages are accounted for\n\t * via NR_FILE_PAGES and NR_ANON_PAGES if they\n\t * are mapped to swap space.\n\t *\/\n\t__dec_zone_page_state(page, NR_FILE_PAGES);\n\t__inc_zone_page_state(newpage, NR_FILE_PAGES);\n\tif (!PageSwapCache(page) && PageSwapBacked(page)) {\n\t\t__dec_zone_page_state(page, NR_SHMEM);\n\t\t__inc_zone_page_state(newpage, NR_SHMEM);\n\t}\n\tspin_unlock_irq(&mapping->tree_lock);\n\n\treturn MIGRATEPAGE_SUCCESS;\n}","target":1,"code_token_length":756,"total_token_length":992,"max_tokens_setting":1024}
+{"idx":133919,"func":"String HHVM_FUNCTION(mb_output_handler,\n                     const String& contents,\n                     int status) {\n  mbfl_string string, result;\n  int last_feed;\n\n  mbfl_encoding *encoding = MBSTRG(current_http_output_encoding);\n\n  \/* start phase only *\/\n  if (status & k_PHP_OUTPUT_HANDLER_START) {\n    \/* delete the converter just in case. *\/\n    if (MBSTRG(outconv)) {\n      MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));\n      mbfl_buffer_converter_delete(MBSTRG(outconv));\n      MBSTRG(outconv) = nullptr;\n    }\n    if (encoding == nullptr) {\n      return contents;\n    }\n\n    \/* analyze mime type *\/\n    String mimetype = g_context->getMimeType();\n    if (!mimetype.empty()) {\n      const char *charset = encoding->mime_name;\n      if (charset) {\n        g_context->setContentType(mimetype, charset);\n      }\n      \/* activate the converter *\/\n      MBSTRG(outconv) = mbfl_buffer_converter_new2\n        (MBSTRG(current_internal_encoding), encoding, 0);\n    }\n  }\n\n  \/* just return if the converter is not activated. *\/\n  if (MBSTRG(outconv) == nullptr) {\n    return contents;\n  }\n\n  \/* flag *\/\n  last_feed = ((status & k_PHP_OUTPUT_HANDLER_END) != 0);\n  \/* mode *\/\n  mbfl_buffer_converter_illegal_mode\n    (MBSTRG(outconv), MBSTRG(current_filter_illegal_mode));\n  mbfl_buffer_converter_illegal_substchar\n    (MBSTRG(outconv), MBSTRG(current_filter_illegal_substchar));\n\n  \/* feed the string *\/\n  mbfl_string_init(&string);\n  string.no_language = MBSTRG(current_language);\n  string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;\n  string.val = (unsigned char *)contents.data();\n  string.len = contents.size();\n  mbfl_buffer_converter_feed(MBSTRG(outconv), &string);\n  if (last_feed) {\n    mbfl_buffer_converter_flush(MBSTRG(outconv));\n  }\n  \/* get the converter output, and return it *\/\n  mbfl_buffer_converter_result(MBSTRG(outconv), &result);\n\n  \/* delete the converter if it is the last feed. *\/\n  if (last_feed) {\n    MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));\n    mbfl_buffer_converter_delete(MBSTRG(outconv));\n    MBSTRG(outconv) = nullptr;\n  }\n\n  return String(reinterpret_cast<char*>(result.val), result.len, AttachString);\n}","target":0,"code_token_length":558,"total_token_length":794,"max_tokens_setting":1024}
+{"idx":286768,"func":"static int aasc_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {\n const uint8_t * buf = avpkt -> data ;\n int buf_size = avpkt -> size ;\n AascContext * s = avctx -> priv_data ;\n int compr , i , stride , ret ;\n s -> frame . reference = 1 ;\n s -> frame . buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE ;\n if ( ( ret = avctx -> reget_buffer ( avctx , & s -> frame ) ) < 0 ) {\n av_log ( avctx , AV_LOG_ERROR , \"reget_buffer() failed\\n\" ) ;\n return ret ;\n }\n compr = AV_RL32 ( buf ) ;\n buf += 4 ;\n buf_size -= 4 ;\n switch ( compr ) {\n case 0 : stride = ( avctx -> width * 3 + 3 ) & ~ 3 ;\n for ( i = avctx -> height - 1 ;\n i >= 0 ;\n i -- ) {\n memcpy ( s -> frame . data [ 0 ] + i * s -> frame . linesize [ 0 ] , buf , avctx -> width * 3 ) ;\n buf += stride ;\n }\n break ;\n case 1 : bytestream2_init ( & s -> gb , buf , buf_size ) ;\n ff_msrle_decode ( avctx , ( AVPicture * ) & s -> frame , 8 , & s -> gb ) ;\n break ;\n default : av_log ( avctx , AV_LOG_ERROR , \"Unknown compression type %d\\n\" , compr ) ;\n return AVERROR_INVALIDDATA ;\n }\n * got_frame = 1 ;\n * ( AVFrame * ) data = s -> frame ;\n return buf_size ;\n }","target":1,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":103915,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  auto* params = reinterpret_cast<TfLiteAddParams*>(node->builtin_data);\n\n  TFLITE_DCHECK(node->user_data != nullptr);\n  const OpData* data = static_cast<const OpData*>(node->user_data);\n\n  const TfLiteEvalTensor* input1 =\n      tflite::micro::GetEvalInput(context, node, kInputTensor1);\n  const TfLiteEvalTensor* input2 =\n      tflite::micro::GetEvalInput(context, node, kInputTensor2);\n  TfLiteEvalTensor* output =\n      tflite::micro::GetEvalOutput(context, node, kOutputTensor);\n\n  if (output->type == kTfLiteFloat32) {\n    EvalAdd(context, node, params, data, input1, input2, output);\n  } else if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8) {\n    TF_LITE_ENSURE_OK(context, EvalAddQuantized(context, node, params, data,\n                                                input1, input2, output));\n  } else {\n    TF_LITE_KERNEL_LOG(context, \"Type %s (%d) not supported.\",\n                       TfLiteTypeGetName(output->type), output->type);\n    return kTfLiteError;\n  }\n\n  return kTfLiteOk;\n}","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":435281,"func":"static void lsi_do_dma(LSIState *s, int out)\n{\n    uint32_t count;\n    dma_addr_t addr;\n    SCSIDevice *dev;\n\n    assert(s->current);\n    if (!s->current->dma_len) {\n        \/* Wait until data is available.  *\/\n        trace_lsi_do_dma_unavailable();\n        return;\n    }\n\n    dev = s->current->req->dev;\n    assert(dev);\n\n    count = s->dbc;\n    if (count > s->current->dma_len)\n        count = s->current->dma_len;\n\n    addr = s->dnad;\n    \/* both 40 and Table Indirect 64-bit DMAs store upper bits in dnad64 *\/\n    if (lsi_dma_40bit(s) || lsi_dma_ti64bit(s))\n        addr |= ((uint64_t)s->dnad64 << 32);\n    else if (s->dbms)\n        addr |= ((uint64_t)s->dbms << 32);\n    else if (s->sbms)\n        addr |= ((uint64_t)s->sbms << 32);\n\n    trace_lsi_do_dma(addr, count);\n    s->csbc += count;\n    s->dnad += count;\n    s->dbc -= count;\n     if (s->current->dma_buf == NULL) {\n        s->current->dma_buf = scsi_req_get_buf(s->current->req);\n    }\n    \/* ??? Set SFBR to first data byte.  *\/\n    if (out) {\n        lsi_mem_read(s, addr, s->current->dma_buf, count);\n    } else {\n        lsi_mem_write(s, addr, s->current->dma_buf, count);\n    }\n    s->current->dma_len -= count;\n    if (s->current->dma_len == 0) {\n        s->current->dma_buf = NULL;\n        scsi_req_continue(s->current->req);\n    } else {\n        s->current->dma_buf += count;\n        lsi_resume_script(s);\n    }\n}","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":458863,"func":"write_ct_md(struct dp_packet *pkt, uint16_t zone, const struct conn *conn,\n            const struct conn_key *key, const struct alg_exp_node *alg_exp)\n{\n    pkt->md.ct_state |= CS_TRACKED;\n    pkt->md.ct_zone = zone;\n    pkt->md.ct_mark = conn ? conn->mark : 0;\n    pkt->md.ct_label = conn ? conn->label : OVS_U128_ZERO;\n\n    \/* Use the original direction tuple if we have it. *\/\n    if (conn) {\n        if (conn->alg_related) {\n            key = &conn->master_key;\n        } else {\n            key = &conn->key;\n        }\n    } else if (alg_exp) {\n        pkt->md.ct_mark = alg_exp->master_mark;\n        pkt->md.ct_label = alg_exp->master_label;\n        key = &alg_exp->master_key;\n    }\n    pkt->md.ct_orig_tuple_ipv6 = false;\n    if (key) {\n        if (key->dl_type == htons(ETH_TYPE_IP)) {\n\n            pkt->md.ct_orig_tuple.ipv4 = (struct ovs_key_ct_tuple_ipv4) {\n                key->src.addr.ipv4_aligned,\n                key->dst.addr.ipv4_aligned,\n                key->nw_proto != IPPROTO_ICMP\n                ? key->src.port : htons(key->src.icmp_type),\n                key->nw_proto != IPPROTO_ICMP\n                ? key->dst.port : htons(key->src.icmp_code),\n                key->nw_proto,\n            };\n        } else {\n            pkt->md.ct_orig_tuple_ipv6 = true;\n            pkt->md.ct_orig_tuple.ipv6 = (struct ovs_key_ct_tuple_ipv6) {\n                key->src.addr.ipv6_aligned,\n                key->dst.addr.ipv6_aligned,\n                key->nw_proto != IPPROTO_ICMPV6\n                ? key->src.port : htons(key->src.icmp_type),\n                key->nw_proto != IPPROTO_ICMPV6\n                ? key->dst.port : htons(key->src.icmp_code),\n                key->nw_proto,\n            };\n        }\n    } else {\n        memset(&pkt->md.ct_orig_tuple, 0, sizeof pkt->md.ct_orig_tuple);\n    }\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":99330,"func":"rdpRdp* rdp_new(rdpContext* context)\n{\n\trdpRdp* rdp;\n\tDWORD flags;\n\tBOOL newSettings = FALSE;\n\trdp = (rdpRdp*)calloc(1, sizeof(rdpRdp));\n\n\tif (!rdp)\n\t\treturn NULL;\n\n\trdp->context = context;\n\trdp->instance = context->instance;\n\tflags = 0;\n\n\tif (context->ServerMode)\n\t\tflags |= FREERDP_SETTINGS_SERVER_MODE;\n\n\tif (!context->settings)\n\t{\n\t\tcontext->settings = freerdp_settings_new(flags);\n\n\t\tif (!context->settings)\n\t\t\tgoto out_free;\n\n\t\tnewSettings = TRUE;\n\t}\n\n\trdp->settings = context->settings;\n\n\tif (context->instance)\n\t{\n\t\trdp->settings->instance = context->instance;\n\t\tcontext->instance->settings = rdp->settings;\n\t}\n\telse if (context->peer)\n\t{\n\t\trdp->settings->instance = context->peer;\n\t\tcontext->peer->settings = rdp->settings;\n\t}\n\n\trdp->transport = transport_new(context);\n\n\tif (!rdp->transport)\n\t\tgoto out_free_settings;\n\n\trdp->license = license_new(rdp);\n\n\tif (!rdp->license)\n\t\tgoto out_free_transport;\n\n\trdp->input = input_new(rdp);\n\n\tif (!rdp->input)\n\t\tgoto out_free_license;\n\n\trdp->update = update_new(rdp);\n\n\tif (!rdp->update)\n\t\tgoto out_free_input;\n\n\trdp->fastpath = fastpath_new(rdp);\n\n\tif (!rdp->fastpath)\n\t\tgoto out_free_update;\n\n\trdp->nego = nego_new(rdp->transport);\n\n\tif (!rdp->nego)\n\t\tgoto out_free_fastpath;\n\n\trdp->mcs = mcs_new(rdp->transport);\n\n\tif (!rdp->mcs)\n\t\tgoto out_free_nego;\n\n\trdp->redirection = redirection_new();\n\n\tif (!rdp->redirection)\n\t\tgoto out_free_mcs;\n\n\trdp->autodetect = autodetect_new();\n\n\tif (!rdp->autodetect)\n\t\tgoto out_free_redirection;\n\n\trdp->heartbeat = heartbeat_new();\n\n\tif (!rdp->heartbeat)\n\t\tgoto out_free_autodetect;\n\n\trdp->multitransport = multitransport_new();\n\n\tif (!rdp->multitransport)\n\t\tgoto out_free_heartbeat;\n\n\trdp->bulk = bulk_new(context);\n\n\tif (!rdp->bulk)\n\t\tgoto out_free_multitransport;\n\n\treturn rdp;\nout_free_multitransport:\n\tmultitransport_free(rdp->multitransport);\nout_free_heartbeat:\n\theartbeat_free(rdp->heartbeat);\nout_free_autodetect:\n\tautodetect_free(rdp->autodetect);\nout_free_redirection:\n\tredirection_free(rdp->redirection);\nout_free_mcs:\n\tmcs_free(rdp->mcs);\nout_free_nego:\n\tnego_free(rdp->nego);\nout_free_fastpath:\n\tfastpath_free(rdp->fastpath);\nout_free_update:\n\tupdate_free(rdp->update);\nout_free_input:\n\tinput_free(rdp->input);\nout_free_license:\n\tlicense_free(rdp->license);\nout_free_transport:\n\ttransport_free(rdp->transport);\nout_free_settings:\n\n\tif (newSettings)\n\t\tfreerdp_settings_free(rdp->settings);\n\nout_free:\n\tfree(rdp);\n\treturn NULL;\n}","target":0,"code_token_length":711,"total_token_length":947,"max_tokens_setting":1024}
+{"idx":118854,"func":"rename_buffer(char_u *new_fname)\n{\n    char_u\t*fname, *sfname, *xfname;\n    buf_T\t*buf;\n\n    buf = curbuf;\n    apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);\n    \/\/ buffer changed, don't change name now\n    if (buf != curbuf)\n\treturn FAIL;\n#ifdef FEAT_EVAL\n    if (aborting())\t    \/\/ autocmds may abort script processing\n\treturn FAIL;\n#endif\n    \/*\n     * The name of the current buffer will be changed.\n     * A new (unlisted) buffer entry needs to be made to hold the old file\n     * name, which will become the alternate file name.\n     * But don't set the alternate file name if the buffer didn't have a\n     * name.\n     *\/\n    fname = curbuf->b_ffname;\n    sfname = curbuf->b_sfname;\n    xfname = curbuf->b_fname;\n    curbuf->b_ffname = NULL;\n    curbuf->b_sfname = NULL;\n    if (setfname(curbuf, new_fname, NULL, TRUE) == FAIL)\n    {\n\tcurbuf->b_ffname = fname;\n\tcurbuf->b_sfname = sfname;\n\treturn FAIL;\n    }\n    curbuf->b_flags |= BF_NOTEDITED;\n    if (xfname != NULL && *xfname != NUL)\n    {\n\tbuf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0);\n\tif (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)\n\t    curwin->w_alt_fnum = buf->b_fnum;\n    }\n    vim_free(fname);\n    vim_free(sfname);\n    apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);\n\n    \/\/ Change directories when the 'acd' option is set.\n    DO_AUTOCHDIR;\n    return OK;\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":19234,"func":"static int _compare_path_table ( const void * v1 , const void * v2 ) {\n const struct isoent * p1 , * p2 ;\n const char * s1 , * s2 ;\n int cmp , l ;\n p1 = * ( ( const struct isoent * * ) ( uintptr_t ) v1 ) ;\n p2 = * ( ( const struct isoent * * ) ( uintptr_t ) v2 ) ;\n cmp = p1 -> parent -> dir_number - p2 -> parent -> dir_number ;\n if ( cmp != 0 ) return ( cmp ) ;\n s1 = p1 -> identifier ;\n s2 = p2 -> identifier ;\n l = p1 -> ext_off ;\n if ( l > p2 -> ext_off ) l = p2 -> ext_off ;\n cmp = strncmp ( s1 , s2 , l ) ;\n if ( cmp != 0 ) return ( cmp ) ;\n if ( p1 -> ext_off < p2 -> ext_off ) {\n s2 += l ;\n l = p2 -> ext_off - p1 -> ext_off ;\n while ( l -- ) if ( 0x20 != * s2 ++ ) return ( 0x20 - * ( const unsigned char * ) ( s2 - 1 ) ) ;\n }\n else if ( p1 -> ext_off > p2 -> ext_off ) {\n s1 += l ;\n l = p1 -> ext_off - p2 -> ext_off ;\n while ( l -- ) if ( 0x20 != * s1 ++ ) return ( * ( const unsigned char * ) ( s1 - 1 ) - 0x20 ) ;\n }\n return ( 0 ) ;\n }","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":303314,"func":"struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,\n\t\t\t\t const char *pathname,\n\t\t\t\t const struct rtrs_addr *paths,\n\t\t\t\t size_t paths_num, u16 port,\n\t\t\t\t size_t pdu_sz, u8 reconnect_delay_sec,\n\t\t\t\t s16 max_reconnect_attempts, u32 nr_poll_queues)\n{\n\tstruct rtrs_clt_path *clt_path, *tmp;\n\tstruct rtrs_clt_sess *clt;\n\tint err, i;\n\n\tif (strchr(pathname, '\/') || strchr(pathname, '.')) {\n\t\tpr_err(\"pathname cannot contain \/ and .\\n\");\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tclt = alloc_clt(pathname, paths_num, port, pdu_sz, ops->priv,\n\t\t\tops->link_ev,\n\t\t\treconnect_delay_sec,\n\t\t\tmax_reconnect_attempts);\n\tif (IS_ERR(clt)) {\n\t\terr = PTR_ERR(clt);\n\t\tgoto out;\n\t}\n\tfor (i = 0; i < paths_num; i++) {\n\t\tstruct rtrs_clt_path *clt_path;\n\n\t\tclt_path = alloc_path(clt, &paths[i], nr_cpu_ids,\n\t\t\t\t  nr_poll_queues);\n\t\tif (IS_ERR(clt_path)) {\n\t\t\terr = PTR_ERR(clt_path);\n\t\t\tgoto close_all_path;\n\t\t}\n\t\tif (!i)\n\t\t\tclt_path->for_new_clt = 1;\n\t\tlist_add_tail_rcu(&clt_path->s.entry, &clt->paths_list);\n\n\t\terr = init_path(clt_path);\n\t\tif (err) {\n\t\t\tlist_del_rcu(&clt_path->s.entry);\n\t\t\trtrs_clt_close_conns(clt_path, true);\n\t\t\tfree_percpu(clt_path->stats->pcpu_stats);\n\t\t\tkfree(clt_path->stats);\n\t\t\tfree_path(clt_path);\n\t\t\tgoto close_all_path;\n\t\t}\n\n\t\terr = rtrs_clt_create_path_files(clt_path);\n\t\tif (err) {\n\t\t\tlist_del_rcu(&clt_path->s.entry);\n\t\t\trtrs_clt_close_conns(clt_path, true);\n\t\t\tfree_percpu(clt_path->stats->pcpu_stats);\n\t\t\tkfree(clt_path->stats);\n\t\t\tfree_path(clt_path);\n\t\t\tgoto close_all_path;\n\t\t}\n\t}\n\terr = alloc_permits(clt);\n\tif (err)\n\t\tgoto close_all_path;\n\n\treturn clt;\n\nclose_all_path:\n\tlist_for_each_entry_safe(clt_path, tmp, &clt->paths_list, s.entry) {\n\t\trtrs_clt_destroy_path_files(clt_path, NULL);\n\t\trtrs_clt_close_conns(clt_path, true);\n\t\tkobject_put(&clt_path->kobj);\n\t}\n\trtrs_clt_destroy_sysfs_root(clt);\n\tfree_clt(clt);\n\nout:\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":438897,"func":"cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)\n{\n\tstruct cfg80211_beacon_data *new_beacon;\n\tu8 *pos;\n\tint len;\n\n\tlen = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +\n\t      beacon->proberesp_ies_len + beacon->assocresp_ies_len +\n\t      beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;\n\n\tnew_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);\n\tif (!new_beacon)\n\t\treturn NULL;\n\n\tpos = (u8 *)(new_beacon + 1);\n\tif (beacon->head_len) {\n\t\tnew_beacon->head_len = beacon->head_len;\n\t\tnew_beacon->head = pos;\n\t\tmemcpy(pos, beacon->head, beacon->head_len);\n\t\tpos += beacon->head_len;\n\t}\n\tif (beacon->tail_len) {\n\t\tnew_beacon->tail_len = beacon->tail_len;\n\t\tnew_beacon->tail = pos;\n\t\tmemcpy(pos, beacon->tail, beacon->tail_len);\n\t\tpos += beacon->tail_len;\n\t}\n\tif (beacon->beacon_ies_len) {\n\t\tnew_beacon->beacon_ies_len = beacon->beacon_ies_len;\n\t\tnew_beacon->beacon_ies = pos;\n\t\tmemcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);\n\t\tpos += beacon->beacon_ies_len;\n\t}\n\tif (beacon->proberesp_ies_len) {\n\t\tnew_beacon->proberesp_ies_len = beacon->proberesp_ies_len;\n\t\tnew_beacon->proberesp_ies = pos;\n\t\tmemcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);\n\t\tpos += beacon->proberesp_ies_len;\n\t}\n\tif (beacon->assocresp_ies_len) {\n\t\tnew_beacon->assocresp_ies_len = beacon->assocresp_ies_len;\n\t\tnew_beacon->assocresp_ies = pos;\n\t\tmemcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);\n\t\tpos += beacon->assocresp_ies_len;\n\t}\n\tif (beacon->probe_resp_len) {\n\t\tnew_beacon->probe_resp_len = beacon->probe_resp_len;\n\t\tnew_beacon->probe_resp = pos;\n\t\tmemcpy(pos, beacon->probe_resp, beacon->probe_resp_len);\n\t\tpos += beacon->probe_resp_len;\n\t}\n\n\t\/* might copy -1, meaning no changes requested *\/\n\tnew_beacon->ftm_responder = beacon->ftm_responder;\n\tif (beacon->lci) {\n\t\tnew_beacon->lci_len = beacon->lci_len;\n\t\tnew_beacon->lci = pos;\n\t\tmemcpy(pos, beacon->lci, beacon->lci_len);\n\t\tpos += beacon->lci_len;\n\t}\n\tif (beacon->civicloc) {\n\t\tnew_beacon->civicloc_len = beacon->civicloc_len;\n\t\tnew_beacon->civicloc = pos;\n\t\tmemcpy(pos, beacon->civicloc, beacon->civicloc_len);\n\t\tpos += beacon->civicloc_len;\n\t}\n\n\treturn new_beacon;\n}","target":0,"code_token_length":734,"total_token_length":970,"max_tokens_setting":1024}
+{"idx":72697,"func":"static int prepare_signal(int sig, struct task_struct *p, int from_ancestor_ns)\n{\n\tstruct signal_struct *signal = p->signal;\n\tstruct task_struct *t;\n\n\tif (unlikely(signal->flags & SIGNAL_GROUP_EXIT)) {\n\t\t\/*\n\t\t * The process is in the middle of dying, nothing to do.\n\t\t *\/\n\t} else if (sig_kernel_stop(sig)) {\n\t\t\/*\n\t\t * This is a stop signal.  Remove SIGCONT from all queues.\n\t\t *\/\n\t\trm_from_queue(sigmask(SIGCONT), &signal->shared_pending);\n\t\tt = p;\n\t\tdo {\n\t\t\trm_from_queue(sigmask(SIGCONT), &t->pending);\n\t\t} while_each_thread(p, t);\n\t} else if (sig == SIGCONT) {\n\t\tunsigned int why;\n\t\t\/*\n\t\t * Remove all stop signals from all queues,\n\t\t * and wake all threads.\n\t\t *\/\n\t\trm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending);\n\t\tt = p;\n\t\tdo {\n\t\t\tunsigned int state;\n\t\t\trm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);\n\t\t\t\/*\n\t\t\t * If there is a handler for SIGCONT, we must make\n\t\t\t * sure that no thread returns to user mode before\n\t\t\t * we post the signal, in case it was the only\n\t\t\t * thread eligible to run the signal handler--then\n\t\t\t * it must not do anything between resuming and\n\t\t\t * running the handler.  With the TIF_SIGPENDING\n\t\t\t * flag set, the thread will pause and acquire the\n\t\t\t * siglock that we hold now and until we've queued\n\t\t\t * the pending signal.\n\t\t\t *\n\t\t\t * Wake up the stopped thread _after_ setting\n\t\t\t * TIF_SIGPENDING\n\t\t\t *\/\n\t\t\tstate = __TASK_STOPPED;\n\t\t\tif (sig_user_defined(t, SIGCONT) && !sigismember(&t->blocked, SIGCONT)) {\n\t\t\t\tset_tsk_thread_flag(t, TIF_SIGPENDING);\n\t\t\t\tstate |= TASK_INTERRUPTIBLE;\n\t\t\t}\n\t\t\twake_up_state(t, state);\n\t\t} while_each_thread(p, t);\n\n\t\t\/*\n\t\t * Notify the parent with CLD_CONTINUED if we were stopped.\n\t\t *\n\t\t * If we were in the middle of a group stop, we pretend it\n\t\t * was already finished, and then continued. Since SIGCHLD\n\t\t * doesn't queue we report only CLD_STOPPED, as if the next\n\t\t * CLD_CONTINUED was dropped.\n\t\t *\/\n\t\twhy = 0;\n\t\tif (signal->flags & SIGNAL_STOP_STOPPED)\n\t\t\twhy |= SIGNAL_CLD_CONTINUED;\n\t\telse if (signal->group_stop_count)\n\t\t\twhy |= SIGNAL_CLD_STOPPED;\n\n\t\tif (why) {\n\t\t\t\/*\n\t\t\t * The first thread which returns from do_signal_stop()\n\t\t\t * will take ->siglock, notice SIGNAL_CLD_MASK, and\n\t\t\t * notify its parent. See get_signal_to_deliver().\n\t\t\t *\/\n\t\t\tsignal->flags = why | SIGNAL_STOP_CONTINUED;\n\t\t\tsignal->group_stop_count = 0;\n\t\t\tsignal->group_exit_code = 0;\n\t\t} else {\n\t\t\t\/*\n\t\t\t * We are not stopped, but there could be a stop\n\t\t\t * signal in the middle of being processed after\n\t\t\t * being removed from the queue.  Clear that too.\n\t\t\t *\/\n\t\t\tsignal->flags &= ~SIGNAL_STOP_DEQUEUED;\n\t\t}\n\t}\n\n\treturn !sig_ignored(p, sig, from_ancestor_ns);\n}","target":0,"code_token_length":742,"total_token_length":978,"max_tokens_setting":1024}
+{"idx":270192,"func":"static Jsi_RC jsi_csGetKey(Jsi_Interp *interp, CDataObj *cd, Jsi_Value *arg, void **kPtr, size_t ksize, int anum)\n{\n    void *kBuf = *kPtr;\n    *kPtr = NULL;\n    if (!arg)\n        return Jsi_LogError(\"missing key arg\");;\n    Jsi_Number nval = 0;\n    switch (cd->keyType) {\n        case JSI_KEYS_STRING:\n        case JSI_KEYS_STRINGKEY:\n            *kPtr = (void*)Jsi_ValueString(interp, arg, NULL);\n            if (!*kPtr)\n                return Jsi_LogError(\"arg %d: expected string key\", anum);\n            break;\n        case JSI_KEYS_ONEWORD:\n            if (Jsi_ValueGetNumber(interp, arg, &nval) != JSI_OK)\n                return Jsi_LogError(\"arg %d: expected number key\", anum);\n            *kPtr = (void*)(uintptr_t)nval;\n            break;\n        default: {\n            if (!cd->slKey) {\nbadkey:\n                return Jsi_LogError(\"arg %d: expected struct key\", anum);\n            }\n            if (arg->vt == JSI_VT_OBJECT && arg->d.obj->ot == JSI_OT_OBJECT) {\n                if (cd->slKey->size>ksize || !kBuf)\n                    goto badkey;\n                memset(kBuf, 0, cd->slKey->size);\n                if (Jsi_OptionsConf(interp, (Jsi_OptionSpec*)cd->keysf, kBuf, arg, NULL, 0) != JSI_OK)\n                    return JSI_ERROR;\n                *kPtr = kBuf;\n            } else\n                return Jsi_LogError(\"arg %d: expected object key\", anum);\n        }\n    }\n    return JSI_OK;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":176033,"func":"void impeg2d_bit_stream_init(stream_t *ps_stream,\n                             UWORD8 *pu1_byte_buf,\n                             UWORD32 u4_max_offset)\n{\n    UWORD8      *pu1_byte_buff;\n    UWORD32     *pu4_word_buf;\n size_t     u4_byte_addr;\n    UWORD32     u4_temp1,u4_temp2;\n\n \/* Set parameters of the stream structure.Associate the structure with\n       the file *\/\n    ps_stream->pv_bs_buf           = pu1_byte_buf;\n    ps_stream->u4_offset              = 0;\n\n \/* Take care of unaligned address and create\n       nearest greater aligned address *\/\n    pu1_byte_buff               = (UWORD8 *)pu1_byte_buf;\n    u4_byte_addr                = (size_t)pu1_byte_buff;\n\n if((u4_byte_addr & 3) == 1)\n {\n        u4_temp1                = ((UWORD32)(*pu1_byte_buff++)) << 8;\n        u4_temp1                += ((UWORD32)(*pu1_byte_buff++)) << 16;\n        u4_temp1                += ((UWORD32)(*pu1_byte_buff++)) << 24;\n\n        pu4_word_buf            = (UWORD32 *)pu1_byte_buff;\n\n        ps_stream->u4_offset          = 8;\n }\n else if((u4_byte_addr & 3) == 2)\n {\n        u4_temp1                = ((UWORD32)(*pu1_byte_buff++)) << 16;\n        u4_temp1                += ((UWORD32)(*pu1_byte_buff++)) << 24;\n\n        pu4_word_buf            = (UWORD32 *)pu1_byte_buff;\n\n        ps_stream->u4_offset          = 16;\n }\n else if((u4_byte_addr & 3) == 3)\n {\n        u4_temp1                = (((UWORD32)(*pu1_byte_buff++)) << 24);\n\n        pu4_word_buf            = (UWORD32 *)pu1_byte_buff;\n\n        ps_stream->u4_offset          = 24;\n }\n else\n {\n        pu4_word_buf            = (UWORD32 *)pu1_byte_buff;\n\n        u4_temp1                = *pu4_word_buf++;\n        ps_stream->u4_offset          = 0;\n }\n\n \/* convert the endian ness from Little endian to Big endian so that bits\n       are in proper order from MSB to LSB *\/\n    CONV_LE_TO_BE(u4_temp2,u4_temp1)\n\n \/* Read One more word for buf nxt *\/\n    u4_temp1                    = *pu4_word_buf++;\n    ps_stream->u4_buf              = u4_temp2;\n\n    CONV_LE_TO_BE(u4_temp2,u4_temp1)\n\n    ps_stream->u4_buf_nxt          = u4_temp2;\n\n    ps_stream->pu4_buf_aligned      = pu4_word_buf;\n\n\n    ps_stream->u4_max_offset        = (u4_max_offset << 3) + ps_stream->u4_offset;\n\n return;\n}\n","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":411327,"func":"      \/\/ Tell for each character of an expression if it is inside a string or not.\n      CImg<boolT> is_inside_string(CImg<charT>& expr) const {\n        bool is_escaped = false, next_is_escaped = false;\n        unsigned int mode = 0, next_mode = 0; \/\/ { 0=normal | 1=char-string | 2=vector-string\n        CImg<boolT> res = CImg<charT>::string(expr);\n        bool *pd = res._data;\n        for (const char *ps = expr._data; *ps; ++ps) {\n          if (!next_is_escaped && *ps=='\\\\') next_is_escaped = true;\n          if (!is_escaped && *ps=='\\'') { \/\/ Non-escaped character\n            if (!mode && ps>expr._data && *(ps - 1)=='[') next_mode = mode = 2; \/\/ Start vector-string\n            else if (mode==2 && *(ps + 1)==']') next_mode = !mode; \/\/ End vector-string\n            else if (mode<2) next_mode = mode?(mode = 0):1; \/\/ Start\/end char-string\n          }\n          *(pd++) = mode>=1 || is_escaped;\n          mode = next_mode;\n          is_escaped = next_is_escaped;\n          next_is_escaped = false;\n        }\n        return res;","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":203975,"func":"static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)\n{\n    VirtIONet *n = VIRTIO_NET(vdev);\n    struct virtio_net_ctrl_hdr ctrl;\n    virtio_net_ctrl_ack status = VIRTIO_NET_ERR;\n    VirtQueueElement elem;\n    size_t s;\n    struct iovec *iov;\n    unsigned int iov_cnt;\n\n    while (virtqueue_pop(vq, &elem)) {\n        if (iov_size(elem.in_sg, elem.in_num) < sizeof(status) ||\n            iov_size(elem.out_sg, elem.out_num) < sizeof(ctrl)) {\n            error_report(\"virtio-net ctrl missing headers\");\n            exit(1);\n        }\n\n        iov = elem.out_sg;\n        iov_cnt = elem.out_num;\n        s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));\n        iov_discard_front(&iov, &iov_cnt, sizeof(ctrl));\n        if (s != sizeof(ctrl)) {\n            status = VIRTIO_NET_ERR;\n        } else if (ctrl.class == VIRTIO_NET_CTRL_RX) {\n            status = virtio_net_handle_rx_mode(n, ctrl.cmd, iov, iov_cnt);\n        } else if (ctrl.class == VIRTIO_NET_CTRL_MAC) {\n            status = virtio_net_handle_mac(n, ctrl.cmd, iov, iov_cnt);\n        } else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {\n            status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, iov_cnt);\n        } else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {\n            status = virtio_net_handle_mq(n, ctrl.cmd, iov, iov_cnt);\n        } else if (ctrl.class == VIRTIO_NET_CTRL_GUEST_OFFLOADS) {\n            status = virtio_net_handle_offloads(n, ctrl.cmd, iov, iov_cnt);\n        }\n\n        s = iov_from_buf(elem.in_sg, elem.in_num, 0, &status, sizeof(status));\n        assert(s == sizeof(status));\n\n        virtqueue_push(vq, &elem, sizeof(status));\n        virtio_notify(vdev, vq);\n    }\n}\n","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":112259,"func":"Js::RegSlot ByteCodeGenerator::PrependLocalScopes(Js::RegSlot evalEnv, Js::RegSlot tempLoc, FuncInfo *funcInfo)\n{\n    Scope *currScope = this->currentScope;\n    Scope *funcScope = funcInfo->GetCurrentChildScope() ? funcInfo->GetCurrentChildScope() : funcInfo->GetBodyScope();\n\n    if (currScope == funcScope)\n    {\n        return evalEnv;\n    }\n\n    bool acquireTempLoc = tempLoc == Js::Constants::NoRegister;\n    if (acquireTempLoc)\n    {\n        tempLoc = funcInfo->AcquireTmpRegister();\n    }\n\n    \/\/ The with\/catch objects must be prepended to the environment we pass to eval() or to a func declared inside with,\n    \/\/ but the list must first be reversed so that innermost scopes appear first in the list.\n    while (currScope != funcScope)\n    {\n        Scope *innerScope;\n        for (innerScope = currScope; innerScope->GetEnclosingScope() != funcScope; innerScope = innerScope->GetEnclosingScope())\n            ;\n        if (innerScope->GetMustInstantiate())\n        {\n            if (!innerScope->HasInnerScopeIndex())\n            {\n                if (evalEnv == funcInfo->GetEnvRegister() || evalEnv == funcInfo->frameDisplayRegister)\n                {\n                    this->m_writer.Reg2(Js::OpCode::LdInnerFrameDisplayNoParent, tempLoc, innerScope->GetLocation());\n                }\n                else\n                {\n                    this->m_writer.Reg3(Js::OpCode::LdInnerFrameDisplay, tempLoc, innerScope->GetLocation(), evalEnv);\n                }\n            }\n            else\n            {\n                if (evalEnv == funcInfo->GetEnvRegister() || evalEnv == funcInfo->frameDisplayRegister)\n                {\n                    this->m_writer.Reg1Unsigned1(Js::OpCode::LdIndexedFrameDisplayNoParent, tempLoc, innerScope->GetInnerScopeIndex());\n                }\n                else\n                {\n                    this->m_writer.Reg2Int1(Js::OpCode::LdIndexedFrameDisplay, tempLoc, evalEnv, innerScope->GetInnerScopeIndex());\n                }\n            }\n            evalEnv = tempLoc;\n        }\n        funcScope = innerScope;\n    }\n\n    if (acquireTempLoc)\n    {\n        funcInfo->ReleaseTmpRegister(tempLoc);\n    }\n    return evalEnv;\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":503754,"func":"static int DecodeIPV6RouteTest01 (void)\n{\n    uint8_t raw_pkt1[] = {\n        0x60, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x2b, 0x40,\n        0x20, 0x01, 0xaa, 0xaa, 0x00, 0x01, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\n        0x20, 0x01, 0xaa, 0xaa, 0x00, 0x01, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\n        0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\n        0xb2, 0xed, 0x00, 0x50, 0x1b, 0xc7, 0x6a, 0xdf,\n        0x00, 0x00, 0x00, 0x00, 0x50, 0x02, 0x20, 0x00,\n        0xfa, 0x87, 0x00, 0x00,\n    };\n    Packet *p1 = PacketGetFromAlloc();\n    FAIL_IF(unlikely(p1 == NULL));\n    ThreadVars tv;\n    DecodeThreadVars dtv;\n    PacketQueue pq;\n\n    FlowInitConfig(FLOW_QUIET);\n\n    memset(&pq, 0, sizeof(PacketQueue));\n    memset(&tv, 0, sizeof(ThreadVars));\n    memset(&dtv, 0, sizeof(DecodeThreadVars));\n\n    PacketCopyData(p1, raw_pkt1, sizeof(raw_pkt1));\n\n    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);\n\n    FAIL_IF (!(IPV6_EXTHDR_ISSET_RH(p1)));\n    FAIL_IF (p1->ip6eh.rh_type != 0);\n    PACKET_RECYCLE(p1);\n    SCFree(p1);\n    FlowShutdown();\n    PASS;\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":145941,"func":"void uwsgi_set_cpu_affinity() {\n\tchar buf[4096];\n\tint ret;\n\tint pos = 0;\n\tif (uwsgi.cpu_affinity) {\n\t\tint base_cpu = (uwsgi.mywid - 1) * uwsgi.cpu_affinity;\n\t\tif (base_cpu >= uwsgi.cpus) {\n\t\t\tbase_cpu = base_cpu % uwsgi.cpus;\n\t\t}\n\t\tret = snprintf(buf, 4096, \"mapping worker %d to CPUs:\", uwsgi.mywid);\n\t\tif (ret < 25 || ret >= 4096) {\n\t\t\tuwsgi_log(\"unable to initialize cpu affinity !!!\\n\");\n\t\t\texit(1);\n\t\t}\n\t\tpos += ret;\n#if defined(__linux__) || defined(__GNU_kFreeBSD__)\n\t\tcpu_set_t cpuset;\n#elif defined(__FreeBSD__)\n\t\tcpuset_t cpuset;\n#endif\n#if defined(__linux__) || defined(__FreeBSD__) || defined(__GNU_kFreeBSD__)\n\t\tCPU_ZERO(&cpuset);\n\t\tint i;\n\t\tfor (i = 0; i < uwsgi.cpu_affinity; i++) {\n\t\t\tif (base_cpu >= uwsgi.cpus)\n\t\t\t\tbase_cpu = 0;\n\t\t\tCPU_SET(base_cpu, &cpuset);\n\t\t\tret = snprintf(buf + pos, 4096 - pos, \" %d\", base_cpu);\n\t\t\tif (ret < 2 || ret >= 4096) {\n\t\t\t\tuwsgi_log(\"unable to initialize cpu affinity !!!\\n\");\n\t\t\t\texit(1);\n\t\t\t}\n\t\t\tpos += ret;\n\t\t\tbase_cpu++;\n\t\t}\n#endif\n#if defined(__linux__) || defined(__GNU_kFreeBSD__)\n\t\tif (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {\n\t\t\tuwsgi_error(\"sched_setaffinity()\");\n\t\t}\n#elif defined(__FreeBSD__)\n\t\tif (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset), &cpuset)) {\n\t\t\tuwsgi_error(\"cpuset_setaffinity\");\n\t\t}\n#endif\n\t\tuwsgi_log(\"%s\\n\", buf);\n\t}\n\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":177152,"func":"ExtensionFunction::ResponseAction InputImeSendKeyEventsFunction::Run() {\n  InputImeEventRouter* event_router =\n      GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));\n  InputMethodEngineBase* engine =\n      event_router ? event_router->GetActiveEngine(extension_id()) : nullptr;\n  if (!engine)\n    return RespondNow(Error(kInputImeApiErrorEngineNotAvailable));\n\n  std::unique_ptr<SendKeyEvents::Params> parent_params(\n      SendKeyEvents::Params::Create(*args_));\n  EXTENSION_FUNCTION_VALIDATE(parent_params);\n  const SendKeyEvents::Params::Parameters& params = parent_params->parameters;\n  std::vector<InputMethodEngineBase::KeyboardEvent> key_data_out;\n\n  for (const auto& key_event : params.key_data) {\n    key_data_out.push_back(InputMethodEngineBase::KeyboardEvent());\n    InputMethodEngineBase::KeyboardEvent& event = key_data_out.back();\n    event.type = input_ime::ToString(key_event.type);\n    event.key = key_event.key;\n    event.code = key_event.code;\n    event.key_code = key_event.key_code.get() ? *(key_event.key_code) : 0;\n    event.alt_key = key_event.alt_key ? *(key_event.alt_key) : false;\n    event.ctrl_key = key_event.ctrl_key ? *(key_event.ctrl_key) : false;\n    event.shift_key = key_event.shift_key ? *(key_event.shift_key) : false;\n    event.caps_lock = key_event.caps_lock ? *(key_event.caps_lock) : false;\n  }\n  if (!engine->SendKeyEvents(params.context_id, key_data_out))\n    return RespondNow(Error(kInputImeApiErrorSetKeyEventsFail));\n  return RespondNow(NoArguments());\n}\n","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":512157,"func":"read_bytes (GstRTSPConnection * conn, guint8 * buffer, guint * idx, guint size,\n    gboolean block)\n{\n  guint left;\n  gint r;\n  GError *err = NULL;\n\n  if (G_UNLIKELY (*idx > size))\n    return GST_RTSP_ERROR;\n\n  left = size - *idx;\n\n  while (left) {\n    r = fill_bytes (conn, &buffer[*idx], left, block, &err);\n    if (G_UNLIKELY (r <= 0))\n      goto error;\n\n    left -= r;\n    *idx += r;\n  }\n  return GST_RTSP_OK;\n\n  \/* ERRORS *\/\nerror:\n  {\n    if (G_UNLIKELY (r == 0))\n      return GST_RTSP_EEOF;\n\n    GST_DEBUG (\"%s\", err->message);\n    if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {\n      g_clear_error (&err);\n      return GST_RTSP_EINTR;\n    } else if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {\n      g_clear_error (&err);\n      return GST_RTSP_EINTR;\n    } else if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_TIMED_OUT)) {\n      g_clear_error (&err);\n      return GST_RTSP_ETIMEOUT;\n    }\n    g_clear_error (&err);\n    return GST_RTSP_ESYS;\n  }\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":275416,"func":"ssize_t ewk_frame_source_get(const Evas_Object* ewkFrame, char** frameSource)\n{\n    EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, -1);\n    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, -1);\n    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame->document(), -1);\n    EINA_SAFETY_ON_NULL_RETURN_VAL(frameSource, -1);\n\n    WTF::String source;\n    *frameSource = 0; \/\/ Saves 0 to pointer until it's not allocated.\n\n    if (!smartData->frame->document()->isHTMLDocument()) {\n        WRN(\"Only HTML documents are supported\");\n        return -1;\n    }\n\n    WebCore::Node* documentNode = smartData->frame->document()->documentElement();\n    if (documentNode)\n        for (WebCore::Node* node = documentNode->firstChild(); node; node = node->parentElement()) {\n            if (node->hasTagName(WebCore::HTMLNames::htmlTag)) {\n                WebCore::HTMLElement* element = static_cast<WebCore::HTMLElement*>(node);\n                if (element)\n                    source = element->outerHTML();\n                break;\n            }\n        }\n\n    if (source.isEmpty()) {\n        if (smartData->frame->document()->head())\n            source = smartData->frame->document()->head()->outerHTML();\n\n        if (smartData->frame->document()->body())\n            source += smartData->frame->document()->body()->outerHTML();\n    }\n\n    size_t sourceLength = strlen(source.utf8().data());\n    *frameSource = static_cast<char*>(malloc(sourceLength + 1));\n    if (!*frameSource) {\n        CRITICAL(\"Could not allocate memory.\");\n        return -1;\n    }\n\n    strncpy(*frameSource, source.utf8().data(), sourceLength);\n    (*frameSource)[sourceLength] = '\\0';\n\n    return sourceLength;\n}\n","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":331060,"func":"static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n    GXFContext *gxf = s->priv_data;\n\n    AVIOContext *pb = s->pb;\n\n    AVStream *st = s->streams[pkt->stream_index];\n\n    int64_t pos = avio_tell(pb);\n\n    int padding = 0;\n\n    int packet_start_offset = avio_tell(pb) \/ 1024;\n\n\n\n    gxf_write_packet_header(pb, PKT_MEDIA);\n\n    if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) \/* MPEG-2 frames must be padded *\/\n\n        padding = 4 - pkt->size % 4;\n\n    else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)\n\n        padding = GXF_AUDIO_PACKET_SIZE - pkt->size;\n\n    gxf_write_media_preamble(s, pkt, pkt->size + padding);\n\n    avio_write(pb, pkt->data, pkt->size);\n\n    gxf_write_padding(pb, padding);\n\n\n\n    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {\n\n        if (!(gxf->flt_entries_nb % 500)) {\n\n            int err;\n\n            if ((err = av_reallocp_array(&gxf->flt_entries,\n\n                                         gxf->flt_entries_nb + 500,\n\n                                         sizeof(*gxf->flt_entries))) < 0) {\n\n                gxf->flt_entries_nb = 0;\n\n                av_log(s, AV_LOG_ERROR, \"could not reallocate flt entries\\n\");\n\n                return err;\n\n            }\n\n        }\n\n        gxf->flt_entries[gxf->flt_entries_nb++] = packet_start_offset;\n\n        gxf->nb_fields += 2; \/\/ count fields\n\n    }\n\n\n\n    updatePacketSize(pb, pos);\n\n\n\n    gxf->packet_count++;\n\n    if (gxf->packet_count == 100) {\n\n        gxf_write_map_packet(s, 0);\n\n        gxf->packet_count = 0;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":264707,"func":"static void pred_weight_table(GF_BitStream *bs, u32 slice_type, u32 ChromaArrayType, u32 num_ref_idx_l0_active_minus1, u32 num_ref_idx_l1_active_minus1) {\n\tu32 i, j;\n\tgf_bs_read_ue_log(bs, \"luma_log2_weight_denom\");\n\tif (ChromaArrayType != 0) {\n\t\tgf_bs_read_ue_log(bs, \"chroma_log2_weight_denom\");\n\t}\n\tfor (i = 0; i <= num_ref_idx_l0_active_minus1; i++) {\n\t\tif (gf_bs_read_int_log_idx(bs, 1, \"luma_weight_l0_flag\", i)) {\n\t\t\tgf_bs_read_se_log_idx(bs, \"luma_weight_l0\", i);\n\t\t\tgf_bs_read_se_log_idx(bs, \"luma_offset_l0\", i);\n\t\t}\n\t\tif (ChromaArrayType != 0) {\n\t\t\tif (gf_bs_read_int_log_idx(bs, 1, \"chroma_weight_l0_flag\", i))\n\t\t\t\tfor (j = 0; j < 2; j++) {\n\t\t\t\t\tgf_bs_read_se_log_idx2(bs, \"chroma_weight_l0\", i, j);\n\t\t\t\t\tgf_bs_read_se_log_idx2(bs, \"chroma_offset_l0\", i, j);\n\t\t\t\t}\n\t\t}\n\t}\n\tif (slice_type % 5 == 1) {\n\t\tfor (i = 0; i <= num_ref_idx_l1_active_minus1; i++) {\n\t\t\tif (gf_bs_read_int_log_idx(bs, 1, \"luma_weight_l1_flag\", i)) {\n\t\t\t\tgf_bs_read_se_log_idx(bs, \"luma_weight_l1\", i);\n\t\t\t\tgf_bs_read_se_log_idx(bs, \"luma_offset_l1\", i);\n\t\t\t}\n\t\t\tif (ChromaArrayType != 0) {\n\t\t\t\tif (gf_bs_read_int_log_idx(bs, 1, \"chroma_weight_l1_flag\", i)) {\n\t\t\t\t\tfor (j = 0; j < 2; j++) {\n\t\t\t\t\t\tgf_bs_read_se_log_idx2(bs, \"chroma_weight_l1\", i, j);\n\t\t\t\t\t\tgf_bs_read_se_log_idx2(bs, \"chroma_offset_l1\", i, j);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":320756,"func":"static uint8_t get_tlm(Jpeg2000DecoderContext *s, int n)\n\n{\n\n    uint8_t Stlm, ST, SP, tile_tlm, i;\n\n    bytestream_get_byte(&s->buf);               \/* Ztlm: skipped *\/\n\n    Stlm = bytestream_get_byte(&s->buf);\n\n\n\n    \/\/ too complex ? ST = ((Stlm >> 4) & 0x01) + ((Stlm >> 4) & 0x02);\n\n    ST = (Stlm >> 4) & 0x03;\n\n    \/\/ TODO: Manage case of ST = 0b11 --> raise error\n\n    SP       = (Stlm >> 6) & 0x01;\n\n    tile_tlm = (n - 4) \/ ((SP + 1) * 2 + ST);\n\n    for (i = 0; i < tile_tlm; i++) {\n\n        switch (ST) {\n\n        case 0:\n\n            break;\n\n        case 1:\n\n            bytestream_get_byte(&s->buf);\n\n            break;\n\n        case 2:\n\n            bytestream_get_be16(&s->buf);\n\n            break;\n\n        case 3:\n\n            bytestream_get_be32(&s->buf);\n\n            break;\n\n        }\n\n        if (SP == 0) {\n\n            bytestream_get_be16(&s->buf);\n\n        } else {\n\n            bytestream_get_be32(&s->buf);\n\n        }\n\n    }\n\n    return 0;\n\n}\n","target":1,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":398568,"func":"static plist_t parse_dict_node(struct bplist_data *bplist, const char** bnode, uint64_t size)\n{\n    uint64_t j;\n    uint64_t str_i = 0, str_j = 0;\n    uint64_t index1, index2;\n    plist_data_t data = plist_new_plist_data();\n    const char *const end_data = bplist->data + bplist->size;\n    const char *index1_ptr = NULL;\n    const char *index2_ptr = NULL;\n\n    data->type = PLIST_DICT;\n    data->length = size;\n\n    plist_t node = node_create(NULL, data);\n\n    for (j = 0; j < data->length; j++) {\n        str_i = j * bplist->ref_size;\n        str_j = (j + size) * bplist->ref_size;\n        index1_ptr = (*bnode) + str_i;\n        index2_ptr = (*bnode) + str_j;\n\n        if ((index1_ptr < bplist->data || index1_ptr + bplist->ref_size >= end_data) ||\n            (index2_ptr < bplist->data || index2_ptr + bplist->ref_size >= end_data)) {\n            plist_free(node);\n            return NULL;\n        }\n\n        index1 = UINT_TO_HOST(index1_ptr, bplist->ref_size);\n        index2 = UINT_TO_HOST(index2_ptr, bplist->ref_size);\n\n        if (index1 >= bplist->num_objects) {\n            plist_free(node);\n            return NULL;\n        }\n        if (index2 >= bplist->num_objects) {\n            plist_free(node);\n            return NULL;\n        }\n\n        \/* process key node *\/\n        plist_t key = parse_bin_node_at_index(bplist, index1);\n        if (!key) {\n            plist_free(node);\n            return NULL;\n        }\n\n        if (plist_get_data(key)->type != PLIST_STRING) {\n            fprintf(stderr, \"ERROR: Malformed binary plist dict, invalid node type for key!\\n\");\n            plist_free(node);\n            return NULL;\n        }\n\n        \/* enforce key type *\/\n        plist_get_data(key)->type = PLIST_KEY;\n        if (!plist_get_data(key)->strval) {\n            fprintf(stderr, \"ERROR: Malformed binary plist dict, invalid key node encountered!\\n\");\n            plist_free(key);\n            plist_free(node);\n            return NULL;\n        }\n\n        \/* process value node *\/\n        plist_t val = parse_bin_node_at_index(bplist, index2);\n        if (!val) {\n            plist_free(key);\n            plist_free(node);\n            return NULL;\n        }\n\n        node_attach(node, key);\n        node_attach(node, val);\n    }\n\n    return node;\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":466188,"func":"xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {\n    xmlChar buf[XML_PARSER_BIG_BUFFER_SIZE + 5];\n    int nbchar = 0;\n    int cur, l;\n    int count = 0;\n\n    SHRINK;\n    GROW;\n    cur = CUR_CHAR(l);\n    while ((cur != '<') && \/* checked *\/\n           (cur != '&') &&\n\t   (IS_CHAR(cur))) \/* test also done in xmlCurrentChar() *\/ {\n\tif ((cur == ']') && (NXT(1) == ']') &&\n\t    (NXT(2) == '>')) {\n\t    if (cdata) break;\n\t    else {\n\t\txmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);\n\t    }\n\t}\n\tCOPY_BUF(l,buf,nbchar,cur);\n\tif (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) {\n\t    buf[nbchar] = 0;\n\n\t    \/*\n\t     * OK the segment is to be consumed as chars.\n\t     *\/\n\t    if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {\n\t\tif (areBlanks(ctxt, buf, nbchar, 0)) {\n\t\t    if (ctxt->sax->ignorableWhitespace != NULL)\n\t\t\tctxt->sax->ignorableWhitespace(ctxt->userData,\n\t\t\t                               buf, nbchar);\n\t\t} else {\n\t\t    if (ctxt->sax->characters != NULL)\n\t\t\tctxt->sax->characters(ctxt->userData, buf, nbchar);\n\t\t    if ((ctxt->sax->characters !=\n\t\t         ctxt->sax->ignorableWhitespace) &&\n\t\t\t(*ctxt->space == -1))\n\t\t\t*ctxt->space = -2;\n\t\t}\n\t    }\n\t    nbchar = 0;\n            \/* something really bad happened in the SAX callback *\/\n            if (ctxt->instate != XML_PARSER_CONTENT)\n                return;\n\t}\n\tcount++;\n\tif (count > 50) {\n\t    SHRINK;\n\t    GROW;\n\t    count = 0;\n            if (ctxt->instate == XML_PARSER_EOF)\n\t\treturn;\n\t}\n\tNEXTL(l);\n\tcur = CUR_CHAR(l);\n    }\n    if (nbchar != 0) {\n        buf[nbchar] = 0;\n\t\/*\n\t * OK the segment is to be consumed as chars.\n\t *\/\n\tif ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {\n\t    if (areBlanks(ctxt, buf, nbchar, 0)) {\n\t\tif (ctxt->sax->ignorableWhitespace != NULL)\n\t\t    ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar);\n\t    } else {\n\t\tif (ctxt->sax->characters != NULL)\n\t\t    ctxt->sax->characters(ctxt->userData, buf, nbchar);\n\t\tif ((ctxt->sax->characters != ctxt->sax->ignorableWhitespace) &&\n\t\t    (*ctxt->space == -1))\n\t\t    *ctxt->space = -2;\n\t    }\n\t}\n    }\n    if ((cur != 0) && (!IS_CHAR(cur))) {\n\t\/* Generate the error and skip the offending character *\/\n        xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,\n                          \"PCDATA invalid Char value %d\\n\",\n\t                  cur);\n\tNEXTL(l);\n    }\n}","target":0,"code_token_length":701,"total_token_length":937,"max_tokens_setting":1024}
+{"idx":329486,"func":"void bdrv_info(void)\n\n{\n\n    BlockDriverState *bs;\n\n\n\n    for (bs = bdrv_first; bs != NULL; bs = bs->next) {\n\n        term_printf(\"%s:\", bs->device_name);\n\n        term_printf(\" type=\");\n\n        switch(bs->type) {\n\n        case BDRV_TYPE_HD:\n\n            term_printf(\"hd\");\n\n            break;\n\n        case BDRV_TYPE_CDROM:\n\n            term_printf(\"cdrom\");\n\n            break;\n\n        case BDRV_TYPE_FLOPPY:\n\n            term_printf(\"floppy\");\n\n            break;\n\n        }\n\n        term_printf(\" removable=%d\", bs->removable);\n\n        if (bs->removable) {\n\n            term_printf(\" locked=%d\", bs->locked);\n\n        }\n\n        if (bs->drv) {\n\n            term_printf(\" file=\");\n\n\t    term_print_filename(bs->filename);\n\n            if (bs->backing_file[0] != '\\0') {\n\n                term_printf(\" backing_file=\");\n\n\t\tterm_print_filename(bs->backing_file);\n\n\t    }\n\n            term_printf(\" ro=%d\", bs->read_only);\n\n            term_printf(\" drv=%s\", bs->drv->format_name);\n\n            if (bs->encrypted)\n\n                term_printf(\" encrypted\");\n\n        } else {\n\n            term_printf(\" [not inserted]\");\n\n        }\n\n        term_printf(\"\\n\");\n\n    }\n\n}\n","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":203871,"func":"void Document::ReportFeaturePolicyViolation(\n    mojom::FeaturePolicyFeature feature,\n    mojom::FeaturePolicyDisposition disposition,\n    const String& message) const {\n  if (!RuntimeEnabledFeatures::FeaturePolicyReportingEnabled())\n    return;\n  LocalFrame* frame = GetFrame();\n  if (!frame)\n    return;\n  const String& feature_name = GetNameForFeature(feature);\n  FeaturePolicyViolationReportBody* body =\n      MakeGarbageCollected<FeaturePolicyViolationReportBody>(\n          feature_name, \"Feature policy violation\",\n          (disposition == mojom::FeaturePolicyDisposition::kReport ? \"report\"\n                                                                   : \"enforce\"),\n          SourceLocation::Capture());\n  Report* report =\n      new Report(\"feature-policy-violation\", Url().GetString(), body);\n  ReportingContext::From(this)->QueueReport(report);\n\n  bool is_null;\n  int line_number = body->lineNumber(is_null);\n  line_number = is_null ? 0 : line_number;\n  int column_number = body->columnNumber(is_null);\n  column_number = is_null ? 0 : column_number;\n\n  frame->GetReportingService()->QueueFeaturePolicyViolationReport(\n      Url(), feature_name,\n      (disposition == mojom::FeaturePolicyDisposition::kReport ? \"report\"\n                                                               : \"enforce\"),\n      \"Feature policy violation\", body->sourceFile(), line_number,\n      column_number);\n  if (disposition == mojom::FeaturePolicyDisposition::kEnforce) {\n    frame->Console().AddMessage(ConsoleMessage::Create(\n        kViolationMessageSource, kErrorMessageLevel,\n        (message.IsEmpty() ? (\"Feature policy violation: \" + feature_name +\n                              \" is not allowed in this document.\")\n                           : message)));\n  }\n}\n","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":86749,"func":"TEST_F(RouterTest, TimeoutBudgetHistogramStatOnlyGlobal) {\n  NiceMock<Http::MockRequestEncoder> encoder;\n  Http::ResponseDecoder* response_decoder = nullptr;\n  expectNewStreamWithImmediateEncoder(encoder, &response_decoder, Http::Protocol::Http10);\n\n  expectPerTryTimerCreate();\n\n  Http::TestRequestHeaderMapImpl headers{{\"x-envoy-upstream-rq-timeout-ms\", \"200\"}};\n  HttpTestUtility::addDefaultHeaders(headers);\n  router_.decodeHeaders(headers, false);\n  Buffer::OwnedImpl data;\n  router_.decodeData(data, true);\n  EXPECT_EQ(1U,\n            callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());\n\n  \/\/ Global timeout budget used.\n  EXPECT_CALL(\n      cm_.thread_local_cluster_.cluster_.info_->timeout_budget_stats_store_,\n      deliverHistogramToSinks(\n          Property(&Stats::Metric::name, \"upstream_rq_timeout_budget_percent_used\"), 40ull));\n  \/\/ Per-try budget used is zero out of an infinite timeout.\n  EXPECT_CALL(\n      cm_.thread_local_cluster_.cluster_.info_->timeout_budget_stats_store_,\n      deliverHistogramToSinks(\n          Property(&Stats::Metric::name, \"upstream_rq_timeout_budget_per_try_percent_used\"), 0ull));\n\n  Http::ResponseHeaderMapPtr response_headers(\n      new Http::TestResponseHeaderMapImpl{{\":status\", \"200\"}});\n  response_decoder->decodeHeaders(std::move(response_headers), false);\n  test_time_.advanceTimeWait(std::chrono::milliseconds(80));\n  response_decoder->decodeData(data, true);\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":81397,"func":"static void sas_ata_internal_abort(struct sas_task *task)\n{\n\tstruct sas_internal *si = dev_to_sas_internal(task->dev);\n\tunsigned long flags;\n\tint res;\n\n\tspin_lock_irqsave(&task->task_state_lock, flags);\n\tif (task->task_state_flags & SAS_TASK_STATE_ABORTED ||\n\t    task->task_state_flags & SAS_TASK_STATE_DONE) {\n\t\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n\t\tSAS_DPRINTK(\"%s: Task %p already finished.\\n\", __func__,\n\t\t\t    task);\n\t\tgoto out;\n\t}\n\ttask->task_state_flags |= SAS_TASK_STATE_ABORTED;\n\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n\n\tres = si->dft->lldd_abort_task(task);\n\n\tspin_lock_irqsave(&task->task_state_lock, flags);\n\tif (task->task_state_flags & SAS_TASK_STATE_DONE ||\n\t    res == TMF_RESP_FUNC_COMPLETE) {\n\t\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n\t\tgoto out;\n\t}\n\n\t\/* XXX we are not prepared to deal with ->lldd_abort_task()\n\t * failures.  TODO: lldds need to unconditionally forget about\n\t * aborted ata tasks, otherwise we (likely) leak the sas task\n\t * here\n\t *\/\n\tSAS_DPRINTK(\"%s: Task %p leaked.\\n\", __func__, task);\n\n\tif (!(task->task_state_flags & SAS_TASK_STATE_DONE))\n\t\ttask->task_state_flags &= ~SAS_TASK_STATE_ABORTED;\n\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n\n\treturn;\n out:\n\tsas_free_task(task);\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":80512,"func":"int rdp_recv_autodetect_request_packet(rdpRdp* rdp, wStream* s)\n{\n\tAUTODETECT_REQ_PDU autodetectReqPdu;\n\tBOOL success = FALSE;\n\n\tif (Stream_GetRemainingLength(s) < 6)\n\t\treturn -1;\n\n\tStream_Read_UINT8(s, autodetectReqPdu.headerLength);    \/* headerLength (1 byte) *\/\n\tStream_Read_UINT8(s, autodetectReqPdu.headerTypeId);    \/* headerTypeId (1 byte) *\/\n\tStream_Read_UINT16(s, autodetectReqPdu.sequenceNumber); \/* sequenceNumber (2 bytes) *\/\n\tStream_Read_UINT16(s, autodetectReqPdu.requestType);    \/* requestType (2 bytes) *\/\n\tWLog_VRB(AUTODETECT_TAG,\n\t         \"rdp_recv_autodetect_request_packet: headerLength=%\" PRIu8 \", headerTypeId=%\" PRIu8\n\t         \", sequenceNumber=%\" PRIu16 \", requestType=%04\" PRIx16 \"\",\n\t         autodetectReqPdu.headerLength, autodetectReqPdu.headerTypeId,\n\t         autodetectReqPdu.sequenceNumber, autodetectReqPdu.requestType);\n\n\tif (autodetectReqPdu.headerTypeId != TYPE_ID_AUTODETECT_REQUEST)\n\t\treturn -1;\n\n\tswitch (autodetectReqPdu.requestType)\n\t{\n\t\tcase RDP_RTT_REQUEST_TYPE_CONTINUOUS:\n\t\tcase RDP_RTT_REQUEST_TYPE_CONNECTTIME:\n\t\t\t\/* RTT Measure Request (RDP_RTT_REQUEST) - MS-RDPBCGR 2.2.14.1.1 *\/\n\t\t\tsuccess = autodetect_recv_rtt_measure_request(rdp, s, &autodetectReqPdu);\n\t\t\tbreak;\n\n\t\tcase RDP_BW_START_REQUEST_TYPE_CONTINUOUS:\n\t\tcase RDP_BW_START_REQUEST_TYPE_TUNNEL:\n\t\tcase RDP_BW_START_REQUEST_TYPE_CONNECTTIME:\n\t\t\t\/* Bandwidth Measure Start (RDP_BW_START) - MS-RDPBCGR 2.2.14.1.2 *\/\n\t\t\tsuccess = autodetect_recv_bandwidth_measure_start(rdp, s, &autodetectReqPdu);\n\t\t\tbreak;\n\n\t\tcase RDP_BW_PAYLOAD_REQUEST_TYPE:\n\t\t\t\/* Bandwidth Measure Payload (RDP_BW_PAYLOAD) - MS-RDPBCGR 2.2.14.1.3 *\/\n\t\t\tsuccess = autodetect_recv_bandwidth_measure_payload(rdp, s, &autodetectReqPdu);\n\t\t\tbreak;\n\n\t\tcase RDP_BW_STOP_REQUEST_TYPE_CONNECTTIME:\n\t\tcase RDP_BW_STOP_REQUEST_TYPE_CONTINUOUS:\n\t\tcase RDP_BW_STOP_REQUEST_TYPE_TUNNEL:\n\t\t\t\/* Bandwidth Measure Stop (RDP_BW_STOP) - MS-RDPBCGR 2.2.14.1.4 *\/\n\t\t\tsuccess = autodetect_recv_bandwidth_measure_stop(rdp, s, &autodetectReqPdu);\n\t\t\tbreak;\n\n\t\tcase 0x0840:\n\t\tcase 0x0880:\n\t\tcase 0x08C0:\n\t\t\t\/* Network Characteristics Result (RDP_NETCHAR_RESULT) - MS-RDPBCGR 2.2.14.1.5 *\/\n\t\t\tsuccess = autodetect_recv_netchar_result(rdp, s, &autodetectReqPdu);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\treturn success ? 0 : -1;\n}","target":0,"code_token_length":741,"total_token_length":977,"max_tokens_setting":1024}
+{"idx":253974,"func":"void FrameLoader::RestoreScrollPositionAndViewState(\n    FrameLoadType load_type,\n    bool is_same_document,\n    HistoryItem::ViewState* view_state,\n    HistoryScrollRestorationType scroll_restoration_type) {\n  LocalFrameView* view = frame_->View();\n  if (!view || !view->LayoutViewportScrollableArea() ||\n      !state_machine_.CommittedFirstRealDocumentLoad() ||\n      !frame_->IsAttached()) {\n    return;\n  }\n  if (!NeedsHistoryItemRestore(load_type) || !view_state)\n    return;\n\n  bool should_restore_scroll =\n      scroll_restoration_type != kScrollRestorationManual;\n  bool should_restore_scale = view_state->page_scale_factor_;\n\n  bool can_restore_without_clamping =\n      view->LayoutViewportScrollableArea()->ClampScrollOffset(\n          view_state->scroll_offset_) == view_state->scroll_offset_;\n\n  bool should_force_clamping = !frame_->IsLoading() || is_same_document;\n  if (!can_restore_without_clamping && should_force_clamping)\n    frame_->GetDocument()->UpdateStyleAndLayout();\n\n  bool can_restore_without_annoying_user =\n      !GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user &&\n      (can_restore_without_clamping || should_force_clamping ||\n       !should_restore_scroll);\n  if (!can_restore_without_annoying_user)\n    return;\n\n  if (should_restore_scroll) {\n    ScrollOffset previous_offset =\n        view->LayoutViewportScrollableArea()->GetScrollOffset();\n\n    bool did_restore =\n        ShouldSerializeScrollAnchor() &&\n        view->LayoutViewportScrollableArea()->RestoreScrollAnchor(\n            {view_state->scroll_anchor_data_.selector_,\n             LayoutPoint(view_state->scroll_anchor_data_.offset_.x,\n                         view_state->scroll_anchor_data_.offset_.y),\n             view_state->scroll_anchor_data_.simhash_});\n    if (!did_restore) {\n      view->LayoutViewportScrollableArea()->SetScrollOffset(\n          view_state->scroll_offset_, kProgrammaticScroll);\n    }\n\n    did_restore |= (previous_offset !=\n                    view->LayoutViewportScrollableArea()->GetScrollOffset());\n\n    if (did_restore) {\n      UMA_HISTOGRAM_BOOLEAN(\n          \"Layout.ScrollRestoration.PrecededByJsScroll\",\n          GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_js);\n    }\n  }\n\n  if (frame_->IsMainFrame()) {\n    ScrollOffset visual_viewport_offset(\n        view_state->visual_viewport_scroll_offset_);\n\n    if (visual_viewport_offset.Width() == -1 &&\n        visual_viewport_offset.Height() == -1) {\n      visual_viewport_offset =\n          view_state->scroll_offset_ -\n          view->LayoutViewportScrollableArea()->GetScrollOffset();\n    }\n\n    VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport();\n    if (should_restore_scale && should_restore_scroll) {\n      visual_viewport.SetScaleAndLocation(view_state->page_scale_factor_,\n                                          FloatPoint(visual_viewport_offset));\n    } else if (should_restore_scale) {\n      visual_viewport.SetScale(view_state->page_scale_factor_);\n    } else if (should_restore_scroll) {\n      visual_viewport.SetLocation(FloatPoint(visual_viewport_offset));\n    }\n\n    if (ScrollingCoordinator* scrolling_coordinator =\n            frame_->GetPage()->GetScrollingCoordinator())\n      scrolling_coordinator->FrameViewRootLayerDidChange(view);\n  }\n\n  GetDocumentLoader()->GetInitialScrollState().did_restore_from_history = true;\n}\n","target":0,"code_token_length":725,"total_token_length":961,"max_tokens_setting":1024}
+{"idx":402270,"func":"static void xhci_reset(DeviceState *dev)\n{\n    XHCIState *xhci = XHCI(dev);\n    int i;\n\n    trace_usb_xhci_reset();\n    if (!(xhci->usbsts & USBSTS_HCH)) {\n        DPRINTF(\"xhci: reset while running!\\n\");\n    }\n\n    xhci->usbcmd = 0;\n    xhci->usbsts = USBSTS_HCH;\n    xhci->dnctrl = 0;\n    xhci->crcr_low = 0;\n    xhci->crcr_high = 0;\n    xhci->dcbaap_low = 0;\n    xhci->dcbaap_high = 0;\n    xhci->config = 0;\n\n    for (i = 0; i < xhci->numslots; i++) {\n        xhci_disable_slot(xhci, i+1);\n    }\n\n    for (i = 0; i < xhci->numports; i++) {\n        xhci_port_update(xhci->ports + i, 0);\n    }\n\n    for (i = 0; i < xhci->numintrs; i++) {\n        xhci->intr[i].iman = 0;\n        xhci->intr[i].imod = 0;\n        xhci->intr[i].erstsz = 0;\n        xhci->intr[i].erstba_low = 0;\n        xhci->intr[i].erstba_high = 0;\n        xhci->intr[i].erdp_low = 0;\n        xhci->intr[i].erdp_high = 0;\n        xhci->intr[i].msix_used = 0;\n\n        xhci->intr[i].er_ep_idx = 0;\n        xhci->intr[i].er_pcs = 1;\n        xhci->intr[i].er_full = 0;\n        xhci->intr[i].ev_buffer_put = 0;\n        xhci->intr[i].ev_buffer_get = 0;\n    }\n\n    xhci->mfindex_start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);\n    xhci_mfwrap_update(xhci);\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":91737,"func":"MagickExport MagickBooleanType ThrowException(ExceptionInfo *exception,\n  const ExceptionType severity,const char *reason,const char *description)\n{\n  register ExceptionInfo\n    *p;\n\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  LockSemaphoreInfo(exception->semaphore);\n  p=(ExceptionInfo *) GetLastValueInLinkedList((LinkedListInfo *)\n    exception->exceptions);\n  if ((p != (ExceptionInfo *) NULL) && (p->severity == severity) &&\n      (LocaleCompare(exception->reason,reason) == 0) &&\n      (LocaleCompare(exception->description,description) == 0))\n    {\n      UnlockSemaphoreInfo(exception->semaphore);\n      return(MagickTrue);\n    }\n  p=(ExceptionInfo *) AcquireMagickMemory(sizeof(*p));\n  if (p == (ExceptionInfo *) NULL)\n    {\n      UnlockSemaphoreInfo(exception->semaphore);\n      ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n    }\n  (void) ResetMagickMemory(p,0,sizeof(*p));\n  p->severity=severity;\n  if (reason != (const char *) NULL)\n    p->reason=ConstantString(reason);\n  if (description != (const char *) NULL)\n    p->description=ConstantString(description);\n  p->signature=MagickCoreSignature;\n  (void) AppendValueToLinkedList((LinkedListInfo *) exception->exceptions,p);\n  if (p->severity >= exception->severity)\n    {\n      exception->severity=p->severity;\n      exception->reason=p->reason;\n      exception->description=p->description;\n    }\n  UnlockSemaphoreInfo(exception->semaphore);\n  return(MagickTrue);\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":178799,"func":"std::string TestURLLoader::TestAuditURLRedirect() {\n  pp::URLRequestInfo request(instance_);\n  std::string redirect_prefix(\"\/server-redirect?\");\n  std::string redirect_url =\n      GetReachableAbsoluteURL(\"test_url_loader_data\/hello.txt\");\n  request.SetURL(redirect_prefix.append(redirect_url));\n  request.SetFollowRedirects(false);\n\n  TestCompletionCallback callback(instance_->pp_instance(), callback_type());\n\n  pp::URLLoader loader(instance_);\n  callback.WaitForResult(loader.Open(request, callback.GetCallback()));\n  CHECK_CALLBACK_BEHAVIOR(callback);\n  ASSERT_EQ(PP_OK, callback.result());\n\n  pp::URLResponseInfo response_info(loader.GetResponseInfo());\n  if (response_info.is_null())\n    return \"URLLoader::GetResponseInfo returned null\";\n  int32_t status_code = response_info.GetStatusCode();\n  if (status_code != 301)\n    return \"Response status should be 301\";\n\n  callback.WaitForResult(loader.FollowRedirect(callback.GetCallback()));\n  CHECK_CALLBACK_BEHAVIOR(callback);\n  ASSERT_EQ(PP_OK, callback.result());\n  std::string body;\n  std::string error = ReadEntireResponseBody(&loader, &body);\n  if (!error.empty())\n    return error;\n\n  if (body != \"hello\\n\")\n    return \"URLLoader::FollowRedirect failed\";\n\n  PASS();\n}\n","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":62719,"func":"base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)\n{\n\tint\t\t\terr = 0, id;\n\tstruct mISDNdevice\t*dev;\n\tstruct mISDNversion\tver;\n\n\tswitch (cmd) {\n\tcase IMGETVERSION:\n\t\tver.major = MISDN_MAJOR_VERSION;\n\t\tver.minor = MISDN_MINOR_VERSION;\n\t\tver.release = MISDN_RELEASE;\n\t\tif (copy_to_user((void __user *)arg, &ver, sizeof(ver)))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\tcase IMGETCOUNT:\n\t\tid = get_mdevice_count();\n\t\tif (put_user(id, (int __user *)arg))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\tcase IMGETDEVINFO:\n\t\tif (get_user(id, (int __user *)arg)) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\tdev = get_mdevice(id);\n\t\tif (dev) {\n\t\t\tstruct mISDN_devinfo di;\n\n\t\t\tmemset(&di, 0, sizeof(di));\n\t\t\tdi.id = dev->id;\n\t\t\tdi.Dprotocols = dev->Dprotocols;\n\t\t\tdi.Bprotocols = dev->Bprotocols | get_all_Bprotocols();\n\t\t\tdi.protocol = dev->D.protocol;\n\t\t\tmemcpy(di.channelmap, dev->channelmap,\n\t\t\t       sizeof(di.channelmap));\n\t\t\tdi.nrbchan = dev->nrbchan;\n\t\t\tstrcpy(di.name, dev_name(&dev->dev));\n\t\t\tif (copy_to_user((void __user *)arg, &di, sizeof(di)))\n\t\t\t\terr = -EFAULT;\n\t\t} else\n\t\t\terr = -ENODEV;\n\t\tbreak;\n\tcase IMSETDEVNAME:\n\t{\n\t\tstruct mISDN_devrename dn;\n\t\tif (copy_from_user(&dn, (void __user *)arg,\n\t\t\t\t   sizeof(dn))) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\tdev = get_mdevice(dn.id);\n\t\tif (dev)\n\t\t\terr = device_rename(&dev->dev, dn.name);\n\t\telse\n\t\t\terr = -ENODEV;\n\t}\n\tbreak;\n\tdefault:\n\t\terr = -EINVAL;\n\t}\n\treturn err;\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":144820,"func":"SockClose(Sock *sockPtr, int keep)\n{\n    NS_NONNULL_ASSERT(sockPtr != NULL);\n\n    if (keep != 0) {\n        bool driverKeep = DriverKeep(sockPtr);\n        keep = (int)driverKeep;\n    }\n    if (keep == (int)NS_FALSE) {\n        DriverClose(sockPtr);\n    }\n    Ns_MutexLock(&sockPtr->drvPtr->lock);\n    sockPtr->keep = (bool)keep;\n    Ns_MutexUnlock(&sockPtr->drvPtr->lock);\n\n    \/*\n     * Unconditionally remove temporary file, connection thread\n     * should take care about very large uploads.\n     *\/\n\n    if (sockPtr->tfile != NULL) {\n        unlink(sockPtr->tfile);\n        ns_free(sockPtr->tfile);\n        sockPtr->tfile = NULL;\n\n        if (sockPtr->tfd > 0) {\n            \/*\n             * Close and reset fd. The fd should be > 0 unless we are in error\n             * conditions.\n             *\/\n            (void) ns_close(sockPtr->tfd);\n        }\n        sockPtr->tfd = 0;\n\n    } else if (sockPtr->tfd > 0) {\n        \/*\n         * This must be a fd allocated via Ns_GetTemp();\n         *\/\n        Ns_ReleaseTemp(sockPtr->tfd);\n        sockPtr->tfd = 0;\n    }\n\n#ifndef _WIN32\n    \/*\n     * Un-map temp file used for spooled content.\n     *\/\n    if (sockPtr->taddr != NULL) {\n        munmap(sockPtr->taddr, (size_t)sockPtr->tsize);\n        sockPtr->taddr = NULL;\n    }\n#endif\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":130846,"func":"Jsi_RC Jsi_FunctionInvokeString(Jsi_Interp *interp, Jsi_Value *func, Jsi_Value *arg, Jsi_DString *dStr)\n{\n    if (interp->deleting)\n        return JSI_ERROR;\n    Jsi_Value *vpargs, *frPtr = Jsi_ValueNew1(interp);\n    Jsi_RC rc;\n    if (!arg) {\n        if (!interp->nullFuncArg) {\n            interp->nullFuncArg = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, NULL, 0, 0));\n            Jsi_IncrRefCount(interp, interp->nullFuncArg);\n        }\n        vpargs = interp->nullFuncArg;\n    } else {\n        vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, &arg, 1, 1));\n    }\n    Jsi_IncrRefCount(interp, vpargs);\n    rc = Jsi_FunctionInvoke(interp, func, vpargs, &frPtr, NULL);\n    Jsi_DecrRefCount(interp, vpargs);\n    if (rc != JSI_OK)\n        Jsi_LogError(\"function call failed\");\n    else\n        Jsi_ValueGetDString(interp, frPtr, dStr, 0);\n    Jsi_DecrRefCount(interp, frPtr);\n    return rc;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":288807,"func":"static void main_get_appheader_params ( main_file * file , char * * parsed , int output , const char * type , main_file * other ) {\n if ( file -> filename == NULL && ! ( output && option_stdout ) && strcmp ( parsed [ 0 ] , \"-\" ) != 0 ) {\n file -> filename = parsed [ 0 ] ;\n if ( other -> filename != NULL ) {\n const char * last_slash = strrchr ( other -> filename , '\/' ) ;\n if ( last_slash != NULL ) {\n usize_t dlen = ( usize_t ) ( last_slash - other -> filename ) ;\n XD3_ASSERT ( file -> filename_copy == NULL ) ;\n file -> filename_copy = ( char * ) main_malloc ( dlen + 2 + ( usize_t ) strlen ( file -> filename ) ) ;\n strncpy ( file -> filename_copy , other -> filename , dlen ) ;\n file -> filename_copy [ dlen ] = '\/' ;\n strcpy ( file -> filename_copy + dlen + 1 , parsed [ 0 ] ) ;\n file -> filename = file -> filename_copy ;\n }\n }\n if ( ! option_quiet ) {\n XPR ( NT \"using default %s filename: %s\\n\" , type , file -> filename ) ;\n }\n }\n if ( file -> compressor == NULL && * parsed [ 1 ] != 0 ) {\n file -> flags |= RD_DECOMPSET ;\n file -> compressor = main_get_compressor ( parsed [ 1 ] ) ;\n }\n }","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":378008,"func":"static int build_spdinfo(struct sk_buff *skb, struct net *net,\n\t\t\t u32 portid, u32 seq, u32 flags)\n{\n\tstruct xfrmk_spdinfo si;\n\tstruct xfrmu_spdinfo spc;\n\tstruct xfrmu_spdhinfo sph;\n\tstruct nlmsghdr *nlh;\n\tint err;\n\tu32 *f;\n\n\tnlh = nlmsg_put(skb, portid, seq, XFRM_MSG_NEWSPDINFO, sizeof(u32), 0);\n\tif (nlh == NULL) \/* shouldn't really happen ... *\/\n\t\treturn -EMSGSIZE;\n\n\tf = nlmsg_data(nlh);\n\t*f = flags;\n\txfrm_spd_getinfo(net, &si);\n\tspc.incnt = si.incnt;\n\tspc.outcnt = si.outcnt;\n\tspc.fwdcnt = si.fwdcnt;\n\tspc.inscnt = si.inscnt;\n\tspc.outscnt = si.outscnt;\n\tspc.fwdscnt = si.fwdscnt;\n\tsph.spdhcnt = si.spdhcnt;\n\tsph.spdhmcnt = si.spdhmcnt;\n\n\terr = nla_put(skb, XFRMA_SPD_INFO, sizeof(spc), &spc);\n\tif (!err)\n\t\terr = nla_put(skb, XFRMA_SPD_HINFO, sizeof(sph), &sph);\n\tif (err) {\n\t\tnlmsg_cancel(skb, nlh);\n\t\treturn err;\n\t}\n\n\treturn nlmsg_end(skb, nlh);\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":340802,"func":"DeviceState *qdev_device_add(QemuOpts *opts)\n\n{\n\n    DeviceClass *k;\n\n    const char *driver, *path, *id;\n\n    DeviceState *qdev;\n\n    BusState *bus;\n\n\n\n    driver = qemu_opt_get(opts, \"driver\");\n\n    if (!driver) {\n\n        qerror_report(QERR_MISSING_PARAMETER, \"driver\");\n\n        return NULL;\n\n    }\n\n\n\n    \/* find driver *\/\n\n    k = DEVICE_CLASS(object_class_by_name(driver));\n\n\n\n    \/* find bus *\/\n\n    path = qemu_opt_get(opts, \"bus\");\n\n    if (path != NULL) {\n\n        bus = qbus_find(path);\n\n        if (!bus) {\n\n            return NULL;\n\n        }\n\n        if (bus->info != k->bus_info) {\n\n            qerror_report(QERR_BAD_BUS_FOR_DEVICE,\n\n                           driver, bus->info->name);\n\n            return NULL;\n\n        }\n\n    } else {\n\n        bus = qbus_find_recursive(main_system_bus, NULL, k->bus_info);\n\n        if (!bus) {\n\n            qerror_report(QERR_NO_BUS_FOR_DEVICE,\n\n                          driver, k->bus_info->name);\n\n            return NULL;\n\n        }\n\n    }\n\n    if (qdev_hotplug && !bus->allow_hotplug) {\n\n        qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);\n\n        return NULL;\n\n    }\n\n\n\n    \/* create device, set properties *\/\n\n    qdev = qdev_create_from_info(bus, driver);\n\n    id = qemu_opts_id(opts);\n\n    if (id) {\n\n        qdev->id = id;\n\n        qdev_property_add_child(qdev_get_peripheral(), qdev->id, qdev, NULL);\n\n    } else {\n\n        static int anon_count;\n\n        gchar *name = g_strdup_printf(\"device[%d]\", anon_count++);\n\n        qdev_property_add_child(qdev_get_peripheral_anon(), name,\n\n                                qdev, NULL);\n\n        g_free(name);\n\n    }        \n\n    if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {\n\n        qdev_free(qdev);\n\n        return NULL;\n\n    }\n\n    if (qdev_init(qdev) < 0) {\n\n        qerror_report(QERR_DEVICE_INIT_FAILED, driver);\n\n        return NULL;\n\n    }\n\n    qdev->opts = opts;\n\n    return qdev;\n\n}\n","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":407703,"func":"ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)\n{\n\tuint8_t *data = ldns_rdf_data(rdf);\n\tuint16_t address_family;\n\tuint8_t prefix;\n\tbool negation;\n\tuint8_t adf_length;\n\tsize_t i;\n\tsize_t pos = 0;\n\n\twhile (pos < (unsigned int) ldns_rdf_size(rdf)) {\n                if(pos + 3 >= (unsigned)ldns_rdf_size(rdf))\n                        return LDNS_STATUS_WIRE_RDATA_ERR;\n\t\taddress_family = ldns_read_uint16(&data[pos]);\n\t\tprefix = data[pos + 2];\n\t\tnegation = data[pos + 3] & LDNS_APL_NEGATION;\n\t\tadf_length = data[pos + 3] & LDNS_APL_MASK;\n\t\tif (address_family == LDNS_APL_IP4) {\n\t\t\t\/* check if prefix < 32? *\/\n\t\t\tif (negation) {\n\t\t\t\tldns_buffer_printf(output, \"!\");\n\t\t\t}\n\t\t\tldns_buffer_printf(output, \"%u:\", address_family);\n\t\t\t\/* address is variable length 0 - 4 *\/\n\t\t\tfor (i = 0; i < 4; i++) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tldns_buffer_printf(output, \".\");\n\t\t\t\t}\n\t\t\t\tif (i < (unsigned short) adf_length) {\n                                        if(pos+i+4 >= ldns_rdf_size(rdf))\n\t\t\t\t\t    return LDNS_STATUS_WIRE_RDATA_ERR;\n\t\t\t\t\tldns_buffer_printf(output, \"%d\",\n\t\t\t\t\t                   data[pos + i + 4]);\n\t\t\t\t} else {\n\t\t\t\t\tldns_buffer_printf(output, \"0\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tldns_buffer_printf(output, \"\/%u \", prefix);\n\t\t} else if (address_family == LDNS_APL_IP6) {\n\t\t\t\/* check if prefix < 128? *\/\n\t\t\tif (negation) {\n\t\t\t\tldns_buffer_printf(output, \"!\");\n\t\t\t}\n\t\t\tldns_buffer_printf(output, \"%u:\", address_family);\n\t\t\t\/* address is variable length 0 - 16 *\/\n\t\t\tfor (i = 0; i < 16; i++) {\n\t\t\t\tif (i % 2 == 0 && i > 0) {\n\t\t\t\t\tldns_buffer_printf(output, \":\");\n\t\t\t\t}\n\t\t\t\tif (i < (unsigned short) adf_length) {\n                                        if(pos+i+4 >= ldns_rdf_size(rdf))\n\t\t\t\t\t    return LDNS_STATUS_WIRE_RDATA_ERR;\n\t\t\t\t\tldns_buffer_printf(output, \"%02x\",\n\t\t\t\t\t                   data[pos + i + 4]);\n\t\t\t\t} else {\n\t\t\t\t\tldns_buffer_printf(output, \"00\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tldns_buffer_printf(output, \"\/%u \", prefix);\n\n\t\t} else {\n\t\t\t\/* unknown address family *\/\n\t\t\tldns_buffer_printf(output,\n\t\t\t\t\t\"Unknown address family: %u data: \",\n\t\t\t\t\taddress_family);\n\t\t\tfor (i = 1; i < (unsigned short) (4 + adf_length); i++) {\n                                if(pos+i >= ldns_rdf_size(rdf))\n                                        return LDNS_STATUS_WIRE_RDATA_ERR;\n\t\t\t\tldns_buffer_printf(output, \"%02x\", data[i]);\n\t\t\t}\n\t\t}\n\t\tpos += 4 + adf_length;\n\t}\n\treturn ldns_buffer_status(output);\n}","target":0,"code_token_length":737,"total_token_length":973,"max_tokens_setting":1024}
+{"idx":63144,"func":"static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,\n\t\t\t\t    struct udphdr  *uh,\n\t\t\t\t    __be32 saddr, __be32 daddr,\n\t\t\t\t    struct udp_table *udptable,\n\t\t\t\t    int proto)\n{\n\tstruct sock *sk, *stack[256 \/ sizeof(struct sock *)];\n\tstruct hlist_nulls_node *node;\n\tunsigned short hnum = ntohs(uh->dest);\n\tstruct udp_hslot *hslot = udp_hashslot(udptable, net, hnum);\n\tint dif = skb->dev->ifindex;\n\tunsigned int count = 0, offset = offsetof(typeof(*sk), sk_nulls_node);\n\tunsigned int hash2 = 0, hash2_any = 0, use_hash2 = (hslot->count > 10);\n\tbool inner_flushed = false;\n\n\tif (use_hash2) {\n\t\thash2_any = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum) &\n\t\t\t    udp_table.mask;\n\t\thash2 = udp4_portaddr_hash(net, daddr, hnum) & udp_table.mask;\nstart_lookup:\n\t\thslot = &udp_table.hash2[hash2];\n\t\toffset = offsetof(typeof(*sk), __sk_common.skc_portaddr_node);\n\t}\n\n\tspin_lock(&hslot->lock);\n\tsk_nulls_for_each_entry_offset(sk, node, &hslot->head, offset) {\n\t\tif (__udp_is_mcast_sock(net, sk,\n\t\t\t\t\tuh->dest, daddr,\n\t\t\t\t\tuh->source, saddr,\n\t\t\t\t\tdif, hnum)) {\n\t\t\tif (unlikely(count == ARRAY_SIZE(stack))) {\n\t\t\t\tflush_stack(stack, count, skb, ~0);\n\t\t\t\tinner_flushed = true;\n\t\t\t\tcount = 0;\n\t\t\t}\n\t\t\tstack[count++] = sk;\n\t\t\tsock_hold(sk);\n\t\t}\n\t}\n\n\tspin_unlock(&hslot->lock);\n\n\t\/* Also lookup *:port if we are using hash2 and haven't done so yet. *\/\n\tif (use_hash2 && hash2 != hash2_any) {\n\t\thash2 = hash2_any;\n\t\tgoto start_lookup;\n\t}\n\n\t\/*\n\t * do the slow work with no lock held\n\t *\/\n\tif (count) {\n\t\tflush_stack(stack, count, skb, count - 1);\n\t} else {\n\t\tif (!inner_flushed)\n\t\t\tUDP_INC_STATS_BH(net, UDP_MIB_IGNOREDMULTI,\n\t\t\t\t\t proto == IPPROTO_UDPLITE);\n\t\tconsume_skb(skb);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":279139,"func":"bool RenderFrameHostImpl::DidCommitNavigationInternal(\n    std::unique_ptr<NavigationRequest> navigation_request,\n    FrameHostMsg_DidCommitProvisionalLoad_Params* validated_params,\n    bool is_same_document_navigation) {\n  DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params->transition),\n            !GetParent());\n\n  std::unique_ptr<NavigationRequest> invalid_request = nullptr;\n  if (navigation_request &&\n      navigation_request->commit_params().navigation_token !=\n          validated_params->navigation_token) {\n    navigation_request.reset();\n  }\n\n  if (!ValidateDidCommitParams(navigation_request.get(), validated_params,\n                               is_same_document_navigation)) {\n    return false;\n  }\n\n  if (navigation_request &&\n      navigation_request->common_params().url != validated_params->url) {\n\n    invalid_request = std::move(navigation_request);\n  }\n\n  if (!is_loading()) {\n    bool was_loading = frame_tree_node()->frame_tree()->IsLoading();\n    is_loading_ = true;\n    frame_tree_node()->DidStartLoading(!is_same_document_navigation,\n                                       was_loading);\n  }\n\n  if (navigation_request)\n    was_discarded_ = navigation_request->commit_params().was_discarded;\n\n  if (!navigation_request) {\n    NavigationEntryImpl* entry_for_navigation = nullptr;\n    if (invalid_request && NavigationRequestWasIntendedForPendingEntry(\n                               invalid_request.get(), *validated_params,\n                               is_same_document_navigation)) {\n      entry_for_navigation = NavigationEntryImpl::FromNavigationEntry(\n          frame_tree_node()->navigator()->GetController()->GetPendingEntry());\n    }\n\n    navigation_request = CreateNavigationRequestForCommit(\n        *validated_params, is_same_document_navigation, entry_for_navigation);\n  }\n\n  DCHECK(navigation_request);\n  DCHECK(navigation_request->navigation_handle());\n\n  navigation_request->set_transition(validated_params->transition);\n\n  navigation_request->set_has_user_gesture(validated_params->gesture ==\n                                           NavigationGestureUser);\n\n  UpdateSiteURL(validated_params->url, validated_params->url_is_unreachable);\n\n  is_mhtml_document_ =\n      (navigation_request->GetMimeType() == \"multipart\/related\" ||\n       navigation_request->GetMimeType() == \"message\/rfc822\");\n\n  accessibility_reset_count_ = 0;\n  appcache_handle_ =\n      navigation_request->navigation_handle()->TakeAppCacheHandle();\n  frame_tree_node()->navigator()->DidNavigate(this, *validated_params,\n                                              std::move(navigation_request),\n                                              is_same_document_navigation);\n\n  if (is_same_document_navigation && invalid_request)\n    same_document_navigation_request_ = std::move(invalid_request);\n\n  if (!is_same_document_navigation)\n    scheduler_tracked_features_ = 0;\n\n  return true;\n}\n","target":0,"code_token_length":555,"total_token_length":791,"max_tokens_setting":1024}
+{"idx":489011,"func":"static SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(PCtxtHandle phContext, ULONG fQOP,\n                                                        PSecBufferDesc pMessage, ULONG MessageSeqNo)\n{\n#ifdef WITH_GSSAPI\n\tKRB_CONTEXT* context;\n\tPSecBuffer sig_buffer, data_buffer;\n\tkrb5_key key;\n\tkrb5_keyusage usage;\n\tchar* header;\n\tBYTE flags = 0;\n\tkrb5_crypto_iov iov[] = { { KRB5_CRYPTO_TYPE_DATA, { 0 } },\n\t\t                      { KRB5_CRYPTO_TYPE_DATA, { 0 } },\n\t\t                      { KRB5_CRYPTO_TYPE_CHECKSUM, { 0 } } };\n\n\tcontext = sspi_SecureHandleGetLowerPointer(phContext);\n\tif (!context)\n\t\treturn SEC_E_INVALID_HANDLE;\n\n\tif (!(context->flags & SSPI_GSS_C_INTEG_FLAG))\n\t\treturn SEC_E_UNSUPPORTED_FUNCTION;\n\n\tsig_buffer = sspi_FindSecBuffer(pMessage, SECBUFFER_TOKEN);\n\tdata_buffer = sspi_FindSecBuffer(pMessage, SECBUFFER_DATA);\n\n\tif (!sig_buffer || !data_buffer)\n\t\treturn SEC_E_INVALID_TOKEN;\n\n\tflags |= context->acceptor ? FLAG_SENDER_IS_ACCEPTOR : 0;\n\tflags |= context->acceptor_key ? FLAG_ACCEPTOR_SUBKEY : 0;\n\n\tkey = context->acceptor_key    ? context->acceptor_key\n\t      : context->initiator_key ? context->initiator_key\n\t                               : context->session_key;\n\tif (!key)\n\t\treturn SEC_E_INTERNAL_ERROR;\n\tusage = context->acceptor ? KG_USAGE_ACCEPTOR_SIGN : KG_USAGE_INITIATOR_SIGN;\n\n\t\/* Fill in the lengths of the iov array *\/\n\tiov[0].data.length = data_buffer->cbBuffer;\n\tiov[1].data.length = 16;\n\tif (krb5_c_crypto_length_iov(context->ctx, krb5_k_key_enctype(context->ctx, key), iov,\n\t                             ARRAYSIZE(iov)))\n\t\treturn SEC_E_INTERNAL_ERROR;\n\n\t\/* Ensure the buffer is big enough *\/\n\tif (sig_buffer->cbBuffer < iov[2].data.length + 16)\n\t\treturn SEC_E_INSUFFICIENT_MEMORY;\n\n\t\/* Write the header *\/\n\theader = sig_buffer->pvBuffer;\n\tData_Write_UINT16_BE(header, TOK_ID_MIC);\n\theader[2] = flags;\n\tmemset(header + 3, 0xFF, 5);\n\tData_Write_UINT64_BE(header + 8, (context->local_seq + MessageSeqNo));\n\n\t\/* Set up the iov array *\/\n\tiov[0].data.data = data_buffer->pvBuffer;\n\tiov[1].data.data = header;\n\tiov[2].data.data = header + 16;\n\n\tif (krb5_k_make_checksum_iov(context->ctx, 0, key, usage, iov, ARRAYSIZE(iov)))\n\t\treturn SEC_E_INTERNAL_ERROR;\n\n\tsig_buffer->cbBuffer = iov[2].data.length + 16;\n\n\treturn SEC_E_OK;\n#else\n\treturn SEC_E_UNSUPPORTED_FUNCTION;\n#endif\n}","target":0,"code_token_length":632,"total_token_length":868,"max_tokens_setting":1024}
+{"idx":169859,"func":"static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)\n{\n    char *dirpath = g_path_get_dirname(fs_path->data);\n    char *name = g_path_get_basename(fs_path->data);\n    int ret = -1;\n    int dirfd;\n\n    dirfd = local_opendir_nofollow(fs_ctx, dirpath);\n    if (dirfd == -1) {\n        goto out;\n    }\n\n    if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||\n        (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||\n        (fs_ctx->export_flags & V9FS_SM_NONE)) {\n        ret = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid,\n                       AT_SYMLINK_NOFOLLOW);\n    } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) {\n        ret = local_set_xattrat(dirfd, name, credp);\n    } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {\n        ret = local_set_mapped_file_attrat(dirfd, name, credp);\n    }\n\n    close_preserve_errno(dirfd);\nout:\n    g_free(name);\n    g_free(dirpath);\n    return ret;\n}\n","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":407155,"func":"rotate_backups(const char *fname)\n{\n#ifdef __VMS\n# define SEP \"_\"\n# define AVS \";*\"                       \/* All-version suffix. *\/\n# define AVSL (sizeof (AVS) - 1)\n#else\n# define SEP \".\"\n# define AVSL 0\n#endif\n\n  int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL;\n  char *from = alloca (maxlen);\n  char *to = alloca (maxlen);\n  struct stat sb;\n  int i;\n\n  if (stat (fname, &sb) == 0)\n    if (S_ISREG (sb.st_mode) == 0)\n      return;\n\n  for (i = opt.backups; i > 1; i--)\n    {\n#ifdef VMS\n      \/* Delete (all versions of) any existing max-suffix file, to avoid\n       * creating multiple versions of it.  (On VMS, rename() will\n       * create a new version of an existing destination file, not\n       * destroy\/overwrite it.)\n       *\/\n      if (i == opt.backups)\n        {\n          snprintf (to, sizeof(to), \"%s%s%d%s\", fname, SEP, i, AVS);\n          delete (to);\n        }\n#endif\n      snprintf (to, maxlen, \"%s%s%d\", fname, SEP, i);\n      snprintf (from, maxlen, \"%s%s%d\", fname, SEP, i - 1);\n      if (rename (from, to))\n        logprintf (LOG_NOTQUIET, \"Failed to rename %s to %s: (%d) %s\\n\",\n                   from, to, errno, strerror (errno));\n    }\n\n  snprintf (to, maxlen, \"%s%s%d\", fname, SEP, 1);\n  if (rename(fname, to))\n    logprintf (LOG_NOTQUIET, \"Failed to rename %s to %s: (%d) %s\\n\",\n               fname, to, errno, strerror (errno));\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":471110,"func":"parse_absolute_time(const char *s, uint64_t *tp)\n{\n\tstruct tm tm;\n\ttime_t tt;\n\tchar buf[32], *fmt;\n\n\t*tp = 0;\n\n\t\/*\n\t * POSIX strptime says \"The application shall ensure that there\n\t * is white-space or other non-alphanumeric characters between\n\t * any two conversion specifications\" so arrange things this way.\n\t *\/\n\tswitch (strlen(s)) {\n\tcase 8: \/* YYYYMMDD *\/\n\t\tfmt = \"%Y-%m-%d\";\n\t\tsnprintf(buf, sizeof(buf), \"%.4s-%.2s-%.2s\", s, s + 4, s + 6);\n\t\tbreak;\n\tcase 12: \/* YYYYMMDDHHMM *\/\n\t\tfmt = \"%Y-%m-%dT%H:%M\";\n\t\tsnprintf(buf, sizeof(buf), \"%.4s-%.2s-%.2sT%.2s:%.2s\",\n\t\t    s, s + 4, s + 6, s + 8, s + 10);\n\t\tbreak;\n\tcase 14: \/* YYYYMMDDHHMMSS *\/\n\t\tfmt = \"%Y-%m-%dT%H:%M:%S\";\n\t\tsnprintf(buf, sizeof(buf), \"%.4s-%.2s-%.2sT%.2s:%.2s:%.2s\",\n\t\t    s, s + 4, s + 6, s + 8, s + 10, s + 12);\n\t\tbreak;\n\tdefault:\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\t}\n\n\tmemset(&tm, 0, sizeof(tm));\n\tif (strptime(buf, fmt, &tm) == NULL)\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\tif ((tt = mktime(&tm)) < 0)\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\t\/* success *\/\n\t*tp = (uint64_t)tt;\n\treturn 0;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":243452,"func":"bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr)\n{\n bdstr_t bdstr;\n\n    BTIF_TRACE_EVENT(\"%s: bd_addr=%s\", __FUNCTION__, bdaddr_to_string(bd_addr, bdstr, sizeof(bdstr)));\n\n \/* TODO:\n    **  1. Restore scan modes\n    **  2. special handling for HID devices\n    *\/\n if (pairing_cb.state == BT_BOND_STATE_BONDING)\n {\n\n#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))\n\n if (pairing_cb.is_ssp)\n {\n if (pairing_cb.is_le_only)\n {\n                BTA_DmBleSecurityGrant((UINT8 *)bd_addr->address,BTA_DM_SEC_PAIR_NOT_SPT);\n }\n else\n {\n                BTA_DmConfirm( (UINT8 *)bd_addr->address, FALSE);\n                BTA_DmBondCancel ((UINT8 *)bd_addr->address);\n                btif_storage_remove_bonded_device((bt_bdaddr_t *)bd_addr);\n }\n }\n else\n {\n if (pairing_cb.is_le_only)\n {\n                BTA_DmBondCancel ((UINT8 *)bd_addr->address);\n }\n else\n {\n                BTA_DmPinReply( (UINT8 *)bd_addr->address, FALSE, 0, NULL);\n }\n \/* Cancel bonding, in case it is in ACL connection setup state *\/\n        BTA_DmBondCancel ((UINT8 *)bd_addr->address);\n }\n\n#else\n if (pairing_cb.is_ssp)\n {\n            BTA_DmConfirm( (UINT8 *)bd_addr->address, FALSE);\n }\n else\n {\n            BTA_DmPinReply( (UINT8 *)bd_addr->address, FALSE, 0, NULL);\n }\n \/* Cancel bonding, in case it is in ACL connection setup state *\/\n        BTA_DmBondCancel ((UINT8 *)bd_addr->address);\n        btif_storage_remove_bonded_device((bt_bdaddr_t *)bd_addr);\n#endif\n }\n\n return BT_STATUS_SUCCESS;\n}\n","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":39829,"func":"fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto)\n{\n  char hdr[VAR_CELL_MAX_HEADER_SIZE];\n  var_cell_t *result;\n  uint8_t command;\n  uint16_t length;\n  const int wide_circ_ids = linkproto >= MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS;\n  const int circ_id_len = get_circ_id_size(wide_circ_ids);\n  const unsigned header_len = get_var_cell_header_size(wide_circ_ids);\n  check();\n  *out = NULL;\n  if (buf->datalen < header_len)\n    return 0;\n  peek_from_buf(hdr, header_len, buf);\n\n  command = get_uint8(hdr + circ_id_len);\n  if (!(cell_command_is_var_length(command, linkproto)))\n    return 0;\n\n  length = ntohs(get_uint16(hdr + circ_id_len + 1));\n  if (buf->datalen < (size_t)(header_len+length))\n    return 1;\n  result = var_cell_new(length);\n  result->command = command;\n  if (wide_circ_ids)\n    result->circ_id = ntohl(get_uint32(hdr));\n  else\n    result->circ_id = ntohs(get_uint16(hdr));\n\n  buf_remove_from_front(buf, header_len);\n  peek_from_buf((char*) result->payload, length, buf);\n  buf_remove_from_front(buf, length);\n  check();\n\n  *out = result;\n  return 1;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":59465,"func":"static void gf_hevc_vvc_parse_sei(char *buffer, u32 nal_size, HEVCState *hevc, VVCState *vvc)\n{\n\tu32 ptype, psize, hdr;\n\tu64 start;\n\tGF_BitStream *bs;\n\n\thdr = buffer[0];\n\tif (((hdr & 0x7e) >> 1) != GF_HEVC_NALU_SEI_PREFIX) return;\n\n\tbs = gf_bs_new(buffer, nal_size, GF_BITSTREAM_READ);\n\tgf_bs_enable_emulation_byte_removal(bs, GF_TRUE);\n\n\tgf_bs_read_int(bs, 16);\n\n\t\/*parse SEI*\/\n\twhile (gf_bs_available(bs)) {\n\t\tu32 consumed;\n\t\tptype = 0;\n\t\twhile (gf_bs_peek_bits(bs, 8, 0)==0xFF) {\n\t\t\tgf_bs_read_int(bs, 8);\n\t\t\tptype += 255;\n\t\t}\n\t\tptype += gf_bs_read_int(bs, 8);\n\t\tpsize = 0;\n\t\twhile (gf_bs_peek_bits(bs, 8, 0)==0xFF) {\n\t\t\tgf_bs_read_int(bs, 8);\n\t\t\tpsize += 255;\n\t\t}\n\t\tpsize += gf_bs_read_int(bs, 8);\n\n\t\tstart = gf_bs_get_position(bs);\n\t\tif (start+psize >= nal_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CODING, (\"[%s] SEI user message type %d size error (%d but %d remain), skipping SEI message\\n\", hevc ? \"HEVC\" : \"VVC\", ptype, psize, nal_size-start));\n\t\t\tbreak;\n\t\t}\n\n\t\tswitch (ptype) {\n\t\tcase 4: \/*user registered ITU-T T35*\/\n\t\t\tif (hevc) {\n\t\t\t\tavc_parse_itu_t_t35_sei(bs, &hevc->sei.dovi);\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t\tgf_bs_align(bs);\n\t\tconsumed = (u32) (gf_bs_get_position(bs) - start);\n\t\tpsize-=consumed;\n\t\tgf_bs_skip_bytes(bs, psize);\n\t\tif (gf_bs_available(bs) <= 2)\n\t\t\tbreak;\n\t}\n\tgf_bs_del(bs);\n}","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":409290,"func":"static void digit_gen(diy_fp_t Mp, diy_fp_t delta, char* buffer, int* len, int* K)\n{\n\tuint32_t div, p1;\n\tuint64_t p2;\n\tint d,kappa;\n\tdiy_fp_t one;\n\tone.f = ((uint64_t) 1) << -Mp.e; one.e = Mp.e;\n\tp1 = Mp.f >> -one.e;\n\tp2 = Mp.f & (one.f - 1);\n\t*len = 0; kappa = 3; div = TEN2;\n\twhile (kappa > 0) {\n\t\td = p1 \/ div;\n\t\tif (d || *len) buffer[(*len)++] = '0' + d;\n\t\tp1 %= div; kappa--; div \/= 10;\n\t\tif ((((uint64_t)p1)<<-one.e)+p2 <= delta.f) {\n\t\t\t*K += kappa; return;\n\t\t}\n\t}\n\tdo {\n\t\tp2 *= 10;\n\t\td = p2 >> -one.e;\n\t\tif (d || *len) buffer[(*len)++] = '0' + d;\n\t\tp2 &= one.f - 1; kappa--; delta.f *= 10;\n\t} while (p2 > delta.f);\n\t*K += kappa;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":458259,"func":"opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder)\n{\n    opj_jp2_t *jp2 = (opj_jp2_t*)opj_calloc(1, sizeof(opj_jp2_t));\n    if (jp2) {\n\n        \/* create the J2K codec *\/\n        if (! p_is_decoder) {\n            jp2->j2k = opj_j2k_create_compress();\n        } else {\n            jp2->j2k = opj_j2k_create_decompress();\n        }\n\n        if (jp2->j2k == 00) {\n            opj_jp2_destroy(jp2);\n            return 00;\n        }\n\n        \/* Color structure *\/\n        jp2->color.icc_profile_buf = NULL;\n        jp2->color.icc_profile_len = 0;\n        jp2->color.jp2_cdef = NULL;\n        jp2->color.jp2_pclr = NULL;\n        jp2->color.jp2_has_colr = 0;\n\n        \/* validation list creation *\/\n        jp2->m_validation_list = opj_procedure_list_create();\n        if (! jp2->m_validation_list) {\n            opj_jp2_destroy(jp2);\n            return 00;\n        }\n\n        \/* execution list creation *\/\n        jp2->m_procedure_list = opj_procedure_list_create();\n        if (! jp2->m_procedure_list) {\n            opj_jp2_destroy(jp2);\n            return 00;\n        }\n    }\n\n    return jp2;\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":195578,"func":"static MagickBooleanType ClonePixelCacheOnDisk(\n  CacheInfo *magick_restrict cache_info,CacheInfo *magick_restrict clone_info,\n  ExceptionInfo *exception)\n{\n  MagickSizeType\n    extent;\n\n  size_t\n    quantum;\n\n  ssize_t\n    count;\n\n  struct stat\n    file_stats;\n\n  unsigned char\n    *buffer;\n\n  \/*\n    Clone pixel cache on disk with identical morphology.\n  *\/\n  if ((OpenPixelCacheOnDisk(cache_info,ReadMode) == MagickFalse) ||\n      (OpenPixelCacheOnDisk(clone_info,IOMode) == MagickFalse))\n    return(MagickFalse);\n  quantum=(size_t) MagickMaxBufferExtent;\n  if ((fstat(cache_info->file,&file_stats) == 0) && (file_stats.st_size > 0))\n    quantum=(size_t) MagickMin(file_stats.st_size,MagickMaxBufferExtent);\n  buffer=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*buffer));\n  if (buffer == (unsigned char *) NULL)\n    ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n  extent=0;\n  while ((count=read(cache_info->file,buffer,quantum)) > 0)\n  {\n    ssize_t\n      number_bytes;\n\n    number_bytes=write(clone_info->file,buffer,(size_t) count);\n    if (number_bytes != count)\n      break;\n    extent+=number_bytes;\n  }\n  buffer=(unsigned char *) RelinquishMagickMemory(buffer);\n  if (extent != cache_info->length)\n    return(MagickFalse);\n  return(MagickTrue);\n}\n","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":52966,"func":"static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream)\n{\n    int i, stream_no;\n    const char *type = \"unknown\";\n    char parameters[64];\n    LayeredAVStream *st;\n    AVCodec *codec;\n\n    stream_no = stream->nb_streams;\n\n    avio_printf(pb, \"<table><tr><th>Stream<th>\"\n                    \"type<th>kbit\/s<th>codec<th>\"\n                    \"Parameters\\n\");\n\n    for (i = 0; i < stream_no; i++) {\n        st = stream->streams[i];\n        codec = avcodec_find_encoder(st->codecpar->codec_id);\n\n        parameters[0] = 0;\n\n        switch(st->codecpar->codec_type) {\n        case AVMEDIA_TYPE_AUDIO:\n            type = \"audio\";\n            snprintf(parameters, sizeof(parameters), \"%d channel(s), %d Hz\",\n                     st->codecpar->channels, st->codecpar->sample_rate);\n            break;\n        case AVMEDIA_TYPE_VIDEO:\n            type = \"video\";\n            snprintf(parameters, sizeof(parameters),\n                     \"%dx%d, q=%d-%d, fps=%d\", st->codecpar->width,\n                     st->codecpar->height, st->codec->qmin, st->codec->qmax,\n                     st->time_base.den \/ st->time_base.num);\n            break;\n        default:\n            abort();\n        }\n\n        avio_printf(pb, \"<tr><td>%d<td>%s<td>%\"PRId64\n                        \"<td>%s<td>%s\\n\",\n                    i, type, (int64_t)st->codecpar->bit_rate\/1000,\n                    codec ? codec->name : \"\", parameters);\n     }\n\n     avio_printf(pb, \"<\/table>\\n\");\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":333527,"func":"static int gif_image_write_header(ByteIOContext *pb, \n\n                                  int width, int height, uint32_t *palette)\n\n{\n\n    int i;\n\n    unsigned int v;\n\n\n\n    put_tag(pb, \"GIF\");\n\n    put_tag(pb, \"89a\");\n\n    put_le16(pb, width);\n\n    put_le16(pb, height);\n\n\n\n    put_byte(pb, 0xf7); \/* flags: global clut, 256 entries *\/\n\n    put_byte(pb, 0x1f); \/* background color index *\/\n\n    put_byte(pb, 0); \/* aspect ratio *\/\n\n\n\n    \/* the global palette *\/\n\n    if (!palette) {\n\n        put_buffer(pb, (unsigned char *)gif_clut, 216*3);\n\n        for(i=0;i<((256-216)*3);i++)\n\n            put_byte(pb, 0);\n\n    } else {\n\n        for(i=0;i<256;i++) {\n\n            v = palette[i];\n\n            put_byte(pb, (v >> 16) & 0xff);\n\n            put_byte(pb, (v >> 8) & 0xff);\n\n            put_byte(pb, (v) & 0xff);\n\n        }\n\n    }\n\n\n\n    \/* application extension header *\/\n\n    \/* XXX: not really sure what to put in here... *\/\n\n#ifdef GIF_ADD_APP_HEADER\n\n    put_byte(pb, 0x21);\n\n    put_byte(pb, 0xff);\n\n    put_byte(pb, 0x0b);\n\n    put_tag(pb, \"NETSCAPE2.0\");\n\n    put_byte(pb, 0x03);\n\n    put_byte(pb, 0x01);\n\n    put_byte(pb, 0x00);\n\n    put_byte(pb, 0x00);\n\n#endif\n\n    return 0;\n\n}\n","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":7246,"func":"static struct key *construct_key_and_link(struct keyring_search_context *ctx,\n\t\t\t\t\t  const char *callout_info,\n\t\t\t\t\t  size_t callout_len,\n\t\t\t\t\t  void *aux,\n\t\t\t\t\t  struct key *dest_keyring,\n\t\t\t\t\t  unsigned long flags)\n{\n\tstruct key_user *user;\n\tstruct key *key;\n\tint ret;\n\n\tkenter(\"\");\n\n\tif (ctx->index_key.type == &key_type_keyring)\n\t\treturn ERR_PTR(-EPERM);\n\n\tuser = key_user_lookup(current_fsuid());\n\tif (!user)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tconstruct_get_dest_keyring(&dest_keyring);\n\n\tret = construct_alloc_key(ctx, dest_keyring, flags, user, &key);\n\tkey_user_put(user);\n\n\tif (ret == 0) {\n\t\tret = construct_key(key, callout_info, callout_len, aux,\n\t\t\t\t    dest_keyring);\n\t\tif (ret < 0) {\n\t\t\tkdebug(\"cons failed\");\n\t\t\tgoto construction_failed;\n\t\t}\n\t} else if (ret == -EINPROGRESS) {\n\t\tret = 0;\n\t} else {\n\t\tgoto couldnt_alloc_key;\n\t}\n\n\tkey_put(dest_keyring);\n\tkleave(\" = key %d\", key_serial(key));\n\treturn key;\n\nconstruction_failed:\n\tkey_negate_and_link(key, key_negative_timeout, NULL, NULL);\n\tkey_put(key);\ncouldnt_alloc_key:\n\tkey_put(dest_keyring);\n\tkleave(\" = %d\", ret);\n\treturn ERR_PTR(ret);\n}","target":1,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":249496,"func":"void FS_Restart( int checksumFeed ) {\n\tconst char *lastGameDir;\n\n\tFS_Shutdown( qfalse );\n\n\tfs_checksumFeed = checksumFeed;\n\n\tFS_ClearPakReferences( 0 );\n\n\tFS_Startup(com_basegame->string);\n\n#ifndef STANDALONE\n\tFS_CheckPak0( );\n#endif\n\n\tif ( FS_ReadFile( \"default.cfg\", NULL ) <= 0 ) {\n\t\tif ( lastValidBase[0] ) {\n\t\t\tFS_PureServerSetLoadedPaks( \"\", \"\" );\n\t\t\tCvar_Set( \"fs_basepath\", lastValidBase );\n\t\t\tCvar_Set( \"com_basegame\", lastValidComBaseGame );\n\t\t\tCvar_Set( \"fs_basegame\", lastValidFsBaseGame );\n\t\t\tCvar_Set( \"fs_game\", lastValidGame );\n\t\t\tlastValidBase[0] = '\\0';\n\t\t\tlastValidComBaseGame[0] = '\\0';\n\t\t\tlastValidFsBaseGame[0] = '\\0';\n\t\t\tlastValidGame[0] = '\\0';\n\t\t\tFS_Restart( checksumFeed );\n\t\t\tCom_Error( ERR_DROP, \"Invalid game folder\" );\n\t\t\treturn;\n\t\t}\n\t\tCom_Error( ERR_FATAL, \"Couldn't load default.cfg\" );\n\t}\n\n\tlastGameDir = ( lastValidGame[0] ) ? lastValidGame : lastValidComBaseGame;\n\n\tif ( Q_stricmp( FS_GetCurrentGameDir(), lastGameDir ) ) {\n\t\tSys_RemovePIDFile( lastGameDir );\n\t\tSys_InitPIDFile( FS_GetCurrentGameDir() );\n\n\t\tif ( !Com_SafeMode() ) {\n\t\t\tCbuf_AddText(\"exec \" Q3CONFIG_CFG \"\\n\");\n\t\t}\n\t}\n\n\tQ_strncpyz( lastValidBase, fs_basepath->string, sizeof( lastValidBase ) );\n\tQ_strncpyz( lastValidComBaseGame, com_basegame->string, sizeof( lastValidComBaseGame ) );\n\tQ_strncpyz( lastValidFsBaseGame, fs_basegame->string, sizeof( lastValidFsBaseGame ) );\n\tQ_strncpyz( lastValidGame, fs_gamedirvar->string, sizeof( lastValidGame ) );\n\n}\n","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":16428,"func":"static inline int mpeg2_fast_decode_block_intra ( MpegEncContext * s , int16_t * block , int n ) {\n int level , dc , diff , j , run ;\n int component ;\n RLTable * rl ;\n uint8_t * scantable = s -> intra_scantable . permutated ;\n const uint16_t * quant_matrix ;\n const int qscale = s -> qscale ;\n if ( n < 4 ) {\n quant_matrix = s -> intra_matrix ;\n component = 0 ;\n }\n else {\n quant_matrix = s -> chroma_intra_matrix ;\n component = ( n & 1 ) + 1 ;\n }\n diff = decode_dc ( & s -> gb , component ) ;\n if ( diff >= 0xffff ) return - 1 ;\n dc = s -> last_dc [ component ] ;\n dc += diff ;\n s -> last_dc [ component ] = dc ;\n block [ 0 ] = dc << ( 3 - s -> intra_dc_precision ) ;\n if ( s -> intra_vlc_format ) rl = & ff_rl_mpeg2 ;\n else rl = & ff_rl_mpeg1 ;\n {\n OPEN_READER ( re , & s -> gb ) ;\n for ( ;\n ;\n ) {\n UPDATE_CACHE ( re , & s -> gb ) ;\n GET_RL_VLC ( level , run , re , & s -> gb , rl -> rl_vlc [ 0 ] , TEX_VLC_BITS , 2 , 0 ) ;\n if ( level == 127 ) {\n break ;\n }\n else if ( level != 0 ) {\n scantable += run ;\n j = * scantable ;\n level = ( level * qscale * quant_matrix [ j ] ) >> 4 ;\n level = ( level ^ SHOW_SBITS ( re , & s -> gb , 1 ) ) - SHOW_SBITS ( re , & s -> gb , 1 ) ;\n LAST_SKIP_BITS ( re , & s -> gb , 1 ) ;\n }\n else {\n run = SHOW_UBITS ( re , & s -> gb , 6 ) + 1 ;\n LAST_SKIP_BITS ( re , & s -> gb , 6 ) ;\n UPDATE_CACHE ( re , & s -> gb ) ;\n level = SHOW_SBITS ( re , & s -> gb , 12 ) ;\n SKIP_BITS ( re , & s -> gb , 12 ) ;\n scantable += run ;\n j = * scantable ;\n if ( level < 0 ) {\n level = ( - level * qscale * quant_matrix [ j ] ) >> 4 ;\n level = - level ;\n }\n else {\n level = ( level * qscale * quant_matrix [ j ] ) >> 4 ;\n }\n }\n block [ j ] = level ;\n }\n CLOSE_READER ( re , & s -> gb ) ;\n }\n s -> block_last_index [ n ] = scantable - s -> intra_scantable . permutated ;\n return 0 ;\n }","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":394743,"func":"xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {\n    xmlXPathObjectPtr tmp, obj, point;\n    xmlLocationSetPtr newset = NULL;\n    xmlLocationSetPtr oldset = NULL;\n\n    CHECK_ARITY(1);\n    if ((ctxt->value == NULL) ||\n\t((ctxt->value->type != XPATH_LOCATIONSET) &&\n\t (ctxt->value->type != XPATH_NODESET)))\n        XP_ERROR(XPATH_INVALID_TYPE)\n\n    obj = valuePop(ctxt);\n    if (obj->type == XPATH_NODESET) {\n\t\/*\n\t * First convert to a location set\n\t *\/\n\ttmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);\n\txmlXPathFreeObject(obj);\n\tif (tmp == NULL)\n            XP_ERROR(XPATH_MEMORY_ERROR)\n\tobj = tmp;\n    }\n\n    newset = xmlXPtrLocationSetCreate(NULL);\n    if (newset == NULL) {\n\txmlXPathFreeObject(obj);\n        XP_ERROR(XPATH_MEMORY_ERROR);\n    }\n    oldset = (xmlLocationSetPtr) obj->user;\n    if (oldset != NULL) {\n\tint i;\n\n\tfor (i = 0; i < oldset->locNr; i++) {\n\t    tmp = oldset->locTab[i];\n\t    if (tmp == NULL)\n\t\tcontinue;\n\t    point = NULL;\n\t    switch (tmp->type) {\n\t\tcase XPATH_POINT:\n\t\t    point = xmlXPtrNewPoint(tmp->user, tmp->index);\n\t\t    break;\n\t\tcase XPATH_RANGE: {\n\t\t    xmlNodePtr node = tmp->user2;\n\t\t    if (node != NULL) {\n\t\t\tif (node->type == XML_ATTRIBUTE_NODE) {\n\t\t\t    \/* TODO: Namespace Nodes ??? *\/\n\t\t\t    xmlXPathFreeObject(obj);\n\t\t\t    xmlXPtrFreeLocationSet(newset);\n\t\t\t    XP_ERROR(XPTR_SYNTAX_ERROR);\n\t\t\t}\n\t\t\tpoint = xmlXPtrNewPoint(node, tmp->index2);\n\t\t    } else if (tmp->user == NULL) {\n\t\t\tpoint = xmlXPtrNewPoint(node,\n\t\t\t\t       xmlXPtrNbLocChildren(node));\n\t\t    }\n\t\t    break;\n\t        }\n\t\tdefault:\n\t\t    \/*** Should we raise an error ?\n\t\t    xmlXPathFreeObject(obj);\n\t\t    xmlXPathFreeObject(newset);\n\t\t    XP_ERROR(XPATH_INVALID_TYPE)\n\t\t    ***\/\n\t\t    break;\n\t    }\n            if (point != NULL)\n\t\txmlXPtrLocationSetAdd(newset, point);\n\t}\n    }\n    xmlXPathFreeObject(obj);\n    valuePush(ctxt, xmlXPtrWrapLocationSet(newset));\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":135439,"func":"void ecdsa_sign_legacy(ecdsa_signature_t *signature, const ecc_int256_t *hash, const ecc_int256_t *secret) {\n  ecc_int256_t hash_r, k, krecip, tmp;\n  ecc_25519_work_t kG;\n  uint8_t V[32], K[32];\n\n  \/\/ Reduce hash (instead of clearing 3 bits)\n  ecc_25519_gf_reduce(&hash_r, hash);\n\n  \/\/ Generate k\n  generate_k_prepare(V, K, secret->p, hash_r.p);\n\nregenerate:\n  generate_k(k.p, V, K);\n  ecc_25519_gf_sanitize_secret(&k, &k);\n\n  \/\/ calculate k^(-1)\n  ecc_25519_gf_recip(&krecip, &k);\n\n  \/\/ calculate kG = k * base point\n  ecc_25519_scalarmult_base(&kG, &k);\n\n  \/\/ store x coordinate of kG in r\n  ecc_25519_store_xy_legacy(&tmp, NULL, &kG);\n  ecc_25519_gf_reduce(&signature->r, &tmp);\n\n  if (ecc_25519_gf_is_zero(&signature->r))\n    goto regenerate;\n\n  \/\/ tmp = r * secret\n  ecc_25519_gf_mult(&tmp, &signature->r, secret);\n\n  \/\/ s = hash + tmp = hash + r * secret\n  ecc_25519_gf_add(&signature->s, &hash_r, &tmp);\n\n  \/\/ tmp = krecip * s = k^(-1) * s\n  ecc_25519_gf_mult(&tmp, &krecip, &signature->s);\n\n  \/\/ mod n (order of G)\n  ecc_25519_gf_reduce(&signature->s, &tmp);\n\n  if (ecc_25519_gf_is_zero(&signature->s))\n    goto regenerate;\n}","target":0,"code_token_length":452,"total_token_length":688,"max_tokens_setting":1024}
+{"idx":422324,"func":"e_ews_connection_move_items (EEwsConnection *cnc,\n                             gint pri,\n                             const gchar *folder_id,\n                             gboolean docopy,\n                             const GSList *ids,\n                             GCancellable *cancellable,\n                             GAsyncReadyCallback callback,\n                             gpointer user_data)\n{\n\tESoapMessage *msg;\n\tGSimpleAsyncResult *simple;\n\tEwsAsyncData *async_data;\n\tconst GSList *iter;\n\n\tg_return_if_fail (cnc != NULL);\n\n\tif (docopy)\n\t\tmsg = e_ews_message_new_with_header (\n\t\t\t\tcnc->priv->settings,\n\t\t\t\tcnc->priv->uri,\n\t\t\t\tcnc->priv->impersonate_user,\n\t\t\t\t\"CopyItem\",\n\t\t\t\tNULL,\n\t\t\t\tNULL,\n\t\t\t\tcnc->priv->version,\n\t\t\t\tE_EWS_EXCHANGE_2007_SP1,\n\t\t\t\tFALSE,\n\t\t\t\tTRUE);\n\telse\n\t\tmsg = e_ews_message_new_with_header (\n\t\t\t\tcnc->priv->settings,\n\t\t\t\tcnc->priv->uri,\n\t\t\t\tcnc->priv->impersonate_user,\n\t\t\t\t\"MoveItem\",\n\t\t\t\tNULL,\n\t\t\t\tNULL,\n\t\t\t\tcnc->priv->version,\n\t\t\t\tE_EWS_EXCHANGE_2007_SP1,\n\t\t\t\tFALSE,\n\t\t\t\tTRUE);\n\n\te_soap_message_start_element (msg, \"ToFolderId\", \"messages\", NULL);\n\te_soap_message_start_element (msg, \"FolderId\", NULL, NULL);\n\te_soap_message_add_attribute (msg, \"Id\", folder_id, NULL, NULL);\n\te_soap_message_end_element (msg); \/* FolderId *\/\n\te_soap_message_end_element (msg); \/* ToFolderId *\/\n\n\te_soap_message_start_element (msg, \"ItemIds\", \"messages\", NULL);\n\tfor (iter = ids; iter != NULL; iter = g_slist_next (iter))\n\t\te_ews_message_write_string_parameter_with_attribute (msg, \"ItemId\", NULL, NULL, \"Id\", iter->data);\n\te_soap_message_end_element (msg); \/* ItemIds *\/\n\n\te_ews_message_write_footer (msg);\n\n\tsimple = g_simple_async_result_new (\n\t\tG_OBJECT (cnc), callback, user_data,\n\t\te_ews_connection_move_items);\n\n\tasync_data = g_new0 (EwsAsyncData, 1);\n\tg_simple_async_result_set_op_res_gpointer (\n\t\tsimple, async_data, (GDestroyNotify) async_data_free);\n\n\te_ews_connection_queue_request (\n\t\tcnc, msg, get_items_response_cb,\n\t\tpri, cancellable, simple);\n\n\tg_object_unref (simple);\n}","target":0,"code_token_length":534,"total_token_length":770,"max_tokens_setting":1024}
+{"idx":125481,"func":"static unsigned postProcessScanlines(unsigned char* out, unsigned char* in,\n                                     unsigned w, unsigned h, const LodePNGInfo* info_png)\n{\n  \/*\n  This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.\n  Steps:\n  *) if no Adam7: 1) unfilter 2) remove padding bits (= posible extra bits per scanline if bpp < 8)\n  *) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) Adam7_deinterlace\n  NOTE: the in buffer will be overwritten with intermediate data!\n  *\/\n  unsigned bpp = lodepng_get_bpp(&info_png->color);\n  if(bpp == 0) return 31; \/*error: invalid colortype*\/\n\n  if(info_png->interlace_method == 0)\n  {\n    if(bpp < 8 && w * bpp != ((w * bpp + 7) \/ 8) * 8)\n    {\n      CERROR_TRY_RETURN(unfilter(in, in, w, h, bpp));\n      removePaddingBits(out, in, w * bpp, ((w * bpp + 7) \/ 8) * 8, h);\n    }\n    \/*we can immediatly filter into the out buffer, no other steps needed*\/\n    else CERROR_TRY_RETURN(unfilter(out, in, w, h, bpp));\n  }\n  else \/*interlace_method is 1 (Adam7)*\/\n  {\n    unsigned passw[7], passh[7]; size_t filter_passstart[8], padded_passstart[8], passstart[8];\n    unsigned i;\n\n    Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);\n\n    for(i = 0; i < 7; i++)\n    {\n      CERROR_TRY_RETURN(unfilter(&in[padded_passstart[i]], &in[filter_passstart[i]], passw[i], passh[i], bpp));\n      \/*TODO: possible efficiency improvement: if in this reduced image the bits fit nicely in 1 scanline,\n      move bytes instead of bits or move not at all*\/\n      if(bpp < 8)\n      {\n        \/*remove padding bits in scanlines; after this there still may be padding\n        bits between the different reduced images: each reduced image still starts nicely at a byte*\/\n        removePaddingBits(&in[passstart[i]], &in[padded_passstart[i]], passw[i] * bpp,\n                          ((passw[i] * bpp + 7) \/ 8) * 8, passh[i]);\n      }\n    }\n\n    Adam7_deinterlace(out, in, w, h, bpp);\n  }\n\n  return 0;\n}","target":0,"code_token_length":597,"total_token_length":833,"max_tokens_setting":1024}
+{"idx":488412,"func":"static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,\n\t\t\t  int sfmode, int sfcount, const struct in6_addr *psfsrc,\n\t\t\t  int delta)\n{\n\tstruct ifmcaddr6 *pmc;\n\tint\tisexclude;\n\tint\ti, err;\n\n\tif (!idev)\n\t\treturn -ENODEV;\n\n\tfor_each_mc_mclock(idev, pmc) {\n\t\tif (ipv6_addr_equal(pmca, &pmc->mca_addr))\n\t\t\tbreak;\n\t}\n\tif (!pmc)\n\t\treturn -ESRCH;\n\n\tsf_markstate(pmc);\n\tisexclude = pmc->mca_sfmode == MCAST_EXCLUDE;\n\tif (!delta)\n\t\tpmc->mca_sfcount[sfmode]++;\n\terr = 0;\n\tfor (i = 0; i < sfcount; i++) {\n\t\terr = ip6_mc_add1_src(pmc, sfmode, &psfsrc[i]);\n\t\tif (err)\n\t\t\tbreak;\n\t}\n\tif (err) {\n\t\tint j;\n\n\t\tif (!delta)\n\t\t\tpmc->mca_sfcount[sfmode]--;\n\t\tfor (j = 0; j < i; j++)\n\t\t\tip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);\n\t} else if (isexclude != (pmc->mca_sfcount[MCAST_EXCLUDE] != 0)) {\n\t\tstruct ip6_sf_list *psf;\n\n\t\t\/* filter mode change *\/\n\t\tif (pmc->mca_sfcount[MCAST_EXCLUDE])\n\t\t\tpmc->mca_sfmode = MCAST_EXCLUDE;\n\t\telse if (pmc->mca_sfcount[MCAST_INCLUDE])\n\t\t\tpmc->mca_sfmode = MCAST_INCLUDE;\n\t\t\/* else no filters; keep old mode for reports *\/\n\n\t\tpmc->mca_crcount = idev->mc_qrv;\n\t\tidev->mc_ifc_count = pmc->mca_crcount;\n\t\tfor_each_psf_mclock(pmc, psf)\n\t\t\tpsf->sf_crcount = 0;\n\t\tmld_ifc_event(idev);\n\t} else if (sf_setstate(pmc)) {\n\t\tmld_ifc_event(idev);\n\t}\n\treturn err;\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":481272,"func":"_lou_defaultTableResolver(const char *tableList, const char *base) {\n\tchar *searchPath;\n\tchar **tableFiles;\n\tchar *subTable;\n\tchar *tableList_copy;\n\tchar *cp;\n\tint last;\n\tint k;\n\n\t\/* Set up search path *\/\n\tsearchPath = _lou_getTablePath();\n\n\t\/* Count number of subtables in table list *\/\n\tk = 0;\n\tfor (cp = (char *)tableList; *cp != '\\0'; cp++)\n\t\tif (*cp == ',') k++;\n\ttableFiles = (char **)calloc(k + 2, sizeof(char *));\n\tif (!tableFiles) _lou_outOfMemory();\n\n\t\/* Resolve subtables *\/\n\tk = 0;\n\ttableList_copy = strdup(tableList);\n\tfor (subTable = tableList_copy;; subTable = cp + 1) {\n\t\tfor (cp = subTable; *cp != '\\0' && *cp != ','; cp++)\n\t\t\t;\n\t\tlast = (*cp == '\\0');\n\t\t*cp = '\\0';\n\t\tif (!(tableFiles[k++] = resolveSubtable(subTable, base, searchPath))) {\n\t\t\tchar *path;\n\t\t\t_lou_logMessage(LOU_LOG_ERROR, \"Cannot resolve table '%s'\", subTable);\n\t\t\tpath = getenv(\"LOUIS_TABLEPATH\");\n\t\t\tif (path != NULL && path[0] != '\\0')\n\t\t\t\t_lou_logMessage(LOU_LOG_ERROR, \"LOUIS_TABLEPATH=%s\", path);\n\t\t\tfree(searchPath);\n\t\t\tfree(tableList_copy);\n\t\t\tfree_tablefiles(tableFiles);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (k == 1) base = subTable;\n\t\tif (last) break;\n\t}\n\tfree(searchPath);\n\tfree(tableList_copy);\n\ttableFiles[k] = NULL;\n\treturn tableFiles;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":340058,"func":"static void mem_info(Monitor *mon)\n\n{\n\n    CPUState *env;\n\n    int l1, l2, prot, last_prot;\n\n    uint32_t pgd, pde, pte, start, end;\n\n\n\n    env = mon_get_cpu();\n\n    if (!env)\n\n        return;\n\n\n\n    if (!(env->cr[0] & CR0_PG_MASK)) {\n\n        monitor_printf(mon, \"PG disabled\\n\");\n\n        return;\n\n    }\n\n    pgd = env->cr[3] & ~0xfff;\n\n    last_prot = 0;\n\n    start = -1;\n\n    for(l1 = 0; l1 < 1024; l1++) {\n\n        cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4);\n\n        pde = le32_to_cpu(pde);\n\n        end = l1 << 22;\n\n        if (pde & PG_PRESENT_MASK) {\n\n            if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {\n\n                prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);\n\n                mem_print(mon, &start, &last_prot, end, prot);\n\n            } else {\n\n                for(l2 = 0; l2 < 1024; l2++) {\n\n                    cpu_physical_memory_read((pde & ~0xfff) + l2 * 4,\n\n                                             (uint8_t *)&pte, 4);\n\n                    pte = le32_to_cpu(pte);\n\n                    end = (l1 << 22) + (l2 << 12);\n\n                    if (pte & PG_PRESENT_MASK) {\n\n                        prot = pte & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);\n\n                    } else {\n\n                        prot = 0;\n\n                    }\n\n                    mem_print(mon, &start, &last_prot, end, prot);\n\n                }\n\n            }\n\n        } else {\n\n            prot = 0;\n\n            mem_print(mon, &start, &last_prot, end, prot);\n\n        }\n\n    }\n\n}\n","target":1,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":9073,"func":"static int clone_file(const char *from, const char *to,\n                      const char **err_status, int copy_if_rename_fails) {\n    FILE *from_fp = NULL, *to_fp = NULL;\n    char buf[BUFSIZ];\n    size_t len;\n    int result = -1;\n\n    if (rename(from, to) == 0)\n        return 0;\n    if ((errno != EXDEV && errno != EBUSY) || !copy_if_rename_fails) {\n        *err_status = \"rename\";\n        return -1;\n    }\n\n    \/* rename not possible, copy file contents *\/\n    if (!(from_fp = fopen(from, \"r\"))) {\n        *err_status = \"clone_open_src\";\n        goto done;\n    }\n\n    if (!(to_fp = fopen(to, \"w\"))) {\n        *err_status = \"clone_open_dst\";\n        goto done;\n    }\n\n    if (transfer_file_attrs(from_fp, to_fp, err_status) < 0)\n        goto done;\n\n    while ((len = fread(buf, 1, BUFSIZ, from_fp)) > 0) {\n        if (fwrite(buf, 1, len, to_fp) != len) {\n            *err_status = \"clone_write\";\n            goto done;\n        }\n    }\n    if (ferror(from_fp)) {\n        *err_status = \"clone_read\";\n        goto done;\n    }\n    if (fflush(to_fp) != 0) {\n        *err_status = \"clone_flush\";\n        goto done;\n    }\n    if (fsync(fileno(to_fp)) < 0) {\n        *err_status = \"clone_sync\";\n        goto done;\n    }\n    result = 0;\n done:\n    if (from_fp != NULL)\n        fclose(from_fp);\n    if (to_fp != NULL && fclose(to_fp) != 0)\n        result = -1;\n    if (result != 0)\n        unlink(to);\n    if (result == 0)\n        unlink(from);\n    return result;\n}","target":1,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":24394,"func":"static void ATinit ( struct alltabs * at , SplineFont * sf , EncMap * map , int flags , int layer , enum fontformat format , enum bitmapformat bf , int * bsizes ) {\n at -> gi . flags = flags ;\n at -> gi . layer = layer ;\n at -> gi . is_ttf = format == ff_ttf || format == ff_ttfsym || format == ff_ttfmacbin || format == ff_ttfdfont ;\n at -> gi . sf = sf ;\n at -> applemode = ( flags & ttf_flag_applemode ) ? 1 : 0 ;\n at -> opentypemode = ( flags & ttf_flag_otmode ) ? 1 : 0 ;\n at -> msbitmaps = bsizes != NULL && at -> opentypemode ;\n at -> applebitmaps = bsizes != NULL && at -> applemode ;\n at -> gi . onlybitmaps = format == ff_none ;\n if ( bf == bf_sfnt_dfont ) {\n at -> msbitmaps = false ;\n at -> applebitmaps = true ;\n at -> opentypemode = false ;\n at -> gi . onlybitmaps = true ;\n }\n if ( bf == bf_sfnt_ms ) {\n at -> msbitmaps = true ;\n at -> applebitmaps = false ;\n at -> applemode = false ;\n at -> gi . onlybitmaps = true ;\n }\n if ( bf == bf_otb ) {\n at -> otbbitmaps = true ;\n at -> applebitmaps = at -> msbitmaps = false ;\n at -> applemode = false ;\n at -> gi . onlybitmaps = true ;\n }\n if ( bsizes != NULL && ! at -> applebitmaps && ! at -> otbbitmaps && ! at -> msbitmaps ) at -> msbitmaps = true ;\n at -> gi . bsizes = bsizes ;\n at -> gi . fixed_width = CIDOneWidth ( sf ) ;\n at -> isotf = format == ff_otf || format == ff_otfcid ;\n at -> format = format ;\n at -> next_strid = 256 ;\n if ( at -> applemode && sf -> mm != NULL && sf -> mm -> apple && ( format == ff_ttf || format == ff_ttfsym || format == ff_ttfmacbin || format == ff_ttfdfont ) && MMValid ( sf -> mm , false ) ) {\n at -> dovariations = true ;\n at -> gi . dovariations = true ;\n sf = sf -> mm -> normal ;\n }\n at -> sf = sf ;\n at -> map = map ;\n }","target":0,"code_token_length":540,"total_token_length":776,"max_tokens_setting":1024}
+{"idx":197686,"func":"gst_qtdemux_prepare_current_sample (GstQTDemux * qtdemux,\n    QtDemuxStream * stream, guint64 * offset, guint * size, guint64 * timestamp,\n    guint64 * duration, gboolean * keyframe)\n{\n  QtDemuxSample *sample;\n  guint64 time_position;\n  guint32 seg_idx;\n\n  g_return_val_if_fail (stream != NULL, FALSE);\n\n  time_position = stream->time_position;\n  if (time_position == -1)\n    goto eos;\n\n  seg_idx = stream->segment_index;\n  if (seg_idx == -1) {\n    \/* find segment corresponding to time_position if we are looking\n     * for a segment. *\/\n    seg_idx = gst_qtdemux_find_segment (qtdemux, stream, time_position);\n\n    \/* nothing found, we're really eos *\/\n    if (seg_idx == -1)\n      goto eos;\n  }\n\n  \/* different segment, activate it, sample_index will be set. *\/\n  if (stream->segment_index != seg_idx)\n    gst_qtdemux_activate_segment (qtdemux, stream, seg_idx, time_position);\n\n  GST_LOG_OBJECT (qtdemux, \"segment active, index = %u of %u\",\n      stream->sample_index, stream->n_samples);\n\n  \/* send out pending buffers *\/\n  while (stream->buffers) {\n    GstBuffer *buffer = (GstBuffer *) stream->buffers->data;\n\n    if (stream->discont) {\n      GST_LOG_OBJECT (qtdemux, \"marking discont buffer\");\n      GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);\n      stream->discont = FALSE;\n    }\n    gst_buffer_set_caps (buffer, stream->caps);\n\n    gst_pad_push (stream->pad, buffer);\n\n    stream->buffers = g_slist_delete_link (stream->buffers, stream->buffers);\n  }\n\n  if (stream->sample_index >= stream->n_samples)\n    goto eos;\n\n  \/* now get the info for the sample we're at *\/\n  sample = &stream->samples[stream->sample_index];\n\n  *timestamp = sample->timestamp + sample->pts_offset;\n  *offset = sample->offset;\n  *size = sample->size;\n  *duration = sample->duration;\n  *keyframe = stream->all_keyframe || sample->keyframe;\n\n  \/* add padding *\/\n  if (stream->padding) {\n    *offset += stream->padding;\n    *size -= stream->padding;\n  }\n\n  return TRUE;\n\n  \/* special cases *\/\neos:\n  {\n    stream->time_position = -1;\n    return FALSE;\n  }\n}\n","target":0,"code_token_length":564,"total_token_length":800,"max_tokens_setting":1024}
+{"idx":227752,"func":"void WebPagePrivate::load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, const BlackBerry::Platform::String& method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally, bool forceDownload, const BlackBerry::Platform::String& overrideContentType, const BlackBerry::Platform::String& suggestedSaveName)\n{\n    stopCurrentLoad();\n    DeferredTaskLoadManualScript::finishOrCancel(this);\n\n    String urlString(url);\n    if (urlString.startsWith(\"vs:\", false)) {\n        urlString = urlString.substring(3);\n        m_mainFrame->setInViewSourceMode(true);\n    } else\n        m_mainFrame->setInViewSourceMode(false);\n\n    KURL kurl = parseUrl(urlString);\n    if (protocolIs(kurl, \"javascript\")) {\n        if (m_page->defersLoading())\n            m_deferredTasks.append(adoptPtr(new DeferredTaskLoadManualScript(this, kurl)));\n        else\n            m_mainFrame->script()->executeIfJavaScriptURL(kurl, DoNotReplaceDocumentIfJavaScriptURL);\n        return;\n    }\n\n    if (isInitial)\n        NetworkManager::instance()->setInitialURL(kurl);\n\n    ResourceRequest request(kurl);\n    request.setToken(networkToken);\n    if (isInitial || mustHandleInternally)\n        request.setMustHandleInternally(true);\n    request.setHTTPMethod(method);\n    request.setCachePolicy(toWebCoreCachePolicy(cachePolicy));\n    if (!overrideContentType.empty())\n        request.setOverrideContentType(overrideContentType);\n\n    if (data)\n        request.setHTTPBody(FormData::create(data, dataLength));\n\n    for (unsigned i = 0; i + 1 < headersLength; i += 2)\n        request.addHTTPHeaderField(headers[i], headers[i + 1]);\n\n    if (forceDownload)\n        request.setForceDownload(true);\n\n    request.setSuggestedSaveName(suggestedSaveName);\n\n    FrameLoadRequest frameRequest(m_mainFrame, request);\n    frameRequest.setFrameName(\"\");\n    frameRequest.setShouldCheckNewWindowPolicy(true);\n    m_mainFrame->loader()->load(frameRequest);\n}\n","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":464167,"func":"nm_utils_get_reverse_dns_domains_ip_4(guint32 addr, guint8 plen, GPtrArray *domains)\n{\n    guint32 ip, ip2, mask;\n    guchar *p;\n    guint   octets;\n    guint   i;\n    gsize   len0, len;\n    char *  str, *s;\n\n    g_return_if_fail(domains);\n    g_return_if_fail(plen <= 32);\n\n    if (!plen)\n        return;\n\n    octets = (plen - 1) \/ 8 + 1;\n    ip     = ntohl(addr);\n    mask   = 0xFFFFFFFF << (32 - plen);\n    ip &= mask;\n    ip2 = ip;\n\n    len0 = NM_STRLEN(\"in-addr.arpa\") + (4 * octets) + 1;\n    while ((ip2 & mask) == ip) {\n        addr = htonl(ip2);\n        p    = (guchar *) &addr;\n\n        len = len0;\n        str = s = g_malloc(len);\n        for (i = octets; i > 0; i--)\n            nm_utils_strbuf_append(&s, &len, \"%u.\", p[i - 1] & 0xff);\n        nm_utils_strbuf_append_str(&s, &len, \"in-addr.arpa\");\n\n        g_ptr_array_add(domains, str);\n\n        ip2 += 1 << ((32 - plen) & ~7);\n    }\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":113557,"func":"void video_sample_entry_del(GF_Box *s)\n{\n\tGF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\n\tif (ptr->esd) gf_isom_box_del((GF_Box *)ptr->esd);\n\tif (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);\n\t\/*for publishing*\/\n\tif (ptr->emul_esd) gf_odf_desc_del((GF_Descriptor *)ptr->emul_esd);\n\n\tif (ptr->avc_config) gf_isom_box_del((GF_Box *) ptr->avc_config);\n\tif (ptr->svc_config) gf_isom_box_del((GF_Box *) ptr->svc_config);\n\tif (ptr->mvc_config) gf_isom_box_del((GF_Box *) ptr->mvc_config);\n\tif (ptr->hevc_config) gf_isom_box_del((GF_Box *) ptr->hevc_config);\n\tif (ptr->lhvc_config) gf_isom_box_del((GF_Box *) ptr->lhvc_config);\n\tif (ptr->av1_config) gf_isom_box_del((GF_Box *)ptr->av1_config);\n\tif (ptr->vp_config) gf_isom_box_del((GF_Box *)ptr->vp_config);\n\tif (ptr->cfg_3gpp) gf_isom_box_del((GF_Box *)ptr->cfg_3gpp);\n\n\tif (ptr->descr) gf_isom_box_del((GF_Box *) ptr->descr);\n\tif (ptr->ipod_ext) gf_isom_box_del((GF_Box *)ptr->ipod_ext);\n\n\tif (ptr->pasp) gf_isom_box_del((GF_Box *)ptr->pasp);\n\tif (ptr->clap) gf_isom_box_del((GF_Box *)ptr->clap);\n\tif (ptr->rinf) gf_isom_box_del((GF_Box *)ptr->rinf);\n\tif (ptr->ccst) gf_isom_box_del((GF_Box *)ptr->ccst);\n\n\tif (ptr->rvcc) gf_isom_box_del((GF_Box *)ptr->rvcc);\n\tif (ptr->auxi) gf_isom_box_del((GF_Box *)ptr->auxi);\n\n\tgf_free(ptr);\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":101243,"func":"perf_event_exit_event(struct perf_event *child_event,\n\t\t      struct perf_event_context *child_ctx,\n\t\t      struct task_struct *child)\n{\n\tstruct perf_event *parent_event = child_event->parent;\n\n\t\/*\n\t * Do not destroy the 'original' grouping; because of the context\n\t * switch optimization the original events could've ended up in a\n\t * random child task.\n\t *\n\t * If we were to destroy the original group, all group related\n\t * operations would cease to function properly after this random\n\t * child dies.\n\t *\n\t * Do destroy all inherited groups, we don't care about those\n\t * and being thorough is better.\n\t *\/\n\traw_spin_lock_irq(&child_ctx->lock);\n\tWARN_ON_ONCE(child_ctx->is_active);\n\n\tif (parent_event)\n\t\tperf_group_detach(child_event);\n\tlist_del_event(child_event, child_ctx);\n\tchild_event->state = PERF_EVENT_STATE_EXIT; \/* is_event_hup() *\/\n\traw_spin_unlock_irq(&child_ctx->lock);\n\n\t\/*\n\t * Parent events are governed by their filedesc, retain them.\n\t *\/\n\tif (!parent_event) {\n\t\tperf_event_wakeup(child_event);\n\t\treturn;\n\t}\n\t\/*\n\t * Child events can be cleaned up.\n\t *\/\n\n\tsync_child_event(child_event, child);\n\n\t\/*\n\t * Remove this event from the parent's list\n\t *\/\n\tWARN_ON_ONCE(parent_event->ctx->parent_ctx);\n\tmutex_lock(&parent_event->child_mutex);\n\tlist_del_init(&child_event->child_list);\n\tmutex_unlock(&parent_event->child_mutex);\n\n\t\/*\n\t * Kick perf_poll() for is_event_hup().\n\t *\/\n\tperf_event_wakeup(parent_event);\n\tfree_event(child_event);\n\tput_event(parent_event);\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":513109,"func":"void Gfx::opBeginMarkedContent(Object args[], int numArgs) {\n  \/\/ push a new stack entry\n  pushMarkedContent();\n  \n  OCGs *contentConfig = catalog->getOptContentConfig();\n  char* name0 = args[0].getName();\n  if ( strncmp( name0, \"OC\", 2) == 0 && contentConfig) {\n    if ( numArgs >= 2 ) {\n      if (!args[1].isName()) {\n\terror(getPos(), \"Unexpected MC Type: %i\", args[1].getType());\n      }\n      char* name1 = args[1].getName();\n      Object markedContent;\n      if ( res->lookupMarkedContentNF( name1, &markedContent ) ) {\n\tif ( markedContent.isRef() ) {\n\t  bool visible = contentConfig->optContentIsVisible( &markedContent );\n\t  MarkedContentStack *mc = mcStack;\n\t  mc->ocSuppressed = !(visible);\n       }\n      } else {\n\terror(getPos(), \"DID NOT find %s\", name1);\n      }\n    } else {\n      error(getPos(), \"insufficient arguments for Marked Content\");\n    }\n  }\n\n  if (printCommands) {\n    printf(\"  marked content: %s \", args[0].getName());\n    if (numArgs == 2)\n      args[1].print(stdout);\n    printf(\"\\n\");\n    fflush(stdout);\n  }\n\n  if(numArgs == 2 && args[1].isDict ()) {\n    out->beginMarkedContent(args[0].getName(),args[1].getDict());\n  } else if(numArgs == 1) {\n    out->beginMarkedContent(args[0].getName(),NULL);\n  }\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":86140,"func":"generate_code(mrb_state *mrb, parser_state *p, int val)\n{\n  codegen_scope *scope = scope_new(mrb, 0, 0);\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf jmpbuf;\n  struct RProc *proc;\n\n  mrb->jmp = &jmpbuf;\n\n  scope->mrb = mrb;\n  scope->parser = p;\n  scope->filename_sym = p->filename_sym;\n  scope->filename_index = p->current_filename_index;\n\n  MRB_TRY(mrb->jmp) {\n    \/* prepare irep *\/\n    codegen(scope, p->tree, val);\n    proc = mrb_proc_new(mrb, scope->irep);\n    mrb_irep_decref(mrb, scope->irep);\n    mrb_pool_close(scope->mpool);\n    proc->c = NULL;\n    if (mrb->c->cibase && mrb->c->cibase->proc == proc->upper) {\n      proc->upper = NULL;\n    }\n    mrb->jmp = prev_jmp;\n    return proc;\n  }\n  MRB_CATCH(mrb->jmp) {\n    mrb_irep_decref(mrb, scope->irep);\n    mrb_pool_close(scope->mpool);\n    mrb->jmp = prev_jmp;\n    return NULL;\n  }\n  MRB_END_EXC(mrb->jmp);\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":305349,"func":"\nstatic void net_tx_action(struct softirq_action *h)\n{\n\tstruct softnet_data *sd = this_cpu_ptr(&softnet_data);\n\n\tif (sd->completion_queue) {\n\t\tstruct sk_buff *clist;\n\n\t\tlocal_irq_disable();\n\t\tclist = sd->completion_queue;\n\t\tsd->completion_queue = NULL;\n\t\tlocal_irq_enable();\n\n\t\twhile (clist) {\n\t\t\tstruct sk_buff *skb = clist;\n\t\t\tclist = clist->next;\n\n\t\t\tWARN_ON(atomic_read(&skb->users));\n\t\t\tif (likely(get_kfree_skb_cb(skb)->reason == SKB_REASON_CONSUMED))\n\t\t\t\ttrace_consume_skb(skb);\n\t\t\telse\n\t\t\t\ttrace_kfree_skb(skb, net_tx_action);\n\n\t\t\tif (skb->fclone != SKB_FCLONE_UNAVAILABLE)\n\t\t\t\t__kfree_skb(skb);\n\t\t\telse\n\t\t\t\t__kfree_skb_defer(skb);\n\t\t}\n\n\t\t__kfree_skb_flush();\n\t}\n\n\tif (sd->output_queue) {\n\t\tstruct Qdisc *head;\n\n\t\tlocal_irq_disable();\n\t\thead = sd->output_queue;\n\t\tsd->output_queue = NULL;\n\t\tsd->output_queue_tailp = &sd->output_queue;\n\t\tlocal_irq_enable();\n\n\t\twhile (head) {\n\t\t\tstruct Qdisc *q = head;\n\t\t\tspinlock_t *root_lock;\n\n\t\t\thead = head->next_sched;\n\n\t\t\troot_lock = qdisc_lock(q);\n\t\t\tif (spin_trylock(root_lock)) {\n\t\t\t\tsmp_mb__before_atomic();\n\t\t\t\tclear_bit(__QDISC_STATE_SCHED,\n\t\t\t\t\t  &q->state);\n\t\t\t\tqdisc_run(q);\n\t\t\t\tspin_unlock(root_lock);\n\t\t\t} else {\n\t\t\t\tif (!test_bit(__QDISC_STATE_DEACTIVATED,\n\t\t\t\t\t      &q->state)) {\n\t\t\t\t\t__netif_reschedule(q);\n\t\t\t\t} else {\n\t\t\t\t\tsmp_mb__before_atomic();\n\t\t\t\t\tclear_bit(__QDISC_STATE_SCHED,\n\t\t\t\t\t\t  &q->state);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":496453,"func":"OperatorShellMake(const char *operatorName,\n\t\t\t\t  Oid operatorNamespace,\n\t\t\t\t  Oid leftTypeId,\n\t\t\t\t  Oid rightTypeId)\n{\n\tRelation\tpg_operator_desc;\n\tOid\t\t\toperatorObjectId;\n\tint\t\t\ti;\n\tHeapTuple\ttup;\n\tDatum\t\tvalues[Natts_pg_operator];\n\tbool\t\tnulls[Natts_pg_operator];\n\tNameData\toname;\n\tTupleDesc\ttupDesc;\n\n\t\/*\n\t * validate operator name\n\t *\/\n\tif (!validOperatorName(operatorName))\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_NAME),\n\t\t\t\t errmsg(\"\\\"%s\\\" is not a valid operator name\",\n\t\t\t\t\t\toperatorName)));\n\n\t\/*\n\t * open pg_operator\n\t *\/\n\tpg_operator_desc = table_open(OperatorRelationId, RowExclusiveLock);\n\ttupDesc = pg_operator_desc->rd_att;\n\n\t\/*\n\t * initialize our *nulls and *values arrays\n\t *\/\n\tfor (i = 0; i < Natts_pg_operator; ++i)\n\t{\n\t\tnulls[i] = false;\n\t\tvalues[i] = (Datum) NULL;\t\/* redundant, but safe *\/\n\t}\n\n\t\/*\n\t * initialize values[] with the operator name and input data types. Note\n\t * that oprcode is set to InvalidOid, indicating it's a shell.\n\t *\/\n\toperatorObjectId = GetNewOidWithIndex(pg_operator_desc, OperatorOidIndexId,\n\t\t\t\t\t\t\t\t\t\t  Anum_pg_operator_oid);\n\tvalues[Anum_pg_operator_oid - 1] = ObjectIdGetDatum(operatorObjectId);\n\tnamestrcpy(&oname, operatorName);\n\tvalues[Anum_pg_operator_oprname - 1] = NameGetDatum(&oname);\n\tvalues[Anum_pg_operator_oprnamespace - 1] = ObjectIdGetDatum(operatorNamespace);\n\tvalues[Anum_pg_operator_oprowner - 1] = ObjectIdGetDatum(GetUserId());\n\tvalues[Anum_pg_operator_oprkind - 1] = CharGetDatum(leftTypeId ? (rightTypeId ? 'b' : 'r') : 'l');\n\tvalues[Anum_pg_operator_oprcanmerge - 1] = BoolGetDatum(false);\n\tvalues[Anum_pg_operator_oprcanhash - 1] = BoolGetDatum(false);\n\tvalues[Anum_pg_operator_oprleft - 1] = ObjectIdGetDatum(leftTypeId);\n\tvalues[Anum_pg_operator_oprright - 1] = ObjectIdGetDatum(rightTypeId);\n\tvalues[Anum_pg_operator_oprresult - 1] = ObjectIdGetDatum(InvalidOid);\n\tvalues[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(InvalidOid);\n\tvalues[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(InvalidOid);\n\tvalues[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(InvalidOid);\n\tvalues[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(InvalidOid);\n\tvalues[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(InvalidOid);\n\n\t\/*\n\t * create a new operator tuple\n\t *\/\n\ttup = heap_form_tuple(tupDesc, values, nulls);\n\n\t\/*\n\t * insert our \"shell\" operator tuple\n\t *\/\n\tCatalogTupleInsert(pg_operator_desc, tup);\n\n\t\/* Add dependencies for the entry *\/\n\tmakeOperatorDependencies(tup, false);\n\n\theap_freetuple(tup);\n\n\t\/* Post creation hook for new shell operator *\/\n\tInvokeObjectPostCreateHook(OperatorRelationId, operatorObjectId, 0);\n\n\t\/*\n\t * Make sure the tuple is visible for subsequent lookups\/updates.\n\t *\/\n\tCommandCounterIncrement();\n\n\t\/*\n\t * close the operator relation and return the oid.\n\t *\/\n\ttable_close(pg_operator_desc, RowExclusiveLock);\n\n\treturn operatorObjectId;\n}","target":0,"code_token_length":784,"total_token_length":1020,"max_tokens_setting":1024}
+{"idx":42499,"func":"*\/\nint STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name)\n{\n  struct charset_info_st *cs;\n  const char *save_csdir= charsets_dir;\n\n  if (mysql->options.charset_dir)\n    charsets_dir= mysql->options.charset_dir;\n\n  if (!mysql->net.vio)\n  {\n    \/* Initialize with automatic OS character set detection. *\/\n    mysql_options(mysql, MYSQL_SET_CHARSET_NAME, cs_name);\n    mysql_init_character_set(mysql);\n    \/* \n      In case of automatic OS character set detection\n      mysql_init_character_set changes mysql->options.charset_name\n      from \"auto\" to the real character set name.\n      Reset cs_name to the detected character set name, accordingly.\n    *\/\n    cs_name= mysql->options.charset_name;\n  }\n\n  if (strlen(cs_name) < MY_CS_NAME_SIZE &&\n     (cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))))\n  {\n    char buff[MY_CS_NAME_SIZE + 10];\n    charsets_dir= save_csdir;\n    if (!mysql->net.vio)\n    {\n      \/* If there is no connection yet we don't send \"SET NAMES\" query *\/\n      mysql->charset= cs;\n      return 0;\n    }\n    \/* Skip execution of \"SET NAMES\" for pre-4.1 servers *\/\n    if (mysql_get_server_version(mysql) < 40100)\n      return 0;\n    sprintf(buff, \"SET NAMES %s\", cs_name);\n    if (!mysql_real_query(mysql, buff, (uint) strlen(buff)))\n    {\n      mysql->charset= cs;\n    }\n  }\n  else\n  {\n    char cs_dir_name[FN_REFLEN];\n    get_charsets_dir(cs_dir_name);\n    set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate,\n                             ER(CR_CANT_READ_CHARSET), cs_name, cs_dir_name);\n  }\n  charsets_dir= save_csdir;\n  return mysql->net.last_errno;","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":521426,"func":"create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort)\n{\n  TABLE *table;\n  SQL_SELECT *select;\n  bool quick_created= FALSE;\n  SORT_INFO *file_sort= 0;\n  DBUG_ENTER(\"create_sort_index\");\n\n  if (fsort == NULL)\n    fsort= tab->filesort;\n\n  table=  tab->table;\n  select= fsort->select;\n \n  table->status=0;\t\t\t\t\/\/ May be wrong if quick_select\n\n  if (!tab->preread_init_done && tab->preread_init())\n    goto err;\n\n  \/\/ If table has a range, move it to select\n  if (select && tab->ref.key >= 0)\n  {\n    if (!select->quick)\n    {\n      if (tab->quick)\n      {\n        select->quick= tab->quick;\n        tab->quick= NULL;\n      \/* \n        We can only use 'Only index' if quick key is same as ref_key\n        and in index_merge 'Only index' cannot be used\n      *\/\n      if (((uint) tab->ref.key != select->quick->index))\n        table->file->ha_end_keyread();\n      }\n      else\n      {\n        \/*\n\t  We have a ref on a const;  Change this to a range that filesort\n\t  can use.\n\t  For impossible ranges (like when doing a lookup on NULL on a NOT NULL\n\t  field, quick will contain an empty record set.\n        *\/\n        if (!(select->quick= (tab->type == JT_FT ?\n\t\t\t      get_ft_select(thd, table, tab->ref.key) :\n\t\t\t      get_quick_select_for_ref(thd, table, &tab->ref, \n                                                       tab->found_records))))\n\t  goto err;\n        quick_created= TRUE;\n      }\n      fsort->own_select= true;\n    }\n    else\n    {\n      DBUG_ASSERT(tab->type == JT_REF || tab->type == JT_EQ_REF);\n      \/\/ Update ref value\n      if ((cp_buffer_from_ref(thd, table, &tab->ref) && thd->is_fatal_error))\n        goto err;                                   \/\/ out of memory\n    }\n  }\n\n \n  \/* Fill schema tables with data before filesort if it's necessary *\/\n  if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&\n      get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))\n    goto err;\n\n  if (table->s->tmp_table)\n    table->file->info(HA_STATUS_VARIABLE);\t\/\/ Get record count\n  file_sort= filesort(thd, table, fsort, fsort->tracker, join, tab->table->map);\n  DBUG_ASSERT(tab->filesort_result == 0);\n  tab->filesort_result= file_sort;\n  tab->records= 0;\n  if (file_sort)\n  {\n    tab->records= join->select_options & OPTION_FOUND_ROWS ?\n      file_sort->found_rows : file_sort->return_rows;\n    tab->join->join_examined_rows+= file_sort->examined_rows;\n  }\n\n  if (quick_created)\n  {\n    \/* This will delete the quick select. *\/\n    select->cleanup();\n  }\n \n  table->file->ha_end_keyread();\n  if (tab->type == JT_FT)\n    table->file->ft_end();\n  else\n    table->file->ha_index_or_rnd_end();\n\n  DBUG_RETURN(file_sort == 0);\nerr:\n  DBUG_RETURN(-1);\n}","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":322281,"func":"int avio_read(AVIOContext *s, unsigned char *buf, int size)\n\n{\n\n    int len, size1;\n\n\n\n    size1 = size;\n\n    while (size > 0) {\n\n        len = FFMIN(s->buf_end - s->buf_ptr, size);\n\n        if (len == 0 || s->write_flag) {\n\n            if((s->direct || size > s->buffer_size) && !s->update_checksum) {\n\n                \/\/ bypass the buffer and read data directly into buf\n\n                if(s->read_packet)\n\n                    len = s->read_packet(s->opaque, buf, size);\n\n                else\n\n                    len = AVERROR_EOF;\n\n                if (len == AVERROR_EOF) {\n\n                    \/* do not modify buffer if EOF reached so that a seek back can\n\n                    be done without rereading data *\/\n\n                    s->eof_reached = 1;\n\n                    break;\n\n                } else if (len < 0) {\n\n                    s->eof_reached = 1;\n\n                    s->error= len;\n\n                    break;\n\n                } else {\n\n                    s->pos += len;\n\n                    s->bytes_read += len;\n\n                    size -= len;\n\n                    buf += len;\n\n                    \/\/ reset the buffer\n\n                    s->buf_ptr = s->buffer;\n\n                    s->buf_end = s->buffer\/* + len*\/;\n\n                }\n\n            } else {\n\n                fill_buffer(s);\n\n                len = s->buf_end - s->buf_ptr;\n\n                if (len == 0)\n\n                    break;\n\n            }\n\n        } else {\n\n            memcpy(buf, s->buf_ptr, len);\n\n            buf += len;\n\n            s->buf_ptr += len;\n\n            size -= len;\n\n        }\n\n    }\n\n    if (size1 == size) {\n\n        if (s->error)      return s->error;\n\n        if (avio_feof(s))  return AVERROR_EOF;\n\n    }\n\n    return size1 - size;\n\n}\n","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":207395,"func":"void LayoutBlockFlow::layoutBlockChild(LayoutBox& child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom)\n{\n    LayoutBlockFlow* childLayoutBlockFlow = child.isLayoutBlockFlow() ? toLayoutBlockFlow(&child) : nullptr;\n    LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore();\n    LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();\n\n    child.computeAndSetBlockDirectionMargins(this);\n\n    LayoutUnit estimateWithoutPagination;\n    LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo, estimateWithoutPagination);\n\n    LayoutRect oldRect = child.frameRect();\n\n    bool childNeededLayout = positionAndLayoutOnceIfNeeded(child, logicalTopEstimate, previousFloatLogicalBottom);\n\n    bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock();\n    bool childIsSelfCollapsing = child.isSelfCollapsingBlock();\n    bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child);\n    bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child);\n\n    LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childIsSelfCollapsing, childDiscardMarginBefore, childDiscardMarginAfter);\n\n    bool childDiscardMargin = childDiscardMarginBefore || childDiscardMarginAfter;\n    LayoutUnit newLogicalTop = clearFloatsIfNeeded(child, marginInfo, oldPosMarginBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsing, childDiscardMargin);\n\n    bool paginated = view()->layoutState()->isPaginated();\n    if (paginated) {\n        if (estimateWithoutPagination != newLogicalTop) {\n            positionAndLayoutOnceIfNeeded(child, newLogicalTop, previousFloatLogicalBottom);\n        }\n\n        newLogicalTop = adjustBlockChildForPagination(newLogicalTop, child, atBeforeSideOfBlock && logicalTopBeforeClear == newLogicalTop);\n    }\n\n    if (newLogicalTop != logicalTopEstimate\n        || child.needsLayout()\n        || (paginated && childLayoutBlockFlow && childLayoutBlockFlow->shouldBreakAtLineToAvoidWidow())) {\n        positionAndLayoutOnceIfNeeded(child, newLogicalTop, previousFloatLogicalBottom);\n    }\n\n    if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollapsing)\n        marginInfo.setCanCollapseMarginAfterWithLastChild(true);\n\n    if (marginInfo.atBeforeSideOfBlock() && !childIsSelfCollapsing)\n        marginInfo.setAtBeforeSideOfBlock(false);\n\n    determineLogicalLeftPositionForChild(child);\n\n    LayoutSize childOffset = child.location() - oldRect.location();\n\n    setLogicalHeight(logicalHeight() + logicalHeightForChild(child));\n    if (mustSeparateMarginAfterForChild(child)) {\n        setLogicalHeight(logicalHeight() + marginAfterForChild(child));\n        marginInfo.clearMargin();\n    }\n    if (childLayoutBlockFlow)\n        addOverhangingFloats(childLayoutBlockFlow, !childNeededLayout);\n\n    if (!selfNeedsLayout() && (childOffset.width() || childOffset.height()))\n        child.invalidatePaintForOverhangingFloats(true);\n\n    if (paginated) {\n        LayoutUnit newHeight = applyAfterBreak(child, logicalHeight(), marginInfo);\n        if (newHeight != size().height())\n            setLogicalHeight(newHeight);\n    }\n\n    if (child.isLayoutMultiColumnSpannerPlaceholder()) {\n        positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child));\n    }\n}\n","target":0,"code_token_length":734,"total_token_length":970,"max_tokens_setting":1024}
+{"idx":29715,"func":"static int com_pager ( String * buffer __attribute__ ( ( unused ) ) , char * line __attribute__ ( ( unused ) ) ) {\n char pager_name [ FN_REFLEN ] , * end , * param ;\n if ( status . batch ) return 0 ;\n while ( my_isspace ( charset_info , * line ) ) line ++ ;\n param = strchr ( line , ' ' ) ;\n while ( param && my_isspace ( charset_info , * param ) ) param ++ ;\n if ( ! param || ! strlen ( param ) ) {\n if ( ! default_pager_set ) {\n tee_fprintf ( stdout , \"Default pager wasn't set, using stdout.\\n\" ) ;\n opt_nopager = 1 ;\n strmov ( pager , \"stdout\" ) ;\n PAGER = stdout ;\n return 0 ;\n }\n strmov ( pager , default_pager ) ;\n }\n else {\n end = strmake_buf ( pager_name , param ) ;\n while ( end > pager_name && ( my_isspace ( charset_info , end [ - 1 ] ) || my_iscntrl ( charset_info , end [ - 1 ] ) ) ) end -- ;\n end [ 0 ] = 0 ;\n strmov ( pager , pager_name ) ;\n strmov ( default_pager , pager_name ) ;\n }\n opt_nopager = 0 ;\n tee_fprintf ( stdout , \"PAGER set to '%s'\\n\" , pager ) ;\n return 0 ;\n }","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":426337,"func":"DnD_CPNameListToDynBufArray(char *fileList,           \/\/ IN: CPName format\n                            size_t listSize,          \/\/ IN\n                            DynBufArray *dynBufArray) \/\/ OUT\n{\n   DynBuf buf;\n   BufRead r;\n   int32 pathLen;\n   size_t count;\n   size_t i;\n\n   ASSERT(fileList);\n   r.pos = fileList;\n   r.unreadLen = listSize;\n\n   DynBufArray_Init(dynBufArray, 0);\n\n   while (r.unreadLen > 0) {\n      DynBuf_Init(&buf);\n      if (!DnDReadBuffer(&r, &pathLen, sizeof pathLen) ||\n          (pathLen > r.unreadLen) ||\n          !DynBuf_Append(&buf, r.pos, pathLen)) {\n         goto error;\n      }\n\n      if (!DnDSlideBuffer(&r, pathLen)) {\n         goto error;\n      }\n\n      if (!DynBufArray_Push(dynBufArray, buf)) {\n         goto error;\n      }\n   }\n   return TRUE;\n\nerror:\n   DynBuf_Destroy(&buf);\n\n   count = DynBufArray_Count(dynBufArray);\n   for (i = 0; i < count; i++) {\n      DynBuf *b = DynArray_AddressOf(dynBufArray, i);\n      DynBuf_Destroy(b);\n   }\n   DynBufArray_SetCount(dynBufArray, 0);\n   DynBufArray_Destroy(dynBufArray);\n   return FALSE;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":7623,"func":"static void nsc_decode(NSC_CONTEXT* context)\n{\n\tUINT16 x;\n\tUINT16 y;\n\tUINT16 rw = ROUND_UP_TO(context->width, 8);\n\tBYTE shift = context->ColorLossLevel - 1; \/* colorloss recovery + YCoCg shift *\/\n\tBYTE* bmpdata = context->BitmapData;\n\n\tfor (y = 0; y < context->height; y++)\n\t{\n\t\tconst BYTE* yplane;\n\t\tconst BYTE* coplane;\n\t\tconst BYTE* cgplane;\n\t\tconst BYTE* aplane = context->priv->PlaneBuffers[3] + y * context->width; \/* A *\/\n\n\t\tif (context->ChromaSubsamplingLevel)\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * rw; \/* Y *\/\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>\n\t\t\t          1); \/* Co, supersampled *\/\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>\n\t\t\t          1); \/* Cg, supersampled *\/\n\t\t}\n\t\telse\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * context->width; \/* Y *\/\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + y * context->width; \/* Co *\/\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + y * context->width; \/* Cg *\/\n\t\t}\n\n\t\tfor (x = 0; x < context->width; x++)\n\t\t{\n\t\t\tINT16 y_val = (INT16) * yplane;\n\t\t\tINT16 co_val = (INT16)(INT8)(*coplane << shift);\n\t\t\tINT16 cg_val = (INT16)(INT8)(*cgplane << shift);\n\t\t\tINT16 r_val = y_val + co_val - cg_val;\n\t\t\tINT16 g_val = y_val + cg_val;\n\t\t\tINT16 b_val = y_val - co_val - cg_val;\n\t\t\t*bmpdata++ = MINMAX(b_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(g_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(r_val, 0, 0xFF);\n\t\t\t*bmpdata++ = *aplane;\n\t\t\typlane++;\n\t\t\tcoplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\tcgplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\taplane++;\n\t\t}\n\t}\n}","target":1,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":279479,"func":"attrhash_cmp (const void *p1, const void *p2)\n{\n  const struct attr * attr1 = p1;\n  const struct attr * attr2 = p2;\n\n  if (attr1->flag == attr2->flag\n      && attr1->origin == attr2->origin\n      && attr1->nexthop.s_addr == attr2->nexthop.s_addr\n      && attr1->aspath == attr2->aspath\n      && attr1->community == attr2->community\n      && attr1->med == attr2->med\n      && attr1->local_pref == attr2->local_pref)\n    {\n      const struct attr_extra *ae1 = attr1->extra;\n      const struct attr_extra *ae2 = attr2->extra;\n      \n      if (ae1 && ae2\n          && ae1->aggregator_as == ae2->aggregator_as\n          && ae1->aggregator_addr.s_addr == ae2->aggregator_addr.s_addr\n          && ae1->weight == ae2->weight\n#ifdef HAVE_IPV6\n          && ae1->mp_nexthop_len == ae2->mp_nexthop_len\n          && IPV6_ADDR_SAME (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global)\n          && IPV6_ADDR_SAME (&ae1->mp_nexthop_local, &ae2->mp_nexthop_local)\n#endif \/* HAVE_IPV6 *\/\n          && IPV4_ADDR_SAME (&ae1->mp_nexthop_global_in, &ae2->mp_nexthop_global_in)\n          && ae1->ecommunity == ae2->ecommunity\n          && ae1->cluster == ae2->cluster\n          && ae1->transit == ae2->transit)\n        return 1;\n      else if (ae1 || ae2)\n        return 0;\n      \/* neither attribute has extra attributes, so they're same *\/\n      return 1;\n    }\n  else\n    return 0;\n}\n","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":274993,"func":"TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error)\n\n{\n    char \temsg[1024] = \"\";\n    TIFFRGBAImage img;\n    int \tok;\n    uint32\trowsperstrip, rows_to_read;\n\n    if( TIFFIsTiled( tif ) )\n    {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif),\n                  \"Can't use TIFFReadRGBAStrip() with tiled file.\");\n\treturn (0);\n    }\n    \n    TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);\n    if( (row % rowsperstrip) != 0 )\n    {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif),\n\t\t\t\t\"Row passed to TIFFReadRGBAStrip() must be first in a strip.\");\n\t\treturn (0);\n    }\n\n    if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) {\n\n        img.row_offset = row;\n        img.col_offset = 0;\n\n        if( row + rowsperstrip > img.height )\n            rows_to_read = img.height - row;\n        else\n            rows_to_read = rowsperstrip;\n        \n\tok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read );\n        \n\tTIFFRGBAImageEnd(&img);\n    } else {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"%s\", emsg);\n\t\tok = 0;\n    }\n    \n    return (ok);\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":264674,"func":"group_sched_in(struct perf_event *group_event,\n\t       struct perf_cpu_context *cpuctx,\n\t       struct perf_event_context *ctx)\n{\n\tstruct perf_event *event, *partial_group = NULL;\n\tstruct pmu *pmu = group_event->pmu;\n\tu64 now = ctx->time;\n\tbool simulate = false;\n\n\tif (group_event->state == PERF_EVENT_STATE_OFF)\n\t\treturn 0;\n\n\tpmu->start_txn(pmu);\n\n\tif (event_sched_in(group_event, cpuctx, ctx)) {\n\t\tpmu->cancel_txn(pmu);\n\t\treturn -EAGAIN;\n\t}\n\n\t\/*\n\t * Schedule in siblings as one group (if any):\n\t *\/\n\tlist_for_each_entry(event, &group_event->sibling_list, group_entry) {\n\t\tif (event_sched_in(event, cpuctx, ctx)) {\n\t\t\tpartial_group = event;\n\t\t\tgoto group_error;\n\t\t}\n\t}\n\n\tif (!pmu->commit_txn(pmu))\n\t\treturn 0;\n\ngroup_error:\n\t\/*\n\t * Groups can be scheduled in as one unit only, so undo any\n\t * partial group before returning:\n\t * The events up to the failed event are scheduled out normally,\n\t * tstamp_stopped will be updated.\n\t *\n\t * The failed events and the remaining siblings need to have\n\t * their timings updated as if they had gone thru event_sched_in()\n\t * and event_sched_out(). This is required to get consistent timings\n\t * across the group. This also takes care of the case where the group\n\t * could never be scheduled by ensuring tstamp_stopped is set to mark\n\t * the time the event was actually stopped, such that time delta\n\t * calculation in update_event_times() is correct.\n\t *\/\n\tlist_for_each_entry(event, &group_event->sibling_list, group_entry) {\n\t\tif (event == partial_group)\n\t\t\tsimulate = true;\n\n\t\tif (simulate) {\n\t\t\tevent->tstamp_running += now - event->tstamp_stopped;\n\t\t\tevent->tstamp_stopped = now;\n\t\t} else {\n\t\t\tevent_sched_out(event, cpuctx, ctx);\n\t\t}\n\t}\n\tevent_sched_out(group_event, cpuctx, ctx);\n\n\tpmu->cancel_txn(pmu);\n\n\treturn -EAGAIN;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":498112,"func":"void read_coding_quadtree(thread_context* tctx,\n                          int x0, int y0,\n                          int log2CbSize,\n                          int ctDepth)\n{\n  logtrace(LogSlice,\"- read_coding_quadtree %d;%d cbsize:%d depth:%d POC:%d\\n\",x0,y0,1<<log2CbSize,ctDepth,tctx->img->PicOrderCntVal);\n\n  de265_image* img = tctx->img;\n  const seq_parameter_set& sps = img->get_sps();\n  const pic_parameter_set& pps = img->get_pps();\n\n  int split_flag;\n\n  \/\/ We only send a split flag if CU is larger than minimum size and\n  \/\/ completely contained within the image area.\n  \/\/ If it is partly outside the image area and not at minimum size,\n  \/\/ it is split. If already at minimum size, it is not split further.\n  if (x0+(1<<log2CbSize) <= sps.pic_width_in_luma_samples &&\n      y0+(1<<log2CbSize) <= sps.pic_height_in_luma_samples &&\n      log2CbSize > sps.Log2MinCbSizeY) {\n    split_flag = decode_split_cu_flag(tctx, x0,y0, ctDepth);\n  } else {\n    if (log2CbSize > sps.Log2MinCbSizeY) { split_flag=1; }\n    else                                  { split_flag=0; }\n  }\n\n\n  if (pps.cu_qp_delta_enabled_flag &&\n      log2CbSize >= pps.Log2MinCuQpDeltaSize)\n    {\n      tctx->IsCuQpDeltaCoded = 0;\n      tctx->CuQpDelta = 0;\n    }\n  else\n    {\n      \/\/ shdr->CuQpDelta = 0; \/\/ TODO check: is this the right place to set to default value ?\n    }\n\n\n  if (tctx->shdr->cu_chroma_qp_offset_enabled_flag &&\n      log2CbSize >= pps.Log2MinCuChromaQpOffsetSize) {\n    tctx->IsCuChromaQpOffsetCoded = 0;\n  }\n\n  if (split_flag) {\n    int x1 = x0 + (1<<(log2CbSize-1));\n    int y1 = y0 + (1<<(log2CbSize-1));\n\n    read_coding_quadtree(tctx,x0,y0, log2CbSize-1, ctDepth+1);\n\n    if (x1<sps.pic_width_in_luma_samples)\n      read_coding_quadtree(tctx,x1,y0, log2CbSize-1, ctDepth+1);\n\n    if (y1<sps.pic_height_in_luma_samples)\n      read_coding_quadtree(tctx,x0,y1, log2CbSize-1, ctDepth+1);\n\n    if (x1<sps.pic_width_in_luma_samples &&\n        y1<sps.pic_height_in_luma_samples)\n      read_coding_quadtree(tctx,x1,y1, log2CbSize-1, ctDepth+1);\n  }\n  else {\n    \/\/ set ctDepth of this CU\n\n    img->set_ctDepth(x0,y0, log2CbSize, ctDepth);\n\n    read_coding_unit(tctx, x0,y0, log2CbSize, ctDepth);\n  }\n\n  logtrace(LogSlice,\"-\\n\");\n}","target":0,"code_token_length":729,"total_token_length":965,"max_tokens_setting":1024}
+{"idx":118159,"func":"int ssl3_get_next_proto(SSL *s)\n\t{\n\tint ok;\n\tint proto_len, padding_len;\n\tlong n;\n\tconst unsigned char *p;\n\n\t\/* Clients cannot send a NextProtocol message if we didn't see the\n\t * extension in their ClientHello *\/\n\tif (!s->s3->next_proto_neg_seen)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_NEXT_PROTO,SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION);\n\t\treturn -1;\n\t\t}\n\n\tn=s->method->ssl_get_message(s,\n\t\tSSL3_ST_SR_NEXT_PROTO_A,\n\t\tSSL3_ST_SR_NEXT_PROTO_B,\n\t\tSSL3_MT_NEXT_PROTO,\n\t\t514,  \/* See the payload format below *\/\n\t\t&ok);\n\n\tif (!ok)\n\t\treturn((int)n);\n\n\t\/* s->state doesn't reflect whether ChangeCipherSpec has been received\n\t * in this handshake, but s->s3->change_cipher_spec does (will be reset\n\t * by ssl3_get_finished). *\/\n\tif (!s->s3->change_cipher_spec)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_NEXT_PROTO,SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS);\n\t\treturn -1;\n\t\t}\n\n\tif (n < 2)\n\t\treturn 0;  \/* The body must be > 1 bytes long *\/\n\n\tp=(unsigned char *)s->init_msg;\n\n\t\/*-\n\t * The payload looks like:\n\t *   uint8 proto_len;\n\t *   uint8 proto[proto_len];\n\t *   uint8 padding_len;\n\t *   uint8 padding[padding_len];\n\t *\/\n\tproto_len = p[0];\n\tif (proto_len + 2 > s->init_num)\n\t\treturn 0;\n\tpadding_len = p[proto_len + 1];\n\tif (proto_len + padding_len + 2 != s->init_num)\n\t\treturn 0;\n\n\ts->next_proto_negotiated = OPENSSL_malloc(proto_len);\n\tif (!s->next_proto_negotiated)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_NEXT_PROTO,ERR_R_MALLOC_FAILURE);\n\t\treturn 0;\n\t\t}\n\tmemcpy(s->next_proto_negotiated, p + 1, proto_len);\n\ts->next_proto_negotiated_len = proto_len;\n\n\treturn 1;\n\t}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":498952,"func":"static int esilbreak_reg_write(RzAnalysisEsil *esil, const char *name, ut64 *val) {\n\tif (!esil) {\n\t\treturn 0;\n\t}\n\tRzAnalysis *analysis = esil->analysis;\n\tEsilBreakCtx *ctx = esil->user;\n\tRzAnalysisOp *op = ctx->op;\n\tRzCore *core = analysis->coreb.core;\n\thandle_var_stack_access(esil, *val, RZ_ANALYSIS_VAR_ACCESS_TYPE_PTR, esil->analysis->bits \/ 8);\n\t\/\/specific case to handle blx\/bx cases in arm through emulation\n\t\/\/ XXX this thing creates a lot of false positives\n\tut64 at = *val;\n\tif (analysis && analysis->opt.armthumb) {\n\t\tif (analysis->cur && analysis->cur->arch && analysis->bits < 33 &&\n\t\t\tstrstr(analysis->cur->arch, \"arm\") && !strcmp(name, \"pc\") && op) {\n\t\t\tswitch (op->type) {\n\t\t\tcase RZ_ANALYSIS_OP_TYPE_RCALL: \/\/ BLX\n\t\t\tcase RZ_ANALYSIS_OP_TYPE_RJMP: \/\/ BX\n\t\t\t\t\/\/ maybe UJMP\/UCALL is enough here\n\t\t\t\tif (!(*val & 1)) {\n\t\t\t\t\trz_analysis_hint_set_bits(analysis, *val, 32);\n\t\t\t\t} else {\n\t\t\t\t\tut64 snv = rz_reg_getv(analysis->reg, \"pc\");\n\t\t\t\t\tif (snv != UT32_MAX && snv != UT64_MAX) {\n\t\t\t\t\t\tif (rz_io_is_valid_offset(analysis->iob.io, *val, 1)) {\n\t\t\t\t\t\t\trz_analysis_hint_set_bits(analysis, *val - 1, 16);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (core->rasm->bits == 32 && strstr(core->rasm->cur->name, \"arm\")) {\n\t\tif ((!(at & 1)) && rz_io_is_valid_offset(analysis->iob.io, at, 0)) { \/\/  !core->analysis->opt.noncode)) {\n\t\t\tadd_string_ref(analysis->coreb.core, esil->address, at);\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":498,"total_token_length":734,"max_tokens_setting":1024}
+{"idx":509636,"func":"static void test_bug3796()\n{\n  MYSQL_STMT *stmt;\n  MYSQL_BIND my_bind[1];\n  const char *concat_arg0= \"concat_with_\";\n  enum { OUT_BUFF_SIZE= 30 };\n  char out_buff[OUT_BUFF_SIZE];\n  char canonical_buff[OUT_BUFF_SIZE];\n  ulong out_length;\n  const char *stmt_text;\n  int rc;\n\n  myheader(\"test_bug3796\");\n\n  \/* Create and fill test table *\/\n  stmt_text= \"DROP TABLE IF EXISTS t1\";\n  rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));\n  myquery(rc);\n\n  stmt_text= \"CREATE TABLE t1 (a INT, b VARCHAR(30))\";\n  rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));\n  myquery(rc);\n\n  stmt_text= \"INSERT INTO t1 VALUES(1, 'ONE'), (2, 'TWO')\";\n  rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));\n  myquery(rc);\n\n  \/* Create statement handle and prepare it with select *\/\n  stmt= mysql_stmt_init(mysql);\n  stmt_text= \"SELECT concat(?, b) FROM t1\";\n\n  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));\n  check_execute(stmt, rc);\n\n  \/* Bind input buffers *\/\n  bzero((char*) my_bind, sizeof(my_bind));\n\n  my_bind[0].buffer_type= MYSQL_TYPE_STRING;\n  my_bind[0].buffer= (void *) concat_arg0;\n  my_bind[0].buffer_length= strlen(concat_arg0);\n\n  mysql_stmt_bind_param(stmt, my_bind);\n\n  \/* Execute the select statement *\/\n  rc= mysql_stmt_execute(stmt);\n  check_execute(stmt, rc);\n\n  my_bind[0].buffer= (void *) out_buff;\n  my_bind[0].buffer_length= OUT_BUFF_SIZE;\n  my_bind[0].length= &out_length;\n\n  mysql_stmt_bind_result(stmt, my_bind);\n\n  rc= mysql_stmt_fetch(stmt);\n  if (!opt_silent)\n    printf(\"Concat result: '%s'\\n\", out_buff);\n  check_execute(stmt, rc);\n  strmov(canonical_buff, concat_arg0);\n  strcat(canonical_buff, \"ONE\");\n  DIE_UNLESS(strlen(canonical_buff) == out_length &&\n         strncmp(out_buff, canonical_buff, out_length) == 0);\n\n  rc= mysql_stmt_fetch(stmt);\n  check_execute(stmt, rc);\n  strmov(canonical_buff + strlen(concat_arg0), \"TWO\");\n  DIE_UNLESS(strlen(canonical_buff) == out_length &&\n         strncmp(out_buff, canonical_buff, out_length) == 0);\n  if (!opt_silent)\n    printf(\"Concat result: '%s'\\n\", out_buff);\n\n  rc= mysql_stmt_fetch(stmt);\n  DIE_UNLESS(rc == MYSQL_NO_DATA);\n\n  mysql_stmt_close(stmt);\n\n  stmt_text= \"DROP TABLE IF EXISTS t1\";\n  rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));\n  myquery(rc);\n}","target":0,"code_token_length":635,"total_token_length":871,"max_tokens_setting":1024}
+{"idx":340547,"func":"int page_unprotect(target_ulong address, unsigned long pc, void *puc)\n\n{\n\n    unsigned int page_index, prot, pindex;\n\n    PageDesc *p, *p1;\n\n    target_ulong host_start, host_end, addr;\n\n\n\n    \/* Technically this isn't safe inside a signal handler.  However we\n\n       know this only ever happens in a synchronous SEGV handler, so in\n\n       practice it seems to be ok.  *\/\n\n    mmap_lock();\n\n\n\n    host_start = address & qemu_host_page_mask;\n\n    page_index = host_start >> TARGET_PAGE_BITS;\n\n    p1 = page_find(page_index);\n\n    if (!p1) {\n\n        mmap_unlock();\n\n        return 0;\n\n    }\n\n    host_end = host_start + qemu_host_page_size;\n\n    p = p1;\n\n    prot = 0;\n\n    for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {\n\n        prot |= p->flags;\n\n        p++;\n\n    }\n\n    \/* if the page was really writable, then we change its\n\n       protection back to writable *\/\n\n    if (prot & PAGE_WRITE_ORG) {\n\n        pindex = (address - host_start) >> TARGET_PAGE_BITS;\n\n        if (!(p1[pindex].flags & PAGE_WRITE)) {\n\n            mprotect((void *)g2h(host_start), qemu_host_page_size,\n\n                     (prot & PAGE_BITS) | PAGE_WRITE);\n\n            p1[pindex].flags |= PAGE_WRITE;\n\n            \/* and since the content will be modified, we must invalidate\n\n               the corresponding translated code. *\/\n\n            tb_invalidate_phys_page(address, pc, puc);\n\n#ifdef DEBUG_TB_CHECK\n\n            tb_invalidate_check(address);\n\n#endif\n\n            mmap_unlock();\n\n            return 1;\n\n        }\n\n    }\n\n    mmap_unlock();\n\n    return 0;\n\n}\n","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":105711,"func":"static ssize_t yurex_write(struct file *file, const char __user *user_buffer,\n\t\t\t   size_t count, loff_t *ppos)\n{\n\tstruct usb_yurex *dev;\n\tint i, set = 0, retval = 0;\n\tchar buffer[16];\n\tchar *data = buffer;\n\tunsigned long long c, c2 = 0;\n\tsigned long timeout = 0;\n\tDEFINE_WAIT(wait);\n\n\tcount = min(sizeof(buffer), count);\n\tdev = file->private_data;\n\n\t\/* verify that we actually have some data to write *\/\n\tif (count == 0)\n\t\tgoto error;\n\n\tmutex_lock(&dev->io_mutex);\n\tif (!dev->interface) {\t\t\/* already disconnected *\/\n\t\tmutex_unlock(&dev->io_mutex);\n\t\tretval = -ENODEV;\n\t\tgoto error;\n\t}\n\n\tif (copy_from_user(buffer, user_buffer, count)) {\n\t\tmutex_unlock(&dev->io_mutex);\n\t\tretval = -EFAULT;\n\t\tgoto error;\n\t}\n\tmemset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE);\n\n\tswitch (buffer[0]) {\n\tcase CMD_ANIMATE:\n\tcase CMD_LED:\n\t\tdev->cntl_buffer[0] = buffer[0];\n\t\tdev->cntl_buffer[1] = buffer[1];\n\t\tdev->cntl_buffer[2] = CMD_EOF;\n\t\tbreak;\n\tcase CMD_READ:\n\tcase CMD_VERSION:\n\t\tdev->cntl_buffer[0] = buffer[0];\n\t\tdev->cntl_buffer[1] = 0x00;\n\t\tdev->cntl_buffer[2] = CMD_EOF;\n\t\tbreak;\n\tcase CMD_SET:\n\t\tdata++;\n\t\t\/* FALL THROUGH *\/\n\tcase '0' ... '9':\n\t\tset = 1;\n\t\tc = c2 = simple_strtoull(data, NULL, 0);\n\t\tdev->cntl_buffer[0] = CMD_SET;\n\t\tfor (i = 1; i < 6; i++) {\n\t\t\tdev->cntl_buffer[i] = (c>>32) & 0xff;\n\t\t\tc <<= 8;\n\t\t}\n\t\tbuffer[6] = CMD_EOF;\n\t\tbreak;\n\tdefault:\n\t\tmutex_unlock(&dev->io_mutex);\n\t\treturn -EINVAL;\n\t}\n\n\t\/* send the data as the control msg *\/\n\tprepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);\n\tdev_dbg(&dev->interface->dev, \"%s - submit %c\\n\", __func__,\n\t\tdev->cntl_buffer[0]);\n\tretval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);\n\tif (retval >= 0)\n\t\ttimeout = schedule_timeout(YUREX_WRITE_TIMEOUT);\n\tfinish_wait(&dev->waitq, &wait);\n\n\tmutex_unlock(&dev->io_mutex);\n\n\tif (retval < 0) {\n\t\tdev_err(&dev->interface->dev,\n\t\t\t\"%s - failed to send bulk msg, error %d\\n\",\n\t\t\t__func__, retval);\n\t\tgoto error;\n\t}\n\tif (set && timeout)\n\t\tdev->bbu = c2;\n\treturn timeout ? count : -EIO;\n\nerror:\n\treturn retval;\n}","target":0,"code_token_length":644,"total_token_length":880,"max_tokens_setting":1024}
+{"idx":344495,"func":"_fr_window_ask_overwrite_dialog (OverwriteData *odata)\n{\n\tif ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL)) {\n\t\tconst char *base_name;\n\t\tGFile      *destination;\n\n\t\tbase_name = _g_path_get_relative_basename ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths);\n\t\tdestination = g_file_get_child (odata->edata->destination, base_name);\n\t\tg_file_query_info_async (destination,\n\t\t\t\t\t G_FILE_ATTRIBUTE_STANDARD_TYPE \",\" G_FILE_ATTRIBUTE_STANDARD_NAME \",\" G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,\n\t\t\t\t\t G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,\n\t\t\t\t\t G_PRIORITY_DEFAULT,\n\t\t\t\t\t odata->window->priv->cancellable,\n\t\t\t\t\t query_info_ready_for_overwrite_dialog_cb,\n\t\t\t\t\t odata);\n\n\t\tg_object_unref (destination);\n\n\t\treturn;\n\t}\n\n\tif (odata->edata->file_list != NULL) {\n\t\t\/* speed optimization: passing NULL when extracting all the\n\t\t * files is faster if the command supports the\n\t\t * propCanExtractAll property. *\/\n\t\tif (odata->extract_all) {\n\t\t\t_g_string_list_free (odata->edata->file_list);\n\t\t\todata->edata->file_list = NULL;\n\t\t}\n\t\todata->edata->overwrite = FR_OVERWRITE_YES;\n\t\t_fr_window_archive_extract_from_edata (odata->window, odata->edata);\n\t}\n\telse {\n\t\tGtkWidget *d;\n\n\t\td = _gtk_message_dialog_new (GTK_WINDOW (odata->window),\n\t\t\t\t\t     0,\n\t\t\t\t\t     GTK_STOCK_DIALOG_WARNING,\n\t\t\t\t\t     _(\"Extraction not performed\"),\n\t\t\t\t\t     NULL,\n\t\t\t\t\t     GTK_STOCK_OK, GTK_RESPONSE_OK,\n\t\t\t\t\t     NULL);\n\t\tgtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK);\n\t\tfr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window), _(\"Extraction not performed\"));\n\n\t\tfr_window_stop_batch (odata->window);\n\t}\n\n\tg_free (odata);\n}","target":1,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":74803,"func":"static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,\n\n                                        int dstWidth, const uint8_t *src1,\n\n                                        const uint8_t *src2, int srcW, int xInc)\n\n{\n\n    int32_t *filterPos = c->hChrFilterPos;\n\n    int16_t *filter    = c->hChrFilter;\n\n    void    *mmx2FilterCode= c->chrMmx2FilterCode;\n\n    int i;\n\n#if defined(PIC)\n\n    DECLARE_ALIGNED(8, uint64_t, ebxsave);\n\n#endif\n\n\n\n    __asm__ volatile(\n\n#if defined(PIC)\n\n        \"mov          %%\"REG_b\", %7         \\n\\t\"\n\n#endif\n\n        \"pxor             %%mm7, %%mm7      \\n\\t\"\n\n        \"mov                 %0, %%\"REG_c\"  \\n\\t\"\n\n        \"mov                 %1, %%\"REG_D\"  \\n\\t\"\n\n        \"mov                 %2, %%\"REG_d\"  \\n\\t\"\n\n        \"mov                 %3, %%\"REG_b\"  \\n\\t\"\n\n        \"xor          %%\"REG_a\", %%\"REG_a\"  \\n\\t\" \/\/ i\n\n        PREFETCH\"   (%%\"REG_c\")             \\n\\t\"\n\n        PREFETCH\" 32(%%\"REG_c\")             \\n\\t\"\n\n        PREFETCH\" 64(%%\"REG_c\")             \\n\\t\"\n\n\n\n        CALL_MMX2_FILTER_CODE\n\n        CALL_MMX2_FILTER_CODE\n\n        CALL_MMX2_FILTER_CODE\n\n        CALL_MMX2_FILTER_CODE\n\n        \"xor          %%\"REG_a\", %%\"REG_a\"  \\n\\t\" \/\/ i\n\n        \"mov                 %5, %%\"REG_c\"  \\n\\t\" \/\/ src\n\n        \"mov                 %6, %%\"REG_D\"  \\n\\t\" \/\/ buf2\n\n        PREFETCH\"   (%%\"REG_c\")             \\n\\t\"\n\n        PREFETCH\" 32(%%\"REG_c\")             \\n\\t\"\n\n        PREFETCH\" 64(%%\"REG_c\")             \\n\\t\"\n\n\n\n        CALL_MMX2_FILTER_CODE\n\n        CALL_MMX2_FILTER_CODE\n\n        CALL_MMX2_FILTER_CODE\n\n        CALL_MMX2_FILTER_CODE\n\n\n\n#if defined(PIC)\n\n        \"mov %7, %%\"REG_b\"    \\n\\t\"\n\n#endif\n\n        :: \"m\" (src1), \"m\" (dst1), \"m\" (filter), \"m\" (filterPos),\n\n           \"m\" (mmx2FilterCode), \"m\" (src2), \"m\"(dst2)\n\n#if defined(PIC)\n\n          ,\"m\" (ebxsave)\n\n#endif\n\n        : \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n\n#if !defined(PIC)\n\n         ,\"%\"REG_b\n\n#endif\n\n    );\n\n\n\n    for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {\n\n        dst1[i] = src1[srcW-1]*128;\n\n        dst2[i] = src2[srcW-1]*128;\n\n    }\n\n}\n","target":0,"code_token_length":699,"total_token_length":935,"max_tokens_setting":1024}
+{"idx":347158,"func":"static bool fbo_check_config(const char *cfgstring, char **reason)\n{\n\tchar *options;\n\tchar *path;\n\tint fd;\n\n\ttcmu_dbg(\"check: cfgstring %s\\n\", cfgstring);\n\toptions = strchr(cfgstring, '\/');\n\tif (!options) {\n\t\tif (asprintf(reason, \"Invalid cfgstring\") == -1)\n\t\t\t*reason = NULL;\n\t\treturn false;\n\t}\n\toptions += 1; \/* get past '\/' *\/\n\twhile (options[0] != '\/') {\n\t\tif (strncasecmp(options, \"ro\/\", 3)) {\n\t\t\tif (asprintf(reason, \"Unknown option %s\\n\",\n\t\t\t\t     options) == -1)\n\t\t\t\t*reason = NULL;\n\t\t\treturn false;\n\t\t}\n\n\t\toptions = strchr(options, '\/');\n\t\tif (!options) {\n\t\t\tif (asprintf(reason, \"Invalid cfgstring\") == -1)\n\t\t\t\t*reason = NULL;\n\t\t\treturn false;\n\t\t}\n\t\toptions += 1;\n\t}\n\n\tpath = options;\n\tif (!path) {\n\t\tif (asprintf(reason, \"No path found\") == -1)\n\t\t\t*reason = NULL;\n\t\treturn false;\n\t}\n\n\tif (access(path, R_OK) != -1)\n\t\treturn true; \/* File exists *\/\n\n\t\/* We also support creating the file, so see if we can create it *\/\n\t\/* NB: If we're creating it, then we'll need write permission *\/\n\tfd = creat(path, S_IRUSR | S_IWUSR);\n\tif (fd == -1) {\n\t\tif (asprintf(reason, \"Could not create file\") == -1)\n\t\t\t*reason = NULL;\n\t\treturn false;\n\t}\n\n\tunlink(path);\n\n\treturn true;\n}","target":1,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":15274,"func":"static subpicture_t * spu_new_buffer ( decoder_t * p_dec , const subpicture_updater_t * p_updater ) {\n decoder_owner_sys_t * p_owner = p_dec -> p_owner ;\n vout_thread_t * p_vout = NULL ;\n subpicture_t * p_subpic ;\n int i_attempts = 30 ;\n while ( i_attempts -- ) {\n if ( DecoderIsExitRequested ( p_dec ) || p_dec -> b_error ) break ;\n p_vout = input_resource_HoldVout ( p_owner -> p_resource ) ;\n if ( p_vout ) break ;\n msleep ( DECODER_SPU_VOUT_WAIT_DURATION ) ;\n }\n if ( ! p_vout ) {\n msg_Warn ( p_dec , \"no vout found, dropping subpicture\" ) ;\n return NULL ;\n }\n if ( p_owner -> p_spu_vout != p_vout ) {\n p_owner -> i_spu_channel = vout_RegisterSubpictureChannel ( p_vout ) ;\n p_owner -> i_spu_order = 0 ;\n p_owner -> p_spu_vout = p_vout ;\n }\n p_subpic = subpicture_New ( p_updater ) ;\n if ( p_subpic ) {\n p_subpic -> i_channel = p_owner -> i_spu_channel ;\n p_subpic -> i_order = p_owner -> i_spu_order ++ ;\n p_subpic -> b_subtitle = true ;\n }\n vlc_object_release ( p_vout ) ;\n return p_subpic ;\n }","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":100946,"func":"static void cmd_anal_class_method(RCore *core, const char *input) {\n\tRAnalClassErr err = R_ANAL_CLASS_ERR_SUCCESS;\n\tchar c = input[0];\n\tswitch (c) {\n\tcase ' ': \/\/ \"acm\"\n\tcase '-': \/\/ \"acm-\"\n\tcase 'n': { \/\/ \"acmn\"\n\t\tconst char *str = r_str_trim_head_ro (input + 1);\n\t\tif (!*str) {\n\t\t\teprintf (\"No class name given.\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tchar *cstr = strdup (str);\n\t\tif (!cstr) {\n\t\t\tbreak;\n\t\t}\n\t\tchar *end = strchr (cstr, ' ');\n\t\tif (!end) {\n\t\t\teprintf (\"No method name given.\\n\");\n\t\t\tfree (cstr);\n\t\t\tbreak;\n\t\t}\n\t\t*end = '\\0';\n\t\tchar *name_str = end + 1;\n\n\t\tif (c == ' ' || c == 'n') {\n\t\t\tend = strchr (name_str, ' ');\n\t\t\tif (!end) {\n\t\t\t\tif (c == ' ') {\n\t\t\t\t\teprintf (\"No offset given.\\n\");\n\t\t\t\t} else if (c == 'n') {\n\t\t\t\t\teprintf (\"No new method name given.\\n\");\n\t\t\t\t}\n\t\t\t\tfree (cstr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t*end = '\\0';\n\t\t}\n\n\t\tif (c == ' ') {\n\t\t\tchar *addr_str = end + 1;\n\t\t\tend = strchr (addr_str, ' ');\n\t\t\tif (end) {\n\t\t\t\t*end = '\\0';\n\t\t\t}\n\n\t\t\tRAnalMethod meth;\n\t\t\tmeth.name = name_str;\n\t\t\tmeth.addr = r_num_get (core->num, addr_str);\n\t\t\tmeth.vtable_offset = -1;\n\t\t\tif (end) {\n\t\t\t\tmeth.vtable_offset = (int)r_num_get (core->num, end + 1);\n\t\t\t}\n\t\t\terr = r_anal_class_method_set (core->anal, cstr, &meth);\n\t\t} else if (c == 'n') {\n\t\t\tchar *new_name_str = end + 1;\n\t\t\tend = strchr (new_name_str, ' ');\n\t\t\tif (end) {\n\t\t\t\t*end = '\\0';\n\t\t\t}\n\n\t\t\terr = r_anal_class_method_rename (core->anal, cstr, name_str, new_name_str);\n\t\t} else if (c == '-') {\n\t\t\terr = r_anal_class_method_delete (core->anal, cstr, name_str);\n\t\t}\n\n\t\tfree (cstr);\n\t\tbreak;\n\t}\n\tdefault:\n\t\tr_core_cmd_help (core, help_msg_ac);\n\t\tbreak;\n\t}\n\n\tswitch (err) {\n\t\tcase R_ANAL_CLASS_ERR_NONEXISTENT_CLASS:\n\t\t\teprintf (\"Class does not exist.\\n\");\n\t\t\tbreak;\n\t\tcase R_ANAL_CLASS_ERR_NONEXISTENT_ATTR:\n\t\t\teprintf (\"Method does not exist.\\n\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}","target":0,"code_token_length":631,"total_token_length":867,"max_tokens_setting":1024}
+{"idx":210654,"func":"LayoutUnit LayoutBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& marginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos, bool childIsSelfCollapsing, bool childDiscardMargin)\n{\n    LayoutUnit heightIncrease = getClearDelta(&child, yPos);\n    marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(false);\n\n    if (!heightIncrease)\n        return yPos;\n\n    if (childIsSelfCollapsing) {\n        marginInfo.setLastChildIsSelfCollapsingBlockWithClearance(true);\n        marginInfo.setDiscardMargin(childDiscardMargin);\n\n        LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child);\n        if (!childDiscardMargin) {\n            marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBefore(), childMargins.positiveMarginAfter()));\n            marginInfo.setNegativeMargin(std::max(childMargins.negativeMarginBefore(), childMargins.negativeMarginAfter()));\n        } else {\n            marginInfo.clearMargin();\n        }\n\n        marginInfo.setCanCollapseMarginAfterWithLastChild(false);\n\n        setLogicalHeight(child.logicalTop() + childMargins.negativeMarginBefore());\n    } else {\n        setLogicalHeight(logicalHeight() + heightIncrease);\n    }\n\n    if (marginInfo.canCollapseWithMarginBefore()) {\n        setMaxMarginBeforeValues(oldTopPosMargin, oldTopNegMargin);\n        marginInfo.setAtBeforeSideOfBlock(false);\n\n        setMustDiscardMarginBefore(style()->marginBeforeCollapse() == MDISCARD);\n    }\n\n    return yPos + heightIncrease;\n}\n","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":394911,"func":"static void network_init_gcrypt (void) \/* {{{ *\/\n{\n  gcry_error_t err;\n\n  \/* http:\/\/lists.gnupg.org\/pipermail\/gcrypt-devel\/2003-August\/000458.html\n   * Because you can't know in a library whether another library has\n   * already initialized the library *\/\n  if (gcry_control (GCRYCTL_ANY_INITIALIZATION_P))\n    return;\n\n \/* http:\/\/www.gnupg.org\/documentation\/manuals\/gcrypt\/Multi_002dThreading.html\n  * To ensure thread-safety, it's important to set GCRYCTL_SET_THREAD_CBS\n  * *before* initalizing Libgcrypt with gcry_check_version(), which itself must\n  * be called before any other gcry_* function. GCRYCTL_ANY_INITIALIZATION_P\n  * above doesn't count, as it doesn't implicitly initalize Libgcrypt.\n  *\n  * tl;dr: keep all these gry_* statements in this exact order please. *\/\n# if GCRYPT_VERSION_NUMBER < 0x010600\n  err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);\n  if (err)\n  {\n    ERROR (\"network plugin: gcry_control (GCRYCTL_SET_THREAD_CBS) failed: %s\", gcry_strerror (err));\n    abort ();\n  }\n# endif\n\n  gcry_check_version (NULL);\n\n  err = gcry_control (GCRYCTL_INIT_SECMEM, 32768);\n  if (err)\n  {\n    ERROR (\"network plugin: gcry_control (GCRYCTL_SET_THREAD_CBS) failed: %s\", gcry_strerror (err));\n    abort ();\n  }\n\n  gcry_control (GCRYCTL_INITIALIZATION_FINISHED);\n} \/* }}} void network_init_gcrypt *\/","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":283120,"func":"const BlockEntry* Cluster::GetEntry(const Track* pTrack,\n long long time_ns) const {\n  assert(pTrack);\n\n\n   if (m_pSegment == NULL)  \/\/ this is the special EOS cluster\n     return pTrack->GetEOS();\n \n   const BlockEntry* pResult = pTrack->GetEOS();\n \n   long index = 0;\n\n for (;;) {\n if (index >= m_entries_count) {\n long long pos;\n long len;\n\n const long status = Parse(pos, len);\n      assert(status >= 0);\n\n if (status > 0) \/\/ completely parsed, and no more entries\n return pResult;\n\n if (status < 0) \/\/ should never happen\n return 0;\n\n      assert(m_entries);\n      assert(index < m_entries_count);\n }\n\n const BlockEntry* const pEntry = m_entries[index];\n    assert(pEntry);\n    assert(!pEntry->EOS());\n\n const Block* const pBlock = pEntry->GetBlock();\n    assert(pBlock);\n\n if (pBlock->GetTrackNumber() != pTrack->GetNumber()) {\n ++index;\n continue;\n }\n\n if (pTrack->VetEntry(pEntry)) {\n if (time_ns < 0) \/\/ just want first candidate block\n return pEntry;\n\n const long long ns = pBlock->GetTime(this);\n\n if (ns > time_ns)\n return pResult;\n\n      pResult = pEntry; \/\/ have a candidate\n } else if (time_ns >= 0) {\n const long long ns = pBlock->GetTime(this);\n\n if (ns > time_ns)\n return pResult;\n }\n\n \n     ++index;\n   }\n }\n","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":13821,"func":"void ProfileSyncService::OnExperimentsChanged(\n    const browser_sync::Experiments& experiments) {\n  if (current_experiments.Matches(experiments))\n    return;\n\n  if (migrator_.get() &&\n      migrator_->state() != browser_sync::BackendMigrator::IDLE) {\n    DVLOG(1) << \"Dropping OnExperimentsChanged due to migrator busy.\";\n    return;\n  }\n \n   const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes();\n   syncable::ModelTypeSet to_add;\n  if (experiments.sync_tabs)\n    to_add.Put(syncable::SESSIONS);\n   const syncable::ModelTypeSet to_register =\n       Difference(to_add, registered_types);\n   DVLOG(2) << \"OnExperimentsChanged called with types: \"\n           << syncable::ModelTypeSetToString(to_add);\n  DVLOG(2) << \"Enabling types: \" << syncable::ModelTypeSetToString(to_register);\n\n  for (syncable::ModelTypeSet::Iterator it = to_register.First();\n       it.Good(); it.Inc()) {\n    RegisterNewDataType(it.Get());\n#if !defined(OS_ANDROID)\n    std::string experiment_name = GetExperimentNameForDataType(it.Get());\n    if (experiment_name.empty())\n      continue;\n    about_flags::SetExperimentEnabled(g_browser_process->local_state(),\n                                      experiment_name,\n                                      true);\n#endif  \/\/ !defined(OS_ANDROID)\n  }\n\n  if (sync_prefs_.HasKeepEverythingSynced()) {\n    sync_prefs_.SetPreferredDataTypes(registered_types, registered_types);\n\n    if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) {\n      DVLOG(1) << \"Dynamically enabling new datatypes: \"\n               << syncable::ModelTypeSetToString(to_register);\n      OnMigrationNeededForTypes(to_register);\n    }\n  }\n\n  if (experiments.sync_tab_favicons) {\n    DVLOG(1) << \"Enabling syncing of tab favicons.\";\n    about_flags::SetExperimentEnabled(g_browser_process->local_state(),\n                                      \"sync-tab-favicons\",\n                                      true);\n  }\n\n  current_experiments = experiments;\n}\n","target":1,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":119699,"func":"static int mailimf_unstructured_parse(const char * message, size_t length,\n\t\t\t\t      size_t * indx, char ** result)\n{\n  size_t cur_token;\n  int state;\n  size_t begin;\n  size_t terminal;\n  char * str;\n\n  cur_token = * indx;\n\n\n  while (1) {\n    int r;\n\n    r = mailimf_wsp_parse(message, length, &cur_token);\n    if (r == MAILIMF_NO_ERROR) {\n      \/* do nothing *\/\n    }\n    else if (r == MAILIMF_ERROR_PARSE)\n      break;\n    else {\n      return r;\n    }\n  }\n\n  state = UNSTRUCTURED_START;\n  begin = cur_token;\n  terminal = cur_token;\n\n  while (state != UNSTRUCTURED_OUT) {\n\n    switch(state) {\n    case UNSTRUCTURED_START:\n      if (cur_token >= length)\n\treturn MAILIMF_ERROR_PARSE;\n\n      terminal = cur_token;\n      switch(message[cur_token]) {\n      case '\\r':\n\tstate = UNSTRUCTURED_CR;\n\tbreak;\n      case '\\n':\n\tstate = UNSTRUCTURED_LF;\n\tbreak;\n      default:\n\tstate = UNSTRUCTURED_START;\n\tbreak;\n      }\n      break;\n    case UNSTRUCTURED_CR:\n      if (cur_token >= length)\n\treturn MAILIMF_ERROR_PARSE;\n\n      switch(message[cur_token]) {\n      case '\\n':\n\tstate = UNSTRUCTURED_LF;\n\tbreak;\n      default:\n\tstate = UNSTRUCTURED_START;\n\tbreak;\n      }\n      break;\n\n    case UNSTRUCTURED_LF:\n      if (cur_token >= length) {\n\tstate = UNSTRUCTURED_OUT;\n\tbreak;\n      }\n\n      switch(message[cur_token]) {\n      case '\\t':\n      case ' ':\n\tstate = UNSTRUCTURED_WSP;\n\tbreak;\n      default:\n\tstate = UNSTRUCTURED_OUT;\n\tbreak;\n      }\n      break;\n    case UNSTRUCTURED_WSP:\n      if (cur_token >= length)\n\treturn MAILIMF_ERROR_PARSE;\n\n      switch(message[cur_token]) {\n      case '\\r':\n\tstate = UNSTRUCTURED_CR;\n\tbreak;\n      case '\\n':\n\tstate = UNSTRUCTURED_LF;\n\tbreak;\n      default:\n\tstate = UNSTRUCTURED_START;\n\tbreak;\n      }\n      break;\n    }\n\n    cur_token ++;\n  }\n\n  str = malloc(terminal - begin + 1);\n  if (str == NULL)\n    return MAILIMF_ERROR_MEMORY;\n  strncpy(str, message + begin,  terminal - begin);\n  str[terminal - begin] = '\\0';\n\n  * indx = terminal;\n  * result = str;\n\n  return MAILIMF_NO_ERROR;\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":462237,"func":"static void rtl8139_io_writel(void *opaque, uint8_t addr, uint32_t val)\n{\n    RTL8139State *s = opaque;\n\n    switch (addr)\n    {\n        case RxMissed:\n            DPRINTF(\"RxMissed clearing on write\\n\");\n            s->RxMissed = 0;\n            break;\n\n        case TxConfig:\n            rtl8139_TxConfig_write(s, val);\n            break;\n\n        case RxConfig:\n            rtl8139_RxConfig_write(s, val);\n            break;\n\n        case TxStatus0 ... TxStatus0+4*4-1:\n            rtl8139_TxStatus_write(s, addr-TxStatus0, val);\n            break;\n\n        case TxAddr0 ... TxAddr0+4*4-1:\n            rtl8139_TxAddr_write(s, addr-TxAddr0, val);\n            break;\n\n        case RxBuf:\n            rtl8139_RxBuf_write(s, val);\n            break;\n\n        case RxRingAddrLO:\n            DPRINTF(\"C+ RxRing low bits write val=0x%08x\\n\", val);\n            s->RxRingAddrLO = val;\n            break;\n\n        case RxRingAddrHI:\n            DPRINTF(\"C+ RxRing high bits write val=0x%08x\\n\", val);\n            s->RxRingAddrHI = val;\n            break;\n\n        case Timer:\n            DPRINTF(\"TCTR Timer reset on write\\n\");\n            s->TCTR_base = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);\n            rtl8139_set_next_tctr_time(s);\n            break;\n\n        case FlashReg:\n            DPRINTF(\"FlashReg TimerInt write val=0x%08x\\n\", val);\n            if (s->TimerInt != val) {\n                s->TimerInt = val;\n                rtl8139_set_next_tctr_time(s);\n            }\n            break;\n\n        default:\n            DPRINTF(\"ioport write(l) addr=0x%x val=0x%08x via write(b)\\n\",\n                addr, val);\n            rtl8139_io_writeb(opaque, addr, val & 0xff);\n            rtl8139_io_writeb(opaque, addr + 1, (val >> 8) & 0xff);\n            rtl8139_io_writeb(opaque, addr + 2, (val >> 16) & 0xff);\n            rtl8139_io_writeb(opaque, addr + 3, (val >> 24) & 0xff);\n            break;\n    }\n}","target":0,"code_token_length":566,"total_token_length":802,"max_tokens_setting":1024}
+{"idx":140891,"func":"f_inputdialog(typval_T *argvars, typval_T *rettv)\n{\n#if defined(FEAT_GUI_TEXTDIALOG)\n    \/* Use a GUI dialog if the GUI is running and 'c' is not in 'guioptions' *\/\n    if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL)\n    {\n\tchar_u\t*message;\n\tchar_u\tbuf[NUMBUFLEN];\n\tchar_u\t*defstr = (char_u *)\"\";\n\n\tmessage = tv_get_string_chk(&argvars[0]);\n\tif (argvars[1].v_type != VAR_UNKNOWN\n\t\t&& (defstr = tv_get_string_buf_chk(&argvars[1], buf)) != NULL)\n\t    vim_strncpy(IObuff, defstr, IOSIZE - 1);\n\telse\n\t    IObuff[0] = NUL;\n\tif (message != NULL && defstr != NULL\n\t\t&& do_dialog(VIM_QUESTION, NULL, message,\n\t\t\t  (char_u *)_(\"&OK\\n&Cancel\"), 1, IObuff, FALSE) == 1)\n\t    rettv->vval.v_string = vim_strsave(IObuff);\n\telse\n\t{\n\t    if (message != NULL && defstr != NULL\n\t\t\t\t\t&& argvars[1].v_type != VAR_UNKNOWN\n\t\t\t\t\t&& argvars[2].v_type != VAR_UNKNOWN)\n\t\trettv->vval.v_string = vim_strsave(\n\t\t\t\t      tv_get_string_buf(&argvars[2], buf));\n\t    else\n\t\trettv->vval.v_string = NULL;\n\t}\n\trettv->v_type = VAR_STRING;\n    }\n    else\n#endif\n\tget_user_input(argvars, rettv, TRUE, inputsecret_flag);\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":427939,"func":"static int caldav_check_precond(struct transaction_t *txn, const void *data,\n\t\t\t\tconst char *etag, time_t lastmod)\n{\n    const struct caldav_data *cdata = (const struct caldav_data *) data;\n    const char *stag = cdata ? cdata->sched_tag : NULL;\n    const char **hdr;\n    int precond;\n\n    \/* Do normal WebDAV\/HTTP checks (primarily for lock-token via If header) *\/\n    precond = check_precond(txn, data, etag, lastmod);\n    if (!(precond == HTTP_OK || precond == HTTP_PARTIAL)) return precond;\n\n    \/* Per RFC 6638, check Schedule-Tag *\/\n    if ((hdr = spool_getheader(txn->req_hdrs, \"If-Schedule-Tag-Match\"))) {\n\t\/* Special case for Apple 'If-Schedule-Tag-Match:' with no value\n\t * and also no schedule tag on the record - let that match *\/\n\tif (cdata && !stag && !hdr[0][0]) return precond;\n\tif (etagcmp(hdr[0], stag)) return HTTP_PRECOND_FAILED;\n    }\n\n    if (txn->meth == METH_GET || txn->meth == METH_HEAD) {\n\t\/* Fill in Schedule-Tag for successful GET\/HEAD *\/\n\ttxn->resp_body.stag = stag;\n    }\n\n    return precond;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":29409,"func":"static void * Type_Curve_Read ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsUInt32Number * nItems , cmsUInt32Number SizeOfTag ) {\n cmsUInt32Number Count ;\n cmsToneCurve * NewGamma ;\n * nItems = 0 ;\n if ( ! _cmsReadUInt32Number ( io , & Count ) ) return NULL ;\n switch ( Count ) {\n case 0 : {\n cmsFloat64Number SingleGamma = 1.0 ;\n NewGamma = cmsBuildParametricToneCurve ( self -> ContextID , 1 , & SingleGamma ) ;\n if ( ! NewGamma ) return NULL ;\n * nItems = 1 ;\n return NewGamma ;\n }\n case 1 : {\n cmsUInt16Number SingleGammaFixed ;\n cmsFloat64Number SingleGamma ;\n if ( ! _cmsReadUInt16Number ( io , & SingleGammaFixed ) ) return NULL ;\n SingleGamma = _cms8Fixed8toDouble ( SingleGammaFixed ) ;\n * nItems = 1 ;\n return cmsBuildParametricToneCurve ( self -> ContextID , 1 , & SingleGamma ) ;\n }\n default : if ( Count > 0x7FFF ) return NULL ;\n NewGamma = cmsBuildTabulatedToneCurve16 ( self -> ContextID , Count , NULL ) ;\n if ( ! NewGamma ) return NULL ;\n if ( ! _cmsReadUInt16Array ( io , Count , NewGamma -> Table16 ) ) return NULL ;\n * nItems = 1 ;\n return NewGamma ;\n }\n cmsUNUSED_PARAMETER ( SizeOfTag ) ;\n }","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":384266,"func":"static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodePtr parent TSRMLS_DC)\n{\n\txmlNodePtr xmlParam;\n\tint i;\n\n\txmlParam = xmlNewNode(NULL, BAD_CAST(\"BOGUS\"));\n\txmlAddChild(parent, xmlParam);\n\tFIND_ZVAL_NULL(data, xmlParam, style);\n\n\tif (Z_TYPE_P(data) == IS_ARRAY) {\n\t\ti = zend_hash_num_elements(Z_ARRVAL_P(data));\n\t\tzend_hash_internal_pointer_reset(data->value.ht);\n\t\tfor (;i > 0;i--) {\n\t\t\txmlNodePtr xparam, item;\n\t\t\txmlNodePtr key;\n\t\t\tzval **temp_data;\n\t\t\tchar *key_val;\n\t\t\tulong int_val;\n\n\t\t\tzend_hash_get_current_data(data->value.ht, (void **)&temp_data);\n\t\t\titem = xmlNewNode(NULL, BAD_CAST(\"item\"));\n\t\t\txmlAddChild(xmlParam, item);\n\t\t\tkey = xmlNewNode(NULL, BAD_CAST(\"key\"));\n\t\t\txmlAddChild(item,key);\n\t\t\tif (zend_hash_get_current_key(data->value.ht, &key_val, &int_val, FALSE) == HASH_KEY_IS_STRING) {\n\t\t\t\tif (style == SOAP_ENCODED) {\n\t\t\t\t\tset_xsi_type(key, \"xsd:string\");\n\t\t\t\t}\n\t\t\t\txmlNodeSetContent(key, BAD_CAST(key_val));\n\t\t\t} else {\n\t\t\t\tsmart_str tmp = {0};\n\t\t\t\tsmart_str_append_long(&tmp, int_val);\n\t\t\t\tsmart_str_0(&tmp);\n\n\t\t\t\tif (style == SOAP_ENCODED) {\n\t\t\t\t\tset_xsi_type(key, \"xsd:int\");\n\t\t\t\t}\n\t\t\t\txmlNodeSetContentLen(key, BAD_CAST(tmp.c), tmp.len);\n\n\t\t\t\tsmart_str_free(&tmp);\n\t\t\t}\n\n\t\t\txparam = master_to_xml(get_conversion((*temp_data)->type), (*temp_data), style, item TSRMLS_CC);\n\t\t\txmlNodeSetName(xparam, BAD_CAST(\"value\"));\n\n\t\t\tzend_hash_move_forward(data->value.ht);\n\t\t}\n\t}\n\tif (style == SOAP_ENCODED) {\n\t\tset_ns_and_type(xmlParam, type);\n\t}\n\n\treturn xmlParam;\n}","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":389124,"func":"uint32 fuzzy_distance(const char *s1, unsigned len1, const char *s2, unsigned len2)\n{\n\tuint32 a[MAXPATHLEN], diag, above, left, diag_inc, above_inc, left_inc;\n\tint32 cost;\n\tunsigned i1, i2;\n\n\tif (!len1 || !len2) {\n\t\tif (!len1) {\n\t\t\ts1 = s2;\n\t\t\tlen1 = len2;\n\t\t}\n\t\tfor (i1 = 0, cost = 0; i1 < len1; i1++)\n\t\t\tcost += s1[i1];\n\t\treturn (int32)len1 * UNIT + cost;\n\t}\n\n\tfor (i2 = 0; i2 < len2; i2++)\n\t\ta[i2] = (i2+1) * UNIT;\n\n\tfor (i1 = 0; i1 < len1; i1++) {\n\t\tdiag = i1 * UNIT;\n\t\tabove = (i1+1) * UNIT;\n\t\tfor (i2 = 0; i2 < len2; i2++) {\n\t\t\tleft = a[i2];\n\t\t\tif ((cost = *((uchar*)s1+i1) - *((uchar*)s2+i2)) != 0) {\n\t\t\t\tif (cost < 0)\n\t\t\t\t\tcost = UNIT - cost;\n\t\t\t\telse\n\t\t\t\t\tcost = UNIT + cost;\n\t\t\t}\n\t\t\tdiag_inc = diag + cost;\n\t\t\tleft_inc = left + UNIT + *((uchar*)s1+i1);\n\t\t\tabove_inc = above + UNIT + *((uchar*)s2+i2);\n\t\t\ta[i2] = above = left < above\n\t\t\t      ? (left_inc < diag_inc ? left_inc : diag_inc)\n\t\t\t      : (above_inc < diag_inc ? above_inc : diag_inc);\n\t\t\tdiag = left;\n\t\t}\n\t}\n\n\treturn a[len2-1];\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":234869,"func":"EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(ExecState* exec)\n{\n    JSValue thisValue = exec->hostThisValue();\n    if (!thisValue.inherits(&JSTestObj::s_info))\n        return throwVMTypeError(exec);\n    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));\n     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);\n     TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n     if (exec->argumentCount() < 2)\n        return throwVMError(exec, createNotEnoughArgumentsError(exec));\n     ExceptionCode ec = 0;\n     const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));\n     if (exec->hadException())\n        return JSValue::encode(jsUndefined());\n    TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));\n    if (exec->hadException())\n        return JSValue::encode(jsUndefined());\n\n    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec)));\n    setDOMException(exec, ec);\n    return JSValue::encode(result);\n}\n","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":315578,"func":"int SafeSock::get_bytes(void *dta, int size)\n{\n\tASSERT( size > 0 );\n\twhile(!_msgReady) {\n\t\tif(_timeout > 0) {\n\t\t\tSelector selector;\n\t\t\tselector.set_timeout( _timeout );\n\t\t\tselector.add_fd( _sock, Selector::IO_READ );\n\t\t\t\t\n\t\t\tselector.execute();\n\t\t\tif ( selector.timed_out() ) {\n\t\t\t\treturn 0;\n\t\t\t} else if ( !selector.has_ready() ) {\n\t\t\t\t\tdprintf(D_NETWORK, \"select returns %d, recv failed\\n\",\n\t\t\t\t\t\t\tselector.select_retval());\n\t\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\t(void)handle_incoming_packet();\n\t}\n\n\tchar *tempBuf = (char *)malloc(size);\n    if (!tempBuf) { EXCEPT(\"malloc failed\"); }\n\tint readSize, length;\n    unsigned char * dec;\n\n\tif(_longMsg) {\n        readSize = _longMsg->getn(tempBuf, size);\n    }\n\telse { \n        readSize = _shortMsg.getn(tempBuf, size);\n    }\n\n\n\tif(readSize == size) {\n            if (get_encryption()) {\n                unwrap((unsigned char *) tempBuf, readSize, dec, length);\n                memcpy(dta, dec, readSize);\n                free(dec);\n            }\n            else {\n                memcpy(dta, tempBuf, readSize);\n            }\n\n\n            free(tempBuf);\n            return readSize;\n\t} else {\n\t\tfree(tempBuf);\n        dprintf(D_NETWORK,\n                \"SafeSock::get_bytes - failed because bytes read is different from bytes requested\\n\");\n\t\treturn -1;\n\t}\n}\n","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":272246,"func":"gst_asf_demux_handle_seek_push (GstASFDemux * demux, GstEvent * event)\n{\n  gdouble rate;\n  GstFormat format;\n  GstSeekFlags flags;\n  GstSeekType cur_type, stop_type;\n  gint64 cur, stop;\n  guint packet;\n  gboolean res;\n  GstEvent *byte_event;\n\n  gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur,\n      &stop_type, &stop);\n\n  stop_type = GST_SEEK_TYPE_NONE;\n  stop = -1;\n\n  GST_DEBUG_OBJECT (demux, \"seeking to %\" GST_TIME_FORMAT, GST_TIME_ARGS (cur));\n\n  \/* determine packet, by index or by estimation *\/\n  if (!gst_asf_demux_seek_index_lookup (demux, &packet, cur, NULL, NULL, FALSE,\n          NULL)) {\n    packet =\n        (guint) gst_util_uint64_scale (demux->num_packets, cur,\n        demux->play_time);\n  }\n\n  if (packet > demux->num_packets) {\n    GST_DEBUG_OBJECT (demux, \"could not determine packet to seek to, \"\n        \"seek aborted.\");\n    return FALSE;\n  }\n\n  GST_DEBUG_OBJECT (demux, \"seeking to packet %d\", packet);\n\n  cur = demux->data_offset + ((guint64) packet * demux->packet_size);\n\n  GST_DEBUG_OBJECT (demux, \"Pushing BYTE seek rate %g, \"\n      \"start %\" G_GINT64_FORMAT \", stop %\" G_GINT64_FORMAT, rate, cur, stop);\n  \/* BYTE seek event *\/\n  byte_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, cur_type,\n      cur, stop_type, stop);\n  gst_event_set_seqnum (byte_event, gst_event_get_seqnum (event));\n  res = gst_pad_push_event (demux->sinkpad, byte_event);\n\n  return res;\n}","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":434367,"func":"int mutt_check_overwrite (const char *attname, const char *path,\n\t\t\t\tchar *fname, size_t flen, int *append, char **directory) \n{\n  int rc = 0;\n  char tmp[_POSIX_PATH_MAX];\n  struct stat st;\n\n  strfcpy (fname, path, flen);\n  if (access (fname, F_OK) != 0)\n    return 0;\n  if (stat (fname, &st) != 0)\n    return -1;\n  if (S_ISDIR (st.st_mode))\n  {\n    if (directory)\n    {\n      switch (mutt_multi_choice\n\t      (_(\"File is a directory, save under it? [(y)es, (n)o, (a)ll]\"), _(\"yna\")))\n      {\n\tcase 3:\t\t\/* all *\/\n\t  mutt_str_replace (directory, fname);\n\t  break;\n\tcase 1:\t\t\/* yes *\/\n\t  FREE (directory);\t\t\/* __FREE_CHECKED__ *\/\n\t  break;\n\tcase -1:\t\/* abort *\/\n\t  FREE (directory); \t\t\/* __FREE_CHECKED__ *\/\n\t  return -1;\n\tcase  2:\t\/* no *\/\n\t  FREE (directory);\t\t\/* __FREE_CHECKED__ *\/\n\t  return 1;\n      }\n    }\n    else if ((rc = mutt_yesorno (_(\"File is a directory, save under it?\"), M_YES)) != M_YES)\n      return (rc == M_NO) ? 1 : -1;\n\n    if (!attname || !attname[0])\n    {\n      tmp[0] = 0;\n      if (mutt_get_field (_(\"File under directory: \"), tmp, sizeof (tmp),\n\t\t\t\t      M_FILE | M_CLEAR) != 0 || !tmp[0])\n\treturn (-1);\n      mutt_concat_path (fname, path, tmp, flen);\n    }\n    else\n      mutt_concat_path (fname, path, mutt_basename (attname), flen);\n  }\n  \n  if (*append == 0 && access (fname, F_OK) == 0)\n  {\n    switch (mutt_multi_choice\n\t    (_(\"File exists, (o)verwrite, (a)ppend, or (c)ancel?\"), _(\"oac\")))\n    {\n      case -1: \/* abort *\/\n        return -1;\n      case 3:  \/* cancel *\/\n\treturn 1;\n\n      case 2: \/* append *\/\n        *append = M_SAVE_APPEND;\n        break;\n      case 1: \/* overwrite *\/\n        *append = M_SAVE_OVERWRITE;\n        break;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":437968,"func":"const BlockEntry* Cluster::GetEntry(const CuePoint& cp,\n                                    const CuePoint::TrackPosition& tp) const {\n  assert(m_pSegment);\n  const long long tc = cp.GetTimeCode();\n\n  if (tp.m_block > 0) {\n    const long block = static_cast<long>(tp.m_block);\n    const long index = block - 1;\n\n    while (index >= m_entries_count) {\n      long long pos;\n      long len;\n\n      const long status = Parse(pos, len);\n\n      if (status < 0)  \/\/ TODO: can this happen?\n        return NULL;\n\n      if (status > 0)  \/\/ nothing remains to be parsed\n        return NULL;\n    }\n\n    const BlockEntry* const pEntry = m_entries[index];\n    assert(pEntry);\n    assert(!pEntry->EOS());\n\n    const Block* const pBlock = pEntry->GetBlock();\n    assert(pBlock);\n\n    if ((pBlock->GetTrackNumber() == tp.m_track) &&\n        (pBlock->GetTimeCode(this) == tc)) {\n      return pEntry;\n    }\n  }\n\n  long index = 0;\n\n  for (;;) {\n    if (index >= m_entries_count) {\n      long long pos;\n      long len;\n\n      const long status = Parse(pos, len);\n\n      if (status < 0)  \/\/ TODO: can this happen?\n        return NULL;\n\n      if (status > 0)  \/\/ nothing remains to be parsed\n        return NULL;\n\n      assert(m_entries);\n      assert(index < m_entries_count);\n    }\n\n    const BlockEntry* const pEntry = m_entries[index];\n    assert(pEntry);\n    assert(!pEntry->EOS());\n\n    const Block* const pBlock = pEntry->GetBlock();\n    assert(pBlock);\n\n    if (pBlock->GetTrackNumber() != tp.m_track) {\n      ++index;\n      continue;\n    }\n\n    const long long tc_ = pBlock->GetTimeCode(this);\n\n    if (tc_ < tc) {\n      ++index;\n      continue;\n    }\n\n    if (tc_ > tc)\n      return NULL;\n\n    const Tracks* const pTracks = m_pSegment->GetTracks();\n    assert(pTracks);\n\n    const long tn = static_cast<long>(tp.m_track);\n    const Track* const pTrack = pTracks->GetTrackByNumber(tn);\n\n    if (pTrack == NULL)\n      return NULL;\n\n    const long long type = pTrack->GetType();\n\n    if (type == 2)  \/\/ audio\n      return pEntry;\n\n    if (type != 1)  \/\/ not video\n      return NULL;\n\n    if (!pBlock->IsKey())\n      return NULL;\n\n    return pEntry;\n  }\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":298494,"func":"bool ValidateARIA()\r\n{\r\n\tstd::cout << \"\\nARIA validation suite running...\\n\\n\";\r\n\tbool pass1 = true, pass2 = true, pass3 = true;\r\n\r\n\tARIAEncryption enc;\r\n\tpass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;\r\n\tpass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;\r\n\r\n\tARIADecryption dec;\r\n\tpass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;\r\n\tpass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;\r\n\tstd::cout << (pass1 && pass2 ? \"passed:\" : \"FAILED:\") << \"  Algorithm key lengths\\n\";\r\n\r\n\tFileSource valdata(CRYPTOPP_DATA_DIR \"TestData\/aria.dat\", true, new HexDecoder);\r\n\tpass3 = BlockTransformationTest(FixedRoundsCipherFactory<ARIAEncryption, ARIADecryption>(16), valdata, 15) && pass3;\r\n\tpass3 = BlockTransformationTest(FixedRoundsCipherFactory<ARIAEncryption, ARIADecryption>(24), valdata, 15) && pass3;\r\n\tpass3 = BlockTransformationTest(FixedRoundsCipherFactory<ARIAEncryption, ARIADecryption>(32), valdata, 15) && pass3;\r\n\treturn pass1 && pass2 && pass3;\r\n}\r","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":202809,"func":"static void calc_matrix(double mat[4][4], const double *mat_freq, const int *index)\n{\n    for (int i = 0; i < 4; ++i) {\n        mat[i][i] = mat_freq[2 * index[i]] + 3 * mat_freq[0] - 4 * mat_freq[index[i]];\n        for (int j = i + 1; j < 4; ++j)\n            mat[i][j] = mat[j][i] =\n                mat_freq[index[i] + index[j]] + mat_freq[index[j] - index[i]] +\n                2 * (mat_freq[0] - mat_freq[index[i]] - mat_freq[index[j]]);\n    }\n\n    for (int k = 0; k < 4; ++k) {\n        int ip = k, jp = k;  \/\/ pivot\n        double z = 1 \/ mat[ip][jp];\n        mat[ip][jp] = 1;\n        for (int i = 0; i < 4; ++i) {\n            if (i == ip)\n                continue;\n\n            double mul = mat[i][jp] * z;\n            mat[i][jp] = 0;\n            for (int j = 0; j < 4; ++j)\n                mat[i][j] -= mat[ip][j] * mul;\n        }\n        for (int j = 0; j < 4; ++j)\n            mat[ip][j] *= z;\n    }\n}\n","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":426605,"func":"int pn_ssl_domain_set_protocols(pn_ssl_domain_t *domain, const char *protocols)\n{\n  static const struct {\n    const char *name;\n    const long option;\n  } protocol_options[] =\n  {\n    {\"TLSv1\",   SSL_OP_NO_TLSv1},\n    {\"TLSv1.1\", SSL_OP_NO_TLSv1_1},\n    {\"TLSv1.2\", SSL_OP_NO_TLSv1_2},\n#ifdef SSL_OP_NO_TLSv1_3\n    {\"TLSv1.3\", SSL_OP_NO_TLSv1_3},\n#endif\n  };\n  static const char seps[]    = \" ,;\";\n  static const long all_prots =\n    SSL_OP_NO_TLSv1\n    | SSL_OP_NO_TLSv1_1\n    | SSL_OP_NO_TLSv1_2\n#ifdef SSL_OP_NO_TLSv1_3\n    | SSL_OP_NO_TLSv1_3\n#endif\n    ;\n\n  \/\/ Start with all protocols turned off\n  long options = all_prots;\n\n  \/\/ For each separate token in protocols\n  const char *token = protocols;\n  while (*token!=0) {\n    \/\/ Find next separator\n    size_t tsize = strcspn(token, seps);\n    while (tsize==0 && *token!=0) {\n      ++token;\n      tsize = strcspn(token, seps);\n    }\n    if (tsize==0) break; \/\/ No more tokens\n\n    \/\/ Linear search the possibilities for the option to set\n    for (size_t i = 0; i<sizeof(protocol_options)\/sizeof(*protocol_options); ++i) {\n      if (strncmp(token, protocol_options[i].name, tsize)==0) {\n        options &= ~protocol_options[i].option;\n        goto found;\n      }\n    }\n    \/\/ Didn't find any match - error\n    return PN_ARG_ERR;\n\nfound:\n    token += tsize;\n  }\n\n  \/\/ Check if we found anything\n  if (options==all_prots) return PN_ARG_ERR;\n\n  SSL_CTX_clear_options(domain->ctx, all_prots);\n  SSL_CTX_set_options(domain->ctx, options);\n  return 0;\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":193225,"func":"png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,\n   png_size_t png_struct_size)\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf tmp_jmp;  \/* to save current jump buffer *\/\n#endif\n\n   int i = 0;\n\n   png_structp png_ptr=*ptr_ptr;\n\n   if (png_ptr == NULL)\n      return;\n \n    do\n    {\n      if (user_png_ver == NULL || user_png_ver[i] != png_libpng_ver[i])\n       {\n #ifdef PNG_LEGACY_SUPPORTED\n         png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;\n#else\n        png_ptr->warning_fn = NULL;\n        png_warning(png_ptr,\n         \"Application uses deprecated png_read_init() and should be\"\n         \" recompiled.\");\n        break;\n#endif\n      }\n   } while (png_libpng_ver[i++]);\n\n   png_debug(1, \"in png_read_init_3\");\n\n#ifdef PNG_SETJMP_SUPPORTED\n   \/* Save jump buffer and error functions *\/\n   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));\n#endif\n\n   if (png_sizeof(png_struct) > png_struct_size)\n   {\n      png_destroy_struct(png_ptr);\n      *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);\n      png_ptr = *ptr_ptr;\n   }\n\n   \/* Reset all variables to 0 *\/\n   png_memset(png_ptr, 0, png_sizeof(png_struct));\n\n#ifdef PNG_SETJMP_SUPPORTED\n   \/* Restore jump buffer *\/\n   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));\n#endif\n\n   \/* Added at libpng-1.2.6 *\/\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n   png_ptr->user_width_max = PNG_USER_WIDTH_MAX;\n   png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;\n#endif\n\n   \/* Initialize zbuf - compression buffer *\/\n   png_ptr->zbuf_size = PNG_ZBUF_SIZE;\n   png_ptr->zstream.zalloc = png_zalloc;\n   png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,\n     (png_uint_32)png_ptr->zbuf_size);\n   png_ptr->zstream.zalloc = png_zalloc;\n   png_ptr->zstream.zfree = png_zfree;\n   png_ptr->zstream.opaque = (voidpf)png_ptr;\n\n   switch (inflateInit(&png_ptr->zstream))\n   {\n      case Z_OK: \/* Do nothing *\/ break;\n      case Z_STREAM_ERROR: png_error(png_ptr, \"zlib memory error\"); break;\n      case Z_VERSION_ERROR: png_error(png_ptr, \"zlib version error\");\n          break;\n      default: png_error(png_ptr, \"Unknown zlib error\");\n   }\n\n   png_ptr->zstream.next_out = png_ptr->zbuf;\n   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n\n   png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);\n}\n","target":0,"code_token_length":637,"total_token_length":873,"max_tokens_setting":1024}
+{"idx":181054,"func":"ofpact_is_set_or_move_action(const struct ofpact *a)\n{\n    switch (a->type) {\n    case OFPACT_SET_FIELD:\n    case OFPACT_REG_MOVE:\n    case OFPACT_SET_ETH_DST:\n    case OFPACT_SET_ETH_SRC:\n    case OFPACT_SET_IP_DSCP:\n    case OFPACT_SET_IP_ECN:\n    case OFPACT_SET_IP_TTL:\n    case OFPACT_SET_IPV4_DST:\n    case OFPACT_SET_IPV4_SRC:\n    case OFPACT_SET_L4_DST_PORT:\n    case OFPACT_SET_L4_SRC_PORT:\n    case OFPACT_SET_MPLS_LABEL:\n    case OFPACT_SET_MPLS_TC:\n    case OFPACT_SET_MPLS_TTL:\n    case OFPACT_SET_QUEUE:\n    case OFPACT_SET_TUNNEL:\n    case OFPACT_SET_VLAN_PCP:\n    case OFPACT_SET_VLAN_VID:\n        return true;\n    case OFPACT_BUNDLE:\n    case OFPACT_CLEAR_ACTIONS:\n    case OFPACT_CT:\n    case OFPACT_CT_CLEAR:\n    case OFPACT_CLONE:\n    case OFPACT_NAT:\n    case OFPACT_CONTROLLER:\n    case OFPACT_DEC_MPLS_TTL:\n    case OFPACT_DEC_TTL:\n    case OFPACT_ENQUEUE:\n    case OFPACT_EXIT:\n    case OFPACT_UNROLL_XLATE:\n    case OFPACT_FIN_TIMEOUT:\n    case OFPACT_GOTO_TABLE:\n    case OFPACT_GROUP:\n    case OFPACT_LEARN:\n    case OFPACT_CONJUNCTION:\n    case OFPACT_METER:\n    case OFPACT_MULTIPATH:\n    case OFPACT_NOTE:\n    case OFPACT_OUTPUT:\n    case OFPACT_OUTPUT_REG:\n    case OFPACT_OUTPUT_TRUNC:\n    case OFPACT_POP_MPLS:\n    case OFPACT_POP_QUEUE:\n    case OFPACT_PUSH_MPLS:\n    case OFPACT_PUSH_VLAN:\n    case OFPACT_RESUBMIT:\n    case OFPACT_SAMPLE:\n    case OFPACT_STACK_POP:\n    case OFPACT_STACK_PUSH:\n    case OFPACT_STRIP_VLAN:\n    case OFPACT_WRITE_ACTIONS:\n    case OFPACT_WRITE_METADATA:\n    case OFPACT_DEBUG_RECIRC:\n        return false;\n    default:\n        OVS_NOT_REACHED();\n    }\n}\n","target":0,"code_token_length":513,"total_token_length":749,"max_tokens_setting":1024}
+{"idx":305342,"func":"TfLiteStatus EvalQuantizedInt8(TfLiteContext* context, TfLiteNode* node,\n                               const OpData& data,\n                               const TfLiteEvalTensor* input,\n                               const TfLiteEvalTensor* filter,\n                               const TfLiteEvalTensor* bias,\n                               TfLiteEvalTensor* output) {\n  tflite::FullyConnectedParams op_params;\n  op_params.input_offset = -data.input_zero_point;\n  op_params.weights_offset = -data.filter_zero_point;\n  op_params.output_offset = data.output_zero_point;\n  op_params.output_multiplier = data.output_multiplier;\n  \/\/ TODO(b\/138810107): Figure out whether output shift should be inverted\n  op_params.output_shift = -data.output_shift;\n  op_params.quantized_activation_min = data.output_activation_min;\n  op_params.quantized_activation_max = data.output_activation_max;\n\n  reference_integer_ops::FullyConnected(\n      op_params, tflite::micro::GetTensorShape(input),\n      tflite::micro::GetTensorData<int8_t>(input),\n      tflite::micro::GetTensorShape(filter),\n      tflite::micro::GetTensorData<int8_t>(filter),\n      tflite::micro::GetTensorShape(bias),\n      tflite::micro::GetTensorData<int32_t>(bias),\n      tflite::micro::GetTensorShape(output),\n      tflite::micro::GetTensorData<int8_t>(output));\n  return kTfLiteOk;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":124311,"func":"void kgdb_arch_late(void)\n{\n\tint i, cpu;\n\tstruct perf_event_attr attr;\n\tstruct perf_event **pevent;\n\n\t\/*\n\t * Pre-allocate the hw breakpoint structions in the non-atomic\n\t * portion of kgdb because this operation requires mutexs to\n\t * complete.\n\t *\/\n\thw_breakpoint_init(&attr);\n\tattr.bp_addr = (unsigned long)kgdb_arch_init;\n\tattr.bp_len = HW_BREAKPOINT_LEN_1;\n\tattr.bp_type = HW_BREAKPOINT_W;\n\tattr.disabled = 1;\n\tfor (i = 0; i < HBP_NUM; i++) {\n\t\tif (breakinfo[i].pev)\n\t\t\tcontinue;\n\t\tbreakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL);\n\t\tif (IS_ERR((void * __force)breakinfo[i].pev)) {\n\t\t\tprintk(KERN_ERR \"kgdb: Could not allocate hw\"\n\t\t\t       \"breakpoints\\nDisabling the kernel debugger\\n\");\n\t\t\tbreakinfo[i].pev = NULL;\n\t\t\tkgdb_arch_exit();\n\t\t\treturn;\n\t\t}\n\t\tfor_each_online_cpu(cpu) {\n\t\t\tpevent = per_cpu_ptr(breakinfo[i].pev, cpu);\n\t\t\tpevent[0]->hw.sample_period = 1;\n\t\t\tpevent[0]->overflow_handler = kgdb_hw_overflow_handler;\n\t\t\tif (pevent[0]->destroy != NULL) {\n\t\t\t\tpevent[0]->destroy = NULL;\n\t\t\t\trelease_bp_slot(*pevent);\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":403095,"func":"\tstd::string print_entry(bdecode_node const& e\n\t\t, bool single_line, int indent)\n\t{\n\t\tchar indent_str[200];\n\t\tusing std::memset;\n\t\tmemset(indent_str, ' ', 200);\n\t\tindent_str[0] = ',';\n\t\tindent_str[1] = '\\n';\n\t\tindent_str[199] = 0;\n\t\tif (indent < 197 && indent >= 0) indent_str[indent+2] = 0;\n\t\tstd::string ret;\n\t\tswitch (e.type())\n\t\t{\n\t\t\tcase bdecode_node::none_t: return \"none\";\n\t\t\tcase bdecode_node::int_t:\n\t\t\t{\n\t\t\t\tchar str[100];\n\t\t\t\tsnprintf(str, sizeof(str), \"%\" PRId64, e.int_value());\n\t\t\t\treturn str;\n\t\t\t}\n\t\t\tcase bdecode_node::string_t:\n\t\t\t{\n\t\t\t\tprint_string(ret, e.string_ptr(), e.string_length(), single_line);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase bdecode_node::list_t:\n\t\t\t{\n\t\t\t\tret += '[';\n\t\t\t\tbool one_liner = line_longer_than(e, 200) != -1 || single_line;\n\n\t\t\t\tif (!one_liner) ret += indent_str + 1;\n\t\t\t\tfor (int i = 0; i < e.list_size(); ++i)\n\t\t\t\t{\n\t\t\t\t\tif (i == 0 && one_liner) ret += \" \";\n\t\t\t\t\tret += print_entry(e.list_at(i), single_line, indent + 2);\n\t\t\t\t\tif (i < e.list_size() - 1) ret += (one_liner?\", \":indent_str);\n\t\t\t\t\telse ret += (one_liner?\" \":indent_str+1);\n\t\t\t\t}\n\t\t\t\tret += \"]\";\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tcase bdecode_node::dict_t:\n\t\t\t{\n\t\t\t\tret += \"{\";\n\t\t\t\tbool one_liner = line_longer_than(e, 200) != -1 || single_line;\n\n\t\t\t\tif (!one_liner) ret += indent_str+1;\n\t\t\t\tfor (int i = 0; i < e.dict_size(); ++i)\n\t\t\t\t{\n\t\t\t\t\tif (i == 0 && one_liner) ret += \" \";\n\t\t\t\t\tstd::pair<std::string, bdecode_node> ent = e.dict_at(i);\n\t\t\t\t\tprint_string(ret, ent.first.c_str(), ent.first.size(), true);\n\t\t\t\t\tret += \": \";\n\t\t\t\t\tret += print_entry(ent.second, single_line, indent + 2);\n\t\t\t\t\tif (i < e.dict_size() - 1) ret += (one_liner?\", \":indent_str);\n\t\t\t\t\telse ret += (one_liner?\" \":indent_str+1);\n\t\t\t\t}\n\t\t\t\tret += \"}\";\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":176917,"func":"ui::EventDispatchDetails MockInputMethod::DispatchKeyEvent(ui::KeyEvent* key) {\n#if defined(OS_MACOSX)\n  if (key->is_char())\n    return DispatchKeyEventPostIME(key);\n#endif\n\n  if (key->is_char() && key->HasNativeEvent()) {\n    key->SetHandled();\n    return ui::EventDispatchDetails();\n  }\n\n  ui::EventDispatchDetails dispatch_details;\n\n  bool handled = !IsTextInputTypeNone() && HasComposition();\n  ClearStates();\n  if (handled) {\n    DCHECK(!key->is_char());\n    ui::KeyEvent mock_key(ui::ET_KEY_PRESSED,\n                          ui::VKEY_PROCESSKEY,\n                          key->flags());\n    dispatch_details = DispatchKeyEventPostIME(&mock_key);\n  } else {\n    dispatch_details = DispatchKeyEventPostIME(key);\n  }\n\n  if (key->handled() || dispatch_details.dispatcher_destroyed)\n    return dispatch_details;\n\n  ui::TextInputClient* client = GetTextInputClient();\n  if (client) {\n    if (handled) {\n      if (result_text_.length())\n        client->InsertText(result_text_);\n      if (composition_.text.length())\n        client->SetCompositionText(composition_);\n      else\n        client->ClearCompositionText();\n    } else if (key->type() == ui::ET_KEY_PRESSED) {\n      base::char16 ch = key->GetCharacter();\n      if (ch)\n        client->InsertChar(*key);\n    }\n  }\n\n  ClearComposition();\n\n  return dispatch_details;\n}\n","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":336571,"func":"static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,\n\n                                 uint32_t arg)\n\n{\n\n    LSIState *s = DO_UPCAST(LSIState, dev.qdev, bus->qbus.parent);\n\n    int out;\n\n\n\n    out = (s->sstat1 & PHASE_MASK) == PHASE_DO;\n\n    if (reason == SCSI_REASON_DONE) {\n\n        DPRINTF(\"Command complete status=%d\\n\", (int)arg);\n\n        s->status = arg;\n\n        s->command_complete = 2;\n\n        if (s->waiting && s->dbc != 0) {\n\n            \/* Raise phase mismatch for short transfers.  *\/\n\n            lsi_bad_phase(s, out, PHASE_ST);\n\n        } else {\n\n            lsi_set_phase(s, PHASE_ST);\n\n        }\n\n\n\n        qemu_free(s->current);\n\n        s->current = NULL;\n\n\n\n        lsi_resume_script(s);\n\n        return;\n\n    }\n\n\n\n    if (s->waiting == 1 || !s->current || tag != s->current->tag ||\n\n        (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {\n\n        if (lsi_queue_tag(s, tag, arg))\n\n            return;\n\n    }\n\n\n\n    \/* host adapter (re)connected *\/\n\n    DPRINTF(\"Data ready tag=0x%x len=%d\\n\", tag, arg);\n\n    s->current->dma_len = arg;\n\n    s->command_complete = 1;\n\n    if (!s->waiting)\n\n        return;\n\n    if (s->waiting == 1 || s->dbc == 0) {\n\n        lsi_resume_script(s);\n\n    } else {\n\n        lsi_do_dma(s, out);\n\n    }\n\n}\n","target":1,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":12373,"func":"void MojoVideoEncodeAccelerator::Encode(const scoped_refptr<VideoFrame>& frame,\n                                        bool force_keyframe) {\n  DVLOG(2) << __func__ << \" tstamp=\" << frame->timestamp();\n  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);\n  DCHECK_EQ(PIXEL_FORMAT_I420, frame->format());\n  DCHECK_EQ(VideoFrame::STORAGE_SHMEM, frame->storage_type());\n  DCHECK(frame->shared_memory_handle().IsValid());\n\n  const size_t allocation_size = frame->shared_memory_handle().GetSize();\n \n  mojo::ScopedSharedBufferHandle handle =\n      mojo::WrapSharedMemoryHandle(frame->shared_memory_handle().Duplicate(),\n                                   allocation_size, true \/* read_only *\/);\n \n   const size_t y_offset = frame->shared_memory_offset();\n   const size_t u_offset = y_offset + frame->data(VideoFrame::kUPlane) -\n                          frame->data(VideoFrame::kYPlane);\n  const size_t v_offset = y_offset + frame->data(VideoFrame::kVPlane) -\n                          frame->data(VideoFrame::kYPlane);\n  scoped_refptr<MojoSharedBufferVideoFrame> mojo_frame =\n      MojoSharedBufferVideoFrame::Create(\n          frame->format(), frame->coded_size(), frame->visible_rect(),\n          frame->natural_size(), std::move(handle), allocation_size, y_offset,\n          u_offset, v_offset, frame->stride(VideoFrame::kYPlane),\n          frame->stride(VideoFrame::kUPlane),\n          frame->stride(VideoFrame::kVPlane), frame->timestamp());\n\n  DCHECK(vea_.is_bound());\n  vea_->Encode(mojo_frame, force_keyframe,\n               base::Bind(&KeepVideoFrameAlive, frame));\n}\n","target":1,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":490049,"func":"static int asn1_encode_se_info(sc_context_t *ctx,\n\t\tstruct sc_pkcs15_sec_env_info **se, size_t se_num,\n\t\tunsigned char **buf, size_t *bufsize, int depth)\n{\n\tunsigned char *ptr = NULL, *out = NULL, *p;\n\tsize_t ptrlen = 0, outlen = 0, idx;\n\tint ret;\n\n\tfor (idx=0; idx < se_num; idx++)   {\n\t\tstruct sc_asn1_entry asn1_se[2];\n\t\tstruct sc_asn1_entry asn1_se_info[4];\n\n\t\tsc_copy_asn1_entry(c_asn1_se, asn1_se);\n\t\tsc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);\n\n\t\tsc_format_asn1_entry(asn1_se_info + 0, &se[idx]->se, NULL, 1);\n\t\tif (sc_valid_oid(&se[idx]->owner))\n\t\t\tsc_format_asn1_entry(asn1_se_info + 1, &se[idx]->owner, NULL, 1);\n\t\tif (se[idx]->aid.len)\n\t\t\tsc_format_asn1_entry(asn1_se_info + 2, &se[idx]->aid.value, &se[idx]->aid.len, 1);\n\t\tsc_format_asn1_entry(asn1_se + 0, asn1_se_info, NULL, 1);\n\n\t\tret = sc_asn1_encode(ctx, asn1_se, &ptr, &ptrlen);\n\t\tif (ret != SC_SUCCESS)\n\t\t\tgoto err;\n\n\t\tp = (unsigned char *) realloc(out, outlen + ptrlen);\n\t\tif (!p)   {\n\t\t\tret = SC_ERROR_OUT_OF_MEMORY;\n\t\t\tgoto err;\n\t\t}\n\t\tout = p;\n\t\tmemcpy(out + outlen, ptr, ptrlen);\n\t\toutlen += ptrlen;\n\t\tfree(ptr);\n\t\tptr = NULL;\n\t\tptrlen = 0;\n\t}\n\n\t*buf = out;\n\t*bufsize = outlen;\n\tret = SC_SUCCESS;\nerr:\n\tif (ret != SC_SUCCESS && out != NULL)\n\t\tfree(out);\n\treturn ret;\n}","target":0,"code_token_length":446,"total_token_length":682,"max_tokens_setting":1024}
+{"idx":22055,"func":"static int cirrus_bitblt_common_patterncopy ( CirrusVGAState * s ) {\n uint32_t patternsize ;\n bool videosrc = ! s -> cirrus_srccounter ;\n if ( videosrc ) {\n switch ( s -> vga . get_bpp ( & s -> vga ) ) {\n case 8 : patternsize = 64 ;\n break ;\n case 15 : case 16 : patternsize = 128 ;\n break ;\n case 24 : case 32 : default : patternsize = 256 ;\n break ;\n }\n s -> cirrus_blt_srcaddr &= ~ ( patternsize - 1 ) ;\n if ( s -> cirrus_blt_srcaddr + patternsize > s -> vga . vram_size ) {\n return 0 ;\n }\n }\n if ( blit_is_unsafe ( s , true ) ) {\n return 0 ;\n }\n ( * s -> cirrus_rop ) ( s , s -> cirrus_blt_dstaddr , videosrc ? s -> cirrus_blt_srcaddr : 0 , s -> cirrus_blt_dstpitch , 0 , s -> cirrus_blt_width , s -> cirrus_blt_height ) ;\n cirrus_invalidate_region ( s , s -> cirrus_blt_dstaddr , s -> cirrus_blt_dstpitch , s -> cirrus_blt_width , s -> cirrus_blt_height ) ;\n return 1 ;\n }","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":7099,"func":"bool all_tests () {\n\tmu_run_test (test_r_str_newf);\n\tmu_run_test (test_r_str_replace_char_once);\n\tmu_run_test (test_r_str_replace_char);\n\tmu_run_test (test_r_str_replace);\n\tmu_run_test (test_r_str_bits64);\n\tmu_run_test (test_r_str_rwx);\n\tmu_run_test (test_r_str_rwx_i);\n\tmu_run_test (test_r_str_bool);\n\tmu_run_test (test_r_str_trim);\n\tmu_run_test (test_r_str_case);\n\tmu_run_test (test_r_str_split);\n\tmu_run_test (test_r_str_tokenize);\n\tmu_run_test (test_r_str_char_count);\n\tmu_run_test (test_r_str_word_count);\n\tmu_run_test (test_r_str_ichr);\n\tmu_run_test (test_r_str_lchr);\n\tmu_run_test (test_r_sub_str_lchr);\n\tmu_run_test (test_r_sub_str_rchr);\n\tmu_run_test (test_r_str_rchr);\n\tmu_run_test (test_r_str_ansi_len);\n\tmu_run_test (test_r_str_len_utf8_ansi);\n\tmu_run_test (test_r_str_utf8_charsize);\n\tmu_run_test (test_r_str_utf8_charsize_prev);\n\tmu_run_test (test_r_str_sanitize_sdb_key);\n\tmu_run_test (test_r_str_unescape);\n\tmu_run_test (test_r_str_constpool);\n\tmu_run_test (test_r_str_format_msvc_argv);\n\tmu_run_test (test_r_str_str_xy);\n\treturn tests_passed != tests_run;\n}","target":1,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":463,"func":"static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) {\n OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ;\n }\n static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) {\n return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ;\n }\n static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) {\n return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ;\n }\n static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) {\n return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;\n }\n static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) {\n return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;\n }\n static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) {\n OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) {\n return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) {\n return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ;\n }\n static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) {\n return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ;\n }\n static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) {\n return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ;\n }\n # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ;\n typedef const char * OPENSSL_CSTRING ;\n DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char )","target":1,"code_token_length":743,"total_token_length":979,"max_tokens_setting":1024}
+{"idx":497524,"func":"static void ok_inflater_make_huffman_tree_from_array(ok_inflater_huffman_tree *tree,\n                                                     const uint8_t *code_length, int length) {\n    tree->bits = 1;\n\n    \/\/ Count the number of codes for each code length.\n    \/\/ Let code_length_count[n] be the number of codes of length n, n >= 1.\n    unsigned int code_length_count[MAX_CODE_LENGTH];\n    int i;\n    for (i = 0; i < MAX_CODE_LENGTH; i++) {\n        code_length_count[i] = 0;\n    }\n    for (i = 0; i < length; i++) {\n        code_length_count[code_length[i]]++;\n    }\n\n    \/\/ Find the numerical value of the smallest code for each code length:\n    unsigned int next_code[MAX_CODE_LENGTH];\n    unsigned int code = 0;\n    for (i = 1; i < MAX_CODE_LENGTH; i++) {\n        code = (code + code_length_count[i - 1]) << 1;\n        next_code[i] = code;\n        if (code_length_count[i] != 0) {\n            tree->bits = (unsigned int)i;\n        }\n    }\n\n    \/\/ Init lookup table\n    const unsigned int max = 1 << tree->bits;\n    memset(tree->lookup_table, 0, sizeof(tree->lookup_table[0]) * max);\n\n    \/\/ Assign numerical values to all codes, using consecutive values for all\n    \/\/ codes of the same length with the base values determined at step 2.\n    \/\/ Codes that are never used (which have a bit length of zero) must not be\n    \/\/ assigned a value.\n    for (i = 0; i < length; i++) {\n        unsigned int len = code_length[i];\n        if (len != 0) {\n            code = next_code[len];\n            next_code[len]++;\n\n            unsigned int value = (unsigned int)i | (len << VALUE_BITS);\n            tree->lookup_table[ok_inflater_reverse_bits(code, len)] = (uint16_t)value;\n        }\n    }\n\n    \/\/ Fill in the missing parts of the lookup table\n    int next_limit = 1;\n    int num_bits = 0;\n    int mask = 0;\n    for (i = 1; i < (int)max; i++) {\n        if (i == next_limit) {\n            mask = (1 << num_bits) - 1;\n            num_bits++;\n            next_limit <<= 1;\n        }\n        if (tree->lookup_table[i] == 0) {\n            tree->lookup_table[i] = tree->lookup_table[i & mask];\n        }\n    }\n}","target":0,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":508020,"func":"int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)\n\t{\n\tint j,ret=0;\n\tBIO *in;\n\tRSA *rsa=NULL;\n\n\tin=BIO_new(BIO_s_file_internal());\n\tif (in == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,ERR_R_BUF_LIB);\n\t\tgoto end;\n\t\t}\n\n\tif (BIO_read_filename(in,file) <= 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,ERR_R_SYS_LIB);\n\t\tgoto end;\n\t\t}\n\tif\t(type == SSL_FILETYPE_ASN1)\n\t\t{\n\t\tj=ERR_R_ASN1_LIB;\n\t\trsa=d2i_RSAPrivateKey_bio(in,NULL);\n\t\t}\n\telse if (type == SSL_FILETYPE_PEM)\n\t\t{\n\t\tj=ERR_R_PEM_LIB;\n\t\trsa=PEM_read_bio_RSAPrivateKey(in,NULL,\n\t\t\tssl->ctx->default_passwd_callback,ssl->ctx->default_passwd_callback_userdata);\n\t\t}\n\telse\n\t\t{\n\t\tSSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,SSL_R_BAD_SSL_FILETYPE);\n\t\tgoto end;\n\t\t}\n\tif (rsa == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,j);\n\t\tgoto end;\n\t\t}\n\tret=SSL_use_RSAPrivateKey(ssl,rsa);\n\tRSA_free(rsa);\nend:\n\tif (in != NULL) BIO_free(in);\n\treturn(ret);\n\t}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":379045,"func":"\nstatic void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC) \/* {{{ *\/\n{\n\tchar *key;\n\tuint len;\n\n\tif (ht) {\n\t\tif (zend_hash_num_elements(ht)) {\n\t\t\tHashPosition pos;\n\n\t\t\tif (!sapi_module.phpinfo_as_text) {\n\t\t\t\tphp_info_printf(\"<tr><td class=\\\"e\\\">Registered %s<\/td><td class=\\\"v\\\">\", name);\n\t\t\t} else {\n\t\t\t\tphp_info_printf(\"\\nRegistered %s => \", name);\n\t\t\t}\n\n\t\t\tzend_hash_internal_pointer_reset_ex(ht, &pos);\n\t\t\twhile (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING)\n\t\t\t{\n\t\t\t\tif (!sapi_module.phpinfo_as_text) {\n\t\t\t\t\tphp_info_print_html_esc(key, len-1);\n\t\t\t\t} else {\n\t\t\t\t\tphp_info_print(key);\n\t\t\t\t}\n\t\t\t\tzend_hash_move_forward_ex(ht, &pos);\n\t\t\t\tif (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) {\n\t\t\t\t\tphp_info_print(\", \");\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!sapi_module.phpinfo_as_text) {\n\t\t\t\tphp_info_print(\"<\/td><\/tr>\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\tchar reg_name[128];\n\t\t\tsnprintf(reg_name, sizeof(reg_name), \"Registered %s\", name);\n\t\t\tphp_info_print_table_row(2, reg_name, \"none registered\");\n\t\t}\n\t} else {\n\t\tphp_info_print_table_row(2, name, \"disabled\");\n\t}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":431137,"func":"    Status processUsers(OperationContext* opCtx,\n                        AuthorizationManager* authzManager,\n                        StringData usersCollName,\n                        StringData db,\n                        bool drop) {\n        \/\/ When the \"drop\" argument has been provided, we use this set to store the users\n        \/\/ that are currently in the system, and remove from it as we encounter\n        \/\/ same-named users in the collection we are restoring from.  Once we've fully\n        \/\/ moved over the temp users collection into its final location, we drop\n        \/\/ any users that previously existed there but weren't in the temp collection.\n        \/\/ This is so that we can completely replace the system.users\n        \/\/ collection with the users from the temp collection, without removing all\n        \/\/ users at the beginning and thus potentially locking ourselves out by having\n        \/\/ no users in the whole system for a time.\n        stdx::unordered_set<UserName> usersToDrop;\n\n        if (drop) {\n            \/\/ Create map of the users currently in the DB\n            BSONObj query =\n                db.empty() ? BSONObj() : BSON(AuthorizationManager::USER_DB_FIELD_NAME << db);\n            BSONObj fields = BSON(AuthorizationManager::USER_NAME_FIELD_NAME\n                                  << 1\n                                  << AuthorizationManager::USER_DB_FIELD_NAME\n                                  << 1);\n\n            Status status =\n                queryAuthzDocument(opCtx,\n                                   AuthorizationManager::usersCollectionNamespace,\n                                   query,\n                                   fields,\n                                   [&](const BSONObj& userObj) {\n                                       usersToDrop.insert(extractUserNameFromBSON(userObj));\n                                   });\n            if (!status.isOK()) {\n                return status;\n            }\n        }\n\n        Status status = queryAuthzDocument(\n            opCtx,\n            NamespaceString(usersCollName),\n            db.empty() ? BSONObj() : BSON(AuthorizationManager::USER_DB_FIELD_NAME << db),\n            BSONObj(),\n            [&](const BSONObj& userObj) {\n                return addUser(opCtx, authzManager, db, drop, &usersToDrop, userObj);\n            });\n        if (!status.isOK()) {\n            return status;\n        }\n\n        if (drop) {\n            long long numRemoved;\n            for (const UserName& userName : usersToDrop) {\n                audit::logDropUser(Client::getCurrent(), userName);\n                status = removePrivilegeDocuments(opCtx,\n                                                  BSON(AuthorizationManager::USER_NAME_FIELD_NAME\n                                                       << userName.getUser().toString()\n                                                       << AuthorizationManager::USER_DB_FIELD_NAME\n                                                       << userName.getDB().toString()),\n                                                  &numRemoved);\n                if (!status.isOK()) {\n                    return status;\n                }\n                dassert(numRemoved == 1);\n            }\n        }\n\n        return Status::OK();\n    }","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":74565,"func":"bgp_print(netdissect_options *ndo,\n          const u_char *dat, int length)\n{\n\tconst u_char *p;\n\tconst u_char *ep;\n\tconst u_char *start;\n\tconst u_char marker[] = {\n\t\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n\t\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n\t};\n\tstruct bgp bgp;\n\tuint16_t hlen;\n\n\tep = dat + length;\n\tif (ndo->ndo_snapend < dat + length)\n\t\tep = ndo->ndo_snapend;\n\n\tND_PRINT((ndo, \": BGP\"));\n\n        if (ndo->ndo_vflag < 1) \/* lets be less chatty *\/\n                return;\n\n\tp = dat;\n\tstart = p;\n\twhile (p < ep) {\n\t\tif (!ND_TTEST2(p[0], 1))\n\t\t\tbreak;\n\t\tif (p[0] != 0xff) {\n\t\t\tp++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!ND_TTEST2(p[0], sizeof(marker)))\n\t\t\tbreak;\n\t\tif (memcmp(p, marker, sizeof(marker)) != 0) {\n\t\t\tp++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* found BGP header *\/\n\t\tND_TCHECK2(p[0], BGP_SIZE);\t\/*XXX*\/\n\t\tmemcpy(&bgp, p, BGP_SIZE);\n\n\t\tif (start != p)\n\t\t\tND_PRINT((ndo, \" [|BGP]\"));\n\n\t\thlen = ntohs(bgp.bgp_len);\n\t\tif (hlen < BGP_SIZE) {\n\t\t\tND_PRINT((ndo, \"\\n[|BGP Bogus header length %u < %u]\", hlen,\n\t\t\t    BGP_SIZE));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (ND_TTEST2(p[0], hlen)) {\n\t\t\tif (!bgp_header_print(ndo, p, hlen))\n\t\t\t\treturn;\n\t\t\tp += hlen;\n\t\t\tstart = p;\n\t\t} else {\n\t\t\tND_PRINT((ndo, \"\\n[|BGP %s]\",\n\t\t\t       tok2str(bgp_msg_values,\n\t\t\t\t\t  \"Unknown Message Type\",\n\t\t\t\t\t  bgp.bgp_type)));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \" [|BGP]\"));\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":31116,"func":"static void writer_print_data ( WriterContext * wctx , const char * name , uint8_t * data , int size ) {\n AVBPrint bp ;\n int offset = 0 , l , i ;\n av_bprint_init ( & bp , 0 , AV_BPRINT_SIZE_UNLIMITED ) ;\n av_bprintf ( & bp , \"\\n\" ) ;\n while ( size ) {\n av_bprintf ( & bp , \"%08x: \" , offset ) ;\n l = FFMIN ( size , 16 ) ;\n for ( i = 0 ;\n i < l ;\n i ++ ) {\n av_bprintf ( & bp , \"%02x\" , data [ i ] ) ;\n if ( i & 1 ) av_bprintf ( & bp , \" \" ) ;\n }\n av_bprint_chars ( & bp , ' ' , 41 - 2 * i - i \/ 2 ) ;\n for ( i = 0 ;\n i < l ;\n i ++ ) av_bprint_chars ( & bp , data [ i ] - 32U < 95 ? data [ i ] : '.' , 1 ) ;\n av_bprintf ( & bp , \"\\n\" ) ;\n offset += l ;\n data += l ;\n size -= l ;\n }\n writer_print_string ( wctx , name , bp . str , 0 ) ;\n av_bprint_finalize ( & bp , NULL ) ;\n }","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":39157,"func":"read_StreamsInfo(struct archive_read *a, struct _7z_stream_info *si)\n{\n\tstruct _7zip *zip = (struct _7zip *)a->format->data;\n\tconst unsigned char *p;\n\tunsigned i;\n\n\tmemset(si, 0, sizeof(*si));\n\n\tif ((p = header_bytes(a, 1)) == NULL)\n\t\treturn (-1);\n\tif (*p == kPackInfo) {\n\t\tuint64_t packPos;\n\n\t\tif (read_PackInfo(a, &(si->pi)) < 0)\n\t\t\treturn (-1);\n\n\t\tif (si->pi.positions == NULL || si->pi.sizes == NULL)\n\t\t\treturn (-1);\n\t\t\/*\n\t\t * Calculate packed stream positions.\n\t\t *\/\n\t\tpackPos = si->pi.pos;\n\t\tfor (i = 0; i < si->pi.numPackStreams; i++) {\n\t\t\tsi->pi.positions[i] = packPos;\n\t\t\tpackPos += si->pi.sizes[i];\n\t\t\tif (packPos > zip->header_offset)\n\t\t\t\treturn (-1);\n\t\t}\n\t\tif ((p = header_bytes(a, 1)) == NULL)\n\t\t\treturn (-1);\n\t}\n\tif (*p == kUnPackInfo) {\n\t\tuint32_t packIndex;\n\t\tstruct _7z_folder *f;\n\n\t\tif (read_CodersInfo(a, &(si->ci)) < 0)\n\t\t\treturn (-1);\n\n\t\t\/*\n\t\t * Calculate packed stream indexes.\n\t\t *\/\n\t\tpackIndex = 0;\n\t\tf = si->ci.folders;\n\t\tfor (i = 0; i < si->ci.numFolders; i++) {\n\t\t\tf[i].packIndex = packIndex;\n\t\t\tpackIndex += (uint32_t)f[i].numPackedStreams;\n\t\t\tif (packIndex > si->pi.numPackStreams)\n\t\t\t\treturn (-1);\n\t\t}\n\t\tif ((p = header_bytes(a, 1)) == NULL)\n\t\t\treturn (-1);\n\t}\n\n\tif (*p == kSubStreamsInfo) {\n\t\tif (read_SubStreamsInfo(a, &(si->ss),\n\t\t    si->ci.folders, (size_t)si->ci.numFolders) < 0)\n\t\t\treturn (-1);\n\t\tif ((p = header_bytes(a, 1)) == NULL)\n\t\t\treturn (-1);\n\t}\n\n\t\/*\n\t *  Must be kEnd.\n\t *\/\n\tif (*p != kEnd)\n\t\treturn (-1);\n\treturn (0);\n}","target":0,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":93813,"func":"size_t HTTPSession::sendCertificateRequest(\n    std::unique_ptr<folly::IOBuf> certificateRequestContext,\n    std::vector<fizz::Extension> extensions) {\n  \/\/ Check if both sending and receiving peer have advertised valid\n  \/\/ SETTINGS_HTTP_CERT_AUTH setting. Otherwise, the frames for secondary\n  \/\/ authentication should not be sent.\n  auto ingressSettings = codec_->getIngressSettings();\n  auto egressSettings = codec_->getEgressSettings();\n  if (ingressSettings && egressSettings) {\n    if (ingressSettings->getSetting(SettingsId::SETTINGS_HTTP_CERT_AUTH, 0) ==\n            0 ||\n        egressSettings->getSetting(SettingsId::SETTINGS_HTTP_CERT_AUTH, 0) ==\n            0) {\n      VLOG(4) << \"Secondary certificate authentication is not supported.\";\n      return 0;\n    }\n  }\n  auto authRequest = secondAuthManager_->createAuthRequest(\n      std::move(certificateRequestContext), std::move(extensions));\n  auto encodedSize = codec_->generateCertificateRequest(\n      writeBuf_, authRequest.first, std::move(authRequest.second));\n  if (encodedSize > 0) {\n    scheduleWrite();\n  } else {\n    VLOG(4) << \"Failed to generate CERTIFICATE_REQUEST frame.\";\n  }\n  return encodedSize;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":268962,"func":"static int read_fragment_table(long long *table_start)\n{\n\t\/*\n\t * Note on overflow limits:\n\t * Size of SBlk.s.fragments is 2^32 (unsigned int)\n\t * Max size of bytes is 2^32*16 or 2^36\n\t * Max indexes is (2^32*16)\/8K or 2^23\n\t * Max length is ((2^32*16)\/8K)*8 or 2^26 or 64M\n\t *\/\n\tint res;\n\tunsigned int i;\n\tlong long bytes = SQUASHFS_FRAGMENT_BYTES((long long) sBlk.s.fragments);\n\tint indexes = SQUASHFS_FRAGMENT_INDEXES((long long) sBlk.s.fragments);\n\tint length = SQUASHFS_FRAGMENT_INDEX_BYTES((long long) sBlk.s.fragments);\n\tlong long *fragment_table_index;\n\n\t\/*\n\t * The size of the index table (length bytes) should match the\n\t * table start and end points\n\t *\/\n\tif(length != (*table_start - sBlk.s.fragment_table_start)) {\n\t\tERROR(\"read_fragment_table: Bad fragment count in super block\\n\");\n\t\treturn FALSE;\n\t}\n\n\tTRACE(\"read_fragment_table: %u fragments, reading %d fragment indexes \"\n\t\t\"from 0x%llx\\n\", sBlk.s.fragments, indexes,\n\t\tsBlk.s.fragment_table_start);\n\n\tfragment_table_index = alloc_index_table(indexes);\n\tfragment_table = malloc(bytes);\n\tif(fragment_table == NULL)\n\t\tMEM_ERROR();\n\n\tres = read_fs_bytes(fd, sBlk.s.fragment_table_start, length,\n\t\t\t\t\t\t\tfragment_table_index);\n\tif(res == FALSE) {\n\t\tERROR(\"read_fragment_table: failed to read fragment table \"\n\t\t\t\"index\\n\");\n\t\treturn FALSE;\n\t}\n\tSQUASHFS_INSWAP_FRAGMENT_INDEXES(fragment_table_index, indexes);\n\n\tfor(i = 0; i < indexes; i++) {\n\t\tint expected = (i + 1) != indexes ? SQUASHFS_METADATA_SIZE :\n\t\t\t\t\tbytes & (SQUASHFS_METADATA_SIZE - 1);\n\t\tint length = read_block(fd, fragment_table_index[i], NULL,\n\t\t\texpected, ((char *) fragment_table) + (i *\n\t\t\tSQUASHFS_METADATA_SIZE));\n\t\tTRACE(\"Read fragment table block %d, from 0x%llx, length %d\\n\",\n\t\t\ti, fragment_table_index[i], length);\n\t\tif(length == FALSE) {\n\t\t\tERROR(\"read_fragment_table: failed to read fragment \"\n\t\t\t\t\"table index\\n\");\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\tfor(i = 0; i < sBlk.s.fragments; i++) \n\t\tSQUASHFS_INSWAP_FRAGMENT_ENTRY(&fragment_table[i]);\n\n\t*table_start = fragment_table_index[0];\n\treturn TRUE;\n}","target":0,"code_token_length":596,"total_token_length":832,"max_tokens_setting":1024}
+{"idx":373266,"func":"struct socket_context *tls_init_client(struct socket_context *socket_ctx,\n\t\t\t\t       struct tevent_fd *fde,\n\t\t\t\t       const char *ca_path)\n{\n\tstruct tls_context *tls;\n\tint ret = 0;\n\tconst int cert_type_priority[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };\n\tstruct socket_context *new_sock;\n\tNTSTATUS nt_status;\n\t\n\tnt_status = socket_create_with_ops(socket_ctx, &tls_socket_ops, &new_sock, \n\t\t\t\t\t   SOCKET_TYPE_STREAM, \n\t\t\t\t\t   socket_ctx->flags | SOCKET_FLAG_ENCRYPT);\n\tif (!NT_STATUS_IS_OK(nt_status)) {\n\t\treturn NULL;\n\t}\n\n\ttls = talloc(new_sock, struct tls_context);\n\tif (tls == NULL) return NULL;\n\n\ttls->socket          = socket_ctx;\n\ttalloc_steal(tls, socket_ctx);\n\ttls->fde             = fde;\n\n\tnew_sock->private_data    = tls;\n\n\tgnutls_global_init();\n\n\tgnutls_certificate_allocate_credentials(&tls->xcred);\n\tgnutls_certificate_set_x509_trust_file(tls->xcred, ca_path, GNUTLS_X509_FMT_PEM);\n\tTLSCHECK(gnutls_init(&tls->session, GNUTLS_CLIENT));\n\tTLSCHECK(gnutls_set_default_priority(tls->session));\n\tgnutls_certificate_type_set_priority(tls->session, cert_type_priority);\n\tTLSCHECK(gnutls_credentials_set(tls->session, GNUTLS_CRD_CERTIFICATE, tls->xcred));\n\n\ttalloc_set_destructor(tls, tls_destructor);\n\n\tgnutls_transport_set_ptr(tls->session, (gnutls_transport_ptr)tls);\n\tgnutls_transport_set_pull_function(tls->session, (gnutls_pull_func)tls_pull);\n\tgnutls_transport_set_push_function(tls->session, (gnutls_push_func)tls_push);\n#if GNUTLS_VERSION_MAJOR < 3\n\tgnutls_transport_set_lowat(tls->session, 0);\n#endif\n\ttls->tls_detect = false;\n\n\ttls->output_pending  = false;\n\ttls->done_handshake  = false;\n\ttls->have_first_byte = false;\n\ttls->tls_enabled     = true;\n\ttls->interrupted     = false;\n\t\n\tnew_sock->state = SOCKET_STATE_CLIENT_CONNECTED;\n\n\treturn new_sock;\n\nfailed:\n\tDEBUG(0,(\"TLS init connection failed - %s\\n\", gnutls_strerror(ret)));\n\ttls->tls_enabled = false;\n\treturn new_sock;\n}","target":0,"code_token_length":532,"total_token_length":768,"max_tokens_setting":1024}
+{"idx":212575,"func":"PHP_METHOD(Phar, unlinkArchive)\n{\n\tchar *fname, *error, *zname, *arch, *entry;\n\tsize_t fname_len;\n        int zname_len, arch_len, entry_len;\n        phar_archive_data *phar;\n \n       if (zend_parse_parameters(ZEND_NUM_ARGS(), \"p\", &fname, &fname_len) == FAILURE) {\n                RETURN_FALSE;\n        }\n \n\tif (!fname_len) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown phar archive \\\"\\\"\");\n\t\treturn;\n\t}\n\n\tif (FAILURE == phar_open_from_filename(fname, fname_len, NULL, 0, REPORT_ERRORS, &phar, &error)) {\n\t\tif (error) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown phar archive \\\"%s\\\": %s\", fname, error);\n\t\t\tefree(error);\n\t\t} else {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"Unknown phar archive \\\"%s\\\"\", fname);\n\t\t}\n\t\treturn;\n\t}\n\n\tzname = (char*)zend_get_executed_filename();\n\tzname_len = strlen(zname);\n\n\tif (zname_len > 7 && !memcmp(zname, \"phar:\/\/\", 7) && SUCCESS == phar_split_fname(zname, zname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) {\n\t\tif (arch_len == fname_len && !memcmp(arch, fname, arch_len)) {\n\t\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar archive \\\"%s\\\" cannot be unlinked from within itself\", fname);\n\t\t\tefree(arch);\n\t\t\tefree(entry);\n\t\t\treturn;\n\t\t}\n\t\tefree(arch);\n\t\tefree(entry);\n\t}\n\n\tif (phar->is_persistent) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar archive \\\"%s\\\" is in phar.cache_list, cannot unlinkArchive()\", fname);\n\t\treturn;\n\t}\n\n\tif (phar->refcount) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar archive \\\"%s\\\" has open file handles or objects.  fclose() all file handles, and unset() all objects prior to calling unlinkArchive()\", fname);\n\t\treturn;\n\t}\n\n\tfname = estrndup(phar->fname, phar->fname_len);\n\n\t\/* invalidate phar cache *\/\n\tPHAR_G(last_phar) = NULL;\n\tPHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;\n\n\tphar_archive_delref(phar);\n\tunlink(fname);\n\tefree(fname);\n\tRETURN_TRUE;\n}\n","target":0,"code_token_length":587,"total_token_length":823,"max_tokens_setting":1024}
+{"idx":340017,"func":"static int init_er(MpegEncContext *s)\n\n{\n\n    ERContext *er = &s->er;\n\n    int mb_array_size = s->mb_height * s->mb_stride;\n\n    int i;\n\n\n\n    er->avctx       = s->avctx;\n\n    er->mecc        = &s->mecc;\n\n\n\n    er->mb_index2xy = s->mb_index2xy;\n\n    er->mb_num      = s->mb_num;\n\n    er->mb_width    = s->mb_width;\n\n    er->mb_height   = s->mb_height;\n\n    er->mb_stride   = s->mb_stride;\n\n    er->b8_stride   = s->b8_stride;\n\n\n\n    er->er_temp_buffer     = av_malloc(s->mb_height * s->mb_stride);\n\n    er->error_status_table = av_mallocz(mb_array_size);\n\n    if (!er->er_temp_buffer || !er->error_status_table)\n\n        goto fail;\n\n\n\n    er->mbskip_table  = s->mbskip_table;\n\n    er->mbintra_table = s->mbintra_table;\n\n\n\n    for (i = 0; i < FF_ARRAY_ELEMS(s->dc_val); i++)\n\n        er->dc_val[i] = s->dc_val[i];\n\n\n\n    er->decode_mb = mpeg_er_decode_mb;\n\n    er->opaque    = s;\n\n\n\n    return 0;\n\nfail:\n\n    av_freep(&er->er_temp_buffer);\n\n    av_freep(&er->error_status_table);\n\n    return AVERROR(ENOMEM);\n\n}\n","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":70945,"func":"struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len,\n\t\t\t\t   gfp_t gfp_mask)\n{\n\tstruct page_frag_cache *nc;\n\tunsigned long flags;\n\tstruct sk_buff *skb;\n\tbool pfmemalloc;\n\tvoid *data;\n\n\tlen += NET_SKB_PAD;\n\n\tif ((len > SKB_WITH_OVERHEAD(PAGE_SIZE)) ||\n\t    (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) {\n\t\tskb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE);\n\t\tif (!skb)\n\t\t\tgoto skb_fail;\n\t\tgoto skb_success;\n\t}\n\n\tlen += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));\n\tlen = SKB_DATA_ALIGN(len);\n\n\tif (sk_memalloc_socks())\n\t\tgfp_mask |= __GFP_MEMALLOC;\n\n\tlocal_irq_save(flags);\n\n\tnc = this_cpu_ptr(&netdev_alloc_cache);\n\tdata = page_frag_alloc(nc, len, gfp_mask);\n\tpfmemalloc = nc->pfmemalloc;\n\n\tlocal_irq_restore(flags);\n\n\tif (unlikely(!data))\n\t\treturn NULL;\n\n\tskb = __build_skb(data, len);\n\tif (unlikely(!skb)) {\n\t\tskb_free_frag(data);\n\t\treturn NULL;\n\t}\n\n\t\/* use OR instead of assignment to avoid clearing of bits in mask *\/\n\tif (pfmemalloc)\n\t\tskb->pfmemalloc = 1;\n\tskb->head_frag = 1;\n\nskb_success:\n\tskb_reserve(skb, NET_SKB_PAD);\n\tskb->dev = dev;\n\nskb_fail:\n\treturn skb;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":215395,"func":"xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {\n int res = 0;\n\n \/*\n     * It's Okay to use CUR\/NEXT here since all the blanks are on\n     * the ASCII range.\n     *\/\n if ((ctxt->inputNr == 1) && (ctxt->instate != XML_PARSER_DTD)) {\n const xmlChar *cur;\n \/*\n\t * if we are in the document content, go really fast\n\t *\/\n\tcur = ctxt->input->cur;\n while (IS_BLANK_CH(*cur)) {\n if (*cur == '\\n') {\n\t\tctxt->input->line++; ctxt->input->col = 1;\n } else {\n\t\tctxt->input->col++;\n }\n\t    cur++;\n\t    res++;\n if (*cur == 0) {\n\t\tctxt->input->cur = cur;\n\t\txmlParserInputGrow(ctxt->input, INPUT_CHUNK);\n\t\tcur = ctxt->input->cur;\n }\n }\n\tctxt->input->cur = cur;\n } else {\n int cur;\n do {\n\t    cur = CUR;\n while ((IS_BLANK_CH(cur) && \/* CHECKED tstblanks.xml *\/\n (ctxt->instate != XML_PARSER_EOF))) {\n\t\tNEXT;\n\t\tcur = CUR;\n\t\tres++;\n }\n while ((cur == 0) && (ctxt->inputNr > 1) &&\n (ctxt->instate != XML_PARSER_COMMENT)) {\n\t\txmlPopInput(ctxt);\n\t\tcur = CUR;\n }\n \/*\n\t     * Need to handle support of entities branching here\n\t     *\/\n if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);\n } while ((IS_BLANK(cur)) && \/* CHECKED tstblanks.xml *\/\n (ctxt->instate != XML_PARSER_EOF));\n }\n return(res);\n}\n","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":333992,"func":"static void decode_band_structure(GetBitContext *gbc, int blk, int eac3,\n\n                                  int ecpl, int start_subband, int end_subband,\n\n                                  const uint8_t *default_band_struct,\n\n                                  int *num_bands, uint8_t *band_sizes)\n\n{\n\n    int subbnd, bnd, n_subbands, n_bands=0;\n\n    uint8_t bnd_sz[22];\n\n    uint8_t coded_band_struct[22];\n\n    const uint8_t *band_struct;\n\n\n\n    n_subbands = end_subband - start_subband;\n\n\n\n    \/* decode band structure from bitstream or use default *\/\n\n    if (!eac3 || get_bits1(gbc)) {\n\n        for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {\n\n            coded_band_struct[subbnd] = get_bits1(gbc);\n\n        }\n\n        band_struct = coded_band_struct;\n\n    } else if (!blk) {\n\n        band_struct = &default_band_struct[start_subband+1];\n\n    } else {\n\n        \/* no change in band structure *\/\n\n        return;\n\n    }\n\n\n\n    \/* calculate number of bands and band sizes based on band structure.\n\n       note that the first 4 subbands in enhanced coupling span only 6 bins\n\n       instead of 12. *\/\n\n    if (num_bands || band_sizes ) {\n\n        n_bands = n_subbands;\n\n        bnd_sz[0] = ecpl ? 6 : 12;\n\n        for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {\n\n            int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;\n\n            if (band_struct[subbnd - 1]) {\n\n                n_bands--;\n\n                bnd_sz[bnd] += subbnd_size;\n\n            } else {\n\n                bnd_sz[++bnd] = subbnd_size;\n\n            }\n\n        }\n\n    }\n\n\n\n    \/* set optional output params *\/\n\n    if (num_bands)\n\n        *num_bands = n_bands;\n\n    if (band_sizes)\n\n        memcpy(band_sizes, bnd_sz, n_bands);\n\n}\n","target":1,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":121114,"func":"    int32 JavascriptArray::HeadSegmentIndexOfHelper(Var search, uint32 &fromIndex, uint32 toIndex, bool includesAlgorithm, ScriptContext * scriptContext)\n    {\n        Assert(Is(GetTypeId()) && !JavascriptNativeArray::Is(GetTypeId()));\n\n        if (!HasNoMissingValues() || fromIndex >= GetHead()->length)\n        {\n            return -1;\n        }\n\n        bool isSearchTaggedInt = TaggedInt::Is(search);\n        \/\/ We need to cast head segment to SparseArraySegment<Var> to have access to GetElement (onSparseArraySegment<T>). Because there are separate overloads of this\n        \/\/ virtual method on JavascriptNativeIntArray and JavascriptNativeFloatArray, we know this version of this method will only be called for true JavascriptArray, and not for\n        \/\/ either of the derived native arrays, so the elements of each segment used here must be Vars. Hence, the cast is safe.\n        SparseArraySegment<Var>* head = static_cast<SparseArraySegment<Var>*>(GetHead());\n        uint32 toIndexTrimmed = toIndex <= head->length ? toIndex : head->length;\n        for (uint32 i = fromIndex; i < toIndexTrimmed; i++)\n        {\n            Var element = head->GetElement(i);\n            if (isSearchTaggedInt && TaggedInt::Is(element))\n            {\n                if (search == element)\n                {\n                    return i;\n                }\n            }\n            else if (includesAlgorithm && JavascriptConversion::SameValueZero(element, search))\n            {\n                \/\/Array.prototype.includes\n                return i;\n            }\n            else if (JavascriptOperators::StrictEqual(element, search, scriptContext))\n            {\n                \/\/Array.prototype.indexOf\n                return i;\n            }\n        }\n\n        \/\/ Element not found in the head segment. Keep looking only if the range of indices extends past\n        \/\/ the head segment.\n        fromIndex = toIndex > GetHead()->length ? GetHead()->length : -1;\n        return -1;\n    }","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":338112,"func":"static void gen_spr_book3s_pmu_sup(CPUPPCState *env)\n\n{\n\n    spr_register(env, SPR_POWER_MMCR0, \"MMCR0\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_MMCR1, \"MMCR1\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_MMCRA, \"MMCRA\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_PMC1, \"PMC1\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_PMC2, \"PMC2\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_PMC3, \"PMC3\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_PMC4, \"PMC4\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_PMC5, \"PMC5\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_PMC6, \"PMC6\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_SIAR, \"SIAR\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    spr_register(env, SPR_POWER_SDAR, \"SDAR\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n}\n","target":1,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":190193,"func":"GpuProcessHost::~GpuProcessHost() {\n  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);\n  if (in_process_gpu_thread_)\n    DCHECK(process_);\n\n  SendOutstandingReplies(EstablishChannelStatus::GPU_HOST_INVALID);\n\n#if defined(OS_MACOSX)\n  ca_transaction_gpu_coordinator_->HostWillBeDestroyed();\n  ca_transaction_gpu_coordinator_ = nullptr;\n#endif\n\n  if (status_ == UNKNOWN) {\n    RunRequestGPUInfoCallbacks(gpu::GPUInfo());\n  } else {\n    DCHECK(request_gpu_info_callbacks_.empty());\n  }\n\n  while (!queued_messages_.empty()) {\n    delete queued_messages_.front();\n    queued_messages_.pop();\n  }\n\n  if (g_gpu_process_hosts[kind_] == this)\n    g_gpu_process_hosts[kind_] = nullptr;\n\n#if defined(OS_ANDROID)\n  UMA_HISTOGRAM_COUNTS_100(\"GPU.AtExitSurfaceCount\",\n                           gpu::GpuSurfaceTracker::Get()->GetSurfaceCount());\n#endif\n\n  std::string message;\n  bool block_offscreen_contexts = true;\n  if (!in_process_ && process_launched_) {\n    ChildProcessTerminationInfo info =\n        process_->GetTerminationInfo(false \/* known_dead *\/);\n    UMA_HISTOGRAM_ENUMERATION(\"GPU.GPUProcessTerminationStatus2\",\n                              ConvertToGpuTerminationStatus(info.status),\n                              GpuTerminationStatus::MAX_ENUM);\n\n    if (info.status == base::TERMINATION_STATUS_NORMAL_TERMINATION ||\n        info.status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||\n        info.status == base::TERMINATION_STATUS_PROCESS_CRASHED) {\n      base::UmaHistogramSparse(\"GPU.GPUProcessExitCode\",\n                               std::max(0, std::min(100, info.exit_code)));\n    }\n\n    switch (info.status) {\n      case base::TERMINATION_STATUS_NORMAL_TERMINATION:\n#if defined(OS_ANDROID)\n        block_offscreen_contexts = false;\n#endif\n        message = \"The GPU process exited normally. Everything is okay.\";\n        break;\n      case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:\n        message = base::StringPrintf(\"The GPU process exited with code %d.\",\n                                     info.exit_code);\n        break;\n      case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:\n        message = \"You killed the GPU process! Why?\";\n        break;\n#if defined(OS_CHROMEOS)\n      case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM:\n        message = \"The GUP process was killed due to out of memory.\";\n        break;\n#endif\n      case base::TERMINATION_STATUS_PROCESS_CRASHED:\n        message = \"The GPU process crashed!\";\n        break;\n      case base::TERMINATION_STATUS_LAUNCH_FAILED:\n        message = \"The GPU process failed to start!\";\n        break;\n      default:\n        break;\n    }\n  }\n\n  if (block_offscreen_contexts)\n    BlockLiveOffscreenContexts();\n\n  BrowserThread::PostTask(\n      BrowserThread::UI, FROM_HERE,\n      base::BindOnce(&OnGpuProcessHostDestroyedOnUI, host_id_, message));\n}\n","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":354519,"func":"static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)\n{\n\tstruct ifconf32 ifc32;\n\tstruct ifconf ifc;\n\tstruct ifconf __user *uifc;\n\tstruct ifreq32 __user *ifr32;\n\tstruct ifreq __user *ifr;\n\tunsigned int i, j;\n\tint err;\n\n\tif (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))\n\t\treturn -EFAULT;\n\n\tif (ifc32.ifcbuf == 0) {\n\t\tifc32.ifc_len = 0;\n\t\tifc.ifc_len = 0;\n\t\tifc.ifc_req = NULL;\n\t\tuifc = compat_alloc_user_space(sizeof(struct ifconf));\n\t} else {\n\t\tsize_t len =((ifc32.ifc_len \/ sizeof (struct ifreq32)) + 1) *\n\t\t\tsizeof (struct ifreq);\n\t\tuifc = compat_alloc_user_space(sizeof(struct ifconf) + len);\n\t\tifc.ifc_len = len;\n\t\tifr = ifc.ifc_req = (void __user *)(uifc + 1);\n\t\tifr32 = compat_ptr(ifc32.ifcbuf);\n\t\tfor (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {\n\t\t\tif (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))\n\t\t\t\treturn -EFAULT;\n\t\t\tifr++;\n\t\t\tifr32++; \n\t\t}\n\t}\n\tif (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))\n\t\treturn -EFAULT;\n\n\terr = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);\t\n\tif (err)\n\t\treturn err;\n\n\tif (copy_from_user(&ifc, uifc, sizeof(struct ifconf))) \n\t\treturn -EFAULT;\n\n\tifr = ifc.ifc_req;\n\tifr32 = compat_ptr(ifc32.ifcbuf);\n\tfor (i = 0, j = 0;\n             i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;\n\t     i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {\n\t\tif (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))\n\t\t\treturn -EFAULT;\n\t\tifr32++;\n\t\tifr++;\n\t}\n\n\tif (ifc32.ifcbuf == 0) {\n\t\t\/* Translate from 64-bit structure multiple to\n\t\t * a 32-bit one.\n\t\t *\/\n\t\ti = ifc.ifc_len;\n\t\ti = ((i \/ sizeof(struct ifreq)) * sizeof(struct ifreq32));\n\t\tifc32.ifc_len = i;\n\t} else {\n\t\tifc32.ifc_len = i;\n\t}\n\tif (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":436910,"func":"static void fts3UpdateDocTotals(\n  int *pRC,                       \/* The result code *\/\n  Fts3Table *p,                   \/* Table being updated *\/\n  u32 *aSzIns,                    \/* Size increases *\/\n  u32 *aSzDel,                    \/* Size decreases *\/\n  int nChng                       \/* Change in the number of documents *\/\n){\n  char *pBlob;             \/* Storage for BLOB written into %_stat *\/\n  int nBlob;               \/* Size of BLOB written into %_stat *\/\n  u32 *a;                  \/* Array of integers that becomes the BLOB *\/\n  sqlite3_stmt *pStmt;     \/* Statement for reading and writing *\/\n  int i;                   \/* Loop counter *\/\n  int rc;                  \/* Result code from subfunctions *\/\n\n  const int nStat = p->nColumn+2;\n\n  if( *pRC ) return;\n  a = sqlite3_malloc64( (sizeof(u32)+10)*(sqlite3_int64)nStat );\n  if( a==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  pBlob = (char*)&a[nStat];\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    fts3DecodeIntArray(nStat, a,\n         sqlite3_column_blob(pStmt, 0),\n         sqlite3_column_bytes(pStmt, 0));\n  }else{\n    memset(a, 0, sizeof(u32)*(nStat) );\n  }\n  rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  if( nChng<0 && a[0]<(u32)(-nChng) ){\n    a[0] = 0;\n  }else{\n    a[0] += nChng;\n  }\n  for(i=0; i<p->nColumn+1; i++){\n    u32 x = a[i+1];\n    if( x+aSzIns[i] < aSzDel[i] ){\n      x = 0;\n    }else{\n      x = x + aSzIns[i] - aSzDel[i];\n    }\n    a[i+1] = x;\n  }\n  fts3EncodeIntArray(nStat, a, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n  sqlite3_bind_null(pStmt, 2);\n  sqlite3_free(a);\n}","target":0,"code_token_length":682,"total_token_length":918,"max_tokens_setting":1024}
+{"idx":430196,"func":"int htp_hdr_keycb(llhttp_t *htp, const char *data, size_t len) {\n  auto upstream = static_cast<HttpsUpstream *>(htp->data);\n  auto downstream = upstream->get_downstream();\n  auto &req = downstream->request();\n  auto &httpconf = get_config()->http;\n\n  if (req.fs.buffer_size() + len > httpconf.request_header_field_buffer) {\n    if (LOG_ENABLED(INFO)) {\n      ULOG(INFO, upstream) << \"Too large header block size=\"\n                           << req.fs.buffer_size() + len;\n    }\n    if (downstream->get_request_state() == DownstreamState::INITIAL) {\n      downstream->set_request_state(\n          DownstreamState::HTTP1_REQUEST_HEADER_TOO_LARGE);\n    }\n    llhttp_set_error_reason(htp, \"too large header\");\n    return HPE_USER;\n  }\n  if (downstream->get_request_state() == DownstreamState::INITIAL) {\n    if (req.fs.header_key_prev()) {\n      req.fs.append_last_header_key(data, len);\n    } else {\n      if (req.fs.num_fields() >= httpconf.max_request_header_fields) {\n        if (LOG_ENABLED(INFO)) {\n          ULOG(INFO, upstream)\n              << \"Too many header field num=\" << req.fs.num_fields() + 1;\n        }\n        downstream->set_request_state(\n            DownstreamState::HTTP1_REQUEST_HEADER_TOO_LARGE);\n        llhttp_set_error_reason(htp, \"too many headers\");\n        return HPE_USER;\n      }\n      req.fs.alloc_add_header_name(StringRef{data, len});\n    }\n  } else {\n    \/\/ trailer part\n    if (req.fs.trailer_key_prev()) {\n      req.fs.append_last_trailer_key(data, len);\n    } else {\n      if (req.fs.num_fields() >= httpconf.max_request_header_fields) {\n        if (LOG_ENABLED(INFO)) {\n          ULOG(INFO, upstream)\n              << \"Too many header field num=\" << req.fs.num_fields() + 1;\n        }\n        llhttp_set_error_reason(htp, \"too many headers\");\n        return HPE_USER;\n      }\n      req.fs.alloc_add_trailer_name(StringRef{data, len});\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":316581,"func":"static MagickBooleanType WriteJNGImage(const ImageInfo *image_info,Image *image)\n{\n  MagickBooleanType\n    logging,\n    status;\n\n  MngInfo\n    *mng_info;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  logging=LogMagickEvent(CoderEvent,GetMagickModule(),\"Enter WriteJNGImage()\");\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  if ((image->columns > 65535UL) || (image->rows > 65535UL))\n    ThrowWriterException(ImageError,\"WidthOrHeightExceedsLimit\");\n\n  \/*\n    Allocate a MngInfo structure.\n  *\/\n  mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo));\n  if (mng_info == (MngInfo *) NULL)\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  \/*\n    Initialize members of the MngInfo structure.\n  *\/\n  (void) ResetMagickMemory(mng_info,0,sizeof(MngInfo));\n  mng_info->image=image;\n\n  (void) WriteBlob(image,8,(const unsigned char *) \"\\213JNG\\r\\n\\032\\n\");\n\n  status=WriteOneJNGImage(mng_info,image_info,image);\n  mng_info=MngInfoFreeStruct(mng_info);\n  (void) CloseBlob(image);\n\n  (void) CatchImageException(image);\n  if (logging != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"  exit WriteJNGImage()\");\n  return(status);\n}\n","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":57333,"func":"int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,\n\t\t__u64 start, __u64 len)\n{\n\text4_lblk_t start_blk;\n\tint error = 0;\n\n\t\/* fallback to generic here if not in extents fmt *\/\n\tif (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))\n\t\treturn generic_block_fiemap(inode, fieinfo, start, len,\n\t\t\text4_get_block);\n\n\tif (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))\n\t\treturn -EBADR;\n\n\tif (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {\n\t\terror = ext4_xattr_fiemap(inode, fieinfo);\n\t} else {\n\t\text4_lblk_t len_blks;\n\t\t__u64 last_blk;\n\n\t\tstart_blk = start >> inode->i_sb->s_blocksize_bits;\n\t\tlast_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits;\n\t\tif (last_blk >= EXT_MAX_BLOCK)\n\t\t\tlast_blk = EXT_MAX_BLOCK-1;\n\t\tlen_blks = ((ext4_lblk_t) last_blk) - start_blk + 1;\n\n\t\t\/*\n\t\t * Walk the extent tree gathering extent information.\n\t\t * ext4_ext_fiemap_cb will push extents back to user.\n\t\t *\/\n\t\terror = ext4_ext_walk_space(inode, start_blk, len_blks,\n\t\t\t\t\t  ext4_ext_fiemap_cb, fieinfo);\n\t}\n\n\treturn error;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":334847,"func":"static void mv88w8618_audio_write(void *opaque, target_phys_addr_t offset,\n\n                                  uint64_t value, unsigned size)\n\n{\n\n    mv88w8618_audio_state *s = opaque;\n\n\n\n    switch (offset) {\n\n    case MP_AUDIO_PLAYBACK_MODE:\n\n        if (value & MP_AUDIO_PLAYBACK_EN &&\n\n            !(s->playback_mode & MP_AUDIO_PLAYBACK_EN)) {\n\n            s->status = 0;\n\n            s->last_free = 0;\n\n            s->play_pos = 0;\n\n        }\n\n        s->playback_mode = value;\n\n        mv88w8618_audio_clock_update(s);\n\n        break;\n\n\n\n    case MP_AUDIO_CLOCK_DIV:\n\n        s->clock_div = value;\n\n        s->last_free = 0;\n\n        s->play_pos = 0;\n\n        mv88w8618_audio_clock_update(s);\n\n        break;\n\n\n\n    case MP_AUDIO_IRQ_STATUS:\n\n        s->status &= ~value;\n\n        break;\n\n\n\n    case MP_AUDIO_IRQ_ENABLE:\n\n        s->irq_enable = value;\n\n        if (s->status & s->irq_enable) {\n\n            qemu_irq_raise(s->irq);\n\n        }\n\n        break;\n\n\n\n    case MP_AUDIO_TX_START_LO:\n\n        s->phys_buf = (s->phys_buf & 0xFFFF0000) | (value & 0xFFFF);\n\n        s->target_buffer = s->phys_buf;\n\n        s->play_pos = 0;\n\n        s->last_free = 0;\n\n        break;\n\n\n\n    case MP_AUDIO_TX_THRESHOLD:\n\n        s->threshold = (value + 1) * 4;\n\n        break;\n\n\n\n    case MP_AUDIO_TX_START_HI:\n\n        s->phys_buf = (s->phys_buf & 0xFFFF) | (value << 16);\n\n        s->target_buffer = s->phys_buf;\n\n        s->play_pos = 0;\n\n        s->last_free = 0;\n\n        break;\n\n    }\n\n}\n","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":324146,"func":"static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,\n\n                                    int index, const int type)\n\n{\n\n    static const uint8_t *const scan_patterns[4] =\n\n    { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };\n\n\n\n    int run, level, sign, vlc, limit;\n\n    const int intra = (3 * type) >> 2;\n\n    const uint8_t *const scan = scan_patterns[type];\n\n\n\n    for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {\n\n        for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {\n\n\n\n          if (vlc == INVALID_VLC)\n\n              return -1;\n\n\n\n          sign = (vlc & 0x1) - 1;\n\n          vlc  = (vlc + 1) >> 1;\n\n\n\n          if (type == 3) {\n\n              if (vlc < 3) {\n\n                  run   = 0;\n\n                  level = vlc;\n\n              } else if (vlc < 4) {\n\n                  run   = 1;\n\n                  level = 1;\n\n              } else {\n\n                  run   = (vlc & 0x3);\n\n                  level = ((vlc + 9) >> 2) - run;\n\n              }\n\n          } else {\n\n              if (vlc < 16) {\n\n                  run   = svq3_dct_tables[intra][vlc].run;\n\n                  level = svq3_dct_tables[intra][vlc].level;\n\n              } else if (intra) {\n\n                  run   = (vlc & 0x7);\n\n                  level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1)));\n\n              } else {\n\n                  run   = (vlc & 0xF);\n\n                  level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0)));\n\n              }\n\n          }\n\n\n\n          if ((index += run) >= limit)\n\n              return -1;\n\n\n\n          block[scan[index]] = (level ^ sign) - sign;\n\n        }\n\n\n\n        if (type != 2) {\n\n            break;\n\n        }\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":280550,"func":"ExportTIFF_Date ( const SXMPMeta & xmp, const char * xmpNS, const char * xmpProp, TIFF_Manager * tiff, XMP_Uns16 mainID )\n{\n\tXMP_Uns8 mainIFD = kTIFF_ExifIFD;\n\tXMP_Uns16 fracID=0;\n\tswitch ( mainID ) {\n\t\tcase kTIFF_DateTime : mainIFD = kTIFF_PrimaryIFD; fracID = kTIFF_SubSecTime;\tbreak;\n\t\tcase kTIFF_DateTimeOriginal  : fracID = kTIFF_SubSecTimeOriginal;\tbreak;\n\t\tcase kTIFF_DateTimeDigitized : fracID = kTIFF_SubSecTimeDigitized;\tbreak;\n\t}\n\n\ttry {\t\/\/ Don't let errors with one stop the others.\n\n\t\tstd::string  xmpStr;\n\t\tbool foundXMP = xmp.GetProperty ( xmpNS, xmpProp, &xmpStr, 0 );\n\t\tif ( ! foundXMP ) {\n\t\t\ttiff->DeleteTag ( mainIFD, mainID );\n\t\t\ttiff->DeleteTag ( kTIFF_ExifIFD, fracID );\t\/\/ ! The subseconds are always in the Exif IFD.\n\t\t\treturn;\n\t\t}\n\n\n\t\tXMP_DateTime xmpBin;\n\t\tSXMPUtils::ConvertToDate ( xmpStr.c_str(), &xmpBin );\n\t\t\n\t\tchar buffer[24];\n\t\tsnprintf ( buffer, sizeof(buffer), \"%04d:%02d:%02d %02d:%02d:%02d\",\t\/\/ AUDIT: Use of sizeof(buffer) is safe.\n\t\t\t\t   xmpBin.year, xmpBin.month, xmpBin.day, xmpBin.hour, xmpBin.minute, xmpBin.second );\n\n\t\tsize_t xmpLen = xmpStr.size();\n\t\tif ( xmpLen < 18 ) {\n\t\t\tbuffer[17] = buffer[18] = ' ';\n\t\t\tif ( xmpLen < 15 ) {\n\t\t\t\tbuffer[14] = buffer[15] = ' ';\n\t\t\t\tif ( xmpLen < 12 ) {\n\t\t\t\t\tbuffer[11] = buffer[12] = ' ';\n\t\t\t\t\tif ( xmpLen < 9 ) {\n\t\t\t\t\t\tbuffer[8] = buffer[9] = ' ';\n\t\t\t\t\t\tif ( xmpLen < 6 ) {\n\t\t\t\t\t\t\tbuffer[5] = buffer[6] = ' ';\n\t\t\t\t\t\t\tif ( xmpLen < 1 ) {\n\t\t\t\t\t\t\t\tbuffer[0] = buffer[1] = buffer[2] = buffer[3] = ' ';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\ttiff->SetTag_ASCII ( mainIFD, mainID, buffer );\n\n\t\tif ( xmpBin.nanoSecond == 0 ) {\n\t\t\n\t\t\ttiff->DeleteTag ( kTIFF_ExifIFD, fracID );\n\t\t\n\t\t} else {\n\n\t\t\tsnprintf ( buffer, sizeof(buffer), \"%09d\", xmpBin.nanoSecond );\t\/\/ AUDIT: Use of sizeof(buffer) is safe.\n\t\t\tfor ( size_t i = strlen(buffer)-1; i > 0; --i ) {\n\t\t\t\tif ( buffer[i] != '0' ) break;\n\t\t\t\tbuffer[i] = 0;\t\/\/ Strip trailing zero digits.\n\t\t\t}\n\n\t\t\ttiff->SetTag_ASCII ( kTIFF_ExifIFD, fracID, buffer );\t\/\/ ! The subseconds are always in the Exif IFD.\n\n\t\t}\n\n\t} catch ( ... ) {\n\t}\n\n}\t\/\/ ExportTIFF_Date\n","target":0,"code_token_length":772,"total_token_length":1008,"max_tokens_setting":1024}
+{"idx":164589,"func":"RTCPeerConnectionHandler::RemoveTrackUnifiedPlan(\n    blink::WebRTCRtpSender* web_sender) {\n  DCHECK(task_runner_->RunsTasksInCurrentSequence());\n  DCHECK_EQ(configuration_.sdp_semantics, webrtc::SdpSemantics::kUnifiedPlan);\n  auto it = FindSender(web_sender->Id());\n  if (it == rtp_senders_.end())\n    return webrtc::RTCError(webrtc::RTCErrorType::INVALID_PARAMETER);\n  const auto& sender = *it;\n  auto webrtc_sender = sender->state().webrtc_sender();\n\n  TransceiverStateSurfacer transceiver_state_surfacer(task_runner_,\n                                                      signaling_thread());\n  bool result;\n  RunSynchronousClosureOnSignalingThread(\n      base::BindRepeating(\n          &RTCPeerConnectionHandler::RemoveTrackUnifiedPlanOnSignalingThread,\n          base::Unretained(this), base::RetainedRef(webrtc_sender),\n          base::Unretained(&transceiver_state_surfacer),\n          base::Unretained(&result)),\n      \"RemoveTrackUnifiedPlanOnSignalingThread\");\n  DCHECK(transceiver_state_surfacer.is_initialized());\n  if (!result) {\n    transceiver_state_surfacer.ObtainStates();\n    return webrtc::RTCError(webrtc::RTCErrorType::INTERNAL_ERROR);\n  }\n\n  auto transceiver_states = transceiver_state_surfacer.ObtainStates();\n  DCHECK_EQ(transceiver_states.size(), 1u);\n  auto transceiver_state = std::move(transceiver_states[0]);\n\n  auto transceiver = CreateOrUpdateTransceiver(std::move(transceiver_state));\n  if (peer_connection_tracker_) {\n    size_t transceiver_index = GetTransceiverIndex(*transceiver);\n    peer_connection_tracker_->TrackModifyTransceiver(\n        this, PeerConnectionTracker::TransceiverUpdatedReason::kRemoveTrack,\n        *transceiver.get(), transceiver_index);\n  }\n  std::unique_ptr<blink::WebRTCRtpTransceiver> web_transceiver =\n      std::move(transceiver);\n  return web_transceiver;\n}\n","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":160192,"func":"session_start_process (const gchar **argv,\n                       const gchar **env)\n{\n  CockpitTransport *transport = NULL;\n  CockpitPipe *pipe = NULL;\n  GError *error = NULL;\n  ChildData child;\n  gboolean ret;\n  GPid pid = 0;\n  int fds[2];\n\n  g_debug (\"spawning %s\", argv[0]);\n\n  \/* The main stdin\/stdout for the socket ... both are read\/writable *\/\n  if (socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) < 0)\n    {\n      g_warning (\"couldn't create loopback socket: %s\", g_strerror (errno));\n      return NULL;\n    }\n\n  child.io = fds[0];\n  ret = g_spawn_async_with_pipes (NULL, (gchar **)argv, (gchar **)env,\n                                  G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_LEAVE_DESCRIPTORS_OPEN,\n                                  session_child_setup, &child,\n                                  &pid, NULL, NULL, NULL, &error);\n\n  close (fds[0]);\n\n  if (!ret)\n    {\n      g_message (\"couldn't launch cockpit session: %s: %s\", argv[0], error->message);\n      g_error_free (error);\n      close (fds[1]);\n      return NULL;\n    }\n\n  pipe = g_object_new (COCKPIT_TYPE_PIPE,\n                       \"in-fd\", fds[1],\n                       \"out-fd\", fds[1],\n                       \"pid\", pid,\n                       \"name\", argv[0],\n                       NULL);\n\n  transport = cockpit_pipe_transport_new (pipe);\n  g_object_unref (pipe);\n\n  return transport;\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":325080,"func":"static int do_pcie_aer_inject_error(Monitor *mon,\n\n                                    const QDict *qdict, QObject **ret_data)\n\n{\n\n    const char *id = qdict_get_str(qdict, \"id\");\n\n    const char *error_name;\n\n    uint32_t error_status;\n\n    bool correctable;\n\n    PCIDevice *dev;\n\n    PCIEAERErr err;\n\n    int ret;\n\n\n\n    ret = pci_qdev_find_device(id, &dev);\n\n    if (ret < 0) {\n\n        monitor_printf(mon,\n\n                       \"id or pci device path is invalid or device not \"\n\n                       \"found. %s\\n\", id);\n\n        return ret;\n\n    }\n\n    if (!pci_is_express(dev)) {\n\n        monitor_printf(mon, \"the device doesn't support pci express. %s\\n\",\n\n                       id);\n\n        return -ENOSYS;\n\n    }\n\n\n\n    error_name = qdict_get_str(qdict, \"error_status\");\n\n    if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {\n\n        char *e = NULL;\n\n        error_status = strtoul(error_name, &e, 0);\n\n        correctable = qdict_get_try_bool(qdict, \"correctable\", false);\n\n        if (!e || *e != '\\0') {\n\n            monitor_printf(mon, \"invalid error status value. \\\"%s\\\"\",\n\n                           error_name);\n\n            return -EINVAL;\n\n        }\n\n    }\n\n    err.status = error_status;\n\n    err.source_id = pci_requester_id(dev);\n\n\n\n    err.flags = 0;\n\n    if (correctable) {\n\n        err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;\n\n    }\n\n    if (qdict_get_try_bool(qdict, \"advisory_non_fatal\", false)) {\n\n        err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;\n\n    }\n\n    if (qdict_haskey(qdict, \"header0\")) {\n\n        err.flags |= PCIE_AER_ERR_HEADER_VALID;\n\n    }\n\n    if (qdict_haskey(qdict, \"prefix0\")) {\n\n        err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;\n\n    }\n\n\n\n    err.header[0] = qdict_get_try_int(qdict, \"header0\", 0);\n\n    err.header[1] = qdict_get_try_int(qdict, \"header1\", 0);\n\n    err.header[2] = qdict_get_try_int(qdict, \"header2\", 0);\n\n    err.header[3] = qdict_get_try_int(qdict, \"header3\", 0);\n\n\n\n    err.prefix[0] = qdict_get_try_int(qdict, \"prefix0\", 0);\n\n    err.prefix[1] = qdict_get_try_int(qdict, \"prefix1\", 0);\n\n    err.prefix[2] = qdict_get_try_int(qdict, \"prefix2\", 0);\n\n    err.prefix[3] = qdict_get_try_int(qdict, \"prefix3\", 0);\n\n\n\n    ret = pcie_aer_inject_error(dev, &err);\n\n    *ret_data = qobject_from_jsonf(\"{'id': %s, \"\n\n                                   \"'root_bus': %s, 'bus': %d, 'devfn': %d, \"\n\n                                   \"'ret': %d}\",\n\n                                   id, pci_root_bus_path(dev),\n\n                                   pci_bus_num(dev->bus), dev->devfn,\n\n                                   ret);\n\n    assert(*ret_data);\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":719,"total_token_length":955,"max_tokens_setting":1024}
+{"idx":119596,"func":"static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,\n\t\t\t\t      unsigned long addr)\n{\n\tstruct perf_event *bp;\n\tstruct thread_struct *t = &tsk->thread;\n\tstruct perf_event_attr attr;\n\tint err = 0;\n\n\tif (ptrace_get_breakpoints(tsk) < 0)\n\t\treturn -ESRCH;\n\n\tif (!t->ptrace_bps[nr]) {\n\t\tptrace_breakpoint_init(&attr);\n\t\t\/*\n\t\t * Put stub len and type to register (reserve) an inactive but\n\t\t * correct bp\n\t\t *\/\n\t\tattr.bp_addr = addr;\n\t\tattr.bp_len = HW_BREAKPOINT_LEN_1;\n\t\tattr.bp_type = HW_BREAKPOINT_W;\n\t\tattr.disabled = 1;\n\n\t\tbp = register_user_hw_breakpoint(&attr, ptrace_triggered, tsk);\n\n\t\t\/*\n\t\t * CHECKME: the previous code returned -EIO if the addr wasn't\n\t\t * a valid task virtual addr. The new one will return -EINVAL in\n\t\t *  this case.\n\t\t * -EINVAL may be what we want for in-kernel breakpoints users,\n\t\t * but -EIO looks better for ptrace, since we refuse a register\n\t\t * writing for the user. And anyway this is the previous\n\t\t * behaviour.\n\t\t *\/\n\t\tif (IS_ERR(bp)) {\n\t\t\terr = PTR_ERR(bp);\n\t\t\tgoto put;\n\t\t}\n\n\t\tt->ptrace_bps[nr] = bp;\n\t} else {\n\t\tbp = t->ptrace_bps[nr];\n\n\t\tattr = bp->attr;\n\t\tattr.bp_addr = addr;\n\t\terr = modify_user_hw_breakpoint(bp, &attr);\n\t}\n\nput:\n\tptrace_put_breakpoints(tsk);\n\treturn err;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":30228,"func":"int ssl3_get_finished ( SSL * s , int a , int b ) {\n int al , i , ok ;\n long n ;\n unsigned char * p ;\n # ifdef OPENSSL_NO_NEXTPROTONEG # endif n = s -> method -> ssl_get_message ( s , a , b , SSL3_MT_FINISHED , 64 , & ok ) ;\n if ( ! ok ) return ( ( int ) n ) ;\n if ( ! s -> s3 -> change_cipher_spec ) {\n al = SSL_AD_UNEXPECTED_MESSAGE ;\n SSLerr ( SSL_F_SSL3_GET_FINISHED , SSL_R_GOT_A_FIN_BEFORE_A_CCS ) ;\n goto f_err ;\n }\n s -> s3 -> change_cipher_spec = 0 ;\n p = ( unsigned char * ) s -> init_msg ;\n i = s -> s3 -> tmp . peer_finish_md_len ;\n if ( i != n ) {\n al = SSL_AD_DECODE_ERROR ;\n SSLerr ( SSL_F_SSL3_GET_FINISHED , SSL_R_BAD_DIGEST_LENGTH ) ;\n goto f_err ;\n }\n if ( CRYPTO_memcmp ( p , s -> s3 -> tmp . peer_finish_md , i ) != 0 ) {\n al = SSL_AD_DECRYPT_ERROR ;\n SSLerr ( SSL_F_SSL3_GET_FINISHED , SSL_R_DIGEST_CHECK_FAILED ) ;\n goto f_err ;\n }\n if ( s -> type == SSL_ST_ACCEPT ) {\n OPENSSL_assert ( i <= EVP_MAX_MD_SIZE ) ;\n memcpy ( s -> s3 -> previous_client_finished , s -> s3 -> tmp . peer_finish_md , i ) ;\n s -> s3 -> previous_client_finished_len = i ;\n }\n else {\n OPENSSL_assert ( i <= EVP_MAX_MD_SIZE ) ;\n memcpy ( s -> s3 -> previous_server_finished , s -> s3 -> tmp . peer_finish_md , i ) ;\n s -> s3 -> previous_server_finished_len = i ;\n }\n return ( 1 ) ;\n f_err : ssl3_send_alert ( s , SSL3_AL_FATAL , al ) ;\n return ( 0 ) ;\n }","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":54955,"func":"init_etherarray(netdissect_options *ndo)\n{\n\tregister const struct etherlist *el;\n\tregister struct enamemem *tp;\n#ifdef USE_ETHER_NTOHOST\n\tchar name[256];\n#else\n\tregister struct pcap_etherent *ep;\n\tregister FILE *fp;\n\n\t\/* Suck in entire ethers file *\/\n\tfp = fopen(PCAP_ETHERS_FILE, \"r\");\n\tif (fp != NULL) {\n\t\twhile ((ep = pcap_next_etherent(fp)) != NULL) {\n\t\t\ttp = lookup_emem(ndo, ep->addr);\n\t\t\ttp->e_name = strdup(ep->name);\n\t\t\tif (tp->e_name == NULL)\n\t\t\t\t(*ndo->ndo_error)(ndo,\n\t\t\t\t\t\t  \"init_etherarray: strdup(ep->addr)\");\n\t\t}\n\t\t(void)fclose(fp);\n\t}\n#endif\n\n\t\/* Hardwire some ethernet names *\/\n\tfor (el = etherlist; el->name != NULL; ++el) {\n\t\ttp = lookup_emem(ndo, el->addr);\n\t\t\/* Don't override existing name *\/\n\t\tif (tp->e_name != NULL)\n\t\t\tcontinue;\n\n#ifdef USE_ETHER_NTOHOST\n\t\t\/*\n\t\t * Use YP\/NIS version of name if available.\n\t\t *\/\n\t\tif (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {\n\t\t\ttp->e_name = strdup(name);\n\t\t\tif (tp->e_name == NULL)\n\t\t\t\t(*ndo->ndo_error)(ndo,\n\t\t\t\t\t\t  \"init_etherarray: strdup(name)\");\n\t\t\tcontinue;\n\t\t}\n#endif\n\t\ttp->e_name = el->name;\n\t}\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":4656,"func":"static void tcp_cwnd_reduction(struct sock *sk, const int prior_unsacked,\n\t\t\t       int fast_rexmit, int flag)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint sndcnt = 0;\n\tint delta = tp->snd_ssthresh - tcp_packets_in_flight(tp);\n\tint newly_acked_sacked = prior_unsacked -\n\t\t\t\t (tp->packets_out - tp->sacked_out);\n\n\ttp->prr_delivered += newly_acked_sacked;\n\tif (delta < 0) {\n\t\tu64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered +\n\t\t\t       tp->prior_cwnd - 1;\n\t\tsndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out;\n\t} else if ((flag & FLAG_RETRANS_DATA_ACKED) &&\n\t\t   !(flag & FLAG_LOST_RETRANS)) {\n\t\tsndcnt = min_t(int, delta,\n\t\t\t       max_t(int, tp->prr_delivered - tp->prr_out,\n\t\t\t\t     newly_acked_sacked) + 1);\n\t} else {\n\t\tsndcnt = min(delta, newly_acked_sacked);\n\t}\n\tsndcnt = max(sndcnt, (fast_rexmit ? 1 : 0));\n\ttp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt;\n}","target":1,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":10068,"func":" pixel_copy(png_bytep toBuffer, png_uint_32 toIndex,\n   png_const_bytep fromBuffer, png_uint_32 fromIndex, unsigned int pixelSize)\n {\n    \/* Assume we can multiply by 'size' without overflow because we are\n     * just working in a single buffer.\n    *\/\n   toIndex *= pixelSize;\n   fromIndex *= pixelSize;\n\n    if (pixelSize < 8) \/* Sub-byte *\/\n    {\n       \/* Mask to select the location of the copied pixel: *\/\n      unsigned int destMask = ((1U<<pixelSize)-1) << (8-pixelSize-(toIndex&7));\n       \/* The following read the entire pixels and clears the extra: *\/\n       unsigned int destByte = toBuffer[toIndex >> 3] & ~destMask;\n       unsigned int sourceByte = fromBuffer[fromIndex >> 3];\n \n       \/* Don't rely on << or >> supporting '0' here, just in case: *\/\n       fromIndex &= 7;\n      if (fromIndex > 0) sourceByte <<= fromIndex;\n      if ((toIndex & 7) > 0) sourceByte >>= toIndex & 7;\n \n       toBuffer[toIndex >> 3] = (png_byte)(destByte | (sourceByte & destMask));\n    }\n else \/* One or more bytes *\/\n      memmove(toBuffer+(toIndex>>3), fromBuffer+(fromIndex>>3), pixelSize>>3);\n}\n","target":1,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":474683,"func":"void addClusterMonitorPrivileges(PrivilegeVector* privileges) {\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forClusterResource(), clusterMonitorRoleClusterActions));\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forAnyNormalResource(), clusterMonitorRoleDatabaseActions));\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forDatabaseName(\"config\"), clusterMonitorRoleDatabaseActions));\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forDatabaseName(\"local\"), clusterMonitorRoleDatabaseActions));\n    addReadOnlyDbPrivileges(privileges, \"config\");\n    addReadOnlyDbPrivileges(privileges, \"local\");\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forExactNamespace(NamespaceString(\"local\", \"system.replset\")),\n                  ActionType::find));\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forExactNamespace(NamespaceString(\"local\", \"replset.election\")),\n                  ActionType::find));\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forExactNamespace(NamespaceString(\"local\", \"replset.minvalid\")),\n                  ActionType::find));\n    Privilege::addPrivilegeToPrivilegeVector(\n        privileges,\n        Privilege(ResourcePattern::forCollectionName(\"system.profile\"), ActionType::find));\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":510758,"func":"auth_server_input_mech(struct auth_server_connection *conn,\n\t\t       const char *const *args)\n{\n\tstruct auth_mech_desc mech_desc;\n\n\tif (conn->handshake_received) {\n\t\ti_error(\"BUG: Authentication server already sent handshake\");\n\t\treturn -1;\n\t}\n\tif (args[0] == NULL) {\n\t\ti_error(\"BUG: Authentication server sent broken MECH line\");\n\t\treturn -1;\n\t}\n\n\ti_zero(&mech_desc);\n\tmech_desc.name = p_strdup(conn->pool, args[0]);\n\n\tif (strcmp(mech_desc.name, \"PLAIN\") == 0)\n\t\tconn->has_plain_mech = TRUE;\n\n\tfor (args++; *args != NULL; args++) {\n\t\tif (strcmp(*args, \"private\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_PRIVATE;\n\t\telse if (strcmp(*args, \"anonymous\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_ANONYMOUS;\n\t\telse if (strcmp(*args, \"plaintext\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_PLAINTEXT;\n\t\telse if (strcmp(*args, \"dictionary\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_DICTIONARY;\n\t\telse if (strcmp(*args, \"active\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_ACTIVE;\n\t\telse if (strcmp(*args, \"forward-secrecy\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_FORWARD_SECRECY;\n\t\telse if (strcmp(*args, \"mutual-auth\") == 0)\n\t\t\tmech_desc.flags |= MECH_SEC_MUTUAL_AUTH;\n\t}\n\tarray_append(&conn->available_auth_mechs, &mech_desc, 1);\n\treturn 0;\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":113679,"func":"GF_Err mvhd_Read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_MovieHeaderBox *ptr = (GF_MovieHeaderBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\tif (ptr->version == 1) {\n\t\tptr->creationTime = gf_bs_read_u64(bs);\n\t\tptr->modificationTime = gf_bs_read_u64(bs);\n\t\tptr->timeScale = gf_bs_read_u32(bs);\n\t\tptr->duration = gf_bs_read_u64(bs);\n\t} else {\n\t\tptr->creationTime = gf_bs_read_u32(bs);\n\t\tptr->modificationTime = gf_bs_read_u32(bs);\n\t\tptr->timeScale = gf_bs_read_u32(bs);\n\t\tptr->duration = gf_bs_read_u32(bs);\n\t}\n\tif (!ptr->timeScale) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Movie header timescale is invalid (0) - defaulting to 600\\n\" ));\n\t\tptr->timeScale = 600;\n\t}\n\tptr->preferredRate = gf_bs_read_u32(bs);\n\tptr->preferredVolume = gf_bs_read_u16(bs);\n\tgf_bs_read_data(bs, ptr->reserved, 10);\n\tptr->matrixA = gf_bs_read_u32(bs);\n\tptr->matrixB = gf_bs_read_u32(bs);\n\tptr->matrixU = gf_bs_read_u32(bs);\n\tptr->matrixC = gf_bs_read_u32(bs);\n\tptr->matrixD = gf_bs_read_u32(bs);\n\tptr->matrixV = gf_bs_read_u32(bs);\n\tptr->matrixX = gf_bs_read_u32(bs);\n\tptr->matrixY = gf_bs_read_u32(bs);\n\tptr->matrixW = gf_bs_read_u32(bs);\n\tptr->previewTime = gf_bs_read_u32(bs);\n\tptr->previewDuration = gf_bs_read_u32(bs);\n\tptr->posterTime = gf_bs_read_u32(bs);\n\tptr->selectionTime = gf_bs_read_u32(bs);\n\tptr->selectionDuration = gf_bs_read_u32(bs);\n\tptr->currentTime = gf_bs_read_u32(bs);\n\tptr->nextTrackID = gf_bs_read_u32(bs);\n\tptr->original_duration = ptr->duration;\n\treturn GF_OK;\n}","target":0,"code_token_length":496,"total_token_length":732,"max_tokens_setting":1024}
+{"idx":301717,"func":"void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16 orientation){\n\n\tfloat m1[9];\n\tfloat f=0.0;\n\t\n\tif( boxp->x1 > boxp->x2){\n\t\tf=boxp->x1;\n\t\tboxp->x1=boxp->x2;\n\t\tboxp->x2 = f;\n\t}\n\tif( boxp->y1 > boxp->y2){\n\t\tf=boxp->y1;\n\t\tboxp->y1=boxp->y2;\n\t\tboxp->y2 = f;\n\t}\n\tboxp->mat[0]=m1[0]=boxp->x2-boxp->x1;\n\tboxp->mat[1]=m1[1]=0.0;\n\tboxp->mat[2]=m1[2]=0.0;\n\tboxp->mat[3]=m1[3]=0.0;\n\tboxp->mat[4]=m1[4]=boxp->y2-boxp->y1;\n\tboxp->mat[5]=m1[5]=0.0;\n\tboxp->mat[6]=m1[6]=boxp->x1;\n\tboxp->mat[7]=m1[7]=boxp->y1;\n\tboxp->mat[8]=m1[8]=1.0;\n\tswitch(orientation){\n\t\tcase 0:\n\t\tcase 1:\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tboxp->mat[0]=0.0F-m1[0];\n\t\t\tboxp->mat[6]+=m1[0];\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tboxp->mat[0]=0.0F-m1[0];\n\t\t\tboxp->mat[4]=0.0F-m1[4];\n\t\t\tboxp->mat[6]+=m1[0];\n\t\t\tboxp->mat[7]+=m1[4];\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tboxp->mat[4]=0.0F-m1[4];\n\t\t\tboxp->mat[7]+=m1[4];\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tboxp->mat[0]=0.0F;\n\t\t\tboxp->mat[1]=0.0F-m1[0];\n\t\t\tboxp->mat[3]=0.0F-m1[4];\n\t\t\tboxp->mat[4]=0.0F;\n\t\t\tboxp->mat[6]+=m1[4];\n\t\t\tboxp->mat[7]+=m1[0];\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tboxp->mat[0]=0.0F;\n\t\t\tboxp->mat[1]=0.0F-m1[0];\n\t\t\tboxp->mat[3]=m1[4];\n\t\t\tboxp->mat[4]=0.0F;\n\t\t\tboxp->mat[7]+=m1[0];\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tboxp->mat[0]=0.0F;\n\t\t\tboxp->mat[1]=m1[0];\n\t\t\tboxp->mat[3]=m1[4];\n\t\t\tboxp->mat[4]=0.0F;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tboxp->mat[0]=0.0F;\n\t\t\tboxp->mat[1]=m1[0];\n\t\t\tboxp->mat[3]=0.0F-m1[4];\n\t\t\tboxp->mat[4]=0.0F;\n\t\t\tboxp->mat[6]+=m1[4];\n\t\t\tbreak;\n\t}\n\n\treturn;\n}","target":0,"code_token_length":766,"total_token_length":1002,"max_tokens_setting":1024}
+{"idx":32944,"func":"int cil_gen_default(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)\n{\n\tint rc = SEPOL_ERR;\n\tstruct cil_default *def = NULL;\n\tchar *object;\n\tenum cil_syntax syntax[] = {\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_STRING | CIL_SYN_LIST,\n\t\tCIL_SYN_STRING,\n\t\tCIL_SYN_END\n\t};\n\tint syntax_len = sizeof(syntax)\/sizeof(*syntax);\n\n\trc = __cil_verify_syntax(parse_current, syntax, syntax_len);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tcil_default_init(&def);\n\n\tdef->flavor = flavor;\n\n\tif (parse_current->next->cl_head == NULL) {\n\t\tcil_list_init(&def->class_strs, CIL_CLASS);\n\t\tcil_list_append(def->class_strs, CIL_STRING, parse_current->next->data);\n\t} else {\n\t\trc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\t}\n\n\tobject = parse_current->next->next->data;\n\tif (object == CIL_KEY_SOURCE) {\n\t\tdef->object = CIL_DEFAULT_SOURCE;\n\t} else if (object == CIL_KEY_TARGET) {\n\t\tdef->object = CIL_DEFAULT_TARGET;\n\t} else {\n\t\tcil_log(CIL_ERR,\"Expected either 'source' or 'target'\\n\");\n\t\trc = SEPOL_ERR;\n\t\tgoto exit;\n\t}\n\n\tast_node->data = def;\n\tast_node->flavor = flavor;\n\n\treturn SEPOL_OK;\n\nexit:\n\tcil_tree_log(parse_current, CIL_ERR, \"Bad %s declaration\", cil_node_to_string(parse_current));\n\tcil_destroy_default(def);\n\treturn rc;\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":137658,"func":"TEST_P(RedirectIntegrationTest, InternalRedirectCancelledDueToEarlyResponse) {\n  useAccessLog(\"%RESPONSE_FLAGS% %RESPONSE_CODE% %RESPONSE_CODE_DETAILS% %RESP(test-header)%\");\n\n  initialize();\n\n  codec_client_ = makeHttpConnection(lookupPort(\"http\"));\n\n  default_request_headers_.setHost(\"handle.internal.redirect\");\n  default_request_headers_.setMethod(\"POST\");\n  auto encoder_decoder = codec_client_->startRequest(default_request_headers_);\n  auto& response = encoder_decoder.second;\n\n  \/\/ Wait for the request headers to be received upstream.\n  ASSERT_TRUE(fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, fake_upstream_connection_));\n  ASSERT_TRUE(fake_upstream_connection_->waitForNewStream(*dispatcher_, upstream_request_));\n  ASSERT_TRUE(upstream_request_->waitForHeadersComplete());\n\n  \/\/ Respond with a redirect before the request is complete.\n  upstream_request_->encodeHeaders(redirect_response_, true);\n  ASSERT_TRUE(response->waitForEndStream());\n\n  if (upstreamProtocol() == Http::CodecType::HTTP1) {\n    ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect());\n  } else {\n    ASSERT_TRUE(upstream_request_->waitForReset());\n    ASSERT_TRUE(fake_upstream_connection_->close());\n    ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect());\n  }\n\n  if (downstream_protocol_ == Http::CodecType::HTTP1) {\n    ASSERT_TRUE(codec_client_->waitForDisconnect());\n  } else {\n    codec_client_->close();\n  }\n\n  EXPECT_FALSE(upstream_request_->complete());\n\n  \/\/ Ensure the redirect was returned to the client and not handled internally.\n  EXPECT_TRUE(response->complete());\n  EXPECT_EQ(\"302\", response->headers().getStatusValue());\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":5263,"func":"String StringUtil::Implode(const Variant& items, const String& delim,\n                           const bool checkIsContainer \/* = true *\/) {\n  if (checkIsContainer && !isContainer(items)) {\n    throw_param_is_not_container();\n  }\n  int size = getContainerSize(items);\n  if (size == 0) return empty_string();\n\n  req::vector<String> sitems;\n  sitems.reserve(size);\n  int len = 0;\n  int lenDelim = delim.size();\n  for (ArrayIter iter(items); iter; ++iter) {\n    sitems.emplace_back(iter.second().toString());\n    len += sitems.back().size() + lenDelim;\n  }\n  len -= lenDelim; \/\/ always one delimiter less than count of items\n  assert(sitems.size() == size);\n\n  String s = String(len, ReserveString);\n  char *buffer = s.mutableData();\n  const char *sdelim = delim.data();\n  char *p = buffer;\n  String &init_str = sitems[0];\n  int init_len = init_str.size();\n  memcpy(p, init_str.data(), init_len);\n  p += init_len;\n  for (int i = 1; i < size; i++) {\n    String &item = sitems[i];\n    memcpy(p, sdelim, lenDelim);\n    p += lenDelim;\n    int lenItem = item.size();\n    memcpy(p, item.data(), lenItem);\n    p += lenItem;\n  }\n  assert(p - buffer == len);\n  s.setSize(len);\n  return s;\n}","target":1,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":321907,"func":"static int mpeg_field_start(MpegEncContext *s){\n\n    AVCodecContext *avctx= s->avctx;\n\n    Mpeg1Context *s1 = (Mpeg1Context*)s;\n\n\n\n    \/* start frame decoding *\/\n\n    if(s->first_field || s->picture_structure==PICT_FRAME){\n\n        if(MPV_frame_start(s, avctx) < 0)\n\n            return -1;\n\n\n\n        ff_er_frame_start(s);\n\n\n\n        \/* first check if we must repeat the frame *\/\n\n        s->current_picture_ptr->repeat_pict = 0;\n\n        if (s->repeat_first_field) {\n\n            if (s->progressive_sequence) {\n\n                if (s->top_field_first)\n\n                    s->current_picture_ptr->repeat_pict = 4;\n\n                else\n\n                    s->current_picture_ptr->repeat_pict = 2;\n\n            } else if (s->progressive_frame) {\n\n                s->current_picture_ptr->repeat_pict = 1;\n\n            }\n\n        }\n\n\n\n        *s->current_picture_ptr->pan_scan= s1->pan_scan;\n\n    }else{ \/\/second field\n\n            int i;\n\n\n\n            if(!s->current_picture_ptr){\n\n                av_log(s->avctx, AV_LOG_ERROR, \"first field missing\\n\");\n\n                return -1;\n\n            }\n\n\n\n            for(i=0; i<4; i++){\n\n                s->current_picture.data[i] = s->current_picture_ptr->data[i];\n\n                if(s->picture_structure == PICT_BOTTOM_FIELD){\n\n                    s->current_picture.data[i] += s->current_picture_ptr->linesize[i];\n\n                }\n\n            }\n\n    }\n\n#if CONFIG_MPEG_XVMC_DECODER\n\n\/\/ MPV_frame_start will call this function too,\n\n\/\/ but we need to call it on every field\n\n    if(s->avctx->xvmc_acceleration)\n\n         ff_xvmc_field_start(s,avctx);\n\n#endif\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":403,"total_token_length":639,"max_tokens_setting":1024}
+{"idx":324675,"func":"static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int band,\n\n                           float *bits, float lambda)\n\n{\n\n    int i, b = 0;\n\n    uint32_t cm[2] = { (1 << f->blocks) - 1, (1 << f->blocks) - 1 };\n\n    const int band_size = ff_celt_freq_range[band] << f->size;\n\n    float buf[176 * 2], lowband_scratch[176], norm1[176], norm2[176];\n\n    float dist, cost, err_x = 0.0f, err_y = 0.0f;\n\n    float *X = buf;\n\n    float *X_orig = f->block[0].coeffs + (ff_celt_freq_bands[band] << f->size);\n\n    float *Y = (f->channels == 2) ? &buf[176] : NULL;\n\n    float *Y_orig = f->block[1].coeffs + (ff_celt_freq_bands[band] << f->size);\n\n    OPUS_RC_CHECKPOINT_SPAWN(rc);\n\n\n\n    memcpy(X, X_orig, band_size*sizeof(float));\n\n    if (Y)\n\n        memcpy(Y, Y_orig, band_size*sizeof(float));\n\n\n\n    f->remaining2 = ((f->framebits << 3) - f->anticollapse_needed) - opus_rc_tell_frac(rc) - 1;\n\n    if (band <= f->coded_bands - 1) {\n\n        int curr_balance = f->remaining \/ FFMIN(3, f->coded_bands - band);\n\n        b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[band] + curr_balance), 14);\n\n    }\n\n\n\n    if (f->dual_stereo) {\n\n        pvq->quant_band(pvq, f, rc, band, X, NULL, band_size, b \/ 2, f->blocks, NULL,\n\n                        f->size, norm1, 0, 1.0f, lowband_scratch, cm[0]);\n\n\n\n        pvq->quant_band(pvq, f, rc, band, Y, NULL, band_size, b \/ 2, f->blocks, NULL,\n\n                        f->size, norm2, 0, 1.0f, lowband_scratch, cm[1]);\n\n    } else {\n\n        pvq->quant_band(pvq, f, rc, band, X, Y, band_size, b, f->blocks, NULL, f->size,\n\n                        norm1, 0, 1.0f, lowband_scratch, cm[0] | cm[1]);\n\n    }\n\n\n\n    for (i = 0; i < band_size; i++) {\n\n        err_x += (X[i] - X_orig[i])*(X[i] - X_orig[i]);\n\n        if (Y)\n\n            err_y += (Y[i] - Y_orig[i])*(Y[i] - Y_orig[i]);\n\n    }\n\n\n\n    dist = sqrtf(err_x) + sqrtf(err_y);\n\n    cost = OPUS_RC_CHECKPOINT_BITS(rc)\/8.0f;\n\n    *bits += cost;\n\n\n\n    OPUS_RC_CHECKPOINT_ROLLBACK(rc);\n\n\n\n    return lambda*dist*cost;\n\n}\n","target":0,"code_token_length":720,"total_token_length":956,"max_tokens_setting":1024}
+{"idx":468960,"func":"static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)\n{\n\tint r;\n\tstruct kvm_vcpu *vcpu;\n\tstruct page *page;\n\n\tif (id >= KVM_MAX_VCPU_ID)\n\t\treturn -EINVAL;\n\n\tmutex_lock(&kvm->lock);\n\tif (kvm->created_vcpus == KVM_MAX_VCPUS) {\n\t\tmutex_unlock(&kvm->lock);\n\t\treturn -EINVAL;\n\t}\n\n\tkvm->created_vcpus++;\n\tmutex_unlock(&kvm->lock);\n\n\tr = kvm_arch_vcpu_precreate(kvm, id);\n\tif (r)\n\t\tgoto vcpu_decrement;\n\n\tvcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL_ACCOUNT);\n\tif (!vcpu) {\n\t\tr = -ENOMEM;\n\t\tgoto vcpu_decrement;\n\t}\n\n\tBUILD_BUG_ON(sizeof(struct kvm_run) > PAGE_SIZE);\n\tpage = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);\n\tif (!page) {\n\t\tr = -ENOMEM;\n\t\tgoto vcpu_free;\n\t}\n\tvcpu->run = page_address(page);\n\n\tkvm_vcpu_init(vcpu, kvm, id);\n\n\tr = kvm_arch_vcpu_create(vcpu);\n\tif (r)\n\t\tgoto vcpu_free_run_page;\n\n\tif (kvm->dirty_ring_size) {\n\t\tr = kvm_dirty_ring_alloc(&vcpu->dirty_ring,\n\t\t\t\t\t id, kvm->dirty_ring_size);\n\t\tif (r)\n\t\t\tgoto arch_vcpu_destroy;\n\t}\n\n\tmutex_lock(&kvm->lock);\n\tif (kvm_get_vcpu_by_id(kvm, id)) {\n\t\tr = -EEXIST;\n\t\tgoto unlock_vcpu_destroy;\n\t}\n\n\tvcpu->vcpu_idx = atomic_read(&kvm->online_vcpus);\n\tBUG_ON(kvm->vcpus[vcpu->vcpu_idx]);\n\n\t\/* Now it's all set up, let userspace reach it *\/\n\tkvm_get_kvm(kvm);\n\tr = create_vcpu_fd(vcpu);\n\tif (r < 0) {\n\t\tkvm_put_kvm_no_destroy(kvm);\n\t\tgoto unlock_vcpu_destroy;\n\t}\n\n\tkvm->vcpus[vcpu->vcpu_idx] = vcpu;\n\n\t\/*\n\t * Pairs with smp_rmb() in kvm_get_vcpu.  Write kvm->vcpus\n\t * before kvm->online_vcpu's incremented value.\n\t *\/\n\tsmp_wmb();\n\tatomic_inc(&kvm->online_vcpus);\n\n\tmutex_unlock(&kvm->lock);\n\tkvm_arch_vcpu_postcreate(vcpu);\n\tkvm_create_vcpu_debugfs(vcpu);\n\treturn r;\n\nunlock_vcpu_destroy:\n\tmutex_unlock(&kvm->lock);\n\tkvm_dirty_ring_free(&vcpu->dirty_ring);\narch_vcpu_destroy:\n\tkvm_arch_vcpu_destroy(vcpu);\nvcpu_free_run_page:\n\tfree_page((unsigned long)vcpu->run);\nvcpu_free:\n\tkmem_cache_free(kvm_vcpu_cache, vcpu);\nvcpu_decrement:\n\tmutex_lock(&kvm->lock);\n\tkvm->created_vcpus--;\n\tmutex_unlock(&kvm->lock);\n\treturn r;\n}","target":0,"code_token_length":652,"total_token_length":888,"max_tokens_setting":1024}
+{"idx":181663,"func":"long ContentEncoding::ParseCompressionEntry(long long start, long long size,\n IMkvReader* pReader,\n ContentCompression* compression) {\n  assert(pReader);\n  assert(compression);\n\n long long pos = start;\n const long long stop = start + size;\n\n bool valid = false;\n\n while (pos < stop) {\n long long id, size;\n const long status = ParseElementHeader(pReader, pos, stop, id, size);\n if (status < 0) \/\/ error\n return status;\n\n if (id == 0x254) {\n long long algo = UnserializeUInt(pReader, pos, size);\n if (algo < 0)\n return E_FILE_FORMAT_INVALID;\n      compression->algo = algo;\n      valid = true;\n } else if (id == 0x255) {\n if (size <= 0)\n return E_FILE_FORMAT_INVALID;\n\n const size_t buflen = static_cast<size_t>(size);\n unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen);\n if (buf == NULL)\n return -1;\n\n const int read_status =\n          pReader->Read(pos, static_cast<long>(buflen), buf);\n if (read_status) {\n delete[] buf;\n return status;\n }\n\n      compression->settings = buf;\n      compression->settings_len = buflen;\n }\n\n    pos += size; \/\/ consume payload\n if (pos > stop)\n return E_FILE_FORMAT_INVALID;\n }\n\n if (!valid)\n return E_FILE_FORMAT_INVALID;\n\n return 0;\n}\n","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":174027,"func":"bool RenderFrameDevToolsAgentHost::AttachSession(DevToolsSession* session) {\n  if (!ShouldAllowSession(session))\n    return false;\n\n   protocol::EmulationHandler* emulation_handler =\n       new protocol::EmulationHandler();\n   session->AddHandler(base::WrapUnique(new protocol::BrowserHandler()));\n  session->AddHandler(base::WrapUnique(\n      new protocol::DOMHandler(session->client()->MayAffectLocalFiles())));\n   session->AddHandler(base::WrapUnique(emulation_handler));\n   session->AddHandler(base::WrapUnique(new protocol::InputHandler()));\n   session->AddHandler(base::WrapUnique(new protocol::InspectorHandler()));\n  session->AddHandler(base::WrapUnique(new protocol::IOHandler(\n      GetIOContext())));\n  session->AddHandler(base::WrapUnique(new protocol::MemoryHandler()));\n  session->AddHandler(base::WrapUnique(new protocol::NetworkHandler(\n      GetId(),\n      frame_tree_node_ ? frame_tree_node_->devtools_frame_token()\n                       : base::UnguessableToken(),\n      GetIOContext())));\n  session->AddHandler(base::WrapUnique(new protocol::SchemaHandler()));\n  session->AddHandler(base::WrapUnique(new protocol::ServiceWorkerHandler()));\n  session->AddHandler(base::WrapUnique(new protocol::StorageHandler()));\n  session->AddHandler(base::WrapUnique(new protocol::TargetHandler(\n      session->client()->MayAttachToBrowser()\n          ? protocol::TargetHandler::AccessMode::kRegular\n          : protocol::TargetHandler::AccessMode::kAutoAttachOnly,\n      GetId(), GetRendererChannel(), session->GetRootSession())));\n  session->AddHandler(base::WrapUnique(new protocol::PageHandler(\n      emulation_handler, session->client()->MayAffectLocalFiles())));\n  session->AddHandler(base::WrapUnique(new protocol::SecurityHandler()));\n  if (!frame_tree_node_ || !frame_tree_node_->parent()) {\n    session->AddHandler(base::WrapUnique(\n        new protocol::TracingHandler(frame_tree_node_, GetIOContext())));\n  }\n\n  if (sessions().empty()) {\n    bool use_video_capture_api = true;\n#ifdef OS_ANDROID\n    if (!CompositorImpl::IsInitialized())\n      use_video_capture_api = false;\n#endif\n    if (!use_video_capture_api)\n      frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder());\n    GrantPolicy();\n#if defined(OS_ANDROID)\n    GetWakeLock()->RequestWakeLock();\n#endif\n  }\n  return true;\n}\n","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":355450,"func":"static struct ip_tunnel * ipip6_tunnel_locate(struct net *net,\n\t\tstruct ip_tunnel_parm *parms, int create)\n{\n\t__be32 remote = parms->iph.daddr;\n\t__be32 local = parms->iph.saddr;\n\tstruct ip_tunnel *t, **tp, *nt;\n\tstruct net_device *dev;\n\tchar name[IFNAMSIZ];\n\tstruct sit_net *sitn = net_generic(net, sit_net_id);\n\n\tfor (tp = __ipip6_bucket(sitn, parms); (t = *tp) != NULL; tp = &t->next) {\n\t\tif (local == t->parms.iph.saddr && remote == t->parms.iph.daddr)\n\t\t\treturn t;\n\t}\n\tif (!create)\n\t\tgoto failed;\n\n\tif (parms->name[0])\n\t\tstrlcpy(name, parms->name, IFNAMSIZ);\n\telse\n\t\tsprintf(name, \"sit%%d\");\n\n\tdev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup);\n\tif (dev == NULL)\n\t\treturn NULL;\n\n\tdev_net_set(dev, net);\n\n\tif (strchr(name, '%')) {\n\t\tif (dev_alloc_name(dev, name) < 0)\n\t\t\tgoto failed_free;\n\t}\n\n\tnt = netdev_priv(dev);\n\tdev->init = ipip6_tunnel_init;\n\tnt->parms = *parms;\n\n\tif (parms->i_flags & SIT_ISATAP)\n\t\tdev->priv_flags |= IFF_ISATAP;\n\n\tif (register_netdevice(dev) < 0)\n\t\tgoto failed_free;\n\n\tdev_hold(dev);\n\n\tipip6_tunnel_link(sitn, nt);\n\treturn nt;\n\nfailed_free:\n\tfree_netdev(dev);\nfailed:\n\treturn NULL;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":460997,"func":"static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)\n{\n    MPTSASState *s = MPT_SAS(dev);\n    Error *err = NULL;\n    int ret;\n\n    dev->config[PCI_LATENCY_TIMER] = 0;\n    dev->config[PCI_INTERRUPT_PIN] = 0x01;\n\n    if (s->msi != ON_OFF_AUTO_OFF) {\n        ret = msi_init(dev, 0, 1, true, false, &err);\n        \/* Any error other than -ENOTSUP(board's MSI support is broken)\n         * is a programming error *\/\n        assert(!ret || ret == -ENOTSUP);\n        if (ret && s->msi == ON_OFF_AUTO_ON) {\n            \/* Can't satisfy user's explicit msi=on request, fail *\/\n            error_append_hint(&err, \"You have to use msi=auto (default) or \"\n                    \"msi=off with this machine type.\\n\");\n            error_propagate(errp, err);\n            return;\n        }\n        assert(!err || s->msi == ON_OFF_AUTO_AUTO);\n        \/* With msi=auto, we fall back to MSI off silently *\/\n        error_free(err);\n\n        \/* Only used for migration.  *\/\n        s->msi_in_use = (ret == 0);\n    }\n\n    memory_region_init_io(&s->mmio_io, OBJECT(s), &mptsas_mmio_ops, s,\n                          \"mptsas-mmio\", 0x4000);\n    memory_region_init_io(&s->port_io, OBJECT(s), &mptsas_port_ops, s,\n                          \"mptsas-io\", 256);\n    memory_region_init_io(&s->diag_io, OBJECT(s), &mptsas_diag_ops, s,\n                          \"mptsas-diag\", 0x10000);\n\n    pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io);\n    pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY |\n                                 PCI_BASE_ADDRESS_MEM_TYPE_32, &s->mmio_io);\n    pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY |\n                                 PCI_BASE_ADDRESS_MEM_TYPE_32, &s->diag_io);\n\n    if (!s->sas_addr) {\n        s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID << 24) |\n                       IEEE_COMPANY_LOCALLY_ASSIGNED) << 36;\n        s->sas_addr |= (pci_dev_bus_num(dev) << 16);\n        s->sas_addr |= (PCI_SLOT(dev->devfn) << 8);\n        s->sas_addr |= PCI_FUNC(dev->devfn);\n    }\n    s->max_devices = MPTSAS_NUM_PORTS;\n\n    s->request_bh = qemu_bh_new(mptsas_fetch_requests, s);\n\n    scsi_bus_new(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info, NULL);\n}","target":0,"code_token_length":647,"total_token_length":883,"max_tokens_setting":1024}
+{"idx":270480,"func":"static int __init hugetlb_nrpages_setup(char *s)\n{\n\tunsigned long *mhp;\n\tstatic unsigned long *last_mhp;\n\n\tif (!parsed_valid_hugepagesz) {\n\t\tpr_warn(\"hugepages = %s preceded by \"\n\t\t\t\"an unsupported hugepagesz, ignoring\\n\", s);\n\t\tparsed_valid_hugepagesz = true;\n\t\treturn 1;\n\t}\n\t\/*\n\t * !hugetlb_max_hstate means we haven't parsed a hugepagesz= parameter yet,\n\t * so this hugepages= parameter goes to the \"default hstate\".\n\t *\/\n\telse if (!hugetlb_max_hstate)\n\t\tmhp = &default_hstate_max_huge_pages;\n\telse\n\t\tmhp = &parsed_hstate->max_huge_pages;\n\n\tif (mhp == last_mhp) {\n\t\tpr_warn(\"hugepages= specified twice without interleaving hugepagesz=, ignoring\\n\");\n\t\treturn 1;\n\t}\n\n\tif (sscanf(s, \"%lu\", mhp) <= 0)\n\t\t*mhp = 0;\n\n\t\/*\n\t * Global state is always initialized later in hugetlb_init.\n\t * But we need to allocate >= MAX_ORDER hstates here early to still\n\t * use the bootmem allocator.\n\t *\/\n\tif (hugetlb_max_hstate && parsed_hstate->order >= MAX_ORDER)\n\t\thugetlb_hstate_alloc_pages(parsed_hstate);\n\n\tlast_mhp = mhp;\n\n\treturn 1;\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":452341,"func":"static gboolean vdagent_message_check_size(const VDAgentMessage *message_header)\n{\n    uint32_t min_size = 0;\n\n    if (message_header->protocol != VD_AGENT_PROTOCOL) {\n        syslog(LOG_ERR, \"message with wrong protocol version ignoring\");\n        return FALSE;\n    }\n\n    if (!message_header->type ||\n        message_header->type >= G_N_ELEMENTS(vdagent_message_min_size)) {\n        syslog(LOG_WARNING, \"unknown message type %d, ignoring\",\n               message_header->type);\n        return FALSE;\n    }\n\n    min_size = vdagent_message_min_size[message_header->type];\n    if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size,\n                                VD_AGENT_CAP_CLIPBOARD_SELECTION)) {\n        switch (message_header->type) {\n        case VD_AGENT_CLIPBOARD_GRAB:\n        case VD_AGENT_CLIPBOARD_REQUEST:\n        case VD_AGENT_CLIPBOARD:\n        case VD_AGENT_CLIPBOARD_RELEASE:\n          min_size += 4;\n        }\n    }\n\n    if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size,\n                                VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)\n        && message_header->type == VD_AGENT_CLIPBOARD_GRAB) {\n        min_size += 4;\n    }\n\n    switch (message_header->type) {\n    case VD_AGENT_MONITORS_CONFIG:\n    case VD_AGENT_FILE_XFER_START:\n    case VD_AGENT_FILE_XFER_DATA:\n    case VD_AGENT_CLIPBOARD:\n    case VD_AGENT_CLIPBOARD_GRAB:\n    case VD_AGENT_AUDIO_VOLUME_SYNC:\n    case VD_AGENT_ANNOUNCE_CAPABILITIES:\n    case VD_AGENT_GRAPHICS_DEVICE_INFO:\n        if (message_header->size < min_size) {\n            syslog(LOG_ERR, \"read: invalid message size: %u for message type: %u\",\n                   message_header->size, message_header->type);\n            return FALSE;\n        }\n        break;\n    case VD_AGENT_MOUSE_STATE:\n    case VD_AGENT_FILE_XFER_STATUS:\n    case VD_AGENT_DISPLAY_CONFIG:\n    case VD_AGENT_REPLY:\n    case VD_AGENT_CLIPBOARD_REQUEST:\n    case VD_AGENT_CLIPBOARD_RELEASE:\n    case VD_AGENT_MAX_CLIPBOARD:\n    case VD_AGENT_CLIENT_DISCONNECTED:\n        if (message_header->size != min_size) {\n            syslog(LOG_ERR, \"read: invalid message size: %u for message type: %u\",\n                   message_header->size, message_header->type);\n            return FALSE;\n        }\n        break;\n    default:\n        g_warn_if_reached();\n        return FALSE;\n    }\n    return TRUE;\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":435107,"func":"psutil_users(PyObject *self, PyObject *args) {\n    struct utmpx *ut;\n    PyObject *py_tuple = NULL;\n    PyObject *py_username = NULL;\n    PyObject *py_tty = NULL;\n    PyObject *py_hostname = NULL;\n    PyObject *py_user_proc = NULL;\n    PyObject *py_retlist = PyList_New(0);\n\n    if (py_retlist == NULL)\n        return NULL;\n\n    setutxent();\n    while (NULL != (ut = getutxent())) {\n        if (ut->ut_type == USER_PROCESS)\n            py_user_proc = Py_True;\n        else\n            py_user_proc = Py_False;\n        py_username = PyUnicode_DecodeFSDefault(ut->ut_user);\n        if (! py_username)\n            goto error;\n        py_tty = PyUnicode_DecodeFSDefault(ut->ut_line);\n        if (! py_tty)\n            goto error;\n        py_hostname = PyUnicode_DecodeFSDefault(ut->ut_host);\n        if (! py_hostname)\n            goto error;\n        py_tuple = Py_BuildValue(\n            \"(OOOfOi)\",\n            py_username,              \/\/ username\n            py_tty,                   \/\/ tty\n            py_hostname,              \/\/ hostname\n            (float)ut->ut_tv.tv_sec,  \/\/ tstamp\n            py_user_proc,             \/\/ (bool) user process\n            ut->ut_pid                \/\/ process id\n        );\n        if (py_tuple == NULL)\n            goto error;\n        if (PyList_Append(py_retlist, py_tuple))\n            goto error;\n        Py_CLEAR(py_username);\n        Py_CLEAR(py_tty);\n        Py_CLEAR(py_hostname);\n        Py_CLEAR(py_tuple);\n    }\n    endutxent();\n\n    return py_retlist;\n\nerror:\n    Py_XDECREF(py_username);\n    Py_XDECREF(py_tty);\n    Py_XDECREF(py_hostname);\n    Py_XDECREF(py_tuple);\n    Py_DECREF(py_retlist);\n    endutxent();\n    return NULL;\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":407825,"func":"static int drbg_hmac_update(struct drbg_state *drbg, struct list_head *seed,\n\t\t\t    int reseed)\n{\n\tint ret = -EFAULT;\n\tint i = 0;\n\tstruct drbg_string seed1, seed2, vdata;\n\tLIST_HEAD(seedlist);\n\tLIST_HEAD(vdatalist);\n\n\tif (!reseed)\n\t\t\/* 10.1.2.3 step 2 -- memset(0) of C is implicit with kzalloc *\/\n\t\tmemset(drbg->V, 1, drbg_statelen(drbg));\n\n\tdrbg_string_fill(&seed1, drbg->V, drbg_statelen(drbg));\n\tlist_add_tail(&seed1.list, &seedlist);\n\t\/* buffer of seed2 will be filled in for loop below with one byte *\/\n\tdrbg_string_fill(&seed2, NULL, 1);\n\tlist_add_tail(&seed2.list, &seedlist);\n\t\/* input data of seed is allowed to be NULL at this point *\/\n\tif (seed)\n\t\tlist_splice_tail(seed, &seedlist);\n\n\tdrbg_string_fill(&vdata, drbg->V, drbg_statelen(drbg));\n\tlist_add_tail(&vdata.list, &vdatalist);\n\tfor (i = 2; 0 < i; i--) {\n\t\t\/* first round uses 0x0, second 0x1 *\/\n\t\tunsigned char prefix = DRBG_PREFIX0;\n\t\tif (1 == i)\n\t\t\tprefix = DRBG_PREFIX1;\n\t\t\/* 10.1.2.2 step 1 and 4 -- concatenation and HMAC for key *\/\n\t\tseed2.buf = &prefix;\n\t\tret = drbg_kcapi_hash(drbg, drbg->C, drbg->C, &seedlist);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/* 10.1.2.2 step 2 and 5 -- HMAC for V *\/\n\t\tret = drbg_kcapi_hash(drbg, drbg->C, drbg->V, &vdatalist);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/* 10.1.2.2 step 3 *\/\n\t\tif (!seed)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":24283,"func":"static void tscc2_idct4_put ( int * in , int q [ 3 ] , uint8_t * dst , int stride ) {\n int i ;\n int tblk [ 4 * 4 ] ;\n int t0 , t1 , t2 , t3 ;\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n t0 = DEQUANT ( q [ 0 + ( i & 1 ) ] , in [ 0 * 4 + i ] ) ;\n t1 = DEQUANT ( q [ 1 + ( i & 1 ) ] , in [ 1 * 4 + i ] ) ;\n t2 = DEQUANT ( q [ 0 + ( i & 1 ) ] , in [ 2 * 4 + i ] ) ;\n t3 = DEQUANT ( q [ 1 + ( i & 1 ) ] , in [ 3 * 4 + i ] ) ;\n DCT1D ( tblk [ 0 * 4 + i ] , tblk [ 1 * 4 + i ] , tblk [ 2 * 4 + i ] , tblk [ 3 * 4 + i ] , t0 , t1 , t2 , t3 , COL_OP ) ;\n }\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n DCT1D ( dst [ 0 ] , dst [ 1 ] , dst [ 2 ] , dst [ 3 ] , tblk [ i * 4 + 0 ] , tblk [ i * 4 + 1 ] , tblk [ i * 4 + 2 ] , tblk [ i * 4 + 3 ] , ROW_OP ) ;\n dst += stride ;\n }\n }","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":489576,"func":"GF_Err xtra_box_dump(GF_Box *a, FILE * trace)\n{\n\tGF_XtraBox *ptr = (GF_XtraBox *)a;\n\tu32 i, count = gf_list_count(ptr->tags);\n\n\tgf_isom_box_dump_start(a, \"XtraBox\", trace);\n\tgf_fprintf(trace, \">\\n\");\n\tfor (i=0; i<count; i++) {\n\t\tGF_XtraTag *tag = gf_list_get(ptr->tags, i);\n\n\t\tgf_fprintf(trace, \"<WMATag name=\\\"%s\\\" version=\\\"%d\\\" type=\\\"%d\\\"\", tag->name, tag->flags, tag->prop_type);\n\t\tif (!tag->prop_type) {\n\t\t\tu16 *src_str = (u16 *) tag->prop_value;\n\t\t\tu32 len = UTF8_MAX_BYTES_PER_CHAR * gf_utf8_wcslen(src_str);\n\t\t\tchar *utf8str = (char *)gf_malloc(len + 1);\n\t\t\tu32 res_len = gf_utf8_wcstombs(utf8str, len, (const unsigned short **) &src_str);\n\t\t\tif (res_len != GF_UTF8_FAIL) {\n\t\t\t\tutf8str[res_len] = 0;\n\n\t\t\t\tgf_fprintf(trace, \" value=\\\"%s\\\">\\n\", utf8str);\n\t\t\t}\n\t\t\tgf_free(utf8str);\n\t\t} else {\n\t\t\tgf_fprintf(trace, \" value=\\\"\");\n\t\t\tdump_data_hex(trace, tag->prop_value, tag->prop_size);\n\t\t\tgf_fprintf(trace, \"\\\">\\n\");\n\t\t}\n\t}\n\tgf_isom_box_dump_done(\"XtraBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":202529,"func":"_fep_transceive_control_message (Fep               *fep,\n                                 int                fd,\n                                 FepControlMessage *request,\n                                 FepControlMessage *response)\n{\n  FepList *messages = NULL;\n  int retval = 0;\n\n  retval = _fep_write_control_message (fd, request);\n  if (retval < 0)\n    return retval;\n\n  while (true)\n    {\n      FepControlMessage message;\n\n      retval = _fep_read_control_message (fd, &message);\n      if (retval < 0)\n\tgoto out;\n\n      if (message.command == FEP_CONTROL_RESPONSE)\n\t{\n\t  memcpy (response, &message, sizeof (FepControlMessage));\n\t  break;\n\t}\n\n      fep_log (FEP_LOG_LEVEL_DEBUG,\n\t       \"not a control response %d\",\n\t       message.command);\n\n      messages = _fep_append_control_message (messages, &message);\n    }\n\n  if (response->n_args == 0)\n    {\n      _fep_control_message_free_args (response);\n      fep_log (FEP_LOG_LEVEL_WARNING,\n\t       \"too few arguments for RESPONSE\");\n      retval = -1;\n      goto out;\n    }\n\n  if (response->args[0].len != 1)\n    {\n      _fep_control_message_free_args (response);\n      fep_log (FEP_LOG_LEVEL_WARNING,\n\t       \"can't extract command from RESPONSE\");\n      retval = -1;\n      goto out;\n    }\n\n  if (*response->args[0].str != request->command)\n    {\n      _fep_control_message_free_args (response);\n      fep_log (FEP_LOG_LEVEL_WARNING,\n\t       \"commands do not match (%d != %d)\",\n\t       *response->args[0].str,\n\t       request->command);\n      retval = -1;\n      goto out;\n    }\n\n out:\n  \/* flush queued messages received during waiting for response *\/\n  while (messages)\n    {\n      FepList *_head = messages;\n      FepControlMessage *_message = _head->data;\n\n      messages = _head->next;\n\n      _fep_dispatch_control_message (fep, _message);\n      _fep_control_message_free (_message);\n      free (_head);\n    }\n  return retval;\n}\n","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":84149,"func":"static int lsm_set_label_at(int lsm_labelfd, int on_exec, char *lsm_label)\n{\n\tint fret = -1;\n\tconst char* name;\n\tchar *command = NULL;\n\n\tname = lsm_name();\n\n\tif (strcmp(name, \"nop\") == 0)\n\t\treturn 0;\n\n\tif (strcmp(name, \"none\") == 0)\n\t\treturn 0;\n\n\t\/* We don't support on-exec with AppArmor *\/\n\tif (strcmp(name, \"AppArmor\") == 0)\n\t\ton_exec = 0;\n\n\tif (strcmp(name, \"AppArmor\") == 0) {\n\t\tint size;\n\n\t\tcommand = malloc(strlen(lsm_label) + strlen(\"changeprofile \") + 1);\n\t\tif (!command) {\n\t\t\tSYSERROR(\"Failed to write apparmor profile\");\n\t\t\tgoto out;\n\t\t}\n\n\t\tsize = sprintf(command, \"changeprofile %s\", lsm_label);\n\t\tif (size < 0) {\n\t\t\tSYSERROR(\"Failed to write apparmor profile\");\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (write(lsm_labelfd, command, size + 1) < 0) {\n\t\t\tSYSERROR(\"Unable to set LSM label: %s.\", command);\n\t\t\tgoto out;\n\t\t}\n\t\tINFO(\"Set LSM label to: %s.\", command);\n\t} else if (strcmp(name, \"SELinux\") == 0) {\n\t\tif (write(lsm_labelfd, lsm_label, strlen(lsm_label) + 1) < 0) {\n\t\t\tSYSERROR(\"Unable to set LSM label\");\n\t\t\tgoto out;\n\t\t}\n\t\tINFO(\"Set LSM label to: %s.\", lsm_label);\n\t} else {\n\t\tERROR(\"Unable to restore label for unknown LSM: %s\", name);\n\t\tgoto out;\n\t}\n\tfret = 0;\n\nout:\n\tfree(command);\n\n\tif (lsm_labelfd != -1)\n\t\tclose(lsm_labelfd);\n\n\treturn fret;\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":421889,"func":"flatpak_dir_update_appstream_oci (FlatpakDir          *self,\n                                  const char          *remote,\n                                  const char          *arch,\n                                  gboolean            *out_changed,\n                                  OstreeAsyncProgress *progress,\n                                  GCancellable        *cancellable,\n                                  GError             **error)\n{\n  g_autoptr(GFile) arch_dir = NULL;\n  g_autoptr(GFile) lock_file = NULL;\n  g_auto(GLnxLockFile) lock = { 0, };\n  g_autoptr(GFile) index_cache = NULL;\n  g_autofree char *index_uri = NULL;\n  g_autoptr(GFile) timestamp_file = NULL;\n  g_autoptr(GFile) icons_dir = NULL;\n  glnx_autofd int icons_dfd = -1;\n  g_autoptr(GBytes) appstream = NULL;\n  g_autoptr(GFile) new_appstream_file = NULL;\n\n  arch_dir = flatpak_build_file (flatpak_dir_get_path (self),\n                                 \"appstream\", remote, arch, NULL);\n  if (g_mkdir_with_parents (flatpak_file_get_path_cached (arch_dir), 0755) != 0)\n    {\n      glnx_set_error_from_errno (error);\n      return FALSE;\n    }\n\n  lock_file = g_file_get_child (arch_dir, \"lock\");\n  if (!glnx_make_lock_file (AT_FDCWD, flatpak_file_get_path_cached (lock_file),\n                            LOCK_EX, &lock, error))\n    return FALSE;\n\n  index_cache = flatpak_dir_update_oci_index (self, remote, &index_uri, cancellable, error);\n  if (index_cache == NULL)\n    return FALSE;\n\n  timestamp_file = g_file_get_child (arch_dir, \".timestamp\");\n  if (check_destination_mtime (index_cache, timestamp_file, cancellable))\n    return TRUE;\n\n  icons_dir = g_file_get_child (arch_dir, \"icons\");\n  if (g_mkdir_with_parents (flatpak_file_get_path_cached (icons_dir), 0755) != 0)\n    {\n      glnx_set_error_from_errno (error);\n      return FALSE;\n    }\n\n  if (!glnx_opendirat (AT_FDCWD, flatpak_file_get_path_cached (icons_dir),\n                       FALSE, &icons_dfd, error))\n    return FALSE;\n\n  ensure_soup_session (self);\n\n  appstream = flatpak_oci_index_make_appstream (self->soup_session,\n                                                index_cache,\n                                                index_uri,\n                                                arch,\n                                                icons_dfd,\n                                                cancellable,\n                                                error);\n  if (appstream == NULL)\n    return FALSE;\n\n  new_appstream_file = g_file_get_child (arch_dir, \"appstream.xml.gz\");\n  if (!replace_contents_compressed (new_appstream_file, appstream, cancellable, error))\n    return FALSE;\n\n  if (!g_file_replace_contents (timestamp_file, \"\", 0, NULL, FALSE,\n                                G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, error))\n    return FALSE;\n\n  if (out_changed)\n    *out_changed = TRUE;\n\n  return TRUE;\n}","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":116416,"func":"void xmlrpc_send_string(const char *value)\n{\n\tint len;\n\tchar buf[1024];\n\tconst char *ss;\n\tmowgli_string_t *s = mowgli_string_create();\n\tchar *s2;\n\tchar *header;\n\n\tif (xmlrpc.encode)\n\t{\n\t\tsnprintf(buf, sizeof buf, \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\\r\\n<methodResponse>\\r\\n<params>\\r\\n\", xmlrpc.encode);\n\t}\n\telse\n\t{\n\t\tsnprintf(buf, sizeof buf, \"<?xml version=\\\"1.0\\\"?>\\r\\n<methodResponse>\\r\\n<params>\\r\\n\");\n\t}\n\ts->append(s, buf, strlen(buf));\n\n\tss = \" <param>\\r\\n  <value>\\r\\n   <string>\";\n\ts->append(s, ss, strlen(ss));\n\txmlrpc_append_char_encode(s, value);\n\tss = \"<\/string>\\r\\n  <\/value>\\r\\n <\/param>\\r\\n\";\n\ts->append(s, ss, strlen(ss));\n\n\tss = \"<\/params>\\r\\n<\/methodResponse>\";\n\ts->append(s, ss, strlen(ss));\n\n\tlen = s->pos;\n\n\tif (xmlrpc.httpheader)\n\t{\n\t\theader = xmlrpc_write_header(len);\n\t\ts2 = smalloc(strlen(header) + len + 1);\n\t\tstrcpy(s2, header);\n\t\tmemcpy(s2 + strlen(header), s->str, len);\n\t\txmlrpc.setbuffer(s2, len + strlen(header));\n\t\tfree(header);\n\t\tfree(s2);\n\t\txmlrpc.httpheader = 1;\n\t}\n\telse\n\t{\n\t\txmlrpc.setbuffer(s->str, len);\n\t}\n\tif (xmlrpc.encode)\n\t{\n\t\tfree(xmlrpc.encode);\n\t\txmlrpc.encode = NULL;\n\t}\n\n\ts->destroy(s);\n}","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":373595,"func":"static void init_amd_k6(struct cpuinfo_x86 *c)\n{\n\tu32 l, h;\n\tint mbytes = get_num_physpages() >> (20-PAGE_SHIFT);\n\n\tif (c->x86_model < 6) {\n\t\t\/* Based on AMD doc 20734R - June 2000 *\/\n\t\tif (c->x86_model == 0) {\n\t\t\tclear_cpu_cap(c, X86_FEATURE_APIC);\n\t\t\tset_cpu_cap(c, X86_FEATURE_PGE);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (c->x86_model == 6 && c->x86_mask == 1) {\n\t\tconst int K6_BUG_LOOP = 1000000;\n\t\tint n;\n\t\tvoid (*f_vide)(void);\n\t\tunsigned long d, d2;\n\n\t\tprintk(KERN_INFO \"AMD K6 stepping B detected - \");\n\n\t\t\/*\n\t\t * It looks like AMD fixed the 2.6.2 bug and improved indirect\n\t\t * calls at the same time.\n\t\t *\/\n\n\t\tn = K6_BUG_LOOP;\n\t\tf_vide = vide;\n\t\trdtscl(d);\n\t\twhile (n--)\n\t\t\tf_vide();\n\t\trdtscl(d2);\n\t\td = d2-d;\n\n\t\tif (d > 20*K6_BUG_LOOP)\n\t\t\tprintk(KERN_CONT\n\t\t\t\t\"system stability may be impaired when more than 32 MB are used.\\n\");\n\t\telse\n\t\t\tprintk(KERN_CONT \"probably OK (after B9730xxxx).\\n\");\n\t}\n\n\t\/* K6 with old style WHCR *\/\n\tif (c->x86_model < 8 ||\n\t   (c->x86_model == 8 && c->x86_mask < 8)) {\n\t\t\/* We can only write allocate on the low 508Mb *\/\n\t\tif (mbytes > 508)\n\t\t\tmbytes = 508;\n\n\t\trdmsr(MSR_K6_WHCR, l, h);\n\t\tif ((l&0x0000FFFF) == 0) {\n\t\t\tunsigned long flags;\n\t\t\tl = (1<<0)|((mbytes\/4)<<1);\n\t\t\tlocal_irq_save(flags);\n\t\t\twbinvd();\n\t\t\twrmsr(MSR_K6_WHCR, l, h);\n\t\t\tlocal_irq_restore(flags);\n\t\t\tprintk(KERN_INFO \"Enabling old style K6 write allocation for %d Mb\\n\",\n\t\t\t\tmbytes);\n\t\t}\n\t\treturn;\n\t}\n\n\tif ((c->x86_model == 8 && c->x86_mask > 7) ||\n\t     c->x86_model == 9 || c->x86_model == 13) {\n\t\t\/* The more serious chips .. *\/\n\n\t\tif (mbytes > 4092)\n\t\t\tmbytes = 4092;\n\n\t\trdmsr(MSR_K6_WHCR, l, h);\n\t\tif ((l&0xFFFF0000) == 0) {\n\t\t\tunsigned long flags;\n\t\t\tl = ((mbytes>>2)<<22)|(1<<16);\n\t\t\tlocal_irq_save(flags);\n\t\t\twbinvd();\n\t\t\twrmsr(MSR_K6_WHCR, l, h);\n\t\t\tlocal_irq_restore(flags);\n\t\t\tprintk(KERN_INFO \"Enabling new style K6 write allocation for %d Mb\\n\",\n\t\t\t\tmbytes);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (c->x86_model == 10) {\n\t\t\/* AMD Geode LX is model 10 *\/\n\t\t\/* placeholder for any needed mods *\/\n\t\treturn;\n\t}\n}","target":0,"code_token_length":774,"total_token_length":1010,"max_tokens_setting":1024}
+{"idx":302570,"func":"void CreateExtremalDataAndRunAveragePool(bool padding_same) {\n  const int batch = UniformRandomInt(1, 2);\n  const int input_depth = UniformRandomInt(1, 700);\n  const int output_depth = input_depth;\n  const int input_width_offset = UniformRandomInt(1, 30);\n  const int input_height_offset = UniformRandomInt(1, 30);\n  const int stride_width = UniformRandomInt(1, 128);\n  const int stride_height = UniformRandomInt(1, 128);\n  const int filter_width = UniformRandomInt(1, 28);\n  const int filter_height = UniformRandomInt(1, 28);\n  if (filter_width * filter_height > 64) {\n    std::cout << \"should test 32 version\" << std::endl;\n  }\n  const int input_width = input_width_offset + filter_width;\n  const int input_height = input_height_offset + filter_height;\n  const int output_width =\n      padding_same ? (input_width + stride_width - 1) \/ stride_width\n                   : (input_width - filter_width + stride_width) \/ stride_width;\n  const int output_height =\n      padding_same\n          ? (input_height + stride_height - 1) \/ stride_height\n          : (input_height - filter_height + stride_height) \/ stride_height;\n\n  auto input_shape =\n      RuntimeShape({batch, input_height, input_width, input_depth});\n  auto output_shape =\n      RuntimeShape({batch, output_height, output_width, output_depth});\n\n  PoolParams params;\n  params.stride_height = stride_height;\n  params.stride_width = stride_width;\n  params.filter_height = filter_height;\n  params.filter_width = filter_width;\n  params.quantized_activation_min =\n      static_cast<int8_t>(std::numeric_limits<int8_t>::lowest());\n  params.quantized_activation_max =\n      static_cast<int8_t>(std::numeric_limits<int8_t>::max());\n  auto compute_padding = [](int stride, int in_size, int filter_size,\n                            int out_size) {\n    int padding = ((out_size - 1) * stride + filter_size - in_size) \/ 2;\n    return padding > 0 ? padding : 0;\n  };\n  params.padding_values.width =\n      compute_padding(stride_width, input_width, filter_width, output_width);\n  params.padding_values.height = compute_padding(stride_height, input_height,\n                                                 filter_height, output_height);\n\n  const int buffer_size = input_shape.FlatSize();\n  std::vector<int8> input_data(buffer_size);\n\n  \/\/ Test small values\n  int8 min = std::numeric_limits<int8>::min();\n  int8 max = std::numeric_limits<int8>::min() + 10;\n  FillRandom(&input_data, min, max);\n  RunOneAveragePoolTest(params, input_shape, input_data.data(), output_shape);\n\n  \/\/ Test large values\n  min = std::numeric_limits<int8>::max() - 10;\n  max = std::numeric_limits<int8>::max();\n  FillRandom(&input_data, min, max);\n  RunOneAveragePoolTest(params, input_shape, input_data.data(), output_shape);\n}","target":0,"code_token_length":683,"total_token_length":919,"max_tokens_setting":1024}
+{"idx":83105,"func":"static int cbs_av1_read_increment(CodedBitstreamContext *ctx, GetBitContext *gbc,\n                                  uint32_t range_min, uint32_t range_max,\n                                  const char *name, uint32_t *write_to)\n{\n    uint32_t value;\n    int position, i;\n    char bits[33];\n\n    av_assert0(range_min <= range_max && range_max - range_min < sizeof(bits) - 1);\n    if (ctx->trace_enable)\n        position = get_bits_count(gbc);\n\n    for (i = 0, value = range_min; value < range_max;) {\n        if (get_bits_left(gbc) < 1) {\n            av_log(ctx->log_ctx, AV_LOG_ERROR, \"Invalid increment value at \"\n                   \"%s: bitstream ended.\\n\", name);\n            return AVERROR_INVALIDDATA;\n        }\n        if (get_bits1(gbc)) {\n            bits[i++] = '1';\n            ++value;\n        } else {\n            bits[i++] = '0';\n            break;\n        }\n    }\n\n    if (ctx->trace_enable) {\n        bits[i] = 0;\n        ff_cbs_trace_syntax_element(ctx, position,\n                                    name, NULL, bits, value);\n    }\n\n    *write_to = value;\n    return 0;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":81599,"func":"static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data,\n\t\t\t  int reg)\n{\n\tctxt->ops->get_fpu(ctxt);\n\tswitch (reg) {\n\tcase 0: asm(\"movdqu %0, %%xmm0\" : : \"m\"(*data)); break;\n\tcase 1: asm(\"movdqu %0, %%xmm1\" : : \"m\"(*data)); break;\n\tcase 2: asm(\"movdqu %0, %%xmm2\" : : \"m\"(*data)); break;\n\tcase 3: asm(\"movdqu %0, %%xmm3\" : : \"m\"(*data)); break;\n\tcase 4: asm(\"movdqu %0, %%xmm4\" : : \"m\"(*data)); break;\n\tcase 5: asm(\"movdqu %0, %%xmm5\" : : \"m\"(*data)); break;\n\tcase 6: asm(\"movdqu %0, %%xmm6\" : : \"m\"(*data)); break;\n\tcase 7: asm(\"movdqu %0, %%xmm7\" : : \"m\"(*data)); break;\n#ifdef CONFIG_X86_64\n\tcase 8: asm(\"movdqu %0, %%xmm8\" : : \"m\"(*data)); break;\n\tcase 9: asm(\"movdqu %0, %%xmm9\" : : \"m\"(*data)); break;\n\tcase 10: asm(\"movdqu %0, %%xmm10\" : : \"m\"(*data)); break;\n\tcase 11: asm(\"movdqu %0, %%xmm11\" : : \"m\"(*data)); break;\n\tcase 12: asm(\"movdqu %0, %%xmm12\" : : \"m\"(*data)); break;\n\tcase 13: asm(\"movdqu %0, %%xmm13\" : : \"m\"(*data)); break;\n\tcase 14: asm(\"movdqu %0, %%xmm14\" : : \"m\"(*data)); break;\n\tcase 15: asm(\"movdqu %0, %%xmm15\" : : \"m\"(*data)); break;\n#endif\n\tdefault: BUG();\n\t}\n\tctxt->ops->put_fpu(ctxt);\n}","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":347518,"func":"static const char *GetOpenCLCacheDirectory()\n{\n  if (cache_directory == (char *) NULL)\n    {\n      if (cache_directory_lock == (SemaphoreInfo *) NULL)\n        ActivateSemaphoreInfo(&cache_directory_lock);\n      LockSemaphoreInfo(cache_directory_lock);\n      if (cache_directory == (char *) NULL)\n        {\n          char\n            *home,\n            path[MagickPathExtent],\n            *temp;\n\n          MagickBooleanType\n            status;\n\n          struct stat\n            attributes;\n\n          temp=(char *) NULL;\n          home=GetEnvironmentValue(\"MAGICK_OPENCL_CACHE_DIR\");\n          if (home == (char *) NULL)\n            {\n              home=GetEnvironmentValue(\"XDG_CACHE_HOME\");\n              if (home == (char *) NULL)\n                home=GetEnvironmentValue(\"LOCALAPPDATA\");\n              if (home == (char *) NULL)\n                home=GetEnvironmentValue(\"APPDATA\");\n              if (home == (char *) NULL)\n                home=GetEnvironmentValue(\"USERPROFILE\");\n            }\n\n          if (home != (char *) NULL)\n            {\n              \/* first check if $HOME exists *\/\n              (void) FormatLocaleString(path,MagickPathExtent,\"%s\",home);\n              status=GetPathAttributes(path,&attributes);\n              if (status == MagickFalse)\n                status=MagickCreateDirectory(path);\n\n              \/* first check if $HOME\/ImageMagick exists *\/\n              if (status != MagickFalse)\n                {\n                  (void) FormatLocaleString(path,MagickPathExtent,\n                    \"%s%sImageMagick\",home,DirectorySeparator);\n\n                  status=GetPathAttributes(path,&attributes);\n                  if (status == MagickFalse)\n                    status=MagickCreateDirectory(path);\n                }\n\n              if (status != MagickFalse)\n                {\n                  temp=(char*) AcquireMagickMemory(strlen(path)+1);\n                  CopyMagickString(temp,path,strlen(path)+1);\n                }\n              home=DestroyString(home);\n            }\n          else\n            {\n              home=GetEnvironmentValue(\"HOME\");\n              if (home != (char *) NULL)\n                {\n                  \/* first check if $HOME\/.cache exists *\/\n                  (void) FormatLocaleString(path,MagickPathExtent,\"%s%s.cache\",\n                    home,DirectorySeparator);\n                  status=GetPathAttributes(path,&attributes);\n                  if (status == MagickFalse)\n                    status=MagickCreateDirectory(path);\n\n                  \/* first check if $HOME\/.cache\/ImageMagick exists *\/\n                  if (status != MagickFalse)\n                    {\n                      (void) FormatLocaleString(path,MagickPathExtent,\n                        \"%s%s.cache%sImageMagick\",home,DirectorySeparator,\n                        DirectorySeparator);\n                      status=GetPathAttributes(path,&attributes);\n                      if (status == MagickFalse)\n                        status=MagickCreateDirectory(path);\n                    }\n\n                  if (status != MagickFalse)\n                    {\n                      temp=(char*) AcquireMagickMemory(strlen(path)+1);\n                      CopyMagickString(temp,path,strlen(path)+1);\n                    }\n                  home=DestroyString(home);\n                }\n            }\n          if (temp == (char *) NULL)\n            temp=AcquireString(\"?\");\n          cache_directory=temp;\n        }\n      UnlockSemaphoreInfo(cache_directory_lock);\n    }\n  if (*cache_directory == '?')\n    return((const char *) NULL);\n  return(cache_directory);\n}","target":1,"code_token_length":683,"total_token_length":919,"max_tokens_setting":1024}
+{"idx":91949,"func":"smb2_async_readv(struct cifs_readdata *rdata)\n{\n\tint rc, flags = 0;\n\tchar *buf;\n\tstruct smb2_sync_hdr *shdr;\n\tstruct cifs_io_parms io_parms;\n\tstruct smb_rqst rqst = { .rq_iov = rdata->iov,\n\t\t\t\t .rq_nvec = 1 };\n\tstruct TCP_Server_Info *server;\n\tunsigned int total_len;\n\n\tcifs_dbg(FYI, \"%s: offset=%llu bytes=%u\\n\",\n\t\t __func__, rdata->offset, rdata->bytes);\n\n\tio_parms.tcon = tlink_tcon(rdata->cfile->tlink);\n\tio_parms.offset = rdata->offset;\n\tio_parms.length = rdata->bytes;\n\tio_parms.persistent_fid = rdata->cfile->fid.persistent_fid;\n\tio_parms.volatile_fid = rdata->cfile->fid.volatile_fid;\n\tio_parms.pid = rdata->pid;\n\n\tserver = io_parms.tcon->ses->server;\n\n\trc = smb2_new_read_req(\n\t\t(void **) &buf, &total_len, &io_parms, rdata, 0, 0);\n\tif (rc)\n\t\treturn rc;\n\n\tif (smb3_encryption_required(io_parms.tcon))\n\t\tflags |= CIFS_TRANSFORM_REQ;\n\n\trdata->iov[0].iov_base = buf;\n\trdata->iov[0].iov_len = total_len;\n\n\tshdr = (struct smb2_sync_hdr *)buf;\n\n\tif (rdata->credits.value > 0) {\n\t\tshdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes,\n\t\t\t\t\t\tSMB2_MAX_BUFFER_SIZE));\n\t\tshdr->CreditRequest =\n\t\t\tcpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1);\n\n\t\trc = adjust_credits(server, &rdata->credits, rdata->bytes);\n\t\tif (rc)\n\t\t\tgoto async_readv_out;\n\n\t\tflags |= CIFS_HAS_CREDITS;\n\t}\n\n\tkref_get(&rdata->refcount);\n\trc = cifs_call_async(io_parms.tcon->ses->server, &rqst,\n\t\t\t     cifs_readv_receive, smb2_readv_callback,\n\t\t\t     smb3_handle_read_data, rdata, flags,\n\t\t\t     &rdata->credits);\n\tif (rc) {\n\t\tkref_put(&rdata->refcount, cifs_readdata_release);\n\t\tcifs_stats_fail_inc(io_parms.tcon, SMB2_READ_HE);\n\t\ttrace_smb3_read_err(0 \/* xid *\/, io_parms.persistent_fid,\n\t\t\t\t    io_parms.tcon->tid,\n\t\t\t\t    io_parms.tcon->ses->Suid,\n\t\t\t\t    io_parms.offset, io_parms.length, rc);\n\t}\n\nasync_readv_out:\n\tcifs_small_buf_release(buf);\n\treturn rc;\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":227961,"func":"ttfFont *ttfFont__create(gs_font_dir *dir)\n{\n    gs_memory_t *mem = dir->memory->stable_memory;\n    ttfFont *ttf;\n\n    if (dir->ttm == NULL) {\n        gx_ttfMemory *m = gs_alloc_struct(mem, gx_ttfMemory, &st_gx_ttfMemory, \"ttfFont__create(gx_ttfMemory)\");\n\n        if (!m)\n            return 0;\n        m->super.alloc_struct = gx_ttfMemory__alloc_struct;\n        m->super.alloc_bytes = gx_ttfMemory__alloc_bytes;\n        m->super.free = gx_ttfMemory__free;\n        m->memory = mem;\n        dir->ttm = m;\n    }\n    if(ttfInterpreter__obtain(&dir->ttm->super, &dir->tti))\n        return 0;\n    if(gx_san__obtain(mem, &dir->san))\n        return 0;\n    ttf = gs_alloc_struct(mem, ttfFont, &st_ttfFont, \"ttfFont__create\");\n    if (ttf == NULL)\n        return 0;\n#ifdef DEBUG\n    ttfFont__init(ttf, &dir->ttm->super, DebugRepaint,\n                  (gs_debug_c('Y') ? DebugPrint : NULL), mem);\n#else\n    ttfFont__init(ttf, &dir->ttm->super, DebugRepaint, NULL, mem);\n#endif\n\n    return ttf;\n}\n","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":274162,"func":"static int create_discard_cmd_control(struct f2fs_sb_info *sbi)\n{\n\tdev_t dev = sbi->sb->s_bdev->bd_dev;\n\tstruct discard_cmd_control *dcc;\n\tint err = 0, i;\n\n\tif (SM_I(sbi)->dcc_info) {\n\t\tdcc = SM_I(sbi)->dcc_info;\n\t\tgoto init_thread;\n\t}\n\n\tdcc = kzalloc(sizeof(struct discard_cmd_control), GFP_KERNEL);\n\tif (!dcc)\n\t\treturn -ENOMEM;\n\n\tdcc->discard_granularity = DEFAULT_DISCARD_GRANULARITY;\n\tINIT_LIST_HEAD(&dcc->entry_list);\n\tfor (i = 0; i < MAX_PLIST_NUM; i++) {\n\t\tINIT_LIST_HEAD(&dcc->pend_list[i]);\n\t\tif (i >= dcc->discard_granularity - 1)\n\t\t\tdcc->pend_list_tag[i] |= P_ACTIVE;\n\t}\n\tINIT_LIST_HEAD(&dcc->wait_list);\n\tmutex_init(&dcc->cmd_lock);\n\tatomic_set(&dcc->issued_discard, 0);\n\tatomic_set(&dcc->issing_discard, 0);\n\tatomic_set(&dcc->discard_cmd_cnt, 0);\n\tdcc->nr_discards = 0;\n\tdcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg;\n\tdcc->undiscard_blks = 0;\n\tdcc->root = RB_ROOT;\n\n\tinit_waitqueue_head(&dcc->discard_wait_queue);\n\tSM_I(sbi)->dcc_info = dcc;\ninit_thread:\n\tdcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,\n\t\t\t\t\"f2fs_discard-%u:%u\", MAJOR(dev), MINOR(dev));\n\tif (IS_ERR(dcc->f2fs_issue_discard)) {\n\t\terr = PTR_ERR(dcc->f2fs_issue_discard);\n\t\tkfree(dcc);\n\t\tSM_I(sbi)->dcc_info = NULL;\n\t\treturn err;\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":168069,"func":"void smp_decide_association_model(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {\n uint8_t int_evt = 0;\n  tSMP_INT_DATA smp_int_data;\n\n  SMP_TRACE_DEBUG(\"%s Association Model = %d\", __func__,\n                  p_cb->selected_association_model);\n\n switch (p_cb->selected_association_model) {\n case SMP_MODEL_ENCRYPTION_ONLY: \/* TK = 0, go calculate Confirm *\/\n if (p_cb->role == HCI_ROLE_MASTER &&\n ((p_cb->peer_auth_req & SMP_AUTH_YN_BIT) != 0) &&\n ((p_cb->loc_auth_req & SMP_AUTH_YN_BIT) == 0)) {\n        SMP_TRACE_ERROR(\n \"IO capability does not meet authentication requirement\");\n        smp_int_data.status = SMP_PAIR_AUTH_FAIL;\n        int_evt = SMP_AUTH_CMPL_EVT;\n } else {\n        p_cb->sec_level = SMP_SEC_UNAUTHENTICATE;\n        SMP_TRACE_EVENT(\"p_cb->sec_level =%d (SMP_SEC_UNAUTHENTICATE) \",\n                        p_cb->sec_level);\n\n        tSMP_KEY key;\n        key.key_type = SMP_KEY_TYPE_TK;\n        key.p_data = p_cb->tk;\n        smp_int_data.key = key;\n\n        memset(p_cb->tk, 0, BT_OCTET16_LEN);\n \/* TK, ready  *\/\n        int_evt = SMP_KEY_READY_EVT;\n }\n break;\n\n case SMP_MODEL_PASSKEY:\n      p_cb->sec_level = SMP_SEC_AUTHENTICATED;\n      SMP_TRACE_EVENT(\"p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) \",\n                      p_cb->sec_level);\n\n      p_cb->cb_evt = SMP_PASSKEY_REQ_EVT;\n      int_evt = SMP_TK_REQ_EVT;\n break;\n\n case SMP_MODEL_OOB:\n      SMP_TRACE_ERROR(\"Association Model = SMP_MODEL_OOB\");\n      p_cb->sec_level = SMP_SEC_AUTHENTICATED;\n      SMP_TRACE_EVENT(\"p_cb->sec_level =%d (SMP_SEC_AUTHENTICATED) \",\n                      p_cb->sec_level);\n\n      p_cb->cb_evt = SMP_OOB_REQ_EVT;\n      int_evt = SMP_TK_REQ_EVT;\n break;\n\n case SMP_MODEL_KEY_NOTIF:\n      p_cb->sec_level = SMP_SEC_AUTHENTICATED;\n      SMP_TRACE_DEBUG(\"Need to generate Passkey\");\n\n \/* generate passkey and notify application *\/\n      smp_generate_passkey(p_cb, NULL);\n break;\n\n case SMP_MODEL_SEC_CONN_JUSTWORKS:\n case SMP_MODEL_SEC_CONN_NUM_COMP:\n case SMP_MODEL_SEC_CONN_PASSKEY_ENT:\n case SMP_MODEL_SEC_CONN_PASSKEY_DISP:\n case SMP_MODEL_SEC_CONN_OOB:\n      int_evt = SMP_PUBL_KEY_EXCH_REQ_EVT;\n break;\n\n case SMP_MODEL_OUT_OF_RANGE:\n      SMP_TRACE_ERROR(\"Association Model = SMP_MODEL_OUT_OF_RANGE (failed)\");\n      smp_int_data.status = SMP_UNKNOWN_IO_CAP;\n      int_evt = SMP_AUTH_CMPL_EVT;\n break;\n\n default:\n      SMP_TRACE_ERROR(\n \"Association Model = %d (SOMETHING IS WRONG WITH THE CODE)\",\n          p_cb->selected_association_model);\n      smp_int_data.status = SMP_UNKNOWN_IO_CAP;\n      int_evt = SMP_AUTH_CMPL_EVT;\n }\n\n  SMP_TRACE_EVENT(\"sec_level=%d \", p_cb->sec_level);\n if (int_evt) smp_sm_event(p_cb, int_evt, &smp_int_data);\n}\n","target":0,"code_token_length":715,"total_token_length":951,"max_tokens_setting":1024}
+{"idx":151947,"func":"const char *gf_m4a_object_type_name(u32 objectType)\n{\n\tswitch (objectType) {\n\tcase 0:\n\t\treturn \"MPEG-4 Audio Reserved\";\n\tcase 1:\n\t\treturn \"MPEG-4 Audio AAC Main\";\n\tcase 2:\n\t\treturn \"MPEG-4 Audio AAC LC\";\n\tcase 3:\n\t\treturn \"MPEG-4 Audio AAC SSR\";\n\tcase 4:\n\t\treturn \"MPEG-4 Audio AAC LTP\";\n\tcase 5:\n\t\treturn \"MPEG-4 Audio SBR\";\n\tcase 6:\n\t\treturn \"MPEG-4 Audio AAC Scalable\";\n\tcase 7:\n\t\treturn \"MPEG-4 Audio TwinVQ\";\n\tcase 8:\n\t\treturn \"MPEG-4 Audio CELP\";\n\tcase 9:\n\t\treturn \"MPEG-4 Audio HVXC\";\n\tcase 10:\n\t\treturn \"MPEG-4 Audio Reserved\";\n\tcase 11:\n\t\treturn \"MPEG-4 Audio Reserved\";\n\tcase 12:\n\t\treturn \"MPEG-4 Audio TTSI\";\n\tcase 13:\n\t\treturn \"MPEG-4 Audio Main synthetic\";\n\tcase 14:\n\t\treturn \"MPEG-4 Audio Wavetable synthesis\";\n\tcase 15:\n\t\treturn \"MPEG-4 Audio General MIDI\";\n\tcase 16:\n\t\treturn \"MPEG-4 Audio Algorithmic Synthesis and Audio FX\";\n\tcase 17:\n\t\treturn \"MPEG-4 Audio ER AAC LC\";\n\tcase 18:\n\t\treturn \"MPEG-4 Audio Reserved\";\n\tcase 19:\n\t\treturn \"MPEG-4 Audio ER AAC LTP\";\n\tcase 20:\n\t\treturn \"MPEG-4 Audio ER AAC scalable\";\n\tcase 21:\n\t\treturn \"MPEG-4 Audio ER TwinVQ\";\n\tcase 22:\n\t\treturn \"MPEG-4 Audio ER BSAC\";\n\tcase 23:\n\t\treturn \"MPEG-4 Audio ER AAC LD\";\n\tcase 24:\n\t\treturn \"MPEG-4 Audio ER CELP\";\n\tcase 25:\n\t\treturn \"MPEG-4 Audio ER HVXC\";\n\tcase 26:\n\t\treturn \"MPEG-4 Audio ER HILN\";\n\tcase 27:\n\t\treturn \"MPEG-4 Audio ER Parametric\";\n\tcase 28:\n\t\treturn \"MPEG-4 Audio SSC\";\n\tcase 29:\n\t\treturn \"MPEG-4 Audio ParametricStereo\";\n\tcase 30:\n\t\treturn \"MPEG-4 Audio Reserved\";\n\tcase 31:\n\t\treturn \"MPEG-4 Audio Reserved\";\n\tcase 32:\n\t\treturn \"MPEG-1 Audio Layer-1\";\n\tcase 33:\n\t\treturn \"MPEG-1 Audio Layer-2\";\n\tcase 34:\n\t\treturn \"MPEG-1 Audio Layer-3\";\n\tcase 35:\n\t\treturn \"MPEG-4 Audio DST\";\n\tcase 36:\n\t\treturn \"MPEG-4 Audio ALS\";\n\tdefault:\n\t\treturn \"MPEG-4 Audio Unknown\";\n\t}\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":80881,"func":"static long region_del(struct resv_map *resv, long f, long t)\n{\n\tstruct list_head *head = &resv->regions;\n\tstruct file_region *rg, *trg;\n\tstruct file_region *nrg = NULL;\n\tlong del = 0;\n\nretry:\n\tspin_lock(&resv->lock);\n\tlist_for_each_entry_safe(rg, trg, head, link) {\n\t\t\/*\n\t\t * Skip regions before the range to be deleted.  file_region\n\t\t * ranges are normally of the form [from, to).  However, there\n\t\t * may be a \"placeholder\" entry in the map which is of the form\n\t\t * (from, to) with from == to.  Check for placeholder entries\n\t\t * at the beginning of the range to be deleted.\n\t\t *\/\n\t\tif (rg->to <= f && (rg->to != rg->from || rg->to != f))\n\t\t\tcontinue;\n\n\t\tif (rg->from >= t)\n\t\t\tbreak;\n\n\t\tif (f > rg->from && t < rg->to) { \/* Must split region *\/\n\t\t\t\/*\n\t\t\t * Check for an entry in the cache before dropping\n\t\t\t * lock and attempting allocation.\n\t\t\t *\/\n\t\t\tif (!nrg &&\n\t\t\t    resv->region_cache_count > resv->adds_in_progress) {\n\t\t\t\tnrg = list_first_entry(&resv->region_cache,\n\t\t\t\t\t\t\tstruct file_region,\n\t\t\t\t\t\t\tlink);\n\t\t\t\tlist_del(&nrg->link);\n\t\t\t\tresv->region_cache_count--;\n\t\t\t}\n\n\t\t\tif (!nrg) {\n\t\t\t\tspin_unlock(&resv->lock);\n\t\t\t\tnrg = kmalloc(sizeof(*nrg), GFP_KERNEL);\n\t\t\t\tif (!nrg)\n\t\t\t\t\treturn -ENOMEM;\n\t\t\t\tgoto retry;\n\t\t\t}\n\n\t\t\tdel += t - f;\n\n\t\t\t\/* New entry for end of split region *\/\n\t\t\tnrg->from = t;\n\t\t\tnrg->to = rg->to;\n\t\t\tINIT_LIST_HEAD(&nrg->link);\n\n\t\t\t\/* Original entry is trimmed *\/\n\t\t\trg->to = f;\n\n\t\t\tlist_add(&nrg->link, &rg->link);\n\t\t\tnrg = NULL;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (f <= rg->from && t >= rg->to) { \/* Remove entire region *\/\n\t\t\tdel += rg->to - rg->from;\n\t\t\tlist_del(&rg->link);\n\t\t\tkfree(rg);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (f <= rg->from) {\t\/* Trim beginning of region *\/\n\t\t\tdel += t - rg->from;\n\t\t\trg->from = t;\n\t\t} else {\t\t\/* Trim end of region *\/\n\t\t\tdel += rg->to - f;\n\t\t\trg->to = f;\n\t\t}\n\t}\n\n\tspin_unlock(&resv->lock);\n\tkfree(nrg);\n\treturn del;\n}","target":0,"code_token_length":588,"total_token_length":824,"max_tokens_setting":1024}
+{"idx":1646,"func":"static void fmtint ( char * * sbuffer , char * * buffer , size_t * currlen , size_t * maxlen , LLONG value , int base , int min , int max , int flags ) {\n int signvalue = 0 ;\n const char * prefix = \"\" ;\n unsigned LLONG uvalue ;\n char convert [ DECIMAL_SIZE ( value ) + 3 ] ;\n int place = 0 ;\n int spadlen = 0 ;\n int zpadlen = 0 ;\n int caps = 0 ;\n if ( max < 0 ) max = 0 ;\n uvalue = value ;\n if ( ! ( flags & DP_F_UNSIGNED ) ) {\n if ( value < 0 ) {\n signvalue = '-' ;\n uvalue = - value ;\n }\n else if ( flags & DP_F_PLUS ) signvalue = '+' ;\n else if ( flags & DP_F_SPACE ) signvalue = ' ' ;\n }\n if ( flags & DP_F_NUM ) {\n if ( base == 8 ) prefix = \"0\" ;\n if ( base == 16 ) prefix = \"0x\" ;\n }\n if ( flags & DP_F_UP ) caps = 1 ;\n do {\n convert [ place ++ ] = ( caps ? \"0123456789ABCDEF\" : \"0123456789abcdef\" ) [ uvalue % ( unsigned ) base ] ;\n uvalue = ( uvalue \/ ( unsigned ) base ) ;\n }\n while ( uvalue && ( place < ( int ) sizeof ( convert ) ) ) ;\n if ( place == sizeof ( convert ) ) place -- ;\n convert [ place ] = 0 ;\n zpadlen = max - place ;\n spadlen = min - OSSL_MAX ( max , place ) - ( signvalue ? 1 : 0 ) - strlen ( prefix ) ;\n if ( zpadlen < 0 ) zpadlen = 0 ;\n if ( spadlen < 0 ) spadlen = 0 ;\n if ( flags & DP_F_ZERO ) {\n zpadlen = OSSL_MAX ( zpadlen , spadlen ) ;\n spadlen = 0 ;\n }\n if ( flags & DP_F_MINUS ) spadlen = - spadlen ;\n while ( spadlen > 0 ) {\n doapr_outch ( sbuffer , buffer , currlen , maxlen , ' ' ) ;\n -- spadlen ;\n }\n if ( signvalue ) doapr_outch ( sbuffer , buffer , currlen , maxlen , signvalue ) ;\n while ( * prefix ) {\n doapr_outch ( sbuffer , buffer , currlen , maxlen , * prefix ) ;\n prefix ++ ;\n }\n if ( zpadlen > 0 ) {\n while ( zpadlen > 0 ) {\n doapr_outch ( sbuffer , buffer , currlen , maxlen , '0' ) ;\n -- zpadlen ;\n }\n }\n while ( place > 0 ) doapr_outch ( sbuffer , buffer , currlen , maxlen , convert [ -- place ] ) ;\n while ( spadlen < 0 ) {\n doapr_outch ( sbuffer , buffer , currlen , maxlen , ' ' ) ;\n ++ spadlen ;\n }\n return ;\n }","target":1,"code_token_length":662,"total_token_length":898,"max_tokens_setting":1024}
+{"idx":215664,"func":"ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)\n{\n\tstruct session_state *state = ssh->state;\n\tint len, r, ms_remain;\n\tfd_set *setp;\n\tchar buf[8192];\n\tstruct timeval timeout, start, *timeoutp = NULL;\n\n\tDBG(debug(\"packet_read()\"));\n\n\tsetp = calloc(howmany(state->connection_in + 1,\n\t    NFDBITS), sizeof(fd_mask));\n\tif (setp == NULL)\n\t\treturn SSH_ERR_ALLOC_FAIL;\n\n\t\/*\n\t * Since we are blocking, ensure that all written packets have\n\t * been sent.\n\t *\/\n\tif ((r = ssh_packet_write_wait(ssh)) != 0)\n\t\tgoto out;\n\n\t\/* Stay in the loop until we have received a complete packet. *\/\n\tfor (;;) {\n\t\t\/* Try to read a packet from the buffer. *\/\n\t\tr = ssh_packet_read_poll_seqnr(ssh, typep, seqnr_p);\n\t\tif (r != 0)\n\t\t\tbreak;\n\t\tif (!compat20 && (\n\t\t    *typep == SSH_SMSG_SUCCESS\n\t\t    || *typep == SSH_SMSG_FAILURE\n\t\t    || *typep == SSH_CMSG_EOF\n\t\t    || *typep == SSH_CMSG_EXIT_CONFIRMATION))\n\t\t\tif ((r = sshpkt_get_end(ssh)) != 0)\n\t\t\t\tbreak;\n\t\t\/* If we got a packet, return it. *\/\n\t\tif (*typep != SSH_MSG_NONE)\n\t\t\tbreak;\n\t\t\/*\n\t\t * Otherwise, wait for some data to arrive, add it to the\n\t\t * buffer, and try again.\n\t\t *\/\n\t\tmemset(setp, 0, howmany(state->connection_in + 1,\n\t\t    NFDBITS) * sizeof(fd_mask));\n\t\tFD_SET(state->connection_in, setp);\n\n\t\tif (state->packet_timeout_ms > 0) {\n\t\t\tms_remain = state->packet_timeout_ms;\n\t\t\ttimeoutp = &timeout;\n\t\t}\n\t\t\/* Wait for some data to arrive. *\/\n\t\tfor (;;) {\n\t\t\tif (state->packet_timeout_ms != -1) {\n\t\t\t\tms_to_timeval(&timeout, ms_remain);\n\t\t\t\tgettimeofday(&start, NULL);\n\t\t\t}\n\t\t\tif ((r = select(state->connection_in + 1, setp,\n\t\t\t    NULL, NULL, timeoutp)) >= 0)\n\t\t\t\tbreak;\n\t\t\tif (errno != EAGAIN && errno != EINTR &&\n\t\t\t    errno != EWOULDBLOCK)\n\t\t\t\tbreak;\n\t\t\tif (state->packet_timeout_ms == -1)\n\t\t\t\tcontinue;\n\t\t\tms_subtract_diff(&start, &ms_remain);\n\t\t\tif (ms_remain <= 0) {\n\t\t\t\tr = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (r == 0)\n\t\t\treturn SSH_ERR_CONN_TIMEOUT;\n\t\t\/* Read data from the socket. *\/\n\t\tlen = read(state->connection_in, buf, sizeof(buf));\n\t\tif (len == 0) {\n\t\t\tr = SSH_ERR_CONN_CLOSED;\n\t\t\tgoto out;\n\t\t}\n\t\tif (len < 0) {\n\t\t\tr = SSH_ERR_SYSTEM_ERROR;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Append it to the buffer. *\/\n\t\tif ((r = ssh_packet_process_incoming(ssh, buf, len)) != 0)\n\t\t\tgoto out;\n\t}\n out:\n\tfree(setp);\n\treturn r;\n}\n","target":0,"code_token_length":712,"total_token_length":948,"max_tokens_setting":1024}
+{"idx":370306,"func":"xsltInitDocKeyTable(xsltTransformContextPtr ctxt, const xmlChar *name,\n                    const xmlChar *nameURI)\n{\n    xsltStylesheetPtr style;\n    xsltKeyDefPtr keyd = NULL;\n    int found = 0;\n\n#ifdef KEY_INIT_DEBUG\nfprintf(stderr, \"xsltInitDocKeyTable %s\\n\", name);\n#endif\n\n    style = ctxt->style;\n    while (style != NULL) {\n\tkeyd = (xsltKeyDefPtr) style->keys;\n\twhile (keyd != NULL) {\n\t    if (((keyd->nameURI != NULL) ==\n\t\t (nameURI != NULL)) &&\n\t\txmlStrEqual(keyd->name, name) &&\n\t\txmlStrEqual(keyd->nameURI, nameURI))\n\t    {\n\t\txsltInitCtxtKey(ctxt, ctxt->document, keyd);\n\t\tif (ctxt->document->nbKeysComputed == ctxt->nbKeys)\n\t\t    return(0);\n\t\tfound = 1;\n\t    }\n\t    keyd = keyd->next;\n\t}\n\tstyle = xsltNextImport(style);\n    }\n    if (found == 0) {\n#ifdef WITH_XSLT_DEBUG_KEYS\n\tXSLT_TRACE(ctxt,XSLT_TRACE_KEYS,xsltGenericDebug(xsltGenericDebugContext,\n\t     \"xsltInitDocKeyTable: did not found %s\\n\", name));\n#endif\n\txsltTransformError(ctxt, NULL, keyd? keyd->inst : NULL,\n\t    \"Failed to find key definition for %s\\n\", name);\n\tctxt->state = XSLT_STATE_STOPPED;\n        return(-1);\n    }\n#ifdef KEY_INIT_DEBUG\nfprintf(stderr, \"xsltInitDocKeyTable %s done\\n\", name);\n#endif\n    return(0);\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":446168,"func":"virDomainVcpuPinDefParseXML(virDomainDefPtr def,\n                            xmlNodePtr node)\n{\n    virDomainVcpuDefPtr vcpu;\n    unsigned int vcpuid;\n    g_autofree char *tmp = NULL;\n\n    if (!(tmp = virXMLPropString(node, \"vcpu\"))) {\n        virReportError(VIR_ERR_XML_ERROR, \"%s\", _(\"missing vcpu id in vcpupin\"));\n        return -1;\n    }\n\n    if (virStrToLong_uip(tmp, NULL, 10, &vcpuid) < 0) {\n        virReportError(VIR_ERR_XML_ERROR,\n                       _(\"invalid setting for vcpu '%s'\"), tmp);\n        return -1;\n    }\n    VIR_FREE(tmp);\n\n    if (!(vcpu = virDomainDefGetVcpu(def, vcpuid))) {\n        VIR_WARN(\"Ignoring vcpupin for missing vcpus\");\n        return 0;\n    }\n\n    if (!(tmp = virXMLPropString(node, \"cpuset\"))) {\n        virReportError(VIR_ERR_INTERNAL_ERROR, \"%s\",\n                       _(\"missing cpuset for vcpupin\"));\n        return -1;\n    }\n\n    if (vcpu->cpumask) {\n        virReportError(VIR_ERR_INTERNAL_ERROR,\n                       _(\"duplicate vcpupin for vcpu '%d'\"), vcpuid);\n        return -1;\n    }\n\n    if (virBitmapParse(tmp, &vcpu->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)\n        return -1;\n\n    if (virBitmapIsAllClear(vcpu->cpumask)) {\n        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n                       _(\"Invalid value of 'cpuset': %s\"), tmp);\n        return -1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":443950,"func":"test_connection_missing_server_identity (TestConnection *test,\n                                         gconstpointer   data)\n{\n  GIOStream *connection;\n  GError *error = NULL;\n\n  test->database = g_tls_file_database_new (tls_test_file_path (\"ca-roots.pem\"), &error);\n  g_assert_no_error (error);\n  g_assert_nonnull (test->database);\n\n  \/* We pass NULL instead of test->identity when creating the client\n   * connection. This means verification must fail with\n   * G_TLS_CERTIFICATE_BAD_IDENTITY.\n   *\/\n  connection = start_async_server_and_connect_to_it (test, G_TLS_AUTHENTICATION_NONE);\n  test->client_connection = g_tls_client_connection_new (connection, NULL, &error);\n  g_assert_no_error (error);\n  g_assert_nonnull (test->client_connection);\n  g_object_unref (connection);\n\n  g_tls_connection_set_database (G_TLS_CONNECTION (test->client_connection), test->database);\n\n  \/* All validation in this test *\/\n  g_tls_client_connection_set_validation_flags (G_TLS_CLIENT_CONNECTION (test->client_connection),\n                                                G_TLS_CERTIFICATE_VALIDATE_ALL);\n\n  read_test_data_async (test);\n  g_main_loop_run (test->loop);\n  wait_until_server_finished (test);\n\n  g_assert_error (test->read_error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);\n\n#ifdef BACKEND_IS_GNUTLS\n  g_assert_error (test->server_error, G_TLS_ERROR, G_TLS_ERROR_NOT_TLS);\n#elif defined(BACKEND_IS_OPENSSL)\n  \/* FIXME: This is not OK. There should be a NOT_TLS errors. But some times\n   * we either get no error or BROKEN_PIPE\n   *\/\n#endif\n\n  g_clear_error (&test->read_error);\n  g_clear_error (&test->server_error);\n\n  g_clear_object (&test->client_connection);\n  g_clear_object (&test->server_connection);\n\n  \/* Now do the same thing again, this time ignoring bad identity. *\/\n\n  connection = start_async_server_and_connect_to_it (test, G_TLS_AUTHENTICATION_NONE);\n  test->client_connection = g_tls_client_connection_new (connection, NULL, &error);\n  g_assert_no_error (error);\n  g_assert_nonnull (test->client_connection);\n  g_object_unref (connection);\n\n  g_tls_connection_set_database (G_TLS_CONNECTION (test->client_connection), test->database);\n\n  g_tls_client_connection_set_validation_flags (G_TLS_CLIENT_CONNECTION (test->client_connection),\n                                                G_TLS_CERTIFICATE_VALIDATE_ALL & ~G_TLS_CERTIFICATE_BAD_IDENTITY);\n\n  read_test_data_async (test);\n  g_main_loop_run (test->loop);\n  wait_until_server_finished (test);\n\n  g_assert_no_error (test->read_error);\n  g_assert_no_error (test->server_error);\n}","target":0,"code_token_length":580,"total_token_length":816,"max_tokens_setting":1024}
+{"idx":118979,"func":"void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *handle)\n{\n\tstruct prpl_xfer_data *px = g_new0(struct prpl_xfer_data, 1);\n\tstruct purple_data *pd;\n\tchar *dir, *basename;\n\n\tft->data = px;\n\tpx->ft = ft;\n\tpx->ft->free = prpl_xfer_free;\n\n\tdir = g_strdup(\"\/tmp\/bitlbee-purple-ft.XXXXXX\");\n\tif (!mkdtemp(dir)) {\n\t\timcb_error(ic, \"Could not create temporary file for file transfer\");\n\t\tg_free(px);\n\t\tg_free(dir);\n\t\treturn;\n\t}\n\n\tif ((basename = strrchr(ft->file_name, '\/'))) {\n\t\tbasename++;\n\t} else {\n\t\tbasename = ft->file_name;\n\t}\n\tpx->fn = g_strdup_printf(\"%s\/%s\", dir, basename);\n\tpx->fd = open(px->fn, O_WRONLY | O_CREAT, 0600);\n\tg_free(dir);\n\n\tif (px->fd < 0) {\n\t\timcb_error(ic, \"Could not create temporary file for file transfer\");\n\t\tg_free(px);\n\t\tg_free(px->fn);\n\t\treturn;\n\t}\n\n\tpx->ic = ic;\n\tpx->handle = g_strdup(handle);\n\n\tpd = px->ic->proto_data;\n\tpd->filetransfers = g_slist_prepend(pd->filetransfers, px);\n\n\timcb_log(ic,\n\t         \"Due to libpurple limitations, the file has to be cached locally before proceeding with the actual file transfer. Please wait...\");\n\n\tpx->timeout = b_timeout_add(0, purple_transfer_request_cb, ft);\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":180297,"func":"void get_checksum2(char *buf, int32 len, char *sum)\n{\n\tmd_context m;\n\n\tswitch (xfersum_type) {\n\t  case CSUM_MD5: {\n\t\tuchar seedbuf[4];\n\t\tmd5_begin(&m);\n\t\tif (proper_seed_order) {\n\t\t\tif (checksum_seed) {\n\t\t\t\tSIVALu(seedbuf, 0, checksum_seed);\n\t\t\t\tmd5_update(&m, seedbuf, 4);\n\t\t\t}\n\t\t\tmd5_update(&m, (uchar *)buf, len);\n\t\t} else {\n\t\t\tmd5_update(&m, (uchar *)buf, len);\n\t\t\tif (checksum_seed) {\n\t\t\t\tSIVALu(seedbuf, 0, checksum_seed);\n\t\t\t\tmd5_update(&m, seedbuf, 4);\n\t\t\t}\n\t\t}\n\t\tmd5_result(&m, (uchar *)sum);\n\t\tbreak;\n          }\n          case CSUM_MD4:\n          case CSUM_MD4_OLD:\n         case CSUM_MD4_BUSTED:\n         case CSUM_MD4_ARCHAIC: {\n                int32 i;\n                static char *buf1;\n                static int32 len1;\n\t\tmdfour_begin(&m);\n\n\t\tif (len > len1) {\n\t\t\tif (buf1)\n\t\t\t\tfree(buf1);\n\t\t\tbuf1 = new_array(char, len+4);\n\t\t\tlen1 = len;\n\t\t\tif (!buf1)\n\t\t\t\tout_of_memory(\"get_checksum2\");\n\t\t}\n\n\t\tmemcpy(buf1, buf, len);\n\t\tif (checksum_seed) {\n\t\t\tSIVAL(buf1,len,checksum_seed);\n\t\t\tlen += 4;\n\t\t}\n\n\t\tfor (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK)\n\t\t\tmdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK);\n\n\t\t\/*\n\t\t * Prior to version 27 an incorrect MD4 checksum was computed\n\t\t * by failing to call mdfour_tail() for block sizes that\n\t\t * are multiples of 64.  This is fixed by calling mdfour_update()\n                 * are multiples of 64.  This is fixed by calling mdfour_update()\n                 * even when there are no more bytes.\n                 *\/\n               if (len - i > 0 || xfersum_type > CSUM_MD4_BUSTED)\n                        mdfour_update(&m, (uchar *)(buf1+i), len-i);\n \n                mdfour_result(&m, (uchar *)sum);\n\t  }\n\t}\n}\n","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":306080,"func":"command_key_event (FepClient *client,\n\t\t   FepControlMessage *request,\n\t\t   FepControlMessage *response)\n{\n  FepEventKey event;\n  int retval;\n  uint32_t intval;\n\n  retval = _fep_control_message_read_uint32_arg (request, 0, &intval);\n  if (retval < 0)\n    {\n      fep_log (FEP_LOG_LEVEL_WARNING, \"can't read keyval\");\n      goto out;\n    }\n  event.keyval = intval;\n\n  retval = _fep_control_message_read_uint32_arg (request, 1, &intval);\n  if (retval < 0)\n    {\n      fep_log (FEP_LOG_LEVEL_WARNING, \"can't read modifiers\");\n      goto out;\n    }\n  event.modifiers = intval;\n\n out:\n  response->command = FEP_CONTROL_RESPONSE;\n  _fep_control_message_alloc_args (response, 2);\n  _fep_control_message_write_uint8_arg (response, 0, FEP_CONTROL_KEY_EVENT);\n\n  intval = retval;\n  if (retval == 0 && client->filter)\n    {\n      event.event.type = FEP_KEY_PRESS;\n      event.source = request->args[2].str;\n      event.source_length = request->args[2].len;\n      intval = client->filter ((FepEvent *) &event, client->filter_data);\n      _fep_control_message_write_uint32_arg (response, 1, intval);\n    }\n\n  \/* If key is not handled, send back the original input to the server. *\/\n  if (intval == 0)\n    fep_client_send_data (client, request->args[2].str, request->args[2].len);\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":181076,"func":"void SyncManager::SyncInternal::OnSyncEngineEvent(\n    const SyncEngineEvent& event) {\n  DCHECK(thread_checker_.CalledOnValidThread());\n  if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) {\n    ModelSafeRoutingInfo enabled_types;\n    registrar_->GetModelSafeRoutingInfo(&enabled_types);\n    {\n      sync_api::ReadTransaction trans(FROM_HERE, GetUserShare());\n      Cryptographer* cryptographer = trans.GetCryptographer();\n      if (cryptographer->has_pending_keys()) {\n        DVLOG(1) << \"OnPassPhraseRequired Sent\";\n        sync_pb::EncryptedData pending_keys = cryptographer->GetPendingKeys();\n        FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                          OnPassphraseRequired(sync_api::REASON_DECRYPTION,\n                                               pending_keys));\n      } else if (!cryptographer->is_ready() &&\n                 event.snapshot->initial_sync_ended.Has(syncable::NIGORI)) {\n        DVLOG(1) << \"OnPassphraseRequired sent because cryptographer is not \"\n                 << \"ready\";\n        FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                          OnPassphraseRequired(sync_api::REASON_ENCRYPTION,\n                                               sync_pb::EncryptedData()));\n      }\n\n      allstatus_.SetCryptographerReady(cryptographer->is_ready());\n      allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());\n      allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes());\n    }\n\n    if (!initialized_) {\n      LOG(INFO) << \"OnSyncCycleCompleted not sent because sync api is not \"\n                << \"initialized\";\n      return;\n    }\n\n    if (!event.snapshot->has_more_to_sync) {\n      DVLOG(1) << \"Sending OnSyncCycleCompleted\";\n      FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                        OnSyncCycleCompleted(event.snapshot));\n    }\n\n    bool is_notifiable_commit =\n        (event.snapshot->syncer_status.num_successful_commits > 0);\n    if (is_notifiable_commit) {\n      if (sync_notifier_.get()) {\n        const ModelTypeSet changed_types =\n            syncable::ModelTypePayloadMapToEnumSet(\n                event.snapshot->source.types);\n        sync_notifier_->SendNotification(changed_types);\n      } else {\n        DVLOG(1) << \"Not sending notification: sync_notifier_ is NULL\";\n      }\n    }\n  }\n\n  if (event.what_happened == SyncEngineEvent::STOP_SYNCING_PERMANENTLY) {\n    FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                      OnStopSyncingPermanently());\n    return;\n  }\n\n  if (event.what_happened == SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED) {\n    FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                      OnClearServerDataSucceeded());\n    return;\n  }\n\n  if (event.what_happened == SyncEngineEvent::CLEAR_SERVER_DATA_FAILED) {\n    FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                      OnClearServerDataFailed());\n    return;\n  }\n\n  if (event.what_happened == SyncEngineEvent::UPDATED_TOKEN) {\n    FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                      OnUpdatedToken(event.updated_token));\n    return;\n  }\n\n  if (event.what_happened == SyncEngineEvent::ACTIONABLE_ERROR) {\n    FOR_EACH_OBSERVER(SyncManager::Observer, observers_,\n                      OnActionableError(\n                          event.snapshot->errors.sync_protocol_error));\n    return;\n  }\n\n}\n","target":0,"code_token_length":744,"total_token_length":980,"max_tokens_setting":1024}
+{"idx":206783,"func":"bool verifyJavaStringFormat(const StringPiece16& str) {\n const char16_t* c = str.begin();\n const char16_t* const end = str.end();\n\n size_t argCount = 0;\n bool nonpositional = false;\n while (c != end) {\n if (*c == u'%' && c + 1 < end) {\n            c++;\n\n if (*c == u'%') {\n                c++;\n continue;\n }\n\n            argCount++;\n\n size_t numDigits = consumeDigits(c, end);\n if (numDigits > 0) {\n                c += numDigits;\n if (c != end && *c != u'$') {\n                    nonpositional = true;\n }\n } else if (*c == u'<') {\n                nonpositional = true;\n\n                c++;\n\n if (c != end && *c == u'$') {\n                    c++;\n }\n } else {\n                nonpositional = true;\n }\n\n while (c != end && (*c == u'-' ||\n *c == u'#' ||\n *c == u'+' ||\n *c == u' ' ||\n *c == u',' ||\n *c == u'(' ||\n (*c >= u'0' && *c <= '9'))) {\n                c++;\n }\n\n \/*\n             * This is a shortcut to detect strings that are going to Time.format()\n             * instead of String.format()\n             *\n             * Comparison of String.format() and Time.format() args:\n             *\n             * String: ABC E GH  ST X abcdefgh  nost x\n             *   Time:    DEFGHKMS W Za  d   hkm  s w yz\n             *\n             * Therefore we know it's definitely Time if we have:\n             *     DFKMWZkmwyz\n             *\/\n if (c != end) {\n switch (*c) {\n case 'D':\n case 'F':\n case 'K':\n case 'M':\n case 'W':\n case 'Z':\n case 'k':\n case 'm':\n case 'w':\n case 'y':\n case 'z':\n return true;\n }\n }\n }\n\n if (c != end) {\n            c++;\n }\n }\n\n if (argCount > 1 && nonpositional) {\n return false;\n }\n return true;\n}\n","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":427839,"func":"static int wcd9335_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,\n\t\t\t\t       struct snd_kcontrol *kc, int event)\n{\n\tstruct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);\n\tint ret = 0;\n\n\tswitch (event) {\n\tcase SND_SOC_DAPM_POST_PMU:\n\t\t\/* 5ms sleep is required after PA is enabled as per\n\t\t * HW requirement\n\t\t *\/\n\t\tusleep_range(5000, 5500);\n\t\tsnd_soc_component_update_bits(comp,\n\t\t\t\t\tWCD9335_CDC_RX0_RX_PATH_CTL,\n\t\t\t\t\tWCD9335_CDC_RX_PGA_MUTE_EN_MASK,\n\t\t\t\t\tWCD9335_CDC_RX_PGA_MUTE_DISABLE);\n\t\t\/* Remove mix path mute if it is enabled *\/\n\t\tif ((snd_soc_component_read32(comp,\n\t\t\t\t\tWCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &\n\t\t\t\t\tWCD9335_CDC_RX_PGA_MUTE_EN_MASK)\n\t\t\tsnd_soc_component_update_bits(comp,\n\t\t\t\t\tWCD9335_CDC_RX0_RX_PATH_MIX_CTL,\n\t\t\t\t\tWCD9335_CDC_RX_PGA_MUTE_EN_MASK,\n\t\t\t\t\tWCD9335_CDC_RX_PGA_MUTE_DISABLE);\n\t\tbreak;\n\tcase SND_SOC_DAPM_POST_PMD:\n\t\t\/* 5ms sleep is required after PA is disabled as per\n\t\t * HW requirement\n\t\t *\/\n\t\tusleep_range(5000, 5500);\n\n\t\tbreak;\n\t};\n\n\treturn ret;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":17419,"func":"static void http_connection_test ( int persistent ) {\n short port = - 1 ;\n struct evhttp_connection * evcon = NULL ;\n struct evhttp_request * req = NULL ;\n test_ok = 0 ;\n fprintf ( stdout , \"Testing Request Connection Pipeline %s: \" , persistent ? \"(persistent)\" : \"\" ) ;\n http = http_setup ( & port , NULL ) ;\n evcon = evhttp_connection_new ( \"127.0.0.1\" , port ) ;\n if ( evcon == NULL ) {\n fprintf ( stdout , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n req = evhttp_request_new ( http_request_done , NULL ) ;\n evhttp_add_header ( req -> output_headers , \"Host\" , \"somehost\" ) ;\n if ( evhttp_make_request ( evcon , req , EVHTTP_REQ_GET , \"\/test\" ) == - 1 ) {\n fprintf ( stdout , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n event_dispatch ( ) ;\n if ( test_ok != 1 ) {\n fprintf ( stdout , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n test_ok = 0 ;\n req = evhttp_request_new ( http_request_done , NULL ) ;\n evhttp_add_header ( req -> output_headers , \"Host\" , \"somehost\" ) ;\n if ( ! persistent ) evhttp_add_header ( req -> output_headers , \"Connection\" , \"close\" ) ;\n if ( evhttp_make_request ( evcon , req , EVHTTP_REQ_GET , \"\/test\" ) == - 1 ) {\n fprintf ( stdout , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n event_dispatch ( ) ;\n test_ok = 0 ;\n req = evhttp_request_new ( http_request_empty_done , NULL ) ;\n evhttp_add_header ( req -> output_headers , \"Empty\" , \"itis\" ) ;\n if ( evhttp_make_request ( evcon , req , EVHTTP_REQ_GET , \"\/test\" ) == - 1 ) {\n fprintf ( stdout , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n event_dispatch ( ) ;\n if ( test_ok != 1 ) {\n fprintf ( stdout , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n evhttp_connection_free ( evcon ) ;\n evhttp_free ( http ) ;\n fprintf ( stdout , \"OK\\n\" ) ;\n }","target":0,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":64164,"func":"void CreateDataAndRunAveragePool(bool padding_same) {\n  const int batch = UniformRandomInt(1, 2);\n  const int input_depth = UniformRandomInt(1, 700);\n  const int output_depth = input_depth;\n  const int input_width_offset = UniformRandomInt(1, 30);\n  const int input_height_offset = UniformRandomInt(1, 30);\n  const int stride_width = UniformRandomInt(1, 10);\n  const int stride_height = UniformRandomInt(1, 10);\n  const int filter_width = UniformRandomInt(1, 10);\n  const int filter_height = UniformRandomInt(1, 10);\n  const int input_width = input_width_offset + filter_width;\n  const int input_height = input_height_offset + filter_height;\n  const int output_width =\n      padding_same ? (input_width + stride_width - 1) \/ stride_width\n                   : (input_width - filter_width + stride_width) \/ stride_width;\n  const int output_height =\n      padding_same\n          ? (input_height + stride_height - 1) \/ stride_height\n          : (input_height - filter_height + stride_height) \/ stride_height;\n\n  auto input_shape =\n      RuntimeShape({batch, input_height, input_width, input_depth});\n  auto output_shape =\n      RuntimeShape({batch, output_height, output_width, output_depth});\n  const int buffer_size = input_shape.FlatSize();\n  std::vector<int8> input_data(buffer_size);\n  FillRandom(&input_data);\n\n  PoolParams params;\n  params.stride_height = stride_height;\n  params.stride_width = stride_width;\n  params.filter_height = filter_height;\n  params.filter_width = filter_width;\n  params.quantized_activation_min =\n      static_cast<int8_t>(std::numeric_limits<int8_t>::lowest());\n  params.quantized_activation_max =\n      static_cast<int8_t>(std::numeric_limits<int8_t>::max());\n  auto compute_padding = [](int stride, int in_size, int filter_size,\n                            int out_size) {\n    int padding = ((out_size - 1) * stride + filter_size - in_size) \/ 2;\n    return padding > 0 ? padding : 0;\n  };\n  params.padding_values.width =\n      compute_padding(stride_width, input_width, filter_width, output_width);\n  params.padding_values.height = compute_padding(stride_height, input_height,\n                                                 filter_height, output_height);\n  RunOneAveragePoolTest(params, input_shape, input_data.data(), output_shape);\n}","target":0,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":328317,"func":"static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr,\n\n                                 struct target_ucontext_v2 *uc)\n\n{\n\n    sigset_t host_set;\n\n    abi_ulong *regspace;\n\n\n\n    target_to_host_sigset(&host_set, &uc->tuc_sigmask);\n\n    sigprocmask(SIG_SETMASK, &host_set, NULL);\n\n\n\n    if (restore_sigcontext(env, &uc->tuc_mcontext))\n\n        return 1;\n\n\n\n    \/* Restore coprocessor signal frame *\/\n\n    regspace = uc->tuc_regspace;\n\n    if (arm_feature(env, ARM_FEATURE_VFP)) {\n\n        regspace = restore_sigframe_v2_vfp(env, regspace);\n\n        if (!regspace) {\n\n            return 1;\n\n        }\n\n    }\n\n    if (arm_feature(env, ARM_FEATURE_IWMMXT)) {\n\n        regspace = restore_sigframe_v2_iwmmxt(env, regspace);\n\n        if (!regspace) {\n\n            return 1;\n\n        }\n\n    }\n\n\n\n    if (do_sigaltstack(frame_addr + offsetof(struct target_ucontext_v2, tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)\n\n        return 1;\n\n\n\n#if 0\n\n    \/* Send SIGTRAP if we're single-stepping *\/\n\n    if (ptrace_cancel_bpt(current))\n\n            send_sig(SIGTRAP, current, 1);\n\n#endif\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":241461,"func":"  NotificationView(const DialogNotification& data,\n                   AutofillDialogViewDelegate* delegate)\n      : data_(data),\n        delegate_(delegate),\n        checkbox_(NULL) {\n    scoped_ptr<views::View> label_view;\n    if (data.HasCheckbox()) {\n      scoped_ptr<views::Checkbox> checkbox(\n          new views::Checkbox(base::string16()));\n      checkbox->SetText(data.display_text());\n      checkbox->SetTextMultiLine(true);\n      checkbox->SetHorizontalAlignment(gfx::ALIGN_LEFT);\n      checkbox->SetTextColor(views::Button::STATE_NORMAL,\n                             data.GetTextColor());\n      checkbox->SetTextColor(views::Button::STATE_HOVERED,\n                             data.GetTextColor());\n      checkbox->SetChecked(data.checked());\n      checkbox->set_listener(this);\n      checkbox_ = checkbox.get();\n      label_view.reset(checkbox.release());\n    } else {\n      scoped_ptr<views::StyledLabel> label(new views::StyledLabel(\n          data.display_text(), this));\n      label->set_auto_color_readability_enabled(false);\n\n      views::StyledLabel::RangeStyleInfo text_style;\n      text_style.color = data.GetTextColor();\n\n      if (data.link_range().is_empty()) {\n        label->AddStyleRange(gfx::Range(0, data.display_text().size()),\n                             text_style);\n      } else {\n        gfx::Range prefix_range(0, data.link_range().start());\n        if (!prefix_range.is_empty())\n          label->AddStyleRange(prefix_range, text_style);\n\n        label->AddStyleRange(\n            data.link_range(),\n            views::StyledLabel::RangeStyleInfo::CreateForLink());\n\n        gfx::Range suffix_range(data.link_range().end(),\n                                data.display_text().size());\n        if (!suffix_range.is_empty())\n          label->AddStyleRange(suffix_range, text_style);\n      }\n\n      label_view.reset(label.release());\n    }\n\n    AddChildView(label_view.release());\n\n    if (!data.tooltip_text().empty())\n      AddChildView(new TooltipIcon(data.tooltip_text()));\n\n    set_background(\n       views::Background::CreateSolidBackground(data.GetBackgroundColor()));\n    SetBorder(views::Border::CreateSolidSidedBorder(\n        1, 0, 1, 0, data.GetBorderColor()));\n  }\n","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":379809,"func":"PHP_FUNCTION(sqlite_exec)\n{\n\tzval *zdb;\n\tstruct php_sqlite_db *db;\n\tchar *sql;\n\tint sql_len;\n\tchar *errtext = NULL;\n\tzval *errmsg = NULL;\n\tzval *object = getThis();\n\n\tif (object) {\n\t\tif (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s|z\/\", &sql, &sql_len, &errmsg)) {\n\t\t\treturn;\n\t\t}\n\t\tDB_FROM_OBJECT(db, object);\n\t} else {\n\t\tif(FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,\n\t\t\tZEND_NUM_ARGS() TSRMLS_CC, \"sr\", &sql, &sql_len, &zdb) &&\n\t\t   FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rs|z\/\", &zdb, &sql, &sql_len, &errmsg)) {\n\t\t\treturn;\n\t\t}\n\t\tDB_FROM_ZVAL(db, &zdb);\n\t}\n\n\tif (errmsg) {\n\t\tzval_dtor(errmsg);\n\t\tZVAL_NULL(errmsg);\n\t}\n\n\tPHP_SQLITE_EMPTY_QUERY;\n\n\tdb->last_err_code = sqlite_exec(db->db, sql, NULL, NULL, &errtext);\n\n\tif (db->last_err_code != SQLITE_OK) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"%s\", errtext);\n\t\tif (errmsg) {\n\t\t\tZVAL_STRING(errmsg, errtext, 1);\n\t\t}\n\t\tsqlite_freemem(errtext);\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_TRUE;\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":266166,"func":"EbmlElement * EbmlElement::FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, uint64 MaxDataSize)\n{\n  binary PossibleId[4];\n  int PossibleID_Length = 0;\n  binary PossibleSize[8]; \/\/ we don't support size stored in more than 64 bits\n  uint32 PossibleSizeLength = 0;\n  uint64 SizeUnknown;\n  uint64 SizeFound;\n  bool bElementFound = false;\n\n  binary BitMask;\n  uint64 aElementPosition, aSizePosition;\n  while (!bElementFound) {\n    \/\/ read ID\n    aElementPosition = DataStream.getFilePointer();\n    uint32 ReadSize = 0;\n    BitMask = 1 << 7;\n    while (1) {\n      ReadSize += DataStream.read(&PossibleId[PossibleID_Length], 1);\n      if (ReadSize == uint32(PossibleID_Length)) {\n        return NULL; \/\/ no more data ?\n      }\n      if (++PossibleID_Length > 4) {\n        return NULL; \/\/ we don't support element IDs over class D\n      }\n      if (PossibleId[0] & BitMask) {\n        \/\/ this is the last octet of the ID\n        \/\/ check wether that's the one we're looking for\n\/*      if (PossibleID == EBML_INFO_ID(ClassInfos)) {\n          break;\n        } else {\n          \/\/\/ \\todo This element should be skipped (use a context ?)\n        }*\/\n        bElementFound = true; \/\/\/ \\todo not exactly the one we're looking for\n        break;\n      }\n      BitMask >>= 1;\n    }\n\n    \/\/ read the data size\n    aSizePosition = DataStream.getFilePointer();\n    uint32 _SizeLength;\n    do {\n      if (PossibleSizeLength >= 8)\n        \/\/ Size is larger than 8 bytes\n        return NULL;\n\n      ReadSize += DataStream.read(&PossibleSize[PossibleSizeLength++], 1);\n      _SizeLength = PossibleSizeLength;\n      SizeFound = ReadCodedSizeValue(&PossibleSize[0], _SizeLength, SizeUnknown);\n    } while (_SizeLength == 0);\n  }\n\n  EbmlElement *Result = NULL;\n  EbmlId PossibleID(PossibleId, PossibleID_Length);\n  if (PossibleID == EBML_INFO_ID(ClassInfos)) {\n    \/\/ the element is the one expected\n    Result = &EBML_INFO_CREATE(ClassInfos);\n  } else {\n    \/\/\/ \\todo find the element in the context\n    Result = new (std::nothrow) EbmlDummy(PossibleID);\n    if(Result == NULL)\n      return NULL;\n  }\n\n  Result->SetSizeLength(PossibleSizeLength);\n\n  Result->Size = SizeFound;\n\n  if (!Result->ValidateSize() || (SizeFound != SizeUnknown && MaxDataSize < Result->Size)) {\n    delete Result;\n    return NULL;\n  }\n\n  \/\/ check if the size is not all 1s\n  if (SizeFound == SizeUnknown) {\n    \/\/ Size of this element is unknown\n    \/\/ only possible for Master elements\n    if (!Result->SetSizeInfinite()) {\n      \/\/\/ \\todo the element is not allowed to be infinite\n      delete Result;\n      return NULL;\n    }\n  } else Result->SetSizeInfinite(false);\n  Result->ElementPosition = aElementPosition;\n  Result->SizePosition = aSizePosition;\n\n  return Result;\n}","target":0,"code_token_length":731,"total_token_length":967,"max_tokens_setting":1024}
+{"idx":231258,"func":"isoent_clone_tree(struct archive_write *a, struct isoent **nroot,\n    struct isoent *root)\n{\n\tstruct isoent *np, *xroot, *newent;\n\n\tnp = root;\n\txroot = NULL;\n\tdo {\n\t\tnewent = isoent_clone(np);\n\t\tif (newent == NULL) {\n\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t    \"Can't allocate memory\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tif (xroot == NULL) {\n\t\t\t*nroot = xroot = newent;\n\t\t\tnewent->parent = xroot;\n\t\t} else\n\t\t\tisoent_add_child_tail(xroot, newent);\n\t\tif (np->dir && np->children.first != NULL) {\n\t\t\t\/* Enter to sub directories. *\/\n\t\t\tnp = np->children.first;\n\t\t\txroot = newent;\n\t\t\tcontinue;\n\t\t}\n\t\twhile (np != np->parent) {\n\t\t\tif (np->chnext == NULL) {\n\t\t\t\t\/* Return to the parent directory. *\/\n\t\t\t\tnp = np->parent;\n\t\t\t\txroot = xroot->parent;\n\t\t\t} else {\n\t\t\t\tnp = np->chnext;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} while (np != np->parent);\n\n\treturn (ARCHIVE_OK);\n}\n","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":436904,"func":"static int fts3TermSelectFinishMerge(Fts3Table *p, TermSelect *pTS){\n  char *aOut = 0;\n  int nOut = 0;\n  int i;\n\n  \/* Loop through the doclists in the aaOutput[] array. Merge them all\n  ** into a single doclist.\n  *\/\n  for(i=0; i<SizeofArray(pTS->aaOutput); i++){\n    if( pTS->aaOutput[i] ){\n      if( !aOut ){\n        aOut = pTS->aaOutput[i];\n        nOut = pTS->anOutput[i];\n        pTS->aaOutput[i] = 0;\n      }else{\n        int nNew;\n        char *aNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, \n            pTS->aaOutput[i], pTS->anOutput[i], aOut, nOut, &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aOut);\n          return rc;\n        }\n\n        sqlite3_free(pTS->aaOutput[i]);\n        sqlite3_free(aOut);\n        pTS->aaOutput[i] = 0;\n        aOut = aNew;\n        nOut = nNew;\n      }\n    }\n  }\n\n  pTS->aaOutput[0] = aOut;\n  pTS->anOutput[0] = nOut;\n  return SQLITE_OK;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":415572,"func":"imapx_disconnect (CamelIMAPXServer *is)\n{\n\tg_cancellable_cancel (is->priv->cancellable);\n\n\tg_mutex_lock (&is->priv->stream_lock);\n\n\tif (is->priv->connection) {\n\t\t\/* No need to wait for close for too long *\/\n\t\timapx_server_set_connection_timeout (is->priv->connection, 3);\n\t}\n\n\tg_clear_object (&is->priv->input_stream);\n\tg_clear_object (&is->priv->output_stream);\n\tg_clear_object (&is->priv->connection);\n\tg_clear_object (&is->priv->subprocess);\n\n\tif (is->priv->cinfo) {\n\t\timapx_free_capability (is->priv->cinfo);\n\t\tis->priv->cinfo = NULL;\n\t}\n\n\tg_mutex_unlock (&is->priv->stream_lock);\n\n\tg_mutex_lock (&is->priv->select_lock);\n\tg_weak_ref_set (&is->priv->select_mailbox, NULL);\n\tg_weak_ref_set (&is->priv->select_pending, NULL);\n\tg_mutex_unlock (&is->priv->select_lock);\n\n\tis->priv->is_cyrus = FALSE;\n\tis->priv->state = IMAPX_DISCONNECTED;\n\n\tg_mutex_lock (&is->priv->idle_lock);\n\tis->priv->idle_state = IMAPX_IDLE_STATE_OFF;\n\tg_cond_broadcast (&is->priv->idle_cond);\n\tg_mutex_unlock (&is->priv->idle_lock);\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":250118,"func":"int RenderFlexibleBox::firstLineBoxBaseline() const\n{\n    if (isWritingModeRoot() || m_numberOfInFlowChildrenOnFirstLine <= 0)\n        return -1;\n    RenderBox* baselineChild = 0;\n    int childNumber = 0;\n    for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) {\n        if (child->isOutOfFlowPositioned())\n            continue;\n        if (alignmentForChild(child) == ItemPositionBaseline && !hasAutoMarginsInCrossAxis(child)) {\n            baselineChild = child;\n            break;\n        }\n        if (!baselineChild)\n            baselineChild = child;\n\n        ++childNumber;\n        if (childNumber == m_numberOfInFlowChildrenOnFirstLine)\n            break;\n    }\n\n    if (!baselineChild)\n        return -1;\n\n    if (!isColumnFlow() && hasOrthogonalFlow(baselineChild))\n        return crossAxisExtentForChild(baselineChild) + baselineChild->logicalTop();\n    if (isColumnFlow() && !hasOrthogonalFlow(baselineChild))\n        return mainAxisExtentForChild(baselineChild) + baselineChild->logicalTop();\n\n    int baseline = baselineChild->firstLineBoxBaseline();\n    if (baseline == -1) {\n        LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine : VerticalLine;\n        return synthesizedBaselineFromContentBox(baselineChild, direction) + baselineChild->logicalTop();\n    }\n\n    return baseline + baselineChild->logicalTop();\n}\n","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":228676,"func":"bool HttpUtil::NameValuePairsIterator::GetNext() {\n  if (!props_.GetNext())\n    return false;\n\n  value_begin_ = props_.value_begin();\n  value_end_ = props_.value_end();\n  name_begin_ = name_end_ = value_end_;\n\n  std::string::const_iterator equals = std::find(value_begin_, value_end_, '=');\n  if (equals == value_end_ || equals == value_begin_)\n    return valid_ = false;  \/\/ Malformed, no equals sign\n\n  for (std::string::const_iterator it = value_begin_; it != equals; ++it) {\n    if (HttpUtil::IsQuote(*it))\n      return valid_ = false;  \/\/ Malformed, quote appears before equals sign\n  }\n\n  name_begin_ = value_begin_;\n  name_end_ = equals;\n  value_begin_ = equals + 1;\n\n  TrimLWS(&name_begin_, &name_end_);\n  TrimLWS(&value_begin_, &value_end_);\n  value_is_quoted_ = false;\n  unquoted_value_.clear();\n\n  if (value_begin_ == value_end_)\n    return valid_ = false;  \/\/ Malformed, value is empty\n\n  if (HttpUtil::IsQuote(*value_begin_)) {\n    if (*value_begin_ != *(value_end_ - 1) || value_begin_ + 1 == value_end_) {\n      ++value_begin_;  \/\/ Gracefully recover from mismatching quotes.\n    } else {\n      value_is_quoted_ = true;\n      unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_);\n    }\n  }\n\n  return true;\n}\n","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":401454,"func":"cr_tknzr_parse_w (CRTknzr * a_this, \n                  guchar ** a_start, \n                  guchar ** a_end, \n                  CRParsingLocation *a_location)\n{\n        guint32 cur_char = 0;\n        CRInputPos init_pos;\n        enum CRStatus status = CR_OK;\n\n        g_return_val_if_fail (a_this && PRIVATE (a_this)\n                              && PRIVATE (a_this)->input\n                              && a_start && a_end, \n                              CR_BAD_PARAM_ERROR);\n\n        RECORD_INITIAL_POS (a_this, &init_pos);\n\n        *a_start = NULL;\n        *a_end = NULL;\n\n        READ_NEXT_CHAR (a_this, &cur_char);\n\n        if (cr_utils_is_white_space (cur_char) == FALSE) {\n                status = CR_PARSING_ERROR;\n                goto error;\n        }\n        if (a_location) {\n                cr_tknzr_get_parsing_location (a_this, \n                                               a_location) ;\n        }\n        RECORD_CUR_BYTE_ADDR (a_this, a_start);\n        *a_end = *a_start;\n\n        for (;;) {\n                gboolean is_eof = FALSE;\n\n                cr_input_get_end_of_file (PRIVATE (a_this)->input, &is_eof);\n                if (is_eof)\n                        break;\n\n                status = cr_tknzr_peek_char (a_this, &cur_char);\n                if (status == CR_END_OF_INPUT_ERROR) {\n                        break;\n                } else if (status != CR_OK) {\n                        goto error;\n                }\n\n                if (cr_utils_is_white_space (cur_char) == TRUE) {\n                        READ_NEXT_CHAR (a_this, &cur_char);\n                        RECORD_CUR_BYTE_ADDR (a_this, a_end);\n                } else {\n                        break;\n                }\n        }\n\n        return CR_OK;\n\n      error:\n        cr_tknzr_set_cur_pos (a_this, &init_pos);\n\n        return status;\n}","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":172473,"func":"PHP_FUNCTION(pg_fetch_all_columns)\n{\n\tzval *result;\n\tPGresult *pgsql_result;\n\tpgsql_result_handle *pg_result;\n\tzend_long colno=0;\n\tint pg_numrows, pg_row;\n\tsize_t num_fields;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"r|l\", &result, &colno) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, \"PostgreSQL result\", le_result);\n\n\tpgsql_result = pg_result->result;\n\n\tnum_fields = PQnfields(pgsql_result);\n\tif (colno >= (zend_long)num_fields || colno < 0) {\n\t\tphp_error_docref(NULL, E_WARNING, \"Invalid column number '%pd'\", colno);\n\t\tRETURN_FALSE;\n\t}\n\n\tarray_init(return_value);\n\n\tif ((pg_numrows = PQntuples(pgsql_result)) <= 0) {\n\t\treturn;\n\t}\n\n\tfor (pg_row = 0; pg_row < pg_numrows; pg_row++) {\n\t\tif (PQgetisnull(pgsql_result, pg_row, (int)colno)) {\n\t\t\tadd_next_index_null(return_value);\n\t\t} else {\n\t\t\tadd_next_index_string(return_value, PQgetvalue(pgsql_result, pg_row, (int)colno)); \n\t\t}\n\t}\n}\n","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":33859,"func":"void test_checkout_nasty__dot_git_hfs_ignorable(void)\n{\n#ifdef __APPLE__\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_1\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_2\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_3\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_4\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_5\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_6\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_7\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_8\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_9\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_10\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_11\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_12\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_13\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_14\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_15\", \".git\/foobar\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_hfs_ignorable_16\", \".git\/foobar\");\n#endif\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":476484,"func":"static void lo_do_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,\n                          off_t offset, struct fuse_file_info *fi, int plus)\n{\n    struct lo_data *lo = lo_data(req);\n    struct lo_dirp *d = NULL;\n    struct lo_inode *dinode;\n    g_autofree char *buf = NULL;\n    char *p;\n    size_t rem = size;\n    int err = EBADF;\n\n    dinode = lo_inode(req, ino);\n    if (!dinode) {\n        goto error;\n    }\n\n    d = lo_dirp(req, fi);\n    if (!d) {\n        goto error;\n    }\n\n    err = ENOMEM;\n    buf = g_try_malloc0(size);\n    if (!buf) {\n        goto error;\n    }\n    p = buf;\n\n    if (offset != d->offset) {\n        seekdir(d->dp, offset);\n        d->entry = NULL;\n        d->offset = offset;\n    }\n    while (1) {\n        size_t entsize;\n        off_t nextoff;\n        const char *name;\n\n        if (!d->entry) {\n            errno = 0;\n            d->entry = readdir(d->dp);\n            if (!d->entry) {\n                if (errno) { \/* Error *\/\n                    err = errno;\n                    goto error;\n                } else { \/* End of stream *\/\n                    break;\n                }\n            }\n        }\n        nextoff = d->entry->d_off;\n        name = d->entry->d_name;\n\n        fuse_ino_t entry_ino = 0;\n        struct fuse_entry_param e = (struct fuse_entry_param){\n            .attr.st_ino = d->entry->d_ino,\n            .attr.st_mode = d->entry->d_type << 12,\n        };\n\n        \/* Hide root's parent directory *\/\n        if (dinode == &lo->root && strcmp(name, \"..\") == 0) {\n            e.attr.st_ino = lo->root.key.ino;\n            e.attr.st_mode = DT_DIR << 12;\n        }\n\n        if (plus) {\n            if (!is_dot_or_dotdot(name)) {\n                err = lo_do_lookup(req, ino, name, &e, NULL);\n                if (err) {\n                    goto error;\n                }\n                entry_ino = e.ino;\n            }\n\n            entsize = fuse_add_direntry_plus(req, p, rem, name, &e, nextoff);\n        } else {\n            entsize = fuse_add_direntry(req, p, rem, name, &e.attr, nextoff);\n        }\n        if (entsize > rem) {\n            if (entry_ino != 0) {\n                lo_forget_one(req, entry_ino, 1);\n            }\n            break;\n        }\n\n        p += entsize;\n        rem -= entsize;\n\n        d->entry = NULL;\n        d->offset = nextoff;\n    }\n\n    err = 0;\nerror:\n    lo_dirp_put(&d);\n    lo_inode_put(lo, &dinode);\n\n    \/*\n     * If there's an error, we can only signal it if we haven't stored\n     * any entries yet - otherwise we'd end up with wrong lookup\n     * counts for the entries that are already in the buffer. So we\n     * return what we've collected until that point.\n     *\/\n    if (err && rem == size) {\n        fuse_reply_err(req, err);\n    } else {\n        fuse_reply_buf(req, buf, size - rem);\n    }\n}","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":68216,"func":"int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v)\n{\n\tint changed = 0;\n\tif (snd_BUG_ON(snd_interval_empty(i)))\n\t\treturn -EINVAL;\n\tif (i->min < v->min) {\n\t\ti->min = v->min;\n\t\ti->openmin = v->openmin;\n\t\tchanged = 1;\n\t} else if (i->min == v->min && !i->openmin && v->openmin) {\n\t\ti->openmin = 1;\n\t\tchanged = 1;\n\t}\n\tif (i->max > v->max) {\n\t\ti->max = v->max;\n\t\ti->openmax = v->openmax;\n\t\tchanged = 1;\n\t} else if (i->max == v->max && !i->openmax && v->openmax) {\n\t\ti->openmax = 1;\n\t\tchanged = 1;\n\t}\n\tif (!i->integer && v->integer) {\n\t\ti->integer = 1;\n\t\tchanged = 1;\n\t}\n\tif (i->integer) {\n\t\tif (i->openmin) {\n\t\t\ti->min++;\n\t\t\ti->openmin = 0;\n\t\t}\n\t\tif (i->openmax) {\n\t\t\ti->max--;\n\t\t\ti->openmax = 0;\n\t\t}\n\t} else if (!i->openmin && !i->openmax && i->min == i->max)\n\t\ti->integer = 1;\n\tif (snd_interval_checkempty(i)) {\n\t\tsnd_interval_none(i);\n\t\treturn -EINVAL;\n\t}\n\treturn changed;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":323265,"func":"static void patch_reloc(uint8_t *code_ptr, int type,\n\n                        intptr_t value, intptr_t addend)\n\n{\n\n    uint32_t insn;\n\n    value += addend;\n\n    switch (type) {\n\n    case R_SPARC_32:\n\n        if (value != (uint32_t)value) {\n\n            tcg_abort();\n\n        }\n\n        *(uint32_t *)code_ptr = value;\n\n        break;\n\n    case R_SPARC_WDISP16:\n\n        value -= (intptr_t)code_ptr;\n\n        if (!check_fit_tl(value >> 2, 16)) {\n\n            tcg_abort();\n\n        }\n\n        insn = *(uint32_t *)code_ptr;\n\n        insn &= ~INSN_OFF16(-1);\n\n        insn |= INSN_OFF16(value);\n\n        *(uint32_t *)code_ptr = insn;\n\n        break;\n\n    case R_SPARC_WDISP19:\n\n        value -= (intptr_t)code_ptr;\n\n        if (!check_fit_tl(value >> 2, 19)) {\n\n            tcg_abort();\n\n        }\n\n        insn = *(uint32_t *)code_ptr;\n\n        insn &= ~INSN_OFF19(-1);\n\n        insn |= INSN_OFF19(value);\n\n        *(uint32_t *)code_ptr = insn;\n\n        break;\n\n    default:\n\n        tcg_abort();\n\n    }\n\n}\n","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":346808,"func":"static struct n_hdlc *n_hdlc_alloc(void)\n{\n\tstruct n_hdlc_buf *buf;\n\tint i;\n\tstruct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL);\n\n\tif (!n_hdlc)\n\t\treturn NULL;\n\n\tspin_lock_init(&n_hdlc->rx_free_buf_list.spinlock);\n\tspin_lock_init(&n_hdlc->tx_free_buf_list.spinlock);\n\tspin_lock_init(&n_hdlc->rx_buf_list.spinlock);\n\tspin_lock_init(&n_hdlc->tx_buf_list.spinlock);\n\t\n\t\/* allocate free rx buffer list *\/\n\tfor(i=0;i<DEFAULT_RX_BUF_COUNT;i++) {\n\t\tbuf = kmalloc(N_HDLC_BUF_SIZE, GFP_KERNEL);\n\t\tif (buf)\n\t\t\tn_hdlc_buf_put(&n_hdlc->rx_free_buf_list,buf);\n\t\telse if (debuglevel >= DEBUG_LEVEL_INFO)\t\n\t\t\tprintk(\"%s(%d)n_hdlc_alloc(), kalloc() failed for rx buffer %d\\n\",__FILE__,__LINE__, i);\n\t}\n\t\n\t\/* allocate free tx buffer list *\/\n\tfor(i=0;i<DEFAULT_TX_BUF_COUNT;i++) {\n\t\tbuf = kmalloc(N_HDLC_BUF_SIZE, GFP_KERNEL);\n\t\tif (buf)\n\t\t\tn_hdlc_buf_put(&n_hdlc->tx_free_buf_list,buf);\n\t\telse if (debuglevel >= DEBUG_LEVEL_INFO)\t\n\t\t\tprintk(\"%s(%d)n_hdlc_alloc(), kalloc() failed for tx buffer %d\\n\",__FILE__,__LINE__, i);\n\t}\n\t\n\t\/* Initialize the control block *\/\n\tn_hdlc->magic  = HDLC_MAGIC;\n\tn_hdlc->flags  = 0;\n\t\n\treturn n_hdlc;\n\t\n}\t\/* end of n_hdlc_alloc() *\/","target":1,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":355014,"func":"shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)\n{\n\tstruct inode\t*inode = file->f_path.dentry->d_inode;\n\tloff_t\t\tpos;\n\tunsigned long\twritten;\n\tssize_t\t\terr;\n\n\tif ((ssize_t) count < 0)\n\t\treturn -EINVAL;\n\n\tif (!access_ok(VERIFY_READ, buf, count))\n\t\treturn -EFAULT;\n\n\tmutex_lock(&inode->i_mutex);\n\n\tpos = *ppos;\n\twritten = 0;\n\n\terr = generic_write_checks(file, &pos, &count, 0);\n\tif (err || !count)\n\t\tgoto out;\n\n\terr = remove_suid(file->f_path.dentry);\n\tif (err)\n\t\tgoto out;\n\n\tinode->i_ctime = inode->i_mtime = CURRENT_TIME;\n\n\tdo {\n\t\tstruct page *page = NULL;\n\t\tunsigned long bytes, index, offset;\n\t\tchar *kaddr;\n\t\tint left;\n\n\t\toffset = (pos & (PAGE_CACHE_SIZE -1)); \/* Within page *\/\n\t\tindex = pos >> PAGE_CACHE_SHIFT;\n\t\tbytes = PAGE_CACHE_SIZE - offset;\n\t\tif (bytes > count)\n\t\t\tbytes = count;\n\n\t\t\/*\n\t\t * We don't hold page lock across copy from user -\n\t\t * what would it guard against? - so no deadlock here.\n\t\t * But it still may be a good idea to prefault below.\n\t\t *\/\n\n\t\terr = shmem_getpage(inode, index, &page, SGP_WRITE, NULL);\n\t\tif (err)\n\t\t\tbreak;\n\n\t\tleft = bytes;\n\t\tif (PageHighMem(page)) {\n\t\t\tvolatile unsigned char dummy;\n\t\t\t__get_user(dummy, buf);\n\t\t\t__get_user(dummy, buf + bytes - 1);\n\n\t\t\tkaddr = kmap_atomic(page, KM_USER0);\n\t\t\tleft = __copy_from_user_inatomic(kaddr + offset,\n\t\t\t\t\t\t\tbuf, bytes);\n\t\t\tkunmap_atomic(kaddr, KM_USER0);\n\t\t}\n\t\tif (left) {\n\t\t\tkaddr = kmap(page);\n\t\t\tleft = __copy_from_user(kaddr + offset, buf, bytes);\n\t\t\tkunmap(page);\n\t\t}\n\n\t\twritten += bytes;\n\t\tcount -= bytes;\n\t\tpos += bytes;\n\t\tbuf += bytes;\n\t\tif (pos > inode->i_size)\n\t\t\ti_size_write(inode, pos);\n\n\t\tflush_dcache_page(page);\n\t\tset_page_dirty(page);\n\t\tmark_page_accessed(page);\n\t\tpage_cache_release(page);\n\n\t\tif (left) {\n\t\t\tpos -= left;\n\t\t\twritten -= left;\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * Our dirty pages are not counted in nr_dirty,\n\t\t * and we do not attempt to balance dirty pages.\n\t\t *\/\n\n\t\tcond_resched();\n\t} while (count);\n\n\t*ppos = pos;\n\tif (written)\n\t\terr = written;\nout:\n\tmutex_unlock(&inode->i_mutex);\n\treturn err;\n}","target":0,"code_token_length":622,"total_token_length":858,"max_tokens_setting":1024}
+{"idx":141618,"func":"int snd_timer_open(struct snd_timer_instance **ti,\n\t\t   char *owner, struct snd_timer_id *tid,\n\t\t   unsigned int slave_id)\n{\n\tstruct snd_timer *timer;\n\tstruct snd_timer_instance *timeri = NULL;\n\n\tif (tid->dev_class == SNDRV_TIMER_CLASS_SLAVE) {\n\t\t\/* open a slave instance *\/\n\t\tif (tid->dev_sclass <= SNDRV_TIMER_SCLASS_NONE ||\n\t\t    tid->dev_sclass > SNDRV_TIMER_SCLASS_OSS_SEQUENCER) {\n\t\t\tpr_debug(\"ALSA: timer: invalid slave class %i\\n\",\n\t\t\t\t tid->dev_sclass);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tmutex_lock(®ister_mutex);\n\t\ttimeri = snd_timer_instance_new(owner, NULL);\n\t\tif (!timeri) {\n\t\t\tmutex_unlock(®ister_mutex);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\ttimeri->slave_class = tid->dev_sclass;\n\t\ttimeri->slave_id = tid->device;\n\t\ttimeri->flags |= SNDRV_TIMER_IFLG_SLAVE;\n\t\tlist_add_tail(&timeri->open_list, &snd_timer_slave_list);\n\t\tsnd_timer_check_slave(timeri);\n\t\tmutex_unlock(®ister_mutex);\n\t\t*ti = timeri;\n\t\treturn 0;\n\t}\n\n\t\/* open a master instance *\/\n\tmutex_lock(®ister_mutex);\n\ttimer = snd_timer_find(tid);\n#ifdef CONFIG_MODULES\n\tif (!timer) {\n\t\tmutex_unlock(®ister_mutex);\n\t\tsnd_timer_request(tid);\n\t\tmutex_lock(®ister_mutex);\n\t\ttimer = snd_timer_find(tid);\n\t}\n#endif\n\tif (!timer) {\n\t\tmutex_unlock(®ister_mutex);\n\t\treturn -ENODEV;\n\t}\n\tif (!list_empty(&timer->open_list_head)) {\n\t\ttimeri = list_entry(timer->open_list_head.next,\n\t\t\t\t    struct snd_timer_instance, open_list);\n\t\tif (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) {\n\t\t\tmutex_unlock(®ister_mutex);\n\t\t\treturn -EBUSY;\n\t\t}\n\t}\n\ttimeri = snd_timer_instance_new(owner, timer);\n\tif (!timeri) {\n\t\tmutex_unlock(®ister_mutex);\n\t\treturn -ENOMEM;\n\t}\n\t\/* take a card refcount for safe disconnection *\/\n\tif (timer->card)\n\t\tget_device(&timer->card->card_dev);\n\ttimeri->slave_class = tid->dev_sclass;\n\ttimeri->slave_id = slave_id;\n\tif (list_empty(&timer->open_list_head) && timer->hw.open)\n\t\ttimer->hw.open(timer);\n\tlist_add_tail(&timeri->open_list, &timer->open_list_head);\n\tsnd_timer_check_master(timeri);\n\tmutex_unlock(®ister_mutex);\n\t*ti = timeri;\n\treturn 0;\n}","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":47694,"func":"int mp_radix_size (mp_int *a, int radix, int *size)\n{\n    int      res, digs;\n    fp_digit d;\n#ifndef WOLFSSL_SMALL_STACK\n    fp_int   t[1];\n#else\n    fp_int   *t;\n#endif\n\n    *size = 0;\n\n    \/* special case for binary *\/\n    if (radix == 2) {\n        *size = fp_count_bits (a) + (a->sign == FP_NEG ? 1 : 0) + 1;\n        return FP_YES;\n    }\n\n    \/* make sure the radix is in range *\/\n    if (radix < 2 || radix > 64) {\n        return FP_VAL;\n    }\n\n    if (fp_iszero(a) == MP_YES) {\n        *size = 2;\n        return FP_OKAY;\n    }\n\n    \/* digs is the digit count *\/\n    digs = 0;\n\n    \/* if it's negative add one for the sign *\/\n    if (a->sign == FP_NEG) {\n        ++digs;\n    }\n\n#ifdef WOLFSSL_SMALL_STACK\n    t = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT);\n    if (t == NULL)\n        return FP_MEM;\n#endif\n\n    \/* init a copy of the input *\/\n    fp_init_copy (t, a);\n\n    \/* force temp to positive *\/\n    t->sign = FP_ZPOS;\n\n    \/* fetch out all of the digits *\/\n    while (fp_iszero (t) == FP_NO) {\n        if ((res = fp_div_d (t, (mp_digit) radix, t, &d)) != FP_OKAY) {\n            fp_zero (t);\n        #ifdef WOLFSSL_SMALL_STACK\n            XFREE(t, NULL, DYNAMIC_TYPE_BIGINT);\n        #endif\n            return res;\n        }\n        ++digs;\n    }\n    fp_zero (t);\n\n    \/* return digs + 1, the 1 is for the NULL byte that would be required. *\/\n    *size = digs + 1;\n#ifdef WOLFSSL_SMALL_STACK\n    XFREE(t, NULL, DYNAMIC_TYPE_BIGINT);\n#endif\n    return FP_OKAY;\n}","target":0,"code_token_length":460,"total_token_length":696,"max_tokens_setting":1024}
+{"idx":341040,"func":"Visitor *qmp_input_visitor_new(QObject *obj, bool strict)\n\n{\n\n    QmpInputVisitor *v;\n\n\n\n    assert(obj);\n\n    v = g_malloc0(sizeof(*v));\n\n\n\n    v->visitor.type = VISITOR_INPUT;\n\n    v->visitor.start_struct = qmp_input_start_struct;\n\n    v->visitor.check_struct = qmp_input_check_struct;\n\n    v->visitor.end_struct = qmp_input_pop;\n\n    v->visitor.start_list = qmp_input_start_list;\n\n    v->visitor.next_list = qmp_input_next_list;\n\n    v->visitor.end_list = qmp_input_pop;\n\n    v->visitor.start_alternate = qmp_input_start_alternate;\n\n    v->visitor.type_int64 = qmp_input_type_int64;\n\n    v->visitor.type_uint64 = qmp_input_type_uint64;\n\n    v->visitor.type_bool = qmp_input_type_bool;\n\n    v->visitor.type_str = qmp_input_type_str;\n\n    v->visitor.type_number = qmp_input_type_number;\n\n    v->visitor.type_any = qmp_input_type_any;\n\n    v->visitor.type_null = qmp_input_type_null;\n\n    v->visitor.optional = qmp_input_optional;\n\n    v->visitor.free = qmp_input_free;\n\n    v->strict = strict;\n\n\n\n    v->root = obj;\n\n    qobject_incref(obj);\n\n\n\n    return &v->visitor;\n\n}\n","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":202769,"func":"zstatus(i_ctx_t *i_ctx_p)\n{\n    os_ptr op = osp;\n\n    switch (r_type(op)) {\n        case t_file:\n            {\n                stream *s;\n\n                make_bool(op, (file_is_valid(s, op) ? 1 : 0));\n            }\n            return 0;\n        case t_string:\n            {\n                gs_parsed_file_name_t pname;\n                struct stat fstat;\n                int code = parse_file_name(op, &pname,\n                                           i_ctx_p->LockFilePermissions, imemory);\n                if (code < 0) {\n                    if (code == gs_error_undefinedfilename) {\n                        make_bool(op, 0);\n                        code = 0;\n                    }\n                    return code;\n                }\n                code = gs_terminate_file_name(&pname, imemory, \"status\");\n                if (code < 0)\n                    return code;\n                 code = gs_terminate_file_name(&pname, imemory, \"status\");\n                 if (code < 0)\n                     return code;\n                if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,\n                                       \"PermitFileReading\")) >= 0) {\n                    code = (*pname.iodev->procs.file_status)(pname.iodev,\n                                                        pname.fname, &fstat);\n                }\n                 switch (code) {\n                     case 0:\n                         check_ostack(4);\n                        make_int(op - 4, stat_blocks(&fstat));\n                        make_int(op - 3, fstat.st_size);\n                        \/*\n                         * We can't check the value simply by using ==,\n                         * because signed\/unsigned == does the wrong thing.\n                         * Instead, since integer assignment only keeps the\n                         * bottom bits, we convert the values to double\n                         * and then test for equality.  This handles all\n                         * cases of signed\/unsigned or width mismatch.\n                         *\/\n                        if ((double)op[-4].value.intval !=\n                              (double)stat_blocks(&fstat) ||\n                            (double)op[-3].value.intval !=\n                              (double)fstat.st_size\n                            )\n                            return_error(gs_error_limitcheck);\n                        make_int(op - 2, fstat.st_mtime);\n                        make_int(op - 1, fstat.st_ctime);\n                        make_bool(op, 1);\n                        break;\n                    case gs_error_undefinedfilename:\n                        make_bool(op, 0);\n                        code = 0;\n                }\n                gs_free_file_name(&pname, \"status\");\n                return code;\n            }\n        default:\n            return_op_typecheck(op);\n    }\n}\n","target":0,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":21922,"func":"gcry_sexp_t gcry_sexp_nth ( const gcry_sexp_t list , int number ) {\n const byte * p ;\n DATALEN n ;\n gcry_sexp_t newlist ;\n byte * d ;\n int level = 0 ;\n if ( ! list || list -> d [ 0 ] != ST_OPEN ) return NULL ;\n p = list -> d ;\n while ( number > 0 ) {\n p ++ ;\n if ( * p == ST_DATA ) {\n memcpy ( & n , ++ p , sizeof n ) ;\n p += sizeof n + n ;\n p -- ;\n if ( ! level ) number -- ;\n }\n else if ( * p == ST_OPEN ) {\n level ++ ;\n }\n else if ( * p == ST_CLOSE ) {\n level -- ;\n if ( ! level ) number -- ;\n }\n else if ( * p == ST_STOP ) {\n return NULL ;\n }\n }\n p ++ ;\n if ( * p == ST_DATA ) {\n memcpy ( & n , p , sizeof n ) ;\n p += sizeof n ;\n newlist = gcry_malloc ( sizeof * newlist + n + 1 ) ;\n if ( ! newlist ) return NULL ;\n d = newlist -> d ;\n memcpy ( d , p , n ) ;\n d += n ;\n * d ++ = ST_STOP ;\n }\n else if ( * p == ST_OPEN ) {\n const byte * head = p ;\n level = 1 ;\n do {\n p ++ ;\n if ( * p == ST_DATA ) {\n memcpy ( & n , ++ p , sizeof n ) ;\n p += sizeof n + n ;\n p -- ;\n }\n else if ( * p == ST_OPEN ) {\n level ++ ;\n }\n else if ( * p == ST_CLOSE ) {\n level -- ;\n }\n else if ( * p == ST_STOP ) {\n BUG ( ) ;\n }\n }\n while ( level ) ;\n n = p + 1 - head ;\n newlist = gcry_malloc ( sizeof * newlist + n ) ;\n if ( ! newlist ) return NULL ;\n d = newlist -> d ;\n memcpy ( d , head , n ) ;\n d += n ;\n * d ++ = ST_STOP ;\n }\n else newlist = NULL ;\n return normalize ( newlist ) ;\n }","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":141543,"func":"static int matroska_parse_frame(MatroskaDemuxContext *matroska,\n\n                                MatroskaTrack *track, AVStream *st,\n\n                                uint8_t *data, int pkt_size,\n\n                                uint64_t timecode, uint64_t duration,\n\n                                int64_t pos, int is_keyframe)\n\n{\n\n    MatroskaTrackEncoding *encodings = track->encodings.elem;\n\n    uint8_t *pkt_data = data;\n\n    int offset = 0, res;\n\n    AVPacket *pkt;\n\n\n\n    if (encodings && encodings->scope & 1) {\n\n        res = matroska_decode_buffer(&pkt_data, &pkt_size, track);\n\n        if (res < 0)\n\n            return res;\n\n    }\n\n\n\n    if (st->codec->codec_id == AV_CODEC_ID_WAVPACK) {\n\n        uint8_t *wv_data;\n\n        res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size);\n\n        if (res < 0) {\n\n            av_log(matroska->ctx, AV_LOG_ERROR,\n\n                   \"Error parsing a wavpack block.\\n\");\n\n            goto fail;\n\n        }\n\n        if (pkt_data != data)\n\n\n        pkt_data = wv_data;\n\n    }\n\n\n\n    if (st->codec->codec_id == AV_CODEC_ID_PRORES)\n\n        offset = 8;\n\n\n\n    pkt = av_mallocz(sizeof(AVPacket));\n\n    \/* XXX: prevent data copy... *\/\n\n    if (av_new_packet(pkt, pkt_size + offset) < 0) {\n\n        av_free(pkt);\n\n\n        return AVERROR(ENOMEM);\n\n    }\n\n\n\n    if (st->codec->codec_id == AV_CODEC_ID_PRORES) {\n\n        uint8_t *buf = pkt->data;\n\n        bytestream_put_be32(&buf, pkt_size);\n\n        bytestream_put_be32(&buf, MKBETAG('i', 'c', 'p', 'f'));\n\n    }\n\n\n\n    memcpy(pkt->data + offset, pkt_data, pkt_size);\n\n\n\n    if (pkt_data != data)\n\n        av_free(pkt_data);\n\n\n\n    pkt->flags        = is_keyframe;\n\n    pkt->stream_index = st->index;\n\n\n\n    if (track->ms_compat)\n\n        pkt->dts = timecode;\n\n    else\n\n        pkt->pts = timecode;\n\n    pkt->pos = pos;\n\n    if (st->codec->codec_id == AV_CODEC_ID_TEXT)\n\n        pkt->convergence_duration = duration;\n\n    else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE)\n\n        pkt->duration = duration;\n\n\n\n    if (st->codec->codec_id == AV_CODEC_ID_SSA)\n\n        matroska_fix_ass_packet(matroska, pkt, duration);\n\n\n\n    if (matroska->prev_pkt                                 &&\n\n        timecode                         != AV_NOPTS_VALUE &&\n\n        matroska->prev_pkt->pts          == timecode       &&\n\n        matroska->prev_pkt->stream_index == st->index      &&\n\n        st->codec->codec_id == AV_CODEC_ID_SSA)\n\n        matroska_merge_packets(matroska->prev_pkt, pkt);\n\n    else {\n\n        dynarray_add(&matroska->packets, &matroska->num_packets, pkt);\n\n        matroska->prev_pkt = pkt;\n\n    }\n\n\n\n    return 0;\n\n\n\nfail:\n\n    if (pkt_data != data)\n\n\n    return res;\n\n}","target":1,"code_token_length":714,"total_token_length":950,"max_tokens_setting":1024}
+{"idx":30217,"func":"static void ImportBlackQuantum ( const Image * image , QuantumInfo * quantum_info , const MagickSizeType number_pixels , const unsigned char * magick_restrict p , Quantum * magick_restrict q , ExceptionInfo * exception ) {\n QuantumAny range ;\n register ssize_t x ;\n unsigned int pixel ;\n if ( image -> colorspace != CMYKColorspace ) {\n ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , ImageError , \"ColorSeparatedImageRequired\" , \"`%s'\" , image -> filename ) ;\n return ;\n }\n switch ( quantum_info -> depth ) {\n case 8 : {\n unsigned char pixel ;\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushCharPixel ( p , & pixel ) ;\n SetPixelBlack ( image , ScaleCharToQuantum ( pixel ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n case 16 : {\n unsigned short pixel ;\n if ( quantum_info -> format == FloatingPointQuantumFormat ) {\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;\n SetPixelBlack ( image , ClampToQuantum ( QuantumRange * HalfToSinglePrecision ( pixel ) ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ;\n SetPixelBlack ( image , ScaleShortToQuantum ( pixel ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n case 32 : {\n unsigned int pixel ;\n if ( quantum_info -> format == FloatingPointQuantumFormat ) {\n float pixel ;\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushFloatPixel ( quantum_info , p , & pixel ) ;\n SetPixelBlack ( image , ClampToQuantum ( pixel ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ;\n SetPixelBlack ( image , ScaleLongToQuantum ( pixel ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n case 64 : {\n if ( quantum_info -> format == FloatingPointQuantumFormat ) {\n double pixel ;\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushDoublePixel ( quantum_info , p , & pixel ) ;\n SetPixelBlack ( image , ClampToQuantum ( pixel ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n }\n default : {\n range = GetQuantumRange ( quantum_info -> depth ) ;\n for ( x = 0 ;\n x < ( ssize_t ) number_pixels ;\n x ++ ) {\n p = PushQuantumPixel ( quantum_info , p , & pixel ) ;\n SetPixelBlack ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ;\n p += quantum_info -> pad ;\n q += GetPixelChannels ( image ) ;\n }\n break ;\n }\n }\n }","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":381419,"func":"cmd_readkey (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  unsigned char *cert = NULL;\n  size_t ncert, n;\n  ksba_cert_t kc = NULL;\n  ksba_sexp_t p;\n  unsigned char *pk;\n  size_t pklen;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  line = xstrdup (line); \/* Need a copy of the line. *\/\n  \/* If the application supports the READKEY function we use that.\n     Otherwise we use the old way by extracting it from the\n     certificate.  *\/\n  rc = app_readkey (ctrl->app_ctx, line, &pk, &pklen);\n  if (!rc)\n    { \/* Yeah, got that key - send it back.  *\/\n      rc = assuan_send_data (ctx, pk, pklen);\n      xfree (pk);\n      xfree (line);\n      line = NULL;\n      goto leave;\n    }\n\n  if (gpg_err_code (rc) != GPG_ERR_UNSUPPORTED_OPERATION)\n    log_error (\"app_readkey failed: %s\\n\", gpg_strerror (rc));\n  else\n    {\n      rc = app_readcert (ctrl->app_ctx, line, &cert, &ncert);\n      if (rc)\n        log_error (\"app_readcert failed: %s\\n\", gpg_strerror (rc));\n    }\n  xfree (line);\n  line = NULL;\n  if (rc)\n    goto leave;\n\n  rc = ksba_cert_new (&kc);\n  if (rc)\n    goto leave;\n\n  rc = ksba_cert_init_from_mem (kc, cert, ncert);\n  if (rc)\n    {\n      log_error (\"failed to parse the certificate: %s\\n\", gpg_strerror (rc));\n      goto leave;\n    }\n\n  p = ksba_cert_get_public_key (kc);\n  if (!p)\n    {\n      rc = gpg_error (GPG_ERR_NO_PUBKEY);\n      goto leave;\n    }\n\n  n = gcry_sexp_canon_len (p, 0, NULL, NULL);\n  rc = assuan_send_data (ctx, p, n);\n  xfree (p);\n\n\n leave:\n  ksba_cert_release (kc);\n  xfree (cert);\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":405402,"func":"bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,\n\t\t\t int classzone_idx, unsigned int alloc_flags,\n\t\t\t long free_pages)\n{\n\tlong min = mark;\n\tint o;\n\tconst bool alloc_harder = (alloc_flags & (ALLOC_HARDER|ALLOC_OOM));\n\n\t\/* free_pages may go negative - that's OK *\/\n\tfree_pages -= (1 << order) - 1;\n\n\tif (alloc_flags & ALLOC_HIGH)\n\t\tmin -= min \/ 2;\n\n\t\/*\n\t * If the caller does not have rights to ALLOC_HARDER then subtract\n\t * the high-atomic reserves. This will over-estimate the size of the\n\t * atomic reserve but it avoids a search.\n\t *\/\n\tif (likely(!alloc_harder)) {\n\t\tfree_pages -= z->nr_reserved_highatomic;\n\t} else {\n\t\t\/*\n\t\t * OOM victims can try even harder than normal ALLOC_HARDER\n\t\t * users on the grounds that it's definitely going to be in\n\t\t * the exit path shortly and free memory. Any allocation it\n\t\t * makes during the free path will be small and short-lived.\n\t\t *\/\n\t\tif (alloc_flags & ALLOC_OOM)\n\t\t\tmin -= min \/ 2;\n\t\telse\n\t\t\tmin -= min \/ 4;\n\t}\n\n\n#ifdef CONFIG_CMA\n\t\/* If allocation can't use CMA areas don't use free CMA pages *\/\n\tif (!(alloc_flags & ALLOC_CMA))\n\t\tfree_pages -= zone_page_state(z, NR_FREE_CMA_PAGES);\n#endif\n\n\t\/*\n\t * Check watermarks for an order-0 allocation request. If these\n\t * are not met, then a high-order request also cannot go ahead\n\t * even if a suitable page happened to be free.\n\t *\/\n\tif (free_pages <= min + z->lowmem_reserve[classzone_idx])\n\t\treturn false;\n\n\t\/* If this is an order-0 request then the watermark is fine *\/\n\tif (!order)\n\t\treturn true;\n\n\t\/* For a high-order request, check at least one suitable page is free *\/\n\tfor (o = order; o < MAX_ORDER; o++) {\n\t\tstruct free_area *area = &z->free_area[o];\n\t\tint mt;\n\n\t\tif (!area->nr_free)\n\t\t\tcontinue;\n\n\t\tfor (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {\n\t\t\tif (!list_empty(&area->free_list[mt]))\n\t\t\t\treturn true;\n\t\t}\n\n#ifdef CONFIG_CMA\n\t\tif ((alloc_flags & ALLOC_CMA) &&\n\t\t    !list_empty(&area->free_list[MIGRATE_CMA])) {\n\t\t\treturn true;\n\t\t}\n#endif\n\t\tif (alloc_harder &&\n\t\t\t!list_empty(&area->free_list[MIGRATE_HIGHATOMIC]))\n\t\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":591,"total_token_length":827,"max_tokens_setting":1024}
+{"idx":29913,"func":"static guint16 de_tp_sub_channel ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ ) {\n guint32 curr_offset ;\n guchar oct ;\n const gchar * str ;\n curr_offset = offset ;\n oct = tvb_get_guint8 ( tvb , curr_offset ) & 0x3f ;\n if ( ( oct & 0x38 ) == 0x38 ) str = \"I\" ;\n else if ( ( oct & 0x38 ) == 0x18 ) str = \"F\" ;\n else if ( ( oct & 0x38 ) == 0x10 ) str = \"E\" ;\n else if ( ( oct & 0x38 ) == 0x08 ) str = \"D\" ;\n else if ( ( oct & 0x3c ) == 0x04 ) str = \"C\" ;\n else if ( ( oct & 0x3e ) == 0x02 ) str = \"B\" ;\n else if ( ( oct & 0x3e ) == 0x00 ) str = \"A\" ;\n else str = \"unknown\" ;\n proto_tree_add_uint_format_value ( tree , hf_gsm_a_dtap_test_loop , tvb , curr_offset , 1 , oct , \"%s\" , str ) ;\n proto_tree_add_item ( tree , hf_gsm_a_dtap_subchannel , tvb , curr_offset , 1 , ENC_NA ) ;\n curr_offset += 1 ;\n return ( curr_offset - offset ) ;\n }","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":39232,"func":"SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data)\n{\n\tint rc;\n\tstruct cifs_ses *ses = sess_data->ses;\n\tstruct smb2_sess_setup_req *req;\n\tstruct TCP_Server_Info *server = ses->server;\n\n\trc = small_smb2_init(SMB2_SESSION_SETUP, NULL, (void **) &req);\n\tif (rc)\n\t\treturn rc;\n\n\t\/* First session, not a reauthenticate *\/\n\treq->hdr.sync_hdr.SessionId = 0;\n\n\t\/* if reconnect, we need to send previous sess id, otherwise it is 0 *\/\n\treq->PreviousSessionId = sess_data->previous_session;\n\n\treq->Flags = 0; \/* MBZ *\/\n\t\/* to enable echos and oplocks *\/\n\treq->hdr.sync_hdr.CreditRequest = cpu_to_le16(3);\n\n\t\/* only one of SMB2 signing flags may be set in SMB2 request *\/\n\tif (server->sign)\n\t\treq->SecurityMode = SMB2_NEGOTIATE_SIGNING_REQUIRED;\n\telse if (global_secflags & CIFSSEC_MAY_SIGN) \/* one flag unlike MUST_ *\/\n\t\treq->SecurityMode = SMB2_NEGOTIATE_SIGNING_ENABLED;\n\telse\n\t\treq->SecurityMode = 0;\n\n\treq->Capabilities = 0;\n\treq->Channel = 0; \/* MBZ *\/\n\n\tsess_data->iov[0].iov_base = (char *)req;\n\t\/* 4 for rfc1002 length field and 1 for pad *\/\n\tsess_data->iov[0].iov_len = get_rfc1002_length(req) + 4 - 1;\n\t\/*\n\t * This variable will be used to clear the buffer\n\t * allocated above in case of any error in the calling function.\n\t *\/\n\tsess_data->buf0_type = CIFS_SMALL_BUFFER;\n\n\treturn 0;\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":236776,"func":"int svc_rdma_post_recv(struct svcxprt_rdma *xprt, gfp_t flags)\n{\n\tstruct ib_recv_wr recv_wr, *bad_recv_wr;\n\tstruct svc_rdma_op_ctxt *ctxt;\n\tstruct page *page;\n\tdma_addr_t pa;\n\tint sge_no;\n\tint buflen;\n\tint ret;\n\n\tctxt = svc_rdma_get_context(xprt);\n\tbuflen = 0;\n\tctxt->direction = DMA_FROM_DEVICE;\n\tctxt->cqe.done = svc_rdma_wc_receive;\n\tfor (sge_no = 0; buflen < xprt->sc_max_req_size; sge_no++) {\n\t\tif (sge_no >= xprt->sc_max_sge) {\n\t\t\tpr_err(\"svcrdma: Too many sges (%d)\\n\", sge_no);\n\t\t\tgoto err_put_ctxt;\n\t\t}\n\t\tpage = alloc_page(flags);\n\t\tif (!page)\n\t\t\tgoto err_put_ctxt;\n\t\tctxt->pages[sge_no] = page;\n\t\tpa = ib_dma_map_page(xprt->sc_cm_id->device,\n\t\t\t\t     page, 0, PAGE_SIZE,\n\t\t\t\t     DMA_FROM_DEVICE);\n\t\tif (ib_dma_mapping_error(xprt->sc_cm_id->device, pa))\n\t\t\tgoto err_put_ctxt;\n\t\tsvc_rdma_count_mappings(xprt, ctxt);\n\t\tctxt->sge[sge_no].addr = pa;\n\t\tctxt->sge[sge_no].length = PAGE_SIZE;\n\t\tctxt->sge[sge_no].lkey = xprt->sc_pd->local_dma_lkey;\n\t\tctxt->count = sge_no + 1;\n\t\tbuflen += PAGE_SIZE;\n\t}\n\trecv_wr.next = NULL;\n\trecv_wr.sg_list = &ctxt->sge[0];\n\trecv_wr.num_sge = ctxt->count;\n\trecv_wr.wr_cqe = &ctxt->cqe;\n\n\tsvc_xprt_get(&xprt->sc_xprt);\n\tret = ib_post_recv(xprt->sc_qp, &recv_wr, &bad_recv_wr);\n\tif (ret) {\n\t\tsvc_rdma_unmap_dma(ctxt);\n\t\tsvc_rdma_put_context(ctxt, 1);\n\t\tsvc_xprt_put(&xprt->sc_xprt);\n\t}\n\treturn ret;\n\n err_put_ctxt:\n\tsvc_rdma_unmap_dma(ctxt);\n\tsvc_rdma_put_context(ctxt, 1);\n\treturn -ENOMEM;\n}\n","target":0,"code_token_length":505,"total_token_length":741,"max_tokens_setting":1024}
+{"idx":339831,"func":"static void loop_filter(H264Context *h){\n\n    MpegEncContext * const s = &h->s;\n\n    uint8_t  *dest_y, *dest_cb, *dest_cr;\n\n    int linesize, uvlinesize, mb_x, mb_y;\n\n    const int end_mb_y= s->mb_y + FRAME_MBAFF;\n\n    const int old_slice_type= h->slice_type;\n\n\n\n    if(h->deblocking_filter) {\n\n        for(mb_x= 0; mb_x<s->mb_width; mb_x++){\n\n            for(mb_y=end_mb_y - FRAME_MBAFF; mb_y<= end_mb_y; mb_y++){\n\n                int list, mb_xy, mb_type;\n\n                mb_xy = h->mb_xy = mb_x + mb_y*s->mb_stride;\n\n                h->slice_num= h->slice_table[mb_xy];\n\n                mb_type= s->current_picture.mb_type[mb_xy];\n\n                h->list_count= h->list_counts[mb_xy];\n\n\n\n                if(FRAME_MBAFF)\n\n                    h->mb_mbaff = h->mb_field_decoding_flag = !!IS_INTERLACED(mb_type);\n\n\n\n                s->mb_x= mb_x;\n\n                s->mb_y= mb_y;\n\n                dest_y  = s->current_picture.data[0] + (mb_x + mb_y * s->linesize  ) * 16;\n\n                dest_cb = s->current_picture.data[1] + (mb_x + mb_y * s->uvlinesize) * 8;\n\n                dest_cr = s->current_picture.data[2] + (mb_x + mb_y * s->uvlinesize) * 8;\n\n                    \/\/FIXME simplify above\n\n\n\n                if (MB_FIELD) {\n\n                    linesize   = h->mb_linesize   = s->linesize * 2;\n\n                    uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;\n\n                    if(mb_y&1){ \/\/FIXME move out of this function?\n\n                        dest_y -= s->linesize*15;\n\n                        dest_cb-= s->uvlinesize*7;\n\n                        dest_cr-= s->uvlinesize*7;\n\n                    }\n\n                } else {\n\n                    linesize   = h->mb_linesize   = s->linesize;\n\n                    uvlinesize = h->mb_uvlinesize = s->uvlinesize;\n\n                }\n\n                backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0);\n\n                if(fill_filter_caches(h, mb_type) < 0)\n\n                    continue;\n\n                h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.qscale_table[mb_xy]);\n\n                h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.qscale_table[mb_xy]);\n\n\n\n                if (FRAME_MBAFF) {\n\n                    ff_h264_filter_mb     (h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize);\n\n                } else {\n\n                    ff_h264_filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize);\n\n                }\n\n            }\n\n        }\n\n    }\n\n    h->slice_type= old_slice_type;\n\n    s->mb_x= 0;\n\n    s->mb_y= end_mb_y - FRAME_MBAFF;\n\n}\n","target":0,"code_token_length":727,"total_token_length":963,"max_tokens_setting":1024}
+{"idx":140023,"func":"nvme_fc_parse_traddr(struct nvmet_fc_traddr *traddr, char *buf, size_t blen)\n{\n\tchar name[2 + NVME_FC_TRADDR_HEXNAMELEN + 1];\n\tsubstring_t wwn = { name, &name[sizeof(name)-1] };\n\tint nnoffset, pnoffset;\n\n\t\/* validate it string one of the 2 allowed formats *\/\n\tif (strnlen(buf, blen) == NVME_FC_TRADDR_MAXLENGTH &&\n\t\t\t!strncmp(buf, \"nn-0x\", NVME_FC_TRADDR_OXNNLEN) &&\n\t\t\t!strncmp(&buf[NVME_FC_TRADDR_MAX_PN_OFFSET],\n\t\t\t\t\"pn-0x\", NVME_FC_TRADDR_OXNNLEN)) {\n\t\tnnoffset = NVME_FC_TRADDR_OXNNLEN;\n\t\tpnoffset = NVME_FC_TRADDR_MAX_PN_OFFSET +\n\t\t\t\t\t\tNVME_FC_TRADDR_OXNNLEN;\n\t} else if ((strnlen(buf, blen) == NVME_FC_TRADDR_MINLENGTH &&\n\t\t\t!strncmp(buf, \"nn-\", NVME_FC_TRADDR_NNLEN) &&\n\t\t\t!strncmp(&buf[NVME_FC_TRADDR_MIN_PN_OFFSET],\n\t\t\t\t\"pn-\", NVME_FC_TRADDR_NNLEN))) {\n\t\tnnoffset = NVME_FC_TRADDR_NNLEN;\n\t\tpnoffset = NVME_FC_TRADDR_MIN_PN_OFFSET + NVME_FC_TRADDR_NNLEN;\n\t} else\n\t\tgoto out_einval;\n\n\tname[0] = '0';\n\tname[1] = 'x';\n\tname[2 + NVME_FC_TRADDR_HEXNAMELEN] = 0;\n\n\tmemcpy(&name[2], &buf[nnoffset], NVME_FC_TRADDR_HEXNAMELEN);\n\tif (__nvme_fc_parse_u64(&wwn, &traddr->nn))\n\t\tgoto out_einval;\n\n\tmemcpy(&name[2], &buf[pnoffset], NVME_FC_TRADDR_HEXNAMELEN);\n\tif (__nvme_fc_parse_u64(&wwn, &traddr->pn))\n\t\tgoto out_einval;\n\n\treturn 0;\n\nout_einval:\n\tpr_warn(\"%s: bad traddr string\\n\", __func__);\n\treturn -EINVAL;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":421293,"func":"int bus_socket_connect(sd_bus *b) {\n        bool inotify_done = false;\n        int r;\n\n        assert(b);\n\n        for (;;) {\n                assert(b->input_fd < 0);\n                assert(b->output_fd < 0);\n                assert(b->sockaddr.sa.sa_family != AF_UNSPEC);\n\n                b->input_fd = socket(b->sockaddr.sa.sa_family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);\n                if (b->input_fd < 0)\n                        return -errno;\n\n                b->input_fd = fd_move_above_stdio(b->input_fd);\n\n                b->output_fd = b->input_fd;\n                bus_socket_setup(b);\n\n                if (connect(b->input_fd, &b->sockaddr.sa, b->sockaddr_size) < 0) {\n                        if (errno == EINPROGRESS) {\n\n                                \/* If we have any inotify watches open, close them now, we don't need them anymore, as\n                                 * we have successfully initiated a connection *\/\n                                bus_close_inotify_fd(b);\n\n                                \/* Note that very likely we are already in BUS_OPENING state here, as we enter it when\n                                 * we start parsing the address string. The only reason we set the state explicitly\n                                 * here, is to undo BUS_WATCH_BIND, in case we did the inotify magic. *\/\n                                bus_set_state(b, BUS_OPENING);\n                                return 1;\n                        }\n\n                        if (IN_SET(errno, ENOENT, ECONNREFUSED) &&  \/* ENOENT \u2192 unix socket doesn't exist at all; ECONNREFUSED \u2192 unix socket stale *\/\n                            b->watch_bind &&\n                            b->sockaddr.sa.sa_family == AF_UNIX &&\n                            b->sockaddr.un.sun_path[0] != 0) {\n\n                                \/* This connection attempt failed, let's release the socket for now, and start with a\n                                 * fresh one when reconnecting. *\/\n                                bus_close_io_fds(b);\n\n                                if (inotify_done) {\n                                        \/* inotify set up already, don't do it again, just return now, and remember\n                                         * that we are waiting for inotify events now. *\/\n                                        bus_set_state(b, BUS_WATCH_BIND);\n                                        return 1;\n                                }\n\n                                \/* This is a file system socket, and the inotify logic is enabled. Let's create the necessary inotify fd. *\/\n                                r = bus_socket_inotify_setup(b);\n                                if (r < 0)\n                                        return r;\n\n                                \/* Let's now try to connect a second time, because in theory there's otherwise a race\n                                 * here: the socket might have been created in the time between our first connect() and\n                                 * the time we set up the inotify logic. But let's remember that we set up inotify now,\n                                 * so that we don't do the connect() more than twice. *\/\n                                inotify_done = true;\n\n                        } else\n                                return -errno;\n                } else\n                        break;\n        }\n\n        \/* Yay, established, we don't need no inotify anymore! *\/\n        bus_close_inotify_fd(b);\n\n        return bus_socket_start_auth(b);\n}","target":0,"code_token_length":658,"total_token_length":894,"max_tokens_setting":1024}
+{"idx":505799,"func":"static int FIPS_sha512_test()\n    {\n    unsigned char digest[SHA512_DIGEST_LENGTH] =\n\t{0x99, 0xc9, 0xe9, 0x5b, 0x88, 0xd4, 0x78, 0x88, 0xdf, 0x88, 0x5f, 0x94, 0x71, 0x64, 0x28, 0xca,\n\t 0x16, 0x1f, 0x3d, 0xf4, 0x1f, 0xf3, 0x0f, 0xc5, 0x03, 0x99, 0xb2, 0xd0, 0xe7, 0x0b, 0x94, 0x4a,\n\t 0x45, 0xd2, 0x6c, 0x4f, 0x20, 0x06, 0xef, 0x71, 0xa9, 0x25, 0x7f, 0x24, 0xb1, 0xd9, 0x40, 0x22,\n\t 0x49, 0x54, 0x10, 0xc2, 0x22, 0x9d, 0x27, 0xfe, 0xbd, 0xd6, 0xd6, 0xeb, 0x2d, 0x42, 0x1d, 0xa3};\n    unsigned char str[] = \"etaonrishd\";\n\n    unsigned char md[SHA512_DIGEST_LENGTH];\n\n    ERR_clear_error();\n    if (!FIPS_digest(str,sizeof(str) - 1,md, NULL, EVP_sha512())) return 0;\n    if (memcmp(md,digest,sizeof(md)))\n        return 0;\n    return 1;\n    }","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":447754,"func":"imapx_untagged_list (CamelIMAPXServer *is,\n                     GInputStream *input_stream,\n                     GCancellable *cancellable,\n                     GError **error)\n{\n\tCamelIMAPXListResponse *response;\n\tconst gchar *mailbox_name;\n\tgchar separator;\n\n\tg_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);\n\n\tresponse = camel_imapx_list_response_new (\n\t\tCAMEL_IMAPX_INPUT_STREAM (input_stream), cancellable, error);\n\tif (response == NULL)\n\t\treturn FALSE;\n\n\tmailbox_name = camel_imapx_list_response_get_mailbox_name (response);\n\tseparator = camel_imapx_list_response_get_separator (response);\n\n\t\/* Record the INBOX separator character once we know it. *\/\n\tif (camel_imapx_mailbox_is_inbox (mailbox_name))\n\t\tis->priv->inbox_separator = separator;\n\n\tif (is->priv->list_responses_hash) {\n\t\tis->priv->list_responses = g_slist_prepend (is->priv->list_responses, response);\n\t\tg_hash_table_insert (is->priv->list_responses_hash, (gpointer) camel_imapx_list_response_get_mailbox_name (response), response);\n\t} else {\n\t\tCamelIMAPXStore *imapx_store;\n\n\t\timapx_store = camel_imapx_server_ref_store (is);\n\t\tcamel_imapx_store_handle_list_response (imapx_store, is, response);\n\n\t\tg_clear_object (&imapx_store);\n\t\tg_clear_object (&response);\n\t}\n\n\treturn TRUE;\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":69908,"func":"bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)\n{\n    int\t\tc;\n    char_u\tbuf[NUMBUFLEN + MB_MAXBYTES];\n    int\t\tidx = 0;\n    char_u\t*end = find_termcode((char_u *)\"PE\");\n    int\t\tret_char = -1;\n    int\t\tsave_allow_keys = allow_keys;\n    int\t\tsave_paste = p_paste;\n\n    \/\/ If the end code is too long we can't detect it, read everything.\n    if (end != NULL && STRLEN(end) >= NUMBUFLEN)\n\tend = NULL;\n    ++no_mapping;\n    allow_keys = 0;\n    if (!p_paste)\n\t\/\/ Also have the side effects of setting 'paste' to make it work much\n\t\/\/ faster.\n\tset_option_value((char_u *)\"paste\", TRUE, NULL, 0);\n\n    for (;;)\n    {\n\t\/\/ When the end is not defined read everything there is.\n\tif (end == NULL && vpeekc() == NUL)\n\t    break;\n\tdo\n\t    c = vgetc();\n\twhile (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);\n\tif (c == NUL || got_int || (ex_normal_busy > 0 && c == Ctrl_C))\n\t    \/\/ When CTRL-C was encountered the typeahead will be flushed and we\n\t    \/\/ won't get the end sequence.  Except when using \":normal\".\n\t    break;\n\n\tif (has_mbyte)\n\t    idx += (*mb_char2bytes)(c, buf + idx);\n\telse\n\t    buf[idx++] = c;\n\tbuf[idx] = NUL;\n\tif (end != NULL && STRNCMP(buf, end, idx) == 0)\n\t{\n\t    if (end[idx] == NUL)\n\t\tbreak; \/\/ Found the end of paste code.\n\t    continue;\n\t}\n\tif (!drop)\n\t{\n\t    switch (mode)\n\t    {\n\t\tcase PASTE_CMDLINE:\n\t\t    put_on_cmdline(buf, idx, TRUE);\n\t\t    break;\n\n\t\tcase PASTE_EX:\n\t\t    \/\/ add one for the NUL that is going to be appended\n\t\t    if (gap != NULL && ga_grow(gap, idx + 1) == OK)\n\t\t    {\n\t\t\tmch_memmove((char *)gap->ga_data + gap->ga_len,\n\t\t\t\t\t\t\t     buf, (size_t)idx);\n\t\t\tgap->ga_len += idx;\n\t\t    }\n\t\t    break;\n\n\t\tcase PASTE_INSERT:\n\t\t    if (stop_arrow() == OK)\n\t\t    {\n\t\t\tc = buf[0];\n\t\t\tif (idx == 1 && (c == CAR || c == K_KENTER || c == NL))\n\t\t\t    ins_eol(c);\n\t\t\telse\n\t\t\t{\n\t\t\t    ins_char_bytes(buf, idx);\n\t\t\t    AppendToRedobuffLit(buf, idx);\n\t\t\t}\n\t\t    }\n\t\t    break;\n\n\t\tcase PASTE_ONE_CHAR:\n\t\t    if (ret_char == -1)\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t    ret_char = (*mb_ptr2char)(buf);\n\t\t\telse\n\t\t\t    ret_char = buf[0];\n\t\t    }\n\t\t    break;\n\t    }\n\t}\n\tidx = 0;\n    }\n\n    --no_mapping;\n    allow_keys = save_allow_keys;\n    if (!save_paste)\n\tset_option_value((char_u *)\"paste\", FALSE, NULL, 0);\n\n    return ret_char;\n}","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":442139,"func":"void setInputFrameBuffer(FrameBuffer& frameBuffer, int pixelType,\n                         Array2D<unsigned int>& uData, Array2D<float>& fData,\n                         Array2D<half>& hData, int width, int height)\n{\n    switch (pixelType)\n    {\n        case 0:\n            uData.resizeErase(height, width);\n            frameBuffer.insert (\"UINT\",\n                                Slice (IMF::UINT,\n                                (char *) (&uData[0][0]),\n                                sizeof (uData[0][0]) * 1,\n                                sizeof (uData[0][0]) * width,\n                                1, 1,\n                                0));\n            break;\n        case 1:\n            fData.resizeErase(height, width);\n            frameBuffer.insert (\"FLOAT\",\n                                Slice (IMF::FLOAT,\n                                (char *) (&fData[0][0]),\n                                sizeof (fData[0][0]) * 1,\n                                sizeof (fData[0][0]) * width,\n                                1, 1,\n                                0));\n            break;\n        case 2:\n            hData.resizeErase(height, width);\n            frameBuffer.insert (\"HALF\",\n                                Slice (IMF::HALF,\n                                (char *) (&hData[0][0]),\n                                sizeof (hData[0][0]) * 1,\n                                sizeof (hData[0][0]) * width,\n                                1, 1,\n                                0));\n            break;\n    }\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":175570,"func":"int test_gf2m_mod_div(BIO *bp,BN_CTX *ctx)\n\t{\n\tBIGNUM *a,*b[2],*c,*d,*e,*f;\n\tint i, j, ret = 0;\n\tint p0[] = {163,7,6,3,0,-1};\n\tint p1[] = {193,15,0,-1};\n\n\ta=BN_new();\n\tb[0]=BN_new();\n\tb[1]=BN_new();\n\tc=BN_new();\n\td=BN_new();\n\te=BN_new();\n\tf=BN_new();\n\n\tBN_GF2m_arr2poly(p0, b[0]);\n\tBN_GF2m_arr2poly(p1, b[1]);\n\n\tfor (i=0; i<num0; i++)\n\t\t{\n\t\tBN_bntest_rand(a, 512, 0, 0); \n\t\tBN_bntest_rand(c, 512, 0, 0);\n\t\tfor (j=0; j < 2; j++)\n\t\t\t{\n\t\t\tBN_GF2m_mod_div(d, a, c, b[j], ctx);\n\t\t\tBN_GF2m_mod_mul(e, d, c, b[j], ctx);\n\t\t\tBN_GF2m_mod_div(f, a, e, b[j], ctx);\n#if 0 \/* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic *\/\n\t\t\tif (bp != NULL)\n\t\t\t\t{\n\t\t\t\tif (!results)\n\t\t\t\t\t{\n\t\t\t\t\tBN_print(bp,a);\n\t\t\t\t\tBIO_puts(bp, \" = \");\n\t\t\t\t\tBN_print(bp,c);\n\t\t\t\t\tBIO_puts(bp,\" * \");\n\t\t\t\t\tBN_print(bp,d);\n\t\t\t\t\tBIO_puts(bp, \" % \");\n\t\t\t\t\tBN_print(bp,b[j]);\n\t\t\t\t\tBIO_puts(bp,\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\t\t\t\/* Test that ((a\/c)*c)\/a = 1. *\/\n\t\t\tif(!BN_is_one(f))\n\t\t\t\t{\n\t\t\t\tfprintf(stderr,\"GF(2^m) modular division test failed!\\n\");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tret = 1;\n  err:\n\tBN_free(a);\n\tBN_free(b[0]);\n\tBN_free(b[1]);\n\tBN_free(c);\n\tBN_free(d);\n\tBN_free(e);\n\tBN_free(f);\n\treturn ret;\n\t}\n","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":73900,"func":"do_cast (VerifyContext *ctx, int token, const char *opcode) {\n\tILStackDesc *value;\n\tMonoType *type;\n\tgboolean is_boxed;\n\tgboolean do_box;\n\n\tif (!check_underflow (ctx, 1))\n\t\treturn;\n\n\tif (!(type = get_boxable_mono_type (ctx, token, opcode)))\n\t\treturn;\n\n\tif (type->byref) {\n\t\tADD_VERIFY_ERROR (ctx, g_strdup_printf (\"Invalid %s type at 0x%04x\", opcode, ctx->ip_offset));\n\t\treturn;\n\t}\n\n\tvalue = stack_pop (ctx);\n\tis_boxed = stack_slot_is_boxed_value (value);\n\n\tif (stack_slot_is_managed_pointer (value))\n\t\tCODE_NOT_VERIFIABLE (ctx, g_strdup_printf (\"Invalid value for %s at 0x%04x\", opcode, ctx->ip_offset));\n\telse if (!MONO_TYPE_IS_REFERENCE  (value->type) && !is_boxed) {\n\t\tchar *name = stack_slot_full_name (value);\n\t\tCODE_NOT_VERIFIABLE (ctx, g_strdup_printf (\"Expected a reference type on stack for %s but found %s at 0x%04x\", opcode, name, ctx->ip_offset));\n\t\tg_free (name);\n\t}\n\n\tswitch (value->type->type) {\n\tcase MONO_TYPE_FNPTR:\n\tcase MONO_TYPE_PTR:\n\tcase MONO_TYPE_TYPEDBYREF: \n\t\tCODE_NOT_VERIFIABLE (ctx, g_strdup_printf (\"Invalid value for %s at 0x%04x\", opcode, ctx->ip_offset));\n\t}\n\n\tdo_box = is_boxed || mono_type_is_generic_argument(type) || mono_class_from_mono_type (type)->valuetype;\n\tstack_push_val (ctx, TYPE_COMPLEX | (do_box ? BOXED_MASK : 0), type);\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":138649,"func":"usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)\n{\n\n\tstruct usbtest_dev\t*dev = usb_get_intfdata(intf);\n\tstruct usbtest_param_64 *param_64 = buf;\n\tstruct usbtest_param_32 temp;\n\tstruct usbtest_param_32 *param_32 = buf;\n\tstruct timespec64 start;\n\tstruct timespec64 end;\n\tstruct timespec64 duration;\n\tint retval = -EOPNOTSUPP;\n\n\t\/* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. *\/\n\n\tpattern = mod_pattern;\n\n\tif (mutex_lock_interruptible(&dev->lock))\n\t\treturn -ERESTARTSYS;\n\n\t\/* FIXME: What if a system sleep starts while a test is running? *\/\n\n\t\/* some devices, like ez-usb default devices, need a non-default\n\t * altsetting to have any active endpoints.  some tests change\n\t * altsettings; force a default so most tests don't need to check.\n\t *\/\n\tif (dev->info->alt >= 0) {\n\t\tif (intf->altsetting->desc.bInterfaceNumber) {\n\t\t\tretval = -ENODEV;\n\t\t\tgoto free_mutex;\n\t\t}\n\t\tretval = set_altsetting(dev, dev->info->alt);\n\t\tif (retval) {\n\t\t\tdev_err(&intf->dev,\n\t\t\t\t\t\"set altsetting to %d failed, %d\\n\",\n\t\t\t\t\tdev->info->alt, retval);\n\t\t\tgoto free_mutex;\n\t\t}\n\t}\n\n\tswitch (code) {\n\tcase USBTEST_REQUEST_64:\n\t\ttemp.test_num = param_64->test_num;\n\t\ttemp.iterations = param_64->iterations;\n\t\ttemp.length = param_64->length;\n\t\ttemp.sglen = param_64->sglen;\n\t\ttemp.vary = param_64->vary;\n\t\tparam_32 = &temp;\n\t\tbreak;\n\n\tcase USBTEST_REQUEST_32:\n\t\tbreak;\n\n\tdefault:\n\t\tretval = -EOPNOTSUPP;\n\t\tgoto free_mutex;\n\t}\n\n\tktime_get_ts64(&start);\n\n\tretval = usbtest_do_ioctl(intf, param_32);\n\tif (retval < 0)\n\t\tgoto free_mutex;\n\n\tktime_get_ts64(&end);\n\n\tduration = timespec64_sub(end, start);\n\n\ttemp.duration_sec = duration.tv_sec;\n\ttemp.duration_usec = duration.tv_nsec\/NSEC_PER_USEC;\n\n\tswitch (code) {\n\tcase USBTEST_REQUEST_32:\n\t\tparam_32->duration_sec = temp.duration_sec;\n\t\tparam_32->duration_usec = temp.duration_usec;\n\t\tbreak;\n\n\tcase USBTEST_REQUEST_64:\n\t\tparam_64->duration_sec = temp.duration_sec;\n\t\tparam_64->duration_usec = temp.duration_usec;\n\t\tbreak;\n\t}\n\nfree_mutex:\n\tmutex_unlock(&dev->lock);\n\treturn retval;\n}","target":0,"code_token_length":603,"total_token_length":839,"max_tokens_setting":1024}
+{"idx":305646,"func":"LPCOLESTR Parser::ConstructFinalHintNode(IdentPtr pClassName, IdentPtr pMemberName, IdentPtr pGetSet, bool isStatic, uint32* nameLength, uint32* pShortNameOffset, bool isComputedName, LPCOLESTR pMemberNameHint)\n{\n    if ((pMemberName == nullptr && !isComputedName) ||\n        (pMemberNameHint == nullptr && isComputedName) ||\n        !CONFIG_FLAG(UseFullName))\n    {\n        return nullptr;\n    }\n\n    LPCOLESTR pFinalName = isComputedName? pMemberNameHint : pMemberName->Psz();\n    uint32 fullNameHintLength = 0;\n    uint32 shortNameOffset = 0;\n    if (!isStatic)\n    {\n        \/\/ Add prototype.\n        pFinalName = AppendNameHints(wellKnownPropertyPids.prototype, pFinalName, &fullNameHintLength, &shortNameOffset);\n    }\n\n    if (pClassName)\n    {\n        uint32 classNameOffset = 0;\n        pFinalName = AppendNameHints(pClassName, pFinalName, &fullNameHintLength, &classNameOffset);\n        shortNameOffset += classNameOffset;\n    }\n\n    if (pGetSet)\n    {\n        if (m_scriptContext->GetConfig()->IsES6FunctionNameEnabled())\n        {\n            \/\/ displays as get\/set prototype.funcname\n            uint32 getSetOffset = 0;\n            pFinalName = AppendNameHints(pGetSet, pFinalName, &fullNameHintLength, &getSetOffset, true);\n            shortNameOffset += getSetOffset;\n        }\n        else\n        {\n            pFinalName = AppendNameHints(pFinalName, pGetSet, &fullNameHintLength, &shortNameOffset);\n        }\n\n    }\n    if (fullNameHintLength > *nameLength)\n    {\n        *nameLength = fullNameHintLength;\n    }\n\n    if (shortNameOffset > *pShortNameOffset)\n    {\n        *pShortNameOffset = shortNameOffset;\n    }\n\n    return pFinalName;\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":135999,"func":"get_func_line(\n    int\t    c UNUSED,\n    void    *cookie,\n    int\t    indent UNUSED,\n    getline_opt_T options UNUSED)\n{\n    funccall_T\t*fcp = (funccall_T *)cookie;\n    ufunc_T\t*fp = fcp->func;\n    char_u\t*retval;\n    garray_T\t*gap;  \/\/ growarray with function lines\n\n    \/\/ If breakpoints have been added\/deleted need to check for it.\n    if (fcp->dbg_tick != debug_tick)\n    {\n\tfcp->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name,\n\t\t\t\t\t\t\t       SOURCING_LNUM);\n\tfcp->dbg_tick = debug_tick;\n    }\n#ifdef FEAT_PROFILE\n    if (do_profiling == PROF_YES)\n\tfunc_line_end(cookie);\n#endif\n\n    gap = &fp->uf_lines;\n    if (((fp->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try())\n\t    || fcp->returned)\n\tretval = NULL;\n    else\n    {\n\t\/\/ Skip NULL lines (continuation lines).\n\twhile (fcp->linenr < gap->ga_len\n\t\t\t  && ((char_u **)(gap->ga_data))[fcp->linenr] == NULL)\n\t    ++fcp->linenr;\n\tif (fcp->linenr >= gap->ga_len)\n\t    retval = NULL;\n\telse\n\t{\n\t    retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]);\n\t    SOURCING_LNUM = fcp->linenr;\n#ifdef FEAT_PROFILE\n\t    if (do_profiling == PROF_YES)\n\t\tfunc_line_start(cookie, SOURCING_LNUM);\n#endif\n\t}\n    }\n\n    \/\/ Did we encounter a breakpoint?\n    if (fcp->breakpoint != 0 && fcp->breakpoint <= SOURCING_LNUM)\n    {\n\tdbg_breakpoint(fp->uf_name, SOURCING_LNUM);\n\t\/\/ Find next breakpoint.\n\tfcp->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name,\n\t\t\t\t\t\t\t       SOURCING_LNUM);\n\tfcp->dbg_tick = debug_tick;\n    }\n\n    return retval;\n}","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":158347,"func":"void CServer::RegisterCommands()\n{\n\tm_pConsole = Kernel()->RequestInterface<IConsole>();\n\tm_pGameServer = Kernel()->RequestInterface<IGameServer>();\n\tm_pMap = Kernel()->RequestInterface<IEngineMap>();\n\tm_pStorage = Kernel()->RequestInterface<IStorage>();\n\n\t\/\/ register console commands\n\tConsole()->Register(\"kick\", \"i?r\", CFGFLAG_SERVER, ConKick, this, \"Kick player with specified id for any reason\");\n\tConsole()->Register(\"status\", \"\", CFGFLAG_SERVER, ConStatus, this, \"List players\");\n\tConsole()->Register(\"shutdown\", \"\", CFGFLAG_SERVER, ConShutdown, this, \"Shut down\");\n\tConsole()->Register(\"logout\", \"\", CFGFLAG_SERVER, ConLogout, this, \"Logout of rcon\");\n\n\tConsole()->Register(\"record\", \"?s\", CFGFLAG_SERVER|CFGFLAG_STORE, ConRecord, this, \"Record to a file\");\n\tConsole()->Register(\"stoprecord\", \"\", CFGFLAG_SERVER, ConStopRecord, this, \"Stop recording\");\n\n\tConsole()->Register(\"reload\", \"\", CFGFLAG_SERVER, ConMapReload, this, \"Reload the map\");\n\n\tConsole()->Chain(\"sv_name\", ConchainSpecialInfoupdate, this);\n\tConsole()->Chain(\"password\", ConchainSpecialInfoupdate, this);\n\n\tConsole()->Chain(\"sv_max_clients_per_ip\", ConchainMaxclientsperipUpdate, this);\n\tConsole()->Chain(\"mod_command\", ConchainModCommandUpdate, this);\n\tConsole()->Chain(\"console_output_level\", ConchainConsoleOutputLevelUpdate, this);\n\n\t\/\/ register console commands in sub parts\n\tm_ServerBan.InitServerBan(Console(), Storage(), this);\n\tm_pGameServer->OnConsoleInit();\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":399516,"func":"static void rebind_workers(struct worker_pool *pool)\n{\n\tstruct worker *worker;\n\n\tlockdep_assert_held(&pool->attach_mutex);\n\n\t\/*\n\t * Restore CPU affinity of all workers.  As all idle workers should\n\t * be on the run-queue of the associated CPU before any local\n\t * wake-ups for concurrency management happen, restore CPU affinity\n\t * of all workers first and then clear UNBOUND.  As we're called\n\t * from CPU_ONLINE, the following shouldn't fail.\n\t *\/\n\tfor_each_pool_worker(worker, pool)\n\t\tWARN_ON_ONCE(set_cpus_allowed_ptr(worker->task,\n\t\t\t\t\t\t  pool->attrs->cpumask) < 0);\n\n\tspin_lock_irq(&pool->lock);\n\n\t\/*\n\t * XXX: CPU hotplug notifiers are weird and can call DOWN_FAILED\n\t * w\/o preceding DOWN_PREPARE.  Work around it.  CPU hotplug is\n\t * being reworked and this can go away in time.\n\t *\/\n\tif (!(pool->flags & POOL_DISASSOCIATED)) {\n\t\tspin_unlock_irq(&pool->lock);\n\t\treturn;\n\t}\n\n\tpool->flags &= ~POOL_DISASSOCIATED;\n\n\tfor_each_pool_worker(worker, pool) {\n\t\tunsigned int worker_flags = worker->flags;\n\n\t\t\/*\n\t\t * A bound idle worker should actually be on the runqueue\n\t\t * of the associated CPU for local wake-ups targeting it to\n\t\t * work.  Kick all idle workers so that they migrate to the\n\t\t * associated CPU.  Doing this in the same loop as\n\t\t * replacing UNBOUND with REBOUND is safe as no worker will\n\t\t * be bound before @pool->lock is released.\n\t\t *\/\n\t\tif (worker_flags & WORKER_IDLE)\n\t\t\twake_up_process(worker->task);\n\n\t\t\/*\n\t\t * We want to clear UNBOUND but can't directly call\n\t\t * worker_clr_flags() or adjust nr_running.  Atomically\n\t\t * replace UNBOUND with another NOT_RUNNING flag REBOUND.\n\t\t * @worker will clear REBOUND using worker_clr_flags() when\n\t\t * it initiates the next execution cycle thus restoring\n\t\t * concurrency management.  Note that when or whether\n\t\t * @worker clears REBOUND doesn't affect correctness.\n\t\t *\n\t\t * ACCESS_ONCE() is necessary because @worker->flags may be\n\t\t * tested without holding any lock in\n\t\t * wq_worker_waking_up().  Without it, NOT_RUNNING test may\n\t\t * fail incorrectly leading to premature concurrency\n\t\t * management operations.\n\t\t *\/\n\t\tWARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));\n\t\tworker_flags |= WORKER_REBOUND;\n\t\tworker_flags &= ~WORKER_UNBOUND;\n\t\tACCESS_ONCE(worker->flags) = worker_flags;\n\t}\n\n\tspin_unlock_irq(&pool->lock);\n}","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":118206,"func":"static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,\n\t\t\t\t\tstruct ext4_ext_path *path,\n\t\t\t\t\tstruct ext4_extent *newext)\n{\n\tstruct ext4_ext_path *curp;\n\tint depth, i, err = 0;\n\nrepeat:\n\ti = depth = ext_depth(inode);\n\n\t\/* walk up to the tree and look for free index entry *\/\n\tcurp = path + depth;\n\twhile (i > 0 && !EXT_HAS_FREE_INDEX(curp)) {\n\t\ti--;\n\t\tcurp--;\n\t}\n\n\t\/* we use already allocated block for index block,\n\t * so subsequent data blocks should be contiguous *\/\n\tif (EXT_HAS_FREE_INDEX(curp)) {\n\t\t\/* if we found index with free entry, then use that\n\t\t * entry: create all needed subtree and add new leaf *\/\n\t\terr = ext4_ext_split(handle, inode, path, newext, i);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\t\/* refill path *\/\n\t\text4_ext_drop_refs(path);\n\t\tpath = ext4_ext_find_extent(inode,\n\t\t\t\t    (ext4_lblk_t)le32_to_cpu(newext->ee_block),\n\t\t\t\t    path);\n\t\tif (IS_ERR(path))\n\t\t\terr = PTR_ERR(path);\n\t} else {\n\t\t\/* tree is full, time to grow in depth *\/\n\t\terr = ext4_ext_grow_indepth(handle, inode, path, newext);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\t\/* refill path *\/\n\t\text4_ext_drop_refs(path);\n\t\tpath = ext4_ext_find_extent(inode,\n\t\t\t\t   (ext4_lblk_t)le32_to_cpu(newext->ee_block),\n\t\t\t\t    path);\n\t\tif (IS_ERR(path)) {\n\t\t\terr = PTR_ERR(path);\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/*\n\t\t * only first (depth 0 -> 1) produces free space;\n\t\t * in all other cases we have to split the grown tree\n\t\t *\/\n\t\tdepth = ext_depth(inode);\n\t\tif (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) {\n\t\t\t\/* now we need to split *\/\n\t\t\tgoto repeat;\n\t\t}\n\t}\n\nout:\n\treturn err;\n}","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":318980,"func":"static int adx_read_header(AVFormatContext *s)\n\n{\n\n    ADXDemuxerContext *c = s->priv_data;\n\n    AVCodecParameters *par;\n\n\n\n    AVStream *st = avformat_new_stream(s, NULL);\n\n    if (!st)\n\n        return AVERROR(ENOMEM);\n\n    par = s->streams[0]->codecpar;\n\n\n\n    if (avio_rb16(s->pb) != 0x8000)\n\n        return AVERROR_INVALIDDATA;\n\n    c->header_size = avio_rb16(s->pb) + 4;\n\n    avio_seek(s->pb, -4, SEEK_CUR);\n\n\n\n    if (ff_get_extradata(s, par, s->pb, c->header_size) < 0)\n\n        return AVERROR(ENOMEM);\n\n\n\n    if (par->extradata_size < 12) {\n\n        av_log(s, AV_LOG_ERROR, \"Invalid extradata size.\\n\");\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n    par->channels    = AV_RB8 (par->extradata + 7);\n\n    par->sample_rate = AV_RB32(par->extradata + 8);\n\n\n\n    if (par->channels <= 0) {\n\n        av_log(s, AV_LOG_ERROR, \"invalid number of channels %d\\n\", par->channels);\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    if (par->sample_rate <= 0) {\n\n        av_log(s, AV_LOG_ERROR, \"Invalid sample rate %d\\n\", par->sample_rate);\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    par->codec_type  = AVMEDIA_TYPE_AUDIO;\n\n    par->codec_id    = s->iformat->raw_codec_id;\n\n    par->bit_rate    = par->sample_rate * par->channels * BLOCK_SIZE * 8LL \/ BLOCK_SAMPLES;\n\n\n\n    avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":329717,"func":"static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska,\n\n                                    AVPacket *pkt, uint64_t display_duration)\n\n{\n\n    char *line, *layer, *ptr = pkt->data, *end = ptr+pkt->size;\n\n    for (; *ptr!=',' && ptr<end-1; ptr++);\n\n    if (*ptr == ',')\n\n        layer = ++ptr;\n\n    for (; *ptr!=',' && ptr<end-1; ptr++);\n\n    if (*ptr == ',') {\n\n        int64_t end_pts = pkt->pts + display_duration;\n\n        int sc = matroska->time_scale * pkt->pts \/ 10000000;\n\n        int ec = matroska->time_scale * end_pts  \/ 10000000;\n\n        int sh, sm, ss, eh, em, es, len;\n\n        sh = sc\/360000;  sc -= 360000*sh;\n\n        sm = sc\/  6000;  sc -=   6000*sm;\n\n        ss = sc\/   100;  sc -=    100*ss;\n\n        eh = ec\/360000;  ec -= 360000*eh;\n\n        em = ec\/  6000;  ec -=   6000*em;\n\n        es = ec\/   100;  ec -=    100*es;\n\n        *ptr++ = '\\0';\n\n        len = 50 + end-ptr + FF_INPUT_BUFFER_PADDING_SIZE;\n\n        if (!(line = av_malloc(len)))\n\n            return;\n\n        snprintf(line,len,\"Dialogue: %s,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s\",\n\n                 layer, sh, sm, ss, sc, eh, em, es, ec, ptr);\n\n        av_free(pkt->data);\n\n        pkt->data = line;\n\n        pkt->size = strlen(line);\n\n    }\n\n}\n","target":1,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":523801,"func":"static int make_addressRange(IPAddressOrRange **result,\n                             unsigned char *min,\n                             unsigned char *max, const int length)\n{\n    IPAddressOrRange *aor;\n    int i, prefixlen;\n\n    if ((prefixlen = range_should_be_prefix(min, max, length)) >= 0)\n        return make_addressPrefix(result, min, prefixlen);\n\n    if ((aor = IPAddressOrRange_new()) == NULL)\n        return 0;\n    aor->type = IPAddressOrRange_addressRange;\n    OPENSSL_assert(aor->u.addressRange == NULL);\n    if ((aor->u.addressRange = IPAddressRange_new()) == NULL)\n        goto err;\n    if (aor->u.addressRange->min == NULL &&\n        (aor->u.addressRange->min = ASN1_BIT_STRING_new()) == NULL)\n        goto err;\n    if (aor->u.addressRange->max == NULL &&\n        (aor->u.addressRange->max = ASN1_BIT_STRING_new()) == NULL)\n        goto err;\n\n    for (i = length; i > 0 && min[i - 1] == 0x00; --i) ;\n    if (!ASN1_BIT_STRING_set(aor->u.addressRange->min, min, i))\n        goto err;\n    aor->u.addressRange->min->flags &= ~7;\n    aor->u.addressRange->min->flags |= ASN1_STRING_FLAG_BITS_LEFT;\n    if (i > 0) {\n        unsigned char b = min[i - 1];\n        int j = 1;\n        while ((b & (0xFFU >> j)) != 0)\n            ++j;\n        aor->u.addressRange->min->flags |= 8 - j;\n    }\n\n    for (i = length; i > 0 && max[i - 1] == 0xFF; --i) ;\n    if (!ASN1_BIT_STRING_set(aor->u.addressRange->max, max, i))\n        goto err;\n    aor->u.addressRange->max->flags &= ~7;\n    aor->u.addressRange->max->flags |= ASN1_STRING_FLAG_BITS_LEFT;\n    if (i > 0) {\n        unsigned char b = max[i - 1];\n        int j = 1;\n        while ((b & (0xFFU >> j)) != (0xFFU >> j))\n            ++j;\n        aor->u.addressRange->max->flags |= 8 - j;\n    }\n\n    *result = aor;\n    return 1;\n\n err:\n    IPAddressOrRange_free(aor);\n    return 0;\n}","target":0,"code_token_length":555,"total_token_length":791,"max_tokens_setting":1024}
+{"idx":5974,"func":"int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) \/* {{{ *\/\n{\n\tstruct fpm_worker_pool_config_s *c = wp->config;\n\n\t\/* uninitialized *\/\n\twp->socket_uid = -1;\n\twp->socket_gid = -1;\n\twp->socket_mode = 0666;\n\n\tif (!c) {\n\t\treturn 0;\n\t}\n\n\tif (c->listen_owner && *c->listen_owner) {\n\t\tstruct passwd *pwd;\n\n\t\tpwd = getpwnam(c->listen_owner);\n\t\tif (!pwd) {\n\t\t\tzlog(ZLOG_SYSERROR, \"[pool %s] cannot get uid for user '%s'\", wp->config->name, c->listen_owner);\n\t\t\treturn -1;\n\t\t}\n\n\t\twp->socket_uid = pwd->pw_uid;\n\t\twp->socket_gid = pwd->pw_gid;\n\t}\n\n\tif (c->listen_group && *c->listen_group) {\n\t\tstruct group *grp;\n\n\t\tgrp = getgrnam(c->listen_group);\n\t\tif (!grp) {\n\t\t\tzlog(ZLOG_SYSERROR, \"[pool %s] cannot get gid for group '%s'\", wp->config->name, c->listen_group);\n\t\t\treturn -1;\n\t\t}\n\t\twp->socket_gid = grp->gr_gid;\n\t}\n\n\tif (c->listen_mode && *c->listen_mode) {\n\t\twp->socket_mode = strtoul(c->listen_mode, 0, 8);\n\t}\n\treturn 0;\n}","target":1,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":506591,"func":"int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)\n\t{\n\tSSL_COMP *comp;\n\n        if (cm == NULL || cm->type == NID_undef)\n                return 1;\n\n\t\/* According to draft-ietf-tls-compression-04.txt, the\n\t   compression number ranges should be the following:\n\n\t   0 to 63:    methods defined by the IETF\n\t   64 to 192:  external party methods assigned by IANA\n\t   193 to 255: reserved for private use *\/\n\tif (id < 193 || id > 255)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE);\n\t\treturn 0;\n\t\t}\n\n\tMemCheck_off();\n\tcomp=(SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));\n\tcomp->id=id;\n\tcomp->method=cm;\n\tload_builtin_compressions();\n\tif (ssl_comp_methods\n\t\t&& sk_SSL_COMP_find(ssl_comp_methods,comp) >= 0)\n\t\t{\n\t\tOPENSSL_free(comp);\n\t\tMemCheck_on();\n\t\tSSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,SSL_R_DUPLICATE_COMPRESSION_ID);\n\t\treturn(1);\n\t\t}\n\telse if ((ssl_comp_methods == NULL)\n\t\t|| !sk_SSL_COMP_push(ssl_comp_methods,comp))\n\t\t{\n\t\tOPENSSL_free(comp);\n\t\tMemCheck_on();\n\t\tSSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE);\n\t\treturn(1);\n\t\t}\n\telse\n\t\t{\n\t\tMemCheck_on();\n\t\treturn(0);\n\t\t}\n\t}","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":154656,"func":"fast_save_enter(PicklerObject *self, PyObject *obj)\n{\n    \/* if fast_nesting < 0, we're doing an error exit. *\/\n    if (++self->fast_nesting >= FAST_NESTING_LIMIT) {\n        PyObject *key = NULL;\n        if (self->fast_memo == NULL) {\n            self->fast_memo = PyDict_New();\n            if (self->fast_memo == NULL) {\n                self->fast_nesting = -1;\n                return 0;\n            }\n        }\n        key = PyLong_FromVoidPtr(obj);\n        if (key == NULL) {\n            self->fast_nesting = -1;\n            return 0;\n        }\n        if (PyDict_GetItemWithError(self->fast_memo, key)) {\n            Py_DECREF(key);\n            PyErr_Format(PyExc_ValueError,\n                         \"fast mode: can't pickle cyclic objects \"\n                         \"including object type %.200s at %p\",\n                         obj->ob_type->tp_name, obj);\n            self->fast_nesting = -1;\n            return 0;\n        }\n        if (PyErr_Occurred()) {\n            Py_DECREF(key);\n            self->fast_nesting = -1;\n            return 0;\n        }\n        if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {\n            Py_DECREF(key);\n            self->fast_nesting = -1;\n            return 0;\n        }\n        Py_DECREF(key);\n    }\n    return 1;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":10106,"func":"coolkey_find_attribute(sc_card_t *card, sc_cardctl_coolkey_attribute_t *attribute)\n{\n\tu8 object_record_type;\n\tCK_ATTRIBUTE_TYPE attr_type = attribute->attribute_type;\n\tconst u8 *obj = attribute->object->data;\n\tconst u8 *attr = NULL;\n\tsize_t buf_len = attribute->object->length;\n\tcoolkey_object_header_t *object_head;\n\tint attribute_count,i;\n\tattribute->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_STRING;\n\tattribute->attribute_length = 0;\n\tattribute->attribute_value = NULL;\n\n\tif (obj == NULL) {\n\t\t\/* cast away const so we can cache the data value *\/\n\t\tint r = coolkey_fill_object(card, (sc_cardctl_coolkey_object_t *)attribute->object);\n\t\tif (r < 0) {\n\t\t\treturn r;\n\t\t}\n\t\tobj = attribute->object->data;\n\t}\n\n\t\/* should be a static assert so we catch this at compile time *\/\n\tassert(sizeof(coolkey_object_header_t) >= sizeof(coolkey_v0_object_header_t));\n\t\/* make sure we have enough of the object to read the record_type *\/\n\tif (buf_len <= sizeof(coolkey_v0_object_header_t)) {\n\t\treturn SC_ERROR_CORRUPTED_DATA;\n\t}\n\tobject_head = (coolkey_object_header_t *)obj;\n\tobject_record_type = object_head->record_type;\n\t\/* make sure it's a type we recognize *\/\n\tif ((object_record_type != COOLKEY_V1_OBJECT) && (object_record_type != COOLKEY_V0_OBJECT)) {\n\t\treturn SC_ERROR_CORRUPTED_DATA;\n\t}\n\n\n\t\/*\n\t * now loop through all the attributes in the list. first find the start of the list\n\t *\/\n\tattr = coolkey_attribute_start(obj, object_record_type, buf_len);\n\tif (attr == NULL) {\n\t\treturn SC_ERROR_CORRUPTED_DATA;\n\t}\n\tbuf_len -= (attr-obj);\n\n\t\/* now get the count *\/\n\tattribute_count = coolkey_get_attribute_count(obj, object_record_type, buf_len);\n \tfor (i=0; i < attribute_count; i++) {\n \t\tsize_t record_len = coolkey_get_attribute_record_len(attr, object_record_type, buf_len);\n \t\t\/* make sure we have the complete record *\/\n\t\tif (buf_len < record_len) {\n \t\t\t\treturn SC_ERROR_CORRUPTED_DATA;\n \t\t}\n \t\t\/* does the attribute match the one we are looking for *\/\n\t\tif (attr_type == coolkey_get_attribute_type(attr, object_record_type, record_len)) {\n\t\t\t\/* yup, return it *\/\n\t\t\treturn coolkey_get_attribute_data(attr, object_record_type, record_len, attribute);\n\t\t}\n\t\t\/* go to the next attribute on the list *\/\n\t\tbuf_len -= record_len;\n\t\tattr += record_len;\n\t}\n\t\/* not find in attribute list, check the fixed attribute record *\/\n\tif (object_record_type == COOLKEY_V1_OBJECT) {\n\t\tunsigned long fixed_attributes = bebytes2ulong(object_head->fixed_attributes_values);\n\n\t\treturn coolkey_get_attribute_data_fixed(attr_type, fixed_attributes, attribute);\n\t}\n\treturn SC_ERROR_DATA_OBJECT_NOT_FOUND;\n}\n","target":1,"code_token_length":667,"total_token_length":903,"max_tokens_setting":1024}
+{"idx":354014,"func":"AP_DECLARE(void) ap_update_vhost_from_headers(request_rec *r)\n{\n    core_server_config *conf = ap_get_core_module_config(r->server->module_config);\n    const char *host_header = apr_table_get(r->headers_in, \"Host\");\n    int is_v6literal = 0;\n    int have_hostname_from_url = 0;\n\n    if (r->hostname) {\n        \/*\n         * If there was a host part in the Request-URI, ignore the 'Host'\n         * header.\n         *\/\n        have_hostname_from_url = 1;\n        is_v6literal = fix_hostname(r, NULL, conf->http_conformance);\n    }\n    else if (host_header != NULL) {\n        is_v6literal = fix_hostname(r, host_header, conf->http_conformance);\n    }\n    if (r->status != HTTP_OK)\n        return;\n\n    if (conf->http_conformance != AP_HTTP_CONFORMANCE_UNSAFE) {\n        \/*\n         * If we have both hostname from an absoluteURI and a Host header,\n         * we must ignore the Host header (RFC 2616 5.2).\n         * To enforce this, we reset the Host header to the value from the\n         * request line.\n         *\/\n        if (have_hostname_from_url && host_header != NULL) {\n            const char *repl = construct_host_header(r, is_v6literal);\n            apr_table_setn(r->headers_in, \"Host\", repl);\n            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02417)\n                          \"Replacing host header '%s' with host '%s' given \"\n                          \"in the request uri\", host_header, repl);\n        }\n    }\n\n    \/* check if we tucked away a name_chain *\/\n    if (r->connection->vhost_lookup_data) {\n        if (r->hostname)\n            check_hostalias(r);\n        else\n            check_serverpath(r);\n    }\n}","target":1,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":348668,"func":"void free_G_buffers(__G)     \/* releases all memory allocated in global vars *\/\n    __GDEF\n{\n#ifndef SFX\n    unsigned i;\n#endif\n\n#ifdef SYSTEM_SPECIFIC_DTOR\n    SYSTEM_SPECIFIC_DTOR(__G);\n#endif\n\n    inflate_free(__G);\n    checkdir(__G__ (char *)NULL, END);\n\n#ifdef DYNALLOC_CRCTAB\n    if (CRC_32_TAB) {\n        free_crc_table();\n        CRC_32_TAB = NULL;\n    }\n#endif\n\n   if (G.key != (char *)NULL) {\n        free(G.key);\n        G.key = (char *)NULL;\n   }\n\n   if (G.extra_field != (uch *)NULL) {\n        free(G.extra_field);\n        G.extra_field = (uch *)NULL;\n   }\n\n#if (!defined(VMS) && !defined(SMALL_MEM))\n    \/* VMS uses its own buffer scheme for textmode flush() *\/\n    if (G.outbuf2) {\n        free(G.outbuf2);   \/* malloc'd ONLY if unshrink and -a *\/\n        G.outbuf2 = (uch *)NULL;\n    }\n#endif\n\n    if (G.outbuf)\n        free(G.outbuf);\n    if (G.inbuf)\n        free(G.inbuf);\n    G.inbuf = G.outbuf = (uch *)NULL;\n\n#ifdef UNICODE_SUPPORT\n    if (G.filename_full) {\n        free(G.filename_full);\n        G.filename_full = (char *)NULL;\n        G.fnfull_bufsize = 0;\n    }\n#endif \/* UNICODE_SUPPORT *\/\n\n#ifndef SFX\n    for (i = 0; i < DIR_BLKSIZ; i++) {\n        if (G.info[i].cfilname != (char Far *)NULL) {\n            zffree(G.info[i].cfilname);\n            G.info[i].cfilname = (char Far *)NULL;\n        }\n    }\n#endif\n\n#ifdef MALLOC_WORK\n    if (G.area.Slide) {\n        free(G.area.Slide);\n        G.area.Slide = (uch *)NULL;\n    }\n#endif\n\n} \/* end function free_G_buffers() *\/","target":1,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":456331,"func":"static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)\n{\n#ifdef CONFIG_VMAP_STACK\n\tvoid *stack;\n\tint i;\n\n\tfor (i = 0; i < NR_CACHED_STACKS; i++) {\n\t\tstruct vm_struct *s;\n\n\t\ts = this_cpu_xchg(cached_stacks[i], NULL);\n\n\t\tif (!s)\n\t\t\tcontinue;\n\n\t\t\/* Clear stale pointers from reused stack. *\/\n\t\tmemset(s->addr, 0, THREAD_SIZE);\n\n\t\ttsk->stack_vm_area = s;\n\t\ttsk->stack = s->addr;\n\t\treturn s->addr;\n\t}\n\n\t\/*\n\t * Allocated stacks are cached and later reused by new threads,\n\t * so memcg accounting is performed manually on assigning\/releasing\n\t * stacks to tasks. Drop __GFP_ACCOUNT.\n\t *\/\n\tstack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN,\n\t\t\t\t     VMALLOC_START, VMALLOC_END,\n\t\t\t\t     THREADINFO_GFP & ~__GFP_ACCOUNT,\n\t\t\t\t     PAGE_KERNEL,\n\t\t\t\t     0, node, __builtin_return_address(0));\n\n\t\/*\n\t * We can't call find_vm_area() in interrupt context, and\n\t * free_thread_stack() can be called in interrupt context,\n\t * so cache the vm_struct.\n\t *\/\n\tif (stack) {\n\t\ttsk->stack_vm_area = find_vm_area(stack);\n\t\ttsk->stack = stack;\n\t}\n\treturn stack;\n#else\n\tstruct page *page = alloc_pages_node(node, THREADINFO_GFP,\n\t\t\t\t\t     THREAD_SIZE_ORDER);\n\n\tif (likely(page)) {\n\t\ttsk->stack = page_address(page);\n\t\treturn tsk->stack;\n\t}\n\treturn NULL;\n#endif\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":167526,"func":"ProcXvQueryImageAttributes(ClientPtr client)\n{\n    xvQueryImageAttributesReply rep;\n    int size, num_planes, i;\n    CARD16 width, height;\n    XvImagePtr pImage = NULL;\n    XvPortPtr pPort;\n    int *offsets;\n    int *pitches;\n    int planeLength;\n\n    REQUEST(xvQueryImageAttributesReq);\n\n    REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);\n\n    VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);\n\n    for (i = 0; i < pPort->pAdaptor->nImages; i++) {\n        if (pPort->pAdaptor->pImages[i].id == stuff->id) {\n            pImage = &(pPort->pAdaptor->pImages[i]);\n            break;\n        }\n    }\n\n#ifdef XvMCExtension\n    if (!pImage)\n        pImage = XvMCFindXvImage(pPort, stuff->id);\n#endif\n\n    if (!pImage)\n        return BadMatch;\n\n    num_planes = pImage->num_planes;\n\n    if (!(offsets = malloc(num_planes << 3)))\n        return BadAlloc;\n    pitches = offsets + num_planes;\n\n    width = stuff->width;\n    height = stuff->height;\n\n    size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage,\n                                                       &width, &height, offsets,\n                                                       pitches);\n\n    rep = (xvQueryImageAttributesReply) {\n        .type = X_Reply,\n        .sequenceNumber = client->sequence,\n        .length = planeLength = num_planes << 1,\n        .num_planes = num_planes,\n        .width = width,\n        .height = height,\n        .data_size = size\n    };\n\n    _WriteQueryImageAttributesReply(client, &rep);\n    if (client->swapped)\n        SwapLongs((CARD32 *) offsets, planeLength);\n    WriteToClient(client, planeLength << 2, offsets);\n\n    free(offsets);\n\n    return Success;\n}\n","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":145593,"func":"static void sections_from_bin(RList *ret, RBinFile *bf, RDyldBinImage *bin) {\n\tRDyldCache *cache = (RDyldCache*) bf->o->bin_obj;\n\tif (!cache) {\n\t\treturn;\n\t}\n\n\tstruct MACH0_(obj_t) *mach0 = bin_to_mach0 (bf, bin);\n\tif (!mach0) {\n\t\treturn;\n\t}\n\n\tstruct section_t *sections = NULL;\n\tif (!(sections = MACH0_(get_sections) (mach0))) {\n\t\treturn;\n\t}\n\n\tut64 slide = rebase_infos_get_slide (cache);\n\tint i;\n\tfor (i = 0; !sections[i].last; i++) {\n\t\tRBinSection *ptr = R_NEW0 (RBinSection);\n\t\tif (!ptr) {\n\t\t\tbreak;\n\t\t}\n\t\tif (bin->file) {\n\t\t\tptr->name = r_str_newf (\"%s.%s\", bin->file, (char*)sections[i].name);\n\t\t} else {\n\t\t\tptr->name = r_str_newf (\"%s\", (char*)sections[i].name);\n\t\t}\n\t\tif (strstr (ptr->name, \"la_symbol_ptr\")) {\n\t\t\tint len = sections[i].size \/ 8;\n\t\t\tptr->format = r_str_newf (\"Cd %d[%d]\", 8, len);\n\t\t}\n\t\tptr->is_data = __is_data_section (ptr->name);\n\t\tptr->size = sections[i].size;\n\t\tptr->vsize = sections[i].vsize;\n\t\tptr->vaddr = sections[i].addr;\n\t\tptr->paddr = va2pa (sections[i].addr, cache->n_maps, cache->maps, cache->buf, slide, NULL, NULL);\n\t\tif (!ptr->vaddr) {\n\t\t\tptr->vaddr = ptr->paddr;\n\t\t}\n\t\tptr->perm = sections[i].perm;\n\t\tr_list_append (ret, ptr);\n\t}\n\tfree (sections);\n\tMACH0_(mach0_free) (mach0);\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":8434,"func":"static int replace_map_fd_with_map_ptr(struct verifier_env *env)\n{\n\tstruct bpf_insn *insn = env->prog->insnsi;\n\tint insn_cnt = env->prog->len;\n\tint i, j;\n\n\tfor (i = 0; i < insn_cnt; i++, insn++) {\n\t\tif (BPF_CLASS(insn->code) == BPF_LDX &&\n\t\t    (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) {\n\t\t\tverbose(\"BPF_LDX uses reserved fields\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (BPF_CLASS(insn->code) == BPF_STX &&\n\t\t    ((BPF_MODE(insn->code) != BPF_MEM &&\n\t\t      BPF_MODE(insn->code) != BPF_XADD) || insn->imm != 0)) {\n\t\t\tverbose(\"BPF_STX uses reserved fields\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {\n\t\t\tstruct bpf_map *map;\n\t\t\tstruct fd f;\n\n\t\t\tif (i == insn_cnt - 1 || insn[1].code != 0 ||\n\t\t\t    insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||\n\t\t\t    insn[1].off != 0) {\n\t\t\t\tverbose(\"invalid bpf_ld_imm64 insn\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\tif (insn->src_reg == 0)\n\t\t\t\t\/* valid generic load 64-bit imm *\/\n\t\t\t\tgoto next_insn;\n\n\t\t\tif (insn->src_reg != BPF_PSEUDO_MAP_FD) {\n\t\t\t\tverbose(\"unrecognized bpf_ld_imm64 insn\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\tf = fdget(insn->imm);\n\t\t\tmap = __bpf_map_get(f);\n\t\t\tif (IS_ERR(map)) {\n\t\t\t\tverbose(\"fd %d is not pointing to valid bpf_map\\n\",\n\t\t\t\t\tinsn->imm);\n\t\t\t\treturn PTR_ERR(map);\n\t\t\t}\n\n\t\t\t\/* store map pointer inside BPF_LD_IMM64 instruction *\/\n\t\t\tinsn[0].imm = (u32) (unsigned long) map;\n\t\t\tinsn[1].imm = ((u64) (unsigned long) map) >> 32;\n\n\t\t\t\/* check whether we recorded this map already *\/\n\t\t\tfor (j = 0; j < env->used_map_cnt; j++)\n\t\t\t\tif (env->used_maps[j] == map) {\n\t\t\t\t\tfdput(f);\n\t\t\t\t\tgoto next_insn;\n\t\t\t\t}\n\n\t\t\tif (env->used_map_cnt >= MAX_USED_MAPS) {\n\t\t\t\tfdput(f);\n\t\t\t\treturn -E2BIG;\n\t\t\t}\n\n\t\t\t\/* remember this map *\/\n\t\t\tenv->used_maps[env->used_map_cnt++] = map;\n\n\t\t\t\/* hold the map. If the program is rejected by verifier,\n\t\t\t * the map will be released by release_maps() or it\n\t\t\t * will be used by the valid program until it's unloaded\n\t\t\t * and all maps are released in free_bpf_prog_info()\n\t\t\t *\/\n\t\t\tbpf_map_inc(map, false);\n\t\t\tfdput(f);\nnext_insn:\n\t\t\tinsn++;\n\t\t\ti++;\n\t\t}\n\t}\n\n\t\/* now all pseudo BPF_LD_IMM64 instructions load valid\n\t * 'struct bpf_map *' into a register instead of user map_fd.\n\t * These pointers will be used later by verifier to validate map access.\n\t *\/\n\treturn 0;\n}","target":1,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":339528,"func":"vnc_display_setup_auth(VncDisplay *vs,\n\n                       bool password,\n\n                       bool sasl,\n\n                       bool tls,\n\n                       bool x509)\n\n{\n\n    \/*\n\n     * We have a choice of 3 authentication options\n\n     *\n\n     *   1. none\n\n     *   2. vnc\n\n     *   3. sasl\n\n     *\n\n     * The channel can be run in 2 modes\n\n     *\n\n     *   1. clear\n\n     *   2. tls\n\n     *\n\n     * And TLS can use 2 types of credentials\n\n     *\n\n     *   1. anon\n\n     *   2. x509\n\n     *\n\n     * We thus have 9 possible logical combinations\n\n     *\n\n     *   1. clear + none\n\n     *   2. clear + vnc\n\n     *   3. clear + sasl\n\n     *   4. tls + anon + none\n\n     *   5. tls + anon + vnc\n\n     *   6. tls + anon + sasl\n\n     *   7. tls + x509 + none\n\n     *   8. tls + x509 + vnc\n\n     *   9. tls + x509 + sasl\n\n     *\n\n     * These need to be mapped into the VNC auth schemes\n\n     * in an appropriate manner. In regular VNC, all the\n\n     * TLS options get mapped into VNC_AUTH_VENCRYPT\n\n     * sub-auth types.\n\n     *\/\n\n    if (password) {\n\n        if (tls) {\n\n            vs->auth = VNC_AUTH_VENCRYPT;\n\n            if (x509) {\n\n                VNC_DEBUG(\"Initializing VNC server with x509 password auth\\n\");\n\n                vs->subauth = VNC_AUTH_VENCRYPT_X509VNC;\n\n            } else {\n\n                VNC_DEBUG(\"Initializing VNC server with TLS password auth\\n\");\n\n                vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC;\n\n            }\n\n        } else {\n\n            VNC_DEBUG(\"Initializing VNC server with password auth\\n\");\n\n            vs->auth = VNC_AUTH_VNC;\n\n            vs->subauth = VNC_AUTH_INVALID;\n\n        }\n\n    } else if (sasl) {\n\n        if (tls) {\n\n            vs->auth = VNC_AUTH_VENCRYPT;\n\n            if (x509) {\n\n                VNC_DEBUG(\"Initializing VNC server with x509 SASL auth\\n\");\n\n                vs->subauth = VNC_AUTH_VENCRYPT_X509SASL;\n\n            } else {\n\n                VNC_DEBUG(\"Initializing VNC server with TLS SASL auth\\n\");\n\n                vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL;\n\n            }\n\n        } else {\n\n            VNC_DEBUG(\"Initializing VNC server with SASL auth\\n\");\n\n            vs->auth = VNC_AUTH_SASL;\n\n            vs->subauth = VNC_AUTH_INVALID;\n\n        }\n\n    } else {\n\n        if (tls) {\n\n            vs->auth = VNC_AUTH_VENCRYPT;\n\n            if (x509) {\n\n                VNC_DEBUG(\"Initializing VNC server with x509 no auth\\n\");\n\n                vs->subauth = VNC_AUTH_VENCRYPT_X509NONE;\n\n            } else {\n\n                VNC_DEBUG(\"Initializing VNC server with TLS no auth\\n\");\n\n                vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE;\n\n            }\n\n        } else {\n\n            VNC_DEBUG(\"Initializing VNC server with no auth\\n\");\n\n            vs->auth = VNC_AUTH_NONE;\n\n            vs->subauth = VNC_AUTH_INVALID;\n\n        }\n\n    }\n\n}\n","target":0,"code_token_length":782,"total_token_length":1018,"max_tokens_setting":1024}
+{"idx":97033,"func":"multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags)\n{\n    struct gc_arena gc = gc_new();\n    bool ret = true;\n\n    if (BLEN(&m->top.c2.buf) > 0)\n    {\n        unsigned int mroute_flags;\n        struct mroute_addr src, dest;\n        const int dev_type = TUNNEL_TYPE(m->top.c1.tuntap);\n        int16_t vid = 0;\n\n#ifdef ENABLE_PF\n        struct mroute_addr esrc, *e1, *e2;\n        if (dev_type == DEV_TYPE_TUN)\n        {\n            e1 = NULL;\n            e2 = &src;\n        }\n        else\n        {\n            e1 = e2 = &esrc;\n            mroute_addr_reset(&esrc);\n        }\n#endif\n\n#ifdef MULTI_DEBUG_EVENT_LOOP\n        printf(\"TUN -> TCP\/UDP [%d]\\n\", BLEN(&m->top.c2.buf));\n#endif\n\n        if (m->pending)\n        {\n            return true;\n        }\n\n        if (dev_type == DEV_TYPE_TAP && m->top.options.vlan_tagging)\n        {\n            vid = vlan_decapsulate(&m->top, &m->top.c2.buf);\n            if (vid < 0)\n            {\n                return false;\n            }\n        }\n\n        \/*\n         * Route an incoming tun\/tap packet to\n         * the appropriate multi_instance object.\n         *\/\n\n        mroute_flags = mroute_extract_addr_from_packet(&src,\n                                                       &dest,\n#ifdef ENABLE_PF\n                                                       e1,\n#else\n                                                       NULL,\n#endif\n                                                       NULL,\n                                                       vid,\n                                                       &m->top.c2.buf,\n                                                       dev_type);\n\n        if (mroute_flags & MROUTE_EXTRACT_SUCCEEDED)\n        {\n            struct context *c;\n\n            \/* broadcast or multicast dest addr? *\/\n            if (mroute_flags & (MROUTE_EXTRACT_BCAST|MROUTE_EXTRACT_MCAST))\n            {\n                \/* for now, treat multicast as broadcast *\/\n#ifdef ENABLE_PF\n                multi_bcast(m, &m->top.c2.buf, NULL, e2, vid);\n#else\n                multi_bcast(m, &m->top.c2.buf, NULL, NULL, vid);\n#endif\n            }\n            else\n            {\n                multi_set_pending(m, multi_get_instance_by_virtual_addr(m, &dest, dev_type == DEV_TYPE_TUN));\n\n                if (m->pending)\n                {\n                    \/* get instance context *\/\n                    c = &m->pending->context;\n\n                    set_prefix(m->pending);\n\n#ifdef ENABLE_PF\n                    if (!pf_addr_test(&c->c2.pf, c, e2, \"tun_tap_src_addr\"))\n                    {\n                        msg(D_PF_DROPPED, \"PF: addr[%s] -> client packet dropped by packet filter\",\n                            mroute_addr_print_ex(&src, MAPF_SHOW_ARP, &gc));\n                        buf_reset_len(&c->c2.buf);\n                    }\n                    else\n#endif\n                    {\n                        if (multi_output_queue_ready(m, m->pending))\n                        {\n                            \/* transfer packet pointer from top-level context buffer to instance *\/\n                            c->c2.buf = m->top.c2.buf;\n                        }\n                        else\n                        {\n                            \/* drop packet *\/\n                            msg(D_MULTI_DROPPED, \"MULTI: packet dropped due to output saturation (multi_process_incoming_tun)\");\n                            buf_reset_len(&c->c2.buf);\n                        }\n                    }\n\n                    \/* encrypt in instance context *\/\n                    process_incoming_tun(c);\n\n                    \/* postprocess and set wakeup *\/\n                    ret = multi_process_post(m, m->pending, mpp_flags);\n\n                    clear_prefix();\n                }\n            }\n        }\n    }\n    gc_free(&gc);\n    return ret;\n}","target":0,"code_token_length":787,"total_token_length":1023,"max_tokens_setting":1024}
+{"idx":330677,"func":"static inline int halfpel_motion_search(MpegEncContext * s,\n\n\t\t\t\t  int *mx_ptr, int *my_ptr, int dmin,\n\n\t\t\t\t  int xmin, int ymin, int xmax, int ymax,\n\n                                  int pred_x, int pred_y, uint8_t *ref_picture)\n\n{\n\n    UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; \/\/ f_code of the prev frame\n\n    const int quant= s->qscale;\n\n    int pen_x, pen_y;\n\n    int mx, my, mx1, my1, d, xx, yy, dminh;\n\n    UINT8 *pix, *ptr;\n\n\n\n    mx = *mx_ptr;\n\n    my = *my_ptr;\n\n    ptr = ref_picture + (my * s->linesize) + mx;\n\n\n\n    xx = 16 * s->mb_x;\n\n    yy = 16 * s->mb_y;\n\n    pix =  s->new_picture[0] + (yy * s->linesize) + xx;\n\n    \n\n    dminh = dmin;\n\n\n\n    if (mx > xmin && mx < xmax && \n\n        my > ymin && my < ymax) {\n\n\n\n        mx= mx1= 2*(mx - xx);\n\n        my= my1= 2*(my - yy);\n\n        if(dmin < Z_THRESHOLD && mx==0 && my==0){\n\n            *mx_ptr = 0;\n\n            *my_ptr = 0;\n\n            return dmin;\n\n        }\n\n        \n\n        pen_x= pred_x + mx;\n\n        pen_y= pred_y + my;\n\n\n\n        ptr-= s->linesize;\n\n        CHECK_HALF_MV(xy2, -1, -1)\n\n        CHECK_HALF_MV(y2 ,  0, -1)\n\n        CHECK_HALF_MV(xy2, +1, -1)\n\n        \n\n        ptr+= s->linesize;\n\n        CHECK_HALF_MV(x2 , -1,  0)\n\n        CHECK_HALF_MV(x2 , +1,  0)\n\n        CHECK_HALF_MV(xy2, -1, +1)\n\n        CHECK_HALF_MV(y2 ,  0, +1)\n\n        CHECK_HALF_MV(xy2, +1, +1)\n\n\n\n    }else{\n\n        mx= 2*(mx - xx);\n\n        my= 2*(my - yy);\n\n    }\n\n\n\n    *mx_ptr = mx;\n\n    *my_ptr = my;\n\n    return dminh;\n\n}\n","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":56193,"func":"static void print_udev_format(const char *name, const char *value)\n{\n\tchar enc[265], safe[256];\n\tsize_t namelen = strlen(name);\n\n\t*safe = *enc = '\\0';\n\n\tif (!strcmp(name, \"TYPE\") || !strcmp(name, \"VERSION\")) {\n\t\tblkid_encode_string(value, enc, sizeof(enc));\n\t\tprintf(\"ID_FS_%s=%s\\n\", name, enc);\n\n\t} else if (!strcmp(name, \"UUID\") ||\n\t\t !strcmp(name, \"LABEL\") ||\n\t\t !strcmp(name, \"UUID_SUB\")) {\n\n\t\tblkid_safe_string(value, safe, sizeof(safe));\n\t\tprintf(\"ID_FS_%s=%s\\n\", name, safe);\n\n\t\tblkid_encode_string(value, enc, sizeof(enc));\n\t\tprintf(\"ID_FS_%s_ENC=%s\\n\", name, enc);\n\n\t} else if (!strcmp(name, \"PTUUID\")) {\n\t\tprintf(\"ID_PART_TABLE_UUID=%s\\n\", value);\n\n\t} else if (!strcmp(name, \"PTTYPE\")) {\n\t\tprintf(\"ID_PART_TABLE_TYPE=%s\\n\", value);\n\n\t} else if (!strcmp(name, \"PART_ENTRY_NAME\") ||\n\t\t  !strcmp(name, \"PART_ENTRY_TYPE\")) {\n\n\t\tblkid_encode_string(value, enc, sizeof(enc));\n\t\tprintf(\"ID_%s=%s\\n\", name, enc);\n\n\t} else if (!strncmp(name, \"PART_ENTRY_\", 11))\n\t\tprintf(\"ID_%s=%s\\n\", name, value);\n\n\telse if (namelen >= 15 && (\n\t\t   !strcmp(name + (namelen - 12), \"_SECTOR_SIZE\") ||\n\t\t   !strcmp(name + (namelen - 8), \"_IO_SIZE\") ||\n\t\t   !strcmp(name, \"ALIGNMENT_OFFSET\")))\n\t\t\tprintf(\"ID_IOLIMIT_%s=%s\\n\", name, value);\n\telse\n\t\tprintf(\"ID_FS_%s=%s\\n\", name, value);\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":392583,"func":"HWB_to_RGB (HWBType HWB, RGBType * RGB)\n{\n\n  \/* \n   * H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1].  \n   * RGB are each returned on [0, 1]. \n   *\/\n\n  float h = HWB.H, w = HWB.W, b = HWB.B, v, n, f;\n  int i;\n\n  v = 1 - b;\n  if (h == HWB_UNDEFINED)\n    RETURN_RGB (v, v, v);\n  i = floor (h);\n  f = h - i;\n  if (i & 1)\n    f = 1 - f;\t\t\t\/* if i is odd *\/\n  n = w + f * (v - w);\t\t\/* linear interpolation between w and v *\/\n  switch (i)\n    {\n    case 6:\n    case 0:\n      RETURN_RGB (v, n, w);\n    case 1:\n      RETURN_RGB (n, v, w);\n    case 2:\n      RETURN_RGB (w, v, n);\n    case 3:\n      RETURN_RGB (w, n, v);\n    case 4:\n      RETURN_RGB (n, w, v);\n    case 5:\n      RETURN_RGB (v, w, n);\n    }\n\n  return RGB;\n\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":223167,"func":"void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) {\n  if (!DeleteObject(texture))\n    return;\n\n  int max_bound_texture_index = -1;\n  for (wtf_size_t i = 0; i < one_plus_max_non_default_texture_unit_; ++i) {\n    if (texture == texture_units_[i].texture2d_binding_) {\n      texture_units_[i].texture2d_binding_ = nullptr;\n      max_bound_texture_index = i;\n    }\n    if (texture == texture_units_[i].texture_cube_map_binding_) {\n      texture_units_[i].texture_cube_map_binding_ = nullptr;\n      max_bound_texture_index = i;\n    }\n    if (IsWebGL2OrHigher()) {\n      if (texture == texture_units_[i].texture3d_binding_) {\n        texture_units_[i].texture3d_binding_ = nullptr;\n        max_bound_texture_index = i;\n      }\n      if (texture == texture_units_[i].texture2d_array_binding_) {\n        texture_units_[i].texture2d_array_binding_ = nullptr;\n        max_bound_texture_index = i;\n      }\n    }\n  }\n  if (framebuffer_binding_)\n    framebuffer_binding_->RemoveAttachmentFromBoundFramebuffer(GL_FRAMEBUFFER,\n                                                               texture);\n  if (GetFramebufferBinding(GL_READ_FRAMEBUFFER))\n    GetFramebufferBinding(GL_READ_FRAMEBUFFER)\n        ->RemoveAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER, texture);\n\n  if (one_plus_max_non_default_texture_unit_ ==\n      static_cast<wtf_size_t>(max_bound_texture_index + 1)) {\n    FindNewMaxNonDefaultTextureUnit();\n  }\n}\n","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":8201,"func":"static int follow_dotdot_rcu(struct nameidata *nd)\n{\n\tstruct inode *inode = nd->inode;\n\tif (!nd->root.mnt)\n\t\tset_root_rcu(nd);\n\n\twhile (1) {\n\t\tif (path_equal(&nd->path, &nd->root))\n\t\t\tbreak;\n\t\tif (nd->path.dentry != nd->path.mnt->mnt_root) {\n\t\t\tstruct dentry *old = nd->path.dentry;\n\t\t\tstruct dentry *parent = old->d_parent;\n\t\t\tunsigned seq;\n\n\t\t\tinode = parent->d_inode;\n\t\t\tseq = read_seqcount_begin(&parent->d_seq);\n\t\t\tif (unlikely(read_seqcount_retry(&old->d_seq, nd->seq)))\n\t\t\t\treturn -ECHILD;\n\t\t\tnd->path.dentry = parent;\n\t\t\tnd->seq = seq;\n\t\t\tbreak;\n\t\t} else {\n\t\t\tstruct mount *mnt = real_mount(nd->path.mnt);\n\t\t\tstruct mount *mparent = mnt->mnt_parent;\n\t\t\tstruct dentry *mountpoint = mnt->mnt_mountpoint;\n\t\t\tstruct inode *inode2 = mountpoint->d_inode;\n\t\t\tunsigned seq = read_seqcount_begin(&mountpoint->d_seq);\n\t\t\tif (unlikely(read_seqretry(&mount_lock, nd->m_seq)))\n\t\t\t\treturn -ECHILD;\n\t\t\tif (&mparent->mnt == nd->path.mnt)\n\t\t\t\tbreak;\n\t\t\t\/* we know that mountpoint was pinned *\/\n\t\t\tnd->path.dentry = mountpoint;\n\t\t\tnd->path.mnt = &mparent->mnt;\n\t\t\tinode = inode2;\n\t\t\tnd->seq = seq;\n\t\t}\n\t}\n\twhile (unlikely(d_mountpoint(nd->path.dentry))) {\n\t\tstruct mount *mounted;\n\t\tmounted = __lookup_mnt(nd->path.mnt, nd->path.dentry);\n\t\tif (unlikely(read_seqretry(&mount_lock, nd->m_seq)))\n\t\t\treturn -ECHILD;\n\t\tif (!mounted)\n\t\t\tbreak;\n\t\tnd->path.mnt = &mounted->mnt;\n\t\tnd->path.dentry = mounted->mnt.mnt_root;\n\t\tinode = nd->path.dentry->d_inode;\n\t\tnd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);\n\t}\n\tnd->inode = inode;\n\treturn 0;\n}","target":1,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":258818,"func":"glob_dir_to_array (dir, array, flags)\n     char *dir, **array;\n     int flags;\n{\n  register unsigned int i, l;\n  int add_slash;\n  char **result, *new;\n  struct stat sb;\n\n  l = strlen (dir);\n  if (l == 0)\n    {\n      if (flags & GX_MARKDIRS)\n\tfor (i = 0; array[i]; i++)\n\t  {\n\t    if ((stat (array[i], &sb) == 0) && S_ISDIR (sb.st_mode))\n\t      {\n\t\tl = strlen (array[i]);\n\t\tnew = (char *)realloc (array[i], l + 2);\n\t\tif (new == 0)\n\t\t  return NULL;\n\t\tnew[l] = '\/';\n\t\tnew[l+1] = '\\0';\n\t\tarray[i] = new;\n\t      }\n\t  }\n      return (array);\n    }\n\n  add_slash = dir[l - 1] != '\/';\n\n  i = 0;\n  while (array[i] != NULL)\n    ++i;\n\n  result = (char **) malloc ((i + 1) * sizeof (char *));\n  if (result == NULL)\n    return (NULL);\n\n  for (i = 0; array[i] != NULL; i++)\n    {\n      \/* 3 == 1 for NUL, 1 for slash at end of DIR, 1 for GX_MARKDIRS *\/\n      result[i] = (char *) malloc (l + strlen (array[i]) + 3);\n\n      if (result[i] == NULL)\n\t{\n\t  int ind;\n\t  for (ind = 0; ind < i; ind++)\n\t    free (result[ind]);\n\t  free (result);\n\t  return (NULL);\n\t}\n\n      strcpy (result[i], dir);\n      if (add_slash)\n\tresult[i][l] = '\/';\n      if (array[i][0])\n\t{\n\t  strcpy (result[i] + l + add_slash, array[i]);\n\t  if (flags & GX_MARKDIRS)\n\t    {\n\t      if ((stat (result[i], &sb) == 0) && S_ISDIR (sb.st_mode))\n\t\t{\n\t\t  size_t rlen;\n\t\t  rlen = strlen (result[i]);\n\t\t  result[i][rlen] = '\/';\n\t\t  result[i][rlen+1] = '\\0';\n\t\t}\n\t    }\n\t}\n      else\n        result[i][l+add_slash] = '\\0';\n    }\n  result[i] = NULL;\n\n  \/* Free the input array.  *\/\n  for (i = 0; array[i] != NULL; i++)\n    free (array[i]);\n  free ((char *) array);\n\n  return (result);\n}","target":0,"code_token_length":564,"total_token_length":800,"max_tokens_setting":1024}
+{"idx":499159,"func":"int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)\n{\n\tunsigned char *inode_table = NULL, *dir_table = NULL;\n\tint j, token_count = 0, ret = 0, metablks_count;\n\tstruct squashfs_dir_stream *dirs;\n\tchar **token_list = NULL, *path = NULL;\n\tu32 *pos_list = NULL;\n\n\tdirs = calloc(1, sizeof(*dirs));\n\tif (!dirs)\n\t\treturn -EINVAL;\n\n\t\/* these should be set to NULL to prevent dangling pointers *\/\n\tdirs->dir_header = NULL;\n\tdirs->entry = NULL;\n\tdirs->table = NULL;\n\tdirs->inode_table = NULL;\n\tdirs->dir_table = NULL;\n\n\tret = sqfs_read_inode_table(&inode_table);\n\tif (ret) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tmetablks_count = sqfs_read_directory_table(&dir_table, &pos_list);\n\tif (metablks_count < 1) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* Tokenize filename *\/\n\ttoken_count = sqfs_count_tokens(filename);\n\tif (token_count < 0) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tpath = strdup(filename);\n\tif (!path) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\ttoken_list = malloc(token_count * sizeof(char *));\n\tif (!token_list) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* Fill tokens list *\/\n\tret = sqfs_tokenize(token_list, token_count, path);\n\tif (ret)\n\t\tgoto out;\n\t\/*\n\t * ldir's (extended directory) size is greater than dir, so it works as\n\t * a general solution for the malloc size, since 'i' is a union.\n\t *\/\n\tdirs->inode_table = inode_table;\n\tdirs->dir_table = dir_table;\n\tret = sqfs_search_dir(dirs, token_list, token_count, pos_list,\n\t\t\t      metablks_count);\n\tif (ret)\n\t\tgoto out;\n\n\tif (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)\n\t\tdirs->size = le16_to_cpu(dirs->i_dir.file_size);\n\telse\n\t\tdirs->size = le32_to_cpu(dirs->i_ldir.file_size);\n\n\t\/* Setup directory header *\/\n\tmemcpy(dirs->dir_header, dirs->table, SQFS_DIR_HEADER_SIZE);\n\tdirs->entry_count = dirs->dir_header->count + 1;\n\tdirs->size -= SQFS_DIR_HEADER_SIZE;\n\n\t\/* Setup entry *\/\n\tdirs->entry = NULL;\n\tdirs->table += SQFS_DIR_HEADER_SIZE;\n\n\t*dirsp = (struct fs_dir_stream *)dirs;\n\nout:\n\tfor (j = 0; j < token_count; j++)\n\t\tfree(token_list[j]);\n\tfree(token_list);\n\tfree(pos_list);\n\tfree(path);\n\tif (ret) {\n\t\tfree(inode_table);\n\t\tfree(dirs);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":630,"total_token_length":866,"max_tokens_setting":1024}
+{"idx":337106,"func":"int unix_listen_opts(QemuOpts *opts, Error **errp)\n\n{\n\n    struct sockaddr_un un;\n\n    const char *path = qemu_opt_get(opts, \"path\");\n\n    int sock, fd;\n\n\n\n    sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);\n\n    if (sock < 0) {\n\n        error_setg_errno(errp, errno, \"Failed to create Unix socket\");\n\n        return -1;\n\n    }\n\n\n\n    memset(&un, 0, sizeof(un));\n\n    un.sun_family = AF_UNIX;\n\n    if (path && strlen(path)) {\n\n        snprintf(un.sun_path, sizeof(un.sun_path), \"%s\", path);\n\n    } else {\n\n        const char *tmpdir = getenv(\"TMPDIR\");\n\n        tmpdir = tmpdir ? tmpdir : \"\/tmp\";\n\n        if (snprintf(un.sun_path, sizeof(un.sun_path), \"%s\/qemu-socket-XXXXXX\",\n\n                     tmpdir) >= sizeof(un.sun_path)) {\n\n            error_setg_errno(errp, errno,\n\n                             \"TMPDIR environment variable (%s) too large\", tmpdir);\n\n            goto err;\n\n        }\n\n\n\n        \/*\n\n         * This dummy fd usage silences the mktemp() unsecure warning.\n\n         * Using mkstemp() doesn't make things more secure here\n\n         * though.  bind() complains about existing files, so we have\n\n         * to unlink first and thus re-open the race window.  The\n\n         * worst case possible is bind() failing, i.e. a DoS attack.\n\n         *\/\n\n        fd = mkstemp(un.sun_path);\n\n        if (fd < 0) {\n\n            error_setg_errno(errp, errno,\n\n                             \"Failed to make a temporary socket name in %s\", tmpdir);\n\n            goto err;\n\n        }\n\n        close(fd);\n\n        qemu_opt_set(opts, \"path\", un.sun_path, &error_abort);\n\n    }\n\n\n\n    if ((access(un.sun_path, F_OK) == 0) &&\n\n        unlink(un.sun_path) < 0) {\n\n        error_setg_errno(errp, errno,\n\n                         \"Failed to unlink socket %s\", un.sun_path);\n\n        goto err;\n\n    }\n\n    if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {\n\n        error_setg_errno(errp, errno, \"Failed to bind socket to %s\", un.sun_path);\n\n        goto err;\n\n    }\n\n    if (listen(sock, 1) < 0) {\n\n        error_setg_errno(errp, errno, \"Failed to listen on socket\");\n\n        goto err;\n\n    }\n\n\n\n    return sock;\n\n\n\nerr:\n\n    closesocket(sock);\n\n    return -1;\n\n}\n","target":1,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":498953,"func":"static RzList *analysis_graph_to(RzCore *core, ut64 addr, int depth, HtUP *avoid) {\n\tRzAnalysisFunction *cur_fcn = rz_analysis_get_fcn_in(core->analysis, core->offset, 0);\n\tRzList *list = rz_list_new();\n\tHtUP *state = ht_up_new0();\n\n\tif (!list || !state || !cur_fcn) {\n\t\trz_list_free(list);\n\t\tht_up_free(state);\n\t\treturn NULL;\n\t}\n\n\t\/\/ forward search\n\tif (analysis_path_exists(core, core->offset, addr, list, depth - 1, state, avoid)) {\n\t\tht_up_free(state);\n\t\treturn list;\n\t}\n\n\t\/\/ backward search\n\tRzList *xrefs = rz_analysis_xrefs_get_to(core->analysis, cur_fcn->addr);\n\tif (xrefs) {\n\t\tRzListIter *iter;\n\t\tRzAnalysisXRef *xref = NULL;\n\t\trz_list_foreach (xrefs, iter, xref) {\n\t\t\tif (xref->type == RZ_ANALYSIS_REF_TYPE_CALL) {\n\t\t\t\tut64 offset = core->offset;\n\t\t\t\tcore->offset = xref->from;\n\t\t\t\trz_list_free(list);\n\t\t\t\tlist = analysis_graph_to(core, addr, depth - 1, avoid);\n\t\t\t\tcore->offset = offset;\n\t\t\t\tif (list && rz_list_length(list)) {\n\t\t\t\t\trz_list_free(xrefs);\n\t\t\t\t\tht_up_free(state);\n\t\t\t\t\treturn list;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\trz_list_free(xrefs);\n\tht_up_free(state);\n\trz_list_free(list);\n\treturn NULL;\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":335949,"func":"static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,\n\n    int num_reqs, MultiwriteCB *mcb)\n\n{\n\n    int i, outidx;\n\n\n\n    \/\/ Sort requests by start sector\n\n    qsort(reqs, num_reqs, sizeof(*reqs), &multiwrite_req_compare);\n\n\n\n    \/\/ Check if adjacent requests touch the same clusters. If so, combine them,\n\n    \/\/ filling up gaps with zero sectors.\n\n    outidx = 0;\n\n    for (i = 1; i < num_reqs; i++) {\n\n        int merge = 0;\n\n        int64_t oldreq_last = reqs[outidx].sector + reqs[outidx].nb_sectors;\n\n\n\n        \/\/ This handles the cases that are valid for all block drivers, namely\n\n        \/\/ exactly sequential writes and overlapping writes.\n\n        if (reqs[i].sector <= oldreq_last) {\n\n            merge = 1;\n\n        }\n\n\n\n        \/\/ The block driver may decide that it makes sense to combine requests\n\n        \/\/ even if there is a gap of some sectors between them. In this case,\n\n        \/\/ the gap is filled with zeros (therefore only applicable for yet\n\n        \/\/ unused space in format like qcow2).\n\n        if (!merge && bs->drv->bdrv_merge_requests) {\n\n            merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);\n\n        }\n\n\n\n        if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {\n\n            merge = 0;\n\n        }\n\n\n\n        if (merge) {\n\n            size_t size;\n\n            QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));\n\n            qemu_iovec_init(qiov,\n\n                reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1);\n\n\n\n            \/\/ Add the first request to the merged one. If the requests are\n\n            \/\/ overlapping, drop the last sectors of the first request.\n\n            size = (reqs[i].sector - reqs[outidx].sector) << 9;\n\n            qemu_iovec_concat(qiov, reqs[outidx].qiov, size);\n\n\n\n            \/\/ We might need to add some zeros between the two requests\n\n            if (reqs[i].sector > oldreq_last) {\n\n                size_t zero_bytes = (reqs[i].sector - oldreq_last) << 9;\n\n                uint8_t *buf = qemu_blockalign(bs, zero_bytes);\n\n                memset(buf, 0, zero_bytes);\n\n                qemu_iovec_add(qiov, buf, zero_bytes);\n\n                mcb->callbacks[i].free_buf = buf;\n\n            }\n\n\n\n            \/\/ Add the second request\n\n            qemu_iovec_concat(qiov, reqs[i].qiov, reqs[i].qiov->size);\n\n\n\n            reqs[outidx].nb_sectors += reqs[i].nb_sectors;\n\n            reqs[outidx].qiov = qiov;\n\n\n\n            mcb->callbacks[i].free_qiov = reqs[outidx].qiov;\n\n        } else {\n\n            outidx++;\n\n            reqs[outidx].sector     = reqs[i].sector;\n\n            reqs[outidx].nb_sectors = reqs[i].nb_sectors;\n\n            reqs[outidx].qiov       = reqs[i].qiov;\n\n        }\n\n    }\n\n\n\n    return outidx + 1;\n\n}\n","target":0,"code_token_length":719,"total_token_length":955,"max_tokens_setting":1024}
+{"idx":117692,"func":"learn_address_script(const struct multi_context *m,\n                     const struct multi_instance *mi,\n                     const char *op,\n                     const struct mroute_addr *addr)\n{\n    struct gc_arena gc = gc_new();\n    struct env_set *es;\n    bool ret = true;\n    struct plugin_list *plugins;\n\n    \/* get environmental variable source *\/\n    if (mi && mi->context.c2.es)\n    {\n        es = mi->context.c2.es;\n    }\n    else\n    {\n        es = env_set_create(&gc);\n    }\n\n    \/* get plugin source *\/\n    if (mi)\n    {\n        plugins = mi->context.plugins;\n    }\n    else\n    {\n        plugins = m->top.plugins;\n    }\n\n    if (plugin_defined(plugins, OPENVPN_PLUGIN_LEARN_ADDRESS))\n    {\n        struct argv argv = argv_new();\n        argv_printf(&argv, \"%s %s\",\n                    op,\n                    mroute_addr_print(addr, &gc));\n        if (mi)\n        {\n            argv_printf_cat(&argv, \"%s\", tls_common_name(mi->context.c2.tls_multi, false));\n        }\n        if (plugin_call(plugins, OPENVPN_PLUGIN_LEARN_ADDRESS, &argv, NULL, es) != OPENVPN_PLUGIN_FUNC_SUCCESS)\n        {\n            msg(M_WARN, \"WARNING: learn-address plugin call failed\");\n            ret = false;\n        }\n        argv_free(&argv);\n    }\n\n    if (m->top.options.learn_address_script)\n    {\n        struct argv argv = argv_new();\n        setenv_str(es, \"script_type\", \"learn-address\");\n        argv_parse_cmd(&argv, m->top.options.learn_address_script);\n        argv_printf_cat(&argv, \"%s %s\", op, mroute_addr_print(addr, &gc));\n        if (mi)\n        {\n            argv_printf_cat(&argv, \"%s\", tls_common_name(mi->context.c2.tls_multi, false));\n        }\n        if (!openvpn_run_script(&argv, es, 0, \"--learn-address\"))\n        {\n            ret = false;\n        }\n        argv_free(&argv);\n    }\n\n    gc_free(&gc);\n    return ret;\n}","target":0,"code_token_length":446,"total_token_length":682,"max_tokens_setting":1024}
+{"idx":428323,"func":"void tcp_send_loss_probe(struct sock *sk)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *skb;\n\tint pcount;\n\tint mss = tcp_current_mss(sk);\n\n\tskb = tcp_send_head(sk);\n\tif (skb && tcp_snd_wnd_test(tp, skb, mss)) {\n\t\tpcount = tp->packets_out;\n\t\ttcp_write_xmit(sk, mss, TCP_NAGLE_OFF, 2, GFP_ATOMIC);\n\t\tif (tp->packets_out > pcount)\n\t\t\tgoto probe_sent;\n\t\tgoto rearm_timer;\n\t}\n\tskb = skb_rb_last(&sk->tcp_rtx_queue);\n\tif (unlikely(!skb)) {\n\t\tWARN_ONCE(tp->packets_out,\n\t\t\t  \"invalid inflight: %u state %u cwnd %u mss %d\\n\",\n\t\t\t  tp->packets_out, sk->sk_state, tp->snd_cwnd, mss);\n\t\tinet_csk(sk)->icsk_pending = 0;\n\t\treturn;\n\t}\n\n\t\/* At most one outstanding TLP retransmission. *\/\n\tif (tp->tlp_high_seq)\n\t\tgoto rearm_timer;\n\n\tif (skb_still_in_host_queue(sk, skb))\n\t\tgoto rearm_timer;\n\n\tpcount = tcp_skb_pcount(skb);\n\tif (WARN_ON(!pcount))\n\t\tgoto rearm_timer;\n\n\tif ((pcount > 1) && (skb->len > (pcount - 1) * mss)) {\n\t\tif (unlikely(tcp_fragment(sk, TCP_FRAG_IN_RTX_QUEUE, skb,\n\t\t\t\t\t  (pcount - 1) * mss, mss,\n\t\t\t\t\t  GFP_ATOMIC)))\n\t\t\tgoto rearm_timer;\n\t\tskb = skb_rb_next(skb);\n\t}\n\n\tif (WARN_ON(!skb || !tcp_skb_pcount(skb)))\n\t\tgoto rearm_timer;\n\n\tif (__tcp_retransmit_skb(sk, skb, 1))\n\t\tgoto rearm_timer;\n\n\t\/* Record snd_nxt for loss detection. *\/\n\ttp->tlp_high_seq = tp->snd_nxt;\n\nprobe_sent:\n\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPLOSSPROBES);\n\t\/* Reset s.t. tcp_rearm_rto will restart timer from now *\/\n\tinet_csk(sk)->icsk_pending = 0;\nrearm_timer:\n\ttcp_rearm_rto(sk);\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":205443,"func":"png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,\n   int num_trans, int color_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n   PNG_tRNS;\n#endif\n   png_byte buf[6];\n\n   png_debug(1, \"in png_write_tRNS\");\n\n   if (color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)\n      {\n         png_warning(png_ptr, \"Invalid number of transparent colors specified\");\n         return;\n      }\n      \/* Write the chunk out as it is *\/\n      png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans,\n        (png_size_t)num_trans);\n   }\n   else if (color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      \/* One 16 bit value *\/\n      if (tran->gray >= (1 << png_ptr->bit_depth))\n      {\n         png_warning(png_ptr,\n           \"Ignoring attempt to write tRNS chunk out-of-range for bit_depth\");\n         return;\n      }\n      png_save_uint_16(buf, tran->gray);\n      png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);\n   }\n   else if (color_type == PNG_COLOR_TYPE_RGB)\n   {\n      \/* Three 16 bit values *\/\n      png_save_uint_16(buf, tran->red);\n      png_save_uint_16(buf + 2, tran->green);\n      png_save_uint_16(buf + 4, tran->blue);\n      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n      {\n         png_warning(png_ptr,\n           \"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8\");\n         return;\n      }\n      png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);\n   }\n   else\n   {\n      png_warning(png_ptr, \"Can't write tRNS with an alpha channel\");\n   }\n}\n","target":0,"code_token_length":459,"total_token_length":695,"max_tokens_setting":1024}
+{"idx":389333,"func":"XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval* newvalue) \/* {{{ *\/\n{\n\tXMLRPC_VALUE_TYPE type = xmlrpc_none;\n\n\tif (value) {\n\t\tswitch (Z_TYPE_P(value)) {\n\t\t\tcase IS_NULL:\n\t\t\t\ttype = xmlrpc_base64;\n\t\t\t\tbreak;\n#ifndef BOOL_AS_LONG\n\n\t\t\t\/* Right thing to do, but it breaks some legacy code. *\/\n\t\t\tcase IS_TRUE:\n\t\t\tcase IS_FALSE:\n\t\t\t\ttype = xmlrpc_boolean;\n\t\t\t\tbreak;\n#else\n\t\t\tcase IS_BOOL:\n#endif\n\t\t\tcase IS_LONG:\n\t\t\tcase IS_RESOURCE:\n\t\t\t\ttype = xmlrpc_int;\n\t\t\t\tbreak;\n\t\t\tcase IS_DOUBLE:\n\t\t\t\ttype = xmlrpc_double;\n\t\t\t\tbreak;\n\t\t\tcase IS_CONSTANT:\n\t\t\t\ttype = xmlrpc_string;\n\t\t\t\tbreak;\n\t\t\tcase IS_STRING:\n\t\t\t\ttype = xmlrpc_string;\n\t\t\t\tbreak;\n\t\t\tcase IS_ARRAY:\n\t\t\t\ttype = xmlrpc_vector;\n\t\t\t\tbreak;\n\t\t\tcase IS_OBJECT:\n\t\t\t\t{\n\t\t\t\t\tzval* attr;\n\t\t\t\t\ttype = xmlrpc_vector;\n\n\t\t\t\t\tif ((attr = zend_hash_str_find(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR) - 1)) != NULL) {\n\t\t\t\t\t\tif (Z_TYPE_P(attr) == IS_STRING) {\n\t\t\t\t\t\t\ttype = xmlrpc_str_as_type(Z_STRVAL_P(attr));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\n\t\t\/* if requested, return an unmolested (magic removed) copy of the value *\/\n\t\tif (newvalue) {\n\t\t\tzval* val;\n\n\t\t\tif ((type == xmlrpc_base64 && Z_TYPE_P(value) == IS_OBJECT) || type == xmlrpc_datetime) {\n\t\t\t\tif ((val = zend_hash_str_find(Z_OBJPROP_P(value), OBJECT_VALUE_ATTR, sizeof(OBJECT_VALUE_ATTR) - 1)) != NULL) {\n\t\t\t\t\tZVAL_COPY_VALUE(newvalue, val);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tZVAL_COPY_VALUE(newvalue, value);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn type;\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":392027,"func":"http_DissectResponse(struct worker *w, const struct http_conn *htc,\n    struct http *hp)\n{\n\tint j;\n\tuint16_t retval = 0;\n\tchar *p;\n\n\n\tCHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);\n\tCHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);\n\thp->logtag = HTTP_Rx;\n\n\tif (http_splitline(w, htc->fd, hp, htc,\n\t    HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE))\n\t\tretval = 503;\n\n\tif (retval == 0 && memcmp(hp->hd[HTTP_HDR_PROTO].b, \"HTTP\/1.\", 7))\n\t\tretval = 503;\n\n\tif (retval == 0 && Tlen(hp->hd[HTTP_HDR_STATUS]) != 3)\n\t\tretval = 503;\n\n\tif (retval == 0) {\n\t\thp->status = 0;\n\t\tp = hp->hd[HTTP_HDR_STATUS].b;\n\t\tfor (j = 100; j != 0; j \/= 10) {\n\t\t\tif (!vct_isdigit(*p)) {\n\t\t\t\tretval = 503;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\thp->status += (uint16_t)(j * (*p - '0'));\n\t\t\tp++;\n\t\t}\n\t\tif (*p != '\\0')\n\t\t\tretval = 503;\n\t}\n\n\tif (retval != 0) {\n\t\tWSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf);\n\t\tassert(retval >= 100 && retval <= 999);\n\t\thp->status = retval;\n\t} else {\n\t\thttp_ProtoVer(hp);\n\t}\n\n\tif (hp->hd[HTTP_HDR_RESPONSE].b == NULL ||\n\t    !Tlen(hp->hd[HTTP_HDR_RESPONSE])) {\n\t\t\/* Backend didn't send a response string, use the standard *\/\n\t\thp->hd[HTTP_HDR_RESPONSE].b =\n\t\t    TRUST_ME(http_StatusMessage(hp->status));\n\t\thp->hd[HTTP_HDR_RESPONSE].e =\n\t\t    strchr(hp->hd[HTTP_HDR_RESPONSE].b, '\\0');\n\t}\n\treturn (retval);\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":483048,"func":"rrset_equal(struct ub_packed_rrset_key* k1, struct ub_packed_rrset_key* k2)\n{\n\tstruct packed_rrset_data* d1 = (struct packed_rrset_data*)\n\t\tk1->entry.data;\n\tstruct packed_rrset_data* d2 = (struct packed_rrset_data*)\n\t\tk2->entry.data;\n\tsize_t i, t;\n\tif(k1->rk.dname_len != k2->rk.dname_len ||\n\t\tk1->rk.flags != k2->rk.flags ||\n\t\tk1->rk.type != k2->rk.type ||\n\t\tk1->rk.rrset_class != k2->rk.rrset_class ||\n\t\tquery_dname_compare(k1->rk.dname, k2->rk.dname) != 0)\n\t\treturn 0;\n\tif(\t\/* do not check ttl: d1->ttl != d2->ttl || *\/\n\t\td1->count != d2->count ||\n\t\td1->rrsig_count != d2->rrsig_count ||\n\t\td1->trust != d2->trust ||\n\t\td1->security != d2->security)\n\t\treturn 0;\n\tt = d1->count + d1->rrsig_count;\n\tfor(i=0; i<t; i++) {\n\t\tif(d1->rr_len[i] != d2->rr_len[i] ||\n\t\t\t\/* no ttl check: d1->rr_ttl[i] != d2->rr_ttl[i] ||*\/\n\t\t\tmemcmp(d1->rr_data[i], d2->rr_data[i],\n\t\t\t\td1->rr_len[i]) != 0)\n\t\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":31754,"func":"int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,\n\t\t\t __u32 start_minor_hash, __u32 *next_hash)\n{\n\tstruct dx_hash_info hinfo;\n\tstruct ext4_dir_entry_2 *de;\n\tstruct dx_frame frames[2], *frame;\n\tstruct inode *dir;\n\text4_lblk_t block;\n\tint count = 0;\n\tint ret, err;\n\t__u32 hashval;\n\n\tdxtrace(printk(KERN_DEBUG \"In htree_fill_tree, start hash: %x:%x\\n\",\n\t\t       start_hash, start_minor_hash));\n\tdir = dir_file->f_path.dentry->d_inode;\n\tif (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) {\n\t\thinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;\n\t\tif (hinfo.hash_version <= DX_HASH_TEA)\n\t\t\thinfo.hash_version +=\n\t\t\t\tEXT4_SB(dir->i_sb)->s_hash_unsigned;\n\t\thinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;\n\t\tcount = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo,\n\t\t\t\t\t       start_hash, start_minor_hash);\n\t\t*next_hash = ~0;\n\t\treturn count;\n\t}\n\thinfo.hash = start_hash;\n\thinfo.minor_hash = 0;\n\tframe = dx_probe(NULL, dir, &hinfo, frames, &err);\n\tif (!frame)\n\t\treturn err;\n\n\t\/* Add '.' and '..' from the htree header *\/\n\tif (!start_hash && !start_minor_hash) {\n\t\tde = (struct ext4_dir_entry_2 *) frames[0].bh->b_data;\n\t\tif ((err = ext4_htree_store_dirent(dir_file, 0, 0, de)) != 0)\n\t\t\tgoto errout;\n\t\tcount++;\n\t}\n\tif (start_hash < 2 || (start_hash ==2 && start_minor_hash==0)) {\n\t\tde = (struct ext4_dir_entry_2 *) frames[0].bh->b_data;\n\t\tde = ext4_next_entry(de, dir->i_sb->s_blocksize);\n\t\tif ((err = ext4_htree_store_dirent(dir_file, 2, 0, de)) != 0)\n\t\t\tgoto errout;\n\t\tcount++;\n\t}\n\n\twhile (1) {\n\t\tblock = dx_get_block(frame->at);\n\t\tret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo,\n\t\t\t\t\t     start_hash, start_minor_hash);\n\t\tif (ret < 0) {\n\t\t\terr = ret;\n\t\t\tgoto errout;\n\t\t}\n\t\tcount += ret;\n\t\thashval = ~0;\n\t\tret = ext4_htree_next_block(dir, HASH_NB_ALWAYS,\n\t\t\t\t\t    frame, frames, &hashval);\n\t\t*next_hash = hashval;\n\t\tif (ret < 0) {\n\t\t\terr = ret;\n\t\t\tgoto errout;\n\t\t}\n\t\t\/*\n\t\t * Stop if:  (a) there are no more entries, or\n\t\t * (b) we have inserted at least one entry and the\n\t\t * next hash value is not a continuation\n\t\t *\/\n\t\tif ((ret == 0) ||\n\t\t    (count && ((hashval & 1) == 0)))\n\t\t\tbreak;\n\t}\n\tdx_release(frames);\n\tdxtrace(printk(KERN_DEBUG \"Fill tree: returned %d entries, \"\n\t\t       \"next hash: %x\\n\", count, *next_hash));\n\treturn count;\nerrout:\n\tdx_release(frames);\n\treturn (err);\n}","target":0,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":44045,"func":"static bool esilbreak_mem_read(RAnalEsil *esil, ut64 addr, ut8 *buf, int len) {\n\tut8 str[128];\n\tif (addr != UT64_MAX) {\n\t\tesilbreak_last_read = addr;\n\t}\n\thandle_var_stack_access (esil, addr, R_ANAL_VAR_ACCESS_TYPE_READ, len);\n\tif (myvalid (mycore->io, addr) && r_io_read_at (mycore->io, addr, (ut8*)buf, len)) {\n\t\tut64 refptr;\n\t\tbool trace = true;\n\t\tswitch (len) {\n\t\tcase 2:\n\t\t\tesilbreak_last_data = refptr = (ut64)r_read_ble16 (buf, esil->anal->big_endian);\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tesilbreak_last_data = refptr = (ut64)r_read_ble32 (buf, esil->anal->big_endian);\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tesilbreak_last_data = refptr = r_read_ble64 (buf, esil->anal->big_endian);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttrace = false;\n\t\t\tr_io_read_at (mycore->io, addr, (ut8*)buf, len);\n\t\t\tbreak;\n\t\t}\n\t\t\/\/ TODO incorrect\n\t\tbool validRef = false;\n\t\tif (trace && myvalid (mycore->io, refptr)) {\n\t\t\tif (ntarget == UT64_MAX || ntarget == refptr) {\n\t\t\t\tstr[0] = 0;\n\t\t\t\tif (r_io_read_at (mycore->io, refptr, str, sizeof (str)) < 1) {\n\t\t\t\t\t\/\/eprintf (\"Invalid read\\n\");\n\t\t\t\t\tstr[0] = 0;\n\t\t\t\t\tvalidRef = false;\n\t\t\t\t} else {\n\t\t\t\t\tr_anal_xrefs_set (mycore->anal, esil->address, refptr, R_ANAL_REF_TYPE_DATA);\n\t\t\t\t\tstr[sizeof (str) - 1] = 0;\n\t\t\t\t\tadd_string_ref (mycore, esil->address, refptr);\n\t\t\t\t\tesilbreak_last_data = UT64_MAX;\n\t\t\t\t\tvalidRef = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/** resolve ptr *\/\n\t\tif (ntarget == UT64_MAX || ntarget == addr || (ntarget == UT64_MAX && !validRef)) {\n\t\t\tr_anal_xrefs_set (mycore->anal, esil->address, addr, R_ANAL_REF_TYPE_DATA);\n\t\t}\n\t}\n\treturn false; \/\/ fallback\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":101732,"func":"static RBinObject *r_bin_object_new(RBinFile *binfile, RBinPlugin *plugin,\n\t\t\t\t     ut64 baseaddr, ut64 loadaddr, ut64 offset,\n\t\t\t\t     ut64 sz) {\n\tconst ut8 *bytes = binfile? r_buf_buffer (binfile->buf): NULL;\n\tut64 bytes_sz = binfile? r_buf_size (binfile->buf): 0;\n\tSdb *sdb = binfile? binfile->sdb: NULL;\n\tRBinObject *o = R_NEW0 (RBinObject);\n\tif (!o) {\n\t\treturn NULL;\n\t}\n\to->obj_size = bytes && (bytes_sz >= sz + offset)? sz: 0;\n\to->boffset = offset;\n\to->id = r_num_rand (0xfffff000);\n\to->kv = sdb_new0 ();\n\to->baddr = baseaddr;\n\to->baddr_shift = 0;\n\to->plugin = plugin;\n\to->loadaddr = loadaddr != UT64_MAX ? loadaddr : 0;\n\n\t\/\/ XXX more checking will be needed here\n\t\/\/ only use LoadBytes if buffer offset != 0\n\t\/\/ if (offset != 0 && bytes && plugin && plugin->load_bytes && (bytes_sz\n\t\/\/ >= sz + offset) ) {\n\tif (bytes && plugin && plugin->load_bytes && (bytes_sz >= sz + offset)) {\n\t\tut64 bsz = bytes_sz - offset;\n\t\tif (sz < bsz) {\n\t\t\tbsz = sz;\n\t\t}\n\t\to->bin_obj = plugin->load_bytes (binfile, bytes + offset, sz,\n\t\t\t\t\t\t loadaddr, sdb);\n\t\tif (!o->bin_obj) {\n\t\t\tbprintf (\n\t\t\t\t\"Error in r_bin_object_new: load_bytes failed \"\n\t\t\t\t\"for %s plugin\\n\",\n\t\t\t\tplugin->name);\n\t\t\tsdb_free (o->kv);\n\t\t\tfree (o);\n\t\t\treturn NULL;\n\t\t}\n\t} else if (binfile && plugin && plugin->load) {\n\t\t\/\/ XXX - haha, this is a hack.\n\t\t\/\/ switching out the current object for the new\n\t\t\/\/ one to be processed\n\t\tRBinObject *old_o = binfile->o;\n\t\tbinfile->o = o;\n\t\tif (plugin->load (binfile)) {\n\t\t\tbinfile->sdb_info = o->kv;\n\t\t\t\/\/ mark as do not walk\n\t\t\tsdb_ns_set (binfile->sdb, \"info\", o->kv);\n\t\t} else {\n\t\t\tbinfile->o = old_o;\n\t\t}\n\t\to->obj_size = sz;\n\t} else {\n\t\tsdb_free (o->kv);\n\t\tfree (o);\n\t\treturn NULL;\n\t}\n\n\t\/\/ XXX - binfile could be null here meaning an improper load\n\t\/\/ XXX - object size cant be set here and needs to be set where\n\t\/\/ where the object is created from.  The reason for this is to prevent\n\t\/\/ mis-reporting when the file is loaded from impartial bytes or is\n\t\/\/ extracted\n\t\/\/ from a set of bytes in the file\n\tr_bin_object_set_items (binfile, o);\n\tr_bin_file_object_add (binfile, o);\n\n\t\/\/ XXX this is a very hacky alternative to rewriting the\n\t\/\/ RIO stuff, as discussed here:\n\treturn o;\n}","target":0,"code_token_length":718,"total_token_length":954,"max_tokens_setting":1024}
+{"idx":398495,"func":"static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun,\n                                      MegasasCmd *cmd)\n{\n    struct mfi_ld_info *info = cmd->iov_buf;\n    size_t dcmd_size = sizeof(struct mfi_ld_info);\n    uint8_t cdb[6];\n    SCSIRequest *req;\n    ssize_t len, resid;\n    uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);\n    uint64_t ld_size;\n\n    if (!cmd->iov_buf) {\n        cmd->iov_buf = g_malloc0(dcmd_size);\n        info = cmd->iov_buf;\n        megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83));\n        req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd);\n        if (!req) {\n            trace_megasas_dcmd_req_alloc_failed(cmd->index,\n                                                \"LD get info vpd inquiry\");\n            g_free(cmd->iov_buf);\n            cmd->iov_buf = NULL;\n            return MFI_STAT_FLASH_ALLOC_FAIL;\n        }\n        trace_megasas_dcmd_internal_submit(cmd->index,\n                                           \"LD get info vpd inquiry\", lun);\n        len = scsi_req_enqueue(req);\n        if (len > 0) {\n            cmd->iov_size = len;\n            scsi_req_continue(req);\n        }\n        return MFI_STAT_INVALID_STATUS;\n    }\n\n    info->ld_config.params.state = MFI_LD_STATE_OPTIMAL;\n    info->ld_config.properties.ld.v.target_id = lun;\n    info->ld_config.params.stripe_size = 3;\n    info->ld_config.params.num_drives = 1;\n    info->ld_config.params.is_consistent = 1;\n    \/* Logical device size is in blocks *\/\n    blk_get_geometry(sdev->conf.blk, &ld_size);\n    info->size = cpu_to_le64(ld_size);\n    memset(info->ld_config.span, 0, sizeof(info->ld_config.span));\n    info->ld_config.span[0].start_block = 0;\n    info->ld_config.span[0].num_blocks = info->size;\n    info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id);\n\n    resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg);\n    g_free(cmd->iov_buf);\n    cmd->iov_size = dcmd_size - resid;\n    cmd->iov_buf = NULL;\n    return MFI_STAT_OK;\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":134988,"func":"static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,\n\t\t\t   int broadcast_flags, struct sock *one_sk,\n\t\t\t   struct net *net)\n{\n\tstruct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);\n\tstruct sock *sk;\n\tstruct sk_buff *skb2 = NULL;\n\tint err = -ESRCH;\n\n\t\/* XXX Do we need something like netlink_overrun?  I think\n\t * XXX PF_KEY socket apps will not mind current behavior.\n\t *\/\n\tif (!skb)\n\t\treturn -ENOMEM;\n\n\trcu_read_lock();\n\tsk_for_each_rcu(sk, &net_pfkey->table) {\n\t\tstruct pfkey_sock *pfk = pfkey_sk(sk);\n\t\tint err2;\n\n\t\t\/* Yes, it means that if you are meant to receive this\n\t\t * pfkey message you receive it twice as promiscuous\n\t\t * socket.\n\t\t *\/\n\t\tif (pfk->promisc)\n\t\t\tpfkey_broadcast_one(skb, &skb2, allocation, sk);\n\n\t\t\/* the exact target will be processed later *\/\n\t\tif (sk == one_sk)\n\t\t\tcontinue;\n\t\tif (broadcast_flags != BROADCAST_ALL) {\n\t\t\tif (broadcast_flags & BROADCAST_PROMISC_ONLY)\n\t\t\t\tcontinue;\n\t\t\tif ((broadcast_flags & BROADCAST_REGISTERED) &&\n\t\t\t    !pfk->registered)\n\t\t\t\tcontinue;\n\t\t\tif (broadcast_flags & BROADCAST_ONE)\n\t\t\t\tcontinue;\n\t\t}\n\n\t\terr2 = pfkey_broadcast_one(skb, &skb2, allocation, sk);\n\n\t\t\/* Error is cleare after succecful sending to at least one\n\t\t * registered KM *\/\n\t\tif ((broadcast_flags & BROADCAST_REGISTERED) && err)\n\t\t\terr = err2;\n\t}\n\trcu_read_unlock();\n\n\tif (one_sk != NULL)\n\t\terr = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);\n\n\tkfree_skb(skb2);\n\tkfree_skb(skb);\n\treturn err;\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":64731,"func":"void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6hdr *iph;\n\tstruct sk_buff *skb;\n\tstruct ip6_mtuinfo *mtu_info;\n\n\tif (!np->rxopt.bits.rxpmtu)\n\t\treturn;\n\n\tskb = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC);\n\tif (!skb)\n\t\treturn;\n\n\tskb_put(skb, sizeof(struct ipv6hdr));\n\tskb_reset_network_header(skb);\n\tiph = ipv6_hdr(skb);\n\tiph->daddr = fl6->daddr;\n\n\tmtu_info = IP6CBMTU(skb);\n\n\tmtu_info->ip6m_mtu = mtu;\n\tmtu_info->ip6m_addr.sin6_family = AF_INET6;\n\tmtu_info->ip6m_addr.sin6_port = 0;\n\tmtu_info->ip6m_addr.sin6_flowinfo = 0;\n\tmtu_info->ip6m_addr.sin6_scope_id = fl6->flowi6_oif;\n\tmtu_info->ip6m_addr.sin6_addr = ipv6_hdr(skb)->daddr;\n\n\t__skb_pull(skb, skb_tail_pointer(skb) - skb->data);\n\tskb_reset_transport_header(skb);\n\n\tskb = xchg(&np->rxpmtu, skb);\n\tkfree_skb(skb);\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":94707,"func":"static int finish_read (lua_State *L, int status, lua_KContext ctx) {\n    int rc;\n    struct ssh_userdata *sshu = NULL;\n\n    sshu = (struct ssh_userdata *) nseU_checkudata(L, 1, SSH2_UDATA, \"ssh2\");\n\n    if (lua_toboolean(L, -2)) {\n        size_t n = 0;\n        size_t l = 0;\n        lua_getuservalue(L, 1);\n        lua_getfield(L, -1, \"sp_buff\");\n        lua_pushvalue(L, 3);\n        lua_concat(L, 2);\n        const char *data = lua_tolstring(L, -1, &l);\n        lua_pushliteral(L, \"\");\n        lua_setfield(L, 4, \"sp_buff\");\n\n        while (n < l) {\n#ifdef WIN32\n            rc = send(sshu->sp[1], data + n, l - n, 0);\n#else\n            rc = write(sshu->sp[1], data + n, l - n);\n#endif\n            if (rc == -1 && errno != EAGAIN) {\n                luaL_error(L, \"Writing to socket pair: %s\", strerror(errno));\n            }\n            else if (rc == -1 && errno == EAGAIN) {\n                lua_pushlstring(L, data + n, l - n);\n                lua_setfield(L, 4, \"sp_buff\");\n                break;\n            }\n            else {\n                n += rc;\n            }\n        }\n        return 0;\n    }\n    else {\n        return lua_error(L); \/* uses idx 6 *\/\n    }\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":396982,"func":"otherinfo(ParsedURL *target, ParsedURL *current, char *referer)\n{\n    Str s = Strnew();\n    const int *no_referer_ptr;\n    int no_referer;\n\n    Strcat_charp(s, \"User-Agent: \");\n    if (UserAgent == NULL || *UserAgent == '\\0')\n\tStrcat_charp(s, w3m_version);\n    else\n\tStrcat_charp(s, UserAgent);\n    Strcat_charp(s, \"\\r\\n\");\n\n    Strcat_m_charp(s, \"Accept: \", AcceptMedia, \"\\r\\n\", NULL);\n    Strcat_m_charp(s, \"Accept-Encoding: \", AcceptEncoding, \"\\r\\n\", NULL);\n    Strcat_m_charp(s, \"Accept-Language: \", AcceptLang, \"\\r\\n\", NULL);\n\n    if (target->host) {\n\tStrcat_charp(s, \"Host: \");\n\tStrcat_charp(s, target->host);\n\tif (target->port != DefaultPort[target->scheme])\n\t    Strcat(s, Sprintf(\":%d\", target->port));\n\tStrcat_charp(s, \"\\r\\n\");\n    }\n    if (target->is_nocache || NoCache) {\n\tStrcat_charp(s, \"Pragma: no-cache\\r\\n\");\n\tStrcat_charp(s, \"Cache-control: no-cache\\r\\n\");\n    }\n    no_referer = NoSendReferer;\n    no_referer_ptr = query_SCONF_NO_REFERER_FROM(current);\n    no_referer = no_referer || (no_referer_ptr && *no_referer_ptr);\n    no_referer_ptr = query_SCONF_NO_REFERER_TO(target);\n    no_referer = no_referer || (no_referer_ptr && *no_referer_ptr);\n    if (!no_referer) {\n#ifdef USE_SSL\n        if (current && current->scheme == SCM_HTTPS && target->scheme != SCM_HTTPS) {\n\t  \/* Don't send Referer: if https:\/\/ -> http:\/\/ *\/\n\t}\n\telse\n#endif\n\tif (referer == NULL && current && current->scheme != SCM_LOCAL &&\n\t    current->scheme != SCM_LOCAL_CGI &&\n\t    (current->scheme != SCM_FTP ||\n\t     (current->user == NULL && current->pass == NULL))) {\n\t    char *p = current->label;\n\t    Strcat_charp(s, \"Referer: \");\n\t    current->label = NULL;\n\t    Strcat(s, parsedURL2Str(current));\n\t    current->label = p;\n\t    Strcat_charp(s, \"\\r\\n\");\n\t}\n\telse if (referer != NULL && referer != NO_REFERER) {\n\t    char *p = strchr(referer, '#');\n\t    Strcat_charp(s, \"Referer: \");\n\t    if (p)\n\t\tStrcat_charp_n(s, referer, p - referer);\n\t    else\n\t\tStrcat_charp(s, referer);\n\t    Strcat_charp(s, \"\\r\\n\");\n\t}\n    }\n    return s->ptr;\n}","target":0,"code_token_length":625,"total_token_length":861,"max_tokens_setting":1024}
+{"idx":156746,"func":"void CServer::ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)\n{\n\tif(pResult->NumArguments() == 2)\n\t{\n\t\tCServer *pThis = static_cast<CServer *>(pUserData);\n\t\tconst IConsole::CCommandInfo *pInfo = pThis->Console()->GetCommandInfo(pResult->GetString(0), CFGFLAG_SERVER, false);\n\t\tint OldAccessLevel = 0;\n\t\tif(pInfo)\n\t\t\tOldAccessLevel = pInfo->GetAccessLevel();\n\t\tpfnCallback(pResult, pCallbackUserData);\n\t\tif(pInfo && OldAccessLevel != pInfo->GetAccessLevel())\n\t\t{\n\t\t\tfor(int i = 0; i < MAX_CLIENTS; ++i)\n\t\t\t{\n\t\t\t\tif(pThis->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY || pThis->m_aClients[i].m_Authed != CServer::AUTHED_MOD ||\n\t\t\t\t\t(pThis->m_aClients[i].m_pRconCmdToSend && str_comp(pResult->GetString(0), pThis->m_aClients[i].m_pRconCmdToSend->m_pName) >= 0))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif(OldAccessLevel == IConsole::ACCESS_LEVEL_ADMIN)\n\t\t\t\t\tpThis->SendRconCmdAdd(pInfo, i);\n\t\t\t\telse\n\t\t\t\t\tpThis->SendRconCmdRem(pInfo, i);\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t\tpfnCallback(pResult, pCallbackUserData);\n}","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":492577,"func":"gimp_channel_get_node (GimpFilter *filter)\n{\n  GimpDrawable *drawable = GIMP_DRAWABLE (filter);\n  GimpChannel  *channel  = GIMP_CHANNEL (filter);\n  GeglNode     *node;\n  GeglNode     *source;\n  GeglNode     *mode_node;\n  const Babl   *color_format;\n\n  node = GIMP_FILTER_CLASS (parent_class)->get_node (filter);\n\n  source = gimp_drawable_get_source_node (drawable);\n  gegl_node_add_child (node, source);\n\n  g_warn_if_fail (channel->color_node == NULL);\n\n  if (gimp_drawable_get_linear (drawable))\n    color_format = babl_format (\"RGBA float\");\n  else\n    color_format = babl_format (\"R'G'B'A float\");\n\n  channel->color_node = gegl_node_new_child (node,\n                                             \"operation\", \"gegl:color\",\n                                             \"format\",    color_format,\n                                             NULL);\n  gimp_gegl_node_set_color (channel->color_node,\n                            &channel->color);\n\n  g_warn_if_fail (channel->mask_node == NULL);\n\n  channel->mask_node = gegl_node_new_child (node,\n                                            \"operation\", \"gegl:opacity\",\n                                            NULL);\n  gegl_node_connect_to (channel->color_node, \"output\",\n                        channel->mask_node,  \"input\");\n\n  g_warn_if_fail (channel->invert_node == NULL);\n\n  channel->invert_node = gegl_node_new_child (node,\n                                              \"operation\", \"gegl:invert-linear\",\n                                              NULL);\n\n  if (channel->show_masked)\n    {\n      gegl_node_connect_to (source,               \"output\",\n                            channel->invert_node, \"input\");\n      gegl_node_connect_to (channel->invert_node, \"output\",\n                            channel->mask_node,   \"aux\");\n    }\n  else\n    {\n      gegl_node_connect_to (source,             \"output\",\n                            channel->mask_node, \"aux\");\n    }\n\n  mode_node = gimp_drawable_get_mode_node (drawable);\n\n  gegl_node_connect_to (channel->mask_node, \"output\",\n                        mode_node,          \"aux\");\n\n  return node;\n}","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":312073,"func":"long FS_SV_FOpenFileRead(const char *filename, fileHandle_t *fp)\n{\n\tchar *ospath;\n\tfileHandle_t\tf = 0;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\" );\n\t}\n\n\tf = FS_HandleForFile();\n\tfsh[f].zipFile = qfalse;\n\n\tQ_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );\n\n\n\tospath = FS_BuildOSPath( fs_homepath->string, filename, \"\" );\n\tospath[strlen(ospath)-1] = '\\0';\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_SV_FOpenFileRead (fs_homepath): %s\\n\", ospath );\n\t}\n\n\tfsh[f].handleFiles.file.o = Sys_FOpen( ospath, \"rb\" );\n\tfsh[f].handleSync = qfalse;\n\tif (!fsh[f].handleFiles.file.o)\n\t{\n\t\tif (Q_stricmp(fs_homepath->string,fs_basepath->string))\n\t\t{\n\t\t\tospath = FS_BuildOSPath( fs_basepath->string, filename, \"\" );\n\t\t\tospath[strlen(ospath)-1] = '\\0';\n\n\t\t\tif ( fs_debug->integer )\n\t\t\t{\n\t\t\t\tCom_Printf( \"FS_SV_FOpenFileRead (fs_basepath): %s\\n\", ospath );\n\t\t\t}\n\n\t\t\tfsh[f].handleFiles.file.o = Sys_FOpen( ospath, \"rb\" );\n\t\t\tfsh[f].handleSync = qfalse;\n\t\t}\n\n#ifndef STANDALONE\n\t\tif (!fsh[f].handleFiles.file.o && fs_steampath->string[0])\n\t\t{\n\t\t\tospath = FS_BuildOSPath( fs_steampath->string, filename, \"\" );\n\t\t\tospath[strlen(ospath)-1] = '\\0';\n\n\t\t\tif ( fs_debug->integer )\n\t\t\t{\n\t\t\t\tCom_Printf( \"FS_SV_FOpenFileRead (fs_steampath): %s\\n\", ospath );\n\t\t\t}\n\n\t\t\tfsh[f].handleFiles.file.o = Sys_FOpen( ospath, \"rb\" );\n\t\t\tfsh[f].handleSync = qfalse;\n\t\t}\n#endif\n\n\t\tif ( !fsh[f].handleFiles.file.o )\n\t\t{\n\t\t\tf = 0;\n\t\t}\n\t}\n\n\t*fp = f;\n\tif (f) {\n\t\treturn FS_filelength(f);\n\t}\n\n\treturn -1;\n}\n","target":0,"code_token_length":526,"total_token_length":762,"max_tokens_setting":1024}
+{"idx":407958,"func":"static int parsekeyword(unsigned char **pattern, unsigned char *charset)\n{\n  parsekey_state state = CURLFNM_PKW_INIT;\n#define KEYLEN 10\n  char keyword[KEYLEN] = { 0 };\n  int found = FALSE;\n  int i;\n  unsigned char *p = *pattern;\n  for(i = 0; !found; i++) {\n    char c = *p++;\n    if(i >= KEYLEN)\n      return SETCHARSET_FAIL;\n    switch(state) {\n    case CURLFNM_PKW_INIT:\n      if(ISALPHA(c) && ISLOWER(c))\n        keyword[i] = c;\n      else if(c == ':')\n        state = CURLFNM_PKW_DDOT;\n      else\n        return 0;\n      break;\n    case CURLFNM_PKW_DDOT:\n      if(c == ']')\n        found = TRUE;\n      else\n        return SETCHARSET_FAIL;\n    }\n  }\n#undef KEYLEN\n\n  *pattern = p; \/* move caller's pattern pointer *\/\n  if(strcmp(keyword, \"digit\") == 0)\n    charset[CURLFNM_DIGIT] = 1;\n  else if(strcmp(keyword, \"alnum\") == 0)\n    charset[CURLFNM_ALNUM] = 1;\n  else if(strcmp(keyword, \"alpha\") == 0)\n    charset[CURLFNM_ALPHA] = 1;\n  else if(strcmp(keyword, \"xdigit\") == 0)\n    charset[CURLFNM_XDIGIT] = 1;\n  else if(strcmp(keyword, \"print\") == 0)\n    charset[CURLFNM_PRINT] = 1;\n  else if(strcmp(keyword, \"graph\") == 0)\n    charset[CURLFNM_GRAPH] = 1;\n  else if(strcmp(keyword, \"space\") == 0)\n    charset[CURLFNM_SPACE] = 1;\n  else if(strcmp(keyword, \"blank\") == 0)\n    charset[CURLFNM_BLANK] = 1;\n  else if(strcmp(keyword, \"upper\") == 0)\n    charset[CURLFNM_UPPER] = 1;\n  else if(strcmp(keyword, \"lower\") == 0)\n    charset[CURLFNM_LOWER] = 1;\n  else\n    return SETCHARSET_FAIL;\n  return SETCHARSET_OK;\n}","target":0,"code_token_length":487,"total_token_length":723,"max_tokens_setting":1024}
+{"idx":350142,"func":"TEST_F(ServerSelectorTestFixture, ShouldSelectPreferredIfAvailable) {\n    TopologyStateMachine stateMachine(sdamConfiguration);\n    auto topologyDescription = std::make_shared<TopologyDescription>(sdamConfiguration);\n\n    const auto now = Date_t::now();\n\n\n    const auto d0 = now - Milliseconds(1000);\n    const auto s0 = ServerDescriptionBuilder()\n                        .withAddress(HostAndPort(\"s0\"))\n                        .withType(ServerType::kRSPrimary)\n                        .withRtt(sdamConfiguration.getLocalThreshold())\n                        .withSetName(\"set\")\n                        .withHost(HostAndPort(\"s0\"))\n                        .withHost(HostAndPort(\"s1\"))\n                        .withMinWireVersion(WireVersion::SUPPORTS_OP_MSG)\n                        .withMaxWireVersion(WireVersion::LATEST_WIRE_VERSION)\n                        .withLastWriteDate(d0)\n                        .withTag(\"tag\", \"primary\")\n                        .instance();\n    stateMachine.onServerDescription(*topologyDescription, s0);\n\n    const auto s1 = ServerDescriptionBuilder()\n                        .withAddress(HostAndPort(\"s1\"))\n                        .withType(ServerType::kRSSecondary)\n                        .withRtt(sdamConfiguration.getLocalThreshold())\n                        .withSetName(\"set\")\n                        .withHost(HostAndPort(\"s0\"))\n                        .withHost(HostAndPort(\"s1\"))\n                        .withMinWireVersion(WireVersion::SUPPORTS_OP_MSG)\n                        .withMaxWireVersion(WireVersion::LATEST_WIRE_VERSION)\n                        .withLastWriteDate(d0)\n                        .withTag(\"tag\", \"secondary\")\n                        .instance();\n    stateMachine.onServerDescription(*topologyDescription, s1);\n\n    const auto primaryPreferredTagSecondary =\n        ReadPreferenceSetting(ReadPreference::PrimaryPreferred, TagSets::secondarySet);\n    auto result1 = selector.selectServer(topologyDescription, primaryPreferredTagSecondary);\n    ASSERT(result1 != boost::none);\n    ASSERT_EQ(HostAndPort(\"s0\"), (*result1)->getAddress());\n\n    const auto secondaryPreferredWithTag =\n        ReadPreferenceSetting(ReadPreference::SecondaryPreferred, TagSets::secondarySet);\n    auto result2 = selector.selectServer(topologyDescription, secondaryPreferredWithTag);\n    ASSERT(result2 != boost::none);\n    ASSERT_EQ(HostAndPort(\"s1\"), (*result2)->getAddress());\n\n    const auto secondaryPreferredNoTag = ReadPreferenceSetting(ReadPreference::SecondaryPreferred);\n    auto result3 = selector.selectServer(topologyDescription, secondaryPreferredNoTag);\n    ASSERT(result3 != boost::none);\n    ASSERT_EQ(HostAndPort(\"s1\"), (*result2)->getAddress());\n}","target":1,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":103120,"func":"static void cmd_agraph_print(RCore *core, const char *input) {\n\tswitch (*input) {\n\tcase 'k': \/\/ \"aggk\"\n\t{\n\t\tSdb *db = r_agraph_get_sdb (core->graph);\n\t\tchar *o = sdb_querys (db, \"null\", 0, \"*\");\n\t\tr_cons_print (o);\n\t\tfree (o);\n\t\tbreak;\n\t}\n\tcase 'v': \/\/ \"aggv\"\n\t{\n\t\tconst char *cmd = r_config_get (core->config, \"cmd.graph\");\n\t\tif (cmd && *cmd) {\n\t\t\tchar *newCmd = strdup (cmd);\n\t\t\tif (newCmd) {\n\t\t\t\tnewCmd = r_str_replace (newCmd, \"ag $$\", \"aggd\", 0);\n\t\t\t\tr_core_cmd0 (core, newCmd);\n\t\t\t\tfree (newCmd);\n\t\t\t}\n\t\t} else {\n\t\t\tr_core_cmd0 (core, \"agf\");\n\t\t}\n\t\tbreak;\n\t}\n\tcase 'i': \/\/ \"aggi\" - open current core->graph in interactive mode\n\t{\n\t\tRANode *ran = r_agraph_get_first_node (core->graph);\n\t\tif (ran) {\n\t\t\tr_agraph_set_title (core->graph, r_config_get (core->config, \"graph.title\"));\n\t\t\tr_agraph_set_curnode (core->graph, ran);\n\t\t\tcore->graph->force_update_seek = true;\n\t\t\tcore->graph->need_set_layout = true;\n\t\t\tcore->graph->layout = r_config_get_i (core->config, \"graph.layout\");\n\t\t\tint ov = r_config_get_i (core->config, \"scr.interactive\");\n\t\t\tcore->graph->need_update_dim = true;\n\t\t\tr_core_visual_graph (core, core->graph, NULL, true);\n\t\t\tr_config_set_i (core->config, \"scr.interactive\", ov);\n\t\t\tr_cons_show_cursor (true);\n\t\t} else {\n\t\t\teprintf (\"This graph contains no nodes\\n\");\n\t\t}\n\t\tbreak;\n\t}\n\tcase 'd': \/\/ \"aggd\" - dot format\n\t\tr_cons_printf (\"digraph code {\\ngraph [bgcolor=white];\\n\"\n\t\t\t\"node [color=lightgray, style=filled shape=box \"\n\t\t\t\"fontname=\\\"Courier\\\" fontsize=\\\"8\\\"];\\n\");\n\t\tr_agraph_foreach (core->graph, agraph_print_node_dot, NULL);\n\t\tr_agraph_foreach_edge (core->graph, agraph_print_edge_dot, NULL);\n\t\tr_cons_printf (\"}\\n\");\n\t\tbreak;\n\tcase '*': \/\/ \"agg*\" -\n\t\tr_agraph_foreach (core->graph, agraph_print_node, NULL);\n\t\tr_agraph_foreach_edge (core->graph, agraph_print_edge, NULL);\n\t\tbreak;\n\tcase '?':\n\t\tr_core_cmd_help (core, help_msg_agg);\n\t\tbreak;\n\tdefault:\n\t\tcore->graph->can->linemode = r_config_get_i (core->config, \"graph.linemode\");\n\t\tcore->graph->can->color = r_config_get_i (core->config, \"scr.color\");\n\t\tr_agraph_set_title (core->graph,\n\t\t\tr_config_get (core->config, \"graph.title\"));\n\t\tr_agraph_print (core->graph);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":695,"total_token_length":931,"max_tokens_setting":1024}
+{"idx":331640,"func":"static void pxa2xx_gpio_write(void *opaque, hwaddr offset,\n\n                              uint64_t value, unsigned size)\n\n{\n\n    PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;\n\n    int bank;\n\n    if (offset >= 0x200)\n\n        return;\n\n\n\n    bank = pxa2xx_gpio_regs[offset].bank;\n\n    switch (pxa2xx_gpio_regs[offset].reg) {\n\n    case GPDR:\t\t\/* GPIO Pin-Direction registers *\/\n\n        s->dir[bank] = value;\n\n        pxa2xx_gpio_handler_update(s);\n\n        break;\n\n\n\n    case GPSR:\t\t\/* GPIO Pin-Output Set registers *\/\n\n        s->olevel[bank] |= value;\n\n        pxa2xx_gpio_handler_update(s);\n\n        s->gpsr[bank] = value;\n\n        break;\n\n\n\n    case GPCR:\t\t\/* GPIO Pin-Output Clear registers *\/\n\n        s->olevel[bank] &= ~value;\n\n        pxa2xx_gpio_handler_update(s);\n\n        break;\n\n\n\n    case GRER:\t\t\/* GPIO Rising-Edge Detect Enable registers *\/\n\n        s->rising[bank] = value;\n\n        break;\n\n\n\n    case GFER:\t\t\/* GPIO Falling-Edge Detect Enable registers *\/\n\n        s->falling[bank] = value;\n\n        break;\n\n\n\n    case GAFR_L:\t\/* GPIO Alternate Function registers *\/\n\n        s->gafr[bank * 2] = value;\n\n        break;\n\n\n\n    case GAFR_U:\t\/* GPIO Alternate Function registers *\/\n\n        s->gafr[bank * 2 + 1] = value;\n\n        break;\n\n\n\n    case GEDR:\t\t\/* GPIO Edge Detect Status registers *\/\n\n        s->status[bank] &= ~value;\n\n        pxa2xx_gpio_irq_update(s);\n\n        break;\n\n\n\n    default:\n\n        hw_error(\"%s: Bad offset \" REG_FMT \"\\n\", __FUNCTION__, offset);\n\n    }\n\n}\n","target":1,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":318724,"func":"test_opts_range_unvisited(void)\n\n{\n\n    intList *list = NULL;\n\n    intList *tail;\n\n    QemuOpts *opts;\n\n    Visitor *v;\n\n\n\n    opts = qemu_opts_parse(qemu_find_opts(\"userdef\"), \"ilist=0-2\", false,\n\n                           &error_abort);\n\n\n\n    v = opts_visitor_new(opts);\n\n\n\n    visit_start_struct(v, NULL, NULL, 0, &error_abort);\n\n\n\n    \/* Would be simpler if the visitor genuinely supported virtual walks *\/\n\n    visit_start_list(v, \"ilist\", (GenericList **)&list, sizeof(*list),\n\n                     &error_abort);\n\n    tail = list;\n\n    visit_type_int(v, NULL, &tail->value, &error_abort);\n\n    g_assert_cmpint(tail->value, ==, 0);\n\n    tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));\n\n    g_assert(tail);\n\n    visit_type_int(v, NULL, &tail->value, &error_abort);\n\n    g_assert_cmpint(tail->value, ==, 1);\n\n    tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));\n\n    g_assert(tail);\n\n    visit_check_list(v, &error_abort); \/* BUG: unvisited tail not reported *\/\n\n    visit_end_list(v, (void **)&list);\n\n\n\n    visit_check_struct(v, &error_abort);\n\n    visit_end_struct(v, NULL);\n\n\n\n    qapi_free_intList(list);\n\n    visit_free(v);\n\n    qemu_opts_del(opts);\n\n}\n","target":1,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":63615,"func":"int main(int argc,char* argv[]){\n\n    int i, j;\n\n    uint64_t sse=0;\n\n    uint64_t dev;\n\n    FILE *f[2];\n\n    uint8_t buf[2][SIZE];\n\n    uint64_t psnr;\n\n    int len= argc<4 ? 1 : atoi(argv[3]);\n\n    int64_t max= (1<<(8*len))-1;\n\n    int shift= argc<5 ? 0 : atoi(argv[4]);\n\n    int skip_bytes = argc<6 ? 0 : atoi(argv[5]);\n\n\n\n    if(argc<3){\n\n        printf(\"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\\n\");\n\n        printf(\"For WAV files use the following:\\n\");\n\n        printf(\".\/tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\\n\");\n\n        return -1;\n\n    }\n\n\n\n    f[0]= fopen(argv[1], \"rb\");\n\n    f[1]= fopen(argv[2], \"rb\");\n\n    if(!f[0] || !f[1]){\n\n        fprintf(stderr, \"Could not open input files.\\n\");\n\n        return -1;\n\n    }\n\n    fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET);\n\n\n\n    fseek(f[0],skip_bytes,SEEK_CUR);\n\n    fseek(f[1],skip_bytes,SEEK_CUR);\n\n\n\n    for(i=0;;){\n\n        if( fread(buf[0], SIZE, 1, f[0]) != 1) break;\n\n        if( fread(buf[1], SIZE, 1, f[1]) != 1) break;\n\n\n\n        for(j=0; j<SIZE; i++,j++){\n\n            int64_t a= buf[0][j];\n\n            int64_t b= buf[1][j];\n\n            if(len==2){\n\n                a= (int16_t)(a | (buf[0][++j]<<8));\n\n                b= (int16_t)(b | (buf[1][  j]<<8));\n\n            }\n\n            sse += (a-b) * (a-b);\n\n        }\n\n    }\n\n\n\n    if(!i) i=1;\n\n    dev= int_sqrt( ((sse\/i)*F*F) + (((sse%i)*F*F) + i\/2)\/i );\n\n    if(sse)\n\n        psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) \/ (1LL<<32);\n\n    else\n\n        psnr= 100*F-1; \/\/floating point free infinity :)\n\n\n\n    printf(\"stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\\n\",\n\n        (int)(dev\/F), (int)(dev%F),\n\n        (int)(psnr\/F), (int)(psnr%F),\n\n        i*len);\n\n    return 0;\n\n}\n","target":0,"code_token_length":657,"total_token_length":893,"max_tokens_setting":1024}
+{"idx":364380,"func":"static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)\n{\n\tstruct dhcp_packet packet;\n\n\/*\n * RFC 2131 4.3.2 DHCPREQUEST message\n * ...\n * DHCPREQUEST generated during RENEWING state:\n *\n * 'server identifier' MUST NOT be filled in, 'requested IP address'\n * option MUST NOT be filled in, 'ciaddr' MUST be filled in with\n * client's IP address. In this situation, the client is completely\n * configured, and is trying to extend its lease. This message will\n * be unicast, so no relay agents will be involved in its\n * transmission.  Because 'giaddr' is therefore not filled in, the\n * DHCP server will trust the value in 'ciaddr', and use it when\n * replying to the client.\n *\/\n\t\/* Fill in: op, htype, hlen, cookie, chaddr fields,\n\t * random xid field (we override it below),\n\t * client-id option (unless -C), message type option:\n\t *\/\n\tinit_packet(&packet, DHCPREQUEST);\n\n\tpacket.xid = xid;\n\tpacket.ciaddr = ciaddr;\n\n\t\/* Add options: maxsize,\n\t * optionally: hostname, fqdn, vendorclass,\n\t * \"param req\" option according to -O, and options specified with -x\n\t *\/\n\tadd_client_options(&packet);\n\n\tbb_info_msg(\"Sending renew...\");\n\tif (server)\n\t\treturn udhcp_send_kernel_packet(&packet,\n\t\t\tciaddr, CLIENT_PORT,\n\t\t\tserver, SERVER_PORT);\n\treturn raw_bcast_from_client_config_ifindex(&packet);\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":377591,"func":"static void ide_sector_write_cb(void *opaque, int ret)\n{\n    IDEState *s = opaque;\n    int n;\n\n    bdrv_acct_done(s->bs, &s->acct);\n\n    s->pio_aiocb = NULL;\n    s->status &= ~BUSY_STAT;\n\n    if (ret != 0) {\n        if (ide_handle_rw_error(s, -ret, BM_STATUS_PIO_RETRY)) {\n            return;\n        }\n    }\n\n    n = s->nsector;\n    if (n > s->req_nb_sectors) {\n        n = s->req_nb_sectors;\n    }\n    s->nsector -= n;\n    if (s->nsector == 0) {\n        \/* no more sectors to write *\/\n        ide_transfer_stop(s);\n    } else {\n        int n1 = s->nsector;\n        if (n1 > s->req_nb_sectors) {\n            n1 = s->req_nb_sectors;\n        }\n        ide_transfer_start(s, s->io_buffer, n1 * BDRV_SECTOR_SIZE,\n                           ide_sector_write);\n    }\n    ide_set_sector(s, ide_get_sector(s) + n);\n\n    if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {\n        \/* It seems there is a bug in the Windows 2000 installer HDD\n           IDE driver which fills the disk with empty logs when the\n           IDE write IRQ comes too early. This hack tries to correct\n           that at the expense of slower write performances. Use this\n           option _only_ to install Windows 2000. You must disable it\n           for normal use. *\/\n        timer_mod(s->sector_write_timer,\n                       qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() \/ 1000));\n    } else {\n        ide_set_irq(s->bus);\n    }\n}","target":0,"code_token_length":403,"total_token_length":639,"max_tokens_setting":1024}
+{"idx":454755,"func":"intrusive_ptr<Expression> ExpressionDateFromString::parse(ExpressionContext* const expCtx,\n                                                          BSONElement expr,\n                                                          const VariablesParseState& vps) {\n\n    uassert(40540,\n            str::stream() << \"$dateFromString only supports an object as an argument, found: \"\n                          << typeName(expr.type()),\n            expr.type() == BSONType::Object);\n\n    BSONElement dateStringElem, timeZoneElem, formatElem, onNullElem, onErrorElem;\n\n    const BSONObj args = expr.embeddedObject();\n    for (auto&& arg : args) {\n        auto field = arg.fieldNameStringData();\n\n        if (field == \"format\"_sd) {\n            formatElem = arg;\n        } else if (field == \"dateString\"_sd) {\n            dateStringElem = arg;\n        } else if (field == \"timezone\"_sd) {\n            timeZoneElem = arg;\n        } else if (field == \"onNull\"_sd) {\n            onNullElem = arg;\n        } else if (field == \"onError\"_sd) {\n            onErrorElem = arg;\n        } else {\n            uasserted(40541,\n                      str::stream()\n                          << \"Unrecognized argument to $dateFromString: \" << arg.fieldName());\n        }\n    }\n\n    uassert(40542, \"Missing 'dateString' parameter to $dateFromString\", dateStringElem);\n\n    return new ExpressionDateFromString(\n        expCtx,\n        parseOperand(expCtx, dateStringElem, vps),\n        timeZoneElem ? parseOperand(expCtx, timeZoneElem, vps) : nullptr,\n        formatElem ? parseOperand(expCtx, formatElem, vps) : nullptr,\n        onNullElem ? parseOperand(expCtx, onNullElem, vps) : nullptr,\n        onErrorElem ? parseOperand(expCtx, onErrorElem, vps) : nullptr);\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":378599,"func":"static void dns_udp_call_loop(struct tevent_req *subreq)\n{\n\tstruct dns_udp_socket *sock = tevent_req_callback_data(subreq,\n\t\t\t\t      struct dns_udp_socket);\n\tstruct dns_server *dns = sock->dns_socket->dns;\n\tstruct dns_udp_call *call;\n\tuint8_t *buf;\n\tssize_t len;\n\tint sys_errno;\n\n\tcall = talloc(sock, struct dns_udp_call);\n\tif (call == NULL) {\n\t\ttalloc_free(call);\n\t\tgoto done;\n\t}\n\tcall->sock = sock;\n\n\tlen = tdgram_recvfrom_recv(subreq, &sys_errno,\n\t\t\t\t   call, &buf, &call->src);\n\tTALLOC_FREE(subreq);\n\tif (len == -1) {\n\t\ttalloc_free(call);\n\t\tgoto done;\n\t}\n\n\tcall->in.data = buf;\n\tcall->in.length = len;\n\n\tDEBUG(10,(\"Received DNS UDP packet of length %lu from %s\\n\",\n\t\t (long)call->in.length,\n\t\t tsocket_address_string(call->src, call)));\n\n\tsubreq = dns_process_send(call, dns->task->event_ctx, dns,\n\t\t\t\t  &call->in);\n\tif (subreq == NULL) {\n\t\tTALLOC_FREE(call);\n\t\tgoto done;\n\t}\n\ttevent_req_set_callback(subreq, dns_udp_call_process_done, call);\n\ndone:\n\tsubreq = tdgram_recvfrom_send(sock,\n\t\t\t\t      sock->dns_socket->dns->task->event_ctx,\n\t\t\t\t      sock->dgram);\n\tif (subreq == NULL) {\n\t\ttask_server_terminate(sock->dns_socket->dns->task,\n\t\t\t\t      \"no memory for tdgram_recvfrom_send\",\n\t\t\t\t      true);\n\t\treturn;\n\t}\n\ttevent_req_set_callback(subreq, dns_udp_call_loop, sock);\n}","target":0,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":118543,"func":"static int usb_enumerate_device(struct usb_device *udev)\n{\n\tint err;\n\tstruct usb_hcd *hcd = bus_to_hcd(udev->bus);\n\n\tif (udev->config == NULL) {\n\t\terr = usb_get_configuration(udev);\n\t\tif (err < 0) {\n\t\t\tif (err != -ENODEV)\n\t\t\t\tdev_err(&udev->dev, \"can't read configurations, error %d\\n\",\n\t\t\t\t\t\terr);\n\t\t\treturn err;\n\t\t}\n\t}\n\n\t\/* read the standard strings and cache them if present *\/\n\tudev->product = usb_cache_string(udev, udev->descriptor.iProduct);\n\tudev->manufacturer = usb_cache_string(udev,\n\t\t\t\t\t      udev->descriptor.iManufacturer);\n\tudev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);\n\n\terr = usb_enumerate_device_otg(udev);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (IS_ENABLED(CONFIG_USB_OTG_WHITELIST) && hcd->tpl_support &&\n\t\t!is_targeted(udev)) {\n\t\t\/* Maybe it can talk to us, though we can't talk to it.\n\t\t * (Includes HNP test device.)\n\t\t *\/\n\t\tif (IS_ENABLED(CONFIG_USB_OTG) && (udev->bus->b_hnp_enable\n\t\t\t|| udev->bus->is_b_host)) {\n\t\t\terr = usb_port_suspend(udev, PMSG_AUTO_SUSPEND);\n\t\t\tif (err < 0)\n\t\t\t\tdev_dbg(&udev->dev, \"HNP fail, %d\\n\", err);\n\t\t}\n\t\treturn -ENOTSUPP;\n\t}\n\n\tusb_detect_interface_quirks(udev);\n\n\treturn 0;\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":331619,"func":"static void spapr_finalize_fdt(sPAPREnvironment *spapr,\n\n                               hwaddr fdt_addr,\n\n                               hwaddr rtas_addr,\n\n                               hwaddr rtas_size)\n\n{\n\n    int ret, i;\n\n    size_t cb = 0;\n\n    char *bootlist;\n\n    void *fdt;\n\n    sPAPRPHBState *phb;\n\n\n\n    fdt = g_malloc(FDT_MAX_SIZE);\n\n\n\n    \/* open out the base tree into a temp buffer for the final tweaks *\/\n\n    _FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));\n\n\n\n    ret = spapr_populate_memory(spapr, fdt);\n\n    if (ret < 0) {\n\n        fprintf(stderr, \"couldn't setup memory nodes in fdt\\n\");\n\n        exit(1);\n\n    }\n\n\n\n    ret = spapr_populate_vdevice(spapr->vio_bus, fdt);\n\n    if (ret < 0) {\n\n        fprintf(stderr, \"couldn't setup vio devices in fdt\\n\");\n\n        exit(1);\n\n    }\n\n\n\n    QLIST_FOREACH(phb, &spapr->phbs, list) {\n\n        ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);\n\n    }\n\n\n\n    if (ret < 0) {\n\n        fprintf(stderr, \"couldn't setup PCI devices in fdt\\n\");\n\n        exit(1);\n\n    }\n\n\n\n    \/* RTAS *\/\n\n    ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);\n\n    if (ret < 0) {\n\n        fprintf(stderr, \"Couldn't set up RTAS device tree properties\\n\");\n\n    }\n\n\n\n    \/* Advertise NUMA via ibm,associativity *\/\n\n    ret = spapr_fixup_cpu_dt(fdt, spapr);\n\n    if (ret < 0) {\n\n        fprintf(stderr, \"Couldn't finalize CPU device tree properties\\n\");\n\n    }\n\n\n\n    bootlist = get_boot_devices_list(&cb, true);\n\n    if (cb && bootlist) {\n\n        int offset = fdt_path_offset(fdt, \"\/chosen\");\n\n        if (offset < 0) {\n\n            exit(1);\n\n        }\n\n        for (i = 0; i < cb; i++) {\n\n            if (bootlist[i] == '\\n') {\n\n                bootlist[i] = ' ';\n\n            }\n\n\n\n        }\n\n        ret = fdt_setprop_string(fdt, offset, \"qemu,boot-list\", bootlist);\n\n    }\n\n\n\n    if (!spapr->has_graphics) {\n\n        spapr_populate_chosen_stdout(fdt, spapr->vio_bus);\n\n    }\n\n\n\n    _FDT((fdt_pack(fdt)));\n\n\n\n    if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {\n\n        hw_error(\"FDT too big ! 0x%x bytes (max is 0x%x)\\n\",\n\n                 fdt_totalsize(fdt), FDT_MAX_SIZE);\n\n        exit(1);\n\n    }\n\n\n\n    cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));\n\n\n\n\n    g_free(fdt);\n\n}","target":1,"code_token_length":647,"total_token_length":883,"max_tokens_setting":1024}
+{"idx":78119,"func":"static GCObject **sweepgen (lua_State *L, global_State *g, GCObject **p,\n                            GCObject *limit) {\n  static const lu_byte nextage[] = {\n    G_SURVIVAL,  \/* from G_NEW *\/\n    G_OLD1,      \/* from G_SURVIVAL *\/\n    G_OLD1,      \/* from G_OLD0 *\/\n    G_OLD,       \/* from G_OLD1 *\/\n    G_OLD,       \/* from G_OLD (do not change) *\/\n    G_TOUCHED1,  \/* from G_TOUCHED1 (do not change) *\/\n    G_TOUCHED2   \/* from G_TOUCHED2 (do not change) *\/\n  };\n  int white = luaC_white(g);\n  GCObject *curr;\n  while ((curr = *p) != limit) {\n    if (iswhite(curr)) {  \/* is 'curr' dead? *\/\n      lua_assert(!isold(curr) && isdead(g, curr));\n      *p = curr->next;  \/* remove 'curr' from list *\/\n      freeobj(L, curr);  \/* erase 'curr' *\/\n    }\n    else {  \/* correct mark and age *\/\n      if (getage(curr) == G_NEW)\n        curr->marked = cast_byte((curr->marked & maskgencolors) | white);\n      setage(curr, nextage[getage(curr)]);\n      p = &curr->next;  \/* go to next element *\/\n    }\n  }\n  return p;\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":388420,"func":"void CLASS parse_gps_libraw(int base)\n{\n  unsigned entries, tag, type, len, save, c;\n\n  entries = get2();\n  if (entries > 200)\n  \treturn;\n  if (entries > 0)\n    imgdata.other.parsed_gps.gpsparsed = 1;\n  while (entries--) {\n    tiff_get(base, &tag, &type, &len, &save);\n    switch (tag) {\n    case 1:  imgdata.other.parsed_gps.latref = getc(ifp); break;\n    case 3:  imgdata.other.parsed_gps.longref = getc(ifp); break;\n    case 5:  imgdata.other.parsed_gps.altref = getc(ifp); break;\n    case 2:\n      if (len == 3)\n        FORC(3) imgdata.other.parsed_gps.latitude[c] = getreal(type);\n      break;\n    case 4:\n      if (len == 3)\n        FORC(3) imgdata.other.parsed_gps.longtitude[c] = getreal(type);\n      break;\n    case 7:\n      if (len == 3)\n        FORC(3) imgdata.other.parsed_gps.gpstimestamp[c] = getreal(type);\n      break;\n    case 6:\n      imgdata.other.parsed_gps.altitude = getreal(type);\n      break;\n    case 9: imgdata.other.parsed_gps.gpsstatus = getc(ifp); break;\n    }\n    fseek(ifp, save, SEEK_SET);\n  }\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":240862,"func":"static int piv_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)\n{\n\tpiv_private_data_t * priv = PIV_DATA(card);\n\tu8 * opts; \/*  A or M, key_ref, alg_id *\/\n\n\tLOG_FUNC_CALLED(card->ctx);\n\tsc_log(card->ctx, \"cmd=%ld ptr=%p\", cmd, ptr);\n\n\tif (priv == NULL) {\n\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);\n\t}\n\tswitch(cmd) {\n\t\tcase SC_CARDCTL_PIV_AUTHENTICATE:\n\t\t\topts = (u8 *)ptr;\n\t\t\tswitch (*opts) {\n\t\t\t\tcase 'A':\n\t\t\t\t\treturn piv_general_external_authenticate(card,\n\t\t\t\t\t\t*(opts+1), *(opts+2));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'M':\n\t\t\t\t\treturn piv_general_mutual_authenticate(card,\n\t\t\t\t\t\t*(opts+1), *(opts+2));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase SC_CARDCTL_PIV_GENERATE_KEY:\n\t\t\treturn piv_generate_key(card,\n\t\t\t\t(sc_cardctl_piv_genkey_info_t *) ptr);\n\t\t\tbreak;\n\t\tcase SC_CARDCTL_GET_SERIALNR:\n\t\t\treturn piv_get_serial_nr_from_CHUI(card, (sc_serial_number_t *) ptr);\n\t\t\tbreak;\n\t\tcase SC_CARDCTL_PIV_PIN_PREFERENCE:\n\t\t\treturn piv_get_pin_preference(card, ptr);\n\t\t\tbreak;\n\t\tcase SC_CARDCTL_PIV_OBJECT_PRESENT:\n\t\t\treturn piv_is_object_present(card, ptr);\n\t\t\tbreak;\n\t}\n\n\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);\n}\n","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":118142,"func":"void CL_RequestMotd( void ) {\n#ifdef UPDATE_SERVER_NAME\n\tchar\t\tinfo[MAX_INFO_STRING];\n\n\tif ( !cl_motd->integer ) {\n\t\treturn;\n\t}\n\tCom_Printf( \"Resolving %s\\n\", UPDATE_SERVER_NAME );\n\tif ( !NET_StringToAdr( UPDATE_SERVER_NAME, &cls.updateServer, NA_IP ) ) {\n\t\tCom_Printf( \"Couldn't resolve address\\n\" );\n\t\treturn;\n\t}\n\tcls.updateServer.port = BigShort( PORT_UPDATE );\n\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", UPDATE_SERVER_NAME,\n\t\tcls.updateServer.ip[0], cls.updateServer.ip[1],\n\t\tcls.updateServer.ip[2], cls.updateServer.ip[3],\n\t\tBigShort( cls.updateServer.port ) );\n\t\n\tinfo[0] = 0;\n\n\tCom_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), \"%i\", ((rand() << 16) ^ rand()) ^ Com_Milliseconds());\n\n\tInfo_SetValueForKey( info, \"challenge\", cls.updateChallenge );\n\tInfo_SetValueForKey( info, \"renderer\", cls.glconfig.renderer_string );\n\tInfo_SetValueForKey( info, \"version\", com_version->string );\n\n\tNET_OutOfBandPrint( NS_CLIENT, cls.updateServer, \"getmotd \\\"%s\\\"\\n\", info );\n#endif\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":31184,"func":"static const gchar * get_register_name_from_address ( guint64 addr , gboolean * is_custom_register , u3v_conv_info_t * u3v_conv_info ) {\n const gchar * address_string = NULL ;\n guint32 offset_address ;\n if ( is_custom_register != NULL ) {\n * is_custom_register = FALSE ;\n }\n if ( addr < 0x10000 ) {\n offset_address = ( guint32 ) addr ;\n address_string = try_val_to_str ( offset_address , bootstrap_register_names_abrm ) ;\n }\n if ( u3v_conv_info && u3v_conv_info -> sbrm_addr != 0 && ( addr >= u3v_conv_info -> sbrm_addr ) ) {\n offset_address = ( guint32 ) ( addr - u3v_conv_info -> sbrm_addr ) ;\n address_string = try_val_to_str ( offset_address , bootstrap_register_names_sbrm ) ;\n }\n if ( u3v_conv_info && u3v_conv_info -> sirm_addr != 0 && ( addr >= u3v_conv_info -> sirm_addr ) ) {\n offset_address = ( guint32 ) ( addr - u3v_conv_info -> sirm_addr ) ;\n address_string = try_val_to_str ( offset_address , bootstrap_register_names_sirm ) ;\n }\n if ( u3v_conv_info && u3v_conv_info -> eirm_addr != 0 && ( addr >= u3v_conv_info -> eirm_addr ) ) {\n offset_address = ( guint32 ) ( addr - u3v_conv_info -> eirm_addr ) ;\n address_string = try_val_to_str ( offset_address , bootstrap_register_names_eirm ) ;\n }\n if ( ! address_string ) {\n address_string = wmem_strdup_printf ( wmem_packet_scope ( ) , \"[Addr:0x%016\" G_GINT64_MODIFIER \"X]\" , addr ) ;\n if ( is_custom_register != NULL ) {\n * is_custom_register = TRUE ;\n }\n }\n return address_string ;\n }","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":452922,"func":"static bool torture_smb2_notify_basedir(struct torture_context *torture,\n\t\t\t\tstruct smb2_tree *tree1,\n\t\t\t\tstruct smb2_tree *tree2)\n{\n\tbool ret = true;\n\tNTSTATUS status;\n\tunion smb_notify notify;\n\tunion smb_open io;\n\tstruct smb2_handle h1;\n\tstruct smb2_request *req1;\n\n\tsmb2_deltree(tree1, BASEDIR_BAS);\n\tsmb2_util_rmdir(tree1, BASEDIR_BAS);\n\n\ttorture_comment(torture, \"TESTING CHANGE NOTIFY BASEDIR EVENTS\\n\");\n\n\t\/* get a handle on the directory *\/\n\tZERO_STRUCT(io.smb2);\n\tio.generic.level = RAW_OPEN_SMB2;\n\tio.smb2.in.create_flags = 0;\n\tio.smb2.in.desired_access = SEC_FILE_ALL;\n\tio.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;\n\tio.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;\n\tio.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ |\n\t    NTCREATEX_SHARE_ACCESS_WRITE;\n\tio.smb2.in.alloc_size = 0;\n\tio.smb2.in.create_disposition = NTCREATEX_DISP_OPEN_IF;\n\tio.smb2.in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS;\n\tio.smb2.in.security_flags = 0;\n\tio.smb2.in.fname = BASEDIR_BAS;\n\n\tstatus = smb2_create(tree1, torture, &(io.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\th1 = io.smb2.out.file.handle;\n\n\t\/* create a test file that will also be modified *\/\n\tio.smb2.in.fname = BASEDIR_BAS \"\\\\tname1\";\n\tio.smb2.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;\n\tstatus =  smb2_create(tree2, torture, &(io.smb2));\n\tCHECK_STATUS(status,NT_STATUS_OK);\n\tsmb2_util_close(tree2, io.smb2.out.file.handle);\n\n\t\/* ask for a change notify, on attribute changes. *\/\n\tZERO_STRUCT(notify.smb2);\n\tnotify.smb2.level = RAW_NOTIFY_SMB2;\n\tnotify.smb2.in.buffer_size = 1000;\n\tnotify.smb2.in.completion_filter = FILE_NOTIFY_CHANGE_ATTRIBUTES;\n\tnotify.smb2.in.file.handle = h1;\n\tnotify.smb2.in.recursive = true;\n\n\treq1 = smb2_notify_send(tree1, &(notify.smb2));\n\n\t\/* set attribute on the base dir *\/\n\tsmb2_util_setatr(tree2, BASEDIR_BAS, FILE_ATTRIBUTE_HIDDEN);\n\n\t\/* set attribute on a file to assure we receive a notification *\/\n\tsmb2_util_setatr(tree2, BASEDIR_BAS \"\\\\tname1\", FILE_ATTRIBUTE_HIDDEN);\n\tsmb_msleep(200);\n\n\t\/* check how many responses were given, expect only 1 for the file *\/\n\tstatus = smb2_notify_recv(req1, torture, &(notify.smb2));\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VAL(notify.smb2.out.num_changes, 1);\n\tCHECK_VAL(notify.smb2.out.changes[0].action, NOTIFY_ACTION_MODIFIED);\n\tCHECK_WIRE_STR(notify.smb2.out.changes[0].name, \"tname1\");\n\ndone:\n\tsmb2_deltree(tree1, BASEDIR_BAS);\n\treturn ret;\n}","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":401670,"func":"ZEND_VM_HANDLER(57, ZEND_BEGIN_SILENCE, ANY, ANY)\n{\n\tUSE_OPLINE\n\n\tZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting));\n\n\tif (EG(error_reporting)) {\n\t\tdo {\n\t\t\tEG(error_reporting) = 0;\n\t\t\tif (!EG(error_reporting_ini_entry)) {\n\t\t\t\tzval *zv = zend_hash_find_ex(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), 1);\n\t\t\t\tif (zv) {\n\t\t\t\t\tEG(error_reporting_ini_entry) = (zend_ini_entry *)Z_PTR_P(zv);\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!EG(error_reporting_ini_entry)->modified) {\n\t\t\t\tif (!EG(modified_ini_directives)) {\n\t\t\t\t\tALLOC_HASHTABLE(EG(modified_ini_directives));\n\t\t\t\t\tzend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);\n\t\t\t\t}\n\t\t\t\tif (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), EG(error_reporting_ini_entry)) != NULL)) {\n\t\t\t\t\tEG(error_reporting_ini_entry)->orig_value = EG(error_reporting_ini_entry)->value;\n\t\t\t\t\tEG(error_reporting_ini_entry)->orig_modifiable = EG(error_reporting_ini_entry)->modifiable;\n\t\t\t\t\tEG(error_reporting_ini_entry)->modified = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t} while (0);\n\t}\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":26675,"func":"static int header_bin_le ( struct archive_read * a , struct cpio * cpio , struct archive_entry * entry , size_t * namelength , size_t * name_pad ) {\n const void * h ;\n const unsigned char * header ;\n a -> archive . archive_format = ARCHIVE_FORMAT_CPIO_BIN_LE ;\n a -> archive . archive_format_name = \"cpio (little-endian binary)\" ;\n h = __archive_read_ahead ( a , bin_header_size , NULL ) ;\n if ( h == NULL ) {\n archive_set_error ( & a -> archive , 0 , \"End of file trying to read next cpio header\" ) ;\n return ( ARCHIVE_FATAL ) ;\n }\n header = ( const unsigned char * ) h ;\n archive_entry_set_dev ( entry , header [ bin_dev_offset ] + header [ bin_dev_offset + 1 ] * 256 ) ;\n archive_entry_set_ino ( entry , header [ bin_ino_offset ] + header [ bin_ino_offset + 1 ] * 256 ) ;\n archive_entry_set_mode ( entry , header [ bin_mode_offset ] + header [ bin_mode_offset + 1 ] * 256 ) ;\n archive_entry_set_uid ( entry , header [ bin_uid_offset ] + header [ bin_uid_offset + 1 ] * 256 ) ;\n archive_entry_set_gid ( entry , header [ bin_gid_offset ] + header [ bin_gid_offset + 1 ] * 256 ) ;\n archive_entry_set_nlink ( entry , header [ bin_nlink_offset ] + header [ bin_nlink_offset + 1 ] * 256 ) ;\n archive_entry_set_rdev ( entry , header [ bin_rdev_offset ] + header [ bin_rdev_offset + 1 ] * 256 ) ;\n archive_entry_set_mtime ( entry , le4 ( header + bin_mtime_offset ) , 0 ) ;\n * namelength = header [ bin_namesize_offset ] + header [ bin_namesize_offset + 1 ] * 256 ;\n * name_pad = * namelength & 1 ;\n cpio -> entry_bytes_remaining = le4 ( header + bin_filesize_offset ) ;\n archive_entry_set_size ( entry , cpio -> entry_bytes_remaining ) ;\n cpio -> entry_padding = cpio -> entry_bytes_remaining & 1 ;\n __archive_read_consume ( a , bin_header_size ) ;\n return ( ARCHIVE_OK ) ;\n }","target":0,"code_token_length":502,"total_token_length":738,"max_tokens_setting":1024}
+{"idx":48001,"func":"static int init_dimensions(H264Context *h)\n{\n    int width  = h->width  - (h->sps.crop_right + h->sps.crop_left);\n    int height = h->height - (h->sps.crop_top   + h->sps.crop_bottom);\n    av_assert0(h->sps.crop_right + h->sps.crop_left < (unsigned)h->width);\n    av_assert0(h->sps.crop_top + h->sps.crop_bottom < (unsigned)h->height);\n\n    \/* handle container cropping *\/\n    if (!h->sps.crop &&\n        FFALIGN(h->avctx->width,  16) == h->width &&\n        FFALIGN(h->avctx->height, 16) == h->height) {\n        width  = h->avctx->width;\n        height = h->avctx->height;\n    }\n\n    if (width <= 0 || height <= 0) {\n        av_log(h->avctx, AV_LOG_ERROR, \"Invalid cropped dimensions: %dx%d.\\n\",\n               width, height);\n        if (h->avctx->err_recognition & AV_EF_EXPLODE)\n            return AVERROR_INVALIDDATA;\n\n        av_log(h->avctx, AV_LOG_WARNING, \"Ignoring cropping information.\\n\");\n        h->sps.crop_bottom = h->sps.crop_top = h->sps.crop_right = h->sps.crop_left = 0;\n        h->sps.crop        = 0;\n\n        width  = h->width;\n        height = h->height;\n    }\n\n    h->avctx->coded_width  = h->width;\n    h->avctx->coded_height = h->height;\n    h->avctx->width        = width;\n    h->avctx->height       = height;\n\n    return 0;\n}","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":291511,"func":"static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,\n\t\t\t  int addr_len)\n{\n\tstruct sockaddr_iucv *sa = (struct sockaddr_iucv *) addr;\n\tstruct sock *sk = sock->sk;\n\tstruct iucv_sock *iucv;\n\tint err = 0;\n\tstruct net_device *dev;\n\tchar uid[9];\n\n\t\/* Verify the input sockaddr *\/\n\tif (!addr || addr->sa_family != AF_IUCV)\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\tif (sk->sk_state != IUCV_OPEN) {\n\t\terr = -EBADFD;\n\t\tgoto done;\n\t}\n\n\twrite_lock_bh(&iucv_sk_list.lock);\n\n\tiucv = iucv_sk(sk);\n\tif (__iucv_get_sock_by_name(sa->siucv_name)) {\n\t\terr = -EADDRINUSE;\n\t\tgoto done_unlock;\n\t}\n\tif (iucv->path)\n\t\tgoto done_unlock;\n\n\t\/* Bind the socket *\/\n\tif (pr_iucv)\n\t\tif (!memcmp(sa->siucv_user_id, iucv_userid, 8))\n\t\t\tgoto vm_bind; \/* VM IUCV transport *\/\n\n\t\/* try hiper transport *\/\n\tmemcpy(uid, sa->siucv_user_id, sizeof(uid));\n\tASCEBC(uid, 8);\n\trcu_read_lock();\n\tfor_each_netdev_rcu(&init_net, dev) {\n\t\tif (!memcmp(dev->perm_addr, uid, 8)) {\n\t\t\tmemcpy(iucv->src_name, sa->siucv_name, 8);\n\t\t\tmemcpy(iucv->src_user_id, sa->siucv_user_id, 8);\n\t\t\tsk->sk_bound_dev_if = dev->ifindex;\n\t\t\tiucv->hs_dev = dev;\n\t\t\tdev_hold(dev);\n\t\t\tsk->sk_state = IUCV_BOUND;\n\t\t\tiucv->transport = AF_IUCV_TRANS_HIPER;\n\t\t\tif (!iucv->msglimit)\n\t\t\t\tiucv->msglimit = IUCV_HIPER_MSGLIM_DEFAULT;\n\t\t\trcu_read_unlock();\n\t\t\tgoto done_unlock;\n\t\t}\n\t}\n\trcu_read_unlock();\nvm_bind:\n\tif (pr_iucv) {\n\t\t\/* use local userid for backward compat *\/\n\t\tmemcpy(iucv->src_name, sa->siucv_name, 8);\n\t\tmemcpy(iucv->src_user_id, iucv_userid, 8);\n\t\tsk->sk_state = IUCV_BOUND;\n\t\tiucv->transport = AF_IUCV_TRANS_IUCV;\n\t\tif (!iucv->msglimit)\n\t\t\tiucv->msglimit = IUCV_QUEUELEN_DEFAULT;\n\t\tgoto done_unlock;\n\t}\n\t\/* found no dev to bind *\/\n\terr = -ENODEV;\ndone_unlock:\n\t\/* Release the socket list lock *\/\n\twrite_unlock_bh(&iucv_sk_list.lock);\ndone:\n\trelease_sock(sk);\n\treturn err;\n}","target":0,"code_token_length":620,"total_token_length":856,"max_tokens_setting":1024}
+{"idx":265952,"func":"static int packet_getsockopt(struct socket *sock, int level, int optname,\n\t\t\t     char __user *optval, int __user *optlen)\n{\n\tint len;\n\tint val, lv = sizeof(val);\n\tstruct sock *sk = sock->sk;\n\tstruct packet_sock *po = pkt_sk(sk);\n\tvoid *data = &val;\n\tunion tpacket_stats_u st;\n\n\tif (level != SOL_PACKET)\n\t\treturn -ENOPROTOOPT;\n\n\tif (get_user(len, optlen))\n\t\treturn -EFAULT;\n\n\tif (len < 0)\n\t\treturn -EINVAL;\n\n\tswitch (optname) {\n\tcase PACKET_STATISTICS:\n\t\tspin_lock_bh(&sk->sk_receive_queue.lock);\n\t\tmemcpy(&st, &po->stats, sizeof(st));\n\t\tmemset(&po->stats, 0, sizeof(po->stats));\n\t\tspin_unlock_bh(&sk->sk_receive_queue.lock);\n\n\t\tif (po->tp_version == TPACKET_V3) {\n\t\t\tlv = sizeof(struct tpacket_stats_v3);\n\t\t\tst.stats3.tp_packets += st.stats3.tp_drops;\n\t\t\tdata = &st.stats3;\n\t\t} else {\n\t\t\tlv = sizeof(struct tpacket_stats);\n\t\t\tst.stats1.tp_packets += st.stats1.tp_drops;\n\t\t\tdata = &st.stats1;\n\t\t}\n\n\t\tbreak;\n\tcase PACKET_AUXDATA:\n\t\tval = po->auxdata;\n\t\tbreak;\n\tcase PACKET_ORIGDEV:\n\t\tval = po->origdev;\n\t\tbreak;\n\tcase PACKET_VNET_HDR:\n\t\tval = po->has_vnet_hdr;\n\t\tbreak;\n\tcase PACKET_VERSION:\n\t\tval = po->tp_version;\n\t\tbreak;\n\tcase PACKET_HDRLEN:\n\t\tif (len > sizeof(int))\n\t\t\tlen = sizeof(int);\n\t\tif (copy_from_user(&val, optval, len))\n\t\t\treturn -EFAULT;\n\t\tswitch (val) {\n\t\tcase TPACKET_V1:\n\t\t\tval = sizeof(struct tpacket_hdr);\n\t\t\tbreak;\n\t\tcase TPACKET_V2:\n\t\t\tval = sizeof(struct tpacket2_hdr);\n\t\t\tbreak;\n\t\tcase TPACKET_V3:\n\t\t\tval = sizeof(struct tpacket3_hdr);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbreak;\n\tcase PACKET_RESERVE:\n\t\tval = po->tp_reserve;\n\t\tbreak;\n\tcase PACKET_LOSS:\n\t\tval = po->tp_loss;\n\t\tbreak;\n\tcase PACKET_TIMESTAMP:\n\t\tval = po->tp_tstamp;\n\t\tbreak;\n\tcase PACKET_FANOUT:\n\t\tval = (po->fanout ?\n\t\t       ((u32)po->fanout->id |\n\t\t\t((u32)po->fanout->type << 16) |\n\t\t\t((u32)po->fanout->flags << 24)) :\n\t\t       0);\n\t\tbreak;\n\tcase PACKET_TX_HAS_OFF:\n\t\tval = po->tp_tx_has_off;\n\t\tbreak;\n\tdefault:\n\t\treturn -ENOPROTOOPT;\n\t}\n\n\tif (len > lv)\n\t\tlen = lv;\n\tif (put_user(len, optlen))\n\t\treturn -EFAULT;\n\tif (copy_to_user(optval, data, len))\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":326094,"func":"static av_cold int peak_init_writer(AVFormatContext *s)\n\n{\n\n    WAVMuxContext *wav = s->priv_data;\n\n    AVCodecContext *enc = s->streams[0]->codec;\n\n\n\n    if (enc->codec_id != AV_CODEC_ID_PCM_S8 &&\n\n        enc->codec_id != AV_CODEC_ID_PCM_S16LE &&\n\n        enc->codec_id != AV_CODEC_ID_PCM_U8 &&\n\n        enc->codec_id != AV_CODEC_ID_PCM_U16LE) {\n\n        av_log(s, AV_LOG_ERROR, \"%s codec not supported for Peak Chunk\\n\",\n\n               s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : \"NONE\");\n\n        return -1;\n\n    }\n\n\n\n    wav->peak_bps = av_get_bits_per_sample(enc->codec_id) \/ 8;\n\n\n\n    if (wav->peak_bps == 1 && wav->peak_format == PEAK_FORMAT_UINT16) {\n\n        av_log(s, AV_LOG_ERROR,\n\n               \"Writing 16 bit peak for 8 bit audio does not make sense\\n\");\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    wav->peak_maxpos = av_mallocz(enc->channels * sizeof(*wav->peak_maxpos));\n\n    if (!wav->peak_maxpos)\n\n        goto nomem;\n\n    wav->peak_maxneg = av_mallocz(enc->channels * sizeof(*wav->peak_maxneg));\n\n    if (!wav->peak_maxneg)\n\n        goto nomem;\n\n\n\n    wav->peak_output = av_malloc(PEAK_BUFFER_SIZE);\n\n    if (!wav->peak_output)\n\n        goto nomem;\n\n\n\n    wav->peak_outbuf_size = PEAK_BUFFER_SIZE;\n\n\n\n    return 0;\n\n\n\nnomem:\n\n    av_log(s, AV_LOG_ERROR, \"Out of memory\\n\");\n\n    peak_free_buffers(s);\n\n    return AVERROR(ENOMEM);\n\n}\n","target":1,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":1956,"func":"static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,\n\t\t\t\t\t      struct userfaultfd_wait_queue *ewq)\n{\n\tif (WARN_ON_ONCE(current->flags & PF_EXITING))\n\t\tgoto out;\n\n\tewq->ctx = ctx;\n\tinit_waitqueue_entry(&ewq->wq, current);\n\n\tspin_lock(&ctx->event_wqh.lock);\n\t\/*\n\t * After the __add_wait_queue the uwq is visible to userland\n\t * through poll\/read().\n\t *\/\n\t__add_wait_queue(&ctx->event_wqh, &ewq->wq);\n\tfor (;;) {\n\t\tset_current_state(TASK_KILLABLE);\n\t\tif (ewq->msg.event == 0)\n\t\t\tbreak;\n\t\tif (ACCESS_ONCE(ctx->released) ||\n\t\t    fatal_signal_pending(current)) {\n\t\t\t__remove_wait_queue(&ctx->event_wqh, &ewq->wq);\n\t\t\tif (ewq->msg.event == UFFD_EVENT_FORK) {\n\t\t\t\tstruct userfaultfd_ctx *new;\n\n\t\t\t\tnew = (struct userfaultfd_ctx *)\n\t\t\t\t\t(unsigned long)\n\t\t\t\t\tewq->msg.arg.reserved.reserved1;\n\n\t\t\t\tuserfaultfd_ctx_put(new);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tspin_unlock(&ctx->event_wqh.lock);\n\n\t\twake_up_poll(&ctx->fd_wqh, POLLIN);\n\t\tschedule();\n\n\t\tspin_lock(&ctx->event_wqh.lock);\n\t}\n\t__set_current_state(TASK_RUNNING);\n\tspin_unlock(&ctx->event_wqh.lock);\n\n\t\/*\n\t * ctx may go away after this if the userfault pseudo fd is\n\t * already released.\n\t *\/\nout:\n\tuserfaultfd_ctx_put(ctx);\n}","target":1,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":124528,"func":"static int fill_note_info(struct elfhdr *elf, int phdrs,\n\t\t\t  struct elf_note_info *info,\n\t\t\t  long signr, struct pt_regs *regs)\n{\n\tstruct list_head *t;\n\n\tif (!elf_note_info_init(info))\n\t\treturn 0;\n\n\tif (signr) {\n\t\tstruct core_thread *ct;\n\t\tstruct elf_thread_status *ets;\n\n\t\tfor (ct = current->mm->core_state->dumper.next;\n\t\t\t\t\t\tct; ct = ct->next) {\n\t\t\tets = kzalloc(sizeof(*ets), GFP_KERNEL);\n\t\t\tif (!ets)\n\t\t\t\treturn 0;\n\n\t\t\tets->thread = ct->task;\n\t\t\tlist_add(&ets->list, &info->thread_list);\n\t\t}\n\n\t\tlist_for_each(t, &info->thread_list) {\n\t\t\tint sz;\n\n\t\t\tets = list_entry(t, struct elf_thread_status, list);\n\t\t\tsz = elf_dump_thread_status(signr, ets);\n\t\t\tinfo->thread_status_size += sz;\n\t\t}\n\t}\n\t\/* now collect the dump for the current *\/\n\tmemset(info->prstatus, 0, sizeof(*info->prstatus));\n\tfill_prstatus(info->prstatus, current, signr);\n\telf_core_copy_regs(&info->prstatus->pr_reg, regs);\n\n\t\/* Set up header *\/\n\tfill_elf_header(elf, phdrs, ELF_ARCH, ELF_CORE_EFLAGS, ELF_OSABI);\n\n\t\/*\n\t * Set up the notes in similar form to SVR4 core dumps made\n\t * with info from their \/proc.\n\t *\/\n\n\tfill_note(info->notes + 0, \"CORE\", NT_PRSTATUS,\n\t\t  sizeof(*info->prstatus), info->prstatus);\n\tfill_psinfo(info->psinfo, current->group_leader, current->mm);\n\tfill_note(info->notes + 1, \"CORE\", NT_PRPSINFO,\n\t\t  sizeof(*info->psinfo), info->psinfo);\n\n\tinfo->numnote = 2;\n\n\tfill_auxv_note(&info->notes[info->numnote++], current->mm);\n\n\t\/* Try to dump the FPU. *\/\n\tinfo->prstatus->pr_fpvalid = elf_core_copy_task_fpregs(current, regs,\n\t\t\t\t\t\t\t       info->fpu);\n\tif (info->prstatus->pr_fpvalid)\n\t\tfill_note(info->notes + info->numnote++,\n\t\t\t  \"CORE\", NT_PRFPREG, sizeof(*info->fpu), info->fpu);\n#ifdef ELF_CORE_COPY_XFPREGS\n\tif (elf_core_copy_task_xfpregs(current, info->xfpu))\n\t\tfill_note(info->notes + info->numnote++,\n\t\t\t  \"LINUX\", ELF_CORE_XFPREG_TYPE,\n\t\t\t  sizeof(*info->xfpu), info->xfpu);\n#endif\n\n\treturn 1;\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":405329,"func":"void __init mem_init_print_info(const char *str)\n{\n\tunsigned long physpages, codesize, datasize, rosize, bss_size;\n\tunsigned long init_code_size, init_data_size;\n\n\tphyspages = get_num_physpages();\n\tcodesize = _etext - _stext;\n\tdatasize = _edata - _sdata;\n\trosize = __end_rodata - __start_rodata;\n\tbss_size = __bss_stop - __bss_start;\n\tinit_data_size = __init_end - __init_begin;\n\tinit_code_size = _einittext - _sinittext;\n\n\t\/*\n\t * Detect special cases and adjust section sizes accordingly:\n\t * 1) .init.* may be embedded into .data sections\n\t * 2) .init.text.* may be out of [__init_begin, __init_end],\n\t *    please refer to arch\/tile\/kernel\/vmlinux.lds.S.\n\t * 3) .rodata.* may be embedded into .text or .data sections.\n\t *\/\n#define adj_init_size(start, end, size, pos, adj) \\\n\tdo { \\\n\t\tif (start <= pos && pos < end && size > adj) \\\n\t\t\tsize -= adj; \\\n\t} while (0)\n\n\tadj_init_size(__init_begin, __init_end, init_data_size,\n\t\t     _sinittext, init_code_size);\n\tadj_init_size(_stext, _etext, codesize, _sinittext, init_code_size);\n\tadj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size);\n\tadj_init_size(_stext, _etext, codesize, __start_rodata, rosize);\n\tadj_init_size(_sdata, _edata, datasize, __start_rodata, rosize);\n\n#undef\tadj_init_size\n\n\tpr_info(\"Memory: %luK\/%luK available (%luK kernel code, %luK rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK cma-reserved\"\n#ifdef\tCONFIG_HIGHMEM\n\t\t\", %luK highmem\"\n#endif\n\t\t\"%s%s)\\n\",\n\t\tnr_free_pages() << (PAGE_SHIFT - 10),\n\t\tphyspages << (PAGE_SHIFT - 10),\n\t\tcodesize >> 10, datasize >> 10, rosize >> 10,\n\t\t(init_data_size + init_code_size) >> 10, bss_size >> 10,\n\t\t(physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT - 10),\n\t\ttotalcma_pages << (PAGE_SHIFT - 10),\n#ifdef\tCONFIG_HIGHMEM\n\t\ttotalhigh_pages << (PAGE_SHIFT - 10),\n#endif\n\t\tstr ? \", \" : \"\", str ? str : \"\");\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":201789,"func":"pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)\n{\n\tsc_apdu_t\tapdu;\n\tint\t\tr;\n\n\tLOG_FUNC_CALLED(card->ctx);\n\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, tag >> 8, tag);\n\tapdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;\n\tapdu.resp = buf;\n\tapdu.resplen = buf_len;\n\n\tr = sc_transmit_apdu(card, &apdu);\n\tLOG_TEST_RET(card->ctx, r, \"APDU transmit failed\");\n\n\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\n\t\/* For Gnuk card, if there is no certificate, it returns error instead of empty data.\n\t * So, for this case, we ignore error and consider success *\/\n\tif (r == SC_ERROR_DATA_OBJECT_NOT_FOUND && card->type == SC_CARD_TYPE_OPENPGP_GNUK\n        && (tag == DO_CERT || tag == DO_PRIV1 || tag == DO_PRIV2 || tag == DO_PRIV3 || tag == DO_PRIV4)) {\n\t\tr = SC_SUCCESS;\n\t\tapdu.resplen = 0;\n\t}\n\tLOG_TEST_RET(card->ctx, r, \"Card returned error\");\n\n\tLOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);\n}\n","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":292960,"func":"compile_assign_unlet(\n\tchar_u\t*var_start,\n\tlhs_T\t*lhs,\n\tint\tis_assign,\n\ttype_T\t*rhs_type,\n\tcctx_T\t*cctx)\n{\n    vartype_T\tdest_type;\n    garray_T    *stack = &cctx->ctx_type_stack;\n    int\t\trange = FALSE;\n\n    if (compile_assign_index(var_start, lhs, &range, cctx) == FAIL)\n\treturn FAIL;\n    if (is_assign && range\n\t    && lhs->lhs_type->tt_type != VAR_LIST\n\t    && lhs->lhs_type != &t_blob\n\t    && lhs->lhs_type != &t_any)\n    {\n\tsemsg(_(e_cannot_use_range_with_assignment_str), var_start);\n\treturn FAIL;\n    }\n\n    if (lhs->lhs_type == &t_any)\n    {\n\t\/\/ Index on variable of unknown type: check at runtime.\n\tdest_type = VAR_ANY;\n    }\n    else\n    {\n\tdest_type = lhs->lhs_type->tt_type;\n\tif (dest_type == VAR_DICT && range)\n\t{\n\t    emsg(e_cannot_use_range_with_dictionary);\n\t    return FAIL;\n\t}\n\tif (dest_type == VAR_DICT\n\t\t\t      && may_generate_2STRING(-1, FALSE, cctx) == FAIL)\n\t    return FAIL;\n\tif (dest_type == VAR_LIST || dest_type == VAR_BLOB)\n\t{\n\t    type_T *type;\n\n\t    if (range)\n\t    {\n\t\ttype = ((type_T **)stack->ga_data)[stack->ga_len - 2];\n\t\tif (need_type(type, &t_number,\n\t\t\t\t\t    -1, 0, cctx, FALSE, FALSE) == FAIL)\n\t\treturn FAIL;\n\t    }\n\t    type = ((type_T **)stack->ga_data)[stack->ga_len - 1];\n\t    if ((dest_type != VAR_BLOB && type != &t_special)\n\t\t    && need_type(type, &t_number,\n\t\t\t\t\t    -1, 0, cctx, FALSE, FALSE) == FAIL)\n\t\treturn FAIL;\n\t}\n    }\n\n    \/\/ Load the dict or list.  On the stack we then have:\n    \/\/ - value (for assignment, not for :unlet)\n    \/\/ - index\n    \/\/ - for [a : b] second index\n    \/\/ - variable\n    if (compile_load_lhs(lhs, var_start, rhs_type, cctx) == FAIL)\n\treturn FAIL;\n\n    if (dest_type == VAR_LIST || dest_type == VAR_DICT\n\t\t\t      || dest_type == VAR_BLOB || dest_type == VAR_ANY)\n    {\n\tif (is_assign)\n\t{\n\t    if (range)\n\t    {\n\t\tif (generate_instr_drop(cctx, ISN_STORERANGE, 4) == NULL)\n\t\t    return FAIL;\n\t    }\n\t    else\n\t    {\n\t\tisn_T\t*isn = generate_instr_drop(cctx, ISN_STOREINDEX, 3);\n\n\t\tif (isn == NULL)\n\t\t    return FAIL;\n\t\tisn->isn_arg.vartype = dest_type;\n\t    }\n\t}\n\telse if (range)\n\t{\n\t    if (generate_instr_drop(cctx, ISN_UNLETRANGE, 3) == NULL)\n\t\treturn FAIL;\n\t}\n\telse\n\t{\n\t    if (generate_instr_drop(cctx, ISN_UNLETINDEX, 2) == NULL)\n\t\treturn FAIL;\n\t}\n    }\n    else\n    {\n\temsg(_(e_indexable_type_required));\n\treturn FAIL;\n    }\n\n    return OK;\n}","target":0,"code_token_length":723,"total_token_length":959,"max_tokens_setting":1024}
+{"idx":392342,"func":"bool primality_test(const BigInt& n,\n                    RandomNumberGenerator& rng,\n                    size_t level)\n   {\n   const size_t PREF_NONCE_BITS = 128;\n\n   if(n == 2)\n      return true;\n   if(n <= 1 || n.is_even())\n      return false;\n\n   \/\/ Fast path testing for small numbers (<= 65521)\n   if(n <= PRIMES[PRIME_TABLE_SIZE-1])\n      {\n      const word num = n.word_at(0);\n\n      for(size_t i = 0; PRIMES[i]; ++i)\n         {\n         if(num == PRIMES[i])\n            return true;\n         if(num < PRIMES[i])\n            return false;\n         }\n\n      return false;\n      }\n\n   if(level > 2)\n      level = 2;\n\n   const size_t NONCE_BITS = std::min(n.bits() - 2, PREF_NONCE_BITS);\n\n   MillerRabin_Test mr(n);\n\n   if(mr.is_witness(2))\n      return false;\n\n   const size_t tests = miller_rabin_test_iterations(n.bits(), level);\n\n   for(size_t i = 0; i != tests; ++i)\n      {\n      BigInt nonce;\n      while(nonce < 2 || nonce >= (n-1))\n         nonce.randomize(rng, NONCE_BITS);\n\n      if(mr.is_witness(nonce))\n         return false;\n      }\n\n   return true;\n   }","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":17079,"func":"static cmsBool Type_Dictionary_Write ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , void * Ptr , cmsUInt32Number nItems ) {\n cmsHANDLE hDict = ( cmsHANDLE ) Ptr ;\n const cmsDICTentry * p ;\n cmsBool AnyName , AnyValue ;\n cmsUInt32Number i , Count , Length ;\n cmsUInt32Number DirectoryPos , CurrentPos , BaseOffset ;\n _cmsDICarray a ;\n if ( hDict == NULL ) return FALSE ;\n BaseOffset = io -> Tell ( io ) - sizeof ( _cmsTagBase ) ;\n Count = 0 ;\n AnyName = FALSE ;\n AnyValue = FALSE ;\n for ( p = cmsDictGetEntryList ( hDict ) ;\n p != NULL ;\n p = cmsDictNextEntry ( p ) ) {\n if ( p -> DisplayName != NULL ) AnyName = TRUE ;\n if ( p -> DisplayValue != NULL ) AnyValue = TRUE ;\n Count ++ ;\n }\n Length = 16 ;\n if ( AnyName ) Length += 8 ;\n if ( AnyValue ) Length += 8 ;\n if ( ! _cmsWriteUInt32Number ( io , Count ) ) return FALSE ;\n if ( ! _cmsWriteUInt32Number ( io , Length ) ) return FALSE ;\n DirectoryPos = io -> Tell ( io ) ;\n if ( ! AllocArray ( self -> ContextID , & a , Count , Length ) ) goto Error ;\n if ( ! WriteOffsetArray ( io , & a , Count , Length ) ) goto Error ;\n p = cmsDictGetEntryList ( hDict ) ;\n for ( i = 0 ;\n i < Count ;\n i ++ ) {\n if ( ! WriteOneWChar ( io , & a . Name , i , p -> Name , BaseOffset ) ) goto Error ;\n if ( ! WriteOneWChar ( io , & a . Value , i , p -> Value , BaseOffset ) ) goto Error ;\n if ( p -> DisplayName != NULL ) {\n if ( ! WriteOneMLUC ( self , io , & a . DisplayName , i , p -> DisplayName , BaseOffset ) ) goto Error ;\n }\n if ( p -> DisplayValue != NULL ) {\n if ( ! WriteOneMLUC ( self , io , & a . DisplayValue , i , p -> DisplayValue , BaseOffset ) ) goto Error ;\n }\n p = cmsDictNextEntry ( p ) ;\n }\n CurrentPos = io -> Tell ( io ) ;\n if ( ! io -> Seek ( io , DirectoryPos ) ) goto Error ;\n if ( ! WriteOffsetArray ( io , & a , Count , Length ) ) goto Error ;\n if ( ! io -> Seek ( io , CurrentPos ) ) goto Error ;\n FreeArray ( & a ) ;\n return TRUE ;\n Error : FreeArray ( & a ) ;\n return FALSE ;\n cmsUNUSED_PARAMETER ( nItems ) ;\n }","target":0,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":304723,"func":"static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,\n                                      unsigned char **p,\n                                      unsigned char *end )\n{\n    int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;\n    size_t  len;\n    ((void) ssl);\n\n    \/*\n     * PSK parameters:\n     *\n     * opaque psk_identity_hint<0..2^16-1>;\n     *\/\n    if( (*p) > end - 2 )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server key exchange message \"\n                                    \"(psk_identity_hint length)\" ) );\n        return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );\n    }\n    len = (*p)[0] << 8 | (*p)[1];\n    *p += 2;\n\n    if( (*p) > end - len )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server key exchange message \"\n                                    \"(psk_identity_hint length)\" ) );\n        return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );\n    }\n\n    \/*\n     * Note: we currently ignore the PKS identity hint, as we only allow one\n     * PSK to be provisionned on the client. This could be changed later if\n     * someone needs that feature.\n     *\/\n    *p += len;\n    ret = 0;\n\n    return( ret );\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":175011,"func":"dict_threshold2_params(const ref * pdict, gs_threshold2_halftone * ptp,\n                       ref * ptproc, gs_memory_t *mem)\n{\n    ref *tstring;\n    int code =\n        dict_threshold_common_params(pdict,\n                                     (gs_threshold_halftone_common *)ptp,\n                                     &tstring, ptproc);\n    int bps;\n    uint size;\n    int cw2, ch2;\n\n    if (code < 0 ||\n        (code = cw2 = dict_int_param(pdict, \"Width2\", 0, 0x7fff, 0,\n                                     &ptp->width2)) < 0 ||\n        (code = ch2 = dict_int_param(pdict, \"Height2\", 0, 0x7fff, 0,\n                                     &ptp->height2)) < 0 ||\n        (code = dict_int_param(pdict, \"BitsPerSample\", 8, 16, -1, &bps)) < 0\n        )\n        return code;\n    if ((bps != 8 && bps != 16) || cw2 != ch2 ||\n        (!cw2 && (ptp->width2 == 0 || ptp->height2 == 0))\n        )\n        return_error(gs_error_rangecheck);\n    ptp->bytes_per_sample = bps \/ 8;\n    switch (r_type(tstring)) {\n    case t_string:\n        size = r_size(tstring);\n        gs_bytestring_from_string(&ptp->thresholds, tstring->value.const_bytes,\n                                  size);\n        break;\n    case t_astruct:\n        if (gs_object_type(mem, tstring->value.pstruct) != &st_bytes)\n            return_error(gs_error_typecheck);\n        size = gs_object_size(mem, tstring->value.pstruct);\n        gs_bytestring_from_bytes(&ptp->thresholds, r_ptr(tstring, byte),\n                                 0, size);\n        break;\n    default:\n        return_error(gs_error_typecheck);\n    }\n    check_read(*tstring);\n    if (size != (ptp->width * ptp->height + ptp->width2 * ptp->height2) *\n        ptp->bytes_per_sample)\n        return_error(gs_error_rangecheck);\n    return 0;\n}\n","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":388398,"func":"int LibRaw::subtract_black_internal()\n{\n  CHECK_ORDER_LOW(LIBRAW_PROGRESS_RAW2_IMAGE);\n\n  try {\n    if(!is_phaseone_compressed() && (C.cblack[0] || C.cblack[1] || C.cblack[2] || C.cblack[3] || (C.cblack[4] && C.cblack[5]) ))\n      {\n#define BAYERC(row,col,c) imgdata.image[((row) >> IO.shrink)*S.iwidth + ((col) >> IO.shrink)][c]\n        int cblk[4],i;\n        for(i=0;i<4;i++)\n          cblk[i] = C.cblack[i];\n\n        int size = S.iheight * S.iwidth;\n#define MIN(a,b) ((a) < (b) ? (a) : (b))\n#define MAX(a,b) ((a) > (b) ? (a) : (b))\n#define LIM(x,min,max) MAX(min,MIN(x,max))\n#define CLIP(x) LIM(x,0,65535)\n        int dmax = 0;\n        if(C.cblack[4] && C.cblack[5])\n          {\n            for(i=0; i< size*4; i++)\n              {\n                int val = imgdata.image[0][i];\n                val -= C.cblack[6 + i\/4 \/ S.iwidth % C.cblack[4] * C.cblack[5] +\n\t\t\ti\/4 % S.iwidth % C.cblack[5]];\n                val -= cblk[i & 3];\n                imgdata.image[0][i] = CLIP(val);\n                if(dmax < val) dmax = val;\n              }\n          }\n        else\n          {\n            for(i=0; i< size*4; i++)\n              {\n                int val = imgdata.image[0][i];\n                val -= cblk[i & 3];\n                imgdata.image[0][i] = CLIP(val);\n                if(dmax < val) dmax = val;\n              }\n          }\n        C.data_maximum = dmax & 0xffff;\n#undef MIN\n#undef MAX\n#undef LIM\n#undef CLIP\n        C.maximum -= C.black;\n        ZERO(C.cblack); \/\/ Yeah, we used cblack[6+] values too!\n        C.black = 0;\n#undef BAYERC\n      }\n    else\n      {\n        \/\/ Nothing to Do, maximum is already calculated, black level is 0, so no change\n        \/\/ only calculate channel maximum;\n        int idx;\n        ushort *p = (ushort*)imgdata.image;\n        int dmax = 0;\n        for(idx=0;idx<S.iheight*S.iwidth*4;idx++)\n          if(dmax < p[idx]) dmax = p[idx];\n        C.data_maximum = dmax;\n      }\n    return 0;\n  }\n  catch ( LibRaw_exceptions err) {\n    EXCEPTION_HANDLER(err);\n  }\n\n}","target":0,"code_token_length":627,"total_token_length":863,"max_tokens_setting":1024}
+{"idx":255072,"func":"int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)\n{\n\tstruct hexline *hx;\n\tu8 reset;\n\tint ret,pos=0;\n\n\thx = kmalloc(sizeof(*hx), GFP_KERNEL);\n\tif (!hx)\n\t\treturn -ENOMEM;\n\n\t\/* stop the CPU *\/\n\treset = 1;\n\tif ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)\n\t\terr(\"could not stop the USB controller CPU.\");\n\n\twhile ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) {\n\t\tdeb_fw(\"writing to address 0x%04x (buffer: 0x%02x %02x)\\n\", hx->addr, hx->len, hx->chk);\n\t\tret = usb_cypress_writemem(udev, hx->addr, hx->data, hx->len);\n\n\t\tif (ret != hx->len) {\n\t\t\terr(\"error while transferring firmware (transferred size: %d, block size: %d)\",\n\t\t\t\tret, hx->len);\n\t\t\tret = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (ret < 0) {\n\t\terr(\"firmware download failed at %d with %d\",pos,ret);\n\t\tkfree(hx);\n\t\treturn ret;\n\t}\n\n\tif (ret == 0) {\n\t\t\/* restart the CPU *\/\n\t\treset = 0;\n\t\tif (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {\n\t\t\terr(\"could not restart the USB controller CPU.\");\n\t\t\tret = -EINVAL;\n\t\t}\n\t} else\n\t\tret = -EIO;\n\n\tkfree(hx);\n\n\treturn ret;\n}","target":1,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":255036,"func":"Status GetDeviceForInput(const EagerOperation& op, const EagerContext& ctx,\n                         TensorHandle* tensor_handle, Device** result) {\n  Device* cpu_device = ctx.HostCPU();\n  string device_name;\n  if (tensor_handle->Type() != TensorHandle::LOCAL) {\n    Device* device = tensor_handle->device();\n    device_name = device != nullptr ? device->name() : cpu_device->name();\n    *result = (device == nullptr ? cpu_device : device);\n  } else if (tensor_handle->dtype == DT_RESOURCE) {\n    \/\/ Use the resource's actual device because it is the device that will\n    \/\/ influence partitioning the multi-device function.\n    const Tensor* tensor;\n    \/\/ TODO(fishx): Avoid blocking here.\n    TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor));\n    const ResourceHandle& handle = tensor->flat<ResourceHandle>()(0);\n    device_name = handle.device();\n\n    Device* input_device;\n    TF_RETURN_IF_ERROR(\n        ctx.FindDeviceFromName(device_name.c_str(), &input_device));\n    *result = input_device;\n  } else {\n    Device* device = tensor_handle->device();\n    const bool is_tpu = device != nullptr && device->device_type() == \"TPU\";\n    \/\/ int32 return values can be placed on TPUs.\n    const bool use_host_memory =\n        is_tpu ? MTypeFromDTypeIntsOnDevice(tensor_handle->dtype)\n               : MTypeFromDType(tensor_handle->dtype);\n    if (use_host_memory) {\n      *result = cpu_device;\n    } else {\n      \/\/ Eager ops executing as functions should have their preferred inputs set\n      \/\/ to the op's device. This allows us to avoid expensive D2H copies if a\n      \/\/ mirror of the tensor already exists on the op's device.\n      if (!op.is_function() && device != nullptr && device != cpu_device) {\n        device = absl::get<Device*>(op.Device());\n      }\n      *result = (device == nullptr ? cpu_device : device);\n    }\n  }\n  return Status::OK();\n}","target":1,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":416909,"func":"static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct net *tgt_net = net;\n\tint h, s_h;\n\tint idx = 0, s_idx;\n\tstruct net_device *dev;\n\tstruct hlist_head *head;\n\tstruct nlattr *tb[IFLA_MAX+1];\n\tu32 ext_filter_mask = 0;\n\tconst struct rtnl_link_ops *kind_ops = NULL;\n\tunsigned int flags = NLM_F_MULTI;\n\tint master_idx = 0;\n\tint netnsid = -1;\n\tint err;\n\tint hdrlen;\n\n\ts_h = cb->args[0];\n\ts_idx = cb->args[1];\n\n\t\/* A hack to preserve kernel<->userspace interface.\n\t * The correct header is ifinfomsg. It is consistent with rtnl_getlink.\n\t * However, before Linux v3.9 the code here assumed rtgenmsg and that's\n\t * what iproute2 < v3.9.0 used.\n\t * We can detect the old iproute2. Even including the IFLA_EXT_MASK\n\t * attribute, its netlink message is shorter than struct ifinfomsg.\n\t *\/\n\thdrlen = nlmsg_len(cb->nlh) < sizeof(struct ifinfomsg) ?\n\t\t sizeof(struct rtgenmsg) : sizeof(struct ifinfomsg);\n\n\tif (nlmsg_parse(cb->nlh, hdrlen, tb, IFLA_MAX,\n\t\t\tifla_policy, NULL) >= 0) {\n\t\tif (tb[IFLA_IF_NETNSID]) {\n\t\t\tnetnsid = nla_get_s32(tb[IFLA_IF_NETNSID]);\n\t\t\ttgt_net = get_target_net(skb->sk, netnsid);\n\t\t\tif (IS_ERR(tgt_net)) {\n\t\t\t\ttgt_net = net;\n\t\t\t\tnetnsid = -1;\n\t\t\t}\n\t\t}\n\n\t\tif (tb[IFLA_EXT_MASK])\n\t\t\text_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);\n\n\t\tif (tb[IFLA_MASTER])\n\t\t\tmaster_idx = nla_get_u32(tb[IFLA_MASTER]);\n\n\t\tif (tb[IFLA_LINKINFO])\n\t\t\tkind_ops = linkinfo_to_kind_ops(tb[IFLA_LINKINFO]);\n\n\t\tif (master_idx || kind_ops)\n\t\t\tflags |= NLM_F_DUMP_FILTERED;\n\t}\n\n\tfor (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {\n\t\tidx = 0;\n\t\thead = &tgt_net->dev_index_head[h];\n\t\thlist_for_each_entry(dev, head, index_hlist) {\n\t\t\tif (link_dump_filtered(dev, master_idx, kind_ops))\n\t\t\t\tgoto cont;\n\t\t\tif (idx < s_idx)\n\t\t\t\tgoto cont;\n\t\t\terr = rtnl_fill_ifinfo(skb, dev, net,\n\t\t\t\t\t       RTM_NEWLINK,\n\t\t\t\t\t       NETLINK_CB(cb->skb).portid,\n\t\t\t\t\t       cb->nlh->nlmsg_seq, 0,\n\t\t\t\t\t       flags,\n\t\t\t\t\t       ext_filter_mask, 0, NULL,\n\t\t\t\t\t       netnsid);\n\n\t\t\tif (err < 0) {\n\t\t\t\tif (likely(skb->len))\n\t\t\t\t\tgoto out;\n\n\t\t\t\tgoto out_err;\n\t\t\t}\ncont:\n\t\t\tidx++;\n\t\t}\n\t}\nout:\n\terr = skb->len;\nout_err:\n\tcb->args[1] = idx;\n\tcb->args[0] = h;\n\tcb->seq = net->dev_base_seq;\n\tnl_dump_check_consistent(cb, nlmsg_hdr(skb));\n\tif (netnsid >= 0)\n\t\tput_net(tgt_net);\n\n\treturn err;\n}","target":0,"code_token_length":769,"total_token_length":1005,"max_tokens_setting":1024}
+{"idx":295381,"func":"static long sock_do_ioctl(struct net *net, struct socket *sock,\n\t\t\t\t unsigned int cmd, unsigned long arg)\n{\n\tint err;\n\tvoid __user *argp = (void __user *)arg;\n\n\terr = sock->ops->ioctl(sock, cmd, arg);\n\n\t\/*\n\t * If this ioctl is unknown try to hand it down\n\t * to the NIC driver.\n\t *\/\n\tif (err != -ENOIOCTLCMD)\n\t\treturn err;\n\n\tif (cmd == SIOCGIFCONF) {\n\t\tstruct ifconf ifc;\n\t\tif (copy_from_user(&ifc, argp, sizeof(struct ifconf)))\n\t\t\treturn -EFAULT;\n\t\trtnl_lock();\n\t\terr = dev_ifconf(net, &ifc, sizeof(struct ifreq));\n\t\trtnl_unlock();\n\t\tif (!err && copy_to_user(argp, &ifc, sizeof(struct ifconf)))\n\t\t\terr = -EFAULT;\n\t} else {\n\t\tstruct ifreq ifr;\n\t\tbool need_copyout;\n\t\tif (copy_from_user(&ifr, argp, sizeof(struct ifreq)))\n\t\t\treturn -EFAULT;\n\t\terr = dev_ioctl(net, cmd, &ifr, &need_copyout);\n\t\tif (!err && need_copyout)\n\t\t\tif (copy_to_user(argp, &ifr, sizeof(struct ifreq)))\n\t\t\t\treturn -EFAULT;\n\t}\n\treturn err;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":412627,"func":"pk_transaction_remove_packages (PkTransaction *transaction,\n\t\t\t\tGVariant *params,\n\t\t\t\tGDBusMethodInvocation *context)\n{\n\tgboolean ret;\n\tguint length;\n\tgchar **package_ids;\n\tgboolean allow_deps;\n\tgboolean autoremove;\n\tPkBitfield transaction_flags;\n\t_cleanup_error_free_ GError *error = NULL;\n\t_cleanup_free_ gchar *package_ids_temp = NULL;\n\t_cleanup_free_ gchar *transaction_flags_temp = NULL;\n\n\tg_return_if_fail (PK_IS_TRANSACTION (transaction));\n\tg_return_if_fail (transaction->priv->tid != NULL);\n\n\tg_variant_get (params, \"(t^a&sbb)\",\n\t\t       &transaction_flags,\n\t\t       &package_ids,\n\t\t       &allow_deps,\n\t\t       &autoremove);\n\n\tpackage_ids_temp = pk_package_ids_to_string (package_ids);\n\ttransaction_flags_temp = pk_transaction_flag_bitfield_to_string (transaction_flags);\n\tg_debug (\"RemovePackages method called: %s, %i, %i (transaction_flags: %s)\",\n\t\t package_ids_temp, allow_deps, autoremove, transaction_flags_temp);\n\n\t\/* not implemented yet *\/\n\tif (!pk_backend_is_implemented (transaction->priv->backend,\n\t\t\t\t\tPK_ROLE_ENUM_REMOVE_PACKAGES)) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_NOT_SUPPORTED,\n\t\t\t     \"RemovePackages not supported by backend\");\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* check for length sanity *\/\n\tlength = g_strv_length (package_ids);\n\tif (length > PK_TRANSACTION_MAX_PACKAGES_TO_PROCESS) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_NUMBER_OF_PACKAGES_INVALID,\n\t\t\t     \"Too many packages to process (%i\/%i)\",\n\t\t\t     length, PK_TRANSACTION_MAX_PACKAGES_TO_PROCESS);\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* check package_ids *\/\n\tret = pk_package_ids_check (package_ids);\n\tif (!ret) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_PACKAGE_ID_INVALID,\n\t\t\t     \"The package id's '%s' are not valid\", package_ids_temp);\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* save so we can run later *\/\n\ttransaction->priv->cached_transaction_flags = transaction_flags;\n\ttransaction->priv->cached_package_ids = g_strdupv (package_ids);\n\ttransaction->priv->cached_allow_deps = allow_deps;\n\ttransaction->priv->cached_autoremove = autoremove;\n\tpk_transaction_set_role (transaction, PK_ROLE_ENUM_REMOVE_PACKAGES);\n\n\t\/* this changed *\/\n\tpk_transaction_emit_property_changed (transaction,\n\t\t\t\t\t      \"TransactionFlags\",\n\t\t\t\t\t      g_variant_new_uint64 (transaction_flags));\n\n\t\/* try to get authorization *\/\n\tret = pk_transaction_obtain_authorization (transaction,\n\t\t\t\t\t\t   PK_ROLE_ENUM_REMOVE_PACKAGES,\n\t\t\t\t\t\t   &error);\n\tif (!ret) {\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\nout:\n\tpk_transaction_dbus_return (context, error);\n}","target":0,"code_token_length":648,"total_token_length":884,"max_tokens_setting":1024}
+{"idx":511315,"func":"getpattern (value, quoted, expandpat)\n     char *value;\n     int quoted, expandpat;\n{\n  char *pat, *tword;\n  WORD_LIST *l;\n#if 0\n  int i;\n#endif\n  \/* There is a problem here:  how to handle single or double quotes in the\n     pattern string when the whole expression is between double quotes?\n     POSIX.2 says that enclosing double quotes do not cause the pattern to\n     be quoted, but does that leave us a problem with @ and array[@] and their\n     expansions inside a pattern? *\/\n#if 0\n  if (expandpat && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *tword)\n    {\n      i = 0;\n      pat = string_extract_double_quoted (tword, &i, SX_STRIPDQ);\n      free (tword);\n      tword = pat;\n    }\n#endif\n\n  \/* expand_string_for_rhs () leaves WORD quoted and does not perform\n     word splitting. *\/\n  l = *value ? expand_string_for_rhs (value,\n\t\t\t\t      (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? Q_PATQUOTE : quoted,\n\t\t\t\t      (int *)NULL, (int *)NULL)\n\t     : (WORD_LIST *)0;\n  pat = string_list (l);\n  dispose_words (l);\n  if (pat)\n    {\n      tword = quote_string_for_globbing (pat, QGLOB_CVTNULL);\n      free (pat);\n      pat = tword;\n    }\n  return (pat);\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":326383,"func":"static int pick_formats(AVFilterGraph *graph)\n\n{\n\n    int i, j, ret;\n\n    int change;\n\n\n\n    do{\n\n        change = 0;\n\n        for (i = 0; i < graph->filter_count; i++) {\n\n            AVFilterContext *filter = graph->filters[i];\n\n            if (filter->nb_inputs){\n\n                for (j = 0; j < filter->nb_inputs; j++){\n\n                    if(filter->inputs[j]->in_formats && filter->inputs[j]->in_formats->format_count == 1) {\n\n                        pick_format(filter->inputs[j], NULL);\n\n                        change = 1;\n\n                    }\n\n                }\n\n            }\n\n            if (filter->nb_outputs){\n\n                for (j = 0; j < filter->nb_outputs; j++){\n\n                    if(filter->outputs[j]->in_formats && filter->outputs[j]->in_formats->format_count == 1) {\n\n                        pick_format(filter->outputs[j], NULL);\n\n                        change = 1;\n\n                    }\n\n                }\n\n            }\n\n            if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) {\n\n                for (j = 0; j < filter->nb_outputs; j++) {\n\n                    if(filter->outputs[j]->format<0) {\n\n                        pick_format(filter->outputs[j], filter->inputs[0]);\n\n                        change = 1;\n\n                    }\n\n                }\n\n            }\n\n        }\n\n    }while(change);\n\n\n\n    for (i = 0; i < graph->filter_count; i++) {\n\n        AVFilterContext *filter = graph->filters[i];\n\n\n\n        for (j = 0; j < filter->nb_inputs; j++)\n\n            if ((ret = pick_format(filter->inputs[j], NULL)) < 0)\n\n                return ret;\n\n        for (j = 0; j < filter->nb_outputs; j++)\n\n            if ((ret = pick_format(filter->outputs[j], NULL)) < 0)\n\n                return ret;\n\n    }\n\n    return 0;\n\n}\n","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":77143,"func":"int IniSection::setValue (const YCPPath&p,const YCPValue&in,int what, int depth)\n{\n    string k = ip->changeCase (p->component_str (depth));\n    \/\/ Find the matching sections.\n    \/\/ If we need to recurse, choose one, creating if necessary\n    \/\/ Otherwise set all the matching values\n    \/\/  creating and deleting if the number of them does not match\n\n    if (depth + 1 < p->length())\n    {\n\t\/\/ recurse\n\tpair <IniSectionIdxIterator, IniSectionIdxIterator> r =\n\t    isections.equal_range (k);\n\tIniSectionIdxIterator xi = r.first, xe = r.second;\n\n\tIniIterator si;\n\tif (xi == xe)\n\t{\n\t    \/\/ not found, need to add it;\n\t    y2debug (\"Write: adding recursively %s to %s\", k.c_str (), p->toString().c_str());\n\n\t    IniSection s (ip, k);\n\t    container.push_back (IniContainerElement (s));\n\t    isections.insert (IniSectionIndex::value_type (k, --container.end ()));\n\n\t    si = --container.end ();\n\t}\n\telse\n\t{\n\t    \/\/ there's something, choose last\n\t    si = (--xe)->second;\n\t}\n\treturn si->s ().setValue (p, in, what, depth+1);\n    }\n    else\n    {\n\t\/\/ bottom level\n\treturn setMyValue (p, in, what, depth);\n    }\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":162165,"func":"default_class_from_mono_type (MonoType *type)\n{\n\tswitch (type->type) {\n\tcase MONO_TYPE_OBJECT:\n\t\treturn mono_defaults.object_class;\n\tcase MONO_TYPE_VOID:\n\t\treturn mono_defaults.void_class;\n\tcase MONO_TYPE_BOOLEAN:\n\t\treturn mono_defaults.boolean_class;\n\tcase MONO_TYPE_CHAR:\n\t\treturn mono_defaults.char_class;\n\tcase MONO_TYPE_I1:\n\t\treturn mono_defaults.sbyte_class;\n\tcase MONO_TYPE_U1:\n\t\treturn mono_defaults.byte_class;\n\tcase MONO_TYPE_I2:\n\t\treturn mono_defaults.int16_class;\n\tcase MONO_TYPE_U2:\n\t\treturn mono_defaults.uint16_class;\n\tcase MONO_TYPE_I4:\n\t\treturn mono_defaults.int32_class;\n\tcase MONO_TYPE_U4:\n\t\treturn mono_defaults.uint32_class;\n\tcase MONO_TYPE_I:\n\t\treturn mono_defaults.int_class;\n\tcase MONO_TYPE_U:\n\t\treturn mono_defaults.uint_class;\n\tcase MONO_TYPE_I8:\n\t\treturn mono_defaults.int64_class;\n\tcase MONO_TYPE_U8:\n\t\treturn mono_defaults.uint64_class;\n\tcase MONO_TYPE_R4:\n\t\treturn mono_defaults.single_class;\n\tcase MONO_TYPE_R8:\n\t\treturn mono_defaults.double_class;\n\tcase MONO_TYPE_STRING:\n\t\treturn mono_defaults.string_class;\n\tdefault:\n\t\tg_warning (\"default_class_from_mono_type: implement me 0x%02x\\n\", type->type);\n\t\tg_assert_not_reached ();\n\t}\n\t\n\treturn NULL;\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":398640,"func":"gst_aac_parse_check_adts_frame (GstAacParse * aacparse,\n    const guint8 * data, const guint avail, gboolean drain,\n    guint * framesize, guint * needed_data)\n{\n  guint crc_size;\n\n  *needed_data = 0;\n\n  \/* Absolute minimum to perform the ADTS syncword,\n     layer and sampling frequency tests *\/\n  if (G_UNLIKELY (avail < 3)) {\n    *needed_data = 3;\n    return FALSE;\n  }\n\n  \/* Syncword and layer tests *\/\n  if ((data[0] == 0xff) && ((data[1] & 0xf6) == 0xf0)) {\n\n    \/* Sampling frequency test *\/\n    if (G_UNLIKELY ((data[2] & 0x3C) >> 2 == 15))\n      return FALSE;\n\n    \/* This looks like an ADTS frame header but\n       we need at least 6 bytes to proceed *\/\n    if (G_UNLIKELY (avail < 6)) {\n      *needed_data = 6;\n      return FALSE;\n    }\n\n    *framesize = gst_aac_parse_adts_get_frame_len (data);\n\n    \/* If frame has CRC, it needs 2 bytes\n       for it at the end of the header *\/\n    crc_size = (data[1] & 0x01) ? 0 : 2;\n\n    \/* CRC size test *\/\n    if (*framesize < 7 + crc_size) {\n      *needed_data = 7 + crc_size;\n      return FALSE;\n    }\n\n    \/* In EOS mode this is enough. No need to examine the data further.\n       We also relax the check when we have sync, on the assumption that\n       if we're not looking at random data, we have a much higher chance\n       to get the correct sync, and this avoids losing two frames when\n       a single bit corruption happens. *\/\n    if (drain || !GST_BASE_PARSE_LOST_SYNC (aacparse)) {\n      return TRUE;\n    }\n\n    if (*framesize + ADTS_MAX_SIZE > avail) {\n      \/* We have found a possible frame header candidate, but can't be\n         sure since we don't have enough data to check the next frame *\/\n      GST_DEBUG (\"NEED MORE DATA: we need %d, available %d\",\n          *framesize + ADTS_MAX_SIZE, avail);\n      *needed_data = *framesize + ADTS_MAX_SIZE;\n      gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),\n          *framesize + ADTS_MAX_SIZE);\n      return FALSE;\n    }\n\n    if ((data[*framesize] == 0xff) && ((data[*framesize + 1] & 0xf6) == 0xf0)) {\n      guint nextlen = gst_aac_parse_adts_get_frame_len (data + (*framesize));\n\n      GST_LOG (\"ADTS frame found, len: %d bytes\", *framesize);\n      gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),\n          nextlen + ADTS_MAX_SIZE);\n      return TRUE;\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":660,"total_token_length":896,"max_tokens_setting":1024}
+{"idx":38439,"func":"static boolean ReadComment(j_decompress_ptr jpeg_info)\n{\n  ErrorManager\n    *error_manager;\n\n  ExceptionInfo\n    *exception;\n\n  Image\n    *image;\n\n  register unsigned char\n    *p;\n\n  register ssize_t\n    i;\n\n  size_t\n    length;\n\n  StringInfo\n    *comment;\n\n  \/*\n    Determine length of comment.\n  *\/\n  error_manager=(ErrorManager *) jpeg_info->client_data;\n  exception=error_manager->exception;\n  image=error_manager->image;\n  length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8);\n  length+=GetCharacter(jpeg_info);\n  if (length <= 2)\n    return(TRUE);\n  length-=2;\n  comment=BlobToStringInfo((const void *) NULL,length);\n  if (comment == (StringInfo *) NULL)\n    {\n      (void) ThrowMagickException(exception,GetMagickModule(),\n        ResourceLimitError,\"MemoryAllocationFailed\",\"`%s'\",image->filename);\n      return(FALSE);\n    }\n  \/*\n    Read comment.\n  *\/\n  error_manager->profile=comment;\n  p=GetStringInfoDatum(comment);\n  for (i=0; i < (ssize_t) GetStringInfoLength(comment); i++)\n    *p++=(unsigned char) GetCharacter(jpeg_info);\n  *p='\\0';\n  error_manager->profile=NULL;\n  p=GetStringInfoDatum(comment);\n  (void) SetImageProperty(image,\"comment\",(const char *) p,exception);\n  comment=DestroyStringInfo(comment);\n  return(TRUE);\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":447297,"func":"struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,\n\t\t\t     struct dx_entry *entries, int levels)\n{\n\tunsigned blocksize = dir->i_sb->s_blocksize;\n\tunsigned count = dx_get_count(entries), names = 0, space = 0, i;\n\tunsigned bcount = 0;\n\tstruct buffer_head *bh;\n\tprintk(\"%i indexed blocks...\\n\", count);\n\tfor (i = 0; i < count; i++, entries++)\n\t{\n\t\text4_lblk_t block = dx_get_block(entries);\n\t\text4_lblk_t hash  = i ? dx_get_hash(entries): 0;\n\t\tu32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash;\n\t\tstruct stats stats;\n\t\tprintk(\"%s%3u:%03u hash %8x\/%8x \",levels?\"\":\"   \", i, block, hash, range);\n\t\tbh = ext4_bread(NULL,dir, block, 0);\n\t\tif (!bh || IS_ERR(bh))\n\t\t\tcontinue;\n\t\tstats = levels?\n\t\t   dx_show_entries(hinfo, dir, ((struct dx_node *) bh->b_data)->entries, levels - 1):\n\t\t   dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *)\n\t\t\tbh->b_data, blocksize, 0);\n\t\tnames += stats.names;\n\t\tspace += stats.space;\n\t\tbcount += stats.bcount;\n\t\tbrelse(bh);\n\t}\n\tif (bcount)\n\t\tprintk(KERN_DEBUG \"%snames %u, fullness %u (%u%%)\\n\",\n\t\t       levels ? \"\" : \"   \", names, space\/bcount,\n\t\t       (space\/bcount)*100\/blocksize);\n\treturn (struct stats) { names, space, bcount};\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":498765,"func":"smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,\n\t     struct cifs_sb_info *cifs_sb, struct kstatfs *buf)\n{\n\tstruct smb2_query_info_rsp *rsp;\n\tstruct smb2_fs_full_size_info *info = NULL;\n\tstruct kvec rsp_iov = {NULL, 0};\n\tint buftype = CIFS_NO_BUFFER;\n\tint rc;\n\n\n\trc = smb2_query_info_compound(xid, tcon, \"\",\n\t\t\t\t      FILE_READ_ATTRIBUTES,\n\t\t\t\t      FS_FULL_SIZE_INFORMATION,\n\t\t\t\t      SMB2_O_INFO_FILESYSTEM,\n\t\t\t\t      sizeof(struct smb2_fs_full_size_info),\n\t\t\t\t      &rsp_iov, &buftype, cifs_sb);\n\tif (rc)\n\t\tgoto qfs_exit;\n\n\trsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;\n\tbuf->f_type = SMB2_SUPER_MAGIC;\n\tinfo = (struct smb2_fs_full_size_info *)(\n\t\tle16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp);\n\trc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),\n\t\t\t       le32_to_cpu(rsp->OutputBufferLength),\n\t\t\t       &rsp_iov,\n\t\t\t       sizeof(struct smb2_fs_full_size_info));\n\tif (!rc)\n\t\tsmb2_copy_fs_info_to_kstatfs(info, buf);\n\nqfs_exit:\n\tfree_rsp_buf(buftype, rsp_iov.iov_base);\n\treturn rc;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":217191,"func":"void WebGLRenderingContextBase::Reshape(int width, int height) {\n  if (isContextLost())\n    return;\n\n  GLint buffer = 0;\n  if (IsWebGL2OrHigher()) {\n    ContextGL()->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &buffer);\n    if (buffer) {\n      ContextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);\n    }\n  }\n\n  GLint max_size = std::min(max_texture_size_, max_renderbuffer_size_);\n  GLint max_width = std::min(max_size, max_viewport_dims_[0]);\n  GLint max_height = std::min(max_size, max_viewport_dims_[1]);\n  width = Clamp(width, 1, max_width);\n  height = Clamp(height, 1, max_height);\n\n  const int kMaxArea = 4096 * 4096;\n  int current_area = width * height;\n  if (current_area > kMaxArea) {\n    float scale_factor =\n        sqrtf(static_cast<float>(kMaxArea) \/ static_cast<float>(current_area));\n    width = std::max(1, static_cast<int>(width * scale_factor));\n    height = std::max(1, static_cast<int>(height * scale_factor));\n  }\n\n  GetDrawingBuffer()->Resize(IntSize(width, height));\n\n  if (buffer) {\n    ContextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER,\n                            static_cast<GLuint>(buffer));\n  }\n}\n","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":99582,"func":"build_history_completion_array ()\n{\n  register int i, j;\n  HIST_ENTRY **hlist;\n  char **tokens;\n\n  \/* First, clear out the current dynamic history completion list. *\/\n  if (harry_size)\n    {\n      strvec_dispose (history_completion_array);\n      history_completion_array = (char **)NULL;\n      harry_size = 0;\n      harry_len = 0;\n    }\n\n  \/* Next, grovel each line of history, making each shell-sized token\n     a separate entry in the history_completion_array. *\/\n  hlist = history_list ();\n\n  if (hlist)\n    {\n      for (i = 0; hlist[i]; i++)\n\t;\n      for ( --i; i >= 0; i--)\n\t{\n\t  \/* Separate each token, and place into an array. *\/\n\t  tokens = history_tokenize (hlist[i]->line);\n\n\t  for (j = 0; tokens && tokens[j]; j++)\n\t    {\n\t      if (harry_len + 2 > harry_size)\n\t        history_completion_array = strvec_resize (history_completion_array, harry_size += 10);\n\n\t      history_completion_array[harry_len++] = tokens[j];\n\t      history_completion_array[harry_len] = (char *)NULL;\n\t    }\n\t  free (tokens);\n\t}\n\n      \/* Sort the complete list of tokens. *\/\n      if (dabbrev_expand_active == 0)\n        qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC *)strvec_strcmp);\n    }\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":422618,"func":"ews_backend_child_added (ECollectionBackend *backend,\n                         ESource *child_source)\n{\n\tESource *collection_source;\n\tconst gchar *extension_name;\n\tgboolean is_mail = FALSE;\n\n\tcollection_source = e_backend_get_source (E_BACKEND (backend));\n\n\textension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;\n\tis_mail |= e_source_has_extension (child_source, extension_name);\n\n\textension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;\n\tis_mail |= e_source_has_extension (child_source, extension_name);\n\n\textension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;\n\tis_mail |= e_source_has_extension (child_source, extension_name);\n\n\t\/* Synchronize mail-related user with the collection identity. *\/\n\textension_name = E_SOURCE_EXTENSION_AUTHENTICATION;\n\tif (is_mail && e_source_has_extension (child_source, extension_name)) {\n\t\tESourceAuthentication *auth_child_extension;\n\t\tESourceCollection *collection_extension;\n\n\t\textension_name = E_SOURCE_EXTENSION_COLLECTION;\n\t\tcollection_extension = e_source_get_extension (\n\t\t\tcollection_source, extension_name);\n\n\t\textension_name = E_SOURCE_EXTENSION_AUTHENTICATION;\n\t\tauth_child_extension = e_source_get_extension (\n\t\t\tchild_source, extension_name);\n\n\t\te_binding_bind_property (\n\t\t\tcollection_extension, \"identity\",\n\t\t\tauth_child_extension, \"user\",\n\t\t\tG_BINDING_SYNC_CREATE);\n\t}\n\n\t\/* We track EWS folders in a hash table by folder ID. *\/\n\textension_name = E_SOURCE_EXTENSION_EWS_FOLDER;\n\tif (e_source_has_extension (child_source, extension_name)) {\n\t\tESourceEwsFolder *extension;\n\t\tgchar *folder_id;\n\n\t\textension = e_source_get_extension (\n\t\t\tchild_source, extension_name);\n\t\tfolder_id = e_source_ews_folder_dup_id (extension);\n\t\tif (folder_id != NULL) {\n\t\t\tews_backend_folders_insert (\n\t\t\t\tE_EWS_BACKEND (backend),\n\t\t\t\tfolder_id, child_source);\n\t\t\tg_free (folder_id);\n\t\t}\n\t}\n\n\t\/* Chain up to parent's child_added() method. *\/\n\tE_COLLECTION_BACKEND_CLASS (e_ews_backend_parent_class)->\n\t\tchild_added (backend, child_source);\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":503887,"func":"Http::Status ConnectionImpl::dispatch(Buffer::Instance& data) {\n  \/\/ Add self to the Dispatcher's tracked object stack.\n  ScopeTrackerScopeState scope(this, connection_.dispatcher());\n  ENVOY_CONN_LOG(trace, \"parsing {} bytes\", connection_, data.length());\n  \/\/ Make sure that dispatching_ is set to false after dispatching, even when\n  \/\/ http_parser exits early with an error code.\n  Cleanup cleanup([this]() { dispatching_ = false; });\n  ASSERT(!dispatching_);\n  ASSERT(codec_status_.ok());\n  ASSERT(buffered_body_.length() == 0);\n\n  dispatching_ = true;\n  onDispatch(data);\n  if (maybeDirectDispatch(data)) {\n    return Http::okStatus();\n  }\n\n  \/\/ Always resume before dispatch.\n  parser_->resume();\n\n  ssize_t total_parsed = 0;\n  if (data.length() > 0) {\n    current_dispatching_buffer_ = &data;\n    while (data.length() > 0) {\n      auto slice = data.frontSlice();\n      dispatching_slice_already_drained_ = false;\n      auto statusor_parsed = dispatchSlice(static_cast<const char*>(slice.mem_), slice.len_);\n      if (!statusor_parsed.ok()) {\n        return statusor_parsed.status();\n      }\n      if (!dispatching_slice_already_drained_) {\n        ASSERT(statusor_parsed.value() <= slice.len_);\n        data.drain(statusor_parsed.value());\n      }\n\n      total_parsed += statusor_parsed.value();\n      if (parser_->getStatus() != ParserStatus::Success) {\n        \/\/ Parse errors trigger an exception in dispatchSlice so we are guaranteed to be paused at\n        \/\/ this point.\n        ASSERT(parser_->getStatus() == ParserStatus::Paused);\n        break;\n      }\n    }\n    current_dispatching_buffer_ = nullptr;\n    dispatchBufferedBody();\n  } else {\n    auto result = dispatchSlice(nullptr, 0);\n    if (!result.ok()) {\n      return result.status();\n    }\n  }\n  ASSERT(buffered_body_.length() == 0);\n\n  ENVOY_CONN_LOG(trace, \"parsed {} bytes\", connection_, total_parsed);\n\n  \/\/ If an upgrade has been handled and there is body data or early upgrade\n  \/\/ payload to send on, send it on.\n  maybeDirectDispatch(data);\n  return Http::okStatus();\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":62334,"func":"xfs_da_grow_inode_int(\n\tstruct xfs_da_args\t*args,\n\txfs_fileoff_t\t\t*bno,\n\tint\t\t\tcount)\n{\n\tstruct xfs_trans\t*tp = args->trans;\n\tstruct xfs_inode\t*dp = args->dp;\n\tint\t\t\tw = args->whichfork;\n\txfs_drfsbno_t\t\tnblks = dp->i_d.di_nblocks;\n\tstruct xfs_bmbt_irec\tmap, *mapp;\n\tint\t\t\tnmap, error, got, i, mapi;\n\n\t\/*\n\t * Find a spot in the file space to put the new block.\n\t *\/\n\terror = xfs_bmap_first_unused(tp, dp, count, bno, w);\n\tif (error)\n\t\treturn error;\n\n\t\/*\n\t * Try mapping it in one filesystem block.\n\t *\/\n\tnmap = 1;\n\tASSERT(args->firstblock != NULL);\n\terror = xfs_bmapi_write(tp, dp, *bno, count,\n\t\t\txfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,\n\t\t\targs->firstblock, args->total, &map, &nmap,\n\t\t\targs->flist);\n\tif (error)\n\t\treturn error;\n\n\tASSERT(nmap <= 1);\n\tif (nmap == 1) {\n\t\tmapp = ↦\n\t\tmapi = 1;\n\t} else if (nmap == 0 && count > 1) {\n\t\txfs_fileoff_t\t\tb;\n\t\tint\t\t\tc;\n\n\t\t\/*\n\t\t * If we didn't get it and the block might work if fragmented,\n\t\t * try without the CONTIG flag.  Loop until we get it all.\n\t\t *\/\n\t\tmapp = kmem_alloc(sizeof(*mapp) * count, KM_SLEEP);\n\t\tfor (b = *bno, mapi = 0; b < *bno + count; ) {\n\t\t\tnmap = MIN(XFS_BMAP_MAX_NMAP, count);\n\t\t\tc = (int)(*bno + count - b);\n\t\t\terror = xfs_bmapi_write(tp, dp, b, c,\n\t\t\t\t\txfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,\n\t\t\t\t\targs->firstblock, args->total,\n\t\t\t\t\t&mapp[mapi], &nmap, args->flist);\n\t\t\tif (error)\n\t\t\t\tgoto out_free_map;\n\t\t\tif (nmap < 1)\n\t\t\t\tbreak;\n\t\t\tmapi += nmap;\n\t\t\tb = mapp[mapi - 1].br_startoff +\n\t\t\t    mapp[mapi - 1].br_blockcount;\n\t\t}\n\t} else {\n\t\tmapi = 0;\n\t\tmapp = NULL;\n\t}\n\n\t\/*\n\t * Count the blocks we got, make sure it matches the total.\n\t *\/\n\tfor (i = 0, got = 0; i < mapi; i++)\n\t\tgot += mapp[i].br_blockcount;\n\tif (got != count || mapp[0].br_startoff != *bno ||\n\t    mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount !=\n\t    *bno + count) {\n\t\terror = XFS_ERROR(ENOSPC);\n\t\tgoto out_free_map;\n\t}\n\n\t\/* account for newly allocated blocks in reserved blocks total *\/\n\targs->total -= dp->i_d.di_nblocks - nblks;\n\nout_free_map:\n\tif (mapp != &map)\n\t\tkmem_free(mapp);\n\treturn error;\n}","target":0,"code_token_length":740,"total_token_length":976,"max_tokens_setting":1024}
+{"idx":400013,"func":"void\nlaunch_descriptor_downloads(int purpose,\n                            smartlist_t *downloadable,\n                            const routerstatus_t *source, time_t now)\n{\n  const or_options_t *options = get_options();\n  const char *descname;\n  const int fetch_microdesc = (purpose == DIR_PURPOSE_FETCH_MICRODESC);\n  int n_downloadable = smartlist_len(downloadable);\n\n  int i, n_per_request, max_dl_per_req;\n  const char *req_plural = \"\", *rtr_plural = \"\";\n  int pds_flags = PDS_RETRY_IF_NO_SERVERS;\n\n  tor_assert(fetch_microdesc || purpose == DIR_PURPOSE_FETCH_SERVERDESC);\n  descname = fetch_microdesc ? \"microdesc\" : \"routerdesc\";\n\n  if (!n_downloadable)\n    return;\n\n  if (!directory_fetches_dir_info_early(options)) {\n    if (n_downloadable >= MAX_DL_TO_DELAY) {\n      log_debug(LD_DIR,\n                \"There are enough downloadable %ss to launch requests.\",\n                descname);\n    } else {\n\n      \/* should delay *\/\n      if ((last_descriptor_download_attempted +\n          options->TestingClientMaxIntervalWithoutRequest) > now)\n        return;\n\n      if (last_descriptor_download_attempted) {\n        log_info(LD_DIR,\n                 \"There are not many downloadable %ss, but we've \"\n                 \"been waiting long enough (%d seconds). Downloading.\",\n                 descname,\n                 (int)(now-last_descriptor_download_attempted));\n      } else {\n        log_info(LD_DIR,\n                 \"There are not many downloadable %ss, but we haven't \"\n                 \"tried downloading descriptors recently. Downloading.\",\n                 descname);\n      }\n    }\n  }\n\n  if (!authdir_mode_any_nonhidserv(options)) {\n    \/* If we wind up going to the authorities, we want to only open one\n     * connection to each authority at a time, so that we don't overload\n     * them.  We do this by setting PDS_NO_EXISTING_SERVERDESC_FETCH\n     * regardless of whether we're a cache or not.\n     *\n     * Setting this flag can make initiate_descriptor_downloads() ignore\n     * requests.  We need to make sure that we do in fact call\n     * update_router_descriptor_downloads() later on, once the connections\n     * have succeeded or failed.\n     *\/\n    pds_flags |= fetch_microdesc ?\n      PDS_NO_EXISTING_MICRODESC_FETCH :\n      PDS_NO_EXISTING_SERVERDESC_FETCH;\n  }\n\n  n_per_request = CEIL_DIV(n_downloadable, MIN_REQUESTS);\n  max_dl_per_req = max_dl_per_request(options, purpose);\n\n  if (n_per_request > max_dl_per_req)\n    n_per_request = max_dl_per_req;\n\n  if (n_per_request < MIN_DL_PER_REQUEST)\n    n_per_request = MIN_DL_PER_REQUEST;\n\n  if (n_downloadable > n_per_request)\n    req_plural = rtr_plural = \"s\";\n  else if (n_downloadable > 1)\n    rtr_plural = \"s\";\n\n  log_info(LD_DIR,\n           \"Launching %d request%s for %d %s%s, %d at a time\",\n           CEIL_DIV(n_downloadable, n_per_request), req_plural,\n           n_downloadable, descname, rtr_plural, n_per_request);\n  smartlist_sort_digests(downloadable);\n  for (i=0; i < n_downloadable; i += n_per_request) {\n    initiate_descriptor_downloads(source, purpose,\n                                  downloadable, i, i+n_per_request,\n                                  pds_flags);\n  }\n  last_descriptor_download_attempted = now;","target":0,"code_token_length":757,"total_token_length":993,"max_tokens_setting":1024}
+{"idx":334047,"func":"rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,\n\n                  AVPacket *pkt, uint32_t *timestamp,\n\n                  const uint8_t *buf, int len, uint16_t rtp_seq, int flags)\n\n{\n\n    int seq = 1, res;\n\n    AVIOContext pb;\n\n\n\n    if (!rdt->rmctx)\n\n        return AVERROR(EINVAL);\n\n\n\n    if (rdt->audio_pkt_cnt == 0) {\n\n        int pos;\n\n\n\n        ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);\n\n        flags = (flags & RTP_FLAG_KEY) ? 2 : 0;\n\n        res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,\n\n                                  &seq, flags, *timestamp);\n\n        pos = avio_tell(&pb);\n\n        if (res < 0)\n\n            return res;\n\n        if (res > 0) {\n\n            if (st->codec->codec_id == AV_CODEC_ID_AAC) {\n\n                memcpy (rdt->buffer, buf + pos, len - pos);\n\n                rdt->rmctx->pb = avio_alloc_context (rdt->buffer, len - pos, 0,\n\n                                                    NULL, NULL, NULL, NULL);\n\n            }\n\n            goto get_cache;\n\n        }\n\n    } else {\n\nget_cache:\n\n        rdt->audio_pkt_cnt =\n\n            ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb,\n\n                                  st, rdt->rmst[st->index], pkt);\n\n        if (rdt->audio_pkt_cnt == 0 &&\n\n            st->codec->codec_id == AV_CODEC_ID_AAC)\n\n            av_freep(&rdt->rmctx->pb);\n\n    }\n\n    pkt->stream_index = st->index;\n\n    pkt->pts = *timestamp;\n\n\n\n    return rdt->audio_pkt_cnt > 0;\n\n}\n","target":1,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":48483,"func":"int update_dataps()\n{\n    struct timeval tv;\n    struct AP_info *ap_cur;\n    struct NA_info *na_cur;\n    int sec, usec, diff, ps;\n    float pause;\n\n    gettimeofday(&tv, NULL);\n\n    ap_cur = G.ap_end;\n\n    while( ap_cur != NULL )\n    {\n        sec = (tv.tv_sec - ap_cur->tv.tv_sec);\n        usec = (tv.tv_usec - ap_cur->tv.tv_usec);\n        pause = (((float)(sec*1000000.0f + usec))\/(1000000.0f));\n        if( pause > 2.0f )\n        {\n            diff = ap_cur->nb_data - ap_cur->nb_data_old;\n            ps = (int)(((float)diff)\/pause);\n            ap_cur->nb_dataps = ps;\n            ap_cur->nb_data_old = ap_cur->nb_data;\n            gettimeofday(&(ap_cur->tv), NULL);\n        }\n        ap_cur = ap_cur->prev;\n    }\n\n    na_cur = G.na_1st;\n\n    while( na_cur != NULL )\n    {\n        sec = (tv.tv_sec - na_cur->tv.tv_sec);\n        usec = (tv.tv_usec - na_cur->tv.tv_usec);\n        pause = (((float)(sec*1000000.0f + usec))\/(1000000.0f));\n        if( pause > 2.0f )\n        {\n            diff = na_cur->ack - na_cur->ack_old;\n            ps = (int)(((float)diff)\/pause);\n            na_cur->ackps = ps;\n            na_cur->ack_old = na_cur->ack;\n            gettimeofday(&(na_cur->tv), NULL);\n        }\n        na_cur = na_cur->next;\n    }\n    return(0);\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":138266,"func":"netsnmp_init_mib_internals(void)\n{\n    register struct tok *tp;\n    register int    b, i;\n    int             max_modc;\n\n    if (tree_head)\n        return;\n\n    \/*\n     * Set up hash list of pre-defined tokens\n     *\/\n    memset(buckets, 0, sizeof(buckets));\n    for (tp = tokens; tp->name; tp++) {\n        tp->hash = name_hash(tp->name);\n        b = BUCKET(tp->hash);\n        if (buckets[b])\n            tp->next = buckets[b];      \/* BUG ??? *\/\n        buckets[b] = tp;\n    }\n\n    \/*\n     * Initialise other internal structures\n     *\/\n\n    max_modc = sizeof(module_map) \/ sizeof(module_map[0]) - 1;\n    for (i = 0; i < max_modc; ++i)\n        module_map[i].next = &(module_map[i + 1]);\n    module_map[max_modc].next = NULL;\n    module_map_head = module_map;\n\n    memset(nbuckets, 0, sizeof(nbuckets));\n    memset(tbuckets, 0, sizeof(tbuckets));\n    memset(tclist, 0, MAXTC * sizeof(struct tc));\n    build_translation_table();\n    init_tree_roots();          \/* Set up initial roots *\/\n    \/*\n     * Relies on 'add_mibdir' having set up the modules \n     *\/\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":249602,"func":"int main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);  \/\/ Removes gtest-specific args.\n  CommandLine::Init(argc, argv);\n\n  CommandLine* cmd_line = CommandLine::ForCurrentProcess();\n  DCHECK(cmd_line);\n\n  CommandLine::SwitchMap switches = cmd_line->GetSwitches();\n  for (CommandLine::SwitchMap::const_iterator it = switches.begin();\n       it != switches.end(); ++it) {\n    if (it->first == \"test_video_data\") {\n      test_video_data = it->second.c_str();\n      continue;\n    }\n    LOG(FATAL) << \"Unexpected switch: \" << it->first << \":\" << it->second;\n  }\n#if defined(OS_WIN)\n  base::ShadowingAtExitManager at_exit_manager;\n  gfx::InitializeGLBindings(gfx::kGLImplementationEGLGLES2);\n  gfx::GLSurface::InitializeOneOff();\n  {\n    scoped_refptr<gfx::GLSurface> surface(\n        gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)));\n    scoped_refptr<gfx::GLContext> context(\n        gfx::GLContext::CreateGLContext(NULL, surface.get(),\n                                        gfx::PreferIntegratedGpu));\n    context->MakeCurrent(surface.get());\n  }\n  DXVAVideoDecodeAccelerator::PreSandboxInitialization();\n#endif  \/\/ OS_WIN\n  return RUN_ALL_TESTS();\n}\n","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":510728,"func":"bool ha_partition::setup_engine_array(MEM_ROOT *mem_root)\n{\n  uint i;\n  uchar *buff;\n  handlerton **engine_array;\n\n  DBUG_ASSERT(!m_file);\n  DBUG_ENTER(\"ha_partition::setup_engine_array\");\n  engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*));\n  if (!engine_array)\n    DBUG_RETURN(true);\n\n  buff= (uchar *) (m_file_buffer + PAR_ENGINES_OFFSET);\n  for (i= 0; i < m_tot_parts; i++)\n  {\n    engine_array[i]= ha_resolve_by_legacy_type(ha_thd(),\n                                               (enum legacy_db_type)\n                                                 *(buff + i));\n    if (!engine_array[i])\n      goto err;\n  }\n  if (!(m_engine_array= (plugin_ref*)\n        alloc_root(&m_mem_root, m_tot_parts * sizeof(plugin_ref))))\n    goto err;\n\n  for (i= 0; i < m_tot_parts; i++)\n    m_engine_array[i]= ha_lock_engine(NULL, engine_array[i]);\n\n  my_afree(engine_array);\n    \n  if (create_handlers(mem_root))\n  {\n    clear_handler_file();\n    DBUG_RETURN(true);\n  }\n\n  DBUG_RETURN(false);\n\nerr:\n  my_afree(engine_array);\n  DBUG_RETURN(true);\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":426707,"func":"\nint main(int argc, char **argv) {\n  const char *host = (argc > 1) ? argv[1] : \"\";\n  const char *port = (argc > 2) ? argv[2] : \"amqp\";\n  int err;\n\n  broker_t b = {0};\n  b.proactor = pn_proactor();\n  queues_init(&b.queues);\n  b.container_id = argv[0];\n  b.threads = 4;\n  b.ssl_domain = pn_ssl_domain(PN_SSL_MODE_SERVER);\n  err = SET_CREDENTIALS(b.ssl_domain, \"tserver\");\n  if (err) {\n    printf(\"Failed to set up server certificate: %s, private key: %s\\n\", CERTIFICATE(\"tserver\"), SSL_FILE(\"tserver-private-key.pem\"));\n  }\n  {\n  \/* Listen on addr *\/\n  char addr[PN_MAX_ADDR];\n  pn_proactor_addr(addr, sizeof(addr), host, port);\n  pn_proactor_listen(b.proactor, pn_listener(), addr, 16);\n  }\n\n  {\n  \/* Start n-1 threads *\/\n  pthread_t* threads = (pthread_t*)calloc(sizeof(pthread_t), b.threads);\n  size_t i;\n  for (i = 0; i < b.threads-1; ++i) {\n    pthread_create(&threads[i], NULL, broker_thread, &b);\n  }\n  broker_thread(&b);            \/* Use the main thread too. *\/\n  \/* Join the other threads *\/\n  for (i = 0; i < b.threads-1; ++i) {\n    pthread_join(threads[i], NULL);\n  }\n  pn_proactor_free(b.proactor);\n  free(threads);\n  pn_ssl_domain_free(b.ssl_domain);\n  return 0;\n  }","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":410863,"func":"THEME_REC *theme_load(const char *setname)\n{\n\tTHEME_REC *theme, *oldtheme;\n\tstruct stat statbuf;\n\tchar *fname, *name, *p;\n\n        name = g_strdup(setname);\n\tp = strrchr(name, '.');\n\tif (p != NULL && strcmp(p, \".theme\") == 0) {\n\t\t\/* remove the trailing .theme *\/\n                *p = '\\0';\n\t}\n\n\ttheme = theme_find(name);\n\n\t\/* check home dir *\/\n\tfname = g_strdup_printf(\"%s\/%s.theme\", get_irssi_dir(), name);\n\tif (stat(fname, &statbuf) != 0) {\n\t\t\/* check global config dir *\/\n\t\tg_free(fname);\n\t\tfname = g_strdup_printf(THEMESDIR\"\/%s.theme\", name);\n\t\tif (stat(fname, &statbuf) != 0) {\n\t\t\t\/* theme not found *\/\n\t\t\tg_free(fname);\n\t\t\tg_free(name);\n\t\t\treturn theme; \/* use the one in memory if possible *\/\n\t\t}\n\t}\n\n\tif (theme != NULL && theme->last_modify == statbuf.st_mtime) {\n\t\t\/* theme not modified, use the one already in memory *\/\n\t\tg_free(fname);\n\t\tg_free(name);\n\t\treturn theme;\n\t}\n\n        oldtheme = theme;\n\ttheme = theme_create(fname, name);\n\ttheme->last_modify = statbuf.st_mtime;\n\tif (!theme_read(theme, theme->path, NULL)) {\n                \/* error reading .theme file *\/\n\t\ttheme_destroy(theme);\n\t\ttheme = NULL;\n\t}\n\n\tif (oldtheme != NULL && theme != NULL) {\n\t\ttheme_destroy(oldtheme);\n\t\twindow_themes_update();\n\t}\n\n\tg_free(fname);\n\tg_free(name);\n\treturn theme;\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":301821,"func":"static gcry_cipher_hd_t network_get_aes256_cypher (sockent_t *se, \/* {{{ *\/\n    const void *iv, size_t iv_size, const char *username)\n{\n  gcry_error_t err;\n  gcry_cipher_hd_t *cyper_ptr;\n  unsigned char password_hash[32];\n\n  if (se->type == SOCKENT_TYPE_CLIENT)\n  {\n\t  cyper_ptr = &se->data.client.cypher;\n\t  memcpy (password_hash, se->data.client.password_hash,\n\t\t\t  sizeof (password_hash));\n  }\n  else\n  {\n\t  char *secret;\n\n\t  cyper_ptr = &se->data.server.cypher;\n\n\t  if (username == NULL)\n\t\t  return (NULL);\n\n\t  secret = fbh_get (se->data.server.userdb, username);\n\t  if (secret == NULL)\n\t\t  return (NULL);\n\n\t  gcry_md_hash_buffer (GCRY_MD_SHA256,\n\t\t\t  password_hash,\n\t\t\t  secret, strlen (secret));\n\n\t  sfree (secret);\n  }\n\n  if (*cyper_ptr == NULL)\n  {\n    err = gcry_cipher_open (cyper_ptr,\n        GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_OFB, \/* flags = *\/ 0);\n    if (err != 0)\n    {\n      ERROR (\"network plugin: gcry_cipher_open returned: %s\",\n          gcry_strerror (err));\n      *cyper_ptr = NULL;\n      return (NULL);\n    }\n  }\n  else\n  {\n    gcry_cipher_reset (*cyper_ptr);\n  }\n  assert (*cyper_ptr != NULL);\n\n  err = gcry_cipher_setkey (*cyper_ptr,\n      password_hash, sizeof (password_hash));\n  if (err != 0)\n  {\n    ERROR (\"network plugin: gcry_cipher_setkey returned: %s\",\n        gcry_strerror (err));\n    gcry_cipher_close (*cyper_ptr);\n    *cyper_ptr = NULL;\n    return (NULL);\n  }\n\n  err = gcry_cipher_setiv (*cyper_ptr, iv, iv_size);\n  if (err != 0)\n  {\n    ERROR (\"network plugin: gcry_cipher_setkey returned: %s\",\n        gcry_strerror (err));\n    gcry_cipher_close (*cyper_ptr);\n    *cyper_ptr = NULL;\n    return (NULL);\n  }\n\n  return (*cyper_ptr);\n} \/* }}} int network_get_aes256_cypher *\/","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":500318,"func":"static void do_show_obj(QPDF& pdf, Options& o, int& exit_code)\n{\n    QPDFObjectHandle obj;\n    if (o.show_trailer)\n    {\n        obj = pdf.getTrailer();\n    }\n    else\n    {\n        obj = pdf.getObjectByID(o.show_obj, o.show_gen);\n    }\n    if (obj.isStream())\n    {\n        if (o.show_raw_stream_data || o.show_filtered_stream_data)\n        {\n            bool filter = o.show_filtered_stream_data;\n            if (filter &&\n                (! obj.pipeStreamData(0, 0, qpdf_dl_all)))\n            {\n                QTC::TC(\"qpdf\", \"qpdf unable to filter\");\n                std::cerr << \"Unable to filter stream data.\"\n                          << std::endl;\n                exit_code = EXIT_ERROR;\n            }\n            else\n            {\n                QUtil::binary_stdout();\n                Pl_StdioFile out(\"stdout\", stdout);\n                obj.pipeStreamData(\n                    &out,\n                    (filter && o.normalize) ? qpdf_ef_normalize : 0,\n                    filter ? qpdf_dl_all : qpdf_dl_none);\n            }\n        }\n        else\n        {\n            std::cout\n                << \"Object is stream.  Dictionary:\" << std::endl\n                << obj.getDict().unparseResolved() << std::endl;\n        }\n    }\n    else\n    {\n        std::cout << obj.unparseResolved() << std::endl;\n    }\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":214859,"func":"static inline int build_assignment_string(smart_str *querystr, HashTable *ht, int where_cond, const char *pad, int pad_len TSRMLS_DC)\n{\n\tHashPosition pos;\n\tuint fld_len;\n\tint key_type;\n\tulong num_idx;\n\tchar *fld;\n\tchar buf[256];\n\tzval **val;\n\n\tfor (zend_hash_internal_pointer_reset_ex(ht, &pos);\n\t\t zend_hash_get_current_data_ex(ht, (void **)&val, &pos) == SUCCESS;\n\t\t zend_hash_move_forward_ex(ht, &pos)) {\n\t\t key_type = zend_hash_get_current_key_ex(ht, &fld, &fld_len, &num_idx, 0, &pos);\n\t\tif (key_type == HASH_KEY_IS_LONG) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Expects associative array for values to be inserted\");\n\t\t\treturn -1;\n\t\t}\n\t\tsmart_str_appendl(querystr, fld, fld_len - 1);\n\t\tif (where_cond && Z_TYPE_PP(val) == IS_STRING && !strcmp(Z_STRVAL_PP(val), \"NULL\")) {\n\t\t\tsmart_str_appends(querystr, \" IS \");\n\t\t} else {\n\t\t\tsmart_str_appendc(querystr, '=');\n\t\t}\n\n\t\tswitch(Z_TYPE_PP(val)) {\n\t\t\tcase IS_STRING:\n\t\t\t\tsmart_str_appendl(querystr, Z_STRVAL_PP(val), Z_STRLEN_PP(val));\n\t\t\t\tbreak;\n\t\t\tcase IS_LONG:\n\t\t\t\tsmart_str_append_long(querystr, Z_LVAL_PP(val));\n\t\t\t\tbreak;\n\t\t\tcase IS_DOUBLE:\n\t\t\t\tsmart_str_appendl(querystr, buf, MIN(snprintf(buf, sizeof(buf), \"%F\", Z_DVAL_PP(val)), sizeof(buf)-1));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t\/* should not happen *\/\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Expects scaler values other than NULL. Need to convert?\");\n\t\t\t\treturn -1;\n\t\t}\n\t\tsmart_str_appendl(querystr, pad, pad_len);\n\t}\n\tquerystr->len -= pad_len;\n\n\treturn 0;\n}\n","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":205277,"func":"error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM(\n    uint32_t immediate_data_size,\n    const volatile void* cmd_data) {\n  const volatile gles2::cmds::TraceBeginCHROMIUM& c =\n      *static_cast<const volatile gles2::cmds::TraceBeginCHROMIUM*>(cmd_data);\n  Bucket* category_bucket = GetBucket(c.category_bucket_id);\n  Bucket* name_bucket = GetBucket(c.name_bucket_id);\n  static constexpr size_t kMaxStrLen = 256;\n  if (!category_bucket || category_bucket->size() == 0 ||\n      category_bucket->size() > kMaxStrLen || !name_bucket ||\n      name_bucket->size() == 0 || name_bucket->size() > kMaxStrLen) {\n    return error::kInvalidArguments;\n  }\n\n  std::string category_name;\n  std::string trace_name;\n  if (!category_bucket->GetAsString(&category_name) ||\n      !name_bucket->GetAsString(&trace_name)) {\n    return error::kInvalidArguments;\n  }\n\n  debug_marker_manager_.PushGroup(trace_name);\n  if (!gpu_tracer_->Begin(category_name, trace_name, kTraceCHROMIUM)) {\n    LOCAL_SET_GL_ERROR(\n        GL_INVALID_OPERATION,\n        \"glTraceBeginCHROMIUM\", \"unable to create begin trace\");\n    return error::kNoError;\n  }\n  return error::kNoError;\n}\n","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":369040,"func":"xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {\n    int len = 0, l;\n    int c;\n    int count = 0;\n\n#ifdef DEBUG\n    nbParseNCNameComplex++;\n#endif\n\n    \/*\n     * Handler for more complex cases\n     *\/\n    GROW;\n    c = CUR_CHAR(l);\n    if ((c == ' ') || (c == '>') || (c == '\/') || \/* accelerators *\/\n\t(!xmlIsNameStartChar(ctxt, c) || (c == ':'))) {\n\treturn(NULL);\n    }\n\n    while ((c != ' ') && (c != '>') && (c != '\/') && \/* test bigname.xml *\/\n\t   (xmlIsNameChar(ctxt, c) && (c != ':'))) {\n\tif (count++ > XML_PARSER_CHUNK_SIZE) {\n            if ((len > XML_MAX_NAME_LENGTH) &&\n                ((ctxt->options & XML_PARSE_HUGE) == 0)) {\n                xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, \"NCName\");\n                return(NULL);\n            }\n\t    count = 0;\n\t    GROW;\n            if (ctxt->instate == XML_PARSER_EOF)\n                return(NULL);\n\t}\n\tlen += l;\n\tNEXTL(l);\n\tc = CUR_CHAR(l);\n\tif (c == 0) {\n\t    count = 0;\n\t    GROW;\n            if (ctxt->instate == XML_PARSER_EOF)\n                return(NULL);\n\t    c = CUR_CHAR(l);\n\t}\n    }\n    if ((len > XML_MAX_NAME_LENGTH) &&\n        ((ctxt->options & XML_PARSE_HUGE) == 0)) {\n        xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, \"NCName\");\n        return(NULL);\n    }\n    return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":200410,"func":"void shut_down(int code)\n{\n    int i;\n    int bytes_in = 0;\n    int bytes_out = 0;\n\n    in_shutdown = 1;\n\n    proc_cleanup();\n\n    i = 0;\n    while (backend_cached && backend_cached[i]) {\n        proxy_downserver(backend_cached[i]);\n        if (backend_cached[i]->last_result.s) {\n            free(backend_cached[i]->last_result.s);\n        }\n        free(backend_cached[i]);\n        i++;\n    }\n    if (backend_cached) free(backend_cached);\n    if (mupdate_h) mupdate_disconnect(&mupdate_h);\n\n    if (idling)\n        idle_stop(index_mboxname(imapd_index));\n\n    if (imapd_index) index_close(&imapd_index);\n\n    sync_log_done();\n    seen_done();\n    mboxkey_done();\n    mboxlist_close();\n    mboxlist_done();\n\n    quotadb_close();\n    quotadb_done();\n\n    denydb_close();\n    denydb_done();\n\n    annotatemore_close();\n    annotate_done();\n\n    idle_done();\n\n    if (config_getswitch(IMAPOPT_STATUSCACHE)) {\n        statuscache_close();\n        statuscache_done();\n    }\n\n    partlist_local_done();\n\n    if (imapd_in) {\n        \/* Flush the incoming buffer *\/\n        prot_NONBLOCK(imapd_in);\n        prot_fill(imapd_in);\n        bytes_in = prot_bytes_in(imapd_in);\n        prot_free(imapd_in);\n    }\n\n    if (imapd_out) {\n        \/* Flush the outgoing buffer *\/\n        prot_flush(imapd_out);\n        bytes_out = prot_bytes_out(imapd_out);\n        prot_free(imapd_out);\n\n        \/* one less active connection *\/\n        snmp_increment(ACTIVE_CONNECTIONS, -1);\n    }\n\n    if (config_auditlog)\n        syslog(LOG_NOTICE, \"auditlog: traffic sessionid=<%s> bytes_in=<%d> bytes_out=<%d>\",\n                           session_id(), bytes_in, bytes_out);\n\n    if (protin) protgroup_free(protin);\n\n#ifdef HAVE_SSL\n    tls_shutdown_serverengine();\n#endif\n\n    cyrus_done();\n\n    exit(code);\n}\n","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":438323,"func":"bool SegmentInfo::Write(IMkvWriter* writer) {\n  if (!writer || !muxing_app_ || !writing_app_)\n    return false;\n\n  uint64_t size = EbmlElementSize(libwebm::kMkvTimecodeScale,\n                                  static_cast<uint64>(timecode_scale_));\n  if (duration_ > 0.0)\n    size +=\n        EbmlElementSize(libwebm::kMkvDuration, static_cast<float>(duration_));\n  if (date_utc_ != LLONG_MIN)\n    size += EbmlDateElementSize(libwebm::kMkvDateUTC);\n  size += EbmlElementSize(libwebm::kMkvMuxingApp, muxing_app_);\n  size += EbmlElementSize(libwebm::kMkvWritingApp, writing_app_);\n\n  if (!WriteEbmlMasterElement(writer, libwebm::kMkvInfo, size))\n    return false;\n\n  const int64_t payload_position = writer->Position();\n  if (payload_position < 0)\n    return false;\n\n  if (!WriteEbmlElement(writer, libwebm::kMkvTimecodeScale,\n                        static_cast<uint64>(timecode_scale_)))\n    return false;\n\n  if (duration_ > 0.0) {\n    \/\/ Save for later\n    duration_pos_ = writer->Position();\n\n    if (!WriteEbmlElement(writer, libwebm::kMkvDuration,\n                          static_cast<float>(duration_)))\n      return false;\n  }\n\n  if (date_utc_ != LLONG_MIN)\n    WriteEbmlDateElement(writer, libwebm::kMkvDateUTC, date_utc_);\n\n  if (!WriteEbmlElement(writer, libwebm::kMkvMuxingApp, muxing_app_))\n    return false;\n  if (!WriteEbmlElement(writer, libwebm::kMkvWritingApp, writing_app_))\n    return false;\n\n  const int64_t stop_position = writer->Position();\n  if (stop_position < 0 ||\n      stop_position - payload_position != static_cast<int64_t>(size))\n    return false;\n\n  return true;\n}","target":0,"code_token_length":452,"total_token_length":688,"max_tokens_setting":1024}
+{"idx":463954,"func":"static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,\n                                    struct connectdata *conn, int sockindex,\n                                    const char *pinnedpubkey)\n{\n  struct ssl_connect_data *connssl = &conn->ssl[sockindex];\n  CERT_CONTEXT *pCertContextServer = NULL;\n\n  \/* Result is returned to caller *\/\n  CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;\n\n  \/* if a path wasn't specified, don't pin *\/\n  if(!pinnedpubkey)\n    return CURLE_OK;\n\n  do {\n    SECURITY_STATUS sspi_status;\n    const char *x509_der;\n    DWORD x509_der_len;\n    struct Curl_X509certificate x509_parsed;\n    struct Curl_asn1Element *pubkey;\n\n    sspi_status =\n      s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,\n                                       SECPKG_ATTR_REMOTE_CERT_CONTEXT,\n                                       &pCertContextServer);\n\n    if((sspi_status != SEC_E_OK) || (pCertContextServer == NULL)) {\n      char buffer[STRERROR_LEN];\n      failf(data, \"schannel: Failed to read remote certificate context: %s\",\n            Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));\n      break; \/* failed *\/\n    }\n\n\n    if(!(((pCertContextServer->dwCertEncodingType & X509_ASN_ENCODING) != 0) &&\n         (pCertContextServer->cbCertEncoded > 0)))\n      break;\n\n    x509_der = (const char *)pCertContextServer->pbCertEncoded;\n    x509_der_len = pCertContextServer->cbCertEncoded;\n    memset(&x509_parsed, 0, sizeof(x509_parsed));\n    if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))\n      break;\n\n    pubkey = &x509_parsed.subjectPublicKeyInfo;\n    if(!pubkey->header || pubkey->end <= pubkey->header) {\n      failf(data, \"SSL: failed retrieving public key from server certificate\");\n      break;\n    }\n\n    result = Curl_pin_peer_pubkey(data,\n                                  pinnedpubkey,\n                                  (const unsigned char *)pubkey->header,\n                                  (size_t)(pubkey->end - pubkey->header));\n    if(result) {\n      failf(data, \"SSL: public key does not match pinned public key!\");\n    }\n  } while(0);\n\n  if(pCertContextServer)\n    CertFreeCertificateContext(pCertContextServer);\n\n  return result;\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":477440,"func":"static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)\n{\n\tstruct guest_walker walker;\n\tint r;\n\tunsigned long mmu_seq;\n\tbool is_self_change_mapping;\n\n\tpgprintk(\"%s: addr %lx err %x\\n\", __func__, fault->addr, fault->error_code);\n\tWARN_ON_ONCE(fault->is_tdp);\n\n\t\/*\n\t * Look up the guest pte for the faulting address.\n\t * If PFEC.RSVD is set, this is a shadow page fault.\n\t * The bit needs to be cleared before walking guest page tables.\n\t *\/\n\tr = FNAME(walk_addr)(&walker, vcpu, fault->addr,\n\t\t\t     fault->error_code & ~PFERR_RSVD_MASK);\n\n\t\/*\n\t * The page is not mapped by the guest.  Let the guest handle it.\n\t *\/\n\tif (!r) {\n\t\tpgprintk(\"%s: guest page fault\\n\", __func__);\n\t\tif (!fault->prefetch)\n\t\t\tkvm_inject_emulated_page_fault(vcpu, &walker.fault);\n\n\t\treturn RET_PF_RETRY;\n\t}\n\n\tfault->gfn = walker.gfn;\n\tfault->slot = kvm_vcpu_gfn_to_memslot(vcpu, fault->gfn);\n\n\tif (page_fault_handle_page_track(vcpu, fault)) {\n\t\tshadow_page_table_clear_flood(vcpu, fault->addr);\n\t\treturn RET_PF_EMULATE;\n\t}\n\n\tr = mmu_topup_memory_caches(vcpu, true);\n\tif (r)\n\t\treturn r;\n\n\tvcpu->arch.write_fault_to_shadow_pgtable = false;\n\n\tis_self_change_mapping = FNAME(is_self_change_mapping)(vcpu,\n\t      &walker, fault->user, &vcpu->arch.write_fault_to_shadow_pgtable);\n\n\tif (is_self_change_mapping)\n\t\tfault->max_level = PG_LEVEL_4K;\n\telse\n\t\tfault->max_level = walker.level;\n\n\tmmu_seq = vcpu->kvm->mmu_notifier_seq;\n\tsmp_rmb();\n\n\tif (kvm_faultin_pfn(vcpu, fault, &r))\n\t\treturn r;\n\n\tif (handle_abnormal_pfn(vcpu, fault, walker.pte_access, &r))\n\t\treturn r;\n\n\t\/*\n\t * Do not change pte_access if the pfn is a mmio page, otherwise\n\t * we will cache the incorrect access into mmio spte.\n\t *\/\n\tif (fault->write && !(walker.pte_access & ACC_WRITE_MASK) &&\n\t    !is_cr0_wp(vcpu->arch.mmu) && !fault->user && fault->slot) {\n\t\twalker.pte_access |= ACC_WRITE_MASK;\n\t\twalker.pte_access &= ~ACC_USER_MASK;\n\n\t\t\/*\n\t\t * If we converted a user page to a kernel page,\n\t\t * so that the kernel can write to it when cr0.wp=0,\n\t\t * then we should prevent the kernel from executing it\n\t\t * if SMEP is enabled.\n\t\t *\/\n\t\tif (is_cr4_smep(vcpu->arch.mmu))\n\t\t\twalker.pte_access &= ~ACC_EXEC_MASK;\n\t}\n\n\tr = RET_PF_RETRY;\n\twrite_lock(&vcpu->kvm->mmu_lock);\n\n\tif (is_page_fault_stale(vcpu, fault, mmu_seq))\n\t\tgoto out_unlock;\n\n\tr = make_mmu_pages_available(vcpu);\n\tif (r)\n\t\tgoto out_unlock;\n\tr = FNAME(fetch)(vcpu, fault, &walker);\n\nout_unlock:\n\twrite_unlock(&vcpu->kvm->mmu_lock);\n\tkvm_release_pfn_clean(fault->pfn);\n\treturn r;\n}","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":352602,"func":"static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of,\n\t\t\t\t     char *buf, size_t nbytes, loff_t off,\n\t\t\t\t     bool threadgroup)\n{\n\tstruct cgroup *cgrp;\n\tstruct task_struct *task;\n\tconst struct cred *cred, *tcred;\n\tssize_t ret;\n\tbool locked;\n\n\tcgrp = cgroup_kn_lock_live(of->kn, false);\n\tif (!cgrp)\n\t\treturn -ENODEV;\n\n\ttask = cgroup_procs_write_start(buf, threadgroup, &locked);\n\tret = PTR_ERR_OR_ZERO(task);\n\tif (ret)\n\t\tgoto out_unlock;\n\n\t\/*\n\t * Even if we're attaching all tasks in the thread group, we only\n\t * need to check permissions on one of them.\n\t *\/\n\tcred = current_cred();\n\ttcred = get_task_cred(task);\n\tif (!uid_eq(cred->euid, GLOBAL_ROOT_UID) &&\n\t    !uid_eq(cred->euid, tcred->uid) &&\n\t    !uid_eq(cred->euid, tcred->suid))\n\t\tret = -EACCES;\n\tput_cred(tcred);\n\tif (ret)\n\t\tgoto out_finish;\n\n\tret = cgroup_attach_task(cgrp, task, threadgroup);\n\nout_finish:\n\tcgroup_procs_write_finish(task, locked);\nout_unlock:\n\tcgroup_kn_unlock(of->kn);\n\n\treturn ret ?: nbytes;\n}","target":1,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":52152,"func":"ofpacts_parse__(char *str, const struct ofpact_parse_params *pp,\n                bool allow_instructions, enum ofpact_type outer_action)\n{\n    char *key, *value;\n    bool drop = false;\n    char *pos;\n\n    pos = str;\n    while (ofputil_parse_key_value(&pos, &key, &value)) {\n        enum ofpact_type type;\n        char *error = NULL;\n        ofp_port_t port;\n        if (ofpact_type_from_name(key, &type)) {\n            error = ofpact_parse(type, value, pp);\n\n            if (type == OFPACT_METER && !allow_instructions) {\n                \/* Meter is an action in OF1.5 and it's being used in a\n                 * context where instructions aren't allowed.  Therefore,\n                 * this must be OF1.5+. *\/\n                *pp->usable_protocols &= OFPUTIL_P_OF15_UP;\n            }\n        } else if (!strcasecmp(key, \"mod_vlan_vid\")) {\n            error = parse_set_vlan_vid(value, true, pp);\n        } else if (!strcasecmp(key, \"mod_vlan_pcp\")) {\n            error = parse_set_vlan_pcp(value, true, pp);\n        } else if (!strcasecmp(key, \"set_nw_ttl\")) {\n            error = parse_SET_IP_TTL(value, pp);\n        } else if (!strcasecmp(key, \"pop_vlan\")) {\n            error = parse_pop_vlan(pp);\n        } else if (!strcasecmp(key, \"set_tunnel64\")) {\n            error = parse_set_tunnel(value, NXAST_RAW_SET_TUNNEL64, pp);\n        } else if (!strcasecmp(key, \"load\")) {\n            error = parse_reg_load(value, pp);\n        } else if (!strcasecmp(key, \"bundle_load\")) {\n            error = parse_bundle_load(value, pp);\n        } else if (!strcasecmp(key, \"drop\")) {\n            drop = true;\n        } else if (!strcasecmp(key, \"apply_actions\")) {\n            return xstrdup(\"apply_actions is the default instruction\");\n        } else if (ofputil_port_from_string(key, pp->port_map, &port)) {\n            ofpact_put_OUTPUT(pp->ofpacts)->port = port;\n        } else {\n            return xasprintf(\"unknown action %s\", key);\n        }\n        if (error) {\n            return error;\n        }\n    }\n\n    if (drop && pp->ofpacts->size) {\n        return xstrdup(\"\\\"drop\\\" must not be accompanied by any other action \"\n                       \"or instruction\");\n    }\n\n    char *error = NULL;\n    ofpacts_verify(pp->ofpacts->data, pp->ofpacts->size, OFP11_VERSION,\n                   (allow_instructions\n                    ? (1u << N_OVS_INSTRUCTIONS) - 1\n                    : ((1u << OVSINST_OFPIT11_APPLY_ACTIONS)\n                       | (1u << OVSINST_OFPIT13_METER))),\n                   outer_action, &error);\n    if (error) {\n        return error;\n    }\n\n    return NULL;\n}","target":0,"code_token_length":652,"total_token_length":888,"max_tokens_setting":1024}
+{"idx":345622,"func":"PHP_FUNCTION(dom_document_save)\n{\n\tzval *id;\n\txmlDoc *docp;\n\tint file_len = 0, bytes, format, saveempty = 0;\n\tdom_object *intern;\n\tdom_doc_propsptr doc_props;\n\tchar *file;\n\tlong options = 0;\n\n\tif (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"Os|l\", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (file_len == 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid Filename\");\n\t\tRETURN_FALSE;\n\t}\n\n\tDOM_GET_OBJ(docp, id, xmlDocPtr, intern);\n\n\t\/* encoding handled by property on doc *\/\n\n\tdoc_props = dom_get_doc_props(intern->document);\n\tformat = doc_props->formatoutput;\n\tif (options & LIBXML_SAVE_NOEMPTYTAG) {\n\t\tsaveempty = xmlSaveNoEmptyTags;\n\t\txmlSaveNoEmptyTags = 1;\n\t}\n\tbytes = xmlSaveFormatFileEnc(file, docp, NULL, format);\n\tif (options & LIBXML_SAVE_NOEMPTYTAG) {\n\t\txmlSaveNoEmptyTags = saveempty;\n\t}\n\tif (bytes == -1) {\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_LONG(bytes);\n}","target":1,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":175830,"func":"path_to_hinter(t1_hinter *h, gx_path *path)\n{   int code;\n    gs_path_enum penum;\n    gs_fixed_point pts[3];\n    gs_fixed_point p = {0, 0}; \/* initialize to avoid a warning *\/\n    bool first = true;\n    int op;\n\n    code = gx_path_enum_init(&penum, path);\n    if (code < 0)\n        return code;\n    while ((op = gx_path_enum_next(&penum, pts)) != 0) {\n        switch (op) {\n            case gs_pe_moveto:\n                if (first) {\n                    first = false;\n                    p = pts[0];\n                    code = t1_hinter__rmoveto(h, p.x, p.y);\n                } else\n                    code = t1_hinter__rmoveto(h, pts[0].x - p.x, pts[0].y - p.y);\n                break;\n            case gs_pe_lineto:\n            case gs_pe_gapto:\n                code = t1_hinter__rlineto(h, pts[0].x - p.x, pts[0].y - p.y);\n                break;\n            case gs_pe_curveto:\n                code = t1_hinter__rcurveto(h, pts[0].x - p.x, pts[0].y - p.y,\n                                        pts[1].x - pts[0].x, pts[1].y - pts[0].y,\n                                        pts[2].x - pts[1].x, pts[2].y - pts[1].y);\n                pts[0] = pts[2];\n                break;\n            case gs_pe_closepath:\n                code = t1_hinter__closepath(h);\n                break;\n            default:\n                return_error(gs_error_unregistered);\n        }\n        if (code < 0)\n            return code;\n        p = pts[0];\n    }\n    return 0;\n}\n","target":0,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":412039,"func":"relpTcpChkOnePeerWildcard(tcpPermittedPeerWildcardComp_t *pRoot, char *peername, int *pbFoundPositiveMatch)\n{\n\ttcpPermittedPeerWildcardComp_t *pWildcard;\n\tchar *pC;\n\tchar *pStart; \/* start of current domain component *\/\n\tint iWildcard, iName; \/* work indexes for backward comparisons *\/\n\n\t*pbFoundPositiveMatch = 0;\n\tpWildcard = pRoot;\n\tpC = peername;\n\twhile(*pC != '\\0') {\n\t\tif(pWildcard == NULL) {\n\t\t\t\/* we have more domain components than we have wildcards --> no match *\/\n\t\t\tgoto done;\n\t\t}\n\t\tpStart = pC;\n\t\twhile(*pC != '\\0' && *pC != '.') {\n\t\t\t++pC;\n\t\t}\n\n\t\t\/* got the component, now do the match *\/\n\t\tswitch(pWildcard->wildcardType) {\n\t\t\tcase tcpPEER_WILDCARD_NONE:\n\t\t\t\tif(   pWildcard->lenDomainPart != pC - pStart\n\t\t\t\t   || strncmp((char*)pStart, (char*)pWildcard->pszDomainPart, pC - pStart)) {\n\t\t\t\t\tgoto done;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase tcpPEER_WILDCARD_AT_START:\n\t\t\t\t\/* we need to do the backwards-matching manually *\/\n\t\t\t\tif(pWildcard->lenDomainPart > pC - pStart) {\n\t\t\t\t\tgoto done;\n\t\t\t\t}\n\t\t\t\tiName = (size_t) (pC - pStart) - pWildcard->lenDomainPart;\n\t\t\t\tiWildcard = 0;\n\t\t\t\twhile(iWildcard < pWildcard->lenDomainPart) {\n\t\t\t\t\tif(pWildcard->pszDomainPart[iWildcard] != pStart[iName]) {\n\t\t\t\t\t\tgoto done;\n\t\t\t\t\t}\n\t\t\t\t\t++iName;\n\t\t\t\t\t++iWildcard;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase tcpPEER_WILDCARD_AT_END:\n\t\t\t\tif(   pWildcard->lenDomainPart > pC - pStart\n\t\t\t\t   || strncmp((char*)pStart, (char*)pWildcard->pszDomainPart,\n\t\t\t\t\tpWildcard->lenDomainPart)) {\n\t\t\t\t\tgoto done;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase tcpPEER_WILDCARD_MATCH_ALL:\n\t\t\t\t\/* everything is OK, just continue *\/\n\t\t\t\tbreak;\n\t\t\tcase tcpPEER_WILDCARD_EMPTY_COMPONENT:\n\t\t\t\tif(pC - pStart > 0) {\n\t\t\t\t   \t\/* if it is not empty, it is no match... *\/\n\t\t\t\t\tgoto done;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tpWildcard =  pWildcard->pNext; \/* we processed this entry *\/\n\n\t\t\/* skip '.' if we had it and so prepare for next iteration *\/\n\t\tif(*pC == '.')\n\t\t\t++pC;\n\t}\n\t\n\t\/* we need to adjust for a border case, that is if the last component is\n\t * empty. That happens frequently if the domain root (e.g. \"example.com.\")\n\t * is properly given.\n\t *\/\n\tif(pWildcard != NULL && pWildcard->wildcardType == tcpPEER_WILDCARD_EMPTY_COMPONENT)\n\t\tpWildcard = pWildcard->pNext;\n\n\tif(pWildcard != NULL) {\n\t\t\/* we have more domain components than in the name to be\n\t\t * checked. So this is no match.\n\t\t *\/\n\t\tgoto done;\n\t}\n\t*pbFoundPositiveMatch = 1;\ndone:\treturn;\n}","target":0,"code_token_length":716,"total_token_length":952,"max_tokens_setting":1024}
+{"idx":285796,"func":"get_negotiable_mechs(OM_uint32 *minor_status, spnego_gss_cred_id_t spcred,\n\t\t     gss_cred_usage_t usage, gss_OID_set *rmechs)\n{\n\tOM_uint32 ret, tmpmin;\n\tgss_cred_id_t creds = GSS_C_NO_CREDENTIAL, *credptr;\n\tgss_OID_set cred_mechs = GSS_C_NULL_OID_SET;\n\tgss_OID_set intersect_mechs = GSS_C_NULL_OID_SET;\n\tunsigned int i;\n\tint present;\n\n\tif (spcred == NULL) {\n\t\t\/*\n\t\t * The default credentials were supplied.  Return a list of all\n\t\t * available mechs except SPNEGO.  When initiating, trim this\n\t\t * list to mechs we can acquire credentials for.\n\t\t *\/\n\t\tcredptr = (usage == GSS_C_INITIATE) ? &creds : NULL;\n\t\tret = get_available_mechs(minor_status, GSS_C_NO_NAME, usage,\n\t\t\t\t\t  GSS_C_NO_CRED_STORE, credptr,\n\t\t\t\t\t  rmechs);\n\t\tgss_release_cred(&tmpmin, &creds);\n\t\treturn (ret);\n\t}\n\n\t\/* Get the list of mechs in the mechglue cred. *\/\n\tret = gss_inquire_cred(minor_status, spcred->mcred, NULL, NULL, NULL,\n\t\t\t       &cred_mechs);\n\tif (ret != GSS_S_COMPLETE)\n\t\treturn (ret);\n\n\tif (spcred->neg_mechs == GSS_C_NULL_OID_SET) {\n\t\t\/* gss_set_neg_mechs was never called; return cred_mechs. *\/\n\t\t*rmechs = cred_mechs;\n\t\t*minor_status = 0;\n\t\treturn (GSS_S_COMPLETE);\n\t}\n\n\t\/* Compute the intersection of cred_mechs and spcred->neg_mechs,\n\t * preserving the order in spcred->neg_mechs. *\/\n\tret = gss_create_empty_oid_set(minor_status, &intersect_mechs);\n\tif (ret != GSS_S_COMPLETE) {\n\t\tgss_release_oid_set(&tmpmin, &cred_mechs);\n\t\treturn (ret);\n\t}\n\n\tfor (i = 0; i < spcred->neg_mechs->count; i++) {\n\t\tgss_test_oid_set_member(&tmpmin,\n\t\t\t\t\t&spcred->neg_mechs->elements[i],\n\t\t\t\t\tcred_mechs, &present);\n\t\tif (!present)\n\t\t\tcontinue;\n\t\tret = gss_add_oid_set_member(minor_status,\n\t\t\t\t\t     &spcred->neg_mechs->elements[i],\n\t\t\t\t\t     &intersect_mechs);\n\t\tif (ret != GSS_S_COMPLETE)\n\t\t\tbreak;\n\t}\n\n\tgss_release_oid_set(&tmpmin, &cred_mechs);\n\tif (intersect_mechs->count == 0 || ret != GSS_S_COMPLETE) {\n\t\tgss_release_oid_set(&tmpmin, &intersect_mechs);\n\t\t*minor_status = ERR_SPNEGO_NO_MECHS_AVAILABLE;\n\t\tmap_errcode(minor_status);\n\t\treturn (GSS_S_FAILURE);\n\t}\n\n\t*rmechs = intersect_mechs;\n\t*minor_status = 0;\n\treturn (GSS_S_COMPLETE);\n}\n","target":0,"code_token_length":683,"total_token_length":919,"max_tokens_setting":1024}
+{"idx":437,"func":"static int ipvideo_decode_block_opcode_0x9 ( IpvideoContext * s ) {\n int x , y ;\n unsigned char P [ 4 ] ;\n bytestream2_get_buffer ( & s -> stream_ptr , P , 4 ) ;\n if ( P [ 0 ] <= P [ 1 ] ) {\n if ( P [ 2 ] <= P [ 3 ] ) {\n for ( y = 0 ;\n y < 8 ;\n y ++ ) {\n int flags = bytestream2_get_le16 ( & s -> stream_ptr ) ;\n for ( x = 0 ;\n x < 8 ;\n x ++ , flags >>= 2 ) * s -> pixel_ptr ++ = P [ flags & 0x03 ] ;\n s -> pixel_ptr += s -> line_inc ;\n }\n }\n else {\n uint32_t flags ;\n flags = bytestream2_get_le32 ( & s -> stream_ptr ) ;\n for ( y = 0 ;\n y < 8 ;\n y += 2 ) {\n for ( x = 0 ;\n x < 8 ;\n x += 2 , flags >>= 2 ) {\n s -> pixel_ptr [ x ] = s -> pixel_ptr [ x + 1 ] = s -> pixel_ptr [ x + s -> stride ] = s -> pixel_ptr [ x + 1 + s -> stride ] = P [ flags & 0x03 ] ;\n }\n s -> pixel_ptr += s -> stride * 2 ;\n }\n }\n }\n else {\n uint64_t flags ;\n flags = bytestream2_get_le64 ( & s -> stream_ptr ) ;\n if ( P [ 2 ] <= P [ 3 ] ) {\n for ( y = 0 ;\n y < 8 ;\n y ++ ) {\n for ( x = 0 ;\n x < 8 ;\n x += 2 , flags >>= 2 ) {\n s -> pixel_ptr [ x ] = s -> pixel_ptr [ x + 1 ] = P [ flags & 0x03 ] ;\n }\n s -> pixel_ptr += s -> stride ;\n }\n }\n else {\n for ( y = 0 ;\n y < 8 ;\n y += 2 ) {\n for ( x = 0 ;\n x < 8 ;\n x ++ , flags >>= 2 ) {\n s -> pixel_ptr [ x ] = s -> pixel_ptr [ x + s -> stride ] = P [ flags & 0x03 ] ;\n }\n s -> pixel_ptr += s -> stride * 2 ;\n }\n }\n }\n return 0 ;\n }","target":1,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":328457,"func":"static int fileTest(uint8_t *ref[4], int refStride[4], int w, int h, FILE *fp,\n\n                    enum AVPixelFormat srcFormat_in,\n\n                    enum AVPixelFormat dstFormat_in)\n\n{\n\n    char buf[256];\n\n\n\n    while (fgets(buf, sizeof(buf), fp)) {\n\n        struct Results r;\n\n        enum AVPixelFormat srcFormat;\n\n        char srcStr[12];\n\n        int srcW, srcH;\n\n        enum AVPixelFormat dstFormat;\n\n        char dstStr[12];\n\n        int dstW, dstH;\n\n        int flags;\n\n        int ret;\n\n\n\n        ret = sscanf(buf,\n\n                     \" %12s %dx%d -> %12s %dx%d flags=%d CRC=%x\"\n\n                     \" SSD=%\"SCNu64 \", %\"SCNu64 \", %\"SCNu64 \", %\"SCNu64 \"\\n\",\n\n                     srcStr, &srcW, &srcH, dstStr, &dstW, &dstH,\n\n                     &flags, &r.crc, &r.ssdY, &r.ssdU, &r.ssdV, &r.ssdA);\n\n        if (ret != 12) {\n\n            srcStr[0] = dstStr[0] = 0;\n\n            ret       = sscanf(buf, \"%12s -> %12s\\n\", srcStr, dstStr);\n\n        }\n\n\n\n        srcFormat = av_get_pix_fmt(srcStr);\n\n        dstFormat = av_get_pix_fmt(dstStr);\n\n\n\n        if (srcFormat == AV_PIX_FMT_NONE || dstFormat == AV_PIX_FMT_NONE ||\n\n            srcW > 8192U || srcH > 8192U || dstW > 8192U || dstH > 8192U) {\n\n            fprintf(stderr, \"malformed input file\\n\");\n\n            return -1;\n\n        }\n\n        if ((srcFormat_in != AV_PIX_FMT_NONE && srcFormat_in != srcFormat) ||\n\n            (dstFormat_in != AV_PIX_FMT_NONE && dstFormat_in != dstFormat))\n\n            continue;\n\n        if (ret != 12) {\n\n            printf(\"%s\", buf);\n\n            continue;\n\n        }\n\n\n\n        doTest(ref, refStride, w, h,\n\n               srcFormat, dstFormat,\n\n               srcW, srcH, dstW, dstH, flags,\n\n               &r);\n\n    }\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":505,"total_token_length":741,"max_tokens_setting":1024}
+{"idx":508981,"func":"static int dtls1_process_buffered_records(SSL *s)\n{\n    pitem *item;\n    SSL3_BUFFER *rb;\n    SSL3_RECORD *rr;\n    DTLS1_BITMAP *bitmap;\n    unsigned int is_next_epoch;\n    int replayok = 1;\n\n    item = pqueue_peek(s->d1->unprocessed_rcds.q);\n    if (item) {\n        \/* Check if epoch is current. *\/\n        if (s->d1->unprocessed_rcds.epoch != s->d1->r_epoch)\n            return 1;         \/* Nothing to do. *\/\n\n        rr = &s->s3->rrec;\n        rb = &s->s3->rbuf;\n\n        if (rb->left > 0) {\n            \/*\n             * We've still got data from the current packet to read. There could\n             * be a record from the new epoch in it - so don't overwrite it\n             * with the unprocessed records yet (we'll do it when we've\n             * finished reading the current packet).\n             *\/\n            return 1;\n        }\n\n\n        \/* Process all the records. *\/\n        while (pqueue_peek(s->d1->unprocessed_rcds.q)) {\n            dtls1_get_unprocessed_record(s);\n            bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch);\n            if (bitmap == NULL) {\n                \/*\n                 * Should not happen. This will only ever be NULL when the\n                 * current record is from a different epoch. But that cannot\n                 * be the case because we already checked the epoch above\n                 *\/\n                 SSLerr(SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS,\n                        ERR_R_INTERNAL_ERROR);\n                 return 0;\n            }\n#ifndef OPENSSL_NO_SCTP\n            \/* Only do replay check if no SCTP bio *\/\n            if (!BIO_dgram_is_sctp(SSL_get_rbio(s)))\n#endif\n            {\n                \/*\n                 * Check whether this is a repeat, or aged record. We did this\n                 * check once already when we first received the record - but\n                 * we might have updated the window since then due to\n                 * records we subsequently processed.\n                 *\/\n                replayok = dtls1_record_replay_check(s, bitmap);\n            }\n\n            if (!replayok || !dtls1_process_record(s, bitmap)) {\n                \/* dump this record *\/\n                rr->length = 0;\n                s->packet_length = 0;\n                continue;\n            }\n\n            if (dtls1_buffer_record(s, &(s->d1->processed_rcds),\n                                    s->s3->rrec.seq_num) < 0)\n                return 0;\n        }\n    }\n\n    \/*\n     * sync epoch numbers once all the unprocessed records have been\n     * processed\n     *\/\n    s->d1->processed_rcds.epoch = s->d1->r_epoch;\n    s->d1->unprocessed_rcds.epoch = s->d1->r_epoch + 1;\n\n    return 1;\n}","target":0,"code_token_length":640,"total_token_length":876,"max_tokens_setting":1024}
+{"idx":493207,"func":"get_constraint_index(Oid constraintId)\n{\n\tOid\t\t\tindexId = InvalidOid;\n\tRelation\tdepRel;\n\tScanKeyData key[3];\n\tSysScanDesc scan;\n\tHeapTuple\ttup;\n\n\t\/* Search the dependency table for the dependent index *\/\n\tdepRel = table_open(DependRelationId, AccessShareLock);\n\n\tScanKeyInit(&key[0],\n\t\t\t\tAnum_pg_depend_refclassid,\n\t\t\t\tBTEqualStrategyNumber, F_OIDEQ,\n\t\t\t\tObjectIdGetDatum(ConstraintRelationId));\n\tScanKeyInit(&key[1],\n\t\t\t\tAnum_pg_depend_refobjid,\n\t\t\t\tBTEqualStrategyNumber, F_OIDEQ,\n\t\t\t\tObjectIdGetDatum(constraintId));\n\tScanKeyInit(&key[2],\n\t\t\t\tAnum_pg_depend_refobjsubid,\n\t\t\t\tBTEqualStrategyNumber, F_INT4EQ,\n\t\t\t\tInt32GetDatum(0));\n\n\tscan = systable_beginscan(depRel, DependReferenceIndexId, true,\n\t\t\t\t\t\t\t  NULL, 3, key);\n\n\twhile (HeapTupleIsValid(tup = systable_getnext(scan)))\n\t{\n\t\tForm_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);\n\n\t\t\/*\n\t\t * We assume any internal dependency of an index on the constraint\n\t\t * must be what we are looking for.\n\t\t *\/\n\t\tif (deprec->classid == RelationRelationId &&\n\t\t\tdeprec->objsubid == 0 &&\n\t\t\tdeprec->deptype == DEPENDENCY_INTERNAL)\n\t\t{\n\t\t\tchar\t\trelkind = get_rel_relkind(deprec->objid);\n\n\t\t\t\/*\n\t\t\t * This is pure paranoia; there shouldn't be any other relkinds\n\t\t\t * dependent on a constraint.\n\t\t\t *\/\n\t\t\tif (relkind != RELKIND_INDEX &&\n\t\t\t\trelkind != RELKIND_PARTITIONED_INDEX)\n\t\t\t\tcontinue;\n\n\t\t\tindexId = deprec->objid;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsystable_endscan(scan);\n\ttable_close(depRel, AccessShareLock);\n\n\treturn indexId;\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":322592,"func":"static void init_blk_migration_it(void *opaque, BlockDriverState *bs)\n\n{\n\n    Monitor *mon = opaque;\n\n    BlkMigDevState *bmds;\n\n    int64_t sectors;\n\n\n\n    if (!bdrv_is_read_only(bs)) {\n\n        sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;\n\n        if (sectors <= 0) {\n\n            return;\n\n        }\n\n\n\n        bmds = g_malloc0(sizeof(BlkMigDevState));\n\n        bmds->bs = bs;\n\n        bmds->bulk_completed = 0;\n\n        bmds->total_sectors = sectors;\n\n        bmds->completed_sectors = 0;\n\n        bmds->shared_base = block_mig_state.shared_base;\n\n        alloc_aio_bitmap(bmds);\n\n        drive_get_ref(drive_get_by_blockdev(bs));\n\n        bdrv_set_in_use(bs, 1);\n\n\n\n        block_mig_state.total_sector_sum += sectors;\n\n\n\n        if (bmds->shared_base) {\n\n            monitor_printf(mon, \"Start migration for %s with shared base \"\n\n                                \"image\\n\",\n\n                           bs->device_name);\n\n        } else {\n\n            monitor_printf(mon, \"Start full migration for %s\\n\",\n\n                           bs->device_name);\n\n        }\n\n\n\n        QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry);\n\n    }\n\n}\n","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":157006,"func":"_lyd_insert_hash(struct lyd_node *node, int keyless_list_check)\n{\n    struct lyd_node *iter;\n    int i;\n\n    if (node->parent) {\n        if ((node->schema->nodetype != LYS_LIST) || lyd_list_has_keys(node)) {\n            if ((node->schema->nodetype == LYS_LEAF) && lys_is_key((struct lys_node_leaf *)node->schema, NULL)) {\n                \/* we are adding a key which means that it may be the last missing key for our parent's hash *\/\n                if (!lyd_hash(node->parent)) {\n                    \/* yep, we successfully hashed node->parent so it is technically now added to its parent (hash-wise) *\/\n                    _lyd_insert_hash(node->parent, 0);\n                }\n            }\n\n            \/* create parent hash table if required, otherwise just add the new child *\/\n            if (!node->parent->ht) {\n                for (i = 0, iter = node->parent->child; iter; ++i, iter = iter->next) {\n                    if ((iter->schema->nodetype == LYS_LIST) && !lyd_list_has_keys(iter)) {\n                        \/* it will either never have keys and will never be hashed or has not all keys created yet *\/\n                        --i;\n                    }\n                }\n                assert(i <= LY_CACHE_HT_MIN_CHILDREN);\n                if (i == LY_CACHE_HT_MIN_CHILDREN) {\n                    \/* create hash table, insert all the children *\/\n                    node->parent->ht = lyht_new(1, sizeof(struct lyd_node *), lyd_hash_table_val_equal, NULL, 1);\n                    LY_TREE_FOR(node->parent->child, iter) {\n                        if ((iter->schema->nodetype == LYS_LIST) && !lyd_list_has_keys(iter)) {\n                            \/* skip lists without keys *\/\n                            continue;\n                        }\n\n                        if (lyht_insert(node->parent->ht, &iter, iter->hash, NULL)) {\n                            assert(0);\n                        }\n                    }\n                }\n            } else {\n                if (lyht_insert(node->parent->ht, &node, node->hash, NULL)) {\n                    assert(0);\n                }\n            }\n\n            \/* if node was in a state data subtree, wasn't it a part of a key-less list hash? *\/\n            if (keyless_list_check) {\n                lyd_keyless_list_hash_change(node->parent);\n            }\n        }\n    }\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":22387,"func":"static inline void e1000e_write_ps_rx_descr ( E1000ECore * core , uint8_t * desc , struct NetRxPkt * pkt , const E1000E_RSSInfo * rss_info , size_t ps_hdr_len , uint16_t ( * written ) [ MAX_PS_BUFFERS ] ) {\n int i ;\n union e1000_rx_desc_packet_split * d = ( union e1000_rx_desc_packet_split * ) desc ;\n memset ( & d -> wb , 0 , sizeof ( d -> wb ) ) ;\n d -> wb . middle . length0 = cpu_to_le16 ( ( * written ) [ 0 ] ) ;\n for ( i = 0 ;\n i < PS_PAGE_BUFFERS ;\n i ++ ) {\n d -> wb . upper . length [ i ] = cpu_to_le16 ( ( * written ) [ i + 1 ] ) ;\n }\n e1000e_build_rx_metadata ( core , pkt , pkt != NULL , rss_info , & d -> wb . lower . hi_dword . rss , & d -> wb . lower . mrq , & d -> wb . middle . status_error , & d -> wb . lower . hi_dword . csum_ip . ip_id , & d -> wb . middle . vlan ) ;\n d -> wb . upper . header_status = cpu_to_le16 ( ps_hdr_len | ( ps_hdr_len ? E1000_RXDPS_HDRSTAT_HDRSP : 0 ) ) ;\n trace_e1000e_rx_desc_ps_write ( ( * written ) [ 0 ] , ( * written ) [ 1 ] , ( * written ) [ 2 ] , ( * written ) [ 3 ] ) ;\n }","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":293551,"func":"unpeer_name_resolved(\n\tint\t\t\trescode,\n\tint\t\t\tgai_errno,\n\tvoid *\t\t\tcontext,\n\tconst char *\t\tname,\n\tconst char *\t\tservice,\n\tconst struct addrinfo *\thints,\n\tconst struct addrinfo *\tres\n\t)\n{\n\tsockaddr_u\tpeeraddr;\n\tstruct peer *\tpeer;\n\tu_short\t\taf;\n\tconst char *\tfam_spec;\n\n\tDPRINTF(1, (\"unpeer_name_resolved(%s) rescode %d\\n\", name, rescode));\n\n\tif (rescode) {\n\t\tmsyslog(LOG_ERR, \"giving up resolving unpeer %s: %s (%d)\", \n\t\t\tname, gai_strerror(rescode), rescode);\n\t\treturn;\n\t}\n\t\/*\n\t * Loop through the addresses found\n\t *\/\n\tfor (; res != NULL; res = res->ai_next) {\n\t\tNTP_INSIST(res->ai_addrlen <= sizeof(peeraddr));\n\t\tmemcpy(&peeraddr, res->ai_addr, res->ai_addrlen);\n\t\tDPRINTF(1, (\"unpeer: searching for peer %s\\n\",\n\t\t\t    stoa(&peeraddr)));\n\t\tpeer = findexistingpeer(&peeraddr, NULL, NULL, -1);\n\t\tif (peer != NULL) {\n\t\t\taf = AF(&peeraddr);\n\t\t\tfam_spec = (AF_INET6 == af)\n\t\t\t\t       ? \"(AAAA) \"\n\t\t\t\t       : (AF_INET == af)\n\t\t\t\t\t     ? \"(A) \"\n\t\t\t\t\t     : \"\";\n\t\t\tmsyslog(LOG_NOTICE, \"unpeered %s %s-> %s\", name,\n\t\t\t\tfam_spec, stoa(&peeraddr));\n\t\t\tpeer_clear(peer, \"GONE\");\n\t\t\tunpeer(peer);\n\t\t}\n\t}\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":460005,"func":"hfinfo_char_value_format_display(int display, char buf[7], guint32 value)\n{\n\tchar *ptr = &buf[6];\n\tstatic const gchar hex_digits[16] =\n\t{ '0', '1', '2', '3', '4', '5', '6', '7',\n\t  '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };\n\n\t*ptr = '\\0';\n\t*(--ptr) = '\\'';\n\t\/* Properly format value *\/\n\tif (g_ascii_isprint(value)) {\n\t\t\/*\n\t\t * Printable, so just show the character, and, if it needs\n\t\t * to be escaped, escape it.\n\t\t *\/\n\t\t*(--ptr) = value;\n\t\tif (value == '\\\\' || value == '\\'')\n\t\t\t*(--ptr) = '\\\\';\n\t} else {\n\t\t\/*\n\t\t * Non-printable; show it as an escape sequence.\n\t\t *\/\n\t\tswitch (value) {\n\n\t\tcase '\\0':\n\t\t\t\/*\n\t\t\t * Show a NUL with only one digit.\n\t\t\t *\/\n\t\t\t*(--ptr) = '0';\n\t\t\tbreak;\n\n\t\tcase '\\a':\n\t\t\t*(--ptr) = 'a';\n\t\t\tbreak;\n\n\t\tcase '\\b':\n\t\t\t*(--ptr) = 'b';\n\t\t\tbreak;\n\n\t\tcase '\\f':\n\t\t\t*(--ptr) = 'f';\n\t\t\tbreak;\n\n\t\tcase '\\n':\n\t\t\t*(--ptr) = 'n';\n\t\t\tbreak;\n\n\t\tcase '\\r':\n\t\t\t*(--ptr) = 'r';\n\t\t\tbreak;\n\n\t\tcase '\\t':\n\t\t\t*(--ptr) = 't';\n\t\t\tbreak;\n\n\t\tcase '\\v':\n\t\t\t*(--ptr) = 'v';\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tswitch (FIELD_DISPLAY(display)) {\n\n\t\t\tcase BASE_OCT:\n\t\t\t\t*(--ptr) = (value & 0x7) + '0';\n\t\t\t\tvalue >>= 3;\n\t\t\t\t*(--ptr) = (value & 0x7) + '0';\n\t\t\t\tvalue >>= 3;\n\t\t\t\t*(--ptr) = (value & 0x7) + '0';\n\t\t\t\tbreak;\n\n\t\t\tcase BASE_HEX:\n\t\t\t\t*(--ptr) = hex_digits[value & 0x0F];\n\t\t\t\tvalue >>= 4;\n\t\t\t\t*(--ptr) = hex_digits[value & 0x0F];\n\t\t\t\t*(--ptr) = 'x';\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tg_assert_not_reached();\n\t\t\t}\n\t\t}\n\t\t*(--ptr) = '\\\\';\n\t}\n\t*(--ptr) = '\\'';\n\treturn ptr;\n}","target":0,"code_token_length":555,"total_token_length":791,"max_tokens_setting":1024}
+{"idx":290558,"func":"static int newque(struct ipc_namespace *ns, struct ipc_params *params)\n{\n\tstruct msg_queue *msq;\n\tint id, retval;\n\tkey_t key = params->key;\n\tint msgflg = params->flg;\n\n\tmsq = ipc_rcu_alloc(sizeof(*msq));\n\tif (!msq)\n\t\treturn -ENOMEM;\n\n\tmsq->q_perm.mode = msgflg & S_IRWXUGO;\n\tmsq->q_perm.key = key;\n\n\tmsq->q_perm.security = NULL;\n\tretval = security_msg_queue_alloc(msq);\n\tif (retval) {\n\t\tipc_rcu_putref(msq, ipc_rcu_free);\n\t\treturn retval;\n\t}\n\n\tmsq->q_stime = msq->q_rtime = 0;\n\tmsq->q_ctime = get_seconds();\n\tmsq->q_cbytes = msq->q_qnum = 0;\n\tmsq->q_qbytes = ns->msg_ctlmnb;\n\tmsq->q_lspid = msq->q_lrpid = 0;\n\tINIT_LIST_HEAD(&msq->q_messages);\n\tINIT_LIST_HEAD(&msq->q_receivers);\n\tINIT_LIST_HEAD(&msq->q_senders);\n\n\t\/* ipc_addid() locks msq upon success. *\/\n\tid = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);\n\tif (id < 0) {\n\t\tipc_rcu_putref(msq, msg_rcu_free);\n\t\treturn id;\n\t}\n\n\tipc_unlock_object(&msq->q_perm);\n\trcu_read_unlock();\n\n\treturn msq->q_perm.id;\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":90345,"func":"static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) \/* {{{ *\/\n{\n\tspl_array_object *intern = (spl_array_object*)zend_object_store_get_object(obj TSRMLS_CC);\n\tzval *tmp, *storage;\n\tint name_len;\n\tchar *zname;\n\tzend_class_entry *base;\n\n\t*is_temp = 0;\n\n\tif (!intern->std.properties) {\n\t\trebuild_object_properties(&intern->std);\n\t}\n\n\tif (HASH_OF(intern->array) == intern->std.properties) {\n\t\treturn intern->std.properties;\n\t} else {\n\t\tif (intern->debug_info == NULL) {\n\t\t\tALLOC_HASHTABLE(intern->debug_info);\n\t\t\tZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);\n\t\t}\n\n\t\tif (intern->debug_info->nApplyCount == 0) {\n\t\t\tzend_hash_clean(intern->debug_info);\n\t\t\tzend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));\n\n\t\t\tstorage = intern->array;\n\t\t\tzval_add_ref(&storage);\n\n\t\t\tbase = (Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator) ? spl_ce_ArrayIterator : spl_ce_ArrayObject;\n\t\t\tzname = spl_gen_private_prop_name(base, \"storage\", sizeof(\"storage\")-1, &name_len TSRMLS_CC);\n\t\t\tzend_symtable_update(intern->debug_info, zname, name_len+1, &storage, sizeof(zval *), NULL);\n\t\t\tefree(zname);\n\t\t}\n\n\t\treturn intern->debug_info;\n\t}\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":514627,"func":"Origins::Origins(Isolate* isolate,\n                 Local<Context> context,\n                 Local<String> origin_string,\n                 size_t origin_count) : count_(origin_count) {\n  int origin_string_len = origin_string->Length();\n  if (count_ == 0) {\n    CHECK_EQ(origin_string_len, 0);\n    return;\n  }\n\n  \/\/ Allocate a single buffer with count_ nghttp2_nv structs, followed\n  \/\/ by the raw header data as passed from JS. This looks like:\n  \/\/ | possible padding | nghttp2_nv | nghttp2_nv | ... | header contents |\n  buf_.AllocateSufficientStorage((alignof(nghttp2_origin_entry) - 1) +\n                                 count_ * sizeof(nghttp2_origin_entry) +\n                                 origin_string_len);\n\n  \/\/ Make sure the start address is aligned appropriately for an nghttp2_nv*.\n  char* start = reinterpret_cast<char*>(\n      ROUND_UP(reinterpret_cast<uintptr_t>(*buf_),\n               alignof(nghttp2_origin_entry)));\n  char* origin_contents = start + (count_ * sizeof(nghttp2_origin_entry));\n  nghttp2_origin_entry* const nva =\n      reinterpret_cast<nghttp2_origin_entry*>(start);\n\n  CHECK_LE(origin_contents + origin_string_len, *buf_ + buf_.length());\n  CHECK_EQ(origin_string->WriteOneByte(\n               isolate,\n               reinterpret_cast<uint8_t*>(origin_contents),\n               0,\n               origin_string_len,\n               String::NO_NULL_TERMINATION),\n           origin_string_len);\n\n  size_t n = 0;\n  char* p;\n  for (p = origin_contents; p < origin_contents + origin_string_len; n++) {\n    if (n >= count_) {\n      static uint8_t zero = '\\0';\n      nva[0].origin = &zero;\n      nva[0].origin_len = 1;\n      count_ = 1;\n      return;\n    }\n\n    nva[n].origin = reinterpret_cast<uint8_t*>(p);\n    nva[n].origin_len = strlen(p);\n    p += nva[n].origin_len + 1;\n  }\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":305021,"func":"BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor)\n{\n\t\/* round to two decimals and keep the 100x multiplication to use it in the common square angles \n\t   case later. Keep the two decimal precisions so smaller rotation steps can be done, useful for\n\t   slow animations, f.e. *\/\n\tconst int angle_rounded = fmod((int) floorf(angle * 100), 360 * 100);\n\n\tif (bgcolor < 0) {\n\t\treturn NULL;\n\t}\n\n\t\/* 0 && 90 degrees multiple rotation, 0 rotation simply clones the return image and convert it\n\t   to truecolor, as we must return truecolor image. *\/\n\tswitch (angle_rounded) {\n\t\tcase    0: {\n\t\t\tgdImagePtr dst = gdImageClone(src);\n\n\t\t\tif (dst == NULL) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (dst->trueColor == 0) {\n\t\t\t\tgdImagePaletteToTrueColor(dst);\n\t\t\t}\n\t\t\treturn dst;\n\t\t}\n\n\t\tcase -2700:\n\t\tcase   9000:\n\t\t\treturn gdImageRotate90(src, 0);\n\n\t\tcase -18000:\n\t\tcase  18000:\n\t\t\treturn gdImageRotate180(src, 0);\n\n\t\tcase  -9000:\n\t\tcase  27000:\n\t\t\treturn gdImageRotate270(src, 0);\n\t}\n\n\tif (src == NULL || src->interpolation_id < 1 || src->interpolation_id > GD_METHOD_COUNT) {\n\t\treturn NULL;\n\t}\n\n\tswitch (src->interpolation_id) {\n\t\tcase GD_NEAREST_NEIGHBOUR:\n\t\t\treturn gdImageRotateNearestNeighbour(src, angle, bgcolor);\n\t\t\tbreak;\n\n\t\tcase GD_BILINEAR_FIXED:\n\t\t\treturn gdImageRotateBilinear(src, angle, bgcolor);\n\t\t\tbreak;\n\n\t\tcase GD_BICUBIC_FIXED:\n\t\t\treturn gdImageRotateBicubicFixed(src, angle, bgcolor);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\treturn gdImageRotateGeneric(src, angle, bgcolor);\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":359730,"func":"utils_fill_connection_certs (NMConnection *connection, GError **error)\n{\n\tNMSetting8021x *s_8021x;\n\tconst char *filename;\n\tGError *tmp_error = NULL;\n\tgboolean need_client_cert = TRUE;\n\n\tg_return_val_if_fail (connection != NULL, FALSE);\n\n\ts_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));\n\tif (!s_8021x)\n\t\treturn TRUE;\n\n\tfilename = g_object_get_data (G_OBJECT (connection), NMA_PATH_CA_CERT_TAG);\n\tif (filename) {\n\t\tif (!nm_setting_802_1x_set_ca_cert_from_file (s_8021x, filename, NULL, &tmp_error)) {\n\t\t\tg_set_error (error, tmp_error->domain, tmp_error->code,\n\t\t\t             _(\"Could not read CA certificate: %s\"), tmp_error->message);\n\t\t\tg_clear_error (&tmp_error);\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\t\/* If the private key is PKCS#12, don't set the client cert *\/\n\tneed_client_cert = fill_one_private_key (connection,\n\t                                         NMA_PATH_PRIVATE_KEY_TAG,\n\t                                         NM_SETTING_802_1X_PRIVATE_KEY,\n\t                                         NM_SETTING_802_1X_CLIENT_CERT);\n\tif (need_client_cert) {\n\t\tfilename = g_object_get_data (G_OBJECT (connection), NMA_PATH_CLIENT_CERT_TAG);\n\t\tif (filename) {\n\t\t\tif (!nm_setting_802_1x_set_client_cert_from_file (s_8021x, filename, NULL, &tmp_error)) {\n\t\t\t\tg_set_error (error, tmp_error->domain, tmp_error->code,\n\t\t\t\t             _(\"Could not read client certificate: %s\"), tmp_error->message);\n\t\t\t\tg_clear_error (&tmp_error);\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t}\n\t}\n\n\tfilename = g_object_get_data (G_OBJECT (connection), NMA_PATH_PHASE2_CA_CERT_TAG);\n\tif (filename) {\n\t\tif (!nm_setting_802_1x_set_phase2_ca_cert_from_file (s_8021x, filename, NULL, &tmp_error)) {\n\t\t\tg_set_error (error, tmp_error->domain, tmp_error->code,\n\t\t\t             _(\"Could not read inner CA certificate: %s\"), tmp_error->message);\n\t\t\tg_clear_error (&tmp_error);\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\t\/* If the private key is PKCS#12, don't set the client cert *\/\n\tneed_client_cert = fill_one_private_key (connection,\n\t                                         NMA_PATH_PHASE2_PRIVATE_KEY_TAG,\n\t                                         NM_SETTING_802_1X_PHASE2_PRIVATE_KEY,\n\t                                         NM_SETTING_802_1X_PHASE2_CLIENT_CERT);\n\tif (need_client_cert) {\n\t\tfilename = g_object_get_data (G_OBJECT (connection), NMA_PATH_PHASE2_CLIENT_CERT_TAG);\n\t\tif (filename) {\n\t\t\tif (!nm_setting_802_1x_set_phase2_client_cert_from_file (s_8021x, filename, NULL, &tmp_error)) {\n\t\t\t\tg_set_error (error, tmp_error->domain, tmp_error->code,\n\t\t\t\t             _(\"Could not read inner client certificate: %s\"), tmp_error->message);\n\t\t\t\tg_clear_error (&tmp_error);\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn TRUE;\n}","target":0,"code_token_length":739,"total_token_length":975,"max_tokens_setting":1024}
+{"idx":136603,"func":"Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,\n        SDL_PixelFormat * dst)\n{\n    Uint8 *map;\n    int i;\n    int bpp;\n    SDL_Palette *pal = src->palette;\n\n    bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);\n    map = (Uint8 *) SDL_calloc(256, bpp);\n    if (map == NULL) {\n        SDL_OutOfMemory();\n        return (NULL);\n    }\n\n    \/* We memory copy to the pixel map so the endianness is preserved *\/\n    for (i = 0; i < pal->ncolors; ++i) {\n        Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) \/ 255);\n        Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) \/ 255);\n        Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) \/ 255);\n        Uint8 A = (Uint8) ((pal->colors[i].a * Amod) \/ 255);\n        ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, (Uint32)R, (Uint32)G, (Uint32)B, (Uint32)A);\n    }\n    return (map);\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":482867,"func":"cachedb_intcache_lookup(struct module_qstate* qstate)\n{\n\tuint8_t* dpname=NULL;\n\tsize_t dpnamelen=0;\n\tstruct dns_msg* msg;\n\tif(iter_stub_fwd_no_cache(qstate, &qstate->qinfo,\n\t\t&dpname, &dpnamelen))\n\t\treturn 0; \/* no cache for these queries *\/\n\tmsg = dns_cache_lookup(qstate->env, qstate->qinfo.qname,\n\t\tqstate->qinfo.qname_len, qstate->qinfo.qtype,\n\t\tqstate->qinfo.qclass, qstate->query_flags,\n\t\tqstate->region, qstate->env->scratch,\n\t\t1, \/* no partial messages with only a CNAME *\/\n\t\tdpname, dpnamelen\n\t\t);\n\tif(!msg && qstate->env->neg_cache &&\n\t\titer_qname_indicates_dnssec(qstate->env, &qstate->qinfo)) {\n\t\t\/* lookup in negative cache; may result in \n\t\t * NOERROR\/NODATA or NXDOMAIN answers that need validation *\/\n\t\tmsg = val_neg_getmsg(qstate->env->neg_cache, &qstate->qinfo,\n\t\t\tqstate->region, qstate->env->rrset_cache,\n\t\t\tqstate->env->scratch_buffer,\n\t\t\t*qstate->env->now, 1\/*add SOA*\/, NULL,\n\t\t\tqstate->env->cfg);\n\t}\n\tif(!msg)\n\t\treturn 0;\n\t\/* this is the returned msg *\/\n\tqstate->return_rcode = LDNS_RCODE_NOERROR;\n\tqstate->return_msg = msg;\n\treturn 1;\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":122445,"func":"_pickle_Unpickler_find_class_impl(UnpicklerObject *self,\n                                  PyObject *module_name,\n                                  PyObject *global_name)\n\/*[clinic end generated code: output=becc08d7f9ed41e3 input=e2e6a865de093ef4]*\/\n{\n    PyObject *global;\n    PyObject *module;\n\n    \/* Try to map the old names used in Python 2.x to the new ones used in\n       Python 3.x.  We do this only with old pickle protocols and when the\n       user has not disabled the feature. *\/\n    if (self->proto < 3 && self->fix_imports) {\n        PyObject *key;\n        PyObject *item;\n        PickleState *st = _Pickle_GetGlobalState();\n\n        \/* Check if the global (i.e., a function or a class) was renamed\n           or moved to another module. *\/\n        key = PyTuple_Pack(2, module_name, global_name);\n        if (key == NULL)\n            return NULL;\n        item = PyDict_GetItemWithError(st->name_mapping_2to3, key);\n        Py_DECREF(key);\n        if (item) {\n            if (!PyTuple_Check(item) || PyTuple_GET_SIZE(item) != 2) {\n                PyErr_Format(PyExc_RuntimeError,\n                             \"_compat_pickle.NAME_MAPPING values should be \"\n                             \"2-tuples, not %.200s\", Py_TYPE(item)->tp_name);\n                return NULL;\n            }\n            module_name = PyTuple_GET_ITEM(item, 0);\n            global_name = PyTuple_GET_ITEM(item, 1);\n            if (!PyUnicode_Check(module_name) ||\n                !PyUnicode_Check(global_name)) {\n                PyErr_Format(PyExc_RuntimeError,\n                             \"_compat_pickle.NAME_MAPPING values should be \"\n                             \"pairs of str, not (%.200s, %.200s)\",\n                             Py_TYPE(module_name)->tp_name,\n                             Py_TYPE(global_name)->tp_name);\n                return NULL;\n            }\n        }\n        else if (PyErr_Occurred()) {\n            return NULL;\n        }\n        else {\n            \/* Check if the module was renamed. *\/\n            item = PyDict_GetItemWithError(st->import_mapping_2to3, module_name);\n            if (item) {\n                if (!PyUnicode_Check(item)) {\n                    PyErr_Format(PyExc_RuntimeError,\n                                \"_compat_pickle.IMPORT_MAPPING values should be \"\n                                \"strings, not %.200s\", Py_TYPE(item)->tp_name);\n                    return NULL;\n                }\n                module_name = item;\n            }\n            else if (PyErr_Occurred()) {\n                return NULL;\n            }\n        }\n    }\n\n    module = PyImport_GetModule(module_name);\n    if (module == NULL) {\n        if (PyErr_Occurred())\n            return NULL;\n        module = PyImport_Import(module_name);\n        if (module == NULL)\n            return NULL;\n    }\n    global = getattribute(module, global_name, self->proto >= 4);\n    Py_DECREF(module);\n    return global;\n}","target":0,"code_token_length":637,"total_token_length":873,"max_tokens_setting":1024}
+{"idx":518545,"func":"int Field_medium::store(double nr)\n{\n  ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;\n  int error= 0;\n  nr=rint(nr);\n  if (unsigned_flag)\n  {\n    if (nr < 0)\n    {\n      int3store(ptr,0);\n      set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);\n      error= 1;\n    }\n    else if (nr >= (double) (long) (1L << 24))\n    {\n      uint32 tmp=(uint32) (1L << 24)-1L;\n      int3store(ptr,tmp);\n      set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);\n      error= 1;\n    }\n    else\n      int3store(ptr,(uint32) nr);\n  }\n  else\n  {\n    if (nr < (double) INT_MIN24)\n    {\n      long tmp=(long) INT_MIN24;\n      int3store(ptr,tmp);\n      set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);\n      error= 1;\n    }\n    else if (nr > (double) INT_MAX24)\n    {\n      long tmp=(long) INT_MAX24;\n      int3store(ptr,tmp);\n      set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);\n      error= 1;\n    }\n    else\n      int3store(ptr,(long) nr);\n  }\n  return error;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":313271,"func":"  Ins_IDEF( INS_ARG )\n  {\n    TT_DefRecord*  def;\n    TT_DefRecord*  limit;\n\n\n    \/*  First of all, look for the same function in our table *\/\n\n    def   = CUR.IDefs;\n    limit = def + CUR.numIDefs;\n\n    for ( ; def < limit; def++ )\n      if ( def->opc == (FT_ULong)args[0] )\n        break;\n\n    if ( def == limit )\n    {\n      \/* check that there is enough room for a new instruction *\/\n      if ( CUR.numIDefs >= CUR.maxIDefs )\n      {\n        CUR.error = TT_Err_Too_Many_Instruction_Defs;\n        return;\n      }\n      CUR.numIDefs++;\n    }\n\n    \/* opcode must be unsigned 8-bit integer *\/\n    if ( 0 > args[0] || args[0] > 0x00FF )\n    {\n      CUR.error = TT_Err_Too_Many_Instruction_Defs;\n      return;\n    }\n\n    def->opc    = (FT_Byte)args[0];\n    def->start  = CUR.IP + 1;\n    def->range  = CUR.curRange;\n    def->active = TRUE;\n\n    if ( (FT_ULong)args[0] > CUR.maxIns )\n      CUR.maxIns = (FT_Byte)args[0];\n\n    \/* Now skip the whole function definition. *\/\n    \/* We don't allow nested IDEFs & FDEFs.    *\/\n\n    while ( SKIP_Code() == SUCCESS )\n    {\n      switch ( CUR.opcode )\n      {\n      case 0x89:   \/* IDEF *\/\n      case 0x2C:   \/* FDEF *\/\n        CUR.error = TT_Err_Nested_DEFS;\n        return;\n      case 0x2D:   \/* ENDF *\/\n        return;\n      }\n    }\n  }\n","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":12761,"func":"PHP_METHOD(Phar, delete)\n{\n\tchar *fname;\n\tsize_t fname_len;\n\tchar *error;\n\tphar_entry_info *entry;\n\tPHAR_ARCHIVE_OBJECT();\n\n\tif (PHAR_G(readonly) && !phar_obj->archive->is_data) {\n\t\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,\n\t\t\t\"Cannot write out phar archive, phar is read-only\");\n                return;\n        }\n \n       if (zend_parse_parameters(ZEND_NUM_ARGS(), \"s\", &fname, &fname_len) == FAILURE) {\n                RETURN_FALSE;\n        }\n \n\tif (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"phar \\\"%s\\\" is persistent, unable to copy on write\", phar_obj->archive->fname);\n\t\treturn;\n\t}\n\tif (zend_hash_str_exists(&phar_obj->archive->manifest, fname, (uint) fname_len)) {\n\t\tif (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint) fname_len))) {\n\t\t\tif (entry->is_deleted) {\n\t\t\t\t\/* entry is deleted, but has not been flushed to disk yet *\/\n\t\t\t\tRETURN_TRUE;\n\t\t\t} else {\n\t\t\t\tentry->is_deleted = 1;\n\t\t\t\tentry->is_modified = 1;\n\t\t\t\tphar_obj->archive->is_modified = 1;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tzend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \"Entry %s does not exist and cannot be deleted\", fname);\n\t\tRETURN_FALSE;\n\t}\n\n\tphar_flush(phar_obj->archive, NULL, 0, 0, &error);\n\tif (error) {\n\t\tzend_throw_exception_ex(phar_ce_PharException, 0, \"%s\", error);\n\t\tefree(error);\n\t}\n\n\tRETURN_TRUE;\n}\n","target":1,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":36596,"func":"compat_mpt_command(struct file *filp, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct mpt_ioctl_command32 karg32;\n\tstruct mpt_ioctl_command32 __user *uarg = (struct mpt_ioctl_command32 __user *) arg;\n\tstruct mpt_ioctl_command karg;\n\tMPT_ADAPTER *iocp = NULL;\n\tint iocnum, iocnumX;\n\tint nonblock = (filp->f_flags & O_NONBLOCK);\n\tint ret;\n\n\tif (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32)))\n\t\treturn -EFAULT;\n\n\t\/* Verify intended MPT adapter *\/\n\tiocnumX = karg32.hdr.iocnum & 0xFF;\n\tif (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||\n\t    (iocp == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"::compat_mpt_command @%d - ioc%d not found!\\n\",\n\t\t\t__LINE__, iocnumX);\n\t\treturn -ENODEV;\n\t}\n\n\tif ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)\n\t\treturn ret;\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"compat_mpt_command() called\\n\",\n\t    iocp->name));\n\t\/* Copy data to karg *\/\n\tkarg.hdr.iocnum = karg32.hdr.iocnum;\n\tkarg.hdr.port = karg32.hdr.port;\n\tkarg.timeout = karg32.timeout;\n\tkarg.maxReplyBytes = karg32.maxReplyBytes;\n\n\tkarg.dataInSize = karg32.dataInSize;\n\tkarg.dataOutSize = karg32.dataOutSize;\n\tkarg.maxSenseBytes = karg32.maxSenseBytes;\n\tkarg.dataSgeOffset = karg32.dataSgeOffset;\n\n\tkarg.replyFrameBufPtr = (char __user *)(unsigned long)karg32.replyFrameBufPtr;\n\tkarg.dataInBufPtr = (char __user *)(unsigned long)karg32.dataInBufPtr;\n\tkarg.dataOutBufPtr = (char __user *)(unsigned long)karg32.dataOutBufPtr;\n\tkarg.senseDataPtr = (char __user *)(unsigned long)karg32.senseDataPtr;\n\n\t\/* Pass new structure to do_mpt_command\n\t *\/\n\tret = mptctl_do_mpt_command (iocp, karg, &uarg->MF);\n\n\tmutex_unlock(&iocp->ioctl_cmds.mutex);\n\n\treturn ret;\n}","target":0,"code_token_length":555,"total_token_length":791,"max_tokens_setting":1024}
+{"idx":409501,"func":"static struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev)\n{\n\tstruct bnx2x *bp = netdev_priv(dev);\n\tstruct cnic_eth_dev *cp = &bp->cnic_eth_dev;\n\n\t\/* If both iSCSI and FCoE are disabled - return NULL in\n\t * order to indicate CNIC that it should not try to work\n\t * with this device.\n\t *\/\n\tif (NO_ISCSI(bp) && NO_FCOE(bp))\n\t\treturn NULL;\n\n\tcp->drv_owner = THIS_MODULE;\n\tcp->chip_id = CHIP_ID(bp);\n\tcp->pdev = bp->pdev;\n\tcp->io_base = bp->regview;\n\tcp->io_base2 = bp->doorbells;\n\tcp->max_kwqe_pending = 8;\n\tcp->ctx_blk_size = CDU_ILT_PAGE_SZ;\n\tcp->ctx_tbl_offset = FUNC_ILT_BASE(BP_FUNC(bp)) +\n\t\t\t     bnx2x_cid_ilt_lines(bp);\n\tcp->ctx_tbl_len = CNIC_ILT_LINES;\n\tcp->starting_cid = bnx2x_cid_ilt_lines(bp) * ILT_PAGE_CIDS;\n\tcp->drv_submit_kwqes_16 = bnx2x_cnic_sp_queue;\n\tcp->drv_ctl = bnx2x_drv_ctl;\n\tcp->drv_get_fc_npiv_tbl = bnx2x_get_fc_npiv;\n\tcp->drv_register_cnic = bnx2x_register_cnic;\n\tcp->drv_unregister_cnic = bnx2x_unregister_cnic;\n\tcp->fcoe_init_cid = BNX2X_FCOE_ETH_CID(bp);\n\tcp->iscsi_l2_client_id =\n\t\tbnx2x_cnic_eth_cl_id(bp, BNX2X_ISCSI_ETH_CL_ID_IDX);\n\tcp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID(bp);\n\n\tif (NO_ISCSI_OOO(bp))\n\t\tcp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO;\n\n\tif (NO_ISCSI(bp))\n\t\tcp->drv_state |= CNIC_DRV_STATE_NO_ISCSI;\n\n\tif (NO_FCOE(bp))\n\t\tcp->drv_state |= CNIC_DRV_STATE_NO_FCOE;\n\n\tBNX2X_DEV_INFO(\n\t\t\"page_size %d, tbl_offset %d, tbl_lines %d, starting cid %d\\n\",\n\t   cp->ctx_blk_size,\n\t   cp->ctx_tbl_offset,\n\t   cp->ctx_tbl_len,\n\t   cp->starting_cid);\n\treturn cp;\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":60184,"func":"static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,\n\t\t\t\t    struct tcp_fastopen_cookie *cookie)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *data = tp->syn_data ? tcp_write_queue_head(sk) : NULL;\n\tu16 mss = tp->rx_opt.mss_clamp, try_exp = 0;\n\tbool syn_drop = false;\n\n\tif (mss == tp->rx_opt.user_mss) {\n\t\tstruct tcp_options_received opt;\n\n\t\t\/* Get original SYNACK MSS value if user MSS sets mss_clamp *\/\n\t\ttcp_clear_options(&opt);\n\t\topt.user_mss = opt.mss_clamp = 0;\n\t\ttcp_parse_options(synack, &opt, 0, NULL);\n\t\tmss = opt.mss_clamp;\n\t}\n\n\tif (!tp->syn_fastopen) {\n\t\t\/* Ignore an unsolicited cookie *\/\n\t\tcookie->len = -1;\n\t} else if (tp->total_retrans) {\n\t\t\/* SYN timed out and the SYN-ACK neither has a cookie nor\n\t\t * acknowledges data. Presumably the remote received only\n\t\t * the retransmitted (regular) SYNs: either the original\n\t\t * SYN-data or the corresponding SYN-ACK was dropped.\n\t\t *\/\n\t\tsyn_drop = (cookie->len < 0 && data);\n\t} else if (cookie->len < 0 && !tp->syn_data) {\n\t\t\/* We requested a cookie but didn't get it. If we did not use\n\t\t * the (old) exp opt format then try so next time (try_exp=1).\n\t\t * Otherwise we go back to use the RFC7413 opt (try_exp=2).\n\t\t *\/\n\t\ttry_exp = tp->syn_fastopen_exp ? 2 : 1;\n\t}\n\n\ttcp_fastopen_cache_set(sk, mss, cookie, syn_drop, try_exp);\n\n\tif (data) { \/* Retransmit unacked data in SYN *\/\n\t\ttcp_for_write_queue_from(data, sk) {\n\t\t\tif (data == tcp_send_head(sk) ||\n\t\t\t    __tcp_retransmit_skb(sk, data))\n\t\t\t\tbreak;\n\t\t}\n\t\ttcp_rearm_rto(sk);\n\t\tNET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVEFAIL);\n\t\treturn true;\n\t}\n\ttp->syn_data_acked = tp->syn_data;\n\tif (tp->syn_data_acked)\n\t\tNET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVE);\n\treturn false;\n}","target":0,"code_token_length":546,"total_token_length":782,"max_tokens_setting":1024}
+{"idx":384808,"func":"static char *list_of_tainted_modules(const char *proc_modules)\n{\n    struct strbuf *result = strbuf_new();\n\n    const char *p = proc_modules;\n    for (;;)\n    {\n        const char *end = strchrnul(p, '\\n');\n        const char *paren = strchrnul(p, '(');\n        \/* We look for a line with this format:\n         * \"kvm_intel 126289 0 - Live 0xf829e000 (taint_flags)\"\n         * where taint_flags have letters\n         * (flags '+' and '-' indicate (un)loading, we must ignore them).\n         *\/\n        while (++paren < end)\n        {\n            if ((unsigned)(toupper(*paren) - 'A') <= 'Z'-'A')\n            {\n                strbuf_append_strf(result, result->len == 0 ? \"%.*s\" : \",%.*s\",\n                        (int)(strchrnul(p,' ') - p), p\n                );\n                break;\n            }\n            if (*paren == ')')\n                break;\n        }\n\n        if (*end == '\\0')\n            break;\n        p = end + 1;\n    }\n\n    if (result->len == 0)\n    {\n        strbuf_free(result);\n        return NULL;\n    }\n    return strbuf_free_nobuf(result);\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":304266,"func":"static void l2cap_sock_init(struct sock *sk, struct sock *parent)\n{\n\tstruct l2cap_pinfo *pi = l2cap_pi(sk);\n\tstruct l2cap_chan *chan = pi->chan;\n\n\tBT_DBG(\"sk %p\", sk);\n\n\tif (parent) {\n\t\tstruct l2cap_chan *pchan = l2cap_pi(parent)->chan;\n\n\t\tsk->sk_type = parent->sk_type;\n\t\tbt_sk(sk)->flags = bt_sk(parent)->flags;\n\n\t\tchan->chan_type = pchan->chan_type;\n\t\tchan->imtu = pchan->imtu;\n\t\tchan->omtu = pchan->omtu;\n\t\tchan->conf_state = pchan->conf_state;\n\t\tchan->mode = pchan->mode;\n\t\tchan->fcs  = pchan->fcs;\n\t\tchan->max_tx = pchan->max_tx;\n\t\tchan->tx_win = pchan->tx_win;\n\t\tchan->tx_win_max = pchan->tx_win_max;\n\t\tchan->sec_level = pchan->sec_level;\n\t\tchan->flags = pchan->flags;\n\n\t\tsecurity_sk_clone(parent, sk);\n\t} else {\n\n\t\tswitch (sk->sk_type) {\n\t\tcase SOCK_RAW:\n\t\t\tchan->chan_type = L2CAP_CHAN_RAW;\n\t\t\tbreak;\n\t\tcase SOCK_DGRAM:\n\t\t\tchan->chan_type = L2CAP_CHAN_CONN_LESS;\n\t\t\tbreak;\n\t\tcase SOCK_SEQPACKET:\n\t\tcase SOCK_STREAM:\n\t\t\tchan->chan_type = L2CAP_CHAN_CONN_ORIENTED;\n\t\t\tbreak;\n\t\t}\n\n\t\tchan->imtu = L2CAP_DEFAULT_MTU;\n\t\tchan->omtu = 0;\n\t\tif (!disable_ertm && sk->sk_type == SOCK_STREAM) {\n\t\t\tchan->mode = L2CAP_MODE_ERTM;\n\t\t\tset_bit(CONF_STATE2_DEVICE, &chan->conf_state);\n\t\t} else {\n\t\t\tchan->mode = L2CAP_MODE_BASIC;\n\t\t}\n\n\t\tl2cap_chan_set_defaults(chan);\n\t}\n\n\t\/* Default config options *\/\n\tchan->flush_to = L2CAP_DEFAULT_FLUSH_TO;\n\n\tchan->data = sk;\n\tchan->ops = &l2cap_chan_ops;\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":176236,"func":"void RenderFrameImpl::OnSerializeAsMHTML(\n    const FrameMsg_SerializeAsMHTML_Params& params) {\n  TRACE_EVENT0(\"page-serialization\", \"RenderFrameImpl::OnSerializeAsMHTML\");\n  base::TimeTicks start_time = base::TimeTicks::Now();\n  base::File file = IPC::PlatformFileForTransitToFile(params.destination_file);\n  const WebString mhtml_boundary =\n      WebString::FromUTF8(params.mhtml_boundary_marker);\n  DCHECK(!mhtml_boundary.IsEmpty());\n\n  std::vector<WebThreadSafeData> mhtml_contents;\n  std::set<std::string> serialized_resources_uri_digests;\n  MHTMLPartsGenerationDelegate delegate(params,\n                                        &serialized_resources_uri_digests);\n\n  MhtmlSaveStatus save_status = MhtmlSaveStatus::SUCCESS;\n  bool has_some_data = false;\n\n  if (IsMainFrame()) {\n    TRACE_EVENT0(\"page-serialization\",\n                 \"RenderFrameImpl::OnSerializeAsMHTML header\");\n    mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLHeader(\n        mhtml_boundary, GetWebFrame(), &delegate));\n    if (mhtml_contents.back().IsEmpty())\n      save_status = MhtmlSaveStatus::FRAME_SERIALIZATION_FORBIDDEN;\n    else\n      has_some_data = true;\n  }\n\n  if (save_status == MhtmlSaveStatus::SUCCESS) {\n    TRACE_EVENT0(\"page-serialization\",\n                 \"RenderFrameImpl::OnSerializeAsMHTML parts serialization\");\n    mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLParts(\n        mhtml_boundary, GetWebFrame(), &delegate));\n    has_some_data |= !mhtml_contents.back().IsEmpty();\n  }\n\n\n  base::TimeDelta main_thread_use_time = base::TimeTicks::Now() - start_time;\n  UMA_HISTOGRAM_TIMES(\n      \"PageSerialization.MhtmlGeneration.RendererMainThreadTime.SingleFrame\",\n      main_thread_use_time);\n\n  if (save_status == MhtmlSaveStatus::SUCCESS && has_some_data) {\n    base::PostTaskWithTraitsAndReplyWithResult(\n        FROM_HERE, {base::MayBlock()},\n        base::Bind(&WriteMHTMLToDisk, base::Passed(&mhtml_contents),\n                   base::Passed(&file)),\n        base::Bind(&RenderFrameImpl::OnWriteMHTMLToDiskComplete,\n                   weak_factory_.GetWeakPtr(), params.job_id,\n                   base::Passed(&serialized_resources_uri_digests),\n                   main_thread_use_time));\n  } else {\n    file.Close();\n    OnWriteMHTMLToDiskComplete(params.job_id, serialized_resources_uri_digests,\n                               main_thread_use_time, save_status);\n  }\n}\n","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":426785,"func":"int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions,\n\t\t      int protocol)\n{\n\tsocklen_t addr_len;\n\tint sndbuf = 32768;\n\tint one = 1;\n\n\tmemset(rth, 0, sizeof(*rth));\n\n\trth->proto = protocol;\n\trth->fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, protocol);\n\tif (rth->fd < 0) {\n\t\tperror(\"Cannot open netlink socket\");\n\t\treturn -1;\n\t}\n\n\tif (setsockopt(rth->fd, SOL_SOCKET, SO_SNDBUF,\n\t\t       &sndbuf, sizeof(sndbuf)) < 0) {\n\t\tperror(\"SO_SNDBUF\");\n\t\treturn -1;\n\t}\n\n\tif (setsockopt(rth->fd, SOL_SOCKET, SO_RCVBUF,\n\t\t       &rcvbuf, sizeof(rcvbuf)) < 0) {\n\t\tperror(\"SO_RCVBUF\");\n\t\treturn -1;\n\t}\n\n\t\/* Older kernels may no support extended ACK reporting *\/\n\tsetsockopt(rth->fd, SOL_NETLINK, NETLINK_EXT_ACK,\n\t\t   &one, sizeof(one));\n\n\tmemset(&rth->local, 0, sizeof(rth->local));\n\trth->local.nl_family = AF_NETLINK;\n\trth->local.nl_groups = subscriptions;\n\n\tif (bind(rth->fd, (struct sockaddr *)&rth->local,\n\t\t sizeof(rth->local)) < 0) {\n\t\tperror(\"Cannot bind netlink socket\");\n\t\treturn -1;\n\t}\n\taddr_len = sizeof(rth->local);\n\tif (getsockname(rth->fd, (struct sockaddr *)&rth->local,\n\t\t\t&addr_len) < 0) {\n\t\tperror(\"Cannot getsockname\");\n\t\treturn -1;\n\t}\n\tif (addr_len != sizeof(rth->local)) {\n\t\tfprintf(stderr, \"Wrong address length %d\\n\", addr_len);\n\t\treturn -1;\n\t}\n\tif (rth->local.nl_family != AF_NETLINK) {\n\t\tfprintf(stderr, \"Wrong address family %d\\n\",\n\t\t\trth->local.nl_family);\n\t\treturn -1;\n\t}\n\trth->seq = time(NULL);\n\treturn 0;\n}","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":1026,"func":"static void _SCSUReset ( UConverter * cnv , UConverterResetChoice choice ) {\n SCSUData * scsu = ( SCSUData * ) cnv -> extraInfo ;\n if ( choice <= UCNV_RESET_TO_UNICODE ) {\n uprv_memcpy ( scsu -> toUDynamicOffsets , initialDynamicOffsets , 32 ) ;\n scsu -> toUIsSingleByteMode = TRUE ;\n scsu -> toUState = readCommand ;\n scsu -> toUQuoteWindow = scsu -> toUDynamicWindow = 0 ;\n scsu -> toUByteOne = 0 ;\n cnv -> toULength = 0 ;\n }\n if ( choice != UCNV_RESET_TO_UNICODE ) {\n uprv_memcpy ( scsu -> fromUDynamicOffsets , initialDynamicOffsets , 32 ) ;\n scsu -> fromUIsSingleByteMode = TRUE ;\n scsu -> fromUDynamicWindow = 0 ;\n scsu -> nextWindowUseIndex = 0 ;\n switch ( scsu -> locale ) {\n case l_ja : uprv_memcpy ( scsu -> windowUse , initialWindowUse_ja , 8 ) ;\n break ;\n default : uprv_memcpy ( scsu -> windowUse , initialWindowUse , 8 ) ;\n break ;\n }\n cnv -> fromUChar32 = 0 ;\n }\n }","target":1,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":75697,"func":"TfLiteStatus LogicalImpl(TfLiteContext* context, TfLiteNode* node,\n                         bool (*func)(bool, bool)) {\n  OpData* data = reinterpret_cast<OpData*>(node->user_data);\n\n  const TfLiteTensor* input1;\n  TF_LITE_ENSURE_OK(context,\n                    GetInputSafe(context, node, kInputTensor1, &input1));\n  const TfLiteTensor* input2;\n  TF_LITE_ENSURE_OK(context,\n                    GetInputSafe(context, node, kInputTensor2, &input2));\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context,\n                    GetOutputSafe(context, node, kOutputTensor, &output));\n\n  if (data->requires_broadcast) {\n    reference_ops::BroadcastBinaryFunction4DSlow<bool, bool, bool>(\n        GetTensorShape(input1), GetTensorData<bool>(input1),\n        GetTensorShape(input2), GetTensorData<bool>(input2),\n        GetTensorShape(output), GetTensorData<bool>(output), func);\n  } else {\n    reference_ops::BinaryFunction<bool, bool, bool>(\n        GetTensorShape(input1), GetTensorData<bool>(input1),\n        GetTensorShape(input2), GetTensorData<bool>(input2),\n        GetTensorShape(output), GetTensorData<bool>(output), func);\n  }\n\n  return kTfLiteOk;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":107801,"func":"static struct task_struct *dup_task_struct(struct task_struct *orig)\n{\n\tstruct task_struct *tsk;\n\tstruct thread_info *ti;\n\tunsigned long *stackend;\n\tint node = tsk_fork_get_node(orig);\n\tint err;\n\n\ttsk = alloc_task_struct_node(node);\n\tif (!tsk)\n\t\treturn NULL;\n\n\tti = alloc_thread_info_node(tsk, node);\n\tif (!ti)\n\t\tgoto free_tsk;\n\n\terr = arch_dup_task_struct(tsk, orig);\n\tif (err)\n\t\tgoto free_ti;\n\n\ttsk->stack = ti;\n\n\tsetup_thread_stack(tsk, orig);\n\tclear_user_return_notifier(tsk);\n\tclear_tsk_need_resched(tsk);\n\tstackend = end_of_stack(tsk);\n\t*stackend = STACK_END_MAGIC;\t\/* for overflow detection *\/\n\n#ifdef CONFIG_CC_STACKPROTECTOR\n\ttsk->stack_canary = get_random_int();\n#endif\n\n\t\/*\n\t * One for us, one for whoever does the \"release_task()\" (usually\n\t * parent)\n\t *\/\n\tatomic_set(&tsk->usage, 2);\n#ifdef CONFIG_BLK_DEV_IO_TRACE\n\ttsk->btrace_seq = 0;\n#endif\n\ttsk->splice_pipe = NULL;\n\ttsk->task_frag.page = NULL;\n\n\taccount_kernel_stack(ti, 1);\n\n\treturn tsk;\n\nfree_ti:\n\tfree_thread_info(ti);\nfree_tsk:\n\tfree_task_struct(tsk);\n\treturn NULL;\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":66576,"func":"GF_Err gf_isom_clone_pssh(GF_ISOFile *output, GF_ISOFile *input, Bool in_moof) {\n\tGF_Box *a;\n\tu32 i;\n\ti = 0;\n\n\twhile ((a = (GF_Box *)gf_list_enum(input->moov->child_boxes, &i))) {\n\t\tif (a->type == GF_ISOM_BOX_TYPE_PSSH) {\n\t\t\tGF_List **child_boxes = &output->moov->child_boxes;\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (in_moof)\n\t\t\t\tchild_boxes = &output->moof->child_boxes;\n#endif\n\n\t\t\tGF_ProtectionSystemHeaderBox *pssh = (GF_ProtectionSystemHeaderBox *)gf_isom_box_new_parent(child_boxes, GF_ISOM_BOX_TYPE_PSSH);\n\t\t\tif (!pssh) return GF_OUT_OF_MEM;\n\t\t\tmemmove(pssh->SystemID, ((GF_ProtectionSystemHeaderBox *)a)->SystemID, 16);\n\t\t\tif (((GF_ProtectionSystemHeaderBox *)a)->KIDs && ((GF_ProtectionSystemHeaderBox *)a)->KID_count > 0) {\n\t\t\t\tpssh->KID_count = ((GF_ProtectionSystemHeaderBox *)a)->KID_count;\n\t\t\t\tpssh->KIDs = (bin128 *)gf_malloc(pssh->KID_count*sizeof(bin128));\n\t\t\t\tif (!pssh->KIDs) return GF_OUT_OF_MEM;\n\t\t\t\tmemmove(pssh->KIDs, ((GF_ProtectionSystemHeaderBox *)a)->KIDs, pssh->KID_count*sizeof(bin128));\n\t\t\t}\n\t\t\tpssh->private_data_size = ((GF_ProtectionSystemHeaderBox *)a)->private_data_size;\n\t\t\tpssh->private_data = (u8 *)gf_malloc(pssh->private_data_size*sizeof(char));\n\t\t\tif (!pssh->private_data) return GF_OUT_OF_MEM;\n\t\t\tmemmove(pssh->private_data, ((GF_ProtectionSystemHeaderBox *)a)->private_data, pssh->private_data_size);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":202183,"func":"bool Document::ParseQualifiedName(const AtomicString& qualified_name,\n                                  AtomicString& prefix,\n                                  AtomicString& local_name,\n                                  ExceptionState& exception_state) {\n  unsigned length = qualified_name.length();\n\n  if (!length) {\n    exception_state.ThrowDOMException(DOMExceptionCode::kInvalidCharacterError,\n                                      \"The qualified name provided is empty.\");\n    return false;\n  }\n\n  ParseQualifiedNameResult return_value;\n  if (qualified_name.Is8Bit())\n    return_value =\n        ParseQualifiedNameInternal(qualified_name, qualified_name.Characters8(),\n                                   length, prefix, local_name);\n  else\n    return_value = ParseQualifiedNameInternal(qualified_name,\n                                              qualified_name.Characters16(),\n                                              length, prefix, local_name);\n  if (return_value.status == kQNValid)\n    return true;\n\n  StringBuilder message;\n  message.Append(\"The qualified name provided ('\");\n  message.Append(qualified_name);\n  message.Append(\"') \");\n\n  if (return_value.status == kQNMultipleColons) {\n    message.Append(\"contains multiple colons.\");\n  } else if (return_value.status == kQNInvalidStartChar) {\n    message.Append(\"contains the invalid name-start character '\");\n    message.Append(return_value.character);\n    message.Append(\"'.\");\n  } else if (return_value.status == kQNInvalidChar) {\n    message.Append(\"contains the invalid character '\");\n    message.Append(return_value.character);\n    message.Append(\"'.\");\n  } else if (return_value.status == kQNEmptyPrefix) {\n    message.Append(\"has an empty namespace prefix.\");\n  } else {\n    DCHECK_EQ(return_value.status, kQNEmptyLocalName);\n    message.Append(\"has an empty local name.\");\n  }\n\n  exception_state.ThrowDOMException(DOMExceptionCode::kInvalidCharacterError,\n                                    message.ToString());\n  return false;\n}\n","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":385048,"func":"static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)\n{\n\tphp_curl       *ch  = (php_curl *) ctx;\n\tphp_curl_write *t   = ch->handlers->write_header;\n\tsize_t          length = size * nmemb;\n\tTSRMLS_FETCH_FROM_CTX(ch->thread_ctx);\n\n\tswitch (t->method) {\n\t\tcase PHP_CURL_STDOUT:\n\t\t\t\/* Handle special case write when we're returning the entire transfer\n\t\t\t *\/\n\t\t\tif (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) {\n\t\t\t\tsmart_str_appendl(&ch->handlers->write->buf, data, (int) length);\n\t\t\t} else {\n\t\t\t\tPHPWRITE(data, length);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase PHP_CURL_FILE:\n\t\t\treturn fwrite(data, size, nmemb, t->fp);\n\t\tcase PHP_CURL_USER: {\n\t\t\tzval **argv[2];\n\t\t\tzval  *handle = NULL;\n\t\t\tzval  *zdata = NULL;\n\t\t\tzval  *retval_ptr;\n\t\t\tint   error;\n\t\t\tzend_fcall_info fci;\n\n\t\t\tMAKE_STD_ZVAL(handle);\n\t\t\tMAKE_STD_ZVAL(zdata);\n\n\t\t\tZVAL_RESOURCE(handle, ch->id);\n\t\t\tzend_list_addref(ch->id);\n\t\t\tZVAL_STRINGL(zdata, data, length, 1);\n\n\t\t\targv[0] = &handle;\n\t\t\targv[1] = &zdata;\n\n\t\t\tfci.size = sizeof(fci);\n\t\t\tfci.function_table = EG(function_table);\n\t\t\tfci.function_name = t->func_name;\n\t\t\tfci.symbol_table = NULL;\n\t\t\tfci.object_ptr = NULL;\n\t\t\tfci.retval_ptr_ptr = &retval_ptr;\n\t\t\tfci.param_count = 2;\n\t\t\tfci.params = argv;\n\t\t\tfci.no_separation = 0;\n\n\t\t\tch->in_callback = 1;\n\t\t\terror = zend_call_function(&fci, &t->fci_cache TSRMLS_CC);\n\t\t\tch->in_callback = 0;\n\t\t\tif (error == FAILURE) {\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Could not call the CURLOPT_HEADERFUNCTION\");\n\t\t\t\tlength = -1;\n\t\t\t} else if (retval_ptr) {\n\t\t\t\t_php_curl_verify_handlers(ch, 1 TSRMLS_CC);\n\t\t\t\tif (Z_TYPE_P(retval_ptr) != IS_LONG) {\n\t\t\t\t\tconvert_to_long_ex(&retval_ptr);\n\t\t\t\t}\n\t\t\t\tlength = Z_LVAL_P(retval_ptr);\n\t\t\t\tzval_ptr_dtor(&retval_ptr);\n\t\t\t}\n\t\t\tzval_ptr_dtor(argv[0]);\n\t\t\tzval_ptr_dtor(argv[1]);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PHP_CURL_IGNORE:\n\t\t\treturn length;\n\n\t\tdefault:\n\t\t\treturn -1;\n\t}\n\n\treturn length;\n}","target":0,"code_token_length":606,"total_token_length":842,"max_tokens_setting":1024}
+{"idx":79521,"func":"static void __collapse_huge_page_copy(pte_t *pte, struct page *page,\n\t\t\t\t      struct vm_area_struct *vma,\n\t\t\t\t      unsigned long address,\n\t\t\t\t      spinlock_t *ptl)\n{\n\tpte_t *_pte;\n\tfor (_pte = pte; _pte < pte+HPAGE_PMD_NR; _pte++) {\n\t\tpte_t pteval = *_pte;\n\t\tstruct page *src_page;\n\n\t\tif (pte_none(pteval)) {\n\t\t\tclear_user_highpage(page, address);\n\t\t\tadd_mm_counter(vma->vm_mm, MM_ANONPAGES, 1);\n\t\t} else {\n\t\t\tsrc_page = pte_page(pteval);\n\t\t\tcopy_user_highpage(page, src_page, address, vma);\n\t\t\tVM_BUG_ON(page_mapcount(src_page) != 1);\n\t\t\tVM_BUG_ON(page_count(src_page) != 2);\n\t\t\trelease_pte_page(src_page);\n\t\t\t\/*\n\t\t\t * ptl mostly unnecessary, but preempt has to\n\t\t\t * be disabled to update the per-cpu stats\n\t\t\t * inside page_remove_rmap().\n\t\t\t *\/\n\t\t\tspin_lock(ptl);\n\t\t\t\/*\n\t\t\t * paravirt calls inside pte_clear here are\n\t\t\t * superfluous.\n\t\t\t *\/\n\t\t\tpte_clear(vma->vm_mm, address, _pte);\n\t\t\tpage_remove_rmap(src_page);\n\t\t\tspin_unlock(ptl);\n\t\t\tfree_page_and_swap_cache(src_page);\n\t\t}\n\n\t\taddress += PAGE_SIZE;\n\t\tpage++;\n\t}\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":462438,"func":"static inline void ConvertXYZToAdobe98(const double X,const double Y,\n  const double Z,double *red,double *green,double *blue)\n{\n  double\n    b,\n    g,\n    r;\n\n  assert(red != (double *) NULL);\n  assert(green != (double *) NULL);\n  assert(blue != (double *) NULL);\n  r=2.041587903810746500*X-0.56500697427885960*Y-0.34473135077832956*Z;\n  g=(-0.969243636280879500)*X+1.87596750150772020*Y+0.04155505740717557*Z;\n  b=0.013444280632031142*X-0.11836239223101838*Y+1.01517499439120540*Z;\n  *red=EncodePixelGamma(QuantumRange*r);\n  *green=EncodePixelGamma(QuantumRange*g);\n  *blue=EncodePixelGamma(QuantumRange*b);\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":35046,"func":"static ssize_t ib_ucm_event(struct ib_ucm_file *file,\n\t\t\t    const char __user *inbuf,\n\t\t\t    int in_len, int out_len)\n{\n\tstruct ib_ucm_context *ctx;\n\tstruct ib_ucm_event_get cmd;\n\tstruct ib_ucm_event *uevent;\n\tint result = 0;\n\n\tif (out_len < sizeof(struct ib_ucm_event_resp))\n\t\treturn -ENOSPC;\n\n\tif (copy_from_user(&cmd, inbuf, sizeof(cmd)))\n\t\treturn -EFAULT;\n\n\tmutex_lock(&file->file_mutex);\n\twhile (list_empty(&file->events)) {\n\t\tmutex_unlock(&file->file_mutex);\n\n\t\tif (file->filp->f_flags & O_NONBLOCK)\n\t\t\treturn -EAGAIN;\n\n\t\tif (wait_event_interruptible(file->poll_wait,\n\t\t\t\t\t     !list_empty(&file->events)))\n\t\t\treturn -ERESTARTSYS;\n\n\t\tmutex_lock(&file->file_mutex);\n\t}\n\n\tuevent = list_entry(file->events.next, struct ib_ucm_event, file_list);\n\n\tif (ib_ucm_new_cm_id(uevent->resp.event)) {\n\t\tctx = ib_ucm_ctx_alloc(file);\n\t\tif (!ctx) {\n\t\t\tresult = -ENOMEM;\n\t\t\tgoto done;\n\t\t}\n\n\t\tctx->cm_id = uevent->cm_id;\n\t\tctx->cm_id->context = ctx;\n\t\tuevent->resp.id = ctx->id;\n\t}\n\n\tif (copy_to_user((void __user *)(unsigned long)cmd.response,\n\t\t\t &uevent->resp, sizeof(uevent->resp))) {\n\t\tresult = -EFAULT;\n\t\tgoto done;\n\t}\n\n\tif (uevent->data) {\n\t\tif (cmd.data_len < uevent->data_len) {\n\t\t\tresult = -ENOMEM;\n\t\t\tgoto done;\n\t\t}\n\t\tif (copy_to_user((void __user *)(unsigned long)cmd.data,\n\t\t\t\t uevent->data, uevent->data_len)) {\n\t\t\tresult = -EFAULT;\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\tif (uevent->info) {\n\t\tif (cmd.info_len < uevent->info_len) {\n\t\t\tresult = -ENOMEM;\n\t\t\tgoto done;\n\t\t}\n\t\tif (copy_to_user((void __user *)(unsigned long)cmd.info,\n\t\t\t\t uevent->info, uevent->info_len)) {\n\t\t\tresult = -EFAULT;\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\tlist_del(&uevent->file_list);\n\tlist_del(&uevent->ctx_list);\n\tuevent->ctx->events_reported++;\n\n\tkfree(uevent->data);\n\tkfree(uevent->info);\n\tkfree(uevent);\ndone:\n\tmutex_unlock(&file->file_mutex);\n\treturn result;\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":346183,"func":"PHP_METHOD(Phar, addFile)\n{\n\tchar *fname, *localname = NULL;\n\tsize_t fname_len, localname_len = 0;\n\tphp_stream *resource;\n\tzval zresource;\n\n\tPHAR_ARCHIVE_OBJECT();\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"s|s\", &fname, &fname_len, &localname, &localname_len) == FAILURE) {\n\t\treturn;\n\t}\n\n#if PHP_API_VERSION < 20100412\n\tif (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {\n\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0, \"phar error: unable to open file \\\"%s\\\" to add to phar archive, safe_mode restrictions prevent this\", fname);\n\t\treturn;\n\t}\n#endif\n\n\tif (!strstr(fname, \":\/\/\") && php_check_open_basedir(fname)) {\n\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0, \"phar error: unable to open file \\\"%s\\\" to add to phar archive, open_basedir restrictions prevent this\", fname);\n\t\treturn;\n\t}\n\n\tif (!(resource = php_stream_open_wrapper(fname, \"rb\", 0, NULL))) {\n\t\tzend_throw_exception_ex(spl_ce_RuntimeException, 0, \"phar error: unable to open file \\\"%s\\\" to add to phar archive\", fname);\n\t\treturn;\n\t}\n\n\tif (localname) {\n\t\tfname = localname;\n\t\tfname_len = localname_len;\n\t}\n\n\tphp_stream_to_zval(resource, &zresource);\n\tphar_add_file(&(phar_obj->archive), fname, fname_len, NULL, 0, &zresource);\n\tzval_ptr_dtor(&zresource);\n}","target":1,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":439702,"func":"void SplashOutputDev::paintTransparencyGroup(GfxState *state, const double *bbox) {\n  SplashBitmap *tBitmap;\n  SplashTransparencyGroup *transpGroup;\n  bool isolated;\n  int tx, ty;\n\n  tx = transpGroupStack->tx;\n  ty = transpGroupStack->ty;\n  tBitmap = transpGroupStack->tBitmap;\n  isolated = transpGroupStack->isolated;\n\n  \/\/ paint the transparency group onto the parent bitmap\n  \/\/ - the clip path was set in the parent's state)\n  if (tx < bitmap->getWidth() && ty < bitmap->getHeight()) {\n    SplashCoord knockoutOpacity = (transpGroupStack->next != nullptr) ? transpGroupStack->next->knockoutOpacity\n                                                                   : transpGroupStack->knockoutOpacity;\n    splash->setOverprintMask(0xffffffff, false);\n    splash->composite(tBitmap, 0, 0, tx, ty,\n      tBitmap->getWidth(), tBitmap->getHeight(),\n      false, !isolated, transpGroupStack->next != nullptr && transpGroupStack->next->knockout, knockoutOpacity);\n    fontEngine->setAA(transpGroupStack->fontAA);\n    if (transpGroupStack->next != nullptr && transpGroupStack->next->shape != nullptr) {\n      transpGroupStack->next->knockout = true;\n    }\n  }\n\n  \/\/ pop the stack\n  transpGroup = transpGroupStack;\n  transpGroupStack = transpGroup->next;\n  if (transpGroupStack != nullptr && transpGroup->knockoutOpacity < transpGroupStack->knockoutOpacity) {\n    transpGroupStack->knockoutOpacity = transpGroup->knockoutOpacity;\n  }\n  delete transpGroup->shape;\n  delete transpGroup;\n\n  delete tBitmap;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":312411,"func":"GLES2DecoderPassthroughImpl::GLES2DecoderPassthroughImpl(\n    DecoderClient* client,\n    CommandBufferServiceBase* command_buffer_service,\n    Outputter* outputter,\n    ContextGroup* group)\n    : GLES2Decoder(client, command_buffer_service, outputter),\n      commands_to_process_(0),\n      debug_marker_manager_(),\n      logger_(&debug_marker_manager_,\n              base::BindRepeating(&DecoderClient::OnConsoleMessage,\n                                  base::Unretained(client),\n                                  0),\n              group->gpu_preferences().disable_gl_error_limit),\n      surface_(),\n      context_(),\n      offscreen_(false),\n      group_(group),\n      feature_info_(new FeatureInfo(group->feature_info()->workarounds(),\n                                    group->gpu_feature_info())),\n      emulated_back_buffer_(nullptr),\n      offscreen_single_buffer_(false),\n      offscreen_target_buffer_preserved_(false),\n      create_color_buffer_count_for_test_(0),\n      max_2d_texture_size_(0),\n      bound_draw_framebuffer_(0),\n      bound_read_framebuffer_(0),\n      gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(\n          TRACE_DISABLED_BY_DEFAULT(\"gpu.decoder\"))),\n      gpu_trace_level_(2),\n      gpu_trace_commands_(false),\n      gpu_debug_commands_(false),\n      has_robustness_extension_(false),\n      context_lost_(false),\n      reset_by_robustness_extension_(false),\n      lose_context_when_out_of_memory_(false),\n      weak_ptr_factory_(this) {\n  DCHECK(client);\n  DCHECK(group);\n}\n","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":362325,"func":"static void svm_complete_interrupts(struct vcpu_svm *svm)\n{\n\tu8 vector;\n\tint type;\n\tu32 exitintinfo = svm->vmcb->control.exit_int_info;\n\tunsigned int3_injected = svm->int3_injected;\n\n\tsvm->int3_injected = 0;\n\n\tif (svm->vcpu.arch.hflags & HF_IRET_MASK)\n\t\tsvm->vcpu.arch.hflags &= ~(HF_NMI_MASK | HF_IRET_MASK);\n\n\tsvm->vcpu.arch.nmi_injected = false;\n\tkvm_clear_exception_queue(&svm->vcpu);\n\tkvm_clear_interrupt_queue(&svm->vcpu);\n\n\tif (!(exitintinfo & SVM_EXITINTINFO_VALID))\n\t\treturn;\n\n\tvector = exitintinfo & SVM_EXITINTINFO_VEC_MASK;\n\ttype = exitintinfo & SVM_EXITINTINFO_TYPE_MASK;\n\n\tswitch (type) {\n\tcase SVM_EXITINTINFO_TYPE_NMI:\n\t\tsvm->vcpu.arch.nmi_injected = true;\n\t\tbreak;\n\tcase SVM_EXITINTINFO_TYPE_EXEPT:\n\t\t\/*\n\t\t * In case of software exceptions, do not reinject the vector,\n\t\t * but re-execute the instruction instead. Rewind RIP first\n\t\t * if we emulated INT3 before.\n\t\t *\/\n\t\tif (kvm_exception_is_soft(vector)) {\n\t\t\tif (vector == BP_VECTOR && int3_injected &&\n\t\t\t    kvm_is_linear_rip(&svm->vcpu, svm->int3_rip))\n\t\t\t\tkvm_rip_write(&svm->vcpu,\n\t\t\t\t\t      kvm_rip_read(&svm->vcpu) -\n\t\t\t\t\t      int3_injected);\n\t\t\tbreak;\n\t\t}\n\t\tif (exitintinfo & SVM_EXITINTINFO_VALID_ERR) {\n\t\t\tu32 err = svm->vmcb->control.exit_int_info_err;\n\t\t\tkvm_requeue_exception_e(&svm->vcpu, vector, err);\n\n\t\t} else\n\t\t\tkvm_requeue_exception(&svm->vcpu, vector);\n\t\tbreak;\n\tcase SVM_EXITINTINFO_TYPE_INTR:\n\t\tkvm_queue_interrupt(&svm->vcpu, vector, false);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":324288,"func":"void helper_ldda_asi(target_ulong addr, int asi, int rd)\n\n{\n\n    if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0)\n\n        || ((env->def->features & CPU_FEATURE_HYPV)\n\n            && asi >= 0x30 && asi < 0x80\n\n            && !(env->hpstate & HS_PRIV)))\n\n        raise_exception(TT_PRIV_ACT);\n\n\n\n    switch (asi) {\n\n    case 0x24: \/\/ Nucleus quad LDD 128 bit atomic\n\n    case 0x2c: \/\/ Nucleus quad LDD 128 bit atomic LE\n\n        helper_check_align(addr, 0xf);\n\n        if (rd == 0) {\n\n            env->gregs[1] = ldq_kernel(addr + 8);\n\n            if (asi == 0x2c)\n\n                bswap64s(&env->gregs[1]);\n\n        } else if (rd < 8) {\n\n            env->gregs[rd] = ldq_kernel(addr);\n\n            env->gregs[rd + 1] = ldq_kernel(addr + 8);\n\n            if (asi == 0x2c) {\n\n                bswap64s(&env->gregs[rd]);\n\n                bswap64s(&env->gregs[rd + 1]);\n\n            }\n\n        } else {\n\n            env->regwptr[rd] = ldq_kernel(addr);\n\n            env->regwptr[rd + 1] = ldq_kernel(addr + 8);\n\n            if (asi == 0x2c) {\n\n                bswap64s(&env->regwptr[rd]);\n\n                bswap64s(&env->regwptr[rd + 1]);\n\n            }\n\n        }\n\n        break;\n\n    default:\n\n        helper_check_align(addr, 0x3);\n\n        if (rd == 0)\n\n            env->gregs[1] = helper_ld_asi(addr + 4, asi, 4, 0);\n\n        else if (rd < 8) {\n\n            env->gregs[rd] = helper_ld_asi(addr, asi, 4, 0);\n\n            env->gregs[rd + 1] = helper_ld_asi(addr + 4, asi, 4, 0);\n\n        } else {\n\n            env->regwptr[rd] = helper_ld_asi(addr, asi, 4, 0);\n\n            env->regwptr[rd + 1] = helper_ld_asi(addr + 4, asi, 4, 0);\n\n        }\n\n        break;\n\n    }\n\n}\n","target":1,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":399786,"func":"static int vnc_update_client(VncState *vs, int has_dirty)\n{\n    if (vs->need_update && vs->csock != -1) {\n        VncDisplay *vd = vs->vd;\n        VncJob *job;\n        int y;\n        int width, height;\n        int n = 0;\n\n\n        if (vs->output.offset && !vs->audio_cap && !vs->force_update)\n            \/* kernel send buffers are full -> drop frames to throttle *\/\n            return 0;\n\n        if (!has_dirty && !vs->audio_cap && !vs->force_update)\n            return 0;\n\n        \/*\n         * Send screen updates to the vnc client using the server\n         * surface and server dirty map.  guest surface updates\n         * happening in parallel don't disturb us, the next pass will\n         * send them to the client.\n         *\/\n        job = vnc_job_new(vs);\n\n        width = MIN(pixman_image_get_width(vd->server), vs->client_width);\n        height = MIN(pixman_image_get_height(vd->server), vs->client_height);\n\n        for (y = 0; y < height; y++) {\n            int x;\n            int last_x = -1;\n            for (x = 0; x < width \/ 16; x++) {\n                if (test_and_clear_bit(x, vs->dirty[y])) {\n                    if (last_x == -1) {\n                        last_x = x;\n                    }\n                } else {\n                    if (last_x != -1) {\n                        int h = find_and_clear_dirty_height(vs, y, last_x, x,\n                                                            height);\n\n                        n += vnc_job_add_rect(job, last_x * 16, y,\n                                              (x - last_x) * 16, h);\n                    }\n                    last_x = -1;\n                }\n            }\n            if (last_x != -1) {\n                int h = find_and_clear_dirty_height(vs, y, last_x, x, height);\n                n += vnc_job_add_rect(job, last_x * 16, y,\n                                      (x - last_x) * 16, h);\n            }\n        }\n\n        vnc_job_push(job);\n        vs->force_update = 0;\n        return n;\n    }\n\n    if (vs->csock == -1)\n        vnc_disconnect_finish(vs);\n\n    return 0;\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":347057,"func":"MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,\n                                        MemTxAttrs attrs, uint8_t *buf,\n                                        int len, hwaddr addr1, hwaddr l,\n                                        MemoryRegion *mr)\n{\n    uint8_t *ptr;\n    uint64_t val;\n    MemTxResult result = MEMTX_OK;\n    bool release_lock = false;\n\n    for (;;) {\n        if (!memory_access_is_direct(mr, false)) {\n            \/* I\/O case *\/\n            release_lock |= prepare_mmio_access(mr);\n            l = memory_access_size(mr, l, addr1);\n            switch (l) {\n            case 8:\n                \/* 64 bit read access *\/\n                result |= memory_region_dispatch_read(mr, addr1, &val, 8,\n                                                      attrs);\n                stq_p(buf, val);\n                break;\n            case 4:\n                \/* 32 bit read access *\/\n                result |= memory_region_dispatch_read(mr, addr1, &val, 4,\n                                                      attrs);\n                stl_p(buf, val);\n                break;\n            case 2:\n                \/* 16 bit read access *\/\n                result |= memory_region_dispatch_read(mr, addr1, &val, 2,\n                                                      attrs);\n                stw_p(buf, val);\n                break;\n            case 1:\n                \/* 8 bit read access *\/\n                result |= memory_region_dispatch_read(mr, addr1, &val, 1,\n                                                      attrs);\n                stb_p(buf, val);\n                break;\n            default:\n                abort();\n            }\n        } else {\n            \/* RAM case *\/\n            ptr = qemu_map_ram_ptr(mr->ram_block, addr1);\n            memcpy(buf, ptr, l);\n        }\n\n        if (release_lock) {\n            qemu_mutex_unlock_iothread();\n            release_lock = false;\n        }\n\n        len -= l;\n        buf += l;\n        addr += l;\n\n        if (!len) {\n            break;\n        }\n\n        l = len;\n        mr = address_space_translate(as, addr, &addr1, &l, false);\n    }\n\n    return result;\n}","target":1,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":320275,"func":"static void dvbsub_parse_region_segment(AVCodecContext *avctx,\n\n                                        const uint8_t *buf, int buf_size)\n\n{\n\n    DVBSubContext *ctx = avctx->priv_data;\n\n\n\n    const uint8_t *buf_end = buf + buf_size;\n\n    int region_id, object_id;\n\n    DVBSubRegion *region;\n\n    DVBSubObject *object;\n\n    DVBSubObjectDisplay *display;\n\n    int fill;\n\n\n\n    if (buf_size < 10)\n\n        return;\n\n\n\n    region_id = *buf++;\n\n\n\n    region = get_region(ctx, region_id);\n\n\n\n    if (!region) {\n\n        region = av_mallocz(sizeof(DVBSubRegion));\n\n\n\n        region->id = region_id;\n\n\n\n        region->next = ctx->region_list;\n\n        ctx->region_list = region;\n\n    }\n\n\n\n    fill = ((*buf++) >> 3) & 1;\n\n\n\n    region->width = AV_RB16(buf);\n\n    buf += 2;\n\n    region->height = AV_RB16(buf);\n\n    buf += 2;\n\n\n\n    if (region->width * region->height != region->buf_size) {\n\n        av_free(region->pbuf);\n\n\n\n        region->buf_size = region->width * region->height;\n\n\n\n        region->pbuf = av_malloc(region->buf_size);\n\n\n\n        fill = 1;\n\n    }\n\n\n\n    region->depth = 1 << (((*buf++) >> 2) & 7);\n\n    if(region->depth<2 || region->depth>8){\n\n        av_log(avctx, AV_LOG_ERROR, \"region depth %d is invalid\\n\", region->depth);\n\n        region->depth= 4;\n\n    }\n\n    region->clut = *buf++;\n\n\n\n    if (region->depth == 8)\n\n        region->bgcolor = *buf++;\n\n    else {\n\n        buf += 1;\n\n\n\n        if (region->depth == 4)\n\n            region->bgcolor = (((*buf++) >> 4) & 15);\n\n        else\n\n            region->bgcolor = (((*buf++) >> 2) & 3);\n\n    }\n\n\n\n    av_dlog(avctx, \"Region %d, (%dx%d)\\n\", region_id, region->width, region->height);\n\n\n\n    if (fill) {\n\n        memset(region->pbuf, region->bgcolor, region->buf_size);\n\n        av_dlog(avctx, \"Fill region (%d)\\n\", region->bgcolor);\n\n    }\n\n\n\n    delete_region_display_list(ctx, region);\n\n\n\n    while (buf + 5 < buf_end) {\n\n        object_id = AV_RB16(buf);\n\n        buf += 2;\n\n\n\n        object = get_object(ctx, object_id);\n\n\n\n        if (!object) {\n\n            object = av_mallocz(sizeof(DVBSubObject));\n\n\n\n            object->id = object_id;\n\n            object->next = ctx->object_list;\n\n            ctx->object_list = object;\n\n        }\n\n\n\n        object->type = (*buf) >> 6;\n\n\n\n        display = av_mallocz(sizeof(DVBSubObjectDisplay));\n\n\n\n        display->object_id = object_id;\n\n        display->region_id = region_id;\n\n\n\n        display->x_pos = AV_RB16(buf) & 0xfff;\n\n        buf += 2;\n\n        display->y_pos = AV_RB16(buf) & 0xfff;\n\n        buf += 2;\n\n\n\n        if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {\n\n            display->fgcolor = *buf++;\n\n            display->bgcolor = *buf++;\n\n        }\n\n\n\n        display->region_list_next = region->display_list;\n\n        region->display_list = display;\n\n\n\n        display->object_list_next = object->display_list;\n\n        object->display_list = display;\n\n    }\n\n}\n","target":0,"code_token_length":777,"total_token_length":1013,"max_tokens_setting":1024}
+{"idx":298129,"func":"int ptrace_getregs(struct task_struct *child, void __user *uregs)\n{\n\tstruct pt_regs *regs = task_pt_regs(child);\n\txtensa_gregset_t __user *gregset = uregs;\n\tunsigned long wm = regs->wmask;\n\tunsigned long wb = regs->windowbase;\n\tint live, i;\n\n\tif (!access_ok(VERIFY_WRITE, uregs, sizeof(xtensa_gregset_t)))\n\t\treturn -EIO;\n\n\t__put_user(regs->pc, &gregset->pc);\n\t__put_user(regs->ps & ~(1 << PS_EXCM_BIT), &gregset->ps);\n\t__put_user(regs->lbeg, &gregset->lbeg);\n\t__put_user(regs->lend, &gregset->lend);\n\t__put_user(regs->lcount, &gregset->lcount);\n\t__put_user(regs->windowstart, &gregset->windowstart);\n\t__put_user(regs->windowbase, &gregset->windowbase);\n\n\tlive = (wm & 2) ? 4 : (wm & 4) ? 8 : (wm & 8) ? 12 : 16;\n\n\tfor (i = 0; i < live; i++)\n\t\t__put_user(regs->areg[i],gregset->a+((wb*4+i)%XCHAL_NUM_AREGS));\n\tfor (i = XCHAL_NUM_AREGS - (wm >> 4) * 4; i < XCHAL_NUM_AREGS; i++)\n\t\t__put_user(regs->areg[i],gregset->a+((wb*4+i)%XCHAL_NUM_AREGS));\n\n\treturn 0;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":254819,"func":"WORK_STATE ossl_statem_server_pre_work ( SSL * s , WORK_STATE wst ) {\n OSSL_STATEM * st = & s -> statem ;\n switch ( st -> hand_state ) {\n case TLS_ST_SW_HELLO_REQ : s -> shutdown = 0 ;\n if ( SSL_IS_DTLS ( s ) ) dtls1_clear_record_buffer ( s ) ;\n break ;\n case DTLS_ST_SW_HELLO_VERIFY_REQUEST : s -> shutdown = 0 ;\n if ( SSL_IS_DTLS ( s ) ) {\n dtls1_clear_record_buffer ( s ) ;\n st -> use_timer = 0 ;\n }\n break ;\n case TLS_ST_SW_SRVR_HELLO : if ( SSL_IS_DTLS ( s ) ) {\n st -> use_timer = 1 ;\n }\n break ;\n case TLS_ST_SW_SRVR_DONE : # ifndef OPENSSL_NO_SCTP if ( SSL_IS_DTLS ( s ) && BIO_dgram_is_sctp ( SSL_get_wbio ( s ) ) ) return dtls_wait_for_dry ( s ) ;\n # endif return WORK_FINISHED_CONTINUE ;\n case TLS_ST_SW_SESSION_TICKET : if ( SSL_IS_DTLS ( s ) ) {\n st -> use_timer = 0 ;\n }\n break ;\n case TLS_ST_SW_CHANGE : s -> session -> cipher = s -> s3 -> tmp . new_cipher ;\n if ( ! s -> method -> ssl3_enc -> setup_key_block ( s ) ) {\n ossl_statem_set_error ( s ) ;\n return WORK_ERROR ;\n }\n if ( SSL_IS_DTLS ( s ) ) {\n st -> use_timer = 0 ;\n }\n return WORK_FINISHED_CONTINUE ;\n case TLS_ST_OK : return tls_finish_handshake ( s , wst ) ;\n default : break ;\n }\n return WORK_FINISHED_CONTINUE ;\n }","target":1,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":24094,"func":"static void imdct_and_window ( TwinContext * tctx , enum FrameType ftype , int wtype , float * in , float * prev , int ch ) {\n FFTContext * mdct = & tctx -> mdct_ctx [ ftype ] ;\n const ModeTab * mtab = tctx -> mtab ;\n int bsize = mtab -> size \/ mtab -> fmode [ ftype ] . sub ;\n int size = mtab -> size ;\n float * buf1 = tctx -> tmp_buf ;\n int j ;\n int wsize ;\n float * out = tctx -> curr_frame + 2 * ch * mtab -> size ;\n float * out2 = out ;\n float * prev_buf ;\n int first_wsize ;\n static const uint8_t wtype_to_wsize [ ] = {\n 0 , 0 , 2 , 2 , 2 , 1 , 0 , 1 , 1 }\n ;\n int types_sizes [ ] = {\n mtab -> size \/ mtab -> fmode [ FT_LONG ] . sub , mtab -> size \/ mtab -> fmode [ FT_MEDIUM ] . sub , mtab -> size \/ ( 2 * mtab -> fmode [ FT_SHORT ] . sub ) , }\n ;\n wsize = types_sizes [ wtype_to_wsize [ wtype ] ] ;\n first_wsize = wsize ;\n prev_buf = prev + ( size - bsize ) \/ 2 ;\n for ( j = 0 ;\n j < mtab -> fmode [ ftype ] . sub ;\n j ++ ) {\n int sub_wtype = ftype == FT_MEDIUM ? 8 : wtype ;\n if ( ! j && wtype == 4 ) sub_wtype = 4 ;\n else if ( j == mtab -> fmode [ ftype ] . sub - 1 && wtype == 7 ) sub_wtype = 7 ;\n wsize = types_sizes [ wtype_to_wsize [ sub_wtype ] ] ;\n mdct -> imdct_half ( mdct , buf1 + bsize * j , in + bsize * j ) ;\n tctx -> fdsp . vector_fmul_window ( out2 , prev_buf + ( bsize - wsize ) \/ 2 , buf1 + bsize * j , ff_sine_windows [ av_log2 ( wsize ) ] , wsize \/ 2 ) ;\n out2 += wsize ;\n memcpy ( out2 , buf1 + bsize * j + wsize \/ 2 , ( bsize - wsize \/ 2 ) * sizeof ( float ) ) ;\n out2 += ftype == FT_MEDIUM ? ( bsize - wsize ) \/ 2 : bsize - wsize ;\n prev_buf = buf1 + bsize * j + bsize \/ 2 ;\n }\n tctx -> last_block_pos [ ch ] = ( size + first_wsize ) \/ 2 ;\n }","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":295834,"func":"static int set_bitmap_file(struct mddev *mddev, int fd)\n{\n\tint err = 0;\n\n\tif (mddev->pers) {\n\t\tif (!mddev->pers->quiesce || !mddev->thread)\n\t\t\treturn -EBUSY;\n\t\tif (mddev->recovery || mddev->sync_thread)\n\t\t\treturn -EBUSY;\n\t\t\/* we should be able to change the bitmap.. *\/\n\t}\n\n\tif (fd >= 0) {\n\t\tstruct inode *inode;\n\t\tstruct file *f;\n\n\t\tif (mddev->bitmap || mddev->bitmap_info.file)\n\t\t\treturn -EEXIST; \/* cannot add when bitmap is present *\/\n\t\tf = fget(fd);\n\n\t\tif (f == NULL) {\n\t\t\tprintk(KERN_ERR \"%s: error: failed to get bitmap file\\n\",\n\t\t\t       mdname(mddev));\n\t\t\treturn -EBADF;\n\t\t}\n\n\t\tinode = f->f_mapping->host;\n\t\tif (!S_ISREG(inode->i_mode)) {\n\t\t\tprintk(KERN_ERR \"%s: error: bitmap file must be a regular file\\n\",\n\t\t\t       mdname(mddev));\n\t\t\terr = -EBADF;\n\t\t} else if (!(f->f_mode & FMODE_WRITE)) {\n\t\t\tprintk(KERN_ERR \"%s: error: bitmap file must open for write\\n\",\n\t\t\t       mdname(mddev));\n\t\t\terr = -EBADF;\n\t\t} else if (atomic_read(&inode->i_writecount) != 1) {\n\t\t\tprintk(KERN_ERR \"%s: error: bitmap file is already in use\\n\",\n\t\t\t       mdname(mddev));\n\t\t\terr = -EBUSY;\n\t\t}\n\t\tif (err) {\n\t\t\tfput(f);\n\t\t\treturn err;\n\t\t}\n\t\tmddev->bitmap_info.file = f;\n\t\tmddev->bitmap_info.offset = 0; \/* file overrides offset *\/\n\t} else if (mddev->bitmap == NULL)\n\t\treturn -ENOENT; \/* cannot remove what isn't there *\/\n\terr = 0;\n\tif (mddev->pers) {\n\t\tmddev->pers->quiesce(mddev, 1);\n\t\tif (fd >= 0) {\n\t\t\tstruct bitmap *bitmap;\n\n\t\t\tbitmap = bitmap_create(mddev, -1);\n\t\t\tif (!IS_ERR(bitmap)) {\n\t\t\t\tmddev->bitmap = bitmap;\n\t\t\t\terr = bitmap_load(mddev);\n\t\t\t} else\n\t\t\t\terr = PTR_ERR(bitmap);\n\t\t}\n\t\tif (fd < 0 || err) {\n\t\t\tbitmap_destroy(mddev);\n\t\t\tfd = -1; \/* make sure to put the file *\/\n\t\t}\n\t\tmddev->pers->quiesce(mddev, 0);\n\t}\n\tif (fd < 0) {\n\t\tstruct file *f = mddev->bitmap_info.file;\n\t\tif (f) {\n\t\t\tspin_lock(&mddev->lock);\n\t\t\tmddev->bitmap_info.file = NULL;\n\t\t\tspin_unlock(&mddev->lock);\n\t\t\tfput(f);\n\t\t}\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":626,"total_token_length":862,"max_tokens_setting":1024}
+{"idx":3753,"func":"static boolean ReadICCProfile(j_decompress_ptr jpeg_info)\n{\n  char\n    magick[12];\n\n  ErrorManager\n    *error_manager;\n\n  ExceptionInfo\n    *exception;\n\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  register ssize_t\n    i;\n\n  register unsigned char\n    *p;\n\n  size_t\n    length;\n\n  StringInfo\n    *icc_profile,\n    *profile;\n\n  \/*\n    Read color profile.\n  *\/\n  length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8);\n  length+=(size_t) GetCharacter(jpeg_info);\n  length-=2;\n  if (length <= 14)\n    {\n      while (length-- > 0)\n        if (GetCharacter(jpeg_info) == EOF)\n          break;\n      return(TRUE);\n    }\n  for (i=0; i < 12; i++)\n    magick[i]=(char) GetCharacter(jpeg_info);\n  if (LocaleCompare(magick,ICC_PROFILE) != 0)\n    {\n      \/*\n        Not a ICC profile, return.\n      *\/\n      for (i=0; i < (ssize_t) (length-12); i++)\n        if (GetCharacter(jpeg_info) == EOF)\n          break;\n      return(TRUE);\n    }\n  (void) GetCharacter(jpeg_info);  \/* id *\/\n  (void) GetCharacter(jpeg_info);  \/* markers *\/\n  length-=14;\n  error_manager=(ErrorManager *) jpeg_info->client_data;\n  exception=error_manager->exception;\n  image=error_manager->image;\n  profile=BlobToStringInfo((const void *) NULL,length);\n  if (profile == (StringInfo *) NULL)\n    {\n      (void) ThrowMagickException(exception,GetMagickModule(),\n        ResourceLimitError,\"MemoryAllocationFailed\",\"`%s'\",image->filename);\n      return(FALSE);\n    }\n  error_manager->profile=profile;\n  p=GetStringInfoDatum(profile);\n  for (i=0; i < (ssize_t) length; i++)\n  {\n    int\n      c;\n\n    c=GetCharacter(jpeg_info);\n    if (c == EOF)\n      break;\n    *p++=(unsigned char) c;\n  }\n  if (i != (ssize_t) length)\n    {\n      profile=DestroyStringInfo(profile);\n      (void) ThrowMagickException(exception,GetMagickModule(),\n        CorruptImageError,\"InsufficientImageDataInFile\",\"`%s'\",\n        image->filename);\n      return(FALSE);\n    }\n  error_manager->profile=NULL;\n  icc_profile=(StringInfo *) GetImageProfile(image,\"icc\");\n  if (icc_profile != (StringInfo *) NULL)\n    {\n      ConcatenateStringInfo(icc_profile,profile);\n      profile=DestroyStringInfo(profile);\n    }\n  else\n    {\n      status=SetImageProfile(image,\"icc\",profile,exception);\n      profile=DestroyStringInfo(profile);\n      if (status == MagickFalse)\n        {\n          (void) ThrowMagickException(exception,GetMagickModule(),\n            ResourceLimitError,\"MemoryAllocationFailed\",\"`%s'\",image->filename);\n          return(FALSE);\n        }\n    }\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"Profile: ICC, %.20g bytes\",(double) length);\n  return(TRUE);\n}","target":1,"code_token_length":723,"total_token_length":959,"max_tokens_setting":1024}
+{"idx":387335,"func":"crypto_mv(\n\tstruct exten *ep,\t\/* extension pointer *\/\n\tstruct peer *peer\t\/* peer structure pointer *\/\n\t)\n{\n\tDSA\t*dsa;\t\t\/* MV parameters *\/\n\tDSA\t*sdsa;\t\t\/* DSA parameters *\/\n\tBN_CTX\t*bctx;\t\t\/* BIGNUM context *\/\n\tBIGNUM\t*k, *u, *v;\n\tu_int\tlen;\n\tconst u_char *ptr;\n\tint\ttemp;\n\n\t\/*\n\t * If the MV parameters are not valid or no challenge was sent,\n\t * something awful happened or we are being tormented.\n\t *\/\n\tif (peer->ident_pkey == NULL) {\n\t\tmsyslog(LOG_NOTICE, \"crypto_mv: scheme unavailable\");\n\t\treturn (XEVNT_ID);\n\t}\n\tif (ntohl(ep->fstamp) != peer->ident_pkey->fstamp) {\n\t\tmsyslog(LOG_NOTICE, \"crypto_mv: invalid filestamp %u\",\n\t\t    ntohl(ep->fstamp));\n\t\treturn (XEVNT_FSP);\n\t}\n\tif ((dsa = peer->ident_pkey->pkey->pkey.dsa) == NULL) {\n\t\tmsyslog(LOG_NOTICE, \"crypto_mv: defective key\");\n\t\treturn (XEVNT_PUB);\n\t}\n\tif (peer->iffval == NULL) {\n\t\tmsyslog(LOG_NOTICE, \"crypto_mv: missing challenge\");\n\t\treturn (XEVNT_ID);\n\t}\n\n\t\/*\n\t * Extract the y, gbar and ghat values from the response.\n\t *\/\n\tbctx = BN_CTX_new(); k = BN_new(); u = BN_new(); v = BN_new();\n\tlen = ntohl(ep->vallen);\n\tptr = (u_char *)ep->pkt;\n\tif ((sdsa = d2i_DSAparams(NULL, &ptr, len)) == NULL) {\n\t\tmsyslog(LOG_ERR, \"crypto_mv: %s\",\n\t\t    ERR_error_string(ERR_get_error(), NULL));\n\t\treturn (XEVNT_ERR);\n\t}\n\n\t\/*\n\t * Compute (gbar^xhat ghat^xbar) mod p.\n\t *\/\n\tBN_mod_exp(u, sdsa->q, dsa->pub_key, dsa->p, bctx);\n\tBN_mod_exp(v, sdsa->g, dsa->priv_key, dsa->p, bctx);\n\tBN_mod_mul(u, u, v, dsa->p, bctx);\n\tBN_mod_mul(u, u, sdsa->p, dsa->p, bctx);\n\n\t\/*\n\t * The result should match r.\n\t *\/\n\ttemp = BN_cmp(u, peer->iffval);\n\tBN_CTX_free(bctx); BN_free(k); BN_free(u); BN_free(v);\n\tBN_free(peer->iffval);\n\tpeer->iffval = NULL;\n\tDSA_free(sdsa);\n\tif (temp == 0)\n\t\treturn (XEVNT_OK);\n\n\tmsyslog(LOG_NOTICE, \"crypto_mv: identity not verified\");\n\treturn (XEVNT_ID);\n}","target":0,"code_token_length":624,"total_token_length":860,"max_tokens_setting":1024}
+{"idx":33816,"func":"TEST_P(JSITest, FunctionTest) {\n  \/\/ test move ctor\n  Function fmove = function(\"function() { return 1 }\");\n  {\n    Function g = function(\"function() { return 2 }\");\n    fmove = std::move(g);\n  }\n  EXPECT_EQ(fmove.call(rt).getNumber(), 2);\n\n  \/\/ This tests all the function argument converters, and all the\n  \/\/ non-lvalue overloads of call().\n  Function f = function(\n      \"function(n, b, d, df, i, s1, s2, s3, s_sun, s_bad, o, a, f, v) { \"\n      \"return \"\n      \"n === null && \"\n      \"b === true && \"\n      \"d === 3.14 && \"\n      \"Math.abs(df - 2.71) < 0.001 && \"\n      \"i === 17 && \"\n      \"s1 == 's1' && \"\n      \"s2 == 's2' && \"\n      \"s3 == 's3' && \"\n      \"s_sun == 's\\\\u2600' && \"\n      \"typeof s_bad == 'string' && \"\n      \"typeof o == 'object' && \"\n      \"Array.isArray(a) && \"\n      \"typeof f == 'function' && \"\n      \"v == 42 }\");\n  EXPECT_TRUE(f.call(\n                   rt,\n                   nullptr,\n                   true,\n                   3.14,\n                   2.71f,\n                   17,\n                   \"s1\",\n                   String::createFromAscii(rt, \"s2\"),\n                   std::string{\"s3\"},\n                   std::string{u8\"s\\u2600\"},\n                   \/\/ invalid UTF8 sequence due to unexpected continuation byte\n                   std::string{\"s\\x80\"},\n                   Object(rt),\n                   Array(rt, 1),\n                   function(\"function(){}\"),\n                   Value(42))\n                  .getBool());\n\n  \/\/ lvalue overloads of call()\n  Function flv = function(\n      \"function(s, o, a, f, v) { return \"\n      \"s == 's' && \"\n      \"typeof o == 'object' && \"\n      \"Array.isArray(a) && \"\n      \"typeof f == 'function' && \"\n      \"v == 42 }\");\n\n  String s = String::createFromAscii(rt, \"s\");\n  Object o = Object(rt);\n  Array a = Array(rt, 1);\n  Value v = 42;\n  EXPECT_TRUE(flv.call(rt, s, o, a, f, v).getBool());\n\n  Function f1 = function(\"function() { return 1; }\");\n  Function f2 = function(\"function() { return 2; }\");\n  f2 = std::move(f1);\n  EXPECT_EQ(f2.call(rt).getNumber(), 1);\n}","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":266538,"func":"static OPJ_BOOL opj_j2k_init_info(     opj_j2k_t *p_j2k,\n                                                struct opj_stream_private *p_stream,\n                                                struct opj_event_mgr * p_manager )\n{\n        opj_codestream_info_t * l_cstr_info = 00;\n\n        \/* preconditions *\/\n        assert(p_j2k != 00);\n        assert(p_manager != 00);\n        assert(p_stream != 00);\n  (void)l_cstr_info;\n\n        \/* TODO mergeV2: check this part which use cstr_info *\/\n        \/*l_cstr_info = p_j2k->cstr_info;\n\n        if (l_cstr_info)  {\n                OPJ_UINT32 compno;\n                l_cstr_info->tile = (opj_tile_info_t *) opj_malloc(p_j2k->m_cp.tw * p_j2k->m_cp.th * sizeof(opj_tile_info_t));\n\n                l_cstr_info->image_w = p_j2k->m_image->x1 - p_j2k->m_image->x0;\n                l_cstr_info->image_h = p_j2k->m_image->y1 - p_j2k->m_image->y0;\n\n                l_cstr_info->prog = (&p_j2k->m_cp.tcps[0])->prg;\n\n                l_cstr_info->tw = p_j2k->m_cp.tw;\n                l_cstr_info->th = p_j2k->m_cp.th;\n\n                l_cstr_info->tile_x = p_j2k->m_cp.tdx;*\/        \/* new version parser *\/\n                \/*l_cstr_info->tile_y = p_j2k->m_cp.tdy;*\/      \/* new version parser *\/\n                \/*l_cstr_info->tile_Ox = p_j2k->m_cp.tx0;*\/     \/* new version parser *\/\n                \/*l_cstr_info->tile_Oy = p_j2k->m_cp.ty0;*\/     \/* new version parser *\/\n\n                \/*l_cstr_info->numcomps = p_j2k->m_image->numcomps;\n\n                l_cstr_info->numlayers = (&p_j2k->m_cp.tcps[0])->numlayers;\n\n                l_cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(p_j2k->m_image->numcomps * sizeof(OPJ_INT32));\n\n                for (compno=0; compno < p_j2k->m_image->numcomps; compno++) {\n                        l_cstr_info->numdecompos[compno] = (&p_j2k->m_cp.tcps[0])->tccps->numresolutions - 1;\n                }\n\n                l_cstr_info->D_max = 0.0;       *\/      \/* ADD Marcela *\/\n\n                \/*l_cstr_info->main_head_start = opj_stream_tell(p_stream);*\/ \/* position of SOC *\/\n\n                \/*l_cstr_info->maxmarknum = 100;\n                l_cstr_info->marker = (opj_marker_info_t *) opj_malloc(l_cstr_info->maxmarknum * sizeof(opj_marker_info_t));\n                l_cstr_info->marknum = 0;\n        }*\/\n\n        return opj_j2k_calculate_tp(p_j2k,&(p_j2k->m_cp),&p_j2k->m_specific_param.m_encoder.m_total_tile_parts,p_j2k->m_private_image,p_manager);\n}","target":0,"code_token_length":749,"total_token_length":985,"max_tokens_setting":1024}
+{"idx":5715,"func":"int AES_decrypt(uint8_t *encr_message, uint64_t length, char *message, uint64_t msgLen) {\n\n    if (!message) {\n        LOG_ERROR(\"Null message in AES_encrypt\");\n        return -1;\n    }\n\n    if (!encr_message) {\n        LOG_ERROR(\"Null encr message in AES_encrypt\");\n        return -2;\n    }\n\n\n  if (length < SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE) {\n      LOG_ERROR(\"length < SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE\");\n      return -1;\n  }\n\n\n\n  uint64_t len = length - SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE;\n\n  if (msgLen < len) {\n        LOG_ERROR(\"Output buffer not large enough\");\n        return -2;\n  }\n\n  sgx_status_t status = sgx_rijndael128GCM_decrypt(&AES_key,\n                                                   encr_message + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE, len,\n                                                   (unsigned char*) message,\n                                                   encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE,\n                                                   NULL, 0,\n                                                   (sgx_aes_gcm_128bit_tag_t *)encr_message);\n\n  return status;\n}","target":1,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":150820,"func":"SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){\n  SrcList *pNew;\n  int i;\n  int nByte;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);\n  pNew = sqlite3DbMallocRawNN(db, nByte );\n  if( pNew==0 ) return 0;\n  pNew->nSrc = pNew->nAlloc = p->nSrc;\n  for(i=0; i<p->nSrc; i++){\n    struct SrcList_item *pNewItem = &pNew->a[i];\n    struct SrcList_item *pOldItem = &p->a[i];\n    Table *pTab;\n    pNewItem->pSchema = pOldItem->pSchema;\n    pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase);\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);\n    pNewItem->fg = pOldItem->fg;\n    pNewItem->iCursor = pOldItem->iCursor;\n    pNewItem->addrFillSub = pOldItem->addrFillSub;\n    pNewItem->regReturn = pOldItem->regReturn;\n    if( pNewItem->fg.isIndexedBy ){\n      pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy);\n    }\n    pNewItem->pIBIndex = pOldItem->pIBIndex;\n    if( pNewItem->fg.isTabFunc ){\n      pNewItem->u1.pFuncArg = \n          sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags);\n    }\n    pTab = pNewItem->pTab = pOldItem->pTab;\n    if( pTab ){\n      pTab->nTabRef++;\n    }\n    pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags);\n    pNewItem->pOn = sqlite3ExprDup(db, pOldItem->pOn, flags);\n    pNewItem->pUsing = sqlite3IdListDup(db, pOldItem->pUsing);\n    pNewItem->colUsed = pOldItem->colUsed;\n  }\n  return pNew;\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":433491,"func":"static int rsi_mac80211_set_antenna(struct ieee80211_hw *hw,\n\t\t\t\t    u32 tx_ant, u32 rx_ant)\n{\n\tstruct rsi_hw *adapter = hw->priv;\n\tstruct rsi_common *common = adapter->priv;\n\tu8 antenna = 0;\n\n\tif (tx_ant > 1 || rx_ant > 1) {\n\t\trsi_dbg(ERR_ZONE,\n\t\t\t\"Invalid antenna selection (tx: %d, rx:%d)\\n\",\n\t\t\ttx_ant, rx_ant);\n\t\trsi_dbg(ERR_ZONE,\n\t\t\t\"Use 0 for int_ant, 1 for ext_ant\\n\");\n\t\treturn -EINVAL; \n\t}\n\n\trsi_dbg(INFO_ZONE, \"%s: Antenna map Tx %x Rx %d\\n\",\n\t\t\t__func__, tx_ant, rx_ant);\n\n\tmutex_lock(&common->mutex);\n\n\tantenna = tx_ant ? ANTENNA_SEL_UFL : ANTENNA_SEL_INT;\n\tif (common->ant_in_use != antenna)\n\t\tif (rsi_set_antenna(common, antenna))\n\t\t\tgoto fail_set_antenna;\n\n\trsi_dbg(INFO_ZONE, \"(%s) Antenna path configured successfully\\n\",\n\t\ttx_ant ? \"UFL\" : \"INT\");\n\n\tcommon->ant_in_use = antenna;\n\t\n\tmutex_unlock(&common->mutex);\n\t\n\treturn 0;\n\nfail_set_antenna:\n\trsi_dbg(ERR_ZONE, \"%s: Failed.\\n\", __func__);\n\tmutex_unlock(&common->mutex);\n\treturn -EINVAL;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":486526,"func":"get_gss_name(struct connectdata *conn, bool proxy,\n             struct negotiatedata *neg_ctx)\n{\n  const char* service;\n  size_t length;\n\n  if(proxy && !conn->proxy.name)\n    \/* proxy auth requested but no given proxy name, error out! *\/\n    return -1;\n\n  \/* GSSAPI implementation by Globus (known as GSI) requires the name to be\n     of form \"<service>\/<fqdn>\" instead of <service>@<fqdn> (ie. slash instead\n     of at-sign). Also GSI servers are often identified as 'host' not 'khttp'.\n     Change following lines if you want to use GSI *\/\n\n  \/* IIS uses the <service>@<fqdn> form but uses 'http' as the service name,\n     and SSPI then generates an NTLM token. When using <service>\/<fqdn> a\n     Kerberos token is generated. *\/\n\n  if(neg_ctx->gss)\n    service = \"KHTTP\";\n  else\n    service = \"HTTP\";\n\n  length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name :\n                                        conn->host.name) + 1;\n  if(length + 1 > sizeof(neg_ctx->server_name))\n    return EMSGSIZE;\n\n  snprintf(neg_ctx->server_name, sizeof(neg_ctx->server_name), \"%s\/%s\",\n           service, proxy ? conn->proxy.name : conn->host.name);\n\n  return 0;\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":160400,"func":"static int crypto_rsa_common(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus,\n                             const BYTE* exponent, int exponent_size, BYTE* output)\n{\n\tBN_CTX* ctx = NULL;\n\tint output_length = -1;\n\tBYTE* input_reverse = NULL;\n\tBYTE* modulus_reverse = NULL;\n\tBYTE* exponent_reverse = NULL;\n\tBIGNUM* mod = NULL;\n\tBIGNUM* exp = NULL;\n\tBIGNUM* x = NULL;\n\tBIGNUM* y = NULL;\n\tsize_t bufferSize = 2 * key_length + exponent_size;\n\n\tif (!input || (length < 0) || (exponent_size < 0) || !modulus || !exponent || !output)\n\t\treturn -1;\n\n\tif (length > bufferSize)\n\t\tbufferSize = length;\n\n\tinput_reverse = (BYTE*)calloc(bufferSize, 1);\n\n\tif (!input_reverse)\n\t\treturn -1;\n\n\tmodulus_reverse = input_reverse + key_length;\n\texponent_reverse = modulus_reverse + key_length;\n\tmemcpy(modulus_reverse, modulus, key_length);\n\tcrypto_reverse(modulus_reverse, key_length);\n\tmemcpy(exponent_reverse, exponent, exponent_size);\n\tcrypto_reverse(exponent_reverse, exponent_size);\n\tmemcpy(input_reverse, input, length);\n\tcrypto_reverse(input_reverse, length);\n\n\tif (!(ctx = BN_CTX_new()))\n\t\tgoto fail_bn_ctx;\n\n\tif (!(mod = BN_new()))\n\t\tgoto fail_bn_mod;\n\n\tif (!(exp = BN_new()))\n\t\tgoto fail_bn_exp;\n\n\tif (!(x = BN_new()))\n\t\tgoto fail_bn_x;\n\n\tif (!(y = BN_new()))\n\t\tgoto fail_bn_y;\n\n\tif (!BN_bin2bn(modulus_reverse, key_length, mod))\n\t\tgoto fail;\n\n\tif (!BN_bin2bn(exponent_reverse, exponent_size, exp))\n\t\tgoto fail;\n\tif (!BN_bin2bn(input_reverse, length, x))\n\t\tgoto fail;\n\tif (BN_mod_exp(y, x, exp, mod, ctx) != 1)\n\t\tgoto fail;\n\toutput_length = BN_bn2bin(y, output);\n\tif (output_length < 0)\n\t\tgoto fail;\n\tcrypto_reverse(output, output_length);\n\n\tif (output_length < key_length)\n\t\tmemset(output + output_length, 0, key_length - output_length);\n\nfail:\n\tBN_free(y);\nfail_bn_y:\n\tBN_clear_free(x);\nfail_bn_x:\n\tBN_free(exp);\nfail_bn_exp:\n\tBN_free(mod);\nfail_bn_mod:\n\tBN_CTX_free(ctx);\nfail_bn_ctx:\n\tfree(input_reverse);\n\treturn output_length;\n}","target":0,"code_token_length":524,"total_token_length":760,"max_tokens_setting":1024}
+{"idx":344128,"func":"int main(void) {\n    char *output = NULL;\n    CuSuite* suite = CuSuiteNew();\n    CuSuiteSetup(suite, NULL, NULL);\n    SUITE_ADD_TEST(suite, testDefault);\n    SUITE_ADD_TEST(suite, testNoLoad);\n    SUITE_ADD_TEST(suite, testNoAutoload);\n    SUITE_ADD_TEST(suite, testInvalidLens);\n    SUITE_ADD_TEST(suite, testLoadSave);\n    SUITE_ADD_TEST(suite, testLoadDefined);\n    SUITE_ADD_TEST(suite, testDefvarExpr);\n    SUITE_ADD_TEST(suite, testReloadChanged);\n    SUITE_ADD_TEST(suite, testReloadDirty);\n    SUITE_ADD_TEST(suite, testReloadDeleted);\n    SUITE_ADD_TEST(suite, testReloadDeletedMeta);\n    SUITE_ADD_TEST(suite, testReloadExternalMod);\n    SUITE_ADD_TEST(suite, testReloadAfterSaveNewfile);\n    SUITE_ADD_TEST(suite, testParseErrorReported);\n    SUITE_ADD_TEST(suite, testLoadExclWithRoot);\n    SUITE_ADD_TEST(suite, testLoadTrailingExcl);\n\n    abs_top_srcdir = getenv(\"abs_top_srcdir\");\n    if (abs_top_srcdir == NULL)\n        die(\"env var abs_top_srcdir must be set\");\n\n    abs_top_builddir = getenv(\"abs_top_builddir\");\n    if (abs_top_builddir == NULL)\n        die(\"env var abs_top_builddir must be set\");\n\n    if (asprintf(&root, \"%s\/tests\/root\", abs_top_srcdir) < 0) {\n        die(\"failed to set root\");\n    }\n\n    if (asprintf(&loadpath, \"%s\/lenses\", abs_top_srcdir) < 0) {\n        die(\"failed to set loadpath\");\n    }\n\n    CuSuiteRun(suite);\n    CuSuiteSummary(suite, &output);\n    CuSuiteDetails(suite, &output);\n    printf(\"%s\\n\", output);\n    free(output);\n    return suite->failCount;\n}","target":1,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":57407,"func":"static int proc_open(const char *path, struct fuse_file_info *fi)\n{\n\tint type = -1;\n\tstruct file_info *info;\n\n\tif (strcmp(path, \"\/proc\/meminfo\") == 0)\n\t\ttype = LXC_TYPE_PROC_MEMINFO;\n\telse if (strcmp(path, \"\/proc\/cpuinfo\") == 0)\n\t\ttype = LXC_TYPE_PROC_CPUINFO;\n\telse if (strcmp(path, \"\/proc\/uptime\") == 0)\n\t\ttype = LXC_TYPE_PROC_UPTIME;\n\telse if (strcmp(path, \"\/proc\/stat\") == 0)\n\t\ttype = LXC_TYPE_PROC_STAT;\n\telse if (strcmp(path, \"\/proc\/diskstats\") == 0)\n\t\ttype = LXC_TYPE_PROC_DISKSTATS;\n\tif (type == -1)\n\t\treturn -ENOENT;\n\n\tinfo = malloc(sizeof(*info));\n\tif (!info)\n\t\treturn -ENOMEM;\n\n\tmemset(info, 0, sizeof(*info));\n\tinfo->type = type;\n\n\tinfo->buflen = get_procfile_size(path) + BUF_RESERVE_SIZE;\n\tdo {\n\t\tinfo->buf = malloc(info->buflen);\n\t} while (!info->buf);\n\tmemset(info->buf, 0, info->buflen);\n\t\/* set actual size to buffer size *\/\n\tinfo->size = info->buflen;\n\n\tfi->fh = (unsigned long)info;\n\treturn 0;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":134999,"func":"static int p4_pmu_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)\n{\n\tunsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];\n\tunsigned long escr_mask[BITS_TO_LONGS(P4_ESCR_MSR_TABLE_SIZE)];\n\tint cpu = smp_processor_id();\n\tstruct hw_perf_event *hwc;\n\tstruct p4_event_bind *bind;\n\tunsigned int i, thread, num;\n\tint cntr_idx, escr_idx;\n\n\tbitmap_zero(used_mask, X86_PMC_IDX_MAX);\n\tbitmap_zero(escr_mask, P4_ESCR_MSR_TABLE_SIZE);\n\n\tfor (i = 0, num = n; i < n; i++, num--) {\n\n\t\thwc = &cpuc->event_list[i]->hw;\n\t\tthread = p4_ht_thread(cpu);\n\t\tbind = p4_config_get_bind(hwc->config);\n\t\tescr_idx = p4_get_escr_idx(bind->escr_msr[thread]);\n\t\tif (unlikely(escr_idx == -1))\n\t\t\tgoto done;\n\n\t\tif (hwc->idx != -1 && !p4_should_swap_ts(hwc->config, cpu)) {\n\t\t\tcntr_idx = hwc->idx;\n\t\t\tif (assign)\n\t\t\t\tassign[i] = hwc->idx;\n\t\t\tgoto reserve;\n\t\t}\n\n\t\tcntr_idx = p4_next_cntr(thread, used_mask, bind);\n\t\tif (cntr_idx == -1 || test_bit(escr_idx, escr_mask))\n\t\t\tgoto done;\n\n\t\tp4_pmu_swap_config_ts(hwc, cpu);\n\t\tif (assign)\n\t\t\tassign[i] = cntr_idx;\nreserve:\n\t\tset_bit(cntr_idx, used_mask);\n\t\tset_bit(escr_idx, escr_mask);\n\t}\n\ndone:\n\treturn num ? -ENOSPC : 0;\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":365183,"func":"command_process_destroy_cell(cell_t *cell, or_connection_t *conn)\n{\n  circuit_t *circ;\n  int reason;\n\n  circ = circuit_get_by_circid_orconn(cell->circ_id, conn);\n  reason = (uint8_t)cell->payload[0];\n  if (!circ) {\n    log_info(LD_OR,\"unknown circuit %d on connection from %s:%d. Dropping.\",\n             cell->circ_id, conn->_base.address, conn->_base.port);\n    return;\n  }\n  log_debug(LD_OR,\"Received for circID %d.\",cell->circ_id);\n\n  if (!CIRCUIT_IS_ORIGIN(circ) &&\n      cell->circ_id == TO_OR_CIRCUIT(circ)->p_circ_id) {\n    \/* the destroy came from behind *\/\n    circuit_set_p_circid_orconn(TO_OR_CIRCUIT(circ), 0, NULL);\n    circuit_mark_for_close(circ, reason|END_CIRC_REASON_FLAG_REMOTE);\n  } else { \/* the destroy came from ahead *\/\n    circuit_set_n_circid_orconn(circ, 0, NULL);\n    if (CIRCUIT_IS_ORIGIN(circ)) {\n      circuit_mark_for_close(circ, reason|END_CIRC_REASON_FLAG_REMOTE);\n    } else {\n      char payload[1];\n      log_debug(LD_OR, \"Delivering 'truncated' back.\");\n      payload[0] = (char)reason;\n      relay_send_command_from_edge(0, circ, RELAY_COMMAND_TRUNCATED,\n                                   payload, sizeof(payload), NULL);\n    }\n  }\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":228438,"func":"  TT_DotFix14( FT_Int32  ax,\n               FT_Int32  ay,\n               FT_Int    bx,\n               FT_Int    by )\n  {\n    FT_Int32   m, s, hi1, hi2, hi;\n    FT_UInt32  l, lo1, lo2, lo;\n\n\n    \/* compute ax*bx as 64-bit value *\/\n    l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx );\n    m = ( ax >> 16 ) * bx;\n\n    lo1 = l + ( (FT_UInt32)m << 16 );\n    hi1 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo1 < l );\n\n    \/* compute ay*by as 64-bit value *\/\n    l = (FT_UInt32)( ( ay & 0xFFFFU ) * by );\n    m = ( ay >> 16 ) * by;\n\n    lo2 = l + ( (FT_UInt32)m << 16 );\n    hi2 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo2 < l );\n\n    \/* add them *\/\n    lo = lo1 + lo2;\n    hi = hi1 + hi2 + ( lo < lo1 );\n\n    \/* divide the result by 2^14 with rounding *\/\n    s   = hi >> 31;\n    l   = lo + (FT_UInt32)s;\n    hi += s + ( l < lo );\n    lo  = l;\n\n    l   = lo + 0x2000U;\n    hi += ( l < lo );\n\n    return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );\n  }\n","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":439846,"func":"ipmi_sdr_find_sdr_bytype(struct ipmi_intf *intf, uint8_t type)\n{\n\tstruct sdr_get_rs *header;\n\tstruct sdr_record_list *e;\n\tstruct sdr_record_list *head;\n\n\tif (!sdr_list_itr) {\n\t\tsdr_list_itr = ipmi_sdr_start(intf, 0);\n\t\tif (!sdr_list_itr) {\n\t\t\tlprintf(LOG_ERR, \"Unable to open SDR for reading\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\thead = malloc(sizeof (struct sdr_record_list));\n\tif (!head) {\n\t\tlprintf(LOG_ERR, \"ipmitool: malloc failure\");\n\t\treturn NULL;\n\t}\n\tmemset(head, 0, sizeof (struct sdr_record_list));\n\n\t\/* check what we've already read *\/\n\tfor (e = sdr_list_head; e; e = e->next)\n\t\tif (e->type == type)\n\t\t\t__sdr_list_add(head, e);\n\n\t\/* now keep looking *\/\n\twhile ((header = ipmi_sdr_get_next_header(intf, sdr_list_itr))) {\n\t\tuint8_t *rec;\n\t\tstruct sdr_record_list *sdrr;\n\n\t\tsdrr = malloc(sizeof (struct sdr_record_list));\n\t\tif (!sdrr) {\n\t\t\tlprintf(LOG_ERR, \"ipmitool: malloc failure\");\n\t\t\tbreak;\n\t\t}\n\t\tmemset(sdrr, 0, sizeof (struct sdr_record_list));\n\t\tsdrr->id = header->id;\n\t\tsdrr->type = header->type;\n\n\t\trec = ipmi_sdr_get_record(intf, header, sdr_list_itr);\n\t\tif (!rec) {\n\t\t\tif (sdrr) {\n\t\t\t\tfree(sdrr);\n\t\t\t\tsdrr = NULL;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch (header->type) {\n\t\tcase SDR_RECORD_TYPE_FULL_SENSOR:\n\t\tcase SDR_RECORD_TYPE_COMPACT_SENSOR:\n\t\t\tsdrr->record.common =\n\t\t\t    (struct sdr_record_common_sensor *) rec;\n\t\t\tbreak;\n\t\tcase SDR_RECORD_TYPE_EVENTONLY_SENSOR:\n\t\t\tsdrr->record.eventonly =\n\t\t\t    (struct sdr_record_eventonly_sensor *) rec;\n\t\t\tbreak;\n\t\tcase SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR:\n\t\t\tsdrr->record.genloc =\n\t\t\t    (struct sdr_record_generic_locator *) rec;\n\t\t\tbreak;\n\t\tcase SDR_RECORD_TYPE_FRU_DEVICE_LOCATOR:\n\t\t\tsdrr->record.fruloc =\n\t\t\t    (struct sdr_record_fru_locator *) rec;\n\t\t\tbreak;\n\t\tcase SDR_RECORD_TYPE_MC_DEVICE_LOCATOR:\n\t\t\tsdrr->record.mcloc =\n\t\t\t    (struct sdr_record_mc_locator *) rec;\n\t\t\tbreak;\n\t\tcase SDR_RECORD_TYPE_ENTITY_ASSOC:\n\t\t\tsdrr->record.entassoc =\n\t\t\t    (struct sdr_record_entity_assoc *) rec;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfree(rec);\n\t\t\trec = NULL;\n\t\t\tif (sdrr) {\n\t\t\t\tfree(sdrr);\n\t\t\t\tsdrr = NULL;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (header->type == type)\n\t\t\t__sdr_list_add(head, sdrr);\n\n\t\t\/* add to global record list *\/\n\t\tif (!sdr_list_head)\n\t\t\tsdr_list_head = sdrr;\n\t\telse\n\t\t\tsdr_list_tail->next = sdrr;\n\n\t\tsdr_list_tail = sdrr;\n\t}\n\n\treturn head;\n}","target":0,"code_token_length":701,"total_token_length":937,"max_tokens_setting":1024}
+{"idx":325194,"func":"static void term_hist_add(const char *cmdline)\n\n{\n\n    char *hist_entry, *new_entry;\n\n    int idx;\n\n\n\n    if (cmdline[0] == '\\0')\n\n\treturn;\n\n    new_entry = NULL;\n\n    if (term_hist_entry != -1) {\n\n\t\/* We were editing an existing history entry: replace it *\/\n\n\thist_entry = term_history[term_hist_entry];\n\n\tidx = term_hist_entry;\n\n\tif (strcmp(hist_entry, cmdline) == 0) {\n\n\t    goto same_entry;\n\n\t}\n\n    }\n\n    \/* Search cmdline in history buffers *\/\n\n    for (idx = 0; idx < TERM_MAX_CMDS; idx++) {\n\n\thist_entry = term_history[idx];\n\n\tif (hist_entry == NULL)\n\n\t    break;\n\n\tif (strcmp(hist_entry, cmdline) == 0) {\n\n\tsame_entry:\n\n\t    new_entry = hist_entry;\n\n\t    \/* Put this entry at the end of history *\/\n\n\t    memmove(&term_history[idx], &term_history[idx + 1],\n\n\t\t    &term_history[TERM_MAX_CMDS] - &term_history[idx + 1]);\n\n\t    term_history[TERM_MAX_CMDS - 1] = NULL;\n\n\t    for (; idx < TERM_MAX_CMDS; idx++) {\n\n\t\tif (term_history[idx] == NULL)\n\n\t\t    break;\n\n\t    }\n\n\t    break;\n\n\t}\n\n    }\n\n    if (idx == TERM_MAX_CMDS) {\n\n\t\/* Need to get one free slot *\/\n\n\tfree(term_history[0]);\n\n\tmemcpy(term_history, &term_history[1],\n\n\t       &term_history[TERM_MAX_CMDS] - &term_history[1]);\n\n\tterm_history[TERM_MAX_CMDS - 1] = NULL;\n\n\tidx = TERM_MAX_CMDS - 1;\n\n    }\n\n    if (new_entry == NULL)\n\n\tnew_entry = strdup(cmdline);\n\n    term_history[idx] = new_entry;\n\n    term_hist_entry = -1;\n\n}\n","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":75940,"func":"static int core_pre_connection(conn_rec *c, void *csd)\n{\n    core_net_rec *net;\n    apr_status_t rv;\n\n    if (c->master) {\n        return DONE;\n    }\n    \n    net = apr_palloc(c->pool, sizeof(*net));\n    \/* The Nagle algorithm says that we should delay sending partial\n     * packets in hopes of getting more data.  We don't want to do\n     * this; we are not telnet.  There are bad interactions between\n     * persistent connections and Nagle's algorithm that have very severe\n     * performance penalties.  (Failing to disable Nagle is not much of a\n     * problem with simple HTTP.)\n     *\/\n    rv = apr_socket_opt_set(csd, APR_TCP_NODELAY, 1);\n    if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) {\n        \/* expected cause is that the client disconnected already,\n         * hence the debug level\n         *\/\n        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00139)\n                      \"apr_socket_opt_set(APR_TCP_NODELAY)\");\n    }\n\n    \/* The core filter requires the timeout mode to be set, which\n     * incidentally sets the socket to be nonblocking.  If this\n     * is not initialized correctly, Linux - for example - will\n     * be initially blocking, while Solaris will be non blocking\n     * and any initial read will fail.\n     *\/\n    rv = apr_socket_timeout_set(csd, c->base_server->timeout);\n    if (rv != APR_SUCCESS) {\n        \/* expected cause is that the client disconnected already *\/\n        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00140)\n                      \"apr_socket_timeout_set\");\n    }\n\n    net->c = c;\n    net->in_ctx = NULL;\n    net->out_ctx = NULL;\n    net->client_socket = csd;\n\n    ap_set_core_module_config(net->c->conn_config, csd);\n    \/* only the master connection talks to the network *\/\n    if (c->master == NULL) {\n        ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL,\n                                   net->c);\n        ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL,\n                                    net->c);\n    }\n    return DONE;\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":353773,"func":"findTable (const char *tableName)\n{\n\/* Search paths for tables *\/\n  FILE *tableFile;\n  char *pathList;\n  char pathEnd[2];\n  char trialPath[MAXSTRING];\n  if (tableName == NULL || tableName[0] == 0)\n    return NULL;\n  strcpy (trialPath, tablePath);\n  strcat (trialPath, tableName);\n  if ((tableFile = fopen (trialPath, \"rb\")))\n    return tableFile;\n  pathEnd[0] = DIR_SEP;\n  pathEnd[1] = 0;\n  \/* See if table is on environment path LOUIS_TABLEPATH *\/\n  pathList = getenv (\"LOUIS_TABLEPATH\");\n  if (pathList)\n    while (1)\n      {\n\tint k;\n\tint listLength;\n\tint currentListPos = 0;\n\tlistLength = strlen (pathList);\n\tfor (k = 0; k < listLength; k++)\n\t  if (pathList[k] == ',')\n\t    break;\n\tif (k == listLength || k == 0)\n\t  {\t\t\t\/* Only one file *\/\n\t    strcpy (trialPath, pathList);\n\t    strcat (trialPath, pathEnd);\n\t    strcat (trialPath, tableName);\n\t    if ((tableFile = fopen (trialPath, \"rb\")))\n\t      break;\n\t  }\n\telse\n\t  {\t\t\t\/* Compile a list of files *\/\n\t    strncpy (trialPath, pathList, k);\n\t    trialPath[k] = 0;\n\t    strcat (trialPath, pathEnd);\n\t    strcat (trialPath, tableName);\n\t    currentListPos = k + 1;\n\t    if ((tableFile = fopen (trialPath, \"rb\")))\n\t      break;\n\t    while (currentListPos < listLength)\n\t      {\n\t\tfor (k = currentListPos; k < listLength; k++)\n\t\t  if (pathList[k] == ',')\n\t\t    break;\n\t\tstrncpy (trialPath,\n\t\t\t &pathList[currentListPos], k - currentListPos);\n\t\ttrialPath[k - currentListPos] = 0;\n\t\tstrcat (trialPath, pathEnd);\n\t\tstrcat (trialPath, tableName);\n\t\tif ((tableFile = fopen (trialPath, \"rb\")))\n\t\t  currentListPos = k + 1;\n\t\tbreak;\n\t      }\n\t  }\n\tbreak;\n      }\n  if (tableFile)\n    return tableFile;\n  \/* See if table in current directory or on a path in \n   * the table name*\/\n  if ((tableFile = fopen (tableName, \"rb\")))\n    return tableFile;\n\/* See if table on dataPath. *\/\n  pathList = lou_getDataPath ();\n  if (pathList)\n    {\n      strcpy (trialPath, pathList);\n      strcat (trialPath, pathEnd);\n#ifdef _WIN32\n      strcat (trialPath, \"liblouis\\\\tables\\\\\");\n#else\n      strcat (trialPath, \"liblouis\/tables\/\");\n#endif\n      strcat (trialPath, tableName);\n      if ((tableFile = fopen (trialPath, \"rb\")))\n\treturn tableFile;\n    }\n  \/* See if table on installed or program path. *\/\n#ifdef _WIN32\n  strcpy (trialPath, lou_getProgramPath ());\n  strcat (trialPath, \"\\\\share\\\\liblouis\\\\tables\\\\\");\n#else\n  strcpy (trialPath, TABLESDIR);\n  strcat (trialPath, pathEnd);\n#endif\n  strcat (trialPath, tableName);\n  if ((tableFile = fopen (trialPath, \"rb\")))\n    return tableFile;\n  return NULL;\n}","target":1,"code_token_length":732,"total_token_length":968,"max_tokens_setting":1024}
+{"idx":226125,"func":"static int req_aprtable2luatable_cb(void *l, const char *key,\n                                    const char *value)\n{\n    int t;\n    lua_State *L = (lua_State *) l;     \/* [table<s,t>, table<s,s>] *\/\n    \/* rstack_dump(L, RRR, \"start of cb\"); *\/\n    \/* L is [table<s,t>, table<s,s>] *\/\n    \/* build complex *\/\n\n    lua_getfield(L, -1, key);   \/* [VALUE, table<s,t>, table<s,s>] *\/\n    \/* rstack_dump(L, RRR, \"after getfield\"); *\/\n    t = lua_type(L, -1);\n    switch (t) {\n    case LUA_TNIL:\n    case LUA_TNONE:{\n            lua_pop(L, 1);      \/* [table<s,t>, table<s,s>] *\/\n            lua_newtable(L);    \/* [array, table<s,t>, table<s,s>] *\/\n            lua_pushnumber(L, 1);       \/* [1, array, table<s,t>, table<s,s>] *\/\n            lua_pushstring(L, value);   \/* [string, 1, array, table<s,t>, table<s,s>] *\/\n            lua_settable(L, -3);        \/* [array, table<s,t>, table<s,s>]  *\/\n            lua_setfield(L, -2, key);   \/* [table<s,t>, table<s,s>] *\/\n            break;\n        }\n    case LUA_TTABLE:{\n            \/* [array, table<s,t>, table<s,s>] *\/\n            int size = lua_rawlen(L, -1);\n            lua_pushnumber(L, size + 1);        \/* [#, array, table<s,t>, table<s,s>] *\/\n            lua_pushstring(L, value);   \/* [string, #, array, table<s,t>, table<s,s>] *\/\n            lua_settable(L, -3);        \/* [array, table<s,t>, table<s,s>] *\/\n            lua_setfield(L, -2, key);   \/* [table<s,t>, table<s,s>] *\/\n            break;\n        }\n    }\n\n    \/* L is [table<s,t>, table<s,s>] *\/\n    \/* build simple *\/\n    lua_getfield(L, -2, key);   \/* [VALUE, table<s,s>, table<s,t>] *\/\n    if (lua_isnoneornil(L, -1)) {       \/* only set if not already set *\/\n        lua_pop(L, 1);          \/* [table<s,s>, table<s,t>]] *\/\n        lua_pushstring(L, value);       \/* [string, table<s,s>, table<s,t>] *\/\n        lua_setfield(L, -3, key);       \/* [table<s,s>, table<s,t>]  *\/\n    }\n    else {\n        lua_pop(L, 1);\n    }\n    return 1;\n}\n","target":0,"code_token_length":594,"total_token_length":830,"max_tokens_setting":1024}
+{"idx":450506,"func":"static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,\n\t\t\t   struct nfs_fattr *fattr, struct iattr *sattr,\n\t\t\t   struct nfs_open_context *ctx, struct nfs4_label *ilabel,\n\t\t\t   struct nfs4_label *olabel)\n{\n\tstruct nfs_server *server = NFS_SERVER(inode);\n\t__u32 bitmask[NFS4_BITMASK_SZ];\n\tstruct nfs4_state *state = ctx ? ctx->state : NULL;\n\tstruct nfs_setattrargs\targ = {\n\t\t.fh\t\t= NFS_FH(inode),\n\t\t.iap\t\t= sattr,\n\t\t.server\t\t= server,\n\t\t.bitmask = bitmask,\n\t\t.label\t\t= ilabel,\n\t};\n\tstruct nfs_setattrres  res = {\n\t\t.fattr\t\t= fattr,\n\t\t.label\t\t= olabel,\n\t\t.server\t\t= server,\n\t};\n\tstruct nfs4_exception exception = {\n\t\t.state = state,\n\t\t.inode = inode,\n\t\t.stateid = &arg.stateid,\n\t};\n\tint err;\n\n\tdo {\n\t\tnfs4_bitmap_copy_adjust_setattr(bitmask,\n\t\t\t\tnfs4_bitmask(server, olabel),\n\t\t\t\tinode);\n\n\t\terr = _nfs4_do_setattr(inode, &arg, &res, cred, ctx);\n\t\tswitch (err) {\n\t\tcase -NFS4ERR_OPENMODE:\n\t\t\tif (!(sattr->ia_valid & ATTR_SIZE)) {\n\t\t\t\tpr_warn_once(\"NFSv4: server %s is incorrectly \"\n\t\t\t\t\t\t\"applying open mode checks to \"\n\t\t\t\t\t\t\"a SETATTR that is not \"\n\t\t\t\t\t\t\"changing file size.\\n\",\n\t\t\t\t\t\tserver->nfs_client->cl_hostname);\n\t\t\t}\n\t\t\tif (state && !(state->state & FMODE_WRITE)) {\n\t\t\t\terr = -EBADF;\n\t\t\t\tif (sattr->ia_valid & ATTR_OPEN)\n\t\t\t\t\terr = -EACCES;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\terr = nfs4_handle_exception(server, err, &exception);\n\t} while (exception.retry);\nout:\n\treturn err;\n}","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":389556,"func":"config_tos(\n\tconfig_tree *ptree\n\t)\n{\n\tattr_val *\ttos;\n\tint\t\titem;\n\tdouble\t\tval;\n\n#ifdef __GNUC__\n\titem = -1;\t\/* quiet warning *\/\n#endif\n\ttos = HEAD_PFIFO(ptree->orphan_cmds);\n\tfor (; tos != NULL; tos = tos->link) {\n\t\tval = tos->value.d;\n\t\tswitch(tos->attr) {\n\n\t\tdefault:\n\t\t\tINSIST(0);\n\t\t\tbreak;\n\n\t\tcase T_Ceiling:\n\t\t\tif (val > STRATUM_UNSPEC - 1) {\n\t\t\t\tmsyslog(LOG_WARNING,\n\t\t\t\t\t\"Using maximum tos ceiling %d, %g requested\",\n\t\t\t\t\tSTRATUM_UNSPEC - 1, val);\n\t\t\t\tval = STRATUM_UNSPEC - 1;\n\t\t\t}\n\t\t\titem = PROTO_CEILING;\n\t\t\tbreak;\n\n\t\tcase T_Floor:\n\t\t\titem = PROTO_FLOOR;\n\t\t\tbreak;\n\n\t\tcase T_Cohort:\n\t\t\titem = PROTO_COHORT;\n\t\t\tbreak;\n\n\t\tcase T_Orphan:\n\t\t\titem = PROTO_ORPHAN;\n\t\t\tbreak;\n\n\t\tcase T_Orphanwait:\n\t\t\titem = PROTO_ORPHWAIT;\n\t\t\tbreak;\n\n\t\tcase T_Mindist:\n\t\t\titem = PROTO_MINDISP;\n\t\t\tbreak;\n\n\t\tcase T_Maxdist:\n\t\t\titem = PROTO_MAXDIST;\n\t\t\tbreak;\n\n\t\tcase T_Minclock:\n\t\t\titem = PROTO_MINCLOCK;\n\t\t\tbreak;\n\n\t\tcase T_Maxclock:\n\t\t\titem = PROTO_MAXCLOCK;\n\t\t\tbreak;\n\n\t\tcase T_Minsane:\n\t\t\titem = PROTO_MINSANE;\n\t\t\tbreak;\n\n\t\tcase T_Beacon:\n\t\t\titem = PROTO_BEACON;\n\t\t\tbreak;\n\t\t}\n\t\tproto_config(item, 0, val, NULL);\n\t}\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":39035,"func":"static int opt_show_entries(void *optctx, const char *opt, const char *arg)\n{\n    const char *p = arg;\n    int ret = 0;\n\n    while (*p) {\n        AVDictionary *entries = NULL;\n        char *section_name = av_get_token(&p, \"=:\");\n        int show_all_entries = 0;\n\n        if (!section_name) {\n            av_log(NULL, AV_LOG_ERROR,\n                   \"Missing section name for option '%s'\\n\", opt);\n            return AVERROR(EINVAL);\n        }\n\n        if (*p == '=') {\n            p++;\n            while (*p && *p != ':') {\n                char *entry = av_get_token(&p, \",:\");\n                if (!entry)\n                    break;\n                av_log(NULL, AV_LOG_VERBOSE,\n                       \"Adding '%s' to the entries to show in section '%s'\\n\",\n                       entry, section_name);\n                av_dict_set(&entries, entry, \"\", AV_DICT_DONT_STRDUP_KEY);\n                if (*p == ',')\n                    p++;\n            }\n        } else {\n            show_all_entries = 1;\n        }\n\n        ret = match_section(section_name, show_all_entries, entries);\n        if (ret == 0) {\n            av_log(NULL, AV_LOG_ERROR, \"No match for section '%s'\\n\", section_name);\n            ret = AVERROR(EINVAL);\n        }\n        av_dict_free(&entries);\n        av_free(section_name);\n\n        if (ret <= 0)\n            break;\n        if (*p)\n            p++;\n    }\n\n    return ret;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":285840,"func":"vmxnet3_on_rx_done_update_stats(VMXNET3State *s,\n                                int qidx,\n                                Vmxnet3PktStatus status)\n{\n    struct UPT1_RxStats *stats = &s->rxq_descr[qidx].rxq_stats;\n    size_t tot_len = vmxnet_rx_pkt_get_total_len(s->rx_pkt);\n\n    switch (status) {\n    case VMXNET3_PKT_STATUS_OUT_OF_BUF:\n        stats->pktsRxOutOfBuf++;\n        break;\n\n    case VMXNET3_PKT_STATUS_ERROR:\n        stats->pktsRxError++;\n        break;\n    case VMXNET3_PKT_STATUS_OK:\n        switch (vmxnet_rx_pkt_get_packet_type(s->rx_pkt)) {\n        case ETH_PKT_BCAST:\n            stats->bcastPktsRxOK++;\n            stats->bcastBytesRxOK += tot_len;\n            break;\n        case ETH_PKT_MCAST:\n            stats->mcastPktsRxOK++;\n            stats->mcastBytesRxOK += tot_len;\n            break;\n        case ETH_PKT_UCAST:\n            stats->ucastPktsRxOK++;\n            stats->ucastBytesRxOK += tot_len;\n            break;\n        default:\n            g_assert_not_reached();\n        }\n\n        if (tot_len > s->mtu) {\n            stats->LROPktsRxOK++;\n            stats->LROBytesRxOK += tot_len;\n        }\n        break;\n    default:\n        g_assert_not_reached();\n    }\n}\n","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":189412,"func":"error::Error GLES2DecoderImpl::HandleCoverFillPathInstancedCHROMIUM(\n    uint32_t immediate_data_size,\n    const volatile void* cmd_data) {\n  static const char kFunctionName[] = \"glCoverFillPathInstancedCHROMIUM\";\n  const volatile gles2::cmds::CoverFillPathInstancedCHROMIUM& c =\n      *static_cast<const volatile gles2::cmds::CoverFillPathInstancedCHROMIUM*>(\n          cmd_data);\n  if (!features().chromium_path_rendering)\n    return error::kUnknownCommand;\n\n  PathCommandValidatorContext v(this, kFunctionName);\n  GLuint num_paths = 0;\n  GLenum path_name_type = GL_NONE;\n  GLenum cover_mode = GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM;\n  GLenum transform_type = GL_NONE;\n  if (!v.GetPathCountAndType(c, &num_paths, &path_name_type) ||\n      !v.GetCoverMode(c, &cover_mode) ||\n      !v.GetTransformType(c, &transform_type))\n    return v.error();\n\n  if (num_paths == 0)\n    return error::kNoError;\n\n  std::unique_ptr<GLuint[]> paths;\n  if (!v.GetPathNameData(c, num_paths, path_name_type, &paths))\n    return v.error();\n\n  const GLfloat* transforms = nullptr;\n  if (!v.GetTransforms(c, num_paths, transform_type, &transforms))\n    return v.error();\n\n  if (!CheckBoundDrawFramebufferValid(kFunctionName))\n    return error::kNoError;\n  ApplyDirtyState();\n  api()->glCoverFillPathInstancedNVFn(num_paths, GL_UNSIGNED_INT, paths.get(),\n                                      0, cover_mode, transform_type,\n                                      transforms);\n  return error::kNoError;\n}\n","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":291523,"func":"static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,\n\t\t\t      struct flowi *fl,\n\t\t\t      struct request_sock *req,\n\t\t\t      struct tcp_fastopen_cookie *foc,\n\t\t\t      enum tcp_synack_type synack_type)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 *fl6 = &fl->u.ip6;\n\tstruct sk_buff *skb;\n\tint err = -ENOMEM;\n\n\t\/* First, grab a route. *\/\n\tif (!dst && (dst = inet6_csk_route_req(sk, fl6, req,\n\t\t\t\t\t       IPPROTO_TCP)) == NULL)\n\t\tgoto done;\n\n\tskb = tcp_make_synack(sk, dst, req, foc, synack_type);\n\n\tif (skb) {\n\t\t__tcp_v6_send_check(skb, &ireq->ir_v6_loc_addr,\n\t\t\t\t    &ireq->ir_v6_rmt_addr);\n\n\t\tfl6->daddr = ireq->ir_v6_rmt_addr;\n\t\tif (np->repflow && ireq->pktopts)\n\t\t\tfl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts));\n\n\t\trcu_read_lock();\n\t\topt = ireq->ipv6_opt;\n\t\tif (!opt)\n\t\t\topt = rcu_dereference(np->opt);\n\t\terr = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass);\n\t\trcu_read_unlock();\n\t\terr = net_xmit_eval(err);\n\t}\n\ndone:\n\treturn err;\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":100999,"func":"int cil_resolve_selinuxuser(struct cil_tree_node *current, void *extra_args)\n{\n\tstruct cil_selinuxuser *selinuxuser = current->data;\n\tstruct cil_symtab_datum *user_datum = NULL;\n\tstruct cil_symtab_datum *lvlrange_datum = NULL;\n\tstruct cil_tree_node *user_node = NULL;\n\tint rc = SEPOL_ERR;\n\n\trc = cil_resolve_name(current, selinuxuser->user_str, CIL_SYM_USERS, extra_args, &user_datum);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tuser_node = NODE(user_datum);\n\n\tif (user_node->flavor != CIL_USER) {\n\t\tcil_log(CIL_ERR, \"Selinuxuser must be a user: %s\\n\", user_datum->fqn);\n\t\trc = SEPOL_ERR;\n\t\tgoto exit;\n\t}\n\n\tselinuxuser->user = (struct cil_user*)user_datum;\n\n\tif (selinuxuser->range_str != NULL) {\n\t\trc = cil_resolve_name(current, selinuxuser->range_str, CIL_SYM_LEVELRANGES, extra_args, &lvlrange_datum);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\t\tselinuxuser->range = (struct cil_levelrange*)lvlrange_datum;\n\n\t\t\/* This could still be an anonymous levelrange even if range_str is set, if range_str is a param_str*\/\n\t\tif (selinuxuser->range->datum.name == NULL) {\n\t\t\trc = cil_resolve_levelrange(current, selinuxuser->range, extra_args);\n\t\t\tif (rc != SEPOL_OK) {\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t} else if (selinuxuser->range != NULL) {\n\t\trc = cil_resolve_levelrange(current, selinuxuser->range, extra_args);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\t}\n\n\trc = SEPOL_OK;\nexit:\n\treturn rc;\n}","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":257820,"func":"static cmsBool WriteMatrix ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsStage * mpe ) {\n _cmsStageMatrixData * m = ( _cmsStageMatrixData * ) mpe -> Data ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 0 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 1 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 2 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 3 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 4 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 5 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 6 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 7 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Double [ 8 ] ) ) return FALSE ;\n if ( m -> Offset != NULL ) {\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Offset [ 0 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Offset [ 1 ] ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , m -> Offset [ 2 ] ) ) return FALSE ;\n }\n else {\n if ( ! _cmsWrite15Fixed16Number ( io , 0 ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , 0 ) ) return FALSE ;\n if ( ! _cmsWrite15Fixed16Number ( io , 0 ) ) return FALSE ;\n }\n return TRUE ;\n cmsUNUSED_PARAMETER ( self ) ;\n }","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":431454,"func":"    bool run(OperationContext* opCtx,\n             const string& dbname,\n             const BSONObj& cmdObj,\n             BSONObjBuilder& result) {\n        UserName userName;\n        Status status = auth::parseAndValidateDropUserCommand(cmdObj, dbname, &userName);\n        uassertStatusOK(status);\n\n        ServiceContext* serviceContext = opCtx->getClient()->getServiceContext();\n        stdx::lock_guard<stdx::mutex> lk(getAuthzDataMutex(serviceContext));\n        AuthorizationManager* authzManager = AuthorizationManager::get(serviceContext);\n        status = requireWritableAuthSchema28SCRAM(opCtx, authzManager);\n        uassertStatusOK(status);\n\n        audit::logDropUser(Client::getCurrent(), userName);\n\n        long long nMatched;\n        status = removePrivilegeDocuments(opCtx,\n                                          BSON(AuthorizationManager::USER_NAME_FIELD_NAME\n                                               << userName.getUser()\n                                               << AuthorizationManager::USER_DB_FIELD_NAME\n                                               << userName.getDB()),\n                                          &nMatched);\n        \/\/ Must invalidate even on bad status - what if the write succeeded but the GLE failed?\n        authzManager->invalidateUserByName(userName);\n        uassertStatusOK(status);\n\n        if (nMatched == 0) {\n            uasserted(ErrorCodes::UserNotFound,\n                      str::stream() << \"User '\" << userName.getFullName() << \"' not found\");\n        }\n\n        return true;\n    }","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":102249,"func":"_PyBuiltin_Init(void)\n{\n    PyObject *mod, *dict, *debug;\n\n    const _PyCoreConfig *config = &_PyInterpreterState_GET_UNSAFE()->core_config;\n\n    if (PyType_Ready(&PyFilter_Type) < 0 ||\n        PyType_Ready(&PyMap_Type) < 0 ||\n        PyType_Ready(&PyZip_Type) < 0)\n        return NULL;\n\n    mod = _PyModule_CreateInitialized(&builtinsmodule, PYTHON_API_VERSION);\n    if (mod == NULL)\n        return NULL;\n    dict = PyModule_GetDict(mod);\n\n#ifdef Py_TRACE_REFS\n    \/* \"builtins\" exposes a number of statically allocated objects\n     * that, before this code was added in 2.3, never showed up in\n     * the list of \"all objects\" maintained by Py_TRACE_REFS.  As a\n     * result, programs leaking references to None and False (etc)\n     * couldn't be diagnosed by examining sys.getobjects(0).\n     *\/\n#define ADD_TO_ALL(OBJECT) _Py_AddToAllObjects((PyObject *)(OBJECT), 0)\n#else\n#define ADD_TO_ALL(OBJECT) (void)0\n#endif\n\n#define SETBUILTIN(NAME, OBJECT) \\\n    if (PyDict_SetItemString(dict, NAME, (PyObject *)OBJECT) < 0)       \\\n        return NULL;                                                    \\\n    ADD_TO_ALL(OBJECT)\n\n    SETBUILTIN(\"None\",                  Py_None);\n    SETBUILTIN(\"Ellipsis\",              Py_Ellipsis);\n    SETBUILTIN(\"NotImplemented\",        Py_NotImplemented);\n    SETBUILTIN(\"False\",                 Py_False);\n    SETBUILTIN(\"True\",                  Py_True);\n    SETBUILTIN(\"bool\",                  &PyBool_Type);\n    SETBUILTIN(\"memoryview\",        &PyMemoryView_Type);\n    SETBUILTIN(\"bytearray\",             &PyByteArray_Type);\n    SETBUILTIN(\"bytes\",                 &PyBytes_Type);\n    SETBUILTIN(\"classmethod\",           &PyClassMethod_Type);\n    SETBUILTIN(\"complex\",               &PyComplex_Type);\n    SETBUILTIN(\"dict\",                  &PyDict_Type);\n    SETBUILTIN(\"enumerate\",             &PyEnum_Type);\n    SETBUILTIN(\"filter\",                &PyFilter_Type);\n    SETBUILTIN(\"float\",                 &PyFloat_Type);\n    SETBUILTIN(\"frozenset\",             &PyFrozenSet_Type);\n    SETBUILTIN(\"property\",              &PyProperty_Type);\n    SETBUILTIN(\"int\",                   &PyLong_Type);\n    SETBUILTIN(\"list\",                  &PyList_Type);\n    SETBUILTIN(\"map\",                   &PyMap_Type);\n    SETBUILTIN(\"object\",                &PyBaseObject_Type);\n    SETBUILTIN(\"range\",                 &PyRange_Type);\n    SETBUILTIN(\"reversed\",              &PyReversed_Type);\n    SETBUILTIN(\"set\",                   &PySet_Type);\n    SETBUILTIN(\"slice\",                 &PySlice_Type);\n    SETBUILTIN(\"staticmethod\",          &PyStaticMethod_Type);\n    SETBUILTIN(\"str\",                   &PyUnicode_Type);\n    SETBUILTIN(\"super\",                 &PySuper_Type);\n    SETBUILTIN(\"tuple\",                 &PyTuple_Type);\n    SETBUILTIN(\"type\",                  &PyType_Type);\n    SETBUILTIN(\"zip\",                   &PyZip_Type);\n    debug = PyBool_FromLong(config->optimization_level == 0);\n    if (PyDict_SetItemString(dict, \"__debug__\", debug) < 0) {\n        Py_DECREF(debug);\n        return NULL;\n    }\n    Py_DECREF(debug);\n\n    return mod;\n#undef ADD_TO_ALL\n#undef SETBUILTIN\n}","target":0,"code_token_length":775,"total_token_length":1011,"max_tokens_setting":1024}
+{"idx":367909,"func":"static int restore_sigcontext(struct pt_regs *regs,\n\t\t\t      struct sigcontext __user *sc, long *_d0)\n{\n\tunsigned int err = 0;\n\n\tif (is_using_fpu(current))\n\t\tfpu_kill_state(current);\n\n#define COPY(x) err |= __get_user(regs->x, &sc->x)\n\tCOPY(d1); COPY(d2); COPY(d3);\n\tCOPY(a0); COPY(a1); COPY(a2); COPY(a3);\n\tCOPY(e0); COPY(e1); COPY(e2); COPY(e3);\n\tCOPY(e4); COPY(e5); COPY(e6); COPY(e7);\n\tCOPY(lar); COPY(lir);\n\tCOPY(mdr); COPY(mdrq);\n\tCOPY(mcvf); COPY(mcrl); COPY(mcrh);\n\tCOPY(sp); COPY(pc);\n#undef COPY\n\n\t{\n\t\tunsigned int tmpflags;\n#ifndef CONFIG_MN10300_USING_JTAG\n#define USER_EPSW (EPSW_FLAG_Z | EPSW_FLAG_N | EPSW_FLAG_C | EPSW_FLAG_V | \\\n\t\t   EPSW_T | EPSW_nAR)\n#else\n#define USER_EPSW (EPSW_FLAG_Z | EPSW_FLAG_N | EPSW_FLAG_C | EPSW_FLAG_V | \\\n\t\t   EPSW_nAR)\n#endif\n\t\terr |= __get_user(tmpflags, &sc->epsw);\n\t\tregs->epsw = (regs->epsw & ~USER_EPSW) |\n\t\t  (tmpflags & USER_EPSW);\n\t\tregs->orig_d0 = -1;\t\t\/* disable syscall checks *\/\n\t}\n\n\t{\n\t\tstruct fpucontext *buf;\n\t\terr |= __get_user(buf, &sc->fpucontext);\n\t\tif (buf) {\n\t\t\tif (verify_area(VERIFY_READ, buf, sizeof(*buf)))\n\t\t\t\tgoto badframe;\n\t\t\terr |= fpu_restore_sigcontext(buf);\n\t\t}\n\t}\n\n\terr |= __get_user(*_d0, &sc->d0);\n\treturn err;\n\nbadframe:\n\treturn 1;\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":169599,"func":"int LvmEffect_enable(EffectContext *pContext){\n\n LVM_ControlParams_t ActiveParams; \/* Current control Parameters *\/\n    LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS; \/* Function call status *\/\n\n \/* Get the current settings *\/\n LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,\n &ActiveParams);\n\n    LVM_ERROR_CHECK(LvmStatus, \"LVM_GetControlParameters\", \"LvmEffect_enable\")\n if(LvmStatus != LVM_SUCCESS) return -EINVAL;\n\n if(pContext->EffectType == LVM_BASS_BOOST) {\n        ALOGV(\"\\tLvmEffect_enable : Enabling LVM_BASS_BOOST\");\n ActiveParams.BE_OperatingMode       = LVM_BE_ON;\n }\n if(pContext->EffectType == LVM_VIRTUALIZER) {\n        ALOGV(\"\\tLvmEffect_enable : Enabling LVM_VIRTUALIZER\");\n ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON;\n }\n if(pContext->EffectType == LVM_EQUALIZER) {\n        ALOGV(\"\\tLvmEffect_enable : Enabling LVM_EQUALIZER\");\n ActiveParams.EQNB_OperatingMode     = LVM_EQNB_ON;\n }\n if(pContext->EffectType == LVM_VOLUME) {\n        ALOGV(\"\\tLvmEffect_enable : Enabling LVM_VOLUME\");\n }\n\n LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);\n    LVM_ERROR_CHECK(LvmStatus, \"LVM_SetControlParameters\", \"LvmEffect_enable\")\n if(LvmStatus != LVM_SUCCESS) return -EINVAL;\n\n return 0;\n}\n","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":434967,"func":"static int cmpBitmap(unsigned char *buf, int width, int pitch, int height,\n                     int pf, int flags, int gray2rgb)\n{\n  int roffset = tjRedOffset[pf];\n  int goffset = tjGreenOffset[pf];\n  int boffset = tjBlueOffset[pf];\n  int aoffset = tjAlphaOffset[pf];\n  int ps = tjPixelSize[pf];\n  int i, j;\n\n  for (j = 0; j < height; j++) {\n    int row = (flags & TJFLAG_BOTTOMUP) ? height - j - 1 : j;\n\n    for (i = 0; i < width; i++) {\n      unsigned char r = (i * 256 \/ width) % 256;\n      unsigned char g = (j * 256 \/ height) % 256;\n      unsigned char b = (j * 256 \/ height + i * 256 \/ width) % 256;\n\n      if (pf == TJPF_GRAY) {\n        if (buf[row * pitch + i * ps] != b)\n          return 0;\n      } else if (pf == TJPF_CMYK) {\n        unsigned char rf, gf, bf;\n\n        cmyk_to_rgb(buf[row * pitch + i * ps + 0],\n                    buf[row * pitch + i * ps + 1],\n                    buf[row * pitch + i * ps + 2],\n                    buf[row * pitch + i * ps + 3], &rf, &gf, &bf);\n        if (gray2rgb) {\n          if (rf != b || gf != b || bf != b)\n            return 0;\n        } else if (rf != r || gf != g || bf != b) return 0;\n      } else {\n        if (gray2rgb) {\n          if (buf[row * pitch + i * ps + roffset] != b ||\n              buf[row * pitch + i * ps + goffset] != b ||\n              buf[row * pitch + i * ps + boffset] != b)\n            return 0;\n        } else if (buf[row * pitch + i * ps + roffset] != r ||\n                   buf[row * pitch + i * ps + goffset] != g ||\n                   buf[row * pitch + i * ps + boffset] != b)\n          return 0;\n        if (aoffset >= 0 && buf[row * pitch + i * ps + aoffset] != 0xFF)\n          return 0;\n      }\n    }\n  }\n  return 1;\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":361051,"func":"static char *store_file_unix_basic(connection_struct *conn,\n\t\t\t\tchar *pdata,\n\t\t\t\tfiles_struct *fsp,\n\t\t\t\tconst SMB_STRUCT_STAT *psbuf)\n{\n\tDEBUG(10,(\"store_file_unix_basic: SMB_QUERY_FILE_UNIX_BASIC\\n\"));\n\tDEBUG(4,(\"store_file_unix_basic: st_mode=%o\\n\",(int)psbuf->st_ex_mode));\n\n\tSOFF_T(pdata,0,get_file_size_stat(psbuf));             \/* File size 64 Bit *\/\n\tpdata += 8;\n\n\tSOFF_T(pdata,0,SMB_VFS_GET_ALLOC_SIZE(conn,fsp,psbuf)); \/* Number of bytes used on disk - 64 Bit *\/\n\tpdata += 8;\n\n\tput_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata, psbuf->st_ex_ctime);       \/* Change Time 64 Bit *\/\n\tput_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER ,pdata+8, psbuf->st_ex_atime);     \/* Last access time 64 Bit *\/\n\tput_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata+16, psbuf->st_ex_mtime);    \/* Last modification time 64 Bit *\/\n\tpdata += 24;\n\n\tSIVAL(pdata,0,psbuf->st_ex_uid);               \/* user id for the owner *\/\n\tSIVAL(pdata,4,0);\n\tpdata += 8;\n\n\tSIVAL(pdata,0,psbuf->st_ex_gid);               \/* group id of owner *\/\n\tSIVAL(pdata,4,0);\n\tpdata += 8;\n\n\tSIVAL(pdata,0,unix_filetype(psbuf->st_ex_mode));\n\tpdata += 4;\n\n\tSIVAL(pdata,0,unix_dev_major(psbuf->st_ex_rdev));   \/* Major device number if type is device *\/\n\tSIVAL(pdata,4,0);\n\tpdata += 8;\n\n\tSIVAL(pdata,0,unix_dev_minor(psbuf->st_ex_rdev));   \/* Minor device number if type is device *\/\n\tSIVAL(pdata,4,0);\n\tpdata += 8;\n\n\tSINO_T_VAL(pdata,0,(SMB_INO_T)psbuf->st_ex_ino);   \/* inode number *\/\n\tpdata += 8;\n\n\tSIVAL(pdata,0, unix_perms_to_wire(psbuf->st_ex_mode));     \/* Standard UNIX file permissions *\/\n\tSIVAL(pdata,4,0);\n\tpdata += 8;\n\n\tSIVAL(pdata,0,psbuf->st_ex_nlink);             \/* number of hard links *\/\n\tSIVAL(pdata,4,0);\n\tpdata += 8;\n\n\treturn pdata;\n}","target":0,"code_token_length":554,"total_token_length":790,"max_tokens_setting":1024}
+{"idx":84651,"func":"static void asmlinkage smm_do_relocation(void *arg)\n{\n\tconst struct smm_module_params *p;\n\tconst struct smm_runtime *runtime;\n\tint cpu;\n\tuintptr_t curr_smbase;\n\tuintptr_t perm_smbase;\n\n\tp = arg;\n\truntime = p->runtime;\n\tcpu = p->cpu;\n\tcurr_smbase = runtime->smbase;\n\n\tif (cpu >= CONFIG_MAX_CPUS) {\n\t\tprintk(BIOS_CRIT,\n\t\t       \"Invalid CPU number assigned in SMM stub: %d\\n\", cpu);\n\t\treturn;\n\t}\n\n\t\/*\n\t * The permanent handler runs with all cpus concurrently. Precalculate\n\t * the location of the new SMBASE. If using SMM modules then this\n\t * calculation needs to match that of the module loader.\n\t *\/\n#if CONFIG(X86_SMM_LOADER_VERSION2)\n\tperm_smbase = smm_get_cpu_smbase(cpu);\n\tmp_state.perm_smbase = perm_smbase;\n\tif (!perm_smbase) {\n\t\tprintk(BIOS_ERR, \"%s: bad SMBASE for CPU %d\\n\", __func__, cpu);\n\t\treturn;\n\t}\n#else\n\tperm_smbase = mp_state.perm_smbase;\n\tperm_smbase -= cpu * runtime->save_state_size;\n#endif\n\n\t\/* Setup code checks this callback for validity. *\/\n\tprintk(BIOS_INFO, \"%s : curr_smbase 0x%x perm_smbase 0x%x, cpu = %d\\n\",\n\t\t__func__, (int)curr_smbase, (int)perm_smbase, cpu);\n\tmp_state.ops.relocation_handler(cpu, curr_smbase, perm_smbase);\n\n\tif (CONFIG(STM)) {\n\t\tuintptr_t mseg;\n\n\t\tmseg = mp_state.perm_smbase +\n\t\t\t(mp_state.perm_smsize - CONFIG_MSEG_SIZE);\n\n\t\tstm_setup(mseg, p->cpu,\n\t\t\t\tperm_smbase,\n\t\t\t\tmp_state.perm_smbase,\n\t\t\t\truntime->start32_offset);\n\t}\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":120730,"func":"void MSADPCM::choosePredictorForBlock(const int16_t *decoded)\n{\n\tconst int kPredictorSampleLength = 3;\n\n\tint channelCount = m_track->f.channelCount;\n\n\tfor (int c=0; c<channelCount; c++)\n\t{\n\t\tint bestPredictorIndex = 0;\n\t\tint bestPredictorError = std::numeric_limits<int>::max();\n\t\tfor (int k=0; k<m_numCoefficients; k++)\n\t\t{\n\t\t\tint a0 = m_coefficients[k][0];\n\t\t\tint a1 = m_coefficients[k][1];\n\n\t\t\tint currentPredictorError = 0;\n\t\t\tfor (int i=2; i<2+kPredictorSampleLength; i++)\n\t\t\t{\n\t\t\t\tint error = std::abs(decoded[i*channelCount + c] -\n\t\t\t\t\t((a0 * decoded[(i-1)*channelCount + c] +\n\t\t\t\t\ta1 * decoded[(i-2)*channelCount + c]) >> 8));\n\t\t\t\tcurrentPredictorError += error;\n\t\t\t}\n\n\t\t\tcurrentPredictorError \/= 4 * kPredictorSampleLength;\n\n\t\t\tif (currentPredictorError < bestPredictorError)\n\t\t\t{\n\t\t\t\tbestPredictorError = currentPredictorError;\n\t\t\t\tbestPredictorIndex = k;\n\t\t\t}\n\n\t\t\tif (!currentPredictorError)\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (bestPredictorError < 16)\n\t\t\tbestPredictorError = 16;\n\n\t\tm_state[c].predictorIndex = bestPredictorIndex;\n\t\tm_state[c].delta = bestPredictorError;\n\t}\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":278574,"func":"status_t SampleTable::setTimeToSampleParams(\n off64_t data_offset, size_t data_size) {\n if (mHasTimeToSample || data_size < 8) {\n return ERROR_MALFORMED;\n }\n\n uint8_t header[8];\n if (mDataSource->readAt(\n                data_offset, header, sizeof(header)) < (ssize_t)sizeof(header)) {\n return ERROR_IO;\n }\n\n if (U32_AT(header) != 0) {\n return ERROR_MALFORMED;\n }\n\n    mTimeToSampleCount = U32_AT(&header[4]);\n if (mTimeToSampleCount > UINT32_MAX \/ (2 * sizeof(uint32_t))) {\n        ALOGE(\"Time-to-sample table size too large.\");\n return ERROR_OUT_OF_RANGE;\n }\n\n\n uint64_t allocSize = (uint64_t)mTimeToSampleCount * 2 * sizeof(uint32_t);\n    mTotalSize += allocSize;\n if (mTotalSize > kMaxTotalSize) {\n        ALOGE(\"Time-to-sample table size would make sample table too large.\\n\"\n \"    Requested time-to-sample table size = %llu\\n\"\n \"    Eventual sample table size >= %llu\\n\"\n \"    Allowed sample table size = %llu\\n\",\n (unsigned long long)allocSize,\n (unsigned long long)mTotalSize,\n (unsigned long long)kMaxTotalSize);\n return ERROR_OUT_OF_RANGE;\n }\n\n    mTimeToSample = new (std::nothrow) uint32_t[mTimeToSampleCount * 2];\n if (!mTimeToSample) {\n        ALOGE(\"Cannot allocate time-to-sample table with %llu entries.\",\n (unsigned long long)mTimeToSampleCount);\n return ERROR_OUT_OF_RANGE;\n }\n\n if (mDataSource->readAt(data_offset + 8, mTimeToSample,\n (size_t)allocSize) < (ssize_t)allocSize) {\n        ALOGE(\"Incomplete data read for time-to-sample table.\");\n return ERROR_IO;\n }\n\n for (size_t i = 0; i < mTimeToSampleCount * 2; ++i) {\n        mTimeToSample[i] = ntohl(mTimeToSample[i]);\n }\n\n    mHasTimeToSample = true;\n return OK;\n}\n","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":42828,"func":"static void intel_put_event_constraints(struct cpu_hw_events *cpuc,\n\t\t\t\t\tstruct perf_event *event)\n{\n\tstruct extra_reg *er;\n\tstruct intel_percore *pc;\n\tstruct er_account *era;\n\tstruct hw_perf_event *hwc = &event->hw;\n\tint i, allref;\n\n\tif (!cpuc->percore_used)\n\t\treturn;\n\n\tfor (er = x86_pmu.extra_regs; er->msr; er++) {\n\t\tif (er->event != (hwc->config & er->config_mask))\n\t\t\tcontinue;\n\n\t\tpc = cpuc->per_core;\n\t\traw_spin_lock(&pc->lock);\n\t\tfor (i = 0; i < MAX_EXTRA_REGS; i++) {\n\t\t\tera = &pc->regs[i];\n\t\t\tif (era->ref > 0 &&\n\t\t\t    era->extra_config == hwc->extra_config &&\n\t\t\t    era->extra_reg == er->msr) {\n\t\t\t\tera->ref--;\n\t\t\t\thwc->extra_alloc = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tallref = 0;\n\t\tfor (i = 0; i < MAX_EXTRA_REGS; i++)\n\t\t\tallref += pc->regs[i].ref;\n\t\tif (allref == 0)\n\t\t\tcpuc->percore_used = 0;\n\t\traw_spin_unlock(&pc->lock);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":113000,"func":"OPJ_BOOL opj_j2k_read_header(opj_stream_private_t *p_stream,\n                             opj_j2k_t* p_j2k,\n                             opj_image_t** p_image,\n                             opj_event_mgr_t* p_manager)\n{\n    \/* preconditions *\/\n    assert(p_j2k != 00);\n    assert(p_stream != 00);\n    assert(p_manager != 00);\n\n    \/* create an empty image header *\/\n    p_j2k->m_private_image = opj_image_create0();\n    if (! p_j2k->m_private_image) {\n        return OPJ_FALSE;\n    }\n\n    \/* customization of the validation *\/\n    if (! opj_j2k_setup_decoding_validation(p_j2k, p_manager)) {\n        opj_image_destroy(p_j2k->m_private_image);\n        p_j2k->m_private_image = NULL;\n        return OPJ_FALSE;\n    }\n\n    \/* validation of the parameters codec *\/\n    if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream, p_manager)) {\n        opj_image_destroy(p_j2k->m_private_image);\n        p_j2k->m_private_image = NULL;\n        return OPJ_FALSE;\n    }\n\n    \/* customization of the encoding *\/\n    if (! opj_j2k_setup_header_reading(p_j2k, p_manager)) {\n        opj_image_destroy(p_j2k->m_private_image);\n        p_j2k->m_private_image = NULL;\n        return OPJ_FALSE;\n    }\n\n    \/* read header *\/\n    if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {\n        opj_image_destroy(p_j2k->m_private_image);\n        p_j2k->m_private_image = NULL;\n        return OPJ_FALSE;\n    }\n\n    *p_image = opj_image_create0();\n    if (!(*p_image)) {\n        return OPJ_FALSE;\n    }\n\n    \/* Copy codestream image information to the output image *\/\n    opj_copy_image_header(p_j2k->m_private_image, *p_image);\n\n    \/*Allocate and initialize some elements of codestrem index*\/\n    if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)) {\n        return OPJ_FALSE;\n    }\n\n    return OPJ_TRUE;\n}","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":448909,"func":"xps_output_page(gx_device *dev, int num_copies, int flush)\n{\n    gx_device_xps *const xps = (gx_device_xps*)dev;\n    gx_device_vector *vdev = (gx_device_vector *)dev;\n    int code;\n\n    write_str_to_current_page(xps, \"<\/Canvas><\/FixedPage>\");\n    if (xps->relationship_count > 0)\n    {\n        \/* Close the relationship xml *\/\n        code = close_page_relationship(xps);\n        if (code < 0)\n            return gs_rethrow_code(code);\n        xps->relationship_count = 0;  \/* Reset for next page *\/\n    }\n    xps->page_count++;\n\n    if (gp_ferror(xps->file))\n      return gs_throw_code(gs_error_ioerror);\n\n    if ((code=gx_finish_output_page(dev, num_copies, flush)) < 0)\n        return code;\n\n    \/* Check if we need to change the output file for separate\n       pages. NB not sure if this will work correctly. *\/\n    if (gx_outputfile_is_separate_pages(((gx_device_vector *)dev)->fname, dev->memory)) {\n        if ((code = xps_close_device(dev)) < 0)\n            return code;\n        code = xps_open_device(dev);\n    }\n\n    if_debug1m('_', dev->memory, \"xps_output_page - page=%d\\n\", xps->page_count);\n    vdev->in_page = false;\n\n    return code;\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":387435,"func":"read_sysvars(void)\n{\n\tconst struct ctl_var *v;\n\tstruct ctl_var *kv;\n\tu_int\tn;\n\tu_int\tgotvar;\n\tconst u_char *cs;\n\tchar *\tvaluep;\n\tconst char * pch;\n\tu_char *wants;\n\tsize_t\twants_count;\n\n\t\/*\n\t * Wants system variables. Figure out which he wants\n\t * and give them to him.\n\t *\/\n\trpkt.status = htons(ctlsysstatus());\n\tif (res_authokay)\n\t\tctl_sys_num_events = 0;\n\twants_count = CS_MAXCODE + 1 + count_var(ext_sys_var);\n\twants = emalloc_zero(wants_count);\n\tgotvar = 0;\n\twhile (NULL != (v = ctl_getitem(sys_var, &valuep))) {\n\t\tif (!(EOV & v->flags)) {\n\t\t\tINSIST(v->code < wants_count);\n\t\t\twants[v->code] = 1;\n\t\t\tgotvar = 1;\n\t\t} else {\n\t\t\tv = ctl_getitem(ext_sys_var, &valuep);\n\t\t\tINSIST(v != NULL);\n\t\t\tif (EOV & v->flags) {\n\t\t\t\tctl_error(CERR_UNKNOWNVAR);\n\t\t\t\tfree(wants);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tn = v->code + CS_MAXCODE + 1;\n\t\t\tINSIST(n < wants_count);\n\t\t\twants[n] = 1;\n\t\t\tgotvar = 1;\n\t\t}\n\t}\n\tif (gotvar) {\n\t\tfor (n = 1; n <= CS_MAXCODE; n++)\n\t\t\tif (wants[n])\n\t\t\t\tctl_putsys(n);\n\t\tfor (n = 0; n + CS_MAXCODE + 1 < wants_count; n++)\n\t\t\tif (wants[n + CS_MAXCODE + 1]) {\n\t\t\t\tpch = ext_sys_var[n].text;\n\t\t\t\tctl_putdata(pch, strlen(pch), 0);\n\t\t\t}\n\t} else {\n\t\tfor (cs = def_sys_var; *cs != 0; cs++)\n\t\t\tctl_putsys((int)*cs);\n\t\tfor (kv = ext_sys_var; kv && !(EOV & kv->flags); kv++)\n\t\t\tif (DEF & kv->flags)\n\t\t\t\tctl_putdata(kv->text, strlen(kv->text),\n\t\t\t\t\t    0);\n\t}\n\tfree(wants);\n\tctl_flushpkt(0);\n}","target":0,"code_token_length":499,"total_token_length":735,"max_tokens_setting":1024}
+{"idx":344304,"func":"transit_state (struct dfa *d, int s, unsigned char const **pp)\n{\n  int s1;\n  int mbclen;\t\t\/* The length of current input multibyte character. *\/\n  int maxlen = 0;\n  int i, j;\n  int *match_lens = NULL;\n  int nelem = d->states[s].mbps.nelem; \/* Just a alias.  *\/\n  position_set follows;\n  unsigned char const *p1 = *pp;\n  wchar_t wc;\n\n  if (nelem > 0)\n    \/* This state has (a) multibyte operator(s).\n       We check whether each of them can match or not.  *\/\n    {\n      \/* Note: caller must free the return value of this function.  *\/\n      match_lens = check_matching_with_multibyte_ops(d, s, *pp - buf_begin);\n\n      for (i = 0; i < nelem; i++)\n        \/* Search the operator which match the longest string,\n           in this state.  *\/\n        {\n          if (match_lens[i] > maxlen)\n            maxlen = match_lens[i];\n        }\n    }\n\n  if (nelem == 0 || maxlen == 0)\n    \/* This state has no multibyte operator which can match.\n       We need to check only one single byte character.  *\/\n    {\n      status_transit_state rs;\n      rs = transit_state_singlebyte(d, s, *pp, &s1);\n\n      \/* We must update the pointer if state transition succeeded.  *\/\n      if (rs == TRANSIT_STATE_DONE)\n        ++*pp;\n\n      free(match_lens);\n      return s1;\n    }\n\n  \/* This state has some operators which can match a multibyte character.  *\/\n  alloc_position_set(&follows, d->nleaves);\n\n  \/* `maxlen' may be longer than the length of a character, because it may\n     not be a character but a (multi character) collating element.\n     We enumerate all of the positions which `s' can reach by consuming\n     `maxlen' bytes.  *\/\n  transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows);\n\n  wc = inputwcs[*pp - mbclen - buf_begin];\n  s1 = state_index(d, &follows, wchar_context (wc));\n  realloc_trans_if_necessary(d, s1);\n\n  while (*pp - p1 < maxlen)\n    {\n      transit_state_consume_1char(d, s1, pp, NULL, &mbclen, &follows);\n\n      for (i = 0; i < nelem ; i++)\n        {\n          if (match_lens[i] == *pp - p1)\n            for (j = 0;\n                 j < d->follows[d->states[s1].mbps.elems[i].index].nelem; j++)\n              insert(d->follows[d->states[s1].mbps.elems[i].index].elems[j],\n                     &follows);\n        }\n\n      wc = inputwcs[*pp - mbclen - buf_begin];\n      s1 = state_index(d, &follows, wchar_context (wc));\n      realloc_trans_if_necessary(d, s1);\n    }\n  free(match_lens);\n  free(follows.elems);\n  return s1;\n}","target":1,"code_token_length":708,"total_token_length":944,"max_tokens_setting":1024}
+{"idx":131768,"func":"flatpak_repo_save_digested_summary_delta (OstreeRepo   *repo,\n                                          const char   *from_digest,\n                                          const char   *to_digest,\n                                          GBytes       *delta,\n                                          GCancellable *cancellable,\n                                          GError      **error)\n{\n  int repo_dfd = ostree_repo_get_dfd (repo);\n  g_autofree char *path = NULL;\n  g_autofree char *filename = g_strconcat (from_digest, \"-\", to_digest, \".delta\", NULL);\n  struct stat stbuf;\n\n  if (!glnx_shutil_mkdir_p_at (repo_dfd, \"summaries\",\n                               0775,\n                               cancellable,\n                               error))\n    return FALSE;\n\n  path = g_build_filename (\"summaries\", filename, NULL);\n\n  \/* Check for pre-existing copy of same size and avoid re-writing it *\/\n  if (fstatat (repo_dfd, path, &stbuf, 0) == 0 &&\n      stbuf.st_size == g_bytes_get_size (delta))\n    {\n      g_debug (\"Reusing digested summary-diff for %s\", filename);\n      return TRUE;\n    }\n\n  if (!glnx_file_replace_contents_at (repo_dfd, path,\n                                      g_bytes_get_data (delta, NULL),\n                                      g_bytes_get_size (delta),\n                                      ostree_repo_get_disable_fsync (repo) ? GLNX_FILE_REPLACE_NODATASYNC : GLNX_FILE_REPLACE_DATASYNC_NEW,\n                                      cancellable, error))\n    return FALSE;\n\n  g_debug (\"Wrote digested summary delta at %s\", path);\n  return TRUE;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":105563,"func":"static int coolkey_write_object(sc_card_t *card, unsigned long object_id,\n\t\t\tsize_t offset, const u8 *buf, size_t buf_len, const u8 *nonce, size_t nonce_size)\n{\n\tcoolkey_write_object_param_t params;\n\tsize_t operation_len;\n\tsize_t left = buf_len;\n\tint r;\n\tsize_t max_operation_len;\n\n\t\/* set limit for the card's maximum send size and short write *\/\n\tmax_operation_len = MIN(COOLKEY_MAX_CHUNK_SIZE, (card->max_send_size - sizeof(coolkey_read_object_param_t) - nonce_size));\n\n\tulong2bebytes(¶ms.head.object_id[0], object_id);\n\n\tdo {\n\t\tulong2bebytes(¶ms.head.offset[0], offset);\n\t\toperation_len = MIN(left, max_operation_len);\n\t\tparams.head.length = operation_len;\n\t\tmemcpy(params.buf, buf, operation_len);\n\t\tr = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_WRITE_OBJECT, 0, 0,\n\t\t\t(u8 *)¶ms, sizeof(params.head)+operation_len, NULL, 0, nonce, nonce_size);\n\t\tif (r < 0) {\n\t\t\tgoto fail;\n\t\t}\n\t\tbuf += operation_len;\n\t\toffset += operation_len;\n\t\tleft -= operation_len;\n\t} while (left != 0);\n\n\treturn buf_len - left;\n\nfail:\n\treturn r;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":55734,"func":"void CL_DemoCompleted( void )\n{\n\tchar buffer[ MAX_STRING_CHARS ];\n\n\tif( cl_timedemo && cl_timedemo->integer )\n\t{\n\t\tint\ttime;\n\t\t\n\t\ttime = Sys_Milliseconds() - clc.timeDemoStart;\n\t\tif( time > 0 )\n\t\t{\n\t\t\t\/\/ Millisecond times are frame durations:\n\t\t\t\/\/ minimum\/average\/maximum\/std deviation\n\t\t\tCom_sprintf( buffer, sizeof( buffer ),\n\t\t\t\t\t\"%i frames %3.1f seconds %3.1f fps %d.0\/%.1f\/%d.0\/%.1f ms\\n\",\n\t\t\t\t\tclc.timeDemoFrames,\n\t\t\t\t\ttime\/1000.0,\n\t\t\t\t\tclc.timeDemoFrames*1000.0 \/ time,\n\t\t\t\t\tclc.timeDemoMinDuration,\n\t\t\t\t\ttime \/ (float)clc.timeDemoFrames,\n\t\t\t\t\tclc.timeDemoMaxDuration,\n\t\t\t\t\tCL_DemoFrameDurationSDev( ) );\n\t\t\tCom_Printf( \"%s\", buffer );\n\n\t\t\t\/\/ Write a log of all the frame durations\n\t\t\tif( cl_timedemoLog && strlen( cl_timedemoLog->string ) > 0 )\n\t\t\t{\n\t\t\t\tint i;\n\t\t\t\tint numFrames;\n\t\t\t\tfileHandle_t f;\n\n\t\t\t\tif( ( clc.timeDemoFrames - 1 ) > MAX_TIMEDEMO_DURATIONS )\n\t\t\t\t\tnumFrames = MAX_TIMEDEMO_DURATIONS;\n\t\t\t\telse\n\t\t\t\t\tnumFrames = clc.timeDemoFrames - 1;\n\n\t\t\t\tf = FS_FOpenFileWrite( cl_timedemoLog->string );\n\t\t\t\tif( f )\n\t\t\t\t{\n\t\t\t\t\tFS_Printf( f, \"# %s\", buffer );\n\n\t\t\t\t\tfor( i = 0; i < numFrames; i++ )\n\t\t\t\t\t\tFS_Printf( f, \"%d\\n\", clc.timeDemoDurations[ i ] );\n\n\t\t\t\t\tFS_FCloseFile( f );\n\t\t\t\t\tCom_Printf( \"%s written\\n\", cl_timedemoLog->string );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tCom_Printf( \"Couldn't open %s for writing\\n\",\n\t\t\t\t\t\t\tcl_timedemoLog->string );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tCL_Disconnect( qtrue );\n\tCL_NextDemo();\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":119481,"func":"static gboolean\nverify_generic_parameters (MonoClass *class)\n{\n\tint i;\n\tMonoGenericContainer *gc = class->generic_container;\n\tMonoBitSet *used_args = mono_bitset_new (gc->type_argc, 0);\n\n\tfor (i = 0; i < gc->type_argc; ++i) {\n\t\tMonoGenericParamInfo *param_info = mono_generic_container_get_param_info (gc, i);\n\t\tMonoClass **constraints;\n\n\t\tif (!param_info->constraints)\n\t\t\tcontinue;\n\n\t\tmono_bitset_clear_all (used_args);\n\t\tmono_bitset_set_fast (used_args, i);\n\n\t\tfor (constraints = param_info->constraints; *constraints; ++constraints) {\n\t\t\tMonoClass *ctr = *constraints;\n\t\t\tMonoType *constraint_type = &ctr->byval_arg;\n\n\t\t\tif (!mono_type_is_valid_type_in_context (constraint_type, &gc->context))\n\t\t\t\tgoto fail;\n\n\t\t\tif (mono_type_is_generic_argument (constraint_type) && !recursive_mark_constraint_args (used_args, gc, constraint_type))\n\t\t\t\tgoto fail;\n\t\t\tif (ctr->generic_class && !mono_class_is_valid_generic_instantiation (NULL, ctr))\n\t\t\t\tgoto fail;\n\t\t}\n\t}\n\tmono_bitset_free (used_args);\n\treturn TRUE;\n\nfail:\n\tmono_bitset_free (used_args);\n\treturn FALSE;","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":332161,"func":"void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],\n\n                   const uint8_t *src_data[4], const int src_linesizes[4],\n\n                   enum AVPixelFormat pix_fmt, int width, int height)\n\n{\n\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);\n\n\n\n    if (!desc || desc->flags & PIX_FMT_HWACCEL)\n\n\n\n\n    if (desc->flags & PIX_FMT_PAL ||\n\n        desc->flags & PIX_FMT_PSEUDOPAL) {\n\n        av_image_copy_plane(dst_data[0], dst_linesizes[0],\n\n                            src_data[0], src_linesizes[0],\n\n                            width, height);\n\n        \/* copy the palette *\/\n\n        memcpy(dst_data[1], src_data[1], 4*256);\n\n    } else {\n\n        int i, planes_nb = 0;\n\n\n\n        for (i = 0; i < desc->nb_components; i++)\n\n            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);\n\n\n\n        for (i = 0; i < planes_nb; i++) {\n\n            int h = height;\n\n            int bwidth = av_image_get_linesize(pix_fmt, width, i);\n\n\n\n\n\n            if (i == 1 || i == 2) {\n\n                h= -((-height)>>desc->log2_chroma_h);\n\n\n            av_image_copy_plane(dst_data[i], dst_linesizes[i],\n\n                                src_data[i], src_linesizes[i],\n\n                                bwidth, h);\n\n\n","target":1,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":179269,"func":"static int h2c_frt_init(struct connection *conn)\n{\n\tstruct h2c *h2c;\n\tstruct task *t = NULL;\n\tstruct session *sess = conn->owner;\n\n\th2c = pool_alloc(pool_head_h2c);\n\tif (!h2c)\n\t\tgoto fail;\n\n\n\th2c->shut_timeout = h2c->timeout = sess->fe->timeout.client;\n\tif (tick_isset(sess->fe->timeout.clientfin))\n\t\th2c->shut_timeout = sess->fe->timeout.clientfin;\n\n\th2c->task = NULL;\n\tif (tick_isset(h2c->timeout)) {\n\t\tt = task_new(tid_bit);\n\t\tif (!t)\n\t\t\tgoto fail;\n\n\t\th2c->task = t;\n\t\tt->process = h2_timeout_task;\n\t\tt->context = h2c;\n\t\tt->expire = tick_add(now_ms, h2c->timeout);\n\t}\n\n\th2c->ddht = hpack_dht_alloc(h2_settings_header_table_size);\n\tif (!h2c->ddht)\n\t\tgoto fail;\n\n\t\/* Initialise the context. *\/\n\th2c->st0 = H2_CS_PREFACE;\n\th2c->conn = conn;\n\th2c->max_id = -1;\n\th2c->errcode = H2_ERR_NO_ERROR;\n\th2c->flags = H2_CF_NONE;\n\th2c->rcvd_c = 0;\n\th2c->rcvd_s = 0;\n\th2c->nb_streams = 0;\n\n\th2c->dbuf = &buf_empty;\n\th2c->dsi = -1;\n\th2c->msi = -1;\n\th2c->last_sid = -1;\n\n\th2c->mbuf = &buf_empty;\n\th2c->miw = 65535; \/* mux initial window size *\/\n\th2c->mws = 65535; \/* mux window size *\/\n\th2c->mfs = 16384; \/* initial max frame size *\/\n\th2c->streams_by_id = EB_ROOT_UNIQUE;\n\tLIST_INIT(&h2c->send_list);\n\tLIST_INIT(&h2c->fctl_list);\n\tLIST_INIT(&h2c->buf_wait.list);\n\tconn->mux_ctx = h2c;\n\n\tif (t)\n\t\ttask_queue(t);\n\tconn_xprt_want_recv(conn);\n\n\t\/* mux->wake will be called soon to complete the operation *\/\n\treturn 0;\n fail:\n\tif (t)\n\t\ttask_free(t);\n\tpool_free(pool_head_h2c, h2c);\n\treturn -1;\n}\n","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":443830,"func":"g_tls_connection_base_set_property (GObject      *object,\n                                    guint         prop_id,\n                                    const GValue *value,\n                                    GParamSpec   *pspec)\n{\n  GTlsConnectionBase *tls = G_TLS_CONNECTION_BASE (object);\n  GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);\n  GInputStream *istream;\n  GOutputStream *ostream;\n  gboolean system_certdb;\n  GTlsBackend *backend;\n\n  switch (prop_id)\n    {\n    case PROP_BASE_IO_STREAM:\n      g_assert (!g_value_get_object (value) || !priv->base_socket);\n\n      if (priv->base_io_stream)\n        {\n          g_object_unref (priv->base_io_stream);\n          priv->base_istream = NULL;\n          priv->base_ostream = NULL;\n        }\n      priv->base_io_stream = g_value_dup_object (value);\n      if (!priv->base_io_stream)\n        return;\n\n      istream = g_io_stream_get_input_stream (priv->base_io_stream);\n      ostream = g_io_stream_get_output_stream (priv->base_io_stream);\n\n      if (G_IS_POLLABLE_INPUT_STREAM (istream) &&\n          g_pollable_input_stream_can_poll (G_POLLABLE_INPUT_STREAM (istream)))\n        {\n          priv->base_istream = G_POLLABLE_INPUT_STREAM (istream);\n          priv->tls_istream = g_tls_input_stream_new (tls);\n        }\n      if (G_IS_POLLABLE_OUTPUT_STREAM (ostream) &&\n          g_pollable_output_stream_can_poll (G_POLLABLE_OUTPUT_STREAM (ostream)))\n        {\n          priv->base_ostream = G_POLLABLE_OUTPUT_STREAM (ostream);\n          priv->tls_ostream = g_tls_output_stream_new (tls);\n        }\n      break;\n\n    case PROP_BASE_SOCKET:\n      g_assert (!g_value_get_object (value) || !priv->base_io_stream);\n\n      g_clear_object (&priv->base_socket);\n      priv->base_socket = g_value_dup_object (value);\n      break;\n\n    case PROP_REQUIRE_CLOSE_NOTIFY:\n      priv->require_close_notify = g_value_get_boolean (value);\n      break;\n\n    case PROP_REHANDSHAKE_MODE:\n      priv->rehandshake_mode = g_value_get_enum (value);\n      break;\n\n    case PROP_USE_SYSTEM_CERTDB:\n      system_certdb = g_value_get_boolean (value);\n      if (system_certdb != priv->is_system_certdb)\n        {\n          g_clear_object (&priv->database);\n          if (system_certdb)\n            {\n              backend = g_tls_backend_get_default ();\n              priv->database = g_tls_backend_get_default_database (backend);\n            }\n          priv->is_system_certdb = system_certdb;\n          priv->database_is_unset = FALSE;\n        }\n      break;\n\n    case PROP_DATABASE:\n      g_clear_object (&priv->database);\n      priv->database = g_value_dup_object (value);\n      priv->is_system_certdb = FALSE;\n      priv->database_is_unset = FALSE;\n      break;\n\n    case PROP_CERTIFICATE:\n      if (priv->certificate)\n        g_object_unref (priv->certificate);\n      priv->certificate = g_value_dup_object (value);\n      break;\n\n    case PROP_INTERACTION:\n      g_clear_object (&priv->interaction);\n      priv->interaction = g_value_dup_object (value);\n      break;\n\n    case PROP_ADVERTISED_PROTOCOLS:\n      g_clear_pointer (&priv->advertised_protocols, g_strfreev);\n      priv->advertised_protocols = g_value_dup_boxed (value);\n      break;\n\n    default:\n      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);\n    }\n}","target":0,"code_token_length":749,"total_token_length":985,"max_tokens_setting":1024}
+{"idx":462706,"func":"TEST_F(QueryPlannerTest, LockstepOrEnumerationSanityCheckTwoChildrenDifferentNumSolutions) {\n    params.options =\n        QueryPlannerParams::NO_TABLE_SCAN | QueryPlannerParams::ENUMERATE_OR_CHILDREN_LOCKSTEP;\n    addIndex(BSON(\"a\" << 1 << \"b\" << 1));\n    addIndex(BSON(\"a\" << 1 << \"c\" << 1));\n\n    runQueryAsCommand(fromjson(\"{find: 'testns', filter: {a: 1, $or: [{b: 1}, {b: 2, c: 2}]}}\"));\n\n    assertNumSolutions(4U);\n\n    assertSolutionExists(\n        \"{fetch: {filter: null, node: {or: {nodes: [{ixscan: {pattern: {a: 1, b: 1}}}, {fetch: \"\n        \"{filter: {c: {$eq: 2}}, node: {ixscan: {pattern: {a: 1, b: 1}}}}}]}}}}\");\n    assertSolutionExists(\n        \"{fetch: {filter: null, node: {or: {nodes: [{ixscan: {pattern: {a: 1, b: 1}}}, {fetch: \"\n        \"{filter: {b: {$eq: 2}}, node: {ixscan: {pattern: {a: 1, c: 1}}}}}]}}}}\");\n    assertSolutionExists(\n        \"{fetch: {filter: {$or: [{b: {$eq: 1}}, {b: {$eq: 2}, c: {$eq: 2}}]}, node: {ixscan: \"\n        \"{pattern: {a: 1, b: 1}}}}}}}\");\n    assertSolutionExists(\n        \"{fetch: {filter: {$or: [{b: {$eq: 1}}, {b: {$eq: 2}, c: {$eq: 2}}]}, node: {ixscan: \"\n        \"{pattern: {a: 1, c: 1}}}}}}}\");\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":161207,"func":"static int buffer_want_with_caps(const git_remote_head *head, transport_smart_caps *caps, git_buf *buf)\n{\n\tgit_buf str = GIT_BUF_INIT;\n\tchar oid[GIT_OID_HEXSZ +1] = {0};\n\tsize_t len;\n\n\t\/* Prefer multi_ack_detailed *\/\n\tif (caps->multi_ack_detailed)\n\t\tgit_buf_puts(&str, GIT_CAP_MULTI_ACK_DETAILED \" \");\n\telse if (caps->multi_ack)\n\t\tgit_buf_puts(&str, GIT_CAP_MULTI_ACK \" \");\n\n\t\/* Prefer side-band-64k if the server supports both *\/\n\tif (caps->side_band_64k)\n\t\tgit_buf_printf(&str, \"%s \", GIT_CAP_SIDE_BAND_64K);\n\telse if (caps->side_band)\n\t\tgit_buf_printf(&str, \"%s \", GIT_CAP_SIDE_BAND);\n\n\tif (caps->include_tag)\n\t\tgit_buf_puts(&str, GIT_CAP_INCLUDE_TAG \" \");\n\n\tif (caps->thin_pack)\n\t\tgit_buf_puts(&str, GIT_CAP_THIN_PACK \" \");\n\n\tif (caps->ofs_delta)\n\t\tgit_buf_puts(&str, GIT_CAP_OFS_DELTA \" \");\n\n\tif (git_buf_oom(&str))\n\t\treturn -1;\n\n\tlen = strlen(\"XXXXwant \") + GIT_OID_HEXSZ + 1 \/* NUL *\/ +\n\t\t git_buf_len(&str) + 1 \/* LF *\/;\n\n\tif (len > 0xffff) {\n\t\tgiterr_set(GITERR_NET,\n\t\t\t\"Tried to produce packet with invalid length %\" PRIuZ, len);\n\t\treturn -1;\n\t}\n\n\tgit_buf_grow_by(buf, len);\n\tgit_oid_fmt(oid, &head->oid);\n\tgit_buf_printf(buf,\n\t\t\"%04xwant %s %s\\n\", (unsigned int)len, oid, git_buf_cstr(&str));\n\tgit_buf_free(&str);\n\n\tGITERR_CHECK_ALLOC_BUF(buf);\n\n\treturn 0;\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":81193,"func":"static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id)\n{\n\tstruct tg3_napi *tnapi = dev_id;\n\tstruct tg3 *tp = tnapi->tp;\n\tstruct tg3_hw_status *sblk = tnapi->hw_status;\n\tunsigned int handled = 1;\n\n\t\/* In INTx mode, it is possible for the interrupt to arrive at\n\t * the CPU before the status block posted prior to the interrupt.\n\t * Reading the PCI State register will confirm whether the\n\t * interrupt is ours and will flush the status block.\n\t *\/\n\tif (unlikely(sblk->status_tag == tnapi->last_irq_tag)) {\n\t\tif (tg3_flag(tp, CHIP_RESETTING) ||\n\t\t    (tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {\n\t\t\thandled = 0;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\t\/*\n\t * writing any value to intr-mbox-0 clears PCI INTA# and\n\t * chip-internal interrupt pending events.\n\t * writing non-zero to intr-mbox-0 additional tells the\n\t * NIC to stop sending us irqs, engaging \"in-intr-handler\"\n\t * event coalescing.\n\t *\n\t * Flush the mailbox to de-assert the IRQ immediately to prevent\n\t * spurious interrupts.  The flush impacts performance but\n\t * excessive spurious interrupts can be worse in some cases.\n\t *\/\n\ttw32_mailbox_f(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);\n\n\t\/*\n\t * In a shared interrupt configuration, sometimes other devices'\n\t * interrupts will scream.  We record the current status tag here\n\t * so that the above check can report that the screaming interrupts\n\t * are unhandled.  Eventually they will be silenced.\n\t *\/\n\ttnapi->last_irq_tag = sblk->status_tag;\n\n\tif (tg3_irq_sync(tp))\n\t\tgoto out;\n\n\tprefetch(&tnapi->rx_rcb[tnapi->rx_rcb_ptr]);\n\n\tnapi_schedule(&tnapi->napi);\n\nout:\n\treturn IRQ_RETVAL(handled);\n}","target":0,"code_token_length":460,"total_token_length":696,"max_tokens_setting":1024}
+{"idx":293269,"func":"mwifiex_wmm_setup_queue_priorities(struct mwifiex_private *priv,\n\t\t\t\t   struct ieee_types_wmm_parameter *wmm_ie)\n{\n\tu16 cw_min, avg_back_off, tmp[4];\n\tu32 i, j, num_ac;\n\tu8 ac_idx;\n\n\tif (!wmm_ie || !priv->wmm_enabled) {\n\t\t\/* WMM is not enabled, just set the defaults and return *\/\n\t\tmwifiex_wmm_default_queue_priorities(priv);\n\t\treturn;\n\t}\n\n\tmwifiex_dbg(priv->adapter, INFO,\n\t\t    \"info: WMM Parameter IE: version=%d,\\t\"\n\t\t    \"qos_info Parameter Set Count=%d, Reserved=%#x\\n\",\n\t\t    wmm_ie->version, wmm_ie->qos_info_bitmap &\n\t\t    IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK,\n\t\t    wmm_ie->reserved);\n\n\tfor (num_ac = 0; num_ac < ARRAY_SIZE(wmm_ie->ac_params); num_ac++) {\n\t\tu8 ecw = wmm_ie->ac_params[num_ac].ecw_bitmap;\n\t\tu8 aci_aifsn = wmm_ie->ac_params[num_ac].aci_aifsn_bitmap;\n\t\tcw_min = (1 << (ecw & MWIFIEX_ECW_MIN)) - 1;\n\t\tavg_back_off = (cw_min >> 1) + (aci_aifsn & MWIFIEX_AIFSN);\n\n\t\tac_idx = wmm_aci_to_qidx_map[(aci_aifsn & MWIFIEX_ACI) >> 5];\n\t\tpriv->wmm.queue_priority[ac_idx] = ac_idx;\n\t\ttmp[ac_idx] = avg_back_off;\n\n\t\tmwifiex_dbg(priv->adapter, INFO,\n\t\t\t    \"info: WMM: CWmax=%d CWmin=%d Avg Back-off=%d\\n\",\n\t\t\t    (1 << ((ecw & MWIFIEX_ECW_MAX) >> 4)) - 1,\n\t\t\t    cw_min, avg_back_off);\n\t\tmwifiex_wmm_ac_debug_print(&wmm_ie->ac_params[num_ac]);\n\t}\n\n\t\/* Bubble sort *\/\n\tfor (i = 0; i < num_ac; i++) {\n\t\tfor (j = 1; j < num_ac - i; j++) {\n\t\t\tif (tmp[j - 1] > tmp[j]) {\n\t\t\t\tswap(tmp[j - 1], tmp[j]);\n\t\t\t\tswap(priv->wmm.queue_priority[j - 1],\n\t\t\t\t     priv->wmm.queue_priority[j]);\n\t\t\t} else if (tmp[j - 1] == tmp[j]) {\n\t\t\t\tif (priv->wmm.queue_priority[j - 1]\n\t\t\t\t    < priv->wmm.queue_priority[j])\n\t\t\t\t\tswap(priv->wmm.queue_priority[j - 1],\n\t\t\t\t\t     priv->wmm.queue_priority[j]);\n\t\t\t}\n\t\t}\n\t}\n\n\tmwifiex_wmm_queue_priorities_tid(priv);\n}","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":80705,"func":"std::string get_binary_file_location(const std::string& type, const std::string& filename)\n{\n\tDBG_FS << \"Looking for '\" << filename << \"'.\" << std::endl;\n\n\tif (filename.empty()) {\n\t\tLOG_FS << \"  invalid filename (type: \" << type <<\")\" << std::endl;\n\t\treturn std::string();\n\t}\n\n\t\/\/ Some parts of Wesnoth enjoy putting \"..\" inside filenames. This is\n\t\/\/ bad and should be fixed. But in the meantime, deal with them in a dumb way.\n\tstd::string::size_type pos = filename.rfind(\"..\/\");\n\tif (pos != std::string::npos) {\n\t\tstd::string nf = filename.substr(pos + 3);\n\t\tLOG_FS << \"Illegal path '\" << filename << \"' replaced by '\" << nf << \"'\" << std::endl;\n\t\treturn get_binary_file_location(type, nf);\n\t}\n\n\tif (filename.find(\"..\") != std::string::npos) {\n\t\tERR_FS << \"Illegal path '\" << filename << \"' (\\\"..\\\" not allowed).\" << std::endl;\n\t\treturn std::string();\n\t}\n\n\tBOOST_FOREACH(const std::string &path, get_binary_paths(type))\n\t{\n\t\tconst std::string file = path + filename;\n\t\tDBG_FS << \"  checking '\" << path << \"'\" << std::endl;\n\t\tif(file_exists(file)) {\n\t\t\tDBG_FS << \"  found at '\" << file << \"'\" << std::endl;\n\t\t\treturn file;\n\t\t}\n\t}\n\n\tDBG_FS << \"  not found\" << std::endl;\n\treturn std::string();\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":85950,"func":"static bool parse_reconnect(struct pool *pool, json_t *val)\n{\n\tchar *sockaddr_url, *stratum_port, *tmp;\n\tchar *url, *port, address[256];\n\n\tmemset(address, 0, 255);\n\turl = (char *)json_string_value(json_array_get(val, 0));\n\tif (!url)\n\t\turl = pool->sockaddr_url;\n\telse {\n\t\tchar *dot_pool, *dot_reconnect;\n\t\tdot_pool = strchr(pool->sockaddr_url, '.');\n\t\tif (!dot_pool) {\n\t\t\tapplog(LOG_ERR, \"Denied stratum reconnect request for pool without domain '%s'\",\n\t\t\t       pool->sockaddr_url);\n\t\t\treturn false;\n\t\t}\n\t\tdot_reconnect = strchr(url, '.');\n\t\tif (!dot_reconnect) {\n\t\t\tapplog(LOG_ERR, \"Denied stratum reconnect request to url without domain '%s'\",\n\t\t\t       url);\n\t\t\treturn false;\n\t\t}\n\t\tif (strcmp(dot_pool, dot_reconnect)) {\n\t\t\tapplog(LOG_ERR, \"Denied stratum reconnect request to non-matching domain url '%s'\",\n\t\t\t\tpool->sockaddr_url);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tport = (char *)json_string_value(json_array_get(val, 1));\n\tif (!port)\n\t\tport = pool->stratum_port;\n\n\tsnprintf(address, 254, \"%s:%s\", url, port);\n\n\tif (!extract_sockaddr(address, &sockaddr_url, &stratum_port))\n\t\treturn false;\n\n\tapplog(LOG_WARNING, \"Stratum reconnect requested from pool %d to %s\", pool->pool_no, address);\n\n\tclear_pool_work(pool);\n\n\tmutex_lock(&pool->stratum_lock);\n\t__suspend_stratum(pool);\n\ttmp = pool->sockaddr_url;\n\tpool->sockaddr_url = sockaddr_url;\n\tpool->stratum_url = pool->sockaddr_url;\n\tfree(tmp);\n\ttmp = pool->stratum_port;\n\tpool->stratum_port = stratum_port;\n\tfree(tmp);\n\tmutex_unlock(&pool->stratum_lock);\n\n\tif (!restart_stratum(pool)) {\n\t\tpool_failed(pool);\n\t\treturn false;\n\t}\n\n\treturn true;\n}","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":258933,"func":"PHP_FUNCTION(imagegrabwindow)\n{\n\tHWND window;\n\tlong client_area = 0;\n\tRECT rc = {0};\n\tRECT rc_win = {0};\n\tint Width, Height;\n\tHDC\t\thdc;\n\tHDC memDC;\n\tHBITMAP memBM;\n\tHBITMAP hOld;\n\tHINSTANCE handle;\n\tlong lwindow_handle;\n\ttypedef BOOL (WINAPI *tPrintWindow)(HWND, HDC,UINT);\n\ttPrintWindow pPrintWindow = 0;\n\tgdImagePtr im;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l|l\", &lwindow_handle, &client_area) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\twindow = (HWND) lwindow_handle;\n\n\tif (!IsWindow(window)) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"Invalid window handle\");\n\t\tRETURN_FALSE;\n\t}\n\n\thdc\t\t= GetDC(0);\n\n\tif (client_area) {\n\t\tGetClientRect(window, &rc);\n\t\tWidth = rc.right;\n\t\tHeight = rc.bottom;\n\t} else {\n\t\tGetWindowRect(window, &rc);\n\t\tWidth\t= rc.right - rc.left;\n\t\tHeight\t= rc.bottom - rc.top;\n\t}\n\n\tWidth\t\t= (Width\/4)*4;\n\n\tmemDC\t= CreateCompatibleDC(hdc);\n\tmemBM\t= CreateCompatibleBitmap(hdc, Width, Height);\n\thOld\t= (HBITMAP) SelectObject (memDC, memBM);\n\n\n\thandle = LoadLibrary(\"User32.dll\");\n\tif ( handle == 0 ) {\n\t\tgoto clean;\n\t}\n\tpPrintWindow = (tPrintWindow) GetProcAddress(handle, \"PrintWindow\");\n\n\tif ( pPrintWindow )  {\n\t\tpPrintWindow(window, memDC, (UINT) client_area);\n\t} else {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Windows API too old\");\n\t\tgoto clean;\n\t}\n\n\tFreeLibrary(handle);\n\n\tim = gdImageCreateTrueColor(Width, Height);\n\tif (im) {\n\t\tint x,y;\n\t\tfor (y=0; y <= Height; y++) {\n\t\t\tfor (x=0; x <= Width; x++) {\n\t\t\t\tint c = GetPixel(memDC, x,y);\n\t\t\t\tgdImageSetPixel(im, x, y, gdTrueColor(GetRValue(c), GetGValue(c), GetBValue(c)));\n\t\t\t}\n\t\t}\n\t}\n\nclean:\n\tSelectObject(memDC,hOld);\n\tDeleteObject(memBM);\n\tDeleteDC(memDC);\n\tReleaseDC( 0, hdc );\n\n\tif (!im) {\n\t\tRETURN_FALSE;\n\t} else {\n\t\tZEND_REGISTER_RESOURCE(return_value, im, le_gd);\n\t}\n}","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":48333,"func":"int pgpPrtParams(const uint8_t * pkts, size_t pktlen, unsigned int pkttype,\n\t\t pgpDigParams * ret)\n{\n    const uint8_t *p = pkts;\n    const uint8_t *pend = pkts + pktlen;\n    pgpDigParams digp = NULL;\n    pgpDigParams selfsig = NULL;\n    int i = 0;\n    int alloced = 16; \/* plenty for normal cases *\/\n    struct pgpPkt *all = xmalloc(alloced * sizeof(*all));\n    int rc = -1; \/* assume failure *\/\n    int expect = 0;\n    int prevtag = 0;\n\n    while (p < pend) {\n\tstruct pgpPkt *pkt = &all[i];\n\tif (decodePkt(p, (pend - p), pkt))\n\t    break;\n\n\tif (digp == NULL) {\n\t    if (pkttype && pkt->tag != pkttype) {\n\t\tbreak;\n\t    } else {\n\t\tdigp = pgpDigParamsNew(pkt->tag);\n\t    }\n\t}\n\n\tif (expect) {\n\t    if (pkt->tag != expect)\n\t\tbreak;\n\t    selfsig = pgpDigParamsNew(pkt->tag);\n\t}\n\n\tif (pgpPrtPkt(pkt, selfsig ? selfsig : digp))\n\t    break;\n\n\tif (selfsig) {\n\t    \/* subkeys must be followed by binding signature *\/\n\t    if (prevtag == PGPTAG_PUBLIC_SUBKEY) {\n\t\tif (selfsig->sigtype != PGPSIGTYPE_SUBKEY_BINDING)\n\t\t    break;\n\t    }\n\n\t    int xx = pgpVerifySelf(digp, selfsig, all, i);\n\n\t    selfsig = pgpDigParamsFree(selfsig);\n\t    if (xx)\n\t\tbreak;\n\t    expect = 0;\n\t}\n\n\tif (pkt->tag == PGPTAG_PUBLIC_SUBKEY)\n\t    expect = PGPTAG_SIGNATURE;\n\tprevtag = pkt->tag;\n\n\ti++;\n\tp += (pkt->body - pkt->head) + pkt->blen;\n\tif (pkttype == PGPTAG_SIGNATURE)\n\t    break;\n\n\tif (alloced <= i) {\n\t    alloced *= 2;\n\t    all = xrealloc(all, alloced * sizeof(*all));\n\t}\n    }\n\n    rc = (digp && (p == pend) && expect == 0) ? 0 : -1;\n\n    free(all);\n    if (ret && rc == 0) {\n\t*ret = digp;\n    } else {\n\tpgpDigParamsFree(digp);\n    }\n    return rc;\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":100067,"func":"static void create_initterm_syms(RKext *kext, RList *ret, int type, ut64 *pointers) {\n\tint i = 0;\n\tint count = 0;\n\tfor (; pointers[i]; i++) {\n\t\tut64 func_vaddr = pointers[i];\n\t\tut64 text_start = kext->vaddr;\n\t\tut64 text_end = text_start + kext->text_range.size;\n\n\t\tif (text_start == text_end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (text_start > func_vaddr || func_vaddr >= text_end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\tif (!sym) {\n\t\t\tbreak;\n\t\t}\n\n\t\tsym->name = r_str_newf (\"%s.%s.%d\", kext_short_name (kext), (type == R_BIN_ENTRY_TYPE_INIT) ? \"init\" : \"fini\", count++);\n\t\tsym->vaddr = func_vaddr;\n\t\tsym->paddr = func_vaddr - kext->pa2va_exec;\n\t\tsym->size = 0;\n\t\tsym->forwarder = \"NONE\";\n\t\tsym->bind = \"GLOBAL\";\n\t\tsym->type = \"FUNC\";\n\n\t\tr_list_append (ret, sym);\n\t}\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":162050,"func":"static int setup_post_proxy_fail(REQUEST *request)\n{\n\tDICT_VALUE *dval = NULL;\n\tVALUE_PAIR *vp;\n\n\trequest->child_state = REQUEST_RUNNING;\n\n\tif (request->packet->code == PW_AUTHENTICATION_REQUEST) {\n\t\tdval = dict_valbyname(PW_POST_PROXY_TYPE, \"Fail-Authentication\");\n\n\t} else if (request->packet->code == PW_ACCOUNTING_REQUEST) {\n\t\tdval = dict_valbyname(PW_POST_PROXY_TYPE, \"Fail-Accounting\");\n\n#ifdef WITH_COA\n\t\t\/*\n\t\t *\tSee no_response_to_coa_request\n\t\t *\/\n\t} else if (((request->packet->code >> 8) & 0xff) == PW_COA_REQUEST) {\n\t\trequest->packet->code &= 0xff; \/* restore it *\/\n\n\t\tif (request->proxy->code == PW_COA_REQUEST) {\n\t\t\tdval = dict_valbyname(PW_POST_PROXY_TYPE, \"Fail-CoA\");\n\n\t\t} else if (request->proxy->code == PW_DISCONNECT_REQUEST) {\n\t\t\tdval = dict_valbyname(PW_POST_PROXY_TYPE, \"Fail-Disconnect\");\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\n#endif\n\t} else {\n\t\treturn 0;\n\t}\n\n\tif (!dval) dval = dict_valbyname(PW_POST_PROXY_TYPE, \"Fail\");\n\n\tif (!dval) {\n\t\tpairdelete(&request->config_items, PW_POST_PROXY_TYPE);\n\t\treturn 0;\n\t}\n\n\tvp = pairfind(request->config_items, PW_POST_PROXY_TYPE);\n\tif (!vp) vp = radius_paircreate(request, &request->config_items,\n\t\t\t\t\tPW_POST_PROXY_TYPE, PW_TYPE_INTEGER);\n\tvp->vp_integer = dval->value;\n\n\trad_assert(request->proxy_reply == NULL);\n\n\treturn 1;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":816,"func":"static int16_t * wmv2_pred_motion ( Wmv2Context * w , int * px , int * py ) {\n MpegEncContext * const s = & w -> s ;\n int xy , wrap , diff , type ;\n int16_t * A , * B , * C , * mot_val ;\n wrap = s -> b8_stride ;\n xy = s -> block_index [ 0 ] ;\n mot_val = s -> current_picture . f . motion_val [ 0 ] [ xy ] ;\n A = s -> current_picture . f . motion_val [ 0 ] [ xy - 1 ] ;\n B = s -> current_picture . f . motion_val [ 0 ] [ xy - wrap ] ;\n C = s -> current_picture . f . motion_val [ 0 ] [ xy + 2 - wrap ] ;\n if ( s -> mb_x && ! s -> first_slice_line && ! s -> mspel && w -> top_left_mv_flag ) diff = FFMAX ( FFABS ( A [ 0 ] - B [ 0 ] ) , FFABS ( A [ 1 ] - B [ 1 ] ) ) ;\n else diff = 0 ;\n if ( diff >= 8 ) type = get_bits1 ( & s -> gb ) ;\n else type = 2 ;\n if ( type == 0 ) {\n * px = A [ 0 ] ;\n * py = A [ 1 ] ;\n }\n else if ( type == 1 ) {\n * px = B [ 0 ] ;\n * py = B [ 1 ] ;\n }\n else {\n if ( s -> first_slice_line ) {\n * px = A [ 0 ] ;\n * py = A [ 1 ] ;\n }\n else {\n * px = mid_pred ( A [ 0 ] , B [ 0 ] , C [ 0 ] ) ;\n * py = mid_pred ( A [ 1 ] , B [ 1 ] , C [ 1 ] ) ;\n }\n }\n return mot_val ;\n }","target":1,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":322071,"func":"static void pc_dimm_plug(HotplugHandler *hotplug_dev,\n                         DeviceState *dev, Error **errp)\n{\n    int slot;\n    HotplugHandlerClass *hhc;\n    Error *local_err = NULL;\n    PCMachineState *pcms = PC_MACHINE(hotplug_dev);\n    MachineState *machine = MACHINE(hotplug_dev);\n    PCDIMMDevice *dimm = PC_DIMM(dev);\n    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);\n    MemoryRegion *mr = ddc->get_memory_region(dimm);\n    uint64_t addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,\n                                            &local_err);\n    if (local_err) {\n    addr = pc_dimm_get_free_addr(pcms->hotplug_memory_base,\n                                 memory_region_size(&pcms->hotplug_memory),\n                                 !addr ? NULL : &addr,\n                                 memory_region_size(mr), &local_err);\n    if (local_err) {\n    object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);\n    if (local_err) {\n    trace_mhp_pc_dimm_assigned_address(addr);\n    slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err);\n    if (local_err) {\n    slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot,\n                                 machine->ram_slots, &local_err);\n    if (local_err) {\n    object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err);\n    if (local_err) {\n    trace_mhp_pc_dimm_assigned_slot(slot);\n    if (!pcms->acpi_dev) {\n        error_setg(&local_err,\n                   \"memory hotplug is not enabled: missing acpi device\");\n    memory_region_add_subregion(&pcms->hotplug_memory,\n                                addr - pcms->hotplug_memory_base, mr);\n    vmstate_register_ram(mr, dev);\n    hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);\n    hhc->plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);\nout:\n    error_propagate(errp, local_err);","target":1,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":342561,"func":"static void xlnx_zynqmp_qspips_reset(DeviceState *d)\n\n{\n\n    XlnxZynqMPQSPIPS *s = XLNX_ZYNQMP_QSPIPS(d);\n\n    int i;\n\n\n\n    xilinx_spips_reset(d);\n\n\n\n    for (i = 0; i < XLNX_ZYNQMP_SPIPS_R_MAX; i++) {\n\n        s->regs[i] = 0;\n\n    }\n\n    fifo8_reset(&s->rx_fifo_g);\n\n    fifo8_reset(&s->rx_fifo_g);\n\n    fifo32_reset(&s->fifo_g);\n\n    s->regs[R_INTR_STATUS] = R_INTR_STATUS_RESET;\n\n    s->regs[R_GPIO] = 1;\n\n    s->regs[R_LPBK_DLY_ADJ] = R_LPBK_DLY_ADJ_RESET;\n\n    s->regs[R_GQSPI_GFIFO_THRESH] = 0x10;\n\n    s->regs[R_MOD_ID] = 0x01090101;\n\n    s->regs[R_GQSPI_IMR] = R_GQSPI_IMR_RESET;\n\n    s->regs[R_GQSPI_TX_THRESH] = 1;\n\n    s->regs[R_GQSPI_RX_THRESH] = 1;\n\n    s->regs[R_GQSPI_GPIO] = 1;\n\n    s->regs[R_GQSPI_LPBK_DLY_ADJ] = R_GQSPI_LPBK_DLY_ADJ_RESET;\n\n    s->regs[R_GQSPI_MOD_ID] = R_GQSPI_MOD_ID_RESET;\n\n    s->regs[R_QSPIDMA_DST_CTRL] = R_QSPIDMA_DST_CTRL_RESET;\n\n    s->regs[R_QSPIDMA_DST_I_MASK] = R_QSPIDMA_DST_I_MASK_RESET;\n\n    s->regs[R_QSPIDMA_DST_CTRL2] = R_QSPIDMA_DST_CTRL2_RESET;\n\n    s->man_start_com_g = false;\n\n    s->gqspi_irqline = 0;\n\n    xlnx_zynqmp_qspips_update_ixr(s);\n\n}\n","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":168955,"func":"static MagickBooleanType ReadPSDChannel(Image *image,\n  const ImageInfo *image_info,const PSDInfo *psd_info,LayerInfo* layer_info,\n  const size_t channel,const PSDCompressionType compression,\n  ExceptionInfo *exception)\n{\n  Image\n    *channel_image,\n    *mask;\n\n  MagickOffsetType\n    offset;\n\n  MagickBooleanType\n    status;\n\n  channel_image=image;\n  mask=(Image *) NULL;\n  if (layer_info->channel_info[channel].type < -1)\n    {\n      const char\n        *option;\n      \/*\n        Ignore mask that is not a user supplied layer mask, if the mask is\n        disabled or if the flags have unsupported values.\n      *\/\n      option=GetImageOption(image_info,\"psd:preserve-opacity-mask\");\n      if ((layer_info->channel_info[channel].type != -2) ||\n          (layer_info->mask.flags > 2) || ((layer_info->mask.flags & 0x02) &&\n           (IsStringTrue(option) == MagickFalse)))\n      {\n        SeekBlob(image,layer_info->channel_info[channel].size-2,SEEK_CUR);\n        return(MagickTrue);\n      }\n      mask=CloneImage(image,layer_info->mask.page.width,\n        layer_info->mask.page.height,MagickFalse,exception);\n      mask->matte=MagickFalse;\n      channel_image=mask;\n    }\n\n  offset=TellBlob(image);\n  status=MagickTrue;\n  switch(compression)\n  {\n    case Raw:\n      status=ReadPSDChannelRaw(channel_image,psd_info->channels,\n        layer_info->channel_info[channel].type,exception);\n      break;\n    case RLE:\n      {\n        MagickOffsetType\n          *sizes;\n\n        sizes=ReadPSDRLESizes(channel_image,psd_info,channel_image->rows);\n        if (sizes == (MagickOffsetType *) NULL)\n          ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n            image->filename);\n        status=ReadPSDChannelRLE(channel_image,psd_info,\n          layer_info->channel_info[channel].type,sizes,exception);\n        sizes=(MagickOffsetType *) RelinquishMagickMemory(sizes);\n      }\n      break;\n    case ZipWithPrediction:\n    case ZipWithoutPrediction:\n#ifdef MAGICKCORE_ZLIB_DELEGATE\n      status=ReadPSDChannelZip(channel_image,layer_info->channels,\n        layer_info->channel_info[channel].type,compression,\n        layer_info->channel_info[channel].size-2,exception);\n#else\n      (void) ThrowMagickException(exception,GetMagickModule(),\n          MissingDelegateWarning,\"DelegateLibrarySupportNotBuiltIn\",\n            \"'%s' (ZLIB)\",image->filename);\n#endif\n      break;\n    default:\n      (void) ThrowMagickException(exception,GetMagickModule(),TypeWarning,\n        \"CompressionNotSupported\",\"'%.20g'\",(double) compression);\n      break;\n  }\n\n  SeekBlob(image,offset+layer_info->channel_info[channel].size-2,SEEK_SET);\n  if (status == MagickFalse)\n    {\n      if (mask != (Image *) NULL)\n        DestroyImage(mask);\n      ThrowBinaryException(CoderError,\"UnableToDecompressImage\",\n        image->filename);\n    }\n  if (mask != (Image *) NULL)\n    {\n      if (status != MagickFalse)\n        layer_info->mask.image=mask;\n      else\n        mask=DestroyImage(mask);\n    }\n\n  return(status);\n}\n","target":0,"code_token_length":737,"total_token_length":973,"max_tokens_setting":1024}
+{"idx":25552,"func":"IN_PROC_BROWSER_TEST_F ( UnloadTest , BrowserListDoubleCloseBeforeUnloadCancel ) {\n NavigateToDataURL ( BEFORE_UNLOAD_HTML , \"beforeunload\" ) ;\n UnloadResults unload_results ;\n BrowserList : : CloseAllBrowsersWithProfile ( browser ( ) -> profile ( ) , base : : Bind ( & UnloadResults : : AddSuccess , base : : Unretained ( & unload_results ) ) , base : : Bind ( & UnloadResults : : AddAbort , base : : Unretained ( & unload_results ) ) , false ) ;\n BrowserList : : CloseAllBrowsersWithProfile ( browser ( ) -> profile ( ) , base : : Bind ( & UnloadResults : : AddSuccess , base : : Unretained ( & unload_results ) ) , base : : Bind ( & UnloadResults : : AddAbort , base : : Unretained ( & unload_results ) ) , false ) ;\n base : : string16 expected_title = base : : ASCIIToUTF16 ( \"cancelled\" ) ;\n content : : TitleWatcher title_watcher ( browser ( ) -> tab_strip_model ( ) -> GetActiveWebContents ( ) , expected_title ) ;\n ClickModalDialogButton ( false ) ;\n ASSERT_EQ ( expected_title , title_watcher . WaitAndGetTitle ( ) ) ;\n EXPECT_EQ ( 0 , unload_results . get_successes ( ) ) ;\n EXPECT_EQ ( 1 , unload_results . get_aborts ( ) ) ;\n content : : WindowedNotificationObserver window_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , content : : NotificationService : : AllSources ( ) ) ;\n chrome : : CloseWindow ( browser ( ) ) ;\n ClickModalDialogButton ( true ) ;\n window_observer . Wait ( ) ;\n }","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":395303,"func":"int TC_LOG_BINLOG::open(const char *opt_name)\n{\n  LOG_INFO log_info;\n  int      error= 1;\n\n  DBUG_ASSERT(total_ha_2pc > 1);\n  DBUG_ASSERT(opt_name && opt_name[0]);\n\n  mysql_mutex_init(key_BINLOG_LOCK_prep_xids,\n                   &LOCK_prep_xids, MY_MUTEX_INIT_FAST);\n  mysql_cond_init(key_BINLOG_COND_prep_xids, &COND_prep_xids, 0);\n\n  if (!my_b_inited(&index_file))\n  {\n    \/* There was a failure to open the index file, can't open the binlog *\/\n    cleanup();\n    return 1;\n  }\n\n  if (using_heuristic_recover())\n  {\n    \/* generate a new binlog to mask a corrupted one *\/\n    open(opt_name, LOG_BIN, 0, WRITE_CACHE, 0, max_binlog_size, 0, TRUE);\n    cleanup();\n    return 1;\n  }\n\n  if ((error= find_log_pos(&log_info, NullS, 1)))\n  {\n    if (error != LOG_INFO_EOF)\n      sql_print_error(\"find_log_pos() failed (error: %d)\", error);\n    else\n      error= 0;\n    goto err;\n  }\n\n  {\n    const char *errmsg;\n    IO_CACHE    log;\n    File        file;\n    Log_event  *ev=0;\n    Format_description_log_event fdle(BINLOG_VERSION);\n    char        log_name[FN_REFLEN];\n\n    if (! fdle.is_valid())\n      goto err;\n\n    do\n    {\n      strmake(log_name, log_info.log_file_name, sizeof(log_name)-1);\n    } while (!(error= find_next_log(&log_info, 1)));\n\n    if (error !=  LOG_INFO_EOF)\n    {\n      sql_print_error(\"find_log_pos() failed (error: %d)\", error);\n      goto err;\n    }\n\n    if ((file= open_binlog(&log, log_name, &errmsg)) < 0)\n    {\n      sql_print_error(\"%s\", errmsg);\n      goto err;\n    }\n\n    if ((ev= Log_event::read_log_event(&log, 0, &fdle)) &&\n        ev->get_type_code() == FORMAT_DESCRIPTION_EVENT &&\n        ev->flags & LOG_EVENT_BINLOG_IN_USE_F)\n    {\n      sql_print_information(\"Recovering after a crash using %s\", opt_name);\n      error= recover(&log, (Format_description_log_event *)ev);\n    }\n    else\n      error=0;\n\n    delete ev;\n    end_io_cache(&log);\n    mysql_file_close(file, MYF(MY_WME));\n\n    if (error)\n      goto err;\n  }\n\nerr:\n  return error;\n}","target":0,"code_token_length":572,"total_token_length":808,"max_tokens_setting":1024}
+{"idx":140579,"func":"TEST_P(JSITest, ArrayTest) {\n  eval(\"x = {1:2, '3':4, 5:'six', 'seven':['eight', 'nine']}\");\n\n  Object x = rt.global().getPropertyAsObject(rt, \"x\");\n  Array names = x.getPropertyNames(rt);\n  EXPECT_EQ(names.size(rt), 4);\n  std::unordered_set<std::string> strNames;\n  for (size_t i = 0; i < names.size(rt); ++i) {\n    Value n = names.getValueAtIndex(rt, i);\n    EXPECT_TRUE(n.isString());\n    strNames.insert(n.getString(rt).utf8(rt));\n  }\n\n  EXPECT_EQ(strNames.size(), 4);\n  EXPECT_EQ(strNames.count(\"1\"), 1);\n  EXPECT_EQ(strNames.count(\"3\"), 1);\n  EXPECT_EQ(strNames.count(\"5\"), 1);\n  EXPECT_EQ(strNames.count(\"seven\"), 1);\n\n  Object seven = x.getPropertyAsObject(rt, \"seven\");\n  Array arr = seven.getArray(rt);\n\n  EXPECT_EQ(arr.size(rt), 2);\n  EXPECT_EQ(arr.getValueAtIndex(rt, 0).getString(rt).utf8(rt), \"eight\");\n  EXPECT_EQ(arr.getValueAtIndex(rt, 1).getString(rt).utf8(rt), \"nine\");\n  \/\/ TODO: test out of range\n\n  EXPECT_EQ(x.getPropertyAsObject(rt, \"seven\").getArray(rt).size(rt), 2);\n\n  \/\/ Check that property access with both symbols and strings can access\n  \/\/ array values.\n  EXPECT_EQ(seven.getProperty(rt, \"0\").getString(rt).utf8(rt), \"eight\");\n  EXPECT_EQ(seven.getProperty(rt, \"1\").getString(rt).utf8(rt), \"nine\");\n  seven.setProperty(rt, \"1\", \"modified\");\n  EXPECT_EQ(seven.getProperty(rt, \"1\").getString(rt).utf8(rt), \"modified\");\n  EXPECT_EQ(arr.getValueAtIndex(rt, 1).getString(rt).utf8(rt), \"modified\");\n  EXPECT_EQ(\n      seven.getProperty(rt, PropNameID::forAscii(rt, \"0\"))\n          .getString(rt)\n          .utf8(rt),\n      \"eight\");\n  seven.setProperty(rt, PropNameID::forAscii(rt, \"0\"), \"modified2\");\n  EXPECT_EQ(arr.getValueAtIndex(rt, 0).getString(rt).utf8(rt), \"modified2\");\n\n  Array alpha = Array(rt, 4);\n  EXPECT_TRUE(alpha.getValueAtIndex(rt, 0).isUndefined());\n  EXPECT_TRUE(alpha.getValueAtIndex(rt, 3).isUndefined());\n  EXPECT_EQ(alpha.size(rt), 4);\n  alpha.setValueAtIndex(rt, 0, \"a\");\n  alpha.setValueAtIndex(rt, 1, \"b\");\n  EXPECT_EQ(alpha.length(rt), 4);\n  alpha.setValueAtIndex(rt, 2, \"c\");\n  alpha.setValueAtIndex(rt, 3, \"d\");\n  EXPECT_EQ(alpha.size(rt), 4);\n\n  EXPECT_TRUE(\n      function(\n          \"function (arr) { return \"\n          \"arr.length == 4 && \"\n          \"['a','b','c','d'].every(function(v,i) { return v === arr[i]}); }\")\n          .call(rt, alpha)\n          .getBool());\n\n  Array alpha2 = Array(rt, 1);\n  alpha2 = std::move(alpha);\n  EXPECT_EQ(alpha2.size(rt), 4);\n}","target":0,"code_token_length":702,"total_token_length":938,"max_tokens_setting":1024}
+{"idx":25165,"func":"static void pk_proxy_appeared_cb ( GObject * source , GAsyncResult * res , gpointer user_data ) {\n ActivateParametersInstall * parameters_install = user_data ;\n char * mime_type , * name_owner ;\n char * error_message ;\n GtkWidget * dialog ;\n GDBusProxy * proxy ;\n GError * error = NULL ;\n proxy = g_dbus_proxy_new_for_bus_finish ( res , & error ) ;\n name_owner = g_dbus_proxy_get_name_owner ( proxy ) ;\n if ( error != NULL || name_owner == NULL ) {\n g_warning ( \"Couldn't call Modify on the PackageKit interface: %s\" , error != NULL ? error -> message : \"no owner for PackageKit\" ) ;\n g_clear_error ( & error ) ;\n show_unhandled_type_error ( parameters_install ) ;\n return ;\n }\n g_free ( name_owner ) ;\n mime_type = nautilus_file_get_mime_type ( parameters_install -> file ) ;\n error_message = get_application_no_mime_type_handler_message ( parameters_install -> file , parameters_install -> uri ) ;\n dialog = gtk_message_dialog_new ( parameters_install -> parent_window , 0 , GTK_MESSAGE_ERROR , GTK_BUTTONS_YES_NO , \"%s\" , error_message ) ;\n gtk_message_dialog_format_secondary_text ( GTK_MESSAGE_DIALOG ( dialog ) , _ ( \"There is no application installed for \u201c%s\u201d files.\\n\" \"Do you want to search for an application to open this file?\" ) , g_content_type_get_description ( mime_type ) ) ;\n gtk_window_set_resizable ( GTK_WINDOW ( dialog ) , FALSE ) ;\n parameters_install -> dialog = dialog ;\n parameters_install -> proxy = proxy ;\n g_signal_connect ( dialog , \"response\" , G_CALLBACK ( application_unhandled_file_install ) , parameters_install ) ;\n g_signal_connect ( dialog , \"delete-event\" , G_CALLBACK ( delete_cb ) , NULL ) ;\n gtk_widget_show_all ( dialog ) ;\n g_free ( mime_type ) ;\n }","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":305845,"func":"GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRandomAccessPoint)\n{\n\tGF_TrackBox *trak;\n\tGF_HintSampleEntryBox *entry;\n\tu32 dataRefIndex;\n\tGF_Err e;\n\tGF_BitStream *bs;\n\tGF_ISOSample *samp;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM;\n\n\te = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &dataRefIndex);\n\tif (e) return e;\n\tif (!entry->hint_sample) return GF_BAD_PARAM;\n\n\t\/\/first of all, we need to adjust the offset for data referenced IN THIS hint sample\n\t\/\/and get some PckSize\n\te = AdjustHintInfo(entry, trak->Media->information->sampleTable->SampleSize->sampleCount + 1);\n\tif (e) return e;\n\n\t\/\/ok, let's write the sample\n\tbs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\te = gf_isom_hint_sample_write(entry->hint_sample, bs);\n\tif (e) {\n\t\tgf_bs_del(bs);\n\t\treturn e;\n\t}\n\tsamp = gf_isom_sample_new();\n\tsamp->CTS_Offset = 0;\n\tsamp->IsRAP = IsRandomAccessPoint;\n\tsamp->DTS = entry->hint_sample->TransmissionTime;\n\t\/\/get the sample\n\tgf_bs_get_content(bs, &samp->data, &samp->dataLength);\n\tgf_bs_del(bs);\n\n\t\/\/finally add the sample\n\te = gf_isom_add_sample(the_file, trackNumber, trak->Media->information->sampleTable->currentEntryIndex, samp);\n\tgf_isom_sample_del(&samp);\n\n\t\/\/and delete the sample in our entry ...\n\tgf_isom_hint_sample_del(entry->hint_sample);\n\tentry->hint_sample = NULL;\n\treturn e;\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":353414,"func":"dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)\n{\n\tint i=-1;\n\thm_fragment *frag = NULL;\n\tpitem *item = NULL;\n\tunsigned char seq64be[8];\n\tunsigned long frag_len = msg_hdr->frag_len;\n\n\tif ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len)\n\t\tgoto err;\n\n\t\/* Try to find item in queue, to prevent duplicate entries *\/\n\tmemset(seq64be,0,sizeof(seq64be));\n\tseq64be[6] = (unsigned char) (msg_hdr->seq>>8);\n\tseq64be[7] = (unsigned char) msg_hdr->seq;\n\titem = pqueue_find(s->d1->buffered_messages, seq64be);\n\n\t\/* If we already have an entry and this one is a fragment,\n\t * don't discard it and rather try to reassemble it.\n\t *\/\n\tif (item != NULL && frag_len < msg_hdr->msg_len)\n\t\titem = NULL;\n\n\t\/* Discard the message if sequence number was already there, is\n\t * too far in the future, already in the queue or if we received\n\t * a FINISHED before the SERVER_HELLO, which then must be a stale\n\t * retransmit.\n\t *\/\n\tif (msg_hdr->seq <= s->d1->handshake_read_seq ||\n\t\tmsg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||\n\t\t(s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))\n\t\t{\n\t\tunsigned char devnull [256];\n\n\t\twhile (frag_len)\n\t\t\t{\n\t\t\ti = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,\n\t\t\t\tdevnull,\n\t\t\t\tfrag_len>sizeof(devnull)?sizeof(devnull):frag_len,0);\n\t\t\tif (i<=0) goto err;\n\t\t\tfrag_len -= i;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\tif (frag_len && frag_len < msg_hdr->msg_len)\n\t\t\treturn dtls1_reassemble_fragment(s, msg_hdr, ok);\n\n\t\tfrag = dtls1_hm_fragment_new(frag_len, 0);\n\t\tif ( frag == NULL)\n\t\t\tgoto err;\n\n\t\tmemcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));\n\n\t\tif (frag_len)\n\t\t\t{\n\t\t\t\/* read the body of the fragment (header has already been read *\/\n\t\t\ti = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,\n\t\t\t\tfrag->fragment,frag_len,0);\n\t\t\tif (i<=0 || (unsigned long)i!=frag_len)\n\t\t\t\tgoto err;\n\t\t\t}\n\n\t\tmemset(seq64be,0,sizeof(seq64be));\n\t\tseq64be[6] = (unsigned char)(msg_hdr->seq>>8);\n\t\tseq64be[7] = (unsigned char)(msg_hdr->seq);\n\n\t\titem = pitem_new(seq64be, frag);\n\t\tif ( item == NULL)\n\t\t\tgoto err;\n\n\t\tpqueue_insert(s->d1->buffered_messages, item);\n\t\t}\n\n\treturn DTLS1_HM_FRAGMENT_RETRY;\n\nerr:\n\tif (frag != NULL && item == NULL) dtls1_hm_fragment_free(frag);\n\t*ok = 0;\n\treturn i;\n\t}","target":1,"code_token_length":727,"total_token_length":963,"max_tokens_setting":1024}
+{"idx":122109,"func":"static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref,\n\n                         AVIOInterruptCB *int_cb)\n\n{\n\n    AVOpenCallback open_func = c->fc->open_cb;\n\n\n\n    if (!open_func)\n\n        open_func = ffio_open2_wrapper;\n\n\n\n    \/* try relative path, we do not try the absolute because it can leak information about our\n\n       system to an attacker *\/\n\n    if (ref->nlvl_to > 0 && ref->nlvl_from > 0 && ref->path[0] != '\/') {\n\n        char filename[1025];\n\n        const char *src_path;\n\n        int i, l;\n\n\n\n        \/* find a source dir *\/\n\n        src_path = strrchr(src, '\/');\n\n        if (src_path)\n\n            src_path++;\n\n        else\n\n            src_path = src;\n\n\n\n        \/* find a next level down to target *\/\n\n        for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)\n\n            if (ref->path[l] == '\/') {\n\n                if (i == ref->nlvl_to - 1)\n\n                    break;\n\n                else\n\n                    i++;\n\n            }\n\n\n\n        \/* compose filename if next level down to target was found *\/\n\n        if (i == ref->nlvl_to - 1 && src_path - src  < sizeof(filename)) {\n\n            memcpy(filename, src, src_path - src);\n\n            filename[src_path - src] = 0;\n\n\n\n            for (i = 1; i < ref->nlvl_from; i++)\n\n                av_strlcat(filename, \"..\/\", sizeof(filename));\n\n\n\n            av_strlcat(filename, ref->path + l + 1, sizeof(filename));\n\n            if (!c->use_absolute_path && !c->fc->open_cb)\n\n                if(strstr(ref->path + l + 1, \"..\") || ref->nlvl_from > 1)\n\n                    return AVERROR(ENOENT);\n\n\n\n            if (strlen(filename) + 1 == sizeof(filename))\n\n                return AVERROR(ENOENT);\n\n            if (!open_func(c->fc, pb, filename, AVIO_FLAG_READ, int_cb, NULL))\n\n                return 0;\n\n        }\n\n    } else if (c->use_absolute_path) {\n\n        av_log(c->fc, AV_LOG_WARNING, \"Using absolute path on user request, \"\n\n               \"this is a possible security issue\\n\");\n\n        if (!open_func(c->fc, pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))\n\n            return 0;\n\n    } else if (c->fc->open_cb) {\n\n        if (!open_func(c->fc, pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))\n\n            return 0;\n\n    } else {\n\n        av_log(c->fc, AV_LOG_ERROR,\n\n               \"Absolute path %s not tried for security reasons, \"\n\n               \"set demuxer option use_absolute_path to allow absolute paths\\n\",\n\n               ref->path);\n\n    }\n\n\n\n    return AVERROR(ENOENT);\n\n}\n","target":0,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":200673,"func":"ModuleExport size_t RegisterPSImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=AcquireMagickInfo(\"PS\",\"EPI\",\n    \"Encapsulated PostScript Interchange format\");\n  entry->decoder=(DecodeImageHandler *) ReadPSImage;\n  entry->encoder=(EncodeImageHandler *) WritePSImage;\n  entry->magick=(IsImageFormatHandler *) IsPS;\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  entry->flags^=CoderAdjoinFlag;\n  entry->flags^=CoderBlobSupportFlag;\n  entry->mime_type=ConstantString(\"application\/postscript\");\n  (void) RegisterMagickInfo(entry);\n  entry=AcquireMagickInfo(\"PS\",\"EPS\",\"Encapsulated PostScript\");\n  entry->decoder=(DecodeImageHandler *) ReadPSImage;\n  entry->encoder=(EncodeImageHandler *) WritePSImage;\n  entry->magick=(IsImageFormatHandler *) IsPS;\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  entry->flags^=CoderAdjoinFlag;\n  entry->flags^=CoderBlobSupportFlag;\n  entry->mime_type=ConstantString(\"application\/postscript\");\n  (void) RegisterMagickInfo(entry);\n  entry=AcquireMagickInfo(\"PS\",\"EPSF\",\"Encapsulated PostScript\");\n  entry->decoder=(DecodeImageHandler *) ReadPSImage;\n  entry->encoder=(EncodeImageHandler *) WritePSImage;\n  entry->magick=(IsImageFormatHandler *) IsPS;\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  entry->flags^=CoderAdjoinFlag;\n  entry->flags^=CoderBlobSupportFlag;\n  entry->mime_type=ConstantString(\"application\/postscript\");\n  (void) RegisterMagickInfo(entry);\n  entry=AcquireMagickInfo(\"PS\",\"EPSI\",\n    \"Encapsulated PostScript Interchange format\");\n  entry->decoder=(DecodeImageHandler *) ReadPSImage;\n  entry->encoder=(EncodeImageHandler *) WritePSImage;\n  entry->magick=(IsImageFormatHandler *) IsPS;\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  entry->flags^=CoderAdjoinFlag;\n  entry->flags^=CoderBlobSupportFlag;\n  entry->mime_type=ConstantString(\"application\/postscript\");\n  (void) RegisterMagickInfo(entry);\n  entry=AcquireMagickInfo(\"PS\",\"PS\",\"PostScript\");\n  entry->decoder=(DecodeImageHandler *) ReadPSImage;\n  entry->encoder=(EncodeImageHandler *) WritePSImage;\n  entry->magick=(IsImageFormatHandler *) IsPS;\n  entry->mime_type=ConstantString(\"application\/postscript\");\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  entry->flags^=CoderBlobSupportFlag;\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}\n","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":387972,"func":"png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,\n   png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,\n   int finish)\n{\n   if (png_ptr->zowner == png_ptr->chunk_name)\n   {\n      int ret;\n\n      \/* next_in and avail_in must have been initialized by the caller. *\/\n      png_ptr->zstream.next_out = next_out;\n      png_ptr->zstream.avail_out = 0; \/* set in the loop *\/\n\n      do\n      {\n         if (png_ptr->zstream.avail_in == 0)\n         {\n            if (read_size > *chunk_bytes)\n               read_size = (uInt)*chunk_bytes;\n            *chunk_bytes -= read_size;\n\n            if (read_size > 0)\n               png_crc_read(png_ptr, read_buffer, read_size);\n\n            png_ptr->zstream.next_in = read_buffer;\n            png_ptr->zstream.avail_in = read_size;\n         }\n\n         if (png_ptr->zstream.avail_out == 0)\n         {\n            uInt avail = ZLIB_IO_MAX;\n            if (avail > *out_size)\n               avail = (uInt)*out_size;\n            *out_size -= avail;\n\n            png_ptr->zstream.avail_out = avail;\n         }\n\n         \/* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all\n          * the available output is produced; this allows reading of truncated\n          * streams.\n          *\/\n         ret = inflate(&png_ptr->zstream,\n            *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));\n      }\n      while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));\n\n      *out_size += png_ptr->zstream.avail_out;\n      png_ptr->zstream.avail_out = 0; \/* Should not be required, but is safe *\/\n\n      \/* Ensure the error message pointer is always set: *\/\n      png_zstream_error(png_ptr, ret);\n      return ret;\n   }\n\n   else\n   {\n      png_ptr->zstream.msg = PNGZ_MSG_CAST(\"zstream unclaimed\");\n      return Z_STREAM_ERROR;\n   }\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":343403,"func":"static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)\n{\n    int sx, sy;\n    int dx, dy;\n    int width, height;\n    int depth;\n    int notify = 0;\n\n    depth = s->get_bpp((VGAState *)s) \/ 8;\n    s->get_resolution((VGAState *)s, &width, &height);\n\n    \/* extra x, y *\/\n    sx = (src % (width * depth)) \/ depth;\n    sy = (src \/ (width * depth));\n    dx = (dst % (width *depth)) \/ depth;\n    dy = (dst \/ (width * depth));\n\n    \/* normalize width *\/\n    w \/= depth;\n\n    \/* if we're doing a backward copy, we have to adjust\n       our x\/y to be the upper left corner (instead of the lower\n       right corner) *\/\n    if (s->cirrus_blt_dstpitch < 0) {\n\tsx -= (s->cirrus_blt_width \/ depth) - 1;\n\tdx -= (s->cirrus_blt_width \/ depth) - 1;\n\tsy -= s->cirrus_blt_height - 1;\n\tdy -= s->cirrus_blt_height - 1;\n    }\n\n    \/* are we in the visible portion of memory? *\/\n    if (sx >= 0 && sy >= 0 && dx >= 0 && dy >= 0 &&\n\t(sx + w) <= width && (sy + h) <= height &&\n\t(dx + w) <= width && (dy + h) <= height) {\n\tnotify = 1;\n    }\n\n    \/* make to sure only copy if it's a plain copy ROP *\/\n    if (*s->cirrus_rop != cirrus_bitblt_rop_fwd_src &&\n\t*s->cirrus_rop != cirrus_bitblt_rop_bkwd_src)\n\tnotify = 0;\n\n    \/* we have to flush all pending changes so that the copy\n       is generated at the appropriate moment in time *\/\n    if (notify)\n\tvga_hw_update();\n\n    (*s->cirrus_rop) (s, s->vram_ptr + s->cirrus_blt_dstaddr,\n\t\t      s->vram_ptr + s->cirrus_blt_srcaddr,\n\t\t      s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch,\n\t\t      s->cirrus_blt_width, s->cirrus_blt_height);\n\n    if (notify)\n\ts->ds->dpy_copy(s->ds,\n\t\t\tsx, sy, dx, dy,\n\t\t\ts->cirrus_blt_width \/ depth,\n\t\t\ts->cirrus_blt_height);\n\n    \/* we don't have to notify the display that this portion has\n       changed since dpy_copy implies this *\/\n\n    if (!notify)\n\tcirrus_invalidate_region(s, s->cirrus_blt_dstaddr,\n\t\t\t\t s->cirrus_blt_dstpitch, s->cirrus_blt_width,\n\t\t\t\t s->cirrus_blt_height);\n}","target":1,"code_token_length":650,"total_token_length":886,"max_tokens_setting":1024}
+{"idx":412213,"func":"static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,\n\t\t\t\t  const void *buf, int bufsize)\n{\n\tstruct buffer_head *bh = NULL;\n\tunsigned long block = 0;\n\tint blocksize = ea_inode->i_sb->s_blocksize;\n\tint max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits;\n\tint csize, wsize = 0;\n\tint ret = 0;\n\tint retries = 0;\n\nretry:\n\twhile (ret >= 0 && ret < max_blocks) {\n\t\tstruct ext4_map_blocks map;\n\t\tmap.m_lblk = block += ret;\n\t\tmap.m_len = max_blocks -= ret;\n\n\t\tret = ext4_map_blocks(handle, ea_inode, &map,\n\t\t\t\t      EXT4_GET_BLOCKS_CREATE);\n\t\tif (ret <= 0) {\n\t\t\text4_mark_inode_dirty(handle, ea_inode);\n\t\t\tif (ret == -ENOSPC &&\n\t\t\t    ext4_should_retry_alloc(ea_inode->i_sb, &retries)) {\n\t\t\t\tret = 0;\n\t\t\t\tgoto retry;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (ret < 0)\n\t\treturn ret;\n\n\tblock = 0;\n\twhile (wsize < bufsize) {\n\t\tif (bh != NULL)\n\t\t\tbrelse(bh);\n\t\tcsize = (bufsize - wsize) > blocksize ? blocksize :\n\t\t\t\t\t\t\t\tbufsize - wsize;\n\t\tbh = ext4_getblk(handle, ea_inode, block, 0);\n\t\tif (IS_ERR(bh))\n\t\t\treturn PTR_ERR(bh);\n\t\tret = ext4_journal_get_write_access(handle, bh);\n\t\tif (ret)\n\t\t\tgoto out;\n\n\t\tmemcpy(bh->b_data, buf, csize);\n\t\tset_buffer_uptodate(bh);\n\t\text4_handle_dirty_metadata(handle, ea_inode, bh);\n\n\t\tbuf += csize;\n\t\twsize += csize;\n\t\tblock += 1;\n\t}\n\n\tinode_lock(ea_inode);\n\ti_size_write(ea_inode, wsize);\n\text4_update_i_disksize(ea_inode, wsize);\n\tinode_unlock(ea_inode);\n\n\text4_mark_inode_dirty(handle, ea_inode);\n\nout:\n\tbrelse(bh);\n\n\treturn ret;\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":370462,"func":"int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px)\n{\n\tstruct http_txn *txn = &s->txn;\n\tstruct hdr_exp *exp;\n\n\tfor (exp = px->req_exp; exp; exp = exp->next) {\n\t\tint ret;\n\n\t\t\/*\n\t\t * The interleaving of transformations and verdicts\n\t\t * makes it difficult to decide to continue or stop\n\t\t * the evaluation.\n\t\t *\/\n\n\t\tif (txn->flags & (TX_CLDENY|TX_CLTARPIT))\n\t\t\tbreak;\n\n\t\tif ((txn->flags & TX_CLALLOW) &&\n\t\t    (exp->action == ACT_ALLOW || exp->action == ACT_DENY ||\n\t\t     exp->action == ACT_TARPIT || exp->action == ACT_PASS))\n\t\t\tcontinue;\n\n\t\t\/* if this filter had a condition, evaluate it now and skip to\n\t\t * next filter if the condition does not match.\n\t\t *\/\n\t\tif (exp->cond) {\n\t\t\tret = acl_exec_cond(exp->cond, px, s, txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);\n\t\t\tret = acl_pass(ret);\n\t\t\tif (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS)\n\t\t\t\tret = !ret;\n\n\t\t\tif (!ret)\n\t\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Apply the filter to the request line. *\/\n\t\tret = apply_filter_to_req_line(s, req, exp);\n\t\tif (unlikely(ret < 0))\n\t\t\treturn -1;\n\n\t\tif (likely(ret == 0)) {\n\t\t\t\/* The filter did not match the request, it can be\n\t\t\t * iterated through all headers.\n\t\t\t *\/\n\t\t\tapply_filter_to_req_headers(s, req, exp);\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":383530,"func":"void precompute_partition_info_escapes_(\n\tconst FLAC__int32 residual[],\n\tunsigned raw_bits_per_partition[],\n\tunsigned residual_samples,\n\tunsigned predictor_order,\n\tunsigned min_partition_order,\n\tunsigned max_partition_order\n)\n{\n\tint partition_order;\n\tunsigned from_partition, to_partition = 0;\n\tconst unsigned blocksize = residual_samples + predictor_order;\n\n\t\/* first do max_partition_order *\/\n\tfor(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) {\n\t\tFLAC__int32 r;\n\t\tFLAC__uint32 rmax;\n\t\tunsigned partition, partition_sample, partition_samples, residual_sample;\n\t\tconst unsigned partitions = 1u << partition_order;\n\t\tconst unsigned default_partition_samples = blocksize >> partition_order;\n\n\t\tFLAC__ASSERT(default_partition_samples > predictor_order);\n\n\t\tfor(partition = residual_sample = 0; partition < partitions; partition++) {\n\t\t\tpartition_samples = default_partition_samples;\n\t\t\tif(partition == 0)\n\t\t\t\tpartition_samples -= predictor_order;\n\t\t\trmax = 0;\n\t\t\tfor(partition_sample = 0; partition_sample < partition_samples; partition_sample++) {\n\t\t\t\tr = residual[residual_sample++];\n\t\t\t\t\/* OPT: maybe faster: rmax |= r ^ (r>>31) *\/\n\t\t\t\tif(r < 0)\n\t\t\t\t\trmax |= ~r;\n\t\t\t\telse\n\t\t\t\t\trmax |= r;\n\t\t\t}\n\t\t\t\/* now we know all residual values are in the range [-rmax-1,rmax] *\/\n\t\t\traw_bits_per_partition[partition] = rmax? FLAC__bitmath_ilog2(rmax) + 2 : 1;\n\t\t}\n\t\tto_partition = partitions;\n\t\tbreak; \/*@@@ yuck, should remove the 'for' loop instead *\/\n\t}\n\n\t\/* now merge partitions for lower orders *\/\n\tfor(from_partition = 0, --partition_order; partition_order >= (int)min_partition_order; partition_order--) {\n\t\tunsigned m;\n\t\tunsigned i;\n\t\tconst unsigned partitions = 1u << partition_order;\n\t\tfor(i = 0; i < partitions; i++) {\n\t\t\tm = raw_bits_per_partition[from_partition];\n\t\t\tfrom_partition++;\n\t\t\traw_bits_per_partition[to_partition] = flac_max(m, raw_bits_per_partition[from_partition]);\n\t\t\tfrom_partition++;\n\t\t\tto_partition++;\n\t\t}\n\t}\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":2282,"func":"process_open(u_int32_t id)\n{\n\tu_int32_t pflags;\n\tAttrib a;\n\tchar *name;\n\tint r, handle, fd, flags, mode, status = SSH2_FX_FAILURE;\n\n\tif ((r = sshbuf_get_cstring(iqueue, &name, NULL)) != 0 ||\n\t    (r = sshbuf_get_u32(iqueue, &pflags)) != 0 || \/* portable flags *\/\n\t    (r = decode_attrib(iqueue, &a)) != 0)\n\t\tfatal(\"%s: buffer error: %s\", __func__, ssh_err(r));\n\n\tdebug3(\"request %u: open flags %d\", id, pflags);\n\tflags = flags_from_portable(pflags);\n\tmode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a.perm : 0666;\n\tlogit(\"open \\\"%s\\\" flags %s mode 0%o\",\n\t    name, string_from_portable(pflags), mode);\n\tif (readonly &&\n\t    ((flags & O_ACCMODE) == O_WRONLY ||\n\t    (flags & O_ACCMODE) == O_RDWR)) {\n\t\tverbose(\"Refusing open request in read-only mode\");\n\t\tstatus = SSH2_FX_PERMISSION_DENIED;\n\t} else {\n\t\tfd = open(name, flags, mode);\n\t\tif (fd < 0) {\n\t\t\tstatus = errno_to_portable(errno);\n\t\t} else {\n\t\t\thandle = handle_new(HANDLE_FILE, name, fd, flags, NULL);\n\t\t\tif (handle < 0) {\n\t\t\t\tclose(fd);\n\t\t\t} else {\n\t\t\t\tsend_handle(id, handle);\n\t\t\t\tstatus = SSH2_FX_OK;\n\t\t\t}\n\t\t}\n\t}\n\tif (status != SSH2_FX_OK)\n\t\tsend_status(id, status);\n\tfree(name);\n}","target":1,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":339539,"func":"static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n\n{\n\n    AVStream *st;\n\n    MOVStreamContext *sc;\n\n    unsigned int i, entries;\n\n\n\n    if (c->fc->nb_streams < 1)\n\n        return 0;\n\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    sc = st->priv_data;\n\n\n\n    avio_r8(pb); \/* version *\/\n\n    avio_rb24(pb); \/* flags *\/\n\n\n\n    entries = avio_rb32(pb);\n\n\n\n    av_log(c->fc, AV_LOG_TRACE, \"track[%i].stsc.entries = %i\\n\", c->fc->nb_streams-1, entries);\n\n\n\n    if (!entries)\n\n        return 0;\n\n    if (entries >= UINT_MAX \/ sizeof(*sc->stsc_data))\n\n        return AVERROR_INVALIDDATA;\n\n    sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));\n\n    if (!sc->stsc_data)\n\n        return AVERROR(ENOMEM);\n\n\n\n    for (i = 0; i < entries && !pb->eof_reached; i++) {\n\n        sc->stsc_data[i].first = avio_rb32(pb);\n\n        sc->stsc_data[i].count = avio_rb32(pb);\n\n        sc->stsc_data[i].id = avio_rb32(pb);\n\n        if (sc->stsc_data[i].id < 0 || sc->stsc_data[i].id > sc->stsd_count) {\n\n            sc->stsc_data[i].id = 0;\n\n            if (c->fc->error_recognition & AV_EF_EXPLODE) {\n\n                av_log(c->fc, AV_LOG_ERROR, \"Invalid stsc index.\\n\");\n\n                return AVERROR_INVALIDDATA;\n\n            }\n\n        }\n\n    }\n\n\n\n    sc->stsc_count = i;\n\n\n\n    if (pb->eof_reached)\n\n        return AVERROR_EOF;\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":40386,"func":"make_etype_info2_entry(ETYPE_INFO2_ENTRY *ent, Key *key)\n{\n    krb5_error_code ret;\n\n    ent->etype = key->key.keytype;\n    if(key->salt) {\n\tALLOC(ent->salt);\n\tif (ent->salt == NULL)\n\t    return ENOMEM;\n\t*ent->salt = malloc(key->salt->salt.length + 1);\n\tif (*ent->salt == NULL) {\n\t    free(ent->salt);\n\t    ent->salt = NULL;\n\t    return ENOMEM;\n\t}\n\tmemcpy(*ent->salt, key->salt->salt.data, key->salt->salt.length);\n\t(*ent->salt)[key->salt->salt.length] = '\\0';\n    } else\n\tent->salt = NULL;\n\n    ent->s2kparams = NULL;\n\n    switch (key->key.keytype) {\n    case ETYPE_AES128_CTS_HMAC_SHA1_96:\n    case ETYPE_AES256_CTS_HMAC_SHA1_96:\n\tret = make_s2kparams(_krb5_AES_SHA1_string_to_default_iterator,\n\t\t\t     4, &ent->s2kparams);\n\tbreak;\n    case KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128:\n    case KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192:\n\tret = make_s2kparams(_krb5_AES_SHA2_string_to_default_iterator,\n\t\t\t     4, &ent->s2kparams);\n\tbreak;\n    case ETYPE_DES_CBC_CRC:\n    case ETYPE_DES_CBC_MD4:\n    case ETYPE_DES_CBC_MD5:\n\t\/* Check if this was a AFS3 salted key *\/\n\tif(key->salt && key->salt->type == hdb_afs3_salt)\n\t    ret = make_s2kparams(1, 1, &ent->s2kparams);\n\telse\n\t    ret = 0;\n\tbreak;\n    default:\n\tret = 0;\n\tbreak;\n    }\n    return ret;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":490809,"func":"read_2007_section_appinfohistory (Bit_Chain *restrict dat, Dwg_Data *restrict dwg,\n                                  r2007_section *restrict sections_map,\n                                  r2007_page *restrict pages_map)\n{\n  Bit_Chain old_dat, sec_dat = { 0 };\n  \/\/Bit_Chain *str_dat;\n  Dwg_AppInfoHistory *_obj = &dwg->appinfohistory;\n  Dwg_Object *obj = NULL;\n  int error = 0;\n  \/\/BITCODE_RL rcount1 = 0, rcount2 = 0;\n\n  \/\/ compressed, page size: 0x580\n  error = read_data_section (&sec_dat, dat, sections_map, pages_map,\n                             SECTION_APPINFOHISTORY);\n  if (error >= DWG_ERR_CRITICAL || !sec_dat.chain)\n    {\n      LOG_INFO (\"%s section not found\\n\", \"AppInfoHistory\");\n      if (sec_dat.chain)\n        free (sec_dat.chain);\n      return error;\n    }\n\n  LOG_TRACE (\"\\nAppInfoHistory (%lu)\\n-------------------\\n\", sec_dat.size)\n  old_dat = *dat;\n  dat = &sec_dat; \/\/ restrict in size\n  bit_chain_set_version (&old_dat, dat);\n\n  DEBUG_HERE\n  _obj->size = dat->size;\n  _obj->unknown_bits = bit_read_TF (dat, _obj->size);\n  LOG_TRACE_TF (_obj->unknown_bits, _obj->size)\n\n  LOG_TRACE (\"\\n\")\n  if (sec_dat.chain)\n    free (sec_dat.chain);\n  *dat = old_dat; \/\/ unrestrict\n  return error;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":181808,"func":"RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,\n                                           RenderProcessHost* process,\n                                           int routing_id)\n    : view_(NULL),\n      renderer_initialized_(false),\n      hung_renderer_delay_ms_(kHungRendererDelayMs),\n      delegate_(delegate),\n      process_(process),\n      routing_id_(routing_id),\n      surface_id_(0),\n      is_loading_(false),\n      is_hidden_(false),\n      is_fullscreen_(false),\n      is_accelerated_compositing_active_(false),\n      repaint_ack_pending_(false),\n      resize_ack_pending_(false),\n      should_auto_resize_(false),\n      waiting_for_screen_rects_ack_(false),\n      mouse_move_pending_(false),\n      mouse_wheel_pending_(false),\n      select_range_pending_(false),\n      needs_repainting_on_restore_(false),\n      is_unresponsive_(false),\n      in_flight_event_count_(0),\n      in_get_backing_store_(false),\n      abort_get_backing_store_(false),\n      view_being_painted_(false),\n      ignore_input_events_(false),\n      text_direction_updated_(false),\n      text_direction_(WebKit::WebTextDirectionLeftToRight),\n      text_direction_canceled_(false),\n      suppress_next_char_events_(false),\n      pending_mouse_lock_request_(false),\n      allow_privileged_mouse_lock_(false),\n      has_touch_handler_(false),\n      ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),\n      tick_active_smooth_scroll_gestures_task_posted_(false),\n      touch_event_queue_(new TouchEventQueue(this)),\n      gesture_event_filter_(new GestureEventFilter(this)) {\n  CHECK(delegate_);\n  if (routing_id_ == MSG_ROUTING_NONE) {\n    routing_id_ = process_->GetNextRoutingID();\n    surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer(\n        process_->GetID(),\n        routing_id_);\n  } else {\n    surface_id_ = GpuSurfaceTracker::Get()->LookupSurfaceForRenderer(\n        process_->GetID(),\n        routing_id_);\n    DCHECK(surface_id_);\n  }\n\n  is_threaded_compositing_enabled_ = IsThreadedCompositingEnabled();\n\n  process_->Attach(this, routing_id_);\n  process_->WidgetRestored();\n\n#if defined(USE_AURA)\n  bool overscroll_enabled = CommandLine::ForCurrentProcess()->\n      HasSwitch(switches::kEnableOverscrollHistoryNavigation);\n  if (overscroll_enabled)\n    InitializeOverscrollController();\n#endif\n}\n","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":240496,"func":"inline bool SearchBuffer::isBadMatch(const UChar* match, size_t matchLength) const\n{\n    if (!m_targetRequiresKanaWorkaround)\n        return false;\n\n    normalizeCharacters(match, matchLength, m_normalizedMatch);\n\n    const UChar* a = m_normalizedTarget.begin();\n    const UChar* aEnd = m_normalizedTarget.end();\n\n    const UChar* b = m_normalizedMatch.begin();\n    const UChar* bEnd = m_normalizedMatch.end();\n\n    while (true) {\n        while (a != aEnd && !isKanaLetter(*a))\n            ++a;\n        while (b != bEnd && !isKanaLetter(*b))\n            ++b;\n\n        if (a == aEnd || b == bEnd) {\n            ASSERT(a == aEnd);\n            ASSERT(b == bEnd);\n            return false;\n        }\n\n        if (isSmallKanaLetter(*a) != isSmallKanaLetter(*b))\n            return true;\n        if (composedVoicedSoundMark(*a) != composedVoicedSoundMark(*b))\n            return true;\n        ++a;\n        ++b;\n\n        while (1) {\n            if (!(a != aEnd && isCombiningVoicedSoundMark(*a))) {\n                if (b != bEnd && isCombiningVoicedSoundMark(*b))\n                    return true;\n                break;\n            }\n            if (!(b != bEnd && isCombiningVoicedSoundMark(*b)))\n                return true;\n            if (*a != *b)\n                return true;\n            ++a;\n            ++b;\n        }\n    }\n}\n","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":16289,"func":"static int SpoolssEnumPrinters_q ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep _U_ ) {\n guint32 level , flags ;\n dcerpc_call_value * dcv = ( dcerpc_call_value * ) di -> call_data ;\n static const int * hf_flags [ ] = {\n & hf_enumprinters_flags_network , & hf_enumprinters_flags_shared , & hf_enumprinters_flags_remote , & hf_enumprinters_flags_name , & hf_enumprinters_flags_connections , & hf_enumprinters_flags_local , & hf_enumprinters_flags_default , NULL }\n ;\n offset = dissect_ndr_uint32 ( tvb , offset , pinfo , NULL , di , drep , - 1 , & flags ) ;\n proto_tree_add_bitmask_value ( tree , tvb , offset - 4 , hf_enumprinters_flags , ett_enumprinters_flags , hf_flags , flags ) ;\n offset = dissect_ndr_str_pointer_item ( tvb , offset , pinfo , tree , di , drep , NDR_POINTER_UNIQUE , \"Server name\" , hf_servername , 0 ) ;\n offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_level , & level ) ;\n if ( ! pinfo -> fd -> flags . visited ) {\n dcv -> se_data = GINT_TO_POINTER ( ( int ) level ) ;\n }\n col_append_fstr ( pinfo -> cinfo , COL_INFO , \", level %d\" , level ) ;\n offset = dissect_spoolss_buffer ( tvb , offset , pinfo , tree , di , drep , NULL ) ;\n offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_offered , NULL ) ;\n return offset ;\n }","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":46680,"func":"int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen )\n{\n#if defined(MBEDTLS_PEM_PARSE_C)\n    int success = 0, first_error = 0, total_failed = 0;\n    int buf_format = MBEDTLS_X509_FORMAT_DER;\n#endif\n\n    \/*\n     * Check for valid input\n     *\/\n    if( chain == NULL || buf == NULL )\n        return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );\n\n    \/*\n     * Determine buffer content. Buffer contains either one DER certificate or\n     * one or more PEM certificates.\n     *\/\n#if defined(MBEDTLS_PEM_PARSE_C)\n    if( buflen != 0 && buf[buflen - 1] == '\\0' &&\n        strstr( (const char *) buf, \"-----BEGIN CERTIFICATE-----\" ) != NULL )\n    {\n        buf_format = MBEDTLS_X509_FORMAT_PEM;\n    }\n\n    if( buf_format == MBEDTLS_X509_FORMAT_DER )\n        return mbedtls_x509_crt_parse_der( chain, buf, buflen );\n#else\n    return mbedtls_x509_crt_parse_der( chain, buf, buflen );\n#endif\n\n#if defined(MBEDTLS_PEM_PARSE_C)\n    if( buf_format == MBEDTLS_X509_FORMAT_PEM )\n    {\n        int ret;\n        mbedtls_pem_context pem;\n\n        \/* 1 rather than 0 since the terminating NULL byte is counted in *\/\n        while( buflen > 1 )\n        {\n            size_t use_len;\n            mbedtls_pem_init( &pem );\n\n            \/* If we get there, we know the string is null-terminated *\/\n            ret = mbedtls_pem_read_buffer( &pem,\n                           \"-----BEGIN CERTIFICATE-----\",\n                           \"-----END CERTIFICATE-----\",\n                           buf, NULL, 0, &use_len );\n\n            if( ret == 0 )\n            {\n                \/*\n                 * Was PEM encoded\n                 *\/\n                buflen -= use_len;\n                buf += use_len;\n            }\n            else if( ret == MBEDTLS_ERR_PEM_BAD_INPUT_DATA )\n            {\n                return( ret );\n            }\n            else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT )\n            {\n                mbedtls_pem_free( &pem );\n\n                \/*\n                 * PEM header and footer were found\n                 *\/\n                buflen -= use_len;\n                buf += use_len;\n\n                if( first_error == 0 )\n                    first_error = ret;\n\n                total_failed++;\n                continue;\n            }\n            else\n                break;\n\n            ret = mbedtls_x509_crt_parse_der( chain, pem.buf, pem.buflen );\n\n            mbedtls_pem_free( &pem );\n\n            if( ret != 0 )\n            {\n                \/*\n                 * Quit parsing on a memory error\n                 *\/\n                if( ret == MBEDTLS_ERR_X509_ALLOC_FAILED )\n                    return( ret );\n\n                if( first_error == 0 )\n                    first_error = ret;\n\n                total_failed++;\n                continue;\n            }\n\n            success = 1;\n        }\n    }\n\n    if( success )\n        return( total_failed );\n    else if( first_error )\n        return( first_error );\n    else\n        return( MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT );\n#endif \/* MBEDTLS_PEM_PARSE_C *\/\n}","target":0,"code_token_length":715,"total_token_length":951,"max_tokens_setting":1024}
+{"idx":111176,"func":"ex_tabnext(exarg_T *eap)\n{\n    int tab_number;\n\n    if (ERROR_IF_POPUP_WINDOW)\n\treturn;\n    switch (eap->cmdidx)\n    {\n\tcase CMD_tabfirst:\n\tcase CMD_tabrewind:\n\t    goto_tabpage(1);\n\t    break;\n\tcase CMD_tablast:\n\t    goto_tabpage(9999);\n\t    break;\n\tcase CMD_tabprevious:\n\tcase CMD_tabNext:\n\t    if (eap->arg && *eap->arg != NUL)\n\t    {\n\t\tchar_u *p = eap->arg;\n\t\tchar_u *p_save = p;\n\n\t\ttab_number = getdigits(&p);\n\t\tif (p == p_save || *p_save == '-' || *p != NUL\n\t\t\t    || tab_number == 0)\n\t\t{\n\t\t    \/\/ No numbers as argument.\n\t\t    eap->errmsg = ex_errmsg(e_invalid_argument_str, eap->arg);\n\t\t    return;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tif (eap->addr_count == 0)\n\t\t    tab_number = 1;\n\t\telse\n\t\t{\n\t\t    tab_number = eap->line2;\n\t\t    if (tab_number < 1)\n\t\t    {\n\t\t\teap->errmsg = _(e_invalid_range);\n\t\t\treturn;\n\t\t    }\n\t\t}\n\t    }\n\t    goto_tabpage(-tab_number);\n\t    break;\n\tdefault: \/\/ CMD_tabnext\n\t    tab_number = get_tabpage_arg(eap);\n\t    if (eap->errmsg == NULL)\n\t\tgoto_tabpage(tab_number);\n\t    break;\n    }\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":148655,"func":"unsigned fuse_file_poll(struct file *file, poll_table *wait)\n{\n\tstruct fuse_file *ff = file->private_data;\n\tstruct fuse_conn *fc = ff->fc;\n\tstruct fuse_poll_in inarg = { .fh = ff->fh, .kh = ff->kh };\n\tstruct fuse_poll_out outarg;\n\tstruct fuse_req *req;\n\tint err;\n\n\tif (fc->no_poll)\n\t\treturn DEFAULT_POLLMASK;\n\n\tpoll_wait(file, &ff->poll_wait, wait);\n\n\t\/*\n\t * Ask for notification iff there's someone waiting for it.\n\t * The client may ignore the flag and always notify.\n\t *\/\n\tif (waitqueue_active(&ff->poll_wait)) {\n\t\tinarg.flags |= FUSE_POLL_SCHEDULE_NOTIFY;\n\t\tfuse_register_polled_file(fc, ff);\n\t}\n\n\treq = fuse_get_req(fc);\n\tif (IS_ERR(req))\n\t\treturn POLLERR;\n\n\treq->in.h.opcode = FUSE_POLL;\n\treq->in.h.nodeid = ff->nodeid;\n\treq->in.numargs = 1;\n\treq->in.args[0].size = sizeof(inarg);\n\treq->in.args[0].value = &inarg;\n\treq->out.numargs = 1;\n\treq->out.args[0].size = sizeof(outarg);\n\treq->out.args[0].value = &outarg;\n\tfuse_request_send(fc, req);\n\terr = req->out.h.error;\n\tfuse_put_request(fc, req);\n\n\tif (!err)\n\t\treturn outarg.revents;\n\tif (err == -ENOSYS) {\n\t\tfc->no_poll = 1;\n\t\treturn DEFAULT_POLLMASK;\n\t}\n\treturn POLLERR;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":425818,"func":"static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool nested_ept,\n\t\t\t       u32 *entry_failure_code)\n{\n\tif (cr3 != kvm_read_cr3(vcpu) || (!nested_ept && pdptrs_changed(vcpu))) {\n\t\tif (!nested_cr3_valid(vcpu, cr3)) {\n\t\t\t*entry_failure_code = ENTRY_FAIL_DEFAULT;\n\t\t\treturn 1;\n\t\t}\n\n\t\t\/*\n\t\t * If PAE paging and EPT are both on, CR3 is not used by the CPU and\n\t\t * must not be dereferenced.\n\t\t *\/\n\t\tif (!is_long_mode(vcpu) && is_pae(vcpu) && is_paging(vcpu) &&\n\t\t    !nested_ept) {\n\t\t\tif (!load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3)) {\n\t\t\t\t*entry_failure_code = ENTRY_FAIL_PDPTE;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!nested_ept)\n\t\tkvm_mmu_new_cr3(vcpu, cr3, false);\n\n\tvcpu->arch.cr3 = cr3;\n\t__set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail);\n\n\tkvm_init_mmu(vcpu, false);\n\n\treturn 0;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":335892,"func":"static OSStatus audioDeviceIOProc(\n\n    AudioDeviceID inDevice,\n\n    const AudioTimeStamp* inNow,\n\n    const AudioBufferList* inInputData,\n\n    const AudioTimeStamp* inInputTime,\n\n    AudioBufferList* outOutputData,\n\n    const AudioTimeStamp* inOutputTime,\n\n    void* hwptr)\n\n{\n\n    UInt32 frame, frameCount;\n\n    float *out = outOutputData->mBuffers[0].mData;\n\n    HWVoiceOut *hw = hwptr;\n\n    coreaudioVoiceOut *core = (coreaudioVoiceOut *) hwptr;\n\n    int rpos, live;\n\n    st_sample_t *src;\n\n#ifndef FLOAT_MIXENG\n\n#ifdef RECIPROCAL\n\n    const float scale = 1.f \/ UINT_MAX;\n\n#else\n\n    const float scale = UINT_MAX;\n\n#endif\n\n#endif\n\n\n\n    if (coreaudio_lock (core, \"audioDeviceIOProc\")) {\n\n        inInputTime = 0;\n\n        return 0;\n\n    }\n\n\n\n    frameCount = core->audioDevicePropertyBufferFrameSize;\n\n    live = core->live;\n\n\n\n    \/* if there are not enough samples, set signal and return *\/\n\n    if (live < frameCount) {\n\n        inInputTime = 0;\n\n        coreaudio_unlock (core, \"audioDeviceIOProc(empty)\");\n\n        return 0;\n\n    }\n\n\n\n    rpos = core->rpos;\n\n    src = hw->mix_buf + rpos;\n\n\n\n    \/* fill buffer *\/\n\n    for (frame = 0; frame < frameCount; frame++) {\n\n#ifdef FLOAT_MIXENG\n\n        *out++ = src[frame].l; \/* left channel *\/\n\n        *out++ = src[frame].r; \/* right channel *\/\n\n#else\n\n#ifdef RECIPROCAL\n\n        *out++ = src[frame].l * scale; \/* left channel *\/\n\n        *out++ = src[frame].r * scale; \/* right channel *\/\n\n#else\n\n        *out++ = src[frame].l \/ scale; \/* left channel *\/\n\n        *out++ = src[frame].r \/ scale; \/* right channel *\/\n\n#endif\n\n#endif\n\n    }\n\n\n\n    rpos = (rpos + frameCount) % hw->samples;\n\n    core->decr += frameCount;\n\n    core->rpos = rpos;\n\n\n\n    coreaudio_unlock (core, \"audioDeviceIOProc\");\n\n    return 0;\n\n}\n","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":85720,"func":"static stf_status ikev2_send_auth(struct connection *c,\n\t\t\t\t  struct state *st,\n\t\t\t\t  enum phase1_role role,\n\t\t\t\t  unsigned int np,\n\t\t\t\t  unsigned char *idhash_out,\n\t\t\t\t  pb_stream *outpbs)\n{\n\tstruct ikev2_a a;\n\tpb_stream a_pbs;\n\tstruct state *pst = st;\n\n\tif (st->st_clonedfrom != 0)\n\t\tpst = state_with_serialno(st->st_clonedfrom);\n\n\ta.isaa_critical = ISAKMP_PAYLOAD_NONCRITICAL;\n\tif (DBGP(IMPAIR_SEND_BOGUS_ISAKMP_FLAG)) {\n\t\tlibreswan_log(\n\t\t\t\" setting bogus ISAKMP_PAYLOAD_LIBRESWAN_BOGUS flag in ISAKMP payload\");\n\t\ta.isaa_critical |= ISAKMP_PAYLOAD_LIBRESWAN_BOGUS;\n\t}\n\n\ta.isaa_np = np;\n\n\tif (c->policy & POLICY_RSASIG) {\n\t\ta.isaa_type = v2_AUTH_RSA;\n\t} else if (c->policy & POLICY_PSK) {\n\t\ta.isaa_type = v2_AUTH_SHARED;\n\t} else {\n\t\t\/* what else is there?... DSS not implemented. *\/\n\t\treturn STF_FAIL;\n\t}\n\n\tif (!out_struct(&a,\n\t\t\t&ikev2_a_desc,\n\t\t\toutpbs,\n\t\t\t&a_pbs))\n\t\treturn STF_INTERNAL_ERROR;\n\n\tif (c->policy & POLICY_RSASIG) {\n\t\tif (!ikev2_calculate_rsa_sha1(pst, role, idhash_out, &a_pbs))\n\t\t\treturn STF_FATAL + v2N_AUTHENTICATION_FAILED;\n\n\t} else if (c->policy & POLICY_PSK) {\n\t\tif (!ikev2_calculate_psk_auth(pst, role, idhash_out, &a_pbs))\n\t\t\treturn STF_FAIL + v2N_AUTHENTICATION_FAILED;\n\t}\n\n\tclose_output_pbs(&a_pbs);\n\treturn STF_OK;\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":434445,"func":"errcode_t quota_compare_and_update(quota_ctx_t qctx, enum quota_type qtype,\n\t\t\t\t   int *usage_inconsistent)\n{\n\tstruct quota_handle qh;\n\tstruct scan_dquots_data scan_data;\n\tstruct dquot *dq;\n\tdnode_t *n;\n\tdict_t *dict = qctx->quota_dict[qtype];\n\terrcode_t err = 0;\n\n\tif (!dict)\n\t\tgoto out;\n\n\terr = quota_file_open(qctx, &qh, 0, qtype, -1, 0);\n\tif (err) {\n\t\tlog_debug(\"Open quota file failed\");\n\t\tgoto out;\n\t}\n\n\tscan_data.quota_dict = qctx->quota_dict[qtype];\n\tscan_data.update_limits = 1;\n\tscan_data.update_usage = 0;\n\tscan_data.check_consistency = 1;\n\tscan_data.usage_is_inconsistent = 0;\n\terr = qh.qh_ops->scan_dquots(&qh, scan_dquots_callback, &scan_data);\n\tif (err) {\n\t\tlog_debug(\"Error scanning dquots\");\n\t\t*usage_inconsistent = 1;\n\t\tgoto out_close_qh;\n\t}\n\n\tfor (n = dict_first(dict); n; n = dict_next(dict, n)) {\n\t\tdq = dnode_get(n);\n\t\tif (!dq)\n\t\t\tcontinue;\n\t\tif ((dq->dq_flags & DQF_SEEN) == 0) {\n\t\t\tfprintf(stderr, \"[QUOTA WARNING] \"\n\t\t\t\t\"Missing quota entry ID %d\\n\", dq->dq_id);\n\t\t\tscan_data.usage_is_inconsistent = 1;\n\t\t}\n\t}\n\t*usage_inconsistent = scan_data.usage_is_inconsistent;\n\nout_close_qh:\n\terr = quota_file_close(qctx, &qh);\n\tif (err) {\n\t\tlog_debug(\"Cannot close quotafile: %s\", error_message(errno));\n\t\tif (qh.qh_qf.e2_file)\n\t\t\text2fs_file_close(qh.qh_qf.e2_file);\n\t}\nout:\n\treturn err;\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":468043,"func":"int blk_register_queue(struct gendisk *disk)\n{\n\tint ret;\n\tstruct device *dev = disk_to_dev(disk);\n\tstruct request_queue *q = disk->queue;\n\n\tif (WARN_ON(!q))\n\t\treturn -ENXIO;\n\n\tWARN_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags),\n\t\t  \"%s is registering an already registered queue\\n\",\n\t\t  kobject_name(&dev->kobj));\n\tblk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);\n\n\t\/*\n\t * SCSI probing may synchronously create and destroy a lot of\n\t * request_queues for non-existent devices.  Shutting down a fully\n\t * functional queue takes measureable wallclock time as RCU grace\n\t * periods are involved.  To avoid excessive latency in these\n\t * cases, a request_queue starts out in a degraded mode which is\n\t * faster to shut down and is made fully functional here as\n\t * request_queues for non-existent devices never get registered.\n\t *\/\n\tif (!blk_queue_init_done(q)) {\n\t\tblk_queue_flag_set(QUEUE_FLAG_INIT_DONE, q);\n\t\tpercpu_ref_switch_to_percpu(&q->q_usage_counter);\n\t}\n\n\tret = blk_trace_init_sysfs(dev);\n\tif (ret)\n\t\treturn ret;\n\n\t\/* Prevent changes through sysfs until registration is completed. *\/\n\tmutex_lock(&q->sysfs_lock);\n\n\tret = kobject_add(&q->kobj, kobject_get(&dev->kobj), \"%s\", \"queue\");\n\tif (ret < 0) {\n\t\tblk_trace_remove_sysfs(dev);\n\t\tgoto unlock;\n\t}\n\n\tret = sysfs_create_group(&q->kobj, &queue_attr_group);\n\tif (ret) {\n\t\tblk_trace_remove_sysfs(dev);\n\t\tkobject_del(&q->kobj);\n\t\tkobject_put(&dev->kobj);\n\t\tgoto unlock;\n\t}\n\n\tif (queue_is_mq(q)) {\n\t\t__blk_mq_register_dev(dev, q);\n\t\tblk_mq_debugfs_register(q);\n\t}\n\n\tkobject_uevent(&q->kobj, KOBJ_ADD);\n\n\twbt_enable_default(q);\n\n\tblk_throtl_register_queue(q);\n\n\tif (q->elevator) {\n\t\tret = elv_register_queue(q);\n\t\tif (ret) {\n\t\t\tmutex_unlock(&q->sysfs_lock);\n\t\t\tkobject_uevent(&q->kobj, KOBJ_REMOVE);\n\t\t\tkobject_del(&q->kobj);\n\t\t\tblk_trace_remove_sysfs(dev);\n\t\t\tkobject_put(&dev->kobj);\n\t\t\treturn ret;\n\t\t}\n\t}\n\tret = 0;\nunlock:\n\tmutex_unlock(&q->sysfs_lock);\n\treturn ret;\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":102168,"func":"static bool update_sd_pick_busiest(struct lb_env *env,\n\t\t\t\t   struct sd_lb_stats *sds,\n\t\t\t\t   struct sched_group *sg,\n\t\t\t\t   struct sg_lb_stats *sgs)\n{\n\tstruct sg_lb_stats *busiest = &sds->busiest_stat;\n\n\t\/*\n\t * Don't try to pull misfit tasks we can't help.\n\t * We can use max_capacity here as reduction in capacity on some\n\t * CPUs in the group should either be possible to resolve\n\t * internally or be covered by avg_load imbalance (eventually).\n\t *\/\n\tif (sgs->group_type == group_misfit_task &&\n\t    (!group_smaller_max_cpu_capacity(sg, sds->local) ||\n\t     !group_has_capacity(env, &sds->local_stat)))\n\t\treturn false;\n\n\tif (sgs->group_type > busiest->group_type)\n\t\treturn true;\n\n\tif (sgs->group_type < busiest->group_type)\n\t\treturn false;\n\n\tif (sgs->avg_load <= busiest->avg_load)\n\t\treturn false;\n\n\tif (!(env->sd->flags & SD_ASYM_CPUCAPACITY))\n\t\tgoto asym_packing;\n\n\t\/*\n\t * Candidate sg has no more than one task per CPU and\n\t * has higher per-CPU capacity. Migrating tasks to less\n\t * capable CPUs may harm throughput. Maximize throughput,\n\t * power\/energy consequences are not considered.\n\t *\/\n\tif (sgs->sum_nr_running <= sgs->group_weight &&\n\t    group_smaller_min_cpu_capacity(sds->local, sg))\n\t\treturn false;\n\n\t\/*\n\t * If we have more than one misfit sg go with the biggest misfit.\n\t *\/\n\tif (sgs->group_type == group_misfit_task &&\n\t    sgs->group_misfit_task_load < busiest->group_misfit_task_load)\n\t\treturn false;\n\nasym_packing:\n\t\/* This is the busiest node in its class. *\/\n\tif (!(env->sd->flags & SD_ASYM_PACKING))\n\t\treturn true;\n\n\t\/* No ASYM_PACKING if target CPU is already busy *\/\n\tif (env->idle == CPU_NOT_IDLE)\n\t\treturn true;\n\t\/*\n\t * ASYM_PACKING needs to move all the work to the highest\n\t * prority CPUs in the group, therefore mark all groups\n\t * of lower priority than ourself as busy.\n\t *\/\n\tif (sgs->sum_nr_running &&\n\t    sched_asym_prefer(env->dst_cpu, sg->asym_prefer_cpu)) {\n\t\tif (!sds->busiest)\n\t\t\treturn true;\n\n\t\t\/* Prefer to move from lowest priority CPU's work *\/\n\t\tif (sched_asym_prefer(sds->busiest->asym_prefer_cpu,\n\t\t\t\t      sg->asym_prefer_cpu))\n\t\t\treturn true;\n\t}\n\n\treturn false;\n}","target":0,"code_token_length":590,"total_token_length":826,"max_tokens_setting":1024}
+{"idx":52730,"func":"static int cqspi_probe(struct platform_device *pdev)\n{\n\tstruct device_node *np = pdev->dev.of_node;\n\tstruct device *dev = &pdev->dev;\n\tstruct cqspi_st *cqspi;\n\tstruct resource *res;\n\tstruct resource *res_ahb;\n\tint ret;\n\tint irq;\n\n\tcqspi = devm_kzalloc(dev, sizeof(*cqspi), GFP_KERNEL);\n\tif (!cqspi)\n\t\treturn -ENOMEM;\n\n\tmutex_init(&cqspi->bus_mutex);\n\tcqspi->pdev = pdev;\n\tplatform_set_drvdata(pdev, cqspi);\n\n\t\/* Obtain configuration from OF. *\/\n\tret = cqspi_of_get_pdata(pdev);\n\tif (ret) {\n\t\tdev_err(dev, \"Cannot get mandatory OF data.\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\t\/* Obtain QSPI clock. *\/\n\tcqspi->clk = devm_clk_get(dev, NULL);\n\tif (IS_ERR(cqspi->clk)) {\n\t\tdev_err(dev, \"Cannot claim QSPI clock.\\n\");\n\t\treturn PTR_ERR(cqspi->clk);\n\t}\n\n\t\/* Obtain and remap controller address. *\/\n\tres = platform_get_resource(pdev, IORESOURCE_MEM, 0);\n\tcqspi->iobase = devm_ioremap_resource(dev, res);\n\tif (IS_ERR(cqspi->iobase)) {\n\t\tdev_err(dev, \"Cannot remap controller address.\\n\");\n\t\treturn PTR_ERR(cqspi->iobase);\n\t}\n\n\t\/* Obtain and remap AHB address. *\/\n\tres_ahb = platform_get_resource(pdev, IORESOURCE_MEM, 1);\n\tcqspi->ahb_base = devm_ioremap_resource(dev, res_ahb);\n\tif (IS_ERR(cqspi->ahb_base)) {\n\t\tdev_err(dev, \"Cannot remap AHB address.\\n\");\n\t\treturn PTR_ERR(cqspi->ahb_base);\n\t}\n\n\tinit_completion(&cqspi->transfer_complete);\n\n\t\/* Obtain IRQ line. *\/\n\tirq = platform_get_irq(pdev, 0);\n\tif (irq < 0) {\n\t\tdev_err(dev, \"Cannot obtain IRQ.\\n\");\n\t\treturn -ENXIO;\n\t}\n\n\tret = clk_prepare_enable(cqspi->clk);\n\tif (ret) {\n\t\tdev_err(dev, \"Cannot enable QSPI clock.\\n\");\n\t\treturn ret;\n\t}\n\n\tcqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);\n\n\tret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,\n\t\t\t       pdev->name, cqspi);\n\tif (ret) {\n\t\tdev_err(dev, \"Cannot request IRQ.\\n\");\n\t\tgoto probe_irq_failed;\n\t}\n\n\tcqspi_wait_idle(cqspi);\n\tcqspi_controller_init(cqspi);\n\tcqspi->current_cs = -1;\n\tcqspi->sclk = 0;\n\n\tret = cqspi_setup_flash(cqspi, np);\n\tif (ret) {\n\t\tdev_err(dev, \"Cadence QSPI NOR probe failed %d\\n\", ret);\n\t\tgoto probe_setup_failed;\n\t}\n\n\treturn ret;\nprobe_irq_failed:\n\tcqspi_controller_enable(cqspi, 0);\nprobe_setup_failed:\n\tclk_disable_unprepare(cqspi->clk);\n\treturn ret;\n}","target":0,"code_token_length":679,"total_token_length":915,"max_tokens_setting":1024}
+{"idx":490021,"func":"piv_finish(sc_card_t *card)\n{\n\tpiv_private_data_t * priv = PIV_DATA(card);\n\tint i;\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);\n\tif (priv) {\n\t\tsc_file_free(priv->aid_file);\n\t\tif (priv->w_buf)\n\t\t\tfree(priv->w_buf);\n\t\tif (priv->offCardCertURL)\n\t\t\tfree(priv->offCardCertURL);\n\t\tfor (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) {\n\t\t\tsc_log(card->ctx,\n\t\t\t       \"DEE freeing #%d, 0x%02x %p:%\"SC_FORMAT_LEN_SIZE_T\"u %p:%\"SC_FORMAT_LEN_SIZE_T\"u\",\n\t\t\t       i, priv->obj_cache[i].flags,\n\t\t\t       priv->obj_cache[i].obj_data,\n\t\t\t       priv->obj_cache[i].obj_len,\n\t\t\t       priv->obj_cache[i].internal_obj_data,\n\t\t\t       priv->obj_cache[i].internal_obj_len);\n\t\t\tif (priv->obj_cache[i].obj_data)\n\t\t\t\tfree(priv->obj_cache[i].obj_data);\n\t\t\tif (priv->obj_cache[i].internal_obj_data)\n\t\t\t\tfree(priv->obj_cache[i].internal_obj_data);\n\t\t}\n\t\tfree(priv);\n\t\tcard->drv_data = NULL; \/* priv *\/\n\t}\n\treturn 0;\n}","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":303162,"func":"edit_and_execute_command (count, c, editing_mode, edit_command)\n     int count, c, editing_mode;\n     char *edit_command;\n{\n  char *command, *metaval;\n  int r, rrs, metaflag;\n  sh_parser_state_t ps;\n\n  rrs = rl_readline_state;\n  saved_command_line_count = current_command_line_count;\n\n  \/* Accept the current line. *\/\n  rl_newline (1, c);\n\n  if (rl_explicit_arg)\n    {\n      command = (char *)xmalloc (strlen (edit_command) + 8);\n      sprintf (command, \"%s %d\", edit_command, count);\n    }\n  else\n    {\n      \/* Take the command we were just editing, add it to the history file,\n\t then call fc to operate on it.  We have to add a dummy command to\n\t the end of the history because fc ignores the last command (assumes\n\t it's supposed to deal with the command before the `fc'). *\/\n      \/* This breaks down when using command-oriented history and are not\n\t finished with the command, so we should not ignore the last command *\/\n      using_history ();\n      current_command_line_count++;\t\/* for rl_newline above *\/\n      bash_add_history (rl_line_buffer);\n      current_command_line_count = 0;\t\/* for dummy history entry *\/\n      bash_add_history (\"\");\n      history_lines_this_session++;\n      using_history ();\n      command = savestring (edit_command);\n    }\n\n  metaval = rl_variable_value (\"input-meta\");\n  metaflag = RL_BOOLEAN_VARIABLE_VALUE (metaval);\n  \n  if (rl_deprep_term_function)\n    (*rl_deprep_term_function) ();\n  save_parser_state (&ps);\n  r = parse_and_execute (command, (editing_mode == VI_EDITING_MODE) ? \"v\" : \"C-xC-e\", SEVAL_NOHIST);\n  restore_parser_state (&ps);\n  if (rl_prep_term_function)\n    (*rl_prep_term_function) (metaflag);\n\n  current_command_line_count = saved_command_line_count;\n\n  \/* Now erase the contents of the current line and undo the effects of the\n     rl_accept_line() above.  We don't even want to make the text we just\n     executed available for undoing. *\/\n  rl_line_buffer[0] = '\\0';\t\/* XXX *\/\n  rl_point = rl_end = 0;\n  rl_done = 0;\n  rl_readline_state = rrs;\n\n#if defined (VI_MODE)\n  if (editing_mode == VI_EDITING_MODE)\n    rl_vi_insertion_mode (1, c);\n#endif\n\n  rl_forced_update_display ();\n\n  return r;\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":252566,"func":"static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)\n{\n    DSA *dsa;\n    int ptype;\n    unsigned char *penc = NULL;\n    int penclen;\n    ASN1_STRING *str = NULL;\n\n    dsa = pkey->pkey.dsa;\n    if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) {\n        str = ASN1_STRING_new();\n        if (!str) {\n            DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        str->length = i2d_DSAparams(dsa, &str->data);\n        if (str->length <= 0) {\n            DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        ptype = V_ASN1_SEQUENCE;\n    } else\n        ptype = V_ASN1_UNDEF;\n\n    dsa->write_params = 0;\n\n    penclen = i2d_DSAPublicKey(dsa, &penc);\n\n    if (penclen <= 0) {\n        DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA),\n                               ptype, str, penc, penclen))\n        return 1;\n\n err:\n    if (penc)\n        OPENSSL_free(penc);\n    if (str)\n        ASN1_STRING_free(str);\n\n    return 0;\n}\n","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":230980,"func":"static bool SniffForOfficeDocs(const char* content,\n                               size_t size,\n                               const GURL& url,\n                               bool* have_enough_content,\n                               std::string* result) {\n  *have_enough_content &= TruncateSize(kBytesRequiredForOfficeMagic, &size);\n\n  std::string office_version;\n  if (!CheckForMagicNumbers(content, size, kOfficeMagicNumbers,\n                            arraysize(kOfficeMagicNumbers), &office_version))\n    return false;\n\n  OfficeDocType type = DOC_TYPE_NONE;\n  base::StringPiece url_path = url.path_piece();\n  for (size_t i = 0; i < arraysize(kOfficeExtensionTypes); ++i) {\n    if (url_path.length() < kOfficeExtensionTypes[i].extension_len)\n      continue;\n\n    base::StringPiece extension = url_path.substr(\n        url_path.length() - kOfficeExtensionTypes[i].extension_len);\n    if (base::EqualsCaseInsensitiveASCII(\n            extension,\n            base::StringPiece(kOfficeExtensionTypes[i].extension,\n                              kOfficeExtensionTypes[i].extension_len))) {\n      type = kOfficeExtensionTypes[i].doc_type;\n      break;\n    }\n  }\n\n  if (type == DOC_TYPE_NONE)\n    return false;\n\n  if (office_version == \"CFB\") {\n    switch (type) {\n      case DOC_TYPE_WORD:\n        *result = \"application\/msword\";\n        return true;\n      case DOC_TYPE_EXCEL:\n        *result = \"application\/vnd.ms-excel\";\n        return true;\n      case DOC_TYPE_POWERPOINT:\n        *result = \"application\/vnd.ms-powerpoint\";\n        return true;\n      case DOC_TYPE_NONE:\n        NOTREACHED();\n        return false;\n    }\n  } else if (office_version == \"OOXML\") {\n    switch (type) {\n      case DOC_TYPE_WORD:\n        *result = \"application\/vnd.openxmlformats-officedocument.\"\n                  \"wordprocessingml.document\";\n        return true;\n      case DOC_TYPE_EXCEL:\n        *result = \"application\/vnd.openxmlformats-officedocument.\"\n                  \"spreadsheetml.sheet\";\n        return true;\n      case DOC_TYPE_POWERPOINT:\n        *result = \"application\/vnd.openxmlformats-officedocument.\"\n                  \"presentationml.presentation\";\n        return true;\n      case DOC_TYPE_NONE:\n        NOTREACHED();\n        return false;\n    }\n  }\n\n  NOTREACHED();\n  return false;\n}\n","target":0,"code_token_length":497,"total_token_length":733,"max_tokens_setting":1024}
+{"idx":116088,"func":"static void prepare_emulation_failure_exit(struct kvm_vcpu *vcpu, u64 *data,\n\t\t\t\t\t   u8 ndata, u8 *insn_bytes, u8 insn_size)\n{\n\tstruct kvm_run *run = vcpu->run;\n\tu64 info[5];\n\tu8 info_start;\n\n\t\/*\n\t * Zero the whole array used to retrieve the exit info, as casting to\n\t * u32 for select entries will leave some chunks uninitialized.\n\t *\/\n\tmemset(&info, 0, sizeof(info));\n\n\tstatic_call(kvm_x86_get_exit_info)(vcpu, (u32 *)&info[0], &info[1],\n\t\t\t\t\t   &info[2], (u32 *)&info[3],\n\t\t\t\t\t   (u32 *)&info[4]);\n\n\trun->exit_reason = KVM_EXIT_INTERNAL_ERROR;\n\trun->emulation_failure.suberror = KVM_INTERNAL_ERROR_EMULATION;\n\n\t\/*\n\t * There's currently space for 13 entries, but 5 are used for the exit\n\t * reason and info.  Restrict to 4 to reduce the maintenance burden\n\t * when expanding kvm_run.emulation_failure in the future.\n\t *\/\n\tif (WARN_ON_ONCE(ndata > 4))\n\t\tndata = 4;\n\n\t\/* Always include the flags as a 'data' entry. *\/\n\tinfo_start = 1;\n\trun->emulation_failure.flags = 0;\n\n\tif (insn_size) {\n\t\tBUILD_BUG_ON((sizeof(run->emulation_failure.insn_size) +\n\t\t\t      sizeof(run->emulation_failure.insn_bytes) != 16));\n\t\tinfo_start += 2;\n\t\trun->emulation_failure.flags |=\n\t\t\tKVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES;\n\t\trun->emulation_failure.insn_size = insn_size;\n\t\tmemset(run->emulation_failure.insn_bytes, 0x90,\n\t\t       sizeof(run->emulation_failure.insn_bytes));\n\t\tmemcpy(run->emulation_failure.insn_bytes, insn_bytes, insn_size);\n\t}\n\n\tmemcpy(&run->internal.data[info_start], info, sizeof(info));\n\tmemcpy(&run->internal.data[info_start + ARRAY_SIZE(info)], data,\n\t       ndata * sizeof(data[0]));\n\n\trun->emulation_failure.ndata = info_start + ARRAY_SIZE(info) + ndata;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":401,"func":"IN_PROC_BROWSER_TEST_P ( BrowserCloseManagerWithDownloadsBrowserTest , TestWithDownloadsFromDifferentProfiles ) {\n ProfileManager * profile_manager = g_browser_process -> profile_manager ( ) ;\n Profile * other_profile = nullptr ;\n {\n base : : FilePath path = profile_manager -> user_data_dir ( ) . AppendASCII ( \"test_profile\" ) ;\n base : : ScopedAllowBlockingForTesting allow_blocking ;\n if ( ! base : : PathExists ( path ) ) ASSERT_TRUE ( base : : CreateDirectory ( path ) ) ;\n other_profile = Profile : : CreateProfile ( path , NULL , Profile : : CREATE_MODE_SYNCHRONOUS ) ;\n }\n profile_manager -> RegisterTestingProfile ( other_profile , true , false ) ;\n Browser * other_profile_browser = CreateBrowser ( other_profile ) ;\n SetDownloadPathForProfile ( browser ( ) -> profile ( ) ) ;\n SetDownloadPathForProfile ( other_profile ) ;\n ASSERT_NO_FATAL_FAILURE ( CreateStalledDownload ( browser ( ) ) ) ;\n {\n RepeatedNotificationObserver close_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , 1 ) ;\n browser ( ) -> window ( ) -> Close ( ) ;\n close_observer . Wait ( ) ;\n }\n ui_test_utils : : BrowserAddedObserver new_browser_observer ;\n TestBrowserCloseManager : : AttemptClose ( TestBrowserCloseManager : : USER_CHOICE_USER_CANCELS_CLOSE ) ;\n EXPECT_FALSE ( browser_shutdown : : IsTryingToQuit ( ) ) ;\n Browser * opened_browser = new_browser_observer . WaitForSingleNewBrowser ( ) ;\n EXPECT_EQ ( GURL ( chrome : : kChromeUIDownloadsURL ) , opened_browser -> tab_strip_model ( ) -> GetActiveWebContents ( ) -> GetURL ( ) ) ;\n EXPECT_EQ ( GURL ( \"about:blank\" ) , other_profile_browser -> tab_strip_model ( ) -> GetActiveWebContents ( ) -> GetURL ( ) ) ;\n RepeatedNotificationObserver close_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , 2 ) ;\n TestBrowserCloseManager : : AttemptClose ( TestBrowserCloseManager : : USER_CHOICE_USER_ALLOWS_CLOSE ) ;\n close_observer . Wait ( ) ;\n EXPECT_TRUE ( browser_shutdown : : IsTryingToQuit ( ) ) ;\n EXPECT_TRUE ( BrowserList : : GetInstance ( ) -> empty ( ) ) ;\n if ( browser_defaults : : kBrowserAliveWithNoWindows ) EXPECT_EQ ( 1 , DownloadCoreService : : NonMaliciousDownloadCountAllProfiles ( ) ) ;\n else EXPECT_EQ ( 0 , DownloadCoreService : : NonMaliciousDownloadCountAllProfiles ( ) ) ;\n }","target":1,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":288775,"func":"EC_GROUP * ec_asn1_pkparameters2group ( const ECPKPARAMETERS * params ) {\n EC_GROUP * ret = NULL ;\n int tmp = 0 ;\n if ( params == NULL ) {\n ECerr ( EC_F_EC_ASN1_PKPARAMETERS2GROUP , EC_R_MISSING_PARAMETERS ) ;\n return NULL ;\n }\n if ( params -> type == 0 ) {\n tmp = OBJ_obj2nid ( params -> value . named_curve ) ;\n if ( ( ret = EC_GROUP_new_by_curve_name ( tmp ) ) == NULL ) {\n ECerr ( EC_F_EC_ASN1_PKPARAMETERS2GROUP , EC_R_EC_GROUP_NEW_BY_NAME_FAILURE ) ;\n return NULL ;\n }\n EC_GROUP_set_asn1_flag ( ret , OPENSSL_EC_NAMED_CURVE ) ;\n }\n else if ( params -> type == 1 ) {\n ret = ec_asn1_parameters2group ( params -> value . parameters ) ;\n if ( ! ret ) {\n ECerr ( EC_F_EC_ASN1_PKPARAMETERS2GROUP , ERR_R_EC_LIB ) ;\n return NULL ;\n }\n EC_GROUP_set_asn1_flag ( ret , 0x0 ) ;\n }\n else if ( params -> type == 2 ) {\n return NULL ;\n }\n else {\n ECerr ( EC_F_EC_ASN1_PKPARAMETERS2GROUP , EC_R_ASN1_ERROR ) ;\n return NULL ;\n }\n return ret ;\n }","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":85433,"func":"std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext)\n{\n    YAML::Node yamlnode;\n\n    try\n    {\n        yamlnode = YAML::Load(base_conf);\n    }\n    catch (std::exception &e)\n    {\n        writeLog(0, std::string(\"Clash base loader failed with error: \") + e.what(), LOG_LEVEL_ERROR);\n        return std::string();\n    }\n\n    proxyToClash(nodes, yamlnode, extra_proxy_group, clashR, ext);\n\n    if(ext.nodelist)\n        return YAML::Dump(yamlnode);\n\n    \/*\n    if(ext.enable_rule_generator)\n        rulesetToClash(yamlnode, ruleset_content_array, ext.overwrite_original_rules, ext.clash_new_field_name);\n\n    return YAML::Dump(yamlnode);\n    *\/\n    if(!ext.enable_rule_generator)\n        return YAML::Dump(yamlnode);\n\n    if(!ext.managed_config_prefix.empty() || ext.clash_script)\n    {\n        if(yamlnode[\"mode\"].IsDefined())\n        {\n            if(ext.clash_new_field_name)\n                yamlnode[\"mode\"] = ext.clash_script ? \"script\" : \"rule\";\n            else\n                yamlnode[\"mode\"] = ext.clash_script ? \"Script\" : \"Rule\";\n        }\n\n        renderClashScript(yamlnode, ruleset_content_array, ext.managed_config_prefix, ext.clash_script, ext.overwrite_original_rules, ext.clash_classical_ruleset);\n        return YAML::Dump(yamlnode);\n    }\n\n    std::string output_content = rulesetToClashStr(yamlnode, ruleset_content_array, ext.overwrite_original_rules, ext.clash_new_field_name);\n    output_content.insert(0, YAML::Dump(yamlnode));\n\n    return output_content;\n}","target":0,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":166672,"func":"void Transpose(LocalFrame& frame) {\n  Editor& editor = frame.GetEditor();\n  if (!editor.CanEdit())\n    return;\n\n  Document* const document = frame.GetDocument();\n\n  document->UpdateStyleAndLayoutIgnorePendingStylesheets();\n\n  const EphemeralRange& range = ComputeRangeForTranspose(frame);\n  if (range.IsNull())\n    return;\n\n  const String& text = PlainText(range);\n  if (text.length() != 2)\n    return;\n  const String& transposed = text.Right(1) + text.Left(1);\n\n  if (DispatchBeforeInputInsertText(\n          EventTargetNodeForDocument(document), transposed,\n          InputEvent::InputType::kInsertTranspose,\n          new StaticRangeVector(1, StaticRange::Create(range))) !=\n      DispatchEventResult::kNotCanceled)\n    return;\n\n  if (frame.GetDocument() != document)\n    return;\n\n  document->UpdateStyleAndLayoutIgnorePendingStylesheets();\n\n  const EphemeralRange& new_range = ComputeRangeForTranspose(frame);\n  if (new_range.IsNull())\n    return;\n\n  const String& new_text = PlainText(new_range);\n  if (new_text.length() != 2)\n    return;\n  const String& new_transposed = new_text.Right(1) + new_text.Left(1);\n\n  const SelectionInDOMTree& new_selection =\n      SelectionInDOMTree::Builder().SetBaseAndExtent(new_range).Build();\n\n  if (CreateVisibleSelection(new_selection) !=\n      frame.Selection().ComputeVisibleSelectionInDOMTree())\n    frame.Selection().SetSelection(new_selection);\n\n  editor.ReplaceSelectionWithText(new_transposed, false, false,\n                                  InputEvent::InputType::kInsertTranspose);\n}\n","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":68729,"func":"GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tunsigned int i;\n\tGF_AdobeFragRandomAccessBox *ptr = (GF_AdobeFragRandomAccessBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 9)\n\tptr->long_ids = gf_bs_read_int(bs, 1);\n\tptr->long_offsets = gf_bs_read_int(bs, 1);\n\tptr->global_entries = gf_bs_read_int(bs, 1);\n\tptr->reserved = gf_bs_read_int(bs, 5);\n\tptr->time_scale = gf_bs_read_u32(bs);\n\n\tptr->entry_count = gf_bs_read_u32(bs);\n\tif (ptr->size \/ ( (ptr->long_offsets ? 16 : 12) ) < ptr->entry_count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tfor (i=0; i<ptr->entry_count; i++) {\n\t\tGF_AfraEntry *ae = gf_malloc(sizeof(GF_AfraEntry));\n\t\tif (!ae) return GF_OUT_OF_MEM;\n\t\tgf_list_insert(ptr->local_access_entries, ae, i);\n\n\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\tae->time = gf_bs_read_u64(bs);\n\t\tif (ptr->long_offsets) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\tae->offset = gf_bs_read_u64(bs);\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\tae->offset = gf_bs_read_u32(bs);\n\t\t}\n\t}\n\n\tif (ptr->global_entries) {\n\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\tptr->global_entry_count = gf_bs_read_u32(bs);\n\t\tfor (i=0; i<ptr->global_entry_count; i++) {\n\t\t\tGF_GlobalAfraEntry *ae = gf_malloc(sizeof(GF_GlobalAfraEntry));\n\t\t\tif (!ae) return GF_OUT_OF_MEM;\n\t\t\tgf_list_insert(ptr->global_access_entries, ae, i);\n\n\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\tae->time = gf_bs_read_u64(bs);\n\t\t\tif (ptr->long_ids) {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\t\tae->segment = gf_bs_read_u32(bs);\n\t\t\t\tae->fragment = gf_bs_read_u32(bs);\n\t\t\t} else {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\t\tae->segment = gf_bs_read_u16(bs);\n\t\t\t\tae->fragment = gf_bs_read_u16(bs);\n\t\t\t}\n\t\t\tif (ptr->long_offsets) {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 16)\n\t\t\t\tae->afra_offset = gf_bs_read_u64(bs);\n\t\t\t\tae->offset_from_afra = gf_bs_read_u64(bs);\n\t\t\t} else {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\t\tae->afra_offset = gf_bs_read_u32(bs);\n\t\t\t\tae->offset_from_afra = gf_bs_read_u32(bs);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn GF_OK;\n}","target":0,"code_token_length":673,"total_token_length":909,"max_tokens_setting":1024}
+{"idx":299567,"func":"static void i40e_sync_udp_filters_subtask(struct i40e_pf *pf)\n{\n\tstruct i40e_hw *hw = &pf->hw;\n\tu8 filter_index, type;\n\tu16 port;\n\tint i;\n\n\tif (!test_and_clear_bit(__I40E_UDP_FILTER_SYNC_PENDING, pf->state))\n\t\treturn;\n\n\t\/* acquire RTNL to maintain state of flags and port requests *\/\n\trtnl_lock();\n\n\tfor (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {\n\t\tif (pf->pending_udp_bitmap & BIT_ULL(i)) {\n\t\t\tstruct i40e_udp_port_config *udp_port;\n\t\t\ti40e_status ret = 0;\n\n\t\t\tudp_port = &pf->udp_ports[i];\n\t\t\tpf->pending_udp_bitmap &= ~BIT_ULL(i);\n\n\t\t\tport = READ_ONCE(udp_port->port);\n\t\t\ttype = READ_ONCE(udp_port->type);\n\t\t\tfilter_index = READ_ONCE(udp_port->filter_index);\n\n\t\t\t\/* release RTNL while we wait on AQ command *\/\n\t\t\trtnl_unlock();\n\n\t\t\tif (port)\n\t\t\t\tret = i40e_aq_add_udp_tunnel(hw, port,\n\t\t\t\t\t\t\t     type,\n\t\t\t\t\t\t\t     &filter_index,\n\t\t\t\t\t\t\t     NULL);\n\t\t\telse if (filter_index != I40E_UDP_PORT_INDEX_UNUSED)\n\t\t\t\tret = i40e_aq_del_udp_tunnel(hw, filter_index,\n\t\t\t\t\t\t\t     NULL);\n\n\t\t\t\/* reacquire RTNL so we can update filter_index *\/\n\t\t\trtnl_lock();\n\n\t\t\tif (ret) {\n\t\t\t\tdev_info(&pf->pdev->dev,\n\t\t\t\t\t \"%s %s port %d, index %d failed, err %s aq_err %s\\n\",\n\t\t\t\t\t i40e_tunnel_name(type),\n\t\t\t\t\t port ? \"add\" : \"delete\",\n\t\t\t\t\t port,\n\t\t\t\t\t filter_index,\n\t\t\t\t\t i40e_stat_str(&pf->hw, ret),\n\t\t\t\t\t i40e_aq_str(&pf->hw,\n\t\t\t\t\t\t     pf->hw.aq.asq_last_status));\n\t\t\t\tif (port) {\n\t\t\t\t\t\/* failed to add, just reset port,\n\t\t\t\t\t * drop pending bit for any deletion\n\t\t\t\t\t *\/\n\t\t\t\t\tudp_port->port = 0;\n\t\t\t\t\tpf->pending_udp_bitmap &= ~BIT_ULL(i);\n\t\t\t\t}\n\t\t\t} else if (port) {\n\t\t\t\t\/* record filter index on success *\/\n\t\t\t\tudp_port->filter_index = filter_index;\n\t\t\t}\n\t\t}\n\t}\n\n\trtnl_unlock();\n}","target":0,"code_token_length":529,"total_token_length":765,"max_tokens_setting":1024}
+{"idx":195917,"func":"bool StartupBrowserCreator::LaunchBrowser(\n    const base::CommandLine& command_line,\n    Profile* profile,\n    const base::FilePath& cur_dir,\n    chrome::startup::IsProcessStartup process_startup,\n    chrome::startup::IsFirstRun is_first_run) {\n  DCHECK(profile);\n  in_synchronous_profile_launch_ =\n      process_startup == chrome::startup::IS_PROCESS_STARTUP;\n\n  if (IncognitoModePrefs::ShouldLaunchIncognito(command_line,\n                                                profile->GetPrefs())) {\n    profile = profile->GetOffTheRecordProfile();\n  } else if (command_line.HasSwitch(switches::kIncognito)) {\n    LOG(WARNING) << \"Incognito mode disabled by policy, launching a normal \"\n                 << \"browser session.\";\n  }\n\n  if (IsGuestModeEnforced(command_line, \/* show_warning= *\/ true)) {\n    profile = g_browser_process->profile_manager()\n                  ->GetProfile(ProfileManager::GetGuestProfilePath())\n                  ->GetOffTheRecordProfile();\n  }\n\n#if defined(OS_WIN)\n  if (command_line.HasSwitch(credential_provider::kGcpwSigninSwitch))\n    profile = profile->GetOffTheRecordProfile();\n#endif\n\n  if (!IsSilentLaunchEnabled(command_line, profile)) {\n    StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run);\n    const std::vector<GURL> urls_to_launch =\n        GetURLsFromCommandLine(command_line, cur_dir, profile);\n    const bool launched =\n        lwp.Launch(profile, urls_to_launch, in_synchronous_profile_launch_);\n    in_synchronous_profile_launch_ = false;\n    if (!launched) {\n      LOG(ERROR) << \"launch error\";\n      return false;\n    }\n  } else {\n    in_synchronous_profile_launch_ = false;\n  }\n\n  profile_launch_observer.Get().AddLaunched(profile);\n\n  return true;\n}\n","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":13521,"func":"status_t OMXNodeInstance::updateNativeHandleInMeta(\n        OMX_U32 portIndex, const sp<NativeHandle>& nativeHandle, OMX::buffer_id buffer) {\n Mutex::Autolock autoLock(mLock);\n    OMX_BUFFERHEADERTYPE *header = findBufferHeader(buffer, portIndex);\n if (header == NULL) {\n        ALOGE(\"b\/25884056\");\n return BAD_VALUE;\n }\n\n if (portIndex != kPortIndexInput && portIndex != kPortIndexOutput) {\n return BAD_VALUE;\n\n     }\n \n     BufferMeta *bufferMeta = (BufferMeta *)(header->pAppPrivate);\n     sp<ABuffer> data = bufferMeta->getBuffer(\n             header, false \/* backup *\/, false \/* limit *\/);\n     bufferMeta->setNativeHandle(nativeHandle);\n if (mMetadataType[portIndex] == kMetadataBufferTypeNativeHandleSource\n && data->capacity() >= sizeof(VideoNativeHandleMetadata)) {\n VideoNativeHandleMetadata &metadata = *(VideoNativeHandleMetadata *)(data->data());\n        metadata.eType = mMetadataType[portIndex];\n        metadata.pHandle =\n            nativeHandle == NULL ? NULL : const_cast<native_handle*>(nativeHandle->handle());\n } else {\n        CLOG_ERROR(updateNativeHandleInMeta, BAD_VALUE, \"%s:%u, %#x bad type (%d) or size (%zu)\",\n            portString(portIndex), portIndex, buffer, mMetadataType[portIndex], data->capacity());\n return BAD_VALUE;\n }\n\n    CLOG_BUFFER(updateNativeHandleInMeta, \"%s:%u, %#x := %p\",\n            portString(portIndex), portIndex, buffer,\n            nativeHandle == NULL ? NULL : nativeHandle->handle());\n return OK;\n}\n","target":1,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":22249,"func":"int i2d_ECPrivateKey ( EC_KEY * a , unsigned char * * out ) {\n int ret = 0 , ok = 0 ;\n unsigned char * buffer = NULL ;\n size_t buf_len = 0 , tmp_len ;\n EC_PRIVATEKEY * priv_key = NULL ;\n if ( a == NULL || a -> group == NULL || a -> priv_key == NULL ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_PASSED_NULL_PARAMETER ) ;\n goto err ;\n }\n if ( ( priv_key = EC_PRIVATEKEY_new ( ) ) == NULL ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n priv_key -> version = a -> version ;\n buf_len = ( size_t ) BN_num_bytes ( a -> priv_key ) ;\n buffer = OPENSSL_malloc ( buf_len ) ;\n if ( buffer == NULL ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n if ( ! BN_bn2bin ( a -> priv_key , buffer ) ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_BN_LIB ) ;\n goto err ;\n }\n if ( ! M_ASN1_OCTET_STRING_set ( priv_key -> privateKey , buffer , buf_len ) ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_ASN1_LIB ) ;\n goto err ;\n }\n if ( ! ( a -> enc_flag & EC_PKEY_NO_PARAMETERS ) ) {\n if ( ( priv_key -> parameters = ec_asn1_group2pkparameters ( a -> group , priv_key -> parameters ) ) == NULL ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_EC_LIB ) ;\n goto err ;\n }\n }\n if ( ! ( a -> enc_flag & EC_PKEY_NO_PUBKEY ) ) {\n priv_key -> publicKey = M_ASN1_BIT_STRING_new ( ) ;\n if ( priv_key -> publicKey == NULL ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n tmp_len = EC_POINT_point2oct ( a -> group , a -> pub_key , a -> conv_form , NULL , 0 , NULL ) ;\n if ( tmp_len > buf_len ) {\n unsigned char * tmp_buffer = OPENSSL_realloc ( buffer , tmp_len ) ;\n if ( ! tmp_buffer ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_MALLOC_FAILURE ) ;\n goto err ;\n }\n buffer = tmp_buffer ;\n buf_len = tmp_len ;\n }\n if ( ! EC_POINT_point2oct ( a -> group , a -> pub_key , a -> conv_form , buffer , buf_len , NULL ) ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_EC_LIB ) ;\n goto err ;\n }\n priv_key -> publicKey -> flags &= ~ ( ASN1_STRING_FLAG_BITS_LEFT | 0x07 ) ;\n priv_key -> publicKey -> flags |= ASN1_STRING_FLAG_BITS_LEFT ;\n if ( ! M_ASN1_BIT_STRING_set ( priv_key -> publicKey , buffer , buf_len ) ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_ASN1_LIB ) ;\n goto err ;\n }\n }\n if ( ( ret = i2d_EC_PRIVATEKEY ( priv_key , out ) ) == 0 ) {\n ECerr ( EC_F_I2D_ECPRIVATEKEY , ERR_R_EC_LIB ) ;\n goto err ;\n }\n ok = 1 ;\n err : if ( buffer ) OPENSSL_free ( buffer ) ;\n if ( priv_key ) EC_PRIVATEKEY_free ( priv_key ) ;\n return ( ok ? ret : 0 ) ;\n }","target":0,"code_token_length":757,"total_token_length":993,"max_tokens_setting":1024}
+{"idx":339981,"func":"void load_seg(int seg_reg, int selector)\n\n{\n\n    SegmentCache *sc;\n\n    SegmentDescriptorTable *dt;\n\n    int index;\n\n    uint32_t e1, e2;\n\n    uint8_t *ptr;\n\n\n\n    env->segs[seg_reg] = selector;\n\n    sc = &env->seg_cache[seg_reg];\n\n    if (env->eflags & VM_MASK) {\n\n        sc->base = (void *)(selector << 4);\n\n        sc->limit = 0xffff;\n\n        sc->seg_32bit = 0;\n\n    } else {\n\n        if (selector & 0x4)\n\n            dt = &env->ldt;\n\n        else\n\n            dt = &env->gdt;\n\n        index = selector & ~7;\n\n        if ((index + 7) > dt->limit)\n\n            raise_exception_err(EXCP0D_GPF, selector);\n\n        ptr = dt->base + index;\n\n        e1 = ldl(ptr);\n\n        e2 = ldl(ptr + 4);\n\n        sc->base = (void *)((e1 >> 16) | ((e2 & 0xff) << 16) | (e2 & 0xff000000));\n\n        sc->limit = (e1 & 0xffff) | (e2 & 0x000f0000);\n\n        if (e2 & (1 << 23))\n\n            sc->limit = (sc->limit << 12) | 0xfff;\n\n        sc->seg_32bit = (e2 >> 22) & 1;\n\n#if 0\n\n        fprintf(logfile, \"load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx seg_32bit=%d\\n\", \n\n                selector, (unsigned long)sc->base, sc->limit, sc->seg_32bit);\n\n#endif\n\n    }\n\n}\n","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":348619,"func":"static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,\n\t\t\t       char *buf, unsigned int bug)\n{\n\tif (!boot_cpu_has_bug(bug))\n\t\treturn sprintf(buf, \"Not affected\\n\");\n\n\tswitch (bug) {\n\tcase X86_BUG_CPU_MELTDOWN:\n\t\tif (boot_cpu_has(X86_FEATURE_PTI))\n\t\t\treturn sprintf(buf, \"Mitigation: PTI\\n\");\n\n\t\tif (hypervisor_is_type(X86_HYPER_XEN_PV))\n\t\t\treturn sprintf(buf, \"Unknown (XEN PV detected, hypervisor mitigation required)\\n\");\n\n\t\tbreak;\n\n\tcase X86_BUG_SPECTRE_V1:\n\t\treturn sprintf(buf, \"Mitigation: __user pointer sanitization\\n\");\n\n\tcase X86_BUG_SPECTRE_V2:\n\t\treturn sprintf(buf, \"%s%s%s%s%s%s\\n\", spectre_v2_strings[spectre_v2_enabled],\n\t\t\t       ibpb_state(),\n\t\t\t       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? \", IBRS_FW\" : \"\",\n\t\t\t       stibp_state(),\n\t\t\t       boot_cpu_has(X86_FEATURE_RSB_CTXSW) ? \", RSB filling\" : \"\",\n\t\t\t       spectre_v2_module_string());\n\n\tcase X86_BUG_SPEC_STORE_BYPASS:\n\t\treturn sprintf(buf, \"%s\\n\", ssb_strings[ssb_mode]);\n\n\tcase X86_BUG_L1TF:\n\t\tif (boot_cpu_has(X86_FEATURE_L1TF_PTEINV))\n\t\t\treturn l1tf_show_state(buf);\n\t\tbreak;\n\n\tcase X86_BUG_MDS:\n\t\treturn mds_show_state(buf);\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn sprintf(buf, \"Vulnerable\\n\");\n}","target":1,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":42680,"func":"UnicodeStringTest::TestSpacePadding()\n{\n    UnicodeString test1(\"hello\");\n    UnicodeString test2(\"   there\");\n    UnicodeString test3(\"Hi!  How ya doin'?  Beautiful day, isn't it?\");\n    UnicodeString test4;\n    UBool returnVal;\n    UnicodeString expectedValue;\n\n    returnVal = test1.padLeading(15);\n    expectedValue = \"          hello\";\n    if (returnVal == FALSE || test1 != expectedValue)\n        errln(\"padLeading() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test1 + \"\\\".\");\n\n    returnVal = test2.padTrailing(15);\n    expectedValue = \"   there       \";\n    if (returnVal == FALSE || test2 != expectedValue)\n        errln(\"padTrailing() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test2 + \"\\\".\");\n\n    expectedValue = test3;\n    returnVal = test3.padTrailing(15);\n    if (returnVal == TRUE || test3 != expectedValue)\n        errln(\"padTrailing() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test3 + \"\\\".\");\n\n    expectedValue = \"hello\";\n    test4.setTo(test1).trim();\n\n    if (test4 != expectedValue || test1 == expectedValue || test4 != expectedValue)\n        errln(\"trim(UnicodeString&) failed\");\n    \n    test1.trim();\n    if (test1 != expectedValue)\n        errln(\"trim() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test1 + \"\\\".\");\n\n    test2.trim();\n    expectedValue = \"there\";\n    if (test2 != expectedValue)\n        errln(\"trim() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test2 + \"\\\".\");\n\n    test3.trim();\n    expectedValue = \"Hi!  How ya doin'?  Beautiful day, isn't it?\";\n    if (test3 != expectedValue)\n        errln(\"trim() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test3 + \"\\\".\");\n\n    returnVal = test1.truncate(15);\n    expectedValue = \"hello\";\n    if (returnVal == TRUE || test1 != expectedValue)\n        errln(\"truncate() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test1 + \"\\\".\");\n\n    returnVal = test2.truncate(15);\n    expectedValue = \"there\";\n    if (returnVal == TRUE || test2 != expectedValue)\n        errln(\"truncate() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test2 + \"\\\".\");\n\n    returnVal = test3.truncate(15);\n    expectedValue = \"Hi!  How ya doi\";\n    if (returnVal == FALSE || test3 != expectedValue)\n        errln(\"truncate() failed: expected \\\"\" + expectedValue + \"\\\", got \\\"\" + test3 + \"\\\".\");\n}","target":0,"code_token_length":606,"total_token_length":842,"max_tokens_setting":1024}
+{"idx":333313,"func":"int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,\n\n                          const char *filename, void *logctx,\n\n                          unsigned int offset, unsigned int max_probe_size)\n\n{\n\n    AVProbeData pd = { filename ? filename : \"\", NULL, -offset };\n\n    unsigned char *buf = NULL;\n\n    int ret = 0, probe_size;\n\n\n\n    if (!max_probe_size) {\n\n        max_probe_size = PROBE_BUF_MAX;\n\n    } else if (max_probe_size > PROBE_BUF_MAX) {\n\n        max_probe_size = PROBE_BUF_MAX;\n\n    } else if (max_probe_size < PROBE_BUF_MIN) {\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    if (offset >= max_probe_size) {\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt;\n\n        probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) {\n\n        int score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0;\n\n        int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;\n\n        void *buftmp;\n\n\n\n        if (probe_size < offset) {\n\n            continue;\n\n        }\n\n\n\n        \/* read probe data *\/\n\n        buftmp = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);\n\n        if(!buftmp){\n\n            av_free(buf);\n\n            return AVERROR(ENOMEM);\n\n        }\n\n        buf=buftmp;\n\n        if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) {\n\n            \/* fail if error was not end of file, otherwise, lower score *\/\n\n            if (ret != AVERROR_EOF) {\n\n                av_free(buf);\n\n                return ret;\n\n            }\n\n            score = 0;\n\n            ret = 0;            \/* error was end of file, nothing read *\/\n\n        }\n\n        pd.buf_size += ret;\n\n        pd.buf = &buf[offset];\n\n\n\n        memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);\n\n\n\n        \/* guess file format *\/\n\n        *fmt = av_probe_input_format2(&pd, 1, &score);\n\n        if(*fmt){\n\n            if(score <= AVPROBE_SCORE_RETRY){ \/\/this can only be true in the last iteration\n\n                av_log(logctx, AV_LOG_WARNING, \"Format %s detected only with low score of %d, misdetection possible!\\n\", (*fmt)->name, score);\n\n            }else\n\n                av_log(logctx, AV_LOG_DEBUG, \"Format %s probed with size=%d and score=%d\\n\", (*fmt)->name, probe_size, score);\n\n        }\n\n    }\n\n\n\n    if (!*fmt) {\n\n        av_free(buf);\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    \/* rewind. reuse probe buffer to avoid seeking *\/\n\n    if ((ret = ffio_rewind_with_probe_data(pb, buf, pd.buf_size)) < 0)\n\n        av_free(buf);\n\n\n\n    return ret;\n\n}\n","target":1,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":245252,"func":"void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {\n  LocalizedString localized_strings[] = {\n      {\"searchEnginesPageTitle\", IDS_SETTINGS_SEARCH_ENGINES},\n      {\"searchEnginesAddSearchEngine\",\n       IDS_SETTINGS_SEARCH_ENGINES_ADD_SEARCH_ENGINE},\n      {\"searchEnginesEditSearchEngine\",\n       IDS_SETTINGS_SEARCH_ENGINES_EDIT_SEARCH_ENGINE},\n      {\"searchEngines\", IDS_SETTINGS_SEARCH_ENGINES},\n      {\"searchEnginesDefault\", IDS_SETTINGS_SEARCH_ENGINES_DEFAULT_ENGINES},\n      {\"searchEnginesOther\", IDS_SETTINGS_SEARCH_ENGINES_OTHER_ENGINES},\n      {\"searchEnginesNoOtherEngines\",\n       IDS_SETTINGS_SEARCH_ENGINES_NO_OTHER_ENGINES},\n      {\"searchEnginesExtension\", IDS_SETTINGS_SEARCH_ENGINES_EXTENSION_ENGINES},\n      {\"searchEnginesSearch\", IDS_SETTINGS_SEARCH_ENGINES_SEARCH},\n      {\"searchEnginesSearchEngine\", IDS_SETTINGS_SEARCH_ENGINES_SEARCH_ENGINE},\n      {\"searchEnginesKeyword\", IDS_SETTINGS_SEARCH_ENGINES_KEYWORD},\n      {\"searchEnginesQueryURL\", IDS_SETTINGS_SEARCH_ENGINES_QUERY_URL},\n      {\"searchEnginesQueryURLExplanation\",\n       IDS_SETTINGS_SEARCH_ENGINES_QUERY_URL_EXPLANATION},\n      {\"searchEnginesMakeDefault\", IDS_SETTINGS_SEARCH_ENGINES_MAKE_DEFAULT},\n      {\"searchEnginesRemoveFromList\",\n       IDS_SETTINGS_SEARCH_ENGINES_REMOVE_FROM_LIST},\n      {\"searchEnginesManageExtension\",\n       IDS_SETTINGS_SEARCH_ENGINES_MANAGE_EXTENSION},\n  };\n  AddLocalizedStringsBulk(html_source, localized_strings,\n                          arraysize(localized_strings));\n}\n","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":221585,"func":"void DocumentLoader::responseReceived(CachedResource* resource, const ResourceResponse& response)\n{\n    ASSERT_UNUSED(resource, m_mainResource == resource);\n    RefPtr<DocumentLoader> protect(this);\n    bool willLoadFallback = m_applicationCacheHost->maybeLoadFallbackForMainResponse(request(), response);\n\n    bool shouldRemoveResourceFromCache = willLoadFallback;\n#if PLATFORM(CHROMIUM)\n    if (response.appCacheID())\n        shouldRemoveResourceFromCache = true;\n#endif\n    if (shouldRemoveResourceFromCache)\n        memoryCache()->remove(m_mainResource.get());\n\n    if (willLoadFallback)\n        return;\n\n    DEFINE_STATIC_LOCAL(AtomicString, xFrameOptionHeader, (\"x-frame-options\", AtomicString::ConstructFromLiteral));\n    HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(xFrameOptionHeader);\n    if (it != response.httpHeaderFields().end()) {\n        String content = it->value;\n        ASSERT(m_mainResource);\n        unsigned long identifier = m_identifierForLoadWithoutResourceLoader ? m_identifierForLoadWithoutResourceLoader : m_mainResource->identifier();\n        ASSERT(identifier);\n        if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, response.url(), identifier)) {\n             InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, identifier, response);\n             String message = \"Refused to display '\" + response.url().elidedString() + \"' in a frame because it set 'X-Frame-Options' to '\" + content + \"'.\";\n             frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, identifier);\n             if (HTMLFrameOwnerElement* ownerElement = frame()->ownerElement())\n                 ownerElement->dispatchEvent(Event::create(eventNames().loadEvent, false, false));\n             cancelMainResourceLoad(frameLoader()->cancelledError(m_request));\n            return;\n        }\n    }\n\n#if !USE(CF)\n    ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());\n#endif\n\n    if (m_isLoadingMultipartContent) {\n        setupForReplace();\n        m_mainResource->clear();\n    } else if (response.isMultipart()) {\n        FeatureObserver::observe(m_frame->document(), FeatureObserver::MultipartMainResource);\n        m_isLoadingMultipartContent = true;\n    }\n\n    m_response = response;\n\n    if (m_identifierForLoadWithoutResourceLoader)\n        frameLoader()->notifier()->dispatchDidReceiveResponse(this, m_identifierForLoadWithoutResourceLoader, m_response, 0);\n\n    ASSERT(!m_waitingForContentPolicy);\n    m_waitingForContentPolicy = true;\n\n    if (m_substituteData.isValid()) {\n        continueAfterContentPolicy(PolicyUse);\n        return;\n    }\n\n#if ENABLE(FTPDIR)\n    Settings* settings = m_frame->settings();\n    if (settings && settings->forceFTPDirectoryListings() && m_response.mimeType() == \"application\/x-ftp-directory\") {\n        continueAfterContentPolicy(PolicyUse);\n        return;\n    }\n#endif\n\n#if USE(CONTENT_FILTERING)\n    if (response.url().protocolIs(\"https\") && ContentFilter::isEnabled())\n        m_contentFilter = ContentFilter::create(response);\n#endif\n\n    frameLoader()->policyChecker()->checkContentPolicy(m_response, callContinueAfterContentPolicy, this);\n}\n","target":0,"code_token_length":680,"total_token_length":916,"max_tokens_setting":1024}
+{"idx":67994,"func":"static void instance_destroy(struct calling_instance *inst)\n{\n\tstruct le *le;\n\n\tif (inst->thread_run) {\n\t\tinst->thread_run = false;\n\n\t\tdebug(\"wcall: joining thread..\\n\");\n\n\t\tpthread_join(inst->tid, NULL);\n\t\tpthread_detach(inst->tid);\n\t\tinst->tid = 0;\n\t}\n\n\tuintptr_t vuser = inst->wuser;\n\tmsystem_unregister_listener((void*)vuser);\n\ttmr_cancel(&inst->tmr_roam);\n\n\t\/* Dont call list_flush as we expect a valid list\n\t   in the wcall destructor *\/\n\tle = inst->wcalls.head;\n\twhile(le) {\n\t\tif (le->data) {\n\t\t\tmem_deref(le->data);\n\t\t\tle = inst->wcalls.head;\n\t\t}\n\t\telse {\n\t\t\tle = le->next;\n\t\t}\n\t}\n\tlist_flush(&inst->ctxl);\n\n\tlock_write_get(inst->lock);\n\tlist_unlink(&inst->le);\n\tlist_flush(&inst->ecalls);\n\n\tinst->userid = mem_deref(inst->userid);\n\tinst->clientid = mem_deref(inst->clientid);\n\tinst->mm = mem_deref(inst->mm);\n\tinst->msys = mem_deref(inst->msys);\n\tinst->cfg = mem_deref(inst->cfg);\n\tinst->media_laddr = mem_deref(inst->media_laddr);\n\n\tinst->readyh = NULL;\n\tinst->sendh = NULL;\n\tinst->incomingh = NULL;\n\tinst->estabh = NULL;\n\tinst->closeh = NULL;\n\tinst->vstateh = NULL;\n\tinst->acbrh = NULL;\n\tinst->cfg_reqh = NULL;\n\tinst->arg = NULL;\n\n\tlock_rel(inst->lock);\n\n\tinst->lock = mem_deref(inst->lock);\n\tinst->netprobe = mem_deref(inst->netprobe);\n\n\t{\n\t\tstruct inst_dtor_entry *ide;\n\t\tide = mem_zalloc(sizeof(*ide), ide_destructor);\n\t\tif (!ide)\n\t\t\treturn;\n\t\t\n\t\tide->inst = inst;\n\t\tide->marshal = inst->marshal;\n\n\t\tif (!inst->shuth)\n\t\t\tide_handler(ide);\n\t\telse {\n\t\t\ttmr_init(&ide->tmr);\n\t\t\tide->shuth = inst->shuth;\n\t\t\tide->shuth_arg = inst->shuth_arg;\n\t\t\ttmr_start(&ide->tmr, 0, ide_handler, ide);\n\t\t}\n\t}\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":284102,"func":"ScopedFramebufferCopyBinder::ScopedFramebufferCopyBinder(\n    GLES2DecoderImpl* decoder,\n    GLint x,\n    GLint y,\n    GLint width,\n    GLint height)\n    : decoder_(decoder) {\n  const Framebuffer::Attachment* attachment =\n      decoder->framebuffer_state_.bound_read_framebuffer.get()\n          ->GetReadBufferAttachment();\n  DCHECK(attachment);\n  auto* api = decoder_->api();\n  api->glGenTexturesFn(1, &temp_texture_);\n\n  ScopedTextureBinder texture_binder(&decoder->state_,\n                                     decoder->error_state_.get(), temp_texture_,\n                                     GL_TEXTURE_2D);\n  if (width == 0 || height == 0) {\n    api->glCopyTexImage2DFn(GL_TEXTURE_2D, 0, attachment->internal_format(), 0,\n                            0, attachment->width(), attachment->height(), 0);\n  } else {\n    api->glCopyTexImage2DFn(GL_TEXTURE_2D, 0, attachment->internal_format(), x,\n                            y, width, height, 0);\n  }\n\n  api->glGenFramebuffersEXTFn(1, &temp_framebuffer_);\n  framebuffer_binder_ =\n      std::make_unique<ScopedFramebufferBinder>(decoder, temp_framebuffer_);\n  api->glFramebufferTexture2DEXTFn(GL_READ_FRAMEBUFFER_EXT,\n                                   GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,\n                                   temp_texture_, 0);\n  api->glReadBufferFn(GL_COLOR_ATTACHMENT0);\n}\n","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":336778,"func":"static float64 roundAndPackFloat64( flag zSign, int16 zExp, uint64_t zSig STATUS_PARAM)\n\n{\n\n    int8 roundingMode;\n\n    flag roundNearestEven;\n\n    int16 roundIncrement, roundBits;\n\n    flag isTiny;\n\n\n\n    roundingMode = STATUS(float_rounding_mode);\n\n    roundNearestEven = ( roundingMode == float_round_nearest_even );\n\n    roundIncrement = 0x200;\n\n    if ( ! roundNearestEven ) {\n\n        if ( roundingMode == float_round_to_zero ) {\n\n            roundIncrement = 0;\n\n        }\n\n        else {\n\n            roundIncrement = 0x3FF;\n\n            if ( zSign ) {\n\n                if ( roundingMode == float_round_up ) roundIncrement = 0;\n\n            }\n\n            else {\n\n                if ( roundingMode == float_round_down ) roundIncrement = 0;\n\n            }\n\n        }\n\n    }\n\n    roundBits = zSig & 0x3FF;\n\n    if ( 0x7FD <= (uint16_t) zExp ) {\n\n        if (    ( 0x7FD < zExp )\n\n             || (    ( zExp == 0x7FD )\n\n                  && ( (int64_t) ( zSig + roundIncrement ) < 0 ) )\n\n           ) {\n\n            float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);\n\n            return packFloat64( zSign, 0x7FF, - ( roundIncrement == 0 ));\n\n        }\n\n        if ( zExp < 0 ) {\n\n            if ( STATUS(flush_to_zero) ) return packFloat64( zSign, 0, 0 );\n\n            isTiny =\n\n                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )\n\n                || ( zExp < -1 )\n\n                || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );\n\n            shift64RightJamming( zSig, - zExp, &zSig );\n\n            zExp = 0;\n\n            roundBits = zSig & 0x3FF;\n\n            if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);\n\n        }\n\n    }\n\n    if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;\n\n    zSig = ( zSig + roundIncrement )>>10;\n\n    zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );\n\n    if ( zSig == 0 ) zExp = 0;\n\n    return packFloat64( zSign, zExp, zSig );\n\n\n\n}\n","target":1,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":40888,"func":"static int __hwahc_dev_set_key(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,\n\t\t\t       const void *key, size_t key_size,\n\t\t\t       u8 key_idx)\n{\n\tint result = -ENOMEM;\n\tstruct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);\n\tstruct wahc *wa = &hwahc->wa;\n\tu8 iface_no = wa->usb_iface->cur_altsetting->desc.bInterfaceNumber;\n\tstruct usb_key_descriptor *keyd;\n\tsize_t keyd_len;\n\n\tkeyd_len = sizeof(*keyd) + key_size;\n\tkeyd = kzalloc(keyd_len, GFP_KERNEL);\n\tif (keyd == NULL)\n\t\treturn -ENOMEM;\n\n\tkeyd->bLength = keyd_len;\n\tkeyd->bDescriptorType = USB_DT_KEY;\n\tkeyd->tTKID[0] = (tkid >>  0) & 0xff;\n\tkeyd->tTKID[1] = (tkid >>  8) & 0xff;\n\tkeyd->tTKID[2] = (tkid >> 16) & 0xff;\n\tmemcpy(keyd->bKeyData, key, key_size);\n\n\tresult = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),\n\t\t\tUSB_REQ_SET_DESCRIPTOR,\n\t\t\tUSB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,\n\t\t\tUSB_DT_KEY << 8 | key_idx,\n\t\t\tport_idx << 8 | iface_no,\n\t\t\tkeyd, keyd_len, USB_CTRL_SET_TIMEOUT);\n\n\tkzfree(keyd); \/* clear keys etc. *\/\n\treturn result;\n}","target":0,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":497852,"func":"static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    enum AVAudioServiceType *ast;\n    int ac3info, acmod, lfeon, bsmod;\n    uint64_t mask;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    ast = (enum AVAudioServiceType*)av_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE,\n                                                            sizeof(*ast));\n    if (!ast)\n        return AVERROR(ENOMEM);\n\n    ac3info = avio_rb24(pb);\n    bsmod = (ac3info >> 14) & 0x7;\n    acmod = (ac3info >> 11) & 0x7;\n    lfeon = (ac3info >> 10) & 0x1;\n\n    mask = ff_ac3_channel_layout_tab[acmod];\n    if (lfeon)\n        mask |= AV_CH_LOW_FREQUENCY;\n    av_channel_layout_uninit(&st->codecpar->ch_layout);\n    av_channel_layout_from_mask(&st->codecpar->ch_layout, mask);\n\n    *ast = bsmod;\n    if (st->codecpar->ch_layout.nb_channels > 1 && bsmod == 0x7)\n        *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;\n\n    return 0;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":469673,"func":"virSecuritySELinuxMCSFind(virSecurityManager *mgr,\n                          const char *sens,\n                          int catMin,\n                          int catMax)\n{\n    virSecuritySELinuxData *data = virSecurityManagerGetPrivateData(mgr);\n    int catRange;\n    char *mcs = NULL;\n\n    \/* +1 since virRandomInt range is exclusive of the upper bound *\/\n    catRange = (catMax - catMin) + 1;\n\n    if (catRange < 8) {\n        virReportError(VIR_ERR_INTERNAL_ERROR,\n                       _(\"Category range c%d-c%d too small\"),\n                       catMin, catMax);\n        return NULL;\n    }\n\n    VIR_DEBUG(\"Using sensitivity level '%s' cat min %d max %d range %d\",\n              sens, catMin, catMax, catRange);\n\n    for (;;) {\n        int c1 = virRandomInt(catRange);\n        int c2 = virRandomInt(catRange);\n\n        VIR_DEBUG(\"Try cat %s:c%d,c%d\", sens, c1 + catMin, c2 + catMin);\n\n        if (c1 == c2) {\n            \/*\n             * A process can access a file if the set of MCS categories\n             * for the file is equal-to *or* a subset-of, the set of\n             * MCS categories for the process.\n             *\n             * IOW, we must discard case where the categories are equal\n             * because that is a subset of other category pairs.\n             *\/\n            continue;\n        } else {\n            if (c1 > c2) {\n                int t = c1;\n                c1 = c2;\n                c2 = t;\n            }\n            mcs = g_strdup_printf(\"%s:c%d,c%d\", sens, catMin + c1, catMin + c2);\n        }\n\n        if (virHashLookup(data->mcs, mcs) == NULL)\n            break;\n\n        VIR_FREE(mcs);\n    }\n\n    return mcs;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":305849,"func":"void handleCipherUnavailable(\n    CipherUnavailable* originalData,\n    QuicServerConnectionState& conn,\n    size_t packetSize,\n    ServerEvents::ReadData& readData) {\n  if (!originalData->packet || originalData->packet->empty()) {\n    VLOG(10) << \"drop because no data \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kNoData);\n    }\n    QUIC_TRACE(packet_drop, conn, \"no_data\");\n    return;\n  }\n  if (originalData->protectionType != ProtectionType::ZeroRtt &&\n      originalData->protectionType != ProtectionType::KeyPhaseZero) {\n    VLOG(10) << \"drop because unexpected protection level \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kUnexpectedProtectionLevel);\n    }\n    QUIC_TRACE(packet_drop, conn, \"unexpected_protection_level\");\n    return;\n  }\n\n  size_t combinedSize =\n      (conn.pendingZeroRttData ? conn.pendingZeroRttData->size() : 0) +\n      (conn.pendingOneRttData ? conn.pendingOneRttData->size() : 0);\n  if (combinedSize >= conn.transportSettings.maxPacketsToBuffer) {\n    VLOG(10) << \"drop because max buffered \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kMaxBuffered);\n    }\n    QUIC_TRACE(packet_drop, conn, \"max_buffered\");\n    return;\n  }\n\n  auto& pendingData = originalData->protectionType == ProtectionType::ZeroRtt\n      ? conn.pendingZeroRttData\n      : conn.pendingOneRttData;\n  if (pendingData) {\n    QUIC_TRACE(\n        packet_buffered,\n        conn,\n        originalData->packetNum,\n        originalData->protectionType,\n        packetSize);\n    if (conn.qLogger) {\n      conn.qLogger->addPacketBuffered(\n          originalData->packetNum, originalData->protectionType, packetSize);\n    }\n    ServerEvents::ReadData pendingReadData;\n    pendingReadData.peer = readData.peer;\n    pendingReadData.networkData = NetworkDataSingle(\n        std::move(originalData->packet), readData.networkData.receiveTimePoint);\n    pendingData->emplace_back(std::move(pendingReadData));\n    VLOG(10) << \"Adding pending data to \"\n             << toString(originalData->protectionType)\n             << \" buffer size=\" << pendingData->size() << \" \" << conn;\n  } else {\n    VLOG(10) << \"drop because \" << toString(originalData->protectionType)\n             << \" buffer no longer available \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kBufferUnavailable);\n    }\n    QUIC_TRACE(packet_drop, conn, \"buffer_unavailable\");\n  }\n}","target":0,"code_token_length":636,"total_token_length":872,"max_tokens_setting":1024}
+{"idx":281069,"func":"sshpkt_fatal(struct ssh *ssh, const char *tag, int r)\n{\n\tswitch (r) {\n\tcase SSH_ERR_CONN_CLOSED:\n\t\tlogdie(\"Connection closed by %.200s port %d\",\n\t\t    ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));\n\tcase SSH_ERR_CONN_TIMEOUT:\n\t\tlogdie(\"Connection %s %.200s port %d timed out\",\n\t\t    ssh->state->server_side ? \"from\" : \"to\",\n\t\t    ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));\n\tcase SSH_ERR_DISCONNECTED:\n\t\tlogdie(\"Disconnected from %.200s port %d\",\n\t\t    ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));\n\tcase SSH_ERR_SYSTEM_ERROR:\n\t\tif (errno == ECONNRESET)\n\t\t\tlogdie(\"Connection reset by %.200s port %d\",\n\t\t\t    ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));\n\t\t\/* FALLTHROUGH *\/\n\tcase SSH_ERR_NO_CIPHER_ALG_MATCH:\n\tcase SSH_ERR_NO_MAC_ALG_MATCH:\n\tcase SSH_ERR_NO_COMPRESS_ALG_MATCH:\n\tcase SSH_ERR_NO_KEX_ALG_MATCH:\n\tcase SSH_ERR_NO_HOSTKEY_ALG_MATCH:\n\t\tif (ssh && ssh->kex && ssh->kex->failed_choice) {\n\t\t\tlogdie(\"Unable to negotiate with %.200s port %d: %s. \"\n\t\t\t    \"Their offer: %s\", ssh_remote_ipaddr(ssh),\n\t\t\t    ssh_remote_port(ssh), ssh_err(r),\n\t\t\t    ssh->kex->failed_choice);\n\t\t}\n\t\t\/* FALLTHROUGH *\/\n\tdefault:\n\t\tlogdie(\"%s%sConnection %s %.200s port %d: %s\",\n\t\t    tag != NULL ? tag : \"\", tag != NULL ? \": \" : \"\",\n\t\t    ssh->state->server_side ? \"from\" : \"to\",\n\t\t    ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), ssh_err(r));\n\t}\n}\n","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":153344,"func":"int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)\n{\n\tstruct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;\n\tstruct compat_cmsghdr cmhdr;\n\tstruct compat_timeval ctv;\n\tstruct compat_timespec cts[3];\n\tint cmlen;\n\n\tif (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) {\n\t\tkmsg->msg_flags |= MSG_CTRUNC;\n\t\treturn 0; \/* XXX: return error? check spec. *\/\n\t}\n\n\tif (!COMPAT_USE_64BIT_TIME) {\n\t\tif (level == SOL_SOCKET && type == SCM_TIMESTAMP) {\n\t\t\tstruct timeval *tv = (struct timeval *)data;\n\t\t\tctv.tv_sec = tv->tv_sec;\n\t\t\tctv.tv_usec = tv->tv_usec;\n\t\t\tdata = &ctv;\n\t\t\tlen = sizeof(ctv);\n\t\t}\n\t\tif (level == SOL_SOCKET &&\n\t\t    (type == SCM_TIMESTAMPNS || type == SCM_TIMESTAMPING)) {\n\t\t\tint count = type == SCM_TIMESTAMPNS ? 1 : 3;\n\t\t\tint i;\n\t\t\tstruct timespec *ts = (struct timespec *)data;\n\t\t\tfor (i = 0; i < count; i++) {\n\t\t\t\tcts[i].tv_sec = ts[i].tv_sec;\n\t\t\t\tcts[i].tv_nsec = ts[i].tv_nsec;\n\t\t\t}\n\t\t\tdata = &cts;\n\t\t\tlen = sizeof(cts[0]) * count;\n\t\t}\n\t}\n\n\tcmlen = CMSG_COMPAT_LEN(len);\n\tif (kmsg->msg_controllen < cmlen) {\n\t\tkmsg->msg_flags |= MSG_CTRUNC;\n\t\tcmlen = kmsg->msg_controllen;\n\t}\n\tcmhdr.cmsg_level = level;\n\tcmhdr.cmsg_type = type;\n\tcmhdr.cmsg_len = cmlen;\n\n\tif (copy_to_user(cm, &cmhdr, sizeof cmhdr))\n\t\treturn -EFAULT;\n\tif (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr)))\n\t\treturn -EFAULT;\n\tcmlen = CMSG_COMPAT_SPACE(len);\n\tif (kmsg->msg_controllen < cmlen)\n\t\tcmlen = kmsg->msg_controllen;\n\tkmsg->msg_control += cmlen;\n\tkmsg->msg_controllen -= cmlen;\n\treturn 0;\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":257296,"func":"static char * date_time_from_opaque ( tvbuff_t * tvb , guint32 offset , guint32 data_len ) {\n char * str ;\n switch ( data_len ) {\n case 4 : str = wmem_strdup_printf ( wmem_packet_scope ( ) , \"%%DateTime: \" \"%02x%02x-%02x-%02xT00:00:00Z\" , tvb_get_guint8 ( tvb , offset ) , tvb_get_guint8 ( tvb , offset + 1 ) , tvb_get_guint8 ( tvb , offset + 2 ) , tvb_get_guint8 ( tvb , offset + 3 ) ) ;\n break ;\n case 5 : str = wmem_strdup_printf ( wmem_packet_scope ( ) , \"%%DateTime: \" \"%02x%02x-%02x-%02xT%02x:00:00Z\" , tvb_get_guint8 ( tvb , offset ) , tvb_get_guint8 ( tvb , offset + 1 ) , tvb_get_guint8 ( tvb , offset + 2 ) , tvb_get_guint8 ( tvb , offset + 3 ) , tvb_get_guint8 ( tvb , offset + 4 ) ) ;\n break ;\n case 6 : str = wmem_strdup_printf ( wmem_packet_scope ( ) , \"%%DateTime: \" \"%02x%02x-%02x-%02xT%02x:%02x:00Z\" , tvb_get_guint8 ( tvb , offset ) , tvb_get_guint8 ( tvb , offset + 1 ) , tvb_get_guint8 ( tvb , offset + 2 ) , tvb_get_guint8 ( tvb , offset + 3 ) , tvb_get_guint8 ( tvb , offset + 4 ) , tvb_get_guint8 ( tvb , offset + 5 ) ) ;\n break ;\n case 7 : str = wmem_strdup_printf ( wmem_packet_scope ( ) , \"%%DateTime: \" \"%02x%02x-%02x-%02xT%02x:%02x:%02xZ\" , tvb_get_guint8 ( tvb , offset ) , tvb_get_guint8 ( tvb , offset + 1 ) , tvb_get_guint8 ( tvb , offset + 2 ) , tvb_get_guint8 ( tvb , offset + 3 ) , tvb_get_guint8 ( tvb , offset + 4 ) , tvb_get_guint8 ( tvb , offset + 5 ) , tvb_get_guint8 ( tvb , offset + 6 ) ) ;\n break ;\n default : str = wmem_strdup_printf ( wmem_packet_scope ( ) , \"<Error: invalid binary %%DateTime \" \"(%d bytes of opaque data)>\" , data_len ) ;\n break ;\n }\n return str ;\n }","target":0,"code_token_length":603,"total_token_length":839,"max_tokens_setting":1024}
+{"idx":19980,"func":"char * curl_easy_escape ( struct Curl_easy * data , const char * string , int inlength ) {\n size_t alloc ;\n char * ns ;\n char * testing_ptr = NULL ;\n unsigned char in ;\n size_t newlen ;\n size_t strindex = 0 ;\n size_t length ;\n CURLcode result ;\n if ( inlength < 0 ) return NULL ;\n alloc = ( inlength ? ( size_t ) inlength : strlen ( string ) ) + 1 ;\n newlen = alloc ;\n ns = malloc ( alloc ) ;\n if ( ! ns ) return NULL ;\n length = alloc - 1 ;\n while ( length -- ) {\n in = * string ;\n if ( Curl_isunreserved ( in ) ) ns [ strindex ++ ] = in ;\n else {\n newlen += 2 ;\n if ( newlen > alloc ) {\n alloc *= 2 ;\n testing_ptr = realloc ( ns , alloc ) ;\n if ( ! testing_ptr ) {\n free ( ns ) ;\n return NULL ;\n }\n else {\n ns = testing_ptr ;\n }\n }\n result = Curl_convert_to_network ( data , & in , 1 ) ;\n if ( result ) {\n free ( ns ) ;\n return NULL ;\n }\n snprintf ( & ns [ strindex ] , 4 , \"%%%02X\" , in ) ;\n strindex += 3 ;\n }\n string ++ ;\n }\n ns [ strindex ] = 0 ;\n return ns ;\n }","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":337024,"func":"static void ohci_reset(void *opaque)\n\n{\n\n    OHCIState *ohci = opaque;\n\n    OHCIPort *port;\n\n    int i;\n\n\n\n    ohci_bus_stop(ohci);\n\n    ohci->ctl = 0;\n\n    ohci->old_ctl = 0;\n\n    ohci->status = 0;\n\n    ohci->intr_status = 0;\n\n    ohci->intr = OHCI_INTR_MIE;\n\n\n\n    ohci->hcca = 0;\n\n    ohci->ctrl_head = ohci->ctrl_cur = 0;\n\n    ohci->bulk_head = ohci->bulk_cur = 0;\n\n    ohci->per_cur = 0;\n\n    ohci->done = 0;\n\n    ohci->done_count = 7;\n\n\n\n    \/* FSMPS is marked TBD in OCHI 1.0, what gives ffs?\n\n     * I took the value linux sets ...\n\n     *\/\n\n    ohci->fsmps = 0x2778;\n\n    ohci->fi = 0x2edf;\n\n    ohci->fit = 0;\n\n    ohci->frt = 0;\n\n    ohci->frame_number = 0;\n\n    ohci->pstart = 0;\n\n    ohci->lst = OHCI_LS_THRESH;\n\n\n\n    ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports;\n\n    ohci->rhdesc_b = 0x0; \/* Impl. specific *\/\n\n    ohci->rhstatus = 0;\n\n\n\n    for (i = 0; i < ohci->num_ports; i++)\n\n      {\n\n        port = &ohci->rhport[i];\n\n        port->ctrl = 0;\n\n        if (port->port.dev) {\n\n            usb_attach(&port->port, port->port.dev);\n\n        }\n\n      }\n\n    if (ohci->async_td) {\n\n        usb_cancel_packet(&ohci->usb_packet);\n\n        ohci->async_td = 0;\n\n    }\n\n    DPRINTF(\"usb-ohci: Reset %s\\n\", ohci->name);\n\n}\n","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":14416,"func":"bool SimplifiedBackwardsTextIterator::handleTextNode()\n{\n    m_lastTextNode = m_node;\n\n    int startOffset;\n    int offsetInNode;\n    RenderText* renderer = handleFirstLetter(startOffset, offsetInNode);\n    if (!renderer)\n        return true;\n\n    String text = renderer->text();\n    if (!renderer->firstTextBox() && text.length() > 0)\n        return true;\n\n    m_positionEndOffset = m_offset;\n    m_offset = startOffset + offsetInNode;\n    m_positionNode = m_node;\n    m_positionStartOffset = m_offset;\n\n    ASSERT(0 <= m_positionStartOffset - offsetInNode && m_positionStartOffset - offsetInNode <= static_cast<int>(text.length()));\n    ASSERT(1 <= m_positionEndOffset - offsetInNode && m_positionEndOffset - offsetInNode <= static_cast<int>(text.length()));\n    ASSERT(m_positionStartOffset <= m_positionEndOffset);\n\n     m_textLength = m_positionEndOffset - m_positionStartOffset;\n     m_textCharacters = text.characters() + (m_positionStartOffset - offsetInNode);\n     ASSERT(m_textCharacters >= text.characters());\n    ASSERT(m_textCharacters + m_textLength <= text.characters() + static_cast<int>(text.length()));\n \n     m_lastCharacter = text[m_positionEndOffset - 1];\n \n    return !m_shouldHandleFirstLetter;\n}\n","target":1,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":344364,"func":"ensure_credentials_sync (GoaProvider         *provider,\n                         GoaObject           *object,\n                         gint                *out_expires_in,\n                         GCancellable        *cancellable,\n                         GError             **error)\n{\n  GVariant *credentials;\n  GoaAccount *account;\n  GoaHttpClient *http_client;\n  gboolean ret;\n  const gchar *username;\n  gchar *password;\n  gchar *uri;\n  gchar *uri_webdav;\n\n  credentials = NULL;\n  http_client = NULL;\n  password = NULL;\n  uri = NULL;\n  uri_webdav = NULL;\n\n  ret = FALSE;\n\n  credentials = goa_utils_lookup_credentials_sync (provider,\n                                                   object,\n                                                   cancellable,\n                                                   error);\n  if (credentials == NULL)\n    {\n      if (error != NULL)\n        {\n          g_prefix_error (error, _(\"Credentials not found in keyring (%s, %d): \"),\n                          g_quark_to_string ((*error)->domain), (*error)->code);\n          (*error)->domain = GOA_ERROR;\n          (*error)->code = GOA_ERROR_NOT_AUTHORIZED;\n        }\n      goto out;\n    }\n\n  uri = goa_util_lookup_keyfile_string (object, \"Uri\");\n  uri_webdav = g_strconcat (uri, WEBDAV_ENDPOINT, NULL);\n\n  account = goa_object_peek_account (object);\n  username = goa_account_get_identity (account);\n\n  if (!g_variant_lookup (credentials, \"password\", \"s\", &password))\n    {\n      if (error != NULL)\n        {\n          *error = g_error_new (GOA_ERROR,\n                                GOA_ERROR_NOT_AUTHORIZED,\n                                _(\"Did not find password with username `%s' in credentials\"),\n                                username);\n        }\n      goto out;\n    }\n\n  http_client = goa_http_client_new ();\n  ret = goa_http_client_check_sync (http_client,\n                                    uri_webdav,\n                                    username,\n                                    password,\n                                    cancellable,\n                                    error);\n  if (!ret)\n    {\n      if (error != NULL)\n        {\n          g_prefix_error (error,\n                          \/* Translators: the first %s is the username\n                           * (eg., debarshi.ray@gmail.com or rishi), and the\n                           * (%s, %d) is the error domain and code.\n                           *\/\n                          _(\"Invalid password with username `%s' (%s, %d): \"),\n                          username,\n                          g_quark_to_string ((*error)->domain),\n                          (*error)->code);\n          (*error)->domain = GOA_ERROR;\n          (*error)->code = GOA_ERROR_NOT_AUTHORIZED;\n        }\n      goto out;\n    }\n\n  if (out_expires_in != NULL)\n    *out_expires_in = 0;\n\n out:\n  g_clear_object (&http_client);\n  g_free (password);\n  g_free (uri);\n  g_free (uri_webdav);\n  if (credentials != NULL)\n    g_variant_unref (credentials);\n  return ret;\n}","target":1,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":255345,"func":"char *suhosin_encrypt_single_cookie(char *name, int name_len, char *value, int value_len, char *key TSRMLS_DC)\n{\n\tchar buffer[4096];\n    char buffer2[4096];\n\tchar *buf = buffer, *buf2 = buffer2, *d, *d_url;\n    int l;\n\n\tif (name_len > sizeof(buffer)-2) {\n\t\tbuf = estrndup(name, name_len);\n\t} else {\n\t\tmemcpy(buf, name, name_len);\n\t\tbuf[name_len] = 0;\n\t}\n\t\n\tname_len = php_url_decode(buf, name_len);\n    normalize_varname(buf);\n    name_len = strlen(buf);\n\t\n\tif (SUHOSIN_G(cookie_plainlist)) {\n\t\tif (zend_hash_exists(SUHOSIN_G(cookie_plainlist), buf, name_len+1)) {\nencrypt_return_plain:\n\t\t\tif (buf != buffer) {\n\t\t\t\tefree(buf);\n\t\t\t}\n\t\t\treturn estrndup(value, value_len);\n\t\t}\n\t} else if (SUHOSIN_G(cookie_cryptlist)) {\n\t\tif (!zend_hash_exists(SUHOSIN_G(cookie_cryptlist), buf, name_len+1)) {\n\t\t\tgoto encrypt_return_plain;\n\t\t}\n\t}\n\t\n\tif (strlen(value) <= sizeof(buffer2)-2) {\n\t\tmemcpy(buf2, value, value_len);\n\t\tbuf2[value_len] = 0;\n\t} else {\n\t\tbuf2 = estrndup(value, value_len);\n\t}\n\t\n\tvalue_len = php_url_decode(buf2, value_len);\n\t\n\td = suhosin_encrypt_string(buf2, value_len, buf, name_len, key TSRMLS_CC);\n\td_url = php_url_encode(d, strlen(d), &l);\n\tefree(d);\n    if (buf != buffer) {\n\t\tefree(buf);\n\t}\n    if (buf2 != buffer2) {\n\t\tefree(buf2);\n\t}\n\treturn d_url;\n}","target":1,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":241105,"func":"cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type)\n{\n\tswitch (type) {\n\tcase TIFF_SHORT:\n\t\tif (count == 1) {\n\t\t\tuint16 shortv;\n\t\t\tCopyField(tag, shortv);\n\t\t} else if (count == 2) {\n\t\t\tuint16 shortv1, shortv2;\n\t\t\tCopyField2(tag, shortv1, shortv2);\n\t\t} else if (count == 4) {\n\t\t\tuint16 *tr, *tg, *tb, *ta;\n\t\t\tCopyField4(tag, tr, tg, tb, ta);\n\t\t} else if (count == (uint16) -1) {\n\t\t\tuint16 shortv1;\n\t\t\tuint16* shortav;\n\t\t\tCopyField2(tag, shortv1, shortav);\n\t\t}\n\t\tbreak;\n\tcase TIFF_LONG:\n\t\t{ uint32 longv;\n\t\t  CopyField(tag, longv);\n\t\t}\n\t\tbreak;\n\tcase TIFF_RATIONAL:\n\t\tif (count == 1) {\n\t\t\tfloat floatv;\n\t\t\tCopyField(tag, floatv);\n\t\t} else if (count == (uint16) -1) {\n\t\t\tfloat* floatav;\n\t\t\tCopyField(tag, floatav);\n\t\t}\n\t\tbreak;\n\tcase TIFF_ASCII:\n\t\t{ char* stringv;\n\t\t  CopyField(tag, stringv);\n\t\t}\n\t\tbreak;\n\tcase TIFF_DOUBLE:\n\t\tif (count == 1) {\n\t\t\tdouble doublev;\n\t\t\tCopyField(tag, doublev);\n\t\t} else if (count == (uint16) -1) {\n\t\t\tdouble* doubleav;\n\t\t\tCopyField(tag, doubleav);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tTIFFError(TIFFFileName(in),\n\t\t    \"Data type %d is not supported, tag %d skipped.\",\n\t\t    tag, type);\n\t}\n}\n","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":460607,"func":"dnNormalize(\n    slap_mask_t use,\n    Syntax *syntax,\n    MatchingRule *mr,\n    struct berval *val,\n    struct berval *out,\n    void *ctx)\n{\n\tassert( val != NULL );\n\tassert( out != NULL );\n\n\tDebug( LDAP_DEBUG_TRACE, \">>> dnNormalize: <%s>\\n\", val->bv_val ? val->bv_val : \"\", 0, 0 );\n\n\tif ( val->bv_len != 0 ) {\n\t\tLDAPDN\t\tdn = NULL;\n\t\tint\t\trc;\n\n\t\t\/*\n\t\t * Go to structural representation\n\t\t *\/\n\t\trc = ldap_bv2dn_x( val, &dn, LDAP_DN_FORMAT_LDAP, ctx );\n\t\tif ( rc != LDAP_SUCCESS ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\tassert( strlen( val->bv_val ) == val->bv_len );\n\n\t\t\/*\n\t\t * Schema-aware rewrite\n\t\t *\/\n\t\tif ( LDAPDN_rewrite( dn, 0, ctx ) != LDAP_SUCCESS ) {\n\t\t\tldap_dnfree_x( dn, ctx );\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\t\/*\n\t\t * Back to string representation\n\t\t *\/\n\t\trc = ldap_dn2bv_x( dn, out,\n\t\t\tLDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx );\n\n\t\tldap_dnfree_x( dn, ctx );\n\n\t\tif ( rc != LDAP_SUCCESS ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t} else {\n\t\tber_dupbv_x( out, val, ctx );\n\t}\n\n\tDebug( LDAP_DEBUG_TRACE, \"<<< dnNormalize: <%s>\\n\", out->bv_val ? out->bv_val : \"\", 0, 0 );\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":497564,"func":"sc_oberthur_get_certificate_authority(struct sc_pkcs15_der *der, int *out_authority)\n{\n#ifdef ENABLE_OPENSSL\n\tX509\t*x;\n\tBUF_MEM buf_mem;\n\tBIO *bio = NULL;\n\tBASIC_CONSTRAINTS *bs = NULL;\n\n\tif (!der)\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\n\tbuf_mem.data = malloc(der->len);\n\tif (!buf_mem.data)\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\n\tmemcpy(buf_mem.data, der->value, der->len);\n\tbuf_mem.max = buf_mem.length = der->len;\n\n\tbio = BIO_new(BIO_s_mem());\n\tif (!bio) {\n\t\tfree(buf_mem.data);\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\t}\n\n\tBIO_set_mem_buf(bio, &buf_mem, BIO_NOCLOSE);\n\tx = d2i_X509_bio(bio, 0);\n\tfree(buf_mem.data);\n\tBIO_free(bio);\n\tif (!x)\n\t\treturn SC_ERROR_INVALID_DATA;\n\n\tbs = (BASIC_CONSTRAINTS *)X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL);\n\tif (out_authority)\n\t\t*out_authority = (bs && bs->ca);\n\n\tX509_free(x);\n\n\treturn SC_SUCCESS;\n#else\n\treturn SC_ERROR_NOT_SUPPORTED;\n#endif\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":49052,"func":"static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    int ret = 0;\n    int length = 0;\n    uint64_t original_size;\n    if (c->fc->nb_streams >= 1) {\n        AVCodecParameters *par = c->fc->streams[c->fc->nb_streams-1]->codecpar;\n        if (par->codec_id == AV_CODEC_ID_H264)\n            return 0;\n        if (atom.size == 16) {\n            original_size = par->extradata_size;\n            ret = mov_realloc_extradata(par, atom);\n            if (!ret) {\n                length =  mov_read_atom_into_extradata(c, pb, atom, par, par->extradata + original_size);\n                if (length == atom.size) {\n                    const uint8_t range_value = par->extradata[original_size + 19];\n                    switch (range_value) {\n                    case 1:\n                        par->color_range = AVCOL_RANGE_MPEG;\n                        break;\n                    case 2:\n                        par->color_range = AVCOL_RANGE_JPEG;\n                        break;\n                    default:\n                        av_log(c, AV_LOG_WARNING, \"ignored unknown aclr value (%d)\\n\", range_value);\n                        break;\n                    }\n                    ff_dlog(c, \"color_range: %d\\n\", par->color_range);\n                } else {\n                  \/* For some reason the whole atom was not added to the extradata *\/\n                  av_log(c, AV_LOG_ERROR, \"aclr not decoded - incomplete atom\\n\");\n                }\n            } else {\n                av_log(c, AV_LOG_ERROR, \"aclr not decoded - unable to add atom to extradata\\n\");\n            }\n        } else {\n            av_log(c, AV_LOG_WARNING, \"aclr not decoded - unexpected size %\"PRId64\"\\n\", atom.size);\n        }\n    }\n\n    return ret;\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":88199,"func":"static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request)\n{\n\tstruct inode *inode = state->inode;\n\tstruct nfs_server *server = NFS_SERVER(inode);\n\tstruct nfs_client *clp = server->nfs_client;\n\tstruct nfs_lockt_args arg = {\n\t\t.fh = NFS_FH(inode),\n\t\t.fl = request,\n\t};\n\tstruct nfs_lockt_res res = {\n\t\t.denied = request,\n\t};\n\tstruct rpc_message msg = {\n\t\t.rpc_proc\t= &nfs4_procedures[NFSPROC4_CLNT_LOCKT],\n\t\t.rpc_argp       = &arg,\n\t\t.rpc_resp       = &res,\n\t\t.rpc_cred\t= state->owner->so_cred,\n\t};\n\tstruct nfs4_lock_state *lsp;\n\tint status;\n\n\targ.lock_owner.clientid = clp->cl_clientid;\n\tstatus = nfs4_set_lock_state(state, request);\n\tif (status != 0)\n\t\tgoto out;\n\tlsp = request->fl_u.nfs4_fl.owner;\n\targ.lock_owner.id = lsp->ls_id.id;\n\targ.lock_owner.s_dev = server->s_dev;\n\tstatus = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);\n\tswitch (status) {\n\t\tcase 0:\n\t\t\trequest->fl_type = F_UNLCK;\n\t\t\tbreak;\n\t\tcase -NFS4ERR_DENIED:\n\t\t\tstatus = 0;\n\t}\n\trequest->fl_ops->fl_release_private(request);\nout:\n\treturn status;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":52646,"func":"static void ib_uverbs_add_one(struct ib_device *device)\n{\n\tint devnum;\n\tdev_t base;\n\tstruct ib_uverbs_device *uverbs_dev;\n\tint ret;\n\n\tif (!device->ops.alloc_ucontext)\n\t\treturn;\n\n\tuverbs_dev = kzalloc(sizeof(*uverbs_dev), GFP_KERNEL);\n\tif (!uverbs_dev)\n\t\treturn;\n\n\tret = init_srcu_struct(&uverbs_dev->disassociate_srcu);\n\tif (ret) {\n\t\tkfree(uverbs_dev);\n\t\treturn;\n\t}\n\n\tdevice_initialize(&uverbs_dev->dev);\n\tuverbs_dev->dev.class = uverbs_class;\n\tuverbs_dev->dev.parent = device->dev.parent;\n\tuverbs_dev->dev.release = ib_uverbs_release_dev;\n\tuverbs_dev->groups[0] = &dev_attr_group;\n\tuverbs_dev->dev.groups = uverbs_dev->groups;\n\tatomic_set(&uverbs_dev->refcount, 1);\n\tinit_completion(&uverbs_dev->comp);\n\tuverbs_dev->xrcd_tree = RB_ROOT;\n\tmutex_init(&uverbs_dev->xrcd_tree_mutex);\n\tmutex_init(&uverbs_dev->lists_mutex);\n\tINIT_LIST_HEAD(&uverbs_dev->uverbs_file_list);\n\tINIT_LIST_HEAD(&uverbs_dev->uverbs_events_file_list);\n\trcu_assign_pointer(uverbs_dev->ib_dev, device);\n\tuverbs_dev->num_comp_vectors = device->num_comp_vectors;\n\n\tdevnum = ida_alloc_max(&uverbs_ida, IB_UVERBS_MAX_DEVICES - 1,\n\t\t\t       GFP_KERNEL);\n\tif (devnum < 0)\n\t\tgoto err;\n\tuverbs_dev->devnum = devnum;\n\tif (devnum >= IB_UVERBS_NUM_FIXED_MINOR)\n\t\tbase = dynamic_uverbs_dev + devnum - IB_UVERBS_NUM_FIXED_MINOR;\n\telse\n\t\tbase = IB_UVERBS_BASE_DEV + devnum;\n\n\tif (ib_uverbs_create_uapi(device, uverbs_dev))\n\t\tgoto err_uapi;\n\n\tuverbs_dev->dev.devt = base;\n\tdev_set_name(&uverbs_dev->dev, \"uverbs%d\", uverbs_dev->devnum);\n\n\tcdev_init(&uverbs_dev->cdev,\n\t\t  device->ops.mmap ? &uverbs_mmap_fops : &uverbs_fops);\n\tuverbs_dev->cdev.owner = THIS_MODULE;\n\n\tret = cdev_device_add(&uverbs_dev->cdev, &uverbs_dev->dev);\n\tif (ret)\n\t\tgoto err_uapi;\n\n\tib_set_client_data(device, &uverbs_client, uverbs_dev);\n\treturn;\n\nerr_uapi:\n\tida_free(&uverbs_ida, devnum);\nerr:\n\tif (atomic_dec_and_test(&uverbs_dev->refcount))\n\t\tib_uverbs_comp_dev(uverbs_dev);\n\twait_for_completion(&uverbs_dev->comp);\n\tput_device(&uverbs_dev->dev);\n\treturn;\n}","target":0,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":330842,"func":"int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){\n\n    AVInputFormat *avif= s->iformat;\n\n    int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;\n\n    int64_t ts_min, ts_max, ts;\n\n    int index;\n\n    AVStream *st;\n\n\n\n    if (stream_index < 0)\n\n        return -1;\n\n\n\n#ifdef DEBUG_SEEK\n\n    av_log(s, AV_LOG_DEBUG, \"read_seek: %d %\"PRId64\"\\n\", stream_index, target_ts);\n\n#endif\n\n\n\n    ts_max=\n\n    ts_min= AV_NOPTS_VALUE;\n\n    pos_limit= -1; \/\/gcc falsely says it may be uninitialized\n\n\n\n    st= s->streams[stream_index];\n\n    if(st->index_entries){\n\n        AVIndexEntry *e;\n\n\n\n        index= av_index_search_timestamp(st, target_ts, flags | AVSEEK_FLAG_BACKWARD); \/\/FIXME whole func must be checked for non-keyframe entries in index case, especially read_timestamp()\n\n        index= FFMAX(index, 0);\n\n        e= &st->index_entries[index];\n\n\n\n        if(e->timestamp <= target_ts || e->pos == e->min_distance){\n\n            pos_min= e->pos;\n\n            ts_min= e->timestamp;\n\n#ifdef DEBUG_SEEK\n\n            av_log(s, AV_LOG_DEBUG, \"using cached pos_min=0x%\"PRIx64\" dts_min=%\"PRId64\"\\n\",\n\n                   pos_min,ts_min);\n\n#endif\n\n        }else{\n\n            assert(index==0);\n\n        }\n\n\n\n        index= av_index_search_timestamp(st, target_ts, flags & ~AVSEEK_FLAG_BACKWARD);\n\n        assert(index < st->nb_index_entries);\n\n        if(index >= 0){\n\n            e= &st->index_entries[index];\n\n            assert(e->timestamp >= target_ts);\n\n            pos_max= e->pos;\n\n            ts_max= e->timestamp;\n\n            pos_limit= pos_max - e->min_distance;\n\n#ifdef DEBUG_SEEK\n\n            av_log(s, AV_LOG_DEBUG, \"using cached pos_max=0x%\"PRIx64\" pos_limit=0x%\"PRIx64\" dts_max=%\"PRId64\"\\n\",\n\n                   pos_max,pos_limit, ts_max);\n\n#endif\n\n        }\n\n    }\n\n\n\n    pos= av_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp);\n\n    if(pos<0)\n\n        return -1;\n\n\n\n    \/* do the seek *\/\n\n    url_fseek(s->pb, pos, SEEK_SET);\n\n\n\n    av_update_cur_dts(s, st, ts);\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":458310,"func":"parse_nsh(const void **datap, size_t *sizep, struct ovs_key_nsh *key)\n{\n    const struct nsh_hdr *nsh = (const struct nsh_hdr *) *datap;\n    uint8_t version, length, flags, ttl;\n\n    \/* Check if it is long enough for NSH header, doesn't support\n     * MD type 2 yet\n     *\/\n    if (OVS_UNLIKELY(*sizep < NSH_BASE_HDR_LEN)) {\n        return false;\n    }\n\n    version = nsh_get_ver(nsh);\n    flags = nsh_get_flags(nsh);\n    length = nsh_hdr_len(nsh);\n    ttl = nsh_get_ttl(nsh);\n\n    if (OVS_UNLIKELY(length > *sizep || version != 0)) {\n        return false;\n    }\n\n    key->flags = flags;\n    key->ttl = ttl;\n    key->mdtype = nsh->md_type;\n    key->np = nsh->next_proto;\n    key->path_hdr = nsh_get_path_hdr(nsh);\n\n    switch (key->mdtype) {\n        case NSH_M_TYPE1:\n            if (length != NSH_M_TYPE1_LEN) {\n                return false;\n            }\n            for (size_t i = 0; i < 4; i++) {\n                key->context[i] = get_16aligned_be32(&nsh->md1.context[i]);\n            }\n            break;\n        case NSH_M_TYPE2:\n            \/* Don't support MD type 2 metedata parsing yet *\/\n            if (length < NSH_BASE_HDR_LEN) {\n                return false;\n            }\n\n            memset(key->context, 0, sizeof(key->context));\n            break;\n        default:\n            \/* We don't parse other context headers yet. *\/\n            memset(key->context, 0, sizeof(key->context));\n            break;\n    }\n\n    data_pull(datap, sizep, length);\n\n    return true;\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":467785,"func":"static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)\n{\n\tunsigned long cons_pos, prod_pos, new_prod_pos, flags;\n\tu32 len, pg_off;\n\tstruct bpf_ringbuf_hdr *hdr;\n\n\tif (unlikely(size > RINGBUF_MAX_RECORD_SZ))\n\t\treturn NULL;\n\n\tlen = round_up(size + BPF_RINGBUF_HDR_SZ, 8);\n\tif (len > rb->mask + 1)\n\t\treturn NULL;\n\n\tcons_pos = smp_load_acquire(&rb->consumer_pos);\n\n\tif (in_nmi()) {\n\t\tif (!spin_trylock_irqsave(&rb->spinlock, flags))\n\t\t\treturn NULL;\n\t} else {\n\t\tspin_lock_irqsave(&rb->spinlock, flags);\n\t}\n\n\tprod_pos = rb->producer_pos;\n\tnew_prod_pos = prod_pos + len;\n\n\t\/* check for out of ringbuf space by ensuring producer position\n\t * doesn't advance more than (ringbuf_size - 1) ahead\n\t *\/\n\tif (new_prod_pos - cons_pos > rb->mask) {\n\t\tspin_unlock_irqrestore(&rb->spinlock, flags);\n\t\treturn NULL;\n\t}\n\n\thdr = (void *)rb->data + (prod_pos & rb->mask);\n\tpg_off = bpf_ringbuf_rec_pg_off(rb, hdr);\n\thdr->len = size | BPF_RINGBUF_BUSY_BIT;\n\thdr->pg_off = pg_off;\n\n\t\/* pairs with consumer's smp_load_acquire() *\/\n\tsmp_store_release(&rb->producer_pos, new_prod_pos);\n\n\tspin_unlock_irqrestore(&rb->spinlock, flags);\n\n\treturn (void *)hdr + BPF_RINGBUF_HDR_SZ;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":141236,"func":"int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,\n\t\tfmode_t mode, unsigned int cmd, unsigned long arg)\n{\n\tvoid __user *argp = (void __user *)arg;\n\tint ret;\n\n\t\/*\n\t * Try the generic SCSI command ioctl's first.\n\t *\/\n\tret = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);\n\tif (ret != -ENOTTY)\n\t\treturn ret;\n\n\tswitch (cmd) {\n\tcase CDROMMULTISESSION:\n\t\treturn cdrom_ioctl_multisession(cdi, argp);\n\tcase CDROMEJECT:\n\t\treturn cdrom_ioctl_eject(cdi);\n\tcase CDROMCLOSETRAY:\n\t\treturn cdrom_ioctl_closetray(cdi);\n\tcase CDROMEJECT_SW:\n\t\treturn cdrom_ioctl_eject_sw(cdi, arg);\n\tcase CDROM_MEDIA_CHANGED:\n\t\treturn cdrom_ioctl_media_changed(cdi, arg);\n\tcase CDROM_SET_OPTIONS:\n\t\treturn cdrom_ioctl_set_options(cdi, arg);\n\tcase CDROM_CLEAR_OPTIONS:\n\t\treturn cdrom_ioctl_clear_options(cdi, arg);\n\tcase CDROM_SELECT_SPEED:\n\t\treturn cdrom_ioctl_select_speed(cdi, arg);\n\tcase CDROM_SELECT_DISC:\n\t\treturn cdrom_ioctl_select_disc(cdi, arg);\n\tcase CDROMRESET:\n\t\treturn cdrom_ioctl_reset(cdi, bdev);\n\tcase CDROM_LOCKDOOR:\n\t\treturn cdrom_ioctl_lock_door(cdi, arg);\n\tcase CDROM_DEBUG:\n\t\treturn cdrom_ioctl_debug(cdi, arg);\n\tcase CDROM_GET_CAPABILITY:\n\t\treturn cdrom_ioctl_get_capability(cdi);\n\tcase CDROM_GET_MCN:\n\t\treturn cdrom_ioctl_get_mcn(cdi, argp);\n\tcase CDROM_DRIVE_STATUS:\n\t\treturn cdrom_ioctl_drive_status(cdi, arg);\n\tcase CDROM_DISC_STATUS:\n\t\treturn cdrom_ioctl_disc_status(cdi);\n\tcase CDROM_CHANGER_NSLOTS:\n\t\treturn cdrom_ioctl_changer_nslots(cdi);\n\t}\n\n\t\/*\n\t * Use the ioctls that are implemented through the generic_packet()\n\t * interface. this may look at bit funny, but if -ENOTTY is\n\t * returned that particular ioctl is not implemented and we\n\t * let it go through the device specific ones.\n\t *\/\n\tif (CDROM_CAN(CDC_GENERIC_PACKET)) {\n\t\tret = mmc_ioctl(cdi, cmd, arg);\n\t\tif (ret != -ENOTTY)\n\t\t\treturn ret;\n\t}\n\n\t\/*\n\t * Note: most of the cd_dbg() calls are commented out here,\n\t * because they fill up the sys log when CD players poll\n\t * the drive.\n\t *\/\n\tswitch (cmd) {\n\tcase CDROMSUBCHNL:\n\t\treturn cdrom_ioctl_get_subchnl(cdi, argp);\n\tcase CDROMREADTOCHDR:\n\t\treturn cdrom_ioctl_read_tochdr(cdi, argp);\n\tcase CDROMREADTOCENTRY:\n\t\treturn cdrom_ioctl_read_tocentry(cdi, argp);\n\tcase CDROMPLAYMSF:\n\t\treturn cdrom_ioctl_play_msf(cdi, argp);\n\tcase CDROMPLAYTRKIND:\n\t\treturn cdrom_ioctl_play_trkind(cdi, argp);\n\tcase CDROMVOLCTRL:\n\t\treturn cdrom_ioctl_volctrl(cdi, argp);\n\tcase CDROMVOLREAD:\n\t\treturn cdrom_ioctl_volread(cdi, argp);\n\tcase CDROMSTART:\n\tcase CDROMSTOP:\n\tcase CDROMPAUSE:\n\tcase CDROMRESUME:\n\t\treturn cdrom_ioctl_audioctl(cdi, cmd);\n\t}\n\n\treturn -ENOSYS;\n}","target":0,"code_token_length":752,"total_token_length":988,"max_tokens_setting":1024}
+{"idx":63041,"func":"  (flatpak_dir_log) (FlatpakDir * self,\n                     const char *file,\n                     int line,\n                     const char *func,\n                     const char *source, \/* overrides self->name *\/\n                     const char *change,\n                     const char *remote,\n                     const char *ref,\n                     const char *commit,\n                     const char *old_commit,\n                     const char *url,\n                     const char *format,\n                     ...)\n{\n#ifdef HAVE_LIBSYSTEMD\n  const char *installation = source ? source : flatpak_dir_get_name_cached (self);\n  pid_t source_pid = flatpak_dir_get_source_pid (self);\n  char message[1024];\n  int len;\n  va_list args;\n\n  len = g_snprintf (message, sizeof (message), \"%s: \", installation);\n\n  va_start (args, format);\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wformat-nonliteral\"\n  g_vsnprintf (message + len, sizeof (message) - len, format, args);\n#pragma GCC diagnostic pop\n\n  va_end (args);\n\n  \/* See systemd.journal-fields(7) for the meaning of the\n   * standard fields we use, in particular OBJECT_PID\n   *\/\n  sd_journal_send (\"MESSAGE_ID=\" FLATPAK_MESSAGE_ID,\n                   \"PRIORITY=5\",\n                   \"OBJECT_PID=%d\", source_pid,\n                   \"CODE_FILE=%s\", file,\n                   \"CODE_LINE=%d\", line,\n                   \"CODE_FUNC=%s\", func,\n                   \"MESSAGE=%s\", message,\n                   \/* custom fields below *\/\n                   \"FLATPAK_VERSION=\" PACKAGE_VERSION,\n                   \"INSTALLATION=%s\", installation,\n                   \"OPERATION=%s\", change,\n                   \"REMOTE=%s\", remote ? remote : \"\",\n                   \"REF=%s\", ref ? ref : \"\",\n                   \"COMMIT=%s\", commit ? commit : \"\",\n                   \"OLD_COMMIT=%s\", old_commit ? old_commit : \"\",\n                   \"URL=%s\", url ? url : \"\",\n                   NULL);\n#endif\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":76086,"func":"static bool __stratum_send(struct pool *pool, char *s, ssize_t len)\n{\n\tSOCKETTYPE sock = pool->sock;\n\tssize_t ssent = 0;\n\n\tif (opt_protocol)\n\t\tapplog(LOG_DEBUG, \"SEND: %s\", s);\n\n\tstrcat(s, \"\\n\");\n\tlen++;\n\n\twhile (len > 0 ) {\n\t\tstruct timeval timeout = {0, 0};\n\t\tssize_t sent;\n\t\tfd_set wd;\n\n\t\tFD_ZERO(&wd);\n\t\tFD_SET(sock, &wd);\n\t\tif (select(sock + 1, NULL, &wd, NULL, &timeout) < 1) {\n\t\t\tapplog(LOG_DEBUG, \"Write select failed on pool %d sock\", pool->pool_no);\n\t\t\treturn false;\n\t\t}\n\t\tsent = send(pool->sock, s + ssent, len, 0);\n\t\tif (sent < 0) {\n\t\t\tif (errno != EAGAIN && errno != EWOULDBLOCK) {\n\t\t\t\tapplog(LOG_DEBUG, \"Failed to curl_easy_send in stratum_send\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsent = 0;\n\t\t}\n\t\tssent += sent;\n\t\tlen -= sent;\n\t}\n\n\tpool->cgminer_pool_stats.times_sent++;\n\tpool->cgminer_pool_stats.bytes_sent += ssent;\n\ttotal_bytes_xfer += ssent;\n\tpool->cgminer_pool_stats.net_bytes_sent += ssent;\n\treturn true;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":28123,"func":"static void clear_codec_buffers ( WmallDecodeCtx * s ) {\n int ich , ilms ;\n memset ( s -> acfilter_coeffs , 0 , sizeof ( s -> acfilter_coeffs ) ) ;\n memset ( s -> acfilter_prevvalues , 0 , sizeof ( s -> acfilter_prevvalues ) ) ;\n memset ( s -> lpc_coefs , 0 , sizeof ( s -> lpc_coefs ) ) ;\n memset ( s -> mclms_coeffs , 0 , sizeof ( s -> mclms_coeffs ) ) ;\n memset ( s -> mclms_coeffs_cur , 0 , sizeof ( s -> mclms_coeffs_cur ) ) ;\n memset ( s -> mclms_prevvalues , 0 , sizeof ( s -> mclms_prevvalues ) ) ;\n memset ( s -> mclms_updates , 0 , sizeof ( s -> mclms_updates ) ) ;\n for ( ich = 0 ;\n ich < s -> num_channels ;\n ich ++ ) {\n for ( ilms = 0 ;\n ilms < s -> cdlms_ttl [ ich ] ;\n ilms ++ ) {\n memset ( s -> cdlms [ ich ] [ ilms ] . coefs , 0 , sizeof ( s -> cdlms [ ich ] [ ilms ] . coefs ) ) ;\n memset ( s -> cdlms [ ich ] [ ilms ] . lms_prevvalues , 0 , sizeof ( s -> cdlms [ ich ] [ ilms ] . lms_prevvalues ) ) ;\n memset ( s -> cdlms [ ich ] [ ilms ] . lms_updates , 0 , sizeof ( s -> cdlms [ ich ] [ ilms ] . lms_updates ) ) ;\n }\n s -> ave_sum [ ich ] = 0 ;\n }\n }","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":190887,"func":"channel_register_fds(Channel *c, int rfd, int wfd, int efd,\n    int extusage, int nonblock, int is_tty)\n{\n\t\/* Update the maximum file descriptor value. *\/\n\tchannel_max_fd = MAX(channel_max_fd, rfd);\n\tchannel_max_fd = MAX(channel_max_fd, wfd);\n\tchannel_max_fd = MAX(channel_max_fd, efd);\n\n\tif (rfd != -1)\n\t\tfcntl(rfd, F_SETFD, FD_CLOEXEC);\n\tif (wfd != -1 && wfd != rfd)\n\t\tfcntl(wfd, F_SETFD, FD_CLOEXEC);\n\tif (efd != -1 && efd != rfd && efd != wfd)\n\t\tfcntl(efd, F_SETFD, FD_CLOEXEC);\n\n\tc->rfd = rfd;\n\tc->wfd = wfd;\n\tc->sock = (rfd == wfd) ? rfd : -1;\n\tc->efd = efd;\n\tc->extended_usage = extusage;\n\n\tif ((c->isatty = is_tty) != 0)\n\t\tdebug2(\"channel %d: rfd %d isatty\", c->self, c->rfd);\n#ifdef _AIX\n\t\/* XXX: Later AIX versions can't push as much data to tty *\/\n\tc->wfd_isatty = is_tty || isatty(c->wfd);\n#endif\n\n\t\/* enable nonblocking mode *\/\n\tif (nonblock) {\n\t\tif (rfd != -1)\n\t\t\tset_nonblock(rfd);\n\t\tif (wfd != -1)\n\t\t\tset_nonblock(wfd);\n\t\tif (efd != -1)\n\t\t\tset_nonblock(efd);\n\t}\n}\n","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":304398,"func":"static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,\n\t\t\t       struct cfg80211_chan_def *ch)\n{\n\tstruct brcmu_chan ch_inf;\n\ts32 primary_offset;\n\n\tbrcmf_dbg(TRACE, \"chandef: control %d center %d width %d\\n\",\n\t\t  ch->chan->center_freq, ch->center_freq1, ch->width);\n\tch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq1);\n\tprimary_offset = ch->chan->center_freq - ch->center_freq1;\n\tswitch (ch->width) {\n\tcase NL80211_CHAN_WIDTH_20:\n\tcase NL80211_CHAN_WIDTH_20_NOHT:\n\t\tch_inf.bw = BRCMU_CHAN_BW_20;\n\t\tWARN_ON(primary_offset != 0);\n\t\tbreak;\n\tcase NL80211_CHAN_WIDTH_40:\n\t\tch_inf.bw = BRCMU_CHAN_BW_40;\n\t\tif (primary_offset > 0)\n\t\t\tch_inf.sb = BRCMU_CHAN_SB_U;\n\t\telse\n\t\t\tch_inf.sb = BRCMU_CHAN_SB_L;\n\t\tbreak;\n\tcase NL80211_CHAN_WIDTH_80:\n\t\tch_inf.bw = BRCMU_CHAN_BW_80;\n\t\tif (primary_offset == -30)\n\t\t\tch_inf.sb = BRCMU_CHAN_SB_LL;\n\t\telse if (primary_offset == -10)\n\t\t\tch_inf.sb = BRCMU_CHAN_SB_LU;\n\t\telse if (primary_offset == 10)\n\t\t\tch_inf.sb = BRCMU_CHAN_SB_UL;\n\t\telse\n\t\t\tch_inf.sb = BRCMU_CHAN_SB_UU;\n\t\tbreak;\n\tcase NL80211_CHAN_WIDTH_80P80:\n\tcase NL80211_CHAN_WIDTH_160:\n\tcase NL80211_CHAN_WIDTH_5:\n\tcase NL80211_CHAN_WIDTH_10:\n\tdefault:\n\t\tWARN_ON_ONCE(1);\n\t}\n\tswitch (ch->chan->band) {\n\tcase NL80211_BAND_2GHZ:\n\t\tch_inf.band = BRCMU_CHAN_BAND_2G;\n\t\tbreak;\n\tcase NL80211_BAND_5GHZ:\n\t\tch_inf.band = BRCMU_CHAN_BAND_5G;\n\t\tbreak;\n\tcase NL80211_BAND_60GHZ:\n\tdefault:\n\t\tWARN_ON_ONCE(1);\n\t}\n\td11inf->encchspec(&ch_inf);\n\n\treturn ch_inf.chspec;\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":338902,"func":"static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end)\n\n{\n\n    int pal_start, pal_count, i, ret;\n\n\n\n    if(buf_end - buf < 16) {\n\n        av_log(s->avctx, AV_LOG_WARNING, \"truncated header\\n\");\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    s->width  = AV_RL16(&buf[4]);\n\n    s->height = AV_RL16(&buf[6]);\n\n\n\n    ret = ff_set_dimensions(s->avctx, s->width, s->height);\n\n    if (ret < 0)\n\n        return ret;\n\n\n\n    s->avctx->time_base.num = 1;\n\n    s->avctx->time_base.den = AV_RL16(&buf[10]);\n\n\n\n    pal_start = AV_RL16(&buf[12]);\n\n    pal_count = AV_RL16(&buf[14]);\n\n\n\n    buf += 16;\n\n    for (i=pal_start; i<pal_start+pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) {\n\n        s->palette[i] = AV_RB24(buf);\n\n        buf += 3;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":270870,"func":"static void caif_ctrl_cb(struct cflayer *layr,\n\t\t\t\tenum caif_ctrlcmd flow,\n\t\t\t\tint phyid)\n{\n\tstruct caifsock *cf_sk = container_of(layr, struct caifsock, layer);\n\tswitch (flow) {\n\tcase CAIF_CTRLCMD_FLOW_ON_IND:\n\t\t\/* OK from modem to start sending again *\/\n\t\tset_tx_flow_on(cf_sk);\n\t\tcf_sk->sk.sk_state_change(&cf_sk->sk);\n\t\tbreak;\n\n\tcase CAIF_CTRLCMD_FLOW_OFF_IND:\n\t\t\/* Modem asks us to shut up *\/\n\t\tset_tx_flow_off(cf_sk);\n\t\tcf_sk->sk.sk_state_change(&cf_sk->sk);\n\t\tbreak;\n\n\tcase CAIF_CTRLCMD_INIT_RSP:\n\t\t\/* We're now connected *\/\n\t\tcaif_client_register_refcnt(&cf_sk->layer,\n\t\t\t\t\t\tcfsk_hold, cfsk_put);\n\t\tcf_sk->sk.sk_state = CAIF_CONNECTED;\n\t\tset_tx_flow_on(cf_sk);\n\t\tcf_sk->sk.sk_shutdown = 0;\n\t\tcf_sk->sk.sk_state_change(&cf_sk->sk);\n\t\tbreak;\n\n\tcase CAIF_CTRLCMD_DEINIT_RSP:\n\t\t\/* We're now disconnected *\/\n\t\tcf_sk->sk.sk_state = CAIF_DISCONNECTED;\n\t\tcf_sk->sk.sk_state_change(&cf_sk->sk);\n\t\tbreak;\n\n\tcase CAIF_CTRLCMD_INIT_FAIL_RSP:\n\t\t\/* Connect request failed *\/\n\t\tcf_sk->sk.sk_err = ECONNREFUSED;\n\t\tcf_sk->sk.sk_state = CAIF_DISCONNECTED;\n\t\tcf_sk->sk.sk_shutdown = SHUTDOWN_MASK;\n\t\t\/*\n\t\t * Socket \"standards\" seems to require POLLOUT to\n\t\t * be set at connect failure.\n\t\t *\/\n\t\tset_tx_flow_on(cf_sk);\n\t\tcf_sk->sk.sk_state_change(&cf_sk->sk);\n\t\tbreak;\n\n\tcase CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND:\n\t\t\/* Modem has closed this connection, or device is down. *\/\n\t\tcf_sk->sk.sk_shutdown = SHUTDOWN_MASK;\n\t\tcf_sk->sk.sk_err = ECONNRESET;\n\t\tset_rx_flow_on(cf_sk);\n\t\tcf_sk->sk.sk_error_report(&cf_sk->sk);\n\t\tbreak;\n\n\tdefault:\n\t\tpr_debug(\"Unexpected flow command %d\\n\", flow);\n\t}\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":381484,"func":"my_strusage( int level )\n{\n  static char *digests, *pubkeys, *ciphers;\n  static char *ver_gcry, *ver_ksba;\n  const char *p;\n\n  switch (level)\n    {\n    case 11: p = \"@GPGSM@ (@GNUPG@)\";\n      break;\n    case 13: p = VERSION; break;\n    case 17: p = PRINTABLE_OS_NAME; break;\n    case 19: p = _(\"Please report bugs to <@EMAIL@>.\\n\"); break;\n\n    case 1:\n    case 40: p = _(\"Usage: @GPGSM@ [options] [files] (-h for help)\");\n      break;\n    case 41:\n      p = _(\"Syntax: @GPGSM@ [options] [files]\\n\"\n            \"Sign, check, encrypt or decrypt using the S\/MIME protocol\\n\"\n            \"Default operation depends on the input data\\n\");\n      break;\n\n    case 20:\n      if (!ver_gcry)\n        ver_gcry = make_libversion (\"libgcrypt\", gcry_check_version);\n      p = ver_gcry;\n      break;\n    case 21:\n      if (!ver_ksba)\n        ver_ksba = make_libversion (\"libksba\", ksba_check_version);\n      p = ver_ksba;\n      break;\n\n    case 31: p = \"\\nHome: \"; break;\n    case 32: p = opt.homedir; break;\n    case 33: p = _(\"\\nSupported algorithms:\\n\"); break;\n    case 34:\n      if (!ciphers)\n        ciphers = build_list (\"Cipher: \", gnupg_cipher_algo_name,\n                              our_cipher_test_algo );\n      p = ciphers;\n      break;\n    case 35:\n      if (!pubkeys)\n        pubkeys = build_list (\"Pubkey: \", gcry_pk_algo_name,\n                              our_pk_test_algo );\n      p = pubkeys;\n      break;\n    case 36:\n      if (!digests)\n        digests = build_list(\"Hash: \", gcry_md_algo_name, our_md_test_algo );\n      p = digests;\n      break;\n\n    default: p = NULL; break;\n    }\n  return p;\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":11989,"func":"BrowserActionsContainer::BrowserActionsContainer(\n    Profile* profile, ToolbarView* toolbar)\n    : profile_(profile),\n       toolbar_(toolbar),\n       popup_(NULL),\n       popup_button_(NULL),\n      model_(NULL),\n       resize_gripper_(NULL),\n       chevron_(NULL),\n       suppress_chevron_(false),\n       resize_amount_(0),\n       animation_target_size_(0),\n       ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {\n  SetID(VIEW_ID_BROWSER_ACTION_TOOLBAR);\n   ExtensionsService* extension_service = profile->GetExtensionsService();\n   if (!extension_service)  \/\/ The |extension_service| can be NULL in Incognito.\n     return;\n \n   registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE,\n                  Source<Profile>(profile_));\n \n  model_ = extension_service->toolbar_model();\n  model_->AddObserver(this);\n   resize_animation_.reset(new SlideAnimation(this));\n   resize_gripper_ = new views::ResizeGripper(this);\n   resize_gripper_->SetVisible(false);\n   AddChildView(resize_gripper_);\n\n  ResourceBundle& rb = ResourceBundle::GetSharedInstance();\n  SkBitmap* chevron_image = rb.GetBitmapNamed(IDR_BOOKMARK_BAR_CHEVRONS);\n  chevron_ = new views::MenuButton(NULL, std::wstring(), this, false);\n  chevron_->SetVisible(false);\n  chevron_->SetIcon(*chevron_image);\n  chevron_->EnableCanvasFlippingForRTLUI(true);\n  AddChildView(chevron_);\n\n   int predefined_width =\n       profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth);\n   container_size_ = gfx::Size(predefined_width, kButtonSize);\n }\n","target":1,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":189367,"func":"ZEND_API const char* zend_resolve_method_name(zend_class_entry *ce, zend_function *f) \/* {{{ *\/\n{\n\tzend_function *func;\n\tHashPosition iterator;\n\tHashTable *function_table;\n\n\tif (f->common.type != ZEND_USER_FUNCTION ||\n\t    *(f->op_array.refcount) < 2 ||\n\t    !f->common.scope ||\n\t    !f->common.scope->trait_aliases) {\n\t\treturn f->common.function_name;\n\t}\n\n\tfunction_table = &ce->function_table;\n\tzend_hash_internal_pointer_reset_ex(function_table, &iterator);\n\twhile (zend_hash_get_current_data_ex(function_table, (void **)&func, &iterator) == SUCCESS) {\n\t\tif (func == f) {\n\t\t\tchar *name;\n\t\t\tuint len;\n\t\t\tulong idx;\n\n\t\t\tif (zend_hash_get_current_key_ex(function_table, &name, &len, &idx, 0, &iterator) != HASH_KEY_IS_STRING) {\n\t\t\t\treturn f->common.function_name;\n\t\t\t}\n\t\t\t--len;\n\t\t\tif (len == strlen(f->common.function_name) &&\n\t\t\t    !strncasecmp(name, f->common.function_name, len)) {\n\t\t\t\treturn f->common.function_name;\n\t\t\t}\n\t\t\treturn zend_find_alias_name(f->common.scope, name, len);\n\t\t}\n\t\tzend_hash_move_forward_ex(function_table, &iterator);\n\t}\n\treturn f->common.function_name;\n}\n\/* }}} *\/\n","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":73882,"func":"static int tipc_sk_create(struct net *net, struct socket *sock,\n\t\t\t  int protocol, int kern)\n{\n\tconst struct proto_ops *ops;\n\tstruct sock *sk;\n\tstruct tipc_sock *tsk;\n\tstruct tipc_msg *msg;\n\n\t\/* Validate arguments *\/\n\tif (unlikely(protocol != 0))\n\t\treturn -EPROTONOSUPPORT;\n\n\tswitch (sock->type) {\n\tcase SOCK_STREAM:\n\t\tops = &stream_ops;\n\t\tbreak;\n\tcase SOCK_SEQPACKET:\n\t\tops = &packet_ops;\n\t\tbreak;\n\tcase SOCK_DGRAM:\n\tcase SOCK_RDM:\n\t\tops = &msg_ops;\n\t\tbreak;\n\tdefault:\n\t\treturn -EPROTOTYPE;\n\t}\n\n\t\/* Allocate socket's protocol area *\/\n\tsk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto, kern);\n\tif (sk == NULL)\n\t\treturn -ENOMEM;\n\n\ttsk = tipc_sk(sk);\n\ttsk->max_pkt = MAX_PKT_DEFAULT;\n\ttsk->maxnagle = 0;\n\ttsk->nagle_start = NAGLE_START_INIT;\n\tINIT_LIST_HEAD(&tsk->publications);\n\tINIT_LIST_HEAD(&tsk->cong_links);\n\tmsg = &tsk->phdr;\n\n\t\/* Finish initializing socket data structures *\/\n\tsock->ops = ops;\n\tsock_init_data(sock, sk);\n\ttipc_set_sk_state(sk, TIPC_OPEN);\n\tif (tipc_sk_insert(tsk)) {\n\t\tpr_warn(\"Socket create failed; port number exhausted\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t\/* Ensure tsk is visible before we read own_addr. *\/\n\tsmp_mb();\n\n\ttipc_msg_init(tipc_own_addr(net), msg, TIPC_LOW_IMPORTANCE,\n\t\t      TIPC_NAMED_MSG, NAMED_H_SIZE, 0);\n\n\tmsg_set_origport(msg, tsk->portid);\n\ttimer_setup(&sk->sk_timer, tipc_sk_timeout, 0);\n\tsk->sk_shutdown = 0;\n\tsk->sk_backlog_rcv = tipc_sk_backlog_rcv;\n\tsk->sk_rcvbuf = sysctl_tipc_rmem[1];\n\tsk->sk_data_ready = tipc_data_ready;\n\tsk->sk_write_space = tipc_write_space;\n\tsk->sk_destruct = tipc_sock_destruct;\n\ttsk->conn_timeout = CONN_TIMEOUT_DEFAULT;\n\ttsk->group_is_open = true;\n\tatomic_set(&tsk->dupl_rcvcnt, 0);\n\n\t\/* Start out with safe limits until we receive an advertised window *\/\n\ttsk->snd_win = tsk_adv_blocks(RCVBUF_MIN);\n\ttsk->rcv_win = tsk->snd_win;\n\n\tif (tipc_sk_type_connectionless(sk)) {\n\t\ttsk_set_unreturnable(tsk, true);\n\t\tif (sock->type == SOCK_DGRAM)\n\t\t\ttsk_set_unreliable(tsk, true);\n\t}\n\t__skb_queue_head_init(&tsk->mc_method.deferredq);\n\ttrace_tipc_sk_create(sk, NULL, TIPC_DUMP_NONE, \" \");\n\treturn 0;\n}","target":0,"code_token_length":638,"total_token_length":874,"max_tokens_setting":1024}
+{"idx":174481,"func":"void NetworkHandler::ContinueInterceptedRequest(\n    const std::string& interception_id,\n    Maybe<std::string> error_reason,\n    Maybe<std::string> base64_raw_response,\n    Maybe<std::string> url,\n    Maybe<std::string> method,\n    Maybe<std::string> post_data,\n    Maybe<protocol::Network::Headers> headers,\n     Maybe<protocol::Network::AuthChallengeResponse> auth_challenge_response,\n     std::unique_ptr<ContinueInterceptedRequestCallback> callback) {\n   DevToolsInterceptorController* interceptor =\n      DevToolsInterceptorController::FromBrowserContext(browser_context_);\n   if (!interceptor) {\n     callback->sendFailure(Response::InternalError());\n     return;\n  }\n\n  base::Optional<std::string> raw_response;\n  if (base64_raw_response.isJust()) {\n    std::string decoded;\n    if (!base::Base64Decode(base64_raw_response.fromJust(), &decoded)) {\n      callback->sendFailure(Response::InvalidParams(\"Invalid rawResponse.\"));\n      return;\n    }\n    raw_response = decoded;\n  }\n\n  base::Optional<net::Error> error;\n  bool mark_as_canceled = false;\n  if (error_reason.isJust()) {\n    bool ok;\n    error = NetErrorFromString(error_reason.fromJust(), &ok);\n    if (!ok) {\n      callback->sendFailure(Response::InvalidParams(\"Invalid errorReason.\"));\n      return;\n    }\n\n    mark_as_canceled = true;\n  }\n\n  interceptor->ContinueInterceptedRequest(\n      interception_id,\n      std::make_unique<DevToolsURLRequestInterceptor::Modifications>(\n          std::move(error), std::move(raw_response), std::move(url),\n          std::move(method), std::move(post_data), std::move(headers),\n          std::move(auth_challenge_response), mark_as_canceled),\n      std::move(callback));\n}\n","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":127758,"func":"generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt)\n{\n  MYSQL_RES *result;\n  MYSQL_ROW row;\n  unsigned long long counter;\n  DBUG_ENTER(\"generate_primary_key_list\");\n\n  \/* \n    Blackhole is a special case, this allows us to test the upper end \n    of the server during load runs.\n  *\/\n  if (opt_only_print || (engine_stmt && \n                         strstr(engine_stmt->string, \"blackhole\")))\n  {\n    primary_keys_number_of= 1;\n    primary_keys= (char **)my_malloc(PSI_NOT_INSTRUMENTED,\n                                     (uint)(sizeof(char *) * \n                                            primary_keys_number_of), \n                                    MYF(MY_ZEROFILL|MY_FAE|MY_WME));\n    \/* Yes, we strdup a const string to simplify the interface *\/\n    primary_keys[0]= my_strdup(PSI_NOT_INSTRUMENTED,\n                               \"796c4422-1d94-102a-9d6d-00e0812d\", MYF(0)); \n  }\n  else\n  {\n    if (run_query(mysql, \"SELECT id from t1\", strlen(\"SELECT id from t1\")))\n    {\n      fprintf(stderr,\"%s: Cannot select GUID primary keys. (%s)\\n\", my_progname,\n              mysql_error(mysql));\n      exit(1);\n    }\n\n    if (!(result= mysql_store_result(mysql)))\n    {\n      fprintf(stderr, \"%s: Error when storing result: %d %s\\n\",\n              my_progname, mysql_errno(mysql), mysql_error(mysql));\n      exit(1);\n    }\n    primary_keys_number_of= mysql_num_rows(result);\n\n    \/* So why check this? Blackhole :) *\/\n    if (primary_keys_number_of)\n    {\n      \/*\n        We create the structure and loop and create the items.\n      *\/\n      primary_keys= (char **)my_malloc(PSI_NOT_INSTRUMENTED,\n                                       (uint)(sizeof(char *) * \n                                              primary_keys_number_of), \n                                       MYF(MY_ZEROFILL|MY_FAE|MY_WME));\n      row= mysql_fetch_row(result);\n      for (counter= 0; counter < primary_keys_number_of; \n           counter++, row= mysql_fetch_row(result))\n        primary_keys[counter]= my_strdup(PSI_NOT_INSTRUMENTED,\n                                         row[0], MYF(0));\n    }\n\n    mysql_free_result(result);\n  }\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":523,"total_token_length":759,"max_tokens_setting":1024}
+{"idx":465925,"func":"BnGeneratePrimeForRSA(\n\t\t      bigNum          prime,          \/\/ IN\/OUT: points to the BN that will get the\n\t\t      \/\/  random value\n\t\t      UINT32          bits,           \/\/ IN: number of bits to get\n\t\t      UINT32          exponent,       \/\/ IN: the exponent\n\t\t      RAND_STATE      *rand           \/\/ IN: the random state\n\t\t      )\n{\n    BOOL            found = FALSE;\n    \/\/\n    \/\/ Make sure that the prime is large enough\n    pAssert(prime->allocated >= BITS_TO_CRYPT_WORDS(bits));\n    \/\/ Only try to handle specific sizes of keys in order to save overhead\n    pAssert((bits % 32) == 0);\n    \n    prime->size = BITS_TO_CRYPT_WORDS(bits);\n    \n    while(!found)\n\t{\n\t    \/\/ The change below is to make sure that all keys that are generated from the same\n\t    \/\/ seed value will be the same regardless of the endianess or word size of the CPU.\n\t    \/\/       DRBG_Generate(rand, (BYTE *)prime->d, (UINT16)BITS_TO_BYTES(bits));\/\/ old\n\t    \/\/       if(g_inFailureMode)                                                \/\/ old\n\t\/\/ libtpms changed begin\n\t    if (1) {\n\t\tDRBG_Generate(rand, (BYTE *)prime->d, (UINT16)BITS_TO_BYTES(bits));\n\t\tif (g_inFailureMode)\n\t\t    return TPM_RC_FAILURE;\n\t    } else {\n\t\tif(!BnGetRandomBits(prime, bits, rand))                              \/\/ new\n\t\t    return TPM_RC_FAILURE;\n\t    }\n\t    RsaAdjustPrimeCandidate(prime);\n\t\/\/ libtpms changed end\n\t    found = RsaCheckPrime(prime, exponent, rand) == TPM_RC_SUCCESS;\n\t}\n    return TPM_RC_SUCCESS;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":141828,"func":"\t\tvoid CWebServer::Cmd_GetPlanDevices(WebEmSession & session, const request& req, Json::Value &root)\n\t\t{\n\t\t\tstd::string idx = request::findValue(&req, \"idx\");\n\t\t\tif (idx.empty())\n\t\t\t\treturn;\n\t\t\troot[\"status\"] = \"OK\";\n\t\t\troot[\"title\"] = \"GetPlanDevices\";\n\n\t\t\tstd::vector<std::vector<std::string> > result;\n\t\t\tresult = m_sql.safe_query(\"SELECT ID, DevSceneType, DeviceRowID, [Order] FROM DeviceToPlansMap WHERE (PlanID=='%q') ORDER BY [Order]\",\n\t\t\t\tidx.c_str());\n\t\t\tif (!result.empty())\n\t\t\t{\n\t\t\t\tint ii = 0;\n\t\t\t\tfor (const auto & itt : result)\n\t\t\t\t{\n\t\t\t\t\tstd::vector<std::string> sd = itt;\n\n\t\t\t\t\tstd::string ID = sd[0];\n\t\t\t\t\tint DevSceneType = atoi(sd[1].c_str());\n\t\t\t\t\tstd::string DevSceneRowID = sd[2];\n\n\t\t\t\t\tstd::string Name = \"\";\n\t\t\t\t\tif (DevSceneType == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::vector<std::vector<std::string> > result2;\n\t\t\t\t\t\tresult2 = m_sql.safe_query(\"SELECT Name FROM DeviceStatus WHERE (ID=='%q')\",\n\t\t\t\t\t\t\tDevSceneRowID.c_str());\n\t\t\t\t\t\tif (!result2.empty())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = result2[0][0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::vector<std::vector<std::string> > result2;\n\t\t\t\t\t\tresult2 = m_sql.safe_query(\"SELECT Name FROM Scenes WHERE (ID=='%q')\",\n\t\t\t\t\t\t\tDevSceneRowID.c_str());\n\t\t\t\t\t\tif (!result2.empty())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"[Scene] \" + result2[0][0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (Name != \"\")\n\t\t\t\t\t{\n\t\t\t\t\t\troot[\"result\"][ii][\"idx\"] = ID;\n\t\t\t\t\t\troot[\"result\"][ii][\"devidx\"] = DevSceneRowID;\n\t\t\t\t\t\troot[\"result\"][ii][\"type\"] = DevSceneType;\n\t\t\t\t\t\troot[\"result\"][ii][\"DevSceneRowID\"] = DevSceneRowID;\n\t\t\t\t\t\troot[\"result\"][ii][\"order\"] = sd[3];\n\t\t\t\t\t\troot[\"result\"][ii][\"Name\"] = Name;\n\t\t\t\t\t\tii++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}","target":0,"code_token_length":500,"total_token_length":736,"max_tokens_setting":1024}
+{"idx":293333,"func":"  static const char* Helper(PyObject* obj, int depth, ConverterState* state,\n                            T** buf) {\n    if (TF_PREDICT_FALSE(obj == nullptr)) {\n      return ErrorConverting;\n    }\n\n    Safe_PyObjectPtr seq = make_safe(PySequence_Fast(obj, \"\"));\n    if (TF_PREDICT_FALSE(seq == nullptr)) return ErrorRectangular;\n\n    const int64 s = state->inferred_shape.dim_size(depth);\n    if (TF_PREDICT_FALSE(s != PySequence_Fast_GET_SIZE(seq.get()))) {\n      return ErrorRectangular;\n    }\n\n    if (state->inferred_shape.dims() - depth > 1) {\n      \/* Iterate over outer dim, and recursively convert each element. *\/\n      for (int64 i = 0; i < s; ++i) {\n        const char* error = Helper(PySequence_Fast_GET_ITEM(seq.get(), i),\n                                   depth + 1, state, buf);\n        if (TF_PREDICT_FALSE(error != nullptr)) return error;\n      }\n    } else {\n      PyObject** l = PySequence_Fast_ITEMS(seq.get());\n      for (int64 i = 0; i < s; ++i) {\n        auto scalar = ZeroDimArrayToScalar(l[i], state);\n        const char* error = ConverterTraits<T>::ConvertScalar(scalar, *buf);\n        Py_DECREF(scalar);\n        if (TF_PREDICT_FALSE(error != nullptr)) return error;\n        ++*buf;\n      }\n    }\n    return nullptr;\n  }","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":309969,"func":"void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect,\n                                            const gfx::Rect& clip_rect) {\n  if (window_rect.width() < 0  || window_rect.width() > (1<<15) ||\n      window_rect.height() < 0 || window_rect.height() > (1<<15) ||\n      window_rect.width() * window_rect.height() > (8<<20)) {\n    return;\n  }\n\n  plugin_rect_ = window_rect;\n\n  bool bitmaps_changed = false;\n\n  PluginMsg_UpdateGeometry_Param param;\n#if defined(OS_MACOSX)\n  param.ack_key = -1;\n#endif\n\n  if (windowless_) {\n    if (!backing_store_canvas_.get() ||\n        (window_rect.width() != backing_store_canvas_->getDevice()->width() ||\n         window_rect.height() != backing_store_canvas_->getDevice()->height()))\n        {\n      bitmaps_changed = true;\n\n#if defined(OS_MACOSX)\n      if (backing_store_.get()) {\n        param.ack_key = backing_store_->handle().fd;\n      }\n#endif\n\n      ResetWindowlessBitmaps();\n      if (!window_rect.IsEmpty()) {\n        if (!CreateBitmap(&backing_store_, &backing_store_canvas_) ||\n            !CreateBitmap(&transport_store_, &transport_store_canvas_) ||\n            (transparent_ &&\n             !CreateBitmap(&background_store_, &background_store_canvas_))) {\n          DCHECK(false);\n          ResetWindowlessBitmaps();\n          return;\n        }\n      }\n    }\n  }\n\n  param.window_rect = window_rect;\n  param.clip_rect = clip_rect;\n  param.windowless_buffer = TransportDIB::DefaultHandleValue();\n  param.background_buffer = TransportDIB::DefaultHandleValue();\n\n#if defined(OS_POSIX)\n  if (bitmaps_changed)\n#endif\n  {\n    if (transport_store_.get())\n      param.windowless_buffer = transport_store_->handle();\n\n    if (background_store_.get())\n      param.background_buffer = background_store_->handle();\n  }\n\n  IPC::Message* msg;\n#if defined (OS_WIN)\n  if (info_.name.find(L\"Windows Media Player\") != std::wstring::npos) {\n    msg = new PluginMsg_UpdateGeometrySync(instance_id_, param);\n  }\n  else\n#endif\n  {\n    msg = new PluginMsg_UpdateGeometry(instance_id_, param);\n    msg->set_unblock(true);\n  }\n\n  Send(msg);\n}\n","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":447939,"func":"_XimProtoDestroyIC(\n    XIC\t\t xic)\n{\n    Xic\t\t ic = (Xic)xic;\n    Xim\t \t im = (Xim)ic->core.im;\n    CARD32\t buf32[BUFSIZE\/4];\n    CARD8\t*buf = (CARD8 *)buf32;\n    CARD16\t*buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];\n    INT16\t len;\n    CARD32\t reply32[BUFSIZE\/4];\n    char\t*reply = (char *)reply32;\n    XPointer\t preply;\n    int\t\t buf_size;\n    int\t\t ret_code;\n\n    if (IS_SERVER_CONNECTED(im)) {\n\tbuf_s[0] = im->private.proto.imid;\t\t\/* imid *\/\n\tbuf_s[1] = ic->private.proto.icid;\t\t\/* icid *\/\n\n\tlen = sizeof(CARD16)\t\t\t\/* sizeof imid *\/\n\t    + sizeof(CARD16);\t\t\t\/* sizeof icid *\/\n\n\t_XimSetHeader((XPointer)buf, XIM_DESTROY_IC, 0, &len);\n\t(void)_XimWrite(im, len, (XPointer)buf);\n\t_XimFlush(im);\n\tbuf_size = BUFSIZE;\n\tret_code = _XimRead(im, &len, (XPointer)reply, buf_size,\n\t\t\t\t\t_XimDestroyICCheck, (XPointer)ic);\n\tif (ret_code == XIM_OVERFLOW) {\n\t    buf_size = len;\n\t    preply = Xmalloc(buf_size);\n\t    (void)_XimRead(im, &len, preply, buf_size,\n\t\t\t\t\t_XimDestroyICCheck, (XPointer)ic);\n\t    Xfree(preply);\n\t}\n    }\n    UNMARK_IC_CONNECTED(ic);\n    _XimUnregisterFilter(ic);\n    _XimProtoICFree(ic);\n    return;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":346206,"func":"http_splitheader(struct http *hp, int req)\n{\n\tchar *p, *q, **hh;\n\tint n;\n\tchar buf[20];\n\n\tCHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);\n\tif (req) {\n\t\tmemset(hp->req, 0, sizeof hp->req);\n\t\thh = hp->req;\n\t} else {\n\t\tmemset(hp->resp, 0, sizeof hp->resp);\n\t\thh = hp->resp;\n\t}\n\n\tn = 0;\n\tp = hp->rxbuf;\n\n\t\/* REQ\/PROTO *\/\n\twhile (vct_islws(*p))\n\t\tp++;\n\thh[n++] = p;\n\twhile (!vct_islws(*p))\n\t\tp++;\n\tassert(!vct_iscrlf(*p));\n\t*p++ = '\\0';\n\n\t\/* URL\/STATUS *\/\n\twhile (vct_issp(*p))\t\t\/* XXX: H space only *\/\n\t\tp++;\n\tassert(!vct_iscrlf(*p));\n\thh[n++] = p;\n\twhile (!vct_islws(*p))\n\t\tp++;\n\tif (vct_iscrlf(*p)) {\n\t\thh[n++] = NULL;\n\t\tq = p;\n\t\tp += vct_skipcrlf(p);\n\t\t*q = '\\0';\n\t} else {\n\t\t*p++ = '\\0';\n\t\t\/* PROTO\/MSG *\/\n\t\twhile (vct_issp(*p))\t\t\/* XXX: H space only *\/\n\t\t\tp++;\n\t\thh[n++] = p;\n\t\twhile (!vct_iscrlf(*p))\n\t\t\tp++;\n\t\tq = p;\n\t\tp += vct_skipcrlf(p);\n\t\t*q = '\\0';\n\t}\n\tassert(n == 3);\n\n\twhile (*p != '\\0') {\n\t\tassert(n < MAX_HDR);\n\t\tif (vct_iscrlf(*p))\n\t\t\tbreak;\n\t\thh[n++] = p++;\n\t\twhile (*p != '\\0' && !vct_iscrlf(*p))\n\t\t\tp++;\n\t\tq = p;\n\t\tp += vct_skipcrlf(p);\n\t\t*q = '\\0';\n\t}\n\tp += vct_skipcrlf(p);\n\tassert(*p == '\\0');\n\n\tfor (n = 0; n < 3 || hh[n] != NULL; n++) {\n\t\tsprintf(buf, \"http[%2d] \", n);\n\t\tvtc_dump(hp->vl, 4, buf, hh[n], -1);\n\t}\n}","target":1,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":210032,"func":"xsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns,\n\t         xmlNodePtr out)\n{\n\n    if (ns == NULL)\n\treturn(NULL);\n\n#ifdef XSLT_REFACTORED\n    \/*\n    * Namespace exclusion and ns-aliasing is performed at\n    * compilation-time in the refactored code.\n    * Additionally, aliasing is not intended for non Literal\n    * Result Elements.\n    *\/\n    return(xsltGetSpecialNamespace(ctxt, cur, ns->href, ns->prefix, out));\n#else\n    {\n\txsltStylesheetPtr style;\n\tconst xmlChar *URI = NULL; \/* the replacement URI *\/\n\n\tif ((ctxt == NULL) || (cur == NULL) || (out == NULL))\n\t    return(NULL);\n\n\tstyle = ctxt->style;\n\twhile (style != NULL) {\n\t    if (style->nsAliases != NULL)\n\t\tURI = (const xmlChar *)\n\t\txmlHashLookup(style->nsAliases, ns->href);\n\t    if (URI != NULL)\n\t\tbreak;\n\n\t    style = xsltNextImport(style);\n\t}\n\n\n\tif (URI == UNDEFINED_DEFAULT_NS) {\n\t    return(xsltGetSpecialNamespace(ctxt, cur, NULL, NULL, out));\n#if 0\n\t    \/*\n\t    * TODO: Removed, since wrong. If there was no default\n\t    * namespace in the stylesheet then this must resolve to\n\t    * the NULL namespace.\n\t    *\/\n\t    xmlNsPtr dflt;\n\t    dflt = xmlSearchNs(cur->doc, cur, NULL);\n\t    if (dflt != NULL)\n\t\tURI = dflt->href;\n\t    else\n\t\treturn NULL;\n#endif\n\t} else if (URI == NULL)\n\t    URI = ns->href;\n\n\treturn(xsltGetSpecialNamespace(ctxt, cur, URI, ns->prefix, out));\n    }\n#endif\n}\n","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":271525,"func":"int ext4_change_inode_journal_flag(struct inode *inode, int val)\n{\n\tjournal_t *journal;\n\thandle_t *handle;\n\tint err;\n\n\t\/*\n\t * We have to be very careful here: changing a data block's\n\t * journaling status dynamically is dangerous.  If we write a\n\t * data block to the journal, change the status and then delete\n\t * that block, we risk forgetting to revoke the old log record\n\t * from the journal and so a subsequent replay can corrupt data.\n\t * So, first we make sure that the journal is empty and that\n\t * nobody is changing anything.\n\t *\/\n\n\tjournal = EXT4_JOURNAL(inode);\n\tif (!journal)\n\t\treturn 0;\n\tif (is_journal_aborted(journal))\n\t\treturn -EROFS;\n\t\/* We have to allocate physical blocks for delalloc blocks\n\t * before flushing journal. otherwise delalloc blocks can not\n\t * be allocated any more. even more truncate on delalloc blocks\n\t * could trigger BUG by flushing delalloc blocks in journal.\n\t * There is no delalloc block in non-journal data mode.\n\t *\/\n\tif (val && test_opt(inode->i_sb, DELALLOC)) {\n\t\terr = ext4_alloc_da_blocks(inode);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\t\/* Wait for all existing dio workers *\/\n\text4_inode_block_unlocked_dio(inode);\n\tinode_dio_wait(inode);\n\n\tjbd2_journal_lock_updates(journal);\n\n\t\/*\n\t * OK, there are no updates running now, and all cached data is\n\t * synced to disk.  We are now in a completely consistent state\n\t * which doesn't have anything in the journal, and we know that\n\t * no filesystem updates are running, so it is safe to modify\n\t * the inode's in-core data-journaling state flag now.\n\t *\/\n\n\tif (val)\n\t\text4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);\n\telse {\n\t\terr = jbd2_journal_flush(journal);\n\t\tif (err < 0) {\n\t\t\tjbd2_journal_unlock_updates(journal);\n\t\t\text4_inode_resume_unlocked_dio(inode);\n\t\t\treturn err;\n\t\t}\n\t\text4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);\n\t}\n\text4_set_aops(inode);\n\n\tjbd2_journal_unlock_updates(journal);\n\text4_inode_resume_unlocked_dio(inode);\n\n\t\/* Finally we can mark the inode as dirty. *\/\n\n\thandle = ext4_journal_start(inode, EXT4_HT_INODE, 1);\n\tif (IS_ERR(handle))\n\t\treturn PTR_ERR(handle);\n\n\terr = ext4_mark_inode_dirty(handle, inode);\n\text4_handle_sync(handle);\n\text4_journal_stop(handle);\n\text4_std_error(inode->i_sb, err);\n\n\treturn err;\n}","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":324210,"func":"int av_picture_crop(AVPicture *dst, const AVPicture *src,\n\n                    enum PixelFormat pix_fmt, int top_band, int left_band)\n\n{\n\n    int y_shift;\n\n    int x_shift;\n\n\n\n    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)\n\n        return -1;\n\n\n\n    y_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;\n\n    x_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w;\n\n\n\n    if (is_yuv_planar(&pix_fmt_info[pix_fmt])) {\n\n    dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;\n\n    dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);\n\n    dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);\n\n    } else{\n\n        if(top_band % (1<<y_shift) || left_band % (1<<x_shift))\n\n            return -1;\n\n        if(left_band) \/\/FIXME add support for this too\n\n            return -1;\n\n        dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;\n\n    }\n\n\n\n    dst->linesize[0] = src->linesize[0];\n\n    dst->linesize[1] = src->linesize[1];\n\n    dst->linesize[2] = src->linesize[2];\n\n    return 0;\n\n}\n","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":370313,"func":"xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){\n    xmlNodePtr cur = NULL;\n    xmlXPathObjectPtr obj = NULL;\n    long val;\n    xmlChar str[30];\n    xmlDocPtr doc;\n\n    if (nargs == 0) {\n\tcur = ctxt->context->node;\n    } else if (nargs == 1) {\n\txmlNodeSetPtr nodelist;\n\tint i, ret;\n\n\tif ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {\n\t    ctxt->error = XPATH_INVALID_TYPE;\n\t    xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,\n\t\t\"generate-id() : invalid arg expecting a node-set\\n\");\n\t    return;\n\t}\n\tobj = valuePop(ctxt);\n\tnodelist = obj->nodesetval;\n\tif ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {\n\t    xmlXPathFreeObject(obj);\n\t    valuePush(ctxt, xmlXPathNewCString(\"\"));\n\t    return;\n\t}\n\tcur = nodelist->nodeTab[0];\n\tfor (i = 1;i < nodelist->nodeNr;i++) {\n\t    ret = xmlXPathCmpNodes(cur, nodelist->nodeTab[i]);\n\t    if (ret == -1)\n\t        cur = nodelist->nodeTab[i];\n\t}\n    } else {\n\txsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,\n\t\t\"generate-id() : invalid number of args %d\\n\", nargs);\n\tctxt->error = XPATH_INVALID_ARITY;\n\treturn;\n    }\n    \/*\n     * Okay this is ugly but should work, use the NodePtr address\n     * to forge the ID\n     *\/\n    if (cur->type != XML_NAMESPACE_DECL)\n        doc = cur->doc;\n    else {\n        xmlNsPtr ns = (xmlNsPtr) cur;\n\n        if (ns->context != NULL)\n            doc = ns->context;\n        else\n            doc = ctxt->context->doc;\n\n    }\n\n    if (obj)\n        xmlXPathFreeObject(obj);\n\n    val = (long)((char *)cur - (char *)doc);\n    if (val >= 0) {\n      sprintf((char *)str, \"idp%ld\", val);\n    } else {\n      sprintf((char *)str, \"idm%ld\", -val);\n    }\n    valuePush(ctxt, xmlXPathNewString(str));\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":359349,"func":"tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,\n\t      struct tcf_ext_map *map)\n{\n#ifdef CONFIG_NET_CLS_ACT\n\tif (map->action && exts->action) {\n\t\t\/*\n\t\t * again for backward compatible mode - we want\n\t\t * to work with both old and new modes of entering\n\t\t * tc data even if iproute2  was newer - jhs\n\t\t *\/\n\t\tstruct rtattr * p_rta = (struct rtattr*) skb->tail;\n\n\t\tif (exts->action->type != TCA_OLD_COMPAT) {\n\t\t\tRTA_PUT(skb, map->action, 0, NULL);\n\t\t\tif (tcf_action_dump(skb, exts->action, 0, 0) < 0)\n\t\t\t\tgoto rtattr_failure;\n\t\t\tp_rta->rta_len = skb->tail - (u8*)p_rta;\n\t\t} else if (map->police) {\n\t\t\tRTA_PUT(skb, map->police, 0, NULL);\n\t\t\tif (tcf_action_dump_old(skb, exts->action, 0, 0) < 0)\n\t\t\t\tgoto rtattr_failure;\n\t\t\tp_rta->rta_len = skb->tail - (u8*)p_rta;\n\t\t}\n\t}\n#elif defined CONFIG_NET_CLS_POLICE\n\tif (map->police && exts->police) {\n\t\tstruct rtattr * p_rta = (struct rtattr*) skb->tail;\n\n\t\tRTA_PUT(skb, map->police, 0, NULL);\n\n\t\tif (tcf_police_dump(skb, exts->police) < 0)\n\t\t\tgoto rtattr_failure;\n\n\t\tp_rta->rta_len = skb->tail - (u8*)p_rta;\n\t}\n#endif\n\treturn 0;\nrtattr_failure: __attribute__ ((unused))\n\treturn -1;\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":142191,"func":"static int allocate_buffers(struct v4l2_loopback_device *dev)\n{\n\tint err;\n\n\tMARK();\n\t\/* vfree on close file operation in case no open handles left *\/\n\n\tif (dev->buffer_size < 1 || dev->buffers_number < 1)\n\t\treturn -EINVAL;\n\n\tif ((__LONG_MAX__ \/ dev->buffer_size) < dev->buffers_number)\n\t\treturn -ENOSPC;\n\n\tif (dev->image) {\n\t\tdprintk(\"allocating buffers again: %ld %ld\\n\",\n\t\t\tdev->buffer_size * dev->buffers_number, dev->imagesize);\n\t\t\/* FIXME: prevent double allocation more intelligently! *\/\n\t\tif (dev->buffer_size * dev->buffers_number == dev->imagesize)\n\t\t\treturn 0;\n\n\t\t\/* if there is only one writer, no problem should occur *\/\n\t\tif (dev->open_count.counter == 1)\n\t\t\tfree_buffers(dev);\n\t\telse\n\t\t\treturn -EINVAL;\n\t}\n\n\tdev->imagesize = (unsigned long)dev->buffer_size *\n\t\t\t (unsigned long)dev->buffers_number;\n\n\tdprintk(\"allocating %ld = %ldx%d\\n\", dev->imagesize, dev->buffer_size,\n\t\tdev->buffers_number);\n\terr = -ENOMEM;\n\n\tif (dev->timeout_jiffies > 0) {\n\t\terr = allocate_timeout_image(dev);\n\t\tif (err < 0)\n\t\t\tgoto error;\n\t}\n\n\tdev->image = vmalloc(dev->imagesize);\n\tif (dev->image == NULL)\n\t\tgoto error;\n\n\tdprintk(\"vmallocated %ld bytes\\n\", dev->imagesize);\n\tMARK();\n\n\tinit_buffers(dev);\n\treturn 0;\n\nerror:\n\tfree_buffers(dev);\n\treturn err;\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":234950,"func":"void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)\n{\n    if (!attached() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded())) {\n        m_styleResolver.clear();\n        return;\n    }\n    m_didCalculateStyleResolver = true;\n\n#ifdef INSTRUMENT_LAYOUT_SCHEDULING\n    if (!ownerElement())\n        printf(\"Beginning update of style selector at time %d.\\n\", elapsedTime());\n#endif\n\n    DocumentStyleSheetCollection::UpdateFlag styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded)\n        ? DocumentStyleSheetCollection::OptimizedUpdate\n        : DocumentStyleSheetCollection::FullUpdate;\n    bool stylesheetChangeRequiresStyleRecalc = m_styleSheetCollection->updateActiveStyleSheets(styleSheetUpdate);\n\n    if (updateFlag == DeferRecalcStyle) {\n        scheduleForcedStyleRecalc();\n        return;\n    }\n\n    if (didLayoutWithPendingStylesheets() && !m_styleSheetCollection->hasPendingSheets()) {\n        m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;\n        if (renderer())\n            renderView()->repaintViewAndCompositedLayers();\n    }\n\n    if (!stylesheetChangeRequiresStyleRecalc)\n        return;\n\n    {\n        AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);\n        recalcStyle(Force);\n    }\n\n#ifdef INSTRUMENT_LAYOUT_SCHEDULING\n    if (!ownerElement())\n        printf(\"Finished update of style selector at time %d\\n\", elapsedTime());\n#endif\n\n    if (renderer()) {\n        renderer()->setNeedsLayoutAndPrefWidthsRecalc();\n        if (view())\n            view()->scheduleRelayout();\n    }\n\n    evaluateMediaQueryList();\n}\n","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":430749,"func":"static void build_mixer_unit_ctl(struct mixer_build *state,\n\t\t\t\t struct uac_mixer_unit_descriptor *desc,\n\t\t\t\t int in_pin, int in_ch, int num_outs,\n\t\t\t\t int unitid, struct usb_audio_term *iterm)\n{\n\tstruct usb_mixer_elem_info *cval;\n\tunsigned int i, len;\n\tstruct snd_kcontrol *kctl;\n\tconst struct usbmix_name_map *map;\n\n\tmap = find_map(state->map, unitid, 0);\n\tif (check_ignored_ctl(map))\n\t\treturn;\n\n\tcval = kzalloc(sizeof(*cval), GFP_KERNEL);\n\tif (!cval)\n\t\treturn;\n\n\tsnd_usb_mixer_elem_init_std(&cval->head, state->mixer, unitid);\n\tcval->control = in_ch + 1; \/* based on 1 *\/\n\tcval->val_type = USB_MIXER_S16;\n\tfor (i = 0; i < num_outs; i++) {\n\t\t__u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol);\n\n\t\tif (check_matrix_bitmap(c, in_ch, i, num_outs)) {\n\t\t\tcval->cmask |= (1 << i);\n\t\t\tcval->channels++;\n\t\t}\n\t}\n\n\t\/* get min\/max values *\/\n\tget_min_max(cval, 0);\n\n\tkctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);\n\tif (!kctl) {\n\t\tusb_audio_err(state->chip, \"cannot malloc kcontrol\\n\");\n\t\tkfree(cval);\n\t\treturn;\n\t}\n\tkctl->private_free = snd_usb_mixer_elem_free;\n\n\tlen = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));\n\tif (!len)\n\t\tlen = get_term_name(state->chip, iterm, kctl->id.name,\n\t\t\t\t    sizeof(kctl->id.name), 0);\n\tif (!len)\n\t\tlen = sprintf(kctl->id.name, \"Mixer Source %d\", in_ch + 1);\n\tappend_ctl_name(kctl, \" Volume\");\n\n\tusb_audio_dbg(state->chip, \"[%d] MU [%s] ch = %d, val = %d\/%d\\n\",\n\t\t    cval->head.id, kctl->id.name, cval->channels, cval->min, cval->max);\n\tsnd_usb_mixer_add_control(&cval->head, kctl);\n}","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":39815,"func":"TfLiteStatus CalculateOpData(TfLiteContext* context, TfLiteNode* node,\n                             TfLiteDepthwiseConvParams* params, int width,\n                             int height, int filter_width, int filter_height,\n                             const TfLiteType data_type, OpData* data) {\n  bool has_bias = node->inputs->size == 3;\n  \/\/ Check number of inputs\/outputs\n  TF_LITE_ENSURE(context, has_bias || node->inputs->size == 2);\n  TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n\n  int unused_output_height, unused_output_width;\n  data->padding = ComputePaddingHeightWidth(\n      params->stride_height, params->stride_width, 1, 1, height, width,\n      filter_height, filter_width, params->padding, &unused_output_height,\n      &unused_output_width);\n\n  \/\/ Note that quantized inference requires that all tensors have their\n  \/\/ parameters set. This is usually done during quantized training.\n  if (data_type != kTfLiteFloat32) {\n    const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n    TF_LITE_ENSURE(context, input != nullptr);\n    const TfLiteTensor* filter = GetInput(context, node, kFilterTensor);\n    TF_LITE_ENSURE(context, filter != nullptr);\n    const TfLiteTensor* bias =\n        GetOptionalInputTensor(context, node, kBiasTensor);\n    TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n    TF_LITE_ENSURE(context, output != nullptr);\n    int num_channels = filter->dims->data[kDepthwiseConvQuantizedDimension];\n\n    return tflite::PopulateConvolutionQuantizationParams(\n        context, input, filter, bias, output, params->activation,\n        &data->output_multiplier, &data->output_shift,\n        &data->output_activation_min, &data->output_activation_max,\n        data->per_channel_output_multiplier,\n        reinterpret_cast<int*>(data->per_channel_output_shift), num_channels);\n  }\n  return kTfLiteOk;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":343825,"func":"nautilus_application_startup (NautilusApplication *application,\n\t\t\t      gboolean kill_shell,\n\t\t\t      gboolean no_default_window,\n\t\t\t      gboolean no_desktop,\n\t\t\t      gboolean browser_window,\n\t\t\t      const char *geometry,\n\t\t\t      char **urls)\n{\n\tUniqueMessageData *message;\n\t\n\t\/* Check the user's ~\/.nautilus directories and post warnings\n\t * if there are problems.\n\t *\/\n\tif (!kill_shell && !check_required_directories (application)) {\n\t\treturn;\n\t}\n\n\tif (kill_shell) {\n\t\tif (unique_app_is_running (application->unique_app)) {\n\t\t\tunique_app_send_message (application->unique_app,\n\t\t\t\t\t\t UNIQUE_CLOSE, NULL);\n\t\t\t\n\t\t}\n\t} else {\n\t\t\/* If KDE desktop is running, then force no_desktop *\/\n\t\tif (is_kdesktop_present ()) {\n\t\t\tno_desktop = TRUE;\n\t\t}\n\t\t\n\t\tif (!no_desktop && eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {\n\t\t\tif (unique_app_is_running (application->unique_app)) {\n\t\t\t\tunique_app_send_message (application->unique_app,\n\t\t\t\t\t\t\t COMMAND_START_DESKTOP, NULL);\n\t\t\t} else {\n\t\t\t\tnautilus_application_open_desktop (application);\n\t\t\t}\n\t\t}\n\n\t\tif (!unique_app_is_running (application->unique_app)) {\n\t\t\tfinish_startup (application);\n\t\t\tg_signal_connect (application->unique_app, \"message-received\", G_CALLBACK (message_received_cb), application);\t\t\t\n\t\t}\n\t\t\n\t\t\/* Monitor the preference to show or hide the desktop *\/\n\t\teel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SHOW_DESKTOP,\n\t\t\t\t\t\t\t  desktop_changed_callback,\n\t\t\t\t\t\t\t  application,\n\t\t\t\t\t\t\t  G_OBJECT (application));\n\n\t\t\/* Monitor the preference to have the desktop *\/\n\t\t\/* point to the Unix home folder *\/\n\t\teel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,\n\t\t\t\t\t\t\t  desktop_location_changed_callback,\n\t\t\t\t\t\t\t  NULL,\n\t\t\t\t\t\t\t  G_OBJECT (application));\n\n\t  \t\/* Create the other windows. *\/\n\t\tif (urls != NULL || !no_default_window) {\n\t\t\tif (unique_app_is_running (application->unique_app)) {\n\t\t\t\tmessage = unique_message_data_new ();\n\t\t\t\t_unique_message_data_set_geometry_and_uris (message, geometry, urls);\n\t\t\t\tif (browser_window) {\n\t\t\t\t\tunique_app_send_message (application->unique_app,\n\t\t\t\t\t\t\t\t COMMAND_OPEN_BROWSER, message);\n\t\t\t\t} else {\n\t\t\t\t\tunique_app_send_message (application->unique_app,\n\t\t\t\t\t\t\t\t UNIQUE_OPEN, message);\n\t\t\t\t}\n\t\t\t\tunique_message_data_free (message);\t\t\t\t\n\t\t\t} else {\n\t\t\t\topen_windows (application, NULL,\n\t\t\t\t\t      urls,\n\t\t\t\t\t      geometry,\n\t\t\t\t\t      browser_window);\n\t\t\t}\n\t\t}\n\n\t\t\/* Load session info if availible *\/\n\t\tnautilus_application_load_session (application);\n\t}\n}","target":1,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":285662,"func":"v8::Handle<v8::Value> V8DOMWrapper::convertEventToV8Object(Event* event)\n{\n    if (!event)\n        return v8::Null();\n\n    v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(event);\n    if (!wrapper.IsEmpty())\n        return wrapper;\n\n    V8ClassIndex::V8WrapperType type = V8ClassIndex::EVENT;\n\n    if (event->isUIEvent()) {\n        if (event->isKeyboardEvent())\n            type = V8ClassIndex::KEYBOARDEVENT;\n        else if (event->isTextEvent())\n            type = V8ClassIndex::TEXTEVENT;\n        else if (event->isMouseEvent())\n            type = V8ClassIndex::MOUSEEVENT;\n        else if (event->isWheelEvent())\n            type = V8ClassIndex::WHEELEVENT;\n#if ENABLE(SVG)\n        else if (event->isSVGZoomEvent())\n            type = V8ClassIndex::SVGZOOMEVENT;\n#endif\n        else\n            type = V8ClassIndex::UIEVENT;\n    } else if (event->isMutationEvent())\n        type = V8ClassIndex::MUTATIONEVENT;\n    else if (event->isOverflowEvent())\n        type = V8ClassIndex::OVERFLOWEVENT;\n    else if (event->isMessageEvent())\n        type = V8ClassIndex::MESSAGEEVENT;\n    else if (event->isProgressEvent()) {\n        if (event->isXMLHttpRequestProgressEvent())\n            type = V8ClassIndex::XMLHTTPREQUESTPROGRESSEVENT;\n        else\n            type = V8ClassIndex::PROGRESSEVENT;\n    } else if (event->isWebKitAnimationEvent())\n         type = V8ClassIndex::WEBKITANIMATIONEVENT;\n     else if (event->isWebKitTransitionEvent())\n         type = V8ClassIndex::WEBKITTRANSITIONEVENT;\n#if ENABLE(WORKERS)\n    else if (event->isErrorEvent())\n        type = V8ClassIndex::ERROREVENT;\n#endif\n \n \n     v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::EVENT, event);\n    if (result.IsEmpty()) {\n        return v8::Null();\n    }\n\n    event->ref(); \/\/ fast ref\n    setJSWrapperForDOMObject(event, v8::Persistent<v8::Object>::New(result));\n\n    return result;\n}\n","target":0,"code_token_length":513,"total_token_length":749,"max_tokens_setting":1024}
+{"idx":483264,"func":"struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos,\n\t\t\t\t\t   struct cgroup_subsys_state *parent)\n{\n\tstruct cgroup_subsys_state *next;\n\n\tcgroup_assert_mutex_or_rcu_locked();\n\n\t\/*\n\t * @pos could already have been unlinked from the sibling list.\n\t * Once a cgroup is removed, its ->sibling.next is no longer\n\t * updated when its next sibling changes.  CSS_RELEASED is set when\n\t * @pos is taken off list, at which time its next pointer is valid,\n\t * and, as releases are serialized, the one pointed to by the next\n\t * pointer is guaranteed to not have started release yet.  This\n\t * implies that if we observe !CSS_RELEASED on @pos in this RCU\n\t * critical section, the one pointed to by its next pointer is\n\t * guaranteed to not have finished its RCU grace period even if we\n\t * have dropped rcu_read_lock() in-between iterations.\n\t *\n\t * If @pos has CSS_RELEASED set, its next pointer can't be\n\t * dereferenced; however, as each css is given a monotonically\n\t * increasing unique serial number and always appended to the\n\t * sibling list, the next one can be found by walking the parent's\n\t * children until the first css with higher serial number than\n\t * @pos's.  While this path can be slower, it happens iff iteration\n\t * races against release and the race window is very small.\n\t *\/\n\tif (!pos) {\n\t\tnext = list_entry_rcu(parent->children.next, struct cgroup_subsys_state, sibling);\n\t} else if (likely(!(pos->flags & CSS_RELEASED))) {\n\t\tnext = list_entry_rcu(pos->sibling.next, struct cgroup_subsys_state, sibling);\n\t} else {\n\t\tlist_for_each_entry_rcu(next, &parent->children, sibling,\n\t\t\t\t\tlockdep_is_held(&cgroup_mutex))\n\t\t\tif (next->serial_nr > pos->serial_nr)\n\t\t\t\tbreak;\n\t}\n\n\t\/*\n\t * @next, if not pointing to the head, can be dereferenced and is\n\t * the next sibling.\n\t *\/\n\tif (&next->sibling != &parent->children)\n\t\treturn next;\n\treturn NULL;\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":131865,"func":"static int nf_conntrack_standalone_init_sysctl(struct net *net)\n{\n\tstruct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id);\n\tstruct nf_udp_net *un = nf_udp_pernet(net);\n\tstruct ctl_table *table;\n\n\tBUILD_BUG_ON(ARRAY_SIZE(nf_ct_sysctl_table) != NF_SYSCTL_CT_LAST_SYSCTL);\n\n\ttable = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),\n\t\t\tGFP_KERNEL);\n\tif (!table)\n\t\treturn -ENOMEM;\n\n\ttable[NF_SYSCTL_CT_COUNT].data = &net->ct.count;\n\ttable[NF_SYSCTL_CT_CHECKSUM].data = &net->ct.sysctl_checksum;\n\ttable[NF_SYSCTL_CT_LOG_INVALID].data = &net->ct.sysctl_log_invalid;\n\ttable[NF_SYSCTL_CT_ACCT].data = &net->ct.sysctl_acct;\n\ttable[NF_SYSCTL_CT_HELPER].data = &net->ct.sysctl_auto_assign_helper;\n#ifdef CONFIG_NF_CONNTRACK_EVENTS\n\ttable[NF_SYSCTL_CT_EVENTS].data = &net->ct.sysctl_events;\n#endif\n#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP\n\ttable[NF_SYSCTL_CT_TIMESTAMP].data = &net->ct.sysctl_tstamp;\n#endif\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_GENERIC].data = &nf_generic_pernet(net)->timeout;\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_ICMP].data = &nf_icmp_pernet(net)->timeout;\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_ICMPV6].data = &nf_icmpv6_pernet(net)->timeout;\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_UDP].data = &un->timeouts[UDP_CT_UNREPLIED];\n\ttable[NF_SYSCTL_CT_PROTO_TIMEOUT_UDP_STREAM].data = &un->timeouts[UDP_CT_REPLIED];\n\n\tnf_conntrack_standalone_init_tcp_sysctl(net, table);\n\tnf_conntrack_standalone_init_sctp_sysctl(net, table);\n\tnf_conntrack_standalone_init_dccp_sysctl(net, table);\n\tnf_conntrack_standalone_init_gre_sysctl(net, table);\n\n\t\/* Don't allow non-init_net ns to alter global sysctls *\/\n\tif (!net_eq(&init_net, net)) {\n\t\ttable[NF_SYSCTL_CT_MAX].mode = 0444;\n\t\ttable[NF_SYSCTL_CT_EXPECT_MAX].mode = 0444;\n\t\ttable[NF_SYSCTL_CT_BUCKETS].mode = 0444;\n\t}\n\n\tcnet->sysctl_header = register_net_sysctl(net, \"net\/netfilter\", table);\n\tif (!cnet->sysctl_header)\n\t\tgoto out_unregister_netfilter;\n\n\treturn 0;\n\nout_unregister_netfilter:\n\tkfree(table);\n\treturn -ENOMEM;\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":7757,"func":"static int fsmMkdirs(rpmfiles files, rpmfs fs, rpmPlugins plugins)\n{\n    DNLI_t dnli = dnlInitIterator(files, fs, 0);\n    struct stat sb;\n    const char *dpath;\n    int rc = 0;\n    int i;\n    size_t ldnlen = 0;\n    const char * ldn = NULL;\n\n    while ((dpath = dnlNextIterator(dnli)) != NULL) {\n\tsize_t dnlen = strlen(dpath);\n\tchar * te, dn[dnlen+1];\n\n\tif (dnlen <= 1)\n\t    continue;\n\n\tif (dnlen == ldnlen && rstreq(dpath, ldn))\n\t    continue;\n\n\t\/* Copy as we need to modify the string *\/\n\t(void) stpcpy(dn, dpath);\n\n\t\/* Assume '\/' directory exists, \"mkdir -p\" for others if non-existent *\/\n\tfor (i = 1, te = dn + 1; *te != '\\0'; te++, i++) {\n\t    if (*te != '\/')\n\t\tcontinue;\n\n\t    \/* Already validated? *\/\n\t    if (i < ldnlen &&\n\t\t(ldn[i] == '\/' || ldn[i] == '\\0') && rstreqn(dn, ldn, i))\n\t\tcontinue;\n\n\t    \/* Validate next component of path. *\/\n\t    *te = '\\0';\n\t    rc = fsmStat(dn, 1, &sb); \/* lstat *\/\n\t    *te = '\/';\n\n\t    \/* Directory already exists? *\/\n\t    if (rc == 0 && S_ISDIR(sb.st_mode)) {\n\t\tcontinue;\n\t    } else if (rc == RPMERR_ENOENT) {\n\t\t*te = '\\0';\n\t\tmode_t mode = S_IFDIR | (_dirPerms & 07777);\n\t\trpmFsmOp op = (FA_CREATE|FAF_UNOWNED);\n\n\t\t\/* Run fsm file pre hook for all plugins *\/\n\t\trc = rpmpluginsCallFsmFilePre(plugins, NULL, dn, mode, op);\n\n\t\tif (!rc)\n\t\t    rc = fsmMkdir(dn, mode);\n\n\t\tif (!rc) {\n\t\t    rc = rpmpluginsCallFsmFilePrepare(plugins, NULL, dn, dn,\n\t\t\t\t\t\t      mode, op);\n\t\t}\n\n\t\t\/* Run fsm file post hook for all plugins *\/\n\t\trpmpluginsCallFsmFilePost(plugins, NULL, dn, mode, op, rc);\n\n\t\tif (!rc) {\n\t\t    rpmlog(RPMLOG_DEBUG,\n\t\t\t    \"%s directory created with perms %04o\\n\",\n\t\t\t    dn, (unsigned)(mode & 07777));\n\t\t}\n\t\t*te = '\/';\n\t    }\n\t    if (rc)\n\t\tbreak;\n\t}\n\tif (rc) break;\n\n\t\/* Save last validated path. *\/\n\tldn = dpath;\n\tldnlen = dnlen;\n    }\n    dnlFreeIterator(dnli);\n\n    return rc;\n}","target":1,"code_token_length":623,"total_token_length":859,"max_tokens_setting":1024}
+{"idx":120239,"func":"njs_generate_function_expression(njs_vm_t *vm, njs_generator_t *generator,\n    njs_parser_node_t *node)\n{\n    njs_int_t                ret;\n    njs_variable_t           *var;\n    njs_function_lambda_t    *lambda;\n    njs_vmcode_function_t    *function;\n    const njs_lexer_entry_t  *lex_entry;\n\n    var = njs_variable_reference(vm, node->left);\n    if (njs_slow_path(var == NULL)) {\n        ret = njs_generate_reference_error(vm, generator, node->left);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        return njs_generator_stack_pop(vm, generator, NULL);\n    }\n\n    lambda = node->u.value.data.u.lambda;\n\n    lex_entry = njs_lexer_entry(var->unique_id);\n    if (njs_slow_path(lex_entry == NULL)) {\n        return NJS_ERROR;\n    }\n\n    ret = njs_generate_function_scope(vm, generator, lambda, node,\n                                      &lex_entry->name);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    njs_generate_code(generator, njs_vmcode_function_t, function,\n                      NJS_VMCODE_FUNCTION, 1, node);\n    function->lambda = lambda;\n    function->async = (node->token_type == NJS_TOKEN_ASYNC_FUNCTION_EXPRESSION);\n\n    node->index = njs_generate_object_dest_index(vm, generator, node);\n    if (njs_slow_path(node->index == NJS_INDEX_ERROR)) {\n        return NJS_ERROR;\n    }\n\n    function->retval = node->index;\n\n    return njs_generator_stack_pop(vm, generator, NULL);\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":329580,"func":"static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)\n\n{\n\n    VGACommonState *vga = &qxl->vga;\n\n    DisplaySurface *surface;\n\n    int i;\n\n\n\n    if (qxl->guest_primary.resized) {\n\n        qxl->guest_primary.resized = 0;\n\n        qxl->guest_primary.data = qxl_phys2virt(qxl,\n\n                                                qxl->guest_primary.surface.mem,\n\n                                                MEMSLOT_GROUP_GUEST);\n\n        if (!qxl->guest_primary.data) {\n\n            return;\n\n        }\n\n        qxl_set_rect_to_surface(qxl, &qxl->dirty[0]);\n\n        qxl->num_dirty_rects = 1;\n\n        trace_qxl_render_guest_primary_resized(\n\n               qxl->guest_primary.surface.width,\n\n               qxl->guest_primary.surface.height,\n\n               qxl->guest_primary.qxl_stride,\n\n               qxl->guest_primary.bytes_pp,\n\n               qxl->guest_primary.bits_pp);\n\n        if (qxl->guest_primary.qxl_stride > 0) {\n\n            surface = qemu_create_displaysurface_from\n\n                (qxl->guest_primary.surface.width,\n\n                 qxl->guest_primary.surface.height,\n\n                 qxl->guest_primary.bits_pp,\n\n                 qxl->guest_primary.abs_stride,\n\n                 qxl->guest_primary.data,\n\n                 false);\n\n        } else {\n\n            surface = qemu_create_displaysurface\n\n                (qxl->guest_primary.surface.width,\n\n                 qxl->guest_primary.surface.height);\n\n        }\n\n        dpy_gfx_replace_surface(vga->con, surface);\n\n    }\n\n\n\n    if (!qxl->guest_primary.data) {\n\n        return;\n\n    }\n\n    for (i = 0; i < qxl->num_dirty_rects; i++) {\n\n        if (qemu_spice_rect_is_empty(qxl->dirty+i)) {\n\n            break;\n\n        }\n\n        if (qxl->dirty[i].left > qxl->dirty[i].right ||\n\n            qxl->dirty[i].top > qxl->dirty[i].bottom ||\n\n            qxl->dirty[i].right > qxl->guest_primary.surface.width ||\n\n            qxl->dirty[i].bottom > qxl->guest_primary.surface.height) {\n\n            continue;\n\n        }\n\n        qxl_blit(qxl, qxl->dirty+i);\n\n        dpy_gfx_update(vga->con,\n\n                       qxl->dirty[i].left, qxl->dirty[i].top,\n\n                       qxl->dirty[i].right - qxl->dirty[i].left,\n\n                       qxl->dirty[i].bottom - qxl->dirty[i].top);\n\n    }\n\n    qxl->num_dirty_rects = 0;\n\n}\n","target":1,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":335745,"func":"static int is_intra_more_likely(ERContext *s)\n\n{\n\n    int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;\n\n\n\n    if (!s->last_pic.f || !s->last_pic.f->data[0])\n\n        return 1; \/\/ no previous frame available -> use spatial prediction\n\n\n\n    undamaged_count = 0;\n\n    for (i = 0; i < s->mb_num; i++) {\n\n        const int mb_xy = s->mb_index2xy[i];\n\n        const int error = s->error_status_table[mb_xy];\n\n        if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))\n\n            undamaged_count++;\n\n    }\n\n\n\n    if (s->avctx->codec_id == AV_CODEC_ID_H264 && s->ref_count <= 0)\n\n        return 1;\n\n\n\n    if (undamaged_count < 5)\n\n        return 0; \/\/ almost all MBs damaged -> use temporal prediction\n\n\n\n#if FF_API_XVMC\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n    \/\/ prevent dsp.sad() check, that requires access to the image\n\n    if (CONFIG_MPEG_XVMC_DECODER    &&\n\n        s->avctx->xvmc_acceleration &&\n\n        s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I)\n\n        return 1;\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif \/* FF_API_XVMC *\/\n\n\n\n    skip_amount     = FFMAX(undamaged_count \/ 50, 1); \/\/ check only up to 50 MBs\n\n    is_intra_likely = 0;\n\n\n\n    j = 0;\n\n    for (mb_y = 0; mb_y < s->mb_height - 1; mb_y++) {\n\n        for (mb_x = 0; mb_x < s->mb_width; mb_x++) {\n\n            int error;\n\n            const int mb_xy = mb_x + mb_y * s->mb_stride;\n\n\n\n            error = s->error_status_table[mb_xy];\n\n            if ((error & ER_DC_ERROR) && (error & ER_MV_ERROR))\n\n                continue; \/\/ skip damaged\n\n\n\n            j++;\n\n            \/\/ skip a few to speed things up\n\n            if ((j % skip_amount) != 0)\n\n                continue;\n\n\n\n            if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I) {\n\n                int *linesize = s->cur_pic.f->linesize;\n\n                uint8_t *mb_ptr      = s->cur_pic.f->data[0] +\n\n                                       mb_x * 16 + mb_y * 16 * linesize[0];\n\n                uint8_t *last_mb_ptr = s->last_pic.f->data[0] +\n\n                                       mb_x * 16 + mb_y * 16 * linesize[0];\n\n\n\n                if (s->avctx->codec_id == AV_CODEC_ID_H264) {\n\n                    \/\/ FIXME\n\n                } else {\n\n                    ff_thread_await_progress(s->last_pic.tf, mb_y, 0);\n\n                }\n\n                is_intra_likely += s->mecc->sad[0](NULL, last_mb_ptr, mb_ptr,\n\n                                                   linesize[0], 16);\n\n                is_intra_likely -= s->mecc->sad[0](NULL, last_mb_ptr,\n\n                                                   last_mb_ptr + linesize[0] * 16,\n\n                                                   linesize[0], 16);\n\n            } else {\n\n                if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))\n\n                   is_intra_likely++;\n\n                else\n\n                   is_intra_likely--;\n\n            }\n\n        }\n\n    }\n\n    return is_intra_likely > 0;\n\n}\n","target":0,"code_token_length":783,"total_token_length":1019,"max_tokens_setting":1024}
+{"idx":408792,"func":"query (void)\n{\n  static const GimpParamDef load_args[] =\n  {\n    { GIMP_PDB_INT32,  \"run-mode\",     \"The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }\" },\n    { GIMP_PDB_STRING, \"filename\",     \"The name of the file to load\" },\n    { GIMP_PDB_STRING, \"raw-filename\", \"The name of the file to load\" }\n  };\n  static const GimpParamDef load_return_vals[] =\n  {\n    { GIMP_PDB_IMAGE, \"image\", \"Output image\" }\n  };\n\n#if 0\n  static const GimpParamDef save_args[] =\n  {\n    { GIMP_PDB_INT32,    \"run-mode\",     \"The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }\" },\n    { GIMP_PDB_IMAGE,    \"image\",        \"Input image\" },\n    { GIMP_PDB_DRAWABLE, \"drawable\",     \"Drawable to export\" },\n    { GIMP_PDB_STRING,   \"filename\",     \"The name of the file to export the image in\" },\n    { GIMP_PDB_STRING,   \"raw-filename\", \"The name of the file to export the image in\" },\n    { GIMP_PDB_INT32,    \"compression\",  \"Specify 0 for no compression, 1 for RLE, and 2 for LZ77\" }\n  };\n#endif\n\n  gimp_install_procedure (LOAD_PROC,\n                          \"loads images from the Paint Shop Pro PSP file format\",\n                          \"This plug-in loads and exports images in \"\n                          \"Paint Shop Pro's native PSP format. \"\n                          \"Vector layers aren't handled. Exporting isn't \"\n                          \"yet implemented.\",\n                          \"Tor Lillqvist\",\n                          \"Tor Lillqvist\",\n                          \"1999\",\n                          N_(\"Paint Shop Pro image\"),\n                          NULL,\n                          GIMP_PLUGIN,\n                          G_N_ELEMENTS (load_args),\n                          G_N_ELEMENTS (load_return_vals),\n                          load_args, load_return_vals);\n\n  gimp_register_file_handler_mime (LOAD_PROC, \"image\/x-psp\");\n  gimp_register_magic_load_handler (LOAD_PROC,\n                                    \"psp,tub,pspimage\",\n                                    \"\",\n                                    \"0,string,Paint\\\\040Shop\\\\040Pro\\\\040Image\\\\040File\\n\\032\");\n\n  \/* commented out until exporting is implemented *\/\n#if 0\n  gimp_install_procedure (SAVE_PROC,\n                          \"exports images in the Paint Shop Pro PSP file format\",\n                          \"This plug-in loads and exports images in \"\n                          \"Paint Shop Pro's native PSP format. \"\n                          \"Vector layers aren't handled. Exporting isn't \"\n                          \"yet implemented.\",\n                          \"Tor Lillqvist\",\n                          \"Tor Lillqvist\",\n                          \"1999\",\n                          N_(\"Paint Shop Pro image\"),\n                          \"RGB*, GRAY*, INDEXED*\",\n                          GIMP_PLUGIN,\n                          G_N_ELEMENTS (save_args), 0,\n                          save_args, NULL);\n\n  gimp_register_save_handler (SAVE_PROC, \"psp,tub\", \"\");\n#endif\n}","target":0,"code_token_length":684,"total_token_length":920,"max_tokens_setting":1024}
+{"idx":115848,"func":"static int ext4_journalled_write_end(struct file *file,\n\t\t\t\t     struct address_space *mapping,\n\t\t\t\t     loff_t pos, unsigned len, unsigned copied,\n\t\t\t\t     struct page *page, void *fsdata)\n{\n\thandle_t *handle = ext4_journal_current_handle();\n\tstruct inode *inode = mapping->host;\n\tloff_t old_size = inode->i_size;\n\tint ret = 0, ret2;\n\tint partial = 0;\n\tunsigned from, to;\n\tint size_changed = 0;\n\n\ttrace_ext4_journalled_write_end(inode, pos, len, copied);\n\tfrom = pos & (PAGE_SIZE - 1);\n\tto = from + len;\n\n\tBUG_ON(!ext4_handle_valid(handle));\n\n\tif (ext4_has_inline_data(inode))\n\t\tcopied = ext4_write_inline_data_end(inode, pos, len,\n\t\t\t\t\t\t    copied, page);\n\telse {\n\t\tif (copied < len) {\n\t\t\tif (!PageUptodate(page))\n\t\t\t\tcopied = 0;\n\t\t\tzero_new_buffers(page, from+copied, to);\n\t\t}\n\n\t\tret = ext4_walk_page_buffers(handle, page_buffers(page), from,\n\t\t\t\t\t     to, &partial, write_end_fn);\n\t\tif (!partial)\n\t\t\tSetPageUptodate(page);\n\t}\n\tsize_changed = ext4_update_inode_size(inode, pos + copied);\n\text4_set_inode_state(inode, EXT4_STATE_JDATA);\n\tEXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;\n\tunlock_page(page);\n\tput_page(page);\n\n\tif (old_size < pos)\n\t\tpagecache_isize_extended(inode, old_size, pos);\n\n\tif (size_changed) {\n\t\tret2 = ext4_mark_inode_dirty(handle, inode);\n\t\tif (!ret)\n\t\t\tret = ret2;\n\t}\n\n\tif (pos + len > inode->i_size && ext4_can_truncate(inode))\n\t\t\/* if we have allocated more blocks and copied\n\t\t * less. We will have blocks allocated outside\n\t\t * inode->i_size. So truncate them\n\t\t *\/\n\t\text4_orphan_add(handle, inode);\n\n\tret2 = ext4_journal_stop(handle);\n\tif (!ret)\n\t\tret = ret2;\n\tif (pos + len > inode->i_size) {\n\t\text4_truncate_failed_write(inode);\n\t\t\/*\n\t\t * If truncate failed early the inode might still be\n\t\t * on the orphan list; we need to make sure the inode\n\t\t * is removed from the orphan list in that case.\n\t\t *\/\n\t\tif (inode->i_nlink)\n\t\t\text4_orphan_del(NULL, inode);\n\t}\n\n\treturn ret ? ret : copied;\n}","target":0,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":325686,"func":"static int qxl_init_common(PCIQXLDevice *qxl)\n\n{\n\n    uint8_t* config = qxl->pci.config;\n\n    uint32_t pci_device_id;\n\n    uint32_t pci_device_rev;\n\n    uint32_t io_size;\n\n\n\n    qxl->mode = QXL_MODE_UNDEFINED;\n\n    qxl->generation = 1;\n\n    qxl->num_memslots = NUM_MEMSLOTS;\n\n    qxl->num_surfaces = NUM_SURFACES;\n\n\n\n    switch (qxl->revision) {\n\n    case 1: \/* spice 0.4 -- qxl-1 *\/\n\n        pci_device_id  = QXL_DEVICE_ID_STABLE;\n\n        pci_device_rev = QXL_REVISION_STABLE_V04;\n\n        break;\n\n    case 2: \/* spice 0.6 -- qxl-2 *\/\n\n        pci_device_id  = QXL_DEVICE_ID_STABLE;\n\n        pci_device_rev = QXL_REVISION_STABLE_V06;\n\n        break;\n\n    default: \/* experimental *\/\n\n        pci_device_id  = QXL_DEVICE_ID_DEVEL;\n\n        pci_device_rev = 1;\n\n        break;\n\n    }\n\n\n\n    pci_config_set_vendor_id(config, REDHAT_PCI_VENDOR_ID);\n\n    pci_config_set_device_id(config, pci_device_id);\n\n    pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);\n\n    pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);\n\n\n\n    qxl->rom_size = qxl_rom_size();\n\n    qxl->rom_offset = qemu_ram_alloc(&qxl->pci.qdev, \"qxl.vrom\", qxl->rom_size);\n\n    init_qxl_rom(qxl);\n\n    init_qxl_ram(qxl);\n\n\n\n    if (qxl->vram_size < 16 * 1024 * 1024) {\n\n        qxl->vram_size = 16 * 1024 * 1024;\n\n    }\n\n    if (qxl->revision == 1) {\n\n        qxl->vram_size = 4096;\n\n    }\n\n    qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);\n\n    qxl->vram_offset = qemu_ram_alloc(&qxl->pci.qdev, \"qxl.vram\", qxl->vram_size);\n\n\n\n    io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);\n\n    if (qxl->revision == 1) {\n\n        io_size = 8;\n\n    }\n\n\n\n    pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,\n\n                     io_size, PCI_BASE_ADDRESS_SPACE_IO, qxl_map);\n\n\n\n    pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,\n\n                     qxl->rom_size, PCI_BASE_ADDRESS_SPACE_MEMORY,\n\n                     qxl_map);\n\n\n\n    pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,\n\n                     qxl->vga.vram_size, PCI_BASE_ADDRESS_SPACE_MEMORY,\n\n                     qxl_map);\n\n\n\n    pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX, qxl->vram_size,\n\n                     PCI_BASE_ADDRESS_SPACE_MEMORY, qxl_map);\n\n\n\n    qxl->ssd.qxl.base.sif = &qxl_interface.base;\n\n    qxl->ssd.qxl.id = qxl->id;\n\n    qemu_spice_add_interface(&qxl->ssd.qxl.base);\n\n    qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);\n\n\n\n    init_pipe_signaling(qxl);\n\n    qxl_reset_state(qxl);\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":754,"total_token_length":990,"max_tokens_setting":1024}
+{"idx":94435,"func":"__ip_vs_get_service_entries(const struct ip_vs_get_services *get,\n\t\t\t    struct ip_vs_get_services __user *uptr)\n{\n\tint idx, count=0;\n\tstruct ip_vs_service *svc;\n\tstruct ip_vs_service_entry entry;\n\tint ret = 0;\n\n\tfor (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) {\n\t\tlist_for_each_entry(svc, &ip_vs_svc_table[idx], s_list) {\n\t\t\t\/* Only expose IPv4 entries to old interface *\/\n\t\t\tif (svc->af != AF_INET)\n\t\t\t\tcontinue;\n\n\t\t\tif (count >= get->num_services)\n\t\t\t\tgoto out;\n\t\t\tmemset(&entry, 0, sizeof(entry));\n\t\t\tip_vs_copy_service(&entry, svc);\n\t\t\tif (copy_to_user(&uptr->entrytable[count],\n\t\t\t\t\t &entry, sizeof(entry))) {\n\t\t\t\tret = -EFAULT;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tcount++;\n\t\t}\n\t}\n\n\tfor (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) {\n\t\tlist_for_each_entry(svc, &ip_vs_svc_fwm_table[idx], f_list) {\n\t\t\t\/* Only expose IPv4 entries to old interface *\/\n\t\t\tif (svc->af != AF_INET)\n\t\t\t\tcontinue;\n\n\t\t\tif (count >= get->num_services)\n\t\t\t\tgoto out;\n\t\t\tmemset(&entry, 0, sizeof(entry));\n\t\t\tip_vs_copy_service(&entry, svc);\n\t\t\tif (copy_to_user(&uptr->entrytable[count],\n\t\t\t\t\t &entry, sizeof(entry))) {\n\t\t\t\tret = -EFAULT;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tcount++;\n\t\t}\n\t}\n  out:\n\treturn ret;\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":261757,"func":"static void rtas_start_cpu(sPAPREnvironment *spapr,\n\n                           uint32_t token, uint32_t nargs,\n\n                           target_ulong args,\n\n                           uint32_t nret, target_ulong rets)\n\n{\n\n    target_ulong id, start, r3;\n\n    CPUState *cs;\n\n\n\n    if (nargs != 3 || nret != 1) {\n\n        rtas_st(rets, 0, -3);\n\n        return;\n\n    }\n\n\n\n    id = rtas_ld(args, 0);\n\n    start = rtas_ld(args, 1);\n\n    r3 = rtas_ld(args, 2);\n\n\n\n    cs = qemu_get_cpu(id);\n\n    if (cs != NULL) {\n\n        PowerPCCPU *cpu = POWERPC_CPU(cs);\n\n        CPUPPCState *env = &cpu->env;\n\n\n\n        if (!cs->halted) {\n\n            rtas_st(rets, 0, -1);\n\n            return;\n\n        }\n\n\n\n        \/* This will make sure qemu state is up to date with kvm, and\n\n         * mark it dirty so our changes get flushed back before the\n\n         * new cpu enters *\/\n\n        kvm_cpu_synchronize_state(cs);\n\n\n\n        env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);\n\n        env->nip = start;\n\n        env->gpr[3] = r3;\n\n        cs->halted = 0;\n\n\n\n        qemu_cpu_kick(cs);\n\n\n\n        rtas_st(rets, 0, 0);\n\n        return;\n\n    }\n\n\n\n    \/* Didn't find a matching cpu *\/\n\n    rtas_st(rets, 0, -3);\n\n}\n","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":434380,"func":"void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt, const char *src)\n{\n  const char *p;\n  char *d;\n  size_t slen;\n  int found = 0;\n\n  slen = mutt_strlen (src);\n  destlen--;\n  \n  for (p = fmt, d = dest; destlen && *p; p++)\n  {\n    if (*p == '%') \n    {\n      switch (p[1])\n      {\n\tcase '%':\n\t  *d++ = *p++;\n\t  destlen--;\n\t  break;\n\tcase 's':\n\t  found = 1;\n\t  strfcpy (d, src, destlen + 1);\n\t  d       += destlen > slen ? slen : destlen;\n\t  destlen -= destlen > slen ? slen : destlen;\n\t  p++;\n\t  break;\n\tdefault:\n\t  *d++ = *p; \n\t  destlen--;\n\t  break;\n      }\n    }\n    else\n    {\n      *d++ = *p;\n      destlen--;\n    }\n  }\n  \n  *d = '\\0';\n  \n  if (!found && destlen > 0)\n  {\n    safe_strcat (dest, destlen, \" \");\n    safe_strcat (dest, destlen, src);\n  }\n  \n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":330319,"func":"static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int flags)\n\n{\n\n    PerThreadContext *p = avctx->thread_opaque;\n\n    int err;\n\n\n\n    f->owner = avctx;\n\n\n\n    ff_init_buffer_info(avctx, f->f);\n\n\n\n    if (!(avctx->active_thread_type & FF_THREAD_FRAME))\n\n        return ff_get_buffer(avctx, f->f, flags);\n\n\n\n    if (p->state != STATE_SETTING_UP &&\n\n        (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&\n\n                avctx->get_buffer != avcodec_default_get_buffer))) {\n\n        av_log(avctx, AV_LOG_ERROR, \"get_buffer() cannot be called after ff_thread_finish_setup()\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (avctx->internal->allocate_progress) {\n\n        int *progress;\n\n        f->progress = av_buffer_alloc(2 * sizeof(int));\n\n        if (!f->progress) {\n\n            return AVERROR(ENOMEM);\n\n        }\n\n        progress = (int*)f->progress->data;\n\n\n\n        progress[0] = progress[1] = -1;\n\n    }\n\n\n\n    pthread_mutex_lock(&p->parent->buffer_mutex);\n\n\n\n    if (avctx->thread_safe_callbacks || (\n\n#if FF_API_GET_BUFFER\n\n        !avctx->get_buffer &&\n\n#endif\n\n        avctx->get_buffer2 == avcodec_default_get_buffer2)) {\n\n        err = ff_get_buffer(avctx, f->f, flags);\n\n    } else {\n\n        pthread_mutex_lock(&p->progress_mutex);\n\n        p->requested_frame = f->f;\n\n        p->requested_flags = flags;\n\n        p->state = STATE_GET_BUFFER;\n\n        pthread_cond_broadcast(&p->progress_cond);\n\n\n\n        while (p->state != STATE_SETTING_UP)\n\n            pthread_cond_wait(&p->progress_cond, &p->progress_mutex);\n\n\n\n        err = p->result;\n\n\n\n        pthread_mutex_unlock(&p->progress_mutex);\n\n\n\n        if (!avctx->codec->update_thread_context)\n\n            ff_thread_finish_setup(avctx);\n\n    }\n\n\n\n    if (err)\n\n        av_buffer_unref(&f->progress);\n\n\n\n    pthread_mutex_unlock(&p->parent->buffer_mutex);\n\n\n\n    return err;\n\n}\n","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":422322,"func":"mail_config_ews_autodiscover_run_thread (GTask *task,\n\t\t\t\t\t gpointer source_object,\n\t\t\t\t\t gpointer task_data,\n\t\t\t\t\t GCancellable *cancellable)\n{\n\tAsyncContext *async_context = task_data;\n\tGError *local_error = NULL;\n\tgboolean success = FALSE;\n\n\tif (!g_cancellable_set_error_if_cancelled (cancellable, &local_error) && !local_error) {\n\t\tgboolean without_password;\n\n\t\twithout_password = e_ews_connection_utils_get_without_password (async_context->ews_settings);\n\t\tif (without_password) {\n\t\t\tsuccess = e_ews_autodiscover_ws_url_sync (async_context->source,\n\t\t\t\tasync_context->ews_settings, async_context->email_address, \"\",\n\t\t\t\t&async_context->certificate_pem, &async_context->certificate_errors,\n\t\t\t\tcancellable, &local_error);\n\t\t}\n\n\t\tif (!without_password || g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) {\n\t\t\tEShell *shell;\n\n\t\t\te_ews_connection_utils_force_off_ntlm_auth_check ();\n\t\t\tg_clear_error (&local_error);\n\n\t\t\tshell = e_shell_get_default ();\n\n\t\t\tsuccess = e_credentials_prompter_loop_prompt_sync (e_shell_get_credentials_prompter (shell),\n\t\t\t\tasync_context->source, E_CREDENTIALS_PROMPTER_PROMPT_FLAG_ALLOW_SOURCE_SAVE,\n\t\t\t\tmail_config_ews_autodiscover_sync, async_context, cancellable, &local_error);\n\t\t}\n\t}\n\n\tif (local_error != NULL) {\n\t\tg_task_return_error (task, local_error);\n\t} else {\n\t\tg_task_return_boolean (task, success);\n\t}\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":325617,"func":"static int probe_file(WriterContext *wctx, const char *filename)\n\n{\n\n    AVFormatContext *fmt_ctx;\n\n    int ret, i;\n\n    int section_id;\n\n\n\n    do_read_frames = do_show_frames || do_count_frames;\n\n    do_read_packets = do_show_packets || do_count_packets;\n\n\n\n    ret = open_input_file(&fmt_ctx, filename);\n\n    if (ret < 0)\n\n        return ret;\n\n\n\n    nb_streams_frames  = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));\n\n    nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));\n\n    selected_streams   = av_calloc(fmt_ctx->nb_streams, sizeof(*selected_streams));\n\n\n\n    for (i = 0; i < fmt_ctx->nb_streams; i++) {\n\n        if (stream_specifier) {\n\n            ret = avformat_match_stream_specifier(fmt_ctx,\n\n                                                  fmt_ctx->streams[i],\n\n                                                  stream_specifier);\n\n            if (ret < 0)\n\n                goto end;\n\n            else\n\n                selected_streams[i] = ret;\n\n            ret = 0;\n\n        } else {\n\n            selected_streams[i] = 1;\n\n        }\n\n    }\n\n\n\n    if (do_read_frames || do_read_packets) {\n\n        if (do_show_frames && do_show_packets &&\n\n            wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER)\n\n            section_id = SECTION_ID_PACKETS_AND_FRAMES;\n\n        else if (do_show_packets && !do_show_frames)\n\n            section_id = SECTION_ID_PACKETS;\n\n        else \/\/ (!do_show_packets && do_show_frames)\n\n            section_id = SECTION_ID_FRAMES;\n\n        if (do_show_frames || do_show_packets)\n\n            writer_print_section_header(wctx, section_id);\n\n        read_packets(wctx, fmt_ctx);\n\n        if (do_show_frames || do_show_packets)\n\n            writer_print_section_footer(wctx);\n\n    }\n\n    if (do_show_programs)\n\n        show_programs(wctx, fmt_ctx);\n\n    if (do_show_streams)\n\n        show_streams(wctx, fmt_ctx);\n\n    if (do_show_chapters)\n\n        show_chapters(wctx, fmt_ctx);\n\n    if (do_show_format)\n\n        show_format(wctx, fmt_ctx);\n\n\n\nend:\n\n    close_input_file(&fmt_ctx);\n\n    av_freep(&nb_streams_frames);\n\n    av_freep(&nb_streams_packets);\n\n    av_freep(&selected_streams);\n\n\n\n    return ret;\n\n}\n","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":341066,"func":"static void vga_get_text_resolution(VGACommonState *s, int *pwidth, int *pheight,\n\n                                    int *pcwidth, int *pcheight)\n\n{\n\n    int width, cwidth, height, cheight;\n\n\n\n    \/* total width & height *\/\n\n    cheight = (s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1;\n\n    cwidth = 8;\n\n    if (!(s->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {\n\n        cwidth = 9;\n\n    }\n\n    if (s->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {\n\n        cwidth = 16; \/* NOTE: no 18 pixel wide *\/\n\n    }\n\n    width = (s->cr[VGA_CRTC_H_DISP] + 1);\n\n    if (s->cr[VGA_CRTC_V_TOTAL] == 100) {\n\n        \/* ugly hack for CGA 160x100x16 - explain me the logic *\/\n\n        height = 100;\n\n    } else {\n\n        height = s->cr[VGA_CRTC_V_DISP_END] |\n\n            ((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) |\n\n            ((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3);\n\n        height = (height + 1) \/ cheight;\n\n    }\n\n\n\n    *pwidth = width;\n\n    *pheight = height;\n\n    *pcwidth = cwidth;\n\n    *pcheight = cheight;\n\n}\n","target":1,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":11080,"func":"standard_display_init(standard_display *dp, png_store* ps, png_uint_32 id,\n int do_interlace, int use_update_info)\n{\n   memset(dp, 0, sizeof *dp);\n\n   dp->ps = ps;\n   dp->colour_type = COL_FROM_ID(id);\n   dp->bit_depth = DEPTH_FROM_ID(id);\n if (dp->bit_depth < 1 || dp->bit_depth > 16)\n      internal_error(ps, \"internal: bad bit depth\");\n if (dp->colour_type == 3)\n      dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT = 8;\n else\n      dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT =\n         dp->bit_depth;\n   dp->interlace_type = INTERLACE_FROM_ID(id);\n   check_interlace_type(dp->interlace_type);\n   dp->id = id;\n \/* All the rest are filled in after the read_info: *\/\n   dp->w = 0;\n   dp->h = 0;\n   dp->npasses = 0;\n   dp->pixel_size = 0;\n\n    dp->bit_width = 0;\n    dp->cbRow = 0;\n    dp->do_interlace = do_interlace;\n    dp->is_transparent = 0;\n    dp->speed = ps->speed;\n    dp->use_update_info = use_update_info;\n   dp->npalette = 0;\n \/* Preset the transparent color to black: *\/\n   memset(&dp->transparent, 0, sizeof dp->transparent);\n \/* Preset the palette to full intensity\/opaque througout: *\/\n   memset(dp->palette, 0xff, sizeof dp->palette);\n}\n","target":1,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":469756,"func":"size_t olm_pk_decrypt(\n    OlmPkDecryption * decryption,\n    void const * ephemeral_key, size_t ephemeral_key_length,\n    void const * mac, size_t mac_length,\n    void * ciphertext, size_t ciphertext_length,\n    void * plaintext, size_t max_plaintext_length\n) {\n    if (max_plaintext_length\n            < olm_pk_max_plaintext_length(decryption, ciphertext_length)) {\n        decryption->last_error =\n            OlmErrorCode::OLM_OUTPUT_BUFFER_TOO_SMALL;\n        return std::size_t(-1);\n    }\n\n    size_t raw_ciphertext_length = olm::decode_base64_length(ciphertext_length);\n\n    if (ephemeral_key_length != olm::encode_base64_length(CURVE25519_KEY_LENGTH)\n        || mac_length != olm::encode_base64_length(MAC_LENGTH)\n        || raw_ciphertext_length == std::size_t(-1)) {\n        decryption->last_error = OlmErrorCode::OLM_INVALID_BASE64;\n        return std::size_t(-1);\n    }\n\n    struct _olm_curve25519_public_key ephemeral;\n    olm::decode_base64(\n        (const uint8_t*)ephemeral_key,\n        olm::encode_base64_length(CURVE25519_KEY_LENGTH),\n        (uint8_t *)ephemeral.public_key\n    );\n\n    olm::SharedKey secret;\n    _olm_crypto_curve25519_shared_secret(&decryption->key_pair, &ephemeral, secret);\n\n    uint8_t raw_mac[MAC_LENGTH];\n    olm::decode_base64(\n        (const uint8_t *)mac,\n        olm::encode_base64_length(MAC_LENGTH),\n        raw_mac\n    );\n\n    olm::decode_base64(\n        (const uint8_t *)ciphertext,\n        ciphertext_length,\n        (uint8_t *)ciphertext\n    );\n\n    size_t result = _olm_cipher_aes_sha_256_ops.decrypt(\n        olm_pk_cipher,\n        secret, sizeof(secret),\n        (uint8_t *) raw_mac, MAC_LENGTH,\n        (const uint8_t *) ciphertext, raw_ciphertext_length,\n        (uint8_t *) plaintext, max_plaintext_length\n    );\n    if (result == std::size_t(-1)) {\n        \/\/ we already checked the buffer sizes, so the only error that decrypt\n        \/\/ will return is if the MAC is incorrect\n        decryption->last_error =\n            OlmErrorCode::OLM_BAD_MESSAGE_MAC;\n        return std::size_t(-1);\n    } else {\n        return result;\n    }\n}","target":0,"code_token_length":566,"total_token_length":802,"max_tokens_setting":1024}
+{"idx":395057,"func":"update_random_seed_file()\n{\n    ulong *sp, *dp;\n    int fd, i;\n\n    if( !seed_file_name || !is_initialized || !pool_filled )\n\treturn;\n    if( !allow_seed_file_update ) {\n\tlog_info(_(\"note: random_seed file not updated\\n\"));\n\treturn;\n    }\n\n\n    \/* copy the entropy pool to a scratch pool and mix both of them *\/\n    for(i=0,dp=(ulong*)keypool, sp=(ulong*)rndpool;\n\t\t\t\t    i < POOLWORDS; i++, dp++, sp++ ) {\n\t*dp = *sp + ADD_VALUE;\n    }\n    mix_pool(rndpool); rndstats.mixrnd++;\n    mix_pool(keypool); rndstats.mixkey++;\n\n#if defined(HAVE_DOSISH_SYSTEM) || defined(__CYGWIN__)\n    fd = open( seed_file_name, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,\n\t\t\t\t\t\t\tS_IRUSR|S_IWUSR );\n#else\n# if LOCK_SEED_FILE\n    fd = open( seed_file_name, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR );\n# else\n#  ifdef __VMS\n    \/* Open the seed file for exclusive write access, but allow other\n     * readers.  Loop until success.  Complain after a few failures.  *\/\n    {\n        int backoff = 0;\n\n        while ((fd = open( seed_file_name,\n                           O_WRONLY|O_CREAT,\n                           S_IRUSR|S_IWUSR,\n                           \"shr=get\")) == -1 )\n        {\n          if ((errno != EVMSERR) || (vaxc$errno != RMS$_FLK))\n            {\n              \/* Some unexpected open failure. *\/\n              log_info (_(\"can't lock `%s': %s\\n\"),\n                        seed_file_name, strerror (errno));\n              return;\n            }\n\n          if (backoff > 2) \/* Show the first message after ~3.75 seconds. *\/\n            log_info( _(\"waiting for lock on `%s'...\\n\"), seed_file_name);\n\n          wait_vms( backoff+ 0.25);\n          if (backoff < 10)\n            backoff++ ;\n        }\n    }\n#  else \/* !def __VMS *\/\n    fd = open( seed_file_name, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR );\n#  endif \/* !def __VMS *\/\n# endif\n#endif\n    if( fd == -1 ) {\n\tlog_info(_(\"can't create `%s': %s\\n\"), seed_file_name, strerror(errno));\n\treturn;\n    }\n\n    if (lock_seed_file (fd, seed_file_name, 1))\n      {\n        close (fd);\n        return;\n      }\n#if LOCK_SEED_FILE\n    if (ftruncate (fd, 0))\n      {\n\tlog_info(_(\"can't write `%s': %s\\n\"), seed_file_name, strerror(errno));\n        close (fd);\n        return;\n      }\n#endif \/*LOCK_SEED_FILE*\/\n\n    do {\n\ti = write( fd, keypool, POOLSIZE );\n    } while( i == -1 && errno == EINTR );\n    if( i != POOLSIZE ) {\n\tlog_info(_(\"can't write `%s': %s\\n\"), seed_file_name, strerror(errno) );\n    }\n    if( close(fd) )\n\tlog_info(_(\"can't close `%s': %s\\n\"), seed_file_name, strerror(errno) );\n}","target":0,"code_token_length":716,"total_token_length":952,"max_tokens_setting":1024}
+{"idx":476279,"func":"bool InstanceKlass::is_same_package_member(const Klass* class2, TRAPS) const {\n  if (class2 == this) return true;\n  if (!class2->is_instance_klass())  return false;\n\n  \/\/ must be in same package before we try anything else\n  if (!is_same_class_package(class2))\n    return false;\n\n  \/\/ As long as there is an outer_this.getEnclosingClass,\n  \/\/ shift the search outward.\n  const InstanceKlass* outer_this = this;\n  for (;;) {\n    \/\/ As we walk along, look for equalities between outer_this and class2.\n    \/\/ Eventually, the walks will terminate as outer_this stops\n    \/\/ at the top-level class around the original class.\n    bool ignore_inner_is_member;\n    const Klass* next = outer_this->compute_enclosing_class(&ignore_inner_is_member,\n                                                            CHECK_false);\n    if (next == NULL)  break;\n    if (next == class2)  return true;\n    outer_this = InstanceKlass::cast(next);\n  }\n\n  \/\/ Now do the same for class2.\n  const InstanceKlass* outer2 = InstanceKlass::cast(class2);\n  for (;;) {\n    bool ignore_inner_is_member;\n    Klass* next = outer2->compute_enclosing_class(&ignore_inner_is_member,\n                                                    CHECK_false);\n    if (next == NULL)  break;\n    \/\/ Might as well check the new outer against all available values.\n    if (next == this)  return true;\n    if (next == outer_this)  return true;\n    outer2 = InstanceKlass::cast(next);\n  }\n\n  \/\/ If by this point we have not found an equality between the\n  \/\/ two classes, we know they are in separate package members.\n  return false;\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":92941,"func":"static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht)\n{\n\n\tIS_CONSISTENT(ht);\n\tHT_ASSERT(GC_REFCOUNT(ht) == 1);\n\n\tif (ht->nNumUsed > ht->nNumOfElements + (ht->nNumOfElements >> 5)) { \/* additional term is there to amortize the cost of compaction *\/\n\t\tHANDLE_BLOCK_INTERRUPTIONS();\n\t\tzend_hash_rehash(ht);\n\t\tHANDLE_UNBLOCK_INTERRUPTIONS();\n\t} else if (ht->nTableSize < HT_MAX_SIZE) {\t\/* Let's double the table size *\/\n\t\tvoid *new_data, *old_data = HT_GET_DATA_ADDR(ht);\n\t\tuint32_t nSize = ht->nTableSize + ht->nTableSize;\n\t\tBucket *old_buckets = ht->arData;\n\n\t\tHANDLE_BLOCK_INTERRUPTIONS();\n\t\tnew_data = pemalloc(HT_SIZE_EX(nSize, -nSize), ht->u.flags & HASH_FLAG_PERSISTENT);\n\t\tht->nTableSize = nSize;\n\t\tht->nTableMask = -ht->nTableSize;\n\t\tHT_SET_DATA_ADDR(ht, new_data);\n\t\tmemcpy(ht->arData, old_buckets, sizeof(Bucket) * ht->nNumUsed);\n\t\tpefree(old_data, ht->u.flags & HASH_FLAG_PERSISTENT);\n\t\tzend_hash_rehash(ht);\n\t\tHANDLE_UNBLOCK_INTERRUPTIONS();\n\t} else {\n\t\tzend_error_noreturn(E_ERROR, \"Possible integer overflow in memory allocation (%zu * %zu + %zu)\", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket));\n\t}\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":72638,"func":"selaDisplayInPix(SELA    *sela,\n                 l_int32  size,\n                 l_int32  gthick,\n                 l_int32  spacing,\n                 l_int32  ncols)\n{\nl_int32  nsels, i, w, width;\nPIX     *pixt, *pixd;\nPIXA    *pixa;\nSEL     *sel;\n\n    PROCNAME(\"selaDisplayInPix\");\n\n    if (!sela)\n        return (PIX *)ERROR_PTR(\"sela not defined\", procName, NULL);\n    if (size < 13) {\n        L_WARNING(\"size < 13; setting to 13\\n\", procName);\n        size = 13;\n    }\n    if (size % 2 == 0)\n        size++;\n    if (gthick < 2) {\n        L_WARNING(\"grid thickness < 2; setting to 2\\n\", procName);\n        gthick = 2;\n    }\n    if (spacing < 5) {\n        L_WARNING(\"spacing < 5; setting to 5\\n\", procName);\n        spacing = 5;\n    }\n\n        \/* Accumulate the pix of each sel *\/\n    nsels = selaGetCount(sela);\n    pixa = pixaCreate(nsels);\n    for (i = 0; i < nsels; i++) {\n        sel = selaGetSel(sela, i);\n        pixt = selDisplayInPix(sel, size, gthick);\n        pixaAddPix(pixa, pixt, L_INSERT);\n    }\n\n        \/* Find the tiled output width, using just the first\n         * ncols pix in the pixa.   If all pix have the same width,\n         * they will align properly in columns. *\/\n    width = 0;\n    ncols = L_MIN(nsels, ncols);\n    for (i = 0; i < ncols; i++) {\n        pixt = pixaGetPix(pixa, i, L_CLONE);\n        pixGetDimensions(pixt, &w, NULL, NULL);\n        width += w;\n        pixDestroy(&pixt);\n    }\n    width += (ncols + 1) * spacing;  \/* add spacing all around as well *\/\n\n    pixd = pixaDisplayTiledInRows(pixa, 1, width, 1.0, 0, spacing, 0);\n    pixaDestroy(&pixa);\n    return pixd;\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":10464,"func":"write_one_file(Image *output, Image *image, int convert_to_8bit)\n{\n if (image->opts & FAST_WRITE)\n      image->image.flags |= PNG_IMAGE_FLAG_FAST;\n\n \n    if (image->opts & USE_STDIO)\n    {\n       FILE *f = tmpfile();\n \n       if (f != NULL)\n       {\n if (png_image_write_to_stdio(&image->image, f, convert_to_8bit,\n            image->buffer+16, (png_int_32)image->stride, image->colormap))\n {\n if (fflush(f) == 0)\n {\n               rewind(f);\n               initimage(output, image->opts, \"tmpfile\", image->stride_extra);\n               output->input_file = f;\n if (!checkopaque(image))\n return 0;\n }\n\n else\n return logclose(image, f, \"tmpfile\", \": flush: \");\n }\n\n else\n {\n            fclose(f);\n return logerror(image, \"tmpfile\", \": write failed\", \"\");\n }\n }\n\n else\n return logerror(image, \"tmpfile\", \": open: \", strerror(errno));\n }\n\n else\n {\n static int counter = 0;\n char name[32];\n\n      sprintf(name, \"%s%d.png\", tmpf, ++counter);\n\n if (png_image_write_to_file(&image->image, name, convert_to_8bit,\n         image->buffer+16, (png_int_32)image->stride, image->colormap))\n {\n         initimage(output, image->opts, output->tmpfile_name,\n            image->stride_extra);\n \/* Afterwards, or freeimage will delete it! *\/\n         strcpy(output->tmpfile_name, name);\n\n if (!checkopaque(image))\n return 0;\n }\n\n else\n return logerror(image, name, \": write failed\", \"\");\n }\n\n \/* 'output' has an initialized temporary image, read this back in and compare\n    * this against the original: there should be no change since the original\n    * format was written unmodified unless 'convert_to_8bit' was specified.\n    * However, if the original image was color-mapped, a simple read will zap\n    * the linear, color and maybe alpha flags, this will cause spurious failures\n    * under some circumstances.\n    *\/\n if (read_file(output, image->image.format | FORMAT_NO_CHANGE, NULL))\n {\n      png_uint_32 original_format = image->image.format;\n\n if (convert_to_8bit)\n         original_format &= ~PNG_FORMAT_FLAG_LINEAR;\n\n if ((output->image.format & BASE_FORMATS) !=\n (original_format & BASE_FORMATS))\n return logerror(image, image->file_name, \": format changed on read: \",\n            output->file_name);\n\n return compare_two_images(image, output, 0\/*via linear*\/, NULL);\n }\n\n else\n return logerror(output, output->tmpfile_name,\n \": read of new file failed\", \"\");\n}\n","target":1,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":128566,"func":"static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,\n    mp_int* r, mp_int* s, byte* out, word32 *outlen, WC_RNG* rng,\n    ecc_key* key)\n{\n    int err;\n\n#ifdef PLUTON_CRYPTO_ECC\n    if (key->devId != INVALID_DEVID) \/* use hardware *\/\n#endif\n    {\n        int keysize = key->dp->size;\n\n        \/* Check args *\/\n        if (keysize > ECC_MAX_CRYPTO_HW_SIZE || inlen != keysize ||\n                                                *outlen < keysize*2) {\n            return ECC_BAD_ARG_E;\n        }\n\n    #if defined(WOLFSSL_ATECC508A)\n        \/* Sign: Result is 32-bytes of R then 32-bytes of S *\/\n        err = atcatls_sign(key->slot, in, out);\n        if (err != ATCA_SUCCESS) {\n           return BAD_COND_E;\n        }\n    #elif defined(PLUTON_CRYPTO_ECC)\n        {\n            \/* perform ECC sign *\/\n            word32 raw_sig_size = *outlen;\n            err = Crypto_EccSign(in, inlen, out, &raw_sig_size);\n            if (err != CRYPTO_RES_SUCCESS || raw_sig_size != keysize*2){\n               return BAD_COND_E;\n            }\n        }\n    #endif\n\n        \/* Load R and S *\/\n        err = mp_read_unsigned_bin(r, &out[0], keysize);\n        if (err != MP_OKAY) {\n            return err;\n        }\n        err = mp_read_unsigned_bin(s, &out[keysize], keysize);\n        if (err != MP_OKAY) {\n            return err;\n        }\n\n        \/* Check for zeros *\/\n        if (mp_iszero(r) || mp_iszero(s)) {\n            return MP_ZERO_E;\n        }\n    }\n#ifdef PLUTON_CRYPTO_ECC\n    else {\n        err = wc_ecc_sign_hash_ex(in, inlen, rng, key, r, s);\n    }\n#endif\n\n    return err;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":491780,"func":"ecma_new_ecma_string_from_number (ecma_number_t num) \/**< ecma-number *\/\n{\n  uint32_t uint32_num = ecma_number_to_uint32 (num);\n  if (num == ((ecma_number_t) uint32_num))\n  {\n    return ecma_new_ecma_string_from_uint32 (uint32_num);\n  }\n\n  if (ecma_number_is_nan (num))\n  {\n    return ecma_get_magic_string (LIT_MAGIC_STRING_NAN);\n  }\n\n  if (ecma_number_is_infinity (num))\n  {\n    lit_magic_string_id_t id = (ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL\n                                                              : LIT_MAGIC_STRING_INFINITY_UL);\n    return ecma_get_magic_string (id);\n  }\n\n  lit_utf8_byte_t str_buf[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];\n  lit_utf8_size_t str_size = ecma_number_to_utf8_string (num, str_buf, sizeof (str_buf));\n\n  JERRY_ASSERT (str_size > 0);\n#ifndef JERRY_NDEBUG\n  JERRY_ASSERT (lit_is_utf8_string_magic (str_buf, str_size) == LIT_MAGIC_STRING__COUNT\n                && lit_is_ex_utf8_string_magic (str_buf, str_size) == lit_get_magic_string_ex_count ());\n#endif \/* !JERRY_NDEBUG *\/\n\n  lit_utf8_byte_t *data_p;\n  ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size),\n                                                                        str_size,\n                                                                        &data_p);\n\n  string_desc_p->u.hash = lit_utf8_string_calc_hash (str_buf, str_size);\n  memcpy (data_p, str_buf, str_size);\n\n  return string_desc_p;\n} \/* ecma_new_ecma_string_from_number *\/","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":139773,"func":"static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,\n\t\t\t       const int buflen, const int acl_type)\n{\n\t__u16 rc = 0;\n\tstruct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data;\n\tposix_acl_xattr_header *local_acl = (posix_acl_xattr_header *)pACL;\n\tint count;\n\tint i;\n\n\tif ((buflen == 0) || (pACL == NULL) || (cifs_acl == NULL))\n\t\treturn 0;\n\n\tcount = posix_acl_xattr_count((size_t)buflen);\n\tcFYI(1, \"setting acl with %d entries from buf of length %d and \"\n\t\t\"version of %d\",\n\t\tcount, buflen, le32_to_cpu(local_acl->a_version));\n\tif (le32_to_cpu(local_acl->a_version) != 2) {\n\t\tcFYI(1, \"unknown POSIX ACL version %d\",\n\t\t     le32_to_cpu(local_acl->a_version));\n\t\treturn 0;\n\t}\n\tcifs_acl->version = cpu_to_le16(1);\n\tif (acl_type == ACL_TYPE_ACCESS)\n\t\tcifs_acl->access_entry_count = cpu_to_le16(count);\n\telse if (acl_type == ACL_TYPE_DEFAULT)\n\t\tcifs_acl->default_entry_count = cpu_to_le16(count);\n\telse {\n\t\tcFYI(1, \"unknown ACL type %d\", acl_type);\n\t\treturn 0;\n\t}\n\tfor (i = 0; i < count; i++) {\n\t\trc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],\n\t\t\t\t\t&local_acl->a_entries[i]);\n\t\tif (rc != 0) {\n\t\t\t\/* ACE not converted *\/\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (rc == 0) {\n\t\trc = (__u16)(count * sizeof(struct cifs_posix_ace));\n\t\trc += sizeof(struct cifs_posix_acl);\n\t\t\/* BB add check to make sure ACL does not overflow SMB *\/\n\t}\n\treturn rc;\n}","target":0,"code_token_length":448,"total_token_length":684,"max_tokens_setting":1024}
+{"idx":119466,"func":"heap_add_entry(struct archive_read *a,\n    struct heap_queue *heap, struct xar_file *file)\n{\n\tuint64_t file_id, parent_id;\n\tint hole, parent;\n\n\t\/* Expand our pending files list as necessary. *\/\n\tif (heap->used >= heap->allocated) {\n\t\tstruct xar_file **new_pending_files;\n\t\tint new_size = heap->allocated * 2;\n\n\t\tif (heap->allocated < 1024)\n\t\t\tnew_size = 1024;\n\t\t\/* Overflow might keep us from growing the list. *\/\n\t\tif (new_size <= heap->allocated) {\n\t\t\tarchive_set_error(&a->archive,\n\t\t\t    ENOMEM, \"Out of memory\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tnew_pending_files = (struct xar_file **)\n\t\t    malloc(new_size * sizeof(new_pending_files[0]));\n\t\tif (new_pending_files == NULL) {\n\t\t\tarchive_set_error(&a->archive,\n\t\t\t    ENOMEM, \"Out of memory\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tmemcpy(new_pending_files, heap->files,\n\t\t    heap->allocated * sizeof(new_pending_files[0]));\n\t\tif (heap->files != NULL)\n\t\t\tfree(heap->files);\n\t\theap->files = new_pending_files;\n\t\theap->allocated = new_size;\n\t}\n\n\tfile_id = file->id;\n\n\t\/*\n\t * Start with hole at end, walk it up tree to find insertion point.\n\t *\/\n\thole = heap->used++;\n\twhile (hole > 0) {\n\t\tparent = (hole - 1)\/2;\n\t\tparent_id = heap->files[parent]->id;\n\t\tif (file_id >= parent_id) {\n\t\t\theap->files[hole] = file;\n\t\t\treturn (ARCHIVE_OK);\n\t\t}\n\t\t\/* Move parent into hole <==> move hole up tree. *\/\n\t\theap->files[hole] = heap->files[parent];\n\t\thole = parent;\n\t}\n\theap->files[0] = file;\n\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":407126,"func":"request_send (const struct request *req, int fd, FILE *warc_tmp)\n{\n  char *request_string, *p;\n  int i, size, write_error;\n\n  \/* Count the request size. *\/\n  size = 0;\n\n  \/* METHOD \" \" ARG \" \" \"HTTP\/1.0\" \"\\r\\n\" *\/\n  size += strlen (req->method) + 1 + strlen (req->arg) + 1 + 8 + 2;\n\n  for (i = 0; i < req->hcount; i++)\n    {\n      struct request_header *hdr = &req->headers[i];\n      \/* NAME \": \" VALUE \"\\r\\n\" *\/\n      size += strlen (hdr->name) + 2 + strlen (hdr->value) + 2;\n    }\n\n  \/* \"\\r\\n\\0\" *\/\n  size += 3;\n\n  p = request_string = xmalloc (size);\n\n  \/* Generate the request. *\/\n\n  APPEND (p, req->method); *p++ = ' ';\n  APPEND (p, req->arg);    *p++ = ' ';\n  memcpy (p, \"HTTP\/1.1\\r\\n\", 10); p += 10;\n\n  for (i = 0; i < req->hcount; i++)\n    {\n      struct request_header *hdr = &req->headers[i];\n      APPEND (p, hdr->name);\n      *p++ = ':', *p++ = ' ';\n      APPEND (p, hdr->value);\n      *p++ = '\\r', *p++ = '\\n';\n    }\n\n  *p++ = '\\r', *p++ = '\\n', *p++ = '\\0';\n  assert (p - request_string == size);\n\n#undef APPEND\n\n  DEBUGP ((\"\\n---request begin---\\n%s---request end---\\n\", request_string));\n\n  \/* Send the request to the server. *\/\n\n  write_error = fd_write (fd, request_string, size - 1, -1);\n  if (write_error < 0)\n    logprintf (LOG_VERBOSE, _(\"Failed writing HTTP request: %s.\\n\"),\n               fd_errstr (fd));\n  else if (warc_tmp != NULL)\n    {\n      \/* Write a copy of the data to the WARC record. *\/\n      int warc_tmp_written = fwrite (request_string, 1, size - 1, warc_tmp);\n      if (warc_tmp_written != size - 1)\n        write_error = -2;\n    }\n  xfree (request_string);\n  return write_error;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":24762,"func":"static int x ( struct vcache * avc , int afun , struct vrequest * areq , \\ struct afs_pdata * ain , struct afs_pdata * aout , \\ afs_ucred_t * * acred ) DECL_PIOCTL ( PGetFID ) ;\n DECL_PIOCTL ( PSetAcl ) ;\n DECL_PIOCTL ( PStoreBehind ) ;\n DECL_PIOCTL ( PGCPAGs ) ;\n DECL_PIOCTL ( PGetAcl ) ;\n DECL_PIOCTL ( PNoop ) ;\n DECL_PIOCTL ( PBogus ) ;\n DECL_PIOCTL ( PGetFileCell ) ;\n DECL_PIOCTL ( PGetWSCell ) ;\n DECL_PIOCTL ( PGetUserCell ) ;\n DECL_PIOCTL ( PSetTokens ) ;\n DECL_PIOCTL ( PGetVolumeStatus ) ;\n DECL_PIOCTL ( PSetVolumeStatus ) ;\n DECL_PIOCTL ( PFlush ) ;\n DECL_PIOCTL ( PNewStatMount ) ;\n DECL_PIOCTL ( PGetTokens ) ;\n DECL_PIOCTL ( PUnlog ) ;\n DECL_PIOCTL ( PMariner ) ;\n DECL_PIOCTL ( PCheckServers ) ;\n DECL_PIOCTL ( PCheckVolNames ) ;\n DECL_PIOCTL ( PCheckAuth ) ;\n DECL_PIOCTL ( PFindVolume ) ;\n DECL_PIOCTL ( PViceAccess ) ;\n DECL_PIOCTL ( PSetCacheSize ) ;\n DECL_PIOCTL ( PGetCacheSize ) ;\n DECL_PIOCTL ( PRemoveCallBack )","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":91822,"func":"static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,\n\t\tvoid *frame, struct net_device *dev, int size_max,\n\t\t__be16 proto, unsigned char *addr)\n{\n\tunion {\n\t\tstruct tpacket_hdr *h1;\n\t\tstruct tpacket2_hdr *h2;\n\t\tvoid *raw;\n\t} ph;\n\tint to_write, offset, len, tp_len, nr_frags, len_max;\n\tstruct socket *sock = po->sk.sk_socket;\n\tstruct page *page;\n\tvoid *data;\n\tint err;\n\n\tph.raw = frame;\n\n\tskb->protocol = proto;\n\tskb->dev = dev;\n\tskb->priority = po->sk.sk_priority;\n\tskb->mark = po->sk.sk_mark;\n\tskb_shinfo(skb)->destructor_arg = ph.raw;\n\n\tswitch (po->tp_version) {\n\tcase TPACKET_V2:\n\t\ttp_len = ph.h2->tp_len;\n\t\tbreak;\n\tdefault:\n\t\ttp_len = ph.h1->tp_len;\n\t\tbreak;\n\t}\n\tif (unlikely(tp_len > size_max)) {\n\t\tpr_err(\"packet size is too long (%d > %d)\\n\", tp_len, size_max);\n\t\treturn -EMSGSIZE;\n\t}\n\n\tskb_reserve(skb, LL_RESERVED_SPACE(dev));\n\tskb_reset_network_header(skb);\n\n\tdata = ph.raw + po->tp_hdrlen - sizeof(struct sockaddr_ll);\n\tto_write = tp_len;\n\n\tif (sock->type == SOCK_DGRAM) {\n\t\terr = dev_hard_header(skb, dev, ntohs(proto), addr,\n\t\t\t\tNULL, tp_len);\n\t\tif (unlikely(err < 0))\n\t\t\treturn -EINVAL;\n\t} else if (dev->hard_header_len) {\n\t\t\/* net device doesn't like empty head *\/\n\t\tif (unlikely(tp_len <= dev->hard_header_len)) {\n\t\t\tpr_err(\"packet size is too short (%d < %d)\\n\",\n\t\t\t       tp_len, dev->hard_header_len);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tskb_push(skb, dev->hard_header_len);\n\t\terr = skb_store_bits(skb, 0, data,\n\t\t\t\tdev->hard_header_len);\n\t\tif (unlikely(err))\n\t\t\treturn err;\n\n\t\tdata += dev->hard_header_len;\n\t\tto_write -= dev->hard_header_len;\n\t}\n\n\terr = -EFAULT;\n\toffset = offset_in_page(data);\n\tlen_max = PAGE_SIZE - offset;\n\tlen = ((to_write > len_max) ? len_max : to_write);\n\n\tskb->data_len = to_write;\n\tskb->len += to_write;\n\tskb->truesize += to_write;\n\tatomic_add(to_write, &po->sk.sk_wmem_alloc);\n\n\twhile (likely(to_write)) {\n\t\tnr_frags = skb_shinfo(skb)->nr_frags;\n\n\t\tif (unlikely(nr_frags >= MAX_SKB_FRAGS)) {\n\t\t\tpr_err(\"Packet exceed the number of skb frags(%lu)\\n\",\n\t\t\t       MAX_SKB_FRAGS);\n\t\t\treturn -EFAULT;\n\t\t}\n\n\t\tpage = pgv_to_page(data);\n\t\tdata += len;\n\t\tflush_dcache_page(page);\n\t\tget_page(page);\n\t\tskb_fill_page_desc(skb, nr_frags, page, offset, len);\n\t\tto_write -= len;\n\t\toffset = 0;\n\t\tlen_max = PAGE_SIZE;\n\t\tlen = ((to_write > len_max) ? len_max : to_write);\n\t}\n\n\treturn tp_len;\n}","target":0,"code_token_length":716,"total_token_length":952,"max_tokens_setting":1024}
+{"idx":37902,"func":"int set_env_passwd(unsigned char* passwd, size_t length)\n{\n\tstruct digest *d = NULL;\n\tunsigned char *passwd_sum;\n\tint ret, hash_len;\n\n\tif (IS_ENABLED(CONFIG_PASSWD_CRYPTO_PBKDF2)) {\n\t\thash_len = PBKDF2_LENGTH;\n\t} else {\n\t\td = digest_alloc(PASSWD_SUM);\n\t\tif (!d)\n\t\t\treturn -EINVAL;\n\n\t\thash_len = digest_length(d);\n\t}\n\n\tpasswd_sum = calloc(hash_len, sizeof(unsigned char));\n\tif (!passwd_sum)\n\t\treturn -ENOMEM;\n\n\tif (IS_ENABLED(CONFIG_PASSWD_CRYPTO_PBKDF2)) {\n\t\tchar *key = passwd_sum + PBKDF2_SALT_LEN;\n\t\tchar *salt = passwd_sum;\n\t\tint keylen = PBKDF2_LENGTH - PBKDF2_SALT_LEN;\n\n\t\tret = get_crypto_bytes(passwd_sum, PBKDF2_SALT_LEN);\n\t\tif (ret) {\n\t\t\tpr_err(\"Can't get random numbers\\n\");\n\t\t\treturn ret;\n\t\t}\n\n\t\tret = pkcs5_pbkdf2_hmac_sha1(passwd, length, salt,\n\t\t\t\tPBKDF2_SALT_LEN, PBKDF2_COUNT, keylen, key);\n\t} else {\n\t\tret = digest_digest(d, passwd, length, passwd_sum);\n\t}\n\tif (ret)\n\t\tgoto err;\n\n\tret = write_env_passwd(passwd_sum, hash_len);\n\nerr:\n\tdigest_free(d);\n\tfree(passwd_sum);\n\n\treturn ret;\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":501497,"func":"iasecc_read_public_key(struct sc_card *card, unsigned type,\n\t\tstruct sc_path *key_path, unsigned ref, unsigned size,\n\t\tunsigned char **out, size_t *out_len)\n{\n\tstruct sc_context *ctx = card->ctx;\n\tstruct iasecc_sdo sdo;\n\tstruct sc_pkcs15_bignum bn[2];\n\tstruct sc_pkcs15_pubkey_rsa rsa_key;\n\tint rv;\n\n\tLOG_FUNC_CALLED(ctx);\n\tif (type != SC_ALGORITHM_RSA)\n\t\tLOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);\n\n\tsc_log(ctx, \"read public kay(ref:%i;size:%i)\", ref, size);\n\n\tmemset(&bn, 0, sizeof bn);\n\tmemset(&sdo, 0, sizeof(sdo));\n\tsdo.sdo_class = IASECC_SDO_CLASS_RSA_PUBLIC;\n\tsdo.sdo_ref  = ref & ~IASECC_OBJECT_REF_LOCAL;\n\n\trv = iasecc_sdo_get_data(card, &sdo);\n\tLOG_TEST_GOTO_ERR(ctx, rv, \"failed to read public key: cannot get RSA SDO data\");\n\n\tif (out)\n\t\t*out = NULL;\n\tif (out_len)\n\t\t*out_len = 0;\n\n\tbn[0].data = (unsigned char *) malloc(sdo.data.pub_key.n.size);\n\tif (!bn[0].data)\n\t\tLOG_TEST_GOTO_ERR(ctx, SC_ERROR_OUT_OF_MEMORY, \"failed to read public key: cannot allocate modulus\");\n\tbn[0].len = sdo.data.pub_key.n.size;\n\tmemcpy(bn[0].data, sdo.data.pub_key.n.value, sdo.data.pub_key.n.size);\n\n\tbn[1].data = (unsigned char *) malloc(sdo.data.pub_key.e.size);\n\tif (!bn[1].data)\n\t\tLOG_TEST_GOTO_ERR(ctx, SC_ERROR_OUT_OF_MEMORY, \"failed to read public key: cannot allocate exponent\");\n\tbn[1].len = sdo.data.pub_key.e.size;\n\tmemcpy(bn[1].data, sdo.data.pub_key.e.value, sdo.data.pub_key.e.size);\n\n\trsa_key.modulus = bn[0];\n\trsa_key.exponent = bn[1];\n\n\trv = sc_pkcs15_encode_pubkey_rsa(ctx, &rsa_key, out, out_len);\n\tLOG_TEST_GOTO_ERR(ctx, rv, \"failed to read public key: cannot encode RSA public key\");\n\n\tif (out && out_len)\n\t\tsc_log(ctx, \"encoded public key: %s\", sc_dump_hex(*out, *out_len));\n\nerr:\n\tif (bn[0].data)\n\t\tfree(bn[0].data);\n\tif (bn[1].data)\n\t\tfree(bn[1].data);\n\n\tiasecc_sdo_free_fields(card, &sdo);\n\n\tLOG_FUNC_RETURN(ctx, SC_SUCCESS);\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":495776,"func":"static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)\n{\n#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \\\n                     CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \\\n                     CONFIG_HEVC_VAAPI_HWACCEL + \\\n                     CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \\\n                     CONFIG_HEVC_VDPAU_HWACCEL)\n    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;\n\n    switch (sps->pix_fmt) {\n    case AV_PIX_FMT_YUV420P:\n    case AV_PIX_FMT_YUVJ420P:\n#if CONFIG_HEVC_DXVA2_HWACCEL\n        *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n#endif\n#if CONFIG_HEVC_D3D11VA_HWACCEL\n        *fmt++ = AV_PIX_FMT_D3D11VA_VLD;\n        *fmt++ = AV_PIX_FMT_D3D11;\n#endif\n#if CONFIG_HEVC_VAAPI_HWACCEL\n        *fmt++ = AV_PIX_FMT_VAAPI;\n#endif\n#if CONFIG_HEVC_VDPAU_HWACCEL\n        *fmt++ = AV_PIX_FMT_VDPAU;\n#endif\n#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL\n        *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;\n#endif\n        break;\n    case AV_PIX_FMT_YUV420P10:\n#if CONFIG_HEVC_DXVA2_HWACCEL\n        *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n#endif\n#if CONFIG_HEVC_D3D11VA_HWACCEL\n        *fmt++ = AV_PIX_FMT_D3D11VA_VLD;\n        *fmt++ = AV_PIX_FMT_D3D11;\n#endif\n#if CONFIG_HEVC_VAAPI_HWACCEL\n        *fmt++ = AV_PIX_FMT_VAAPI;\n#endif\n#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL\n        *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;\n#endif\n        break;\n    }\n\n    *fmt++ = sps->pix_fmt;\n    *fmt = AV_PIX_FMT_NONE;\n\n    return ff_thread_get_format(s->avctx, pix_fmts);\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":69433,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  const TfLiteTensor* input;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context,\n                    GetOutputSafe(context, node, kOutputTensor, &output));\n  const int num_elements = NumElements(input);\n  TF_LITE_ENSURE_EQ(context, num_elements, NumElements(output));\n  switch (input->type) {\n    case kTfLiteInt64:\n      return copyToTensor(context, input->data.i64, output, num_elements);\n    case kTfLiteInt32:\n      return copyToTensor(context, input->data.i32, output, num_elements);\n    case kTfLiteUInt8:\n      return copyToTensor(context, input->data.uint8, output, num_elements);\n    case kTfLiteFloat32:\n      return copyToTensor(context, GetTensorData<float>(input), output,\n                          num_elements);\n    case kTfLiteBool:\n      return copyToTensor(context, input->data.b, output, num_elements);\n    case kTfLiteComplex64:\n      return copyToTensor(\n          context, reinterpret_cast<std::complex<float>*>(input->data.c64),\n          output, num_elements);\n    default:\n      \/\/ Unsupported type.\n      TF_LITE_UNSUPPORTED_TYPE(context, input->type, \"Cast\");\n  }\n  return kTfLiteOk;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":245555,"func":"int tls1_process_heartbeat(SSL *s)\n{\n    unsigned char *p = &s->s3->rrec.data[0], *pl;\n    unsigned short hbtype;\n    unsigned int payload;\n    unsigned int padding = 16;  \/* Use minimum padding *\/\n\n    if (s->msg_callback)\n        s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT,\n                        &s->s3->rrec.data[0], s->s3->rrec.length,\n                        s, s->msg_callback_arg);\n\n    \/* Read type and payload length first *\/\n    if (1 + 2 + 16 > s->s3->rrec.length)\n        return 0;               \/* silently discard *\/\n    hbtype = *p++;\n    n2s(p, payload);\n    if (1 + 2 + payload + 16 > s->s3->rrec.length)\n        return 0;               \/* silently discard per RFC 6520 sec. 4 *\/\n    pl = p;\n\n    if (hbtype == TLS1_HB_REQUEST) {\n        unsigned char *buffer, *bp;\n        int r;\n\n        \/*\n         * Allocate memory for the response, size is 1 bytes message type,\n         * plus 2 bytes payload length, plus payload, plus padding\n         *\/\n        buffer = OPENSSL_malloc(1 + 2 + payload + padding);\n        if (buffer == NULL)\n            return -1;\n        bp = buffer;\n\n        \/* Enter response type, length and copy payload *\/\n        *bp++ = TLS1_HB_RESPONSE;\n        s2n(payload, bp);\n        memcpy(bp, pl, payload);\n        bp += payload;\n        \/* Random padding *\/\n        if (RAND_bytes(bp, padding) <= 0) {\n            OPENSSL_free(buffer);\n            return -1;\n        }\n\n        r = ssl3_write_bytes(s, TLS1_RT_HEARTBEAT, buffer,\n                             3 + payload + padding);\n\n        if (r >= 0 && s->msg_callback)\n            s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT,\n                            buffer, 3 + payload + padding,\n                            s, s->msg_callback_arg);\n\n        OPENSSL_free(buffer);\n\n        if (r < 0)\n            return r;\n    } else if (hbtype == TLS1_HB_RESPONSE) {\n        unsigned int seq;\n\n        \/*\n         * We only send sequence numbers (2 bytes unsigned int), and 16\n         * random bytes, so we just try to read the sequence number\n         *\/\n        n2s(pl, seq);\n\n        if (payload == 18 && seq == s->tlsext_hb_seq) {\n            s->tlsext_hb_seq++;\n            s->tlsext_hb_pending = 0;\n        }\n    }\n\n    return 0;\n}\n","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":353499,"func":"NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)\n{\n\tstatic const char module[] = \"NeXTDecode\";\n\tunsigned char *bp, *op;\n\ttmsize_t cc;\n\tuint8* row;\n\ttmsize_t scanline, n;\n\n\t(void) s;\n\t\/*\n\t * Each scanline is assumed to start off as all\n\t * white (we assume a PhotometricInterpretation\n\t * of ``min-is-black'').\n\t *\/\n\tfor (op = (unsigned char*) buf, cc = occ; cc-- > 0;)\n\t\t*op++ = 0xff;\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n\tcc = tif->tif_rawcc;\n\tscanline = tif->tif_scanlinesize;\n\tif (occ % scanline)\n\t{\n\t\tTIFFErrorExt(tif->tif_clientdata, module, \"Fractional scanlines cannot be read\");\n\t\treturn (0);\n\t}\n\tfor (row = buf; occ > 0; occ -= scanline, row += scanline) {\n\t\tn = *bp++, cc--;\n\t\tswitch (n) {\n\t\tcase LITERALROW:\n\t\t\t\/*\n\t\t\t * The entire scanline is given as literal values.\n\t\t\t *\/\n\t\t\tif (cc < scanline)\n\t\t\t\tgoto bad;\n\t\t\t_TIFFmemcpy(row, bp, scanline);\n\t\t\tbp += scanline;\n\t\t\tcc -= scanline;\n\t\t\tbreak;\n\t\tcase LITERALSPAN: {\n\t\t\ttmsize_t off;\n\t\t\t\/*\n\t\t\t * The scanline has a literal span that begins at some\n\t\t\t * offset.\n\t\t\t *\/\n\t\t\toff = (bp[0] * 256) + bp[1];\n\t\t\tn = (bp[2] * 256) + bp[3];\n\t\t\tif (cc < 4+n || off+n > scanline)\n\t\t\t\tgoto bad;\n\t\t\t_TIFFmemcpy(row+off, bp+4, n);\n\t\t\tbp += 4+n;\n\t\t\tcc -= 4+n;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tuint32 npixels = 0, grey;\n\t\t\tuint32 imagewidth = tif->tif_dir.td_imagewidth;\n            if( isTiled(tif) )\n                imagewidth = tif->tif_dir.td_tilewidth;\n\n\t\t\t\/*\n\t\t\t * The scanline is composed of a sequence of constant\n\t\t\t * color ``runs''.  We shift into ``run mode'' and\n\t\t\t * interpret bytes as codes of the form\n\t\t\t * <color><npixels> until we've filled the scanline.\n\t\t\t *\/\n\t\t\top = row;\n\t\t\tfor (;;) {\n\t\t\t\tgrey = (uint32)((n>>6) & 0x3);\n\t\t\t\tn &= 0x3f;\n\t\t\t\t\/*\n\t\t\t\t * Ensure the run does not exceed the scanline\n\t\t\t\t * bounds, potentially resulting in a security\n\t\t\t\t * issue.\n\t\t\t\t *\/\n\t\t\t\twhile (n-- > 0 && npixels < imagewidth)\n\t\t\t\t\tSETPIXEL(op, grey);\n\t\t\t\tif (npixels >= imagewidth)\n\t\t\t\t\tbreak;\n\t\t\t\tif (cc == 0)\n\t\t\t\t\tgoto bad;\n\t\t\t\tn = *bp++, cc--;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t}\n\ttif->tif_rawcp = (uint8*) bp;\n\ttif->tif_rawcc = cc;\n\treturn (1);\nbad:\n\tTIFFErrorExt(tif->tif_clientdata, module, \"Not enough data for scanline %ld\",\n\t    (long) tif->tif_row);\n\treturn (0);\n}","target":1,"code_token_length":763,"total_token_length":999,"max_tokens_setting":1024}
+{"idx":117987,"func":"add_monitor_path_args (gboolean      use_session_helper,\n                       FlatpakBwrap *bwrap)\n{\n  g_autoptr(AutoFlatpakSessionHelper) session_helper = NULL;\n  g_autofree char *monitor_path = NULL;\n  g_autofree char *pkcs11_socket_path = NULL;\n  g_autoptr(GVariant) session_data = NULL;\n\n  if (use_session_helper)\n    {\n      session_helper =\n        flatpak_session_helper_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,\n                                                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,\n                                                       \"org.freedesktop.Flatpak\",\n                                                       \"\/org\/freedesktop\/Flatpak\/SessionHelper\",\n                                                       NULL, NULL);\n    }\n\n  if (session_helper &&\n      flatpak_session_helper_call_request_session_sync (session_helper,\n                                                        &session_data,\n                                                        NULL, NULL))\n    {\n      if (g_variant_lookup (session_data, \"path\", \"s\", &monitor_path))\n        flatpak_bwrap_add_args (bwrap,\n                                \"--ro-bind\", monitor_path, \"\/run\/host\/monitor\",\n                                \"--symlink\", \"\/run\/host\/monitor\/resolv.conf\", \"\/etc\/resolv.conf\",\n                                \"--symlink\", \"\/run\/host\/monitor\/host.conf\", \"\/etc\/host.conf\",\n                                \"--symlink\", \"\/run\/host\/monitor\/hosts\", \"\/etc\/hosts\",\n                                NULL);\n\n      if (g_variant_lookup (session_data, \"pkcs11-socket\", \"s\", &pkcs11_socket_path))\n        {\n          g_autofree char *sandbox_pkcs11_socket_path = g_strdup_printf (\"\/run\/user\/%d\/p11-kit\/pkcs11\", getuid ());\n          const char *trusted_module_contents =\n            \"# This overrides the runtime p11-kit-trusted module with a client one talking to the trust module on the host\\n\"\n            \"module: p11-kit-client.so\\n\";\n\n          if (flatpak_bwrap_add_args_data (bwrap, \"p11-kit-trust.module\",\n                                           trusted_module_contents, -1,\n                                           \"\/etc\/pkcs11\/modules\/p11-kit-trust.module\", NULL))\n            {\n              flatpak_bwrap_add_args (bwrap,\n                                      \"--ro-bind\", pkcs11_socket_path, sandbox_pkcs11_socket_path,\n                                      NULL);\n              flatpak_bwrap_unset_env (bwrap, \"P11_KIT_SERVER_ADDRESS\");\n            }\n        }\n    }\n  else\n    {\n      if (g_file_test (\"\/etc\/resolv.conf\", G_FILE_TEST_EXISTS))\n        flatpak_bwrap_add_args (bwrap,\n                                \"--ro-bind\", \"\/etc\/resolv.conf\", \"\/etc\/resolv.conf\",\n                                NULL);\n      if (g_file_test (\"\/etc\/host.conf\", G_FILE_TEST_EXISTS))\n        flatpak_bwrap_add_args (bwrap,\n                                \"--ro-bind\", \"\/etc\/host.conf\", \"\/etc\/host.conf\",\n                                NULL);\n      if (g_file_test (\"\/etc\/hosts\", G_FILE_TEST_EXISTS))\n        flatpak_bwrap_add_args (bwrap,\n                                \"--ro-bind\", \"\/etc\/hosts\", \"\/etc\/hosts\",\n                                NULL);\n    }\n}","target":0,"code_token_length":666,"total_token_length":902,"max_tokens_setting":1024}
+{"idx":426878,"func":"  String_Schema_Obj Parser::parse_css_variable_value()\n  {\n    String_Schema_Obj schema = SASS_MEMORY_NEW(String_Schema, pstate);\n    std::vector<char> brackets;\n    while (true) {\n      if (\n        (brackets.empty() && lex< css_variable_top_level_value >(false)) ||\n        (!brackets.empty() && lex< css_variable_value >(false))\n      ) {\n        Token str(lexed);\n        schema->append(SASS_MEMORY_NEW(String_Constant, pstate, str));\n      } else if (Expression_Obj tok = lex_interpolation()) {\n        if (String_Schema* s = Cast<String_Schema>(tok)) {\n          if (s->empty()) break;\n          schema->concat(s);\n        } else {\n          schema->append(tok);\n        }\n      } else if (lex< quoted_string >()) {\n        Expression_Obj tok = parse_string();\n        if (tok.isNull()) break;\n        if (String_Schema* s = Cast<String_Schema>(tok)) {\n          if (s->empty()) break;\n          schema->concat(s);\n        } else {\n          schema->append(tok);\n        }\n      } else if (lex< alternatives< exactly<'('>, exactly<'['>, exactly<'{'> > >()) {\n        const char opening_bracket = *(position - 1);\n        brackets.push_back(opening_bracket);\n        schema->append(SASS_MEMORY_NEW(String_Constant, pstate, std::string(1, opening_bracket)));\n      } else if (const char *match = peek< alternatives< exactly<')'>, exactly<']'>, exactly<'}'> > >()) {\n        if (brackets.empty()) break;\n        const char closing_bracket = *(match - 1);\n        if (brackets.back() != Util::opening_bracket_for(closing_bracket)) {\n          std::string message = \": expected \\\"\";\n          message += Util::closing_bracket_for(brackets.back());\n          message += \"\\\", was \";\n          css_error(\"Invalid CSS\", \" after \", message);\n        }\n        lex< alternatives< exactly<')'>, exactly<']'>, exactly<'}'> > >();\n        schema->append(SASS_MEMORY_NEW(String_Constant, pstate, std::string(1, closing_bracket)));\n        brackets.pop_back();\n      } else {\n        break;\n      }\n    }\n\n    if (!brackets.empty()) {\n      std::string message = \": expected \\\"\";\n      message += Util::closing_bracket_for(brackets.back());\n      message += \"\\\", was \";\n      css_error(\"Invalid CSS\", \" after \", message);\n    }\n\n    if (schema->empty()) return {};\n    return schema.detach();\n  }","target":0,"code_token_length":558,"total_token_length":794,"max_tokens_setting":1024}
+{"idx":514658,"func":"int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {\n  Environment* env = Environment::GetCurrent(args);\n\n  CHECK(args[0]->IsObject());\n  CHECK(args[1]->IsArray());\n\n  Local<Object> req_wrap_obj = args[0].As<Object>();\n  Local<Array> chunks = args[1].As<Array>();\n  bool all_buffers = args[2]->IsTrue();\n\n  size_t count;\n  if (all_buffers)\n    count = chunks->Length();\n  else\n    count = chunks->Length() >> 1;\n\n  MaybeStackBuffer<uv_buf_t, 16> bufs(count);\n\n  size_t storage_size = 0;\n  size_t offset;\n\n  if (!all_buffers) {\n    \/\/ Determine storage size first\n    for (size_t i = 0; i < count; i++) {\n      Local<Value> chunk = chunks->Get(env->context(), i * 2).ToLocalChecked();\n\n      if (Buffer::HasInstance(chunk))\n        continue;\n        \/\/ Buffer chunk, no additional storage required\n\n      \/\/ String chunk\n      Local<String> string = chunk->ToString(env->context()).ToLocalChecked();\n      enum encoding encoding = ParseEncoding(env->isolate(),\n          chunks->Get(env->context(), i * 2 + 1).ToLocalChecked());\n      size_t chunk_size;\n      if (encoding == UTF8 && string->Length() > 65535 &&\n          !StringBytes::Size(env->isolate(), string, encoding).To(&chunk_size))\n        return 0;\n      else if (!StringBytes::StorageSize(env->isolate(), string, encoding)\n                    .To(&chunk_size))\n        return 0;\n      storage_size += chunk_size;\n    }\n\n    if (storage_size > INT_MAX)\n      return UV_ENOBUFS;\n  } else {\n    for (size_t i = 0; i < count; i++) {\n      Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();\n      bufs[i].base = Buffer::Data(chunk);\n      bufs[i].len = Buffer::Length(chunk);\n    }\n  }\n\n  AllocatedBuffer storage;\n  if (storage_size > 0)\n    storage = AllocatedBuffer::AllocateManaged(env, storage_size);\n\n  offset = 0;\n  if (!all_buffers) {\n    for (size_t i = 0; i < count; i++) {\n      Local<Value> chunk = chunks->Get(env->context(), i * 2).ToLocalChecked();\n\n      \/\/ Write buffer\n      if (Buffer::HasInstance(chunk)) {\n        bufs[i].base = Buffer::Data(chunk);\n        bufs[i].len = Buffer::Length(chunk);\n        continue;\n      }\n\n      \/\/ Write string\n      CHECK_LE(offset, storage_size);\n      char* str_storage = storage.data() + offset;\n      size_t str_size = storage.size() - offset;\n\n      Local<String> string = chunk->ToString(env->context()).ToLocalChecked();\n      enum encoding encoding = ParseEncoding(env->isolate(),\n          chunks->Get(env->context(), i * 2 + 1).ToLocalChecked());\n      str_size = StringBytes::Write(env->isolate(),\n                                    str_storage,\n                                    str_size,\n                                    string,\n                                    encoding);\n      bufs[i].base = str_storage;\n      bufs[i].len = str_size;\n      offset += str_size;\n    }\n  }\n\n  StreamWriteResult res = Write(*bufs, count, nullptr, req_wrap_obj);\n  SetWriteResult(res);\n  if (res.wrap != nullptr && storage_size > 0) {\n    res.wrap->SetAllocatedStorage(std::move(storage));\n  }\n  return res.err;\n}","target":0,"code_token_length":772,"total_token_length":1008,"max_tokens_setting":1024}
+{"idx":213485,"func":" void DataReductionProxyConfig::FetchWarmupProbeURL() {\n   DCHECK(thread_checker_.CalledOnValidThread());\n \n  if (params::IsIncludedInHoldbackFieldTrial())\n    return;\n\n   if (!enabled_by_user_) {\n     RecordWarmupURLFetchAttemptEvent(\n         WarmupURLFetchAttemptEvent::kProxyNotEnabledByUser);\n    return;\n  }\n\n  if (!params::FetchWarmupProbeURLEnabled()) {\n    RecordWarmupURLFetchAttemptEvent(\n        WarmupURLFetchAttemptEvent::kWarmupURLFetchingDisabled);\n    return;\n  }\n\n  if (connection_type_ == network::mojom::ConnectionType::CONNECTION_NONE) {\n    RecordWarmupURLFetchAttemptEvent(\n        WarmupURLFetchAttemptEvent::kConnectionTypeNone);\n    return;\n  }\n\n  base::Optional<DataReductionProxyServer> warmup_proxy =\n      GetProxyConnectionToProbe();\n\n  if (!warmup_proxy)\n    return;\n\n  warmup_url_fetch_in_flight_secure_proxy_ = warmup_proxy->IsSecureProxy();\n  warmup_url_fetch_in_flight_core_proxy_ = warmup_proxy->IsCoreProxy();\n\n  size_t previous_attempt_counts = GetWarmupURLFetchAttemptCounts();\n\n  network_properties_manager_->OnWarmupFetchInitiated(\n      warmup_url_fetch_in_flight_secure_proxy_,\n      warmup_url_fetch_in_flight_core_proxy_);\n\n  RecordWarmupURLFetchAttemptEvent(WarmupURLFetchAttemptEvent::kFetchInitiated);\n\n  warmup_url_fetcher_->FetchWarmupURL(previous_attempt_counts,\n                                      warmup_proxy.value());\n}\n","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":126572,"func":"static void ResetCaption()\n{\n\tGF_Event event;\n\tif (display_rti) return;\n\tevent.type = GF_EVENT_SET_CAPTION;\n\tif (is_connected) {\n\t\tchar szName[1024];\n\t\tNetInfoCommand com;\n\n\t\tevent.caption.caption = NULL;\n\t\t\/*get any service info*\/\n\t\tif (!startup_file && gf_term_get_service_info(term, gf_term_get_root_object(term), &com) == GF_OK) {\n\t\t\tstrcpy(szName, \"\");\n\t\t\tif (com.track_info) {\n\t\t\t\tchar szBuf[10];\n\t\t\t\tsprintf(szBuf, \"%02d \", (u32) (com.track_info>>16) );\n\t\t\t\tstrcat(szName, szBuf);\n\t\t\t}\n\t\t\tif (com.artist) {\n\t\t\t\tstrcat(szName, com.artist);\n\t\t\t\tstrcat(szName, \" \");\n\t\t\t}\n\t\t\tif (com.name) {\n\t\t\t\tstrcat(szName, com.name);\n\t\t\t\tstrcat(szName, \" \");\n\t\t\t}\n\t\t\tif (com.album) {\n\t\t\t\tstrcat(szName, \"(\");\n\t\t\t\tstrcat(szName, com.album);\n\t\t\t\tstrcat(szName, \")\");\n\t\t\t}\n\t\t\tif (com.provider) {\n\t\t\t\tstrcat(szName, \"(\");\n\t\t\t\tstrcat(szName, com.provider);\n\t\t\t\tstrcat(szName, \")\");\n\t\t\t}\n\n\t\t\tif (strlen(szName)) event.caption.caption = szName;\n\t\t}\n\t\tif (!event.caption.caption) {\n\t\t\tchar *str = strrchr(the_url, '\\\\');\n\t\t\tif (!str) str = strrchr(the_url, '\/');\n\t\t\tevent.caption.caption = str ? str+1 : the_url;\n\t\t}\n\t} else {\n\t\tevent.caption.caption = \"GPAC MP4Client \" GPAC_FULL_VERSION;\n\t}\n\tgf_term_user_event(term, &event);\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":155537,"func":"static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )\n{\n    const unsigned char *p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl );\n    int major_ver, minor_ver;\n    unsigned char cookie_len;\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> parse hello verify request\" ) );\n\n    \/*\n     * struct {\n     *   ProtocolVersion server_version;\n     *   opaque cookie<0..2^8-1>;\n     * } HelloVerifyRequest;\n     *\/\n    MBEDTLS_SSL_DEBUG_BUF( 3, \"server version\", p, 2 );\n    mbedtls_ssl_read_version( &major_ver, &minor_ver, ssl->conf->transport, p );\n    p += 2;\n\n    \/*\n     * Since the RFC is not clear on this point, accept DTLS 1.0 (TLS 1.1)\n     * even is lower than our min version.\n     *\/\n    if( major_ver < MBEDTLS_SSL_MAJOR_VERSION_3 ||\n        minor_ver < MBEDTLS_SSL_MINOR_VERSION_2 ||\n        major_ver > ssl->conf->max_major_ver  ||\n        minor_ver > ssl->conf->max_minor_ver  )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server version\" ) );\n\n        mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n                                     MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION );\n\n        return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION );\n    }\n\n    cookie_len = *p++;\n    MBEDTLS_SSL_DEBUG_BUF( 3, \"cookie\", p, cookie_len );\n\n    if( ( ssl->in_msg + ssl->in_msglen ) - p < cookie_len )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1,\n            ( \"cookie length does not match incoming message size\" ) );\n        mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n                                    MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );\n        return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );\n    }\n\n    mbedtls_free( ssl->handshake->verify_cookie );\n\n    ssl->handshake->verify_cookie = mbedtls_calloc( 1, cookie_len );\n    if( ssl->handshake->verify_cookie  == NULL )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"alloc failed (%d bytes)\", cookie_len ) );\n        return( MBEDTLS_ERR_SSL_ALLOC_FAILED );\n    }\n\n    memcpy( ssl->handshake->verify_cookie, p, cookie_len );\n    ssl->handshake->verify_cookie_len = cookie_len;\n\n    \/* Start over at ClientHello *\/\n    ssl->state = MBEDTLS_SSL_CLIENT_HELLO;\n    mbedtls_ssl_reset_checksum( ssl );\n\n    mbedtls_ssl_recv_flight_completed( ssl );\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= parse hello verify request\" ) );\n\n    return( 0 );\n}","target":0,"code_token_length":608,"total_token_length":844,"max_tokens_setting":1024}
+{"idx":36108,"func":"find_next_completion_match(\n\tint\tallow_get_expansion,\n\tint\ttodo,\t\t\/\/ repeat completion this many times\n\tint\tadvance,\n\tint\t*num_matches)\n{\n    int\t    found_end = FALSE;\n    compl_T *found_compl = NULL;\n\n    while (--todo >= 0)\n    {\n\tif (compl_shows_dir_forward() && compl_shown_match->cp_next != NULL)\n\t{\n\t    compl_shown_match = compl_shown_match->cp_next;\n\t    found_end = (compl_first_match != NULL\n\t\t    && (is_first_match(compl_shown_match->cp_next)\n\t\t\t|| is_first_match(compl_shown_match)));\n\t}\n\telse if (compl_shows_dir_backward()\n\t\t&& compl_shown_match->cp_prev != NULL)\n\t{\n\t    found_end = is_first_match(compl_shown_match);\n\t    compl_shown_match = compl_shown_match->cp_prev;\n\t    found_end |= is_first_match(compl_shown_match);\n\t}\n\telse\n\t{\n\t    if (!allow_get_expansion)\n\t    {\n\t\tif (advance)\n\t\t{\n\t\t    if (compl_shows_dir_backward())\n\t\t\tcompl_pending -= todo + 1;\n\t\t    else\n\t\t\tcompl_pending += todo + 1;\n\t\t}\n\t\treturn -1;\n\t    }\n\n\t    if (!compl_no_select && advance)\n\t    {\n\t\tif (compl_shows_dir_backward())\n\t\t    --compl_pending;\n\t\telse\n\t\t    ++compl_pending;\n\t    }\n\n\t    \/\/ Find matches.\n\t    *num_matches = ins_compl_get_exp(&compl_startpos);\n\n\t    \/\/ handle any pending completions\n\t    while (compl_pending != 0 && compl_direction == compl_shows_dir\n\t\t    && advance)\n\t    {\n\t\tif (compl_pending > 0 && compl_shown_match->cp_next != NULL)\n\t\t{\n\t\t    compl_shown_match = compl_shown_match->cp_next;\n\t\t    --compl_pending;\n\t\t}\n\t\tif (compl_pending < 0 && compl_shown_match->cp_prev != NULL)\n\t\t{\n\t\t    compl_shown_match = compl_shown_match->cp_prev;\n\t\t    ++compl_pending;\n\t\t}\n\t\telse\n\t\t    break;\n\t    }\n\t    found_end = FALSE;\n\t}\n\tif (!match_at_original_text(compl_shown_match)\n\t\t&& compl_leader != NULL\n\t\t&& !ins_compl_equal(compl_shown_match,\n\t\t    compl_leader, (int)STRLEN(compl_leader)))\n\t    ++todo;\n\telse\n\t    \/\/ Remember a matching item.\n\t    found_compl = compl_shown_match;\n\n\t\/\/ Stop at the end of the list when we found a usable match.\n\tif (found_end)\n\t{\n\t    if (found_compl != NULL)\n\t    {\n\t\tcompl_shown_match = found_compl;\n\t\tbreak;\n\t    }\n\t    todo = 1;\t    \/\/ use first usable match after wrapping around\n\t}\n    }\n\n    return OK;\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":446635,"func":"virDomainStorageSourceParse(xmlNodePtr node,\n                            xmlXPathContextPtr ctxt,\n                            virStorageSourcePtr src,\n                            unsigned int flags,\n                            virDomainXMLOptionPtr xmlopt)\n{\n    VIR_XPATH_NODE_AUTORESTORE(ctxt);\n    xmlNodePtr tmp;\n\n    ctxt->node = node;\n\n    switch ((virStorageType)src->type) {\n    case VIR_STORAGE_TYPE_FILE:\n        src->path = virXMLPropString(node, \"file\");\n        break;\n    case VIR_STORAGE_TYPE_BLOCK:\n        src->path = virXMLPropString(node, \"dev\");\n        break;\n    case VIR_STORAGE_TYPE_DIR:\n        src->path = virXMLPropString(node, \"dir\");\n        break;\n    case VIR_STORAGE_TYPE_NETWORK:\n        if (virDomainDiskSourceNetworkParse(node, ctxt, src, flags) < 0)\n            return -1;\n        break;\n    case VIR_STORAGE_TYPE_VOLUME:\n        if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0)\n            return -1;\n        break;\n    case VIR_STORAGE_TYPE_NVME:\n        if (virDomainDiskSourceNVMeParse(node, ctxt, src) < 0)\n            return -1;\n        break;\n    case VIR_STORAGE_TYPE_NONE:\n    case VIR_STORAGE_TYPE_LAST:\n        virReportError(VIR_ERR_INTERNAL_ERROR,\n                       _(\"unexpected disk type %s\"),\n                       virStorageTypeToString(src->type));\n        return -1;\n    }\n\n    if ((tmp = virXPathNode(\".\/auth\", ctxt)) &&\n        !(src->auth = virStorageAuthDefParse(tmp, ctxt)))\n        return -1;\n\n    if ((tmp = virXPathNode(\".\/encryption\", ctxt)) &&\n        !(src->encryption = virStorageEncryptionParseNode(tmp, ctxt)))\n        return -1;\n\n    if (virDomainDiskSourcePRParse(node, ctxt, &src->pr) < 0)\n        return -1;\n\n    if (virDomainStorageSourceParseSlices(src, ctxt) < 0)\n        return -1;\n\n    if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabels,\n                                          ctxt, flags) < 0)\n        return -1;\n\n    \/* People sometimes pass a bogus '' source path when they mean to omit the\n     * source element completely (e.g. CDROM without media). This is just a\n     * little compatibility check to help those broken apps *\/\n    if (src->path && !*src->path)\n        VIR_FREE(src->path);\n\n    if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&\n        xmlopt && xmlopt->privateData.storageParse &&\n        (tmp = virXPathNode(\".\/privateData\", ctxt))) {\n        ctxt->node = tmp;\n\n        if (xmlopt->privateData.storageParse(ctxt, src) < 0)\n            return -1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":612,"total_token_length":848,"max_tokens_setting":1024}
+{"idx":309484,"func":"long ContentEncoding::ParseEncryptionEntry(long long start, long long size,\n IMkvReader* pReader,\n ContentEncryption* encryption) {\n  assert(pReader);\n  assert(encryption);\n\n long long pos = start;\n const long long stop = start + size;\n\n while (pos < stop) {\n long long id, size;\n const long status = ParseElementHeader(pReader, pos, stop, id, size);\n if (status < 0) \/\/ error\n return status;\n\n if (id == 0x7E1) {\n      encryption->algo = UnserializeUInt(pReader, pos, size);\n if (encryption->algo != 5)\n\n         return E_FILE_FORMAT_INVALID;\n     } else if (id == 0x7E2) {\n      delete[] encryption->key_id;\n       encryption->key_id = NULL;\n       encryption->key_id_len = 0;\n \n if (size <= 0)\n\n         return E_FILE_FORMAT_INVALID;\n \n       const size_t buflen = static_cast<size_t>(size);\n      unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen);\n       if (buf == NULL)\n         return -1;\n \n const int read_status =\n          pReader->Read(pos, static_cast<long>(buflen), buf);\n if (read_status) {\n delete[] buf;\n return status;\n }\n\n      encryption->key_id = buf;\n\n       encryption->key_id_len = buflen;\n     } else if (id == 0x7E3) {\n      delete[] encryption->signature;\n       encryption->signature = NULL;\n       encryption->signature_len = 0;\n \n if (size <= 0)\n\n         return E_FILE_FORMAT_INVALID;\n \n       const size_t buflen = static_cast<size_t>(size);\n      unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen);\n       if (buf == NULL)\n         return -1;\n \n const int read_status =\n          pReader->Read(pos, static_cast<long>(buflen), buf);\n if (read_status) {\n delete[] buf;\n return status;\n }\n\n      encryption->signature = buf;\n\n       encryption->signature_len = buflen;\n     } else if (id == 0x7E4) {\n      delete[] encryption->sig_key_id;\n       encryption->sig_key_id = NULL;\n       encryption->sig_key_id_len = 0;\n \n if (size <= 0)\n\n         return E_FILE_FORMAT_INVALID;\n \n       const size_t buflen = static_cast<size_t>(size);\n      unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen);\n       if (buf == NULL)\n         return -1;\n \n const int read_status =\n          pReader->Read(pos, static_cast<long>(buflen), buf);\n if (read_status) {\n delete[] buf;\n return status;\n }\n\n      encryption->sig_key_id = buf;\n      encryption->sig_key_id_len = buflen;\n } else if (id == 0x7E5) {\n      encryption->sig_algo = UnserializeUInt(pReader, pos, size);\n } else if (id == 0x7E6) {\n      encryption->sig_hash_algo = UnserializeUInt(pReader, pos, size);\n } else if (id == 0x7E7) {\n const long status = ParseContentEncAESSettingsEntry(\n          pos, size, pReader, &encryption->aes_settings);\n if (status)\n return status;\n\n     }\n \n     pos += size;  \/\/ consume payload\n    if (pos > stop)\n      return E_FILE_FORMAT_INVALID;\n   }\n \n   return 0;\n}\n","target":0,"code_token_length":737,"total_token_length":973,"max_tokens_setting":1024}
+{"idx":349261,"func":"bool MasteringMetadata::Write(IMkvWriter* writer) const {\n  const uint64_t size = PayloadSize();\n\n  \/\/ Don't write an empty element.\n  if (size == 0)\n    return true;\n\n  if (!WriteEbmlMasterElement(writer, libwebm::kMkvMasteringMetadata, size))\n    return false;\n  if (luminance_max_ != kValueNotPresent &&\n      !WriteEbmlElement(writer, libwebm::kMkvLuminanceMax, luminance_max_)) {\n    return false;\n  }\n  if (luminance_min_ != kValueNotPresent &&\n      !WriteEbmlElement(writer, libwebm::kMkvLuminanceMin, luminance_min_)) {\n    return false;\n  }\n  if (r_ &&\n      !r_->Write(writer, libwebm::kMkvPrimaryRChromaticityX,\n                 libwebm::kMkvPrimaryRChromaticityY)) {\n    return false;\n  }\n  if (g_ &&\n      !g_->Write(writer, libwebm::kMkvPrimaryGChromaticityX,\n                 libwebm::kMkvPrimaryGChromaticityY)) {\n    return false;\n  }\n  if (b_ &&\n      !b_->Write(writer, libwebm::kMkvPrimaryBChromaticityX,\n                 libwebm::kMkvPrimaryBChromaticityY)) {\n    return false;\n  }\n  if (white_point_ &&\n      !white_point_->Write(writer, libwebm::kMkvWhitePointChromaticityX,\n                           libwebm::kMkvWhitePointChromaticityY)) {\n    return false;\n  }\n\n  return true;\n}","target":1,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":423436,"func":"zone_check_mx(dns_zone_t *zone, dns_db_t *db, dns_name_t *name,\n\t      dns_name_t *owner)\n{\n\tisc_result_t result;\n\tchar ownerbuf[DNS_NAME_FORMATSIZE];\n\tchar namebuf[DNS_NAME_FORMATSIZE];\n\tchar altbuf[DNS_NAME_FORMATSIZE];\n\tdns_fixedname_t fixed;\n\tdns_name_t *foundname;\n\tint level;\n\n\t\/*\n\t * \".\" means the services does not exist.\n\t *\/\n\tif (dns_name_equal(name, dns_rootname))\n\t\treturn (true);\n\n\t\/*\n\t * Outside of zone.\n\t *\/\n\tif (!dns_name_issubdomain(name, &zone->origin)) {\n\t\tif (zone->checkmx != NULL)\n\t\t\treturn ((zone->checkmx)(zone, name, owner));\n\t\treturn (true);\n\t}\n\n\tif (zone->type == dns_zone_master)\n\t\tlevel = ISC_LOG_ERROR;\n\telse\n\t\tlevel = ISC_LOG_WARNING;\n\n\tfoundname = dns_fixedname_initname(&fixed);\n\n\tresult = dns_db_find(db, name, NULL, dns_rdatatype_a,\n\t\t\t     0, 0, NULL, foundname, NULL, NULL);\n\tif (result == ISC_R_SUCCESS)\n\t\treturn (true);\n\n\tif (result == DNS_R_NXRRSET) {\n\t\tresult = dns_db_find(db, name, NULL, dns_rdatatype_aaaa,\n\t\t\t\t     0, 0, NULL, foundname, NULL, NULL);\n\t\tif (result == ISC_R_SUCCESS)\n\t\t\treturn (true);\n\t}\n\n\tdns_name_format(owner, ownerbuf, sizeof ownerbuf);\n\tdns_name_format(name, namebuf, sizeof namebuf);\n\tif (result == DNS_R_NXRRSET || result == DNS_R_NXDOMAIN ||\n\t    result == DNS_R_EMPTYNAME) {\n\t\tif (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKMXFAIL))\n\t\t\tlevel = ISC_LOG_WARNING;\n\t\tdns_zone_log(zone, level,\n\t\t\t     \"%s\/MX '%s' has no address records (A or AAAA)\",\n\t\t\t     ownerbuf, namebuf);\n\t\treturn ((level == ISC_LOG_WARNING) ? true : false);\n\t}\n\n\tif (result == DNS_R_CNAME) {\n\t\tif (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_WARNMXCNAME) ||\n\t\t    DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME))\n\t\t\tlevel = ISC_LOG_WARNING;\n\t\tif (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME))\n\t\t\tdns_zone_log(zone, level,\n\t\t\t\t     \"%s\/MX '%s' is a CNAME (illegal)\",\n\t\t\t\t     ownerbuf, namebuf);\n\t\treturn ((level == ISC_LOG_WARNING) ? true : false);\n\t}\n\n\tif (result == DNS_R_DNAME) {\n\t\tif (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_WARNMXCNAME) ||\n\t\t    DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME))\n\t\t\tlevel = ISC_LOG_WARNING;\n\t\tif (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME)) {\n\t\t\tdns_name_format(foundname, altbuf, sizeof altbuf);\n\t\t\tdns_zone_log(zone, level, \"%s\/MX '%s' is below a DNAME\"\n\t\t\t\t     \" '%s' (illegal)\", ownerbuf, namebuf,\n\t\t\t\t     altbuf);\n\t\t}\n\t\treturn ((level == ISC_LOG_WARNING) ? true : false);\n\t}\n\n\tif (zone->checkmx != NULL && result == DNS_R_DELEGATION)\n\t\treturn ((zone->checkmx)(zone, name, owner));\n\n\treturn (true);\n}","target":0,"code_token_length":724,"total_token_length":960,"max_tokens_setting":1024}
+{"idx":468441,"func":"virNodeDevCapMdevTypesParseXML(xmlXPathContextPtr ctxt,\n                               virMediatedDeviceTypePtr **mdev_types,\n                               size_t *nmdev_types)\n{\n    int ret = -1;\n    xmlNodePtr orignode = NULL;\n    xmlNodePtr *nodes = NULL;\n    int ntypes = -1;\n    virMediatedDeviceTypePtr type = NULL;\n    size_t i;\n\n    if ((ntypes = virXPathNodeSet(\".\/type\", ctxt, &nodes)) < 0)\n        goto cleanup;\n\n    if (nmdev_types == 0) {\n        virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                       _(\"missing <type> element in <capability> element\"));\n        goto cleanup;\n    }\n\n    orignode = ctxt->node;\n    for (i = 0; i < ntypes; i++) {\n        ctxt->node = nodes[i];\n\n        type = g_new0(virMediatedDeviceType, 1);\n\n        if (!(type->id = virXPathString(\"string(.\/@id[1])\", ctxt))) {\n            virReportError(VIR_ERR_XML_ERROR, \"%s\",\n                           _(\"missing 'id' attribute for mediated device's \"\n                             \"<type> element\"));\n            goto cleanup;\n        }\n\n        if (!(type->device_api = virXPathString(\"string(.\/deviceAPI[1])\", ctxt))) {\n            virReportError(VIR_ERR_XML_ERROR,\n                           _(\"missing device API for mediated device type '%s'\"),\n                           type->id);\n            goto cleanup;\n        }\n\n        if (virXPathUInt(\"number(.\/availableInstances)\", ctxt,\n                         &type->available_instances) < 0) {\n            virReportError(VIR_ERR_XML_ERROR,\n                           _(\"missing number of available instances for \"\n                             \"mediated device type '%s'\"),\n                           type->id);\n            goto cleanup;\n        }\n\n        type->name = virXPathString(\"string(.\/name)\", ctxt);\n\n        if (VIR_APPEND_ELEMENT(*mdev_types,\n                               *nmdev_types, type) < 0)\n            goto cleanup;\n    }\n\n    ret = 0;\n cleanup:\n    VIR_FREE(nodes);\n    virMediatedDeviceTypeFree(type);\n    ctxt->node = orignode;\n    return ret;\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":327704,"func":"static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic,\n\n                                const uint8_t *src, int src_size)\n\n{\n\n    GetByteContext gb;\n\n    GetBitContext  gb2;\n\n    int nslices, slice, slice_height;\n\n    uint32_t off, slice_size;\n\n    uint8_t *dst;\n\n    int ret;\n\n\n\n    bytestream2_init(&gb, src, src_size);\n\n    nslices = bytestream2_get_le16(&gb);\n\n    off = FFALIGN(nslices * 4 + 2, 16);\n\n    if (src_size < off) {\n\n        av_log(avctx, AV_LOG_ERROR, \"no slice data\\n\");\n\n        return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    if (!nslices || avctx->height % nslices) {\n\n        avpriv_request_sample(avctx, \"%d slices for %dx%d\", nslices,\n\n                              avctx->width, avctx->height);\n\n        return AVERROR_PATCHWELCOME;\n\n    }\n\n\n\n    slice_height = avctx->height \/ nslices;\n\n    avctx->pix_fmt = AV_PIX_FMT_BGR24;\n\n    if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)\n\n        return ret;\n\n\n\n    dst = pic->data[0];\n\n    for (slice = 0; slice < nslices; slice++) {\n\n        slice_size = bytestream2_get_le32(&gb);\n\n        if (slice_size > src_size - off) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"invalid slice size %\"PRIu32\" (only %\"PRIu32\" bytes left)\\n\",\n\n                   slice_size, src_size - off);\n\n            return AVERROR_INVALIDDATA;\n\n        }\n\n        if (slice_size <= 16) {\n\n            av_log(avctx, AV_LOG_ERROR, \"invalid slice size %\"PRIu32\"\\n\",\n\n                   slice_size);\n\n            return AVERROR_INVALIDDATA;\n\n        }\n\n\n\n        if (AV_RL32(src + off) != slice_size - 16) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"Slice sizes mismatch: got %\"PRIu32\" instead of %\"PRIu32\"\\n\",\n\n                   AV_RL32(src + off), slice_size - 16);\n\n        }\n\n        init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);\n\n        dx2_decode_slice_rgb(&gb2, avctx->width, slice_height, dst,\n\n                             pic->linesize[0]);\n\n\n\n        dst += pic->linesize[0] * slice_height;\n\n        off += slice_size;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":201773,"func":"void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg)\n{\n\tstruct proxy *fe = strm_fe(s);\n\tint tmp = TX_CON_WANT_KAL;\n\n\tif (!((fe->options2|s->be->options2) & PR_O2_FAKE_KA)) {\n\t\tif ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN ||\n\t\t    (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN)\n\t\t\ttmp = TX_CON_WANT_TUN;\n\n\t\tif ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||\n\t\t    (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)\n\t\t\ttmp = TX_CON_WANT_TUN;\n\t}\n\n\tif ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL ||\n\t    (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL) {\n\t\t\/* option httpclose + server_close => forceclose *\/\n\t\tif ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||\n\t\t    (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)\n\t\t\ttmp = TX_CON_WANT_CLO;\n\t\telse\n\t\t\ttmp = TX_CON_WANT_SCL;\n\t}\n\n\tif ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL ||\n\t    (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL)\n\t\ttmp = TX_CON_WANT_CLO;\n\n\tif ((txn->flags & TX_CON_WANT_MSK) < tmp)\n\t\ttxn->flags = (txn->flags & ~TX_CON_WANT_MSK) | tmp;\n\n\tif (!(txn->flags & TX_HDR_CONN_PRS) &&\n\t    (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) {\n\t\t\/* parse the Connection header and possibly clean it *\/\n\t\tint to_del = 0;\n\t\tif ((msg->flags & HTTP_MSGF_VER_11) ||\n\t\t    ((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL &&\n\t\t     !((fe->options2|s->be->options2) & PR_O2_FAKE_KA)))\n\t\t\tto_del |= 2; \/* remove \"keep-alive\" *\/\n\t\tif (!(msg->flags & HTTP_MSGF_VER_11))\n\t\t\tto_del |= 1; \/* remove \"close\" *\/\n\t\thttp_parse_connection_header(txn, msg, to_del);\n\t}\n\n\t\/* check if client or config asks for explicit close in KAL\/SCL *\/\n\tif (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL ||\n\t     (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) &&\n\t    ((txn->flags & TX_HDR_CONN_CLO) ||                         \/* \"connection: close\" *\/\n\t     (!(msg->flags & HTTP_MSGF_VER_11) && !(txn->flags & TX_HDR_CONN_KAL)) || \/* no \"connection: k-a\" in 1.0 *\/\n\t     !(msg->flags & HTTP_MSGF_XFER_LEN) ||                     \/* no length known => close *\/\n\t     fe->state == PR_STSTOPPED))                            \/* frontend is stopping *\/\n\t\ttxn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO;\n}\n","target":0,"code_token_length":713,"total_token_length":949,"max_tokens_setting":1024}
+{"idx":461070,"func":"static MemTxResult gic_hyp_read(void *opaque, int cpu, hwaddr addr,\n                                uint64_t *data, MemTxAttrs attrs)\n{\n    GICState *s = ARM_GIC(opaque);\n    int vcpu = cpu + GIC_NCPU;\n\n    switch (addr) {\n    case A_GICH_HCR: \/* Hypervisor Control *\/\n        *data = s->h_hcr[cpu];\n        break;\n\n    case A_GICH_VTR: \/* VGIC Type *\/\n        *data = FIELD_DP32(0, GICH_VTR, ListRegs, s->num_lrs - 1);\n        *data = FIELD_DP32(*data, GICH_VTR, PREbits,\n                           GIC_VIRT_MAX_GROUP_PRIO_BITS - 1);\n        *data = FIELD_DP32(*data, GICH_VTR, PRIbits,\n                           (7 - GIC_VIRT_MIN_BPR) - 1);\n        break;\n\n    case A_GICH_VMCR: \/* Virtual Machine Control *\/\n        *data = FIELD_DP32(0, GICH_VMCR, VMCCtlr,\n                           extract32(s->cpu_ctlr[vcpu], 0, 10));\n        *data = FIELD_DP32(*data, GICH_VMCR, VMABP, s->abpr[vcpu]);\n        *data = FIELD_DP32(*data, GICH_VMCR, VMBP, s->bpr[vcpu]);\n        *data = FIELD_DP32(*data, GICH_VMCR, VMPriMask,\n                           extract32(s->priority_mask[vcpu], 3, 5));\n        break;\n\n    case A_GICH_MISR: \/* Maintenance Interrupt Status *\/\n        *data = s->h_misr[cpu];\n        break;\n\n    case A_GICH_EISR0: \/* End of Interrupt Status 0 and 1 *\/\n    case A_GICH_EISR1:\n        *data = gic_compute_eisr(s, cpu, (addr - A_GICH_EISR0) * 8);\n        break;\n\n    case A_GICH_ELRSR0: \/* Empty List Status 0 and 1 *\/\n    case A_GICH_ELRSR1:\n        *data = gic_compute_elrsr(s, cpu, (addr - A_GICH_ELRSR0) * 8);\n        break;\n\n    case A_GICH_APR: \/* Active Priorities *\/\n        *data = s->h_apr[cpu];\n        break;\n\n    case A_GICH_LR0 ... A_GICH_LR63: \/* List Registers *\/\n    {\n        int lr_idx = (addr - A_GICH_LR0) \/ 4;\n\n        if (lr_idx > s->num_lrs) {\n            *data = 0;\n        } else {\n            *data = s->h_lr[lr_idx][cpu];\n        }\n        break;\n    }\n\n    default:\n        qemu_log_mask(LOG_GUEST_ERROR,\n                      \"gic_hyp_read: Bad offset %\" HWADDR_PRIx \"\\n\", addr);\n        return MEMTX_OK;\n    }\n\n    trace_gic_hyp_read(addr, *data);\n    return MEMTX_OK;\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":485861,"func":"sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep,\n\t\t\t\t\t   const struct sctp_association *asoc,\n\t\t\t\t\t   const sctp_subtype_t type,\n\t\t\t\t\t   void *arg,\n\t\t\t\t\t   sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tsctp_shutdownhdr_t *sdh;\n\tsctp_disposition_t disposition;\n\tstruct sctp_ulpevent *ev;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the SHUTDOWN chunk has a valid length. *\/\n\tif (!sctp_chunk_length_valid(chunk,\n\t\t\t\t      sizeof(struct sctp_shutdown_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\t\/* Convert the elaborate header.  *\/\n\tsdh = (sctp_shutdownhdr_t *)chunk->skb->data;\n\tskb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t));\n\tchunk->subh.shutdown_hdr = sdh;\n\n\t\/* API 5.3.1.5 SCTP_SHUTDOWN_EVENT\n\t * When a peer sends a SHUTDOWN, SCTP delivers this notification to\n\t * inform the application that it should cease sending data.\n\t *\/\n\tev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC);\n\tif (!ev) {\n\t\tdisposition = SCTP_DISPOSITION_NOMEM;\n\t\tgoto out;\t\n\t}\n\tsctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));\n\n\t\/* Upon the reception of the SHUTDOWN, the peer endpoint shall\n\t *  - enter the SHUTDOWN-RECEIVED state,\n\t *  - stop accepting new data from its SCTP user\n\t *\n\t * [This is implicit in the new state.]\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,\n\t\t\tSCTP_STATE(SCTP_STATE_SHUTDOWN_RECEIVED));\n\tdisposition = SCTP_DISPOSITION_CONSUME;\n\n\tif (sctp_outq_is_empty(&asoc->outqueue)) {\n\t\tdisposition = sctp_sf_do_9_2_shutdown_ack(ep, asoc, type,\n\t\t\t\t\t\t\t  arg, commands);\n\t}\n\n\tif (SCTP_DISPOSITION_NOMEM == disposition)\n\t\tgoto out;\n\n\t\/*  - verify, by checking the Cumulative TSN Ack field of the\n\t *    chunk, that all its outstanding DATA chunks have been\n\t *    received by the SHUTDOWN sender.\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN,\n\t\t\tSCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack));\n\nout:\n\treturn disposition;\n}","target":0,"code_token_length":576,"total_token_length":812,"max_tokens_setting":1024}
+{"idx":349581,"func":"spa_base64_to_bits (char *out, int outlength, const char *in)\n\/* base 64 to raw bytes in quasi-big-endian order, returning count of bytes *\/\n{\n  int len = 0;\n  register uschar digit1, digit2, digit3, digit4;\n\n  if (in[0] == '+' && in[1] == ' ')\n    in += 2;\n  if (*in == '\\r')\n    return (0);\n\n  do\n    {\n      if (len >= outlength)                   \/* Added by PH *\/\n        return (-1);                          \/* Added by PH *\/\n      digit1 = in[0];\n      if (DECODE64 (digit1) == BAD)\n       return (-1);\n      digit2 = in[1];\n      if (DECODE64 (digit2) == BAD)\n       return (-1);\n      digit3 = in[2];\n      if (digit3 != '=' && DECODE64 (digit3) == BAD)\n       return (-1);\n      digit4 = in[3];\n      if (digit4 != '=' && DECODE64 (digit4) == BAD)\n       return (-1);\n      in += 4;\n      *out++ = (DECODE64 (digit1) << 2) | (DECODE64 (digit2) >> 4);\n      ++len;\n      if (digit3 != '=')\n       {\n         if (len >= outlength)                   \/* Added by PH *\/\n           return (-1);                          \/* Added by PH *\/\n         *out++ =\n           ((DECODE64 (digit2) << 4) & 0xf0) | (DECODE64 (digit3) >> 2);\n         ++len;\n         if (digit4 != '=')\n           {\n             if (len >= outlength)                   \/* Added by PH *\/\n               return (-1);                          \/* Added by PH *\/\n             *out++ = ((DECODE64 (digit3) << 6) & 0xc0) | DECODE64 (digit4);\n             ++len;\n           }\n       }\n    }\n  while (*in && *in != '\\r' && digit4 != '=');\n\n  return (len);\n}","target":1,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":441380,"func":"int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) {\n  *new_op = op;\n  ldout(s->cct, 10) << __func__ << \" Starting retarget\" << dendl;\n\n  if (!(s->prot_flags & RGW_REST_WEBSITE))\n    return 0;\n\n  int ret = store->get_bucket_info(*s->sysobj_ctx, s->bucket_tenant,\n\t\t\t\t  s->bucket_name, s->bucket_info, NULL,\n\t\t\t\t  &s->bucket_attrs);\n  if (ret < 0) {\n      \/\/ TODO-FUTURE: if the bucket does not exist, maybe expose it here?\n      return -ERR_NO_SUCH_BUCKET;\n  }\n  if (!s->bucket_info.has_website) {\n      \/\/ TODO-FUTURE: if the bucket has no WebsiteConfig, expose it here\n      return -ERR_NO_SUCH_WEBSITE_CONFIGURATION;\n  }\n\n  rgw_obj_key new_obj;\n  bool get_res = s->bucket_info.website_conf.get_effective_key(s->object.name, &new_obj.name, web_dir());\n  if (!get_res) {\n    s->err.message = \"The IndexDocument Suffix is not configurated or not well formed!\";\n    ldout(s->cct, 5) << s->err.message << dendl;\n    return -EINVAL;\n  }\n\n  ldout(s->cct, 10) << \"retarget get_effective_key \" << s->object << \" -> \"\n\t\t    << new_obj << dendl;\n\n  RGWBWRoutingRule rrule;\n  bool should_redirect =\n    s->bucket_info.website_conf.should_redirect(new_obj.name, 0, &rrule);\n\n  if (should_redirect) {\n    const string& hostname = s->info.env->get(\"HTTP_HOST\", \"\");\n    const string& protocol =\n      (s->info.env->get(\"SERVER_PORT_SECURE\") ? \"https\" : \"http\");\n    int redirect_code = 0;\n    rrule.apply_rule(protocol, hostname, s->object.name, &s->redirect,\n\t\t    &redirect_code);\n    \/\/ APply a custom HTTP response code\n    if (redirect_code > 0)\n      s->err.http_ret = redirect_code; \/\/ Apply a custom HTTP response code\n    ldout(s->cct, 10) << \"retarget redirect code=\" << redirect_code\n\t\t      << \" proto+host:\" << protocol << \":\/\/\" << hostname\n\t\t      << \" -> \" << s->redirect << dendl;\n    return -ERR_WEBSITE_REDIRECT;\n  }\n\n  \/*\n   * FIXME: if s->object != new_obj, drop op and create a new op to handle\n   * operation. Or remove this comment if it's not applicable anymore\n   *\/\n\n  s->object = new_obj;\n\n  return 0;\n}","target":0,"code_token_length":597,"total_token_length":833,"max_tokens_setting":1024}
+{"idx":190062,"func":"size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,\n                    const void* dict, size_t dictSize, const ZSTD_CDict* cdict,\n                    ZSTD_CCtx_params params, unsigned long long pledgedSrcSize)\n{\n    DEBUGLOG(4, \"ZSTD_initCStream_internal\");\n    params.cParams = ZSTD_getCParamsFromCCtxParams(¶ms, pledgedSrcSize, dictSize);\n    assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));\n    assert(!((dict) && (cdict)));  \/* either dict or cdict, not both *\/\n\n    if (dict && dictSize >= 8) {\n        DEBUGLOG(4, \"loading dictionary of size %u\", (U32)dictSize);\n        if (zcs->staticSize) {   \/* static CCtx : never uses malloc *\/\n            \/* incompatible with internal cdict creation *\/\n            return ERROR(memory_allocation);\n        }\n        ZSTD_freeCDict(zcs->cdictLocal);\n        zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,\n                                            ZSTD_dlm_byCopy, ZSTD_dct_auto,\n                                            params.cParams, zcs->customMem);\n        zcs->cdict = zcs->cdictLocal;\n        if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);\n    } else {\n        if (cdict) {\n            params.cParams = ZSTD_getCParamsFromCDict(cdict);  \/* cParams are enforced from cdict; it includes windowLog *\/\n        }\n        ZSTD_freeCDict(zcs->cdictLocal);\n        zcs->cdictLocal = NULL;\n        zcs->cdict = cdict;\n    }\n\n    return ZSTD_resetCStream_internal(zcs, NULL, 0, ZSTD_dct_auto, zcs->cdict, params, pledgedSrcSize);\n}\n","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":304310,"func":"SYSCALL_DEFINE4(epoll_wait, int, epfd, struct epoll_event __user *, events,\n\t\tint, maxevents, int, timeout)\n{\n\tint error;\n\tstruct file *file;\n\tstruct eventpoll *ep;\n\n\t\/* The maximum number of event must be greater than zero *\/\n\tif (maxevents <= 0 || maxevents > EP_MAX_EVENTS)\n\t\treturn -EINVAL;\n\n\t\/* Verify that the area passed by the user is writeable *\/\n\tif (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))) {\n\t\terror = -EFAULT;\n\t\tgoto error_return;\n\t}\n\n\t\/* Get the \"struct file *\" for the eventpoll file *\/\n\terror = -EBADF;\n\tfile = fget(epfd);\n\tif (!file)\n\t\tgoto error_return;\n\n\t\/*\n\t * We have to check that the file structure underneath the fd\n\t * the user passed to us _is_ an eventpoll file.\n\t *\/\n\terror = -EINVAL;\n\tif (!is_file_epoll(file))\n\t\tgoto error_fput;\n\n\t\/*\n\t * At this point it is safe to assume that the \"private_data\" contains\n\t * our own data structure.\n\t *\/\n\tep = file->private_data;\n\n\t\/* Time to fish for events ... *\/\n\terror = ep_poll(ep, events, maxevents, timeout);\n\nerror_fput:\n\tfput(file);\nerror_return:\n\n\treturn error;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":107883,"func":"mii_set_media_pcs (struct net_device *dev)\n{\n\t__u16 bmcr;\n\t__u16 esr;\n\t__u16 anar;\n\tint phy_addr;\n\tstruct netdev_private *np;\n\tnp = netdev_priv(dev);\n\tphy_addr = np->phy_addr;\n\n\t\/* Auto-Negotiation? *\/\n\tif (np->an_enable) {\n\t\t\/* Advertise capabilities *\/\n\t\tesr = mii_read (dev, phy_addr, PCS_ESR);\n\t\tanar = mii_read (dev, phy_addr, MII_ADVERTISE) &\n\t\t\t~PCS_ANAR_HALF_DUPLEX &\n\t\t\t~PCS_ANAR_FULL_DUPLEX;\n\t\tif (esr & (MII_ESR_1000BT_HD | MII_ESR_1000BX_HD))\n\t\t\tanar |= PCS_ANAR_HALF_DUPLEX;\n\t\tif (esr & (MII_ESR_1000BT_FD | MII_ESR_1000BX_FD))\n\t\t\tanar |= PCS_ANAR_FULL_DUPLEX;\n\t\tanar |= PCS_ANAR_PAUSE | PCS_ANAR_ASYMMETRIC;\n\t\tmii_write (dev, phy_addr, MII_ADVERTISE, anar);\n\n\t\t\/* Soft reset PHY *\/\n\t\tmii_write (dev, phy_addr, MII_BMCR, BMCR_RESET);\n\t\tbmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET;\n\t\tmii_write (dev, phy_addr, MII_BMCR, bmcr);\n\t\tmdelay(1);\n\t} else {\n\t\t\/* Force speed setting *\/\n\t\t\/* PHY Reset *\/\n\t\tbmcr = BMCR_RESET;\n\t\tmii_write (dev, phy_addr, MII_BMCR, bmcr);\n\t\tmdelay(10);\n\t\tif (np->full_duplex) {\n\t\t\tbmcr = BMCR_FULLDPLX;\n\t\t\tprintk (KERN_INFO \"Manual full duplex\\n\");\n\t\t} else {\n\t\t\tbmcr = 0;\n\t\t\tprintk (KERN_INFO \"Manual half duplex\\n\");\n\t\t}\n\t\tmii_write (dev, phy_addr, MII_BMCR, bmcr);\n\t\tmdelay(10);\n\n\t\t\/*  Advertise nothing *\/\n\t\tmii_write (dev, phy_addr, MII_ADVERTISE, 0);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":384071,"func":"idna_to_ascii_4z (const uint32_t * input, char **output, int flags)\n{\n  const uint32_t *start = input;\n  const uint32_t *end;\n  char buf[64];\n  char *out = NULL;\n  int rc;\n\n  \/* 1) Whenever dots are used as label separators, the following\n     characters MUST be recognized as dots: U+002E (full stop),\n     U+3002 (ideographic full stop), U+FF0E (fullwidth full stop),\n     U+FF61 (halfwidth ideographic full stop). *\/\n\n  if (input[0] == 0)\n    {\n      \/* Handle implicit zero-length root label. *\/\n      *output = malloc (1);\n      if (!*output)\n\treturn IDNA_MALLOC_ERROR;\n      strcpy (*output, \"\");\n      return IDNA_SUCCESS;\n    }\n\n  if (DOTP (input[0]) && input[1] == 0)\n    {\n      \/* Handle explicit zero-length root label. *\/\n      *output = malloc (2);\n      if (!*output)\n\treturn IDNA_MALLOC_ERROR;\n      strcpy (*output, \".\");\n      return IDNA_SUCCESS;\n    }\n\n  *output = NULL;\n  do\n    {\n      end = start;\n\n      for (; *end && !DOTP (*end); end++)\n\t;\n\n      if (*end == '\\0' && start == end)\n\t{\n\t  \/* Handle explicit zero-length root label. *\/\n\t  buf[0] = '\\0';\n\t}\n      else\n\t{\n\t  rc = idna_to_ascii_4i (start, (size_t) (end - start), buf, flags);\n\t  if (rc != IDNA_SUCCESS)\n\t    {\n\t      free (out);\n\t      return rc;\n\t    }\n\t}\n\n      if (out)\n\t{\n\t  size_t l = strlen (out) + 1 + strlen (buf) + 1;\n\t  char *newp = realloc (out, l);\n\t  if (!newp)\n\t    {\n\t      free (out);\n\t      return IDNA_MALLOC_ERROR;\n\t    }\n\t  out = newp;\n\t  strcat (out, \".\");\n\t  strcat (out, buf);\n\t}\n      else\n\t{\n\t  out = strdup (buf);\n\t  if (!out)\n\t    return IDNA_MALLOC_ERROR;\n\t}\n\n      start = end + 1;\n    }\n  while (*end);\n\n  *output = out;\n\n  return IDNA_SUCCESS;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":429419,"func":"        void PngChunk::decodeIHDRChunk(const DataBuf& data, PngImageHeader& h)\n        {\n            enforce(data.size_ == 13, kerCorruptedMetadata);\n\n            h.width = getLong((const byte*)data.pData_, bigEndian);\n            h.height = getLong((const byte*)data.pData_ + 4, bigEndian);\n            h.bitDepth = data.pData_[8];\n            h.colorType = data.pData_[9];\n            h.compressionMethod = data.pData_[10];\n            h.filterMethod = data.pData_[11];\n            h.interlaceMethod = data.pData_[12];\n\n            enforce(h.colorType == 0 || h.colorType == 2 || h.colorType == 3 || h.colorType == 4 || h.colorType == 6,\n                    kerCorruptedMetadata);\n            switch(h.colorType)\n            {\n            case 0:\n                enforce(h.bitDepth == 1 || h.bitDepth == 2 || h.bitDepth == 4 || h.bitDepth == 8 || h.bitDepth == 16,\n                        kerCorruptedMetadata);\n                break;\n            case 2:\n                enforce(h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata);\n                break;\n            case 3:\n                enforce(h.bitDepth == 1 || h.bitDepth == 2 || h.bitDepth == 4 || h.bitDepth == 8, kerCorruptedMetadata);\n                break;\n            case 4:\n                enforce(h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata);\n                break;\n            case 6:\n                enforce(h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata);\n                break;\n            }\n            enforce(h.compressionMethod == 0, kerCorruptedMetadata);\n            enforce(h.filterMethod == 0, kerCorruptedMetadata);\n            enforce(h.interlaceMethod == 0 || h.interlaceMethod == 1, kerCorruptedMetadata);\n        }","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":420636,"func":"parse_strict_transport_security (const char *header, time_t *max_age, bool *include_subdomains)\n{\n  param_token name, value;\n  const char *c_max_age = NULL;\n  bool is = false; \/* includeSubDomains *\/\n  bool is_url_encoded = false;\n  bool success = false;\n\n  if (header)\n    {\n      \/* Process the STS header. Keys should be matched case-insensitively. *\/\n      for (; extract_param (&header, &name, &value, ';', &is_url_encoded); is_url_encoded = false)\n        {\n          if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, \"max-age\"))\n            {\n              xfree(c_max_age);\n              c_max_age = strdupdelim (value.b, value.e);\n            }\n          else if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, \"includeSubDomains\"))\n            is = true;\n        }\n\n      \/* pass the parsed values over *\/\n      if (c_max_age)\n        {\n          \/* If the string value goes out of a long's bounds, strtol() will return LONG_MIN or LONG_MAX.\n           * In theory, the HSTS engine should be able to handle it.\n           * Also, time_t is normally defined as a long, so this should not break.\n           *\/\n          if (max_age)\n            *max_age = (time_t) strtol (c_max_age, NULL, 10);\n          if (include_subdomains)\n            *include_subdomains = is;\n\n          DEBUGP ((\"Parsed Strict-Transport-Security max-age = %s, includeSubDomains = %s\\n\",\n                 c_max_age, (is ? \"true\" : \"false\")));\n\n          xfree (c_max_age);\n          success = true;\n        }\n      else\n        {\n          \/* something weird happened *\/\n          logprintf (LOG_VERBOSE, \"Could not parse String-Transport-Security header\\n\");\n          success = false;\n        }\n    }\n\n  return success;\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":342223,"func":"static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){\n\n    int i, si, di;\n\n    uint8_t *dst;\n\n    int bufidx;\n\n\n\n\/\/    src[0]&0x80;                \/\/forbidden bit\n\n    h->nal_ref_idc= src[0]>>5;\n\n    h->nal_unit_type= src[0]&0x1F;\n\n\n\n    src++; length--;\n\n#if 0\n\n    for(i=0; i<length; i++)\n\n        printf(\"%2X \", src[i]);\n\n#endif\n\n    for(i=0; i+1<length; i+=2){\n\n        if(src[i]) continue;\n\n        if(i>0 && src[i-1]==0) i--;\n\n        if(i+2<length && src[i+1]==0 && src[i+2]<=3){\n\n            if(src[i+2]!=3){\n\n                \/* startcode, so we must be past the end *\/\n\n                length=i;\n\n            }\n\n            break;\n\n        }\n\n    }\n\n\n\n    if(i>=length-1){ \/\/no escaped 0\n\n        *dst_length= length;\n\n        *consumed= length+1; \/\/+1 for the header\n\n        return src;\n\n    }\n\n\n\n    bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; \/\/ use second escape buffer for inter data\n\n    h->rbsp_buffer[bufidx]= av_fast_realloc(h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length);\n\n    dst= h->rbsp_buffer[bufidx];\n\n\n\n    if (dst == NULL){\n\n        return NULL;\n\n    }\n\n\n\n\/\/printf(\"decoding esc\\n\");\n\n    si=di=0;\n\n    while(si<length){\n\n        \/\/remove escapes (very rare 1:2^22)\n\n        if(si+2<length && src[si]==0 && src[si+1]==0 && src[si+2]<=3){\n\n            if(src[si+2]==3){ \/\/escape\n\n                dst[di++]= 0;\n\n                dst[di++]= 0;\n\n                si+=3;\n\n                continue;\n\n            }else \/\/next start code\n\n                break;\n\n        }\n\n\n\n        dst[di++]= src[si++];\n\n    }\n\n\n\n    *dst_length= di;\n\n    *consumed= si + 1;\/\/+1 for the header\n\n\/\/FIXME store exact number of bits in the getbitcontext (it is needed for decoding)\n\n    return dst;\n\n}\n","target":1,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":462877,"func":"TEST(BitTestMatchExpression, DoesNotMatchBinary2) {\n    BSONArray bas = BSON_ARRAY(21 << 22 << 23 << 24 << 25);\n    BSONArray bac = BSON_ARRAY(20 << 23 << 21);\n    std::vector<uint32_t> bitPositionsSet = bsonArrayToBitPositions(bas);\n    std::vector<uint32_t> bitPositionsClear = bsonArrayToBitPositions(bac);\n\n    BSONObj match1 = fromjson(\"{a: {$binary: 'AANgAAAAAAAAAAAAAAAAAAAAAAAA', $type: '00'}}\");\n    \/\/ Base64 to Binary: 00000000 00000011 01100000\n    BSONObj match2 = fromjson(\"{a: {$binary: 'JANgqwetkqwklEWRbWERKKJREtbq', $type: '00'}}\");\n    \/\/ Base64 to Binary: ........ 00000011 01100000\n\n    BitsAllSetMatchExpression balls;\n    BitsAllClearMatchExpression ballc;\n    BitsAnySetMatchExpression banys;\n    BitsAnyClearMatchExpression banyc;\n\n    ASSERT_OK(balls.init(\"a\", bitPositionsSet));\n    ASSERT_OK(ballc.init(\"a\", bitPositionsClear));\n    ASSERT_OK(banys.init(\"a\", bitPositionsSet));\n    ASSERT_OK(banyc.init(\"a\", bitPositionsClear));\n    ASSERT_EQ((size_t)5, balls.numBitPositions());\n    ASSERT_EQ((size_t)3, ballc.numBitPositions());\n    ASSERT_EQ((size_t)5, banys.numBitPositions());\n    ASSERT_EQ((size_t)3, banyc.numBitPositions());\n    ASSERT(!balls.matchesSingleElement(match1[\"a\"]));\n    ASSERT(!balls.matchesSingleElement(match2[\"a\"]));\n    ASSERT(!ballc.matchesSingleElement(match1[\"a\"]));\n    ASSERT(!ballc.matchesSingleElement(match2[\"a\"]));\n    ASSERT(banys.matchesSingleElement(match1[\"a\"]));\n    ASSERT(banys.matchesSingleElement(match2[\"a\"]));\n    ASSERT(banyc.matchesSingleElement(match1[\"a\"]));\n    ASSERT(banyc.matchesSingleElement(match2[\"a\"]));\n}","target":0,"code_token_length":487,"total_token_length":723,"max_tokens_setting":1024}
+{"idx":96294,"func":"void nl80211_send_beacon_hint_event(struct wiphy *wiphy,\n\t\t\t\t    struct ieee80211_channel *channel_before,\n\t\t\t\t    struct ieee80211_channel *channel_after)\n{\n\tstruct sk_buff *msg;\n\tvoid *hdr;\n\tstruct nlattr *nl_freq;\n\n\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\n\tif (!msg)\n\t\treturn;\n\n\thdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_BEACON_HINT);\n\tif (!hdr) {\n\t\tnlmsg_free(msg);\n\t\treturn;\n\t}\n\n\t\/*\n\t * Since we are applying the beacon hint to a wiphy we know its\n\t * wiphy_idx is valid\n\t *\/\n\tif (nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy)))\n\t\tgoto nla_put_failure;\n\n\t\/* Before *\/\n\tnl_freq = nla_nest_start_noflag(msg, NL80211_ATTR_FREQ_BEFORE);\n\tif (!nl_freq)\n\t\tgoto nla_put_failure;\n\n\tif (nl80211_msg_put_channel(msg, wiphy, channel_before, false))\n\t\tgoto nla_put_failure;\n\tnla_nest_end(msg, nl_freq);\n\n\t\/* After *\/\n\tnl_freq = nla_nest_start_noflag(msg, NL80211_ATTR_FREQ_AFTER);\n\tif (!nl_freq)\n\t\tgoto nla_put_failure;\n\n\tif (nl80211_msg_put_channel(msg, wiphy, channel_after, false))\n\t\tgoto nla_put_failure;\n\tnla_nest_end(msg, nl_freq);\n\n\tgenlmsg_end(msg, hdr);\n\n\trcu_read_lock();\n\tgenlmsg_multicast_allns(&nl80211_fam, msg, 0,\n\t\t\t\tNL80211_MCGRP_REGULATORY, GFP_ATOMIC);\n\trcu_read_unlock();\n\n\treturn;\n\nnla_put_failure:\n\tnlmsg_free(msg);\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":217872,"func":"String8 effectFlagsToString(uint32_t flags) {\n String8 s;\n\n    s.append(\"conn. mode: \");\n switch (flags & EFFECT_FLAG_TYPE_MASK) {\n case EFFECT_FLAG_TYPE_INSERT: s.append(\"insert\"); break;\n case EFFECT_FLAG_TYPE_AUXILIARY: s.append(\"auxiliary\"); break;\n case EFFECT_FLAG_TYPE_REPLACE: s.append(\"replace\"); break;\n case EFFECT_FLAG_TYPE_PRE_PROC: s.append(\"preproc\"); break;\n case EFFECT_FLAG_TYPE_POST_PROC: s.append(\"postproc\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n    s.append(\", \");\n\n    s.append(\"insert pref: \");\n switch (flags & EFFECT_FLAG_INSERT_MASK) {\n case EFFECT_FLAG_INSERT_ANY: s.append(\"any\"); break;\n case EFFECT_FLAG_INSERT_FIRST: s.append(\"first\"); break;\n case EFFECT_FLAG_INSERT_LAST: s.append(\"last\"); break;\n case EFFECT_FLAG_INSERT_EXCLUSIVE: s.append(\"exclusive\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n    s.append(\", \");\n\n    s.append(\"volume mgmt: \");\n switch (flags & EFFECT_FLAG_VOLUME_MASK) {\n case EFFECT_FLAG_VOLUME_NONE: s.append(\"none\"); break;\n case EFFECT_FLAG_VOLUME_CTRL: s.append(\"implements control\"); break;\n case EFFECT_FLAG_VOLUME_IND: s.append(\"requires indication\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n    s.append(\", \");\n\n uint32_t devind = flags & EFFECT_FLAG_DEVICE_MASK;\n if (devind) {\n        s.append(\"device indication: \");\n switch (devind) {\n case EFFECT_FLAG_DEVICE_IND: s.append(\"requires updates\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n        s.append(\", \");\n }\n\n    s.append(\"input mode: \");\n switch (flags & EFFECT_FLAG_INPUT_MASK) {\n case EFFECT_FLAG_INPUT_DIRECT: s.append(\"direct\"); break;\n case EFFECT_FLAG_INPUT_PROVIDER: s.append(\"provider\"); break;\n case EFFECT_FLAG_INPUT_BOTH: s.append(\"direct+provider\"); break;\n default: s.append(\"not set\"); break;\n }\n    s.append(\", \");\n\n    s.append(\"output mode: \");\n switch (flags & EFFECT_FLAG_OUTPUT_MASK) {\n case EFFECT_FLAG_OUTPUT_DIRECT: s.append(\"direct\"); break;\n case EFFECT_FLAG_OUTPUT_PROVIDER: s.append(\"provider\"); break;\n case EFFECT_FLAG_OUTPUT_BOTH: s.append(\"direct+provider\"); break;\n default: s.append(\"not set\"); break;\n }\n    s.append(\", \");\n\n uint32_t accel = flags & EFFECT_FLAG_HW_ACC_MASK;\n if (accel) {\n        s.append(\"hardware acceleration: \");\n switch (accel) {\n case EFFECT_FLAG_HW_ACC_SIMPLE: s.append(\"non-tunneled\"); break;\n case EFFECT_FLAG_HW_ACC_TUNNEL: s.append(\"tunneled\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n        s.append(\", \");\n }\n\n uint32_t modeind = flags & EFFECT_FLAG_AUDIO_MODE_MASK;\n if (modeind) {\n        s.append(\"mode indication: \");\n switch (modeind) {\n case EFFECT_FLAG_AUDIO_MODE_IND: s.append(\"required\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n        s.append(\", \");\n }\n\n uint32_t srcind = flags & EFFECT_FLAG_AUDIO_SOURCE_MASK;\n if (srcind) {\n        s.append(\"source indication: \");\n switch (srcind) {\n case EFFECT_FLAG_AUDIO_SOURCE_IND: s.append(\"required\"); break;\n default: s.append(\"unknown\/reserved\"); break;\n }\n        s.append(\", \");\n }\n\n if (flags & EFFECT_FLAG_OFFLOAD_MASK) {\n        s.append(\"offloadable, \");\n }\n\n int len = s.length();\n if (s.length() > 2) {\n char *str = s.lockBuffer(len);\n        s.unlockBuffer(len - 2);\n }\n return s;\n}\n","target":0,"code_token_length":785,"total_token_length":1021,"max_tokens_setting":1024}
+{"idx":474327,"func":"static int _crypt_load_integrity(struct crypt_device *cd,\n\t\t\t\t struct crypt_params_integrity *params)\n{\n\tint r;\n\n\tr = init_crypto(cd);\n\tif (r < 0)\n\t\treturn r;\n\n\tr = INTEGRITY_read_sb(cd, &cd->u.integrity.params, &cd->u.integrity.sb_flags);\n\tif (r < 0)\n\t\treturn r;\n\n\t\/\/ FIXME: add checks for fields in integrity sb vs params\n\n\tif (params) {\n\t\tcd->u.integrity.params.journal_watermark = params->journal_watermark;\n\t\tcd->u.integrity.params.journal_commit_time = params->journal_commit_time;\n\t\tcd->u.integrity.params.buffer_sectors = params->buffer_sectors;\n\t\t\/\/ FIXME: check ENOMEM\n\t\tif (params->integrity)\n\t\t\tcd->u.integrity.params.integrity = strdup(params->integrity);\n\t\tcd->u.integrity.params.integrity_key_size = params->integrity_key_size;\n\t\tif (params->journal_integrity)\n\t\t\tcd->u.integrity.params.journal_integrity = strdup(params->journal_integrity);\n\t\tif (params->journal_crypt)\n\t\t\tcd->u.integrity.params.journal_crypt = strdup(params->journal_crypt);\n\n\t\tif (params->journal_crypt_key) {\n\t\t\tcd->u.integrity.journal_crypt_key =\n\t\t\t\tcrypt_alloc_volume_key(params->journal_crypt_key_size,\n\t\t\t\t\t\t       params->journal_crypt_key);\n\t\t\tif (!cd->u.integrity.journal_crypt_key)\n\t\t\t\treturn -ENOMEM;\n\t\t}\n\t\tif (params->journal_integrity_key) {\n\t\t\tcd->u.integrity.journal_mac_key =\n\t\t\t\tcrypt_alloc_volume_key(params->journal_integrity_key_size,\n\t\t\t\t\t\t       params->journal_integrity_key);\n\t\t\tif (!cd->u.integrity.journal_mac_key)\n\t\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\n\tif (!cd->type && !(cd->type = strdup(CRYPT_INTEGRITY))) {\n\t\tfree(CONST_CAST(void*)cd->u.integrity.params.integrity);\n\t\treturn -ENOMEM;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":48765,"func":"dwarf_uncompress_integer_block_a(Dwarf_Debug dbg,\n    Dwarf_Unsigned     input_length_in_bytes,\n    void             * input_block,\n    Dwarf_Unsigned   * value_count,\n    Dwarf_Signed    ** value_array,\n    Dwarf_Error      * error)\n{\n    Dwarf_Unsigned output_length_in_units = 0;\n    Dwarf_Signed * output_block = 0;\n    unsigned i = 0;\n    char * ptr = 0;\n    int remain = 0;\n    Dwarf_Signed * array = 0;\n    Dwarf_Byte_Ptr endptr = (Dwarf_Byte_Ptr)input_block+\n        input_length_in_bytes;\n\n    output_length_in_units = 0;\n    remain = input_length_in_bytes;\n    ptr = input_block;\n    while (remain > 0) {\n        Dwarf_Unsigned len = 0;\n        Dwarf_Signed value = 0;\n        int rres = 0;\n\n        rres = dwarf_decode_signed_leb128((char *)ptr,\n            &len, &value,(char *)endptr);\n        if (rres != DW_DLV_OK) {\n            _dwarf_error(NULL, error, DW_DLE_LEB_IMPROPER);\n            return DW_DLV_ERROR;\n        }\n        ptr += len;\n        remain -= len;\n        output_length_in_units++;\n    }\n    if (remain != 0) {\n        _dwarf_error(NULL, error, DW_DLE_ALLOC_FAIL);\n        return DW_DLV_ERROR;\n    }\n\n    output_block = (Dwarf_Signed*)\n        _dwarf_get_alloc(dbg,\n            DW_DLA_STRING,\n            output_length_in_units * sizeof(Dwarf_Signed));\n    if (!output_block) {\n        _dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);\n        return DW_DLV_ERROR;\n    }\n    array = output_block;\n    remain = input_length_in_bytes;\n    ptr = input_block;\n    for (i=0; i<output_length_in_units && remain>0; i++) {\n        Dwarf_Signed num;\n        Dwarf_Unsigned len;\n        int sres = 0;\n\n        sres = dwarf_decode_signed_leb128((char *)ptr,\n            &len, &num,(char *)endptr);\n        if (sres != DW_DLV_OK) {\n            dwarf_dealloc(dbg,output_block,DW_DLA_STRING);\n            _dwarf_error(NULL, error, DW_DLE_LEB_IMPROPER);\n            return DW_DLV_ERROR;\n        }\n        ptr += len;\n        remain -= len;\n        array[i] = num;\n    }\n\n    if (remain != 0) {\n        dwarf_dealloc(dbg, (unsigned char *)output_block,\n            DW_DLA_STRING);\n        _dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);\n        return DW_DLV_ERROR;\n    }\n\n    *value_count = output_length_in_units;\n    *value_array = output_block;\n    return DW_DLV_OK;\n}","target":0,"code_token_length":622,"total_token_length":858,"max_tokens_setting":1024}
+{"idx":417322,"func":"    void CrwMap::decodeBasic(const CiffComponent& ciffComponent,\n                             const CrwMapping*    pCrwMapping,\n                                   Image&         image,\n                                   ByteOrder      byteOrder)\n    {\n        assert(pCrwMapping != 0);\n        \/\/ create a key and value pair\n        ExifKey key(pCrwMapping->tag_, Internal::groupName(pCrwMapping->ifdId_));\n        Value::AutoPtr value;\n        if (ciffComponent.typeId() != directory) {\n            value = Value::create(ciffComponent.typeId());\n            uint32_t size = 0;\n            if (pCrwMapping->size_ != 0) {\n                \/\/ size in the mapping table overrides all\n                size = pCrwMapping->size_;\n            }\n            else if (ciffComponent.typeId() == asciiString) {\n                \/\/ determine size from the data, by looking for the first 0\n                uint32_t i = 0;\n                for (;    i < ciffComponent.size()\n                       && ciffComponent.pData()[i] != '\\0'; ++i) {\n                    \/\/ empty\n                }\n                size = ++i;\n            }\n            else {\n                \/\/ by default, use the size from the directory entry\n                size = ciffComponent.size();\n            }\n            value->read(ciffComponent.pData(), size, byteOrder);\n        }\n        \/\/ Add metadatum to exif data\n        image.exifData().add(key, value.get());\n    } \/\/ CrwMap::decodeBasic","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":78825,"func":"void init_numa_balancing(unsigned long clone_flags, struct task_struct *p)\n{\n\tint mm_users = 0;\n\tstruct mm_struct *mm = p->mm;\n\n\tif (mm) {\n\t\tmm_users = atomic_read(&mm->mm_users);\n\t\tif (mm_users == 1) {\n\t\t\tmm->numa_next_scan = jiffies + msecs_to_jiffies(sysctl_numa_balancing_scan_delay);\n\t\t\tmm->numa_scan_seq = 0;\n\t\t}\n\t}\n\tp->node_stamp\t\t\t= 0;\n\tp->numa_scan_seq\t\t= mm ? mm->numa_scan_seq : 0;\n\tp->numa_scan_period\t\t= sysctl_numa_balancing_scan_delay;\n\t\/* Protect against double add, see task_tick_numa and task_numa_work *\/\n\tp->numa_work.next\t\t= &p->numa_work;\n\tp->numa_faults\t\t\t= NULL;\n\tRCU_INIT_POINTER(p->numa_group, NULL);\n\tp->last_task_numa_placement\t= 0;\n\tp->last_sum_exec_runtime\t= 0;\n\n\tinit_task_work(&p->numa_work, task_numa_work);\n\n\t\/* New address space, reset the preferred nid *\/\n\tif (!(clone_flags & CLONE_VM)) {\n\t\tp->numa_preferred_nid = NUMA_NO_NODE;\n\t\treturn;\n\t}\n\n\t\/*\n\t * New thread, keep existing numa_preferred_nid which should be copied\n\t * already by arch_dup_task_struct but stagger when scans start.\n\t *\/\n\tif (mm) {\n\t\tunsigned int delay;\n\n\t\tdelay = min_t(unsigned int, task_scan_max(current),\n\t\t\tcurrent->numa_scan_period * mm_users * NSEC_PER_MSEC);\n\t\tdelay += 2 * TICK_NSEC;\n\t\tp->node_stamp = delay;\n\t}\n}","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":293083,"func":"INST_HANDLER (std) {\t\/\/ ST Y, Rr\tST Z, Rr\n\t\t\t\/\/ ST Y+, Rr\tST Z+, Rr\n\t\t\t\/\/ ST -Y, Rr\tST -Z, Rr\n\t\t\t\/\/ ST Y+q, Rr\tST Z+q, Rr\n\t\/\/ load register\n\tESIL_A (\"r%d,\", ((buf[1] & 1) << 4) | ((buf[0] >> 4) & 0xf));\n\t\/\/ write in memory\n\t__generic_ld_st (\n\t\top, \"ram\",\n\t\tbuf[0] & 0x8 ? 'y' : 'z',\t\/\/ index register Y\/Z\n\t\t0,\t\t\t\t\/\/ no use RAMP* registers\n\t\t!(buf[1] & 0x10)\n\t\t\t? 0\t\t\t\/\/ no increment\n\t\t\t: buf[0] & 0x1\n\t\t\t\t? 1\t\t\/\/ post incremented\n\t\t\t\t: -1,\t\t\/\/ pre decremented\n\t\t!(buf[1] & 0x10)\n\t\t\t? (buf[1] & 0x20)\t\/\/ offset\n\t\t\t| ((buf[1] & 0xc) << 1)\n\t\t\t| (buf[0] & 0x7)\n\t\t\t: 0,\t\t\t\/\/ no offset\n\t\t1);\t\t\t\t\/\/ load operation (!st)\n\/\/\t\/\/ cycles\n\/\/\top->cycles =\n\/\/\t\tbuf[1] & 0x1 == 0\n\/\/\t\t\t? !(offset ? 1 : 3)\t\t\/\/ LDD\n\/\/\t\t\t: buf[0] & 0x3 == 0\n\/\/\t\t\t\t? 1\t\t\t\/\/ LD Rd, X\n\/\/\t\t\t\t: buf[0] & 0x3 == 1\n\/\/\t\t\t\t\t? 2\t\t\/\/ LD Rd, X+\n\/\/\t\t\t\t\t: 3;\t\t\/\/ LD Rd, -X\n\/\/\tif (!STR_BEGINS (cpu->model, \"ATxmega\") && op->cycles > 1) {\n\/\/\t\t\/\/ AT*mega optimizes 1 cycle!\n\/\/\t\top->cycles--;\n\/\/\t}\n}","target":0,"code_token_length":486,"total_token_length":722,"max_tokens_setting":1024}
+{"idx":360295,"func":"fill_emblem_cache_if_needed (NautilusFile *file)\n{\n\tGList *node, *keywords;\n\tchar *scanner;\n\tsize_t length;\n\n\tif (file->details->compare_by_emblem_cache != NULL) {\n\t\t\/* Got a cache already. *\/\n\t\treturn;\n\t}\n\n\tkeywords = nautilus_file_get_keywords (file);\n\n\t\/* Add up the keyword string lengths *\/\n\tlength = 1;\n\tfor (node = keywords; node != NULL; node = node->next) {\n\t\tlength += strlen ((const char *) node->data) + 1;\n\t}\n\n\t\/* Now that we know how large the cache struct needs to be, allocate it. *\/\n\tfile->details->compare_by_emblem_cache = g_malloc (sizeof(NautilusFileSortByEmblemCache) + length);\n\n\t\/* Copy them into the cache. *\/\n\tscanner = file->details->compare_by_emblem_cache->emblem_keywords;\n\tfor (node = keywords; node != NULL; node = node->next) {\n\t\tlength = strlen ((const char *) node->data) + 1;\n\t\tmemcpy (scanner, (const char *) node->data, length);\n\t\tscanner += length;\n\t}\n\n\t\/* Zero-terminate so we can tell where the list ends. *\/\n\t*scanner = 0;\n\n\teel_g_list_free_deep (keywords);\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":259999,"func":"int ecryptfs_decrypt_page(struct page *page)\n{\n\tstruct inode *ecryptfs_inode;\n\tstruct ecryptfs_crypt_stat *crypt_stat;\n\tchar *page_virt;\n\tunsigned long extent_offset;\n\tloff_t lower_offset;\n\tint rc = 0;\n\n\tecryptfs_inode = page->mapping->host;\n\tcrypt_stat =\n\t\t&(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);\n\tBUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));\n\n\tlower_offset = lower_offset_for_page(crypt_stat, page);\n\tpage_virt = kmap(page);\n\trc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_CACHE_SIZE,\n\t\t\t\t ecryptfs_inode);\n\tkunmap(page);\n\tif (rc < 0) {\n\t\tecryptfs_printk(KERN_ERR,\n\t\t\t\"Error attempting to read lower page; rc = [%d]\\n\",\n\t\t\trc);\n\t\tgoto out;\n\t}\n\n\tfor (extent_offset = 0;\n\t     extent_offset < (PAGE_CACHE_SIZE \/ crypt_stat->extent_size);\n\t     extent_offset++) {\n\t\trc = crypt_extent(crypt_stat, page, page,\n\t\t\t\t  extent_offset, DECRYPT);\n\t\tif (rc) {\n\t\t\tprintk(KERN_ERR \"%s: Error encrypting extent; \"\n\t\t\t       \"rc = [%d]\\n\", __func__, rc);\n\t\t\tgoto out;\n\t\t}\n\t}\nout:\n\treturn rc;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":107936,"func":"struct MACH0_(obj_t) {\n\tstruct MACH0_(mach_header) hdr;\n\tstruct MACH0_(segment_command) *segs;\n\tchar *intrp;\n\tchar *compiler;\n\tint nsegs;\n\tint segs_count;\n\tstruct r_dyld_chained_starts_in_segment **chained_starts;\n\tstruct dyld_chained_fixups_header fixups_header;\n\tut64 fixups_offset;\n\tut64 fixups_size;\n\tstruct MACH0_(section) *sects;\n\tint nsects;\n\tstruct MACH0_(nlist) *symtab;\n\tut8 *symstr;\n\tut8 *func_start; \/\/buffer that hold the data from LC_FUNCTION_STARTS\n\tint symstrlen;\n\tint nsymtab;\n\tut32 *indirectsyms;\n\tint nindirectsyms;\n\n\tRBinImport **imports_by_ord;\n\tsize_t imports_by_ord_size;\n\tHtPP *imports_by_name;\n\n\tstruct dysymtab_command dysymtab;\n\tstruct load_command main_cmd;\n\tstruct dyld_info_command *dyld_info;\n\tstruct dylib_table_of_contents *toc;\n\tint ntoc;\n\tstruct MACH0_(dylib_module) *modtab;\n\tint nmodtab;\n\tstruct thread_command thread;\n\tut8 *signature;\n\tunion {\n\t\tstruct x86_thread_state32 x86_32;\n\t\tstruct x86_thread_state64 x86_64;\n\t\tstruct ppc_thread_state32 ppc_32;\n\t\tstruct ppc_thread_state64 ppc_64;\n\t\tstruct arm_thread_state32 arm_32;\n\t\tstruct arm_thread_state64 arm_64;\n\t} thread_state;\n\tchar (*libs)[R_BIN_MACH0_STRING_LENGTH];\n\tint nlibs;\n\tint size;\n\tut64 baddr;\n\tut64 entry;\n\tbool big_endian;\n\tconst char *file;\n\tRBuffer *b;\n\tint os;\n\tSdb *kv;\n\tint has_crypto;\n\tint has_canary;\n\tint has_retguard;\n\tint has_sanitizers;\n\tint has_blocks_ext;\n\tint dbg_info;\n\tconst char *lang;\n\tint uuidn;\n\tint func_size;\n\tbool verbose;\n\tut64 header_at;\n\tut64 symbols_off;\n\tvoid *user;\n\tut64 (*va2pa)(ut64 p, ut32 *offset, ut32 *left, RBinFile *bf);\n\tstruct symbol_t *symbols;\n\tut64 main_addr;\n\tint (*original_io_read)(RIO *io, RIODesc *fd, ut8 *buf, int count);\n\tbool rebasing_buffer;\n};","target":0,"code_token_length":544,"total_token_length":780,"max_tokens_setting":1024}
+{"idx":137982,"func":"static noinline int btrfs_ioctl_snap_create_v2(struct file *file,\n\t\t\t\t\t       void __user *arg, int subvol)\n{\n\tstruct btrfs_ioctl_vol_args_v2 *vol_args;\n\tint ret;\n\tu64 transid = 0;\n\tu64 *ptr = NULL;\n\tbool readonly = false;\n\tstruct btrfs_qgroup_inherit *inherit = NULL;\n\n\tif (!S_ISDIR(file_inode(file)->i_mode))\n\t\treturn -ENOTDIR;\n\n\tvol_args = memdup_user(arg, sizeof(*vol_args));\n\tif (IS_ERR(vol_args))\n\t\treturn PTR_ERR(vol_args);\n\tvol_args->name[BTRFS_SUBVOL_NAME_MAX] = '\\0';\n\n\tif (vol_args->flags &\n\t    ~(BTRFS_SUBVOL_CREATE_ASYNC | BTRFS_SUBVOL_RDONLY |\n\t      BTRFS_SUBVOL_QGROUP_INHERIT)) {\n\t\tret = -EOPNOTSUPP;\n\t\tgoto free_args;\n\t}\n\n\tif (vol_args->flags & BTRFS_SUBVOL_CREATE_ASYNC)\n\t\tptr = &transid;\n\tif (vol_args->flags & BTRFS_SUBVOL_RDONLY)\n\t\treadonly = true;\n\tif (vol_args->flags & BTRFS_SUBVOL_QGROUP_INHERIT) {\n\t\tif (vol_args->size > PAGE_SIZE) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto free_args;\n\t\t}\n\t\tinherit = memdup_user(vol_args->qgroup_inherit, vol_args->size);\n\t\tif (IS_ERR(inherit)) {\n\t\t\tret = PTR_ERR(inherit);\n\t\t\tgoto free_args;\n\t\t}\n\t}\n\n\tret = btrfs_ioctl_snap_create_transid(file, vol_args->name,\n\t\t\t\t\t      vol_args->fd, subvol, ptr,\n\t\t\t\t\t      readonly, inherit);\n\tif (ret)\n\t\tgoto free_inherit;\n\n\tif (ptr && copy_to_user(arg +\n\t\t\t\toffsetof(struct btrfs_ioctl_vol_args_v2,\n\t\t\t\t\ttransid),\n\t\t\t\tptr, sizeof(*ptr)))\n\t\tret = -EFAULT;\n\nfree_inherit:\n\tkfree(inherit);\nfree_args:\n\tkfree(vol_args);\n\treturn ret;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":143101,"func":"static int fdt_include_supernodes(struct fdt_region_state *info, int depth)\n{\n\tint base = fdt_off_dt_struct(info->fdt);\n\tint start, stop_at;\n\tint i;\n\n\t\/*\n\t * Work down the stack looking for supernodes that we didn't include.\n\t * The algortihm here is actually pretty simple, since we know that\n\t * no previous subnode had to include these nodes, or if it did, we\n\t * marked them as included (on the stack) already.\n\t *\/\n\tfor (i = 0; i <= depth; i++) {\n\t\tif (!info->stack[i].included) {\n\t\t\tstart = info->stack[i].offset;\n\n\t\t\t\/* Add the FDT_BEGIN_NODE tag of this supernode *\/\n\t\t\tfdt_next_tag(info->fdt, start, &stop_at);\n\t\t\tif (fdt_add_region(info, base + start, stop_at - start))\n\t\t\t\treturn -1;\n\n\t\t\t\/* Remember that this supernode is now included *\/\n\t\t\tinfo->stack[i].included = 1;\n\t\t\tinfo->can_merge = 1;\n\t\t}\n\n\t\t\/* Force (later) generation of the FDT_END_NODE tag *\/\n\t\tif (!info->stack[i].want)\n\t\t\tinfo->stack[i].want = WANT_NODES_ONLY;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":165035,"func":"PassRefPtrWillBeRawPtr<Node> Document::adoptNode(PassRefPtrWillBeRawPtr<Node> source, ExceptionState& exceptionState)\n{\n    EventQueueScope scope;\n\n    switch (source->nodeType()) {\n    case DOCUMENT_NODE:\n        exceptionState.throwDOMException(NotSupportedError, \"The node provided is of type '\" + source->nodeName() + \"', which may not be adopted.\");\n        return nullptr;\n    case ATTRIBUTE_NODE: {\n        Attr* attr = toAttr(source.get());\n        if (RefPtrWillBeRawPtr<Element> ownerElement = attr->ownerElement())\n            ownerElement->removeAttributeNode(attr, exceptionState);\n        break;\n    }\n    default:\n        if (source->isShadowRoot()) {\n            exceptionState.throwDOMException(HierarchyRequestError, \"The node provided is a shadow root, which may not be adopted.\");\n            return nullptr;\n        }\n\n        if (source->isFrameOwnerElement()) {\n            HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(source.get());\n            if (frame() && frame()->tree().isDescendantOf(frameOwnerElement->contentFrame())) {\n                exceptionState.throwDOMException(HierarchyRequestError, \"The node provided is a frame which contains this document.\");\n                return nullptr;\n            }\n        }\n        if (source->parentNode()) {\n            source->parentNode()->removeChild(source.get(), exceptionState);\n            if (exceptionState.hadException())\n                return nullptr;\n            RELEASE_ASSERT(!source->parentNode());\n        }\n    }\n\n    this->adoptIfNeeded(*source);\n\n    return source;\n}\n","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":233823,"func":"GahpClient::gt4_gram_client_job_start(const char * job_contact)\n{\n\tstatic const char* command = \"GT4_GRAM_JOB_START\";\n\n\tif  (server->m_commands_supported->contains_anycase(command)==FALSE) {\n\t\treturn GAHPCLIENT_COMMAND_NOT_SUPPORTED;\n\t}\n\n\tif (!job_contact) job_contact=NULLSTRING;\n\tstd::string reqline;\n\tint x = sprintf(reqline,\"%s\",escapeGahpString(job_contact));\n\tASSERT( x > 0 );\n\tconst char *buf = reqline.c_str();\n\n\tif ( !is_pending(command,buf) ) {\n\t\tif ( m_mode == results_only ) {\n\t\t\treturn GAHPCLIENT_COMMAND_NOT_SUBMITTED;\n\t\t}\n\t\tnow_pending(command,buf,normal_proxy);\n\t}\n\n\t\t\n\tGahp_Args* result = get_pending_result(command,buf);\n\tif ( result ) {\n\t\tif (result->argc != 3) {\n\t\t\tEXCEPT(\"Bad %s Result\",command);\n\t\t}\n\t\tint rc = atoi(result->argv[1]);\n\t\tif ( strcasecmp(result->argv[2], NULLSTRING) ) {\n\t\t\terror_string = result->argv[2];\n\t\t} else {\n\t\t\terror_string = \"\";\n\t\t}\n\t\tdelete result;\n\t\treturn rc;\n\t}\n\n\tif ( check_pending_timeout(command,buf) ) {\n\t\tsprintf( error_string, \"%s timed out\", command );\n\t\treturn GAHPCLIENT_COMMAND_TIMED_OUT;\n\t}\n\n\treturn GAHPCLIENT_COMMAND_PENDING;\n}\n","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":485803,"func":"int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_cancel *cancel = io_kiocb_to_cmd(req, struct io_cancel);\n\tstruct io_cancel_data cd = {\n\t\t.ctx\t= req->ctx,\n\t\t.data\t= cancel->addr,\n\t\t.flags\t= cancel->flags,\n\t\t.seq\t= atomic_inc_return(&req->ctx->cancel_seq),\n\t};\n\tstruct io_uring_task *tctx = req->task->io_uring;\n\tint ret;\n\n\tif (cd.flags & IORING_ASYNC_CANCEL_FD) {\n\t\tif (req->flags & REQ_F_FIXED_FILE ||\n\t\t    cd.flags & IORING_ASYNC_CANCEL_FD_FIXED) {\n\t\t\treq->flags |= REQ_F_FIXED_FILE;\n\t\t\treq->file = io_file_get_fixed(req, cancel->fd,\n\t\t\t\t\t\t\tissue_flags);\n\t\t} else {\n\t\t\treq->file = io_file_get_normal(req, cancel->fd);\n\t\t}\n\t\tif (!req->file) {\n\t\t\tret = -EBADF;\n\t\t\tgoto done;\n\t\t}\n\t\tcd.file = req->file;\n\t}\n\n\tret = __io_async_cancel(&cd, tctx, issue_flags);\ndone:\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_set_res(req, ret, 0);\n\treturn IOU_OK;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":449968,"func":"static void hdr_dump_tokens(struct crypt_device *cd, json_object *hdr_jobj)\n{\n\tchar token[16];\n\tjson_object *tokens_jobj, *jobj2, *jobj3, *val;\n\tconst char *tmps;\n\tint i, j;\n\n\tlog_std(cd, \"Tokens:\\n\");\n\tjson_object_object_get_ex(hdr_jobj, \"tokens\", &tokens_jobj);\n\n\tfor (j = 0; j < LUKS2_TOKENS_MAX; j++) {\n\t\t(void) snprintf(token, sizeof(token), \"%i\", j);\n\t\tjson_object_object_get_ex(tokens_jobj, token, &val);\n\t\tif (!val)\n\t\t\tcontinue;\n\n\t\tjson_object_object_get_ex(val, \"type\", &jobj2);\n\t\ttmps = json_object_get_string(jobj2);\n\t\tlog_std(cd, \"  %s: %s\\n\", token, tmps);\n\n\t\tLUKS2_token_dump(cd, j);\n\n\t\tjson_object_object_get_ex(val, \"keyslots\", &jobj2);\n\t\tfor (i = 0; i < (int) json_object_array_length(jobj2); i++) {\n\t\t\tjobj3 = json_object_array_get_idx(jobj2, i);\n\t\t\tlog_std(cd, \"\\tKeyslot:    %s\\n\", json_object_get_string(jobj3));\n\t\t}\n\t}\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":102828,"func":"int lzxd_set_reference_data(struct lzxd_stream *lzx,\n\t\t\t    struct mspack_system *system,\n\t\t\t    struct mspack_file *input,\n\t\t\t    unsigned int length)\n{\n    if (!lzx) return MSPACK_ERR_ARGS;\n\n    if (!lzx->is_delta) {\n        D((\"only LZX DELTA streams support reference data\"))\n        return MSPACK_ERR_ARGS;\n    }\n    if (lzx->offset) {\n\tD((\"too late to set reference data after decoding starts\"))\n\treturn MSPACK_ERR_ARGS;\n    }\n    if (length > lzx->window_size) {\n\tD((\"reference length (%u) is longer than the window\", length))\n\treturn MSPACK_ERR_ARGS;\n    }\n    if (length > 0 && (!system || !input)) {\n        D((\"length > 0 but no system or input\"))\n        return MSPACK_ERR_ARGS;\n    }\n\n    lzx->ref_data_size = length;\n    if (length > 0) {\n        \/* copy reference data *\/\n        unsigned char *pos = &lzx->window[lzx->window_size - length];\n\tint bytes = system->read(input, pos, length);\n        \/* length can't be more than 2^25, so no signedness problem *\/\n\tif (bytes < (int)length) return MSPACK_ERR_READ;\n    }\n    lzx->ref_data_size = length;\n    return MSPACK_ERR_OK;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":365453,"func":"xmlIsNameChar(xmlParserCtxtPtr ctxt, int c) {\n    if ((ctxt->options & XML_PARSE_OLD10) == 0) {\n        \/*\n\t * Use the new checks of production [4] [4a] amd [5] of the\n\t * Update 5 of XML-1.0\n\t *\/\n\tif ((c != ' ') && (c != '>') && (c != '\/') && \/* accelerators *\/\n\t    (((c >= 'a') && (c <= 'z')) ||\n\t     ((c >= 'A') && (c <= 'Z')) ||\n\t     ((c >= '0') && (c <= '9')) || \/* !start *\/\n\t     (c == '_') || (c == ':') ||\n\t     (c == '-') || (c == '.') || (c == 0xB7) || \/* !start *\/\n\t     ((c >= 0xC0) && (c <= 0xD6)) ||\n\t     ((c >= 0xD8) && (c <= 0xF6)) ||\n\t     ((c >= 0xF8) && (c <= 0x2FF)) ||\n\t     ((c >= 0x300) && (c <= 0x36F)) || \/* !start *\/\n\t     ((c >= 0x370) && (c <= 0x37D)) ||\n\t     ((c >= 0x37F) && (c <= 0x1FFF)) ||\n\t     ((c >= 0x200C) && (c <= 0x200D)) ||\n\t     ((c >= 0x203F) && (c <= 0x2040)) || \/* !start *\/\n\t     ((c >= 0x2070) && (c <= 0x218F)) ||\n\t     ((c >= 0x2C00) && (c <= 0x2FEF)) ||\n\t     ((c >= 0x3001) && (c <= 0xD7FF)) ||\n\t     ((c >= 0xF900) && (c <= 0xFDCF)) ||\n\t     ((c >= 0xFDF0) && (c <= 0xFFFD)) ||\n\t     ((c >= 0x10000) && (c <= 0xEFFFF))))\n\t     return(1);\n    } else {\n        if ((IS_LETTER(c)) || (IS_DIGIT(c)) ||\n            (c == '.') || (c == '-') ||\n\t    (c == '_') || (c == ':') || \n\t    (IS_COMBINING(c)) ||\n\t    (IS_EXTENDER(c)))\n\t    return(1);\n    }\n    return(0);\n}","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":320765,"func":"void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,\n\n                                      ptrdiff_t linesize_arg,\n\n                                      int block_w, int block_h,\n\n                                      int src_x, int src_y, int w, int h)\n\n{\n\n    int x, y;\n\n    int start_y, start_x, end_y, end_x;\n\n    emuedge_linesize_type linesize = linesize_arg;\n\n\n\n    if (!w || !h)\n\n        return;\n\n\n\n    if (src_y >= h) {\n\n        src -= src_y * linesize;\n\n        src += (h - 1) * linesize;\n\n        src_y = h - 1;\n\n    } else if (src_y <= -block_h) {\n\n        src -= src_y * linesize;\n\n        src += (1 - block_h) * linesize;\n\n        src_y = 1 - block_h;\n\n    }\n\n    if (src_x >= w) {\n\n        src  += (w - 1 - src_x) * sizeof(pixel);\n\n        src_x = w - 1;\n\n    } else if (src_x <= -block_w) {\n\n        src  += (1 - block_w - src_x) * sizeof(pixel);\n\n        src_x = 1 - block_w;\n\n    }\n\n\n\n    start_y = FFMAX(0, -src_y);\n\n    start_x = FFMAX(0, -src_x);\n\n    end_y = FFMIN(block_h, h-src_y);\n\n    end_x = FFMIN(block_w, w-src_x);\n\n    av_assert2(start_y < end_y && block_h);\n\n    av_assert2(start_x < end_x && block_w);\n\n\n\n    w    = end_x - start_x;\n\n    src += start_y * linesize + start_x * sizeof(pixel);\n\n    buf += start_x * sizeof(pixel);\n\n\n\n    \/\/ top\n\n    for (y = 0; y < start_y; y++) {\n\n        memcpy(buf, src, w * sizeof(pixel));\n\n        buf += linesize;\n\n    }\n\n\n\n    \/\/ copy existing part\n\n    for (; y < end_y; y++) {\n\n        memcpy(buf, src, w * sizeof(pixel));\n\n        src += linesize;\n\n        buf += linesize;\n\n    }\n\n\n\n    \/\/ bottom\n\n    src -= linesize;\n\n    for (; y < block_h; y++) {\n\n        memcpy(buf, src, w * sizeof(pixel));\n\n        buf += linesize;\n\n    }\n\n\n\n    buf -= block_h * linesize + start_x * sizeof(pixel);\n\n    while (block_h--) {\n\n        pixel *bufp = (pixel *) buf;\n\n\n\n        \/\/ left\n\n        for(x = 0; x < start_x; x++) {\n\n            bufp[x] = bufp[start_x];\n\n        }\n\n\n\n        \/\/ right\n\n        for (x = end_x; x < block_w; x++) {\n\n            bufp[x] = bufp[end_x - 1];\n\n        }\n\n        buf += linesize;\n\n    }\n\n}\n","target":1,"code_token_length":606,"total_token_length":842,"max_tokens_setting":1024}
+{"idx":143966,"func":"static void SendATCommand(struct mp_port *mtpt)\n{\n\t\/\/\t\t      a    t\tcr   lf\n\tunsigned char ch[] = {0x61,0x74,0x0d,0x0a,0x0};\n\tunsigned char lineControl;\n\tunsigned char i=0;\n\tunsigned char Divisor = 0xc;\n\n\tlineControl = serial_inp(mtpt,UART_LCR);\n\tserial_outp(mtpt,UART_LCR,(lineControl | UART_LCR_DLAB));\n\tserial_outp(mtpt,UART_DLL,(Divisor & 0xff));\n\tserial_outp(mtpt,UART_DLM,(Divisor & 0xff00)>>8); \/\/baudrate is 4800\n\n\n\tserial_outp(mtpt,UART_LCR,lineControl);\t\n\tserial_outp(mtpt,UART_LCR,0x03); \/\/ N-8-1\n\tserial_outp(mtpt,UART_FCR,7); \n\tserial_outp(mtpt,UART_MCR,0x3);\n\twhile(ch[i]){\n\t\twhile((serial_inp(mtpt,UART_LSR) & 0x60) !=0x60){\n\t\t\t;\n\t\t}\n\t\tserial_outp(mtpt,0,ch[i++]);\n\t}\n\n\n}\/\/ end of SendATCommand()","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":176046,"func":" void ShellWindowFrameView::Init(views::Widget* frame) {\n   frame_ = frame;\n\n  if (!is_frameless_) {\n    ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();\n    close_button_ = new views::ImageButton(this);\n    close_button_->SetImage(views::CustomButton::BS_NORMAL,\n        rb.GetNativeImageNamed(IDR_CLOSE_BAR).ToImageSkia());\n    close_button_->SetImage(views::CustomButton::BS_HOT,\n        rb.GetNativeImageNamed(IDR_CLOSE_BAR_H).ToImageSkia());\n    close_button_->SetImage(views::CustomButton::BS_PUSHED,\n        rb.GetNativeImageNamed(IDR_CLOSE_BAR_P).ToImageSkia());\n    close_button_->SetAccessibleName(\n        l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));\n    AddChildView(close_button_);\n  }\n \n #if defined(USE_ASH)\n   aura::Window* window = frame->GetNativeWindow();\n  int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?\n      kResizeOutsideBoundsSizeTouch :\n      kResizeOutsideBoundsSize;\n  window->set_hit_test_bounds_override_outer(\n      gfx::Insets(-outside_bounds, -outside_bounds,\n                  -outside_bounds, -outside_bounds));\n  window->set_hit_test_bounds_override_inner(\n      gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize,\n                  kResizeInsideBoundsSize, kResizeInsideBoundsSize));\n#endif\n }\n","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":58396,"func":"cmsBool  Type_UcrBg_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)\n{\n    cmsUcrBg* Value = (cmsUcrBg*) Ptr;\n    cmsUInt32Number TextSize;\n    char* Text;\n\n    \/\/ First curve is Under color removal\n    if (!_cmsWriteUInt32Number(io, Value ->Ucr ->nEntries)) return FALSE;\n    if (!_cmsWriteUInt16Array(io, Value ->Ucr ->nEntries, Value ->Ucr ->Table16)) return FALSE;\n\n    \/\/ Then black generation\n    if (!_cmsWriteUInt32Number(io, Value ->Bg ->nEntries)) return FALSE;\n    if (!_cmsWriteUInt16Array(io, Value ->Bg ->nEntries, Value ->Bg ->Table16)) return FALSE;\n\n    \/\/ Now comes the text. The length is specified by the tag size\n    TextSize = cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, NULL, 0);\n    Text     = (char*) _cmsMalloc(self ->ContextID, TextSize);\n    if (cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, Text, TextSize) != TextSize) return FALSE;\n\n    if (!io ->Write(io, TextSize, Text)) return FALSE;\n    _cmsFree(self ->ContextID, Text);\n\n    return TRUE;\n\n    cmsUNUSED_PARAMETER(nItems);\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":485307,"func":"bgp_write (struct thread *thread)\n{\n  struct peer *peer;\n  u_char type;\n  struct stream *s; \n  int num;\n  unsigned int count = 0;\n  int write_errno;\n\n  \/* Yes first of all get peer pointer. *\/\n  peer = THREAD_ARG (thread);\n  peer->t_write = NULL;\n\n  \/* For non-blocking IO check. *\/\n  if (peer->status == Connect)\n    {\n      bgp_connect_check (peer);\n      return 0;\n    }\n\n    \/* Nonblocking write until TCP output buffer is full.  *\/\n  while (1)\n    {\n      int writenum;\n      int val;\n\n      s = bgp_write_packet (peer);\n      if (! s)\n\treturn 0;\n      \n      \/* XXX: FIXME, the socket should be NONBLOCK from the start\n       * status shouldnt need to be toggled on each write\n       *\/\n      val = fcntl (peer->fd, F_GETFL, 0);\n      fcntl (peer->fd, F_SETFL, val|O_NONBLOCK);\n\n      \/* Number of bytes to be sent.  *\/\n      writenum = stream_get_endp (s) - stream_get_getp (s);\n\n      \/* Call write() system call.  *\/\n      num = write (peer->fd, STREAM_PNT (s), writenum);\n      write_errno = errno;\n      fcntl (peer->fd, F_SETFL, val);\n      if (num <= 0)\n\t{\n\t  \/* Partial write. *\/\n\t  if (write_errno == EWOULDBLOCK || write_errno == EAGAIN)\n\t      break;\n\n\t  BGP_EVENT_ADD (peer, TCP_fatal_error);\n\t  return 0;\n\t}\n      if (num != writenum)\n\t{\n\t  stream_forward_getp (s, num);\n\n\t  if (write_errno == EAGAIN)\n\t    break;\n\n\t  continue;\n\t}\n\n      \/* Retrieve BGP packet type. *\/\n      stream_set_getp (s, BGP_MARKER_SIZE + 2);\n      type = stream_getc (s);\n\n      switch (type)\n\t{\n\tcase BGP_MSG_OPEN:\n\t  peer->open_out++;\n\t  break;\n\tcase BGP_MSG_UPDATE:\n\t  peer->update_out++;\n\t  break;\n\tcase BGP_MSG_NOTIFY:\n\t  peer->notify_out++;\n\t  \/* Double start timer. *\/\n\t  peer->v_start *= 2;\n\n\t  \/* Overflow check. *\/\n\t  if (peer->v_start >= (60 * 2))\n\t    peer->v_start = (60 * 2);\n\n\t  \/* Flush any existing events *\/\n\t  BGP_EVENT_ADD (peer, BGP_Stop);\n\t  return 0;\n\tcase BGP_MSG_KEEPALIVE:\n\t  peer->keepalive_out++;\n\t  break;\n\tcase BGP_MSG_ROUTE_REFRESH_NEW:\n\tcase BGP_MSG_ROUTE_REFRESH_OLD:\n\t  peer->refresh_out++;\n\t  break;\n\tcase BGP_MSG_CAPABILITY:\n\t  peer->dynamic_cap_out++;\n\t  break;\n\t}\n\n      \/* OK we send packet so delete it. *\/\n      bgp_packet_delete (peer);\n\n      if (++count >= BGP_WRITE_PACKET_MAX)\n\tbreak;\n    }\n  \n  if (bgp_write_proceed (peer))\n    BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);\n  \n  return 0;\n}","target":0,"code_token_length":686,"total_token_length":922,"max_tokens_setting":1024}
+{"idx":165757,"func":"xps_parse_path_geometry(xps_document *doc, xps_resource *dict, fz_xml *root, int stroking, int *fill_rule)\n{\n\tfz_xml *node;\n\n\tchar *figures_att;\n\tchar *fill_rule_att;\n\tchar *transform_att;\n\n\tfz_xml *transform_tag = NULL;\n\tfz_xml *figures_tag = NULL; \/* only used by resource *\/\n\n\tfz_matrix transform;\n\tfz_path *path;\n\n\tfigures_att = fz_xml_att(root, \"Figures\");\n\tfill_rule_att = fz_xml_att(root, \"FillRule\");\n\ttransform_att = fz_xml_att(root, \"Transform\");\n\n\tfor (node = fz_xml_down(root); node; node = fz_xml_next(node))\n\t{\n\t\tif (!strcmp(fz_xml_tag(node), \"PathGeometry.Transform\"))\n\t\t\ttransform_tag = fz_xml_down(node);\n\t}\n\n\txps_resolve_resource_reference(doc, dict, &transform_att, &transform_tag, NULL);\n\txps_resolve_resource_reference(doc, dict, &figures_att, &figures_tag, NULL);\n\n\tif (fill_rule_att)\n\t{\n\t\tif (!strcmp(fill_rule_att, \"NonZero\"))\n\t\t\t*fill_rule = 1;\n\t\tif (!strcmp(fill_rule_att, \"EvenOdd\"))\n\t\t\t*fill_rule = 0;\n\t}\n\n\ttransform = fz_identity;\n\tif (transform_att)\n\t\txps_parse_render_transform(doc, transform_att, &transform);\n\tif (transform_tag)\n\t\txps_parse_matrix_transform(doc, transform_tag, &transform);\n\n\tif (figures_att)\n\t\tpath = xps_parse_abbreviated_geometry(doc, figures_att, fill_rule);\n\telse\n\t\tpath = fz_new_path(doc->ctx);\n\n\tif (figures_tag)\n\t\txps_parse_path_figure(doc->ctx, path, figures_tag, stroking);\n\n\tfor (node = fz_xml_down(root); node; node = fz_xml_next(node))\n\t{\n\t\tif (!strcmp(fz_xml_tag(node), \"PathFigure\"))\n\t\t\txps_parse_path_figure(doc->ctx, path, node, stroking);\n\t}\n\n\tif (transform_att || transform_tag)\n\t\tfz_transform_path(doc->ctx, path, &transform);\n\n\treturn path;\n}\n","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":52849,"func":"R_API void r_core_bin_export_info_rad(RCore *core) {\n\tSdb *db = NULL;\n\tchar *flagname = NULL, *offset = NULL;\n\tRBinFile *bf = r_bin_cur (core->bin);\n\tif (!bf) {\n\t\treturn;\n\t}\n\tdb = sdb_ns (bf->sdb, \"info\", 0);;\n\tif (db) {\n\t\tSdbListIter *iter;\n\t\tSdbKv *kv;\n\t\tr_cons_printf (\"fs format\\n\");\n\t\t\/\/ iterate over all keys\n\t\tSdbList *ls = sdb_foreach_list (db, false);\n\t\tls_foreach (ls, iter, kv) {\n\t\t\tchar *k = sdbkv_key (kv);\n\t\t\tchar *v = sdbkv_value (kv);\n\t\t\tchar *dup = strdup (k);\n\t\t\t\/\/printf (\"?e (%s) (%s)\\n\", k, v);\n\t\t\tif ((flagname = strstr (dup, \".offset\"))) {\n\t\t\t\t*flagname = 0;\n\t\t\t\tflagname = dup;\n\t\t\t\tr_cons_printf (\"f %s @ %s\\n\", flagname, v);\n\t\t\t\tfree (offset);\n\t\t\t\toffset = strdup (v);\n\t\t\t}\n\t\t\tif ((flagname = strstr (dup, \".cparse\"))) {\n\t\t\t\tr_cons_printf (\"\\\"td %s\\\"\\n\", v);\n\t\t\t}\n\t\t\tfree (dup);\n\t\t}\n\t\tR_FREE (offset);\n\t\tls_foreach (ls, iter, kv) {\n\t\t\tchar *k = sdbkv_key (kv);\n\t\t\tchar *v = sdbkv_value (kv);\n\t\t\tchar *dup = strdup (k);\n\t\t\tif ((flagname = strstr (dup, \".format\"))) {\n\t\t\t\t*flagname = 0;\n\t\t\t\tif (!offset) {\n\t\t\t\t\toffset = strdup (\"0\");\n\t\t\t\t}\n\t\t\t\tflagname = dup;\n\t\t\t\tr_cons_printf (\"pf.%s %s\\n\", flagname, v);\n\t\t\t}\n\t\t\tfree (dup);\n\t\t}\n\t\tls_foreach (ls, iter, kv) {\n\t\t\tchar *k = sdbkv_key (kv);\n\t\t\tchar *v = sdbkv_value (kv);\n\t\t\tchar *dup = strdup (k);\n\t\t\tif ((flagname = strstr (dup, \".format\"))) {\n\t\t\t\t*flagname = 0;\n\t\t\t\tif (!offset) {\n\t\t\t\t\toffset = strdup (\"0\");\n\t\t\t\t}\n\t\t\t\tflagname = dup;\n\t\t\t\tint fmtsize = r_print_format_struct_size (core->print, v, 0, 0);\n\t\t\t\tchar *offset_key = r_str_newf (\"%s.offset\", flagname);\n\t\t\t\tconst char *off = sdb_const_get (db, offset_key, 0);\n\t\t\t\tfree (offset_key);\n\t\t\t\tif (off) {\n\t\t\t\t\tr_cons_printf (\"Cf %d %s @ %s\\n\", fmtsize, v, off);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ((flagname = strstr (dup, \".size\"))) {\n\t\t\t\t*flagname = 0;\n\t\t\t\tflagname = dup;\n\t\t\t\tr_cons_printf (\"fl %s %s\\n\", flagname, v);\n\t\t\t}\n\t\t\tfree (dup);\n\t\t}\n\t\tfree (offset);\n\t}\n}","target":0,"code_token_length":678,"total_token_length":914,"max_tokens_setting":1024}
+{"idx":341256,"func":"void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,\n\n                               unsigned int *out_bytes,\n\n                               unsigned max_in_bytes, unsigned max_out_bytes)\n\n{\n\n    unsigned int idx;\n\n    unsigned int total_bufs, in_total, out_total;\n\n\n\n    idx = vq->last_avail_idx;\n\n\n\n    total_bufs = in_total = out_total = 0;\n\n    while (virtqueue_num_heads(vq, idx)) {\n\n        unsigned int max, num_bufs, indirect = 0;\n\n        hwaddr desc_pa;\n\n        int i;\n\n\n\n        max = vq->vring.num;\n\n        num_bufs = total_bufs;\n\n        i = virtqueue_get_head(vq, idx++);\n\n        desc_pa = vq->vring.desc;\n\n\n\n        if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_INDIRECT) {\n\n            if (vring_desc_len(desc_pa, i) % sizeof(VRingDesc)) {\n\n                error_report(\"Invalid size for indirect buffer table\");\n\n                exit(1);\n\n            }\n\n\n\n            \/* If we've got too many, that implies a descriptor loop. *\/\n\n            if (num_bufs >= max) {\n\n                error_report(\"Looped descriptor\");\n\n                exit(1);\n\n            }\n\n\n\n            \/* loop over the indirect descriptor table *\/\n\n            indirect = 1;\n\n            max = vring_desc_len(desc_pa, i) \/ sizeof(VRingDesc);\n\n            num_bufs = i = 0;\n\n            desc_pa = vring_desc_addr(desc_pa, i);\n\n        }\n\n\n\n        do {\n\n            \/* If we've got too many, that implies a descriptor loop. *\/\n\n            if (++num_bufs > max) {\n\n                error_report(\"Looped descriptor\");\n\n                exit(1);\n\n            }\n\n\n\n            if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) {\n\n                in_total += vring_desc_len(desc_pa, i);\n\n            } else {\n\n                out_total += vring_desc_len(desc_pa, i);\n\n            }\n\n            if (in_total >= max_in_bytes && out_total >= max_out_bytes) {\n\n                goto done;\n\n            }\n\n        } while ((i = virtqueue_next_desc(desc_pa, i, max)) != max);\n\n\n\n        if (!indirect)\n\n            total_bufs = num_bufs;\n\n        else\n\n            total_bufs++;\n\n    }\n\ndone:\n\n    if (in_bytes) {\n\n        *in_bytes = in_total;\n\n    }\n\n    if (out_bytes) {\n\n        *out_bytes = out_total;\n\n    }\n\n}\n","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":347559,"func":"ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)\n{\n\tstruct ext4_group_desc *desc;\n\tstruct buffer_head *bh;\n\text4_fsblk_t bitmap_blk;\n\tint err;\n\n\tdesc = ext4_get_group_desc(sb, block_group, NULL);\n\tif (!desc)\n\t\treturn ERR_PTR(-EFSCORRUPTED);\n\tbitmap_blk = ext4_block_bitmap(sb, desc);\n\tbh = sb_getblk(sb, bitmap_blk);\n\tif (unlikely(!bh)) {\n\t\text4_error(sb, \"Cannot get buffer for block bitmap - \"\n\t\t\t   \"block_group = %u, block_bitmap = %llu\",\n\t\t\t   block_group, bitmap_blk);\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\n\tif (bitmap_uptodate(bh))\n\t\tgoto verify;\n\n\tlock_buffer(bh);\n\tif (bitmap_uptodate(bh)) {\n\t\tunlock_buffer(bh);\n\t\tgoto verify;\n\t}\n\text4_lock_group(sb, block_group);\n\tif (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {\n\t\terr = ext4_init_block_bitmap(sb, bh, block_group, desc);\n\t\tset_bitmap_uptodate(bh);\n\t\tset_buffer_uptodate(bh);\n\t\tset_buffer_verified(bh);\n\t\text4_unlock_group(sb, block_group);\n\t\tunlock_buffer(bh);\n\t\tif (err) {\n\t\t\text4_error(sb, \"Failed to init block bitmap for group \"\n\t\t\t\t   \"%u: %d\", block_group, err);\n\t\t\tgoto out;\n\t\t}\n\t\tgoto verify;\n\t}\n\text4_unlock_group(sb, block_group);\n\tif (buffer_uptodate(bh)) {\n\t\t\/*\n\t\t * if not uninit if bh is uptodate,\n\t\t * bitmap is also uptodate\n\t\t *\/\n\t\tset_bitmap_uptodate(bh);\n\t\tunlock_buffer(bh);\n\t\tgoto verify;\n\t}\n\t\/*\n\t * submit the buffer_head for reading\n\t *\/\n\tset_buffer_new(bh);\n\ttrace_ext4_read_block_bitmap_load(sb, block_group);\n\tbh->b_end_io = ext4_end_bitmap_read;\n\tget_bh(bh);\n\tsubmit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);\n\treturn bh;\nverify:\n\terr = ext4_validate_block_bitmap(sb, desc, block_group, bh);\n\tif (err)\n\t\tgoto out;\n\treturn bh;\nout:\n\tput_bh(bh);\n\treturn ERR_PTR(err);\n}","target":1,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":294153,"func":"TEST_F(HTTPDownstreamSessionTest, SingleBytesWithBody) {\n  InSequence enforceOrder;\n\n  auto handler = addSimpleNiceHandler();\n  handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {\n      const HTTPHeaders& hdrs = msg->getHeaders();\n      EXPECT_EQ(3, hdrs.size());\n      EXPECT_TRUE(hdrs.exists(\"host\"));\n      EXPECT_TRUE(hdrs.exists(\"content-length\"));\n      EXPECT_TRUE(hdrs.exists(\"myheader\"));\n\n      EXPECT_FALSE(msg->getIsChunked());\n      EXPECT_FALSE(msg->getIsUpgraded());\n      EXPECT_EQ(\"\/somepath.php?param=foo\", msg->getURL());\n      EXPECT_EQ(\"\/somepath.php\", msg->getPath());\n      EXPECT_EQ(\"param=foo\", msg->getQueryString());\n      EXPECT_EQ(1, msg->getHTTPVersion().first);\n      EXPECT_EQ(1, msg->getHTTPVersion().second);\n    });\n  EXPECT_CALL(*handler, onBody(_))\n    .WillOnce(ExpectString(\"1\"))\n    .WillOnce(ExpectString(\"2\"))\n    .WillOnce(ExpectString(\"3\"))\n    .WillOnce(ExpectString(\"4\"))\n    .WillOnce(ExpectString(\"5\"));\n  onEOMTerminateHandlerExpectShutdown(*handler);\n\n  addSingleByteReads(\"POST \/somepath.php?param=foo HTTP\/1.1\\r\\n\"\n                     \"Host: example.com\\r\\n\"\n                     \"MyHeader: FooBar\\r\\n\"\n                     \"Content-Length: 5\\r\\n\"\n                     \"\\r\\n\"\n                     \"12345\");\n  transport_->addReadEOF(milliseconds(0));\n  transport_->startReadEvents();\n  eventBase_.loop();\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":339299,"func":"static av_cold int vdadec_init(AVCodecContext *avctx)\n{\n    VDADecoderContext *ctx = avctx->priv_data;\n    struct vda_context *vda_ctx = &ctx->vda_ctx;\n    OSStatus status;\n    int ret;\n    ctx->h264_initialized = 0;\n    \/* init pix_fmts of codec *\/\n    if (!ff_h264_vda_decoder.pix_fmts) {\n        if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)\n            ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;\n        else\n            ff_h264_vda_decoder.pix_fmts = vda_pixfmts;\n    \/* init vda *\/\n    memset(vda_ctx, 0, sizeof(struct vda_context));\n    vda_ctx->width = avctx->width;\n    vda_ctx->height = avctx->height;\n    vda_ctx->format = 'avc1';\n    vda_ctx->use_sync_decoding = 1;\n    vda_ctx->use_ref_buffer = 1;\n    ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);\n    switch (ctx->pix_fmt) {\n    case AV_PIX_FMT_UYVY422:\n        vda_ctx->cv_pix_fmt_type = '2vuy';\n        break;\n    case AV_PIX_FMT_YUYV422:\n        vda_ctx->cv_pix_fmt_type = 'yuvs';\n        break;\n    case AV_PIX_FMT_NV12:\n        vda_ctx->cv_pix_fmt_type = '420v';\n        break;\n    case AV_PIX_FMT_YUV420P:\n        vda_ctx->cv_pix_fmt_type = 'y420';\n        break;\n    default:\n        av_log(avctx, AV_LOG_ERROR, \"Unsupported pixel format: %d\\n\", avctx->pix_fmt);\n    status = ff_vda_create_decoder(vda_ctx,\n                                   avctx->extradata, avctx->extradata_size);\n    if (status != kVDADecoderNoErr) {\n        av_log(avctx, AV_LOG_ERROR,\n                \"Failed to init VDA decoder: %d.\\n\", status);\n    \/* init H.264 decoder *\/\n    set_context(avctx);\n    ret = ff_h264_decoder.init(avctx);\n    restore_context(avctx);\n    if (ret < 0) {\n        av_log(avctx, AV_LOG_ERROR, \"Failed to open H.264 decoder.\\n\");\n    ctx->h264_initialized = 1;\n    return 0;\nfailed:\n    vdadec_close(avctx);\n    return -1;","target":1,"code_token_length":590,"total_token_length":826,"max_tokens_setting":1024}
+{"idx":332061,"func":"int main(int argc, char* argv[])\n\n{\n\n    FILE *f[2];\n\n    uint8_t *buf[2], *plane[2][3];\n\n    int *temp;\n\n    uint64_t ssd[3] = {0,0,0};\n\n    double ssim[3] = {0,0,0};\n\n    int frame_size, w, h;\n\n    int frames, seek;\n\n    int i;\n\n\n\n    if( argc<4 || 2 != sscanf(argv[3], \"%dx%d\", &w, &h) )\n\n    {\n\n        printf(\"tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\\n\");\n\n        return -1;\n\n    }\n\n\n\n    f[0] = fopen(argv[1], \"rb\");\n\n    f[1] = fopen(argv[2], \"rb\");\n\n    sscanf(argv[3], \"%dx%d\", &w, &h);\n\n    frame_size = w*h*3\/2;\n\n    for( i=0; i<2; i++ )\n\n    {\n\n        buf[i] = malloc(frame_size);\n\n        plane[i][0] = buf[i];\n\n        plane[i][1] = plane[i][0] + w*h;\n\n        plane[i][2] = plane[i][1] + w*h\/4;\n\n    }\n\n    temp = malloc((2*w+12)*sizeof(*temp));\n\n    seek = argc<5 ? 0 : atoi(argv[4]);\n\n    fseek(f[seek<0], seek < 0 ? -seek : seek, SEEK_SET);\n\n\n\n    for( frames=0;; frames++ )\n\n    {\n\n        uint64_t ssd_one[3];\n\n        double ssim_one[3];\n\n        if( fread(buf[0], frame_size, 1, f[0]) != 1) break;\n\n        if( fread(buf[1], frame_size, 1, f[1]) != 1) break;\n\n        for( i=0; i<3; i++ )\n\n        {\n\n            ssd_one[i]  = ssd_plane ( plane[0][i], plane[1][i], w*h>>2*!!i );\n\n            ssim_one[i] = ssim_plane( plane[0][i], w>>!!i,\n\n                                     plane[1][i], w>>!!i,\n\n                                     w>>!!i, h>>!!i, temp, NULL );\n\n            ssd[i] += ssd_one[i];\n\n            ssim[i] += ssim_one[i];\n\n        }\n\n\n\n        printf(\"Frame %d | \", frames);\n\n        print_results(ssd_one, ssim_one, 1, w, h);\n\n        printf(\"                \\r\");\n\n        fflush(stdout);\n\n    }\n\n\n\n    if( !frames ) return 0;\n\n\n\n    printf(\"Total %d frames | \", frames);\n\n    print_results(ssd, ssim, frames, w, h);\n\n    printf(\"\\n\");\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":622,"total_token_length":858,"max_tokens_setting":1024}
+{"idx":306512,"func":"mymono_metadata_type_hash (MonoType *t1)\n{\n\tguint hash;\n\n\thash = t1->type;\n\n\thash |= t1->byref << 6; \/* do not collide with t1->type values *\/\n\tswitch (t1->type) {\n\tcase MONO_TYPE_VALUETYPE:\n\tcase MONO_TYPE_CLASS:\n\tcase MONO_TYPE_SZARRAY:\n\t\t\/* check if the distribution is good enough *\/\n\t\treturn ((hash << 5) - hash) ^ mono_aligned_addr_hash (t1->data.klass);\n\tcase MONO_TYPE_PTR:\n\t\treturn ((hash << 5) - hash) ^ mymono_metadata_type_hash (t1->data.type);\n\tcase MONO_TYPE_GENERICINST: {\n\t\tint i;\n\t\tMonoGenericInst *inst = t1->data.generic_class->context.class_inst;\n\t\thash += g_str_hash (t1->data.generic_class->container_class->name);\n\t\thash *= 13;\n\t\tfor (i = 0; i < inst->type_argc; ++i) {\n\t\t\thash += mymono_metadata_type_hash (inst->type_argv [i]);\n\t\t\thash *= 13;\n\t\t}\n\t\treturn hash;\n\t}\n\tcase MONO_TYPE_VAR:\n\tcase MONO_TYPE_MVAR:\n\t\treturn ((hash << 5) - hash) ^ GPOINTER_TO_UINT (t1->data.generic_param);\n\t}\n\treturn hash;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":63827,"func":"static URI_INLINE const URI_CHAR * URI_FUNC(ParseIpLit2)(\n\t\tURI_TYPE(ParserState) * state, const URI_CHAR * first,\n\t\tconst URI_CHAR * afterLast, UriMemoryManager * memory) {\n\tif (first >= afterLast) {\n\t\tURI_FUNC(StopSyntax)(state, first, memory);\n\t\treturn NULL;\n\t}\n\n\tswitch (*first) {\n\tcase _UT('v'):\n\t\t{\n\t\t\tconst URI_CHAR * const afterIpFuture\n\t\t\t\t\t= URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);\n\t\t\tif (afterIpFuture == NULL) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif ((afterIpFuture >= afterLast)\n\t\t\t\t\t|| (*afterIpFuture != _UT(']'))) {\n\t\t\t\tURI_FUNC(StopSyntax)(state, first, memory);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treturn afterIpFuture + 1;\n\t\t}\n\n\tcase _UT(':'):\n\tcase _UT(']'):\n\tcase URI_SET_HEXDIG:\n\t\tstate->uri->hostData.ip6 = memory->malloc(memory, 1 * sizeof(UriIp6)); \/* Freed when stopping on parse error *\/\n\t\tif (state->uri->hostData.ip6 == NULL) {\n\t\t\tURI_FUNC(StopMalloc)(state, memory);\n\t\t\treturn NULL;\n\t\t}\n\t\treturn URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory);\n\n\tdefault:\n\t\tURI_FUNC(StopSyntax)(state, first, memory);\n\t\treturn NULL;\n\t}\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":317627,"func":"RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(\n    const GURL& page_url) const {\n  if (page_url.host() == extension_misc::kBookmarkManagerId)\n    return BookmarksUI::GetFaviconResourceBytes();\n\n  if (page_url.SchemeIs(chrome::kExtensionScheme)) {\n    NOTREACHED();\n     return NULL;\n   }\n \n  if (!content::GetContentClient()->HasWebUIScheme(page_url))\n     return NULL;\n \n #if defined(OS_WIN)\n  if (page_url.host() == chrome::kChromeUIConflictsHost)\n    return ConflictsUI::GetFaviconResourceBytes();\n#endif\n\n  if (page_url.host() == chrome::kChromeUICrashesHost)\n    return CrashesUI::GetFaviconResourceBytes();\n\n  if (page_url.host() == chrome::kChromeUIHistoryHost)\n    return HistoryUI::GetFaviconResourceBytes();\n\n  if (page_url.host() == chrome::kChromeUIFlagsHost)\n    return FlagsUI::GetFaviconResourceBytes();\n\n  if (page_url.host() == chrome::kChromeUISessionsHost)\n    return SessionsUI::GetFaviconResourceBytes();\n\n  if (page_url.host() == chrome::kChromeUIFlashHost)\n    return FlashUI::GetFaviconResourceBytes();\n\n#if !defined(OS_ANDROID)\n  if (page_url.host() == chrome::kChromeUIDownloadsHost)\n    return DownloadsUI::GetFaviconResourceBytes();\n\n  if (page_url.host() == chrome::kChromeUISettingsHost)\n    return OptionsUI::GetFaviconResourceBytes();\n\n  if (page_url.host() == chrome::kChromeUISettingsFrameHost)\n    return options2::OptionsUI::GetFaviconResourceBytes();\n#endif\n\n  if (page_url.host() == chrome::kChromeUIPluginsHost)\n    return PluginsUI::GetFaviconResourceBytes();\n\n  return NULL;\n}\n","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":2256,"func":"error_t ssiProcessExecCommand(HttpConnection *connection, const char_t *tag, size_t length)\n{\n   char_t *separator;\n   char_t *attribute;\n   char_t *value;\n\n   \/\/First, check whether CGI is supported by the server\n   if(connection->settings->cgiCallback == NULL)\n      return ERROR_INVALID_TAG;\n\n   \/\/Discard invalid SSI directives\n   if(length < 4 || length >= HTTP_SERVER_BUFFER_SIZE)\n      return ERROR_INVALID_TAG;\n\n   \/\/Skip the SSI exec command (4 bytes)\n   osMemcpy(connection->buffer, tag + 4, length - 4);\n   \/\/Ensure the resulting string is NULL-terminated\n   connection->buffer[length - 4] = '\\0';\n\n   \/\/Check whether a separator is present\n   separator = strchr(connection->buffer, '=');\n   \/\/Separator not found?\n   if(!separator)\n      return ERROR_INVALID_TAG;\n\n   \/\/Split the tag\n   *separator = '\\0';\n\n   \/\/Get attribute name and value\n   attribute = strTrimWhitespace(connection->buffer);\n   value = strTrimWhitespace(separator + 1);\n\n   \/\/Remove leading simple or double quote\n   if(value[0] == '\\'' || value[0] == '\\\"')\n      value++;\n\n   \/\/Get the length of the attribute value\n   length = osStrlen(value);\n\n   \/\/Remove trailing simple or double quote\n   if(length > 0)\n   {\n      if(value[length - 1] == '\\'' || value[length - 1] == '\\\"')\n         value[length - 1] = '\\0';\n   }\n\n   \/\/Enforce attribute name\n   if(osStrcasecmp(attribute, \"cgi\") && osStrcasecmp(attribute, \"cmd\") && osStrcasecmp(attribute, \"cmd_argument\"))\n      return ERROR_INVALID_TAG;\n   \/\/Check the length of the CGI parameter\n   if(osStrlen(value) > HTTP_SERVER_CGI_PARAM_MAX_LEN)\n      return ERROR_INVALID_TAG;\n\n   \/\/The scratch buffer may be altered by the user-defined callback.\n   \/\/So the CGI parameter must be copied prior to function invocation\n   osStrcpy(connection->cgiParam, value);\n\n   \/\/Invoke user-defined callback\n   return connection->settings->cgiCallback(connection, connection->cgiParam);\n}","target":1,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":182206,"func":"internalEntityProcessor(XML_Parser parser,\n                        const char *s,\n                        const char *end,\n                        const char **nextPtr)\n{\n  ENTITY *entity;\n  const char *textStart, *textEnd;\n  const char *next;\n  enum XML_Error result;\n  OPEN_INTERNAL_ENTITY *openEntity = parser->m_openInternalEntities;\n  if (!openEntity)\n    return XML_ERROR_UNEXPECTED_STATE;\n\n  entity = openEntity->entity;\n  textStart = ((char *)entity->textPtr) + entity->processed;\n  textEnd = (char *)(entity->textPtr + entity->textLen);\n  \/* Set a safe default value in case 'next' does not get set *\/\n  next = textStart;\n\n#ifdef XML_DTD\n  if (entity->is_param) {\n    int tok = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);\n    result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, tok,\n                      next, &next, XML_FALSE);\n  }\n  else\n#endif \/* XML_DTD *\/\n    result = doContent(parser, openEntity->startTagLevel, parser->m_internalEncoding,\n                       textStart, textEnd, &next, XML_FALSE);\n\n  if (result != XML_ERROR_NONE)\n    return result;\n  else if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {\n    entity->processed = (int)(next - (char *)entity->textPtr);\n    return result;\n  }\n  else {\n    entity->open = XML_FALSE;\n    parser->m_openInternalEntities = openEntity->next;\n    \/* put openEntity back in list of free instances *\/\n    openEntity->next = parser->m_freeInternalEntities;\n    parser->m_freeInternalEntities = openEntity;\n  }\n\n#ifdef XML_DTD\n  if (entity->is_param) {\n    int tok;\n    parser->m_processor = prologProcessor;\n    tok = XmlPrologTok(parser->m_encoding, s, end, &next);\n    return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,\n                    (XML_Bool)!parser->m_parsingStatus.finalBuffer);\n  }\n  else\n#endif \/* XML_DTD *\/\n  {\n    parser->m_processor = contentProcessor;\n    \/* see externalEntityContentProcessor vs contentProcessor *\/\n    return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, s, end,\n                     nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer);\n  }\n}\n","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":497297,"func":"static int ff_layout_write_done_cb(struct rpc_task *task,\n\t\t\t\tstruct nfs_pgio_header *hdr)\n{\n\tloff_t end_offs = 0;\n\tint err;\n\n\tif (task->tk_status < 0) {\n\t\tff_layout_io_track_ds_error(hdr->lseg, hdr->pgio_mirror_idx,\n\t\t\t\t\t    hdr->args.offset, hdr->args.count,\n\t\t\t\t\t    &hdr->res.op_status, OP_WRITE,\n\t\t\t\t\t    task->tk_status);\n\t\ttrace_ff_layout_write_error(hdr);\n\t}\n\n\terr = ff_layout_async_handle_error(task, hdr->args.context->state,\n\t\t\t\t\t   hdr->ds_clp, hdr->lseg,\n\t\t\t\t\t   hdr->pgio_mirror_idx);\n\n\ttrace_nfs4_pnfs_write(hdr, err);\n\tclear_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags);\n\tclear_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags);\n\tswitch (err) {\n\tcase -NFS4ERR_RESET_TO_PNFS:\n\t\tset_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags);\n\t\treturn task->tk_status;\n\tcase -NFS4ERR_RESET_TO_MDS:\n\t\tset_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags);\n\t\treturn task->tk_status;\n\tcase -EAGAIN:\n\t\treturn -EAGAIN;\n\t}\n\n\tif (hdr->res.verf->committed == NFS_FILE_SYNC ||\n\t    hdr->res.verf->committed == NFS_DATA_SYNC)\n\t\tend_offs = hdr->mds_offset + (loff_t)hdr->res.count;\n\n\t\/* Note: if the write is unstable, don't set end_offs until commit *\/\n\tff_layout_set_layoutcommit(hdr->inode, hdr->lseg, end_offs);\n\n\t\/* zero out fattr since we don't care DS attr at all *\/\n\thdr->fattr.valid = 0;\n\tif (task->tk_status >= 0)\n\t\tnfs_writeback_update_inode(hdr);\n\n\treturn 0;\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":195341,"func":"static const char *getpassf(const char *filename)\n{\n\tSTRUCT_STAT st;\n\tchar buffer[512], *p;\n\tint n;\n\n\tif (!filename)\n\t\treturn NULL;\n\n\tif (strcmp(filename, \"-\") == 0) {\n\t\tn = fgets(buffer, sizeof buffer, stdin) == NULL ? -1 : (int)strlen(buffer);\n\t} else {\n\t\tint fd;\n\n\t\tif ((fd = open(filename,O_RDONLY)) < 0) {\n\t\t\trsyserr(FERROR, errno, \"could not open password file %s\", filename);\n\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t}\n\n\t\tif (do_stat(filename, &st) == -1) {\n\t\t\trsyserr(FERROR, errno, \"stat(%s)\", filename);\n\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t}\n\t\tif ((st.st_mode & 06) != 0) {\n\t\t\trprintf(FERROR, \"ERROR: password file must not be other-accessible\\n\");\n\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t}\n\t\tif (MY_UID() == 0 && st.st_uid != 0) {\n\t\t\trprintf(FERROR, \"ERROR: password file must be owned by root when running as root\\n\");\n\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t}\n\n\t\tn = read(fd, buffer, sizeof buffer - 1);\n\t\tclose(fd);\n\t}\n\n\tif (n > 0) {\n\t\tbuffer[n] = '\\0';\n\t\tif ((p = strtok(buffer, \"\\n\\r\")) != NULL)\n\t\t\treturn strdup(p);\n\t}\n\n\trprintf(FERROR, \"ERROR: failed to read a password from %s\\n\", filename);\n\texit_cleanup(RERR_SYNTAX);\n}\n","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":411503,"func":"\n    CImg<T>& _priority_queue_remove(unsigned int& siz) {\n      (*this)(0,0) = (*this)(--siz,0);\n      (*this)(0,1) = (*this)(siz,1);\n      (*this)(0,2) = (*this)(siz,2);\n      (*this)(0,3) = (*this)(siz,3);\n      const float value = (*this)(0,0);\n      for (unsigned int pos = 0, left = 0, right = 0;\n           ((right=2*(pos + 1),(left=right - 1))<siz && value<(*this)(left,0)) ||\n             (right<siz && value<(*this)(right,0));) {\n        if (right<siz) {\n          if ((*this)(left,0)>(*this)(right,0)) {\n            cimg::swap((*this)(pos,0),(*this)(left,0));\n            cimg::swap((*this)(pos,1),(*this)(left,1));\n            cimg::swap((*this)(pos,2),(*this)(left,2));\n            cimg::swap((*this)(pos,3),(*this)(left,3));\n            pos = left;\n          } else {\n            cimg::swap((*this)(pos,0),(*this)(right,0));\n            cimg::swap((*this)(pos,1),(*this)(right,1));\n            cimg::swap((*this)(pos,2),(*this)(right,2));\n            cimg::swap((*this)(pos,3),(*this)(right,3));\n            pos = right;\n          }\n        } else {\n          cimg::swap((*this)(pos,0),(*this)(left,0));\n          cimg::swap((*this)(pos,1),(*this)(left,1));\n          cimg::swap((*this)(pos,2),(*this)(left,2));\n          cimg::swap((*this)(pos,3),(*this)(left,3));\n          pos = left;\n        }\n      }\n      return *this;","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":334351,"func":"static int svag_read_header(AVFormatContext *s)\n\n{\n\n    unsigned size, align;\n\n    AVStream *st;\n\n\n\n    avio_skip(s->pb, 4);\n\n\n\n    st = avformat_new_stream(s, NULL);\n\n    if (!st)\n\n        return AVERROR(ENOMEM);\n\n\n\n    size                   = avio_rl32(s->pb);\n\n    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;\n\n    st->codec->codec_id    = AV_CODEC_ID_ADPCM_PSX;\n\n    st->codec->sample_rate = avio_rl32(s->pb);\n\n    if (st->codec->sample_rate <= 0)\n\n        return AVERROR_INVALIDDATA;\n\n    st->codec->channels    = avio_rl32(s->pb);\n\n    if (st->codec->channels <= 0)\n\n        return AVERROR_INVALIDDATA;\n\n    st->duration           = size \/ (16 * st->codec->channels) * 28;\n\n    align                  = avio_rl32(s->pb);\n\n    if (align <= 0 || align > INT_MAX \/ st->codec->channels)\n\n        return AVERROR_INVALIDDATA;\n\n    st->codec->block_align = align * st->codec->channels;\n\n    avio_skip(s->pb, 0x800 - avio_tell(s->pb));\n\n    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":327417,"func":"void virtio_scsi_dataplane_stop(VirtIOSCSI *s)\n\n{\n\n    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));\n\n    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n\n    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);\n\n    int i;\n\n\n\n    \/* Better luck next time. *\/\n\n    if (s->dataplane_fenced) {\n\n        s->dataplane_fenced = false;\n\n        return;\n\n    }\n\n    if (!s->dataplane_started || s->dataplane_stopping) {\n\n        return;\n\n    }\n\n    s->dataplane_stopping = true;\n\n    assert(s->ctx == iothread_get_aio_context(vs->conf.iothread));\n\n\n\n    aio_context_acquire(s->ctx);\n\n\n\n    aio_set_event_notifier(s->ctx, &s->ctrl_vring->host_notifier,\n\n                           false, NULL);\n\n    aio_set_event_notifier(s->ctx, &s->event_vring->host_notifier,\n\n                           false, NULL);\n\n    for (i = 0; i < vs->conf.num_queues; i++) {\n\n        aio_set_event_notifier(s->ctx, &s->cmd_vrings[i]->host_notifier,\n\n                               false, NULL);\n\n    }\n\n\n\n    blk_drain_all(); \/* ensure there are no in-flight requests *\/\n\n\n\n    aio_context_release(s->ctx);\n\n\n\n    \/* Sync vring state back to virtqueue so that non-dataplane request\n\n     * processing can continue when we disable the host notifier below.\n\n     *\/\n\n    virtio_scsi_vring_teardown(s);\n\n\n\n    for (i = 0; i < vs->conf.num_queues + 2; i++) {\n\n        k->set_host_notifier(qbus->parent, i, false);\n\n    }\n\n\n\n    \/* Clean up guest notifier (irq) *\/\n\n    k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);\n\n    s->dataplane_stopping = false;\n\n    s->dataplane_started = false;\n\n}\n","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":164128,"func":"static void uipc_flush_ch_locked(tUIPC_CH_ID ch_id)\n{\n char buf[UIPC_FLUSH_BUFFER_SIZE];\n struct pollfd pfd;\n int ret;\n\n    pfd.events = POLLIN;\n    pfd.fd = uipc_main.ch[ch_id].fd;\n\n if (uipc_main.ch[ch_id].fd == UIPC_DISCONNECTED)\n {\n        BTIF_TRACE_EVENT(\"%s() - fd disconnected. Exiting\", __FUNCTION__);\n return;\n }\n\n \n     while (1)\n     {\n        ret = TEMP_FAILURE_RETRY(poll(&pfd, 1, 1));\n         BTIF_TRACE_VERBOSE(\"%s() - polling fd %d, revents: 0x%x, ret %d\",\n                 __FUNCTION__, pfd.fd, pfd.revents, ret);\n \n if (pfd.revents & (POLLERR|POLLHUP))\n {\n            BTIF_TRACE_EVENT(\"%s() - POLLERR or POLLHUP. Exiting\", __FUNCTION__);\n return;\n }\n\n if (ret <= 0)\n {\n            BTIF_TRACE_EVENT(\"%s() - error (%d). Exiting\", __FUNCTION__, ret);\n return;\n }\n\n \n         \/* read sufficiently large buffer to ensure flush empties socket faster than\n            it is getting refilled *\/\n        TEMP_FAILURE_RETRY(read(pfd.fd, &buf, UIPC_FLUSH_BUFFER_SIZE));\n     }\n }\n","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":278715,"func":"void CL_InitDownloads( void ) {\n#ifndef PRE_RELEASE_DEMO\n\tchar missingfiles[1024];\n\tchar *dir = FS_ShiftStr( AUTOUPDATE_DIR, AUTOUPDATE_DIR_SHIFT );\n\n\tif ( autoupdateStarted && NET_CompareAdr( cls.autoupdateServer, clc.serverAddress ) ) {\n\t\tif ( strlen( cl_updatefiles->string ) > 4 ) {\n\t\t\tQ_strncpyz( autoupdateFilename, cl_updatefiles->string, sizeof( autoupdateFilename ) );\n\t\t\tQ_strncpyz( clc.downloadList, va( \"@%s\/%s@%s\/%s\", dir, cl_updatefiles->string, dir, cl_updatefiles->string ), MAX_INFO_STRING );\n\t\t\tclc.state = CA_CONNECTED;\n\t\t\tCL_NextDownload();\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tif ( !(cl_allowDownload->integer & DLF_ENABLE) ) {\n\n\t\t\tif ( FS_ComparePaks( missingfiles, sizeof( missingfiles ), qfalse ) ) {\n\t\t\t\tCvar_Set( \"com_missingFiles\", missingfiles );\n\t\t\t} else {\n\t\t\t\tCvar_Set( \"com_missingFiles\", \"\" );\n\t\t\t}\n\t\t\tCom_Printf( \"\\nWARNING: You are missing some files referenced by the server:\\n%s\"\n\t\t\t\t\t\t\"You might not be able to join the game\\n\"\n\t\t\t\t\t\t\"Go to the setting menu to turn on autodownload, or get the file elsewhere\\n\\n\", missingfiles );\n\t\t}\n\t\telse if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ), qtrue ) ) {\n\t\t\tCom_Printf( CL_TranslateStringBuf( \"Need paks: %s\\n\" ), clc.downloadList );\n\n\t\t\tif ( *clc.downloadList ) {\n\t\t\t\tclc.state = CA_CONNECTED;\n\n\t\t\t\t*clc.downloadTempName = *clc.downloadName = 0;\n\t\t\t\tCvar_Set( \"cl_downloadName\", \"\" );\n\n\t\t\t\tCL_NextDownload();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n#endif\n\n\tCL_DownloadsComplete();\n}\n","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":392038,"func":"http_CollectHdr(struct http *hp, const char *hdr)\n{\n\tunsigned u, v, ml, f = 0, x;\n\tchar *b = NULL, *e = NULL;\n\n\tfor (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {\n\t\twhile (u < hp->nhd && http_IsHdr(&hp->hd[u], hdr)) {\n\t\t\tTcheck(hp->hd[u]);\n\t\t\tif (f == 0) {\n\t\t\t\t\/* Found first header, just record the fact *\/\n\t\t\t\tf = u;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (b == NULL) {\n\t\t\t\t\/* Found second header, start our collection *\/\n\t\t\t\tml = WS_Reserve(hp->ws, 0);\n\t\t\t\tb = hp->ws->f;\n\t\t\t\te = b + ml;\n\t\t\t\tx = Tlen(hp->hd[f]);\n\t\t\t\tif (b + x < e) {\n\t\t\t\t\tmemcpy(b, hp->hd[f].b, x);\n\t\t\t\t\tb += x;\n\t\t\t\t} else\n\t\t\t\t\tb = e;\n\t\t\t}\n\n\t\t\tAN(b);\n\t\t\tAN(e);\n\n\t\t\t\/* Append the Nth header we found *\/\n\t\t\tif (b < e)\n\t\t\t\t*b++ = ',';\n\t\t\tx = Tlen(hp->hd[u]) - *hdr;\n\t\t\tif (b + x < e) {\n\t\t\t\tmemcpy(b, hp->hd[u].b + *hdr, x);\n\t\t\t\tb += x;\n\t\t\t} else\n\t\t\t\tb = e;\n\n\t\t\t\/* Shift remaining headers up one slot *\/\n\t\t\tfor (v = u; v < hp->nhd - 1; v++)\n\t\t\t\thp->hd[v] = hp->hd[v + 1];\n\t\t\thp->nhd--;\n\t\t}\n\n\t}\n\tif (b == NULL)\n\t\treturn;\n\tAN(e);\n\tif (b >= e) {\n\t\tWS_Release(hp->ws, 0);\n\t\treturn;\n\t}\n\t*b = '\\0';\n\thp->hd[f].b = hp->ws->f;\n\thp->hd[f].e = b;\n\tWS_ReleaseP(hp->ws, b + 1);\n}","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":455865,"func":"Value ExpressionSubstrBytes::evaluate(const Document& root, Variables* variables) const {\n    Value pString(_children[0]->evaluate(root, variables));\n    Value pLower(_children[1]->evaluate(root, variables));\n    Value pLength(_children[2]->evaluate(root, variables));\n\n    string str = pString.coerceToString();\n    uassert(16034,\n            str::stream() << getOpName()\n                          << \":  starting index must be a numeric type (is BSON type \"\n                          << typeName(pLower.getType()) << \")\",\n            (pLower.getType() == NumberInt || pLower.getType() == NumberLong ||\n             pLower.getType() == NumberDouble));\n    uassert(16035,\n            str::stream() << getOpName() << \":  length must be a numeric type (is BSON type \"\n                          << typeName(pLength.getType()) << \")\",\n            (pLength.getType() == NumberInt || pLength.getType() == NumberLong ||\n             pLength.getType() == NumberDouble));\n\n    const long long signedLower = pLower.coerceToLong();\n\n    uassert(50752,\n            str::stream() << getOpName()\n                          << \":  starting index must be non-negative (got: \" << signedLower << \")\",\n            signedLower >= 0);\n\n    const string::size_type lower = static_cast<string::size_type>(signedLower);\n\n    \/\/ If the passed length is negative, we should return the rest of the string.\n    const long long signedLength = pLength.coerceToLong();\n    const string::size_type length =\n        signedLength < 0 ? str.length() : static_cast<string::size_type>(signedLength);\n\n    uassert(28656,\n            str::stream() << getOpName()\n                          << \":  Invalid range, starting index is a UTF-8 continuation byte.\",\n            (lower >= str.length() || !str::isUTF8ContinuationByte(str[lower])));\n\n    \/\/ Check the byte after the last character we'd return. If it is a continuation byte, that\n    \/\/ means we're in the middle of a UTF-8 character.\n    uassert(\n        28657,\n        str::stream() << getOpName()\n                      << \":  Invalid range, ending index is in the middle of a UTF-8 character.\",\n        (lower + length >= str.length() || !str::isUTF8ContinuationByte(str[lower + length])));\n\n    if (lower >= str.length()) {\n        \/\/ If lower > str.length() then string::substr() will throw out_of_range, so return an\n        \/\/ empty string if lower is not a valid string index.\n        return Value(StringData());\n    }\n    return Value(str.substr(lower, length));\n}","target":0,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":351882,"func":"__read_extent_tree_block(const char *function, unsigned int line,\n\t\t\t struct inode *inode, ext4_fsblk_t pblk, int depth,\n\t\t\t int flags)\n{\n\tstruct buffer_head\t\t*bh;\n\tint\t\t\t\terr;\n\tgfp_t\t\t\t\tgfp_flags = __GFP_MOVABLE | GFP_NOFS;\n\n\tif (flags & EXT4_EX_NOFAIL)\n\t\tgfp_flags |= __GFP_NOFAIL;\n\n\tbh = sb_getblk_gfp(inode->i_sb, pblk, gfp_flags);\n\tif (unlikely(!bh))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tif (!bh_uptodate_or_lock(bh)) {\n\t\ttrace_ext4_ext_load_extent(inode, pblk, _RET_IP_);\n\t\terr = bh_submit_read(bh);\n\t\tif (err < 0)\n\t\t\tgoto errout;\n\t}\n\tif (buffer_verified(bh) && !(flags & EXT4_EX_FORCE_CACHE))\n\t\treturn bh;\n\tif (!ext4_has_feature_journal(inode->i_sb) ||\n\t    (inode->i_ino !=\n\t     le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum))) {\n\t\terr = __ext4_ext_check(function, line, inode,\n\t\t\t\t       ext_block_hdr(bh), depth, pblk);\n\t\tif (err)\n\t\t\tgoto errout;\n\t}\n\tset_buffer_verified(bh);\n\t\/*\n\t * If this is a leaf block, cache all of its entries\n\t *\/\n\tif (!(flags & EXT4_EX_NOCACHE) && depth == 0) {\n\t\tstruct ext4_extent_header *eh = ext_block_hdr(bh);\n\t\text4_cache_extents(inode, eh);\n\t}\n\treturn bh;\nerrout:\n\tput_bh(bh);\n\treturn ERR_PTR(err);\n\n}","target":1,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":430930,"func":"int cpia2_usb_stream_start(struct camera_data *cam, unsigned int alternate)\n{\n\tint ret;\n\tint old_alt;\n\n\tif(cam->streaming)\n\t\treturn 0;\n\n\tif (cam->flush) {\n\t\tint i;\n\t\tDBG(\"Flushing buffers\\n\");\n\t\tfor(i=0; i<cam->num_frames; ++i) {\n\t\t\tcam->buffers[i].status = FRAME_EMPTY;\n\t\t\tcam->buffers[i].length = 0;\n\t\t}\n\t\tcam->curbuff = &cam->buffers[0];\n\t\tcam->workbuff = cam->curbuff->next;\n\t\tcam->flush = false;\n\t}\n\n\told_alt = cam->params.camera_state.stream_mode;\n\tcam->params.camera_state.stream_mode = 0;\n\tret = cpia2_usb_change_streaming_alternate(cam, alternate);\n\tif (ret < 0) {\n\t\tint ret2;\n\t\tERR(\"cpia2_usb_change_streaming_alternate() = %d!\\n\", ret);\n\t\tcam->params.camera_state.stream_mode = old_alt;\n\t\tret2 = set_alternate(cam, USBIF_CMDONLY);\n\t\tif (ret2 < 0) {\n\t\t\tERR(\"cpia2_usb_change_streaming_alternate(%d) =%d has already failed. Then tried to call set_alternate(USBIF_CMDONLY) = %d.\\n\",\n\t\t\t    alternate, ret, ret2);\n\t\t}\n\t} else {\n\t\tcam->frame_count = 0;\n\t\tcam->streaming = 1;\n\t\tret = cpia2_usb_stream_resume(cam);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":523480,"func":"bool parse_sql(THD *thd, Parser_state *parser_state,\n               Object_creation_ctx *creation_ctx, bool do_pfs_digest)\n{\n  bool ret_value;\n  DBUG_ENTER(\"parse_sql\");\n  DBUG_ASSERT(thd->m_parser_state == NULL);\n  DBUG_ASSERT(thd->lex->m_sql_cmd == NULL);\n\n  MYSQL_QUERY_PARSE_START(thd->query());\n  \/* Backup creation context. *\/\n\n  Object_creation_ctx *backup_ctx= NULL;\n\n  if (creation_ctx)\n    backup_ctx= creation_ctx->set_n_backup(thd);\n\n  \/* Set parser state. *\/\n\n  thd->m_parser_state= parser_state;\n\n  parser_state->m_digest_psi= NULL;\n  parser_state->m_lip.m_digest= NULL;\n\n  if (do_pfs_digest)\n  {\n    \/* Start Digest *\/\n    parser_state->m_digest_psi= MYSQL_DIGEST_START(thd->m_statement_psi);\n\n    if (parser_state->m_digest_psi != NULL)\n    {\n      \/*\n        If either:\n        - the caller wants to compute a digest\n        - the performance schema wants to compute a digest\n        set the digest listener in the lexer.\n      *\/\n      parser_state->m_lip.m_digest= thd->m_digest;\n      parser_state->m_lip.m_digest->m_digest_storage.m_charset_number= thd->charset()->number;\n    }\n  }\n\n  \/* Parse the query. *\/\n\n  bool mysql_parse_status=\n         ((thd->variables.sql_mode & MODE_ORACLE) ?\n          ORAparse(thd) :\n          MYSQLparse(thd)) != 0;\n  DBUG_ASSERT(opt_bootstrap || mysql_parse_status ||\n              thd->lex->select_stack_top == 0);\n  thd->lex->current_select= thd->lex->first_select_lex();\n\n  \/*\n    Check that if MYSQLparse() failed either thd->is_error() is set, or an\n    internal error handler is set.\n\n    The assert will not catch a situation where parsing fails without an\n    error reported if an error handler exists. The problem is that the\n    error handler might have intercepted the error, so thd->is_error() is\n    not set. However, there is no way to be 100% sure here (the error\n    handler might be for other errors than parsing one).\n  *\/\n\n  DBUG_ASSERT(!mysql_parse_status ||\n              thd->is_error() ||\n              thd->get_internal_handler());\n\n  \/* Reset parser state. *\/\n\n  thd->m_parser_state= NULL;\n\n  \/* Restore creation context. *\/\n\n  if (creation_ctx)\n    creation_ctx->restore_env(thd, backup_ctx);\n\n  \/* That's it. *\/\n\n  ret_value= mysql_parse_status || thd->is_fatal_error;\n\n  if ((ret_value == 0) && (parser_state->m_digest_psi != NULL))\n  {\n    \/*\n      On parsing success, record the digest in the performance schema.\n    *\/\n    DBUG_ASSERT(do_pfs_digest);\n    DBUG_ASSERT(thd->m_digest != NULL);\n    MYSQL_DIGEST_END(parser_state->m_digest_psi,\n                     & thd->m_digest->m_digest_storage);\n  }\n\n  MYSQL_QUERY_PARSE_DONE(ret_value);\n  DBUG_RETURN(ret_value);\n}","target":0,"code_token_length":683,"total_token_length":919,"max_tokens_setting":1024}
+{"idx":407492,"func":"static int dcc_send_one_file(int queue, const char *target, const char *fname,\n\t\t\t     IRC_SERVER_REC *server, CHAT_DCC_REC *chat,\n\t\t\t     int passive)\n{\n\tstruct stat st;\n\tchar *str;\n\tchar host[MAX_IP_LEN];\n\tint hfile, port = 0;\n        SEND_DCC_REC *dcc;\n\tIPADDR own_ip;\n\tGIOChannel *handle;\n\n\tif (dcc_find_request(DCC_SEND_TYPE, target, fname)) {\n\t\tsignal_emit(\"dcc error send exists\", 2, target, fname);\n\t\treturn FALSE;\n\t}\n\n\tstr = dcc_send_get_file(fname);\n\thfile = open(str, O_RDONLY);\n\tg_free(str);\n\n\tif (hfile == -1) {\n\t\tsignal_emit(\"dcc error file open\", 3, target, fname,\n\t\t\t    GINT_TO_POINTER(errno));\n\t\treturn FALSE;\n\t}\n\n\tif (fstat(hfile, &st) < 0) {\n\t\tg_warning(\"fstat() failed: %s\", strerror(errno));\n\t\tclose(hfile);\n\t\treturn FALSE;\n\t}\n\n\t\/* start listening (only if passive == FALSE )*\/\n\n\tif (passive == FALSE) {\n\t\thandle = dcc_listen(chat != NULL ? chat->handle :\n\t\t\t\t    net_sendbuffer_handle(server->handle),\n\t\t\t\t    &own_ip, &port);\n\t\tif (handle == NULL) {\n\t\t\tclose(hfile);\n\t\t\tg_warning(\"dcc_listen() failed: %s\", strerror(errno));\n\t\t\treturn FALSE;\n\t\t}\n\t} else {\n\t\thandle = NULL;\n\t}\n\n\tstr = g_path_get_basename(fname);\n\n\t\/* Replace all the spaces with underscore so that lesser\n\t   intelligent clients can communicate.. *\/\n\tif (settings_get_bool(\"dcc_send_replace_space_with_underscore\"))\n\t\tg_strdelimit(str, \" \", '_');\n\n\tdcc = dcc_send_create(server, chat, target, str);\n\tg_free(str);\n\tif (dcc == NULL) {\n\t\tg_warn_if_reached();\n\t\treturn FALSE;\n\t}\n\n\tdcc->handle = handle;\n\tdcc->port = port;\n\tdcc->size = st.st_size;\n\tdcc->fhandle = hfile;\n\tdcc->queue = queue;\n        dcc->file_quoted = strchr(fname, ' ') != NULL;\n\tif (!passive) {\n\t\tdcc->tagconn = g_input_add(handle, G_INPUT_READ,\n\t\t\t\t\t   (GInputFunction) dcc_send_connected,\n\t\t\t\t\t   dcc);\n\t}\n\n\t\/* Generate an ID for this send if using passive protocol *\/\n\tif (passive) {\n\t\tdcc->pasv_id = rand() % 64;\n\t}\n\n\t\/* send DCC request *\/\n\tsignal_emit(\"dcc request send\", 1, dcc);\n\n\n\tdcc_ip2str(&own_ip, host);\n\tif (passive == FALSE) {\n\t\tstr = g_strdup_printf(dcc->file_quoted ?\n\t\t\t\t      \"DCC SEND \\\"%s\\\" %s %d %\"PRIuUOFF_T :\n\t\t\t\t      \"DCC SEND %s %s %d %\"PRIuUOFF_T,\n\t\t\t\t      dcc->arg, host, port, dcc->size);\n\t} else {\n\t\tstr = g_strdup_printf(dcc->file_quoted ?\n\t\t\t\t      \"DCC SEND \\\"%s\\\" 16843009 0 %\"PRIuUOFF_T\" %d\" :\n\t\t\t\t      \"DCC SEND %s 16843009 0 %\"PRIuUOFF_T\" %d\",\n\t\t\t\t      dcc->arg, dcc->size, dcc->pasv_id);\n\t}\n\tdcc_ctcp_message(server, target, chat, FALSE, str);\n\n\tg_free(str);\n\treturn TRUE;\n}","target":0,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":176320,"func":"_eXosip_is_public_address (const char *c_address)\n{\n  return (0 != strncmp (c_address, \"192.168\", 7)\n          && 0 != strncmp (c_address, \"10.\", 3)\n          && 0 != strncmp (c_address, \"172.16.\", 7)\n          && 0 != strncmp (c_address, \"172.17.\", 7)\n          && 0 != strncmp (c_address, \"172.18.\", 7)\n          && 0 != strncmp (c_address, \"172.19.\", 7)\n          && 0 != strncmp (c_address, \"172.20.\", 7)\n          && 0 != strncmp (c_address, \"172.21.\", 7)\n          && 0 != strncmp (c_address, \"172.22.\", 7)\n          && 0 != strncmp (c_address, \"172.23.\", 7)\n          && 0 != strncmp (c_address, \"172.24.\", 7)\n          && 0 != strncmp (c_address, \"172.25.\", 7)\n          && 0 != strncmp (c_address, \"172.26.\", 7)\n          && 0 != strncmp (c_address, \"172.27.\", 7)\n          && 0 != strncmp (c_address, \"172.28.\", 7)\n          && 0 != strncmp (c_address, \"172.29.\", 7)\n          && 0 != strncmp (c_address, \"172.30.\", 7)\n          && 0 != strncmp (c_address, \"172.31.\", 7)\n          && 0 != strncmp (c_address, \"169.254\", 7));\n}\n","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":86018,"func":"do_exmode(\n    int\t\timproved)\t    \/\/ TRUE for \"improved Ex\" mode\n{\n    int\t\tsave_msg_scroll;\n    int\t\tprev_msg_row;\n    linenr_T\tprev_line;\n    varnumber_T\tchangedtick;\n\n    if (improved)\n\texmode_active = EXMODE_VIM;\n    else\n\texmode_active = EXMODE_NORMAL;\n    State = MODE_NORMAL;\n    may_trigger_modechanged();\n\n    \/\/ When using \":global \/pat\/ visual\" and then \"Q\" we return to continue\n    \/\/ the :global command.\n    if (global_busy)\n\treturn;\n\n    save_msg_scroll = msg_scroll;\n    ++RedrawingDisabled;\t    \/\/ don't redisplay the window\n    ++no_wait_return;\t\t    \/\/ don't wait for return\n#ifdef FEAT_GUI\n    \/\/ Ignore scrollbar and mouse events in Ex mode\n    ++hold_gui_events;\n#endif\n\n    msg(_(\"Entering Ex mode.  Type \\\"visual\\\" to go to Normal mode.\"));\n    while (exmode_active)\n    {\n\t\/\/ Check for a \":normal\" command and no more characters left.\n\tif (ex_normal_busy > 0 && typebuf.tb_len == 0)\n\t{\n\t    exmode_active = FALSE;\n\t    break;\n\t}\n\tmsg_scroll = TRUE;\n\tneed_wait_return = FALSE;\n\tex_pressedreturn = FALSE;\n\tex_no_reprint = FALSE;\n\tchangedtick = CHANGEDTICK(curbuf);\n\tprev_msg_row = msg_row;\n\tprev_line = curwin->w_cursor.lnum;\n\tif (improved)\n\t{\n\t    cmdline_row = msg_row;\n\t    do_cmdline(NULL, getexline, NULL, 0);\n\t}\n\telse\n\t    do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT);\n\tlines_left = Rows - 1;\n\n\tif ((prev_line != curwin->w_cursor.lnum\n\t\t   || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint)\n\t{\n\t    if (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t\temsg(_(e_empty_buffer));\n\t    else\n\t    {\n\t\tif (ex_pressedreturn)\n\t\t{\n\t\t    \/\/ go up one line, to overwrite the \":<CR>\" line, so the\n\t\t    \/\/ output doesn't contain empty lines.\n\t\t    msg_row = prev_msg_row;\n\t\t    if (prev_msg_row == Rows - 1)\n\t\t\tmsg_row--;\n\t\t}\n\t\tmsg_col = 0;\n\t\tprint_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE);\n\t\tmsg_clr_eos();\n\t    }\n\t}\n\telse if (ex_pressedreturn && !ex_no_reprint)\t\/\/ must be at EOF\n\t{\n\t    if (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t\temsg(_(e_empty_buffer));\n\t    else\n\t\temsg(_(e_at_end_of_file));\n\t}\n    }\n\n#ifdef FEAT_GUI\n    --hold_gui_events;\n#endif\n    --RedrawingDisabled;\n    --no_wait_return;\n    update_screen(CLEAR);\n    need_wait_return = FALSE;\n    msg_scroll = save_msg_scroll;\n}","target":0,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":160068,"func":"static int StreamTcpTest22 (void)\n{\n    StreamTcpThread stt;\n    struct in_addr addr;\n    char os_policy_name[10] = \"windows\";\n    const char *ip_addr;\n    TcpStream stream;\n    Packet *p = SCMalloc(SIZE_OF_PACKET);\n    if (unlikely(p == NULL))\n    return 0;\n    IPV4Hdr ipv4h;\n    int ret = 0;\n\n    memset(&addr, 0, sizeof(addr));\n    memset(&stream, 0, sizeof(stream));\n    memset(p, 0, SIZE_OF_PACKET);\n    memset(&ipv4h, 0, sizeof(ipv4h));\n\n    StreamTcpUTInit(&stt.ra_ctx);\n    SCHInfoCleanResources();\n\n    \/* Load the config string in to parser *\/\n    ConfCreateContextBackup();\n    ConfInit();\n    ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));\n\n    \/* Get the IP address as string and add it to Host info tree for lookups *\/\n    ip_addr = StreamTcpParseOSPolicy(os_policy_name);\n    SCHInfoAddHostOSInfo(os_policy_name, ip_addr, -1);\n\n    p->dst.family = AF_INET;\n    p->ip4h = &ipv4h;\n    addr.s_addr = inet_addr(\"123.231.2.1\");\n    p->dst.address.address_un_data32[0] = addr.s_addr;\n    StreamTcpSetOSPolicy(&stream, p);\n\n    if (stream.os_policy != OS_POLICY_DEFAULT) {\n        printf(\"expected os_policy: %\"PRIu8\" but received %\"PRIu8\"\\n\",\n                (uint8_t)OS_POLICY_DEFAULT, stream.os_policy);\n        goto end;\n    }\n\n    ret = 1;\nend:\n    ConfDeInit();\n    ConfRestoreContextBackup();\n    SCFree(p);\n    StreamTcpUTDeinit(stt.ra_ctx);\n    return ret;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":50229,"func":"fptr_finalize(mrb_state *mrb, struct mrb_io *fptr, int quiet)\n{\n  int saved_errno = 0;\n\n  if (fptr == NULL) {\n    return;\n  }\n\n  if (fptr->fd > 2) {\n#ifdef _WIN32\n    if (fptr->is_socket) {\n      if (closesocket(fptr->fd) != 0) {\n        saved_errno = WSAGetLastError();\n      }\n      fptr->fd = -1;\n    }\n#endif\n    if (fptr->fd != -1) {\n      if (close(fptr->fd) == -1) {\n        saved_errno = errno;\n      }\n    }\n    fptr->fd = -1;\n  }\n\n  if (fptr->fd2 > 2) {\n    if (close(fptr->fd2) == -1) {\n      if (saved_errno == 0) {\n        saved_errno = errno;\n      }\n    }\n    fptr->fd2 = -1;\n  }\n\n  if (fptr->pid != 0) {\n#if !defined(_WIN32) && !defined(_WIN64)\n    pid_t pid;\n    int status;\n    do {\n      pid = waitpid(fptr->pid, &status, 0);\n    } while (pid == -1 && errno == EINTR);\n    if (!quiet && pid == fptr->pid) {\n      io_set_process_status(mrb, pid, status);\n    }\n#else\n    HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, fptr->pid);\n    DWORD status;\n    if (WaitForSingleObject(h, INFINITE) && GetExitCodeProcess(h, &status))\n      if (!quiet)\n        io_set_process_status(mrb, fptr->pid, (int)status);\n    CloseHandle(h);\n#endif\n    fptr->pid = 0;\n    \/* Note: we don't raise an exception when waitpid(3) fails *\/\n  }\n\n  if (!quiet && saved_errno != 0) {\n    errno = saved_errno;\n    mrb_sys_fail(mrb, \"fptr_finalize failed.\");\n  }\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":477435,"func":"FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,\n\t\t     u64 *spte, pt_element_t gpte, bool no_dirty_log)\n{\n\tstruct kvm_memory_slot *slot;\n\tunsigned pte_access;\n\tgfn_t gfn;\n\tkvm_pfn_t pfn;\n\n\tif (FNAME(prefetch_invalid_gpte)(vcpu, sp, spte, gpte))\n\t\treturn false;\n\n\tpgprintk(\"%s: gpte %llx spte %p\\n\", __func__, (u64)gpte, spte);\n\n\tgfn = gpte_to_gfn(gpte);\n\tpte_access = sp->role.access & FNAME(gpte_access)(gpte);\n\tFNAME(protect_clean_gpte)(vcpu->arch.mmu, &pte_access, gpte);\n\n\tslot = gfn_to_memslot_dirty_bitmap(vcpu, gfn,\n\t\t\tno_dirty_log && (pte_access & ACC_WRITE_MASK));\n\tif (!slot)\n\t\treturn false;\n\n\tpfn = gfn_to_pfn_memslot_atomic(slot, gfn);\n\tif (is_error_pfn(pfn))\n\t\treturn false;\n\n\tmmu_set_spte(vcpu, slot, spte, pte_access, gfn, pfn, NULL);\n\tkvm_release_pfn_clean(pfn);\n\treturn true;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":507664,"func":"static int rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)\n{\n    X509_ALGOR *alg = NULL;\n    switch (op) {\n\n    case ASN1_PKEY_CTRL_PKCS7_SIGN:\n        if (arg1 == 0)\n            PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, NULL, &alg);\n        break;\n\n    case ASN1_PKEY_CTRL_PKCS7_ENCRYPT:\n        if (arg1 == 0)\n            PKCS7_RECIP_INFO_get0_alg(arg2, &alg);\n        break;\n#ifndef OPENSSL_NO_CMS\n    case ASN1_PKEY_CTRL_CMS_SIGN:\n        if (arg1 == 0)\n            return rsa_cms_sign(arg2);\n        else if (arg1 == 1)\n            return rsa_cms_verify(arg2);\n        break;\n\n    case ASN1_PKEY_CTRL_CMS_ENVELOPE:\n        if (arg1 == 0)\n            return rsa_cms_encrypt(arg2);\n        else if (arg1 == 1)\n            return rsa_cms_decrypt(arg2);\n        break;\n\n    case ASN1_PKEY_CTRL_CMS_RI_TYPE:\n        *(int *)arg2 = CMS_RECIPINFO_TRANS;\n        return 1;\n#endif\n\n    case ASN1_PKEY_CTRL_DEFAULT_MD_NID:\n        *(int *)arg2 = NID_sha256;\n        return 1;\n\n    default:\n        return -2;\n\n    }\n\n    if (alg)\n        X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0);\n\n    return 1;\n\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":296293,"func":"nv_down(cmdarg_T *cap)\n{\n    if (mod_mask & MOD_MASK_SHIFT)\n    {\n\t\/\/ <S-Down> is page down\n\tcap->arg = FORWARD;\n\tnv_page(cap);\n    }\n#if defined(FEAT_QUICKFIX)\n    \/\/ Quickfix window only: view the result under the cursor.\n    else if (bt_quickfix(curbuf) && cap->cmdchar == CAR)\n\tqf_view_result(FALSE);\n#endif\n    else\n    {\n#ifdef FEAT_CMDWIN\n\t\/\/ In the cmdline window a <CR> executes the command.\n\tif (cmdwin_type != 0 && cap->cmdchar == CAR)\n\t    cmdwin_result = CAR;\n\telse\n#endif\n#ifdef FEAT_JOB_CHANNEL\n\t\/\/ In a prompt buffer a <CR> in the last line invokes the callback.\n\tif (bt_prompt(curbuf) && cap->cmdchar == CAR\n\t\t       && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)\n\t{\n\t    invoke_prompt_callback();\n\t    if (restart_edit == 0)\n\t\trestart_edit = 'a';\n\t}\n\telse\n#endif\n\t{\n\t    cap->oap->motion_type = MLINE;\n\t    if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)\n\t\tclearopbeep(cap->oap);\n\t    else if (cap->arg)\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t}\n    }\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":114783,"func":"static inline int hpel_motion_lowres(MpegEncContext *s,\n                                     uint8_t *dest, uint8_t *src,\n                                     int field_based, int field_select,\n                                     int src_x, int src_y,\n                                     int width, int height, ptrdiff_t stride,\n                                     int h_edge_pos, int v_edge_pos,\n                                     int w, int h, h264_chroma_mc_func *pix_op,\n                                     int motion_x, int motion_y)\n{\n    const int lowres   = s->avctx->lowres;\n    const int op_index = FFMIN(lowres, 3);\n    const int s_mask   = (2 << lowres) - 1;\n    int emu = 0;\n    int sx, sy;\n\n    if (s->quarter_sample) {\n        motion_x \/= 2;\n        motion_y \/= 2;\n    }\n\n    sx = motion_x & s_mask;\n    sy = motion_y & s_mask;\n    src_x += motion_x >> lowres + 1;\n    src_y += motion_y >> lowres + 1;\n\n    src   += src_y * stride + src_x;\n\n    if ((unsigned)src_x > FFMAX( h_edge_pos - (!!sx) - w,                 0) ||\n        (unsigned)src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {\n        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,\n                                 s->linesize, s->linesize,\n                                 w + 1, (h + 1) << field_based,\n                                 src_x, src_y   << field_based,\n                                 h_edge_pos, v_edge_pos);\n        src = s->sc.edge_emu_buffer;\n        emu = 1;\n    }\n\n    sx = (sx << 2) >> lowres;\n    sy = (sy << 2) >> lowres;\n    if (field_select)\n        src += s->linesize;\n    pix_op[op_index](dest, src, stride, h, sx, sy);\n    return emu;\n}","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":59397,"func":"ngx_http_lua_process_vars_option(ngx_http_request_t *r, lua_State *L,\n    int table, ngx_array_t **varsp)\n{\n    ngx_array_t         *vars;\n    ngx_keyval_t        *var;\n\n    if (table < 0) {\n        table = lua_gettop(L) + table + 1;\n    }\n\n    vars = *varsp;\n\n    if (vars == NULL) {\n\n        vars = ngx_array_create(r->pool, 4, sizeof(ngx_keyval_t));\n        if (vars == NULL) {\n            dd(\"here\");\n            luaL_error(L, \"no memory\");\n            return;\n        }\n\n        *varsp = vars;\n    }\n\n    lua_pushnil(L);\n    while (lua_next(L, table) != 0) {\n\n        if (lua_type(L, -2) != LUA_TSTRING) {\n            luaL_error(L, \"attempt to use a non-string key in the \"\n                       \"\\\"vars\\\" option table\");\n            return;\n        }\n\n        if (!lua_isstring(L, -1)) {\n            luaL_error(L, \"attempt to use bad variable value type %s\",\n                       luaL_typename(L, -1));\n            return;\n        }\n\n        var = ngx_array_push(vars);\n        if (var == NULL) {\n            dd(\"here\");\n            luaL_error(L, \"no memory\");\n            return;\n        }\n\n        var->key.data = (u_char *) lua_tolstring(L, -2, &var->key.len);\n        var->value.data = (u_char *) lua_tolstring(L, -1, &var->value.len);\n\n        lua_pop(L, 1);\n    }\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":294577,"func":"static MagickBooleanType WritePTIFImage(const ImageInfo *image_info,\n  Image *image,ExceptionInfo *exception)\n{\n  Image\n    *images,\n    *next,\n    *pyramid_image;\n\n  ImageInfo\n    *write_info;\n\n  MagickBooleanType\n    status;\n\n  PointInfo\n    resolution;\n\n  size_t\n    columns,\n    rows;\n\n  \/*\n    Create pyramid-encoded TIFF image.\n  *\/\n  images=NewImageList();\n  for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))\n  {\n    Image\n      *clone_image;\n\n    clone_image=CloneImage(next,0,0,MagickFalse,exception);\n    if (clone_image == (Image *) NULL)\n      break;\n    clone_image->previous=NewImageList();\n    clone_image->next=NewImageList();\n    (void) SetImageProperty(clone_image,\"tiff:subfiletype\",\"none\",exception);\n    AppendImageToList(&images,clone_image);\n    columns=next->columns;\n    rows=next->rows;\n    resolution=next->resolution;\n    while ((columns > 64) && (rows > 64))\n    {\n      columns\/=2;\n      rows\/=2;\n      resolution.x\/=2;\n      resolution.y\/=2;\n      pyramid_image=ResizeImage(next,columns,rows,image->filter,exception);\n      if (pyramid_image == (Image *) NULL)\n        break;\n      pyramid_image->resolution=resolution;\n      (void) SetImageProperty(pyramid_image,\"tiff:subfiletype\",\"REDUCEDIMAGE\",\n        exception);\n      AppendImageToList(&images,pyramid_image);\n    }\n  }\n  images=GetFirstImageInList(images);\n  \/*\n    Write pyramid-encoded TIFF image.\n  *\/\n  write_info=CloneImageInfo(image_info);\n  write_info->adjoin=MagickTrue;\n  (void) CopyMagickString(write_info->magick,\"TIFF\",MagickPathExtent);\n  (void) CopyMagickString(images->magick,\"TIFF\",MagickPathExtent);\n  status=WriteTIFFImage(write_info,images,exception);\n  images=DestroyImageList(images);\n  write_info=DestroyImageInfo(write_info);\n  return(status);\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":149347,"func":"static int check_map_prog_compatibility(struct bpf_verifier_env *env,\n\t\t\t\t\tstruct bpf_map *map,\n\t\t\t\t\tstruct bpf_prog *prog)\n\n{\n\t\/*\n\t * Validate that trace type programs use preallocated hash maps.\n\t *\n\t * For programs attached to PERF events this is mandatory as the\n\t * perf NMI can hit any arbitrary code sequence.\n\t *\n\t * All other trace types using preallocated hash maps are unsafe as\n\t * well because tracepoint or kprobes can be inside locked regions\n\t * of the memory allocator or at a place where a recursion into the\n\t * memory allocator would see inconsistent state.\n\t *\n\t * On RT enabled kernels run-time allocation of all trace type\n\t * programs is strictly prohibited due to lock type constraints. On\n\t * !RT kernels it is allowed for backwards compatibility reasons for\n\t * now, but warnings are emitted so developers are made aware of\n\t * the unsafety and can fix their programs before this is enforced.\n\t *\/\n\tif (is_tracing_prog_type(prog->type) && !is_preallocated_map(map)) {\n\t\tif (prog->type == BPF_PROG_TYPE_PERF_EVENT) {\n\t\t\tverbose(env, \"perf_event programs can only use preallocated hash map\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (IS_ENABLED(CONFIG_PREEMPT_RT)) {\n\t\t\tverbose(env, \"trace type programs can only use preallocated hash map\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tWARN_ONCE(1, \"trace type BPF program uses run-time allocation\\n\");\n\t\tverbose(env, \"trace type programs with run-time allocated hash maps are unsafe. Switch to preallocated hash maps.\\n\");\n\t}\n\n\tif ((is_tracing_prog_type(prog->type) ||\n\t     prog->type == BPF_PROG_TYPE_SOCKET_FILTER) &&\n\t    map_value_has_spin_lock(map)) {\n\t\tverbose(env, \"tracing progs cannot use bpf_spin_lock yet\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif ((bpf_prog_is_dev_bound(prog->aux) || bpf_map_is_dev_bound(map)) &&\n\t    !bpf_offload_prog_map_match(prog, map)) {\n\t\tverbose(env, \"offload device mismatch between prog and map\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (map->map_type == BPF_MAP_TYPE_STRUCT_OPS) {\n\t\tverbose(env, \"bpf_struct_ops map cannot be used in prog\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":123015,"func":"static void add_timer_randomness(struct timer_rand_state *state, unsigned num)\n{\n\tstruct entropy_store\t*r;\n\tstruct {\n\t\tlong jiffies;\n\t\tunsigned cycles;\n\t\tunsigned num;\n\t} sample;\n\tlong delta, delta2, delta3;\n\n\tsample.jiffies = jiffies;\n\tsample.cycles = random_get_entropy();\n\tsample.num = num;\n\tr = &input_pool;\n\tmix_pool_bytes(r, &sample, sizeof(sample));\n\n\t\/*\n\t * Calculate number of bits of randomness we probably added.\n\t * We take into account the first, second and third-order deltas\n\t * in order to make our estimate.\n\t *\/\n\tdelta = sample.jiffies - READ_ONCE(state->last_time);\n\tWRITE_ONCE(state->last_time, sample.jiffies);\n\n\tdelta2 = delta - READ_ONCE(state->last_delta);\n\tWRITE_ONCE(state->last_delta, delta);\n\n\tdelta3 = delta2 - READ_ONCE(state->last_delta2);\n\tWRITE_ONCE(state->last_delta2, delta2);\n\n\tif (delta < 0)\n\t\tdelta = -delta;\n\tif (delta2 < 0)\n\t\tdelta2 = -delta2;\n\tif (delta3 < 0)\n\t\tdelta3 = -delta3;\n\tif (delta > delta2)\n\t\tdelta = delta2;\n\tif (delta > delta3)\n\t\tdelta = delta3;\n\n\t\/*\n\t * delta is now minimum absolute delta.\n\t * Round down by 1 bit on general principles,\n\t * and limit entropy estimate to 12 bits.\n\t *\/\n\tcredit_entropy_bits(r, min_t(int, fls(delta>>1), 11));\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":267557,"func":"static int follow_automount(struct path *path, struct nameidata *nd,\n\t\t\t    bool *need_mntput)\n{\n\tstruct vfsmount *mnt;\n\tint err;\n\n\tif (!path->dentry->d_op || !path->dentry->d_op->d_automount)\n\t\treturn -EREMOTE;\n\n\t\/* We don't want to mount if someone's just doing a stat -\n\t * unless they're stat'ing a directory and appended a '\/' to\n\t * the name.\n\t *\n\t * We do, however, want to mount if someone wants to open or\n\t * create a file of any type under the mountpoint, wants to\n\t * traverse through the mountpoint or wants to open the\n\t * mounted directory.  Also, autofs may mark negative dentries\n\t * as being automount points.  These will need the attentions\n\t * of the daemon to instantiate them before they can be used.\n\t *\/\n\tif (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |\n\t\t\t   LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) &&\n\t    path->dentry->d_inode)\n\t\treturn -EISDIR;\n\n\tnd->total_link_count++;\n\tif (nd->total_link_count >= 40)\n\t\treturn -ELOOP;\n\n\tmnt = path->dentry->d_op->d_automount(path);\n\tif (IS_ERR(mnt)) {\n\t\t\/*\n\t\t * The filesystem is allowed to return -EISDIR here to indicate\n\t\t * it doesn't want to automount.  For instance, autofs would do\n\t\t * this so that its userspace daemon can mount on this dentry.\n\t\t *\n\t\t * However, we can only permit this if it's a terminal point in\n\t\t * the path being looked up; if it wasn't then the remainder of\n\t\t * the path is inaccessible and we should say so.\n\t\t *\/\n\t\tif (PTR_ERR(mnt) == -EISDIR && (nd->flags & LOOKUP_PARENT))\n\t\t\treturn -EREMOTE;\n\t\treturn PTR_ERR(mnt);\n\t}\n\n\tif (!mnt) \/* mount collision *\/\n\t\treturn 0;\n\n\tif (!*need_mntput) {\n\t\t\/* lock_mount() may release path->mnt on error *\/\n\t\tmntget(path->mnt);\n\t\t*need_mntput = true;\n\t}\n\terr = finish_automount(mnt, path);\n\n\tswitch (err) {\n\tcase -EBUSY:\n\t\t\/* Someone else made a mount here whilst we were busy *\/\n\t\treturn 0;\n\tcase 0:\n\t\tpath_put(path);\n\t\tpath->mnt = mnt;\n\t\tpath->dentry = dget(mnt->mnt_root);\n\t\treturn 0;\n\tdefault:\n\t\treturn err;\n\t}\n\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":285214,"func":"void FFmpegVideoDecodeEngine::DecodeFrame(scoped_refptr<Buffer> buffer) {\n  scoped_refptr<VideoFrame> video_frame;\n\n  AVPacket packet;\n  av_init_packet(&packet);\n  packet.data = const_cast<uint8*>(buffer->GetData());\n  packet.size = buffer->GetDataSize();\n\n  PipelineStatistics statistics;\n  statistics.video_bytes_decoded = buffer->GetDataSize();\n\n  codec_context_->reordered_opaque = buffer->GetTimestamp().InMicroseconds();\n\n  av_frame_->reordered_opaque = codec_context_->reordered_opaque;\n\n  int frame_decoded = 0;\n  int result = avcodec_decode_video2(codec_context_,\n                                     av_frame_.get(),\n                                     &frame_decoded,\n                                     &packet);\n\n  if (result < 0) {\n    LOG(ERROR) << \"Error decoding a video frame with timestamp: \"\n               << buffer->GetTimestamp().InMicroseconds() << \" us, duration: \"\n               << buffer->GetDuration().InMicroseconds() << \" us, packet size: \"\n               << buffer->GetDataSize() << \" bytes\";\n    event_handler_->OnError();\n    return;\n  }\n\n  if (frame_decoded == 0) {\n    if (buffer->IsEndOfStream()) {  \/\/ We had started flushing.\n      event_handler_->ConsumeVideoFrame(video_frame, statistics);\n      output_eos_reached_ = true;\n    } else {\n      ReadInput();\n    }\n    return;\n  }\n\n  if (!av_frame_->data[VideoFrame::kYPlane] ||\n      !av_frame_->data[VideoFrame::kUPlane] ||\n      !av_frame_->data[VideoFrame::kVPlane]) {\n    event_handler_->OnError();\n    return;\n  }\n\n  DCHECK_LE(av_frame_->repeat_pict, 2);  \/\/ Sanity check.\n  AVRational doubled_time_base;\n  doubled_time_base.num = frame_rate_denominator_;\n  doubled_time_base.den = frame_rate_numerator_ * 2;\n\n  base::TimeDelta timestamp =\n      base::TimeDelta::FromMicroseconds(av_frame_->reordered_opaque);\n  base::TimeDelta duration =\n      ConvertFromTimeBase(doubled_time_base, 2 + av_frame_->repeat_pict);\n\n  DCHECK(frame_queue_available_.size());\n  video_frame = frame_queue_available_.front();\n  frame_queue_available_.pop_front();\n\n  size_t height = codec_context_->height;\n  CopyPlane(VideoFrame::kYPlane, video_frame.get(), av_frame_.get(), height);\n  CopyPlane(VideoFrame::kUPlane, video_frame.get(), av_frame_.get(), height);\n  CopyPlane(VideoFrame::kVPlane, video_frame.get(), av_frame_.get(), height);\n\n  video_frame->SetTimestamp(timestamp);\n  video_frame->SetDuration(duration);\n\n  pending_output_buffers_--;\n  event_handler_->ConsumeVideoFrame(video_frame, statistics);\n}\n","target":0,"code_token_length":599,"total_token_length":835,"max_tokens_setting":1024}
+{"idx":337931,"func":"static int svq1_decode_frame_header(GetBitContext *bitbuf, MpegEncContext *s)\n\n{\n\n    int frame_size_code;\n\n\n\n    skip_bits(bitbuf, 8); \/* temporal_reference *\/\n\n\n\n    \/* frame type *\/\n\n    s->pict_type = get_bits(bitbuf, 2) + 1;\n\n    if (s->pict_type == 4)\n\n        return AVERROR_INVALIDDATA;\n\n\n\n    if (s->pict_type == AV_PICTURE_TYPE_I) {\n\n        \/* unknown fields *\/\n\n        if (s->f_code == 0x50 || s->f_code == 0x60) {\n\n            int csum = get_bits(bitbuf, 16);\n\n\n\n            csum = ff_svq1_packet_checksum(bitbuf->buffer,\n\n                                           bitbuf->size_in_bits >> 3,\n\n                                           csum);\n\n\n\n            av_dlog(s->avctx, \"%s checksum (%02x) for packet data\\n\",\n\n                    (csum == 0) ? \"correct\" : \"incorrect\", csum);\n\n        }\n\n\n\n        if ((s->f_code ^ 0x10) >= 0x50) {\n\n            uint8_t msg[256];\n\n\n\n            svq1_parse_string(bitbuf, msg);\n\n\n\n            av_log(s->avctx, AV_LOG_ERROR,\n\n                   \"embedded message: \\\"%s\\\"\\n\", (char *)msg);\n\n        }\n\n\n\n        skip_bits(bitbuf, 2);\n\n        skip_bits(bitbuf, 2);\n\n        skip_bits1(bitbuf);\n\n\n\n        \/* load frame size *\/\n\n        frame_size_code = get_bits(bitbuf, 3);\n\n\n\n        if (frame_size_code == 7) {\n\n            \/* load width, height (12 bits each) *\/\n\n            s->width  = get_bits(bitbuf, 12);\n\n            s->height = get_bits(bitbuf, 12);\n\n\n\n            if (!s->width || !s->height)\n\n                return AVERROR_INVALIDDATA;\n\n        } else {\n\n            \/* get width, height from table *\/\n\n            s->width  = ff_svq1_frame_size_table[frame_size_code].width;\n\n            s->height = ff_svq1_frame_size_table[frame_size_code].height;\n\n        }\n\n    }\n\n\n\n    \/* unknown fields *\/\n\n    if (get_bits1(bitbuf) == 1) {\n\n        skip_bits1(bitbuf);    \/* use packet checksum if (1) *\/\n\n        skip_bits1(bitbuf);    \/* component checksums after image data if (1) *\/\n\n\n\n        if (get_bits(bitbuf, 2) != 0)\n\n            return AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    if (get_bits1(bitbuf) == 1) {\n\n        skip_bits1(bitbuf);\n\n        skip_bits(bitbuf, 4);\n\n        skip_bits1(bitbuf);\n\n        skip_bits(bitbuf, 2);\n\n\n\n        while (get_bits1(bitbuf) == 1)\n\n            skip_bits(bitbuf, 8);\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":394537,"func":"static int mb86a20s_reset_counters(struct dvb_frontend *fe)\n{\n\tstruct mb86a20s_state *state = fe->demodulator_priv;\n\tstruct dtv_frontend_properties *c = &fe->dtv_property_cache;\n\tint rc, val;\n\n\tdev_dbg(&state->i2c->dev, \"%s called.\\n\", __func__);\n\n\t\/* Reset the counters, if the channel changed *\/\n\tif (state->last_frequency != c->frequency) {\n\t\tmemset(&c->cnr, 0, sizeof(c->cnr));\n\t\tmemset(&c->pre_bit_error, 0, sizeof(c->pre_bit_error));\n\t\tmemset(&c->pre_bit_count, 0, sizeof(c->pre_bit_count));\n\t\tmemset(&c->post_bit_error, 0, sizeof(c->post_bit_error));\n\t\tmemset(&c->post_bit_count, 0, sizeof(c->post_bit_count));\n\t\tmemset(&c->block_error, 0, sizeof(c->block_error));\n\t\tmemset(&c->block_count, 0, sizeof(c->block_count));\n\n\t\tstate->last_frequency = c->frequency;\n\t}\n\n\t\/* Clear status for most stats *\/\n\n\t\/* BER\/PER counter reset *\/\n\trc = mb86a20s_writeregdata(state, mb86a20s_per_ber_reset);\n\tif (rc < 0)\n\t\tgoto err;\n\n\t\/* CNR counter reset *\/\n\trc = mb86a20s_readreg(state, 0x45);\n\tif (rc < 0)\n\t\tgoto err;\n\tval = rc;\n\trc = mb86a20s_writereg(state, 0x45, val | 0x10);\n\tif (rc < 0)\n\t\tgoto err;\n\trc = mb86a20s_writereg(state, 0x45, val & 0x6f);\n\tif (rc < 0)\n\t\tgoto err;\n\n\t\/* MER counter reset *\/\n\trc = mb86a20s_writereg(state, 0x50, 0x50);\n\tif (rc < 0)\n\t\tgoto err;\n\trc = mb86a20s_readreg(state, 0x51);\n\tif (rc < 0)\n\t\tgoto err;\n\tval = rc;\n\trc = mb86a20s_writereg(state, 0x51, val | 0x01);\n\tif (rc < 0)\n\t\tgoto err;\n\trc = mb86a20s_writereg(state, 0x51, val & 0x06);\n\tif (rc < 0)\n\t\tgoto err;\n\n\tgoto ok;\nerr:\n\tdev_err(&state->i2c->dev,\n\t\t\"%s: Can't reset FE statistics (error %d).\\n\",\n\t\t__func__, rc);\nok:\n\treturn rc;\n}","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":51872,"func":"static int MP4_ReadBox_dac3( stream_t *p_stream, MP4_Box_t *p_box )\n{\n    MP4_Box_data_dac3_t *p_dac3;\n    MP4_READBOX_ENTER( MP4_Box_data_dac3_t );\n\n    p_dac3 = p_box->data.p_dac3;\n\n    unsigned i_header;\n    MP4_GET3BYTES( i_header );\n\n    p_dac3->i_fscod = ( i_header >> 22 ) & 0x03;\n    p_dac3->i_bsid  = ( i_header >> 17 ) & 0x01f;\n    p_dac3->i_bsmod = ( i_header >> 14 ) & 0x07;\n    p_dac3->i_acmod = ( i_header >> 11 ) & 0x07;\n    p_dac3->i_lfeon = ( i_header >> 10 ) & 0x01;\n    p_dac3->i_bitrate_code = ( i_header >> 5) & 0x1f;\n\n#ifdef MP4_VERBOSE\n    msg_Dbg( p_stream,\n             \"read box: \\\"dac3\\\" fscod=0x%x bsid=0x%x bsmod=0x%x acmod=0x%x lfeon=0x%x bitrate_code=0x%x\",\n             p_dac3->i_fscod, p_dac3->i_bsid, p_dac3->i_bsmod, p_dac3->i_acmod, p_dac3->i_lfeon, p_dac3->i_bitrate_code );\n#endif\n    MP4_READBOX_EXIT( 1 );\n}","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":184863,"func":"bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* layer)\n{\n    bool compositedLayerMappingChanged = false;\n    bool nonCompositedReasonChanged = updateLayerIfViewportConstrained(layer);\n    CompositingStateTransitionType compositedLayerUpdate = computeCompositedLayerUpdate(layer);\n\n    switch (compositedLayerUpdate) {\n    case AllocateOwnCompositedLayerMapping:\n        ASSERT(!layer->hasCompositedLayerMapping());\n        enableCompositingMode();\n\n        repaintOnCompositingChange(layer);\n        layer->ensureCompositedLayerMapping();\n        compositedLayerMappingChanged = true;\n\n        if (layer->isRootLayer() && isMainFrame()) {\n            if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())\n                scrollingCoordinator->frameViewRootLayerDidChange(m_renderView->frameView());\n        }\n\n        layer->setGroupedMapping(0);\n\n        if (layer->parent())\n            layer->repainter().computeRepaintRectsIncludingDescendants();\n\n        break;\n    case RemoveOwnCompositedLayerMapping:\n    case AddToSquashingLayer:\n        if (layer->hasCompositedLayerMapping()) {\n            if (layer->isReflection()) {\n                RenderLayer* sourceLayer = toRenderLayerModelObject(layer->renderer()->parent())->layer();\n                if (sourceLayer->hasCompositedLayerMapping()) {\n                    ASSERT(sourceLayer->compositedLayerMapping()->mainGraphicsLayer()->replicaLayer() == layer->compositedLayerMapping()->mainGraphicsLayer());\n                    sourceLayer->compositedLayerMapping()->mainGraphicsLayer()->setReplicatedByLayer(0);\n                }\n            }\n\n            removeViewportConstrainedLayer(layer);\n\n            layer->clearCompositedLayerMapping();\n            compositedLayerMappingChanged = true;\n\n            layer->repainter().computeRepaintRectsIncludingDescendants();\n\n            repaintOnCompositingChange(layer);\n        }\n\n        break;\n    case RemoveFromSquashingLayer:\n    case NoCompositingStateChange:\n        break;\n    }\n\n    if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForIntrinsicReasons())\n        compositedLayerMappingChanged = true;\n\n    if (compositedLayerMappingChanged && layer->renderer()->isRenderPart()) {\n        RenderLayerCompositor* innerCompositor = frameContentsCompositor(toRenderPart(layer->renderer()));\n        if (innerCompositor && innerCompositor->inCompositingMode())\n            innerCompositor->updateRootLayerAttachment();\n    }\n\n    if (compositedLayerMappingChanged)\n        layer->clipper().clearClipRectsIncludingDescendants(PaintingClipRects);\n\n    if (compositedLayerMappingChanged || nonCompositedReasonChanged) {\n        if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())\n            scrollingCoordinator->frameViewFixedObjectsDidChange(m_renderView->frameView());\n    }\n\n    return compositedLayerMappingChanged || nonCompositedReasonChanged;\n}\n","target":0,"code_token_length":636,"total_token_length":872,"max_tokens_setting":1024}
+{"idx":361145,"func":"static void call_trans2findnotifyfirst(connection_struct *conn,\n\t\t\t\t       struct smb_request *req,\n\t\t\t\t       char **pparams, int total_params,\n\t\t\t\t       char **ppdata, int total_data,\n\t\t\t\t       unsigned int max_data_bytes)\n{\n\tchar *params = *pparams;\n\tuint16 info_level;\n\n\tif (total_params < 6) {\n\t\treply_nterror(req, NT_STATUS_INVALID_PARAMETER);\n\t\treturn;\n\t}\n\n\tinfo_level = SVAL(params,4);\n\tDEBUG(3,(\"call_trans2findnotifyfirst - info_level %d\\n\", info_level));\n\n\tswitch (info_level) {\n\t\tcase 1:\n\t\tcase 2:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treply_nterror(req, NT_STATUS_INVALID_LEVEL);\n\t\t\treturn;\n\t}\n\n\t\/* Realloc the parameter and data sizes *\/\n\t*pparams = (char *)SMB_REALLOC(*pparams,6);\n\tif (*pparams == NULL) {\n\t\treply_nterror(req, NT_STATUS_NO_MEMORY);\n\t\treturn;\n\t}\n\tparams = *pparams;\n\n\tSSVAL(params,0,fnf_handle);\n\tSSVAL(params,2,0); \/* No changes *\/\n\tSSVAL(params,4,0); \/* No EA errors *\/\n\n\tfnf_handle++;\n\n\tif(fnf_handle == 0)\n\t\tfnf_handle = 257;\n\n\tsend_trans2_replies(conn, req, params, 6, *ppdata, 0, max_data_bytes);\n\n\treturn;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":372693,"func":"void CLASS lin_interpolate()\n{\n  int code[16][16][32], size=16, *ip, sum[4];\n  int f, c, x, y, row, col, shift, color;\n\n\n#ifdef DCRAW_VERBOSE\n  if (verbose) fprintf (stderr,_(\"Bilinear interpolation...\\n\"));\n#endif\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_INTERPOLATE,0,3);\n#endif\n\n  if (filters == 9) size = 6;\n  border_interpolate(1);\n  for (row=0; row < size; row++)\n    for (col=0; col < size; col++) {\n      ip = code[row][col]+1;\n      f = fcol(row,col);\n      memset (sum, 0, sizeof sum);\n      for (y=-1; y <= 1; y++)\n\tfor (x=-1; x <= 1; x++) {\n\t  shift = (y==0) + (x==0);\n\t  color = fcol(row+y,col+x);\n\t  if (color == f) continue;\n\t  *ip++ = (width*y + x)*4 + color;\n\t  *ip++ = shift;\n\t  *ip++ = color;\n\t  sum[color] += 1 << shift;\n\t}\n      code[row][col][0] = (ip - code[row][col]) \/ 3;\n      FORCC\n\tif (c != f) {\n\t  *ip++ = c;\n\t  *ip++ = 256 \/ sum[c];\n\t}\n    }\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_INTERPOLATE,1,3);\n#endif\n  lin_interpolate_loop(code,size);\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_INTERPOLATE,2,3);\n#endif\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":122402,"func":"int ethereum_message_verify(const EthereumVerifyMessage *msg) {\n  if (msg->signature.size != 65 || msg->address.size != 20) {\n    fsm_sendFailure(FailureType_Failure_SyntaxError, _(\"Malformed data\"));\n    return 1;\n  }\n\n  uint8_t pubkey[65];\n  uint8_t hash[32];\n\n  ethereum_message_hash(msg->message.bytes, msg->message.size, hash);\n\n  \/* v should be 27, 28 but some implementations use 0,1.  We are\n   * compatible with both.\n   *\/\n  uint8_t v = msg->signature.bytes[64];\n  if (v >= 27) {\n    v -= 27;\n  }\n  if (v >= 2 || ecdsa_recover_pub_from_sig(\n                    &secp256k1, pubkey, msg->signature.bytes, hash, v) != 0) {\n    return 2;\n  }\n\n  struct SHA3_CTX ctx;\n  sha3_256_Init(&ctx);\n  sha3_Update(&ctx, pubkey + 1, 64);\n  keccak_Final(&ctx, hash);\n\n  \/* result are the least significant 160 bits *\/\n  if (memcmp(msg->address.bytes, hash + 12, 20) != 0) {\n    return 2;\n  }\n  return 0;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":504919,"func":"rsvg_filter_set_args (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)\n{\n    const char *value;\n    RsvgFilter *filter;\n\n    filter = (RsvgFilter *) self;\n\n    if (rsvg_property_bag_size (atts)) {\n        if ((value = rsvg_property_bag_lookup (atts, \"filterUnits\"))) {\n            if (!strcmp (value, \"userSpaceOnUse\"))\n                filter->filterunits = userSpaceOnUse;\n            else\n                filter->filterunits = objectBoundingBox;\n        }\n        if ((value = rsvg_property_bag_lookup (atts, \"primitiveUnits\"))) {\n            if (!strcmp (value, \"objectBoundingBox\"))\n                filter->primitiveunits = objectBoundingBox;\n            else\n                filter->primitiveunits = userSpaceOnUse;\n        }\n        if ((value = rsvg_property_bag_lookup (atts, \"x\")))\n            filter->x = _rsvg_css_parse_length (value);\n        if ((value = rsvg_property_bag_lookup (atts, \"y\")))\n            filter->y = _rsvg_css_parse_length (value);\n        if ((value = rsvg_property_bag_lookup (atts, \"width\")))\n            filter->width = _rsvg_css_parse_length (value);\n        if ((value = rsvg_property_bag_lookup (atts, \"height\")))\n            filter->height = _rsvg_css_parse_length (value);\n        if ((value = rsvg_property_bag_lookup (atts, \"id\")))\n            rsvg_defs_register_name (ctx->priv->defs, value, &filter->super);\n    }\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":241863,"func":"void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(\n    const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {\n  TRACE_EVENT0(\"gpu\", \"GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped\");\n \n   base::ScopedClosureRunner scoped_completion_runner(\n       base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted,\n          host_id_, params.route_id, params.surface_id, params.surface_handle,\n          true, base::TimeTicks(), base::TimeDelta()));\n \n   gfx::PluginWindowHandle handle =\n       GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id);\n\n  if (!handle) {\n    TRACE_EVENT1(\"gpu\", \"SurfaceIDNotFound_RoutingToUI\",\n                 \"surface_id\", params.surface_id);\n#if defined(USE_AURA)\n    scoped_completion_runner.Release();\n    RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));\n#endif\n    return;\n  }\n\n\n  scoped_refptr<AcceleratedPresenter> presenter(\n      AcceleratedPresenter::GetForWindow(handle));\n  if (!presenter) {\n    TRACE_EVENT1(\"gpu\", \"EarlyOut_NativeWindowNotFound\", \"handle\", handle);\n    return;\n  }\n\n  scoped_completion_runner.Release();\n  presenter->AsyncPresentAndAcknowledge(\n      params.size,\n      params.surface_handle,\n       base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted,\n                  host_id_,\n                  params.route_id,\n                 params.surface_id,\n                 params.surface_handle));\n }\n","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":43313,"func":"load_dummy_buffer(\n    char_u\t*fname,\n    char_u\t*dirname_start,  \/\/ in: old directory\n    char_u\t*resulting_dir)  \/\/ out: new directory\n{\n    buf_T\t*newbuf;\n    bufref_T\tnewbufref;\n    bufref_T\tnewbuf_to_wipe;\n    int\t\tfailed = TRUE;\n    aco_save_T\taco;\n    int\t\treadfile_result;\n\n    \/\/ Allocate a buffer without putting it in the buffer list.\n    newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);\n    if (newbuf == NULL)\n\treturn NULL;\n    set_bufref(&newbufref, newbuf);\n\n    \/\/ Init the options.\n    buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);\n\n    \/\/ need to open the memfile before putting the buffer in a window\n    if (ml_open(newbuf) == OK)\n    {\n\t\/\/ Make sure this buffer isn't wiped out by autocommands.\n\t++newbuf->b_locked;\n\n\t\/\/ set curwin\/curbuf to buf and save a few things\n\taucmd_prepbuf(&aco, newbuf);\n\n\t\/\/ Need to set the filename for autocommands.\n\t(void)setfname(curbuf, fname, NULL, FALSE);\n\n\t\/\/ Create swap file now to avoid the ATTENTION message.\n\tcheck_need_swap(TRUE);\n\n\t\/\/ Remove the \"dummy\" flag, otherwise autocommands may not\n\t\/\/ work.\n\tcurbuf->b_flags &= ~BF_DUMMY;\n\n\tnewbuf_to_wipe.br_buf = NULL;\n\treadfile_result = readfile(fname, NULL,\n\t\t    (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,\n\t\t    NULL, READ_NEW | READ_DUMMY);\n\t--newbuf->b_locked;\n\tif (readfile_result == OK\n\t\t&& !got_int\n\t\t&& !(curbuf->b_flags & BF_NEW))\n\t{\n\t    failed = FALSE;\n\t    if (curbuf != newbuf)\n\t    {\n\t\t\/\/ Bloody autocommands changed the buffer!  Can happen when\n\t\t\/\/ using netrw and editing a remote file.  Use the current\n\t\t\/\/ buffer instead, delete the dummy one after restoring the\n\t\t\/\/ window stuff.\n\t\tset_bufref(&newbuf_to_wipe, newbuf);\n\t\tnewbuf = curbuf;\n\t    }\n\t}\n\n\t\/\/ restore curwin\/curbuf and a few other things\n\taucmd_restbuf(&aco);\n\tif (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe))\n\t    wipe_buffer(newbuf_to_wipe.br_buf, FALSE);\n\n\t\/\/ Add back the \"dummy\" flag, otherwise buflist_findname_stat() won't\n\t\/\/ skip it.\n\tnewbuf->b_flags |= BF_DUMMY;\n    }\n\n    \/\/ When autocommands\/'autochdir' option changed directory: go back.\n    \/\/ Let the caller know what the resulting dir was first, in case it is\n    \/\/ important.\n    mch_dirname(resulting_dir, MAXPATHL);\n    restore_start_dir(dirname_start);\n\n    if (!bufref_valid(&newbufref))\n\treturn NULL;\n    if (failed)\n    {\n\twipe_dummy_buffer(newbuf, dirname_start);\n\treturn NULL;\n    }\n    return newbuf;\n}","target":0,"code_token_length":719,"total_token_length":955,"max_tokens_setting":1024}
+{"idx":469137,"func":"static int io_sq_offload_start(struct io_ring_ctx *ctx,\n\t\t\t       struct io_uring_params *p)\n{\n\tint ret;\n\n\tmmgrab(current->mm);\n\tctx->sqo_mm = current->mm;\n\n\tif (ctx->flags & IORING_SETUP_SQPOLL) {\n\t\tret = -EPERM;\n\t\tif (!capable(CAP_SYS_ADMIN))\n\t\t\tgoto err;\n\n\t\tctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle);\n\t\tif (!ctx->sq_thread_idle)\n\t\t\tctx->sq_thread_idle = HZ;\n\n\t\tif (p->flags & IORING_SETUP_SQ_AFF) {\n\t\t\tint cpu = p->sq_thread_cpu;\n\n\t\t\tret = -EINVAL;\n\t\t\tif (cpu >= nr_cpu_ids)\n\t\t\t\tgoto err;\n\t\t\tif (!cpu_online(cpu))\n\t\t\t\tgoto err;\n\n\t\t\tctx->sqo_thread = kthread_create_on_cpu(io_sq_thread,\n\t\t\t\t\t\t\tctx, cpu,\n\t\t\t\t\t\t\t\"io_uring-sq\");\n\t\t} else {\n\t\t\tctx->sqo_thread = kthread_create(io_sq_thread, ctx,\n\t\t\t\t\t\t\t\"io_uring-sq\");\n\t\t}\n\t\tif (IS_ERR(ctx->sqo_thread)) {\n\t\t\tret = PTR_ERR(ctx->sqo_thread);\n\t\t\tctx->sqo_thread = NULL;\n\t\t\tgoto err;\n\t\t}\n\t\twake_up_process(ctx->sqo_thread);\n\t} else if (p->flags & IORING_SETUP_SQ_AFF) {\n\t\t\/* Can't have SQ_AFF without SQPOLL *\/\n\t\tret = -EINVAL;\n\t\tgoto err;\n\t}\n\n\tret = io_init_wq_offload(ctx, p);\n\tif (ret)\n\t\tgoto err;\n\n\treturn 0;\nerr:\n\tio_finish_async(ctx);\n\tif (ctx->sqo_mm) {\n\t\tmmdrop(ctx->sqo_mm);\n\t\tctx->sqo_mm = NULL;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":260934,"func":"int dbd_db_login(SV* dbh, imp_dbh_t* imp_dbh, char* dbname, char* user,\n\t\t char* password) {\n#ifdef dTHR\n  dTHR;\n#endif\n  dTHX; \n  D_imp_xxh(dbh);\n\n  if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)\n    PerlIO_printf(DBIc_LOGPIO(imp_xxh),\n\t\t  \"imp_dbh->connect: dsn = %s, uid = %s, pwd = %s\\n\",\n\t\t  dbname ? dbname : \"NULL\",\n\t\t  user ? user : \"NULL\",\n\t\t  password ? password : \"NULL\");\n\n  imp_dbh->stats.auto_reconnects_ok= 0;\n  imp_dbh->stats.auto_reconnects_failed= 0;\n  imp_dbh->bind_type_guessing= FALSE;\n  imp_dbh->bind_comment_placeholders= FALSE;\n  imp_dbh->has_transactions= TRUE;\n \/* Safer we flip this to TRUE perl side if we detect a mod_perl env. *\/\n  imp_dbh->auto_reconnect = FALSE;\n\n  \/* HELMUT *\/\n#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION\n  imp_dbh->enable_utf8 = FALSE;  \/* initialize mysql_enable_utf8 *\/\n#endif\n\n  if (!my_login(aTHX_ dbh, imp_dbh))\n  {\n    if(imp_dbh->pmysql)\n        do_error(dbh, mysql_errno(imp_dbh->pmysql),\n                mysql_error(imp_dbh->pmysql) ,mysql_sqlstate(imp_dbh->pmysql));\n    return FALSE;\n  }\n\n    \/*\n     *  Tell DBI, that dbh->disconnect should be called for this handle\n     *\/\n    DBIc_ACTIVE_on(imp_dbh);\n\n    \/* Tell DBI, that dbh->destroy should be called for this handle *\/\n    DBIc_on(imp_dbh, DBIcf_IMPSET);\n\n    return TRUE;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":117663,"func":"OPJ_BOOL opj_tcd_t1_encode ( opj_tcd_t *p_tcd )\n{\n        opj_t1_t * l_t1;\n        const OPJ_FLOAT64 * l_mct_norms;\n        OPJ_UINT32 l_mct_numcomps = 0U;\n        opj_tcp_t * l_tcp = p_tcd->tcp;\n\n        l_t1 = opj_t1_create(OPJ_TRUE);\n        if (l_t1 == 00) {\n                return OPJ_FALSE;\n        }\n\n        if (l_tcp->mct == 1) {\n                l_mct_numcomps = 3U;\n                \/* irreversible encoding *\/\n                if (l_tcp->tccps->qmfbid == 0) {\n                        l_mct_norms = opj_mct_get_mct_norms_real();\n                }\n                else {\n                        l_mct_norms = opj_mct_get_mct_norms();\n                }\n        }\n        else {\n                l_mct_numcomps = p_tcd->image->numcomps;\n                l_mct_norms = (const OPJ_FLOAT64 *) (l_tcp->mct_norms);\n        }\n\n        if (! opj_t1_encode_cblks(l_t1, p_tcd->tcd_image->tiles , l_tcp, l_mct_norms, l_mct_numcomps)) {\n        opj_t1_destroy(l_t1);\n                return OPJ_FALSE;\n        }\n\n        opj_t1_destroy(l_t1);\n\n        return OPJ_TRUE;\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":338442,"func":"static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)\n\n{\n\n    AVStream *st = c->fc->streams[c->fc->nb_streams-1];\n\n    uint32_t type;\n\n    uint32_t ctype;\n\n\n\n    get_byte(pb); \/* version *\/\n\n    get_be24(pb); \/* flags *\/\n\n\n\n    \/* component type *\/\n\n    ctype = get_le32(pb);\n\n    type = get_le32(pb); \/* component subtype *\/\n\n\n\n    dprintf(c->fc, \"ctype= %c%c%c%c (0x%08x)\\n\", *((char *)&ctype), ((char *)&ctype)[1],\n\n            ((char *)&ctype)[2], ((char *)&ctype)[3], (int) ctype);\n\n    dprintf(c->fc, \"stype= %c%c%c%c\\n\",\n\n            *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);\n\n    if(!ctype)\n\n        c->isom = 1;\n\n    if     (type == MKTAG('v','i','d','e'))\n\n        st->codec->codec_type = CODEC_TYPE_VIDEO;\n\n    else if(type == MKTAG('s','o','u','n'))\n\n        st->codec->codec_type = CODEC_TYPE_AUDIO;\n\n    else if(type == MKTAG('m','1','a',' '))\n\n        st->codec->codec_id = CODEC_ID_MP2;\n\n    else if(type == MKTAG('s','u','b','p')) {\n\n        st->codec->codec_type = CODEC_TYPE_SUBTITLE;\n\n    }\n\n    get_be32(pb); \/* component  manufacture *\/\n\n    get_be32(pb); \/* component flags *\/\n\n    get_be32(pb); \/* component flags mask *\/\n\n\n\n    if(atom.size <= 24)\n\n        return 0; \/* nothing left to read *\/\n\n\n\n    url_fskip(pb, atom.size - (url_ftell(pb) - atom.offset));\n\n    return 0;\n\n}\n","target":1,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":468749,"func":"yin_parse_extcomplex_bool(struct lys_module *mod, struct lyxml_elem *node,\n                          struct lys_ext_instance_complex *ext, LY_STMT stmt,\n                          const char *true_val, const char *false_val, struct unres_schema *unres)\n{\n    uint8_t *val;\n    const char *str;\n    struct lyext_substmt *info;\n\n    val = lys_ext_complex_get_substmt(stmt, ext, &info);\n    if (!val) {\n        LOGVAL(mod->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);\n        return EXIT_FAILURE;\n    }\n    if (*val) {\n        LOGVAL(mod->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);\n        return EXIT_FAILURE;\n    }\n\n    if (lyp_yin_parse_subnode_ext(mod, ext, LYEXT_PAR_EXTINST, node, (LYEXT_SUBSTMT)stmt, 0, unres)) {\n        return EXIT_FAILURE;\n    }\n\n    str = lyxml_get_attr(node, \"value\", NULL);\n    if (!str) {\n        LOGVAL(mod->ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, \"value\", node->name);\n    } else if (true_val && !strcmp(true_val, str)) {\n        \/* true value *\/\n        *val = 1;\n    } else if (false_val && !strcmp(false_val, str)) {\n        \/* false value *\/\n        *val = 2;\n    } else {\n        \/* unknown value *\/\n        LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);\n        return EXIT_FAILURE;\n    }\n\n    return EXIT_SUCCESS;\n}","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":38503,"func":"static u32 gf_media_nalu_locate_start_code_bs(GF_BitStream *bs, Bool locate_trailing)\n{\n\tu32 v, bpos, nb_cons_zeros = 0;\n\tchar avc_cache[AVC_CACHE_SIZE];\n\tu64 end, cache_start, load_size;\n\tu64 start = gf_bs_get_position(bs);\n\tif (start < 3) return 0;\n\n\tload_size = 0;\n\tbpos = 0;\n\tcache_start = 0;\n\tend = 0;\n\tv = 0xffffffff;\n\twhile (!end) {\n\t\t\/*refill cache*\/\n\t\tif (bpos == (u32)load_size) {\n\t\t\tif (!gf_bs_available(bs)) break;\n\t\t\tload_size = gf_bs_available(bs);\n\t\t\tif (load_size > AVC_CACHE_SIZE) load_size = AVC_CACHE_SIZE;\n\t\t\tbpos = 0;\n\t\t\tcache_start = gf_bs_get_position(bs);\n\t\t\tgf_bs_read_data(bs, avc_cache, (u32)load_size);\n\t\t}\n\t\tv = ( (v<<8) & 0xFFFFFF00) | ((u32) avc_cache[bpos]);\n\t\tbpos++;\n\n\t\tif (locate_trailing) {\n\t\t\tif ((v & 0x000000FF) == 0) nb_cons_zeros++;\n\t\t\telse nb_cons_zeros = 0;\n\t\t}\n\n\t\tif (v == 0x00000001) end = cache_start + bpos - 4;\n\t\telse if ((v & 0x00FFFFFF) == 0x00000001) end = cache_start + bpos - 3;\n\t}\n\n\tgf_bs_seek(bs, start);\n\tif (!end) end = gf_bs_get_size(bs);\n\tif (locate_trailing) {\n\t\tif (nb_cons_zeros >= 3)\n\t\t\treturn (u32)(end - start - nb_cons_zeros);\n\t}\n\treturn (u32)(end - start);\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":70972,"func":"flatpak_transaction_add_op (FlatpakTransaction             *self,\n                            const char                     *remote,\n                            FlatpakDecomposed              *ref,\n                            const char                    **subpaths,\n                            const char                    **previous_ids,\n                            const char                     *commit,\n                            GFile                          *bundle,\n                            FlatpakTransactionOperationType kind,\n                            gboolean                        pin_on_deploy,\n                            GError                        **error)\n{\n  FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (self);\n  FlatpakTransactionOperation *op;\n  g_autofree char *subpaths_str = NULL;\n\n  subpaths_str = subpaths_to_string (subpaths);\n  g_debug (\"Transaction: %s %s:%s%s%s%s\",\n           kind_to_str (kind), remote, flatpak_decomposed_get_ref (ref),\n           commit != NULL ? \"@\" : \"\",\n           commit != NULL ? commit : \"\",\n           subpaths_str);\n\n  op = flatpak_transaction_get_last_op_for_ref (self, ref);\n  \/* If previous_ids is given, then this is a rebase operation. *\/\n  if (op != NULL && kind_compatible (kind, op->kind, previous_ids != NULL))\n    {\n      g_auto(GStrv) old_subpaths = NULL;\n      g_auto(GStrv) old_previous_ids = NULL;\n\n      old_subpaths = op->subpaths;\n      op->subpaths = flatpak_subpaths_merge (old_subpaths, (char **) subpaths);\n\n      old_previous_ids = op->previous_ids;\n      op->previous_ids = flatpak_strv_merge (old_previous_ids, (char **) previous_ids);\n\n      return op;\n    }\n\n  op = flatpak_transaction_operation_new (remote, ref, subpaths, previous_ids,\n                                          commit, bundle, kind, pin_on_deploy);\n  g_hash_table_insert (priv->last_op_for_ref, flatpak_decomposed_ref (ref), op);\n\n  priv->ops = g_list_prepend (priv->ops, op);\n\n  priv->needs_resolve = TRUE;\n\n  return op;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":399351,"func":"switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,\n\t\t    int pinned)\n{\n\tstruct hrtimer_cpu_base *new_cpu_base, *this_cpu_base;\n\tstruct hrtimer_clock_base *new_base;\n\tint basenum = base->index;\n\n\tthis_cpu_base = this_cpu_ptr(&hrtimer_bases);\n\tnew_cpu_base = get_target_base(this_cpu_base, pinned);\nagain:\n\tnew_base = &new_cpu_base->clock_base[basenum];\n\n\tif (base != new_base) {\n\t\t\/*\n\t\t * We are trying to move timer to new_base.\n\t\t * However we can't change timer's base while it is running,\n\t\t * so we keep it on the same CPU. No hassle vs. reprogramming\n\t\t * the event source in the high resolution case. The softirq\n\t\t * code will take care of this when the timer function has\n\t\t * completed. There is no conflict as we hold the lock until\n\t\t * the timer is enqueued.\n\t\t *\/\n\t\tif (unlikely(hrtimer_callback_running(timer)))\n\t\t\treturn base;\n\n\t\t\/* See the comment in lock_hrtimer_base() *\/\n\t\ttimer->base = &migration_base;\n\t\traw_spin_unlock(&base->cpu_base->lock);\n\t\traw_spin_lock(&new_base->cpu_base->lock);\n\n\t\tif (new_cpu_base != this_cpu_base &&\n\t\t    hrtimer_check_target(timer, new_base)) {\n\t\t\traw_spin_unlock(&new_base->cpu_base->lock);\n\t\t\traw_spin_lock(&base->cpu_base->lock);\n\t\t\tnew_cpu_base = this_cpu_base;\n\t\t\ttimer->base = base;\n\t\t\tgoto again;\n\t\t}\n\t\ttimer->base = new_base;\n\t} else {\n\t\tif (new_cpu_base != this_cpu_base &&\n\t\t    hrtimer_check_target(timer, new_base)) {\n\t\t\tnew_cpu_base = this_cpu_base;\n\t\t\tgoto again;\n\t\t}\n\t}\n\treturn new_base;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":162274,"func":"DEFINE_TEST(test_read_format_rar5_multiple_files_solid)\n{\n\tconst int DATA_SIZE = 4096;\n\tuint8_t buff[4096];\n\n\tPROLOGUE(\"test_read_format_rar5_multiple_files_solid.rar\");\n\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test1.bin\", archive_entry_pathname(ae));\n\tassertEqualInt(DATA_SIZE, archive_entry_size(ae));\n\tassertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));\n\tassertA(verify_data(buff, 1, DATA_SIZE));\n\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test2.bin\", archive_entry_pathname(ae));\n\tassertEqualInt(DATA_SIZE, archive_entry_size(ae));\n\tassertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));\n\tassertA(verify_data(buff, 2, DATA_SIZE));\n\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test3.bin\", archive_entry_pathname(ae));\n\tassertEqualInt(DATA_SIZE, archive_entry_size(ae));\n\tassertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));\n\tassertA(verify_data(buff, 3, DATA_SIZE));\n\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"test4.bin\", archive_entry_pathname(ae));\n\tassertEqualInt(DATA_SIZE, archive_entry_size(ae));\n\tassertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));\n\tassertA(verify_data(buff, 4, DATA_SIZE));\n\n\tassertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));\n\tEPILOGUE();\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":248315,"func":"htmlParseComment(htmlParserCtxtPtr ctxt) {\n    xmlChar *buf = NULL;\n    int len;\n    int size = HTML_PARSER_BUFFER_SIZE;\n    int q, ql;\n    int r, rl;\n    int cur, l;\n    xmlParserInputState state;\n\n    \/*\n     * Check that there is a comment right here.\n     *\/\n    if ((RAW != '<') || (NXT(1) != '!') ||\n        (NXT(2) != '-') || (NXT(3) != '-')) return;\n\n    state = ctxt->instate;\n    ctxt->instate = XML_PARSER_COMMENT;\n    SHRINK;\n    SKIP(4);\n    buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));\n    if (buf == NULL) {\n        htmlErrMemory(ctxt, \"buffer allocation failed\\n\");\n\tctxt->instate = state;\n\treturn;\n    }\n    len = 0;\n    buf[len] = 0;\n    q = CUR_CHAR(ql);\n    if (!IS_CHAR(q))\n        goto unfinished;\n    NEXTL(ql);\n    r = CUR_CHAR(rl);\n    if (!IS_CHAR(r))\n        goto unfinished;\n    NEXTL(rl);\n    cur = CUR_CHAR(l);\n    while (IS_CHAR(cur) &&\n           ((cur != '>') ||\n\t    (r != '-') || (q != '-'))) {\n\tif (len + 5 >= size) {\n\t    xmlChar *tmp;\n\n\t    size *= 2;\n\t    tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));\n\t    if (tmp == NULL) {\n\t        xmlFree(buf);\n\t        htmlErrMemory(ctxt, \"growing buffer failed\\n\");\n\t\tctxt->instate = state;\n\t\treturn;\n\t    }\n\t    buf = tmp;\n\t}\n\tCOPY_BUF(ql,buf,len,q);\n\tq = r;\n\tql = rl;\n\tr = cur;\n\trl = l;\n\tNEXTL(l);\n\tcur = CUR_CHAR(l);\n\tif (cur == 0) {\n\t    SHRINK;\n\t    GROW;\n\t    cur = CUR_CHAR(l);\n\t}\n    }\n    buf[len] = 0;\n    if (IS_CHAR(cur)) {\n        NEXT;\n\tif ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&\n\t    (!ctxt->disableSAX))\n\t    ctxt->sax->comment(ctxt->userData, buf);\n\txmlFree(buf);\n\tctxt->instate = state;\n\treturn;\n    }\n\nunfinished:\n    htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,\n\t\t \"Comment not terminated \\n<!--%.50s\\n\", buf, NULL);\n    xmlFree(buf);\n}\n","target":0,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":13197,"func":"int sc_asn1_read_tag(const u8 ** buf, size_t buflen, unsigned int *cla_out,\n\t\t     unsigned int *tag_out, size_t *taglen)\n{\n\tconst u8 *p = *buf;\n\tsize_t left = buflen, len;\n\tunsigned int cla, tag, i;\n\n\tif (left < 2)\n\t\treturn SC_ERROR_INVALID_ASN1_OBJECT;\n\t*buf = NULL;\n\tif (*p == 0xff || *p == 0) {\n\t\t\/* end of data reached *\/\n\t\t*taglen = 0;\n\t\t*tag_out = SC_ASN1_TAG_EOC;\n\t\treturn SC_SUCCESS;\n\t}\n\t\/* parse tag byte(s)\n\t * Resulted tag is presented by integer that has not to be\n\t * confused with the 'tag number' part of ASN.1 tag.\n\t *\/\n\tcla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);\n\ttag = *p & SC_ASN1_TAG_PRIMITIVE;\n\tp++;\n\tleft--;\n\tif (tag == SC_ASN1_TAG_PRIMITIVE) {\n\t\t\/* high tag number *\/\n\t\tsize_t n = SC_ASN1_TAGNUM_SIZE - 1;\n\t\t\/* search the last tag octet *\/\n\t\twhile (left-- != 0 && n != 0) {\n\t\t\ttag <<= 8;\n\t\t\ttag |= *p;\n\t\t\tif ((*p++ & 0x80) == 0)\n\t\t\t\tbreak;\n\t\t\tn--;\n\t\t}\n\t\tif (left == 0 || n == 0)\n\t\t\t\/* either an invalid tag or it doesn't fit in\n\t\t\t * unsigned int *\/\n\t\t\treturn SC_ERROR_INVALID_ASN1_OBJECT;\n\t}\n\n\t\/* parse length byte(s) *\/\n \tlen = *p & 0x7f;\n \tif (*p++ & 0x80) {\n \t\tunsigned int a = 0;\n \t\tif (len > 4 || len > left)\n \t\t\treturn SC_ERROR_INVALID_ASN1_OBJECT;\n \t\tleft -= len;\n\t\tfor (i = 0; i < len; i++) {\n\t\t\ta <<= 8;\n\t\t\ta |= *p;\n\t\t\tp++;\n\t\t}\n\t\tlen = a;\n\t}\n\n\t*cla_out = cla;\n\t*tag_out = tag;\n\t*taglen = len;\n\t*buf = p;\n\n\tif (len > left)\n\t\treturn SC_ERROR_ASN1_END_OF_CONTENTS;\n\n\treturn SC_SUCCESS;\n}\n","target":1,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":248255,"func":"gamma_component_compose(int do_background, double input_sample, double alpha,\n double background, int *compose)\n{\n switch (do_background)\n {\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n case PNG_BACKGROUND_GAMMA_SCREEN:\n case PNG_BACKGROUND_GAMMA_FILE:\n case PNG_BACKGROUND_GAMMA_UNIQUE:\n \/* Standard PNG background processing. *\/\n if (alpha < 1)\n {\n if (alpha > 0)\n {\n               input_sample = input_sample * alpha + background * (1-alpha);\n if (compose != NULL)\n *compose = 1;\n }\n\n else\n               input_sample = background;\n }\n break;\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD:\n case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN:\n \/* The components are premultiplied in either case and the output is\n          * gamma encoded (to get standard Porter-Duff we expect the output\n          * gamma to be set to 1.0!)\n          *\/\n case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED:\n \/* The optimization is that the partial-alpha entries are linear\n          * while the opaque pixels are gamma encoded, but this only affects the\n          * output encoding.\n          *\/\n if (alpha < 1)\n {\n if (alpha > 0)\n {\n               input_sample *= alpha;\n if (compose != NULL)\n *compose = 1;\n }\n\n else\n               input_sample = 0;\n }\n break;\n#endif\n\n default:\n \/* Standard cases where no compositing is done (so the component\n          * value is already correct.)\n          *\/\n         UNUSED(alpha)\n         UNUSED(background)\n         UNUSED(compose)\n break;\n }\n\n return input_sample;\n}\n","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":439057,"func":"static ImageList *SFDGetImagePNG(FILE *sfd) {\n    int pnglen;\n    ImageList *img;\n    struct enc85 dec = {0};\n    int i, ch;\n\n    img = calloc(1,sizeof(ImageList));\n    dec.pos = -1;\n    dec.sfd = sfd;\n\n    getint(sfd,&pnglen);\n    getreal(sfd,&img->xoff);\n    getreal(sfd,&img->yoff);\n    getreal(sfd,&img->xscale);\n    getreal(sfd,&img->yscale);\n\n    while ( (ch=nlgetc(sfd))==' ' || ch=='\\t' )\n        \/* skip *\/;\n\n    char* pngbuf = malloc(pnglen * sizeof(char));\n    if (pngbuf == NULL) {\n        IError(\"Failed to allocate buffer to read PNG in SFD file\");\n        return NULL;\n    }\n\n    for (i = 0; i<pnglen; ++i) {\n        pngbuf[i] = Dec85(&dec);\n    }\n\n    img->image = GImageReadPngBuf(pngbuf, pnglen);\n    free(pngbuf);\n\n    if (img->image == NULL) {\n        IError(\"Failed to read PNG in SFD file, skipping it.\");\n        free(img);\n        return NULL;\n    }\n\n    img->bb.minx = img->xoff; img->bb.maxy = img->yoff;\n    img->bb.maxx = img->xoff + GImageGetWidth(img->image)*img->xscale;\n    img->bb.miny = img->yoff - GImageGetHeight(img->image)*img->yscale;\n    return img;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":339349,"func":"static void scsi_do_read(void *opaque, int ret)\n{\n    SCSIDiskReq *r = opaque;\n    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n    uint32_t n;\n    if (r->req.aiocb != NULL) {\n        r->req.aiocb = NULL;\n        bdrv_acct_done(s->qdev.conf.bs, &r->acct);\n    if (ret < 0) {\n        if (scsi_handle_rw_error(r, -ret)) {\n            goto done;\n    if (r->req.sg) {\n        dma_acct_start(s->qdev.conf.bs, &r->acct, r->req.sg, BDRV_ACCT_READ);\n        r->req.resid -= r->req.sg->size;\n        r->req.aiocb = dma_bdrv_read(s->qdev.conf.bs, r->req.sg, r->sector,\n                                     scsi_dma_complete, r);\n    } else {\n        n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);\n        bdrv_acct_start(s->qdev.conf.bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);\n        r->req.aiocb = bdrv_aio_readv(s->qdev.conf.bs, r->sector, &r->qiov, n,\n                                      scsi_read_complete, r);\ndone:\n    if (!r->req.io_canceled) {\n        scsi_req_unref(&r->req);","target":1,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":362110,"func":"  event_help( RenderState  state )\n  {\n    ADisplay  display = (ADisplay)state->display.disp;\n    grEvent   dummy_event;\n\n\n    adisplay_clear( display );\n    grGotoxy( 0, 0 );\n    grSetMargin( 2, 1 );\n    grGotobitmap( display->bitmap );\n\n    grWriteln( \"Text Viewer - Simple text\/font proofer for the FreeType project\" );\n    grLn();\n    grWriteln( \"This program is used to display text using two distinct algorithms.\" );\n    grWriteln( \"On the left, text is rendered by the TrueType bytecode interpreter.\" );\n    grWriteln( \"In the middle, text is rendered through the FreeType auto-hinter.\" );\n    grWriteln( \"On the right, text is rendered unhinted.\" );\n    grLn();\n    grWriteln( \"Use the following keys:\" );\n    grLn();\n    grWriteln( \"  F1, ?       display this help screen\" );\n    grLn();\n    grWriteln( \"  n, p        select previous\/next font\" );\n    grLn();\n    grWriteln( \"  1, 2, 3     select left, middle, or right column\" );\n    grWriteln( \"  a           toggle `ignore global advance width flag'\" );\n    grWriteln( \"  d           toggle lsb\/rsb deltas\" );\n    grWriteln( \"  h           toggle hinting mode\" );\n    grWriteln( \"  k           toggle kerning\" );\n    grWriteln( \"  g, v        adjust gamma value\" );\n    grWriteln( \"  r           toggle rendering mode\" );\n    grLn();\n    grWriteln( \"  l           change LCD filter type\" );\n    grWriteln( \"  [, ]        select custom LCD filter weight\" );\n    grWriteln( \"  -, +(=)     adjust selected custom LCD filter weight\");\n    grLn();\n    grWriteln( \"  Up, Down    adjust pointsize by 0.5 unit\" );\n    grWriteln( \"  PgUp, PgDn  adjust pointsize by 5 units\" );\n    grLn();\n    grWriteln( \"press any key to exit this help screen\" );\n\n    grRefreshSurface( display->surface );\n    grListenSurface( display->surface, gr_event_key, &dummy_event );\n  }","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":365515,"func":"static int proc_fd_info(struct inode *inode, struct path *path, char *info)\n{\n\tstruct task_struct *task = get_proc_task(inode);\n\tstruct files_struct *files = NULL;\n\tstruct file *file;\n\tint fd = proc_fd(inode);\n\n\tif (task) {\n\t\tfiles = get_files_struct(task);\n\t\tput_task_struct(task);\n\t}\n\tif (files) {\n\t\t\/*\n\t\t * We are not taking a ref to the file structure, so we must\n\t\t * hold ->file_lock.\n\t\t *\/\n\t\tspin_lock(&files->file_lock);\n\t\tfile = fcheck_files(files, fd);\n\t\tif (file) {\n\t\t\tunsigned int f_flags;\n\t\t\tstruct fdtable *fdt;\n\n\t\t\tfdt = files_fdtable(files);\n\t\t\tf_flags = file->f_flags & ~O_CLOEXEC;\n\t\t\tif (FD_ISSET(fd, fdt->close_on_exec))\n\t\t\t\tf_flags |= O_CLOEXEC;\n\n\t\t\tif (path) {\n\t\t\t\t*path = file->f_path;\n\t\t\t\tpath_get(&file->f_path);\n\t\t\t}\n\t\t\tif (info)\n\t\t\t\tsnprintf(info, PROC_FDINFO_MAX,\n\t\t\t\t\t \"pos:\\t%lli\\n\"\n\t\t\t\t\t \"flags:\\t0%o\\n\",\n\t\t\t\t\t (long long) file->f_pos,\n\t\t\t\t\t f_flags);\n\t\t\tspin_unlock(&files->file_lock);\n\t\t\tput_files_struct(files);\n\t\t\treturn 0;\n\t\t}\n\t\tspin_unlock(&files->file_lock);\n\t\tput_files_struct(files);\n\t}\n\treturn -ENOENT;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":185586,"func":"SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)\n{\n int error;\n\n if (!name)\n return -EFAULT;\n if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))\n return -EFAULT;\n\n\tdown_read(&uts_sem);\n\terror = __copy_to_user(&name->sysname, &utsname()->sysname,\n\t\t\t       __OLD_UTS_LEN);\n\terror |= __put_user(0, name->sysname + __OLD_UTS_LEN);\n\terror |= __copy_to_user(&name->nodename, &utsname()->nodename,\n\t\t\t\t__OLD_UTS_LEN);\n\terror |= __put_user(0, name->nodename + __OLD_UTS_LEN);\n\terror |= __copy_to_user(&name->release, &utsname()->release,\n\t\t\t\t__OLD_UTS_LEN);\n\terror |= __put_user(0, name->release + __OLD_UTS_LEN);\n\terror |= __copy_to_user(&name->version, &utsname()->version,\n\t\t\t\t__OLD_UTS_LEN);\n\terror |= __put_user(0, name->version + __OLD_UTS_LEN);\n\terror |= __copy_to_user(&name->machine, &utsname()->machine,\n\t\t\t\t__OLD_UTS_LEN);\n\terror |= __put_user(0, name->machine + __OLD_UTS_LEN);\n\tup_read(&uts_sem);\n\n if (!error && override_architecture(name))\n\t\terror = -EFAULT;\n if (!error && override_release(name->release, sizeof(name->release)))\n\t\terror = -EFAULT;\n return error ? -EFAULT : 0;\n}\n","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":355342,"func":"expand_user_macro (struct obstack *obs, symbol *sym,\n\t\t   int argc, token_data **argv)\n{\n  const char *text;\n  int i;\n\n  for (text = SYMBOL_TEXT (sym); *text != '\\0';)\n    {\n      if (*text != '$')\n\t{\n\t  obstack_1grow (obs, *text);\n\t  text++;\n\t  continue;\n\t}\n      text++;\n      switch (*text)\n\t{\n\tcase '0': case '1': case '2': case '3': case '4':\n\tcase '5': case '6': case '7': case '8': case '9':\n\t  if (no_gnu_extensions)\n\t    {\n\t      i = *text++ - '0';\n\t    }\n\t  else\n\t    {\n\t      for (i = 0; isdigit (to_uchar (*text)); text++)\n\t\ti = i*10 + (*text - '0');\n\t    }\n\t  if (i < argc)\n\t    obstack_grow (obs, TOKEN_DATA_TEXT (argv[i]),\n\t\t\t  strlen (TOKEN_DATA_TEXT (argv[i])));\n\t  break;\n\n\tcase '#':\t\t\/* number of arguments *\/\n\t  shipout_int (obs, argc - 1);\n\t  text++;\n\t  break;\n\n\tcase '*':\t\t\/* all arguments *\/\n\tcase '@':\t\t\/* ... same, but quoted *\/\n\t  dump_args (obs, argc, argv, \",\", *text == '@');\n\t  text++;\n\t  break;\n\n\tdefault:\n\t  obstack_1grow (obs, '$');\n\t  break;\n\t}\n    }\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":434364,"func":"static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)\n{\n  BUFFER templ;\n\n  memset(&templ, 0, sizeof(templ));\n\n  \/* Insist on at least one parameter *\/\n  if (!MoreArgs(s))\n  {\n    if (data == M_SPAM)\n      strfcpy(err->data, _(\"spam: no matching pattern\"), err->dsize);\n    else\n      strfcpy(err->data, _(\"nospam: no matching pattern\"), err->dsize);\n    return -1;\n  }\n\n  \/* Extract the first token, a regexp *\/\n  mutt_extract_token (buf, s, 0);\n\n  \/* data should be either M_SPAM or M_NOSPAM. M_SPAM is for spam commands. *\/\n  if (data == M_SPAM)\n  {\n    \/* If there's a second parameter, it's a template for the spam tag. *\/\n    if (MoreArgs(s))\n    {\n      mutt_extract_token (&templ, s, 0);\n\n      \/* Add to the spam list. *\/\n      if (add_to_spam_list (&SpamList, buf->data, templ.data, err) != 0) {\n\t  FREE(&templ.data);\n          return -1;\n      }\n      FREE(&templ.data);\n    }\n\n    \/* If not, try to remove from the nospam list. *\/\n    else\n    {\n      mutt_remove_from_rx_list(&NoSpamList, buf->data);\n    }\n\n    return 0;\n  }\n\n  \/* M_NOSPAM is for nospam commands. *\/\n  else if (data == M_NOSPAM)\n  {\n    \/* nospam only ever has one parameter. *\/\n\n    \/* \"*\" is a special case. *\/\n    if (!mutt_strcmp(buf->data, \"*\"))\n    {\n      mutt_free_spam_list (&SpamList);\n      mutt_free_rx_list (&NoSpamList);\n      return 0;\n    }\n\n    \/* If it's on the spam list, just remove it. *\/\n    if (remove_from_spam_list(&SpamList, buf->data) != 0)\n      return 0;\n\n    \/* Otherwise, add it to the nospam list. *\/\n    if (mutt_add_to_rx_list (&NoSpamList, buf->data, REG_ICASE, err) != 0)\n      return -1;\n\n    return 0;\n  }\n\n  \/* This should not happen. *\/\n  strfcpy(err->data, \"This is no good at all.\", err->dsize);\n  return -1;\n}","target":0,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":281085,"func":"static void cirrus_linear_write(void *opaque, hwaddr addr,\n                                uint64_t val, unsigned size)\n{\n    CirrusVGAState *s = opaque;\n    unsigned mode;\n\n    addr &= s->cirrus_addr_mask;\n\n    if (((s->vga.sr[0x17] & 0x44) == 0x44) &&\n        ((addr & s->linear_mmio_mask) ==  s->linear_mmio_mask)) {\n\t\/* memory-mapped I\/O *\/\n\tcirrus_mmio_blt_write(s, addr & 0xff, val);\n    } else if (s->cirrus_srcptr != s->cirrus_srcptr_end) {\n\t\/* bitblt *\/\n\t*s->cirrus_srcptr++ = (uint8_t) val;\n\tif (s->cirrus_srcptr >= s->cirrus_srcptr_end) {\n\t    cirrus_bitblt_cputovideo_next(s);\n\t}\n    } else {\n\t\/* video memory *\/\n\tif ((s->vga.gr[0x0B] & 0x14) == 0x14) {\n\t    addr <<= 4;\n\t} else if (s->vga.gr[0x0B] & 0x02) {\n\t    addr <<= 3;\n\t}\n\taddr &= s->cirrus_addr_mask;\n\n\tmode = s->vga.gr[0x05] & 0x7;\n\tif (mode < 4 || mode > 5 || ((s->vga.gr[0x0B] & 0x4) == 0)) {\n\t    *(s->vga.vram_ptr + addr) = (uint8_t) val;\n            memory_region_set_dirty(&s->vga.vram, addr, 1);\n\t} else {\n\t    if ((s->vga.gr[0x0B] & 0x14) != 0x14) {\n\t\tcirrus_mem_writeb_mode4and5_8bpp(s, mode, addr, val);\n\t    } else {\n\t\tcirrus_mem_writeb_mode4and5_16bpp(s, mode, addr, val);\n\t    }\n\t}\n    }\n}\n","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":436742,"func":"int mingw_open (const char *filename, int oflags, ...)\n{\n\tva_list args;\n\tunsigned mode;\n\tint fd;\n\twchar_t wfilename[MAX_PATH];\n\n\tva_start(args, oflags);\n\tmode = va_arg(args, int);\n\tva_end(args);\n\n\tif (filename && !strcmp(filename, \"\/dev\/null\"))\n\t\tfilename = \"nul\";\n\n\tif (xutftowcs_path(wfilename, filename) < 0)\n\t\treturn -1;\n\tfd = _wopen(wfilename, oflags, mode);\n\n\tif (fd < 0 && (oflags & O_ACCMODE) != O_RDONLY && errno == EACCES) {\n\t\tDWORD attrs = GetFileAttributesW(wfilename);\n\t\tif (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))\n\t\t\terrno = EISDIR;\n\t}\n\tif ((oflags & O_CREAT) && needs_hiding(filename)) {\n\t\t\/*\n\t\t * Internally, _wopen() uses the CreateFile() API which errors\n\t\t * out with an ERROR_ACCESS_DENIED if CREATE_ALWAYS was\n\t\t * specified and an already existing file's attributes do not\n\t\t * match *exactly*. As there is no mode or flag we can set that\n\t\t * would correspond to FILE_ATTRIBUTE_HIDDEN, let's just try\n\t\t * again *without* the O_CREAT flag (that corresponds to the\n\t\t * CREATE_ALWAYS flag of CreateFile()).\n\t\t *\/\n\t\tif (fd < 0 && errno == EACCES)\n\t\t\tfd = _wopen(wfilename, oflags & ~O_CREAT, mode);\n\t\tif (fd >= 0 && set_hidden_flag(wfilename, 1))\n\t\t\twarning(\"could not mark '%s' as hidden.\", filename);\n\t}\n\treturn fd;\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":134100,"func":"void ByteCodeGenerator::EnsureNoRedeclarations(ParseNode *pnodeBlock, FuncInfo *funcInfo)\n{\n    \/\/ Emit dynamic runtime checks for variable re-declarations. Only necessary for global functions (script or eval).\n    \/\/ In eval only var declarations can cause redeclaration, and only in non-strict mode, because let\/const variables\n    \/\/ remain local to the eval code.\n\n    Assert(pnodeBlock->nop == knopBlock);\n    Assert(pnodeBlock->sxBlock.blockType == PnodeBlockType::Global || pnodeBlock->sxBlock.scope->GetScopeType() == ScopeType_GlobalEvalBlock);\n\n    if (!(this->flags & fscrEvalCode))\n    {\n        IterateBlockScopedVariables(pnodeBlock, [this](ParseNode *pnode)\n        {\n            FuncInfo *funcInfo = this->TopFuncInfo();\n            Symbol *sym = pnode->sxVar.sym;\n\n            Assert(sym->GetIsGlobal());\n\n            Js::PropertyId propertyId = sym->EnsurePosition(this);\n\n            this->m_writer.ElementRootU(Js::OpCode::EnsureNoRootFld, funcInfo->FindOrAddReferencedPropertyId(propertyId));\n        });\n    }\n\n    for (ParseNode *pnode = funcInfo->root->sxFnc.pnodeVars; pnode; pnode = pnode->sxVar.pnodeNext)\n    {\n        Symbol* sym = pnode->sxVar.sym;\n\n        if (sym == nullptr || pnode->sxVar.isBlockScopeFncDeclVar)\n            continue;\n\n        if (sym->GetIsCatch() || (pnode->nop == knopVarDecl && sym->GetIsBlockVar()))\n        {\n            \/\/ The init node was bound to the catch object, because it's inside a catch and has the\n            \/\/ same name as the catch object. But we want to define a user var at function scope,\n            \/\/ so find the right symbol. (We'll still assign the RHS value to the catch object symbol.)\n            \/\/ This also applies to a var declaration in the same scope as a let declaration.\n\n            \/\/ Assert that catch cannot be at function scope and let and var at function scope is redeclaration error.\n            Assert(sym->GetIsCatch() || funcInfo->bodyScope != sym->GetScope());\n            sym = funcInfo->bodyScope->FindLocalSymbol(sym->GetName());\n            Assert(sym && !sym->GetIsCatch() && !sym->GetIsBlockVar());\n        }\n\n        Assert(sym->GetIsGlobal());\n\n        if (sym->GetSymbolType() == STVariable)\n        {\n            Js::PropertyId propertyId = sym->EnsurePosition(this);\n\n            if (this->flags & fscrEval)\n            {\n                if (!funcInfo->byteCodeFunction->GetIsStrictMode())\n                {\n                    this->m_writer.ScopedProperty(Js::OpCode::ScopedEnsureNoRedeclFld, ByteCodeGenerator::RootObjectRegister,\n                        funcInfo->FindOrAddReferencedPropertyId(propertyId));\n                }\n            }\n            else\n            {\n                this->m_writer.ElementRootU(Js::OpCode::EnsureNoRootRedeclFld, funcInfo->FindOrAddReferencedPropertyId(propertyId));\n            }\n        }\n    }\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":18857,"func":"REGRESSION_TEST ( SDK_API_DEBUG_NAME_LOOKUPS ) ( RegressionTest * test , int , int * pstatus ) {\n bool success = true ;\n const char state_name [ ] = \"INACTIVE_TIMEOUT\" ;\n const char hook_name [ ] = \"TS_HTTP_READ_RESPONSE_HDR_HOOK\" ;\n const char event_name [ ] = \"VC_EVENT_IMMEDIATE\" ;\n const char * str ;\n * pstatus = REGRESSION_TEST_INPROGRESS ;\n str = TSHttpServerStateNameLookup ( TS_SRVSTATE_INACTIVE_TIMEOUT ) ;\n if ( ( strlen ( str ) != strlen ( state_name ) || strcmp ( str , state_name ) ) ) {\n SDK_RPRINT ( test , \"TSHttpServerStateNameLookup\" , \"TestCase1\" , TC_FAIL , \"Failed on %d, expected %s, got %s\" , TS_SRVSTATE_INACTIVE_TIMEOUT , state_name , str ) ;\n success = false ;\n }\n else {\n SDK_RPRINT ( test , \"TSHttpServerStateNameLookup\" , \"TestCase1\" , TC_PASS , \"ok\" ) ;\n }\n str = TSHttpHookNameLookup ( TS_HTTP_READ_RESPONSE_HDR_HOOK ) ;\n if ( ( strlen ( str ) != strlen ( hook_name ) || strcmp ( str , hook_name ) ) ) {\n SDK_RPRINT ( test , \"TSHttpHookNameLookup\" , \"TestCase1\" , TC_FAIL , \"Failed on %d, expected %s, got %s\" , TS_HTTP_READ_RESPONSE_HDR_HOOK , hook_name , str ) ;\n success = false ;\n }\n else {\n SDK_RPRINT ( test , \"TSHttpHookNameLookup\" , \"TestCase1\" , TC_PASS , \"ok\" ) ;\n }\n str = TSHttpEventNameLookup ( TS_EVENT_IMMEDIATE ) ;\n if ( ( strlen ( str ) != strlen ( event_name ) || strcmp ( str , event_name ) ) ) {\n SDK_RPRINT ( test , \"TSHttpEventNameLookup\" , \"TestCase1\" , TC_FAIL , \"Failed on %d, expected %s, got %s\" , TS_EVENT_IMMEDIATE , hook_name , str ) ;\n success = false ;\n }\n else {\n SDK_RPRINT ( test , \"TSHttpEventNameLookup\" , \"TestCase1\" , TC_PASS , \"ok\" ) ;\n }\n * pstatus = success ? REGRESSION_TEST_PASSED : REGRESSION_TEST_FAILED ;\n return ;\n }","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":513579,"func":"uint16_t tls1_shared_group(SSL *s, int nmatch)\n{\n    const uint16_t *pref, *supp;\n    size_t num_pref, num_supp, i;\n    int k;\n\n    \/* Can't do anything on client side *\/\n    if (s->server == 0)\n        return 0;\n    if (nmatch == -2) {\n        if (tls1_suiteb(s)) {\n            \/*\n             * For Suite B ciphersuite determines curve: we already know\n             * these are acceptable due to previous checks.\n             *\/\n            unsigned long cid = s->s3.tmp.new_cipher->id;\n\n            if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)\n                return TLSEXT_curve_P_256;\n            if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)\n                return TLSEXT_curve_P_384;\n            \/* Should never happen *\/\n            return 0;\n        }\n        \/* If not Suite B just return first preference shared curve *\/\n        nmatch = 0;\n    }\n    \/*\n     * If server preference set, our groups are the preference order\n     * otherwise peer decides.\n     *\/\n    if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) {\n        tls1_get_supported_groups(s, &pref, &num_pref);\n        tls1_get_peer_groups(s, &supp, &num_supp);\n    } else {\n        tls1_get_peer_groups(s, &pref, &num_pref);\n        tls1_get_supported_groups(s, &supp, &num_supp);\n    }\n\n    for (k = 0, i = 0; i < num_pref; i++) {\n        uint16_t id = pref[i];\n\n        if (!tls1_in_list(id, supp, num_supp)\n            || !tls_group_allowed(s, id, SSL_SECOP_CURVE_SHARED))\n                    continue;\n        if (nmatch == k)\n            return id;\n         k++;\n    }\n    if (nmatch == -1)\n        return k;\n    \/* Out of range (nmatch > k). *\/\n    return 0;\n}","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":138150,"func":"static void icmp_timestamp(struct sk_buff *skb)\n{\n\tstruct timespec tv;\n\tstruct icmp_bxm icmp_param;\n\t\/*\n\t *\tToo short.\n\t *\/\n\tif (skb->len < 4)\n\t\tgoto out_err;\n\n\t\/*\n\t *\tFill in the current time as ms since midnight UT:\n\t *\/\n\tgetnstimeofday(&tv);\n\ticmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC +\n\t\t\t\t\t tv.tv_nsec \/ NSEC_PER_MSEC);\n\ticmp_param.data.times[2] = icmp_param.data.times[1];\n\tif (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))\n\t\tBUG();\n\ticmp_param.data.icmph\t   = *icmp_hdr(skb);\n\ticmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;\n\ticmp_param.data.icmph.code = 0;\n\ticmp_param.skb\t\t   = skb;\n\ticmp_param.offset\t   = 0;\n\ticmp_param.data_len\t   = 0;\n\ticmp_param.head_len\t   = sizeof(struct icmphdr) + 12;\n\ticmp_reply(&icmp_param, skb);\nout:\n\treturn;\nout_err:\n\tICMP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), ICMP_MIB_INERRORS);\n\tgoto out;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":152412,"func":"get_scriptlocal_funcname(char_u *funcname)\n{\n    char\tsid_buf[25];\n    int\t\toff;\n    char_u\t*newname;\n    char_u\t*p = funcname;\n\n    if (funcname == NULL)\n\treturn NULL;\n\n    if (STRNCMP(funcname, \"s:\", 2) != 0\n\t\t&& STRNCMP(funcname, \"<SID>\", 5) != 0)\n    {\n\tufunc_T\t    *ufunc;\n\n\t\/\/ The function name does not have a script-local prefix.  Try finding\n\t\/\/ it when in a Vim9 script and there is no \"g:\" prefix.\n\tif (!in_vim9script() || STRNCMP(funcname, \"g:\", 2) == 0)\n\t    return NULL;\n\tufunc = find_func(funcname, FALSE);\n\tif (ufunc == NULL || func_is_global(ufunc)\n\t\t\t      || (p = vim_strchr(ufunc->uf_name, '_')) == NULL)\n\t    return NULL;\n\t++p;\n\toff = 0;\n    }\n    else\n\toff = *funcname == 's' ? 2 : 5;\n\n    if (!SCRIPT_ID_VALID(current_sctx.sc_sid))\n    {\n\temsg(_(e_using_sid_not_in_script_context));\n\treturn NULL;\n    }\n    \/\/ Expand s: prefix into <SNR>nr_<name>\n    vim_snprintf(sid_buf, sizeof(sid_buf), \"<SNR>%ld_\",\n\t    (long)current_sctx.sc_sid);\n    newname = alloc(STRLEN(sid_buf) + STRLEN(p + off) + 1);\n    if (newname == NULL)\n\treturn NULL;\n    STRCPY(newname, sid_buf);\n    STRCAT(newname, p + off);\n\n    return newname;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":84374,"func":"void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,\n\t\t   struct pt_regs *regs, struct hlist_head *head, int rctx,\n\t\t   struct task_struct *task)\n{\n\tstruct perf_sample_data data;\n\tstruct perf_event *event;\n\n\tstruct perf_raw_record raw = {\n\t\t.frag = {\n\t\t\t.size = entry_size,\n\t\t\t.data = record,\n\t\t},\n\t};\n\n\tperf_sample_data_init(&data, 0, 0);\n\tdata.raw = &raw;\n\n\tperf_trace_buf_update(record, event_type);\n\n\thlist_for_each_entry_rcu(event, head, hlist_entry) {\n\t\tif (perf_tp_event_match(event, &data, regs))\n\t\t\tperf_swevent_event(event, count, &data, regs);\n\t}\n\n\t\/*\n\t * If we got specified a target task, also iterate its context and\n\t * deliver this event there too.\n\t *\/\n\tif (task && task != current) {\n\t\tstruct perf_event_context *ctx;\n\t\tstruct trace_entry *entry = record;\n\n\t\trcu_read_lock();\n\t\tctx = rcu_dereference(task->perf_event_ctxp[perf_sw_context]);\n\t\tif (!ctx)\n\t\t\tgoto unlock;\n\n\t\tlist_for_each_entry_rcu(event, &ctx->event_list, event_entry) {\n\t\t\tif (event->attr.type != PERF_TYPE_TRACEPOINT)\n\t\t\t\tcontinue;\n\t\t\tif (event->attr.config != entry->type)\n\t\t\t\tcontinue;\n\t\t\tif (perf_tp_event_match(event, &data, regs))\n\t\t\t\tperf_swevent_event(event, count, &data, regs);\n\t\t}\nunlock:\n\t\trcu_read_unlock();\n\t}\n\n\tperf_swevent_put_recursion_context(rctx);\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":387943,"func":"png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_bytep rp_end = row + bpp;\n\n   \/* Process the first pixel in the row completely (this is the same as 'up'\n    * because there is only one candidate predictor for the first row).\n    *\/\n   while (row < rp_end)\n   {\n      int a = *row + *prev_row++;\n      *row++ = (png_byte)a;\n   }\n\n   \/* Remainder *\/\n   rp_end += row_info->rowbytes - bpp;\n\n   while (row < rp_end)\n   {\n      int a, b, c, pa, pb, pc, p;\n\n      c = *(prev_row - bpp);\n      a = *(row - bpp);\n      b = *prev_row++;\n\n      p = b - c;\n      pc = a - c;\n\n#ifdef PNG_USE_ABS\n      pa = abs(p);\n      pb = abs(pc);\n      pc = abs(p + pc);\n#else\n      pa = p < 0 ? -p : p;\n      pb = pc < 0 ? -pc : pc;\n      pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n\n      if (pb < pa) pa = pb, a = b;\n      if (pc < pa) a = c;\n\n      a += *row;\n      *row++ = (png_byte)a;\n   }\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":48358,"func":"void nl80211_send_roamed(struct cfg80211_registered_device *rdev,\n\t\t\t struct net_device *netdev,\n\t\t\t struct cfg80211_roam_info *info, gfp_t gfp)\n{\n\tstruct sk_buff *msg;\n\tvoid *hdr;\n\tconst u8 *bssid = info->bss ? info->bss->bssid : info->bssid;\n\n\tmsg = nlmsg_new(100 + info->req_ie_len + info->resp_ie_len +\n\t\t\tinfo->fils.kek_len + info->fils.pmk_len +\n\t\t\t(info->fils.pmkid ? WLAN_PMKID_LEN : 0), gfp);\n\tif (!msg)\n\t\treturn;\n\n\thdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_ROAM);\n\tif (!hdr) {\n\t\tnlmsg_free(msg);\n\t\treturn;\n\t}\n\n\tif (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||\n\t    nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||\n\t    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid) ||\n\t    (info->req_ie &&\n\t     nla_put(msg, NL80211_ATTR_REQ_IE, info->req_ie_len,\n\t\t     info->req_ie)) ||\n\t    (info->resp_ie &&\n\t     nla_put(msg, NL80211_ATTR_RESP_IE, info->resp_ie_len,\n\t\t     info->resp_ie)) ||\n\t    (info->fils.update_erp_next_seq_num &&\n\t     nla_put_u16(msg, NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM,\n\t\t\t info->fils.erp_next_seq_num)) ||\n\t    (info->fils.kek &&\n\t     nla_put(msg, NL80211_ATTR_FILS_KEK, info->fils.kek_len,\n\t\t     info->fils.kek)) ||\n\t    (info->fils.pmk &&\n\t     nla_put(msg, NL80211_ATTR_PMK, info->fils.pmk_len, info->fils.pmk)) ||\n\t    (info->fils.pmkid &&\n\t     nla_put(msg, NL80211_ATTR_PMKID, WLAN_PMKID_LEN, info->fils.pmkid)))\n\t\tgoto nla_put_failure;\n\n\tgenlmsg_end(msg, hdr);\n\n\tgenlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,\n\t\t\t\tNL80211_MCGRP_MLME, gfp);\n\treturn;\n\n nla_put_failure:\n\tnlmsg_free(msg);\n}","target":0,"code_token_length":610,"total_token_length":846,"max_tokens_setting":1024}
+{"idx":402985,"func":"void t_cpp_generator::generate_struct_result_writer(ofstream& out,\n                                                    t_struct* tstruct,\n                                                    bool pointers) {\n  string name = tstruct->get_name();\n  const vector<t_field*>& fields = tstruct->get_sorted_members();\n  vector<t_field*>::const_iterator f_iter;\n\n  if (gen_templates_) {\n    out << indent() << \"template <class Protocol_>\" << endl << indent() << \"uint32_t \"\n        << tstruct->get_name() << \"::write(Protocol_* oprot) const {\" << endl;\n  } else {\n    indent(out) << \"uint32_t \" << tstruct->get_name()\n                << \"::write(::apache::thrift::protocol::TProtocol* oprot) const {\" << endl;\n  }\n  indent_up();\n\n  out << endl << indent() << \"uint32_t xfer = 0;\" << endl << endl;\n\n  indent(out) << \"xfer += oprot->writeStructBegin(\\\"\" << name << \"\\\");\" << endl;\n\n  bool first = true;\n  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\n    if (first) {\n      first = false;\n      out << endl << indent() << \"if \";\n    } else {\n      out << \" else if \";\n    }\n\n    out << \"(this->__isset.\" << (*f_iter)->get_name() << \") {\" << endl;\n\n    indent_up();\n\n    \/\/ Write field header\n    out << indent() << \"xfer += oprot->writeFieldBegin(\"\n        << \"\\\"\" << (*f_iter)->get_name() << \"\\\", \" << type_to_enum((*f_iter)->get_type()) << \", \"\n        << (*f_iter)->get_key() << \");\" << endl;\n    \/\/ Write field contents\n    if (pointers) {\n      generate_serialize_field(out, *f_iter, \"(*(this->\", \"))\");\n    } else {\n      generate_serialize_field(out, *f_iter, \"this->\");\n    }\n    \/\/ Write field closer\n    indent(out) << \"xfer += oprot->writeFieldEnd();\" << endl;\n\n    indent_down();\n    indent(out) << \"}\";\n  }\n\n  \/\/ Write the struct map\n  out << endl << indent() << \"xfer += oprot->writeFieldStop();\" << endl << indent()\n      << \"xfer += oprot->writeStructEnd();\" << endl << indent() << \"return xfer;\" << endl;\n\n  indent_down();\n  indent(out) << \"}\" << endl << endl;\n}","target":0,"code_token_length":531,"total_token_length":767,"max_tokens_setting":1024}
+{"idx":494852,"func":"static void emit_dependencies(StrList *list)\n{\n    FILE *deps;\n    int linepos, len;\n    StrList *l, *nl;\n    bool wmake = (quote_for_make == quote_for_wmake);\n    const char *wrapstr, *nulltarget;\n\n    wrapstr = wmake ? \" &\\n \" : \" \\\\\\n \";\n    nulltarget = wmake ? \"\\t%null\\n\" : \"\";\n\n    if (depend_file && strcmp(depend_file, \"-\")) {\n        deps = nasm_open_write(depend_file, NF_TEXT);\n        if (!deps) {\n            nasm_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,\n                       \"unable to write dependency file `%s'\", depend_file);\n            return;\n        }\n    } else {\n        deps = stdout;\n    }\n\n    linepos = fprintf(deps, \"%s :\", depend_target);\n    list_for_each(l, list) {\n        char *file = quote_for_make(l->str);\n        len = strlen(file);\n        if (linepos + len > 62 && linepos > 1) {\n            fputs(wrapstr, deps);\n            linepos = 1;\n        }\n        fprintf(deps, \" %s\", file);\n        linepos += len+1;\n        nasm_free(file);\n    }\n    fprintf(deps, \"\\n\\n\");\n\n    list_for_each_safe(l, nl, list) {\n        if (depend_emit_phony) {\n            char *file = quote_for_make(l->str);\n            fprintf(deps, \"%s :\\n%s\\n\", file, nulltarget);\n            nasm_free(file);\n        }\n        nasm_free(l);\n    }\n\n    if (deps != stdout)\n        fclose(deps);\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":324506,"func":"static void init_proc_750cx (CPUPPCState *env)\n\n{\n\n    gen_spr_ne_601(env);\n\n    gen_spr_7xx(env);\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_L2CR, \"L2CR\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, NULL,\n\n                 0x00000000);\n\n    \/* Time base *\/\n\n    gen_tbl(env);\n\n    \/* Thermal management *\/\n\n    gen_spr_thrm(env);\n\n    \/* This register is not implemented but is present for compatibility *\/\n\n    spr_register(env, SPR_SDA, \"SDA\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* Hardware implementation registers *\/\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_HID0, \"HID0\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* XXX : not implemented *\/\n\n    spr_register(env, SPR_HID1, \"HID1\",\n\n                 SPR_NOACCESS, SPR_NOACCESS,\n\n                 &spr_read_generic, &spr_write_generic,\n\n                 0x00000000);\n\n    \/* Memory management *\/\n\n    gen_low_BATs(env);\n\n    \/* PowerPC 750cx has 8 DBATs and 8 IBATs *\/\n\n    gen_high_BATs(env);\n\n    init_excp_750cx(env);\n\n    env->dcache_line_size = 32;\n\n    env->icache_line_size = 32;\n\n    \/* Allocate hardware IRQ controller *\/\n\n    ppc6xx_irq_init(env);\n\n}\n","target":1,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":414064,"func":"int wmi_addba_rx_resp(struct wil6210_priv *wil, u8 cid, u8 tid, u8 token,\n\t\t      u16 status, bool amsdu, u16 agg_wsize, u16 timeout)\n{\n\tint rc;\n\tstruct wmi_rcp_addba_resp_cmd cmd = {\n\t\t.cidxtid = mk_cidxtid(cid, tid),\n\t\t.dialog_token = token,\n\t\t.status_code = cpu_to_le16(status),\n\t\t\/* bit 0: A-MSDU supported\n\t\t * bit 1: policy (should be 0 for us)\n\t\t * bits 2..5: TID\n\t\t * bits 6..15: buffer size\n\t\t *\/\n\t\t.ba_param_set = cpu_to_le16((amsdu ? 1 : 0) | (tid << 2) |\n\t\t\t\t\t    (agg_wsize << 6)),\n\t\t.ba_timeout = cpu_to_le16(timeout),\n\t};\n\tstruct {\n\t\tstruct wmi_cmd_hdr wmi;\n\t\tstruct wmi_rcp_addba_resp_sent_event evt;\n\t} __packed reply;\n\n\twil_dbg_wmi(wil,\n\t\t    \"ADDBA response for CID %d TID %d size %d timeout %d status %d AMSDU%s\\n\",\n\t\t    cid, tid, agg_wsize, timeout, status, amsdu ? \"+\" : \"-\");\n\n\trc = wmi_call(wil, WMI_RCP_ADDBA_RESP_CMDID, &cmd, sizeof(cmd),\n\t\t      WMI_RCP_ADDBA_RESP_SENT_EVENTID, &reply, sizeof(reply),\n\t\t      100);\n\tif (rc)\n\t\treturn rc;\n\n\tif (reply.evt.status) {\n\t\twil_err(wil, \"ADDBA response failed with status %d\\n\",\n\t\t\tle16_to_cpu(reply.evt.status));\n\t\trc = -EINVAL;\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":281962,"func":"status_t CameraService::connectDevice(\n const sp<ICameraDeviceCallbacks>& cameraCb,\n int cameraId,\n const String16& clientPackageName,\n int clientUid,\n \/*out*\/\n        sp<ICameraDeviceUser>& device)\n{\n\n String8 clientName8(clientPackageName);\n int callingPid = getCallingPid();\n\n    LOG1(\"CameraService::connectDevice E (pid %d \\\"%s\\\", id %d)\", callingPid,\n            clientName8.string(), cameraId);\n\n status_t status = validateConnect(cameraId, \/*inout*\/clientUid);\n if (status != OK) {\n return status;\n }\n\n    sp<CameraDeviceClient> client;\n {\n Mutex::Autolock lock(mServiceLock);\n {\n            sp<BasicClient> client;\n if (!canConnectUnsafe(cameraId, clientPackageName,\n                                  cameraCb->asBinder(),\n \/*out*\/client)) {\n return -EBUSY;\n }\n }\n\n int facing = -1;\n int deviceVersion = getDeviceVersion(cameraId, &facing);\n\n if (isValidCameraId(cameraId)) {\n            updateStatus(ICameraServiceListener::STATUS_NOT_AVAILABLE,\n                         cameraId);\n }\n\n switch(deviceVersion) {\n case CAMERA_DEVICE_API_VERSION_1_0:\n            ALOGW(\"Camera using old HAL version: %d\", deviceVersion);\n return -EOPNOTSUPP;\n case CAMERA_DEVICE_API_VERSION_2_0:\n case CAMERA_DEVICE_API_VERSION_2_1:\n case CAMERA_DEVICE_API_VERSION_3_0:\n            client = new CameraDeviceClient(this, cameraCb, clientPackageName,\n                    cameraId, facing, callingPid, clientUid, getpid());\n break;\n case -1:\n            ALOGE(\"Invalid camera id %d\", cameraId);\n return BAD_VALUE;\n default:\n            ALOGE(\"Unknown camera device HAL version: %d\", deviceVersion);\n return INVALID_OPERATION;\n }\n\n status_t status = connectFinishUnsafe(client, client->getRemote());\n if (status != OK) {\n            updateStatus(ICameraServiceListener::STATUS_PRESENT, cameraId);\n return status;\n }\n\n        LOG1(\"CameraService::connectDevice X (id %d, this pid is %d)\", cameraId,\n                getpid());\n\n        mClient[cameraId] = client;\n }\n\n    device = client;\n return OK;\n}\n","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":137129,"func":"Jsi_RC Jsi_InitMySql(Jsi_Interp *interp, int release)\n{\n    if (release) {\n        if (!--mydbObjCmd.init)\n            mysql_library_end();\n        return Jsi_DoneMySql(interp);\n    }\n    Jsi_Hash* dbSys;\n#if JSI_USE_STUBS\n  if (Jsi_StubsInit(interp, 0) != JSI_OK)\n    return JSI_ERROR;\n#endif\n#ifndef JSI_OMIT_THREADS\n    if (mydbObjCmd.init == 0 && mysql_library_init(0, NULL, NULL))\n        return Jsi_LogError(\"failed to initialize MySQL library\\n\");\n#else\n    return Jsi_LogError(\"Threads required for mysql\");\n#endif\n\n    Jsi_Value *info = Jsi_ValueNew1(interp);\n    Jsi_JSONParseFmt(interp, &info, \"{pkgVer:%d}\", MYSQL_VERSION_ID);\n    Jsi_PkgOpts dbPkgOpts = { mydb_ObjCmd_Specs, &mydbObjCmd, mysqlCmds, info};\n    Jsi_RC rc = Jsi_PkgProvideEx(interp, \"MySql\", 1.1, Jsi_InitMySql, &dbPkgOpts);\n    Jsi_DecrRefCount(interp, info);\n    if (rc != JSI_OK)\n        rc = JSI_ERROR;\n    else if (!(dbSys = Jsi_UserObjRegister(interp, &mysqlobject))) \n        rc = Jsi_LogError(\"Failed to init mysql extension\");\n    else if (!Jsi_CommandCreateSpecs(interp, mysqlobject.name, mysqlCmds, dbSys, JSI_CMDSPEC_ISOBJ))\n        rc = JSI_ERROR;\n    if (rc == JSI_OK)\n        mydbObjCmd.init++;\n    else\n        mysql_library_end();\n    return rc;\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":479798,"func":"    CImg<T>& HSLtoRGB() {\n      if (_spectrum!=3)\n        throw CImgInstanceException(_cimg_instance\n                                    \"HSLtoRGB(): Instance is not a HSL image.\",\n                                    cimg_instance);\n\n      T *p1 = data(0,0,0,0), *p2 = data(0,0,0,1), *p3 = data(0,0,0,2);\n      const longT whd = (longT)width()*height()*depth();\n      cimg_pragma_openmp(parallel for cimg_openmp_if_size(whd,256))\n      for (longT N = 0; N<whd; ++N) {\n        const Tfloat\n          H = cimg::mod((Tfloat)p1[N]\/60,(Tfloat)6),\n          S = (Tfloat)p2[N],\n          L = (Tfloat)p3[N],\n          C = (1 - cimg::abs(2*L - 1))*S,\n          X = C*(1 - cimg::abs(cimg::mod(H,(Tfloat)2) - 1)),\n          m = L - C\/2;\n        Tfloat R, G, B;\n        switch ((int)H) {\n        case 0 : R = C; G = X; B = 0; break;\n        case 1 : R = X; G = C; B = 0; break;\n        case 2 : R = 0; G = C; B = X; break;\n        case 3 : R = 0; G = X; B = C; break;\n        case 4 : R = X; G = 0; B = C; break;\n        default : R = C; G = 0; B = X;\n        }\n        p1[N] = (T)((R + m)*255);\n        p2[N] = (T)((G + m)*255);\n        p3[N] = (T)((B + m)*255);\n      }\n      return *this;\n    }","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":34728,"func":"static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count,\n\t\t\t\t\t\tnodemask_t *nodes_allowed)\n{\n\tunsigned long min_count, ret;\n\n\tif (h->order >= MAX_ORDER)\n\t\treturn h->max_huge_pages;\n\n\t\/*\n\t * Increase the pool size\n\t * First take pages out of surplus state.  Then make up the\n\t * remaining difference by allocating fresh huge pages.\n\t *\n\t * We might race with alloc_buddy_huge_page() here and be unable\n\t * to convert a surplus huge page to a normal huge page. That is\n\t * not critical, though, it just means the overall size of the\n\t * pool might be one hugepage larger than it needs to be, but\n\t * within all the constraints specified by the sysctls.\n\t *\/\n\tspin_lock(&hugetlb_lock);\n\twhile (h->surplus_huge_pages && count > persistent_huge_pages(h)) {\n\t\tif (!adjust_pool_surplus(h, nodes_allowed, -1))\n\t\t\tbreak;\n\t}\n\n\twhile (count > persistent_huge_pages(h)) {\n\t\t\/*\n\t\t * If this allocation races such that we no longer need the\n\t\t * page, free_huge_page will handle it by freeing the page\n\t\t * and reducing the surplus.\n\t\t *\/\n\t\tspin_unlock(&hugetlb_lock);\n\t\tret = alloc_fresh_huge_page(h, nodes_allowed);\n\t\tspin_lock(&hugetlb_lock);\n\t\tif (!ret)\n\t\t\tgoto out;\n\n\t\t\/* Bail for signals. Probably ctrl-c from user *\/\n\t\tif (signal_pending(current))\n\t\t\tgoto out;\n\t}\n\n\t\/*\n\t * Decrease the pool size\n\t * First return free pages to the buddy allocator (being careful\n\t * to keep enough around to satisfy reservations).  Then place\n\t * pages into surplus state as needed so the pool will shrink\n\t * to the desired size as pages become free.\n\t *\n\t * By placing pages into the surplus state independent of the\n\t * overcommit value, we are allowing the surplus pool size to\n\t * exceed overcommit. There are few sane options here. Since\n\t * alloc_buddy_huge_page() is checking the global counter,\n\t * though, we'll note that we're not allowed to exceed surplus\n\t * and won't grow the pool anywhere else. Not until one of the\n\t * sysctls are changed, or the surplus pages go out of use.\n\t *\/\n\tmin_count = h->resv_huge_pages + h->nr_huge_pages - h->free_huge_pages;\n\tmin_count = max(count, min_count);\n\ttry_to_free_low(h, min_count, nodes_allowed);\n\twhile (min_count < persistent_huge_pages(h)) {\n\t\tif (!free_pool_huge_page(h, nodes_allowed, 0))\n\t\t\tbreak;\n\t}\n\twhile (count < persistent_huge_pages(h)) {\n\t\tif (!adjust_pool_surplus(h, nodes_allowed, 1))\n\t\t\tbreak;\n\t}\nout:\n\tret = persistent_huge_pages(h);\n\tspin_unlock(&hugetlb_lock);\n\treturn ret;\n}","target":0,"code_token_length":647,"total_token_length":883,"max_tokens_setting":1024}
+{"idx":394018,"func":"try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)\n{\n\tunsigned long flags;\n\tint cpu, success = 0;\n\n\t\/*\n\t * If we are going to wake up a thread waiting for CONDITION we\n\t * need to ensure that CONDITION=1 done by the caller can not be\n\t * reordered with p->state check below. This pairs with mb() in\n\t * set_current_state() the waiting thread does.\n\t *\/\n\tsmp_mb__before_spinlock();\n\traw_spin_lock_irqsave(&p->pi_lock, flags);\n\tif (!(p->state & state))\n\t\tgoto out;\n\n\ttrace_sched_waking(p);\n\n\tsuccess = 1; \/* we're going to change ->state *\/\n\tcpu = task_cpu(p);\n\n\tif (p->on_rq && ttwu_remote(p, wake_flags))\n\t\tgoto stat;\n\n#ifdef CONFIG_SMP\n\t\/*\n\t * Ensure we load p->on_cpu _after_ p->on_rq, otherwise it would be\n\t * possible to, falsely, observe p->on_cpu == 0.\n\t *\n\t * One must be running (->on_cpu == 1) in order to remove oneself\n\t * from the runqueue.\n\t *\n\t *  [S] ->on_cpu = 1;\t[L] ->on_rq\n\t *      UNLOCK rq->lock\n\t *\t\t\tRMB\n\t *      LOCK   rq->lock\n\t *  [S] ->on_rq = 0;    [L] ->on_cpu\n\t *\n\t * Pairs with the full barrier implied in the UNLOCK+LOCK on rq->lock\n\t * from the consecutive calls to schedule(); the first switching to our\n\t * task, the second putting it to sleep.\n\t *\/\n\tsmp_rmb();\n\n\t\/*\n\t * If the owning (remote) cpu is still in the middle of schedule() with\n\t * this task as prev, wait until its done referencing the task.\n\t *\n\t * Pairs with the smp_store_release() in finish_lock_switch().\n\t *\n\t * This ensures that tasks getting woken will be fully ordered against\n\t * their previous state and preserve Program Order.\n\t *\/\n\tsmp_cond_acquire(!p->on_cpu);\n\n\tp->sched_contributes_to_load = !!task_contributes_to_load(p);\n\tp->state = TASK_WAKING;\n\n\tif (p->sched_class->task_waking)\n\t\tp->sched_class->task_waking(p);\n\n\tcpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags);\n\tif (task_cpu(p) != cpu) {\n\t\twake_flags |= WF_MIGRATED;\n\t\tset_task_cpu(p, cpu);\n\t}\n#endif \/* CONFIG_SMP *\/\n\n\tttwu_queue(p, cpu);\nstat:\n\tif (schedstat_enabled())\n\t\tttwu_stat(p, cpu, wake_flags);\nout:\n\traw_spin_unlock_irqrestore(&p->pi_lock, flags);\n\n\treturn success;\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":83620,"func":"void usage() {\n\tprintf(\"This is nbd-server version \" VERSION \"\\n\");\n\tprintf(\"Usage: [ip:|ip6@]port file_to_export [size][kKmM] [-l authorize_file] [-r] [-m] [-c] [-C configuration file] [-p PID file name] [-o section name] [-M max connections]\\n\"\n\t       \"\\t-r|--read-only\\t\\tread only\\n\"\n\t       \"\\t-m|--multi-file\\t\\tmultiple file\\n\"\n\t       \"\\t-c|--copy-on-write\\tcopy on write\\n\"\n\t       \"\\t-C|--config-file\\tspecify an alternate configuration file\\n\"\n\t       \"\\t-l|--authorize-file\\tfile with list of hosts that are allowed to\\n\\t\\t\\t\\tconnect.\\n\"\n\t       \"\\t-p|--pid-file\\t\\tspecify a filename to write our PID to\\n\"\n\t       \"\\t-o|--output-config\\toutput a config file section for what you\\n\\t\\t\\t\\tspecified on the command line, with the\\n\\t\\t\\t\\tspecified section name\\n\"\n\t       \"\\t-M|--max-connections\\tspecify the maximum number of opened connections\\n\\n\"\n\t       \"\\tif port is set to 0, stdin is used (for running from inetd).\\n\"\n\t       \"\\tif file_to_export contains '%%s', it is substituted with the IP\\n\"\n\t       \"\\t\\taddress of the machine trying to connect\\n\" \n\t       \"\\tif ip is set, it contains the local IP address on which we're listening.\\n\\tif not, the server will listen on all local IP addresses\\n\");\n\tprintf(\"Using configuration file %s\\n\", CFILE);\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":57536,"func":"static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,\n\t\t       struct msqid_ds __user *buf, int version)\n{\n\tstruct kern_ipc_perm *ipcp;\n\tstruct msqid64_ds uninitialized_var(msqid64);\n\tstruct msg_queue *msq;\n\tint err;\n\n\tif (cmd == IPC_SET) {\n\t\tif (copy_msqid_from_user(&msqid64, buf, version))\n\t\t\treturn -EFAULT;\n\t}\n\n\tipcp = ipcctl_pre_down(ns, &msg_ids(ns), msqid, cmd,\n\t\t\t       &msqid64.msg_perm, msqid64.msg_qbytes);\n\tif (IS_ERR(ipcp))\n\t\treturn PTR_ERR(ipcp);\n\n\tmsq = container_of(ipcp, struct msg_queue, q_perm);\n\n\terr = security_msg_queue_msgctl(msq, cmd);\n\tif (err)\n\t\tgoto out_unlock;\n\n\tswitch (cmd) {\n\tcase IPC_RMID:\n\t\tfreeque(ns, ipcp);\n\t\tgoto out_up;\n\tcase IPC_SET:\n\t\tif (msqid64.msg_qbytes > ns->msg_ctlmnb &&\n\t\t    !capable(CAP_SYS_RESOURCE)) {\n\t\t\terr = -EPERM;\n\t\t\tgoto out_unlock;\n\t\t}\n\n\t\terr = ipc_update_perm(&msqid64.msg_perm, ipcp);\n\t\tif (err)\n\t\t\tgoto out_unlock;\n\n\t\tmsq->q_qbytes = msqid64.msg_qbytes;\n\n\t\tmsq->q_ctime = get_seconds();\n\t\t\/* sleeping receivers might be excluded by\n\t\t * stricter permissions.\n\t\t *\/\n\t\texpunge_all(msq, -EAGAIN);\n\t\t\/* sleeping senders might be able to send\n\t\t * due to a larger queue size.\n\t\t *\/\n\t\tss_wakeup(&msq->q_senders, 0);\n\t\tbreak;\n\tdefault:\n\t\terr = -EINVAL;\n\t}\nout_unlock:\n\tmsg_unlock(msq);\nout_up:\n\tup_write(&msg_ids(ns).rw_mutex);\n\treturn err;\n}","target":0,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":11297,"func":"static void ssl_check_for_safari(SSL *s, const unsigned char *data,\n                                 const unsigned char *limit)\n{\n    unsigned short type, size;\n    static const unsigned char kSafariExtensionsBlock[] = {\n        0x00, 0x0a,             \/* elliptic_curves extension *\/\n        0x00, 0x08,             \/* 8 bytes *\/\n        0x00, 0x06,             \/* 6 bytes of curve ids *\/\n        0x00, 0x17,             \/* P-256 *\/\n        0x00, 0x18,             \/* P-384 *\/\n        0x00, 0x19,             \/* P-521 *\/\n\n        0x00, 0x0b,             \/* ec_point_formats *\/\n        0x00, 0x02,             \/* 2 bytes *\/\n        0x01,                   \/* 1 point format *\/\n        0x00,                   \/* uncompressed *\/\n    };\n\n    \/* The following is only present in TLS 1.2 *\/\n    static const unsigned char kSafariTLS12ExtensionsBlock[] = {\n        0x00, 0x0d,             \/* signature_algorithms *\/\n        0x00, 0x0c,             \/* 12 bytes *\/\n        0x00, 0x0a,             \/* 10 bytes *\/\n        0x05, 0x01,             \/* SHA-384\/RSA *\/\n        0x04, 0x01,             \/* SHA-256\/RSA *\/\n        0x02, 0x01,             \/* SHA-1\/RSA *\/\n        0x04, 0x03,             \/* SHA-256\/ECDSA *\/\n         0x02, 0x03,             \/* SHA-1\/ECDSA *\/\n     };\n \n    if (data >= (limit - 2))\n         return;\n     data += 2;\n \n    if (data > (limit - 4))\n         return;\n     n2s(data, type);\n     n2s(data, size);\n\n     if (type != TLSEXT_TYPE_server_name)\n         return;\n \n    if (data + size > limit)\n         return;\n     data += size;\n \n    if (TLS1_get_client_version(s) >= TLS1_2_VERSION) {\n         const size_t len1 = sizeof(kSafariExtensionsBlock);\n         const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock);\n \n        if (data + len1 + len2 != limit)\n             return;\n         if (memcmp(data, kSafariExtensionsBlock, len1) != 0)\n             return;\n        if (memcmp(data + len1, kSafariTLS12ExtensionsBlock, len2) != 0)\n            return;\n     } else {\n         const size_t len = sizeof(kSafariExtensionsBlock);\n \n        if (data + len != limit)\n             return;\n         if (memcmp(data, kSafariExtensionsBlock, len) != 0)\n             return;\n    }\n\n    s->s3->is_probably_safari = 1;\n}\n","target":1,"code_token_length":711,"total_token_length":947,"max_tokens_setting":1024}
+{"idx":163305,"func":"static void stroke_add_conn(private_stroke_socket_t *this, stroke_msg_t *msg)\n{\n\tpop_string(msg, &msg->add_conn.name);\n\tDBG1(DBG_CFG, \"received stroke: add connection '%s'\", msg->add_conn.name);\n\n\tDBG2(DBG_CFG, \"conn %s\", msg->add_conn.name);\n\tpop_end(msg, \"left\", &msg->add_conn.me);\n\tpop_end(msg, \"right\", &msg->add_conn.other);\n\tpop_string(msg, &msg->add_conn.eap_identity);\n\tpop_string(msg, &msg->add_conn.aaa_identity);\n\tpop_string(msg, &msg->add_conn.xauth_identity);\n\tpop_string(msg, &msg->add_conn.algorithms.ike);\n\tpop_string(msg, &msg->add_conn.algorithms.esp);\n\tpop_string(msg, &msg->add_conn.algorithms.ah);\n\tpop_string(msg, &msg->add_conn.ikeme.mediated_by);\n\tpop_string(msg, &msg->add_conn.ikeme.peerid);\n\tDBG_OPT(\"  eap_identity=%s\", msg->add_conn.eap_identity);\n\tDBG_OPT(\"  aaa_identity=%s\", msg->add_conn.aaa_identity);\n\tDBG_OPT(\"  xauth_identity=%s\", msg->add_conn.xauth_identity);\n\tDBG_OPT(\"  ike=%s\", msg->add_conn.algorithms.ike);\n\tDBG_OPT(\"  esp=%s\", msg->add_conn.algorithms.esp);\n\tDBG_OPT(\"  ah=%s\", msg->add_conn.algorithms.ah);\n\tDBG_OPT(\"  dpddelay=%d\", msg->add_conn.dpd.delay);\n\tDBG_OPT(\"  dpdtimeout=%d\", msg->add_conn.dpd.timeout);\n\tDBG_OPT(\"  dpdaction=%d\", msg->add_conn.dpd.action);\n\tDBG_OPT(\"  closeaction=%d\", msg->add_conn.close_action);\n\tDBG_OPT(\"  sha256_96=%s\", msg->add_conn.sha256_96 ? \"yes\" : \"no\");\n\tDBG_OPT(\"  mediation=%s\", msg->add_conn.ikeme.mediation ? \"yes\" : \"no\");\n\tDBG_OPT(\"  mediated_by=%s\", msg->add_conn.ikeme.mediated_by);\n\tDBG_OPT(\"  me_peerid=%s\", msg->add_conn.ikeme.peerid);\n\tDBG_OPT(\"  keyexchange=ikev%u\", msg->add_conn.version);\n\n\tthis->config->add(this->config, msg);\n\tthis->attribute->add_dns(this->attribute, msg);\n\tthis->handler->add_attributes(this->handler, msg);\n}\n","target":0,"code_token_length":532,"total_token_length":768,"max_tokens_setting":1024}
+{"idx":110201,"func":"static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,\n\t\t\t    int rotate, unsigned int num)\n{\n\tunsigned int x;\n\n\tif (rotate == FB_ROTATE_UR) {\n\t\tfor (x = 0;\n\t\t     x < num && image->dx + image->width <= info->var.xres;\n\t\t     x++) {\n\t\t\tinfo->fbops->fb_imageblit(info, image);\n\t\t\timage->dx += image->width + 8;\n\t\t}\n\t} else if (rotate == FB_ROTATE_UD) {\n\t\tfor (x = 0; x < num && image->dx >= 0; x++) {\n\t\t\tinfo->fbops->fb_imageblit(info, image);\n\t\t\timage->dx -= image->width + 8;\n\t\t}\n\t} else if (rotate == FB_ROTATE_CW) {\n\t\tfor (x = 0;\n\t\t     x < num && image->dy + image->height <= info->var.yres;\n\t\t     x++) {\n\t\t\tinfo->fbops->fb_imageblit(info, image);\n\t\t\timage->dy += image->height + 8;\n\t\t}\n\t} else if (rotate == FB_ROTATE_CCW) {\n\t\tfor (x = 0; x < num && image->dy >= 0; x++) {\n\t\t\tinfo->fbops->fb_imageblit(info, image);\n\t\t\timage->dy -= image->height + 8;\n\t\t}\n\t}\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":343271,"func":"static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,\n\n                               int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,\n\n                               uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)\n\n{\n\n    \/\/FIXME Optimize (just quickly writen not opti..)\n\n    int i;\n\n    for (i=0; i<dstW; i++)\n\n    {\n\n        int val=1<<18;\n\n        int j;\n\n        for (j=0; j<lumFilterSize; j++)\n\n            val += lumSrc[j][i] * lumFilter[j];\n\n\n\n        dest[i]= av_clip_uint8(val>>19);\n\n    }\n\n\n\n    if (uDest)\n\n        for (i=0; i<chrDstW; i++)\n\n        {\n\n            int u=1<<18;\n\n            int v=1<<18;\n\n            int j;\n\n            for (j=0; j<chrFilterSize; j++)\n\n            {\n\n                u += chrSrc[j][i] * chrFilter[j];\n\n                v += chrSrc[j][i + 2048] * chrFilter[j];\n\n            }\n\n\n\n            uDest[i]= av_clip_uint8(u>>19);\n\n            vDest[i]= av_clip_uint8(v>>19);\n\n        }\n\n}\n","target":1,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":429573,"func":"    std::string XPathIo::writeDataToFile(const std::string& orgPath) {\n        Protocol prot = fileProtocol(orgPath);\n\n        \/\/ generating the name for temp file.\n        std::time_t timestamp = std::time(NULL);\n        std::stringstream ss;\n        ss << timestamp << XPathIo::TEMP_FILE_EXT;\n        std::string path = ss.str();\n\n        if (prot == pStdin) {\n            if (isatty(fileno(stdin)))\n                throw Error(kerInputDataReadFailed);\n#if defined(_MSC_VER) || defined(__MINGW__)\n            \/\/ convert stdin to binary\n            if (_setmode(_fileno(stdin), _O_BINARY) == -1)\n                throw Error(kerInputDataReadFailed);\n#endif\n            std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);\n            \/\/ read stdin and write to the temp file.\n            char readBuf[100*1024];\n            std::streamsize readBufSize = 0;\n            do {\n                std::cin.read(readBuf, sizeof(readBuf));\n                readBufSize = std::cin.gcount();\n                if (readBufSize > 0) {\n                    fs.write (readBuf, readBufSize);\n                }\n            } while(readBufSize);\n            fs.close();\n        } else if (prot == pDataUri) {\n            std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);\n            \/\/ read data uri and write to the temp file.\n            size_t base64Pos = orgPath.find(\"base64,\");\n            if (base64Pos == std::string::npos) {\n                fs.close();\n                throw Error(kerErrorMessage, \"No base64 data\");\n            }\n\n            std::string data = orgPath.substr(base64Pos+7);\n            char* decodeData = new char[data.length()];\n            long size = base64decode(data.c_str(), decodeData, data.length());\n            if (size > 0) {\n                fs.write(decodeData, size);\n                fs.close();\n            } else {\n                fs.close();\n                throw Error(kerErrorMessage, \"Unable to decode base 64.\");\n            }\n            delete[] decodeData;\n        }\n\n        return path;\n    }","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":5854,"func":"R_API RBinJavaAttrInfo *r_bin_java_local_variable_type_table_attr_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaLocalVariableTypeAttribute *lvattr;\n\tut64 offset = 6;\n\tut32 i = 0;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (buffer, sz, 0);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_LOCAL_VARIABLE_TYPE_TABLE_ATTR;\n\tattr->info.local_variable_type_table_attr.table_length = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.local_variable_type_table_attr.local_variable_table = r_list_newf (r_bin_java_local_variable_type_table_attr_entry_free);\n\tfor (i = 0; i < attr->info.local_variable_type_table_attr.table_length; i++) {\n\t\tut64 curpos = buf_offset + offset;\n\t\tlvattr = R_NEW0 (RBinJavaLocalVariableTypeAttribute);\n\t\tif (!lvattr) {\n\t\t\tperror (\"calloc\");\n\t\t\tbreak;\n\t\t}\n\t\tlvattr->start_pc = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlvattr->length = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlvattr->name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlvattr->signature_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlvattr->index = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tlvattr->file_offset = curpos;\n\t\tlvattr->name = r_bin_java_get_utf8_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, lvattr->name_idx);\n\t\tlvattr->size = 10;\n\t\tif (!lvattr->name) {\n\t\t\tlvattr->name = strdup (\"NULL\");\n\t\t\teprintf (\"r_bin_java_local_variable_type_table_attr_new: Unable to find the name for %d index.\\n\", lvattr->name_idx);\n\t\t}\n\t\tlvattr->signature = r_bin_java_get_utf8_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, lvattr->signature_idx);\n\t\tif (!lvattr->signature) {\n\t\t\tlvattr->signature = strdup (\"NULL\");\n\t\t\teprintf (\"r_bin_java_local_variable_type_table_attr_new: Unable to find the descriptor for %d index.\\n\", lvattr->signature_idx);\n\t\t}\n\t\tr_list_append (attr->info.local_variable_type_table_attr.local_variable_table, lvattr);\n\t}\n\t\/\/ IFDBG r_bin_java_print_local_variable_type_table_attr_summary(attr);\n\tattr->size = offset;\n\treturn attr;\n}","target":1,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":495477,"func":"njs_string_prototype_char_code_at(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    double                num;\n    size_t                length;\n    int64_t               index;\n    uint32_t              code;\n    njs_int_t             ret;\n    const u_char          *start, *end;\n    njs_string_prop_t     string;\n    njs_unicode_decode_t  ctx;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = njs_string_prop(&string, njs_argument(args, 0));\n\n    ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &index);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_slow_path(index < 0 || index >= (int64_t) length)) {\n        num = NAN;\n        goto done;\n    }\n\n    if (length == string.size) {\n        \/* Byte or ASCII string. *\/\n        code = string.start[index];\n\n    } else {\n        njs_utf8_decode_init(&ctx);\n\n        \/* UTF-8 string. *\/\n        end = string.start + string.size;\n        start = njs_string_offset(string.start, end, index);\n        code = njs_utf8_decode(&ctx, &start, end);\n    }\n\n    num = code;\n\ndone:\n\n    njs_set_number(&vm->retval, num);\n\n    return NJS_OK;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":412521,"func":"pk_transaction_install_signature (PkTransaction *transaction,\n\t\t\t\t  GVariant *params,\n\t\t\t\t  GDBusMethodInvocation *context)\n{\n\tgboolean ret;\n\tconst gchar *key_id;\n\tconst gchar *package_id;\n\tPkSigTypeEnum sig_type;\n\tg_autoptr(GError) error = NULL;\n\n\tg_return_if_fail (PK_IS_TRANSACTION (transaction));\n\tg_return_if_fail (transaction->priv->tid != NULL);\n\n\tg_variant_get (params, \"(u&s&s)\",\n\t\t       &sig_type,\n\t\t       &key_id,\n\t\t       &package_id);\n\n\tg_debug (\"InstallSignature method called: %s, %s, %s\",\n\t\t pk_sig_type_enum_to_string (sig_type),\n\t\t key_id,\n\t\t package_id);\n\n\t\/* not implemented yet *\/\n\tif (!pk_backend_is_implemented (transaction->priv->backend,\n\t\t\t\t\tPK_ROLE_ENUM_INSTALL_SIGNATURE)) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_NOT_SUPPORTED,\n\t\t\t     \"InstallSignature not supported by backend\");\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* check for sanity *\/\n\tret = pk_transaction_strvalidate (key_id, &error);\n\tif (!ret) {\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* check package_id (';;;repo-id' is used for the repo key) *\/\n\tret = pk_package_id_check (package_id);\n\tif (!ret && !g_str_has_prefix (package_id, \";;;\")) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_PACKAGE_ID_INVALID,\n\t\t\t     \"The package id '%s' is not valid\", package_id);\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* save so we can run later *\/\n\ttransaction->priv->cached_package_id = g_strdup (package_id);\n\ttransaction->priv->cached_key_id = g_strdup (key_id);\n\tpk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_SIGNATURE);\n\n\t\/* try to get authorization *\/\n\tret = pk_transaction_obtain_authorization (transaction,\n\t\t\t\t\t\t   PK_ROLE_ENUM_INSTALL_SIGNATURE,\n\t\t\t\t\t\t   &error);\n\tif (!ret) {\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\nout:\n\tpk_transaction_dbus_return (context, error);\n}","target":0,"code_token_length":487,"total_token_length":723,"max_tokens_setting":1024}
+{"idx":411612,"func":"    **\/\n    CImg<T>& noise(const double sigma, const unsigned int noise_type=0) {\n      if (is_empty()) return *this;\n      const Tfloat vmin = (Tfloat)cimg::type<T>::min(), vmax = (Tfloat)cimg::type<T>::max();\n      Tfloat nsigma = (Tfloat)sigma, m = 0, M = 0;\n      if (nsigma==0 && noise_type!=3) return *this;\n      if (nsigma<0 || noise_type==2) m = (Tfloat)min_max(M);\n      if (nsigma<0) nsigma = (Tfloat)(-nsigma*(M-m)\/100.0);\n      switch (noise_type) {\n      case 0 : { \/\/ Gaussian noise\n        cimg_rof(*this,ptrd,T) {\n          Tfloat val = (Tfloat)(*ptrd + nsigma*cimg::grand());\n          if (val>vmax) val = vmax;\n          if (val<vmin) val = vmin;\n          *ptrd = (T)val;\n        }\n      } break;\n      case 1 : { \/\/ Uniform noise\n        cimg_rof(*this,ptrd,T) {\n          Tfloat val = (Tfloat)(*ptrd + nsigma*cimg::rand(-1,1));\n          if (val>vmax) val = vmax;\n          if (val<vmin) val = vmin;\n          *ptrd = (T)val;\n        }\n      } break;\n      case 2 : { \/\/ Salt & Pepper noise\n        if (nsigma<0) nsigma = -nsigma;\n        if (M==m) { m = 0; M = cimg::type<T>::is_float()?(Tfloat)1:(Tfloat)cimg::type<T>::max(); }\n        cimg_rof(*this,ptrd,T) if (cimg::rand(100)<nsigma) *ptrd = (T)(cimg::rand()<0.5?M:m);\n      } break;\n      case 3 : { \/\/ Poisson Noise\n        cimg_rof(*this,ptrd,T) *ptrd = (T)cimg::prand(*ptrd);\n      } break;\n      case 4 : { \/\/ Rice noise\n        const Tfloat sqrt2 = (Tfloat)std::sqrt(2.0);\n        cimg_rof(*this,ptrd,T) {\n          const Tfloat\n            val0 = (Tfloat)*ptrd\/sqrt2,\n            re = (Tfloat)(val0 + nsigma*cimg::grand()),\n            im = (Tfloat)(val0 + nsigma*cimg::grand());\n          Tfloat val = cimg::hypot(re,im);\n          if (val>vmax) val = vmax;\n          if (val<vmin) val = vmin;\n          *ptrd = (T)val;\n        }\n      } break;\n      default :\n        throw CImgArgumentException(_cimg_instance\n                                    \"noise(): Invalid specified noise type %d \"\n                                    \"(should be { 0=gaussian | 1=uniform | 2=salt&Pepper | 3=poisson }).\",\n                                    cimg_instance,\n                                    noise_type);\n      }\n      return *this;","target":0,"code_token_length":699,"total_token_length":935,"max_tokens_setting":1024}
+{"idx":81132,"func":"GF_Err gf_isom_set_audio_layout(GF_ISOFile *movie, u32 trackNumber, u32 sampleDescriptionIndex, GF_AudioChannelLayout *layout)\n{\n\tGF_Err e;\n\tGF_TrackBox *trak;\n\tGF_SampleEntryBox *entry;\n\tGF_AudioSampleEntryBox*aud_entry;\n\tGF_SampleDescriptionBox *stsd;\n\tGF_ChannelLayoutBox *chnl;\n\te = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE);\n\tif (e) return e;\n\n\ttrak = gf_isom_get_track_from_file(movie, trackNumber);\n\tif (!trak) return GF_BAD_PARAM;\n\n\tstsd = trak->Media->information->sampleTable->SampleDescription;\n\tif (!stsd) {\n\t\treturn movie->LastError = GF_ISOM_INVALID_FILE;\n\t}\n\tif (!sampleDescriptionIndex || sampleDescriptionIndex > gf_list_count(stsd->child_boxes)) {\n\t\treturn movie->LastError = GF_BAD_PARAM;\n\t}\n\tentry = (GF_SampleEntryBox *)gf_list_get(stsd->child_boxes, sampleDescriptionIndex - 1);\n\t\/\/no support for generic sample entries (eg, no MPEG4 descriptor)\n\tif (entry == NULL) return GF_BAD_PARAM;\n\tif (!movie->keep_utc)\n\t\ttrak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time();\n\n\tif (entry->internal_type != GF_ISOM_SAMPLE_ENTRY_AUDIO) return GF_BAD_PARAM;\n\taud_entry = (GF_AudioSampleEntryBox*) entry;\n\tif (aud_entry->qtff_mode) {\n\t\tu32 sr = aud_entry->samplerate_hi;\n\t\tif (aud_entry->type==GF_ISOM_BOX_TYPE_MLPA) {\n\t\t\tsr <<= 16;\n\t\t\tsr |= aud_entry->samplerate_lo;\n\t\t}\n\t\te = gf_isom_set_audio_info(movie, trackNumber, sampleDescriptionIndex, sr, aud_entry->channel_count, (u8) aud_entry->bitspersample, GF_IMPORT_AUDIO_SAMPLE_ENTRY_v1_MPEG);\n\t\tif (e) return e;\n\t}\n\tchnl = (GF_ChannelLayoutBox *) gf_isom_box_find_child(aud_entry->child_boxes, GF_ISOM_BOX_TYPE_CHNL);\n\tif (!chnl) {\n\t\tchnl = (GF_ChannelLayoutBox *)gf_isom_box_new_parent(&aud_entry->child_boxes, GF_ISOM_BOX_TYPE_CHNL);\n\t\tif (!chnl) return GF_OUT_OF_MEM;\n\t}\n\taud_entry->channel_count = layout->channels_count;\n\tmemcpy(&chnl->layout, layout, sizeof(GF_AudioChannelLayout));\n\treturn GF_OK;\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":146792,"func":"wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)\n{\n    \/\/ If any autocommand opened a window on the dummy buffer, close that\n    \/\/ window.  If we can't close them all then give up.\n    while (buf->b_nwindows > 0)\n    {\n\tint\t    did_one = FALSE;\n\twin_T\t    *wp;\n\n\tif (firstwin->w_next != NULL)\n\t    FOR_ALL_WINDOWS(wp)\n\t\tif (wp->w_buffer == buf)\n\t\t{\n\t\t    if (win_close(wp, FALSE) == OK)\n\t\t\tdid_one = TRUE;\n\t\t    break;\n\t\t}\n\tif (!did_one)\n\t    return;\n    }\n\n    if (curbuf != buf && buf->b_nwindows == 0)\t\/\/ safety check\n    {\n#if defined(FEAT_EVAL)\n\tcleanup_T   cs;\n\n\t\/\/ Reset the error\/interrupt\/exception state here so that aborting()\n\t\/\/ returns FALSE when wiping out the buffer.  Otherwise it doesn't\n\t\/\/ work when got_int is set.\n\tenter_cleanup(&cs);\n#endif\n\n\twipe_buffer(buf, TRUE);\n\n#if defined(FEAT_EVAL)\n\t\/\/ Restore the error\/interrupt\/exception state if not discarded by a\n\t\/\/ new aborting error, interrupt, or uncaught exception.\n\tleave_cleanup(&cs);\n#endif\n\t\/\/ When autocommands\/'autochdir' option changed directory: go back.\n\trestore_start_dir(dirname_start);\n    }\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":18311,"func":"TEST_F ( ProfileInfoCacheTest , GAIAName ) {\n GetCache ( ) -> AddProfileToCache ( GetProfilePath ( \"path_1\" ) , ASCIIToUTF16 ( \"Person 1\" ) , base : : string16 ( ) , 0 , std : : string ( ) ) ;\n base : : string16 profile_name ( ASCIIToUTF16 ( \"Person 2\" ) ) ;\n GetCache ( ) -> AddProfileToCache ( GetProfilePath ( \"path_2\" ) , profile_name , base : : string16 ( ) , 0 , std : : string ( ) ) ;\n int index1 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( \"path_1\" ) ) ;\n int index2 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( \"path_2\" ) ) ;\n EXPECT_TRUE ( GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index1 ) . empty ( ) ) ;\n EXPECT_TRUE ( GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index2 ) . empty ( ) ) ;\n base : : string16 gaia_name ( ASCIIToUTF16 ( \"Pat Smith\" ) ) ;\n GetCache ( ) -> SetGAIANameOfProfileAtIndex ( index2 , gaia_name ) ;\n index1 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( \"path_1\" ) ) ;\n index2 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( \"path_2\" ) ) ;\n EXPECT_TRUE ( GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index1 ) . empty ( ) ) ;\n EXPECT_EQ ( gaia_name , GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index2 ) ) ;\n EXPECT_EQ ( gaia_name , GetCache ( ) -> GetNameOfProfileAtIndex ( index2 ) ) ;\n base : : string16 custom_name ( ASCIIToUTF16 ( \"Custom name\" ) ) ;\n GetCache ( ) -> SetNameOfProfileAtIndex ( index2 , custom_name ) ;\n GetCache ( ) -> SetProfileIsUsingDefaultNameAtIndex ( index2 , false ) ;\n index1 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( \"path_1\" ) ) ;\n index2 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( \"path_2\" ) ) ;\n EXPECT_EQ ( custom_name , GetCache ( ) -> GetNameOfProfileAtIndex ( index2 ) ) ;\n EXPECT_EQ ( gaia_name , GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index2 ) ) ;\n }","target":0,"code_token_length":566,"total_token_length":802,"max_tokens_setting":1024}
+{"idx":509713,"func":"static void test_frm_bug()\n{\n  MYSQL_STMT *stmt;\n  MYSQL_BIND my_bind[2];\n  MYSQL_RES  *result;\n  MYSQL_ROW  row;\n  FILE       *test_file;\n  char       data_dir[FN_REFLEN];\n  char       test_frm[FN_REFLEN];\n  int        rc;\n\n  myheader(\"test_frm_bug\");\n\n  mysql_autocommit(mysql, TRUE);\n\n  rc= mysql_query(mysql, \"drop table if exists test_frm_bug\");\n  myquery(rc);\n\n  rc= mysql_query(mysql, \"flush tables\");\n  myquery(rc);\n\n  stmt= mysql_simple_prepare(mysql, \"show variables like 'datadir'\");\n  check_stmt(stmt);\n\n  rc= mysql_stmt_execute(stmt);\n  check_execute(stmt, rc);\n\n  bzero((char*) my_bind, sizeof(my_bind));\n  my_bind[0].buffer_type= MYSQL_TYPE_STRING;\n  my_bind[0].buffer= data_dir;\n  my_bind[0].buffer_length= FN_REFLEN;\n  my_bind[1]= my_bind[0];\n\n  rc= mysql_stmt_bind_result(stmt, my_bind);\n  check_execute(stmt, rc);\n\n  rc= mysql_stmt_fetch(stmt);\n  check_execute(stmt, rc);\n\n  if (!opt_silent)\n    fprintf(stdout, \"\\n data directory: %s\", data_dir);\n\n  rc= mysql_stmt_fetch(stmt);\n  DIE_UNLESS(rc == MYSQL_NO_DATA);\n\n  strxmov(test_frm, data_dir, \"\/\", current_db, \"\/\", \"test_frm_bug.frm\", NullS);\n\n  if (!opt_silent)\n    fprintf(stdout, \"\\n test_frm: %s\", test_frm);\n\n  if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME))))\n  {\n    fprintf(stdout, \"\\n ERROR: my_fopen failed for '%s'\", test_frm);\n    fprintf(stdout, \"\\n test cancelled\");\n    exit(1);\n  }\n  if (!opt_silent)\n    fprintf(test_file, \"this is a junk file for test\");\n\n  rc= mysql_query(mysql, \"SHOW TABLE STATUS like 'test_frm_bug'\");\n  myquery(rc);\n\n  result= mysql_store_result(mysql);\n  mytest(result);\/* It can't be NULL *\/\n\n  rc= my_process_result_set(result);\n  DIE_UNLESS(rc == 1);\n\n  mysql_data_seek(result, 0);\n\n  row= mysql_fetch_row(result);\n  mytest(row);\n\n  if (!opt_silent)\n    fprintf(stdout, \"\\n Comment: %s\", row[17]);\n  DIE_UNLESS(row[17] != 0);\n\n  mysql_free_result(result);\n  mysql_stmt_close(stmt);\n\n  my_fclose(test_file, MYF(0));\n  mysql_query(mysql, \"drop table if exists test_frm_bug\");\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":186079,"func":"void ExtensionFunctionDispatcher::Dispatch(\n    const ExtensionHostMsg_Request_Params& params,\n    RenderViewHost* render_view_host) {\n  ExtensionService* service = profile()->GetExtensionService();\n  ExtensionProcessManager* process_manager =\n      extensions::ExtensionSystem::Get(profile())->process_manager();\n  extensions::ProcessMap* process_map = service->process_map();\n  if (!service || !process_map)\n    return;\n\n  const Extension* extension = service->extensions()->GetByID(\n      params.extension_id);\n  if (!extension)\n    extension = service->extensions()->GetHostedAppByURL(ExtensionURLInfo(\n        WebSecurityOrigin::createFromString(params.source_origin),\n        params.source_url));\n\n  scoped_refptr<ExtensionFunction> function(\n      CreateExtensionFunction(params, extension,\n                              render_view_host->GetProcess()->GetID(),\n                              *(service->process_map()),\n                              extensions::ExtensionAPI::GetSharedInstance(),\n                              profile(), render_view_host, render_view_host,\n                              render_view_host->GetRoutingID()));\n  scoped_ptr<ListValue> args(params.arguments.DeepCopy());\n\n  if (!function) {\n    LogFailure(extension,\n               params.name,\n               args.Pass(),\n               kAccessDenied,\n               profile());\n    return;\n  }\n\n  UIThreadExtensionFunction* function_ui =\n      function->AsUIThreadExtensionFunction();\n  if (!function_ui) {\n    NOTREACHED();\n    return;\n  }\n  function_ui->set_dispatcher(AsWeakPtr());\n  function_ui->set_profile(profile_);\n  function->set_include_incognito(service->CanCrossIncognito(extension));\n\n  if (!CheckPermissions(function, extension, params, render_view_host,\n                        render_view_host->GetRoutingID())) {\n    LogFailure(extension,\n               params.name,\n               args.Pass(),\n               kAccessDenied,\n               profile());\n    return;\n  }\n\n  ExtensionsQuotaService* quota = service->quota_service();\n  std::string violation_error = quota->Assess(extension->id(),\n                                              function,\n                                              ¶ms.arguments,\n                                              base::TimeTicks::Now());\n  if (violation_error.empty()) {\n    ExternalProtocolHandler::PermitLaunchUrl();\n    LogSuccess(extension, params.name, args.Pass(), profile());\n    function->Run();\n  } else {\n    LogFailure(extension,\n               params.name,\n               args.Pass(),\n               kQuotaExceeded,\n               profile());\n    function->OnQuotaExceeded(violation_error);\n  }\n\n\n  if (!service->extensions()->GetByID(params.extension_id))\n    return;\n\n  process_manager->IncrementLazyKeepaliveCount(extension);\n}\n","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":129694,"func":"static struct inode *hugetlbfs_get_inode(struct super_block *sb,\n\t\t\t\t\tstruct inode *dir,\n\t\t\t\t\tumode_t mode, dev_t dev)\n{\n\tstruct inode *inode;\n\n\tinode = new_inode(sb);\n\tif (inode) {\n\t\tstruct hugetlbfs_inode_info *info;\n\t\tinode->i_ino = get_next_ino();\n\t\tinode_init_owner(inode, dir, mode);\n\t\tinode->i_mapping->a_ops = &hugetlbfs_aops;\n\t\tinode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;\n\t\tinode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;\n\t\tINIT_LIST_HEAD(&inode->i_mapping->private_list);\n\t\tinfo = HUGETLBFS_I(inode);\n\t\t\/*\n\t\t * The policy is initialized here even if we are creating a\n\t\t * private inode because initialization simply creates an\n\t\t * an empty rb tree and calls spin_lock_init(), later when we\n\t\t * call mpol_free_shared_policy() it will just return because\n\t\t * the rb tree will still be empty.\n\t\t *\/\n\t\tmpol_shared_policy_init(&info->policy, NULL);\n\t\tswitch (mode & S_IFMT) {\n\t\tdefault:\n\t\t\tinit_special_inode(inode, mode, dev);\n\t\t\tbreak;\n\t\tcase S_IFREG:\n\t\t\tinode->i_op = &hugetlbfs_inode_operations;\n\t\t\tinode->i_fop = &hugetlbfs_file_operations;\n\t\t\tbreak;\n\t\tcase S_IFDIR:\n\t\t\tinode->i_op = &hugetlbfs_dir_inode_operations;\n\t\t\tinode->i_fop = &simple_dir_operations;\n\n\t\t\t\/* directory inodes start off with i_nlink == 2 (for \".\" entry) *\/\n\t\t\tinc_nlink(inode);\n\t\t\tbreak;\n\t\tcase S_IFLNK:\n\t\t\tinode->i_op = &page_symlink_inode_operations;\n\t\t\tbreak;\n\t\t}\n\t\tlockdep_annotate_inode_mutex_key(inode);\n\t}\n\treturn inode;\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":2939,"func":"static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,\n\t\tstruct nfsd3_setaclargs *argp,\n\t\tstruct nfsd3_attrstat *resp)\n{\n\tstruct inode *inode;\n\tsvc_fh *fh;\n\t__be32 nfserr = 0;\n\tint error;\n\n\tfh = fh_copy(&resp->fh, &argp->fh);\n\tnfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);\n\tif (nfserr)\n\t\tgoto out;\n\n\tinode = d_inode(fh->fh_dentry);\n\tif (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {\n\t\terror = -EOPNOTSUPP;\n\t\tgoto out_errno;\n\t}\n\n\terror = fh_want_write(fh);\n\tif (error)\n\t\tgoto out_errno;\n\n\terror = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);\n\tif (error)\n\t\tgoto out_drop_write;\n\terror = inode->i_op->set_acl(inode, argp->acl_default,\n\t\t\t\t     ACL_TYPE_DEFAULT);\n\nout_drop_write:\n\tfh_drop_write(fh);\nout_errno:\n\tnfserr = nfserrno(error);\nout:\n\t\/* argp->acl_{access,default} may have been allocated in\n\t   nfs3svc_decode_setaclargs. *\/\n\tposix_acl_release(argp->acl_access);\n\tposix_acl_release(argp->acl_default);\n\tRETURN_STATUS(nfserr);\n}","target":1,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":223340,"func":"void WebGLRenderingContextBase::TexImageByGPU(\n    TexImageFunctionID function_id,\n    WebGLTexture* texture,\n    GLenum target,\n    GLint level,\n    GLint xoffset,\n    GLint yoffset,\n    GLint zoffset,\n    CanvasImageSource* image,\n    const IntRect& source_sub_rectangle) {\n  DCHECK(image->IsCanvasElement() || image->IsImageBitmap());\n  int width = source_sub_rectangle.Width();\n  int height = source_sub_rectangle.Height();\n\n  ScopedTexture2DRestorer restorer(this);\n\n  GLuint target_texture = texture->Object();\n  bool possible_direct_copy = false;\n  if (function_id == kTexImage2D || function_id == kTexSubImage2D) {\n    possible_direct_copy = Extensions3DUtil::CanUseCopyTextureCHROMIUM(target);\n  }\n\n  GLint copy_x_offset = xoffset;\n  GLint copy_y_offset = yoffset;\n  GLenum copy_target = target;\n\n  if (!possible_direct_copy) {\n    ContextGL()->GenTextures(1, &target_texture);\n    ContextGL()->BindTexture(GL_TEXTURE_2D, target_texture);\n    ContextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,\n                               GL_NEAREST);\n    ContextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,\n                               GL_NEAREST);\n    ContextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,\n                               GL_CLAMP_TO_EDGE);\n    ContextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,\n                               GL_CLAMP_TO_EDGE);\n    ContextGL()->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,\n                            GL_RGBA, GL_UNSIGNED_BYTE, nullptr);\n    copy_x_offset = 0;\n    copy_y_offset = 0;\n    copy_target = GL_TEXTURE_2D;\n  }\n\n  {\n    ScopedUnpackParametersResetRestore temporaryResetUnpack(this);\n    if (image->IsCanvasElement()) {\n      TexImageCanvasByGPU(function_id, static_cast<HTMLCanvasElement*>(image),\n                          copy_target, target_texture, copy_x_offset,\n                          copy_y_offset, source_sub_rectangle);\n    } else {\n      TexImageBitmapByGPU(static_cast<ImageBitmap*>(image), copy_target,\n                          target_texture, !unpack_flip_y_, copy_x_offset,\n                          copy_y_offset, source_sub_rectangle);\n    }\n  }\n\n  if (!possible_direct_copy) {\n    GLuint tmp_fbo;\n    ContextGL()->GenFramebuffers(1, &tmp_fbo);\n    ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmp_fbo);\n    ContextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,\n                                      GL_TEXTURE_2D, target_texture, 0);\n    ContextGL()->BindTexture(texture->GetTarget(), texture->Object());\n    if (function_id == kTexImage2D) {\n      ContextGL()->CopyTexSubImage2D(target, level, 0, 0, 0, 0, width, height);\n    } else if (function_id == kTexSubImage2D) {\n      ContextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, 0, 0,\n                                     width, height);\n    } else if (function_id == kTexSubImage3D) {\n      ContextGL()->CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset,\n                                     0, 0, width, height);\n    }\n    ContextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,\n                                      GL_TEXTURE_2D, 0, 0);\n    RestoreCurrentFramebuffer();\n    ContextGL()->DeleteFramebuffers(1, &tmp_fbo);\n    ContextGL()->DeleteTextures(1, &target_texture);\n  }\n}\n","target":0,"code_token_length":777,"total_token_length":1013,"max_tokens_setting":1024}
+{"idx":442439,"func":"void checkValue (void* sampleRawData,\n                 int sampleCount,\n                 int channelType,\n                 int dwx,\n                 int dwy)\n{\n    for (int l = 0; l < sampleCount; l++)\n    {\n        if (channelType == 0)\n        {\n            unsigned int* value = (unsigned int*)(sampleRawData);\n            if (value[l] != static_cast<unsigned int>((dwy * width + dwx) % 2049))\n                cout << dwx << \", \" << dwy << \" error, should be \"\n                     << (dwy * width + dwx) % 2049 << \", is \" << value[l]\n                     << endl << flush;\n            assert (value[l] == static_cast<unsigned int>((dwy * width + dwx) % 2049));\n        }\n        if (channelType == 1)\n        {\n            half* value = (half*)(sampleRawData);\n            if (value[l] != (dwy * width + dwx) % 2049)\n                cout << dwx << \", \" << dwy << \" error, should be \"\n                     << (dwy * width + dwx) % 2049 << \", is \" << value[l]\n                     << endl << flush;\n            assert (value[l] == (dwy * width + dwx) % 2049);\n        }\n        if (channelType == 2)\n        {\n            float* value = (float*)(sampleRawData);\n            if (value[l] != (dwy * width + dwx) % 2049)\n                cout << dwx << \", \" << dwy << \" error, should be \"\n                     << (dwy * width + dwx) % 2049 << \", is \" << value[l]\n                     << endl << flush;\n            assert (value[l] == (dwy * width + dwx) % 2049);\n        }\n    }\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":348865,"func":"static struct domain_device *sas_ex_discover_expander(\n\tstruct domain_device *parent, int phy_id)\n{\n\tstruct sas_expander_device *parent_ex = rphy_to_expander_device(parent->rphy);\n\tstruct ex_phy *phy = &parent->ex_dev.ex_phy[phy_id];\n\tstruct domain_device *child = NULL;\n\tstruct sas_rphy *rphy;\n\tstruct sas_expander_device *edev;\n\tstruct asd_sas_port *port;\n\tint res;\n\n\tif (phy->routing_attr == DIRECT_ROUTING) {\n\t\tpr_warn(\"ex %016llx:%02d:D <--> ex %016llx:0x%x is not allowed\\n\",\n\t\t\tSAS_ADDR(parent->sas_addr), phy_id,\n\t\t\tSAS_ADDR(phy->attached_sas_addr),\n\t\t\tphy->attached_phy_id);\n\t\treturn NULL;\n\t}\n\tchild = sas_alloc_device();\n\tif (!child)\n\t\treturn NULL;\n\n\tphy->port = sas_port_alloc(&parent->rphy->dev, phy_id);\n\t\/* FIXME: better error handling *\/\n\tBUG_ON(sas_port_add(phy->port) != 0);\n\n\n\tswitch (phy->attached_dev_type) {\n\tcase SAS_EDGE_EXPANDER_DEVICE:\n\t\trphy = sas_expander_alloc(phy->port,\n\t\t\t\t\t  SAS_EDGE_EXPANDER_DEVICE);\n\t\tbreak;\n\tcase SAS_FANOUT_EXPANDER_DEVICE:\n\t\trphy = sas_expander_alloc(phy->port,\n\t\t\t\t\t  SAS_FANOUT_EXPANDER_DEVICE);\n\t\tbreak;\n\tdefault:\n\t\trphy = NULL;\t\/* shut gcc up *\/\n\t\tBUG();\n\t}\n\tport = parent->port;\n\tchild->rphy = rphy;\n\tget_device(&rphy->dev);\n\tedev = rphy_to_expander_device(rphy);\n\tchild->dev_type = phy->attached_dev_type;\n\tkref_get(&parent->kref);\n\tchild->parent = parent;\n\tchild->port = port;\n\tchild->iproto = phy->attached_iproto;\n\tchild->tproto = phy->attached_tproto;\n\tmemcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE);\n\tsas_hash_addr(child->hashed_sas_addr, child->sas_addr);\n\tsas_ex_get_linkrate(parent, child, phy);\n\tedev->level = parent_ex->level + 1;\n\tparent->port->disc.max_level = max(parent->port->disc.max_level,\n\t\t\t\t\t   edev->level);\n\tsas_init_dev(child);\n\tsas_fill_in_rphy(child, rphy);\n\tsas_rphy_add(rphy);\n\n\tspin_lock_irq(&parent->port->dev_list_lock);\n\tlist_add_tail(&child->dev_list_node, &parent->port->dev_list);\n\tspin_unlock_irq(&parent->port->dev_list_lock);\n\n\tres = sas_discover_expander(child);\n\tif (res) {\n\t\tsas_rphy_delete(rphy);\n\t\tspin_lock_irq(&parent->port->dev_list_lock);\n\t\tlist_del(&child->dev_list_node);\n\t\tspin_unlock_irq(&parent->port->dev_list_lock);\n\t\tsas_put_device(child);\n\t\treturn NULL;\n\t}\n\tlist_add_tail(&child->siblings, &parent->ex_dev.children);\n\treturn child;\n}","target":1,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":416848,"func":"static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,\n\t\t\t     struct netlink_ext_ack *extack)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct rtnl_link *handlers;\n\tint err = -EOPNOTSUPP;\n\trtnl_doit_func doit;\n\tunsigned int flags;\n\tint kind;\n\tint family;\n\tint type;\n\n\ttype = nlh->nlmsg_type;\n\tif (type > RTM_MAX)\n\t\treturn -EOPNOTSUPP;\n\n\ttype -= RTM_BASE;\n\n\t\/* All the messages must have at least 1 byte length *\/\n\tif (nlmsg_len(nlh) < sizeof(struct rtgenmsg))\n\t\treturn 0;\n\n\tfamily = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;\n\tkind = type&3;\n\n\tif (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))\n\t\treturn -EPERM;\n\n\tif (family >= ARRAY_SIZE(rtnl_msg_handlers))\n\t\tfamily = PF_UNSPEC;\n\n\trcu_read_lock();\n\thandlers = rcu_dereference(rtnl_msg_handlers[family]);\n\tif (!handlers) {\n\t\tfamily = PF_UNSPEC;\n\t\thandlers = rcu_dereference(rtnl_msg_handlers[family]);\n\t}\n\n\tif (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {\n\t\tstruct sock *rtnl;\n\t\trtnl_dumpit_func dumpit;\n\t\tu16 min_dump_alloc = 0;\n\n\t\tdumpit = READ_ONCE(handlers[type].dumpit);\n\t\tif (!dumpit) {\n\t\t\tfamily = PF_UNSPEC;\n\t\t\thandlers = rcu_dereference(rtnl_msg_handlers[PF_UNSPEC]);\n\t\t\tif (!handlers)\n\t\t\t\tgoto err_unlock;\n\n\t\t\tdumpit = READ_ONCE(handlers[type].dumpit);\n\t\t\tif (!dumpit)\n\t\t\t\tgoto err_unlock;\n\t\t}\n\n\t\trefcount_inc(&rtnl_msg_handlers_ref[family]);\n\n\t\tif (type == RTM_GETLINK - RTM_BASE)\n\t\t\tmin_dump_alloc = rtnl_calcit(skb, nlh);\n\n\t\trcu_read_unlock();\n\n\t\trtnl = net->rtnl;\n\t\t{\n\t\t\tstruct netlink_dump_control c = {\n\t\t\t\t.dump\t\t= dumpit,\n\t\t\t\t.min_dump_alloc\t= min_dump_alloc,\n\t\t\t};\n\t\t\terr = netlink_dump_start(rtnl, skb, nlh, &c);\n\t\t}\n\t\trefcount_dec(&rtnl_msg_handlers_ref[family]);\n\t\treturn err;\n\t}\n\n\tdoit = READ_ONCE(handlers[type].doit);\n\tif (!doit) {\n\t\tfamily = PF_UNSPEC;\n\t\thandlers = rcu_dereference(rtnl_msg_handlers[family]);\n\t}\n\n\tflags = READ_ONCE(handlers[type].flags);\n\tif (flags & RTNL_FLAG_DOIT_UNLOCKED) {\n\t\trefcount_inc(&rtnl_msg_handlers_ref[family]);\n\t\tdoit = READ_ONCE(handlers[type].doit);\n\t\trcu_read_unlock();\n\t\tif (doit)\n\t\t\terr = doit(skb, nlh, extack);\n\t\trefcount_dec(&rtnl_msg_handlers_ref[family]);\n\t\treturn err;\n\t}\n\n\trcu_read_unlock();\n\n\trtnl_lock();\n\thandlers = rtnl_dereference(rtnl_msg_handlers[family]);\n\tif (handlers) {\n\t\tdoit = READ_ONCE(handlers[type].doit);\n\t\tif (doit)\n\t\t\terr = doit(skb, nlh, extack);\n\t}\n\trtnl_unlock();\n\treturn err;\n\nerr_unlock:\n\trcu_read_unlock();\n\treturn -EOPNOTSUPP;\n}","target":0,"code_token_length":777,"total_token_length":1013,"max_tokens_setting":1024}
+{"idx":265053,"func":"connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)\n{\n  int payload_len, command;\n  const char *string_addr;\n  char inaddr_buf[REVERSE_LOOKUP_NAME_BUF_LEN];\n  origin_circuit_t *circ;\n  edge_connection_t *edge_conn = ENTRY_TO_EDGE_CONN(ap_conn);\n  connection_t *base_conn = TO_CONN(edge_conn);\n  tor_assert(edge_conn->on_circuit);\n  circ = TO_ORIGIN_CIRCUIT(edge_conn->on_circuit);\n\n  tor_assert(base_conn->type == CONN_TYPE_AP);\n  tor_assert(base_conn->state == AP_CONN_STATE_CIRCUIT_WAIT);\n  tor_assert(ap_conn->socks_request);\n  tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL);\n\n  command = ap_conn->socks_request->command;\n  tor_assert(SOCKS_COMMAND_IS_RESOLVE(command));\n\n  edge_conn->stream_id = get_unique_stream_id_by_circ(circ);\n  if (edge_conn->stream_id==0) {\n    \/* XXXX+ Instead of closing this stream, we should make it get\n     * retried on another circuit. *\/\n    connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);\n\n    \/* Mark this circuit \"unusable for new streams\". *\/\n    mark_circuit_unusable_for_new_conns(circ);\n    return -1;\n  }\n\n  if (command == SOCKS_COMMAND_RESOLVE) {\n    string_addr = ap_conn->socks_request->address;\n    payload_len = (int)strlen(string_addr)+1;\n  } else {\n    \/* command == SOCKS_COMMAND_RESOLVE_PTR *\/\n    const char *a = ap_conn->socks_request->address;\n    tor_addr_t addr;\n    int r;\n\n    \/* We're doing a reverse lookup.  The input could be an IP address, or\n     * could be an .in-addr.arpa or .ip6.arpa address *\/\n    r = tor_addr_parse_PTR_name(&addr, a, AF_UNSPEC, 1);\n    if (r <= 0) {\n      log_warn(LD_APP, \"Rejecting ill-formed reverse lookup of %s\",\n               safe_str_client(a));\n      connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);\n      return -1;\n    }\n\n    r = tor_addr_to_PTR_name(inaddr_buf, sizeof(inaddr_buf), &addr);\n    if (r < 0) {\n      log_warn(LD_BUG, \"Couldn't generate reverse lookup hostname of %s\",\n               safe_str_client(a));\n      connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);\n      return -1;\n    }\n\n    string_addr = inaddr_buf;\n    payload_len = (int)strlen(inaddr_buf)+1;\n    tor_assert(payload_len <= (int)sizeof(inaddr_buf));\n  }\n\n  log_debug(LD_APP,\n            \"Sending relay cell to begin stream %d.\", edge_conn->stream_id);\n\n  if (connection_edge_send_command(edge_conn,\n                           RELAY_COMMAND_RESOLVE,\n                           string_addr, payload_len) < 0)\n    return -1; \/* circuit is closed, don't continue *\/\n\n  if (!base_conn->address) {\n    \/* This might be unnecessary. XXXX *\/\n    base_conn->address = tor_addr_to_str_dup(&base_conn->addr);\n  }\n  base_conn->state = AP_CONN_STATE_RESOLVE_WAIT;\n  log_info(LD_APP,\"Address sent for resolve, ap socket \"TOR_SOCKET_T_FORMAT\n           \", n_circ_id %u\",\n           base_conn->s, (unsigned)circ->base_.n_circ_id);\n  control_event_stream_status(ap_conn, STREAM_EVENT_SENT_RESOLVE, 0);\n  return 0;\n}","target":0,"code_token_length":778,"total_token_length":1014,"max_tokens_setting":1024}
+{"idx":380121,"func":"PHP_FUNCTION(sqlite_fetch_column_types)\n{\n\tzval *zdb;\n\tstruct php_sqlite_db *db;\n\tchar *tbl, *sql;\n\tint tbl_len;\n\tchar *errtext = NULL;\n\tzval *object = getThis();\n\tstruct php_sqlite_result res;\n\tconst char **rowdata, **colnames, *tail;\n\tint i, ncols;\n\tlong result_type = PHPSQLITE_ASSOC;\n\n\tif (object) {\n\t\tif (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s|l\", &tbl, &tbl_len, &result_type)) {\n\t\t\treturn;\n\t\t}\n\t\tDB_FROM_OBJECT(db, object);\n\t} else {\n\t\tif (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,\n\t\t\t\tZEND_NUM_ARGS() TSRMLS_CC, \"sr|l\", &tbl, &tbl_len, &zdb, &result_type) &&\n\t\t\tFAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rs|l\", &zdb, &tbl, &tbl_len, &result_type)) {\n\t\t\treturn;\n\t\t}\n\t\tDB_FROM_ZVAL(db, &zdb);\n\t}\n\n\tif (!(sql = sqlite_mprintf(\"SELECT * FROM '%q' LIMIT 1\", tbl))) {\n\t\tRETURN_FALSE;\n\t}\n\n\tsqlite_exec(db->db, \"PRAGMA show_datatypes = ON\", NULL, NULL, NULL);\n\n\tdb->last_err_code = sqlite_compile(db->db, sql, &tail, &res.vm, &errtext);\n\n\tsqlite_freemem(sql);\n\n\tif (db->last_err_code != SQLITE_OK) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"%s\", errtext);\n\t\tsqlite_freemem(errtext);\n\t\tRETVAL_FALSE;\n\t\tgoto done;\n\t}\n\n\tsqlite_step(res.vm, &ncols, &rowdata, &colnames);\n\n\tarray_init(return_value);\n\n\tfor (i = 0; i < ncols; i++) {\n\t\tif (result_type == PHPSQLITE_ASSOC) {\n\t\t\tchar *colname = estrdup((char *)colnames[i]);\n\n\t\t\tif (SQLITE_G(assoc_case) == 1) {\n\t\t\t\tphp_sqlite_strtoupper(colname);\n\t\t\t} else if (SQLITE_G(assoc_case) == 2) {\n\t\t\t\tphp_sqlite_strtolower(colname);\n\t\t\t}\n\n\t\t\tadd_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : \"\", 1);\n\t\t\tefree(colname);\n\t\t}\n\t\tif (result_type == PHPSQLITE_NUM) {\n\t\t\tadd_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : \"\", 1);\n\t\t}\n\t}\n\tif (res.vm) {\n\t\tsqlite_finalize(res.vm, NULL);\n\t}\ndone:\n\tsqlite_exec(db->db, \"PRAGMA show_datatypes = OFF\", NULL, NULL, NULL);\n}","target":0,"code_token_length":635,"total_token_length":871,"max_tokens_setting":1024}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..259aa1d130f3038964bba0785f47bcc96048af66
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:166ae48227c9df80e286327ad6a0a47f780c0c7f895752578851815ea5367ff2
+size 3423016
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..d075edb86f71b307e3ccc0e3fcb332397fa1a974
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.jsonl
@@ -0,0 +1,25 @@
+{"idx":327145,"func":"av_cold int ff_mpv_encode_init(AVCodecContext *avctx)\n\n{\n\n    MpegEncContext *s = avctx->priv_data;\n\n    int i, ret, format_supported;\n\n\n\n    mpv_encode_defaults(s);\n\n\n\n    switch (avctx->codec_id) {\n\n    case AV_CODEC_ID_MPEG2VIDEO:\n\n        if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&\n\n            avctx->pix_fmt != AV_PIX_FMT_YUV422P) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"only YUV420 and YUV422 are supported\\n\");\n\n            return -1;\n\n        }\n\n        break;\n\n    case AV_CODEC_ID_MJPEG:\n\n        format_supported = 0;\n\n        \/* JPEG color space *\/\n\n        if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||\n\n            avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||\n\n            (avctx->color_range == AVCOL_RANGE_JPEG &&\n\n             (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||\n\n              avctx->pix_fmt == AV_PIX_FMT_YUV422P)))\n\n            format_supported = 1;\n\n        \/* MPEG color space *\/\n\n        else if (avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL &&\n\n                 (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||\n\n                  avctx->pix_fmt == AV_PIX_FMT_YUV422P))\n\n            format_supported = 1;\n\n\n\n        if (!format_supported) {\n\n            av_log(avctx, AV_LOG_ERROR, \"colorspace not supported in jpeg\\n\");\n\n            return -1;\n\n        }\n\n        break;\n\n    default:\n\n        if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {\n\n            av_log(avctx, AV_LOG_ERROR, \"only YUV420 is supported\\n\");\n\n            return -1;\n\n        }\n\n    }\n\n\n\n    switch (avctx->pix_fmt) {\n\n    case AV_PIX_FMT_YUVJ422P:\n\n    case AV_PIX_FMT_YUV422P:\n\n        s->chroma_format = CHROMA_422;\n\n        break;\n\n    case AV_PIX_FMT_YUVJ420P:\n\n    case AV_PIX_FMT_YUV420P:\n\n    default:\n\n        s->chroma_format = CHROMA_420;\n\n        break;\n\n    }\n\n\n\n    s->bit_rate = avctx->bit_rate;\n\n    s->width    = avctx->width;\n\n    s->height   = avctx->height;\n\n    if (avctx->gop_size > 600 &&\n\n        avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"Warning keyframe interval too large! reducing it ...\\n\");\n\n        avctx->gop_size = 600;\n\n    }\n\n    s->gop_size     = avctx->gop_size;\n\n    s->avctx        = avctx;\n\n    if (avctx->max_b_frames > MAX_B_FRAMES) {\n\n        av_log(avctx, AV_LOG_ERROR, \"Too many B-frames requested, maximum \"\n\n               \"is %d.\\n\", MAX_B_FRAMES);\n\n    }\n\n    s->max_b_frames = avctx->max_b_frames;\n\n    s->codec_id     = avctx->codec->id;\n\n    s->strict_std_compliance = avctx->strict_std_compliance;\n\n    s->quarter_sample     = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;\n\n    s->mpeg_quant         = avctx->mpeg_quant;\n\n    s->rtp_mode           = !!avctx->rtp_payload_size;\n\n    s->intra_dc_precision = avctx->intra_dc_precision;\n\n    s->user_specified_pts = AV_NOPTS_VALUE;\n\n\n\n    if (s->gop_size <= 1) {\n\n        s->intra_only = 1;\n\n        s->gop_size   = 12;\n\n    } else {\n\n        s->intra_only = 0;\n\n    }\n\n\n\n#if FF_API_MOTION_EST\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n    s->me_method = avctx->me_method;\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n    \/* Fixed QSCALE *\/\n\n    s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE);\n\n\n\n#if FF_API_MPV_OPT\n\n    FF_DISABLE_DEPRECATION_WARNINGS\n\n    if (avctx->border_masking != 0.0)\n\n        s->border_masking = avctx->border_masking;\n\n    FF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n    s->adaptive_quant = (s->avctx->lumi_masking ||\n\n                         s->avctx->dark_masking ||\n\n                         s->avctx->temporal_cplx_masking ||\n\n                         s->avctx->spatial_cplx_masking  ||\n\n                         s->avctx->p_masking      ||\n\n                         s->border_masking ||\n\n                         (s->mpv_flags & FF_MPV_FLAG_QP_RD)) &&\n\n                        !s->fixed_qscale;\n\n\n\n    s->loop_filter = !!(s->avctx->flags & AV_CODEC_FLAG_LOOP_FILTER);\n\n\n\n    if (avctx->rc_max_rate && !avctx->rc_buffer_size) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"a vbv buffer size is needed, \"\n\n               \"for encoding with a maximum bitrate\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) {\n\n        av_log(avctx, AV_LOG_INFO,\n\n               \"Warning min_rate > 0 but min_rate != max_rate isn't recommended!\\n\");\n\n    }\n\n\n\n    if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) {\n\n        av_log(avctx, AV_LOG_ERROR, \"bitrate below min bitrate\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) {\n\n        av_log(avctx, AV_LOG_INFO, \"bitrate above max bitrate\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (avctx->rc_max_rate &&\n\n        avctx->rc_max_rate == avctx->bit_rate &&\n\n        avctx->rc_max_rate != avctx->rc_min_rate) {\n\n        av_log(avctx, AV_LOG_INFO,\n\n               \"impossible bitrate constraints, this will fail\\n\");\n\n    }\n\n\n\n    if (avctx->rc_buffer_size &&\n\n        avctx->bit_rate * (int64_t)avctx->time_base.num >\n\n            avctx->rc_buffer_size * (int64_t)avctx->time_base.den) {\n\n        av_log(avctx, AV_LOG_ERROR, \"VBV buffer too small for bitrate\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (!s->fixed_qscale &&\n\n        avctx->bit_rate * av_q2d(avctx->time_base) >\n\n            avctx->bit_rate_tolerance) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"bitrate tolerance too small for bitrate\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->avctx->rc_max_rate &&\n\n        s->avctx->rc_min_rate == s->avctx->rc_max_rate &&\n\n        (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||\n\n         s->codec_id == AV_CODEC_ID_MPEG2VIDEO) &&\n\n        90000LL * (avctx->rc_buffer_size - 1) >\n\n            s->avctx->rc_max_rate * 0xFFFFLL) {\n\n        av_log(avctx, AV_LOG_INFO,\n\n               \"Warning vbv_delay will be set to 0xFFFF (=VBR) as the \"\n\n               \"specified vbv buffer is too large for the given bitrate!\\n\");\n\n    }\n\n\n\n    if ((s->avctx->flags & AV_CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 &&\n\n        s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P &&\n\n        s->codec_id != AV_CODEC_ID_FLV1) {\n\n        av_log(avctx, AV_LOG_ERROR, \"4MV not supported by codec\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"OBMC is only supported with simple mb decision\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) {\n\n        av_log(avctx, AV_LOG_ERROR, \"qpel not supported by codec\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->max_b_frames                    &&\n\n        s->codec_id != AV_CODEC_ID_MPEG4      &&\n\n        s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&\n\n        s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {\n\n        av_log(avctx, AV_LOG_ERROR, \"b frames not supported by codec\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if ((s->codec_id == AV_CODEC_ID_MPEG4 ||\n\n         s->codec_id == AV_CODEC_ID_H263  ||\n\n         s->codec_id == AV_CODEC_ID_H263P) &&\n\n        (avctx->sample_aspect_ratio.num > 255 ||\n\n         avctx->sample_aspect_ratio.den > 255)) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"Invalid pixel aspect ratio %i\/%i, limit is 255\/255\\n\",\n\n               avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);\n\n        return -1;\n\n    }\n\n\n\n    if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME)) &&\n\n        s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {\n\n        av_log(avctx, AV_LOG_ERROR, \"interlacing not supported by codec\\n\");\n\n        return -1;\n\n    }\n\n\n\n    \/\/ FIXME mpeg2 uses that too\n\n    if (s->mpeg_quant && s->codec_id != AV_CODEC_ID_MPEG4) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"mpeg2 style quantization not supported by codec\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if ((s->mpv_flags & FF_MPV_FLAG_CBP_RD) && !avctx->trellis) {\n\n        av_log(avctx, AV_LOG_ERROR, \"CBP RD needs trellis quant\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) &&\n\n        s->avctx->mb_decision != FF_MB_DECISION_RD) {\n\n        av_log(avctx, AV_LOG_ERROR, \"QP RD needs mbd=2\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->avctx->scenechange_threshold < 1000000000 &&\n\n        (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"closed gop with scene change detection are not supported yet, \"\n\n               \"set threshold to 1000000000\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) {\n\n        if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                  \"low delay forcing is only available for mpeg2\\n\");\n\n            return -1;\n\n        }\n\n        if (s->max_b_frames != 0) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"b frames cannot be used with low delay\\n\");\n\n            return -1;\n\n        }\n\n    }\n\n\n\n    if (s->q_scale_type == 1) {\n\n        if (avctx->qmax > 12) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"non linear quant only supports qmax <= 12 currently\\n\");\n\n            return -1;\n\n        }\n\n    }\n\n\n\n    if (avctx->slices > 1 &&\n\n        (avctx->codec_id == AV_CODEC_ID_FLV1 || avctx->codec_id == AV_CODEC_ID_H261)) {\n\n        av_log(avctx, AV_LOG_ERROR, \"Multiple slices are not supported by this codec\\n\");\n\n        return AVERROR(EINVAL);\n\n    }\n\n\n\n    if (s->avctx->thread_count > 1         &&\n\n        s->codec_id != AV_CODEC_ID_MPEG4      &&\n\n        s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&\n\n        s->codec_id != AV_CODEC_ID_MPEG2VIDEO &&\n\n        (s->codec_id != AV_CODEC_ID_H263P)) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"multi threaded encoding not supported by codec\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->avctx->thread_count < 1) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"automatic thread number detection not supported by codec,\"\n\n               \"patch welcome\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (s->avctx->thread_count > 1)\n\n        s->rtp_mode = 1;\n\n\n\n    if (!avctx->time_base.den || !avctx->time_base.num) {\n\n        av_log(avctx, AV_LOG_ERROR, \"framerate not set\\n\");\n\n        return -1;\n\n    }\n\n\n\n    if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) {\n\n        av_log(avctx, AV_LOG_INFO,\n\n               \"notice: b_frame_strategy only affects the first pass\\n\");\n\n        avctx->b_frame_strategy = 0;\n\n    }\n\n\n\n    i = av_gcd(avctx->time_base.den, avctx->time_base.num);\n\n    if (i > 1) {\n\n        av_log(avctx, AV_LOG_INFO, \"removing common factors from framerate\\n\");\n\n        avctx->time_base.den \/= i;\n\n        avctx->time_base.num \/= i;\n\n        \/\/return -1;\n\n    }\n\n\n\n    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||\n\n        s->codec_id == AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG) {\n\n        \/\/ (a + x * 3 \/ 8) \/ x\n\n        s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3);\n\n        s->inter_quant_bias = 0;\n\n    } else {\n\n        s->intra_quant_bias = 0;\n\n        \/\/ (a - x \/ 4) \/ x\n\n        s->inter_quant_bias = -(1 << (QUANT_BIAS_SHIFT - 2));\n\n    }\n\n\n\n#if FF_API_QUANT_BIAS\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n    if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)\n\n        s->intra_quant_bias = avctx->intra_quant_bias;\n\n    if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)\n\n        s->inter_quant_bias = avctx->inter_quant_bias;\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n    if (avctx->codec_id == AV_CODEC_ID_MPEG4 &&\n\n        s->avctx->time_base.den > (1 << 16) - 1) {\n\n        av_log(avctx, AV_LOG_ERROR,\n\n               \"timebase %d\/%d not supported by MPEG 4 standard, \"\n\n               \"the maximum admitted value for the timebase denominator \"\n\n               \"is %d\\n\", s->avctx->time_base.num, s->avctx->time_base.den,\n\n               (1 << 16) - 1);\n\n        return -1;\n\n    }\n\n    s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;\n\n\n\n    switch (avctx->codec->id) {\n\n    case AV_CODEC_ID_MPEG1VIDEO:\n\n        s->out_format = FMT_MPEG1;\n\n        s->low_delay  = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY);\n\n        avctx->delay  = s->low_delay ? 0 : (s->max_b_frames + 1);\n\n        break;\n\n    case AV_CODEC_ID_MPEG2VIDEO:\n\n        s->out_format = FMT_MPEG1;\n\n        s->low_delay  = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY);\n\n        avctx->delay  = s->low_delay ? 0 : (s->max_b_frames + 1);\n\n        s->rtp_mode   = 1;\n\n        break;\n\n    case AV_CODEC_ID_MJPEG:\n\n        s->out_format = FMT_MJPEG;\n\n        s->intra_only = 1; \/* force intra only for jpeg *\/\n\n        if (!CONFIG_MJPEG_ENCODER ||\n\n            ff_mjpeg_encode_init(s) < 0)\n\n            return -1;\n\n        avctx->delay = 0;\n\n        s->low_delay = 1;\n\n        break;\n\n    case AV_CODEC_ID_H261:\n\n        if (!CONFIG_H261_ENCODER)\n\n            return -1;\n\n        if (ff_h261_get_picture_format(s->width, s->height) < 0) {\n\n            av_log(avctx, AV_LOG_ERROR,\n\n                   \"The specified picture size of %dx%d is not valid for the \"\n\n                   \"H.261 codec.\\nValid sizes are 176x144, 352x288\\n\",\n\n                    s->width, s->height);\n\n            return -1;\n\n        }\n\n        s->out_format = FMT_H261;\n\n        avctx->delay  = 0;\n\n        s->low_delay  = 1;\n\n        s->rtp_mode   = 0; \/* Sliced encoding not supported *\/\n\n        break;\n\n    case AV_CODEC_ID_H263:\n\n        if (!CONFIG_H263_ENCODER)\n\n        return -1;\n\n        if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format),\n\n                             s->width, s->height) == 8) {\n\n            av_log(avctx, AV_LOG_INFO,\n\n                   \"The specified picture size of %dx%d is not valid for \"\n\n                   \"the H.263 codec.\\nValid sizes are 128x96, 176x144, \"\n\n                   \"352x288, 704x576, and 1408x1152.\"\n\n                   \"Try H.263+.\\n\", s->width, s->height);\n\n            return -1;\n\n        }\n\n        s->out_format = FMT_H263;\n\n        avctx->delay  = 0;\n\n        s->low_delay  = 1;\n\n        break;\n\n    case AV_CODEC_ID_H263P:\n\n        s->out_format = FMT_H263;\n\n        s->h263_plus  = 1;\n\n        \/* Fx *\/\n\n        s->h263_aic        = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0;\n\n        s->modified_quant  = s->h263_aic;\n\n        s->loop_filter     = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;\n\n        s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus;\n\n\n\n        \/* \/Fx *\/\n\n        \/* These are just to be sure *\/\n\n        avctx->delay = 0;\n\n        s->low_delay = 1;\n\n        break;\n\n    case AV_CODEC_ID_FLV1:\n\n        s->out_format      = FMT_H263;\n\n        s->h263_flv        = 2; \/* format = 1; 11-bit codes *\/\n\n        s->unrestricted_mv = 1;\n\n        s->rtp_mode  = 0; \/* don't allow GOB *\/\n\n        avctx->delay = 0;\n\n        s->low_delay = 1;\n\n        break;\n\n    case AV_CODEC_ID_RV10:\n\n        s->out_format = FMT_H263;\n\n        avctx->delay  = 0;\n\n        s->low_delay  = 1;\n\n        break;\n\n    case AV_CODEC_ID_RV20:\n\n        s->out_format      = FMT_H263;\n\n        avctx->delay       = 0;\n\n        s->low_delay       = 1;\n\n        s->modified_quant  = 1;\n\n        s->h263_aic        = 1;\n\n        s->h263_plus       = 1;\n\n        s->loop_filter     = 1;\n\n        s->unrestricted_mv = 0;\n\n        break;\n\n    case AV_CODEC_ID_MPEG4:\n\n        s->out_format      = FMT_H263;\n\n        s->h263_pred       = 1;\n\n        s->unrestricted_mv = 1;\n\n        s->low_delay       = s->max_b_frames ? 0 : 1;\n\n        avctx->delay       = s->low_delay ? 0 : (s->max_b_frames + 1);\n\n        break;\n\n    case AV_CODEC_ID_MSMPEG4V2:\n\n        s->out_format      = FMT_H263;\n\n        s->h263_pred       = 1;\n\n        s->unrestricted_mv = 1;\n\n        s->msmpeg4_version = 2;\n\n        avctx->delay       = 0;\n\n        s->low_delay       = 1;\n\n        break;\n\n    case AV_CODEC_ID_MSMPEG4V3:\n\n        s->out_format        = FMT_H263;\n\n        s->h263_pred         = 1;\n\n        s->unrestricted_mv   = 1;\n\n        s->msmpeg4_version   = 3;\n\n        s->flipflop_rounding = 1;\n\n        avctx->delay         = 0;\n\n        s->low_delay         = 1;\n\n        break;\n\n    case AV_CODEC_ID_WMV1:\n\n        s->out_format        = FMT_H263;\n\n        s->h263_pred         = 1;\n\n        s->unrestricted_mv   = 1;\n\n        s->msmpeg4_version   = 4;\n\n        s->flipflop_rounding = 1;\n\n        avctx->delay         = 0;\n\n        s->low_delay         = 1;\n\n        break;\n\n    case AV_CODEC_ID_WMV2:\n\n        s->out_format        = FMT_H263;\n\n        s->h263_pred         = 1;\n\n        s->unrestricted_mv   = 1;\n\n        s->msmpeg4_version   = 5;\n\n        s->flipflop_rounding = 1;\n\n        avctx->delay         = 0;\n\n        s->low_delay         = 1;\n\n        break;\n\n    default:\n\n        return -1;\n\n    }\n\n\n\n    avctx->has_b_frames = !s->low_delay;\n\n\n\n    s->encoding = 1;\n\n\n\n    s->progressive_frame    =\n\n    s->progressive_sequence = !(avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT |\n\n                                                AV_CODEC_FLAG_INTERLACED_ME) ||\n\n                                s->alternate_scan);\n\n\n\n    \/* init *\/\n\n    ff_mpv_idct_init(s);\n\n    if (ff_mpv_common_init(s) < 0)\n\n        return -1;\n\n\n\n    if (ARCH_X86)\n\n        ff_mpv_encode_init_x86(s);\n\n\n\n    ff_fdctdsp_init(&s->fdsp, avctx);\n\n    ff_me_cmp_init(&s->mecc, avctx);\n\n    ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);\n\n    ff_pixblockdsp_init(&s->pdsp, avctx);\n\n    ff_qpeldsp_init(&s->qdsp);\n\n\n\n    if (s->msmpeg4_version) {\n\n        FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,\n\n                          2 * 2 * (MAX_LEVEL + 1) *\n\n                          (MAX_RUN + 1) * 2 * sizeof(int), fail);\n\n    }\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);\n\n\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix,   64 * 32 * sizeof(int), fail);\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix,   64 * 32 * sizeof(int), fail);\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,\n\n                      MAX_PICTURE_COUNT * sizeof(Picture *), fail);\n\n    FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,\n\n                      MAX_PICTURE_COUNT * sizeof(Picture *), fail);\n\n\n\n    if (s->avctx->noise_reduction) {\n\n        FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,\n\n                          2 * 64 * sizeof(uint16_t), fail);\n\n    }\n\n\n\n    if (CONFIG_H263_ENCODER)\n\n        ff_h263dsp_init(&s->h263dsp);\n\n    if (!s->dct_quantize)\n\n        s->dct_quantize = ff_dct_quantize_c;\n\n    if (!s->denoise_dct)\n\n        s->denoise_dct  = denoise_dct_c;\n\n    s->fast_dct_quantize = s->dct_quantize;\n\n    if (avctx->trellis)\n\n        s->dct_quantize  = dct_quantize_trellis_c;\n\n\n\n    if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)\n\n        s->chroma_qscale_table = ff_h263_chroma_qscale_table;\n\n\n\n    s->quant_precision = 5;\n\n\n\n    ff_set_cmp(&s->mecc, s->mecc.ildct_cmp,      s->avctx->ildct_cmp);\n\n    ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->avctx->frame_skip_cmp);\n\n\n\n    if (CONFIG_H261_ENCODER && s->out_format == FMT_H261)\n\n        ff_h261_encode_init(s);\n\n    if (CONFIG_H263_ENCODER && s->out_format == FMT_H263)\n\n        ff_h263_encode_init(s);\n\n    if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)\n\n        if ((ret = ff_msmpeg4_encode_init(s)) < 0)\n\n            return ret;\n\n    if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)\n\n        && s->out_format == FMT_MPEG1)\n\n        ff_mpeg1_encode_init(s);\n\n\n\n    \/* init q matrix *\/\n\n    for (i = 0; i < 64; i++) {\n\n        int j = s->idsp.idct_permutation[i];\n\n        if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 &&\n\n            s->mpeg_quant) {\n\n            s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];\n\n            s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];\n\n        } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {\n\n            s->intra_matrix[j] =\n\n            s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];\n\n        } else {\n\n            \/* mpeg1\/2 *\/\n\n            s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];\n\n            s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];\n\n        }\n\n        if (s->avctx->intra_matrix)\n\n            s->intra_matrix[j] = s->avctx->intra_matrix[i];\n\n        if (s->avctx->inter_matrix)\n\n            s->inter_matrix[j] = s->avctx->inter_matrix[i];\n\n    }\n\n\n\n    \/* precompute matrix *\/\n\n    \/* for mjpeg, we do include qscale in the matrix *\/\n\n    if (s->out_format != FMT_MJPEG) {\n\n        ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,\n\n                          s->intra_matrix, s->intra_quant_bias, avctx->qmin,\n\n                          31, 1);\n\n        ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16,\n\n                          s->inter_matrix, s->inter_quant_bias, avctx->qmin,\n\n                          31, 0);\n\n    }\n\n\n\n    if (ff_rate_control_init(s) < 0)\n\n        return -1;\n\n\n\n#if FF_API_ERROR_RATE\n\n    FF_DISABLE_DEPRECATION_WARNINGS\n\n    if (avctx->error_rate)\n\n        s->error_rate = avctx->error_rate;\n\n    FF_ENABLE_DEPRECATION_WARNINGS;\n\n#endif\n\n\n\n#if FF_API_NORMALIZE_AQP\n\n    FF_DISABLE_DEPRECATION_WARNINGS\n\n    if (avctx->flags & CODEC_FLAG_NORMALIZE_AQP)\n\n        s->mpv_flags |= FF_MPV_FLAG_NAQ;\n\n    FF_ENABLE_DEPRECATION_WARNINGS;\n\n#endif\n\n\n\n#if FF_API_MV0\n\n    FF_DISABLE_DEPRECATION_WARNINGS\n\n    if (avctx->flags & CODEC_FLAG_MV0)\n\n        s->mpv_flags |= FF_MPV_FLAG_MV0;\n\n    FF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n#if FF_API_MPV_OPT\n\n    FF_DISABLE_DEPRECATION_WARNINGS\n\n    if (avctx->rc_qsquish != 0.0)\n\n        s->rc_qsquish = avctx->rc_qsquish;\n\n    if (avctx->rc_qmod_amp != 0.0)\n\n        s->rc_qmod_amp = avctx->rc_qmod_amp;\n\n    if (avctx->rc_qmod_freq)\n\n        s->rc_qmod_freq = avctx->rc_qmod_freq;\n\n    if (avctx->rc_buffer_aggressivity != 1.0)\n\n        s->rc_buffer_aggressivity = avctx->rc_buffer_aggressivity;\n\n    if (avctx->rc_initial_cplx != 0.0)\n\n        s->rc_initial_cplx = avctx->rc_initial_cplx;\n\n    if (avctx->lmin)\n\n        s->lmin = avctx->lmin;\n\n    if (avctx->lmax)\n\n        s->lmax = avctx->lmax;\n\n\n\n    if (avctx->rc_eq) {\n\n        av_freep(&s->rc_eq);\n\n        s->rc_eq = av_strdup(avctx->rc_eq);\n\n        if (!s->rc_eq)\n\n            return AVERROR(ENOMEM);\n\n    }\n\n    FF_ENABLE_DEPRECATION_WARNINGS\n\n#endif\n\n\n\n    if (avctx->b_frame_strategy == 2) {\n\n        for (i = 0; i < s->max_b_frames + 2; i++) {\n\n            s->tmp_frames[i] = av_frame_alloc();\n\n            if (!s->tmp_frames[i])\n\n                return AVERROR(ENOMEM);\n\n\n\n            s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P;\n\n            s->tmp_frames[i]->width  = s->width  >> avctx->brd_scale;\n\n            s->tmp_frames[i]->height = s->height >> avctx->brd_scale;\n\n\n\n            ret = av_frame_get_buffer(s->tmp_frames[i], 32);\n\n            if (ret < 0)\n\n                return ret;\n\n        }\n\n    }\n\n\n\n    return 0;\n\nfail:\n\n    ff_mpv_encode_end(avctx);\n\n    return AVERROR_UNKNOWN;\n\n}\n","target":1,"code_token_length":6943,"total_token_length":7179,"max_tokens_setting":8192}
+{"idx":105598,"func":"WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,\n  const int argc,const char **argv,Image **images,ExceptionInfo *exception)\n{\n  const char\n    *option;\n\n  ImageInfo\n    *mogrify_info;\n\n  MagickStatusType\n    status;\n\n  PixelInterpolateMethod\n   interpolate_method;\n\n  QuantizeInfo\n    *quantize_info;\n\n  register ssize_t\n    i;\n\n  ssize_t\n    count,\n    index;\n\n  \/*\n    Apply options to the image list.\n  *\/\n  assert(image_info != (ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(images != (Image **) NULL);\n  assert((*images)->previous == (Image *) NULL);\n  assert((*images)->signature == MagickCoreSignature);\n  if ((*images)->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      (*images)->filename);\n  if ((argc <= 0) || (*argv == (char *) NULL))\n    return(MagickTrue);\n  interpolate_method=UndefinedInterpolatePixel;\n  mogrify_info=CloneImageInfo(image_info);\n  quantize_info=AcquireQuantizeInfo(mogrify_info);\n  status=MagickTrue;\n  for (i=0; i < (ssize_t) argc; i++)\n  {\n    if (*images == (Image *) NULL)\n      break;\n    option=argv[i];\n    if (IsCommandOption(option) == MagickFalse)\n      continue;\n    count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);\n    count=MagickMax(count,0L);\n    if ((i+count) >= (ssize_t) argc)\n      break;\n    status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);\n    switch (*(option+1))\n    {\n      case 'a':\n      {\n        if (LocaleCompare(\"affinity\",option+1) == 0)\n          {\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            if (*option == '+')\n              {\n                (void) RemapImages(quantize_info,*images,(Image *) NULL,\n                  exception);\n                break;\n              }\n            i++;\n            break;\n          }\n        if (LocaleCompare(\"append\",option+1) == 0)\n          {\n            Image\n              *append_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            append_image=AppendImages(*images,*option == '-' ? MagickTrue :\n              MagickFalse,exception);\n            if (append_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=append_image;\n            break;\n          }\n        if (LocaleCompare(\"average\",option+1) == 0)\n          {\n            Image\n              *average_image;\n\n            \/*\n              Average an image sequence (deprecated).\n            *\/\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            average_image=EvaluateImages(*images,MeanEvaluateOperator,\n              exception);\n            if (average_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=average_image;\n            break;\n          }\n        break;\n      }\n      case 'c':\n      {\n        if (LocaleCompare(\"channel-fx\",option+1) == 0)\n          {\n            Image\n              *channel_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            channel_image=ChannelFxImage(*images,argv[i+1],exception);\n            if (channel_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=channel_image;\n            break;\n          }\n        if (LocaleCompare(\"clut\",option+1) == 0)\n          {\n            Image\n              *clut_image,\n              *image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            image=RemoveFirstImageFromList(images);\n            clut_image=RemoveFirstImageFromList(images);\n            if (clut_image == (Image *) NULL)\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"ImageSequenceRequired\",\"`%s'\",option);\n                image=DestroyImage(image);\n                status=MagickFalse;\n                break;\n              }\n            (void) ClutImage(image,clut_image,interpolate_method,exception);\n            clut_image=DestroyImage(clut_image);\n            *images=DestroyImageList(*images);\n            *images=image;\n            break;\n          }\n        if (LocaleCompare(\"coalesce\",option+1) == 0)\n          {\n            Image\n              *coalesce_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            coalesce_image=CoalesceImages(*images,exception);\n            if (coalesce_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=coalesce_image;\n            break;\n          }\n        if (LocaleCompare(\"combine\",option+1) == 0)\n          {\n            ColorspaceType\n              colorspace;\n\n            Image\n              *combine_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            colorspace=(*images)->colorspace;\n            if ((*images)->number_channels < GetImageListLength(*images))\n              colorspace=sRGBColorspace;\n            if (*option == '+')\n              colorspace=(ColorspaceType) ParseCommandOption(\n                MagickColorspaceOptions,MagickFalse,argv[i+1]);\n            combine_image=CombineImages(*images,colorspace,exception);\n            if (combine_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=combine_image;\n            break;\n          }\n        if (LocaleCompare(\"compare\",option+1) == 0)\n          {\n            double\n              distortion;\n\n            Image\n              *difference_image,\n              *image,\n              *reconstruct_image;\n\n            MetricType\n              metric;\n\n            \/*\n              Mathematically and visually annotate the difference between an\n              image and its reconstruction.\n            *\/\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            image=RemoveFirstImageFromList(images);\n            reconstruct_image=RemoveFirstImageFromList(images);\n            if (reconstruct_image == (Image *) NULL)\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"ImageSequenceRequired\",\"`%s'\",option);\n                image=DestroyImage(image);\n                status=MagickFalse;\n                break;\n              }\n            metric=UndefinedErrorMetric;\n            option=GetImageOption(mogrify_info,\"metric\");\n            if (option != (const char *) NULL)\n              metric=(MetricType) ParseCommandOption(MagickMetricOptions,\n                MagickFalse,option);\n            difference_image=CompareImages(image,reconstruct_image,metric,\n              &distortion,exception);\n            if (difference_image == (Image *) NULL)\n              break;\n            reconstruct_image=DestroyImage(reconstruct_image);\n            image=DestroyImage(image);\n            if (*images != (Image *) NULL)\n              *images=DestroyImageList(*images);\n            *images=difference_image;\n            break;\n          }\n        if (LocaleCompare(\"complex\",option+1) == 0)\n          {\n            ComplexOperator\n              op;\n\n            Image\n              *complex_images;\n\n            (void) SyncImageSettings(mogrify_info,*images,exception);\n            op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,\n              MagickFalse,argv[i+1]);\n            complex_images=ComplexImages(*images,op,exception);\n            if (complex_images == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=complex_images;\n            break;\n          }\n        if (LocaleCompare(\"composite\",option+1) == 0)\n          {\n            CompositeOperator\n              compose;\n\n            const char*\n              value;\n\n            MagickBooleanType\n              clip_to_self;\n\n            Image\n              *mask_image,\n              *new_images,\n              *source_image;\n\n            RectangleInfo\n              geometry;\n\n            \/* Compose value from \"-compose\" option only *\/\n            (void) SyncImageSettings(mogrify_info,*images,exception);\n            value=GetImageOption(mogrify_info,\"compose\");\n            if (value == (const char *) NULL)\n              compose=OverCompositeOp;  \/* use Over not source_image->compose *\/\n            else\n              compose=(CompositeOperator) ParseCommandOption(\n                MagickComposeOptions,MagickFalse,value);\n\n            \/* Get \"clip-to-self\" expert setting (false is normal) *\/\n            clip_to_self=GetCompositeClipToSelf(compose);\n            value=GetImageOption(mogrify_info,\"compose:clip-to-self\");\n            if (value != (const char *) NULL)\n              clip_to_self=IsStringTrue(value);\n            value=GetImageOption(mogrify_info,\"compose:outside-overlay\");\n            if (value != (const char *) NULL)\n              clip_to_self=IsStringFalse(value);  \/* deprecated *\/\n\n            new_images=RemoveFirstImageFromList(images);\n            source_image=RemoveFirstImageFromList(images);\n            if (source_image == (Image *) NULL)\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"ImageSequenceRequired\",\"`%s'\",option);\n                new_images=DestroyImage(new_images);\n                status=MagickFalse;\n                break;\n              }\n\n            \/* FUTURE: this should not be here! - should be part of -geometry *\/\n            if (source_image->geometry != (char *) NULL)\n              {\n                RectangleInfo\n                  resize_geometry;\n\n                (void) ParseRegionGeometry(source_image,source_image->geometry,\n                  &resize_geometry,exception);\n                if ((source_image->columns != resize_geometry.width) ||\n                    (source_image->rows != resize_geometry.height))\n                  {\n                    Image\n                      *resize_image;\n\n                    resize_image=ResizeImage(source_image,resize_geometry.width,\n                      resize_geometry.height,source_image->filter,exception);\n                    if (resize_image != (Image *) NULL)\n                      {\n                        source_image=DestroyImage(source_image);\n                        source_image=resize_image;\n                      }\n                  }\n              }\n            SetGeometry(source_image,&geometry);\n            (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);\n            GravityAdjustGeometry(new_images->columns,new_images->rows,\n              new_images->gravity,&geometry);\n            mask_image=RemoveFirstImageFromList(images);\n            if (mask_image == (Image *) NULL)\n              status&=CompositeImage(new_images,source_image,compose,\n                clip_to_self,geometry.x,geometry.y,exception);\n            else\n              {\n                if ((compose == DisplaceCompositeOp) ||\n                    (compose == DistortCompositeOp))\n                  {\n                    status&=CompositeImage(source_image,mask_image,\n                      CopyGreenCompositeOp,MagickTrue,0,0,exception);\n                    status&=CompositeImage(new_images,source_image,compose,\n                      clip_to_self,geometry.x,geometry.y,exception);\n                  }\n                else\n                  {\n                    Image\n                      *clone_image;\n\n                    clone_image=CloneImage(new_images,0,0,MagickTrue,exception);\n                    if (clone_image == (Image *) NULL)\n                      break;\n                    status&=CompositeImage(new_images,source_image,compose,\n                      clip_to_self,geometry.x,geometry.y,exception);\n                    status&=CompositeImage(new_images,mask_image,\n                      CopyAlphaCompositeOp,MagickTrue,0,0,exception);\n                    status&=CompositeImage(clone_image,new_images,\n                      OverCompositeOp,clip_to_self,0,0,exception);\n                    new_images=DestroyImageList(new_images);\n                    new_images=clone_image;\n                  }\n                mask_image=DestroyImage(mask_image);\n              }\n            source_image=DestroyImage(source_image);\n            *images=DestroyImageList(*images);\n            *images=new_images;\n            break;\n          }\n        if (LocaleCompare(\"copy\",option+1) == 0)\n          {\n            Image\n              *source_image;\n\n            OffsetInfo\n              offset;\n\n            RectangleInfo\n              geometry;\n\n            \/*\n              Copy image pixels.\n            *\/\n            (void) SyncImageSettings(mogrify_info,*images,exception);\n            (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);\n            offset.x=geometry.x;\n            offset.y=geometry.y;\n            source_image=(*images);\n            if (source_image->next != (Image *) NULL)\n              source_image=source_image->next;\n            (void) ParsePageGeometry(source_image,argv[i+1],&geometry,\n              exception);\n            status=CopyImagePixels(*images,source_image,&geometry,&offset,\n              exception);\n            break;\n          }\n        break;\n      }\n      case 'd':\n      {\n        if (LocaleCompare(\"deconstruct\",option+1) == 0)\n          {\n            Image\n              *deconstruct_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,\n              exception);\n            if (deconstruct_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=deconstruct_image;\n            break;\n          }\n        if (LocaleCompare(\"delete\",option+1) == 0)\n          {\n            if (*option == '+')\n              DeleteImages(images,\"-1\",exception);\n            else\n              DeleteImages(images,argv[i+1],exception);\n            break;\n          }\n        if (LocaleCompare(\"dither\",option+1) == 0)\n          {\n            if (*option == '+')\n              {\n                quantize_info->dither_method=NoDitherMethod;\n                break;\n              }\n            quantize_info->dither_method=(DitherMethod) ParseCommandOption(\n              MagickDitherOptions,MagickFalse,argv[i+1]);\n            break;\n          }\n        if (LocaleCompare(\"duplicate\",option+1) == 0)\n          {\n            Image\n              *duplicate_images;\n\n            if (*option == '+')\n              duplicate_images=DuplicateImages(*images,1,\"-1\",exception);\n            else\n              {\n                const char\n                  *p;\n\n                size_t\n                  number_duplicates;\n\n                number_duplicates=(size_t) StringToLong(argv[i+1]);\n                p=strchr(argv[i+1],',');\n                if (p == (const char *) NULL)\n                  duplicate_images=DuplicateImages(*images,number_duplicates,\n                    \"-1\",exception);\n                else\n                  duplicate_images=DuplicateImages(*images,number_duplicates,p,\n                    exception);\n              }\n            AppendImageToList(images, duplicate_images);\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            break;\n          }\n        break;\n      }\n      case 'e':\n      {\n        if (LocaleCompare(\"evaluate-sequence\",option+1) == 0)\n          {\n            Image\n              *evaluate_image;\n\n            MagickEvaluateOperator\n              op;\n\n            (void) SyncImageSettings(mogrify_info,*images,exception);\n            op=(MagickEvaluateOperator) ParseCommandOption(\n              MagickEvaluateOptions,MagickFalse,argv[i+1]);\n            evaluate_image=EvaluateImages(*images,op,exception);\n            if (evaluate_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=evaluate_image;\n            break;\n          }\n        break;\n      }\n      case 'f':\n      {\n        if (LocaleCompare(\"fft\",option+1) == 0)\n          {\n            Image\n              *fourier_image;\n\n            \/*\n              Implements the discrete Fourier transform (DFT).\n            *\/\n            (void) SyncImageSettings(mogrify_info,*images,exception);\n            fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?\n              MagickTrue : MagickFalse,exception);\n            if (fourier_image == (Image *) NULL)\n              break;\n            *images=DestroyImageList(*images);\n            *images=fourier_image;\n            break;\n          }\n        if (LocaleCompare(\"flatten\",option+1) == 0)\n          {\n            Image\n              *flatten_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            flatten_image=MergeImageLayers(*images,FlattenLayer,exception);\n            if (flatten_image == (Image *) NULL)\n              break;\n            *images=DestroyImageList(*images);\n            *images=flatten_image;\n            break;\n          }\n        if (LocaleCompare(\"fx\",option+1) == 0)\n          {\n            Image\n              *fx_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            fx_image=FxImage(*images,argv[i+1],exception);\n            if (fx_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=fx_image;\n            break;\n          }\n        break;\n      }\n      case 'h':\n      {\n        if (LocaleCompare(\"hald-clut\",option+1) == 0)\n          {\n            Image\n              *hald_image,\n              *image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            image=RemoveFirstImageFromList(images);\n            hald_image=RemoveFirstImageFromList(images);\n            if (hald_image == (Image *) NULL)\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"ImageSequenceRequired\",\"`%s'\",option);\n                image=DestroyImage(image);\n                status=MagickFalse;\n                break;\n              }\n            (void) HaldClutImage(image,hald_image,exception);\n            hald_image=DestroyImage(hald_image);\n            if (*images != (Image *) NULL)\n              *images=DestroyImageList(*images);\n            *images=image;\n            break;\n          }\n        break;\n      }\n      case 'i':\n      {\n        if (LocaleCompare(\"ift\",option+1) == 0)\n          {\n            Image\n              *fourier_image,\n              *magnitude_image,\n              *phase_image;\n\n            \/*\n              Implements the inverse fourier discrete Fourier transform (DFT).\n            *\/\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            magnitude_image=RemoveFirstImageFromList(images);\n            phase_image=RemoveFirstImageFromList(images);\n            if (phase_image == (Image *) NULL)\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"ImageSequenceRequired\",\"`%s'\",option);\n                magnitude_image=DestroyImage(magnitude_image);\n                status=MagickFalse;\n                break;\n              }\n            fourier_image=InverseFourierTransformImage(magnitude_image,\n              phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);\n            magnitude_image=DestroyImage(magnitude_image);\n            phase_image=DestroyImage(phase_image);\n            if (fourier_image == (Image *) NULL)\n              break;\n            if (*images != (Image *) NULL)\n              *images=DestroyImageList(*images);\n            *images=fourier_image;\n            break;\n          }\n        if (LocaleCompare(\"insert\",option+1) == 0)\n          {\n            Image\n              *p,\n              *q;\n\n            index=0;\n            if (*option != '+')\n              index=(ssize_t) StringToLong(argv[i+1]);\n            p=RemoveLastImageFromList(images);\n            if (p == (Image *) NULL)\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"NoSuchImage\",\"`%s'\",argv[i+1]);\n                status=MagickFalse;\n                break;\n              }\n            q=p;\n            if (index == 0)\n              PrependImageToList(images,q);\n            else\n              if (index == (ssize_t) GetImageListLength(*images))\n                AppendImageToList(images,q);\n              else\n                {\n                   q=GetImageFromList(*images,index-1);\n                   if (q == (Image *) NULL)\n                     {\n                       p=DestroyImage(p);\n                       (void) ThrowMagickException(exception,GetMagickModule(),\n                         OptionError,\"NoSuchImage\",\"`%s'\",argv[i+1]);\n                       status=MagickFalse;\n                       break;\n                     }\n                  InsertImageInList(&q,p);\n                }\n            *images=GetFirstImageInList(q);\n            break;\n          }\n        if (LocaleCompare(\"interpolate\",option+1) == 0)\n          {\n            interpolate_method=(PixelInterpolateMethod) ParseCommandOption(\n              MagickInterpolateOptions,MagickFalse,argv[i+1]);\n            break;\n          }\n        break;\n      }\n      case 'l':\n      {\n        if (LocaleCompare(\"layers\",option+1) == 0)\n          {\n            Image\n              *layers;\n\n            LayerMethod\n              method;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            layers=(Image *) NULL;\n            method=(LayerMethod) ParseCommandOption(MagickLayerOptions,\n              MagickFalse,argv[i+1]);\n            switch (method)\n            {\n              case CoalesceLayer:\n              {\n                layers=CoalesceImages(*images,exception);\n                break;\n              }\n              case CompareAnyLayer:\n              case CompareClearLayer:\n              case CompareOverlayLayer:\n              default:\n              {\n                layers=CompareImagesLayers(*images,method,exception);\n                break;\n              }\n              case MergeLayer:\n              case FlattenLayer:\n              case MosaicLayer:\n              case TrimBoundsLayer:\n              {\n                layers=MergeImageLayers(*images,method,exception);\n                break;\n              }\n              case DisposeLayer:\n              {\n                layers=DisposeImages(*images,exception);\n                break;\n              }\n              case OptimizeImageLayer:\n              {\n                layers=OptimizeImageLayers(*images,exception);\n                break;\n              }\n              case OptimizePlusLayer:\n              {\n                layers=OptimizePlusImageLayers(*images,exception);\n                break;\n              }\n              case OptimizeTransLayer:\n              {\n                OptimizeImageTransparency(*images,exception);\n                break;\n              }\n              case RemoveDupsLayer:\n              {\n                RemoveDuplicateLayers(images,exception);\n                break;\n              }\n              case RemoveZeroLayer:\n              {\n                RemoveZeroDelayLayers(images,exception);\n                break;\n              }\n              case OptimizeLayer:\n              {\n                \/*\n                  General Purpose, GIF Animation Optimizer.\n                *\/\n                layers=CoalesceImages(*images,exception);\n                if (layers == (Image *) NULL)\n                  {\n                    status=MagickFalse;\n                    break;\n                  }\n                *images=DestroyImageList(*images);\n                *images=layers;\n                layers=OptimizeImageLayers(*images,exception);\n                if (layers == (Image *) NULL)\n                  {\n                    status=MagickFalse;\n                    break;\n                  }\n                *images=DestroyImageList(*images);\n                *images=layers;\n                layers=(Image *) NULL;\n                OptimizeImageTransparency(*images,exception);\n                (void) RemapImages(quantize_info,*images,(Image *) NULL,\n                  exception);\n                break;\n              }\n              case CompositeLayer:\n              {\n                CompositeOperator\n                  compose;\n\n                Image\n                  *source;\n\n                RectangleInfo\n                  geometry;\n\n                \/*\n                  Split image sequence at the first 'NULL:' image.\n                *\/\n                source=(*images);\n                while (source != (Image *) NULL)\n                {\n                  source=GetNextImageInList(source);\n                  if ((source != (Image *) NULL) &&\n                      (LocaleCompare(source->magick,\"NULL\") == 0))\n                    break;\n                }\n                if (source != (Image *) NULL)\n                  {\n                    if ((GetPreviousImageInList(source) == (Image *) NULL) ||\n                        (GetNextImageInList(source) == (Image *) NULL))\n                      source=(Image *) NULL;\n                    else\n                      {\n                        \/*\n                          Separate the two lists, junk the null: image.\n                        *\/\n                        source=SplitImageList(source->previous);\n                        DeleteImageFromList(&source);\n                      }\n                  }\n                if (source == (Image *) NULL)\n                  {\n                    (void) ThrowMagickException(exception,GetMagickModule(),\n                      OptionError,\"MissingNullSeparator\",\"layers Composite\");\n                    status=MagickFalse;\n                    break;\n                  }\n                \/*\n                  Adjust offset with gravity and virtual canvas.\n                *\/\n                SetGeometry(*images,&geometry);\n                (void) ParseAbsoluteGeometry((*images)->geometry,&geometry);\n                geometry.width=source->page.width != 0 ?\n                  source->page.width : source->columns;\n                geometry.height=source->page.height != 0 ?\n                 source->page.height : source->rows;\n                GravityAdjustGeometry((*images)->page.width != 0 ?\n                  (*images)->page.width : (*images)->columns,\n                  (*images)->page.height != 0 ? (*images)->page.height :\n                  (*images)->rows,(*images)->gravity,&geometry);\n                compose=OverCompositeOp;\n                option=GetImageOption(mogrify_info,\"compose\");\n                if (option != (const char *) NULL)\n                  compose=(CompositeOperator) ParseCommandOption(\n                    MagickComposeOptions,MagickFalse,option);\n                CompositeLayers(*images,compose,source,geometry.x,geometry.y,\n                  exception);\n                source=DestroyImageList(source);\n                break;\n              }\n            }\n            if (layers == (Image *) NULL)\n              break;\n            *images=DestroyImageList(*images);\n            *images=layers;\n            break;\n          }\n        break;\n      }\n      case 'm':\n      {\n        if (LocaleCompare(\"map\",option+1) == 0)\n          {\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            if (*option == '+')\n              {\n                (void) RemapImages(quantize_info,*images,(Image *) NULL,\n                  exception);\n                break;\n              }\n            i++;\n            break;\n          }\n        if (LocaleCompare(\"maximum\",option+1) == 0)\n          {\n            Image\n              *maximum_image;\n\n            \/*\n              Maximum image sequence (deprecated).\n            *\/\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);\n            if (maximum_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=maximum_image;\n            break;\n          }\n        if (LocaleCompare(\"minimum\",option+1) == 0)\n          {\n            Image\n              *minimum_image;\n\n            \/*\n              Minimum image sequence (deprecated).\n            *\/\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);\n            if (minimum_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=minimum_image;\n            break;\n          }\n        if (LocaleCompare(\"morph\",option+1) == 0)\n          {\n            Image\n              *morph_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),\n              exception);\n            if (morph_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=morph_image;\n            break;\n          }\n        if (LocaleCompare(\"mosaic\",option+1) == 0)\n          {\n            Image\n              *mosaic_image;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);\n            if (mosaic_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=mosaic_image;\n            break;\n          }\n        break;\n      }\n      case 'p':\n      {\n        if (LocaleCompare(\"poly\",option+1) == 0)\n          {\n            char\n              *args,\n              token[MagickPathExtent];\n\n            const char\n              *p;\n\n            double\n              *arguments;\n\n            Image\n              *polynomial_image;\n\n            register ssize_t\n              x;\n\n            size_t\n              number_arguments;\n\n            \/*\n              Polynomial image.\n            *\/\n            (void) SyncImageSettings(mogrify_info,*images,exception);\n            args=InterpretImageProperties(mogrify_info,*images,argv[i+1],\n              exception);\n            if (args == (char *) NULL)\n              break;\n            p=(char *) args;\n            for (x=0; *p != '\\0'; x++)\n            {\n              GetNextToken(p,&p,MagickPathExtent,token);\n              if (*token == ',')\n                GetNextToken(p,&p,MagickPathExtent,token);\n            }\n            number_arguments=(size_t) x;\n            arguments=(double *) AcquireQuantumMemory(number_arguments,\n              sizeof(*arguments));\n            if (arguments == (double *) NULL)\n              ThrowWandFatalException(ResourceLimitFatalError,\n                \"MemoryAllocationFailed\",(*images)->filename);\n            (void) memset(arguments,0,number_arguments*\n              sizeof(*arguments));\n            p=(char *) args;\n            for (x=0; (x < (ssize_t) number_arguments) && (*p != '\\0'); x++)\n            {\n              GetNextToken(p,&p,MagickPathExtent,token);\n              if (*token == ',')\n                GetNextToken(p,&p,MagickPathExtent,token);\n              arguments[x]=StringToDouble(token,(char **) NULL);\n            }\n            args=DestroyString(args);\n            polynomial_image=PolynomialImage(*images,number_arguments >> 1,\n              arguments,exception);\n            arguments=(double *) RelinquishMagickMemory(arguments);\n            if (polynomial_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=polynomial_image;\n          }\n        if (LocaleCompare(\"print\",option+1) == 0)\n          {\n            char\n              *string;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            string=InterpretImageProperties(mogrify_info,*images,argv[i+1],\n              exception);\n            if (string == (char *) NULL)\n              break;\n            (void) FormatLocaleFile(stdout,\"%s\",string);\n            string=DestroyString(string);\n          }\n        if (LocaleCompare(\"process\",option+1) == 0)\n          {\n            char\n              **arguments;\n\n            int\n              j,\n              number_arguments;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            arguments=StringToArgv(argv[i+1],&number_arguments);\n            if (arguments == (char **) NULL)\n              break;\n            if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))\n              {\n                char\n                  breaker,\n                  quote,\n                  *token;\n\n                const char\n                  *argument;\n\n                int\n                  next,\n                  token_status;\n\n                size_t\n                  length;\n\n                TokenInfo\n                  *token_info;\n\n                \/*\n                  Support old style syntax, filter=\"-option arg\".\n                *\/\n                length=strlen(argv[i+1]);\n                token=(char *) NULL;\n                if (~length >= (MagickPathExtent-1))\n                  token=(char *) AcquireQuantumMemory(length+MagickPathExtent,\n                    sizeof(*token));\n                if (token == (char *) NULL)\n                  break;\n                next=0;\n                argument=argv[i+1];\n                token_info=AcquireTokenInfo();\n                token_status=Tokenizer(token_info,0,token,length,argument,\"\",\n                  \"=\",\"\\\"\",'\\0',&breaker,&next,"e);\n                token_info=DestroyTokenInfo(token_info);\n                if (token_status == 0)\n                  {\n                    const char\n                      *arg;\n\n                    arg=(&(argument[next]));\n                    (void) InvokeDynamicImageFilter(token,&(*images),1,&arg,\n                      exception);\n                  }\n                token=DestroyString(token);\n                break;\n              }\n            (void) SubstituteString(&arguments[1],\"-\",\"\");\n            (void) InvokeDynamicImageFilter(arguments[1],&(*images),\n              number_arguments-2,(const char **) arguments+2,exception);\n            for (j=0; j < number_arguments; j++)\n              arguments[j]=DestroyString(arguments[j]);\n            arguments=(char **) RelinquishMagickMemory(arguments);\n            break;\n          }\n        break;\n      }\n      case 'r':\n      {\n        if (LocaleCompare(\"reverse\",option+1) == 0)\n          {\n            ReverseImageList(images);\n            break;\n          }\n        break;\n      }\n      case 's':\n      {\n        if (LocaleCompare(\"smush\",option+1) == 0)\n          {\n            Image\n              *smush_image;\n\n            ssize_t\n              offset;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            offset=(ssize_t) StringToLong(argv[i+1]);\n            smush_image=SmushImages(*images,*option == '-' ? MagickTrue :\n              MagickFalse,offset,exception);\n            if (smush_image == (Image *) NULL)\n              {\n                status=MagickFalse;\n                break;\n              }\n            *images=DestroyImageList(*images);\n            *images=smush_image;\n            break;\n          }\n        if (LocaleCompare(\"swap\",option+1) == 0)\n          {\n            Image\n              *p,\n              *q,\n              *u,\n              *v;\n\n            ssize_t\n              swap_index;\n\n            index=(-1);\n            swap_index=(-2);\n            if (*option != '+')\n              {\n                GeometryInfo\n                  geometry_info;\n\n                MagickStatusType\n                  flags;\n\n                swap_index=(-1);\n                flags=ParseGeometry(argv[i+1],&geometry_info);\n                index=(ssize_t) geometry_info.rho;\n                if ((flags & SigmaValue) != 0)\n                  swap_index=(ssize_t) geometry_info.sigma;\n              }\n            p=GetImageFromList(*images,index);\n            q=GetImageFromList(*images,swap_index);\n            if ((p == (Image *) NULL) || (q == (Image *) NULL))\n              {\n                (void) ThrowMagickException(exception,GetMagickModule(),\n                  OptionError,\"NoSuchImage\",\"`%s'\",(*images)->filename);\n                status=MagickFalse;\n                break;\n              }\n            if (p == q)\n              break;\n            u=CloneImage(p,0,0,MagickTrue,exception);\n            if (u == (Image *) NULL)\n              break;\n            v=CloneImage(q,0,0,MagickTrue,exception);\n            if (v == (Image *) NULL)\n              {\n                u=DestroyImage(u);\n                break;\n              }\n            ReplaceImageInList(&p,v);\n            ReplaceImageInList(&q,u);\n            *images=GetFirstImageInList(q);\n            break;\n          }\n        break;\n      }\n      case 'w':\n      {\n        if (LocaleCompare(\"write\",option+1) == 0)\n          {\n            char\n              key[MagickPathExtent];\n\n            Image\n              *write_images;\n\n            ImageInfo\n              *write_info;\n\n            (void) SyncImagesSettings(mogrify_info,*images,exception);\n            (void) FormatLocaleString(key,MagickPathExtent,\"cache:%s\",\n              argv[i+1]);\n            (void) DeleteImageRegistry(key);\n            write_images=(*images);\n            if (*option == '+')\n              write_images=CloneImageList(*images,exception);\n            write_info=CloneImageInfo(mogrify_info);\n            status&=WriteImages(write_info,write_images,argv[i+1],exception);\n            write_info=DestroyImageInfo(write_info);\n            if (*option == '+')\n              write_images=DestroyImageList(write_images);\n            break;\n          }\n        break;\n      }\n      default:\n        break;\n    }\n    i+=count;\n  }\n  quantize_info=DestroyQuantizeInfo(quantize_info);\n  mogrify_info=DestroyImageInfo(mogrify_info);\n  status&=MogrifyImageInfo(image_info,argc,argv,exception);\n  return(status != 0 ? MagickTrue : MagickFalse);\n}","target":0,"code_token_length":7845,"total_token_length":8081,"max_tokens_setting":8192}
+{"idx":1,"func":"unsigned long # define BN_LONG long # define BN_BITS 128 # define BN_BYTES 8 # define BN_BITS2 64 # define BN_BITS4 32 # define BN_MASK ( 0xffffffffffffffffffffffffffffffffLL ) # define BN_MASK2 ( 0xffffffffffffffffL ) # define BN_MASK2l ( 0xffffffffL ) # define BN_MASK2h ( 0xffffffff00000000L ) # define BN_MASK2h1 ( 0xffffffff80000000L ) # define BN_TBIT ( 0x8000000000000000L ) # define BN_DEC_CONV ( 10000000000000000000UL ) # define BN_DEC_FMT1 \"%lu\" # define BN_DEC_FMT2 \"%019lu\" # define BN_DEC_NUM 19 # define BN_HEX_FMT1 \"%lX\" # define BN_HEX_FMT2 \"%016lX\" # endif # ifdef SIXTY_FOUR_BIT # undef BN_LLONG # undef BN_ULLONG # define BN_ULONG unsigned long long # define BN_LONG long long # define BN_BITS 128 # define BN_BYTES 8 # define BN_BITS2 64 # define BN_BITS4 32 # define BN_MASK2 ( 0xffffffffffffffffLL ) # define BN_MASK2l ( 0xffffffffL ) # define BN_MASK2h ( 0xffffffff00000000LL ) # define BN_MASK2h1 ( 0xffffffff80000000LL ) # define BN_TBIT ( 0x8000000000000000LL ) # define BN_DEC_CONV ( 10000000000000000000ULL ) # define BN_DEC_FMT1 \"%llu\" # define BN_DEC_FMT2 \"%019llu\" # define BN_DEC_NUM 19 # define BN_HEX_FMT1 \"%llX\" # define BN_HEX_FMT2 \"%016llX\" # endif # ifdef THIRTY_TWO_BIT # ifdef BN_LLONG # if defined ( _WIN32 ) && ! defined ( __GNUC__ ) # define BN_ULLONG unsigned __int64 # define BN_MASK ( 0xffffffffffffffffI64 ) # else # define BN_ULLONG unsigned long long # define BN_MASK ( 0xffffffffffffffffLL ) # endif # endif # define BN_ULONG unsigned int # define BN_LONG int # define BN_BITS 64 # define BN_BYTES 4 # define BN_BITS2 32 # define BN_BITS4 16 # define BN_MASK2 ( 0xffffffffL ) # define BN_MASK2l ( 0xffff ) # define BN_MASK2h1 ( 0xffff8000L ) # define BN_MASK2h ( 0xffff0000L ) # define BN_TBIT ( 0x80000000L ) # define BN_DEC_CONV ( 1000000000L ) # define BN_DEC_FMT1 \"%u\" # define BN_DEC_FMT2 \"%09u\" # define BN_DEC_NUM 9 # define BN_HEX_FMT1 \"%X\" # define BN_HEX_FMT2 \"%08X\" # endif # define BN_DEFAULT_BITS 1280 # define BN_FLG_MALLOCED 0x01 # define BN_FLG_STATIC_DATA 0x02 # define BN_FLG_CONSTTIME 0x04 # ifndef OPENSSL_NO_DEPRECATED # define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME # endif # ifndef OPENSSL_NO_DEPRECATED # define BN_FLG_FREE 0x8000 # endif # define BN_set_flags ( b , n ) ( ( b ) -> flags |= ( n ) ) # define BN_get_flags ( b , n ) ( ( b ) -> flags & ( n ) ) # define BN_with_flags ( dest , b , n ) ( ( dest ) -> d = ( b ) -> d , \\ ( dest ) -> top = ( b ) -> top , \\ ( dest ) -> dmax = ( b ) -> dmax , \\ ( dest ) -> neg = ( b ) -> neg , \\ ( dest ) -> flags = ( ( ( dest ) -> flags & BN_FLG_MALLOCED ) \\ | ( ( b ) -> flags & ~ BN_FLG_MALLOCED ) \\ | BN_FLG_STATIC_DATA \\ | ( n ) ) ) # if 0 typedef struct bignum_st BIGNUM ;\n typedef struct bignum_ctx BN_CTX ;\n typedef struct bn_blinding_st BN_BLINDING ;\n typedef struct bn_mont_ctx_st BN_MONT_CTX ;\n typedef struct bn_recp_ctx_st BN_RECP_CTX ;\n typedef struct bn_gencb_st BN_GENCB ;\n # endif struct bignum_st {\n BN_ULONG * d ;\n int top ;\n int dmax ;\n int neg ;\n int flags ;\n }\n ;\n struct bn_mont_ctx_st {\n int ri ;\n BIGNUM RR ;\n BIGNUM N ;\n BIGNUM Ni ;\n BN_ULONG n0 [ 2 ] ;\n int flags ;\n }\n ;\n struct bn_recp_ctx_st {\n BIGNUM N ;\n BIGNUM Nr ;\n int num_bits ;\n int shift ;\n int flags ;\n }\n ;\n struct bn_gencb_st {\n unsigned int ver ;\n void * arg ;\n union {\n void ( * cb_1 ) ( int , int , void * ) ;\n int ( * cb_2 ) ( int , int , BN_GENCB * ) ;\n }\n cb ;\n }\n ;\n int BN_GENCB_call ( BN_GENCB * cb , int a , int b ) ;\n # define BN_GENCB_set_old ( gencb , callback , cb_arg ) {\n \\ BN_GENCB * tmp_gencb = ( gencb ) ;\n \\ tmp_gencb -> ver = 1 ;\n \\ tmp_gencb -> arg = ( cb_arg ) ;\n \\ tmp_gencb -> cb . cb_1 = ( callback ) ;\n }\n # define BN_GENCB_set ( gencb , callback , cb_arg ) {\n \\ BN_GENCB * tmp_gencb = ( gencb ) ;\n \\ tmp_gencb -> ver = 2 ;\n \\ tmp_gencb -> arg = ( cb_arg ) ;\n \\ tmp_gencb -> cb . cb_2 = ( callback ) ;\n }\n # define BN_prime_checks 0 # define BN_prime_checks_for_size ( b ) ( ( b ) >= 1300 ? 2 : \\ ( b ) >= 850 ? 3 : \\ ( b ) >= 650 ? 4 : \\ ( b ) >= 550 ? 5 : \\ ( b ) >= 450 ? 6 : \\ ( b ) >= 400 ? 7 : \\ ( b ) >= 350 ? 8 : \\ ( b ) >= 300 ? 9 : \\ ( b ) >= 250 ? 12 : \\ ( b ) >= 200 ? 15 : \\ ( b ) >= 150 ? 18 : \\ 27 ) # define BN_num_bytes ( a ) ( ( BN_num_bits ( a ) + 7 ) \/ 8 ) # define BN_abs_is_word ( a , w ) ( ( ( ( a ) -> top == 1 ) && ( ( a ) -> d [ 0 ] == ( BN_ULONG ) ( w ) ) ) || \\ ( ( ( w ) == 0 ) && ( ( a ) -> top == 0 ) ) ) # define BN_is_zero ( a ) ( ( a ) -> top == 0 ) # define BN_is_one ( a ) ( BN_abs_is_word ( ( a ) , 1 ) && ! ( a ) -> neg ) # define BN_is_word ( a , w ) ( BN_abs_is_word ( ( a ) , ( w ) ) && ( ! ( w ) || ! ( a ) -> neg ) ) # define BN_is_odd ( a ) ( ( ( a ) -> top > 0 ) && ( ( a ) -> d [ 0 ] & 1 ) ) # define BN_one ( a ) ( BN_set_word ( ( a ) , 1 ) ) # define BN_zero_ex ( a ) \\ do {\n \\ BIGNUM * _tmp_bn = ( a ) ;\n \\ _tmp_bn -> top = 0 ;\n \\ _tmp_bn -> neg = 0 ;\n \\ }\n while ( 0 ) # ifdef OPENSSL_NO_DEPRECATED # define BN_zero ( a ) BN_zero_ex ( a ) # else # define BN_zero ( a ) ( BN_set_word ( ( a ) , 0 ) ) # endif const BIGNUM * BN_value_one ( void ) ;\n char * BN_options ( void ) ;\n BN_CTX * BN_CTX_new ( void ) ;\n # ifndef OPENSSL_NO_DEPRECATED void BN_CTX_init ( BN_CTX * c ) ;\n # endif void BN_CTX_free ( BN_CTX * c ) ;\n void BN_CTX_start ( BN_CTX * ctx ) ;\n BIGNUM * BN_CTX_get ( BN_CTX * ctx ) ;\n void BN_CTX_end ( BN_CTX * ctx ) ;\n int BN_rand ( BIGNUM * rnd , int bits , int top , int bottom ) ;\n int BN_pseudo_rand ( BIGNUM * rnd , int bits , int top , int bottom ) ;\n int BN_rand_range ( BIGNUM * rnd , const BIGNUM * range ) ;\n int BN_pseudo_rand_range ( BIGNUM * rnd , const BIGNUM * range ) ;\n int BN_num_bits ( const BIGNUM * a ) ;\n int BN_num_bits_word ( BN_ULONG l ) ;\n BIGNUM * BN_new ( void ) ;\n void BN_init ( BIGNUM * ) ;\n void BN_clear_free ( BIGNUM * a ) ;\n BIGNUM * BN_copy ( BIGNUM * a , const BIGNUM * b ) ;\n void BN_swap ( BIGNUM * a , BIGNUM * b ) ;\n BIGNUM * BN_bin2bn ( const unsigned char * s , int len , BIGNUM * ret ) ;\n int BN_bn2bin ( const BIGNUM * a , unsigned char * to ) ;\n BIGNUM * BN_mpi2bn ( const unsigned char * s , int len , BIGNUM * ret ) ;\n int BN_bn2mpi ( const BIGNUM * a , unsigned char * to ) ;\n int BN_sub ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_usub ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_uadd ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_add ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_mul ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , BN_CTX * ctx ) ;\n int BN_sqr ( BIGNUM * r , const BIGNUM * a , BN_CTX * ctx ) ;\n void BN_set_negative ( BIGNUM * b , int n ) ;\n # define BN_is_negative ( a ) ( ( a ) -> neg != 0 ) int BN_div ( BIGNUM * dv , BIGNUM * rem , const BIGNUM * m , const BIGNUM * d , BN_CTX * ctx ) ;\n # define BN_mod ( rem , m , d , ctx ) BN_div ( NULL , ( rem ) , ( m ) , ( d ) , ( ctx ) ) int BN_nnmod ( BIGNUM * r , const BIGNUM * m , const BIGNUM * d , BN_CTX * ctx ) ;\n int BN_mod_add ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_add_quick ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m ) ;\n int BN_mod_sub ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_sub_quick ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m ) ;\n int BN_mod_mul ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_sqr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_lshift1 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_lshift1_quick ( BIGNUM * r , const BIGNUM * a , const BIGNUM * m ) ;\n int BN_mod_lshift ( BIGNUM * r , const BIGNUM * a , int n , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_lshift_quick ( BIGNUM * r , const BIGNUM * a , int n , const BIGNUM * m ) ;\n BN_ULONG BN_mod_word ( const BIGNUM * a , BN_ULONG w ) ;\n BN_ULONG BN_div_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_mul_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_add_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_sub_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_set_word ( BIGNUM * a , BN_ULONG w ) ;\n BN_ULONG BN_get_word ( const BIGNUM * a ) ;\n int BN_cmp ( const BIGNUM * a , const BIGNUM * b ) ;\n void BN_free ( BIGNUM * a ) ;\n int BN_is_bit_set ( const BIGNUM * a , int n ) ;\n int BN_lshift ( BIGNUM * r , const BIGNUM * a , int n ) ;\n int BN_lshift1 ( BIGNUM * r , const BIGNUM * a ) ;\n int BN_exp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_mod_exp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_exp_mont ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) ;\n int BN_mod_exp_mont_consttime ( BIGNUM * rr , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * in_mont ) ;\n int BN_mod_exp_mont_word ( BIGNUM * r , BN_ULONG a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) ;\n int BN_mod_exp2_mont ( BIGNUM * r , const BIGNUM * a1 , const BIGNUM * p1 , const BIGNUM * a2 , const BIGNUM * p2 , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) ;\n int BN_mod_exp_simple ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mask_bits ( BIGNUM * a , int n ) ;\n # ifndef OPENSSL_NO_FP_API int BN_print_fp ( FILE * fp , const BIGNUM * a ) ;\n # endif # ifdef HEADER_BIO_H int BN_print ( BIO * fp , const BIGNUM * a ) ;\n # else int BN_print ( void * fp , const BIGNUM * a ) ;\n # endif int BN_reciprocal ( BIGNUM * r , const BIGNUM * m , int len , BN_CTX * ctx ) ;\n int BN_rshift ( BIGNUM * r , const BIGNUM * a , int n ) ;\n int BN_rshift1 ( BIGNUM * r , const BIGNUM * a ) ;\n void BN_clear ( BIGNUM * a ) ;\n BIGNUM * BN_dup ( const BIGNUM * a ) ;\n int BN_ucmp ( const BIGNUM * a , const BIGNUM * b ) ;\n int BN_set_bit ( BIGNUM * a , int n ) ;\n int BN_clear_bit ( BIGNUM * a , int n ) ;\n char * BN_bn2hex ( const BIGNUM * a ) ;\n char * BN_bn2dec ( const BIGNUM * a ) ;\n int BN_hex2bn ( BIGNUM * * a , const char * str ) ;\n int BN_dec2bn ( BIGNUM * * a , const char * str ) ;\n int BN_asc2bn ( BIGNUM * * a , const char * str ) ;\n int BN_gcd ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , BN_CTX * ctx ) ;\n int BN_kronecker ( const BIGNUM * a , const BIGNUM * b , BN_CTX * ctx ) ;\n BIGNUM * BN_mod_inverse ( BIGNUM * ret , const BIGNUM * a , const BIGNUM * n , BN_CTX * ctx ) ;\n BIGNUM * BN_mod_sqrt ( BIGNUM * ret , const BIGNUM * a , const BIGNUM * n , BN_CTX * ctx ) ;\n # ifndef OPENSSL_NO_DEPRECATED BIGNUM * BN_generate_prime ( BIGNUM * ret , int bits , int safe , const BIGNUM * add , const BIGNUM * rem , void ( * callback ) ( int , int , void * ) , void * cb_arg ) ;\n int BN_is_prime ( const BIGNUM * p , int nchecks , void ( * callback ) ( int , int , void * ) , BN_CTX * ctx , void * cb_arg ) ;\n int BN_is_prime_fasttest ( const BIGNUM * p , int nchecks , void ( * callback ) ( int , int , void * ) , BN_CTX * ctx , void * cb_arg , int do_trial_division ) ;\n # endif int BN_generate_prime_ex ( BIGNUM * ret , int bits , int safe , const BIGNUM * add , const BIGNUM * rem , BN_GENCB * cb ) ;\n int BN_is_prime_ex ( const BIGNUM * p , int nchecks , BN_CTX * ctx , BN_GENCB * cb ) ;\n int BN_is_prime_fasttest_ex ( const BIGNUM * p , int nchecks , BN_CTX * ctx , int do_trial_division , BN_GENCB * cb ) ;\n int BN_X931_generate_Xpq ( BIGNUM * Xp , BIGNUM * Xq , int nbits , BN_CTX * ctx ) ;\n int BN_X931_derive_prime_ex ( BIGNUM * p , BIGNUM * p1 , BIGNUM * p2 , const BIGNUM * Xp , const BIGNUM * Xp1 , const BIGNUM * Xp2 , const BIGNUM * e , BN_CTX * ctx , BN_GENCB * cb ) ;\n int BN_X931_generate_prime_ex ( BIGNUM * p , BIGNUM * p1 , BIGNUM * p2 , BIGNUM * Xp1 , BIGNUM * Xp2 , const BIGNUM * Xp , const BIGNUM * e , BN_CTX * ctx , BN_GENCB * cb ) ;\n BN_MONT_CTX * BN_MONT_CTX_new ( void ) ;\n void BN_MONT_CTX_init ( BN_MONT_CTX * ctx ) ;\n int BN_mod_mul_montgomery ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , BN_MONT_CTX * mont , BN_CTX * ctx ) ;\n # define BN_to_montgomery ( r , a , mont , ctx ) BN_mod_mul_montgomery ( \\ ( r ) , ( a ) , & ( ( mont ) -> RR ) , ( mont ) , ( ctx ) ) int BN_from_montgomery ( BIGNUM * r , const BIGNUM * a , BN_MONT_CTX * mont , BN_CTX * ctx ) ;\n void BN_MONT_CTX_free ( BN_MONT_CTX * mont ) ;\n int BN_MONT_CTX_set ( BN_MONT_CTX * mont , const BIGNUM * mod , BN_CTX * ctx ) ;\n BN_MONT_CTX * BN_MONT_CTX_copy ( BN_MONT_CTX * to , BN_MONT_CTX * from ) ;\n BN_MONT_CTX * BN_MONT_CTX_set_locked ( BN_MONT_CTX * * pmont , int lock , const BIGNUM * mod , BN_CTX * ctx ) ;\n # define BN_BLINDING_NO_UPDATE 0x00000001 # define BN_BLINDING_NO_RECREATE 0x00000002 BN_BLINDING * BN_BLINDING_new ( const BIGNUM * A , const BIGNUM * Ai , BIGNUM * mod ) ;\n void BN_BLINDING_free ( BN_BLINDING * b ) ;\n int BN_BLINDING_update ( BN_BLINDING * b , BN_CTX * ctx ) ;\n int BN_BLINDING_convert ( BIGNUM * n , BN_BLINDING * b , BN_CTX * ctx ) ;\n int BN_BLINDING_invert ( BIGNUM * n , BN_BLINDING * b , BN_CTX * ctx ) ;\n int BN_BLINDING_convert_ex ( BIGNUM * n , BIGNUM * r , BN_BLINDING * b , BN_CTX * ) ;\n int BN_BLINDING_invert_ex ( BIGNUM * n , const BIGNUM * r , BN_BLINDING * b , BN_CTX * ) ;\n # ifndef OPENSSL_NO_DEPRECATED unsigned long BN_BLINDING_get_thread_id ( const BN_BLINDING * ) ;\n void BN_BLINDING_set_thread_id ( BN_BLINDING * , unsigned long ) ;\n # endif CRYPTO_THREADID * BN_BLINDING_thread_id ( BN_BLINDING * ) ;\n unsigned long BN_BLINDING_get_flags ( const BN_BLINDING * ) ;\n void BN_BLINDING_set_flags ( BN_BLINDING * , unsigned long ) ;\n BN_BLINDING * BN_BLINDING_create_param ( BN_BLINDING * b , const BIGNUM * e , BIGNUM * m , BN_CTX * ctx , int ( * bn_mod_exp ) ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) , BN_MONT_CTX * m_ctx ) ;\n # ifndef OPENSSL_NO_DEPRECATED void BN_set_params ( int mul , int high , int low , int mont ) ;\n int BN_get_params ( int which ) ;\n # endif void BN_RECP_CTX_init ( BN_RECP_CTX * recp ) ;\n BN_RECP_CTX * BN_RECP_CTX_new ( void ) ;\n void BN_RECP_CTX_free ( BN_RECP_CTX * recp ) ;\n int BN_RECP_CTX_set ( BN_RECP_CTX * recp , const BIGNUM * rdiv , BN_CTX * ctx ) ;\n int BN_mod_mul_reciprocal ( BIGNUM * r , const BIGNUM * x , const BIGNUM * y , BN_RECP_CTX * recp , BN_CTX * ctx ) ;\n int BN_mod_exp_recp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_div_recp ( BIGNUM * dv , BIGNUM * rem , const BIGNUM * m , BN_RECP_CTX * recp , BN_CTX * ctx ) ;\n # ifndef OPENSSL_NO_EC2M int BN_GF2m_add ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n # define BN_GF2m_sub ( r , a , b ) BN_GF2m_add ( r , a , b ) int BN_GF2m_mod ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p ) ;\n int BN_GF2m_mod_mul ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_inv ( BIGNUM * r , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_div ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_exp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqrt ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_solve_quad ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n # define BN_GF2m_cmp ( a , b ) BN_ucmp ( ( a ) , ( b ) ) int BN_GF2m_mod_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] ) ;\n int BN_GF2m_mod_mul_arr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqr_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_inv_arr ( BIGNUM * r , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_div_arr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_exp_arr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqrt_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_solve_quad_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_poly2arr ( const BIGNUM * a , int p [ ] , int max ) ;\n int BN_GF2m_arr2poly ( const int p [ ] , BIGNUM * a ) ;\n # endif int BN_nist_mod_192 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_224 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_256 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_384 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_521 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n const BIGNUM * BN_get0_nist_prime_192 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_224 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_256 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_384 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_521 ( void ) ;\n int ( * BN_nist_mod_func ( const BIGNUM * p ) ) ( BIGNUM * r , const BIGNUM * a , const BIGNUM * field , BN_CTX * ctx ) ;\n int BN_generate_dsa_nonce ( BIGNUM * out , const BIGNUM * range , const BIGNUM * priv , const unsigned char * message , size_t message_len , BN_CTX * ctx ) ;\n # define bn_expand ( a , bits ) ( ( ( ( ( ( bits + BN_BITS2 - 1 ) ) \/ BN_BITS2 ) ) <= ( a ) -> dmax ) ? \\ ( a ) : bn_expand2 ( ( a ) , ( bits + BN_BITS2 - 1 ) \/ BN_BITS2 ) ) # define bn_wexpand ( a , words ) ( ( ( words ) <= ( a ) -> dmax ) ? ( a ) : bn_expand2 ( ( a ) , ( words ) ) ) BIGNUM * bn_expand2 ( BIGNUM * a , int words ) ;\n # ifndef OPENSSL_NO_DEPRECATED BIGNUM * bn_dup_expand ( const BIGNUM * a , int words ) ;\n # endif # ifdef BN_DEBUG # include < assert . h > # ifdef BN_DEBUG_RAND # ifndef RAND_pseudo_bytes int RAND_pseudo_bytes ( unsigned char * buf , int num ) ;\n # define BN_DEBUG_TRIX # endif # define bn_pollute ( a ) \\ do {\n \\ const BIGNUM * _bnum1 = ( a ) ;\n \\ if ( _bnum1 -> top < _bnum1 -> dmax ) {\n \\ unsigned char _tmp_char ;\n \\ \\ BN_ULONG * _not_const ;\n \\ memcpy ( & _not_const , & _bnum1 -> d , sizeof ( BN_ULONG * ) ) ;\n \\ RAND_pseudo_bytes ( & _tmp_char , 1 ) ;\n \\ memset ( ( unsigned char * ) ( _not_const + _bnum1 -> top ) , _tmp_char , \\ ( _bnum1 -> dmax - _bnum1 -> top ) * sizeof ( BN_ULONG ) ) ;\n \\ }\n \\ }\n while ( 0 ) # ifdef BN_DEBUG_TRIX # undef RAND_pseudo_bytes # endif # else # define bn_pollute ( a ) # endif # define bn_check_top ( a ) \\ do {\n \\ const BIGNUM * _bnum2 = ( a ) ;\n \\ if ( _bnum2 != NULL ) {\n \\ assert ( ( _bnum2 -> top == 0 ) || \\ ( _bnum2 -> d [ _bnum2 -> top - 1 ] != 0 ) ) ;\n \\ bn_pollute ( _bnum2 ) ;\n \\ }\n \\ }\n while ( 0 ) # define bn_fix_top ( a ) bn_check_top ( a ) # else # define bn_pollute ( a ) # define bn_check_top ( a ) # define bn_fix_top ( a ) bn_correct_top ( a ) # endif # define bn_correct_top ( a ) \\ {\n \\ BN_ULONG * ftl ;\n \\ int tmp_top = ( a ) -> top ;\n \\ if ( tmp_top > 0 ) \\ {\n \\ for ( ftl = & ( ( a ) -> d [ tmp_top - 1 ] ) ;\n tmp_top > 0 ;\n tmp_top -- ) \\ if ( * ( ftl -- ) ) break ;\n \\ ( a ) -> top = tmp_top ;\n \\ }\n \\ bn_pollute ( a ) ;\n \\ }\n BN_ULONG bn_mul_add_words ( BN_ULONG * rp , const BN_ULONG * ap , int num , BN_ULONG w ) ;\n BN_ULONG bn_mul_words ( BN_ULONG * rp , const BN_ULONG * ap , int num , BN_ULONG w ) ;\n void bn_sqr_words ( BN_ULONG * rp , const BN_ULONG * ap , int num ) ;\n BN_ULONG bn_div_words ( BN_ULONG h , BN_ULONG l , BN_ULONG d ) ;\n BN_ULONG bn_add_words ( BN_ULONG * rp , const BN_ULONG * ap , const BN_ULONG * bp , int num ) ;\n BN_ULONG bn_sub_words ( BN_ULONG * rp , const BN_ULONG * ap , const BN_ULONG * bp , int num )","target":1,"code_token_length":7050,"total_token_length":7286,"max_tokens_setting":8192}
+{"idx":308716,"func":"SplashError Splash::drawImage(SplashImageSource src, void *srcData,\n\t\t\t      SplashColorMode srcMode, GBool srcAlpha,\n\t\t\t      int w, int h, SplashCoord *mat) {\n  SplashPipe pipe;\n  GBool ok, rot;\n  SplashCoord xScale, yScale, xShear, yShear, yShear1;\n  int tx, tx2, ty, ty2, scaledWidth, scaledHeight, xSign, ySign;\n  int ulx, uly, llx, lly, urx, ury, lrx, lry;\n  int ulx1, uly1, llx1, lly1, urx1, ury1, lrx1, lry1;\n  int xMin, xMax, yMin, yMax;\n  SplashClipResult clipRes, clipRes2;\n  int yp, yq, yt, yStep, lastYStep;\n  int xp, xq, xt, xStep, xSrc;\n  int k1, spanXMin, spanXMax, spanY;\n  SplashColorPtr colorBuf, p;\n  SplashColor pix;\n  Guchar *alphaBuf, *q;\n#if SPLASH_CMYK\n  int pixAcc0, pixAcc1, pixAcc2, pixAcc3;\n#else\n  int pixAcc0, pixAcc1, pixAcc2;\n#endif\n  int alphaAcc;\n  SplashCoord pixMul, alphaMul, alpha;\n  int x, y, x1, x2, y2;\n  SplashCoord y1;\n  int nComps, n, m, i, j;\n\n  if (debugMode) {\n    printf(\"drawImage: srcMode=%d srcAlpha=%d w=%d h=%d mat=[%.2f %.2f %.2f %.2f %.2f %.2f]\\n\",\n\t   srcMode, srcAlpha, w, h, (double)mat[0], (double)mat[1], (double)mat[2],\n\t   (double)mat[3], (double)mat[4], (double)mat[5]);\n  }\n\n  ok = gFalse; \/\/ make gcc happy\n  nComps = 0; \/\/ make gcc happy\n  switch (bitmap->mode) {\n  case splashModeMono1:\n  case splashModeMono8:\n    ok = srcMode == splashModeMono8;\n    nComps = 1;\n    break;\n  case splashModeRGB8:\n    ok = srcMode == splashModeRGB8;\n    nComps = 3;\n    break;\n  case splashModeXBGR8:\n    ok = srcMode == splashModeXBGR8;\n    nComps = 4;\n    break;\n  case splashModeBGR8:\n    ok = srcMode == splashModeBGR8;\n    nComps = 3;\n    break;\n#if SPLASH_CMYK\n  case splashModeCMYK8:\n    ok = srcMode == splashModeCMYK8;\n    nComps = 4;\n    break;\n#endif\n  }\n  if (!ok) {\n    return splashErrModeMismatch;\n  }\n\n  if (splashAbs(mat[0] * mat[3] - mat[1] * mat[2]) < 0.000001) {\n    return splashErrSingularMatrix;\n  }\n\n  rot = splashAbs(mat[1]) > splashAbs(mat[0]);\n  if (rot) {\n    xScale = -mat[1];\n    yScale = mat[2] - (mat[0] * mat[3]) \/ mat[1];\n    xShear = -mat[3] \/ yScale;\n    yShear = -mat[0] \/ mat[1];\n  } else {\n    xScale = mat[0];\n    yScale = mat[3] - (mat[1] * mat[2]) \/ mat[0];\n    xShear = mat[2] \/ yScale;\n    yShear = mat[1] \/ mat[0];\n  }\n  if (xScale >= 0) {\n    tx = splashFloor(mat[4] - 0.01);\n    tx2 = splashFloor(mat[4] + xScale + 0.01);\n  } else {\n    tx = splashFloor(mat[4] + 0.01);\n    tx2 = splashFloor(mat[4] + xScale - 0.01);\n  }\n  scaledWidth = abs(tx2 - tx) + 1;\n  if (yScale >= 0) {\n    ty = splashFloor(mat[5] - 0.01);\n    ty2 = splashFloor(mat[5] + yScale + 0.01);\n  } else {\n    ty = splashFloor(mat[5] + 0.01);\n    ty2 = splashFloor(mat[5] + yScale - 0.01);\n  }\n  scaledHeight = abs(ty2 - ty) + 1;\n  xSign = (xScale < 0) ? -1 : 1;\n  ySign = (yScale < 0) ? -1 : 1;\n  yShear1 = (SplashCoord)xSign * yShear;\n\n  ulx1 = 0;\n  uly1 = 0;\n  urx1 = xSign * (scaledWidth - 1);\n  ury1 = (int)(yShear * urx1);\n  llx1 = splashRound(xShear * ySign * (scaledHeight - 1));\n  lly1 = ySign * (scaledHeight - 1) + (int)(yShear * llx1);\n  lrx1 = xSign * (scaledWidth - 1) +\n           splashRound(xShear * ySign * (scaledHeight - 1));\n  lry1 = ySign * (scaledHeight - 1) + (int)(yShear * lrx1);\n  if (rot) {\n    ulx = tx + uly1;    uly = ty - ulx1;\n    urx = tx + ury1;    ury = ty - urx1;\n    llx = tx + lly1;    lly = ty - llx1;\n    lrx = tx + lry1;    lry = ty - lrx1;\n  } else {\n    ulx = tx + ulx1;    uly = ty + uly1;\n    urx = tx + urx1;    ury = ty + ury1;\n    llx = tx + llx1;    lly = ty + lly1;\n    lrx = tx + lrx1;    lry = ty + lry1;\n  }\n  xMin = (ulx < urx) ? (ulx < llx) ? (ulx < lrx) ? ulx : lrx\n                                   : (llx < lrx) ? llx : lrx\n\t\t     : (urx < llx) ? (urx < lrx) ? urx : lrx\n                                   : (llx < lrx) ? llx : lrx;\n  xMax = (ulx > urx) ? (ulx > llx) ? (ulx > lrx) ? ulx : lrx\n                                   : (llx > lrx) ? llx : lrx\n\t\t     : (urx > llx) ? (urx > lrx) ? urx : lrx\n                                   : (llx > lrx) ? llx : lrx;\n  yMin = (uly < ury) ? (uly < lly) ? (uly < lry) ? uly : lry\n                                   : (lly < lry) ? lly : lry\n\t\t     : (ury < lly) ? (ury < lry) ? ury : lry\n                                   : (lly < lry) ? lly : lry;\n  yMax = (uly > ury) ? (uly > lly) ? (uly > lry) ? uly : lry\n                                   : (lly > lry) ? lly : lry\n\t\t     : (ury > lly) ? (ury > lry) ? ury : lry\n                                   : (lly > lry) ? lly : lry;\n  clipRes = state->clip->testRect(xMin, yMin, xMax, yMax);\n  opClipRes = clipRes;\n  if (clipRes == splashClipAllOutside) {\n    return splashOk;\n  }\n\n  yp = h \/ scaledHeight;\n  yq = h % scaledHeight;\n  xp = w \/ scaledWidth;\n   xq = w % scaledWidth;\n \n  colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps);\n   if (srcAlpha) {\n    alphaBuf = (Guchar *)gmallocn((yp + 1), w);\n   } else {\n     alphaBuf = NULL;\n   }\n\n  pixAcc0 = pixAcc1 = pixAcc2 = 0; \/\/ make gcc happy\n#if SPLASH_CMYK\n  pixAcc3 = 0; \/\/ make gcc happy\n#endif\n\n  pipeInit(&pipe, 0, 0, NULL, pix, state->fillAlpha,\n\t   srcAlpha || (vectorAntialias && clipRes != splashClipAllInside),\n\t   gFalse);\n  if (vectorAntialias) {\n    drawAAPixelInit();\n  }\n\n  if (srcAlpha) {\n\n    yt = 0;\n    lastYStep = 1;\n\n    for (y = 0; y < scaledHeight; ++y) {\n\n      yStep = yp;\n      yt += yq;\n      if (yt >= scaledHeight) {\n\tyt -= scaledHeight;\n\t++yStep;\n      }\n\n      n = (yp > 0) ? yStep : lastYStep;\n      if (n > 0) {\n\tp = colorBuf;\n\tq = alphaBuf;\n\tfor (i = 0; i < n; ++i) {\n\t  (*src)(srcData, p, q);\n\t  p += w * nComps;\n\t  q += w;\n\t}\n      }\n      lastYStep = yStep;\n\n      k1 = splashRound(xShear * ySign * y);\n  \n      if (clipRes != splashClipAllInside &&\n\t  !rot &&\n\t  (int)(yShear * k1) ==\n\t    (int)(yShear * (xSign * (scaledWidth - 1) + k1))) {\n\tif (xSign > 0) {\n\t  spanXMin = tx + k1;\n\t  spanXMax = spanXMin + (scaledWidth - 1);\n\t} else {\n\t  spanXMax = tx + k1;\n\t  spanXMin = spanXMax - (scaledWidth - 1);\n\t}\n\tspanY = ty + ySign * y + (int)(yShear * k1);\n\tclipRes2 = state->clip->testSpan(spanXMin, spanXMax, spanY);\n\tif (clipRes2 == splashClipAllOutside) {\n\t  continue;\n\t}\n      } else {\n\tclipRes2 = clipRes;\n      }\n\n      xt = 0;\n      xSrc = 0;\n\n      x1 = k1;\n\n      y1 = (SplashCoord)ySign * y + yShear * x1;\n      if (yShear1 < 0) {\n\ty1 += 0.999;\n      }\n\n      n = yStep > 0 ? yStep : 1;\n\n      switch (srcMode) {\n\n      case splashModeMono1:\n      case splashModeMono8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  alphaAcc = 0;\n\t  p = colorBuf + xSrc;\n\t  q = alphaBuf + xSrc;\n\t  pixAcc0 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      alphaAcc += *q++;\n\t    }\n\t    p += w - m;\n\t    q += w - m;\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\t  alphaMul = pixMul * (1.0 \/ 255.0);\n\t  alpha = (SplashCoord)alphaAcc * alphaMul;\n\n\t  if (alpha > 0) {\n\t    pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\n\t    pipe.shape = alpha;\n\t    if (vectorAntialias && clipRes != splashClipAllInside) {\n\t      drawAAPixel(&pipe, tx + x2, ty + y2);\n\t    } else {\n\t      drawPixel(&pipe, tx + x2, ty + y2,\n\t\t\tclipRes2 == splashClipAllInside);\n\t    }\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n\n      case splashModeRGB8:\n      case splashModeBGR8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  alphaAcc = 0;\n\t  p = colorBuf + xSrc * 3;\n\t  q = alphaBuf + xSrc;\n\t  pixAcc0 = pixAcc1 = pixAcc2 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      pixAcc1 += *p++;\n\t      pixAcc2 += *p++;\n\t      alphaAcc += *q++;\n\t    }\n\t    p += 3 * (w - m);\n\t    q += w - m;\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\t  alphaMul = pixMul * (1.0 \/ 255.0);\n\t  alpha = (SplashCoord)alphaAcc * alphaMul;\n\n\t  if (alpha > 0) {\n\t    pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\t    pix[1] = (int)((SplashCoord)pixAcc1 * pixMul);\n\t    pix[2] = (int)((SplashCoord)pixAcc2 * pixMul);\n\n\t    pipe.shape = alpha;\n\t    if (vectorAntialias && clipRes != splashClipAllInside) {\n\t      drawAAPixel(&pipe, tx + x2, ty + y2);\n\t    } else {\n\t      drawPixel(&pipe, tx + x2, ty + y2,\n\t\t\tclipRes2 == splashClipAllInside);\n\t    }\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n\n      case splashModeXBGR8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  alphaAcc = 0;\n\t  p = colorBuf + xSrc * 4;\n\t  q = alphaBuf + xSrc;\n\t  pixAcc0 = pixAcc1 = pixAcc2 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      pixAcc1 += *p++;\n\t      pixAcc2 += *p++;\n\t      *p++;\n\t      alphaAcc += *q++;\n\t    }\n\t    p += 4 * (w - m);\n\t    q += w - m;\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\t  alphaMul = pixMul * (1.0 \/ 255.0);\n\t  alpha = (SplashCoord)alphaAcc * alphaMul;\n\n\t  if (alpha > 0) {\n\t    pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\t    pix[1] = (int)((SplashCoord)pixAcc1 * pixMul);\n\t    pix[2] = (int)((SplashCoord)pixAcc2 * pixMul);\n\t    pix[3] = 255;\n\n\t    pipe.shape = alpha;\n\t    if (vectorAntialias && clipRes != splashClipAllInside) {\n\t      drawAAPixel(&pipe, tx + x2, ty + y2);\n\t    } else {\n\t      drawPixel(&pipe, tx + x2, ty + y2,\n\t\t\tclipRes2 == splashClipAllInside);\n\t    }\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n\n\n#if SPLASH_CMYK\n      case splashModeCMYK8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  alphaAcc = 0;\n\t  p = colorBuf + xSrc * 4;\n\t  q = alphaBuf + xSrc;\n\t  pixAcc0 = pixAcc1 = pixAcc2 = pixAcc3 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      pixAcc1 += *p++;\n\t      pixAcc2 += *p++;\n\t      pixAcc3 += *p++;\n\t      alphaAcc += *q++;\n\t    }\n\t    p += 4 * (w - m);\n\t    q += w - m;\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\t  alphaMul = pixMul * (1.0 \/ 255.0);\n\t  alpha = (SplashCoord)alphaAcc * alphaMul;\n\n\t  if (alpha > 0) {\n\t    pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\t    pix[1] = (int)((SplashCoord)pixAcc1 * pixMul);\n\t    pix[2] = (int)((SplashCoord)pixAcc2 * pixMul);\n\t    pix[3] = (int)((SplashCoord)pixAcc3 * pixMul);\n\n\t    pipe.shape = alpha;\n\t    if (vectorAntialias && clipRes != splashClipAllInside) {\n\t      drawAAPixel(&pipe, tx + x2, ty + y2);\n\t    } else {\n\t      drawPixel(&pipe, tx + x2, ty + y2,\n\t\t\tclipRes2 == splashClipAllInside);\n\t    }\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n#endif \/\/ SPLASH_CMYK\n      }\n    }\n\n  } else {\n\n    yt = 0;\n    lastYStep = 1;\n\n    for (y = 0; y < scaledHeight; ++y) {\n\n      yStep = yp;\n      yt += yq;\n      if (yt >= scaledHeight) {\n\tyt -= scaledHeight;\n\t++yStep;\n      }\n\n      n = (yp > 0) ? yStep : lastYStep;\n      if (n > 0) {\n\tp = colorBuf;\n\tfor (i = 0; i < n; ++i) {\n\t  (*src)(srcData, p, NULL);\n\t  p += w * nComps;\n\t}\n      }\n      lastYStep = yStep;\n\n      k1 = splashRound(xShear * ySign * y);\n\n      if (clipRes != splashClipAllInside &&\n\t  !rot &&\n\t  (int)(yShear * k1) ==\n\t    (int)(yShear * (xSign * (scaledWidth - 1) + k1))) {\n\tif (xSign > 0) {\n\t  spanXMin = tx + k1;\n\t  spanXMax = spanXMin + (scaledWidth - 1);\n\t} else {\n\t  spanXMax = tx + k1;\n\t  spanXMin = spanXMax - (scaledWidth - 1);\n\t}\n\tspanY = ty + ySign * y + (int)(yShear * k1);\n\tclipRes2 = state->clip->testSpan(spanXMin, spanXMax, spanY);\n\tif (clipRes2 == splashClipAllOutside) {\n\t  continue;\n\t}\n      } else {\n\tclipRes2 = clipRes;\n      }\n\n      xt = 0;\n      xSrc = 0;\n\n      x1 = k1;\n\n      y1 = (SplashCoord)ySign * y + yShear * x1;\n      if (yShear1 < 0) {\n\ty1 += 0.999;\n      }\n\n      n = yStep > 0 ? yStep : 1;\n\n      switch (srcMode) {\n\n      case splashModeMono1:\n      case splashModeMono8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  p = colorBuf + xSrc;\n\t  pixAcc0 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t    }\n\t    p += w - m;\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\n\t  pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\n\t  if (vectorAntialias && clipRes != splashClipAllInside) {\n\t    pipe.shape = (SplashCoord)1;\n\t    drawAAPixel(&pipe, tx + x2, ty + y2);\n\t  } else {\n\t    drawPixel(&pipe, tx + x2, ty + y2,\n\t\t      clipRes2 == splashClipAllInside);\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n\n      case splashModeRGB8:\n      case splashModeBGR8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  p = colorBuf + xSrc * 3;\n\t  pixAcc0 = pixAcc1 = pixAcc2 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      pixAcc1 += *p++;\n\t      pixAcc2 += *p++;\n\t    }\n\t    p += 3 * (w - m);\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\n\t  pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\t  pix[1] = (int)((SplashCoord)pixAcc1 * pixMul);\n\t  pix[2] = (int)((SplashCoord)pixAcc2 * pixMul);\n\n\t  if (vectorAntialias && clipRes != splashClipAllInside) {\n\t    pipe.shape = (SplashCoord)1;\n\t    drawAAPixel(&pipe, tx + x2, ty + y2);\n\t  } else {\n\t    drawPixel(&pipe, tx + x2, ty + y2,\n\t\t      clipRes2 == splashClipAllInside);\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n\n      case splashModeXBGR8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  p = colorBuf + xSrc * 4;\n\t  pixAcc0 = pixAcc1 = pixAcc2 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      pixAcc1 += *p++;\n\t      pixAcc2 += *p++;\n\t      *p++;\n\t    }\n\t    p += 4 * (w - m);\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\n\t  pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\t  pix[1] = (int)((SplashCoord)pixAcc1 * pixMul);\n\t  pix[2] = (int)((SplashCoord)pixAcc2 * pixMul);\n\t  pix[3] = 255;\n\n\t  if (vectorAntialias && clipRes != splashClipAllInside) {\n\t    pipe.shape = (SplashCoord)1;\n\t    drawAAPixel(&pipe, tx + x2, ty + y2);\n\t  } else {\n\t    drawPixel(&pipe, tx + x2, ty + y2,\n\t\t      clipRes2 == splashClipAllInside);\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n\n#if SPLASH_CMYK\n      case splashModeCMYK8:\n\tfor (x = 0; x < scaledWidth; ++x) {\n\n\t  xStep = xp;\n\t  xt += xq;\n\t  if (xt >= scaledWidth) {\n\t    xt -= scaledWidth;\n\t    ++xStep;\n\t  }\n\n\t  if (rot) {\n\t    x2 = (int)y1;\n\t    y2 = -x1;\n\t  } else {\n\t    x2 = x1;\n\t    y2 = (int)y1;\n\t  }\n\n\t  m = xStep > 0 ? xStep : 1;\n\t  p = colorBuf + xSrc * 4;\n\t  pixAcc0 = pixAcc1 = pixAcc2 = pixAcc3 = 0;\n\t  for (i = 0; i < n; ++i) {\n\t    for (j = 0; j < m; ++j) {\n\t      pixAcc0 += *p++;\n\t      pixAcc1 += *p++;\n\t      pixAcc2 += *p++;\n\t      pixAcc3 += *p++;\n\t    }\n\t    p += 4 * (w - m);\n\t  }\n\t  pixMul = (SplashCoord)1 \/ (SplashCoord)(n * m);\n\n\t  pix[0] = (int)((SplashCoord)pixAcc0 * pixMul);\n\t  pix[1] = (int)((SplashCoord)pixAcc1 * pixMul);\n\t  pix[2] = (int)((SplashCoord)pixAcc2 * pixMul);\n\t  pix[3] = (int)((SplashCoord)pixAcc3 * pixMul);\n\n\t  if (vectorAntialias && clipRes != splashClipAllInside) {\n\t    pipe.shape = (SplashCoord)1;\n\t    drawAAPixel(&pipe, tx + x2, ty + y2);\n\t  } else {\n\t    drawPixel(&pipe, tx + x2, ty + y2,\n\t\t      clipRes2 == splashClipAllInside);\n\t  }\n\n\t  xSrc += xStep;\n\n\t  x1 += xSign;\n\n\t  y1 += yShear1;\n\t}\n\tbreak;\n#endif \/\/ SPLASH_CMYK\n      }\n    }\n\n  }\n\n  gfree(colorBuf);\n  gfree(alphaBuf);\n\n  return splashOk;\n}\n","target":0,"code_token_length":6411,"total_token_length":6647,"max_tokens_setting":8192}
+{"idx":105459,"func":"njs_vmcode_interpreter(njs_vm_t *vm, u_char *pc, void *promise_cap,\n    void *async_ctx)\n{\n    u_char                       *catch;\n    double                       num, exponent;\n    int32_t                      i32;\n    uint32_t                     u32;\n    njs_str_t                    string;\n    njs_uint_t                   hint;\n    njs_bool_t                   valid, lambda_call;\n    njs_value_t                  *retval, *value1, *value2;\n    njs_value_t                  *src, *s1, *s2, dst;\n    njs_value_t                  *function, name;\n    njs_value_t                  numeric1, numeric2, primitive1, primitive2;\n    njs_frame_t                  *frame;\n    njs_jump_off_t               ret;\n    njs_vmcode_await_t           *await;\n    njs_native_frame_t           *previous, *native;\n    njs_property_next_t          *next;\n    njs_vmcode_import_t          *import;\n    njs_vmcode_finally_t         *finally;\n    njs_vmcode_generic_t         *vmcode;\n    njs_vmcode_variable_t        *var;\n    njs_vmcode_move_arg_t        *move_arg;\n    njs_vmcode_prop_get_t        *get;\n    njs_vmcode_prop_set_t        *set;\n    njs_vmcode_operation_t       op;\n    njs_vmcode_prop_next_t       *pnext;\n    njs_vmcode_test_jump_t       *test_jump;\n    njs_vmcode_equal_jump_t      *equal;\n    njs_vmcode_try_return_t      *try_return;\n    njs_vmcode_method_frame_t    *method_frame;\n    njs_vmcode_function_copy_t   *fcopy;\n    njs_vmcode_prop_accessor_t   *accessor;\n    njs_vmcode_try_trampoline_t  *try_trampoline;\n    njs_vmcode_function_frame_t  *function_frame;\n\nnext:\n\n    for ( ;; ) {\n\n        vmcode = (njs_vmcode_generic_t *) pc;\n\n        \/*\n         * The first operand is passed as is in value2 to\n         *   NJS_VMCODE_JUMP,\n         *   NJS_VMCODE_IF_TRUE_JUMP,\n         *   NJS_VMCODE_IF_FALSE_JUMP,\n         *   NJS_VMCODE_FUNCTION_FRAME,\n         *   NJS_VMCODE_FUNCTION_CALL,\n         *   NJS_VMCODE_RETURN,\n         *   NJS_VMCODE_TRY_START,\n         *   NJS_VMCODE_TRY_CONTINUE,\n         *   NJS_VMCODE_TRY_BREAK,\n         *   NJS_VMCODE_TRY_END,\n         *   NJS_VMCODE_CATCH,\n         *   NJS_VMCODE_THROW,\n         *   NJS_VMCODE_STOP.\n         *\/\n        value2 = (njs_value_t *) vmcode->operand1;\n        value1 = NULL;\n\n        switch (vmcode->code.operands) {\n\n        case NJS_VMCODE_3OPERANDS:\n            njs_vmcode_operand(vm, vmcode->operand3, value2);\n\n            \/* Fall through. *\/\n\n        case NJS_VMCODE_2OPERANDS:\n            njs_vmcode_operand(vm, vmcode->operand2, value1);\n        }\n\n        op = vmcode->code.operation;\n\n        \/*\n         * On success an operation returns size of the bytecode,\n         * a jump offset or zero after the call or return operations.\n         * Jumps can return a negative offset.  Compilers can generate\n         *    (ret < 0 && ret >= NJS_PREEMPT)\n         * as a single unsigned comparision.\n         *\/\n\n        if (op > NJS_VMCODE_NORET) {\n\n            if (op == NJS_VMCODE_MOVE) {\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                *retval = *value1;\n\n                pc += sizeof(njs_vmcode_move_t);\n                goto next;\n            }\n\n            if (op == NJS_VMCODE_PROPERTY_GET) {\n                get = (njs_vmcode_prop_get_t *) pc;\n                njs_vmcode_operand(vm, get->value, retval);\n\n                ret = njs_value_property(vm, value1, value2, retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                pc += sizeof(njs_vmcode_prop_get_t);\n                goto next;\n            }\n\n            switch (op) {\n            case NJS_VMCODE_INCREMENT:\n            case NJS_VMCODE_POST_INCREMENT:\n            case NJS_VMCODE_DECREMENT:\n            case NJS_VMCODE_POST_DECREMENT:\n                if (njs_slow_path(!njs_is_numeric(value2))) {\n                    ret = njs_value_to_numeric(vm, value2, &numeric1);\n                    if (njs_slow_path(ret != NJS_OK)) {\n                        goto error;\n                    }\n\n                    num = njs_number(&numeric1);\n\n                } else {\n                    num = njs_number(value2);\n                }\n\n                njs_set_number(value1,\n                           num + (1 - 2 * ((op - NJS_VMCODE_INCREMENT) >> 1)));\n\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n\n                if (op & 1) {\n                    njs_set_number(retval, num);\n\n                } else {\n                    *retval = *value1;\n                }\n\n                pc += sizeof(njs_vmcode_3addr_t);\n                goto next;\n\n            case NJS_VMCODE_GLOBAL_GET:\n                get = (njs_vmcode_prop_get_t *) pc;\n                njs_vmcode_operand(vm, get->value, retval);\n\n                ret = njs_value_property(vm, value1, value2, retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                pc += sizeof(njs_vmcode_prop_get_t);\n\n                if (ret == NJS_OK) {\n                    pc += sizeof(njs_vmcode_error_t);\n                }\n\n                goto next;\n\n            \/*\n             * njs_vmcode_try_return() saves a return value to use it later by\n             * njs_vmcode_finally(), and jumps to the nearest try_break block.\n             *\/\n            case NJS_VMCODE_TRY_RETURN:\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                *retval = *value1;\n\n                try_return = (njs_vmcode_try_return_t *) pc;\n                pc += try_return->offset;\n                goto next;\n\n            case NJS_VMCODE_LESS:\n            case NJS_VMCODE_GREATER:\n            case NJS_VMCODE_LESS_OR_EQUAL:\n            case NJS_VMCODE_GREATER_OR_EQUAL:\n            case NJS_VMCODE_ADDITION:\n                if (njs_slow_path(!njs_is_primitive(value1))) {\n                    hint = (op == NJS_VMCODE_ADDITION) && njs_is_date(value1);\n                    ret = njs_value_to_primitive(vm, &primitive1, value1, hint);\n                    if (ret != NJS_OK) {\n                        goto error;\n                    }\n\n                    value1 = &primitive1;\n                }\n\n                if (njs_slow_path(!njs_is_primitive(value2))) {\n                    hint = (op == NJS_VMCODE_ADDITION) && njs_is_date(value2);\n                    ret = njs_value_to_primitive(vm, &primitive2, value2, hint);\n                    if (ret != NJS_OK) {\n                        goto error;\n                    }\n\n                    value2 = &primitive2;\n                }\n\n                if (njs_slow_path(njs_is_symbol(value1)\n                                  || njs_is_symbol(value2)))\n                {\n                    njs_symbol_conversion_failed(vm,\n                        (op == NJS_VMCODE_ADDITION) &&\n                        (njs_is_string(value1) || njs_is_string(value2)));\n\n                    goto error;\n                }\n\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n\n                if (op == NJS_VMCODE_ADDITION) {\n                    if (njs_fast_path(njs_is_numeric(value1)\n                                      && njs_is_numeric(value2)))\n                    {\n                        njs_set_number(retval, njs_number(value1)\n                                               + njs_number(value2));\n                        pc += sizeof(njs_vmcode_3addr_t);\n                        goto next;\n                    }\n\n                    if (njs_is_string(value1)) {\n                        s1 = value1;\n                        s2 = &dst;\n                        src = value2;\n\n                    } else {\n                        s1 = &dst;\n                        s2 = value2;\n                        src = value1;\n                    }\n\n                    ret = njs_primitive_value_to_string(vm, &dst, src);\n                    if (njs_slow_path(ret != NJS_OK)) {\n                        goto error;\n                    }\n\n                    ret = njs_string_concat(vm, s1, s2);\n                    if (njs_slow_path(ret == NJS_ERROR)) {\n                        goto error;\n                    }\n\n                    *retval = vm->retval;\n\n                    pc += ret;\n                    goto next;\n                }\n\n                if ((uint8_t) (op - NJS_VMCODE_GREATER) < 2) {\n                    \/* NJS_VMCODE_GREATER, NJS_VMCODE_LESS_OR_EQUAL *\/\n                    src = value1;\n                    value1 = value2;\n                    value2 = src;\n                }\n\n                ret = njs_primitive_values_compare(vm, value1, value2);\n\n                if (op < NJS_VMCODE_LESS_OR_EQUAL) {\n                    ret = ret > 0;\n\n                } else {\n                    ret = ret == 0;\n                }\n\n                njs_set_boolean(retval, ret);\n\n                pc += sizeof(njs_vmcode_3addr_t);\n                goto next;\n\n            case NJS_VMCODE_EQUAL:\n            case NJS_VMCODE_NOT_EQUAL:\n                ret = njs_values_equal(vm, value1, value2);\n                if (njs_slow_path(ret < 0)) {\n                    goto error;\n                }\n\n                ret ^= op - NJS_VMCODE_EQUAL;\n\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                njs_set_boolean(retval, ret);\n\n                pc += sizeof(njs_vmcode_3addr_t);\n                goto next;\n\n            case NJS_VMCODE_SUBSTRACTION:\n            case NJS_VMCODE_MULTIPLICATION:\n            case NJS_VMCODE_EXPONENTIATION:\n            case NJS_VMCODE_DIVISION:\n            case NJS_VMCODE_REMAINDER:\n            case NJS_VMCODE_BITWISE_AND:\n            case NJS_VMCODE_BITWISE_OR:\n            case NJS_VMCODE_BITWISE_XOR:\n            case NJS_VMCODE_LEFT_SHIFT:\n            case NJS_VMCODE_RIGHT_SHIFT:\n            case NJS_VMCODE_UNSIGNED_RIGHT_SHIFT:\n                if (njs_slow_path(!njs_is_numeric(value1))) {\n                    ret = njs_value_to_numeric(vm, value1, &numeric1);\n                    if (njs_slow_path(ret != NJS_OK)) {\n                        goto error;\n                    }\n\n                    value1 = &numeric1;\n                }\n\n                if (njs_slow_path(!njs_is_numeric(value2))) {\n                    ret = njs_value_to_numeric(vm, value2, &numeric2);\n                    if (njs_slow_path(ret != NJS_OK)) {\n                        goto error;\n                    }\n\n                    value2 = &numeric2;\n                }\n\n                num = njs_number(value1);\n\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                pc += sizeof(njs_vmcode_3addr_t);\n\n                switch (op) {\n                case NJS_VMCODE_SUBSTRACTION:\n                    num -= njs_number(value2);\n                    break;\n\n                case NJS_VMCODE_MULTIPLICATION:\n                    num *= njs_number(value2);\n                    break;\n\n                case NJS_VMCODE_EXPONENTIATION:\n                    exponent = njs_number(value2);\n\n                    \/*\n                     * According to ES7:\n                     *  1. If exponent is NaN, the result should be NaN;\n                     *  2. The result of +\/-1 ** +\/-Infinity should be NaN.\n                     *\/\n                    valid = njs_expect(1, fabs(num) != 1\n                                          || (!isnan(exponent)\n                                              && !isinf(exponent)));\n\n                    num = valid ? pow(num, exponent) : NAN;\n                    break;\n\n                case NJS_VMCODE_DIVISION:\n                    num \/= njs_number(value2);\n                    break;\n\n                case NJS_VMCODE_REMAINDER:\n                    num = fmod(num, njs_number(value2));\n                    break;\n\n                case NJS_VMCODE_BITWISE_AND:\n                case NJS_VMCODE_BITWISE_OR:\n                case NJS_VMCODE_BITWISE_XOR:\n                    i32 = njs_number_to_int32(njs_number(value2));\n\n                    switch (op) {\n                    case NJS_VMCODE_BITWISE_AND:\n                        i32 &= njs_number_to_int32(num);\n                        break;\n\n                    case NJS_VMCODE_BITWISE_OR:\n                        i32 |= njs_number_to_int32(num);\n                        break;\n\n                    case NJS_VMCODE_BITWISE_XOR:\n                        i32 ^= njs_number_to_int32(num);\n                        break;\n                    }\n\n                    njs_set_int32(retval, i32);\n                    goto next;\n\n                default:\n                    u32 = njs_number_to_uint32(njs_number(value2)) & 0x1f;\n\n                    switch (op) {\n                    case NJS_VMCODE_LEFT_SHIFT:\n                    case NJS_VMCODE_RIGHT_SHIFT:\n                        i32 = njs_number_to_int32(num);\n\n                        if (op == NJS_VMCODE_LEFT_SHIFT) {\n                            \/* Shifting of negative numbers is undefined. *\/\n                            i32 = (uint32_t) i32 << u32;\n                        } else {\n                            i32 >>= u32;\n                        }\n\n                        njs_set_int32(retval, i32);\n                        break;\n\n                    default: \/* NJS_VMCODE_UNSIGNED_RIGHT_SHIFT *\/\n                        njs_set_uint32(retval,\n                                       njs_number_to_uint32(num) >> u32);\n                    }\n\n                    goto next;\n                }\n\n                njs_set_number(retval, num);\n                goto next;\n\n            case NJS_VMCODE_OBJECT_COPY:\n                ret = njs_vmcode_object_copy(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_TEMPLATE_LITERAL:\n                ret = njs_vmcode_template_literal(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_PROPERTY_IN:\n                ret = njs_vmcode_property_in(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_PROPERTY_DELETE:\n                ret = njs_value_property_delete(vm, value1, value2, NULL);\n                if (njs_fast_path(ret != NJS_ERROR)) {\n                    vm->retval = njs_value_true;\n\n                    ret = sizeof(njs_vmcode_3addr_t);\n                }\n\n                break;\n\n            case NJS_VMCODE_PROPERTY_FOREACH:\n                ret = njs_vmcode_property_foreach(vm, value1, value2, pc);\n                break;\n\n            case NJS_VMCODE_STRICT_EQUAL:\n            case NJS_VMCODE_STRICT_NOT_EQUAL:\n                ret = njs_values_strict_equal(value1, value2);\n\n                ret ^= op - NJS_VMCODE_STRICT_EQUAL;\n\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                njs_set_boolean(retval, ret);\n\n                pc += sizeof(njs_vmcode_3addr_t);\n                goto next;\n\n            case NJS_VMCODE_TEST_IF_TRUE:\n            case NJS_VMCODE_TEST_IF_FALSE:\n            case NJS_VMCODE_COALESCE:\n                if (op == NJS_VMCODE_COALESCE) {\n                    ret = !njs_is_null_or_undefined(value1);\n\n                } else {\n                    ret = njs_is_true(value1);\n                    ret ^= op - NJS_VMCODE_TEST_IF_TRUE;\n                }\n\n                if (ret) {\n                    test_jump = (njs_vmcode_test_jump_t *) pc;\n                    ret = test_jump->offset;\n\n                } else {\n                    ret = sizeof(njs_vmcode_3addr_t);\n                }\n\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                *retval = *value1;\n\n                pc += ret;\n                goto next;\n\n            case NJS_VMCODE_UNARY_PLUS:\n            case NJS_VMCODE_UNARY_NEGATION:\n            case NJS_VMCODE_BITWISE_NOT:\n                if (njs_slow_path(!njs_is_numeric(value1))) {\n                    ret = njs_value_to_numeric(vm, value1, &numeric1);\n                    if (njs_slow_path(ret != NJS_OK)) {\n                        goto error;\n                    }\n\n                    value1 = &numeric1;\n                }\n\n                num = njs_number(value1);\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n\n                switch (op) {\n                case NJS_VMCODE_UNARY_NEGATION:\n                    num = -num;\n\n                    \/* Fall through. *\/\n                case NJS_VMCODE_UNARY_PLUS:\n                    njs_set_number(retval, num);\n                    break;\n\n                case NJS_VMCODE_BITWISE_NOT:\n                    njs_set_int32(retval, ~njs_number_to_uint32(num));\n                }\n\n                pc += sizeof(njs_vmcode_2addr_t);\n                goto next;\n\n            case NJS_VMCODE_LOGICAL_NOT:\n                njs_vmcode_operand(vm, vmcode->operand1, retval);\n                njs_set_boolean(retval, !njs_is_true(value1));\n\n                pc += sizeof(njs_vmcode_2addr_t);\n                goto next;\n\n            case NJS_VMCODE_OBJECT:\n                ret = njs_vmcode_object(vm);\n                break;\n\n            case NJS_VMCODE_ARRAY:\n                ret = njs_vmcode_array(vm, pc);\n                break;\n\n            case NJS_VMCODE_FUNCTION:\n                ret = njs_vmcode_function(vm, pc);\n                break;\n\n            case NJS_VMCODE_REGEXP:\n                ret = njs_vmcode_regexp(vm, pc);\n                break;\n\n            case NJS_VMCODE_INSTANCE_OF:\n                ret = njs_vmcode_instance_of(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_TYPEOF:\n                ret = njs_vmcode_typeof(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_VOID:\n                njs_set_undefined(&vm->retval);\n\n                ret = sizeof(njs_vmcode_2addr_t);\n                break;\n\n            case NJS_VMCODE_DELETE:\n                njs_release(vm, value1);\n                vm->retval = njs_value_true;\n\n                ret = sizeof(njs_vmcode_2addr_t);\n                break;\n\n            case NJS_VMCODE_DEBUGGER:\n                ret = njs_vmcode_debugger(vm);\n                break;\n\n            default:\n                njs_internal_error(vm, \"%d has retval\", op);\n                goto error;\n            }\n\n            if (njs_slow_path(ret < 0 && ret >= NJS_PREEMPT)) {\n                break;\n            }\n\n            njs_vmcode_operand(vm, vmcode->operand1, retval);\n            njs_release(vm, retval);\n            *retval = vm->retval;\n\n        } else {\n\n            switch (op) {\n            case NJS_VMCODE_MOVE_ARG:\n                move_arg = (njs_vmcode_move_arg_t *) pc;\n                native = vm->top_frame;\n\n                hint = move_arg->dst;\n\n                value1 = &native->arguments_offset[hint];\n                njs_vmcode_operand(vm, move_arg->src, value2);\n\n                *value1 = *value2;\n\n                ret = sizeof(njs_vmcode_move_arg_t);\n                break;\n\n            case NJS_VMCODE_STOP:\n                njs_vmcode_operand(vm, (njs_index_t) value2, value2);\n                vm->retval = *value2;\n\n                return NJS_OK;\n\n            case NJS_VMCODE_JUMP:\n                ret = (njs_jump_off_t) value2;\n                break;\n\n            case NJS_VMCODE_PROPERTY_SET:\n                set = (njs_vmcode_prop_set_t *) pc;\n                njs_vmcode_operand(vm, set->value, retval);\n\n                ret = njs_value_property_set(vm, value1, value2, retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                ret = sizeof(njs_vmcode_prop_set_t);\n                break;\n\n            case NJS_VMCODE_PROPERTY_ACCESSOR:\n                accessor = (njs_vmcode_prop_accessor_t *) pc;\n                njs_vmcode_operand(vm, accessor->value, function);\n\n                ret = njs_value_to_key(vm, &name, value2);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    njs_internal_error(vm, \"failed conversion of type \\\"%s\\\" \"\n                                       \"to string while property define\",\n                                       njs_type_string(value2->type));\n                    goto error;\n                }\n\n                ret = njs_object_prop_define(vm, value1, &name, function,\n                                             accessor->type);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    return NJS_ERROR;\n                }\n\n                ret = sizeof(njs_vmcode_prop_accessor_t);\n                break;\n\n            case NJS_VMCODE_IF_TRUE_JUMP:\n            case NJS_VMCODE_IF_FALSE_JUMP:\n                ret = njs_is_true(value1);\n\n                ret ^= op - NJS_VMCODE_IF_TRUE_JUMP;\n\n                ret = ret ? (njs_jump_off_t) value2\n                          : (njs_jump_off_t) sizeof(njs_vmcode_cond_jump_t);\n\n                break;\n\n            case NJS_VMCODE_IF_EQUAL_JUMP:\n                if (njs_values_strict_equal(value1, value2)) {\n                    equal = (njs_vmcode_equal_jump_t *) pc;\n                    ret = equal->offset;\n\n                } else {\n                    ret = sizeof(njs_vmcode_3addr_t);\n                }\n\n                break;\n\n            case NJS_VMCODE_PROPERTY_INIT:\n                set = (njs_vmcode_prop_set_t *) pc;\n                njs_vmcode_operand(vm, set->value, retval);\n                ret = njs_vmcode_property_init(vm, value1, value2, retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                break;\n\n            case NJS_VMCODE_RETURN:\n                njs_vmcode_operand(vm, (njs_index_t) value2, value2);\n                return njs_vmcode_return(vm, NULL, value2);\n\n            case NJS_VMCODE_FUNCTION_COPY:\n                fcopy = (njs_vmcode_function_copy_t *) pc;\n                ret = njs_vmcode_function_copy(vm, fcopy->function,\n                                               fcopy->retval);\n                break;\n\n            case NJS_VMCODE_FUNCTION_FRAME:\n                function_frame = (njs_vmcode_function_frame_t *) pc;\n\n                \/* TODO: external object instead of void this. *\/\n\n                ret = njs_function_frame_create(vm, value1,\n                                                &njs_value_undefined,\n                                                (uintptr_t) value2,\n                                                function_frame->ctor);\n\n                if (njs_slow_path(ret != NJS_OK)) {\n                    goto error;\n                }\n\n                ret = sizeof(njs_vmcode_function_frame_t);\n                break;\n\n            case NJS_VMCODE_METHOD_FRAME:\n                method_frame = (njs_vmcode_method_frame_t *) pc;\n\n                ret = njs_value_property(vm, value1, value2, &dst);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                if (njs_slow_path(!njs_is_function(&dst))) {\n                    ret = njs_value_to_key(vm, value2, value2);\n                    if (njs_slow_path(ret != NJS_OK)) {\n                        return NJS_ERROR;\n                    }\n\n                    njs_key_string_get(vm, value2, &string);\n                    njs_type_error(vm,\n                               \"(intermediate value)[\\\"%V\\\"] is not a function\",\n                               &string);\n                    goto error;\n                }\n\n                ret = njs_function_frame_create(vm, &dst, value1,\n                                                method_frame->nargs,\n                                                method_frame->ctor);\n\n                if (njs_slow_path(ret != NJS_OK)) {\n                    goto error;\n                }\n\n                ret = sizeof(njs_vmcode_method_frame_t);\n                break;\n\n            case NJS_VMCODE_FUNCTION_CALL:\n                vm->active_frame->native.pc = pc;\n\n                njs_vmcode_operand(vm, (njs_index_t) value2, value2);\n\n                ret = njs_function_frame_invoke(vm, value2);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                ret = sizeof(njs_vmcode_function_call_t);\n                break;\n\n            case NJS_VMCODE_PROPERTY_NEXT:\n                pnext = (njs_vmcode_prop_next_t *) pc;\n                retval = njs_scope_value(vm, pnext->retval);\n\n                next = value2->data.u.next;\n\n                if (next->index < next->array->length) {\n                    *retval = next->array->start[next->index++];\n\n                    ret = pnext->offset;\n                    break;\n                }\n\n                njs_mp_free(vm->mem_pool, next);\n\n                ret = sizeof(njs_vmcode_prop_next_t);\n                break;\n\n            case NJS_VMCODE_ARGUMENTS:\n                ret = njs_vmcode_arguments(vm, pc);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                break;\n\n            case NJS_VMCODE_PROTO_INIT:\n                set = (njs_vmcode_prop_set_t *) pc;\n                njs_vmcode_operand(vm, set->value, retval);\n                ret = njs_vmcode_proto_init(vm, value1, value2, retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                break;\n\n            case NJS_VMCODE_IMPORT:\n                import = (njs_vmcode_import_t *) pc;\n                retval = njs_scope_value(vm, import->retval);\n                ret = njs_vmcode_import(vm, import->module, retval);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                break;\n\n            case NJS_VMCODE_AWAIT:\n                await = (njs_vmcode_await_t *) pc;\n                return njs_vmcode_await(vm, await, promise_cap, async_ctx);\n\n            case NJS_VMCODE_TRY_START:\n                ret = njs_vmcode_try_start(vm, value1, value2, pc);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto error;\n                }\n\n                break;\n\n            case NJS_VMCODE_THROW:\n                njs_vmcode_operand(vm, (njs_index_t) value2, value2);\n                vm->retval = *value2;\n                goto error;\n\n            case NJS_VMCODE_TRY_BREAK:\n                try_trampoline = (njs_vmcode_try_trampoline_t *) pc;\n                value1 = njs_scope_value(vm, try_trampoline->exit_value);\n\n                ret = njs_vmcode_try_break(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_TRY_CONTINUE:\n                try_trampoline = (njs_vmcode_try_trampoline_t *) pc;\n                value1 = njs_scope_value(vm, try_trampoline->exit_value);\n\n                ret = njs_vmcode_try_continue(vm, value1, value2);\n                break;\n\n            case NJS_VMCODE_TRY_END:\n                ret = njs_vmcode_try_end(vm, value1, value2);\n                break;\n\n            \/*\n             * njs_vmcode_catch() is set on the start of a \"catch\" block to\n             * store exception and to remove a \"try\" block if there is no\n             * \"finally\" block or to update a catch address to the start of\n             * a \"finally\" block.\n             * njs_vmcode_catch() is set on the start of a \"finally\" block\n             * to store uncaught exception and to remove a \"try\" block.\n             *\/\n            case NJS_VMCODE_CATCH:\n                *value1 = vm->retval;\n\n                if ((njs_jump_off_t) value2 == sizeof(njs_vmcode_catch_t)) {\n                    ret = njs_vmcode_try_end(vm, value1, value2);\n\n                } else {\n                    frame = (njs_frame_t *) vm->top_frame;\n                    frame->exception.catch = pc + (njs_jump_off_t) value2;\n                    ret = sizeof(njs_vmcode_catch_t);\n                }\n\n                break;\n\n            case NJS_VMCODE_FINALLY:\n                finally = (njs_vmcode_finally_t *) pc;\n                value1 = njs_scope_value(vm, finally->exit_value);\n\n                ret = njs_vmcode_finally(vm, value1, value2, pc);\n\n                switch (ret) {\n                case NJS_OK:\n                    return NJS_OK;\n                case NJS_ERROR:\n                    goto error;\n                }\n\n                break;\n\n            case NJS_VMCODE_LET:\n                var = (njs_vmcode_variable_t *) pc;\n                value1 = njs_scope_value(vm, var->dst);\n\n                if (njs_is_valid(value1)) {\n                    value1 = njs_mp_alloc(vm->mem_pool, sizeof(njs_value_t));\n                    if (njs_slow_path(value1 == NULL)) {\n                        return NJS_ERROR;\n                    }\n\n                    njs_scope_value_set(vm, var->dst, value1);\n                }\n\n                njs_set_undefined(value1);\n\n                ret = sizeof(njs_vmcode_variable_t);\n                break;\n\n            case NJS_VMCODE_LET_UPDATE:\n                var = (njs_vmcode_variable_t *) pc;\n                value2 = njs_scope_value(vm, var->dst);\n\n                value1 = njs_mp_alloc(vm->mem_pool, sizeof(njs_value_t));\n                if (njs_slow_path(value1 == NULL)) {\n                    return NJS_ERROR;\n                }\n\n                *value1 = *value2;\n\n                njs_scope_value_set(vm, var->dst, value1);\n\n                ret = sizeof(njs_vmcode_variable_t);\n                break;\n\n            case NJS_VMCODE_INITIALIZATION_TEST:\n                var = (njs_vmcode_variable_t *) pc;\n                value1 = njs_scope_value(vm, var->dst);\n\n                if (njs_is_valid(value1)) {\n                    ret = sizeof(njs_vmcode_variable_t);\n                    break;\n                }\n\n                \/* Fall through. *\/\n\n            case NJS_VMCODE_NOT_INITIALIZED:\n                njs_reference_error(vm, \"cannot access variable \"\n                                        \"before initialization\");\n                goto error;\n\n            case NJS_VMCODE_ERROR:\n                njs_vmcode_error(vm, pc);\n                goto error;\n\n            case NJS_VMCODE_ASSIGNMENT_ERROR:\n                njs_type_error(vm, \"assignment to constant variable\");\n                goto error;\n\n            default:\n                njs_internal_error(vm, \"%d has NO retval\", op);\n                goto error;\n            }\n        }\n\n        pc += ret;\n    }\n\nerror:\n\n    if (njs_is_error(&vm->retval)) {\n        vm->active_frame->native.pc = pc;\n        (void) njs_error_stack_attach(vm, &vm->retval);\n    }\n\n    for ( ;; ) {\n        native = vm->top_frame;\n\n        if (!native->native) {\n            frame = (njs_frame_t *) native;\n            catch = frame->exception.catch;\n\n            if (catch != NULL) {\n                pc = catch;\n\n                goto next;\n            }\n        }\n\n        previous = native->previous;\n        if (previous == NULL) {\n            break;\n        }\n\n        lambda_call = (native == &vm->active_frame->native);\n\n        njs_vm_scopes_restore(vm, native, previous);\n\n        if (native->size != 0) {\n            vm->stack_size -= native->size;\n            njs_mp_free(vm->mem_pool, native);\n        }\n\n        if (lambda_call) {\n            break;\n        }\n    }\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":6838,"total_token_length":7074,"max_tokens_setting":8192}
+{"idx":10756,"func":"int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC) \/* {{{ *\/\n{\n\tphar_zip_dir_end locator;\n\tchar buf[sizeof(locator) + 65536];\n\tlong size;\n\tphp_uint16 i;\n\tphar_archive_data *mydata = NULL;\n\tphar_entry_info entry = {0};\n\tchar *p = buf, *ext, *actual_alias = NULL;\n\tchar *metadata = NULL;\n\n\tsize = php_stream_tell(fp);\n\n\tif (size > sizeof(locator) + 65536) {\n\t\t\/* seek to max comment length + end of central directory record *\/\n\t\tsize = sizeof(locator) + 65536;\n\t\tif (FAILURE == php_stream_seek(fp, -size, SEEK_END)) {\n\t\t\tphp_stream_close(fp);\n\t\t\tif (error) {\n\t\t\t\tspprintf(error, 4096, \"phar error: unable to search for end of central directory in zip-based phar \\\"%s\\\"\", fname);\n\t\t\t}\n\t\t\treturn FAILURE;\n\t\t}\n\t} else {\n\t\tphp_stream_seek(fp, 0, SEEK_SET);\n\t}\n\n\tif (!php_stream_read(fp, buf, size)) {\n\t\tphp_stream_close(fp);\n\t\tif (error) {\n\t\t\tspprintf(error, 4096, \"phar error: unable to read in data to search for end of central directory in zip-based phar \\\"%s\\\"\", fname);\n\t\t}\n\t\treturn FAILURE;\n        }\n \n        while ((p=(char *) memchr(p + 1, 'P', (size_t) (size - (p + 1 - buf)))) != NULL) {\n               if (!memcmp(p + 1, \"K\\5\\6\", 3)) {\n                        memcpy((void *)&locator, (void *) p, sizeof(locator));\n                        if (PHAR_GET_16(locator.centraldisk) != 0 || PHAR_GET_16(locator.disknumber) != 0) {\n                                \/* split archives not handled *\/\n\t\t\t\tphp_stream_close(fp);\n\t\t\t\tif (error) {\n\t\t\t\t\tspprintf(error, 4096, \"phar error: split archives spanning multiple zips cannot be processed in zip-based phar \\\"%s\\\"\", fname);\n\t\t\t\t}\n\t\t\t\treturn FAILURE;\n\t\t\t}\n\n\t\t\tif (PHAR_GET_16(locator.counthere) != PHAR_GET_16(locator.count)) {\n\t\t\t\tif (error) {\n\t\t\t\t\tspprintf(error, 4096, \"phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar \\\"%s\\\"\", fname);\n\t\t\t\t}\n\t\t\t\tphp_stream_close(fp);\n\t\t\t\treturn FAILURE;\n\t\t\t}\n\n\t\t\tmydata = pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist));\n\t\t\tmydata->is_persistent = PHAR_G(persist);\n\n\t\t\t\/* read in archive comment, if any *\/\n\t\t\tif (PHAR_GET_16(locator.comment_len)) {\n\n\t\t\t\tmetadata = p + sizeof(locator);\n\n\t\t\t\tif (PHAR_GET_16(locator.comment_len) != size - (metadata - buf)) {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tspprintf(error, 4096, \"phar error: corrupt zip archive, zip file comment truncated in zip-based phar \\\"%s\\\"\", fname);\n\t\t\t\t\t}\n\t\t\t\t\tphp_stream_close(fp);\n\t\t\t\t\tpefree(mydata, mydata->is_persistent);\n\t\t\t\t\treturn FAILURE;\n\t\t\t\t}\n\n\t\t\t\tmydata->metadata_len = PHAR_GET_16(locator.comment_len);\n\n\t\t\t\tif (phar_parse_metadata(&metadata, &mydata->metadata, PHAR_GET_16(locator.comment_len) TSRMLS_CC) == FAILURE) {\n\t\t\t\t\tmydata->metadata_len = 0;\n\t\t\t\t\t\/* if not valid serialized data, it is a regular string *\/\n\n\t\t\t\t\tif (entry.is_persistent) {\n\t\t\t\t\t\tALLOC_PERMANENT_ZVAL(mydata->metadata);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tALLOC_ZVAL(mydata->metadata);\n\t\t\t\t\t}\n\n\t\t\t\t\tINIT_ZVAL(*mydata->metadata);\n\t\t\t\t\tmetadata = pestrndup(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent);\n\t\t\t\t\tZVAL_STRINGL(mydata->metadata, metadata, PHAR_GET_16(locator.comment_len), 0);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmydata->metadata = NULL;\n\t\t\t}\n\n\t\t\tgoto foundit;\n\t\t}\n\t}\n\n\tphp_stream_close(fp);\n\n\tif (error) {\n\t\tspprintf(error, 4096, \"phar error: end of central directory not found in zip-based phar \\\"%s\\\"\", fname);\n\t}\n\n\treturn FAILURE;\nfoundit:\n\tmydata->fname = pestrndup(fname, fname_len, mydata->is_persistent);\n#ifdef PHP_WIN32\n\tphar_unixify_path_separators(mydata->fname, fname_len);\n#endif\n\tmydata->is_zip = 1;\n\tmydata->fname_len = fname_len;\n\text = strrchr(mydata->fname, '\/');\n\n\tif (ext) {\n\t\tmydata->ext = memchr(ext, '.', (mydata->fname + fname_len) - ext);\n\t\tif (mydata->ext == ext) {\n\t\t\tmydata->ext = memchr(ext + 1, '.', (mydata->fname + fname_len) - ext - 1);\n\t\t}\n\t\tif (mydata->ext) {\n\t\t\tmydata->ext_len = (mydata->fname + fname_len) - mydata->ext;\n\t\t}\n\t}\n\n\t\/* clean up on big-endian systems *\/\n\t\/* seek to central directory *\/\n\tphp_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET);\n\t\/* read in central directory *\/\n\tzend_hash_init(&mydata->manifest, PHAR_GET_16(locator.count),\n\t\tzend_get_hash_value, destroy_phar_manifest_entry, (zend_bool)mydata->is_persistent);\n\tzend_hash_init(&mydata->mounted_dirs, 5,\n\t\tzend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);\n\tzend_hash_init(&mydata->virtual_dirs, PHAR_GET_16(locator.count) * 2,\n\t\tzend_get_hash_value, NULL, (zend_bool)mydata->is_persistent);\n\tentry.phar = mydata;\n\tentry.is_zip = 1;\n\tentry.fp_type = PHAR_FP;\n\tentry.is_persistent = mydata->is_persistent;\n#define PHAR_ZIP_FAIL_FREE(errmsg, save) \\\n\t\t\tzend_hash_destroy(&mydata->manifest); \\\n\t\t\tmydata->manifest.arBuckets = 0; \\\n\t\t\tzend_hash_destroy(&mydata->mounted_dirs); \\\n\t\t\tmydata->mounted_dirs.arBuckets = 0; \\\n\t\t\tzend_hash_destroy(&mydata->virtual_dirs); \\\n\t\t\tmydata->virtual_dirs.arBuckets = 0; \\\n\t\t\tphp_stream_close(fp); \\\n\t\t\tif (mydata->metadata) { \\\n\t\t\t\tzval_dtor(mydata->metadata); \\\n\t\t\t} \\\n\t\t\tif (mydata->signature) { \\\n\t\t\t\tefree(mydata->signature); \\\n\t\t\t} \\\n\t\t\tif (error) { \\\n\t\t\t\tspprintf(error, 4096, \"phar error: %s in zip-based phar \\\"%s\\\"\", errmsg, mydata->fname); \\\n\t\t\t} \\\n\t\t\tpefree(mydata->fname, mydata->is_persistent); \\\n\t\t\tif (mydata->alias) { \\\n\t\t\t\tpefree(mydata->alias, mydata->is_persistent); \\\n\t\t\t} \\\n\t\t\tpefree(mydata, mydata->is_persistent); \\\n\t\t\tefree(save); \\\n\t\t\treturn FAILURE;\n#define PHAR_ZIP_FAIL(errmsg) \\\n\t\t\tzend_hash_destroy(&mydata->manifest); \\\n\t\t\tmydata->manifest.arBuckets = 0; \\\n\t\t\tzend_hash_destroy(&mydata->mounted_dirs); \\\n\t\t\tmydata->mounted_dirs.arBuckets = 0; \\\n\t\t\tzend_hash_destroy(&mydata->virtual_dirs); \\\n\t\t\tmydata->virtual_dirs.arBuckets = 0; \\\n\t\t\tphp_stream_close(fp); \\\n\t\t\tif (mydata->metadata) { \\\n\t\t\t\tzval_dtor(mydata->metadata); \\\n\t\t\t} \\\n\t\t\tif (mydata->signature) { \\\n\t\t\t\tefree(mydata->signature); \\\n\t\t\t} \\\n\t\t\tif (error) { \\\n\t\t\t\tspprintf(error, 4096, \"phar error: %s in zip-based phar \\\"%s\\\"\", errmsg, mydata->fname); \\\n\t\t\t} \\\n\t\t\tpefree(mydata->fname, mydata->is_persistent); \\\n\t\t\tif (mydata->alias) { \\\n\t\t\t\tpefree(mydata->alias, mydata->is_persistent); \\\n\t\t\t} \\\n\t\t\tpefree(mydata, mydata->is_persistent); \\\n\t\t\treturn FAILURE;\n\n\t\/* add each central directory item to the manifest *\/\n\tfor (i = 0; i < PHAR_GET_16(locator.count); ++i) {\n\t\tphar_zip_central_dir_file zipentry;\n\t\toff_t beforeus = php_stream_tell(fp);\n\n\t\tif (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {\n\t\t\tPHAR_ZIP_FAIL(\"unable to read central directory entry, truncated\");\n\t\t}\n\n\t\t\/* clean up for bigendian systems *\/\n\t\tif (memcmp(\"PK\\1\\2\", zipentry.signature, 4)) {\n\t\t\t\/* corrupted entry *\/\n\t\t\tPHAR_ZIP_FAIL(\"corrupted central directory entry, no magic signature\");\n\t\t}\n\n\t\tif (entry.is_persistent) {\n\t\t\tentry.manifest_pos = i;\n\t\t}\n\n\t\tentry.compressed_filesize = PHAR_GET_32(zipentry.compsize);\n\t\tentry.uncompressed_filesize = PHAR_GET_32(zipentry.uncompsize);\n\t\tentry.crc32 = PHAR_GET_32(zipentry.crc32);\n\t\t\/* do not PHAR_GET_16 either on the next line *\/\n\t\tentry.timestamp = phar_zip_d2u_time(zipentry.timestamp, zipentry.datestamp);\n\t\tentry.flags = PHAR_ENT_PERM_DEF_FILE;\n\t\tentry.header_offset = PHAR_GET_32(zipentry.offset);\n\t\tentry.offset = entry.offset_abs = PHAR_GET_32(zipentry.offset) + sizeof(phar_zip_file_header) + PHAR_GET_16(zipentry.filename_len) +\n\t\t\tPHAR_GET_16(zipentry.extra_len);\n\n\t\tif (PHAR_GET_16(zipentry.flags) & PHAR_ZIP_FLAG_ENCRYPTED) {\n\t\t\tPHAR_ZIP_FAIL(\"Cannot process encrypted zip files\");\n\t\t}\n\n\t\tif (!PHAR_GET_16(zipentry.filename_len)) {\n\t\t\tPHAR_ZIP_FAIL(\"Cannot process zips created from stdin (zero-length filename)\");\n\t\t}\n\n\t\tentry.filename_len = PHAR_GET_16(zipentry.filename_len);\n\t\tentry.filename = (char *) pemalloc(entry.filename_len + 1, entry.is_persistent);\n\n\t\tif (entry.filename_len != php_stream_read(fp, entry.filename, entry.filename_len)) {\n\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\tPHAR_ZIP_FAIL(\"unable to read in filename from central directory, truncated\");\n\t\t}\n\n\t\tentry.filename[entry.filename_len] = '\\0';\n\n\t\tif (entry.filename[entry.filename_len - 1] == '\/') {\n\t\t\tentry.is_dir = 1;\n\t\t\tif(entry.filename_len > 1) {\n\t\t\t\tentry.filename_len--;\n\t\t\t}\n\t\t\tentry.flags |= PHAR_ENT_PERM_DEF_DIR;\n\t\t} else {\n\t\t\tentry.is_dir = 0;\n\t\t}\n\n\t\tif (entry.filename_len == sizeof(\".phar\/signature.bin\")-1 && !strncmp(entry.filename, \".phar\/signature.bin\", sizeof(\".phar\/signature.bin\")-1)) {\n\t\t\tsize_t read;\n\t\t\tphp_stream *sigfile;\n\t\t\toff_t now;\n\t\t\tchar *sig;\n\n\t\t\tnow = php_stream_tell(fp);\n\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\tsigfile = php_stream_fopen_tmpfile();\n\t\t\tif (!sigfile) {\n\t\t\t\tPHAR_ZIP_FAIL(\"couldn't open temporary file\");\n\t\t\t}\n\n\t\t\tphp_stream_seek(fp, 0, SEEK_SET);\n\t\t\t\/* copy file contents + local headers and zip comment, if any, to be hashed for signature *\/\n\t\t\tphar_stream_copy_to_stream(fp, sigfile, entry.header_offset, NULL);\n\t\t\t\/* seek to central directory *\/\n\t\t\tphp_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET);\n\t\t\t\/* copy central directory header *\/\n\t\t\tphar_stream_copy_to_stream(fp, sigfile, beforeus - PHAR_GET_32(locator.cdir_offset), NULL);\n\t\t\tif (metadata) {\n\t\t\t\tphp_stream_write(sigfile, metadata, PHAR_GET_16(locator.comment_len));\n\t\t\t}\n\t\t\tphp_stream_seek(fp, sizeof(phar_zip_file_header) + entry.header_offset + entry.filename_len + PHAR_GET_16(zipentry.extra_len), SEEK_SET);\n\t\t\tsig = (char *) emalloc(entry.uncompressed_filesize);\n\t\t\tread = php_stream_read(fp, sig, entry.uncompressed_filesize);\n\t\t\tif (read != entry.uncompressed_filesize) {\n\t\t\t\tphp_stream_close(sigfile);\n\t\t\t\tefree(sig);\n\t\t\t\tPHAR_ZIP_FAIL(\"signature cannot be read\");\n\t\t\t}\n\t\t\tmydata->sig_flags = PHAR_GET_32(sig);\n\t\t\tif (FAILURE == phar_verify_signature(sigfile, php_stream_tell(sigfile), mydata->sig_flags, sig + 8, entry.uncompressed_filesize - 8, fname, &mydata->signature, &mydata->sig_len, error TSRMLS_CC)) {\n\t\t\t\tefree(sig);\n\t\t\t\tif (error) {\n\t\t\t\t\tchar *save;\n\t\t\t\t\tphp_stream_close(sigfile);\n\t\t\t\t\tspprintf(&save, 4096, \"signature cannot be verified: %s\", *error);\n\t\t\t\t\tefree(*error);\n\t\t\t\t\tPHAR_ZIP_FAIL_FREE(save, save);\n\t\t\t\t} else {\n\t\t\t\t\tphp_stream_close(sigfile);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"signature cannot be verified\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tphp_stream_close(sigfile);\n\t\t\tefree(sig);\n\t\t\t\/* signature checked out, let's ensure this is the last file in the phar *\/\n\t\t\tif (i != PHAR_GET_16(locator.count) - 1) {\n\t\t\t\tPHAR_ZIP_FAIL(\"entries exist after signature, invalid phar\");\n\t\t\t}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tphar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);\n\n\t\tif (PHAR_GET_16(zipentry.extra_len)) {\n\t\t\toff_t loc = php_stream_tell(fp);\n\t\t\tif (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len) TSRMLS_CC)) {\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"Unable to process extra field header for file in central directory\");\n\t\t\t}\n\t\t\tphp_stream_seek(fp, loc + PHAR_GET_16(zipentry.extra_len), SEEK_SET);\n\t\t}\n\n\t\tswitch (PHAR_GET_16(zipentry.compressed)) {\n\t\t\tcase PHAR_ZIP_COMP_NONE :\n\t\t\t\t\/* compression flag already set *\/\n\t\t\t\tbreak;\n\t\t\tcase PHAR_ZIP_COMP_DEFLATE :\n\t\t\t\tentry.flags |= PHAR_ENT_COMPRESSED_GZ;\n\t\t\t\tif (!PHAR_G(has_zlib)) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"zlib extension is required\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase PHAR_ZIP_COMP_BZIP2 :\n\t\t\t\tentry.flags |= PHAR_ENT_COMPRESSED_BZ2;\n\t\t\t\tif (!PHAR_G(has_bz2)) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"bzip2 extension is required\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (Shrunk) used in this zip\");\n\t\t\tcase 2 :\n\t\t\tcase 3 :\n\t\t\tcase 4 :\n\t\t\tcase 5 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (Reduce) used in this zip\");\n\t\t\tcase 6 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (Implode) used in this zip\");\n\t\t\tcase 7 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (Tokenize) used in this zip\");\n\t\t\tcase 9 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (Deflate64) used in this zip\");\n\t\t\tcase 10 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (PKWare Implode\/old IBM TERSE) used in this zip\");\n\t\t\tcase 14 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (LZMA) used in this zip\");\n\t\t\tcase 18 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (IBM TERSE) used in this zip\");\n\t\t\tcase 19 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (IBM LZ77) used in this zip\");\n\t\t\tcase 97 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (WavPack) used in this zip\");\n\t\t\tcase 98 :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (PPMd) used in this zip\");\n\t\t\tdefault :\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unsupported compression method (unknown) used in this zip\");\n\t\t}\n\n\t\t\/* get file metadata *\/\n\t\tif (PHAR_GET_16(zipentry.comment_len)) {\n\t\t\tif (PHAR_GET_16(zipentry.comment_len) != php_stream_read(fp, buf, PHAR_GET_16(zipentry.comment_len))) {\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"unable to read in file comment, truncated\");\n\t\t\t}\n\n\t\t\tp = buf;\n\t\t\tentry.metadata_len = PHAR_GET_16(zipentry.comment_len);\n\n\t\t\tif (phar_parse_metadata(&p, &(entry.metadata), PHAR_GET_16(zipentry.comment_len) TSRMLS_CC) == FAILURE) {\n\t\t\t\tentry.metadata_len = 0;\n\t\t\t\t\/* if not valid serialized data, it is a regular string *\/\n\n\t\t\t\tif (entry.is_persistent) {\n\t\t\t\t\tALLOC_PERMANENT_ZVAL(entry.metadata);\n\t\t\t\t} else {\n\t\t\t\t\tALLOC_ZVAL(entry.metadata);\n\t\t\t\t}\n\n\t\t\t\tINIT_ZVAL(*entry.metadata);\n\t\t\t\tZVAL_STRINGL(entry.metadata, pestrndup(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent), PHAR_GET_16(zipentry.comment_len), 0);\n\t\t\t}\n\t\t} else {\n\t\t\tentry.metadata = NULL;\n\t\t}\n\n\t\tif (!actual_alias && entry.filename_len == sizeof(\".phar\/alias.txt\")-1 && !strncmp(entry.filename, \".phar\/alias.txt\", sizeof(\".phar\/alias.txt\")-1)) {\n\t\t\tphp_stream_filter *filter;\n\t\t\toff_t saveloc;\n\t\t\t\/* verify local file header *\/\n\t\t\tphar_zip_file_header local;\n\n\t\t\t\/* archive alias found *\/\n\t\t\tsaveloc = php_stream_tell(fp);\n\t\t\tphp_stream_seek(fp, PHAR_GET_32(zipentry.offset), SEEK_SET);\n\n\t\t\tif (sizeof(local) != php_stream_read(fp, (char *) &local, sizeof(local))) {\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"phar error: internal corruption of zip-based phar (cannot read local file header for alias)\");\n\t\t\t}\n\n\t\t\t\/* verify local header *\/\n\t\t\tif (entry.filename_len != PHAR_GET_16(local.filename_len) || entry.crc32 != PHAR_GET_32(local.crc32) || entry.uncompressed_filesize != PHAR_GET_32(local.uncompsize) || entry.compressed_filesize != PHAR_GET_32(local.compsize)) {\n\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\tPHAR_ZIP_FAIL(\"phar error: internal corruption of zip-based phar (local header of alias does not match central directory)\");\n\t\t\t}\n\n\t\t\t\/* construct actual offset to file start - local extra_len can be different from central extra_len *\/\n\t\t\tentry.offset = entry.offset_abs =\n\t\t\t\tsizeof(local) + entry.header_offset + PHAR_GET_16(local.filename_len) + PHAR_GET_16(local.extra_len);\n\t\t\tphp_stream_seek(fp, entry.offset, SEEK_SET);\n\t\t\t\/* these next lines should be for php < 5.2.6 after 5.3 filters are fixed *\/\n\t\t\tfp->writepos = 0;\n\t\t\tfp->readpos = 0;\n\t\t\tphp_stream_seek(fp, entry.offset, SEEK_SET);\n\t\t\tfp->writepos = 0;\n\t\t\tfp->readpos = 0;\n\t\t\t\/* the above lines should be for php < 5.2.6 after 5.3 filters are fixed *\/\n\n\t\t\tmydata->alias_len = entry.uncompressed_filesize;\n\n\t\t\tif (entry.flags & PHAR_ENT_COMPRESSED_GZ) {\n\t\t\t\tfilter = php_stream_filter_create(\"zlib.inflate\", NULL, php_stream_is_persistent(fp) TSRMLS_CC);\n\n\t\t\t\tif (!filter) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"unable to decompress alias, zlib filter creation failed\");\n\t\t\t\t}\n\n\t\t\t\tphp_stream_filter_append(&fp->readfilters, filter);\n\n\t\t\t\tif (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"unable to read in alias, truncated\");\n\t\t\t\t}\n\n\t\t\t\tphp_stream_filter_flush(filter, 1);\n\t\t\t\tphp_stream_filter_remove(filter, 1 TSRMLS_CC);\n\n\t\t\t} else if (entry.flags & PHAR_ENT_COMPRESSED_BZ2) {\n\t\t\t\tfilter = php_stream_filter_create(\"bzip2.decompress\", NULL, php_stream_is_persistent(fp) TSRMLS_CC);\n\n\t\t\t\tif (!filter) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"unable to read in alias, bzip2 filter creation failed\");\n\t\t\t\t}\n\n\t\t\t\tphp_stream_filter_append(&fp->readfilters, filter);\n\n\t\t\t\tif (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"unable to read in alias, truncated\");\n\t\t\t\t}\n\n\t\t\t\tphp_stream_filter_flush(filter, 1);\n\t\t\t\tphp_stream_filter_remove(filter, 1 TSRMLS_CC);\n\t\t\t} else {\n\t\t\t\tif (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {\n\t\t\t\t\tpefree(entry.filename, entry.is_persistent);\n\t\t\t\t\tPHAR_ZIP_FAIL(\"unable to read in alias, truncated\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/* return to central directory parsing *\/\n\t\t\tphp_stream_seek(fp, saveloc, SEEK_SET);\n\t\t}\n\n\t\tphar_set_inode(&entry TSRMLS_CC);\n\t\tzend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void *)&entry,sizeof(phar_entry_info), NULL);\n\t}\n\n\tmydata->fp = fp;\n\n\tif (zend_hash_exists(&(mydata->manifest), \".phar\/stub.php\", sizeof(\".phar\/stub.php\")-1)) {\n\t\tmydata->is_data = 0;\n\t} else {\n\t\tmydata->is_data = 1;\n\t}\n\n\tzend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);\n\n\tif (actual_alias) {\n\t\tphar_archive_data **fd_ptr;\n\n\t\tif (!phar_validate_alias(actual_alias, mydata->alias_len)) {\n\t\t\tif (error) {\n\t\t\t\tspprintf(error, 4096, \"phar error: invalid alias \\\"%s\\\" in zip-based phar \\\"%s\\\"\", actual_alias, fname);\n\t\t\t}\n\t\t\tefree(actual_alias);\n\t\t\tzend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);\n\t\t\treturn FAILURE;\n\t\t}\n\n\t\tmydata->is_temporary_alias = 0;\n\n\t\tif (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void **)&fd_ptr)) {\n\t\t\tif (SUCCESS != phar_free_alias(*fd_ptr, actual_alias, mydata->alias_len TSRMLS_CC)) {\n\t\t\t\tif (error) {\n\t\t\t\t\tspprintf(error, 4096, \"phar error: Unable to add zip-based phar \\\"%s\\\" with implicit alias, alias is already in use\", fname);\n\t\t\t\t}\n\t\t\t\tefree(actual_alias);\n\t\t\t\tzend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);\n\t\t\t\treturn FAILURE;\n\t\t\t}\n\t\t}\n\n\t\tmydata->alias = entry.is_persistent ? pestrndup(actual_alias, mydata->alias_len, 1) : actual_alias;\n\n\t\tif (entry.is_persistent) {\n\t\t\tefree(actual_alias);\n\t\t}\n\n\t\tzend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);\n\t} else {\n\t\tphar_archive_data **fd_ptr;\n\n\t\tif (alias_len) {\n\t\t\tif (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void **)&fd_ptr)) {\n\t\t\t\tif (SUCCESS != phar_free_alias(*fd_ptr, alias, alias_len TSRMLS_CC)) {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tspprintf(error, 4096, \"phar error: Unable to add zip-based phar \\\"%s\\\" with explicit alias, alias is already in use\", fname);\n\t\t\t\t\t}\n\t\t\t\t\tzend_hash_del(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len);\n\t\t\t\t\treturn FAILURE;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tzend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);\n\t\t\tmydata->alias = pestrndup(alias, alias_len, mydata->is_persistent);\n\t\t\tmydata->alias_len = alias_len;\n\t\t} else {\n\t\t\tmydata->alias = pestrndup(mydata->fname, fname_len, mydata->is_persistent);\n\t\t\tmydata->alias_len = fname_len;\n\t\t}\n\n\t\tmydata->is_temporary_alias = 1;\n\t}\n\n\tif (pphar) {\n\t\t*pphar = mydata;\n\t}\n\n\treturn SUCCESS;\n}\n\/* }}} *\/\n","target":1,"code_token_length":6046,"total_token_length":6282,"max_tokens_setting":8192}
+{"idx":367,"func":"int ff_h264_decode_mb_cabac ( H264Context * h ) {\n int mb_xy ;\n int mb_type , partition_count , cbp = 0 ;\n int dct8x8_allowed = h -> pps . transform_8x8_mode ;\n int decode_chroma = h -> sps . chroma_format_idc == 1 || h -> sps . chroma_format_idc == 2 ;\n const int pixel_shift = h -> pixel_shift ;\n mb_xy = h -> mb_xy = h -> mb_x + h -> mb_y * h -> mb_stride ;\n tprintf ( h -> avctx , \"pic:%d mb:%d\/%d\\n\" , h -> frame_num , h -> mb_x , h -> mb_y ) ;\n if ( h -> slice_type_nos != AV_PICTURE_TYPE_I ) {\n int skip ;\n if ( FRAME_MBAFF && ( h -> mb_y & 1 ) == 1 && h -> prev_mb_skipped ) skip = h -> next_mb_skipped ;\n else skip = decode_cabac_mb_skip ( h , h -> mb_x , h -> mb_y ) ;\n if ( skip ) {\n if ( FRAME_MBAFF && ( h -> mb_y & 1 ) == 0 ) {\n h -> cur_pic . f . mb_type [ mb_xy ] = MB_TYPE_SKIP ;\n h -> next_mb_skipped = decode_cabac_mb_skip ( h , h -> mb_x , h -> mb_y + 1 ) ;\n if ( ! h -> next_mb_skipped ) h -> mb_mbaff = h -> mb_field_decoding_flag = decode_cabac_field_decoding_flag ( h ) ;\n }\n decode_mb_skip ( h ) ;\n h -> cbp_table [ mb_xy ] = 0 ;\n h -> chroma_pred_mode_table [ mb_xy ] = 0 ;\n h -> last_qscale_diff = 0 ;\n return 0 ;\n }\n }\n if ( FRAME_MBAFF ) {\n if ( ( h -> mb_y & 1 ) == 0 ) h -> mb_mbaff = h -> mb_field_decoding_flag = decode_cabac_field_decoding_flag ( h ) ;\n }\n h -> prev_mb_skipped = 0 ;\n fill_decode_neighbors ( h , - ( MB_FIELD ) ) ;\n if ( h -> slice_type_nos == AV_PICTURE_TYPE_B ) {\n int ctx = 0 ;\n assert ( h -> slice_type_nos == AV_PICTURE_TYPE_B ) ;\n if ( ! IS_DIRECT ( h -> left_type [ LTOP ] - 1 ) ) ctx ++ ;\n if ( ! IS_DIRECT ( h -> top_type - 1 ) ) ctx ++ ;\n if ( ! get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + ctx ] ) ) {\n mb_type = 0 ;\n }\n else if ( ! get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 3 ] ) ) {\n mb_type = 1 + get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) ;\n }\n else {\n int bits ;\n bits = get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 4 ] ) << 3 ;\n bits += get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) << 2 ;\n bits += get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) << 1 ;\n bits += get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) ;\n if ( bits < 8 ) {\n mb_type = bits + 3 ;\n }\n else if ( bits == 13 ) {\n mb_type = decode_cabac_intra_mb_type ( h , 32 , 0 ) ;\n goto decode_intra_mb ;\n }\n else if ( bits == 14 ) {\n mb_type = 11 ;\n }\n else if ( bits == 15 ) {\n mb_type = 22 ;\n }\n else {\n bits = ( bits << 1 ) + get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 27 + 5 ] ) ;\n mb_type = bits - 4 ;\n }\n }\n partition_count = b_mb_type_info [ mb_type ] . partition_count ;\n mb_type = b_mb_type_info [ mb_type ] . type ;\n }\n else if ( h -> slice_type_nos == AV_PICTURE_TYPE_P ) {\n if ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 14 ] ) == 0 ) {\n if ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 15 ] ) == 0 ) {\n mb_type = 3 * get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 16 ] ) ;\n }\n else {\n mb_type = 2 - get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 17 ] ) ;\n }\n partition_count = p_mb_type_info [ mb_type ] . partition_count ;\n mb_type = p_mb_type_info [ mb_type ] . type ;\n }\n else {\n mb_type = decode_cabac_intra_mb_type ( h , 17 , 0 ) ;\n goto decode_intra_mb ;\n }\n }\n else {\n mb_type = decode_cabac_intra_mb_type ( h , 3 , 1 ) ;\n if ( h -> slice_type == AV_PICTURE_TYPE_SI && mb_type ) mb_type -- ;\n assert ( h -> slice_type_nos == AV_PICTURE_TYPE_I ) ;\n decode_intra_mb : partition_count = 0 ;\n cbp = i_mb_type_info [ mb_type ] . cbp ;\n h -> intra16x16_pred_mode = i_mb_type_info [ mb_type ] . pred_mode ;\n mb_type = i_mb_type_info [ mb_type ] . type ;\n }\n if ( MB_FIELD ) mb_type |= MB_TYPE_INTERLACED ;\n h -> slice_table [ mb_xy ] = h -> slice_num ;\n if ( IS_INTRA_PCM ( mb_type ) ) {\n const int mb_size = ff_h264_mb_sizes [ h -> sps . chroma_format_idc ] * h -> sps . bit_depth_luma >> 3 ;\n const uint8_t * ptr ;\n ptr = h -> cabac . bytestream ;\n if ( h -> cabac . low & 0x1 ) ptr -- ;\n if ( CABAC_BITS == 16 ) {\n if ( h -> cabac . low & 0x1FF ) ptr -- ;\n }\n if ( ( int ) ( h -> cabac . bytestream_end - ptr ) < mb_size ) return - 1 ;\n h -> intra_pcm_ptr = ptr ;\n ptr += mb_size ;\n ff_init_cabac_decoder ( & h -> cabac , ptr , h -> cabac . bytestream_end - ptr ) ;\n h -> cbp_table [ mb_xy ] = 0xf7ef ;\n h -> chroma_pred_mode_table [ mb_xy ] = 0 ;\n h -> cur_pic . f . qscale_table [ mb_xy ] = 0 ;\n memset ( h -> non_zero_count [ mb_xy ] , 16 , 48 ) ;\n h -> cur_pic . f . mb_type [ mb_xy ] = mb_type ;\n h -> last_qscale_diff = 0 ;\n return 0 ;\n }\n fill_decode_caches ( h , mb_type ) ;\n if ( IS_INTRA ( mb_type ) ) {\n int i , pred_mode ;\n if ( IS_INTRA4x4 ( mb_type ) ) {\n if ( dct8x8_allowed && get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 399 + h -> neighbor_transform_size ] ) ) {\n mb_type |= MB_TYPE_8x8DCT ;\n for ( i = 0 ;\n i < 16 ;\n i += 4 ) {\n int pred = pred_intra_mode ( h , i ) ;\n int mode = decode_cabac_mb_intra4x4_pred_mode ( h , pred ) ;\n fill_rectangle ( & h -> intra4x4_pred_mode_cache [ scan8 [ i ] ] , 2 , 2 , 8 , mode , 1 ) ;\n }\n }\n else {\n for ( i = 0 ;\n i < 16 ;\n i ++ ) {\n int pred = pred_intra_mode ( h , i ) ;\n h -> intra4x4_pred_mode_cache [ scan8 [ i ] ] = decode_cabac_mb_intra4x4_pred_mode ( h , pred ) ;\n av_dlog ( h -> avctx , \"i4x4 pred=%d mode=%d\\n\" , pred , h -> intra4x4_pred_mode_cache [ scan8 [ i ] ] ) ;\n }\n }\n write_back_intra_pred_mode ( h ) ;\n if ( ff_h264_check_intra4x4_pred_mode ( h ) < 0 ) return - 1 ;\n }\n else {\n h -> intra16x16_pred_mode = ff_h264_check_intra_pred_mode ( h , h -> intra16x16_pred_mode , 0 ) ;\n if ( h -> intra16x16_pred_mode < 0 ) return - 1 ;\n }\n if ( decode_chroma ) {\n h -> chroma_pred_mode_table [ mb_xy ] = pred_mode = decode_cabac_mb_chroma_pre_mode ( h ) ;\n pred_mode = ff_h264_check_intra_pred_mode ( h , pred_mode , 1 ) ;\n if ( pred_mode < 0 ) return - 1 ;\n h -> chroma_pred_mode = pred_mode ;\n }\n else {\n h -> chroma_pred_mode = DC_128_PRED8x8 ;\n }\n }\n else if ( partition_count == 4 ) {\n int i , j , sub_partition_count [ 4 ] , list , ref [ 2 ] [ 4 ] ;\n if ( h -> slice_type_nos == AV_PICTURE_TYPE_B ) {\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n h -> sub_mb_type [ i ] = decode_cabac_b_mb_sub_type ( h ) ;\n sub_partition_count [ i ] = b_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . partition_count ;\n h -> sub_mb_type [ i ] = b_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . type ;\n }\n if ( IS_DIRECT ( h -> sub_mb_type [ 0 ] | h -> sub_mb_type [ 1 ] | h -> sub_mb_type [ 2 ] | h -> sub_mb_type [ 3 ] ) ) {\n ff_h264_pred_direct_motion ( h , & mb_type ) ;\n h -> ref_cache [ 0 ] [ scan8 [ 4 ] ] = h -> ref_cache [ 1 ] [ scan8 [ 4 ] ] = h -> ref_cache [ 0 ] [ scan8 [ 12 ] ] = h -> ref_cache [ 1 ] [ scan8 [ 12 ] ] = PART_NOT_AVAILABLE ;\n for ( i = 0 ;\n i < 4 ;\n i ++ ) fill_rectangle ( & h -> direct_cache [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , ( h -> sub_mb_type [ i ] >> 1 ) & 0xFF , 1 ) ;\n }\n }\n else {\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n h -> sub_mb_type [ i ] = decode_cabac_p_mb_sub_type ( h ) ;\n sub_partition_count [ i ] = p_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . partition_count ;\n h -> sub_mb_type [ i ] = p_sub_mb_type_info [ h -> sub_mb_type [ i ] ] . type ;\n }\n }\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n if ( IS_DIRECT ( h -> sub_mb_type [ i ] ) ) continue ;\n if ( IS_DIR ( h -> sub_mb_type [ i ] , 0 , list ) ) {\n int rc = h -> ref_count [ list ] << MB_MBAFF ;\n if ( rc > 1 ) {\n ref [ list ] [ i ] = decode_cabac_mb_ref ( h , list , 4 * i ) ;\n if ( ref [ list ] [ i ] >= ( unsigned ) rc ) {\n av_log ( h -> avctx , AV_LOG_ERROR , \"Reference %d >= %d\\n\" , ref [ list ] [ i ] , rc ) ;\n return - 1 ;\n }\n }\n else ref [ list ] [ i ] = 0 ;\n }\n else {\n ref [ list ] [ i ] = - 1 ;\n }\n h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 1 ] = h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 8 ] = h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 9 ] = ref [ list ] [ i ] ;\n }\n }\n if ( dct8x8_allowed ) dct8x8_allowed = get_dct8x8_allowed ( h ) ;\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n h -> ref_cache [ list ] [ scan8 [ 4 * i ] ] = h -> ref_cache [ list ] [ scan8 [ 4 * i ] + 1 ] ;\n if ( IS_DIRECT ( h -> sub_mb_type [ i ] ) ) {\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , 0 , 2 ) ;\n continue ;\n }\n if ( IS_DIR ( h -> sub_mb_type [ i ] , 0 , list ) && ! IS_DIRECT ( h -> sub_mb_type [ i ] ) ) {\n const int sub_mb_type = h -> sub_mb_type [ i ] ;\n const int block_width = ( sub_mb_type & ( MB_TYPE_16x16 | MB_TYPE_16x8 ) ) ? 2 : 1 ;\n for ( j = 0 ;\n j < sub_partition_count [ i ] ;\n j ++ ) {\n int mpx , mpy ;\n int mx , my ;\n const int index = 4 * i + block_width * j ;\n int16_t ( * mv_cache ) [ 2 ] = & h -> mv_cache [ list ] [ scan8 [ index ] ] ;\n uint8_t ( * mvd_cache ) [ 2 ] = & h -> mvd_cache [ list ] [ scan8 [ index ] ] ;\n pred_motion ( h , index , block_width , list , h -> ref_cache [ list ] [ scan8 [ index ] ] , & mx , & my ) ;\n DECODE_CABAC_MB_MVD ( h , list , index ) tprintf ( h -> avctx , \"final mv:%d %d\\n\" , mx , my ) ;\n if ( IS_SUB_8X8 ( sub_mb_type ) ) {\n mv_cache [ 1 ] [ 0 ] = mv_cache [ 8 ] [ 0 ] = mv_cache [ 9 ] [ 0 ] = mx ;\n mv_cache [ 1 ] [ 1 ] = mv_cache [ 8 ] [ 1 ] = mv_cache [ 9 ] [ 1 ] = my ;\n mvd_cache [ 1 ] [ 0 ] = mvd_cache [ 8 ] [ 0 ] = mvd_cache [ 9 ] [ 0 ] = mpx ;\n mvd_cache [ 1 ] [ 1 ] = mvd_cache [ 8 ] [ 1 ] = mvd_cache [ 9 ] [ 1 ] = mpy ;\n }\n else if ( IS_SUB_8X4 ( sub_mb_type ) ) {\n mv_cache [ 1 ] [ 0 ] = mx ;\n mv_cache [ 1 ] [ 1 ] = my ;\n mvd_cache [ 1 ] [ 0 ] = mpx ;\n mvd_cache [ 1 ] [ 1 ] = mpy ;\n }\n else if ( IS_SUB_4X8 ( sub_mb_type ) ) {\n mv_cache [ 8 ] [ 0 ] = mx ;\n mv_cache [ 8 ] [ 1 ] = my ;\n mvd_cache [ 8 ] [ 0 ] = mpx ;\n mvd_cache [ 8 ] [ 1 ] = mpy ;\n }\n mv_cache [ 0 ] [ 0 ] = mx ;\n mv_cache [ 0 ] [ 1 ] = my ;\n mvd_cache [ 0 ] [ 0 ] = mpx ;\n mvd_cache [ 0 ] [ 1 ] = mpy ;\n }\n }\n else {\n fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , 0 , 4 ) ;\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 4 * i ] ] , 2 , 2 , 8 , 0 , 2 ) ;\n }\n }\n }\n }\n else if ( IS_DIRECT ( mb_type ) ) {\n ff_h264_pred_direct_motion ( h , & mb_type ) ;\n fill_rectangle ( h -> mvd_cache [ 0 ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , 0 , 2 ) ;\n fill_rectangle ( h -> mvd_cache [ 1 ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , 0 , 2 ) ;\n dct8x8_allowed &= h -> sps . direct_8x8_inference_flag ;\n }\n else {\n int list , i ;\n if ( IS_16X16 ( mb_type ) ) {\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n if ( IS_DIR ( mb_type , 0 , list ) ) {\n int ref , rc = h -> ref_count [ list ] << MB_MBAFF ;\n if ( rc > 1 ) {\n ref = decode_cabac_mb_ref ( h , list , 0 ) ;\n if ( ref >= ( unsigned ) rc ) {\n av_log ( h -> avctx , AV_LOG_ERROR , \"Reference %d >= %d\\n\" , ref , rc ) ;\n return - 1 ;\n }\n }\n else ref = 0 ;\n fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , ref , 1 ) ;\n }\n }\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n if ( IS_DIR ( mb_type , 0 , list ) ) {\n int mx , my , mpx , mpy ;\n pred_motion ( h , 0 , 4 , list , h -> ref_cache [ list ] [ scan8 [ 0 ] ] , & mx , & my ) ;\n DECODE_CABAC_MB_MVD ( h , list , 0 ) tprintf ( h -> avctx , \"final mv:%d %d\\n\" , mx , my ) ;\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , pack8to16 ( mpx , mpy ) , 2 ) ;\n fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] ] , 4 , 4 , 8 , pack16to32 ( mx , my ) , 4 ) ;\n }\n }\n }\n else if ( IS_16X8 ( mb_type ) ) {\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n for ( i = 0 ;\n i < 2 ;\n i ++ ) {\n if ( IS_DIR ( mb_type , i , list ) ) {\n int ref , rc = h -> ref_count [ list ] << MB_MBAFF ;\n if ( rc > 1 ) {\n ref = decode_cabac_mb_ref ( h , list , 8 * i ) ;\n if ( ref >= ( unsigned ) rc ) {\n av_log ( h -> avctx , AV_LOG_ERROR , \"Reference %d >= %d\\n\" , ref , rc ) ;\n return - 1 ;\n }\n }\n else ref = 0 ;\n fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , ref , 1 ) ;\n }\n else fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , ( LIST_NOT_USED & 0xFF ) , 1 ) ;\n }\n }\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n for ( i = 0 ;\n i < 2 ;\n i ++ ) {\n if ( IS_DIR ( mb_type , i , list ) ) {\n int mx , my , mpx , mpy ;\n pred_16x8_motion ( h , 8 * i , list , h -> ref_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , & mx , & my ) ;\n DECODE_CABAC_MB_MVD ( h , list , 8 * i ) tprintf ( h -> avctx , \"final mv:%d %d\\n\" , mx , my ) ;\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , pack8to16 ( mpx , mpy ) , 2 ) ;\n fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , pack16to32 ( mx , my ) , 4 ) ;\n }\n else {\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , 0 , 2 ) ;\n fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 16 * i ] , 4 , 2 , 8 , 0 , 4 ) ;\n }\n }\n }\n }\n else {\n assert ( IS_8X16 ( mb_type ) ) ;\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n for ( i = 0 ;\n i < 2 ;\n i ++ ) {\n if ( IS_DIR ( mb_type , i , list ) ) {\n int ref , rc = h -> ref_count [ list ] << MB_MBAFF ;\n if ( rc > 1 ) {\n ref = decode_cabac_mb_ref ( h , list , 4 * i ) ;\n if ( ref >= ( unsigned ) rc ) {\n av_log ( h -> avctx , AV_LOG_ERROR , \"Reference %d >= %d\\n\" , ref , rc ) ;\n return - 1 ;\n }\n }\n else ref = 0 ;\n fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , ref , 1 ) ;\n }\n else fill_rectangle ( & h -> ref_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , ( LIST_NOT_USED & 0xFF ) , 1 ) ;\n }\n }\n for ( list = 0 ;\n list < h -> list_count ;\n list ++ ) {\n for ( i = 0 ;\n i < 2 ;\n i ++ ) {\n if ( IS_DIR ( mb_type , i , list ) ) {\n int mx , my , mpx , mpy ;\n pred_8x16_motion ( h , i * 4 , list , h -> ref_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , & mx , & my ) ;\n DECODE_CABAC_MB_MVD ( h , list , 4 * i ) tprintf ( h -> avctx , \"final mv:%d %d\\n\" , mx , my ) ;\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , pack8to16 ( mpx , mpy ) , 2 ) ;\n fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , pack16to32 ( mx , my ) , 4 ) ;\n }\n else {\n fill_rectangle ( h -> mvd_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , 0 , 2 ) ;\n fill_rectangle ( h -> mv_cache [ list ] [ scan8 [ 0 ] + 2 * i ] , 2 , 4 , 8 , 0 , 4 ) ;\n }\n }\n }\n }\n }\n if ( IS_INTER ( mb_type ) ) {\n h -> chroma_pred_mode_table [ mb_xy ] = 0 ;\n write_back_motion ( h , mb_type ) ;\n }\n if ( ! IS_INTRA16x16 ( mb_type ) ) {\n cbp = decode_cabac_mb_cbp_luma ( h ) ;\n if ( decode_chroma ) cbp |= decode_cabac_mb_cbp_chroma ( h ) << 4 ;\n }\n h -> cbp_table [ mb_xy ] = h -> cbp = cbp ;\n if ( dct8x8_allowed && ( cbp & 15 ) && ! IS_INTRA ( mb_type ) ) {\n mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 399 + h -> neighbor_transform_size ] ) ;\n }\n if ( CHROMA444 && IS_8x8DCT ( mb_type ) ) {\n int i ;\n uint8_t * nnz_cache = h -> non_zero_count_cache ;\n for ( i = 0 ;\n i < 2 ;\n i ++ ) {\n if ( h -> left_type [ LEFT ( i ) ] && ! IS_8x8DCT ( h -> left_type [ LEFT ( i ) ] ) ) {\n nnz_cache [ 3 + 8 * 1 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 2 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 6 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 7 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 11 + 2 * 8 * i ] = nnz_cache [ 3 + 8 * 12 + 2 * 8 * i ] = IS_INTRA ( mb_type ) ? 64 : 0 ;\n }\n }\n if ( h -> top_type && ! IS_8x8DCT ( h -> top_type ) ) {\n uint32_t top_empty = CABAC && ! IS_INTRA ( mb_type ) ? 0 : 0x40404040 ;\n AV_WN32A ( & nnz_cache [ 4 + 8 * 0 ] , top_empty ) ;\n AV_WN32A ( & nnz_cache [ 4 + 8 * 5 ] , top_empty ) ;\n AV_WN32A ( & nnz_cache [ 4 + 8 * 10 ] , top_empty ) ;\n }\n }\n h -> cur_pic . f . mb_type [ mb_xy ] = mb_type ;\n if ( cbp || IS_INTRA16x16 ( mb_type ) ) {\n const uint8_t * scan , * scan8x8 ;\n const uint32_t * qmul ;\n if ( IS_INTERLACED ( mb_type ) ) {\n scan8x8 = h -> qscale ? h -> field_scan8x8 : h -> field_scan8x8_q0 ;\n scan = h -> qscale ? h -> field_scan : h -> field_scan_q0 ;\n }\n else {\n scan8x8 = h -> qscale ? h -> zigzag_scan8x8 : h -> zigzag_scan8x8_q0 ;\n scan = h -> qscale ? h -> zigzag_scan : h -> zigzag_scan_q0 ;\n }\n if ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 60 + ( h -> last_qscale_diff != 0 ) ] ) ) {\n int val = 1 ;\n int ctx = 2 ;\n const int max_qp = 51 + 6 * ( h -> sps . bit_depth_luma - 8 ) ;\n while ( get_cabac_noinline ( & h -> cabac , & h -> cabac_state [ 60 + ctx ] ) ) {\n ctx = 3 ;\n val ++ ;\n if ( val > 2 * max_qp ) {\n av_log ( h -> avctx , AV_LOG_ERROR , \"cabac decode of qscale diff failed at %d %d\\n\" , h -> mb_x , h -> mb_y ) ;\n return - 1 ;\n }\n }\n if ( val & 0x01 ) val = ( val + 1 ) >> 1 ;\n else val = - ( ( val + 1 ) >> 1 ) ;\n h -> last_qscale_diff = val ;\n h -> qscale += val ;\n if ( ( ( unsigned ) h -> qscale ) > max_qp ) {\n if ( h -> qscale < 0 ) h -> qscale += max_qp + 1 ;\n else h -> qscale -= max_qp + 1 ;\n }\n h -> chroma_qp [ 0 ] = get_chroma_qp ( h , 0 , h -> qscale ) ;\n h -> chroma_qp [ 1 ] = get_chroma_qp ( h , 1 , h -> qscale ) ;\n }\n else h -> last_qscale_diff = 0 ;\n decode_cabac_luma_residual ( h , scan , scan8x8 , pixel_shift , mb_type , cbp , 0 ) ;\n if ( CHROMA444 ) {\n decode_cabac_luma_residual ( h , scan , scan8x8 , pixel_shift , mb_type , cbp , 1 ) ;\n decode_cabac_luma_residual ( h , scan , scan8x8 , pixel_shift , mb_type , cbp , 2 ) ;\n }\n else if ( CHROMA422 ) {\n if ( cbp & 0x30 ) {\n int c ;\n for ( c = 0 ;\n c < 2 ;\n c ++ ) decode_cabac_residual_dc_422 ( h , h -> mb + ( ( 256 + 16 * 16 * c ) << pixel_shift ) , 3 , CHROMA_DC_BLOCK_INDEX + c , chroma422_dc_scan , 8 ) ;\n }\n if ( cbp & 0x20 ) {\n int c , i , i8x8 ;\n for ( c = 0 ;\n c < 2 ;\n c ++ ) {\n int16_t * mb = h -> mb + ( 16 * ( 16 + 16 * c ) << pixel_shift ) ;\n qmul = h -> dequant4_coeff [ c + 1 + ( IS_INTRA ( mb_type ) ? 0 : 3 ) ] [ h -> chroma_qp [ c ] ] ;\n for ( i8x8 = 0 ;\n i8x8 < 2 ;\n i8x8 ++ ) {\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n const int index = 16 + 16 * c + 8 * i8x8 + i ;\n decode_cabac_residual_nondc ( h , mb , 4 , index , scan + 1 , qmul , 15 ) ;\n mb += 16 << pixel_shift ;\n }\n }\n }\n }\n else {\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 16 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 32 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n }\n }\n else {\n if ( cbp & 0x30 ) {\n int c ;\n for ( c = 0 ;\n c < 2 ;\n c ++ ) decode_cabac_residual_dc ( h , h -> mb + ( ( 256 + 16 * 16 * c ) << pixel_shift ) , 3 , CHROMA_DC_BLOCK_INDEX + c , chroma_dc_scan , 4 ) ;\n }\n if ( cbp & 0x20 ) {\n int c , i ;\n for ( c = 0 ;\n c < 2 ;\n c ++ ) {\n qmul = h -> dequant4_coeff [ c + 1 + ( IS_INTRA ( mb_type ) ? 0 : 3 ) ] [ h -> chroma_qp [ c ] ] ;\n for ( i = 0 ;\n i < 4 ;\n i ++ ) {\n const int index = 16 + 16 * c + i ;\n decode_cabac_residual_nondc ( h , h -> mb + ( 16 * index << pixel_shift ) , 4 , index , scan + 1 , qmul , 15 ) ;\n }\n }\n }\n else {\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 16 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 32 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n }\n }\n }\n else {\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 0 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 16 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n fill_rectangle ( & h -> non_zero_count_cache [ scan8 [ 32 ] ] , 4 , 4 , 8 , 0 , 1 ) ;\n h -> last_qscale_diff = 0 ;\n }\n h -> cur_pic . f . qscale_table [ mb_xy ] = h -> qscale ;\n write_back_non_zero_count ( h ) ;\n return 0 ;\n }","target":1,"code_token_length":7471,"total_token_length":7707,"max_tokens_setting":8192}
+{"idx":336090,"func":"int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)\n\n{\n\n    int pqindex, lowquant;\n\n    int status;\n\n    int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; \/* useful only for debugging *\/\n\n    int field_mode, fcm;\n\n\n\n    v->numref          = 0;\n\n    v->p_frame_skipped = 0;\n\n    if (v->second_field) {\n\n        v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;\n\n        if (v->fptype & 4)\n\n            v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;\n\n        v->s.current_picture_ptr->f.pict_type = v->s.pict_type;\n\n        if (!v->pic_header_flag)\n\n            goto parse_common_info;\n\n    }\n\n\n\n    field_mode = 0;\n\n    if (v->interlace) {\n\n        fcm = decode012(gb);\n\n        if (fcm) {\n\n            if (fcm == ILACE_FIELD)\n\n                field_mode = 1;\n\n        }\n\n    } else {\n\n        fcm = PROGRESSIVE;\n\n    }\n\n    if (!v->first_pic_header_flag && v->field_mode != field_mode)\n\n        return AVERROR_INVALIDDATA;\n\n    v->field_mode = field_mode;\n\n    v->fcm = fcm;\n\n\n\n    if (v->field_mode) {\n\n        v->s.mb_height = FFALIGN(v->s.height + 15 >> 4, 2);\n\n        v->fptype = get_bits(gb, 3);\n\n        v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;\n\n        if (v->fptype & 4) \/\/ B-picture\n\n            v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;\n\n    } else {\n\n        v->s.mb_height = v->s.height + 15 >> 4;\n\n        switch (get_unary(gb, 0, 4)) {\n\n        case 0:\n\n            v->s.pict_type = AV_PICTURE_TYPE_P;\n\n            break;\n\n        case 1:\n\n            v->s.pict_type = AV_PICTURE_TYPE_B;\n\n            break;\n\n        case 2:\n\n            v->s.pict_type = AV_PICTURE_TYPE_I;\n\n            break;\n\n        case 3:\n\n            v->s.pict_type = AV_PICTURE_TYPE_BI;\n\n            break;\n\n        case 4:\n\n            v->s.pict_type = AV_PICTURE_TYPE_P; \/\/ skipped pic\n\n            v->p_frame_skipped = 1;\n\n            break;\n\n        }\n\n    }\n\n    if (v->tfcntrflag)\n\n        skip_bits(gb, 8);\n\n    if (v->broadcast) {\n\n        if (!v->interlace || v->psf) {\n\n            v->rptfrm = get_bits(gb, 2);\n\n        } else {\n\n            v->tff = get_bits1(gb);\n\n            v->rff = get_bits1(gb);\n\n        }\n\n    }\n\n    if (v->panscanflag) {\n\n        avpriv_report_missing_feature(v->s.avctx, \"Pan-scan\");\n\n        \/\/...\n\n    }\n\n    if (v->p_frame_skipped) {\n\n        return 0;\n\n    }\n\n    v->rnd = get_bits1(gb);\n\n    if (v->interlace)\n\n        v->uvsamp = get_bits1(gb);\n\n    if (v->field_mode) {\n\n        if (!v->refdist_flag)\n\n            v->refdist = 0;\n\n        else if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) {\n\n            v->refdist = get_bits(gb, 2);\n\n            if (v->refdist == 3)\n\n                v->refdist += get_unary(gb, 0, 16);\n\n        }\n\n        if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) {\n\n            v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);\n\n            v->bfraction           = ff_vc1_bfraction_lut[v->bfraction_lut_index];\n\n            v->frfd = (v->bfraction * v->refdist) >> 8;\n\n            v->brfd = v->refdist - v->frfd - 1;\n\n            if (v->brfd < 0)\n\n                v->brfd = 0;\n\n        }\n\n        goto parse_common_info;\n\n    }\n\n    if (v->fcm == PROGRESSIVE) {\n\n        if (v->finterpflag)\n\n            v->interpfrm = get_bits1(gb);\n\n        if (v->s.pict_type == AV_PICTURE_TYPE_B) {\n\n            v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);\n\n            v->bfraction           = ff_vc1_bfraction_lut[v->bfraction_lut_index];\n\n            if (v->bfraction == 0) {\n\n                v->s.pict_type = AV_PICTURE_TYPE_BI; \/* XXX: should not happen here *\/\n\n            }\n\n        }\n\n    }\n\n\n\n    parse_common_info:\n\n    if (v->field_mode)\n\n        v->cur_field_type = !(v->tff ^ v->second_field);\n\n    pqindex = get_bits(gb, 5);\n\n    if (!pqindex)\n\n        return -1;\n\n    v->pqindex = pqindex;\n\n    if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)\n\n        v->pq = ff_vc1_pquant_table[0][pqindex];\n\n    else\n\n        v->pq = ff_vc1_pquant_table[1][pqindex];\n\n\n\n    v->pquantizer = 1;\n\n    if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)\n\n        v->pquantizer = pqindex < 9;\n\n    if (v->quantizer_mode == QUANT_NON_UNIFORM)\n\n        v->pquantizer = 0;\n\n    v->pqindex = pqindex;\n\n    if (pqindex < 9)\n\n        v->halfpq = get_bits1(gb);\n\n    else\n\n        v->halfpq = 0;\n\n    if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)\n\n        v->pquantizer = get_bits1(gb);\n\n    if (v->postprocflag)\n\n        v->postproc = get_bits(gb, 2);\n\n\n\n    if (v->parse_only)\n\n        return 0;\n\n\n\n    if (v->first_pic_header_flag)\n\n        rotate_luts(v);\n\n\n\n    switch (v->s.pict_type) {\n\n    case AV_PICTURE_TYPE_I:\n\n    case AV_PICTURE_TYPE_BI:\n\n        if (v->fcm == ILACE_FRAME) { \/\/interlace frame picture\n\n            status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"FIELDTX plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n        }\n\n        status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);\n\n        if (status < 0)\n\n            return -1;\n\n        av_log(v->s.avctx, AV_LOG_DEBUG, \"ACPRED plane encoding: \"\n\n               \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n        v->condover = CONDOVER_NONE;\n\n        if (v->overlap && v->pq <= 8) {\n\n            v->condover = decode012(gb);\n\n            if (v->condover == CONDOVER_SELECT) {\n\n                status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v);\n\n                if (status < 0)\n\n                    return -1;\n\n                av_log(v->s.avctx, AV_LOG_DEBUG, \"CONDOVER plane encoding: \"\n\n                       \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            }\n\n        }\n\n        break;\n\n    case AV_PICTURE_TYPE_P:\n\n        if (v->field_mode) {\n\n            v->numref = get_bits1(gb);\n\n            if (!v->numref) {\n\n                v->reffield          = get_bits1(gb);\n\n                v->ref_field_type[0] = v->reffield ^ !v->cur_field_type;\n\n            }\n\n        }\n\n        if (v->extended_mv)\n\n            v->mvrange = get_unary(gb, 0, 3);\n\n        else\n\n            v->mvrange = 0;\n\n        if (v->interlace) {\n\n            if (v->extended_dmv)\n\n                v->dmvrange = get_unary(gb, 0, 3);\n\n            else\n\n                v->dmvrange = 0;\n\n            if (v->fcm == ILACE_FRAME) { \/\/ interlaced frame picture\n\n                v->fourmvswitch = get_bits1(gb);\n\n                v->intcomp      = get_bits1(gb);\n\n                if (v->intcomp) {\n\n                    v->lumscale = get_bits(gb, 6);\n\n                    v->lumshift = get_bits(gb, 6);\n\n                    INIT_LUT(v->lumscale, v->lumshift, v->last_luty[0], v->last_lutuv[0], 1);\n\n                    INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1);\n\n                    v->last_use_ic = 1;\n\n                }\n\n                status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);\n\n                av_log(v->s.avctx, AV_LOG_DEBUG, \"SKIPMB plane encoding: \"\n\n                       \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n                mbmodetab = get_bits(gb, 2);\n\n                if (v->fourmvswitch)\n\n                    v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab];\n\n                else\n\n                    v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];\n\n                imvtab         = get_bits(gb, 2);\n\n                v->imv_vlc     = &ff_vc1_1ref_mvdata_vlc[imvtab];\n\n                \/\/ interlaced p-picture cbpcy range is [1, 63]\n\n                icbptab        = get_bits(gb, 3);\n\n                v->cbpcy_vlc   = &ff_vc1_icbpcy_vlc[icbptab];\n\n                twomvbptab     = get_bits(gb, 2);\n\n                v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];\n\n                if (v->fourmvswitch) {\n\n                    fourmvbptab     = get_bits(gb, 2);\n\n                    v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];\n\n                }\n\n            }\n\n        }\n\n        v->k_x = v->mvrange + 9 + (v->mvrange >> 1); \/\/k_x can be 9 10 12 13\n\n        v->k_y = v->mvrange + 8; \/\/k_y can be 8 9 10 11\n\n        v->range_x = 1 << (v->k_x - 1);\n\n        v->range_y = 1 << (v->k_y - 1);\n\n\n\n        if (v->pq < 5)\n\n            v->tt_index = 0;\n\n        else if (v->pq < 13)\n\n            v->tt_index = 1;\n\n        else\n\n            v->tt_index = 2;\n\n        if (v->fcm != ILACE_FRAME) {\n\n            int mvmode;\n\n            mvmode     = get_unary(gb, 1, 4);\n\n            lowquant   = (v->pq > 12) ? 0 : 1;\n\n            v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode];\n\n            if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {\n\n                int mvmode2;\n\n                mvmode2 = get_unary(gb, 1, 3);\n\n                v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2];\n\n                if (v->field_mode) {\n\n                    v->intcompfield = decode210(gb) ^ 3;\n\n                } else\n\n                    v->intcompfield = 3;\n\n\n\n                v->lumscale2 = v->lumscale = 32;\n\n                v->lumshift2 = v->lumshift =  0;\n\n                if (v->intcompfield & 1) {\n\n                    v->lumscale = get_bits(gb, 6);\n\n                    v->lumshift = get_bits(gb, 6);\n\n                }\n\n                if ((v->intcompfield & 2) && v->field_mode) {\n\n                    v->lumscale2 = get_bits(gb, 6);\n\n                    v->lumshift2 = get_bits(gb, 6);\n\n                } else if(!v->field_mode) {\n\n                    v->lumscale2 = v->lumscale;\n\n                    v->lumshift2 = v->lumshift;\n\n                }\n\n                if (v->field_mode && v->second_field) {\n\n                    if (v->cur_field_type) {\n\n                        INIT_LUT(v->lumscale , v->lumshift , v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);\n\n                        INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[v->cur_field_type  ], v->last_lutuv[v->cur_field_type  ], 1);\n\n                    } else {\n\n                        INIT_LUT(v->lumscale2, v->lumshift2, v->curr_luty[v->cur_field_type^1], v->curr_lutuv[v->cur_field_type^1], 0);\n\n                        INIT_LUT(v->lumscale , v->lumshift , v->last_luty[v->cur_field_type  ], v->last_lutuv[v->cur_field_type  ], 1);\n\n                    }\n\n                    v->next_use_ic = v->curr_use_ic = 1;\n\n                } else {\n\n                    INIT_LUT(v->lumscale , v->lumshift , v->last_luty[0], v->last_lutuv[0], 1);\n\n                    INIT_LUT(v->lumscale2, v->lumshift2, v->last_luty[1], v->last_lutuv[1], 1);\n\n                }\n\n                v->last_use_ic = 1;\n\n            }\n\n            v->qs_last = v->s.quarter_sample;\n\n            if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)\n\n                v->s.quarter_sample = 0;\n\n            else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {\n\n                if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)\n\n                    v->s.quarter_sample = 0;\n\n                else\n\n                    v->s.quarter_sample = 1;\n\n            } else\n\n                v->s.quarter_sample = 1;\n\n            v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN\n\n                           || (v->mv_mode == MV_PMODE_INTENSITY_COMP\n\n                               && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));\n\n        }\n\n        if (v->fcm == PROGRESSIVE) { \/\/ progressive\n\n            if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&\n\n                 v->mv_mode2 == MV_PMODE_MIXED_MV)\n\n                || v->mv_mode == MV_PMODE_MIXED_MV) {\n\n                status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);\n\n                if (status < 0)\n\n                    return -1;\n\n                av_log(v->s.avctx, AV_LOG_DEBUG, \"MB MV Type plane encoding: \"\n\n                       \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            } else {\n\n                v->mv_type_is_raw = 0;\n\n                memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);\n\n            }\n\n            status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"MB Skip plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n\n\n            \/* Hopefully this is correct for P frames *\/\n\n            v->s.mv_table_index = get_bits(gb, 2); \/\/but using ff_vc1_ tables\n\n            v->cbpcy_vlc        = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];\n\n        } else if (v->fcm == ILACE_FRAME) { \/\/ frame interlaced\n\n            v->qs_last          = v->s.quarter_sample;\n\n            v->s.quarter_sample = 1;\n\n            v->s.mspel          = 1;\n\n        } else {    \/\/ field interlaced\n\n            mbmodetab = get_bits(gb, 3);\n\n            imvtab = get_bits(gb, 2 + v->numref);\n\n            if (!v->numref)\n\n                v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];\n\n            else\n\n                v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];\n\n            icbptab = get_bits(gb, 3);\n\n            v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];\n\n            if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&\n\n                v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) {\n\n                fourmvbptab     = get_bits(gb, 2);\n\n                v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];\n\n                v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];\n\n            } else {\n\n                v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];\n\n            }\n\n        }\n\n        if (v->dquant) {\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"VOP DQuant info\\n\");\n\n            vop_dquant_decoding(v);\n\n        }\n\n\n\n        v->ttfrm = 0; \/\/FIXME Is that so ?\n\n        if (v->vstransform) {\n\n            v->ttmbf = get_bits1(gb);\n\n            if (v->ttmbf) {\n\n                v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];\n\n            }\n\n        } else {\n\n            v->ttmbf = 1;\n\n            v->ttfrm = TT_8X8;\n\n        }\n\n        break;\n\n    case AV_PICTURE_TYPE_B:\n\n        if (v->fcm == ILACE_FRAME) {\n\n            v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);\n\n            v->bfraction           = ff_vc1_bfraction_lut[v->bfraction_lut_index];\n\n            if (v->bfraction == 0) {\n\n                return -1;\n\n            }\n\n        }\n\n        if (v->extended_mv)\n\n            v->mvrange = get_unary(gb, 0, 3);\n\n        else\n\n            v->mvrange = 0;\n\n        v->k_x     = v->mvrange + 9 + (v->mvrange >> 1); \/\/k_x can be 9 10 12 13\n\n        v->k_y     = v->mvrange + 8; \/\/k_y can be 8 9 10 11\n\n        v->range_x = 1 << (v->k_x - 1);\n\n        v->range_y = 1 << (v->k_y - 1);\n\n\n\n        if (v->pq < 5)\n\n            v->tt_index = 0;\n\n        else if (v->pq < 13)\n\n            v->tt_index = 1;\n\n        else\n\n            v->tt_index = 2;\n\n\n\n        if (v->field_mode) {\n\n            int mvmode;\n\n            if (v->extended_dmv)\n\n                v->dmvrange = get_unary(gb, 0, 3);\n\n            mvmode = get_unary(gb, 1, 3);\n\n            lowquant = (v->pq > 12) ? 0 : 1;\n\n            v->mv_mode          = ff_vc1_mv_pmode_table2[lowquant][mvmode];\n\n            v->qs_last          = v->s.quarter_sample;\n\n            v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV);\n\n            v->s.mspel          = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL);\n\n            status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"MB Forward Type plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            mbmodetab = get_bits(gb, 3);\n\n            if (v->mv_mode == MV_PMODE_MIXED_MV)\n\n                v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];\n\n            else\n\n                v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];\n\n            imvtab       = get_bits(gb, 3);\n\n            v->imv_vlc   = &ff_vc1_2ref_mvdata_vlc[imvtab];\n\n            icbptab      = get_bits(gb, 3);\n\n            v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];\n\n            if (v->mv_mode == MV_PMODE_MIXED_MV) {\n\n                fourmvbptab     = get_bits(gb, 2);\n\n                v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];\n\n            }\n\n            v->numref = 1; \/\/ interlaced field B pictures are always 2-ref\n\n        } else if (v->fcm == ILACE_FRAME) {\n\n            if (v->extended_dmv)\n\n                v->dmvrange = get_unary(gb, 0, 3);\n\n            if (get_bits1(gb)) \/* intcomp - present but shall always be 0 *\/\n\n                av_log(v->s.avctx, AV_LOG_WARNING, \"Intensity compensation set for B picture\\n\");\n\n            v->intcomp          = 0;\n\n            v->mv_mode          = MV_PMODE_1MV;\n\n            v->fourmvswitch     = 0;\n\n            v->qs_last          = v->s.quarter_sample;\n\n            v->s.quarter_sample = 1;\n\n            v->s.mspel          = 1;\n\n            status              = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"MB Direct Type plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"MB Skip plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            mbmodetab       = get_bits(gb, 2);\n\n            v->mbmode_vlc   = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];\n\n            imvtab          = get_bits(gb, 2);\n\n            v->imv_vlc      = &ff_vc1_1ref_mvdata_vlc[imvtab];\n\n            \/\/ interlaced p\/b-picture cbpcy range is [1, 63]\n\n            icbptab         = get_bits(gb, 3);\n\n            v->cbpcy_vlc    = &ff_vc1_icbpcy_vlc[icbptab];\n\n            twomvbptab      = get_bits(gb, 2);\n\n            v->twomvbp_vlc  = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];\n\n            fourmvbptab     = get_bits(gb, 2);\n\n            v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];\n\n        } else {\n\n            v->mv_mode          = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;\n\n            v->qs_last          = v->s.quarter_sample;\n\n            v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);\n\n            v->s.mspel          = v->s.quarter_sample;\n\n            status              = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"MB Direct Type plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);\n\n            if (status < 0)\n\n                return -1;\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"MB Skip plane encoding: \"\n\n                   \"Imode: %i, Invert: %i\\n\", status>>1, status&1);\n\n            v->s.mv_table_index = get_bits(gb, 2);\n\n            v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];\n\n        }\n\n\n\n        if (v->dquant) {\n\n            av_log(v->s.avctx, AV_LOG_DEBUG, \"VOP DQuant info\\n\");\n\n            vop_dquant_decoding(v);\n\n        }\n\n\n\n        v->ttfrm = 0;\n\n        if (v->vstransform) {\n\n            v->ttmbf = get_bits1(gb);\n\n            if (v->ttmbf) {\n\n                v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];\n\n            }\n\n        } else {\n\n            v->ttmbf = 1;\n\n            v->ttfrm = TT_8X8;\n\n        }\n\n        break;\n\n    }\n\n\n\n    if (v->fcm != PROGRESSIVE && !v->s.quarter_sample) {\n\n        v->range_x <<= 1;\n\n        v->range_y <<= 1;\n\n    }\n\n\n\n    \/* AC Syntax *\/\n\n    v->c_ac_table_index = decode012(gb);\n\n    if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {\n\n        v->y_ac_table_index = decode012(gb);\n\n    }\n\n    \/* DC Syntax *\/\n\n    v->s.dc_table_index = get_bits1(gb);\n\n    if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)\n\n        && v->dquant) {\n\n        av_log(v->s.avctx, AV_LOG_DEBUG, \"VOP DQuant info\\n\");\n\n        vop_dquant_decoding(v);\n\n    }\n\n\n\n    v->bi_type = 0;\n\n    if (v->s.pict_type == AV_PICTURE_TYPE_BI) {\n\n        v->s.pict_type = AV_PICTURE_TYPE_B;\n\n        v->bi_type = 1;\n\n    }\n\n    return 0;\n\n}\n","target":1,"code_token_length":6457,"total_token_length":6693,"max_tokens_setting":8192}
+{"idx":95145,"func":"static Jsi_Interp* jsi_InterpNew(Jsi_Interp *parent, Jsi_Value *opts, Jsi_InterpOpts *iopts)\n{\n    Jsi_Interp* interp;\n    if (parent && parent->noSubInterps) {\n        interp = parent;\n        Jsi_LogError(\"subinterps disallowed\");\n        return NULL;\n    }\n    if (opts && parent && (Jsi_ValueIsObjType(parent, opts, JSI_OT_OBJECT)==0 ||\n        Jsi_TreeSize(opts->d.obj->tree)<=0))\n        opts = NULL;\n    interp = (Jsi_Interp *)Jsi_Calloc(1,sizeof(*interp) + sizeof(jsi_Frame));\n    interp->framePtr = (jsi_Frame*)(((uchar*)interp)+sizeof(*interp));\n    if (!parent)\n        interp->maxInterpDepth = JSI_MAX_SUBINTERP_DEPTH;\n    else {\n        interp->maxInterpDepth = parent->maxInterpDepth;\n        interp->interpDepth = parent->interpDepth+1;\n        if (interp->interpDepth > interp->maxInterpDepth) {\n            Jsi_Free(interp);\n            interp = parent;\n            Jsi_LogError(\"exceeded max subinterp depth\");\n            return NULL;\n        }\n    }\n    interp->maxDepth = JSI_MAX_EVAL_DEPTH;\n    interp->maxIncDepth = JSI_MAX_INCLUDE_DEPTH;\n    interp->maxArrayList = MAX_ARRAY_LIST;\n    interp->typeWarnMax = 50;\n    interp->subOpts.dblPrec = __DBL_DECIMAL_DIG__-1;\n    interp->subOpts.prompt = \"$ \";\n    interp->subOpts.prompt2 = \"> \";\n\n    int iocnt;\n    if (iopts) {\n        iopts->interp = interp;\n        interp->opts = *iopts;\n    }\n    interp->logOpts.file = 1;\n    interp->logOpts.func = 1;\n    interp->logOpts.Info = 1;\n    interp->logOpts.Warn = 1;\n    interp->logOpts.Error = 1;\n    int argc = interp->opts.argc;\n    char **argv = interp->opts.argv;\n    char *argv0 = (argv?argv[0]:NULL);\n    interp->parent = parent;\n    interp->topInterp = (parent == NULL ? interp: parent->topInterp);\n    if (jsiIntData.mainInterp == NULL)\n        jsiIntData.mainInterp = interp->topInterp;\n    interp->mainInterp = jsiIntData.mainInterp; \/\/ The first interps handles exit.\n    interp->memDebug = interp->opts.mem_debug;\n    if (parent) {\n        interp->dbPtr = parent->dbPtr;\n    } else {\n        interp->dbPtr = &interp->dbStatic;\n    }\n#ifdef JSI_MEM_DEBUG\n    if (!interp->dbPtr->valueDebugTbl) {\n        interp->dbPtr->valueDebugTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, NULL);\n        interp->dbPtr->objDebugTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, NULL);\n    }\n#endif\n    if (parent) {\n        if (parent->pkgDirs)\n            interp->pkgDirs = Jsi_ValueDupJSON(interp, parent->pkgDirs);\n    } else {\n#ifdef JSI_PKG_DIRS\n        interp->pkgDirs = Jsi_StringSplit(interp, JSI_PKG_DIRS, \",\");\n        Jsi_IncrRefCount(interp, interp->pkgDirs);\n#endif\n    }\n#ifdef JSI_USE_COMPAT\n    interp->compat = JSI_USE_COMPAT;\n#endif\n#ifndef JSI_CONF_ARGS\n#define JSI_CONF_ARGS \"\"\n#endif\n    interp->confArgs = JSI_CONF_ARGS;\n    for (iocnt = 1; (iocnt+1)<argc; iocnt+=2)\n    {\n        const char *aio = argv[iocnt];\n        if (Jsi_Strcmp(aio, \"--T\") == 0 || Jsi_Strcmp(aio, \"--C\") == 0 || Jsi_Strcmp(aio, \"--L\") == 0) {\n            continue;\n        }\n        if (Jsi_Strcmp(aio, \"--F\") == 0 || Jsi_Strcmp(aio, \"--U\") == 0 || Jsi_Strcmp(aio, \"--V\") == 0) {\n            iocnt--;\n            continue;\n        }\n        if (!Jsi_Strcmp(aio, \"--I\")) {\n            const char *aio2 = argv[iocnt+1];\n            if (!Jsi_Strncmp(\"memDebug:\", aio2, sizeof(\"memDebug\")))\n                interp->memDebug=strtol(aio2+sizeof(\"memDebug\"), NULL, 0);\n            else if (!Jsi_Strncmp(\"compat\", aio2, sizeof(\"compat\")))\n                interp->subOpts.compat=strtol(aio2+sizeof(\"compat\"), NULL, 0);\n            continue;\n        }\n        break;\n    }\n    SIGINIT(interp,INTERP);\n    interp->NullValue = Jsi_ValueNewNull(interp);\n    Jsi_IncrRefCount(interp, interp->NullValue);\n#ifdef __WIN32\n    Jsi_DString cwdStr;\n    Jsi_DSInit(&cwdStr);\n    interp->curDir = Jsi_Strdup(Jsi_GetCwd(interp, &cwdStr));\n    Jsi_DSFree(&cwdStr);\n#else\n    char buf[JSI_BUFSIZ];\n    interp->curDir = getcwd(buf, sizeof(buf));\n    interp->curDir = Jsi_Strdup(interp->curDir?interp->curDir:\".\");\n#endif\n    interp->onDeleteTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeOnDeleteTbl);\n    interp->assocTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, freeAssocTbl);\n    interp->cmdSpecTbl = Jsi_MapNew(interp, JSI_MAP_TREE, JSI_KEYS_STRING, freeCmdSpecTbl);\n    interp->eventTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeEventTbl);\n    interp->fileTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_HashFree);\n    interp->funcObjTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeFuncObjTbl);\n    interp->funcsTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeFuncsTbl);\n    interp->bindTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeBindObjTbl);\n    interp->protoTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, NULL\/*freeValueTbl*\/);\n    interp->regexpTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, regExpFree);\n    interp->preserveTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, jsi_HashFree);\n    interp->loadTbl = (parent?parent->loadTbl:Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_FreeOneLoadHandle));\n    interp->packageHash = Jsi_HashNew(interp, JSI_KEYS_STRING, packageHashFree);\n    interp->aliasHash = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_AliasFree);\n\n    interp->lockTimeout = -1;\n#ifdef JSI_LOCK_TIMEOUT\n    interp->lockTimeout JSI_LOCK_TIMEOUT;\n#endif\n#ifndef JSI_DO_UNLOCK\n#define JSI_DO_UNLOCK 1\n#endif\n    interp->subOpts.mutexUnlock = JSI_DO_UNLOCK;\n    Jsi_Map_Type mapType = JSI_MAP_HASH;\n#ifdef JSI_USE_MANY_STRKEY\n    mapType = JSI_MAP_TREE;\n#endif\n\n    if (interp == jsiIntData.mainInterp || interp->threadId != jsiIntData.mainInterp->threadId) {\n        interp->strKeyTbl = Jsi_MapNew(interp,  mapType, JSI_KEYS_STRING, NULL);\n        interp->subOpts.privKeys = 1;\n    }\n    \/\/ Handle interp options: -T value and -Ixxx value\n    for (iocnt = 1; (iocnt+1)<argc && !interp->parent; iocnt+=2)\n    {\n        const char *aio = argv[iocnt];\n        if (Jsi_Strcmp(aio, \"--F\") == 0) {\n            interp->traceCall |= (jsi_callTraceFuncs |jsi_callTraceArgs |jsi_callTraceReturn | jsi_callTraceBefore | jsi_callTraceFullPath);\n            iocnt--;\n            interp->iskips++;\n            continue;\n        }\n        if (Jsi_Strcmp(aio, \"--U\") == 0) {\n            interp->asserts = 1;\n            interp->unitTest = 1;\n            iocnt--;\n            interp->iskips++;\n            continue;\n        }\n        if (Jsi_Strcmp(aio, \"--V\") == 0) {\n            interp->asserts = 1;\n            interp->unitTest = 5;\n            interp->tracePuts = 1;\n            iocnt--;\n            interp->iskips++;\n            continue;\n        }\n        if (Jsi_Strcmp(aio, \"--C\") == 0) {\n            if (interp->confFile)\n               Jsi_LogWarn(\"overriding confFile: %s\", interp->confFile);\n            interp->confFile = argv[iocnt+1];\n            interp->iskips+=2;\n            continue;\n        }\n        if (Jsi_Strcmp(aio, \"--L\") == 0) {\n            struct stat sb;\n            const char* path = argv[iocnt+1]; \/\/TODO: convert to Jsi_Value first?\n            if (!path || stat(path, &sb)\n                || !((S_ISREG(sb.st_mode) && !access(path, W_OK)) || (S_ISDIR(sb.st_mode) && !access(path, X_OK)))) {\n                Jsi_LogError(\"Lockdown path must exist and be a writable file or executable dir: %s\", path);\n                Jsi_InterpDelete(interp);\n                return NULL;\n            }\n            interp->isSafe = true;\n            interp->safeMode = jsi_safe_Lockdown;\n            if (interp->safeWriteDirs) {\n                Jsi_LogWarn(\"Overriding safeWriteDirs\");\n                Jsi_DecrRefCount(interp, interp->safeWriteDirs);\n            }\n            const char *vda[2] = {};\n            char npath[PATH_MAX];\n            vda[0] = Jsi_FileRealpathStr(interp, path, npath);\n            interp->safeWriteDirs = Jsi_ValueNewArray(interp, vda, 1);\n            Jsi_IncrRefCount(interp, interp->safeWriteDirs);\n            if (!interp->safeReadDirs) {\n                interp->safeReadDirs = interp->safeWriteDirs;\n                Jsi_IncrRefCount(interp, interp->safeReadDirs);\n            }\n            interp->iskips+=2;\n            continue;\n        }\n        if (Jsi_Strcmp(aio, \"--T\") == 0) {\n            if (jsi_ParseTypeCheckStr(interp, argv[iocnt+1]) != JSI_OK) {\n                Jsi_InterpDelete(interp);\n                return NULL;\n            }\n            interp->iskips+=2;\n            continue;\n        }\n        if (!Jsi_Strcmp(aio, \"--I\"))  {\n            bool bv = 1;\n            char *aio2 = argv[iocnt+1], *aioc = Jsi_Strchr(aio2, ':'),\n                argNamS[50], *argNam = aio2;\n            const char *argVal;\n            if (!Jsi_Strcmp(\"traceCall\", aio2))\n                interp->traceCall |= (jsi_callTraceFuncs |jsi_callTraceArgs |jsi_callTraceReturn | jsi_callTraceBefore | jsi_callTraceFullPath);\n            else {\n                if (aioc) {\n                    argNam = argNamS;\n                    argVal = aioc+1;\n                    snprintf(argNamS, sizeof(argNamS), \"%.*s\", (int)(aioc-aio2), aio2);\n                }\n                \n                DECL_VALINIT(argV);\n                Jsi_Value *argValue = &argV;\n                Jsi_Number dv;\n                if (!aioc || Jsi_GetBool(interp, argVal, &bv) == JSI_OK) {\n                    Jsi_ValueMakeBool(interp, &argValue, bv);\n                } else if (!Jsi_Strcmp(\"null\", argVal)) {\n                    Jsi_ValueMakeNull(interp, &argValue);\n                } else if (Jsi_GetDouble(interp, argVal, &dv) == JSI_OK) {\n                    Jsi_ValueMakeNumber(interp, &argValue, dv);\n                } else {\n                    Jsi_ValueMakeStringKey(interp, &argValue, argVal);\n                }\n                if (JSI_OK != Jsi_OptionsSet(interp, InterpOptions, interp, argNam, argValue, 0)) {\n                    Jsi_InterpDelete(interp);\n                    return NULL;\n                }\n            }\n            interp->iskips+=2;\n            continue;\n        }\n        break;\n    }\n    if (!interp->strKeyTbl)\n        interp->strKeyTbl = jsiIntData.mainInterp->strKeyTbl;\n    if (opts) {\n        interp->inopts = opts = Jsi_ValueDupJSON(interp, opts);\n        if (Jsi_OptionsProcess(interp, InterpOptions, interp, opts, 0) < 0) {\n            Jsi_DecrRefCount(interp, opts);\n            interp->inopts = NULL;\n            Jsi_InterpDelete(interp);\n            return NULL;\n        }\n    }\n    if (interp == jsiIntData.mainInterp) {\n        interp->subthread = 0;\n    } else {\n        if (opts) {\n            if (interp->subOpts.privKeys && interp->strKeyTbl == jsiIntData.mainInterp->strKeyTbl) {\n                \/\/Jsi_HashDelete(interp->strKeyTbl);\n                Jsi_OptionsFree(interp, InterpOptions, interp, 0); \/* Reparse options to populate new key table. *\/\n                interp->strKeyTbl = Jsi_MapNew(interp, mapType, JSI_KEYS_STRING, NULL);\n                if (opts->vt != JSI_VT_NULL) Jsi_OptionsProcess(interp, InterpOptions, interp, opts, 0);\n            } else if (interp->subOpts.privKeys == 0 && interp->strKeyTbl != jsiIntData.mainInterp->strKeyTbl) {\n                Jsi_OptionsFree(interp, InterpOptions, interp, 0); \/* Reparse options to populate new key table. *\/\n                Jsi_MapDelete(interp->strKeyTbl);\n                interp->strKeyTbl = jsiIntData.mainInterp->strKeyTbl;\n                if (opts->vt != JSI_VT_NULL) Jsi_OptionsProcess(interp, InterpOptions, interp, opts, 0);\n            }\n        }\n        if (parent && parent->isSafe) {\n            interp->isSafe = 1;\n            interp->safeMode = parent->safeMode;\n        }\n        if (interp->subthread && interp->isSafe) {\n            interp->subthread = 0;\n            Jsi_LogError(\"threading disallowed in safe mode\");\n            Jsi_InterpDelete(interp);\n            return NULL;\n        }\n        if (interp->subthread)\n            jsiIntData.mainInterp->threadCnt++;\n        if (interp->subthread && interp->strKeyTbl == jsiIntData.mainInterp->strKeyTbl)\n            jsiIntData.mainInterp->threadShrCnt++;\n        if (jsiIntData.mainInterp->threadShrCnt)\n#ifdef JSI_USE_MANY_STRKEY\n            jsiIntData.mainInterp->strKeyTbl->v.tree->opts.lockTreeProc = KeyLockerTree;\n#else\n            jsiIntData.mainInterp->strKeyTbl->v.hash->opts.lockHashProc = KeyLocker;\n#endif\n    }\n    if (parent && parent->isSafe) {\n        interp->isSafe = 1;\n        interp->safeMode = parent->safeMode;\n        interp->maxOpCnt = parent->maxOpCnt;\n        if (interp->safeWriteDirs || interp->safeReadDirs || interp->safeExecPattern) {\n            Jsi_LogWarn(\"ignoring safe* options in safe sub-sub-interp\");\n            if (interp->safeWriteDirs) Jsi_DecrRefCount(interp, interp->safeWriteDirs);\n            if (interp->safeReadDirs) Jsi_DecrRefCount(interp, interp->safeReadDirs);\n            interp->safeWriteDirs = interp->safeReadDirs = NULL;\n            interp->safeExecPattern = NULL;\n        }\n    }\n\n    jsi_InterpConfFiles(interp);\n    if (!interp->udata) {\n        interp->udata = Jsi_ValueNewObj(interp, NULL);\n        Jsi_IncrRefCount(interp, interp->udata);\n    }\n    if (interp->subthread && !interp->scriptStr && !interp->scriptFile) {\n        Jsi_LogError(\"subthread interp must be specify either scriptFile or scriptStr\");\n        Jsi_InterpDelete(interp);\n        return NULL;\n    }\n#ifndef JSI_MEM_DEBUG\n    static int warnNoDebug = 0;\n    if (interp->memDebug && warnNoDebug == 0) {\n        Jsi_LogWarn(\"ignoring memDebug as jsi was compiled without memory debugging\");\n        warnNoDebug = 1;\n    }\n#endif\n    interp->threadId = Jsi_CurrentThread();\n    if (interp->parent && interp->subthread==0 && interp->threadId != interp->parent->threadId) {\n        interp->threadId = interp->parent->threadId;\n#ifndef JSI_MEM_DEBUG\n        Jsi_LogWarn(\"non-threaded sub-interp created by different thread than parent\");\n#endif\n    }\n    if (interp->safeMode != jsi_safe_None)\n        interp->isSafe = interp->startSafe = 1;\n    if (!interp->parent) {\n        if (interp->isSafe)\n            interp->startSafe = 1;\n        if (interp->debugOpts.msgCallback)\n            Jsi_LogWarn(\"ignoring msgCallback\");\n        if (interp->debugOpts.putsCallback)\n            Jsi_LogWarn(\"ignoring putsCallback\");\n        if (interp->busyCallback)\n            Jsi_LogWarn(\"ignoring busyCallback\");\n        if (interp->debugOpts.traceCallback)\n            Jsi_LogWarn(\"ignoring traceCallback\");\n    } else if (interp->busyCallback && interp->threadId != interp->parent->threadId) {\n        Jsi_LogWarn(\"disabling busyCallback due to threads\");\n        interp->busyCallback = NULL;\n    }\n    if (interp == jsiIntData.mainInterp)\n        interp->lexkeyTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, NULL);\n    else\n        interp->lexkeyTbl = jsiIntData.mainInterp->lexkeyTbl;\n    interp->thisTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeValueTbl);\n    interp->userdataTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, freeUserdataTbl);\n    interp->varTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, NULL);\n    interp->codeTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, freeCodeTbl);\n    interp->genValueTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD,freeValueTbl);\n    interp->genObjTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, freeGenObjTbl);\n#ifdef JSI_MEM_DEBUG\n    interp->codesTbl = (interp == jsiIntData.mainInterp ? Jsi_HashNew(interp, JSI_KEYS_ONEWORD, NULL) : jsiIntData.mainInterp->codesTbl);\n#endif\n    if (interp->typeCheck.all|interp->typeCheck.parse|interp->typeCheck.funcsig)\n        interp->staticFuncsTbl = Jsi_HashNew(interp, JSI_KEYS_STRING, NULL);\n    if (!jsiIntData.isInit) {\n        jsiIntData.isInit = 1;\n        jsi_InitValue(interp, 0);\n        jsiIntData.interpsTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, 0);\n    }\n\n    \/* current scope, also global *\/\n    interp->csc = Jsi_ValueNew1(interp);\n    Jsi_ValueMakeObject(interp, &interp->csc, Jsi_ObjNew(interp));\n    interp->framePtr->incsc = interp->csc;\n\n#define JSIDOINIT(nam) if (!jsi_ModBlacklisted(interp,#nam)) { if (jsi_Init##nam(interp, 0) != JSI_OK) { Jsi_LogBug(\"Init failure in %s\", #nam); } }\n#define JSIDOINIT2(nam) if (!jsi_ModBlacklisted(interp,#nam)) { if (Jsi_Init##nam(interp, 0) != JSI_OK) { Jsi_LogBug(\"Init failure in %s\", #nam); } }\n\n    JSIDOINIT(Proto);\n\n    if (interp->pkgDirs) \/\/ Fix-up because above, array was not yet initialized.\n        interp->pkgDirs->d.obj->__proto__ = interp->Array_prototype;\n\n    Jsi_Value *modObj = Jsi_ValueNewObj(interp, Jsi_ObjNewType(interp, JSI_OT_OBJECT));\n    Jsi_ValueInsert(interp, interp->csc, \"Jsi_Auto\", modObj, JSI_OM_DONTDEL);\n\n    \/* initial scope chain, nothing *\/\n    interp->framePtr->ingsc = interp->gsc = jsi_ScopeChainNew(interp, 0);\n\n    interp->ps = jsi_PstateNew(interp); \/* Default parser. *\/\n    if (interp->unitTest&2) {\n        interp->logOpts.before = 1;\n        interp->logOpts.full = 1;\n        interp->tracePuts = 1;\n        interp->noStderr = 1;\n    }\n    if (interp->args && argc) {\n        Jsi_LogBug(\"args may not be specified both as options and parameter\");\n        Jsi_InterpDelete(interp);\n        return NULL;\n    }\n    if (interp->maxDepth>JSI_MAX_EVAL_DEPTH)\n        interp->maxDepth = JSI_MAX_EVAL_DEPTH;\n\n    \/\/ Create the args array.\n    if (argc >= 0 && !interp->args) {\n        Jsi_Value *iargs = Jsi_ValueNew1(interp);\n        iargs->f.bits.dontdel = 1;\n        iargs->f.bits.readonly = 1;\n        Jsi_Obj *iobj = Jsi_ObjNew(interp);\n        Jsi_ValueMakeArrayObject(interp, &iargs, iobj);\n        int i = 1, ii = (iocnt>1 ? iocnt : 1);\n        int msiz = (argc?argc-iocnt:0);\n        Jsi_ObjArraySizer(interp, iobj, msiz);\n        iobj->arrMaxSize = msiz;\n        iocnt--;\n        iobj->arrCnt = argc-iocnt;\n        for (i = 1; ii < argc; ++ii, i++) {\n            iobj->arr[i-1] = Jsi_ValueNewStringKey(interp, argv[ii]);\n            Jsi_IncrRefCount(interp, iobj->arr[i-1]);\n            jsi_ValueDebugLabel(iobj->arr[i-1], \"InterpCreate\", \"args\");\n        }\n        Jsi_ObjSetLength(interp, iobj, msiz);\n        interp->args = iargs;\n    } else if (interp->parent && interp->args) {\n        \/\/ Avoid strings from sneeking in with options from parent...\n        Jsi_Value *nar = Jsi_ValueDupJSON(interp, interp->args);\n        Jsi_DecrRefCount(interp, interp->args);\n        interp->args = nar;\n    }\n    JSIDOINIT(Options);\n    JSIDOINIT(Cmds);\n    JSIDOINIT(Interp);\n    JSIDOINIT(JSON);\n\n    interp->retValue = Jsi_ValueNew1(interp);\n    interp->Mutex = Jsi_MutexNew(interp, -1, JSI_MUTEX_RECURSIVE);\n    if (1 || interp->subthread) {\n        interp->QMutex = Jsi_MutexNew(interp, -1, JSI_MUTEX_RECURSIVE);\n        \/\/Jsi_DSInit(&interp->interpEvalQ);\n    }\n    JSIDOINIT(Lexer);\n    if (interp != jsiIntData.mainInterp && !parent)\n        Jsi_HashSet(jsiIntData.interpsTbl, interp, NULL);\n\n    if (!interp->isSafe) {\n        JSIDOINIT(Load);\n#if JSI__SIGNAL==1\n        JSIDOINIT(Signal);\n#endif\n    }\n    if (interp->isSafe == 0 || interp->startSafe || interp->safeWriteDirs!=NULL || interp->safeReadDirs!=NULL) {\n#if JSI__FILESYS==1\n        JSIDOINIT(FileCmds);\n        JSIDOINIT(Filesys);\n#endif\n    }\n#if JSI__SQLITE==1\n    JSIDOINIT2(Sqlite);\n#else\n    Jsi_initSqlite(interp, 0);\n#endif\n#if JSI__MYSQL==1\n    if (!interp->noNetwork) {\n        JSIDOINIT2(MySql);\n    }\n#endif\n#if JSI__SOCKET==1\n    JSIDOINIT2(Socket);\n#endif\n#if JSI__WEBSOCKET==1\n    JSIDOINIT2(WebSocket);\n#endif\n\n#if JSI__CDATA==1\n    JSIDOINIT(CData);\n#endif\n\n#ifdef JSI_USER_EXTENSION\n    extern int JSI_USER_EXTENSION(Jsi_Interp *interp, int release);\n    if (JSI_USER_EXTENSION (interp, 0) != JSI_OK) {\n        fprintf(stderr, \"extension load failed\");\n        return jsi_DoExit(interp, 1);\n    }\n#endif\n    Jsi_PkgProvide(interp, \"Jsi\", JSI_VERSION, NULL);\n    if (argc > 0) {\n        char *ss = argv0;\n        char epath[PATH_MAX] = \"\"; \/\/ Path of executable\n#ifdef __WIN32\n\n        if (GetModuleFileName(NULL, epath, sizeof(epath))>0)\n            ss = epath;\n#else\n#ifndef PROC_SELF_DIR\n#define PROC_SELF_DIR \"\/proc\/self\/exe\"\n#endif\n        if (ss && *ss != '\/' && readlink(PROC_SELF_DIR, epath, sizeof(epath)) && epath[0])\n            ss = epath;\n#endif\n        Jsi_Value *src = Jsi_ValueNewStringDup(interp, ss);\n        Jsi_IncrRefCount(interp, src);\n        jsiIntData.execName = Jsi_Realpath(interp, src, NULL);\n        Jsi_DecrRefCount(interp, src);\n        if (!jsiIntData.execName) jsiIntData.execName = Jsi_Strdup(\"\");\n        jsiIntData.execValue = Jsi_ValueNewString(interp, jsiIntData.execName, -1);\n        Jsi_IncrRefCount(interp, jsiIntData.execValue);\n        Jsi_HashSet(interp->genValueTbl, jsiIntData.execValue, jsiIntData.execValue);\n    }\n\n    \/\/interp->nocacheOpCodes = 1;\n    if (interp->debugOpts.debugCallback && !interp->debugOpts.hook) {\n        interp->debugOpts.hook = jsi_InterpDebugHook;\n    }\n    interp->startTime = jsi_GetTimestamp();\n#ifdef JSI_INTERP_EXTENSION_CODE \/\/ For extending interp from jsi.c\n    JSI_INTERP_EXTENSION_CODE\n#endif\n    if (interp->opts.initProc && (*interp->opts.initProc)(interp, 0) != JSI_OK)\n        Jsi_LogBug(\"Init failure in initProc\");\n\n    return interp;\n}","target":0,"code_token_length":5934,"total_token_length":6170,"max_tokens_setting":8192}
+{"idx":433758,"func":"lmp_print(netdissect_options *ndo,\n          register const u_char *pptr, register u_int len)\n{\n    const struct lmp_common_header *lmp_com_header;\n    const struct lmp_object_header *lmp_obj_header;\n    const u_char *tptr,*obj_tptr;\n    u_int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen;\n    int hexdump, ret;\n    u_int offset;\n    u_int link_type;\n\n    union { \/* int to float conversion buffer *\/\n        float f;\n        uint32_t i;\n    } bw;\n\n    tptr=pptr;\n    lmp_com_header = (const struct lmp_common_header *)pptr;\n    ND_TCHECK(*lmp_com_header);\n\n    \/*\n     * Sanity checking of the header.\n     *\/\n    if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) {\n\tND_PRINT((ndo, \"LMP version %u packet not supported\",\n               LMP_EXTRACT_VERSION(lmp_com_header->version_res[0])));\n\treturn;\n    }\n\n    \/* in non-verbose mode just lets print the basic Message Type*\/\n    if (ndo->ndo_vflag < 1) {\n        ND_PRINT((ndo, \"LMPv%u %s Message, length: %u\",\n               LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),\n               tok2str(lmp_msg_type_values, \"unknown (%u)\",lmp_com_header->msg_type),\n               len));\n        return;\n    }\n\n    \/* ok they seem to want to know everything - lets fully decode it *\/\n\n    tlen=EXTRACT_16BITS(lmp_com_header->length);\n\n    ND_PRINT((ndo, \"\\n\\tLMPv%u, msg-type: %s, Flags: [%s], length: %u\",\n           LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),\n           tok2str(lmp_msg_type_values, \"unknown, type: %u\",lmp_com_header->msg_type),\n           bittok2str(lmp_header_flag_values,\"none\",lmp_com_header->flags),\n           tlen));\n    if (tlen < sizeof(const struct lmp_common_header)) {\n        ND_PRINT((ndo, \" (too short)\"));\n        return;\n    }\n    if (tlen > len) {\n        ND_PRINT((ndo, \" (too long)\"));\n        tlen = len;\n    }\n\n    tptr+=sizeof(const struct lmp_common_header);\n    tlen-=sizeof(const struct lmp_common_header);\n\n    while(tlen>0) {\n        \/* did we capture enough for fully decoding the object header ? *\/\n        ND_TCHECK2(*tptr, sizeof(struct lmp_object_header));\n\n        lmp_obj_header = (const struct lmp_object_header *)tptr;\n        lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length);\n        lmp_obj_ctype=(lmp_obj_header->ctype)&0x7f;\n\n        ND_PRINT((ndo, \"\\n\\t  %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u\",\n               tok2str(lmp_obj_values,\n                       \"Unknown\",\n                       lmp_obj_header->class_num),\n               lmp_obj_header->class_num,\n               tok2str(lmp_ctype_values,\n                       \"Unknown\",\n                       ((lmp_obj_header->class_num)<<8)+lmp_obj_ctype),\n               lmp_obj_ctype,\n               (lmp_obj_header->ctype)&0x80 ? \"\" : \"non-\",\n               lmp_obj_len));\n\n        if (lmp_obj_len < 4) {\n            ND_PRINT((ndo, \" (too short)\"));\n            return;\n        }\n        if ((lmp_obj_len % 4) != 0) {\n            ND_PRINT((ndo, \" (not a multiple of 4)\"));\n            return;\n        }\n\n        obj_tptr=tptr+sizeof(struct lmp_object_header);\n        obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);\n\n        \/* did we capture enough for fully decoding the object ? *\/\n        ND_TCHECK2(*tptr, lmp_obj_len);\n        hexdump=FALSE;\n\n        switch(lmp_obj_header->class_num) {\n\n        case LMP_OBJ_CC_ID:\n            switch(lmp_obj_ctype) {\n            case LMP_CTYPE_LOC:\n            case LMP_CTYPE_RMT:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Control Channel ID: %u (0x%08x)\",\n                       EXTRACT_32BITS(obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_LINK_ID:\n        case LMP_OBJ_INTERFACE_ID:\n            switch(lmp_obj_ctype) {\n            case LMP_CTYPE_IPV4_LOC:\n            case LMP_CTYPE_IPV4_RMT:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    IPv4 Link ID: %s (0x%08x)\",\n                       ipaddr_string(ndo, obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n            case LMP_CTYPE_IPV6_LOC:\n            case LMP_CTYPE_IPV6_RMT:\n                if (obj_tlen != 16) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    IPv6 Link ID: %s (0x%08x)\",\n                       ip6addr_string(ndo, obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n            case LMP_CTYPE_UNMD_LOC:\n            case LMP_CTYPE_UNMD_RMT:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Link ID: %u (0x%08x)\",\n                       EXTRACT_32BITS(obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_MESSAGE_ID:\n            switch(lmp_obj_ctype) {\n            case LMP_CTYPE_1:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Message ID: %u (0x%08x)\",\n                       EXTRACT_32BITS(obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n            case LMP_CTYPE_2:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Message ID Ack: %u (0x%08x)\",\n                       EXTRACT_32BITS(obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_NODE_ID:\n            switch(lmp_obj_ctype) {\n            case LMP_CTYPE_LOC:\n            case LMP_CTYPE_RMT:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Node ID: %s (0x%08x)\",\n                       ipaddr_string(ndo, obj_tptr),\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_CONFIG:\n            switch(lmp_obj_ctype) {\n            case LMP_CTYPE_HELLO_CONFIG:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Hello Interval: %u\\n\\t    Hello Dead Interval: %u\",\n                       EXTRACT_16BITS(obj_tptr),\n                       EXTRACT_16BITS(obj_tptr+2)));\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_HELLO:\n            switch(lmp_obj_ctype) {\n\t    case LMP_CTYPE_HELLO:\n                if (obj_tlen != 8) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Tx Seq: %u, Rx Seq: %u\",\n                       EXTRACT_32BITS(obj_tptr),\n                       EXTRACT_32BITS(obj_tptr+4)));\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_TE_LINK:\n\t    switch(lmp_obj_ctype) {\n\t    case LMP_CTYPE_IPV4:\n                if (obj_tlen != 12) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t    Flags: [%s]\",\n\t\t    bittok2str(lmp_obj_te_link_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_8BITS(obj_tptr))));\n\n\t\tND_PRINT((ndo, \"\\n\\t    Local Link-ID: %s (0x%08x)\"\n\t\t       \"\\n\\t    Remote Link-ID: %s (0x%08x)\",\n                       ipaddr_string(ndo, obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+4),\n                       ipaddr_string(ndo, obj_tptr+8),\n                       EXTRACT_32BITS(obj_tptr+8)));\n\t\tbreak;\n\n\t    case LMP_CTYPE_IPV6:\n                if (obj_tlen != 36) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t    Flags: [%s]\",\n\t\t    bittok2str(lmp_obj_te_link_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_8BITS(obj_tptr))));\n\n\t\tND_PRINT((ndo, \"\\n\\t    Local Link-ID: %s (0x%08x)\"\n\t\t       \"\\n\\t    Remote Link-ID: %s (0x%08x)\",\n                       ip6addr_string(ndo, obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+4),\n                       ip6addr_string(ndo, obj_tptr+20),\n                       EXTRACT_32BITS(obj_tptr+20)));\n                break;\n\n\t    case LMP_CTYPE_UNMD:\n                if (obj_tlen != 12) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t    Flags: [%s]\",\n\t\t    bittok2str(lmp_obj_te_link_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_8BITS(obj_tptr))));\n\n\t\tND_PRINT((ndo, \"\\n\\t    Local Link-ID: %u (0x%08x)\"\n\t\t       \"\\n\\t    Remote Link-ID: %u (0x%08x)\",\n                       EXTRACT_32BITS(obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+8),\n                       EXTRACT_32BITS(obj_tptr+8)));\n\t\tbreak;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_DATA_LINK:\n\t    switch(lmp_obj_ctype) {\n\t    case LMP_CTYPE_IPV4:\n                if (obj_tlen < 12) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t        ND_PRINT((ndo, \"\\n\\t    Flags: [%s]\",\n\t\t    bittok2str(lmp_obj_data_link_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_8BITS(obj_tptr))));\n                ND_PRINT((ndo, \"\\n\\t    Local Interface ID: %s (0x%08x)\"\n                       \"\\n\\t    Remote Interface ID: %s (0x%08x)\",\n                       ipaddr_string(ndo, obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+4),\n                       ipaddr_string(ndo, obj_tptr+8),\n                       EXTRACT_32BITS(obj_tptr+8)));\n\n\t\tret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12);\n\t\tif (ret == -1)\n\t\t    goto trunc;\n\t\tif (ret == TRUE)\n\t\t    hexdump=TRUE;\n\t\tbreak;\n\n\t    case LMP_CTYPE_IPV6:\n                if (obj_tlen < 36) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t        ND_PRINT((ndo, \"\\n\\t    Flags: [%s]\",\n\t\t    bittok2str(lmp_obj_data_link_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_8BITS(obj_tptr))));\n                ND_PRINT((ndo, \"\\n\\t    Local Interface ID: %s (0x%08x)\"\n                       \"\\n\\t    Remote Interface ID: %s (0x%08x)\",\n                       ip6addr_string(ndo, obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+4),\n                       ip6addr_string(ndo, obj_tptr+20),\n                       EXTRACT_32BITS(obj_tptr+20)));\n\n\t\tret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36);\n\t\tif (ret == -1)\n\t\t    goto trunc;\n\t\tif (ret == TRUE)\n\t\t    hexdump=TRUE;\n\t\tbreak;\n\n\t    case LMP_CTYPE_UNMD:\n                if (obj_tlen < 12) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t        ND_PRINT((ndo, \"\\n\\t    Flags: [%s]\",\n\t\t    bittok2str(lmp_obj_data_link_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_8BITS(obj_tptr))));\n                ND_PRINT((ndo, \"\\n\\t    Local Interface ID: %u (0x%08x)\"\n                       \"\\n\\t    Remote Interface ID: %u (0x%08x)\",\n                       EXTRACT_32BITS(obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+4),\n                       EXTRACT_32BITS(obj_tptr+8),\n                       EXTRACT_32BITS(obj_tptr+8)));\n\n\t\tret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12);\n\t\tif (ret == -1)\n\t\t    goto trunc;\n\t\tif (ret == TRUE)\n\t\t    hexdump=TRUE;\n\t\tbreak;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_VERIFY_BEGIN:\n\t    switch(lmp_obj_ctype) {\n            case LMP_CTYPE_1:\n                if (obj_tlen != 20) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t    Flags: %s\",\n\t\tbittok2str(lmp_obj_begin_verify_flag_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_16BITS(obj_tptr))));\n\t\tND_PRINT((ndo, \"\\n\\t    Verify Interval: %u\",\n\t\t\tEXTRACT_16BITS(obj_tptr+2)));\n\t\tND_PRINT((ndo, \"\\n\\t    Data links: %u\",\n\t\t\tEXTRACT_32BITS(obj_tptr+4)));\n                ND_PRINT((ndo, \"\\n\\t    Encoding type: %s\",\n\t\t\ttok2str(gmpls_encoding_values, \"Unknown\", *(obj_tptr+8))));\n                ND_PRINT((ndo, \"\\n\\t    Verify Transport Mechanism: %u (0x%x)%s\",\n\t\t\tEXTRACT_16BITS(obj_tptr+10),\n\t\t\tEXTRACT_16BITS(obj_tptr+10),\n\t\t\tEXTRACT_16BITS(obj_tptr+10)&8000 ? \" (Payload test messages capable)\" : \"\"));\n                bw.i = EXTRACT_32BITS(obj_tptr+12);\n\t\tND_PRINT((ndo, \"\\n\\t    Transmission Rate: %.3f Mbps\",bw.f*8\/1000000));\n\t\tND_PRINT((ndo, \"\\n\\t    Wavelength: %u\",\n\t\t\tEXTRACT_32BITS(obj_tptr+16)));\n\t\tbreak;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_VERIFY_BEGIN_ACK:\n\t    switch(lmp_obj_ctype) {\n            case LMP_CTYPE_1:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Verify Dead Interval: %u\"\n                       \"\\n\\t    Verify Transport Response: %u\",\n                       EXTRACT_16BITS(obj_tptr),\n                       EXTRACT_16BITS(obj_tptr+2)));\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n\tcase LMP_OBJ_VERIFY_ID:\n\t    switch(lmp_obj_ctype) {\n            case LMP_CTYPE_1:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n                ND_PRINT((ndo, \"\\n\\t    Verify ID: %u\",\n                       EXTRACT_32BITS(obj_tptr)));\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n\tcase LMP_OBJ_CHANNEL_STATUS:\n            switch(lmp_obj_ctype) {\n\t    case LMP_CTYPE_IPV4:\n\t\toffset = 0;\n\t\t\/* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> *\/\n\t\twhile (offset+8 <= obj_tlen) {\n\t\t\tND_PRINT((ndo, \"\\n\\t    Interface ID: %s (0x%08x)\",\n\t\t\tipaddr_string(ndo, obj_tptr+offset),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset)));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Active: %s (%u)\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?\n\t\t\t\t\t\t\"Allocated\" : \"Non-allocated\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>31)));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Direction: %s (%u)\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?\n\t\t\t\t\t\t\"Transmit\" : \"Receive\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Channel Status: %s (%u)\",\n\t\t\t\t\ttok2str(lmp_obj_channel_status_values,\n\t\t\t \t\t\"Unknown\",\n\t\t\t\t\tEXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF));\n\t\t\toffset+=8;\n\t\t}\n                break;\n\n\t    case LMP_CTYPE_IPV6:\n\t\toffset = 0;\n\t\t\/* Decode pairs: <Interface_ID (16 bytes), Channel_status (4 bytes)> *\/\n\t\twhile (offset+20 <= obj_tlen) {\n\t\t\tND_PRINT((ndo, \"\\n\\t    Interface ID: %s (0x%08x)\",\n\t\t\tip6addr_string(ndo, obj_tptr+offset),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset)));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Active: %s (%u)\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+16)>>31) ?\n\t\t\t\t\t\t\"Allocated\" : \"Non-allocated\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+16)>>31)));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Direction: %s (%u)\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+16)>>30)&0x1 ?\n\t\t\t\t\t\t\"Transmit\" : \"Receive\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+16)>>30)&0x1));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Channel Status: %s (%u)\",\n\t\t\t\t\ttok2str(lmp_obj_channel_status_values,\n\t\t\t\t\t\"Unknown\",\n\t\t\t\t\tEXTRACT_32BITS(obj_tptr+offset+16)&0x3FFFFFF),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset+16)&0x3FFFFFF));\n\t\t\toffset+=20;\n\t\t}\n                break;\n\n\t    case LMP_CTYPE_UNMD:\n\t\toffset = 0;\n\t\t\/* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> *\/\n\t\twhile (offset+8 <= obj_tlen) {\n\t\t\tND_PRINT((ndo, \"\\n\\t    Interface ID: %u (0x%08x)\",\n\t\t\tEXTRACT_32BITS(obj_tptr+offset),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset)));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Active: %s (%u)\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?\n\t\t\t\t\t\t\"Allocated\" : \"Non-allocated\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>31)));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Direction: %s (%u)\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?\n\t\t\t\t\t\t\"Transmit\" : \"Receive\",\n\t\t\t\t(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1));\n\n\t\t\tND_PRINT((ndo, \"\\n\\t\\t    Channel Status: %s (%u)\",\n\t\t\t\t\ttok2str(lmp_obj_channel_status_values,\n\t\t\t\t\t\"Unknown\",\n\t\t\t\t\tEXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF));\n\t\t\toffset+=8;\n\t\t}\n                break;\n\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n\tcase LMP_OBJ_CHANNEL_STATUS_REQ:\n            switch(lmp_obj_ctype) {\n\t    case LMP_CTYPE_IPV4:\n\t\toffset = 0;\n\t\twhile (offset+4 <= obj_tlen) {\n\t\t\tND_PRINT((ndo, \"\\n\\t    Interface ID: %s (0x%08x)\",\n\t\t\tipaddr_string(ndo, obj_tptr+offset),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset)));\n\t\t\toffset+=4;\n\t\t}\n                break;\n\n\t    case LMP_CTYPE_IPV6:\n\t\toffset = 0;\n\t\twhile (offset+16 <= obj_tlen) {\n\t\t\tND_PRINT((ndo, \"\\n\\t    Interface ID: %s (0x%08x)\",\n\t\t\tip6addr_string(ndo, obj_tptr+offset),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset)));\n\t\t\toffset+=16;\n\t\t}\n                break;\n\n\t    case LMP_CTYPE_UNMD:\n\t\toffset = 0;\n\t\twhile (offset+4 <= obj_tlen) {\n\t\t\tND_PRINT((ndo, \"\\n\\t    Interface ID: %u (0x%08x)\",\n\t\t\tEXTRACT_32BITS(obj_tptr+offset),\n\t\t\tEXTRACT_32BITS(obj_tptr+offset)));\n\t\t\toffset+=4;\n\t\t}\n                break;\n\n\t    default:\n                hexdump=TRUE;\n            }\n            break;\n\n        case LMP_OBJ_ERROR_CODE:\n\t    switch(lmp_obj_ctype) {\n            case LMP_CTYPE_BEGIN_VERIFY_ERROR:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t    Error Code: %s\",\n\t\tbittok2str(lmp_obj_begin_verify_error_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_32BITS(obj_tptr))));\n                break;\n\n            case LMP_CTYPE_LINK_SUMMARY_ERROR:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t    Error Code: %s\",\n\t\tbittok2str(lmp_obj_link_summary_error_values,\n\t\t\t\"none\",\n\t\t\tEXTRACT_32BITS(obj_tptr))));\n                break;\n            default:\n                hexdump=TRUE;\n            }\n            break;\n\n\tcase LMP_OBJ_SERVICE_CONFIG:\n\t    switch (lmp_obj_ctype) {\n\t    case LMP_CTYPE_SERVICE_CONFIG_SP:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\t\tND_PRINT((ndo, \"\\n\\t Flags: %s\",\n\t\t       bittok2str(lmp_obj_service_config_sp_flag_values,\n\t\t\t\t  \"none\",\n\t\t\t\t  EXTRACT_8BITS(obj_tptr))));\n\n\t\tND_PRINT((ndo, \"\\n\\t  UNI Version: %u\",\n\t\t       EXTRACT_8BITS(obj_tptr + 1)));\n\n\t\tbreak;\n\n            case LMP_CTYPE_SERVICE_CONFIG_CPSA:\n                if (obj_tlen != 16) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\n\t\tlink_type = EXTRACT_8BITS(obj_tptr);\n\n\t\tND_PRINT((ndo, \"\\n\\t Link Type: %s (%u)\",\n\t\t       tok2str(lmp_sd_service_config_cpsa_link_type_values,\n\t\t\t       \"Unknown\", link_type),\n\t\t       link_type));\n\n\t\tswitch (link_type) {\n\t\tcase LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH:\n\t\t    ND_PRINT((ndo, \"\\n\\t Signal Type: %s (%u)\",\n\t\t\t   tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values,\n\t\t\t\t   \"Unknown\",\n\t\t\t\t   EXTRACT_8BITS(obj_tptr + 1)),\n\t\t\t\t   EXTRACT_8BITS(obj_tptr + 1)));\n\t\t    break;\n\n\t\tcase LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET:\n\t\t    ND_PRINT((ndo, \"\\n\\t Signal Type: %s (%u)\",\n\t\t\t   tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values,\n\t\t\t\t   \"Unknown\",\n\t\t\t\t   EXTRACT_8BITS(obj_tptr + 1)),\n\t\t\t\t   EXTRACT_8BITS(obj_tptr + 1)));\n\t\t    break;\n\t\t}\n\n\t\tND_PRINT((ndo, \"\\n\\t Transparency: %s\",\n\t\t       bittok2str(lmp_obj_service_config_cpsa_tp_flag_values,\n\t\t\t\t  \"none\",\n\t\t\t\t  EXTRACT_8BITS(obj_tptr + 2))));\n\n\t\tND_PRINT((ndo, \"\\n\\t Contiguous Concatenation Types: %s\",\n\t\t       bittok2str(lmp_obj_service_config_cpsa_cct_flag_values,\n\t\t\t\t  \"none\",\n\t\t\t\t  EXTRACT_8BITS(obj_tptr + 3))));\n\n\t\tND_PRINT((ndo, \"\\n\\t Minimum NCC: %u\",\n\t\t       EXTRACT_16BITS(obj_tptr+4)));\n\n\t\tND_PRINT((ndo, \"\\n\\t Maximum NCC: %u\",\n\t\t       EXTRACT_16BITS(obj_tptr+6)));\n\n\t\tND_PRINT((ndo, \"\\n\\t Minimum NVC:%u\",\n\t\t       EXTRACT_16BITS(obj_tptr+8)));\n\n\t\tND_PRINT((ndo, \"\\n\\t Maximum NVC:%u\",\n\t\t       EXTRACT_16BITS(obj_tptr+10)));\n\n\t\tND_PRINT((ndo, \"\\n\\t    Local Interface ID: %s (0x%08x)\",\n\t\t       ipaddr_string(ndo, obj_tptr+12),\n\t\t       EXTRACT_32BITS(obj_tptr+12)));\n\n\t\tbreak;\n\n\t    case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM:\n                if (obj_tlen != 8) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\n\t\tND_PRINT((ndo, \"\\n\\t Transparency Flags: %s\",\n\t\t       bittok2str(\n\t\t\t   lmp_obj_service_config_nsa_transparency_flag_values,\n\t\t\t   \"none\",\n\t\t\t   EXTRACT_32BITS(obj_tptr))));\n\n\t\tND_PRINT((ndo, \"\\n\\t TCM Monitoring Flags: %s\",\n\t\t       bittok2str(\n\t\t\t   lmp_obj_service_config_nsa_tcm_flag_values,\n\t\t\t   \"none\",\n\t\t\t   EXTRACT_8BITS(obj_tptr + 7))));\n\n\t\tbreak;\n\n\t    case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY:\n                if (obj_tlen != 4) {\n                    ND_PRINT((ndo, \" (not correct for object)\"));\n                    break;\n                }\n\n\t\tND_PRINT((ndo, \"\\n\\t Diversity: Flags: %s\",\n\t\t       bittok2str(\n\t\t\t   lmp_obj_service_config_nsa_network_diversity_flag_values,\n\t\t\t   \"none\",\n\t\t\t   EXTRACT_8BITS(obj_tptr + 3))));\n\t\tbreak;\n\n\t    default:\n\t\thexdump = TRUE;\n\t    }\n\n\tbreak;\n\n        default:\n            if (ndo->ndo_vflag <= 1)\n                print_unknown_data(ndo,obj_tptr,\"\\n\\t    \",obj_tlen);\n            break;\n        }\n        \/* do we want to see an additionally hexdump ? *\/\n        if (ndo->ndo_vflag > 1 || hexdump==TRUE)\n            print_unknown_data(ndo,tptr+sizeof(struct lmp_object_header),\"\\n\\t    \",\n                               lmp_obj_len-sizeof(struct lmp_object_header));\n\n        tptr+=lmp_obj_len;\n        tlen-=lmp_obj_len;\n    }\n    return;\ntrunc:\n    ND_PRINT((ndo, \"%s\", tstr));\n}","target":0,"code_token_length":6536,"total_token_length":6772,"max_tokens_setting":8192}
+{"idx":353567,"func":"int ssl3_send_client_key_exchange(SSL *s)\n\t{\n\tunsigned char *p,*d;\n\tint n;\n\tunsigned long alg_k;\n#ifndef OPENSSL_NO_RSA\n\tunsigned char *q;\n\tEVP_PKEY *pkey=NULL;\n#endif\n#ifndef OPENSSL_NO_KRB5\n\tKSSL_ERR kssl_err;\n#endif \/* OPENSSL_NO_KRB5 *\/\n#ifndef OPENSSL_NO_ECDH\n\tEC_KEY *clnt_ecdh = NULL;\n\tconst EC_POINT *srvr_ecpoint = NULL;\n\tEVP_PKEY *srvr_pub_pkey = NULL;\n\tunsigned char *encodedPoint = NULL;\n\tint encoded_pt_len = 0;\n\tBN_CTX * bn_ctx = NULL;\n#endif\n\n\tif (s->state == SSL3_ST_CW_KEY_EXCH_A)\n\t\t{\n\t\td=(unsigned char *)s->init_buf->data;\n\t\tp= &(d[4]);\n\n\t\talg_k=s->s3->tmp.new_cipher->algorithm_mkey;\n\n\t\t\/* Fool emacs indentation *\/\n\t\tif (0) {}\n#ifndef OPENSSL_NO_RSA\n\t\telse if (alg_k & SSL_kRSA)\n\t\t\t{\n\t\t\tRSA *rsa;\n\t\t\tunsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];\n\n\t\t\tif (s->session->sess_cert->peer_rsa_tmp != NULL)\n\t\t\t\trsa=s->session->sess_cert->peer_rsa_tmp;\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tpkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);\n\t\t\t\tif ((pkey == NULL) ||\n\t\t\t\t\t(pkey->type != EVP_PKEY_RSA) ||\n\t\t\t\t\t(pkey->pkey.rsa == NULL))\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\trsa=pkey->pkey.rsa;\n\t\t\t\tEVP_PKEY_free(pkey);\n\t\t\t\t}\n\t\t\t\t\n\t\t\ttmp_buf[0]=s->client_version>>8;\n\t\t\ttmp_buf[1]=s->client_version&0xff;\n\t\t\tif (RAND_bytes(&(tmp_buf[2]),sizeof tmp_buf-2) <= 0)\n\t\t\t\t\tgoto err;\n\n\t\t\ts->session->master_key_length=sizeof tmp_buf;\n\n\t\t\tq=p;\n\t\t\t\/* Fix buf for TLS and beyond *\/\n\t\t\tif (s->version > SSL3_VERSION)\n\t\t\t\tp+=2;\n\t\t\tn=RSA_public_encrypt(sizeof tmp_buf,\n\t\t\t\ttmp_buf,p,rsa,RSA_PKCS1_PADDING);\n#ifdef PKCS1_CHECK\n\t\t\tif (s->options & SSL_OP_PKCS1_CHECK_1) p[1]++;\n\t\t\tif (s->options & SSL_OP_PKCS1_CHECK_2) tmp_buf[0]=0x70;\n#endif\n\t\t\tif (n <= 0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_ENCRYPT);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\t\/* Fix buf for TLS and beyond *\/\n\t\t\tif (s->version > SSL3_VERSION)\n\t\t\t\t{\n\t\t\t\ts2n(n,q);\n\t\t\t\tn+=2;\n\t\t\t\t}\n\n\t\t\ts->session->master_key_length=\n\t\t\t\ts->method->ssl3_enc->generate_master_secret(s,\n\t\t\t\t\ts->session->master_key,\n\t\t\t\t\ttmp_buf,sizeof tmp_buf);\n\t\t\tOPENSSL_cleanse(tmp_buf,sizeof tmp_buf);\n\t\t\t}\n#endif\n#ifndef OPENSSL_NO_KRB5\n\t\telse if (alg_k & SSL_kKRB5)\n\t\t\t{\n\t\t\tkrb5_error_code\tkrb5rc;\n\t\t\tKSSL_CTX\t*kssl_ctx = s->kssl_ctx;\n\t\t\t\/*  krb5_data\tkrb5_ap_req;  *\/\n\t\t\tkrb5_data\t*enc_ticket;\n\t\t\tkrb5_data\tauthenticator, *authp = NULL;\n\t\t\tEVP_CIPHER_CTX\tciph_ctx;\n\t\t\tconst EVP_CIPHER *enc = NULL;\n\t\t\tunsigned char\tiv[EVP_MAX_IV_LENGTH];\n\t\t\tunsigned char\ttmp_buf[SSL_MAX_MASTER_KEY_LENGTH];\n\t\t\tunsigned char\tepms[SSL_MAX_MASTER_KEY_LENGTH \n\t\t\t\t\t\t+ EVP_MAX_IV_LENGTH];\n\t\t\tint \t\tpadl, outl = sizeof(epms);\n\n\t\t\tEVP_CIPHER_CTX_init(&ciph_ctx);\n\n#ifdef KSSL_DEBUG\n\t\t\tprintf(\"ssl3_send_client_key_exchange(%lx & %lx)\\n\",\n\t\t\t\talg_k, SSL_kKRB5);\n#endif\t\/* KSSL_DEBUG *\/\n\n\t\t\tauthp = NULL;\n#ifdef KRB5SENDAUTH\n\t\t\tif (KRB5SENDAUTH)  authp = &authenticator;\n#endif\t\/* KRB5SENDAUTH *\/\n\n\t\t\tkrb5rc = kssl_cget_tkt(kssl_ctx, &enc_ticket, authp,\n\t\t\t\t&kssl_err);\n\t\t\tenc = kssl_map_enc(kssl_ctx->enctype);\n\t\t\tif (enc == NULL)\n\t\t\t    goto err;\n#ifdef KSSL_DEBUG\n\t\t\t{\n\t\t\tprintf(\"kssl_cget_tkt rtn %d\\n\", krb5rc);\n\t\t\tif (krb5rc && kssl_err.text)\n\t\t\t  printf(\"kssl_cget_tkt kssl_err=%s\\n\", kssl_err.text);\n\t\t\t}\n#endif\t\/* KSSL_DEBUG *\/\n\n\t\t\tif (krb5rc)\n\t\t\t\t{\n\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,\n\t\t\t\t\t\tSSL_AD_HANDSHAKE_FAILURE);\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\t\tkssl_err.reason);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\t\/*  20010406 VRS - Earlier versions used KRB5 AP_REQ\n\t\t\t**  in place of RFC 2712 KerberosWrapper, as in:\n\t\t\t**\n\t\t\t**  Send ticket (copy to *p, set n = length)\n\t\t\t**  n = krb5_ap_req.length;\n\t\t\t**  memcpy(p, krb5_ap_req.data, krb5_ap_req.length);\n\t\t\t**  if (krb5_ap_req.data)  \n\t\t\t**    kssl_krb5_free_data_contents(NULL,&krb5_ap_req);\n\t\t\t**\n\t\t\t**  Now using real RFC 2712 KerberosWrapper\n\t\t\t**  (Thanks to Simon Wilkinson <sxw@sxw.org.uk>)\n\t\t\t**  Note: 2712 \"opaque\" types are here replaced\n\t\t\t**  with a 2-byte length followed by the value.\n\t\t\t**  Example:\n\t\t\t**  KerberosWrapper= xx xx asn1ticket 0 0 xx xx encpms\n\t\t\t**  Where \"xx xx\" = length bytes.  Shown here with\n\t\t\t**  optional authenticator omitted.\n\t\t\t*\/\n\n\t\t\t\/*  KerberosWrapper.Ticket\t\t*\/\n\t\t\ts2n(enc_ticket->length,p);\n\t\t\tmemcpy(p, enc_ticket->data, enc_ticket->length);\n\t\t\tp+= enc_ticket->length;\n\t\t\tn = enc_ticket->length + 2;\n\n\t\t\t\/*  KerberosWrapper.Authenticator\t*\/\n\t\t\tif (authp  &&  authp->length)  \n\t\t\t\t{\n\t\t\t\ts2n(authp->length,p);\n\t\t\t\tmemcpy(p, authp->data, authp->length);\n\t\t\t\tp+= authp->length;\n\t\t\t\tn+= authp->length + 2;\n\t\t\t\t\n\t\t\t\tfree(authp->data);\n\t\t\t\tauthp->data = NULL;\n\t\t\t\tauthp->length = 0;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\ts2n(0,p);\/*  null authenticator length\t*\/\n\t\t\t\tn+=2;\n\t\t\t\t}\n \n\t\t\t    tmp_buf[0]=s->client_version>>8;\n\t\t\t    tmp_buf[1]=s->client_version&0xff;\n\t\t\t    if (RAND_bytes(&(tmp_buf[2]),sizeof tmp_buf-2) <= 0)\n\t\t\t\tgoto err;\n\n\t\t\t\/*  20010420 VRS.  Tried it this way; failed.\n\t\t\t**\tEVP_EncryptInit_ex(&ciph_ctx,enc, NULL,NULL);\n\t\t\t**\tEVP_CIPHER_CTX_set_key_length(&ciph_ctx,\n\t\t\t**\t\t\t\tkssl_ctx->length);\n\t\t\t**\tEVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv);\n\t\t\t*\/\n\n\t\t\tmemset(iv, 0, sizeof iv);  \/* per RFC 1510 *\/\n\t\t\tEVP_EncryptInit_ex(&ciph_ctx,enc, NULL,\n\t\t\t\tkssl_ctx->key,iv);\n\t\t\tEVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf,\n\t\t\t\tsizeof tmp_buf);\n\t\t\tEVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl);\n\t\t\toutl += padl;\n\t\t\tif (outl > (int)sizeof epms)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tEVP_CIPHER_CTX_cleanup(&ciph_ctx);\n\n\t\t\t\/*  KerberosWrapper.EncryptedPreMasterSecret\t*\/\n\t\t\ts2n(outl,p);\n\t\t\tmemcpy(p, epms, outl);\n\t\t\tp+=outl;\n\t\t\tn+=outl + 2;\n\n\t\t\ts->session->master_key_length=\n\t\t\t\ts->method->ssl3_enc->generate_master_secret(s,\n\t\t\t\t\ts->session->master_key,\n\t\t\t\t\ttmp_buf, sizeof tmp_buf);\n\n\t\t\tOPENSSL_cleanse(tmp_buf, sizeof tmp_buf);\n\t\t\tOPENSSL_cleanse(epms, outl);\n\t\t\t}\n#endif\n#ifndef OPENSSL_NO_DH\n\t\telse if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd))\n\t\t\t{\n\t\t\tDH *dh_srvr,*dh_clnt;\n\t\t\tSESS_CERT *scert = s->session->sess_cert;\n\n\t\t\tif (scert == NULL) \n\t\t\t\t{\n\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_UNEXPECTED_MESSAGE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\tif (scert->peer_dh_tmp != NULL)\n\t\t\t\tdh_srvr=scert->peer_dh_tmp;\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t\/* we get them from the cert *\/\n\t\t\t\tint idx = scert->peer_cert_type;\n\t\t\t\tEVP_PKEY *spkey = NULL;\n\t\t\t\tdh_srvr = NULL;\n\t\t\t\tif (idx >= 0)\n\t\t\t\t\tspkey = X509_get_pubkey(\n\t\t\t\t\t\tscert->peer_pkeys[idx].x509);\n\t\t\t\tif (spkey)\n\t\t\t\t\t{\n\t\t\t\t\tdh_srvr = EVP_PKEY_get1_DH(spkey);\n\t\t\t\t\tEVP_PKEY_free(spkey);\n\t\t\t\t\t}\n\t\t\t\tif (dh_srvr == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\t    ERR_R_INTERNAL_ERROR);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\/* generate a new random key *\/\n\t\t\tif ((dh_clnt=DHparams_dup(dh_srvr)) == NULL)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (!DH_generate_key(dh_clnt))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);\n\t\t\t\tDH_free(dh_clnt);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\t\/* use the 'p' output buffer for the DH key, but\n\t\t\t * make sure to clear it out afterwards *\/\n\n\t\t\tn=DH_compute_key(p,dh_srvr->pub_key,dh_clnt);\n\t\t\tif (scert->peer_dh_tmp == NULL)\n\t\t\t\tDH_free(dh_srvr);\n\n\t\t\tif (n <= 0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);\n\t\t\t\tDH_free(dh_clnt);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\t\/* generate master key from the result *\/\n\t\t\ts->session->master_key_length=\n\t\t\t\ts->method->ssl3_enc->generate_master_secret(s,\n\t\t\t\t\ts->session->master_key,p,n);\n\t\t\t\/* clean up *\/\n\t\t\tmemset(p,0,n);\n\n\t\t\t\/* send off the data *\/\n\t\t\tn=BN_num_bytes(dh_clnt->pub_key);\n\t\t\ts2n(n,p);\n\t\t\tBN_bn2bin(dh_clnt->pub_key,p);\n\t\t\tn+=2;\n\n\t\t\tDH_free(dh_clnt);\n\n\t\t\t\/* perhaps clean things up a bit EAY EAY EAY EAY*\/\n\t\t\t}\n#endif\n\n#ifndef OPENSSL_NO_ECDH \n\t\telse if (alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe))\n\t\t\t{\n\t\t\tconst EC_GROUP *srvr_group = NULL;\n\t\t\tEC_KEY *tkey;\n\t\t\tint ecdh_clnt_cert = 0;\n\t\t\tint field_size = 0;\n\n\t\t\t\/* Did we send out the client's\n\t\t\t * ECDH share for use in premaster\n\t\t\t * computation as part of client certificate?\n\t\t\t * If so, set ecdh_clnt_cert to 1.\n\t\t\t *\/\n\t\t\tif ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->cert != NULL)) \n\t\t\t\t{\n\t\t\t\t\/* XXX: For now, we do not support client\n\t\t\t\t * authentication using ECDH certificates.\n\t\t\t\t * To add such support, one needs to add\n\t\t\t\t * code that checks for appropriate \n\t\t\t\t * conditions and sets ecdh_clnt_cert to 1.\n\t\t\t\t * For example, the cert have an ECC\n\t\t\t\t * key on the same curve as the server's\n\t\t\t\t * and the key should be authorized for\n\t\t\t\t * key agreement.\n\t\t\t\t *\n\t\t\t\t * One also needs to add code in ssl3_connect\n\t\t\t\t * to skip sending the certificate verify\n\t\t\t\t * message.\n\t\t\t\t *\n\t\t\t\t * if ((s->cert->key->privatekey != NULL) &&\n\t\t\t\t *     (s->cert->key->privatekey->type ==\n\t\t\t\t *      EVP_PKEY_EC) && ...)\n\t\t\t\t * ecdh_clnt_cert = 1;\n\t\t\t\t *\/\n\t\t\t\t}\n\n\t\t\tif (s->session->sess_cert->peer_ecdh_tmp != NULL)\n\t\t\t\t{\n\t\t\t\ttkey = s->session->sess_cert->peer_ecdh_tmp;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t\/* Get the Server Public Key from Cert *\/\n\t\t\t\tsrvr_pub_pkey = X509_get_pubkey(s->session-> \\\n\t\t\t\t    sess_cert->peer_pkeys[SSL_PKEY_ECC].x509);\n\t\t\t\tif ((srvr_pub_pkey == NULL) ||\n\t\t\t\t    (srvr_pub_pkey->type != EVP_PKEY_EC) ||\n\t\t\t\t    (srvr_pub_pkey->pkey.ec == NULL))\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\t    ERR_R_INTERNAL_ERROR);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\n\t\t\t\ttkey = srvr_pub_pkey->pkey.ec;\n\t\t\t\t}\n\n\t\t\tsrvr_group   = EC_KEY_get0_group(tkey);\n\t\t\tsrvr_ecpoint = EC_KEY_get0_public_key(tkey);\n\n\t\t\tif ((srvr_group == NULL) || (srvr_ecpoint == NULL))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t    ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\tif ((clnt_ecdh=EC_KEY_new()) == NULL) \n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\tif (!EC_KEY_set_group(clnt_ecdh, srvr_group))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_EC_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (ecdh_clnt_cert) \n\t\t\t\t{ \n\t\t\t\t\/* Reuse key info from our certificate\n\t\t\t\t * We only need our private key to perform\n\t\t\t\t * the ECDH computation.\n\t\t\t\t *\/\n\t\t\t\tconst BIGNUM *priv_key;\n\t\t\t\ttkey = s->cert->key->privatekey->pkey.ec;\n\t\t\t\tpriv_key = EC_KEY_get0_private_key(tkey);\n\t\t\t\tif (priv_key == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\tif (!EC_KEY_set_private_key(clnt_ecdh, priv_key))\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_EC_LIB);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse \n\t\t\t\t{\n\t\t\t\t\/* Generate a new ECDH key pair *\/\n\t\t\t\tif (!(EC_KEY_generate_key(clnt_ecdh)))\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\/* use the 'p' output buffer for the ECDH key, but\n\t\t\t * make sure to clear it out afterwards\n\t\t\t *\/\n\n\t\t\tfield_size = EC_GROUP_get_degree(srvr_group);\n\t\t\tif (field_size <= 0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, \n\t\t\t\t       ERR_R_ECDH_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tn=ECDH_compute_key(p, (field_size+7)\/8, srvr_ecpoint, clnt_ecdh, NULL);\n\t\t\tif (n <= 0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, \n\t\t\t\t       ERR_R_ECDH_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\t\/* generate master key from the result *\/\n\t\t\ts->session->master_key_length = s->method->ssl3_enc \\\n\t\t\t    -> generate_master_secret(s, \n\t\t\t\ts->session->master_key,\n\t\t\t\tp, n);\n\n\t\t\tmemset(p, 0, n); \/* clean up *\/\n\n\t\t\tif (ecdh_clnt_cert) \n\t\t\t\t{\n\t\t\t\t\/* Send empty client key exch message *\/\n\t\t\t\tn = 0;\n\t\t\t\t}\n\t\t\telse \n\t\t\t\t{\n\t\t\t\t\/* First check the size of encoding and\n\t\t\t\t * allocate memory accordingly.\n\t\t\t\t *\/\n\t\t\t\tencoded_pt_len = \n\t\t\t\t    EC_POINT_point2oct(srvr_group, \n\t\t\t\t\tEC_KEY_get0_public_key(clnt_ecdh), \n\t\t\t\t\tPOINT_CONVERSION_UNCOMPRESSED, \n\t\t\t\t\tNULL, 0, NULL);\n\n\t\t\t\tencodedPoint = (unsigned char *) \n\t\t\t\t    OPENSSL_malloc(encoded_pt_len * \n\t\t\t\t\tsizeof(unsigned char)); \n\t\t\t\tbn_ctx = BN_CTX_new();\n\t\t\t\tif ((encodedPoint == NULL) || \n\t\t\t\t    (bn_ctx == NULL)) \n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\n\t\t\t\t\/* Encode the public key *\/\n\t\t\t\tn = EC_POINT_point2oct(srvr_group, \n\t\t\t\t    EC_KEY_get0_public_key(clnt_ecdh), \n\t\t\t\t    POINT_CONVERSION_UNCOMPRESSED, \n\t\t\t\t    encodedPoint, encoded_pt_len, bn_ctx);\n\n\t\t\t\t*p = n; \/* length of encoded point *\/\n\t\t\t\t\/* Encoded point will be copied here *\/\n\t\t\t\tp += 1; \n\t\t\t\t\/* copy the point *\/\n\t\t\t\tmemcpy((unsigned char *)p, encodedPoint, n);\n\t\t\t\t\/* increment n to account for length field *\/\n\t\t\t\tn += 1; \n\t\t\t\t}\n\n\t\t\t\/* Free allocated memory *\/\n\t\t\tBN_CTX_free(bn_ctx);\n\t\t\tif (encodedPoint != NULL) OPENSSL_free(encodedPoint);\n\t\t\tif (clnt_ecdh != NULL) \n\t\t\t\t EC_KEY_free(clnt_ecdh);\n\t\t\tEVP_PKEY_free(srvr_pub_pkey);\n\t\t\t}\n#endif \/* !OPENSSL_NO_ECDH *\/\n\t\telse if (alg_k & SSL_kGOST) \n\t\t\t{\n\t\t\t\/* GOST key exchange message creation *\/\n\t\t\tEVP_PKEY_CTX *pkey_ctx;\n\t\t\tX509 *peer_cert; \n\t\t\tsize_t msglen;\n\t\t\tunsigned int md_len;\n\t\t\tint keytype;\n\t\t\tunsigned char premaster_secret[32],shared_ukm[32], tmp[256];\n\t\t\tEVP_MD_CTX *ukm_hash;\n\t\t\tEVP_PKEY *pub_key;\n\n\t\t\t\/* Get server sertificate PKEY and create ctx from it *\/\n\t\t\tpeer_cert=s->session->sess_cert->peer_pkeys[(keytype=SSL_PKEY_GOST01)].x509;\n\t\t\tif (!peer_cert) \n\t\t\t\tpeer_cert=s->session->sess_cert->peer_pkeys[(keytype=SSL_PKEY_GOST94)].x509;\n\t\t\tif (!peer_cert)\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER);\n\t\t\t\t\tgoto err;\n\t\t\t\t}\t\n\t\t\t\t\n\t\t\tpkey_ctx=EVP_PKEY_CTX_new(pub_key=X509_get_pubkey(peer_cert),NULL);\n\t\t\t\/* If we have send a certificate, and certificate key\n\n\t\t\t * parameters match those of server certificate, use\n\t\t\t * certificate key for key exchange\n\t\t\t *\/\n\n\t\t\t \/* Otherwise, generate ephemeral key pair *\/\n\t\t\t\t\t\n\t\t\tEVP_PKEY_encrypt_init(pkey_ctx);\n\t\t\t  \/* Generate session key *\/\t\n\t\t    RAND_bytes(premaster_secret,32);\n\t\t\t\/* If we have client certificate, use its secret as peer key *\/\n\t\t\tif (s->s3->tmp.cert_req && s->cert->key->privatekey) {\n\t\t\t\tif (EVP_PKEY_derive_set_peer(pkey_ctx,s->cert->key->privatekey) <=0) {\n\t\t\t\t\t\/* If there was an error - just ignore it. Ephemeral key\n\t\t\t\t\t* would be used\n\t\t\t\t\t*\/\n\t\t\t\t\tERR_clear_error();\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\t\/* Compute shared IV and store it in algorithm-specific\n\t\t\t * context data *\/\n\t\t\tukm_hash = EVP_MD_CTX_create();\n\t\t\tEVP_DigestInit(ukm_hash,EVP_get_digestbynid(NID_id_GostR3411_94));\n\t\t\tEVP_DigestUpdate(ukm_hash,s->s3->client_random,SSL3_RANDOM_SIZE);\n\t\t\tEVP_DigestUpdate(ukm_hash,s->s3->server_random,SSL3_RANDOM_SIZE);\n\t\t\tEVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len);\n\t\t\tEVP_MD_CTX_destroy(ukm_hash);\n\t\t\tif (EVP_PKEY_CTX_ctrl(pkey_ctx,-1,EVP_PKEY_OP_ENCRYPT,EVP_PKEY_CTRL_SET_IV,\n\t\t\t\t8,shared_ukm)<0) {\n\t\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\t\tSSL_R_LIBRARY_BUG);\n\t\t\t\t\tgoto err;\n\t\t\t\t}\t\n\t\t\t\/* Make GOST keytransport blob message *\/\n\t\t\t\/*Encapsulate it into sequence *\/\n\t\t\t*(p++)=V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED;\n\t\t\tmsglen=255;\n\t\t\tif (EVP_PKEY_encrypt(pkey_ctx,tmp,&msglen,premaster_secret,32)<0) {\n\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tSSL_R_LIBRARY_BUG);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tif (msglen >= 0x80)\n\t\t\t\t{\n\t\t\t\t*(p++)=0x81;\n\t\t\t\t*(p++)= msglen & 0xff;\n\t\t\t\tn=msglen+3;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t*(p++)= msglen & 0xff;\n\t\t\t\tn=msglen+2;\n\t\t\t\t}\n\t\t\tmemcpy(p, tmp, msglen);\n\t\t\t\/* Check if pubkey from client certificate was used *\/\n\t\t\tif (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0)\n\t\t\t\t{\n\t\t\t\t\/* Set flag \"skip certificate verify\" *\/\n\t\t\t\ts->s3->flags |= TLS1_FLAGS_SKIP_CERT_VERIFY;\n\t\t\t\t}\n\t\t\tEVP_PKEY_CTX_free(pkey_ctx);\n\t\t\ts->session->master_key_length=\n\t\t\t\ts->method->ssl3_enc->generate_master_secret(s,\n\t\t\t\t\ts->session->master_key,premaster_secret,32);\n\t\t\tEVP_PKEY_free(pub_key);\n\n\t\t\t}\n#ifndef OPENSSL_NO_SRP\n\t\telse if (alg_k & SSL_kSRP)\n\t\t\t{\n\t\t\tif (s->srp_ctx.A != NULL)\n\t\t\t\t{\n\t\t\t\t\/* send off the data *\/\n\t\t\t\tn=BN_num_bytes(s->srp_ctx.A);\n\t\t\t\ts2n(n,p);\n\t\t\t\tBN_bn2bin(s->srp_ctx.A,p);\n\t\t\t\tn+=2;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (s->session->srp_username != NULL)\n\t\t\t\tOPENSSL_free(s->session->srp_username);\n\t\t\ts->session->srp_username = BUF_strdup(s->srp_ctx.login);\n\t\t\tif (s->session->srp_username == NULL)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\tif ((s->session->master_key_length = SRP_generate_client_master_secret(s,s->session->master_key))<0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n#endif\n#ifndef OPENSSL_NO_PSK\n\t\telse if (alg_k & SSL_kPSK)\n\t\t\t{\n\t\t\tchar identity[PSK_MAX_IDENTITY_LEN];\n\t\t\tunsigned char *t = NULL;\n\t\t\tunsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2+4];\n\t\t\tunsigned int pre_ms_len = 0, psk_len = 0;\n\t\t\tint psk_err = 1;\n\n\t\t\tn = 0;\n\t\t\tif (s->psk_client_callback == NULL)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tSSL_R_PSK_NO_CLIENT_CB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\n\t\t\tpsk_len = s->psk_client_callback(s, s->ctx->psk_identity_hint,\n\t\t\t\tidentity, PSK_MAX_IDENTITY_LEN,\n\t\t\t\tpsk_or_pre_ms, sizeof(psk_or_pre_ms));\n\t\t\tif (psk_len > PSK_MAX_PSK_LEN)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto psk_err;\n\t\t\t\t}\n\t\t\telse if (psk_len == 0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tSSL_R_PSK_IDENTITY_NOT_FOUND);\n\t\t\t\tgoto psk_err;\n\t\t\t\t}\n\n\t\t\t\/* create PSK pre_master_secret *\/\n\t\t\tpre_ms_len = 2+psk_len+2+psk_len;\n\t\t\tt = psk_or_pre_ms;\n\t\t\tmemmove(psk_or_pre_ms+psk_len+4, psk_or_pre_ms, psk_len);\n\t\t\ts2n(psk_len, t);\n\t\t\tmemset(t, 0, psk_len);\n\t\t\tt+=psk_len;\n\t\t\ts2n(psk_len, t);\n\n\t\t\tif (s->session->psk_identity_hint != NULL)\n\t\t\t\tOPENSSL_free(s->session->psk_identity_hint);\n\t\t\ts->session->psk_identity_hint = BUF_strdup(s->ctx->psk_identity_hint);\n\t\t\tif (s->ctx->psk_identity_hint != NULL &&\n\t\t\t\ts->session->psk_identity_hint == NULL)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto psk_err;\n\t\t\t\t}\n\n\t\t\tif (s->session->psk_identity != NULL)\n\t\t\t\tOPENSSL_free(s->session->psk_identity);\n\t\t\ts->session->psk_identity = BUF_strdup(identity);\n\t\t\tif (s->session->psk_identity == NULL)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto psk_err;\n\t\t\t\t}\n\n\t\t\ts->session->master_key_length =\n\t\t\t\ts->method->ssl3_enc->generate_master_secret(s,\n\t\t\t\t\ts->session->master_key,\n\t\t\t\t\tpsk_or_pre_ms, pre_ms_len); \n\t\t\tn = strlen(identity);\n\t\t\ts2n(n, p);\n\t\t\tmemcpy(p, identity, n);\n\t\t\tn+=2;\n\t\t\tpsk_err = 0;\n\t\tpsk_err:\n\t\t\tOPENSSL_cleanse(identity, PSK_MAX_IDENTITY_LEN);\n\t\t\tOPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms));\n\t\t\tif (psk_err != 0)\n\t\t\t\t{\n\t\t\t\tssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\telse\n\t\t\t{\n\t\t\tssl3_send_alert(s, SSL3_AL_FATAL,\n\t\t\t    SSL_AD_HANDSHAKE_FAILURE);\n\t\t\tSSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n\t\t\t    ERR_R_INTERNAL_ERROR);\n\t\t\tgoto err;\n\t\t\t}\n\t\t\n\t\t*(d++)=SSL3_MT_CLIENT_KEY_EXCHANGE;\n\t\tl2n3(n,d);\n\n\t\ts->state=SSL3_ST_CW_KEY_EXCH_B;\n\t\t\/* number of bytes to write *\/\n\t\ts->init_num=n+4;\n\t\ts->init_off=0;\n\t\t}\n\n\t\/* SSL3_ST_CW_KEY_EXCH_B *\/\n\treturn(ssl3_do_write(s,SSL3_RT_HANDSHAKE));\nerr:\n#ifndef OPENSSL_NO_ECDH\n\tBN_CTX_free(bn_ctx);\n\tif (encodedPoint != NULL) OPENSSL_free(encodedPoint);\n\tif (clnt_ecdh != NULL) \n\t\tEC_KEY_free(clnt_ecdh);\n\tEVP_PKEY_free(srvr_pub_pkey);\n#endif\n\treturn(-1);\n\t}","target":1,"code_token_length":6442,"total_token_length":6678,"max_tokens_setting":8192}
+{"idx":178650,"func":"WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)\n{\n \/* ! *\/\n\n dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);\n\n    WORD32 i4_err_status = 0;\n    UWORD8 *pu1_buf = NULL;\n    WORD32 buflen;\n    UWORD32 u4_max_ofst, u4_length_of_start_code = 0;\n\n    UWORD32 bytes_consumed = 0;\n    UWORD32 cur_slice_is_nonref = 0;\n    UWORD32 u4_next_is_aud;\n    UWORD32 u4_first_start_code_found = 0;\n    WORD32 ret = 0,api_ret_value = IV_SUCCESS;\n    WORD32 header_data_left = 0,frame_data_left = 0;\n    UWORD8 *pu1_bitstrm_buf;\n ivd_video_decode_ip_t *ps_dec_ip;\n ivd_video_decode_op_t *ps_dec_op;\n\n    ithread_set_name((void*)\"Parse_thread\");\n\n    ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip;\n    ps_dec_op = (ivd_video_decode_op_t *)pv_api_op;\n\n {\n        UWORD32 u4_size;\n        u4_size = ps_dec_op->u4_size;\n        memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t));\n        ps_dec_op->u4_size = u4_size;\n }\n\n    ps_dec->pv_dec_out = ps_dec_op;\n if(ps_dec->init_done != 1)\n {\n return IV_FAIL;\n }\n\n \/*Data memory barries instruction,so that bitstream write by the application is complete*\/\n    DATA_SYNC();\n\n if(0 == ps_dec->u1_flushfrm)\n {\n if(ps_dec_ip->pv_stream_buffer == NULL)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL;\n return IV_FAIL;\n }\n if(ps_dec_ip->u4_num_Bytes <= 0)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV;\n return IV_FAIL;\n\n }\n }\n    ps_dec->u1_pic_decode_done = 0;\n\n    ps_dec_op->u4_num_bytes_consumed = 0;\n\n    ps_dec->ps_out_buffer = NULL;\n\n if(ps_dec_ip->u4_size\n >= offsetof(ivd_video_decode_ip_t, s_out_buffer))\n        ps_dec->ps_out_buffer = &ps_dec_ip->s_out_buffer;\n\n    ps_dec->u4_fmt_conv_cur_row = 0;\n\n    ps_dec->u4_output_present = 0;\n    ps_dec->s_disp_op.u4_error_code = 1;\n    ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS;\n if(0 == ps_dec->u4_share_disp_buf\n && ps_dec->i4_decode_header == 0)\n {\n        UWORD32 i;\n if((ps_dec->ps_out_buffer->u4_num_bufs == 0) ||\n (ps_dec->ps_out_buffer->u4_num_bufs > IVD_VIDDEC_MAX_IO_BUFFERS))\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS;\n return IV_FAIL;\n }\n\n for(i = 0; i < ps_dec->ps_out_buffer->u4_num_bufs; i++)\n {\n if(ps_dec->ps_out_buffer->pu1_bufs[i] == NULL)\n {\n                ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n                ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL;\n return IV_FAIL;\n }\n\n if(ps_dec->ps_out_buffer->u4_min_out_buf_size[i] == 0)\n {\n                ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n                ps_dec_op->u4_error_code |=\n                                IVD_DISP_FRM_ZERO_OP_BUF_SIZE;\n return IV_FAIL;\n }\n }\n }\n\n if(ps_dec->u4_total_frames_decoded >= NUM_FRAMES_LIMIT)\n {\n        ps_dec_op->u4_error_code = ERROR_FRAME_LIMIT_OVER;\n return IV_FAIL;\n }\n\n \/* ! *\/\n    ps_dec->u4_ts = ps_dec_ip->u4_ts;\n\n    ps_dec_op->u4_error_code = 0;\n    ps_dec_op->e_pic_type = -1;\n    ps_dec_op->u4_output_present = 0;\n    ps_dec_op->u4_frame_decoded_flag = 0;\n\n    ps_dec->i4_frametype = -1;\n    ps_dec->i4_content_type = -1;\n\n    ps_dec->u4_slice_start_code_found = 0;\n\n \/* In case the deocder is not in flush mode(in shared mode),\n     then decoder has to pick up a buffer to write current frame.\n     Check if a frame is available in such cases *\/\n\n if(ps_dec->u1_init_dec_flag == 1 && ps_dec->u4_share_disp_buf == 1\n && ps_dec->u1_flushfrm == 0)\n {\n        UWORD32 i;\n\n        WORD32 disp_avail = 0, free_id;\n\n \/* Check if at least one buffer is available with the codec *\/\n \/* If not then return to application with error *\/\n for(i = 0; i < ps_dec->u1_pic_bufs; i++)\n {\n if(0 == ps_dec->u4_disp_buf_mapping[i]\n || 1 == ps_dec->u4_disp_buf_to_be_freed[i])\n {\n                disp_avail = 1;\n break;\n }\n\n }\n\n if(0 == disp_avail)\n {\n \/* If something is queued for display wait for that buffer to be returned *\/\n\n            ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;\n            ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n return (IV_FAIL);\n }\n\n while(1)\n {\n pic_buffer_t *ps_pic_buf;\n            ps_pic_buf = (pic_buffer_t *)ih264_buf_mgr_get_next_free(\n (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, &free_id);\n\n if(ps_pic_buf == NULL)\n {\n                UWORD32 i, display_queued = 0;\n\n \/* check if any buffer was given for display which is not returned yet *\/\n for(i = 0; i < (MAX_DISP_BUFS_NEW); i++)\n {\n if(0 != ps_dec->u4_disp_buf_mapping[i])\n {\n                        display_queued = 1;\n break;\n }\n }\n \/* If some buffer is queued for display, then codec has to singal an error and wait\n                 for that buffer to be returned.\n                 If nothing is queued for display then codec has ownership of all display buffers\n                 and it can reuse any of the existing buffers and continue decoding *\/\n\n if(1 == display_queued)\n {\n \/* If something is queued for display wait for that buffer to be returned *\/\n                    ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;\n                    ps_dec_op->u4_error_code |= (1\n << IVD_UNSUPPORTEDPARAM);\n return (IV_FAIL);\n }\n }\n else\n {\n \/* If the buffer is with display, then mark it as in use and then look for a buffer again *\/\n if(1 == ps_dec->u4_disp_buf_mapping[free_id])\n {\n                    ih264_buf_mgr_set_status(\n (buf_mgr_t *)ps_dec->pv_pic_buf_mgr,\n                                    free_id,\n                                    BUF_MGR_IO);\n }\n else\n {\n \/**\n                     *  Found a free buffer for present call. Release it now.\n                     *  Will be again obtained later.\n                     *\/\n                    ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,\n                                          free_id,\n                                          BUF_MGR_IO);\n break;\n }\n }\n }\n\n }\n\n if(ps_dec->u1_flushfrm)\n {\n if(ps_dec->u1_init_dec_flag == 0)\n {\n \/*Come out of flush mode and return*\/\n            ps_dec->u1_flushfrm = 0;\n return (IV_FAIL);\n }\n\n\n\n        ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer,\n &(ps_dec->s_disp_op));\n if(0 == ps_dec->s_disp_op.u4_error_code)\n {\n \/* check output buffer size given by the application *\/\n if(check_app_out_buf_size(ps_dec) != IV_SUCCESS)\n {\n                ps_dec_op->u4_error_code= IVD_DISP_FRM_ZERO_OP_BUF_SIZE;\n return (IV_FAIL);\n }\n\n            ps_dec->u4_fmt_conv_cur_row = 0;\n            ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht;\n            ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op),\n                                  ps_dec->u4_fmt_conv_cur_row,\n                                  ps_dec->u4_fmt_conv_num_rows);\n            ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;\n            ps_dec->u4_output_present = 1;\n\n }\n        ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op));\n\n        ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width;\n        ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height;\n\n        ps_dec_op->u4_new_seq = 0;\n\n        ps_dec_op->u4_output_present = ps_dec->u4_output_present;\n        ps_dec_op->u4_progressive_frame_flag =\n                        ps_dec->s_disp_op.u4_progressive_frame_flag;\n        ps_dec_op->e_output_format =\n                        ps_dec->s_disp_op.e_output_format;\n        ps_dec_op->s_disp_frm_buf = ps_dec->s_disp_op.s_disp_frm_buf;\n        ps_dec_op->e4_fld_type = ps_dec->s_disp_op.e4_fld_type;\n        ps_dec_op->u4_ts = ps_dec->s_disp_op.u4_ts;\n        ps_dec_op->u4_disp_buf_id = ps_dec->s_disp_op.u4_disp_buf_id;\n\n \/*In the case of flush ,since no frame is decoded set pic type as invalid*\/\n        ps_dec_op->u4_is_ref_flag = -1;\n        ps_dec_op->e_pic_type = IV_NA_FRAME;\n        ps_dec_op->u4_frame_decoded_flag = 0;\n\n if(0 == ps_dec->s_disp_op.u4_error_code)\n {\n return (IV_SUCCESS);\n }\n else\n return (IV_FAIL);\n\n }\n if(ps_dec->u1_res_changed == 1)\n {\n \/*if resolution has changed and all buffers have been flushed, reset decoder*\/\n        ih264d_init_decoder(ps_dec);\n }\n\n    ps_dec->u4_prev_nal_skipped = 0;\n\n    ps_dec->u2_cur_mb_addr = 0;\n    ps_dec->u2_total_mbs_coded = 0;\n    ps_dec->u2_cur_slice_num = 0;\n    ps_dec->cur_dec_mb_num = 0;\n    ps_dec->cur_recon_mb_num = 0;\n    ps_dec->u4_first_slice_in_pic = 1;\n    ps_dec->u1_slice_header_done = 0;\n    ps_dec->u1_dangling_field = 0;\n\n    ps_dec->u4_dec_thread_created = 0;\n    ps_dec->u4_bs_deblk_thread_created = 0;\n    ps_dec->u4_cur_bs_mb_num = 0;\n    ps_dec->u4_start_recon_deblk  = 0;\n    ps_dec->u4_sps_cnt_in_process = 0;\n\n    DEBUG_THREADS_PRINTF(\" Starting process call\\n\");\n\n\n    ps_dec->u4_pic_buf_got = 0;\n\n do\n {\n        WORD32 buf_size;\n\n        pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer\n + ps_dec_op->u4_num_bytes_consumed;\n\n        u4_max_ofst = ps_dec_ip->u4_num_Bytes\n - ps_dec_op->u4_num_bytes_consumed;\n\n \/* If dynamic bitstream buffer is not allocated and\n         * header decode is done, then allocate dynamic bitstream buffer\n         *\/\n if((NULL == ps_dec->pu1_bits_buf_dynamic) &&\n (ps_dec->i4_header_decoded & 1))\n {\n            WORD32 size;\n\n\n             void *pv_buf;\n             void *pv_mem_ctxt = ps_dec->pv_mem_ctxt;\n             size = MAX(256000, ps_dec->u2_pic_wd * ps_dec->u2_pic_ht * 3 \/ 2);\n            pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128,\n                                              size + EXTRA_BS_OFFSET);\n             RETURN_IF((NULL == pv_buf), IV_FAIL);\n             ps_dec->pu1_bits_buf_dynamic = pv_buf;\n             ps_dec->u4_dynamic_bits_buf_size = size;\n }\n\n if(ps_dec->pu1_bits_buf_dynamic)\n {\n            pu1_bitstrm_buf = ps_dec->pu1_bits_buf_dynamic;\n            buf_size = ps_dec->u4_dynamic_bits_buf_size;\n }\n else\n {\n            pu1_bitstrm_buf = ps_dec->pu1_bits_buf_static;\n            buf_size = ps_dec->u4_static_bits_buf_size;\n }\n\n        u4_next_is_aud = 0;\n\n        buflen = ih264d_find_start_code(pu1_buf, 0, u4_max_ofst,\n &u4_length_of_start_code,\n &u4_next_is_aud);\n\n if(buflen == -1)\n            buflen = 0;\n \/* Ignore bytes beyond the allocated size of intermediate buffer *\/\n \/* Since 8 bytes are read ahead, ensure 8 bytes are free at the\n        end of the buffer, which will be memset to 0 after emulation prevention *\/\n        buflen = MIN(buflen, buf_size - 8);\n\n        bytes_consumed = buflen + u4_length_of_start_code;\n        ps_dec_op->u4_num_bytes_consumed += bytes_consumed;\n\n {\n            UWORD8 u1_firstbyte, u1_nal_ref_idc;\n\n if(ps_dec->i4_app_skip_mode == IVD_SKIP_B)\n {\n                u1_firstbyte = *(pu1_buf + u4_length_of_start_code);\n                u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_firstbyte));\n if(u1_nal_ref_idc == 0)\n {\n \/*skip non reference frames*\/\n                    cur_slice_is_nonref = 1;\n continue;\n }\n else\n {\n if(1 == cur_slice_is_nonref)\n {\n \/*We have encountered a referenced frame,return to app*\/\n                        ps_dec_op->u4_num_bytes_consumed -=\n                                        bytes_consumed;\n                        ps_dec_op->e_pic_type = IV_B_FRAME;\n                        ps_dec_op->u4_error_code =\n                                        IVD_DEC_FRM_SKIPPED;\n                        ps_dec_op->u4_error_code |= (1\n << IVD_UNSUPPORTEDPARAM);\n                        ps_dec_op->u4_frame_decoded_flag = 0;\n                        ps_dec_op->u4_size =\n sizeof(ivd_video_decode_op_t);\n \/*signal the decode thread*\/\n                        ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n                            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n\n return (IV_FAIL);\n }\n }\n\n }\n\n }\n\n\n if(buflen)\n {\n            memcpy(pu1_bitstrm_buf, pu1_buf + u4_length_of_start_code,\n                   buflen);\n \/* Decoder may read extra 8 bytes near end of the frame *\/\n if((buflen + 8) < buf_size)\n {\n                memset(pu1_bitstrm_buf + buflen, 0, 8);\n }\n            u4_first_start_code_found = 1;\n\n }\n else\n {\n \/*start code not found*\/\n\n if(u4_first_start_code_found == 0)\n {\n \/*no start codes found in current process call*\/\n\n                ps_dec->i4_error_code = ERROR_START_CODE_NOT_FOUND;\n                ps_dec_op->u4_error_code |= 1 << IVD_INSUFFICIENTDATA;\n\n if(ps_dec->u4_pic_buf_got == 0)\n {\n\n                    ih264d_fill_output_struct_from_context(ps_dec,\n                                                           ps_dec_op);\n\n                    ps_dec_op->u4_error_code = ps_dec->i4_error_code;\n                    ps_dec_op->u4_frame_decoded_flag = 0;\n\n return (IV_FAIL);\n }\n else\n {\n                    ps_dec->u1_pic_decode_done = 1;\n continue;\n }\n }\n else\n {\n \/* a start code has already been found earlier in the same process call*\/\n                frame_data_left = 0;\n                header_data_left = 0;\n continue;\n }\n\n }\n\n        ps_dec->u4_return_to_app = 0;\n        ret = ih264d_parse_nal_unit(dec_hdl, ps_dec_op,\n                              pu1_bitstrm_buf, buflen);\n if(ret != OK)\n {\n            UWORD32 error =  ih264d_map_error(ret);\n            ps_dec_op->u4_error_code = error | ret;\n            api_ret_value = IV_FAIL;\n\n if((ret == IVD_RES_CHANGED)\n || (ret == IVD_MEM_ALLOC_FAILED)\n || (ret == ERROR_UNAVAIL_PICBUF_T)\n || (ret == ERROR_UNAVAIL_MVBUF_T)\n || (ret == ERROR_INV_SPS_PPS_T)\n || (ret == IVD_DISP_FRM_ZERO_OP_BUF_SIZE))\n {\n                ps_dec->u4_slice_start_code_found = 0;\n break;\n }\n\n if((ret == ERROR_INCOMPLETE_FRAME) || (ret == ERROR_DANGLING_FIELD_IN_PIC))\n {\n                ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;\n                api_ret_value = IV_FAIL;\n break;\n }\n\n if(ret == ERROR_IN_LAST_SLICE_OF_PIC)\n {\n                api_ret_value = IV_FAIL;\n break;\n }\n\n }\n\n if(ps_dec->u4_return_to_app)\n {\n \/*We have encountered a referenced frame,return to app*\/\n            ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;\n            ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED;\n            ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n            ps_dec_op->u4_frame_decoded_flag = 0;\n            ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t);\n \/*signal the decode thread*\/\n            ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n                ih264d_signal_bs_deblk_thread(ps_dec);\n }\n return (IV_FAIL);\n\n }\n\n\n\n        header_data_left = ((ps_dec->i4_decode_header == 1)\n && (ps_dec->i4_header_decoded != 3)\n && (ps_dec_op->u4_num_bytes_consumed\n < ps_dec_ip->u4_num_Bytes));\n        frame_data_left = (((ps_dec->i4_decode_header == 0)\n && ((ps_dec->u1_pic_decode_done == 0)\n || (u4_next_is_aud == 1)))\n && (ps_dec_op->u4_num_bytes_consumed\n < ps_dec_ip->u4_num_Bytes));\n }\n while(( header_data_left == 1)||(frame_data_left == 1));\n\n if((ps_dec->u4_pic_buf_got == 1)\n && (ret != IVD_MEM_ALLOC_FAILED)\n && ps_dec->u2_total_mbs_coded < ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)\n {\n        WORD32 num_mb_skipped;\n        WORD32 prev_slice_err;\n pocstruct_t temp_poc;\n        WORD32 ret1;\n        WORD32 ht_in_mbs;\n        ht_in_mbs = ps_dec->u2_pic_ht >> (4 + ps_dec->ps_cur_slice->u1_field_pic_flag);\n        num_mb_skipped = (ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)\n - ps_dec->u2_total_mbs_coded;\n\n if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0))\n            prev_slice_err = 1;\n else\n            prev_slice_err = 2;\n\n if(ps_dec->u4_first_slice_in_pic && (ps_dec->u2_total_mbs_coded == 0))\n            prev_slice_err = 1;\n\n        ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num,\n &temp_poc, prev_slice_err);\n\n if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T) ||\n (ret1 == ERROR_INV_SPS_PPS_T))\n {\n            ret = ret1;\n }\n }\n\n if((ret == IVD_RES_CHANGED)\n || (ret == IVD_MEM_ALLOC_FAILED)\n || (ret == ERROR_UNAVAIL_PICBUF_T)\n || (ret == ERROR_UNAVAIL_MVBUF_T)\n || (ret == ERROR_INV_SPS_PPS_T))\n {\n\n \/* signal the decode thread *\/\n        ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet *\/\n if(ps_dec->u4_num_cores == 3)\n {\n            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n \/* dont consume bitstream for change in resolution case *\/\n if(ret == IVD_RES_CHANGED)\n {\n            ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;\n }\n return IV_FAIL;\n }\n\n\n if(ps_dec->u1_separate_parse)\n {\n \/* If Format conversion is not complete,\n         complete it here *\/\n if(ps_dec->u4_num_cores == 2)\n {\n\n \/*do deblocking of all mbs*\/\n if((ps_dec->u4_nmb_deblk == 0) &&(ps_dec->u4_start_recon_deblk == 1) && (ps_dec->ps_cur_sps->u1_mb_aff_flag == 0))\n {\n                UWORD32 u4_num_mbs,u4_max_addr;\n tfr_ctxt_t s_tfr_ctxt;\n tfr_ctxt_t *ps_tfr_cxt = &s_tfr_ctxt;\n pad_mgr_t *ps_pad_mgr = &ps_dec->s_pad_mgr;\n\n \/*BS is done for all mbs while parsing*\/\n                u4_max_addr = (ps_dec->u2_frm_wd_in_mbs * ps_dec->u2_frm_ht_in_mbs) - 1;\n                ps_dec->u4_cur_bs_mb_num = u4_max_addr + 1;\n\n\n                ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt,\n                                           ps_dec->u2_frm_wd_in_mbs, 0);\n\n\n                u4_num_mbs = u4_max_addr\n - ps_dec->u4_cur_deblk_mb_num + 1;\n\n                DEBUG_PERF_PRINTF(\"mbs left for deblocking= %d \\n\",u4_num_mbs);\n\n if(u4_num_mbs != 0)\n                    ih264d_check_mb_map_deblk(ps_dec, u4_num_mbs,\n                                                   ps_tfr_cxt,1);\n\n                ps_dec->u4_start_recon_deblk  = 0;\n\n }\n\n }\n\n \/*signal the decode thread*\/\n        ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n }\n\n\n    DATA_SYNC();\n\n\n if((ps_dec_op->u4_error_code & 0xff)\n != ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED)\n {\n        ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width;\n        ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height;\n }\n\n if(ps_dec->i4_header_decoded != 3)\n {\n        ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA);\n\n }\n\n if(ps_dec->i4_decode_header == 1 && ps_dec->i4_header_decoded != 3)\n {\n        ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA);\n\n }\n if(ps_dec->u4_prev_nal_skipped)\n {\n \/*We have encountered a referenced frame,return to app*\/\n        ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED;\n        ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n        ps_dec_op->u4_frame_decoded_flag = 0;\n        ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n return (IV_FAIL);\n\n }\n\n if((ps_dec->u4_pic_buf_got == 1)\n && (ERROR_DANGLING_FIELD_IN_PIC != i4_err_status))\n {\n \/*\n         * For field pictures, set the bottom and top picture decoded u4_flag correctly.\n         *\/\n\n if(ps_dec->ps_cur_slice->u1_field_pic_flag)\n {\n if(1 == ps_dec->ps_cur_slice->u1_bottom_field_flag)\n {\n                ps_dec->u1_top_bottom_decoded |= BOT_FIELD_ONLY;\n }\n else\n {\n                ps_dec->u1_top_bottom_decoded |= TOP_FIELD_ONLY;\n }\n }\n else\n {\n                ps_dec->u1_top_bottom_decoded = TOP_FIELD_ONLY | BOT_FIELD_ONLY;\n }\n\n \/* if new frame in not found (if we are still getting slices from previous frame)\n         * ih264d_deblock_display is not called. Such frames will not be added to reference \/display\n         *\/\n if ((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0)\n {\n \/* Calling Function to deblock Picture and Display *\/\n            ret = ih264d_deblock_display(ps_dec);\n }\n\n\n \/*set to complete ,as we dont support partial frame decode*\/\n if(ps_dec->i4_header_decoded == 3)\n {\n            ps_dec->u2_total_mbs_coded = ps_dec->ps_cur_sps->u2_max_mb_addr + 1;\n }\n\n \/*Update the i4_frametype at the end of picture*\/\n if(ps_dec->ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL)\n {\n            ps_dec->i4_frametype = IV_IDR_FRAME;\n }\n else if(ps_dec->i4_pic_type == B_SLICE)\n {\n            ps_dec->i4_frametype = IV_B_FRAME;\n }\n else if(ps_dec->i4_pic_type == P_SLICE)\n {\n            ps_dec->i4_frametype = IV_P_FRAME;\n }\n else if(ps_dec->i4_pic_type == I_SLICE)\n {\n            ps_dec->i4_frametype = IV_I_FRAME;\n }\n else\n {\n            H264_DEC_DEBUG_PRINT(\"Shouldn't come here\\n\");\n }\n\n        ps_dec->i4_content_type = ps_dec->ps_cur_slice->u1_field_pic_flag;\n\n        ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + 2;\n        ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded\n - ps_dec->ps_cur_slice->u1_field_pic_flag;\n\n }\n\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n        ih264d_signal_bs_deblk_thread(ps_dec);\n }\n\n\n {\n \/* In case the decoder is configured to run in low delay mode,\n         * then get display buffer and then format convert.\n         * Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles\n         *\/\n\n if((IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode)\n && ps_dec->u1_init_dec_flag)\n {\n\n            ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer,\n &(ps_dec->s_disp_op));\n if(0 == ps_dec->s_disp_op.u4_error_code)\n {\n                ps_dec->u4_fmt_conv_cur_row = 0;\n                ps_dec->u4_output_present = 1;\n }\n }\n\n        ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op);\n\n \/* If Format conversion is not complete,\n         complete it here *\/\n if(ps_dec->u4_output_present &&\n (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht))\n {\n            ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht\n - ps_dec->u4_fmt_conv_cur_row;\n            ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op),\n                                  ps_dec->u4_fmt_conv_cur_row,\n                                  ps_dec->u4_fmt_conv_num_rows);\n            ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;\n }\n\n        ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op));\n }\n\n if(ps_dec->i4_decode_header == 1 && (ps_dec->i4_header_decoded & 1) == 1)\n {\n        ps_dec_op->u4_progressive_frame_flag = 1;\n if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))\n {\n if((0 == ps_dec->ps_sps->u1_frame_mbs_only_flag)\n && (0 == ps_dec->ps_sps->u1_mb_aff_flag))\n                ps_dec_op->u4_progressive_frame_flag = 0;\n\n }\n }\n\n if((TOP_FIELD_ONLY | BOT_FIELD_ONLY) == ps_dec->u1_top_bottom_decoded)\n {\n        ps_dec->u1_top_bottom_decoded = 0;\n }\n \/*--------------------------------------------------------------------*\/\n \/* Do End of Pic processing.                                          *\/\n \/* Should be called only if frame was decoded in previous process call*\/\n \/*--------------------------------------------------------------------*\/\n if(ps_dec->u4_pic_buf_got == 1)\n {\n if(1 == ps_dec->u1_last_pic_not_decoded)\n {\n            ret = ih264d_end_of_pic_dispbuf_mgr(ps_dec);\n\n if(ret != OK)\n return ret;\n\n            ret = ih264d_end_of_pic(ps_dec);\n if(ret != OK)\n return ret;\n }\n else\n {\n            ret = ih264d_end_of_pic(ps_dec);\n if(ret != OK)\n return ret;\n }\n\n }\n\n\n \/*Data memory barrier instruction,so that yuv write by the library is complete*\/\n    DATA_SYNC();\n\n    H264_DEC_DEBUG_PRINT(\"The num bytes consumed: %d\\n\",\n                         ps_dec_op->u4_num_bytes_consumed);\n return api_ret_value;\n}\n","target":0,"code_token_length":6683,"total_token_length":6919,"max_tokens_setting":8192}
+{"idx":256512,"func":"WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand,\n  const char *option,const char *arg1n,const char *arg2n)\n{\n  const char    \/* percent escaped versions of the args *\/\n    *arg1,\n    *arg2;\n\n  Image\n    *new_images;\n\n  MagickStatusType\n    status;\n\n  ssize_t\n    parse;\n\n#define _image_info     (cli_wand->wand.image_info)\n#define _images         (cli_wand->wand.images)\n#define _exception      (cli_wand->wand.exception)\n#define _draw_info      (cli_wand->draw_info)\n#define _quantize_info  (cli_wand->quantize_info)\n#define _process_flags  (cli_wand->process_flags)\n#define _option_type    ((CommandOptionFlags) cli_wand->command->flags)\n#define IfNormalOp      (*option=='-')\n#define IfPlusOp        (*option!='-')\n#define IsNormalOp      IfNormalOp ? MagickTrue : MagickFalse\n\n  assert(cli_wand != (MagickCLI *) NULL);\n  assert(cli_wand->signature == MagickWandSignature);\n  assert(cli_wand->wand.signature == MagickWandSignature);\n  assert(_images != (Image *) NULL);             \/* _images must be present *\/\n\n  if (cli_wand->wand.debug != MagickFalse)\n    (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),\n       \"- List Operator: %s \\\"%s\\\" \\\"%s\\\"\", option,\n       arg1n == (const char *) NULL ? \"null\" : arg1n,\n       arg2n == (const char *) NULL ? \"null\" : arg2n);\n\n  arg1 = arg1n;\n  arg2 = arg2n;\n\n  \/* Interpret Percent Escapes in Arguments - using first image *\/\n  if ( (((_process_flags & ProcessInterpretProperities) != 0 )\n        || ((_option_type & AlwaysInterpretArgsFlag) != 0)\n       )  && ((_option_type & NeverInterpretArgsFlag) == 0) ) {\n    \/* Interpret Percent escapes in argument 1 *\/\n    if (arg1n != (char *) NULL) {\n      arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);\n      if (arg1 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg1=arg1n;  \/* use the given argument as is *\/\n      }\n    }\n    if (arg2n != (char *) NULL) {\n      arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n      if (arg2 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg2=arg2n;  \/* use the given argument as is *\/\n      }\n    }\n  }\n#undef _process_flags\n#undef _option_type\n\n  status=MagickTrue;\n  new_images=NewImageList();\n\n  switch (*(option+1))\n  {\n    case 'a':\n    {\n      if (LocaleCompare(\"append\",option+1) == 0)\n        {\n          new_images=AppendImages(_images,IsNormalOp,_exception);\n          break;\n        }\n      if (LocaleCompare(\"average\",option+1) == 0)\n        {\n          CLIWandWarnReplaced(\"-evaluate-sequence Mean\");\n          (void) CLIListOperatorImages(cli_wand,\"-evaluate-sequence\",\"Mean\",\n            NULL);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'c':\n    {\n      if (LocaleCompare(\"channel-fx\",option+1) == 0)\n        {\n          new_images=ChannelFxImage(_images,arg1,_exception);\n          break;\n        }\n      if (LocaleCompare(\"clut\",option+1) == 0)\n        {\n          Image\n            *clut_image;\n\n          \/* FUTURE - make this a compose option, and thus can be used\n             with layers compose or even compose last image over all other\n              _images.\n           *\/\n           new_images=RemoveFirstImageFromList(&_images);\n          clut_image=RemoveLastImageFromList(&_images);\n           \/* FUTURE - produce Exception, rather than silent fail *\/\n           if (clut_image == (Image *) NULL)\n            break;\n           (void) ClutImage(new_images,clut_image,new_images->interpolate,\n             _exception);\n           clut_image=DestroyImage(clut_image);\n          break;\n        }\n      if (LocaleCompare(\"coalesce\",option+1) == 0)\n        {\n          new_images=CoalesceImages(_images,_exception);\n          break;\n        }\n      if (LocaleCompare(\"combine\",option+1) == 0)\n        {\n          parse=(ssize_t) _images->colorspace;\n          if (_images->number_channels < GetImageListLength(_images))\n            parse=sRGBColorspace;\n          if ( IfPlusOp )\n            parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedColorspace\",option,\n              arg1);\n          new_images=CombineImages(_images,(ColorspaceType) parse,_exception);\n          break;\n        }\n      if (LocaleCompare(\"compare\",option+1) == 0)\n        {\n          double\n            distortion;\n\n          Image\n            *image,\n            *reconstruct_image;\n\n          MetricType\n            metric;\n\n          \/*\n            Mathematically and visually annotate the difference between an\n            image and its reconstruction.\n          *\/\n          image=RemoveFirstImageFromList(&_images);\n           reconstruct_image=RemoveFirstImageFromList(&_images);\n           \/* FUTURE - produce Exception, rather than silent fail *\/\n           if (reconstruct_image == (Image *) NULL)\n            { \n               image=DestroyImage(image);\n               break;\n             }\n           metric=UndefinedErrorMetric;\n          option=GetImageOption(_image_info,\"metric\");\n          if (option != (const char *) NULL)\n            metric=(MetricType) ParseCommandOption(MagickMetricOptions,\n              MagickFalse,option);\n          new_images=CompareImages(image,reconstruct_image,metric,&distortion,\n            _exception);\n          (void) distortion;\n          reconstruct_image=DestroyImage(reconstruct_image);\n          image=DestroyImage(image);\n          break;\n        }\n      if (LocaleCompare(\"complex\",option+1) == 0)\n        {\n          parse=ParseCommandOption(MagickComplexOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedEvaluateOperator\",\n              option,arg1);\n          new_images=ComplexImages(_images,(ComplexOperator) parse,_exception);\n          break;\n        }\n      if (LocaleCompare(\"composite\",option+1) == 0)\n        {\n          CompositeOperator\n            compose;\n\n          const char*\n            value;\n\n          MagickBooleanType\n            clip_to_self;\n\n          Image\n            *mask_image,\n            *source_image;\n\n          RectangleInfo\n            geometry;\n\n          \/* Compose value from \"-compose\" option only *\/\n          value=GetImageOption(_image_info,\"compose\");\n          if (value == (const char *) NULL)\n            compose=OverCompositeOp;  \/* use Over not source_image->compose *\/\n          else\n            compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,\n              MagickFalse,value);\n\n          \/* Get \"clip-to-self\" expert setting (false is normal) *\/\n          clip_to_self=GetCompositeClipToSelf(compose);\n          value=GetImageOption(_image_info,\"compose:clip-to-self\");\n          if (value != (const char *) NULL)\n            clip_to_self=IsStringTrue(value);\n          value=GetImageOption(_image_info,\"compose:outside-overlay\");\n          if (value != (const char *) NULL)\n            clip_to_self=IsStringFalse(value);  \/* deprecated *\/\n\n           new_images=RemoveFirstImageFromList(&_images);\n           source_image=RemoveFirstImageFromList(&_images);\n           if (source_image == (Image *) NULL)\n            break; \/* FUTURE - produce Exception, rather than silent fail *\/\n \n           \/* FUTURE - this should not be here! - should be part of -geometry *\/\n           if (source_image->geometry != (char *) NULL)\n            {\n              RectangleInfo\n                resize_geometry;\n\n              (void) ParseRegionGeometry(source_image,source_image->geometry,\n                &resize_geometry,_exception);\n              if ((source_image->columns != resize_geometry.width) ||\n                  (source_image->rows != resize_geometry.height))\n                {\n                  Image\n                    *resize_image;\n\n                  resize_image=ResizeImage(source_image,resize_geometry.width,\n                    resize_geometry.height,source_image->filter,_exception);\n                  if (resize_image != (Image *) NULL)\n                    {\n                      source_image=DestroyImage(source_image);\n                      source_image=resize_image;\n                    }\n                }\n            }\n          SetGeometry(source_image,&geometry);\n          (void) ParseAbsoluteGeometry(source_image->geometry,&geometry);\n          GravityAdjustGeometry(new_images->columns,new_images->rows,\n            new_images->gravity, &geometry);\n          mask_image=RemoveFirstImageFromList(&_images);\n          if (mask_image == (Image *) NULL)\n            status&=CompositeImage(new_images,source_image,compose,clip_to_self,\n              geometry.x,geometry.y,_exception);\n          else\n            {\n              if ((compose == DisplaceCompositeOp) ||\n                  (compose == DistortCompositeOp))\n                {\n                  status&=CompositeImage(source_image,mask_image,\n                    CopyGreenCompositeOp,MagickTrue,0,0,_exception);\n                  status&=CompositeImage(new_images,source_image,compose,\n                    clip_to_self,geometry.x,geometry.y,_exception);\n                }\n              else\n                {\n                  Image\n                    *clone_image;\n\n                  clone_image=CloneImage(new_images,0,0,MagickTrue,_exception);\n                  if (clone_image == (Image *) NULL)\n                    break;\n                  status&=CompositeImage(new_images,source_image,compose,\n                    clip_to_self,geometry.x,geometry.y,_exception);\n                  status&=CompositeImage(new_images,mask_image,\n                    CopyAlphaCompositeOp,MagickTrue,0,0,_exception);\n                  status&=CompositeImage(clone_image,new_images,OverCompositeOp,\n                    clip_to_self,0,0,_exception);\n                  new_images=DestroyImageList(new_images);\n                  new_images=clone_image;\n                }\n              mask_image=DestroyImage(mask_image);\n            }\n          source_image=DestroyImage(source_image);\n          break;\n        }\n        if (LocaleCompare(\"copy\",option+1) == 0)\n          {\n            Image\n              *source_image;\n\n            OffsetInfo\n              offset;\n\n            RectangleInfo\n              geometry;\n\n            \/*\n              Copy image pixels.\n            *\/\n            if (IsGeometry(arg1) == MagickFalse)\n              CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n            if (IsGeometry(arg2) == MagickFalse)\n              CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n            (void) ParsePageGeometry(_images,arg2,&geometry,_exception);\n            offset.x=geometry.x;\n            offset.y=geometry.y;\n            source_image=_images;\n            if (source_image->next != (Image *) NULL)\n              source_image=source_image->next;\n            (void) ParsePageGeometry(source_image,arg1,&geometry,_exception);\n            (void) CopyImagePixels(_images,source_image,&geometry,&offset,\n              _exception);\n            break;\n          }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'd':\n    {\n      if (LocaleCompare(\"deconstruct\",option+1) == 0)\n        {\n          CLIWandWarnReplaced(\"-layer CompareAny\");\n          (void) CLIListOperatorImages(cli_wand,\"-layer\",\"CompareAny\",NULL);\n          break;\n        }\n      if (LocaleCompare(\"delete\",option+1) == 0)\n        {\n          if (IfNormalOp)\n            DeleteImages(&_images,arg1,_exception);\n          else\n            DeleteImages(&_images,\"-1\",_exception);\n          break;\n        }\n      if (LocaleCompare(\"duplicate\",option+1) == 0)\n        {\n          if (IfNormalOp)\n            {\n              const char\n                *p;\n\n              size_t\n                number_duplicates;\n\n              if (IsGeometry(arg1) == MagickFalse)\n                CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,\n                      arg1);\n              number_duplicates=(size_t) StringToLong(arg1);\n              p=strchr(arg1,',');\n              if (p == (const char *) NULL)\n                new_images=DuplicateImages(_images,number_duplicates,\"-1\",\n                  _exception);\n              else\n                new_images=DuplicateImages(_images,number_duplicates,p,\n                  _exception);\n            }\n          else\n            new_images=DuplicateImages(_images,1,\"-1\",_exception);\n          AppendImageToList(&_images, new_images);\n          new_images=(Image *) NULL;\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'e':\n    {\n      if (LocaleCompare(\"evaluate-sequence\",option+1) == 0)\n        {\n          parse=ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedEvaluateOperator\",\n              option,arg1);\n          new_images=EvaluateImages(_images,(MagickEvaluateOperator) parse,\n            _exception);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'f':\n    {\n      if (LocaleCompare(\"fft\",option+1) == 0)\n        {\n          new_images=ForwardFourierTransformImage(_images,IsNormalOp,\n           _exception);\n          break;\n        }\n      if (LocaleCompare(\"flatten\",option+1) == 0)\n        {\n          \/* REDIRECTED to use -layers flatten instead *\/\n          (void) CLIListOperatorImages(cli_wand,\"-layers\",option+1,NULL);\n          break;\n        }\n      if (LocaleCompare(\"fx\",option+1) == 0)\n        {\n          new_images=FxImage(_images,arg1,_exception);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'h':\n    {\n      if (LocaleCompare(\"hald-clut\",option+1) == 0)\n        {\n          \/* FUTURE - make this a compose option (and thus layers compose )\n             or perhaps compose last image over all other _images.\n          *\/\n          Image\n            *hald_image;\n\n           new_images=RemoveFirstImageFromList(&_images);\n           hald_image=RemoveLastImageFromList(&_images);\n           if (hald_image == (Image *) NULL)\n            break;\n           (void) HaldClutImage(new_images,hald_image,_exception);\n           hald_image=DestroyImage(hald_image);\n           break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'i':\n    {\n      if (LocaleCompare(\"ift\",option+1) == 0)\n        {\n          Image\n             *magnitude_image,\n             *phase_image;\n \n           magnitude_image=RemoveFirstImageFromList(&_images);\n           phase_image=RemoveFirstImageFromList(&_images);\n          \/* FUTURE - produce Exception, rather than silent fail *\/\n           if (phase_image == (Image *) NULL)\n             break;\n           new_images=InverseFourierTransformImage(magnitude_image,phase_image,\n             IsNormalOp,_exception);\n           magnitude_image=DestroyImage(magnitude_image);\n           phase_image=DestroyImage(phase_image);\n           break;\n         }\n       if (LocaleCompare(\"insert\",option+1) == 0)\n        {\n          Image\n            *insert_image,\n            *index_image;\n\n          ssize_t\n            index;\n\n          if (IfNormalOp && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          index=0;\n          insert_image=RemoveLastImageFromList(&_images);\n          if (IfNormalOp)\n            index=(ssize_t) StringToLong(arg1);\n          index_image=insert_image;\n          if (index == 0)\n            PrependImageToList(&_images,insert_image);\n          else if (index == (ssize_t) GetImageListLength(_images))\n            AppendImageToList(&_images,insert_image);\n          else\n            {\n               index_image=GetImageFromList(_images,index-1);\n               if (index_image == (Image *) NULL)\n                 {\n                   insert_image=DestroyImage(insert_image);\n                   CLIWandExceptArgBreak(OptionError,\"NoSuchImage\",option,arg1);\n                 }\n              InsertImageInList(&index_image,insert_image);\n            }\n          _images=GetFirstImageInList(index_image);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'l':\n    {\n      if (LocaleCompare(\"layers\",option+1) == 0)\n        {\n          parse=ParseCommandOption(MagickLayerOptions,MagickFalse,arg1);\n          if ( parse < 0 )\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedLayerMethod\",\n                 option,arg1);\n          switch ((LayerMethod) parse)\n          {\n            case CoalesceLayer:\n            {\n              new_images=CoalesceImages(_images,_exception);\n              break;\n            }\n            case CompareAnyLayer:\n            case CompareClearLayer:\n            case CompareOverlayLayer:\n            default:\n            {\n              new_images=CompareImagesLayers(_images,(LayerMethod) parse,\n                   _exception);\n              break;\n            }\n            case MergeLayer:\n            case FlattenLayer:\n            case MosaicLayer:\n            case TrimBoundsLayer:\n            {\n              new_images=MergeImageLayers(_images,(LayerMethod) parse,\n                _exception);\n              break;\n            }\n            case DisposeLayer:\n            {\n              new_images=DisposeImages(_images,_exception);\n              break;\n            }\n            case OptimizeImageLayer:\n            {\n              new_images=OptimizeImageLayers(_images,_exception);\n              break;\n            }\n            case OptimizePlusLayer:\n            {\n              new_images=OptimizePlusImageLayers(_images,_exception);\n              break;\n            }\n            case OptimizeTransLayer:\n            {\n              OptimizeImageTransparency(_images,_exception);\n              break;\n            }\n            case RemoveDupsLayer:\n            {\n              RemoveDuplicateLayers(&_images,_exception);\n              break;\n            }\n            case RemoveZeroLayer:\n            {\n              RemoveZeroDelayLayers(&_images,_exception);\n              break;\n            }\n            case OptimizeLayer:\n            { \/* General Purpose, GIF Animation Optimizer.  *\/\n              new_images=CoalesceImages(_images,_exception);\n              if (new_images == (Image *) NULL)\n                break;\n              _images=DestroyImageList(_images);\n              _images=OptimizeImageLayers(new_images,_exception);\n              if (_images == (Image *) NULL)\n                break;\n              new_images=DestroyImageList(new_images);\n              OptimizeImageTransparency(_images,_exception);\n              (void) RemapImages(_quantize_info,_images,(Image *) NULL,\n                _exception);\n              break;\n            }\n            case CompositeLayer:\n            {\n              Image\n                *source;\n\n              RectangleInfo\n                geometry;\n\n              CompositeOperator\n                compose;\n\n              const char*\n                value;\n\n              value=GetImageOption(_image_info,\"compose\");\n              compose=OverCompositeOp;  \/* Default to Over *\/\n              if (value != (const char *) NULL)\n                compose=(CompositeOperator) ParseCommandOption(\n                      MagickComposeOptions,MagickFalse,value);\n\n              \/* Split image sequence at the first 'NULL:' image. *\/\n              source=_images;\n              while (source != (Image *) NULL)\n              {\n                source=GetNextImageInList(source);\n                if ((source != (Image *) NULL) &&\n                    (LocaleCompare(source->magick,\"NULL\") == 0))\n                  break;\n              }\n              if (source != (Image *) NULL)\n                {\n                  if ((GetPreviousImageInList(source) == (Image *) NULL) ||\n                      (GetNextImageInList(source) == (Image *) NULL))\n                    source=(Image *) NULL;\n                  else\n                    { \/* Separate the two lists, junk the null: image.  *\/\n                      source=SplitImageList(source->previous);\n                      DeleteImageFromList(&source);\n                    }\n                }\n              if (source == (Image *) NULL)\n                {\n                  (void) ThrowMagickException(_exception,GetMagickModule(),\n                    OptionError,\"MissingNullSeparator\",\"layers Composite\");\n                  break;\n                }\n              \/* Adjust offset with gravity and virtual canvas.  *\/\n              SetGeometry(_images,&geometry);\n              (void) ParseAbsoluteGeometry(_images->geometry,&geometry);\n              geometry.width=source->page.width != 0 ?\n                source->page.width : source->columns;\n              geometry.height=source->page.height != 0 ?\n               source->page.height : source->rows;\n              GravityAdjustGeometry(_images->page.width != 0 ?\n                _images->page.width : _images->columns,\n                _images->page.height != 0 ? _images->page.height :\n                _images->rows,_images->gravity,&geometry);\n\n              \/* Compose the two image sequences together *\/\n              CompositeLayers(_images,compose,source,geometry.x,geometry.y,\n                _exception);\n              source=DestroyImageList(source);\n              break;\n            }\n          }\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'm':\n    {\n      if (LocaleCompare(\"map\",option+1) == 0)\n        {\n          CLIWandWarnReplaced(\"+remap\");\n          (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);\n          break;\n        }\n      if (LocaleCompare(\"metric\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"morph\",option+1) == 0)\n        {\n          Image\n            *morph_image;\n\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          morph_image=MorphImages(_images,StringToUnsignedLong(arg1),\n            _exception);\n          if (morph_image == (Image *) NULL)\n            break;\n          _images=DestroyImageList(_images);\n          _images=morph_image;\n          break;\n        }\n      if (LocaleCompare(\"mosaic\",option+1) == 0)\n        {\n          \/* REDIRECTED to use -layers mosaic instead *\/\n          (void) CLIListOperatorImages(cli_wand,\"-layers\",option+1,NULL);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'p':\n    {\n      if (LocaleCompare(\"poly\",option+1) == 0)\n        {\n          double\n            *args;\n\n          ssize_t\n            count;\n\n          \/* convert argument string into an array of doubles *\/\n          args = StringToArrayOfDoubles(arg1,&count,_exception);\n          if (args == (double *) NULL )\n            CLIWandExceptArgBreak(OptionError,\"InvalidNumberList\",option,arg1);\n          new_images=PolynomialImage(_images,(size_t) (count >> 1),args,\n           _exception);\n          args=(double *) RelinquishMagickMemory(args);\n          break;\n        }\n      if (LocaleCompare(\"process\",option+1) == 0)\n        {\n          \/* FUTURE: better parsing using ScriptToken() from string ??? *\/\n          char\n            **arguments;\n\n          int\n            j,\n            number_arguments;\n\n          arguments=StringToArgv(arg1,&number_arguments);\n          if (arguments == (char **) NULL)\n            break;\n          if (strchr(arguments[1],'=') != (char *) NULL)\n            {\n              char\n                breaker,\n                quote,\n                *token;\n\n              const char\n                *arguments;\n\n              int\n                next,\n                status;\n\n              size_t\n                length;\n\n              TokenInfo\n                *token_info;\n\n              \/*\n                Support old style syntax, filter=\"-option arg1\".\n              *\/\n              assert(arg1 != (const char *) NULL);\n              length=strlen(arg1);\n              token=(char *) NULL;\n              if (~length >= (MagickPathExtent-1))\n                token=(char *) AcquireQuantumMemory(length+MagickPathExtent,\n                  sizeof(*token));\n              if (token == (char *) NULL)\n                break;\n              next=0;\n              arguments=arg1;\n              token_info=AcquireTokenInfo();\n              status=Tokenizer(token_info,0,token,length,arguments,\"\",\"=\",\n                \"\\\"\",'\\0',&breaker,&next,"e);\n              token_info=DestroyTokenInfo(token_info);\n              if (status == 0)\n                {\n                  const char\n                    *argv;\n\n                  argv=(&(arguments[next]));\n                  (void) InvokeDynamicImageFilter(token,&_images,1,&argv,\n                    _exception);\n                }\n              token=DestroyString(token);\n              break;\n            }\n          (void) SubstituteString(&arguments[1],\"-\",\"\");\n          (void) InvokeDynamicImageFilter(arguments[1],&_images,\n            number_arguments-2,(const char **) arguments+2,_exception);\n          for (j=0; j < number_arguments; j++)\n            arguments[j]=DestroyString(arguments[j]);\n          arguments=(char **) RelinquishMagickMemory(arguments);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'r':\n    {\n      if (LocaleCompare(\"remap\",option+1) == 0)\n        {\n          (void) RemapImages(_quantize_info,_images,(Image *) NULL,_exception);\n          break;\n        }\n      if (LocaleCompare(\"reverse\",option+1) == 0)\n        {\n          ReverseImageList(&_images);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 's':\n    {\n      if (LocaleCompare(\"smush\",option+1) == 0)\n        {\n          \/* FUTURE: this option needs more work to make better *\/\n          ssize_t\n            offset;\n\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          offset=(ssize_t) StringToLong(arg1);\n          new_images=SmushImages(_images,IsNormalOp,offset,_exception);\n          break;\n        }\n      if (LocaleCompare(\"subimage\",option+1) == 0)\n        {\n          Image\n            *base_image,\n            *compare_image;\n\n          const char\n            *value;\n\n          MetricType\n            metric;\n\n          double\n            similarity;\n\n          RectangleInfo\n            offset;\n\n          base_image=GetImageFromList(_images,0);\n          compare_image=GetImageFromList(_images,1);\n\n          \/* Comparision Metric *\/\n          metric=UndefinedErrorMetric;\n          value=GetImageOption(_image_info,\"metric\");\n          if (value != (const char *) NULL)\n            metric=(MetricType) ParseCommandOption(MagickMetricOptions,\n              MagickFalse,value);\n\n          new_images=SimilarityImage(base_image,compare_image,metric,0.0,\n            &offset,&similarity,_exception);\n\n          if (new_images != (Image *) NULL)\n            {\n              char\n                result[MagickPathExtent];\n\n              (void) FormatLocaleString(result,MagickPathExtent,\"%lf\",\n                similarity);\n              (void) SetImageProperty(new_images,\"subimage:similarity\",result,\n                _exception);\n              (void) FormatLocaleString(result,MagickPathExtent,\"%+ld\",(long)\n                offset.x);\n              (void) SetImageProperty(new_images,\"subimage:x\",result,\n                _exception);\n              (void) FormatLocaleString(result,MagickPathExtent,\"%+ld\",(long)\n                offset.y);\n              (void) SetImageProperty(new_images,\"subimage:y\",result,\n                _exception);\n              (void) FormatLocaleString(result,MagickPathExtent,\n                \"%lux%lu%+ld%+ld\",(unsigned long) offset.width,(unsigned long)\n                offset.height,(long) offset.x,(long) offset.y);\n              (void) SetImageProperty(new_images,\"subimage:offset\",result,\n                _exception);\n            }\n          break;\n        }\n      if (LocaleCompare(\"swap\",option+1) == 0)\n        {\n        Image\n          *p,\n          *q,\n          *swap;\n\n        ssize_t\n          index,\n          swap_index;\n\n        index=(-1);\n        swap_index=(-2);\n        if (IfNormalOp) {\n          GeometryInfo\n            geometry_info;\n\n          MagickStatusType\n            flags;\n\n          swap_index=(-1);\n          flags=ParseGeometry(arg1,&geometry_info);\n          if ((flags & RhoValue) == 0)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          index=(ssize_t) geometry_info.rho;\n          if ((flags & SigmaValue) != 0)\n            swap_index=(ssize_t) geometry_info.sigma;\n        }\n        p=GetImageFromList(_images,index);\n        q=GetImageFromList(_images,swap_index);\n        if ((p == (Image *) NULL) || (q == (Image *) NULL)) {\n          if (IfNormalOp)\n            CLIWandExceptArgBreak(OptionError,\"InvalidImageIndex\",option,arg1)\n          else\n            CLIWandExceptionBreak(OptionError,\"TwoOrMoreImagesRequired\",option);\n        }\n        if (p == q)\n          CLIWandExceptArgBreak(OptionError,\"InvalidImageIndex\",option,arg1);\n        swap=CloneImage(p,0,0,MagickTrue,_exception);\n        if (swap == (Image *) NULL)\n          CLIWandExceptArgBreak(ResourceLimitError,\"MemoryAllocationFailed\",\n            option,GetExceptionMessage(errno));\n        ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,_exception));\n        ReplaceImageInList(&q,swap);\n        _images=GetFirstImageInList(q);\n        break;\n      }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    default:\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n  }\n\n  \/* clean up percent escape interpreted strings *\/\n  if (arg1 != arg1n )\n    arg1=DestroyString((char *)arg1);\n  if (arg2 != arg2n )\n    arg2=DestroyString((char *)arg2);\n\n  \/* if new image list generated, replace existing image list *\/\n  if (new_images == (Image *) NULL)\n    return(status == 0 ? MagickFalse : MagickTrue);\n  _images=DestroyImageList(_images);\n  _images=GetFirstImageInList(new_images);\n  return(status == 0 ? MagickFalse : MagickTrue);\n\n#undef _image_info\n#undef _images\n#undef _exception\n#undef _draw_info\n#undef _quantize_info\n#undef IfNormalOp\n#undef IfPlusOp\n#undef IsNormalOp\n}\n","target":1,"code_token_length":6694,"total_token_length":6930,"max_tokens_setting":8192}
+{"idx":354002,"func":"gst_matroska_demux_parse_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml,\n    GstMatroskaTrackContext ** dest_context)\n{\n  GstMatroskaTrackContext *context;\n  GstCaps *caps = NULL;\n  GstTagList *cached_taglist;\n  GstFlowReturn ret;\n  guint32 id, riff_fourcc = 0;\n  guint16 riff_audio_fmt = 0;\n  gchar *codec = NULL;\n\n  DEBUG_ELEMENT_START (demux, ebml, \"TrackEntry\");\n\n  \/* start with the master *\/\n  if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) {\n    DEBUG_ELEMENT_STOP (demux, ebml, \"TrackEntry\", ret);\n    return ret;\n  }\n\n  \/* allocate generic... if we know the type, we'll g_renew()\n   * with the precise type *\/\n  context = g_new0 (GstMatroskaTrackContext, 1);\n  context->index_writer_id = -1;\n  context->type = 0;            \/* no type yet *\/\n  context->default_duration = 0;\n  context->pos = 0;\n  context->set_discont = TRUE;\n  context->timecodescale = 1.0;\n  context->flags =\n      GST_MATROSKA_TRACK_ENABLED | GST_MATROSKA_TRACK_DEFAULT |\n      GST_MATROSKA_TRACK_LACING;\n  context->from_time = GST_CLOCK_TIME_NONE;\n  context->from_offset = -1;\n  context->to_offset = G_MAXINT64;\n  context->alignment = 1;\n  context->dts_only = FALSE;\n  context->intra_only = FALSE;\n  context->tags = gst_tag_list_new_empty ();\n  g_queue_init (&context->protection_event_queue);\n  context->protection_info = NULL;\n\n  GST_DEBUG_OBJECT (demux, \"Parsing a TrackEntry (%d tracks parsed so far)\",\n      demux->common.num_streams);\n\n  \/* try reading the trackentry headers *\/\n  while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) {\n    if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)\n      break;\n\n    switch (id) {\n        \/* track number (unique stream ID) *\/\n      case GST_MATROSKA_ID_TRACKNUMBER:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num == 0) {\n          GST_ERROR_OBJECT (demux, \"Invalid TrackNumber 0\");\n          ret = GST_FLOW_ERROR;\n          break;\n        }\n\n        GST_DEBUG_OBJECT (demux, \"TrackNumber: %\" G_GUINT64_FORMAT, num);\n        context->num = num;\n        break;\n      }\n        \/* track UID (unique identifier) *\/\n      case GST_MATROSKA_ID_TRACKUID:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num == 0) {\n          GST_ERROR_OBJECT (demux, \"Invalid TrackUID 0\");\n          ret = GST_FLOW_ERROR;\n          break;\n        }\n\n        GST_DEBUG_OBJECT (demux, \"TrackUID: %\" G_GUINT64_FORMAT, num);\n        context->uid = num;\n        break;\n      }\n\n        \/* track type (video, audio, combined, subtitle, etc.) *\/\n      case GST_MATROSKA_ID_TRACKTYPE:{\n        guint64 track_type;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &track_type)) != GST_FLOW_OK) {\n          break;\n        }\n\n        if (context->type != 0 && context->type != track_type) {\n          GST_WARNING_OBJECT (demux,\n              \"More than one tracktype defined in a TrackEntry - skipping\");\n          break;\n        } else if (track_type < 1 || track_type > 254) {\n          GST_WARNING_OBJECT (demux, \"Invalid TrackType %\" G_GUINT64_FORMAT,\n              track_type);\n          break;\n        }\n\n        GST_DEBUG_OBJECT (demux, \"TrackType: %\" G_GUINT64_FORMAT, track_type);\n\n        \/* ok, so we're actually going to reallocate this thing *\/\n        switch (track_type) {\n          case GST_MATROSKA_TRACK_TYPE_VIDEO:\n            gst_matroska_track_init_video_context (&context);\n            break;\n          case GST_MATROSKA_TRACK_TYPE_AUDIO:\n            gst_matroska_track_init_audio_context (&context);\n            break;\n          case GST_MATROSKA_TRACK_TYPE_SUBTITLE:\n            gst_matroska_track_init_subtitle_context (&context);\n            break;\n          case GST_MATROSKA_TRACK_TYPE_COMPLEX:\n          case GST_MATROSKA_TRACK_TYPE_LOGO:\n          case GST_MATROSKA_TRACK_TYPE_BUTTONS:\n          case GST_MATROSKA_TRACK_TYPE_CONTROL:\n          default:\n            GST_WARNING_OBJECT (demux,\n                \"Unknown or unsupported TrackType %\" G_GUINT64_FORMAT,\n                track_type);\n            context->type = 0;\n            break;\n        }\n        break;\n      }\n\n        \/* tracktype specific stuff for video *\/\n      case GST_MATROSKA_ID_TRACKVIDEO:{\n        GstMatroskaTrackVideoContext *videocontext;\n\n        DEBUG_ELEMENT_START (demux, ebml, \"TrackVideo\");\n\n        if (!gst_matroska_track_init_video_context (&context)) {\n          GST_WARNING_OBJECT (demux,\n              \"TrackVideo element in non-video track - ignoring track\");\n          ret = GST_FLOW_ERROR;\n          break;\n        } else if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) {\n          break;\n        }\n        videocontext = (GstMatroskaTrackVideoContext *) context;\n\n        while (ret == GST_FLOW_OK &&\n            gst_ebml_read_has_remaining (ebml, 1, TRUE)) {\n          if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)\n            break;\n\n          switch (id) {\n              \/* Should be one level up but some broken muxers write it here. *\/\n            case GST_MATROSKA_ID_TRACKDEFAULTDURATION:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackDefaultDuration 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackDefaultDuration: %\" G_GUINT64_FORMAT, num);\n              context->default_duration = num;\n              break;\n            }\n\n              \/* video framerate *\/\n              \/* NOTE: This one is here only for backward compatibility.\n               * Use _TRACKDEFAULDURATION one level up. *\/\n            case GST_MATROSKA_ID_VIDEOFRAMERATE:{\n              gdouble num;\n\n              if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num <= 0.0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackVideoFPS %lf\", num);\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux, \"TrackVideoFrameRate: %lf\", num);\n              if (context->default_duration == 0)\n                context->default_duration =\n                    gst_gdouble_to_guint64 ((gdouble) GST_SECOND * (1.0 \/ num));\n              videocontext->default_fps = num;\n              break;\n            }\n\n              \/* width of the size to display the video at *\/\n            case GST_MATROSKA_ID_VIDEODISPLAYWIDTH:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackVideoDisplayWidth 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackVideoDisplayWidth: %\" G_GUINT64_FORMAT, num);\n              videocontext->display_width = num;\n              break;\n            }\n\n              \/* height of the size to display the video at *\/\n            case GST_MATROSKA_ID_VIDEODISPLAYHEIGHT:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackVideoDisplayHeight 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackVideoDisplayHeight: %\" G_GUINT64_FORMAT, num);\n              videocontext->display_height = num;\n              break;\n            }\n\n              \/* width of the video in the file *\/\n            case GST_MATROSKA_ID_VIDEOPIXELWIDTH:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackVideoPixelWidth 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackVideoPixelWidth: %\" G_GUINT64_FORMAT, num);\n              videocontext->pixel_width = num;\n              break;\n            }\n\n              \/* height of the video in the file *\/\n            case GST_MATROSKA_ID_VIDEOPIXELHEIGHT:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackVideoPixelHeight 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackVideoPixelHeight: %\" G_GUINT64_FORMAT, num);\n              videocontext->pixel_height = num;\n              break;\n            }\n\n              \/* whether the video is interlaced *\/\n            case GST_MATROSKA_ID_VIDEOFLAGINTERLACED:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 1)\n                videocontext->interlace_mode =\n                    GST_MATROSKA_INTERLACE_MODE_INTERLACED;\n              else if (num == 2)\n                videocontext->interlace_mode =\n                    GST_MATROSKA_INTERLACE_MODE_PROGRESSIVE;\n              else\n                videocontext->interlace_mode =\n                    GST_MATROSKA_INTERLACE_MODE_UNKNOWN;\n\n              GST_DEBUG_OBJECT (demux, \"video track interlacing mode: %d\",\n                  videocontext->interlace_mode);\n              break;\n            }\n\n              \/* interlaced field order *\/\n            case GST_MATROSKA_ID_VIDEOFIELDORDER:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (videocontext->interlace_mode !=\n                  GST_MATROSKA_INTERLACE_MODE_INTERLACED) {\n                GST_WARNING_OBJECT (demux,\n                    \"FieldOrder element when not interlaced - ignoring\");\n                break;\n              }\n\n              if (num == 0)\n                \/* turns out we're actually progressive *\/\n                videocontext->interlace_mode =\n                    GST_MATROSKA_INTERLACE_MODE_PROGRESSIVE;\n              else if (num == 2)\n                videocontext->field_order = GST_VIDEO_FIELD_ORDER_UNKNOWN;\n              else if (num == 9)\n                videocontext->field_order =\n                    GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST;\n              else if (num == 14)\n                videocontext->field_order =\n                    GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST;\n              else {\n                GST_FIXME_OBJECT (demux,\n                    \"Unknown or unsupported FieldOrder %\" G_GUINT64_FORMAT,\n                    num);\n                videocontext->field_order = GST_VIDEO_FIELD_ORDER_UNKNOWN;\n              }\n\n              GST_DEBUG_OBJECT (demux, \"video track field order: %d\",\n                  videocontext->field_order);\n              break;\n            }\n\n              \/* aspect ratio behaviour *\/\n            case GST_MATROSKA_ID_VIDEOASPECTRATIOTYPE:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num != GST_MATROSKA_ASPECT_RATIO_MODE_FREE &&\n                  num != GST_MATROSKA_ASPECT_RATIO_MODE_KEEP &&\n                  num != GST_MATROSKA_ASPECT_RATIO_MODE_FIXED) {\n                GST_WARNING_OBJECT (demux,\n                    \"Unknown TrackVideoAspectRatioType 0x%x\", (guint) num);\n                break;\n              }\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackVideoAspectRatioType: %\" G_GUINT64_FORMAT, num);\n              videocontext->asr_mode = num;\n              break;\n            }\n\n              \/* colourspace (only matters for raw video) fourcc *\/\n            case GST_MATROSKA_ID_VIDEOCOLOURSPACE:{\n              guint8 *data;\n              guint64 datalen;\n\n              if ((ret =\n                      gst_ebml_read_binary (ebml, &id, &data,\n                          &datalen)) != GST_FLOW_OK)\n                break;\n\n              if (datalen != 4) {\n                g_free (data);\n                GST_WARNING_OBJECT (demux,\n                    \"Invalid TrackVideoColourSpace length %\" G_GUINT64_FORMAT,\n                    datalen);\n                break;\n              }\n\n              memcpy (&videocontext->fourcc, data, 4);\n              GST_DEBUG_OBJECT (demux,\n                  \"TrackVideoColourSpace: %\" GST_FOURCC_FORMAT,\n                  GST_FOURCC_ARGS (videocontext->fourcc));\n              g_free (data);\n              break;\n            }\n\n              \/* color info *\/\n            case GST_MATROSKA_ID_VIDEOCOLOUR:{\n              ret = gst_matroska_demux_parse_colour (demux, ebml, videocontext);\n              break;\n            }\n\n            case GST_MATROSKA_ID_VIDEOSTEREOMODE:\n            {\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              GST_DEBUG_OBJECT (demux, \"StereoMode: %\" G_GUINT64_FORMAT, num);\n\n              switch (num) {\n                case GST_MATROSKA_STEREO_MODE_SBS_RL:\n                  videocontext->multiview_flags =\n                      GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST;\n                  \/* fall through *\/\n                case GST_MATROSKA_STEREO_MODE_SBS_LR:\n                  videocontext->multiview_mode =\n                      GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE;\n                  break;\n                case GST_MATROSKA_STEREO_MODE_TB_RL:\n                  videocontext->multiview_flags =\n                      GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST;\n                  \/* fall through *\/\n                case GST_MATROSKA_STEREO_MODE_TB_LR:\n                  videocontext->multiview_mode =\n                      GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM;\n                  break;\n                case GST_MATROSKA_STEREO_MODE_CHECKER_RL:\n                  videocontext->multiview_flags =\n                      GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST;\n                  \/* fall through *\/\n                case GST_MATROSKA_STEREO_MODE_CHECKER_LR:\n                  videocontext->multiview_mode =\n                      GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD;\n                  break;\n                case GST_MATROSKA_STEREO_MODE_FBF_RL:\n                  videocontext->multiview_flags =\n                      GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST;\n                  \/* fall through *\/\n                case GST_MATROSKA_STEREO_MODE_FBF_LR:\n                  videocontext->multiview_mode =\n                      GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME;\n                  \/* FIXME: In frame-by-frame mode, left\/right frame buffers are\n                   * laced within one block, and we'll need to apply FIRST_IN_BUNDLE\n                   * accordingly. See http:\/\/www.matroska.org\/technical\/specs\/index.html#StereoMode *\/\n                  GST_FIXME_OBJECT (demux,\n                      \"Frame-by-frame stereoscopic mode not fully implemented\");\n                  break;\n              }\n              break;\n            }\n\n            default:\n              GST_WARNING_OBJECT (demux,\n                  \"Unknown TrackVideo subelement 0x%x - ignoring\", id);\n              \/* fall through *\/\n            case GST_MATROSKA_ID_VIDEODISPLAYUNIT:\n            case GST_MATROSKA_ID_VIDEOPIXELCROPBOTTOM:\n            case GST_MATROSKA_ID_VIDEOPIXELCROPTOP:\n            case GST_MATROSKA_ID_VIDEOPIXELCROPLEFT:\n            case GST_MATROSKA_ID_VIDEOPIXELCROPRIGHT:\n            case GST_MATROSKA_ID_VIDEOGAMMAVALUE:\n              ret = gst_ebml_read_skip (ebml);\n              break;\n          }\n        }\n\n        DEBUG_ELEMENT_STOP (demux, ebml, \"TrackVideo\", ret);\n        break;\n      }\n\n        \/* tracktype specific stuff for audio *\/\n      case GST_MATROSKA_ID_TRACKAUDIO:{\n        GstMatroskaTrackAudioContext *audiocontext;\n\n        DEBUG_ELEMENT_START (demux, ebml, \"TrackAudio\");\n\n        if (!gst_matroska_track_init_audio_context (&context)) {\n          GST_WARNING_OBJECT (demux,\n              \"TrackAudio element in non-audio track - ignoring track\");\n          ret = GST_FLOW_ERROR;\n          break;\n        }\n\n        if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK)\n          break;\n\n        audiocontext = (GstMatroskaTrackAudioContext *) context;\n\n        while (ret == GST_FLOW_OK &&\n            gst_ebml_read_has_remaining (ebml, 1, TRUE)) {\n          if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)\n            break;\n\n          switch (id) {\n              \/* samplerate *\/\n            case GST_MATROSKA_ID_AUDIOSAMPLINGFREQ:{\n              gdouble num;\n\n              if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n\n              if (num <= 0.0) {\n                GST_WARNING_OBJECT (demux,\n                    \"Invalid TrackAudioSamplingFrequency %lf\", num);\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux, \"TrackAudioSamplingFrequency: %lf\", num);\n              audiocontext->samplerate = num;\n              break;\n            }\n\n              \/* bitdepth *\/\n            case GST_MATROSKA_ID_AUDIOBITDEPTH:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackAudioBitDepth 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux, \"TrackAudioBitDepth: %\" G_GUINT64_FORMAT,\n                  num);\n              audiocontext->bitdepth = num;\n              break;\n            }\n\n              \/* channels *\/\n            case GST_MATROSKA_ID_AUDIOCHANNELS:{\n              guint64 num;\n\n              if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n                break;\n\n              if (num == 0) {\n                GST_WARNING_OBJECT (demux, \"Invalid TrackAudioChannels 0\");\n                break;\n              }\n\n              GST_DEBUG_OBJECT (demux, \"TrackAudioChannels: %\" G_GUINT64_FORMAT,\n                  num);\n              audiocontext->channels = num;\n              break;\n            }\n\n            default:\n              GST_WARNING_OBJECT (demux,\n                  \"Unknown TrackAudio subelement 0x%x - ignoring\", id);\n              \/* fall through *\/\n            case GST_MATROSKA_ID_AUDIOCHANNELPOSITIONS:\n            case GST_MATROSKA_ID_AUDIOOUTPUTSAMPLINGFREQ:\n              ret = gst_ebml_read_skip (ebml);\n              break;\n          }\n        }\n\n        DEBUG_ELEMENT_STOP (demux, ebml, \"TrackAudio\", ret);\n\n        break;\n      }\n\n        \/* codec identifier *\/\n      case GST_MATROSKA_ID_CODECID:{\n        gchar *text;\n\n        if ((ret = gst_ebml_read_ascii (ebml, &id, &text)) != GST_FLOW_OK)\n          break;\n\n        GST_DEBUG_OBJECT (demux, \"CodecID: %s\", GST_STR_NULL (text));\n        context->codec_id = text;\n        break;\n      }\n\n        \/* codec private data *\/\n      case GST_MATROSKA_ID_CODECPRIVATE:{\n        guint8 *data;\n        guint64 size;\n\n        if ((ret =\n                gst_ebml_read_binary (ebml, &id, &data, &size)) != GST_FLOW_OK)\n          break;\n\n        context->codec_priv = data;\n        context->codec_priv_size = size;\n\n        GST_DEBUG_OBJECT (demux, \"CodecPrivate of size %\" G_GUINT64_FORMAT,\n            size);\n        break;\n      }\n\n        \/* name of the codec *\/\n      case GST_MATROSKA_ID_CODECNAME:{\n        gchar *text;\n\n        if ((ret = gst_ebml_read_utf8 (ebml, &id, &text)) != GST_FLOW_OK)\n          break;\n\n        GST_DEBUG_OBJECT (demux, \"CodecName: %s\", GST_STR_NULL (text));\n        context->codec_name = text;\n        break;\n      }\n\n        \/* codec delay *\/\n      case GST_MATROSKA_ID_CODECDELAY:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        context->codec_delay = num;\n\n        GST_DEBUG_OBJECT (demux, \"CodecDelay: %\" GST_TIME_FORMAT,\n            GST_TIME_ARGS (num));\n        break;\n      }\n\n        \/* codec delay *\/\n      case GST_MATROSKA_ID_SEEKPREROLL:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        context->seek_preroll = num;\n\n        GST_DEBUG_OBJECT (demux, \"SeekPreroll: %\" GST_TIME_FORMAT,\n            GST_TIME_ARGS (num));\n        break;\n      }\n\n        \/* name of this track *\/\n      case GST_MATROSKA_ID_TRACKNAME:{\n        gchar *text;\n\n        if ((ret = gst_ebml_read_utf8 (ebml, &id, &text)) != GST_FLOW_OK)\n          break;\n\n        context->name = text;\n        GST_DEBUG_OBJECT (demux, \"TrackName: %s\", GST_STR_NULL (text));\n        break;\n      }\n\n        \/* language (matters for audio\/subtitles, mostly) *\/\n      case GST_MATROSKA_ID_TRACKLANGUAGE:{\n        gchar *text;\n\n        if ((ret = gst_ebml_read_utf8 (ebml, &id, &text)) != GST_FLOW_OK)\n          break;\n\n\n        context->language = text;\n\n        \/* fre-ca => fre *\/\n        if (strlen (context->language) >= 4 && context->language[3] == '-')\n          context->language[3] = '\\0';\n\n        GST_DEBUG_OBJECT (demux, \"TrackLanguage: %s\",\n            GST_STR_NULL (context->language));\n        break;\n      }\n\n        \/* whether this is actually used *\/\n      case GST_MATROSKA_ID_TRACKFLAGENABLED:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num)\n          context->flags |= GST_MATROSKA_TRACK_ENABLED;\n        else\n          context->flags &= ~GST_MATROSKA_TRACK_ENABLED;\n\n        GST_DEBUG_OBJECT (demux, \"TrackEnabled: %d\",\n            (context->flags & GST_MATROSKA_TRACK_ENABLED) ? 1 : 0);\n        break;\n      }\n\n        \/* whether it's the default for this track type *\/\n      case GST_MATROSKA_ID_TRACKFLAGDEFAULT:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num)\n          context->flags |= GST_MATROSKA_TRACK_DEFAULT;\n        else\n          context->flags &= ~GST_MATROSKA_TRACK_DEFAULT;\n\n        GST_DEBUG_OBJECT (demux, \"TrackDefault: %d\",\n            (context->flags & GST_MATROSKA_TRACK_DEFAULT) ? 1 : 0);\n        break;\n      }\n\n        \/* whether the track must be used during playback *\/\n      case GST_MATROSKA_ID_TRACKFLAGFORCED:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num)\n          context->flags |= GST_MATROSKA_TRACK_FORCED;\n        else\n          context->flags &= ~GST_MATROSKA_TRACK_FORCED;\n\n        GST_DEBUG_OBJECT (demux, \"TrackForced: %d\",\n            (context->flags & GST_MATROSKA_TRACK_FORCED) ? 1 : 0);\n        break;\n      }\n\n        \/* lacing (like MPEG, where blocks don't end\/start on frame\n         * boundaries) *\/\n      case GST_MATROSKA_ID_TRACKFLAGLACING:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num)\n          context->flags |= GST_MATROSKA_TRACK_LACING;\n        else\n          context->flags &= ~GST_MATROSKA_TRACK_LACING;\n\n        GST_DEBUG_OBJECT (demux, \"TrackLacing: %d\",\n            (context->flags & GST_MATROSKA_TRACK_LACING) ? 1 : 0);\n        break;\n      }\n\n        \/* default length (in time) of one data block in this track *\/\n      case GST_MATROSKA_ID_TRACKDEFAULTDURATION:{\n        guint64 num;\n\n        if ((ret = gst_ebml_read_uint (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n\n        if (num == 0) {\n          GST_WARNING_OBJECT (demux, \"Invalid TrackDefaultDuration 0\");\n          break;\n        }\n\n        GST_DEBUG_OBJECT (demux, \"TrackDefaultDuration: %\" G_GUINT64_FORMAT,\n            num);\n        context->default_duration = num;\n        break;\n      }\n\n      case GST_MATROSKA_ID_CONTENTENCODINGS:{\n        ret = gst_matroska_read_common_read_track_encodings (&demux->common,\n            ebml, context);\n        break;\n      }\n\n      case GST_MATROSKA_ID_TRACKTIMECODESCALE:{\n        gdouble num;\n\n        if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK)\n          break;\n\n        if (num <= 0.0) {\n          GST_WARNING_OBJECT (demux, \"Invalid TrackTimeCodeScale %lf\", num);\n          break;\n        }\n\n        GST_DEBUG_OBJECT (demux, \"TrackTimeCodeScale: %lf\", num);\n        context->timecodescale = num;\n        break;\n      }\n\n      default:\n        GST_WARNING (\"Unknown TrackEntry subelement 0x%x - ignoring\", id);\n        \/* pass-through *\/\n\n        \/* we ignore these because they're nothing useful (i.e. crap)\n         * or simply not implemented yet. *\/\n      case GST_MATROSKA_ID_TRACKMINCACHE:\n      case GST_MATROSKA_ID_TRACKMAXCACHE:\n      case GST_MATROSKA_ID_MAXBLOCKADDITIONID:\n      case GST_MATROSKA_ID_TRACKATTACHMENTLINK:\n      case GST_MATROSKA_ID_TRACKOVERLAY:\n      case GST_MATROSKA_ID_TRACKTRANSLATE:\n      case GST_MATROSKA_ID_TRACKOFFSET:\n      case GST_MATROSKA_ID_CODECSETTINGS:\n      case GST_MATROSKA_ID_CODECINFOURL:\n      case GST_MATROSKA_ID_CODECDOWNLOADURL:\n      case GST_MATROSKA_ID_CODECDECODEALL:\n        ret = gst_ebml_read_skip (ebml);\n        break;\n    }\n  }\n\n  DEBUG_ELEMENT_STOP (demux, ebml, \"TrackEntry\", ret);\n\n  \/* Decode codec private data if necessary *\/\n  if (context->encodings && context->encodings->len > 0 && context->codec_priv\n      && context->codec_priv_size > 0) {\n    if (!gst_matroska_decode_data (context->encodings,\n            &context->codec_priv, &context->codec_priv_size,\n            GST_MATROSKA_TRACK_ENCODING_SCOPE_CODEC_DATA, TRUE)) {\n      GST_WARNING_OBJECT (demux, \"Decoding codec private data failed\");\n      ret = GST_FLOW_ERROR;\n    }\n  }\n\n  if (context->type == 0 || context->codec_id == NULL || (ret != GST_FLOW_OK\n          && ret != GST_FLOW_EOS)) {\n    if (ret == GST_FLOW_OK || ret == GST_FLOW_EOS)\n      GST_WARNING_OBJECT (ebml, \"Unknown stream\/codec in track entry header\");\n\n    gst_matroska_track_free (context);\n    context = NULL;\n    *dest_context = NULL;\n    return ret;\n  }\n\n  \/* check for a cached track taglist  *\/\n  cached_taglist =\n      (GstTagList *) g_hash_table_lookup (demux->common.cached_track_taglists,\n      GUINT_TO_POINTER (context->uid));\n  if (cached_taglist)\n    gst_tag_list_insert (context->tags, cached_taglist, GST_TAG_MERGE_APPEND);\n\n  \/* compute caps *\/\n  switch (context->type) {\n    case GST_MATROSKA_TRACK_TYPE_VIDEO:{\n      GstMatroskaTrackVideoContext *videocontext =\n          (GstMatroskaTrackVideoContext *) context;\n\n      caps = gst_matroska_demux_video_caps (videocontext,\n          context->codec_id, context->codec_priv,\n          context->codec_priv_size, &codec, &riff_fourcc);\n\n      if (codec) {\n        gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,\n            GST_TAG_VIDEO_CODEC, codec, NULL);\n        context->tags_changed = TRUE;\n        g_free (codec);\n      }\n      break;\n    }\n\n    case GST_MATROSKA_TRACK_TYPE_AUDIO:{\n      GstClockTime lead_in_ts = 0;\n      GstMatroskaTrackAudioContext *audiocontext =\n          (GstMatroskaTrackAudioContext *) context;\n\n      caps = gst_matroska_demux_audio_caps (audiocontext,\n          context->codec_id, context->codec_priv, context->codec_priv_size,\n          &codec, &riff_audio_fmt, &lead_in_ts);\n      if (lead_in_ts > demux->audio_lead_in_ts) {\n        demux->audio_lead_in_ts = lead_in_ts;\n        GST_DEBUG_OBJECT (demux, \"Increased audio lead-in to %\" GST_TIME_FORMAT,\n            GST_TIME_ARGS (lead_in_ts));\n      }\n\n      if (codec) {\n        gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,\n            GST_TAG_AUDIO_CODEC, codec, NULL);\n        context->tags_changed = TRUE;\n        g_free (codec);\n      }\n      break;\n    }\n\n    case GST_MATROSKA_TRACK_TYPE_SUBTITLE:{\n      GstMatroskaTrackSubtitleContext *subtitlecontext =\n          (GstMatroskaTrackSubtitleContext *) context;\n\n      caps = gst_matroska_demux_subtitle_caps (subtitlecontext,\n          context->codec_id, context->codec_priv, context->codec_priv_size);\n      break;\n    }\n\n    case GST_MATROSKA_TRACK_TYPE_COMPLEX:\n    case GST_MATROSKA_TRACK_TYPE_LOGO:\n    case GST_MATROSKA_TRACK_TYPE_BUTTONS:\n    case GST_MATROSKA_TRACK_TYPE_CONTROL:\n    default:\n      \/* we should already have quit by now *\/\n      g_assert_not_reached ();\n  }\n\n  if ((context->language == NULL || *context->language == '\\0') &&\n      (context->type == GST_MATROSKA_TRACK_TYPE_AUDIO ||\n          context->type == GST_MATROSKA_TRACK_TYPE_SUBTITLE)) {\n    GST_LOG (\"stream %d: language=eng (assuming default)\", context->index);\n    context->language = g_strdup (\"eng\");\n  }\n\n  if (context->language) {\n    const gchar *lang;\n\n    \/* Matroska contains ISO 639-2B codes, we want ISO 639-1 *\/\n    lang = gst_tag_get_language_code (context->language);\n    gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,\n        GST_TAG_LANGUAGE_CODE, (lang) ? lang : context->language, NULL);\n\n    if (context->name) {\n      gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,\n          GST_TAG_TITLE, context->name, NULL);\n    }\n    context->tags_changed = TRUE;\n  }\n\n  if (caps == NULL) {\n    GST_WARNING_OBJECT (demux, \"could not determine caps for stream with \"\n        \"codec_id='%s'\", context->codec_id);\n    switch (context->type) {\n      case GST_MATROSKA_TRACK_TYPE_VIDEO:\n        caps = gst_caps_new_empty_simple (\"video\/x-unknown\");\n        break;\n      case GST_MATROSKA_TRACK_TYPE_AUDIO:\n        caps = gst_caps_new_empty_simple (\"audio\/x-unknown\");\n        break;\n      case GST_MATROSKA_TRACK_TYPE_SUBTITLE:\n        caps = gst_caps_new_empty_simple (\"application\/x-subtitle-unknown\");\n        break;\n      case GST_MATROSKA_TRACK_TYPE_COMPLEX:\n      default:\n        caps = gst_caps_new_empty_simple (\"application\/x-matroska-unknown\");\n        break;\n    }\n    gst_caps_set_simple (caps, \"codec-id\", G_TYPE_STRING, context->codec_id,\n        NULL);\n\n    \/* add any unrecognised riff fourcc \/ audio format, but after codec-id *\/\n    if (context->type == GST_MATROSKA_TRACK_TYPE_AUDIO && riff_audio_fmt != 0)\n      gst_caps_set_simple (caps, \"format\", G_TYPE_INT, riff_audio_fmt, NULL);\n    else if (context->type == GST_MATROSKA_TRACK_TYPE_VIDEO && riff_fourcc != 0) {\n      gchar *fstr = g_strdup_printf (\"%\" GST_FOURCC_FORMAT,\n          GST_FOURCC_ARGS (riff_fourcc));\n      gst_caps_set_simple (caps, \"fourcc\", G_TYPE_STRING, fstr, NULL);\n      g_free (fstr);\n    }\n  } else if (context->stream_headers != NULL) {\n    gst_matroska_demux_add_stream_headers_to_caps (demux,\n        context->stream_headers, caps);\n  }\n\n  if (context->encodings) {\n    GstMatroskaTrackEncoding *enc;\n    guint i;\n\n    for (i = 0; i < context->encodings->len; i++) {\n      enc = &g_array_index (context->encodings, GstMatroskaTrackEncoding, i);\n      if (enc->type == GST_MATROSKA_ENCODING_ENCRYPTION \/* encryption *\/ ) {\n        GstStructure *s = gst_caps_get_structure (caps, 0);\n        if (!gst_structure_has_name (s, \"application\/x-webm-enc\")) {\n          gst_structure_set (s, \"original-media-type\", G_TYPE_STRING,\n              gst_structure_get_name (s), NULL);\n          gst_structure_set (s, \"encryption-algorithm\", G_TYPE_STRING,\n              gst_matroska_track_encryption_algorithm_name (enc->enc_algo),\n              NULL);\n          gst_structure_set (s, \"encoding-scope\", G_TYPE_STRING,\n              gst_matroska_track_encoding_scope_name (enc->scope), NULL);\n          gst_structure_set (s, \"cipher-mode\", G_TYPE_STRING,\n              gst_matroska_track_encryption_cipher_mode_name\n              (enc->enc_cipher_mode), NULL);\n          gst_structure_set_name (s, \"application\/x-webm-enc\");\n        }\n      }\n    }\n  }\n\n  context->caps = caps;\n\n  \/* tadaah! *\/\n  *dest_context = context;\n  return ret;\n}","target":1,"code_token_length":7769,"total_token_length":8005,"max_tokens_setting":8192}
+{"idx":236101,"func":"WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)\n{\n \/* ! *\/\n\n dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);\n\n    WORD32 i4_err_status = 0;\n    UWORD8 *pu1_buf = NULL;\n    WORD32 buflen;\n    UWORD32 u4_max_ofst, u4_length_of_start_code = 0;\n\n    UWORD32 bytes_consumed = 0;\n    UWORD32 cur_slice_is_nonref = 0;\n    UWORD32 u4_next_is_aud;\n    UWORD32 u4_first_start_code_found = 0;\n    WORD32 ret = 0,api_ret_value = IV_SUCCESS;\n    WORD32 header_data_left = 0,frame_data_left = 0;\n    UWORD8 *pu1_bitstrm_buf;\n ivd_video_decode_ip_t *ps_dec_ip;\n ivd_video_decode_op_t *ps_dec_op;\n\n    ithread_set_name((void*)\"Parse_thread\");\n\n    ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip;\n    ps_dec_op = (ivd_video_decode_op_t *)pv_api_op;\n    ps_dec->pv_dec_out = ps_dec_op;\n if(ps_dec->init_done != 1)\n {\n return IV_FAIL;\n }\n\n \/*Data memory barries instruction,so that bitstream write by the application is complete*\/\n    DATA_SYNC();\n\n if(0 == ps_dec->u1_flushfrm)\n {\n if(ps_dec_ip->pv_stream_buffer == NULL)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL;\n return IV_FAIL;\n }\n if(ps_dec_ip->u4_num_Bytes <= 0)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV;\n return IV_FAIL;\n\n }\n }\n    ps_dec->u1_pic_decode_done = 0;\n\n    ps_dec_op->u4_num_bytes_consumed = 0;\n\n    ps_dec->ps_out_buffer = NULL;\n\n if(ps_dec_ip->u4_size\n >= offsetof(ivd_video_decode_ip_t, s_out_buffer))\n        ps_dec->ps_out_buffer = &ps_dec_ip->s_out_buffer;\n\n    ps_dec->u4_fmt_conv_cur_row = 0;\n\n    ps_dec->u4_output_present = 0;\n    ps_dec->s_disp_op.u4_error_code = 1;\n    ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS;\n if(0 == ps_dec->u4_share_disp_buf\n && ps_dec->i4_decode_header == 0)\n {\n        UWORD32 i;\n if(ps_dec->ps_out_buffer->u4_num_bufs == 0)\n {\n            ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n            ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS;\n return IV_FAIL;\n }\n\n for(i = 0; i < ps_dec->ps_out_buffer->u4_num_bufs; i++)\n {\n if(ps_dec->ps_out_buffer->pu1_bufs[i] == NULL)\n {\n                ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n                ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL;\n return IV_FAIL;\n }\n\n if(ps_dec->ps_out_buffer->u4_min_out_buf_size[i] == 0)\n {\n                ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;\n                ps_dec_op->u4_error_code |=\n                                IVD_DISP_FRM_ZERO_OP_BUF_SIZE;\n return IV_FAIL;\n }\n }\n }\n\n if(ps_dec->u4_total_frames_decoded >= NUM_FRAMES_LIMIT)\n {\n        ps_dec_op->u4_error_code = ERROR_FRAME_LIMIT_OVER;\n return IV_FAIL;\n }\n\n \/* ! *\/\n    ps_dec->u4_ts = ps_dec_ip->u4_ts;\n\n    ps_dec_op->u4_error_code = 0;\n    ps_dec_op->e_pic_type = -1;\n    ps_dec_op->u4_output_present = 0;\n    ps_dec_op->u4_frame_decoded_flag = 0;\n\n    ps_dec->i4_frametype = -1;\n    ps_dec->i4_content_type = -1;\n \/*\n     * For field pictures, set the bottom and top picture decoded u4_flag correctly.\n     *\/\n {\n if((TOP_FIELD_ONLY | BOT_FIELD_ONLY) == ps_dec->u1_top_bottom_decoded)\n {\n            ps_dec->u1_top_bottom_decoded = 0;\n }\n }\n    ps_dec->u4_slice_start_code_found = 0;\n\n \/* In case the deocder is not in flush mode(in shared mode),\n     then decoder has to pick up a buffer to write current frame.\n     Check if a frame is available in such cases *\/\n\n if(ps_dec->u1_init_dec_flag == 1 && ps_dec->u4_share_disp_buf == 1\n && ps_dec->u1_flushfrm == 0)\n {\n        UWORD32 i;\n\n        WORD32 disp_avail = 0, free_id;\n\n \/* Check if at least one buffer is available with the codec *\/\n \/* If not then return to application with error *\/\n for(i = 0; i < ps_dec->u1_pic_bufs; i++)\n {\n if(0 == ps_dec->u4_disp_buf_mapping[i]\n || 1 == ps_dec->u4_disp_buf_to_be_freed[i])\n {\n                disp_avail = 1;\n break;\n }\n\n }\n\n if(0 == disp_avail)\n {\n \/* If something is queued for display wait for that buffer to be returned *\/\n\n            ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;\n            ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n return (IV_FAIL);\n }\n\n while(1)\n {\n pic_buffer_t *ps_pic_buf;\n            ps_pic_buf = (pic_buffer_t *)ih264_buf_mgr_get_next_free(\n (buf_mgr_t *)ps_dec->pv_pic_buf_mgr, &free_id);\n\n if(ps_pic_buf == NULL)\n {\n                UWORD32 i, display_queued = 0;\n\n \/* check if any buffer was given for display which is not returned yet *\/\n for(i = 0; i < (MAX_DISP_BUFS_NEW); i++)\n {\n if(0 != ps_dec->u4_disp_buf_mapping[i])\n {\n                        display_queued = 1;\n break;\n }\n }\n \/* If some buffer is queued for display, then codec has to singal an error and wait\n                 for that buffer to be returned.\n                 If nothing is queued for display then codec has ownership of all display buffers\n                 and it can reuse any of the existing buffers and continue decoding *\/\n\n if(1 == display_queued)\n {\n \/* If something is queued for display wait for that buffer to be returned *\/\n                    ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;\n                    ps_dec_op->u4_error_code |= (1\n << IVD_UNSUPPORTEDPARAM);\n return (IV_FAIL);\n }\n }\n else\n {\n \/* If the buffer is with display, then mark it as in use and then look for a buffer again *\/\n if(1 == ps_dec->u4_disp_buf_mapping[free_id])\n {\n                    ih264_buf_mgr_set_status(\n (buf_mgr_t *)ps_dec->pv_pic_buf_mgr,\n                                    free_id,\n                                    BUF_MGR_IO);\n }\n else\n {\n \/**\n                     *  Found a free buffer for present call. Release it now.\n                     *  Will be again obtained later.\n                     *\/\n                    ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,\n                                          free_id,\n                                          BUF_MGR_IO);\n break;\n }\n }\n }\n\n }\n\n if(ps_dec->u1_flushfrm && ps_dec->u1_init_dec_flag)\n {\n\n        ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer,\n &(ps_dec->s_disp_op));\n if(0 == ps_dec->s_disp_op.u4_error_code)\n {\n            ps_dec->u4_fmt_conv_cur_row = 0;\n            ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht;\n            ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op),\n                                  ps_dec->u4_fmt_conv_cur_row,\n                                  ps_dec->u4_fmt_conv_num_rows);\n            ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;\n            ps_dec->u4_output_present = 1;\n\n }\n        ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op));\n\n        ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width;\n        ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height;\n\n        ps_dec_op->u4_new_seq = 0;\n\n        ps_dec_op->u4_output_present = ps_dec->u4_output_present;\n        ps_dec_op->u4_progressive_frame_flag =\n                        ps_dec->s_disp_op.u4_progressive_frame_flag;\n        ps_dec_op->e_output_format =\n                        ps_dec->s_disp_op.e_output_format;\n        ps_dec_op->s_disp_frm_buf = ps_dec->s_disp_op.s_disp_frm_buf;\n        ps_dec_op->e4_fld_type = ps_dec->s_disp_op.e4_fld_type;\n        ps_dec_op->u4_ts = ps_dec->s_disp_op.u4_ts;\n        ps_dec_op->u4_disp_buf_id = ps_dec->s_disp_op.u4_disp_buf_id;\n\n \/*In the case of flush ,since no frame is decoded set pic type as invalid*\/\n        ps_dec_op->u4_is_ref_flag = -1;\n        ps_dec_op->e_pic_type = IV_NA_FRAME;\n        ps_dec_op->u4_frame_decoded_flag = 0;\n\n if(0 == ps_dec->s_disp_op.u4_error_code)\n {\n return (IV_SUCCESS);\n }\n else\n return (IV_FAIL);\n\n }\n if(ps_dec->u1_res_changed == 1)\n {\n \/*if resolution has changed and all buffers have been flushed, reset decoder*\/\n        ih264d_init_decoder(ps_dec);\n }\n\n    ps_dec->u4_prev_nal_skipped = 0;\n\n    ps_dec->u2_cur_mb_addr = 0;\n    ps_dec->u2_total_mbs_coded = 0;\n    ps_dec->u2_cur_slice_num = 0;\n    ps_dec->cur_dec_mb_num = 0;\n    ps_dec->cur_recon_mb_num = 0;\n    ps_dec->u4_first_slice_in_pic = 2;\n    ps_dec->u1_slice_header_done = 0;\n    ps_dec->u1_dangling_field = 0;\n\n    ps_dec->u4_dec_thread_created = 0;\n    ps_dec->u4_bs_deblk_thread_created = 0;\n    ps_dec->u4_cur_bs_mb_num = 0;\n\n    DEBUG_THREADS_PRINTF(\" Starting process call\\n\");\n\n\n    ps_dec->u4_pic_buf_got = 0;\n\n do\n {\n        WORD32 buf_size;\n\n        pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer\n + ps_dec_op->u4_num_bytes_consumed;\n\n        u4_max_ofst = ps_dec_ip->u4_num_Bytes\n - ps_dec_op->u4_num_bytes_consumed;\n\n \/* If dynamic bitstream buffer is not allocated and\n         * header decode is done, then allocate dynamic bitstream buffer\n         *\/\n if((NULL == ps_dec->pu1_bits_buf_dynamic) &&\n (ps_dec->i4_header_decoded & 1))\n {\n            WORD32 size;\n\n void *pv_buf;\n void *pv_mem_ctxt = ps_dec->pv_mem_ctxt;\n            size = MAX(256000, ps_dec->u2_pic_wd * ps_dec->u2_pic_ht * 3 \/ 2);\n            pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);\n            RETURN_IF((NULL == pv_buf), IV_FAIL);\n            ps_dec->pu1_bits_buf_dynamic = pv_buf;\n            ps_dec->u4_dynamic_bits_buf_size = size;\n }\n\n if(ps_dec->pu1_bits_buf_dynamic)\n {\n            pu1_bitstrm_buf = ps_dec->pu1_bits_buf_dynamic;\n            buf_size = ps_dec->u4_dynamic_bits_buf_size;\n }\n else\n {\n            pu1_bitstrm_buf = ps_dec->pu1_bits_buf_static;\n            buf_size = ps_dec->u4_static_bits_buf_size;\n }\n\n        u4_next_is_aud = 0;\n\n        buflen = ih264d_find_start_code(pu1_buf, 0, u4_max_ofst,\n &u4_length_of_start_code,\n &u4_next_is_aud);\n\n if(buflen == -1)\n            buflen = 0;\n \/* Ignore bytes beyond the allocated size of intermediate buffer *\/\n        buflen = MIN(buflen, buf_size);\n\n        bytes_consumed = buflen + u4_length_of_start_code;\n        ps_dec_op->u4_num_bytes_consumed += bytes_consumed;\n\n {\n            UWORD8 u1_firstbyte, u1_nal_ref_idc;\n\n if(ps_dec->i4_app_skip_mode == IVD_SKIP_B)\n {\n                u1_firstbyte = *(pu1_buf + u4_length_of_start_code);\n                u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_firstbyte));\n if(u1_nal_ref_idc == 0)\n {\n \/*skip non reference frames*\/\n                    cur_slice_is_nonref = 1;\n continue;\n }\n else\n {\n if(1 == cur_slice_is_nonref)\n {\n \/*We have encountered a referenced frame,return to app*\/\n                        ps_dec_op->u4_num_bytes_consumed -=\n                                        bytes_consumed;\n                        ps_dec_op->e_pic_type = IV_B_FRAME;\n                        ps_dec_op->u4_error_code =\n                                        IVD_DEC_FRM_SKIPPED;\n                        ps_dec_op->u4_error_code |= (1\n << IVD_UNSUPPORTEDPARAM);\n                        ps_dec_op->u4_frame_decoded_flag = 0;\n                        ps_dec_op->u4_size =\n sizeof(ivd_video_decode_op_t);\n \/*signal the decode thread*\/\n                        ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n                            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n\n return (IV_FAIL);\n }\n }\n\n }\n\n }\n\n\n if(buflen)\n {\n            memcpy(pu1_bitstrm_buf, pu1_buf + u4_length_of_start_code,\n                   buflen);\n \/* Decoder may read extra 8 bytes near end of the frame *\/\n if((buflen + 8) < buf_size)\n {\n                memset(pu1_bitstrm_buf + buflen, 0, 8);\n }\n            u4_first_start_code_found = 1;\n\n }\n else\n {\n \/*start code not found*\/\n\n if(u4_first_start_code_found == 0)\n {\n \/*no start codes found in current process call*\/\n\n                ps_dec->i4_error_code = ERROR_START_CODE_NOT_FOUND;\n                ps_dec_op->u4_error_code |= 1 << IVD_INSUFFICIENTDATA;\n\n if(ps_dec->u4_pic_buf_got == 0)\n {\n\n                    ih264d_fill_output_struct_from_context(ps_dec,\n                                                           ps_dec_op);\n\n                    ps_dec_op->u4_error_code = ps_dec->i4_error_code;\n                    ps_dec_op->u4_frame_decoded_flag = 0;\n\n return (IV_FAIL);\n }\n else\n {\n                    ps_dec->u1_pic_decode_done = 1;\n continue;\n }\n }\n else\n {\n \/* a start code has already been found earlier in the same process call*\/\n                frame_data_left = 0;\n continue;\n }\n\n }\n\n        ps_dec->u4_return_to_app = 0;\n        ret = ih264d_parse_nal_unit(dec_hdl, ps_dec_op,\n                              pu1_bitstrm_buf, buflen);\n if(ret != OK)\n {\n            UWORD32 error =  ih264d_map_error(ret);\n            ps_dec_op->u4_error_code = error | ret;\n            api_ret_value = IV_FAIL;\n\n if((ret == IVD_RES_CHANGED)\n || (ret == IVD_MEM_ALLOC_FAILED)\n || (ret == ERROR_UNAVAIL_PICBUF_T)\n || (ret == ERROR_UNAVAIL_MVBUF_T))\n {\n break;\n }\n\n if((ret == ERROR_INCOMPLETE_FRAME) || (ret == ERROR_DANGLING_FIELD_IN_PIC))\n {\n                ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;\n                api_ret_value = IV_FAIL;\n break;\n }\n\n if(ret == ERROR_IN_LAST_SLICE_OF_PIC)\n {\n                api_ret_value = IV_FAIL;\n break;\n }\n\n }\n\n if(ps_dec->u4_return_to_app)\n {\n \/*We have encountered a referenced frame,return to app*\/\n            ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;\n            ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED;\n            ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n            ps_dec_op->u4_frame_decoded_flag = 0;\n            ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t);\n \/*signal the decode thread*\/\n            ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n                ih264d_signal_bs_deblk_thread(ps_dec);\n }\n return (IV_FAIL);\n\n }\n\n\n\n        header_data_left = ((ps_dec->i4_decode_header == 1)\n && (ps_dec->i4_header_decoded != 3)\n && (ps_dec_op->u4_num_bytes_consumed\n < ps_dec_ip->u4_num_Bytes));\n        frame_data_left = (((ps_dec->i4_decode_header == 0)\n && ((ps_dec->u1_pic_decode_done == 0)\n || (u4_next_is_aud == 1)))\n && (ps_dec_op->u4_num_bytes_consumed\n < ps_dec_ip->u4_num_Bytes));\n }\n while(( header_data_left == 1)||(frame_data_left == 1));\n\n if((ps_dec->u4_slice_start_code_found == 1)\n && (ret != IVD_MEM_ALLOC_FAILED)\n && ps_dec->u2_total_mbs_coded < ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)\n {\n        WORD32 num_mb_skipped;\n        WORD32 prev_slice_err;\n pocstruct_t temp_poc;\n        WORD32 ret1;\n\n        num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)\n - ps_dec->u2_total_mbs_coded;\n\n if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0))\n            prev_slice_err = 1;\n else\n            prev_slice_err = 2;\n\n        ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num,\n &temp_poc, prev_slice_err);\n\n if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T))\n {\n return IV_FAIL;\n }\n }\n\n if((ret == IVD_RES_CHANGED)\n || (ret == IVD_MEM_ALLOC_FAILED)\n || (ret == ERROR_UNAVAIL_PICBUF_T)\n || (ret == ERROR_UNAVAIL_MVBUF_T))\n {\n\n \/* signal the decode thread *\/\n        ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet *\/\n if(ps_dec->u4_num_cores == 3)\n {\n            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n \/* dont consume bitstream for change in resolution case *\/\n if(ret == IVD_RES_CHANGED)\n {\n            ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;\n }\n return IV_FAIL;\n }\n\n\n if(ps_dec->u1_separate_parse)\n {\n \/* If Format conversion is not complete,\n         complete it here *\/\n if(ps_dec->u4_num_cores == 2)\n {\n\n \/*do deblocking of all mbs*\/\n if((ps_dec->u4_nmb_deblk == 0) &&(ps_dec->u4_start_recon_deblk == 1) && (ps_dec->ps_cur_sps->u1_mb_aff_flag == 0))\n {\n                UWORD32 u4_num_mbs,u4_max_addr;\n tfr_ctxt_t s_tfr_ctxt;\n tfr_ctxt_t *ps_tfr_cxt = &s_tfr_ctxt;\n pad_mgr_t *ps_pad_mgr = &ps_dec->s_pad_mgr;\n\n \/*BS is done for all mbs while parsing*\/\n                u4_max_addr = (ps_dec->u2_frm_wd_in_mbs * ps_dec->u2_frm_ht_in_mbs) - 1;\n                ps_dec->u4_cur_bs_mb_num = u4_max_addr + 1;\n\n\n                ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt,\n                                           ps_dec->u2_frm_wd_in_mbs, 0);\n\n\n                u4_num_mbs = u4_max_addr\n - ps_dec->u4_cur_deblk_mb_num + 1;\n\n                DEBUG_PERF_PRINTF(\"mbs left for deblocking= %d \\n\",u4_num_mbs);\n\n if(u4_num_mbs != 0)\n                    ih264d_check_mb_map_deblk(ps_dec, u4_num_mbs,\n                                                   ps_tfr_cxt,1);\n\n                ps_dec->u4_start_recon_deblk  = 0;\n\n }\n\n }\n\n \/*signal the decode thread*\/\n        ih264d_signal_decode_thread(ps_dec);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n }\n\n\n    DATA_SYNC();\n\n\n if((ps_dec_op->u4_error_code & 0xff)\n != ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED)\n {\n        ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width;\n        ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height;\n }\n\n if(ps_dec->i4_header_decoded != 3)\n {\n        ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA);\n\n }\n\n if(ps_dec->i4_decode_header == 1 && ps_dec->i4_header_decoded != 3)\n {\n        ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA);\n\n }\n if(ps_dec->u4_prev_nal_skipped)\n {\n \/*We have encountered a referenced frame,return to app*\/\n        ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED;\n        ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);\n        ps_dec_op->u4_frame_decoded_flag = 0;\n        ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t);\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n            ih264d_signal_bs_deblk_thread(ps_dec);\n }\n return (IV_FAIL);\n\n }\n\n if((ps_dec->u4_slice_start_code_found == 1)\n && (ERROR_DANGLING_FIELD_IN_PIC != i4_err_status))\n {\n \/*\n         * For field pictures, set the bottom and top picture decoded u4_flag correctly.\n         *\/\n\n if(ps_dec->ps_cur_slice->u1_field_pic_flag)\n {\n if(1 == ps_dec->ps_cur_slice->u1_bottom_field_flag)\n {\n                ps_dec->u1_top_bottom_decoded |= BOT_FIELD_ONLY;\n }\n else\n {\n                ps_dec->u1_top_bottom_decoded |= TOP_FIELD_ONLY;\n }\n }\n\n \/* if new frame in not found (if we are still getting slices from previous frame)\n         * ih264d_deblock_display is not called. Such frames will not be added to reference \/display\n         *\/\n if((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0)\n {\n \/* Calling Function to deblock Picture and Display *\/\n            ret = ih264d_deblock_display(ps_dec);\n if(ret != 0)\n {\n return IV_FAIL;\n }\n }\n\n\n \/*set to complete ,as we dont support partial frame decode*\/\n if(ps_dec->i4_header_decoded == 3)\n {\n            ps_dec->u2_total_mbs_coded = ps_dec->ps_cur_sps->u2_max_mb_addr + 1;\n }\n\n \/*Update the i4_frametype at the end of picture*\/\n if(ps_dec->ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL)\n {\n            ps_dec->i4_frametype = IV_IDR_FRAME;\n }\n else if(ps_dec->i4_pic_type == B_SLICE)\n {\n            ps_dec->i4_frametype = IV_B_FRAME;\n }\n else if(ps_dec->i4_pic_type == P_SLICE)\n {\n            ps_dec->i4_frametype = IV_P_FRAME;\n }\n else if(ps_dec->i4_pic_type == I_SLICE)\n {\n            ps_dec->i4_frametype = IV_I_FRAME;\n }\n else\n {\n            H264_DEC_DEBUG_PRINT(\"Shouldn't come here\\n\");\n }\n\n        ps_dec->i4_content_type = ps_dec->ps_cur_slice->u1_field_pic_flag;\n\n        ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + 2;\n        ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded\n - ps_dec->ps_cur_slice->u1_field_pic_flag;\n\n }\n\n \/* close deblock thread if it is not closed yet*\/\n if(ps_dec->u4_num_cores == 3)\n {\n        ih264d_signal_bs_deblk_thread(ps_dec);\n }\n\n\n {\n \/* In case the decoder is configured to run in low delay mode,\n         * then get display buffer and then format convert.\n         * Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles\n         *\/\n\n if((IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode)\n && ps_dec->u1_init_dec_flag)\n {\n\n            ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer,\n &(ps_dec->s_disp_op));\n if(0 == ps_dec->s_disp_op.u4_error_code)\n {\n                ps_dec->u4_fmt_conv_cur_row = 0;\n                ps_dec->u4_output_present = 1;\n }\n }\n\n        ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op);\n\n \/* If Format conversion is not complete,\n         complete it here *\/\n if(ps_dec->u4_output_present &&\n (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht))\n {\n            ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht\n - ps_dec->u4_fmt_conv_cur_row;\n            ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op),\n                                  ps_dec->u4_fmt_conv_cur_row,\n                                  ps_dec->u4_fmt_conv_num_rows);\n            ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;\n }\n\n        ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op));\n }\n\n if(ps_dec->i4_decode_header == 1 && (ps_dec->i4_header_decoded & 1) == 1)\n {\n        ps_dec_op->u4_progressive_frame_flag = 1;\n if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))\n {\n if((0 == ps_dec->ps_sps->u1_frame_mbs_only_flag)\n && (0 == ps_dec->ps_sps->u1_mb_aff_flag))\n                ps_dec_op->u4_progressive_frame_flag = 0;\n\n }\n }\n\n \/*Data memory barrier instruction,so that yuv write by the library is complete*\/\n    DATA_SYNC();\n\n    H264_DEC_DEBUG_PRINT(\"The num bytes consumed: %d\\n\",\n                         ps_dec_op->u4_num_bytes_consumed);\n return api_ret_value;\n}\n","target":0,"code_token_length":6180,"total_token_length":6416,"max_tokens_setting":8192}
+{"idx":346717,"func":"gst_riff_create_audio_caps (guint16 codec_id,\n    gst_riff_strh * strh, gst_riff_strf_auds * strf,\n    GstBuffer * strf_data, GstBuffer * strd_data, char **codec_name,\n    gint channel_reorder_map[18])\n{\n  gboolean block_align = FALSE, rate_chan = TRUE;\n  GstCaps *caps = NULL;\n  gint i;\n\n  if (channel_reorder_map)\n    for (i = 0; i < 18; i++)\n      channel_reorder_map[i] = -1;\n\n  switch (codec_id) {\n    case GST_RIFF_WAVE_FORMAT_PCM:     \/* PCM *\/\n      if (strf != NULL) {\n        gint ba = strf->blockalign;\n        gint ch = strf->channels;\n        gint wd, ws;\n        GstAudioFormat format;\n\n        if (ba > (32 \/ 8) * ch) {\n          GST_WARNING (\"Invalid block align: %d > %d\", ba, (32 \/ 8) * ch);\n          wd = GST_ROUND_UP_8 (strf->bits_per_sample);\n        } else if (ba != 0) {\n          \/* If we have an empty blockalign, we take the width contained in \n           * strf->bits_per_sample *\/\n          wd = ba * 8 \/ ch;\n        } else {\n          wd = GST_ROUND_UP_8 (strf->bits_per_sample);\n        }\n\n        if (strf->bits_per_sample > 32) {\n          GST_WARNING (\"invalid depth (%d) of pcm audio, overwriting.\",\n              strf->bits_per_sample);\n          strf->bits_per_sample = wd;\n        }\n\n        \/* in riff, the depth is stored in the size field but it just means that\n         * the _least_ significant bits are cleared. We can therefore just play\n         * the sample as if it had a depth == width *\/\n        \/* For reference, the actual depth is in strf->bits_per_sample *\/\n        ws = wd;\n\n        format =\n            gst_audio_format_build_integer (wd != 8, G_LITTLE_ENDIAN, wd, ws);\n        if (format == GST_AUDIO_FORMAT_UNKNOWN) {\n          GST_WARNING (\"Unsupported raw audio format with width %d\", wd);\n          return NULL;\n        }\n\n        caps = gst_caps_new_simple (\"audio\/x-raw\",\n            \"format\", G_TYPE_STRING, gst_audio_format_to_string (format),\n            \"layout\", G_TYPE_STRING, \"interleaved\",\n            \"channels\", G_TYPE_INT, ch, NULL);\n\n        \/* Add default channel layout. We know no default layout for more than\n         * 8 channels. *\/\n        if (ch > 8)\n          GST_WARNING (\"don't know default layout for %d channels\", ch);\n        else if (gst_riff_wave_add_default_channel_mask (caps, ch,\n                channel_reorder_map))\n          GST_DEBUG (\"using default channel layout for %d channels\", ch);\n        else\n          GST_WARNING (\"failed to add channel layout\");\n      } else {\n        \/* FIXME: this is pretty useless - we need fixed caps *\/\n        caps = gst_caps_from_string (\"audio\/x-raw, \"\n            \"format = (string) { S8, U8, S16LE, U16LE, S24LE, \"\n            \"U24LE, S32LE, U32LE }, \" \"layout = (string) interleaved\");\n      }\n      if (codec_name && strf)\n        *codec_name = g_strdup_printf (\"Uncompressed %d-bit PCM audio\",\n            strf->bits_per_sample);\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_ADPCM:\n      if (strf != NULL) {\n        \/* Many encoding tools create a wrong bitrate information in the header,\n         * so either we calculate the bitrate or mark it as invalid as this\n         * would probably confuse timing *\/\n        strf->av_bps = 0;\n        if (strf->channels != 0 && strf->rate != 0 && strf->blockalign != 0) {\n          int spb = ((strf->blockalign - strf->channels * 7) \/ 2) * 2;\n          strf->av_bps =\n              gst_util_uint64_scale_int (strf->rate, strf->blockalign, spb);\n          GST_DEBUG (\"fixing av_bps to calculated value %d of MS ADPCM\",\n              strf->av_bps);\n        }\n      }\n      caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n          \"layout\", G_TYPE_STRING, \"microsoft\", NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"ADPCM audio\");\n      block_align = TRUE;\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_IEEE_FLOAT:\n      if (strf != NULL) {\n        gint ba = strf->blockalign;\n        gint ch = strf->channels;\n        gint wd = ba * 8 \/ ch;\n\n        caps = gst_caps_new_simple (\"audio\/x-raw\",\n            \"format\", G_TYPE_STRING, wd == 64 ? \"F64LE\" : \"F32LE\",\n            \"layout\", G_TYPE_STRING, \"interleaved\",\n            \"channels\", G_TYPE_INT, ch, NULL);\n\n        \/* Add default channel layout. We know no default layout for more than\n         * 8 channels. *\/\n        if (ch > 8)\n          GST_WARNING (\"don't know default layout for %d channels\", ch);\n        else if (gst_riff_wave_add_default_channel_mask (caps, ch,\n                channel_reorder_map))\n          GST_DEBUG (\"using default channel layout for %d channels\", ch);\n        else\n          GST_WARNING (\"failed to add channel layout\");\n      } else {\n        \/* FIXME: this is pretty useless - we need fixed caps *\/\n        caps = gst_caps_from_string (\"audio\/x-raw, \"\n            \"format = (string) { F32LE, F64LE }, \"\n            \"layout = (string) interleaved\");\n      }\n      if (codec_name && strf)\n        *codec_name = g_strdup_printf (\"Uncompressed %d-bit IEEE float audio\",\n            strf->bits_per_sample);\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_IBM_CVSD:\n      goto unknown;\n\n    case GST_RIFF_WAVE_FORMAT_ALAW:\n      if (strf != NULL) {\n        if (strf->bits_per_sample != 8) {\n          GST_WARNING (\"invalid depth (%d) of alaw audio, overwriting.\",\n              strf->bits_per_sample);\n          strf->bits_per_sample = 8;\n          strf->blockalign = (strf->bits_per_sample * strf->channels) \/ 8;\n          strf->av_bps = strf->blockalign * strf->rate;\n        }\n        if (strf->av_bps == 0 || strf->blockalign == 0) {\n          GST_WARNING (\"fixing av_bps (%d) and blockalign (%d) of alaw audio\",\n              strf->av_bps, strf->blockalign);\n          strf->blockalign = (strf->bits_per_sample * strf->channels) \/ 8;\n          strf->av_bps = strf->blockalign * strf->rate;\n        }\n      }\n      caps = gst_caps_new_empty_simple (\"audio\/x-alaw\");\n      if (codec_name)\n        *codec_name = g_strdup (\"A-law audio\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_WMS:\n      caps = gst_caps_new_empty_simple (\"audio\/x-wms\");\n      if (strf != NULL) {\n        gst_caps_set_simple (caps,\n            \"bitrate\", G_TYPE_INT, strf->av_bps * 8,\n            \"width\", G_TYPE_INT, strf->bits_per_sample,\n            \"depth\", G_TYPE_INT, strf->bits_per_sample, NULL);\n      } else {\n        gst_caps_set_simple (caps,\n            \"bitrate\", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);\n      }\n      if (codec_name)\n        *codec_name = g_strdup (\"Windows Media Audio Speech\");\n      block_align = TRUE;\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_MULAW:\n      if (strf != NULL) {\n        if (strf->bits_per_sample != 8) {\n          GST_WARNING (\"invalid depth (%d) of mulaw audio, overwriting.\",\n              strf->bits_per_sample);\n          strf->bits_per_sample = 8;\n          strf->blockalign = (strf->bits_per_sample * strf->channels) \/ 8;\n          strf->av_bps = strf->blockalign * strf->rate;\n        }\n        if (strf->av_bps == 0 || strf->blockalign == 0) {\n          GST_WARNING (\"fixing av_bps (%d) and blockalign (%d) of mulaw audio\",\n              strf->av_bps, strf->blockalign);\n          strf->blockalign = (strf->bits_per_sample * strf->channels) \/ 8;\n          strf->av_bps = strf->blockalign * strf->rate;\n        }\n      }\n      caps = gst_caps_new_empty_simple (\"audio\/x-mulaw\");\n      if (codec_name)\n        *codec_name = g_strdup (\"Mu-law audio\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_OKI_ADPCM:\n      goto unknown;\n\n    case GST_RIFF_WAVE_FORMAT_DVI_ADPCM:\n      if (strf != NULL) {\n        \/* Many encoding tools create a wrong bitrate information in the\n         * header, so either we calculate the bitrate or mark it as invalid\n         * as this would probably confuse timing *\/\n        strf->av_bps = 0;\n        if (strf->channels != 0 && strf->rate != 0 && strf->blockalign != 0) {\n          int spb = ((strf->blockalign - strf->channels * 4) \/ 2) * 2;\n          strf->av_bps =\n              gst_util_uint64_scale_int (strf->rate, strf->blockalign, spb);\n          GST_DEBUG (\"fixing av_bps to calculated value %d of IMA DVI ADPCM\",\n              strf->av_bps);\n        }\n      }\n      caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n          \"layout\", G_TYPE_STRING, \"dvi\", NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"DVI ADPCM audio\");\n      block_align = TRUE;\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_ADPCM_G722:\n      caps = gst_caps_new_empty_simple (\"audio\/G722\");\n      if (codec_name)\n        *codec_name = g_strdup (\"G722 audio\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_ITU_G726_ADPCM:\n      if (strf != NULL) {\n        gint bitrate;\n        bitrate = 0;\n        if (strf->av_bps == 2000 || strf->av_bps == 3000 || strf->av_bps == 4000\n            || strf->av_bps == 5000) {\n          strf->blockalign = strf->av_bps \/ 1000;\n          bitrate = strf->av_bps * 8;\n        } else if (strf->blockalign >= 2 && strf->blockalign <= 5) {\n          bitrate = strf->blockalign * 8000;\n        }\n        if (bitrate > 0) {\n          caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n              \"layout\", G_TYPE_STRING, \"g726\", \"bitrate\", G_TYPE_INT, bitrate,\n              NULL);\n        } else {\n          caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n              \"layout\", G_TYPE_STRING, \"g726\", NULL);\n        }\n      } else {\n        caps = gst_caps_new_simple (\"audio\/x-adpcm\",\n            \"layout\", G_TYPE_STRING, \"g726\", NULL);\n      }\n      if (codec_name)\n        *codec_name = g_strdup (\"G726 ADPCM audio\");\n      block_align = TRUE;\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_DSP_TRUESPEECH:\n      caps = gst_caps_new_empty_simple (\"audio\/x-truespeech\");\n      if (codec_name)\n        *codec_name = g_strdup (\"DSP Group TrueSpeech\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_GSM610:\n    case GST_RIFF_WAVE_FORMAT_MSN:\n      caps = gst_caps_new_empty_simple (\"audio\/ms-gsm\");\n      if (codec_name)\n        *codec_name = g_strdup (\"MS GSM audio\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_MPEGL12: \/* mp1 or mp2 *\/\n      caps = gst_caps_new_simple (\"audio\/mpeg\",\n          \"mpegversion\", G_TYPE_INT, 1, \"layer\", G_TYPE_INT, 2, NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"MPEG-1 layer 2\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_MPEGL3:  \/* mp3 *\/\n      caps = gst_caps_new_simple (\"audio\/mpeg\",\n          \"mpegversion\", G_TYPE_INT, 1, \"layer\", G_TYPE_INT, 3, NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"MPEG-1 layer 3\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_AMR_NB:  \/* amr-nb *\/\n      caps = gst_caps_new_empty_simple (\"audio\/AMR\");\n      if (codec_name)\n        *codec_name = g_strdup (\"AMR Narrow Band (NB)\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_AMR_WB:  \/* amr-wb *\/\n      caps = gst_caps_new_empty_simple (\"audio\/AMR-WB\");\n      if (codec_name)\n        *codec_name = g_strdup (\"AMR Wide Band (WB)\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_VORBIS1: \/* ogg\/vorbis mode 1 *\/\n    case GST_RIFF_WAVE_FORMAT_VORBIS2: \/* ogg\/vorbis mode 2 *\/\n    case GST_RIFF_WAVE_FORMAT_VORBIS3: \/* ogg\/vorbis mode 3 *\/\n    case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS:     \/* ogg\/vorbis mode 1+ *\/\n    case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS:     \/* ogg\/vorbis mode 2+ *\/\n    case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS:     \/* ogg\/vorbis mode 3+ *\/\n      caps = gst_caps_new_empty_simple (\"audio\/x-vorbis\");\n      if (codec_name)\n        *codec_name = g_strdup (\"Vorbis\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_A52:\n      caps = gst_caps_new_empty_simple (\"audio\/x-ac3\");\n      if (codec_name)\n        *codec_name = g_strdup (\"AC-3 audio\");\n      break;\n    case GST_RIFF_WAVE_FORMAT_DTS:\n      caps = gst_caps_new_empty_simple (\"audio\/x-dts\");\n      if (codec_name)\n        *codec_name = g_strdup (\"DTS audio\");\n      \/* wavparse is not always able to specify rate\/channels for DTS-in-wav *\/\n      rate_chan = FALSE;\n      break;\n    case GST_RIFF_WAVE_FORMAT_AAC:\n    case GST_RIFF_WAVE_FORMAT_AAC_AC:\n    case GST_RIFF_WAVE_FORMAT_AAC_pm:\n    {\n      caps = gst_caps_new_simple (\"audio\/mpeg\",\n          \"mpegversion\", G_TYPE_INT, 4, NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"MPEG-4 AAC audio\");\n      break;\n    }\n    case GST_RIFF_WAVE_FORMAT_WMAV1:\n    case GST_RIFF_WAVE_FORMAT_WMAV2:\n    case GST_RIFF_WAVE_FORMAT_WMAV3:\n    case GST_RIFF_WAVE_FORMAT_WMAV3_L:\n    {\n      gint version = (codec_id - GST_RIFF_WAVE_FORMAT_WMAV1) + 1;\n\n      block_align = TRUE;\n\n      caps = gst_caps_new_simple (\"audio\/x-wma\",\n          \"wmaversion\", G_TYPE_INT, version, NULL);\n\n      if (codec_name) {\n        if (codec_id == GST_RIFF_WAVE_FORMAT_WMAV3_L)\n          *codec_name = g_strdup (\"WMA Lossless\");\n        else\n          *codec_name = g_strdup_printf (\"WMA Version %d\", version + 6);\n      }\n\n      if (strf != NULL) {\n        gst_caps_set_simple (caps,\n            \"bitrate\", G_TYPE_INT, strf->av_bps * 8,\n            \"depth\", G_TYPE_INT, strf->bits_per_sample, NULL);\n      } else {\n        gst_caps_set_simple (caps,\n            \"bitrate\", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);\n      }\n      break;\n    }\n    case GST_RIFF_WAVE_FORMAT_SONY_ATRAC3:\n      caps = gst_caps_new_empty_simple (\"audio\/x-vnd.sony.atrac3\");\n      if (codec_name)\n        *codec_name = g_strdup (\"Sony ATRAC3\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_SIREN:\n      caps = gst_caps_new_empty_simple (\"audio\/x-siren\");\n      if (codec_name)\n        *codec_name = g_strdup (\"Siren7\");\n      rate_chan = FALSE;\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_ADPCM_IMA_DK4:\n      caps =\n          gst_caps_new_simple (\"audio\/x-adpcm\", \"layout\", G_TYPE_STRING, \"dk4\",\n          NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"IMA\/DK4 ADPCM\");\n      break;\n    case GST_RIFF_WAVE_FORMAT_ADPCM_IMA_DK3:\n      caps =\n          gst_caps_new_simple (\"audio\/x-adpcm\", \"layout\", G_TYPE_STRING, \"dk3\",\n          NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"IMA\/DK3 ADPCM\");\n      break;\n\n    case GST_RIFF_WAVE_FORMAT_ADPCM_IMA_WAV:\n      caps =\n          gst_caps_new_simple (\"audio\/x-adpcm\", \"layout\", G_TYPE_STRING, \"dvi\",\n          NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"IMA\/WAV ADPCM\");\n      break;\n    case GST_RIFF_WAVE_FORMAT_EXTENSIBLE:{\n      guint16 valid_bits_per_sample;\n      guint32 channel_mask;\n      guint32 subformat_guid[4];\n      GstMapInfo info;\n      gsize size;\n\n      \/* should be at least 22 bytes *\/\n      size = gst_buffer_get_size (strf_data);\n\n      if (strf_data == NULL || size < 22) {\n        GST_WARNING (\"WAVE_FORMAT_EXTENSIBLE data size is %\" G_GSIZE_FORMAT\n            \" (expected: 22)\", (strf_data) ? size : -1);\n        return NULL;\n      }\n\n      gst_buffer_map (strf_data, &info, GST_MAP_READ);\n      valid_bits_per_sample = GST_READ_UINT16_LE (info.data);\n      channel_mask = GST_READ_UINT32_LE (info.data + 2);\n      subformat_guid[0] = GST_READ_UINT32_LE (info.data + 6);\n      subformat_guid[1] = GST_READ_UINT32_LE (info.data + 10);\n      subformat_guid[2] = GST_READ_UINT32_LE (info.data + 14);\n      subformat_guid[3] = GST_READ_UINT32_LE (info.data + 18);\n      gst_buffer_unmap (strf_data, &info);\n\n      GST_DEBUG (\"valid bps    = %u\", valid_bits_per_sample);\n      GST_DEBUG (\"channel mask = 0x%08x\", channel_mask);\n      GST_DEBUG (\"GUID         = %08x-%08x-%08x-%08x\", subformat_guid[0],\n          subformat_guid[1], subformat_guid[2], subformat_guid[3]);\n\n      if (subformat_guid[1] == 0x00100000 &&\n          subformat_guid[2] == 0xaa000080 && subformat_guid[3] == 0x719b3800) {\n        if (subformat_guid[0] == 0x00000001) {\n          GST_DEBUG (\"PCM\");\n          if (strf != NULL && strf->blockalign != 0 && strf->channels != 0\n              && strf->rate != 0) {\n            gint ba = strf->blockalign;\n            gint wd = ba * 8 \/ strf->channels;\n            gint ws;\n            GstAudioFormat format;\n\n            \/* in riff, the depth is stored in the size field but it just\n             * means that the _least_ significant bits are cleared. We can\n             * therefore just play the sample as if it had a depth == width *\/\n            ws = wd;\n\n            \/* For reference, use this to get the actual depth:\n             * ws = strf->bits_per_sample;\n             * if (valid_bits_per_sample != 0)\n             *   ws = valid_bits_per_sample; *\/\n\n            format =\n                gst_audio_format_build_integer (wd != 8, G_LITTLE_ENDIAN, wd,\n                ws);\n\n            caps = gst_caps_new_simple (\"audio\/x-raw\",\n                \"format\", G_TYPE_STRING, gst_audio_format_to_string (format),\n                \"layout\", G_TYPE_STRING, \"interleaved\",\n                \"channels\", G_TYPE_INT, strf->channels,\n                \"rate\", G_TYPE_INT, strf->rate, NULL);\n\n            if (codec_name) {\n              *codec_name = g_strdup_printf (\"Uncompressed %d-bit PCM audio\",\n                  strf->bits_per_sample);\n            }\n          }\n        } else if (subformat_guid[0] == 0x00000003) {\n          GST_DEBUG (\"FLOAT\");\n          if (strf != NULL && strf->blockalign != 0 && strf->channels != 0\n              && strf->rate != 0) {\n            gint ba = strf->blockalign;\n            gint wd = ba * 8 \/ strf->channels;\n\n            caps = gst_caps_new_simple (\"audio\/x-raw\",\n                \"format\", G_TYPE_STRING, wd == 32 ? \"F32LE\" : \"F64LE\",\n                \"layout\", G_TYPE_STRING, \"interleaved\",\n                \"channels\", G_TYPE_INT, strf->channels,\n                \"rate\", G_TYPE_INT, strf->rate, NULL);\n\n            if (codec_name) {\n              *codec_name =\n                  g_strdup_printf (\"Uncompressed %d-bit IEEE float audio\",\n                  strf->bits_per_sample);\n            }\n          }\n        } else if (subformat_guid[0] == 0x0000006) {\n          GST_DEBUG (\"ALAW\");\n          if (strf != NULL) {\n            if (strf->bits_per_sample != 8) {\n              GST_WARNING (\"invalid depth (%d) of alaw audio, overwriting.\",\n                  strf->bits_per_sample);\n              strf->bits_per_sample = 8;\n              strf->av_bps = 8;\n              strf->blockalign = strf->av_bps * strf->channels;\n            }\n            if (strf->av_bps == 0 || strf->blockalign == 0) {\n              GST_WARNING\n                  (\"fixing av_bps (%d) and blockalign (%d) of alaw audio\",\n                  strf->av_bps, strf->blockalign);\n              strf->av_bps = strf->bits_per_sample;\n              strf->blockalign = strf->av_bps * strf->channels;\n            }\n          }\n          caps = gst_caps_new_empty_simple (\"audio\/x-alaw\");\n\n          if (codec_name)\n            *codec_name = g_strdup (\"A-law audio\");\n        } else if (subformat_guid[0] == 0x00000007) {\n          GST_DEBUG (\"MULAW\");\n          if (strf != NULL) {\n            if (strf->bits_per_sample != 8) {\n              GST_WARNING (\"invalid depth (%d) of mulaw audio, overwriting.\",\n                  strf->bits_per_sample);\n              strf->bits_per_sample = 8;\n              strf->av_bps = 8;\n              strf->blockalign = strf->av_bps * strf->channels;\n            }\n            if (strf->av_bps == 0 || strf->blockalign == 0) {\n              GST_WARNING\n                  (\"fixing av_bps (%d) and blockalign (%d) of mulaw audio\",\n                  strf->av_bps, strf->blockalign);\n              strf->av_bps = strf->bits_per_sample;\n              strf->blockalign = strf->av_bps * strf->channels;\n            }\n          }\n          caps = gst_caps_new_empty_simple (\"audio\/x-mulaw\");\n          if (codec_name)\n            *codec_name = g_strdup (\"Mu-law audio\");\n        } else if (subformat_guid[0] == 0x00000092) {\n          GST_DEBUG (\"FIXME: handle DOLBY AC3 SPDIF format\");\n          GST_DEBUG (\"WAVE_FORMAT_EXTENSIBLE AC-3 SPDIF audio\");\n          caps = gst_caps_new_empty_simple (\"audio\/x-ac3\");\n          if (codec_name)\n            *codec_name = g_strdup (\"wavext AC-3 SPDIF audio\");\n        } else if ((subformat_guid[0] & 0xffff) ==\n            GST_RIFF_WAVE_FORMAT_EXTENSIBLE) {\n          GST_DEBUG (\"WAVE_FORMAT_EXTENSIBLE nested\");\n        } else {\n          \/* recurse where no special consideration has yet to be identified \n           * for the subformat guid *\/\n          caps = gst_riff_create_audio_caps (subformat_guid[0], strh, strf,\n              strf_data, strd_data, codec_name, channel_reorder_map);\n          if (!codec_name)\n            GST_DEBUG (\"WAVE_FORMAT_EXTENSIBLE audio\");\n          if (caps) {\n            if (codec_name) {\n              GST_DEBUG (\"WAVE_FORMAT_EXTENSIBLE %s\", *codec_name);\n              *codec_name = g_strjoin (\"wavext \", *codec_name, NULL);\n            }\n            return caps;\n          }\n        }\n      } else if (subformat_guid[0] == 0x6ba47966 &&\n          subformat_guid[1] == 0x41783f83 &&\n          subformat_guid[2] == 0xf0006596 && subformat_guid[3] == 0xe59262bf) {\n        caps = gst_caps_new_empty_simple (\"application\/x-ogg-avi\");\n        if (codec_name)\n          *codec_name = g_strdup (\"Ogg-AVI\");\n      }\n\n      if (caps == NULL) {\n        GST_WARNING (\"Unknown WAVE_FORMAT_EXTENSIBLE audio format\");\n        return NULL;\n      }\n\n      if (strf != NULL) {\n        \/* If channel_mask == 0 and channels > 1 let's\n         * assume default layout as some wav files don't have the\n         * channel mask set. Don't set the layout for 1 channel. *\/\n        if (channel_mask == 0 && strf->channels > 1)\n          channel_mask =\n              gst_riff_wavext_get_default_channel_mask (strf->channels);\n\n        if ((channel_mask != 0 || strf->channels > 1) &&\n            !gst_riff_wavext_add_channel_mask (caps, strf->channels,\n                channel_mask, channel_reorder_map)) {\n          GST_WARNING (\"failed to add channel layout\");\n          gst_caps_unref (caps);\n          caps = NULL;\n        }\n        rate_chan = FALSE;\n      }\n\n      break;\n    }\n      \/* can anything decode these? pitfdll? *\/\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_AC8:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_AC10:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_AC16:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_AC20:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_METAVOICE:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_METASOUND:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_RT29HW:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_VR12:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_VR18:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_TQ40:\n    case GST_RIFF_WAVE_FORMAT_VOXWARE_TQ60:{\n      caps = gst_caps_new_simple (\"audio\/x-voxware\",\n          \"voxwaretype\", G_TYPE_INT, (gint) codec_id, NULL);\n      if (codec_name)\n        *codec_name = g_strdup (\"Voxware\");\n      break;\n    }\n    default:\n    unknown:\n      GST_WARNING (\"Unknown audio tag 0x%04x\", codec_id);\n      return NULL;\n  }\n\n  if (strf != NULL) {\n    if (rate_chan) {\n      gst_caps_set_simple (caps,\n          \"rate\", G_TYPE_INT, strf->rate,\n          \"channels\", G_TYPE_INT, strf->channels, NULL);\n    }\n    if (block_align) {\n      gst_caps_set_simple (caps,\n          \"block_align\", G_TYPE_INT, strf->blockalign, NULL);\n    }\n  } else {\n    if (block_align) {\n      gst_caps_set_simple (caps,\n          \"block_align\", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);\n    }\n  }\n\n  \/* extradata *\/\n  if (strf_data || strd_data) {\n    gst_caps_set_simple (caps, \"codec_data\", GST_TYPE_BUFFER,\n        strf_data ? strf_data : strd_data, NULL);\n  }\n\n  return caps;\n}","target":1,"code_token_length":6540,"total_token_length":6776,"max_tokens_setting":8192}
+{"idx":104251,"func":"static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info,\n  Image *image,ExceptionInfo *exception)\n{\n  const char\n    *option,\n    *sampling_factor,\n    *value;\n\n  ErrorManager\n    error_manager;\n\n  Image\n    *volatile volatile_image;\n\n  int\n    colorspace,\n    quality;\n\n  JSAMPLE\n    *volatile jpeg_pixels;\n\n  JSAMPROW\n    scanline[1];\n\n  MagickBooleanType\n    status;\n\n  MemoryInfo\n    *memory_info;\n\n  register JSAMPLE\n    *q;\n\n  register ssize_t\n    i;\n\n  ssize_t\n    y;\n\n  struct jpeg_compress_struct\n    jpeg_info;\n\n  struct jpeg_error_mgr\n    jpeg_error;\n\n  unsigned short\n    scale;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  if ((LocaleCompare(image_info->magick,\"JPS\") == 0) &&\n      (image->next != (Image *) NULL))\n    image=AppendImages(image,MagickFalse,exception);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  \/*\n    Initialize JPEG parameters.\n  *\/\n  (void) ResetMagickMemory(&error_manager,0,sizeof(error_manager));\n  (void) ResetMagickMemory(&jpeg_info,0,sizeof(jpeg_info));\n  (void) ResetMagickMemory(&jpeg_error,0,sizeof(jpeg_error));\n  volatile_image=image;\n  jpeg_info.client_data=(void *) volatile_image;\n  jpeg_info.err=jpeg_std_error(&jpeg_error);\n  jpeg_info.err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler;\n  jpeg_info.err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler;\n  error_manager.exception=exception;\n  error_manager.image=volatile_image;\n  memory_info=(MemoryInfo *) NULL;\n  if (setjmp(error_manager.error_recovery) != 0)\n    {\n      jpeg_destroy_compress(&jpeg_info);\n      (void) CloseBlob(volatile_image);\n      return(MagickFalse);\n    }\n  jpeg_info.client_data=(void *) &error_manager;\n  jpeg_create_compress(&jpeg_info);\n  JPEGDestinationManager(&jpeg_info,image);\n  if ((image->columns != (unsigned int) image->columns) ||\n      (image->rows != (unsigned int) image->rows))\n    ThrowWriterException(ImageError,\"WidthOrHeightExceedsLimit\");\n  jpeg_info.image_width=(unsigned int) image->columns;\n  jpeg_info.image_height=(unsigned int) image->rows;\n  jpeg_info.input_components=3;\n  jpeg_info.data_precision=8;\n  jpeg_info.in_color_space=JCS_RGB;\n  switch (image->colorspace)\n  {\n    case CMYKColorspace:\n    {\n      jpeg_info.input_components=4;\n      jpeg_info.in_color_space=JCS_CMYK;\n      break;\n    }\n    case YCbCrColorspace:\n    case Rec601YCbCrColorspace:\n    case Rec709YCbCrColorspace:\n    {\n      jpeg_info.in_color_space=JCS_YCbCr;\n      break;\n    }\n    case GRAYColorspace:\n    {\n      if (image_info->type == TrueColorType)\n        break;\n      jpeg_info.input_components=1;\n      jpeg_info.in_color_space=JCS_GRAYSCALE;\n      break;\n    }\n    default:\n    {\n      (void) TransformImageColorspace(image,sRGBColorspace,exception);\n      if (image_info->type == TrueColorType)\n        break;\n      if (SetImageGray(image,exception) != MagickFalse)\n        {\n          jpeg_info.input_components=1;\n          jpeg_info.in_color_space=JCS_GRAYSCALE;\n        }\n      break;\n    }\n  }\n  jpeg_set_defaults(&jpeg_info);\n  if (jpeg_info.in_color_space == JCS_CMYK)\n    jpeg_set_colorspace(&jpeg_info,JCS_YCCK);\n  if ((jpeg_info.data_precision != 12) && (image->depth <= 8))\n    jpeg_info.data_precision=8;\n  else\n    jpeg_info.data_precision=BITS_IN_JSAMPLE;\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"Image resolution: %.20g,%.20g\",image->resolution.x,image->resolution.y);\n  if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))\n    {\n      \/*\n        Set image resolution.\n      *\/\n      jpeg_info.write_JFIF_header=TRUE;\n      jpeg_info.X_density=(UINT16) image->resolution.x;\n      jpeg_info.Y_density=(UINT16) image->resolution.y;\n      \/*\n        Set image resolution units.\n      *\/\n      if (image->units == PixelsPerInchResolution)\n        jpeg_info.density_unit=(UINT8) 1;\n      if (image->units == PixelsPerCentimeterResolution)\n        jpeg_info.density_unit=(UINT8) 2;\n    }\n  jpeg_info.dct_method=JDCT_FLOAT;\n  option=GetImageOption(image_info,\"jpeg:dct-method\");\n  if (option != (const char *) NULL)\n    switch (*option)\n    {\n      case 'D':\n      case 'd':\n      {\n        if (LocaleCompare(option,\"default\") == 0)\n          jpeg_info.dct_method=JDCT_DEFAULT;\n        break;\n      }\n      case 'F':\n      case 'f':\n      {\n        if (LocaleCompare(option,\"fastest\") == 0)\n          jpeg_info.dct_method=JDCT_FASTEST;\n        if (LocaleCompare(option,\"float\") == 0)\n          jpeg_info.dct_method=JDCT_FLOAT;\n        break;\n      }\n      case 'I':\n      case 'i':\n      {\n        if (LocaleCompare(option,\"ifast\") == 0)\n          jpeg_info.dct_method=JDCT_IFAST;\n        if (LocaleCompare(option,\"islow\") == 0)\n          jpeg_info.dct_method=JDCT_ISLOW;\n        break;\n      }\n    }\n  option=GetImageOption(image_info,\"jpeg:optimize-coding\");\n  if (option != (const char *) NULL)\n    jpeg_info.optimize_coding=IsStringTrue(option) != MagickFalse ? TRUE :\n      FALSE;\n  else\n    {\n      MagickSizeType\n        length;\n\n      length=(MagickSizeType) jpeg_info.input_components*image->columns*\n        image->rows*sizeof(JSAMPLE);\n      if (length == (MagickSizeType) ((size_t) length))\n        {\n          \/*\n            Perform optimization only if available memory resources permit it.\n          *\/\n          status=AcquireMagickResource(MemoryResource,length);\n          RelinquishMagickResource(MemoryResource,length);\n          jpeg_info.optimize_coding=status == MagickFalse ? FALSE : TRUE;\n        }\n    }\n#if (JPEG_LIB_VERSION >= 61) && defined(C_PROGRESSIVE_SUPPORTED)\n  if ((LocaleCompare(image_info->magick,\"PJPEG\") == 0) ||\n      (image_info->interlace != NoInterlace))\n    {\n      if (image->debug != MagickFalse)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Interlace: progressive\");\n      jpeg_simple_progression(&jpeg_info);\n    }\n  else\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"Interlace: non-progressive\");\n#else\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"Interlace: nonprogressive\");\n#endif\n  quality=92;\n  if ((image_info->compression != LosslessJPEGCompression) &&\n      (image->quality <= 100))\n    {\n      if (image->quality != UndefinedCompressionQuality)\n        quality=(int) image->quality;\n      if (image->debug != MagickFalse)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Quality: %.20g\",\n          (double) image->quality);\n    }\n  else\n    {\n#if !defined(C_LOSSLESS_SUPPORTED)\n      quality=100;\n      if (image->debug != MagickFalse)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Quality: 100\");\n#else\n      if (image->quality < 100)\n        (void) ThrowMagickException(exception,GetMagickModule(),CoderWarning,\n          \"LosslessToLossyJPEGConversion\",image->filename);\n      else\n        {\n          int\n            point_transform,\n            predictor;\n\n          predictor=image->quality\/100;  \/* range 1-7 *\/\n          point_transform=image->quality % 20;  \/* range 0-15 *\/\n          jpeg_simple_lossless(&jpeg_info,predictor,point_transform);\n          if (image->debug != MagickFalse)\n            {\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"Compression: lossless\");\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"Predictor: %d\",predictor);\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"Point Transform: %d\",point_transform);\n            }\n        }\n#endif\n    }\n  option=GetImageOption(image_info,\"jpeg:extent\");\n  if (option != (const char *) NULL)\n    {\n      Image\n        *jpeg_image;\n\n      ImageInfo\n        *extent_info;\n\n      extent_info=CloneImageInfo(image_info);\n      extent_info->blob=NULL;\n      jpeg_image=CloneImage(image,0,0,MagickTrue,exception);\n      if (jpeg_image != (Image *) NULL)\n        {\n          MagickSizeType\n            extent;\n\n          size_t\n            maximum,\n            minimum;\n\n          \/*\n            Search for compression quality that does not exceed image extent.\n          *\/\n          extent_info->quality=0;\n          extent=(MagickSizeType) SiPrefixToDoubleInterval(option,100.0);\n          (void) DeleteImageOption(extent_info,\"jpeg:extent\");\n          (void) DeleteImageArtifact(jpeg_image,\"jpeg:extent\");\n          maximum=image_info->quality;\n          if (maximum < 2)\n            maximum=101;\n          for (minimum=2; minimum < maximum; )\n          {\n            (void) AcquireUniqueFilename(jpeg_image->filename);\n            jpeg_image->quality=minimum+(maximum-minimum+1)\/2;\n            status=WriteJPEGImage(extent_info,jpeg_image,exception);\n            if (GetBlobSize(jpeg_image) <= extent)\n              minimum=jpeg_image->quality+1;\n            else\n              maximum=jpeg_image->quality-1;\n            (void) RelinquishUniqueFileResource(jpeg_image->filename);\n          }\n          quality=(int) minimum-1;\n          jpeg_image=DestroyImage(jpeg_image);\n        }\n      extent_info=DestroyImageInfo(extent_info);\n    }\n  jpeg_set_quality(&jpeg_info,quality,TRUE);\n#if (JPEG_LIB_VERSION >= 70)\n  option=GetImageOption(image_info,\"quality\");\n  if (option != (const char *) NULL)\n    {\n      GeometryInfo\n        geometry_info;\n\n      int\n        flags;\n\n      \/*\n        Set quality scaling for luminance and chrominance separately.\n      *\/\n      flags=ParseGeometry(option,&geometry_info);\n      if (((flags & RhoValue) != 0) && ((flags & SigmaValue) != 0))\n        {\n          jpeg_info.q_scale_factor[0]=jpeg_quality_scaling((int)\n            (geometry_info.rho+0.5));\n          jpeg_info.q_scale_factor[1]=jpeg_quality_scaling((int)\n            (geometry_info.sigma+0.5));\n          jpeg_default_qtables(&jpeg_info,TRUE);\n        }\n    }\n#endif\n  colorspace=jpeg_info.in_color_space;\n  value=GetImageOption(image_info,\"jpeg:colorspace\");\n  if (value == (char *) NULL)\n    value=GetImageProperty(image,\"jpeg:colorspace\",exception);\n  if (value != (char *) NULL)\n    colorspace=StringToInteger(value);\n  sampling_factor=(const char *) NULL;\n  if (colorspace == jpeg_info.in_color_space)\n    {\n      value=GetImageOption(image_info,\"jpeg:sampling-factor\");\n      if (value == (char *) NULL)\n        value=GetImageProperty(image,\"jpeg:sampling-factor\",exception);\n      if (value != (char *) NULL)\n        {\n          sampling_factor=value;\n          if (image->debug != MagickFalse)\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Input sampling-factors=%s\",sampling_factor);\n        }\n    }\n  value=GetImageOption(image_info,\"jpeg:sampling-factor\");\n  if (image_info->sampling_factor != (char *) NULL)\n    sampling_factor=image_info->sampling_factor;\n  if (sampling_factor == (const char *) NULL)\n    {\n      if (quality >= 90)\n        for (i=0; i < MAX_COMPONENTS; i++)\n        {\n          jpeg_info.comp_info[i].h_samp_factor=1;\n          jpeg_info.comp_info[i].v_samp_factor=1;\n        }\n    }\n  else\n    {\n      char\n        **factors;\n\n      GeometryInfo\n        geometry_info;\n\n      MagickStatusType\n        flags;\n\n      \/*\n        Set sampling factor.\n      *\/\n      i=0;\n      factors=SamplingFactorToList(sampling_factor);\n      if (factors != (char **) NULL)\n        {\n          for (i=0; i < MAX_COMPONENTS; i++)\n          {\n            if (factors[i] == (char *) NULL)\n              break;\n            flags=ParseGeometry(factors[i],&geometry_info);\n            if ((flags & SigmaValue) == 0)\n              geometry_info.sigma=geometry_info.rho;\n            jpeg_info.comp_info[i].h_samp_factor=(int) geometry_info.rho;\n            jpeg_info.comp_info[i].v_samp_factor=(int) geometry_info.sigma;\n            factors[i]=(char *) RelinquishMagickMemory(factors[i]);\n          }\n          factors=(char **) RelinquishMagickMemory(factors);\n        }\n      for ( ; i < MAX_COMPONENTS; i++)\n      {\n        jpeg_info.comp_info[i].h_samp_factor=1;\n        jpeg_info.comp_info[i].v_samp_factor=1;\n      }\n    }\n  option=GetImageOption(image_info,\"jpeg:q-table\");\n  if (option != (const char *) NULL)\n    {\n      QuantizationTable\n        *table;\n\n      \/*\n        Custom quantization tables.\n      *\/\n      table=GetQuantizationTable(option,\"0\",exception);\n      if (table != (QuantizationTable *) NULL)\n        {\n          for (i=0; i < MAX_COMPONENTS; i++)\n            jpeg_info.comp_info[i].quant_tbl_no=0;\n          jpeg_add_quant_table(&jpeg_info,0,table->levels,\n            jpeg_quality_scaling(quality),0);\n          table=DestroyQuantizationTable(table);\n        }\n      table=GetQuantizationTable(option,\"1\",exception);\n      if (table != (QuantizationTable *) NULL)\n        {\n          for (i=1; i < MAX_COMPONENTS; i++)\n            jpeg_info.comp_info[i].quant_tbl_no=1;\n          jpeg_add_quant_table(&jpeg_info,1,table->levels,\n            jpeg_quality_scaling(quality),0);\n          table=DestroyQuantizationTable(table);\n        }\n      table=GetQuantizationTable(option,\"2\",exception);\n      if (table != (QuantizationTable *) NULL)\n        {\n          for (i=2; i < MAX_COMPONENTS; i++)\n            jpeg_info.comp_info[i].quant_tbl_no=2;\n          jpeg_add_quant_table(&jpeg_info,2,table->levels,\n            jpeg_quality_scaling(quality),0);\n          table=DestroyQuantizationTable(table);\n        }\n      table=GetQuantizationTable(option,\"3\",exception);\n      if (table != (QuantizationTable *) NULL)\n        {\n          for (i=3; i < MAX_COMPONENTS; i++)\n            jpeg_info.comp_info[i].quant_tbl_no=3;\n          jpeg_add_quant_table(&jpeg_info,3,table->levels,\n            jpeg_quality_scaling(quality),0);\n          table=DestroyQuantizationTable(table);\n        }\n    }\n  jpeg_start_compress(&jpeg_info,TRUE);\n  if (image->debug != MagickFalse)\n    {\n      if (image->storage_class == PseudoClass)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Storage class: PseudoClass\");\n      else\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Storage class: DirectClass\");\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Depth: %.20g\",\n        (double) image->depth);\n      if (image->colors != 0)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Number of colors: %.20g\",(double) image->colors);\n      else\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Number of colors: unspecified\");\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"JPEG data precision: %d\",(int) jpeg_info.data_precision);\n      switch (image->colorspace)\n      {\n        case CMYKColorspace:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Storage class: DirectClass\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Colorspace: CMYK\");\n          break;\n        }\n        case YCbCrColorspace:\n        case Rec601YCbCrColorspace:\n        case Rec709YCbCrColorspace:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Colorspace: YCbCr\");\n          break;\n        }\n        default:\n          break;\n      }\n      switch (image->colorspace)\n      {\n        case CMYKColorspace:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Colorspace: CMYK\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Sampling factors: %dx%d,%dx%d,%dx%d,%dx%d\",\n            jpeg_info.comp_info[0].h_samp_factor,\n            jpeg_info.comp_info[0].v_samp_factor,\n            jpeg_info.comp_info[1].h_samp_factor,\n            jpeg_info.comp_info[1].v_samp_factor,\n            jpeg_info.comp_info[2].h_samp_factor,\n            jpeg_info.comp_info[2].v_samp_factor,\n            jpeg_info.comp_info[3].h_samp_factor,\n            jpeg_info.comp_info[3].v_samp_factor);\n          break;\n        }\n        case GRAYColorspace:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Colorspace: GRAY\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Sampling factors: %dx%d\",jpeg_info.comp_info[0].h_samp_factor,\n            jpeg_info.comp_info[0].v_samp_factor);\n          break;\n        }\n        case sRGBColorspace:\n        case RGBColorspace:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Image colorspace is RGB\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Sampling factors: %dx%d,%dx%d,%dx%d\",\n            jpeg_info.comp_info[0].h_samp_factor,\n            jpeg_info.comp_info[0].v_samp_factor,\n            jpeg_info.comp_info[1].h_samp_factor,\n            jpeg_info.comp_info[1].v_samp_factor,\n            jpeg_info.comp_info[2].h_samp_factor,\n            jpeg_info.comp_info[2].v_samp_factor);\n          break;\n        }\n        case YCbCrColorspace:\n        case Rec601YCbCrColorspace:\n        case Rec709YCbCrColorspace:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Colorspace: YCbCr\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Sampling factors: %dx%d,%dx%d,%dx%d\",\n            jpeg_info.comp_info[0].h_samp_factor,\n            jpeg_info.comp_info[0].v_samp_factor,\n            jpeg_info.comp_info[1].h_samp_factor,\n            jpeg_info.comp_info[1].v_samp_factor,\n            jpeg_info.comp_info[2].h_samp_factor,\n            jpeg_info.comp_info[2].v_samp_factor);\n          break;\n        }\n        default:\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Colorspace: %d\",\n            image->colorspace);\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"Sampling factors: %dx%d,%dx%d,%dx%d,%dx%d\",\n            jpeg_info.comp_info[0].h_samp_factor,\n            jpeg_info.comp_info[0].v_samp_factor,\n            jpeg_info.comp_info[1].h_samp_factor,\n            jpeg_info.comp_info[1].v_samp_factor,\n            jpeg_info.comp_info[2].h_samp_factor,\n            jpeg_info.comp_info[2].v_samp_factor,\n            jpeg_info.comp_info[3].h_samp_factor,\n            jpeg_info.comp_info[3].v_samp_factor);\n          break;\n        }\n      }\n    }\n  \/*\n    Write JPEG profiles.\n  *\/\n  value=GetImageProperty(image,\"comment\",exception);\n  if (value != (char *) NULL)\n    for (i=0; i < (ssize_t) strlen(value); i+=65533L)\n      jpeg_write_marker(&jpeg_info,JPEG_COM,(unsigned char *) value+i,\n        (unsigned int) MagickMin((size_t) strlen(value+i),65533L));\n  if (image->profiles != (void *) NULL)\n    WriteProfile(&jpeg_info,image,exception);\n  \/*\n    Convert MIFF to JPEG raster pixels.\n  *\/\n  memory_info=AcquireVirtualMemory((size_t) image->columns,\n    jpeg_info.input_components*sizeof(*jpeg_pixels));\n  if (memory_info == (MemoryInfo *) NULL)\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info);\n  if (setjmp(error_manager.error_recovery) != 0)\n    {\n      jpeg_destroy_compress(&jpeg_info);\n      if (memory_info != (MemoryInfo *) NULL)\n        memory_info=RelinquishVirtualMemory(memory_info);\n      (void) CloseBlob(image);\n      return(MagickFalse);\n    }\n  scanline[0]=(JSAMPROW) jpeg_pixels;\n  scale=65535\/(unsigned short) GetQuantumRange((size_t)\n    jpeg_info.data_precision);\n  if (scale == 0)\n    scale=1;\n  if (jpeg_info.data_precision <= 8)\n    {\n      if ((jpeg_info.in_color_space == JCS_RGB) ||\n          (jpeg_info.in_color_space == JCS_YCbCr))\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register const Quantum\n            *p;\n\n          register ssize_t\n            x;\n\n          p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n          if (p == (const Quantum *) NULL)\n            break;\n          q=jpeg_pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            *q++=(JSAMPLE) ScaleQuantumToChar(GetPixelRed(image,p));\n            *q++=(JSAMPLE) ScaleQuantumToChar(GetPixelGreen(image,p));\n            *q++=(JSAMPLE) ScaleQuantumToChar(GetPixelBlue(image,p));\n            p+=GetPixelChannels(image);\n          }\n          (void) jpeg_write_scanlines(&jpeg_info,scanline,1);\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n      else\n        if (jpeg_info.in_color_space == JCS_GRAYSCALE)\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            register const Quantum\n              *p;\n\n            register ssize_t\n              x;\n\n            p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n            if (p == (const Quantum *) NULL)\n              break;\n            q=jpeg_pixels;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              *q++=(JSAMPLE) ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(\n                image,p)));\n              p+=GetPixelChannels(image);\n            }\n            (void) jpeg_write_scanlines(&jpeg_info,scanline,1);\n            status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n              image->rows);\n            if (status == MagickFalse)\n              break;\n            }\n        else\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            register const Quantum\n              *p;\n\n            register ssize_t\n              x;\n\n            p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n            if (p == (const Quantum *) NULL)\n              break;\n            q=jpeg_pixels;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              \/*\n                Convert DirectClass packets to contiguous CMYK scanlines.\n              *\/\n              *q++=(JSAMPLE) (ScaleQuantumToChar((Quantum) (QuantumRange-\n                GetPixelCyan(image,p))));\n              *q++=(JSAMPLE) (ScaleQuantumToChar((Quantum) (QuantumRange-\n                GetPixelMagenta(image,p))));\n              *q++=(JSAMPLE) (ScaleQuantumToChar((Quantum) (QuantumRange-\n                GetPixelYellow(image,p))));\n              *q++=(JSAMPLE) (ScaleQuantumToChar((Quantum) (QuantumRange-\n                GetPixelBlack(image,p))));\n              p+=GetPixelChannels(image);\n            }\n            (void) jpeg_write_scanlines(&jpeg_info,scanline,1);\n            status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n              image->rows);\n            if (status == MagickFalse)\n              break;\n          }\n    }\n  else\n    if (jpeg_info.in_color_space == JCS_GRAYSCALE)\n      for (y=0; y < (ssize_t) image->rows; y++)\n      {\n        register const Quantum\n          *p;\n\n        register ssize_t\n          x;\n\n        p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n        if (p == (const Quantum *) NULL)\n          break;\n        q=jpeg_pixels;\n        for (x=0; x < (ssize_t) image->columns; x++)\n        {\n          *q++=(JSAMPLE) (ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,\n            p)))\/scale);\n          p+=GetPixelChannels(image);\n        }\n        (void) jpeg_write_scanlines(&jpeg_info,scanline,1);\n        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n          image->rows);\n        if (status == MagickFalse)\n          break;\n      }\n    else\n      if ((jpeg_info.in_color_space == JCS_RGB) ||\n          (jpeg_info.in_color_space == JCS_YCbCr))\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register const Quantum\n            *p;\n\n          register ssize_t\n            x;\n\n          p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n          if (p == (const Quantum *) NULL)\n            break;\n          q=jpeg_pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            *q++=(JSAMPLE) (ScaleQuantumToShort(GetPixelRed(image,p))\/scale);\n            *q++=(JSAMPLE) (ScaleQuantumToShort(GetPixelGreen(image,p))\/scale);\n            *q++=(JSAMPLE) (ScaleQuantumToShort(GetPixelBlue(image,p))\/scale);\n            p+=GetPixelChannels(image);\n          }\n          (void) jpeg_write_scanlines(&jpeg_info,scanline,1);\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n      else\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register const Quantum\n            *p;\n\n          register ssize_t\n            x;\n\n          p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n          if (p == (const Quantum *) NULL)\n            break;\n          q=jpeg_pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            \/*\n              Convert DirectClass packets to contiguous CMYK scanlines.\n            *\/\n            *q++=(JSAMPLE) (ScaleQuantumToShort(QuantumRange-GetPixelRed(\n              image,p))\/scale);\n            *q++=(JSAMPLE) (ScaleQuantumToShort(QuantumRange-GetPixelGreen(\n              image,p))\/scale);\n            *q++=(JSAMPLE) (ScaleQuantumToShort(QuantumRange-GetPixelBlue(\n              image,p))\/scale);\n            *q++=(JSAMPLE) (ScaleQuantumToShort(QuantumRange-GetPixelBlack(\n              image,p))\/scale);\n            p+=GetPixelChannels(image);\n          }\n          (void) jpeg_write_scanlines(&jpeg_info,scanline,1);\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n  if (y == (ssize_t) image->rows)\n    jpeg_finish_compress(&jpeg_info);\n  \/*\n    Relinquish resources.\n  *\/\n  jpeg_destroy_compress(&jpeg_info);\n  memory_info=RelinquishVirtualMemory(memory_info);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":6649,"total_token_length":6885,"max_tokens_setting":8192}
+{"idx":8962,"func":"static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)\n{\n\tconst unsigned char *cursor, *limit, *marker, *start;\n\tzval *rval_ref;\n\n\tlimit = max;\n\tcursor = *p;\n\n\tif (YYCURSOR >= YYLIMIT) {\n\t\treturn 0;\n\t}\n\n\tif (var_hash && (*p)[0] != 'R') {\n\t\tvar_push(var_hash, rval);\n\t}\n\n\tstart = cursor;\n\n\n#line 554 \"ext\/standard\/var_unserializer.c\"\n{\n\tYYCTYPE yych;\n\tstatic const unsigned char yybm[] = {\n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t128, 128, 128, 128, 128, 128, 128, 128, \n\t\t128, 128,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t};\n\n\tif ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);\n\tyych = *YYCURSOR;\n\tswitch (yych) {\n\tcase 'C':\n\tcase 'O':\tgoto yy13;\n\tcase 'N':\tgoto yy5;\n\tcase 'R':\tgoto yy2;\n\tcase 'S':\tgoto yy10;\n\tcase 'a':\tgoto yy11;\n\tcase 'b':\tgoto yy6;\n\tcase 'd':\tgoto yy8;\n\tcase 'i':\tgoto yy7;\n\tcase 'o':\tgoto yy12;\n\tcase 'r':\tgoto yy4;\n\tcase 's':\tgoto yy9;\n\tcase '}':\tgoto yy14;\n\tdefault:\tgoto yy16;\n\t}\nyy2:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy95;\nyy3:\n#line 884 \"ext\/standard\/var_unserializer.re\"\n\t{ return 0; }\n#line 580 \"ext\/standard\/var_unserializer.c\"\nyy4:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy89;\n\tgoto yy3;\nyy5:\n\tyych = *++YYCURSOR;\n\tif (yych == ';') goto yy87;\n\tgoto yy3;\nyy6:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy83;\n\tgoto yy3;\nyy7:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy77;\n\tgoto yy3;\nyy8:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy53;\n\tgoto yy3;\nyy9:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy46;\n\tgoto yy3;\nyy10:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy39;\n\tgoto yy3;\nyy11:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy32;\n\tgoto yy3;\nyy12:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy25;\n\tgoto yy3;\nyy13:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy17;\n\tgoto yy3;\nyy14:\n\t++YYCURSOR;\n#line 878 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t\/* this is the case where we have less data than planned *\/\n\tphp_error_docref(NULL, E_NOTICE, \"Unexpected end of serialized data\");\n\treturn 0; \/* not sure if it should be 0 or 1 here? *\/\n}\n#line 629 \"ext\/standard\/var_unserializer.c\"\nyy16:\n\tyych = *++YYCURSOR;\n\tgoto yy3;\nyy17:\n\tyych = *++YYCURSOR;\n\tif (yybm[0+yych] & 128) {\n\t\tgoto yy20;\n\t}\n\tif (yych == '+') goto yy19;\nyy18:\n\tYYCURSOR = YYMARKER;\n\tgoto yy3;\nyy19:\n\tyych = *++YYCURSOR;\n\tif (yybm[0+yych] & 128) {\n\t\tgoto yy20;\n\t}\n\tgoto yy18;\nyy20:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yybm[0+yych] & 128) {\n\t\tgoto yy20;\n\t}\n\tif (yych != ':') goto yy18;\n\tyych = *++YYCURSOR;\n\tif (yych != '\"') goto yy18;\n\t++YYCURSOR;\n#line 733 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tsize_t len, len2, len3, maxlen;\n\tzend_long elements;\n\tchar *str;\n\tzend_string *class_name;\n\tzend_class_entry *ce;\n\tint incomplete_class = 0;\n\n\tint custom_object = 0;\n\n\tzval user_func;\n\tzval retval;\n\tzval args[1];\n\n    if (!var_hash) return 0;\n\tif (*start == 'C') {\n\t\tcustom_object = 1;\n\t}\n\n\tlen2 = len = parse_uiv(start + 2);\n\tmaxlen = max - YYCURSOR;\n\tif (maxlen < len || len == 0) {\n\t\t*p = start + 2;\n\t\treturn 0;\n\t}\n\n\tstr = (char*)YYCURSOR;\n\n\tYYCURSOR += len;\n\n\tif (*(YYCURSOR) != '\"') {\n\t\t*p = YYCURSOR;\n\t\treturn 0;\n\t}\n\tif (*(YYCURSOR+1) != ':') {\n\t\t*p = YYCURSOR+1;\n\t\treturn 0;\n\t}\n\n\tlen3 = strspn(str, \"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\177\\200\\201\\202\\203\\204\\205\\206\\207\\210\\211\\212\\213\\214\\215\\216\\217\\220\\221\\222\\223\\224\\225\\226\\227\\230\\231\\232\\233\\234\\235\\236\\237\\240\\241\\242\\243\\244\\245\\246\\247\\250\\251\\252\\253\\254\\255\\256\\257\\260\\261\\262\\263\\264\\265\\266\\267\\270\\271\\272\\273\\274\\275\\276\\277\\300\\301\\302\\303\\304\\305\\306\\307\\310\\311\\312\\313\\314\\315\\316\\317\\320\\321\\322\\323\\324\\325\\326\\327\\330\\331\\332\\333\\334\\335\\336\\337\\340\\341\\342\\343\\344\\345\\346\\347\\350\\351\\352\\353\\354\\355\\356\\357\\360\\361\\362\\363\\364\\365\\366\\367\\370\\371\\372\\373\\374\\375\\376\\377\\\\\");\n\tif (len3 != len)\n\t{\n\t\t*p = YYCURSOR + len3 - len;\n\t\treturn 0;\n\t}\n\n\tclass_name = zend_string_init(str, len, 0);\n\n\tdo {\n\t\tif(!unserialize_allowed_class(class_name, classes)) {\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Try to find class directly *\/\n\t\tBG(serialize_lock)++;\n\t\tce = zend_lookup_class(class_name);\n\t\tif (ce) {\n\t\t\tBG(serialize_lock)--;\n\t\t\tif (EG(exception)) {\n\t\t\t\tzend_string_release(class_name);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tBG(serialize_lock)--;\n\n\t\tif (EG(exception)) {\n\t\t\tzend_string_release(class_name);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* Check for unserialize callback *\/\n\t\tif ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\\0')) {\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Call unserialize callback *\/\n\t\tZVAL_STRING(&user_func, PG(unserialize_callback_func));\n\n\t\tZVAL_STR_COPY(&args[0], class_name);\n\t\tBG(serialize_lock)++;\n\t\tif (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL) != SUCCESS) {\n\t\t\tBG(serialize_lock)--;\n\t\t\tif (EG(exception)) {\n\t\t\t\tzend_string_release(class_name);\n\t\t\t\tzval_ptr_dtor(&user_func);\n\t\t\t\tzval_ptr_dtor(&args[0]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tphp_error_docref(NULL, E_WARNING, \"defined (%s) but not found\", Z_STRVAL(user_func));\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t\tzval_ptr_dtor(&user_func);\n\t\t\tzval_ptr_dtor(&args[0]);\n\t\t\tbreak;\n\t\t}\n\t\tBG(serialize_lock)--;\n\t\tzval_ptr_dtor(&retval);\n\t\tif (EG(exception)) {\n\t\t\tzend_string_release(class_name);\n\t\t\tzval_ptr_dtor(&user_func);\n\t\t\tzval_ptr_dtor(&args[0]);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* The callback function may have defined the class *\/\n\t\tif ((ce = zend_lookup_class(class_name)) == NULL) {\n\t\t\tphp_error_docref(NULL, E_WARNING, \"Function %s() hasn't defined the class it was called for\", Z_STRVAL(user_func));\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t}\n\n\t\tzval_ptr_dtor(&user_func);\n\t\tzval_ptr_dtor(&args[0]);\n\t\tbreak;\n\t} while (1);\n\n\t*p = YYCURSOR;\n\n\tif (custom_object) {\n\t\tint ret;\n\n\t\tret = object_custom(UNSERIALIZE_PASSTHRU, ce);\n\n\t\tif (ret && incomplete_class) {\n\t\t\tphp_store_class_name(rval, ZSTR_VAL(class_name), len2);\n\t\t}\n\t\tzend_string_release(class_name);\n\t\treturn ret;\n\t}\n\n\telements = object_common1(UNSERIALIZE_PASSTHRU, ce);\n\n\tif (incomplete_class) {\n\t\tphp_store_class_name(rval, ZSTR_VAL(class_name), len2);\n\t}\n\tzend_string_release(class_name);\n\n\treturn object_common2(UNSERIALIZE_PASSTHRU, elements);\n}\n#line 804 \"ext\/standard\/var_unserializer.c\"\nyy25:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych != '+') goto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy26;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy27;\n\t\tgoto yy18;\n\t}\nyy26:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy27:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy27;\n\tif (yych >= ';') goto yy18;\n\tyych = *++YYCURSOR;\n\tif (yych != '\"') goto yy18;\n\t++YYCURSOR;\n#line 726 \"ext\/standard\/var_unserializer.re\"\n\t{\n    if (!var_hash) return 0;\n\n\treturn object_common2(UNSERIALIZE_PASSTHRU,\n\t\t\tobject_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));\n}\n#line 836 \"ext\/standard\/var_unserializer.c\"\nyy32:\n\tyych = *++YYCURSOR;\n\tif (yych == '+') goto yy33;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy34;\n\tgoto yy18;\nyy33:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy34:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy34;\n\tif (yych >= ';') goto yy18;\n\tyych = *++YYCURSOR;\n\tif (yych != '{') goto yy18;\n\t++YYCURSOR;\n#line 702 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long elements = parse_iv(start + 2);\n\t\/* use iv() not uiv() in order to check data range *\/\n\t*p = YYCURSOR;\n    if (!var_hash) return 0;\n\n\tif (elements < 0) {\n\t\treturn 0;\n\t}\n\n\tarray_init_size(rval, elements);\n\tif (elements) {\n\t\t\/* we can't convert from packed to hash during unserialization, because\n\t\t   reference to some zvals might be keept in var_hash (to support references) *\/\n\t\tzend_hash_real_init(Z_ARRVAL_P(rval), 0);\n\t}\n\n\tif (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_P(rval), elements, 0)) {\n\t\treturn 0;\n\t}\n\n\treturn finish_nested_data(UNSERIALIZE_PASSTHRU);\n}\n#line 881 \"ext\/standard\/var_unserializer.c\"\nyy39:\n\tyych = *++YYCURSOR;\n\tif (yych == '+') goto yy40;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy41;\n\tgoto yy18;\nyy40:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy41:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy41;\n\tif (yych >= ';') goto yy18;\n\tyych = *++YYCURSOR;\n\tif (yych != '\"') goto yy18;\n\t++YYCURSOR;\n#line 668 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tsize_t len, maxlen;\n\tzend_string *str;\n\n\tlen = parse_uiv(start + 2);\n\tmaxlen = max - YYCURSOR;\n\tif (maxlen < len) {\n\t\t*p = start + 2;\n\t\treturn 0;\n\t}\n\n\tif ((str = unserialize_str(&YYCURSOR, len, maxlen)) == NULL) {\n\t\treturn 0;\n\t}\n\n\tif (*(YYCURSOR) != '\"') {\n\t\tzend_string_free(str);\n\t\t*p = YYCURSOR;\n\t\treturn 0;\n\t}\n\n\tif (*(YYCURSOR + 1) != ';') {\n\t\tefree(str);\n\t\t*p = YYCURSOR + 1;\n\t\treturn 0;\n\t}\n\n\tYYCURSOR += 2;\n\t*p = YYCURSOR;\n\n\tZVAL_STR(rval, str);\n\treturn 1;\n}\n#line 936 \"ext\/standard\/var_unserializer.c\"\nyy46:\n\tyych = *++YYCURSOR;\n\tif (yych == '+') goto yy47;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy48;\n\tgoto yy18;\nyy47:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy48:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy48;\n\tif (yych >= ';') goto yy18;\n\tyych = *++YYCURSOR;\n\tif (yych != '\"') goto yy18;\n\t++YYCURSOR;\n#line 636 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tsize_t len, maxlen;\n\tchar *str;\n\n\tlen = parse_uiv(start + 2);\n\tmaxlen = max - YYCURSOR;\n\tif (maxlen < len) {\n\t\t*p = start + 2;\n\t\treturn 0;\n\t}\n\n\tstr = (char*)YYCURSOR;\n\n\tYYCURSOR += len;\n\n\tif (*(YYCURSOR) != '\"') {\n\t\t*p = YYCURSOR;\n\t\treturn 0;\n\t}\n\n\tif (*(YYCURSOR + 1) != ';') {\n\t\t*p = YYCURSOR + 1;\n\t\treturn 0;\n\t}\n\n\tYYCURSOR += 2;\n\t*p = YYCURSOR;\n\n\tZVAL_STRINGL(rval, str, len);\n\treturn 1;\n}\n#line 989 \"ext\/standard\/var_unserializer.c\"\nyy53:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') {\n\t\tif (yych <= ',') {\n\t\t\tif (yych == '+') goto yy57;\n\t\t\tgoto yy18;\n\t\t} else {\n\t\t\tif (yych <= '-') goto yy55;\n\t\t\tif (yych <= '.') goto yy60;\n\t\t\tgoto yy18;\n\t\t}\n\t} else {\n\t\tif (yych <= 'I') {\n\t\t\tif (yych <= '9') goto yy58;\n\t\t\tif (yych <= 'H') goto yy18;\n\t\t\tgoto yy56;\n\t\t} else {\n\t\t\tif (yych != 'N') goto yy18;\n\t\t}\n\t}\n\tyych = *++YYCURSOR;\n\tif (yych == 'A') goto yy76;\n\tgoto yy18;\nyy55:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') {\n\t\tif (yych == '.') goto yy60;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '9') goto yy58;\n\t\tif (yych != 'I') goto yy18;\n\t}\nyy56:\n\tyych = *++YYCURSOR;\n\tif (yych == 'N') goto yy72;\n\tgoto yy18;\nyy57:\n\tyych = *++YYCURSOR;\n\tif (yych == '.') goto yy60;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy58:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);\n\tyych = *YYCURSOR;\n\tif (yych <= ':') {\n\t\tif (yych <= '.') {\n\t\t\tif (yych <= '-') goto yy18;\n\t\t\tgoto yy70;\n\t\t} else {\n\t\t\tif (yych <= '\/') goto yy18;\n\t\t\tif (yych <= '9') goto yy58;\n\t\t\tgoto yy18;\n\t\t}\n\t} else {\n\t\tif (yych <= 'E') {\n\t\t\tif (yych <= ';') goto yy63;\n\t\t\tif (yych <= 'D') goto yy18;\n\t\t\tgoto yy65;\n\t\t} else {\n\t\t\tif (yych == 'e') goto yy65;\n\t\t\tgoto yy18;\n\t\t}\n\t}\nyy60:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy61:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);\n\tyych = *YYCURSOR;\n\tif (yych <= ';') {\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy61;\n\t\tif (yych <= ':') goto yy18;\n\t} else {\n\t\tif (yych <= 'E') {\n\t\t\tif (yych <= 'D') goto yy18;\n\t\t\tgoto yy65;\n\t\t} else {\n\t\t\tif (yych == 'e') goto yy65;\n\t\t\tgoto yy18;\n\t\t}\n\t}\nyy63:\n\t++YYCURSOR;\n#line 627 \"ext\/standard\/var_unserializer.re\"\n\t{\n#if SIZEOF_ZEND_LONG == 4\nuse_double:\n#endif\n\t*p = YYCURSOR;\n\tZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));\n\treturn 1;\n}\n#line 1086 \"ext\/standard\/var_unserializer.c\"\nyy65:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych != '+') goto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy66;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy67;\n\t\tgoto yy18;\n\t}\nyy66:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy69;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy69;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych >= ':') goto yy18;\n\t}\nyy67:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy67;\n\tif (yych == ';') goto yy63;\n\tgoto yy18;\nyy69:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy67;\n\tgoto yy18;\nyy70:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);\n\tyych = *YYCURSOR;\n\tif (yych <= ';') {\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy70;\n\t\tif (yych <= ':') goto yy18;\n\t\tgoto yy63;\n\t} else {\n\t\tif (yych <= 'E') {\n\t\t\tif (yych <= 'D') goto yy18;\n\t\t\tgoto yy65;\n\t\t} else {\n\t\t\tif (yych == 'e') goto yy65;\n\t\t\tgoto yy18;\n\t\t}\n\t}\nyy72:\n\tyych = *++YYCURSOR;\n\tif (yych != 'F') goto yy18;\nyy73:\n\tyych = *++YYCURSOR;\n\tif (yych != ';') goto yy18;\n\t++YYCURSOR;\n#line 611 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t*p = YYCURSOR;\n\n\tif (!strncmp((char*)start + 2, \"NAN\", 3)) {\n\t\tZVAL_DOUBLE(rval, php_get_nan());\n\t} else if (!strncmp((char*)start + 2, \"INF\", 3)) {\n\t\tZVAL_DOUBLE(rval, php_get_inf());\n\t} else if (!strncmp((char*)start + 2, \"-INF\", 4)) {\n\t\tZVAL_DOUBLE(rval, -php_get_inf());\n\t} else {\n\t\tZVAL_NULL(rval);\n\t}\n\n\treturn 1;\n}\n#line 1161 \"ext\/standard\/var_unserializer.c\"\nyy76:\n\tyych = *++YYCURSOR;\n\tif (yych == 'N') goto yy73;\n\tgoto yy18;\nyy77:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych != '+') goto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy78;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy79;\n\t\tgoto yy18;\n\t}\nyy78:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy79:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy79;\n\tif (yych != ';') goto yy18;\n\t++YYCURSOR;\n#line 585 \"ext\/standard\/var_unserializer.re\"\n\t{\n#if SIZEOF_ZEND_LONG == 4\n\tint digits = YYCURSOR - start - 3;\n\n\tif (start[2] == '-' || start[2] == '+') {\n\t\tdigits--;\n\t}\n\n\t\/* Use double for large zend_long values that were serialized on a 64-bit system *\/\n\tif (digits >= MAX_LENGTH_OF_LONG - 1) {\n\t\tif (digits == MAX_LENGTH_OF_LONG - 1) {\n\t\t\tint cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1);\n\n\t\t\tif (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) {\n\t\t\t\tgoto use_double;\n\t\t\t}\n\t\t} else {\n\t\t\tgoto use_double;\n\t\t}\n\t}\n#endif\n\t*p = YYCURSOR;\n\tZVAL_LONG(rval, parse_iv(start + 2));\n\treturn 1;\n}\n#line 1214 \"ext\/standard\/var_unserializer.c\"\nyy83:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= '2') goto yy18;\n\tyych = *++YYCURSOR;\n\tif (yych != ';') goto yy18;\n\t++YYCURSOR;\n#line 579 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t*p = YYCURSOR;\n\tZVAL_BOOL(rval, parse_iv(start + 2));\n\treturn 1;\n}\n#line 1228 \"ext\/standard\/var_unserializer.c\"\nyy87:\n\t++YYCURSOR;\n#line 573 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t*p = YYCURSOR;\n\tZVAL_NULL(rval);\n\treturn 1;\n}\n#line 1237 \"ext\/standard\/var_unserializer.c\"\nyy89:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych != '+') goto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy90;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy91;\n\t\tgoto yy18;\n\t}\nyy90:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy91:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy91;\n\tif (yych != ';') goto yy18;\n\t++YYCURSOR;\n#line 548 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long id;\n\n \t*p = YYCURSOR;\n\tif (!var_hash) return 0;\n\n\tid = parse_iv(start + 2) - 1;\n\tif (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) {\n\t\treturn 0;\n\t}\n\n\tif (rval_ref == rval) {\n\t\treturn 0;\n\t}\n\n\tif (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {\n\t\tZVAL_UNDEF(rval);\n\t\treturn 1;\n\t}\n\n\tZVAL_COPY(rval, rval_ref);\n\n\treturn 1;\n}\n#line 1285 \"ext\/standard\/var_unserializer.c\"\nyy95:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych != '+') goto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy96;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy97;\n\t\tgoto yy18;\n\t}\nyy96:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy97:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy97;\n\tif (yych != ';') goto yy18;\n\t++YYCURSOR;\n#line 522 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long id;\n\n \t*p = YYCURSOR;\n\tif (!var_hash) return 0;\n\n\tid = parse_iv(start + 2) - 1;\n\tif (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) {\n\t\treturn 0;\n\t}\n\n\tzval_ptr_dtor(rval);\n\tif (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {\n\t\tZVAL_UNDEF(rval);\n\t\treturn 1;\n\t}\n\tif (Z_ISREF_P(rval_ref)) {\n\t\tZVAL_COPY(rval, rval_ref);\n\t} else {\n\t\tZVAL_NEW_REF(rval_ref, rval_ref);\n\t\tZVAL_COPY(rval, rval_ref);\n\t}\n\n\treturn 1;\n}\n#line 1334 \"ext\/standard\/var_unserializer.c\"\n}\n#line 886 \"ext\/standard\/var_unserializer.re\"\n\n\n\treturn 0;\n}","target":1,"code_token_length":7912,"total_token_length":8148,"max_tokens_setting":8192}
+{"idx":698,"func":"unsigned long # define BN_LONG long # define BN_BITS 128 # define BN_BYTES 8 # define BN_BITS2 64 # define BN_BITS4 32 # define BN_MASK ( 0xffffffffffffffffffffffffffffffffLL ) # define BN_MASK2 ( 0xffffffffffffffffL ) # define BN_MASK2l ( 0xffffffffL ) # define BN_MASK2h ( 0xffffffff00000000L ) # define BN_MASK2h1 ( 0xffffffff80000000L ) # define BN_TBIT ( 0x8000000000000000L ) # define BN_DEC_CONV ( 10000000000000000000UL ) # define BN_DEC_FMT1 \"%lu\" # define BN_DEC_FMT2 \"%019lu\" # define BN_DEC_NUM 19 # define BN_HEX_FMT1 \"%lX\" # define BN_HEX_FMT2 \"%016lX\" # endif # ifdef SIXTY_FOUR_BIT # undef BN_LLONG # undef BN_ULLONG # define BN_ULONG unsigned long long # define BN_LONG long long # define BN_BITS 128 # define BN_BYTES 8 # define BN_BITS2 64 # define BN_BITS4 32 # define BN_MASK2 ( 0xffffffffffffffffLL ) # define BN_MASK2l ( 0xffffffffL ) # define BN_MASK2h ( 0xffffffff00000000LL ) # define BN_MASK2h1 ( 0xffffffff80000000LL ) # define BN_TBIT ( 0x8000000000000000LL ) # define BN_DEC_CONV ( 10000000000000000000ULL ) # define BN_DEC_FMT1 \"%llu\" # define BN_DEC_FMT2 \"%019llu\" # define BN_DEC_NUM 19 # define BN_HEX_FMT1 \"%llX\" # define BN_HEX_FMT2 \"%016llX\" # endif # ifdef THIRTY_TWO_BIT # ifdef BN_LLONG # if defined ( _WIN32 ) && ! defined ( __GNUC__ ) # define BN_ULLONG unsigned __int64 # define BN_MASK ( 0xffffffffffffffffI64 ) # else # define BN_ULLONG unsigned long long # define BN_MASK ( 0xffffffffffffffffLL ) # endif # endif # define BN_ULONG unsigned int # define BN_LONG int # define BN_BITS 64 # define BN_BYTES 4 # define BN_BITS2 32 # define BN_BITS4 16 # define BN_MASK2 ( 0xffffffffL ) # define BN_MASK2l ( 0xffff ) # define BN_MASK2h1 ( 0xffff8000L ) # define BN_MASK2h ( 0xffff0000L ) # define BN_TBIT ( 0x80000000L ) # define BN_DEC_CONV ( 1000000000L ) # define BN_DEC_FMT1 \"%u\" # define BN_DEC_FMT2 \"%09u\" # define BN_DEC_NUM 9 # define BN_HEX_FMT1 \"%X\" # define BN_HEX_FMT2 \"%08X\" # endif # define BN_DEFAULT_BITS 1280 # define BN_FLG_MALLOCED 0x01 # define BN_FLG_STATIC_DATA 0x02 # define BN_FLG_CONSTTIME 0x04 # ifndef OPENSSL_NO_DEPRECATED # define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME # endif # ifndef OPENSSL_NO_DEPRECATED # define BN_FLG_FREE 0x8000 # endif # define BN_set_flags ( b , n ) ( ( b ) -> flags |= ( n ) ) # define BN_get_flags ( b , n ) ( ( b ) -> flags & ( n ) ) # define BN_with_flags ( dest , b , n ) ( ( dest ) -> d = ( b ) -> d , \\ ( dest ) -> top = ( b ) -> top , \\ ( dest ) -> dmax = ( b ) -> dmax , \\ ( dest ) -> neg = ( b ) -> neg , \\ ( dest ) -> flags = ( ( ( dest ) -> flags & BN_FLG_MALLOCED ) \\ | ( ( b ) -> flags & ~ BN_FLG_MALLOCED ) \\ | BN_FLG_STATIC_DATA \\ | ( n ) ) ) # if 0 typedef struct bignum_st BIGNUM ;\n typedef struct bignum_ctx BN_CTX ;\n typedef struct bn_blinding_st BN_BLINDING ;\n typedef struct bn_mont_ctx_st BN_MONT_CTX ;\n typedef struct bn_recp_ctx_st BN_RECP_CTX ;\n typedef struct bn_gencb_st BN_GENCB ;\n # endif struct bignum_st {\n BN_ULONG * d ;\n int top ;\n int dmax ;\n int neg ;\n int flags ;\n }\n ;\n struct bn_mont_ctx_st {\n int ri ;\n BIGNUM RR ;\n BIGNUM N ;\n BIGNUM Ni ;\n BN_ULONG n0 [ 2 ] ;\n int flags ;\n }\n ;\n struct bn_recp_ctx_st {\n BIGNUM N ;\n BIGNUM Nr ;\n int num_bits ;\n int shift ;\n int flags ;\n }\n ;\n struct bn_gencb_st {\n unsigned int ver ;\n void * arg ;\n union {\n void ( * cb_1 ) ( int , int , void * ) ;\n int ( * cb_2 ) ( int , int , BN_GENCB * ) ;\n }\n cb ;\n }\n ;\n int BN_GENCB_call ( BN_GENCB * cb , int a , int b ) ;\n # define BN_GENCB_set_old ( gencb , callback , cb_arg ) {\n \\ BN_GENCB * tmp_gencb = ( gencb ) ;\n \\ tmp_gencb -> ver = 1 ;\n \\ tmp_gencb -> arg = ( cb_arg ) ;\n \\ tmp_gencb -> cb . cb_1 = ( callback ) ;\n }\n # define BN_GENCB_set ( gencb , callback , cb_arg ) {\n \\ BN_GENCB * tmp_gencb = ( gencb ) ;\n \\ tmp_gencb -> ver = 2 ;\n \\ tmp_gencb -> arg = ( cb_arg ) ;\n \\ tmp_gencb -> cb . cb_2 = ( callback ) ;\n }\n # define BN_prime_checks 0 # define BN_prime_checks_for_size ( b ) ( ( b ) >= 1300 ? 2 : \\ ( b ) >= 850 ? 3 : \\ ( b ) >= 650 ? 4 : \\ ( b ) >= 550 ? 5 : \\ ( b ) >= 450 ? 6 : \\ ( b ) >= 400 ? 7 : \\ ( b ) >= 350 ? 8 : \\ ( b ) >= 300 ? 9 : \\ ( b ) >= 250 ? 12 : \\ ( b ) >= 200 ? 15 : \\ ( b ) >= 150 ? 18 : \\ 27 ) # define BN_num_bytes ( a ) ( ( BN_num_bits ( a ) + 7 ) \/ 8 ) # define BN_abs_is_word ( a , w ) ( ( ( ( a ) -> top == 1 ) && ( ( a ) -> d [ 0 ] == ( BN_ULONG ) ( w ) ) ) || \\ ( ( ( w ) == 0 ) && ( ( a ) -> top == 0 ) ) ) # define BN_is_zero ( a ) ( ( a ) -> top == 0 ) # define BN_is_one ( a ) ( BN_abs_is_word ( ( a ) , 1 ) && ! ( a ) -> neg ) # define BN_is_word ( a , w ) ( BN_abs_is_word ( ( a ) , ( w ) ) && ( ! ( w ) || ! ( a ) -> neg ) ) # define BN_is_odd ( a ) ( ( ( a ) -> top > 0 ) && ( ( a ) -> d [ 0 ] & 1 ) ) # define BN_one ( a ) ( BN_set_word ( ( a ) , 1 ) ) # define BN_zero_ex ( a ) \\ do {\n \\ BIGNUM * _tmp_bn = ( a ) ;\n \\ _tmp_bn -> top = 0 ;\n \\ _tmp_bn -> neg = 0 ;\n \\ }\n while ( 0 ) # ifdef OPENSSL_NO_DEPRECATED # define BN_zero ( a ) BN_zero_ex ( a ) # else # define BN_zero ( a ) ( BN_set_word ( ( a ) , 0 ) ) # endif const BIGNUM * BN_value_one ( void ) ;\n char * BN_options ( void ) ;\n BN_CTX * BN_CTX_new ( void ) ;\n # ifndef OPENSSL_NO_DEPRECATED void BN_CTX_init ( BN_CTX * c ) ;\n # endif void BN_CTX_free ( BN_CTX * c ) ;\n void BN_CTX_start ( BN_CTX * ctx ) ;\n BIGNUM * BN_CTX_get ( BN_CTX * ctx ) ;\n void BN_CTX_end ( BN_CTX * ctx ) ;\n int BN_rand ( BIGNUM * rnd , int bits , int top , int bottom ) ;\n int BN_pseudo_rand ( BIGNUM * rnd , int bits , int top , int bottom ) ;\n int BN_rand_range ( BIGNUM * rnd , const BIGNUM * range ) ;\n int BN_pseudo_rand_range ( BIGNUM * rnd , const BIGNUM * range ) ;\n int BN_num_bits ( const BIGNUM * a ) ;\n int BN_num_bits_word ( BN_ULONG l ) ;\n BIGNUM * BN_new ( void ) ;\n void BN_init ( BIGNUM * ) ;\n void BN_clear_free ( BIGNUM * a ) ;\n BIGNUM * BN_copy ( BIGNUM * a , const BIGNUM * b ) ;\n void BN_swap ( BIGNUM * a , BIGNUM * b ) ;\n BIGNUM * BN_bin2bn ( const unsigned char * s , int len , BIGNUM * ret ) ;\n int BN_bn2bin ( const BIGNUM * a , unsigned char * to ) ;\n BIGNUM * BN_mpi2bn ( const unsigned char * s , int len , BIGNUM * ret ) ;\n int BN_bn2mpi ( const BIGNUM * a , unsigned char * to ) ;\n int BN_sub ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_usub ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_uadd ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_add ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n int BN_mul ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , BN_CTX * ctx ) ;\n int BN_sqr ( BIGNUM * r , const BIGNUM * a , BN_CTX * ctx ) ;\n void BN_set_negative ( BIGNUM * b , int n ) ;\n # define BN_is_negative ( a ) ( ( a ) -> neg != 0 ) int BN_div ( BIGNUM * dv , BIGNUM * rem , const BIGNUM * m , const BIGNUM * d , BN_CTX * ctx ) ;\n # define BN_mod ( rem , m , d , ctx ) BN_div ( NULL , ( rem ) , ( m ) , ( d ) , ( ctx ) ) int BN_nnmod ( BIGNUM * r , const BIGNUM * m , const BIGNUM * d , BN_CTX * ctx ) ;\n int BN_mod_add ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_add_quick ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m ) ;\n int BN_mod_sub ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_sub_quick ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m ) ;\n int BN_mod_mul ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_sqr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_lshift1 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_lshift1_quick ( BIGNUM * r , const BIGNUM * a , const BIGNUM * m ) ;\n int BN_mod_lshift ( BIGNUM * r , const BIGNUM * a , int n , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_lshift_quick ( BIGNUM * r , const BIGNUM * a , int n , const BIGNUM * m ) ;\n BN_ULONG BN_mod_word ( const BIGNUM * a , BN_ULONG w ) ;\n BN_ULONG BN_div_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_mul_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_add_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_sub_word ( BIGNUM * a , BN_ULONG w ) ;\n int BN_set_word ( BIGNUM * a , BN_ULONG w ) ;\n BN_ULONG BN_get_word ( const BIGNUM * a ) ;\n int BN_cmp ( const BIGNUM * a , const BIGNUM * b ) ;\n void BN_free ( BIGNUM * a ) ;\n int BN_is_bit_set ( const BIGNUM * a , int n ) ;\n int BN_lshift ( BIGNUM * r , const BIGNUM * a , int n ) ;\n int BN_lshift1 ( BIGNUM * r , const BIGNUM * a ) ;\n int BN_exp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_mod_exp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mod_exp_mont ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) ;\n int BN_mod_exp_mont_consttime ( BIGNUM * rr , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * in_mont ) ;\n int BN_mod_exp_mont_word ( BIGNUM * r , BN_ULONG a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) ;\n int BN_mod_exp2_mont ( BIGNUM * r , const BIGNUM * a1 , const BIGNUM * p1 , const BIGNUM * a2 , const BIGNUM * p2 , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) ;\n int BN_mod_exp_simple ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_mask_bits ( BIGNUM * a , int n ) ;\n # ifndef OPENSSL_NO_FP_API int BN_print_fp ( FILE * fp , const BIGNUM * a ) ;\n # endif # ifdef HEADER_BIO_H int BN_print ( BIO * fp , const BIGNUM * a ) ;\n # else int BN_print ( void * fp , const BIGNUM * a ) ;\n # endif int BN_reciprocal ( BIGNUM * r , const BIGNUM * m , int len , BN_CTX * ctx ) ;\n int BN_rshift ( BIGNUM * r , const BIGNUM * a , int n ) ;\n int BN_rshift1 ( BIGNUM * r , const BIGNUM * a ) ;\n void BN_clear ( BIGNUM * a ) ;\n BIGNUM * BN_dup ( const BIGNUM * a ) ;\n int BN_ucmp ( const BIGNUM * a , const BIGNUM * b ) ;\n int BN_set_bit ( BIGNUM * a , int n ) ;\n int BN_clear_bit ( BIGNUM * a , int n ) ;\n char * BN_bn2hex ( const BIGNUM * a ) ;\n char * BN_bn2dec ( const BIGNUM * a ) ;\n int BN_hex2bn ( BIGNUM * * a , const char * str ) ;\n int BN_dec2bn ( BIGNUM * * a , const char * str ) ;\n int BN_asc2bn ( BIGNUM * * a , const char * str ) ;\n int BN_gcd ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , BN_CTX * ctx ) ;\n int BN_kronecker ( const BIGNUM * a , const BIGNUM * b , BN_CTX * ctx ) ;\n BIGNUM * BN_mod_inverse ( BIGNUM * ret , const BIGNUM * a , const BIGNUM * n , BN_CTX * ctx ) ;\n BIGNUM * BN_mod_sqrt ( BIGNUM * ret , const BIGNUM * a , const BIGNUM * n , BN_CTX * ctx ) ;\n # ifndef OPENSSL_NO_DEPRECATED BIGNUM * BN_generate_prime ( BIGNUM * ret , int bits , int safe , const BIGNUM * add , const BIGNUM * rem , void ( * callback ) ( int , int , void * ) , void * cb_arg ) ;\n int BN_is_prime ( const BIGNUM * p , int nchecks , void ( * callback ) ( int , int , void * ) , BN_CTX * ctx , void * cb_arg ) ;\n int BN_is_prime_fasttest ( const BIGNUM * p , int nchecks , void ( * callback ) ( int , int , void * ) , BN_CTX * ctx , void * cb_arg , int do_trial_division ) ;\n # endif int BN_generate_prime_ex ( BIGNUM * ret , int bits , int safe , const BIGNUM * add , const BIGNUM * rem , BN_GENCB * cb ) ;\n int BN_is_prime_ex ( const BIGNUM * p , int nchecks , BN_CTX * ctx , BN_GENCB * cb ) ;\n int BN_is_prime_fasttest_ex ( const BIGNUM * p , int nchecks , BN_CTX * ctx , int do_trial_division , BN_GENCB * cb ) ;\n int BN_X931_generate_Xpq ( BIGNUM * Xp , BIGNUM * Xq , int nbits , BN_CTX * ctx ) ;\n int BN_X931_derive_prime_ex ( BIGNUM * p , BIGNUM * p1 , BIGNUM * p2 , const BIGNUM * Xp , const BIGNUM * Xp1 , const BIGNUM * Xp2 , const BIGNUM * e , BN_CTX * ctx , BN_GENCB * cb ) ;\n int BN_X931_generate_prime_ex ( BIGNUM * p , BIGNUM * p1 , BIGNUM * p2 , BIGNUM * Xp1 , BIGNUM * Xp2 , const BIGNUM * Xp , const BIGNUM * e , BN_CTX * ctx , BN_GENCB * cb ) ;\n BN_MONT_CTX * BN_MONT_CTX_new ( void ) ;\n void BN_MONT_CTX_init ( BN_MONT_CTX * ctx ) ;\n int BN_mod_mul_montgomery ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , BN_MONT_CTX * mont , BN_CTX * ctx ) ;\n # define BN_to_montgomery ( r , a , mont , ctx ) BN_mod_mul_montgomery ( \\ ( r ) , ( a ) , & ( ( mont ) -> RR ) , ( mont ) , ( ctx ) ) int BN_from_montgomery ( BIGNUM * r , const BIGNUM * a , BN_MONT_CTX * mont , BN_CTX * ctx ) ;\n void BN_MONT_CTX_free ( BN_MONT_CTX * mont ) ;\n int BN_MONT_CTX_set ( BN_MONT_CTX * mont , const BIGNUM * mod , BN_CTX * ctx ) ;\n BN_MONT_CTX * BN_MONT_CTX_copy ( BN_MONT_CTX * to , BN_MONT_CTX * from ) ;\n BN_MONT_CTX * BN_MONT_CTX_set_locked ( BN_MONT_CTX * * pmont , int lock , const BIGNUM * mod , BN_CTX * ctx ) ;\n # define BN_BLINDING_NO_UPDATE 0x00000001 # define BN_BLINDING_NO_RECREATE 0x00000002 BN_BLINDING * BN_BLINDING_new ( const BIGNUM * A , const BIGNUM * Ai , BIGNUM * mod ) ;\n void BN_BLINDING_free ( BN_BLINDING * b ) ;\n int BN_BLINDING_update ( BN_BLINDING * b , BN_CTX * ctx ) ;\n int BN_BLINDING_convert ( BIGNUM * n , BN_BLINDING * b , BN_CTX * ctx ) ;\n int BN_BLINDING_invert ( BIGNUM * n , BN_BLINDING * b , BN_CTX * ctx ) ;\n int BN_BLINDING_convert_ex ( BIGNUM * n , BIGNUM * r , BN_BLINDING * b , BN_CTX * ) ;\n int BN_BLINDING_invert_ex ( BIGNUM * n , const BIGNUM * r , BN_BLINDING * b , BN_CTX * ) ;\n # ifndef OPENSSL_NO_DEPRECATED unsigned long BN_BLINDING_get_thread_id ( const BN_BLINDING * ) ;\n void BN_BLINDING_set_thread_id ( BN_BLINDING * , unsigned long ) ;\n # endif CRYPTO_THREADID * BN_BLINDING_thread_id ( BN_BLINDING * ) ;\n unsigned long BN_BLINDING_get_flags ( const BN_BLINDING * ) ;\n void BN_BLINDING_set_flags ( BN_BLINDING * , unsigned long ) ;\n BN_BLINDING * BN_BLINDING_create_param ( BN_BLINDING * b , const BIGNUM * e , BIGNUM * m , BN_CTX * ctx , int ( * bn_mod_exp ) ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx , BN_MONT_CTX * m_ctx ) , BN_MONT_CTX * m_ctx ) ;\n # ifndef OPENSSL_NO_DEPRECATED void BN_set_params ( int mul , int high , int low , int mont ) ;\n int BN_get_params ( int which ) ;\n # endif void BN_RECP_CTX_init ( BN_RECP_CTX * recp ) ;\n BN_RECP_CTX * BN_RECP_CTX_new ( void ) ;\n void BN_RECP_CTX_free ( BN_RECP_CTX * recp ) ;\n int BN_RECP_CTX_set ( BN_RECP_CTX * recp , const BIGNUM * rdiv , BN_CTX * ctx ) ;\n int BN_mod_mul_reciprocal ( BIGNUM * r , const BIGNUM * x , const BIGNUM * y , BN_RECP_CTX * recp , BN_CTX * ctx ) ;\n int BN_mod_exp_recp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , const BIGNUM * m , BN_CTX * ctx ) ;\n int BN_div_recp ( BIGNUM * dv , BIGNUM * rem , const BIGNUM * m , BN_RECP_CTX * recp , BN_CTX * ctx ) ;\n # ifndef OPENSSL_NO_EC2M int BN_GF2m_add ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b ) ;\n # define BN_GF2m_sub ( r , a , b ) BN_GF2m_add ( r , a , b ) int BN_GF2m_mod ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p ) ;\n int BN_GF2m_mod_mul ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_inv ( BIGNUM * r , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_div ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_exp ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqrt ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_GF2m_mod_solve_quad ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n # define BN_GF2m_cmp ( a , b ) BN_ucmp ( ( a ) , ( b ) ) int BN_GF2m_mod_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] ) ;\n int BN_GF2m_mod_mul_arr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqr_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_inv_arr ( BIGNUM * r , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_div_arr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_exp_arr ( BIGNUM * r , const BIGNUM * a , const BIGNUM * b , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_sqrt_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_mod_solve_quad_arr ( BIGNUM * r , const BIGNUM * a , const int p [ ] , BN_CTX * ctx ) ;\n int BN_GF2m_poly2arr ( const BIGNUM * a , int p [ ] , int max ) ;\n int BN_GF2m_arr2poly ( const int p [ ] , BIGNUM * a ) ;\n # endif int BN_nist_mod_192 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_224 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_256 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_384 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n int BN_nist_mod_521 ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) ;\n const BIGNUM * BN_get0_nist_prime_192 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_224 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_256 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_384 ( void ) ;\n const BIGNUM * BN_get0_nist_prime_521 ( void ) ;\n int ( * BN_nist_mod_func ( const BIGNUM * p ) ) ( BIGNUM * r , const BIGNUM * a , const BIGNUM * field , BN_CTX * ctx ) ;\n int BN_generate_dsa_nonce ( BIGNUM * out , const BIGNUM * range , const BIGNUM * priv , const unsigned char * message , size_t message_len , BN_CTX * ctx ) ;\n # define bn_expand ( a , bits ) ( ( ( ( ( ( bits + BN_BITS2 - 1 ) ) \/ BN_BITS2 ) ) <= ( a ) -> dmax ) ? \\ ( a ) : bn_expand2 ( ( a ) , ( bits + BN_BITS2 - 1 ) \/ BN_BITS2 ) ) # define bn_wexpand ( a , words ) ( ( ( words ) <= ( a ) -> dmax ) ? ( a ) : bn_expand2 ( ( a ) , ( words ) ) ) BIGNUM * bn_expand2 ( BIGNUM * a , int words ) ;\n # ifndef OPENSSL_NO_DEPRECATED BIGNUM * bn_dup_expand ( const BIGNUM * a , int words ) ;\n # endif # ifdef BN_DEBUG # include < assert . h > # ifdef BN_DEBUG_RAND # ifndef RAND_pseudo_bytes int RAND_pseudo_bytes ( unsigned char * buf , int num ) ;\n # define BN_DEBUG_TRIX # endif # define bn_pollute ( a ) \\ do {\n \\ const BIGNUM * _bnum1 = ( a ) ;\n \\ if ( _bnum1 -> top < _bnum1 -> dmax ) {\n \\ unsigned char _tmp_char ;\n \\ \\ BN_ULONG * _not_const ;\n \\ memcpy ( & _not_const , & _bnum1 -> d , sizeof ( BN_ULONG * ) ) ;\n \\ RAND_pseudo_bytes ( & _tmp_char , 1 ) ;\n \\ memset ( ( unsigned char * ) ( _not_const + _bnum1 -> top ) , _tmp_char , \\ ( _bnum1 -> dmax - _bnum1 -> top ) * sizeof ( BN_ULONG ) ) ;\n \\ }\n \\ }\n while ( 0 ) # ifdef BN_DEBUG_TRIX # undef RAND_pseudo_bytes # endif # else # define bn_pollute ( a ) # endif # define bn_check_top ( a ) \\ do {\n \\ const BIGNUM * _bnum2 = ( a ) ;\n \\ if ( _bnum2 != NULL ) {\n \\ assert ( ( _bnum2 -> top == 0 ) || \\ ( _bnum2 -> d [ _bnum2 -> top - 1 ] != 0 ) ) ;\n \\ bn_pollute ( _bnum2 ) ;\n \\ }\n \\ }\n while ( 0 ) # define bn_fix_top ( a ) bn_check_top ( a ) # else # define bn_pollute ( a ) # define bn_check_top ( a ) # define bn_fix_top ( a ) bn_correct_top ( a ) # endif # define bn_correct_top ( a ) \\ {\n \\ BN_ULONG * ftl ;\n \\ int tmp_top = ( a ) -> top ;\n \\ if ( tmp_top > 0 ) \\ {\n \\ for ( ftl = & ( ( a ) -> d [ tmp_top - 1 ] ) ;\n tmp_top > 0 ;\n tmp_top -- ) \\ if ( * ( ftl -- ) ) break ;\n \\ ( a ) -> top = tmp_top ;\n \\ }\n \\ bn_pollute ( a ) ;\n \\ }\n BN_ULONG bn_mul_add_words ( BN_ULONG * rp , const BN_ULONG * ap , int num , BN_ULONG w ) ;\n BN_ULONG bn_mul_words ( BN_ULONG * rp , const BN_ULONG * ap , int num , BN_ULONG w ) ;\n void bn_sqr_words ( BN_ULONG * rp , const BN_ULONG * ap , int num ) ;\n BN_ULONG bn_div_words ( BN_ULONG h , BN_ULONG l , BN_ULONG d ) ;\n BN_ULONG bn_add_words ( BN_ULONG * rp , const BN_ULONG * ap , const BN_ULONG * bp , int num )","target":1,"code_token_length":7019,"total_token_length":7255,"max_tokens_setting":8192}
+{"idx":147171,"func":"irc_server_print_log ()\n{\n    struct t_irc_server *ptr_server;\n    struct t_irc_channel *ptr_channel;\n    int i;\n\n    for (ptr_server = irc_servers; ptr_server;\n         ptr_server = ptr_server->next_server)\n    {\n        weechat_log_printf (\"\");\n        weechat_log_printf (\"[server %s (addr:0x%lx)]\", ptr_server->name, ptr_server);\n        \/* addresses *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_ADDRESSES]))\n            weechat_log_printf (\"  addresses. . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_ADDRESSES));\n        else\n            weechat_log_printf (\"  addresses. . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_ADDRESSES]));\n        \/* proxy *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PROXY]))\n            weechat_log_printf (\"  proxy. . . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_PROXY));\n        else\n            weechat_log_printf (\"  proxy. . . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_PROXY]));\n        \/* ipv6 *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_IPV6]))\n            weechat_log_printf (\"  ipv6 . . . . . . . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_IPV6)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  ipv6 . . . . . . . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6])) ?\n                                \"on\" : \"off\");\n        \/* ssl *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL]))\n            weechat_log_printf (\"  ssl. . . . . . . . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_SSL)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  ssl. . . . . . . . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL])) ?\n                                \"on\" : \"off\");\n        \/* ssl_cert *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT]))\n            weechat_log_printf (\"  ssl_cert . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SSL_CERT));\n        else\n            weechat_log_printf (\"  ssl_cert . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT]));\n        \/* ssl_password *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_PASSWORD]))\n            weechat_log_printf (\"  ssl_password . . . . : null\");\n        else\n            weechat_log_printf (\"  ssl_password . . . . : (hidden)\");\n        \/* ssl_priorities *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_PRIORITIES]))\n            weechat_log_printf (\"  ssl_priorities . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SSL_PRIORITIES));\n        else\n            weechat_log_printf (\"  ssl_priorities . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_SSL_PRIORITIES]));\n        \/* ssl_dhkey_size *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE]))\n            weechat_log_printf (\"  ssl_dhkey_size . . . : null ('%d')\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE));\n        else\n            weechat_log_printf (\"  ssl_dhkey_size . . . : '%d'\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE]));\n        \/* ssl_fingerprint *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_FINGERPRINT]))\n            weechat_log_printf (\"  ssl_fingerprint. . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SSL_FINGERPRINT));\n        else\n            weechat_log_printf (\"  ssl_fingerprint. . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_SSL_FINGERPRINT]));\n        \/* ssl_verify *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY]))\n            weechat_log_printf (\"  ssl_verify . . . . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_SSL_VERIFY)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  ssl_verify . . . . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ?\n                                \"on\" : \"off\");\n        \/* password *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PASSWORD]))\n            weechat_log_printf (\"  password . . . . . . : null\");\n        else\n            weechat_log_printf (\"  password . . . . . . : (hidden)\");\n        \/* client capabilities *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_CAPABILITIES]))\n            weechat_log_printf (\"  capabilities . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_CAPABILITIES));\n        else\n            weechat_log_printf (\"  capabilities . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_CAPABILITIES]));\n        \/* sasl_mechanism *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_MECHANISM]))\n            weechat_log_printf (\"  sasl_mechanism . . . : null ('%s')\",\n                                irc_sasl_mechanism_string[IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_SASL_MECHANISM)]);\n        else\n            weechat_log_printf (\"  sasl_mechanism . . . : '%s'\",\n                                irc_sasl_mechanism_string[weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_SASL_MECHANISM])]);\n        \/* sasl_username *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_USERNAME]))\n            weechat_log_printf (\"  sasl_username. . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SASL_USERNAME));\n        else\n            weechat_log_printf (\"  sasl_username. . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_SASL_USERNAME]));\n        \/* sasl_password *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_PASSWORD]))\n            weechat_log_printf (\"  sasl_password. . . . : null\");\n        else\n            weechat_log_printf (\"  sasl_password. . . . : (hidden)\");\n        \/* sasl_key *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_KEY]))\n            weechat_log_printf (\"  sasl_key. .  . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SASL_KEY));\n        else\n            weechat_log_printf (\"  sasl_key. .  . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_SASL_KEY]));\n        \/* sasl_fail *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_FAIL]))\n            weechat_log_printf (\"  sasl_fail. . . . . . : null ('%s')\",\n                                irc_server_sasl_fail_string[IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_SASL_FAIL)]);\n        else\n            weechat_log_printf (\"  sasl_fail. . . . . . : '%s'\",\n                                irc_server_sasl_fail_string[weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_SASL_FAIL])]);\n        \/* autoconnect *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT]))\n            weechat_log_printf (\"  autoconnect. . . . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTOCONNECT)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  autoconnect. . . . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ?\n                                \"on\" : \"off\");\n        \/* autoreconnect *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]))\n            weechat_log_printf (\"  autoreconnect. . . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTORECONNECT)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  autoreconnect. . . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ?\n                                \"on\" : \"off\");\n        \/* autoreconnect_delay *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))\n            weechat_log_printf (\"  autoreconnect_delay. : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY));\n        else\n            weechat_log_printf (\"  autoreconnect_delay. : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]));\n        \/* nicks *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_NICKS]))\n            weechat_log_printf (\"  nicks. . . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_NICKS));\n        else\n            weechat_log_printf (\"  nicks. . . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_NICKS]));\n        \/* nicks_alternate *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE]))\n            weechat_log_printf (\"  nicks_alternate. . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  nicks_alternate. . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ?\n                                \"on\" : \"off\");\n        \/* username *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_USERNAME]))\n            weechat_log_printf (\"  username . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_USERNAME));\n        else\n            weechat_log_printf (\"  username . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_USERNAME]));\n        \/* realname *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_REALNAME]))\n            weechat_log_printf (\"  realname . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_REALNAME));\n        else\n            weechat_log_printf (\"  realname . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_REALNAME]));\n        \/* local_hostname *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]))\n            weechat_log_printf (\"  local_hostname . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_LOCAL_HOSTNAME));\n        else\n            weechat_log_printf (\"  local_hostname . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]));\n        \/* usermode *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_USERMODE]))\n            weechat_log_printf (\"  usermode . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_USERMODE));\n        else\n            weechat_log_printf (\"  usermode . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_USERMODE]));\n        \/* command *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_COMMAND]))\n            weechat_log_printf (\"  command. . . . . . . : null\");\n        else\n            weechat_log_printf (\"  command. . . . . . . : (hidden)\");\n        \/* command_delay *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_COMMAND_DELAY]))\n            weechat_log_printf (\"  command_delay. . . . : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_COMMAND_DELAY));\n        else\n            weechat_log_printf (\"  command_delay. . . . : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_COMMAND_DELAY]));\n        \/* autojoin *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOJOIN]))\n            weechat_log_printf (\"  autojoin . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_AUTOJOIN));\n        else\n            weechat_log_printf (\"  autojoin . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_AUTOJOIN]));\n        \/* autorejoin *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN]))\n            weechat_log_printf (\"  autorejoin . . . . . : null (%s)\",\n                                (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTOREJOIN)) ?\n                                \"on\" : \"off\");\n        else\n            weechat_log_printf (\"  autorejoin . . . . . : %s\",\n                                (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ?\n                                \"on\" : \"off\");\n        \/* autorejoin_delay *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))\n            weechat_log_printf (\"  autorejoin_delay . . : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY));\n        else\n            weechat_log_printf (\"  autorejoin_delay . . : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]));\n        \/* connection_timeout *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]))\n            weechat_log_printf (\"  connection_timeout . : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT));\n        else\n            weechat_log_printf (\"  connection_timeout . : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]));\n        \/* anti_flood_prio_high *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]))\n            weechat_log_printf (\"  anti_flood_prio_high : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH));\n        else\n            weechat_log_printf (\"  anti_flood_prio_high : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]));\n        \/* anti_flood_prio_low *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]))\n            weechat_log_printf (\"  anti_flood_prio_low. : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW));\n        else\n            weechat_log_printf (\"  anti_flood_prio_low. : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]));\n        \/* away_check *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK]))\n            weechat_log_printf (\"  away_check . . . . . : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK));\n        else\n            weechat_log_printf (\"  away_check . . . . . : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK]));\n        \/* away_check_max_nicks *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]))\n            weechat_log_printf (\"  away_check_max_nicks : null (%d)\",\n                                IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS));\n        else\n            weechat_log_printf (\"  away_check_max_nicks : %d\",\n                                weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]));\n        \/* msg_kick *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_KICK]))\n            weechat_log_printf (\"  msg_kick . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_KICK));\n        else\n            weechat_log_printf (\"  msg_kick . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_KICK]));\n        \/* msg_part *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_PART]))\n            weechat_log_printf (\"  msg_part . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_PART));\n        else\n            weechat_log_printf (\"  msg_part . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_PART]));\n        \/* msg_quit *\/\n        if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT]))\n            weechat_log_printf (\"  msg_quit . . . . . . : null ('%s')\",\n                                IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_MSG_QUIT));\n        else\n            weechat_log_printf (\"  msg_quit . . . . . . : '%s'\",\n                                weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT]));\n        \/* other server variables *\/\n        weechat_log_printf (\"  temp_server. . . . . : %d\",    ptr_server->temp_server);\n        weechat_log_printf (\"  reloading_from_config: %d\",    ptr_server->reloaded_from_config);\n        weechat_log_printf (\"  reloaded_from_config : %d\",    ptr_server->reloaded_from_config);\n        weechat_log_printf (\"  addresses_eval . . . : '%s'\",  ptr_server->addresses_eval);\n        weechat_log_printf (\"  addresses_count. . . : %d\",    ptr_server->addresses_count);\n        weechat_log_printf (\"  addresses_array. . . : 0x%lx\", ptr_server->addresses_array);\n        weechat_log_printf (\"  ports_array. . . . . : 0x%lx\", ptr_server->ports_array);\n        weechat_log_printf (\"  retry_array. . . . . : 0x%lx\", ptr_server->retry_array);\n        weechat_log_printf (\"  index_current_address: %d\",    ptr_server->index_current_address);\n        weechat_log_printf (\"  current_address. . . : '%s'\",  ptr_server->current_address);\n        weechat_log_printf (\"  current_ip . . . . . : '%s'\",  ptr_server->current_ip);\n        weechat_log_printf (\"  current_port . . . . : %d\",    ptr_server->current_port);\n        weechat_log_printf (\"  current_retry. . . . : %d\",    ptr_server->current_retry);\n        weechat_log_printf (\"  sock . . . . . . . . : %d\",    ptr_server->sock);\n        weechat_log_printf (\"  hook_connect . . . . : 0x%lx\", ptr_server->hook_connect);\n        weechat_log_printf (\"  hook_fd. . . . . . . : 0x%lx\", ptr_server->hook_fd);\n        weechat_log_printf (\"  hook_timer_connection: 0x%lx\", ptr_server->hook_timer_connection);\n        weechat_log_printf (\"  hook_timer_sasl. . . : 0x%lx\", ptr_server->hook_timer_sasl);\n        weechat_log_printf (\"  is_connected . . . . : %d\",    ptr_server->is_connected);\n        weechat_log_printf (\"  ssl_connected. . . . : %d\",    ptr_server->ssl_connected);\n        weechat_log_printf (\"  disconnected . . . . : %d\",    ptr_server->disconnected);\n#ifdef HAVE_GNUTLS\n        weechat_log_printf (\"  gnutls_sess. . . . . : 0x%lx\", ptr_server->gnutls_sess);\n#endif \/* HAVE_GNUTLS *\/\n        weechat_log_printf (\"  unterminated_message : '%s'\",  ptr_server->unterminated_message);\n        weechat_log_printf (\"  nicks_count. . . . . : %d\",    ptr_server->nicks_count);\n        weechat_log_printf (\"  nicks_array. . . . . : 0x%lx\", ptr_server->nicks_array);\n        weechat_log_printf (\"  nick_first_tried . . : %d\",    ptr_server->nick_first_tried);\n        weechat_log_printf (\"  nick_alternate_number: %d\",    ptr_server->nick_alternate_number);\n        weechat_log_printf (\"  nick . . . . . . . . : '%s'\",  ptr_server->nick);\n        weechat_log_printf (\"  nick_modes . . . . . : '%s'\",  ptr_server->nick_modes);\n        weechat_log_printf (\"  host . . . . . . . . : '%s'\",  ptr_server->host);\n        weechat_log_printf (\"  checking_cap_ls. . . : %d\",    ptr_server->checking_cap_ls);\n        weechat_log_printf (\"  cap_ls . . . . . . . : 0x%lx (hashtable: '%s')\",\n                            ptr_server->cap_ls,\n                            weechat_hashtable_get_string (ptr_server->cap_ls, \"keys_values\"));\n        weechat_log_printf (\"  checking_cap_list. . : %d\",    ptr_server->checking_cap_list);\n        weechat_log_printf (\"  cap_list . . . . . . : 0x%lx (hashtable: '%s')\",\n                            ptr_server->cap_list,\n                            weechat_hashtable_get_string (ptr_server->cap_list, \"keys_values\"));\n        weechat_log_printf (\"  isupport . . . . . . : '%s'\",  ptr_server->isupport);\n        weechat_log_printf (\"  prefix_modes . . . . : '%s'\",  ptr_server->prefix_modes);\n        weechat_log_printf (\"  prefix_chars . . . . : '%s'\",  ptr_server->prefix_chars);\n        weechat_log_printf (\"  nick_max_length. . . : %d\",    ptr_server->nick_max_length);\n        weechat_log_printf (\"  user_max_length. . . : %d\",    ptr_server->user_max_length);\n        weechat_log_printf (\"  host_max_length. . . : %d\",    ptr_server->host_max_length);\n        weechat_log_printf (\"  casemapping. . . . . : %d (%s)\",\n                            ptr_server->casemapping,\n                            irc_server_casemapping_string[ptr_server->casemapping]);\n        weechat_log_printf (\"  chantypes. . . . . . : '%s'\",  ptr_server->chantypes);\n        weechat_log_printf (\"  chanmodes. . . . . . : '%s'\",  ptr_server->chanmodes);\n        weechat_log_printf (\"  monitor. . . . . . . : %d\",    ptr_server->monitor);\n        weechat_log_printf (\"  monitor_time . . . . : %lld\",  (long long)ptr_server->monitor_time);\n        weechat_log_printf (\"  reconnect_delay. . . : %d\",    ptr_server->reconnect_delay);\n        weechat_log_printf (\"  reconnect_start. . . : %lld\",  (long long)ptr_server->reconnect_start);\n        weechat_log_printf (\"  command_time . . . . : %lld\",  (long long)ptr_server->command_time);\n        weechat_log_printf (\"  reconnect_join . . . : %d\",    ptr_server->reconnect_join);\n        weechat_log_printf (\"  disable_autojoin . . : %d\",    ptr_server->disable_autojoin);\n        weechat_log_printf (\"  is_away. . . . . . . : %d\",    ptr_server->is_away);\n        weechat_log_printf (\"  away_message . . . . : '%s'\",  ptr_server->away_message);\n        weechat_log_printf (\"  away_time. . . . . . : %lld\",  (long long)ptr_server->away_time);\n        weechat_log_printf (\"  lag. . . . . . . . . : %d\",    ptr_server->lag);\n        weechat_log_printf (\"  lag_displayed. . . . : %d\",    ptr_server->lag_displayed);\n        weechat_log_printf (\"  lag_check_time . . . : tv_sec:%d, tv_usec:%d\",\n                            ptr_server->lag_check_time.tv_sec,\n                            ptr_server->lag_check_time.tv_usec);\n        weechat_log_printf (\"  lag_next_check . . . : %lld\",  (long long)ptr_server->lag_next_check);\n        weechat_log_printf (\"  lag_last_refresh . . : %lld\",  (long long)ptr_server->lag_last_refresh);\n        weechat_log_printf (\"  cmd_list_regexp. . . : 0x%lx\", ptr_server->cmd_list_regexp);\n        weechat_log_printf (\"  last_user_message. . : %lld\",  (long long)ptr_server->last_user_message);\n        weechat_log_printf (\"  last_away_check. . . : %lld\",  (long long)ptr_server->last_away_check);\n        weechat_log_printf (\"  last_data_purge. . . : %lld\",  (long long)ptr_server->last_data_purge);\n        for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)\n        {\n            weechat_log_printf (\"  outqueue[%02d] . . . . : 0x%lx\", i, ptr_server->outqueue[i]);\n            weechat_log_printf (\"  last_outqueue[%02d]. . : 0x%lx\", i, ptr_server->last_outqueue[i]);\n        }\n        weechat_log_printf (\"  redirects. . . . . . : 0x%lx\", ptr_server->redirects);\n        weechat_log_printf (\"  last_redirect. . . . : 0x%lx\", ptr_server->last_redirect);\n        weechat_log_printf (\"  notify_list. . . . . : 0x%lx\", ptr_server->notify_list);\n        weechat_log_printf (\"  last_notify. . . . . : 0x%lx\", ptr_server->last_notify);\n        weechat_log_printf (\"  notify_count . . . . : %d\",    ptr_server->notify_count);\n        weechat_log_printf (\"  join_manual. . . . . : 0x%lx (hashtable: '%s')\",\n                            ptr_server->join_manual,\n                            weechat_hashtable_get_string (ptr_server->join_manual, \"keys_values\"));\n        weechat_log_printf (\"  join_channel_key . . : 0x%lx (hashtable: '%s')\",\n                            ptr_server->join_channel_key,\n                            weechat_hashtable_get_string (ptr_server->join_channel_key, \"keys_values\"));\n        weechat_log_printf (\"  join_noswitch. . . . : 0x%lx (hashtable: '%s')\",\n                            ptr_server->join_noswitch,\n                            weechat_hashtable_get_string (ptr_server->join_noswitch, \"keys_values\"));\n        weechat_log_printf (\"  buffer . . . . . . . : 0x%lx\", ptr_server->buffer);\n        weechat_log_printf (\"  buffer_as_string . . : 0x%lx\", ptr_server->buffer_as_string);\n        weechat_log_printf (\"  channels . . . . . . : 0x%lx\", ptr_server->channels);\n        weechat_log_printf (\"  last_channel . . . . : 0x%lx\", ptr_server->last_channel);\n        weechat_log_printf (\"  prev_server. . . . . : 0x%lx\", ptr_server->prev_server);\n        weechat_log_printf (\"  next_server. . . . . : 0x%lx\", ptr_server->next_server);\n\n        irc_redirect_print_log (ptr_server);\n\n        irc_notify_print_log (ptr_server);\n\n        for (ptr_channel = ptr_server->channels; ptr_channel;\n             ptr_channel = ptr_channel->next_channel)\n        {\n            irc_channel_print_log (ptr_channel);\n        }\n    }\n}","target":0,"code_token_length":6691,"total_token_length":6927,"max_tokens_setting":8192}
+{"idx":129539,"func":"static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image)\n{\n  const char\n    *option;\n\n  Image\n    *next_image;\n\n  MagickBooleanType\n    status;\n\n  volatile MagickBooleanType\n    logging;\n\n  MngInfo\n    *mng_info;\n\n  int\n    image_count,\n    need_iterations,\n    need_matte;\n\n  volatile int\n#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \\\n    defined(PNG_MNG_FEATURES_SUPPORTED)\n    need_local_plte,\n#endif\n    all_images_are_gray,\n    need_defi,\n    use_global_plte;\n\n  register ssize_t\n    i;\n\n  unsigned char\n    chunk[800];\n\n  volatile unsigned int\n    write_jng,\n    write_mng;\n\n  volatile size_t\n    scene;\n\n  size_t\n    final_delay=0,\n    initial_delay,\n    imageListLength;\n\n#if (PNG_LIBPNG_VER < 10200)\n    if (image_info->verbose)\n      printf(\"Your PNG library (libpng-%s) is rather old.\\n\",\n         PNG_LIBPNG_VER_STRING);\n#endif\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  logging=LogMagickEvent(CoderEvent,GetMagickModule(),\"Enter WriteMNGImage()\");\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n\n  \/*\n    Allocate a MngInfo structure.\n  *\/\n  mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo));\n  if (mng_info == (MngInfo *) NULL)\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  \/*\n    Initialize members of the MngInfo structure.\n  *\/\n  (void) memset(mng_info,0,sizeof(MngInfo));\n  mng_info->image=image;\n  write_mng=LocaleCompare(image_info->magick,\"MNG\") == 0;\n\n  \/*\n   * See if user has requested a specific PNG subformat to be used\n   * for all of the PNGs in the MNG being written, e.g.,\n   *\n   *    convert *.png png8:animation.mng\n   *\n   * To do: check -define png:bit_depth and png:color_type as well,\n   * or perhaps use mng:bit_depth and mng:color_type instead for\n   * global settings.\n   *\/\n\n  mng_info->write_png8=LocaleCompare(image_info->magick,\"PNG8\") == 0;\n  mng_info->write_png24=LocaleCompare(image_info->magick,\"PNG24\") == 0;\n  mng_info->write_png32=LocaleCompare(image_info->magick,\"PNG32\") == 0;\n\n  write_jng=MagickFalse;\n  if (image_info->compression == JPEGCompression)\n    write_jng=MagickTrue;\n\n  mng_info->adjoin=image_info->adjoin &&\n    (GetNextImageInList(image) != (Image *) NULL) && write_mng;\n\n  if (logging != MagickFalse)\n    {\n      \/* Log some info about the input *\/\n      Image\n        *p;\n\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Checking input image(s)\\n\"\n        \"    Image_info depth: %.20g,    Type: %d\",\n        (double) image_info->depth, image_info->type);\n\n      scene=0;\n      for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))\n      {\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"    Scene: %.20g\\n,   Image depth: %.20g\",\n          (double) scene++, (double) p->depth);\n\n        if (p->matte)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"      Matte: True\");\n\n        else\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"      Matte: False\");\n\n        if (p->storage_class == PseudoClass)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"      Storage class: PseudoClass\");\n\n        else\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"      Storage class: DirectClass\");\n\n        if (p->colors)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"      Number of colors: %.20g\",(double) p->colors);\n\n        else\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"      Number of colors: unspecified\");\n\n        if (mng_info->adjoin == MagickFalse)\n          break;\n      }\n    }\n\n  use_global_plte=MagickFalse;\n  all_images_are_gray=MagickFalse;\n#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED\n  need_local_plte=MagickTrue;\n#endif\n  need_defi=MagickFalse;\n  need_matte=MagickFalse;\n  mng_info->framing_mode=1;\n  mng_info->old_framing_mode=1;\n\n  if (write_mng)\n      if (image_info->page != (char *) NULL)\n        {\n          \/*\n            Determine image bounding box.\n          *\/\n          SetGeometry(image,&mng_info->page);\n          (void) ParseMetaGeometry(image_info->page,&mng_info->page.x,\n            &mng_info->page.y,&mng_info->page.width,&mng_info->page.height);\n        }\n  if (write_mng)\n    {\n      unsigned int\n        need_geom;\n\n      unsigned short\n        red,\n        green,\n        blue;\n\n      mng_info->page=image->page;\n      need_geom=MagickTrue;\n      if (mng_info->page.width || mng_info->page.height)\n         need_geom=MagickFalse;\n      \/*\n        Check all the scenes.\n      *\/\n      initial_delay=image->delay;\n      need_iterations=MagickFalse;\n      mng_info->equal_chrms=image->chromaticity.red_primary.x != 0.0;\n      mng_info->equal_physs=MagickTrue,\n      mng_info->equal_gammas=MagickTrue;\n      mng_info->equal_srgbs=MagickTrue;\n      mng_info->equal_backgrounds=MagickTrue;\n      image_count=0;\n#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \\\n    defined(PNG_MNG_FEATURES_SUPPORTED)\n      all_images_are_gray=MagickTrue;\n      mng_info->equal_palettes=MagickFalse;\n      need_local_plte=MagickFalse;\n#endif\n      for (next_image=image; next_image != (Image *) NULL; )\n      {\n        if (need_geom)\n          {\n            if ((next_image->columns+next_image->page.x) > mng_info->page.width)\n              mng_info->page.width=next_image->columns+next_image->page.x;\n\n            if ((next_image->rows+next_image->page.y) > mng_info->page.height)\n              mng_info->page.height=next_image->rows+next_image->page.y;\n          }\n\n        if (next_image->page.x || next_image->page.y)\n          need_defi=MagickTrue;\n\n        if (next_image->matte)\n          need_matte=MagickTrue;\n\n        if ((int) next_image->dispose >= BackgroundDispose)\n          if (next_image->matte || next_image->page.x || next_image->page.y ||\n              ((next_image->columns < mng_info->page.width) &&\n               (next_image->rows < mng_info->page.height)))\n            mng_info->need_fram=MagickTrue;\n\n        if (next_image->iterations)\n          need_iterations=MagickTrue;\n\n        final_delay=next_image->delay;\n\n        if (final_delay != initial_delay || final_delay > 1UL*\n           next_image->ticks_per_second)\n          mng_info->need_fram=1;\n\n#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \\\n    defined(PNG_MNG_FEATURES_SUPPORTED)\n        \/*\n          check for global palette possibility.\n        *\/\n        if (image->matte != MagickFalse)\n           need_local_plte=MagickTrue;\n\n        if (need_local_plte == 0)\n          {\n            if (SetImageGray(image,&image->exception) == MagickFalse)\n              all_images_are_gray=MagickFalse;\n            mng_info->equal_palettes=PalettesAreEqual(image,next_image);\n            if (use_global_plte == 0)\n              use_global_plte=mng_info->equal_palettes;\n            need_local_plte=!mng_info->equal_palettes;\n          }\n#endif\n        if (GetNextImageInList(next_image) != (Image *) NULL)\n          {\n            if (next_image->background_color.red !=\n                next_image->next->background_color.red ||\n                next_image->background_color.green !=\n                next_image->next->background_color.green ||\n                next_image->background_color.blue !=\n                next_image->next->background_color.blue)\n              mng_info->equal_backgrounds=MagickFalse;\n\n            if (next_image->gamma != next_image->next->gamma)\n              mng_info->equal_gammas=MagickFalse;\n\n            if (next_image->rendering_intent !=\n                next_image->next->rendering_intent)\n              mng_info->equal_srgbs=MagickFalse;\n\n            if ((next_image->units != next_image->next->units) ||\n                (next_image->x_resolution != next_image->next->x_resolution) ||\n                (next_image->y_resolution != next_image->next->y_resolution))\n              mng_info->equal_physs=MagickFalse;\n\n            if (mng_info->equal_chrms)\n              {\n                if (next_image->chromaticity.red_primary.x !=\n                    next_image->next->chromaticity.red_primary.x ||\n                    next_image->chromaticity.red_primary.y !=\n                    next_image->next->chromaticity.red_primary.y ||\n                    next_image->chromaticity.green_primary.x !=\n                    next_image->next->chromaticity.green_primary.x ||\n                    next_image->chromaticity.green_primary.y !=\n                    next_image->next->chromaticity.green_primary.y ||\n                    next_image->chromaticity.blue_primary.x !=\n                    next_image->next->chromaticity.blue_primary.x ||\n                    next_image->chromaticity.blue_primary.y !=\n                    next_image->next->chromaticity.blue_primary.y ||\n                    next_image->chromaticity.white_point.x !=\n                    next_image->next->chromaticity.white_point.x ||\n                    next_image->chromaticity.white_point.y !=\n                    next_image->next->chromaticity.white_point.y)\n                  mng_info->equal_chrms=MagickFalse;\n              }\n          }\n        image_count++;\n        next_image=GetNextImageInList(next_image);\n      }\n      if (image_count < 2)\n        {\n          mng_info->equal_backgrounds=MagickFalse;\n          mng_info->equal_chrms=MagickFalse;\n          mng_info->equal_gammas=MagickFalse;\n          mng_info->equal_srgbs=MagickFalse;\n          mng_info->equal_physs=MagickFalse;\n          use_global_plte=MagickFalse;\n#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED\n          need_local_plte=MagickTrue;\n#endif\n          need_iterations=MagickFalse;\n        }\n\n     if (mng_info->need_fram == MagickFalse)\n       {\n         \/*\n           Only certain framing rates 100\/n are exactly representable without\n           the FRAM chunk but we'll allow some slop in VLC files\n         *\/\n         if (final_delay == 0)\n           {\n             if (need_iterations != MagickFalse)\n               {\n                 \/*\n                   It's probably a GIF with loop; don't run it *too* fast.\n                 *\/\n                 if (mng_info->adjoin)\n                   {\n                     final_delay=10;\n                     (void) ThrowMagickException(&image->exception,\n                        GetMagickModule(),CoderWarning,\n                       \"input has zero delay between all frames; assuming\",\n                       \" 10 cs `%s'\",\"\");\n                   }\n               }\n             else\n               mng_info->ticks_per_second=0;\n           }\n         if (final_delay != 0)\n           mng_info->ticks_per_second=(png_uint_32)\n              (image->ticks_per_second\/final_delay);\n         if (final_delay > 50)\n           mng_info->ticks_per_second=2;\n\n         if (final_delay > 75)\n           mng_info->ticks_per_second=1;\n\n         if (final_delay > 125)\n           mng_info->need_fram=MagickTrue;\n\n         if (need_defi && final_delay > 2 && (final_delay != 4) &&\n            (final_delay != 5) && (final_delay != 10) && (final_delay != 20) &&\n            (final_delay != 25) && (final_delay != 50) &&\n            (final_delay != (size_t) image->ticks_per_second))\n           mng_info->need_fram=MagickTrue;  \/* make it exact; cannot be VLC *\/\n       }\n\n     if (mng_info->need_fram != MagickFalse)\n        mng_info->ticks_per_second=1UL*image->ticks_per_second;\n     \/*\n        If pseudocolor, we should also check to see if all the\n        palettes are identical and write a global PLTE if they are.\n        ..\/glennrp Feb 99.\n     *\/\n     \/*\n        Write the MNG version 1.0 signature and MHDR chunk.\n     *\/\n     (void) WriteBlob(image,8,(const unsigned char *) \"\\212MNG\\r\\n\\032\\n\");\n     (void) WriteBlobMSBULong(image,28L);  \/* chunk data length=28 *\/\n     PNGType(chunk,mng_MHDR);\n     LogPNGChunk(logging,mng_MHDR,28L);\n     PNGLong(chunk+4,(png_uint_32) mng_info->page.width);\n     PNGLong(chunk+8,(png_uint_32) mng_info->page.height);\n     PNGLong(chunk+12,mng_info->ticks_per_second);\n     PNGLong(chunk+16,0L);  \/* layer count=unknown *\/\n     PNGLong(chunk+20,0L);  \/* frame count=unknown *\/\n     PNGLong(chunk+24,0L);  \/* play time=unknown   *\/\n     if (write_jng)\n       {\n         if (need_matte)\n           {\n             if (need_defi || mng_info->need_fram || use_global_plte)\n               PNGLong(chunk+28,27L);    \/* simplicity=LC+JNG *\/\n\n             else\n               PNGLong(chunk+28,25L);    \/* simplicity=VLC+JNG *\/\n           }\n\n         else\n           {\n             if (need_defi || mng_info->need_fram || use_global_plte)\n               PNGLong(chunk+28,19L);  \/* simplicity=LC+JNG, no transparency *\/\n\n             else\n               PNGLong(chunk+28,17L);  \/* simplicity=VLC+JNG, no transparency *\/\n           }\n       }\n\n     else\n       {\n         if (need_matte)\n           {\n             if (need_defi || mng_info->need_fram || use_global_plte)\n               PNGLong(chunk+28,11L);    \/* simplicity=LC *\/\n\n             else\n               PNGLong(chunk+28,9L);    \/* simplicity=VLC *\/\n           }\n\n         else\n           {\n             if (need_defi || mng_info->need_fram || use_global_plte)\n               PNGLong(chunk+28,3L);    \/* simplicity=LC, no transparency *\/\n\n             else\n               PNGLong(chunk+28,1L);    \/* simplicity=VLC, no transparency *\/\n           }\n       }\n     (void) WriteBlob(image,32,chunk);\n     (void) WriteBlobMSBULong(image,crc32(0,chunk,32));\n     option=GetImageOption(image_info,\"mng:need-cacheoff\");\n     if (option != (const char *) NULL)\n       {\n         size_t\n           length;\n\n         \/*\n           Write \"nEED CACHEOFF\" to turn playback caching off for streaming MNG.\n         *\/\n         PNGType(chunk,mng_nEED);\n         length=CopyMagickString((char *) chunk+4,\"CACHEOFF\",20);\n         (void) WriteBlobMSBULong(image,(size_t) length);\n         LogPNGChunk(logging,mng_nEED,(size_t) length);\n         length+=4;\n         (void) WriteBlob(image,length,chunk);\n         (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) length));\n       }\n     if ((GetPreviousImageInList(image) == (Image *) NULL) &&\n         (GetNextImageInList(image) != (Image *) NULL) &&\n         (image->iterations != 1))\n       {\n         \/*\n           Write MNG TERM chunk\n         *\/\n         (void) WriteBlobMSBULong(image,10L);  \/* data length=10 *\/\n         PNGType(chunk,mng_TERM);\n         LogPNGChunk(logging,mng_TERM,10L);\n         chunk[4]=3;  \/* repeat animation *\/\n         chunk[5]=0;  \/* show last frame when done *\/\n         PNGLong(chunk+6,(png_uint_32) (mng_info->ticks_per_second*\n            final_delay\/MagickMax(image->ticks_per_second,1)));\n\n         if (image->iterations == 0)\n           PNGLong(chunk+10,PNG_UINT_31_MAX);\n\n         else\n           PNGLong(chunk+10,(png_uint_32) image->iterations);\n\n         if (logging != MagickFalse)\n           {\n             (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n               \"     TERM delay: %.20g\",(double) (mng_info->ticks_per_second*\n              final_delay\/MagickMax(image->ticks_per_second,1)));\n\n             if (image->iterations == 0)\n               (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                 \"     TERM iterations: %.20g\",(double) PNG_UINT_31_MAX);\n\n             else\n               (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                 \"     Image iterations: %.20g\",(double) image->iterations);\n           }\n         (void) WriteBlob(image,14,chunk);\n         (void) WriteBlobMSBULong(image,crc32(0,chunk,14));\n       }\n     \/*\n       To do: check for cHRM+gAMA == sRGB, and write sRGB instead.\n     *\/\n     if ((image->colorspace == sRGBColorspace || image->rendering_intent) &&\n          mng_info->equal_srgbs)\n       {\n         \/*\n           Write MNG sRGB chunk\n         *\/\n         (void) WriteBlobMSBULong(image,1L);\n         PNGType(chunk,mng_sRGB);\n         LogPNGChunk(logging,mng_sRGB,1L);\n\n         if (image->rendering_intent != UndefinedIntent)\n           chunk[4]=(unsigned char)\n             Magick_RenderingIntent_to_PNG_RenderingIntent(\n             (image->rendering_intent));\n\n         else\n           chunk[4]=(unsigned char)\n             Magick_RenderingIntent_to_PNG_RenderingIntent(\n               (PerceptualIntent));\n\n         (void) WriteBlob(image,5,chunk);\n         (void) WriteBlobMSBULong(image,crc32(0,chunk,5));\n         mng_info->have_write_global_srgb=MagickTrue;\n       }\n\n     else\n       {\n         if (image->gamma && mng_info->equal_gammas)\n           {\n             \/*\n                Write MNG gAMA chunk\n             *\/\n             (void) WriteBlobMSBULong(image,4L);\n             PNGType(chunk,mng_gAMA);\n             LogPNGChunk(logging,mng_gAMA,4L);\n             PNGLong(chunk+4,(png_uint_32) (100000*image->gamma+0.5));\n             (void) WriteBlob(image,8,chunk);\n             (void) WriteBlobMSBULong(image,crc32(0,chunk,8));\n             mng_info->have_write_global_gama=MagickTrue;\n           }\n         if (mng_info->equal_chrms)\n           {\n             PrimaryInfo\n               primary;\n\n             \/*\n                Write MNG cHRM chunk\n             *\/\n             (void) WriteBlobMSBULong(image,32L);\n             PNGType(chunk,mng_cHRM);\n             LogPNGChunk(logging,mng_cHRM,32L);\n             primary=image->chromaticity.white_point;\n             PNGLong(chunk+4,(png_uint_32) (100000*primary.x+0.5));\n             PNGLong(chunk+8,(png_uint_32) (100000*primary.y+0.5));\n             primary=image->chromaticity.red_primary;\n             PNGLong(chunk+12,(png_uint_32) (100000*primary.x+0.5));\n             PNGLong(chunk+16,(png_uint_32) (100000*primary.y+0.5));\n             primary=image->chromaticity.green_primary;\n             PNGLong(chunk+20,(png_uint_32) (100000*primary.x+0.5));\n             PNGLong(chunk+24,(png_uint_32) (100000*primary.y+0.5));\n             primary=image->chromaticity.blue_primary;\n             PNGLong(chunk+28,(png_uint_32) (100000*primary.x+0.5));\n             PNGLong(chunk+32,(png_uint_32) (100000*primary.y+0.5));\n             (void) WriteBlob(image,36,chunk);\n             (void) WriteBlobMSBULong(image,crc32(0,chunk,36));\n             mng_info->have_write_global_chrm=MagickTrue;\n           }\n       }\n     if (image->x_resolution && image->y_resolution && mng_info->equal_physs)\n       {\n         \/*\n            Write MNG pHYs chunk\n         *\/\n         (void) WriteBlobMSBULong(image,9L);\n         PNGType(chunk,mng_pHYs);\n         LogPNGChunk(logging,mng_pHYs,9L);\n\n         if (image->units == PixelsPerInchResolution)\n           {\n             PNGLong(chunk+4,(png_uint_32)\n               (image->x_resolution*100.0\/2.54+0.5));\n\n             PNGLong(chunk+8,(png_uint_32)\n               (image->y_resolution*100.0\/2.54+0.5));\n\n             chunk[12]=1;\n           }\n\n         else\n           {\n             if (image->units == PixelsPerCentimeterResolution)\n               {\n                 PNGLong(chunk+4,(png_uint_32)\n                   (image->x_resolution*100.0+0.5));\n\n                 PNGLong(chunk+8,(png_uint_32)\n                   (image->y_resolution*100.0+0.5));\n\n                 chunk[12]=1;\n               }\n\n             else\n               {\n                 PNGLong(chunk+4,(png_uint_32) (image->x_resolution+0.5));\n                 PNGLong(chunk+8,(png_uint_32) (image->y_resolution+0.5));\n                 chunk[12]=0;\n               }\n           }\n         (void) WriteBlob(image,13,chunk);\n         (void) WriteBlobMSBULong(image,crc32(0,chunk,13));\n       }\n     \/*\n       Write MNG BACK chunk and global bKGD chunk, if the image is transparent\n       or does not cover the entire frame.\n     *\/\n     if (write_mng && (image->matte || image->page.x > 0 ||\n         image->page.y > 0 || (image->page.width &&\n         (image->page.width+image->page.x < mng_info->page.width))\n         || (image->page.height && (image->page.height+image->page.y\n         < mng_info->page.height))))\n       {\n         (void) WriteBlobMSBULong(image,6L);\n         PNGType(chunk,mng_BACK);\n         LogPNGChunk(logging,mng_BACK,6L);\n         red=ScaleQuantumToShort(image->background_color.red);\n         green=ScaleQuantumToShort(image->background_color.green);\n         blue=ScaleQuantumToShort(image->background_color.blue);\n         PNGShort(chunk+4,red);\n         PNGShort(chunk+6,green);\n         PNGShort(chunk+8,blue);\n         (void) WriteBlob(image,10,chunk);\n         (void) WriteBlobMSBULong(image,crc32(0,chunk,10));\n         if (mng_info->equal_backgrounds)\n           {\n             (void) WriteBlobMSBULong(image,6L);\n             PNGType(chunk,mng_bKGD);\n             LogPNGChunk(logging,mng_bKGD,6L);\n             (void) WriteBlob(image,10,chunk);\n             (void) WriteBlobMSBULong(image,crc32(0,chunk,10));\n           }\n       }\n\n#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED\n     if ((need_local_plte == MagickFalse) &&\n         (image->storage_class == PseudoClass) &&\n         (all_images_are_gray == MagickFalse))\n       {\n         size_t\n           data_length;\n\n         \/*\n           Write MNG PLTE chunk\n         *\/\n         data_length=3*image->colors;\n         (void) WriteBlobMSBULong(image,data_length);\n         PNGType(chunk,mng_PLTE);\n         LogPNGChunk(logging,mng_PLTE,data_length);\n\n         for (i=0; i < (ssize_t) image->colors; i++)\n         {\n           chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red) & 0xff;\n           chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green) & 0xff;\n           chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue) & 0xff;\n         }\n\n         (void) WriteBlob(image,data_length+4,chunk);\n         (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) (data_length+4)));\n         mng_info->have_write_global_plte=MagickTrue;\n       }\n#endif\n    }\n  scene=0;\n  mng_info->delay=0;\n#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \\\n    defined(PNG_MNG_FEATURES_SUPPORTED)\n  mng_info->equal_palettes=MagickFalse;\n#endif\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    if (mng_info->adjoin)\n    {\n#if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \\\n    defined(PNG_MNG_FEATURES_SUPPORTED)\n    \/*\n      If we aren't using a global palette for the entire MNG, check to\n      see if we can use one for two or more consecutive images.\n    *\/\n    if (need_local_plte && use_global_plte && !all_images_are_gray)\n      {\n        if (mng_info->IsPalette)\n          {\n            \/*\n              When equal_palettes is true, this image has the same palette\n              as the previous PseudoClass image\n            *\/\n            mng_info->have_write_global_plte=mng_info->equal_palettes;\n            mng_info->equal_palettes=PalettesAreEqual(image,image->next);\n            if (mng_info->equal_palettes && !mng_info->have_write_global_plte)\n              {\n                \/*\n                  Write MNG PLTE chunk\n                *\/\n                size_t\n                  data_length;\n\n                data_length=3*image->colors;\n                (void) WriteBlobMSBULong(image,data_length);\n                PNGType(chunk,mng_PLTE);\n                LogPNGChunk(logging,mng_PLTE,data_length);\n\n                for (i=0; i < (ssize_t) image->colors; i++)\n                {\n                  chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red);\n                  chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green);\n                  chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue);\n                }\n\n                (void) WriteBlob(image,data_length+4,chunk);\n                (void) WriteBlobMSBULong(image,crc32(0,chunk,\n                   (uInt) (data_length+4)));\n                mng_info->have_write_global_plte=MagickTrue;\n              }\n          }\n        else\n          mng_info->have_write_global_plte=MagickFalse;\n      }\n#endif\n    if (need_defi)\n      {\n        ssize_t\n          previous_x,\n          previous_y;\n\n        if (scene != 0)\n          {\n            previous_x=mng_info->page.x;\n            previous_y=mng_info->page.y;\n          }\n        else\n          {\n            previous_x=0;\n            previous_y=0;\n          }\n        mng_info->page=image->page;\n        if ((mng_info->page.x !=  previous_x) ||\n            (mng_info->page.y != previous_y))\n          {\n             (void) WriteBlobMSBULong(image,12L);  \/* data length=12 *\/\n             PNGType(chunk,mng_DEFI);\n             LogPNGChunk(logging,mng_DEFI,12L);\n             chunk[4]=0; \/* object 0 MSB *\/\n             chunk[5]=0; \/* object 0 LSB *\/\n             chunk[6]=0; \/* visible  *\/\n             chunk[7]=0; \/* abstract *\/\n             PNGLong(chunk+8,(png_uint_32) mng_info->page.x);\n             PNGLong(chunk+12,(png_uint_32) mng_info->page.y);\n             (void) WriteBlob(image,16,chunk);\n             (void) WriteBlobMSBULong(image,crc32(0,chunk,16));\n          }\n      }\n    }\n\n   mng_info->write_mng=write_mng;\n\n   if ((int) image->dispose >= 3)\n     mng_info->framing_mode=3;\n\n   if (mng_info->need_fram && mng_info->adjoin &&\n       ((image->delay != mng_info->delay) ||\n        (mng_info->framing_mode != mng_info->old_framing_mode)))\n     {\n       if (image->delay == mng_info->delay)\n         {\n           \/*\n             Write a MNG FRAM chunk with the new framing mode.\n           *\/\n           (void) WriteBlobMSBULong(image,1L);  \/* data length=1 *\/\n           PNGType(chunk,mng_FRAM);\n           LogPNGChunk(logging,mng_FRAM,1L);\n           chunk[4]=(unsigned char) mng_info->framing_mode;\n           (void) WriteBlob(image,5,chunk);\n           (void) WriteBlobMSBULong(image,crc32(0,chunk,5));\n         }\n       else\n         {\n           \/*\n             Write a MNG FRAM chunk with the delay.\n           *\/\n           (void) WriteBlobMSBULong(image,10L);  \/* data length=10 *\/\n           PNGType(chunk,mng_FRAM);\n           LogPNGChunk(logging,mng_FRAM,10L);\n           chunk[4]=(unsigned char) mng_info->framing_mode;\n           chunk[5]=0;  \/* frame name separator (no name) *\/\n           chunk[6]=2;  \/* flag for changing default delay *\/\n           chunk[7]=0;  \/* flag for changing frame timeout *\/\n           chunk[8]=0;  \/* flag for changing frame clipping *\/\n           chunk[9]=0;  \/* flag for changing frame sync_id *\/\n           PNGLong(chunk+10,(png_uint_32)\n             ((mng_info->ticks_per_second*\n             image->delay)\/MagickMax(image->ticks_per_second,1)));\n           (void) WriteBlob(image,14,chunk);\n           (void) WriteBlobMSBULong(image,crc32(0,chunk,14));\n           mng_info->delay=(png_uint_32) image->delay;\n         }\n       mng_info->old_framing_mode=mng_info->framing_mode;\n     }\n\n#if defined(JNG_SUPPORTED)\n   if (image_info->compression == JPEGCompression)\n     {\n       ImageInfo\n         *write_info;\n\n       if (logging != MagickFalse)\n         (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n           \"  Writing JNG object.\");\n       \/* To do: specify the desired alpha compression method. *\/\n       write_info=CloneImageInfo(image_info);\n       write_info->compression=UndefinedCompression;\n       status=WriteOneJNGImage(mng_info,write_info,image);\n       write_info=DestroyImageInfo(write_info);\n     }\n   else\n#endif\n     {\n       if (logging != MagickFalse)\n         (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n           \"  Writing PNG object.\");\n\n       mng_info->need_blob = MagickFalse;\n       mng_info->ping_preserve_colormap = MagickFalse;\n\n       \/* We don't want any ancillary chunks written *\/\n       mng_info->ping_exclude_bKGD=MagickTrue;\n       mng_info->ping_exclude_caNv=MagickTrue;\n       mng_info->ping_exclude_cHRM=MagickTrue;\n       mng_info->ping_exclude_date=MagickTrue;\n       mng_info->ping_exclude_EXIF=MagickTrue;\n       mng_info->ping_exclude_eXIf=MagickTrue;\n       mng_info->ping_exclude_gAMA=MagickTrue;\n       mng_info->ping_exclude_iCCP=MagickTrue;\n       \/* mng_info->ping_exclude_iTXt=MagickTrue; *\/\n       mng_info->ping_exclude_oFFs=MagickTrue;\n       mng_info->ping_exclude_pHYs=MagickTrue;\n       mng_info->ping_exclude_sRGB=MagickTrue;\n       mng_info->ping_exclude_tEXt=MagickTrue;\n       mng_info->ping_exclude_tRNS=MagickTrue;\n       mng_info->ping_exclude_zCCP=MagickTrue;\n       mng_info->ping_exclude_zTXt=MagickTrue;\n\n       status=WriteOnePNGImage(mng_info,image_info,image);\n     }\n\n    if (status == MagickFalse)\n      {\n        mng_info=MngInfoFreeStruct(mng_info);\n        (void) CloseBlob(image);\n        return(MagickFalse);\n      }\n    (void) CatchImageException(image);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n\n    if (status == MagickFalse)\n      break;\n\n  } while (mng_info->adjoin);\n\n  if (write_mng)\n    {\n      while (GetPreviousImageInList(image) != (Image *) NULL)\n        image=GetPreviousImageInList(image);\n      \/*\n        Write the MEND chunk.\n      *\/\n      (void) WriteBlobMSBULong(image,0x00000000L);\n      PNGType(chunk,mng_MEND);\n      LogPNGChunk(logging,mng_MEND,0L);\n      (void) WriteBlob(image,4,chunk);\n      (void) WriteBlobMSBULong(image,crc32(0,chunk,4));\n    }\n  \/*\n    Relinquish resources.\n  *\/\n  (void) CloseBlob(image);\n  mng_info=MngInfoFreeStruct(mng_info);\n\n  if (logging != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"exit WriteMNGImage()\");\n\n  return(MagickTrue);\n}","target":0,"code_token_length":7948,"total_token_length":8184,"max_tokens_setting":8192}
+{"idx":508037,"func":"int ssl3_send_client_key_exchange(SSL *s)\n{\n    unsigned char *p, *d;\n    int n;\n    unsigned long alg_k;\n#ifndef OPENSSL_NO_RSA\n    unsigned char *q;\n    EVP_PKEY *pkey = NULL;\n#endif\n#ifndef OPENSSL_NO_KRB5\n    KSSL_ERR kssl_err;\n#endif                          \/* OPENSSL_NO_KRB5 *\/\n#ifndef OPENSSL_NO_ECDH\n    EC_KEY *clnt_ecdh = NULL;\n    const EC_POINT *srvr_ecpoint = NULL;\n    EVP_PKEY *srvr_pub_pkey = NULL;\n    unsigned char *encodedPoint = NULL;\n    int encoded_pt_len = 0;\n    BN_CTX *bn_ctx = NULL;\n#endif\n\n    if (s->state == SSL3_ST_CW_KEY_EXCH_A) {\n        d = (unsigned char *)s->init_buf->data;\n        p = &(d[4]);\n\n        alg_k = s->s3->tmp.new_cipher->algorithm_mkey;\n\n        \/* Fool emacs indentation *\/\n        if (0) {\n        }\n#ifndef OPENSSL_NO_RSA\n        else if (alg_k & SSL_kRSA) {\n            RSA *rsa;\n            unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];\n\n            if (s->session->sess_cert == NULL) {\n                \/*\n                 * We should always have a server certificate with SSL_kRSA.\n                 *\/\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            if (s->session->sess_cert->peer_rsa_tmp != NULL)\n                rsa = s->session->sess_cert->peer_rsa_tmp;\n            else {\n                pkey =\n                    X509_get_pubkey(s->session->\n                                    sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].\n                                    x509);\n                if ((pkey == NULL) || (pkey->type != EVP_PKEY_RSA)\n                    || (pkey->pkey.rsa == NULL)) {\n                    SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                           ERR_R_INTERNAL_ERROR);\n                    EVP_PKEY_free(pkey);\n                    goto err;\n                }\n                rsa = pkey->pkey.rsa;\n                EVP_PKEY_free(pkey);\n            }\n\n            tmp_buf[0] = s->client_version >> 8;\n            tmp_buf[1] = s->client_version & 0xff;\n            if (RAND_bytes(&(tmp_buf[2]), sizeof tmp_buf - 2) <= 0)\n                goto err;\n\n            s->session->master_key_length = sizeof tmp_buf;\n\n            q = p;\n            \/* Fix buf for TLS and beyond *\/\n            if (s->version > SSL3_VERSION)\n                p += 2;\n            n = RSA_public_encrypt(sizeof tmp_buf,\n                                   tmp_buf, p, rsa, RSA_PKCS1_PADDING);\n# ifdef PKCS1_CHECK\n            if (s->options & SSL_OP_PKCS1_CHECK_1)\n                p[1]++;\n            if (s->options & SSL_OP_PKCS1_CHECK_2)\n                tmp_buf[0] = 0x70;\n# endif\n            if (n <= 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_BAD_RSA_ENCRYPT);\n                goto err;\n            }\n\n            \/* Fix buf for TLS and beyond *\/\n            if (s->version > SSL3_VERSION) {\n                s2n(n, q);\n                n += 2;\n            }\n\n            s->session->master_key_length =\n                s->method->ssl3_enc->generate_master_secret(s,\n                                                            s->\n                                                            session->master_key,\n                                                            tmp_buf,\n                                                            sizeof tmp_buf);\n            OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);\n        }\n#endif\n#ifndef OPENSSL_NO_KRB5\n        else if (alg_k & SSL_kKRB5) {\n            krb5_error_code krb5rc;\n            KSSL_CTX *kssl_ctx = s->kssl_ctx;\n            \/*  krb5_data   krb5_ap_req;  *\/\n            krb5_data *enc_ticket;\n            krb5_data authenticator, *authp = NULL;\n            EVP_CIPHER_CTX ciph_ctx;\n            const EVP_CIPHER *enc = NULL;\n            unsigned char iv[EVP_MAX_IV_LENGTH];\n            unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];\n            unsigned char epms[SSL_MAX_MASTER_KEY_LENGTH + EVP_MAX_IV_LENGTH];\n            int padl, outl = sizeof(epms);\n\n            EVP_CIPHER_CTX_init(&ciph_ctx);\n\n# ifdef KSSL_DEBUG\n            fprintf(stderr, \"ssl3_send_client_key_exchange(%lx & %lx)\\n\",\n                    alg_k, SSL_kKRB5);\n# endif                         \/* KSSL_DEBUG *\/\n\n            authp = NULL;\n# ifdef KRB5SENDAUTH\n            if (KRB5SENDAUTH)\n                authp = &authenticator;\n# endif                         \/* KRB5SENDAUTH *\/\n\n            krb5rc = kssl_cget_tkt(kssl_ctx, &enc_ticket, authp, &kssl_err);\n            enc = kssl_map_enc(kssl_ctx->enctype);\n            if (enc == NULL)\n                goto err;\n# ifdef KSSL_DEBUG\n            {\n                fprintf(stderr, \"kssl_cget_tkt rtn %d\\n\", krb5rc);\n                if (krb5rc && kssl_err.text)\n                    fprintf(stderr, \"kssl_cget_tkt kssl_err=%s\\n\",\n                            kssl_err.text);\n            }\n# endif                         \/* KSSL_DEBUG *\/\n\n            if (krb5rc) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, kssl_err.reason);\n                goto err;\n            }\n\n            \/*-\n             * 20010406 VRS - Earlier versions used KRB5 AP_REQ\n             * in place of RFC 2712 KerberosWrapper, as in:\n             *\n             * Send ticket (copy to *p, set n = length)\n             * n = krb5_ap_req.length;\n             * memcpy(p, krb5_ap_req.data, krb5_ap_req.length);\n             * if (krb5_ap_req.data)\n             *   kssl_krb5_free_data_contents(NULL,&krb5_ap_req);\n             *\n             * Now using real RFC 2712 KerberosWrapper\n             * (Thanks to Simon Wilkinson <sxw@sxw.org.uk>)\n             * Note: 2712 \"opaque\" types are here replaced\n             * with a 2-byte length followed by the value.\n             * Example:\n             * KerberosWrapper= xx xx asn1ticket 0 0 xx xx encpms\n             * Where \"xx xx\" = length bytes.  Shown here with\n             * optional authenticator omitted.\n             *\/\n\n            \/*  KerberosWrapper.Ticket              *\/\n            s2n(enc_ticket->length, p);\n            memcpy(p, enc_ticket->data, enc_ticket->length);\n            p += enc_ticket->length;\n            n = enc_ticket->length + 2;\n\n            \/*  KerberosWrapper.Authenticator       *\/\n            if (authp && authp->length) {\n                s2n(authp->length, p);\n                memcpy(p, authp->data, authp->length);\n                p += authp->length;\n                n += authp->length + 2;\n\n                free(authp->data);\n                authp->data = NULL;\n                authp->length = 0;\n            } else {\n                s2n(0, p);      \/* null authenticator length *\/\n                n += 2;\n            }\n\n            tmp_buf[0] = s->client_version >> 8;\n            tmp_buf[1] = s->client_version & 0xff;\n            if (RAND_bytes(&(tmp_buf[2]), sizeof tmp_buf - 2) <= 0)\n                goto err;\n\n            \/*-\n             * 20010420 VRS.  Tried it this way; failed.\n             *      EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,NULL);\n             *      EVP_CIPHER_CTX_set_key_length(&ciph_ctx,\n             *                              kssl_ctx->length);\n             *      EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv);\n             *\/\n\n            memset(iv, 0, sizeof iv); \/* per RFC 1510 *\/\n            EVP_EncryptInit_ex(&ciph_ctx, enc, NULL, kssl_ctx->key, iv);\n            EVP_EncryptUpdate(&ciph_ctx, epms, &outl, tmp_buf,\n                              sizeof tmp_buf);\n            EVP_EncryptFinal_ex(&ciph_ctx, &(epms[outl]), &padl);\n            outl += padl;\n            if (outl > (int)sizeof epms) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            EVP_CIPHER_CTX_cleanup(&ciph_ctx);\n\n            \/*  KerberosWrapper.EncryptedPreMasterSecret    *\/\n            s2n(outl, p);\n            memcpy(p, epms, outl);\n            p += outl;\n            n += outl + 2;\n\n            s->session->master_key_length =\n                s->method->ssl3_enc->generate_master_secret(s,\n                                                            s->\n                                                            session->master_key,\n                                                            tmp_buf,\n                                                            sizeof tmp_buf);\n\n            OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);\n            OPENSSL_cleanse(epms, outl);\n        }\n#endif\n#ifndef OPENSSL_NO_DH\n        else if (alg_k & (SSL_kEDH | SSL_kDHr | SSL_kDHd)) {\n            DH *dh_srvr, *dh_clnt;\n\n            if (s->session->sess_cert == NULL) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_UNEXPECTED_MESSAGE);\n                goto err;\n            }\n\n            if (s->session->sess_cert->peer_dh_tmp != NULL)\n                dh_srvr = s->session->sess_cert->peer_dh_tmp;\n            else {\n                \/* we get them from the cert *\/\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_UNABLE_TO_FIND_DH_PARAMETERS);\n                goto err;\n            }\n\n            \/* generate a new random key *\/\n            if ((dh_clnt = DHparams_dup(dh_srvr)) == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB);\n                goto err;\n            }\n            if (!DH_generate_key(dh_clnt)) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB);\n                DH_free(dh_clnt);\n                goto err;\n            }\n\n            \/*\n             * use the 'p' output buffer for the DH key, but make sure to\n             * clear it out afterwards\n             *\/\n\n            n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt);\n\n            if (n <= 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB);\n                DH_free(dh_clnt);\n                goto err;\n            }\n\n            \/* generate master key from the result *\/\n            s->session->master_key_length =\n                s->method->ssl3_enc->generate_master_secret(s,\n                                                            s->\n                                                            session->master_key,\n                                                            p, n);\n            \/* clean up *\/\n            memset(p, 0, n);\n\n            \/* send off the data *\/\n            n = BN_num_bytes(dh_clnt->pub_key);\n            s2n(n, p);\n            BN_bn2bin(dh_clnt->pub_key, p);\n            n += 2;\n\n            DH_free(dh_clnt);\n        }\n#endif\n\n#ifndef OPENSSL_NO_ECDH\n        else if (alg_k & (SSL_kEECDH | SSL_kECDHr | SSL_kECDHe)) {\n            const EC_GROUP *srvr_group = NULL;\n            EC_KEY *tkey;\n            int ecdh_clnt_cert = 0;\n            int field_size = 0;\n\n            if (s->session->sess_cert == NULL) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_UNEXPECTED_MESSAGE);\n                goto err;\n            }\n\n            \/*\n             * Did we send out the client's ECDH share for use in premaster\n             * computation as part of client certificate? If so, set\n             * ecdh_clnt_cert to 1.\n             *\/\n            if ((alg_k & (SSL_kECDHr | SSL_kECDHe)) && (s->cert != NULL)) {\n                \/*-\n                 * XXX: For now, we do not support client\n                 * authentication using ECDH certificates.\n                 * To add such support, one needs to add\n                 * code that checks for appropriate\n                 * conditions and sets ecdh_clnt_cert to 1.\n                 * For example, the cert have an ECC\n                 * key on the same curve as the server's\n                 * and the key should be authorized for\n                 * key agreement.\n                 *\n                 * One also needs to add code in ssl3_connect\n                 * to skip sending the certificate verify\n                 * message.\n                 *\n                 * if ((s->cert->key->privatekey != NULL) &&\n                 *     (s->cert->key->privatekey->type ==\n                 *      EVP_PKEY_EC) && ...)\n                 * ecdh_clnt_cert = 1;\n                 *\/\n            }\n\n            if (s->session->sess_cert->peer_ecdh_tmp != NULL) {\n                tkey = s->session->sess_cert->peer_ecdh_tmp;\n            } else {\n                \/* Get the Server Public Key from Cert *\/\n                srvr_pub_pkey =\n                    X509_get_pubkey(s->session->\n                                    sess_cert->peer_pkeys[SSL_PKEY_ECC].x509);\n                if ((srvr_pub_pkey == NULL)\n                    || (srvr_pub_pkey->type != EVP_PKEY_EC)\n                    || (srvr_pub_pkey->pkey.ec == NULL)) {\n                    SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                           ERR_R_INTERNAL_ERROR);\n                    goto err;\n                }\n\n                tkey = srvr_pub_pkey->pkey.ec;\n            }\n\n            srvr_group = EC_KEY_get0_group(tkey);\n            srvr_ecpoint = EC_KEY_get0_public_key(tkey);\n\n            if ((srvr_group == NULL) || (srvr_ecpoint == NULL)) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            if ((clnt_ecdh = EC_KEY_new()) == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n\n            if (!EC_KEY_set_group(clnt_ecdh, srvr_group)) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB);\n                goto err;\n            }\n            if (ecdh_clnt_cert) {\n                \/*\n                 * Reuse key info from our certificate We only need our\n                 * private key to perform the ECDH computation.\n                 *\/\n                const BIGNUM *priv_key;\n                tkey = s->cert->key->privatekey->pkey.ec;\n                priv_key = EC_KEY_get0_private_key(tkey);\n                if (priv_key == NULL) {\n                    SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                           ERR_R_MALLOC_FAILURE);\n                    goto err;\n                }\n                if (!EC_KEY_set_private_key(clnt_ecdh, priv_key)) {\n                    SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB);\n                    goto err;\n                }\n            } else {\n                \/* Generate a new ECDH key pair *\/\n                if (!(EC_KEY_generate_key(clnt_ecdh))) {\n                    SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                           ERR_R_ECDH_LIB);\n                    goto err;\n                }\n            }\n\n            \/*\n             * use the 'p' output buffer for the ECDH key, but make sure to\n             * clear it out afterwards\n             *\/\n\n            field_size = EC_GROUP_get_degree(srvr_group);\n            if (field_size <= 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n                goto err;\n            }\n            n = ECDH_compute_key(p, (field_size + 7) \/ 8, srvr_ecpoint,\n                                 clnt_ecdh, NULL);\n            if (n <= 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB);\n                goto err;\n            }\n\n            \/* generate master key from the result *\/\n            s->session->master_key_length =\n                s->method->ssl3_enc->generate_master_secret(s,\n                                                            s->\n                                                            session->master_key,\n                                                            p, n);\n\n            memset(p, 0, n);    \/* clean up *\/\n\n            if (ecdh_clnt_cert) {\n                \/* Send empty client key exch message *\/\n                n = 0;\n            } else {\n                \/*\n                 * First check the size of encoding and allocate memory\n                 * accordingly.\n                 *\/\n                encoded_pt_len =\n                    EC_POINT_point2oct(srvr_group,\n                                       EC_KEY_get0_public_key(clnt_ecdh),\n                                       POINT_CONVERSION_UNCOMPRESSED,\n                                       NULL, 0, NULL);\n\n                encodedPoint = (unsigned char *)\n                    OPENSSL_malloc(encoded_pt_len * sizeof(unsigned char));\n                bn_ctx = BN_CTX_new();\n                if ((encodedPoint == NULL) || (bn_ctx == NULL)) {\n                    SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                           ERR_R_MALLOC_FAILURE);\n                    goto err;\n                }\n\n                \/* Encode the public key *\/\n                n = EC_POINT_point2oct(srvr_group,\n                                       EC_KEY_get0_public_key(clnt_ecdh),\n                                       POINT_CONVERSION_UNCOMPRESSED,\n                                       encodedPoint, encoded_pt_len, bn_ctx);\n\n                *p = n;         \/* length of encoded point *\/\n                \/* Encoded point will be copied here *\/\n                p += 1;\n                \/* copy the point *\/\n                memcpy((unsigned char *)p, encodedPoint, n);\n                \/* increment n to account for length field *\/\n                n += 1;\n            }\n\n            \/* Free allocated memory *\/\n            BN_CTX_free(bn_ctx);\n            if (encodedPoint != NULL)\n                OPENSSL_free(encodedPoint);\n            if (clnt_ecdh != NULL)\n                EC_KEY_free(clnt_ecdh);\n            EVP_PKEY_free(srvr_pub_pkey);\n        }\n#endif                          \/* !OPENSSL_NO_ECDH *\/\n        else if (alg_k & SSL_kGOST) {\n            \/* GOST key exchange message creation *\/\n            EVP_PKEY_CTX *pkey_ctx;\n            X509 *peer_cert;\n            size_t msglen;\n            unsigned int md_len;\n            int keytype;\n            unsigned char premaster_secret[32], shared_ukm[32], tmp[256];\n            EVP_MD_CTX *ukm_hash;\n            EVP_PKEY *pub_key;\n\n            \/*\n             * Get server sertificate PKEY and create ctx from it\n             *\/\n            peer_cert =\n                s->session->\n                sess_cert->peer_pkeys[(keytype = SSL_PKEY_GOST01)].x509;\n            if (!peer_cert)\n                peer_cert =\n                    s->session->\n                    sess_cert->peer_pkeys[(keytype = SSL_PKEY_GOST94)].x509;\n            if (!peer_cert) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER);\n                goto err;\n            }\n\n            pkey_ctx = EVP_PKEY_CTX_new(pub_key =\n                                        X509_get_pubkey(peer_cert), NULL);\n            if (pkey_ctx == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            \/*\n             * If we have send a certificate, and certificate key\n             *\n             * * parameters match those of server certificate, use\n             * certificate key for key exchange\n             *\/\n\n            \/* Otherwise, generate ephemeral key pair *\/\n\n            if (pkey_ctx == NULL\n                    || EVP_PKEY_encrypt_init(pkey_ctx) <= 0\n                    \/* Generate session key *\/\n                    || RAND_bytes(premaster_secret, 32) <= 0) {\n                EVP_PKEY_CTX_free(pkey_ctx);\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            \/*\n             * Compute shared IV and store it in algorithm-specific context\n             * data\n             *\/\n            ukm_hash = EVP_MD_CTX_create();\n            if (EVP_DigestInit(ukm_hash,\n                               EVP_get_digestbynid(NID_id_GostR3411_94)) <= 0\n                    || EVP_DigestUpdate(ukm_hash, s->s3->client_random,\n                                        SSL3_RANDOM_SIZE) <= 0\n                    || EVP_DigestUpdate(ukm_hash, s->s3->server_random,\n                                        SSL3_RANDOM_SIZE) <= 0\n                    || EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len) <= 0) {\n                EVP_MD_CTX_destroy(ukm_hash);\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            EVP_MD_CTX_destroy(ukm_hash);\n            if (EVP_PKEY_CTX_ctrl\n                (pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8,\n                 shared_ukm) < 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_LIBRARY_BUG);\n                goto err;\n            }\n            \/* Make GOST keytransport blob message *\/\n            \/*\n             * Encapsulate it into sequence\n             *\/\n            *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED;\n            msglen = 255;\n            if (EVP_PKEY_encrypt(pkey_ctx, tmp, &msglen, premaster_secret, 32)\n                <= 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_LIBRARY_BUG);\n                goto err;\n            }\n            if (msglen >= 0x80) {\n                *(p++) = 0x81;\n                *(p++) = msglen & 0xff;\n                n = msglen + 3;\n            } else {\n                *(p++) = msglen & 0xff;\n                n = msglen + 2;\n            }\n            memcpy(p, tmp, msglen);\n            EVP_PKEY_CTX_free(pkey_ctx);\n            s->session->master_key_length =\n                s->method->ssl3_enc->generate_master_secret(s,\n                                                            s->\n                                                            session->master_key,\n                                                            premaster_secret,\n                                                            32);\n            EVP_PKEY_free(pub_key);\n\n        }\n#ifndef OPENSSL_NO_SRP\n        else if (alg_k & SSL_kSRP) {\n            if (s->srp_ctx.A != NULL) {\n                \/* send off the data *\/\n                n = BN_num_bytes(s->srp_ctx.A);\n                s2n(n, p);\n                BN_bn2bin(s->srp_ctx.A, p);\n                n += 2;\n            } else {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            if (s->session->srp_username != NULL)\n                OPENSSL_free(s->session->srp_username);\n            s->session->srp_username = BUF_strdup(s->srp_ctx.login);\n            if (s->session->srp_username == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n\n            if ((s->session->master_key_length =\n                 SRP_generate_client_master_secret(s,\n                                                   s->session->master_key)) <\n                0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n        }\n#endif\n#ifndef OPENSSL_NO_PSK\n        else if (alg_k & SSL_kPSK) {\n            \/*\n             * The callback needs PSK_MAX_IDENTITY_LEN + 1 bytes to return a\n             * \\0-terminated identity. The last byte is for us for simulating\n             * strnlen.\n             *\/\n            char identity[PSK_MAX_IDENTITY_LEN + 2];\n            size_t identity_len;\n            unsigned char *t = NULL;\n            unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN * 2 + 4];\n            unsigned int pre_ms_len = 0, psk_len = 0;\n            int psk_err = 1;\n\n            n = 0;\n            if (s->psk_client_callback == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_PSK_NO_CLIENT_CB);\n                goto err;\n            }\n\n            memset(identity, 0, sizeof(identity));\n            psk_len = s->psk_client_callback(s, s->session->psk_identity_hint,\n                                             identity, sizeof(identity) - 1,\n                                             psk_or_pre_ms,\n                                             sizeof(psk_or_pre_ms));\n            if (psk_len > PSK_MAX_PSK_LEN) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto psk_err;\n            } else if (psk_len == 0) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       SSL_R_PSK_IDENTITY_NOT_FOUND);\n                goto psk_err;\n            }\n            identity[PSK_MAX_IDENTITY_LEN + 1] = '\\0';\n            identity_len = strlen(identity);\n            if (identity_len > PSK_MAX_IDENTITY_LEN) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_INTERNAL_ERROR);\n                goto psk_err;\n            }\n            \/* create PSK pre_master_secret *\/\n            pre_ms_len = 2 + psk_len + 2 + psk_len;\n            t = psk_or_pre_ms;\n            memmove(psk_or_pre_ms + psk_len + 4, psk_or_pre_ms, psk_len);\n            s2n(psk_len, t);\n            memset(t, 0, psk_len);\n            t += psk_len;\n            s2n(psk_len, t);\n\n            if (s->session->psk_identity_hint != NULL)\n                OPENSSL_free(s->session->psk_identity_hint);\n            s->session->psk_identity_hint =\n                BUF_strdup(s->ctx->psk_identity_hint);\n            if (s->ctx->psk_identity_hint != NULL\n                && s->session->psk_identity_hint == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_MALLOC_FAILURE);\n                goto psk_err;\n            }\n\n            if (s->session->psk_identity != NULL)\n                OPENSSL_free(s->session->psk_identity);\n            s->session->psk_identity = BUF_strdup(identity);\n            if (s->session->psk_identity == NULL) {\n                SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,\n                       ERR_R_MALLOC_FAILURE);\n                goto psk_err;\n            }\n\n            s->session->master_key_length =\n                s->method->ssl3_enc->generate_master_secret(s,\n                                                            s->\n                                                            session->master_key,\n                                                            psk_or_pre_ms,\n                                                            pre_ms_len);\n            s2n(identity_len, p);\n            memcpy(p, identity, identity_len);\n            n = 2 + identity_len;\n            psk_err = 0;\n psk_err:\n            OPENSSL_cleanse(identity, sizeof(identity));\n            OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms));\n            if (psk_err != 0) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n                goto err;\n            }\n        }\n#endif\n        else {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n            SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n\n        *(d++) = SSL3_MT_CLIENT_KEY_EXCHANGE;\n        l2n3(n, d);\n\n        s->state = SSL3_ST_CW_KEY_EXCH_B;\n        \/* number of bytes to write *\/\n        s->init_num = n + 4;\n        s->init_off = 0;\n    }\n\n    \/* SSL3_ST_CW_KEY_EXCH_B *\/\n    return (ssl3_do_write(s, SSL3_RT_HANDSHAKE));\n err:\n#ifndef OPENSSL_NO_ECDH\n    BN_CTX_free(bn_ctx);\n    if (encodedPoint != NULL)\n        OPENSSL_free(encodedPoint);\n    if (clnt_ecdh != NULL)\n        EC_KEY_free(clnt_ecdh);\n    EVP_PKEY_free(srvr_pub_pkey);\n#endif\n    s->state = SSL_ST_ERR;\n    return (-1);\n}","target":0,"code_token_length":6299,"total_token_length":6535,"max_tokens_setting":8192}
+{"idx":43590,"func":"getcmdline_int(\n    int\t\tfirstc,\n    long\tcount UNUSED,\t\/\/ only used for incremental search\n    int\t\tindent,\t\t\/\/ indent for inside conditionals\n    int\t\tclear_ccline)\t\/\/ clear ccline first\n{\n    static int\tdepth = 0;\t    \/\/ call depth\n    int\t\tc;\n    int\t\ti;\n    int\t\tj;\n    int\t\tgotesc = FALSE;\t\t\/\/ TRUE when <ESC> just typed\n    int\t\tdo_abbr;\t\t\/\/ when TRUE check for abbr.\n    char_u\t*lookfor = NULL;\t\/\/ string to match\n    int\t\thiscnt;\t\t\t\/\/ current history line in use\n    int\t\thistype;\t\t\/\/ history type to be used\n#ifdef FEAT_SEARCH_EXTRA\n    incsearch_state_T\tis_state;\n#endif\n    int\t\tdid_wild_list = FALSE;\t\/\/ did wild_list() recently\n    int\t\twim_index = 0;\t\t\/\/ index in wim_flags[]\n    int\t\tres;\n    int\t\tsave_msg_scroll = msg_scroll;\n    int\t\tsave_State = State;\t\/\/ remember State when called\n    int\t\tsome_key_typed = FALSE;\t\/\/ one of the keys was typed\n    \/\/ mouse drag and release events are ignored, unless they are\n    \/\/ preceded with a mouse down event\n    int\t\tignore_drag_release = TRUE;\n#ifdef FEAT_EVAL\n    int\t\tbreak_ctrl_c = FALSE;\n#endif\n    expand_T\txpc;\n    long\t*b_im_ptr = NULL;\n    cmdline_info_T save_ccline;\n    int\t\tdid_save_ccline = FALSE;\n    int\t\tcmdline_type;\n    int\t\twild_type;\n\n    \/\/ one recursion level deeper\n    ++depth;\n\n    if (ccline.cmdbuff != NULL)\n    {\n\t\/\/ Being called recursively.  Since ccline is global, we need to save\n\t\/\/ the current buffer and restore it when returning.\n\tsave_cmdline(&save_ccline);\n\tdid_save_ccline = TRUE;\n    }\n    if (clear_ccline)\n\tCLEAR_FIELD(ccline);\n\n#ifdef FEAT_EVAL\n    if (firstc == -1)\n    {\n\tfirstc = NUL;\n\tbreak_ctrl_c = TRUE;\n    }\n#endif\n#ifdef FEAT_RIGHTLEFT\n    \/\/ start without Hebrew mapping for a command line\n    if (firstc == ':' || firstc == '=' || firstc == '>')\n\tcmd_hkmap = 0;\n#endif\n\n#ifdef FEAT_SEARCH_EXTRA\n    init_incsearch_state(&is_state);\n#endif\n\n    if (init_ccline(firstc, indent) != OK)\n\tgoto theend;\t\/\/ out of memory\n\n    if (depth == 50)\n    {\n\t\/\/ Somehow got into a loop recursively calling getcmdline(), bail out.\n\temsg(_(e_command_too_recursive));\n\tgoto theend;\n    }\n\n    ExpandInit(&xpc);\n    ccline.xpc = &xpc;\n\n#ifdef FEAT_RIGHTLEFT\n    if (curwin->w_p_rl && *curwin->w_p_rlc == 's'\n\t\t\t\t\t  && (firstc == '\/' || firstc == '?'))\n\tcmdmsg_rl = TRUE;\n    else\n\tcmdmsg_rl = FALSE;\n#endif\n\n    redir_off = TRUE;\t\t\/\/ don't redirect the typed command\n    if (!cmd_silent)\n    {\n\ti = msg_scrolled;\n\tmsg_scrolled = 0;\t\t\/\/ avoid wait_return message\n\tgotocmdline(TRUE);\n\tmsg_scrolled += i;\n\tredrawcmdprompt();\t\t\/\/ draw prompt or indent\n\tset_cmdspos();\n    }\n    xpc.xp_context = EXPAND_NOTHING;\n    xpc.xp_backslash = XP_BS_NONE;\n#ifndef BACKSLASH_IN_FILENAME\n    xpc.xp_shell = FALSE;\n#endif\n\n#if defined(FEAT_EVAL)\n    if (ccline.input_fn)\n    {\n\txpc.xp_context = ccline.xp_context;\n\txpc.xp_pattern = ccline.cmdbuff;\n\txpc.xp_arg = ccline.xp_arg;\n    }\n#endif\n\n    \/*\n     * Avoid scrolling when called by a recursive do_cmdline(), e.g. when\n     * doing \":@0\" when register 0 doesn't contain a CR.\n     *\/\n    msg_scroll = FALSE;\n\n    State = MODE_CMDLINE;\n\n    if (firstc == '\/' || firstc == '?' || firstc == '@')\n    {\n\t\/\/ Use \":lmap\" mappings for search pattern and input().\n\tif (curbuf->b_p_imsearch == B_IMODE_USE_INSERT)\n\t    b_im_ptr = &curbuf->b_p_iminsert;\n\telse\n\t    b_im_ptr = &curbuf->b_p_imsearch;\n\tif (*b_im_ptr == B_IMODE_LMAP)\n\t    State |= MODE_LANGMAP;\n#ifdef HAVE_INPUT_METHOD\n\tim_set_active(*b_im_ptr == B_IMODE_IM);\n#endif\n    }\n#ifdef HAVE_INPUT_METHOD\n    else if (p_imcmdline)\n\tim_set_active(TRUE);\n#endif\n\n    setmouse();\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n\n    \/\/ When inside an autocommand for writing \"exiting\" may be set and\n    \/\/ terminal mode set to cooked.  Need to set raw mode here then.\n    settmode(TMODE_RAW);\n\n    \/\/ Trigger CmdlineEnter autocommands.\n    cmdline_type = firstc == NUL ? '-' : firstc;\n    trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER);\n#ifdef FEAT_EVAL\n    if (!debug_mode)\n\tmay_trigger_modechanged();\n#endif\n\n    init_history();\n    hiscnt = get_hislen();\t\/\/ set hiscnt to impossible history value\n    histype = hist_char2type(firstc);\n\n#ifdef FEAT_DIGRAPHS\n    do_digraph(-1);\t\t\/\/ init digraph typeahead\n#endif\n\n    \/\/ If something above caused an error, reset the flags, we do want to type\n    \/\/ and execute commands. Display may be messed up a bit.\n    if (did_emsg)\n\tredrawcmd();\n\n#ifdef FEAT_STL_OPT\n    \/\/ Redraw the statusline in case it uses the current mode using the mode()\n    \/\/ function.\n    if (!cmd_silent && msg_scrolled == 0)\n    {\n\tint\tfound_one = FALSE;\n\twin_T\t*wp;\n\n\tFOR_ALL_WINDOWS(wp)\n\t    if (*p_stl != NUL || *wp->w_p_stl != NUL)\n\t    {\n\t\twp->w_redr_status = TRUE;\n\t\tfound_one = TRUE;\n\t    }\n\tif (found_one)\n\t    redraw_statuslines();\n    }\n#endif\n\n    did_emsg = FALSE;\n    got_int = FALSE;\n\n    \/*\n     * Collect the command string, handling editing keys.\n     *\/\n    for (;;)\n    {\n\tint trigger_cmdlinechanged = TRUE;\n\tint end_wildmenu;\n\n\tredir_off = TRUE;\t\/\/ Don't redirect the typed command.\n\t\t\t\t\/\/ Repeated, because a \":redir\" inside\n\t\t\t\t\/\/ completion may switch it on.\n#ifdef USE_ON_FLY_SCROLL\n\tdont_scroll = FALSE;\t\/\/ allow scrolling here\n#endif\n\tquit_more = FALSE;\t\/\/ reset after CTRL-D which had a more-prompt\n\n\tdid_emsg = FALSE;\t\/\/ There can't really be a reason why an error\n\t\t\t\t\/\/ that occurs while typing a command should\n\t\t\t\t\/\/ cause the command not to be executed.\n\n\t\/\/ Trigger SafeState if nothing is pending.\n\tmay_trigger_safestate(xpc.xp_numfiles <= 0);\n\n\t\/\/ Get a character.  Ignore K_IGNORE and K_NOP, they should not do\n\t\/\/ anything, such as stop completion.\n\tdo\n\t{\n\t    cursorcmd();\t\t\/\/ set the cursor on the right spot\n\t    c = safe_vgetc();\n\t} while (c == K_IGNORE || c == K_NOP);\n\n\tif (c == K_COMMAND || c == K_SCRIPT_COMMAND)\n\t{\n\t    int\t    clen = ccline.cmdlen;\n\n\t    if (do_cmdkey_command(c, DOCMD_NOWAIT) == OK)\n\t    {\n\t\tif (clen == ccline.cmdlen)\n\t\t    trigger_cmdlinechanged = FALSE;\n\t\tgoto cmdline_changed;\n\t    }\n\t}\n\n\tif (KeyTyped)\n\t{\n\t    some_key_typed = TRUE;\n#ifdef FEAT_RIGHTLEFT\n\t    if (cmd_hkmap)\n\t\tc = hkmap(c);\n\t    if (cmdmsg_rl && !KeyStuffed)\n\t    {\n\t\t\/\/ Invert horizontal movements and operations.  Only when\n\t\t\/\/ typed by the user directly, not when the result of a\n\t\t\/\/ mapping.\n\t\tswitch (c)\n\t\t{\n\t\t    case K_RIGHT:   c = K_LEFT; break;\n\t\t    case K_S_RIGHT: c = K_S_LEFT; break;\n\t\t    case K_C_RIGHT: c = K_C_LEFT; break;\n\t\t    case K_LEFT:    c = K_RIGHT; break;\n\t\t    case K_S_LEFT:  c = K_S_RIGHT; break;\n\t\t    case K_C_LEFT:  c = K_C_RIGHT; break;\n\t\t}\n\t    }\n#endif\n\t}\n\n\t\/*\n\t * Ignore got_int when CTRL-C was typed here.\n\t * Don't ignore it in :global, we really need to break then, e.g., for\n\t * \":g\/pat\/normal \/pat\" (without the <CR>).\n\t * Don't ignore it for the input() function.\n\t *\/\n\tif ((c == Ctrl_C\n#ifdef UNIX\n\t\t|| c == intr_char\n#endif\n\t\t\t\t)\n#if defined(FEAT_EVAL) || defined(FEAT_CRYPT)\n\t\t&& firstc != '@'\n#endif\n#ifdef FEAT_EVAL\n\t\t&& !break_ctrl_c\n#endif\n\t\t&& !global_busy)\n\t    got_int = FALSE;\n\n\t\/\/ free old command line when finished moving around in the history\n\t\/\/ list\n\tif (lookfor != NULL\n\t\t&& c != K_S_DOWN && c != K_S_UP\n\t\t&& c != K_DOWN && c != K_UP\n\t\t&& c != K_PAGEDOWN && c != K_PAGEUP\n\t\t&& c != K_KPAGEDOWN && c != K_KPAGEUP\n\t\t&& c != K_LEFT && c != K_RIGHT\n\t\t&& (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N)))\n\t    VIM_CLEAR(lookfor);\n\n\t\/*\n\t * When there are matching completions to select <S-Tab> works like\n\t * CTRL-P (unless 'wc' is <S-Tab>).\n\t *\/\n\tif (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0)\n\t    c = Ctrl_P;\n\n#ifdef FEAT_WILDMENU\n\tif (p_wmnu)\n\t    c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list);\n\n\tif (cmdline_pum_active())\n\t{\n\t    \/\/ Ctrl-Y: Accept the current selection and close the popup menu.\n\t    \/\/ Ctrl-E: cancel the cmdline popup menu and return the original\n\t    \/\/ text.\n\t    if (c == Ctrl_E || c == Ctrl_Y)\n\t    {\n\t\twild_type = (c == Ctrl_E) ? WILD_CANCEL : WILD_APPLY;\n\t\tif (nextwild(&xpc, wild_type, WILD_NO_BEEP,\n\t\t\t\t\t\t\tfirstc != '@') == FAIL)\n\t\t    break;\n\t\tc = Ctrl_E;\n\t    }\n\t}\n#endif\n\n\t\/\/ The wildmenu is cleared if the pressed key is not used for\n\t\/\/ navigating the wild menu (i.e. the key is not 'wildchar' or\n\t\/\/ 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L).\n\t\/\/ If the popup menu is displayed, then PageDown and PageUp keys are\n\t\/\/ also used to navigate the menu.\n\tend_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm\n\t\t&& c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L);\n#ifdef FEAT_WILDMENU\n\tend_wildmenu = end_wildmenu && (!cmdline_pum_active() ||\n\t\t\t    (c != K_PAGEDOWN && c != K_PAGEUP\n\t\t\t     && c != K_KPAGEDOWN && c != K_KPAGEUP));\n#endif\n\n\t\/\/ free expanded names when finished walking through matches\n\tif (end_wildmenu)\n\t{\n#ifdef FEAT_WILDMENU\n\t    if (cmdline_pum_active())\n\t\tcmdline_pum_remove();\n#endif\n\t    if (xpc.xp_numfiles != -1)\n\t\t(void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);\n\t    did_wild_list = FALSE;\n#ifdef FEAT_WILDMENU\n\t    if (!p_wmnu || (c != K_UP && c != K_DOWN))\n#endif\n\t\txpc.xp_context = EXPAND_NOTHING;\n\t    wim_index = 0;\n#ifdef FEAT_WILDMENU\n\t    wildmenu_cleanup(&ccline);\n#endif\n\t}\n\n#ifdef FEAT_WILDMENU\n\tif (p_wmnu)\n\t    c = wildmenu_process_key(&ccline, c, &xpc);\n#endif\n\n\t\/\/ CTRL-\\ CTRL-N goes to Normal mode, CTRL-\\ CTRL-G goes to Insert\n\t\/\/ mode when 'insertmode' is set, CTRL-\\ e prompts for an expression.\n\tif (c == Ctrl_BSL)\n\t{\n\t    res = cmdline_handle_backslash_key(c, &gotesc);\n\t    if (res == CMDLINE_CHANGED)\n\t\tgoto cmdline_changed;\n\t    else if (res == CMDLINE_NOT_CHANGED)\n\t\tgoto cmdline_not_changed;\n\t    else if (res == GOTO_NORMAL_MODE)\n\t\tgoto returncmd;\t\t\/\/ back to cmd mode\n\t    c = Ctrl_BSL;\t\t\/\/ backslash key not processed by\n\t\t\t\t\t\/\/ cmdline_handle_backslash_key()\n\t}\n\n#ifdef FEAT_CMDWIN\n\tif (c == cedit_key || c == K_CMDWIN)\n\t{\n\t    \/\/ TODO: why is ex_normal_busy checked here?\n\t    if ((c == K_CMDWIN || ex_normal_busy == 0) && got_int == FALSE)\n\t    {\n\t\t\/*\n\t\t * Open a window to edit the command line (and history).\n\t\t *\/\n\t\tc = open_cmdwin();\n\t\tsome_key_typed = TRUE;\n\t    }\n\t}\n# ifdef FEAT_DIGRAPHS\n\telse\n# endif\n#endif\n#ifdef FEAT_DIGRAPHS\n\t    c = do_digraph(c);\n#endif\n\n\tif (c == '\\n' || c == '\\r' || c == K_KENTER || (c == ESC\n\t\t\t&& (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL)))\n\t{\n\t    \/\/ In Ex mode a backslash escapes a newline.\n\t    if (exmode_active\n\t\t    && c != ESC\n\t\t    && ccline.cmdpos == ccline.cmdlen\n\t\t    && ccline.cmdpos > 0\n\t\t    && ccline.cmdbuff[ccline.cmdpos - 1] == '\\\\')\n\t    {\n\t\tif (c == K_KENTER)\n\t\t    c = '\\n';\n\t    }\n\t    else\n\t    {\n\t\tgotesc = FALSE;\t\/\/ Might have typed ESC previously, don't\n\t\t\t\t\/\/ truncate the cmdline now.\n\t\tif (ccheck_abbr(c + ABBR_OFF))\n\t\t    goto cmdline_changed;\n\t\tif (!cmd_silent)\n\t\t{\n\t\t    windgoto(msg_row, 0);\n\t\t    out_flush();\n\t\t}\n\t\tbreak;\n\t    }\n\t}\n\n\t\/\/ Completion for 'wildchar' or 'wildcharm' key.\n\tif ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm)\n\t{\n\t    res = cmdline_wildchar_complete(c, firstc != '@', &did_wild_list,\n\t\t    &wim_index, &xpc, &gotesc);\n\t    if (res == CMDLINE_CHANGED)\n\t\tgoto cmdline_changed;\n\t}\n\n\tgotesc = FALSE;\n\n\t\/\/ <S-Tab> goes to last match, in a clumsy way\n\tif (c == K_S_TAB && KeyTyped)\n\t{\n\t    if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK)\n\t    {\n\t\tif (xpc.xp_numfiles > 1)\n\t\t{\n#ifdef FEAT_WILDMENU\n\t\t    \/\/ Trigger the popup menu when wildoptions=pum\n\t\t    showmatches(&xpc, p_wmnu\n\t\t\t    && ((wim_flags[wim_index] & WIM_LIST) == 0));\n#else\n\t\t    (void)showmatches(&xpc, FALSE);\n#endif\n\t\t}\n\t\tif (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK\n\t\t\t&& nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK)\n\t\t    goto cmdline_changed;\n\t    }\n\t}\n\n\tif (c == NUL || c == K_ZERO)\t    \/\/ NUL is stored as NL\n\t    c = NL;\n\n\tdo_abbr = TRUE;\t\t\/\/ default: check for abbreviation\n\n\t\/*\n\t * Big switch for a typed command line character.\n\t *\/\n\tswitch (c)\n\t{\n\tcase K_BS:\n\tcase Ctrl_H:\n\tcase K_DEL:\n\tcase K_KDEL:\n\tcase Ctrl_W:\n\t    res = cmdline_erase_chars(c, indent\n#ifdef FEAT_SEARCH_EXTRA\n\t\t    , &is_state\n#endif\n\t\t    );\n\t    if (res == CMDLINE_NOT_CHANGED)\n\t\tgoto cmdline_not_changed;\n\t    else if (res == GOTO_NORMAL_MODE)\n\t\tgoto returncmd;\t\t\/\/ back to cmd mode\n\t    goto cmdline_changed;\n\n\tcase K_INS:\n\tcase K_KINS:\n\t\tccline.overstrike = !ccline.overstrike;\n#ifdef CURSOR_SHAPE\n\t\tui_cursor_shape();\t\/\/ may show different cursor shape\n#endif\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_HAT:\n\t\tcmdline_toggle_langmap(b_im_ptr);\n\t\tgoto cmdline_not_changed;\n\n\/\/\tcase '@':   only in very old vi\n\tcase Ctrl_U:\n\t\t\/\/ delete all characters left of the cursor\n\t\tj = ccline.cmdpos;\n\t\tccline.cmdlen -= j;\n\t\ti = ccline.cmdpos = 0;\n\t\twhile (i < ccline.cmdlen)\n\t\t    ccline.cmdbuff[i++] = ccline.cmdbuff[j++];\n\t\t\/\/ Truncate at the end, required for multi-byte chars.\n\t\tccline.cmdbuff[ccline.cmdlen] = NUL;\n#ifdef FEAT_SEARCH_EXTRA\n\t\tif (ccline.cmdlen == 0)\n\t\t    is_state.search_start = is_state.save_cursor;\n#endif\n\t\tredrawcmd();\n\t\tgoto cmdline_changed;\n\n#ifdef FEAT_CLIPBOARD\n\tcase Ctrl_Y:\n\t\t\/\/ Copy the modeless selection, if there is one.\n\t\tif (clip_star.state != SELECT_CLEARED)\n\t\t{\n\t\t    if (clip_star.state == SELECT_DONE)\n\t\t\tclip_copy_modeless_selection(TRUE);\n\t\t    goto cmdline_not_changed;\n\t\t}\n\t\tbreak;\n#endif\n\n\tcase ESC:\t\/\/ get here if p_wc != ESC or when ESC typed twice\n\tcase Ctrl_C:\n\t\t\/\/ In exmode it doesn't make sense to return.  Except when\n\t\t\/\/ \":normal\" runs out of characters.\n\t\tif (exmode_active\n\t\t\t       && (ex_normal_busy == 0 || typebuf.tb_len > 0))\n\t\t    goto cmdline_not_changed;\n\n\t\tgotesc = TRUE;\t\t\/\/ will free ccline.cmdbuff after\n\t\t\t\t\t\/\/ putting it in history\n\t\tgoto returncmd;\t\t\/\/ back to cmd mode\n\n\tcase Ctrl_R:\t\t\t\/\/ insert register\n\t\tres = cmdline_insert_reg(&gotesc);\n\t\tif (res == CMDLINE_NOT_CHANGED)\n\t\t    goto cmdline_not_changed;\n\t\telse if (res == GOTO_NORMAL_MODE)\n\t\t    goto returncmd;\n\t\tgoto cmdline_changed;\n\n\tcase Ctrl_D:\n\t\tif (showmatches(&xpc, FALSE) == EXPAND_NOTHING)\n\t\t    break;\t\/\/ Use ^D as normal char instead\n\n\t\tredrawcmd();\n\t\tcontinue;\t\/\/ don't do incremental search now\n\n\tcase K_RIGHT:\n\tcase K_S_RIGHT:\n\tcase K_C_RIGHT:\n\t\tdo\n\t\t{\n\t\t    if (ccline.cmdpos >= ccline.cmdlen)\n\t\t\tbreak;\n\t\t    i = cmdline_charsize(ccline.cmdpos);\n\t\t    if (KeyTyped && ccline.cmdspos + i >= Columns * Rows)\n\t\t\tbreak;\n\t\t    ccline.cmdspos += i;\n\t\t    if (has_mbyte)\n\t\t\tccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff\n\t\t\t\t\t\t\t     + ccline.cmdpos);\n\t\t    else\n\t\t\t++ccline.cmdpos;\n\t\t}\n\t\twhile ((c == K_S_RIGHT || c == K_C_RIGHT\n\t\t\t       || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))\n\t\t\t&& ccline.cmdbuff[ccline.cmdpos] != ' ');\n\t\tif (has_mbyte)\n\t\t    set_cmdspos_cursor();\n\t\tgoto cmdline_not_changed;\n\n\tcase K_LEFT:\n\tcase K_S_LEFT:\n\tcase K_C_LEFT:\n\t\tif (ccline.cmdpos == 0)\n\t\t    goto cmdline_not_changed;\n\t\tdo\n\t\t{\n\t\t    --ccline.cmdpos;\n\t\t    if (has_mbyte)\t\/\/ move to first byte of char\n\t\t\tccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,\n\t\t\t\t\t      ccline.cmdbuff + ccline.cmdpos);\n\t\t    ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);\n\t\t}\n\t\twhile (ccline.cmdpos > 0\n\t\t\t&& (c == K_S_LEFT || c == K_C_LEFT\n\t\t\t       || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))\n\t\t\t&& ccline.cmdbuff[ccline.cmdpos - 1] != ' ');\n\t\tif (has_mbyte)\n\t\t    set_cmdspos_cursor();\n\t\tgoto cmdline_not_changed;\n\n\tcase K_IGNORE:\n\t\t\/\/ Ignore mouse event or open_cmdwin() result.\n\t\tgoto cmdline_not_changed;\n\n#ifdef FEAT_GUI_MSWIN\n\t    \/\/ On MS-Windows ignore <M-F4>, we get it when closing the window\n\t    \/\/ was cancelled.\n\tcase K_F4:\n\t    if (mod_mask == MOD_MASK_ALT)\n\t    {\n\t\tredrawcmd();\t    \/\/ somehow the cmdline is cleared\n\t\tgoto cmdline_not_changed;\n\t    }\n\t    break;\n#endif\n\n\tcase K_MIDDLEDRAG:\n\tcase K_MIDDLERELEASE:\n\t\tgoto cmdline_not_changed;\t\/\/ Ignore mouse\n\n\tcase K_MIDDLEMOUSE:\n# ifdef FEAT_GUI\n\t\t\/\/ When GUI is active, also paste when 'mouse' is empty\n\t\tif (!gui.in_use)\n# endif\n\t\t    if (!mouse_has(MOUSE_COMMAND))\n\t\t\tgoto cmdline_not_changed;   \/\/ Ignore mouse\n# ifdef FEAT_CLIPBOARD\n\t\tif (clip_star.available)\n\t\t    cmdline_paste('*', TRUE, TRUE);\n\t\telse\n# endif\n\t\t    cmdline_paste(0, TRUE, TRUE);\n\t\tredrawcmd();\n\t\tgoto cmdline_changed;\n\n# ifdef FEAT_DND\n\tcase K_DROP:\n\t\tcmdline_paste('~', TRUE, FALSE);\n\t\tredrawcmd();\n\t\tgoto cmdline_changed;\n# endif\n\n\tcase K_LEFTDRAG:\n\tcase K_LEFTRELEASE:\n\tcase K_RIGHTDRAG:\n\tcase K_RIGHTRELEASE:\n\t\t\/\/ Ignore drag and release events when the button-down wasn't\n\t\t\/\/ seen before.\n\t\tif (ignore_drag_release)\n\t\t    goto cmdline_not_changed;\n\t\t\/\/ FALLTHROUGH\n\tcase K_LEFTMOUSE:\n\tcase K_RIGHTMOUSE:\n\t\tcmdline_left_right_mouse(c, &ignore_drag_release);\n\t\tgoto cmdline_not_changed;\n\n\t\/\/ Mouse scroll wheel: ignored here\n\tcase K_MOUSEDOWN:\n\tcase K_MOUSEUP:\n\tcase K_MOUSELEFT:\n\tcase K_MOUSERIGHT:\n\t\/\/ Alternate buttons ignored here\n\tcase K_X1MOUSE:\n\tcase K_X1DRAG:\n\tcase K_X1RELEASE:\n\tcase K_X2MOUSE:\n\tcase K_X2DRAG:\n\tcase K_X2RELEASE:\n\tcase K_MOUSEMOVE:\n\t\tgoto cmdline_not_changed;\n\n#ifdef FEAT_GUI\n\tcase K_LEFTMOUSE_NM:\t\/\/ mousefocus click, ignored\n\tcase K_LEFTRELEASE_NM:\n\t\tgoto cmdline_not_changed;\n\n\tcase K_VER_SCROLLBAR:\n\t\tif (msg_scrolled == 0)\n\t\t{\n\t\t    gui_do_scroll();\n\t\t    redrawcmd();\n\t\t}\n\t\tgoto cmdline_not_changed;\n\n\tcase K_HOR_SCROLLBAR:\n\t\tif (msg_scrolled == 0)\n\t\t{\n\t\t    gui_do_horiz_scroll(scrollbar_value, FALSE);\n\t\t    redrawcmd();\n\t\t}\n\t\tgoto cmdline_not_changed;\n#endif\n#ifdef FEAT_GUI_TABLINE\n\tcase K_TABLINE:\n\tcase K_TABMENU:\n\t\t\/\/ Don't want to change any tabs here.  Make sure the same tab\n\t\t\/\/ is still selected.\n\t\tif (gui_use_tabline())\n\t\t    gui_mch_set_curtab(tabpage_index(curtab));\n\t\tgoto cmdline_not_changed;\n#endif\n\n\tcase K_SELECT:\t    \/\/ end of Select mode mapping - ignore\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_B:\t    \/\/ begin of command line\n\tcase K_HOME:\n\tcase K_KHOME:\n\tcase K_S_HOME:\n\tcase K_C_HOME:\n\t\tccline.cmdpos = 0;\n\t\tset_cmdspos();\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_E:\t    \/\/ end of command line\n\tcase K_END:\n\tcase K_KEND:\n\tcase K_S_END:\n\tcase K_C_END:\n\t\tccline.cmdpos = ccline.cmdlen;\n\t\tset_cmdspos_cursor();\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_A:\t    \/\/ all matches\n#ifdef FEAT_WILDMENU\n\t\tif (cmdline_pum_active())\n\t\t    \/\/ As Ctrl-A completes all the matches, close the popup\n\t\t    \/\/ menu (if present)\n\t\t    cmdline_pum_cleanup(&ccline);\n#endif\n\t\tif (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)\n\t\t    break;\n\t\txpc.xp_context = EXPAND_NOTHING;\n\t\tdid_wild_list = FALSE;\n\t\tgoto cmdline_changed;\n\n\tcase Ctrl_L:\n#ifdef FEAT_SEARCH_EXTRA\n\t\tif (may_add_char_to_search(firstc, &c, &is_state) == OK)\n\t\t    goto cmdline_not_changed;\n#endif\n\n\t\t\/\/ completion: longest common part\n\t\tif (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL)\n\t\t    break;\n\t\tgoto cmdline_changed;\n\n\tcase Ctrl_N:\t    \/\/ next match\n\tcase Ctrl_P:\t    \/\/ previous match\n\t\tif (xpc.xp_numfiles > 0)\n\t\t{\n\t\t    wild_type = (c == Ctrl_P) ? WILD_PREV : WILD_NEXT;\n\t\t    if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)\n\t\t\tbreak;\n\t\t    goto cmdline_not_changed;\n\t\t}\n\t\t\/\/ FALLTHROUGH\n\tcase K_UP:\n\tcase K_DOWN:\n\tcase K_S_UP:\n\tcase K_S_DOWN:\n\tcase K_PAGEUP:\n\tcase K_KPAGEUP:\n\tcase K_PAGEDOWN:\n\tcase K_KPAGEDOWN:\n#ifdef FEAT_WILDMENU\n\t\tif (cmdline_pum_active()\n\t\t\t&& (c == K_PAGEUP || c == K_PAGEDOWN ||\n\t\t\t    c == K_KPAGEUP || c == K_KPAGEDOWN))\n\t\t{\n\t\t    \/\/ If the popup menu is displayed, then PageUp and PageDown\n\t\t    \/\/ are used to scroll the menu.\n\t\t    wild_type = WILD_PAGEUP;\n\t\t    if (c == K_PAGEDOWN || c == K_KPAGEDOWN)\n\t\t\twild_type = WILD_PAGEDOWN;\n\t\t    if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)\n\t\t\tbreak;\n\t\t    goto cmdline_not_changed;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    res = cmdline_browse_history(c, firstc, &lookfor, histype,\n\t\t\t    &hiscnt, &xpc);\n\t\t    if (res == CMDLINE_CHANGED)\n\t\t\tgoto cmdline_changed;\n\t\t    else if (res == GOTO_NORMAL_MODE)\n\t\t\tgoto returncmd;\n\t\t}\n\t\tgoto cmdline_not_changed;\n\n#ifdef FEAT_SEARCH_EXTRA\n\tcase Ctrl_G:\t    \/\/ next match\n\tcase Ctrl_T:\t    \/\/ previous match\n\t\tif (may_adjust_incsearch_highlighting(\n\t\t\t\t\t  firstc, count, &is_state, c) == FAIL)\n\t\t    goto cmdline_not_changed;\n\t\tbreak;\n#endif\n\n\tcase Ctrl_V:\n\tcase Ctrl_Q:\n\t\t{\n\t\t    ignore_drag_release = TRUE;\n\t\t    putcmdline('^', TRUE);\n\n\t\t    \/\/ Get next (two) character(s).  Do not change any\n\t\t    \/\/ modifyOtherKeys ESC sequence to a normal key for\n\t\t    \/\/ CTRL-SHIFT-V.\n\t\t    c = get_literal(mod_mask & MOD_MASK_SHIFT);\n\n\t\t    do_abbr = FALSE;\t    \/\/ don't do abbreviation now\n\t\t    extra_char = NUL;\n\t\t    \/\/ may need to remove ^ when composing char was typed\n\t\t    if (enc_utf8 && utf_iscomposing(c) && !cmd_silent)\n\t\t    {\n\t\t\tdraw_cmdline(ccline.cmdpos,\n\t\t\t\t\t\tccline.cmdlen - ccline.cmdpos);\n\t\t\tmsg_putchar(' ');\n\t\t\tcursorcmd();\n\t\t    }\n\t\t}\n\n\t\tbreak;\n\n#ifdef FEAT_DIGRAPHS\n\tcase Ctrl_K:\n\t\tignore_drag_release = TRUE;\n\t\tputcmdline('?', TRUE);\n# ifdef USE_ON_FLY_SCROLL\n\t\tdont_scroll = TRUE;\t    \/\/ disallow scrolling here\n# endif\n\t\tc = get_digraph(TRUE);\n\t\textra_char = NUL;\n\t\tif (c != NUL)\n\t\t    break;\n\n\t\tredrawcmd();\n\t\tgoto cmdline_not_changed;\n#endif \/\/ FEAT_DIGRAPHS\n\n#ifdef FEAT_RIGHTLEFT\n\tcase Ctrl__:\t    \/\/ CTRL-_: switch language mode\n\t\tif (!p_ari)\n\t\t    break;\n\t\tcmd_hkmap = !cmd_hkmap;\n\t\tgoto cmdline_not_changed;\n#endif\n\n\tcase K_PS:\n\t\tbracketed_paste(PASTE_CMDLINE, FALSE, NULL);\n\t\tgoto cmdline_changed;\n\n\tdefault:\n#ifdef UNIX\n\t\tif (c == intr_char)\n\t\t{\n\t\t    gotesc = TRUE;\t\/\/ will free ccline.cmdbuff after\n\t\t\t\t\t\/\/ putting it in history\n\t\t    goto returncmd;\t\/\/ back to Normal mode\n\t\t}\n#endif\n\t\t\/*\n\t\t * Normal character with no special meaning.  Just set mod_mask\n\t\t * to 0x0 so that typing Shift-Space in the GUI doesn't enter\n\t\t * the string <S-Space>.  This should only happen after ^V.\n\t\t *\/\n\t\tif (!IS_SPECIAL(c))\n\t\t    mod_mask = 0x0;\n\t\tbreak;\n\t}\n\t\/*\n\t * End of switch on command line character.\n\t * We come here if we have a normal character.\n\t *\/\n\n\tif (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c))\n\t\t&& (ccheck_abbr(\n\t\t\t\/\/ Add ABBR_OFF for characters above 0x100, this is\n\t\t\t\/\/ what check_abbr() expects.\n\t\t\t\t(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c)\n\t\t    || c == Ctrl_RSB))\n\t    goto cmdline_changed;\n\n\t\/*\n\t * put the character in the command line\n\t *\/\n\tif (IS_SPECIAL(c) || mod_mask != 0)\n\t    put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE);\n\telse\n\t{\n\t    if (has_mbyte)\n\t    {\n\t\tj = (*mb_char2bytes)(c, IObuff);\n\t\tIObuff[j] = NUL;\t\/\/ exclude composing chars\n\t\tput_on_cmdline(IObuff, j, TRUE);\n\t    }\n\t    else\n\t    {\n\t\tIObuff[0] = c;\n\t\tput_on_cmdline(IObuff, 1, TRUE);\n\t    }\n\t}\n\tgoto cmdline_changed;\n\n\/*\n * This part implements incremental searches for \"\/\" and \"?\"\n * Jump to cmdline_not_changed when a character has been read but the command\n * line did not change. Then we only search and redraw if something changed in\n * the past.\n * Jump to cmdline_changed when the command line did change.\n * (Sorry for the goto's, I know it is ugly).\n *\/\ncmdline_not_changed:\n#ifdef FEAT_SEARCH_EXTRA\n\tif (!is_state.incsearch_postponed)\n\t    continue;\n#endif\n\ncmdline_changed:\n#ifdef FEAT_SEARCH_EXTRA\n\t\/\/ If the window changed incremental search state is not valid.\n\tif (is_state.winid != curwin->w_id)\n\t    init_incsearch_state(&is_state);\n#endif\n\tif (trigger_cmdlinechanged)\n\t    \/\/ Trigger CmdlineChanged autocommands.\n\t    trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);\n\n#ifdef FEAT_SEARCH_EXTRA\n\tif (xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL))\n\t    may_do_incsearch_highlighting(firstc, count, &is_state);\n#endif\n\n#ifdef FEAT_RIGHTLEFT\n\tif (cmdmsg_rl\n# ifdef FEAT_ARABIC\n\t\t|| (p_arshape && !p_tbidi\n\t\t\t\t       && cmdline_has_arabic(0, ccline.cmdlen))\n# endif\n\t\t)\n\t    \/\/ Always redraw the whole command line to fix shaping and\n\t    \/\/ right-left typing.  Not efficient, but it works.\n\t    \/\/ Do it only when there are no characters left to read\n\t    \/\/ to avoid useless intermediate redraws.\n\t    if (vpeekc() == NUL)\n\t\tredrawcmd();\n#endif\n    }\n\nreturncmd:\n\n#ifdef FEAT_RIGHTLEFT\n    cmdmsg_rl = FALSE;\n#endif\n\n    ExpandCleanup(&xpc);\n    ccline.xpc = NULL;\n\n#ifdef FEAT_SEARCH_EXTRA\n    finish_incsearch_highlighting(gotesc, &is_state, FALSE);\n#endif\n\n    if (ccline.cmdbuff != NULL)\n    {\n\t\/*\n\t * Put line in history buffer (\":\" and \"=\" only when it was typed).\n\t *\/\n\tif (ccline.cmdlen && firstc != NUL\n\t\t&& (some_key_typed || histype == HIST_SEARCH))\n\t{\n\t    add_to_history(histype, ccline.cmdbuff, TRUE,\n\t\t\t\t       histype == HIST_SEARCH ? firstc : NUL);\n\t    if (firstc == ':')\n\t    {\n\t\tvim_free(new_last_cmdline);\n\t\tnew_last_cmdline = vim_strsave(ccline.cmdbuff);\n\t    }\n\t}\n\n\tif (gotesc)\n\t    abandon_cmdline();\n    }\n\n    \/*\n     * If the screen was shifted up, redraw the whole screen (later).\n     * If the line is too long, clear it, so ruler and shown command do\n     * not get printed in the middle of it.\n     *\/\n    msg_check();\n    msg_scroll = save_msg_scroll;\n    redir_off = FALSE;\n\n    \/\/ When the command line was typed, no need for a wait-return prompt.\n    if (some_key_typed)\n\tneed_wait_return = FALSE;\n\n    \/\/ Trigger CmdlineLeave autocommands.\n    trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);\n\n    State = save_State;\n\n#ifdef FEAT_EVAL\n    if (!debug_mode)\n\tmay_trigger_modechanged();\n#endif\n\n#ifdef HAVE_INPUT_METHOD\n    if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP)\n\tim_save_status(b_im_ptr);\n    im_set_active(FALSE);\n#endif\n    setmouse();\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n    sb_text_end_cmdline();\n\ntheend:\n    {\n\tchar_u *p = ccline.cmdbuff;\n\n\t--depth;\n\tif (did_save_ccline)\n\t    restore_cmdline(&save_ccline);\n\telse\n\t    ccline.cmdbuff = NULL;\n\treturn p;\n    }\n}","target":0,"code_token_length":7605,"total_token_length":7841,"max_tokens_setting":8192}
+{"idx":462058,"func":"void t2p_read_tiff_data(T2P* t2p, TIFF* input){\n\n\tint i=0;\n\tuint16* r = NULL;\n\tuint16* g = NULL;\n\tuint16* b = NULL;\n\tuint16* a = NULL;\n\tuint16 xuint16;\n\tuint16* xuint16p;\n\tfloat* xfloatp;\n\n\tt2p->pdf_transcode = T2P_TRANSCODE_ENCODE;\n\tt2p->pdf_sample = T2P_SAMPLE_NOTHING;\n        t2p->pdf_switchdecode = t2p->pdf_colorspace_invert;\n        \n\t\n\tTIFFSetDirectory(input, t2p->tiff_pages[t2p->pdf_page].page_directory);\n\n\tTIFFGetField(input, TIFFTAG_IMAGEWIDTH, &(t2p->tiff_width));\n\tif(t2p->tiff_width == 0){\n\t\tTIFFError(\n\t\t\tTIFF2PDF_MODULE, \n\t\t\t\"No support for %s with zero width\", \n\t\t\tTIFFFileName(input)\t);\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\treturn;\n\t}\n\n\tTIFFGetField(input, TIFFTAG_IMAGELENGTH, &(t2p->tiff_length));\n\tif(t2p->tiff_length == 0){\n\t\tTIFFError(\n\t\t\tTIFF2PDF_MODULE, \n\t\t\t\"No support for %s with zero length\", \n\t\t\tTIFFFileName(input)\t);\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\treturn;\n\t}\n\n        if(TIFFGetField(input, TIFFTAG_COMPRESSION, &(t2p->tiff_compression)) == 0){\n                TIFFError(\n                        TIFF2PDF_MODULE, \n                        \"No support for %s with no compression tag\", \n                        TIFFFileName(input)     );\n                t2p->t2p_error = T2P_ERR_ERROR;\n                return;\n\n        }\n        if( TIFFIsCODECConfigured(t2p->tiff_compression) == 0){\n\t\tTIFFError(\n\t\t\tTIFF2PDF_MODULE, \n\t\t\t\"No support for %s with compression type %u:  not configured\", \n\t\t\tTIFFFileName(input), \n\t\t\tt2p->tiff_compression\t\n\t\t\t);\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\treturn;\n\t\n\t}\n\n\tTIFFGetFieldDefaulted(input, TIFFTAG_BITSPERSAMPLE, &(t2p->tiff_bitspersample));\n\tswitch(t2p->tiff_bitspersample){\n\t\tcase 1:\n\t\tcase 2:\n\t\tcase 4:\n\t\tcase 8:\n\t\t\tbreak;\n\t\tcase 0:\n\t\t\tTIFFWarning(\n\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\"Image %s has 0 bits per sample, assuming 1\",\n\t\t\t\tTIFFFileName(input));\n\t\t\tt2p->tiff_bitspersample=1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tTIFFError(\n\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\"No support for %s with %u bits per sample\",\n\t\t\t\tTIFFFileName(input),\n\t\t\t\tt2p->tiff_bitspersample);\n\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\treturn;\n\t}\n\n\tTIFFGetFieldDefaulted(input, TIFFTAG_SAMPLESPERPIXEL, &(t2p->tiff_samplesperpixel));\n\tif(t2p->tiff_samplesperpixel>4){\n\t\tTIFFError(\n\t\t\tTIFF2PDF_MODULE, \n\t\t\t\"No support for %s with %u samples per pixel\",\n\t\t\tTIFFFileName(input),\n\t\t\tt2p->tiff_samplesperpixel);\n\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\treturn;\n\t}\n\tif(t2p->tiff_samplesperpixel==0){\n\t\tTIFFWarning(\n\t\t\tTIFF2PDF_MODULE, \n\t\t\t\"Image %s has 0 samples per pixel, assuming 1\",\n\t\t\tTIFFFileName(input));\n\t\tt2p->tiff_samplesperpixel=1;\n\t}\n\t\n\tif(TIFFGetField(input, TIFFTAG_SAMPLEFORMAT, &xuint16) != 0 ){\n\t\tswitch(xuint16){\n\t\t\tcase 0:\n\t\t\tcase 1:\n\t\t\tcase 4:\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for %s with sample format %u\",\n\t\t\t\t\tTIFFFileName(input),\n\t\t\t\t\txuint16);\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tTIFFGetFieldDefaulted(input, TIFFTAG_FILLORDER, &(t2p->tiff_fillorder));\n\t\n        if(TIFFGetField(input, TIFFTAG_PHOTOMETRIC, &(t2p->tiff_photometric)) == 0){\n                TIFFError(\n                        TIFF2PDF_MODULE, \n                        \"No support for %s with no photometric interpretation tag\", \n                        TIFFFileName(input)     );\n                t2p->t2p_error = T2P_ERR_ERROR;\n                return;\n\n        }\n        \n\tswitch(t2p->tiff_photometric){\n\t\tcase PHOTOMETRIC_MINISWHITE:\n\t\tcase PHOTOMETRIC_MINISBLACK: \n\t\t\tif (t2p->tiff_bitspersample==1){\n\t\t\t\tt2p->pdf_colorspace=T2P_CS_BILEVEL;\n\t\t\t\tif(t2p->tiff_photometric==PHOTOMETRIC_MINISWHITE){\n\t\t\t\t\tt2p->pdf_switchdecode ^= 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tt2p->pdf_colorspace=T2P_CS_GRAY;\n\t\t\t\tif(t2p->tiff_photometric==PHOTOMETRIC_MINISWHITE){\n\t\t\t\t\tt2p->pdf_switchdecode ^= 1;\n\t\t\t\t} \n\t\t\t}\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_RGB: \n\t\t\tt2p->pdf_colorspace=T2P_CS_RGB;\n\t\t\tif(t2p->tiff_samplesperpixel == 3){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)){\n\t\t\t\tif(xuint16==1)\n\t\t\t\t\tgoto photometric_palette;\n\t\t\t}\n\t\t\tif(t2p->tiff_samplesperpixel > 3) {\n\t\t\t\tif(t2p->tiff_samplesperpixel == 4) {\n\t\t\t\t\tt2p->pdf_colorspace = T2P_CS_RGB;\n\t\t\t\t\tif(TIFFGetField(input,\n\t\t\t\t\t\t\tTIFFTAG_EXTRASAMPLES,\n\t\t\t\t\t\t\t&xuint16, &xuint16p)\n\t\t\t\t\t   && xuint16 == 1) {\n\t\t\t\t\t\tif(xuint16p[0] == EXTRASAMPLE_ASSOCALPHA){\n\t\t\t\t\t\t\tif( t2p->tiff_bitspersample != 8 )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t    TIFFError(\n\t\t\t\t\t\t\t\t    TIFF2PDF_MODULE, \n\t\t\t\t\t\t\t\t    \"No support for BitsPerSample=%d for RGBA\",\n\t\t\t\t\t\t\t\t    t2p->tiff_bitspersample);\n\t\t\t\t\t\t\t    t2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\t\t\t\t    return;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tt2p->pdf_sample=T2P_SAMPLE_RGBAA_TO_RGB;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(xuint16p[0] == EXTRASAMPLE_UNASSALPHA){\n\t\t\t\t\t\t\tif( t2p->tiff_bitspersample != 8 )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t    TIFFError(\n\t\t\t\t\t\t\t\t    TIFF2PDF_MODULE, \n\t\t\t\t\t\t\t\t    \"No support for BitsPerSample=%d for RGBA\",\n\t\t\t\t\t\t\t\t    t2p->tiff_bitspersample);\n\t\t\t\t\t\t\t    t2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\t\t\t\t    return;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tt2p->pdf_sample=T2P_SAMPLE_RGBA_TO_RGB;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTIFFWarning(\n\t\t\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\t\t\"RGB image %s has 4 samples per pixel, assuming RGBA\",\n\t\t\t\t\t\t\tTIFFFileName(input));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tt2p->pdf_colorspace=T2P_CS_CMYK;\n\t\t\t\t\tt2p->pdf_switchdecode ^= 1;\n\t\t\t\t\tTIFFWarning(\n\t\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\t\"RGB image %s has 4 samples per pixel, assuming inverse CMYK\",\n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tTIFFError(\n\t\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\t\"No support for RGB image %s with %u samples per pixel\", \n\t\t\t\t\t\tTIFFFileName(input), \n\t\t\t\t\t\tt2p->tiff_samplesperpixel);\n\t\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for RGB image %s with %u samples per pixel\", \n\t\t\t\t\tTIFFFileName(input), \n\t\t\t\t\tt2p->tiff_samplesperpixel);\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tcase PHOTOMETRIC_PALETTE: \n\t\t\tphotometric_palette:\n\t\t\tif(t2p->tiff_samplesperpixel!=1){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for palettized image %s with not one sample per pixel\", \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tt2p->pdf_colorspace=T2P_CS_RGB | T2P_CS_PALETTE;\n\t\t\tt2p->pdf_palettesize=0x0001<<t2p->tiff_bitspersample;\n\t\t\tif(!TIFFGetField(input, TIFFTAG_COLORMAP, &r, &g, &b)){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE,\n\t\t\t\t\t\"Palettized image %s has no color map\",\n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(r == NULL || g == NULL || b == NULL){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE,\n\t\t\t\t\t\"Error getting 3 components from color map\");\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(t2p->pdf_palette != NULL){\n\t\t\t\t_TIFFfree(t2p->pdf_palette);\n\t\t\t\tt2p->pdf_palette=NULL;\n\t\t\t}\n\t\t\tt2p->pdf_palette = (unsigned char*)\n\t\t\t\t_TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_palettesize,3));\n\t\t\tif(t2p->pdf_palette==NULL){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %u bytes of memory for t2p_read_tiff_image, %s\", \n\t\t\t\t\tt2p->pdf_palettesize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor(i=0;i<t2p->pdf_palettesize;i++){\n\t\t\t\tt2p->pdf_palette[(i*3)]  = (unsigned char) (r[i]>>8);\n\t\t\t\tt2p->pdf_palette[(i*3)+1]= (unsigned char) (g[i]>>8);\n\t\t\t\tt2p->pdf_palette[(i*3)+2]= (unsigned char) (b[i]>>8);\n\t\t\t}\n\t\t\tt2p->pdf_palettesize *= 3;\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_SEPARATED:\n\t\t\tif(TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)){\n\t\t\t\tif(xuint16==1){\n\t\t\t\t\t\tgoto photometric_palette_cmyk;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif( TIFFGetField(input, TIFFTAG_INKSET, &xuint16) ){\n\t\t\t\tif(xuint16 != INKSET_CMYK){\n\t\t\t\t\tTIFFError(\n\t\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\t\"No support for %s because its inkset is not CMYK\",\n\t\t\t\t\t\tTIFFFileName(input) );\n\t\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(t2p->tiff_samplesperpixel==4){\n\t\t\t\tt2p->pdf_colorspace=T2P_CS_CMYK;\n\t\t\t} else {\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for %s because it has %u samples per pixel\",\n\t\t\t\t\tTIFFFileName(input), \n\t\t\t\t\tt2p->tiff_samplesperpixel);\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\t\tphotometric_palette_cmyk:\n\t\t\tif(t2p->tiff_samplesperpixel!=1){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for palettized CMYK image %s with not one sample per pixel\", \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tt2p->pdf_colorspace=T2P_CS_CMYK | T2P_CS_PALETTE;\n\t\t\tt2p->pdf_palettesize=0x0001<<t2p->tiff_bitspersample;\n\t\t\tif(!TIFFGetField(input, TIFFTAG_COLORMAP, &r, &g, &b, &a)){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE,\n\t\t\t\t\t\"Palettized image %s has no color map\",\n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(r == NULL || g == NULL || b == NULL || a == NULL){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE,\n\t\t\t\t\t\"Error getting 4 components from color map\");\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(t2p->pdf_palette != NULL){\n\t\t\t\t_TIFFfree(t2p->pdf_palette);\n\t\t\t\tt2p->pdf_palette=NULL;\n\t\t\t}\n\t\t\tt2p->pdf_palette = (unsigned char*) \n\t\t\t\t_TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_palettesize,4));\n\t\t\tif(t2p->pdf_palette==NULL){\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"Can't allocate %u bytes of memory for t2p_read_tiff_image, %s\", \n\t\t\t\t\tt2p->pdf_palettesize, \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor(i=0;i<t2p->pdf_palettesize;i++){\n\t\t\t\tt2p->pdf_palette[(i*4)]  = (unsigned char) (r[i]>>8);\n\t\t\t\tt2p->pdf_palette[(i*4)+1]= (unsigned char) (g[i]>>8);\n\t\t\t\tt2p->pdf_palette[(i*4)+2]= (unsigned char) (b[i]>>8);\n\t\t\t\tt2p->pdf_palette[(i*4)+3]= (unsigned char) (a[i]>>8);\n\t\t\t}\n\t\t\tt2p->pdf_palettesize *= 4;\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_YCBCR:\n\t\t\tt2p->pdf_colorspace=T2P_CS_RGB;\n\t\t\tif(t2p->tiff_samplesperpixel==1){\n\t\t\t\tt2p->pdf_colorspace=T2P_CS_GRAY;\n\t\t\t\tt2p->tiff_photometric=PHOTOMETRIC_MINISBLACK;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tt2p->pdf_sample=T2P_SAMPLE_YCBCR_TO_RGB;\n#ifdef JPEG_SUPPORT\n\t\t\tif(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){\n\t\t\t\tt2p->pdf_sample=T2P_SAMPLE_NOTHING;\n\t\t\t}\n#endif\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_CIELAB:\n            if( t2p->tiff_samplesperpixel != 3){\n                TIFFError(\n                    TIFF2PDF_MODULE, \n                    \"Unsupported samplesperpixel = %d for CIELAB\", \n                    t2p->tiff_samplesperpixel);\n                t2p->t2p_error = T2P_ERR_ERROR;\n                return;\n            }\n            if( t2p->tiff_bitspersample != 8){\n                TIFFError(\n                    TIFF2PDF_MODULE, \n                    \"Invalid bitspersample = %d for CIELAB\", \n                    t2p->tiff_bitspersample);\n                t2p->t2p_error = T2P_ERR_ERROR;\n                return;\n            }\n\t\t\tt2p->pdf_labrange[0]= -127;\n\t\t\tt2p->pdf_labrange[1]= 127;\n\t\t\tt2p->pdf_labrange[2]= -127;\n\t\t\tt2p->pdf_labrange[3]= 127;\n\t\t\tt2p->pdf_sample=T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED;\n\t\t\tt2p->pdf_colorspace=T2P_CS_LAB;\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_ICCLAB:\n\t\t\tt2p->pdf_labrange[0]= 0;\n\t\t\tt2p->pdf_labrange[1]= 255;\n\t\t\tt2p->pdf_labrange[2]= 0;\n\t\t\tt2p->pdf_labrange[3]= 255;\n\t\t\tt2p->pdf_colorspace=T2P_CS_LAB;\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_ITULAB:\n            if( t2p->tiff_samplesperpixel != 3){\n                TIFFError(\n                    TIFF2PDF_MODULE, \n                    \"Unsupported samplesperpixel = %d for ITULAB\", \n                    t2p->tiff_samplesperpixel);\n                t2p->t2p_error = T2P_ERR_ERROR;\n                return;\n            }\n            if( t2p->tiff_bitspersample != 8){\n                TIFFError(\n                    TIFF2PDF_MODULE, \n                    \"Invalid bitspersample = %d for ITULAB\", \n                    t2p->tiff_bitspersample);\n                t2p->t2p_error = T2P_ERR_ERROR;\n                return;\n            }\n\t\t\tt2p->pdf_labrange[0]=-85;\n\t\t\tt2p->pdf_labrange[1]=85;\n\t\t\tt2p->pdf_labrange[2]=-75;\n\t\t\tt2p->pdf_labrange[3]=124;\n\t\t\tt2p->pdf_sample=T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED;\n\t\t\tt2p->pdf_colorspace=T2P_CS_LAB;\n\t\t\tbreak;\n\t\tcase PHOTOMETRIC_LOGL:\n\t\tcase PHOTOMETRIC_LOGLUV:\n\t\t\tTIFFError(\n\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\"No support for %s with photometric interpretation LogL\/LogLuv\", \n\t\t\t\tTIFFFileName(input));\n\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\treturn;\n\t\tdefault:\n\t\t\tTIFFError(\n\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\"No support for %s with photometric interpretation %u\", \n\t\t\t\tTIFFFileName(input),\n\t\t\t\tt2p->tiff_photometric);\n\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\treturn;\n\t}\n\n\tif(TIFFGetField(input, TIFFTAG_PLANARCONFIG, &(t2p->tiff_planar))){\n\t\tswitch(t2p->tiff_planar){\n\t\t\tcase 0:\n\t\t\t\tTIFFWarning(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"Image %s has planar configuration 0, assuming 1\", \n\t\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->tiff_planar=PLANARCONFIG_CONTIG;\n\t\t\tcase PLANARCONFIG_CONTIG:\n\t\t\t\tbreak;\n\t\t\tcase PLANARCONFIG_SEPARATE:\n\t\t\t\tt2p->pdf_sample=T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG;\n\t\t\t\tif(t2p->tiff_bitspersample!=8){\n\t\t\t\t\tTIFFError(\n\t\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\t\"No support for %s with separated planar configuration and %u bits per sample\", \n\t\t\t\t\t\tTIFFFileName(input),\n\t\t\t\t\t\tt2p->tiff_bitspersample);\n\t\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tTIFFError(\n\t\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\t\"No support for %s with planar configuration %u\", \n\t\t\t\t\tTIFFFileName(input),\n\t\t\t\t\tt2p->tiff_planar);\n\t\t\t\tt2p->t2p_error = T2P_ERR_ERROR;\n\t\t\t\treturn;\n\t\t}\n\t}\n\n        TIFFGetFieldDefaulted(input, TIFFTAG_ORIENTATION,\n                              &(t2p->tiff_orientation));\n        if(t2p->tiff_orientation>8){\n                TIFFWarning(TIFF2PDF_MODULE,\n                            \"Image %s has orientation %u, assuming 0\",\n                            TIFFFileName(input), t2p->tiff_orientation);\n                t2p->tiff_orientation=0;\n        }\n\n        if(TIFFGetField(input, TIFFTAG_XRESOLUTION, &(t2p->tiff_xres) ) == 0){\n                t2p->tiff_xres=0.0;\n        }\n        if(TIFFGetField(input, TIFFTAG_YRESOLUTION, &(t2p->tiff_yres) ) == 0){\n                t2p->tiff_yres=0.0;\n        }\n\tTIFFGetFieldDefaulted(input, TIFFTAG_RESOLUTIONUNIT,\n\t\t\t      &(t2p->tiff_resunit));\n\tif(t2p->tiff_resunit == RESUNIT_CENTIMETER) {\n\t\tt2p->tiff_xres *= 2.54F;\n\t\tt2p->tiff_yres *= 2.54F;\n\t} else if (t2p->tiff_resunit != RESUNIT_INCH\n\t\t   && t2p->pdf_centimeters != 0) {\n\t\tt2p->tiff_xres *= 2.54F;\n\t\tt2p->tiff_yres *= 2.54F;\n\t}\n\n\tt2p_compose_pdf_page(t2p);\n        if( t2p->t2p_error == T2P_ERR_ERROR )\n\t    return;\n\n\tt2p->pdf_transcode = T2P_TRANSCODE_ENCODE;\n        \/* It seems that T2P_TRANSCODE_RAW mode doesn't support separate->contig *\/\n        \/* conversion. At least t2p_read_tiff_size and t2p_read_tiff_size_tile *\/\n        \/* do not take into account the number of samples, and thus *\/\n        \/* that can cause heap buffer overflows such as in *\/\n        \/* http:\/\/bugzilla.maptools.org\/show_bug.cgi?id=2715 *\/\n\tif(t2p->pdf_nopassthrough==0 && t2p->tiff_planar!=PLANARCONFIG_SEPARATE){\n#ifdef CCITT_SUPPORT\n\t\tif(t2p->tiff_compression==COMPRESSION_CCITTFAX4  \n\t\t\t){\n\t\t\tif(TIFFIsTiled(input) || (TIFFNumberOfStrips(input)==1) ){\n\t\t\t\tt2p->pdf_transcode = T2P_TRANSCODE_RAW;\n\t\t\t\tt2p->pdf_compression=T2P_COMPRESS_G4;\n\t\t\t}\n\t\t}\n#endif\n#ifdef ZIP_SUPPORT\n\t\tif(t2p->tiff_compression== COMPRESSION_ADOBE_DEFLATE \n\t\t\t|| t2p->tiff_compression==COMPRESSION_DEFLATE){\n\t\t\tif(TIFFIsTiled(input) || (TIFFNumberOfStrips(input)==1) ){\n\t\t\t\tuint16 predictor;\n\t\t\t\tt2p->pdf_transcode = T2P_TRANSCODE_RAW;\n\t\t\t\tt2p->pdf_compression=T2P_COMPRESS_ZIP;\n\t\t\t\tTIFFGetField(input, TIFFTAG_PREDICTOR, &predictor);\n\t\t\t\tt2p->pdf_compressionquality = predictor;\n\t\t\t\t\/* TIFFTAG_ZIPQUALITY is always Z_DEFAULT_COMPRESSION on reading *\/\n\t\t\t}\n\t\t}\n#endif\n#ifdef OJPEG_SUPPORT\n\t\tif(t2p->tiff_compression==COMPRESSION_OJPEG){\n\t\t\tt2p->pdf_transcode = T2P_TRANSCODE_RAW;\n\t\t\tt2p->pdf_compression=T2P_COMPRESS_JPEG;\n\t\t\tt2p_process_ojpeg_tables(t2p, input);\n\t\t}\n#endif\n#ifdef JPEG_SUPPORT\n\t\tif(t2p->tiff_compression==COMPRESSION_JPEG){\n\t\t\tt2p->pdf_transcode = T2P_TRANSCODE_RAW;\n\t\t\tt2p->pdf_compression=T2P_COMPRESS_JPEG;\n\t\t}\n#endif\n\t\t(void)0;\n\t}\n\n\tif(t2p->pdf_transcode!=T2P_TRANSCODE_RAW){\n\t\tt2p->pdf_compression = t2p->pdf_defaultcompression;\n\t}\n\n#ifdef JPEG_SUPPORT\n\tif(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){\n\t\tif(t2p->pdf_colorspace & T2P_CS_PALETTE){\n\t\t\tt2p->pdf_sample|=T2P_SAMPLE_REALIZE_PALETTE;\n\t\t\tt2p->pdf_colorspace ^= T2P_CS_PALETTE;\n\t\t\tt2p->tiff_pages[t2p->pdf_page].page_extra--;\n\t\t}\n\t}\n\tif(t2p->tiff_compression==COMPRESSION_JPEG){\n\t\tif(t2p->tiff_planar==PLANARCONFIG_SEPARATE){\n\t\t\tTIFFError(\n\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\"No support for %s with JPEG compression and separated planar configuration\", \n\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error=T2P_ERR_ERROR;\n\t\t\treturn;\n\t\t}\n\t}\n#endif\n#ifdef OJPEG_SUPPORT\n\tif(t2p->tiff_compression==COMPRESSION_OJPEG){\n\t\tif(t2p->tiff_planar==PLANARCONFIG_SEPARATE){\n\t\t\tTIFFError(\n\t\t\t\tTIFF2PDF_MODULE, \n\t\t\t\t\"No support for %s with OJPEG compression and separated planar configuration\", \n\t\t\t\tTIFFFileName(input));\n\t\t\t\tt2p->t2p_error=T2P_ERR_ERROR;\n\t\t\treturn;\n\t\t}\n\t}\n#endif\n\n\tif(t2p->pdf_sample & T2P_SAMPLE_REALIZE_PALETTE){\n\t\tif(t2p->pdf_colorspace & T2P_CS_CMYK){\n\t\t\tt2p->tiff_samplesperpixel=4;\n\t\t\tt2p->tiff_photometric=PHOTOMETRIC_SEPARATED;\n\t\t} else {\n\t\t\tt2p->tiff_samplesperpixel=3;\n\t\t\tt2p->tiff_photometric=PHOTOMETRIC_RGB;\n\t\t}\n\t}\n\n\tif (TIFFGetField(input, TIFFTAG_TRANSFERFUNCTION,\n\t\t\t &(t2p->tiff_transferfunction[0]),\n\t\t\t &(t2p->tiff_transferfunction[1]),\n\t\t\t &(t2p->tiff_transferfunction[2]))) {\n\t\tif((t2p->tiff_transferfunction[1] != (uint16*) NULL) &&\n                   (t2p->tiff_transferfunction[2] != (uint16*) NULL)\n                  ) {\n\t\t\tt2p->tiff_transferfunctioncount=3;\n\t\t} else {\n\t\t\tt2p->tiff_transferfunctioncount=1;\n\t\t}\n\t} else {\n\t\tt2p->tiff_transferfunctioncount=0;\n\t}\n\tif(TIFFGetField(input, TIFFTAG_WHITEPOINT, &xfloatp)!=0){\n\t\tt2p->tiff_whitechromaticities[0]=xfloatp[0];\n\t\tt2p->tiff_whitechromaticities[1]=xfloatp[1];\n\t\tif(t2p->pdf_colorspace & T2P_CS_GRAY){\n\t\t\tt2p->pdf_colorspace |= T2P_CS_CALGRAY;\n\t\t}\n\t\tif(t2p->pdf_colorspace & T2P_CS_RGB){\n\t\t\tt2p->pdf_colorspace |= T2P_CS_CALRGB;\n\t\t}\n\t}\n\tif(TIFFGetField(input, TIFFTAG_PRIMARYCHROMATICITIES, &xfloatp)!=0){\n\t\tt2p->tiff_primarychromaticities[0]=xfloatp[0];\n\t\tt2p->tiff_primarychromaticities[1]=xfloatp[1];\n\t\tt2p->tiff_primarychromaticities[2]=xfloatp[2];\n\t\tt2p->tiff_primarychromaticities[3]=xfloatp[3];\n\t\tt2p->tiff_primarychromaticities[4]=xfloatp[4];\n\t\tt2p->tiff_primarychromaticities[5]=xfloatp[5];\n\t\tif(t2p->pdf_colorspace & T2P_CS_RGB){\n\t\t\tt2p->pdf_colorspace |= T2P_CS_CALRGB;\n\t\t}\n\t}\n\tif(t2p->pdf_colorspace & T2P_CS_LAB){\n\t\tif(TIFFGetField(input, TIFFTAG_WHITEPOINT, &xfloatp) != 0){\n\t\t\tt2p->tiff_whitechromaticities[0]=xfloatp[0];\n\t\t\tt2p->tiff_whitechromaticities[1]=xfloatp[1];\n\t\t} else {\n\t\t\tt2p->tiff_whitechromaticities[0]=0.3457F; \/* 0.3127F; *\/\n\t\t\tt2p->tiff_whitechromaticities[1]=0.3585F; \/* 0.3290F; *\/\n\t\t}\n\t}\n\tif(TIFFGetField(input, \n\t\tTIFFTAG_ICCPROFILE, \n\t\t&(t2p->tiff_iccprofilelength), \n\t\t&(t2p->tiff_iccprofile))!=0){\n\t\tt2p->pdf_colorspace |= T2P_CS_ICCBASED;\n\t} else {\n\t\tt2p->tiff_iccprofilelength=0;\n\t\tt2p->tiff_iccprofile=NULL;\n\t}\n\t\n#ifdef CCITT_SUPPORT\n\tif( t2p->tiff_bitspersample==1 &&\n\t\tt2p->tiff_samplesperpixel==1){\n\t\tt2p->pdf_compression = T2P_COMPRESS_G4;\n\t}\n#endif\n\n\n\treturn;\n}","target":0,"code_token_length":6537,"total_token_length":6773,"max_tokens_setting":8192}
+{"idx":495814,"func":"static s32 gf_vvc_read_sps_bs_internal(GF_BitStream *bs, VVCState *vvc, u8 layer_id, u32 *vui_flag_pos)\n{\n\ts32 vps_id, sps_id;\n\tu32 i, CtbSizeY;\n\tVVC_SPS *sps;\n\tu8 sps_ptl_dpb_hrd_params_present_flag;\n\n\tif (vui_flag_pos) *vui_flag_pos = 0;\n\n\tsps_id = gf_bs_read_int_log(bs, 4, \"sps_id\");\n\tif ((sps_id<0) || (sps_id >= 16)) {\n\t\treturn -1;\n\t}\n\tvps_id = gf_bs_read_int_log(bs, 4, \"vps_id\");\n\tif ((vps_id<0) || (vps_id >= 16)) {\n\t\treturn -1;\n\t}\n\tif (!vps_id && !vvc->vps[0].state) {\n\t\tvvc->vps[0].state = 1;\n\t\tvvc->vps[0].num_ptl = 1;\n\t\tvvc->vps[0].max_layers = 1;\n\t\tvvc->vps[0].all_layers_independent = 1;\n\t}\n\n\tsps = &vvc->sps[sps_id];\n\tif (!sps->state) {\n\t\tsps->state = 1;\n\t\tsps->id = sps_id;\n\t\tsps->vps_id = vps_id;\n\t}\n\tsps->max_sublayers = 1 + gf_bs_read_int_log(bs, 3, \"max_sublayers_minus1\");\n\tsps->chroma_format_idc = gf_bs_read_int_log(bs, 2, \"chroma_format_idc\");\n\tsps->log2_ctu_size = 5 + gf_bs_read_int_log(bs, 2, \"log2_ctu_size_minus5\");\n\tCtbSizeY = 1<<sps->log2_ctu_size;\n\n\tsps_ptl_dpb_hrd_params_present_flag = gf_bs_read_int_log(bs, 1, \"sps_ptl_dpb_hrd_params_present_flag\");\n\tif (sps_ptl_dpb_hrd_params_present_flag) {\n\t\tVVC_ProfileTierLevel ptl, *p_ptl;\n\t\tif (sps->vps_id) {\n\t\t\tp_ptl = &ptl;\n\t\t} else {\n\t\t\tp_ptl = &vvc->vps[0].ptl[0];\n\t\t}\n\t\tmemset(p_ptl, 0, sizeof(VVC_ProfileTierLevel));\n\t\tp_ptl->pt_present = 1;\n\t\tp_ptl->ptl_max_tid = sps->max_sublayers-1;\n\t\tvvc_profile_tier_level(bs, p_ptl, 0);\n\t}\n\tsps->gdr_enabled = gf_bs_read_int_log(bs, 1, \"gdr_enabled\");\n\tsps->ref_pic_resampling = gf_bs_read_int_log(bs, 1, \"ref_pic_resampling\");\n\tif (sps->ref_pic_resampling)\n\t\tsps->res_change_in_clvs = gf_bs_read_int_log(bs, 1, \"res_change_in_clvs\");\n\tsps->width = gf_bs_read_ue_log(bs, \"width\");\n\tsps->height = gf_bs_read_ue_log(bs, \"height\");\n\tsps->conf_window = gf_bs_read_int_log(bs, 1, \"conformance_window_present_flag\");\n\tif (sps->conf_window) {\n\t\tu32 SubWidthC, SubHeightC;\n\t\tsps->cw_left = gf_bs_read_ue_log(bs, \"conformance_window_left\");\n\t\tsps->cw_right = gf_bs_read_ue_log(bs, \"conformance_window_right\");\n\t\tsps->cw_top = gf_bs_read_ue_log(bs, \"conformance_window_top\");\n\t\tsps->cw_bottom = gf_bs_read_ue_log(bs, \"conformance_window_bottom\");\n\n\n\t\tif (sps->chroma_format_idc == 1) {\n\t\t\tSubWidthC = SubHeightC = 2;\n\t\t} else if (sps->chroma_format_idc == 2) {\n\t\t\tSubWidthC = 2;\n\t\t\tSubHeightC = 1;\n\t\t} else {\n\t\t\tSubWidthC = SubHeightC = 1;\n\t\t}\n\t\tsps->width -= SubWidthC * (sps->cw_left + sps->cw_right);\n\t\tsps->height -= SubHeightC * (sps->cw_top + sps->cw_bottom);\n\t}\n\t\n\tsps->subpic_info_present = gf_bs_read_int_log(bs, 1, \"subpic_info_present\");\n\tif (sps->subpic_info_present) {\n\t\tsps->nb_subpics = 1 + gf_bs_read_ue_log(bs, \"nb_subpics_minus1\");\n\t\tif (sps->nb_subpics>1) {\n\t\t\tu32 tmpWidthVal, tmpHeightVal;\n\t\t\tsps->independent_subpic_flags = gf_bs_read_int_log(bs, 1, \"independent_subpic_flags\");\n\t\t\tsps->subpic_same_size = gf_bs_read_int_log(bs, 1, \"subpic_same_size\");\n\n\t\t\ttmpWidthVal = (sps->width + CtbSizeY-1) \/ CtbSizeY;\n\t\t\ttmpWidthVal = gf_get_bit_size(tmpWidthVal);\n\t\t\ttmpHeightVal = (sps->height + CtbSizeY-1) \/ CtbSizeY;\n\t\t\ttmpHeightVal = gf_get_bit_size(tmpHeightVal);\n\n\t\t\tfor (i=0; i<sps->nb_subpics; i++) {\n\t\t\t\tif( !sps->subpic_same_size || !i) {\n\t\t\t\t\tif (i && (sps->width > CtbSizeY))\n\t\t\t\t\t\tgf_bs_read_int_log(bs, tmpWidthVal, \"subpic_ctu_top_left_x\");\n\t\t\t\t\tif (i && (sps->height > CtbSizeY))\n\t\t\t\t\t\tgf_bs_read_int_log(bs, tmpHeightVal, \"subpic_ctu_top_left_y\");\n\t\t\t\t\tif ((i+1 < sps->nb_subpics) && (sps->width > CtbSizeY))\n\t\t\t\t\t\tgf_bs_read_int_log(bs, tmpWidthVal, \"subpic_width_minus1\");\n\t\t\t\t\tif ((i+1 < sps->nb_subpics) && (sps->height > CtbSizeY))\n\t\t\t\t\t\tgf_bs_read_int_log(bs, tmpHeightVal, \"subpic_height_minus1\");\n\t\t\t\t}\n\t\t\t\tif (!sps->independent_subpic_flags) {\n\t\t\t\t\tgf_bs_read_int_log(bs, 1, \"subpic_treated_as_pic_flag\");\n\t\t\t\t\tgf_bs_read_int_log(bs, 1, \"loop_filter_across_subpic_enabled_flag\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tsps->subpicid_len = gf_bs_read_ue_log(bs, \"subpic_id_len_minus1\") + 1;\n\t\t\tsps->subpicid_mapping_explicit = gf_bs_read_int_log(bs, 1, \"subpic_id_mapping_explicitly_signalled_flag\");\n\t\t\tif (sps->subpicid_mapping_explicit) {\n\t\t\t\tsps->subpicid_mapping_present = gf_bs_read_int_log(bs, 1, \"subpic_id_mapping_present_flag\");\n\t\t\t\tif (sps->subpicid_mapping_present) {\n\t\t\t\t\tfor (i=0; i<sps->nb_subpics; i++) {\n\t\t\t\t\t\tgf_bs_read_ue_log(bs, \"subpic_id\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tsps->nb_subpics = 1;\n\t}\n\tsps->bitdepth = gf_bs_read_ue_log(bs, \"bitdepth_minus8\") + 8;\n\tsps->entropy_coding_sync_enabled_flag = gf_bs_read_int_log(bs, 1, \"entropy_coding_sync_enabled_flag\");\n\tsps->entry_point_offsets_present_flag = gf_bs_read_int_log(bs, 1, \"entry_point_offsets_present_flag\");\n\tsps->log2_max_poc_lsb = 4 + gf_bs_read_int_log(bs, 4, \"log2_max_poc_lsb_minus4\");\n\tif ((sps->poc_msb_cycle_flag = gf_bs_read_int_log(bs, 1, \"poc_msb_cycle_flag\")))\n\t\tsps->poc_msb_cycle_len = 1 + gf_bs_read_ue_log(bs, \"poc_msb_cycle_len_minus1\");\n\n\tu8 sps_num_extra_ph_bits = 8 * gf_bs_read_int_log(bs, 2, \"sps_num_extra_ph_bytes\");\n\tfor (i=0; i<sps_num_extra_ph_bits; i++) {\n\t\tif (gf_bs_read_int_log_idx(bs, 1, \"extra_ph_bit_present_flag\", 1))\n\t\t\tsps->ph_num_extra_bits++;\n\t}\n\tu8 sps_num_extra_sh_bits = 8 * gf_bs_read_int_log(bs, 2, \"num_extra_sh_bytes\");\n\tfor (i=0; i<sps_num_extra_sh_bits; i++) {\n\t\tif (gf_bs_read_int_log_idx(bs, 1, \"extra_sh_bit_present_flag\", i))\n\t\t\tsps->sh_num_extra_bits++;\n\t}\n\n\tif (sps_ptl_dpb_hrd_params_present_flag) {\n\t\tu8 sps_sublayer_dpb_params_flag = 0;\n\t\tif (sps->max_sublayers>1) {\n\t\t\tsps_sublayer_dpb_params_flag = gf_bs_read_int_log(bs, 1, \"sps_sublayer_dpb_params_flag\");\n\t\t}\n\t\tfor (i=(sps_sublayer_dpb_params_flag ? 0 : sps->max_sublayers-1); i < sps->max_sublayers; i++ ) {\n\t\t\tgf_bs_read_ue_log_idx(bs, \"dpb_max_dec_pic_buffering_minus1\", i);\n\t\t\tgf_bs_read_ue_log_idx(bs, \"dpb_max_num_reorder_pics\", i);\n\t\t\tgf_bs_read_ue_log_idx(bs, \"dpb_max_latency_increase_plus1\", i);\n\t\t}\n\t}\n\tgf_bs_read_ue_log(bs, \"sps_log2_min_luma_coding_block_size_minus2\");\n\tsps->partition_constraints_override_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_partition_constraints_override_enabled_flag\");\n\tgf_bs_read_ue_log(bs, \"sps_log2_min_luma_coding_block_size_minus2\");\n\tu8 sps_max_mtt_hierarchy_depth_intra_slice_luma = gf_bs_read_ue_log(bs, \"sps_max_mtt_hierarchy_depth_intra_slice_luma\");\n\tif (sps_max_mtt_hierarchy_depth_intra_slice_luma != 0) {\n\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_max_bt_min_qt_intra_slice_luma\");\n\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_max_tt_min_qt_intra_slice_luma\");\n\t}\n\tu8 sps_qtbtt_dual_tree_intra_flag = 0;\n\tif (sps->chroma_format_idc) {\n\t\tsps_qtbtt_dual_tree_intra_flag = gf_bs_read_int_log(bs, 1, \"sps_qtbtt_dual_tree_intra_flag\");\n\t}\n\tif (sps_qtbtt_dual_tree_intra_flag) {\n\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_min_qt_min_cb_intra_slice_chroma\");\n\t\tu8 sps_max_mtt_hierarchy_depth_intra_slice_chroma = gf_bs_read_ue_log(bs, \"sps_max_mtt_hierarchy_depth_intra_slice_chroma\");\n\t\tif( sps_max_mtt_hierarchy_depth_intra_slice_chroma != 0) {\n\t\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_max_bt_min_qt_intra_slice_chroma\");\n\t\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_max_tt_min_qt_intra_slice_chroma\");\n\t\t}\n\t}\n\n\tgf_bs_read_ue_log(bs, \"sps_log2_diff_min_qt_min_cb_inter_slice\");\n\tu8 sps_max_mtt_hierarchy_depth_inter_slice = gf_bs_read_ue_log(bs, \"sps_max_mtt_hierarchy_depth_inter_slice\");\n\tif (sps_max_mtt_hierarchy_depth_inter_slice != 0) {\n\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_max_bt_min_qt_inter_slice\");\n\t\tgf_bs_read_ue_log(bs, \"sps_log2_diff_max_tt_min_qt_inter_slice\");\n\t}\n\tu8 max_luma_transform_size_64_flag = 0;\n\tif (CtbSizeY > 32) {\n\t\tmax_luma_transform_size_64_flag = gf_bs_read_int_log(bs, 1, \"sps_max_luma_transform_size_64_flag\");\n\t}\n\tsps->transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_transform_skip_enabled_flag\");\n\n\tif (sps->transform_skip_enabled_flag) {\n\t\tgf_bs_read_ue_log(bs, \"sps_log2_transform_skip_max_size_minus2\");\n\t\tgf_bs_read_int_log(bs, 1, \"sps_bdpcm_enabled_flag\");\n\t}\n\tif (gf_bs_read_int_log(bs, 1, \"sps_mts_enabled_flag\")) {\n\t\tgf_bs_read_int_log(bs, 1, \"sps_explicit_mts_intra_enabled_flag\");\n\t\tgf_bs_read_int_log(bs, 1, \"sps_explicit_mts_inter_enabled_flag\");\n\t}\n\tBool lfnst_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_lfnst_enabled_flag\");\n\tsps->joint_cbcr_enabled_flag = 0;\n\tif (sps->chroma_format_idc) {\n\t\tsps->joint_cbcr_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_joint_cbcr_enabled_flag\");\n\t\tu8 sps_same_qp_table_for_chroma_flag = gf_bs_read_int_log(bs, 1, \"sps_same_qp_table_for_chroma_flag\");\n\t\tu32 numQpTables = sps_same_qp_table_for_chroma_flag ? 1 : (sps->joint_cbcr_enabled_flag ? 3 : 2);\n\t\tfor (i=0; i<numQpTables; i++) {\n\t\t\tgf_bs_read_se_log_idx(bs, \"sps_qp_table_start_minus26\", i);\n\t\t\tu32 j, sps_num_points_in_qp_table = 1 + gf_bs_read_ue_log_idx(bs, \"sps_num_points_in_qp_table_minus1\", i);\n\t\t\tfor (j=0; j<sps_num_points_in_qp_table; j++) {\n\t\t\t\tgf_bs_read_ue_log_idx2(bs, \"sps_delta_qp_in_val_minus1\", i, j);\n\t\t\t\tgf_bs_read_ue_log_idx2(bs, \"sps_delta_qp_diff_val\", i, j);\n\t\t\t}\n\t\t}\n\t}\n\tsps->sao_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_sao_enabled_flag\");\n\tsps->alf_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_alf_enabled_flag\");\n\tif (sps->alf_enabled_flag && sps->chroma_format_idc) {\n\t\tsps->ccalf_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_ccalf_enabled_flag\");\n\t}\n\tsps->lmcs_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_lmcs_enabled_flag\");\n\tsps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, \"sps_weighted_pred_flag\");\n\tsps->weighted_bipred_flag = gf_bs_read_int_log(bs, 1, \"sps_weighted_bipred_flag\");\n\tsps->long_term_ref_pics_flag = gf_bs_read_int_log(bs, 1, \"sps_long_term_ref_pics_flag\");\n\tif (sps->vps_id>0)\n\t\tsps->inter_layer_prediction_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_inter_layer_prediction_enabled_flag\");\n\tsps->idr_rpl_present_flag = gf_bs_read_int_log(bs, 1, \"sps_idr_rpl_present_flag\");\n\tu32 sps_rpl1_same_as_rpl0 = gf_bs_read_int_log(bs, 1, \"sps_rpl1_same_as_rpl0_flag\") ? 1: 2;\n\tfor (i=0; i<sps_rpl1_same_as_rpl0; i++) {\n\t\tu32 j;\n\t\tsps->num_ref_pic_lists[i] = gf_bs_read_ue_log_idx(bs, \"sps_num_ref_pic_lists\", i);\n\t\tfor (j=0; j<sps->num_ref_pic_lists[i]; j++) {\n\t\t\ts32 res = vvc_parse_ref_pic_list_struct(bs, sps, i, j, &sps->rps[i][j]);\n\t\t\tif (res<0) return res;\n\t\t}\n\t}\n\tgf_bs_read_int_log(bs, 1, \"sps_ref_wraparound_enabled_flag\");\n\tsps->temporal_mvp_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_temporal_mvp_enabled_flag\");\n\tif (sps->temporal_mvp_enabled_flag) {\n\t\tgf_bs_read_int_log(bs, 1, \"sps_sbtmvp_enabled_flag\");\n\t}\n\tBool amvr_enabled = gf_bs_read_int_log(bs, 1, \"sps_amvr_enabled_flag\");\n\tsps->bdof_control_present_in_ph_flag = 0;\n\tif (gf_bs_read_int_log(bs, 1, \"sps_bdof_enabled_flag\")) {\n\t\tsps->bdof_control_present_in_ph_flag = gf_bs_read_int_log(bs, 1, \"sps_bdof_control_present_in_ph_flag\");\n\t}\n\tgf_bs_read_int_log(bs, 1, \"sps_smvd_enabled_flag\");\n\tsps->dmvr_control_present_in_ph_flag = 0;\n\tif (gf_bs_read_int_log(bs, 1, \"sps_dmvr_enabled_flag\")) {\n\t\tsps->dmvr_control_present_in_ph_flag = gf_bs_read_int_log(bs, 1, \"sps_dmvr_control_present_in_ph_flag\");\n\t}\n\tsps->mmvd_fullpel_only_enabled_flag = 0;\n\tif (gf_bs_read_int_log(bs, 1, \"sps_mmvd_enabled_flag\")) {\n\t\tsps->mmvd_fullpel_only_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_mmvd_fullpel_only_enabled_flag\");\n\t}\n\tu32 MaxNumMergeCand  = 6 - gf_bs_read_ue_log(bs, \"sps_six_minus_max_num_merge_cand\");\n\n\tsps->prof_control_present_in_ph_flag = 0;\n\tgf_bs_read_int_log(bs, 1, \"sps_sbt_enabled_flag\");\n\tif (gf_bs_read_int_log(bs, 1, \"sps_affine_enabled_flag\")) {\n\t\tgf_bs_read_ue_log(bs, \"sps_five_minus_max_num_subblock_merge_cand\");\n\t\tgf_bs_read_int_log(bs, 1, \"sps_6param_affine_enabled_flag\");\n\t\tif (amvr_enabled) {\n\t\t\tgf_bs_read_int_log(bs, 1, \"sps_affine_amvr_enabled_flag\");\n\t\t}\n\t\tif (gf_bs_read_int_log(bs, 1, \"sps_affine_prof_enabled_flag\")) {\n\t\t\tsps->prof_control_present_in_ph_flag = gf_bs_read_int_log(bs, 1, \"sps_prof_control_present_in_ph_flag\");\n\t\t}\n\t}\n\n\tgf_bs_read_int_log(bs, 1, \"sps_bcw_enabled_flag\");\n\tgf_bs_read_int_log(bs, 1, \"sps_ciip_enabled_flag\");\n\tif (MaxNumMergeCand >= 2) {\n\t\tBool gpm_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_gpm_enabled_flag\");\n\t\tif (gpm_enabled_flag && (MaxNumMergeCand >= 3)) {\n\t\t\tgf_bs_read_ue_log(bs, \"sps_max_num_merge_cand_minus_max_num_gpm_cand\");\n\t\t}\n\t}\n\tgf_bs_read_ue_log(bs, \"sps_log2_parallel_merge_level_minus2\");\n\n\tgf_bs_read_int_log(bs, 1, \"sps_isp_enabled_flag\");\n\tgf_bs_read_int_log(bs, 1, \"sps_mrl_enabled_flag\");\n\tgf_bs_read_int_log(bs, 1, \"sps_mip_enabled_flag\");\n\tif (sps->chroma_format_idc != 0) {\n\t\tgf_bs_read_int_log(bs, 1, \"sps_cclm_enabled_flag\");\n\t}\n\tif (sps->chroma_format_idc == 1) {\n\t\tgf_bs_read_int_log(bs, 1, \"sps_chroma_horizontal_collocated_flag\");\n\t\tgf_bs_read_int_log(bs, 1, \"sps_chroma_vertical_collocated_flag\");\n\t}\n\tBool act_enabled_flag = GF_FALSE;\n\tBool palette_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_palette_enabled_flag\");\n\tif ((sps->chroma_format_idc == 3) && !max_luma_transform_size_64_flag) {\n\t\tact_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_act_enabled_flag\");\n\t}\n\tif (sps->transform_skip_enabled_flag || palette_enabled_flag) {\n\t\tgf_bs_read_ue_log(bs, \"sps_min_qp_prime_ts\");\n\t}\n\tif (gf_bs_read_int_log(bs, 1, \"sps_ibc_enabled_flag\")) {\n\t\tgf_bs_read_ue_log(bs, \"sps_six_minus_max_num_ibc_merge_cand\");\n\t}\n\tif (gf_bs_read_int_log(bs, 1, \"sps_ladf_enabled_flag\")) {\n\t\tu32 num_ladf_intervals_minus2 = gf_bs_read_int_log(bs, 2, \"sps_num_ladf_intervals_minus2\");\n\t\tgf_bs_read_se_log(bs, \"sps_ladf_lowest_interval_qp_offset\");\n\t\tfor (i=0; i<num_ladf_intervals_minus2+1; i++) {\n\t\t\tgf_bs_read_se_log_idx(bs, \"sps_ladf_qp_offset\", i);\n\t\t\tgf_bs_read_ue_log_idx(bs, \"sps_ladf_delta_threshold_minus1\", i);\n\t\t}\n\t}\n\tsps->explicit_scaling_list_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_explicit_scaling_list_enabled_flag\");\n\tif (lfnst_enabled_flag && sps->explicit_scaling_list_enabled_flag) {\n\t\tgf_bs_read_int_log(bs, 1, \"sps_scaling_matrix_for_lfnst_disabled_flag\");\n\t}\n\tBool scaling_matrix_for_alternative_colour_space_disabled_flag = 0;\n\tif (act_enabled_flag && sps->explicit_scaling_list_enabled_flag) {\n\t\tscaling_matrix_for_alternative_colour_space_disabled_flag = gf_bs_read_int_log(bs, 1, \"sps_scaling_matrix_for_alternative_colour_space_disabled_flag\");\n\t}\n\tif (scaling_matrix_for_alternative_colour_space_disabled_flag) {\n\t\tgf_bs_read_int_log(bs, 1, \"sps_scaling_matrix_designated_colour_space_flag\");\n\t}\n\tsps->dep_quant_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_dep_quant_enabled_flag\");\n\tsps->sign_data_hiding_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_sign_data_hiding_enabled_flag\");\n\tsps->virtual_boundaries_enabled_flag = gf_bs_read_int_log(bs, 1, \"sps_virtual_boundaries_enabled_flag\");\n\tif (sps->virtual_boundaries_enabled_flag) {\n\t\tsps->virtual_boundaries_present_flag = gf_bs_read_int_log(bs, 1, \"sps_virtual_boundaries_present_flag\");\n\t\tif (sps->virtual_boundaries_present_flag) {\n\t\t\tu32 num_virtual_boundaries = gf_bs_read_ue_log(bs, \"sps_num_ver_virtual_boundaries\");\n\t\t\tfor (i=0; i<num_virtual_boundaries; i++) {\n\t\t\t\tgf_bs_read_ue_log_idx(bs, \"sps_virtual_boundary_pos_x_minus1\", i);\n\t\t\t}\n\t\t\tnum_virtual_boundaries = gf_bs_read_ue_log(bs, \"sps_num_hor_virtual_boundaries\");\n\t\t\tfor (i=0; i<num_virtual_boundaries; i++) {\n\t\t\t\tgf_bs_read_ue_log_idx(bs, \"sps_virtual_boundary_pos_y_minus1\", i);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (sps_ptl_dpb_hrd_params_present_flag) {\n\t\tif (gf_bs_read_int_log(bs, 1, \"sps_timing_hrd_params_present_flag\")) {\n\t\t\tBool general_nal_hrd_params_present_flag, general_vcl_hrd_params_present_flag, general_du_hrd_params_present_flag;\n\t\t\tu32 hrd_cpb_cnt_minus1=0;\n\t\t\tu32 sublayer_cpb_params_present_flag = 0;\n\t\t\tvvc_parse_general_timing_hrd_parameters(bs, sps, NULL, &general_nal_hrd_params_present_flag, &general_vcl_hrd_params_present_flag, &general_du_hrd_params_present_flag, &hrd_cpb_cnt_minus1);\n\t\t\tif (sps->max_sublayers > 1) {\n\t\t\t\tsublayer_cpb_params_present_flag = gf_bs_read_int_log(bs, 1, \"sps_sublayer_cpb_params_present_flag\");\n\t\t\t}\n\t\t\tu32 firstSubLayer = sublayer_cpb_params_present_flag ? 0 : sps->max_sublayers - 1;\n\t\t\tvvc_parse_ols_timing_hrd_parameters(bs, firstSubLayer, sps->max_sublayers-1, general_nal_hrd_params_present_flag, general_vcl_hrd_params_present_flag, general_du_hrd_params_present_flag, hrd_cpb_cnt_minus1);\n\n\t\t}\n\t}\n\n\tgf_bs_read_int_log(bs, 1, \"sps_field_seq_flag\");\n\tif (vui_flag_pos) {\n\t\t*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);\n\t}\n\t\/\/all this to get to VUI !!!\n\tif (gf_bs_read_int_log(bs, 1, \"sps_vui_parameters_present_flag\")) {\n\t\tgf_bs_read_ue_log(bs, \"sps_vui_payload_size_minus1\");\n\t\twhile (!gf_bs_is_align(bs)) {\n\t\t\tgf_bs_read_int_log(bs, 1, \"sps_vui_alignment_zero_bit\");\n\t\t}\n\t\t\/\/vui parameters\n\t\tBool vui_progressive_source_flag = gf_bs_read_int_log(bs, 1, \"vui_progressive_source_flag\");\n\t\tBool vui_interlaced_source_flag = gf_bs_read_int_log(bs, 1, \"vui_interlaced_source_flag\");\n\t\tgf_bs_read_int_log(bs, 1, \"vui_non_packed_constraint_flag\");\n\t\tgf_bs_read_int_log(bs, 1, \"vui_non_projected_constraint_flag\");\n\t\tsps->aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, \"vui_aspect_ratio_info_present_flag\");\n\t\tif (sps->aspect_ratio_info_present_flag) {\n\t\t\tgf_bs_read_int_log(bs, 1, \"vui_aspect_ratio_constant_flag\");\n\t\t\tsps->sar_idc = gf_bs_read_int_log(bs, 8, \"vui_aspect_ratio_idc\");\n\t\t\tif (sps->sar_idc== 0xFF) {\n\t\t\t\tsps->sar_width = gf_bs_read_int_log(bs, 16, \"vui_sar_width\");\n\t\t\t\tsps->sar_height = gf_bs_read_int_log(bs, 16, \"vui_sar_height\");\n\t\t\t}\n\t\t}\n\t\tsps->overscan_info_present_flag = gf_bs_read_int_log(bs, 1, \"vui_overscan_info_present_flag\");\n\t\tif (sps->overscan_info_present_flag) {\n\t\t\tgf_bs_read_int_log(bs, 1, \"vui_overscan_appropriate_flag\");\n\t\t}\n\t\tsps->colour_description_present_flag = gf_bs_read_int_log(bs, 1, \"vui_colour_description_present_flag\");\n\t\tif (sps->colour_description_present_flag) {\n\t\t\tsps->colour_primaries = gf_bs_read_int_log(bs, 8, \"vui_colour_primaries\");\n\t\t\tsps->transfer_characteristics = gf_bs_read_int_log(bs, 8, \"vui_transfer_characteristics\");\n\t\t\tsps->matrix_coefficients = gf_bs_read_int_log(bs, 8, \"vui_matrix_coeffs\");\n\t\t\tsps->video_full_range_flag = gf_bs_read_int_log(bs, 1, \"vui_full_range_flag\");\n\t\t}\n\t\tif (gf_bs_read_int_log(bs, 1, \" vui_chroma_loc_info_present_flag\")) {\n\t\t\tif (vui_progressive_source_flag && !vui_interlaced_source_flag) {\n\t\t\t\tgf_bs_read_ue_log(bs, \"vui_chroma_sample_loc_type_frame\");\n\t\t\t} else {\n\t\t\t\tgf_bs_read_ue_log(bs, \"vui_chroma_sample_loc_type_top_field\");\n\t\t\t\tgf_bs_read_ue_log(bs, \"vui_chroma_sample_loc_type_bottom_field\");\n\t\t\t}\n\t\t}\n\t\t\/\/WE DON'T PARSE vui_payload_bit_equal_to_one because we dont parse the rest (sps extensions)\n\t\t\/\/if needed, see rewrite_vui code\n\t}\n\treturn sps_id;\n}","target":0,"code_token_length":6308,"total_token_length":6544,"max_tokens_setting":8192}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..aaad16c57c4c5dadfc2a2e6e56def30b7f9c8609
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f239ef00e194dd7763f7cff0b72956b5a1cad7788fd9cf894bce103a0d647210
+size 599950
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..f20c473f6a01afe75f0a529394f442887b7fa4e7
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.jsonl
@@ -0,0 +1,8 @@
+{"idx":351094,"func":"Init_date_core(void)\n{\n    #ifdef HAVE_RB_EXT_RACTOR_SAFE\n\tRB_EXT_RACTOR_SAFE(true);\n    #endif\n    id_cmp = rb_intern_const(\"<=>\");\n    id_le_p = rb_intern_const(\"<=\");\n    id_ge_p = rb_intern_const(\">=\");\n    id_eqeq_p = rb_intern_const(\"==\");\n\n    half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2));\n\n#if (LONG_MAX \/ DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS\n    day_in_nanoseconds = LONG2NUM((long)DAY_IN_SECONDS *\n\t\t\t\t  SECOND_IN_NANOSECONDS);\n#elif defined HAVE_LONG_LONG\n    day_in_nanoseconds = LL2NUM((LONG_LONG)DAY_IN_SECONDS *\n\t\t\t\tSECOND_IN_NANOSECONDS);\n#else\n    day_in_nanoseconds = f_mul(INT2FIX(DAY_IN_SECONDS),\n\t\t\t       INT2FIX(SECOND_IN_NANOSECONDS));\n#endif\n\n    rb_gc_register_mark_object(half_days_in_day);\n    rb_gc_register_mark_object(day_in_nanoseconds);\n\n    positive_inf = +INFINITY;\n    negative_inf = -INFINITY;\n\n    \/*\n     * date and datetime class - Tadayoshi Funaba 1998-2011\n     *\n     * 'date' provides two classes: Date and DateTime.\n     *\n     * == Terms and Definitions\n     *\n     * Some terms and definitions are based on ISO 8601 and JIS X 0301.\n     *\n     * === Calendar Date\n     *\n     * The calendar date is a particular day of a calendar year,\n     * identified by its ordinal number within a calendar month within\n     * that year.\n     *\n     * In those classes, this is so-called \"civil\".\n     *\n     * === Ordinal Date\n     *\n     * The ordinal date is a particular day of a calendar year identified\n     * by its ordinal number within the year.\n     *\n     * In those classes, this is so-called \"ordinal\".\n     *\n     * === Week Date\n     *\n     * The week date is a date identified by calendar week and day numbers.\n     *\n     * The calendar week is a seven day period within a calendar year,\n     * starting on a Monday and identified by its ordinal number within\n     * the year; the first calendar week of the year is the one that\n     * includes the first Thursday of that year. In the Gregorian\n     * calendar, this is equivalent to the week which includes January 4.\n     *\n     * In those classes, this is so-called \"commercial\".\n     *\n     * === Julian Day Number\n     *\n     * The Julian day number is in elapsed days since noon (Greenwich Mean\n     * Time) on January 1, 4713 BCE (in the Julian calendar).\n     *\n     * In this document, the astronomical Julian day number is the same as\n     * the original Julian day number. And the chronological Julian day\n     * number is a variation of the Julian day number. Its days begin at\n     * midnight on local time.\n     *\n     * In this document, when the term \"Julian day number\" simply appears,\n     * it just refers to \"chronological Julian day number\", not the\n     * original.\n     *\n     * In those classes, those are so-called \"ajd\" and \"jd\".\n     *\n     * === Modified Julian Day Number\n     *\n     * The modified Julian day number is in elapsed days since midnight\n     * (Coordinated Universal Time) on November 17, 1858 CE (in the\n     * Gregorian calendar).\n     *\n     * In this document, the astronomical modified Julian day number is\n     * the same as the original modified Julian day number. And the\n     * chronological modified Julian day number is a variation of the\n     * modified Julian day number. Its days begin at midnight on local\n     * time.\n     *\n     * In this document, when the term \"modified Julian day number\" simply\n     * appears, it just refers to \"chronological modified Julian day\n     * number\", not the original.\n     *\n     * In those classes, those are so-called \"amjd\" and \"mjd\".\n     *\n     * == Date\n     *\n     * A subclass of Object that includes the Comparable module and\n     * easily handles date.\n     *\n     * A Date object is created with Date::new, Date::jd, Date::ordinal,\n     * Date::commercial, Date::parse, Date::strptime, Date::today,\n     * Time#to_date, etc.\n     *\n     *     require 'date'\n     *\n     *     Date.new(2001,2,3)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.jd(2451944)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.ordinal(2001,34)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.commercial(2001,5,6)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.parse('2001-02-03')\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.strptime('03-02-2001', '%d-%m-%Y')\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Time.new(2001,2,3).to_date\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *\n     * All date objects are immutable; hence cannot modify themselves.\n     *\n     * The concept of a date object can be represented as a tuple\n     * of the day count, the offset and the day of calendar reform.\n     *\n     * The day count denotes the absolute position of a temporal\n     * dimension. The offset is relative adjustment, which determines\n     * decoded local time with the day count. The day of calendar\n     * reform denotes the start day of the new style. The old style\n     * of the West is the Julian calendar which was adopted by\n     * Caesar. The new style is the Gregorian calendar, which is the\n     * current civil calendar of many countries.\n     *\n     * The day count is virtually the astronomical Julian day number.\n     * The offset in this class is usually zero, and cannot be\n     * specified directly.\n     *\n     * A Date object can be created with an optional argument,\n     * the day of calendar reform as a Julian day number, which\n     * should be 2298874 to 2426355 or negative\/positive infinity.\n     * The default value is +Date::ITALY+ (2299161=1582-10-15).\n     * See also sample\/cal.rb.\n     *\n     *     $ ruby sample\/cal.rb -c it 10 1582\n     *         October 1582\n     *      S  M Tu  W Th  F  S\n     *         1  2  3  4 15 16\n     *     17 18 19 20 21 22 23\n     *     24 25 26 27 28 29 30\n     *     31\n     *\n     *     $ ruby sample\/cal.rb -c gb  9 1752\n     *        September 1752\n     *      S  M Tu  W Th  F  S\n     *            1  2 14 15 16\n     *     17 18 19 20 21 22 23\n     *     24 25 26 27 28 29 30\n     *\n     * A Date object has various methods. See each reference.\n     *\n     *     d = Date.parse('3rd Feb 2001')\n     *\t\t\t\t\t#=> #<Date: 2001-02-03 ...>\n     *     d.year\t\t\t#=> 2001\n     *     d.mon\t\t\t#=> 2\n     *     d.mday\t\t\t#=> 3\n     *     d.wday\t\t\t#=> 6\n     *     d += 1\t\t\t#=> #<Date: 2001-02-04 ...>\n     *     d.strftime('%a %d %b %Y')\t#=> \"Sun 04 Feb 2001\"\n     *\n     *\/\n    cDate = rb_define_class(\"Date\", rb_cObject);\n    eDateError = rb_define_class_under(cDate, \"Error\", rb_eArgError);\n\n    rb_include_module(cDate, rb_mComparable);\n\n    \/* An array of strings of full month names in English.  The first\n     * element is nil.\n     *\/\n    rb_define_const(cDate, \"MONTHNAMES\", mk_ary_of_str(13, monthnames));\n\n    \/* An array of strings of abbreviated month names in English.  The\n     * first element is nil.\n     *\/\n    rb_define_const(cDate, \"ABBR_MONTHNAMES\",\n\t\t    mk_ary_of_str(13, abbr_monthnames));\n\n    \/* An array of strings of the full names of days of the week in English.\n     * The first is \"Sunday\".\n     *\/\n    rb_define_const(cDate, \"DAYNAMES\", mk_ary_of_str(7, daynames));\n\n    \/* An array of strings of abbreviated day names in English.  The\n     * first is \"Sun\".\n     *\/\n    rb_define_const(cDate, \"ABBR_DAYNAMES\", mk_ary_of_str(7, abbr_daynames));\n\n    \/* The Julian day number of the day of calendar reform for Italy\n     * and some catholic countries.\n     *\/\n    rb_define_const(cDate, \"ITALY\", INT2FIX(ITALY));\n\n    \/* The Julian day number of the day of calendar reform for England\n     * and her colonies.\n     *\/\n    rb_define_const(cDate, \"ENGLAND\", INT2FIX(ENGLAND));\n\n    \/* The Julian day number of the day of calendar reform for the\n     * proleptic Julian calendar.\n     *\/\n    rb_define_const(cDate, \"JULIAN\", DBL2NUM(JULIAN));\n\n    \/* The Julian day number of the day of calendar reform for the\n     * proleptic Gregorian calendar.\n     *\/\n    rb_define_const(cDate, \"GREGORIAN\", DBL2NUM(GREGORIAN));\n\n    rb_define_alloc_func(cDate, d_lite_s_alloc_simple);\n\n#ifndef NDEBUG\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_jd?\",\n\t\t\t     date_s__valid_jd_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_ordinal?\",\n\t\t\t     date_s__valid_ordinal_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_civil?\",\n\t\t\t     date_s__valid_civil_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_date?\",\n\t\t\t     date_s__valid_civil_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_commercial?\",\n\t\t\t     date_s__valid_commercial_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_weeknum?\",\n\t\t\t     date_s__valid_weeknum_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_nth_kday?\",\n\t\t\t     date_s__valid_nth_kday_p, -1);\n#endif\n\n    rb_define_singleton_method(cDate, \"valid_jd?\", date_s_valid_jd_p, -1);\n    rb_define_singleton_method(cDate, \"valid_ordinal?\",\n\t\t\t       date_s_valid_ordinal_p, -1);\n    rb_define_singleton_method(cDate, \"valid_civil?\", date_s_valid_civil_p, -1);\n    rb_define_singleton_method(cDate, \"valid_date?\", date_s_valid_civil_p, -1);\n    rb_define_singleton_method(cDate, \"valid_commercial?\",\n\t\t\t       date_s_valid_commercial_p, -1);\n\n#ifndef NDEBUG\n    rb_define_private_method(CLASS_OF(cDate), \"valid_weeknum?\",\n\t\t\t     date_s_valid_weeknum_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"valid_nth_kday?\",\n\t\t\t     date_s_valid_nth_kday_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"zone_to_diff\",\n\t\t\t     date_s_zone_to_diff, 1);\n#endif\n\n    rb_define_singleton_method(cDate, \"julian_leap?\", date_s_julian_leap_p, 1);\n    rb_define_singleton_method(cDate, \"gregorian_leap?\",\n\t\t\t       date_s_gregorian_leap_p, 1);\n    rb_define_singleton_method(cDate, \"leap?\",\n\t\t\t       date_s_gregorian_leap_p, 1);\n\n#ifndef NDEBUG\n    rb_define_singleton_method(cDate, \"new!\", date_s_new_bang, -1);\n    rb_define_alias(rb_singleton_class(cDate), \"new_l!\", \"new\");\n#endif\n\n    rb_define_singleton_method(cDate, \"jd\", date_s_jd, -1);\n    rb_define_singleton_method(cDate, \"ordinal\", date_s_ordinal, -1);\n    rb_define_singleton_method(cDate, \"civil\", date_s_civil, -1);\n    rb_define_singleton_method(cDate, \"commercial\", date_s_commercial, -1);\n\n#ifndef NDEBUG\n    rb_define_singleton_method(cDate, \"weeknum\", date_s_weeknum, -1);\n    rb_define_singleton_method(cDate, \"nth_kday\", date_s_nth_kday, -1);\n#endif\n\n    rb_define_singleton_method(cDate, \"today\", date_s_today, -1);\n    rb_define_singleton_method(cDate, \"_strptime\", date_s__strptime, -1);\n    rb_define_singleton_method(cDate, \"strptime\", date_s_strptime, -1);\n    rb_define_singleton_method(cDate, \"_parse\", date_s__parse, -1);\n    rb_define_singleton_method(cDate, \"parse\", date_s_parse, -1);\n    rb_define_singleton_method(cDate, \"_iso8601\", date_s__iso8601, 1);\n    rb_define_singleton_method(cDate, \"iso8601\", date_s_iso8601, -1);\n    rb_define_singleton_method(cDate, \"_rfc3339\", date_s__rfc3339, 1);\n    rb_define_singleton_method(cDate, \"rfc3339\", date_s_rfc3339, -1);\n    rb_define_singleton_method(cDate, \"_xmlschema\", date_s__xmlschema, 1);\n    rb_define_singleton_method(cDate, \"xmlschema\", date_s_xmlschema, -1);\n    rb_define_singleton_method(cDate, \"_rfc2822\", date_s__rfc2822, 1);\n    rb_define_singleton_method(cDate, \"_rfc822\", date_s__rfc2822, 1);\n    rb_define_singleton_method(cDate, \"rfc2822\", date_s_rfc2822, -1);\n    rb_define_singleton_method(cDate, \"rfc822\", date_s_rfc2822, -1);\n    rb_define_singleton_method(cDate, \"_httpdate\", date_s__httpdate, 1);\n    rb_define_singleton_method(cDate, \"httpdate\", date_s_httpdate, -1);\n    rb_define_singleton_method(cDate, \"_jisx0301\", date_s__jisx0301, 1);\n    rb_define_singleton_method(cDate, \"jisx0301\", date_s_jisx0301, -1);\n\n    rb_define_method(cDate, \"initialize\", date_initialize, -1);\n    rb_define_method(cDate, \"initialize_copy\", d_lite_initialize_copy, 1);\n\n#ifndef NDEBUG\n    rb_define_method(cDate, \"fill\", d_lite_fill, 0);\n#endif\n\n    rb_define_method(cDate, \"ajd\", d_lite_ajd, 0);\n    rb_define_method(cDate, \"amjd\", d_lite_amjd, 0);\n    rb_define_method(cDate, \"jd\", d_lite_jd, 0);\n    rb_define_method(cDate, \"mjd\", d_lite_mjd, 0);\n    rb_define_method(cDate, \"ld\", d_lite_ld, 0);\n\n    rb_define_method(cDate, \"year\", d_lite_year, 0);\n    rb_define_method(cDate, \"yday\", d_lite_yday, 0);\n    rb_define_method(cDate, \"mon\", d_lite_mon, 0);\n    rb_define_method(cDate, \"month\", d_lite_mon, 0);\n    rb_define_method(cDate, \"mday\", d_lite_mday, 0);\n    rb_define_method(cDate, \"day\", d_lite_mday, 0);\n    rb_define_method(cDate, \"day_fraction\", d_lite_day_fraction, 0);\n\n    rb_define_method(cDate, \"cwyear\", d_lite_cwyear, 0);\n    rb_define_method(cDate, \"cweek\", d_lite_cweek, 0);\n    rb_define_method(cDate, \"cwday\", d_lite_cwday, 0);\n\n#ifndef NDEBUG\n    rb_define_private_method(cDate, \"wnum0\", d_lite_wnum0, 0);\n    rb_define_private_method(cDate, \"wnum1\", d_lite_wnum1, 0);\n#endif\n\n    rb_define_method(cDate, \"wday\", d_lite_wday, 0);\n\n    rb_define_method(cDate, \"sunday?\", d_lite_sunday_p, 0);\n    rb_define_method(cDate, \"monday?\", d_lite_monday_p, 0);\n    rb_define_method(cDate, \"tuesday?\", d_lite_tuesday_p, 0);\n    rb_define_method(cDate, \"wednesday?\", d_lite_wednesday_p, 0);\n    rb_define_method(cDate, \"thursday?\", d_lite_thursday_p, 0);\n    rb_define_method(cDate, \"friday?\", d_lite_friday_p, 0);\n    rb_define_method(cDate, \"saturday?\", d_lite_saturday_p, 0);\n\n#ifndef NDEBUG\n    rb_define_method(cDate, \"nth_kday?\", d_lite_nth_kday_p, 2);\n#endif\n\n    rb_define_private_method(cDate, \"hour\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"min\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"minute\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"sec\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"second\", d_lite_zero, 0);\n\n    rb_define_method(cDate, \"julian?\", d_lite_julian_p, 0);\n    rb_define_method(cDate, \"gregorian?\", d_lite_gregorian_p, 0);\n    rb_define_method(cDate, \"leap?\", d_lite_leap_p, 0);\n\n    rb_define_method(cDate, \"start\", d_lite_start, 0);\n    rb_define_method(cDate, \"new_start\", d_lite_new_start, -1);\n    rb_define_method(cDate, \"italy\", d_lite_italy, 0);\n    rb_define_method(cDate, \"england\", d_lite_england, 0);\n    rb_define_method(cDate, \"julian\", d_lite_julian, 0);\n    rb_define_method(cDate, \"gregorian\", d_lite_gregorian, 0);\n\n    rb_define_method(cDate, \"+\", d_lite_plus, 1);\n    rb_define_method(cDate, \"-\", d_lite_minus, 1);\n\n    rb_define_method(cDate, \"next_day\", d_lite_next_day, -1);\n    rb_define_method(cDate, \"prev_day\", d_lite_prev_day, -1);\n    rb_define_method(cDate, \"next\", d_lite_next, 0);\n    rb_define_method(cDate, \"succ\", d_lite_next, 0);\n\n    rb_define_method(cDate, \">>\", d_lite_rshift, 1);\n    rb_define_method(cDate, \"<<\", d_lite_lshift, 1);\n\n    rb_define_method(cDate, \"next_month\", d_lite_next_month, -1);\n    rb_define_method(cDate, \"prev_month\", d_lite_prev_month, -1);\n    rb_define_method(cDate, \"next_year\", d_lite_next_year, -1);\n    rb_define_method(cDate, \"prev_year\", d_lite_prev_year, -1);\n\n    rb_define_method(cDate, \"step\", d_lite_step, -1);\n    rb_define_method(cDate, \"upto\", d_lite_upto, 1);\n    rb_define_method(cDate, \"downto\", d_lite_downto, 1);\n\n    rb_define_method(cDate, \"<=>\", d_lite_cmp, 1);\n    rb_define_method(cDate, \"===\", d_lite_equal, 1);\n    rb_define_method(cDate, \"eql?\", d_lite_eql_p, 1);\n    rb_define_method(cDate, \"hash\", d_lite_hash, 0);\n\n    rb_define_method(cDate, \"to_s\", d_lite_to_s, 0);\n#ifndef NDEBUG\n    rb_define_method(cDate, \"inspect_raw\", d_lite_inspect_raw, 0);\n#endif\n    rb_define_method(cDate, \"inspect\", d_lite_inspect, 0);\n\n    rb_define_method(cDate, \"strftime\", d_lite_strftime, -1);\n\n    rb_define_method(cDate, \"asctime\", d_lite_asctime, 0);\n    rb_define_method(cDate, \"ctime\", d_lite_asctime, 0);\n    rb_define_method(cDate, \"iso8601\", d_lite_iso8601, 0);\n    rb_define_method(cDate, \"xmlschema\", d_lite_iso8601, 0);\n    rb_define_method(cDate, \"rfc3339\", d_lite_rfc3339, 0);\n    rb_define_method(cDate, \"rfc2822\", d_lite_rfc2822, 0);\n    rb_define_method(cDate, \"rfc822\", d_lite_rfc2822, 0);\n    rb_define_method(cDate, \"httpdate\", d_lite_httpdate, 0);\n    rb_define_method(cDate, \"jisx0301\", d_lite_jisx0301, 0);\n\n#ifndef NDEBUG\n    rb_define_method(cDate, \"marshal_dump_old\", d_lite_marshal_dump_old, 0);\n#endif\n    rb_define_method(cDate, \"marshal_dump\", d_lite_marshal_dump, 0);\n    rb_define_method(cDate, \"marshal_load\", d_lite_marshal_load, 1);\n    rb_define_singleton_method(cDate, \"_load\", date_s__load, 1);\n\n    \/*\n     * == DateTime\n     *\n     * A subclass of Date that easily handles date, hour, minute, second,\n     * and offset.\n     *\n     * DateTime class is considered deprecated. Use Time class.\n     *\n     * DateTime does not consider any leap seconds, does not track\n     * any summer time rules.\n     *\n     * A DateTime object is created with DateTime::new, DateTime::jd,\n     * DateTime::ordinal, DateTime::commercial, DateTime::parse,\n     * DateTime::strptime, DateTime::now, Time#to_datetime, etc.\n     *\n     *     require 'date'\n     *\n     *     DateTime.new(2001,2,3,4,5,6)\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>\n     *\n     * The last element of day, hour, minute, or second can be a\n     * fractional number. The fractional number's precision is assumed\n     * at most nanosecond.\n     *\n     *     DateTime.new(2001,2,3.5)\n     *                         #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>\n     *\n     * An optional argument, the offset, indicates the difference\n     * between the local time and UTC. For example, <tt>Rational(3,24)<\/tt>\n     * represents ahead of 3 hours of UTC, <tt>Rational(-5,24)<\/tt> represents\n     * behind of 5 hours of UTC. The offset should be -1 to +1, and\n     * its precision is assumed at most second. The default value is\n     * zero (equals to UTC).\n     *\n     *     DateTime.new(2001,2,3,4,5,6,Rational(3,24))\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>\n     *\n     * The offset also accepts string form:\n     *\n     *     DateTime.new(2001,2,3,4,5,6,'+03:00')\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>\n     *\n     * An optional argument, the day of calendar reform (+start+), denotes\n     * a Julian day number, which should be 2298874 to 2426355 or\n     * negative\/positive infinity.\n     * The default value is +Date::ITALY+ (2299161=1582-10-15).\n     *\n     * A DateTime object has various methods. See each reference.\n     *\n     *     d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>\n     *     d.hour              #=> 4\n     *     d.min               #=> 5\n     *     d.sec               #=> 6\n     *     d.offset            #=> (7\/48)\n     *     d.zone              #=> \"+03:30\"\n     *     d += Rational('1.5')\n     *                         #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...>\n     *     d = d.new_offset('+09:00')\n     *                         #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...>\n     *     d.strftime('%I:%M:%S %p')\n     *                         #=> \"09:35:06 PM\"\n     *     d > DateTime.new(1999)\n     *                         #=> true\n     *\n     * === When should you use DateTime and when should you use Time?\n     *\n     * It's a common misconception that\n     * {William Shakespeare}[https:\/\/en.wikipedia.org\/wiki\/William_Shakespeare]\n     * and\n     * {Miguel de Cervantes}[https:\/\/en.wikipedia.org\/wiki\/Miguel_de_Cervantes]\n     * died on the same day in history -\n     * so much so that UNESCO named April 23 as\n     * {World Book Day because of this fact}[https:\/\/en.wikipedia.org\/wiki\/World_Book_Day].\n     * However, because England hadn't yet adopted the\n     * {Gregorian Calendar Reform}[https:\/\/en.wikipedia.org\/wiki\/Gregorian_calendar#Gregorian_reform]\n     * (and wouldn't until {1752}[https:\/\/en.wikipedia.org\/wiki\/Calendar_(New_Style)_Act_1750])\n     * their deaths are actually 10 days apart.\n     * Since Ruby's Time class implements a\n     * {proleptic Gregorian calendar}[https:\/\/en.wikipedia.org\/wiki\/Proleptic_Gregorian_calendar]\n     * and has no concept of calendar reform there's no way\n     * to express this with Time objects. This is where DateTime steps in:\n     *\n     *     shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)\n     *      #=> Tue, 23 Apr 1616 00:00:00 +0000\n     *     cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)\n     *      #=> Sat, 23 Apr 1616 00:00:00 +0000\n     *\n     * Already you can see something is weird - the days of the week\n     * are different. Taking this further:\n     *\n     *     cervantes == shakespeare\n     *      #=> false\n     *     (shakespeare - cervantes).to_i\n     *      #=> 10\n     *\n     * This shows that in fact they died 10 days apart (in reality\n     * 11 days since Cervantes died a day earlier but was buried on\n     * the 23rd). We can see the actual date of Shakespeare's death by\n     * using the #gregorian method to convert it:\n     *\n     *     shakespeare.gregorian\n     *      #=> Tue, 03 May 1616 00:00:00 +0000\n     *\n     * So there's an argument that all the celebrations that take\n     * place on the 23rd April in Stratford-upon-Avon are actually\n     * the wrong date since England is now using the Gregorian calendar.\n     * You can see why when we transition across the reform\n     * date boundary:\n     *\n     *     # start off with the anniversary of Shakespeare's birth in 1751\n     *     shakespeare = DateTime.iso8601('1751-04-23', Date::ENGLAND)\n     *      #=> Tue, 23 Apr 1751 00:00:00 +0000\n     *\n     *     # add 366 days since 1752 is a leap year and April 23 is after February 29\n     *     shakespeare + 366\n     *      #=> Thu, 23 Apr 1752 00:00:00 +0000\n     *\n     *     # add another 365 days to take us to the anniversary in 1753\n     *     shakespeare + 366 + 365\n     *      #=> Fri, 04 May 1753 00:00:00 +0000\n     *\n     * As you can see, if we're accurately tracking the number of\n     * {solar years}[https:\/\/en.wikipedia.org\/wiki\/Tropical_year]\n     * since Shakespeare's birthday then the correct anniversary date\n     * would be the 4th May and not the 23rd April.\n     *\n     * So when should you use DateTime in Ruby and when should\n     * you use Time? Almost certainly you'll want to use Time\n     * since your app is probably dealing with current dates and\n     * times. However, if you need to deal with dates and times in a\n     * historical context you'll want to use DateTime to avoid\n     * making the same mistakes as UNESCO. If you also have to deal\n     * with timezones then best of luck - just bear in mind that\n     * you'll probably be dealing with\n     * {local solar times}[https:\/\/en.wikipedia.org\/wiki\/Solar_time],\n     * since it wasn't until the 19th century that the introduction\n     * of the railways necessitated the need for\n     * {Standard Time}[https:\/\/en.wikipedia.org\/wiki\/Standard_time#Great_Britain]\n     * and eventually timezones.\n     *\/\n\n    cDateTime = rb_define_class(\"DateTime\", cDate);\n    rb_define_alloc_func(cDateTime, d_lite_s_alloc_complex);\n\n    rb_define_singleton_method(cDateTime, \"jd\", datetime_s_jd, -1);\n    rb_define_singleton_method(cDateTime, \"ordinal\", datetime_s_ordinal, -1);\n    rb_define_singleton_method(cDateTime, \"civil\", datetime_s_civil, -1);\n    rb_define_singleton_method(cDateTime, \"new\", datetime_s_civil, -1);\n    rb_define_singleton_method(cDateTime, \"commercial\",\n\t\t\t       datetime_s_commercial, -1);\n\n#ifndef NDEBUG\n    rb_define_singleton_method(cDateTime, \"weeknum\",\n\t\t\t       datetime_s_weeknum, -1);\n    rb_define_singleton_method(cDateTime, \"nth_kday\",\n\t\t\t       datetime_s_nth_kday, -1);\n#endif\n\n    rb_undef_method(CLASS_OF(cDateTime), \"today\");\n\n    rb_define_singleton_method(cDateTime, \"now\", datetime_s_now, -1);\n    rb_define_singleton_method(cDateTime, \"_strptime\",\n\t\t\t       datetime_s__strptime, -1);\n    rb_define_singleton_method(cDateTime, \"strptime\",\n\t\t\t       datetime_s_strptime, -1);\n    rb_define_singleton_method(cDateTime, \"parse\",\n\t\t\t       datetime_s_parse, -1);\n    rb_define_singleton_method(cDateTime, \"iso8601\",\n\t\t\t       datetime_s_iso8601, -1);\n    rb_define_singleton_method(cDateTime, \"rfc3339\",\n\t\t\t       datetime_s_rfc3339, -1);\n    rb_define_singleton_method(cDateTime, \"xmlschema\",\n\t\t\t       datetime_s_xmlschema, -1);\n    rb_define_singleton_method(cDateTime, \"rfc2822\",\n\t\t\t       datetime_s_rfc2822, -1);\n    rb_define_singleton_method(cDateTime, \"rfc822\",\n\t\t\t       datetime_s_rfc2822, -1);\n    rb_define_singleton_method(cDateTime, \"httpdate\",\n\t\t\t       datetime_s_httpdate, -1);\n    rb_define_singleton_method(cDateTime, \"jisx0301\",\n\t\t\t       datetime_s_jisx0301, -1);\n\n    rb_define_method(cDateTime, \"hour\", d_lite_hour, 0);\n    rb_define_method(cDateTime, \"min\", d_lite_min, 0);\n    rb_define_method(cDateTime, \"minute\", d_lite_min, 0);\n    rb_define_method(cDateTime, \"sec\", d_lite_sec, 0);\n    rb_define_method(cDateTime, \"second\", d_lite_sec, 0);\n    rb_define_method(cDateTime, \"sec_fraction\", d_lite_sec_fraction, 0);\n    rb_define_method(cDateTime, \"second_fraction\", d_lite_sec_fraction, 0);\n    rb_define_method(cDateTime, \"offset\", d_lite_offset, 0);\n    rb_define_method(cDateTime, \"zone\", d_lite_zone, 0);\n    rb_define_method(cDateTime, \"new_offset\", d_lite_new_offset, -1);\n\n    rb_define_method(cDateTime, \"to_s\", dt_lite_to_s, 0);\n\n    rb_define_method(cDateTime, \"strftime\", dt_lite_strftime, -1);\n\n    rb_define_method(cDateTime, \"iso8601\", dt_lite_iso8601, -1);\n    rb_define_method(cDateTime, \"xmlschema\", dt_lite_iso8601, -1);\n    rb_define_method(cDateTime, \"rfc3339\", dt_lite_rfc3339, -1);\n    rb_define_method(cDateTime, \"jisx0301\", dt_lite_jisx0301, -1);\n\n    \/* conversions *\/\n\n    rb_define_method(rb_cTime, \"to_time\", time_to_time, 0);\n    rb_define_method(rb_cTime, \"to_date\", time_to_date, 0);\n    rb_define_method(rb_cTime, \"to_datetime\", time_to_datetime, 0);\n\n    rb_define_method(cDate, \"to_time\", date_to_time, 0);\n    rb_define_method(cDate, \"to_date\", date_to_date, 0);\n    rb_define_method(cDate, \"to_datetime\", date_to_datetime, 0);\n\n    rb_define_method(cDateTime, \"to_time\", datetime_to_time, 0);\n    rb_define_method(cDateTime, \"to_date\", datetime_to_date, 0);\n    rb_define_method(cDateTime, \"to_datetime\", datetime_to_datetime, 0);\n\n#ifndef NDEBUG\n    \/* tests *\/\n\n    rb_define_singleton_method(cDate, \"test_civil\", date_s_test_civil, 0);\n    rb_define_singleton_method(cDate, \"test_ordinal\", date_s_test_ordinal, 0);\n    rb_define_singleton_method(cDate, \"test_commercial\",\n\t\t\t       date_s_test_commercial, 0);\n    rb_define_singleton_method(cDate, \"test_weeknum\", date_s_test_weeknum, 0);\n    rb_define_singleton_method(cDate, \"test_nth_kday\", date_s_test_nth_kday, 0);\n    rb_define_singleton_method(cDate, \"test_unit_conv\",\n\t\t\t       date_s_test_unit_conv, 0);\n    rb_define_singleton_method(cDate, \"test_all\", date_s_test_all, 0);\n#endif\n}","target":1,"code_token_length":8172,"total_token_length":8408,"max_tokens_setting":11000}
+{"idx":426370,"func":"static Image *ReadTIFFImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n#define ThrowTIFFException(severity,message) \\\n{ \\\n  if (tiff_pixels != (unsigned char *) NULL) \\\n    tiff_pixels=(unsigned char *) RelinquishMagickMemory(tiff_pixels); \\\n  if (quantum_info != (QuantumInfo *) NULL) \\\n    quantum_info=DestroyQuantumInfo(quantum_info); \\\n  TIFFClose(tiff); \\\n  ThrowReaderException(severity,message); \\\n}\n\n  const char\n    *option;\n\n  float\n    *chromaticity,\n    x_position,\n    y_position,\n    x_resolution,\n    y_resolution;\n\n  Image\n    *image;\n\n  int\n    tiff_status;\n\n  MagickBooleanType\n    more_frames,\n    status;\n\n  MagickSizeType\n    number_pixels;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  register ssize_t\n    i;\n\n  size_t\n    pad;\n\n  ssize_t\n    y;\n\n  TIFF\n    *tiff;\n\n  TIFFMethodType\n    method;\n\n  uint16\n    compress_tag,\n    bits_per_sample,\n    endian,\n    extra_samples,\n    interlace,\n    max_sample_value,\n    min_sample_value,\n    orientation,\n    pages,\n    photometric,\n    *sample_info,\n    sample_format,\n    samples_per_pixel,\n    units,\n    value;\n\n  uint32\n    height,\n    rows_per_strip,\n    width;\n\n  unsigned char\n    *tiff_pixels;\n\n  \/*\n    Open image.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  (void) SetMagickThreadValue(tiff_exception,exception);\n  tiff=TIFFClientOpen(image->filename,\"rb\",(thandle_t) image,TIFFReadBlob,\n    TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob,\n    TIFFUnmapBlob);\n  if (tiff == (TIFF *) NULL)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (exception->severity > ErrorException)\n    {\n      TIFFClose(tiff);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (image_info->number_scenes != 0)\n    {\n      \/*\n        Generate blank images for subimage specification (e.g. image.tif[4].\n        We need to check the number of directores because it is possible that\n        the subimage(s) are stored in the photoshop profile.\n      *\/\n      if (image_info->scene < (size_t) TIFFNumberOfDirectories(tiff))\n        {\n          for (i=0; i < (ssize_t) image_info->scene; i++)\n          {\n            status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n            if (status == MagickFalse)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            AcquireNextImage(image_info,image,exception);\n            if (GetNextImageInList(image) == (Image *) NULL)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            image=SyncNextImageInList(image);\n          }\n      }\n  }\n  more_frames=MagickTrue;\n  do\n  {\nDisableMSCWarning(4127)\n    if (0 && (image_info->verbose != MagickFalse))\n      TIFFPrintDirectory(tiff,stdout,MagickFalse);\nRestoreMSCWarning\n    photometric=PHOTOMETRIC_RGB;\n    if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) ||\n        (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value) != 1))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    if (((sample_format != SAMPLEFORMAT_IEEEFP) || (bits_per_sample == 64)) &&\n        ((bits_per_sample <= 0) || (bits_per_sample > 32)))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"UnsupportedBitsPerPixel\");\n      }\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      (void) SetImageProperty(image,\"quantum:format\",\"floating-point\",\n        exception);\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-black\",\n          exception);\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-white\",\n          exception);\n        break;\n      }\n      case PHOTOMETRIC_PALETTE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"palette\",exception);\n        break;\n      }\n      case PHOTOMETRIC_RGB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"RGB\",exception);\n        break;\n      }\n      case PHOTOMETRIC_CIELAB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIELAB\",exception);\n        break;\n      }\n      case PHOTOMETRIC_LOGL:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIE Log2(L)\",\n          exception);\n        break;\n      }\n      case PHOTOMETRIC_LOGLUV:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"LOGLUV\",exception);\n        break;\n      }\n#if defined(PHOTOMETRIC_MASK)\n      case PHOTOMETRIC_MASK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"MASK\",exception);\n        break;\n      }\n#endif\n      case PHOTOMETRIC_SEPARATED:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"separated\",exception);\n        break;\n      }\n      case PHOTOMETRIC_YCBCR:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"YCBCR\",exception);\n        break;\n      }\n      default:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"unknown\",exception);\n        break;\n      }\n    }\n    if (image->debug != MagickFalse)\n      {\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Geometry: %ux%u\",\n          (unsigned int) width,(unsigned int) height);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Interlace: %u\",\n          interlace);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Bits per sample: %u\",bits_per_sample);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Min sample value: %u\",min_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Max sample value: %u\",max_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Photometric \"\n          \"interpretation: %s\",GetImageProperty(image,\"tiff:photometric\",\n          exception));\n      }\n    image->columns=(size_t) width;\n    image->rows=(size_t) height;\n    image->depth=(size_t) bits_per_sample;\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Image depth: %.20g\",\n        (double) image->depth);\n    image->endian=MSBEndian;\n    if (endian == FILLORDER_LSB2MSB)\n      image->endian=LSBEndian;\n#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN)\n    if (TIFFIsBigEndian(tiff) == 0)\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"lsb\",exception);\n        image->endian=LSBEndian;\n      }\n    else\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"msb\",exception);\n        image->endian=MSBEndian;\n      }\n#endif\n    if ((photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      SetImageColorspace(image,GRAYColorspace,exception);\n    if (photometric == PHOTOMETRIC_SEPARATED)\n      SetImageColorspace(image,CMYKColorspace,exception);\n    if (photometric == PHOTOMETRIC_CIELAB)\n      SetImageColorspace(image,LabColorspace,exception);\n    TIFFGetProfiles(tiff,image,exception);\n    TIFFGetProperties(tiff,image,exception);\n    option=GetImageOption(image_info,\"tiff:exif-properties\");\n    if (IsStringFalse(option) == MagickFalse) \/* enabled by default *\/\n      TIFFGetEXIFProperties(tiff,image,exception);\n    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,\n      &samples_per_pixel);\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution) == 1))\n      {\n        image->resolution.x=x_resolution;\n        image->resolution.y=y_resolution;\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units) == 1)\n      {\n        if (units == RESUNIT_INCH)\n          image->units=PixelsPerInchResolution;\n        if (units == RESUNIT_CENTIMETER)\n          image->units=PixelsPerCentimeterResolution;\n      }\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position) == 1))\n      {\n        image->page.x=(ssize_t) ceil(x_position*image->resolution.x-0.5);\n        image->page.y=(ssize_t) ceil(y_position*image->resolution.y-0.5);\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation) == 1)\n      image->orientation=(OrientationType) orientation;\n    if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1)\n      {\n        if (chromaticity != (float *) NULL)\n          {\n            image->chromaticity.white_point.x=chromaticity[0];\n            image->chromaticity.white_point.y=chromaticity[1];\n          }\n      }\n    if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1)\n      {\n        if (chromaticity != (float *) NULL)\n          {\n            image->chromaticity.red_primary.x=chromaticity[0];\n            image->chromaticity.red_primary.y=chromaticity[1];\n            image->chromaticity.green_primary.x=chromaticity[2];\n            image->chromaticity.green_primary.y=chromaticity[3];\n            image->chromaticity.blue_primary.x=chromaticity[4];\n            image->chromaticity.blue_primary.y=chromaticity[5];\n          }\n      }\n#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)\n    if ((compress_tag != COMPRESSION_NONE) &&\n        (TIFFIsCODECConfigured(compress_tag) == 0))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CoderError,\"CompressNotSupported\");\n      }\n#endif\n    switch (compress_tag)\n    {\n      case COMPRESSION_NONE: image->compression=NoCompression; break;\n      case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break;\n      case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break;\n      case COMPRESSION_JPEG:\n      {\n         image->compression=JPEGCompression;\n#if defined(JPEG_SUPPORT)\n         {\n           char\n             sampling_factor[MagickPathExtent];\n\n           uint16\n             horizontal,\n             vertical;\n\n           tiff_status=TIFFGetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal,\n             &vertical);\n           if (tiff_status == 1)\n             {\n               (void) FormatLocaleString(sampling_factor,MagickPathExtent,\n                 \"%dx%d\",horizontal,vertical);\n               (void) SetImageProperty(image,\"jpeg:sampling-factor\",\n                 sampling_factor,exception);\n               (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                 \"Sampling Factors: %s\",sampling_factor);\n             }\n         }\n#endif\n        break;\n      }\n      case COMPRESSION_OJPEG: image->compression=JPEGCompression; break;\n#if defined(COMPRESSION_LZMA)\n      case COMPRESSION_LZMA: image->compression=LZMACompression; break;\n#endif\n      case COMPRESSION_LZW: image->compression=LZWCompression; break;\n      case COMPRESSION_DEFLATE: image->compression=ZipCompression; break;\n      case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break;\n#if defined(COMPRESSION_WEBP)\n      case COMPRESSION_WEBP: image->compression=WebPCompression; break;\n#endif\n#if defined(COMPRESSION_ZSTD)\n      case COMPRESSION_ZSTD: image->compression=ZstdCompression; break;\n#endif\n      default: image->compression=RLECompression; break;\n    }\n    quantum_info=(QuantumInfo *) NULL;\n    if ((photometric == PHOTOMETRIC_PALETTE) &&\n        (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))\n      {\n        size_t\n          colors;\n\n        colors=(size_t) GetQuantumRange(bits_per_sample)+1;\n        if (AcquireImageColormap(image,colors,exception) == MagickFalse)\n          {\n            TIFFClose(tiff);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    value=(unsigned short) image->scene;\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages) == 1)\n      image->scene=value;\n    if (image->storage_class == PseudoClass)\n      {\n        size_t\n          range;\n\n        uint16\n          *blue_colormap,\n          *green_colormap,\n          *red_colormap;\n\n        \/*\n          Initialize colormap.\n        *\/\n        tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,\n          &green_colormap,&blue_colormap);\n        if (tiff_status == 1)\n          {\n            if ((red_colormap != (uint16 *) NULL) &&\n                (green_colormap != (uint16 *) NULL) &&\n                (blue_colormap != (uint16 *) NULL))\n              {\n                range=255;  \/* might be old style 8-bit colormap *\/\n                for (i=0; i < (ssize_t) image->colors; i++)\n                  if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||\n                      (blue_colormap[i] >= 256))\n                    {\n                      range=65535;\n                      break;\n                    }\n                for (i=0; i < (ssize_t) image->colors; i++)\n                {\n                  image->colormap[i].red=ClampToQuantum(((double)\n                    QuantumRange*red_colormap[i])\/range);\n                  image->colormap[i].green=ClampToQuantum(((double)\n                    QuantumRange*green_colormap[i])\/range);\n                  image->colormap[i].blue=ClampToQuantum(((double)\n                    QuantumRange*blue_colormap[i])\/range);\n                }\n              }\n          }\n      }\n    if (image_info->ping != MagickFalse)\n      {\n        if (image_info->number_scenes != 0)\n          if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n            break;\n        goto next_tiff_frame;\n      }\n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        return(DestroyImageList(image));\n      }\n    status=ResetImagePixels(image,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        return(DestroyImageList(image));\n      }\n    \/*\n      Allocate memory for the image and pixel buffer.\n    *\/\n    tiff_pixels=(unsigned char *) NULL;\n    quantum_info=AcquireQuantumInfo(image_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (sample_format == SAMPLEFORMAT_UINT)\n      status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_INT)\n      status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);\n    if (status == MagickFalse)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    status=MagickTrue;\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        quantum_info->min_is_white=MagickFalse;\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        quantum_info->min_is_white=MagickTrue;\n        break;\n      }\n      default:\n        break;\n    }\n    tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,\n      &sample_info);\n    if (tiff_status == 1)\n      {\n        (void) SetImageProperty(image,\"tiff:alpha\",\"unspecified\",exception);\n        if (extra_samples == 0)\n          {\n            if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))\n              image->alpha_trait=BlendPixelTrait;\n          }\n        else\n          for (i=0; i < extra_samples; i++)\n          {\n            image->alpha_trait=BlendPixelTrait;\n            if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)\n              {\n                SetQuantumAlphaType(quantum_info,AssociatedQuantumAlpha);\n                (void) SetImageProperty(image,\"tiff:alpha\",\"associated\",\n                  exception);\n              }\n            else\n              if (sample_info[i] == EXTRASAMPLE_UNASSALPHA)\n                {\n                  SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);\n                  (void) SetImageProperty(image,\"tiff:alpha\",\"unassociated\",\n                    exception);\n                }\n          }\n      }\n    if (image->alpha_trait != UndefinedPixelTrait)\n      (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);\n    method=ReadGenericMethod;\n    rows_per_strip=(uint32) image->rows;\n    if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1)\n      {\n        char\n          buffer[MagickPathExtent];\n\n        method=ReadStripMethod;\n        (void) FormatLocaleString(buffer,MagickPathExtent,\"%u\",\n          (unsigned int) rows_per_strip);\n        (void) SetImageProperty(image,\"tiff:rows-per-strip\",buffer,exception);\n      }\n    if (rows_per_strip > (uint32) image->rows)\n      rows_per_strip=(uint32) image->rows;\n    if ((samples_per_pixel >= 3) && (interlace == PLANARCONFIG_CONTIG))\n      if ((image->alpha_trait == UndefinedPixelTrait) ||\n          (samples_per_pixel >= 4))\n        method=ReadRGBAMethod;\n    if ((samples_per_pixel >= 4) && (interlace == PLANARCONFIG_SEPARATE))\n      if ((image->alpha_trait == UndefinedPixelTrait) ||\n          (samples_per_pixel >= 5))\n        method=ReadCMYKAMethod;\n    if ((photometric != PHOTOMETRIC_RGB) &&\n        (photometric != PHOTOMETRIC_CIELAB) &&\n        (photometric != PHOTOMETRIC_SEPARATED))\n      method=ReadGenericMethod;\n    if (image->storage_class == PseudoClass)\n      method=ReadSingleSampleMethod;\n    if ((photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      method=ReadSingleSampleMethod;\n    if ((photometric != PHOTOMETRIC_SEPARATED) &&\n        (interlace == PLANARCONFIG_SEPARATE) && (bits_per_sample < 64))\n      method=ReadGenericMethod;\n    if (image->compression == JPEGCompression)\n      method=GetJPEGMethod(image,tiff,photometric,bits_per_sample,\n        samples_per_pixel);\n    if (compress_tag == COMPRESSION_JBIG)\n      method=ReadStripMethod;\n    if (TIFFIsTiled(tiff) != MagickFalse)\n      method=ReadTileMethod;\n    quantum_info->endian=LSBEndian;\n    quantum_type=RGBQuantum;\n    if (TIFFScanlineSize(tiff) <= 0)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (((MagickSizeType) TIFFScanlineSize(tiff)) > (2*GetBlobSize(image)))\n      ThrowTIFFException(CorruptImageError,\"InsufficientImageDataInFile\");\n    number_pixels=MagickMax(TIFFScanlineSize(tiff),MagickMax((ssize_t)\n      image->columns*samples_per_pixel*pow(2.0,ceil(log(bits_per_sample)\/\n      log(2.0))),image->columns*rows_per_strip)*sizeof(uint32));\n    tiff_pixels=(unsigned char *) AcquireMagickMemory(number_pixels);\n    if (tiff_pixels == (unsigned char *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    (void) memset(tiff_pixels,0,number_pixels);\n    switch (method)\n    {\n      case ReadSingleSampleMethod:\n      {\n        \/*\n          Convert TIFF image to PseudoClass MIFF image.\n        *\/\n        quantum_type=IndexQuantum;\n        pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0);\n        if (image->alpha_trait != UndefinedPixelTrait)\n          {\n            if (image->storage_class != PseudoClass)\n              {\n                quantum_type=samples_per_pixel == 1 ? AlphaQuantum :\n                  GrayAlphaQuantum;\n                pad=(size_t) MagickMax((ssize_t) samples_per_pixel-2,0);\n              }\n            else\n              {\n                quantum_type=IndexAlphaQuantum;\n                pad=(size_t) MagickMax((ssize_t) samples_per_pixel-2,0);\n              }\n          }\n        else\n          if (image->storage_class != PseudoClass)\n            {\n              quantum_type=GrayQuantum;\n              pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0);\n            }\n        status=SetQuantumPad(image,quantum_info,pad*pow(2,ceil(log(\n          bits_per_sample)\/log(2))));\n        if (status == MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register Quantum\n            *magick_restrict q;\n\n          tiff_status=TIFFReadPixels(tiff,0,y,(char *) tiff_pixels);\n          if (tiff_status == -1)\n            break;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n            quantum_type,tiff_pixels,exception);\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadRGBAMethod:\n      {\n        \/*\n          Convert TIFF image to DirectClass MIFF image.\n        *\/\n        pad=(size_t) MagickMax((size_t) samples_per_pixel-3,0);\n        quantum_type=RGBQuantum;\n        if (image->alpha_trait != UndefinedPixelTrait)\n          {\n            quantum_type=RGBAQuantum;\n            pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0);\n          }\n        if (image->colorspace == CMYKColorspace)\n          {\n            pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0);\n            quantum_type=CMYKQuantum;\n            if (image->alpha_trait != UndefinedPixelTrait)\n              {\n                quantum_type=CMYKAQuantum;\n                pad=(size_t) MagickMax((size_t) samples_per_pixel-5,0);\n              }\n          }\n        status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3));\n        if (status == MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register Quantum\n            *magick_restrict q;\n\n          tiff_status=TIFFReadPixels(tiff,0,y,(char *) tiff_pixels);\n          if (tiff_status == -1)\n            break;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n            quantum_type,tiff_pixels,exception);\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadCMYKAMethod:\n      {\n        \/*\n          Convert TIFF image to DirectClass MIFF image.\n        *\/\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            register Quantum\n              *magick_restrict q;\n\n            tiff_status=TIFFReadPixels(tiff,(tsample_t) i,y,(char *)\n              tiff_pixels);\n            if (tiff_status == -1)\n              break;\n            q=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            if (image->colorspace != CMYKColorspace)\n              switch (i)\n              {\n                case 0: quantum_type=RedQuantum; break;\n                case 1: quantum_type=GreenQuantum; break;\n                case 2: quantum_type=BlueQuantum; break;\n                case 3: quantum_type=AlphaQuantum; break;\n                default: quantum_type=UndefinedQuantum; break;\n              }\n            else\n              switch (i)\n              {\n                case 0: quantum_type=CyanQuantum; break;\n                case 1: quantum_type=MagentaQuantum; break;\n                case 2: quantum_type=YellowQuantum; break;\n                case 3: quantum_type=BlackQuantum; break;\n                case 4: quantum_type=AlphaQuantum; break;\n                default: quantum_type=UndefinedQuantum; break;\n              }\n            (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n              quantum_type,tiff_pixels,exception);\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n          }\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadYCCKMethod:\n      {\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register Quantum\n            *magick_restrict q;\n\n          register ssize_t\n            x;\n\n          unsigned char\n            *p;\n\n          tiff_status=TIFFReadPixels(tiff,0,y,(char *) tiff_pixels);\n          if (tiff_status == -1)\n            break;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          p=tiff_pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelCyan(image,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.402*(double) *(p+2))-179.456)),q);\n            SetPixelMagenta(image,ScaleCharToQuantum(ClampYCC((double) *p-\n              (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+\n              135.45984)),q);\n            SetPixelYellow(image,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.772*(double) *(p+1))-226.816)),q);\n            SetPixelBlack(image,ScaleCharToQuantum((unsigned char) *(p+3)),q);\n            q+=GetPixelChannels(image);\n            p+=4;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadStripMethod:\n      {\n        register uint32\n          *p;\n\n        \/*\n          Convert stripped TIFF image to DirectClass MIFF image.\n        *\/\n        (void) SetImageStorageClass(image,DirectClass,exception);\n        i=0;\n        p=(uint32 *) NULL;\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register ssize_t\n            x;\n\n          register Quantum\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          if (i == 0)\n            {\n              if (TIFFReadRGBAStrip(tiff,(tstrip_t) y,(uint32 *) tiff_pixels) == 0)\n                break;\n              i=(ssize_t) MagickMin((ssize_t) rows_per_strip,(ssize_t)\n                image->rows-y);\n            }\n          i--;\n          p=((uint32 *) tiff_pixels)+image->columns*i;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(image,ScaleCharToQuantum((unsigned char)\n              (TIFFGetR(*p))),q);\n            SetPixelGreen(image,ScaleCharToQuantum((unsigned char)\n              (TIFFGetG(*p))),q);\n            SetPixelBlue(image,ScaleCharToQuantum((unsigned char)\n              (TIFFGetB(*p))),q);\n            if (image->alpha_trait != UndefinedPixelTrait)\n              SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)\n                (TIFFGetA(*p))),q);\n            p++;\n            q+=GetPixelChannels(image);\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadTileMethod:\n      {\n        register uint32\n          *p;\n\n        uint32\n          *tile_pixels,\n          columns,\n          rows;\n\n        \/*\n          Convert tiled TIFF image to DirectClass MIFF image.\n        *\/\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        if ((AcquireMagickResource(WidthResource,columns) == MagickFalse) ||\n            (AcquireMagickResource(HeightResource,rows) == MagickFalse))\n          ThrowTIFFException(ImageError,\"WidthOrHeightExceedsLimit\");\n        (void) SetImageStorageClass(image,DirectClass,exception);\n        number_pixels=(MagickSizeType) columns*rows;\n        if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        tile_pixels=(uint32 *) AcquireQuantumMemory(columns,rows*\n          sizeof(*tile_pixels));\n        if (tile_pixels == (uint32 *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        for (y=0; y < (ssize_t) image->rows; y+=rows)\n        {\n          register ssize_t\n            x;\n\n          register Quantum\n            *magick_restrict q,\n            *magick_restrict tile;\n\n          size_t\n            columns_remaining,\n            rows_remaining;\n\n          rows_remaining=image->rows-y;\n          if ((ssize_t) (y+rows) < (ssize_t) image->rows)\n            rows_remaining=rows;\n          tile=QueueAuthenticPixels(image,0,y,image->columns,rows_remaining,\n            exception);\n          if (tile == (Quantum *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x+=columns)\n          {\n            size_t\n              column,\n              row;\n\n            if (TIFFReadRGBATile(tiff,(uint32) x,(uint32) y,tile_pixels) == 0)\n              break;\n            columns_remaining=image->columns-x;\n            if ((ssize_t) (x+columns) < (ssize_t) image->columns)\n              columns_remaining=columns;\n            p=tile_pixels+(rows-rows_remaining)*columns;\n            q=tile+GetPixelChannels(image)*(image->columns*(rows_remaining-1)+\n              x);\n            for (row=rows_remaining; row > 0; row--)\n            {\n              if (image->alpha_trait != UndefinedPixelTrait)\n                for (column=columns_remaining; column > 0; column--)\n                {\n                  SetPixelRed(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetR(*p)),q);\n                  SetPixelGreen(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetG(*p)),q);\n                  SetPixelBlue(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetB(*p)),q);\n                  SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetA(*p)),q);\n                  p++;\n                  q+=GetPixelChannels(image);\n                }\n              else\n                for (column=columns_remaining; column > 0; column--)\n                {\n                  SetPixelRed(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetR(*p)),q);\n                  SetPixelGreen(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetG(*p)),q);\n                  SetPixelBlue(image,ScaleCharToQuantum((unsigned char)\n                    TIFFGetB(*p)),q);\n                  p++;\n                  q+=GetPixelChannels(image);\n                }\n              p+=columns-columns_remaining;\n              q-=GetPixelChannels(image)*(image->columns+columns_remaining);\n            }\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        tile_pixels=(uint32 *) RelinquishMagickMemory(tile_pixels);\n        break;\n      }\n      case ReadGenericMethod:\n      default:\n      {\n        MemoryInfo\n          *pixel_info;\n\n        register uint32\n          *p;\n\n        uint32\n          *pixels;\n\n        \/*\n          Convert TIFF image to DirectClass MIFF image.\n        *\/\n        (void) SetImageStorageClass(image,DirectClass,exception);\n        number_pixels=(MagickSizeType) image->columns*image->rows;\n        if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixel_info=AcquireVirtualMemory(image->columns,image->rows*\n          sizeof(uint32));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(uint32 *) GetVirtualMemoryBlob(pixel_info);\n        (void) TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32)\n          image->rows,(uint32 *) pixels,0);\n        \/*\n          Convert image to DirectClass pixel packets.\n        *\/\n        p=pixels+number_pixels-1;\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register ssize_t\n            x;\n\n          register Quantum\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          q+=GetPixelChannels(image)*(image->columns-1);\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(image,ScaleCharToQuantum((unsigned char)\n              TIFFGetR(*p)),q);\n            SetPixelGreen(image,ScaleCharToQuantum((unsigned char)\n              TIFFGetG(*p)),q);\n            SetPixelBlue(image,ScaleCharToQuantum((unsigned char)\n              TIFFGetB(*p)),q);\n            if (image->alpha_trait != UndefinedPixelTrait)\n              SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)\n                TIFFGetA(*p)),q);\n            p--;\n            q-=GetPixelChannels(image);\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        pixel_info=RelinquishVirtualMemory(pixel_info);\n        break;\n      }\n    }\n    tiff_pixels=(unsigned char *) RelinquishMagickMemory(tiff_pixels);\n    SetQuantumImageType(image,quantum_type);\n  next_tiff_frame:\n    if (quantum_info != (QuantumInfo *) NULL)\n      quantum_info=DestroyQuantumInfo(quantum_info);\n    if (photometric == PHOTOMETRIC_CIELAB)\n      DecodeLabImage(image,exception);\n    if ((photometric == PHOTOMETRIC_LOGL) ||\n        (photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      {\n        image->type=GrayscaleType;\n        if (bits_per_sample == 1)\n          image->type=BilevelType;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    more_frames=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n    if (more_frames != MagickFalse)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image,exception);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,image->scene-1,\n          image->scene);\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((status != MagickFalse) && (more_frames != MagickFalse));\n  TIFFClose(tiff);\n  TIFFReadPhotoshopLayers(image_info,image,exception);\n  if ((image_info->number_scenes != 0) &&\n      (image_info->scene >= GetImageListLength(image)))\n    status=MagickFalse;\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":9261,"total_token_length":9497,"max_tokens_setting":11000}
+{"idx":347396,"func":"int parse_arguments(int *argc_p, const char ***argv_p)\n{\n\tstatic poptContext pc;\n\tchar *ref = lp_refuse_options(module_id);\n\tconst char *arg, **argv = *argv_p;\n\tint argc = *argc_p;\n\tint opt;\n\n\tif (ref && *ref)\n\t\tset_refuse_options(ref);\n\tif (am_daemon) {\n\t\tset_refuse_options(\"log-file*\");\n#ifdef ICONV_OPTION\n\t\tif (!*lp_charset(module_id))\n\t\t\tset_refuse_options(\"iconv\");\n#endif\n\t}\n\n#ifdef ICONV_OPTION\n\tif (!am_daemon && protect_args <= 0 && (arg = getenv(\"RSYNC_ICONV\")) != NULL && *arg)\n\t\ticonv_opt = strdup(arg);\n#endif\n\n\t\/* TODO: Call poptReadDefaultConfig; handle errors. *\/\n\n\t\/* The context leaks in case of an error, but if there's a\n\t * problem we always exit anyhow. *\/\n\tif (pc)\n\t\tpoptFreeContext(pc);\n\tpc = poptGetContext(RSYNC_NAME, argc, argv, long_options, 0);\n\tif (!am_server) {\n\t\tpoptReadDefaultConfig(pc, 0);\n\t\tpopt_unalias(pc, \"--daemon\");\n\t\tpopt_unalias(pc, \"--server\");\n\t}\n\n\twhile ((opt = poptGetNextOpt(pc)) != -1) {\n\t\t\/* most options are handled automatically by popt;\n\t\t * only special cases are returned and listed here. *\/\n\n\t\tswitch (opt) {\n\t\tcase OPT_VERSION:\n\t\t\tprint_rsync_version(FINFO);\n\t\t\texit_cleanup(0);\n\n\t\tcase OPT_SERVER:\n\t\t\tif (!am_server) {\n\t\t\t\t\/* Disable popt aliases on the server side and\n\t\t\t\t * then start parsing the options again. *\/\n\t\t\t\tpoptFreeContext(pc);\n\t\t\t\tpc = poptGetContext(RSYNC_NAME, argc, argv,\n\t\t\t\t\t\t    long_options, 0);\n\t\t\t\tam_server = 1;\n\t\t\t}\n#ifdef ICONV_OPTION\n\t\t\ticonv_opt = NULL;\n#endif\n\t\t\tbreak;\n\n\t\tcase OPT_SENDER:\n\t\t\tif (!am_server) {\n\t\t\t\tusage(FERROR);\n\t\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t\t}\n\t\t\tam_sender = 1;\n\t\t\tbreak;\n\n\t\tcase OPT_DAEMON:\n\t\t\tif (am_daemon) {\n\t\t\t\tstrlcpy(err_buf,\n\t\t\t\t\t\"Attempt to hack rsync thwarted!\\n\",\n\t\t\t\t\tsizeof err_buf);\n\t\t\t\treturn 0;\n\t\t\t}\n#ifdef ICONV_OPTION\n\t\t\ticonv_opt = NULL;\n#endif\n\t\t\tprotect_args = 0;\n\t\t\tpoptFreeContext(pc);\n\t\t\tpc = poptGetContext(RSYNC_NAME, argc, argv,\n\t\t\t\t\t    long_daemon_options, 0);\n\t\t\twhile ((opt = poptGetNextOpt(pc)) != -1) {\n\t\t\t\tchar **cpp;\n\t\t\t\tswitch (opt) {\n\t\t\t\tcase 'h':\n\t\t\t\t\tdaemon_usage(FINFO);\n\t\t\t\t\texit_cleanup(0);\n\n\t\t\t\tcase 'M':\n\t\t\t\t\targ = poptGetOptArg(pc);\n\t\t\t\t\tif (!strchr(arg, '=')) {\n\t\t\t\t\t\trprintf(FERROR,\n\t\t\t\t\t\t    \"--dparam value is missing an '=': %s\\n\",\n\t\t\t\t\t\t    arg);\n\t\t\t\t\t\tgoto daemon_error;\n\t\t\t\t\t}\n\t\t\t\t\tcpp = EXPAND_ITEM_LIST(&dparam_list, char *, 4);\n\t\t\t\t\t*cpp = strdup(arg);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'v':\n\t\t\t\t\tverbose++;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\trprintf(FERROR,\n\t\t\t\t\t    \"rsync: %s: %s (in daemon mode)\\n\",\n\t\t\t\t\t    poptBadOption(pc, POPT_BADOPTION_NOALIAS),\n\t\t\t\t\t    poptStrerror(opt));\n\t\t\t\t\tgoto daemon_error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (dparam_list.count && !set_dparams(1))\n\t\t\t\texit_cleanup(RERR_SYNTAX);\n\n\t\t\tif (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t \"the --temp-dir path is WAY too long.\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tif (!daemon_opt) {\n\t\t\t\trprintf(FERROR, \"Daemon option(s) used without --daemon.\\n\");\n\t\t\t    daemon_error:\n\t\t\t\trprintf(FERROR,\n\t\t\t\t    \"(Type \\\"rsync --daemon --help\\\" for assistance with daemon mode.)\\n\");\n\t\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t\t}\n\n\t\t\t*argv_p = argv = poptGetArgs(pc);\n\t\t\t*argc_p = argc = count_args(argv);\n\t\t\tam_starting_up = 0;\n\t\t\tdaemon_opt = 0;\n\t\t\tam_daemon = 1;\n\t\t\treturn 1;\n\n\t\tcase OPT_MODIFY_WINDOW:\n\t\t\t\/* The value has already been set by popt, but\n\t\t\t * we need to remember that we're using a\n\t\t\t * non-default setting. *\/\n\t\t\tmodify_window_set = 1;\n\t\t\tbreak;\n\n\t\tcase OPT_FILTER:\n\t\t\tparse_filter_str(&filter_list, poptGetOptArg(pc),\n\t\t\t\t\trule_template(0), 0);\n\t\t\tbreak;\n\n\t\tcase OPT_EXCLUDE:\n\t\t\tparse_filter_str(&filter_list, poptGetOptArg(pc),\n\t\t\t\t\trule_template(0), XFLG_OLD_PREFIXES);\n\t\t\tbreak;\n\n\t\tcase OPT_INCLUDE:\n\t\t\tparse_filter_str(&filter_list, poptGetOptArg(pc),\n\t\t\t\t\trule_template(FILTRULE_INCLUDE), XFLG_OLD_PREFIXES);\n\t\t\tbreak;\n\n\t\tcase OPT_EXCLUDE_FROM:\n\t\tcase OPT_INCLUDE_FROM:\n\t\t\targ = poptGetOptArg(pc);\n\t\t\tif (sanitize_paths)\n\t\t\t\targ = sanitize_path(NULL, arg, NULL, 0, SP_DEFAULT);\n\t\t\tif (daemon_filter_list.head) {\n\t\t\t\tint rej;\n\t\t\t\tchar *cp = strdup(arg);\n\t\t\t\tif (!cp)\n\t\t\t\t\tout_of_memory(\"parse_arguments\");\n\t\t\t\tif (!*cp)\n\t\t\t\t\trej = 1;\n\t\t\t\telse {\n\t\t\t\t\tchar *dir = cp + (*cp == '\/' ? module_dirlen : 0);\n\t\t\t\t\tclean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);\n\t\t\t\t\trej = check_filter(&daemon_filter_list, FLOG, dir, 0) < 0;\n\t\t\t\t}\n\t\t\t\tfree(cp);\n\t\t\t\tif (rej)\n\t\t\t\t\tgoto options_rejected;\n\t\t\t}\n\t\t\tparse_filter_file(&filter_list, arg,\n\t\t\t\trule_template(opt == OPT_INCLUDE_FROM ? FILTRULE_INCLUDE : 0),\n\t\t\t\tXFLG_FATAL_ERRORS | XFLG_OLD_PREFIXES);\n\t\t\tbreak;\n\n\t\tcase 'a':\n\t\t\tif (refused_archive_part) {\n\t\t\t\tcreate_refuse_error(refused_archive_part);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!recurse) \/* preserve recurse == 2 *\/\n\t\t\t\trecurse = 1;\n#ifdef SUPPORT_LINKS\n\t\t\tpreserve_links = 1;\n#endif\n\t\t\tpreserve_perms = 1;\n\t\t\tpreserve_times = 1;\n\t\t\tpreserve_gid = 1;\n\t\t\tpreserve_uid = 1;\n\t\t\tpreserve_devices = 1;\n\t\t\tpreserve_specials = 1;\n\t\t\tbreak;\n\n\t\tcase 'D':\n\t\t\tpreserve_devices = preserve_specials = 1;\n\t\t\tbreak;\n\n\t\tcase OPT_NO_D:\n\t\t\tpreserve_devices = preserve_specials = 0;\n\t\t\tbreak;\n\n\t\tcase 'h':\n\t\t\thuman_readable++;\n\t\t\tbreak;\n\n\t\tcase 'H':\n\t\t\tpreserve_hard_links++;\n\t\t\tbreak;\n\n\t\tcase 'i':\n\t\t\titemize_changes++;\n\t\t\tbreak;\n\n\t\tcase 'v':\n\t\t\tverbose++;\n\t\t\tbreak;\n\n\t\tcase 'y':\n\t\t\tfuzzy_basis++;\n\t\t\tbreak;\n\n\t\tcase 'q':\n\t\t\tquiet++;\n\t\t\tbreak;\n\n\t\tcase 'x':\n\t\t\tone_file_system++;\n\t\t\tbreak;\n\n\t\tcase 'F':\n\t\t\tswitch (++F_option_cnt) {\n\t\t\tcase 1:\n\t\t\t\tparse_filter_str(&filter_list,\": \/.rsync-filter\",rule_template(0),0);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tparse_filter_str(&filter_list,\"- .rsync-filter\",rule_template(0),0);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'P':\n\t\t\tif (refused_partial || refused_progress) {\n\t\t\t\tcreate_refuse_error(refused_partial\n\t\t\t\t    ? refused_partial : refused_progress);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tdo_progress = 1;\n\t\t\tkeep_partial = 1;\n\t\t\tbreak;\n\n\t\tcase 'z':\n\t\t\tdo_compression++;\n\t\t\tbreak;\n\n\t\tcase 'M':\n\t\t\targ = poptGetOptArg(pc);\n\t\t\tif (*arg != '-') {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"Remote option must start with a dash: %s\\n\", arg);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (remote_option_cnt+2 >= remote_option_alloc) {\n\t\t\t\tremote_option_alloc += 16;\n\t\t\t\tremote_options = realloc_array(remote_options,\n\t\t\t\t\t\t\tconst char *, remote_option_alloc);\n\t\t\t\tif (!remote_options)\n\t\t\t\t\tout_of_memory(\"parse_arguments\");\n\t\t\t\tif (!remote_option_cnt)\n\t\t\t\t\tremote_options[0] = \"ARG0\";\n\t\t\t}\n\t\t\tremote_options[++remote_option_cnt] = arg;\n\t\t\tremote_options[remote_option_cnt+1] = NULL;\n\t\t\tbreak;\n\n\t\tcase OPT_WRITE_BATCH:\n\t\t\t\/* batch_name is already set *\/\n\t\t\twrite_batch = 1;\n\t\t\tbreak;\n\n\t\tcase OPT_ONLY_WRITE_BATCH:\n\t\t\t\/* batch_name is already set *\/\n\t\t\twrite_batch = -1;\n\t\t\tbreak;\n\n\t\tcase OPT_READ_BATCH:\n\t\t\t\/* batch_name is already set *\/\n\t\t\tread_batch = 1;\n\t\t\tbreak;\n\n\t\tcase OPT_NO_ICONV:\n#ifdef ICONV_OPTION\n\t\t\ticonv_opt = NULL;\n#endif\n\t\t\tbreak;\n\n\t\tcase OPT_MAX_SIZE:\n\t\t\tif ((max_size = parse_size_arg(&max_size_arg, 'b')) < 0) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"--max-size value is invalid: %s\\n\",\n\t\t\t\t\tmax_size_arg);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_MIN_SIZE:\n\t\t\tif ((min_size = parse_size_arg(&min_size_arg, 'b')) < 0) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"--min-size value is invalid: %s\\n\",\n\t\t\t\t\tmin_size_arg);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_BWLIMIT:\n\t\t\t{\n\t\t\t\tOFF_T limit = parse_size_arg(&bwlimit_arg, 'K');\n\t\t\t\tif (limit < 0) {\n\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\t\"--bwlimit value is invalid: %s\\n\", bwlimit_arg);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbwlimit = (limit + 512) \/ 1024;\n\t\t\t\tif (limit && !bwlimit) {\n\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\t\"--bwlimit value is too small: %s\\n\", bwlimit_arg);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_APPEND:\n\t\t\tif (am_server)\n\t\t\t\tappend_mode++;\n\t\t\telse\n\t\t\t\tappend_mode = 1;\n\t\t\tbreak;\n\n\t\tcase OPT_LINK_DEST:\n#ifdef SUPPORT_HARD_LINKS\n\t\t\tlink_dest = 1;\n\t\t\tdest_option = \"--link-dest\";\n\t\t\tgoto set_dest_dir;\n#else\n\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t \"hard links are not supported on this %s\\n\",\n\t\t\t\t am_server ? \"server\" : \"client\");\n\t\t\treturn 0;\n#endif\n\n\t\tcase OPT_COPY_DEST:\n\t\t\tcopy_dest = 1;\n\t\t\tdest_option = \"--copy-dest\";\n\t\t\tgoto set_dest_dir;\n\n\t\tcase OPT_COMPARE_DEST:\n\t\t\tcompare_dest = 1;\n\t\t\tdest_option = \"--compare-dest\";\n\t\tset_dest_dir:\n\t\t\tif (basis_dir_cnt >= MAX_BASIS_DIRS) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"ERROR: at most %d %s args may be specified\\n\",\n\t\t\t\t\tMAX_BASIS_DIRS, dest_option);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t\/* We defer sanitizing this arg until we know what\n\t\t\t * our destination directory is going to be. *\/\n\t\t\tbasis_dir[basis_dir_cnt++] = (char *)poptGetOptArg(pc);\n\t\t\tbreak;\n\n\t\tcase OPT_CHMOD:\n\t\t\targ = poptGetOptArg(pc);\n\t\t\tif (!parse_chmod(arg, &chmod_modes)) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t    \"Invalid argument passed to --chmod (%s)\\n\",\n\t\t\t\t    arg);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_INFO:\n\t\t\targ = poptGetOptArg(pc);\n\t\t\tparse_output_words(info_words, info_levels, arg, USER_PRIORITY);\n\t\t\tbreak;\n\n\t\tcase OPT_DEBUG:\n\t\t\targ = poptGetOptArg(pc);\n\t\t\tparse_output_words(debug_words, debug_levels, arg, USER_PRIORITY);\n\t\t\tbreak;\n\n\t\tcase OPT_USERMAP:\n\t\t\tif (usermap) {\n\t\t\t\tif (usermap_via_chown) {\n\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t    \"--usermap conflicts with prior --chown.\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t    \"You can only specify --usermap once.\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tusermap = (char *)poptGetOptArg(pc);\n\t\t\tusermap_via_chown = False;\n\t\t\tbreak;\n\n\t\tcase OPT_GROUPMAP:\n\t\t\tif (groupmap) {\n\t\t\t\tif (groupmap_via_chown) {\n\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t    \"--groupmap conflicts with prior --chown.\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t    \"You can only specify --groupmap once.\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tgroupmap = (char *)poptGetOptArg(pc);\n\t\t\tgroupmap_via_chown = False;\n\t\t\tbreak;\n\n\t\tcase OPT_CHOWN: {\n\t\t\tconst char *chown = poptGetOptArg(pc);\n\t\t\tint len;\n\t\t\tif ((arg = strchr(chown, ':')) != NULL)\n\t\t\t\tlen = arg++ - chown;\n\t\t\telse\n\t\t\t\tlen = strlen(chown);\n\t\t\tif (len) {\n\t\t\t\tif (usermap) {\n\t\t\t\t\tif (!usermap_via_chown) {\n\t\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\t    \"--chown conflicts with prior --usermap.\\n\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t    \"You can only specify a user-affecting --chown once.\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (asprintf(&usermap, \"*:%.*s\", len, chown) < 0)\n\t\t\t\t\tout_of_memory(\"parse_arguments\");\n\t\t\t\tusermap_via_chown = True;\n\t\t\t}\n\t\t\tif (arg && *arg) {\n\t\t\t\tif (groupmap) {\n\t\t\t\t\tif (!groupmap_via_chown) {\n\t\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\t    \"--chown conflicts with prior --groupmap.\\n\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t    \"You can only specify a group-affecting --chown once.\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (asprintf(&groupmap, \"*:%s\", arg) < 0)\n\t\t\t\t\tout_of_memory(\"parse_arguments\");\n\t\t\t\tgroupmap_via_chown = True;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OPT_HELP:\n\t\t\tusage(FINFO);\n\t\t\texit_cleanup(0);\n\n\t\tcase 'A':\n#ifdef SUPPORT_ACLS\n\t\t\tpreserve_acls = 1;\n\t\t\tpreserve_perms = 1;\n\t\t\tbreak;\n#else\n\t\t\t\/* FIXME: this should probably be ignored with a\n\t\t\t * warning and then countermeasures taken to\n\t\t\t * restrict group and other access in the presence\n\t\t\t * of any more restrictive ACLs, but this is safe\n\t\t\t * for now *\/\n\t\t\tsnprintf(err_buf,sizeof(err_buf),\n                                 \"ACLs are not supported on this %s\\n\",\n\t\t\t\t am_server ? \"server\" : \"client\");\n\t\t\treturn 0;\n#endif\n\n\t\tcase 'X':\n#ifdef SUPPORT_XATTRS\n\t\t\tpreserve_xattrs++;\n\t\t\tbreak;\n#else\n\t\t\tsnprintf(err_buf,sizeof(err_buf),\n\t\t\t\t \"extended attributes are not supported on this %s\\n\",\n\t\t\t\t am_server ? \"server\" : \"client\");\n\t\t\treturn 0;\n#endif\n\n\t\tdefault:\n\t\t\t\/* A large opt value means that set_refuse_options()\n\t\t\t * turned this option off. *\/\n\t\t\tif (opt >= OPT_REFUSED_BASE) {\n\t\t\t\tcreate_refuse_error(opt);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tsnprintf(err_buf, sizeof err_buf, \"%s%s: %s\\n\",\n\t\t\t\t am_server ? \"on remote machine: \" : \"\",\n\t\t\t\t poptBadOption(pc, POPT_BADOPTION_NOALIAS),\n\t\t\t\t poptStrerror(opt));\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif (protect_args < 0) {\n\t\tif (am_server)\n\t\t\tprotect_args = 0;\n\t\telse if ((arg = getenv(\"RSYNC_PROTECT_ARGS\")) != NULL && *arg)\n\t\t\tprotect_args = atoi(arg) ? 1 : 0;\n\t\telse {\n#ifdef RSYNC_USE_PROTECTED_ARGS\n\t\t\tprotect_args = 1;\n#else\n\t\t\tprotect_args = 0;\n#endif\n\t\t}\n\t}\n\n\tif (checksum_choice && strcmp(checksum_choice, \"auto\") != 0 && strcmp(checksum_choice, \"auto,auto\") != 0) {\n\t\t\/* Call this early to verify the args and figure out if we need to force\n\t\t * --whole-file. Note that the parse function will get called again later,\n\t\t * just in case an \"auto\" choice needs to know the protocol_version. *\/\n\t\tif (parse_checksum_choice())\n\t\t\twhole_file = 1;\n\t} else\n\t\tchecksum_choice = NULL;\n\n\tif (human_readable > 1 && argc == 2 && !am_server) {\n\t\t\/* Allow the old meaning of 'h' (--help) on its own. *\/\n\t\tusage(FINFO);\n\t\texit_cleanup(0);\n\t}\n\n\tif (do_compression || def_compress_level != NOT_SPECIFIED) {\n\t\tif (def_compress_level == NOT_SPECIFIED)\n\t\t\tdef_compress_level = Z_DEFAULT_COMPRESSION;\n\t\telse if (def_compress_level < Z_DEFAULT_COMPRESSION || def_compress_level > Z_BEST_COMPRESSION) {\n\t\t\tsnprintf(err_buf, sizeof err_buf, \"--compress-level value is invalid: %d\\n\",\n\t\t\t\t def_compress_level);\n\t\t\treturn 0;\n\t\t} else if (def_compress_level == Z_NO_COMPRESSION)\n\t\t\tdo_compression = 0;\n\t\telse if (!do_compression)\n\t\t\tdo_compression = 1;\n\t\tif (do_compression && refused_compress) {\n\t\t\tcreate_refuse_error(refused_compress);\n\t\t\treturn 0;\n\t\t}\n#ifdef EXTERNAL_ZLIB\n\t\tif (do_compression == 1) {\n\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\"This rsync lacks old-style --compress due to its external zlib.  Try -zz.\\n\");\n\t\t\tif (am_server)\n\t\t\t\treturn 0;\n\t\t\tfprintf(stderr, \"%s\" \"Continuing without compression.\\n\\n\", err_buf);\n\t\t\tdo_compression = 0;\n\t\t}\n#endif\n\t}\n\n#ifdef HAVE_SETVBUF\n\tif (outbuf_mode && !am_server) {\n\t\tint mode = *(uchar *)outbuf_mode;\n\t\tif (islower(mode))\n\t\t\tmode = toupper(mode);\n\t\tfflush(stdout); \/* Just in case... *\/\n\t\tswitch (mode) {\n\t\tcase 'N': \/* None *\/\n\t\tcase 'U': \/* Unbuffered *\/\n\t\t\tmode = _IONBF;\n\t\t\tbreak;\n\t\tcase 'L': \/* Line *\/\n\t\t\tmode = _IOLBF;\n\t\t\tbreak;\n\t\tcase 'B': \/* Block *\/\n\t\tcase 'F': \/* Full *\/\n\t\t\tmode = _IOFBF;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\"Invalid --outbuf setting -- specify N, L, or B.\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tsetvbuf(stdout, (char *)NULL, mode, 0);\n\t}\n\n\tif (msgs2stderr) {\n\t\t\/* Make stderr line buffered for better sharing of the stream. *\/\n\t\tfflush(stderr); \/* Just in case... *\/\n\t\tsetvbuf(stderr, (char *)NULL, _IOLBF, 0);\n\t}\n#endif\n\n\tset_output_verbosity(verbose, DEFAULT_PRIORITY);\n\n\tif (do_stats) {\n\t\tparse_output_words(info_words, info_levels,\n\t\t\tverbose > 1 ? \"stats3\" : \"stats2\", DEFAULT_PRIORITY);\n\t}\n\n#ifdef ICONV_OPTION\n\tif (iconv_opt && protect_args != 2) {\n\t\tif (!am_server && strcmp(iconv_opt, \"-\") == 0)\n\t\t\ticonv_opt = NULL;\n\t\telse\n\t\t\tneed_unsorted_flist = 1;\n\t}\n\tif (refused_no_iconv && !iconv_opt) {\n\t\tcreate_refuse_error(refused_no_iconv);\n\t\treturn 0;\n\t}\n#endif\n\n\tif (fuzzy_basis > 1)\n\t\tfuzzy_basis = basis_dir_cnt + 1;\n\n\tif (protect_args == 1 && am_server)\n\t\treturn 1;\n\n\t*argv_p = argv = poptGetArgs(pc);\n\t*argc_p = argc = count_args(argv);\n\n#ifndef SUPPORT_LINKS\n\tif (preserve_links && !am_sender) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"symlinks are not supported on this %s\\n\",\n\t\t\t am_server ? \"server\" : \"client\");\n\t\treturn 0;\n\t}\n#endif\n\n#ifndef SUPPORT_HARD_LINKS\n\tif (preserve_hard_links) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"hard links are not supported on this %s\\n\",\n\t\t\t am_server ? \"server\" : \"client\");\n\t\treturn 0;\n\t}\n#endif\n\n#ifdef SUPPORT_XATTRS\n\tif (am_root < 0 && preserve_xattrs > 1) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"--fake-super conflicts with -XX\\n\");\n\t\treturn 0;\n\t}\n#else\n\tif (am_root < 0) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"--fake-super requires an rsync with extended attributes enabled\\n\");\n\t\treturn 0;\n\t}\n#endif\n\n\tif (block_size > MAX_BLOCK_SIZE) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"--block-size=%lu is too large (max: %u)\\n\", block_size, MAX_BLOCK_SIZE);\n\t\treturn 0;\n\t}\n\n\tif (write_batch && read_batch) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"--write-batch and --read-batch can not be used together\\n\");\n\t\treturn 0;\n\t}\n\tif (write_batch > 0 || read_batch) {\n\t\tif (am_server) {\n\t\t\trprintf(FINFO,\n\t\t\t\t\"ignoring --%s-batch option sent to server\\n\",\n\t\t\t\twrite_batch ? \"write\" : \"read\");\n\t\t\t\/* We don't actually exit_cleanup(), so that we can\n\t\t\t * still service older version clients that still send\n\t\t\t * batch args to server. *\/\n\t\t\tread_batch = write_batch = 0;\n\t\t\tbatch_name = NULL;\n\t\t} else if (dry_run)\n\t\t\twrite_batch = 0;\n\t} else if (write_batch < 0 && dry_run)\n\t\twrite_batch = 0;\n\tif (read_batch && files_from) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"--read-batch cannot be used with --files-from\\n\");\n\t\treturn 0;\n\t}\n\tif (read_batch && remove_source_files) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"--read-batch cannot be used with --remove-%s-files\\n\",\n\t\t\tremove_source_files == 1 ? \"source\" : \"sent\");\n\t\treturn 0;\n\t}\n\tif (batch_name && strlen(batch_name) > MAX_BATCH_NAME_LEN) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"the batch-file name must be %d characters or less.\\n\",\n\t\t\tMAX_BATCH_NAME_LEN);\n\t\treturn 0;\n\t}\n\n\tif (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"the --temp-dir path is WAY too long.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (max_delete < 0 && max_delete != INT_MIN) {\n\t\t\/* Negative numbers are treated as \"no deletions\". *\/\n\t\tmax_delete = 0;\n\t}\n\n\tif (compare_dest + copy_dest + link_dest > 1) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"You may not mix --compare-dest, --copy-dest, and --link-dest.\\n\");\n\t\treturn 0;\n\t}\n\n\tif (files_from) {\n\t\tif (recurse == 1) \/* preserve recurse == 2 *\/\n\t\t\trecurse = 0;\n\t\tif (xfer_dirs < 0)\n\t\t\txfer_dirs = 1;\n\t}\n\n\tif (argc < 2 && !read_batch && !am_server)\n\t\tlist_only |= 1;\n\n\tif (xfer_dirs >= 4) {\n\t\tparse_filter_str(&filter_list, \"- \/*\/*\", rule_template(0), 0);\n\t\trecurse = xfer_dirs = 1;\n\t} else if (recurse)\n\t\txfer_dirs = 1;\n\telse if (xfer_dirs < 0)\n\t\txfer_dirs = list_only ? 1 : 0;\n\n\tif (relative_paths < 0)\n\t\trelative_paths = files_from? 1 : 0;\n\tif (!relative_paths)\n\t\timplied_dirs = 0;\n\n\tif (delete_before + !!delete_during + delete_after > 1) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"You may not combine multiple --delete-WHEN options.\\n\");\n\t\treturn 0;\n\t}\n\tif (delete_before || delete_during || delete_after)\n\t\tdelete_mode = 1;\n\telse if (delete_mode || delete_excluded) {\n\t\t\/* Only choose now between before & during if one is refused. *\/\n\t\tif (refused_delete_before) {\n\t\t\tif (!refused_delete_during)\n\t\t\t\tdelete_during = 1;\n\t\t\telse {\n\t\t\t\tcreate_refuse_error(refused_delete_before);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t} else if (refused_delete_during)\n\t\t\tdelete_before = 1;\n\t\tdelete_mode = 1;\n\t}\n\tif (!xfer_dirs && delete_mode) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"--delete does not work without --recursive (-r) or --dirs (-d).\\n\");\n\t\treturn 0;\n\t}\n\n\tif (missing_args == 3) \/* simplify if both options were specified *\/\n\t\tmissing_args = 2;\n\tif (refused_delete && (delete_mode || missing_args == 2)) {\n\t\tcreate_refuse_error(refused_delete);\n\t\treturn 0;\n\t}\n\n\tif (remove_source_files) {\n\t\t\/* We only want to infer this refusal of --remove-source-files\n\t\t * via the refusal of \"delete\", not any of the \"delete-FOO\"\n\t\t * options. *\/\n\t\tif (refused_delete && am_sender) {\n\t\t\tcreate_refuse_error(refused_delete);\n\t\t\treturn 0;\n\t\t}\n\t\tneed_messages_from_generator = 1;\n\t}\n\n\tif (munge_symlinks && !am_daemon) {\n\t\tSTRUCT_STAT st;\n\t\tchar prefix[SYMLINK_PREFIX_LEN]; \/* NOT +1 ! *\/\n\t\tstrlcpy(prefix, SYMLINK_PREFIX, sizeof prefix); \/* trim the trailing slash *\/\n\t\tif (do_stat(prefix, &st) == 0 && S_ISDIR(st.st_mode)) {\n\t\t\trprintf(FERROR, \"Symlink munging is unsafe when a %s directory exists.\\n\",\n\t\t\t\tprefix);\n\t\t\texit_cleanup(RERR_UNSUPPORTED);\n\t\t}\n\t}\n\n\tif (sanitize_paths) {\n\t\tint i;\n\t\tfor (i = argc; i-- > 0; )\n\t\t\targv[i] = sanitize_path(NULL, argv[i], \"\", 0, SP_KEEP_DOT_DIRS);\n\t\tif (tmpdir)\n\t\t\ttmpdir = sanitize_path(NULL, tmpdir, NULL, 0, SP_DEFAULT);\n\t\tif (backup_dir)\n\t\t\tbackup_dir = sanitize_path(NULL, backup_dir, NULL, 0, SP_DEFAULT);\n\t}\n\tif (daemon_filter_list.head && !am_sender) {\n\t\tfilter_rule_list *elp = &daemon_filter_list;\n\t\tif (tmpdir) {\n\t\t\tchar *dir;\n\t\t\tif (!*tmpdir)\n\t\t\t\tgoto options_rejected;\n\t\t\tdir = tmpdir + (*tmpdir == '\/' ? module_dirlen : 0);\n\t\t\tclean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);\n\t\t\tif (check_filter(elp, FLOG, dir, 1) < 0)\n\t\t\t\tgoto options_rejected;\n\t\t}\n\t\tif (backup_dir) {\n\t\t\tchar *dir;\n\t\t\tif (!*backup_dir)\n\t\t\t\tgoto options_rejected;\n\t\t\tdir = backup_dir + (*backup_dir == '\/' ? module_dirlen : 0);\n\t\t\tclean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);\n\t\t\tif (check_filter(elp, FLOG, dir, 1) < 0)\n\t\t\t\tgoto options_rejected;\n\t\t}\n\t}\n\n\tif (!backup_suffix)\n\t\tbackup_suffix = backup_dir ? \"\" : BACKUP_SUFFIX;\n\tbackup_suffix_len = strlen(backup_suffix);\n\tif (strchr(backup_suffix, '\/') != NULL) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"--suffix cannot contain slashes: %s\\n\",\n\t\t\tbackup_suffix);\n\t\treturn 0;\n\t}\n\tif (backup_dir) {\n\t\tsize_t len;\n\t\twhile (*backup_dir == '.' && backup_dir[1] == '\/')\n\t\t\tbackup_dir += 2;\n\t\tif (*backup_dir == '.' && backup_dir[1] == '\\0')\n\t\t\tbackup_dir++;\n\t\tlen = strlcpy(backup_dir_buf, backup_dir, sizeof backup_dir_buf);\n\t\tif (len > sizeof backup_dir_buf - 128) {\n\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\"the --backup-dir path is WAY too long.\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tbackup_dir_len = (int)len;\n\t\tif (!backup_dir_len) {\n\t\t\tbackup_dir_len = -1;\n\t\t\tbackup_dir = NULL;\n\t\t} else if (backup_dir_buf[backup_dir_len - 1] != '\/') {\n\t\t\tbackup_dir_buf[backup_dir_len++] = '\/';\n\t\t\tbackup_dir_buf[backup_dir_len] = '\\0';\n\t\t}\n\t\tbackup_dir_remainder = sizeof backup_dir_buf - backup_dir_len;\n\t}\n\tif (backup_dir) {\n\t\t\/* No need for a suffix or a protect rule. *\/\n\t} else if (!backup_suffix_len && (!am_server || !am_sender)) {\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\"--suffix cannot be empty %s\\n\", backup_dir_len < 0\n\t\t\t? \"when --backup-dir is the same as the dest dir\"\n\t\t\t: \"without a --backup-dir\");\n\t\treturn 0;\n\t} else if (make_backups && delete_mode && !delete_excluded && !am_server) {\n\t\tsnprintf(backup_dir_buf, sizeof backup_dir_buf,\n\t\t\t\"P *%s\", backup_suffix);\n\t\tparse_filter_str(&filter_list, backup_dir_buf, rule_template(0), 0);\n\t}\n\n\tif (preserve_times) {\n\t\tpreserve_times = PRESERVE_FILE_TIMES;\n\t\tif (!omit_dir_times)\n\t\t\tpreserve_times |= PRESERVE_DIR_TIMES;\n#ifdef CAN_SET_SYMLINK_TIMES\n\t\tif (!omit_link_times)\n\t\t\tpreserve_times |= PRESERVE_LINK_TIMES;\n#endif\n\t}\n\n\tif (make_backups && !backup_dir) {\n\t\tomit_dir_times = 0; \/* Implied, so avoid -O to sender. *\/\n\t\tpreserve_times &= ~PRESERVE_DIR_TIMES;\n\t}\n\n\tif (stdout_format) {\n\t\tif (am_server && log_format_has(stdout_format, 'I'))\n\t\t\tstdout_format_has_i = 2;\n\t\telse if (log_format_has(stdout_format, 'i'))\n\t\t\tstdout_format_has_i = itemize_changes | 1;\n\t\tif (!log_format_has(stdout_format, 'b')\n\t\t && !log_format_has(stdout_format, 'c')\n\t\t && !log_format_has(stdout_format, 'C'))\n\t\t\tlog_before_transfer = !am_server;\n\t} else if (itemize_changes) {\n\t\tstdout_format = \"%i %n%L\";\n\t\tstdout_format_has_i = itemize_changes;\n\t\tlog_before_transfer = !am_server;\n\t}\n\n\tif (do_progress && !am_server) {\n\t\tif (!log_before_transfer && INFO_EQ(NAME, 0))\n\t\t\tparse_output_words(info_words, info_levels, \"name\", DEFAULT_PRIORITY);\n\t\tparse_output_words(info_words, info_levels, \"flist2,progress\", DEFAULT_PRIORITY);\n\t}\n\n\tif (dry_run)\n\t\tdo_xfers = 0;\n\n\tset_io_timeout(io_timeout);\n\n\tif (INFO_GTE(NAME, 1) && !stdout_format) {\n\t\tstdout_format = \"%n%L\";\n\t\tlog_before_transfer = !am_server;\n\t}\n\tif (stdout_format_has_i || log_format_has(stdout_format, 'o'))\n\t\tstdout_format_has_o_or_i = 1;\n\n\tif (logfile_name && !am_daemon) {\n\t\tif (!logfile_format) {\n\t\t\tlogfile_format = \"%i %n%L\";\n\t\t\tlogfile_format_has_i = logfile_format_has_o_or_i = 1;\n\t\t} else {\n\t\t\tif (log_format_has(logfile_format, 'i'))\n\t\t\t\tlogfile_format_has_i = 1;\n\t\t\tif (logfile_format_has_i || log_format_has(logfile_format, 'o'))\n\t\t\t\tlogfile_format_has_o_or_i = 1;\n\t\t}\n\t\tlog_init(0);\n\t} else if (!am_daemon)\n\t\tlogfile_format = NULL;\n\n\tif (daemon_bwlimit && (!bwlimit || bwlimit > daemon_bwlimit))\n\t\tbwlimit = daemon_bwlimit;\n\tif (bwlimit) {\n\t\tbwlimit_writemax = (size_t)bwlimit * 128;\n\t\tif (bwlimit_writemax < 512)\n\t\t\tbwlimit_writemax = 512;\n\t}\n\n\tif (append_mode) {\n\t\tif (whole_file > 0) {\n\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t \"--append cannot be used with --whole-file\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (refused_inplace) {\n\t\t\tcreate_refuse_error(refused_inplace);\n\t\t\treturn 0;\n\t\t}\n\t\tinplace = 1;\n\t}\n\n\tif (delay_updates && !partial_dir)\n\t\tpartial_dir = tmp_partialdir;\n\n\tif (inplace) {\n#ifdef HAVE_FTRUNCATE\n\t\tif (partial_dir) {\n\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t \"--%s cannot be used with --%s\\n\",\n\t\t\t\t append_mode ? \"append\" : \"inplace\",\n\t\t\t\t delay_updates ? \"delay-updates\" : \"partial-dir\");\n\t\t\treturn 0;\n\t\t}\n\t\t\/* --inplace implies --partial for refusal purposes, but we\n\t\t * clear the keep_partial flag for internal logic purposes. *\/\n\t\tif (refused_partial) {\n\t\t\tcreate_refuse_error(refused_partial);\n\t\t\treturn 0;\n\t\t}\n\t\tkeep_partial = 0;\n#else\n\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t \"--%s is not supported on this %s\\n\",\n\t\t\t append_mode ? \"append\" : \"inplace\",\n\t\t\t am_server ? \"server\" : \"client\");\n\t\treturn 0;\n#endif\n\t} else {\n\t\tif (keep_partial && !partial_dir && !am_server) {\n\t\t\tif ((arg = getenv(\"RSYNC_PARTIAL_DIR\")) != NULL && *arg)\n\t\t\t\tpartial_dir = strdup(arg);\n\t\t}\n\t\tif (partial_dir) {\n\t\t\tif (*partial_dir)\n\t\t\t\tclean_fname(partial_dir, CFN_COLLAPSE_DOT_DOT_DIRS);\n\t\t\tif (!*partial_dir || strcmp(partial_dir, \".\") == 0)\n\t\t\t\tpartial_dir = NULL;\n\t\t\tif (!partial_dir && refused_partial) {\n\t\t\t\tcreate_refuse_error(refused_partial);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tkeep_partial = 1;\n\t\t}\n\t}\n\n\tif (files_from) {\n\t\tchar *h, *p;\n\t\tint q;\n\t\tif (argc > 2 || (!am_daemon && !am_server && argc == 1)) {\n\t\t\tusage(FERROR);\n\t\t\texit_cleanup(RERR_SYNTAX);\n\t\t}\n\t\tif (strcmp(files_from, \"-\") == 0) {\n\t\t\tfilesfrom_fd = 0;\n\t\t\tif (am_server)\n\t\t\t\tfilesfrom_host = \"\"; \/* reading from socket *\/\n\t\t} else if ((p = check_for_hostspec(files_from, &h, &q)) != 0) {\n\t\t\tif (am_server) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"The --files-from sent to the server cannot specify a host.\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfiles_from = p;\n\t\t\tfilesfrom_host = h;\n\t\t\tif (strcmp(files_from, \"-\") == 0) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"Invalid --files-from remote filename\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t} else {\n\t\t\tif (sanitize_paths)\n\t\t\t\tfiles_from = sanitize_path(NULL, files_from, NULL, 0, SP_DEFAULT);\n\t\t\tif (daemon_filter_list.head) {\n\t\t\t\tchar *dir;\n\t\t\t\tif (!*files_from)\n\t\t\t\t\tgoto options_rejected;\n\t\t\t\tdir = files_from + (*files_from == '\/' ? module_dirlen : 0);\n\t\t\t\tclean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);\n\t\t\t\tif (check_filter(&daemon_filter_list, FLOG, dir, 0) < 0)\n\t\t\t\t\tgoto options_rejected;\n\t\t\t}\n\t\t\tfilesfrom_fd = open(files_from, O_RDONLY|O_BINARY);\n\t\t\tif (filesfrom_fd < 0) {\n\t\t\t\tsnprintf(err_buf, sizeof err_buf,\n\t\t\t\t\t\"failed to open files-from file %s: %s\\n\",\n\t\t\t\t\tfiles_from, strerror(errno));\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tam_starting_up = 0;\n\n\treturn 1;\n\n  options_rejected:\n\tsnprintf(err_buf, sizeof err_buf,\n\t\t\"Your options have been rejected by the server.\\n\");\n\treturn 0;\n}","target":1,"code_token_length":8164,"total_token_length":8400,"max_tokens_setting":11000}
+{"idx":11809,"func":"std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target)\n{\n\tstd::vector<GetLengthType> results;\n\tGetLengthType retval;\n\tretval.startOrder = target.startOrder;\n\tretval.startRow = target.startRow;\n\n\tconst bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget;\n\tconst bool adjustSamplePos = (adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions;\n\n\tSEQUENCEINDEX sequence = target.sequence;\n\tif(sequence >= Order.GetNumSequences()) sequence = Order.GetCurrentSequenceIndex();\n\tconst ModSequence &orderList = Order(sequence);\n\n\tGetLengthMemory memory(*this);\n\tCSoundFile::PlayState &playState = *memory.state;\n\tRowVisitor visitedRows(*this, sequence);\n\n\tplayState.m_nNextRow = playState.m_nRow = target.startRow;\n\tplayState.m_nNextOrder = playState.m_nCurrentOrder = target.startOrder;\n\n\tstd::bitset<MAX_EFFECTS> forbiddenCommands;\n\tstd::bitset<MAX_VOLCMDS> forbiddenVolCommands;\n\n\tif(adjustSamplePos)\n\t{\n\t\tforbiddenCommands.set(CMD_ARPEGGIO);             forbiddenCommands.set(CMD_PORTAMENTOUP);\n\t\tforbiddenCommands.set(CMD_PORTAMENTODOWN);       forbiddenCommands.set(CMD_XFINEPORTAUPDOWN);\n\t\tforbiddenCommands.set(CMD_NOTESLIDEUP);          forbiddenCommands.set(CMD_NOTESLIDEUPRETRIG);\n\t\tforbiddenCommands.set(CMD_NOTESLIDEDOWN);        forbiddenCommands.set(CMD_NOTESLIDEDOWNRETRIG);\n\t\tforbiddenVolCommands.set(VOLCMD_PORTAUP);        forbiddenVolCommands.set(VOLCMD_PORTADOWN);\n\n\t\tfor(CHANNELINDEX i = 0; i < GetNumChannels(); i++)\n\t\t{\n\t\t\tif(ChnSettings[i].dwFlags[CHN_MUTE]) memory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL;\n\t\t}\n\t\tif(target.mode == GetLengthTarget::SeekPosition && target.pos.order < orderList.size())\n\t\t{\n\t\t\tconst PATTERNINDEX seekPat = orderList[target.pos.order];\n\t\t\tif(Patterns.IsValidPat(seekPat) && Patterns[seekPat].IsValidRow(target.pos.row))\n\t\t\t{\n\t\t\t\tconst ModCommand *m = Patterns[seekPat].GetRow(target.pos.row);\n\t\t\t\tfor(CHANNELINDEX i = 0; i < GetNumChannels(); i++, m++)\n\t\t\t\t{\n\t\t\t\t\tif(m->note == NOTE_NOTECUT || m->note == NOTE_KEYOFF || (m->note == NOTE_FADE && GetNumInstruments())\n\t\t\t\t\t\t|| (m->IsNote() && !m->IsPortamento()))\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tuint32 oldTickDuration = 0;\n\n\tfor (;;)\n\t{\n\t\tif(target.mode == GetLengthTarget::SeekSeconds && memory.elapsedTime >= target.time)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tuint32 rowDelay = 0, tickDelay = 0;\n\t\tplayState.m_nRow = playState.m_nNextRow;\n\t\tplayState.m_nCurrentOrder = playState.m_nNextOrder;\n\n\t\tif(orderList.IsValidPat(playState.m_nCurrentOrder) && playState.m_nRow >= Patterns[orderList[playState.m_nCurrentOrder]].GetNumRows())\n\t\t{\n\t\t\tplayState.m_nRow = 0;\n\t\t\tif(m_playBehaviour[kFT2LoopE60Restart])\n\t\t\t{\n\t\t\t\tplayState.m_nRow = playState.m_nNextPatStartRow;\n\t\t\t\tplayState.m_nNextPatStartRow = 0;\n\t\t\t}\n\t\t\tplayState.m_nCurrentOrder = ++playState.m_nNextOrder;\n\t\t}\n\n\t\tplayState.m_nPattern = playState.m_nCurrentOrder < orderList.size() ? orderList[playState.m_nCurrentOrder] : orderList.GetInvalidPatIndex();\n\t\tbool positionJumpOnThisRow = false;\n\t\tbool patternBreakOnThisRow = false;\n\t\tbool patternLoopEndedOnThisRow = false, patternLoopStartedOnThisRow = false;\n\n\t\tif(!Patterns.IsValidPat(playState.m_nPattern) && playState.m_nPattern != orderList.GetInvalidPatIndex() && target.mode == GetLengthTarget::SeekPosition && playState.m_nCurrentOrder == target.pos.order)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}\n\n\t\twhile(playState.m_nPattern >= Patterns.Size())\n\t\t{\n\t\t\tif((playState.m_nPattern == orderList.GetInvalidPatIndex()) || (playState.m_nCurrentOrder >= orderList.size()))\n\t\t\t{\n\t\t\t\tif(playState.m_nCurrentOrder == orderList.GetRestartPos())\n\t\t\t\t\tbreak;\n\t\t\t\telse\n\t\t\t\t\tplayState.m_nCurrentOrder = orderList.GetRestartPos();\n\t\t\t} else\n\t\t\t{\n\t\t\t\tplayState.m_nCurrentOrder++;\n\t\t\t}\n\t\t\tplayState.m_nPattern = (playState.m_nCurrentOrder < orderList.size()) ? orderList[playState.m_nCurrentOrder] : orderList.GetInvalidPatIndex();\n\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder;\n\t\t\tif((!Patterns.IsValidPat(playState.m_nPattern)) && visitedRows.IsVisited(playState.m_nCurrentOrder, 0, true))\n\t\t\t{\n\t\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\t\tresults.push_back(retval);\n\t\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\t\tmemory.Reset();\n\n\t\t\t\t\tplayState.m_nCurrentOrder = playState.m_nNextOrder;\n\t\t\t\t\tplayState.m_nPattern = orderList[playState.m_nCurrentOrder];\n\t\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(playState.m_nNextOrder == ORDERINDEX_INVALID)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\n\t\tif(!Patterns.IsValidPat(playState.m_nPattern))\n\t\t{\n\t\t\tif(playState.m_nCurrentOrder == orderList.GetRestartPos())\n\t\t\t{\n\t\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\t\tresults.push_back(retval);\n\t\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\t\tmemory.Reset();\n\t\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder + 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif(playState.m_nRow >= Patterns[playState.m_nPattern].GetNumRows())\n\t\t\tplayState.m_nRow = 0;\n\n\t\tif(target.mode == GetLengthTarget::SeekPosition && playState.m_nCurrentOrder == target.pos.order && playState.m_nRow == target.pos.row)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tif(visitedRows.IsVisited(playState.m_nCurrentOrder, playState.m_nRow, true))\n\t\t{\n\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t} else\n\t\t\t{\n\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\tresults.push_back(retval);\n\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\tmemory.Reset();\n\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tretval.endOrder = playState.m_nCurrentOrder;\n\t\tretval.endRow = playState.m_nRow;\n\n\t\tplayState.m_nNextRow = playState.m_nRow + 1;\n\n\t\tif(playState.m_nRow >= Patterns[playState.m_nPattern].GetNumRows())\n\t\t{\n\t\t\tplayState.m_nRow = 0;\n\t\t}\n\t\tif(!playState.m_nRow)\n\t\t{\n\t\t\tfor(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)\n\t\t\t{\n\t\t\t\tmemory.chnSettings[chn].patLoop = memory.elapsedTime;\n\t\t\t\tmemory.chnSettings[chn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t}\n\t\t}\n\n\t\tModChannel *pChn = playState.Chn;\n\t\t\n\t\tconst ModCommand *p = Patterns[playState.m_nPattern].GetpModCommand(playState.m_nRow, 0);\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, p++)\n\t\t{\n\t\t\tif(m_playBehaviour[kST3NoMutedChannels] && ChnSettings[nChn].dwFlags[CHN_MUTE])\t\/\/ not even effects are processed on muted S3M channels\n\t\t\t\tcontinue;\n\t\t\tif(p->IsPcNote())\n\t\t\t{\n#ifndef NO_PLUGINS\n\t\t\t\tif((adjustMode & eAdjust) && p->instr > 0 && p->instr <= MAX_MIXPLUGINS)\n\t\t\t\t{\n\t\t\t\t\tmemory.plugParams[std::make_pair(p->instr, p->GetValueVolCol())] = p->GetValueEffectCol();\n\t\t\t\t}\n#endif \/\/ NO_PLUGINS\n\t\t\t\tpChn[nChn].rowCommand.Clear();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpChn[nChn].rowCommand = *p;\n\t\t\tswitch(p->command)\n\t\t\t{\n\t\t\tcase CMD_SPEED:\n\t\t\t\tSetSpeed(playState, p->param);\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_TEMPO:\n\t\t\t\tif(m_playBehaviour[kMODVBlankTiming])\n\t\t\t\t{\n\t\t\t\t\tif(p->param != 0) SetSpeed(playState, p->param);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tif((p->param & 0xF0) == 0x60)\n\t\t\t\t{\n\t\t\t\t\ttickDelay += (p->param & 0x0F);\n\t\t\t\t} else if((p->param & 0xF0) == 0xE0 && !rowDelay)\n\t\t\t\t{\n\t\t\t\t\tif(!(GetType() & MOD_TYPE_S3M) || (p->param & 0x0F) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\trowDelay = 1 + (p->param & 0x0F);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tif((p->param & 0xF0) == 0xE0)\n\t\t\t\t{\n\t\t\t\t\trowDelay = 1 + (p->param & 0x0F);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(rowDelay == 0) rowDelay = 1;\n\t\tconst uint32 numTicks = (playState.m_nMusicSpeed + tickDelay) * rowDelay;\n\t\tconst uint32 nonRowTicks = numTicks - rowDelay;\n\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); pChn++, nChn++) if(!pChn->rowCommand.IsEmpty())\n\t\t{\n\t\t\tif(m_playBehaviour[kST3NoMutedChannels] && ChnSettings[nChn].dwFlags[CHN_MUTE])\t\/\/ not even effects are processed on muted S3M channels\n\t\t\t\tcontinue;\n\t\t\tModCommand::COMMAND command = pChn->rowCommand.command;\n\t\t\tModCommand::PARAM param = pChn->rowCommand.param;\n\t\t\tModCommand::NOTE note = pChn->rowCommand.note;\n\n\t\t\tif (pChn->rowCommand.instr)\n\t\t\t{\n\t\t\t\tpChn->nNewIns = pChn->rowCommand.instr;\n\t\t\t\tpChn->nLastNote = NOTE_NONE;\n\t\t\t\tmemory.chnSettings[nChn].vol = 0xFF;\n\t\t\t}\n\t\t\tif (pChn->rowCommand.IsNote()) pChn->nLastNote = note;\n\n\t\t\tif(pChn->rowCommand.IsNote() || pChn->rowCommand.instr)\n\t\t\t{\n\t\t\t\tSAMPLEINDEX smp = 0;\n\t\t\t\tif(GetNumInstruments())\n\t\t\t\t{\n\t\t\t\t\tModInstrument *pIns;\n\t\t\t\t\tif(pChn->nNewIns <= GetNumInstruments() && (pIns = Instruments[pChn->nNewIns]) != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pIns->dwFlags[INS_SETPANNING])\n\t\t\t\t\t\t\tpChn->nPan = pIns->nPan;\n\t\t\t\t\t\tif(ModCommand::IsNote(note))\n\t\t\t\t\t\t\tsmp = pIns->Keyboard[note - NOTE_MIN];\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tsmp = pChn->nNewIns;\n\t\t\t\t}\n\t\t\t\tif(smp > 0 && smp <= GetNumSamples() && Samples[smp].uFlags[CHN_PANNING])\n\t\t\t\t{\n\t\t\t\t\tpChn->nPan = Samples[smp].nPan;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch(pChn->rowCommand.volcmd)\n\t\t\t{\n\t\t\tcase VOLCMD_VOLUME:\n\t\t\t\tmemory.chnSettings[nChn].vol = pChn->rowCommand.vol;\n\t\t\t\tbreak;\n\t\t\tcase VOLCMD_VOLSLIDEUP:\n\t\t\tcase VOLCMD_VOLSLIDEDOWN:\n\t\t\t\tif(pChn->rowCommand.vol != 0)\n\t\t\t\t\tpChn->nOldVolParam = pChn->rowCommand.vol;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tswitch(command)\n\t\t\t{\n\t\t\tcase CMD_POSITIONJUMP:\n\t\t\t\tpositionJumpOnThisRow = true;\n\t\t\t\tplayState.m_nNextOrder = static_cast<ORDERINDEX>(CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn));\n\t\t\t\tplayState.m_nNextPatStartRow = 0;  \/\/ FT2 E60 bug\n\t\t\t\tif(!patternBreakOnThisRow || (GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)))\n\t\t\t\t\tplayState.m_nNextRow = 0;\n\n\t\t\t\tif (adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tpChn->nPatternLoopCount = 0;\n\t\t\t\t\tpChn->nPatternLoop = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PATTERNBREAK:\n\t\t\t\t{\n\t\t\t\t\tROWINDEX row = PatternBreak(playState, nChn, param);\n\t\t\t\t\tif(row != ROWINDEX_INVALID)\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternBreakOnThisRow = true;\n\t\t\t\t\t\tplayState.m_nNextRow = row;\n\n\t\t\t\t\t\tif(!positionJumpOnThisRow)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpChn->nPatternLoopCount = 0;\n\t\t\t\t\t\t\tpChn->nPatternLoop = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_TEMPO:\n\t\t\t\tif(!m_playBehaviour[kMODVBlankTiming])\n\t\t\t\t{\n\t\t\t\t\tTEMPO tempo(CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn), 0);\n\t\t\t\t\tif ((adjustMode & eAdjust) && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (tempo.GetInt()) pChn->nOldTempo = static_cast<uint8>(tempo.GetInt()); else tempo.Set(pChn->nOldTempo);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tempo.GetInt() >= 0x20) playState.m_nMusicTempo = tempo;\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tTEMPO tempoDiff((tempo.GetInt() & 0x0F) * nonRowTicks, 0);\n\t\t\t\t\t\tif ((tempo.GetInt() & 0xF0) == 0x10)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tplayState.m_nMusicTempo += tempoDiff;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(tempoDiff < playState.m_nMusicTempo)\n\t\t\t\t\t\t\t\tplayState.m_nMusicTempo -= tempoDiff;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tplayState.m_nMusicTempo.Set(0);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tTEMPO tempoMin = GetModSpecifications().GetTempoMin(), tempoMax = GetModSpecifications().GetTempoMax();\n\t\t\t\t\tif(m_playBehaviour[kTempoClamp])\t\/\/ clamp tempo correctly in compatible mode\n\t\t\t\t\t{\n\t\t\t\t\t\ttempoMax.Set(255);\n\t\t\t\t\t}\n\t\t\t\t\tLimit(playState.m_nMusicTempo, tempoMin, tempoMax);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tswitch(param & 0xF0)\n\t\t\t\t{\n\t\t\t\tcase 0x90:\n\t\t\t\t\tif(param <= 0x91)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->dwFlags.set(CHN_SURROUND, param == 0x91);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 0xA0:\n\t\t\t\t\tpChn->nOldHiOffset = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase 0xB0:\n\t\t\t\t\tif (param & 0x0F)\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternLoopEndedOnThisRow = true;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tCHANNELINDEX firstChn = nChn, lastChn = nChn;\n\t\t\t\t\t\tif(GetType() == MOD_TYPE_S3M)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfirstChn = 0;\n\t\t\t\t\t\t\tlastChn = GetNumChannels() - 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(CHANNELINDEX c = firstChn; c <= lastChn; c++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoop = memory.elapsedTime;\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoopStart = playState.m_nRow;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpatternLoopStartedOnThisRow = true;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 0xF0:\n\t\t\t\t\tpChn->nActiveMacro = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tswitch(param & 0xF0)\n\t\t\t\t{\n\t\t\t\tcase 0x60:\n\t\t\t\t\tif (param & 0x0F)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.m_nNextPatStartRow = memory.chnSettings[nChn].patLoopStart; \/\/ FT2 E60 bug\n\t\t\t\t\t\tpatternLoopEndedOnThisRow = true;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternLoopStartedOnThisRow = true;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopStart = playState.m_nRow;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 0xF0:\n\t\t\t\t\tpChn->nActiveMacro = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_XFINEPORTAUPDOWN:\n\t\t\t\tif(((param & 0xF0) == 0xA0) && !m_playBehaviour[kFT2RestrictXCommand]) pChn->nOldHiOffset = param & 0x0F;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!(adjustMode & eAdjust)) continue;\n\t\t\tswitch(command)\n\t\t\t{\n\t\t\tcase CMD_PORTAMENTOUP:\n\t\t\t\tif(param)\n\t\t\t\t{\n\t\t\t\t\tif(!m_playBehaviour[kFT2PortaUpDownMemory])\n\t\t\t\t\t\tpChn->nOldPortaDown = param;\n\t\t\t\t\tpChn->nOldPortaUp = param;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PORTAMENTODOWN:\n\t\t\t\tif(param)\n\t\t\t\t{\n\t\t\t\t\tif(!m_playBehaviour[kFT2PortaUpDownMemory])\n\t\t\t\t\t\tpChn->nOldPortaUp = param;\n\t\t\t\t\tpChn->nOldPortaDown = param;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_TONEPORTAMENTO:\n\t\t\t\tif (param) pChn->nPortamentoSlide = param << 2;\n\t\t\t\tbreak;\n\t\t\tcase CMD_OFFSET:\n\t\t\t\tif (param) pChn->oldOffset = param << 8;\n\t\t\t\tbreak;\n\t\t\tcase CMD_VOLUMESLIDE:\n\t\t\tcase CMD_TONEPORTAVOL:\n\t\t\t\tif (param) pChn->nOldVolumeSlide = param;\n\t\t\t\tbreak;\n\t\t\tcase CMD_VOLUME:\n\t\t\t\tmemory.chnSettings[nChn].vol = param;\n\t\t\t\tbreak;\n\t\t\tcase CMD_GLOBALVOLUME:\n\t\t\t\tif(!(GetType() & GLOBALVOL_7BIT_FORMATS) && param < 128) param *= 2;\n\t\t\t\tif(param <= 128)\n\t\t\t\t{\n\t\t\t\t\tplayState.m_nGlobalVolume = param * 2;\n\t\t\t\t} else if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M)))\n\t\t\t\t{\n\t\t\t\t\tplayState.m_nGlobalVolume = 256;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_GLOBALVOLSLIDE:\n\t\t\t\tif(m_playBehaviour[kPerChannelGlobalVolSlide])\n\t\t\t\t{\n\t\t\t\t\tif (param) pChn->nOldGlobalVolSlide = param; else param = pChn->nOldGlobalVolSlide;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif (param) playState.Chn[0].nOldGlobalVolSlide = param; else param = playState.Chn[0].nOldGlobalVolSlide;\n\t\t\t\t}\n\t\t\t\tif (((param & 0x0F) == 0x0F) && (param & 0xF0))\n\t\t\t\t{\n\t\t\t\t\tparam >>= 4;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume += param << 1;\n\t\t\t\t} else if (((param & 0xF0) == 0xF0) && (param & 0x0F))\n\t\t\t\t{\n\t\t\t\t\tparam = (param & 0x0F) << 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume -= param;\n\t\t\t\t} else if (param & 0xF0)\n\t\t\t\t{\n\t\t\t\t\tparam >>= 4;\n\t\t\t\t\tparam <<= 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume += param * nonRowTicks;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tparam = (param & 0x0F) << 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume -= param * nonRowTicks;\n\t\t\t\t}\n\t\t\t\tLimit(playState.m_nGlobalVolume, 0, 256);\n\t\t\t\tbreak;\n\t\t\tcase CMD_CHANNELVOLUME:\n\t\t\t\tif (param <= 64) pChn->nGlobalVol = param;\n\t\t\t\tbreak;\n\t\t\tcase CMD_CHANNELVOLSLIDE:\n\t\t\t\t{\n\t\t\t\t\tif (param) pChn->nOldChnVolSlide = param; else param = pChn->nOldChnVolSlide;\n\t\t\t\t\tint32 volume = pChn->nGlobalVol;\n\t\t\t\t\tif((param & 0x0F) == 0x0F && (param & 0xF0))\n\t\t\t\t\t\tvolume += (param >> 4);\t\t\/\/ Fine Up\n\t\t\t\t\telse if((param & 0xF0) == 0xF0 && (param & 0x0F))\n\t\t\t\t\t\tvolume -= (param & 0x0F);\t\/\/ Fine Down\n\t\t\t\t\telse if(param & 0x0F)\t\t\t\/\/ Down\n\t\t\t\t\t\tvolume -= (param & 0x0F) * nonRowTicks;\n\t\t\t\t\telse\t\t\t\t\t\t\t\/\/ Up\n\t\t\t\t\t\tvolume += ((param & 0xF0) >> 4) * nonRowTicks;\n\t\t\t\t\tLimit(volume, 0, 64);\n\t\t\t\t\tpChn->nGlobalVol = volume;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PANNING8:\n\t\t\t\tPanning(pChn, param, Pan8bit);\n\t\t\t\tbreak;\n\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tif(param < 0x10)\n\t\t\t\t{\n\t\t\t\t\tfor(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.Chn[chn].dwFlags.set(CHN_AMIGAFILTER, !(param & 1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tMPT_FALLTHROUGH;\n\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tif((param & 0xF0) == 0x80)\n\t\t\t\t{\n\t\t\t\t\tPanning(pChn, (param & 0x0F), Pan4bit);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\tif (param) pChn->nOldVolumeSlide = param;\n\t\t\t\tparam = 0;\n\t\t\t\tMPT_FALLTHROUGH;\n\t\t\tcase CMD_VIBRATO:\n\t\t\t\tVibrato(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_FINEVIBRATO:\n\t\t\t\tFineVibrato(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_TREMOLO:\n\t\t\t\tTremolo(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_PANBRELLO:\n\t\t\t\tPanbrello(pChn, param);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tswitch(pChn->rowCommand.volcmd)\n\t\t\t{\n\t\t\tcase VOLCMD_PANNING:\n\t\t\t\tPanning(pChn, pChn->rowCommand.vol, Pan6bit);\n\t\t\t\tbreak;\n\n\t\t\tcase VOLCMD_VIBRATOSPEED:\n\t\t\t\tif(m_playBehaviour[kFT2VolColVibrato])\n\t\t\t\t\tpChn->nVibratoSpeed = pChn->rowCommand.vol & 0x0F;\n\t\t\t\telse\n\t\t\t\t\tVibrato(pChn, pChn->rowCommand.vol << 4);\n\t\t\t\tbreak;\n\t\t\tcase VOLCMD_VIBRATODEPTH:\n\t\t\t\tVibrato(pChn, pChn->rowCommand.vol);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tswitch(pChn->rowCommand.command)\n\t\t\t{\n\t\t\tcase CMD_VIBRATO:\n\t\t\tcase CMD_FINEVIBRATO:\n\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tuint32 vibTicks = ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS]) ? numTicks : nonRowTicks;\n\t\t\t\t\tuint32 inc = pChn->nVibratoSpeed * vibTicks;\n\t\t\t\t\tif(m_playBehaviour[kITVibratoTremoloPanbrello])\n\t\t\t\t\t\tinc *= 4;\n\t\t\t\t\tpChn->nVibratoPos += static_cast<uint8>(inc);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_TREMOLO:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tuint32 tremTicks = ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS]) ? numTicks : nonRowTicks;\n\t\t\t\t\tuint32 inc = pChn->nTremoloSpeed * tremTicks;\n\t\t\t\t\tif(m_playBehaviour[kITVibratoTremoloPanbrello])\n\t\t\t\t\t\tinc *= 4;\n\t\t\t\t\tpChn->nTremoloPos += static_cast<uint8>(inc);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CMD_PANBRELLO:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tpChn->nPanbrelloPos += static_cast<uint8>(pChn->nPanbrelloSpeed * (numTicks - 1));\n\t\t\t\t\tProcessPanbrello(pChn);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif(GetType() == MOD_TYPE_XM && playState.m_nMusicSpeed == uint16_max)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\n\t\tplayState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat;\n\t\tif(Patterns[playState.m_nPattern].GetOverrideSignature())\n\t\t{\n\t\t\tplayState.m_nCurrentRowsPerBeat = Patterns[playState.m_nPattern].GetRowsPerBeat();\n\t\t}\n\n\t\tconst uint32 tickDuration = GetTickDuration(playState);\n\t\tconst uint32 rowDuration = tickDuration * numTicks;\n\t\tmemory.elapsedTime += static_cast<double>(rowDuration) \/ static_cast<double>(m_MixerSettings.gdwMixingFreq);\n\t\tplayState.m_lTotalSampleCount += rowDuration;\n\n\t\tif(adjustSamplePos)\n\t\t{\n\t\t\tpChn = playState.Chn;\n\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); pChn++, nChn++)\n\t\t\t{\n\t\t\t\tif(memory.chnSettings[nChn].ticksToRender == GetLengthMemory::IGNORE_CHANNEL)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tuint32 startTick = 0;\n\t\t\t\tconst ModCommand &m = pChn->rowCommand;\n\t\t\t\tuint32 paramHi = m.param >> 4, paramLo = m.param & 0x0F;\n\t\t\t\tbool porta = m.command == CMD_TONEPORTAMENTO || m.command == CMD_TONEPORTAVOL || m.volcmd == VOLCMD_TONEPORTAMENTO;\n\t\t\t\tbool stopNote = patternLoopStartedOnThisRow;\t\/\/ It's too much trouble to keep those pattern loops in sync...\n\n\t\t\t\tif(m.instr) pChn->proTrackerOffset = 0;\n\t\t\t\tif(m.IsNote())\n\t\t\t\t{\n\t\t\t\t\tif(porta && memory.chnSettings[nChn].incChanged)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->increment = GetChannelIncrement(pChn, pChn->nPeriod, 0);\n\t\t\t\t\t}\n\t\t\t\t\tint32 setPan = pChn->nPan;\n\t\t\t\t\tpChn->nNewNote = pChn->nLastNote;\n\t\t\t\t\tif(pChn->nNewIns != 0) InstrumentChange(pChn, pChn->nNewIns, porta);\n\t\t\t\t\tNoteChange(pChn, m.note, porta);\n\t\t\t\t\tmemory.chnSettings[nChn].incChanged = true;\n\n\t\t\t\t\tif((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && (m.param & 0xF0) == 0xD0 && paramLo < numTicks)\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick = paramLo;\n\t\t\t\t\t} else if(m.command == CMD_DELAYCUT && paramHi < numTicks)\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick = paramHi;\n\t\t\t\t\t}\n\t\t\t\t\tif(rowDelay > 1 && startTick != 0 && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick += (playState.m_nMusicSpeed + tickDelay) * (rowDelay - 1);\n\t\t\t\t\t}\n\t\t\t\t\tif(!porta) memory.chnSettings[nChn].ticksToRender = 0;\n\n\t\t\t\t\tif(m.command == CMD_PANNING8\n\t\t\t\t\t\t|| ((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && paramHi == 0x8)\n\t\t\t\t\t\t|| m.volcmd == VOLCMD_PANNING)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->nPan = setPan;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(m.command == CMD_OFFSET)\n\t\t\t\t\t{\n\t\t\t\t\t\tbool isExtended = false;\n\t\t\t\t\t\tSmpLength offset = CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn, &isExtended);\n\t\t\t\t\t\tif(!isExtended)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toffset <<= 8;\n\t\t\t\t\t\t\tif(offset == 0) offset = pChn->oldOffset;\n\t\t\t\t\t\t\toffset += static_cast<SmpLength>(pChn->nOldHiOffset) << 16;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSampleOffset(*pChn, offset);\n\t\t\t\t\t} else if(m.command == CMD_OFFSETPERCENTAGE)\n\t\t\t\t\t{\n\t\t\t\t\t\tSampleOffset(*pChn, Util::muldiv_unsigned(pChn->nLength, m.param, 255));\n\t\t\t\t\t} else if(m.command == CMD_REVERSEOFFSET && pChn->pModSample != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t\/\/ Re-sync what we've got so far\n\t\t\t\t\t\tReverseSampleOffset(*pChn, m.param);\n\t\t\t\t\t\tstartTick = playState.m_nMusicSpeed - 1;\n\t\t\t\t\t} else if(m.volcmd == VOLCMD_OFFSET)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(m.vol <= CountOf(pChn->pModSample->cues) && pChn->pModSample != nullptr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSmpLength offset;\n\t\t\t\t\t\t\tif(m.vol == 0)\n\t\t\t\t\t\t\t\toffset = pChn->oldOffset;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\toffset = pChn->oldOffset = pChn->pModSample->cues[m.vol - 1];\n\t\t\t\t\t\t\tSampleOffset(*pChn, offset);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(m.note == NOTE_KEYOFF || m.note == NOTE_NOTECUT || (m.note == NOTE_FADE && GetNumInstruments())\n\t\t\t\t\t|| ((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && (m.param & 0xF0) == 0xC0 && paramLo < numTicks)\n\t\t\t\t\t|| (m.command == CMD_DELAYCUT && paramLo != 0 && startTick + paramLo < numTicks))\n\t\t\t\t{\n\t\t\t\t\tstopNote = true;\n\t\t\t\t}\n\n\t\t\t\tif(m.command == CMD_VOLUME)\n\t\t\t\t{\n\t\t\t\t\tpChn->nVolume = m.param * 4;\n\t\t\t\t} else if(m.volcmd == VOLCMD_VOLUME)\n\t\t\t\t{\n\t\t\t\t\tpChn->nVolume = m.vol * 4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(pChn->pModSample && !stopNote)\n\t\t\t\t{\n\t\t\t\t\tif(m.command < MAX_EFFECTS)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(forbiddenCommands[m.command])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t\t} else if(m.command == CMD_MODCMDEX)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tswitch(m.param & 0xF0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0x10:\n\t\t\t\t\t\t\tcase 0x20:\n\t\t\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif(m.volcmd < forbiddenVolCommands.size() && forbiddenVolCommands[m.volcmd])\n\t\t\t\t\t{\n\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(stopNote)\n\t\t\t\t{\n\t\t\t\t\tpChn->Stop();\n\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender = 0;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif(oldTickDuration != tickDuration && oldTickDuration != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t\/\/ Re-sync what we've got so far\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch(m.command)\n\t\t\t\t\t{\n\t\t\t\t\tcase CMD_TONEPORTAVOL:\n\t\t\t\t\tcase CMD_VOLUMESLIDE:\n\t\t\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\t\t\tif(m.param || (GetType() != MOD_TYPE_MOD))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor(uint32 i = 0; i < numTicks; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->isFirstTick = (i == 0);\n\t\t\t\t\t\t\t\tVolumeSlide(pChn, m.param);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase CMD_MODCMDEX:\n\t\t\t\t\t\tif((m.param & 0x0F) || (GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpChn->isFirstTick = true;\n\t\t\t\t\t\t\tswitch(m.param & 0xF0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0xA0: FineVolumeUp(pChn, m.param & 0x0F, false); break;\n\t\t\t\t\t\t\tcase 0xB0: FineVolumeDown(pChn, m.param & 0x0F, false); break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\t\t\tif(m.param == 0x9E)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t\/\/ Re-sync what we've got so far\n\t\t\t\t\t\t\tpChn->dwFlags.reset(CHN_PINGPONGFLAG);\n\t\t\t\t\t\t} else if(m.param == 0x9F)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t\/\/ Re-sync what we've got so far\n\t\t\t\t\t\t\tpChn->dwFlags.set(CHN_PINGPONGFLAG);\n\t\t\t\t\t\t\tif(!pChn->position.GetInt() && pChn->nLength && (m.IsNote() || !pChn->dwFlags[CHN_LOOP]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->position.Set(pChn->nLength - 1, SamplePosition::fractMax);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if((m.param & 0xF0) == 0x70)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tpChn->isFirstTick = true;\n\t\t\t\t\tswitch(m.volcmd)\n\t\t\t\t\t{\n\t\t\t\t\tcase VOLCMD_FINEVOLUP:\t\tFineVolumeUp(pChn, m.vol, m_playBehaviour[kITVolColMemory]); break;\n\t\t\t\t\tcase VOLCMD_FINEVOLDOWN:\tFineVolumeDown(pChn, m.vol, m_playBehaviour[kITVolColMemory]); break;\n\t\t\t\t\tcase VOLCMD_VOLSLIDEUP:\n\t\t\t\t\tcase VOLCMD_VOLSLIDEDOWN:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tModCommand::VOL vol = m.vol;\n\t\t\t\t\t\t\tif(vol == 0 && m_playBehaviour[kITVolColMemory])\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvol = pChn->nOldVolParam;\n\t\t\t\t\t\t\t\tif(vol == 0)\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(m.volcmd == VOLCMD_VOLSLIDEUP)\n\t\t\t\t\t\t\t\tvol <<= 4;\n\t\t\t\t\t\t\tfor(uint32 i = 0; i < numTicks; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->isFirstTick = (i == 0);\n\t\t\t\t\t\t\t\tVolumeSlide(pChn, vol);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(porta)\n\t\t\t\t\t{\n\t\t\t\t\t\tuint32 portaTick = memory.chnSettings[nChn].ticksToRender + startTick + 1;\n\t\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender += numTicks;\n\t\t\t\t\t\tmemory.RenderChannel(nChn, tickDuration, portaTick);\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender += (numTicks - startTick);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\toldTickDuration = tickDuration;\n\n\t\tif(patternLoopEndedOnThisRow\n\t\t\t&& (!m_playBehaviour[kFT2PatternLoopWithJumps] || !(positionJumpOnThisRow || patternBreakOnThisRow))\n\t\t\t&& (!m_playBehaviour[kITPatternLoopWithJumps] || !positionJumpOnThisRow))\n\t\t{\n\t\t\tstd::map<double, int> startTimes;\n\t\t\tpChn = playState.Chn;\n\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n\t\t\t{\n\t\t\t\tModCommand::COMMAND command = pChn->rowCommand.command;\n\t\t\t\tModCommand::PARAM param = pChn->rowCommand.param;\n\t\t\t\tif((command == CMD_S3MCMDEX && param >= 0xB1 && param <= 0xBF)\n\t\t\t\t\t|| (command == CMD_MODCMDEX && param >= 0x61 && param <= 0x6F))\n\t\t\t\t{\n\t\t\t\t\tconst double start = memory.chnSettings[nChn].patLoop;\n\t\t\t\t\tif(!startTimes[start]) startTimes[start] = 1;\n\t\t\t\t\tstartTimes[start] = mpt::lcm(startTimes[start], 1 + (param & 0x0F));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(const auto &i : startTimes)\n\t\t\t{\n\t\t\t\tmemory.elapsedTime += (memory.elapsedTime - i.first) * (double)(i.second - 1);\n\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n\t\t\t\t{\n\t\t\t\t\tif(memory.chnSettings[nChn].patLoop == i.first)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.m_lTotalSampleCount += (playState.m_lTotalSampleCount - memory.chnSettings[nChn].patLoopSmp) * (i.second - 1);\n\t\t\t\t\t\tif(m_playBehaviour[kITPatternLoopTargetReset] || (GetType() == MOD_TYPE_S3M))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopStart = playState.m_nRow + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n \t\t\tif(GetType() == MOD_TYPE_IT)\n \t\t\t{\n\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)\n \t\t\t\t{\n \t\t\t\t\tif((pChn->rowCommand.command == CMD_S3MCMDEX && pChn->rowCommand.param >= 0xB1 && pChn->rowCommand.param <= 0xBF))\n \t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(adjustSamplePos)\n\t{\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)\n\t\t{\n\t\t\tif(memory.chnSettings[nChn].ticksToRender != GetLengthMemory::IGNORE_CHANNEL)\n\t\t\t{\n\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\n\t\t\t}\n\t\t}\n\t}\n\n\tif(retval.targetReached || target.mode == GetLengthTarget::NoTarget)\n\t{\n\t\tretval.lastOrder = playState.m_nCurrentOrder;\n\t\tretval.lastRow = playState.m_nRow;\n\t}\n\tretval.duration = memory.elapsedTime;\n\tresults.push_back(retval);\n\n\tif(adjustMode & eAdjust)\n\t{\n\t\tif(retval.targetReached || target.mode == GetLengthTarget::NoTarget)\n\t\t{\n\t\t\tm_PlayState = std::move(playState);\n\t\t\tm_PlayState.m_nNextRow = m_PlayState.m_nRow;\n\t\t\tm_PlayState.m_nFrameDelay = m_PlayState.m_nPatternDelay = 0;\n\t\t\tm_PlayState.m_nTickCount = Util::MaxValueOfType(m_PlayState.m_nTickCount) - 1;\n\t\t\tm_PlayState.m_bPositionChanged = true;\n\t\t\tfor(CHANNELINDEX n = 0; n < GetNumChannels(); n++)\n\t\t\t{\n\t\t\t\tif(m_PlayState.Chn[n].nLastNote != NOTE_NONE)\n\t\t\t\t{\n\t\t\t\t\tm_PlayState.Chn[n].nNewNote = m_PlayState.Chn[n].nLastNote;\n\t\t\t\t}\n\t\t\t\tif(memory.chnSettings[n].vol != 0xFF && !adjustSamplePos)\n\t\t\t\t{\n\t\t\t\t\tm_PlayState.Chn[n].nVolume = std::min(memory.chnSettings[n].vol, uint8(64)) * 4;\n\t\t\t\t}\n\t\t\t}\n\n#ifndef NO_PLUGINS\n\t\t\tstd::bitset<MAX_MIXPLUGINS> plugSetProgram;\n\t\t\tfor(const auto ¶m : memory.plugParams)\n\t\t\t{\n\t\t\t\tPLUGINDEX plug = param.first.first - 1;\n\t\t\t\tIMixPlugin *plugin = m_MixPlugins[plug].pMixPlugin;\n\t\t\t\tif(plugin != nullptr)\n\t\t\t\t{\n\t\t\t\t\tif(!plugSetProgram[plug])\n\t\t\t\t\t{\n\t\t\t\t\t\tplugSetProgram.set(plug);\n\t\t\t\t\t\tplugin->BeginSetProgram();\n\t\t\t\t\t}\n\t\t\t\t\tplugin->SetParameter(param.first.second, param.second \/ PlugParamValue(ModCommand::maxColumnValue));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(plugSetProgram.any())\n\t\t\t{\n\t\t\t\tfor(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)\n\t\t\t\t{\n\t\t\t\t\tif(plugSetProgram[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tm_MixPlugins[i].pMixPlugin->EndSetProgram();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n#endif \/\/ NO_PLUGINS\n\t\t} else if(adjustMode != eAdjustOnSuccess)\n\t\t{\n\t\t\tm_PlayState.m_nMusicSpeed = m_nDefaultSpeed;\n\t\t\tm_PlayState.m_nMusicTempo = m_nDefaultTempo;\n\t\t\tm_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume;\n\t\t}\n\t\tif(sequence != Order.GetCurrentSequenceIndex())\n\t\t{\n\t\t\tOrder.SetSequence(sequence);\n\t\t}\n\t\tvisitedSongRows.Set(visitedRows);\n\t}\n\n\treturn results;\n\n}\n","target":1,"code_token_length":9636,"total_token_length":9872,"max_tokens_setting":11000}
+{"idx":252220,"func":"static int DecodeIPV6FragTest01 (void)\n{\n\n    uint8_t raw_frag1[] = {\n        0x60, 0x0f, 0x1a, 0xcf, 0x05, 0xa8, 0x2c, 0x36, 0x20, 0x01, 0x04, 0x70, 0x00, 0x01, 0x00, 0x18,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x01, 0x09, 0x80, 0x32, 0xb2, 0x00, 0x01,\n        0x2e, 0x41, 0x38, 0xff, 0xfe, 0xa7, 0xea, 0xeb, 0x06, 0x00, 0x00, 0x01, 0xdf, 0xf8, 0x11, 0xd7,\n        0x00, 0x50, 0xa6, 0x5c, 0xcc, 0xd7, 0x28, 0x9f, 0xc3, 0x34, 0xc6, 0x58, 0x80, 0x10, 0x20, 0x13,\n        0x18, 0x1f, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xcd, 0xf9, 0x3a, 0x41, 0x00, 0x1a, 0x91, 0x8a,\n        0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d,\n        0x0a, 0x44, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x30, 0x32, 0x20, 0x44,\n        0x65, 0x63, 0x20, 0x32, 0x30, 0x31, 0x31, 0x20, 0x30, 0x38, 0x3a, 0x33, 0x32, 0x3a, 0x35, 0x37,\n        0x20, 0x47, 0x4d, 0x54, 0x0d, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x41, 0x70,\n        0x61, 0x63, 0x68, 0x65, 0x0d, 0x0a, 0x43, 0x61, 0x63, 0x68, 0x65, 0x2d, 0x43, 0x6f, 0x6e, 0x74,\n        0x72, 0x6f, 0x6c, 0x3a, 0x20, 0x6e, 0x6f, 0x2d, 0x63, 0x61, 0x63, 0x68, 0x65, 0x0d, 0x0a, 0x50,\n        0x72, 0x61, 0x67, 0x6d, 0x61, 0x3a, 0x20, 0x6e, 0x6f, 0x2d, 0x63, 0x61, 0x63, 0x68, 0x65, 0x0d,\n        0x0a, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x3a, 0x20, 0x54, 0x68, 0x75, 0x2c, 0x20, 0x30,\n        0x31, 0x20, 0x4a, 0x61, 0x6e, 0x20, 0x31, 0x39, 0x37, 0x31, 0x20, 0x30, 0x30, 0x3a, 0x30, 0x30,\n        0x3a, 0x30, 0x30, 0x20, 0x47, 0x4d, 0x54, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,\n        0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3a, 0x20, 0x31, 0x35, 0x39, 0x39, 0x0d, 0x0a, 0x4b,\n        0x65, 0x65, 0x70, 0x2d, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x3a, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x6f,\n        0x75, 0x74, 0x3d, 0x35, 0x2c, 0x20, 0x6d, 0x61, 0x78, 0x3d, 0x39, 0x39, 0x0d, 0x0a, 0x43, 0x6f,\n        0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x4b, 0x65, 0x65, 0x70, 0x2d, 0x41,\n        0x6c, 0x69, 0x76, 0x65, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79,\n        0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f,\n        0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3b, 0x63, 0x68, 0x61, 0x72, 0x73,\n        0x65, 0x74, 0x3d, 0x61, 0x73, 0x63, 0x69, 0x69, 0x0d, 0x0a, 0x0d, 0x0a, 0x5f, 0x6a, 0x71, 0x6a,\n        0x73, 0x70, 0x28, 0x7b, 0x22, 0x69, 0x70, 0x22, 0x3a, 0x22, 0x32, 0x30, 0x30, 0x31, 0x3a, 0x39,\n        0x38, 0x30, 0x3a, 0x33, 0x32, 0x62, 0x32, 0x3a, 0x31, 0x3a, 0x32, 0x65, 0x34, 0x31, 0x3a, 0x33,\n        0x38, 0x66, 0x66, 0x3a, 0x66, 0x65, 0x61, 0x37, 0x3a, 0x65, 0x61, 0x65, 0x62, 0x22, 0x2c, 0x22,\n        0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x69, 0x70, 0x76, 0x36, 0x22, 0x2c, 0x22, 0x73, 0x75,\n        0x62, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x76, 0x69, 0x61, 0x22, 0x3a,\n        0x22, 0x22, 0x2c, 0x22, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x22, 0x3a, 0x22, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n    };\n    uint8_t raw_frag2[] = {\n        0x60, 0x0f, 0x1a, 0xcf, 0x00, 0x1c, 0x2c, 0x36, 0x20, 0x01, 0x04, 0x70, 0x00, 0x01, 0x00, 0x18,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x01, 0x09, 0x80, 0x32, 0xb2, 0x00, 0x01,\n        0x2e, 0x41, 0x38, 0xff, 0xfe, 0xa7, 0xea, 0xeb, 0x06, 0x00, 0x05, 0xa0, 0xdf, 0xf8, 0x11, 0xd7,\n        0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\n        0x20, 0x20, 0x20, 0x20,\n    };\n    Packet *pkt;\n    Packet *p1 = PacketGetFromAlloc();\n    if (unlikely(p1 == NULL))\n        return 0;\n    Packet *p2 = PacketGetFromAlloc();\n    if (unlikely(p2 == NULL)) {\n        SCFree(p1);\n        return 0;\n    }\n    ThreadVars tv;\n    DecodeThreadVars dtv;\n    int result = 0;\n    PacketQueue pq;\n\n    FlowInitConfig(FLOW_QUIET);\n    DefragInit();\n\n    memset(&pq, 0, sizeof(PacketQueue));\n    memset(&tv, 0, sizeof(ThreadVars));\n    memset(&dtv, 0, sizeof(DecodeThreadVars));\n\n    PacketCopyData(p1, raw_frag1, sizeof(raw_frag1));\n    PacketCopyData(p2, raw_frag2, sizeof(raw_frag2));\n\n    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);\n\n    if (!(IPV6_EXTHDR_ISSET_FH(p1))) {\n        printf(\"ipv6 frag header not detected: \");\n        goto end;\n    }\n\n    DecodeIPV6(&tv, &dtv, p2, GET_PKT_DATA(p2), GET_PKT_LEN(p2), &pq);\n\n    if (!(IPV6_EXTHDR_ISSET_FH(p2))) {\n        printf(\"ipv6 frag header not detected: \");\n        goto end;\n    }\n\n    if (pq.len != 1) {\n        printf(\"no reassembled packet: \");\n        goto end;\n    }\n\n    result = 1;\nend:\n    PACKET_RECYCLE(p1);\n    PACKET_RECYCLE(p2);\n    SCFree(p1);\n    SCFree(p2);\n    pkt = PacketDequeue(&pq);\n    while (pkt != NULL) {\n        PACKET_RECYCLE(pkt);\n        SCFree(pkt);\n        pkt = PacketDequeue(&pq);\n    }\n    DefragDestroy();\n    FlowShutdown();\n    return result;\n}\n","target":0,"code_token_length":9848,"total_token_length":10084,"max_tokens_setting":11000}
+{"idx":347705,"func":"static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  BMPInfo\n    bmp_info;\n\n  Image\n    *image;\n\n  IndexPacket\n    index;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    start_position;\n\n  MemoryInfo\n    *pixel_info;\n\n  register IndexPacket\n    *indexes;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *p;\n\n  size_t\n    bit,\n    bytes_per_line,\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    magick[12],\n    *pixels;\n\n  unsigned int\n    blue,\n    green,\n    offset_bits,\n    red;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Determine if this a BMP file.\n  *\/\n  (void) memset(&bmp_info,0,sizeof(bmp_info));\n  bmp_info.ba_offset=0;\n  start_position=0;\n  offset_bits=0;\n  count=ReadBlob(image,2,magick);\n  if (count != 2)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  do\n  {\n    LongPixelPacket\n      shift;\n\n    PixelPacket\n      quantum_bits;\n\n    \/*\n      Verify BMP identifier.\n    *\/\n    if (bmp_info.ba_offset == 0)\n      start_position=TellBlob(image)-2;\n    bmp_info.ba_offset=0;\n    while (LocaleNCompare((char *) magick,\"BA\",2) == 0)\n    {\n      bmp_info.file_size=ReadBlobLSBLong(image);\n      bmp_info.ba_offset=ReadBlobLSBLong(image);\n      bmp_info.offset_bits=ReadBlobLSBLong(image);\n      count=ReadBlob(image,2,magick);\n      if (count != 2)\n        break;\n    }\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  Magick: %c%c\",\n        magick[0],magick[1]);\n    if ((count != 2) || ((LocaleNCompare((char *) magick,\"BM\",2) != 0) &&\n        (LocaleNCompare((char *) magick,\"CI\",2) != 0)))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    bmp_info.file_size=ReadBlobLSBLong(image);\n    (void) ReadBlobLSBLong(image);\n\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n         \"  File_size in header:  %u bytes\",bmp_info.file_size);\n\n    bmp_info.offset_bits=ReadBlobLSBLong(image);\n    bmp_info.size=ReadBlobLSBLong(image);\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  BMP size: %u\",\n        bmp_info.size);\n    if (bmp_info.size == 12)\n      {\n        \/*\n          OS\/2 BMP image file.\n        *\/\n        (void) CopyMagickString(image->magick,\"BMP2\",MaxTextExtent);\n        bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.x_pixels=0;\n        bmp_info.y_pixels=0;\n        bmp_info.number_colors=0;\n        bmp_info.compression=BI_RGB;\n        bmp_info.image_size=0;\n        bmp_info.alpha_mask=0;\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: OS\/2 Bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n          }\n      }\n    else\n      {\n        \/*\n          Microsoft Windows BMP image file.\n        *\/\n        if (bmp_info.size < 40)\n          ThrowReaderException(CorruptImageError,\"NonOS2HeaderSizeError\");\n        bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.compression=ReadBlobLSBLong(image);\n        bmp_info.image_size=ReadBlobLSBLong(image);\n        bmp_info.x_pixels=ReadBlobLSBLong(image);\n        bmp_info.y_pixels=ReadBlobLSBLong(image);\n        bmp_info.number_colors=ReadBlobLSBLong(image);\n        bmp_info.colors_important=ReadBlobLSBLong(image);\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: MS Windows bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Bits per pixel: %.20g\",(double) bmp_info.bits_per_pixel);\n            switch (bmp_info.compression)\n            {\n              case BI_RGB:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RGB\");\n                break;\n              }\n              case BI_RLE4:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE4\");\n                break;\n              }\n              case BI_RLE8:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE8\");\n                break;\n              }\n              case BI_BITFIELDS:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_BITFIELDS\");\n                break;\n              }\n              case BI_PNG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_PNG\");\n                break;\n              }\n              case BI_JPEG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_JPEG\");\n                break;\n              }\n              default:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: UNKNOWN (%u)\",bmp_info.compression);\n              }\n            }\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Number of colors: %u\",bmp_info.number_colors);\n          }\n        bmp_info.red_mask=ReadBlobLSBLong(image);\n        bmp_info.green_mask=ReadBlobLSBLong(image);\n        bmp_info.blue_mask=ReadBlobLSBLong(image);\n        if (bmp_info.size > 40)\n          {\n            double\n              gamma;\n\n            \/*\n              Read color management information.\n            *\/\n            bmp_info.alpha_mask=ReadBlobLSBLong(image);\n            bmp_info.colorspace=ReadBlobLSBSignedLong(image);\n            \/*\n              Decode 2^30 fixed point formatted CIE primaries.\n            *\/\n#           define BMP_DENOM ((double) 0x40000000)\n            bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n\n            gamma=bmp_info.red_primary.x+bmp_info.red_primary.y+\n              bmp_info.red_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.red_primary.x*=gamma;\n            bmp_info.red_primary.y*=gamma;\n            image->chromaticity.red_primary.x=bmp_info.red_primary.x;\n            image->chromaticity.red_primary.y=bmp_info.red_primary.y;\n\n            gamma=bmp_info.green_primary.x+bmp_info.green_primary.y+\n              bmp_info.green_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.green_primary.x*=gamma;\n            bmp_info.green_primary.y*=gamma;\n            image->chromaticity.green_primary.x=bmp_info.green_primary.x;\n            image->chromaticity.green_primary.y=bmp_info.green_primary.y;\n\n            gamma=bmp_info.blue_primary.x+bmp_info.blue_primary.y+\n              bmp_info.blue_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.blue_primary.x*=gamma;\n            bmp_info.blue_primary.y*=gamma;\n            image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;\n            image->chromaticity.blue_primary.y=bmp_info.blue_primary.y;\n\n            \/*\n              Decode 16^16 fixed point formatted gamma_scales.\n            *\/\n            bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)\/0x10000;\n            \/*\n              Compute a single gamma from the BMP 3-channel gamma.\n            *\/\n            image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+\n              bmp_info.gamma_scale.z)\/3.0;\n          }\n        else\n          (void) CopyMagickString(image->magick,\"BMP3\",MaxTextExtent);\n\n        if (bmp_info.size > 108)\n          {\n            size_t\n              intent;\n\n            \/*\n              Read BMP Version 5 color management information.\n            *\/\n            intent=ReadBlobLSBLong(image);\n            switch ((int) intent)\n            {\n              case LCS_GM_BUSINESS:\n              {\n                image->rendering_intent=SaturationIntent;\n                break;\n              }\n              case LCS_GM_GRAPHICS:\n              {\n                image->rendering_intent=RelativeIntent;\n                break;\n              }\n              case LCS_GM_IMAGES:\n              {\n                image->rendering_intent=PerceptualIntent;\n                break;\n              }\n              case LCS_GM_ABS_COLORIMETRIC:\n              {\n                image->rendering_intent=AbsoluteIntent;\n                break;\n              }\n            }\n            (void) ReadBlobLSBLong(image);  \/* Profile data *\/\n            (void) ReadBlobLSBLong(image);  \/* Profile size *\/\n            (void) ReadBlobLSBLong(image);  \/* Reserved byte *\/\n          }\n      }\n    if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))\n      (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,\n        \"LengthAndFilesizeDoNotMatch\",\"`%s'\",image->filename);\n    else\n      if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          CorruptImageWarning,\"LengthAndFilesizeDoNotMatch\",\"`%s'\",\n          image->filename);\n    if (bmp_info.width <= 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.height == 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.planes != 1)\n      ThrowReaderException(CorruptImageError,\"StaticPlanesValueNotEqualToOne\");\n    if ((bmp_info.bits_per_pixel != 1) && (bmp_info.bits_per_pixel != 4) &&\n        (bmp_info.bits_per_pixel != 8) && (bmp_info.bits_per_pixel != 16) &&\n        (bmp_info.bits_per_pixel != 24) && (bmp_info.bits_per_pixel != 32))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if (bmp_info.bits_per_pixel < 16 &&\n        bmp_info.number_colors > (1U << bmp_info.bits_per_pixel))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedNumberOfColors\");\n    if ((bmp_info.compression == 1) && (bmp_info.bits_per_pixel != 8))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 2) && (bmp_info.bits_per_pixel != 4))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 3) && (bmp_info.bits_per_pixel < 16))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    switch (bmp_info.compression)\n    {\n      case BI_RGB:\n        image->compression=NoCompression;\n        break;\n      case BI_RLE8:\n      case BI_RLE4:\n        image->compression=RLECompression;\n        break;\n      case BI_BITFIELDS:\n        break;\n      case BI_JPEG:\n        ThrowReaderException(CoderError,\"JPEGCompressNotSupported\");\n      case BI_PNG:\n        ThrowReaderException(CoderError,\"PNGCompressNotSupported\");\n      default:\n        ThrowReaderException(CorruptImageError,\"UnrecognizedImageCompression\");\n    }\n    image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);\n    image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);\n    image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;\n    image->matte=((bmp_info.alpha_mask != 0) &&\n      (bmp_info.compression == BI_BITFIELDS)) ? MagickTrue : MagickFalse;\n    if (bmp_info.bits_per_pixel < 16)\n      {\n        size_t\n          one;\n\n        image->storage_class=PseudoClass;\n        image->colors=bmp_info.number_colors;\n        one=1;\n        if (image->colors == 0)\n          image->colors=one << bmp_info.bits_per_pixel;\n      }\n    image->x_resolution=(double) bmp_info.x_pixels\/100.0;\n    image->y_resolution=(double) bmp_info.y_pixels\/100.0;\n    image->units=PixelsPerCentimeterResolution;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    if (image->storage_class == PseudoClass)\n      {\n        unsigned char\n          *bmp_colormap;\n\n        size_t\n          packet_size;\n\n        \/*\n          Read BMP raster colormap.\n        *\/\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading colormap of %.20g colors\",(double) image->colors);\n        if (AcquireImageColormap(image,image->colors) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        bmp_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n          image->colors,4*sizeof(*bmp_colormap));\n        if (bmp_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        if ((bmp_info.size == 12) || (bmp_info.size == 64))\n          packet_size=3;\n        else\n          packet_size=4;\n        offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET);\n        if (offset < 0)\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n          }\n        count=ReadBlob(image,packet_size*image->colors,bmp_colormap);\n        if (count != (ssize_t) (packet_size*image->colors))\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n        p=bmp_colormap;\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].blue=ScaleCharToQuantum(*p++);\n          image->colormap[i].green=ScaleCharToQuantum(*p++);\n          image->colormap[i].red=ScaleCharToQuantum(*p++);\n          if (packet_size == 4)\n            p++;\n        }\n        bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n      }\n    \/*\n      Read image data.\n    *\/\n    if (bmp_info.offset_bits == offset_bits)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    offset_bits=bmp_info.offset_bits;\n    offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET);\n    if (offset < 0)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if (bmp_info.compression == BI_RLE4)\n      bmp_info.bits_per_pixel<<=1;\n    bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)\/32);\n    length=(size_t) bytes_per_line*image->rows;\n    if (((MagickSizeType) length\/8) > GetBlobSize(image))\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    if ((bmp_info.compression == BI_RGB) ||\n        (bmp_info.compression == BI_BITFIELDS))\n      {\n        pixel_info=AcquireVirtualMemory((size_t) image->rows,\n          MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading pixels (%.20g bytes)\",(double) length);\n        count=ReadBlob(image,length,pixels);\n        if (count != (ssize_t) length)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n      }\n    else\n      {\n        \/*\n          Convert run-length encoded raster pixels.\n        *\/\n        pixel_info=AcquireVirtualMemory((size_t) image->rows,\n          MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        status=DecodeImage(image,bmp_info.compression,pixels,\n          image->columns*image->rows);\n        if (status == MagickFalse)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnableToRunlengthDecodeImage\");\n          }\n      }\n    \/*\n      Convert BMP raster image to pixel packets.\n    *\/\n    if (bmp_info.compression == BI_RGB)\n      {\n        \/*\n          We should ignore the alpha value in BMP3 files but there have been\n          reports about 32 bit files with alpha. We do a quick check to see if\n          the alpha channel contains a value that is not zero (default value).\n          If we find a non zero value we asume the program that wrote the file\n          wants to use the alpha channel.\n        *\/\n        if ((image->matte == MagickFalse) && (bmp_info.size == 40) &&\n            (bmp_info.bits_per_pixel == 32))\n          {\n            bytes_per_line=4*(image->columns);\n            for (y=(ssize_t) image->rows-1; y >= 0; y--)\n            {\n              p=pixels+(image->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                if (*(p+3) != 0)\n                  {\n                    image->matte=MagickTrue;\n                    y=-1;\n                    break;\n                  }\n                p+=4;\n              }\n            }\n          }\n        bmp_info.alpha_mask=image->matte != MagickFalse ? 0xff000000U : 0U;\n        bmp_info.red_mask=0x00ff0000U;\n        bmp_info.green_mask=0x0000ff00U;\n        bmp_info.blue_mask=0x000000ffU;\n        if (bmp_info.bits_per_pixel == 16)\n          {\n            \/*\n              RGB555.\n            *\/\n            bmp_info.red_mask=0x00007c00U;\n            bmp_info.green_mask=0x000003e0U;\n            bmp_info.blue_mask=0x0000001fU;\n          }\n      }\n    (void) memset(&shift,0,sizeof(shift));\n    (void) memset(&quantum_bits,0,sizeof(quantum_bits));\n    if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))\n      {\n        register size_t\n          sample;\n\n        \/*\n          Get shift and quantum bits info from bitfield masks.\n        *\/\n        if (bmp_info.red_mask != 0)\n          while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)\n          {\n            shift.red++;\n            if (shift.red > 32U)\n              break;\n          }\n        if (bmp_info.green_mask != 0)\n          while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)\n          {\n            shift.green++;\n            if (shift.green > 32U)\n              break;\n          }\n        if (bmp_info.blue_mask != 0)\n          while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)\n          {\n            shift.blue++;\n            if (shift.blue > 32U)\n              break;\n          }\n        if (bmp_info.alpha_mask != 0)\n          while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)\n          {\n            shift.opacity++;\n            if (shift.opacity > 32U)\n              break;\n          }\n        sample=shift.red;\n        while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.red=ClampToQuantum((MagickRealType) sample-shift.red);\n        sample=shift.green;\n        while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.green=ClampToQuantum((MagickRealType) sample-shift.green);\n        sample=shift.blue;\n        while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.blue=ClampToQuantum((MagickRealType) sample-shift.blue);\n        sample=shift.opacity;\n        while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.opacity=ClampToQuantum((MagickRealType) sample-\n          shift.opacity);\n      }\n    switch (bmp_info.bits_per_pixel)\n    {\n      case 1:\n      {\n        \/*\n          Convert bitmap scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n          {\n            for (bit=0; bit < 8; bit++)\n            {\n              index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n              SetPixelIndex(indexes+x+bit,index);\n              q++;\n            }\n            p++;\n          }\n          if ((image->columns % 8) != 0)\n            {\n              for (bit=0; bit < (image->columns % 8); bit++)\n              {\n                index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n                SetPixelIndex(indexes+x+bit,index);\n              }\n              p++;\n            }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 4:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-1); x+=2)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0x0f),\n              &index,exception);\n            SetPixelIndex(indexes+x,index);\n            (void) IsValidColormapIndex(image,(ssize_t) (*p & 0x0f),&index,\n              exception);\n            SetPixelIndex(indexes+x+1,index);\n            p++;\n          }\n          if ((image->columns % 2) != 0)\n            {\n              (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0xf),\n                &index,exception);\n              SetPixelIndex(indexes+(x++),index);\n              p++;\n            }\n          if (x < (ssize_t) image->columns)\n            break;\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 8:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        if ((bmp_info.compression == BI_RLE8) ||\n            (bmp_info.compression == BI_RLE4))\n          bytes_per_line=image->columns;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=(ssize_t) image->columns; x != 0; --x)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) *p,&index,exception);\n            SetPixelIndex(indexes,index);\n            indexes++;\n            p++;\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 16:\n      {\n        unsigned int\n          alpha,\n          pixel;\n\n        \/*\n          Convert bitfield encoded 16-bit PseudoColor scanline.\n        *\/\n        if (bmp_info.compression != BI_RGB &&\n            bmp_info.compression != BI_BITFIELDS)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=2*(image->columns+image->columns % 2);\n        image->storage_class=DirectClass;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=(*p++) << 8;\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 5)\n              red|=((red & 0xe000) >> 5);\n            if (quantum_bits.red <= 8)\n              red|=((red & 0xff00) >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 5)\n              green|=((green & 0xe000) >> 5);\n            if (quantum_bits.green == 6)\n              green|=((green & 0xc000) >> 6);\n            if (quantum_bits.green <= 8)\n              green|=((green & 0xff00) >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 5)\n              blue|=((blue & 0xe000) >> 5);\n            if (quantum_bits.blue <= 8)\n              blue|=((blue & 0xff00) >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelOpacity(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity <= 8)\n                  alpha|=((alpha & 0xff00) >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 24:\n      {\n        \/*\n          Convert DirectColor scanline.\n        *\/\n        bytes_per_line=4*((image->columns*24+31)\/32);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelBlue(q,ScaleCharToQuantum(*p++));\n            SetPixelGreen(q,ScaleCharToQuantum(*p++));\n            SetPixelRed(q,ScaleCharToQuantum(*p++));\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 32:\n      {\n        \/*\n          Convert bitfield encoded DirectColor scanline.\n        *\/\n        if ((bmp_info.compression != BI_RGB) &&\n            (bmp_info.compression != BI_BITFIELDS))\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=4*(image->columns);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          unsigned int\n            alpha,\n            pixel;\n\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=((unsigned int) *p++ << 8);\n            pixel|=((unsigned int) *p++ << 16);\n            pixel|=((unsigned int) *p++ << 24);\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 8)\n              red|=(red >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 8)\n              green|=(green >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 8)\n              blue|=(blue >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelAlpha(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity == 8)\n                  alpha|=(alpha >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      default:\n      {\n        pixel_info=RelinquishVirtualMemory(pixel_info);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (y > 0)\n      break;\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    if (bmp_info.height < 0)\n      {\n        Image\n          *flipped_image;\n\n        \/*\n          Correct image orientation.\n        *\/\n        flipped_image=FlipImage(image,exception);\n        if (flipped_image != (Image *) NULL)\n          {\n            DuplicateBlob(flipped_image,image);\n            ReplaceImageInList(&image, flipped_image);\n            image=flipped_image;\n          }\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    *magick='\\0';\n    if (bmp_info.ba_offset != 0)\n      {\n        offset=SeekBlob(image,(MagickOffsetType) bmp_info.ba_offset,SEEK_SET);\n        if (offset < 0)\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    count=ReadBlob(image,2,magick);\n    if ((count == 2) && (IsBMP(magick,2) != MagickFalse))\n      {\n        \/*\n          Acquire next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            image=DestroyImageList(image);\n            return((Image *) NULL);\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (IsBMP(magick,2) != MagickFalse);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":8624,"total_token_length":8860,"max_tokens_setting":11000}
+{"idx":128559,"func":"static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)\n{\n\tconst unsigned char *cursor, *limit, *marker, *start;\n\tzval *rval_ref;\n\n\tlimit = max;\n\tcursor = *p;\n\n\tif (YYCURSOR >= YYLIMIT) {\n\t\treturn 0;\n\t}\n\n\tif (var_hash && (*p)[0] != 'R') {\n\t\tvar_push(var_hash, rval);\n\t}\n\n\tstart = cursor;\n\n\n#line 576 \"ext\/standard\/var_unserializer.c\"\n{\n\tYYCTYPE yych;\n\tstatic const unsigned char yybm[] = {\n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t128, 128, 128, 128, 128, 128, 128, 128, \n\t\t128, 128,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t\t  0,   0,   0,   0,   0,   0,   0,   0, \n\t};\n\tif ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);\n\tyych = *YYCURSOR;\n\tswitch (yych) {\n\tcase 'C':\n\tcase 'O':\tgoto yy4;\n\tcase 'N':\tgoto yy5;\n\tcase 'R':\tgoto yy6;\n\tcase 'S':\tgoto yy7;\n\tcase 'a':\tgoto yy8;\n\tcase 'b':\tgoto yy9;\n\tcase 'd':\tgoto yy10;\n\tcase 'i':\tgoto yy11;\n\tcase 'o':\tgoto yy12;\n\tcase 'r':\tgoto yy13;\n\tcase 's':\tgoto yy14;\n\tcase '}':\tgoto yy15;\n\tdefault:\tgoto yy2;\n\t}\nyy2:\n\t++YYCURSOR;\nyy3:\n#line 951 \"ext\/standard\/var_unserializer.re\"\n\t{ return 0; }\n#line 636 \"ext\/standard\/var_unserializer.c\"\nyy4:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy17;\n\tgoto yy3;\nyy5:\n\tyych = *++YYCURSOR;\n\tif (yych == ';') goto yy19;\n\tgoto yy3;\nyy6:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy21;\n\tgoto yy3;\nyy7:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy22;\n\tgoto yy3;\nyy8:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy23;\n\tgoto yy3;\nyy9:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy24;\n\tgoto yy3;\nyy10:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy25;\n\tgoto yy3;\nyy11:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy26;\n\tgoto yy3;\nyy12:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy27;\n\tgoto yy3;\nyy13:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy28;\n\tgoto yy3;\nyy14:\n\tyych = *(YYMARKER = ++YYCURSOR);\n\tif (yych == ':') goto yy29;\n\tgoto yy3;\nyy15:\n\t++YYCURSOR;\n#line 945 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t\/* this is the case where we have less data than planned *\/\n\tphp_error_docref(NULL, E_NOTICE, \"Unexpected end of serialized data\");\n\treturn 0; \/* not sure if it should be 0 or 1 here? *\/\n}\n#line 689 \"ext\/standard\/var_unserializer.c\"\nyy17:\n\tyych = *++YYCURSOR;\n\tif (yybm[0+yych] & 128) {\n\t\tgoto yy31;\n\t}\n\tif (yych == '+') goto yy30;\nyy18:\n\tYYCURSOR = YYMARKER;\n\tgoto yy3;\nyy19:\n\t++YYCURSOR;\n#line 629 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t*p = YYCURSOR;\n\tZVAL_NULL(rval);\n\treturn 1;\n}\n#line 707 \"ext\/standard\/var_unserializer.c\"\nyy21:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy33;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy33;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy34;\n\t\tgoto yy18;\n\t}\nyy22:\n\tyych = *++YYCURSOR;\n\tif (yych == '+') goto yy36;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy37;\n\tgoto yy18;\nyy23:\n\tyych = *++YYCURSOR;\n\tif (yych == '+') goto yy39;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy40;\n\tgoto yy18;\nyy24:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '1') goto yy42;\n\tgoto yy18;\nyy25:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') {\n\t\tif (yych <= ',') {\n\t\t\tif (yych == '+') goto yy43;\n\t\t\tgoto yy18;\n\t\t} else {\n\t\t\tif (yych <= '-') goto yy44;\n\t\t\tif (yych <= '.') goto yy45;\n\t\t\tgoto yy18;\n\t\t}\n\t} else {\n\t\tif (yych <= 'I') {\n\t\t\tif (yych <= '9') goto yy46;\n\t\t\tif (yych <= 'H') goto yy18;\n\t\t\tgoto yy48;\n\t\t} else {\n\t\t\tif (yych == 'N') goto yy49;\n\t\t\tgoto yy18;\n\t\t}\n\t}\nyy26:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy50;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy50;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy51;\n\t\tgoto yy18;\n\t}\nyy27:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy53;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy53;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy54;\n\t\tgoto yy18;\n\t}\nyy28:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy56;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy56;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy57;\n\t\tgoto yy18;\n\t}\nyy29:\n\tyych = *++YYCURSOR;\n\tif (yych == '+') goto yy59;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy60;\n\tgoto yy18;\nyy30:\n\tyych = *++YYCURSOR;\n\tif (yybm[0+yych] & 128) {\n\t\tgoto yy31;\n\t}\n\tgoto yy18;\nyy31:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yybm[0+yych] & 128) {\n\t\tgoto yy31;\n\t}\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= ':') goto yy62;\n\tgoto yy18;\nyy33:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy34:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy34;\n\tif (yych == ';') goto yy63;\n\tgoto yy18;\nyy36:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy37:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy37;\n\tif (yych <= ':') goto yy65;\n\tgoto yy18;\nyy39:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy40:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy40;\n\tif (yych <= ':') goto yy66;\n\tgoto yy18;\nyy42:\n\tyych = *++YYCURSOR;\n\tif (yych == ';') goto yy67;\n\tgoto yy18;\nyy43:\n\tyych = *++YYCURSOR;\n\tif (yych == '.') goto yy45;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy46;\n\tgoto yy18;\nyy44:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') {\n\t\tif (yych != '.') goto yy18;\n\t} else {\n\t\tif (yych <= '9') goto yy46;\n\t\tif (yych == 'I') goto yy48;\n\t\tgoto yy18;\n\t}\nyy45:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy69;\n\tgoto yy18;\nyy46:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);\n\tyych = *YYCURSOR;\n\tif (yych <= ':') {\n\t\tif (yych <= '.') {\n\t\t\tif (yych <= '-') goto yy18;\n\t\t\tgoto yy69;\n\t\t} else {\n\t\t\tif (yych <= '\/') goto yy18;\n\t\t\tif (yych <= '9') goto yy46;\n\t\t\tgoto yy18;\n\t\t}\n\t} else {\n\t\tif (yych <= 'E') {\n\t\t\tif (yych <= ';') goto yy71;\n\t\t\tif (yych <= 'D') goto yy18;\n\t\t\tgoto yy73;\n\t\t} else {\n\t\t\tif (yych == 'e') goto yy73;\n\t\t\tgoto yy18;\n\t\t}\n\t}\nyy48:\n\tyych = *++YYCURSOR;\n\tif (yych == 'N') goto yy74;\n\tgoto yy18;\nyy49:\n\tyych = *++YYCURSOR;\n\tif (yych == 'A') goto yy75;\n\tgoto yy18;\nyy50:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy51:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy51;\n\tif (yych == ';') goto yy76;\n\tgoto yy18;\nyy53:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy54:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy54;\n\tif (yych <= ':') goto yy78;\n\tgoto yy18;\nyy56:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy57:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy57;\n\tif (yych == ';') goto yy79;\n\tgoto yy18;\nyy59:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych >= ':') goto yy18;\nyy60:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy60;\n\tif (yych <= ':') goto yy81;\n\tgoto yy18;\nyy62:\n\tyych = *++YYCURSOR;\n\tif (yych == '\"') goto yy82;\n\tgoto yy18;\nyy63:\n\t++YYCURSOR;\n#line 580 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long id;\n\n \t*p = YYCURSOR;\n\tif (!var_hash) return 0;\n\n\tid = parse_iv(start + 2) - 1;\n\tif (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) {\n\t\treturn 0;\n\t}\n\n\tif (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {\n\t\treturn 0;\n\t}\n\n\tif (Z_ISREF_P(rval_ref)) {\n\t\tZVAL_COPY(rval, rval_ref);\n\t} else {\n\t\tZVAL_NEW_REF(rval_ref, rval_ref);\n\t\tZVAL_COPY(rval, rval_ref);\n\t}\n\n\treturn 1;\n}\n#line 982 \"ext\/standard\/var_unserializer.c\"\nyy65:\n\tyych = *++YYCURSOR;\n\tif (yych == '\"') goto yy84;\n\tgoto yy18;\nyy66:\n\tyych = *++YYCURSOR;\n\tif (yych == '{') goto yy86;\n\tgoto yy18;\nyy67:\n\t++YYCURSOR;\n#line 635 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t*p = YYCURSOR;\n\tZVAL_BOOL(rval, parse_iv(start + 2));\n\treturn 1;\n}\n#line 999 \"ext\/standard\/var_unserializer.c\"\nyy69:\n\t++YYCURSOR;\n\tif ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);\n\tyych = *YYCURSOR;\n\tif (yych <= ';') {\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy69;\n\t\tif (yych <= ':') goto yy18;\n\t} else {\n\t\tif (yych <= 'E') {\n\t\t\tif (yych <= 'D') goto yy18;\n\t\t\tgoto yy73;\n\t\t} else {\n\t\t\tif (yych == 'e') goto yy73;\n\t\t\tgoto yy18;\n\t\t}\n\t}\nyy71:\n\t++YYCURSOR;\n#line 683 \"ext\/standard\/var_unserializer.re\"\n\t{\n#if SIZEOF_ZEND_LONG == 4\nuse_double:\n#endif\n\t*p = YYCURSOR;\n\tZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));\n\treturn 1;\n}\n#line 1028 \"ext\/standard\/var_unserializer.c\"\nyy73:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy88;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy88;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych <= '9') goto yy89;\n\t\tgoto yy18;\n\t}\nyy74:\n\tyych = *++YYCURSOR;\n\tif (yych == 'F') goto yy91;\n\tgoto yy18;\nyy75:\n\tyych = *++YYCURSOR;\n\tif (yych == 'N') goto yy91;\n\tgoto yy18;\nyy76:\n\t++YYCURSOR;\n#line 641 \"ext\/standard\/var_unserializer.re\"\n\t{\n#if SIZEOF_ZEND_LONG == 4\n\tint digits = YYCURSOR - start - 3;\n\n\tif (start[2] == '-' || start[2] == '+') {\n\t\tdigits--;\n\t}\n\n\t\/* Use double for large zend_long values that were serialized on a 64-bit system *\/\n\tif (digits >= MAX_LENGTH_OF_LONG - 1) {\n\t\tif (digits == MAX_LENGTH_OF_LONG - 1) {\n\t\t\tint cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1);\n\n\t\t\tif (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) {\n\t\t\t\tgoto use_double;\n\t\t\t}\n\t\t} else {\n\t\t\tgoto use_double;\n\t\t}\n\t}\n#endif\n\t*p = YYCURSOR;\n\tZVAL_LONG(rval, parse_iv(start + 2));\n\treturn 1;\n}\n#line 1076 \"ext\/standard\/var_unserializer.c\"\nyy78:\n\tyych = *++YYCURSOR;\n\tif (yych == '\"') goto yy92;\n\tgoto yy18;\nyy79:\n\t++YYCURSOR;\n#line 605 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long id;\n\n \t*p = YYCURSOR;\n\tif (!var_hash) return 0;\n\n\tid = parse_iv(start + 2) - 1;\n\tif (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) {\n\t\treturn 0;\n\t}\n\n\tif (rval_ref == rval) {\n\t\treturn 0;\n\t}\n\n\tif (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {\n\t\treturn 0;\n\t}\n\n\tZVAL_COPY(rval, rval_ref);\n\n\treturn 1;\n}\n#line 1107 \"ext\/standard\/var_unserializer.c\"\nyy81:\n\tyych = *++YYCURSOR;\n\tif (yych == '\"') goto yy94;\n\tgoto yy18;\nyy82:\n\t++YYCURSOR;\n#line 793 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tsize_t len, len2, len3, maxlen;\n\tzend_long elements;\n\tchar *str;\n\tzend_string *class_name;\n\tzend_class_entry *ce;\n\tint incomplete_class = 0;\n\n\tint custom_object = 0;\n\n\tzval user_func;\n\tzval retval;\n\tzval args[1];\n\n    if (!var_hash) return 0;\n\tif (*start == 'C') {\n\t\tcustom_object = 1;\n\t}\n\n\tlen2 = len = parse_uiv(start + 2);\n\tmaxlen = max - YYCURSOR;\n\tif (maxlen < len || len == 0) {\n\t\t*p = start + 2;\n\t\treturn 0;\n\t}\n\n\tstr = (char*)YYCURSOR;\n\n\tYYCURSOR += len;\n\n\tif (*(YYCURSOR) != '\"') {\n\t\t*p = YYCURSOR;\n\t\treturn 0;\n\t}\n\tif (*(YYCURSOR+1) != ':') {\n\t\t*p = YYCURSOR+1;\n\t\treturn 0;\n\t}\n\n\tlen3 = strspn(str, \"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\177\\200\\201\\202\\203\\204\\205\\206\\207\\210\\211\\212\\213\\214\\215\\216\\217\\220\\221\\222\\223\\224\\225\\226\\227\\230\\231\\232\\233\\234\\235\\236\\237\\240\\241\\242\\243\\244\\245\\246\\247\\250\\251\\252\\253\\254\\255\\256\\257\\260\\261\\262\\263\\264\\265\\266\\267\\270\\271\\272\\273\\274\\275\\276\\277\\300\\301\\302\\303\\304\\305\\306\\307\\310\\311\\312\\313\\314\\315\\316\\317\\320\\321\\322\\323\\324\\325\\326\\327\\330\\331\\332\\333\\334\\335\\336\\337\\340\\341\\342\\343\\344\\345\\346\\347\\350\\351\\352\\353\\354\\355\\356\\357\\360\\361\\362\\363\\364\\365\\366\\367\\370\\371\\372\\373\\374\\375\\376\\377\\\\\");\n\tif (len3 != len)\n\t{\n\t\t*p = YYCURSOR + len3 - len;\n\t\treturn 0;\n\t}\n\n\tclass_name = zend_string_init(str, len, 0);\n\n\tdo {\n\t\tif(!unserialize_allowed_class(class_name, classes)) {\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Try to find class directly *\/\n\t\tBG(serialize_lock)++;\n\t\tce = zend_lookup_class(class_name);\n\t\tif (ce) {\n\t\t\tBG(serialize_lock)--;\n\t\t\tif (EG(exception)) {\n\t\t\t\tzend_string_release(class_name);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tBG(serialize_lock)--;\n\n\t\tif (EG(exception)) {\n\t\t\tzend_string_release(class_name);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* Check for unserialize callback *\/\n\t\tif ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\\0')) {\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Call unserialize callback *\/\n\t\tZVAL_STRING(&user_func, PG(unserialize_callback_func));\n\n\t\tZVAL_STR_COPY(&args[0], class_name);\n\t\tBG(serialize_lock)++;\n\t\tif (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL) != SUCCESS) {\n\t\t\tBG(serialize_lock)--;\n\t\t\tif (EG(exception)) {\n\t\t\t\tzend_string_release(class_name);\n\t\t\t\tzval_ptr_dtor(&user_func);\n\t\t\t\tzval_ptr_dtor(&args[0]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tphp_error_docref(NULL, E_WARNING, \"defined (%s) but not found\", Z_STRVAL(user_func));\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t\tzval_ptr_dtor(&user_func);\n\t\t\tzval_ptr_dtor(&args[0]);\n\t\t\tbreak;\n\t\t}\n\t\tBG(serialize_lock)--;\n\t\tzval_ptr_dtor(&retval);\n\t\tif (EG(exception)) {\n\t\t\tzend_string_release(class_name);\n\t\t\tzval_ptr_dtor(&user_func);\n\t\t\tzval_ptr_dtor(&args[0]);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* The callback function may have defined the class *\/\n\t\tBG(serialize_lock)++;\n\t\tif ((ce = zend_lookup_class(class_name)) == NULL) {\n\t\t\tphp_error_docref(NULL, E_WARNING, \"Function %s() hasn't defined the class it was called for\", Z_STRVAL(user_func));\n\t\t\tincomplete_class = 1;\n\t\t\tce = PHP_IC_ENTRY;\n\t\t}\n\t\tBG(serialize_lock)--;\n\n\t\tzval_ptr_dtor(&user_func);\n\t\tzval_ptr_dtor(&args[0]);\n\t\tbreak;\n\t} while (1);\n\n\t*p = YYCURSOR;\n\n\tif (custom_object) {\n\t\tint ret;\n\n\t\tret = object_custom(UNSERIALIZE_PASSTHRU, ce);\n\n\t\tif (ret && incomplete_class) {\n\t\t\tphp_store_class_name(rval, ZSTR_VAL(class_name), len2);\n\t\t}\n\t\tzend_string_release(class_name);\n\t\treturn ret;\n\t}\n\n\telements = object_common1(UNSERIALIZE_PASSTHRU, ce);\n\n\tif (elements < 0) {\n\t   zend_string_release(class_name);\n\t   return 0;\n\t}\n\n\tif (incomplete_class) {\n\t\tphp_store_class_name(rval, ZSTR_VAL(class_name), len2);\n\t}\n\tzend_string_release(class_name);\n\n\treturn object_common2(UNSERIALIZE_PASSTHRU, elements);\n}\n#line 1266 \"ext\/standard\/var_unserializer.c\"\nyy84:\n\t++YYCURSOR;\n#line 724 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tsize_t len, maxlen;\n\tzend_string *str;\n\n\tlen = parse_uiv(start + 2);\n\tmaxlen = max - YYCURSOR;\n\tif (maxlen < len) {\n\t\t*p = start + 2;\n\t\treturn 0;\n\t}\n\n\tif ((str = unserialize_str(&YYCURSOR, len, maxlen)) == NULL) {\n\t\treturn 0;\n\t}\n\n\tif (*(YYCURSOR) != '\"') {\n\t\tzend_string_free(str);\n\t\t*p = YYCURSOR;\n\t\treturn 0;\n\t}\n\n\tif (*(YYCURSOR + 1) != ';') {\n\t\tefree(str);\n\t\t*p = YYCURSOR + 1;\n\t\treturn 0;\n\t}\n\n\tYYCURSOR += 2;\n\t*p = YYCURSOR;\n\n\tZVAL_STR(rval, str);\n\treturn 1;\n}\n#line 1303 \"ext\/standard\/var_unserializer.c\"\nyy86:\n\t++YYCURSOR;\n#line 758 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long elements = parse_iv(start + 2);\n\t\/* use iv() not uiv() in order to check data range *\/\n\t*p = YYCURSOR;\n    if (!var_hash) return 0;\n\n\tif (elements < 0 || elements >= HT_MAX_SIZE) {\n\t\treturn 0;\n\t}\n\n\tarray_init_size(rval, elements);\n\tif (elements) {\n\t\t\/* we can't convert from packed to hash during unserialization, because\n\t\t   reference to some zvals might be keept in var_hash (to support references) *\/\n\t\tzend_hash_real_init(Z_ARRVAL_P(rval), 0);\n\t}\n\n\tif (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_P(rval), elements, 0)) {\n\t\treturn 0;\n\t}\n\n\treturn finish_nested_data(UNSERIALIZE_PASSTHRU);\n}\n#line 1330 \"ext\/standard\/var_unserializer.c\"\nyy88:\n\tyych = *++YYCURSOR;\n\tif (yych <= ',') {\n\t\tif (yych == '+') goto yy96;\n\t\tgoto yy18;\n\t} else {\n\t\tif (yych <= '-') goto yy96;\n\t\tif (yych <= '\/') goto yy18;\n\t\tif (yych >= ':') goto yy18;\n\t}\nyy89:\n\t++YYCURSOR;\n\tif (YYLIMIT <= YYCURSOR) YYFILL(1);\n\tyych = *YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy89;\n\tif (yych == ';') goto yy71;\n\tgoto yy18;\nyy91:\n\tyych = *++YYCURSOR;\n\tif (yych == ';') goto yy97;\n\tgoto yy18;\nyy92:\n\t++YYCURSOR;\n#line 782 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tzend_long elements;\n    if (!var_hash) return 0;\n\n\telements = object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR);\n\tif (elements < 0 || elements >= HT_MAX_SIZE) {\n\t\treturn 0;\n\t}\n\treturn object_common2(UNSERIALIZE_PASSTHRU, elements);\n}\n#line 1366 \"ext\/standard\/var_unserializer.c\"\nyy94:\n\t++YYCURSOR;\n#line 692 \"ext\/standard\/var_unserializer.re\"\n\t{\n\tsize_t len, maxlen;\n\tchar *str;\n\n\tlen = parse_uiv(start + 2);\n\tmaxlen = max - YYCURSOR;\n\tif (maxlen < len) {\n\t\t*p = start + 2;\n\t\treturn 0;\n\t}\n\n\tstr = (char*)YYCURSOR;\n\n\tYYCURSOR += len;\n\n\tif (*(YYCURSOR) != '\"') {\n\t\t*p = YYCURSOR;\n\t\treturn 0;\n\t}\n\n\tif (*(YYCURSOR + 1) != ';') {\n\t\t*p = YYCURSOR + 1;\n\t\treturn 0;\n\t}\n\n\tYYCURSOR += 2;\n\t*p = YYCURSOR;\n\n\tZVAL_STRINGL(rval, str, len);\n\treturn 1;\n}\n#line 1401 \"ext\/standard\/var_unserializer.c\"\nyy96:\n\tyych = *++YYCURSOR;\n\tif (yych <= '\/') goto yy18;\n\tif (yych <= '9') goto yy89;\n\tgoto yy18;\nyy97:\n\t++YYCURSOR;\n#line 667 \"ext\/standard\/var_unserializer.re\"\n\t{\n\t*p = YYCURSOR;\n\n\tif (!strncmp((char*)start + 2, \"NAN\", 3)) {\n\t\tZVAL_DOUBLE(rval, php_get_nan());\n\t} else if (!strncmp((char*)start + 2, \"INF\", 3)) {\n\t\tZVAL_DOUBLE(rval, php_get_inf());\n\t} else if (!strncmp((char*)start + 2, \"-INF\", 4)) {\n\t\tZVAL_DOUBLE(rval, -php_get_inf());\n\t} else {\n\t\tZVAL_NULL(rval);\n\t}\n\n\treturn 1;\n}\n#line 1425 \"ext\/standard\/var_unserializer.c\"\n}\n#line 953 \"ext\/standard\/var_unserializer.re\"\n\n\n\treturn 0;\n}","target":0,"code_token_length":8020,"total_token_length":8256,"max_tokens_setting":11000}
+{"idx":4279,"func":"ex_substitute(exarg_T *eap)\n{\n    linenr_T\tlnum;\n    long\ti = 0;\n    regmmatch_T regmatch;\n    static subflags_T subflags = {FALSE, FALSE, FALSE, TRUE, FALSE,\n\t\t\t\t\t\t\t      FALSE, FALSE, 0};\n#ifdef FEAT_EVAL\n    subflags_T\tsubflags_save;\n#endif\n    int\t\tsave_do_all;\t\t\/\/ remember user specified 'g' flag\n    int\t\tsave_do_ask;\t\t\/\/ remember user specified 'c' flag\n    char_u\t*pat = NULL, *sub = NULL;\t\/\/ init for GCC\n    int\t\tdelimiter;\n    int\t\tsublen;\n    int\t\tgot_quit = FALSE;\n    int\t\tgot_match = FALSE;\n    int\t\ttemp;\n    int\t\twhich_pat;\n    char_u\t*cmd;\n    int\t\tsave_State;\n    linenr_T\tfirst_line = 0;\t\t\/\/ first changed line\n    linenr_T\tlast_line= 0;\t\t\/\/ below last changed line AFTER the\n\t\t\t\t\t\/\/ change\n    linenr_T\told_line_count = curbuf->b_ml.ml_line_count;\n    linenr_T\tline2;\n    long\tnmatch;\t\t\t\/\/ number of lines in match\n    char_u\t*sub_firstline;\t\t\/\/ allocated copy of first sub line\n    int\t\tendcolumn = FALSE;\t\/\/ cursor in last column when done\n    pos_T\told_cursor = curwin->w_cursor;\n    int\t\tstart_nsubs;\n#ifdef FEAT_EVAL\n    int\t\tsave_ma = 0;\n#endif\n\n    cmd = eap->arg;\n    if (!global_busy)\n    {\n\tsub_nsubs = 0;\n\tsub_nlines = 0;\n    }\n    start_nsubs = sub_nsubs;\n\n    if (eap->cmdidx == CMD_tilde)\n\twhich_pat = RE_LAST;\t\/\/ use last used regexp\n    else\n\twhich_pat = RE_SUBST;\t\/\/ use last substitute regexp\n\n\t\t\t\t\/\/ new pattern and substitution\n    if (eap->cmd[0] == 's' && *cmd != NUL && !VIM_ISWHITE(*cmd)\n\t\t&& vim_strchr((char_u *)\"0123456789cegriIp|\\\"\", *cmd) == NULL)\n    {\n\t\t\t\t\/\/ don't accept alphanumeric for separator\n\tif (check_regexp_delim(*cmd) == FAIL)\n\t    return;\n#ifdef FEAT_EVAL\n\tif (in_vim9script() && check_global_and_subst(eap->cmd, eap->arg)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t    return;\n#endif\n\n\t\/*\n\t * undocumented vi feature:\n\t *  \"\\\/sub\/\" and \"\\?sub?\" use last used search pattern (almost like\n\t *  \/\/sub\/r).  \"\\&sub&\" use last substitute pattern (like \/\/sub\/).\n\t *\/\n\tif (*cmd == '\\\\')\n\t{\n\t    ++cmd;\n\t    if (vim_strchr((char_u *)\"\/?&\", *cmd) == NULL)\n\t    {\n\t\temsg(_(e_backslash_should_be_followed_by));\n\t\treturn;\n\t    }\n\t    if (*cmd != '&')\n\t\twhich_pat = RE_SEARCH;\t    \/\/ use last '\/' pattern\n\t    pat = (char_u *)\"\";\t\t    \/\/ empty search pattern\n\t    delimiter = *cmd++;\t\t    \/\/ remember delimiter character\n\t}\n\telse\t\t\/\/ find the end of the regexp\n\t{\n\t    which_pat = RE_LAST;\t    \/\/ use last used regexp\n\t    delimiter = *cmd++;\t\t    \/\/ remember delimiter character\n\t    pat = cmd;\t\t\t    \/\/ remember start of search pat\n\t    cmd = skip_regexp_ex(cmd, delimiter, magic_isset(),\n\t\t\t\t\t\t\t&eap->arg, NULL, NULL);\n\t    if (cmd[0] == delimiter)\t    \/\/ end delimiter found\n\t\t*cmd++ = NUL;\t\t    \/\/ replace it with a NUL\n\t}\n\n\t\/*\n\t * Small incompatibility: vi sees '\\n' as end of the command, but in\n\t * Vim we want to use '\\n' to find\/substitute a NUL.\n\t *\/\n\tsub = cmd;\t    \/\/ remember the start of the substitution\n\tcmd = skip_substitute(cmd, delimiter);\n\n\tif (!eap->skip)\n\t{\n\t    \/\/ In POSIX vi \":s\/pat\/%\/\" uses the previous subst. string.\n\t    if (STRCMP(sub, \"%\") == 0\n\t\t\t\t && vim_strchr(p_cpo, CPO_SUBPERCENT) != NULL)\n\t    {\n\t\tif (old_sub == NULL)\t\/\/ there is no previous command\n\t\t{\n\t\t    emsg(_(e_no_previous_substitute_regular_expression));\n\t\t    return;\n\t\t}\n\t\tsub = old_sub;\n\t    }\n\t    else\n\t    {\n\t\tvim_free(old_sub);\n\t\told_sub = vim_strsave(sub);\n\t    }\n\t}\n    }\n    else if (!eap->skip)\t\/\/ use previous pattern and substitution\n    {\n\tif (old_sub == NULL)\t\/\/ there is no previous command\n\t{\n\t    emsg(_(e_no_previous_substitute_regular_expression));\n\t    return;\n\t}\n\tpat = NULL;\t\t\/\/ search_regcomp() will use previous pattern\n\tsub = old_sub;\n\n\t\/\/ Vi compatibility quirk: repeating with \":s\" keeps the cursor in the\n\t\/\/ last column after using \"$\".\n\tendcolumn = (curwin->w_curswant == MAXCOL);\n    }\n\n    \/\/ Recognize \":%s\/\\n\/\/\" and turn it into a join command, which is much\n    \/\/ more efficient.\n    \/\/ TODO: find a generic solution to make line-joining operations more\n    \/\/ efficient, avoid allocating a string that grows in size.\n    if (pat != NULL && STRCMP(pat, \"\\\\n\") == 0\n\t    && *sub == NUL\n\t    && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'\n\t\t\t\t\t     || *cmd == 'p' || *cmd == '#'))))\n    {\n\tlinenr_T    joined_lines_count;\n\n\tif (eap->skip)\n\t    return;\n\tcurwin->w_cursor.lnum = eap->line1;\n\tif (*cmd == 'l')\n\t    eap->flags = EXFLAG_LIST;\n\telse if (*cmd == '#')\n\t    eap->flags = EXFLAG_NR;\n\telse if (*cmd == 'p')\n\t    eap->flags = EXFLAG_PRINT;\n\n\t\/\/ The number of lines joined is the number of lines in the range plus\n\t\/\/ one.  One less when the last line is included.\n\tjoined_lines_count = eap->line2 - eap->line1 + 1;\n\tif (eap->line2 < curbuf->b_ml.ml_line_count)\n\t    ++joined_lines_count;\n\tif (joined_lines_count > 1)\n\t{\n\t    (void)do_join(joined_lines_count, FALSE, TRUE, FALSE, TRUE);\n\t    sub_nsubs = joined_lines_count - 1;\n\t    sub_nlines = 1;\n\t    (void)do_sub_msg(FALSE);\n\t    ex_may_print(eap);\n\t}\n\n\tif ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0)\n\t    save_re_pat(RE_SUBST, pat, magic_isset());\n\t\/\/ put pattern in history\n\tadd_to_history(HIST_SEARCH, pat, TRUE, NUL);\n\n\treturn;\n    }\n\n    \/*\n     * Find trailing options.  When '&' is used, keep old options.\n     *\/\n    if (*cmd == '&')\n\t++cmd;\n    else\n    {\n#ifdef FEAT_EVAL\n\tif (in_vim9script())\n\t{\n\t    \/\/ ignore 'gdefault' and 'edcompatible'\n\t    subflags.do_all = FALSE;\n\t    subflags.do_ask = FALSE;\n\t}\n\telse\n#endif\n\tif (!p_ed)\n\t{\n\t    if (p_gd)\t\t\/\/ default is global on\n\t\tsubflags.do_all = TRUE;\n\t    else\n\t\tsubflags.do_all = FALSE;\n\t    subflags.do_ask = FALSE;\n\t}\n\tsubflags.do_error = TRUE;\n\tsubflags.do_print = FALSE;\n\tsubflags.do_list = FALSE;\n\tsubflags.do_count = FALSE;\n\tsubflags.do_number = FALSE;\n\tsubflags.do_ic = 0;\n    }\n    while (*cmd)\n    {\n\t\/*\n\t * Note that 'g' and 'c' are always inverted, also when p_ed is off.\n\t * 'r' is never inverted.\n\t *\/\n\tif (*cmd == 'g')\n\t    subflags.do_all = !subflags.do_all;\n\telse if (*cmd == 'c')\n\t    subflags.do_ask = !subflags.do_ask;\n\telse if (*cmd == 'n')\n\t    subflags.do_count = TRUE;\n\telse if (*cmd == 'e')\n\t    subflags.do_error = !subflags.do_error;\n\telse if (*cmd == 'r')\t    \/\/ use last used regexp\n\t    which_pat = RE_LAST;\n\telse if (*cmd == 'p')\n\t    subflags.do_print = TRUE;\n\telse if (*cmd == '#')\n\t{\n\t    subflags.do_print = TRUE;\n\t    subflags.do_number = TRUE;\n\t}\n\telse if (*cmd == 'l')\n\t{\n\t    subflags.do_print = TRUE;\n\t    subflags.do_list = TRUE;\n\t}\n\telse if (*cmd == 'i')\t    \/\/ ignore case\n\t    subflags.do_ic = 'i';\n\telse if (*cmd == 'I')\t    \/\/ don't ignore case\n\t    subflags.do_ic = 'I';\n\telse\n\t    break;\n\t++cmd;\n    }\n    if (subflags.do_count)\n\tsubflags.do_ask = FALSE;\n\n    save_do_all = subflags.do_all;\n    save_do_ask = subflags.do_ask;\n\n    \/*\n     * check for a trailing count\n     *\/\n    cmd = skipwhite(cmd);\n    if (VIM_ISDIGIT(*cmd))\n    {\n\ti = getdigits(&cmd);\n\tif (i <= 0 && !eap->skip && subflags.do_error)\n\t{\n\t    emsg(_(e_positive_count_required));\n\t    return;\n\t}\n\teap->line1 = eap->line2;\n\teap->line2 += i - 1;\n\tif (eap->line2 > curbuf->b_ml.ml_line_count)\n\t    eap->line2 = curbuf->b_ml.ml_line_count;\n    }\n\n    \/*\n     * check for trailing command or garbage\n     *\/\n    cmd = skipwhite(cmd);\n    if (*cmd && *cmd != '\"')\t    \/\/ if not end-of-line or comment\n    {\n\tset_nextcmd(eap, cmd);\n\tif (eap->nextcmd == NULL)\n\t{\n\t    semsg(_(e_trailing_characters_str), cmd);\n\t    return;\n\t}\n    }\n\n    if (eap->skip)\t    \/\/ not executing commands, only parsing\n\treturn;\n\n    if (!subflags.do_count && !curbuf->b_p_ma)\n    {\n\t\/\/ Substitution is not allowed in non-'modifiable' buffer\n\temsg(_(e_cannot_make_changes_modifiable_is_off));\n\treturn;\n    }\n\n    if (search_regcomp(pat, RE_SUBST, which_pat, SEARCH_HIS, ®match) == FAIL)\n    {\n\tif (subflags.do_error)\n\t    emsg(_(e_invalid_command));\n\treturn;\n    }\n\n    \/\/ the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase'\n    if (subflags.do_ic == 'i')\n\tregmatch.rmm_ic = TRUE;\n    else if (subflags.do_ic == 'I')\n\tregmatch.rmm_ic = FALSE;\n\n    sub_firstline = NULL;\n\n    \/*\n     * ~ in the substitute pattern is replaced with the old pattern.\n     * We do it here once to avoid it to be replaced over and over again.\n     * But don't do it when it starts with \"\\=\", then it's an expression.\n     *\/\n    if (!(sub[0] == '\\\\' && sub[1] == '='))\n\tsub = regtilde(sub, magic_isset());\n\n    \/*\n     * Check for a match on each line.\n     *\/\n    line2 = eap->line2;\n    for (lnum = eap->line1; lnum <= line2 && !(got_quit\n#if defined(FEAT_EVAL)\n\t\t|| aborting()\n#endif\n\t\t); ++lnum)\n    {\n\tnmatch = vim_regexec_multi(®match, curwin, curbuf, lnum,\n\t\t\t\t\t\t       (colnr_T)0, NULL, NULL);\n\tif (nmatch)\n\t{\n\t    colnr_T\tcopycol;\n\t    colnr_T\tmatchcol;\n\t    colnr_T\tprev_matchcol = MAXCOL;\n\t    char_u\t*new_end, *new_start = NULL;\n\t    unsigned\tnew_start_len = 0;\n\t    char_u\t*p1;\n\t    int\t\tdid_sub = FALSE;\n\t    int\t\tlastone;\n\t    int\t\tlen, copy_len, needed_len;\n\t    long\tnmatch_tl = 0;\t\/\/ nr of lines matched below lnum\n\t    int\t\tdo_again;\t\/\/ do it again after joining lines\n\t    int\t\tskip_match = FALSE;\n\t    linenr_T\tsub_firstlnum;\t\/\/ nr of first sub line\n#ifdef FEAT_PROP_POPUP\n\t    int\t\tapc_flags = APC_SAVE_FOR_UNDO | APC_SUBSTITUTE;\n\t    colnr_T\ttotal_added =  0;\n#endif\n\n\t    \/*\n\t     * The new text is build up step by step, to avoid too much\n\t     * copying.  There are these pieces:\n\t     * sub_firstline\tThe old text, unmodified.\n\t     * copycol\t\tColumn in the old text where we started\n\t     *\t\t\tlooking for a match; from here old text still\n\t     *\t\t\tneeds to be copied to the new text.\n\t     * matchcol\t\tColumn number of the old text where to look\n\t     *\t\t\tfor the next match.  It's just after the\n\t     *\t\t\tprevious match or one further.\n\t     * prev_matchcol\tColumn just after the previous match (if any).\n\t     *\t\t\tMostly equal to matchcol, except for the first\n\t     *\t\t\tmatch and after skipping an empty match.\n\t     * regmatch.*pos\tWhere the pattern matched in the old text.\n\t     * new_start\tThe new text, all that has been produced so\n\t     *\t\t\tfar.\n\t     * new_end\t\tThe new text, where to append new text.\n\t     *\n\t     * lnum\t\tThe line number where we found the start of\n\t     *\t\t\tthe match.  Can be below the line we searched\n\t     *\t\t\twhen there is a \\n before a \\zs in the\n\t     *\t\t\tpattern.\n\t     * sub_firstlnum\tThe line number in the buffer where to look\n\t     *\t\t\tfor a match.  Can be different from \"lnum\"\n\t     *\t\t\twhen the pattern or substitute string contains\n\t     *\t\t\tline breaks.\n\t     *\n\t     * Special situations:\n\t     * - When the substitute string contains a line break, the part up\n\t     *   to the line break is inserted in the text, but the copy of\n\t     *   the original line is kept.  \"sub_firstlnum\" is adjusted for\n\t     *   the inserted lines.\n\t     * - When the matched pattern contains a line break, the old line\n\t     *   is taken from the line at the end of the pattern.  The lines\n\t     *   in the match are deleted later, \"sub_firstlnum\" is adjusted\n\t     *   accordingly.\n\t     *\n\t     * The new text is built up in new_start[].  It has some extra\n\t     * room to avoid using alloc()\/free() too often.  new_start_len is\n\t     * the length of the allocated memory at new_start.\n\t     *\n\t     * Make a copy of the old line, so it won't be taken away when\n\t     * updating the screen or handling a multi-line match.  The \"old_\"\n\t     * pointers point into this copy.\n\t     *\/\n\t    sub_firstlnum = lnum;\n\t    copycol = 0;\n\t    matchcol = 0;\n\n\t    \/\/ At first match, remember current cursor position.\n\t    if (!got_match)\n\t    {\n\t\tsetpcmark();\n\t\tgot_match = TRUE;\n\t    }\n\n\t    \/*\n\t     * Loop until nothing more to replace in this line.\n\t     * 1. Handle match with empty string.\n\t     * 2. If do_ask is set, ask for confirmation.\n\t     * 3. substitute the string.\n\t     * 4. if do_all is set, find next match\n\t     * 5. break if there isn't another match in this line\n\t     *\/\n\t    for (;;)\n\t    {\n\t\t\/\/ Advance \"lnum\" to the line where the match starts.  The\n\t\t\/\/ match does not start in the first line when there is a line\n\t\t\/\/ break before \\zs.\n\t\tif (regmatch.startpos[0].lnum > 0)\n\t\t{\n\t\t    lnum += regmatch.startpos[0].lnum;\n\t\t    sub_firstlnum += regmatch.startpos[0].lnum;\n\t\t    nmatch -= regmatch.startpos[0].lnum;\n\t\t    VIM_CLEAR(sub_firstline);\n\t\t}\n\n\t\t\/\/ Match might be after the last line for \"\\n\\zs\" matching at\n\t\t\/\/ the end of the last line.\n\t\tif (lnum > curbuf->b_ml.ml_line_count)\n\t\t    break;\n\n\t\tif (sub_firstline == NULL)\n\t\t{\n\t\t    sub_firstline = vim_strsave(ml_get(sub_firstlnum));\n\t\t    if (sub_firstline == NULL)\n\t\t    {\n\t\t\tvim_free(new_start);\n\t\t\tgoto outofmem;\n\t\t    }\n\t\t}\n\n\t\t\/\/ Save the line number of the last change for the final\n\t\t\/\/ cursor position (just like Vi).\n\t\tcurwin->w_cursor.lnum = lnum;\n\t\tdo_again = FALSE;\n\n\t\t\/*\n\t\t * 1. Match empty string does not count, except for first\n\t\t * match.  This reproduces the strange vi behaviour.\n\t\t * This also catches endless loops.\n\t\t *\/\n\t\tif (matchcol == prev_matchcol\n\t\t\t&& regmatch.endpos[0].lnum == 0\n\t\t\t&& matchcol == regmatch.endpos[0].col)\n\t\t{\n\t\t    if (sub_firstline[matchcol] == NUL)\n\t\t\t\/\/ We already were at the end of the line.  Don't look\n\t\t\t\/\/ for a match in this line again.\n\t\t\tskip_match = TRUE;\n\t\t    else\n\t\t    {\n\t\t\t \/\/ search for a match at next column\n\t\t\tif (has_mbyte)\n\t\t\t    matchcol += mb_ptr2len(sub_firstline + matchcol);\n\t\t\telse\n\t\t\t    ++matchcol;\n\t\t    }\n\t\t    goto skip;\n\t\t}\n\n\t\t\/\/ Normally we continue searching for a match just after the\n\t\t\/\/ previous match.\n\t\tmatchcol = regmatch.endpos[0].col;\n\t\tprev_matchcol = matchcol;\n\n\t\t\/*\n\t\t * 2. If do_count is set only increase the counter.\n\t\t *    If do_ask is set, ask for confirmation.\n\t\t *\/\n\t\tif (subflags.do_count)\n\t\t{\n\t\t    \/\/ For a multi-line match, put matchcol at the NUL at\n\t\t    \/\/ the end of the line and set nmatch to one, so that\n\t\t    \/\/ we continue looking for a match on the next line.\n\t\t    \/\/ Avoids that \":s\/\\nB\\@=\/\/gc\" get stuck.\n\t\t    if (nmatch > 1)\n\t\t    {\n\t\t\tmatchcol = (colnr_T)STRLEN(sub_firstline);\n\t\t\tnmatch = 1;\n\t\t\tskip_match = TRUE;\n\t\t    }\n\t\t    sub_nsubs++;\n\t\t    did_sub = TRUE;\n#ifdef FEAT_EVAL\n\t\t    \/\/ Skip the substitution, unless an expression is used,\n\t\t    \/\/ then it is evaluated in the sandbox.\n\t\t    if (!(sub[0] == '\\\\' && sub[1] == '='))\n#endif\n\t\t\tgoto skip;\n\t\t}\n\n\t\tif (subflags.do_ask)\n\t\t{\n\t\t    int typed = 0;\n\n\t\t    \/\/ change State to CONFIRM, so that the mouse works\n\t\t    \/\/ properly\n\t\t    save_State = State;\n\t\t    State = CONFIRM;\n\t\t    setmouse();\t\t\/\/ disable mouse in xterm\n\t\t    curwin->w_cursor.col = regmatch.startpos[0].col;\n\t\t    if (curwin->w_p_crb)\n\t\t\tdo_check_cursorbind();\n\n\t\t    \/\/ When 'cpoptions' contains \"u\" don't sync undo when\n\t\t    \/\/ asking for confirmation.\n\t\t    if (vim_strchr(p_cpo, CPO_UNDO) != NULL)\n\t\t\t++no_u_sync;\n\n\t\t    \/*\n\t\t     * Loop until 'y', 'n', 'q', CTRL-E or CTRL-Y typed.\n\t\t     *\/\n\t\t    while (subflags.do_ask)\n\t\t    {\n\t\t\tif (exmode_active)\n\t\t\t{\n\t\t\t    char_u\t*resp;\n\t\t\t    colnr_T\tsc, ec;\n\n\t\t\t    print_line_no_prefix(lnum,\n\t\t\t\t\t subflags.do_number, subflags.do_list);\n\n\t\t\t    getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);\n\t\t\t    curwin->w_cursor.col = regmatch.endpos[0].col - 1;\n\t\t\t    if (curwin->w_cursor.col < 0)\n\t\t\t\tcurwin->w_cursor.col = 0;\n\t\t\t    getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);\n\t\t\t    curwin->w_cursor.col = regmatch.startpos[0].col;\n\t\t\t    if (subflags.do_number || curwin->w_p_nu)\n\t\t\t    {\n\t\t\t\tint numw = number_width(curwin) + 1;\n\t\t\t\tsc += numw;\n\t\t\t\tec += numw;\n\t\t\t    }\n\t\t\t    msg_start();\n\t\t\t    for (i = 0; i < (long)sc; ++i)\n\t\t\t\tmsg_putchar(' ');\n\t\t\t    for ( ; i <= (long)ec; ++i)\n\t\t\t\tmsg_putchar('^');\n\n\t\t\t    resp = getexmodeline('?', NULL, 0, TRUE);\n\t\t\t    if (resp != NULL)\n\t\t\t    {\n\t\t\t\ttyped = *resp;\n\t\t\t\tvim_free(resp);\n\t\t\t    }\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    char_u *orig_line = NULL;\n\t\t\t    int    len_change = 0;\n\t\t\t    int\t   save_p_lz = p_lz;\n#ifdef FEAT_FOLDING\n\t\t\t    int save_p_fen = curwin->w_p_fen;\n\n\t\t\t    curwin->w_p_fen = FALSE;\n#endif\n\t\t\t    \/\/ Invert the matched string.\n\t\t\t    \/\/ Remove the inversion afterwards.\n\t\t\t    temp = RedrawingDisabled;\n\t\t\t    RedrawingDisabled = 0;\n\n\t\t\t    \/\/ avoid calling update_screen() in vgetorpeek()\n\t\t\t    p_lz = FALSE;\n\n\t\t\t    if (new_start != NULL)\n\t\t\t    {\n\t\t\t\t\/\/ There already was a substitution, we would\n\t\t\t\t\/\/ like to show this to the user.  We cannot\n\t\t\t\t\/\/ really update the line, it would change\n\t\t\t\t\/\/ what matches.  Temporarily replace the line\n\t\t\t\t\/\/ and change it back afterwards.\n\t\t\t\torig_line = vim_strsave(ml_get(lnum));\n\t\t\t\tif (orig_line != NULL)\n\t\t\t\t{\n\t\t\t\t    char_u *new_line = concat_str(new_start,\n\t\t\t\t\t\t     sub_firstline + copycol);\n\n\t\t\t\t    if (new_line == NULL)\n\t\t\t\t\tVIM_CLEAR(orig_line);\n\t\t\t\t    else\n\t\t\t\t    {\n\t\t\t\t\t\/\/ Position the cursor relative to the\n\t\t\t\t\t\/\/ end of the line, the previous\n\t\t\t\t\t\/\/ substitute may have inserted or\n\t\t\t\t\t\/\/ deleted characters before the\n\t\t\t\t\t\/\/ cursor.\n\t\t\t\t\tlen_change = (int)STRLEN(new_line)\n\t\t\t\t\t\t     - (int)STRLEN(orig_line);\n\t\t\t\t\tcurwin->w_cursor.col += len_change;\n\t\t\t\t\tml_replace(lnum, new_line, FALSE);\n\t\t\t\t    }\n\t\t\t\t}\n\t\t\t    }\n\n\t\t\t    search_match_lines = regmatch.endpos[0].lnum\n\t\t\t\t\t\t  - regmatch.startpos[0].lnum;\n\t\t\t    search_match_endcol = regmatch.endpos[0].col\n\t\t\t\t\t\t\t\t + len_change;\n\t\t\t    highlight_match = TRUE;\n\n\t\t\t    update_topline();\n\t\t\t    validate_cursor();\n\t\t\t    update_screen(SOME_VALID);\n\t\t\t    highlight_match = FALSE;\n\t\t\t    redraw_later(SOME_VALID);\n\n#ifdef FEAT_FOLDING\n\t\t\t    curwin->w_p_fen = save_p_fen;\n#endif\n\t\t\t    if (msg_row == Rows - 1)\n\t\t\t\tmsg_didout = FALSE;\t\/\/ avoid a scroll-up\n\t\t\t    msg_starthere();\n\t\t\t    i = msg_scroll;\n\t\t\t    msg_scroll = 0;\t\t\/\/ truncate msg when\n\t\t\t\t\t\t\t\/\/ needed\n\t\t\t    msg_no_more = TRUE;\n\t\t\t    \/\/ write message same highlighting as for\n\t\t\t    \/\/ wait_return\n\t\t\t    smsg_attr(HL_ATTR(HLF_R),\n\t\t\t\t_(\"replace with %s (y\/n\/a\/q\/l\/^E\/^Y)?\"), sub);\n\t\t\t    msg_no_more = FALSE;\n\t\t\t    msg_scroll = i;\n\t\t\t    showruler(TRUE);\n\t\t\t    windgoto(msg_row, msg_col);\n\t\t\t    RedrawingDisabled = temp;\n\n#ifdef USE_ON_FLY_SCROLL\n\t\t\t    dont_scroll = FALSE; \/\/ allow scrolling here\n#endif\n\t\t\t    ++no_mapping;\t\/\/ don't map this key\n\t\t\t    ++allow_keys;\t\/\/ allow special keys\n\t\t\t    typed = plain_vgetc();\n\t\t\t    --allow_keys;\n\t\t\t    --no_mapping;\n\n\t\t\t    \/\/ clear the question\n\t\t\t    msg_didout = FALSE;\t\/\/ don't scroll up\n\t\t\t    msg_col = 0;\n\t\t\t    gotocmdline(TRUE);\n\t\t\t    p_lz = save_p_lz;\n\n\t\t\t    \/\/ restore the line\n\t\t\t    if (orig_line != NULL)\n\t\t\t\tml_replace(lnum, orig_line, FALSE);\n\t\t\t}\n\n\t\t\tneed_wait_return = FALSE; \/\/ no hit-return prompt\n\t\t\tif (typed == 'q' || typed == ESC || typed == Ctrl_C\n#ifdef UNIX\n\t\t\t\t|| typed == intr_char\n#endif\n\t\t\t\t)\n\t\t\t{\n\t\t\t    got_quit = TRUE;\n\t\t\t    break;\n\t\t\t}\n\t\t\tif (typed == 'n')\n\t\t\t    break;\n\t\t\tif (typed == 'y')\n\t\t\t    break;\n\t\t\tif (typed == 'l')\n\t\t\t{\n\t\t\t    \/\/ last: replace and then stop\n\t\t\t    subflags.do_all = FALSE;\n\t\t\t    line2 = lnum;\n\t\t\t    break;\n\t\t\t}\n\t\t\tif (typed == 'a')\n\t\t\t{\n\t\t\t    subflags.do_ask = FALSE;\n\t\t\t    break;\n\t\t\t}\n\t\t\tif (typed == Ctrl_E)\n\t\t\t    scrollup_clamp();\n\t\t\telse if (typed == Ctrl_Y)\n\t\t\t    scrolldown_clamp();\n\t\t    }\n\t\t    State = save_State;\n\t\t    setmouse();\n\t\t    if (vim_strchr(p_cpo, CPO_UNDO) != NULL)\n\t\t\t--no_u_sync;\n\n\t\t    if (typed == 'n')\n\t\t    {\n\t\t\t\/\/ For a multi-line match, put matchcol at the NUL at\n\t\t\t\/\/ the end of the line and set nmatch to one, so that\n\t\t\t\/\/ we continue looking for a match on the next line.\n\t\t\t\/\/ Avoids that \":%s\/\\nB\\@=\/\/gc\" and \":%s\/\\n\/,\\r\/gc\"\n\t\t\t\/\/ get stuck when pressing 'n'.\n\t\t\tif (nmatch > 1)\n\t\t\t{\n\t\t\t    matchcol = (colnr_T)STRLEN(sub_firstline);\n\t\t\t    skip_match = TRUE;\n\t\t\t}\n\t\t\tgoto skip;\n\t\t    }\n\t\t    if (got_quit)\n\t\t\tgoto skip;\n\t\t}\n\n\t\t\/\/ Move the cursor to the start of the match, so that we can\n\t\t\/\/ use \"\\=col(\".\").\n\t\tcurwin->w_cursor.col = regmatch.startpos[0].col;\n\n\t\t\/*\n\t\t * 3. substitute the string.\n\t\t *\/\n#ifdef FEAT_EVAL\n\t\tsave_ma = curbuf->b_p_ma;\n\t\tif (subflags.do_count)\n\t\t{\n\t\t    \/\/ prevent accidentally changing the buffer by a function\n\t\t    curbuf->b_p_ma = FALSE;\n\t\t    sandbox++;\n\t\t}\n\t\t\/\/ Save flags for recursion.  They can change for e.g.\n\t\t\/\/ :s\/^\/\\=execute(\"s#^##gn\")\n\t\tsubflags_save = subflags;\n#endif\n\t\t\/\/ get length of substitution part\n\t\tsublen = vim_regsub_multi(®match,\n\t\t\t\t    sub_firstlnum - regmatch.startpos[0].lnum,\n\t\t\t       sub, sub_firstline, FALSE, magic_isset(), TRUE);\n#ifdef FEAT_EVAL\n\t\t\/\/ If getting the substitute string caused an error, don't do\n\t\t\/\/ the replacement.\n\t\t\/\/ Don't keep flags set by a recursive call.\n\t\tsubflags = subflags_save;\n\t\tif (aborting() || subflags.do_count)\n\t\t{\n\t\t    curbuf->b_p_ma = save_ma;\n\t\t    if (sandbox > 0)\n\t\t\tsandbox--;\n\t\t    goto skip;\n\t\t}\n#endif\n\n\t\t\/\/ When the match included the \"$\" of the last line it may\n\t\t\/\/ go beyond the last line of the buffer.\n\t\tif (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1)\n\t\t{\n\t\t    nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1;\n\t\t    skip_match = TRUE;\n\t\t}\n\n\t\t\/\/ Need room for:\n\t\t\/\/ - result so far in new_start (not for first sub in line)\n\t\t\/\/ - original text up to match\n\t\t\/\/ - length of substituted part\n\t\t\/\/ - original text after match\n\t\t\/\/ Adjust text properties here, since we have all information\n\t\t\/\/ needed.\n\t\tif (nmatch == 1)\n\t\t{\n\t\t    p1 = sub_firstline;\n#ifdef FEAT_PROP_POPUP\n\t\t    if (curbuf->b_has_textprop)\n\t\t    {\n\t\t\tint bytes_added = sublen - 1 - (regmatch.endpos[0].col\n\t\t\t\t\t\t   - regmatch.startpos[0].col);\n\n\t\t\t\/\/ When text properties are changed, need to save for\n\t\t\t\/\/ undo first, unless done already.\n\t\t\tif (adjust_prop_columns(lnum,\n\t\t\t\t\ttotal_added + regmatch.startpos[0].col,\n\t\t\t\t\t\t       bytes_added, apc_flags))\n\t\t\t    apc_flags &= ~APC_SAVE_FOR_UNDO;\n\t\t\t\/\/ Offset for column byte number of the text property\n\t\t\t\/\/ in the resulting buffer afterwards.\n\t\t\ttotal_added += bytes_added;\n\t\t    }\n#endif\n\t\t}\n\t\telse\n\t\t{\n\t\t    p1 = ml_get(sub_firstlnum + nmatch - 1);\n\t\t    nmatch_tl += nmatch - 1;\n\t\t}\n\t\tcopy_len = regmatch.startpos[0].col - copycol;\n\t\tneeded_len = copy_len + ((unsigned)STRLEN(p1)\n\t\t\t\t       - regmatch.endpos[0].col) + sublen + 1;\n\t\tif (new_start == NULL)\n\t\t{\n\t\t    \/*\n\t\t     * Get some space for a temporary buffer to do the\n\t\t     * substitution into (and some extra space to avoid\n\t\t     * too many calls to alloc()\/free()).\n\t\t     *\/\n\t\t    new_start_len = needed_len + 50;\n\t\t    if ((new_start = alloc(new_start_len)) == NULL)\n\t\t\tgoto outofmem;\n\t\t    *new_start = NUL;\n\t\t    new_end = new_start;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/*\n\t\t     * Check if the temporary buffer is long enough to do the\n\t\t     * substitution into.  If not, make it larger (with a bit\n\t\t     * extra to avoid too many calls to alloc()\/free()).\n\t\t     *\/\n\t\t    len = (unsigned)STRLEN(new_start);\n\t\t    needed_len += len;\n\t\t    if (needed_len > (int)new_start_len)\n\t\t    {\n\t\t\tnew_start_len = needed_len + 50;\n\t\t\tif ((p1 = alloc(new_start_len)) == NULL)\n\t\t\t{\n\t\t\t    vim_free(new_start);\n\t\t\t    goto outofmem;\n\t\t\t}\n\t\t\tmch_memmove(p1, new_start, (size_t)(len + 1));\n\t\t\tvim_free(new_start);\n\t\t\tnew_start = p1;\n\t\t    }\n\t\t    new_end = new_start + len;\n\t\t}\n\n\t\t\/*\n\t\t * copy the text up to the part that matched\n\t\t *\/\n\t\tmch_memmove(new_end, sub_firstline + copycol, (size_t)copy_len);\n\t\tnew_end += copy_len;\n\n\t\t(void)vim_regsub_multi(®match,\n\t\t\t\t    sub_firstlnum - regmatch.startpos[0].lnum,\n\t\t\t\t      sub, new_end, TRUE, magic_isset(), TRUE);\n\t\tsub_nsubs++;\n\t\tdid_sub = TRUE;\n\n\t\t\/\/ Move the cursor to the start of the line, to avoid that it\n\t\t\/\/ is beyond the end of the line after the substitution.\n\t\tcurwin->w_cursor.col = 0;\n\n\t\t\/\/ For a multi-line match, make a copy of the last matched\n\t\t\/\/ line and continue in that one.\n\t\tif (nmatch > 1)\n\t\t{\n\t\t    sub_firstlnum += nmatch - 1;\n\t\t    vim_free(sub_firstline);\n\t\t    sub_firstline = vim_strsave(ml_get(sub_firstlnum));\n\t\t    \/\/ When going beyond the last line, stop substituting.\n\t\t    if (sub_firstlnum <= line2)\n\t\t\tdo_again = TRUE;\n\t\t    else\n\t\t\tsubflags.do_all = FALSE;\n\t\t}\n\n\t\t\/\/ Remember next character to be copied.\n\t\tcopycol = regmatch.endpos[0].col;\n\n\t\tif (skip_match)\n\t\t{\n\t\t    \/\/ Already hit end of the buffer, sub_firstlnum is one\n\t\t    \/\/ less than what it ought to be.\n\t\t    vim_free(sub_firstline);\n\t\t    sub_firstline = vim_strsave((char_u *)\"\");\n\t\t    copycol = 0;\n\t\t}\n\n\t\t\/*\n\t\t * Now the trick is to replace CTRL-M chars with a real line\n\t\t * break.  This would make it impossible to insert a CTRL-M in\n\t\t * the text.  The line break can be avoided by preceding the\n\t\t * CTRL-M with a backslash.  To be able to insert a backslash,\n\t\t * they must be doubled in the string and are halved here.\n\t\t * That is Vi compatible.\n\t\t *\/\n\t\tfor (p1 = new_end; *p1; ++p1)\n\t\t{\n\t\t    if (p1[0] == '\\\\' && p1[1] != NUL)  \/\/ remove backslash\n\t\t    {\n\t\t\tSTRMOVE(p1, p1 + 1);\n#ifdef FEAT_PROP_POPUP\n\t\t\tif (curbuf->b_has_textprop)\n\t\t\t{\n\t\t\t    \/\/ When text properties are changed, need to save\n\t\t\t    \/\/ for undo first, unless done already.\n\t\t\t    if (adjust_prop_columns(lnum,\n\t\t\t\t\t(colnr_T)(p1 - new_start), -1,\n\t\t\t\t\tapc_flags))\n\t\t\t\tapc_flags &= ~APC_SAVE_FOR_UNDO;\n\t\t\t}\n#endif\n\t\t    }\n\t\t    else if (*p1 == CAR)\n\t\t    {\n\t\t\tif (u_inssub(lnum) == OK)   \/\/ prepare for undo\n\t\t\t{\n\t\t\t    colnr_T\tplen = (colnr_T)(p1 - new_start + 1);\n\n\t\t\t    *p1 = NUL;\t\t    \/\/ truncate up to the CR\n\t\t\t    ml_append(lnum - 1, new_start, plen, FALSE);\n\t\t\t    mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);\n\t\t\t    if (subflags.do_ask)\n\t\t\t\tappended_lines(lnum - 1, 1L);\n\t\t\t    else\n\t\t\t    {\n\t\t\t\tif (first_line == 0)\n\t\t\t\t    first_line = lnum;\n\t\t\t\tlast_line = lnum + 1;\n\t\t\t    }\n#ifdef FEAT_PROP_POPUP\n\t\t\t    adjust_props_for_split(lnum + 1, lnum, plen, 1);\n#endif\n\t\t\t    \/\/ all line numbers increase\n\t\t\t    ++sub_firstlnum;\n\t\t\t    ++lnum;\n\t\t\t    ++line2;\n\t\t\t    \/\/ move the cursor to the new line, like Vi\n\t\t\t    ++curwin->w_cursor.lnum;\n\t\t\t    \/\/ copy the rest\n\t\t\t    STRMOVE(new_start, p1 + 1);\n\t\t\t    p1 = new_start - 1;\n\t\t\t}\n\t\t    }\n\t\t    else if (has_mbyte)\n\t\t\tp1 += (*mb_ptr2len)(p1) - 1;\n\t\t}\n\n\t\t\/*\n\t\t * 4. If do_all is set, find next match.\n\t\t * Prevent endless loop with patterns that match empty\n\t\t * strings, e.g. :s\/$\/pat\/g or :s\/[a-z]* \/(&)\/g.\n\t\t * But \":s\/\\n\/#\/\" is OK.\n\t\t *\/\nskip:\n\t\t\/\/ We already know that we did the last subst when we are at\n\t\t\/\/ the end of the line, except that a pattern like\n\t\t\/\/ \"bar\\|\\nfoo\" may match at the NUL.  \"lnum\" can be below\n\t\t\/\/ \"line2\" when there is a \\zs in the pattern after a line\n\t\t\/\/ break.\n\t\tlastone = (skip_match\n\t\t\t|| got_int\n\t\t\t|| got_quit\n\t\t\t|| lnum > line2\n\t\t\t|| !(subflags.do_all || do_again)\n\t\t\t|| (sub_firstline[matchcol] == NUL && nmatch <= 1\n\t\t\t\t\t && !re_multiline(regmatch.regprog)));\n\t\tnmatch = -1;\n\n\t\t\/*\n\t\t * Replace the line in the buffer when needed.  This is\n\t\t * skipped when there are more matches.\n\t\t * The check for nmatch_tl is needed for when multi-line\n\t\t * matching must replace the lines before trying to do another\n\t\t * match, otherwise \"\\@<=\" won't work.\n\t\t * When the match starts below where we start searching also\n\t\t * need to replace the line first (using \\zs after \\n).\n\t\t *\/\n\t\tif (lastone\n\t\t\t|| nmatch_tl > 0\n\t\t\t|| (nmatch = vim_regexec_multi(®match, curwin,\n\t\t\t\t\t\t\tcurbuf, sub_firstlnum,\n\t\t\t\t\t\t    matchcol, NULL, NULL)) == 0\n\t\t\t|| regmatch.startpos[0].lnum > 0)\n\t\t{\n\t\t    if (new_start != NULL)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Copy the rest of the line, that didn't match.\n\t\t\t * \"matchcol\" has to be adjusted, we use the end of\n\t\t\t * the line as reference, because the substitute may\n\t\t\t * have changed the number of characters.  Same for\n\t\t\t * \"prev_matchcol\".\n\t\t\t *\/\n\t\t\tSTRCAT(new_start, sub_firstline + copycol);\n\t\t\tmatchcol = (colnr_T)STRLEN(sub_firstline) - matchcol;\n\t\t\tprev_matchcol = (colnr_T)STRLEN(sub_firstline)\n\t\t\t\t\t\t\t      - prev_matchcol;\n\n\t\t\tif (u_savesub(lnum) != OK)\n\t\t\t    break;\n\t\t\tml_replace(lnum, new_start, TRUE);\n\n\t\t\tif (nmatch_tl > 0)\n\t\t\t{\n\t\t\t    \/*\n\t\t\t     * Matched lines have now been substituted and are\n\t\t\t     * useless, delete them.  The part after the match\n\t\t\t     * has been appended to new_start, we don't need\n\t\t\t     * it in the buffer.\n\t\t\t     *\/\n\t\t\t    ++lnum;\n\t\t\t    if (u_savedel(lnum, nmatch_tl) != OK)\n\t\t\t\tbreak;\n\t\t\t    for (i = 0; i < nmatch_tl; ++i)\n\t\t\t\tml_delete(lnum);\n\t\t\t    mark_adjust(lnum, lnum + nmatch_tl - 1,\n\t\t\t\t\t\t   (long)MAXLNUM, -nmatch_tl);\n\t\t\t    if (subflags.do_ask)\n\t\t\t\tdeleted_lines(lnum, nmatch_tl);\n\t\t\t    --lnum;\n\t\t\t    line2 -= nmatch_tl; \/\/ nr of lines decreases\n\t\t\t    nmatch_tl = 0;\n\t\t\t}\n\n\t\t\t\/\/ When asking, undo is saved each time, must also set\n\t\t\t\/\/ changed flag each time.\n\t\t\tif (subflags.do_ask)\n\t\t\t    changed_bytes(lnum, 0);\n\t\t\telse\n\t\t\t{\n\t\t\t    if (first_line == 0)\n\t\t\t\tfirst_line = lnum;\n\t\t\t    last_line = lnum + 1;\n\t\t\t}\n\n\t\t\tsub_firstlnum = lnum;\n\t\t\tvim_free(sub_firstline);    \/\/ free the temp buffer\n\t\t\tsub_firstline = new_start;\n\t\t\tnew_start = NULL;\n\t\t\tmatchcol = (colnr_T)STRLEN(sub_firstline) - matchcol;\n\t\t\tprev_matchcol = (colnr_T)STRLEN(sub_firstline)\n\t\t\t\t\t\t\t      - prev_matchcol;\n\t\t\tcopycol = 0;\n\t\t    }\n\t\t    if (nmatch == -1 && !lastone)\n\t\t\tnmatch = vim_regexec_multi(®match, curwin, curbuf,\n\t\t\t\t\t  sub_firstlnum, matchcol, NULL, NULL);\n\n\t\t    \/*\n\t\t     * 5. break if there isn't another match in this line\n\t\t     *\/\n\t\t    if (nmatch <= 0)\n\t\t    {\n\t\t\t\/\/ If the match found didn't start where we were\n\t\t\t\/\/ searching, do the next search in the line where we\n\t\t\t\/\/ found the match.\n\t\t\tif (nmatch == -1)\n\t\t\t    lnum -= regmatch.startpos[0].lnum;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\n\t\tline_breakcheck();\n\t    }\n\n\t    if (did_sub)\n\t\t++sub_nlines;\n\t    vim_free(new_start);\t\/\/ for when substitute was cancelled\n\t    VIM_CLEAR(sub_firstline);\t\/\/ free the copy of the original line\n\t}\n\n\tline_breakcheck();\n    }\n\n    if (first_line != 0)\n    {\n\t\/\/ Need to subtract the number of added lines from \"last_line\" to get\n\t\/\/ the line number before the change (same as adding the number of\n\t\/\/ deleted lines).\n\ti = curbuf->b_ml.ml_line_count - old_line_count;\n\tchanged_lines(first_line, 0, last_line - i, i);\n    }\n\noutofmem:\n    vim_free(sub_firstline); \/\/ may have to free allocated copy of the line\n\n    \/\/ \":s\/pat\/\/n\" doesn't move the cursor\n    if (subflags.do_count)\n\tcurwin->w_cursor = old_cursor;\n\n    if (sub_nsubs > start_nsubs)\n    {\n\tif ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)\n\t{\n\t    \/\/ Set the '[ and '] marks.\n\t    curbuf->b_op_start.lnum = eap->line1;\n\t    curbuf->b_op_end.lnum = line2;\n\t    curbuf->b_op_start.col = curbuf->b_op_end.col = 0;\n\t}\n\n\tif (!global_busy)\n\t{\n\t    \/\/ when interactive leave cursor on the match\n\t    if (!subflags.do_ask)\n\t    {\n\t\tif (endcolumn)\n\t\t    coladvance((colnr_T)MAXCOL);\n\t\telse\n\t\t    beginline(BL_WHITE | BL_FIX);\n\t    }\n\t    if (!do_sub_msg(subflags.do_count) && subflags.do_ask)\n\t\tmsg(\"\");\n\t}\n\telse\n\t    global_need_beginline = TRUE;\n\tif (subflags.do_print)\n\t    print_line(curwin->w_cursor.lnum,\n\t\t\t\t\t subflags.do_number, subflags.do_list);\n    }\n    else if (!global_busy)\n    {\n\tif (got_int)\t\t\/\/ interrupted\n\t    emsg(_(e_interrupted));\n\telse if (got_match)\t\/\/ did find something but nothing substituted\n\t    msg(\"\");\n\telse if (subflags.do_error)\t\/\/ nothing found\n\t    semsg(_(e_pattern_not_found_str), get_search_pat());\n    }\n\n#ifdef FEAT_FOLDING\n    if (subflags.do_ask && hasAnyFolding(curwin))\n\t\/\/ Cursor position may require updating\n\tchanged_window_setting();\n#endif\n\n    vim_regfree(regmatch.regprog);\n\n    \/\/ Restore the flag values, they can be used for \":&&\".\n    subflags.do_all = save_do_all;\n    subflags.do_ask = save_do_ask;\n}","target":1,"code_token_length":9333,"total_token_length":9569,"max_tokens_setting":11000}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..259183e1e2f1d2853852a83dc81dcfc9a913e21c
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:41f09969b6f5a8f5bd39792866400881ba7cdc9a2d86c2c041ca8d7f0179b730
+size 218568
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_stats.json b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_stats.json
new file mode 100644
index 0000000000000000000000000000000000000000..7ff2a337ef455fec2ea2e08f8a5d6d8ad78e51f7
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_stats.json
@@ -0,0 +1,47 @@
+{
+  "total": 10000,
+  "processed": 9999,
+  "skipped": 1,
+  "categories": {
+    "under_512": {
+      "count": 7000,
+      "percentage": 70.0,
+      "max_tokens_setting": 512
+    },
+    "512_to_1024": {
+      "count": 2089,
+      "percentage": 20.89,
+      "max_tokens_setting": 1024
+    },
+    "1024_to_2048": {
+      "count": 639,
+      "percentage": 6.39,
+      "max_tokens_setting": 2048
+    },
+    "2048_to_4096": {
+      "count": 183,
+      "percentage": 1.83,
+      "max_tokens_setting": 4096
+    },
+    "4096_to_6144": {
+      "count": 45,
+      "percentage": 0.45,
+      "max_tokens_setting": 6144
+    },
+    "6144_to_8192": {
+      "count": 25,
+      "percentage": 0.25,
+      "max_tokens_setting": 8192
+    },
+    "8192_to_11000": {
+      "count": 8,
+      "percentage": 0.08,
+      "max_tokens_setting": 11000
+    },
+    "11000_to_28000": {
+      "count": 10,
+      "percentage": 0.1,
+      "max_tokens_setting": 28000
+    }
+  }
+}
\ No newline at end of file
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.jsonl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..069c0429ec17dc4baa355399911099f1a1b44e7f
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.jsonl
@@ -0,0 +1,7000 @@
+{"idx":45922,"func":"static FlatView *generate_memory_topology(struct uc_struct *uc, MemoryRegion *mr)\n{\n    int i;\n    FlatView *view;\n\n    view = flatview_new(mr);\n\n    if (mr) {\n        render_memory_region(view, mr, int128_zero(),\n                             addrrange_make(int128_zero(), int128_2_64()),\n                             false);\n    }\n    flatview_simplify(view);\n\n    view->dispatch = address_space_dispatch_new(uc, view);\n    for (i = 0; i < view->nr; i++) {\n        MemoryRegionSection mrs =\n            section_from_flat_range(&view->ranges[i], view);\n        flatview_add_to_dispatch(uc, view, &mrs);\n    }\n    address_space_dispatch_compact(view->dispatch);\n    g_hash_table_replace(uc->flat_views, mr, view);\n\n    return view;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":391645,"func":"xmlNodeGetLang(const xmlNode *cur) {\n    xmlChar *lang;\n\n    if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))\n        return(NULL);\n    while (cur != NULL) {\n        lang = xmlGetNsProp(cur, BAD_CAST \"lang\", XML_XML_NAMESPACE);\n\tif (lang != NULL)\n\t    return(lang);\n\tcur = cur->parent;\n    }\n    return(NULL);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":102824,"func":"static inline loff_t *io_kiocb_update_pos(struct io_kiocb *req)\n{\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\n\tif (kiocb->ki_pos != -1)\n\t\treturn &kiocb->ki_pos;\n\n\tif (!(req->file->f_mode & FMODE_STREAM)) {\n\t\treq->flags |= REQ_F_CUR_POS;\n\t\tkiocb->ki_pos = req->file->f_pos;\n\t\treturn &kiocb->ki_pos;\n\t}\n\n\tkiocb->ki_pos = 0;\n\treturn NULL;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":310188,"func":"nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lock *lock)\n{\n\tstruct xdr_stream *xdr = &resp->xdr;\n\n\tif (!nfserr)\n\t\tnfserr = nfsd4_encode_stateid(xdr, &lock->lk_resp_stateid);\n\telse if (nfserr == nfserr_denied)\n\t\tnfserr = nfsd4_encode_lock_denied(xdr, &lock->lk_denied);\n\n\treturn nfserr;\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":58465,"func":"int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)\n\n{\n\n    const char *id = qdict_get_str(qdict, \"id\");\n\n    VLANClientState *vc;\n\n\n\n    vc = qemu_find_netdev(id);\n\n    if (!vc || vc->info->type == NET_CLIENT_TYPE_NIC) {\n\n        qerror_report(QERR_DEVICE_NOT_FOUND, id);\n\n        return -1;\n\n    }\n\n    if (vc->peer) {\n\n        qerror_report(QERR_DEVICE_IN_USE, id);\n\n        return -1;\n\n    }\n\n    qemu_del_vlan_client(vc);\n\n    qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id));\n\n    return 0;\n\n}\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":212165,"func":"void GLES2DecoderImpl::DoCommitOverlayPlanes(uint64_t swap_id,\n                                             GLbitfield flags) {\n  TRACE_EVENT0(\"gpu\", \"GLES2DecoderImpl::DoCommitOverlayPlanes\");\n  if (!supports_commit_overlay_planes_) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, \"glCommitOverlayPlanes\",\n                       \"command not supported by surface\");\n    return;\n  }\n  ClearScheduleCALayerState();\n  if (supports_async_swap_) {\n    client()->OnSwapBuffers(swap_id, flags);\n    surface_->CommitOverlayPlanesAsync(\n        base::BindOnce(&GLES2DecoderImpl::FinishAsyncSwapBuffers,\n                       weak_ptr_factory_.GetWeakPtr(), swap_id),\n        base::DoNothing());\n  } else {\n    client()->OnSwapBuffers(swap_id, flags);\n    FinishSwapBuffers(surface_->CommitOverlayPlanes(base::DoNothing()));\n  }\n}\n","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":469224,"func":"static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr)\n{\n\tstruct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);\n\tstruct xfrm6_tunnel_spi *x6spi;\n\n\thlist_for_each_entry_rcu(x6spi,\n\t\t\t     &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],\n\t\t\t     list_byaddr) {\n\t\tif (xfrm6_addr_equal(&x6spi->addr, saddr))\n\t\t\treturn x6spi;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":254692,"func":"void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) {\n  EnsureWebKitInitialized();\n  RenderViewImpl::Create(params.opener_route_id,\n                         params.window_was_created_with_opener,\n                         params.renderer_preferences,\n                         params.web_preferences,\n                         params.view_id,\n                         params.main_frame_routing_id,\n                         params.surface_id,\n                         params.session_storage_namespace_id,\n                         params.frame_name,\n                         false,\n                         params.swapped_out,\n                         params.proxy_routing_id,\n                         params.hidden,\n                         params.never_visible,\n                         params.next_page_id,\n                         params.screen_info);\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":213977,"func":"::ppapi::TrackerBase* GetTrackerBase() {\n  return ResourceTracker::Get();\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":189788,"func":"void ExtensionTtsController::CheckSpeechStatus() {\n \n  std::set<std::string> desired_event_types;\n  if (options->HasKey(constants::kDesiredEventTypesKey)) {\n    ListValue* list;\n    EXTENSION_FUNCTION_VALIDATE(\n        options->GetList(constants::kDesiredEventTypesKey, &list));\n    for (size_t i = 0; i < list->GetSize(); i++) {\n      std::string event_type;\n      if (!list->GetString(i, &event_type))\n        desired_event_types.insert(event_type);\n    }\n   }\n \n  std::string voice_extension_id;\n  if (options->HasKey(constants::kExtensionIdKey)) {\n    EXTENSION_FUNCTION_VALIDATE(\n        options->GetString(constants::kExtensionIdKey, &voice_extension_id));\n   }\n","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":228382,"func":"static void overloadedPerWorldBindingsMethod1Method(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    imp->overloadedPerWorldBindingsMethod();\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":229961,"func":"e1000e_set_tidv(E1000ECore *core, int index, uint32_t val)\n{\n    e1000e_set_16bit(core, index, val);\n\n    if ((val & E1000_TIDV_FPD) && (core->tidv.running)) {\n        trace_e1000e_irq_tidv_fpd_running();\n        e1000e_intrmgr_fire_delayed_interrupts(core);\n    } else {\n        trace_e1000e_irq_tidv_fpd_not_running();\n    }\n}\n","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":166671,"func":"BluetoothSocketAsyncApiFunction::BluetoothSocketAsyncApiFunction() {}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":456819,"func":"static inline int free_consistency_checks(struct kmem_cache *s,\n\t\tstruct page *page, void *object, unsigned long addr)\n{\n\tif (!check_valid_pointer(s, page, object)) {\n\t\tslab_err(s, page, \"Invalid object pointer 0x%p\", object);\n\t\treturn 0;\n\t}\n\n\tif (on_freelist(s, page, object)) {\n\t\tobject_err(s, page, object, \"Object already free\");\n\t\treturn 0;\n\t}\n\n\tif (!check_object(s, page, object, SLUB_RED_ACTIVE))\n\t\treturn 0;\n\n\tif (unlikely(s != page->slab_cache)) {\n\t\tif (!PageSlab(page)) {\n\t\t\tslab_err(s, page, \"Attempt to free object(0x%p) outside of slab\",\n\t\t\t\t object);\n\t\t} else if (!page->slab_cache) {\n\t\t\tpr_err(\"SLUB <none>: no slab for object 0x%p.\\n\",\n\t\t\t       object);\n\t\t\tdump_stack();\n\t\t} else\n\t\t\tobject_err(s, page, object,\n\t\t\t\t\t\"page slab pointer corrupt.\");\n\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":59101,"func":"sshpkt_get_bignum2(struct ssh *ssh, BIGNUM *v)\n{\n\treturn sshbuf_get_bignum2(ssh->state->incoming_packet, v);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":108380,"func":"static int regex_match_full(char *str, struct regex *r, int len)\n{\n\t\/* len of zero means str is dynamic and ends with '\\0' *\/\n\tif (!len)\n\t\treturn strcmp(str, r->pattern) == 0;\n\n\treturn strncmp(str, r->pattern, len) == 0;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":257516,"func":"static int dissect_h225_h225_RasMessage ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data _U_ ) {\n proto_item * it ;\n proto_tree * tr ;\n guint32 offset = 0 ;\n h225_packet_info * h225_pi ;\n h225_pi = create_h225_packet_info ( pinfo ) ;\n h225_pi -> msg_type = H225_RAS ;\n p_add_proto_data ( wmem_packet_scope ( ) , pinfo , proto_h225 , 0 , h225_pi ) ;\n col_set_str ( pinfo -> cinfo , COL_PROTOCOL , PSNAME ) ;\n it = proto_tree_add_protocol_format ( tree , proto_h225 , tvb , offset , - 1 , PSNAME \" RAS\" ) ;\n tr = proto_item_add_subtree ( it , ett_h225 ) ;\n offset = dissect_RasMessage_PDU ( tvb , pinfo , tr , NULL ) ;\n ras_call_matching ( tvb , pinfo , tr , h225_pi ) ;\n tap_queue_packet ( h225_tap , pinfo , h225_pi ) ;\n return offset ;\n }","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":36555,"func":"static void cbcmac_exit_tfm(struct crypto_tfm *tfm)\n{\n\tstruct cbcmac_tfm_ctx *ctx = crypto_tfm_ctx(tfm);\n\tcrypto_free_cipher(ctx->child);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":97209,"func":"void BinaryProtocolReader::readI32(int32_t& i32) {\n  i32 = in_.readBE<int32_t>();\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":293258,"func":"line_interpt(PG_FUNCTION_ARGS)\n{\n\tLINE\t   *l1 = PG_GETARG_LINE_P(0);\n\tLINE\t   *l2 = PG_GETARG_LINE_P(1);\n\tPoint\t   *result;\n\n\tresult = line_interpt_internal(l1, l2);\n\n\tif (result == NULL)\n\t\tPG_RETURN_NULL();\n\tPG_RETURN_POINT_P(result);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":313274,"func":"bool Dispatcher::IsRuntimeAvailableToContext(ScriptContext* context) {\n  for (const auto& extension :\n       *RendererExtensionRegistry::Get()->GetMainThreadExtensionSet()) {\n    ExternallyConnectableInfo* info = static_cast<ExternallyConnectableInfo*>(\n        extension->GetManifestData(manifest_keys::kExternallyConnectable));\n    if (info && info->matches.MatchesURL(context->url()))\n      return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":305999,"func":"  TensorBuffer* root_buffer() override { return this; }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":103228,"func":"void jpeg_gdIOCtx_dest (j_compress_ptr cinfo, gdIOCtx * outfile)\n{\n\tmy_dest_ptr dest;\n\n\t\/* The destination object is made permanent so that multiple JPEG images\n\t * can be written to the same file without re-executing jpeg_stdio_dest.\n\t * This makes it dangerous to use this manager and a different destination\n\t * manager serially with the same JPEG object, because their private object\n\t * sizes may be different.  Caveat programmer.\n\t *\/\n\tif (cinfo->dest == NULL) { \/* first time for this JPEG object? *\/\n\t\tcinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof (my_destination_mgr));\n\t}\n\n\tdest = (my_dest_ptr) cinfo->dest;\n\tdest->pub.init_destination = init_destination;\n\tdest->pub.empty_output_buffer = empty_output_buffer;\n\tdest->pub.term_destination = term_destination;\n\tdest->outfile = outfile;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":395089,"func":"void FillFirstShaper(cmsS1Fixed14Number* Table, cmsToneCurve* Curve)\n{\n    int i;\n    cmsFloat32Number R, y;\n\n    for (i=0; i < 256; i++) {\n\n        R   = (cmsFloat32Number) (i \/ 255.0);\n        y   = cmsEvalToneCurveFloat(Curve, R);\n\n        if (y < 131072.0)\n            Table[i] = DOUBLE_TO_1FIXED14(y);\n        else\n            Table[i] = 0x7fffffff;\n    }\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":276228,"func":"void Document::writeln(const String& text, Document* ownerDocument)\n{\n    write(text, ownerDocument);\n    write(\"\\n\", ownerDocument);\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":440583,"func":"static u32 eth_hash(const unsigned char *addr)\n{\n\tu64 value = get_unaligned((u64 *)addr);\n\n\t\/* only want 6 bytes *\/\n#ifdef __BIG_ENDIAN\n\tvalue >>= 16;\n#else\n\tvalue <<= 16;\n#endif\n\treturn hash_64(value, FDB_HASH_BITS);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":405857,"func":"port_name_needs_quotes(const char *port_name)\n{\n    if (!isalpha((unsigned char) port_name[0])) {\n        return true;\n    }\n\n    for (const char *p = port_name + 1; *p; p++) {\n        if (!isalnum((unsigned char) *p)) {\n            return true;\n        }\n    }\n    return false;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":423496,"func":"dns_zone_setflag(dns_zone_t *zone, unsigned int flags, bool value) {\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\n\tLOCK_ZONE(zone);\n\tif (value)\n\t\tDNS_ZONE_SETFLAG(zone, flags);\n\telse\n\t\tDNS_ZONE_CLRFLAG(zone, flags);\n\tUNLOCK_ZONE(zone);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":289447,"func":"static const char * hfinfo_number_vals_format64 ( const header_field_info * hfinfo , char buf [ 64 ] , guint64 value ) {\n int display = hfinfo -> display & FIELD_DISPLAY_E_MASK ;\n if ( display == BASE_NONE ) return NULL ;\n if ( display == BASE_DEC_HEX ) display = BASE_DEC ;\n if ( display == BASE_HEX_DEC ) display = BASE_HEX ;\n return hfinfo_number_value_format_display64 ( hfinfo , display , buf , value ) ;\n }","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":68768,"func":"PHP_FUNCTION(imagealphablending)\n{\n\tzval *IM;\n\tzend_bool blend;\n\tgdImagePtr im;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rb\", &IM, &blend) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\tgdImageAlphaBlending(im, blend);\n\n\tRETURN_TRUE;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":216799,"func":"V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, Node* node, v8::Isolate* isolate)\n    : V8AbstractEventListener(true, DOMWrapperWorld::mainWorld(), isolate)\n    , m_functionName(functionName)\n    , m_eventParameterName(eventParameterName)\n    , m_code(code)\n    , m_sourceURL(sourceURL)\n    , m_node(node)\n    , m_position(position)\n{\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":12729,"func":" Blob::Blob(const KURL& srcURL, const String& type, long long size)\n    : m_type(type)\n    , m_size(size)\n{\n    ScriptWrappable::init(this);\n \n     m_internalURL = BlobURL::createInternalURL();\n    ThreadableBlobRegistry::registerBlobURL(0, m_internalURL, srcURL);\n }\n","target":1,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":242216,"func":"void ScriptController::clearForOutOfMemory()\n{\n    clearForClose(true);\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":153455,"func":"static int trace_die_handler(struct notifier_block *self,\n\t\t\t     unsigned long val,\n\t\t\t     void *data)\n{\n\tswitch (val) {\n\tcase DIE_OOPS:\n\t\tif (ftrace_dump_on_oops)\n\t\t\tftrace_dump(ftrace_dump_on_oops);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn NOTIFY_OK;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":269765,"func":"decode_NXAST_RAW_FIN_TIMEOUT(const struct nx_action_fin_timeout *naft,\n                             enum ofp_version ofp_version OVS_UNUSED,\n                             struct ofpbuf *out)\n{\n    struct ofpact_fin_timeout *oft;\n\n    oft = ofpact_put_FIN_TIMEOUT(out);\n    oft->fin_idle_timeout = ntohs(naft->fin_idle_timeout);\n    oft->fin_hard_timeout = ntohs(naft->fin_hard_timeout);\n    return 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":272830,"func":"IdentPtrList* Parser::EnsureRequestedModulesList()\n{\n    if (m_currentNodeProg->sxModule.requestedModules == nullptr)\n    {\n        m_currentNodeProg->sxModule.requestedModules = Anew(&m_nodeAllocator, IdentPtrList, &m_nodeAllocator);\n    }\n    return m_currentNodeProg->sxModule.requestedModules;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":511891,"func":"make_func_export_array ()\n{\n  char **list;\n  SHELL_VAR **vars;\n\n  vars = map_over_funcs (visible_and_exported);\n  if (vars == 0)\n    return (char **)NULL;\n\n  list = make_env_array_from_var_list (vars);\n\n  free (vars);\n  return (list);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":174662,"func":"JSValue JSTestEventTarget::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)\n{\n    JSTestEventTarget* thisObj = jsCast<JSTestEventTarget*>(asObject(slotBase));\n    ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);\n    return toJS(exec, thisObj->globalObject(), static_cast<TestEventTarget*>(thisObj->impl())->item(index));\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":115125,"func":"static int session_call_on_frame_received(nghttp2_session *session,\n                                          nghttp2_frame *frame) {\n  int rv;\n  if (session->callbacks.on_frame_recv_callback) {\n    rv = session->callbacks.on_frame_recv_callback(session, frame,\n                                                   session->user_data);\n    if (rv != 0) {\n      return NGHTTP2_ERR_CALLBACK_FAILURE;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":307509,"func":"std::vector<RenderWidgetHostView*> GetInputEventRouterRenderWidgetHostViews(\n    WebContents* web_contents) {\n  return static_cast<WebContentsImpl*>(web_contents)\n      ->GetInputEventRouter()\n      ->GetRenderWidgetHostViewsForTests();\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":391836,"func":"PHP_METHOD(Phar, getSupportedSignatures)\n{\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tarray_init(return_value);\n\n\tadd_next_index_stringl(return_value, \"MD5\", 3);\n\tadd_next_index_stringl(return_value, \"SHA-1\", 5);\n#ifdef PHAR_HASH_OK\n\tadd_next_index_stringl(return_value, \"SHA-256\", 7);\n\tadd_next_index_stringl(return_value, \"SHA-512\", 7);\n#endif\n#if PHAR_HAVE_OPENSSL\n\tadd_next_index_stringl(return_value, \"OpenSSL\", 7);\n#else\n\tif (zend_hash_str_exists(&module_registry, \"openssl\", sizeof(\"openssl\")-1)) {\n\t\tadd_next_index_stringl(return_value, \"OpenSSL\", 7);\n\t}\n#endif\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":238368,"func":"    OVS_REQUIRES(ofproto_mutex)\n{\n    struct rule_collection *old_rules = &ofm->old_rules;\n    enum ofperr error;\n\n    error = collect_rules_loose(ofproto, &ofm->criteria, old_rules);\n\n    if (!error) {\n        error = modify_flows_start__(ofproto, ofm);\n    }\n\n    if (error) {\n        rule_collection_destroy(old_rules);\n    }\n\n    return error;\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":438310,"func":"  uint64_t max_block_additional_id() const { return max_block_additional_id_; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":483841,"func":"bool device_is_bound(struct device *dev)\n{\n\treturn dev->p && klist_node_attached(&dev->p->knode_driver);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":443515,"func":"static void window_reset(struct psi_window *win, u64 now, u64 value,\n\t\t\t u64 prev_growth)\n{\n\twin->start_time = now;\n\twin->start_value = value;\n\twin->prev_growth = prev_growth;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":510338,"func":"Item *Item_static_float_func::safe_charset_converter(CHARSET_INFO *tocs)\n{\n  Item_string *conv;\n  char buf[64];\n  String *s, tmp(buf, sizeof(buf), &my_charset_bin);\n  s= val_str(&tmp);\n  if ((conv= new Item_static_string_func(func_name, s->ptr(), s->length(),\n                                         s->charset())))\n  {\n    conv->str_value.copy();\n    conv->str_value.mark_as_const();\n  }\n  return conv;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":210766,"func":"int32_t WebPage::finishComposition()\n{\n    return d->m_inputHandler->finishComposition();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":184817,"func":"void GpuProcessHost::OnAcceleratedSurfaceSuspend(int32 surface_id) {\n  TRACE_EVENT0(\"gpu\", \"GpuProcessHost::OnAcceleratedSurfaceSuspend\");\n\n  gfx::PluginWindowHandle handle =\n      GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(surface_id);\n  if (!handle)\n    return;\n\n  scoped_refptr<AcceleratedPresenter> presenter(\n      AcceleratedPresenter::GetForWindow(handle));\n  if (!presenter)\n    return;\n\n  presenter->Suspend();\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":384997,"func":"static PHP_FUNCTION(xmlwriter_full_end_element)\n{\n\tphp_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterFullEndElement);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":269942,"func":"void __init inode_init(void)\n{\n\t\/* inode slab cache *\/\n\tinode_cachep = kmem_cache_create(\"inode_cache\",\n\t\t\t\t\t sizeof(struct inode),\n\t\t\t\t\t 0,\n\t\t\t\t\t (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|\n\t\t\t\t\t SLAB_MEM_SPREAD|SLAB_ACCOUNT),\n\t\t\t\t\t init_once);\n\n\t\/* Hash may have been set up in inode_init_early *\/\n\tif (!hashdist)\n\t\treturn;\n\n\tinode_hashtable =\n\t\talloc_large_system_hash(\"Inode-cache\",\n\t\t\t\t\tsizeof(struct hlist_head),\n\t\t\t\t\tihash_entries,\n\t\t\t\t\t14,\n\t\t\t\t\tHASH_ZERO,\n\t\t\t\t\t&i_hash_shift,\n\t\t\t\t\t&i_hash_mask,\n\t\t\t\t\t0,\n\t\t\t\t\t0);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":106055,"func":"validate_maphash(void)\n{\n    if (!maphash_valid)\n    {\n\tvim_memset(maphash, 0, sizeof(maphash));\n\tmaphash_valid = TRUE;\n    }\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":464445,"func":"static void tipc_node_delete_from_list(struct tipc_node *node)\n{\n#ifdef CONFIG_TIPC_CRYPTO\n\ttipc_crypto_key_flush(node->crypto_rx);\n#endif\n\tlist_del_rcu(&node->list);\n\thlist_del_rcu(&node->hash);\n\ttipc_node_put(node);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":294837,"func":"static int lua_apr_b64decode(lua_State *L)\n{\n    const char     *encoded;\n    char           *plain;\n    size_t          encoded_len, decoded_len;\n    request_rec    *r;\n\n    r = ap_lua_check_request_rec(L, 1);\n    luaL_checktype(L, 2, LUA_TSTRING);\n    encoded = lua_tolstring(L, 2, &encoded_len);\n    decoded_len = apr_base64_decode_len(encoded);\n    if (decoded_len) {\n        plain = apr_palloc(r->pool, decoded_len);\n        decoded_len = apr_base64_decode(plain, encoded);\n        if (decoded_len > 0 && plain[decoded_len - 1] == '\\0')\n            decoded_len--; \n        lua_pushlstring(L, plain, decoded_len);\n        return 1;\n    }\n    return 0;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":15057,"func":"static void srtp_calc_aead_iv_srtcp ( srtp_stream_ctx_t * stream , v128_t * iv , uint32_t seq_num , srtcp_hdr_t * hdr ) {\n v128_t in ;\n v128_t salt ;\n memset ( & in , 0 , sizeof ( v128_t ) ) ;\n memset ( & salt , 0 , sizeof ( v128_t ) ) ;\n in . v16 [ 0 ] = 0 ;\n memcpy ( & in . v16 [ 1 ] , & hdr -> ssrc , 4 ) ;\n in . v16 [ 3 ] = 0 ;\n in . v32 [ 2 ] = 0x7FFFFFFF & htonl ( seq_num ) ;\n debug_print ( mod_srtp , \"Pre-salted RTCP IV = %s\\n\" , v128_hex_string ( & in ) ) ;\n memcpy ( salt . v8 , stream -> c_salt , 12 ) ;\n debug_print ( mod_srtp , \"RTCP SALT = %s\\n\" , v128_hex_string ( & salt ) ) ;\n v128_xor ( iv , & in , & salt ) ;\n }","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":266789,"func":"bool_t ipv6IsAnycastAddr(NetInterface *interface, const Ipv6Addr *ipAddr)\n{\n   uint_t i;\n   Ipv6Addr *anycastAddrList;\n\n   \/\/Point to the list of anycast addresses assigned to the interface\n   anycastAddrList = interface->ipv6Context.anycastAddrList;\n\n   \/\/Loop through the list of IPv6 anycast addresses\n   for(i = 0; i < IPV6_ANYCAST_ADDR_LIST_SIZE; i++)\n   {\n      \/\/Valid entry?\n      if(!ipv6CompAddr(&anycastAddrList[i], &IPV6_UNSPECIFIED_ADDR))\n      {\n         \/\/Check whether the specified address matches a valid anycast\n         \/\/address assigned to the interface\n         if(ipv6CompAddr(&anycastAddrList[i], ipAddr))\n         {\n            \/\/The specified IPv6 address is an anycast address\n            return TRUE;\n         }\n      }\n   }\n\n   \/\/The specified IPv6 address is not an anycast address\n   return FALSE;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":63246,"func":"int _cdk_sk_get_csum(cdk_pkt_seckey_t sk)\n{\n\tu16 csum = 0, i;\n\n\tif (!sk)\n\t\treturn 0;\n\tfor (i = 0; i < cdk_pk_get_nskey(sk->pubkey_algo); i++)\n\t\tcsum += checksum_mpi(sk->mpi[i]);\n\treturn csum;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":442705,"func":"static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)\n{\n\t__u8 status = *((__u8 *) skb->data);\n\n\tBT_DBG(\"%s status 0x%2.2x\", hdev->name, status);\n\n\tclear_bit(HCI_RESET, &hdev->flags);\n\n\tif (status)\n\t\treturn;\n\n\t\/* Reset all non-persistent flags *\/\n\thci_dev_clear_volatile_flags(hdev);\n\n\thci_discovery_set_state(hdev, DISCOVERY_STOPPED);\n\n\thdev->inq_tx_power = HCI_TX_POWER_INVALID;\n\thdev->adv_tx_power = HCI_TX_POWER_INVALID;\n\n\tmemset(hdev->adv_data, 0, sizeof(hdev->adv_data));\n\thdev->adv_data_len = 0;\n\n\tmemset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data));\n\thdev->scan_rsp_data_len = 0;\n\n\thdev->le_scan_type = LE_SCAN_PASSIVE;\n\n\thdev->ssp_debug_mode = 0;\n\n\thci_bdaddr_list_clear(&hdev->le_white_list);\n\thci_bdaddr_list_clear(&hdev->le_resolv_list);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":30052,"func":"void EVP_EncodeFinal ( EVP_ENCODE_CTX * ctx , unsigned char * out , int * outl ) {\n unsigned int ret = 0 ;\n if ( ctx -> num != 0 ) {\n ret = EVP_EncodeBlock ( out , ctx -> enc_data , ctx -> num ) ;\n out [ ret ++ ] = '\\n' ;\n out [ ret ] = '\\0' ;\n ctx -> num = 0 ;\n }\n * outl = ret ;\n }","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":143086,"func":"void fx_TypedArray_prototype_reduceRight(txMachine* the)\n{\n\tmxTypedArrayDeclarations;\n\ttxInteger delta = dispatch->value.typedArray.dispatch->size;\n\ttxSlot* function = fxArgToCallback(the, 0);\n\ttxInteger index = length - 1;\n\tif (mxArgc > 1)\n\t\t*mxResult = *mxArgv(1);\n\telse if (index >= 0) {\n\t\t(*dispatch->value.typedArray.dispatch->getter)(the, buffer->value.reference->next, view->value.dataView.offset + (index * delta), mxResult, EndianNative);\n\t\tindex--;\n\t}\n\telse\n\t\tmxTypeError(\"no initial value\");\n\twhile (index >= 0) {\n\t\tfxReduceTypedArrayItem(the, function, dispatch, view, buffer->value.reference->next, index);\n\t\tindex--;\n\t}\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":465611,"func":"static void sctp_sendmsg_update_sinfo(struct sctp_association *asoc,\n\t\t\t\t      struct sctp_sndrcvinfo *sinfo,\n\t\t\t\t      struct sctp_cmsgs *cmsgs)\n{\n\tif (!cmsgs->srinfo && !cmsgs->sinfo) {\n\t\tsinfo->sinfo_stream = asoc->default_stream;\n\t\tsinfo->sinfo_ppid = asoc->default_ppid;\n\t\tsinfo->sinfo_context = asoc->default_context;\n\t\tsinfo->sinfo_assoc_id = sctp_assoc2id(asoc);\n\n\t\tif (!cmsgs->prinfo)\n\t\t\tsinfo->sinfo_flags = asoc->default_flags;\n\t}\n\n\tif (!cmsgs->srinfo && !cmsgs->prinfo)\n\t\tsinfo->sinfo_timetolive = asoc->default_timetolive;\n\n\tif (cmsgs->authinfo) {\n\t\t\/* Reuse sinfo_tsn to indicate that authinfo was set and\n\t\t * sinfo_ssn to save the keyid on tx path.\n\t\t *\/\n\t\tsinfo->sinfo_tsn = 1;\n\t\tsinfo->sinfo_ssn = cmsgs->authinfo->auth_keynumber;\n\t}\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":25666,"func":"void notef ( struct GlobalConfig * config , const char * fmt , ... ) {\n va_list ap ;\n va_start ( ap , fmt ) ;\n if ( config -> tracetype ) voutf ( config , NOTE_PREFIX , fmt , ap ) ;\n va_end ( ap ) ;\n }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":223503,"func":"  void FileSelectionCanceled() {\n    proxy_ = nullptr;\n    if (!render_frame_host_)\n      return;\n    std::move(callback_).Run(nullptr);\n  }\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":281983,"func":"EncodedJSValue JSC_HOST_CALL JSDataViewConstructor::constructJSDataView(ExecState* exec)\n{\n    if (exec->argument(0).isNull() || !exec->argument(0).isObject())\n        return throwVMTypeError(exec);\n\n    RefPtr<DataView> view = constructArrayBufferViewWithArrayBufferArgument<DataView, char>(exec);\n    if (!view.get()) {\n        setDOMException(exec, INDEX_SIZE_ERR);\n        return JSValue::encode(jsUndefined());\n    }\n\n    JSDataViewConstructor* jsConstructor = jsCast<JSDataViewConstructor*>(exec->callee());\n    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), view.get())));\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":228204,"func":" void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {\n  TRACE_EVENT1(\"evdev\",\n               \"TouchEventConverterEvdev::OnFileCanReadWithoutBlocking\", \"fd\",\n               fd);\n\n   input_event inputs[kNumTouchEvdevSlots * 6 + 1];\n   ssize_t read_size = read(fd, inputs, sizeof(inputs));\n   if (read_size < 0) {\n    if (errno == EINTR || errno == EAGAIN)\n      return;\n    if (errno != ENODEV)\n      PLOG(ERROR) << \"error reading device \" << path_.value();\n    Stop();\n    return;\n  }\n\n  if (ignore_events_)\n    return;\n\n  for (unsigned i = 0; i < read_size \/ sizeof(*inputs); i++) {\n    if (!has_mt_) {\n      EmulateMultitouchEvent(inputs[i]);\n    }\n\n    ProcessMultitouchEvent(inputs[i]);\n  }\n}\n","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":156833,"func":"void free_cache_bitmap_v2_order(rdpContext* context, CACHE_BITMAP_V2_ORDER* order)\n{\n\tif (order)\n\t\tfree(order->bitmapDataStream);\n\n\tfree(order);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":123611,"func":"static void init_threaded_search(void)\n{\n\tinit_recursive_mutex(&read_mutex);\n\tpthread_mutex_init(&cache_mutex, NULL);\n\tpthread_mutex_init(&progress_mutex, NULL);\n\tpthread_cond_init(&progress_cond, NULL);\n\told_try_to_free_routine = set_try_to_free_routine(try_to_free_from_threads);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":158948,"func":"lyp_check_mandatory_choice(struct lys_node *node)\n{\n    const struct lys_node *mand, *dflt = ((struct lys_node_choice *)node)->dflt;\n\n    if ((mand = lyp_check_mandatory_(dflt))) {\n        if (mand != dflt) {\n            LOGVAL(node->module->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, \"mandatory\");\n            LOGVAL(node->module->ctx, LYE_SPEC, LY_VLOG_NONE, NULL,\n                   \"Mandatory node \\\"%s\\\" is directly under the default case \\\"%s\\\" of the \\\"%s\\\" choice.\",\n                   mand->name, dflt->name, node->name);\n            return -1;\n        }\n        return EXIT_FAILURE;\n    }\n\n    return EXIT_SUCCESS;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":448027,"func":"int sftp_reply_names_add(sftp_client_message msg, const char *file,\n    const char *longname, sftp_attributes attr) {\n  ssh_string name;\n\n  name = ssh_string_from_char(file);\n  if (name == NULL) {\n    return -1;\n  }\n\n  if (msg->attrbuf == NULL) {\n    msg->attrbuf = ssh_buffer_new();\n    if (msg->attrbuf == NULL) {\n      SSH_STRING_FREE(name);\n      return -1;\n    }\n  }\n\n  if (ssh_buffer_add_ssh_string(msg->attrbuf, name) < 0) {\n    SSH_STRING_FREE(name);\n    return -1;\n  }\n\n  SSH_STRING_FREE(name);\n  name = ssh_string_from_char(longname);\n  if (name == NULL) {\n    return -1;\n  }\n  if (ssh_buffer_add_ssh_string(msg->attrbuf,name) < 0 ||\n      buffer_add_attributes(msg->attrbuf,attr) < 0) {\n    SSH_STRING_FREE(name);\n    return -1;\n  }\n  SSH_STRING_FREE(name);\n  msg->attr_num++;\n\n  return 0;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":208191,"func":"void setJSTestObjUnsignedShortSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value)\n{\n    JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject);\n    TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n    impl->setUnsignedShortSequenceAttr(toNativeArray<unsigned short>(exec, value));\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":336267,"func":"void msix_unuse_all_vectors(PCIDevice *dev)\n\n{\n\n    if (!(dev->cap_present & QEMU_PCI_CAP_MSIX))\n\n        return;\n\n    msix_free_irq_entries(dev);\n\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":4700,"func":"bool HHVM_FUNCTION(apc_clear_cache, const String& \/*cache_type*\/ \/* = \"\" *\/) {\n  if (!apcExtension::Enable) return false;\n  return apc_store().clear();\n}","target":1,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":79310,"func":"SQLiteDBInstanceRef SQLiteDBManager::getUnique() {\n  auto instance = std::make_shared<SQLiteDBInstance>();\n  attachVirtualTables(instance);\n  return instance;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":293031,"func":"static struct user_ta_elf *find_ta_elf(const TEE_UUID *uuid,\n\t\t\t\t       struct user_ta_ctx *utc)\n{\n\tstruct user_ta_elf *elf;\n\n\tTAILQ_FOREACH(elf, &utc->elfs, link)\n\t\tif (!memcmp(&elf->uuid, uuid, sizeof(*uuid)))\n\t\t\treturn elf;\n\treturn NULL;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":516535,"func":"close_mysql_tables(THD *thd)\n{\n  if (! thd->in_sub_stmt)\n    trans_commit_stmt(thd);\n  close_thread_tables(thd);\n  thd->release_transactional_locks();\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":245832,"func":"DOMTokenList* HTMLIFrameElement::sandbox() const {\n  return sandbox_.Get();\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":286219,"func":"ui::AXNode* FindNodeWithChildTreeId(ui::AXNode* node, int child_tree_id) {\n  if (child_tree_id == node->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID))\n    return node;\n\n  for (int i = 0; i < node->child_count(); ++i) {\n    ui::AXNode* result =\n        FindNodeWithChildTreeId(node->ChildAtIndex(i), child_tree_id);\n    if (result)\n      return result;\n  }\n\n  return nullptr;\n}\n","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":503983,"func":"static int _sqlite_commit_txn(void *db, const sasl_utils_t *utils)\n{\n    return _sqlite_exec(db, \"COMMIT TRANSACTION\", NULL, 0, NULL, utils);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":396312,"func":"static void emit(JF, int value)\n{\n\temitraw(J, F, value);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":113348,"func":"    OVS_REQUIRES(ipf->ipf_lock)\n{\n    struct ipf_list *ipf_list;\n    HMAP_FOR_EACH_WITH_HASH (ipf_list, node, hash, &ipf->frag_lists) {\n        if (ipf_list_key_eq(&ipf_list->key, key)) {\n            return ipf_list;\n        }\n    }\n    return NULL;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":161371,"func":"ImagingTiffVersion(void)\n{\n    return TIFFGetVersion();\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":301016,"func":"GF_Err dmax_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":173260,"func":"static int sched_rt_global_constraints(void)\n{\n\tunsigned long flags;\n\tint i;\n\n\traw_spin_lock_irqsave(&def_rt_bandwidth.rt_runtime_lock, flags);\n\tfor_each_possible_cpu(i) {\n\t\tstruct rt_rq *rt_rq = &cpu_rq(i)->rt;\n\n\t\traw_spin_lock(&rt_rq->rt_runtime_lock);\n\t\trt_rq->rt_runtime = global_rt_runtime();\n\t\traw_spin_unlock(&rt_rq->rt_runtime_lock);\n\t}\n\traw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);\n\n\treturn 0;\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":395193,"func":"create_info_message_area (const gchar                 *primary_text,\n\t\t\t  const gchar                 *secondary_text,\n\t\t\t  EogErrorMessageAreaButtons   buttons)\n{\n\tGtkWidget *message_area;\n\n\t\/* create a new message area *\/\n\tmessage_area = gtk_info_bar_new ();\n\n\t\/* add requested buttons to the message area *\/\n\tadd_message_area_buttons (message_area, buttons);\n\n\t\/* set message type *\/\n\tgtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),\n\t\t\t\t       GTK_MESSAGE_INFO);\n\n\t\/* set text and icon *\/\n\tset_message_area_text_and_icon (GTK_INFO_BAR (message_area),\n\t\t\t\t\t\"dialog-information\",\n\t\t\t\t\tprimary_text,\n\t\t\t\t\tsecondary_text);\n\n\treturn message_area;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":478368,"func":"    CImg<T>& select(CImgDisplay &disp,\n                    const unsigned int feature_type=2, unsigned int *const XYZ=0,\n                    const bool exit_on_anykey=false,\n                    const bool is_deep_selection_default=false) {\n      return get_select(disp,feature_type,XYZ,exit_on_anykey,is_deep_selection_default).move_to(*this);\n    }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":69221,"func":"\n      static double mp_cut(_cimg_math_parser& mp) {\n        double val = _mp_arg(2), cmin = _mp_arg(3), cmax = _mp_arg(4);\n        return val<cmin?cmin:val>cmax?cmax:val;","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":328420,"func":"static SlirpState *slirp_lookup(Monitor *mon, const char *vlan,\n\n                                const char *stack)\n\n{\n\n    VLANClientState *vc;\n\n\n\n    if (vlan) {\n\n        vc = qemu_find_vlan_client_by_name(mon, strtol(vlan, NULL, 0), stack);\n\n        if (!vc) {\n\n            return NULL;\n\n        }\n\n        if (strcmp(vc->model, \"user\")) {\n\n            monitor_printf(mon, \"invalid device specified\\n\");\n\n            return NULL;\n\n        }\n\n        return vc->opaque;\n\n    } else {\n\n        if (TAILQ_EMPTY(&slirp_stacks)) {\n\n            monitor_printf(mon, \"user mode network stack not in use\\n\");\n\n            return NULL;\n\n        }\n\n        return TAILQ_FIRST(&slirp_stacks);\n\n    }\n\n}\n","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":297367,"func":"static int vmci_transport_reply_reset(struct vmci_transport_packet *pkt)\n{\n\treturn vmci_transport_reply_control_pkt_fast(\n\t\t\t\t\t\tpkt,\n\t\t\t\t\t\tVMCI_TRANSPORT_PACKET_TYPE_RST,\n\t\t\t\t\t\t0, 0, NULL,\n\t\t\t\t\t\tVMCI_INVALID_HANDLE);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":283078,"func":"void InlineTextBox::computeRectForReplacementMarker(int \/*tx*\/, int \/*ty*\/, const DocumentMarker& marker, RenderStyle* style, const Font& font)\n{\n    int y = selectionTop();\n    int h = selectionHeight();\n    \n    int sPos = max(marker.startOffset - m_start, (unsigned)0);\n    int ePos = min(marker.endOffset - m_start, (unsigned)m_len);    \n    TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());\n    IntPoint startPoint = IntPoint(m_x, y);\n    \n    IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, h, sPos, ePos));\n    markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();\n    renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);\n}\n","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":332075,"func":"static void bdrv_cow_init(void)\n\n{\n\n    bdrv_register(&bdrv_cow);\n\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":496665,"func":"TEST_P(Security, BuiltinAuthenticationAndAccessAndCryptoPlugin_PermissionsEnableDiscoveryDisableAccessNone_validation_ok_enable_discovery_enable_access_none)\n\/\/ *INDENT-ON*\n{\n    PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);\n    PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);\n    std::string governance_file(\"governance_enable_discovery_disable_access_none.smime\");\n\n    BuiltinAuthenticationAndAccessAndCryptoPlugin_Permissions_validation_ok_common(reader, writer, governance_file);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":311649,"func":"int64_t MetricsLog::GetBuildTime() {\n  static int64_t integral_build_time = 0;\n  if (!integral_build_time)\n    integral_build_time = static_cast<int64_t>(base::GetBuildTime().ToTimeT());\n  return integral_build_time;\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":400410,"func":"sig_handler endprog(int signal_number MY_ATTRIBUTE((unused)))\n{\n  interrupted=1;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":275121,"func":"HTMLBodyElement::HTMLBodyElement(Document& document)\n    : HTMLElement(bodyTag, document)\n{\n    ScriptWrappable::init(this);\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":499898,"func":"    ContentProvider(QPDFObjectHandle from_page) :\n        from_page(from_page)\n    {\n    }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":172587,"func":"void socket_register(socket_t *socket, reactor_t *reactor, void *context, socket_cb read_cb, socket_cb write_cb) {\n  assert(socket != NULL);\n\n  socket_unregister(socket);\n\n  socket->read_ready = read_cb;\n  socket->write_ready = write_cb;\n  socket->context = context;\n\n void (*read_fn)(void *) = (read_cb != NULL) ? internal_read_ready : NULL;\n void (*write_fn)(void *) = (write_cb != NULL) ? internal_write_ready : NULL;\n\n  socket->reactor_object = reactor_register(reactor, socket->fd, socket, read_fn, write_fn);\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":38577,"func":"static pj_bool_t mod_pjsua_on_rx_request(pjsip_rx_data *rdata)\n{\n    pj_bool_t processed = PJ_FALSE;\n\n    PJSUA_LOCK();\n\n    if (rdata->msg_info.msg->line.req.method.id == PJSIP_INVITE_METHOD) {\n\n\tprocessed = pjsua_call_on_incoming(rdata);\n    }\n\n    PJSUA_UNLOCK();\n\n    return processed;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":364281,"func":"gif_set_get_frame_info (GifContext *context)\n{\n\tcontext->state = GIF_GET_FRAME_INFO;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":247577,"func":"BrowserWindow* Browser::CreateBrowserWindow() {\n  if (type() == Browser::TYPE_APP_PANEL &&\n      CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels))\n    return PanelManager::GetInstance()->CreatePanel(this);\n\n  return BrowserWindow::CreateBrowserWindow(this);\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":282634,"func":"void FramebufferManager::OnTextureRefDetached(TextureRef* texture) {\n  for (TextureDetachObserverVector::iterator it =\n           texture_detach_observers_.begin();\n       it != texture_detach_observers_.end();\n       ++it) {\n    TextureDetachObserver* observer = *it;\n    observer->OnTextureRefDetachedFromFramebuffer(texture);\n  }\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":470414,"func":"void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r) {\n    assert(r);\n\n    AVAHI_LLIST_REMOVE(AvahiSHostNameResolver, resolver, r->server->host_name_resolvers, r);\n\n    if (r->record_browser_a)\n        avahi_s_record_browser_free(r->record_browser_a);\n\n    if (r->record_browser_aaaa)\n        avahi_s_record_browser_free(r->record_browser_aaaa);\n\n    if (r->time_event)\n        avahi_time_event_free(r->time_event);\n\n    if (r->address_record)\n        avahi_record_unref(r->address_record);\n\n    avahi_free(r->host_name);\n    avahi_free(r);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":519539,"func":"double Field_real::get_double(const char *str, size_t length, CHARSET_INFO *cs,\n                              int *error)\n{\n  char *end;\n  double nr= my_strntod(cs,(char*) str, length, &end, error);\n  if (unlikely(*error))\n  {\n    set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);\n    *error= 1;\n  }\n  else if (get_thd()->count_cuted_fields > CHECK_FIELD_EXPRESSION &&\n           check_edom_and_truncation(\"double\", str == end,\n                                     cs, str, length, end))\n    *error= 1;\n  return nr;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":138033,"func":"void __fsnotify_vfsmount_delete(struct vfsmount *mnt)\n{\n\tfsnotify_clear_marks_by_mount(mnt);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":77578,"func":"R_API int *r_str_split_lines(char *str, int *count) {\n\tint i;\n\tint lines = 0;\n\tif (!str) {\n\t\treturn NULL;\n\t}\n\tint *indexes = NULL;\n\t\/\/ count lines\n\tfor (i = 0; str[i]; i++) {\n\t\tif (str[i] == '\\n') {\n\t\t\tlines++;\n\t\t}\n\t}\n\t\/\/ allocate and set indexes\n\tindexes = calloc (sizeof (int), lines + 1);\n\tif (!indexes) {\n\t\treturn NULL;\n\t}\n\tint line = 0;\n\tindexes[line++] = 0;\n\tfor (i = 0; str[i]; i++) {\n\t\tif (str[i] == '\\n') {\n\t\t\tstr[i] = 0;\n\t\t\tindexes[line++] = i + 1;\n\t\t}\n\t}\n\tif (count) {\n\t\t*count = line;\n\t}\n\treturn indexes;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":19825,"func":"static int try_grow_lower ( MAIN_WINDOW_REC * window , int count ) {\n MAIN_WINDOW_REC * grow_win ;\n grow_win = mainwindows_find_lower ( window ) ;\n if ( grow_win != NULL ) {\n MAIN_WINDOW_REC * win ;\n GSList * grow_list , * shrink_list , * tmp ;\n grow_list = mainwindows_get_line ( grow_win ) ;\n shrink_list = mainwindows_get_line ( window ) ;\n for ( tmp = grow_list ;\n tmp != NULL ;\n tmp = tmp -> next ) {\n win = tmp -> data ;\n win -> first_line -= count ;\n }\n for ( tmp = shrink_list ;\n tmp != NULL ;\n tmp = tmp -> next ) {\n win = tmp -> data ;\n win -> last_line -= count ;\n }\n mainwindows_resize_two ( grow_list , shrink_list , count ) ;\n g_slist_free ( shrink_list ) ;\n g_slist_free ( grow_list ) ;\n }\n return grow_win != NULL ;\n }","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":163587,"func":"InlineFlowBox::~InlineFlowBox()\n{\n    if (!m_hasBadChildList)\n        for (InlineBox* child = firstChild(); child; child = child->nextOnLine())\n            child->setHasBadParent();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":439257,"func":"  [[nodiscard]] Guard add(Connection& conn) {\n    std::lock_guard lock{mutex};\n    connections.push_back(conn);\n    return Guard{this, &conn};\n  }","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":79559,"func":"virDomainGetJobStats(virDomainPtr domain,\n                     int *type,\n                     virTypedParameterPtr *params,\n                     int *nparams,\n                     unsigned int flags)\n{\n    virConnectPtr conn;\n\n    VIR_DOMAIN_DEBUG(domain, \"type=%p, params=%p, nparams=%p, flags=%x\",\n                     type, params, nparams, flags);\n\n    virResetLastError();\n\n    virCheckDomainReturn(domain, -1);\n    virCheckNonNullArgGoto(type, error);\n    virCheckNonNullArgGoto(params, error);\n    virCheckNonNullArgGoto(nparams, error);\n\n    conn = domain->conn;\n\n    if (conn->driver->domainGetJobStats) {\n        int ret;\n        ret = conn->driver->domainGetJobStats(domain, type, params,\n                                              nparams, flags);\n        if (ret < 0)\n            goto error;\n        return ret;\n    }\n\n    virReportUnsupportedError();\n\n error:\n    virDispatchError(domain->conn);\n    return -1;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":389992,"func":"output_buffer& HandShakeHeader::get(output_buffer& out) const\n{\n    return out << *this;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":79459,"func":"static bool will_write_block(struct port *port)\n{\n\tbool ret;\n\n\tif (!port->guest_connected) {\n\t\t\/* Port got hot-unplugged. Let's exit. *\/\n\t\treturn false;\n\t}\n\tif (!port->host_connected)\n\t\treturn true;\n\n\tspin_lock_irq(&port->outvq_lock);\n\t\/*\n\t * Check if the Host has consumed any buffers since we last\n\t * sent data (this is only applicable for nonblocking ports).\n\t *\/\n\treclaim_consumed_buffers(port);\n\tret = port->outvq_full;\n\tspin_unlock_irq(&port->outvq_lock);\n\n\treturn ret;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":177352,"func":"SoftAACEncoder2::~SoftAACEncoder2() {\n    aacEncClose(&mAACEncoder);\n\n    onReset();\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":418274,"func":"void RGWListMultipart::execute()\n{\n  map<string, bufferlist> xattrs;\n  string meta_oid;\n  RGWMPObj mp;\n\n  op_ret = get_params();\n  if (op_ret < 0)\n    return;\n\n  mp.init(s->object.name, upload_id);\n  meta_oid = mp.get_meta();\n\n  op_ret = get_multipart_info(store, s, meta_oid, &policy, xattrs);\n  if (op_ret < 0)\n    return;\n\n  op_ret = list_multipart_parts(store, s, upload_id, meta_oid, max_parts,\n\t\t\t\tmarker, parts, NULL, &truncated);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":214877,"func":"v8::Handle<v8::Value> V8ThrowException::throwException(v8::Handle<v8::Value> exception, v8::Isolate* isolate)\n{\n    if (!v8::V8::IsExecutionTerminating())\n        isolate->ThrowException(exception);\n    return v8::Undefined(isolate);\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":429081,"func":"ModuleExport void UnregisterHEICImage(void)\n{\n  (void) UnregisterMagickInfo(\"HEIC\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":40478,"func":"void iwpvt_prng_destroy(struct iw_context *ctx, struct iw_prng *prng)\n{\n\tif(prng) iw_free(ctx,(void*)prng);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":19135,"func":"static inline void SetPixelMagenta ( const Image * restrict image , const Quantum magenta , Quantum * restrict pixel ) {\n pixel [ image -> channel_map [ MagentaPixelChannel ] . offset ] = magenta ;\n }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":342314,"func":"static int nvenc_find_free_reg_resource(AVCodecContext *avctx)\n\n{\n\n    NvencContext *ctx = avctx->priv_data;\n\n    NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;\n\n    NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;\n\n\n\n    int i;\n\n\n\n    if (ctx->nb_registered_frames == FF_ARRAY_ELEMS(ctx->registered_frames)) {\n\n        for (i = 0; i < ctx->nb_registered_frames; i++) {\n\n            if (!ctx->registered_frames[i].mapped) {\n\n                if (ctx->registered_frames[i].regptr) {\n\n                    p_nvenc->nvEncUnregisterResource(ctx->nvencoder,\n\n                                                ctx->registered_frames[i].regptr);\n\n                    ctx->registered_frames[i].regptr = NULL;\n\n                }\n\n                return i;\n\n            }\n\n        }\n\n    } else {\n\n        return ctx->nb_registered_frames++;\n\n    }\n\n\n\n    av_log(avctx, AV_LOG_ERROR, \"Too many registered CUDA frames\\n\");\n\n    return AVERROR(ENOMEM);\n\n}\n","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":206547,"func":" const VisibleSelection& FrameSelection::ComputeVisibleSelectionInDOMTree()\n     const {\n   return selection_editor_->ComputeVisibleSelectionInDOMTree();\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":252779,"func":"Tab* TabStrip::FindTabForEvent(const gfx::Point& point) {\n  if (touch_layout_.get()) {\n    int active_tab_index = touch_layout_->active_index();\n    if (active_tab_index != -1) {\n      Tab* tab = FindTabForEventFrom(point, active_tab_index, -1);\n      if (!tab)\n        tab = FindTabForEventFrom(point, active_tab_index + 1, 1);\n      return tab;\n    } else if (tab_count()) {\n      return FindTabForEventFrom(point, 0, 1);\n    }\n  } else {\n    for (int i = 0; i < tab_count(); ++i) {\n      if (IsPointInTab(tab_at(i), point))\n        return tab_at(i);\n    }\n  }\n  return NULL;\n}\n","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":491005,"func":"static RBinWasmElementEntry *parse_element_entry(RBinWasmObj *bin, ut64 bound, ut32 index) {\n\tRBuffer *b = bin->buf;\n\tRBinWasmElementEntry *elem = R_NEW0 (RBinWasmElementEntry);\n\tif (elem) {\n\t\telem->sec_i = index;\n\t\telem->file_offset = r_buf_tell (b);\n\t\tif (!consume_u32_r (b, bound, &elem->index)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (!consume_init_expr_r (b, bound, R_BIN_WASM_END_OF_CODE, NULL)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (!consume_u32_r (b, bound, &elem->num_elem)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tut32 j = 0;\n\t\twhile (r_buf_tell (b) <= bound && j < elem->num_elem) {\n\t\t\t\/\/ TODO: allocate space and fill entry\n\t\t\tif (!consume_u32_r (b, bound, NULL)) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t}\n\t}\n\treturn elem;\n\nbeach:\n\tfree (elem);\n\treturn NULL;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":301965,"func":"int proc_nr_files(ctl_table *table, int write,\n                     void __user *buffer, size_t *lenp, loff_t *ppos)\n{\n\tfiles_stat.nr_files = get_nr_files();\n\treturn proc_doulongvec_minmax(table, write, buffer, lenp, ppos);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":521066,"func":"  CHARSET_INFO *charset_for_protocol(void) const\n  {\n    return type_handler()->charset_for_protocol(this);\n  };","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":417924,"func":"void RGWRESTMgr::register_default_mgr(RGWRESTMgr *mgr)\n{\n  delete default_mgr;\n  default_mgr = mgr;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":144255,"func":"batchNumMsgs(batch_t *pBatch) {\n\treturn pBatch->nElem;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":187095,"func":"void WebPageProxy::didPerformDragControllerAction(uint64_t resultOperation)\n{\n    m_currentDragOperation = static_cast<DragOperation>(resultOperation);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":200250,"func":"xmlBufCreateSize(size_t size) {\n    xmlBufPtr ret;\n\n    ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));\n    if (ret == NULL) {\n\txmlBufMemoryError(NULL, \"creating buffer\");\n        return(NULL);\n    }\n    ret->compat_use = 0;\n    ret->use = 0;\n    ret->error = 0;\n    ret->buffer = NULL;\n    ret->alloc = xmlBufferAllocScheme;\n    ret->size = (size ? size+2 : 0);         \/* +1 for ending null *\/\n    ret->compat_size = (int) ret->size;\n    if (ret->size){\n        ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));\n        if (ret->content == NULL) {\n\t    xmlBufMemoryError(ret, \"creating buffer\");\n            xmlFree(ret);\n            return(NULL);\n        }\n        ret->content[0] = 0;\n    } else\n\tret->content = NULL;\n    ret->contentIO = NULL;\n    return(ret);\n}\n","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":52114,"func":"srs_init(srs_t *srs)\n{\n\tmemset(srs, 0, sizeof(srs_t));\n\tsrs->secrets = NULL;\n\tsrs->numsecrets = 0;\n\tsrs->separator = '=';\n\tsrs->maxage = 21;\n\tsrs->hashlength = 4;\n\tsrs->hashmin = srs->hashlength;\n\tsrs->alwaysrewrite = FALSE;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":284722,"func":"bool AccessibilityTreeContainsNodeWithName(BrowserAccessibility* node,\n                                           const std::string& name) {\n  if (node->GetStringAttribute(ax::mojom::StringAttribute::kName) == name)\n    return true;\n  for (unsigned i = 0; i < node->PlatformChildCount(); i++) {\n    if (AccessibilityTreeContainsNodeWithName(node->PlatformGetChild(i), name))\n      return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":376145,"func":"static inline void inet_frag_lru_del(struct inet_frag_queue *q)\n{\n\tspin_lock(&q->net->lru_lock);\n\tlist_del(&q->lru_list);\n\tspin_unlock(&q->net->lru_lock);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":211643,"func":"error::Error GLES2DecoderPassthroughImpl::DoResumeTransformFeedback() {\n  api()->glResumeTransformFeedbackFn();\n  return error::kNoError;\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":311763,"func":"static void dumpFrameScrollPosition(WKBundleFrameRef frame, StringBuilder& stringBuilder, FrameNamePolicy shouldIncludeFrameName = ShouldNotIncludeFrameName)\n{\n    double x = numericWindowPropertyValue(frame, \"pageXOffset\");\n    double y = numericWindowPropertyValue(frame, \"pageYOffset\");\n    if (fabs(x) <= 0.00000001 && fabs(y) <= 0.00000001)\n        return;\n\n    if (shouldIncludeFrameName) {\n        WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame));\n        stringBuilder.appendLiteral(\"frame '\");\n        stringBuilder.append(toWTFString(name));\n        stringBuilder.appendLiteral(\"' \");\n    }\n    stringBuilder.appendLiteral(\"scrolled to \");\n    stringBuilder.append(WTF::String::number(x));\n    stringBuilder.append(',');\n    stringBuilder.append(WTF::String::number(y));\n    stringBuilder.append('\\n');\n}\n","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":70571,"func":"ofpact_hdrs_equal(const struct ofpact_hdrs *a,\n                  const struct ofpact_hdrs *b)\n{\n    return (a->vendor == b->vendor\n            && a->type == b->type\n            && a->ofp_version == b->ofp_version);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":428926,"func":"static PHP_INI_MH(OnUpdateInputEncoding)\n{\n\tif (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {\n\t\treturn FAILURE;\n\t}\n\tif (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {\n\t\tphp_error_docref(\"ref.iconv\", E_DEPRECATED, \"Use of iconv.input_encoding is deprecated\");\n\t}\n\tOnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);\n\treturn SUCCESS;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":395687,"func":"void manager_enumerate(Manager *m) {\n        UnitType c;\n\n        assert(m);\n\n        \/* Let's ask every type to load all units from disk\/kernel\n         * that it might know *\/\n        for (c = 0; c < _UNIT_TYPE_MAX; c++) {\n                if (!unit_type_supported(c)) {\n                        log_debug(\"Unit type .%s is not supported on this system.\", unit_type_to_string(c));\n                        continue;\n                }\n\n                if (!unit_vtable[c]->enumerate)\n                        continue;\n\n                unit_vtable[c]->enumerate(m);\n        }\n\n        manager_dispatch_load_queue(m);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":253310,"func":"void PrintPreviewDialogController::SaveInitiatorTitle(\n    WebContents* preview_dialog) {\n  WebContents* initiator = GetInitiator(preview_dialog);\n  if (initiator && preview_dialog->GetWebUI()) {\n    PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(\n        preview_dialog->GetWebUI()->GetController());\n    print_preview_ui->SetInitiatorTitle(\n        PrintViewManager::FromWebContents(initiator)->RenderSourceName());\n  }\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":164910,"func":" void HTMLElement::insertAdjacentHTML(const String& where, const String& markup, ExceptionCode& ec)\n {\n     Element* contextElement = contextElementForInsertion(where, this, ec);\n     if (!contextElement)\n         return;\n    ExceptionCode ignoredEc = 0; \/\/ FIXME: We should propagate a syntax error exception out here.\n    RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, this, ignoredEc);\n    if (ignoredEc)\n        return;\n     insertAdjacent(where, fragment.get(), ec);\n }\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":402876,"func":"  bool is_reference(t_field* tfield) { return tfield->get_reference(); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":210877,"func":"static zval *php_zip_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) \/* {{{ *\/\n{\n\tze_zip_object *obj;\n\tzval tmp_member;\n\tzval *retval = NULL;\n\tzip_prop_handler *hnd = NULL;\n\tzend_object_handlers *std_hnd;\n\n\tif (Z_TYPE_P(member) != IS_STRING) {\n\t\tZVAL_COPY(&tmp_member, member);\n\t\tconvert_to_string(&tmp_member);\n\t\tmember = &tmp_member;\n\t\tcache_slot = NULL;\n\t}\n\n\tobj = Z_ZIP_P(object);\n\n\tif (obj->prop_handler != NULL) {\n\t\thnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member));\n\t}\n\n\tif (hnd == NULL) {\n\t\tstd_hnd = zend_get_std_object_handlers();\n\t\tretval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot);\n\t}\n\n\tif (member == &tmp_member) {\n\t\tzval_dtor(member);\n\t}\n\n\treturn retval;\n}\n\/* }}} *\/\n","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":49037,"func":"int64_t NgxEspRequest::GetGrpcResponseBytes() {\n  ngx_esp_request_ctx_t *ctx = ngx_http_esp_get_module_ctx(r_);\n  return ctx->grpc_response_bytes;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":125047,"func":"static int __msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs,\n\t\t    struct kvm_msr_entry *entries,\n\t\t    int (*do_msr)(struct kvm_vcpu *vcpu,\n\t\t\t\t  unsigned index, u64 *data))\n{\n\tint i, idx;\n\n\tidx = srcu_read_lock(&vcpu->kvm->srcu);\n\tfor (i = 0; i < msrs->nmsrs; ++i)\n\t\tif (do_msr(vcpu, entries[i].index, &entries[i].data))\n\t\t\tbreak;\n\tsrcu_read_unlock(&vcpu->kvm->srcu, idx);\n\n\treturn i;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":389305,"func":"NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_dev_ratio)\n{\n  inst->max_delay_dev_ratio = new_max_delay_dev_ratio;\n  LOG(LOGS_INFO, LOGF_NtpCore, \"Source %s new max delay dev ratio %f\",\n      UTI_IPToString(&inst->remote_addr.ip_addr), new_max_delay_dev_ratio);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":418271,"func":"  virtual void pre_exec() {}","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":318854,"func":"static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr,\n\n                                                         ram_addr_t offset)\n\n{\n\n    bool ret;\n\n    int nr = (mr->ram_addr + offset) >> TARGET_PAGE_BITS;\n\n\n\n    ret = test_and_clear_bit(nr, migration_bitmap);\n\n\n\n    if (ret) {\n\n        migration_dirty_pages--;\n\n    }\n\n    return ret;\n\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":59434,"func":"void pcre_reinit() {\n  PCRECache::CacheKind kind;\n  if (RuntimeOption::EvalPCRECacheType == \"static\") {\n    kind = PCRECache::CacheKind::Static;\n  } else if (RuntimeOption::EvalPCRECacheType == \"lru\") {\n    kind = PCRECache::CacheKind::Lru;\n  } else if (RuntimeOption::EvalPCRECacheType == \"scalable\") {\n    kind = PCRECache::CacheKind::Scalable;\n  } else {\n    Logger::Warning(\"Eval.PCRECacheType should be either static, \"\n                    \"lru or scalable\");\n    kind = PCRECache::CacheKind::Scalable;\n  }\n  s_pcreCache.reinit(kind);\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":110391,"func":"    inline void ThrowTypeErrorOnFailureHelper::ThrowTypeErrorOnFailure(BOOL operationSucceeded)\n    {\n        if (IsThrowTypeError(operationSucceeded))\n        {\n            ThrowTypeErrorOnFailure();\n        }\n    }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":434498,"func":"int parse_sa_P_opt(char *argv[], int *opt, unsigned int *flags, struct activity *act[])\n{\n\tint p;\n\n\tp = get_activity_position(act, A_CPU, EXIT_IF_NOT_FOUND);\n\n\tif (argv[++(*opt)]) {\n\t\tif (parse_values(argv[*opt], act[p]->bitmap->b_array,\n\t\t\t     act[p]->bitmap->b_size, K_LOWERALL))\n\t\t\treturn 1;\n\t\t(*opt)++;\n\t\t*flags |= S_F_OPTION_P;\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":20418,"func":"static void dct_unquantize_mpeg1_intra_c ( MpegEncContext * s , int16_t * block , int n , int qscale ) {\n int i , level , nCoeffs ;\n const uint16_t * quant_matrix ;\n nCoeffs = s -> block_last_index [ n ] ;\n if ( n < 4 ) block [ 0 ] = block [ 0 ] * s -> y_dc_scale ;\n else block [ 0 ] = block [ 0 ] * s -> c_dc_scale ;\n quant_matrix = s -> intra_matrix ;\n for ( i = 1 ;\n i <= nCoeffs ;\n i ++ ) {\n int j = s -> intra_scantable . permutated [ i ] ;\n level = block [ j ] ;\n if ( level ) {\n if ( level < 0 ) {\n level = - level ;\n level = ( int ) ( level * qscale * quant_matrix [ j ] ) >> 3 ;\n level = ( level - 1 ) | 1 ;\n level = - level ;\n }\n else {\n level = ( int ) ( level * qscale * quant_matrix [ j ] ) >> 3 ;\n level = ( level - 1 ) | 1 ;\n }\n block [ j ] = level ;\n }\n }\n }","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":517775,"func":"static int add_keyword_string(String *str, const char *keyword,\n                              bool quoted, const char *keystr)\n{\n  int err= str->append(' ');\n  err+= str->append(keyword);\n\n  str->append(STRING_WITH_LEN(\" = \"));\n  if (quoted)\n  {\n    err+= str->append('\\'');\n    err+= str->append_for_single_quote(keystr);\n    err+= str->append('\\'');\n  }\n  else\n    err+= str->append(keystr);\n  return err;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":106071,"func":"void ff_mov_close_hinting(MOVTrack *track) {\n\n    AVFormatContext* rtp_ctx = track->rtp_ctx;\n\n    uint8_t *ptr;\n\n\n\n    av_freep(&track->enc);\n\n    sample_queue_free(&track->sample_queue);\n\n    if (!rtp_ctx)\n\n        return;\n\n    if (rtp_ctx->pb) {\n\n        av_write_trailer(rtp_ctx);\n\n        url_close_dyn_buf(rtp_ctx->pb, &ptr);\n\n        av_free(ptr);\n\n    }\n\n    av_metadata_free(&rtp_ctx->streams[0]->metadata);\n\n    av_metadata_free(&rtp_ctx->metadata);\n\n\n    av_free(rtp_ctx->streams[0]);\n\n    av_freep(&rtp_ctx);\n\n}","target":1,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":74796,"func":"int pam_sm_setcred (pam_handle_t * pamh, int flags,\n    int argc, const char **argv) {\n\n    int ctrl = _pam_parse (argc, argv);\n\n    if (ctrl & PAM_TAC_DEBUG)\n        syslog (LOG_DEBUG, \"%s: called (pam_tacplus v%u.%u.%u)\"\n            , __FUNCTION__, PAM_TAC_VMAJ, PAM_TAC_VMIN, PAM_TAC_VPAT);\n\n    return PAM_SUCCESS;\n}    \/* pam_sm_setcred *\/","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":227172,"func":"void RenderWidgetHostImpl::CopyFromBackingStore(\n    const gfx::Rect& src_subrect,\n    const gfx::Size& accelerated_dst_size,\n    const ReadbackRequestCallback& callback,\n    const SkColorType preferred_color_type) {\n  if (view_) {\n    TRACE_EVENT0(\"browser\",\n        \"RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface\");\n    gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ?\n        gfx::Rect(view_->GetViewBounds().size()) : src_subrect;\n    view_->CopyFromCompositingSurface(accelerated_copy_rect,\n                                      accelerated_dst_size, callback,\n                                      preferred_color_type);\n    return;\n  }\n\n  callback.Run(SkBitmap(), content::READBACK_FAILED);\n}\n","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":14028,"func":"void TransportTexture::OnTexturesCreated(std::vector<int> textures) {\n   bool ret = decoder_->MakeCurrent();\n   if (!ret) {\n     LOG(ERROR) << \"Failed to switch context\";\n    return;\n  }\n\n  output_textures_->clear();\n  for (size_t i = 0; i < textures.size(); ++i) {\n    uint32 gl_texture = 0;\n\n    ret = decoder_->GetServiceTextureId(textures[i], &gl_texture);\n    DCHECK(ret) << \"Cannot translate client texture ID to service ID\";\n    output_textures_->push_back(gl_texture);\n    texture_map_.insert(std::make_pair(gl_texture, textures[i]));\n  }\n\n  create_task_->Run();\n  create_task_.reset();\n  output_textures_ = NULL;\n}\n","target":1,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":249963,"func":"bool SocketPair(int* fd1, int* fd2) {\n  int pipe_fds[2];\n  if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) {\n    PLOG(ERROR) << \"socketpair()\";\n    return false;\n  }\n\n  if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 ||\n      fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) {\n    PLOG(ERROR) << \"fcntl(O_NONBLOCK)\";\n    HANDLE_EINTR(close(pipe_fds[0]));\n    HANDLE_EINTR(close(pipe_fds[1]));\n    return false;\n  }\n\n  *fd1 = pipe_fds[0];\n  *fd2 = pipe_fds[1];\n\n  return true;\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":515122,"func":"char *findFill(node_t * n)\n{\n    return (findFillDflt(n, DEFAULT_FILL));\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":118316,"func":"static unsigned char *EncodeRLE(unsigned char *destination,\n  unsigned char *source,size_t literal,size_t repeat)\n{\n  if (literal > 0)\n    *destination++=(unsigned char) (literal-1);\n  (void) CopyMagickMemory(destination,source,literal);\n  destination+=literal;\n  if (repeat > 0)\n    {\n      *destination++=(unsigned char) (0x80 | (repeat-1));\n      *destination++=source[literal];\n    }\n  return(destination);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":248603,"func":"void ContentSecurityPolicy::AddAndReportPolicyFromHeaderValue(\n    const String& header,\n    ContentSecurityPolicyHeaderType type,\n    ContentSecurityPolicyHeaderSource source) {\n  wtf_size_t previous_policy_count = policies_.size();\n  AddPolicyFromHeaderValue(header, type, source);\n  WebVector<WebContentSecurityPolicy> policies(policies_.size() -\n                                               previous_policy_count);\n  for (wtf_size_t i = previous_policy_count; i < policies_.size(); ++i) {\n    policies[i - previous_policy_count] =\n        policies_[i]->ExposeForNavigationalChecks();\n  }\n  if (GetDocument() && GetDocument()->GetFrame()) {\n    GetDocument()->GetFrame()->Client()->DidAddContentSecurityPolicies(\n        policies);\n  }\n}\n","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":301664,"func":"static void * load_buffer(RBinFile *bf, RBuffer *buf, ut64 loadaddr, Sdb *sdb) {\n\tstruct Elf_(r_bin_elf_obj_t) *res;\n\tif (!buf) {\n\t\treturn NULL;\n\t}\n\tres = Elf_(r_bin_elf_new_buf) (buf, bf->rbin->verbose);\n\tif (res) {\n\t\tsdb_ns_set (sdb, \"info\", res->kv);\n\t}\n\treturn res;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":58783,"func":"static u32 tg3_read_indirect_reg32(struct tg3 *tp, u32 off)\n{\n\tunsigned long flags;\n\tu32 val;\n\n\tspin_lock_irqsave(&tp->indirect_lock, flags);\n\tpci_write_config_dword(tp->pdev, TG3PCI_REG_BASE_ADDR, off);\n\tpci_read_config_dword(tp->pdev, TG3PCI_REG_DATA, &val);\n\tspin_unlock_irqrestore(&tp->indirect_lock, flags);\n\treturn val;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":266231,"func":"static BOOL wf_cliprdr_get_file_contents(WCHAR* file_name, BYTE* buffer, LONG positionLow,\n                                         LONG positionHigh, DWORD nRequested, DWORD* puSize)\n{\n\tBOOL res = FALSE;\n\tHANDLE hFile;\n\tDWORD nGet, rc;\n\n\tif (!file_name || !buffer || !puSize)\n\t{\n\t\tWLog_ERR(TAG, \"get file contents Invalid Arguments.\");\n\t\treturn FALSE;\n\t}\n\n\thFile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,\n\t                    FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);\n\n\tif (hFile == INVALID_HANDLE_VALUE)\n\t\treturn FALSE;\n\n\trc = SetFilePointer(hFile, positionLow, &positionHigh, FILE_BEGIN);\n\n\tif (rc == INVALID_SET_FILE_POINTER)\n\t\tgoto error;\n\n\tif (!ReadFile(hFile, buffer, nRequested, &nGet, NULL))\n\t{\n\t\tDEBUG_CLIPRDR(\"ReadFile failed with 0x%08lX.\", GetLastError());\n\t\tgoto error;\n\t}\n\n\tres = TRUE;\nerror:\n\n\tif (!CloseHandle(hFile))\n\t\tres = FALSE;\n\n\tif (res)\n\t\t*puSize = nGet;\n\n\treturn res;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":91815,"func":"install_keyword_root(const char *string, void (*handler) (vector_t *), bool active)\n{\n\t\/* If the root keyword is inactive, the handler will still be called,\n\t * but with a NULL strvec *\/\n\tkeyword_alloc(keywords, string, handler, active);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":24368,"func":"static void cirrus_linear_bitblt_write ( void * opaque , hwaddr addr , uint64_t val , unsigned size ) {\n CirrusVGAState * s = opaque ;\n if ( s -> cirrus_srcptr != s -> cirrus_srcptr_end ) {\n * s -> cirrus_srcptr ++ = ( uint8_t ) val ;\n if ( s -> cirrus_srcptr >= s -> cirrus_srcptr_end ) {\n cirrus_bitblt_cputovideo_next ( s ) ;\n }\n }\n }","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":164908,"func":"  void WriteReplyAndDeleteThis(const IPC::ChannelHandle& handle) {\n    ViewHostMsg_OpenChannelToPlugin::WriteReplyParams(reply_msg(),\n                                                      handle, info_);\n    filter()->OnCompletedOpenChannelToNpapiPlugin(this);\n    SendReplyAndDeleteThis();\n  }\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":283225,"func":"static int mptsas_scsi_device_find(MPTSASState *s, int bus, int target,\n                                   uint8_t *lun, SCSIDevice **sdev)\n{\n    if (bus != 0) {\n        return MPI_IOCSTATUS_SCSI_INVALID_BUS;\n    }\n\n    if (target >= s->max_devices) {\n        return MPI_IOCSTATUS_SCSI_INVALID_TARGETID;\n    }\n\n    *sdev = scsi_device_find(&s->bus, bus, target, lun[1]);\n    if (!*sdev) {\n        return MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE;\n    }\n\n    return 0;\n}\n","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":214871,"func":"bool ImeObserver::IsInterestedInKeyEvent() const {\n  return ShouldForwardKeyEvent();\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":195022,"func":"bool AllSamplesPassedQuery::Process() {\n  GLuint available = 0;\n  glGetQueryObjectuivARB(\n      service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available);\n  if (!available) {\n    return true;\n  }\n  GLuint result = 0;\n  glGetQueryObjectuivARB(\n      service_id_, GL_QUERY_RESULT_EXT, &result);\n\n  return MarkAsCompleted(result != 0);\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":293874,"func":"otError Commissioner::Start(otCommissionerStateCallback  aStateCallback,\n                            otCommissionerJoinerCallback aJoinerCallback,\n                            void *                       aCallbackContext)\n{\n    otError error = OT_ERROR_NONE;\n\n    VerifyOrExit(Get<Mle::MleRouter>().IsAttached(), error = OT_ERROR_INVALID_STATE);\n    VerifyOrExit(mState == OT_COMMISSIONER_STATE_DISABLED, error = OT_ERROR_INVALID_STATE);\n\n    SuccessOrExit(error = Get<Coap::CoapSecure>().Start(SendRelayTransmit, this));\n    Get<Coap::CoapSecure>().SetConnectedCallback(&Commissioner::HandleCoapsConnected, this);\n\n    mStateCallback    = aStateCallback;\n    mJoinerCallback   = aJoinerCallback;\n    mCallbackContext  = aCallbackContext;\n    mTransmitAttempts = 0;\n\n    SuccessOrExit(error = SendPetition());\n    SetState(OT_COMMISSIONER_STATE_PETITION);\n\nexit:\n    return error;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":374202,"func":"has_foreign_data_wrapper_privilege_name(PG_FUNCTION_ARGS)\n{\n\ttext\t   *fdwname = PG_GETARG_TEXT_P(0);\n\ttext\t   *priv_type_text = PG_GETARG_TEXT_P(1);\n\tOid\t\t\troleid;\n\tOid\t\t\tfdwid;\n\tAclMode\t\tmode;\n\tAclResult\taclresult;\n\n\troleid = GetUserId();\n\tfdwid = convert_foreign_data_wrapper_name(fdwname);\n\tmode = convert_foreign_data_wrapper_priv_string(priv_type_text);\n\n\taclresult = pg_foreign_data_wrapper_aclcheck(fdwid, roleid, mode);\n\n\tPG_RETURN_BOOL(aclresult == ACLCHECK_OK);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":90921,"func":"UnicodeString::removeRef() {\n  return umtx_atomic_dec((u_atomic_int32_t *)fUnion.fFields.fArray - 1);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":203563,"func":"void PrintWebViewHelper::UpdateFrameAndViewFromCssPageLayout(\n    WebKit::WebFrame* frame,\n    const WebKit::WebNode& node,\n    PrepareFrameAndViewForPrint* prepare,\n    const PrintMsg_Print_Params& params,\n    bool ignore_css_margins) {\n  if (PrintingNodeOrPdfFrame(frame, node))\n    return;\n  bool fit_to_page = ignore_css_margins &&\n                     params.print_scaling_option ==\n                          WebKit::WebPrintScalingOptionFitToPrintableArea;\n  PrintMsg_Print_Params print_params = CalculatePrintParamsForCss(\n      frame, 0, params, ignore_css_margins, fit_to_page, NULL);\n  prepare->UpdatePrintParams(print_params);\n}\n","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":441813,"func":"int force_sig_fault_to_task(int sig, int code, void __user *addr\n\t___ARCH_SI_TRAPNO(int trapno)\n\t___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)\n\t, struct task_struct *t)\n{\n\tstruct kernel_siginfo info;\n\n\tclear_siginfo(&info);\n\tinfo.si_signo = sig;\n\tinfo.si_errno = 0;\n\tinfo.si_code  = code;\n\tinfo.si_addr  = addr;\n#ifdef __ARCH_SI_TRAPNO\n\tinfo.si_trapno = trapno;\n#endif\n#ifdef __ia64__\n\tinfo.si_imm = imm;\n\tinfo.si_flags = flags;\n\tinfo.si_isr = isr;\n#endif\n\treturn force_sig_info_to_task(&info, t);\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":222138,"func":"static ActivationState ParseActivationState(\n    const std::string& activation_state) {\n  if (activation_state == kActivationStateActivated)\n    return ACTIVATION_STATE_ACTIVATED;\n  if (activation_state == kActivationStateActivating)\n    return ACTIVATION_STATE_ACTIVATING;\n  if (activation_state == kActivationStateNotActivated)\n    return ACTIVATION_STATE_NOT_ACTIVATED;\n  if (activation_state == kActivationStateUnknown)\n    return ACTIVATION_STATE_UNKNOWN;\n  if (activation_state == kActivationStatePartiallyActivated)\n    return ACTIVATION_STATE_PARTIALLY_ACTIVATED;\n  return ACTIVATION_STATE_UNKNOWN;\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":277792,"func":"static unsigned uivector_push_back(uivector* p, unsigned c)\n{\n  if(!uivector_resize(p, p->size + 1)) return 0;\n  p->data[p->size - 1] = c;\n  return 1;\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":484760,"func":"static size_t compute_user_elem_size(size_t size, unsigned int count)\n{\n\treturn sizeof(struct user_element) + size * count;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":63435,"func":"static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)\n{\n\tconst char *p;\n\tunsigned len, count, leading_zero_bytes;\n\tint ret, rc;\n\n\tp = name;\n\tif (strncasecmp(p, \"0x\", 2) == 0)\n\t\tp += 2;\n\tret = -EINVAL;\n\tlen = strlen(p);\n\tif (len % 2)\n\t\tgoto out;\n\tcount = min(len \/ 2, 16U);\n\tleading_zero_bytes = 16 - count;\n\tmemset(i_port_id, 0, leading_zero_bytes);\n\trc = hex2bin(i_port_id + leading_zero_bytes, p, count);\n\tif (rc < 0)\n\t\tpr_debug(\"hex2bin failed for srpt_parse_i_port_id: %d\\n\", rc);\n\tret = 0;\nout:\n\treturn ret;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":105298,"func":"__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)\n{\n    _PyErr_StackItem *exc_info = tstate->exc_info;\n    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&\n           exc_info->previous_item != NULL)\n    {\n        exc_info = exc_info->previous_item;\n    }\n    return exc_info;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":281780,"func":"JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&)\n{\n    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));\n    UNUSED_PARAM(exec);\n    TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n    JSValue result = jsNumber(impl->unsignedLongLongAttr());\n    return result;\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":176159,"func":"void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)\n{\n    WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);\n    itemID = item ? item->itemID() : 0;\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":80230,"func":"int ipc_parse_version (int *cmd)\n{\n\tif (*cmd & IPC_64) {\n\t\t*cmd ^= IPC_64;\n\t\treturn IPC_64;\n\t} else {\n\t\treturn IPC_OLD;\n\t}\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":445305,"func":"  void resumeListening() override { udp_listener_->enable(); }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":161344,"func":"static void check_sync_rss_stat(struct task_struct *task)\n{\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":510662,"func":"table_map Item_ref::used_tables() const\t\t\n{\n  return get_depended_from() ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); \n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":112010,"func":"static void cit_send_x_00_05_02_08_01(struct gspca_dev *gspca_dev, u16 x)\n{\n\tcit_write_reg(gspca_dev, x,      0x0127);\n\tcit_write_reg(gspca_dev, 0x0000, 0x0124);\n\tcit_write_reg(gspca_dev, 0x0005, 0x0124);\n\tcit_write_reg(gspca_dev, 0x0002, 0x0124);\n\tcit_write_reg(gspca_dev, 0x0008, 0x0124);\n\tcit_write_reg(gspca_dev, 0x0001, 0x0124);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":504264,"func":"unsigned long tipc_link_tolerance(struct tipc_link *l)\n{\n\treturn l->tolerance;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":337651,"func":"static void isapc_machine_options(MachineClass *m)\n\n{\n\n    pc_common_machine_options(m);\n\n    m->desc = \"ISA-only PC\";\n\n    m->max_cpus = 1;\n\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":77671,"func":"static unsigned long capacity_orig_of(int cpu)\n{\n\treturn cpu_rq(cpu)->cpu_capacity_orig;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":432672,"func":"void CascadeClassifier::detectMultiScale( InputArray image,\n                      CV_OUT std::vector<Rect>& objects,\n                      double scaleFactor,\n                      int minNeighbors, int flags,\n                      Size minSize,\n                      Size maxSize )\n{\n    CV_INSTRUMENT_REGION();\n\n    CV_Assert(!empty());\n    cc->detectMultiScale(image, objects, scaleFactor, minNeighbors, flags, minSize, maxSize);\n    clipObjects(image.size(), objects, 0, 0);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":375811,"func":"static int pl022_post_load(void *opaque, int version_id)\n{\n    PL022State *s = opaque;\n\n    if (s->tx_fifo_head < 0 ||\n        s->tx_fifo_head >= ARRAY_SIZE(s->tx_fifo) ||\n        s->rx_fifo_head < 0 ||\n        s->rx_fifo_head >= ARRAY_SIZE(s->rx_fifo)) {\n        return -1;\n    }\n    return 0;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":9963,"func":"Win32StackFrameUnwinder::~Win32StackFrameUnwinder() {\n  if (pending_blacklisted_module_) {\n    LeafUnwindBlacklist::GetInstance()->AddModuleToBlacklist(\n        pending_blacklisted_module_);\n  }\n}\n","target":1,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":259515,"func":"GIT_INLINE(int) checkout_conflict_detect_submodule(checkout_conflictdata *conflict)\n{\n\tconflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) ||\n\t\t(conflict->ours && S_ISGITLINK(conflict->ours->mode)) ||\n\t\t(conflict->theirs && S_ISGITLINK(conflict->theirs->mode)));\n\treturn 0;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":517640,"func":"  virtual void add_key_fields(JOIN *join, KEY_FIELD **key_fields,\n                              uint *and_level,\n                              table_map usable_tables,\n                              SARGABLE_PARAM **sargables)\n  {\n    return;\n  }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":491706,"func":"scanner_add_literal (parser_context_t *context_p, \/**< context *\/\n                     scanner_context_t *scanner_context_p) \/**< scanner context *\/\n{\n  return scanner_add_custom_literal (context_p,\n                                     scanner_context_p->active_literal_pool_p,\n                                     &context_p->token.lit_location);\n} \/* scanner_add_literal *\/","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":349352,"func":"ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddress)\n{\n\tObjectAddress address;\n\tObjectAddress refAddr;\n\tRelation\trel;\n\n\taddress =\n\t\tget_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,\n\t\t\t\t\t\t\t  &rel, AccessExclusiveLock, false);\n\n\t\/*\n\t * If a relation was involved, it would have been opened and locked. We\n\t * don't need the relation here, but we'll retain the lock until commit.\n\t *\/\n\tif (rel)\n\t\ttable_close(rel, NoLock);\n\n\trefAddr = get_object_address(OBJECT_EXTENSION, (Node *) stmt->extname,\n\t\t\t\t\t\t\t\t &rel, AccessExclusiveLock, false);\n\tAssert(rel == NULL);\n\tif (refAddress)\n\t\t*refAddress = refAddr;\n\n\trecordDependencyOn(&address, &refAddr, DEPENDENCY_AUTO_EXTENSION);\n\n\treturn address;\n}","target":1,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":248834,"func":" void WebPluginDelegatePepper::DidReceiveManualResponse(\n    const GURL& url, const std::string& mime_type,\n    const std::string& headers, uint32 expected_length, uint32 last_modified) {\n  instance()->DidReceiveManualResponse(url, mime_type, headers,\n                                       expected_length, last_modified);\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":7138,"func":"WRITE_JSON_ELEMENT(ArrStart) {\n    \/* increase depth, save: before first array entry no comma needed. *\/\n    ctx->commaNeeded[++ctx->depth] = false;\n    return writeChar(ctx, '[');\n}","target":1,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":277463,"func":"void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase,\n                                                     base::TimeDelta interval) {\n  DCHECK(!gl::IsPresentationCallbackEnabled());\n  if (!update_vsync_parameters_completion_callback_.is_null())\n    update_vsync_parameters_completion_callback_.Run(timebase, interval);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":117,"func":"static void _UTF7Reset ( UConverter * cnv , UConverterResetChoice choice ) {\n if ( choice <= UCNV_RESET_TO_UNICODE ) {\n cnv -> toUnicodeStatus = 0x1000000 ;\n cnv -> toULength = 0 ;\n }\n if ( choice != UCNV_RESET_TO_UNICODE ) {\n cnv -> fromUnicodeStatus = ( cnv -> fromUnicodeStatus & 0xf0000000 ) | 0x1000000 ;\n }\n }","target":1,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":510985,"func":"void html_link_open(char *url, char *title, char *class)\n{\n\thtml(\"<a href='\");\n\thtml_attr(url);\n\tif (title) {\n\t\thtml(\"' title='\");\n\t\thtml_attr(title);\n\t}\n\tif (class) {\n\t\thtml(\"' class='\");\n\t\thtml_attr(class);\n\t}\n\thtml(\"'>\");\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":315557,"func":"static inline bool isLocalFileScheme(WKStringRef scheme)\n{\n    return WKStringIsEqualToUTF8CStringIgnoringCase(scheme, \"file\");\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":103212,"func":"main(int argc, char *argv[])\n{\n    oid             objid[MAX_OID_LEN];\n    int             objidlen = MAX_OID_LEN;\n    int             count;\n    netsnmp_variable_list variable;\n\n    netsnmp_init_mib();\n    if (argc < 2)\n        print_subtree(stdout, tree_head, 0);\n    variable.type = ASN_INTEGER;\n    variable.val.integer = 3;\n    variable.val_len = 4;\n    for (argc--; argc; argc--, argv++) {\n        objidlen = MAX_OID_LEN;\n        printf(\"read_objid(%s) = %d\\n\",\n               argv[1], read_objid(argv[1], objid, &objidlen));\n        for (count = 0; count < objidlen; count++)\n            printf(\"%d.\", objid[count]);\n        printf(\"\\n\");\n        print_variable(objid, objidlen, &variable);\n    }\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":442310,"func":"void testMultiPartThreading (const std::string & tempDir)\n{\n    try\n    {\n        cout << \"Testing the multi part APIs for multi-thread use\" << endl;\n\n        random_reseed(1);\n\n        int numThreads = ThreadPool::globalThreadPool().numThreads();\n        ThreadPool::globalThreadPool().setNumThreads(32);\n\n        testWriteRead ( 1, 1,   5, tempDir);\n        testWriteRead ( 2, 2,  10, tempDir);\n        testWriteRead ( 5, 5,  25, tempDir);\n        testWriteRead (50, 2, 250, tempDir);\n\n        ThreadPool::globalThreadPool().setNumThreads(numThreads);\n\n        cout << \"ok\\n\" << endl;\n    }\n    catch (const std::exception &e)\n    {\n        cerr << \"ERROR -- caught exception: \" << e.what() << endl;\n        assert (false);\n    }\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":496233,"func":"input_value_description(agooErr err, gqlDoc doc, gqlCobj obj, gqlField field, gqlSel sel, gqlValue result, int depth) {\n    const char\t*key = sel->name;\n    const char\t*s = ((gqlArg)obj->ptr)->desc;\n    gqlValue\tdesc;\n\n    if (NULL != sel->alias) {\n\tkey = sel->alias;\n    }\n    if (NULL == s) {\n\tdesc = gql_null_create(err);\n    } else {\n\tdesc = gql_string_create(err, s, -1);\n    }\n    return gql_object_set(err, result, key, desc);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":122701,"func":"static int l_userauth_publickey (lua_State *L) {\n    return userauth_publickey(L, 0, 0);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":422128,"func":"update_delegate_response_cb (ESoapResponse *response,\n                             GSimpleAsyncResult *simple)\n{\n\tESoapParameter *param;\n\tESoapParameter *subparam;\n\tGError *error = NULL;\n\n\tif (ews_get_response_status (e_soap_response_get_parameter (response), &error)) {\n\t\tparam = e_soap_response_get_first_parameter_by_name (\n\t\t\tresponse, \"ResponseMessages\", NULL);\n\t\t\/* that's OK to not receive any ResponseMessages here *\/\n\t\tif (!param)\n\t\t\treturn;\n\t} else\n\t\tparam = NULL;\n\n\t\/* Sanity check *\/\n\tg_return_if_fail (\n\t\t(param != NULL && error == NULL) ||\n\t\t(param == NULL && error != NULL));\n\n\tif (error != NULL) {\n\t\tg_simple_async_result_take_error (simple, error);\n\t\treturn;\n\t}\n\n\tsubparam = e_soap_parameter_get_first_child (param);\n\n\twhile (subparam != NULL) {\n\t\tif (!ews_get_response_status (subparam, &error)) {\n\t\t\tg_simple_async_result_take_error (simple, error);\n\t\t\treturn;\n\t\t}\n\n\t\tsubparam = e_soap_parameter_get_next_child (param);\n\t}\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":311997,"func":"static PHP_FUNCTION(session_destroy)\n{\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tRETURN_BOOL(php_session_destroy(TSRMLS_C) == SUCCESS);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":512019,"func":"bind_variable_value (var, value, aflags)\n     SHELL_VAR *var;\n     char *value;\n     int aflags;\n{\n  char *t;\n\n  VUNSETATTR (var, att_invisible);\n\n  if (var->assign_func)\n    {\n      \/* If we're appending, we need the old value, so use\n\t make_variable_value *\/\n      t = (aflags & ASS_APPEND) ? make_variable_value (var, value, aflags) : value;\n      (*(var->assign_func)) (var, t, -1, 0);\n      if (t != value && t)\n\tfree (t);      \n    }\n  else\n    {\n      t = make_variable_value (var, value, aflags);\n      FREE (value_cell (var));\n      var_setvalue (var, t);\n    }\n\n  INVALIDATE_EXPORTSTR (var);\n\n  if (mark_modified_vars)\n    VSETATTR (var, att_exported);\n\n  if (exported_p (var))\n    array_needs_making = 1;\n\n  return (var);\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":67018,"func":"static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter)\n{\n\tstruct pcie_service_card *card = adapter->card;\n\tconst struct mwifiex_pcie_card_reg *reg = card->pcie.reg;\n\n\tmwifiex_cleanup_rxq_ring(adapter);\n\n\tif (card->rxbd_ring_vbase)\n\t\tpci_free_consistent(card->dev, card->rxbd_ring_size,\n\t\t\t\t    card->rxbd_ring_vbase,\n\t\t\t\t    card->rxbd_ring_pbase);\n\tcard->rxbd_ring_size = 0;\n\tcard->rxbd_wrptr = 0;\n\tcard->rxbd_rdptr = 0 | reg->rx_rollover_ind;\n\tcard->rxbd_ring_vbase = NULL;\n\tcard->rxbd_ring_pbase = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":307934,"func":"static WKURLRef blankURL()\n{\n    static WKURLRef staticBlankURL = WKURLCreateWithUTF8CString(\"about:blank\");\n    return staticBlankURL;\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":216920,"func":"MODRET set_displaylogin(cmd_rec *cmd) {\n  config_rec *c = NULL;\n\n  CHECK_ARGS(cmd, 1);\n  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL|CONF_ANON);\n\n  c = add_config_param_str(cmd->argv[0], 1, cmd->argv[1]);\n  c->flags |= CF_MERGEDOWN;\n\n  return PR_HANDLED(cmd);\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":165886,"func":"void RenderFrameImpl::ShowContextMenu(const blink::WebContextMenuData& data) {\n  ContextMenuParams params = ContextMenuParamsBuilder::Build(data);\n  blink::WebRect position_in_window(params.x, params.y, 0, 0);\n  GetRenderWidget()->ConvertViewportToWindow(&position_in_window);\n  params.x = position_in_window.x;\n  params.y = position_in_window.y;\n  GetRenderWidget()->OnShowHostContextMenu(¶ms);\n  if (GetRenderWidget()->has_host_context_menu_location()) {\n    params.x = GetRenderWidget()->host_context_menu_location().x();\n    params.y = GetRenderWidget()->host_context_menu_location().y();\n  }\n\n  if (params.src_url.spec().size() > url::kMaxURLChars)\n    params.src_url = GURL();\n\n  blink::WebRect selection_in_window(data.selection_rect);\n  GetRenderWidget()->ConvertViewportToWindow(&selection_in_window);\n  params.selection_rect = selection_in_window;\n\n#if defined(OS_ANDROID)\n  base::ThreadTaskRunnerHandle::Get()->PostTask(\n      FROM_HERE, base::Bind(&RenderFrameImpl::ShowDeferredContextMenu,\n                            weak_factory_.GetWeakPtr(), params));\n#else\n  ShowDeferredContextMenu(params);\n#endif\n}\n","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":306636,"func":"GSList*\nmono_image_verify_tables (MonoImage *image, int level)\n{\n\t\/* The verifier was disabled at compile time *\/\n\treturn NULL;","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":466688,"func":"sync_result_msg(Slapi_PBlock *pb, Sync_Cookie *cookie)\n{\n    int rc = 0;\n    char *cookiestr = sync_cookie2str(cookie);\n\n    LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *));\n\n    if (cookie->openldap_compat) {\n        sync_create_sync_done_control(&ctrl[0], 1, cookiestr);\n    } else {\n        sync_create_sync_done_control(&ctrl[0], 0, cookiestr);\n    }\n    slapi_pblock_set(pb, SLAPI_RESCONTROLS, ctrl);\n    slapi_send_ldap_result(pb, 0, NULL, NULL, 0, NULL);\n\n    slapi_ch_free((void **)&cookiestr);\n    return (rc);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":308711,"func":"static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition)\n{\n    WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);\n    Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));\n    if (!coreFrame)\n        return;\n\n    FrameView* view = coreFrame->view();\n    if (!view)\n        return;\n\n    requisition->width = view->contentsWidth();\n    requisition->height = view->contentsHeight();\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":444733,"func":"TEST_P(ProtocolIntegrationTest, MaxStreamDurationWithRetryPolicyWhenRetryUpstreamDisconnection) {\n  testMaxStreamDurationWithRetry(true);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":366442,"func":"static inline hpa_t pfn_to_hpa(pfn_t pfn)\n{\n\treturn (hpa_t)pfn << PAGE_SHIFT;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":364944,"func":"static void parseType(struct cli_bc *bc, struct cli_bc_type *ty,\n\t\t      unsigned char *buffer, unsigned *off, unsigned len,\n\t\t      char *ok)\n{\n    unsigned j;\n\n    ty->numElements = readNumber(buffer, off, len, ok);\n    if (!*ok) {\n\tcli_errmsg(\"Error parsing type\\n\");\n\t*ok = 0;\n\treturn;\n    }\n    ty->containedTypes = cli_malloc(sizeof(*ty->containedTypes)*ty->numElements);\n    if (!ty->containedTypes) {\n\tcli_errmsg(\"Out of memory allocating %u types\\n\", ty->numElements);\n\t*ok = 0;\n\treturn;\n    }\n    for (j=0;j<ty->numElements;j++) {\n\tty->containedTypes[j] = readTypeID(bc, buffer, off, len, ok);\n    }\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":362679,"func":"xmlPointerListFree(xmlPointerListPtr list)\n{\n    if (list == NULL)\n\treturn;\n    if (list->items != NULL)\n\txmlFree(list->items);\n    xmlFree(list);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":180482,"func":"handle_queue_get_config_request_for_port(struct ofport *port, uint32_t queue,\n                                         struct ovs_list *replies)\n{\n    struct smap details = SMAP_INITIALIZER(&details);\n    if (queue != OFPQ_ALL) {\n        int error = netdev_get_queue(port->netdev, queue, &details);\n        switch (error) {\n        case 0:\n            put_queue_get_config_reply(port, queue, replies);\n            break;\n        case EOPNOTSUPP:\n        case EINVAL:\n            return OFPERR_OFPQOFC_BAD_QUEUE;\n        default:\n            return OFPERR_NXQOFC_QUEUE_ERROR;\n        }\n    } else {\n        struct netdev_queue_dump queue_dump;\n        uint32_t queue_id;\n\n        NETDEV_QUEUE_FOR_EACH (&queue_id, &details, &queue_dump,\n                               port->netdev) {\n            put_queue_get_config_reply(port, queue_id, replies);\n        }\n    }\n    smap_destroy(&details);\n    return 0;\n}\n","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":11968,"func":"static inline unsigned char unimap_bsearch(const uni_to_enc *table, unsigned code_key_a, size_t num)\n{\n\tconst uni_to_enc *l = table,\n\t\t\t\t\t *h = &table[num-1],\n\t\t\t\t\t *m;\n\tunsigned short code_key;\n\n\t\/* we have no mappings outside the BMP *\/\n\tif (code_key_a > 0xFFFFU)\n \t\treturn 0;\n \n \tcode_key = (unsigned short) code_key_a;\n \twhile (l <= h) {\n \t\tm = l + (h - l) \/ 2;\n \t\tif (code_key < m->un_code_point)\n\t\t\th = m - 1;\n\t\telse if (code_key > m->un_code_point)\n\t\t\tl = m + 1;\n\t\telse\n\t\t\treturn m->cs_code;\n\t}\n\treturn 0;\n}\n","target":1,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":228785,"func":"std::unique_ptr<EventMatcher> EventBindings::ParseEventMatcher(\n    std::unique_ptr<base::DictionaryValue> filter) {\n  return base::WrapUnique(new EventMatcher(\n      std::move(filter), context()->GetRenderFrame()->GetRoutingID()));\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":520968,"func":"  uint32 max_display_length() const { return field->max_display_length(); }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":169997,"func":"void js_setregistry(js_State *J, const char *name)\n{\n\tjsR_setproperty(J, J->R, name);\n\tjs_pop(J, 1);\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":296858,"func":"static int vidioc_s_input(struct file *file, void *fh, unsigned int i)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);\n\tif (!dev->announce_all_caps && !dev->ready_for_capture)\n\t\treturn -ENOTTY;\n\tif (i == 0)\n\t\treturn 0;\n\treturn -EINVAL;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":303882,"func":"TEST_F(QuicUnencryptedServerTransportTest, FirstPacketProcessedCallback) {\n  getFakeHandshakeLayer()->allowZeroRttKeys();\n  EXPECT_CALL(connCallback, onFirstPeerPacketProcessed()).Times(1);\n  recvClientHello();\n  loopForWrites();\n  AckBlocks acks;\n  acks.insert(0);\n  auto aead = getInitialCipher();\n  auto headerCipher = getInitialHeaderCipher();\n  EXPECT_CALL(connCallback, onFirstPeerPacketProcessed()).Times(0);\n  deliverData(packetToBufCleartext(\n      createAckPacket(\n          server->getNonConstConn(),\n          clientNextInitialPacketNum,\n          acks,\n          PacketNumberSpace::Initial,\n          aead.get()),\n      *aead,\n      *headerCipher,\n      clientNextInitialPacketNum));\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":216730,"func":"    bool doReadUintHelper(T* value)\n    {\n        *value = 0;\n        uint8_t currentByte;\n        int shift = 0;\n        do {\n            if (m_position >= m_length)\n                return false;\n            currentByte = m_buffer[m_position++];\n            *value |= ((currentByte & varIntMask) << shift);\n            shift += varIntShift;\n        } while (currentByte & (1 << varIntShift));\n        return true;\n    }\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":348759,"func":"void Downstream::inspect_http1_request() {\n  if (req_.method == HTTP_CONNECT) {\n    req_.upgrade_request = true;\n  } else if (req_.http_minor > 0) {\n    auto upgrade = req_.fs.header(http2::HD_UPGRADE);\n    if (upgrade) {\n      const auto &val = upgrade->value;\n      \/\/ TODO Perform more strict checking for upgrade headers\n      if (util::streq_l(NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, val.c_str(),\n                        val.size())) {\n        req_.http2_upgrade_seen = true;\n      } else {\n        req_.upgrade_request = true;\n\n        \/\/ TODO Should we check Sec-WebSocket-Key, and\n        \/\/ Sec-WebSocket-Version as well?\n        if (util::strieq_l(\"websocket\", val)) {\n          req_.connect_proto = ConnectProto::WEBSOCKET;\n        }\n      }\n    }\n  }\n  auto transfer_encoding = req_.fs.header(http2::HD_TRANSFER_ENCODING);\n  if (transfer_encoding) {\n    req_.fs.content_length = -1;\n    if (util::iends_with_l(transfer_encoding->value, \"chunked\")) {\n      chunked_request_ = true;\n    }\n  }\n}","target":1,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":192526,"func":"RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const\n{\n    RenderFlowThread* flowThread = flowThreadContainingBlock();\n    if (!flowThread || !flowThread->hasValidRegionInfo())\n        return 0;\n\n    return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + blockOffset, true);\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":486181,"func":"usage (void)\n{\n    printf (\"Usage: %s [OPTIONS]\\n\", prog);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":297441,"func":"sixel_allocator_calloc(\n    sixel_allocator_t   \/* in *\/ *allocator,  \/* allocator object *\/\n    size_t              \/* in *\/ nelm,        \/* number of elements *\/\n    size_t              \/* in *\/ elsize)      \/* size of element *\/\n{\n    size_t n;\n\n    \/* precondition *\/\n    assert(allocator);\n    assert(allocator->fn_calloc);\n\n    n = nelm * elsize;\n\n    if (n == 0) {\n        sixel_helper_set_additional_message(\n            \"sixel_allocator_malloc: called with n == 0\");\n        return NULL;\n    }\n\n    if (n > SIXEL_ALLOCATE_BYTES_MAX) {\n        return NULL;\n    }\n\n    return allocator->fn_calloc(nelm, elsize);\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":447174,"func":"void aarp_cleanup_module(void)\n{\n\tdel_timer_sync(&aarp_timer);\n\tunregister_netdevice_notifier(&aarp_notifier);\n\tunregister_snap_client(aarp_dl);\n\taarp_purge();\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":198484,"func":"int BackendImpl::OpenEntry(const std::string& key, Entry** entry,\n                           const CompletionCallback& callback) {\n  DCHECK(!callback.is_null());\n  background_queue_.OpenEntry(key, entry, callback);\n  return net::ERR_IO_PENDING;\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":211085,"func":"MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents(\n    content::WebContents* web_contents,\n    std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) {\n  DCHECK(web_contents);\n\n  MetricsWebContentsObserver* metrics = FromWebContents(web_contents);\n  if (!metrics) {\n    metrics = new MetricsWebContentsObserver(web_contents,\n                                             std::move(embedder_interface));\n    web_contents->SetUserData(UserDataKey(), base::WrapUnique(metrics));\n  }\n  return metrics;\n}\n","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":490036,"func":"static int coolkey_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* serial)\n{\n\tcoolkey_private_data_t * priv = COOLKEY_DATA(card);\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);\n\tmemcpy(serial->value, &priv->cuid, sizeof(priv->cuid));\n\tserial->len = sizeof(priv->cuid);\n\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":246094,"func":"int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const\n{\n    int length = (orientation == HorizontalScrollbar) ?\n        box().pixelSnappedClientWidth() : box().pixelSnappedClientHeight();\n    int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionToStepWhenPaging();\n    int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPages());\n\n    return max(pageStep, 1);\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":162349,"func":"lys_container_free(struct ly_ctx *ctx, struct lys_node_container *cont,\n                   void (*private_destructor)(const struct lys_node *node, void *priv))\n{\n    int i;\n\n    \/* handle only specific parts for LY_NODE_CONTAINER *\/\n    lydict_remove(ctx, cont->presence);\n\n    for (i = 0; i < cont->tpdf_size; i++) {\n        lys_tpdf_free(ctx, &cont->tpdf[i], private_destructor);\n    }\n    free(cont->tpdf);\n\n    for (i = 0; i < cont->must_size; i++) {\n        lys_restr_free(ctx, &cont->must[i], private_destructor);\n    }\n    free(cont->must);\n\n    lys_when_free(ctx, cont->when, private_destructor);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":432194,"func":"static bool toneport_has_led(struct usb_line6_toneport *toneport)\n{\n\tswitch (toneport->type) {\n\tcase LINE6_GUITARPORT:\n\tcase LINE6_TONEPORT_GX:\n\t\/* add your device here if you are missing support for the LEDs *\/\n\t\treturn true;\n\n\tdefault:\n\t\treturn false;\n\t}\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":381759,"func":"UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)\n{\n\tBitmapset  *parmset;\n\n\t\/*\n\t * The plan node only depends on params listed in its allParam set. Don't\n\t * include anything else into its chgParam set.\n\t *\/\n\tparmset = bms_intersect(node->plan->allParam, newchg);\n\n\t\/*\n\t * Keep node->chgParam == NULL if there's not actually any members; this\n\t * allows the simplest possible tests in executor node files.\n\t *\/\n\tif (!bms_is_empty(parmset))\n\t\tnode->chgParam = bms_join(node->chgParam, parmset);\n\telse\n\t\tbms_free(parmset);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":50775,"func":"int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest)\n{\n\treturn dest == 0xff || kvm_apic_id(apic) == dest;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":178261,"func":"const SSL_CIPHER *dtls1_get_cipher(unsigned int u)\n\t{\n\tconst SSL_CIPHER *ciph = ssl3_get_cipher(u);\n\n\tif (ciph != NULL)\n\t\t{\n\t\tif (ciph->algorithm_enc == SSL_RC4)\n\t\t\treturn NULL;\n\t\t}\n\n\treturn ciph;\n\t}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":87280,"func":"build_oid_noalloc(oid * in, size_t in_len, size_t * out_len,\n                  oid * prefix, size_t prefix_len,\n                  netsnmp_variable_list * indexes)\n{\n    netsnmp_variable_list *var;\n\n    if (prefix) {\n        if (in_len < prefix_len)\n            return SNMPERR_GENERR;\n        memcpy(in, prefix, prefix_len * sizeof(oid));\n        *out_len = prefix_len;\n    } else {\n        *out_len = 0;\n    }\n\n    for (var = indexes; var != NULL; var = var->next_variable) {\n        if (build_oid_segment(var) != SNMPERR_SUCCESS)\n            return SNMPERR_GENERR;\n        if (var->name_length + *out_len <= in_len) {\n            memcpy(&(in[*out_len]), var->name,\n                   sizeof(oid) * var->name_length);\n            *out_len += var->name_length;\n        } else {\n            return SNMPERR_GENERR;\n        }\n    }\n\n    DEBUGMSGTL((\"build_oid_noalloc\", \"generated: \"));\n    DEBUGMSGOID((\"build_oid_noalloc\", in, *out_len));\n    DEBUGMSG((\"build_oid_noalloc\", \"\\n\"));\n    return SNMPERR_SUCCESS;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":390555,"func":"    X509_STORE* X509_STORE_new(void)\n    {\n        \/\/ TODO:\n        return 0;\n    }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":271184,"func":"MagickPrivate NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)\n{\n  NexusInfo\n    **magick_restrict nexus_info;\n\n  register ssize_t\n    i;\n\n  nexus_info=(NexusInfo **) MagickAssumeAligned(AcquireAlignedMemory(\n    number_threads,sizeof(*nexus_info)));\n  if (nexus_info == (NexusInfo **) NULL)\n    ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n  nexus_info[0]=(NexusInfo *) AcquireQuantumMemory(number_threads,\n    sizeof(**nexus_info));\n  if (nexus_info[0] == (NexusInfo *) NULL)\n    ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n  (void) ResetMagickMemory(nexus_info[0],0,number_threads*sizeof(**nexus_info));\n  for (i=0; i < (ssize_t) number_threads; i++)\n  {\n    nexus_info[i]=(&nexus_info[0][i]);\n    nexus_info[i]->signature=MagickCoreSignature;\n  }\n  return(nexus_info);\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":205434,"func":"void DevToolsUIBindings::ShowDevToolsConfirmInfoBar(\n    const base::string16& message,\n    const InfoBarCallback& callback) {\n  if (!delegate_->GetInfoBarService()) {\n    callback.Run(false);\n    return;\n  }\n  std::unique_ptr<DevToolsConfirmInfoBarDelegate> delegate(\n      new DevToolsConfirmInfoBarDelegate(callback, message));\n   GlobalConfirmInfoBar::Show(std::move(delegate));\n }\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":262145,"func":"static inline int is_timeval_eq(const struct timeval *i1, const struct timeval *i2)\n{\n\treturn i1->tv_sec == i2->tv_sec && i1->tv_usec == i2->tv_usec;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":377134,"func":"bool bdrv_is_first_non_filter(BlockDriverState *candidate)\n{\n    BlockDriverState *bs;\n\n    \/* walk down the bs forest recursively *\/\n    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {\n        bool perm;\n\n        \/* try to recurse in this top level bs *\/\n        perm = bdrv_recurse_is_first_non_filter(bs, candidate);\n\n        \/* candidate is the first non filter *\/\n        if (perm) {\n            return true;\n        }\n    }\n\n    return false;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":462426,"func":"static void lo_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)\n{\n    struct fuse_entry_param e;\n    int err;\n\n    fuse_log(FUSE_LOG_DEBUG, \"lo_lookup(parent=%\" PRIu64 \", name=%s)\\n\", parent,\n             name);\n\n    \/*\n     * Don't use is_safe_path_component(), allow \".\" and \"..\" for NFS export\n     * support.\n     *\/\n    if (strchr(name, '\/')) {\n        fuse_reply_err(req, EINVAL);\n        return;\n    }\n\n    err = lo_do_lookup(req, parent, name, &e, NULL);\n    if (err) {\n        fuse_reply_err(req, err);\n    } else {\n        fuse_reply_entry(req, &e);\n    }\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":55348,"func":"static void rpmsg_upref_sleepers(struct virtproc_info *vrp)\n{\n\t\/* support multiple concurrent senders *\/\n\tmutex_lock(&vrp->tx_lock);\n\n\t\/* are we the first sleeping context waiting for tx buffers ? *\/\n\tif (atomic_inc_return(&vrp->sleepers) == 1)\n\t\t\/* enable \"tx-complete\" interrupts before dozing off *\/\n\t\tvirtqueue_enable_cb(vrp->svq);\n\n\tmutex_unlock(&vrp->tx_lock);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":261174,"func":"size_t mobi_get_aid_offset(const MOBIPart *html, const char *aid) {\n    size_t length = html->size;\n    const char *data = (char *) html->data;\n    const size_t aid_length = strlen(aid);\n    const size_t attr_length = 5; \/* \"aid='\" length *\/\n    do {\n        if (length > (aid_length + attr_length) && memcmp(data, \"aid=\", attr_length - 1) == 0) {\n            data += attr_length;\n            length -= attr_length;\n            if (memcmp(data, aid, aid_length) == 0) {\n                if (data[aid_length] == '\\'' || data[aid_length] == '\"') {\n                    return html->size - length;\n                }\n            }\n        }\n        data++;\n    } while (--length);\n    return SIZE_MAX;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":271506,"func":"    BOOL JavascriptArray::SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags)\n    {\n        ScriptContext* scriptContext = this->GetScriptContext();\n\n        uint32 index;\n        if (scriptContext->IsNumericPropertyId(propertyId, &index))\n        {\n            return GetTypeHandler()->ConvertToTypeWithItemAttributes(this)\n                ->SetItemAccessors(this, index, getter, setter);\n        }\n\n        return __super::SetAccessors(propertyId, getter, setter, flags);\n    }","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":29397,"func":"static void * prplcb_account_request_authorize ( PurpleAccount * account , const char * remote_user , const char * id , const char * alias , const char * message , gboolean on_list , PurpleAccountRequestAuthorizationCb authorize_cb , PurpleAccountRequestAuthorizationCb deny_cb , void * user_data ) {\n struct im_connection * ic = purple_ic_by_pa ( account ) ;\n char * q ;\n if ( alias ) {\n q = g_strdup_printf ( \"%s (%s) wants to add you to his\/her contact \" \"list. (%s)\" , alias , remote_user , message ) ;\n }\n else {\n q = g_strdup_printf ( \"%s wants to add you to his\/her contact \" \"list. (%s)\" , remote_user , message ) ;\n }\n imcb_ask_with_free ( ic , q , user_data , authorize_cb , deny_cb , NULL ) ;\n g_free ( q ) ;\n return NULL ;\n }","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":288206,"func":"XSharedMemoryId AttachSharedMemory(Display* display, int shared_memory_key) {\n  DCHECK(QuerySharedMemorySupport(display));\n\n  XShmSegmentInfo shminfo;\n  memset(&shminfo, 0, sizeof(shminfo));\n  shminfo.shmid = shared_memory_key;\n\n  if (!XShmAttach(display, &shminfo))\n     NOTREACHED();\n \n   return shminfo.shmseg;\n }\n","target":1,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":488825,"func":"static gboolean avdtp_reconf_cmd(struct avdtp *session, uint8_t transaction,\n\t\t\t\t\tstruct seid_req *req, int size)\n{\n\tstruct conf_rej rej;\n\n\trej.error = AVDTP_NOT_SUPPORTED_COMMAND;\n\trej.category = 0x00;\n\n\treturn avdtp_send(session, transaction, AVDTP_MSG_TYPE_REJECT,\n\t\t\t\t\tAVDTP_RECONFIGURE, &rej, sizeof(rej));\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":429818,"func":"smpl_t aubio_onset_get_thresholded_descriptor(const aubio_onset_t * o) {\n  fvec_t * thresholded = aubio_peakpicker_get_thresholded_input(o->pp);\n  return thresholded->data[0];\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":188098,"func":"static inline int s16(byte *p)\n{\n    return (signed short)( (p[0] << 8) | p[1] );\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":219375,"func":"ProfileChooserView::ProfileChooserView(views::Button* anchor_button,\n                                       Browser* browser,\n                                       profiles::BubbleViewMode view_mode,\n                                       signin::GAIAServiceType service_type,\n                                       signin_metrics::AccessPoint access_point)\n    : BubbleDialogDelegateView(anchor_button, views::BubbleBorder::TOP_RIGHT),\n      browser_(browser),\n      anchor_button_(anchor_button),\n      view_mode_(view_mode),\n      gaia_service_type_(service_type),\n      access_point_(access_point),\n      close_bubble_helper_(this, browser),\n      dice_enabled_(AccountConsistencyModeManager::IsDiceEnabledForProfile(\n          browser->profile())),\n      menu_width_(dice_enabled_ ? kFixedMenuWidthDice\n                                : kFixedMenuWidthPreDice) {\n  set_margins(gfx::Insets(0, views::GridLayout::kFixedSize, 2, 0));\n  ResetView();\n  chrome::RecordDialogCreation(chrome::DialogIdentifier::PROFILE_CHOOSER);\n}\n","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":144476,"func":"static inline u64 vmx_control_msr(u32 low, u32 high)\n{\n\treturn low | ((u64)high << 32);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":55088,"func":"PJ_DEF(pjsip_dialog*) pjsip_tdata_get_dlg( pjsip_tx_data *tdata )\n{\n    return (pjsip_dialog*) tdata->mod_data[mod_ua.mod.id];\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":362854,"func":"static __inline__ void sk_add_bind_node(struct sock *sk,\n\t\t\t\t\tstruct hlist_head *list)\n{\n\thlist_add_head(&sk->sk_bind_node, list);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":295785,"func":"cib_remote_connection_destroy(gpointer user_data)\n{\n    crm_err(\"Connection destroyed\");\n#ifdef HAVE_GNUTLS_GNUTLS_H\n    cib_tls_close(user_data);\n#endif\n    return;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":513083,"func":"  virtual void dump() {}","target":0,"code_token_length":6,"total_token_length":242,"max_tokens_setting":512}
+{"idx":300198,"func":"int af9005_read_ofdm_register(struct dvb_usb_device *d, u16 reg, u8 * value)\n{\n\tint ret;\n\tdeb_reg(\"read register %x \", reg);\n\tret = af9005_generic_read_write(d, reg,\n\t\t\t\t\tAF9005_CMD_READ, AF9005_OFDM_REG,\n\t\t\t\t\tvalue, 1);\n\tif (ret)\n\t\tdeb_reg(\"failed\\n\");\n\telse\n\t\tdeb_reg(\"value %x\\n\", *value);\n\treturn ret;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":62223,"func":"void ASC_getUserIdentAC(T_ASC_Parameters* params, UserIdentityNegotiationSubItemAC** usrIdentAC)\n{\n  *usrIdentAC = params->DULparams.ackUserIdentNeg;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":386577,"func":"\n\/* {{{ PHP_RSHUTDOWN_FUNCTION *\/\nPHP_RSHUTDOWN_FUNCTION(date)\n{\n\tif (DATEG(timezone)) {\n\t\tefree(DATEG(timezone));\n\t}\n\tDATEG(timezone) = NULL;\n\tif(DATEG(tzcache)) {\n\t\tzend_hash_destroy(DATEG(tzcache));\n\t\tFREE_HASHTABLE(DATEG(tzcache));\n\t\tDATEG(tzcache) = NULL;\n\t}\n\tif (DATEG(last_errors)) {\n\t\ttimelib_error_container_dtor(DATEG(last_errors));\n\t\tDATEG(last_errors) = NULL;\n\t}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":102246,"func":"R_API RBuffer *r_buf_new_with_bytes(const ut8 *bytes, ut64 len) {\n\tstruct buf_bytes_user u = { 0 };\n\tu.data = bytes;\n\tu.length = len;\n\treturn new_buffer (R_BUFFER_BYTES, &u);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":505106,"func":"static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)\n{\n\tchar *emtmp;\n\t\/* First some sanity checks *\/\n\tif(email->type != V_ASN1_IA5STRING) return 1;\n\tif(!email->data || !email->length) return 1;\n\tif(!*sk) *sk = sk_OPENSSL_STRING_new(sk_strcmp);\n\tif(!*sk) return 0;\n\t\/* Don't add duplicates *\/\n\tif(sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) return 1;\n\temtmp = BUF_strdup((char *)email->data);\n\tif(!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) {\n\t\tX509_email_free(*sk);\n\t\t*sk = NULL;\n\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":137557,"func":"static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id)\n{\n\tstruct kvm_vcpu *target = NULL;\n\tstruct kvm_apic_map *map;\n\n\tvcpu->stat.directed_yield_attempted++;\n\n\tif (single_task_running())\n\t\tgoto no_yield;\n\n\trcu_read_lock();\n\tmap = rcu_dereference(vcpu->kvm->arch.apic_map);\n\n\tif (likely(map) && dest_id <= map->max_apic_id && map->phys_map[dest_id])\n\t\ttarget = map->phys_map[dest_id]->vcpu;\n\n\trcu_read_unlock();\n\n\tif (!target || !READ_ONCE(target->ready))\n\t\tgoto no_yield;\n\n\t\/* Ignore requests to yield to self *\/\n\tif (vcpu == target)\n\t\tgoto no_yield;\n\n\tif (kvm_vcpu_yield_to(target) <= 0)\n\t\tgoto no_yield;\n\n\tvcpu->stat.directed_yield_successful++;\n\nno_yield:\n\treturn;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":315700,"func":"CanvasResourceProvider* HTMLCanvasElement::GetOrCreateCanvasResourceProvider(\n    AccelerationHint hint) {\n  if (Is2d())\n    return GetOrCreateCanvas2DLayerBridge()->GetOrCreateResourceProvider(hint);\n\n  return CanvasRenderingContextHost::GetOrCreateCanvasResourceProvider(hint);\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":212186,"func":"void PrintPreviewMessageHandler::OnRequestPrintPreview(\n    content::RenderFrameHost* render_frame_host,\n    const PrintHostMsg_RequestPrintPreview_Params& params) {\n  if (params.webnode_only) {\n    PrintViewManager::FromWebContents(web_contents())->PrintPreviewForWebNode(\n        render_frame_host);\n  }\n  PrintPreviewDialogController::PrintPreview(web_contents());\n  PrintPreviewUI::SetInitialParams(GetPrintPreviewDialog(), params);\n}\n","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":217422,"func":"int BrowserActionsContainer::GetCurrentTabId() const {\n  TabContents* tab_contents = toolbar_->browser()->GetSelectedTabContents();\n  if (!tab_contents)\n    return -1;\n\n  return tab_contents->controller().session_id().id();\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":517276,"func":"  Item_default_value(THD *thd, Name_resolution_context *context_arg, Field *a)\n    :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,\n                (const char *)NULL),\n    arg(NULL),cached_field(NULL) {}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":17517,"func":"static void dissect_zcl_identify_identify ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {\n proto_tree_add_item ( tree , hf_zbee_zcl_identify_identify_time , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;\n * offset += 2 ;\n }","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":501435,"func":"size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)\n{\n    if (cctx==NULL) return 0;   \/* support free on NULL *\/\n    if (cctx->staticSize) return ERROR(memory_allocation);   \/* not compatible with static CCtx *\/\n    ZSTD_freeCCtxContent(cctx);\n    ZSTD_free(cctx, cctx->customMem);\n    return 0;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":245500,"func":"blink::WebAppBannerClient* RenderFrameImpl::appBannerClient() {\n  if (!app_banner_client_) {\n    app_banner_client_ =\n        GetContentClient()->renderer()->CreateAppBannerClient(this);\n  }\n\n  return app_banner_client_.get();\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":241022,"func":"void CapturerMac::ClearInvalidRects() {\n  helper_.ClearInvalidRects();\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":86267,"func":"static int ahash_setkey_unaligned(struct crypto_ahash *tfm, const u8 *key,\n\t\t\t\tunsigned int keylen)\n{\n\tunsigned long alignmask = crypto_ahash_alignmask(tfm);\n\tint ret;\n\tu8 *buffer, *alignbuffer;\n\tunsigned long absize;\n\n\tabsize = keylen + alignmask;\n\tbuffer = kmalloc(absize, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\talignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);\n\tmemcpy(alignbuffer, key, keylen);\n\tret = tfm->setkey(tfm, alignbuffer, keylen);\n\tkzfree(buffer);\n\treturn ret;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":198368,"func":"HistogramBase* CustomHistogram::DeserializeInfoImpl(PickleIterator* iter) {\n  std::string histogram_name;\n  int flags;\n  int declared_min;\n  int declared_max;\n  uint32_t bucket_count;\n  uint32_t range_checksum;\n\n  if (!ReadHistogramArguments(iter, &histogram_name, &flags, &declared_min,\n                              &declared_max, &bucket_count, &range_checksum)) {\n    return NULL;\n  }\n\n  std::vector<Sample> sample_ranges(bucket_count - 1);\n\n  for (uint32_t i = 0; i < sample_ranges.size(); ++i) {\n    if (!iter->ReadInt(&sample_ranges[i]))\n      return NULL;\n  }\n\n  HistogramBase* histogram = CustomHistogram::FactoryGet(\n      histogram_name, sample_ranges, flags);\n  if (!ValidateRangeChecksum(*histogram, range_checksum)) {\n    return NULL;\n  }\n  return histogram;\n}\n","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":13683,"func":" void PlatformSensorFusion::Create(\n    mojo::ScopedSharedBufferMapping mapping,\n     PlatformSensorProvider* provider,\n     std::unique_ptr<PlatformSensorFusionAlgorithm> fusion_algorithm,\n     const PlatformSensorProviderBase::CreateSensorCallback& callback) {\n  Factory::CreateSensorFusion(std::move(mapping), std::move(fusion_algorithm),\n                               callback, provider);\n }\n","target":1,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":444257,"func":"int ConnectionImpl::onMetadataFrameComplete(int32_t stream_id, bool end_metadata) {\n  ENVOY_CONN_LOG(trace, \"recv METADATA frame on stream {}, end_metadata: {}\", connection_,\n                 stream_id, end_metadata);\n\n  StreamImpl* stream = getStream(stream_id);\n  if (stream == nullptr) {\n    return 0;\n  }\n\n  bool result = stream->getMetadataDecoder().onMetadataFrameComplete(end_metadata);\n  return result ? 0 : NGHTTP2_ERR_CALLBACK_FAILURE;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":208194,"func":" virtual bool livesLocally(node_id node, pid_t pid) {\n Parcel data, reply;\n        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());\n        data.writeInt32((int32_t)node);\n        data.writeInt32(pid);\n        remote()->transact(LIVES_LOCALLY, data, &reply);\n\n return reply.readInt32() != 0;\n }\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":142125,"func":"static int ntop_change_user_host_pool(lua_State* vm) {\n  char *username, *host_pool_id;\n\n  ntop->getTrace()->traceEvent(TRACE_DEBUG, \"%s() called\", __FUNCTION__);\n  if(!Utils::isUserAdministrator(vm)) return(CONST_LUA_ERROR);\n\n  if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING)) return(CONST_LUA_PARAM_ERROR);\n  if((username = (char*)lua_tostring(vm, 1)) == NULL) return(CONST_LUA_PARAM_ERROR);\n\n  if(ntop_lua_check(vm, __FUNCTION__, 2, LUA_TSTRING)) return(CONST_LUA_PARAM_ERROR);\n  if((host_pool_id = (char*)lua_tostring(vm, 2)) == NULL) return(CONST_LUA_PARAM_ERROR);\n\n  return ntop->changeUserHostPool(username, host_pool_id);\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":368269,"func":"token_clear(directory_token_t *tok)\n{\n  if (tok->key)\n    crypto_free_pk_env(tok->key);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":184293,"func":"void QuotaManager::GetGlobalUsage(StorageType type,\n                                  const GlobalUsageCallback& callback) {\n  LazyInitialize();\n  GetUsageTracker(type)->GetGlobalUsage(callback);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":277489,"func":"void BaseRenderingContext2D::RestoreMatrixClipStack(PaintCanvas* c) const {\n  if (!c)\n    return;\n  HeapVector<Member<CanvasRenderingContext2DState>>::const_iterator curr_state;\n  DCHECK(state_stack_.begin() < state_stack_.end());\n  for (curr_state = state_stack_.begin(); curr_state < state_stack_.end();\n       curr_state++) {\n    c->setMatrix(SkMatrix::I());\n    if (curr_state->Get()) {\n      curr_state->Get()->PlaybackClips(c);\n      c->setMatrix(AffineTransformToSkMatrix(curr_state->Get()->Transform()));\n    }\n    c->save();\n  }\n  c->restore();\n  ValidateStateStack();\n}\n","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":478444,"func":"    static int _assign_xshm(Display *dpy, XErrorEvent *error) {\n      cimg::unused(dpy,error);\n      cimg::X11_attr().is_shm_enabled = false;\n      return 0;\n    }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":285360,"func":"gx_dc_pattern2_color_has_bbox(const gx_device_color * pdevc)\n{\n    gs_pattern2_instance_t *pinst = (gs_pattern2_instance_t *)pdevc->ccolor.pattern;\n    const gs_shading_t *psh = pinst->templat.Shading;\n\n    return psh->params.have_BBox;\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":344701,"func":"int main( int argc, char *argv[] )\n{\n    ((void) argc);\n    ((void) argv);\n\n    printf(\"POLARSSL_TIMING_C not defined.\\n\");\n    return( 0 );\n}","target":1,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":421738,"func":"flatpak_load_override_keyfile (const char *app_id, gboolean user, GError **error)\n{\n  g_autofree char *metadata_contents = NULL;\n  gsize metadata_size;\n\n  g_autoptr(GKeyFile) metakey = g_key_file_new ();\n  g_autoptr(FlatpakDir) dir = NULL;\n\n  dir = user ? flatpak_dir_get_user () : flatpak_dir_get_system_default ();\n\n  metadata_contents = flatpak_dir_load_override (dir, app_id, &metadata_size, error);\n  if (metadata_contents == NULL)\n    return NULL;\n\n  if (!g_key_file_load_from_data (metakey,\n                                  metadata_contents,\n                                  metadata_size,\n                                  0, error))\n    return NULL;\n\n  return g_steal_pointer (&metakey);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":452597,"func":"AuthAuthorizer* MonClient::build_authorizer(int service_id) const {\n  std::lock_guard l(monc_lock);\n  if (auth) {\n    return auth->build_authorizer(service_id);\n  } else {\n    ldout(cct, 0) << __func__ << \" for \" << ceph_entity_type_name(service_id)\n\t\t  << \", but no auth is available now\" << dendl;\n    return nullptr;\n  }\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":290384,"func":"static uint8_t pfkey_proto_to_xfrm ( uint8_t proto ) {\n return proto == IPSEC_PROTO_ANY ? 0 : proto ;\n }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":31054,"func":"static hb_codepoint_t hb_ucdn_mirroring ( hb_unicode_funcs_t * ufuncs , hb_codepoint_t unicode , void * user_data HB_UNUSED ) {\n return ucdn_mirror ( unicode ) ;\n }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":462781,"func":"TEST(GtOp, MatchesDotNotationNull) {\n    BSONObj operand = BSON(\"$gt\" << BSONNULL);\n    GTMatchExpression gt(\"a.b\", operand[\"$gt\"]);\n    ASSERT(!gt.matchesBSON(BSONObj(), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << BSONNULL), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << 4), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << BSONObj()), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << BSON_ARRAY(BSON(\"b\" << BSONNULL))), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << BSON_ARRAY(BSON(\"a\" << 4) << BSON(\"b\" << 4))), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << BSON_ARRAY(4)), NULL));\n    ASSERT(!gt.matchesBSON(BSON(\"a\" << BSON_ARRAY(BSON(\"b\" << 4))), NULL));\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":479859,"func":"    CImg<T> get_rows(const int y0, const int y1) const {\n      return get_crop(0,y0,0,0,width() - 1,y1,depth() - 1,spectrum() - 1);\n    }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":512851,"func":"void Gfx::opCurveTo2(Object args[], int numArgs) {\n  double x1, y1, x2, y2, x3, y3;\n\n  if (!state->isCurPt()) {\n    error(getPos(), \"No current point in curveto2\");\n    return;\n  }\n  x1 = args[0].getNum();\n  y1 = args[1].getNum();\n  x2 = args[2].getNum();\n  y2 = args[3].getNum();\n  x3 = x2;\n  y3 = y2;\n  state->curveTo(x1, y1, x2, y2, x3, y3);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":400198,"func":"clear_status_flags_on_sybil(routerstatus_t *rs)\n{\n  rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =\n    rs->is_flagged_running = rs->is_named = rs->is_valid =\n    rs->is_hs_dir = rs->is_v2_dir = rs->is_possible_guard = 0;\n  \/* FFFF we might want some mechanism to check later on if we\n   * missed zeroing any flags: it's easy to add a new flag but\n   * forget to add it to this clause. *\/\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":144156,"func":"get_pfxmatch(\n\tchar ** s,\n\tstruct masks *m\n\t)\n{\n\twhile (m->name) {\n\t\tif (strncmp(*s, m->name, strlen(m->name)) == 0) {\n\t\t\t*s += strlen(m->name);\n\t\t\treturn m->mask;\n\t\t} else {\n\t\t\tm++;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":173824,"func":"ChromotingInstance::ChromotingInstance(PP_Instance pp_instance)\n    : pp::Instance(pp_instance),\n      initialized_(false),\n      plugin_task_runner_(\n          new PluginThreadTaskRunner(&plugin_thread_delegate_)),\n      context_(plugin_task_runner_),\n      input_tracker_(&mouse_input_filter_),\n#if defined(OS_MACOSX)\n      mac_key_event_processor_(&input_tracker_),\n      key_mapper_(&mac_key_event_processor_),\n#else\n      key_mapper_(&input_tracker_),\n#endif\n      input_handler_(&key_mapper_),\n      weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {\n  RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL);\n  RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);\n\n  RegisterLoggingInstance();\n\n  scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());\n  data->SetInteger(\"apiVersion\", kApiVersion);\n  data->SetString(\"apiFeatures\", kApiFeatures);\n  data->SetInteger(\"apiMinVersion\", kApiMinMessagingVersion);\n  PostChromotingMessage(\"hello\", data.Pass());\n}\n","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":261531,"func":"static u16 tcm_loop_get_tag(struct se_portal_group *se_tpg)\n{\n\tstruct tcm_loop_tpg *tl_tpg =\n\t\t(struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;\n\t\/*\n\t * This Tag is used when forming SCSI Name identifier in EVPD=1 0x83\n\t * to represent the SCSI Target Port.\n\t *\/\n\treturn tl_tpg->tl_tpgt;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":487186,"func":"        query_string& operator=(query_string&& qs)\n        {\n            key_value_pairs_ = std::move(qs.key_value_pairs_);\n            char* old_data = (char*)qs.url_.c_str();\n            url_ = std::move(qs.url_);\n            for (auto& p : key_value_pairs_)\n            {\n                p += (char*)url_.c_str() - old_data;\n            }\n            return *this;\n        }","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":508421,"func":"int SSL_pending(const SSL *s)\n{\n    \/*\n     * SSL_pending cannot work properly if read-ahead is enabled\n     * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)), and it is\n     * impossible to fix since SSL_pending cannot report errors that may be\n     * observed while scanning the new data. (Note that SSL_pending() is\n     * often used as a boolean value, so we'd better not return -1.)\n     *\/\n    return (s->method->ssl_pending(s));\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":376027,"func":"static int pxa2xx_fir_is_empty(void *opaque)\n{\n    PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;\n    return (s->rx_len < 64);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":42382,"func":"osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,\n\t        uint16_t checksum, int checksum_offset, u_int length)\n{\n        uint16_t calculated_checksum;\n\n        \/* do not attempt to verify the checksum if it is zero,\n         * if the offset is nonsense,\n         * or the base pointer is not sane\n         *\/\n        if (!checksum\n            || checksum_offset < 0\n            || !ND_TTEST2(*(pptr + checksum_offset), 2)\n            || (u_int)checksum_offset > length\n            || !ND_TTEST2(*pptr, length)) {\n                ND_PRINT((ndo, \" (unverified)\"));\n        } else {\n#if 0\n                printf(\"\\nosi_print_cksum: %p %u %u\\n\", pptr, checksum_offset, length);\n#endif\n                calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);\n                if (checksum == calculated_checksum) {\n                        ND_PRINT((ndo, \" (correct)\"));\n                } else {\n                        ND_PRINT((ndo, \" (incorrect should be 0x%04x)\", calculated_checksum));\n                }\n        }\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":186069,"func":"void WebContentsImpl::SetAudioMuted(bool mute) {\n  DVLOG(1) << \"SetAudioMuted(mute=\" << mute << \"), was \" << IsAudioMuted()\n           << \" for WebContentsImpl@\" << this;\n\n  if (mute == IsAudioMuted())\n    return;\n\n  if (mute) {\n    if (!audio_muter_)\n      audio_muter_.reset(new WebContentsAudioMuter(this));\n    audio_muter_->StartMuting();\n  } else {\n    DCHECK(audio_muter_);\n    audio_muter_->StopMuting();\n  }\n\n  FOR_EACH_OBSERVER(WebContentsObserver, observers_,\n                    DidUpdateAudioMutingState(mute));\n\n  NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);\n}\n","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":69679,"func":"ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)\n{\n    ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;\n    assert((uintptr_t)host >= (uintptr_t)rb->host);\n    assert(res < rb->max_length);\n\n    return res;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":511261,"func":"ignore_tty_job_signals ()\n{\n#if defined (SIGTSTP)\n  set_signal_handler (SIGTSTP, SIG_IGN);\n  set_signal_handler (SIGTTIN, SIG_IGN);\n  set_signal_handler (SIGTTOU, SIG_IGN);\n#endif\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":34972,"func":"mrb_malloc(mrb_state *mrb, size_t len)\n{\n  return mrb_realloc(mrb, 0, len);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":396498,"func":"putHmarker(HmarkerList *ml, int line, int pos, int seq)\n{\n    if (ml == NULL) {\n\tml = New(HmarkerList);\n\tml->marks = NULL;\n\tml->nmark = 0;\n\tml->markmax = 0;\n\tml->prevhseq = -1;\n    }\n    if (ml->markmax == 0) {\n\tml->markmax = FIRST_MARKER_SIZE;\n\tml->marks = NewAtom_N(BufferPoint, ml->markmax);\n\tbzero(ml->marks, sizeof(BufferPoint) * ml->markmax);\n    }\n    if (seq + 1 > ml->nmark)\n\tml->nmark = seq + 1;\n    if (ml->nmark >= ml->markmax) {\n\tml->markmax = ml->nmark * 2;\n\tml->marks = New_Reuse(BufferPoint, ml->marks, ml->markmax);\n    }\n    ml->marks[seq].line = line;\n    ml->marks[seq].pos = pos;\n    ml->marks[seq].invalid = 0;\n    return ml;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":127963,"func":"static __always_inline void pv_wait(u8 *ptr, u8 val)\n{\n\tPVOP_VCALL2(lock.wait, ptr, val);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":122912,"func":"static void gdImageHLine(gdImagePtr im, int y, int x1, int x2, int col)\n{\n\tif (im->thick > 1) {\n\t\tint thickhalf = im->thick >> 1;\n\t\t_gdImageFilledHRectangle(im, x1, y - thickhalf, x2, y + im->thick - thickhalf - 1, col);\n\t} else {\n\t\tif (x2 < x1) {\n\t\t\tint t = x2;\n\t\t\tx2 = x1;\n\t\t\tx1 = t;\n\t\t}\n\n\t\tfor (;x1 <= x2; x1++) {\n\t\t\tgdImageSetPixel(im, x1, y, col);\n\t\t}\n\t}\n\treturn;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":149166,"func":"static inline void fwnet_make_uf_hdr(struct rfc2734_header *hdr,\n\t\tunsigned ether_type)\n{\n\thdr->w0 = fwnet_set_hdr_lf(RFC2374_HDR_UNFRAG)\n\t\t  | fwnet_set_hdr_ether_type(ether_type);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":198154,"func":"void RenderFrameImpl::PluginDidStartLoading() {\n  DidStartLoading();\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":11622,"func":" zsetdevice(i_ctx_t *i_ctx_p)\n {\n    gx_device *dev = gs_currentdevice(igs);\n     os_ptr op = osp;\n    int code = 0;\n \n     check_write_type(*op, t_device);\n    if (dev->LockSafetyParams) {         \/* do additional checking if locked  *\/\n        if(op->value.pdevice != dev)     \/* don't allow a different device    *\/\n             return_error(gs_error_invalidaccess);\n     }\n     dev->ShowpageCount = 0;\n    code = gs_setdevice_no_erase(igs, op->value.pdevice);\n    if (code < 0)\n        return code;\n\n    make_bool(op, code != 0);\t\/* erase page if 1 *\/\n    invalidate_stack_devices(i_ctx_p);\n    clear_pagedevice(istate);\n    return code;\n}\n","target":1,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":191956,"func":"std::vector<std::string> RegisterAllFeatureVariationParameters(\n    flags_ui::FlagsStorage* flags_storage,\n    base::FeatureList* feature_list) {\n  return FlagsStateSingleton::GetFlagsState()\n      ->RegisterAllFeatureVariationParameters(flags_storage, feature_list);\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":253400,"func":"HttpBridgeFactory::HttpBridgeFactory(\n    net::URLRequestContextGetter* baseline_context_getter) {\n  DCHECK(baseline_context_getter != NULL);\n  request_context_getter_ =\n      new HttpBridge::RequestContextGetter(baseline_context_getter);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":411572,"func":"    **\/\n    CImg<T>& operator%=(const char *const expression) {\n      return *this%=(+*this)._fill(expression,true,true,0,0,\"operator%=\",this);","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":192482,"func":"void readpng2_version_info(void)\n{\n    fprintf(stderr, \"   Compiled with libpng %s; using libpng %s\\n\",\n      PNG_LIBPNG_VER_STRING, png_libpng_ver);\n\n    fprintf(stderr, \"   and with zlib %s; using zlib %s.\\n\",\n      ZLIB_VERSION, zlib_version);\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":298969,"func":"void kvm_vcpu_block(struct kvm_vcpu *vcpu)\n{\n\tDEFINE_WAIT(wait);\n\n\tfor (;;) {\n\t\tprepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE);\n\n\t\tif (kvm_arch_vcpu_runnable(vcpu)) {\n\t\t\tkvm_make_request(KVM_REQ_UNHALT, vcpu);\n\t\t\tbreak;\n\t\t}\n\t\tif (kvm_cpu_has_pending_timer(vcpu))\n\t\t\tbreak;\n\t\tif (signal_pending(current))\n\t\t\tbreak;\n\n\t\tschedule();\n\t}\n\n\tfinish_wait(&vcpu->wq, &wait);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":315250,"func":"WebContentsLoadedOrDestroyedWatcher::WebContentsLoadedOrDestroyedWatcher(\n    content::WebContents* web_contents)\n    : content::WebContentsObserver(web_contents),\n      message_loop_runner_(new content::MessageLoopRunner) {\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":277213,"func":"int BrowserMainLoop::PreMainMessageLoopRun() {\n#if defined(OS_ANDROID)\n  ui::SetScreenAndroid();\n#endif\n\n  if (parts_) {\n    TRACE_EVENT0(\"startup\",\n        \"BrowserMainLoop::CreateThreads:PreMainMessageLoopRun\");\n\n    parts_->PreMainMessageLoopRun();\n  }\n\n  base::ThreadRestrictions::SetIOAllowed(false);\n  base::ThreadRestrictions::DisallowWaiting();\n  return result_code_;\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":280199,"func":"int OmniboxViewViews::OnDrop(const ui::OSExchangeData& data) {\n  if (HasTextBeingDragged())\n    return ui::DragDropTypes::DRAG_NONE;\n\n   if (data.HasURL()) {\n     GURL url;\n     base::string16 title;\n    if (data.GetURLAndTitle(\n            ui::OSExchangeData::CONVERT_FILENAMES, &url, &title)) {\n       base::string16 text(\n           StripJavascriptSchemas(base::UTF8ToUTF16(url.spec())));\n       if (model()->CanPasteAndGo(text)) {\n        model()->PasteAndGo(text);\n        return ui::DragDropTypes::DRAG_COPY;\n      }\n    }\n  } else if (data.HasString()) {\n    base::string16 text;\n    if (data.GetString(&text)) {\n      base::string16 collapsed_text(CollapseWhitespace(text, true));\n      if (model()->CanPasteAndGo(collapsed_text))\n        model()->PasteAndGo(collapsed_text);\n      return ui::DragDropTypes::DRAG_COPY;\n    }\n  }\n\n  return ui::DragDropTypes::DRAG_NONE;\n}\n","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":388764,"func":"const uint8_t *smb1cli_conn_server_challenge(struct smbXcli_conn *conn)\n{\n\treturn conn->smb1.server.challenge;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":133745,"func":"void sctp_hash_established(struct sctp_association *asoc)\n{\n\tif (asoc->temp)\n\t\treturn;\n\n\tsctp_local_bh_disable();\n\t__sctp_hash_established(asoc);\n\tsctp_local_bh_enable();\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":470984,"func":"wl_array_copy(struct wl_array *array, struct wl_array *source)\n{\n\tif (array->size < source->size) {\n\t\tif (!wl_array_add(array, source->size - array->size))\n\t\t\treturn -1;\n\t} else {\n\t\tarray->size = source->size;\n\t}\n\n\tif (source->size > 0)\n\t\tmemcpy(array->data, source->data, source->size);\n\n\treturn 0;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":401192,"func":"static sci_t macsec_frame_sci(struct macsec_eth_header *hdr, bool sci_present)\n{\n\tsci_t sci;\n\n\tif (sci_present)\n\t\tmemcpy(&sci, hdr->secure_channel_id,\n\t\t       sizeof(hdr->secure_channel_id));\n\telse\n\t\tsci = make_sci(hdr->eth.h_source, MACSEC_PORT_ES);\n\n\treturn sci;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":262858,"func":"static int cmd_queue(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags)\n{\n  if (cmd_queue_full(adata))\n  {\n    mutt_debug(LL_DEBUG3, \"Draining IMAP command pipeline\\n\");\n\n    const int rc = imap_exec(adata, NULL, flags & IMAP_CMD_POLL);\n\n    if (rc == IMAP_EXEC_ERROR)\n      return IMAP_RES_BAD;\n  }\n\n  struct ImapCommand *cmd = cmd_new(adata);\n  if (!cmd)\n    return IMAP_RES_BAD;\n\n  if (mutt_buffer_add_printf(&adata->cmdbuf, \"%s %s\\r\\n\", cmd->seq, cmdstr) < 0)\n    return IMAP_RES_BAD;\n\n  return 0;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":306329,"func":"void ConnectDialog::sendPing(const QHostAddress &host, unsigned short port) {\n\tchar blob[16];\n\n\tServerAddress addr(HostAddress(host), port);\n\n\tquint64 uiRand;\n\tif (qhPingRand.contains(addr)) {\n\t\tuiRand = qhPingRand.value(addr);\n\t} else {\n\t\tuiRand = (static_cast<quint64>(qrand()) << 32) | static_cast<quint64>(qrand());\n\t\tqhPingRand.insert(addr, uiRand);\n\t}\n\n\tmemset(blob, 0, sizeof(blob));\n\t* reinterpret_cast<quint64 *>(blob+8) = tPing.elapsed() ^ uiRand;\n\n\tif (bIPv4 && host.protocol() == QAbstractSocket::IPv4Protocol)\n\t\tqusSocket4->writeDatagram(blob+4, 12, host, port);\n\telse if (bIPv6 && host.protocol() == QAbstractSocket::IPv6Protocol)\n\t\tqusSocket6->writeDatagram(blob+4, 12, host, port);\n\telse\n\t\treturn;\n\n\tconst QSet<ServerItem *> &qs = qhPings.value(addr);\n\n\tforeach(ServerItem *si, qs)\n\t\t++ si->uiSent;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":494578,"func":"void add_tree_ipv4(const unsigned long ip,\n                   const u_char *data,\n                   const int len,\n                   const int datalink)\n{\n    tcpr_tree_t *newnode;\n    assert(data);\n\n    newnode = packet2tree(data, len, datalink);\n    if (newnode) {\n        assert(ip == newnode->u.ip);\n\n        if (newnode->type == DIR_UNKNOWN) {\n            \/* couldn't figure out if packet was client or server *\/\n\n            dbgx(2, \"%s (%lu) unknown client\/server\",\n                 get_addr2name4(newnode->u.ip, RESOLVE),\n                 newnode->u.ip);\n\n        }\n\n        add_tree_node(newnode);\n    }\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":184787,"func":"void RenderFrameImpl::PepperDidReceiveMouseEvent(\n    PepperPluginInstanceImpl* instance) {\n  render_view_->set_pepper_last_mouse_event_target(instance);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":316884,"func":"std::string SerializeSeedBase64(const variations::VariationsSeed& seed) {\n  std::string serialized_seed = SerializeSeed(seed);\n  std::string base64_serialized_seed;\n  base::Base64Encode(Compress(serialized_seed), &base64_serialized_seed);\n  return base64_serialized_seed;\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":385078,"func":"static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, off_t offset TSRMLS_DC)\n{\n\tphar_entry_fp_info *data;\n\n\tif (!entry->is_persistent) {\n\t\tentry->fp_type = type;\n\t\tentry->offset = offset;\n\t\treturn;\n\t}\n\tdata = &(PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos]);\n\tdata->fp_type = type;\n\tdata->offset = offset;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":341004,"func":"static void virtio_net_add_queue(VirtIONet *n, int index)\n\n{\n\n    VirtIODevice *vdev = VIRTIO_DEVICE(n);\n\n\n\n    n->vqs[index].rx_vq = virtio_add_queue(vdev, n->net_conf.rx_queue_size,\n\n                                           virtio_net_handle_rx);\n\n    if (n->net_conf.tx && !strcmp(n->net_conf.tx, \"timer\")) {\n\n        n->vqs[index].tx_vq =\n\n            virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer);\n\n        n->vqs[index].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,\n\n                                              virtio_net_tx_timer,\n\n                                              &n->vqs[index]);\n\n    } else {\n\n        n->vqs[index].tx_vq =\n\n            virtio_add_queue(vdev, 256, virtio_net_handle_tx_bh);\n\n        n->vqs[index].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[index]);\n\n    }\n\n\n\n    n->vqs[index].tx_waiting = 0;\n\n    n->vqs[index].n = n;\n\n}\n","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":92389,"func":"void rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname)\n{\n\t__rpc_init_priority_wait_queue(queue, qname, RPC_NR_PRIORITY);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":259129,"func":"static inline int propagate_entity_load_avg(struct sched_entity *se)\n{\n\treturn 0;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":183323,"func":"static MagickStatusType CorrectPSDOpacity(LayerInfo* layer_info,\n  ExceptionInfo *exception)\n{\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    x;\n\n  ssize_t\n    y;\n\n  if (layer_info->opacity == OpaqueOpacity)\n    return(MagickTrue);\n\n  layer_info->image->matte=MagickTrue;\n  for (y=0; y < (ssize_t) layer_info->image->rows; y++)\n  {\n    q=GetAuthenticPixels(layer_info->image,0,y,layer_info->image->columns,1,\n      exception);\n    if (q == (PixelPacket *) NULL)\n      break;\n    for (x=0; x < (ssize_t) layer_info->image->columns; x++)\n    {\n      q->opacity=(Quantum) (QuantumRange-(Quantum) (QuantumScale*(\n        (QuantumRange-q->opacity)*(QuantumRange-layer_info->opacity))));\n      q++;\n    }\n    if (SyncAuthenticPixels(layer_info->image,exception) == MagickFalse)\n      return(MagickFalse);\n  }\n  return(MagickTrue);\n}\n","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":227975,"func":"    clearMediaPlayerAndAudioSourceProviderClientWithoutLocking() {\n  getAudioSourceProvider().setClient(nullptr);\n  if (m_webMediaPlayer) {\n    m_audioSourceProvider.wrap(nullptr);\n    m_webMediaPlayer.reset();\n  }\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":160245,"func":"static PayloadContext *h264_new_context(void)\n\n{\n\n    PayloadContext *data =\n\n        av_mallocz(sizeof(PayloadContext) +\n\n                   FF_INPUT_BUFFER_PADDING_SIZE);\n\n\n\n    if (data) {\n\n        data->cookie = MAGIC_COOKIE;\n\n    }\n\n\n\n    return data;\n\n}\n","target":1,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":136106,"func":"decrypt_R2004_header (Bit_Chain *restrict dat, BITCODE_RC *restrict decrypted,\n                      unsigned long size, Dwg_Data *restrict dwg)\n{\n  unsigned int rseed = 1;\n  unsigned i;\n\n  \/* Decrypt *\/\n  for (i = 0; i < size; i++)\n    {\n      rseed *= 0x343fd;\n      rseed += 0x269ec3;\n      decrypted[i] = bit_read_RC (dat) ^ (rseed >> 0x10);\n    }\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":181186,"func":"void ContentSecurityPolicy::dispatchViolationEvents(\n    const SecurityPolicyViolationEventInit& violationData,\n    Element* element) {\n  EventQueue* queue = m_executionContext->getEventQueue();\n  if (!queue)\n    return;\n\n  SecurityPolicyViolationEvent* event = SecurityPolicyViolationEvent::create(\n      EventTypeNames::securitypolicyviolation, violationData);\n  DCHECK(event->bubbles());\n\n  if (m_executionContext->isDocument()) {\n    Document* document = toDocument(m_executionContext);\n    if (element && element->isConnected() && element->document() == document)\n      event->setTarget(element);\n    else\n      event->setTarget(document);\n  } else if (m_executionContext->isWorkerGlobalScope()) {\n    event->setTarget(toWorkerGlobalScope(m_executionContext));\n  }\n  queue->enqueueEvent(event);\n}\n","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":192652,"func":"void RenderFrameHostImpl::OnScrollRectToVisibleInParentFrame(\n    const gfx::Rect& rect_to_scroll,\n    const blink::WebScrollIntoViewParams& params) {\n  RenderFrameProxyHost* proxy =\n      frame_tree_node_->render_manager()->GetProxyToParent();\n  if (!proxy)\n    return;\n  proxy->ScrollRectToVisible(rect_to_scroll, params);\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":314882,"func":"static int req_escape_html(lua_State *L)\n{\n    request_rec *r = ap_lua_check_request_rec(L, 1);\n    const char *s = luaL_checkstring(L, 2);\n    lua_pushstring(L, ap_escape_html(r->pool, s));\n    return 1;\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":407963,"func":"TEST(MessageCompressorManager, BadCompressionRequested) {\n    auto input = BSON(\"isMaster\" << 1 << \"compression\" << BSON_ARRAY(\"fakecompressor\"));\n    checkServerNegotiation(input, {});\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":86816,"func":"GF_Err tpyl_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_NTYLBox *ptr = (GF_NTYLBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\tISOM_DECREASE_SIZE(ptr, 8);\n\tptr->nbBytes = gf_bs_read_u64(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":69152,"func":"static inline wchar_t vfat_bad_char(wchar_t w)\n{\n\treturn (w < 0x0020)\n\t    || (w == '*') || (w == '?') || (w == '<') || (w == '>')\n\t    || (w == '|') || (w == '\"') || (w == ':') || (w == '\/')\n\t    || (w == '\\\\');\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":177709,"func":"static int handle_pal_call(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)\n{\n\tstruct exit_ctl_data *p;\n\n\tp = kvm_get_exit_data(vcpu);\n\n\tif (p->exit_reason == EXIT_REASON_PAL_CALL)\n\t\treturn kvm_pal_emul(vcpu, kvm_run);\n\telse {\n\t\tkvm_run->exit_reason = KVM_EXIT_UNKNOWN;\n\t\tkvm_run->hw.hardware_exit_reason = 2;\n\t\treturn 0;\n\t}\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":491358,"func":"find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types)\n{\n  struct cu_tu_set *p;\n  unsigned int nsets;\n  unsigned int dw_sect;\n\n  if (do_types)\n    {\n      p = tu_sets;\n      nsets = tu_count;\n      dw_sect = DW_SECT_TYPES;\n    }\n  else\n    {\n      p = cu_sets;\n      nsets = cu_count;\n      dw_sect = DW_SECT_INFO;\n    }\n  while (nsets > 0)\n    {\n      if (p->section_offsets [dw_sect] == cu_offset)\n\treturn p;\n      p++;\n      nsets--;\n    }\n  return NULL;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":298351,"func":"inline size_t StringData::heapSize() const {\n  return isFlat()\n    ? isRefCounted()\n      ? MemoryManager::sizeIndex2Size(m_aux16)\n      : size() + kStringOverhead\n    : sizeof(StringData) + sizeof(Proxy);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":328613,"func":"void tcg_region_reset_all(void)\n\n{\n\n    unsigned int i;\n\n\n\n    qemu_mutex_lock(®ion.lock);\n\n    region.current = 0;\n\n    region.agg_size_full = 0;\n\n\n\n    for (i = 0; i < n_tcg_ctxs; i++) {\n\n        bool err = tcg_region_initial_alloc__locked(tcg_ctxs[i]);\n\n\n\n        g_assert(!err);\n\n    }\n\n    qemu_mutex_unlock(®ion.lock);\n\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":267739,"func":"void rand_initialize_disk(struct gendisk *disk)\n{\n\tstruct timer_rand_state *state;\n\n\t\/*\n\t * If kzalloc returns null, we just won't use that entropy\n\t * source.\n\t *\/\n\tstate = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL);\n\tif (state) {\n\t\tstate->last_time = INITIAL_JIFFIES;\n\t\tdisk->random = state;\n\t}\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":421360,"func":"eb_unreserve_vma(struct i915_vma *vma, unsigned int *flags)\n{\n\tif (!(*flags & __EXEC_OBJECT_HAS_PIN))\n\t\treturn;\n\n\t__eb_unreserve_vma(vma, *flags);\n\t*flags &= ~__EXEC_OBJECT_RESERVED;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":199132,"func":"static void activityLoggingForAllWorldsPerWorldBindingsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    imp->activityLoggingForAllWorldsPerWorldBindingsVoidMethod();\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":304010,"func":"static int set_tracer_option(struct trace_array *tr, char *cmp, int neg)\n{\n\tstruct tracer *trace = tr->current_trace;\n\tstruct tracer_flags *tracer_flags = trace->flags;\n\tstruct tracer_opt *opts = NULL;\n\tint i;\n\n\tfor (i = 0; tracer_flags->opts[i].name; i++) {\n\t\topts = &tracer_flags->opts[i];\n\n\t\tif (strcmp(cmp, opts->name) == 0)\n\t\t\treturn __set_tracer_option(tr, trace->flags, opts, neg);\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":96075,"func":"CModule::EModRet CModule::OnPrivCTCPMessage(CCTCPMessage& Message) {\n    CString sText = Message.GetText();\n    EModRet ret = OnPrivCTCP(Message.GetNick(), sText);\n    Message.SetText(sText);\n    return ret;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":499147,"func":"static int sqfs_disk_read(__u32 block, __u32 nr_blocks, void *buf)\n{\n\tulong ret;\n\n\tif (!ctxt.cur_dev)\n\t\treturn -1;\n\n\tret = blk_dread(ctxt.cur_dev, ctxt.cur_part_info.start + block,\n\t\t\tnr_blocks, buf);\n\n\tif (ret != nr_blocks)\n\t\treturn -1;\n\n\treturn ret;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":400533,"func":"MagickExport const OptionInfo *GetCommandOptionInfo(const char *option)\n{\n  register ssize_t\n    i;\n\n  for (i=0; CommandOptions[i].mnemonic != (char *) NULL; i++)\n    if (LocaleCompare(option,CommandOptions[i].mnemonic) == 0)\n      break;\n  return(CommandOptions+i);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":308977,"func":"static int storebuffer(int output, FILE *data)\n{\n  char **buffer = (char **)data;\n  unsigned char outc = (unsigned char)output;\n  **buffer = outc;\n  (*buffer)++;\n  return outc; \/* act like fputc() ! *\/\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":432153,"func":"static int snd_line6_impulse_period_info(struct snd_kcontrol *kcontrol,\n\t\t\t\t\t struct snd_ctl_elem_info *uinfo)\n{\n\tuinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;\n\tuinfo->count = 1;\n\tuinfo->value.integer.min = 0;\n\tuinfo->value.integer.max = 2000;\n\treturn 0;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":439647,"func":"  bool matches(const Ref *idA, double m11A, double m12A,\n\t\tdouble m21A, double m22A)\n    { return fontID == *idA &&\n\t     m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; }","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":162495,"func":"void WebContentsImpl::IncrementCapturerCount() {\n  DCHECK(!is_being_destroyed_);\n  ++capturer_count_;\n  DVLOG(1) << \"There are now \" << capturer_count_\n           << \" capturing(s) of WebContentsImpl@\" << this;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":502958,"func":"static void ReplaceIRINode(GF_Node *FromNode, GF_Node *old_node, GF_Node *newNode)\n{\n\tGF_ChildNodeItem *prev = NULL;\n\tGF_ChildNodeItem *child = ((SVG_Element *)FromNode)->children;\n\twhile (child) {\n\t\tif (child->node != old_node) {\n\t\t\tprev = child;\n\t\t\tchild = child->next;\n\t\t\tcontinue;\n\t\t}\n\t\tif (newNode) {\n\t\t\tchild->node = newNode;\n\t\t} else {\n\t\t\tif (prev) prev->next = child->next;\n\t\t\telse ((SVG_Element *)FromNode)->children = child->next;\n\t\t\tgf_free(child);\n\t\t}\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":394125,"func":"PHP_METHOD(Phar, offsetExists)\n{\n\tchar *fname;\n\tint fname_len;\n\tphar_entry_info *entry;\n\n\tPHAR_ARCHIVE_OBJECT();\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"p\", &fname, &fname_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {\n\t\tif (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {\n\t\t\tif (entry->is_deleted) {\n\t\t\t\t\/* entry is deleted, but has not been flushed to disk yet *\/\n\t\t\t\tRETURN_FALSE;\n\t\t\t}\n\t\t}\n\n\t\tif (fname_len >= sizeof(\".phar\")-1 && !memcmp(fname, \".phar\", sizeof(\".phar\")-1)) {\n\t\t\t\/* none of these are real files, so they don't exist *\/\n\t\t\tRETURN_FALSE;\n\t\t}\n\t\tRETURN_TRUE;\n\t} else {\n\t\tif (zend_hash_exists(&phar_obj->arc.archive->virtual_dirs, fname, (uint) fname_len)) {\n\t\t\tRETURN_TRUE;\n\t\t}\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":436318,"func":"onig_capture_tree_traverse(OnigRegion* region, int at,\n                  int(*callback_func)(int,int,int,int,int,void*), void* arg)\n{\n#ifdef USE_CAPTURE_HISTORY\n  return capture_tree_traverse(region->history_root, at,\n                               callback_func, 0, arg);\n#else\n  return ONIG_NO_SUPPORT_CONFIG;\n#endif\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":78039,"func":"static void macvlan_port_destroy(struct net_device *dev)\n{\n\tstruct macvlan_port *port = macvlan_port_get(dev);\n\n\tdev->priv_flags &= ~IFF_MACVLAN_PORT;\n\tnetdev_rx_handler_unregister(dev);\n\tkfree_rcu(port, rcu);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":514054,"func":"toggle_display_of_ipc_commands()\n{\n    if (mouse_setting.verbose)\n\tmouse_setting.verbose = 0;\n    else\n\tmouse_setting.verbose = 1;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":517456,"func":"  Item* get_copy(THD *thd, MEM_ROOT *mem_root)\n  { return get_item_copy<Item_ident_for_show>(thd, mem_root, this); }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":53379,"func":"static int xen_evtchn_cpu_dead(unsigned int cpu)\n{\n\tint ret = 0;\n\n\tif (evtchn_ops->percpu_deinit)\n\t\tret = evtchn_ops->percpu_deinit(cpu);\n\n\treturn ret;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":486942,"func":"grammar_current_rule_begin (symbol *lhs, location loc,\n                            named_ref *lhs_name)\n{\n  \/* Start a new rule and record its lhs.  *\/\n  ++nrules;\n  previous_rule_end = grammar_end;\n\n  current_rule = grammar_symbol_append (lhs, loc);\n  if (lhs_name)\n    assign_named_ref (current_rule, named_ref_copy (lhs_name));\n\n  \/* Mark the rule's lhs as a nonterminal if not already so.  *\/\n  if (lhs->content->class == unknown_sym || lhs->content->class == pct_type_sym)\n    symbol_class_set (lhs, nterm_sym, empty_loc, false);\n  else if (lhs->content->class == token_sym)\n    complain (&loc, complaint, _(\"rule given for %s, which is a token\"),\n              lhs->tag);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":327063,"func":"void OPPROTO op_fdivr_ST0_FT0(void)\n\n{\n\n    ST0 = FT0 \/ ST0;\n\n}\n","target":1,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":523377,"func":"bool LEX::call_statement_start(THD *thd, sp_name *name)\n{\n  Database_qualified_name pkgname(&null_clex_str, &null_clex_str);\n  const Sp_handler *sph= &sp_handler_procedure;\n  sql_command= SQLCOM_CALL;\n  value_list.empty();\n  if (unlikely(sph->sp_resolve_package_routine(thd, thd->lex->sphead,\n                                               name, &sph, &pkgname)))\n    return true;\n  if (unlikely(!(m_sql_cmd= new (thd->mem_root) Sql_cmd_call(name, sph))))\n    return true;\n  sph->add_used_routine(this, thd, name);\n  if (pkgname.m_name.length)\n    sp_handler_package_body.add_used_routine(this, thd, &pkgname);\n  return false;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":157203,"func":"regexp_engine const *\nPerl_current_re_engine(pTHX)\n{\n    if (IN_PERL_COMPILETIME) {\n\tHV * const table = GvHV(PL_hintgv);\n\tSV **ptr;\n\n\tif (!table || !(PL_hints & HINT_LOCALIZE_HH))\n\t    return &PL_core_reg_engine;\n\tptr = hv_fetchs(table, \"regcomp\", FALSE);\n\tif ( !(ptr && SvIOK(*ptr) && SvIV(*ptr)))\n\t    return &PL_core_reg_engine;\n\treturn INT2PTR(regexp_engine*, SvIV(*ptr));\n    }\n    else {\n\tSV *ptr;\n\tif (!PL_curcop->cop_hints_hash)\n\t    return &PL_core_reg_engine;\n\tptr = cop_hints_fetch_pvs(PL_curcop, \"regcomp\", 0);\n\tif ( !(ptr && SvIOK(ptr) && SvIV(ptr)))\n\t    return &PL_core_reg_engine;\n\treturn INT2PTR(regexp_engine*, SvIV(ptr));\n    }","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":179714,"func":"void BlobURLRequestJob::CreateFileStreamReader(size_t index,\n                                               int64 additional_offset) {\n  DCHECK_LT(index, blob_data_->items().size());\n  const BlobData::Item& item = blob_data_->items().at(index);\n  DCHECK(IsFileType(item.type()));\n  DCHECK_EQ(0U, index_to_reader_.count(index));\n\n  FileStreamReader* reader = NULL;\n  switch (item.type()) {\n    case BlobData::Item::TYPE_FILE:\n      reader = new LocalFileStreamReader(\n          file_thread_proxy_,\n          item.path(),\n          item.offset() + additional_offset,\n          item.expected_modification_time());\n      break;\n    case BlobData::Item::TYPE_FILE_FILESYSTEM:\n      reader = file_system_context_->CreateFileStreamReader(\n          fileapi::FileSystemURL(file_system_context_->CrackURL(item.url())),\n          item.offset() + additional_offset,\n          item.expected_modification_time());\n      break;\n    default:\n      NOTREACHED();\n  }\n  DCHECK(reader);\n  index_to_reader_[index] = reader;\n}\n","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":115852,"func":"static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribute *attr, char *buf)\n{\n\tstruct aiptek *aiptek = dev_get_drvdata(dev);\n\n\treturn snprintf(buf, PAGE_SIZE, \"%s\\n\",\n\t\t\tmap_val_to_str(stylus_button_map,\n\t\t\t\t\taiptek->curSetting.stylusButtonLower));\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":53034,"func":"static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb,\n                             unsigned len, const char *key)\n{\n    short genre;\n    char buf[20];\n\n    avio_r8(pb); \/\/ unknown\n\n    genre = avio_r8(pb);\n    if (genre < 1 || genre > ID3v1_GENRE_MAX)\n        return 0;\n    snprintf(buf, sizeof(buf), \"%s\", ff_id3v1_genre_str[genre-1]);\n    av_dict_set(&c->fc->metadata, key, buf, 0);\n\n    return 0;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":265048,"func":"    SG_Exception_BadSum::SG_Exception_BadSum(const char* container_name, const char* arg1, const char* arg2)\n    {\n        std::string cn_s(container_name);\n        std::string arg1_s(arg1);\n        std::string arg2_s(arg2);\n\n        this -> err_msg = \"[\" + cn_s + \"]\"\n                + \" The sum of all values in \"\n                + arg1_s\n                + \" and \"\n                + arg2_s\n                + \" do not match.\";\n    }","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":116952,"func":"int tcp_sendpage(struct sock *sk, struct page *page, int offset,\n\t\t size_t size, int flags)\n{\n\tssize_t res;\n\n\tif (!(sk->sk_route_caps & NETIF_F_SG) ||\n\t    !sk_check_csum_caps(sk))\n\t\treturn sock_no_sendpage(sk->sk_socket, page, offset, size,\n\t\t\t\t\tflags);\n\n\tlock_sock(sk);\n\n\ttcp_rate_check_app_limited(sk);  \/* is sending application-limited? *\/\n\n\tres = do_tcp_sendpages(sk, page, offset, size, flags);\n\trelease_sock(sk);\n\treturn res;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":122585,"func":"int usb_disabled(void)\n{\n\treturn nousb;\n}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":503824,"func":"void FilterManager::maybeEndDecode(bool end_stream) {\n  \/\/ If recreateStream is called, the HCM rewinds state and may send more encodeData calls.\n  if (end_stream && !remoteDecodeComplete()) {\n    stream_info_.downstreamTiming().onLastDownstreamRxByteReceived(dispatcher().timeSource());\n    ENVOY_STREAM_LOG(debug, \"request end stream\", *this);\n  }\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":14961,"func":"static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)\n\n{\n\n        hw_error(\"Unsupported short raccess. reg=\" TARGET_FMT_plx \"\\n\", addr);\n\n        return 0;\n\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":91699,"func":"static void mipspmu_del(struct perf_event *event, int flags)\n{\n\tstruct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);\n\tstruct hw_perf_event *hwc = &event->hw;\n\tint idx = hwc->idx;\n\n\tWARN_ON(idx < 0 || idx >= mipspmu->num_counters);\n\n\tmipspmu_stop(event, PERF_EF_UPDATE);\n\tcpuc->events[idx] = NULL;\n\tclear_bit(idx, cpuc->used_mask);\n\n\tperf_event_update_userpage(event);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":216164,"func":"rule_criteria_destroy(struct rule_criteria *criteria)\n{\n    cls_rule_destroy(&criteria->cr);\n    criteria->version = OVS_VERSION_NOT_REMOVED; \/* Mark as destroyed. *\/\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":238487,"func":"filesystem_create_wait_for_luks_device_not_seen_cb (gpointer user_data)\n{\n  MkfsLuksData *data = user_data;\n\n  throw_error (data->context,\n               ERROR_FAILED,\n               \"Error creating luks encrypted file system: timeout (10s) waiting for luks device to show up\");\n\n  g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id);\n  mkfse_data_unref (data);\n\n  return FALSE;\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":514524,"func":"const char* Http2Session::TypeName() const {\n  switch (session_type_) {\n    case NGHTTP2_SESSION_SERVER: return \"server\";\n    case NGHTTP2_SESSION_CLIENT: return \"client\";\n    default:\n      \/\/ This should never happen\n      ABORT();\n  }\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":333855,"func":"static int aio_epoll(AioContext *ctx, GPollFD *pfds,\n\n                     unsigned npfd, int64_t timeout)\n\n{\n\n    assert(false);\n\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":379695,"func":"static int ZEND_FASTCALL  ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\treturn zend_fetch_property_address_read_helper_SPEC_UNUSED_VAR(BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":404896,"func":"static void l2cap_state_change(struct l2cap_chan *chan, int state)\n{\n\tBT_DBG(\"chan %p %s -> %s\", chan, state_to_string(chan->state),\n\t       state_to_string(state));\n\n\tchan->state = state;\n\tchan->ops->state_change(chan, state, 0);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":438756,"func":"at_subpath(int fd, size_t baselen, const char *path)\n{\n#if USE_OPENDIR_AT\n    if (fd != (int)AT_FDCWD && baselen > 0) {\n\tpath += baselen;\n\tif (*path == '\/') ++path;\n    }\n#endif\n    return *path ? path : \".\";\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":126206,"func":"static int af9005_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)\n{\n\tint ret;\n\tdeb_info(\"pid filter control  onoff %d\\n\", onoff);\n\tif (onoff) {\n\t\tret =\n\t\t    af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 1);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tret =\n\t\t    af9005_write_register_bits(adap->dev,\n\t\t\t\t\t       XD_MP2IF_DMX_CTRL, 1, 1, 1);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tret =\n\t\t    af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 1);\n\t} else\n\t\tret =\n\t\t    af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 0);\n\tif (ret)\n\t\treturn ret;\n\tdeb_info(\"pid filter control ok\\n\");\n\treturn 0;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":317227,"func":"void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) {\n  DCHECK(!run_modal_reply_msg_);\n  run_modal_reply_msg_ = reply_msg;\n  run_modal_opener_id_ = opener_id;\n\n  RecordAction(UserMetricsAction(\"ShowModalDialog\"));\n\n  RenderViewHostImpl* opener =\n      RenderViewHostImpl::FromID(GetProcess()->GetID(), run_modal_opener_id_);\n  if (opener) {\n    opener->StopHangMonitorTimeout();\n    opener->decrement_in_flight_event_count();\n  }\n\n}\n","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":316625,"func":"Element* RootEditableElementOfSelection(const FrameSelection& frameSelection) {\n  const SelectionInDOMTree& selection = frameSelection.GetSelectionInDOMTree();\n  if (selection.IsNone())\n    return nullptr;\n  if (Element* editable = RootEditableElementOf(selection.Base()))\n    return editable;\n\n\n  frameSelection.GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();\n  const VisibleSelection& visibleSeleciton =\n      frameSelection.ComputeVisibleSelectionInDOMTree();\n  return RootEditableElementOf(visibleSeleciton.Start());\n}\n","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":474162,"func":"static inline void unix_release_addr(struct unix_address *addr)\n{\n\tif (refcount_dec_and_test(&addr->refcnt))\n\t\tkfree(addr);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":404577,"func":"tiff_load_map_file (thandle_t handle, tdata_t *buf, toff_t *size)\n{\n        TiffContext *context = (TiffContext *)handle;\n        \n        *buf = context->buffer;\n        *size = context->used;\n        \n        return 0;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":431356,"func":"    const char* dbrefNS() const {\n        uassert(10063, \"not a dbref\", type() == DBRef);\n        return value() + 4;\n    }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":189870,"func":"bool HTMLLinkElement::HasLegalLinkAttribute(const QualifiedName& name) const {\n  return name == hrefAttr || HTMLElement::HasLegalLinkAttribute(name);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":308904,"func":"void DatabaseMessageFilter::OnDatabaseGetUsageAndQuota(\n    IPC::Message* reply_msg,\n    quota::QuotaStatusCode status,\n    int64 usage,\n    int64 quota) {\n  int64 available = 0;\n  if ((status == quota::kQuotaStatusOk) && (usage < quota))\n    available = quota - usage;\n  DatabaseHostMsg_GetSpaceAvailable::WriteReplyParams(reply_msg, available);\n  Send(reply_msg);\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":172849,"func":"bool ClipboardUtil::GetWebCustomData(\n    IDataObject* data_object,\n    std::map<base::string16, base::string16>* custom_data) {\n  DCHECK(data_object && custom_data);\n\n  if (!HasData(data_object, Clipboard::GetWebCustomDataFormatType()))\n    return false;\n\n   STGMEDIUM store;\n   if (GetData(data_object, Clipboard::GetWebCustomDataFormatType(), &store)) {\n     {\n      base::win::ScopedHGlobal<char*> data(store.hGlobal);\n       ReadCustomDataIntoMap(data.get(), data.Size(), custom_data);\n     }\n     ReleaseStgMedium(&store);\n    return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":247879,"func":"void WorkerThread::willDestroyIsolate()\n{\n    ASSERT(isCurrentThread());\n    ASSERT(m_isolate);\n    V8PerIsolateData::willBeDestroyed(m_isolate);\n    ThreadState::current()->removeInterruptor(m_interruptor.get());\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":484073,"func":"static void i740fb_ddc_setsda(void *data, int val)\n{\n\tstruct i740fb_par *par = data;\n\n\ti740outreg_mask(par, XRX, REG_DDC_DRIVE, DDC_SDA, DDC_SDA);\n\ti740outreg_mask(par, XRX, REG_DDC_STATE, val ? DDC_SDA : 0, DDC_SDA);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":111635,"func":"bos_reply_print(netdissect_options *ndo,\n                register const u_char *bp, int length, int32_t opcode)\n{\n\tconst struct rx_header *rxh;\n\n\tif (length <= (int)sizeof(struct rx_header))\n\t\treturn;\n\n\trxh = (const struct rx_header *) bp;\n\n\t\/*\n\t * Print out the afs call we're invoking.  The table used here was\n\t * gleaned from volser\/volint.xg\n\t *\/\n\n\tND_PRINT((ndo, \" bos reply %s\", tok2str(bos_req, \"op#%d\", opcode)));\n\n\tbp += sizeof(struct rx_header);\n\n\t\/*\n\t * If it was a data packet, interpret the response.\n\t *\/\n\n\tif (rxh->type == RX_PACKET_TYPE_DATA)\n\t\t\/* Well, no, not really.  Leave this for later *\/\n\t\t;\n\telse {\n\t\t\/*\n\t\t * Otherwise, just print out the return code\n\t\t *\/\n\t\tND_PRINT((ndo, \" errcode\"));\n\t\tINTOUT();\n\t}\n\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \" [|bos]\"));\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":180347,"func":"void JSTestActiveDOMObject::destroy(JSC::JSCell* cell)\n{\n    JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(cell);\n    thisObject->JSTestActiveDOMObject::~JSTestActiveDOMObject();\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":295445,"func":"int wc_SetAuthKeyIdFromCert(Cert *cert, const byte *der, int derSz)\n{\n    int ret = 0;\n\n    if (cert == NULL) {\n        ret = BAD_FUNC_ARG;\n    }\n    else {\n        \/* Check if decodedCert is cached *\/\n        if (cert->der != der) {\n            \/* Allocate cache for the decoded cert *\/\n            ret = wc_SetCert_LoadDer(cert, der, derSz);\n        }\n\n        if (ret >= 0) {\n            ret = SetAuthKeyIdFromDcert(cert, (DecodedCert*)cert->decodedCert);\n#ifndef WOLFSSL_CERT_GEN_CACHE\n            wc_SetCert_Free(cert);\n#endif\n        }\n    }\n\n    return ret;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":222895,"func":"SoftMPEG4Encoder::~SoftMPEG4Encoder() {\n    ALOGV(\"Destruct SoftMPEG4Encoder\");\n    releaseEncoder();\n List<BufferInfo *> &outQueue = getPortQueue(1);\n List<BufferInfo *> &inQueue = getPortQueue(0);\n    CHECK(outQueue.empty());\n    CHECK(inQueue.empty());\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":214737,"func":" jbig2_sd_release(Jbig2Ctx *ctx, Jbig2SymbolDict *dict)\n {\n    uint32_t i;\n \n     if (dict == NULL)\n         return;\n    for (i = 0; i < dict->n_symbols; i++)\n        if (dict->glyphs[i])\n            jbig2_image_release(ctx, dict->glyphs[i]);\n    jbig2_free(ctx->allocator, dict->glyphs);\n    jbig2_free(ctx->allocator, dict);\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":468974,"func":"kvm_pfn_t __gfn_to_pfn_memslot(struct kvm_memory_slot *slot, gfn_t gfn,\n\t\t\t       bool atomic, bool *async, bool write_fault,\n\t\t\t       bool *writable, hva_t *hva)\n{\n\tunsigned long addr = __gfn_to_hva_many(slot, gfn, NULL, write_fault);\n\n\tif (hva)\n\t\t*hva = addr;\n\n\tif (addr == KVM_HVA_ERR_RO_BAD) {\n\t\tif (writable)\n\t\t\t*writable = false;\n\t\treturn KVM_PFN_ERR_RO_FAULT;\n\t}\n\n\tif (kvm_is_error_hva(addr)) {\n\t\tif (writable)\n\t\t\t*writable = false;\n\t\treturn KVM_PFN_NOSLOT;\n\t}\n\n\t\/* Do not map writable pfn in the readonly memslot. *\/\n\tif (writable && memslot_is_readonly(slot)) {\n\t\t*writable = false;\n\t\twritable = NULL;\n\t}\n\n\treturn hva_to_pfn(addr, atomic, async, write_fault,\n\t\t\t  writable);\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":301460,"func":"void CLASS kodak_65000_load_raw()\n{\n  short buf[272]; \/* 264 looks enough *\/\n  int row, col, len, pred[2], ret, i;\n\n  for (row = 0; row < height; row++)\n  {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    for (col = 0; col < width; col += 256)\n    {\n      pred[0] = pred[1] = 0;\n      len = MIN(256, width - col);\n      ret = kodak_65000_decode(buf, len);\n      for (i = 0; i < len; i++)\n      {\n        int idx = ret ? buf[i] : (pred[i & 1] += buf[i]);\n\tif(idx >=0 && idx < 0xffff)\n\t {\n           if ((RAW(row, col + i) = curve[idx]) >> 12)\n          derror();\n\t  }\n\t else\n\t  derror();\n      }\n    }\n  }\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":202597,"func":"void RenderViewTest::LoadHTML(const char* html) {\n  std::string url_str = \"data:text\/html;charset=utf-8,\";\n  url_str.append(html);\n  GURL url(url_str);\n\n  GetMainFrame()->loadRequest(WebURLRequest(url));\n\n  ProcessPendingMessages();\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":235679,"func":"  ~Logger() {}\n","target":0,"code_token_length":5,"total_token_length":241,"max_tokens_setting":512}
+{"idx":360885,"func":"on_config_changed (GConfClient          *client,\n                   guint                 cnxn_id,\n                   GConfEntry           *entry,\n                   GsdXrandrManager *manager)\n{\n        start_or_stop_icon (manager);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":158991,"func":"\t\tGeneration(const string &serverInstanceDir, unsigned int number) {\n\t\t\tpath = serverInstanceDir + \"\/generation-\" + toString(number);\n\t\t\tthis->number = number;\n\t\t\towner = false;\n\t\t}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":421287,"func":"static void iovec_advance(struct iovec iov[], unsigned *idx, size_t size) {\n\n        while (size > 0) {\n                struct iovec *i = iov + *idx;\n\n                if (i->iov_len > size) {\n                        i->iov_base = (uint8_t*) i->iov_base + size;\n                        i->iov_len -= size;\n                        return;\n                }\n\n                size -= i->iov_len;\n\n                *i = IOVEC_MAKE(NULL, 0);\n\n                (*idx)++;\n        }\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":159900,"func":"    ClientThread(Messenger *m, int c, ConnectionRef con, int len, int ops, int think_time_us):\n        msgr(m), concurrent(c), conn(con), oid(\"object-name\"), oloc(1, 1), msg_len(len), ops(ops),\n        dispatcher(think_time_us, this), lock(\"MessengerBenchmark::ClientThread::lock\"), inflight(0) {\n      m->add_dispatcher_head(&dispatcher);\n      bufferptr ptr(msg_len);\n      memset(ptr.c_str(), 0, msg_len);\n      data.append(ptr);\n    }","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":432225,"func":"static bool log_access_ok(void __user *log_base, u64 addr, unsigned long sz)\n{\n\tu64 a = addr \/ VHOST_PAGE_SIZE \/ 8;\n\n\t\/* Make sure 64 bit math will not overflow. *\/\n\tif (a > ULONG_MAX - (unsigned long)log_base ||\n\t    a + (unsigned long)log_base > ULONG_MAX)\n\t\treturn false;\n\n\treturn access_ok(log_base + a,\n\t\t\t (sz + VHOST_PAGE_SIZE * 8 - 1) \/ VHOST_PAGE_SIZE \/ 8);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":102126,"func":"TRIO_PUBLIC_STRING int trio_xstring_match TRIO_ARGS2((self, other), trio_string_t* self,\n                                                     TRIO_CONST char* other)\n{\n\tassert(self);\n\tassert(other);\n\n\treturn trio_match(self->content, other);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":337104,"func":"static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len,\n\n                               char *dst, int dstlen)\n\n{\n\n    char *p = dst;\n\n    char *end = dst+dstlen-1;\n\n    int i;\n\n\n\n    for (i = 0; i < len; i++) {\n\n        uint8_t t, c = avio_r8(pb);\n\n        if (c < 0x80 && p < end)\n\n            *p++ = c;\n\n        else\n\n            PUT_UTF8(mac_to_unicode[c-0x80], t, if (p < end) *p++ = t;);\n\n    }\n\n    *p = 0;\n\n    return p - dst;\n\n}\n","target":1,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":41854,"func":"int sctp_register_af(struct sctp_af *af)\n{\n\tswitch (af->sa_family) {\n\tcase AF_INET:\n\t\tif (sctp_af_v4_specific)\n\t\t\treturn 0;\n\t\tsctp_af_v4_specific = af;\n\t\tbreak;\n\tcase AF_INET6:\n\t\tif (sctp_af_v6_specific)\n\t\t\treturn 0;\n\t\tsctp_af_v6_specific = af;\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\tINIT_LIST_HEAD(&af->list);\n\tlist_add_tail(&af->list, &sctp_address_families);\n\treturn 1;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":75457,"func":"static void async_newpending(struct async *as)\n{\n\tstruct usb_dev_state *ps = as->ps;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&ps->lock, flags);\n\tlist_add_tail(&as->asynclist, &ps->async_pending);\n\tspin_unlock_irqrestore(&ps->lock, flags);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":259848,"func":"static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *mntfh,\n\t\t\t      struct nfs_fsinfo *info)\n{\n\tint error;\n\tstruct nfs_fattr *fattr = info->fattr;\n\n\terror = nfs4_server_capabilities(server, mntfh);\n\tif (error < 0) {\n\t\tdprintk(\"nfs4_get_root: getcaps error = %d\\n\", -error);\n\t\treturn error;\n\t}\n\n\terror = nfs4_proc_getattr(server, mntfh, fattr);\n\tif (error < 0) {\n\t\tdprintk(\"nfs4_get_root: getattr error = %d\\n\", -error);\n\t\treturn error;\n\t}\n\n\tif (fattr->valid & NFS_ATTR_FATTR_FSID &&\n\t    !nfs_fsid_equal(&server->fsid, &fattr->fsid))\n\t\tmemcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid));\n\n\treturn error;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":156360,"func":"void WebContents::FindReply(content::WebContents* web_contents,\n                            int request_id,\n                            int number_of_matches,\n                            const gfx::Rect& selection_rect,\n                            int active_match_ordinal,\n                            bool final_update) {\n  if (!final_update)\n    return;\n\n  v8::Locker locker(isolate());\n  v8::HandleScope handle_scope(isolate());\n  gin_helper::Dictionary result = gin::Dictionary::CreateEmpty(isolate());\n  result.Set(\"requestId\", request_id);\n  result.Set(\"matches\", number_of_matches);\n  result.Set(\"selectionArea\", selection_rect);\n  result.Set(\"activeMatchOrdinal\", active_match_ordinal);\n  result.Set(\"finalUpdate\", final_update);  \/\/ Deprecate after 2.0\n  Emit(\"found-in-page\", result.GetHandle());\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":446708,"func":"virDomainDefPostParseCheckFailure(virDomainDefPtr def,\n                                  unsigned int parseFlags,\n                                  int ret)\n{\n    if (ret != 0)\n        def->postParseFailed = true;\n\n    if (ret <= 0)\n        return ret;\n\n    if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL))\n        return -1;\n\n    virResetLastError();\n    return 0;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":171869,"func":"void SyncManager::UpdateCredentials(const SyncCredentials& credentials) {\n  DCHECK(thread_checker_.CalledOnValidThread());\n  data_->UpdateCredentials(credentials);\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":244397,"func":"static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, bool timelinePrefix)\n{\n    ConsoleHelper helper(info);\n    if (V8InspectorClient* client = helper.ensureDebuggerClient()) {\n        String16 protocolTitle = helper.firstArgToString(\"default\");\n        if (timelinePrefix)\n            protocolTitle = \"Timeline '\" + protocolTitle + \"'\";\n        client->consoleTime(protocolTitle);\n\n        v8::Local<v8::Map> timeMap;\n        if (!helper.privateMap(\"V8Console#timeMap\").ToLocal(&timeMap))\n            return;\n        helper.setDoubleOnMap(timeMap, protocolTitle, client->currentTimeMS());\n    }\n}\n","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":172714,"func":"SpeechRecognitionManagerImpl::FrameDeletionObserver::~FrameDeletionObserver() {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n\n  DCHECK_EQ(0u, contents_observers_.size());\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":387069,"func":"static int ssl_write_split( ssl_context *ssl,\n                            const unsigned char *buf, size_t len )\n{\n    int ret;\n\n    if( ssl->split_done == SSL_CBC_RECORD_SPLITTING_DISABLED ||\n        len <= 1 ||\n        ssl->minor_ver > SSL_MINOR_VERSION_1 ||\n        cipher_get_cipher_mode( &ssl->transform_out->cipher_ctx_enc )\n                                != POLARSSL_MODE_CBC )\n    {\n        return( ssl_write_real( ssl, buf, len ) );\n    }\n\n    if( ssl->split_done == 0 )\n    {\n        if( ( ret = ssl_write_real( ssl, buf, 1 ) ) <= 0 )\n            return( ret );\n        ssl->split_done = 1;\n    }\n\n    if( ( ret = ssl_write_real( ssl, buf + 1, len - 1 ) ) <= 0 )\n        return( ret );\n    ssl->split_done = 0;\n\n    return( ret + 1 );\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":235208,"func":"void V8InjectedScriptHost::proxyTargetValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    if (info.Length() != 1 || !info[0]->IsProxy()) {\n        NOTREACHED();\n        return;\n    }\n    v8::Local<v8::Object> target = info[0].As<v8::Proxy>();\n    while (target->IsProxy())\n        target = v8::Local<v8::Proxy>::Cast(target)->GetTarget();\n    info.GetReturnValue().Set(target);\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":240570,"func":"int64_t LayerTreeHostQt::adoptImageBackingStore(Image* image)\n{\n    if (!image)\n        return InvalidWebLayerID;\n    QPixmap* pixmap = image->nativeImageForCurrentFrame();\n\n    if (!pixmap)\n        return InvalidWebLayerID;\n\n    int64_t key = pixmap->cacheKey();\n    HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key);\n\n    if (it != m_directlyCompositedImageRefCounts.end()) {\n        ++(it->second);\n        return key;\n    }\n\n    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0);\n    {\n        OwnPtr<WebCore::GraphicsContext> graphicsContext = bitmap->createGraphicsContext();\n        graphicsContext->drawImage(image, ColorSpaceDeviceRGB, IntPoint::zero());\n    }\n\n    ShareableBitmap::Handle handle;\n    bitmap->createHandle(handle);\n    m_webPage->send(Messages::LayerTreeHostProxy::CreateDirectlyCompositedImage(key, handle));\n    m_directlyCompositedImageRefCounts.add(key, 1);\n    return key;\n}\n","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":34865,"func":"int evdns_resolve_ipv6(const char *name, int flags,\n    evdns_callback_type callback, void *ptr) {\n\treturn evdns_base_resolve_ipv6(current_base, name, flags, callback, ptr)\n\t\t? 0 : -1;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":489487,"func":"GF_Err chan_box_dump(GF_Box *a, FILE * trace)\n{\n\tu32 i;\n\tGF_ChannelLayoutInfoBox *p = (GF_ChannelLayoutInfoBox *) a;\n\n\tgf_isom_box_dump_start(a, \"ChannelLayoutInfoBox\", trace);\n\tgf_fprintf(trace, \"layout=\\\"%d\\\" bitmap=\\\"%d\\\">\\n\", p->layout_tag, p->bitmap);\n\tfor (i=0; i<p->num_audio_description; i++) {\n\t\tGF_AudioChannelDescription *adesc = &p->audio_descs[i];\n\t\tgf_fprintf(trace, \"<AudioChannelDescription label=\\\"%d\\\" flags=\\\"%08X\\\" coordinates=\\\"%f %f %f\\\"\/>\\n\", adesc->label, adesc->flags, adesc->coordinates[0], adesc->coordinates[1], adesc->coordinates[2]);\n\t}\n\tgf_isom_box_dump_done(\"ChannelLayoutInfoBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":46818,"func":"AVFrame *avcodec_alloc_frame(void)\n\n{\n\n    AVFrame *frame = av_mallocz(sizeof(AVFrame));\n\n\n\n    if (frame == NULL)\n\n        return NULL;\n\n\n\nFF_DISABLE_DEPRECATION_WARNINGS\n\n    avcodec_get_frame_defaults(frame);\n\nFF_ENABLE_DEPRECATION_WARNINGS\n\n\n\n    return frame;\n\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":492457,"func":"    bool operator!=(const DateTimeVal& other) const { return !(*this == other); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":241521,"func":"static void set_pixel_format(VncState *vs,\n                             int bits_per_pixel, int depth,\n                             int big_endian_flag, int true_color_flag,\n                             int red_max, int green_max, int blue_max,\n                             int red_shift, int green_shift, int blue_shift)\n{\n    if (!true_color_flag) {\n        vnc_client_error(vs);\n         return;\n     }\n \n    switch (bits_per_pixel) {\n    case 8:\n    case 16:\n    case 32:\n        break;\n    default:\n        vnc_client_error(vs);\n        return;\n    }\n\n     vs->client_pf.rmax = red_max;\n     vs->client_pf.rbits = hweight_long(red_max);\n     vs->client_pf.rshift = red_shift;\n    vs->client_pf.bytes_per_pixel = bits_per_pixel \/ 8;\n    vs->client_pf.depth = bits_per_pixel == 32 ? 24 : bits_per_pixel;\n    vs->client_be = big_endian_flag;\n\n    set_pixel_conversion(vs);\n\n    graphic_hw_invalidate(NULL);\n    graphic_hw_update(NULL);\n}\n","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":353007,"func":"v8::Local<v8::Object> CreateNativeEvent(\n    v8::Isolate* isolate,\n    v8::Local<v8::Object> sender,\n    content::RenderFrameHost* frame,\n    electron::mojom::ElectronBrowser::MessageSyncCallback callback) {\n  v8::Local<v8::Object> event;\n  if (frame && callback) {\n    gin::Handle<Event> native_event = Event::Create(isolate);\n    native_event->SetCallback(std::move(callback));\n    event = native_event.ToV8().As<v8::Object>();\n  } else {\n    \/\/ No need to create native event if we do not need to send reply.\n    event = CreateEvent(isolate);\n  }\n\n  Dictionary dict(isolate, event);\n  dict.Set(\"sender\", sender);\n  \/\/ Should always set frameId even when callback is null.\n  if (frame) {\n    dict.Set(\"frameId\", frame->GetRoutingID());\n    dict.Set(\"processId\", frame->GetProcess()->GetID());\n  }\n  return event;\n}","target":1,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":416139,"func":"gdev_pdf_put_params(gx_device * dev, gs_param_list * plist)\n{\n    int code;\n    gx_device_pdf *pdev = (gx_device_pdf *) dev;\n    gs_memory_t *mem = gs_memory_stable(pdev->memory);\n    gx_device_pdf *save_dev = gs_malloc(mem, sizeof(gx_device_pdf), 1,\n        \"saved gx_device_pdf\");\n\n    if (!save_dev)\n        return_error(gs_error_VMerror);\n    memcpy(save_dev, pdev, sizeof(gx_device_pdf));\n    code = gdev_pdf_put_params_impl(dev, save_dev, plist);\n    gs_free(mem, save_dev, sizeof(gx_device_pdf), 1, \"saved gx_device_pdf\");\n    return code;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":437884,"func":"Block::~Block() { delete[] m_frames; }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":262214,"func":"void bgp_packet_mpattr_end(struct stream *s, size_t sizep)\n{\n\t\/* Set MP attribute length. Don't count the (2) bytes used to encode\n\t   the attr length *\/\n\tstream_putw_at(s, sizep, (stream_get_endp(s) - sizep) - 2);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":341304,"func":"static long kvm_hypercall(unsigned long nr, unsigned long param1,\n\n                          unsigned long param2)\n\n{\n\n\tregister ulong r_nr asm(\"1\") = nr;\n\n\tregister ulong r_param1 asm(\"2\") = param1;\n\n\tregister ulong r_param2 asm(\"3\") = param2;\n\n\tregister long retval asm(\"2\");\n\n\n\n\tasm volatile (\"diag 2,4,0x500\"\n\n\t\t      : \"=d\" (retval)\n\n\t\t      : \"d\" (r_nr), \"0\" (r_param1), \"r\"(r_param2)\n\n\t\t      : \"memory\", \"cc\");\n\n\n\n\treturn retval;\n\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":347653,"func":"static inline void ext4_iget_extra_inode(struct inode *inode,\n\t\t\t\t\t struct ext4_inode *raw_inode,\n\t\t\t\t\t struct ext4_inode_info *ei)\n{\n\t__le32 *magic = (void *)raw_inode +\n\t\t\tEXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;\n\tif (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize + sizeof(__le32) <=\n\t    EXT4_INODE_SIZE(inode->i_sb) &&\n\t    *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {\n\t\text4_set_inode_state(inode, EXT4_STATE_XATTR);\n\t\text4_find_inline_data_nolock(inode);\n\t} else\n\t\tEXT4_I(inode)->i_inline_off = 0;\n}","target":1,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":432150,"func":"static int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol,\n\t\t\t\t\t  struct snd_ctl_elem_value *ucontrol)\n{\n\tint i;\n\tstruct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);\n\n\tfor (i = 0; i < 2; i++)\n\t\tucontrol->value.integer.value[i] = line6pcm->volume_playback[i];\n\n\treturn 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":44592,"func":"static int get_float64(QEMUFile *f, void *pv, size_t size)\n\n{\n\n    float64 *v = pv;\n\n\n\n    *v = make_float64(qemu_get_be64(f));\n\n    return 0;\n\n}\n","target":1,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":51658,"func":"static inline bool kvm_apic_sw_enabled(struct kvm_lapic *apic)\n{\n\tif (static_key_false(&apic_sw_disabled.key))\n\t\treturn apic->sw_enabled;\n\treturn true;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":146748,"func":"CURLcode Curl_auth_create_external_message(struct Curl_easy *data,\n                                           const char *user, char **outptr,\n                                           size_t *outlen)\n{\n  \/* This is the same formatting as the login message *\/\n  return Curl_auth_create_login_message(data, user, outptr, outlen);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":174236,"func":"    DrawingBufferClientRestorePixelUnpackBufferBinding() {}\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":275039,"func":"BOOLEAN btif_hl_find_app_idx_using_deleted_mdl_id( UINT8 mdl_id,\n                                           UINT8 *p_app_idx){\n btif_hl_app_cb_t *p_acb;\n    BOOLEAN         found=FALSE;\n    UINT8 i;\n\n for (i=0; i<BTA_HL_NUM_APPS; i++)\n {\n        p_acb =BTIF_HL_GET_APP_CB_PTR(i);\n if (p_acb->delete_mdl.active) {\n            BTIF_TRACE_DEBUG(\"%s: app_idx=%d, mdl_id=%d\",\n                             __FUNCTION__,i,mdl_id);\n }\n if (p_acb->delete_mdl.active &&\n (p_acb->delete_mdl.mdl_id == mdl_id))\n {\n            found = TRUE;\n *p_app_idx = i;\n break;\n }\n }\n    BTIF_TRACE_DEBUG(\"%s found=%d app_idx=%d\",__FUNCTION__,\n                      found, i);\n return found;\n}\n","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":217327,"func":"HTTP_Init(void)\n{\n\n#define HTTPH(a, b, c, d, e, f, g) b[0] = (char)strlen(b + 1);\n#include \"http_headers.h\"\n#undef HTTPH\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":127161,"func":"iperf_setaffinity(int affinity)\n{\n#ifdef linux\n    cpu_set_t cpu_set;\n\n    CPU_ZERO(&cpu_set);\n    CPU_SET(affinity, &cpu_set);\n    if (sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set) != 0) {\n\ti_errno = IEAFFINITY;\n        return -1;\n    }\n    return 0;\n#else \/*linux*\/\n    i_errno = IEAFFINITY;\n    return -1;\n#endif \/*linux*\/\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":38941,"func":"auth_sig_compatible(uint8_t type)\n{\n\tswitch (type) {\n\tcase IKEV2_AUTH_RSA_SIG:\n\tcase IKEV2_AUTH_ECDSA_256:\n\tcase IKEV2_AUTH_ECDSA_384:\n\tcase IKEV2_AUTH_ECDSA_521:\n\tcase IKEV2_AUTH_SIG_ANY:\n\t\treturn (1);\n\t}\n\treturn (0);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":372598,"func":"\tvoid addHeader(string &headers, const char *name, const StaticString &value) {\n\t\tif (name != NULL) {\n\t\t\theaders.append(name);\n\t\t\theaders.append(1, '\\0');\n\t\t\theaders.append(value.c_str(), value.size());\n\t\t\theaders.append(1, '\\0');\n\t\t}\n\t}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":302107,"func":"static void uv__write_int(int fd, int val) {\n  ssize_t n;\n\n  do\n    n = write(fd, &val, sizeof(val));\n  while (n == -1 && errno == EINTR);\n\n  if (n == -1 && errno == EPIPE)\n    return; \/* parent process has quit *\/\n\n  assert(n == sizeof(val));\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":224060,"func":"ResourceFetcher::~ResourceFetcher() {}\n","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":463963,"func":"static CURLcode gtls_sha256sum(const unsigned char *tmp, \/* input *\/\n                               size_t tmplen,\n                               unsigned char *sha256sum, \/* output *\/\n                               size_t sha256len)\n{\n  struct sha256_ctx SHA256pw;\n  sha256_init(&SHA256pw);\n  sha256_update(&SHA256pw, (unsigned int)tmplen, tmp);\n  sha256_digest(&SHA256pw, (unsigned int)sha256len, sha256sum);\n  return CURLE_OK;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":305829,"func":"static int cac_match_card(sc_card_t *card)\n{\n\tint r;\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);\n\t\/* Since we send an APDU, the card's logout function may be called...\n\t * however it may be in dirty memory *\/\n\tcard->ops->logout = NULL;\n\n\tr = cac_find_and_initialize(card, 0);\n\treturn (r == SC_SUCCESS); \/* never match *\/\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":51937,"func":"  Status operator()(const GPUDevice& d,\n                    typename TTypes<qint8, 4, int>::ConstTensor in,\n                    int input_pad_top, int input_pad_bottom, int input_pad_left,\n                    int input_pad_right,\n                    typename TTypes<qint8, 4, int>::Tensor out,\n                    TensorFormat format) {\n    return errors::InvalidArgument(\n        \"Explicit padding not yet supported with qint8\");\n  }","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":161400,"func":"kernel_map_pages(struct page *page, int numpages, int enable)\n{\n\tif (!debug_pagealloc_enabled())\n\t\treturn;\n\n\t__kernel_map_pages(page, numpages, enable);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":227955,"func":"  void CreateLinearAccelerationFusionSensor() {\n    auto fusion_algorithm =\n        std::make_unique<LinearAccelerationFusionAlgorithmUsingAccelerometer>();\n    CreateFusionSensor(std::move(fusion_algorithm));\n  }\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":208036,"func":"int WebContentsImpl::GetCrashedErrorCode() const {\n  return crashed_error_code_;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":239495,"func":" virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) {\n Parcel data, reply;\n        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());\n\n status_t status = remote()->transact(GET_SECURE_STOPS, data, &reply);\n if (status != OK) {\n return status;\n }\n\n        secureStops.clear();\n uint32_t count = reply.readInt32();\n for (size_t i = 0; i < count; i++) {\n Vector<uint8_t> secureStop;\n            readVector(reply, secureStop);\n            secureStops.push_back(secureStop);\n }\n return reply.readInt32();\n }\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":1200,"func":"int parse_CCategSpec ( tvbuff_t * tvb , int offset , proto_tree * parent_tree , proto_tree * pad_tree , const char * fmt , ... ) {\n proto_item * item ;\n proto_tree * tree ;\n va_list ap ;\n guint32 type ;\n const char * txt ;\n va_start ( ap , fmt ) ;\n txt = wmem_strdup_vprintf ( wmem_packet_scope ( ) , fmt , ap ) ;\n va_end ( ap ) ;\n tree = proto_tree_add_subtree ( parent_tree , tvb , offset , 0 , ett_CCategSpec , & item , txt ) ;\n type = tvb_get_letohl ( tvb , offset ) ;\n proto_tree_add_uint ( tree , hf_mswsp_ccategspec_type , tvb , offset , 4 , type ) ;\n proto_item_append_text ( item , \" Type %u\" , type ) ;\n offset += 4 ;\n offset = parse_CSort ( tvb , offset , tree , pad_tree , \"CSort\" ) ;\n offset = parse_CRangeCategSpec ( tvb , offset , tree , pad_tree , \"CRangeCategSpec\" ) ;\n proto_item_set_end ( item , tvb , offset ) ;\n return offset ;\n }","target":1,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":371509,"func":"    void AuthorizationManager::logoutDatabase(const std::string& dbname) {\n        Principal* principal = _authenticatedPrincipals.lookupByDBName(dbname);\n        if (!principal)\n            return;\n        _acquiredPrivileges.revokePrivilegesFromPrincipal(principal->getName());\n        _authenticatedPrincipals.removeByDBName(dbname);\n    }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":111142,"func":"unsigned long get_max_files(void)\n{\n\treturn files_stat.max_files;\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":445938,"func":"BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height)\n{\n\tif (!context)\n\t\treturn FALSE;\n\n\tcontext->width = width;\n\tcontext->height = height;\n\tcontext->state = RFX_STATE_SEND_HEADERS;\n\tcontext->expectedDataBlockType = WBT_FRAME_BEGIN;\n\tcontext->frameIdx = 0;\n\treturn TRUE;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":95273,"func":"PJ_DEF(void) pjsip_tx_data_invalidate_msg( pjsip_tx_data *tdata )\n{\n    tdata->buf.cur = tdata->buf.start;\n    tdata->info = NULL;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":300741,"func":"void RequestContext::FillCheckRequestInfo(\n    service_control::CheckRequestInfo *info) {\n  FillOperationInfo(info);\n\n  request_->FindHeader(kXAndroidPackage, &info->android_package_name);\n  request_->FindHeader(kXAndroidCert, &info->android_cert_fingerprint);\n  request_->FindHeader(kXIosBundleId, &info->ios_bundle_id);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":74262,"func":"static void sig_exit_handler(int sig)\n{\n\tsig_exit_handler_sig = sig;\n\tsig_exit_handler_called = 1;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":513839,"func":"cliprdr_server_file_contents_response(CliprdrServerContext* context,\n                                      const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)\n{\n\twStream* s;\n\tCliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;\n\n\tif (fileContentsResponse->msgType != CB_FILECONTENTS_RESPONSE)\n\t\tWLog_WARN(TAG, \"[%s] called with invalid type %08\" PRIx32, __FUNCTION__,\n\t\t          fileContentsResponse->msgType);\n\n\ts = cliprdr_packet_file_contents_response_new(fileContentsResponse);\n\tif (!s)\n\t{\n\t\tWLog_ERR(TAG, \"cliprdr_packet_file_contents_response_new failed!\");\n\t\treturn ERROR_INTERNAL_ERROR;\n\t}\n\n\tWLog_DBG(TAG, \"ServerFileContentsResponse: streamId: 0x%08\" PRIX32 \"\",\n\t         fileContentsResponse->streamId);\n\treturn cliprdr_server_packet_send(cliprdr, s);\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":505434,"func":"void OpenSSLDie(const char *file,int line,const char *assertion)\n\t{\n\tOPENSSL_showfatal(\n\t\t\"%s(%d): OpenSSL internal error, assertion failed: %s\\n\",\n\t\tfile,line,assertion);\n\tabort();\n\t}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":29777,"func":"int qemuMonitorTextSetCPU ( qemuMonitorPtr mon , int cpu , int online ) {\n char * cmd ;\n char * reply = NULL ;\n int ret = - 1 ;\n if ( virAsprintf ( & cmd , \"cpu_set %d %s\" , cpu , online ? \"online\" : \"offline\" ) < 0 ) {\n virReportOOMError ( ) ;\n return - 1 ;\n }\n if ( qemuMonitorHMPCommand ( mon , cmd , & reply ) < 0 ) {\n qemuReportError ( VIR_ERR_OPERATION_FAILED , \"%s\" , _ ( \"could not change CPU online status\" ) ) ;\n VIR_FREE ( cmd ) ;\n return - 1 ;\n }\n VIR_FREE ( cmd ) ;\n if ( strstr ( reply , \"unknown command:\" ) ) {\n ret = 0 ;\n }\n else {\n ret = 1 ;\n }\n VIR_FREE ( reply ) ;\n return ret ;\n }","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":409967,"func":"\nstatic inline void skb_set_mac_header(struct sk_buff *skb, const int offset)\n{\n\tskb_reset_mac_header(skb);\n\tskb->mac_header += offset;","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":375416,"func":"findchar(char *str, int c)\n{\n\twhile (*str)\n\t{\n\t\tif (t_iseq(str, c))\n\t\t\treturn str;\n\t\tstr += pg_mblen(str);\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":155281,"func":"xfs_buf_ioerror(\n\txfs_buf_t\t\t*bp,\n\tint\t\t\terror)\n{\n\tASSERT(error >= 0 && error <= 0xffff);\n\tbp->b_error = (unsigned short)error;\n\ttrace_xfs_buf_ioerror(bp, error, _RET_IP_);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":116303,"func":"BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)\n{\n\t_noLibzError();\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":77542,"func":"BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)\n{\n\t_noLibzError();\n\treturn NULL;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":218895,"func":"void ChromeNetworkDelegate::set_cookie_settings(\n    CookieSettings* cookie_settings) {\n  cookie_settings_ = cookie_settings;\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":164911,"func":"aspath_add_asns (struct aspath *aspath, as_t asno, u_char type, unsigned num)\n{\n  struct assegment *assegment = aspath->segments;\n  unsigned i;\n\n  if (assegment && assegment->type == type)\n    {\n      \/* extend existing segment *\/\n      aspath->segments = assegment_prepend_asns (aspath->segments, asno, num);\n    }\n  else \n    {\n      \/* prepend with new segment *\/\n      struct assegment *newsegment = assegment_new (type, num);\n      for (i = 0; i < num; i++)\n\tnewsegment->as[i] = asno;\n\n      \/* insert potentially replacing empty segment *\/\n      if (assegment && assegment->length == 0)\n\t{\n\t  newsegment->next = assegment->next;\n\t  assegment_free (assegment);\n\t}\n       else\n\t  newsegment->next = assegment;\n      aspath->segments = newsegment;\n    }\n\n  aspath_str_update (aspath);\n  return aspath;\n}\n","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":167895,"func":"void BaseRenderingContext2D::ClearCanvas() {\n  FloatRect canvas_rect(0, 0, Width(), Height());\n  CheckOverdraw(canvas_rect, nullptr, CanvasRenderingContext2DState::kNoImage,\n                kClipFill);\n  PaintCanvas* c = DrawingCanvas();\n  if (c)\n    c->clear(HasAlpha() ? SK_ColorTRANSPARENT : SK_ColorBLACK);\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":518187,"func":"bool Item_temporal_literal::eq(const Item *item, bool binary_cmp) const\n{\n  return\n    item->basic_const_item() && type() == item->type() &&\n    field_type() == ((Item_temporal_literal *) item)->field_type() &&\n    !my_time_compare(&cached_time,\n                     &((Item_temporal_literal *) item)->cached_time);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":285589,"func":"void InterstitialPage::DontProceed() {\n  DCHECK(action_taken_ != DONT_PROCEED_ACTION);\n\n  Disable();\n  action_taken_ = DONT_PROCEED_ACTION;\n\n  if (new_navigation_)\n    TakeActionOnResourceDispatcher(RESUME);\n  else\n    TakeActionOnResourceDispatcher(CANCEL);\n\n  if (should_discard_pending_nav_entry_) {\n    tab_->controller().DiscardNonCommittedEntries();\n  }\n\n  Hide();\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":429505,"func":"dir_changed (GFileMonitor       *monitor,\n              GFile             *file,\n              GFile             *other_file,\n              GFileMonitorEvent  event_type,\n              gpointer           user_data)\n{\n  GKeyfileSettingsBackend *kfsb = user_data;\n\n  g_keyfile_settings_backend_keyfile_writable (kfsb);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":298838,"func":"static void index_entry_adjust_namemask(\n\t\tgit_index_entry *entry,\n\t\tsize_t path_length)\n{\n\tentry->flags &= ~GIT_IDXENTRY_NAMEMASK;\n\n\tif (path_length < GIT_IDXENTRY_NAMEMASK)\n\t\tentry->flags |= path_length & GIT_IDXENTRY_NAMEMASK;\n\telse\n\t\tentry->flags |= GIT_IDXENTRY_NAMEMASK;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":144988,"func":"static int oom_reaper(void *unused)\n{\n\twhile (true) {\n\t\tstruct task_struct *tsk = NULL;\n\n\t\twait_event_freezable(oom_reaper_wait, oom_reaper_list != NULL);\n\t\tspin_lock(&oom_reaper_lock);\n\t\tif (oom_reaper_list != NULL) {\n\t\t\ttsk = oom_reaper_list;\n\t\t\toom_reaper_list = tsk->oom_reaper_list;\n\t\t}\n\t\tspin_unlock(&oom_reaper_lock);\n\n\t\tif (tsk)\n\t\t\toom_reap_task(tsk);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":258833,"func":"term_getjob(term_T *term)\n{\n    return term != NULL ? term->tl_job : NULL;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":250318,"func":"static void on_connection_close(nw_ses *ses)\n{\n    log_trace(\"connection %s close\", nw_sock_human_addr(&ses->peer_addr));\n    struct clt_info *info = ses->privdata;\n    struct ws_svr *svr = ws_svr_from_ses(ses);\n    if (info->upgrade) {\n        if (svr->type.on_close) {\n            svr->type.on_close(ses, info->remote);\n        }\n        if (svr->type.on_privdata_free) {\n            svr->type.on_privdata_free(svr, info->privdata);\n        }\n    }\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":219933,"func":"void ClipboardMessageFilter::OnReadHTML(ui::ClipboardType type,\n                                        base::string16* markup,\n                                        GURL* url,\n                                        uint32* fragment_start,\n                                        uint32* fragment_end) {\n  std::string src_url_str;\n  GetClipboard()->ReadHTML(type, markup, &src_url_str, fragment_start,\n                           fragment_end);\n  *url = GURL(src_url_str);\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":96398,"func":"BOOL CALLBACK win_init_once(\n  PINIT_ONCE InitOnce,\n  PVOID Parameter,\n  PVOID *lpContext)\n{\n  return !mysql_once_init();\n  return TRUE;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":456918,"func":"static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page)\n{\n\tif (!(s->flags & SLAB_STORE_USER))\n\t\treturn;\n\n\tlockdep_assert_held(&n->list_lock);\n\tlist_del(&page->slab_list);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":448998,"func":"UTI_CompareNtp64(NTP_int64 *a, NTP_int64 *b)\n{\n  int32_t diff;\n\n  if (a->hi == b->hi && a->lo == b->lo)\n    return 0;\n\n  diff = ntohl(a->hi) - ntohl(b->hi);\n\n  if (diff < 0)\n    return -1;\n  if (diff > 0)\n    return 1;\n\n  return ntohl(a->lo) < ntohl(b->lo) ? -1 : 1;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":128887,"func":"  WasmResult set(absl::string_view vm_id, absl::string_view key, absl::string_view value,\n                 uint32_t cas) {\n    absl::WriterMutexLock l(&mutex);\n    absl::flat_hash_map<std::string, std::pair<std::string, uint32_t>>* map;\n    auto map_it = data.find(vm_id);\n    if (map_it == data.end()) {\n      map = &data[vm_id];\n    } else {\n      map = &map_it->second;\n    }\n    auto it = map->find(key);\n    if (it != map->end()) {\n      if (cas && cas != it->second.second) {\n        return WasmResult::CasMismatch;\n      }\n      it->second = std::make_pair(std::string(value), nextCas());\n    } else {\n      map->emplace(key, std::make_pair(std::string(value), nextCas()));\n    }\n    return WasmResult::Ok;\n  }","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":384325,"func":"static void dma_buf_commit(IDEState *s, uint32_t tx_bytes)\n{\n    if (s->bus->dma->ops->commit_buf) {\n        s->bus->dma->ops->commit_buf(s->bus->dma, tx_bytes);\n    }\n    qemu_sglist_destroy(&s->sg);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":146865,"func":"static void l2tp_ip6_destroy_sock(struct sock *sk)\n{\n\tstruct l2tp_tunnel *tunnel = l2tp_sock_to_tunnel(sk);\n\n\tlock_sock(sk);\n\tip6_flush_pending_frames(sk);\n\trelease_sock(sk);\n\n\tif (tunnel) {\n\t\tl2tp_tunnel_closeall(tunnel);\n\t\tsock_put(sk);\n\t}\n\n\tinet6_destroy_sock(sk);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":112003,"func":"RAMBlock *qemu_ram_alloc(struct uc_struct *uc, ram_addr_t size, MemoryRegion *mr)\n{\n    return qemu_ram_alloc_from_ptr(uc, size, NULL, mr);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":304425,"func":"char *url_decode_r(char *to, char *url, size_t size) {\n    char *s = url,           \/\/ source\n         *d = to,            \/\/ destination\n         *e = &to[size - 1]; \/\/ destination end\n\n    while(*s && d < e) {\n        if(unlikely(*s == '%')) {\n            if(likely(s[1] && s[2])) {\n                char t = from_hex(s[1]) << 4 | from_hex(s[2]);\n                \/\/ avoid HTTP header injection\n                *d++ = (char)((isprint(t))? t : ' ');\n                s += 2;\n            }\n        }\n        else if(unlikely(*s == '+'))\n            *d++ = ' ';\n\n        else\n            *d++ = *s;\n\n        s++;\n    }\n\n    *d = '\\0';\n\n    return to;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":474584,"func":"static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,\n\t\t\t\t\t\t  enum cgroup_filetype type)\n{\n\tstruct cgroup_pidlist *l;\n\t\/* don't need task_nsproxy() if we're looking at ourself *\/\n\tstruct pid_namespace *ns = task_active_pid_ns(current);\n\n\tlockdep_assert_held(&cgrp->pidlist_mutex);\n\n\tlist_for_each_entry(l, &cgrp->pidlists, links)\n\t\tif (l->key.type == type && l->key.ns == ns)\n\t\t\treturn l;\n\treturn NULL;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":48618,"func":"static void spl_filesystem_tree_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator = (spl_filesystem_iterator *)iter;\n\tspl_filesystem_object   *object   = spl_filesystem_iterator_to_object(iterator);\n\n\tif (SPL_FILE_DIR_CURRENT(object, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {\n\t\tif (!iterator->current) {\n\t\t\tALLOC_INIT_ZVAL(iterator->current);\n\t\t\tspl_filesystem_object_get_file_name(object TSRMLS_CC);\n\t\t\tZVAL_STRINGL(iterator->current, object->file_name, object->file_name_len, 1);\n\t\t}\n\t\t*data = &iterator->current;\n\t} else if (SPL_FILE_DIR_CURRENT(object, SPL_FILE_DIR_CURRENT_AS_FILEINFO)) {\n\t\tif (!iterator->current) {\n\t\t\tALLOC_INIT_ZVAL(iterator->current);\n\t\t\tspl_filesystem_object_get_file_name(object TSRMLS_CC);\n\t\t\tspl_filesystem_object_create_type(0, object, SPL_FS_INFO, NULL, iterator->current TSRMLS_CC);\n\t\t}\n\t\t*data = &iterator->current;\n\t} else {\n\t\t*data = (zval**)&iterator->intern.data;\n\t}\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":233908,"func":"void AudioOutputDeviceTest::WaitUntilRenderCallback() {\n  io_loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),\n                           TestTimeouts::action_timeout());\n  io_loop_.Run();\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":490603,"func":"Bool gf_filter_has_pid_connection_pending(GF_Filter *filter, GF_Filter *stop_at_filter)\n{\n\tGF_FilterSession *fsess;\n\tBool res;\n\tif (!filter) return GF_FALSE;\n\t\/\/lock session, this is an unsafe call\n\tfsess = filter->session;\n\tgf_mx_p(fsess->filters_mx);\n\tres = gf_filter_has_pid_connection_pending_internal(filter, stop_at_filter);\n\tgf_mx_v(fsess->filters_mx);\n\treturn res;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":518265,"func":"static void warn_if_datadir_altered(THD *thd,\n    const partition_element *part_elem)\n{\n  DBUG_ASSERT(part_elem);\n\n  if (part_elem->engine_type &&\n      part_elem->engine_type->db_type != DB_TYPE_INNODB)\n    return;\n\n  if (part_elem->data_file_name)\n  {\n    push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,\n        WARN_INNODB_PARTITION_OPTION_IGNORED,\n        ER(WARN_INNODB_PARTITION_OPTION_IGNORED),\n        \"DATA DIRECTORY\");\n  }\n  if (part_elem->index_file_name)\n  {\n    push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,\n        WARN_INNODB_PARTITION_OPTION_IGNORED,\n        ER(WARN_INNODB_PARTITION_OPTION_IGNORED),\n        \"INDEX DIRECTORY\");\n  }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":396539,"func":"GC_API size_t GC_CALL GC_get_free_bytes(void)\n{\n    \/* ignore the memory space returned to OS *\/\n    return (size_t)(GC_large_free_bytes - GC_unmapped_bytes);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":96566,"func":"void NumberFormatTest::TestHostClone()\n{\n    \/*\n    Verify that a cloned formatter gives the same results\n    and is useable after the original has been deleted.\n    *\/\n    \/\/ This is mainly important on Windows.\n    UErrorCode status = U_ZERO_ERROR;\n    Locale loc(\"en_US@compat=host\");\n    UDate now = Calendar::getNow();\n    NumberFormat *full = NumberFormat::createInstance(loc, status);\n    if (full == NULL || U_FAILURE(status)) {\n        dataerrln(\"FAIL: Can't create NumberFormat date instance - %s\", u_errorName(status));\n        return;\n    }\n    UnicodeString result1;\n    full->format(now, result1, status);\n    Format *fullClone = full->clone();\n    delete full;\n    full = NULL;\n\n    UnicodeString result2;\n    fullClone->format(now, result2, status);\n    if (U_FAILURE(status)) {\n        errln(\"FAIL: format failure.\");\n    }\n    if (result1 != result2) {\n        errln(\"FAIL: Clone returned different result from non-clone.\");\n    }\n    delete fullClone;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":66273,"func":"ParseNodePtr Parser::ParseMetaProperty(tokens metaParentKeyword, charcount_t ichMin, _Out_opt_ BOOL* pfCanAssign)\n{\n    AssertMsg(metaParentKeyword == tkNEW, \"Only supported for tkNEW parent keywords\");\n    AssertMsg(this->m_token.tk == tkDot, \"We must be currently sitting on the dot after the parent keyword\");\n\n    m_pscan->Scan();\n\n    if (this->m_token.tk == tkID && this->m_token.GetIdentifier(m_phtbl) == this->GetTargetPid())\n    {\n        ThrowNewTargetSyntaxErrForGlobalScope();\n        if (pfCanAssign)\n        {\n            *pfCanAssign = FALSE;\n        }\n        if (buildAST)\n        {\n            return CreateNodeWithScanner<knopNewTarget>(ichMin);\n        }\n    }\n    else\n    {\n        Error(ERRsyntax);\n    }\n\n    return nullptr;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":128855,"func":"NOEXPORT void session_cache_retrieve(CLI *c) {\n    SSL_SESSION *sess;\n\n    CRYPTO_THREAD_read_lock(stunnel_locks[LOCK_SESSION]);\n    if(c->opt->option.delayed_lookup) {\n        sess=c->opt->session;\n    } else { \/* per-destination client cache *\/\n        if(c->opt->connect_session) {\n            sess=c->opt->connect_session[c->idx];\n        } else {\n            s_log(LOG_ERR, \"INTERNAL ERROR: Uninitialized client session cache\");\n            sess=NULL;\n        }\n    }\n    if(sess)\n        SSL_set_session(c->ssl, sess);\n    CRYPTO_THREAD_unlock(stunnel_locks[LOCK_SESSION]);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":522010,"func":"double user_var_entry::val_real(bool *null_value)\n{\n  if ((*null_value= (value == 0)))\n    return 0.0;\n\n  switch (type) {\n  case REAL_RESULT:\n    return *(double*) value;\n  case INT_RESULT:\n    return (double) *(longlong*) value;\n  case DECIMAL_RESULT:\n  {\n    double result;\n    my_decimal2double(E_DEC_FATAL_ERROR, (my_decimal *)value, &result);\n    return result;\n  }\n  case STRING_RESULT:\n    return my_atof(value);                      \/\/ This is null terminated\n  case ROW_RESULT:\n  case TIME_RESULT:\n    DBUG_ASSERT(0);\t\t\t\t\/\/ Impossible\n    break;\n  }\n  return 0.0;\t\t\t\t\t\/\/ Impossible\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":10771,"func":"bool DeleteReparsePoint(HANDLE source) {\n  DWORD returned;\n  REPARSE_DATA_BUFFER data = {0};\n  data.ReparseTag = 0xa0000003;\n  if (!DeviceIoControl(source, FSCTL_DELETE_REPARSE_POINT, &data, 8, NULL, 0,\n                       &returned, NULL)) {\n    return false;\n  }\n  return true;\n}\n","target":1,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":386724,"func":"OPJ_UINT32 opj_j2k_get_max_toc_size (opj_j2k_t *p_j2k)\n{\n        OPJ_UINT32 i;\n        OPJ_UINT32 l_nb_tiles;\n        OPJ_UINT32 l_max = 0;\n        opj_tcp_t * l_tcp = 00;\n\n        l_tcp = p_j2k->m_cp.tcps;\n        l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;\n\n        for (i=0;i<l_nb_tiles;++i) {\n                l_max = opj_uint_max(l_max,l_tcp->m_nb_tile_parts);\n\n                ++l_tcp;\n        }\n\n        return 12 * l_max;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":223780,"func":"static void deprecatedVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::voidMethod);\n    TestObjectPythonV8Internal::deprecatedVoidMethodMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":175511,"func":"int TabStrip::GetInactiveTabWidth() const {\n  return layout_helper_->inactive_tab_width();\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":457566,"func":"rb_update_read_stamp(struct ring_buffer_per_cpu *cpu_buffer,\n\t\t     struct ring_buffer_event *event)\n{\n\tu64 delta;\n\n\tswitch (event->type_len) {\n\tcase RINGBUF_TYPE_PADDING:\n\t\treturn;\n\n\tcase RINGBUF_TYPE_TIME_EXTEND:\n\t\tdelta = ring_buffer_event_time_stamp(event);\n\t\tcpu_buffer->read_stamp += delta;\n\t\treturn;\n\n\tcase RINGBUF_TYPE_TIME_STAMP:\n\t\tdelta = ring_buffer_event_time_stamp(event);\n\t\tcpu_buffer->read_stamp = delta;\n\t\treturn;\n\n\tcase RINGBUF_TYPE_DATA:\n\t\tcpu_buffer->read_stamp += event->time_delta;\n\t\treturn;\n\n\tdefault:\n\t\tRB_WARN_ON(cpu_buffer, 1);\n\t}\n\treturn;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":175267,"func":"void GuestViewBase::UpdatePreferredSize(\n    content::WebContents* target_web_contents,\n    const gfx::Size& pref_size) {\n  DCHECK_EQ(web_contents(), target_web_contents);\n  if (IsPreferredSizeModeEnabled()) {\n    OnPreferredSizeChanged(pref_size);\n  }\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":19313,"func":"static int noise_motion_thresh ( BLOCK_SIZE bs , int increase_denoising ) {\n ( void ) bs ;\n ( void ) increase_denoising ;\n return 25 * 25 ;\n }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":21519,"func":"static inline void tb_hash_remove ( TranslationBlock * * ptb , TranslationBlock * tb ) {\n TranslationBlock * tb1 ;\n for ( ;\n ;\n ) {\n tb1 = * ptb ;\n if ( tb1 == tb ) {\n * ptb = tb1 -> phys_hash_next ;\n break ;\n }\n ptb = & tb1 -> phys_hash_next ;\n }\n }","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":140914,"func":"export_pamenv (void)\n{\n  char **env;\n\n  \/* This is a copy but don't care to free as we exec later anyways.  *\/\n  env = pam_getenvlist (pamh);\n  while (env && *env)\n    {\n      if (putenv (*env) != 0)\n\terr (EXIT_FAILURE, NULL);\n      env++;\n    }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":12077,"func":"   DeviceRequest(\n       int requesting_process_id,\n       int requesting_frame_id,\n       int page_request_id,\n       bool user_gesture,\n       MediaStreamRequestType request_type,\n      const StreamControls& controls,\n      MediaDeviceSaltAndOrigin salt_and_origin,\n       DeviceStoppedCallback device_stopped_cb = DeviceStoppedCallback())\n       : requesting_process_id(requesting_process_id),\n         requesting_frame_id(requesting_frame_id),\n         page_request_id(page_request_id),\n         user_gesture(user_gesture),\n         controls(controls),\n        salt_and_origin(std::move(salt_and_origin)),\n        device_stopped_cb(std::move(device_stopped_cb)),\n        state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED),\n        request_type_(request_type),\n        audio_type_(MEDIA_NO_SERVICE),\n        video_type_(MEDIA_NO_SERVICE),\n        target_process_id_(-1),\n        target_frame_id_(-1) {}\n","target":1,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":103756,"func":"void BlockCodec::sync1()\n{\n\tm_savedPositionNextFrame = m_track->fpos_next_frame;\n\tm_savedNextFrame = m_track->nextfframe;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":54188,"func":"void __module_get(struct module *module)\n{\n\tif (module) {\n\t\tpreempt_disable();\n\t\tatomic_inc(&module->refcnt);\n\t\ttrace_module_get(module, _RET_IP_);\n\t\tpreempt_enable();\n\t}\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":412337,"func":"rb_dir_exists_p(VALUE obj, VALUE fname)\n{\n    rb_warning(\"Dir.exists? is a deprecated name, use Dir.exist? instead\");\n    return rb_file_directory_p(obj, fname);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":466981,"func":"dnscrypt_pad(uint8_t *buf, const size_t len, const size_t max_len,\n             const uint8_t *nonce, const uint8_t *secretkey)\n{\n    uint8_t *buf_padding_area = buf + len;\n    size_t padded_len;\n    uint32_t rnd;\n\n    \/\/ no padding\n    if (max_len < len + DNSCRYPT_MIN_PAD_LEN)\n        return len;\n\n    assert(nonce[crypto_box_HALF_NONCEBYTES] == nonce[0]);\n\n    crypto_stream((unsigned char *)&rnd, (unsigned long long)sizeof(rnd), nonce,\n                  secretkey);\n    padded_len =\n        len + DNSCRYPT_MIN_PAD_LEN + rnd % (max_len - len -\n                                            DNSCRYPT_MIN_PAD_LEN + 1);\n    padded_len += DNSCRYPT_BLOCK_SIZE - padded_len % DNSCRYPT_BLOCK_SIZE;\n    if (padded_len > max_len)\n        padded_len = max_len;\n\n    memset(buf_padding_area, 0, padded_len - len);\n    *buf_padding_area = 0x80;\n\n    return padded_len;\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":387642,"func":"xz_avail(xz_statep state)\n{\n    lzma_stream *strm = &(state->strm);\n\n    if (state->err != LZMA_OK)\n        return -1;\n    if (state->eof == 0) {\n        \/* avail_in is size_t, which is not necessary sizeof(unsigned) *\/\n        unsigned tmp = strm->avail_in;\n\n        if (xz_load(state, state->in, state->size, &tmp) == -1) {\n            strm->avail_in = tmp;\n            return -1;\n        }\n        strm->avail_in = tmp;\n        strm->next_in = state->in;\n    }\n    return 0;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":264913,"func":"  explicit ReverseOp(OpKernelConstruction* context) : OpKernel(context) {}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":31045,"func":"static cmsBool Type_S15Fixed16_Write ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , void * Ptr , cmsUInt32Number nItems ) {\n cmsFloat64Number * Value = ( cmsFloat64Number * ) Ptr ;\n cmsUInt32Number i ;\n for ( i = 0 ;\n i < nItems ;\n i ++ ) {\n if ( ! _cmsWrite15Fixed16Number ( io , Value [ i ] ) ) return FALSE ;\n }\n return TRUE ;\n cmsUNUSED_PARAMETER ( self ) ;\n }","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":21491,"func":"void # ifdef M_DEBUG mpi_debug_free_limb_space ( mpi_ptr_t a , const char * info ) # else mpi_free_limb_space ( mpi_ptr_t a ) # endif {\n if ( ! a ) return ;\n if ( DBG_MEMORY ) log_debug ( \"mpi_free_limb_space of size %lu\\n\" , ( ulong ) m_size ( a ) * 8 ) ;\n # if 0 if ( ! m_is_secure ( a ) ) {\n size_t nlimbs = m_size ( a ) \/ 4 ;\n void * p = a ;\n if ( nlimbs == 5 ) {\n * a = unused_limbs_5 ;\n unused_limbs_5 = a ;\n return ;\n }\n else if ( nlimbs == 32 ) {\n * a = unused_limbs_32 ;\n unused_limbs_32 = a ;\n return ;\n }\n else if ( nlimbs == 64 ) {\n * a = unused_limbs_64 ;\n unused_limbs_64 = a ;\n return ;\n }\n }\n # endif xfree ( a ) ;\n }","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":271661,"func":"SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig)\n{\n\t\/* This is only valid for single tasks *\/\n\tif (pid <= 0 || tgid <= 0)\n\t\treturn -EINVAL;\n\n\treturn do_tkill(tgid, pid, sig);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":154233,"func":"TfLiteRegistration* Register_MAX_POOL_2D() {\n  return Register_MAX_POOL_GENERIC_OPT();\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":65065,"func":"ip6_tnl_unlink(struct ip6_tnl_net *ip6n, struct ip6_tnl *t)\n{\n\tstruct ip6_tnl **tp;\n\n\tfor (tp = ip6_tnl_bucket(ip6n, &t->parms); *tp; tp = &(*tp)->next) {\n\t\tif (t == *tp) {\n\t\t\tspin_lock_bh(&ip6_tnl_lock);\n\t\t\t*tp = t->next;\n\t\t\tspin_unlock_bh(&ip6_tnl_lock);\n\t\t\tbreak;\n\t\t}\n\t}\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":319678,"func":"static inline int num_effective_busses(XilinxSPIPS *s)\n\n{\n\n    return (s->regs[R_LQSPI_STS] & LQSPI_CFG_SEP_BUS &&\n\n            s->regs[R_LQSPI_STS] & LQSPI_CFG_TWO_MEM) ? s->num_busses : 1;\n\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":230747,"func":"int dom_document_preserve_whitespace_read(dom_object *obj, zval **retval TSRMLS_DC)\n{\n\tdom_doc_propsptr doc_prop;\n\n\tALLOC_ZVAL(*retval);\n\tif (obj->document) {\n\t\tdoc_prop = dom_get_doc_props(obj->document);\n\t\tZVAL_BOOL(*retval, doc_prop->preservewhitespace);\n\t} else {\n\t\tZVAL_FALSE(*retval);\n\t}\n\treturn SUCCESS;\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":22867,"func":"static uint64_t xhci_oper_read ( void * ptr , hwaddr reg , unsigned size ) {\n XHCIState * xhci = ptr ;\n uint32_t ret ;\n switch ( reg ) {\n case 0x00 : ret = xhci -> usbcmd ;\n break ;\n case 0x04 : ret = xhci -> usbsts ;\n break ;\n case 0x08 : ret = 1 ;\n break ;\n case 0x14 : ret = xhci -> dnctrl ;\n break ;\n case 0x18 : ret = xhci -> crcr_low & ~ 0xe ;\n break ;\n case 0x1c : ret = xhci -> crcr_high ;\n break ;\n case 0x30 : ret = xhci -> dcbaap_low ;\n break ;\n case 0x34 : ret = xhci -> dcbaap_high ;\n break ;\n case 0x38 : ret = xhci -> config ;\n break ;\n default : trace_usb_xhci_unimplemented ( \"oper read\" , reg ) ;\n ret = 0 ;\n }\n trace_usb_xhci_oper_read ( reg , ret ) ;\n return ret ;\n }","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":439367,"func":"static CURLcode file_disconnect(struct connectdata *conn,\n                                bool dead_connection)\n{\n  struct FILEPROTO *file = conn->data->req.protop;\n  (void)dead_connection; \/* not used *\/\n\n  if(file) {\n    Curl_safefree(file->freepath);\n    file->path = NULL;\n    if(file->fd != -1)\n      close(file->fd);\n    file->fd = -1;\n  }\n\n  return CURLE_OK;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":200980,"func":"static inline bool migration_bitmap_set_dirty(ram_addr_t addr)\n{\n    bool ret;\n    int nr = addr >> TARGET_PAGE_BITS;\n\n    ret = test_and_set_bit(nr, migration_bitmap);\n\n    if (!ret) {\n        migration_dirty_pages++;\n    }\n    return ret;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":66124,"func":"int unregister_reboot_notifier(struct notifier_block *nb)\n{\n\treturn blocking_notifier_chain_unregister(&reboot_notifier_list, nb);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":169779,"func":"void LogHTMLForm(SavePasswordProgressLogger* logger,\n                 SavePasswordProgressLogger::StringID message_id,\n                 const WebFormElement& form) {\n  logger->LogHTMLForm(message_id, form.GetName().Utf8(),\n                      GURL(form.Action().Utf8()));\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":247083,"func":"static void php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_D)\n{\n\tif (ZLIBG(ob_gzhandler)) {\n\t\tdeflateEnd(&(ZLIBG(ob_gzhandler)->Z));\n\t\tphp_zlib_output_handler_context_dtor(ZLIBG(ob_gzhandler) TSRMLS_CC);\n\t\tZLIBG(ob_gzhandler) = NULL;\n\t}\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":197839,"func":"void LayerTreeCoordinator::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)\n{\n    if (graphicsLayer == m_nonCompositedContentLayer) {\n        m_webPage->drawRect(graphicsContext, clipRect);\n        return;\n    }\n\n    if (graphicsLayer == m_pageOverlayLayer) {\n        graphicsContext.clearRect(clipRect);\n        m_webPage->drawPageOverlay(graphicsContext, clipRect);\n        return;\n    }\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":351482,"func":"static void vt_disallocate_all(void)\n{\n\tstruct vc_data *vc[MAX_NR_CONSOLES];\n\tint i;\n\n\tconsole_lock();\n\tfor (i = 1; i < MAX_NR_CONSOLES; i++)\n\t\tif (!vt_busy(i))\n\t\t\tvc[i] = vc_deallocate(i);\n\t\telse\n\t\t\tvc[i] = NULL;\n\tconsole_unlock();\n\n\tfor (i = 1; i < MAX_NR_CONSOLES; i++) {\n\t\tif (vc[i] && i >= MIN_NR_CONSOLES) {\n\t\t\ttty_port_destroy(&vc[i]->port);\n\t\t\tkfree(vc[i]);\n\t\t}\n\t}\n}","target":1,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":218711,"func":"void Document::SetTitleElement(Element* title_element) {\n  if (isSVGSVGElement(documentElement())) {\n    title_element_ = Traversal<SVGTitleElement>::FirstChild(*documentElement());\n  } else {\n    if (title_element_ && title_element_ != title_element)\n      title_element_ = Traversal<HTMLTitleElement>::FirstWithin(*this);\n    else\n      title_element_ = title_element;\n\n    if (isSVGTitleElement(title_element_)) {\n      title_element_ = nullptr;\n      return;\n    }\n  }\n\n  if (isHTMLTitleElement(title_element_))\n    UpdateTitle(toHTMLTitleElement(title_element_)->text());\n  else if (isSVGTitleElement(title_element_))\n    UpdateTitle(toSVGTitleElement(title_element_)->textContent());\n}\n","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":138083,"func":"void vmalloc_sync_all(void)\n{\n\tunsigned long address;\n\n\tif (SHARED_KERNEL_PMD)\n\t\treturn;\n\n\tfor (address = VMALLOC_START & PMD_MASK;\n\t     address >= TASK_SIZE && address < FIXADDR_TOP;\n\t     address += PMD_SIZE) {\n\t\tstruct page *page;\n\n\t\tspin_lock(&pgd_lock);\n\t\tlist_for_each_entry(page, &pgd_list, lru) {\n\t\t\tspinlock_t *pgt_lock;\n\t\t\tpmd_t *ret;\n\n\t\t\t\/* the pgt_lock only for Xen *\/\n\t\t\tpgt_lock = &pgd_page_get_mm(page)->page_table_lock;\n\n\t\t\tspin_lock(pgt_lock);\n\t\t\tret = vmalloc_sync_one(page_address(page), address);\n\t\t\tspin_unlock(pgt_lock);\n\n\t\t\tif (!ret)\n\t\t\t\tbreak;\n\t\t}\n\t\tspin_unlock(&pgd_lock);\n\t}\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":159492,"func":"void Pipe::DelayedDelivery::flush()\n{\n  lgeneric_subdout(pipe->msgr->cct, ms, 20) << *pipe << \"DelayedDelivery::flush\" << dendl;\n  Mutex::Locker l(delay_lock);\n  flush_count = delay_queue.size();\n  delay_cond.Signal();\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":215929,"func":"void StatusBubbleGtk::SetURL(const GURL& url, const string16& languages) {\n  url_ = url;\n  languages_ = languages;\n\n  if (url.is_empty() && !status_text_.empty()) {\n    url_text_ = std::string();\n    SetStatusTextTo(status_text_);\n    return;\n  }\n\n  SetStatusTextToURL();\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":197085,"func":"bool OmniboxViewWin::IsImeComposing() const {\n  bool ime_composing = false;\n  HIMC context = ImmGetContext(m_hWnd);\n  if (context) {\n    ime_composing = !!ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0);\n    ImmReleaseContext(m_hWnd, context);\n  }\n  return ime_composing;\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":10050,"func":"net::WebSocket* WebSocketExperimentTask::Context::CreateWebSocket(\n    const Config& config, net::WebSocketDelegate* delegate) {\n  URLRequestContextGetter* getter =\n      Profile::GetDefaultRequestContext();\n  if (!getter)\n    return NULL;\n  net::WebSocket::Request* request(\n      new net::WebSocket::Request(config.url,\n                                   config.ws_protocol,\n                                   config.ws_origin,\n                                   config.ws_location,\n                                   getter->GetURLRequestContext()));\n   return new net::WebSocket(request, delegate);\n }\n","target":1,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":21598,"func":"rfbClientPtr rfbNewUDPClient ( rfbScreenInfoPtr rfbScreen ) {\n return ( ( rfbScreen -> udpClient = rfbNewTCPOrUDPClient ( rfbScreen , rfbScreen -> udpSock , TRUE ) ) ) ;\n }","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":317908,"func":"  void SetPageInfoBubbleIdentityInfo(\n      const PageInfoUI::IdentityInfo& identity_info) {\n    static_cast<PageInfoBubbleView*>(PageInfoBubbleView::GetPageInfoBubble())\n         ->SetIdentityInfo(identity_info);\n   }\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":430454,"func":"ippGetGroupTag(ipp_attribute_t *attr)\t\/* I - IPP attribute *\/\n{\n \/*\n  * Range check input...\n  *\/\n\n  if (!attr)\n    return (IPP_TAG_ZERO);\n\n \/*\n  * Return the group...\n  *\/\n\n  return (attr->group_tag);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":331731,"func":"int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,\n\n                          const uint8_t *buf, int nb_sectors)\n\n{\n\n    BlockDriver *drv = bs->drv;\n\n    int ret;\n\n\n\n    if (!drv) {\n\n        return -ENOMEDIUM;\n\n    }\n\n    if (!drv->bdrv_write_compressed) {\n\n        return -ENOTSUP;\n\n    }\n\n    ret = bdrv_check_request(bs, sector_num, nb_sectors);\n\n    if (ret < 0) {\n\n        return ret;\n\n    }\n\n\n\n    assert(QLIST_EMPTY(&bs->dirty_bitmaps));\n\n\n\n    return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);\n\n}\n","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":70827,"func":"static PHP_FUNCTION(session_decode)\n{\n\tchar *str;\n\tint str_len;\n\n\tif (PS(session_status) == php_session_none) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &str, &str_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tRETVAL_BOOL(php_session_decode(str, str_len TSRMLS_CC) == SUCCESS);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":109573,"func":"  void setupConnection() override {}","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":96701,"func":"f_funcref(typval_T *argvars, typval_T *rettv)\n{\n    common_function(argvars, rettv, TRUE);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":85749,"func":"  void setContext(Context* context) { contexts_[context->id()] = context; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":100703,"func":"mt_copy(mrb_state *mrb, mt_tbl *t)\n{\n  mt_tbl *t2;\n  size_t i;\n\n  if (t == NULL) return NULL;\n  if (t->alloc == 0) return NULL;\n  if (t->size == 0) return NULL;\n\n  t2 = mt_new(mrb);\n  for (i=0; i<t->alloc; i++) {\n    struct mt_elem *slot = &t->table[i];\n\n    if (slot->key) {\n      mt_put(mrb, t2, slot->key, slot->func_p, slot->noarg_p, slot->ptr);\n    }\n  }\n  return t2;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":302875,"func":"static struct sk_buff *\nsch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)\n{\n\tstruct tcf_proto *cl = rcu_dereference_bh(dev->egress_cl_list);\n\tstruct tcf_result cl_res;\n\n\tif (!cl)\n\t\treturn skb;\n\n\t\/* qdisc_skb_cb(skb)->pkt_len was already set by the caller. *\/\n\tqdisc_bstats_cpu_update(cl->q, skb);\n\n\tswitch (tcf_classify(skb, cl, &cl_res, false)) {\n\tcase TC_ACT_OK:\n\tcase TC_ACT_RECLASSIFY:\n\t\tskb->tc_index = TC_H_MIN(cl_res.classid);\n\t\tbreak;\n\tcase TC_ACT_SHOT:\n\t\tqdisc_qstats_cpu_drop(cl->q);\n\t\t*ret = NET_XMIT_DROP;\n\t\tkfree_skb(skb);\n\t\treturn NULL;\n\tcase TC_ACT_STOLEN:\n\tcase TC_ACT_QUEUED:\n\tcase TC_ACT_TRAP:\n\t\t*ret = NET_XMIT_SUCCESS;\n\t\tconsume_skb(skb);\n\t\treturn NULL;\n\tcase TC_ACT_REDIRECT:\n\t\t\/* No need to push\/pop skb's mac_header here on egress! *\/\n\t\tskb_do_redirect(skb);\n\t\t*ret = NET_XMIT_SUCCESS;\n\t\treturn NULL;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn skb;","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":110725,"func":"static struct ion_handle *ion_handle_get_by_id_nolock(struct ion_client *client,\n\t\t\t\t\t\tint id)\n{\n\tstruct ion_handle *handle;\n\n\thandle = idr_find(&client->idr, id);\n\tif (handle)\n\t\tion_handle_get(handle);\n\n\treturn handle ? handle : ERR_PTR(-EINVAL);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":277226,"func":"INLINE UWORD32 impeg2d_bit_stream_get(void* pv_ctxt, UWORD32 u4_num_bits)\n{\n    UWORD32 u4_next_bits = impeg2d_bit_stream_nxt(pv_ctxt, u4_num_bits);\n    impeg2d_bit_stream_flush(pv_ctxt, u4_num_bits);\n return(u4_next_bits);\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":128738,"func":"PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)\n{\n    STACK_OF(PKCS7_RECIP_INFO) *rsk;\n    PKCS7_RECIP_INFO *ri;\n    int i;\n\n    i = OBJ_obj2nid(p7->type);\n    if (i != NID_pkcs7_signedAndEnveloped)\n        return NULL;\n    if (p7->d.signed_and_enveloped == NULL)\n        return NULL;\n    rsk = p7->d.signed_and_enveloped->recipientinfo;\n    if (rsk == NULL)\n        return NULL;\n    ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);\n    if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)\n        return (NULL);\n    ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);\n    return (ri->issuer_and_serial);\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":199813,"func":"Response EmulationHandler::SetEmitTouchEventsForMouse(\n    bool enabled,\n    Maybe<std::string> configuration) {\n  touch_emulation_enabled_ = enabled;\n  touch_emulation_configuration_ = configuration.fromMaybe(\"\");\n  UpdateTouchEventEmulationState();\n  return Response::OK();\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":115332,"func":"static int __init packet_init(void)\n{\n\tint rc = proto_register(&packet_proto, 0);\n\n\tif (rc != 0)\n\t\tgoto out;\n\n\tsock_register(&packet_family_ops);\n\tregister_pernet_subsys(&packet_net_ops);\n\tregister_netdevice_notifier(&packet_netdev_notifier);\nout:\n\treturn rc;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":138659,"func":"void httpParseConnectionField(HttpConnection *connection,\n   char_t *value)\n{\n   char_t *p;\n   char_t *token;\n\n   \/\/Get the first value of the list\n   token = osStrtok_r(value, \",\", &p);\n\n   \/\/Parse the comma-separated list\n   while(token != NULL)\n   {\n      \/\/Trim whitespace characters\n      value = strTrimWhitespace(token);\n\n      \/\/Check current value\n      if(!osStrcasecmp(value, \"keep-alive\"))\n      {\n         \/\/The connection is persistent\n         connection->request.keepAlive = TRUE;\n      }\n      else if(!osStrcasecmp(value, \"close\"))\n      {\n         \/\/The connection will be closed after completion of the response\n         connection->request.keepAlive = FALSE;\n      }\n#if (HTTP_SERVER_WEB_SOCKET_SUPPORT == ENABLED)\n      else if(!osStrcasecmp(value, \"upgrade\"))\n      {\n         \/\/Upgrade the connection\n         connection->request.connectionUpgrade = TRUE;\n      }\n#endif\n\n      \/\/Get next value\n      token = osStrtok_r(NULL, \",\", &p);\n   }\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":372786,"func":"void CLASS remove_zeroes()\n{\n  unsigned row, col, tot, n, r, c;\n\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_REMOVE_ZEROES,0,2);\n#endif\n  for (row=0; row < height; row++)\n    for (col=0; col < width; col++)\n      if (BAYER(row,col) == 0) {\n\ttot = n = 0;\n\tfor (r = row-2; r <= row+2; r++)\n\t  for (c = col-2; c <= col+2; c++)\n\t    if (r < height && c < width &&\n\t\tFC(r,c) == FC(row,col) && BAYER(r,c))\n\t      tot += (n++,BAYER(r,c));\n\tif (n) BAYER(row,col) = tot\/n;\n      }\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_REMOVE_ZEROES,1,2);\n#endif\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":505796,"func":"int fips_drbg_cprng_test(DRBG_CTX *dctx, const unsigned char *out)\n\t{\n\t\/* No CPRNG in test mode *\/\n\tif (dctx->xflags & DRBG_FLAG_TEST)\n\t\treturn 1;\n\t\/* Check block is valid: should never happen *\/\n\tif (dctx->lb_valid == 0)\n\t\t{\n\t\tFIPSerr(FIPS_F_FIPS_DRBG_CPRNG_TEST, FIPS_R_INTERNAL_ERROR);\n\t\tfips_set_selftest_fail();\n\t\treturn 0;\n\t\t}\n\tif (drbg_stick)\n\t\tmemcpy(dctx->lb, out, dctx->blocklength);\n\t\/* Check against last block: fail if match *\/\n\tif (!memcmp(dctx->lb, out, dctx->blocklength))\n\t\t{\n\t\tFIPSerr(FIPS_F_FIPS_DRBG_CPRNG_TEST, FIPS_R_DRBG_STUCK);\n\t\tfips_set_selftest_fail();\n\t\treturn 0;\n\t\t}\n\t\/* Save last block for next comparison *\/\n\tmemcpy(dctx->lb, out, dctx->blocklength);\n\treturn 1;\n\t}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":194926,"func":"PHP_FUNCTION(ini_restore)\n{\n\tchar *varname;\n\tint varname_len;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &varname, &varname_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tzend_restore_ini_entry(varname, varname_len+1, PHP_INI_STAGE_RUNTIME);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":462070,"func":"void *zcalloc_usable(size_t size, size_t *usable) {\n    void *ptr = ztrycalloc_usable(size, usable);\n    if (!ptr) zmalloc_oom_handler(size);\n    return ptr;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":497008,"func":"TF_LITE_MICRO_TEST(GatherNd_BatchedIndexingIntoMatrix2) {\n  \/\/ For input_dims[], index_dims[], or output_dims[], element 0 is the\n  \/\/ number of dimensions in that array, not the actual dimension data.\n  int input_dims[] = {2, 2, 2};\n  int index_dims[] = {3, 2, 1, 2};\n  const int32_t index_data[] = {0, 0, 1, 1};\n  const float input_data[] = {1.1, 1.2, 2.1, 2.2};\n  const float golden_data[] = {1.1, 2.2};\n  float output_data[2];\n  int output_dims[] = {3, 0, 0, 0};\n  tflite::testing::TestGatherNd<float, int32_t>(\n      input_dims, input_data, index_dims, index_data, output_dims, output_data,\n      golden_data);\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":217150,"func":"MetricsLog::~MetricsLog() {\n}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":301292,"func":"static int pnm_getsint(jas_stream_t *in, int wordsize, int_fast32_t *val)\n{\n\tuint_fast32_t tmpval;\n\n\tif (pnm_getuint(in, wordsize, &tmpval)) {\n\t\treturn -1;\n\t}\n\tif ((tmpval & (1 << (wordsize - 1))) != 0) {\n\t\tjas_eprintf(\"PNM decoder does not fully support signed data\\n\");\n\t\treturn -1;\n\t}\n\tif (val) {\n\t\t*val = tmpval;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":301403,"func":"  ApcLoadJob(void *handle, int index) : m_handle(handle), m_index(index) {}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":483997,"func":"int memhp_online_type_from_str(const char *str)\n{\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(online_type_to_str); i++) {\n\t\tif (sysfs_streq(str, online_type_to_str[i]))\n\t\t\treturn i;\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":219212,"func":"void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(\n    Event* event) {\n  if (event->type() == EventTypeNames::click) {\n    if (mediaElement().textTracks()->length() == 1) {\n      if (mediaElement().textTracks()->hasShowingTracks()) {\n        mediaControls().disableShowingTextTracks();\n      } else {\n        mediaControls().showTextTrackAtIndex(0);\n      }\n    } else {\n      mediaControls().toggleTextTrackList();\n    }\n\n    updateDisplayType();\n    event->setDefaultHandled();\n  }\n\n  MediaControlInputElement::defaultEventHandler(event);\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":121944,"func":"static inline uint64_t memory_region_shift_write_access(uint64_t *value,\n                                                        signed shift,\n                                                        uint64_t mask)\n{\n    uint64_t tmp;\n\n    if (shift >= 0) {\n        tmp = (*value >> shift) & mask;\n    } else {\n        tmp = (*value << -shift) & mask;\n    }\n\n    return tmp;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":321683,"func":"int cpu_get_dump_info(ArchDumpInfo *info,\n\n                      const struct GuestPhysBlockList *guest_phys_blocks)\n\n{\n\n    PowerPCCPU *cpu = POWERPC_CPU(first_cpu);\n\n    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);\n\n\n\n    info->d_machine = PPC_ELF_MACHINE;\n\n    info->d_class = ELFCLASS;\n\n\n\n    if ((*pcc->interrupts_big_endian)(cpu)) {\n\n        info->d_endian = ELFDATA2MSB;\n\n    } else {\n\n        info->d_endian = ELFDATA2LSB;\n\n    }\n\n    \/* 64KB is the max page size for pseries kernel *\/\n\n    if (strncmp(object_get_typename(qdev_get_machine()),\n\n                \"pseries-\", 8) == 0) {\n\n        info->page_size = (1U << 16);\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":180780,"func":"void RenderWidgetHostViewAura::DidCreateNewRendererCompositorFrameSink(\n    cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) {\n  renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;\n  if (delegated_frame_host_) {\n    delegated_frame_host_->DidCreateNewRendererCompositorFrameSink(\n        renderer_compositor_frame_sink_);\n  }\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":311935,"func":"void BackendIO::DoomAllEntries() {\n  operation_ = OP_DOOM_ALL;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":204401,"func":"void V8Proxy::registerExtension(v8::Extension* extension)\n{\n    registerExtensionWithV8(extension);\n    staticExtensionsList().append(extension);\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":237812,"func":"   virtual void SetUp() {\n     UUT_ = GET_PARAM(2);\n#if CONFIG_VP9_HIGHBITDEPTH\n    if (UUT_->use_highbd_ != 0)\n      mask_ = (1 << UUT_->use_highbd_) - 1;\n    else\n      mask_ = 255;\n#endif\n     \/* Set up guard blocks for an inner block centered in the outer block *\/\n     for (int i = 0; i < kOutputBufferSize; ++i) {\n       if (IsIndexInBorder(i))\n        output_[i] = 255;\n else\n        output_[i] = 0;\n\n     }\n \n     ::libvpx_test::ACMRandom prng;\n    for (int i = 0; i < kInputBufferSize; ++i) {\n      if (i & 1) {\n        input_[i] = 255;\n#if CONFIG_VP9_HIGHBITDEPTH\n        input16_[i] = mask_;\n#endif\n      } else {\n        input_[i] = prng.Rand8Extremes();\n#if CONFIG_VP9_HIGHBITDEPTH\n        input16_[i] = prng.Rand16() & mask_;\n#endif\n      }\n    }\n   }\n","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":473244,"func":"valid_ordinal_p(VALUE y, int d, double sg,\n\t\tVALUE *nth, int *ry,\n\t\tint *rd, int *rjd,\n\t\tint *ns)\n{\n    double style = guess_style(y, sg);\n    int r;\n\n    if (style == 0) {\n\tint jd;\n\n\tr = c_valid_ordinal_p(FIX2INT(y), d, sg, rd, &jd, ns);\n\tif (!r)\n\t    return 0;\n\tdecode_jd(INT2FIX(jd), nth, rjd);\n\tif (f_zero_p(*nth))\n\t    *ry = FIX2INT(y);\n\telse {\n\t    VALUE nth2;\n\t    decode_year(y, *ns ? -1 : +1, &nth2, ry);\n\t}\n    }\n    else {\n\tdecode_year(y, style, nth, ry);\n\tr = c_valid_ordinal_p(*ry, d, style, rd, rjd, ns);\n    }\n    return r;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":86637,"func":"static int strict_blocks_to_sectors(const char *buf, sector_t *sectors)\n{\n\tunsigned long long blocks;\n\tsector_t new;\n\n\tif (kstrtoull(buf, 10, &blocks) < 0)\n\t\treturn -EINVAL;\n\n\tif (blocks & 1ULL << (8 * sizeof(blocks) - 1))\n\t\treturn -EINVAL; \/* sector conversion overflow *\/\n\n\tnew = blocks * 2;\n\tif (new != blocks * 2)\n\t\treturn -EINVAL; \/* unsigned long long to sector_t overflow *\/\n\n\t*sectors = new;\n\treturn 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":84053,"func":"PJ_DEF(void) pj_scan_save_state( const pj_scanner *scanner, \n\t\t\t\t pj_scan_state *state)\n{\n    state->curptr = scanner->curptr;\n    state->line = scanner->line;\n    state->start_line = scanner->start_line;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":78899,"func":"static int opfiadd(RAsm *a, ut8 *data, const Opcode *op) {\n\tint l = 0;\n\tswitch (op->operands_count) {\n\tcase 1:\n\t\tif ( op->operands[0].type & OT_MEMORY ) {\n\t\t\tif ( op->operands[0].type & OT_WORD ) {\n\t\t\t\tdata[l++] = 0xde;\n\t\t\t\tdata[l++] = 0x00 | op->operands[0].regs[0];\n\t\t\t} else if ( op->operands[0].type & OT_DWORD ) {\n\t\t\t\tdata[l++] = 0xda;\n\t\t\t\tdata[l++] = 0x00 | op->operands[0].regs[0];\n\t\t\t} else {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\treturn -1;\n\t}\n\treturn l;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":86647,"func":"void CL_AddToLimboChat( const char *str ) {\n\tint len = 0;\n\tchar *p;\n\tint i;\n\n\tcl.limboChatPos = LIMBOCHAT_HEIGHT - 1;\n\n\t\/\/ copy old strings\n\tfor ( i = cl.limboChatPos; i > 0; i-- ) {\n\t\tstrcpy( cl.limboChatMsgs[i], cl.limboChatMsgs[i - 1] );\n\t}\n\n\t\/\/ copy new string\n\tp = cl.limboChatMsgs[0];\n\t*p = 0;\n\n\twhile ( *str ) {\n\t\tif ( len > LIMBOCHAT_WIDTH - 1 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( Q_IsColorString( str ) ) {\n\t\t\t*p++ = *str++;\n\t\t\t*p++ = *str++;\n\t\t\tcontinue;\n\t\t}\n\t\t*p++ = *str++;\n\t\tlen++;\n\t}\n\t*p = 0;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":307450,"func":"    void setCanCollapseMarginAfterWithChildren(bool collapse) { m_canCollapseMarginAfterWithChildren = collapse; }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":481597,"func":"static inline struct io_kiocb *io_req_find_next(struct io_kiocb *req)\n{\n\tstruct io_kiocb *nxt;\n\n\t\/*\n\t * If LINK is set, we have dependent requests in this chain. If we\n\t * didn't fail this request, queue the first one up, moving any other\n\t * dependencies to the next request. In case of failure, fail the rest\n\t * of the chain.\n\t *\/\n\tif (unlikely(req->flags & IO_DISARM_MASK))\n\t\t__io_req_find_next_prep(req);\n\tnxt = req->link;\n\treq->link = NULL;\n\treturn nxt;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":97950,"func":"static int check_reg_arg(struct reg_state *regs, u32 regno,\n\t\t\t enum reg_arg_type t)\n{\n\tif (regno >= MAX_BPF_REG) {\n\t\tverbose(\"R%d is invalid\\n\", regno);\n\t\treturn -EINVAL;\n\t}\n\n\tif (t == SRC_OP) {\n\t\t\/* check whether register used as source operand can be read *\/\n\t\tif (regs[regno].type == NOT_INIT) {\n\t\t\tverbose(\"R%d !read_ok\\n\", regno);\n\t\t\treturn -EACCES;\n\t\t}\n\t} else {\n\t\t\/* check whether register used as dest operand can be written to *\/\n\t\tif (regno == BPF_REG_FP) {\n\t\t\tverbose(\"frame pointer is read only\\n\");\n\t\t\treturn -EACCES;\n\t\t}\n\t\tif (t == DST_OP)\n\t\t\tmark_reg_unknown_value(regs, regno);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":451568,"func":"static BROTLI_INLINE size_t NextBlockTypeCode(\n    BlockTypeCodeCalculator* calculator, uint8_t type) {\n  size_t type_code = (type == calculator->last_type + 1) ? 1u :\n      (type == calculator->second_last_type) ? 0u : type + 2u;\n  calculator->second_last_type = calculator->last_type;\n  calculator->last_type = type;\n  return type_code;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":237016,"func":"  TestInterstitialPageDelegate(TestInterstitialPage* interstitial_page)\n      : interstitial_page_(interstitial_page) {}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":139190,"func":"flatpak_run_add_pcsc_args (FlatpakBwrap *bwrap)\n{\n  const char * pcsc_socket;\n  const char * sandbox_pcsc_socket = \"\/run\/pcscd\/pcscd.comm\";\n\n  pcsc_socket = g_getenv (\"PCSCLITE_CSOCK_NAME\");\n  if (pcsc_socket)\n    {\n      if (!g_file_test (pcsc_socket, G_FILE_TEST_EXISTS))\n        {\n          flatpak_bwrap_unset_env (bwrap, \"PCSCLITE_CSOCK_NAME\");\n          return;\n        }\n    }\n  else\n    {\n      pcsc_socket = \"\/run\/pcscd\/pcscd.comm\";\n      if (!g_file_test (pcsc_socket, G_FILE_TEST_EXISTS))\n        return;\n    }\n\n  flatpak_bwrap_add_args (bwrap,\n                          \"--ro-bind\", pcsc_socket, sandbox_pcsc_socket,\n                          NULL);\n  flatpak_bwrap_set_env (bwrap, \"PCSCLITE_CSOCK_NAME\", sandbox_pcsc_socket, TRUE);\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":103618,"func":"static int nf_tables_loop_check_setelem(const struct nft_ctx *ctx,\n\t\t\t\t\tconst struct nft_set *set,\n\t\t\t\t\tconst struct nft_set_iter *iter,\n\t\t\t\t\tconst struct nft_set_elem *elem)\n{\n\tif (elem->flags & NFT_SET_ELEM_INTERVAL_END)\n\t\treturn 0;\n\n\tswitch (elem->data.verdict) {\n\tcase NFT_JUMP:\n\tcase NFT_GOTO:\n\t\treturn nf_tables_check_loops(ctx, elem->data.chain);\n\tdefault:\n\t\treturn 0;\n\t}\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":71600,"func":"bool AdminRequestHandler::handleRandomStaticStringsRequest(\n  const std::string& \/*cmd*\/, Transport* transport) {\n  size_t count = 1;\n  auto countParam = transport->getParam(\"count\");\n  if (countParam != \"\") {\n    try {\n      count = folly::to<size_t>(countParam);\n    } catch (...) {\n      \/\/ do the default on invalid input\n    }\n  }\n  std::string output;\n  auto list = lookupDefinedStaticStrings();\n  if (count < list.size()) {\n    for (size_t i = 0; i < count; i++) {\n      size_t j = folly::Random::rand64(i, list.size());\n      std::swap(list[i], list[j]);\n    }\n    list.resize(count);\n  }\n  for (auto item : list) {\n    output += formatStaticString(item);\n  }\n  transport->sendString(output);\n  return true;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":389490,"func":"_encode(ImagingEncoderObject* encoder, PyObject* args)\n{\n    PyObject* buf;\n    PyObject* result;\n    int status;\n\n    \/* Encode to a Python string (allocated by this method) *\/\n\n    int bufsize = 16384;\n\n    if (!PyArg_ParseTuple(args, \"|i\", &bufsize))\n\treturn NULL;\n\n    buf = PyBytes_FromStringAndSize(NULL, bufsize);\n    if (!buf)\n\treturn NULL;\n\n    status = encoder->encode(encoder->im, &encoder->state,\n\t\t\t     (UINT8*) PyBytes_AsString(buf), bufsize);\n\n    \/* adjust string length to avoid slicing in encoder *\/\n    if (_PyBytes_Resize(&buf, (status > 0) ? status : 0) < 0)\n        return NULL;\n\n    result = Py_BuildValue(\"iiO\", status, encoder->state.errcode, buf);\n\n    Py_DECREF(buf); \/* must release buffer!!! *\/\n\n    return result;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":160385,"func":"static inline bool rom_order_compare(Rom *rom, Rom *item)\n{\n    return ((uintptr_t)(void *)rom->as > (uintptr_t)(void *)item->as) ||\n           (rom->as == item->as && rom->addr >= item->addr);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":87117,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nGF_Err tsro_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TimeOffHintEntryBox *ptr = (GF_TimeOffHintEntryBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->TimeOffset);\n\treturn GF_OK;","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":210871,"func":"void BrowserWindowGtk::Close() {\n  if (!window_)\n    return;\n\n  if (!CanClose())\n    return;\n\n  tabstrip_->StopAnimation();\n\n  SaveWindowPosition();\n\n  if (accel_group_) {\n    AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance();\n    for (AcceleratorsGtk::const_iterator iter = accelerators->begin();\n         iter != accelerators->end(); ++iter) {\n      gtk_accel_group_disconnect_key(accel_group_,\n          iter->second.GetGdkKeyCode(),\n          static_cast<GdkModifierType>(iter->second.modifiers()));\n    }\n    gtk_window_remove_accel_group(window_, accel_group_);\n    g_object_unref(accel_group_);\n    accel_group_ = NULL;\n  }\n\n  window_configure_debounce_timer_.Stop();\n\n  loading_animation_timer_.Stop();\n\n  GtkWidget* window = GTK_WIDGET(window_);\n  window_ = NULL;\n  window_has_shown_ = false;\n  titlebar_->set_window(NULL);\n\n  global_menu_bar_->Disable();\n  gtk_widget_destroy(window);\n}\n","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":115951,"func":"  QUInt8(const uint8_t v) : value(v) {}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":273937,"func":"bson_iter_key (const bson_iter_t *iter) \/* IN *\/\n{\n   BSON_ASSERT (iter);\n\n   return bson_iter_key_unsafe (iter);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":408433,"func":"string_isupper(PyStringObject *self)\n{\n    register const unsigned char *p\n        = (unsigned char *) PyString_AS_STRING(self);\n    register const unsigned char *e;\n    int cased;\n\n    \/* Shortcut for single character strings *\/\n    if (PyString_GET_SIZE(self) == 1)\n        return PyBool_FromLong(isupper(*p) != 0);\n\n    \/* Special case for empty strings *\/\n    if (PyString_GET_SIZE(self) == 0)\n        return PyBool_FromLong(0);\n\n    e = p + PyString_GET_SIZE(self);\n    cased = 0;\n    for (; p < e; p++) {\n        if (islower(*p))\n            return PyBool_FromLong(0);\n        else if (!cased && isupper(*p))\n            cased = 1;\n    }\n    return PyBool_FromLong(cased);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":96076,"func":"mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *argv)\n{\n  mrb_value obj;\n  mrb_sym mid;\n\n  obj = mrb_instance_alloc(mrb, mrb_obj_value(c));\n  mid = MRB_SYM(initialize);\n  if (!mrb_func_basic_p(mrb, obj, mid, mrb_do_nothing)) {\n    mrb_funcall_argv(mrb, obj, mid, argc, argv);\n  }\n  return obj;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":483419,"func":"static void *cgroup_idr_replace(struct idr *idr, void *ptr, int id)\n{\n\tvoid *ret;\n\n\tspin_lock_bh(&cgroup_idr_lock);\n\tret = idr_replace(idr, ptr, id);\n\tspin_unlock_bh(&cgroup_idr_lock);\n\treturn ret;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":202297,"func":"RenderFrameHostImpl::GetFindInPage() {\n  if (!find_in_page_ || !find_in_page_.is_bound() ||\n      find_in_page_.encountered_error())\n    GetRemoteAssociatedInterfaces()->GetInterface(&find_in_page_);\n  return find_in_page_;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":492096,"func":"backup_cleanup()\n{\n\tfree(mysql_binlog_position);\n\tfree(buffer_pool_filename);\n\tfree(backup_uuid);\n\tbackup_uuid = NULL;\n\n\tif (mysql_connection) {\n\t\tmysql_close(mysql_connection);\n\t}\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":167370,"func":"void BlobStorageContext::NotifyTransportComplete(const std::string& uuid) {\n  BlobEntry* entry = registry_.GetEntry(uuid);\n  CHECK(entry) << \"There is no blob entry with uuid \" << uuid;\n  DCHECK(BlobStatusIsPending(entry->status()));\n  NotifyTransportCompleteInternal(entry);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":99240,"func":"PHP_FUNCTION(imagecolorresolvealpha)\n{\n\tzval *IM;\n\tlong red, green, blue, alpha;\n\tgdImagePtr im;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rllll\", &IM, &red, &green, &blue, &alpha) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\n\tRETURN_LONG(gdImageColorResolveAlpha(im, red, green, blue, alpha));\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":272208,"func":"    \/\/! Return pixel value, using cubic interpolation and mirror boundary conditions for the X and Y-coordinates.\n    Tfloat cubic_atXY_p(const float fx, const float fy, const int z=0, const int c=0) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"cubic_atXY_p(): Empty instance.\",\n                                    cimg_instance);\n      return _cubic_atXY_p(fx,fy,z,c);","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":447229,"func":"int efi_mem_type(unsigned long phys_addr)\n{\n\tconst efi_memory_desc_t *md;\n\n\tif (!efi_enabled(EFI_MEMMAP))\n\t\treturn -ENOTSUPP;\n\n\tfor_each_efi_memory_desc(md) {\n\t\tif ((md->phys_addr <= phys_addr) &&\n\t\t    (phys_addr < (md->phys_addr +\n\t\t\t\t  (md->num_pages << EFI_PAGE_SHIFT))))\n\t\t\treturn md->type;\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":284058,"func":"launch_login(struct passwd *pw, const char *hostname)\n{\n\t\/* Launch login(1). *\/\n\n\texecl(LOGIN_PROGRAM, \"login\", \"-h\", hostname,\n#ifdef xxxLOGIN_NEEDS_TERM\n\t\t    (s->term ? s->term : \"unknown\"),\n#endif \/* LOGIN_NEEDS_TERM *\/\n#ifdef LOGIN_NO_ENDOPT\n\t    \"-p\", \"-f\", pw->pw_name, (char *)NULL);\n#else\n\t    \"-p\", \"-f\", \"--\", pw->pw_name, (char *)NULL);\n#endif\n\n\t\/* Login couldn't be executed, die. *\/\n\n\tperror(\"login\");\n\texit(1);\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":432089,"func":"static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)\n{\n  time_t                current;\n  tftp_state_data_t     *state = (tftp_state_data_t *)conn->proto.tftpc;\n\n  if(event)\n    *event = TFTP_EVENT_NONE;\n\n  time(¤t);\n  if(current > state->max_time) {\n    DEBUGF(infof(conn->data, \"timeout: %ld > %ld\\n\",\n                 (long)current, (long)state->max_time));\n    state->error = TFTP_ERR_TIMEOUT;\n    state->state = TFTP_STATE_FIN;\n    return 0;\n  }\n  if(current > state->rx_time + state->retry_time) {\n    if(event)\n      *event = TFTP_EVENT_TIMEOUT;\n    time(&state->rx_time); \/* update even though we received nothing *\/\n  }\n\n  \/* there's a typecast below here since 'time_t' may in fact be larger than\n     'long', but we estimate that a 'long' will still be able to hold number\n     of seconds even if \"only\" 32 bit *\/\n  return (long)(state->max_time - current);\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":315531,"func":"void DTLS_RECORD_LAYER_set_saved_w_epoch(RECORD_LAYER *rl, unsigned short e)\n{\n    if (e == rl->d->w_epoch - 1) {\n        memcpy(rl->d->curr_write_sequence,\n               rl->write_sequence, sizeof(rl->write_sequence));\n        memcpy(rl->write_sequence,\n               rl->d->last_write_sequence, sizeof(rl->write_sequence));\n    } else if (e == rl->d->w_epoch + 1) {\n        memcpy(rl->d->last_write_sequence,\n               rl->write_sequence, sizeof(unsigned char[8]));\n        memcpy(rl->write_sequence,\n               rl->d->curr_write_sequence, sizeof(rl->write_sequence));\n    }\n    rl->d->w_epoch = e;\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":1888,"func":"static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_report_kpp rkpp;\n\n\tstrlcpy(rkpp.type, \"kpp\", sizeof(rkpp.type));\n\n\tif (nla_put(skb, CRYPTOCFGA_REPORT_KPP,\n\t\t    sizeof(struct crypto_report_kpp), &rkpp))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -EMSGSIZE;\n}","target":1,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":442540,"func":"static bool rbuf_alloc(conn *c) {\n    if (c->rbuf == NULL) {\n        c->rbuf = do_cache_alloc(c->thread->rbuf_cache);\n        if (!c->rbuf) {\n            THR_STATS_LOCK(c);\n            c->thread->stats.read_buf_oom++;\n            THR_STATS_UNLOCK(c);\n            return false;\n        }\n        c->rsize = READ_BUFFER_SIZE;\n        c->rcurr = c->rbuf;\n    }\n    return true;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":269259,"func":"void HeaderMapImpl::addReferenceKey(const LowerCaseString& key, uint64_t value) {\n  HeaderString ref_key(key);\n  HeaderString new_value;\n  new_value.setInteger(value);\n  insertByKey(std::move(ref_key), std::move(new_value));\n  ASSERT(new_value.empty()); \/\/ NOLINT(bugprone-use-after-move)\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":210622,"func":"RTCPeerConnectionHandler::GetConfiguration() const {\n  return configuration_;\n}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":104909,"func":"static int vmx_cpu_uses_apicv(struct kvm_vcpu *vcpu)\n{\n\treturn enable_apicv && lapic_in_kernel(vcpu);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":296721,"func":"static void run_tests()\n{\n    test_simple();\n    test_secure_funcs();\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":35392,"func":"void usb_sg_cancel(struct usb_sg_request *io)\n{\n\tunsigned long flags;\n\tint i, retval;\n\n\tspin_lock_irqsave(&io->lock, flags);\n\tif (io->status || io->count == 0) {\n\t\tspin_unlock_irqrestore(&io->lock, flags);\n\t\treturn;\n\t}\n\t\/* shut everything down *\/\n\tio->status = -ECONNRESET;\n\tio->count++;\t\t\/* Keep the request alive until we're done *\/\n\tspin_unlock_irqrestore(&io->lock, flags);\n\n\tfor (i = io->entries - 1; i >= 0; --i) {\n\t\tusb_block_urb(io->urbs[i]);\n\n\t\tretval = usb_unlink_urb(io->urbs[i]);\n\t\tif (retval != -EINPROGRESS\n\t\t    && retval != -ENODEV\n\t\t    && retval != -EBUSY\n\t\t    && retval != -EIDRM)\n\t\t\tdev_warn(&io->dev->dev, \"%s, unlink --> %d\\n\",\n\t\t\t\t __func__, retval);\n\t}\n\n\tspin_lock_irqsave(&io->lock, flags);\n\tio->count--;\n\tif (!io->count)\n\t\tcomplete(&io->complete);\n\tspin_unlock_irqrestore(&io->lock, flags);\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":85358,"func":"static void tb_phys_invalidate__locked(TCGContext *tcg_ctx, TranslationBlock *tb)\n{\n    do_tb_phys_invalidate(tcg_ctx, tb, true);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":223972,"func":"void RootWindow::OnLayerAnimationAborted(\n    ui::LayerAnimationSequence* animation) {\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":356663,"func":"static jas_cmpxformseq_t *jas_cmpxformseq_copy(jas_cmpxformseq_t *pxformseq)\n{\n\tjas_cmpxformseq_t *newpxformseq;\n\n\tif (!(newpxformseq = jas_cmpxformseq_create()))\n\t\tgoto error;\n\tif (jas_cmpxformseq_append(newpxformseq, pxformseq))\n\t\tgoto error;\n\treturn newpxformseq;\nerror:\n\treturn 0;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":115915,"func":"static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)\n{\n\tswitch (device->fs_devices->chunk_alloc_policy) {\n\tcase BTRFS_CHUNK_ALLOC_REGULAR:\n\t\t\/*\n\t\t * We don't want to overwrite the superblock on the drive nor\n\t\t * any area used by the boot loader (grub for example), so we\n\t\t * make sure to start at an offset of at least 1MB.\n\t\t *\/\n\t\treturn max_t(u64, start, SZ_1M);\n\tcase BTRFS_CHUNK_ALLOC_ZONED:\n\t\t\/*\n\t\t * We don't care about the starting region like regular\n\t\t * allocator, because we anyway use\/reserve the first two zones\n\t\t * for superblock logging.\n\t\t *\/\n\t\treturn ALIGN(start, device->zone_info->zone_size);\n\tdefault:\n\t\tBUG();\n\t}\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":452025,"func":"static void rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,\n\t\t\t\t    int which)\n{\n\tstruct rbd_obj_request *obj_req = osd_req->r_priv;\n\n\tswitch (obj_req->img_request->op_type) {\n\tcase OBJ_OP_WRITE:\n\t\t__rbd_osd_setup_write_ops(osd_req, which);\n\t\tbreak;\n\tcase OBJ_OP_DISCARD:\n\t\t__rbd_osd_setup_discard_ops(osd_req, which);\n\t\tbreak;\n\tcase OBJ_OP_ZEROOUT:\n\t\t__rbd_osd_setup_zeroout_ops(osd_req, which);\n\t\tbreak;\n\tdefault:\n\t\tBUG();\n\t}\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":243330,"func":"void LocalFrameClientImpl::DidChangePerformanceTiming() {\n  if (web_frame_->Client())\n    web_frame_->Client()->DidChangePerformanceTiming();\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":363533,"func":"hook_infolist_get (struct t_weechat_plugin *plugin, const char *infolist_name,\n                   void *pointer, const char *arguments)\n{\n    struct t_hook *ptr_hook, *next_hook;\n    struct t_infolist *value;\n    \n    \/* make C compiler happy *\/\n    (void) plugin;\n    \n    if (!infolist_name || !infolist_name[0])\n        return NULL;\n    \n    hook_exec_start ();\n    \n    ptr_hook = weechat_hooks[HOOK_TYPE_INFOLIST];\n    while (ptr_hook)\n    {\n        next_hook = ptr_hook->next_hook;\n        \n        if (!ptr_hook->deleted\n            && !ptr_hook->running\n            && (string_strcasecmp (HOOK_INFOLIST(ptr_hook, infolist_name),\n                                   infolist_name) == 0))\n        {\n            ptr_hook->running = 1;\n            value = (HOOK_INFOLIST(ptr_hook, callback))\n                (ptr_hook->callback_data, infolist_name, pointer, arguments);\n            ptr_hook->running = 0;\n            \n            hook_exec_end ();\n            return value;\n        }\n        \n        ptr_hook = next_hook;\n    }\n    \n    hook_exec_end ();\n    \n    \/* infolist not found *\/\n    return NULL;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":401551,"func":"gboolean menu_cache_app_get_is_visible( MenuCacheApp* app, guint32 de_flags )\n{\n    if(app->flags & FLAG_IS_NODISPLAY)\n        return FALSE;\n    return (!app->show_in_flags || (app->show_in_flags & de_flags)) &&\n           _can_be_exec(app);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":84765,"func":"frame_add_height(frame_T *frp, int n)\n{\n    frame_new_height(frp, frp->fr_height + n, FALSE, FALSE);\n    for (;;)\n    {\n\tfrp = frp->fr_parent;\n\tif (frp == NULL)\n\t    break;\n\tfrp->fr_height += n;\n    }\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":366583,"func":"MP4::Properties::bitsPerSample() const\n{\n  return d->bitsPerSample;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":501539,"func":"  void setupServiceRegexPatternValidationHC() {\n    std::string yaml = R\"EOF(\n    timeout: 1s\n    interval: 1s\n    interval_jitter: 1s\n    unhealthy_threshold: 2\n    healthy_threshold: 2\n    http_health_check:\n      service_name_matcher:\n        safe_regex:\n          google_re2: {}\n          regex: 'locations-.*-.*$'\n      path: \/healthcheck\n    )EOF\";\n\n    allocHealthChecker(yaml);\n    addCompletionCallback();\n  }","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":299873,"func":"static bool mtrr_lookup_fixed_start(struct mtrr_iter *iter)\n{\n\tint seg, index;\n\n\tif (!fixed_mtrr_is_enabled(iter->mtrr_state))\n\t\treturn false;\n\n\tseg = fixed_mtrr_addr_to_seg(iter->start);\n\tif (seg < 0)\n\t\treturn false;\n\n\titer->fixed = true;\n\tindex = fixed_mtrr_addr_seg_to_range_index(iter->start, seg);\n\titer->index = index;\n\titer->seg = seg;\n\treturn true;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":231444,"func":"QString IRCView::closeToTagString(TextHtmlData* data, const QString& _tag)\n{\n    QString ret;\n    QString tag;\n    int i = data->openHtmlTags.count() - 1;\n    for ( ; i >= 0 ; --i)\n    {\n        tag = data->openHtmlTags.at(i);\n        ret += QLatin1String(\"<\/\") + tag + QLatin1Char('>');\n        if (tag == _tag)\n        {\n            data->openHtmlTags.removeAt(i);\n            break;\n        }\n     }\n \n    if (i > -1)\n        ret += openTags(data, i);\n \n     return ret;\n }\n","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":194234,"func":"void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr)\n{\n    vdev->vq[n].vring.desc = addr;\n    virtio_queue_update_rings(vdev, n);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":314190,"func":"static int wait_on_pipe(struct trace_iterator *iter, int full)\n{\n\t\/* Iterators are static, they should be filled or empty *\/\n\tif (trace_buffer_iter(iter, iter->cpu_file))\n\t\treturn 0;\n\n\treturn ring_buffer_wait(iter->trace_buffer->buffer, iter->cpu_file,\n\t\t\t\tfull);\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":504404,"func":"TPMI_DH_SAVED_Marshal(TPMI_DH_CONTEXT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_HANDLE_Marshal(source, buffer, size);\n    return written;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":391679,"func":"xmlDOMWrapNewCtxt(void)\n{\n    xmlDOMWrapCtxtPtr ret;\n\n    ret = xmlMalloc(sizeof(xmlDOMWrapCtxt));\n    if (ret == NULL) {\n\txmlTreeErrMemory(\"allocating DOM-wrapper context\");\n\treturn (NULL);\n    }\n    memset(ret, 0, sizeof(xmlDOMWrapCtxt));\n    return (ret);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":251304,"func":"void WebGL2RenderingContextBase::uniformMatrix2fv(\n    const WebGLUniformLocation* location,\n    GLboolean transpose,\n    Vector<GLfloat>& v) {\n  WebGLRenderingContextBase::uniformMatrix2fv(location, transpose, v);\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":119783,"func":"StartSelect(XtermWidget xw, const CELL *cell)\n{\n    TScreen *screen = TScreenOf(xw);\n\n    TRACE((\"StartSelect row=%d, col=%d\\n\", cell->row, cell->col));\n    if (screen->cursor_state)\n\tHideCursor(xw);\n    if (screen->numberOfClicks == 1) {\n\t\/* set start of selection *\/\n\tscreen->rawPos = *cell;\n    }\n    \/* else use old values in rawPos *\/\n    screen->saveStartR = screen->startExt = screen->rawPos;\n    screen->saveEndR = screen->endExt = screen->rawPos;\n    if (Coordinate(screen, cell) < Coordinate(screen, &(screen->rawPos))) {\n\tscreen->eventMode = LEFTEXTENSION;\n\tscreen->startExt = *cell;\n    } else {\n\tscreen->eventMode = RIGHTEXTENSION;\n\tscreen->endExt = *cell;\n    }\n    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), False, True);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":23812,"func":"char * evhttp_encode_uri ( const char * uri ) {\n struct evbuffer * buf = evbuffer_new ( ) ;\n char * p ;\n for ( p = ( char * ) uri ;\n * p != '\\0' ;\n p ++ ) {\n if ( uri_chars [ ( u_char ) ( * p ) ] ) {\n evbuffer_add ( buf , p , 1 ) ;\n }\n else {\n evbuffer_add_printf ( buf , \"%%%02X\" , ( u_char ) ( * p ) ) ;\n }\n }\n evbuffer_add ( buf , \"\" , 1 ) ;\n p = strdup ( ( char * ) EVBUFFER_DATA ( buf ) ) ;\n evbuffer_free ( buf ) ;\n return ( p ) ;\n }","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":278166,"func":"void js_defaccessor(js_State *J, int idx, const char *name, int atts)\n{\n\tjsR_defproperty(J, js_toobject(J, idx), name, atts, NULL, jsR_tofunction(J, -2), jsR_tofunction(J, -1));\n\tjs_pop(J, 2);\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":31486,"func":"static struct in_ifaddr *inet_alloc_ifa(void)\n{\n\treturn kzalloc(sizeof(struct in_ifaddr), GFP_KERNEL);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":157768,"func":"DEFINE_TEST(test_read_format_rar5_invalid_dict_reference)\n{\n\tuint8_t buf[16];\n\n\tPROLOGUE(\"test_read_format_rar5_invalid_dict_reference.rar\");\n\n\t\/* This test should fail on parsing the header. *\/\n\tassertA(archive_read_next_header(a, &ae) != ARCHIVE_OK);\n\n\t\/* This archive is invalid. However, processing it shouldn't cause any\n\t * errors related to buffer underflow when using -fsanitize. *\/\n\tassertA(archive_read_data(a, buf, sizeof(buf)) <= 0);\n\n\t\/* This test only cares about not returning success here. *\/\n\tassertA(ARCHIVE_OK != archive_read_next_header(a, &ae));\n\n\tEPILOGUE();\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":46672,"func":"  bool isInvalid() const override {\n    return data == nullptr;\n  }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":361488,"func":"struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,\n\t\t\t  const struct cred *cred, unsigned long flags,\n\t\t\t  struct key *dest)\n{\n\tstruct key *keyring;\n\tint ret;\n\n\tkeyring = key_alloc(&key_type_keyring, description,\n\t\t\t    uid, gid, cred,\n\t\t\t    (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL,\n\t\t\t    flags);\n\n\tif (!IS_ERR(keyring)) {\n\t\tret = key_instantiate_and_link(keyring, NULL, 0, dest, NULL);\n\t\tif (ret < 0) {\n\t\t\tkey_put(keyring);\n\t\t\tkeyring = ERR_PTR(ret);\n\t\t}\n\t}\n\n\treturn keyring;\n\n} \/* end keyring_alloc() *\/","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":288901,"func":"static const char * ultag_getRegion ( const ULanguageTag * langtag ) {\n return langtag -> region ;\n }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":281773,"func":"static void voidMethodSequenceDictionaryArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    TestObjectPythonV8Internal::voidMethodSequenceDictionaryArgMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":143687,"func":"static int ocfs2_dir_open(struct inode *inode, struct file *file)\n{\n\treturn ocfs2_init_file_private(inode, file);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":182282,"func":"int64 GetAmountOfFreeDiskSpace() {\n  if (global_free_disk_getter_for_testing)\n    return global_free_disk_getter_for_testing->AmountOfFreeDiskSpace();\n\n  return base::SysInfo::AmountOfFreeDiskSpace(\n      FilePath::FromUTF8Unsafe(GetHomeDirectory()));\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":21060,"func":"static int qdev_add_one_global(QemuOpts *opts, void *opaque)\n\n{\n\n    GlobalProperty *g;\n\n    ObjectClass *oc;\n\n\n\n    g = g_malloc0(sizeof(*g));\n\n    g->driver   = qemu_opt_get(opts, \"driver\");\n\n    g->property = qemu_opt_get(opts, \"property\");\n\n    g->value    = qemu_opt_get(opts, \"value\");\n\n    oc = object_class_by_name(g->driver);\n\n    if (oc) {\n\n        DeviceClass *dc = DEVICE_CLASS(oc);\n\n\n\n        if (dc->hotpluggable) {\n\n            \/* If hotpluggable then skip not_used checking. *\/\n\n            g->not_used = false;\n\n        } else {\n\n            \/* Maybe a typo. *\/\n\n            g->not_used = true;\n\n        }\n\n    } else {\n\n        \/* Maybe a typo. *\/\n\n        g->not_used = true;\n\n    }\n\n    qdev_prop_register_global(g);\n\n    return 0;\n\n}\n","target":1,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":70591,"func":"static void snd_timer_clear_callbacks(struct snd_timer *timer,\n\t\t\t\t      struct list_head *head)\n{\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&timer->lock, flags);\n\twhile (!list_empty(head))\n\t\tlist_del_init(head->next);\n\tspin_unlock_irqrestore(&timer->lock, flags);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":147724,"func":"nvmet_fc_find_target_assoc(struct nvmet_fc_tgtport *tgtport,\n\t\t\t\tu64 association_id)\n{\n\tstruct nvmet_fc_tgt_assoc *assoc;\n\tstruct nvmet_fc_tgt_assoc *ret = NULL;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&tgtport->lock, flags);\n\tlist_for_each_entry(assoc, &tgtport->assoc_list, a_list) {\n\t\tif (association_id == assoc->association_id) {\n\t\t\tret = assoc;\n\t\t\tnvmet_fc_tgt_a_get(assoc);\n\t\t\tbreak;\n\t\t}\n\t}\n\tspin_unlock_irqrestore(&tgtport->lock, flags);\n\n\treturn ret;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":123126,"func":"static int create_std_midi_quirk(struct snd_usb_audio *chip,\n\t\t\t\t struct usb_interface *iface,\n\t\t\t\t struct usb_driver *driver,\n\t\t\t\t struct usb_host_interface *alts)\n{\n\tstruct usb_ms_header_descriptor *mshd;\n\tstruct usb_ms_endpoint_descriptor *msepd;\n\n\t\/* must have the MIDIStreaming interface header descriptor*\/\n\tmshd = (struct usb_ms_header_descriptor *)alts->extra;\n\tif (alts->extralen < 7 ||\n\t    mshd->bLength < 7 ||\n\t    mshd->bDescriptorType != USB_DT_CS_INTERFACE ||\n\t    mshd->bDescriptorSubtype != USB_MS_HEADER)\n\t\treturn -ENODEV;\n\t\/* must have the MIDIStreaming endpoint descriptor*\/\n\tmsepd = (struct usb_ms_endpoint_descriptor *)alts->endpoint[0].extra;\n\tif (alts->endpoint[0].extralen < 4 ||\n\t    msepd->bLength < 4 ||\n\t    msepd->bDescriptorType != USB_DT_CS_ENDPOINT ||\n\t    msepd->bDescriptorSubtype != UAC_MS_GENERAL ||\n\t    msepd->bNumEmbMIDIJack < 1 ||\n\t    msepd->bNumEmbMIDIJack > 16)\n\t\treturn -ENODEV;\n\n\treturn create_any_midi_quirk(chip, iface, driver, NULL);\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":277176,"func":"static bool cmd_identify(IDEState *s, uint8_t cmd)\n{\n    if (s->blk && s->drive_kind != IDE_CD) {\n        if (s->drive_kind != IDE_CFATA) {\n            ide_identify(s);\n        } else {\n            ide_cfata_identify(s);\n        }\n        s->status = READY_STAT | SEEK_STAT;\n        ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);\n        ide_set_irq(s->bus);\n        return false;\n    } else {\n        if (s->drive_kind == IDE_CD) {\n            ide_set_signature(s);\n        }\n        ide_abort_command(s);\n    }\n\n    return true;\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":125216,"func":"void* leak_realloc(void* oldMem, size_t bytes)\n{\n    if (oldMem == NULL) {\n        return leak_malloc(bytes);\n    }\n    void* newMem = NULL;\n    AllocationEntry* header = (AllocationEntry*)oldMem - 1;\n    if (header && header->guard == GUARD) {\n        size_t oldSize = header->entry->size & ~SIZE_FLAG_MASK;\n        newMem = leak_malloc(bytes);\n        if (newMem != NULL) {\n            size_t copySize = (oldSize <= bytes) ? oldSize : bytes;\n            memcpy(newMem, oldMem, copySize);\n            leak_free(oldMem);\n        }\n    } else {\n        newMem = dlrealloc(oldMem, bytes);\n    }\n    return newMem;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":377316,"func":"static gnutls_datum_t mmap_file(const char *file)\n{\n    int fd;\n    gnutls_datum_t mmaped_file = { NULL, 0 };\n    struct stat stat_st;\n    void *ptr;\n\n    fd = open(file, 0);\n    if (fd == -1)\n\treturn mmaped_file;\n\n    fstat(fd, &stat_st);\n\n    if ((ptr =\n\t mmap(NULL, stat_st.st_size, PROT_READ, MAP_SHARED, fd,\n\t      0)) == MAP_FAILED)\n    {\n      close(fd);\n\treturn mmaped_file;\n    }\n   close(fd);\n\n    mmaped_file.data = (unsigned char*)ptr;\n    mmaped_file.size = stat_st.st_size;\n\n    return mmaped_file;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":243560,"func":"ShellWindowViews::~ShellWindowViews() {\n  web_view_->SetWebContents(NULL);\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":199398,"func":"ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)\n : AState(parentState),\n      mCodec(codec) {\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":125484,"func":"static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)\n{\n\tstruct inode *inode = dentry->d_inode;\n\tstruct task_struct *task = get_proc_task(inode);\n\tint fd = proc_fd(inode);\n\tstruct files_struct *files;\n\tconst struct cred *cred;\n\n\tif (task) {\n\t\tfiles = get_files_struct(task);\n\t\tif (files) {\n\t\t\trcu_read_lock();\n\t\t\tif (fcheck_files(files, fd)) {\n\t\t\t\trcu_read_unlock();\n\t\t\t\tput_files_struct(files);\n\t\t\t\tif (task_dumpable(task)) {\n\t\t\t\t\trcu_read_lock();\n\t\t\t\t\tcred = __task_cred(task);\n\t\t\t\t\tinode->i_uid = cred->euid;\n\t\t\t\t\tinode->i_gid = cred->egid;\n\t\t\t\t\trcu_read_unlock();\n\t\t\t\t} else {\n\t\t\t\t\tinode->i_uid = 0;\n\t\t\t\t\tinode->i_gid = 0;\n\t\t\t\t}\n\t\t\t\tinode->i_mode &= ~(S_ISUID | S_ISGID);\n\t\t\t\tsecurity_task_to_inode(task, inode);\n\t\t\t\tput_task_struct(task);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\trcu_read_unlock();\n\t\t\tput_files_struct(files);\n\t\t}\n\t\tput_task_struct(task);\n\t}\n\td_drop(dentry);\n\treturn 0;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":37974,"func":"static BOOL freerdp_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)\n{\n\trfds[*rcount] = (void*)(long)(client->context->rdp->transport->TcpIn->sockfd);\n\t(*rcount)++;\n\n\treturn TRUE;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":28597,"func":"int min_heap_elem_greater ( struct event * a , struct event * b ) {\n return evutil_timercmp ( & a -> ev_timeout , & b -> ev_timeout , > ) ;\n }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":477623,"func":"static inline void ax25_hold_route(ax25_route *ax25_rt)\n{\n\trefcount_inc(&ax25_rt->refcount);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":189049,"func":"static void TestInterfaceOrLongMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  TestInterfaceOrLong result;\n  impl->testInterfaceOrLongMethod(result);\n  V8SetReturnValue(info, result);\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":41104,"func":"void ssl_handshake_free( ssl_handshake_params *handshake )\n{\n#if defined(POLARSSL_DHM_C)\n    dhm_free( &handshake->dhm_ctx );\n#endif\n    memset( handshake, 0, sizeof( ssl_handshake_params ) );\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":484827,"func":"ut64 MACH0_(get_baddr)(struct MACH0_(obj_t) * bin) {\n\tint i;\n\n\tif (bin->hdr.filetype != MH_EXECUTE && bin->hdr.filetype != MH_DYLINKER &&\n\t\tbin->hdr.filetype != MH_FILESET) {\n\t\treturn 0;\n\t}\n\tfor (i = 0; i < bin->nsegs; i++) {\n\t\tif (bin->segs[i].fileoff == 0 && bin->segs[i].filesize != 0) {\n\t\t\treturn bin->segs[i].vmaddr;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":309044,"func":"void TypingCommand::forwardDeleteKeyPressed(Document& document,\n                                            EditingState* editingState,\n                                            Options options,\n                                            TextGranularity granularity) {\n  if (granularity == CharacterGranularity) {\n    LocalFrame* frame = document.frame();\n    if (TypingCommand* lastTypingCommand =\n            lastTypingCommandIfStillOpenForTyping(frame)) {\n      updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand, frame);\n      lastTypingCommand->setShouldPreventSpellChecking(options &\n                                                       PreventSpellChecking);\n      lastTypingCommand->forwardDeleteKeyPressed(\n          granularity, options & KillRing, editingState);\n      return;\n    }\n  }\n\n  TypingCommand::create(document, ForwardDeleteKey, \"\", options, granularity)\n      ->apply();\n}\n","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":179128,"func":"void PrintPreviewMessageHandler::OnDidGetPreviewPageCount(\n    const PrintHostMsg_DidGetPreviewPageCount_Params& params) {\n  if (params.page_count <= 0) {\n    NOTREACHED();\n    return;\n  }\n\n  PrintPreviewUI* print_preview_ui = GetPrintPreviewUI();\n  if (!print_preview_ui)\n    return;\n\n  if (params.clear_preview_data)\n    print_preview_ui->ClearAllPreviewData();\n\n  print_preview_ui->OnDidGetPreviewPageCount(params);\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":366937,"func":"static int inode_has_perm(const struct cred *cred,\n\t\t\t  struct inode *inode,\n\t\t\t  u32 perms,\n\t\t\t  struct common_audit_data *adp)\n{\n\tstruct inode_security_struct *isec;\n\tstruct common_audit_data ad;\n\tu32 sid;\n\n\tvalidate_creds(cred);\n\n\tif (unlikely(IS_PRIVATE(inode)))\n\t\treturn 0;\n\n\tsid = cred_sid(cred);\n\tisec = inode->i_security;\n\n\tif (!adp) {\n\t\tadp = &ad;\n\t\tCOMMON_AUDIT_DATA_INIT(&ad, FS);\n\t\tad.u.fs.inode = inode;\n\t}\n\n\treturn avc_has_perm(sid, isec->sid, isec->sclass, perms, adp);\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":268526,"func":"int send_sig_info(int sig, struct siginfo *info, struct task_struct *p)\n{\n\t\/*\n\t * Make sure legacy kernel users don't send in bad values\n\t * (normal paths check this in check_kill_permission).\n\t *\/\n\tif (!valid_signal(sig))\n\t\treturn -EINVAL;\n\n\treturn do_send_sig_info(sig, info, p, false);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":483744,"func":"void fw_devlink_pause(void)\n{\n\tmutex_lock(&defer_fw_devlink_lock);\n\tdefer_fw_devlink_count++;\n\tmutex_unlock(&defer_fw_devlink_lock);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":206915,"func":"static char *exif_get_sectionlist(int sectionlist TSRMLS_DC)\n{\n\tint i, len, ml = 0;\n\tchar *sections;\n\n\tfor(i=0; i<SECTION_COUNT; i++) {\n\t\tml += strlen(exif_get_sectionname(i))+2;\n\t}\n\tsections = safe_emalloc(ml, 1, 1);\n\tsections[0] = '\\0';\n\tlen = 0;\n\tfor(i=0; i<SECTION_COUNT; i++) {\n\t\tif (sectionlist&(1<<i)) {\n\t\t\tsnprintf(sections+len, ml-len, \"%s, \", exif_get_sectionname(i));\n\t\t\tlen = strlen(sections);\n\t\t}\n\t}\n\tif (len>2)\n\t\tsections[len-2] = '\\0';\n\treturn sections;\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":512467,"func":"int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)\n{\n    *key = OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX + 1;\n    return 1;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":368297,"func":"router_get_by_descriptor_digest(const char *digest)\n{\n  tor_assert(digest);\n\n  if (!routerlist) return NULL;\n\n  return sdmap_get(routerlist->desc_digest_map, digest);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":348318,"func":"compute_tag(dns_name_t *name, dns_rdata_dnskey_t *dnskey, isc_mem_t *mctx,\n\t    dns_keytag_t *tag)\n{\n\tisc_result_t result;\n\tdns_rdata_t rdata = DNS_RDATA_INIT;\n\tunsigned char data[4096];\n\tisc_buffer_t buffer;\n\tdst_key_t *dstkey = NULL;\n\n\tisc_buffer_init(&buffer, data, sizeof(data));\n\tdns_rdata_fromstruct(&rdata, dnskey->common.rdclass,\n\t\t\t     dns_rdatatype_dnskey, dnskey, &buffer);\n\n\tresult = dns_dnssec_keyfromrdata(name, &rdata, mctx, &dstkey);\n\tif (result == ISC_R_SUCCESS)\n\t\t*tag = dst_key_id(dstkey);\n\tdst_key_free(&dstkey);\n\n\treturn (result);\n}","target":1,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":245979,"func":"NaClIPCAdapter::~NaClIPCAdapter() {\n  task_runner_->PostTask(FROM_HERE,\n      base::Bind(&DeleteChannel, io_thread_data_.channel_.release()));\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":291541,"func":"BOOLEAN SkipIP6ExtensionHeader(\n    IPv6Header *ip6Hdr,\n    ULONG dataLength,\n    PULONG ip6HdrLength,\n    PUCHAR nextHdr)\n{\n    IPv6ExtHeader* ip6ExtHdr;\n\n    if (*ip6HdrLength + sizeof(*ip6ExtHdr) > dataLength)\n        return FALSE;\n\n    ip6ExtHdr = (IPv6ExtHeader *)RtlOffsetToPointer(ip6Hdr, *ip6HdrLength);\n    *nextHdr = ip6ExtHdr->ip6ext_next_header;\n    *ip6HdrLength += (ip6ExtHdr->ip6ext_hdr_len + 1) * IP6_EXT_HDR_GRANULARITY;\n    return TRUE;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":240349,"func":"views::View* ShellSurface::GetContentsView() {\n  return this;\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":315310,"func":"void AppLaunchObserver::Observe(int type,\n                                const content::NotificationSource& source,\n                                const content::NotificationDetails& details) {\n  if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) {\n    new_window_id_ =\n        ExtensionTabUtil::GetWindowId(content::Source<Browser>(source).ptr());\n    return;\n  }\n\n  DCHECK_EQ(content::NOTIFICATION_LOAD_STOP, type);\n  SessionTabHelper* session_tab_helper = SessionTabHelper::FromWebContents(\n      content::Source<NavigationController>(source)->GetWebContents());\n  if ((launch_container_ == extension_misc::LAUNCH_TAB) ||\n      (session_tab_helper &&\n          (session_tab_helper->window_id().id() == new_window_id_))) {\n    if (automation_) {\n      AutomationJSONReply(automation_,\n                          reply_message_.release()).SendSuccess(NULL);\n    }\n    delete this;\n  }\n}\n","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":442987,"func":"static void update_cr0_intercept(struct vcpu_svm *svm)\n{\n\tulong gcr0 = svm->vcpu.arch.cr0;\n\tu64 *hcr0 = &svm->vmcb->save.cr0;\n\n\t*hcr0 = (*hcr0 & ~SVM_CR0_SELECTIVE_MASK)\n\t\t| (gcr0 & SVM_CR0_SELECTIVE_MASK);\n\n\tmark_dirty(svm->vmcb, VMCB_CR);\n\n\tif (gcr0 == *hcr0) {\n\t\tclr_cr_intercept(svm, INTERCEPT_CR0_READ);\n\t\tclr_cr_intercept(svm, INTERCEPT_CR0_WRITE);\n\t} else {\n\t\tset_cr_intercept(svm, INTERCEPT_CR0_READ);\n\t\tset_cr_intercept(svm, INTERCEPT_CR0_WRITE);\n\t}\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":21827,"func":"IN_PROC_BROWSER_TEST_F ( VirtualKeyboardBrowserTest , HideKeyboardKeyTest ) {\n RunTest ( base : : FilePath ( FILE_PATH_LITERAL ( \"hide_keyboard_key_test.js\" ) ) ) ;\n }","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":305897,"func":"void uwsgi_write_pidfile(char *pidfile_name) {\n\tuwsgi_log(\"writing pidfile to %s\\n\", pidfile_name);\n\tif (uwsgi_write_intfile(pidfile_name, (int) getpid())) {\n\t\tuwsgi_log(\"could not write pidfile.\\n\");\n\t}\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":491742,"func":"ecma_date_date_from_time (ecma_number_t time) \/**< time value *\/\n{\n  JERRY_ASSERT (!ecma_number_is_nan (time));\n\n  int32_t year = ecma_date_year_from_time (time);\n  int32_t day_within_year = ecma_date_day_from_time (time) - ecma_date_day_from_year (year);\n\n  JERRY_ASSERT (day_within_year >= 0 && day_within_year < ECMA_DATE_DAYS_IN_LEAP_YEAR);\n\n  int32_t in_leap_year = ecma_date_in_leap_year (year);\n\n  int32_t month = 11;\n\n  for (int i = 1; i < 12; i++)\n  {\n    if (day_within_year < first_day_in_month[in_leap_year][i])\n    {\n      month = i - 1;\n      break;\n    }\n  }\n\n  return day_within_year + 1 - first_day_in_month[in_leap_year][month];\n} \/* ecma_date_date_from_time *\/","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":158564,"func":"IRC_PROTOCOL_CALLBACK(008)\n{\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, argv[2], command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, address),\n        _(\"%sServer notice mask for %s%s%s: %s\"),\n        weechat_prefix (\"network\"),\n        irc_nick_color_for_msg (server, 1, NULL, argv[2]),\n        argv[2],\n        IRC_COLOR_RESET,\n        (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":476831,"func":"static int nft_dup_netdev_offload(struct nft_offload_ctx *ctx,\n\t\t\t\t  struct nft_flow_rule *flow,\n\t\t\t\t  const struct nft_expr *expr)\n{\n\tconst struct nft_dup_netdev *priv = nft_expr_priv(expr);\n\tint oif = ctx->regs[priv->sreg_dev].data.data[0];\n\n\treturn nft_fwd_dup_netdev_offload(ctx, flow, FLOW_ACTION_MIRRED, oif);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":338569,"func":"target_ulong helper_rdhwr_performance(CPUMIPSState *env)\n\n{\n\n    check_hwrena(env, 4);\n\n    return env->CP0_Performance0;\n\n}\n","target":1,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":310076,"func":"void FrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error)\n{\n    dispatchDidFailLoad(error);\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":165170,"func":"void RenderWidgetHostImpl::StopInputEventAckTimeout() {\n  if (input_event_ack_timeout_)\n    input_event_ack_timeout_->Stop();\n\n  if (!input_event_ack_start_time_.is_null()) {\n    base::TimeDelta elapsed = clock_->NowTicks() - input_event_ack_start_time_;\n    const base::TimeDelta kMinimumHangTimeToReport =\n        base::TimeDelta::FromSeconds(5);\n    if (elapsed >= kMinimumHangTimeToReport)\n      UMA_HISTOGRAM_LONG_TIMES(\"Renderer.Hung.Duration\", elapsed);\n\n    input_event_ack_start_time_ = TimeTicks();\n  }\n  RendererIsResponsive();\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":317000,"func":"ValidityMessage::ValidityMessage(const base::string16& text, bool sure)\n    : text(text), sure(sure) {}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":223513,"func":"find_clp_in_name_tree(struct xdr_netobj *name, struct rb_root *root)\n{\n\tint cmp;\n\tstruct rb_node *node = root->rb_node;\n\tstruct nfs4_client *clp;\n\n\twhile (node) {\n\t\tclp = rb_entry(node, struct nfs4_client, cl_namenode);\n\t\tcmp = compare_blob(&clp->cl_name, name);\n\t\tif (cmp > 0)\n\t\t\tnode = node->rb_left;\n\t\telse if (cmp < 0)\n\t\t\tnode = node->rb_right;\n\t\telse\n\t\t\treturn clp;\n\t}\n\treturn NULL;\n}\n","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":26445,"func":"static gboolean gst_asf_demux_check_buffer_is_header ( GstASFDemux * demux , GstBuffer * buf ) {\n AsfObject obj ;\n GstMapInfo map ;\n gboolean valid ;\n g_assert ( buf != NULL ) ;\n GST_LOG_OBJECT ( demux , \"Checking if buffer is a header\" ) ;\n gst_buffer_map ( buf , & map , GST_MAP_READ ) ;\n if ( map . size < ASF_OBJECT_HEADER_SIZE ) {\n gst_buffer_unmap ( buf , & map ) ;\n return FALSE ;\n }\n valid = asf_demux_peek_object ( demux , map . data , ASF_OBJECT_HEADER_SIZE , & obj , TRUE ) ;\n gst_buffer_unmap ( buf , & map ) ;\n if ( valid && obj . id == ASF_OBJ_HEADER ) {\n return TRUE ;\n }\n return FALSE ;\n }","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":489174,"func":"GF_Err btrt_box_dump(GF_Box *a, FILE * trace)\n{\n\tGF_BitRateBox *p = (GF_BitRateBox*)a;\n\tgf_isom_box_dump_start(a, \"BitRateBox\", trace);\n\tgf_fprintf(trace, \"BufferSizeDB=\\\"%d\\\" avgBitRate=\\\"%d\\\" maxBitRate=\\\"%d\\\">\\n\", p->bufferSizeDB, p->avgBitrate, p->maxBitrate);\n\tgf_isom_box_dump_done(\"BitRateBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":213123,"func":"void DownloadManagerImpl::InterceptNavigation(\n    std::unique_ptr<network::ResourceRequest> resource_request,\n    std::vector<GURL> url_chain,\n    scoped_refptr<network::ResourceResponse> response,\n    network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints,\n    net::CertStatus cert_status,\n    int frame_tree_node_id) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  if (!delegate_) {\n    DropDownload();\n    return;\n  }\n\n  const GURL& url = resource_request->url;\n  const std::string& method = resource_request->method;\n\n  ResourceRequestInfo::WebContentsGetter web_contents_getter =\n      base::BindRepeating(WebContents::FromFrameTreeNodeId, frame_tree_node_id);\n\n  base::OnceCallback<void(bool \/* download allowed *\/)>\n      on_download_checks_done = base::BindOnce(\n          &DownloadManagerImpl::InterceptNavigationOnChecksComplete,\n          weak_factory_.GetWeakPtr(), web_contents_getter,\n          std::move(resource_request), std::move(url_chain),\n          std::move(response), cert_status,\n          std::move(url_loader_client_endpoints));\n\n  delegate_->CheckDownloadAllowed(std::move(web_contents_getter), url, method,\n                                  std::move(on_download_checks_done));\n}\n","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":429378,"func":"    long writeFile(const DataBuf& buf, const std::wstring& wpath)\n    {\n        FileIo file(wpath);\n        if (file.open(\"wb\") != 0) {\n            throw WError(kerFileOpenFailed, wpath, \"wb\", strError().c_str());\n        }\n        return file.write(buf.pData_, buf.size_);\n    }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":387045,"func":"static void ssl_ticket_keys_free( ssl_ticket_keys *tkeys )\n{\n    aes_free( &tkeys->enc );\n    aes_free( &tkeys->dec );\n\n    polarssl_zeroize( tkeys, sizeof(ssl_ticket_keys) );\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":74567,"func":"void kvm_exit(void)\n{\n\tkvm_exit_debug();\n\tmisc_deregister(&kvm_dev);\n\tkmem_cache_destroy(kvm_vcpu_cache);\n\tkvm_async_pf_deinit();\n\tunregister_syscore_ops(&kvm_syscore_ops);\n\tunregister_reboot_notifier(&kvm_reboot_notifier);\n\tunregister_cpu_notifier(&kvm_cpu_notifier);\n\ton_each_cpu(hardware_disable_nolock, NULL, 1);\n\tkvm_arch_hardware_unsetup();\n\tkvm_arch_exit();\n\tkvm_irqfd_exit();\n\tfree_cpumask_var(cpus_hardware_enabled);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":93993,"func":"static int dictIndexOf(tr_variant const* dict, tr_quark const key)\n{\n    if (tr_variantIsDict(dict))\n    {\n        for (size_t i = 0; i < dict->val.l.count; ++i)\n        {\n            if (dict->val.l.vals[i].key == key)\n            {\n                return (int)i;\n            }\n        }\n    }\n\n    return -1;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":22958,"func":"static void vvalue_strbuf_append_r8 ( wmem_strbuf_t * strbuf , void * ptr ) {\n double r8 = * ( double * ) ptr ;\n wmem_strbuf_append_printf ( strbuf , \"%g\" , r8 ) ;\n }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":423403,"func":"file_regfree(file_regex_t *rx)\n{\n\tif (rx->rc == 0)\n\t\tregfree(&rx->rx);\n#ifdef USE_C_LOCALE\n\t(void)uselocale(rx->old_lc_ctype);\n\tfreelocale(rx->c_lc_ctype);\n#else\n\t(void)setlocale(LC_CTYPE, rx->old_lc_ctype);\n#endif\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":165758,"func":"NaClProcessHost::NaClProcessHost(const std::wstring& url)\n    : BrowserChildProcessHost(NACL_LOADER_PROCESS),\n      reply_msg_(NULL),\n      internal_(new NaClInternal()),\n      running_on_wow64_(false),\n      ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {\n  set_name(WideToUTF16Hack(url));\n#if defined(OS_WIN)\n  running_on_wow64_ = (base::win::OSInfo::GetInstance()->wow64_status() ==\n      base::win::OSInfo::WOW64_ENABLED);\n#endif\n}\n","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":474694,"func":"get_cached_region (GeglOperation *operation,\n                   const GeglRectangle *roi)\n{\n  return get_bounding_box (operation);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":277903,"func":"MagickExport const IndexPacket *GetVirtualIndexQueue(const Image *image)\n{\n  CacheInfo\n    *restrict cache_info;\n\n  const int\n    id = GetOpenMPThreadId();\n\n  assert(image != (const Image *) NULL);\n  assert(image->signature == MagickSignature);\n  assert(image->cache != (Cache) NULL);\n  cache_info=(CacheInfo *) image->cache;\n  assert(cache_info->signature == MagickSignature);\n  if (cache_info->methods.get_virtual_indexes_from_handler !=\n       (GetVirtualIndexesFromHandler) NULL)\n    return(cache_info->methods.get_virtual_indexes_from_handler(image));\n  assert(id < (int) cache_info->number_threads);\n  return(GetVirtualIndexesFromNexus(cache_info,cache_info->nexus_info[id]));\n}\n","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":392317,"func":"bool MillerRabin_Test::is_witness(const BigInt& a)\n   {\n   if(a < 2 || a >= n_minus_1)\n      throw Invalid_Argument(\"Bad size for nonce in Miller-Rabin test\");\n\n   BigInt y = pow_mod(a);\n   if(y == 1 || y == n_minus_1)\n      return false;\n\n   for(size_t i = 1; i != s; ++i)\n      {\n      y = reducer.square(y);\n\n      if(y == 1) \/\/ found a non-trivial square root\n         return true;\n\n      if(y == n_minus_1) \/\/ -1, trivial square root, so give up\n         return false;\n      }\n\n   \/\/ If we reached here then n fails the Fermat test\n   return true;\n   }","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":325045,"func":"static void vnc_dpy_setdata(DisplayChangeListener *dcl,\n\n                            DisplayState *ds)\n\n{\n\n    VncDisplay *vd = ds->opaque;\n\n\n\n    qemu_pixman_image_unref(vd->guest.fb);\n\n    vd->guest.fb = pixman_image_ref(ds->surface->image);\n\n    vd->guest.format = ds->surface->format;\n\n    vnc_dpy_update(dcl, ds, 0, 0, ds_get_width(ds), ds_get_height(ds));\n\n}\n","target":1,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":268508,"func":"TEST_F(SslContextImplTest, TestCipherSuites) {\n  const std::string yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites: \"-ALL:+[AES128-SHA|BOGUS1-SHA256]:BOGUS2-SHA:AES256-SHA\"\n  )EOF\";\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), tls_context);\n  ClientContextConfigImpl cfg(tls_context, factory_context_);\n  EXPECT_THROW_WITH_MESSAGE(\n      manager_.createSslClientContext(store_, cfg, nullptr), EnvoyException,\n      \"Failed to initialize cipher suites \"\n      \"-ALL:+[AES128-SHA|BOGUS1-SHA256]:BOGUS2-SHA:AES256-SHA. The following \"\n      \"ciphers were rejected when tried individually: BOGUS1-SHA256, BOGUS2-SHA\");\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":420001,"func":"purge_if_name_removed(const gs_memory_t *mem, cached_char * cc, void *vsave)\n{\n    return alloc_name_index_is_since_save(mem, cc->code, vsave);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":198438,"func":"void WebRuntimeFeatures::EnableWebGLImageChromium(bool enable) {\n  RuntimeEnabledFeatures::SetWebGLImageChromiumEnabled(enable);\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":101535,"func":"_movU(int n)\n{\n    int i, m = searchKeyNum();\n    if (Currentbuf->firstLine == NULL)\n\treturn;\n    for (i = 0; i < m; i++)\n\tcursorUp(Currentbuf, n);\n    displayBuffer(Currentbuf, B_NORMAL);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":384410,"func":"static void ide_resize_cb(void *opaque)\n{\n    IDEState *s = opaque;\n    uint64_t nb_sectors;\n\n    if (!s->identify_set) {\n        return;\n    }\n\n    blk_get_geometry(s->blk, &nb_sectors);\n    s->nb_sectors = nb_sectors;\n\n    \/* Update the identify data buffer. *\/\n    if (s->drive_kind == IDE_CFATA) {\n        ide_cfata_identify_size(s);\n    } else {\n        \/* IDE_CD uses a different set of callbacks entirely. *\/\n        assert(s->drive_kind != IDE_CD);\n        ide_identify_size(s);\n    }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":54330,"func":"static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(PyObject *__pyx_v_self) {\n  PyObject *__pyx_r = 0;\n  __Pyx_RefNannyDeclarations\n  __Pyx_RefNannySetupContext(\"__get__ (wrapper)\", 0);\n  __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));\n\n  \/* function exit code *\/\n  __Pyx_RefNannyFinishContext();\n  return __pyx_r;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":50636,"func":"static int rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)\n{\n\tstruct list_head *head = cpu_buffer->pages;\n\tstruct buffer_page *bpage, *tmp;\n\n\t\/* Reset the head page if it exists *\/\n\tif (cpu_buffer->head_page)\n\t\trb_set_head_page(cpu_buffer);\n\n\trb_head_page_deactivate(cpu_buffer);\n\n\tif (RB_WARN_ON(cpu_buffer, head->next->prev != head))\n\t\treturn -1;\n\tif (RB_WARN_ON(cpu_buffer, head->prev->next != head))\n\t\treturn -1;\n\n\tif (rb_check_list(cpu_buffer, head))\n\t\treturn -1;\n\n\tlist_for_each_entry_safe(bpage, tmp, head, list) {\n\t\tif (RB_WARN_ON(cpu_buffer,\n\t\t\t       bpage->list.next->prev != &bpage->list))\n\t\t\treturn -1;\n\t\tif (RB_WARN_ON(cpu_buffer,\n\t\t\t       bpage->list.prev->next != &bpage->list))\n\t\t\treturn -1;\n\t\tif (rb_check_list(cpu_buffer, &bpage->list))\n\t\t\treturn -1;\n\t}\n\n\trb_head_page_activate(cpu_buffer);\n\n\treturn 0;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":181227,"func":"  void AssertCBIsNull() {\n    ASSERT_TRUE(cb.is_null());\n    cb_already_run = true;\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":51415,"func":"static int lua_ap_getdir(lua_State *L)\n{\n    request_rec    *r;\n    apr_dir_t      *thedir;\n    apr_finfo_t    file_info;\n    apr_status_t   status;\n    const char     *directory;\n\n    luaL_checktype(L, 1, LUA_TUSERDATA);\n    luaL_checktype(L, 2, LUA_TSTRING);\n    r = ap_lua_check_request_rec(L, 1);\n    directory = lua_tostring(L, 2);\n    if (apr_dir_open(&thedir, directory, r->pool) == APR_SUCCESS) {\n        int i = 0;\n        lua_newtable(L);\n        do {\n            status = apr_dir_read(&file_info, APR_FINFO_NAME, thedir);\n            if (APR_STATUS_IS_INCOMPLETE(status)) {\n                continue; \/* ignore un-stat()able files *\/\n            }\n            else if (status != APR_SUCCESS) {\n                break;\n            }\n            lua_pushinteger(L, ++i);\n            lua_pushstring(L, file_info.name);\n            lua_settable(L, -3);\n\n        } while (1);\n        apr_dir_close(thedir);\n        return 1;\n    }\n    else {\n        return 0;\n    }\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":445612,"func":"OwnedImpl::OwnedImpl(absl::string_view data) : OwnedImpl() { add(data); }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":330801,"func":"void cpu_resume_from_signal(CPUState *env1, void *puc)\n\n{\n\n    env = env1;\n\n\n\n    \/* XXX: restore cpu registers saved in host registers *\/\n\n\n\n    env->exception_index = -1;\n\n    longjmp(env->jmp_env, 1);\n\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":278068,"func":"const Cluster* Segment::FindCluster(long long time_ns) const {\n if ((m_clusters == NULL) || (m_clusterCount <= 0))\n return &m_eos;\n\n {\n Cluster* const pCluster = m_clusters[0];\n    assert(pCluster);\n    assert(pCluster->m_index == 0);\n\n if (time_ns <= pCluster->GetTime())\n return pCluster;\n }\n\n\n long i = 0;\n long j = m_clusterCount;\n\n while (i < j) {\n\n const long k = i + (j - i) \/ 2;\n    assert(k < m_clusterCount);\n\n Cluster* const pCluster = m_clusters[k];\n    assert(pCluster);\n    assert(pCluster->m_index == k);\n\n const long long t = pCluster->GetTime();\n\n if (t <= time_ns)\n      i = k + 1;\n else\n      j = k;\n\n    assert(i <= j);\n }\n\n  assert(i == j);\n  assert(i > 0);\n  assert(i <= m_clusterCount);\n\n const long k = i - 1;\n\n Cluster* const pCluster = m_clusters[k];\n  assert(pCluster);\n  assert(pCluster->m_index == k);\n  assert(pCluster->GetTime() <= time_ns);\n\n return pCluster;\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":509699,"func":"static void test_mdev3885() \n{\n  int rc;\n  MYSQL *conn;\n\n  myheader(\"test_mdev3885\");\n  conn= client_connect(0, MYSQL_PROTOCOL_TCP, 0);\n  rc= mysql_kill(conn, mysql_thread_id(conn));\n  DIE_UNLESS(rc);\n  mysql_close(conn);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":72756,"func":"static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)\n{\n\tstruct page *page[1];\n\tunsigned long addr;\n\tint npages;\n\tgfn_t gfn = vmf->pgoff;\n\tstruct kvm *kvm = vma->vm_file->private_data;\n\n\taddr = gfn_to_hva(kvm, gfn);\n\tif (kvm_is_error_hva(addr))\n\t\treturn VM_FAULT_SIGBUS;\n\n\tnpages = get_user_pages(current, current->mm, addr, 1, 1, 0, page,\n\t\t\t\tNULL);\n\tif (unlikely(npages != 1))\n\t\treturn VM_FAULT_SIGBUS;\n\n\tvmf->page = page[0];\n\treturn 0;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":316041,"func":"static void pdf_run_TL(fz_context *ctx, pdf_processor *proc, float leading)\n{\n\tpdf_run_processor *pr = (pdf_run_processor *)proc;\n\tpdf_gstate *gstate = pr->gstate + pr->gtop;\n\tgstate->text.leading = leading;\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":149275,"func":"static int cuse_channel_open(struct inode *inode, struct file *file)\n{\n\tstruct fuse_dev *fud;\n\tstruct cuse_conn *cc;\n\tint rc;\n\n\t\/* set up cuse_conn *\/\n\tcc = kzalloc(sizeof(*cc), GFP_KERNEL);\n\tif (!cc)\n\t\treturn -ENOMEM;\n\n\tfuse_conn_init(&cc->fc);\n\n\tfud = fuse_dev_alloc(&cc->fc);\n\tif (!fud) {\n\t\tkfree(cc);\n\t\treturn -ENOMEM;\n\t}\n\n\tINIT_LIST_HEAD(&cc->list);\n\tcc->fc.release = cuse_fc_release;\n\n\tcc->fc.initialized = 1;\n\trc = cuse_send_init(cc);\n\tif (rc) {\n\t\tfuse_dev_free(fud);\n\t\treturn rc;\n\t}\n\tfile->private_data = fud;\n\n\treturn 0;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":107562,"func":"cdataSectionProcessor(XML_Parser parser, const char *start, const char *end,\n                      const char **endPtr) {\n  enum XML_Error result\n      = doCdataSection(parser, parser->m_encoding, &start, end, endPtr,\n                       (XML_Bool)! parser->m_parsingStatus.finalBuffer);\n  if (result != XML_ERROR_NONE)\n    return result;\n  if (start) {\n    if (parser->m_parentParser) { \/* we are parsing an external entity *\/\n      parser->m_processor = externalEntityContentProcessor;\n      return externalEntityContentProcessor(parser, start, end, endPtr);\n    } else {\n      parser->m_processor = contentProcessor;\n      return contentProcessor(parser, start, end, endPtr);\n    }\n  }\n  return result;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":445055,"func":"    AdminFilterChain() {} \/\/ NOLINT(modernize-use-equals-default)","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":286896,"func":"error_t lpc546xxEthUpdateMacConfig(NetInterface *interface)\n{\n   uint32_t config;\n\n   \/\/Read current MAC configuration\n   config = ENET->MAC_CONFIG;\n\n   \/\/10BASE-T or 100BASE-TX operation mode?\n   if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)\n   {\n      config |= ENET_MAC_CONFIG_FES_MASK;\n   }\n   else\n   {\n      config &= ~ENET_MAC_CONFIG_FES_MASK;\n   }\n\n   \/\/Half-duplex or full-duplex mode?\n   if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)\n   {\n      config |= ENET_MAC_CONFIG_DM_MASK;\n   }\n   else\n   {\n      config &= ~ENET_MAC_CONFIG_DM_MASK;\n   }\n\n   \/\/Update MAC configuration register\n   ENET->MAC_CONFIG = config;\n\n   \/\/Successful processing\n   return NO_ERROR;\n}","target":1,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":406610,"func":"  Item_cache(enum_field_types field_type_arg):\n    example(0), used_table_map(0), cached_field(0),\n    cached_field_type(field_type_arg),\n    value_cached(0)\n  {\n    fixed= 1;\n    null_value= 1;\n  }","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":137238,"func":"free_blocks(sblock_T *bl)\n{\n    sblock_T\t*next;\n\n    while (bl != NULL)\n    {\n\tnext = bl->sb_next;\n\tvim_free(bl);\n\tbl = next;\n    }\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":111041,"func":"inline bool StringData::empty() const { return size() == 0; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":516154,"func":"int SSL_add_store_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,\n                                         const char *store)\n{\n    int (*oldcmp) (const X509_NAME *const *a, const X509_NAME *const *b)\n        = sk_X509_NAME_set_cmp_func(stack, xname_sk_cmp);\n    int ret = add_uris_recursive(stack, store, 1);\n\n    (void)sk_X509_NAME_set_cmp_func(stack, oldcmp);\n    return ret;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":137303,"func":"lengthOfLines(TScreen *screen, int firstRow, int lastRow)\n{\n    unsigned length = 0;\n    int n;\n\n    for (n = firstRow; n <= lastRow; ++n) {\n\tLineData *ld = GET_LINEDATA(screen, n);\n\tint value = LastTextCol(screen, ld, n);\n\tif (value >= 0)\n\t    length += (unsigned) (value + 1);\n    }\n    return length;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":364352,"func":"static void log_option(const char *pfx, const uint8_t *opt)\n{\n\tif (dhcp_verbose >= 2) {\n\t\tchar buf[256 * 2 + 2];\n\t\t*bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\\0';\n\t\tbb_info_msg(\"%s: 0x%02x %s\", pfx, opt[OPT_CODE], buf);\n\t}\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":257795,"func":"size_t WriteOffset ( ArchiveHandle * AH , pgoff_t o , int wasSet ) {\n int off ;\n ( * AH -> WriteBytePtr ) ( AH , wasSet ) ;\n for ( off = 0 ;\n off < sizeof ( pgoff_t ) ;\n off ++ ) {\n ( * AH -> WriteBytePtr ) ( AH , o & 0xFF ) ;\n o >>= 8 ;\n }\n return sizeof ( pgoff_t ) + 1 ;\n }","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":65841,"func":"bool bounded_iostream::chkerr() {\n    return err != Sirikata::JpegError::nil();\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":445112,"func":"TEST_P(ProxyProtocolTest, NotEnoughFields) {\n  connect(false);\n  write(\"PROXY TCP6 1:2:3::4 5:6::7:8 1234\\r\\nmore data\");\n  expectProxyProtoError();\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":143633,"func":"static int fwnet_change_mtu(struct net_device *net, int new_mtu)\n{\n\tif (new_mtu < 68)\n\t\treturn -EINVAL;\n\n\tnet->mtu = new_mtu;\n\treturn 0;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":428564,"func":"g_file_set_attribute_byte_string  (GFile                *file,\n                                   const gchar          *attribute,\n                                   const gchar          *value,\n                                   GFileQueryInfoFlags   flags,\n                                   GCancellable         *cancellable,\n                                   GError              **error)\n{\n  return g_file_set_attribute (file, attribute,\n                               G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, (gpointer)value,\n                               flags, cancellable, error);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":64590,"func":"f_ch_read(typval_T *argvars, typval_T *rettv)\n{\n    common_channel_read(argvars, rettv, FALSE, FALSE);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":320799,"func":"static inline void t_gen_mov_preg_TN(DisasContext *dc, int r, TCGv tn)\n\n{\n\n    if (r < 0 || r > 15) {\n\n        fprintf(stderr, \"wrong register write $p%d\\n\", r);\n\n    }\n\n    if (r == PR_BZ || r == PR_WZ || r == PR_DZ) {\n\n        return;\n\n    } else if (r == PR_SRS) {\n\n        tcg_gen_andi_tl(cpu_PR[r], tn, 3);\n\n    } else {\n\n        if (r == PR_PID) {\n\n            gen_helper_tlb_flush_pid(cpu_env, tn);\n\n        }\n\n        if (dc->tb_flags & S_FLAG && r == PR_SPC) {\n\n            gen_helper_spc_write(cpu_env, tn);\n\n        } else if (r == PR_CCS) {\n\n            dc->cpustate_changed = 1;\n\n        }\n\n        tcg_gen_mov_tl(cpu_PR[r], tn);\n\n    }\n\n}\n","target":1,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":426097,"func":"qb_ipcs_connection_get_buffer_size(qb_ipcs_connection_t *c)\n{\n\tif (c == NULL) {\n\t\treturn -EINVAL;\n\t}\n\n\t\/* request, response, and event shoud all have the same\n\t * buffer size allocated. It doesn't matter which we return\n\t * here. *\/\n\treturn c->response.max_msg_size;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":82070,"func":"R_API RBinObject *r_bin_file_object_get_cur(RBinFile *binfile) {\n\treturn binfile? binfile->o: NULL;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":349664,"func":"TEST_P(Http2CodecImplTest, HeaderNameWithUnderscoreAreRejectedByDefault) {\n  headers_with_underscores_action_ = envoy::config::core::v3::HttpProtocolOptions::REJECT_REQUEST;\n  initialize();\n\n  TestRequestHeaderMapImpl request_headers;\n  HttpTestUtility::addDefaultHeaders(request_headers);\n  request_headers.addCopy(\"bad_header\", \"something\");\n  EXPECT_CALL(server_stream_callbacks_, onResetStream(_, _)).Times(1);\n  request_encoder_->encodeHeaders(request_headers, false);\n  EXPECT_EQ(1, stats_store_.counter(\"http2.requests_rejected_with_underscores_in_headers\").value());\n}","target":1,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":118410,"func":"static int __init ipc_init(void)\n{\n\tsem_init();\n\tmsg_init();\n\tshm_init();\n\tregister_hotmemory_notifier(&ipc_memory_nb);\n\tregister_ipcns_notifier(&init_ipc_ns);\n\treturn 0;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":185385,"func":"void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders(\n    const net::HttpResponseHeaders* headers) {\n  DCHECK(request_);\n  DCHECK(headers);\n  net::HttpRequestHeaders extra_headers;\n\n  const std::string last_modified = \"Last-Modified\";\n  std::string last_modified_value;\n  headers->EnumerateHeader(NULL, last_modified, &last_modified_value);\n  if (!last_modified_value.empty()) {\n    extra_headers.SetHeader(net::HttpRequestHeaders::kIfModifiedSince,\n                            last_modified_value);\n  }\n\n  const std::string etag = \"ETag\";\n  std::string etag_value;\n  headers->EnumerateHeader(NULL, etag, &etag_value);\n  if (!etag_value.empty()) {\n    extra_headers.SetHeader(net::HttpRequestHeaders::kIfNoneMatch,\n                            etag_value);\n  }\n  if (!extra_headers.IsEmpty())\n    request_->SetExtraRequestHeaders(extra_headers);\n}\n","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":64972,"func":"  RegexMatcherImpl(const RequirementRule& rule)\n      : BaseMatcherImpl(rule), regex_str_(rule.match().safe_regex().regex()),\n        path_matcher_(Matchers::PathMatcher::createSafeRegex(rule.match().safe_regex())) {\n    ASSERT(rule.match().path_specifier_case() ==\n           envoy::config::route::v3::RouteMatch::PathSpecifierCase::kSafeRegex);\n  }","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":221222,"func":"void DevToolsWindow::OnPageCloseCanceled(content::WebContents* contents) {\n  DevToolsWindow *window =\n      DevToolsWindow::GetInstanceForInspectedRenderViewHost(\n          contents->GetRenderViewHost());\n  if (!window)\n    return;\n  window->intercepted_page_beforeunload_ = false;\n  DevToolsWindow::OnPageCloseCanceled(window->web_contents());\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":259785,"func":"string convertHexToDec(const string &hex_str) {\n    mpz_t dec;\n    mpz_init(dec);\n\n    string ret = \"\";\n\n    try {\n        if (mpz_set_str(dec, hex_str.c_str(), 16) == -1) {\n            mpz_clear(dec);\n            return ret;\n        }\n\n        SAFE_CHAR_BUF(arr,mpz_sizeinbase(dec, 10) + 2);\n        mpz_get_str(arr, 10, dec);\n        ret = arr;\n    } catch (exception &e) {\n        mpz_clear(dec);\n        throw SGXException(INCORRECT_STRING_CONVERSION, e.what());\n    } catch (...) {\n        mpz_clear(dec);\n        throw SGXException(UNKNOWN_ERROR, \"\");\n    }\n\n    return ret;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":359219,"func":"static inline int dev_iwstats(struct net_device *dev, struct ifreq *ifr)\n{\n\t\/* Get stats from the driver *\/\n\tstruct iw_statistics *stats;\n\n\tstats = get_wireless_stats(dev);\n\tif (stats != (struct iw_statistics *) NULL) {\n\t\tstruct iwreq *\twrq = (struct iwreq *)ifr;\n\n\t\t\/* Copy statistics to the user buffer *\/\n\t\tif(copy_to_user(wrq->u.data.pointer, stats,\n\t\t\t\tsizeof(struct iw_statistics)))\n\t\t\treturn -EFAULT;\n\n\t\t\/* Check if we need to clear the update flag *\/\n\t\tif(wrq->u.data.flags != 0)\n\t\t\tstats->qual.updated = 0;\n\t\treturn 0;\n\t} else\n\t\treturn -EOPNOTSUPP;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":453939,"func":"TEST(ParseExpression, ShouldRejectExpressionIfItsNotTheOnlyField) {\n    ASSERT_THROWS(parseExpression(BSON(\"$and\" << BSONArray() << \"a\" << BSON(\"$or\" << BSONArray()))),\n                  AssertionException);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":178493,"func":"void PPB_URLLoader_Impl::SetDefersLoading(bool defers_loading) {\n  if (loader_.get()) {\n    loader_->setDefersLoading(defers_loading);\n    is_asynchronous_load_suspended_ = defers_loading;\n  }\n\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":431197,"func":"    bool isAuthEnabled() const override {\n        return false;\n    }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":109478,"func":"void jas_matrix_divpow2(jas_matrix_t *matrix, int n)\n{\n\tjas_matind_t i;\n\tjas_matind_t j;\n\tjas_seqent_t *rowstart;\n\tjas_matind_t rowstep;\n\tjas_seqent_t *data;\n\n\tif (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) {\n\t\tassert(matrix->rows_);\n\t\trowstep = jas_matrix_rowstep(matrix);\n\t\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t\t  rowstart += rowstep) {\n\t\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t\t  ++data) {\n\t\t\t\t*data = (*data >= 0) ? ((*data) >> n) :\n\t\t\t\t  (-((-(*data)) >> n));\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":511089,"func":"rl_bind_keyseq_if_unbound (keyseq, default_func)\n     const char *keyseq;\n     rl_command_func_t *default_func;\n{\n  return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":24366,"func":"static guint8 dissect_zcl_ota_field_ctrl_field ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {\n guint8 field ;\n static const int * field_ctrl [ ] = {\n & hf_zbee_zcl_ota_field_ctrl_hw_ver_present , & hf_zbee_zcl_ota_field_ctrl_reserved , NULL }\n ;\n field = tvb_get_guint8 ( tvb , * offset ) ;\n proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_ota_field_ctrl , ett_zbee_zcl_ota_field_ctrl , field_ctrl , ENC_BIG_ENDIAN ) ;\n * offset += 1 ;\n return field ;\n }","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":486447,"func":"ossl_cipher_is_authenticated(VALUE self)\n{\n    EVP_CIPHER_CTX *ctx;\n    int nid;\n\n    GetCipher(self, ctx);\n    nid = EVP_CIPHER_CTX_nid(ctx);\n\n    if (ossl_is_gcm(nid)) {\n\treturn Qtrue;\n    } else {\n\treturn Qfalse;\n    }\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":61994,"func":"static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)\n{\n\tint err;\n\tstruct sock_diag_req *req = nlmsg_data(nlh);\n\tconst struct sock_diag_handler *hndl;\n\n\tif (nlmsg_len(nlh) < sizeof(*req))\n\t\treturn -EINVAL;\n\n\tif (req->sdiag_family >= AF_MAX)\n\t\treturn -EINVAL;\n\n\thndl = sock_diag_lock_handler(req->sdiag_family);\n\tif (hndl == NULL)\n\t\terr = -ENOENT;\n\telse\n\t\terr = hndl->dump(skb, nlh);\n\tsock_diag_unlock_handler(hndl);\n\n\treturn err;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":59856,"func":"static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,\n\tconst struct kvm_one_reg *reg, void __user *uaddr)\n{\n\t__u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];\n\n\tif (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":83249,"func":"}\n\nstatic inline bool f2fs_hw_support_discard(struct f2fs_sb_info *sbi)\n{\n\tint i;\n\n\tif (!f2fs_is_multi_device(sbi))\n\t\treturn f2fs_bdev_support_discard(sbi->sb->s_bdev);\n\n\tfor (i = 0; i < sbi->s_ndevs; i++)\n\t\tif (f2fs_bdev_support_discard(FDEV(i).bdev))\n\t\t\treturn true;","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":374908,"func":"_outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)\n{\n\tWRITE_NODE_TYPE(\"BITMAPHEAPSCAN\");\n\n\t_outScanInfo(str, (const Scan *) node);\n\n\tWRITE_NODE_FIELD(bitmapqualorig);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":29534,"func":"static inline int check_for_slice ( AVSContext * h ) {\n GetBitContext * gb = & h -> gb ;\n int align ;\n if ( h -> mbx ) return 0 ;\n align = ( - get_bits_count ( gb ) ) & 7 ;\n if ( ! align && ( show_bits ( gb , 8 ) == 0x80 ) ) align = 8 ;\n if ( ( show_bits_long ( gb , 24 + align ) & 0xFFFFFF ) == 0x000001 ) {\n skip_bits_long ( gb , 24 + align ) ;\n h -> stc = get_bits ( gb , 8 ) ;\n if ( h -> stc >= h -> mb_height ) return 0 ;\n decode_slice_header ( h , gb ) ;\n return 1 ;\n }\n return 0 ;\n }","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":375187,"func":"_equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)\n{\n\tCOMPARE_SCALAR_FIELD(rtekind);\n\tCOMPARE_SCALAR_FIELD(relid);\n\tCOMPARE_SCALAR_FIELD(relkind);\n\tCOMPARE_NODE_FIELD(subquery);\n\tCOMPARE_SCALAR_FIELD(security_barrier);\n\tCOMPARE_SCALAR_FIELD(jointype);\n\tCOMPARE_NODE_FIELD(joinaliasvars);\n\tCOMPARE_NODE_FIELD(functions);\n\tCOMPARE_SCALAR_FIELD(funcordinality);\n\tCOMPARE_NODE_FIELD(values_lists);\n\tCOMPARE_NODE_FIELD(values_collations);\n\tCOMPARE_STRING_FIELD(ctename);\n\tCOMPARE_SCALAR_FIELD(ctelevelsup);\n\tCOMPARE_SCALAR_FIELD(self_reference);\n\tCOMPARE_NODE_FIELD(ctecoltypes);\n\tCOMPARE_NODE_FIELD(ctecoltypmods);\n\tCOMPARE_NODE_FIELD(ctecolcollations);\n\tCOMPARE_NODE_FIELD(alias);\n\tCOMPARE_NODE_FIELD(eref);\n\tCOMPARE_SCALAR_FIELD(lateral);\n\tCOMPARE_SCALAR_FIELD(inh);\n\tCOMPARE_SCALAR_FIELD(inFromCl);\n\tCOMPARE_SCALAR_FIELD(requiredPerms);\n\tCOMPARE_SCALAR_FIELD(checkAsUser);\n\tCOMPARE_BITMAPSET_FIELD(selectedCols);\n\tCOMPARE_BITMAPSET_FIELD(modifiedCols);\n\n\treturn true;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":467561,"func":"EXPORTED char *dumpentryatt(const struct entryattlist *l)\n{\n    struct buf buf = BUF_INITIALIZER;\n\n    const struct entryattlist *ee;\n    buf_printf(&buf, \"(\");\n    const char *sp = \"\";\n    const struct attvaluelist *av;\n    for (ee = l ; ee ; ee = ee->next) {\n        buf_printf(&buf, \"%s%s (\", sp, ee->entry);\n        const char *insp = \"\";\n        for (av = ee->attvalues ; av ; av = av->next) {\n            buf_printf(&buf, \"%s%s %s\", insp, av->attrib, buf_cstring(&av->value));\n            insp = \" \";\n        }\n        buf_printf(&buf, \")\");\n        sp = \" \";\n    }\n    buf_printf(&buf, \")\");\n\n    char *res = buf_release(&buf);\n    buf_free(&buf);\n\n    return res;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":100206,"func":"njs_vm_retval(njs_vm_t *vm)\n{\n    return &vm->retval;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":335751,"func":"static void mkv_free(MatroskaMuxContext *mkv) {\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    if (mkv->main_seekhead) {\n\n        av_freep(&mkv->main_seekhead->entries);\n\n        av_freep(&mkv->main_seekhead);\n\n\n    if (mkv->cues) {\n\n        av_freep(&mkv->cues->entries);\n\n        av_freep(&mkv->cues);\n\n\n    if (mkv->attachments) {\n\n        av_freep(&mkv->attachments->entries);\n\n        av_freep(&mkv->attachments);\n\n\n    av_freep(&mkv->tracks);\n\n    av_freep(&mkv->stream_durations);\n\n    av_freep(&mkv->stream_duration_offsets);\n","target":1,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":47872,"func":"    **\/\n    CImg<T>& assign(const unsigned int size_x, const unsigned int size_y,\n                    const unsigned int size_z, const unsigned int size_c,\n                    const double value0, const double value1, ...) {\n      assign(size_x,size_y,size_z,size_c);\n      _CImg_stdarg(*this,value0,value1,(size_t)size_x*size_y*size_z*size_c,double);\n      return *this;","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":131850,"func":"MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)\n{\n  return(_imgRef->options()->quantizeInfo());\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":268684,"func":"void dhcpServerParseInform(DhcpServerContext *context,\n   const DhcpMessage *message, size_t length)\n{\n   \/\/Make sure the client IP address is valid\n   if(message->ciaddr != IPV4_UNSPECIFIED_ADDR)\n   {\n      \/\/Servers receiving a DHCPINFORM message construct a DHCPACK message\n      \/\/with any local configuration parameters appropriate for the client\n      dhcpServerSendReply(context, DHCP_MESSAGE_TYPE_ACK,\n         IPV4_UNSPECIFIED_ADDR, message, length);\n   }\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":93808,"func":"cifs_writedata_alloc(unsigned int nr_pages)\n{\n\tstruct cifs_writedata *wdata;\n\n\t\/* this would overflow *\/\n\tif (nr_pages == 0) {\n\t\tcERROR(1, \"%s: called with nr_pages == 0!\", __func__);\n\t\treturn NULL;\n\t}\n\n\t\/* writedata + number of page pointers *\/\n\twdata = kzalloc(sizeof(*wdata) +\n\t\t\tsizeof(struct page *) * (nr_pages - 1), GFP_NOFS);\n\tif (wdata != NULL) {\n\t\tINIT_WORK(&wdata->work, cifs_writev_complete);\n\t\tkref_init(&wdata->refcount);\n\t}\n\treturn wdata;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":265877,"func":"void CollectGraphs(EagerContext* ctx) {\n  mutex_lock ml(*ctx->MetadataMu());\n\n  GraphCollector* collector = ctx->GetGraphCollector();\n  mutex_lock mll(collector->mu);\n\n  \/\/ Adding to partition graphs for backward compatibility.\n  for (const auto& graph : collector->partitioned_graphs) {\n    *ctx->RunMetadataProto()->add_partition_graphs() = graph;\n  }\n\n  if (collector->dirty) {\n    auto* function_graphs = ctx->RunMetadataProto()->add_function_graphs();\n    *function_graphs->mutable_post_optimization_graph() =\n        collector->optimized_graph;\n    *function_graphs->mutable_pre_optimization_graph() = collector->raw_graph;\n    for (const auto& graph : collector->partitioned_graphs) {\n      *function_graphs->add_partition_graphs() = graph;\n    }\n  }\n\n  collector->ClearGraphs();\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":455106,"func":"TEST_F(QueryPlannerTest, ShardFilterBasicCovered) {\n    params.options = QueryPlannerParams::INCLUDE_SHARD_FILTER;\n    params.shardKey = BSON(\"a\" << 1);\n    addIndex(BSON(\"a\" << 1));\n\n    runQuery(fromjson(\"{a: 1}\"));\n\n    assertNumSolutions(1U);\n    assertSolutionExists(\n        \"{fetch: {node: \"\n        \"{sharding_filter: {node: \"\n        \"{ixscan: {pattern: {a: 1}}}}}}}\");\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":200697,"func":"static void LodePNGText_cleanup(LodePNGInfo* info)\n{\n  size_t i;\n  for(i = 0; i < info->text_num; i++)\n  {\n    string_cleanup(&info->text_keys[i]);\n    string_cleanup(&info->text_strings[i]);\n  }\n  free(info->text_keys);\n  free(info->text_strings);\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":332114,"func":"void qemu_vfree(void *ptr)\n\n{\n\n    \/* may be useful some day, but currently we do not need to free *\/\n\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":352064,"func":"TPMI_SM4_KEY_BITS_Unmarshal(TPMI_SM4_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_KEY_BITS_Unmarshal(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case 128:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}","target":1,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":297898,"func":"ASC_acceptContextsWithPreferredTransferSyntaxes(\n    T_ASC_Parameters * params,\n    const char* abstractSyntaxes[], int abstractSyntaxCount,\n    const char* transferSyntaxes[], int transferSyntaxCount,\n    T_ASC_SC_ROLE acceptedRole)\n{\n    int i;\n    OFCondition cond = EC_Normal;\n    \/*\n    ** Accept in the order \"least wanted\" to \"most wanted\" transfer\n    ** syntax.  Accepting a transfer syntax will override previously\n    ** accepted transfer syntaxes.\n    *\/\n    for (i=transferSyntaxCount-1; i>=0; i--)\n    {\n        cond = ASC_acceptContextsWithTransferSyntax(\n            params, transferSyntaxes[i],\n            abstractSyntaxCount, abstractSyntaxes, acceptedRole);\n        if (cond.bad()) return cond;\n    }\n    return cond;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":466253,"func":"TEST_F(HttpConnectionManagerImplTest, DateHeaderNotPresent) {\n  setup(false, \"\");\n  setUpEncoderAndDecoder(false, false);\n  sendRequestHeadersAndData();\n  const auto* modified_headers = sendResponseHeaders(\n      ResponseHeaderMapPtr{new TestResponseHeaderMapImpl{{\":status\", \"200\"}, {\"server\", \"foo\"}}});\n  ASSERT_TRUE(modified_headers);\n  EXPECT_TRUE(modified_headers->Date());\n  doRemoteClose();\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":393958,"func":"void show_state_filter(unsigned long state_filter)\n{\n\tstruct task_struct *g, *p;\n\n#if BITS_PER_LONG == 32\n\tprintk(KERN_INFO\n\t\t\"  task                PC stack   pid father\\n\");\n#else\n\tprintk(KERN_INFO\n\t\t\"  task                        PC stack   pid father\\n\");\n#endif\n\trcu_read_lock();\n\tfor_each_process_thread(g, p) {\n\t\t\/*\n\t\t * reset the NMI-timeout, listing all files on a slow\n\t\t * console might take a lot of time:\n\t\t *\/\n\t\ttouch_nmi_watchdog();\n\t\tif (!state_filter || (p->state & state_filter))\n\t\t\tsched_show_task(p);\n\t}\n\n\ttouch_all_softlockup_watchdogs();\n\n#ifdef CONFIG_SCHED_DEBUG\n\tsysrq_sched_debug_show();\n#endif\n\trcu_read_unlock();\n\t\/*\n\t * Only show locks if all tasks are dumped:\n\t *\/\n\tif (!state_filter)\n\t\tdebug_show_all_locks();\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":63899,"func":"Wasm::Wasm(absl::string_view vm, absl::string_view vm_id, absl::string_view vm_configuration,\n           PluginSharedPtr plugin, Stats::ScopeSharedPtr scope,\n           Upstream::ClusterManager& cluster_manager, Event::Dispatcher& dispatcher)\n    : vm_id_(std::string(vm_id)), wasm_vm_(Common::Wasm::createWasmVm(vm)), plugin_(plugin),\n      scope_(scope), cluster_manager_(cluster_manager), dispatcher_(dispatcher),\n      time_source_(dispatcher.timeSource()), vm_configuration_(vm_configuration),\n      stat_name_set_(scope_->symbolTable().makeSet(\"Wasm\").release()) {}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":415535,"func":"imapx_untagged_flags (CamelIMAPXServer *is,\n                      GInputStream *input_stream,\n                      GCancellable *cancellable,\n                      GError **error)\n{\n\tguint32 flags = 0;\n\tgboolean success;\n\n\tg_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);\n\n\tsuccess = imapx_parse_flags (\n\t\tCAMEL_IMAPX_INPUT_STREAM (input_stream),\n\t\t&flags, NULL, cancellable, error);\n\n\tc (is->priv->tagprefix, \"flags: %08x\\n\", flags);\n\n\treturn success;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":247429,"func":"void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() {\n  legacy_render_widget_host_HWND_ = NULL;\n  legacy_window_destroyed_ = true;\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":234660,"func":"bool HTMLFormControlElement::isAutofocusable() const\n{\n    return fastHasAttribute(autofocusAttr) && supportsAutofocus();\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":107284,"func":"static char *write_metadata (WavpackMetadata *wpmd, char *outdata)\n{\n    unsigned char id = wpmd->id, wordlen [3];\n\n    wordlen [0] = (wpmd->byte_length + 1) >> 1;\n    wordlen [1] = (wpmd->byte_length + 1) >> 9;\n    wordlen [2] = (wpmd->byte_length + 1) >> 17;\n\n    if (wpmd->byte_length & 1)\n        id |= ID_ODD_SIZE;\n\n    if (wordlen [1] || wordlen [2])\n        id |= ID_LARGE;\n\n    *outdata++ = id;\n    *outdata++ = wordlen [0];\n\n    if (id & ID_LARGE) {\n        *outdata++ = wordlen [1];\n        *outdata++ = wordlen [2];\n    }\n\n    if (wpmd->data && wpmd->byte_length) {\n        memcpy (outdata, wpmd->data, wpmd->byte_length);\n        outdata += wpmd->byte_length;\n\n        if (wpmd->byte_length & 1)\n            *outdata++ = 0;\n    }\n\n    return outdata;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":19254,"func":"IN_PROC_BROWSER_TEST_F ( BluetoothChooserBrowserTest , InvokeDialog_ConnectedBubble ) {\n set_status ( FakeBluetoothChooserController : : BluetoothStatus : : IDLE ) ;\n AddConnectedDevice ( ) ;\n RunDialog ( ) ;\n }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":341195,"func":"void ff_vp3_idct_c(DCTELEM *block\/* align 16*\/){\n\n    idct(NULL, 0, block, 0);\n\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":334700,"func":"static bool memory_region_access_valid(MemoryRegion *mr,\n\n                                       target_phys_addr_t addr,\n\n                                       unsigned size)\n\n{\n\n    if (!mr->ops->valid.unaligned && (addr & (size - 1))) {\n\n        return false;\n\n    }\n\n\n\n    \/* Treat zero as compatibility all valid *\/\n\n    if (!mr->ops->valid.max_access_size) {\n\n        return true;\n\n    }\n\n\n\n    if (size > mr->ops->valid.max_access_size\n\n        || size < mr->ops->valid.min_access_size) {\n\n        return false;\n\n    }\n\n    return true;\n\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":299258,"func":"int mg_base64_final(char *to, int n) {\n  int saved = n;\n  \/\/ printf(\"---[%.*s]\\n\", n, to);\n  if (n & 3) n = mg_base64_update(0, to, n);\n  if ((saved & 3) == 2) n--;\n  \/\/ printf(\"    %d[%.*s]\\n\", n, n, to);\n  while (n & 3) to[n++] = '=';\n  to[n] = '\\0';\n  return n;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":423033,"func":"*__dma_request_slave_channel_compat(const dma_cap_mask_t *mask,\n\t\t\t\t  dma_filter_fn fn, void *fn_param,\n\t\t\t\t  struct device *dev, char *name)\n{\n\tstruct dma_chan *chan;\n\n\tchan = dma_request_slave_channel(dev, name);\n\tif (chan)\n\t\treturn chan;\n\n\treturn __dma_request_channel(mask, fn, fn_param);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":471294,"func":"void killRDBChild(void) {\n    kill(server.rdb_child_pid,SIGUSR1);\n    rdbRemoveTempFile(server.rdb_child_pid, 0);\n    closeChildInfoPipe();\n    updateDictResizePolicy();\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":473917,"func":"hash_value_compare(const void *a, const void *b)\n{\n    uint64_t ia = (uint64_t)a;\n    uint64_t ib = (uint64_t)b;\n    return ia == ib;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":258048,"func":"int get_ber_length ( tvbuff_t * tvb , int offset , guint32 * length , gboolean * ind ) {\n return try_get_ber_length ( tvb , offset , length , ind , 1 ) ;\n }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":298765,"func":"      static cimg_uint64 min() { return 0; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":95553,"func":"virtio_set_modern_pio_bar(struct virtio_base *base, int barnum)\n{\n\tint rc;\n\tstruct virtio_pci_notify_cap notify_pio = {\n\t\t.cap.cap_vndr = PCIY_VENDOR,\n\t\t.cap.cap_next = 0,\n\t\t.cap.cap_len = sizeof(notify_pio),\n\t\t.cap.cfg_type = VIRTIO_PCI_CAP_NOTIFY_CFG,\n\t\t.cap.bar = barnum,\n\t\t.cap.offset = 0,\n\t\t.cap.length = 4,\n\t\t.notify_off_multiplier = 0,\n\t};\n\n\t\/* notification capability *\/\n\trc = pci_emul_add_capability(base->dev, (u_char *)¬ify_pio,\n\t\tsizeof(notify_pio));\n\tif (rc != 0) {\n\t\tpr_err(\"pci emulation add notification capability for virtio modern PIO BAR failed\\n\");\n\t\treturn -1;\n\t}\n\n\t\/* allocate and register modern pio bar *\/\n\trc = pci_emul_alloc_bar(base->dev, barnum, PCIBAR_IO, 4);\n\tif (rc != 0) {\n\t\tpr_err(\"allocate and register modern pio bar failed\\n\");\n\t\treturn -1;\n\t}\n\n\tbase->modern_pio_bar_idx = barnum;\n\treturn 0;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":258392,"func":"char * xmlrpc_time2date ( char * buf , time_t t ) {\n char timebuf [ XMLRPC_BUFSIZE ] ;\n struct tm * tm ;\n * buf = '\\0' ;\n tm = localtime ( & t ) ;\n strftime ( timebuf , XMLRPC_BUFSIZE - 1 , \"%Y%m%dT%I:%M:%S\" , tm ) ;\n snprintf ( buf , XMLRPC_BUFSIZE , \"<dateTime.iso8601>%s<\/dateTime.iso8601>\" , timebuf ) ;\n return buf ;\n }","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":176665,"func":"LoginBigUserView* LockContentsView::TestApi::primary_big_view() const {\n  return view_->primary_big_view_;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":113961,"func":"nv_exmode(cmdarg_T *cap)\n{\n    \/*\n     * Ignore 'Q' in Visual mode, just give a beep.\n     *\/\n    if (VIsual_active)\n\tvim_beep(BO_EX);\n    else if (!checkclearop(cap->oap))\n\tdo_exmode(FALSE);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":259608,"func":"static unsigned long weighted_cpuload(const int cpu)\n{\n\treturn cpu_rq(cpu)->load.weight;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":30381,"func":"static inline uint8_t NVRAM_get_byte ( m48t59_t * nvram , uint32_t addr ) {\n m48t59_set_addr ( nvram , addr ) ;\n return m48t59_read ( nvram ) ;\n }","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":119399,"func":"void *fxArrayBuffer(txMachine* the, txSlot* slot, void* data, txInteger byteLength, txInteger maxByteLength)\n{\n\ttxSlot* instance;\n\ttxSlot* arrayBuffer;\n\ttxSlot* bufferInfo;\n\tif (byteLength < 0)\n\t\tmxRangeError(\"invalid byteLength %ld\", byteLength);\n\tmxPush(mxArrayBufferPrototype);\n\tinstance = fxNewArrayBufferInstance(the);\n\tarrayBuffer = instance->next;\n\tarrayBuffer->value.arrayBuffer.address = fxNewChunk(the, byteLength);\n\tbufferInfo = arrayBuffer->next;\n\tbufferInfo->value.bufferInfo.length = byteLength;\n\tbufferInfo->value.bufferInfo.maxLength = maxByteLength;\n\tif (data != NULL)\n\t\tc_memcpy(arrayBuffer->value.arrayBuffer.address, data, byteLength);\n\telse\n\t\tc_memset(arrayBuffer->value.arrayBuffer.address, 0, byteLength);\n\tmxPullSlot(slot);\n\treturn arrayBuffer->value.arrayBuffer.address;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":296404,"func":"GF_Err sdp_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 length;\n\tGF_SDPBox *ptr = (GF_SDPBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\n\tlength = (u32) (ptr->size);\n\n\tif (length >= (u32)0xFFFFFFFF) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid length %lu in sdp box\\n\", length));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\t\/\/sdp text has no delimiter !!!\n\tptr->sdpText = (char*)gf_malloc(sizeof(char) * (length+1));\n\tif (!ptr->sdpText) return GF_OUT_OF_MEM;\n\n\tgf_bs_read_data(bs, ptr->sdpText, length);\n\tptr->sdpText[length] = 0;\n\treturn GF_OK;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":271091,"func":"SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,\n\t\tstruct timespec __user *, interval)\n{\n\tstruct task_struct *p;\n\tunsigned int time_slice;\n\tunsigned long flags;\n\tstruct rq *rq;\n\tint retval;\n\tstruct timespec t;\n\n\tif (pid < 0)\n\t\treturn -EINVAL;\n\n\tretval = -ESRCH;\n\trcu_read_lock();\n\tp = find_process_by_pid(pid);\n\tif (!p)\n\t\tgoto out_unlock;\n\n\tretval = security_task_getscheduler(p);\n\tif (retval)\n\t\tgoto out_unlock;\n\n\trq = task_rq_lock(p, &flags);\n\ttime_slice = p->sched_class->get_rr_interval(rq, p);\n\ttask_rq_unlock(rq, &flags);\n\n\trcu_read_unlock();\n\tjiffies_to_timespec(time_slice, &t);\n\tretval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0;\n\treturn retval;\n\nout_unlock:\n\trcu_read_unlock();\n\treturn retval;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":295390,"func":"void traf_del(GF_Box *s)\n{\n\tGF_TrackFragmentBox *ptr = (GF_TrackFragmentBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->tfhd) gf_isom_box_del((GF_Box *) ptr->tfhd);\n\tif (ptr->sdtp) gf_isom_box_del((GF_Box *) ptr->sdtp);\n\tif (ptr->sub_samples) gf_isom_box_array_del(ptr->sub_samples);\n\tif (ptr->tfdt) gf_isom_box_del((GF_Box *) ptr->tfdt);\n\tif (ptr->sample_encryption) gf_isom_box_del((GF_Box *) ptr->sample_encryption);\n\tgf_isom_box_array_del(ptr->TrackRuns);\n\tif (ptr->sampleGroups) gf_isom_box_array_del(ptr->sampleGroups);\n\tif (ptr->sampleGroupsDescription) gf_isom_box_array_del(ptr->sampleGroupsDescription);\n\tif (ptr->sai_sizes) gf_isom_box_array_del(ptr->sai_sizes);\n\tif (ptr->sai_offsets) gf_isom_box_array_del(ptr->sai_offsets);\n\tgf_free(ptr);\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":142105,"func":"qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,\n                            virDomainObjPtr vm)\n{\n    qemuDomainObjPrivatePtr priv = vm->privateData;\n\n    if (priv->fakeReboot) {\n        g_autofree char *name = g_strdup_printf(\"reboot-%s\", vm->def->name);\n        virThread th;\n\n        qemuDomainSetFakeReboot(driver, vm, false);\n        virObjectRef(vm);\n        if (virThreadCreateFull(&th,\n                                false,\n                                qemuProcessFakeReboot,\n                                name,\n                                false,\n                                vm) < 0) {\n            VIR_ERROR(_(\"Failed to create reboot thread, killing domain\"));\n            ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));\n            priv->pausedShutdown = false;\n            virObjectUnref(vm);\n        }\n    } else {\n        ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));\n    }\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":253755,"func":"BluetoothDeviceChooserController::BluetoothDeviceChooserController(\n    WebBluetoothServiceImpl* web_bluetooth_service,\n    RenderFrameHost* render_frame_host,\n    device::BluetoothAdapter* adapter)\n    : adapter_(adapter),\n      web_bluetooth_service_(web_bluetooth_service),\n      render_frame_host_(render_frame_host),\n      web_contents_(WebContents::FromRenderFrameHost(render_frame_host_)),\n      discovery_session_timer_(\n          FROM_HERE,\n          base::TimeDelta::FromSeconds(scan_duration_),\n          base::Bind(&BluetoothDeviceChooserController::StopDeviceDiscovery,\n                     base::Unretained(this))) {\n  CHECK(adapter_);\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":304274,"func":"utfc_ptr2len(char_u *p)\n{\n    int\t\tlen;\n    int\t\tb0 = *p;\n#ifdef FEAT_ARABIC\n    int\t\tprevlen;\n#endif\n\n    if (b0 == NUL)\n\treturn 0;\n    if (b0 < 0x80 && p[1] < 0x80)\t\/\/ be quick for ASCII\n\treturn 1;\n\n    \/\/ Skip over first UTF-8 char, stopping at a NUL byte.\n    len = utf_ptr2len(p);\n\n    \/\/ Check for illegal byte.\n    if (len == 1 && b0 >= 0x80)\n\treturn 1;\n\n    \/*\n     * Check for composing characters.  We can handle only the first six, but\n     * skip all of them (otherwise the cursor would get stuck).\n     *\/\n#ifdef FEAT_ARABIC\n    prevlen = 0;\n#endif\n    for (;;)\n    {\n\tif (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len))\n\t    return len;\n\n\t\/\/ Skip over composing char\n#ifdef FEAT_ARABIC\n\tprevlen = len;\n#endif\n\tlen += utf_ptr2len(p + len);\n    }\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":33489,"func":"void test_checkout_nasty__dot_dotgit_tree(void)\n{\n\ttest_checkout_fails(\"refs\/heads\/dot_dotgit_tree\", \".git\/foobar\");\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":67643,"func":"Type makeFrozenStructALike() {\n  Type structALike;\n  structALike.fieldA_ref() = 2000;\n  return structALike;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":228114,"func":"static void NPN_UnscheduleTimer(NPP instance, uint32_t timerID)\n{\n    notImplemented();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":75810,"func":"void CServer::ConchainPlayerSlotsUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)\n{\n\tpfnCallback(pResult, pCallbackUserData);\n\tCServer *pSelf = (CServer *)pUserData;\n\tif(pResult->NumArguments())\n\t{\n\t\tif(pSelf->Config()->m_SvMaxClients < pSelf->Config()->m_SvPlayerSlots)\n\t\t\tpSelf->Config()->m_SvPlayerSlots = pSelf->Config()->m_SvMaxClients;\n\t}\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":209481,"func":"void FileAPIMessageFilter::OnAppendSharedMemory(\n    const GURL& url, base::SharedMemoryHandle handle, size_t buffer_size) {\n  DCHECK(base::SharedMemory::IsHandleValid(handle));\n  if (!buffer_size) {\n    BadMessageReceived();\n    return;\n  }\n#if defined(OS_WIN)\n  base::SharedMemory shared_memory(handle, true, peer_handle());\n#else\n  base::SharedMemory shared_memory(handle, true);\n#endif\n  if (!shared_memory.Map(buffer_size)) {\n    OnRemoveBlob(url);\n    return;\n  }\n\n  BlobData::Item item;\n  item.SetToSharedBytes(static_cast<char*>(shared_memory.memory()),\n                        buffer_size);\n  blob_storage_context_->controller()->AppendBlobDataItem(url, item);\n}\n","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":222548,"func":"static int __apic_accept_irq(struct kvm_vcpu *vcpu, uint64_t vector)\n{\n\tstruct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);\n\n\tif (!test_and_set_bit(vector, &vpd->irr[0])) {\n\t\tvcpu->arch.irq_new_pending = 1;\n\t\tkvm_vcpu_kick(vcpu);\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":37267,"func":"  static int64_t Unknown() { return -1; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":495274,"func":"lexer_string_is_use_strict (parser_context_t *context_p) \/**< context *\/\n{\n  JERRY_ASSERT (context_p->token.type == LEXER_LITERAL && context_p->token.lit_location.type == LEXER_STRING_LITERAL);\n\n  return (context_p->token.lit_location.length == 10\n          && !(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)\n          && memcmp (context_p->token.lit_location.char_p, \"use strict\", 10) == 0);\n} \/* lexer_string_is_use_strict *\/","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":274271,"func":"lookupGid(const string &groupName) {\n\tstruct group *groupEntry;\n\n\tgroupEntry = getgrnam(groupName.c_str());\n\tif (groupEntry == NULL) {\n\t\tif (looksLikePositiveNumber(groupName)) {\n\t\t\treturn atoi(groupName);\n\t\t} else {\n\t\t\treturn (gid_t) -1;\n\t\t}\n\t} else {\n\t\treturn groupEntry->gr_gid;\n\t}\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":16549,"func":"IN_PROC_BROWSER_TEST_F ( ExtensionMessageBubbleViewBrowserTest , ExtensionBubbleAnchoredToAppMenu ) {\n TestBubbleAnchoredToAppMenu ( ) ;\n }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":507115,"func":"int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,\n\t     unsigned int *siglen, DSA *dsa)\n\t{\n\tDSA_SIG *s;\n#ifdef OPENSSL_FIPS\n\tif(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))\n\t\t{\n\t\tDSAerr(DSA_F_DSA_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE);\n\t\treturn 0;\n\t\t}\n#endif\n\tRAND_seed(dgst, dlen);\n\ts=DSA_do_sign(dgst,dlen,dsa);\n\tif (s == NULL)\n\t\t{\n\t\t*siglen=0;\n\t\treturn(0);\n\t\t}\n\t*siglen=i2d_DSA_SIG(s,&sig);\n\tDSA_SIG_free(s);\n\treturn(1);\n\t}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":318573,"func":"int bdrv_pwrite(BlockDriverState *bs, int64_t offset,\n\n                const void *buf, int bytes)\n\n{\n\n    QEMUIOVector qiov;\n\n    struct iovec iov = {\n\n        .iov_base   = (void *) buf,\n\n        .iov_len    = bytes,\n\n    };\n\n\n\n    if (bytes < 0) {\n\n        return -EINVAL;\n\n    }\n\n\n\n    qemu_iovec_init_external(&qiov, &iov, 1);\n\n    return bdrv_pwritev(bs, offset, &qiov);\n\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":83322,"func":"php_apache_sapi_flush(void *server_context)\n{\n\tphp_struct *ctx;\n\trequest_rec *r;\n\tTSRMLS_FETCH();\n\n\tctx = server_context;\n\n\t\/* If we haven't registered a server_context yet,\n\t * then don't bother flushing. *\/\n\tif (!server_context) {\n\t\treturn;\n\t}\n\n\tr = ctx->r;\n\n\tsapi_send_headers(TSRMLS_C);\n\n\tr->status = SG(sapi_headers).http_response_code;\n\tSG(headers_sent) = 1;\n\n\tif (ap_rflush(r) < 0 || r->connection->aborted) {\n\t\tphp_handle_aborted_connection();\n\t}\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":192017,"func":"static void clear_leases(const uint8_t *chaddr, uint32_t yiaddr)\n{\n\tunsigned i;\n\n\tfor (i = 0; i < server_config.max_leases; i++) {\n\t\tif ((chaddr && memcmp(g_leases[i].lease_mac, chaddr, 6) == 0)\n\t\t || (yiaddr && g_leases[i].lease_nip == yiaddr)\n\t\t) {\n\t\t\tmemset(&g_leases[i], 0, sizeof(g_leases[i]));\n\t\t}\n\t}\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":217094,"func":"void OneClickSigninHelper::LogConfirmHistogramValue(int action) {\n  UMA_HISTOGRAM_ENUMERATION(\"Signin.OneClickConfirmation\", action,\n                            one_click_signin::HISTOGRAM_CONFIRM_MAX);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":127897,"func":"irc_server_get_prefix_modes (struct t_irc_server *server)\n{\n    return (server && server->prefix_modes) ?\n        server->prefix_modes : irc_server_prefix_modes_default;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":336163,"func":"static bool blit_region_is_unsafe(struct CirrusVGAState *s,\n\n                                  int32_t pitch, int32_t addr)\n\n{\n\n    if (pitch < 0) {\n\n        int64_t min = addr\n\n            + ((int64_t)s->cirrus_blt_height-1) * pitch;\n\n        int32_t max = addr\n\n            + s->cirrus_blt_width;\n\n        if (min < 0 || max >= s->vga.vram_size) {\n\n            return true;\n\n        }\n\n    } else {\n\n        int64_t max = addr\n\n            + ((int64_t)s->cirrus_blt_height-1) * pitch\n\n            + s->cirrus_blt_width;\n\n        if (max >= s->vga.vram_size) {\n\n            return true;\n\n        }\n\n    }\n\n    return false;\n\n}\n","target":1,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":228411,"func":"ewk_frame_scroll_set(Evas_Object* ewkFrame, int x, int y)\n{\n    EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, false);\n    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, false);\n    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame->view(), false);\n    smartData->frame->view()->setScrollPosition(WebCore::IntPoint(x, y));\n    return true;\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":467205,"func":"std::string RGWFormPost::get_current_content_type() const\n{\n  try {\n    const auto& field = current_data_part->fields.at(\"Content-Type\");\n    return field.val;\n  } catch (std::out_of_range&) {\n    \/* NOP *\/;\n  }\n\n  return std::string();\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":320698,"func":"static void handle_arg_log_filename(const char *arg)\n\n{\n\n    qemu_set_log_filename(arg);\n\n}\n","target":1,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":309933,"func":"  RelayTruncatePlatformFile(base::PlatformFile file,\n                            int64 length,\n                            base::FileUtilProxy::StatusCallback* callback)\n      : RelayWithStatusCallback(callback),\n        file_(file),\n        length_(length) {\n  }\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":242962,"func":"void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) {\n  DCHECK(page_number_ == PageNumber::npos());\n  owner_ = new_owner;\n }\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":301281,"func":"static void muscle_load_single_acl(sc_file_t* file, int operation, unsigned short acl)\n{\n\tint key;\n\t\/* Everybody by default.... *\/\n\tsc_file_add_acl_entry(file, operation, SC_AC_NONE, 0);\n\tif(acl == 0xFFFF) {\n\t\tsc_file_add_acl_entry(file, operation, SC_AC_NEVER, 0);\n\t\treturn;\n\t}\n\tfor(key = 0; key < 16; key++) {\n\t\tif(acl >> key & 1) {\n\t\t\tsc_file_add_acl_entry(file, operation, SC_AC_CHV, key);\n\t\t}\n\t}\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":60832,"func":"CModule::EModRet CModule::OnPrivNotice(CNick& Nick, CString& sMessage) {\n    return CONTINUE;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":171177,"func":"bool ParamTraits<base::TimeDelta>::Read(const Message* m,\n                                        PickleIterator* iter,\n                                        param_type* r) {\n  int64 value;\n  bool ret = ParamTraits<int64>::Read(m, iter, &value);\n  if (ret)\n    *r = base::TimeDelta::FromInternalValue(value);\n\n  return ret;\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":520034,"func":"  wait_for_commit *suspend_subsequent_commits() {\n    wait_for_commit *suspended= wait_for_commit_ptr;\n    wait_for_commit_ptr= NULL;\n    return suspended;\n  }","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":413223,"func":"int ldb_sqlite3_init(const char *version)\n{\n\tLDB_MODULE_CHECK_VERSION(version);\n\treturn ldb_register_backend(\"sqlite3\", lsqlite3_connect, false);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":225607,"func":"void AXLayoutObject::detach() {\n  AXNodeObject::detach();\n\n  detachRemoteSVGRoot();\n\n#if DCHECK_IS_ON()\n  if (m_layoutObject)\n    m_layoutObject->setHasAXObject(false);\n#endif\n  m_layoutObject = 0;\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":261662,"func":"TEST_P(Http2CodecImplTest, SmallMetadataVecTest) {\n  allow_metadata_ = true;\n  initialize();\n\n  \/\/ Generates a valid stream_id by sending a request header.\n  TestHeaderMapImpl request_headers;\n  HttpTestUtility::addDefaultHeaders(request_headers);\n  EXPECT_CALL(request_decoder_, decodeHeaders_(_, true));\n  request_encoder_->encodeHeaders(request_headers, true);\n\n  MetadataMapVector metadata_map_vector;\n  const int size = 10;\n  for (int i = 0; i < size; i++) {\n    MetadataMap metadata_map = {\n        {\"header_key1\", \"header_value1\"},\n        {\"header_key2\", \"header_value2\"},\n        {\"header_key3\", \"header_value3\"},\n        {\"header_key4\", \"header_value4\"},\n    };\n    MetadataMapPtr metadata_map_ptr = std::make_unique<MetadataMap>(metadata_map);\n    metadata_map_vector.push_back(std::move(metadata_map_ptr));\n  }\n\n  EXPECT_CALL(request_decoder_, decodeMetadata_(_)).Times(size);\n  request_encoder_->encodeMetadata(metadata_map_vector);\n\n  EXPECT_CALL(response_decoder_, decodeMetadata_(_)).Times(size);\n  response_encoder_->encodeMetadata(metadata_map_vector);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":128066,"func":"mono_thread_get_undeniable_exception (void)\n{\n\tMonoInternalThread *thread = mono_thread_internal_current ();\n\n\tif (thread && thread->abort_exc && !is_running_protected_wrapper ()) {\n\t\t\/*\n\t\t * FIXME: Clear the abort exception and return an AppDomainUnloaded \n\t\t * exception if the thread no longer references a dying appdomain.\n\t\t *\/\n\t\tthread->abort_exc->trace_ips = NULL;\n\t\tthread->abort_exc->stack_trace = NULL;\n\t\treturn thread->abort_exc;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":68199,"func":"struct regmap *regulator_get_regmap(struct regulator *regulator)\n{\n\tstruct regmap *map = regulator->rdev->regmap;\n\n\treturn map ? map : ERR_PTR(-EOPNOTSUPP);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":79873,"func":"static int em_imul_3op(struct x86_emulate_ctxt *ctxt)\n{\n\tctxt->dst.val = ctxt->src2.val;\n\treturn fastop(ctxt, em_imul);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":78862,"func":"R_API int r_anal_var_count_all(RAnalFunction *fcn) {\n\tr_return_val_if_fail (fcn, 0);\n\treturn r_pvector_len (&fcn->vars);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":91402,"func":"    \/\/! Load gzipped image file, using external tool 'gunzip' \\newinstance.\n    static CImg<T> get_load_gzip_external(const char *const filename) {\n      return CImg<T>().load_gzip_external(filename);","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":256738,"func":"static inline void set_num_731 ( unsigned char * p , uint32_t value ) {\n archive_le32enc ( p , value ) ;\n }","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":523096,"func":"  const char *end() const { return str + length + is_quoted(); }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":350869,"func":"static void set_error_response(h2_stream *stream, int http_status)\n{\n    if (!h2_stream_is_ready(stream)) {\n        stream->rtmp->http_status = http_status;\n    }\n}","target":1,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":189943,"func":"void BookmarksAPI::Shutdown() {\n  ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":474378,"func":"*LUKS2_keyslot_handler(struct crypt_device *cd, int keyslot)\n{\n\tstruct luks2_hdr *hdr;\n\tjson_object *jobj1, *jobj2;\n\n\tif (keyslot < 0)\n\t\treturn NULL;\n\n\tif (!(hdr = crypt_get_hdr(cd, CRYPT_LUKS2)))\n\t\treturn NULL;\n\n\tif (!(jobj1 = LUKS2_get_keyslot_jobj(hdr, keyslot)))\n\t\treturn NULL;\n\n\tif (!json_object_object_get_ex(jobj1, \"type\", &jobj2))\n\t\treturn NULL;\n\n\treturn LUKS2_keyslot_handler_type(cd, json_object_get_string(jobj2));\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":518530,"func":"  Field_longlong(uint32 len_arg,bool maybe_null_arg,\n\t\t const LEX_CSTRING *field_name_arg,\n                 bool unsigned_arg)\n    :Field_int((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) \"\": 0,0,\n                NONE, field_name_arg, 0, unsigned_arg)\n    {}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":470510,"func":"read_name_from_file (struct cpio_file_stat *file_hdr, int fd, uintmax_t len)\n{\n  if (len == 0)\n    {\n      error (0, 0, _(\"malformed header: file name of zero length\"));\n    }\n  else\n    {\n      cpio_realloc_c_name (file_hdr, len);\n      tape_buffered_read (file_hdr->c_name, fd, len);\n      if (file_hdr->c_name[len-1] != 0)\n\t{\n\t  error (0, 0, _(\"malformed header: file name is not nul-terminated\"));\n\t  \/* Skip this file *\/\n\t  len = 0;\n\t}\n    }\n  file_hdr->c_namesize = len;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":1116,"func":"IN_PROC_BROWSER_TEST_F ( HttpsEngagementPageLoadMetricsBrowserTest , ClosedWhileHidden_Http ) {\n StartHttpServer ( ) ;\n base : : TimeDelta upper_bound = NavigateInForegroundAndCloseInBackgroundWithTiming ( http_test_server_ -> GetURL ( \"\/simple.html\" ) ) ;\n histogram_tester_ . ExpectTotalCount ( internal : : kHttpEngagementHistogram , 1 ) ;\n histogram_tester_ . ExpectTotalCount ( internal : : kHttpsEngagementHistogram , 0 ) ;\n int32_t bucket_min = histogram_tester_ . GetAllSamples ( internal : : kHttpEngagementHistogram ) [ 0 ] . min ;\n EXPECT_GE ( upper_bound . InMilliseconds ( ) , bucket_min ) ;\n EXPECT_LT ( 0 , bucket_min ) ;\n }","target":1,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":373917,"func":"        bool moreJSObjs() const {\n            return nextjsobj != 0;\n        }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":514327,"func":"static void test_message_parser_trailing_dashes(void)\n{\nstatic const char input_msg[] =\n\"Content-Type: multipart\/mixed; boundary=\\\"a--\\\"\\n\"\n\"\\n\"\n\"--a--\\n\"\n\"Content-Type: multipart\/mixed; boundary=\\\"a----\\\"\\n\"\n\"\\n\"\n\"--a----\\n\"\n\"Content-Type: text\/plain\\n\"\n\"\\n\"\n\"body\\n\"\n\"--a------\\n\"\n\"Content-Type: text\/html\\n\"\n\"\\n\"\n\"body2\\n\"\n\"--a----\";\n\tstruct istream *input;\n\tstruct message_part *parts;\n\tpool_t pool;\n\n\ttest_begin(\"message parser trailing dashes\");\n\tpool = pool_alloconly_create(\"message parser\", 10240);\n\tinput = test_istream_create(input_msg);\n\n\ttest_assert(message_parse_stream(pool, input, &set_empty, FALSE, &parts) < 0);\n\n\ttest_assert(parts->children_count == 2);\n\ttest_assert(parts->children->next == NULL);\n\ttest_assert(parts->children->children_count == 1);\n\ttest_assert(parts->children->children->next == NULL);\n\ttest_assert(parts->children->children->children_count == 0);\n\n\ttest_parsed_parts(input, parts);\n\ti_stream_unref(&input);\n\tpool_unref(&pool);\n\ttest_end();\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":280526,"func":"static int _hid_get_string_descriptor(struct hid_device_priv* dev, int _index,\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":169911,"func":"void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  for (std::vector<int>::iterator it = aec_dump_consumers_.begin();\n       it != aec_dump_consumers_.end(); ++it) {\n    if (*it == id) {\n      aec_dump_consumers_.erase(it);\n      break;\n    }\n  }\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":263650,"func":"static int acm_wb_alloc(struct acm *acm)\n{\n\tint i, wbn;\n\tstruct acm_wb *wb;\n\n\twbn = 0;\n\ti = 0;\n\tfor (;;) {\n\t\twb = &acm->wb[wbn];\n\t\tif (!wb->use) {\n\t\t\twb->use = 1;\n\t\t\treturn wbn;\n\t\t}\n\t\twbn = (wbn + 1) % ACM_NW;\n\t\tif (++i >= ACM_NW)\n\t\t\treturn -1;\n\t}\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":513853,"func":"static UINT cliprdr_server_monitor_ready(CliprdrServerContext* context,\n                                         const CLIPRDR_MONITOR_READY* monitorReady)\n{\n\twStream* s;\n\tCliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;\n\n\tif (monitorReady->msgType != CB_MONITOR_READY)\n\t\tWLog_WARN(TAG, \"[%s] called with invalid type %08\" PRIx32, __FUNCTION__,\n\t\t          monitorReady->msgType);\n\n\ts = cliprdr_packet_new(CB_MONITOR_READY, monitorReady->msgFlags, monitorReady->dataLen);\n\n\tif (!s)\n\t{\n\t\tWLog_ERR(TAG, \"cliprdr_packet_new failed!\");\n\t\treturn ERROR_INTERNAL_ERROR;\n\t}\n\n\tWLog_DBG(TAG, \"ServerMonitorReady\");\n\treturn cliprdr_server_packet_send(cliprdr, s);\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":129110,"func":"cockpit_web_response_get_state (CockpitWebResponse *self)\n{\n  g_return_val_if_fail (COCKPIT_IS_WEB_RESPONSE (self), 0);\n\n  if (self->done)\n    return COCKPIT_WEB_RESPONSE_SENT;\n  else if (self->complete)\n    return COCKPIT_WEB_RESPONSE_COMPLETE;\n  else if (self->count == 0)\n    return COCKPIT_WEB_RESPONSE_READY;\n  else\n    return COCKPIT_WEB_RESPONSE_QUEUING;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":343065,"func":"void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,\n\n                        void *opaque)\n\n{\n\n    VMStateField *field = vmsd->fields;\n\n\n\n    if (vmsd->pre_save) {\n\n        vmsd->pre_save(opaque);\n\n\n    while (field->name) {\n\n        if (!field->field_exists ||\n\n            field->field_exists(opaque, vmsd->version_id)) {\n\n            void *base_addr = vmstate_base_addr(opaque, field);\n\n            int i, n_elems = vmstate_n_elems(opaque, field);\n\n            int size = vmstate_size(opaque, field);\n\n\n\n            for (i = 0; i < n_elems; i++) {\n\n                void *addr = base_addr + size * i;\n\n\n\n                if (field->flags & VMS_ARRAY_OF_POINTER) {\n\n                    addr = *(void **)addr;\n\n\n                if (field->flags & VMS_STRUCT) {\n\n                    vmstate_save_state(f, field->vmsd, addr);\n\n\n                    field->info->put(f, addr, size);\n\n\n\n\n\n\n\n\n\n\n        field++;\n\n\n    vmstate_subsection_save(f, vmsd, opaque);\n","target":1,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":99555,"func":"static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *_std)\n{\n\tv4l2_std_id req_std = 0, supported_std = 0;\n\tconst v4l2_std_id all_std = V4L2_STD_ALL, no_std = 0;\n\n\tif (_std) {\n\t\treq_std = *_std;\n\t\t*_std = all_std;\n\t}\n\n\t\/* we support everything in V4L2_STD_ALL, but not more... *\/\n\tsupported_std = (all_std & req_std);\n\tif (no_std == supported_std)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":471081,"func":"cleanhostname(char *host)\n{\n\tif (*host == '[' && host[strlen(host) - 1] == ']') {\n\t\thost[strlen(host) - 1] = '\\0';\n\t\treturn (host + 1);\n\t} else\n\t\treturn host;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":131258,"func":"void sqlite3VdbeRewind(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n  assert( p!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT || p->magic==VDBE_MAGIC_RESET );\n\n  \/* There should be at least one opcode.\n  *\/\n  assert( p->nOp>0 );\n\n  \/* Set the magic to VDBE_MAGIC_RUN sooner rather than later. *\/\n  p->magic = VDBE_MAGIC_RUN;\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<p->nMem; i++){\n    assert( p->aMem[i].db==p->db );\n  }\n#endif\n  p->pc = -1;\n  p->rc = SQLITE_OK;\n  p->errorAction = OE_Abort;\n  p->nChange = 0;\n  p->cacheCtr = 1;\n  p->minWriteFileFormat = 255;\n  p->iStatement = 0;\n  p->nFkConstraint = 0;\n#ifdef VDBE_PROFILE\n  for(i=0; i<p->nOp; i++){\n    p->aOp[i].cnt = 0;\n    p->aOp[i].cycles = 0;\n  }\n#endif\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":70301,"func":"static void vfio_bar_quirk_teardown(VFIOPCIDevice *vdev, int nr)\n\n{\n\n    VFIOBAR *bar = &vdev->bars[nr];\n\n\n\n    while (!QLIST_EMPTY(&bar->quirks)) {\n\n        VFIOQuirk *quirk = QLIST_FIRST(&bar->quirks);\n\n        memory_region_del_subregion(&bar->region.mem, &quirk->mem);\n\n        object_unparent(OBJECT(&quirk->mem));\n\n        QLIST_REMOVE(quirk, next);\n\n        g_free(quirk);\n\n    }\n\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":217590,"func":"void GLES2Implementation::ResizeCHROMIUM(GLuint width,\n                                         GLuint height,\n                                         float scale_factor,\n                                         GLenum color_space,\n                                         GLboolean alpha) {\n  GPU_CLIENT_SINGLE_THREAD_CHECK();\n  GPU_CLIENT_LOG(\"[\" << GetLogPrefix() << \"] glResizeCHROMIUM(\" << width << \", \"\n                     << height << \", \" << scale_factor << \", \" << alpha << \")\");\n  helper_->ResizeCHROMIUM(width, height, scale_factor, color_space, alpha);\n  CheckGLError();\n}\n","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":431471,"func":"Status AuthorizationManagerImpl::_fetchUserV2(OperationContext* opCtx,\n                                              const UserName& userName,\n                                              std::unique_ptr<User>* acquiredUser) {\n    BSONObj userObj;\n    Status status = getUserDescription(opCtx, userName, &userObj);\n    if (!status.isOK()) {\n        return status;\n    }\n\n    \/\/ Put the new user into an unique_ptr temporarily in case there's an error while\n    \/\/ initializing the user.\n    auto user = stdx::make_unique<User>(userName);\n\n    status = _initializeUserFromPrivilegeDocument(user.get(), userObj);\n    if (!status.isOK()) {\n        return status;\n    }\n    acquiredUser->reset(user.release());\n    return Status::OK();\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":378301,"func":"static int selinux_inode_setsecurity(struct inode *inode, const char *name,\n\t\t\t\t     const void *value, size_t size, int flags)\n{\n\tstruct inode_security_struct *isec = inode->i_security;\n\tu32 newsid;\n\tint rc;\n\n\tif (strcmp(name, XATTR_SELINUX_SUFFIX))\n\t\treturn -EOPNOTSUPP;\n\n\tif (!value || !size)\n\t\treturn -EACCES;\n\n\trc = security_context_to_sid((void *)value, size, &newsid, GFP_KERNEL);\n\tif (rc)\n\t\treturn rc;\n\n\tisec->sclass = inode_mode_to_security_class(inode->i_mode);\n\tisec->sid = newsid;\n\tisec->initialized = 1;\n\treturn 0;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":500391,"func":"QPDFAcroFormDocumentHelper::getFormFields()\n{\n    analyze();\n    std::vector<QPDFFormFieldObjectHelper> result;\n    for (std::map<QPDFObjGen,\n             std::vector<QPDFAnnotationObjectHelper> >::iterator iter =\n             this->m->field_to_annotations.begin();\n         iter != this->m->field_to_annotations.end(); ++iter)\n    {\n        result.push_back(this->qpdf.getObjectByObjGen((*iter).first));\n    }\n    return result;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":345958,"func":"bool asn1_check_enumerated(struct asn1_data *data, int v)\n{\n\tuint8_t b;\n\tif (!asn1_start_tag(data, ASN1_ENUMERATED)) return false;\n\tasn1_read_uint8(data, &b);\n\tasn1_end_tag(data);\n\n\tif (v != b)\n\t\tdata->has_error = false;\n\n\treturn !data->has_error;\n}","target":1,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":380203,"func":"static int ZEND_FASTCALL  ZEND_FETCH_FUNC_ARG_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\treturn zend_fetch_var_address_helper_SPEC_TMP(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), EX(opline)->extended_value)?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":284753,"func":"bool RenderFrameImpl::IsEncryptedMediaEnabled() const {\n  return GetRendererPreferences().enable_encrypted_media;\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":467192,"func":"RGWOp *RGWHandler_REST_Bucket_SWIFT::op_options()\n{\n  return new RGWOptionsCORS_ObjStore_SWIFT;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":356820,"func":"static inline struct nlattr *nla_nest_start(struct sk_buff *skb, int attrtype)\n{\n\tstruct nlattr *start = (struct nlattr *)skb_tail_pointer(skb);\n\n\tif (nla_put(skb, attrtype, 0, NULL) < 0)\n\t\treturn NULL;\n\n\treturn start;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":375179,"func":"_equalWindowDef(const WindowDef *a, const WindowDef *b)\n{\n\tCOMPARE_STRING_FIELD(name);\n\tCOMPARE_STRING_FIELD(refname);\n\tCOMPARE_NODE_FIELD(partitionClause);\n\tCOMPARE_NODE_FIELD(orderClause);\n\tCOMPARE_SCALAR_FIELD(frameOptions);\n\tCOMPARE_NODE_FIELD(startOffset);\n\tCOMPARE_NODE_FIELD(endOffset);\n\tCOMPARE_LOCATION_FIELD(location);\n\n\treturn true;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":492444,"func":"    IntVal(int32_t val) : val(val) {}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":476150,"func":"void InstanceKlass::call_class_initializer(TRAPS) {\n  if (ReplayCompiles &&\n      (ReplaySuppressInitializers == 1 ||\n       (ReplaySuppressInitializers >= 2 && class_loader() != NULL))) {\n    \/\/ Hide the existence of the initializer for the purpose of replaying the compile\n    return;\n  }\n\n  methodHandle h_method(THREAD, class_initializer());\n  assert(!is_initialized(), \"we cannot initialize twice\");\n  LogTarget(Info, class, init) lt;\n  if (lt.is_enabled()) {\n    ResourceMark rm(THREAD);\n    LogStream ls(lt);\n    ls.print(\"%d Initializing \", call_class_initializer_counter++);\n    name()->print_value_on(&ls);\n    ls.print_cr(\"%s (\" INTPTR_FORMAT \")\", h_method() == NULL ? \"(no method)\" : \"\", p2i(this));\n  }\n  if (h_method() != NULL) {\n    JavaCallArguments args; \/\/ No arguments\n    JavaValue result(T_VOID);\n    JavaCalls::call(&result, h_method, &args, CHECK); \/\/ Static call (no args)\n  }\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":202776,"func":"void RenderThread::OnSetNextPageID(int32 next_page_id) {\n  RenderView::SetNextPageID(next_page_id);\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":66251,"func":"static int pvc_create(struct net *net, struct socket *sock, int protocol,\n\t\t      int kern)\n{\n\tif (net != &init_net)\n\t\treturn -EAFNOSUPPORT;\n\n\tsock->ops = &pvc_proto_ops;\n\treturn vcc_create(net, sock, protocol, PF_ATMPVC);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":254294,"func":"EXPORTED int mboxlist_alluser(user_cb *proc, void *rock)\n{\n    struct alluser_rock urock;\n    int r = 0;\n    urock.prev = NULL;\n    urock.proc = proc;\n    urock.rock = rock;\n    r = mboxlist_allmbox(NULL, alluser_cb, &urock, \/*flags*\/0);\n    free(urock.prev);\n    return r;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":308802,"func":"int VideoRendererBase::NumFrames_Locked() const {\n  lock_.AssertAcquired();\n  int outstanding_frames =\n      (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) +\n      (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0);\n  return ready_frames_.size() + outstanding_frames;\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":200626,"func":"void PeopleHandler::OnAccountUpdated(const AccountInfo& info) {\n  FireWebUIListener(\"stored-accounts-updated\", *GetStoredAccountsList());\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":129390,"func":"static QString currentUser(void)\n{\n  struct passwd *current = getpwuid(getuid());\n  QString fullname(current->pw_gecos);\n  if (fullname.find(',') != -1)\n    \/* Remove everything from and including first comma *\/\n    fullname.resize(fullname.find(','));\n\n  QString username(current->pw_name);\n\n  return fullname + \" (\" + username + \")\";\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":268713,"func":"NOEXPORT const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,\n        unsigned int *len) {\n    if(len)\n        *len=s->session_id_length;\n    return (const unsigned char *)s->session_id;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":254218,"func":"void BrowserPolicyConnector::RegisterForUserPolicy(\n    const std::string& oauth_token) {\n  if (user_data_store_.get())\n    user_data_store_->SetOAuthToken(oauth_token);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":84842,"func":"bool Dispatcher::operator==( const Dispatcher &x ) const\n{\n  return ( params == x.params ) && ( parsed_params == x.parsed_params ) && ( parsed == x.parsed )\n    && ( dispatch_chars == x.dispatch_chars ) && ( OSC_string == x.OSC_string ) && ( terminal_to_host == x.terminal_to_host );\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":360095,"func":"nautilus_file_constructor (GType                  type,\n\t\t\t   guint                  n_construct_properties,\n\t\t\t   GObjectConstructParam *construct_params)\n{\n  GObject *object;\n  NautilusFile *file;\n\n  object = (* G_OBJECT_CLASS (nautilus_file_parent_class)->constructor) (type,\n\t\t\t\t\t\t\t\t\t n_construct_properties,\n\t\t\t\t\t\t\t\t\t construct_params);\n\n  file = NAUTILUS_FILE (object);\n\n  \/* Set to default type after full construction *\/\n  if (NAUTILUS_FILE_GET_CLASS (file)->default_file_type != G_FILE_TYPE_UNKNOWN) {\n\t  file->details->type = NAUTILUS_FILE_GET_CLASS (file)->default_file_type;\n  }\n  \n  return object;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":202379,"func":"void Browser::ShowCollectedCookiesDialog(TabContents *tab_contents) {\n  window()->ShowCollectedCookiesDialog(tab_contents);\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":284948,"func":"void ImageBitmapFactories::ImageBitmapLoader::LoadBlobAsync(\nvoid ImageBitmapFactories::ImageBitmapLoader::LoadBlobAsync(Blob* blob) {\n   loader_->Start(blob->GetBlobDataHandle());\n }\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":154435,"func":"static ssize_t k90_store_current_profile(struct device *dev,\n\t\t\t\t\t struct device_attribute *attr,\n\t\t\t\t\t const char *buf, size_t count)\n{\n\tint ret;\n\tstruct usb_interface *usbif = to_usb_interface(dev->parent);\n\tstruct usb_device *usbdev = interface_to_usbdev(usbif);\n\tint profile;\n\n\tif (kstrtoint(buf, 10, &profile))\n\t\treturn -EINVAL;\n\tif (profile < 1 || profile > 3)\n\t\treturn -EINVAL;\n\n\tret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0),\n\t\t\t      K90_REQUEST_PROFILE,\n\t\t\t      USB_DIR_OUT | USB_TYPE_VENDOR |\n\t\t\t      USB_RECIP_DEVICE, profile, 0, NULL, 0,\n\t\t\t      USB_CTRL_SET_TIMEOUT);\n\tif (ret != 0) {\n\t\tdev_warn(dev, \"Failed to change current profile (error %d).\\n\",\n\t\t\t ret);\n\t\treturn ret;\n\t}\n\n\treturn count;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":397912,"func":"void irc_queries_deinit(void)\n{\n\tsignal_remove(\"event privmsg\", (SIGNAL_FUNC) event_privmsg);\n\tsignal_remove(\"ctcp action\", (SIGNAL_FUNC) ctcp_action);\n\tsignal_remove(\"event nick\", (SIGNAL_FUNC) event_nick);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":111744,"func":"void PackLinuxElf64::updateLoader(OutputFile * \/*fo*\/)\n{\n    if (xct_off) {\n        return;  \/\/ FIXME elfout has no values at all\n    }\n    upx_uint64_t const vbase = get_te64(&elfout.phdr[0].p_vaddr);\n    unsigned start = linker->getSymbolOffset(\"_start\");\n\n    if (get_te16(&elfout.ehdr.e_machine)==Elf64_Ehdr::EM_PPC64\n    &&  elfout.ehdr.e_ident[Elf64_Ehdr::EI_DATA]==Elf64_Ehdr::ELFDATA2MSB) {\n        unsigned descr = linker->getSymbolOffset(\"entry_descr\");\n\n        \/\/ External relocation of PPC64 function descriptor.\n        upx_uint64_t dot_entry = start + sz_pack2 + vbase;\n        upx_byte *p = getLoader();\n\n        set_te64(&p[descr], dot_entry);\n        set_te64(&elfout.ehdr.e_entry, descr + sz_pack2 + vbase);\n    }\n    else {\n        set_te64(&elfout.ehdr.e_entry, start + sz_pack2 + vbase);\n    }\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":194771,"func":"     virtual void scheduleDrawAndPresent()\n    {\n        m_proxy->drawLayersAndPresentOnCCThread();\n    }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":202155,"func":"bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged(\n    const std::string& extension_id) {\n  return ReadExtensionPrefBoolean(extension_id, kPrefBlacklistAcknowledged);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":202239,"func":"void Document::DidRemoveAllPendingBodyStylesheets() {\n  if (ScriptableDocumentParser* parser = GetScriptableDocumentParser())\n    parser->DidLoadAllBodyStylesheets();\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":401130,"func":"static void cirrus_bitblt_rop_nop(CirrusVGAState *s,\n                                  uint32_t dstaddr, uint32_t srcaddr,\n                                  int dstpitch,int srcpitch,\n                                  int bltwidth,int bltheight)\n{\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":196813,"func":"bool ParamTraits<gfx::SizeF>::Read(const Message* m,\n                                   PickleIterator* iter,\n                                   gfx::SizeF* p) {\n  float w, h;\n  if (!ParamTraits<float>::Read(m, iter, &w) ||\n      !ParamTraits<float>::Read(m, iter, &h))\n    return false;\n  p->set_width(w);\n  p->set_height(h);\n  return true;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":368065,"func":"handle_denyall(CMD_Request *rx_message, CMD_Reply *tx_message)\n{\n  IPAddr ip;\n  int subnet_bits;\n  UTI_IPNetworkToHost(&rx_message->data.allow_deny.ip, &ip);\n  subnet_bits = ntohl(rx_message->data.allow_deny.subnet_bits);\n  if (NCR_AddAccessRestriction(&ip, subnet_bits, 0, 1)) {\n    tx_message->status = htons(STT_SUCCESS);\n  } else {\n    tx_message->status = htons(STT_BADSUBNET);\n  }              \n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":251053,"func":"std::unique_ptr<NavigationUIData> WebContentsImpl::GetNavigationUIData(\n    NavigationHandle* navigation_handle) {\n  DCHECK(IsBrowserSideNavigationEnabled());\n  return GetContentClient()->browser()->GetNavigationUIData(navigation_handle);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":413300,"func":"Elf32_Shdr const *PackLinuxElf32::elf_find_section_name(\n    char const *const name\n) const\n{\n    Elf32_Shdr const *shdr = shdri;\n    if (!shdr) {\n        return 0;\n    }\n    int j = e_shnum;\n    for (; 0 <=--j; ++shdr) {\n        if (0==strcmp(name, &shstrtab[get_te32(&shdr->sh_name)])) {\n            return shdr;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":270980,"func":"int luaopen_create(lua_State *L) {\n    int i;\n    \/* Manually construct our module table instead of\n     * relying on _register or _newlib *\/\n    lua_newtable(L);\n\n    for (i = 0; i < (sizeof(cmds)\/sizeof(*cmds) - 1); i++) {\n        lua_pushcfunction(L, cmds[i].func);\n        lua_setfield(L, -2, cmds[i].name);\n    }\n\n    \/* Add metadata *\/\n    lua_pushliteral(L, LUACMSGPACK_NAME);\n    lua_setfield(L, -2, \"_NAME\");\n    lua_pushliteral(L, LUACMSGPACK_VERSION);\n    lua_setfield(L, -2, \"_VERSION\");\n    lua_pushliteral(L, LUACMSGPACK_COPYRIGHT);\n    lua_setfield(L, -2, \"_COPYRIGHT\");\n    lua_pushliteral(L, LUACMSGPACK_DESCRIPTION);\n    lua_setfield(L, -2, \"_DESCRIPTION\");\n    return 1;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":253183,"func":"void DelegatedFrameHost::OnUpdateVSyncParameters(base::TimeTicks timebase,\n                                                 base::TimeDelta interval) {\n  vsync_timebase_ = timebase;\n  vsync_interval_ = interval;\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":428260,"func":"int tcp_set_rcvlowat(struct sock *sk, int val)\n{\n\tint cap;\n\n\tif (sk->sk_userlocks & SOCK_RCVBUF_LOCK)\n\t\tcap = sk->sk_rcvbuf >> 1;\n\telse\n\t\tcap = sock_net(sk)->ipv4.sysctl_tcp_rmem[2] >> 1;\n\tval = min(val, cap);\n\tsk->sk_rcvlowat = val ? : 1;\n\n\t\/* Check if we need to signal EPOLLIN right now *\/\n\ttcp_data_ready(sk);\n\n\tif (sk->sk_userlocks & SOCK_RCVBUF_LOCK)\n\t\treturn 0;\n\n\tval <<= 1;\n\tif (val > sk->sk_rcvbuf) {\n\t\tsk->sk_rcvbuf = val;\n\t\ttcp_sk(sk)->window_clamp = tcp_win_from_space(sk, val);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":286268,"func":"process_config_source( const char* file, const char* name,\n\t\t\t\t\t   const char* host, int required )\n{\n\tint rval;\n\tif( access( file, R_OK ) != 0 && !is_piped_command(file)) {\n\t\tif( !required) { return; }\n\n\t\tif( !host ) {\n\t\t\tfprintf( stderr, \"ERROR: Can't read %s %s\\n\",\n\t\t\t\t\t name, file );\n\t\t\texit( 1 );\n\t\t}\n\t} else {\n\t\trval = Read_config( file, ConfigTab, TABLESIZE, EXPAND_LAZY,\n\t\t\t\t\t\t\tfalse, extra_info );\n\t\tif( rval < 0 ) {\n\t\t\tfprintf( stderr,\n\t\t\t\t\t \"Configuration Error Line %d while reading %s %s\\n\",\n\t\t\t\t\t ConfigLineNo, name, file );\n\t\t\texit( 1 );\n\t\t}\n\t}\n}\n","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":212570,"func":"static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu)\n{\n\tint i;\n\tfor (i = 0; i < roundup_pow_of_two(ASYNC_PF_PER_VCPU); i++)\n\t\tvcpu->arch.apf.gfns[i] = ~0;\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":404716,"func":"static void foo_close(struct tcmu_device *dev)\n{\n\t\/* not supported in this example *\/\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":474600,"func":"mirror_wait_for_free_in_flight_slot(MirrorBlockJob *s)\n{\n    \/* Only non-active operations use up in-flight slots *\/\n    mirror_wait_for_any_operation(s, false);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":9083,"func":"bool SimpleMessenger::verify_authorizer(Connection *con, int peer_type,\n\t\t\t\t\tint protocol, bufferlist& authorizer, bufferlist& authorizer_reply,\n\t\t\t\t\tbool& isvalid,CryptoKey& session_key)\n{\n  return ms_deliver_verify_authorizer(con, peer_type, protocol, authorizer, authorizer_reply, isvalid,session_key);\n}","target":1,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":366743,"func":"static int selinux_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp)\n{\n\tint rc;\n\n\trc = cap_task_setscheduler(p, policy, lp);\n\tif (rc)\n\t\treturn rc;\n\n\treturn current_has_perm(p, PROCESS__SETSCHED);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":419566,"func":"char *get_sa_devname(unsigned int major, unsigned int minor, unsigned int flags)\n{\n\tchar *dev_name = NULL, *persist_dev_name = NULL;\n\n\tif (DISPLAY_PERSIST_NAME_S(flags)) {\n\t\tpersist_dev_name = get_persistent_name_from_pretty(get_devname(major, minor, TRUE));\n\t}\n\n\tif (persist_dev_name) {\n\t\tdev_name = persist_dev_name;\n\t}\n\telse {\n\t\tif ((USE_PRETTY_OPTION(flags)) && (major == dm_major)) {\n\t\t\tdev_name = transform_devmapname(major, minor);\n\t\t}\n\n\t\tif (!dev_name) {\n\t\t\tdev_name = get_devname(major, minor,\n\t\t\t\t\t       USE_PRETTY_OPTION(flags));\n\t\t}\n\t}\n\n\treturn dev_name;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":55427,"func":"static void cassignop(JF, js_Ast *exp, int opcode)\n{\n\tjs_Ast *lhs = exp->a;\n\tjs_Ast *rhs = exp->b;\n\tcassignop1(J, F, lhs);\n\tcexp(J, F, rhs);\n\temitline(J, F, exp);\n\temit(J, F, opcode);\n\tcassignop2(J, F, lhs, 0);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":314220,"func":"SoundChannel::~SoundChannel()\n{\n    ALOGV(\"SoundChannel destructor %p\", this);\n {\n Mutex::Autolock lock(&mLock);\n        clearNextEvent();\n        doStop_l();\n }\n    mAudioTrack.clear();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":424603,"func":"utf16le_code_to_mbclen(OnigCodePoint code)\n{\n  return (code > 0xffff ? 4 : 2);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":180744,"func":"void V8TestObject::ElementAttributeAttributeSetterCallback(\n    const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_elementAttribute_Setter\");\n\n  v8::Local<v8::Value> v8_value = info[0];\n\n  test_object_v8_internal::ElementAttributeAttributeSetter(v8_value, info);\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":213216,"func":"static void unsignedLongLongAttrAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n    TestObjectV8Internal::unsignedLongLongAttrAttributeSetter(jsValue, info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":436343,"func":"get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t\t   const OnigUChar* p, const OnigUChar* end,\n\t\t\t   OnigCaseFoldCodeItem items[])\n{\n  return onigenc_get_case_fold_codes_by_str_with_map(\n\t     sizeof(CaseFoldMap)\/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,\n\t     flag, p, end, items);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":478883,"func":"    const CImg<T>& save_off(const CImgList<tf>& primitives, const CImgList<tc>& colors,\n                            std::FILE *const file) const {\n      return _save_off(primitives,colors,file,0);\n    }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":197338,"func":"WebUI* WebContentsImpl::GetWebUI() const {\n  return render_manager_.web_ui() ? render_manager_.web_ui()\n      : render_manager_.pending_web_ui();\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":98320,"func":"static int setup_efi_info_memmap(struct boot_params *params,\n\t\t\t\t  unsigned long params_load_addr,\n\t\t\t\t  unsigned int efi_map_offset,\n\t\t\t\t  unsigned int efi_map_sz)\n{\n\tvoid *efi_map = (void *)params + efi_map_offset;\n\tunsigned long efi_map_phys_addr = params_load_addr + efi_map_offset;\n\tstruct efi_info *ei = ¶ms->efi_info;\n\n\tif (!efi_map_sz)\n\t\treturn 0;\n\n\tefi_runtime_map_copy(efi_map, efi_map_sz);\n\n\tei->efi_memmap = efi_map_phys_addr & 0xffffffff;\n\tei->efi_memmap_hi = efi_map_phys_addr >> 32;\n\tei->efi_memmap_size = efi_map_sz;\n\n\treturn 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":302281,"func":"static int pfkey_acquire(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr, void * const *ext_hdrs)\n{\n\tstruct net *net = sock_net(sk);\n\tstruct xfrm_state *x;\n\n\tif (hdr->sadb_msg_len != sizeof(struct sadb_msg)\/8)\n\t\treturn -EOPNOTSUPP;\n\n\tif (hdr->sadb_msg_seq == 0 || hdr->sadb_msg_errno == 0)\n\t\treturn 0;\n\n\tx = xfrm_find_acq_byseq(net, DUMMY_MARK, hdr->sadb_msg_seq);\n\tif (x == NULL)\n\t\treturn 0;\n\n\tspin_lock_bh(&x->lock);\n\tif (x->km.state == XFRM_STATE_ACQ)\n\t\tx->km.state = XFRM_STATE_ERROR;\n\n\tspin_unlock_bh(&x->lock);\n\txfrm_state_put(x);\n\treturn 0;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":370096,"func":"PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC)\n{\n\tif (!node) {\n\t\treturn;\n\t}\n\n\tswitch (node->type) {\n\t\tcase XML_DOCUMENT_NODE:\n\t\tcase XML_HTML_DOCUMENT_NODE:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (node->parent == NULL || node->type == XML_NAMESPACE_DECL) {\n\t\t\t\tphp_libxml_node_free_list((xmlNodePtr) node->children TSRMLS_CC);\n\t\t\t\tswitch (node->type) {\n\t\t\t\t\t\/* Skip property freeing for the following types *\/\n\t\t\t\t\tcase XML_ATTRIBUTE_DECL:\n\t\t\t\t\tcase XML_DTD_NODE:\n\t\t\t\t\tcase XML_DOCUMENT_TYPE_NODE:\n\t\t\t\t\tcase XML_ENTITY_DECL:\n\t\t\t\t\tcase XML_ATTRIBUTE_NODE:\n\t\t\t\t\tcase XML_NAMESPACE_DECL:\n\t\t\t\t\tcase XML_TEXT_NODE:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tphp_libxml_node_free_list((xmlNodePtr) node->properties TSRMLS_CC);\n\t\t\t\t}\n\t\t\t\tif (php_libxml_unregister_node(node TSRMLS_CC) == 0) {\n\t\t\t\t\tnode->doc = NULL;\n\t\t\t\t}\n\t\t\t\tphp_libxml_node_free(node);\n\t\t\t} else {\n\t\t\t\tphp_libxml_unregister_node(node TSRMLS_CC);\n\t\t\t}\n\t}\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":19250,"func":"uint32_t jbig2_get_uint32 ( const byte * bptr ) {\n return ( ( uint32_t ) get_uint16 ( bptr ) << 16 ) | get_uint16 ( bptr + 2 ) ;\n }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":147864,"func":"static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)\n{\n\tstruct unimac_mdio_priv *priv = bus->priv;\n\tint ret;\n\tu32 cmd;\n\n\t\/* Prepare the read operation *\/\n\tcmd = MDIO_RD | (phy_id << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT);\n\tunimac_mdio_writel(priv, cmd, MDIO_CMD);\n\n\t\/* Start MDIO transaction *\/\n\tunimac_mdio_start(priv);\n\n\tret = priv->wait_func(priv->wait_func_data);\n\tif (ret)\n\t\treturn ret;\n\n\tcmd = unimac_mdio_readl(priv, MDIO_CMD);\n\n\t\/* Some broken devices are known not to release the line during\n\t * turn-around, e.g: Broadcom BCM53125 external switches, so check for\n\t * that condition here and ignore the MDIO controller read failure\n\t * indication.\n\t *\/\n\tif (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL))\n\t\treturn -EIO;\n\n\treturn cmd & 0xffff;\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":499837,"func":"static void print_rect(std::ostream& out,\n                       QPDFObjectHandle::Rectangle const& r)\n{\n    out << \"[\" << r.llx << \", \" << r.lly << \", \"\n        << r.urx << \", \" << r.ury << \"]\";\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":137130,"func":"PHP_FUNCTION(imagepalettecopy)\n{\n\tzval *dstim, *srcim;\n\tgdImagePtr dst, src;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rr\", &dstim, &srcim) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(dst, gdImagePtr, &dstim, -1, \"Image\", le_gd);\n\tZEND_FETCH_RESOURCE(src, gdImagePtr, &srcim, -1, \"Image\", le_gd);\n\n\tgdImagePaletteCopy(dst, src);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":65074,"func":"v3d_reset_v3d(struct v3d_dev *v3d)\n{\n\tif (v3d->reset)\n\t\treset_control_reset(v3d->reset);\n\telse\n\t\tv3d_reset_by_bridge(v3d);\n\n\tv3d_init_hw_state(v3d);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":51571,"func":"path_poly(PG_FUNCTION_ARGS)\n{\n\tPATH\t   *path = PG_GETARG_PATH_P(0);\n\tPOLYGON    *poly;\n\tint\t\t\tsize;\n\tint\t\t\ti;\n\n\t\/* This is not very consistent --- other similar cases return NULL ... *\/\n\tif (!path->closed)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_PARAMETER_VALUE),\n\t\t\t\t errmsg(\"open path cannot be converted to polygon\")));\n\n\t\/*\n\t * Never overflows: the old size fit in MaxAllocSize, and the new size is\n\t * just a small constant larger.\n\t *\/\n\tsize = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * path->npts;\n\tpoly = (POLYGON *) palloc(size);\n\n\tSET_VARSIZE(poly, size);\n\tpoly->npts = path->npts;\n\n\tfor (i = 0; i < path->npts; i++)\n\t{\n\t\tpoly->p[i].x = path->p[i].x;\n\t\tpoly->p[i].y = path->p[i].y;\n\t}\n\n\tmake_bound_box(poly);\n\n\tPG_RETURN_POLYGON_P(poly);\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":439826,"func":"ipmi_sdr_get_sensor_thresholds(struct ipmi_intf *intf, uint8_t sensor,\n\t\t\t\t\tuint8_t target, uint8_t lun, uint8_t channel)\n{\n\tstruct ipmi_rq req;\n\tstruct ipmi_rs *rsp;\n\tuint8_t  bridged_request = 0;\n\tuint32_t save_addr;\n\tuint32_t save_channel;\n\n\tif ( BRIDGE_TO_SENSOR(intf, target, channel) ) {\n\t\tbridged_request = 1;\n\t\tsave_addr = intf->target_addr;\n\t\tintf->target_addr = target;\n\t\tsave_channel = intf->target_channel;\n\t\tintf->target_channel = channel;\n\t}\n\n\tmemset(&req, 0, sizeof (req));\n\treq.msg.netfn = IPMI_NETFN_SE;\n\treq.msg.lun = lun;\n\treq.msg.cmd = GET_SENSOR_THRESHOLDS;\n\treq.msg.data = &sensor;\n\treq.msg.data_len = sizeof (sensor);\n\n\trsp = intf->sendrecv(intf, &req);\n\tif (bridged_request) {\n\t\tintf->target_addr = save_addr;\n\t\tintf->target_channel = save_channel;\n\t}\n\treturn rsp;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":153423,"func":"static void cryp_state_free(struct user_ta_ctx *utc, struct tee_cryp_state *cs)\n{\n\tstruct tee_obj *o;\n\n\tif (tee_obj_get(utc, cs->key1, &o) == TEE_SUCCESS)\n\t\ttee_obj_close(utc, o);\n\tif (tee_obj_get(utc, cs->key2, &o) == TEE_SUCCESS)\n\t\ttee_obj_close(utc, o);\n\n\tTAILQ_REMOVE(&utc->cryp_states, cs, link);\n\tif (cs->ctx_finalize != NULL)\n\t\tcs->ctx_finalize(cs->ctx, cs->algo);\n\n\tswitch (TEE_ALG_GET_CLASS(cs->algo)) {\n\tcase TEE_OPERATION_CIPHER:\n\t\tcrypto_cipher_free_ctx(cs->ctx, cs->algo);\n\t\tbreak;\n\tcase TEE_OPERATION_AE:\n\t\tcrypto_authenc_free_ctx(cs->ctx, cs->algo);\n\t\tbreak;\n\tcase TEE_OPERATION_DIGEST:\n\t\tcrypto_hash_free_ctx(cs->ctx, cs->algo);\n\t\tbreak;\n\tcase TEE_OPERATION_MAC:\n\t\tcrypto_mac_free_ctx(cs->ctx, cs->algo);\n\t\tbreak;\n\tdefault:\n\t\tassert(!cs->ctx);\n\t}\n\n\tfree(cs);\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":334255,"func":"void qemu_system_reset(ShutdownCause reason)\n\n{\n\n    MachineClass *mc;\n\n\n\n    mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;\n\n\n\n    cpu_synchronize_all_states();\n\n\n\n    if (mc && mc->reset) {\n\n        mc->reset();\n\n    } else {\n\n        qemu_devices_reset();\n\n    }\n\n    if (reason) {\n\n        \/* TODO update event based on reason *\/\n\n        qapi_event_send_reset(&error_abort);\n\n    }\n\n    cpu_synchronize_all_post_reset();\n\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":161497,"func":"static const char *pathbase(const char *path) {\n    const char *p = strrchr(path, SEP);\n    return (p == NULL) ? path : p + 1;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":111384,"func":"void cil_destroy_cats(struct cil_cats *cats)\n{\n\tif (cats == NULL) {\n\t\treturn;\n\t}\n\n\tcil_list_destroy(&cats->str_expr, CIL_TRUE);\n\n\tcil_list_destroy(&cats->datum_expr, CIL_FALSE);\n\n\tfree(cats);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":252493,"func":"base::Histogram::Sample HashInterfaceNameToHistogramSample(\n    base::StringPiece name) {\n  return base::strict_cast<base::Histogram::Sample>(\n      static_cast<int32_t>(base::HashMetricName(name) & 0x7fffffffull));\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":394254,"func":"static cmsHTRANSFORM *AcquireTransformThreadSet(Image *image,\n  const cmsHPROFILE source_profile,const cmsUInt32Number source_type,\n  const cmsHPROFILE target_profile,const cmsUInt32Number target_type,\n  const int intent,const cmsUInt32Number flags)\n{\n  cmsHTRANSFORM\n    *transform;\n\n  register ssize_t\n    i;\n\n  size_t\n    number_threads;\n\n  number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n  transform=(cmsHTRANSFORM *) AcquireQuantumMemory(number_threads,\n    sizeof(*transform));\n  if (transform == (cmsHTRANSFORM *) NULL)\n    return((cmsHTRANSFORM *) NULL);\n  (void) ResetMagickMemory(transform,0,number_threads*sizeof(*transform));\n  for (i=0; i < (ssize_t) number_threads; i++)\n  {\n    transform[i]=cmsCreateTransformTHR(image,source_profile,source_type,\n      target_profile,target_type,intent,flags);\n    if (transform[i] == (cmsHTRANSFORM) NULL)\n      return(DestroyTransformThreadSet(transform));\n  }\n  return(transform);\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":238103,"func":"static void arrayBufferAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    V8TRYCATCH_VOID(ArrayBuffer*, cppValue, jsValue->IsArrayBuffer() ? V8ArrayBuffer::toNative(v8::Handle<v8::ArrayBuffer>::Cast(jsValue)) : 0);\n    imp->setArrayBufferAttribute(WTF::getPtr(cppValue));\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":110116,"func":"get_sw_value_col(buf_T *buf, colnr_T col UNUSED)\n{\n    return buf->b_p_sw ? buf->b_p_sw :\n#ifdef FEAT_VARTABS\n\ttabstop_at(col, buf->b_p_ts, buf->b_p_vts_array);\n#else\n\tbuf->b_p_ts;\n#endif\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":427508,"func":"string_timediff(struct timeval * diff)\n{\nstatic uschar buf[sizeof(\"0.000s\")];\n\nif (diff->tv_sec >= 5 || !LOGGING(millisec))\n  return readconf_printtime((int)diff->tv_sec);\n\nsprintf(CS buf, \"%u.%03us\", (uint)diff->tv_sec, (uint)diff->tv_usec\/1000);\nreturn buf;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":141356,"func":"void lua_datum::shutdown(CLua &)\n{\n    cleanup();\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":501001,"func":"GF_Box *txtc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextConfigBox, GF_ISOM_BOX_TYPE_TXTC);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":130524,"func":"static struct dentry *trace_options_init_dentry(struct trace_array *tr)\n{\n\tstruct dentry *d_tracer;\n\n\tif (tr->options)\n\t\treturn tr->options;\n\n\td_tracer = tracing_get_dentry(tr);\n\tif (IS_ERR(d_tracer))\n\t\treturn NULL;\n\n\ttr->options = tracefs_create_dir(\"options\", d_tracer);\n\tif (!tr->options) {\n\t\tpr_warn(\"Could not create tracefs directory 'options'\\n\");\n\t\treturn NULL;\n\t}\n\n\treturn tr->options;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":301850,"func":"long jas_stream_seek(jas_stream_t *stream, long offset, int origin)\n{\n\tlong newpos;\n\n\t\/* The buffer cannot be in use for both reading and writing. *\/\n\tassert(!((stream->bufmode_ & JAS_STREAM_RDBUF) && (stream->bufmode_ &\n\t  JAS_STREAM_WRBUF)));\n\n\t\/* Reset the EOF indicator (since we may not be at the EOF anymore). *\/\n\tstream->flags_ &= ~JAS_STREAM_EOF;\n\n\tif (stream->bufmode_ & JAS_STREAM_RDBUF) {\n\t\tif (origin == SEEK_CUR) {\n\t\t\toffset -= stream->cnt_;\n\t\t}\n\t} else if (stream->bufmode_ & JAS_STREAM_WRBUF) {\n\t\tif (jas_stream_flush(stream)) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\tstream->cnt_ = 0;\n\tstream->ptr_ = stream->bufstart_;\n\tstream->bufmode_ &= ~(JAS_STREAM_RDBUF | JAS_STREAM_WRBUF);\n\n\tif ((newpos = (*stream->ops_->seek_)(stream->obj_, offset, origin))\n\t  < 0) {\n\t\treturn -1;\n\t}\n\n\treturn newpos;\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":377671,"func":"void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)\n{\n\thrtimer_cancel(&wd->timer);\n\tqdisc_unthrottled(wd->qdisc);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":507032,"func":"static const SSL_METHOD *ssl23_get_server_method(int ver)\n\t{\n#ifndef OPENSSL_NO_SSL2\n\tif (ver == SSL2_VERSION)\n\t\treturn(SSLv2_server_method());\n#endif\n#ifndef OPENSSL_NO_SSL3\n\tif (ver == SSL3_VERSION)\n\t\treturn(SSLv3_server_method());\n#endif\n\tif (ver == TLS1_VERSION)\n\t\treturn(TLSv1_server_method());\n\telse if (ver == TLS1_1_VERSION)\n\t\treturn(TLSv1_1_server_method());\n\telse if (ver == TLS1_2_VERSION)\n\t\treturn(TLSv1_2_server_method());\n\telse\n\t\treturn(NULL);\n\t}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":287935,"func":"DOMHandler::DOMHandler()\n     : DevToolsDomainHandler(DOM::Metainfo::domainName),\n      host_(nullptr) {\n}\n","target":1,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":42107,"func":"write_pool(struct entropy_store *r, const char __user *buffer, size_t count)\n{\n\tsize_t bytes;\n\t__u32 buf[16];\n\tconst char __user *p = buffer;\n\n\twhile (count > 0) {\n\t\tbytes = min(count, sizeof(buf));\n\t\tif (copy_from_user(&buf, p, bytes))\n\t\t\treturn -EFAULT;\n\n\t\tcount -= bytes;\n\t\tp += bytes;\n\n\t\tmix_pool_bytes(r, buf, bytes);\n\t\tcond_resched();\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":119019,"func":"static void sig_handler(const int sig) {\n    printf(\"SIGINT handled.\\n\");\n    exit(EXIT_SUCCESS);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":276845,"func":"BrowserContext* NavigationControllerImpl::GetBrowserContext() const {\n  return browser_context_;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":314566,"func":"RenderWidget* RenderViewImpl::GetWidget() {\n  return this;\n}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":516365,"func":"void X509Certificate::InfoAccess(const FunctionCallbackInfo<Value>& args) {\n  Environment* env = Environment::GetCurrent(args);\n  X509Certificate* cert;\n  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());\n  BIOPointer bio(BIO_new(BIO_s_mem()));\n  Local<Value> ret;\n  if (GetInfoAccessString(env, bio, cert->get()).ToLocal(&ret))\n    args.GetReturnValue().Set(ret);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":125266,"func":"flatpak_dir_get_remote_oci (FlatpakDir *self,\n                            const char *remote_name)\n{\n  g_autofree char *url = NULL;\n\n  if (!flatpak_dir_ensure_repo (self, NULL, NULL))\n    return FALSE;\n\n  if (!ostree_repo_remote_get_url (self->repo, remote_name, &url, NULL))\n    return FALSE;\n\n  return url && g_str_has_prefix (url, \"oci+\");\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":438762,"func":"push_glob0_caller(const char *path, VALUE val, void *enc)\n{\n    struct push_glob0_args *arg = (struct push_glob0_args *)val;\n    return ruby_glob0(path, arg->fd, arg->base, arg->flags, arg->funcs, arg->arg, enc);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":365315,"func":"rb_str_center(argc, argv, str)\n    int argc;\n    VALUE *argv;\n    VALUE str;\n{\n    return rb_str_justify(argc, argv, str, 'c');\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":303050,"func":"XML_GetIdAttributeIndex(XML_Parser parser) {\n  if (parser == NULL)\n    return -1;\n  return parser->m_idAttIndex;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":458515,"func":"skip_non_digits(char *str)\n{\n    while (!isdigit(*str) && *str != 0) {\n        str++;\n    }\n    return str;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":519111,"func":"  Field_timestampf(uchar *ptr_arg,\n                   uchar *null_ptr_arg, uchar null_bit_arg,\n                   enum utype unireg_check_arg,\n                   const LEX_CSTRING *field_name_arg,\n                   TABLE_SHARE *share, uint dec_arg) :\n    Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,\n                             unireg_check_arg, field_name_arg, share, dec_arg)\n    {}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":515328,"func":"smtp_server_connection_send_replies(struct smtp_server_connection *conn)\n{\n\t\/* Send more replies until no more replies remain, the output\n\t   blocks again, or the connection is closed *\/\n\twhile (!conn->disconnected && smtp_server_connection_next_reply(conn));\n\n\tsmtp_server_connection_timeout_update(conn);\n\n\t\/* Accept more commands if possible *\/\n\tsmtp_server_connection_input_resume(conn);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":363247,"func":"pango_ot_info_list_languages (PangoOTInfo      *info,\n\t\t\t      PangoOTTableType  table_type,\n\t\t\t      guint             script_index,\n\t\t\t      PangoOTTag        language_tag G_GNUC_UNUSED)\n{\n  hb_ot_layout_table_type_t tt = get_hb_table_type (table_type);\n  PangoOTTag *result;\n  unsigned int count, i;\n\n  count = hb_ot_layout_script_get_language_count (info->layout, tt,\n\t\t\t\t\t\t  script_index);\n\n  result = g_new (PangoOTTag, count + 1);\n\n  for (i = 0; i < count; i++)\n    result[i] = hb_ot_layout_script_get_language_tag (info->layout, tt,\n\t\t\t\t\t\t      script_index,\n\t\t\t\t\t\t      i);\n\n  result[i] = 0;\n\n  return result;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":378957,"func":"int LZ4IO_setNotificationLevel(int level)\n{\n    displayLevel = level;\n    return displayLevel;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":448161,"func":"static char *mk_str(link_ctx *ctx, size_t end) \n{\n    if (ctx->i < end) {\n        return apr_pstrndup(ctx->pool, ctx->s + ctx->i, end - ctx->i);\n    }\n    return (char*)\"\";\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":311678,"func":"void LazyBackgroundPageNativeHandler::IncrementKeepaliveCount(\n    const v8::FunctionCallbackInfo<v8::Value>& args) {\n  if (context() && ExtensionFrameHelper::IsContextForEventPage(context())) {\n    content::RenderFrame* render_frame = context()->GetRenderFrame();\n    render_frame->Send(new ExtensionHostMsg_IncrementLazyKeepaliveCount(\n        render_frame->GetRoutingID()));\n  }\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":198395,"func":"GURL SavePackage::GetUrlToBeSaved() {\n  NavigationEntry* active_entry =\n      web_contents()->GetController().GetActiveEntry();\n  return active_entry->GetURL();\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":167784,"func":"void InspectorOverlay::setOverridesTopOffset(int offset)\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":279544,"func":"void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents,\n                               int element_instance_id,\n                               bool is_full_page_plugin) {\n  if (owner_web_contents_ != embedder_web_contents) {\n    DCHECK_EQ(owner_contents_observer_->web_contents(), owner_web_contents_);\n    StopTrackingEmbedderZoomLevel();\n    owner_web_contents_ = embedder_web_contents;\n    owner_contents_observer_.reset(\n        new OwnerContentsObserver(this, embedder_web_contents));\n  }\n\n  StartTrackingEmbedderZoomLevel();\n  element_instance_id_ = element_instance_id;\n  is_full_page_plugin_ = is_full_page_plugin;\n\n  WillAttachToEmbedder();\n}\n","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":365139,"func":"connection_dirserv_flushed_some(dir_connection_t *conn)\n{\n  tor_assert(conn->_base.state == DIR_CONN_STATE_SERVER_WRITING);\n\n  if (buf_datalen(conn->_base.outbuf) >= DIRSERV_BUFFER_MIN)\n    return 0;\n\n  switch (conn->dir_spool_src) {\n    case DIR_SPOOL_EXTRA_BY_DIGEST:\n    case DIR_SPOOL_EXTRA_BY_FP:\n    case DIR_SPOOL_SERVER_BY_DIGEST:\n    case DIR_SPOOL_SERVER_BY_FP:\n      return connection_dirserv_add_servers_to_outbuf(conn);\n    case DIR_SPOOL_MICRODESC:\n      return connection_dirserv_add_microdescs_to_outbuf(conn);\n    case DIR_SPOOL_CACHED_DIR:\n      return connection_dirserv_add_dir_bytes_to_outbuf(conn);\n    case DIR_SPOOL_NETWORKSTATUS:\n      return connection_dirserv_add_networkstatus_bytes_to_outbuf(conn);\n    case DIR_SPOOL_NONE:\n    default:\n      return 0;\n  }\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":304094,"func":"static int instantiate_none(struct lxc_handler *handler, struct lxc_netdev *netdev)\n{\n\tnetdev->ifindex = 0;\n\treturn 0;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":391485,"func":"static int snd_usb_capture_open(struct snd_pcm_substream *substream)\n{\n\treturn snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":124290,"func":"void MirrorJob::Statistics::Reset()\n{\n   tot_files=new_files=mod_files=del_files=\n   tot_symlinks=new_symlinks=mod_symlinks=del_symlinks=\n   dirs=del_dirs=0;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":156886,"func":"gboolean\nmono_verifier_is_method_full_trust (MonoMethod *method)\n{\n\t\/* The verifier was disabled at compile time *\/\n\treturn TRUE;","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":478112,"func":"    static CImg<T> identity_matrix(const unsigned int N) {\n      CImg<T> res(N,N,1,1,0);\n      cimg_forX(res,x) res(x,x) = 1;\n      return res;\n    }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":60777,"func":"  CertificateValidationContextSdsRotationApiTest() {\n    envoy::config::core::v3::ConfigSource config_source;\n    sds_api_ = std::make_unique<CertificateValidationContextSdsApi>(\n        config_source, \"abc.com\", subscription_factory_, time_system_, validation_visitor_, stats_,\n        []() {}, mock_dispatcher_, *api_);\n    init_manager_.add(*sds_api_->initTarget());\n    initialize();\n    handle_ = sds_api_->addUpdateCallback([this]() { secret_callback_.onAddOrUpdateSecret(); });\n  }","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":285955,"func":"void Document::setTitle(const String& title)\n{\n    m_titleSetExplicitly = true;\n    if (!isHTMLDocument() && !isXHTMLDocument())\n        m_titleElement = 0;\n    else if (!m_titleElement) {\n        if (HTMLElement* headElement = head()) {\n            m_titleElement = createElement(titleTag, false);\n            headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION);\n        }\n    }\n\n    updateTitle(StringWithDirection(title, LTR));\n\n    if (m_titleElement) {\n        ASSERT(m_titleElement->hasTagName(titleTag));\n        if (m_titleElement->hasTagName(titleTag))\n            static_cast<HTMLTitleElement*>(m_titleElement.get())->setText(title);\n    }\n}\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":242994,"func":"void AppCacheUpdateJob::FetchMasterEntries() {\n  DCHECK(internal_state_ == NO_UPDATE || internal_state_ == DOWNLOADING);\n\n  while (master_entry_fetches_.size() < kMaxConcurrentUrlFetches &&\n         !master_entries_to_fetch_.empty()) {\n    const GURL& url = *master_entries_to_fetch_.begin();\n\n    if (AlreadyFetchedEntry(url, AppCacheEntry::MASTER)) {\n      ++master_entries_completed_;  \/\/ saved a URL request\n\n      if (internal_state_ == NO_UPDATE) {\n        DCHECK(!inprogress_cache_.get());\n        AppCache* cache = group_->newest_complete_cache();\n        auto found = pending_master_entries_.find(url);\n        DCHECK(found != pending_master_entries_.end());\n        PendingHosts& hosts = found->second;\n        for (AppCacheHost* host : hosts)\n          host->AssociateCompleteCache(cache);\n      }\n    } else {\n      URLFetcher* fetcher = new URLFetcher(url, URLFetcher::MASTER_ENTRY_FETCH,\n                                           this, kAppCacheFetchBufferSize);\n      fetcher->Start();\n      master_entry_fetches_.insert(PendingUrlFetches::value_type(url, fetcher));\n    }\n\n    master_entries_to_fetch_.erase(master_entries_to_fetch_.begin());\n  }\n}\n","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":392234,"func":"void rebuild_check_host(void)\n{\n  delete_dynamic(&acl_wild_hosts);\n  my_hash_free(&acl_check_hosts);\n  init_check_host();\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":84694,"func":"static void sig_chat_protocol_deinit(CHAT_PROTOCOL_REC *proto)\n{\n        disconnect_servers(servers, proto->id);\n        disconnect_servers(lookup_servers, proto->id);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":439208,"func":"Ptr<FileStorageParser> createXMLParser(FileStorage_API* fs)\n{\n    return makePtr<XMLParser>(fs);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":24307,"func":"IN_PROC_BROWSER_TEST_F ( HttpsEngagementPageLoadMetricsBrowserTest , Navigate_Http ) {\n StartHttpServer ( ) ;\n NavigateTwiceInTabAndClose ( http_test_server_ -> GetURL ( \"\/simple.html\" ) , GURL ( chrome : : kChromeUIVersionURL ) ) ;\n histogram_tester_ . ExpectTotalCount ( internal : : kHttpEngagementHistogram , 1 ) ;\n histogram_tester_ . ExpectTotalCount ( internal : : kHttpsEngagementHistogram , 0 ) ;\n FakeUserMetricsUpload ( ) ;\n histogram_tester_ . ExpectTotalCount ( internal : : kHttpsEngagementSessionPercentage , 1 ) ;\n int32_t ratio_bucket = histogram_tester_ . GetAllSamples ( internal : : kHttpsEngagementSessionPercentage ) [ 0 ] . min ;\n EXPECT_EQ ( 0 , ratio_bucket ) ;\n }","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":372247,"func":"cmsBool Done(void)\r\n{\r\n\tjpeg_destroy_decompress(&Decompressor);\r\n\tjpeg_destroy_compress(&Compressor);\r\n\treturn fclose(InFile) + fclose(OutFile);\r\n\r\n}\r","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":96945,"func":"libFile(char *base)\n{\n    return expandPath(Strnew_m_charp(w3m_lib_dir(), \"\/\", base, NULL)->ptr);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":223660,"func":"ftrace_snapshot_init(struct ftrace_probe_ops *ops, struct trace_array *tr,\n\t\t     unsigned long ip, void *init_data, void **data)\n{\n\tstruct ftrace_func_mapper *mapper = *data;\n\n\tif (!mapper) {\n\t\tmapper = allocate_ftrace_func_mapper();\n\t\tif (!mapper)\n\t\t\treturn -ENOMEM;\n\t\t*data = mapper;\n\t}\n\n\treturn ftrace_func_mapper_add_ip(mapper, ip, init_data);\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":236828,"func":"bool InputMethodLinuxX11::DispatchFabricatedKeyEvent(\n    const ui::KeyEvent& event) {\n  if (DispatchFabricatedKeyEventPostIME(event.type(), event.key_code(),\n                                        event.flags()))\n    return true;\n\n  if (event.type() == ET_KEY_PRESSED && GetTextInputClient()) {\n    const uint16 ch = event.GetCharacter();\n    if (ch) {\n      GetTextInputClient()->InsertChar(ch, event.flags());\n      return true;\n    }\n  }\n\n  return false;\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":253398,"func":"MagickExport const IndexPacket *GetVirtualIndexesFromNexus(const Cache cache,\n  NexusInfo *nexus_info)\n{\n  CacheInfo\n    *restrict cache_info;\n\n  assert(cache != (Cache) NULL);\n  cache_info=(CacheInfo *) cache;\n  assert(cache_info->signature == MagickSignature);\n  if (cache_info->storage_class == UndefinedClass)\n    return((IndexPacket *) NULL);\n  return(nexus_info->indexes);\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":450449,"func":"static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp,\n\t\t\t\t     struct xdr_stream *xdr,\n\t\t\t\t     void *data)\n{\n\tstruct nfs_open_confirmres *res = data;\n\tstruct compound_hdr hdr;\n\tint status;\n\n\tstatus = decode_compound_hdr(xdr, &hdr);\n\tif (status)\n\t\tgoto out;\n\tstatus = decode_putfh(xdr);\n\tif (status)\n\t\tgoto out;\n\tstatus = decode_open_confirm(xdr, res);\nout:\n\treturn status;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":453752,"func":"static uint32_t dp8393x_wt(dp8393xState *s)\n{\n    return s->regs[SONIC_WT1] << 16 | s->regs[SONIC_WT0];\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":500312,"func":"void qpdf_set_ignore_xref_streams(qpdf_data qpdf, QPDF_BOOL value)\n{\n    QTC::TC(\"qpdf\", \"qpdf-c called qpdf_set_ignore_xref_streams\");\n    qpdf->qpdf->setIgnoreXRefStreams(value);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":485772,"func":"static int snd_pcm_oss_release(struct inode *inode, struct file *file)\n{\n\tstruct snd_pcm *pcm;\n\tstruct snd_pcm_substream *substream;\n\tstruct snd_pcm_oss_file *pcm_oss_file;\n\n\tpcm_oss_file = file->private_data;\n\tsubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];\n\tif (substream == NULL)\n\t\tsubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];\n\tif (snd_BUG_ON(!substream))\n\t\treturn -ENXIO;\n\tpcm = substream->pcm;\n\tif (!pcm->card->shutdown)\n\t\tsnd_pcm_oss_sync(pcm_oss_file);\n\tmutex_lock(&pcm->open_mutex);\n\tsnd_pcm_oss_release_file(pcm_oss_file);\n\tmutex_unlock(&pcm->open_mutex);\n\twake_up(&pcm->open_wait);\n\tmodule_put(pcm->card->module);\n\tsnd_card_file_remove(pcm->card, file);\n\treturn 0;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":406542,"func":"  Settable_routine_parameter *get_settable_routine_parameter()\n  {\n    return this;\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":413603,"func":"static void _fb_rdlock(void)\n{\n\tslurm_mutex_lock(&file_bcast_mutex);\n\twhile (1) {\n\t\tif ((fb_write_wait_lock == 0) && (fb_write_lock == 0)) {\n\t\t\tfb_read_lock++;\n\t\t\tbreak;\n\t\t} else {\t\/* wait for state change and retry *\/\n\t\t\tslurm_cond_wait(&file_bcast_cond, &file_bcast_mutex);\n\t\t}\n\t}\n\tslurm_mutex_unlock(&file_bcast_mutex);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":49387,"func":"static void __exit ip6_tables_fini(void)\n{\n\tnf_unregister_sockopt(&ip6t_sockopts);\n\n\txt_unregister_matches(ip6t_builtin_mt, ARRAY_SIZE(ip6t_builtin_mt));\n\txt_unregister_targets(ip6t_builtin_tg, ARRAY_SIZE(ip6t_builtin_tg));\n\tunregister_pernet_subsys(&ip6_tables_net_ops);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":137813,"func":"int MemFile::getc() {\n  assertx(m_len != -1);\n  return File::getc();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":421252,"func":"void FAST_FUNC udhcp_add_binary_option(struct dhcp_packet *packet, uint8_t *addopt)\n{\n\tunsigned len;\n\tuint8_t *optionptr = packet->options;\n\tunsigned end = udhcp_end_option(optionptr);\n\n\tlen = OPT_DATA + addopt[OPT_LEN];\n\t\/* end position + (option code\/length + addopt length) + end option *\/\n\tif (end + len + 1 >= DHCP_OPTIONS_BUFSIZE) {\n\/\/TODO: learn how to use overflow option if we exhaust packet->options[]\n\t\tbb_error_msg(\"option 0x%02x did not fit into the packet\",\n\t\t\t\taddopt[OPT_CODE]);\n\t\treturn;\n\t}\n\tlog_option(\"adding option\", addopt);\n\tmemcpy(optionptr + end, addopt, len);\n\toptionptr[end + len] = DHCP_END;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":382580,"func":"p_count(p)\nregister struct parse *p;\n{\n\tregister int count = 0;\n\tregister int ndigits = 0;\n\n\twhile (MORE() && my_isdigit(p->charset,PEEK()) && count <= DUPMAX) {\n\t\tcount = count*10 + (GETNEXT() - '0');\n\t\tndigits++;\n\t}\n\n\tif(REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR)) {}\n\treturn(count);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":426678,"func":"    void release() {\n        if (set_) {\n            set_ = false;\n            LeaveCriticalSection(cs_);\n        }\n    }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":510377,"func":"my_decimal *Item_int::val_decimal(my_decimal *decimal_value)\n{\n  int2my_decimal(E_DEC_FATAL_ERROR, value, unsigned_flag, decimal_value);\n  return decimal_value;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":21780,"func":"static int SpoolssAddForm_q ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep _U_ ) {\n dcerpc_call_value * dcv = ( dcerpc_call_value * ) di -> call_data ;\n guint32 level ;\n proto_item * hidden_item ;\n hidden_item = proto_tree_add_uint ( tree , hf_form , tvb , offset , 0 , 1 ) ;\n PROTO_ITEM_SET_HIDDEN ( hidden_item ) ;\n offset = dissect_nt_policy_hnd ( tvb , offset , pinfo , tree , di , drep , hf_hnd , NULL , NULL , FALSE , FALSE ) ;\n offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_form_level , & level ) ;\n col_append_fstr ( pinfo -> cinfo , COL_INFO , \", level %d\" , level ) ;\n if ( ! pinfo -> fd -> flags . visited ) {\n dcv -> se_data = GUINT_TO_POINTER ( ( int ) level ) ;\n }\n offset = dissect_FORM_CTR ( tvb , offset , pinfo , tree , di , drep ) ;\n return offset ;\n }","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":460567,"func":"static int parseTreeDelete (\n\tOperation *op,\n\tSlapReply *rs,\n\tLDAPControl *ctrl )\n{\n\tif ( op->o_tree_delete != SLAP_CONTROL_NONE ) {\n\t\trs->sr_text = \"treeDelete control specified multiple times\";\n\t\treturn LDAP_PROTOCOL_ERROR;\n\t}\n\n\tif ( !BER_BVISNULL( &ctrl->ldctl_value )) {\n\t\trs->sr_text = \"treeDelete control value not absent\";\n\t\treturn LDAP_PROTOCOL_ERROR;\n\t}\n\n\top->o_tree_delete = ctrl->ldctl_iscritical\n\t\t? SLAP_CONTROL_CRITICAL\n\t\t: SLAP_CONTROL_NONCRITICAL;\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":493057,"func":"void PM_io_parser<PMDEC>::dump(const PMDEC& D, std::ostream& os)\n{ PM_io_parser<PMDEC> Out(os,D);\n  Out.print();\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":283081,"func":"  explicit TaskManagerTableModel(TaskManagerModel* model)\n      : model_(model),\n        observer_(NULL) {\n    model_->AddObserver(this);\n  }\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":25869,"func":"static VALUE mHash_to_json ( int argc , VALUE * argv , VALUE self ) {\n GENERATE_JSON ( object ) ;\n }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":20240,"func":"void unireg_end ( void ) {\n clean_up ( 1 ) ;\n my_thread_end ( ) ;\n # if defined ( SIGNALS_DONT_BREAK_READ ) exit ( 0 ) ;\n # else pthread_exit ( 0 ) ;\n # endif }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":84061,"func":"static int ntop_get_interface_local_flows_info(lua_State* vm)  { return(ntop_get_interface_flows(vm, location_local_only));   }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":289227,"func":"static void stroke_unroute ( private_stroke_socket_t * this , stroke_msg_t * msg , FILE * out ) {\n pop_string ( msg , & msg -> terminate . name ) ;\n DBG1 ( DBG_CFG , \"received stroke: unroute '%s'\" , msg -> route . name ) ;\n this -> control -> unroute ( this -> control , msg , out ) ;\n }","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":82075,"func":"find_lively_task_by_vpid(pid_t vpid)\n{\n\tstruct task_struct *task;\n\tint err;\n\n\trcu_read_lock();\n\tif (!vpid)\n\t\ttask = current;\n\telse\n\t\ttask = find_task_by_vpid(vpid);\n\tif (task)\n\t\tget_task_struct(task);\n\trcu_read_unlock();\n\n\tif (!task)\n\t\treturn ERR_PTR(-ESRCH);\n\n\t\/* Reuse ptrace permission checks for now. *\/\n\terr = -EACCES;\n\tif (!ptrace_may_access(task, PTRACE_MODE_READ))\n\t\tgoto errout;\n\n\treturn task;\nerrout:\n\tput_task_struct(task);\n\treturn ERR_PTR(err);\n\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":296474,"func":"static __always_inline bool bpf_tree_less(struct latch_tree_node *a,\n\t\t\t\t\t  struct latch_tree_node *b)\n{\n\treturn bpf_get_prog_addr_start(a) < bpf_get_prog_addr_start(b);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":446682,"func":"virDomainHostdevMatchCapsMisc(virDomainHostdevDefPtr a,\n                              virDomainHostdevDefPtr b)\n{\n    return STREQ_NULLABLE(a->source.caps.u.misc.chardev,\n                          b->source.caps.u.misc.chardev);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":255640,"func":"int jpc_bitstream_putbits(jpc_bitstream_t *bitstream, int n, long v)\n{\n\tint m;\n\n\t\/* We can reliably put at most 31 bits since ISO\/IEC 9899 only\n\t  guarantees that a long can represent values up to 2^31-1. *\/\n\tassert(n >= 0 && n < 32);\n\t\/* Ensure that only the bits to be output are nonzero. *\/\n\tassert(!(v & (~JAS_ONES(n))));\n\n\t\/* Put the desired number of bits to the specified bit stream. *\/\n\tm = n - 1;\n\twhile (--n >= 0) {\n\t\tif (jpc_bitstream_putbit(bitstream, (v >> m) & 1) == EOF) {\n\t\t\treturn EOF;\n\t\t}\n\t\tv <<= 1;\n\t}\n\treturn 0;\n}","target":1,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":457134,"func":"p11_rpc_buffer_get_attribute_array_value (p11_buffer *buffer,\n\t\t\t\t\t  size_t *offset,\n\t\t\t\t\t  void *value,\n\t\t\t\t\t  CK_ULONG *value_length)\n{\n\tuint32_t count, i;\n\tCK_ATTRIBUTE *attr, temp;\n\n\tif (!p11_rpc_buffer_get_uint32 (buffer, offset, &count))\n\t\treturn false;\n\n\tif (!value) {\n\t\tmemset (&temp, 0, sizeof (CK_ATTRIBUTE));\n\t\tattr = &temp;\n\t} else\n\t\tattr = value;\n\n\tfor (i = 0; i < count; i++) {\n\t\tif (!p11_rpc_buffer_get_attribute (buffer, offset, attr))\n\t\t\treturn false;\n\t\tif (value)\n\t\t\tattr++;\n\t}\n\n\tif (value_length)\n\t\t*value_length = count * sizeof (CK_ATTRIBUTE);\n\n\treturn true;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":97873,"func":"const char *proxytype(proxytypes_t proxytype)\n{\n\tint i;\n\n\tfor (i = 0; proxynames[i].name; i++)\n\t\tif (proxynames[i].proxytype == proxytype)\n\t\t\treturn proxynames[i].name;\n\n\treturn \"invalid\";\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":168283,"func":"bool GLES2DecoderImpl::HasMoreIdleWork() const {\n  return !pending_readpixel_fences_.empty() ||\n         gpu_tracer_->HasTracesToProcess() ||\n         !texture_refs_pending_destruction_.empty();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":47170,"func":"void inet_netconf_notify_devconf(struct net *net, int type, int ifindex,\n\t\t\t\t struct ipv4_devconf *devconf)\n{\n\tstruct sk_buff *skb;\n\tint err = -ENOBUFS;\n\n\tskb = nlmsg_new(inet_netconf_msgsize_devconf(type), GFP_ATOMIC);\n\tif (!skb)\n\t\tgoto errout;\n\n\terr = inet_netconf_fill_devconf(skb, ifindex, devconf, 0, 0,\n\t\t\t\t\tRTM_NEWNETCONF, 0, type);\n\tif (err < 0) {\n\t\t\/* -EMSGSIZE implies BUG in inet_netconf_msgsize_devconf() *\/\n\t\tWARN_ON(err == -EMSGSIZE);\n\t\tkfree_skb(skb);\n\t\tgoto errout;\n\t}\n\trtnl_notify(skb, net, 0, RTNLGRP_IPV4_NETCONF, NULL, GFP_ATOMIC);\n\treturn;\nerrout:\n\tif (err < 0)\n\t\trtnl_set_sk_err(net, RTNLGRP_IPV4_NETCONF, err);\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":456785,"func":"__add_partial(struct kmem_cache_node *n, struct page *page, int tail)\n{\n\tn->nr_partial++;\n\tif (tail == DEACTIVATE_TO_TAIL)\n\t\tlist_add_tail(&page->slab_list, &n->partial);\n\telse\n\t\tlist_add(&page->slab_list, &n->partial);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":282447,"func":"  virtual void AnimationProgressed(const ui::Animation* animation) {\n    TabAnimation::AnimationProgressed(animation);\n\n    int x = animation_.CurrentValueBetween(start_bounds_.x(),\n                                           target_bounds_.x());\n    int width = animation_.CurrentValueBetween(start_bounds_.width(),\n                                               target_bounds_.width());\n    gfx::Rect tab_bounds(x, start_bounds_.y(), width,\n                         start_bounds_.height());\n    tabstrip_->SetTabBounds(tab_, tab_bounds);\n  }\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":193867,"func":"    EntryFolderFeature(bool is_machine_root,\n                       bool is_arbitrary_sync_folder,\n                       bool is_external_media)\n        : is_machine_root(is_machine_root),\n          is_arbitrary_sync_folder(is_arbitrary_sync_folder),\n          is_external_media(is_external_media) {}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":161340,"func":"static void virtio_serial_port_class_init(ObjectClass *klass, void *data)\n{\n    DeviceClass *k = DEVICE_CLASS(klass);\n\n    set_bit(DEVICE_CATEGORY_INPUT, k->categories);\n    k->bus_type = TYPE_VIRTIO_SERIAL_BUS;\n    k->realize = virtser_port_device_realize;\n    k->unrealize = virtser_port_device_unrealize;\n    k->props = virtser_props;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":57347,"func":"static int nl80211_valid_4addr(struct cfg80211_registered_device *rdev,\n\t\t\t       struct net_device *netdev, u8 use_4addr,\n\t\t\t       enum nl80211_iftype iftype)\n{\n\tif (!use_4addr) {\n\t\tif (netdev && (netdev->priv_flags & IFF_BRIDGE_PORT))\n\t\t\treturn -EBUSY;\n\t\treturn 0;\n\t}\n\n\tswitch (iftype) {\n\tcase NL80211_IFTYPE_AP_VLAN:\n\t\tif (rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase NL80211_IFTYPE_STATION:\n\t\tif (rdev->wiphy.flags & WIPHY_FLAG_4ADDR_STATION)\n\t\t\treturn 0;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn -EOPNOTSUPP;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":393971,"func":"static int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_us)\n{\n\tu64 rt_runtime, rt_period;\n\n\trt_period = rt_period_us * NSEC_PER_USEC;\n\trt_runtime = tg->rt_bandwidth.rt_runtime;\n\n\treturn tg_set_rt_bandwidth(tg, rt_period, rt_runtime);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":131933,"func":"static int binder_put_node_cmd(struct binder_proc *proc,\n\t\t\t       struct binder_thread *thread,\n\t\t\t       void __user **ptrp,\n\t\t\t       binder_uintptr_t node_ptr,\n\t\t\t       binder_uintptr_t node_cookie,\n\t\t\t       int node_debug_id,\n\t\t\t       uint32_t cmd, const char *cmd_name)\n{\n\tvoid __user *ptr = *ptrp;\n\n\tif (put_user(cmd, (uint32_t __user *)ptr))\n\t\treturn -EFAULT;\n\tptr += sizeof(uint32_t);\n\n\tif (put_user(node_ptr, (binder_uintptr_t __user *)ptr))\n\t\treturn -EFAULT;\n\tptr += sizeof(binder_uintptr_t);\n\n\tif (put_user(node_cookie, (binder_uintptr_t __user *)ptr))\n\t\treturn -EFAULT;\n\tptr += sizeof(binder_uintptr_t);\n\n\tbinder_stat_br(proc, thread, cmd);\n\tbinder_debug(BINDER_DEBUG_USER_REFS, \"%d:%d %s %d u%016llx c%016llx\\n\",\n\t\t     proc->pid, thread->pid, cmd_name, node_debug_id,\n\t\t     (u64)node_ptr, (u64)node_cookie);\n\n\t*ptrp = ptr;\n\treturn 0;\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":382482,"func":"prepare_for_client_read(void)\n{\n\tif (DoingCommandRead)\n\t{\n\t\t\/* Enable immediate processing of asynchronous signals *\/\n\t\tEnableNotifyInterrupt();\n\t\tEnableCatchupInterrupt();\n\n\t\t\/* Allow die interrupts to be processed while waiting *\/\n\t\tImmediateInterruptOK = true;\n\n\t\t\/* And don't forget to detect one that already arrived *\/\n\t\tCHECK_FOR_INTERRUPTS();\n\t}\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":223277,"func":"gx_dc_binary_masked_load(gx_device_color * pdevc, const gs_gstate * pgs,\n                         gx_device * dev, gs_color_select_t select)\n{\n    int code = (*gx_dc_type_data_ht_binary.load) (pdevc, pgs, dev, select);\n\n    if (code < 0)\n        return code;\n    FINISH_PATTERN_LOAD\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":323463,"func":"void bdrv_io_limits_enable(BlockDriverState *bs)\n\n{\n\n    qemu_co_queue_init(&bs->throttled_reqs);\n\n    bs->block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs);\n\n    bs->io_limits_enabled = true;\n\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":214706,"func":"double EglRenderingVDAClient::frames_per_second() {\n  base::TimeDelta delta = last_frame_delivered_ticks_ - initialize_done_ticks_;\n  if (delta.InSecondsF() == 0)\n    return 0;\n  return num_decoded_frames_ \/ delta.InSecondsF();\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":331657,"func":"int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s)\n{\n    if (s->codec) {\n        ff_AMediaCodec_delete(s->codec);\n        s->codec = NULL;\n    }\n    if (s->format) {\n        ff_AMediaFormat_delete(s->format);\n        s->format = NULL;\n    }\n    return 0;\n}","target":1,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":427621,"func":"push_handlers (void)\n{\n\torig_error_handler = TIFFSetErrorHandler (NULL);\n\torig_warning_handler = TIFFSetWarningHandler (NULL);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":290322,"func":"void xps_parse_brush ( xps_document * doc , const fz_matrix * ctm , const fz_rect * area , char * base_uri , xps_resource * dict , fz_xml * node ) {\n if ( doc -> cookie && doc -> cookie -> abort ) return ;\n if ( ! strcmp ( fz_xml_tag ( node ) , \"ImageBrush\" ) ) xps_parse_image_brush ( doc , ctm , area , base_uri , dict , node ) ;\n else if ( ! strcmp ( fz_xml_tag ( node ) , \"VisualBrush\" ) ) xps_parse_visual_brush ( doc , ctm , area , base_uri , dict , node ) ;\n else if ( ! strcmp ( fz_xml_tag ( node ) , \"LinearGradientBrush\" ) ) xps_parse_linear_gradient_brush ( doc , ctm , area , base_uri , dict , node ) ;\n else if ( ! strcmp ( fz_xml_tag ( node ) , \"RadialGradientBrush\" ) ) xps_parse_radial_gradient_brush ( doc , ctm , area , base_uri , dict , node ) ;\n else fz_warn ( doc -> ctx , \"unknown brush tag: %s\" , fz_xml_tag ( node ) ) ;\n }","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":119267,"func":"extern \"C\" char *my_demangle(const char *mangled_name, int *status)\n{\n  return abi::__cxa_demangle(mangled_name, NULL, NULL, status);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":308761,"func":"float AXNodeObject::stepValueForRange() const {\n  if (!isNativeSlider())\n    return 0.0;\n\n  Decimal step =\n      toHTMLInputElement(*getNode()).createStepRange(RejectAny).step();\n  return step.toString().toFloat();\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":252097,"func":"static void sapi_update_response_code(int ncode TSRMLS_DC)\n{\n\t\/* if the status code did not change, we do not want\n\t   to change the status line, and no need to change the code *\/\n\tif (SG(sapi_headers).http_response_code == ncode) {\n\t\treturn;\n\t}\n\n\tif (SG(sapi_headers).http_status_line) {\n\t\tefree(SG(sapi_headers).http_status_line);\n\t\tSG(sapi_headers).http_status_line = NULL;\n\t}\n\tSG(sapi_headers).http_response_code = ncode;\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":67067,"func":"void test_checkout_nasty__dotgit_alternate_data_stream(void)\n{\n\ttest_checkout_fails(\"refs\/heads\/dotgit_alternate_data_stream\", \".git\/dummy-file\");\n\ttest_checkout_fails(\"refs\/heads\/dotgit_alternate_data_stream\", \".git::$INDEX_ALLOCATION\/dummy-file\");\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":470330,"func":"const char *__get_arch(r_bin_le_obj_t *bin) {\n\tswitch (bin->header->cpu) {\n\tcase 1:\n\tcase 2:\n\tcase 3:\n\t\treturn \"x86\";\n\tcase 0x20:\n\tcase 0x21:\n\t\treturn \"i860\";\n\tcase 0x40:\n\tcase 0x41:\n\tcase 0x42:\n\t\treturn \"mips\";\n\tdefault:\n\t\treturn \"Unknown\";\n\t}\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":33462,"func":"static pyc_object *get_ref_object(RBuffer *buffer) {\n\tbool error = false;\n\tut32 index = get_ut32 (buffer, &error);\n\tif (error) {\n\t\treturn NULL;\n\t}\n\tif (index >= r_list_length (refs)) {\n\t\treturn NULL;\n\t}\n\tpyc_object *obj = r_list_get_n (refs, index);\n\treturn obj? copy_object (obj): NULL;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":413144,"func":"catch(std::exception& e)\n{\n  cerr<<\"Receiver function died: \"<<e.what()<<endl;\n  exit(1);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":276377,"func":"bool Document::needsLayoutTreeUpdateForNode(const Node& node) const\n{\n    if (!node.canParticipateInFlatTree())\n        return false;\n    if (!needsLayoutTreeUpdate())\n        return false;\n    if (!node.inShadowIncludingDocument())\n        return false;\n\n    if (needsFullLayoutTreeUpdate() || node.needsStyleRecalc() || node.needsStyleInvalidation())\n        return true;\n    for (const ContainerNode* ancestor = LayoutTreeBuilderTraversal::parent(node); ancestor; ancestor = LayoutTreeBuilderTraversal::parent(*ancestor)) {\n        if (ancestor->needsStyleRecalc() || ancestor->needsStyleInvalidation() || ancestor->needsAdjacentStyleRecalc())\n            return true;\n    }\n    return false;\n}\n","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":95935,"func":"u32 cdk_sk_get_keyid(cdk_pkt_seckey_t sk, u32 * keyid)\n{\n\tu32 lowbits = 0;\n\n\tif (sk && sk->pk) {\n\t\tlowbits = cdk_pk_get_keyid(sk->pk, keyid);\n\t\tsk->keyid[0] = sk->pk->keyid[0];\n\t\tsk->keyid[1] = sk->pk->keyid[1];\n\t}\n\n\treturn lowbits;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":484364,"func":"void JBIG2Stream::resetGenericStats(unsigned int templ, JArithmeticDecoderStats *prevStats)\n{\n    int size;\n\n    size = contextSize[templ];\n    if (prevStats && prevStats->getContextSize() == size) {\n        if (genericRegionStats->getContextSize() == size) {\n            genericRegionStats->copyFrom(prevStats);\n        } else {\n            delete genericRegionStats;\n            genericRegionStats = prevStats->copy();\n        }\n    } else {\n        if (genericRegionStats->getContextSize() == size) {\n            genericRegionStats->reset();\n        } else {\n            delete genericRegionStats;\n            genericRegionStats = new JArithmeticDecoderStats(1 << size);\n        }\n    }\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":227093,"func":"void StackTrace::OutputToStream(std::ostream* os) const {\n  StreamBacktraceOutputHandler handler(os);\n  ProcessBacktrace(trace_, count_, &handler);\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":24431,"func":"void main_file_cleanup ( main_file * xfile ) {\n XD3_ASSERT ( xfile != NULL ) ;\n if ( main_file_isopen ( xfile ) ) {\n main_file_close ( xfile ) ;\n }\n if ( xfile -> snprintf_buf != NULL ) {\n main_free ( xfile -> snprintf_buf ) ;\n xfile -> snprintf_buf = NULL ;\n }\n if ( xfile -> filename_copy != NULL ) {\n main_free ( xfile -> filename_copy ) ;\n xfile -> filename_copy = NULL ;\n }\n }","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":138474,"func":"static HuffReader *get_huffman_group(WebPContext *s, ImageContext *img,\n                                     int x, int y)\n{\n    ImageContext *gimg = &s->image[IMAGE_ROLE_ENTROPY];\n    int group = 0;\n\n    if (gimg->size_reduction > 0) {\n        int group_x = x >> gimg->size_reduction;\n        int group_y = y >> gimg->size_reduction;\n        int g0      = GET_PIXEL_COMP(gimg->frame, group_x, group_y, 1);\n        int g1      = GET_PIXEL_COMP(gimg->frame, group_x, group_y, 2);\n        group       = g0 << 8 | g1;\n    }\n\n    return &img->huffman_groups[group * HUFFMAN_CODES_PER_META_CODE];\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":214203,"func":"  TopSitesImpl* top_sites() { return top_sites_impl_.get(); }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":105582,"func":"void DeallocatorWrapperFunc(void* data, size_t len, void* dlmt_vptr) {\n  TFE_CallDLManagedTensorDeleter(dlmt_vptr);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":87965,"func":"static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)\n{\n  MSLInfo\n    *msl_info;\n\n  \/*\n    Receiving some ignorable whitespaces from the parser.\n  *\/\n  (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n    \"  SAX.ignorableWhitespace(%.30s, %d)\",c,length);\n  msl_info=(MSLInfo *) context;\n  (void) msl_info;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":184190,"func":"static void checkMutexEnter(sqlite3_mutex *p){\n  CheckMutex *pCheck = (CheckMutex*)p;\n  if( pCheck->iType==SQLITE_MUTEX_WARNONCONTENTION ){\n    if( SQLITE_OK==pGlobalMutexMethods->xMutexTry(pCheck->mutex) ){\n      return;\n    }\n    sqlite3_log(SQLITE_MISUSE,\n        \"illegal multi-threaded access to database connection\"\n    );\n  }\n  pGlobalMutexMethods->xMutexEnter(pCheck->mutex);\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":231599,"func":"  bool ScriptOnly(const Extension* extension, const GURL& url,\n                  const GURL& top_url, int tab_id) {\n    return AllowedScript(extension, url, top_url, tab_id) &&\n           !extension->permissions_data()->CanCaptureVisiblePage(tab_id, NULL);\n  }\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":264719,"func":"DEFUN(deletePrevBuf, DELETE_PREVBUF, \"Delete previous buffer (mainly for local CGI-scripts)\")\n{\n    Buffer *buf = Currentbuf->nextBuffer;\n    if (buf)\n\tdelBuffer(buf);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":117310,"func":"void streamEncodeID(void *buf, streamID *id) {\n    uint64_t e[2];\n    e[0] = htonu64(id->ms);\n    e[1] = htonu64(id->seq);\n    memcpy(buf,e,sizeof(e));\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":420455,"func":"void CLASS process_Sony_0x9403(uchar *buf, ushort len)\n{\n  if (len < 6)\n    return;\n  uchar bufx = SonySubstitution[buf[4]];\n  if ((bufx == 0x00) || (bufx == 0x94))\n    return;\n\n  imgdata.other.SensorTemperature = (float)((short)SonySubstitution[buf[5]]);\n\n  return;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":508734,"func":"_set_source_rsvg_solid_colour (RsvgDrawingCtx * ctx,\n                               RsvgSolidColour * colour, guint8 opacity, guint32 current_colour)\n{\n    RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);\n    cairo_t *cr = render->cr;\n    guint32 argb = colour->argb;\n    double r, g, b, a;\n\n    if (colour->currentcolour)\n        argb = current_colour;\n\n    r = ((argb >> 16) & 0xff) \/ 255.0;\n    g = ((argb >>  8) & 0xff) \/ 255.0;\n    b = ((argb >>  0) & 0xff) \/ 255.0;\n    a =  (argb >> 24) \/ 255.0 * (opacity \/ 255.0);\n\n    cairo_set_source_rgba (cr, r, g, b, a);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":287798,"func":" bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v)\n {\n        uint8_t tmp = 0;\n       asn1_start_tag(data, ASN1_BOOLEAN);\n       asn1_read_uint8(data, &tmp);\n        if (tmp == 0xFF) {\n                *v = true;\n       } else {\n               *v = false;\n        }\n       asn1_end_tag(data);\n       return !data->has_error;\n }\n","target":1,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":41276,"func":"static void rfcomm_tty_throttle(struct tty_struct *tty)\n{\n\tstruct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;\n\n\tBT_DBG(\"tty %p dev %p\", tty, dev);\n\n\trfcomm_dlc_throttle(dev->dlc);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":233976,"func":"static bool ExecuteJustifyRight(LocalFrame& frame,\n                                Event*,\n                                EditorCommandSource source,\n                                const String&) {\n  return ExecuteApplyParagraphStyle(frame, source,\n                                    InputEvent::InputType::kFormatJustifyRight,\n                                    CSSPropertyTextAlign, \"right\");\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":120066,"func":"void ByteCodeGenerator::EmitClassConstructorEndCode(FuncInfo *funcInfo)\n{\n    if (funcInfo->thisPointerRegister != Js::Constants::NoRegister)\n    {\n        \/\/ We need to try and load 'this' from the scope slot, if there is one.\n        EmitScopeSlotLoadThis(funcInfo, funcInfo->thisPointerRegister);\n        this->Writer()->Reg2(Js::OpCode::Ld_A, ByteCodeGenerator::ReturnRegister, funcInfo->thisPointerRegister);\n    }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":415708,"func":"char *put_dec_full8(char *buf, unsigned r)\n{\n\tunsigned q;\n\n\t\/* 0 <= r < 10^8 *\/\n\tq = (r * (u64)0x28f5c29) >> 32;\n\t*((u16 *)buf) = decpair[r - 100*q];\n\tbuf += 2;\n\n\t\/* 0 <= q < 10^6 *\/\n\tr = (q * (u64)0x28f5c29) >> 32;\n\t*((u16 *)buf) = decpair[q - 100*r];\n\tbuf += 2;\n\n\t\/* 0 <= r < 10^4 *\/\n\tq = (r * 0x147b) >> 19;\n\t*((u16 *)buf) = decpair[r - 100*q];\n\tbuf += 2;\n\n\t\/* 0 <= q < 100 *\/\n\t*((u16 *)buf) = decpair[q];\n\tbuf += 2;\n\treturn buf;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":31578,"func":"  GraphConstructor(const Options& opts, Graph* g, ShapeRefiner* refiner,\n                   std::vector<std::pair<Node*, int>>* return_tensors,\n                   std::vector<Node*>* return_nodes,\n                   std::vector<SafeTensorId>* missing_unused_input_map_keys)\n      : opts_(opts),\n        g_(g),\n        original_versions_(g->versions()),\n        prefix_(opts.prefix),\n        refiner_(refiner),\n        return_tensors_(return_tensors),\n        return_nodes_(return_nodes),\n        missing_unused_input_map_keys_(missing_unused_input_map_keys) {}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":167826,"func":"static int ssh_comp_none_block(void *handle, unsigned char *block, int len,\n\t\t\t       unsigned char **outblock, int *outlen)\n{\n    return 0;\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":209757,"func":"bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const\n{\n    if (isFloating() || (isInlineBlockOrInlineTable() && !isMarquee()))\n        return true;\n\n    if (logicalWidth.type() == Intrinsic)\n        return true;\n\n    if (parent()->isMarquee()) {\n        EMarqueeDirection dir = parent()->style()->marqueeDirection();\n        if (dir == MAUTO || dir == MFORWARD || dir == MBACKWARD || dir == MLEFT || dir == MRIGHT)\n            return true;\n    }\n\n    if (parent()->isFlexibleBox()) {\n        if (!parent()->style()->isColumnFlexDirection() || parent()->style()->flexWrap() != FlexNoWrap)\n            return true;\n        if (!columnFlexItemHasStretchAlignment(this))\n            return true;\n    }\n\n    if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() == HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH))\n        return true;\n\n    if (logicalWidth.isAuto() && !isStretchingColumnFlexItem(this) && autoWidthShouldFitContent())\n        return true;\n\n    if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode())\n        return true;\n\n    return false;\n}\n","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":318776,"func":"static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,\n\n                                          AVFilterBufferRef *ref)\n\n{\n\n    AVFilterLink *outlink = ctx->outputs[0];\n\n    AVFilterBufferRef *buf;\n\n    int channels, data_size, i;\n\n\n\n    switch (outlink->type) {\n\n\n\n    case AVMEDIA_TYPE_VIDEO:\n\n        buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,\n\n                                        ref->video->w, ref->video->h);\n\n\n\n        av_image_copy(buf->data, buf->linesize,\n\n                      (void*)ref->data, ref->linesize,\n\n                      ref->format, ref->video->w, ref->video->h);\n\n        break;\n\n\n\n    case AVMEDIA_TYPE_AUDIO:\n\n        buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,\n\n                                        ref->audio->nb_samples);\n\n\n\n        channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);\n\n        av_samples_copy(buf->extended_data, ref->buf->extended_data,\n\n                        0, 0, ref->audio->nb_samples,\n\n                        channels,\n\n                        ref->format);\n\n        break;\n\n\n\n    default:\n\n\n    }\n\n    avfilter_copy_buffer_ref_props(buf, ref);\n\n    return buf;\n\n}","target":1,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":57205,"func":"static QSvgNode *createTextAreaNode(QSvgNode *parent,\n                                    const QXmlStreamAttributes &attributes,\n                                    QSvgHandler *handler)\n{\n    QSvgText *node = static_cast<QSvgText *>(createTextNode(parent, attributes, handler));\n    if (node) {\n        QSvgHandler::LengthType type;\n        qreal width = parseLength(attributes.value(QLatin1String(\"width\")), type, handler);\n        qreal height = parseLength(attributes.value(QLatin1String(\"height\")), type, handler);\n        node->setTextArea(QSizeF(width, height));\n    }\n    return node;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":196691,"func":"ofproto_group_lookup__(const struct ofproto *ofproto, uint32_t group_id,\n                       ovs_version_t version)\n{\n    struct ofgroup *group;\n\n    CMAP_FOR_EACH_WITH_HASH (group, cmap_node, hash_int(group_id, 0),\n                             &ofproto->groups) {\n        if (group->group_id == group_id\n            && versions_visible_in_version(&group->versions, version)) {\n            return group;\n        }\n    }\n\n    return NULL;\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":11698,"func":" void ResetPaddingKeyForTesting() {\n  *GetPaddingKey() = SymmetricKey::GenerateRandomKey(kPaddingKeyAlgorithm, 128);\n }\n","target":1,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":520548,"func":"  Field *tmp_table_field_from_field_type(TABLE *table)\n  {\n    DBUG_ASSERT(is_fixed());\n    const Type_handler *h= type_handler()->type_handler_for_tmp_table(this);\n    return h->make_and_init_table_field(&name, Record_addr(maybe_null),\n                                        *this, table);\n  }","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":124443,"func":"CModule::EModRet CModule::OnUserCTCPMessage(CCTCPMessage& Message) {\n    CString sTarget = Message.GetTarget();\n    CString sText = Message.GetText();\n    EModRet ret = OnUserCTCP(sTarget, sText);\n    Message.SetTarget(sTarget);\n    Message.SetText(sText);\n    return ret;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":139876,"func":"f_byteidx(typval_T *argvars, typval_T *rettv)\n{\n    byteidx(argvars, rettv, FALSE);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":444022,"func":"Http::Status ServerConnectionImpl::dispatch(Buffer::Instance& data) {\n  \/\/ TODO(#10878): Remove this wrapper when exception removal is complete. innerDispatch may either\n  \/\/ throw an exception or return an error status. The utility wrapper catches exceptions and\n  \/\/ converts them to error statuses.\n  return Http::Utility::exceptionToStatus(\n      [&](Buffer::Instance& data) -> Http::Status { return innerDispatch(data); }, data);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":265844,"func":"static int attach_auth_trunc(struct xfrm_algo_auth **algpp, u8 *props,\n\t\t\t     struct nlattr *rta)\n{\n\tstruct xfrm_algo_auth *p, *ualg;\n\tstruct xfrm_algo_desc *algo;\n\n\tif (!rta)\n\t\treturn 0;\n\n\tualg = nla_data(rta);\n\n\talgo = xfrm_aalg_get_byname(ualg->alg_name, 1);\n\tif (!algo)\n\t\treturn -ENOSYS;\n\tif (ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits)\n\t\treturn -EINVAL;\n\t*props = algo->desc.sadb_alg_id;\n\n\tp = kmemdup(ualg, xfrm_alg_auth_len(ualg), GFP_KERNEL);\n\tif (!p)\n\t\treturn -ENOMEM;\n\n\tstrcpy(p->alg_name, algo->name);\n\tif (!p->alg_trunc_len)\n\t\tp->alg_trunc_len = algo->uinfo.auth.icv_truncbits;\n\n\t*algpp = p;\n\treturn 0;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":2326,"func":"nvmet_fc_find_target_queue(struct nvmet_fc_tgtport *tgtport,\n\t\t\t\tu64 connection_id)\n{\n\tstruct nvmet_fc_tgt_assoc *assoc;\n\tstruct nvmet_fc_tgt_queue *queue;\n\tu64 association_id = nvmet_fc_getassociationid(connection_id);\n\tu16 qid = nvmet_fc_getqueueid(connection_id);\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&tgtport->lock, flags);\n\tlist_for_each_entry(assoc, &tgtport->assoc_list, a_list) {\n\t\tif (association_id == assoc->association_id) {\n\t\t\tqueue = assoc->queues[qid];\n\t\t\tif (queue &&\n\t\t\t    (!atomic_read(&queue->connected) ||\n\t\t\t     !nvmet_fc_tgt_q_get(queue)))\n\t\t\t\tqueue = NULL;\n\t\t\tspin_unlock_irqrestore(&tgtport->lock, flags);\n\t\t\treturn queue;\n\t\t}\n\t}\n\tspin_unlock_irqrestore(&tgtport->lock, flags);\n\treturn NULL;\n}","target":1,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":247488,"func":"void CL_ShellExecute_URL_f( void ) {\n\tqboolean doexit;\n\n\tCom_DPrintf( \"CL_ShellExecute_URL_f\\n\" );\n\n\tif ( Q_stricmp( Cmd_Argv( 1 ),\"open\" ) ) {\n\t\tCom_DPrintf( \"invalid CL_ShellExecute_URL_f syntax (shellExecute \\\"open\\\" <url> <doExit>)\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() < 4 ) {\n\t\tdoexit = qtrue;\n\t} else {\n\t\tdoexit = (qboolean)( atoi( Cmd_Argv( 3 ) ) );\n\t}\n\n\tSys_OpenURL( Cmd_Argv( 2 ),doexit );\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":43886,"func":"int imap_cmd_start(struct ImapAccountData *adata, const char *cmdstr)\n{\n  return cmd_start(adata, cmdstr, IMAP_CMD_NO_FLAGS);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":485506,"func":"static void nf_tables_unregister_hook(struct net *net,\n\t\t\t\t      const struct nft_table *table,\n\t\t\t\t      struct nft_chain *chain)\n{\n\treturn __nf_tables_unregister_hook(net, table, chain, false);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":109521,"func":"TfLiteRegistration* Register_DEPTH_TO_SPACE_REF() {\n  static TfLiteRegistration r = {\n      nullptr, nullptr, depth_to_space::Prepare,\n      depth_to_space::Eval<depth_to_space::kReference>};\n  return &r;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":420693,"func":"static int h2c_handle_goaway(struct h2c *h2c)\n{\n\tint error;\n\tint last;\n\n\tif (h2c->dsi != 0) {\n\t\terror = H2_ERR_PROTOCOL_ERROR;\n\t\tgoto conn_err;\n\t}\n\n\tif (h2c->dfl < 8) {\n\t\terror = H2_ERR_FRAME_SIZE_ERROR;\n\t\tgoto conn_err;\n\t}\n\n\t\/* process full frame only *\/\n\tif (b_data(&h2c->dbuf) < h2c->dfl)\n\t\treturn 0;\n\n\tlast = h2_get_n32(&h2c->dbuf, 0);\n\th2c->errcode = h2_get_n32(&h2c->dbuf, 4);\n\th2_wake_some_streams(h2c, last, CS_FL_ERR_PENDING);\n\tif (h2c->last_sid < 0)\n\t\th2c->last_sid = last;\n\treturn 1;\n\n conn_err:\n\th2c_error(h2c, error);\n\treturn 0;\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":229262,"func":"void RenderFrameImpl::SendFailedProvisionalLoad(\n    const blink::WebURLRequest& request,\n    const WebURLError& error,\n    blink::WebLocalFrame* frame) {\n  bool show_repost_interstitial =\n      (error.reason() == net::ERR_CACHE_MISS &&\n       base::EqualsASCII(request.HttpMethod().Utf16(), \"POST\"));\n\n  FrameHostMsg_DidFailProvisionalLoadWithError_Params params;\n  params.error_code = error.reason();\n  GetContentClient()->renderer()->GetErrorDescription(\n      request, error, ¶ms.error_description);\n  params.url = error.url(),\n  params.showing_repost_interstitial = show_repost_interstitial;\n  Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params));\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":24150,"func":"static void _setWithOids ( ArchiveHandle * AH , TocEntry * te ) {\n if ( AH -> currWithOids != te -> withOids ) {\n _doSetWithOids ( AH , te -> withOids ) ;\n AH -> currWithOids = te -> withOids ;\n }\n }","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":241527,"func":"bool ResourceDispatcherHost::Read(URLRequest* request, int* bytes_read) {\n  ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);\n  DCHECK(!info->is_paused());\n\n  net::IOBuffer* buf;\n  int buf_size;\n  if (!info->resource_handler()->OnWillRead(info->request_id(),\n                                            &buf, &buf_size, -1)) {\n    return false;\n  }\n\n  DCHECK(buf);\n  DCHECK(buf_size > 0);\n\n  info->set_has_started_reading(true);\n  return request->Read(buf, buf_size, bytes_read);\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":42606,"func":"COMPS_HSList* comps_objmrtree_keys(COMPS_ObjMRTree * rt) {\n    return __comps_objmrtree_all(rt, 0);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":257288,"func":"TEST ( DownloadPrefsTest , AutoOpenPrefSkipsDangerousFileTypesInPrefs ) {\n const base : : FilePath kDangerousFilePath ( FILE_PATH_LITERAL ( \"\/b\/very-bad.swf\" ) ) ;\n const base : : FilePath kSafeFilePath ( FILE_PATH_LITERAL ( \"\/goodothing-wrong.txt\" ) ) ;\n content : : TestBrowserThreadBundle threads_are_required_for_testing_profile ;\n TestingProfile profile ;\n profile . GetPrefs ( ) -> SetString ( prefs : : kDownloadExtensionsToOpen , \"swf:txt\" ) ;\n DownloadPrefs prefs ( & profile ) ;\n EXPECT_FALSE ( prefs . IsAutoOpenEnabledBasedOnExtension ( kDangerousFilePath ) ) ;\n EXPECT_TRUE ( prefs . IsAutoOpenEnabledBasedOnExtension ( kSafeFilePath ) ) ;\n }","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":459226,"func":"gst_h264_create_sei_memory_avc (guint8 nal_length_size, GArray * messages)\n{\n  g_return_val_if_fail (nal_length_size > 0 && nal_length_size < 5, NULL);\n  g_return_val_if_fail (messages != NULL, NULL);\n  g_return_val_if_fail (messages->len > 0, NULL);\n\n  return gst_h264_create_sei_memory_internal (nal_length_size, TRUE, messages);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":169827,"func":"bool HTMLFormElement::rendererIsNeeded(const RenderStyle& style)\n{\n    if (!m_wasDemoted)\n        return HTMLElement::rendererIsNeeded(style);\n\n    ContainerNode* node = parentNode();\n    RenderObject* parentRenderer = node->renderer();\n    bool parentIsTableElementPart = (parentRenderer->isTable() && isHTMLTableElement(node))\n        || (parentRenderer->isTableRow() && node->hasTagName(trTag))\n        || (parentRenderer->isTableSection() && node->hasTagName(tbodyTag))\n        || (parentRenderer->isRenderTableCol() && node->hasTagName(colTag))\n        || (parentRenderer->isTableCell() && node->hasTagName(trTag));\n\n    if (!parentIsTableElementPart)\n        return true;\n\n    EDisplay display = style.display();\n    bool formIsTablePart = display == TABLE || display == INLINE_TABLE || display == TABLE_ROW_GROUP\n        || display == TABLE_HEADER_GROUP || display == TABLE_FOOTER_GROUP || display == TABLE_ROW\n        || display == TABLE_COLUMN_GROUP || display == TABLE_COLUMN || display == TABLE_CELL\n        || display == TABLE_CAPTION;\n\n    return formIsTablePart;\n}\n","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":275298,"func":"bool OSExchangeDataProviderWin::GetFilenames(\n    std::vector<OSExchangeData::FileInfo>* filenames) const {\n  std::vector<base::string16> filenames_local;\n  bool success = ClipboardUtil::GetFilenames(source_object_, &filenames_local);\n  if (success) {\n    for (size_t i = 0; i < filenames_local.size(); ++i)\n      filenames->push_back(\n          OSExchangeData::FileInfo(base::FilePath(filenames_local[i]),\n                                   base::FilePath()));\n  }\n  return success;\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":191028,"func":"static SRP_gN_cache *SRP_gN_new_init(const char *ch)\n{\n    unsigned char tmp[MAX_LEN];\n    int len;\n\n    SRP_gN_cache *newgN =\n        (SRP_gN_cache *)OPENSSL_malloc(sizeof(SRP_gN_cache));\n    if (newgN == NULL)\n        return NULL;\n\n    if ((newgN->b64_bn = BUF_strdup(ch)) == NULL)\n        goto err;\n\n    len = t_fromb64(tmp, ch);\n    if ((newgN->bn = BN_bin2bn(tmp, len, NULL)))\n        return newgN;\n\n    OPENSSL_free(newgN->b64_bn);\n err:\n    OPENSSL_free(newgN);\n    return NULL;\n}\n","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":95397,"func":"static int __init ip_vs_genl_register(void)\n{\n\treturn genl_register_family_with_ops(&ip_vs_genl_family,\n\t\tip_vs_genl_ops, ARRAY_SIZE(ip_vs_genl_ops));\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":487601,"func":"breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(\n    const std::string& process_type) {\n  base::FilePath dumps_path;\n  base::PathService::Get(electron::DIR_CRASH_DUMPS, &dumps_path);\n  {\n    ANNOTATE_SCOPED_MEMORY_LEAK;\n    bool upload = ElectronCrashReporterClient::Get()->GetCollectStatsConsent();\n    breakpad::CrashHandlerHostLinux* crash_handler =\n        new breakpad::CrashHandlerHostLinux(process_type, dumps_path, upload);\n    crash_handler->StartUploaderThread();\n    return crash_handler;\n  }\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":233845,"func":"static void ServerNameToSyncAPIName(const std::string& server_name,\n                                    std::string* out) {\n  CHECK(out);\n  int length_to_copy = server_name.length();\n  if (IsNameServerIllegalAfterTrimming(server_name) &&\n      EndsWithSpace(server_name)) {\n    --length_to_copy;\n  }\n  *out = std::string(server_name.c_str(), length_to_copy);\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":359460,"func":"lt_dlmakeresident (lt_dlhandle handle)\n{\n  int errors = 0;\n\n  if (!handle)\n    {\n      LT__SETERROR (INVALID_HANDLE);\n      ++errors;\n    }\n  else\n    {\n      handle->info.is_resident = 1;\n    }\n\n  return errors;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":199062,"func":"LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)\n{\n\ttmsize_t rowlen = TIFFScanlineSize(tif);\n\n        if (rowlen == 0)\n                return 0;\n\n\tassert(cc%rowlen == 0);\n\twhile (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) {\n\t\tbp += rowlen;\n\t\tcc -= rowlen;\n\t}\n\treturn (cc == 0);\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":296613,"func":"EC_Group::EC_Group(const std::string& str)\n   {\n   if(str == \"\")\n      return; \/\/ no initialization \/ uninitialized\n\n   try\n      {\n      OID oid = OIDS::lookup(str);\n      if(oid.empty() == false)\n         m_data = ec_group_data().lookup(oid);\n      }\n   catch(Invalid_OID&)\n      {\n      }\n\n   if(m_data == nullptr)\n      {\n      if(str.size() > 30 && str.substr(0, 29) == \"-----BEGIN EC PARAMETERS-----\")\n         {\n         \/\/ OK try it as PEM ...\n         secure_vector<uint8_t> ber = PEM_Code::decode_check_label(str, \"EC PARAMETERS\");\n         this->m_data = BER_decode_EC_group(ber.data(), ber.size());\n         }\n      }\n\n   if(m_data == nullptr)\n      throw Invalid_Argument(\"Unknown ECC group '\" + str + \"'\");\n   }","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":107928,"func":"openlog (const char *ident, int logstat, int logfac)\n{\n  \/* Protect against multiple users.  *\/\n  __libc_cleanup_region_start ((void (*) __P ((void *))) __libc_mutex_unlock,\n\t\t\t       &syslog_lock);\n  __libc_lock_lock (syslog_lock);\n\n  openlog_internal (ident, logstat, logfac);\n\n  \/* Free the lock.  *\/\n  __libc_cleanup_region_end (1);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":265182,"func":"static void udf_write_failed(struct address_space *mapping, loff_t to)\n{\n\tstruct inode *inode = mapping->host;\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\tloff_t isize = inode->i_size;\n\n\tif (to > isize) {\n\t\ttruncate_pagecache(inode, isize);\n\t\tif (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {\n\t\t\tdown_write(&iinfo->i_data_sem);\n\t\t\tudf_clear_extent_cache(inode);\n\t\t\tudf_truncate_extents(inode);\n\t\t\tup_write(&iinfo->i_data_sem);\n\t\t}\n\t}\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":515327,"func":"int smtp_server_connection_flush(struct smtp_server_connection *conn)\n{\n\tstruct ostream *output = conn->conn.output;\n\tint ret;\n\n\tif ((ret = o_stream_flush(output)) <= 0) {\n\t\tif (ret < 0)\n\t\t\tsmtp_server_connection_handle_output_error(conn);\n\t\treturn ret;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":176685,"func":"bool SelectFileDialogImpl::IsRunning(HWND owning_hwnd) const {\n  return listener_ && IsRunningDialogForOwner(owning_hwnd);\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":324252,"func":"static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)\n\n{\n\n    VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev);\n\n    DeviceState *vdev = DEVICE(&dev->vdev);\n\n    DeviceState *qdev = DEVICE(ccw_dev);\n\n    Error *err = NULL;\n\n    char *bus_name;\n\n\n\n    \/*\n\n     * For command line compatibility, this sets the virtio-scsi-device bus\n\n     * name as before.\n\n     *\/\n\n    if (qdev->id) {\n\n        bus_name = g_strdup_printf(\"%s.0\", qdev->id);\n\n        virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);\n\n        g_free(bus_name);\n\n    }\n\n\n\n    qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));\n\n    object_property_set_bool(OBJECT(vdev), true, \"realized\", &err);\n\n    if (err) {\n\n        error_propagate(errp, err);\n\n    }\n\n}\n","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":372385,"func":"cmsFloat32Number CMSEXPORT cmsEvalToneCurveFloat(const cmsToneCurve* Curve, cmsFloat32Number v)\n{\n    _cmsAssert(Curve != NULL);\n\n    \/\/ Check for 16 bits table. If so, this is a limited-precision tone curve\n    if (Curve ->nSegments == 0) {\n\n        cmsUInt16Number In, Out;\n\n        In = (cmsUInt16Number) _cmsQuickSaturateWord(v * 65535.0);\n        Out = cmsEvalToneCurve16(Curve, In);\n\n        return (cmsFloat32Number) (Out \/ 65535.0);\n    }\n\n    return (cmsFloat32Number) EvalSegmentedFn(Curve, v);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":491216,"func":"TPMI_DH_PERSISTENT_Unmarshal(TPMI_DH_PERSISTENT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    TPMI_DH_PERSISTENT orig_target = *target; \/\/ libtpms added\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tif (isNotPersistent) {\n\t    rc = TPM_RC_VALUE;\n\t    *target = orig_target; \/\/ libtpms added\n\t}\n    }\n    return rc;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":277414,"func":"bool CSSComputedStyleDeclaration::useFixedFontDefaultSize() const\n{\n    if (!m_node)\n        return false;\n\n    RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);\n    if (!style)\n        return false;\n\n    return style->fontDescription().useFixedDefaultSize();\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":492608,"func":"gimp_channel_all (GimpChannel *channel,\n                  gboolean     push_undo)\n{\n  g_return_if_fail (GIMP_IS_CHANNEL (channel));\n\n  if (! gimp_item_is_attached (GIMP_ITEM (channel)))\n    push_undo = FALSE;\n\n  GIMP_CHANNEL_GET_CLASS (channel)->all (channel, push_undo);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":54666,"func":"static inline void evmcs_load(u64 phys_addr) {}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":191094,"func":"void RenderView::didExecuteCommand(const WebString& command_name) {\n  const std::string& name = UTF16ToUTF8(command_name);\n  if (StartsWithASCII(name, \"Move\", true) ||\n      StartsWithASCII(name, \"Insert\", true) ||\n      StartsWithASCII(name, \"Delete\", true))\n    return;\n  RenderThread::current()->Send(\n      new ViewHostMsg_UserMetricsRecordAction(name));\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":491217,"func":"TPMU_SENSITIVE_COMPOSITE_Unmarshal(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\trc = TPM2B_PRIVATE_KEY_RSA_Unmarshal(&target->rsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TPM2B_ECC_PARAMETER_Unmarshal(&target->ecc, buffer, size);\n\tbreak;\n#endif\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TPM2B_SENSITIVE_DATA_Unmarshal(&target->bits, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TPM2B_SYM_KEY_Unmarshal(&target->sym, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":74916,"func":"void CLASS get_timestamp(int reversed)\n{\n  struct tm t;\n  char str[20];\n  int i;\n\n  str[19] = 0;\n  if (reversed)\n    for (i = 19; i--;)\n      str[i] = fgetc(ifp);\n  else\n    fread(str, 19, 1, ifp);\n  memset(&t, 0, sizeof t);\n  if (sscanf(str, \"%d:%d:%d %d:%d:%d\", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec) != 6)\n    return;\n  t.tm_year -= 1900;\n  t.tm_mon -= 1;\n  t.tm_isdst = -1;\n  if (mktime(&t) > 0)\n    timestamp = mktime(&t);\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":42998,"func":"void ireftype_box_del(GF_Box *s)\n{\n\tGF_ItemReferenceTypeBox *ptr = (GF_ItemReferenceTypeBox *)s;\n\tif (!ptr) return;\n\tif (ptr->to_item_IDs) gf_free(ptr->to_item_IDs);\n\tgf_free(ptr);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":490861,"func":"void io_start_multiplex_out(int fd)\n{\n\tio_flush(FULL_FLUSH);\n\n\tif (msgs2stderr == 1 && DEBUG_GTE(IO, 2))\n\t\trprintf(FINFO, \"[%s] io_start_multiplex_out(%d)\\n\", who_am_i(), fd);\n\n\tif (!iobuf.msg.buf)\n\t\talloc_xbuf(&iobuf.msg, ROUND_UP_1024(IO_BUFFER_SIZE));\n\n\tiobuf.out_empty_len = 4; \/* See also OUT_MULTIPLEXED *\/\n\tio_start_buffering_out(fd);\n\tgot_kill_signal = 0;\n\n\tiobuf.raw_data_header_pos = iobuf.out.pos + iobuf.out.len;\n\tiobuf.out.len += 4;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":319875,"func":"int main(void)\n\n{\n\n    int nf;\n\n    Suite *s;\n\n    SRunner *sr;\n\n\n\n    s = qfloat_suite();\n\n    sr = srunner_create(s);\n\n\n\n    srunner_run_all(sr, CK_NORMAL);\n\n    nf = srunner_ntests_failed(sr);\n\n    srunner_free(sr);\n\n\n\n    return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;\n\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":353857,"func":"static void test_json_append_escaped_data(void)\n{\n\tstatic const unsigned char test_input[] =\n\t\t\"\\b\\f\\r\\n\\t\\\"\\\\\\000\\001\\002-\\xC3\\xA4\\xf0\\x90\\x90\\xb7\";\n\tstring_t *str = t_str_new(32);\n\n\ttest_begin(\"json_append_escaped()\");\n\tjson_append_escaped_data(str, test_input, sizeof(test_input)-1);\n\ttest_assert(strcmp(str_c(str), \"\\\\b\\\\f\\\\r\\\\n\\\\t\\\\\\\"\\\\\\\\\\\\u0000\\\\u0001\\\\u0002-\\\\u00e4\\\\ud801\\\\udc37\") == 0);\n\ttest_end();\n}","target":1,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":488551,"func":"free_toporder_info (class ipa_topo_info *topo)\n{\n  ipa_free_postorder_info ();\n  free (topo->order);\n  free (topo->stack);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":519778,"func":"  select_result_interceptor(THD *thd_arg):\n    select_result(thd_arg), suppress_my_ok(false)\n  {\n    DBUG_ENTER(\"select_result_interceptor::select_result_interceptor\");\n    DBUG_PRINT(\"enter\", (\"this %p\", this));\n    DBUG_VOID_RETURN;\n  }              \/* Remove gcc warning *\/","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":405676,"func":"WandExport void DrawRectangle(DrawingWand *wand,const double x1,const double y1,\n  const double x2,const double y2)\n{\n  assert(wand != (DrawingWand *) NULL);\n  assert(wand->signature == MagickWandSignature);\n  if (wand->debug != MagickFalse)\n    (void) LogMagickEvent(WandEvent,GetMagickModule(),\"%s\",wand->name);\n  (void) MVGPrintf(wand,\"rectangle %.20g %.20g %.20g %.20g\\n\",x1,y1,x2,y2);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":133216,"func":"static bool xdp_is_valid_access(int off, int size,\n\t\t\t\tenum bpf_access_type type,\n\t\t\t\tconst struct bpf_prog *prog,\n\t\t\t\tstruct bpf_insn_access_aux *info)\n{\n\tif (type == BPF_WRITE)\n\t\treturn false;\n\n\tswitch (off) {\n\tcase offsetof(struct xdp_md, data):\n\t\tinfo->reg_type = PTR_TO_PACKET;\n\t\tbreak;\n\tcase offsetof(struct xdp_md, data_meta):\n\t\tinfo->reg_type = PTR_TO_PACKET_META;\n\t\tbreak;\n\tcase offsetof(struct xdp_md, data_end):\n\t\tinfo->reg_type = PTR_TO_PACKET_END;\n\t\tbreak;\n\t}\n\n\treturn __is_valid_xdp_access(off, size);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":474844,"func":"static int assign_proto_idx(struct proto *prot)\n{\n\tprot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR);\n\n\tif (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) {\n\t\tpr_err(\"PROTO_INUSE_NR exhausted\\n\");\n\t\treturn -ENOSPC;\n\t}\n\n\tset_bit(prot->inuse_idx, proto_inuse_idx);\n\treturn 0;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":382432,"func":"ProcReleaseLocks(bool isCommit)\n{\n\tif (!MyProc)\n\t\treturn;\n\t\/* If waiting, get off wait queue (should only be needed after error) *\/\n\tLockErrorCleanup();\n\t\/* Release standard locks, including session-level if aborting *\/\n\tLockReleaseAll(DEFAULT_LOCKMETHOD, !isCommit);\n\t\/* Release transaction-level advisory locks *\/\n\tLockReleaseAll(USER_LOCKMETHOD, false);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":265610,"func":"QPDFObjectHandle::setArrayFromVector(std::vector<QPDFObjectHandle> const& items)\n{\n    assertArray();\n    return dynamic_cast<QPDF_Array*>(obj.getPointer())->setFromVector(items);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":355303,"func":"int hrtimer_try_to_cancel(struct hrtimer *timer)\n{\n\tstruct hrtimer_clock_base *base;\n\tunsigned long flags;\n\tint ret = -1;\n\n\tbase = lock_hrtimer_base(timer, &flags);\n\n\tif (!hrtimer_callback_running(timer))\n\t\tret = remove_hrtimer(timer, base);\n\n\tunlock_hrtimer_base(timer, &flags);\n\n\treturn ret;\n\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":413753,"func":"addBackwardPassRule(TranslationTableOffset *newRuleOffset, TranslationTableRule *newRule,\n\t\tTranslationTableHeader *table) {\n\tTranslationTableOffset *currentOffsetPtr;\n\tTranslationTableRule *currentRule;\n\tswitch (newRule->opcode) {\n\tcase CTO_Correct:\n\t\tcurrentOffsetPtr = &table->backPassRules[0];\n\t\tbreak;\n\tcase CTO_Context:\n\t\tcurrentOffsetPtr = &table->backPassRules[1];\n\t\tbreak;\n\tcase CTO_Pass2:\n\t\tcurrentOffsetPtr = &table->backPassRules[2];\n\t\tbreak;\n\tcase CTO_Pass3:\n\t\tcurrentOffsetPtr = &table->backPassRules[3];\n\t\tbreak;\n\tcase CTO_Pass4:\n\t\tcurrentOffsetPtr = &table->backPassRules[4];\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\twhile (*currentOffsetPtr) {\n\t\tcurrentRule = (TranslationTableRule *)&table->ruleArea[*currentOffsetPtr];\n\t\tif (newRule->charslen > currentRule->charslen) break;\n\t\tcurrentOffsetPtr = ¤tRule->dotsnext;\n\t}\n\tnewRule->dotsnext = *currentOffsetPtr;\n\t*currentOffsetPtr = *newRuleOffset;\n\treturn 1;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":55246,"func":"int setns(int fd, int nstype)\n{\n\treturn syscall(SYS_setns, fd, nstype);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":366771,"func":"sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)\n{\n\treturn do_sigaltstack(uss, uoss, rdusp());\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":292527,"func":"vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp)\n{\n    ff_visited_list_hdr_T *vp;\n\n    while (*list_headp != NULL)\n    {\n\tvp = (*list_headp)->ffvl_next;\n\tff_free_visited_list((*list_headp)->ffvl_visited_list);\n\n\tvim_free((*list_headp)->ffvl_filename);\n\tvim_free(*list_headp);\n\t*list_headp = vp;\n    }\n    *list_headp = NULL;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":370898,"func":"rb_to_id(VALUE name)\n{\n    VALUE tmp;\n    ID id;\n\n    switch (TYPE(name)) {\n      default:\n\ttmp = rb_check_string_type(name);\n\tif (NIL_P(tmp)) {\n\t    tmp = rb_inspect(name);\n\t    rb_raise(rb_eTypeError, \"%s is not a symbol\",\n\t\t     RSTRING_PTR(tmp));\n\t}\n\tname = tmp;\n\t\/* fall through *\/\n      case T_STRING:\n\tname = rb_str_intern(name);\n\t\/* fall through *\/\n      case T_SYMBOL:\n\treturn SYM2ID(name);\n    }\n    return id;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":501775,"func":"  HealthCheckerFactoryContextImpl(Upstream::Cluster& cluster, Envoy::Runtime::Loader& runtime,\n                                  Event::Dispatcher& dispatcher,\n                                  HealthCheckEventLoggerPtr&& event_logger,\n                                  ProtobufMessage::ValidationVisitor& validation_visitor,\n                                  Api::Api& api)\n      : cluster_(cluster), runtime_(runtime), dispatcher_(dispatcher),\n        event_logger_(std::move(event_logger)), validation_visitor_(validation_visitor), api_(api) {\n  }","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":793,"func":"int16_t vp9_dc_quant ( int qindex , int delta ) {\n return dc_qlookup [ clamp ( qindex + delta , 0 , MAXQ ) ] ;\n }","target":1,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":414034,"func":"int wmi_read_hdr(struct wil6210_priv *wil, __le32 ptr,\n\t\t struct wil6210_mbox_hdr *hdr)\n{\n\tvoid __iomem *src = wmi_buffer(wil, ptr);\n\n\tif (!src)\n\t\treturn -EINVAL;\n\n\twil_memcpy_fromio_32(hdr, src, sizeof(*hdr));\n\n\treturn 0;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":112386,"func":"static int hns_nic_dev_remove(struct platform_device *pdev)\n{\n\tstruct net_device *ndev = platform_get_drvdata(pdev);\n\tstruct hns_nic_priv *priv = netdev_priv(ndev);\n\n\tif (ndev->reg_state != NETREG_UNINITIALIZED)\n\t\tunregister_netdev(ndev);\n\n\tif (priv->ring_data)\n\t\thns_nic_uninit_ring_data(priv);\n\tpriv->ring_data = NULL;\n\n\tif (ndev->phydev)\n\t\tphy_disconnect(ndev->phydev);\n\n\tif (!IS_ERR_OR_NULL(priv->ae_handle))\n\t\thnae_put_handle(priv->ae_handle);\n\tpriv->ae_handle = NULL;\n\tif (priv->notifier_block.notifier_call)\n\t\thnae_unregister_notifier(&priv->notifier_block);\n\tpriv->notifier_block.notifier_call = NULL;\n\n\tset_bit(NIC_STATE_REMOVING, &priv->state);\n\t(void)cancel_work_sync(&priv->service_task);\n\n\tfree_netdev(ndev);\n\treturn 0;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":175930,"func":"xsltFreeExtModule(xsltExtModulePtr ext)\n{\n    if (ext == NULL)\n        return;\n    xmlFree(ext);\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":278009,"func":"void HWNDMessageHandler::Maximize() {\n  ExecuteSystemMenuCommand(SC_MAXIMIZE);\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":365058,"func":"tor_tls_context_incref(tor_tls_context_t *ctx)\n{\n  ++ctx->refcnt;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":189919,"func":"  bool SendPacket(QuicPacketSequenceNumber sequence_number,\n                  QuicPacket* packet,\n                  bool resend,\n                  bool force) {\n    return QuicConnection::SendPacket(sequence_number, packet, resend, force);\n  }\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":481305,"func":"create_macro(const char *name, const widechar *definition, int definition_length,\n\t\tconst int *substitutions, int substitution_count, int argument_count) {\n\tMacro *m = malloc(sizeof(Macro));\n\tm->name = strdup(name);\n\twidechar *definition_copy = malloc(definition_length * sizeof(widechar));\n\tmemcpy(definition_copy, definition, definition_length * sizeof(widechar));\n\tm->definition = definition_copy;\n\tm->definition_length = definition_length;\n\tint *substitutions_copy = malloc(2 * substitution_count * sizeof(int));\n\tmemcpy(substitutions_copy, substitutions, 2 * substitution_count * sizeof(int));\n\tm->substitutions = substitutions_copy;\n\tm->substitution_count = substitution_count;\n\tm->argument_count = argument_count;\n\treturn m;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":125740,"func":"Variant HHVM_FUNCTION(exif_thumbnail, const String& filename,\n                         VRefParam width \/* = null *\/,\n                         VRefParam height \/* = null *\/,\n                         VRefParam imagetype \/* = null *\/) {\n  image_info_type ImageInfo;\n\n  memset(&ImageInfo, 0, sizeof(ImageInfo));\n\n  int ret = exif_read_file(&ImageInfo, filename.c_str(), 1, 0);\n  if (ret==0) {\n    exif_discard_imageinfo(&ImageInfo);\n    return false;\n  }\n\n  if (!ImageInfo.Thumbnail.data || !ImageInfo.Thumbnail.size) {\n    exif_discard_imageinfo(&ImageInfo);\n    return false;\n  }\n\n  if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {\n    exif_scan_thumbnail(&ImageInfo);\n  }\n  width.assignIfRef((int64_t)ImageInfo.Thumbnail.width);\n  height.assignIfRef((int64_t)ImageInfo.Thumbnail.height);\n  imagetype.assignIfRef(ImageInfo.Thumbnail.filetype);\n  String str(ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size, CopyString);\n  exif_discard_imageinfo(&ImageInfo);\n  return str;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":253781,"func":"void AwContents::RequestNewHitTestDataAt(JNIEnv* env,\n                                         jobject obj,\n                                         jfloat x,\n                                         jfloat y,\n                                         jfloat touch_major) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  gfx::PointF touch_center(x, y);\n  gfx::SizeF touch_area(touch_major, touch_major);\n  render_view_host_ext_->RequestNewHitTestDataAt(touch_center, touch_area);\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":370760,"func":"rb_str_buf_cat(VALUE str, const char *ptr, long len)\n{\n    if (len == 0) return str;\n    if (len < 0) {\n\trb_raise(rb_eArgError, \"negative string size (or size too big)\");\n    }\n    return str_buf_cat(str, ptr, len);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":274278,"func":"static int ntlm_write_ntlm_v2_client_challenge(wStream* s, NTLMv2_CLIENT_CHALLENGE* challenge)\n{\n\tULONG length;\n\tStream_Write_UINT8(s, challenge->RespType);\n\tStream_Write_UINT8(s, challenge->HiRespType);\n\tStream_Write_UINT16(s, challenge->Reserved1);\n\tStream_Write_UINT32(s, challenge->Reserved2);\n\tStream_Write(s, challenge->Timestamp, 8);\n\tStream_Write(s, challenge->ClientChallenge, 8);\n\tStream_Write_UINT32(s, challenge->Reserved3);\n\tlength = ntlm_av_pair_list_length(challenge->AvPairs, challenge->cbAvPairs);\n\tStream_Write(s, challenge->AvPairs, length);\n\treturn 1;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":439734,"func":"SplashGouraudPattern::~SplashGouraudPattern() {\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":428605,"func":"replace_async_data_free (ReplaceAsyncData *data)\n{\n  if (data->stream)\n    g_object_unref (data->stream);\n  g_free (data->etag);\n  g_free (data);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":190916,"func":"bool HTMLCanvasElement::WouldTaintOrigin() const {\n  return !OriginClean();\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":243463,"func":"void LayerTreeHost::RegisterViewportLayers(\n    scoped_refptr<Layer> page_scale_layer,\n    scoped_refptr<Layer> inner_viewport_scroll_layer,\n    scoped_refptr<Layer> outer_viewport_scroll_layer) {\n  page_scale_layer_ = page_scale_layer;\n  inner_viewport_scroll_layer_ = inner_viewport_scroll_layer;\n  outer_viewport_scroll_layer_ = outer_viewport_scroll_layer;\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":399988,"func":"policy_hash(const policy_map_ent_t *ent)\n{\n  const addr_policy_t *a = ent->policy;\n  addr_policy_t aa;\n  memset(&aa, 0, sizeof(aa));\n\n  aa.prt_min = a->prt_min;\n  aa.prt_max = a->prt_max;\n  aa.maskbits = a->maskbits;\n  aa.policy_type = a->policy_type;\n  aa.is_private = a->is_private;\n\n  if (a->is_private) {\n    aa.is_private = 1;\n  } else {\n    tor_addr_copy_tight(&aa.addr, &a->addr);\n  }\n\n  return (unsigned) siphash24g(&aa, sizeof(aa));\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":32876,"func":"void teecore_init_pub_ram(void)\n{\n\tvaddr_t s;\n\tvaddr_t e;\n\n\t\/* get virtual addr\/size of NSec shared mem allcated from teecore *\/\n\tcore_mmu_get_mem_by_type(MEM_AREA_NSEC_SHM, &s, &e);\n\n\tif (s >= e || s & SMALL_PAGE_MASK || e & SMALL_PAGE_MASK)\n\t\tpanic(\"invalid PUB RAM\");\n\n\t\/* extra check: we could rely on  core_mmu_get_mem_by_type() *\/\n\tif (!tee_vbuf_is_non_sec(s, e - s))\n\t\tpanic(\"PUB RAM is not non-secure\");\n\n#ifdef CFG_PL310\n\t\/* Allocate statically the l2cc mutex *\/\n\ttee_l2cc_store_mutex_boot_pa(virt_to_phys((void *)s));\n\ts += sizeof(uint32_t);\t\t\t\/* size of a pl310 mutex *\/\n\ts =  ROUNDUP(s, SMALL_PAGE_SIZE);\t\/* keep required alignment *\/\n#endif\n\n\tdefault_nsec_shm_paddr = virt_to_phys((void *)s);\n\tdefault_nsec_shm_size = e - s;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":412415,"func":"static void snd_pcm_xrun_debug_write(struct snd_info_entry *entry,\n\t\t\t\t     struct snd_info_buffer *buffer)\n{\n\tstruct snd_pcm_str *pstr = entry->private_data;\n\tchar line[64];\n\tif (!snd_info_get_line(buffer, line, sizeof(line)))\n\t\tpstr->xrun_debug = simple_strtoul(line, NULL, 10);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":421262,"func":"static int FAST_FUNC read_optset(const char *line, void *arg) {\n\treturn udhcp_str2optset(line, arg,\n\t\t\tdhcp_optflags, dhcp_option_strings,\n\t\t\t\/*dhcpv6:*\/ 0\n\t);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":468109,"func":"blk_get_flush_queue(struct request_queue *q, struct blk_mq_ctx *ctx)\n{\n\treturn blk_mq_map_queue(q, REQ_OP_FLUSH, ctx)->fq;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":188481,"func":"void setFixedFontFamilyWrapper(WebSettings* settings,\n                               const string16& font,\n                               UScriptCode script) {\n  settings->setFixedFontFamily(font, script);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":443783,"func":"bool RGWCORSRule::is_origin_present(const char *o) {\n  string origin = o;\n  return is_string_in_set(allowed_origins, origin);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":464155,"func":"nm_utils_machine_id_str(void)\n{\n    return _machine_id_get(TRUE)->str;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":385064,"func":"static inline php_stream *phar_get_entrypfp(phar_entry_info *entry TSRMLS_DC)\n{\n\tif (!entry->is_persistent) {\n\t\treturn entry->phar->fp;\n\t}\n\treturn PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].fp;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":273181,"func":"Word getUpstreamDataBufferBytesHandler(void* raw_context, Word start, Word length, Word ptr_ptr,\n                                       Word size_ptr) {\n  auto context = WASM_CONTEXT(raw_context);\n  absl::string_view data;\n  auto result = context->getUpstreamDataBufferBytes(start.u64_, length.u64_, &data);\n  if (result != WasmResult::Ok) {\n    return wasmResultToWord(result);\n  }\n  context->wasm()->copyToPointerSize(data, ptr_ptr.u64_, size_ptr.u64_);\n  return wasmResultToWord(WasmResult::Ok);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":404008,"func":"bool ptr_is_within_mem_clumps(const void *ptr, gs_ref_memory_t *mem)\n{\n    clump_t *cp = mem->root;\n\n    while (cp)\n    {\n        if (PTR_LT(ptr, cp->cbase))\n        {\n            cp = cp->left;\n            continue;\n        }\n        if (PTR_GE(ptr, cp->cend))\n        {\n            cp = cp->right;\n            continue;\n        }\n        \/* Found it! *\/\n        splay_move_to_root(cp, mem);\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":184063,"func":"void OverlayWindowViews::SetPictureInPictureCustomControls(\n    const std::vector<blink::PictureInPictureControlInfo>& controls) {\n  first_custom_controls_view_.reset();\n  second_custom_controls_view_.reset();\n\n  if (controls.size() > 0)\n    CreateCustomControl(first_custom_controls_view_, controls[0],\n                        ControlPosition::kLeft);\n  if (controls.size() > 1)\n    CreateCustomControl(second_custom_controls_view_, controls[1],\n                        ControlPosition::kRight);\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":373878,"func":"    bool fieldsMatch(const BSONObj& lhs, const BSONObj& rhs) {\n        BSONObjIterator l(lhs);\n        BSONObjIterator r(rhs);\n\n        while (l.more() && r.more()){\n            if (strcmp(l.next().fieldName(), r.next().fieldName())) {\n                return false;\n            }\n        }\n\n        return !(l.more() || r.more()); \/\/ false if lhs and rhs have diff nFields()\n    }","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":413709,"func":"getCharOrDots(widechar c, int m, TranslationTableHeader *table) {\n\tCharOrDots *cdPtr;\n\tTranslationTableOffset bucket;\n\tunsigned long int makeHash = (unsigned long int)c % HASHNUM;\n\tif (m == 0)\n\t\tbucket = table->charToDots[makeHash];\n\telse\n\t\tbucket = table->dotsToChar[makeHash];\n\twhile (bucket) {\n\t\tcdPtr = (CharOrDots *)&table->ruleArea[bucket];\n\t\tif (cdPtr->lookFor == c) return cdPtr;\n\t\tbucket = cdPtr->next;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":60321,"func":"ufmt_close(UFormattable *fmt) {\n  Formattable *obj = Formattable::fromUFormattable(fmt);\n\n  delete obj;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":155433,"func":"\t__releases(&hb->lock)\n{\n\t__queue_me(q, hb);\n\tspin_unlock(&hb->lock);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":207162,"func":"sk_deep_copy(void *sk_void, void *copy_func_void, void *free_func_void)\n{\n\t_STACK *sk = sk_void;\n\tvoid *(*copy_func)(void *) = copy_func_void;\n\tvoid (*free_func)(void *) = free_func_void;\n\t_STACK *ret = sk_dup(sk);\n\tsize_t i;\n\n\tif (ret == NULL)\n\t\treturn NULL;\n\n\tfor (i = 0; i < ret->num; i++) {\n\t\tif (ret->data[i] == NULL)\n\t\t\tcontinue;\n\t\tret->data[i] = copy_func(ret->data[i]);\n\t\tif (ret->data[i] == NULL) {\n\t\t\tsize_t j;\n\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\tif (ret->data[j] != NULL)\n\t\t\t\t\tfree_func(ret->data[j]);\n\t\t\t}\n\t\t\tsk_free(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\treturn ret;\n}\n","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":416590,"func":"gx_get_largest_clipping_box(gx_device * dev, gs_fixed_rect * pbox)\n{\n    pbox->p.x = min_fixed;\n    pbox->p.y = min_fixed;\n    pbox->q.x = max_fixed;\n    pbox->q.y = max_fixed;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":374573,"func":"_equalCreateForeignServerStmt(const CreateForeignServerStmt *a, const CreateForeignServerStmt *b)\n{\n\tCOMPARE_STRING_FIELD(servername);\n\tCOMPARE_STRING_FIELD(servertype);\n\tCOMPARE_STRING_FIELD(version);\n\tCOMPARE_STRING_FIELD(fdwname);\n\tCOMPARE_NODE_FIELD(options);\n\n\treturn true;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":489143,"func":"char *split_comma(char *str) {\n\tif (str == NULL || *str == '\\0')\n\t\treturn NULL;\n\tchar *ptr = strchr(str, ',');\n\tif (!ptr)\n\t\treturn NULL;\n\t*ptr = '\\0';\n\tptr++;\n\tif (*ptr == '\\0')\n\t\treturn NULL;\n\treturn ptr;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":158053,"func":"ves_icall_MonoType_get_Name (MonoReflectionType *type)\n{\n\tMonoDomain *domain = mono_domain_get (); \n\tMonoClass *class = mono_class_from_mono_type (type->type);\n\n\tMONO_ARCH_SAVE_REGS;\n\n\tif (type->type->byref) {\n\t\tchar *n = g_strdup_printf (\"%s&\", class->name);\n\t\tMonoString *res = mono_string_new (domain, n);\n\n\t\tg_free (n);\n\n\t\treturn res;\n\t} else {\n\t\treturn mono_string_new (domain, class->name);\n\t}\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":319874,"func":"static inline void gen_efdnabs(DisasContext *ctx)\n\n{\n\n    if (unlikely(!ctx->spe_enabled)) {\n\n        gen_exception(ctx, POWERPC_EXCP_APU);\n\n        return;\n\n    }\n\n#if defined(TARGET_PPC64)\n\n    tcg_gen_ori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 0x8000000000000000LL);\n\n#else\n\n    tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);\n\n    tcg_gen_ori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], 0x80000000);\n\n#endif\n\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":121500,"func":"compile_length_string_raw_node(StrNode* sn, regex_t* reg)\n{\n  if (sn->end <= sn->s)\n    return 0;\n\n  return add_compile_string_length(sn->s, 1 \/* sb *\/, (int )(sn->end - sn->s),\n                                   reg, 0);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":238884,"func":"static int register_memsw_files(struct cgroup *cont, struct cgroup_subsys *ss)\n{\n\tif (!do_swap_account)\n\t\treturn 0;\n\treturn cgroup_add_files(cont, ss, memsw_cgroup_files,\n\t\t\t\tARRAY_SIZE(memsw_cgroup_files));\n};\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":8487,"func":"\t\tvoid CWebServer::GetFloorplanImage(WebEmSession & session, const request& req, reply & rep)\n\t\t{\n\t\t\tstd::string idx = request::findValue(&req, \"idx\");\n\t\t\tif (idx == \"\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstd::vector<std::vector<std::string> > result;\n\t\t\tresult = m_sql.safe_queryBlob(\"SELECT Image FROM Floorplans WHERE ID=%s\", idx.c_str());\n\t\t\tif (result.empty())\n\t\t\t\treturn;\n\t\t\treply::set_content(&rep, result[0][0].begin(), result[0][0].end());\n\t\t\tstd::string oname = \"floorplan\";\n\t\t\tif (result[0][0].size() > 10)\n\t\t\t{\n\t\t\t\tif (result[0][0][0] == 'P')\n\t\t\t\t\toname += \".png\";\n\t\t\t\telse if (result[0][0][0] == -1)\n\t\t\t\t\toname += \".jpg\";\n\t\t\t\telse if (result[0][0][0] == 'B')\n\t\t\t\t\toname += \".bmp\";\n\t\t\t\telse if (result[0][0][0] == 'G')\n\t\t\t\t\toname += \".gif\";\n\t\t\t}\n\t\t\treply::add_header_attachment(&rep, oname);\n\t\t}","target":1,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":295547,"func":"sshpkt_send(struct ssh *ssh)\n{\n\tif (compat20)\n\t\treturn ssh_packet_send2(ssh);\n\telse\n\t\treturn ssh_packet_send1(ssh);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":190711,"func":"StringValue* MakeEnumValue(T t, const char* (*converter_fn)(T)) {\n  return Value::CreateStringValue(converter_fn(t));\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":407007,"func":"static void insert_part_info_log_entry_list(partition_info *part_info,\n                                            DDL_LOG_MEMORY_ENTRY *log_entry)\n{\n  log_entry->next_active_log_entry= part_info->first_log_entry;\n  part_info->first_log_entry= log_entry;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":380508,"func":"evbuffer_free(struct evbuffer *buffer)\n{\n\tEVBUFFER_LOCK(buffer);\n\tevbuffer_decref_and_unlock_(buffer);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":466247,"func":"TEST_P(DownstreamProtocolIntegrationTest, ConnectStreamRejection) {\n  \/\/ TODO(danzh) add \"allow_connect\" to http3 options.\n  EXCLUDE_DOWNSTREAM_HTTP3;\n  if (downstreamProtocol() == Http::CodecClient::Type::HTTP1) {\n    return;\n  }\n  config_helper_.addConfigModifier(\n      [](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&\n             hcm) -> void {\n        hcm.mutable_http3_protocol_options()\n            ->mutable_override_stream_error_on_invalid_http_message()\n            ->set_value(true);\n        hcm.mutable_http2_protocol_options()\n            ->mutable_override_stream_error_on_invalid_http_message()\n            ->set_value(true);\n      });\n\n  initialize();\n  codec_client_ = makeHttpConnection(lookupPort(\"http\"));\n  auto response = codec_client_->makeHeaderOnlyRequest(Http::TestRequestHeaderMapImpl{\n      {\":method\", \"CONNECT\"}, {\":path\", \"\/\"}, {\":authority\", \"host\"}});\n\n  ASSERT_TRUE(response->waitForReset());\n  EXPECT_FALSE(codec_client_->disconnected());\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":418024,"func":"  int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) override {\n    return op->get_data_cb(bl, bl_ofs, bl_len);\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":90725,"func":"\n      static double mp_dot(_cimg_math_parser& mp) {\n        const unsigned int siz = (unsigned int)mp.opcode[4];\n        return CImg<doubleT>(&_mp_arg(2) + 1,1,siz,1,1,true).\n          dot(CImg<doubleT>(&_mp_arg(3) + 1,1,siz,1,1,true));","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":375846,"func":"static int vmstate_n_elems(void *opaque, VMStateField *field)\n{\n    int n_elems = 1;\n\n    if (field->flags & VMS_ARRAY) {\n        n_elems = field->num;\n    } else if (field->flags & VMS_VARRAY_INT32) {\n        n_elems = *(int32_t *)(opaque+field->num_offset);\n    } else if (field->flags & VMS_VARRAY_UINT32) {\n        n_elems = *(uint32_t *)(opaque+field->num_offset);\n    } else if (field->flags & VMS_VARRAY_UINT16) {\n        n_elems = *(uint16_t *)(opaque+field->num_offset);\n    } else if (field->flags & VMS_VARRAY_UINT8) {\n        n_elems = *(uint8_t *)(opaque+field->num_offset);\n    }\n\n    return n_elems;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":188136,"func":"void Tab::OnGestureEvent(ui::GestureEvent* event) {\n  controller_->UpdateHoverCard(this, false);\n  switch (event->type()) {\n    case ui::ET_GESTURE_TAP_DOWN: {\n      DCHECK_EQ(1, event->details().touch_points());\n\n      ui::GestureEvent event_in_parent(*event, static_cast<View*>(this),\n                                       parent());\n      ui::ListSelectionModel original_selection;\n      original_selection = controller_->GetSelectionModel();\n      tab_activated_with_last_tap_down_ = !IsActive();\n      if (!IsSelected())\n        controller_->SelectTab(this, *event);\n      gfx::Point loc(event->location());\n      views::View::ConvertPointToScreen(this, &loc);\n      ui::GestureEvent cloned_event(event_in_parent, parent(),\n                                    static_cast<View*>(this));\n      controller_->MaybeStartDrag(this, cloned_event, original_selection);\n      break;\n    }\n\n    case ui::ET_GESTURE_END:\n      controller_->EndDrag(END_DRAG_COMPLETE);\n      break;\n\n    case ui::ET_GESTURE_SCROLL_UPDATE:\n      controller_->ContinueDrag(this, *event);\n      break;\n\n    default:\n      break;\n  }\n  event->SetHandled();\n}\n","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":377115,"func":"static void bdrv_io_limits_intercept(BlockDriverState *bs,\n                                     unsigned int bytes,\n                                     bool is_write)\n{\n    \/* does this io must wait *\/\n    bool must_wait = throttle_schedule_timer(&bs->throttle_state, is_write);\n\n    \/* if must wait or any request of this type throttled queue the IO *\/\n    if (must_wait ||\n        !qemu_co_queue_empty(&bs->throttled_reqs[is_write])) {\n        qemu_co_queue_wait(&bs->throttled_reqs[is_write]);\n    }\n\n    \/* the IO will be executed, do the accounting *\/\n    throttle_account(&bs->throttle_state, is_write, bytes);\n\n\n    \/* if the next request must wait -> do nothing *\/\n    if (throttle_schedule_timer(&bs->throttle_state, is_write)) {\n        return;\n    }\n\n    \/* else queue next request for execution *\/\n    qemu_co_queue_next(&bs->throttled_reqs[is_write]);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":505082,"func":"static void signal_sep4(GtkWidget *w, gpointer data)\n{\n    window_separation((IMAGE *)data, 4);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":520902,"func":"void Item_func_if::fix_after_pullout(st_select_lex *new_parent,\n                                     Item **ref, bool merge)\n{\n  \/* This will re-calculate attributes of the arguments *\/\n  Item_func::fix_after_pullout(new_parent, ref, merge);\n  \/* Then, re-calculate not_null_tables_cache according to our special rules *\/\n  eval_not_null_tables(NULL);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":132883,"func":"   position *\/\n\nint find_set(REP_SETS *sets,REP_SET *find)\n{\n  uint i;\n  for (i=0 ; i < sets->count-1 ; i++)\n  {\n    if (!cmp_bits(sets->set+i,find))\n    {\n      free_last_set(sets);\n      return i;\n    }\n  }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":137412,"func":"void SHA256Transform(void* pstate, void* pinput, const void* pinit)\n{\n    SHA256_CTX ctx;\n    unsigned char data[64];\n\n    SHA256_Init(&ctx);\n\n    for (int i = 0; i < 16; i++)\n        ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]);\n\n    for (int i = 0; i < 8; i++)\n        ctx.h[i] = ((uint32_t*)pinit)[i];\n\n    SHA256_Update(&ctx, data, sizeof(data));\n    for (int i = 0; i < 8; i++) \n        ((uint32_t*)pstate)[i] = ctx.h[i];\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":332862,"func":"static int pci_pbm_map_irq(PCIDevice *pci_dev, int irq_num)\n\n{\n\n    int bus_offset;\n\n    if (pci_dev->devfn & 1)\n\n        bus_offset = 16;\n\n    else\n\n        bus_offset = 0;\n\n    return (bus_offset + (PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f;\n\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":241332,"func":"standard_end(png_structp ppIn, png_infop pi)\n{\n   png_const_structp pp = ppIn;\n   standard_display *dp = voidcast(standard_display*,\n      png_get_progressive_ptr(pp));\n\n   UNUSED(pi)\n\n \/* Validate the image - progressive reading only produces one variant for\n    * interlaced images.\n    *\/\n   standard_text_validate(dp, pp, pi,\n      PNG_LIBPNG_VER >= 10518\/*check_end: see comments above*\/);\n   standard_image_validate(dp, pp, 0, -1);\n}\n","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":284684,"func":"unsupported_nesting(enum ofpact_type action, enum ofpact_type outer_action)\n{\n    VLOG_WARN(\"%s action doesn't support nested action %s\",\n              ofpact_name(outer_action), ofpact_name(action));\n    return OFPERR_OFPBAC_BAD_ARGUMENT;\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":300634,"func":"static int amd_gpio_get_value(struct gpio_chip *gc, unsigned offset)\n{\n\tu32 pin_reg;\n\tunsigned long flags;\n\tstruct amd_gpio *gpio_dev = gpiochip_get_data(gc);\n\n\tspin_lock_irqsave(&gpio_dev->lock, flags);\n\tpin_reg = readl(gpio_dev->base + offset * 4);\n\tspin_unlock_irqrestore(&gpio_dev->lock, flags);\n\n\treturn !!(pin_reg & BIT(PIN_STS_OFF));\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":186452,"func":"void WebGL2RenderingContextBase::bufferSubData(GLenum target,\n                                               long long offset,\n                                               DOMArrayBuffer* data) {\n  WebGLRenderingContextBase::bufferSubData(target, offset, data);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":517073,"func":"uint st_select_lex_node::get_in_sum_expr()           { return 0; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":271263,"func":"static int __find_bmc_prod_dev_id(struct device *dev, void *data)\n{\n\tstruct prod_dev_id *cid = data;\n\tstruct bmc_device *bmc;\n\tint rv;\n\n\tif (dev->type != &bmc_device_type)\n\t\treturn 0;\n\n\tbmc = to_bmc_device(dev);\n\trv = (bmc->id.product_id == cid->product_id\n\t      && bmc->id.device_id == cid->device_id);\n\tif (rv)\n\t\trv = kref_get_unless_zero(&bmc->usecount);\n\treturn rv;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":265997,"func":"void crypto_unregister_skcipher(struct skcipher_alg *alg)\n{\n\tcrypto_unregister_alg(&alg->base);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":256582,"func":"static inline uint32_t cirrus_src32 ( CirrusVGAState * s , uint32_t srcaddr ) {\n uint32_t * src ;\n if ( s -> cirrus_srccounter ) {\n src = ( void * ) & s -> cirrus_bltbuf [ srcaddr & ( CIRRUS_BLTBUFSIZE - 1 ) & ~ 3 ] ;\n }\n else {\n src = ( void * ) & s -> vga . vram_ptr [ srcaddr & s -> cirrus_addr_mask & ~ 3 ] ;\n }\n return * src ;\n }","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":476447,"func":"static int rtsx_usb_ms_suspend(struct device *dev)\n{\n\tstruct rtsx_usb_ms *host = dev_get_drvdata(dev);\n\tstruct memstick_host *msh = host->msh;\n\n\t\/* Since we use rtsx_usb's resume callback to runtime resume its\n\t * children to implement remote wakeup signaling, this causes\n\t * rtsx_usb_ms' runtime resume callback runs after its suspend\n\t * callback:\n\t * rtsx_usb_ms_suspend()\n\t * rtsx_usb_resume()\n\t *   -> rtsx_usb_ms_runtime_resume()\n\t *     -> memstick_detect_change()\n\t *\n\t * rtsx_usb_suspend()\n\t *\n\t * To avoid this, skip runtime resume\/suspend if system suspend is\n\t * underway.\n\t *\/\n\n\thost->system_suspending = true;\n\tmemstick_suspend_host(msh);\n\n\treturn 0;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":184169,"func":"void RenderViewImpl::FocusNext() {\n  Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false));\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":364602,"func":"static char *nntp_parsesuccess(char *str, const char **status)\n{\n    char *success = NULL;\n\n    if (!strncmp(str, \"283 \", 4)) {\n\tsuccess = str+4;\n    }\n\n    if (status) *status = NULL;\n    return success;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":423326,"func":"static inline void tcp_openreq_init(struct request_sock *req,\n\t\t\t\t    struct tcp_options_received *rx_opt,\n\t\t\t\t    struct sk_buff *skb)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\n\treq->rcv_wnd = 0;\t\t\/* So that tcp_send_synack() knows! *\/\n\treq->cookie_ts = 0;\n\ttcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;\n\ttcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;\n\ttcp_rsk(req)->snt_synack = 0;\n\treq->mss = rx_opt->mss_clamp;\n\treq->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;\n\tireq->tstamp_ok = rx_opt->tstamp_ok;\n\tireq->sack_ok = rx_opt->sack_ok;\n\tireq->snd_wscale = rx_opt->snd_wscale;\n\tireq->wscale_ok = rx_opt->wscale_ok;\n\tireq->acked = 0;\n\tireq->ecn_ok = 0;\n\tireq->ir_rmt_port = tcp_hdr(skb)->source;\n\tireq->ir_num = ntohs(tcp_hdr(skb)->dest);\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":311088,"func":"void NavigationControllerImpl::RendererDidNavigateInPage(\n    const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) {\n  DCHECK(PageTransitionIsMainFrame(params.transition)) <<\n      \"WebKit should only tell us about in-page navs for the main frame.\";\n  NavigationEntryImpl* existing_entry = GetEntryWithPageID(\n      web_contents_->GetSiteInstance(), params.page_id);\n\n  existing_entry->SetURL(params.url);\n  if (existing_entry->update_virtual_url_with_url())\n    UpdateVirtualURLToURL(existing_entry, params.url);\n\n  *did_replace_entry = true;\n\n  DiscardNonCommittedEntriesInternal();\n\n  last_committed_entry_index_ =\n      GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id);\n}\n","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":6623,"func":"monitor_init(void)\n{\n\tstruct ssh *ssh = active_state;\t\t\t\/* XXX *\/\n\tstruct monitor *mon;\n\n\tmon = xcalloc(1, sizeof(*mon));\n\n\tmonitor_openfds(mon, 1);\n\n\t\/* Used to share zlib space across processes *\/\n\tif (options.compression) {\n\t\tmon->m_zback = mm_create(NULL, MM_MEMSIZE);\n\t\tmon->m_zlib = mm_create(mon->m_zback, 20 * MM_MEMSIZE);\n\n\t\t\/* Compression needs to share state across borders *\/\n\t\tssh_packet_set_compress_hooks(ssh, mon->m_zlib,\n\t\t    (ssh_packet_comp_alloc_func *)mm_zalloc,\n\t\t    (ssh_packet_comp_free_func *)mm_zfree);\n\t}\n\n\treturn mon;\n}","target":1,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":155887,"func":"static void rds_ib_sub_signaled(struct rds_ib_connection *ic, int nr)\n{\n\tif ((atomic_sub_return(nr, &ic->i_signaled_sends) == 0) &&\n\t    waitqueue_active(&rds_ib_ring_empty_wait))\n\t\twake_up(&rds_ib_ring_empty_wait);\n\tBUG_ON(atomic_read(&ic->i_signaled_sends) < 0);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":125102,"func":"FileModule *_af_ms_adpcm_init_compress (Track *track, File *fh,\n\tbool canSeek, bool headerless, AFframecount *chunkFrames)\n{\n\treturn MSADPCM::createCompress(track, fh, canSeek, headerless, chunkFrames);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":431758,"func":"    CmdMergeAuthzCollections() : Command(\"_mergeAuthzCollections\") {}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":8931,"func":"void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)\n{\n    if (!dd->locked)\n        error_msg_and_die(\"dump_dir is not opened\"); \/* bug *\/\n\n    if (!str_is_correct_filename(name))\n        error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n\n    char *full_path = concat_path_file(dd->dd_dirname, name);\n    save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);\n    free(full_path);\n}","target":1,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":334819,"func":"void event_notifier_set_handler(EventNotifier *e,\n\n                                EventNotifierHandler *handler)\n\n{\n\n    iohandler_init();\n\n    aio_set_event_notifier(iohandler_ctx, e, false,\n\n                           handler, NULL);\n\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":122567,"func":"njs_array_length_redefine(njs_vm_t *vm, njs_value_t *value, uint32_t length)\n{\n    njs_object_prop_t  *prop;\n\n    static const njs_value_t  string_length = njs_string(\"length\");\n\n    if (njs_slow_path(!njs_is_array(value))) {\n        njs_internal_error(vm, \"njs_array_length_redefine() \"\n                           \"applied to non-array\");\n        return NJS_ERROR;\n    }\n\n    prop = njs_object_property_add(vm, value, njs_value_arg(&string_length), 1);\n    if (njs_slow_path(prop == NULL)) {\n        njs_internal_error(vm, \"njs_array_length_redefine() \"\n                           \"cannot redefine \\\"length\\\"\");\n        return NJS_ERROR;\n    }\n\n    prop->enumerable = 0;\n    prop->configurable = 0;\n\n    njs_value_number_set(&prop->value, length);\n\n    return NJS_OK;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":57552,"func":"bool proc_fill_cache(struct file *file, struct dir_context *ctx,\n\tconst char *name, int len,\n\tinstantiate_t instantiate, struct task_struct *task, const void *ptr)\n{\n\tstruct dentry *child, *dir = file->f_path.dentry;\n\tstruct qstr qname = QSTR_INIT(name, len);\n\tstruct inode *inode;\n\tunsigned type;\n\tino_t ino;\n\n\tchild = d_hash_and_lookup(dir, &qname);\n\tif (!child) {\n\t\tchild = d_alloc(dir, &qname);\n\t\tif (!child)\n\t\t\tgoto end_instantiate;\n\t\tif (instantiate(d_inode(dir), child, task, ptr) < 0) {\n\t\t\tdput(child);\n\t\t\tgoto end_instantiate;\n\t\t}\n\t}\n\tinode = d_inode(child);\n\tino = inode->i_ino;\n\ttype = inode->i_mode >> 12;\n\tdput(child);\n\treturn dir_emit(ctx, name, len, ino, type);\n\nend_instantiate:\n\treturn dir_emit(ctx, name, len, 1, DT_UNKNOWN);\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":211484,"func":"bool TabStrip::IsTabStripCloseable() const {\n  return !IsDragSessionActive();\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":232254,"func":"MYSQLND_METHOD(mysqlnd_protocol, get_row_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC)\n{\n\tstruct st_mysqlnd_packet_row * packet = mnd_pecalloc(1, packet_methods[PROT_ROW_PACKET].struct_size, persistent);\n\tDBG_ENTER(\"mysqlnd_protocol::get_row_packet\");\n\tif (packet) {\n\t\tpacket->header.m = &packet_methods[PROT_ROW_PACKET];\n\t\tpacket->header.persistent = persistent;\n\t}\n\tDBG_RETURN(packet);\n}\n","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":11738,"func":" void OPENSSL_fork_child(void)\n {\n    rand_fork();\n }\n","target":1,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":125427,"func":"static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)\n{\n\treturn (pud_t *)pgd_page_vaddr(*pgd) + pud_index(address);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":278470,"func":"void BrowserWindowGtk::Paste() {\n  gtk_window_util::DoPaste(\n      window_, chrome::GetActiveWebContents(browser_.get()));\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":92737,"func":"static int _notifier_call_chain(struct regulator_dev *rdev,\n\t\t\t\t  unsigned long event, void *data)\n{\n\t\/* call rdev chain first *\/\n\treturn blocking_notifier_call_chain(&rdev->notifier, event, data);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":117825,"func":"static void hns_gmac_autoneg_stat(void *mac_drv, u32 *enable)\n{\n\tstruct mac_driver *drv = (struct mac_driver *)mac_drv;\n\n\t*enable = dsaf_get_dev_bit(drv, GMAC_TRANSMIT_CONTROL_REG,\n\t\t\t\t   GMAC_TX_AN_EN_B);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":79419,"func":"fst_q_work_item(u64 * queue, int card_index)\n{\n\tunsigned long flags;\n\tu64 mask;\n\n\t\/*\n\t * Grab the queue exclusively\n\t *\/\n\tspin_lock_irqsave(&fst_work_q_lock, flags);\n\n\t\/*\n\t * Making an entry in the queue is simply a matter of setting\n\t * a bit for the card indicating that there is work to do in the\n\t * bottom half for the card.  Note the limitation of 64 cards.\n\t * That ought to be enough\n\t *\/\n\tmask = (u64)1 << card_index;\n\t*queue |= mask;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":33914,"func":"static void sigterm(int sig)\n{\n    const int olderrno = errno;\n    (void) sig;\n\n    stop_server = 1;\n    if (listenfd != -1) {\n        shutdown(listenfd, 2);\n        (void) close(listenfd);\n    }\n    if (listenfd6 != -1) {\n        shutdown(listenfd6, 2);\n        (void) close(listenfd6);\n    }\n    errno = olderrno;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":494973,"func":"static vm_fault_t snd_pcm_mmap_data_fault(struct vm_fault *vmf)\n{\n\tstruct snd_pcm_substream *substream = vmf->vma->vm_private_data;\n\tstruct snd_pcm_runtime *runtime;\n\tunsigned long offset;\n\tstruct page * page;\n\tsize_t dma_bytes;\n\t\n\tif (substream == NULL)\n\t\treturn VM_FAULT_SIGBUS;\n\truntime = substream->runtime;\n\toffset = vmf->pgoff << PAGE_SHIFT;\n\tdma_bytes = PAGE_ALIGN(runtime->dma_bytes);\n\tif (offset > dma_bytes - PAGE_SIZE)\n\t\treturn VM_FAULT_SIGBUS;\n\tif (substream->ops->page)\n\t\tpage = substream->ops->page(substream, offset);\n\telse if (!snd_pcm_get_dma_buf(substream))\n\t\tpage = virt_to_page(runtime->dma_area + offset);\n\telse\n\t\tpage = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset);\n\tif (!page)\n\t\treturn VM_FAULT_SIGBUS;\n\tget_page(page);\n\tvmf->page = page;\n\treturn 0;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":324188,"func":"static const char *token_get_value(QObject *obj)\n\n{\n\n    return qdict_get_str(qobject_to_qdict(obj), \"token\");\n\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":377562,"func":"static int ide_handle_rw_error(IDEState *s, int error, int op)\n{\n    bool is_read = (op & BM_STATUS_RETRY_READ) != 0;\n    BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error);\n\n    if (action == BDRV_ACTION_STOP) {\n        s->bus->dma->ops->set_unit(s->bus->dma, s->unit);\n        s->bus->error_status = op;\n    } else if (action == BDRV_ACTION_REPORT) {\n        if (op & BM_STATUS_DMA_RETRY) {\n            dma_buf_commit(s);\n            ide_dma_error(s);\n        } else {\n            ide_rw_error(s);\n        }\n    }\n    bdrv_error_action(s->bs, action, is_read, error);\n    return action != BDRV_ACTION_IGNORE;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":109535,"func":"float32 helper_fqtos(CPUSPARCState *env)\n\n{\n\n    float32 ret;\n\n    clear_float_exceptions(env);\n\n    ret = float128_to_float32(QT1, &env->fp_status);\n\n    check_ieee_exceptions(env);\n\n    return ret;\n\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":221423,"func":"String Document::OutgoingReferrer() const {\n\n  const Document* referrer_document = this;\n\n  if (GetSecurityOrigin()->IsOpaque())\n    return String();\n\n  if (LocalFrame* frame = frame_) {\n    while (frame->GetDocument()->IsSrcdocDocument()) {\n      frame = To<LocalFrame>(frame->Tree().Parent());\n      DCHECK(frame);\n    }\n    referrer_document = frame->GetDocument();\n  }\n\n  return referrer_document->url_.StrippedForUseAsReferrer();\n}\n","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":191862,"func":"void ewk_view_pre_render_cancel(Evas_Object* ewkView)\n{\n    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);\n    EINA_SAFETY_ON_NULL_RETURN(smartData->api->pre_render_cancel);\n    smartData->api->pre_render_cancel(smartData);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":121308,"func":"DEFINE_TEST(test_read_too_many_filters)\n{\n\tconst char *name = \"test_read_too_many_filters.gz\";\n\tstruct archive *a;\n\tint r;\n\n\tassert((a = archive_read_new()) != NULL);\n\tr = archive_read_support_filter_gzip(a);\n\tif (r == ARCHIVE_WARN) {\n\t\tskipping(\"gzip reading not fully supported on this platform\");\n\t}\n\tassertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));\n\textract_reference_file(name);\n\tassertEqualIntA(a, ARCHIVE_FATAL,\n\t    archive_read_open_filename(a, name, 200));\n\n\tassertEqualInt(ARCHIVE_OK, archive_read_close(a));\n\tassertEqualInt(ARCHIVE_OK, archive_read_free(a));\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":427157,"func":"static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,\n\t\t\t\tstruct gvt_dma *entry)\n{\n\trb_erase(&entry->gfn_node, &vgpu->vdev.gfn_cache);\n\trb_erase(&entry->dma_addr_node, &vgpu->vdev.dma_addr_cache);\n\tkfree(entry);\n\tvgpu->vdev.nr_cache_entries--;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":178606,"func":"void FrameLoader::setDefersLoading(bool defers)\n{\n    if (m_documentLoader)\n        m_documentLoader->setDefersLoading(defers);\n    if (m_provisionalDocumentLoader)\n        m_provisionalDocumentLoader->setDefersLoading(defers);\n    if (m_policyDocumentLoader)\n        m_policyDocumentLoader->setDefersLoading(defers);\n\n    if (!defers) {\n        m_frame->redirectScheduler()->startTimer();\n        startCheckCompleteTimer();\n    }\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":311768,"func":"void FinishParseMediaMetadata(\n    metadata::MediaMetadataParser* \/* parser *\/,\n    const extensions::api::media_galleries::MediaMetadata& metadata,\n    const std::vector<metadata::AttachedImage>& attached_images) {\n  Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished(\n      true, *metadata.ToValue(), attached_images));\n  ReleaseProcessIfNeeded();\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":439977,"func":"void\nhttp_parser_init (http_parser *parser, enum http_parser_type t)\n{\n  void *data = parser->data; \/* preserve application data *\/\n  memset(parser, 0, sizeof(*parser));\n  parser->data = data;\n  parser->type = t;\n  parser->state = (t == HTTP_REQUEST ? s_start_req : (t == HTTP_RESPONSE ? s_start_res : s_start_req_or_res));\n  parser->http_errno = HPE_OK;","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":456400,"func":"static void delete_char(struct vc_data *vc, unsigned int nr)\n{\n\tunsigned short *p = (unsigned short *) vc->vc_pos;\n\n\tvc_uniscr_delete(vc, nr);\n\tscr_memcpyw(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2);\n\tscr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char,\n\t\t\tnr * 2);\n\tvc->vc_need_wrap = 0;\n\tif (con_should_update(vc))\n\t\tdo_update_region(vc, (unsigned long) p,\n\t\t\tvc->vc_cols - vc->state.x);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":56330,"func":"static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr)\n{\n\tstruct sctp_hashbucket *head;\n\tstruct sctp_ep_common *epb;\n\tstruct sctp_endpoint *ep;\n\tstruct hlist_node *node;\n\tint hash;\n\n\thash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port));\n\thead = &sctp_ep_hashtable[hash];\n\tread_lock(&head->lock);\n\tsctp_for_each_hentry(epb, node, &head->chain) {\n\t\tep = sctp_ep(epb);\n\t\tif (sctp_endpoint_is_match(ep, laddr))\n\t\t\tgoto hit;\n\t}\n\n\tep = sctp_sk((sctp_get_ctl_sock()))->ep;\n\nhit:\n\tsctp_endpoint_hold(ep);\n\tread_unlock(&head->lock);\n\treturn ep;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":380466,"func":"evbuffer_expand(struct evbuffer *buf, size_t datlen)\n{\n\tstruct evbuffer_chain *chain;\n\n\tEVBUFFER_LOCK(buf);\n\tchain = evbuffer_expand_singlechain(buf, datlen);\n\tEVBUFFER_UNLOCK(buf);\n\treturn chain ? 0 : -1;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":211566,"func":"void InspectorPageAgent::setDeviceOrientationOverride(ErrorString* error, double alpha, double beta, double gamma)\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":45014,"func":"void *UntrustedCacheMalloc::GetBuffer() {\n  void **buffers = nullptr;\n  void *buffer;\n  bool is_pool_empty;\n\n  {\n    LockGuard spin_lock(&lock_);\n    is_pool_empty = buffer_pool_.empty();\n    if (is_pool_empty) {\n      buffers =\n          primitives::AllocateUntrustedBuffers(kPoolIncrement, kPoolEntrySize);\n      for (int i = 0; i < kPoolIncrement; i++) {\n        void *buf = buffers[i];\n        if (!buf || !TrustedPrimitives::IsOutsideEnclave(buf, kPoolEntrySize)) {\n          TrustedPrimitives::BestEffortAbort(\n              \"Cached buffer is not outside the enclave\");\n        }\n        buffer_pool_.push(buf);\n      }\n    }\n    buffer = buffer_pool_.top();\n    buffer_pool_.pop();\n    busy_buffers_.insert(buffer);\n  }\n\n  if (is_pool_empty) {\n    \/\/ Free memory held by the array of buffer pointers returned by\n    \/\/ AllocateUntrustedBuffers.\n    Free(buffers);\n  }\n  return buffer;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":398387,"func":"inbound_cap_nak (server *serv, const message_tags_data *tags_data)\n{\n\tserv->sent_capend = TRUE;\n\ttcp_send_len (serv, \"CAP END\\r\\n\", 9);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":277613,"func":"void AppCacheUpdateJob::FetchManifest(bool is_first_fetch) {\n  DCHECK(!manifest_fetcher_);\n  manifest_fetcher_ = new URLFetcher(\n     manifest_url_,\n     is_first_fetch ? URLFetcher::MANIFEST_FETCH :\n                      URLFetcher::MANIFEST_REFETCH,\n     this);\n\n  if (is_first_fetch) {\n    AppCacheEntry* entry = (update_type_ == UPGRADE_ATTEMPT) ?\n        group_->newest_complete_cache()->GetEntry(manifest_url_) : NULL;\n    if (entry && !doing_full_update_check_) {\n      storage_->LoadResponseInfo(manifest_url_, group_->group_id(),\n                                 entry->response_id(), this);\n      return;\n    }\n    manifest_fetcher_->Start();\n    return;\n  }\n\n  DCHECK(internal_state_ == REFETCH_MANIFEST);\n  DCHECK(manifest_response_info_.get());\n  manifest_fetcher_->set_existing_response_headers(\n      manifest_response_info_->headers.get());\n  manifest_fetcher_->Start();\n}\n","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":72436,"func":"correct_range(exarg_T *eap)\n{\n    if (!(eap->argt & ZEROR))\t    \/* zero in range not allowed *\/\n    {\n\tif (eap->line1 == 0)\n\t    eap->line1 = 1;\n\tif (eap->line2 == 0)\n\t    eap->line2 = 1;\n    }\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":221473,"func":"get_object_start(void *state)\n{\n\tGetState   *_state = (GetState *) state;\n\tint\t\t\tlex_level = _state->lex->lex_level;\n\n\tif (lex_level == 0 && _state->npath == 0)\n\t{\n\t\t\/*\n\t\t * Special case: we should match the entire object.  We only need this\n\t\t * at outermost level because at nested levels the match will have\n\t\t * been started by the outer field or array element callback.\n\t\t *\/\n\t\t_state->result_start = _state->lex->token_start;\n\t}\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":46970,"func":"struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)\n{\n\tstruct mm_struct *mm;\n\tint err;\n\n\terr =  mutex_lock_killable(&task->signal->exec_update_mutex);\n\tif (err)\n\t\treturn ERR_PTR(err);\n\n\tmm = get_task_mm(task);\n\tif (mm && mm != current->mm &&\n\t\t\t!ptrace_may_access(task, mode)) {\n\t\tmmput(mm);\n\t\tmm = ERR_PTR(-EACCES);\n\t}\n\tmutex_unlock(&task->signal->exec_update_mutex);\n\n\treturn mm;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":207109,"func":"  void VerifyPrintPreviewGenerated(bool generated_preview) {\n    const IPC::Message* preview_msg =\n        render_thread_.sink().GetUniqueMessageMatching(\n            PrintHostMsg_MetafileReadyForPrinting::ID);\n    bool did_get_preview_msg = (NULL != preview_msg);\n    ASSERT_EQ(generated_preview, did_get_preview_msg);\n    if (did_get_preview_msg) {\n      PrintHostMsg_MetafileReadyForPrinting::Param preview_param;\n      PrintHostMsg_MetafileReadyForPrinting::Read(preview_msg, &preview_param);\n      EXPECT_NE(0, preview_param.a.document_cookie);\n      EXPECT_NE(0, preview_param.a.expected_pages_count);\n      EXPECT_NE(0U, preview_param.a.data_size);\n    }\n  }\n","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":343290,"func":"static struct scsi_task *iscsi_do_inquiry(struct iscsi_context *iscsi, int lun,\n\n                                          int evpd, int pc)\n\n{\n\n    int full_size;\n\n    struct scsi_task *task = NULL;\n\n    task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, 64);\n\n    if (task == NULL || task->status != SCSI_STATUS_GOOD) {\n\n        goto fail;\n\n    }\n\n    full_size = scsi_datain_getfullsize(task);\n\n    if (full_size > task->datain.size) {\n\n        scsi_free_scsi_task(task);\n\n\n\n        \/* we need more data for the full list *\/\n\n        task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, full_size);\n\n        if (task == NULL || task->status != SCSI_STATUS_GOOD) {\n\n            goto fail;\n\n        }\n\n    }\n\n\n\n    return task;\n\n\n\nfail:\n\n    error_report(\"iSCSI: Inquiry command failed : %s\",\n\n                 iscsi_get_error(iscsi));\n\n    if (task) {\n\n        scsi_free_scsi_task(task);\n\n        return NULL;\n\n    }\n\n    return NULL;\n\n}\n","target":1,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":404912,"func":"static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src)\n{\n\tstruct l2cap_chan *c;\n\n\tlist_for_each_entry(c, &chan_list, global_l) {\n\t\tif (c->sport == psm && !bacmp(&c->src, src))\n\t\t\treturn c;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":19600,"func":"static void cirrus_bitblt_reset ( CirrusVGAState * s ) {\n int need_update ;\n s -> vga . gr [ 0x31 ] &= ~ ( CIRRUS_BLT_START | CIRRUS_BLT_BUSY | CIRRUS_BLT_FIFOUSED ) ;\n need_update = s -> cirrus_srcptr != & s -> cirrus_bltbuf [ 0 ] || s -> cirrus_srcptr_end != & s -> cirrus_bltbuf [ 0 ] ;\n s -> cirrus_srcptr = & s -> cirrus_bltbuf [ 0 ] ;\n s -> cirrus_srcptr_end = & s -> cirrus_bltbuf [ 0 ] ;\n s -> cirrus_srccounter = 0 ;\n if ( ! need_update ) return ;\n cirrus_update_memory_access ( s ) ;\n }","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":277492,"func":"void Gfx::doEndPath() {\n  if (state->isCurPt() && clip != clipNone) {\n    state->clip();\n    if (clip == clipNormal) {\n      out->clip(state);\n    } else {\n      out->eoClip(state);\n    }\n  }\n  clip = clipNone;\n  state->clearPath();\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":151527,"func":"void Context::onQueueReady(uint32_t token) {\n  if (wasm_->onQueueReady_) {\n    wasm_->onQueueReady_(this, id_, token);\n  }\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":279629,"func":"void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData)\n{\n    updateInvalidationSets(ruleData);\n\n    FeatureMetadata metadata;\n    collectFeaturesFromSelector(ruleData.selector(), metadata);\n    m_metadata.add(metadata);\n\n    if (metadata.foundSiblingSelector)\n        siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));\n    if (ruleData.containsUncommonAttributeSelector())\n        uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":72364,"func":"int PageHuge(struct page *page)\n{\n\tcompound_page_dtor *dtor;\n\n\tif (!PageCompound(page))\n\t\treturn 0;\n\n\tpage = compound_head(page);\n\tdtor = get_compound_page_dtor(page);\n\n\treturn dtor == free_huge_page;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":206486,"func":"bool ContentSecurityPolicy::IsNonceableElement(const Element* element) {\n  if (element->nonce().IsNull())\n    return false;\n\n  bool nonceable = true;\n\n  if (nonceable) {\n    static const char kScriptString[] = \"<SCRIPT\";\n    static const char kStyleString[] = \"<STYLE\";\n    for (const Attribute& attr : element->Attributes()) {\n      const AtomicString& name = attr.LocalName();\n      const AtomicString& value = attr.Value();\n      if (name.FindIgnoringASCIICase(kScriptString) != WTF::kNotFound ||\n          name.FindIgnoringASCIICase(kStyleString) != WTF::kNotFound ||\n          value.FindIgnoringASCIICase(kScriptString) != WTF::kNotFound ||\n          value.FindIgnoringASCIICase(kStyleString) != WTF::kNotFound) {\n        nonceable = false;\n        break;\n      }\n    }\n  }\n\n  UseCounter::Count(\n      element->GetDocument(),\n      nonceable ? WebFeature::kCleanScriptElementWithNonce\n                : WebFeature::kPotentiallyInjectedScriptElementWithNonce);\n\n  return nonceable;\n}\n","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":454030,"func":"    BSONObj spec() {\n        return BSON(\"$eq\" << BSON_ARRAY(1 << \"$a\"));\n    }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":523498,"func":"bool LEX::stmt_uninstall_plugin_by_soname(const DDL_options_st &opt,\n                                          const LEX_CSTRING &soname)\n{\n  check_opt.init();\n  if (add_create_options_with_check(opt))\n    return true;\n  sql_command= SQLCOM_UNINSTALL_PLUGIN;\n  comment= null_clex_str;\n  ident= soname;\n  return false;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":107651,"func":"int SSL_set_session_secret_cb(SSL *s,\n                              int (*tls_session_secret_cb) (SSL *s,\n                                                            void *secret,\n                                                            int *secret_len,\n                                                            STACK_OF(SSL_CIPHER)\n                                                            *peer_ciphers,\n                                                            SSL_CIPHER\n                                                            **cipher,\n                                                            void *arg),\n                              void *arg)\n{\n    if (s == NULL)\n        return (0);\n    s->tls_session_secret_cb = tls_session_secret_cb;\n    s->tls_session_secret_cb_arg = arg;\n    return (1);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":386288,"func":"static void MClearArea(Window *p, int xs, int ys, int xe, int ye, int bce)\n{\n\tint n, y;\n\tint xxe;\n\tstruct mline *ml;\n\n\t\/* Check for zero-height window *\/\n\tif (ys < 0 || ye < ys)\n\t\treturn;\n\n\t\/* check for magic margin condition *\/\n\tif (xs >= p->w_width)\n\t\txs = p->w_width - 1;\n\tif (xe >= p->w_width)\n\t\txe = p->w_width - 1;\n\n\tMKillDwRight(p, p->w_mlines + ys, xs);\n\tMKillDwLeft(p, p->w_mlines + ye, xe);\n\n\tml = p->w_mlines + ys;\n\tfor (y = ys; y <= ye; y++, ml++) {\n\t\txxe = (y == ye) ? xe : p->w_width - 1;\n\t\tn = xxe - xs + 1;\n\t\tif (n > 0)\n\t\t\tclear_mline(ml, xs, n);\n\t\tif (n > 0 && bce)\n\t\t\tMBceLine(p, y, xs, xs + n - 1, bce);\n\t\txs = 0;\n\t}\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":523672,"func":"int ssl_prepare_clienthello_tlsext(SSL *s)\n{\n    s->s3->alpn_sent = 0;\n    return 1;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":60536,"func":"Status GetElementShapeFromInput(OpKernelContext* c,\n                                const TensorList& tensor_list, int index,\n                                PartialTensorShape* element_shape) {\n  TF_RETURN_IF_ERROR(TensorShapeFromTensor(c->input(index), element_shape));\n  \/\/ Check that `element_shape` and `tensor_list.element_shape` are\n  \/\/ compatible and store the merged shape in `element_shape`.\n  PartialTensorShape tmp = *element_shape;\n  TF_RETURN_IF_ERROR(tmp.MergeWith(tensor_list.element_shape, element_shape));\n  return Status::OK();\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":271261,"func":"GF_Err gf_laser_decoder_remove_stream(GF_LASeRCodec *codec, u16 ESID)\n{\n\tu32 i, count;\n\tcount = gf_list_count(codec->streamInfo);\n\tfor (i=0; i<count; i++) {\n\t\tLASeRStreamInfo *ptr = (LASeRStreamInfo *) gf_list_get(codec->streamInfo, i);\n\t\tif (ptr->ESID==ESID) {\n\t\t\tgf_free(ptr);\n\t\t\tgf_list_rem(codec->streamInfo, i);\n\t\t\treturn GF_OK;\n\t\t}\n\t}\n\treturn GF_BAD_PARAM;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":397083,"func":"ircam_type_find (GstTypeFind * tf, gpointer ununsed)\n{\n  const guint8 *data = gst_type_find_peek (tf, 0, 4);\n  guint8 mask[4] = { 0xFF, 0xFF, 0xF8, 0xFF };\n  guint8 match[4] = { 0x64, 0xA3, 0x00, 0x00 };\n  gint x;\n  gboolean matched = TRUE;\n\n  if (!data) {\n    return;\n  }\n  for (x = 0; x < 4; x++) {\n    if ((data[x] & mask[x]) != match[x]) {\n      matched = FALSE;\n    }\n  }\n  if (matched) {\n    gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, IRCAM_CAPS);\n    return;\n  }\n  \/* now try the reverse version *\/\n  matched = TRUE;\n  for (x = 0; x < 4; x++) {\n    if ((data[x] & mask[3 - x]) != match[3 - x]) {\n      matched = FALSE;\n    }\n  }\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":496710,"func":"static bool is_partition_in_criterias(\n        const std::string& partition,\n        const std::vector<Criteria>& criterias)\n{\n    bool returned_value = false;\n\n    for (auto criteria_it = criterias.begin(); !returned_value &&\n            criteria_it != criterias.end(); ++criteria_it)\n    {\n        for (auto part : (*criteria_it).partitions)\n        {\n            if (StringMatching::matchPattern(part.c_str(), partition.c_str()))\n            {\n                returned_value = true;\n                break;\n            }\n        }\n    }\n\n    return returned_value;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":433891,"func":"    bool encode(FilterChar * & in0, FilterChar * & stop,\n                FilterCharVector & out) const {\n      FilterChar * in = in0;\n      for (; in != stop; ++in)\n        *in = lookup(*in);\n      return true;\n    }","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":409183,"func":"static js_Ast *unary(js_State *J)\n{\n\tjs_Ast *a;\n\tINCREC();\n\tif (jsP_accept(J, TK_DELETE)) a = EXP1(DELETE, unary(J));\n\telse if (jsP_accept(J, TK_VOID)) a = EXP1(VOID, unary(J));\n\telse if (jsP_accept(J, TK_TYPEOF)) a = EXP1(TYPEOF, unary(J));\n\telse if (jsP_accept(J, TK_INC)) a = EXP1(PREINC, unary(J));\n\telse if (jsP_accept(J, TK_DEC)) a = EXP1(PREDEC, unary(J));\n\telse if (jsP_accept(J, '+')) a = EXP1(POS, unary(J));\n\telse if (jsP_accept(J, '-')) a = EXP1(NEG, unary(J));\n\telse if (jsP_accept(J, '~')) a = EXP1(BITNOT, unary(J));\n\telse if (jsP_accept(J, '!')) a = EXP1(LOGNOT, unary(J));\n\telse a = postfix(J);\n\tDECREC();\n\treturn a;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":216772,"func":"void ScrollableShelfView::ScrollToXOffset(float x_target_offset,\n                                          bool animating) {\n  x_target_offset = CalculateClampedScrollOffset(x_target_offset);\n  const float old_x = scroll_offset_.x();\n  scroll_offset_.set_x(x_target_offset);\n  Layout();\n  const float diff = x_target_offset - old_x;\n\n  if (animating)\n    StartShelfScrollAnimation(diff);\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":41652,"func":"static inline Quantum GetPixela(const Image *restrict image,\n  const Quantum *restrict pixel)\n{\n  return(pixel[image->channel_map[aPixelChannel].offset]);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":198414,"func":"void OxideQQuickWebViewPrivate::DownloadRequested(\n    const OxideQDownloadRequest& download_request) {\n  Q_Q(OxideQQuickWebView);\n\n  emit q->downloadRequested(download_request);\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":521284,"func":"  With_sum_func_cache(const Item *a, const Item *b, const Item *c)\n   :m_with_sum_func(a->with_sum_func() || b->with_sum_func() ||\n                    c->with_sum_func())\n  { }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":354787,"func":"static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl)\n{\n\treturn -EIO;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":488201,"func":"static inline int ok_jpg_load_next_bits(ok_jpg_decoder *decoder, int num_bits) {\n    ok_jpg_load_bits(decoder, num_bits);\n    int mask = (1 << num_bits) - 1;\n    decoder->input_buffer_bit_count -= num_bits;\n    return (int)(decoder->input_buffer_bits >> decoder->input_buffer_bit_count) & mask;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":182571,"func":"unsigned long AudioHandler::ChannelCount() {\n  return channel_count_;\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":210635,"func":"void BrowserView::ToggleBookmarkBar() {\n  bookmark_utils::ToggleWhenVisible(browser_->profile());\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":241237,"func":"void RenderWidgetHostImpl::OnSnapshotReceived(int snapshot_id,\n                                              gfx::Image image) {\n  PendingSnapshotMap::iterator it = pending_browser_snapshots_.begin();\n  while (it != pending_browser_snapshots_.end()) {\n    if (it->first <= snapshot_id) {\n      it->second.Run(image);\n      pending_browser_snapshots_.erase(it++);\n    } else {\n      ++it;\n    }\n  }\n#if defined(OS_MACOSX)\n  if (pending_browser_snapshots_.empty())\n    GetWakeLock()->CancelWakeLock();\n#endif\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":34013,"func":"static bool netlink_tx_is_mmaped(struct sock *sk)\n{\n\treturn nlk_sk(sk)->tx_ring.pg_vec != NULL;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":319165,"func":"void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t is_dcbzl)\n\n{\n\n    int dcbz_size = env->dcache_line_size;\n\n\n\n#if defined(TARGET_PPC64)\n\n    if (!is_dcbzl &&\n\n        (env->excp_model == POWERPC_EXCP_970) &&\n\n        ((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) {\n\n        dcbz_size = 32;\n\n    }\n\n#endif\n\n\n\n    \/* XXX add e500mc support *\/\n\n\n\n    do_dcbz(env, addr, dcbz_size, GETPC());\n\n}\n","target":1,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":333918,"func":"static void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v)\n\n{\n\n    TCGv_i64 tcg_zero = tcg_const_i64(0);\n\n\n\n    tcg_gen_st_i64(v, cpu_env, fp_reg_offset(reg, MO_64));\n\n    tcg_gen_st_i64(tcg_zero, cpu_env, fp_reg_hi_offset(reg));\n\n    tcg_temp_free_i64(tcg_zero);\n\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":138897,"func":"bool CIRCNetwork::PutIRC(const CMessage& Message) {\n    CIRCSock* pIRCSock = GetIRCSock();\n\n    if (!pIRCSock) {\n        return false;\n    }\n\n    pIRCSock->PutIRC(Message);\n    return true;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":252066,"func":"  SingleThreadTaskGraphRunner() {\n    Start(\"CompositorTileWorker1\", base::SimpleThread::Options());\n  }\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":148793,"func":"set_bound_node_opt_info(OptNode* opt, MinMax* plen)\n{\n  copy_mml(&(opt->sb.mmd),  plen);\n  copy_mml(&(opt->spr.mmd), plen);\n  copy_mml(&(opt->map.mmd), plen);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":186914,"func":"on_fileselector_done(void *user_data, Evas_Object *file_selector, void *event_info)\n{\n    FileSelectorData *fs_data = (FileSelectorData *)user_data;\n\n    const char *selected = (const char *)event_info;\n    if (selected && *selected)\n        ewk_file_chooser_request_file_choose(fs_data->request, selected);\n\n    close_file_picker(fs_data);\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":142477,"func":"static void i40e_pci_error_reset_prepare(struct pci_dev *pdev)\n{\n\tstruct i40e_pf *pf = pci_get_drvdata(pdev);\n\n\ti40e_prep_for_reset(pf, false);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":154904,"func":"get_login_name()\n{\n    static char buf[BUFSZ];\n    struct passwd *pw = get_unix_pw();\n\n    buf[0] = '\\0';\n    if (pw)\n        (void)strcpy(buf, pw->pw_name);\n\n    return buf;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":52441,"func":"  std::size_t num_entries() const { return ix_.dim_size(0); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":102430,"func":"TfLiteRegistration* Register_BIDIRECTIONAL_SEQUENCE_RNN() {\n  static TfLiteRegistration r = {\n      bidirectional_sequence_rnn::Init, bidirectional_sequence_rnn::Free,\n      bidirectional_sequence_rnn::Prepare, bidirectional_sequence_rnn::Eval};\n  return &r;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":41565,"func":"static struct extent_map *defrag_lookup_extent(struct inode *inode, u64 start)\n{\n\tstruct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;\n\tstruct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;\n\tstruct extent_map *em;\n\tu64 len = PAGE_CACHE_SIZE;\n\n\t\/*\n\t * hopefully we have this extent in the tree already, try without\n\t * the full extent lock\n\t *\/\n\tread_lock(&em_tree->lock);\n\tem = lookup_extent_mapping(em_tree, start, len);\n\tread_unlock(&em_tree->lock);\n\n\tif (!em) {\n\t\t\/* get the big lock and read metadata off disk *\/\n\t\tlock_extent(io_tree, start, start + len - 1);\n\t\tem = btrfs_get_extent(inode, NULL, 0, start, len, 0);\n\t\tunlock_extent(io_tree, start, start + len - 1);\n\n\t\tif (IS_ERR(em))\n\t\t\treturn NULL;\n\t}\n\n\treturn em;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":231554,"func":"ofputil_nx_flow_format_is_valid(enum nx_flow_format flow_format)\n{\n    return ofputil_nx_flow_format_to_protocol(flow_format) != 0;\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":471722,"func":"unsigned long zslGetRank(zskiplist *zsl, double score, sds ele) {\n    zskiplistNode *x;\n    unsigned long rank = 0;\n    int i;\n\n    x = zsl->header;\n    for (i = zsl->level-1; i >= 0; i--) {\n        while (x->level[i].forward &&\n            (x->level[i].forward->score < score ||\n                (x->level[i].forward->score == score &&\n                sdscmp(x->level[i].forward->ele,ele) <= 0))) {\n            rank += x->level[i].span;\n            x = x->level[i].forward;\n        }\n\n        \/* x might be equal to zsl->header, so test if obj is non-NULL *\/\n        if (x->ele && sdscmp(x->ele,ele) == 0) {\n            return rank;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":247628,"func":"LayoutRect RenderBlock::rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const\n{\n    LayoutRect r(RenderBox::rectWithOutlineForRepaint(repaintContainer, outlineWidth));\n    if (isAnonymousBlockContinuation())\n        r.inflateY(collapsedMarginBefore()); \/\/ FIXME: This is wrong for block-flows that are horizontal.\n    return r;\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":285136,"func":"static void CollectScrollbarUpdates(\n    ScrollAndScaleSet* scroll_info,\n    std::unordered_map<int, std::unique_ptr<ScrollbarAnimationController>>*\n        controllers) {\n  scroll_info->scrollbars.reserve(controllers->size());\n  for (auto& pair : *controllers) {\n    scroll_info->scrollbars.push_back(LayerTreeHostCommon::ScrollbarsUpdateInfo(\n        pair.first, pair.second->ScrollbarsHidden()));\n  }\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":172481,"func":"void gscms_set_icc_range(cmm_profile_t **icc_profile)\n{\n    int num_comp = (*icc_profile)->num_comps;\n    int k;\n\n    for ( k = 0; k < num_comp; k++) {\n        (*icc_profile)->Range.ranges[k].rmin = 0.0;\n        (*icc_profile)->Range.ranges[k].rmax = 1.0;\n    }\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":138890,"func":"static int set_procfs_val(const char *path, const char *val)\n{\n\tint rc = -1;\n\tFILE *fp = fopen(path, \"w\");\n\n\tif (fp) {\n\t\tif (fprintf(fp, \"%s\", val) > 0)\n\t\t\trc = 0;\n\t\tfclose(fp);\n\t}\n\treturn rc;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":125580,"func":"  uint32_t writeFieldBegin(\n      const char* name,\n      const TType fieldType,\n      const int16_t fieldId) {\n    T_VIRTUAL_CALL();\n    return writeFieldBegin_virt(name, fieldType, fieldId);\n  }","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":52618,"func":"int mp_invmod_mont_ct (mp_int * a, mp_int * b, mp_int * c, mp_digit mp)\n{\n  return fp_invmod_mont_ct(a, b, c, mp);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":44472,"func":"void c_SimpleXMLElementIterator::set_parent(c_SimpleXMLElement* parent) {\n  m_parent = parent;\n  reset_iterator();\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":28533,"func":"static void flush ( AVCodecContext * avctx ) {\n WMAProDecodeCtx * s = avctx -> priv_data ;\n int i ;\n for ( i = 0 ;\n i < avctx -> channels ;\n i ++ ) memset ( s -> channel [ i ] . out , 0 , s -> samples_per_frame * sizeof ( * s -> channel [ i ] . out ) ) ;\n s -> packet_loss = 1 ;\n }","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":395567,"func":"static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)\n{\n  DBUG_ENTER(\"binlog_savepoint_set\");\n\n  binlog_trans_log_savepos(thd, (my_off_t*) sv);\n\n  \/\/ buffer to store quoted identifier\n  char* buffer= (char *)my_malloc(sizeof(\"SAVEPOINT \")+ 1 + NAME_LEN * 2 + 2,\n                                  MYF(0));\n  String log_query(buffer, sizeof(buffer), system_charset_info);\n  log_query.length(0);\n\n  \/* Write it to the binary log *\/\n\n  if (log_query.append(STRING_WITH_LEN(\"SAVEPOINT \")))\n    DBUG_RETURN(1);\n  else\n    append_identifier(thd, &log_query, thd->lex->ident.str,\n                      thd->lex->ident.length);\n  int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);\n  Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),\n                        TRUE, FALSE, TRUE, errcode);\n  my_free(buffer);\n  DBUG_RETURN(mysql_bin_log.write(&qinfo));\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":453223,"func":"static bool address_char(int const c)\n{\n  return filename_char(c) ||\n         (c == ':') || (c == '[') || (c == ']') || (c == '\/');\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":49699,"func":"nfs_commit_list(struct inode *inode, struct list_head *head, int how,\n\t\tstruct nfs_commit_info *cinfo)\n{\n\tstruct nfs_commit_data\t*data;\n\n\tdata = nfs_commitdata_alloc();\n\n\tif (!data)\n\t\tgoto out_bad;\n\n\t\/* Set up the argument struct *\/\n\tnfs_init_commit(data, head, NULL, cinfo);\n\tatomic_inc(&cinfo->mds->rpcs_out);\n\treturn nfs_initiate_commit(NFS_CLIENT(inode), data, data->mds_ops,\n\t\t\t\t   how, 0);\n out_bad:\n\tnfs_retry_commit(head, NULL, cinfo);\n\tcinfo->completion_ops->error_cleanup(NFS_I(inode));\n\treturn -ENOMEM;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":458767,"func":"conntrack_flush(struct conntrack *ct, const uint16_t *zone)\n{\n    for (unsigned i = 0; i < CONNTRACK_BUCKETS; i++) {\n        struct conntrack_bucket *ctb = &ct->buckets[i];\n        ovs_mutex_lock(&ctb->cleanup_mutex);\n        ct_lock_lock(&ctb->lock);\n        for (unsigned j = 0; j < N_CT_TM; j++) {\n            struct conn *conn, *next;\n            LIST_FOR_EACH_SAFE (conn, next, exp_node, &ctb->exp_lists[j]) {\n                if (!zone || *zone == conn->key.zone) {\n                    conn_clean(ct, conn, ctb);\n                }\n            }\n        }\n        ct_lock_unlock(&ctb->lock);\n        ovs_mutex_unlock(&ctb->cleanup_mutex);\n    }\n\n    return 0;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":306903,"func":"void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)\n{\n    WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator>> nodeIteratorsList = m_nodeIterators;\n    for (NodeIterator* ni : nodeIteratorsList) {\n        if (ni->root() == node) {\n            detachNodeIterator(ni);\n            newDocument.attachNodeIterator(ni);\n        }\n    }\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":301805,"func":"menu_add_link(WebKitWebView *page, GArray *argv, GString *result) {\n    (void) page;\n    (void) result;\n\n    add_to_menu(argv, WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":356033,"func":"int udplite_get_port(struct sock *sk, unsigned short p,\n\t\t     int (*c)(const struct sock *, const struct sock *))\n{\n\treturn  __udp_lib_get_port(sk, p, udplite_hash, c);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":331819,"func":"int av_opt_set_pixel_fmt(void *obj, const char *name, enum AVPixelFormat fmt, int search_flags)\n\n{\n\n    return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_PIXEL_FMT, \"pixel\", AV_PIX_FMT_NB-1);\n\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":368683,"func":"eat_whitespace_no_nl(const char *s)\n{\n  while (*s == ' ' || *s == '\\t' || *s == '\\r')\n    ++s;\n  return s;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":512216,"func":"const char *imap_parser_read_word(struct imap_parser *parser)\n{\n\tconst unsigned char *data;\n\tsize_t i, data_size;\n\n\tdata = i_stream_get_data(parser->input, &data_size);\n\n\tfor (i = 0; i < data_size; i++) {\n\t\tif (data[i] == ' ' || data[i] == '\\r' || data[i] == '\\n')\n\t\t\tbreak;\n\t}\n\n\tif (i < data_size) {\n\t\tdata_size = i + (data[i] == ' ' ? 1 : 0);\n\t\tparser->line_size += data_size;\n\t\ti_stream_skip(parser->input, data_size);\n\t\treturn p_strndup(parser->pool, data, i);\n\t} else {\n\t\treturn NULL;\n\t}\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":351254,"func":"void ServerSecurityFeature::collectOptions(\n    std::shared_ptr<ProgramOptions> options) {\n  options\n      ->addOption(\n          \"--server.harden\",\n          \"lock down REST APIs that reveal version information or server \"\n          \"internals for non-admin users\",\n          new BooleanParameter(&_hardenedRestApi))\n      .setIntroducedIn(30500);\n\n  options\n      ->addOption(\"--foxx.api\", \"enables Foxx management REST APIs\",\n                  new BooleanParameter(&_enableFoxxApi),\n                  arangodb::options::makeFlags(\n                      arangodb::options::Flags::DefaultNoComponents,\n                      arangodb::options::Flags::OnCoordinator,\n                      arangodb::options::Flags::OnSingle))\n      .setIntroducedIn(30500);\n  options\n      ->addOption(\"--foxx.store\", \"enables Foxx store in web interface\",\n                  new BooleanParameter(&_enableFoxxStore),\n                  arangodb::options::makeFlags(\n                      arangodb::options::Flags::DefaultNoComponents,\n                      arangodb::options::Flags::OnCoordinator,\n                      arangodb::options::Flags::OnSingle))\n      .setIntroducedIn(30500);\n}","target":1,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":321682,"func":"static always_inline void gen_arith3 (void *helper,\n\n                                      int ra, int rb, int rc,\n\n                                      int islit, uint8_t lit)\n\n{\n\n    if (unlikely(rc == 31))\n\n        return;\n\n\n\n    if (ra != 31) {\n\n        if (islit) {\n\n            TCGv tmp = tcg_const_i64(lit);\n\n            tcg_gen_helper_1_2(helper, cpu_ir[rc], cpu_ir[ra], tmp);\n\n            tcg_temp_free(tmp);\n\n        } else\n\n            tcg_gen_helper_1_2(helper, cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);\n\n    } else {\n\n        TCGv tmp1 = tcg_const_i64(0);\n\n        if (islit) {\n\n            TCGv tmp2 = tcg_const_i64(lit);\n\n            tcg_gen_helper_1_2(helper, cpu_ir[rc], tmp1, tmp2);\n\n            tcg_temp_free(tmp2);\n\n        } else\n\n            tcg_gen_helper_1_2(helper, cpu_ir[rc], tmp1, cpu_ir[rb]);\n\n        tcg_temp_free(tmp1);\n\n    }\n\n}\n","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":449468,"func":"HttpHeader::getByNameListMember(const char *name, const char *member, const char separator) const\n{\n    String header;\n    const char *pos = NULL;\n    const char *item;\n    int ilen;\n    int mlen = strlen(member);\n\n    assert(name);\n\n    header = getByName(name);\n\n    String result;\n\n    while (strListGetItem(&header, separator, &item, &ilen, &pos)) {\n        if (strncmp(item, member, mlen) == 0 && item[mlen] == '=') {\n            result.append(item + mlen + 1, ilen - mlen - 1);\n            break;\n        }\n    }\n\n    return result;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":424472,"func":"add_opt_anc_info(OptAncInfo* to, int anc)\n{\n  if (is_left_anchor(anc))\n    to->left_anchor |= anc;\n  else\n    to->right_anchor |= anc;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":461369,"func":"static void send_packet_to_client(GDHCPServer *dhcp_server,\n\t\t\t\tstruct dhcp_packet *dhcp_pkt)\n{\n\tconst uint8_t *chaddr;\n\tuint32_t ciaddr;\n\n\tif ((dhcp_pkt->flags & htons(BROADCAST_FLAG))\n\t\t\t\t|| dhcp_pkt->ciaddr == 0) {\n\t\tdebug(dhcp_server, \"Broadcasting packet to client\");\n\t\tciaddr = INADDR_BROADCAST;\n\t\tchaddr = MAC_BCAST_ADDR;\n\t} else {\n\t\tdebug(dhcp_server, \"Unicasting packet to client ciaddr\");\n\t\tciaddr = dhcp_pkt->ciaddr;\n\t\tchaddr = dhcp_pkt->chaddr;\n\t}\n\n\tdhcp_send_raw_packet(dhcp_pkt,\n\t\tdhcp_server->server_nip, SERVER_PORT,\n\t\tciaddr, CLIENT_PORT, chaddr,\n\t\tdhcp_server->ifindex, false);\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":392150,"func":"int check_password_policy(String *password)\n{\n  plugin_ref plugin;\n  String empty_string;\n\n  if (!password)\n    password= &empty_string;\n\n  plugin= my_plugin_lock_by_name(0, &validate_password_plugin_name,\n                                 MYSQL_VALIDATE_PASSWORD_PLUGIN);\n  if (plugin)\n  {\n    st_mysql_validate_password *password_validate=\n                      (st_mysql_validate_password *) plugin_decl(plugin)->info;\n\n    if (!password_validate->validate_password(password))\n    {  \n      my_error(ER_NOT_VALID_PASSWORD, MYF(0));\n      plugin_unlock(0, plugin);\n      return (1);\n    }\n    plugin_unlock(0, plugin);\n  }\n  return (0);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":406264,"func":"ModuleExport void UnregisterCAPTIONImage(void)\n{\n  (void) UnregisterMagickInfo(\"CAPTION\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":330967,"func":"VirtIOSCSIReq *virtio_scsi_pop_req_vring(VirtIOSCSI *s,\n\n                                         VirtIOSCSIVring *vring)\n\n{\n\n    VirtIOSCSIReq *req = virtio_scsi_init_req(s, NULL);\n\n    int r;\n\n\n\n    req->vring = vring;\n\n    r = vring_pop((VirtIODevice *)s, &vring->vring, &req->elem);\n\n    if (r < 0) {\n\n        virtio_scsi_free_req(req);\n\n        req = NULL;\n\n    }\n\n    return req;\n\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":184973,"func":"void tracing_reset_online_cpus(struct trace_buffer *buf)\n{\n\tstruct ring_buffer *buffer = buf->buffer;\n\tint cpu;\n\n\tif (!buffer)\n\t\treturn;\n\n\tring_buffer_record_disable(buffer);\n\n\t\/* Make sure all commits have finished *\/\n\tsynchronize_sched();\n\n\tbuf->time_start = buffer_ftrace_now(buf, buf->cpu);\n\n\tfor_each_online_cpu(cpu)\n\t\tring_buffer_reset_cpu(buffer, cpu);\n\n\tring_buffer_record_enable(buffer);\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":471441,"func":"void addReplyArrayLen(client *c, long length) {\n    addReplyAggregateLen(c,length,'*');\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":202360,"func":"void FrameBuffer::Destroy() {\n  if (id_ != 0) {\n    ScopedGLErrorSuppressor suppressor(decoder_);\n    glDeleteFramebuffersEXT(1, &id_);\n    id_ = 0;\n  }\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":313375,"func":"void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() {\n  ProcessPendingReadPixels(false);\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":444741,"func":"TEST_F(Http1ServerConnectionImplTest, UnsupportedEncoding) {\n  initialize();\n\n  InSequence sequence;\n\n  MockRequestDecoder decoder;\n  EXPECT_CALL(callbacks_, newStream(_, _)).WillOnce(ReturnRef(decoder));\n\n  Buffer::OwnedImpl buffer(\"GET \/ HTTP\/1.1\\r\\ntransfer-encoding: gzip\\r\\n\\r\\n\");\n  EXPECT_CALL(decoder, sendLocalReply(_, _, _, _, _, _, _));\n  auto status = codec_->dispatch(buffer);\n  EXPECT_TRUE(isCodecProtocolError(status));\n  EXPECT_EQ(status.message(), \"http\/1.1 protocol error: unsupported transfer encoding\");\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":228236,"func":"FolderHeaderView::FolderHeaderView(FolderHeaderViewDelegate* delegate)\n    : folder_item_(NULL),\n      back_button_(new views::ImageButton(this)),\n      folder_name_view_(new FolderNameView),\n      folder_name_placeholder_text_(\n          ui::ResourceBundle::GetSharedInstance().GetLocalizedString(\n              IDS_APP_LIST_FOLDER_NAME_PLACEHOLDER)),\n      delegate_(delegate),\n      folder_name_visible_(true) {\n  ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();\n  back_button_->SetImage(views::ImageButton::STATE_NORMAL,\n      rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));\n  back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,\n      views::ImageButton::ALIGN_MIDDLE);\n  AddChildView(back_button_);\n\n  folder_name_view_->SetFontList(\n      rb.GetFontList(ui::ResourceBundle::MediumFont));\n  folder_name_view_->set_placeholder_text_color(kHintTextColor);\n  folder_name_view_->set_placeholder_text(folder_name_placeholder_text_);\n  folder_name_view_->SetBorder(views::Border::NullBorder());\n  folder_name_view_->SetBackgroundColor(kContentsBackgroundColor);\n  folder_name_view_->set_controller(this);\n  AddChildView(folder_name_view_);\n}\n","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":135608,"func":"static int mov_write_vmhd_tag(AVIOContext *pb)\n{\n    avio_wb32(pb, 0x14); \/* size (always 0x14) *\/\n    ffio_wfourcc(pb, \"vmhd\");\n    avio_wb32(pb, 0x01); \/* version & flags *\/\n    avio_wb64(pb, 0); \/* reserved (graphics mode = copy) *\/\n    return 0x14;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":231345,"func":"void ServiceWorkerContextCore::UnprotectVersion(int64_t version_id) {\n  DCHECK(protected_versions_.find(version_id) != protected_versions_.end());\n  protected_versions_.erase(version_id);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":398248,"func":"js_Value *js_tovalue(js_State *J, int idx)\n{\n\treturn stackidx(J, idx);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":372159,"func":"auth_shadow (\n  const char *login __attribute__((unused)),\n  const char *passwd __attribute__((unused)),\n  const char *service __attribute__((unused)),\n  const char *realm __attribute__((unused))\n  )\n{\n    return NULL;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":66940,"func":"GF_Err moof_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_MovieFragmentBox *ptr = (GF_MovieFragmentBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\t\/\/Header First\n\tgf_isom_check_position(s, (GF_Box *)ptr->mfhd, &pos);\n\t\/\/then PSSH\n\tgf_isom_check_position_list(s, ptr->PSSHs, &pos);\n\t\/\/then the track list\n\tgf_isom_check_position_list(s, ptr->TrackList, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":231342,"func":" virtual status_t listModules(struct sound_trigger_module_descriptor *modules,\n uint32_t *numModules)\n {\n if (numModules == NULL || (*numModules != 0 && modules == NULL)) {\n return BAD_VALUE;\n }\n Parcel data, reply;\n        data.writeInterfaceToken(ISoundTriggerHwService::getInterfaceDescriptor());\n unsigned int numModulesReq = (modules == NULL) ? 0 : *numModules;\n        data.writeInt32(numModulesReq);\n status_t status = remote()->transact(LIST_MODULES, data, &reply);\n if (status == NO_ERROR) {\n            status = (status_t)reply.readInt32();\n *numModules = (unsigned int)reply.readInt32();\n }\n        ALOGV(\"listModules() status %d got *numModules %d\", status, *numModules);\n if (status == NO_ERROR) {\n if (numModulesReq > *numModules) {\n                numModulesReq = *numModules;\n }\n if (numModulesReq > 0) {\n                reply.read(modules, numModulesReq * sizeof(struct sound_trigger_module_descriptor));\n }\n }\n return status;\n }\n","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":357404,"func":"static struct inotify_watch *inode_find_handle(struct inode *inode,\n\t\t\t\t\t       struct inotify_handle *ih)\n{\n\tstruct inotify_watch *watch;\n\n\tlist_for_each_entry(watch, &inode->inotify_watches, i_list) {\n\t\tif (watch->ih == ih)\n\t\t\treturn watch;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":176024,"func":"my_object_get_hash (MyObject *obj, GHashTable **ret, GError **error)\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":167900,"func":"void AsyncFileSystemChromium::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)\n{\n    m_webFileSystem->move(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":416574,"func":"gx_default_finish_copydevice(gx_device *dev, const gx_device *from_dev)\n{\n    \/* Only allow copying the prototype. *\/\n    return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":308528,"func":"   favicon::MockFaviconService* favicon_service() {\n     return mock_favicon_service_.get();\n   }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":265356,"func":"static void __report_tpr_access(struct kvm_lapic *apic, bool write)\n{\n\tstruct kvm_vcpu *vcpu = apic->vcpu;\n\tstruct kvm_run *run = vcpu->run;\n\n\tkvm_make_request(KVM_REQ_REPORT_TPR_ACCESS, vcpu);\n\trun->tpr_access.rip = kvm_rip_read(vcpu);\n\trun->tpr_access.is_write = write;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":251939,"func":"void MessageService::PendingOpenChannel(scoped_ptr<OpenChannelParams> params,\n                                        int source_process_id,\n                                        ExtensionHost* host) {\n  if (!host)\n    return;  \/\/ TODO(mpcomplete): notify source of disconnect?\n\n  content::RenderProcessHost* source =\n      content::RenderProcessHost::FromID(source_process_id);\n  if (!source)\n    return;\n\n  params->source = source;\n  params->receiver.reset(new ExtensionMessagePort(host->render_process_host(),\n                                                  MSG_ROUTING_CONTROL,\n                                                  params->target_extension_id));\n  OpenChannelImpl(params.Pass());\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":411016,"func":"static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc,\n\t\t\t\t\t   int length)\n{\n\tstruct sctp_reconf_chunk *reconf;\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_control(asoc, SCTP_CID_RECONF, 0, length,\n\t\t\t\t   GFP_ATOMIC);\n\tif (!retval)\n\t\treturn NULL;\n\n\treconf = (struct sctp_reconf_chunk *)retval->chunk_hdr;\n\tretval->param_hdr.v = reconf->params;\n\n\treturn retval;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":315116,"func":"void Document::setDir(const AtomicString& value)\n{\n    Element* rootElement = documentElement();\n    if (isHTMLHtmlElement(rootElement))\n        toHTMLHtmlElement(rootElement)->setDir(value);\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":136536,"func":"AP4_SubtitleSampleEntry::ReadFields(AP4_ByteStream& stream)\n{\n    \/\/ sample entry\n    AP4_Result result = AP4_SampleEntry::ReadFields(stream);\n    if (result < 0) return result;\n\n    \/\/ read fields from this class\n    result = stream.ReadNullTerminatedString(m_Namespace);\n    if (AP4_FAILED(result)) return result;\n    result = stream.ReadNullTerminatedString(m_SchemaLocation);\n    if (AP4_FAILED(result)) return result;\n    result = stream.ReadNullTerminatedString(m_ImageMimeType);\n    if (AP4_FAILED(result)) return result;\n    \n    return AP4_SUCCESS;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":509969,"func":"JPEGVGetField(TIFF* tif, uint32 tag, va_list ap)\n{\n\tJPEGState* sp = JState(tif);\n\n\tassert(sp != NULL);\n\n\tswitch (tag) {\n\t\tcase TIFFTAG_JPEGTABLES:\n\t\t\t*va_arg(ap, uint32*) = sp->jpegtables_length;\n\t\t\t*va_arg(ap, void**) = sp->jpegtables;\n\t\t\tbreak;\n\t\tcase TIFFTAG_JPEGQUALITY:\n\t\t\t*va_arg(ap, int*) = sp->jpegquality;\n\t\t\tbreak;\n\t\tcase TIFFTAG_JPEGCOLORMODE:\n\t\t\t*va_arg(ap, int*) = sp->jpegcolormode;\n\t\t\tbreak;\n\t\tcase TIFFTAG_JPEGTABLESMODE:\n\t\t\t*va_arg(ap, int*) = sp->jpegtablesmode;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn (*sp->vgetparent)(tif, tag, ap);\n\t}\n\treturn (1);\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":446861,"func":"int ldb_set_timeout_from_prev_req(struct ldb_context *ldb,\n\t\t\t\t  struct ldb_request *oldreq,\n\t\t\t\t  struct ldb_request *newreq)\n{\n\tif (newreq == NULL) return LDB_ERR_OPERATIONS_ERROR;\n\n\tif (oldreq == NULL) {\n\t\treturn ldb_set_timeout(ldb, newreq, 0);\n\t}\n\n\tnewreq->starttime = oldreq->starttime;\n\tnewreq->timeout = oldreq->timeout;\n\n\treturn LDB_SUCCESS;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":517947,"func":"void Item_ref::cleanup()\n{\n  DBUG_ENTER(\"Item_ref::cleanup\");\n  Item_ident::cleanup();\n  if (reference_trough_name)\n  {\n    \/* We have to reset the reference as it may been freed *\/\n    ref= 0;\n  }\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":21471,"func":"static Datum ExecEvalWholeRowFast ( WholeRowVarExprState * wrvstate , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) {\n Var * variable = ( Var * ) wrvstate -> xprstate . expr ;\n TupleTableSlot * slot ;\n HeapTupleHeader dtuple ;\n if ( isDone ) * isDone = ExprSingleResult ;\n * isNull = false ;\n switch ( variable -> varno ) {\n case INNER_VAR : slot = econtext -> ecxt_innertuple ;\n break ;\n case OUTER_VAR : slot = econtext -> ecxt_outertuple ;\n break ;\n default : slot = econtext -> ecxt_scantuple ;\n break ;\n }\n if ( wrvstate -> wrv_junkFilter != NULL ) slot = ExecFilterJunk ( wrvstate -> wrv_junkFilter , slot ) ;\n dtuple = DatumGetHeapTupleHeader ( ExecFetchSlotTupleDatum ( slot ) ) ;\n HeapTupleHeaderSetTypeId ( dtuple , wrvstate -> wrv_tupdesc -> tdtypeid ) ;\n HeapTupleHeaderSetTypMod ( dtuple , wrvstate -> wrv_tupdesc -> tdtypmod ) ;\n return PointerGetDatum ( dtuple ) ;\n }","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":135195,"func":"static void parse_new_blob(void)\n{\n\tread_next_command();\n\tparse_mark();\n\tparse_and_store_blob(&last_blob, NULL, next_mark);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":414233,"func":"GuestUserList *qmp_guest_get_users(Error **errp)\n{\n    error_setg(errp, QERR_UNSUPPORTED);\n    return NULL;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":15471,"func":"static UHashTok _uhash_setElement ( UHashtable * hash , UHashElement * e , int32_t hashcode , UHashTok key , UHashTok value , int8_t hint ) {\n UHashTok oldValue = e -> value ;\n if ( hash -> keyDeleter != NULL && e -> key . pointer != NULL && e -> key . pointer != key . pointer ) {\n ( * hash -> keyDeleter ) ( e -> key . pointer ) ;\n }\n if ( hash -> valueDeleter != NULL ) {\n if ( oldValue . pointer != NULL && oldValue . pointer != value . pointer ) {\n ( * hash -> valueDeleter ) ( oldValue . pointer ) ;\n }\n oldValue . pointer = NULL ;\n }\n if ( hint & HINT_KEY_POINTER ) {\n e -> key . pointer = key . pointer ;\n }\n else {\n e -> key = key ;\n }\n if ( hint & HINT_VALUE_POINTER ) {\n e -> value . pointer = value . pointer ;\n }\n else {\n e -> value = value ;\n }\n e -> hashcode = hashcode ;\n return oldValue ;\n }","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":214967,"func":"GDataEntry::GDataEntry(GDataDirectory* parent,\nGDataEntry::GDataEntry(GDataDirectoryService* directory_service)\n    : parent_(NULL),\n      directory_service_(directory_service),\n       deleted_(false) {\n }\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":518576,"func":"int Field_time::store(double nr)\n{\n  MYSQL_TIME ltime;\n  ErrConvDouble str(nr);\n  int was_cut;\n  bool neg= nr < 0;\n  if (neg)\n    nr= -nr;\n  int have_smth_to_conv= !number_to_time(neg, (ulonglong) nr,\n                                         (ulong)((nr - floor(nr)) * TIME_SECOND_PART_FACTOR),\n                                         <ime, &was_cut);\n\n  return store_TIME_with_warning(<ime, &str, was_cut, have_smth_to_conv);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":131211,"func":"static void reallymarkobject (global_State *g, GCObject *o) {\n  white2gray(o);\n  switch (o->tt) {\n    case LUA_VSHRSTR:\n    case LUA_VLNGSTR: {\n      gray2black(o);\n      break;\n    }\n    case LUA_VUPVAL: {\n      UpVal *uv = gco2upv(o);\n      if (!upisopen(uv))  \/* open upvalues are kept gray *\/\n        gray2black(o);\n      markvalue(g, uv->v);  \/* mark its content *\/\n      break;\n    }\n    case LUA_VUSERDATA: {\n      Udata *u = gco2u(o);\n      if (u->nuvalue == 0) {  \/* no user values? *\/\n        markobjectN(g, u->metatable);  \/* mark its metatable *\/\n        gray2black(o);  \/* nothing else to mark *\/\n        break;\n      }\n      \/* else... *\/\n    }  \/* FALLTHROUGH *\/\n    case LUA_VLCL: case LUA_VCCL: case LUA_VTABLE:\n    case LUA_VTHREAD: case LUA_VPROTO: {\n      linkobjgclist(o, g->gray);\n      break;\n    }\n    default: lua_assert(0); break;\n  }\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":57273,"func":"static void tcp_incr_quickack(struct sock *sk)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tunsigned int quickacks = tcp_sk(sk)->rcv_wnd \/ (2 * icsk->icsk_ack.rcv_mss);\n\n\tif (quickacks == 0)\n\t\tquickacks = 2;\n\tif (quickacks > icsk->icsk_ack.quick)\n\t\ticsk->icsk_ack.quick = min(quickacks, TCP_MAX_QUICKACKS);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":187541,"func":"void FrameLoader::load(DocumentLoader* newDocumentLoader)\n{\n    ResourceRequest& r = newDocumentLoader->request();\n    addExtraFieldsToMainResourceRequest(r);\n    FrameLoadType type;\n\n    if (shouldTreatURLAsSameAsCurrent(newDocumentLoader->originalRequest().url())) {\n        r.setCachePolicy(ReloadIgnoringCacheData);\n        type = FrameLoadTypeSame;\n    } else\n        type = FrameLoadTypeStandard;\n\n    if (m_documentLoader)\n        newDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEncoding());\n    \n    if (shouldReloadToHandleUnreachableURL(newDocumentLoader)) {\n        ASSERT(type == FrameLoadTypeStandard);\n        type = FrameLoadTypeReload;\n    }\n\n    loadWithDocumentLoader(newDocumentLoader, type, 0);\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":194939,"func":"int tls1_ec_curve_id2nid(int curve_id)\n{\n    \/* ECC curves from RFC 4492 and RFC 7027 *\/\n    if ((curve_id < 1) || ((unsigned int)curve_id >\n                           sizeof(nid_list) \/ sizeof(nid_list[0])))\n        return 0;\n    return nid_list[curve_id - 1];\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":17646,"func":"static void omap_lpg_tick(void *opaque)\n\n{\n\n    struct omap_lpg_s *s = opaque;\n\n\n\n    if (s->cycle)\n\n        timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->period - s->on);\n\n    else\n\n        timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->on);\n\n\n\n    s->cycle = !s->cycle;\n\n    printf(\"%s: LED is %s\\n\", __FUNCTION__, s->cycle ? \"on\" : \"off\");\n\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":78346,"func":"struct usb_device *usb_get_dev(struct usb_device *dev)\n{\n\tif (dev)\n\t\tget_device(&dev->dev);\n\treturn dev;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":326364,"func":"static void breakpoint_invalidate(CPUState *env, target_ulong pc)\n\n{\n\n    target_ulong phys_addr;\n\n\n\n    phys_addr = cpu_get_phys_page_debug(env, pc);\n\n    tb_invalidate_phys_page_range(phys_addr, phys_addr + 1, 0);\n\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":60432,"func":"set_param_option(char *option)\n{\n    Str tmp = Strnew();\n    char *p = option, *q;\n\n    while (*p && !IS_SPACE(*p) && *p != '=')\n\tStrcat_char(tmp, *p++);\n    while (*p && IS_SPACE(*p))\n\tp++;\n    if (*p == '=') {\n\tp++;\n\twhile (*p && IS_SPACE(*p))\n\t    p++;\n    }\n    Strlower(tmp);\n    if (set_param(tmp->ptr, p))\n\tgoto option_assigned;\n    q = tmp->ptr;\n    if (!strncmp(q, \"no\", 2)) {\t\/* -o noxxx, -o no-xxx, -o no_xxx *\/\n\tq += 2;\n\tif (*q == '-' || *q == '_')\n\t    q++;\n    }\n    else if (tmp->ptr[0] == '-')\t\/* -o -xxx *\/\n\tq++;\n    else\n\treturn 0;\n    if (set_param(q, \"0\"))\n\tgoto option_assigned;\n    return 0;\n  option_assigned:\n    return 1;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":189571,"func":"static AUDIO_OBJECT_TYPE getAOTFromProfile(OMX_U32 profile) {\n if (profile == OMX_AUDIO_AACObjectLC) {\n return AOT_AAC_LC;\n } else if (profile == OMX_AUDIO_AACObjectHE) {\n return AOT_SBR;\n } else if (profile == OMX_AUDIO_AACObjectHE_PS) {\n return AOT_PS;\n } else if (profile == OMX_AUDIO_AACObjectLD) {\n return AOT_ER_AAC_LD;\n } else if (profile == OMX_AUDIO_AACObjectELD) {\n return AOT_ER_AAC_ELD;\n } else {\n        ALOGW(\"Unsupported AAC profile - defaulting to AAC-LC\");\n return AOT_AAC_LC;\n }\n}\n","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":322948,"func":"static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,\n\n                             Error **errp)\n\n{\n\n    struct omap_lcd_panel_s *omap_lcd = opaque;\n\n    DisplaySurface *surface = qemu_console_surface(omap_lcd->con);\n\n\n\n    omap_update_display(opaque);\n\n    if (omap_lcd && surface_data(surface))\n\n        omap_ppm_save(filename, surface_data(surface),\n\n                    omap_lcd->width, omap_lcd->height,\n\n                    surface_stride(surface), errp);\n\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":217201,"func":"  virtual ~LoggingNetworkChangeObserver() {\n    net::NetworkChangeNotifier::RemoveIPAddressObserver(this);\n    net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);\n    net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);\n  }\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":223724,"func":"bool AXObject::lastKnownIsIgnoredValue() {\n  if (m_lastKnownIsIgnoredValue == DefaultBehavior)\n    m_lastKnownIsIgnoredValue =\n        accessibilityIsIgnored() ? IgnoreObject : IncludeObject;\n\n  return m_lastKnownIsIgnoredValue == IgnoreObject;\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":23215,"func":"static PyObject * string_rsplit ( PyStringObject * self , PyObject * args ) {\n Py_ssize_t len = PyString_GET_SIZE ( self ) , n ;\n Py_ssize_t maxsplit = - 1 ;\n const char * s = PyString_AS_STRING ( self ) , * sub ;\n PyObject * subobj = Py_None ;\n if ( ! PyArg_ParseTuple ( args , \"|On:rsplit\" , & subobj , & maxsplit ) ) return NULL ;\n if ( maxsplit < 0 ) maxsplit = PY_SSIZE_T_MAX ;\n if ( subobj == Py_None ) return stringlib_rsplit_whitespace ( ( PyObject * ) self , s , len , maxsplit ) ;\n if ( PyString_Check ( subobj ) ) {\n sub = PyString_AS_STRING ( subobj ) ;\n n = PyString_GET_SIZE ( subobj ) ;\n }\n # ifdef Py_USING_UNICODE else if ( PyUnicode_Check ( subobj ) ) return PyUnicode_RSplit ( ( PyObject * ) self , subobj , maxsplit ) ;\n # endif else if ( PyObject_AsCharBuffer ( subobj , & sub , & n ) ) return NULL ;\n return stringlib_rsplit ( ( PyObject * ) self , s , len , sub , n , maxsplit ) ;\n }","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":36690,"func":"const QLoggingCategory &Helper::loggerCategory()\n{\n    return lcDeepinGhost();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":413036,"func":"static int proc_pid_patch_state(struct seq_file *m, struct pid_namespace *ns,\n\t\t\t\tstruct pid *pid, struct task_struct *task)\n{\n\tseq_printf(m, \"%d\\n\", task->patch_state);\n\treturn 0;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":389803,"func":"static MemTxResult watch_mem_read(void *opaque, hwaddr addr, uint64_t *pdata,\n                                  unsigned size, MemTxAttrs attrs)\n{\n    MemTxResult res;\n    uint64_t data;\n\n    check_watchpoint(addr & ~TARGET_PAGE_MASK, size, attrs, BP_MEM_READ);\n    switch (size) {\n    case 1:\n        data = address_space_ldub(&address_space_memory, addr, attrs, &res);\n        break;\n    case 2:\n        data = address_space_lduw(&address_space_memory, addr, attrs, &res);\n        break;\n    case 4:\n        data = address_space_ldl(&address_space_memory, addr, attrs, &res);\n        break;\n    default: abort();\n    }\n    *pdata = data;\n    return res;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":258282,"func":"static int get_dimension ( GetBitContext * gb , const int * dim ) {\n int t = get_bits ( gb , 3 ) ;\n int val = dim [ t ] ;\n if ( val < 0 ) val = dim [ get_bits1 ( gb ) - val ] ;\n if ( ! val ) {\n do {\n t = get_bits ( gb , 8 ) ;\n val += t << 2 ;\n }\n while ( t == 0xFF ) ;\n }\n return val ;\n }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":73339,"func":"hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)\n{\n\tint i, j;\n\tstruct hid_report *report;\n\tstruct hid_report_enum *report_enum;\n\tstruct hid_field *field;\n\n\tif (uref->report_type < HID_REPORT_TYPE_MIN ||\n\t    uref->report_type > HID_REPORT_TYPE_MAX)\n\t\treturn NULL;\n\n\treport_enum = hid->report_enum +\n\t\t(uref->report_type - HID_REPORT_TYPE_MIN);\n\n\tlist_for_each_entry(report, &report_enum->report_list, list) {\n\t\tfor (i = 0; i < report->maxfield; i++) {\n\t\t\tfield = report->field[i];\n\t\t\tfor (j = 0; j < field->maxusage; j++) {\n\t\t\t\tif (field->usage[j].hid == uref->usage_code) {\n\t\t\t\t\turef->report_id = report->id;\n\t\t\t\t\turef->field_index = i;\n\t\t\t\t\turef->usage_index = j;\n\t\t\t\t\treturn field;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":65244,"func":"MagickExport ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)\n{\n  ModuleInfo\n    *module_info;\n\n  if (IsModuleTreeInstantiated() == MagickFalse)\n    return((ModuleInfo *) NULL);\n  LockSemaphoreInfo(module_semaphore);\n  ResetSplayTreeIterator(module_list);\n  if ((tag == (const char *) NULL) || (LocaleCompare(tag,\"*\") == 0))\n    {\n#if defined(MAGICKCORE_MODULES_SUPPORT)\n      if (LocaleCompare(tag,\"*\") == 0)\n        (void) OpenModules(exception);\n#endif\n      module_info=(ModuleInfo *) GetNextValueInSplayTree(module_list);\n      UnlockSemaphoreInfo(module_semaphore);\n      return(module_info);\n    }\n  module_info=(ModuleInfo *) GetValueFromSplayTree(module_list,tag);\n  UnlockSemaphoreInfo(module_semaphore);\n  return(module_info);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":237390,"func":"void EventBindings::AttachEvent(const std::string& event_name) {\n  if (!context()->HasAccessOrThrowError(event_name))\n    return;\n\n  attached_event_names_.insert(event_name);\n\n  const std::string& extension_id = context()->GetExtensionID();\n  if (IncrementEventListenerCount(context(), event_name) == 1) {\n    content::RenderThread::Get()->Send(new ExtensionHostMsg_AddListener(\n        extension_id, context()->url(), event_name));\n  }\n\n  if (ExtensionFrameHelper::IsContextForEventPage(context())) {\n    content::RenderThread::Get()->Send(\n        new ExtensionHostMsg_AddLazyListener(extension_id, event_name));\n  }\n}\n","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":239174,"func":"static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)\n{\n\treturn !fc->initialized || (for_background && fc->blocked);\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":490274,"func":"char *_q_strcpy(char *dst, size_t size, const char *src)\n{\n    if (dst == NULL || size == 0 || src == NULL) return dst;\n\n    size_t copylen = strlen(src);\n    if (copylen >= size) copylen = size - 1;\n    memmove((void *)dst, (void *)src, copylen);\n    dst[copylen] = '\\0';\n\n    return dst;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":506156,"func":"int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)\n\t{\n\tif (cert ==  NULL)\n\t\treturn 1;\n\tif (SSL_CTX_use_certificate(ctx,cert) <= 0)\n\t\t{\n\t\tBIO_printf(bio_err,\"error setting certificate\\n\");\n\t\tERR_print_errors(bio_err);\n\t\treturn 0;\n\t\t}\n\tif (SSL_CTX_use_PrivateKey(ctx,key) <= 0)\n\t\t{\n\t\tBIO_printf(bio_err,\"error setting private key\\n\");\n\t\tERR_print_errors(bio_err);\n\t\treturn 0;\n\t\t}\n\n\t\t\n\t\t\/* Now we know that a key and cert have been set against\n\t\t * the SSL context *\/\n\tif (!SSL_CTX_check_private_key(ctx))\n\t\t{\n\t\tBIO_printf(bio_err,\"Private key does not match the certificate public key\\n\");\n\t\treturn 0;\n\t\t}\n\treturn 1;\n\t}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":478332,"func":"    T& atNXY(const int pos, const int x, const int y, const int z=0, const int c=0) {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXY(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXY(pos,x,y,z,c);\n    }","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":458732,"func":"dp_packet_l4_checksum_bad(struct dp_packet *p)\n{\n    return (p->mbuf.ol_flags & PKT_RX_L4_CKSUM_MASK) ==\n            PKT_RX_L4_CKSUM_BAD;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":35503,"func":"static int tiocsetd(struct tty_struct *tty, int __user *p)\n{\n\tint ldisc;\n\tint ret;\n\n\tif (get_user(ldisc, p))\n\t\treturn -EFAULT;\n\n\tret = tty_set_ldisc(tty, ldisc);\n\n\treturn ret;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":199876,"func":"static int cac_decipher(sc_card_t *card,\n\t\t\t\t\t const u8 * data, size_t datalen,\n\t\t\t\t\t u8 * out, size_t outlen)\n{\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);\n\n\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, cac_rsa_op(card, data, datalen, out, outlen));\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":158762,"func":"  static constexpr bool kSortKeys() {\n    return false;\n  }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":229094,"func":"void linuxMemoryWarnings(void) {\n    if (linuxOvercommitMemoryValue() == 0) {\n        serverLog(LL_WARNING,\"WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to \/etc\/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.\");\n    }\n    if (THPIsEnabled()) {\n        serverLog(LL_WARNING,\"WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > \/sys\/kernel\/mm\/transparent_hugepage\/enabled' as root, and add it to your \/etc\/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.\");\n    }\n}\n","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":13025,"func":"static int cac_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* serial)\n{\n\tcac_private_data_t * priv = CAC_DATA(card);\n\n\tSC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);\n        if (card->serialnr.len)   {\n                *serial = card->serialnr;\n                SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n         }\n \tif (priv->cac_id_len) {\n \t\tserial->len = MIN(priv->cac_id_len, SC_MAX_SERIALNR);\n\t\tmemcpy(serial->value, priv->cac_id, priv->cac_id_len);\n \t\tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);\n \t}\n \tSC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_NOT_FOUND);\n}\n","target":1,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":518483,"func":"Item* Item_ref::build_clone(THD *thd)\n{\n  Item_ref *copy= (Item_ref *) get_copy(thd);\n  if (unlikely(!copy) ||\n      unlikely(!(copy->ref= (Item**) alloc_root(thd->mem_root,\n                                                sizeof(Item*)))) ||\n      unlikely(!(*copy->ref= (* ref)->build_clone(thd))))\n    return 0;\n  return copy;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":98429,"func":"void* CurvesDup(cmsContext ContextID, const void* ptr)\n{\n    Curves16Data* Data = _cmsDupMem(ContextID, ptr, sizeof(Curves16Data));\n    int i;\n\n    if (Data == NULL) return NULL;\n\n    Data ->Curves = _cmsDupMem(ContextID, Data ->Curves, Data ->nCurves * sizeof(cmsUInt16Number*));\n\n    for (i=0; i < Data -> nCurves; i++) {\n        Data ->Curves[i] = _cmsDupMem(ContextID, Data ->Curves[i], Data -> nElements * sizeof(cmsUInt16Number));\n    }\n\n    return (void*) Data;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":32311,"func":"Perl_ckwarn(pTHX_ U32 w)\n{\n    \/* If lexical warnings have not been set, use $^W.  *\/\n    if (isLEXWARN_off)\n\treturn PL_dowarn & G_WARN_ON;\n\n    return ckwarn_common(w);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":141117,"func":"PLT_HttpServer::Stop()\n{\n    \/\/ we can't restart an aborted server\n    if (m_Aborted || !m_Running) NPT_CHECK_WARNING(NPT_ERROR_INVALID_STATE);\n    \n    \/\/ stop all other pending tasks \n    m_TaskManager->Abort();\n    \n    m_Running = false;\n    m_Aborted = true;\n    \n    return NPT_SUCCESS;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":370573,"func":"htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,\n              const char *URL, const char *encoding, int options)\n{\n    xmlParserInputBufferPtr input;\n    xmlParserInputPtr stream;\n\n    if (fd < 0)\n        return (NULL);\n    if (ctxt == NULL)\n        return (NULL);\n\n    htmlCtxtReset(ctxt);\n\n\n    input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);\n    if (input == NULL)\n        return (NULL);\n    stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);\n    if (stream == NULL) {\n        xmlFreeParserInputBuffer(input);\n        return (NULL);\n    }\n    inputPush(ctxt, stream);\n    return (htmlDoRead(ctxt, URL, encoding, options, 1));\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":279144,"func":"bool VaapiWrapper::IsEntrypointSupported_Locked(VAProfile va_profile,\n                                                VAEntrypoint entrypoint) {\n  va_lock_->AssertAcquired();\n  int max_entrypoints = vaMaxNumEntrypoints(va_display_);\n  std::vector<VAEntrypoint> supported_entrypoints(\n      base::checked_cast<size_t>(max_entrypoints));\n\n  int num_supported_entrypoints;\n  VAStatus va_res = vaQueryConfigEntrypoints(va_display_,\n                                             va_profile,\n                                             &supported_entrypoints[0],\n                                             &num_supported_entrypoints);\n  VA_SUCCESS_OR_RETURN(va_res, \"vaQueryConfigEntrypoints failed\", false);\n  if (num_supported_entrypoints < 0 ||\n      num_supported_entrypoints > max_entrypoints) {\n    LOG(ERROR) << \"vaQueryConfigEntrypoints returned: \"\n               << num_supported_entrypoints;\n    return false;\n  }\n\n  if (std::find(supported_entrypoints.begin(),\n                supported_entrypoints.end(),\n                entrypoint) == supported_entrypoints.end()) {\n    DVLOG(1) << \"Unsupported entrypoint\";\n    return false;\n  }\n  return true;\n}\n","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":341562,"func":"static void vmmouse_reset(DeviceState *d)\n{\n    VMMouseState *s = container_of(d, VMMouseState, dev.qdev);\n    s->status = 0xffff;\n    s->queue_size = VMMOUSE_QUEUE_SIZE;\n}","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":224172,"func":"void CL_ReloadTranslation( void ) {\n\tchar    **fileList;\n\tint numFiles, i;\n\tchar fileName[MAX_QPATH];\n\n\tfor ( i = 0; i < FILE_HASH_SIZE; i++ ) {\n\t\tif ( transTable[i] ) {\n\t\t\tfree( transTable[i] );\n\t\t}\n\t}\n\n\tmemset( transTable, 0, sizeof( trans_t* ) * FILE_HASH_SIZE );\n\tCL_LoadTransTable( \"scripts\/translation.cfg\" );\n\n\tfileList = FS_ListFiles( \"translations\", \".cfg\", &numFiles );\n\n\tfor ( i = 0; i < numFiles; i++ ) {\n\t\tCom_sprintf( fileName, sizeof (fileName), \"translations\/%s\", fileList[i] );\n\t\tCL_LoadTransTable( fileName );\n\t}\n}\n","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":127381,"func":"static int gif_read_close(AVFormatContext *s1)\n\n{\n\n    GifState *s = s1->priv_data;\n\n    av_free(s->image_buf);\n\n    return 0;\n\n}\n","target":1,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":360774,"func":"static USBHostDevice *hostdev_find(int bus_num, int addr)\n{\n    USBHostDevice *s = hostdev_list;\n    while (s) {\n        if (s->bus_num == bus_num && s->addr == addr)\n            return s;\n        s = s->next;\n    }\n    return NULL;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":83949,"func":"iasecc_logout(struct sc_card *card)\n{\n\tstruct sc_context *ctx = card->ctx;\n\tstruct sc_path path;\n\tint rv;\n\n\tLOG_FUNC_CALLED(ctx);\n\tif (!card->ef_atr || !card->ef_atr->aid.len)\n\t\treturn SC_SUCCESS;\n\n\tmemset(&path, 0, sizeof(struct sc_path));\n\tpath.type = SC_PATH_TYPE_DF_NAME;\n\tmemcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);\n\tpath.len = card->ef_atr->aid.len;\n\n\trv = iasecc_select_file(card, &path, NULL);\n\tsc_log(ctx, \"Select ECC ROOT with the AID from EF.ATR: rv %i\", rv);\n\n\tLOG_FUNC_RETURN(ctx, rv);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":68297,"func":"R_API char *r_bin_java_print_null_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *value = malloc (size);\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name);\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size);\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset,\n\t\t\t\t\t((RBinJavaCPTypeMetas *) obj->metas->type_info)->name);\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":59201,"func":"MONGO_EXPORT bson_err_handler set_bson_err_handler( bson_err_handler func ) {\n    bson_err_handler old = err_handler;\n    err_handler = func;\n    return old;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":212903,"func":"error::Error GLES2DecoderPassthroughImpl::DoGetInteger64v(GLenum pname,\n                                                          GLsizei bufsize,\n                                                          GLsizei* length,\n                                                          GLint64* params) {\n  return GetNumericHelper(\n      pname, bufsize, length, params,\n      [this](GLenum pname, GLsizei bufsize, GLsizei* length, GLint64* params) {\n        api()->glGetInteger64vRobustANGLEFn(pname, bufsize, length, params);\n      });\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":54808,"func":"cmd_str_r(const notify_script_t *script, char *buf, size_t len)\n{\n\tchar *str_p;\n\tint i;\n\tsize_t str_len;\n\n\tstr_p = buf;\n\n\tfor (i = 0; i < script->num_args; i++) {\n\t\t\/* Check there is enough room for the next word *\/\n\t\tstr_len = strlen(script->args[i]);\n\t\tif (str_p + str_len + 2 + (i ? 1 : 0) >= buf + len)\n\t\t\treturn NULL;\n\n\t\tif (i)\n\t\t\t*str_p++ = ' ';\n\t\t*str_p++ = '\\'';\n\t\tstrcpy(str_p, script->args[i]);\n\t\tstr_p += str_len;\n\t\t*str_p++ = '\\'';\n\t}\n\t*str_p = '\\0';\n\n\treturn buf;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":126083,"func":"flatpak_transaction_operation_get_decomposed (FlatpakTransactionOperation *self)\n{\n  return self->ref;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":362267,"func":"form_auth_data_free (EphyEmbedSingleFormAuthData *data)\n{\n  g_free (data->form_username);\n  g_free (data->form_password);\n  g_free (data->username);\n\n  g_slice_free (EphyEmbedSingleFormAuthData, data);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":414710,"func":"\nstatic inline bool ext4_has_compat_features(struct super_block *sb)\n{\n\treturn (EXT4_SB(sb)->s_es->s_feature_compat != 0);","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":241369,"func":"long Tracks::Parse()\n","target":0,"code_token_length":5,"total_token_length":241,"max_tokens_setting":512}
+{"idx":331893,"func":"static inline uint64_t tcg_opc_movi_a(int qp, TCGReg dst, int64_t src)\n\n{\n\n    assert(src == sextract64(src, 0, 22));\n\n    return tcg_opc_a5(qp, OPC_ADDL_A5, dst, src, TCG_REG_R0);\n\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":395608,"func":"static void xilinx_ethlite_register_types(void)\n{\n    type_register_static(&xilinx_ethlite_info);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":407936,"func":"int canonical_checksum(int csum_type)\n{\n    return csum_type >= CSUM_MD4 ? 1 : 0;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":320805,"func":"static uint32_t qvirtio_pci_get_features(QVirtioDevice *d)\n\n{\n\n    QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;\n\n    return qpci_io_readl(dev->pdev, dev->addr + VIRTIO_PCI_HOST_FEATURES);\n\n}\n","target":1,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":388617,"func":"const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,\n\t\t\t\t     const char *filename)\n{\n\tVFS_FIND(connectpath);\n\treturn handle->fns->connectpath_fn(handle, filename);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":188204,"func":"xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs) {\n    CHECK_ARITY(0);\n    valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":220608,"func":"WebMediaPlayer::Preload HTMLMediaElement::EffectivePreloadType() const {\n  if (Autoplay() && !autoplay_policy_->IsGestureNeededForPlayback())\n    return WebMediaPlayer::kPreloadAuto;\n\n  WebMediaPlayer::Preload preload = PreloadType();\n  if (ignore_preload_none_ && preload == WebMediaPlayer::kPreloadNone)\n    return WebMediaPlayer::kPreloadMetaData;\n\n  return preload;\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":219024,"func":"WebURLResponseExtraDataImpl* GetExtraDataFromResponse(\n    const WebURLResponse& response) {\n  return static_cast<WebURLResponseExtraDataImpl*>(response.GetExtraData());\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":192084,"func":"  const AccessorySheetData& Build() { return accessory_sheet_data_; }\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":209494,"func":"window_change_handler(int sig)\n{\n\treceived_window_change_signal = 1;\n\tsignal(SIGWINCH, window_change_handler);\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":99726,"func":"const char *arch_vma_name(struct vm_area_struct *vma)\n{\n\tif (vma->vm_flags & VM_MPX)\n\t\treturn \"[mpx]\";\n\treturn NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":250346,"func":"void ExtensionPrefs::SetDidExtensionEscalatePermissions(\n    const Extension* extension, bool did_escalate) {\n  UpdateExtensionPref(extension->id(), kExtensionDidEscalatePermissions,\n                      Value::CreateBooleanValue(did_escalate));\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":235868,"func":"   virtual ~FwdTrans8x8HT() {}\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":20270,"func":"int ffv1_allocate_initial_states ( FFV1Context * f ) {\n int i ;\n for ( i = 0 ;\n i < f -> quant_table_count ;\n i ++ ) {\n f -> initial_states [ i ] = av_malloc ( f -> context_count [ i ] * sizeof ( * f -> initial_states [ i ] ) ) ;\n if ( ! f -> initial_states [ i ] ) return AVERROR ( ENOMEM ) ;\n memset ( f -> initial_states [ i ] , 128 , f -> context_count [ i ] * sizeof ( * f -> initial_states [ i ] ) ) ;\n }\n return 0 ;\n }","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":106336,"func":"TRIO_PUBLIC_STRING int trio_string_equal_case TRIO_ARGS2((self, other), trio_string_t* self,\n                                                         trio_string_t* other)\n{\n\tassert(self);\n\tassert(other);\n\n\treturn trio_equal_case(self->content, other->content);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":448696,"func":"okiibm_print_page(gx_device_printer *pdev, gp_file *prn_stream)\n{\n        char init_string[16], end_string[16];\n        int init_length, end_length;\n\n        init_length = sizeof(okiibm_init_string);\n        memcpy(init_string, okiibm_init_string, init_length);\n\n        end_length = sizeof(okiibm_end_string);\n        memcpy(end_string, okiibm_end_string, end_length);\n\n        if ( pdev->y_pixels_per_inch > 72 &&\n             pdev->x_pixels_per_inch > 60 )\n        {\n                \/* Unidirectional printing for the higher resolutions. *\/\n                memcpy( init_string + init_length, okiibm_one_direct,\n                        sizeof(okiibm_one_direct) );\n                init_length += sizeof(okiibm_one_direct);\n\n                memcpy( end_string + end_length, okiibm_two_direct,\n                        sizeof(okiibm_two_direct) );\n                end_length += sizeof(okiibm_two_direct);\n        }\n\n        return okiibm_print_page1( pdev, prn_stream,\n                                   pdev->y_pixels_per_inch > 72 ? 1 : 0,\n                                   init_string, init_length,\n                                   end_string, end_length );\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":225676,"func":"void BluetoothDeviceChromeOS::RequestPinCode(\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":118060,"func":"void posix_acl_fix_xattr_from_user(void *value, size_t size)\n{\n\tstruct user_namespace *user_ns = current_user_ns();\n\tif (user_ns == &init_user_ns)\n\t\treturn;\n\tposix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":194140,"func":"bool ExtensionApiTest::RunExtensionSubtest(const std::string& extension_name,\n                                           const std::string& page_url,\n                                           int flags) {\n  DCHECK(!page_url.empty()) << \"Argument page_url is required.\";\n  if (ExtensionSubtestsAreSkipped())\n    return true;\n  return RunExtensionTestImpl(extension_name, page_url, NULL, flags);\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":512631,"func":"void ssh_scp_free(ssh_scp scp)\n{\n    if (scp == NULL) {\n        return;\n    }\n\n    if (scp->state != SSH_SCP_NEW) {\n        ssh_scp_close(scp);\n    }\n\n    if (scp->channel) {\n        ssh_channel_free(scp->channel);\n    }\n\n    SAFE_FREE(scp->location);\n    SAFE_FREE(scp->request_name);\n    SAFE_FREE(scp->warning);\n    SAFE_FREE(scp);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":502053,"func":"static NTSTATUS pdb_samba_dsdb_add_groupmem(struct pdb_methods *m,\n\t\t\t\t     TALLOC_CTX *mem_ctx,\n\t\t\t\t     uint32_t group_rid, uint32_t member_rid)\n{\n\treturn pdb_samba_dsdb_mod_groupmem(m, mem_ctx, group_rid, member_rid,\n\t\t\t\t    LDB_FLAG_MOD_ADD);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":273765,"func":"confirm_multiple_windows (GtkWindow *parent_window,\n                          int        count,\n                          gboolean   use_tabs)\n{\n    GtkDialog *dialog;\n    char *prompt;\n    char *detail;\n    int response;\n\n    if (count <= SILENT_WINDOW_OPEN_LIMIT)\n    {\n        return TRUE;\n    }\n\n    prompt = _(\"Are you sure you want to open all files?\");\n    if (use_tabs)\n    {\n        detail = g_strdup_printf (ngettext (\"This will open %d separate tab.\",\n                                            \"This will open %d separate tabs.\", count), count);\n    }\n    else\n    {\n        detail = g_strdup_printf (ngettext (\"This will open %d separate window.\",\n                                            \"This will open %d separate windows.\", count), count);\n    }\n    dialog = eel_show_yes_no_dialog (prompt, detail,\n                                     _(\"_OK\"), _(\"_Cancel\"),\n                                     parent_window);\n    g_free (detail);\n\n    response = gtk_dialog_run (dialog);\n    gtk_widget_destroy (GTK_WIDGET (dialog));\n\n    return response == GTK_RESPONSE_YES;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":435804,"func":"int should_update_submodules(void)\n{\n\treturn config_update_recurse_submodules == RECURSE_SUBMODULES_ON;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":178773,"func":"bool RenderWidgetHostViewAura::ShouldSkipFrame(gfx::Size size_in_dip) const {\n  if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||\n      can_lock_compositor_ == NO_PENDING_COMMIT ||\n      !resize_lock_.get())\n    return false;\n\n  return size_in_dip != resize_lock_->expected_size();\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":294667,"func":"vrrp_gnotify_fault_handler(vector_t *strvec)\n{\n\tvrrp_sgroup_t *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);\n\tif (vgroup->script_fault) {\n\t\treport_config_error(CONFIG_GENERAL_ERROR, \"vrrp group %s: notify_fault script already specified - ignoring %s\", vgroup->gname, FMT_STR_VSLOT(strvec,1));\n\t\treturn;\n\t}\n\tvgroup->script_fault = set_vrrp_notify_script(strvec, 0);\n\tvgroup->notify_exec = true;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":53946,"func":"R_API ut64 r_bin_java_integer_cp_calc_size(RBinJavaCPTypeObj *obj) {\n\tut64 size = 0;\n\t\/\/ tag\n\tsize += 1;\n\t\/\/ obj->info.cp_string.string_idx = R_BIN_JAVA_USHORT (buffer, 1);\n\tsize += 4;\n\treturn size;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":449778,"func":"static void pp_pre_define(char *definition)\n{\n    Token *def, *space;\n    Line *l;\n    char *equals;\n\n    equals = strchr(definition, '=');\n    space = new_White(NULL);\n    def = new_Token(space, TOK_PREPROC_ID, \"%define\", 0);\n    if (equals)\n        *equals = ' ';\n    space->next = tokenize(definition);\n    if (equals)\n        *equals = '=';\n\n    \/* We can't predefine a TOK_LOCAL_MACRO for obvious reasons... *\/\n    if (space->next->type != TOK_PREPROC_ID &&\n        space->next->type != TOK_ID)\n        nasm_warn(WARN_OTHER, \"pre-defining non ID `%s\\'\\n\", definition);\n\n    l = nasm_malloc(sizeof(Line));\n    l->next = predef;\n    l->first = def;\n    l->finishes = NULL;\n    predef = l;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":154623,"func":"static bool ims_pcu_byte_needs_escape(u8 byte)\n{\n\treturn byte == IMS_PCU_PROTOCOL_STX ||\n\t       byte == IMS_PCU_PROTOCOL_ETX ||\n\t       byte == IMS_PCU_PROTOCOL_DLE;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":235525,"func":"linux_md_remove_component_device_not_seen_cb (gpointer user_data)\n{\n  RemoveComponentData *data = user_data;\n\n  throw_error (data->context,\n               ERROR_FAILED,\n               \"Error removing component: timeout (10s) waiting for slave to stop being busy\");\n\n  g_signal_handler_disconnect (data->slave->priv->daemon, data->device_changed_signal_handler_id);\n  remove_component_data_unref (data);\n\n  return FALSE;\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":128551,"func":"void nft_unregister_expr(struct nft_expr_type *type)\n{\n\tnfnl_lock(NFNL_SUBSYS_NFTABLES);\n\tlist_del_rcu(&type->list);\n\tnfnl_unlock(NFNL_SUBSYS_NFTABLES);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":184806,"func":"Color Document::themeColor() const\n{\n    for (HTMLMetaElement* metaElement = head() ? Traversal<HTMLMetaElement>::firstChild(*head()) : 0; metaElement; metaElement = Traversal<HTMLMetaElement>::nextSibling(*metaElement)) {\n        RGBA32 rgb = Color::transparent;\n        if (equalIgnoringCase(metaElement->name(), \"theme-color\") && CSSParser::parseColor(rgb, metaElement->content().string().stripWhiteSpace(), true))\n            return Color(rgb);\n    }\n    return Color();\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":277023,"func":"gfx::Size LayerTreeHostImpl::DrawViewportSize() const {\n  return DeviceViewport().size();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":196468,"func":"ListValue* ExtensionTabUtil::CreateTabList(\n    const Browser* browser,\n    const extensions::Extension* extension) {\n  NOTIMPLEMENTED();\n  return NULL;\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":66517,"func":"static inline void halt(void)\n{\n\tPVOP_VCALL0(irq.halt);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":296742,"func":"TfLiteStatus ResizeTensor(TfLiteContext* context,\n                          const TfLiteTensor* shape_tensor,\n                          TfLiteTensor* tensor_to_resize) {\n  \/\/ Currently only support int32 for output shape.\n  if (shape_tensor->type != kTfLiteInt32) {\n    TF_LITE_KERNEL_LOG(context, \"Output shape is %s, not int32.\",\n                       TfLiteTypeGetName(shape_tensor->type));\n    return kTfLiteError;\n  }\n\n  TfLiteIntArray* shape = TfLiteIntArrayCreate(NumElements(shape_tensor));\n  for (int i = 0; i < shape->size; ++i) {\n    shape->data[i] = GetTensorData<int32_t>(shape_tensor)[i];\n  }\n\n  return context->ResizeTensor(context, tensor_to_resize, shape);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":9384,"func":"long long Chapters::Atom::GetTime(\n    const Chapters* pChapters,\n    long long timecode)\n{\n    if (pChapters == NULL)\n        return -1;\n    Segment* const pSegment = pChapters->m_pSegment;\n    if (pSegment == NULL)  \/\/ weird\n        return -1;\n    const SegmentInfo* const pInfo = pSegment->GetInfo();\n    if (pInfo == NULL)\n        return -1;\n    const long long timecode_scale = pInfo->GetTimeCodeScale();\n    if (timecode_scale < 1)  \/\/ weird\n        return -1;\n    if (timecode < 0)\n        return -1;\n    const long long result = timecode_scale * timecode;\n    return result;\n}\n","target":1,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":151071,"func":"static int rose_dev_exists(rose_address *addr)\n{\n\tstruct net_device *dev;\n\n\trcu_read_lock();\n\tfor_each_netdev_rcu(&init_net, dev) {\n\t\tif ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)\n\t\t\tgoto out;\n\t}\n\tdev = NULL;\nout:\n\trcu_read_unlock();\n\treturn dev != NULL;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":12084,"func":"bool FileUtilProxy::Write(\n    scoped_refptr<MessageLoopProxy> message_loop_proxy,\n    PlatformFile file,\n    int64 offset,\n     const char* buffer,\n     int bytes_to_write,\n     WriteCallback* callback) {\n  if (bytes_to_write <= 0)\n     return false;\n   return Start(FROM_HERE, message_loop_proxy,\n                new RelayWrite(file, offset, buffer, bytes_to_write, callback));\n }\n","target":1,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":370637,"func":"GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)\n{\n    if (ga_is_frozen(ga_state)) {\n        return GUEST_FSFREEZE_STATUS_FROZEN;\n    }\n\n    return GUEST_FSFREEZE_STATUS_THAWED;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":181017,"func":"void ResourceDispatcherHost::OnSetCookieBlocked(URLRequest* request) {\n  RESOURCE_LOG(\"OnSetCookieBlocked: \" << request->url().spec());\n\n  int render_process_id, render_view_id;\n  if (!RenderViewForRequest(request, &render_process_id, &render_view_id))\n    return;\n\n  CallRenderViewHostResourceDelegate(\n      render_process_id, render_view_id,\n      &RenderViewHostDelegate::Resource::OnContentBlocked,\n      CONTENT_SETTINGS_TYPE_COOKIES);\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":354500,"func":"static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)\n{\n\tstruct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg);\n\tstruct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a));\n\tcompat_caddr_t udata;\n\tcompat_int_t n;\n\tint err;\n\t\n\terr = get_user(n, &ua32->op);\n\terr |= put_user(n, &a->op);\n\terr |= get_user(n, &ua32->flags);\n\terr |= put_user(n, &a->flags);\n\terr |= get_user(n, &ua32->datalen);\n\terr |= put_user(n, &a->datalen);\n\terr |= get_user(udata, &ua32->data);\n\terr |= put_user(compat_ptr(udata), &a->data);\n\tif (err)\n\t\treturn err;\n\n\treturn sys_ioctl(fd, cmd, (unsigned long)a);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":477137,"func":"int vhost_vsock_common_pre_save(void *opaque)\n{\n    VHostVSockCommon *vvc = opaque;\n\n    \/*\n     * At this point, backend must be stopped, otherwise\n     * it might keep writing to memory.\n     *\/\n    assert(!vvc->vhost_dev.started);\n\n    return 0;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":319112,"func":"DISAS_INSN(shift_im)\n\n{\n\n    TCGv reg;\n\n    int tmp;\n\n    TCGv shift;\n\n\n\n    set_cc_op(s, CC_OP_FLAGS);\n\n\n\n    reg = DREG(insn, 0);\n\n    tmp = (insn >> 9) & 7;\n\n    if (tmp == 0)\n\n        tmp = 8;\n\n    shift = tcg_const_i32(tmp);\n\n    \/* No need to flush flags becuse we know we will set C flag.  *\/\n\n    if (insn & 0x100) {\n\n        gen_helper_shl_cc(reg, cpu_env, reg, shift);\n\n    } else {\n\n        if (insn & 8) {\n\n            gen_helper_shr_cc(reg, cpu_env, reg, shift);\n\n        } else {\n\n            gen_helper_sar_cc(reg, cpu_env, reg, shift);\n\n        }\n\n    }\n\n}\n","target":1,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":373265,"func":"void tls_cert_dummy(void) {}","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":320382,"func":"int s390_virtio_hypercall(CPUS390XState *env)\n\n{\n\n    s390_virtio_fn fn = s390_diag500_table[env->regs[1]];\n\n\n\n    if (!fn) {\n\n        return -EINVAL;\n\n    }\n\n\n\n    return fn(&env->regs[2]);\n\n}\n","target":1,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":400890,"func":"ref_param_write_typed_array(gs_param_list * plist, gs_param_name pkey,\n                            void *pvalue, uint count,\n                            int (*make)(ref *, const void *, uint,\n                                        gs_ref_memory_t *))\n{\n    iparam_list *const iplist = (iparam_list *) plist;\n    ref value;\n    uint i;\n    ref *pe;\n    int code;\n\n    if ((code = ref_array_param_requested(iplist, pkey, &value, count,\n                                       \"ref_param_write_typed_array\")) <= 0)\n        return code;\n    for (i = 0, pe = value.value.refs; i < count; ++i, ++pe)\n        if ((code = (*make) (pe, pvalue, i, iplist->ref_memory)) < 0)\n            return code;\n    return ref_param_write(iplist, pkey, &value);\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":251721,"func":"error::Error GLES2DecoderPassthroughImpl::DoTexStorage3D(GLenum target,\n                                                         GLsizei levels,\n                                                         GLenum internalFormat,\n                                                         GLsizei width,\n                                                         GLsizei height,\n                                                         GLsizei depth) {\n  CheckErrorCallbackState();\n  api()->glTexStorage3DFn(target, levels, internalFormat, width, height, depth);\n  if (CheckErrorCallbackState()) {\n    return error::kNoError;\n  }\n\n  UpdateTextureSizeFromTarget(target);\n  return error::kNoError;\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":500705,"func":"static int call_function(cfg_t *cfg, cfg_opt_t *opt, cfg_opt_t *funcopt)\n{\n\tint ret;\n\tconst char **argv;\n\tunsigned int i;\n\n\tif (!cfg || !opt ||!funcopt) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\t\/*\n\t * create am argv string vector and call the registered function\n\t *\/\n\targv = calloc(funcopt->nvalues, sizeof(char *));\n\tif (!argv)\n\t\treturn CFG_FAIL;\n\n\tfor (i = 0; i < funcopt->nvalues; i++)\n\t\targv[i] = funcopt->values[i]->string;\n\n\tret = (*opt->func) (cfg, opt, funcopt->nvalues, argv);\n\tcfg_free_value(funcopt);\n\tfree(argv);\n\n\treturn ret;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":31725,"func":"std::vector<Box_iref::Reference> Box_iref::get_references_from(heif_item_id itemID) const\n{\n  std::vector<Reference> references;\n\n  for (const Reference& ref : m_references) {\n    if (ref.from_item_ID == itemID) {\n      references.push_back(ref);\n    }\n  }\n\n  return references;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":168018,"func":"void IndexedDBDispatcher::RequestIDBObjectStoreGet(\n    const IndexedDBKey& key,\n    WebIDBCallbacks* callbacks_ptr,\n    int32 idb_object_store_id,\n    const WebIDBTransaction& transaction,\n    WebExceptionCode* ec) {\n  ResetCursorPrefetchCaches();\n  scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);\n\n  int32 response_id = pending_callbacks_.Add(callbacks.release());\n  Send(new IndexedDBHostMsg_ObjectStoreGet(\n           idb_object_store_id, CurrentWorkerId(), response_id,\n           key, TransactionId(transaction), ec));\n  if (*ec)\n    pending_callbacks_.Remove(response_id);\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":168561,"func":"v8::Local<v8::Context> V8Proxy::isolatedWorldContext(int worldId)\n{\n    IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldId);\n    if (iter == m_isolatedWorlds.end())\n        return v8::Local<v8::Context>();\n    return v8::Local<v8::Context>::New(iter->second->context());\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":441140,"func":"void RGWPutBucketReplication_ObjStore_S3::send_response()\n{\n  if (op_ret)\n    set_req_state_err(s, op_ret);\n  dump_errno(s);\n  end_header(s, this, \"application\/xml\");\n  dump_start(s);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":444925,"func":"TEST_F(Http1ServerConnectionImplTest, LargeRequestHeadersAcceptedMaxConfigurable) {\n  max_request_headers_kb_ = 96;\n  std::string long_string = \"big: \" + std::string(95 * 1024, 'q') + \"\\r\\n\";\n  testRequestHeadersAccepted(long_string);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":65369,"func":"    \/\/! Return reference to the first image of the list \\const.\n    const CImg<T>& front() const {\n      return *_data;","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":361927,"func":"vte_sequence_handler_set_icon_title (VteTerminal *terminal, GValueArray *params)\n{\n\tvte_sequence_handler_set_title_internal(terminal, params, TRUE, FALSE);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":510840,"func":"inline void Http2Session::RemoveStream(int32_t id) {\n  streams_.erase(id);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":164965,"func":"void tracing_reset_all_online_cpus(void)\n{\n\tstruct trace_array *tr;\n\n\tlist_for_each_entry(tr, &ftrace_trace_arrays, list) {\n\t\tif (!tr->clear_trace)\n\t\t\tcontinue;\n\t\ttr->clear_trace = false;\n\t\ttracing_reset_online_cpus(&tr->trace_buffer);\n#ifdef CONFIG_TRACER_MAX_TRACE\n\t\ttracing_reset_online_cpus(&tr->max_buffer);\n#endif\n\t}\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":309280,"func":"static void cwd_globals_dtor(virtual_cwd_globals *cwd_g TSRMLS_DC) \/* {{{ *\/\n{\n\tCWD_STATE_FREE(&cwd_g->cwd);\n\trealpath_cache_clean(TSRMLS_C);\n}\n\/* }}} *\/\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":135844,"func":"inline int web_client_api_request_v1_alarm_variables(RRDHOST *host, struct web_client *w, char *url) {\n    return web_client_api_request_single_chart(host, w, url, health_api_v1_chart_variables2json);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":363552,"func":"irc_server_switch_address (struct t_irc_server *server, int connection)\n{\n    if (server->addresses_count > 1)\n    {\n        irc_server_set_index_current_address (server,\n                                              (server->index_current_address + 1) % server->addresses_count);\n        weechat_printf (server->buffer,\n                        _(\"%s: switching address to %s\/%d\"),\n                        IRC_PLUGIN_NAME,\n                        server->current_address,\n                        server->current_port);\n        if (connection)\n        {\n            if (server->index_current_address == 0)\n                irc_server_reconnect_schedule (server);\n            else\n                irc_server_connect (server);\n        }\n    }\n    else\n    {\n        if (connection)\n            irc_server_reconnect_schedule (server);\n    }\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":519768,"func":"  inline uint32 query_length() const\n  {\n    return static_cast<uint32>(query_string.length());\n  }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":226435,"func":"void DataReductionProxyIOData::SetProxyPrefs(bool enabled, bool at_startup) {\n  DCHECK(io_task_runner_->BelongsToCurrentThread());\n  enabled_ = enabled;\n  config_->SetProxyConfig(enabled, at_startup);\n  if (config_client_) {\n    config_client_->SetEnabled(enabled);\n    if (enabled)\n      config_client_->RetrieveConfig();\n  }\n\n  if (!enabled) {\n    if (proxy_config_client_)\n      proxy_config_client_->ClearBadProxiesCache();\n  }\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":44047,"func":"static TEE_Result op_attr_secret_value_from_obj(void *attr, void *src_attr)\n{\n\tstruct tee_cryp_obj_secret *key = attr;\n\tstruct tee_cryp_obj_secret *src_key = src_attr;\n\n\tif (src_key->key_size > key->alloc_size)\n\t\treturn TEE_ERROR_BAD_STATE;\n\tmemcpy(key + 1, src_key + 1, src_key->key_size);\n\tkey->key_size = src_key->key_size;\n\treturn TEE_SUCCESS;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":341115,"func":"static void v9fs_create_post_mksock(V9fsState *s, V9fsCreateState *vs,\n\n                                                                int err)\n\n{\n\n    if (err) {\n\n        err = -errno;\n\n        goto out;\n\n    }\n\n\n\n    err = v9fs_do_chmod(s, &vs->fullname, vs->perm & 0777);\n\n    v9fs_create_post_perms(s, vs, err);\n\n    return;\n\n\n\nout:\n\n    v9fs_post_create(s, vs, err);\n\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":460065,"func":"proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,\n\t\t    gint length, guint32 value)\n{\n\tproto_item\t  *pi = NULL;\n\theader_field_info *hfinfo;\n\n\tCHECK_FOR_NULL_TREE(tree);\n\n\tTRY_TO_FAKE_THIS_ITEM(tree, hfindex, hfinfo);\n\n\tswitch (hfinfo->type) {\n\t\tcase FT_CHAR:\n\t\tcase FT_UINT8:\n\t\tcase FT_UINT16:\n\t\tcase FT_UINT24:\n\t\tcase FT_UINT32:\n\t\tcase FT_FRAMENUM:\n\t\t\tpi = proto_tree_add_pi(tree, hfinfo, tvb, start, &length);\n\t\t\tproto_tree_set_uint(PNODE_FINFO(pi), value);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tREPORT_DISSECTOR_BUG(\"field %s is not of type FT_CHAR, FT_UINT8, FT_UINT16, FT_UINT24, FT_UINT32, or FT_FRAMENUM\",\n\t\t\t    hfinfo->abbrev);\n\t}\n\n\treturn pi;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":75981,"func":"error_t httpSend(HttpConnection *connection,\n   const void *data, size_t length, uint_t flags)\n{\n#if (NET_RTOS_SUPPORT == ENABLED)\n   error_t error;\n\n#if (HTTP_SERVER_TLS_SUPPORT == ENABLED)\n   \/\/Check whether a secure connection is being used\n   if(connection->tlsContext != NULL)\n   {\n      \/\/Use TLS to transmit data to the client\n      error = tlsWrite(connection->tlsContext, data, length, NULL, flags);\n   }\n   else\n#endif\n   {\n      \/\/Transmit data to the client\n      error = socketSend(connection->socket, data, length, NULL, flags);\n   }\n\n   \/\/Return status code\n   return error;\n#else\n   \/\/Prevent buffer overflow\n   if((connection->bufferLen + length) > HTTP_SERVER_BUFFER_SIZE)\n      return ERROR_BUFFER_OVERFLOW;\n\n   \/\/Copy user data\n   osMemcpy(connection->buffer + connection->bufferLen, data, length);\n   \/\/Adjust the length of the buffer\n   connection->bufferLen += length;\n\n   \/\/Successful processing\n   return NO_ERROR;\n#endif\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":443408,"func":"reply_get_NS_rrset(struct reply_info* rep)\n{\n\tsize_t i;\n\tfor(i=0; i<rep->rrset_count; i++) {\n\t\tif(rep->rrsets[i]->rk.type == htons(LDNS_RR_TYPE_NS)) {\n\t\t\treturn rep->rrsets[i];\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":333628,"func":"static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,\n\n                             int width, int height)\n\n{\n\n    int src_wrap, x, y;\n\n    int r, g, b;\n\n    uint8_t *lum, *cb, *cr;\n\n    const uint8_t *p;\n\n\n\n    lum = dst->data[0];\n\n    cb = dst->data[1];\n\n    cr = dst->data[2];\n\n\n\n    src_wrap = src->linesize[0] - width * BPP;\n\n    p = src->data[0];\n\n    for(y=0;y<height;y++) {\n\n        for(x=0;x<width;x++) {\n\n            RGB_IN(r, g, b, p);\n\n            lum[0] = RGB_TO_Y_CCIR(r, g, b);\n\n            cb[0] = RGB_TO_U_CCIR(r, g, b, 0);\n\n            cr[0] = RGB_TO_V_CCIR(r, g, b, 0);\n\n            cb++;\n\n            cr++;\n\n            lum++;\n\n        }\n\n        p += src_wrap;\n\n        lum += dst->linesize[0] - width;\n\n        cb += dst->linesize[1] - width;\n\n        cr += dst->linesize[2] - width;\n\n    }\n\n}\n","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":445882,"func":"static void PresentationContext_unref(PresentationContext* presentation)\n{\n\tVideoClientContextPriv* priv;\n\tMAPPED_GEOMETRY* geometry;\n\n\tif (!presentation)\n\t\treturn;\n\n\tif (InterlockedDecrement(&presentation->refCounter) != 0)\n\t\treturn;\n\n\tgeometry = presentation->geometry;\n\tif (geometry)\n\t{\n\t\tgeometry->MappedGeometryUpdate = NULL;\n\t\tgeometry->MappedGeometryClear = NULL;\n\t\tgeometry->custom = NULL;\n\t\tmappedGeometryUnref(geometry);\n\t}\n\n\tpriv = presentation->video->priv;\n\n\th264_context_free(presentation->h264);\n\tStream_Free(presentation->currentSample, TRUE);\n\tpresentation->video->deleteSurface(presentation->video, presentation->surface);\n\tBufferPool_Return(priv->surfacePool, presentation->surfaceData);\n\tyuv_context_free(presentation->yuv);\n\tfree(presentation);\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":163275,"func":"bool DesktopWindowTreeHostX11::IsFullscreen() const {\n  return is_fullscreen_;\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":254013,"func":"int WebFrame::InstanceCount() {\n  return g_frame_count;\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":450464,"func":"static int decode_lookupp(struct xdr_stream *xdr)\n{\n\treturn decode_op_hdr(xdr, OP_LOOKUPP);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":286006,"func":"static const IntSize MaxDragImageSize(float device_scale_factor) {\n#if defined(OS_MACOSX)\n  static const IntSize kMaxDragImageSize(400, 400);\n#else\n  static const IntSize kMaxDragImageSize(200, 200);\n#endif\n  IntSize max_size_in_pixels = kMaxDragImageSize;\n  max_size_in_pixels.Scale(device_scale_factor);\n  return max_size_in_pixels;\n}\n","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":278708,"func":"void HTMLMediaElement::VideoWillBeDrawnToCanvas() const {\n  DCHECK(IsHTMLVideoElement());\n  UseCounter::Count(GetDocument(), WebFeature::kVideoInCanvas);\n  autoplay_policy_->VideoWillBeDrawnToCanvas();\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":226922,"func":"void LayerTreeCoordinator::layerFlushTimerFired(Timer<LayerTreeCoordinator>*)\n{\n    performScheduledLayerFlush();\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":470114,"func":"static void svm_msr_filter_changed(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tu32 i;\n\n\t\/*\n\t * Set intercept permissions for all direct access MSRs again. They\n\t * will automatically get filtered through the MSR filter, so we are\n\t * back in sync after this.\n\t *\/\n\tfor (i = 0; direct_access_msrs[i].index != MSR_INVALID; i++) {\n\t\tu32 msr = direct_access_msrs[i].index;\n\t\tu32 read = test_bit(i, svm->shadow_msr_intercept.read);\n\t\tu32 write = test_bit(i, svm->shadow_msr_intercept.write);\n\n\t\tset_msr_interception_bitmap(vcpu, svm->msrpm, msr, read, write);\n\t}\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":266190,"func":"CongestionAndRttState moveCurrentCongestionAndRttState(\n    QuicServerConnectionState& conn) {\n  CongestionAndRttState state;\n  state.peerAddress = conn.peerAddress;\n  state.recordTime = Clock::now();\n  state.congestionController = std::move(conn.congestionController);\n  state.srtt = conn.lossState.srtt;\n  state.lrtt = conn.lossState.lrtt;\n  state.rttvar = conn.lossState.rttvar;\n  state.mrtt = conn.lossState.mrtt;\n  return state;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":140090,"func":"const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk)\n{\n  unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;\n  return &chunk[total_chunk_length];\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":367117,"func":"static int cap_unix_may_send(struct socket *sock, struct socket *other)\n{\n\treturn 0;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":521294,"func":"bool Item_func_in::fix_for_row_comparison_using_bisection(THD *thd)\n{\n  if (unlikely(!(array= new (thd->mem_root) in_row(thd, arg_count-1, 0))))\n    return true;\n  cmp_item_row *cmp= &((in_row*)array)->tmp;\n  if (cmp->prepare_comparators(thd, func_name(), this, 0))\n    return true;\n  fix_in_vector();\n  return false;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":388283,"func":"static int extent_same_check_offsets(struct inode *inode, u64 off, u64 *plen,\n\t\t\t\t     u64 olen)\n{\n\tu64 len = *plen;\n\tu64 bs = BTRFS_I(inode)->root->fs_info->sb->s_blocksize;\n\n\tif (off + olen > inode->i_size || off + olen < off)\n\t\treturn -EINVAL;\n\n\t\/* if we extend to eof, continue to block boundary *\/\n\tif (off + len == inode->i_size)\n\t\t*plen = len = ALIGN(inode->i_size, bs) - off;\n\n\t\/* Check that we are block aligned - btrfs_clone() requires this *\/\n\tif (!IS_ALIGNED(off, bs) || !IS_ALIGNED(off + len, bs))\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":271766,"func":"static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n{\n\tif (!buf || size < 46)\n\t\tdie(\"Not a valid commit: %s\", sha1_to_hex(b->sha1));\n\tif (memcmp(\"tree \", buf, 5)\n\t\t|| get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))\n\t\tdie(\"The commit %s is corrupt\", sha1_to_hex(b->sha1));\n\thashcpy(b->branch_tree.versions[0].sha1,\n\t\tb->branch_tree.versions[1].sha1);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":399613,"func":"hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)\n{\n\tktime_t expires_next;\n\n\tif (!cpu_base->hres_active)\n\t\treturn;\n\n\texpires_next = __hrtimer_get_next_event(cpu_base);\n\n\tif (skip_equal && expires_next == cpu_base->expires_next)\n\t\treturn;\n\n\tcpu_base->expires_next = expires_next;\n\n\t\/*\n\t * If a hang was detected in the last timer interrupt then we\n\t * leave the hang delay active in the hardware. We want the\n\t * system to make progress. That also prevents the following\n\t * scenario:\n\t * T1 expires 50ms from now\n\t * T2 expires 5s from now\n\t *\n\t * T1 is removed, so this code is called and would reprogram\n\t * the hardware to 5s from now. Any hrtimer_start after that\n\t * will not reprogram the hardware due to hang_detected being\n\t * set. So we'd effectivly block all timers until the T2 event\n\t * fires.\n\t *\/\n\tif (cpu_base->hang_detected)\n\t\treturn;\n\n\ttick_program_event(cpu_base->expires_next, 1);\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":241360,"func":"void VideoRendererBase::AttemptFlush_Locked() {\n  lock_.AssertAcquired();\n  DCHECK_EQ(kFlushing, state_);\n\n  ready_frames_.clear();\n\n  if (!pending_paint_ && !pending_read_) {\n    state_ = kFlushed;\n    current_frame_ = NULL;\n    base::ResetAndReturn(&flush_cb_).Run();\n  }\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":85404,"func":"closeTransport(PRIVATE_ASSOCIATIONKEY ** association)\n{\n    closeTransportTCP(association);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":446964,"func":"static bool paged_attrs_same(const char * const *attrs_1,\n\t\t\t     const char * const *attrs_2) {\n\tint i;\n\tif (attrs_1 == NULL || attrs_2 == NULL) {\n\t\tif (attrs_1 == NULL && attrs_2 == NULL) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfor (i=0; attrs_1[i] != NULL; i++) {\n\t       if (!ldb_attr_in_list(attrs_2, attrs_1[i])) {\n\t\t       return false;\n\t       }\n\t}\n\treturn true;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":447985,"func":"_XimSetICValuesCheck(\n    Xim          im,\n    INT16        len,\n    XPointer\t data,\n    XPointer     arg)\n{\n    Xic\t\t ic = (Xic)arg;\n    CARD16\t*buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);\n    CARD8\t major_opcode = *((CARD8 *)data);\n    CARD8\t minor_opcode = *((CARD8 *)data + 1);\n    XIMID\t imid = buf_s[0];\n    XICID\t icid = buf_s[1];\n\n    if ((major_opcode == XIM_SET_IC_VALUES_REPLY)\n     && (minor_opcode == 0)\n     && (imid == im->private.proto.imid)\n     && (icid == ic->private.proto.icid))\n\treturn True;\n    if ((major_opcode == XIM_ERROR)\n     && (minor_opcode == 0)\n     && (buf_s[2] & XIM_IMID_VALID)\n     && (imid == im->private.proto.imid)\n     && (buf_s[2] & XIM_ICID_VALID)\n     && (icid == ic->private.proto.icid))\n\treturn True;\n    return False;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":40787,"func":"static void write_bin_response(conn *c, void *d, int hlen, int keylen, int dlen) {\n    if (!c->noreply || c->cmd == PROTOCOL_BINARY_CMD_GET ||\n        c->cmd == PROTOCOL_BINARY_CMD_GETK) {\n        add_bin_header(c, 0, hlen, keylen, dlen);\n        if(dlen > 0) {\n            add_iov(c, d, dlen);\n        }\n        conn_set_state(c, conn_mwrite);\n        c->write_and_go = conn_new_cmd;\n    } else {\n        conn_set_state(c, conn_new_cmd);\n    }\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":108762,"func":"static inline void schedule_debug(struct task_struct *prev)\n{\n\t\/*\n\t * Test if we are atomic. Since do_exit() needs to call into\n\t * schedule() atomically, we ignore that path for now.\n\t * Otherwise, whine if we are scheduling when we should not be.\n\t *\/\n\tif (unlikely(in_atomic_preempt_off() && !prev->exit_state))\n\t\t__schedule_bug(prev);\n\n\tprofile_hit(SCHED_PROFILING, __builtin_return_address(0));\n\n\tschedstat_inc(this_rq(), sched_count);\n#ifdef CONFIG_SCHEDSTATS\n\tif (unlikely(prev->lock_depth >= 0)) {\n\t\tschedstat_inc(this_rq(), bkl_count);\n\t\tschedstat_inc(prev, sched_info.bkl_count);\n\t}\n#endif\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":418560,"func":"snmpLookupNodeStr(mib_tree_entry *root, const char *str)\n{\n    oid *name;\n    int namelen;\n    mib_tree_entry *e;\n\n    if (root)\n        e = root;\n    else\n        e = mib_tree_head;\n\n    if (! snmpCreateOidFromStr(str, &name, &namelen))\n        return NULL;\n\n    \/* I wish there were some kind of sensible existing tree traversal\n     * routine to use. I'll worry about that later *\/\n    if (namelen <= 1) {\n        xfree(name);\n        return e;       \/* XXX it should only be this? *\/\n    }\n\n    int i, r = 1;\n    while (r < namelen) {\n\n        \/* Find the child node which matches this *\/\n        for (i = 0; i < e->children && e->leaves[i]->name[r] != name[r]; ++i) ; \/\/ seek-loop\n\n        \/* Are we pointing to that node? *\/\n        if (i >= e->children)\n            break;\n        assert(e->leaves[i]->name[r] == name[r]);\n\n        \/* Skip to that node! *\/\n        e = e->leaves[i];\n        ++r;\n    }\n\n    xfree(name);\n    return e;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":447097,"func":"Guint FoFiTrueType::scanLookupList(Guint listIndex, Guint orgGID)\n{\n  Guint lookupTable;\n  Guint subTableCount;\n  Guint subTable;\n  Guint i;\n  Guint gid = 0;\n  Guint pos;\n\n  if (gsubLookupList == 0) return 0; \/* no lookup list *\/\n  pos = gsubLookupList+2+listIndex*2;\n  lookupTable = getU16BE(pos,&parsedOk);\n  \/* read lookup table *\/\n  pos = gsubLookupList+lookupTable+4;\n  subTableCount = getU16BE(pos,&parsedOk);\n  pos += 2;;\n  for (i = 0;i < subTableCount;i++) {\n    subTable = getU16BE(pos,&parsedOk);\n    pos += 2;\n    if ((gid = scanLookupSubTable(gsubLookupList+lookupTable+subTable,orgGID))\n         != 0) break;\n  }\n  return gid;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":473878,"func":"void fd_install(unsigned int fd, struct file *file)\n{\n\tstruct files_struct *files = current->files;\n\tstruct fdtable *fdt;\n\n\trcu_read_lock_sched();\n\n\tif (unlikely(files->resize_in_progress)) {\n\t\trcu_read_unlock_sched();\n\t\tspin_lock(&files->file_lock);\n\t\tfdt = files_fdtable(files);\n\t\tBUG_ON(fdt->fd[fd] != NULL);\n\t\trcu_assign_pointer(fdt->fd[fd], file);\n\t\tspin_unlock(&files->file_lock);\n\t\treturn;\n\t}\n\t\/* coupled with smp_wmb() in expand_fdtable() *\/\n\tsmp_rmb();\n\tfdt = rcu_dereference_sched(files->fdt);\n\tBUG_ON(fdt->fd[fd] != NULL);\n\trcu_assign_pointer(fdt->fd[fd], file);\n\trcu_read_unlock_sched();\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":251516,"func":"PassRefPtr<HTMLCollection> Document::forms()\n{\n    return ensureCachedCollection(DocForms);\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":190932,"func":"void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement* referencedElement)\n{\n    ASSERT(referencedElement);\n    HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_elementDependencies.find(referencedElement);\n    if (it == m_elementDependencies.end())\n        return;\n    ASSERT(it->key == referencedElement);\n    Vector<SVGElement*> toBeNotified;\n\n    HashSet<SVGElement*>* referencingElements = it->value.get();\n    HashSet<SVGElement*>::iterator setEnd = referencingElements->end();\n    for (HashSet<SVGElement*>::iterator setIt = referencingElements->begin(); setIt != setEnd; ++setIt)\n        toBeNotified.append(*setIt);\n\n    Vector<SVGElement*>::iterator vectorEnd = toBeNotified.end();\n    for (Vector<SVGElement*>::iterator vectorIt = toBeNotified.begin(); vectorIt != vectorEnd; ++vectorIt) {\n        if (HashSet<SVGElement*>* referencingElements = setOfElementsReferencingTarget(referencedElement)) {\n            if (referencingElements->contains(*vectorIt))\n                (*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr);\n        }\n    }\n}\n","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":486190,"func":"dns_enable_merge (void (*f)(const char *, const char *, const char *))\n{\n    merge_enable = 1;\n    merge_logger = f;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":234835,"func":"MediaElementAudioSourceNode* MediaElementAudioSourceNode::Create(\n    AudioContext* context,\n    const MediaElementAudioSourceOptions& options,\n    ExceptionState& exception_state) {\n  return Create(*context, *options.mediaElement(), exception_state);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":116368,"func":"ConfigHelper::buildBaseListener(const std::string& name, const std::string& address,\n                                const std::string& filter_chains) {\n  API_NO_BOOST(envoy::config::listener::v3::Listener) listener;\n  TestUtility::loadFromYaml(fmt::format(\n                                R\"EOF(\n      name: {}\n      address:\n        socket_address:\n          address: {}\n          port_value: 0\n      filter_chains:\n      {}\n    )EOF\",\n                                name, address, filter_chains),\n                            listener);\n  return listener;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":378672,"func":"static bool vfswrap_strict_lock(struct vfs_handle_struct *handle,\n\t\t\t\tfiles_struct *fsp,\n\t\t\t\tstruct lock_struct *plock)\n{\n\tSMB_ASSERT(plock->lock_type == READ_LOCK ||\n\t    plock->lock_type == WRITE_LOCK);\n\n\treturn strict_lock_default(fsp, plock);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":62469,"func":"void LoRaMacProcess( void )\r\n{\r\n    uint8_t noTx = false;\r\n\r\n    LoRaMacHandleIrqEvents( );\r\n    LoRaMacClassBProcess( );\r\n\r\n    \/\/ MAC proceeded a state and is ready to check\r\n    if( MacCtx.MacFlags.Bits.MacDone == 1 )\r\n    {\r\n        LoRaMacEnableRequests( LORAMAC_REQUEST_HANDLING_OFF );\r\n        LoRaMacCheckForRxAbort( );\r\n\r\n        \/\/ An error occurs during transmitting\r\n        if( IsRequestPending( ) > 0 )\r\n        {\r\n            noTx |= LoRaMacCheckForBeaconAcquisition( );\r\n        }\r\n\r\n        if( noTx == 0x00 )\r\n        {\r\n            LoRaMacHandleMlmeRequest( );\r\n            LoRaMacHandleMcpsRequest( );\r\n        }\r\n        LoRaMacHandleRequestEvents( );\r\n        LoRaMacHandleScheduleUplinkEvent( );\r\n        LoRaMacEnableRequests( LORAMAC_REQUEST_HANDLING_ON );\r\n    }\r\n    LoRaMacHandleIndicationEvents( );\r\n    if( MacCtx.RxSlot == RX_SLOT_WIN_CLASS_C )\r\n    {\r\n        OpenContinuousRxCWindow( );\r\n    }\r\n}\r","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":156991,"func":"void WebContents::GoForward() {\n  if (!ElectronBrowserClient::Get()->CanUseCustomSiteInstance()) {\n    electron::ElectronBrowserClient::SuppressRendererProcessRestartForOnce();\n  }\n  web_contents()->GetController().GoForward();\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":131915,"func":"mode_t enc_untrusted_umask(mode_t mask) {\n  return EnsureInitializedAndDispatchSyscall(asylo::system_call::kSYS_umask,\n                                             mask);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":86366,"func":"rsvg_new_filter_primitive_specular_lighting (const char *element_name, RsvgNode *parent)\n{\n    RsvgFilterPrimitiveSpecularLighting *filter;\n\n    filter = g_new0 (RsvgFilterPrimitiveSpecularLighting, 1);\n    filter->super.in = g_string_new (\"none\");\n    filter->super.result = g_string_new (\"none\");\n    filter->surfaceScale = 1;\n    filter->specularConstant = 1;\n    filter->specularExponent = 1;\n    filter->lightingcolor = 0xFFFFFFFF;\n    filter->super.render = rsvg_filter_primitive_specular_lighting_render;\n\n    return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_SPECULAR_LIGHTING,\n                                parent,\n                                rsvg_state_new (),\n                                filter,\n                                rsvg_filter_primitive_specular_lighting_set_atts,\n                                rsvg_filter_draw,\n                                rsvg_filter_primitive_free);\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":159480,"func":"LibRaw_byte_buffer::~LibRaw_byte_buffer() \n{ \n    if(do_free) free(buf);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":201836,"func":"void LoadingDataCollector::CleanupAbandonedNavigations(\n    const NavigationID& navigation_id) {\n  if (stats_collector_)\n    stats_collector_->CleanupAbandonedStats();\n\n  static const base::TimeDelta max_navigation_age =\n      base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds);\n\n  base::TimeTicks time_now = base::TimeTicks::Now();\n  for (auto it = inflight_navigations_.begin();\n       it != inflight_navigations_.end();) {\n    if ((it->first.tab_id == navigation_id.tab_id) ||\n        (time_now - it->first.creation_time > max_navigation_age)) {\n      inflight_navigations_.erase(it++);\n    } else {\n      ++it;\n    }\n  }\n}\n","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":64474,"func":"static gboolean handle_store(MonoThread *thread)\n{\n\tmono_threads_lock ();\n\n\tTHREAD_DEBUG (g_message (\"%s: thread %p ID %\"G_GSIZE_FORMAT, __func__, thread, (gsize)thread->internal_thread->tid));\n\n\tif (threads_starting_up)\n\t\tmono_g_hash_table_remove (threads_starting_up, thread);\n\n\tif (shutting_down) {\n\t\tmono_threads_unlock ();\n\t\treturn FALSE;\n\t}\n\n\tif(threads==NULL) {\n\t\tMONO_GC_REGISTER_ROOT_FIXED (threads);\n\t\tthreads=mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_VALUE_GC);\n\t}\n\n\t\/* We don't need to duplicate thread->handle, because it is\n\t * only closed when the thread object is finalized by the GC.\n\t *\/\n\tg_assert (thread->internal_thread);\n\tmono_g_hash_table_insert(threads, (gpointer)(gsize)(thread->internal_thread->tid),\n\t\t\t\t thread->internal_thread);\n\n\tmono_threads_unlock ();\n\n\treturn TRUE;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":69264,"func":"validate_cursor(void)\n{\n    check_cursor_moved(curwin);\n    if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW))\n\tcurs_columns(TRUE);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":118088,"func":"static void ff_jref_idct2_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block)\n{\n    ff_j_rev_dct2 (block);\n    add_pixels_clamped2_c(block, dest, line_size);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":231021,"func":"AutofillDialogViews::NotificationArea::~NotificationArea() {}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":444600,"func":"TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsNotDisarmedOnIncompleteRequestWithHeader) {\n  request_timeout_ = std::chrono::milliseconds(10);\n  setup(false, \"\");\n\n  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> Http::Status {\n    Event::MockTimer* request_timer = setUpTimer();\n    EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1);\n    EXPECT_CALL(*request_timer, disableTimer()).Times(0);\n\n    RequestDecoder* decoder = &conn_manager_->newStream(response_encoder_);\n    RequestHeaderMapPtr headers{\n        new TestRequestHeaderMapImpl{{\":authority\", \"host\"}, {\":path\", \"\/\"}, {\":method\", \"GET\"}}};\n\n    \/\/ the second parameter 'false' leaves the stream open\n    decoder->decodeHeaders(std::move(headers), false);\n    return Http::okStatus();\n  }));\n\n  Buffer::OwnedImpl fake_input(\"1234\");\n  conn_manager_->onData(fake_input, false); \/\/ kick off request\n\n  EXPECT_EQ(0U, stats_.named_.downstream_rq_timeout_.value());\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":223706,"func":"    ReceiveFileWriterCallback()\n    {\n    }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":240278,"func":"void ChromotingInstance::PauseVideo(bool pause) {\n  if (!IsConnected()) {\n    return;\n  }\n  protocol::VideoControl video_control;\n  video_control.set_enable(!pause);\n  host_connection_->host_stub()->ControlVideo(video_control);\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":314035,"func":"void RenderFrameHostImpl::ForEachImmediateLocalRoot(\n    const base::Callback<void(RenderFrameHostImpl*)>& callback) {\n  if (!frame_tree_node_->child_count())\n    return;\n\n  base::queue<FrameTreeNode*> queue;\n  for (size_t index = 0; index < frame_tree_node_->child_count(); ++index)\n    queue.push(frame_tree_node_->child_at(index));\n  while (queue.size()) {\n    FrameTreeNode* current = queue.front();\n    queue.pop();\n    if (current->current_frame_host()->is_local_root()) {\n      callback.Run(current->current_frame_host());\n    } else {\n      for (size_t index = 0; index < current->child_count(); ++index)\n        queue.push(current->child_at(index));\n    }\n  }\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":410458,"func":"QUtil::srandom(unsigned int seed)\n{\n#ifdef HAVE_RANDOM\n    ::srandom(seed);\n#else\n    srand(seed);\n#endif\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":184638,"func":"void InspectorResourceAgent::didFinishXHRLoading(ThreadableLoaderClient* client, unsigned long identifier, ScriptString sourceString, const String&, const String&, unsigned)\n{\n    m_pendingXHRReplayData.remove(client);\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":316192,"func":"void AppCacheUpdateJob::URLFetcher::Start() {\n  request_->set_first_party_for_cookies(job_->manifest_url_);\n  if (fetch_type_ == MANIFEST_FETCH && job_->doing_full_update_check_)\n    request_->SetLoadFlags(request_->load_flags() | net::LOAD_BYPASS_CACHE);\n  else if (existing_response_headers_.get())\n    AddConditionalHeaders(existing_response_headers_.get());\n  request_->Start();\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":222343,"func":"static void padstr(char *str, const char *src, int len)\n{\n    int i, v;\n    for(i = 0; i < len; i++) {\n        if (*src)\n            v = *src++;\n        else\n            v = ' ';\n        str[i^1] = v;\n    }\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":172205,"func":"bool HTMLInputElement::tooLong() const\n{\n    return willValidate() && tooLong(value(), CheckDirtyFlag);\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":94801,"func":"static void add_sit_entry(unsigned int segno, struct list_head *head)\n{\n\tstruct sit_entry_set *ses;\n\tunsigned int start_segno = START_SEGNO(segno);\n\n\tlist_for_each_entry(ses, head, set_list) {\n\t\tif (ses->start_segno == start_segno) {\n\t\t\tses->entry_cnt++;\n\t\t\tadjust_sit_entry_set(ses, head);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tses = grab_sit_entry_set();\n\n\tses->start_segno = start_segno;\n\tses->entry_cnt++;\n\tlist_add(&ses->set_list, head);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":406529,"func":"  virtual Item *replace_equal_field(uchar * arg) { return this; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":387640,"func":"__libxml2_xzcompressed(xzFile f) {\n    return xz_compressed(f);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":237702,"func":"bool SendCloseTabJSONRequest(\n    AutomationMessageSender* sender,\n    int browser_index,\n    int tab_index,\n    std::string* error_msg) {\n  DictionaryValue dict;\n  dict.SetString(\"command\", \"CloseTab\");\n  dict.SetInteger(\"windex\", browser_index);\n  dict.SetInteger(\"tab_index\", tab_index);\n  DictionaryValue reply_dict;\n  return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":35156,"func":"R_API void r_bin_java_print_annotation_default_attr_summary(RBinJavaAttrInfo *attr) {\n\tif (attr && attr->type == R_BIN_JAVA_ATTR_TYPE_ANNOTATION_DEFAULT_ATTR) {\n\t\teprintf (\"Annotation Default Attribute Information:\\n\");\n\t\teprintf (\"   Attribute Offset: 0x%08\"PFMT64x \"\\n\", attr->file_offset);\n\t\teprintf (\"   Attribute Name Index: %d (%s)\\n\", attr->name_idx, attr->name);\n\t\teprintf (\"   Attribute Length: %d\\n\", attr->length);\n\t\tr_bin_java_print_element_value_summary ((attr->info.annotation_default_attr.default_value));\n\t} else {\n\t\t\/\/ TODO: eprintf attr is invalid\n\t}\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":182410,"func":"void WebPageProxy::reattachToWebProcess()\n{\n    m_isValid = true;\n\n    context()->relaunchProcessIfNecessary();\n    process()->addExistingWebPage(this, m_pageID);\n\n    initializeWebPage();\n\n    m_pageClient->didRelaunchProcess();\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":252112,"func":"static void JNI_SendTabToSelfAndroidBridge_GetAllGuids(\n    JNIEnv* env,\n    const JavaParamRef<jobject>& j_profile,\n    const JavaParamRef<jobject>& j_guid_list_obj) {\n  SendTabToSelfModel* model = GetModel(j_profile);\n  if (model->IsReady()) {\n    std::vector<std::string> all_ids = model->GetAllGuids();\n    for (std::vector<std::string>::iterator it = all_ids.begin();\n         it != all_ids.end(); ++it) {\n      ScopedJavaLocalRef<jstring> j_guid = ConvertUTF8ToJavaString(env, *it);\n      Java_SendTabToSelfAndroidBridge_addToGuidList(env, j_guid_list_obj,\n                                                    j_guid);\n    }\n  }\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":332764,"func":"test_tls_get_ipaddr(const char *addrstr,\n\n                    char **data,\n\n                    int *datalen)\n\n{\n\n    struct addrinfo *res;\n\n    struct addrinfo hints;\n\n\n\n    memset(&hints, 0, sizeof(hints));\n\n    hints.ai_flags = AI_NUMERICHOST;\n\n    g_assert(getaddrinfo(addrstr, NULL, &hints, &res) == 0);\n\n\n\n    *datalen = res->ai_addrlen;\n\n    *data = g_new(char, *datalen);\n\n    memcpy(*data, res->ai_addr, *datalen);\n\n\n}","target":1,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":441242,"func":"void RGWDeleteBucketReplication_ObjStore_S3::update_sync_policy(rgw_sync_policy_info *policy)\n{\n  policy->groups.erase(enabled_group_id);\n  policy->groups.erase(disabled_group_id);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":43712,"func":"void o2nm_node_put(struct o2nm_node *node)\n{\n\tconfig_item_put(&node->nd_item);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":519666,"func":"static uchar *get_field_name(Field **buff, size_t *length,\n                             my_bool not_used __attribute__((unused)))\n{\n  *length= (uint) strlen((*buff)->field_name);\n  return (uchar*) (*buff)->field_name;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":41293,"func":"onig_get_passed_args_num_by_callout_args(OnigCalloutArgs* args)\n{\n  int num;\n  CalloutListEntry* e;\n\n  num = args->num;\n  e = onig_reg_callout_list_at(args->regex, num);\n  if (IS_NULL(e)) return ONIGERR_INVALID_ARGUMENT;\n  if (e->of == ONIG_CALLOUT_OF_NAME) {\n    return e->u.arg.passed_num;\n  }\n\n  return ONIGERR_INVALID_ARGUMENT;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":252439,"func":"void SavePackageNotificationObserver::Observe(\n    int type,\n    const content::NotificationSource& source,\n    const content::NotificationDetails& details) {\n  if (type == content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED) {\n    if (automation_) {\n      AutomationJSONReply(automation_,\n                          reply_message_.release()).SendSuccess(NULL);\n    }\n    delete this;\n  } else {\n    NOTREACHED();\n  }\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":246113,"func":" static int ReleaseVP9FrameBuffer(void *user_priv,\n vpx_codec_frame_buffer_t *fb) {\n ExternalFrameBufferMD5Test *const md5Test =\n reinterpret_cast<ExternalFrameBufferMD5Test*>(user_priv);\n return md5Test->fb_list_.ReturnFrameBuffer(fb);\n }\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":435771,"func":"static int gitmodules_cb(const char *var, const char *value, void *data)\n{\n\tstruct repository *repo = data;\n\treturn submodule_config_option(repo, var, value);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":62330,"func":"static bool blk_pm_allow_request(struct request *rq)\n{\n\treturn true;\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":458320,"func":"dp_packet_batch_is_full(const struct dp_packet_batch *batch)\n{\n    return dp_packet_batch_size(batch) == NETDEV_MAX_BURST;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":369774,"func":"static void qxl_del_memslot(PCIQXLDevice *d, uint32_t slot_id)\n{\n    dprint(d, 1, \"%s: slot %d\\n\", __FUNCTION__, slot_id);\n    qemu_spice_del_memslot(&d->ssd, MEMSLOT_GROUP_HOST, slot_id);\n    d->guest_slots[slot_id].active = 0;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":137083,"func":"evdns_base_free(struct evdns_base *base, int fail_requests)\n{\n\tEVDNS_LOCK(base);\n\tevdns_base_free_and_unlock(base, fail_requests);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":218980,"func":"bool WebMediaPlayerImpl::DidLoadingProgress() {\n  DCHECK(main_task_runner_->BelongsToCurrentThread());\n\n  const bool pipeline_progress = pipeline_controller_.DidLoadingProgress();\n  const bool data_progress = buffered_data_source_host_.DidLoadingProgress();\n  return pipeline_progress || data_progress;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":232655,"func":"AppListControllerDelegate::~AppListControllerDelegate() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":59035,"func":"static void adjust_subprog_starts(struct bpf_verifier_env *env, u32 off, u32 len)\n{\n\tint i;\n\n\tif (len == 1)\n\t\treturn;\n\t\/* NOTE: fake 'exit' subprog should be updated as well. *\/\n\tfor (i = 0; i <= env->subprog_cnt; i++) {\n\t\tif (env->subprog_info[i].start <= off)\n\t\t\tcontinue;\n\t\tenv->subprog_info[i].start += len - 1;\n\t}\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":61496,"func":"static int crypto_init_blkcipher_ops_sync(struct crypto_tfm *tfm)\n{\n\tstruct blkcipher_tfm *crt = &tfm->crt_blkcipher;\n\tstruct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;\n\tunsigned long align = crypto_tfm_alg_alignmask(tfm) + 1;\n\tunsigned long addr;\n\n\tcrt->setkey = setkey;\n\tcrt->encrypt = alg->encrypt;\n\tcrt->decrypt = alg->decrypt;\n\n\taddr = (unsigned long)crypto_tfm_ctx(tfm);\n\taddr = ALIGN(addr, align);\n\taddr += ALIGN(tfm->__crt_alg->cra_ctxsize, align);\n\tcrt->iv = (void *)addr;\n\n\treturn 0;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":38953,"func":"static void nfs4_proc_rename_setup(struct rpc_message *msg, struct inode *dir)\n{\n\tstruct nfs_server *server = NFS_SERVER(dir);\n\tstruct nfs_renameargs *arg = msg->rpc_argp;\n\tstruct nfs_renameres *res = msg->rpc_resp;\n\n\tmsg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME];\n\targ->bitmask = server->attr_bitmask;\n\tres->server = server;\n\tnfs41_init_sequence(&arg->seq_args, &res->seq_res, 1);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":10879,"func":"PHP_FUNCTION(snmp_set_enum_print)\n{\n\tlong a1;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &a1) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n \n        netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);\n        RETURN_TRUE;\n} \n","target":1,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":372270,"func":"cmsBool  CMSEXPORT cmsIsMatrixShaper(cmsHPROFILE hProfile)\n{\n    switch (cmsGetColorSpace(hProfile)) {\n\n    case cmsSigGrayData:\n\n        return cmsIsTag(hProfile, cmsSigGrayTRCTag);\n\n    case cmsSigRgbData:\n\n        return (cmsIsTag(hProfile, cmsSigRedColorantTag) &&\n                cmsIsTag(hProfile, cmsSigGreenColorantTag) &&\n                cmsIsTag(hProfile, cmsSigBlueColorantTag) &&\n                cmsIsTag(hProfile, cmsSigRedTRCTag) &&\n                cmsIsTag(hProfile, cmsSigGreenTRCTag) &&\n                cmsIsTag(hProfile, cmsSigBlueTRCTag));\n\n    default:\n\n        return FALSE;\n    }\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":185248,"func":"GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac,\n\t\t\t     SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) {\n  return SplashFont::getGlyph(c, xFrac, 0, bitmap, x0, y0, clip, clipRes);\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":212532,"func":"const ParsedFeaturePolicy Document::GetOwnerContainerPolicy() const {\n  if (frame_ && frame_->Owner())\n    return frame_->Owner()->ContainerPolicy();\n  return ParsedFeaturePolicy();\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":420258,"func":"destroyIoQ(void)\n{\n\tio_req_t *n;\n\tif (io_q.stats != NULL) {\n\t\tstatsobj.Destruct(&io_q.stats);\n\t}\n\tpthread_mutex_lock(&io_q.mut);\n\twhile (!STAILQ_EMPTY(&io_q.q)) {\n\t\tn = STAILQ_FIRST(&io_q.q);\n\t\tSTAILQ_REMOVE_HEAD(&io_q.q, link);\n\t\terrmsg.LogError(0, RS_RET_INTERNAL_ERROR, \"imptcp: discarded enqueued io-work to allow shutdown - ignored\");\n\t\tfree(n);\n\t}\n\tio_q.sz = 0;\n\tpthread_mutex_unlock(&io_q.mut);\n\tpthread_cond_destroy(&io_q.wakeup_worker);\n\tpthread_mutex_destroy(&io_q.mut);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":205126,"func":"bool ExtensionApiTest::RunExtensionTestWithArg(\n    const std::string& extension_name,\n    const char* custom_arg) {\n  return RunExtensionTestImpl(extension_name, std::string(), custom_arg,\n                               kFlagEnableFileAccess);\n }\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":267465,"func":"ALWAYS_INLINE void MulAdd(const Packet a, const bfloat16** binp, float** out) {\n  auto inp = reinterpret_cast<const float*>(*binp);\n  const auto b = LOAD(inp);\n  EXPAND_BFLOAT_L(b, b_0);\n  EXPAND_BFLOAT_U(b, b_1);\n  *binp += 2 * kNumOperands;\n  auto c1 = LOAD(*out);\n  auto c2 = LOAD(*out + kNumOperands);\n  FMA(a, b_0, c1, c1);\n  FMA(a, b_1, c2, c2);\n  STORE(*out, c1);\n  STORE(*out + kNumOperands, c2);\n  *out += 2 * kNumOperands;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":324659,"func":"int64_t bdrv_get_block_status_above(BlockDriverState *bs,\n\n                                    BlockDriverState *base,\n\n                                    int64_t sector_num,\n\n                                    int nb_sectors, int *pnum,\n\n                                    BlockDriverState **file)\n\n{\n\n    Coroutine *co;\n\n    BdrvCoGetBlockStatusData data = {\n\n        .bs = bs,\n\n        .base = base,\n\n        .file = file,\n\n        .sector_num = sector_num,\n\n        .nb_sectors = nb_sectors,\n\n        .pnum = pnum,\n\n        .done = false,\n\n    };\n\n\n\n    if (qemu_in_coroutine()) {\n\n        \/* Fast-path if already in coroutine context *\/\n\n        bdrv_get_block_status_above_co_entry(&data);\n\n    } else {\n\n        AioContext *aio_context = bdrv_get_aio_context(bs);\n\n\n\n        co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry,\n\n                                   &data);\n\n        qemu_coroutine_enter(co);\n\n        while (!data.done) {\n\n            aio_poll(aio_context, true);\n\n        }\n\n    }\n\n    return data.ret;\n\n}\n","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":477723,"func":"    }\n\n    \/\/! Load a list from a PAR\/REC (Philips) file \\newinstance.","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":283326,"func":"void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) {\n  if (!powered && discovery_session_.get()) {\n    StopDiscoverySession(std::move(discovery_session_));\n  }\n\n  if (chooser_.get()) {\n    chooser_->SetAdapterPresence(\n        powered ? BluetoothChooser::AdapterPresence::POWERED_ON\n                : BluetoothChooser::AdapterPresence::POWERED_OFF);\n    if (powered) {\n      OnBluetoothChooserEvent(BluetoothChooser::Event::RESCAN,\n                              \"\" \/* device_address *\/);\n    }\n  }\n\n  if (!powered) {\n    discovery_session_timer_.Stop();\n  }\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":198569,"func":"scoped_refptr<DataPipeConsumerDispatcher> DataPipeConsumerDispatcher::Create(\n    NodeController* node_controller,\n    const ports::PortRef& control_port,\n    base::UnsafeSharedMemoryRegion shared_ring_buffer,\n    const MojoCreateDataPipeOptions& options,\n    uint64_t pipe_id) {\n  scoped_refptr<DataPipeConsumerDispatcher> consumer =\n      new DataPipeConsumerDispatcher(node_controller, control_port,\n                                     std::move(shared_ring_buffer), options,\n                                     pipe_id);\n  base::AutoLock lock(consumer->lock_);\n  if (!consumer->InitializeNoLock())\n    return nullptr;\n  return consumer;\n}\n","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":232912,"func":"  const cc::TransformNode& GetTransformNode(const cc::Layer* layer) {\n    return *GetPropertyTrees().transform_tree.Node(\n        layer->transform_tree_index());\n  }\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":47752,"func":"void Database::setLocalMuted(const QString &hash, bool muted) {\n\tQSqlQuery query;\n\n\tif (muted)\n\t\tquery.prepare(QLatin1String(\"INSERT INTO `muted` (`hash`) VALUES (?)\"));\n\telse\n\t\tquery.prepare(QLatin1String(\"DELETE FROM `muted` WHERE `hash` = ?\"));\n\tquery.addBindValue(hash);\n\tquery.exec();\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":82618,"func":"void Magick::Image::strokeColor(const Magick::Color &strokeColor_)\n{\n  std::string\n    value;\n\n  modifyImage();\n  options()->strokeColor(strokeColor_);\n  value=strokeColor_;\n  artifact(\"stroke\",value);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":419773,"func":"static int get_source_for_fd(RemoteServer *s,\n                             int fd, char *name, RemoteSource **source) {\n        Writer *writer;\n        int r;\n\n        \/* This takes ownership of name, but only on success. *\/\n\n        assert(fd >= 0);\n        assert(source);\n\n        if (!GREEDY_REALLOC0(s->sources, s->sources_size, fd + 1))\n                return log_oom();\n\n        r = journal_remote_get_writer(s, name, &writer);\n        if (r < 0)\n                return log_warning_errno(r, \"Failed to get writer for source %s: %m\",\n                                         name);\n\n        if (s->sources[fd] == NULL) {\n                s->sources[fd] = source_new(fd, false, name, writer);\n                if (!s->sources[fd]) {\n                        writer_unref(writer);\n                        return log_oom();\n                }\n\n                s->active++;\n        }\n\n        *source = s->sources[fd];\n        return 0;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":394610,"func":"isofile_free(struct isofile *file)\n{\n\tstruct content *con, *tmp;\n\n\tcon = file->content.next;\n\twhile (con != NULL) {\n\t\ttmp = con;\n\t\tcon = con->next;\n\t\tfree(tmp);\n\t}\n\tarchive_entry_free(file->entry);\n\tarchive_string_free(&(file->parentdir));\n\tarchive_string_free(&(file->basename));\n\tarchive_string_free(&(file->basename_utf16));\n\tarchive_string_free(&(file->symlink));\n\tfree(file);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":360108,"func":"nautilus_file_compare_for_sort_internal (NautilusFile *file_1,\n\t\t\t\t\t NautilusFile *file_2,\n\t\t\t\t\t gboolean directories_first,\n\t\t\t\t\t gboolean reversed)\n{\n\tgboolean is_directory_1, is_directory_2;\n\n\tif (directories_first) {\n\t\tis_directory_1 = nautilus_file_is_directory (file_1);\n\t\tis_directory_2 = nautilus_file_is_directory (file_2);\n\n\t\tif (is_directory_1 && !is_directory_2) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (is_directory_2 && !is_directory_1) {\n\t\t\treturn +1;\n\t\t}\n\t}\n\n\tif (file_1->details->sort_order < file_2->details->sort_order) {\n\t\treturn reversed ? 1 : -1;\n\t} else if (file_1->details->sort_order > file_2->details->sort_order) {\n\t\treturn reversed ? -1 : 1;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":437436,"func":"static struct io_kiocb *io_get_fallback_req(struct io_ring_ctx *ctx)\n{\n\tstruct io_kiocb *req;\n\n\treq = ctx->fallback_req;\n\tif (!test_and_set_bit_lock(0, (unsigned long *) ctx->fallback_req))\n\t\treturn req;\n\n\treturn NULL;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":143438,"func":"static int bond_ioctl(struct net *net, unsigned int cmd,\n\t\t\t struct compat_ifreq __user *ifr32)\n{\n\tstruct ifreq kifr;\n\tmm_segment_t old_fs;\n\tint err;\n\n\tswitch (cmd) {\n\tcase SIOCBONDENSLAVE:\n\tcase SIOCBONDRELEASE:\n\tcase SIOCBONDSETHWADDR:\n\tcase SIOCBONDCHANGEACTIVE:\n\t\tif (copy_from_user(&kifr, ifr32, sizeof(struct compat_ifreq)))\n\t\t\treturn -EFAULT;\n\n\t\told_fs = get_fs();\n\t\tset_fs(KERNEL_DS);\n\t\terr = dev_ioctl(net, cmd,\n\t\t\t\t(struct ifreq __user __force *) &kifr);\n\t\tset_fs(old_fs);\n\n\t\treturn err;\n\tdefault:\n\t\treturn -ENOIOCTLCMD;\n\t}\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":143436,"func":"MagickExport ssize_t WriteBlobMSBLongLong(Image *image,\n  const MagickSizeType value)\n{\n  unsigned char\n    buffer[8];\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  buffer[0]=(unsigned char) (value >> 56);\n  buffer[1]=(unsigned char) (value >> 48);\n  buffer[2]=(unsigned char) (value >> 40);\n  buffer[3]=(unsigned char) (value >> 32);\n  buffer[4]=(unsigned char) (value >> 24);\n  buffer[5]=(unsigned char) (value >> 16);\n  buffer[6]=(unsigned char) (value >> 8);\n  buffer[7]=(unsigned char) value;\n  return(WriteBlobStream(image,8,buffer));\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":81542,"func":"QPDF::CopiedStreamDataProvider::provideStreamData(\n    int objid, int generation, Pipeline* pipeline)\n{\n    QPDFObjectHandle foreign_stream =\n        this->foreign_streams[QPDFObjGen(objid, generation)];\n    foreign_stream.pipeStreamData(pipeline, false, false, false);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":41785,"func":"trans_characters(\n    char_u\t*buf,\n    int\t\tbufsize)\n{\n    int\t\tlen;\t\t\/\/ length of string needing translation\n    int\t\troom;\t\t\/\/ room in buffer after string\n    char_u\t*trs;\t\t\/\/ translated character\n    int\t\ttrs_len;\t\/\/ length of trs[]\n\n    len = (int)STRLEN(buf);\n    room = bufsize - len;\n    while (*buf != 0)\n    {\n\t\/\/ Assume a multi-byte character doesn't need translation.\n\tif (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)\n\t    len -= trs_len;\n\telse\n\t{\n\t    trs = transchar_byte(*buf);\n\t    trs_len = (int)STRLEN(trs);\n\t    if (trs_len > 1)\n\t    {\n\t\troom -= trs_len - 1;\n\t\tif (room <= 0)\n\t\t    return;\n\t\tmch_memmove(buf + trs_len, buf + 1, (size_t)len);\n\t    }\n\t    mch_memmove(buf, trs, (size_t)trs_len);\n\t    --len;\n\t}\n\tbuf += trs_len;\n    }\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":451282,"func":"int DynamicMetadataMapWrapper::luaPairs(lua_State* state) {\n  if (iterator_.get() != nullptr) {\n    luaL_error(state, \"cannot create a second iterator before completing the first\");\n  }\n\n  iterator_.reset(DynamicMetadataMapIterator::create(state, *this), true);\n  lua_pushcclosure(state, DynamicMetadataMapIterator::static_luaPairsIterator, 1);\n  return 1;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":212755,"func":"static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)\n{\n    notImplemented();\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":370169,"func":"int sctp_outq_uncork(struct sctp_outq *q)\n{\n\tint error = 0;\n\tif (q->cork)\n\t\tq->cork = 0;\n\terror = sctp_outq_flush(q, 0);\n\treturn error;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":228270,"func":"static int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q)\n{\n\tr->p = p;\n\tr->q = q;\n\n\treturn 1;\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":438635,"func":"execlists_context_status_change(struct i915_request *rq, unsigned long status)\n{\n\t\/*\n\t * Only used when GVT-g is enabled now. When GVT-g is disabled,\n\t * The compiler should eliminate this function as dead-code.\n\t *\/\n\tif (!IS_ENABLED(CONFIG_DRM_I915_GVT))\n\t\treturn;\n\n\tatomic_notifier_call_chain(&rq->engine->context_status_notifier,\n\t\t\t\t   status, rq);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":514701,"func":"int llhttp__internal__c_update_type_1(\n    llhttp__internal_t* state,\n    const unsigned char* p,\n    const unsigned char* endp) {\n  state->type = 2;\n  return 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":35584,"func":"static int vhost_update_used_flags(struct vhost_virtqueue *vq)\n{\n\tvoid __user *used;\n\tif (__put_user(cpu_to_vhost16(vq, vq->used_flags), &vq->used->flags) < 0)\n\t\treturn -EFAULT;\n\tif (unlikely(vq->log_used)) {\n\t\t\/* Make sure the flag is seen before log. *\/\n\t\tsmp_wmb();\n\t\t\/* Log used flag write. *\/\n\t\tused = &vq->used->flags;\n\t\tlog_write(vq->log_base, vq->log_addr +\n\t\t\t  (used - (void __user *)vq->used),\n\t\t\t  sizeof vq->used->flags);\n\t\tif (vq->log_ctx)\n\t\t\teventfd_signal(vq->log_ctx, 1);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":283926,"func":"  int Width() const { return size_.width; }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":75230,"func":"ngx_http_auth_spnego_init(\n        ngx_conf_t * cf)\n{\n    ngx_http_handler_pt *h;\n    ngx_http_core_main_conf_t *cmcf;\n\n    cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);\n\n    h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);\n    if (NULL == h) {\n        return NGX_ERROR;\n    }\n\n    *h = ngx_http_auth_spnego_handler;\n\n    return NGX_OK;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":217296,"func":"  PPAPIFileChooserTestWithSBService()\n      : safe_browsing_service_factory_(&safe_browsing_test_configuration_) {}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":481897,"func":"static void clear_atexit(void) {\n\tEUID_ROOT();\n\tdelete_run_files(getpid());\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":515154,"func":"static double invflip_angle(double angle, int rankdir)\n{\n    switch (rankdir) {\n    case RANKDIR_TB:\n\tbreak;\n    case RANKDIR_BT:\n\tangle *= -1;\n\tbreak;\n    case RANKDIR_LR:\n\tangle -= M_PI * 0.5;\n\tbreak;\n    case RANKDIR_RL:\n\tif (angle == M_PI)\n\t    angle = -0.5 * M_PI;\n\telse if (angle == M_PI * 0.75)\n\t    angle = -0.25 * M_PI;\n\telse if (angle == M_PI * 0.5)\n\t    angle = 0;\n\/* clang complains about self assignment of double\n\telse if (angle == M_PI * 0.25)\n\t    angle = angle;\n *\/\n\telse if (angle == 0)\n\t    angle = M_PI * 0.5;\n\telse if (angle == M_PI * -0.25)\n\t    angle = M_PI * 0.75;\n\telse if (angle == M_PI * -0.5)\n\t    angle = M_PI;\n\/* clang complains about self assignment of double\n\telse if (angle == M_PI * -0.75)\n\t    angle = angle;\n *\/\n\tbreak;\n    }\n    return angle;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":26724,"func":"static VALUE mFixnum_to_json ( int argc , VALUE * argv , VALUE self ) {\n GENERATE_JSON ( fixnum ) ;\n }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":102764,"func":"  explicit CopyOp(OpKernelConstruction* ctx) : CopyOpBase(ctx) {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":317717,"func":"void GDataFileSystem::RenameAfterGetEntryInfo(\n    const FilePath& file_path,\n    const FilePath::StringType& new_name,\n    const FileMoveCallback& callback,\n    GDataFileError error,\n    scoped_ptr<GDataEntryProto> entry_proto) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n\n  if (error != GDATA_FILE_OK) {\n    if (!callback.is_null())\n      callback.Run(error, file_path);\n    return;\n  }\n  DCHECK(entry_proto.get());\n\n  FilePath::StringType file_name = new_name;\n  if (entry_proto->has_file_specific_info() &&\n      entry_proto->file_specific_info().is_hosted_document()) {\n    FilePath new_file(file_name);\n    if (new_file.Extension() ==\n        entry_proto->file_specific_info().document_extension()) {\n      file_name = new_file.RemoveExtension().value();\n    }\n  }\n\n  documents_service_->RenameResource(\n      GURL(entry_proto->edit_url()),\n      file_name,\n      base::Bind(&GDataFileSystem::RenameFileOnFileSystem,\n                 ui_weak_ptr_,\n                 file_path,\n                 file_name,\n                 callback));\n}\n","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":104317,"func":"static bool atl2_write_eeprom(struct atl2_hw *hw, u32 offset, u32 value)\n{\n\treturn true;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":302832,"func":"static void circ_read(circ_buf_t *cb, pj_uint8_t *dst, pj_size_t len)\n{\n    pj_size_t size_after = cb->cap - cb->readp;\n    pj_size_t tbc = PJ_MIN(size_after, len);\n    pj_size_t rem = len - tbc;\n\n    pj_memcpy(dst, cb->buf + cb->readp, tbc);\n    pj_memcpy(dst + tbc, cb->buf, rem);\n\n    cb->readp += len;\n    cb->readp &= (cb->cap - 1);\n\n    cb->size -= len;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":335249,"func":"struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,\n\n                                                 target_ulong pc)\n\n{\n\n    struct kvm_sw_breakpoint *bp;\n\n\n\n    TAILQ_FOREACH(bp, &env->kvm_state->kvm_sw_breakpoints, entry) {\n\n        if (bp->pc == pc)\n\n            return bp;\n\n    }\n\n    return NULL;\n\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":70786,"func":"latin_char2cells(int c UNUSED)\n{\n    return 1;\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":422285,"func":"e_ews_connection_get_uri (EEwsConnection *cnc)\n{\n\tg_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), NULL);\n\n\treturn cnc->priv->uri;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":211777,"func":"v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(const char* functionName, int argc, v8::Local<v8::Value> argv[])\n{\n    v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);\n    v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);\n    v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScript->Get(toV8StringInternalized(m_isolate, functionName)));\n    DCHECK(m_isolate->InContext());\n    return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc, argv);\n}\n","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":333233,"func":"static av_noinline void emulated_edge_mc_mmxext(uint8_t *buf, const uint8_t *src,\n\n                                                ptrdiff_t buf_stride,\n\n                                                ptrdiff_t src_stride,\n\n                                                int block_w, int block_h,\n\n                                                int src_x, int src_y, int w, int h)\n\n{\n\n    emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h,\n\n                     src_x, src_y, w, h, vfixtbl_mmx, &ff_emu_edge_vvar_mmx,\n\n                     hfixtbl_mmxext, &ff_emu_edge_hvar_mmxext);\n\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":411880,"func":"static ogg_uint32_t bitreverse(ogg_uint32_t x){\n  x=    ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000);\n  x=    ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00);\n  x=    ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0);\n  x=    ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc);\n  return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":307979,"func":"fep_client_set_status_text (FepClient    *client,\n                            const char   *text,\n                            FepAttribute *attr)\n{\n  FepControlMessage message;\n\n  message.command = FEP_CONTROL_SET_STATUS_TEXT;\n  _fep_control_message_alloc_args (&message, 2);\n  _fep_control_message_write_string_arg (&message, 0, text, strlen (text) + 1);\n  _fep_control_message_write_attribute_arg (&message, 1, attr ? attr : &empty_attr);\n\n  if (client->filter_running)\n    client->messages = _fep_append_control_message (client->messages, &message);\n  else\n    _fep_write_control_message (client->control, &message);\n  _fep_control_message_free_args (&message);\n}\n","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":519417,"func":"  int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":304123,"func":"static void fmt_bytecount(AVIOContext *pb, int64_t count)\n{\n    static const char suffix[] = \" kMGTP\";\n    const char *s;\n\n    for (s = suffix; count >= 100000 && s[1]; count \/= 1000, s++);\n\n    avio_printf(pb, \"%\"PRId64\"%c\", count, *s);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":202580,"func":"base::string16 AuthenticatorClientPinTapAgainSheetModel::GetStepDescription()\n    const {\n  return l10n_util::GetStringUTF16(IDS_WEBAUTHN_PIN_TAP_AGAIN_DESCRIPTION);\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":473973,"func":"create_work_q(void)\n{\n    struct Slapi_work_q *work_q = (struct Slapi_work_q *)PR_StackPop(work_q_stack);\n    if (!work_q) {\n        work_q = (struct Slapi_work_q *)slapi_ch_malloc(sizeof(struct Slapi_work_q));\n    } else {\n        PR_AtomicDecrement(&work_q_stack_size);\n    }\n    return work_q;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":192976,"func":"void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() {\n  if (frame_subscriber() && CanCopyToVideoFrame()) {\n    const base::TimeTicks present_time = base::TimeTicks::Now();\n    scoped_refptr<media::VideoFrame> frame;\n    RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;\n    if (frame_subscriber()->ShouldCaptureFrame(present_time,\n                                               &frame, &callback)) {\n      CopyFromCompositingSurfaceToVideoFrame(\n          gfx::Rect(current_frame_size_),\n          frame,\n          base::Bind(callback, present_time));\n    }\n  }\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":387649,"func":"xz_skip(xz_statep state, uint64_t len)\n{\n    unsigned n;\n\n    \/* skip over len bytes or reach end-of-file, whichever comes first *\/\n    while (len)\n        \/* skip over whatever is in output buffer *\/\n        if (state->have) {\n            n = (uint64_t) state->have > len ?\n                (unsigned) len : state->have;\n            state->have -= n;\n            state->next += n;\n            state->pos += n;\n            len -= n;\n        }\n\n    \/* output buffer empty -- return if we're at the end of the input *\/\n        else if (state->eof && state->strm.avail_in == 0)\n            break;\n\n    \/* need more data to skip -- load up output buffer *\/\n        else {\n            \/* get more output, looking for header if required *\/\n            if (xz_make(state) == -1)\n                return -1;\n        }\n    return 0;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":181886,"func":"void AuthenticatorSheetModelBase::OnAccept() {\n  NOTREACHED();\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":251654,"func":"static WebHistoryCommitType LoadTypeToCommitType(WebFrameLoadType type) {\n  switch (type) {\n    case WebFrameLoadType::kStandard:\n      return kWebStandardCommit;\n    case WebFrameLoadType::kBackForward:\n      return kWebBackForwardCommit;\n    case WebFrameLoadType::kReload:\n    case WebFrameLoadType::kReplaceCurrentItem:\n    case WebFrameLoadType::kReloadBypassingCache:\n      return kWebHistoryInertCommit;\n  }\n  NOTREACHED();\n  return kWebHistoryInertCommit;\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":203153,"func":"void WebRuntimeFeatures::EnableOrientationEvent(bool enable) {\n  RuntimeEnabledFeatures::SetOrientationEventEnabled(enable);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":108010,"func":"struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)\n{\n\tstruct dentry *p;\n\n\tif (p1 == p2) {\n\t\tinode_lock_nested(p1->d_inode, I_MUTEX_PARENT);\n\t\treturn NULL;\n\t}\n\n\tmutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex);\n\n\tp = d_ancestor(p2, p1);\n\tif (p) {\n\t\tinode_lock_nested(p2->d_inode, I_MUTEX_PARENT);\n\t\tinode_lock_nested(p1->d_inode, I_MUTEX_CHILD);\n\t\treturn p;\n\t}\n\n\tp = d_ancestor(p1, p2);\n\tif (p) {\n\t\tinode_lock_nested(p1->d_inode, I_MUTEX_PARENT);\n\t\tinode_lock_nested(p2->d_inode, I_MUTEX_CHILD);\n\t\treturn p;\n\t}\n\n\tinode_lock_nested(p1->d_inode, I_MUTEX_PARENT);\n\tinode_lock_nested(p2->d_inode, I_MUTEX_PARENT2);\n\treturn NULL;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":241526,"func":"Element* Document::elementFromPoint(int x, int y) const\n{\n    if (!renderer())\n        return 0;\n\n    return TreeScope::elementFromPoint(x, y);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":241616,"func":"static void get_keyword(struct token *t)\n{\n\tint i;\n\n\tfor (i = 0; keywords[i].val; i++) {\n\t\tif (!strcmp(t->val, keywords[i].val)) {\n\t\t\tt->type = keywords[i].type;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":225057,"func":"void VideoRendererBase::Flush(const base::Closure& callback) {\n  base::AutoLock auto_lock(lock_);\n  DCHECK_EQ(state_, kPaused);\n  flush_cb_ = callback;\n  state_ = kFlushingDecoder;\n\n  base::AutoUnlock auto_unlock(lock_);\n  decoder_->Reset(base::Bind(&VideoRendererBase::OnDecoderFlushDone, this));\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":122259,"func":"void Magick::Image::clutChannel(const ChannelType channel_,\n  const Image &clutImage_,const PixelInterpolateMethod method)\n{\n  modifyImage();\n  GetPPException;\n  GetAndSetPPChannelMask(channel_);\n  ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);\n  RestorePPChannelMask;\n  ThrowImageException;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":517160,"func":"  bool check_vcol_func_processor(void *arg) { return FALSE;}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":70329,"func":"QPDFObjectHandle::getStreamData(qpdf_stream_decode_level_e level)\n{\n    assertStream();\n    return dynamic_cast<QPDF_Stream*>(\n        m->obj.getPointer())->getStreamData(level);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":182607,"func":"  IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) {\n    base::FilePath profile_path =\n        PepperFlashFileMessageFilter::GetDataDirName(browser_context_path_);\n#if defined(OS_WIN)\n    base::FilePath plugin_data_path =\n        profile_path.Append(base::FilePath(base::UTF8ToUTF16(plugin_name_)));\n#else\n    base::FilePath plugin_data_path =\n        profile_path.Append(base::FilePath(plugin_name_));\n#endif  \/\/ defined(OS_WIN)\n    return new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(),\n                                      kClearAllData, max_age);\n  }\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":210368,"func":"void ewk_frame_load_provisional(Evas_Object* ewkFrame)\n{\n    evas_object_smart_callback_call(ewkFrame, \"load,provisional\", 0);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":400179,"func":"dirserv_set_node_flags_from_authoritative_status(node_t *node,\n                                                 uint32_t authstatus)\n{\n  node->is_valid = (authstatus & FP_INVALID) ? 0 : 1;\n  node->is_bad_exit = (authstatus & FP_BADEXIT) ? 1 : 0;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":62405,"func":"static int disas_cp_insn(CPUState *env, DisasContext *s, uint32_t insn)\n\n{\n\n    TCGv tmp, tmp2;\n\n    uint32_t rd = (insn >> 12) & 0xf;\n\n    uint32_t cp = (insn >> 8) & 0xf;\n\n    if (IS_USER(s)) {\n\n        return 1;\n\n    }\n\n\n\n    if (insn & ARM_CP_RW_BIT) {\n\n        if (!env->cp[cp].cp_read)\n\n            return 1;\n\n        gen_set_pc_im(s->pc);\n\n        tmp = new_tmp();\n\n        tmp2 = tcg_const_i32(insn);\n\n        gen_helper_get_cp(tmp, cpu_env, tmp2);\n\n        tcg_temp_free(tmp2);\n\n        store_reg(s, rd, tmp);\n\n    } else {\n\n        if (!env->cp[cp].cp_write)\n\n            return 1;\n\n        gen_set_pc_im(s->pc);\n\n        tmp = load_reg(s, rd);\n\n        tmp2 = tcg_const_i32(insn);\n\n        gen_helper_set_cp(cpu_env, tmp2, tmp);\n\n        tcg_temp_free(tmp2);\n\n        dead_tmp(tmp);\n\n    }\n\n    return 0;\n\n}\n","target":1,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":117246,"func":"static inline void control_tx_modulation_enable(struct cx23885_dev *dev,\n\t\t\t\t\t\tbool enable)\n{\n\tcx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~CNTRL_MOD,\n\t\t\t   enable ? CNTRL_MOD : 0);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":311807,"func":"validGlxFBConfigForWindow(ClientPtr client, __GLXconfig *config,\n\t\t\t  DrawablePtr pDraw, int *err)\n{\n    ScreenPtr pScreen = pDraw->pScreen;\n    VisualPtr pVisual = NULL;\n    XID vid;\n    int i;\n\n    vid = wVisual((WindowPtr)pDraw);\n    for (i = 0; i < pScreen->numVisuals; i++) {\n\tif (pScreen->visuals[i].vid == vid) {\n\t    pVisual = &pScreen->visuals[i];\n\t    break;\n\t}\n    }\n\n    \/* FIXME: What exactly should we check here... *\/\n    if (pVisual->class != glxConvertToXVisualType(config->visualType) ||\n\t!(config->drawableType & GLX_WINDOW_BIT)) {\n\tclient->errorValue = pDraw->id;\n\t*err = BadMatch;\n\treturn FALSE;\n    }\n\n    return TRUE;\n}\n","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":165376,"func":"sp<SoundTriggerHwService::Model> SoundTriggerHwService::Module::getModel(\n sound_model_handle_t handle)\n{\n    sp<Model> model;\n ssize_t index = mModels.indexOfKey(handle);\n if (index >= 0) {\n        model = mModels.valueAt(index);\n }\n return model;\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":85308,"func":"static\nvoid php_mysqlnd_cmd_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)\n{\n\tif (!stack_allocation) {\n\t\tMYSQLND_PACKET_COMMAND * p = (MYSQLND_PACKET_COMMAND *) _packet;\n\t\tmnd_pefree(p, p->header.persistent);\n\t}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":306325,"func":"    Command(vector<string>& c, ceph_tid_t t, bufferlist& bl, Connection *co)\n      : cmd(c), tid(t), indata(bl), con(co) {}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":134313,"func":"static void error(const char *format,...)\n{\n  va_list args;\n  va_start(args, format);\n  error_or_warning(format, args, \"ERROR\");\n  va_end(args);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":234297,"func":"parse_pop_vlan(struct ofpbuf *ofpacts)\n{\n    ofpact_put_STRIP_VLAN(ofpacts)->ofpact.raw = OFPAT_RAW11_POP_VLAN;\n    return NULL;\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":485749,"func":"static long snd_pcm_oss_ioctl_compat(struct file *file, unsigned int cmd,\n\t\t\t\t     unsigned long arg)\n{\n\t\/*\n\t * Everything is compatbile except SNDCTL_DSP_MAPINBUF\/SNDCTL_DSP_MAPOUTBUF,\n\t * which are not implemented for the native case either\n\t *\/\n\treturn snd_pcm_oss_ioctl(file, cmd, (unsigned long)compat_ptr(arg));\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":383105,"func":"cache_disabled_value (PKT_public_key *pk)\n{\n#ifdef NO_TRUST_MODELS\n  (void)pk;\n  return 0;\n#else\n  return tdb_cache_disabled_value (pk);\n#endif\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":336435,"func":"hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)\n\n{\n\n    S390CPU *cpu = S390_CPU(cs);\n\n    CPUS390XState *env = &cpu->env;\n\n    target_ulong raddr;\n\n    int prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;\n\n    int old_exc = cs->exception_index;\n\n    uint64_t asc = env->psw.mask & PSW_MASK_ASC;\n\n\n\n    \/* 31-Bit mode *\/\n\n    if (!(env->psw.mask & PSW_MASK_64)) {\n\n        vaddr &= 0x7fffffff;\n\n    }\n\n\n\n    mmu_translate(env, vaddr, 2, asc, &raddr, &prot);\n\n    cs->exception_index = old_exc;\n\n\n\n    return raddr;\n\n}\n","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":12499,"func":"void CameraSource::signalBufferReturned(MediaBuffer *buffer) {\n    ALOGV(\"signalBufferReturned: %p\", buffer->data());\n Mutex::Autolock autoLock(mLock);\n\n     for (List<sp<IMemory> >::iterator it = mFramesBeingEncoded.begin();\n          it != mFramesBeingEncoded.end(); ++it) {\n         if ((*it)->pointer() ==  buffer->data()) {\n             releaseOneRecordingFrame((*it));\n             mFramesBeingEncoded.erase(it);\n             ++mNumFramesEncoded;\n            buffer->setObserver(0);\n            buffer->release();\n            mFrameCompleteCondition.signal();\n return;\n }\n }\n    CHECK(!\"signalBufferReturned: bogus buffer\");\n}\n","target":1,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":502512,"func":"static NTSTATUS pdb_samba_dsdb_lookup_names(struct pdb_methods *m,\n\t\t\t\t     const struct dom_sid *domain_sid,\n\t\t\t\t     int num_names,\n\t\t\t\t     const char **pp_names,\n\t\t\t\t     uint32_t *rids,\n\t\t\t\t     enum lsa_SidType *attrs)\n{\n\treturn NT_STATUS_NOT_IMPLEMENTED;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":270639,"func":"static void r_coresym_cache_element_line_info_fini(RCoreSymCacheElementLineInfo *line) {\n\tif (line) {\n\t\tr_coresym_cache_element_flc_fini (&line->flc);\n\t}\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":377992,"func":"static void dn_dev_timer_func(unsigned long arg)\n{\n\tstruct net_device *dev = (struct net_device *)arg;\n\tstruct dn_dev *dn_db;\n\tstruct dn_ifaddr *ifa;\n\n\trcu_read_lock();\n\tdn_db = rcu_dereference(dev->dn_ptr);\n\tif (dn_db->t3 <= dn_db->parms.t2) {\n\t\tif (dn_db->parms.timer3) {\n\t\t\tfor (ifa = rcu_dereference(dn_db->ifa_list);\n\t\t\t     ifa;\n\t\t\t     ifa = rcu_dereference(ifa->ifa_next)) {\n\t\t\t\tif (!(ifa->ifa_flags & IFA_F_SECONDARY))\n\t\t\t\t\tdn_db->parms.timer3(dev, ifa);\n\t\t\t}\n\t\t}\n\t\tdn_db->t3 = dn_db->parms.t3;\n\t} else {\n\t\tdn_db->t3 -= dn_db->parms.t2;\n\t}\n\trcu_read_unlock();\n\tdn_dev_set_timer(dev);\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":467982,"func":"static int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n{\n\tstruct io_sr_msg *sr = &req->sr_msg;\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\n\tsr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\tsr->len = READ_ONCE(sqe->len);\n\tsr->bgid = READ_ONCE(sqe->buf_group);\n\tsr->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;\n\tif (sr->msg_flags & MSG_DONTWAIT)\n\t\treq->flags |= REQ_F_NOWAIT;\n\n#ifdef CONFIG_COMPAT\n\tif (req->ctx->compat)\n\t\tsr->msg_flags |= MSG_CMSG_COMPAT;\n#endif\n\treturn 0;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":297290,"func":"static int ion_handle_put_nolock(struct ion_handle *handle)\n{\n\tint ret;\n\n\tret = kref_put(&handle->ref, ion_handle_destroy);\n\n\treturn ret;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":457241,"func":"proxy_free (Proxy *py, unsigned finalize)\n{\n\tif (py) {\n\t\tif (finalize)\n\t\t\tp11_kit_modules_finalize (py->inited);\n\t\tfree (py->inited);\n\t\tp11_dict_free (py->sessions);\n\t\tfree (py->mappings);\n\t\tfree (py);\n\t}\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":266111,"func":"void jslSeekTo(size_t seekToChar) {\n  if (lex->it.var) jsvLockAgain(lex->it.var); \/\/ see jslGetNextCh\n  jsvStringIteratorFree(&lex->it);\n  jsvStringIteratorNew(&lex->it, lex->sourceVar, seekToChar);\n  jsvUnLock(lex->it.var); \/\/ see jslGetNextCh\n  lex->tokenStart.it.var = 0;\n  lex->tokenStart.currCh = 0;\n  jslPreload();\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":130842,"func":"static inline ssize_t WriteBlobStream(Image *image,const size_t length,\n  const unsigned char *data)\n{\n  BlobInfo\n    *magick_restrict blob_info;\n\n  MagickSizeType\n    extent;\n\n  register unsigned char\n    *q;\n\n  assert(image->blob != (BlobInfo *) NULL);\n  assert(image->blob->type != UndefinedStream);\n  assert(data != (void *) NULL);\n  blob_info=image->blob;\n  if (blob_info->type != BlobStream)\n    return(WriteBlob(image,length,data));\n  extent=(MagickSizeType) (blob_info->offset+(MagickOffsetType) length);\n  if (extent >= blob_info->extent)\n    {\n      extent=blob_info->extent+blob_info->quantum+length;\n      blob_info->quantum<<=1;\n      if (SetBlobExtent(image,extent) == MagickFalse)\n        return(0);\n    }\n  q=blob_info->data+blob_info->offset;\n  (void) memcpy(q,data,length);\n  blob_info->offset+=length;\n  if (blob_info->offset >= (MagickOffsetType) blob_info->length)\n    blob_info->length=(size_t) blob_info->offset;\n  return((ssize_t) length);\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":449048,"func":"SRC_ActiveSources(void)\n{\n  int i, r;\n\n  for (i = r = 0; i < n_sources; i++)\n    if (sources[i]->active)\n      r++;\n\n  return r;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":494507,"func":"static const struct content_encoding *find_encoding(const char *name,\n                                                    size_t len)\n{\n  const struct content_encoding * const *cep;\n\n  for(cep = encodings; *cep; cep++) {\n    const struct content_encoding *ce = *cep;\n    if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||\n       (ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))\n      return ce;\n  }\n  return NULL;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":403097,"func":"TORRENT_TEST(dict_nonstring_key)\n{\n\tchar b[] = \"di5e1:ae\";\n\tbdecode_node e;\n\terror_code ec;\n\tint pos;\n\tint ret = bdecode(b, b + sizeof(b)-1, e, ec, &pos);\n\tTEST_EQUAL(ret, -1);\n\tTEST_EQUAL(pos, 1);\n\tTEST_EQUAL(ec, error_code(bdecode_errors::expected_digit));\n\tprintf(\"%s\\n\", print_entry(e).c_str());\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":175203,"func":"error::Error GLES2DecoderPassthroughImpl::DoUseProgram(GLuint program) {\n  api()->glUseProgramFn(GetProgramServiceID(program, resources_));\n  return error::kNoError;\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":19960,"func":"GSList * mainwindows_get_line ( MAIN_WINDOW_REC * rec ) {\n MAIN_WINDOW_REC * win ;\n GSList * list ;\n list = NULL ;\n for ( win = mainwindows_find_left ( rec , FALSE ) ;\n win != NULL ;\n win = mainwindows_find_left ( win , FALSE ) ) {\n list = g_slist_append ( list , win ) ;\n }\n if ( rec != NULL ) list = g_slist_append ( list , rec ) ;\n for ( win = mainwindows_find_right ( rec , FALSE ) ;\n win != NULL ;\n win = mainwindows_find_right ( win , FALSE ) ) {\n list = g_slist_append ( list , win ) ;\n }\n return list ;\n }","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":310716,"func":"PointInBorderSize(WindowPtr pWin, int x, int y)\n{\n    BoxRec box;\n\n    if (RegionContainsPoint(&pWin->borderSize, x, y, &box))\n        return TRUE;\n\n#ifdef PANORAMIX\n    if (!noPanoramiXExtension &&\n        XineramaSetWindowPntrs(inputInfo.pointer, pWin)) {\n        SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite;\n        int i;\n\n        FOR_NSCREENS_FORWARD_SKIP(i) {\n            if (RegionContainsPoint(&pSprite->windows[i]->borderSize,\n                                    x + screenInfo.screens[0]->x -\n                                    screenInfo.screens[i]->x,\n                                    y + screenInfo.screens[0]->y -\n                                    screenInfo.screens[i]->y, &box))\n                return TRUE;\n        }\n    }\n#endif\n    return FALSE;\n}\n","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":151962,"func":"int CLASS nikon_is_compressed()\n{\n  uchar test[256];\n  int i;\n\n  fseek (ifp, data_offset, SEEK_SET);\n  fread (test, 1, 256, ifp);\n  for (i=15; i < 256; i+=16)\n    if (test[i]) return 1;\n  return 0;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":339693,"func":"static BlockJob *find_block_job(const char *device, AioContext **aio_context,\n\n                                Error **errp)\n\n{\n\n    BlockBackend *blk;\n\n    BlockDriverState *bs;\n\n\n\n    *aio_context = NULL;\n\n\n\n    blk = blk_by_name(device);\n\n    if (!blk) {\n\n        goto notfound;\n\n    }\n\n\n\n    *aio_context = blk_get_aio_context(blk);\n\n    aio_context_acquire(*aio_context);\n\n\n\n    if (!blk_is_available(blk)) {\n\n        goto notfound;\n\n    }\n\n    bs = blk_bs(blk);\n\n\n\n    if (!bs->job) {\n\n        goto notfound;\n\n    }\n\n\n\n    return bs->job;\n\n\n\nnotfound:\n\n    error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE,\n\n              \"No active block job on device '%s'\", device);\n\n    if (*aio_context) {\n\n        aio_context_release(*aio_context);\n\n        *aio_context = NULL;\n\n    }\n\n    return NULL;\n\n}\n","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":314927,"func":"static int get_valid_interface(struct libusb_device_handle *dev_handle, int api_id)\n{\n\tstruct windows_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);\n \tstruct windows_device_priv *priv = _device_priv(dev_handle->dev);\n \tint i;\n \n\tif ((api_id < USB_API_WINUSBX) || (api_id >= USB_API_MAX)) {\n \t\tusbi_dbg(\"unsupported API ID\");\n \t\treturn -1;\n \t}\n\n\tfor (i=0; i<USB_MAXINTERFACES; i++) {\n\t\tif ( (handle_priv->interface_handle[i].dev_handle != 0)\n\t\t  && (handle_priv->interface_handle[i].dev_handle != INVALID_HANDLE_VALUE)\n\t\t  && (handle_priv->interface_handle[i].api_handle != 0)\n\t\t  && (handle_priv->interface_handle[i].api_handle != INVALID_HANDLE_VALUE)\n\t\t  && (priv->usb_interface[i].apib->id == api_id) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":512098,"func":"get_random_number ()\n{\n  int rv, pid;\n\n  \/* Reset for command and process substitution. *\/\n  pid = getpid ();\n  if (subshell_environment && seeded_subshell != pid)\n    {\n      seedrand ();\n      seeded_subshell = pid;\n    }\n\n  do\n    rv = brand ();\n  while (rv == last_random_value);\n  return rv;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":152123,"func":"dse_callback_new(int operation,\n                 int flags,\n                 const Slapi_DN *base,\n                 int scope,\n                 const char *filter,\n                 dseCallbackFn fn,\n                 void *fn_arg,\n                 struct slapdplugin *plugin)\n{\n    struct dse_callback *p = NULL;\n    p = (struct dse_callback *)slapi_ch_calloc(1, sizeof(struct dse_callback));\n    if (p != NULL) {\n        p->operation = operation;\n        p->flags = flags;\n        p->base = slapi_sdn_dup(base);\n        p->scope = scope;\n        if (NULL == filter) {\n            p->filter = NULL;\n            p->slapifilter = NULL;\n        } else {\n            p->filter = slapi_ch_strdup(filter);\n            p->slapifilter = slapi_str2filter(p->filter);\n            filter_normalize(p->slapifilter);\n        }\n        p->fn = fn;\n        p->fn_arg = fn_arg;\n        p->plugin = plugin;\n        p->next = NULL;\n    }\n    return p;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":420153,"func":"int sk_wait_data(struct sock *sk, long *timeo, const struct sk_buff *skb)\n{\n\tDEFINE_WAIT_FUNC(wait, woken_wake_function);\n\tint rc;\n\n\tadd_wait_queue(sk_sleep(sk), &wait);\n\tsk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);\n\trc = sk_wait_event(sk, timeo, skb_peek_tail(&sk->sk_receive_queue) != skb, &wait);\n\tsk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);\n\tremove_wait_queue(sk_sleep(sk), &wait);\n\treturn rc;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":173176,"func":"bool ShouldSendPinchGesture() {\n  static bool pinch_allowed =\n      CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) ||\n      CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch);\n  return pinch_allowed;\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":132004,"func":"PJ_DEF(pj_status_t)  pj_stun_msg_add_uint64_attr(pj_pool_t *pool,\n\t\t\t\t\t         pj_stun_msg *msg,\n\t\t\t\t\t         int attr_type,\n\t\t\t\t\t         const pj_timestamp *value)\n{\n    pj_stun_uint64_attr *attr = NULL;\n    pj_status_t status;\n\n    status = pj_stun_uint64_attr_create(pool, attr_type, value, &attr);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    return pj_stun_msg_add_attr(msg, &attr->hdr);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":269351,"func":"client_message_generates_reply (Header *header)\n{\n  switch (header->type)\n    {\n    case G_DBUS_MESSAGE_TYPE_METHOD_CALL:\n      return (header->flags & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED) == 0;\n\n    case G_DBUS_MESSAGE_TYPE_SIGNAL:\n    case G_DBUS_MESSAGE_TYPE_METHOD_RETURN:\n    case G_DBUS_MESSAGE_TYPE_ERROR:\n    default:\n      return FALSE;\n    }\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":133194,"func":"    yaffscache_objects_free(YAFFSFS_INFO *yfs)\n{\n    if((yfs != NULL) && (yfs->cache_objects != NULL)){\n        YaffsCacheObject *obj = yfs->cache_objects;\n        while(obj != NULL) {\n            YaffsCacheObject *to_free = obj;\n\n            YaffsCacheVersion *ver = obj->yco_latest;\n            while(ver != NULL) {\n                YaffsCacheVersion *v_to_free = ver;\n                ver = ver->ycv_prior;\n                free(v_to_free);\n            }\n\n            obj = obj->yco_next;\n            free(to_free);\n        }\n    }\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":55480,"func":"int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)\n{\n   float **outputs;\n   int len = num_shorts \/ channels;\n   int n=0;\n   int z = f->channels;\n   if (z > channels) z = channels;\n   while (n < len) {\n      int k = f->channel_buffer_end - f->channel_buffer_start;\n      if (n+k >= len) k = len - n;\n      if (k)\n         convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k);\n      buffer += k*channels;\n      n += k;\n      f->channel_buffer_start += k;\n      if (n == len) break;\n      if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;\n   }\n   return n;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":445435,"func":"TEST_P(DnsImplZeroTimeoutTest, Timeout) {\n  server_->addHosts(\"some.good.domain\", {\"201.134.56.7\"}, RecordType::A);\n\n  EXPECT_NE(nullptr,\n            resolveWithExpectations(\"some.good.domain\", DnsLookupFamily::V4Only,\n                                    DnsResolver::ResolutionStatus::Failure, {}, {}, absl::nullopt));\n  dispatcher_->run(Event::Dispatcher::RunType::Block);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":362923,"func":"static inline void sk_refcnt_debug_release(const struct sock *sk)\n{\n\tif (atomic_read(&sk->sk_refcnt) != 1)\n\t\tprintk(KERN_DEBUG \"Destruction of the %s socket %p delayed, refcnt=%d\\n\",\n\t\t       sk->sk_prot->name, sk, atomic_read(&sk->sk_refcnt));\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":119522,"func":"u32 gf_isom_sample_get_subsamples_count(GF_ISOFile *movie, u32 track)\n{\n\tGF_TrackBox *trak = gf_isom_get_track_from_file(movie, track);\n\tif (!track) return 0;\n\tif (!trak->Media || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->sub_samples) return 0;\n\treturn gf_list_count(trak->Media->information->sampleTable->sub_samples);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":496902,"func":"\nstatic void\nyy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, RE_LEX_ENVIRONMENT *lex_env)\n{\n  YYFPRINTF (yyoutput, \"%s %s (\",\n             yytype < YYNTOKENS ? \"token\" : \"nterm\", yytname[yytype]);\n\n  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, lex_env);","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":460912,"func":"void reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *client)\n{\n    MainChannelClient *mcc;\n\n    spice_debug(\"%p\", client);\n    mcc = client->get_main();\n\n    \/\/ TODO: not doing net test. consider doing it on client_migrate_info\n    mcc->push_init(reds->qxl_instances.size(), reds->mouse_mode,\n                   reds->is_client_mouse_allowed,\n                   reds_get_mm_time() - MM_TIME_DELTA,\n                   reds_qxl_ram_size(reds));\n    reds_link_mig_target_channels(reds, client);\n    mcc->migrate_dst_complete();\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":458503,"func":"dp_packet_batch_refill_init(struct dp_packet_batch *batch)\n{\n    batch->count = 0;\n};","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":361192,"func":"int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,\n\t\t\tuid_t uid, gid_t gid)\n{\n\tVFS_FIND(lchown);\n\treturn handle->fns->lchown(handle, path, uid, gid);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":479169,"func":"      static bool is_finite(const cimg_int64) { return true; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":520553,"func":"  Item_int(THD *thd, longlong i,size_t length= MY_INT64_NUM_DECIMAL_DIGITS):\n    Item_num(thd), value(i)\n    { max_length=(uint32)length; }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":312735,"func":"void kvm_arch_commit_memory_region(struct kvm *kvm,\n\t\tstruct kvm_userspace_memory_region *mem,\n\t\tstruct kvm_memory_slot old,\n\t\tint user_alloc)\n{\n\treturn;\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":124713,"func":"static void lock_mnt_tree(struct mount *mnt)\n{\n\tstruct mount *p;\n\n\tfor (p = mnt; p; p = next_mnt(p, mnt)) {\n\t\tint flags = p->mnt.mnt_flags;\n\t\t\/* Don't allow unprivileged users to change mount flags *\/\n\t\tflags |= MNT_LOCK_ATIME;\n\n\t\tif (flags & MNT_READONLY)\n\t\t\tflags |= MNT_LOCK_READONLY;\n\n\t\tif (flags & MNT_NODEV)\n\t\t\tflags |= MNT_LOCK_NODEV;\n\n\t\tif (flags & MNT_NOSUID)\n\t\t\tflags |= MNT_LOCK_NOSUID;\n\n\t\tif (flags & MNT_NOEXEC)\n\t\t\tflags |= MNT_LOCK_NOEXEC;\n\t\t\/* Don't allow unprivileged users to reveal what is under a mount *\/\n\t\tif (list_empty(&p->mnt_expire))\n\t\t\tflags |= MNT_LOCKED;\n\t\tp->mnt.mnt_flags = flags;\n\t}\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":522292,"func":"  Partition_read_cursor(THD *thd, SQL_I_List<ORDER> *partition_list) :\n    bound_tracker(thd, partition_list) {}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":176460,"func":"bool xmp_set_property(XmpPtr xmp, const char *schema, const char *name,\n                      const char *value, uint32_t optionBits)\n{\n    CHECK_PTR(xmp, false);\n    RESET_ERROR;\n\n    bool ret = false;\n    auto txmp = reinterpret_cast<SXMPMeta *>(xmp);\n    if ((optionBits & (XMP_PROP_VALUE_IS_STRUCT | XMP_PROP_VALUE_IS_ARRAY)) &&\n        (*value == 0)) {\n        value = NULL;\n    }\n    try {\n        txmp->SetProperty(schema, name, value, optionBits);\n        ret = true;\n    }\n    catch (const XMP_Error &e) {\n        set_error(e);\n    }\n    catch (...) {\n    }\n    return ret;\n}\n","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":292407,"func":"  virtual void __fastcall Terminate()\r\n  {\r\n    TOwnConsole::FInstance->BreakInput();\r\n  }\r","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":459323,"func":"major_from_header (const char *p, size_t s)\n{\n  return from_header (p, s, \"major_t\",\n\t\t      TYPE_MINIMUM (major_t), TYPE_MAXIMUM (major_t),\n\t\t      false, false);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":267905,"func":"launch_location_list_free (GList *list)\n{\n    g_list_foreach (list, (GFunc) launch_location_free, NULL);\n    g_list_free (list);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":6772,"func":"static void snd_usb_mixer_free(struct usb_mixer_interface *mixer)\n{\n\tkfree(mixer->id_elems);\n\tif (mixer->urb) {\n\t\tkfree(mixer->urb->transfer_buffer);\n\t\tusb_free_urb(mixer->urb);\n\t}\n\tusb_free_urb(mixer->rc_urb);\n\tkfree(mixer->rc_setup_packet);\n\tkfree(mixer);\n}","target":1,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":120718,"func":"static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)\n{\n\t__be32 *p;\n\tint status = 0;\n\n\t*maxname = 1024;\n\tif (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))\n\t\treturn -EIO;\n\tif (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {\n\t\tp = xdr_inline_decode(xdr, 4);\n\t\tif (unlikely(!p))\n\t\t\tgoto out_overflow;\n\t\t*maxname = be32_to_cpup(p);\n\t\tbitmap[0] &= ~FATTR4_WORD0_MAXNAME;\n\t}\n\tdprintk(\"%s: maxname=%u\\n\", __func__, *maxname);\n\treturn status;\nout_overflow:\n\tprint_overflow_msg(__func__, xdr);\n\treturn -EIO;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":417285,"func":"static void h2_session_ev_conn_error(h2_session *session, int arg, const char *msg)\n{\n    switch (session->state) {\n        case H2_SESSION_ST_INIT:\n        case H2_SESSION_ST_DONE:\n            \/* just leave *\/\n            transit(session, \"conn error\", H2_SESSION_ST_DONE);\n            break;\n        \n        default:\n            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, \n                          H2_SSSN_LOG(APLOGNO(03401), session, \n                          \"conn error -> shutdown\"));\n            h2_session_shutdown(session, arg, msg, 0);\n            break;\n    }\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":388452,"func":"bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,\n\t\t\t\t  struct asn1_data *data,\n\t\t\t\t  const char **result)\n{\n\tDATA_BLOB string;\n\tif (!asn1_read_OctetString(data, mem_ctx, &string))\n\t\treturn false;\n\t*result = blob2string_talloc(mem_ctx, string);\n\tdata_blob_free(&string);\n\treturn true;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":218380,"func":"int js_hasproperty(js_State *J, int idx, const char *name)\n{\n\treturn jsR_hasproperty(J, js_toobject(J, idx), name);\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":76729,"func":"static void init_once(void *foo)\n{\n\tstruct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo;\n\n\tinode_init_once(&fi->vfs_inode);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":71233,"func":"static inline uint16_t vmid_to_domainid(uint16_t vm_id)\n{\n\treturn vm_id + 1U;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":496482,"func":"  void visit(Halfedge_handle ) {}","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":193372,"func":"void LayerTilerChromium::invalidateRect(const IntRect& contentRect)\n{\n    if (contentRect.isEmpty())\n        return;\n\n    growLayerToContain(contentRect);\n\n    IntRect layerRect = contentRectToLayerRect(contentRect);\n\n    int left, top, right, bottom;\n    contentRectToTileIndices(contentRect, left, top, right, bottom);\n    for (int j = top; j <= bottom; ++j) {\n        for (int i = left; i <= right; ++i) {\n            Tile* tile = m_tiles[tileIndex(i, j)].get();\n            if (!tile)\n                continue;\n            IntRect bound = tileLayerRect(i, j);\n            bound.intersect(layerRect);\n            tile->m_dirtyLayerRect.unite(bound);\n        }\n    }\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":482698,"func":"htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,\n\t          const char *encoding ATTRIBUTE_UNUSED) {\n    xmlDtdPtr cur = doc->intSubset;\n\n    if (cur == NULL) {\n\thtmlSaveErr(XML_SAVE_NO_DOCTYPE, (xmlNodePtr) doc, NULL);\n\treturn;\n    }\n    xmlOutputBufferWriteString(buf, \"<!DOCTYPE \");\n    xmlOutputBufferWriteString(buf, (const char *)cur->name);\n    if (cur->ExternalID != NULL) {\n\txmlOutputBufferWriteString(buf, \" PUBLIC \");\n\txmlBufWriteQuotedString(buf->buffer, cur->ExternalID);\n\tif (cur->SystemID != NULL) {\n\t    xmlOutputBufferWriteString(buf, \" \");\n\t    xmlBufWriteQuotedString(buf->buffer, cur->SystemID);\n\t}\n    } else if (cur->SystemID != NULL &&\n\t       xmlStrcmp(cur->SystemID, BAD_CAST \"about:legacy-compat\")) {\n\txmlOutputBufferWriteString(buf, \" SYSTEM \");\n\txmlBufWriteQuotedString(buf->buffer, cur->SystemID);\n    }\n    xmlOutputBufferWriteString(buf, \">\\n\");\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":408554,"func":"dvi_document_get_n_pages (EvDocument *document)\n{\n\tDviDocument *dvi_document = DVI_DOCUMENT (document);\n\t\n\treturn dvi_document->context->npages;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":266158,"func":"static byte cdecrypt(byte cipher, unsigned short *cr)\n{\n    const byte plain = (cipher ^ (*cr >> 8));\n    *cr = (cipher + *cr) * t1_c1 + t1_c2;\n    return plain;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":275382,"func":"void BrowserView::UpdateDevToolsSplitPosition() {\n  if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {\n    int split_offset = contents_split_->width() -\n        devtools_window_->GetWidth(contents_split_->width());\n    contents_split_->set_divider_offset(split_offset);\n  } else {\n    int split_offset = contents_split_->height() -\n        devtools_window_->GetHeight(contents_split_->height());\n    contents_split_->set_divider_offset(split_offset);\n  }\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":374604,"func":"_copyCreateFunctionStmt(const CreateFunctionStmt *from)\n{\n\tCreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);\n\n\tCOPY_SCALAR_FIELD(replace);\n\tCOPY_NODE_FIELD(funcname);\n\tCOPY_NODE_FIELD(parameters);\n\tCOPY_NODE_FIELD(returnType);\n\tCOPY_NODE_FIELD(options);\n\tCOPY_NODE_FIELD(withClause);\n\n\treturn newnode;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":283200,"func":"void V8TestObject::VoidMethodArrayOfDoubleOrDOMStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_voidMethodArrayOfDoubleOrDOMStringArg\");\n\n  test_object_v8_internal::VoidMethodArrayOfDoubleOrDOMStringArgMethod(info);\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":248295,"func":"WebLocalFrame* WebLocalFrameImpl::ToWebLocalFrame() {\n  return this;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":237721,"func":"void HideHostCursor() {\n  CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor,\n                         (CreateInvisibleCursor(), ui::GetXDisplay()));\n  XDefineCursor(ui::GetXDisplay(), DefaultRootWindow(ui::GetXDisplay()),\n                invisible_cursor.get());\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":459644,"func":"dissect_kafka_describe_groups_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,\n                                       kafka_api_version_t api_version)\n{\n    if (api_version >= 1) {\n        offset = dissect_kafka_throttle_time(tvb, pinfo, tree, offset);\n    }\n\n    \/* [group] *\/\n    offset = dissect_kafka_array(tree, tvb, pinfo, offset, api_version >= 5, api_version,\n                                 &dissect_kafka_describe_groups_response_group, NULL);\n\n    if (api_version >= 5) {\n        offset = dissect_kafka_tagged_fields(tvb, pinfo, tree, offset, 0);\n    }\n\n    return offset;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":37149,"func":"static int x86_pmu_extra_regs(u64 config, struct perf_event *event)\n{\n\tstruct extra_reg *er;\n\n\tevent->hw.extra_reg = 0;\n\tevent->hw.extra_config = 0;\n\n\tif (!x86_pmu.extra_regs)\n\t\treturn 0;\n\n\tfor (er = x86_pmu.extra_regs; er->msr; er++) {\n\t\tif (er->event != (config & er->config_mask))\n\t\t\tcontinue;\n\t\tif (event->attr.config1 & ~er->valid_mask)\n\t\t\treturn -EINVAL;\n\t\tevent->hw.extra_reg = er->msr;\n\t\tevent->hw.extra_config = event->attr.config1;\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":316099,"func":"void FrameSelection::SetUseSecureKeyboardEntry(bool enable) {\n  if (enable)\n    EnableSecureTextInput();\n  else\n    DisableSecureTextInput();\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":354627,"func":"pfm_unprotect_ctx_ctxsw(pfm_context_t *x, unsigned long f)\n{\n\tspin_unlock(&(x)->ctx_lock);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":461766,"func":"\nstatic struct bus_type iscsi_flashnode_bus;\n\nint iscsi_flashnode_bus_match(struct device *dev,\n\t\t\t\t     struct device_driver *drv)\n{\n\tif (dev->bus == &iscsi_flashnode_bus)","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":476739,"func":"prologProcessor(XML_Parser parser, const char *s, const char *end,\n                const char **nextPtr) {\n  const char *next = s;\n  int tok = XmlPrologTok(parser->m_encoding, s, end, &next);\n  return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,\n                  (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE,\n                  XML_ACCOUNT_DIRECT);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":197781,"func":"  bool running() const { return running_; }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":109082,"func":"void sqlite3WithDelete(sqlite3 *db, With *pWith){\n  if( pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      struct Cte *pCte = &pWith->a[i];\n      sqlite3ExprListDelete(db, pCte->pCols);\n      sqlite3SelectDelete(db, pCte->pSelect);\n      sqlite3DbFree(db, pCte->zName);\n    }\n    sqlite3DbFree(db, pWith);\n  }\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":385903,"func":"static int load_dh_params(SSL_CTX *ctx, char *file)\n{\n\tDH *dh = NULL;\n\tBIO *bio;\n\n\tif (!file) return 0;\n\n\tif ((bio = BIO_new_file(file, \"r\")) == NULL) {\n\t\tERROR(LOG_PREFIX \": Unable to open DH file - %s\", file);\n\t\treturn -1;\n\t}\n\n\tdh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);\n\tBIO_free(bio);\n\tif (!dh) {\n\t\tWARN(LOG_PREFIX \": Unable to set DH parameters.  DH cipher suites may not work!\");\n\t\tWARN(LOG_PREFIX \": Fix this by running the OpenSSL command listed in eap.conf\");\n\t\treturn 0;\n\t}\n\n\tif (SSL_CTX_set_tmp_dh(ctx, dh) < 0) {\n\t\tERROR(LOG_PREFIX \": Unable to set DH parameters\");\n\t\tDH_free(dh);\n\t\treturn -1;\n\t}\n\n\tDH_free(dh);\n\treturn 0;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":174143,"func":"const AtomicString& DocumentLoader::ResponseMIMEType() const {\n  return response_.MimeType();\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":248439,"func":"void LayerTreeHostImpl::AnimateInternal(bool active_tree) {\n  DCHECK(task_runner_provider_->IsImplThread());\n  base::TimeTicks monotonic_time = CurrentBeginFrameArgs().frame_time;\n\n\n  bool did_animate = false;\n\n  if (input_handler_client_) {\n    bool ignore_fling =\n        settings_.ignore_root_layer_flings && IsCurrentlyScrollingViewport();\n    if (!ignore_fling) {\n      input_handler_client_->Animate(monotonic_time);\n    }\n  }\n\n  did_animate |= AnimatePageScale(monotonic_time);\n  did_animate |= AnimateLayers(monotonic_time);\n  did_animate |= AnimateScrollbars(monotonic_time);\n  did_animate |= AnimateBrowserControls(monotonic_time);\n\n  if (active_tree) {\n    did_animate |= Mutate(monotonic_time);\n\n    UpdateRootLayerStateForSynchronousInputHandler();\n    if (did_animate) {\n      SetNeedsRedraw();\n    }\n  }\n}\n","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":127804,"func":"GF_Err dimm_Read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_DIMMBox *ptr = (GF_DIMMBox *)s;\n\tptr->nbBytes = gf_bs_read_u64(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":314909,"func":"WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform)\n    : context_(new Context(this)),\n      platform_(platform) {\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":41435,"func":"struct sk_buff *__netdev_alloc_skb(struct net_device *dev,\n\t\t\t\t   unsigned int length, gfp_t gfp_mask)\n{\n\tstruct sk_buff *skb = NULL;\n\tunsigned int fragsz = SKB_DATA_ALIGN(length + NET_SKB_PAD) +\n\t\t\t      SKB_DATA_ALIGN(sizeof(struct skb_shared_info));\n\n\tif (fragsz <= PAGE_SIZE && !(gfp_mask & (__GFP_WAIT | GFP_DMA))) {\n\t\tvoid *data;\n\n\t\tif (sk_memalloc_socks())\n\t\t\tgfp_mask |= __GFP_MEMALLOC;\n\n\t\tdata = __netdev_alloc_frag(fragsz, gfp_mask);\n\n\t\tif (likely(data)) {\n\t\t\tskb = build_skb(data, fragsz);\n\t\t\tif (unlikely(!skb))\n\t\t\t\tput_page(virt_to_head_page(data));\n\t\t}\n\t} else {\n\t\tskb = __alloc_skb(length + NET_SKB_PAD, gfp_mask,\n\t\t\t\t  SKB_ALLOC_RX, NUMA_NO_NODE);\n\t}\n\tif (likely(skb)) {\n\t\tskb_reserve(skb, NET_SKB_PAD);\n\t\tskb->dev = dev;\n\t}\n\treturn skb;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":46829,"func":"int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){\n  Walker w;\n  p = sqlite3ExprSkipCollateAndLikely(p);\n  if( p==0 ) return 0;\n  if( p->op==TK_NOTNULL ){\n    p = p->pLeft;\n  }else{\n    while( p->op==TK_AND ){\n      if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;\n      p = p->pRight;\n    }\n  }\n  w.xExprCallback = impliesNotNullRow;\n  w.xSelectCallback = 0;\n  w.xSelectCallback2 = 0;\n  w.eCode = 0;\n  w.u.iCur = iTab;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":483428,"func":"bool css_has_online_children(struct cgroup_subsys_state *css)\n{\n\tstruct cgroup_subsys_state *child;\n\tbool ret = false;\n\n\trcu_read_lock();\n\tcss_for_each_child(child, css) {\n\t\tif (child->flags & CSS_ONLINE) {\n\t\t\tret = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\trcu_read_unlock();\n\treturn ret;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":174746,"func":"RGBGrayEncoder::~RGBGrayEncoder() {\n  if (str->isEncoder())\n    delete str;\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":263044,"func":"static int copy_from_read_buf(struct tty_struct *tty,\n\t\t\t\t      unsigned char __user **b,\n\t\t\t\t      size_t *nr)\n\n{\n\tstruct n_tty_data *ldata = tty->disc_data;\n\tint retval;\n\tsize_t n;\n\tbool is_eof;\n\tsize_t tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1);\n\n\tretval = 0;\n\tn = min(read_cnt(ldata), N_TTY_BUF_SIZE - tail);\n\tn = min(*nr, n);\n\tif (n) {\n\t\tretval = copy_to_user(*b, read_buf_addr(ldata, tail), n);\n\t\tn -= retval;\n\t\tis_eof = n == 1 && read_buf(ldata, tail) == EOF_CHAR(tty);\n\t\ttty_audit_add_data(tty, read_buf_addr(ldata, tail), n,\n\t\t\t\tldata->icanon);\n\t\tldata->read_tail += n;\n\t\t\/* Turn single EOF into zero-length read *\/\n\t\tif (L_EXTPROC(tty) && ldata->icanon && is_eof && !read_cnt(ldata))\n\t\t\tn = 0;\n\t\t*b += n;\n\t\t*nr -= n;\n\t}\n\treturn retval;\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":488883,"func":"uint8_t avdtp_error_category(struct avdtp_error *err)\n{\n\treturn err->category;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":521237,"func":"int Arg_comparator::compare_decimal()\n{\n  VDec val1(*a);\n  if (!val1.is_null())\n  {\n    VDec val2(*b);\n    if (!val2.is_null())\n    {\n      if (set_null)\n        owner->null_value= 0;\n      val1.round_self_if_needed((*a)->decimals, HALF_UP);\n      val2.round_self_if_needed((*b)->decimals, HALF_UP);\n      return val1.cmp(val2);\n    }\n  }\n  if (set_null)\n    owner->null_value= 1;\n  return -1;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":310999,"func":"  Browser* browser() { return browser_.get(); }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":156540,"func":"authDigestNonceLastRequest(digest_nonce_h * nonce)\n{\n    if (!nonce)\n        return -1;\n\n    if (nonce->nc == 99999997) {\n        debugs(29, 4, \"Nonce count about to overflow\");\n        return -1;\n    }\n\n    if (nonce->nc >= static_cast<Auth::Digest::Config*>(Auth::Config::Find(\"digest\"))->noncemaxuses - 1) {\n        debugs(29, 4, \"Nonce count about to hit user limit\");\n        return -1;\n    }\n\n    \/* and other tests are possible. *\/\n    return 0;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":312434,"func":"Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(ContainerNode* insertionPoint)\n{\n    m_ancestorDisabledState = AncestorDisabledStateUnknown;\n    m_dataListAncestorState = Unknown;\n    setNeedsWillValidateCheck();\n    HTMLElement::insertedInto(insertionPoint);\n    FormAssociatedElement::insertedInto(insertionPoint);\n    fieldSetAncestorsSetNeedsValidityCheck(insertionPoint);\n\n    if (!formOwner() && insertionPoint->inDocument())\n        document().didAssociateFormControl(this);\n\n    return InsertionDone;\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":283188,"func":"  ImageResourceFactory(const FetchParameters& fetch_params)\n      : NonTextResourceFactory(Resource::kImage),\n        fetch_params_(&fetch_params) {}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":438190,"func":"bool Segment::QueueFrame(Frame* frame) {\n  const int32_t new_size = frames_size_ + 1;\n\n  if (new_size > frames_capacity_) {\n    \/\/ Add more frames.\n    const int32_t new_capacity = (!frames_capacity_) ? 2 : frames_capacity_ * 2;\n\n    if (new_capacity < 1)\n      return false;\n\n    Frame** const frames = new (std::nothrow) Frame*[new_capacity];  \/\/ NOLINT\n    if (!frames)\n      return false;\n\n    for (int32_t i = 0; i < frames_size_; ++i) {\n      frames[i] = frames_[i];\n    }\n\n    delete[] frames_;\n    frames_ = frames;\n    frames_capacity_ = new_capacity;\n  }\n\n  frames_[frames_size_++] = frame;\n\n  return true;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":360030,"func":"filesystem_info_start (NautilusDirectory *directory,\n\t\t       NautilusFile *file,\n\t\t       gboolean *doing_io)\n{\n\tGFile *location;\n\tFilesystemInfoState *state;\n\n\tif (directory->details->filesystem_info_state != NULL) {\n\t\t*doing_io = TRUE;\n\t\treturn;\n\t}\n\n\tif (!is_needy (file,\n\t\t       lacks_filesystem_info,\n\t\t       REQUEST_FILESYSTEM_INFO)) {\n\t\treturn;\n\t}\n\t*doing_io = TRUE;\n\n\tif (!async_job_start (directory, \"filesystem info\")) {\n\t\treturn;\n\t}\n\t\n\tstate = g_new0 (FilesystemInfoState, 1);\n\tstate->directory = directory;\n\tstate->file = file;\n\tstate->cancellable = g_cancellable_new ();\n\n\tlocation = nautilus_file_get_location (file);\n\t\n\tdirectory->details->filesystem_info_state = state;\n\n\tg_file_query_filesystem_info_async (location,\n\t\t\t\t\t    G_FILE_ATTRIBUTE_FILESYSTEM_READONLY \",\"\n\t\t\t\t\t    G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW,\n\t\t\t\t\t    G_PRIORITY_DEFAULT,\n\t\t\t\t\t    state->cancellable, \n\t\t\t\t\t    query_filesystem_info_callback, \n\t\t\t\t\t    state);\n\tg_object_unref (location);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":515576,"func":"static int equal_wildcard(const unsigned char *pattern, size_t pattern_len,\n                          const unsigned char *subject, size_t subject_len,\n                          unsigned int flags)\n{\n    const unsigned char *star = NULL;\n\n    \/*\n     * Subject names starting with '.' can only match a wildcard pattern\n     * via a subject sub-domain pattern suffix match.\n     *\/\n    if (!(subject_len > 1 && subject[0] == '.'))\n        star = valid_star(pattern, pattern_len, flags);\n    if (star == NULL)\n        return equal_nocase(pattern, pattern_len,\n                            subject, subject_len, flags);\n    return wildcard_match(pattern, star - pattern,\n                          star + 1, (pattern + pattern_len) - star - 1,\n                          subject, subject_len, flags);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":46965,"func":"f_strtrans(typval_T *argvars, typval_T *rettv)\n{\n    rettv->v_type = VAR_STRING;\n    rettv->vval.v_string = transstr(tv_get_string(&argvars[0]));\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":516044,"func":"save_number(const char *fmt, int number, int len)\n{\n    size_t s_len = (size_t) len + 30 + strlen(fmt);\n    get_space(s_len + 1);\n\n    _nc_SPRINTF(TPS(out_buff) + TPS(out_used),\n\t\t_nc_SLIMIT(TPS(out_size) - TPS(out_used))\n\t\tfmt, number);\n    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":126641,"func":"static int em_mov(struct x86_emulate_ctxt *ctxt)\n{\n\tmemcpy(ctxt->dst.valptr, ctxt->src.valptr, sizeof(ctxt->src.valptr));\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":408284,"func":"static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)\n{\n\tstruct uprobe_consumer *uc;\n\tint remove = UPROBE_HANDLER_REMOVE;\n\tbool need_prep = false; \/* prepare return uprobe, when needed *\/\n\n\tdown_read(&uprobe->register_rwsem);\n\tfor (uc = uprobe->consumers; uc; uc = uc->next) {\n\t\tint rc = 0;\n\n\t\tif (uc->handler) {\n\t\t\trc = uc->handler(uc, regs);\n\t\t\tWARN(rc & ~UPROBE_HANDLER_MASK,\n\t\t\t\t\"bad rc=0x%x from %pf()\\n\", rc, uc->handler);\n\t\t}\n\n\t\tif (uc->ret_handler)\n\t\t\tneed_prep = true;\n\n\t\tremove &= rc;\n\t}\n\n\tif (need_prep && !remove)\n\t\tprepare_uretprobe(uprobe, regs); \/* put bp at return *\/\n\n\tif (remove && uprobe->consumers) {\n\t\tWARN_ON(!uprobe_is_active(uprobe));\n\t\tunapply_uprobe(uprobe, current->mm);\n\t}\n\tup_read(&uprobe->register_rwsem);\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":227383,"func":"eval_number(uschar **sptr, BOOL decimal, uschar **error)\n{\nregister int c;\nint_eximarith_t n;\nuschar *s = *sptr;\nwhile (isspace(*s)) s++;\nc = *s;\nif (isdigit(c))\n  {\n  int count;\n  (void)sscanf(CS s, (decimal? SC_EXIM_DEC \"%n\" : SC_EXIM_ARITH \"%n\"), &n, &count);\n  s += count;\n  switch (tolower(*s))\n    {\n    default: break;\n    case 'k': n *= 1024; s++; break;\n    case 'm': n *= 1024*1024; s++; break;\n    case 'g': n *= 1024*1024*1024; s++; break;\n    }\n  while (isspace (*s)) s++;\n  }\nelse if (c == '(')\n  {\n  s++;\n  n = eval_expr(&s, decimal, error, 1);\n  }\nelse\n  {\n  *error = US\"expecting number or opening parenthesis\";\n  n = 0;\n  }\n*sptr = s;\nreturn n;\n}\n","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":206607,"func":"TemplateURL::AssociatedExtensionInfo::~AssociatedExtensionInfo() {\n}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":16614,"func":"PHP_FUNCTION ( uwsgi_masterpid ) {\n if ( uwsgi . master_process ) {\n RETURN_LONG ( uwsgi . workers [ 0 ] . pid ) ;\n }\n RETURN_LONG ( 0 ) ;\n }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":483878,"func":"void unregister_memory_notifier(struct notifier_block *nb)\n{\n\tblocking_notifier_chain_unregister(&memory_chain, nb);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":123593,"func":"static inline struct crypto_ahash *crypto_spawn_ahash(\n\tstruct crypto_ahash_spawn *spawn)\n{\n\treturn crypto_spawn_tfm2(&spawn->base);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":495037,"func":"static void snd_pcm_post_reset(struct snd_pcm_substream *substream,\n\t\t\t       snd_pcm_state_t state)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\truntime->control->appl_ptr = runtime->status->hw_ptr;\n\tif (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&\n\t    runtime->silence_size > 0)\n\t\tsnd_pcm_playback_silence(substream, ULONG_MAX);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":475748,"func":"static int nft_set_elem_expr_setup(struct nft_ctx *ctx,\n\t\t\t\t   const struct nft_set_ext *ext,\n\t\t\t\t   struct nft_expr *expr_array[],\n\t\t\t\t   u32 num_exprs)\n{\n\tstruct nft_set_elem_expr *elem_expr = nft_set_ext_expr(ext);\n\tstruct nft_expr *expr;\n\tint i, err;\n\n\tfor (i = 0; i < num_exprs; i++) {\n\t\texpr = nft_setelem_expr_at(elem_expr, elem_expr->size);\n\t\terr = nft_expr_clone(expr, expr_array[i]);\n\t\tif (err < 0)\n\t\t\tgoto err_elem_expr_setup;\n\n\t\telem_expr->size += expr_array[i]->ops->size;\n\t\tnft_expr_destroy(ctx, expr_array[i]);\n\t\texpr_array[i] = NULL;\n\t}\n\n\treturn 0;\n\nerr_elem_expr_setup:\n\tfor (; i < num_exprs; i++) {\n\t\tnft_expr_destroy(ctx, expr_array[i]);\n\t\texpr_array[i] = NULL;\n\t}\n\n\treturn -ENOMEM;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":114024,"func":"static ssize_t ati_remote2_show_channel_mask(struct device *dev,\n\t\t\t\t\t     struct device_attribute *attr,\n\t\t\t\t\t     char *buf)\n{\n\tstruct usb_device *udev = to_usb_device(dev);\n\tstruct usb_interface *intf = usb_ifnum_to_if(udev, 0);\n\tstruct ati_remote2 *ar2 = usb_get_intfdata(intf);\n\n\treturn sprintf(buf, \"0x%04x\\n\", ar2->channel_mask);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":461288,"func":"static bool sanity_check(struct ip_udp_dhcp_packet *packet, int bytes)\n{\n\tif (packet->ip.protocol != IPPROTO_UDP)\n\t\treturn false;\n\n\tif (packet->ip.version != IPVERSION)\n\t\treturn false;\n\n\tif (packet->ip.ihl != sizeof(packet->ip) >> 2)\n\t\treturn false;\n\n\tif (packet->udp.dest != htons(CLIENT_PORT))\n\t\treturn false;\n\n\tif (ntohs(packet->udp.len) != (uint16_t)(bytes - sizeof(packet->ip)))\n\t\treturn false;\n\n\treturn true;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":70483,"func":"_archive_write_disk_data_block(struct archive *_a,\n    const void *buff, size_t size, int64_t offset)\n{\n\tstruct archive_write_disk *a = (struct archive_write_disk *)_a;\n\tssize_t r;\n\n\tarchive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,\n\t    ARCHIVE_STATE_DATA, \"archive_write_data_block\");\n\n\ta->offset = offset;\n\tif (a->todo & TODO_HFS_COMPRESSION)\n\t\tr = hfs_write_data_block(a, buff, size);\n\telse\n\t\tr = write_data_block(a, buff, size);\n\tif (r < ARCHIVE_OK)\n\t\treturn (r);\n\tif ((size_t)r < size) {\n\t\tarchive_set_error(&a->archive, 0,\n\t\t    \"Write request too large\");\n\t\treturn (ARCHIVE_WARN);\n\t}\n#if ARCHIVE_VERSION_NUMBER < 3999000\n\treturn (ARCHIVE_OK);\n#else\n\treturn (size);\n#endif\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":325588,"func":"static int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack* track)\n\n{\n\n    offset_t pos = url_ftell(pb);\n\n    put_be32(pb, 0); \/* size *\/\n\n    put_tag(pb, \"stbl\");\n\n    mov_write_stsd_tag(pb, track);\n\n    mov_write_stts_tag(pb, track);\n\n    if (track->enc->codec_type == CODEC_TYPE_VIDEO &&\n\n        track->hasKeyframes < track->entry)\n\n        mov_write_stss_tag(pb, track);\n\n    if (track->enc->codec_type == CODEC_TYPE_VIDEO &&\n\n        track->hasBframes)\n\n        mov_write_ctts_tag(pb, track);\n\n    mov_write_stsc_tag(pb, track);\n\n    mov_write_stsz_tag(pb, track);\n\n    mov_write_stco_tag(pb, track);\n\n    return updateSize(pb, pos);\n\n}\n","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":184366,"func":"unsigned HTMLCanvasElement::GetMSAASampleCountFor2dContext() const {\n  if (!GetDocument().GetSettings())\n    return 0;\n  return GetDocument().GetSettings()->GetAccelerated2dCanvasMSAASampleCount();\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":429829,"func":"smpl_t aubio_onset_get_awhitening (aubio_onset_t *o)\n{\n  return o->apply_awhitening;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":244552,"func":"void red_client_set_migration_seamless(RedClient *client) \/\/ dest\n{\n    RingItem *link;\n    pthread_mutex_lock(&client->lock);\n    client->seamless_migrate = TRUE;\n    \/* update channel clients that got connected before the migration\n     * type was set. red_client_add_channel will handle newer channel clients *\/\n    RING_FOREACH(link, &client->channels) {\n        RedChannelClient *rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link);\n        red_channel_client_set_migration_seamless(rcc);\n    }\n    pthread_mutex_unlock(&client->lock);\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":273875,"func":"selftest_fips_192 (int extended, selftest_report_func_t report)\n{\n  const char *what;\n  const char *errtxt;\n\n  (void)extended; \/* No extended tests available.  *\/\n\n  what = \"low-level\";\n  errtxt = selftest_basic_192 ();\n  if (errtxt)\n    goto failed;\n\n\n  return 0; \/* Succeeded. *\/\n\n failed:\n  if (report)\n    report (\"cipher\", GCRY_CIPHER_AES192, what, errtxt);\n  return GPG_ERR_SELFTEST_FAILED;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":210543,"func":"void Browser::FocusLocationBar() {\n  UserMetrics::RecordAction(UserMetricsAction(\"FocusLocation\"));\n  window_->SetFocusToLocationBar(true);\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":520104,"func":"subselect_rowid_merge_engine::cmp_keys_by_cur_rownum(void *arg,\n                                                     uchar *k1, uchar *k2)\n{\n  rownum_t r1= ((Ordered_key*) k1)->current();\n  rownum_t r2= ((Ordered_key*) k2)->current();\n\n  return (r1 < r2) ? -1 : (r1 > r2) ? 1 : 0;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":264016,"func":"void ext4_ext_init(struct super_block *sb)\n{\n\t\/*\n\t * possible initialization would be here\n\t *\/\n\n\tif (ext4_has_feature_extents(sb)) {\n#if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS)\n\t\tprintk(KERN_INFO \"EXT4-fs: file extents enabled\"\n#ifdef AGGRESSIVE_TEST\n\t\t       \", aggressive tests\"\n#endif\n#ifdef CHECK_BINSEARCH\n\t\t       \", check binsearch\"\n#endif\n#ifdef EXTENTS_STATS\n\t\t       \", stats\"\n#endif\n\t\t       \"\\n\");\n#endif\n#ifdef EXTENTS_STATS\n\t\tspin_lock_init(&EXT4_SB(sb)->s_ext_stats_lock);\n\t\tEXT4_SB(sb)->s_ext_min = 1 << 30;\n\t\tEXT4_SB(sb)->s_ext_max = 0;\n#endif\n\t}\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":209076,"func":"static void iscsi_detach_aio_context(BlockDriverState *bs)\n{\n    IscsiLun *iscsilun = bs->opaque;\n\n    aio_set_fd_handler(iscsilun->aio_context, iscsi_get_fd(iscsilun->iscsi),\n                       false, NULL, NULL, NULL);\n    iscsilun->events = 0;\n\n    if (iscsilun->nop_timer) {\n        timer_del(iscsilun->nop_timer);\n        timer_free(iscsilun->nop_timer);\n        iscsilun->nop_timer = NULL;\n    }\n    if (iscsilun->event_timer) {\n        timer_del(iscsilun->event_timer);\n        timer_free(iscsilun->event_timer);\n        iscsilun->event_timer = NULL;\n    }\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":520823,"func":"  void set_param_func(uchar **pos, ulong len)\n  {\n    \/*\n      To avoid Item_param::set_xxx() asserting on data type mismatch,\n      we set the value type handler here:\n      - It can not be initialized yet after Item_param::setup_conversion().\n      - Also, for LIMIT clause parameters, the value type handler might have\n        changed from the real type handler to type_handler_longlong.\n        So here we'll restore it.\n    *\/\n    const Type_handler *h= Item_param::type_handler();\n    value.set_handler(h);\n    h->Item_param_set_param_func(this, pos, len);\n  }","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":390173,"func":"long SSL_CTX_get_session_cache_mode(SSL_CTX*)\n{\n    \/\/ always 0, unlimited size for now\n    return 0;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":182831,"func":"CastTrayView::~CastTrayView() {\n}\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":21717,"func":"static uint query_cache_hits ( MYSQL * conn ) {\n MYSQL_RES * res ;\n MYSQL_ROW row ;\n int rc ;\n uint result ;\n rc = mysql_query ( conn , \"show status like 'qcache_hits'\" ) ;\n myquery ( rc ) ;\n res = mysql_use_result ( conn ) ;\n DIE_UNLESS ( res ) ;\n row = mysql_fetch_row ( res ) ;\n DIE_UNLESS ( row ) ;\n result = atoi ( row [ 1 ] ) ;\n mysql_free_result ( res ) ;\n return result ;\n }","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":316400,"func":"  void DownloadFilesToReadonlyFolder(size_t count,\n                                     DownloadInfo* download_info) {\n    DownloadFilesCheckErrorsSetup();\n\n    base::FilePath destination_folder = GetDownloadDirectory(browser());\n    DVLOG(1) << \" \" << __FUNCTION__ << \"()\"\n             << \" folder = '\" << destination_folder.value() << \"'\";\n    base::FilePermissionRestorer permission_restorer(destination_folder);\n    EXPECT_TRUE(base::MakeFileUnwritable(destination_folder));\n\n    for (size_t i = 0; i < count; ++i) {\n      DownloadFilesCheckErrorsLoopBody(download_info[i], i);\n    }\n  }\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":477485,"func":"static void tcf_proto_get(struct tcf_proto *tp)\n{\n\trefcount_inc(&tp->refcnt);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":193048,"func":"void RenderFrameHostCreatedObserver::RenderFrameCreated(\n    RenderFrameHost* render_frame_host) {\n  frames_created_++;\n  if (frames_created_ == expected_frame_count_) {\n    message_loop_runner_->Quit();\n  }\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":285909,"func":"ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()\n    : download_file_manager_(new DownloadFileManager(NULL)),\n      save_file_manager_(new SaveFileManager()),\n      request_id_(-1),\n      is_shutdown_(false),\n      max_outstanding_requests_cost_per_process_(\n          kMaxOutstandingRequestsCostPerProcess),\n      filter_(NULL),\n      delegate_(NULL),\n      allow_cross_origin_auth_prompt_(false) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n  DCHECK(!g_resource_dispatcher_host);\n  g_resource_dispatcher_host = this;\n\n  GetContentClient()->browser()->ResourceDispatcherHostCreated();\n\n  ANNOTATE_BENIGN_RACE(\n      &last_user_gesture_time_,\n      \"We don't care about the precise value, see http:\/\/crbug.com\/92889\");\n\n  BrowserThread::PostTask(\n      BrowserThread::IO, FROM_HERE,\n      base::Bind(&appcache::AppCacheInterceptor::EnsureRegistered));\n\n  update_load_states_timer_.reset(\n      new base::RepeatingTimer<ResourceDispatcherHostImpl>());\n}\n","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":273018,"func":"static int adts_write_trailer(AVFormatContext *s)\n{\n    ADTSContext *adts = s->priv_data;\n\n    if (adts->apetag)\n        ff_ape_write_tag(s);\n\n    return 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":140095,"func":"static void *setup_temp_malloc(vorb *f, int sz)\n{\n   sz = (sz+3) & ~3;\n   if (f->alloc.alloc_buffer) {\n      if (f->temp_offset - sz < f->setup_offset) return NULL;\n      f->temp_offset -= sz;\n      return (char *) f->alloc.alloc_buffer + f->temp_offset;\n   }\n   return malloc(sz);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":455515,"func":"TEST_F(RenameCollectionTest, RenameCollectionAcrossDatabaseDropsTemporaryCollectionOnException) {\n    _createCollection(_opCtx.get(), _sourceNss);\n    _createIndexOnEmptyCollection(_opCtx.get(), _sourceNss, \"a_1\");\n    _insertDocument(_opCtx.get(), _sourceNss, BSON(\"_id\" << 0));\n    _opObserver->onInsertsThrows = true;\n    _opObserver->oplogEntries.clear();\n    ASSERT_THROWS_CODE(renameCollection(_opCtx.get(), _sourceNss, _targetNssDifferentDb, {}),\n                       AssertionException,\n                       ErrorCodes::OperationFailed);\n    _checkOplogEntries(_opObserver->oplogEntries, {\"create\", \"index\", \"drop\"});\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":47254,"func":"static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,\n\t\t\t      struct pid *pid, struct task_struct *task)\n{\n\tif (unlikely(!sched_info_on()))\n\t\tseq_printf(m, \"0 0 0\\n\");\n\telse\n\t\tseq_printf(m, \"%llu %llu %lu\\n\",\n\t\t   (unsigned long long)task->se.sum_exec_runtime,\n\t\t   (unsigned long long)task->sched_info.run_delay,\n\t\t   task->sched_info.pcount);\n\n\treturn 0;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":207135,"func":"void V8Console::lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    ConsoleHelper helper(info);\n    InspectedContext* context = helper.ensureInspectedContext();\n    if (!context)\n        return;\n    if (InjectedScript* injectedScript = context->getInjectedScript())\n        info.GetReturnValue().Set(injectedScript->lastEvaluationResult());\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":74610,"func":"static int close_user_core(int user_core_fd, off_t core_size)\n{\n    if (user_core_fd >= 0 && (fsync(user_core_fd) != 0 || close(user_core_fd) != 0 || core_size < 0))\n    {\n        perror_msg(\"Error writing '%s' at '%s'\", core_basename, user_pwd);\n        return -1;\n    }\n    return 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":268244,"func":"void do_append_file(struct st_command *command)\n{\n  do_write_file_command(command, TRUE);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":424384,"func":"int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference, UnitDependencyMask mask) {\n        int r;\n\n        assert(u);\n\n        r = unit_add_dependency(u, d, other, add_reference, mask);\n        if (r < 0)\n                return r;\n\n        return unit_add_dependency(u, e, other, add_reference, mask);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":58026,"func":"static DWORD get_win32_connect_timeout(MYSQL *mysql)\n{\n  DWORD timeout_ms;\n  uint timeout_sec;\n\n  \/*\n    A timeout of 0 means no timeout. Also, the connect_timeout\n    option value is in seconds, while WIN32 timeouts are in\n    milliseconds. Hence, check for a possible overflow. In case\n    of overflow, set to no timeout.\n  *\/\n  timeout_sec= mysql->options.connect_timeout;\n\n  if (!timeout_sec || (timeout_sec > INT_MAX\/1000))\n    timeout_ms= INFINITE;\n  else\n    timeout_ms= (DWORD) (timeout_sec * 1000);\n\n  return timeout_ms;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":7442,"func":"static bool check_underflow(const struct ip6t_entry *e)\n{\n\tconst struct xt_entry_target *t;\n\tunsigned int verdict;\n\n\tif (!unconditional(&e->ipv6))\n\t\treturn false;\n\tt = ip6t_get_target_c(e);\n\tif (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)\n\t\treturn false;\n\tverdict = ((struct xt_standard_target *)t)->verdict;\n\tverdict = -verdict - 1;\n\treturn verdict == NF_DROP || verdict == NF_ACCEPT;\n}","target":1,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":479179,"func":"      static double mp_image_whds(_cimg_math_parser& mp) {\n        unsigned int ind = (unsigned int)mp.opcode[2];\n        if (ind!=~0U) {\n          if (!mp.imglist.width()) return cimg::type<double>::nan();\n          ind = (unsigned int)cimg::mod((int)_mp_arg(2),mp.imglist.width());\n        }\n        const CImg<T> &img = ind==~0U?mp.imgout:mp.imglist[ind];\n        return (double)img.width()*img.height()*img.depth()*img.spectrum();\n      }","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":222071,"func":"bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) {\n  if (!pepper_delegate_.IsPluginFocused())\n    return false;\n  *rect = pepper_delegate_.GetCaretBounds();\n  return true;\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":182383,"func":"void RenderFrameImpl::DidChangePerformanceTiming() {\n  for (auto& observer : observers_)\n    observer.DidChangePerformanceTiming();\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":391052,"func":"static int ntop_get_interface_find_user_flows(lua_State* vm) {\n  NetworkInterfaceView *ntop_interface = getCurrentInterface(vm);\n  char *key;\n\n  ntop->getTrace()->traceEvent(TRACE_INFO, \"%s() called\", __FUNCTION__);\n\n  if(!Utils::isUserAdministrator(vm)) return(CONST_LUA_ERROR);\n\n  if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING)) return(CONST_LUA_ERROR);\n  key = (char*)lua_tostring(vm, 1);\n\n  if(!ntop_interface) return(CONST_LUA_ERROR);\n\n  ntop_interface->findUserFlows(vm, key);\n  return(CONST_LUA_OK);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":426998,"func":"xsltFreeNsAliasList(xsltNsAliasPtr item)\n{\n    xsltNsAliasPtr tmp;\n\n    while (item) {\n\ttmp = item;\n\titem = item->next;\n\txmlFree(tmp);\n    }\n    return;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":139842,"func":"ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)\n{\n    return mr->ram_block ? mr->ram_block->offset : RAM_ADDR_INVALID;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":186641,"func":"int NavigationControllerImpl::GetIndexOfEntry(\n    const NavigationEntryImpl* entry) const {\n  const NavigationEntries::const_iterator i(std::find(\n      entries_.begin(),\n      entries_.end(),\n      entry));\n  return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin());\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":27272,"func":"static void dtap_sms_cp_data ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {\n guint32 curr_offset ;\n guint32 consumed ;\n guint curr_len ;\n curr_offset = offset ;\n curr_len = len ;\n is_uplink = IS_UPLINK_TRUE ;\n ELEM_MAND_LV ( GSM_A_PDU_TYPE_DTAP , DE_CP_USER_DATA , NULL ) ;\n EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_dtap_extraneous_data ) ;\n }","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":161186,"func":"\t\tunsigned int getNumber() const {\n\t\t\treturn number;\n\t\t}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":381797,"func":"CopySendString(CopyState cstate, const char *str)\n{\n\tappendBinaryStringInfo(cstate->fe_msgbuf, str, strlen(str));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":193147,"func":"void LockContentsView::Layout() {\n  View::Layout();\n  LayoutTopHeader();\n  LayoutPublicSessionView();\n\n  if (users_list_)\n    users_list_->Layout();\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":493693,"func":"static void fuse_lib_release(fuse_req_t req, fuse_ino_t ino,\n                             struct fuse_file_info *fi)\n{\n    struct fuse *f = req_fuse_prepare(req);\n    struct fuse_intr_data d;\n    char *path;\n    int err = 0;\n\n    pthread_rwlock_rdlock(&f->tree_lock);\n    path = get_path(f, ino);\n    if (f->conf.debug)\n        fprintf(stderr, \"RELEASE%s[%llu] flags: 0x%x\\n\",\n                fi->flush ? \"+FLUSH\" : \"\",\n                (unsigned long long) fi->fh, fi->flags);\n\n    if (fi->flush) {\n        err = fuse_flush_common(f, req, ino, path, fi);\n        if (err == -ENOSYS)\n            err = 0;\n    }\n\n    fuse_prepare_interrupt(f, req, &d);\n    fuse_do_release(f, ino, path, fi);\n    fuse_finish_interrupt(f, req, &d);\n    free(path);\n    pthread_rwlock_unlock(&f->tree_lock);\n\n    reply_err(req, err);\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":18174,"func":"TSReturnCode TSMgmtIntCreate ( TSRecordType rec_type , const char * name , TSMgmtInt data_default , TSRecordUpdateType update_type , TSRecordCheckType check_type , const char * check_regex , TSRecordAccessType access_type ) {\n if ( check_regex == nullptr && check_type != TS_RECORDCHECK_NULL ) {\n return TS_ERROR ;\n }\n if ( REC_ERR_OKAY != RecRegisterConfigInt ( ( enum RecT ) rec_type , name , ( RecInt ) data_default , ( enum RecUpdateT ) update_type , ( enum RecCheckT ) check_type , check_regex , REC_SOURCE_PLUGIN , ( enum RecAccessT ) access_type ) ) {\n return TS_ERROR ;\n }\n return TS_SUCCESS ;\n }","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":363486,"func":"on_saved_language_name_read (GdmSessionWorker *worker)\n{\n        char *language_name;\n\n        language_name = gdm_session_settings_get_language_name (worker->priv->user_settings);\n        send_dbus_string_method (worker->priv->connection,\n                                 \"SavedLanguageNameRead\",\n                                 language_name);\n        g_free (language_name);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":144960,"func":"int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)\n{\n\tstruct nameidata nd;\n\tvoid *cookie;\n\tint res;\n\n\tnd.depth = 0;\n\tcookie = dentry->d_inode->i_op->follow_link(dentry, &nd);\n\tif (IS_ERR(cookie))\n\t\treturn PTR_ERR(cookie);\n\n\tres = readlink_copy(buffer, buflen, nd_get_link(&nd));\n\tif (dentry->d_inode->i_op->put_link)\n\t\tdentry->d_inode->i_op->put_link(dentry, &nd, cookie);\n\treturn res;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":469047,"func":"     set_session_enable(cmd_parms * parms, void *dconf, int flag)\n{\n    session_dir_conf *conf = dconf;\n\n    conf->enabled = flag;\n    conf->enabled_set = 1;\n\n    return NULL;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":120914,"func":"void __weak module_arch_cleanup(struct module *mod)\n{\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":212590,"func":"bool BackendImpl::CreateBackingStore(disk_cache::File* file) {\n  AdjustMaxCacheSize(0);\n\n  IndexHeader header;\n  header.table_len = DesiredIndexTableLen(max_size_);\n\n  if (new_eviction_)\n    header.version = 0x20001;\n\n  header.create_time = Time::Now().ToInternalValue();\n\n  if (!file->Write(&header, sizeof(header), 0))\n    return false;\n\n  return file->SetLength(GetIndexSize(header.table_len));\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":283233,"func":"void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)\n{\n    process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":431210,"func":"bool isAuthzCollection(StringData coll) {\n    return (coll == AuthorizationManager::rolesCollectionNamespace.coll() ||\n            coll == AuthorizationManager::usersCollectionNamespace.coll() ||\n            coll == AuthorizationManager::versionCollectionNamespace.coll());\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":160106,"func":"ssize_t vb2_fop_write(struct file *file, const char __user *buf,\n\t\tsize_t count, loff_t *ppos)\n{\n\tstruct video_device *vdev = video_devdata(file);\n\tstruct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock;\n\tint err = -EBUSY;\n\n\tif (!(vdev->queue->io_modes & VB2_WRITE))\n\t\treturn -EINVAL;\n\tif (lock && mutex_lock_interruptible(lock))\n\t\treturn -ERESTARTSYS;\n\tif (vb2_queue_is_busy(vdev, file))\n\t\tgoto exit;\n\terr = vb2_write(vdev->queue, buf, count, ppos,\n\t\t       file->f_flags & O_NONBLOCK);\n\tif (vdev->queue->fileio)\n\t\tvdev->queue->owner = file->private_data;\nexit:\n\tif (lock)\n\t\tmutex_unlock(lock);\n\treturn err;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":39856,"func":"static int linear_ioctl(struct dm_target *ti, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct linear_c *lc = (struct linear_c *) ti->private;\n\tstruct dm_dev *dev = lc->dev;\n\tint r = 0;\n\n\t\/*\n\t * Only pass ioctls through if the device sizes match exactly.\n\t *\/\n\tif (lc->start ||\n\t    ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)\n\t\tr = scsi_verify_blk_ioctl(NULL, cmd);\n\n\treturn r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":190858,"func":"void ForwardRequestStatus(\n    RequestStatus status, net::URLRequest* request, void* profile_id) {\n  const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);\n  if (!info)\n    return;\n\n  int process_id, render_view_id;\n  if (info->GetAssociatedRenderView(&process_id, &render_view_id)) {\n    BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,\n        base::Bind(&NotifyEPMRequestStatus,\n                   status, profile_id, process_id, render_view_id));\n   }\n }\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":450142,"func":"static inline size_t ctnetlink_timestamp_size(const struct nf_conn *ct)\n{\n#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP\n\tif (!nf_ct_ext_exist(ct, NF_CT_EXT_TSTAMP))\n\t\treturn 0;\n\treturn nla_total_size(0) + 2 * nla_total_size_64bit(sizeof(uint64_t));\n#else\n\treturn 0;\n#endif\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":215967,"func":"static TriState StateStrikethrough(LocalFrame& frame, Event*) {\n  return StateStyle(frame, CSSPropertyWebkitTextDecorationsInEffect,\n                    \"line-through\");\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":234572,"func":"static void mptsas_interrupt_status_write(MPTSASState *s)\n{\n    switch (s->doorbell_state) {\n    case DOORBELL_NONE:\n    case DOORBELL_WRITE:\n        s->intr_status &= ~MPI_HIS_DOORBELL_INTERRUPT;\n        break;\n\n    case DOORBELL_READ:\n        \/* The reply can be read continuously, so leave the interrupt up.  *\/\n        assert(s->intr_status & MPI_HIS_DOORBELL_INTERRUPT);\n        if (s->doorbell_reply_idx == s->doorbell_reply_size) {\n            s->doorbell_state = DOORBELL_NONE;\n        }\n        break;\n\n    default:\n        abort();\n    }\n    mptsas_update_interrupt(s);\n}\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":68484,"func":"armpmu_release_hardware(struct arm_pmu *armpmu)\n{\n\tint irq;\n\tunsigned int i, irqs;\n\tstruct platform_device *pmu_device = armpmu->plat_device;\n\n\tirqs = min(pmu_device->num_resources, num_possible_cpus());\n\tif (!irqs)\n\t\treturn;\n\n\tirq = platform_get_irq(pmu_device, 0);\n\tif (irq <= 0)\n\t\treturn;\n\n\tif (irq_is_percpu(irq)) {\n\t\ton_each_cpu(armpmu_disable_percpu_irq, &irq, 1);\n\t\tfree_percpu_irq(irq, &cpu_hw_events);\n\t} else {\n\t\tfor (i = 0; i < irqs; ++i) {\n\t\t\tif (!cpumask_test_and_clear_cpu(i, &armpmu->active_irqs))\n\t\t\t\tcontinue;\n\t\t\tirq = platform_get_irq(pmu_device, i);\n\t\t\tif (irq > 0)\n\t\t\t\tfree_irq(irq, armpmu);\n\t\t}\n\t}\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":196746,"func":"tracing_saved_cmdlines_size_write(struct file *filp, const char __user *ubuf,\n\t\t\t\t  size_t cnt, loff_t *ppos)\n{\n\tunsigned long val;\n\tint ret;\n\n\tret = kstrtoul_from_user(ubuf, cnt, 10, &val);\n\tif (ret)\n\t\treturn ret;\n\n\t\/* must have at least 1 entry or less than PID_MAX_DEFAULT *\/\n\tif (!val || val > PID_MAX_DEFAULT)\n\t\treturn -EINVAL;\n\n\tret = tracing_resize_saved_cmdlines((unsigned int)val);\n\tif (ret < 0)\n\t\treturn ret;\n\n\t*ppos += cnt;\n\n\treturn cnt;\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":227226,"func":"bool Textfield::Paste() {\n  if (!read_only() && model_->Paste()) {\n    if (controller_)\n      controller_->OnAfterPaste();\n    return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":421368,"func":"static inline bool eb_use_cmdparser(const struct i915_execbuffer *eb)\n{\n\treturn intel_engine_needs_cmd_parser(eb->engine) && eb->batch_len;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":17029,"func":"static gint dissect_gatt_uuid ( proto_tree * tree , packet_info * pinfo , tvbuff_t * tvb , gint offset ) {\n proto_item * sub_item ;\n bluetooth_uuid_t sub_uuid ;\n if ( tvb_reported_length_remaining ( tvb , offset ) == 2 ) {\n proto_tree_add_item ( tree , hf_btatt_uuid16 , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;\n sub_uuid = get_uuid ( tvb , offset , 2 ) ;\n offset += 2 ;\n }\n else if ( tvb_reported_length_remaining ( tvb , offset ) == 16 ) {\n sub_item = proto_tree_add_item ( tree , hf_btatt_uuid128 , tvb , offset , 16 , ENC_NA ) ;\n sub_uuid = get_uuid ( tvb , offset , 16 ) ;\n proto_item_append_text ( sub_item , \" (%s)\" , print_uuid ( & sub_uuid ) ) ;\n offset += 16 ;\n }\n else {\n sub_item = proto_tree_add_item ( tree , hf_btatt_value , tvb , offset , - 1 , ENC_NA ) ;\n expert_add_info ( pinfo , sub_item , & ei_btatt_bad_data ) ;\n offset = tvb_captured_length ( tvb ) ;\n }\n return offset ;\n }","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":319483,"func":"static uint64_t qemu_rdma_make_wrid(uint64_t wr_id, uint64_t index,\n\n                                         uint64_t chunk)\n\n{\n\n    uint64_t result = wr_id & RDMA_WRID_TYPE_MASK;\n\n\n\n    result |= (index << RDMA_WRID_BLOCK_SHIFT);\n\n    result |= (chunk << RDMA_WRID_CHUNK_SHIFT);\n\n\n\n    return result;\n\n}\n","target":1,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":503558,"func":"make_result(int16_t stream, messages::result_message& msg, const tracing::trace_state_ptr& tr_state,\n        cql_protocol_version_type version, bool skip_metadata) {\n    auto response = std::make_unique<cql_server::response>(stream, cql_binary_opcode::RESULT, tr_state);\n    if (__builtin_expect(!msg.warnings().empty() && version > 3, false)) {\n        response->set_frame_flag(cql_frame_flags::warning);\n        response->write_string_list(msg.warnings());\n    }\n    cql_server::fmt_visitor fmt{version, *response, skip_metadata};\n    msg.accept(fmt);\n    return response;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":131389,"func":"static int get_column_id(int num)\n{\n\tassert(num >= 0);\n\tassert((size_t) num < ncolumns);\n\tassert((size_t) columns[num] < ARRAY_SIZE(infos));\n\treturn columns[num];\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":80379,"func":"ZipFile::ZipFile (InputSource* source)  : inputSource (source)\r\n{\r\n    init();\r\n}\r","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":71766,"func":"void solo_lock_if_not_already() {\n    uint8_t buf[2048];\n\n    memmove(buf, (uint8_t*)ATTESTATION_PAGE_ADDR, 2048);\n\n    ((flash_attestation_page *)buf)->device_settings |= SOLO_FLAG_LOCKED;\n\n    flash_erase_page(ATTESTATION_PAGE);\n\n    flash_write(ATTESTATION_PAGE_ADDR, buf, 2048);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":452172,"func":"int sc_pkcs15emu_gemsafeGPK_init_ex(sc_pkcs15_card_t *p15card, struct sc_aid *aid)\n{\n\tsc_card_t   *card = p15card->card;\n\tsc_context_t    *ctx = card->ctx;\n\n\tsc_log(ctx,  \"Entering %s\", __FUNCTION__);\n\n\tif (gemsafe_detect_card(p15card))\n\t\treturn SC_ERROR_WRONG_CARD;\n\treturn sc_pkcs15emu_gemsafeGPK_init(p15card);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":422699,"func":"convert_indexed_contact_property_to_updatexml_physical_address (ESoapMessage *message,\n                                                                const gchar *name,\n                                                                const gchar *uri_element,\n                                                                const gchar *value,\n                                                                const gchar *prefix,\n                                                                const gchar *element_name,\n                                                                const gchar *key)\n{\n\tgchar * fielduri = NULL;\n\tgboolean delete_field = FALSE;\n\n\tif (!value || g_strcmp0 (value, \"\") == 0)\n\t\tdelete_field = TRUE;\n\n\tfielduri = g_strconcat (name, \":\", uri_element, NULL);\n\n\te_ews_message_start_set_indexed_item_field (message, fielduri , prefix, \"Contact\", key, delete_field);\n\n\tif (!delete_field)\n\t{\n\t\te_soap_message_start_element (message, element_name, NULL, NULL);\n\n\t\te_soap_message_start_element (message, \"Entry\", NULL, NULL);\n\t\te_soap_message_add_attribute (message, \"Key\", key, NULL, NULL);\n\t\te_ews_message_write_string_parameter (message, uri_element, NULL, value);\n\t\te_soap_message_end_element (message);\n\n\t\te_soap_message_end_element (message);\n\t}\n\te_ews_message_end_set_indexed_item_field (message, delete_field);\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":31227,"func":"static int get_nick_length ( void * data ) {\n return string_width ( ( ( NICK_REC * ) data ) -> nick , - 1 ) ;\n }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":133655,"func":"void pipe_wait(struct pipe_inode_info *pipe)\n{\n\tDEFINE_WAIT(wait);\n\n\t\/*\n\t * Pipes are system-local resources, so sleeping on them\n\t * is considered a noninteractive wait:\n\t *\/\n\tprepare_to_wait(&pipe->wait, &wait, TASK_INTERRUPTIBLE);\n\tpipe_unlock(pipe);\n\tschedule();\n\tfinish_wait(&pipe->wait, &wait);\n\tpipe_lock(pipe);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":112475,"func":"PNET_BUFFER_LIST CNBL::DetachInternalObject()\n{\n\n    \/\/ do it for both LsoV1 and LsoV2\n    if (IsLSO())\n    {\n        m_LsoInfo.LsoV1TransmitComplete.TcpPayload = m_TransferSize;\n    }\n\n    \/\/Flush changes made in LSO structures\n    NET_BUFFER_LIST_INFO(m_NBL, TcpLargeSendNetBufferListInfo) = m_LsoInfo.Value;\n\n    auto Res = m_NBL;\n    m_NBL = nullptr;\n    return Res;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":461218,"func":"autoar_extractor_set_delete_after_extraction (AutoarExtractor *self,\n                                              gboolean         delete_after_extraction)\n{\n  g_return_if_fail (AUTOAR_IS_EXTRACTOR (self));\n  self->delete_after_extraction = delete_after_extraction;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":295045,"func":"int rsi_set_antenna(struct rsi_common *common, u8 antenna)\n{\n\tstruct rsi_ant_sel_frame *ant_sel_frame;\n\tstruct sk_buff *skb;\n\n\tskb = dev_alloc_skb(FRAME_DESC_SZ);\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, FRAME_DESC_SZ);\n\n\tant_sel_frame = (struct rsi_ant_sel_frame *)skb->data;\n\tant_sel_frame->desc_dword0.frame_type = ANT_SEL_FRAME;\n\tant_sel_frame->sub_frame_type = ANTENNA_SEL_TYPE;\n\tant_sel_frame->ant_value = cpu_to_le16(antenna & ANTENNA_MASK_VALUE);\n\trsi_set_len_qno(&ant_sel_frame->desc_dword0.len_qno,\n\t\t\t0, RSI_WIFI_MGMT_Q);\n\tskb_put(skb, FRAME_DESC_SZ);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":115390,"func":"_dwarf_formsig8_internal(Dwarf_Attribute attr,\n    int formexpected,\n    Dwarf_Sig8 * returned_sig_bytes,\n    Dwarf_Error*     error)\n{\n    Dwarf_Debug dbg = 0;\n    Dwarf_CU_Context cu_context = 0;\n    Dwarf_Byte_Ptr  field_end = 0;\n    Dwarf_Byte_Ptr  section_end = 0;\n\n    int res  = get_attr_dbg(&dbg,&cu_context,attr,error);\n    if (res != DW_DLV_OK) {\n        return res;\n    }\n\n    if (attr->ar_attribute_form != formexpected) {\n        return DW_DLV_NO_ENTRY;\n    }\n    section_end =\n        _dwarf_calculate_info_section_end_ptr(cu_context);\n    field_end = attr->ar_debug_ptr + sizeof(Dwarf_Sig8);\n    if (field_end > section_end) {\n        _dwarf_error(dbg, error, DW_DLE_ATTR_FORM_OFFSET_BAD);\n        return DW_DLV_ERROR;\n    }\n\n    memcpy(returned_sig_bytes, attr->ar_debug_ptr,\n        sizeof(*returned_sig_bytes));\n    return DW_DLV_OK;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":497026,"func":"static time_t debugtime(void *unused)\n{\n  char *timestr = getenv(\"CURL_TIME\");\n  (void)unused;\n  if(timestr) {\n    curl_off_t val;\n    (void)curlx_strtoofft(timestr, NULL, 10, &val);\n\n    val += (curl_off_t)deltatime;\n    return (time_t)val;\n  }\n  return time(NULL);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":457564,"func":"ring_buffer_commit_overrun_cpu(struct trace_buffer *buffer, int cpu)\n{\n\tstruct ring_buffer_per_cpu *cpu_buffer;\n\tunsigned long ret;\n\n\tif (!cpumask_test_cpu(cpu, buffer->cpumask))\n\t\treturn 0;\n\n\tcpu_buffer = buffer->buffers[cpu];\n\tret = local_read(&cpu_buffer->commit_overrun);\n\n\treturn ret;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":281476,"func":"static bool TypeNeedsSynchronousCacheHit(Resource::Type type) {\n  if (type == Resource::kCSSStyleSheet)\n    return true;\n  if (type == Resource::kScript)\n    return true;\n  if (type == Resource::kFont)\n    return true;\n  return false;\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":17292,"func":"static inline void vc1_b_mc ( VC1Context * v , int dmv_x [ 2 ] , int dmv_y [ 2 ] , int direct , int mode ) {\n if ( v -> use_ic ) {\n v -> mv_mode2 = v -> mv_mode ;\n v -> mv_mode = MV_PMODE_INTENSITY_COMP ;\n }\n if ( direct ) {\n vc1_mc_1mv ( v , 0 ) ;\n vc1_interp_mc ( v ) ;\n if ( v -> use_ic ) v -> mv_mode = v -> mv_mode2 ;\n return ;\n }\n if ( mode == BMV_TYPE_INTERPOLATED ) {\n vc1_mc_1mv ( v , 0 ) ;\n vc1_interp_mc ( v ) ;\n if ( v -> use_ic ) v -> mv_mode = v -> mv_mode2 ;\n return ;\n }\n if ( v -> use_ic && ( mode == BMV_TYPE_BACKWARD ) ) v -> mv_mode = v -> mv_mode2 ;\n vc1_mc_1mv ( v , ( mode == BMV_TYPE_BACKWARD ) ) ;\n if ( v -> use_ic ) v -> mv_mode = v -> mv_mode2 ;\n }","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":325727,"func":"static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq)\n\n{\n\n    DeviceState *dev;\n\n    SysBusDevice *s;\n\n\n\n    qemu_check_nic_model(nd, \"cadence_gem\");\n\n    dev = qdev_create(NULL, \"cadence_gem\");\n\n    qdev_set_nic_properties(dev, nd);\n\n    qdev_init_nofail(dev);\n\n    s = SYS_BUS_DEVICE(dev);\n\n    sysbus_mmio_map(s, 0, base);\n\n    sysbus_connect_irq(s, 0, irq);\n\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":135295,"func":"void php_gd_error_ex(int type, const char *format, ...)\n{\n  va_list args;\n\n  va_start(args, format);\n  std::string msg;\n  HPHP::string_vsnprintf(msg, format, args);\n  va_end(args);\n\n  if (type == E_ERROR) {\n    HPHP::raise_error(msg);\n  } else if (type == E_WARNING) {\n    HPHP::raise_warning(msg);\n  } else if (type == E_NOTICE) {\n    HPHP::raise_notice(msg);\n  }\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":323747,"func":"static void prodsum(float *tgt, float *src, int len, int n)\n\n{\n\n    unsigned int x;\n\n    float *p1, *p2;\n\n    double sum;\n\n\n\n    while (n >= 0) {\n\n        p1 = (p2 = src) - n;\n\n        for (sum=0, x=len; x--; sum += (*p1++) * (*p2++));\n\n        tgt[n--] = sum;\n\n    }\n\n}\n","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":20658,"func":"inline int32_t http_hdr_version_get ( HTTPHdrImpl * hh ) {\n return ( hh -> m_version ) ;\n }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":328852,"func":"static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)\n\n{\n\n    int i;\n\n    int vlc    = get_bits1(&q->gb);\n\n    int start  = cplband[p->js_subband_start];\n\n    int end    = cplband[p->subbands - 1];\n\n    int length = end - start + 1;\n\n\n\n    if (start > end)\n\n        return;\n\n\n\n    if (vlc)\n\n        for (i = 0; i < length; i++)\n\n            decouple_tab[start + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2);\n\n    else\n\n        for (i = 0; i < length; i++)\n\n            decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits);\n\n}\n","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":165940,"func":"static bool ExecutePasteAndMatchStyle(LocalFrame& frame,\n                                      Event*,\n                                      EditorCommandSource source,\n                                      const String&) {\n  frame.GetEditor().PasteAsPlainText(source);\n  return true;\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":311684,"func":"bool AutofillExternalDelegate::RemoveSuggestion(const base::string16& value,\n                                                int identifier) {\n  if (identifier > 0)\n    return manager_->RemoveAutofillProfileOrCreditCard(identifier);\n\n  if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) {\n    manager_->RemoveAutocompleteEntry(query_field_.name, value);\n    return true;\n  }\n\n  return false;\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":464837,"func":"static void emit_align(u8 **pprog, u32 align)\n{\n\tu8 *target, *prog = *pprog;\n\n\ttarget = PTR_ALIGN(prog, align);\n\tif (target != prog)\n\t\temit_nops(&prog, target - prog);\n\n\t*pprog = prog;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":99339,"func":"static int __dev_close(struct net_device *dev)\n{\n\tint retval;\n\tLIST_HEAD(single);\n\n\tlist_add(&dev->close_list, &single);\n\tretval = __dev_close_many(&single);\n\tlist_del(&single);\n\n\treturn retval;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":312595,"func":"void RenderFrameHostManager::OnEnforceInsecureRequestPolicy(\n    blink::WebInsecureRequestPolicy policy) {\n  if (!SiteIsolationPolicy::AreCrossProcessFramesPossible())\n    return;\n\n  for (const auto& pair : proxy_hosts_) {\n    pair.second->Send(new FrameMsg_EnforceInsecureRequestPolicy(\n        pair.second->GetRoutingID(), policy));\n  }\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":487507,"func":"  v8::Local<v8::Value> GetTop(v8::Isolate* isolate) {\n    content::RenderFrame* render_frame;\n    if (!MaybeGetRenderFrame(isolate, \"top\", &render_frame))\n      return v8::Null(isolate);\n\n    blink::WebFrame* frame = render_frame->GetWebFrame()->Top();\n    return CreateWebFrameRenderer(isolate, frame);\n  }","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":21123,"func":"static void U_CALLCONV myMemFree ( const void * context , void * mem ) {\n char * freePtr = ( char * ) mem ;\n if ( freePtr != NULL ) {\n freePtr -= sizeof ( ctest_AlignedMemory ) ;\n }\n free ( freePtr ) ;\n }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":164112,"func":"void ExtensionUninstallObserver::Observe(\n    int type,\n    const content::NotificationSource& source,\n    const content::NotificationDetails& details) {\n  if (!automation_) {\n    delete this;\n    return;\n  }\n\n  switch (type) {\n    case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {\n      if (id_ == content::Details<extensions::Extension>(details).ptr()->id()) {\n        scoped_ptr<DictionaryValue> return_value(new DictionaryValue);\n        return_value->SetBoolean(\"success\", true);\n        AutomationJSONReply(automation_, reply_message_.release())\n            .SendSuccess(return_value.get());\n        delete this;\n        return;\n      }\n      break;\n    }\n\n    case chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED: {\n      const extensions::Extension* extension =\n          content::Details<extensions::Extension>(details).ptr();\n      if (id_ == extension->id()) {\n        scoped_ptr<DictionaryValue> return_value(new DictionaryValue);\n        return_value->SetBoolean(\"success\", false);\n        AutomationJSONReply(automation_, reply_message_.release())\n            .SendSuccess(return_value.get());\n        delete this;\n        return;\n      }\n      break;\n    }\n\n    default:\n      NOTREACHED();\n  }\n}\n","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":95214,"func":"TEST(BasicFlatBufferModel, TestWithNullVerifier) {\n  ASSERT_TRUE(FlatBufferModel::VerifyAndBuildFromFile(\n      \"tensorflow\/lite\/testdata\/test_model.bin\", nullptr));\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":191817,"func":"void DisplaySourceCustomBindings::OnCallCompleted(\n    int call_id,\n    bool success,\n    const std::string& error_message) {\n  v8::Isolate* isolate = context()->isolate();\n  ModuleSystem* module_system = context()->module_system();\n  v8::HandleScope handle_scope(isolate);\n  v8::Context::Scope context_scope(context()->v8_context());\n\n  v8::Local<v8::Value> callback_args[2];\n  callback_args[0] = v8::Integer::New(isolate, call_id);\n  if (success)\n    callback_args[1] = v8::Null(isolate);\n  else\n    callback_args[1] = v8::String::NewFromUtf8(isolate, error_message.c_str());\n\n  module_system->CallModuleMethod(\"displaySource\", \"callCompletionCallback\", 2,\n                                  callback_args);\n}\n","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":233299,"func":"void Browser::ConfirmAddSearchProvider(TemplateURL* template_url,\n                                       Profile* profile) {\n  window()->ConfirmAddSearchProvider(template_url, profile);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":444731,"func":"TEST_F(Http1ServerConnectionImplTest, PostWithContentLengthFragmentedBuffer) {\n  initialize();\n\n  InSequence sequence;\n\n  MockRequestDecoder decoder;\n  EXPECT_CALL(callbacks_, newStream(_, _)).WillOnce(ReturnRef(decoder));\n\n  TestRequestHeaderMapImpl expected_headers{\n      {\"content-length\", \"5\"}, {\":path\", \"\/\"}, {\":method\", \"POST\"}};\n  EXPECT_CALL(decoder, decodeHeaders_(HeaderMapEqual(&expected_headers), false));\n\n  Buffer::OwnedImpl expected_data1(\"12345\");\n  EXPECT_CALL(decoder, decodeData(BufferEqual(&expected_data1), false));\n\n  Buffer::OwnedImpl expected_data2;\n  EXPECT_CALL(decoder, decodeData(BufferEqual(&expected_data2), true));\n\n  Buffer::OwnedImpl buffer =\n      createBufferWithNByteSlices(\"POST \/ HTTP\/1.1\\r\\ncontent-length: 5\\r\\n\\r\\n12345\", 1);\n  auto status = codec_->dispatch(buffer);\n  EXPECT_TRUE(status.ok());\n  EXPECT_EQ(0U, buffer.length());\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":171599,"func":"static void reflectBooleanAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    V8TRYCATCH_VOID(bool, cppValue, jsValue->BooleanValue());\n    CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;\n    imp->setBooleanAttribute(HTMLNames::reflectbooleanattributeAttr, cppValue);\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":407977,"func":"(InitializerContext* context) {\n    auto& compressorRegistry = MessageCompressorRegistry::get();\n    compressorRegistry.registerImplementation(stdx::make_unique<SnappyMessageCompressor>());\n    return Status::OK();\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":240673,"func":"scoped_refptr<EntryImpl> BackendImpl::ResurrectEntry(\n    scoped_refptr<EntryImpl> deleted_entry) {\n  if (ENTRY_NORMAL == deleted_entry->entry()->Data()->state) {\n    deleted_entry = nullptr;\n    stats_.OnEvent(Stats::CREATE_MISS);\n    Trace(\"create entry miss \");\n    return NULL;\n  }\n\n\n  eviction_.OnCreateEntry(deleted_entry.get());\n  entry_count_++;\n\n  stats_.OnEvent(Stats::RESURRECT_HIT);\n  Trace(\"Resurrect entry hit \");\n  return deleted_entry;\n}\n","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":280841,"func":"void RenderFrameHostImpl::JavaScriptDialogClosed(\n    IPC::Message* reply_msg,\n    bool success,\n    const base::string16& user_input) {\n  GetProcess()->SetIgnoreInputEvents(false);\n\n  SendJavaScriptDialogReply(reply_msg, success, user_input);\n\n  for (RenderFrameHostImpl* frame = this; frame; frame = frame->GetParent()) {\n    if (frame->is_waiting_for_beforeunload_ack_ &&\n        frame->beforeunload_timeout_) {\n      frame->beforeunload_timeout_->Start(\n          TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS));\n    }\n  }\n}\n","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":165443,"func":"DocumentInit& DocumentInit::WithPreviousDocumentCSP(\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":228832,"func":"static bool isPointSkiaSafe(const SkMatrix& transform, const SkPoint& pt)\n{\n#ifdef ENSURE_VALUE_SAFETY_FOR_SKIA\n    SkPoint xPt;\n    transform.mapPoints(&xPt, &pt, 1);\n    return isCoordinateSkiaSafe(xPt.fX) && isCoordinateSkiaSafe(xPt.fY);\n#else\n    return true;\n#endif\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":365704,"func":"xrdp_mm_chan_data_in(struct trans* trans)\n{\n  struct xrdp_mm* self;\n  struct stream* s;\n  int id;\n  int size;\n  int error;\n\n  if (trans == 0)\n  {\n    return 1;\n  }\n  self = (struct xrdp_mm*)(trans->callback_data);\n  s = trans_get_in_s(trans);\n  if (s == 0)\n  {\n    return 1;\n  }\n  in_uint32_le(s, id);\n  in_uint32_le(s, size);\n  error = trans_force_read(trans, size - 8);\n  if (error == 0)\n  {\n    \/* here, the entire message block is read in, process it *\/\n    error = xrdp_mm_chan_process_msg(self, trans, s);\n  }\n  return error;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":316662,"func":"String HTMLInputElement::resultForDialogSubmit()\n{\n    return m_inputType->resultForDialogSubmit();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":221357,"func":"void GLManager::MakeCurrent() {\n  ::gles2::SetGLContext(gles2_implementation_.get());\n  if (!decoder_->MakeCurrent())\n    command_buffer_->service()->SetParseError(error::kLostContext);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":113690,"func":"get_tty_part(term_T *term)\n{\n#ifdef UNIX\n    ch_part_T\tparts[3] = {PART_IN, PART_OUT, PART_ERR};\n    int\t\ti;\n\n    for (i = 0; i < 3; ++i)\n    {\n\tint fd = term->tl_job->jv_channel->ch_part[parts[i]].ch_fd;\n\n\tif (isatty(fd))\n\t    return parts[i];\n    }\n#endif\n    return PART_IN;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":205167,"func":"int FAST_FUNC sprint_nip6(char *dest, \/*const char *pre,*\/ const uint8_t *ip)\n{\n\tchar hexstrbuf[16 * 2];\n\tbin2hex(hexstrbuf, (void*)ip, 16);\n\treturn sprintf(dest, \/* \"%s\" *\/\n\t\t\"%.4s:%.4s:%.4s:%.4s:%.4s:%.4s:%.4s:%.4s\",\n\t\t\/* pre, *\/\n\t\thexstrbuf + 0 * 4,\n\t\thexstrbuf + 1 * 4,\n\t\thexstrbuf + 2 * 4,\n\t\thexstrbuf + 3 * 4,\n\t\thexstrbuf + 4 * 4,\n\t\thexstrbuf + 5 * 4,\n\t\thexstrbuf + 6 * 4,\n\t\thexstrbuf + 7 * 4\n\t);\n}\n","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":173043,"func":"parse_SET_ETH_DST(char *arg, struct ofpbuf *ofpacts,\n                 enum ofputil_protocol *usable_protocols OVS_UNUSED)\n{\n    return str_to_mac(arg, &ofpact_put_SET_ETH_DST(ofpacts)->mac);\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":197948,"func":"ClientUsageTracker* UsageTracker::GetClientTracker(QuotaClient::ID client_id) {\n  ClientTrackerMap::iterator found = client_tracker_map_.find(client_id);\n  if (found != client_tracker_map_.end())\n    return found->second;\n  return NULL;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":89542,"func":"static void mntput_no_expire(struct mount *mnt)\n{\nput_again:\n#ifdef CONFIG_SMP\n\tbr_read_lock(&vfsmount_lock);\n\tif (likely(mnt->mnt_ns)) {\n\t\t\/* shouldn't be the last one *\/\n\t\tmnt_add_count(mnt, -1);\n\t\tbr_read_unlock(&vfsmount_lock);\n\t\treturn;\n\t}\n\tbr_read_unlock(&vfsmount_lock);\n\n\tbr_write_lock(&vfsmount_lock);\n\tmnt_add_count(mnt, -1);\n\tif (mnt_get_count(mnt)) {\n\t\tbr_write_unlock(&vfsmount_lock);\n\t\treturn;\n\t}\n#else\n\tmnt_add_count(mnt, -1);\n\tif (likely(mnt_get_count(mnt)))\n\t\treturn;\n\tbr_write_lock(&vfsmount_lock);\n#endif\n\tif (unlikely(mnt->mnt_pinned)) {\n\t\tmnt_add_count(mnt, mnt->mnt_pinned + 1);\n\t\tmnt->mnt_pinned = 0;\n\t\tbr_write_unlock(&vfsmount_lock);\n\t\tacct_auto_close_mnt(&mnt->mnt);\n\t\tgoto put_again;\n\t}\n\n\tlist_del(&mnt->mnt_instance);\n\tbr_write_unlock(&vfsmount_lock);\n\tmntfree(mnt);\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":261007,"func":"onig_st_lookup_strend(hash_table_type* table, const UChar* str_key,\n\t\t      const UChar* end_key, hash_data_type *value)\n{\n  st_str_end_key key;\n\n  key.s   = (UChar* )str_key;\n  key.end = (UChar* )end_key;\n\n  return onig_st_lookup(table, (st_data_t )(&key), value);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":36881,"func":"vips_foreign_load_gif_close( VipsForeignLoadGif *gif )\n{\n#ifdef HAVE_GIFLIB_5\n\tif( gif->file ) {\n\t\tint error; \n\n\t\tif( DGifCloseFile( gif->file, &error ) == GIF_ERROR ) \n\t\t\tvips_foreign_load_gif_error_vips( gif, error );\n\t\tgif->file = NULL;\n\t}\n#else \n\tif( gif->file ) {\n\t\tif( DGifCloseFile( gif->file ) == GIF_ERROR ) \n\t\t\tvips_foreign_load_gif_error_vips( gif, GifLastError() ); \n\t\tgif->file = NULL;\n\t}\n#endif\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":391025,"func":"static int ntop_stats_insert_hour_sampling(lua_State *vm) {\n  char *sampling;\n  time_t rawtime;\n  int ifid;\n  NetworkInterface* iface;\n  StatsManager *sm;\n\n  ntop->getTrace()->traceEvent(TRACE_INFO, \"%s() called\", __FUNCTION__);\n\n  if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER)) return(CONST_LUA_ERROR);\n  ifid = lua_tointeger(vm, 1);\n  if(ifid < 0)\n    return(CONST_LUA_ERROR);\n  if(ntop_lua_check(vm, __FUNCTION__, 2, LUA_TSTRING)) return(CONST_LUA_ERROR);\n  if((sampling = (char*)lua_tostring(vm, 2)) == NULL)  return(CONST_LUA_PARAM_ERROR);\n\n  if(!(iface = ntop->getInterfaceById(ifid)) ||\n     !(sm = iface->getStatsManager()))\n    return (CONST_LUA_ERROR);\n\n  time(&rawtime);\n  rawtime -= (rawtime % 60);\n\n  if(sm->insertHourSampling(rawtime, sampling))\n    return(CONST_LUA_ERROR);\n\n  return(CONST_LUA_OK);\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":42338,"func":"print_unix_command_map ()\n{\n  Keymap save, cmd_xmap;\n\n  save = rl_get_keymap ();\n  cmd_xmap = get_cmd_xmap_from_keymap (save);\n  rl_set_keymap (cmd_xmap);\n  rl_macro_dumper (1);\n  rl_set_keymap (save);\n  return 0;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":42313,"func":"event_name2nr(char_u *start, char_u **end)\n{\n    char_u\t*p;\n    int\t\ti;\n    int\t\tlen;\n\n    \/\/ the event name ends with end of line, '|', a blank or a comma\n    for (p = start; *p && !VIM_ISWHITE(*p) && *p != ',' && *p != '|'; ++p)\n\t;\n    for (i = 0; event_names[i].name != NULL; ++i)\n    {\n\tlen = (int)STRLEN(event_names[i].name);\n\tif (len == p - start && STRNICMP(event_names[i].name, start, len) == 0)\n\t    break;\n    }\n    if (*p == ',')\n\t++p;\n    *end = p;\n    if (event_names[i].name == NULL)\n\treturn NUM_EVENTS;\n    return event_names[i].event;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":20402,"func":"static int php_uwsgi_startup ( sapi_module_struct * sapi_module ) {\n if ( php_module_startup ( & uwsgi_sapi_module , & uwsgi_module_entry , 1 ) == FAILURE ) {\n return FAILURE ;\n }\n else {\n return SUCCESS ;\n }\n }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":477859,"func":"    CImg<T>& load_pnm(std::FILE *const file) {\n      return _load_pnm(file,0);\n    }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":463361,"func":"static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len)\n{\n\tint ret = 0;\n\tstruct adapter *padapter = rtw_netdev_priv(dev);\n\tstruct mlme_priv *pmlmepriv = &padapter->mlmepriv;\n\tstruct sta_priv *pstapriv = &padapter->stapriv;\n\tunsigned char *pbuf = param->u.bcn_ie.buf;\n\n\tDBG_88E(\"%s, len =%d\\n\", __func__, len);\n\n\tif (!check_fwstate(pmlmepriv, WIFI_AP_STATE))\n\t\treturn -EINVAL;\n\n\tmemcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2);\n\n\tif ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0))\n\t\tpstapriv->max_num_sta = NUM_STA;\n\n\tif (rtw_check_beacon_data(padapter, pbuf, len - 12 - 2) == _SUCCESS) \/* 12 = param header, 2:no packed *\/\n\t\tret = 0;\n\telse\n\t\tret = -EINVAL;\n\n\treturn ret;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":318511,"func":"int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)\n\n{\n\n    _Bool exp = 0;\n\n    if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)\n\n        return 0;\n\n\n\n    if (lockmgr_cb) {\n\n        if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))\n\n            return -1;\n\n    }\n\n\n\n    if (atomic_fetch_add(&entangled_thread_counter, 1)) {\n\n        av_log(log_ctx, AV_LOG_ERROR,\n\n               \"Insufficient thread locking. At least %d threads are \"\n\n               \"calling avcodec_open2() at the same time right now.\\n\",\n\n               atomic_load(&entangled_thread_counter));\n\n        if (!lockmgr_cb)\n\n            av_log(log_ctx, AV_LOG_ERROR, \"No lock manager is set, please see av_lockmgr_register()\\n\");\n\n        atomic_store(&ff_avcodec_locked, 1);\n\n        ff_unlock_avcodec(codec);\n\n        return AVERROR(EINVAL);\n\n    }\n\n    av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 1));\n\n    return 0;\n\n}\n","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":376626,"func":"void HGraphBuilder::GenerateMathSqrt(CallRuntime* call) {\n  return Bailout(\"inlined runtime function: MathSqrt\");\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":514587,"func":"  void MemoryInfo(MemoryTracker* tracker) const override {\n    tracker->TrackField(\"paths\", paths);\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":425774,"func":"apr_status_t h2_mplx_stream_cleanup(h2_mplx *m, h2_stream *stream)\n{\n    H2_MPLX_ENTER(m);\n    \n    ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, m->c, \n                  H2_STRM_MSG(stream, \"cleanup\"));\n    stream_cleanup(m, stream);        \n    \n    H2_MPLX_LEAVE(m);\n    return APR_SUCCESS;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":309715,"func":"RenderText* SimplifiedBackwardsTextIterator::handleFirstLetter(int& startOffset, int& offsetInNode)\n{\n    RenderText* renderer = toRenderText(m_node->renderer());\n    startOffset = (m_node == m_startNode) ? m_startOffset : 0;\n\n    if (!renderer->isTextFragment()) {\n        offsetInNode = 0;\n        return renderer;\n    }\n\n    RenderTextFragment* fragment = toRenderTextFragment(renderer);\n    int offsetAfterFirstLetter = fragment->start();\n    if (startOffset >= offsetAfterFirstLetter) {\n        ASSERT(!m_shouldHandleFirstLetter);\n        offsetInNode = offsetAfterFirstLetter;\n        return renderer;\n    }\n\n    if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) {\n        m_shouldHandleFirstLetter = true;\n        offsetInNode = offsetAfterFirstLetter;\n        return renderer;\n    }\n\n    m_shouldHandleFirstLetter = false;\n    offsetInNode = 0;\n    return firstRenderTextInFirstLetter(fragment->firstLetter());\n}\n","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":463094,"func":"        void doCheckAuthorization(OperationContext* opCtx) const final {\n            AuthorizationSession* authSession = AuthorizationSession::get(opCtx->getClient());\n\n            uassert(ErrorCodes::Unauthorized,\n                    \"Unauthorized\",\n                    authSession->isAuthorizedToParseNamespaceElement(_request.body.firstElement()));\n\n            const auto hasTerm = _request.body.hasField(kTermField);\n            uassertStatusOK(authSession->checkAuthForFind(\n                AutoGetCollection::resolveNamespaceStringOrUUID(\n                    opCtx, CommandHelpers::parseNsOrUUID(_dbName, _request.body)),\n                hasTerm));\n        }","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":515718,"func":"get_baudrate(TERMINAL *termp)\n{\n    int my_ospeed;\n    int result;\n    if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) {\n#ifdef TERMIOS\n\ttermp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);\n#else\n\ttermp->Nttyb.sg_flags &= (unsigned) (~XTABS);\n#endif\n    }\n#ifdef USE_OLD_TTY\n    result = (int) cfgetospeed(&(termp->Nttyb));\n    my_ospeed = (NCURSES_OSPEED) _nc_ospeed(result);\n#else \/* !USE_OLD_TTY *\/\n#ifdef TERMIOS\n    my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb));\n#else\n    my_ospeed = (NCURSES_OSPEED) termp->Nttyb.sg_ospeed;\n#endif\n    result = _nc_baudrate(my_ospeed);\n#endif\n    termp->_baudrate = result;\n    ospeed = (NCURSES_OSPEED) my_ospeed;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":310335,"func":" int ProfileChooserView::GetDiceSigninPromoShowCount() const {\n  return browser_->profile()->GetPrefs()->GetInteger(\n      prefs::kDiceSigninUserMenuPromoCount);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":153578,"func":"int do_journal_get_write_access(handle_t *handle,\n\t\t\t\tstruct buffer_head *bh)\n{\n\tint dirty = buffer_dirty(bh);\n\tint ret;\n\n\tif (!buffer_mapped(bh) || buffer_freed(bh))\n\t\treturn 0;\n\t\/*\n\t * __block_write_begin() could have dirtied some buffers. Clean\n\t * the dirty bit as jbd2_journal_get_write_access() could complain\n\t * otherwise about fs integrity issues. Setting of the dirty bit\n\t * by __block_write_begin() isn't a real problem here as we clear\n\t * the bit before releasing a page lock and thus writeback cannot\n\t * ever write the buffer.\n\t *\/\n\tif (dirty)\n\t\tclear_buffer_dirty(bh);\n\tBUFFER_TRACE(bh, \"get write access\");\n\tret = ext4_journal_get_write_access(handle, bh);\n\tif (!ret && dirty)\n\t\tret = ext4_handle_dirty_metadata(handle, NULL, bh);\n\treturn ret;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":328056,"func":"static void tlb_unprotect_code_phys(CPUState *env, ram_addr_t ram_addr,\n\n                                    target_ulong vaddr)\n\n{\n\n    phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] |= CODE_DIRTY_FLAG;\n\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":515834,"func":"lookup_user_capability(const char *name)\n{\n    struct user_table_entry const *result = 0;\n    if (*name != 'k') {\n\tresult = _nc_find_user_entry(name);\n    }\n    return result;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":327687,"func":"static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){\n\n    int64_t pos = avio_tell(pb);\n\n    avio_wb32(pb, 0);                              \/* size *\/\n\n    ffio_wfourcc(pb, \"name\");                      \/* Data format *\/\n\n    avio_wb16(pb, strlen(reel_name));              \/* string size *\/\n\n    avio_wb16(pb, track->language);                \/* langcode *\/\n\n    avio_write(pb, reel_name, strlen(reel_name));  \/* reel name *\/\n\n    return update_size(pb,pos);\n\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":402298,"func":"static void xhci_reset_streams(XHCIEPContext *epctx)\n{\n    unsigned int i;\n\n    for (i = 0; i < epctx->nr_pstreams; i++) {\n        epctx->pstreams[i].sct = -1;\n    }\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":422232,"func":"ews_backend_sync_deleted_folders (EEwsBackend *backend,\n                                  GSList *list)\n{\n\tGSList *link;\n\n\tfor (link = list; link != NULL; link = g_slist_next (link)) {\n\t\tconst gchar *folder_id = link->data;\n\t\tESource *source = NULL;\n\n\t\tif (folder_id != NULL)\n\t\t\tsource = ews_backend_folders_lookup (\n\t\t\t\tbackend, folder_id);\n\n\t\tif (source == NULL)\n\t\t\tcontinue;\n\n\t\t\/* This will trigger a \"child-removed\" signal and\n\t\t * our handler will remove the hash table entry. *\/\n\t\te_source_remove_sync (source, NULL, NULL);\n\n\t\tg_object_unref (source);\n\t}\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":146661,"func":"aff_check_number(int spinval, int affval, char *name)\n{\n    if (spinval != 0 && spinval != affval)\n\tsmsg(_(\"%s value differs from what is used in another .aff file\"), name);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":393885,"func":"dissect_rpcap_open_reply (tvbuff_t *tvb, packet_info *pinfo _U_,\n                          proto_tree *parent_tree, gint offset)\n{\n  proto_tree *tree;\n  proto_item *ti;\n\n  ti = proto_tree_add_item (parent_tree, hf_open_reply, tvb, offset, -1, ENC_NA);\n  tree = proto_item_add_subtree (ti, ett_open_reply);\n\n  linktype = tvb_get_ntohl (tvb, offset);\n  proto_tree_add_item (tree, hf_linktype, tvb, offset, 4, ENC_BIG_ENDIAN);\n  offset += 4;\n\n  proto_tree_add_item (tree, hf_tzoff, tvb, offset, 4, ENC_BIG_ENDIAN);\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":204231,"func":"void RunLoop::AfterRun() {\n  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);\n\n  running_ = false;\n\n  auto& active_run_loops_ = delegate_->active_run_loops_;\n  DCHECK_EQ(active_run_loops_.top(), this);\n  active_run_loops_.pop();\n\n  RunLoop* previous_run_loop =\n      active_run_loops_.empty() ? nullptr : active_run_loops_.top();\n\n  if (previous_run_loop && previous_run_loop->quit_called_)\n    delegate_->Quit();\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":453686,"func":"bootParameterValidate(\n\tSyntax *syntax,\n\tstruct berval *val )\n{\n\tchar *p, *e;\n\n\tif ( BER_BVISEMPTY( val ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tp = (char *)val->bv_val;\n\te = p + val->bv_len;\n\n\t\/* key *\/\n\tfor (; ( p < e ) && ( *p != '=' ); p++ ) {\n\t\tif ( !AD_CHAR( *p ) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\tif ( *p != '=' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* server *\/\n\tfor ( p++; ( p < e ) && ( *p != ':' ); p++ ) {\n\t\tif ( !AD_CHAR( *p ) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\tif ( *p != ':' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* path *\/\n\tfor ( p++; p < e; p++ ) {\n\t\tif ( !SLAP_PRINTABLE( *p ) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":265804,"func":"term_write_session(FILE *fd, win_T *wp)\n{\n    term_T *term = wp->w_buffer->b_term;\n\n    \/* Create the terminal and run the command.  This is not without\n     * risk, but let's assume the user only creates a session when this\n     * will be OK. *\/\n    if (fprintf(fd, \"terminal ++curwin ++cols=%d ++rows=%d \",\n\t\tterm->tl_cols, term->tl_rows) < 0)\n\treturn FAIL;\n    if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0)\n\treturn FAIL;\n\n    return put_eol(fd);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":242798,"func":"static void btif_in_split_uuids_string_to_list(char *str, bt_uuid_t *p_uuid,\n uint32_t *p_num_uuid)\n{\n char buf[64];\n char *p_start = str;\n char *p_needle;\n uint32_t num = 0;\n do\n {\n        p_needle = strchr(p_start, ' ');\n if (p_needle < p_start) break;\n        memset(buf, 0, sizeof(buf));\n        strncpy(buf, p_start, (p_needle-p_start));\n        string_to_uuid(buf, p_uuid + num);\n        num++;\n        p_start = ++p_needle;\n\n } while (*p_start != 0);\n *p_num_uuid = num;\n}\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":377234,"func":"static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t sector_num,\n                                      int nb_sectors, QEMUIOVector *iov,\n                                      bool is_write)\n{\n    CoroutineIOCompletion co = {\n        .coroutine = qemu_coroutine_self(),\n    };\n    BlockDriverAIOCB *acb;\n\n    if (is_write) {\n        acb = bs->drv->bdrv_aio_writev(bs, sector_num, iov, nb_sectors,\n                                       bdrv_co_io_em_complete, &co);\n    } else {\n        acb = bs->drv->bdrv_aio_readv(bs, sector_num, iov, nb_sectors,\n                                      bdrv_co_io_em_complete, &co);\n    }\n\n    trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);\n    if (!acb) {\n        return -EIO;\n    }\n    qemu_coroutine_yield();\n\n    return co.ret;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":164262,"func":" PrintPreviewUI::~PrintPreviewUI() {\n  print_preview_data_service()->RemoveEntry(id_);\n  g_print_preview_request_id_map.Get().Erase(id_);\n  g_print_preview_ui_id_map.Get().Remove(id_);\n }\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":371036,"func":"int LibRaw::adjust_maximum()\n{\n    int i;\n    ushort real_max;\n    float  auto_threshold;\n\n    if(O.adjust_maximum_thr < 0.00001)\n        return LIBRAW_SUCCESS;\n    else if (O.adjust_maximum_thr > 0.99999)\n        auto_threshold = LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD;\n    else\n        auto_threshold = O.adjust_maximum_thr;\n        \n    \n    real_max = C.channel_maximum[0];\n    for(i = 1; i< 4; i++)\n        if(real_max < C.channel_maximum[i])\n            real_max = C.channel_maximum[i];\n\n    if (real_max > 0 && real_max < C.maximum && real_max > C.maximum* auto_threshold)\n        {\n            C.maximum = real_max;\n        }\n    return LIBRAW_SUCCESS;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":401863,"func":"ZEND_VM_COLD_CONST_HANDLER(14, ZEND_BOOL_NOT, CONST|TMPVAR|CV, ANY)\n{\n\tUSE_OPLINE\n\tzval *val;\n\tzend_free_op free_op1;\n\n\tval = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);\n\tif (Z_TYPE_INFO_P(val) == IS_TRUE) {\n\t\tZVAL_FALSE(EX_VAR(opline->result.var));\n\t} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {\n\t\t\/* The result and op1 can be the same cv zval *\/\n\t\tconst uint32_t orig_val_type = Z_TYPE_INFO_P(val);\n\t\tZVAL_TRUE(EX_VAR(opline->result.var));\n\t\tif (OP1_TYPE == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {\n\t\t\tSAVE_OPLINE();\n\t\t\tZVAL_UNDEFINED_OP1();\n\t\t\tZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();\n\t\t}\n\t} else {\n\t\tSAVE_OPLINE();\n\t\tZVAL_BOOL(EX_VAR(opline->result.var), !i_zend_is_true(val));\n\t\tFREE_OP1();\n\t\tZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();\n\t}\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":244535,"func":"void InputConnectionImpl::StartStateUpdateTimer() {\n  state_update_timer_.Start(\n      FROM_HERE, kStateUpdateTimeout,\n      base::BindOnce(&InputConnectionImpl::UpdateTextInputState,\n                     base::Unretained(this),\n                     true \/* is_input_state_update_requested *\/));\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":143716,"func":"    SegmentBTreeRoot * JavascriptArray::GetSegmentMap() const\n    {\n        return (HasSegmentMap() ? segmentUnion.segmentBTreeRoot : nullptr);\n    }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":385620,"func":"PHP_FUNCTION(pcntl_getpriority)\n{\n\tlong who = PRIO_PROCESS;\n\tlong pid = getpid();\n\tint pri;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"|ll\", &pid, &who) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* needs to be cleared, since any returned value is valid *\/\n\terrno = 0;\n\n\tpri = getpriority(who, pid);\n\n\tif (errno) {\n\t\tPCNTL_G(last_error) = errno;\n\t\tswitch (errno) {\n\t\t\tcase ESRCH:\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Error %d: No process was located using the given parameters\", errno);\n\t\t\t\tbreak;\n\t\t\tcase EINVAL:\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Error %d: Invalid identifier flag\", errno);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown error %d has occurred\", errno);\n\t\t\t\tbreak;\n\t\t}\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_LONG(pri);\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":165081,"func":"findCursorHideCount(ClientPtr pClient, ScreenPtr pScreen)\n{\n    CursorScreenPtr cs = GetCursorScreen(pScreen);\n    CursorHideCountPtr pChc;\n\n    for (pChc = cs->pCursorHideCounts; pChc != NULL; pChc = pChc->pNext) {\n        if (pChc->pClient == pClient) {\n            return pChc;\n        }\n    }\n\n    return NULL;\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":199955,"func":"gfx::Size WebContentsImpl::GetSizeForNewRenderView(bool is_main_frame) {\n  gfx::Size size;\n  if (is_main_frame)\n    size = device_emulation_size_;\n  if (size.IsEmpty() && delegate_)\n    size = delegate_->GetSizeForNewRenderView(this);\n  if (size.IsEmpty())\n    size = GetContainerBounds().size();\n  return size;\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":34827,"func":"static int use_db(char *database)\n{\n  if (mysql_get_server_version(sock) >= FIRST_INFORMATION_SCHEMA_VERSION &&\n      !my_strcasecmp(&my_charset_latin1, database, INFORMATION_SCHEMA_DB_NAME))\n    return 1;\n  if (mysql_get_server_version(sock) >= FIRST_PERFORMANCE_SCHEMA_VERSION &&\n      !my_strcasecmp(&my_charset_latin1, database, PERFORMANCE_SCHEMA_DB_NAME))\n    return 1;\n  if (mysql_select_db(sock, database))\n  {\n    DBerror(sock, \"when selecting the database\");\n    return 1;\n  }\n  return 0;\n} \/* use_db *\/","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":295759,"func":"static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmode, struct nfs4_state **res)\n{\n\tstruct nfs4_state *newstate;\n\tint ret;\n\n\topendata->o_arg.open_flags = 0;\n\topendata->o_arg.fmode = fmode;\n\tmemset(&opendata->o_res, 0, sizeof(opendata->o_res));\n\tmemset(&opendata->c_res, 0, sizeof(opendata->c_res));\n\tnfs4_init_opendata_res(opendata);\n\tret = _nfs4_proc_open(opendata);\n\tif (ret != 0)\n\t\treturn ret; \n\tnewstate = nfs4_opendata_to_nfs4_state(opendata);\n\tif (IS_ERR(newstate))\n\t\treturn PTR_ERR(newstate);\n\tnfs4_close_state(&opendata->path, newstate, fmode);\n\t*res = newstate;\n\treturn 0;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":318414,"func":"av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)\n\n{\n\n    afq->avctx             = avctx;\n\n    afq->next_pts          = AV_NOPTS_VALUE;\n\n    afq->remaining_delay   = avctx->delay;\n\n    afq->remaining_samples = avctx->delay;\n\n    afq->frame_queue       = NULL;\n\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":434204,"func":"number_format(int value)\n{\n    const char *result = \"%d\";\n    if ((outform != F_TERMCAP) && (value > 255)) {\n\tunsigned long lv = (unsigned long) value;\n\tunsigned long mm;\n\tint bits = sizeof(unsigned long) * 8;\n\tint nn;\n\tfor (nn = 8; nn < bits; ++nn) {\n\t    mm = 1UL << nn;\n\t    if ((mm - 16) <= lv && (mm + 16) > lv) {\n\t\tresult = \"%#x\";\n\t\tbreak;\n\t    }\n\t}\n    }\n    return result;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":338718,"func":"int swr_convert_frame(SwrContext *s,\n\n                      AVFrame *out, const AVFrame *in)\n\n{\n\n    int ret, setup = 0;\n\n\n\n    if (!swr_is_initialized(s)) {\n\n        if ((ret = swr_config_frame(s, out, in)) < 0)\n\n            return ret;\n\n        if ((ret = swr_init(s)) < 0)\n\n            return ret;\n\n        setup = 1;\n\n    } else {\n\n        \/\/ return as is or reconfigure for input changes?\n\n        if ((ret = config_changed(s, out, in)))\n\n            return ret;\n\n    }\n\n\n\n    if (out) {\n\n        if (!out->linesize[0]) {\n\n            out->nb_samples =   swr_get_delay(s, s->out_sample_rate)\n\n                              + in->nb_samples*(int64_t)s->out_sample_rate \/ s->in_sample_rate\n\n                              + 3;\n\n            if ((ret = av_frame_get_buffer(out, 0)) < 0) {\n\n                if (setup)\n\n                    swr_close(s);\n\n                return ret;\n\n            }\n\n        } else {\n\n            if (!out->nb_samples)\n\n                out->nb_samples = available_samples(out);\n\n        }\n\n    }\n\n\n\n    return convert_frame(s, out, in);\n\n}\n","target":1,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":214065,"func":"void Dispatcher::OnCancelSuspend(const std::string& extension_id) {\n  DispatchEvent(extension_id, kOnSuspendCanceledEvent);\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":378622,"func":"static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)\n{\n\treturn listxattr(path, list, size);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":333138,"func":"static gsize calc_float_string_storage(double value)\n\n{\n\n    int whole_value = value;\n\n    gsize i = 0;\n\n    do {\n\n        i++;\n\n    } while (whole_value \/= 10);\n\n    return i + 2 + FLOAT_STRING_PRECISION;\n\n}\n","target":1,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":173960,"func":"bool NetworkThrottleManagerImpl::ThrottleImpl::IsBlocked() const {\n  return state_ == State::BLOCKED;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":507457,"func":"ASN1_INTEGER *TS_ACCURACY_get_micros(TS_ACCURACY *a)\n\t{\n\treturn a->micros;\n\t}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":414072,"func":"int wmi_set_mgmt_retry(struct wil6210_priv *wil, u8 retry_short)\n{\n\tint rc;\n\tstruct wmi_set_mgmt_retry_limit_cmd cmd = {\n\t\t.mgmt_retry_limit = retry_short,\n\t};\n\tstruct {\n\t\tstruct wmi_cmd_hdr wmi;\n\t\tstruct wmi_set_mgmt_retry_limit_event evt;\n\t} __packed reply;\n\n\twil_dbg_wmi(wil, \"Setting mgmt retry short %d\\n\", retry_short);\n\n\tif (!test_bit(WMI_FW_CAPABILITY_MGMT_RETRY_LIMIT, wil->fw_capabilities))\n\t\treturn -ENOTSUPP;\n\n\treply.evt.status = WMI_FW_STATUS_FAILURE;\n\n\trc = wmi_call(wil, WMI_SET_MGMT_RETRY_LIMIT_CMDID, &cmd, sizeof(cmd),\n\t\t      WMI_SET_MGMT_RETRY_LIMIT_EVENTID, &reply, sizeof(reply),\n\t\t      100);\n\tif (rc)\n\t\treturn rc;\n\n\tif (reply.evt.status != WMI_FW_STATUS_SUCCESS) {\n\t\twil_err(wil, \"set mgmt retry limit failed with status %d\\n\",\n\t\t\treply.evt.status);\n\t\trc = -EINVAL;\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":46246,"func":"START_TEST(single_quote_string)\n\n{\n\n    int i;\n\n    struct {\n\n        const char *encoded;\n\n        const char *decoded;\n\n    } test_cases[] = {\n\n        { \"'hello world'\", \"hello world\" },\n\n        { \"'the quick brown fox \\\\' jumped over the fence'\",\n\n          \"the quick brown fox ' jumped over the fence\" },\n\n        {}\n\n    };\n\n\n\n    for (i = 0; test_cases[i].encoded; i++) {\n\n        QObject *obj;\n\n        QString *str;\n\n\n\n        obj = qobject_from_json(test_cases[i].encoded);\n\n\n\n        fail_unless(obj != NULL);\n\n        fail_unless(qobject_type(obj) == QTYPE_QSTRING);\n\n        \n\n        str = qobject_to_qstring(obj);\n\n        fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);\n\n\n\n        QDECREF(str);\n\n    }\n\n}\n","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":413708,"func":"allocateHeader(FileInfo *nested, TranslationTableHeader **table) {\n\t\/* Allocate memory for the table header and a guess on the number of\n\t * rules *\/\n\tconst TranslationTableOffset startSize = 2 * sizeof(**table);\n\tif (*table) return 1;\n\ttableUsed = sizeof(**table) + OFFSETSIZE; \/* So no offset is ever zero *\/\n\tif (!(*table = malloc(startSize))) {\n\t\tcompileError(nested, \"Not enough memory\");\n\t\tif (*table != NULL) free(*table);\n\t\t*table = NULL;\n\t\t_lou_outOfMemory();\n\t}\n\tmemset(*table, 0, startSize);\n\ttableSize = startSize;\n\treturn 1;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":139436,"func":"static int is_non_fatal(int lib_error_code) {\n  return lib_error_code < 0 && lib_error_code > NGHTTP2_ERR_FATAL;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":200556,"func":"void WebPage::popupClosed()\n{\n    ASSERT(d->m_selectPopup);\n    d->m_selectPopup = 0;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":233927,"func":"http_process(struct vtclog *vl, const char *spec, int sock, int *sfd)\n{\n\tstruct http *hp;\n\tchar *s, *q;\n\tint retval;\n\n\t(void)sfd;\n\tALLOC_OBJ(hp, HTTP_MAGIC);\n\tAN(hp);\n\thp->fd = sock;\n\thp->timeout = 15000;\n\thp->nrxbuf = 2048*1024;\n\thp->vsb = VSB_new_auto();\n\thp->rxbuf = malloc(hp->nrxbuf);\t\t\/* XXX *\/\n\thp->sfd = sfd;\n\thp->vl = vl;\n\thp->gziplevel = 0;\n\thp->gzipresidual = -1;\n\tAN(hp->rxbuf);\n\tAN(hp->vsb);\n\n\ts = strdup(spec);\n\tq = strchr(s, '\\0');\n\tassert(q > s);\n\tAN(s);\n\tparse_string(s, http_cmds, hp, vl);\n\tretval = hp->fd;\n\tVSB_delete(hp->vsb);\n\tfree(hp->rxbuf);\n\tfree(hp);\n\treturn (retval);\n}\n","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":403568,"func":"acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)\n{\n\tstruct acpi_madt_local_x2apic *processor = NULL;\n\tint apic_id;\n\tu8 enabled;\n\n\tprocessor = (struct acpi_madt_local_x2apic *)header;\n\n\tif (BAD_MADT_ENTRY(processor, end))\n\t\treturn -EINVAL;\n\n\tacpi_table_print_madt_entry(header);\n\n\tapic_id = processor->local_apic_id;\n\tenabled = processor->lapic_flags & ACPI_MADT_ENABLED;\n#ifdef CONFIG_X86_X2APIC\n\t\/*\n\t * We need to register disabled CPU as well to permit\n\t * counting disabled CPUs. This allows us to size\n\t * cpus_possible_map more accurately, to permit\n\t * to not preallocating memory for all NR_CPUS\n\t * when we use CPU hotplug.\n\t *\/\n\tif (!apic->apic_id_valid(apic_id) && enabled)\n\t\tprintk(KERN_WARNING PREFIX \"x2apic entry ignored\\n\");\n\telse\n\t\tacpi_register_lapic(apic_id, processor->uid, enabled);\n#else\n\tprintk(KERN_WARNING PREFIX \"x2apic entry ignored\\n\");\n#endif\n\n\treturn 0;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":265993,"func":"trigger_set_xy(int trigger_index, int x, int y)\n{\n\tstruct map_trigger* trigger;\n\n\ttrigger = vector_get(s_map->triggers, trigger_index);\n\ttrigger->x = x;\n\ttrigger->y = y;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":259296,"func":"int SPIFFEValidator::initializeSslContexts(std::vector<SSL_CTX*>, bool) {\n  return SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":334897,"func":"static void pflash_timer (void *opaque)\n\n{\n\n    pflash_t *pfl = opaque;\n\n\n\n    DPRINTF(\"%s: command %02x done\\n\", __func__, pfl->cmd);\n\n    \/* Reset flash *\/\n\n    pfl->status ^= 0x80;\n\n    if (pfl->bypass) {\n\n        pfl->wcycle = 2;\n\n    } else {\n\n        memory_region_rom_device_set_readable(&pfl->mem, true);\n\n        pfl->wcycle = 0;\n\n    }\n\n    pfl->cmd = 0;\n\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":134033,"func":"static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,\n\t\t\t\t  int len, u32 dst)\n{\n\tstruct rpmsg_device *rpdev = ept->rpdev;\n\tu32 src = ept->addr;\n\n\treturn rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":268762,"func":"struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,\n\t\t\t\t\t const union tcp_md5_addr *addr,\n\t\t\t\t\t int family)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tstruct tcp_md5sig_key *key;\n\tunsigned int size = sizeof(struct in_addr);\n\tconst struct tcp_md5sig_info *md5sig;\n\n\t\/* caller either holds rcu_read_lock() or socket lock *\/\n\tmd5sig = rcu_dereference_check(tp->md5sig_info,\n\t\t\t\t       lockdep_sock_is_held(sk));\n\tif (!md5sig)\n\t\treturn NULL;\n#if IS_ENABLED(CONFIG_IPV6)\n\tif (family == AF_INET6)\n\t\tsize = sizeof(struct in6_addr);\n#endif\n\thlist_for_each_entry_rcu(key, &md5sig->head, node) {\n\t\tif (key->family != family)\n\t\t\tcontinue;\n\t\tif (!memcmp(&key->addr, addr, size))\n\t\t\treturn key;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":126425,"func":"void AxoGluonArc(double *args)\n{\n        SetLineWidth(axolinewidth + args[7]);\n    if ( args[9] ) {    \/* Clockwise *\/\n        double a = args[3]; args[3] = args[4]; args[4] = a;\n    }\n    if ( args[8] ) {  \/* Dashes *\/\n        args[7] = args[8];\n        DashGluonArc(args);\n    }\n    else {\n            GluonArc(args);\n    }\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":136710,"func":"static VALUE cState_aref(VALUE self, VALUE name)\n{\n    name = rb_funcall(name, i_to_s, 0);\n    if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {\n        return rb_funcall(self, i_send, 1, name);\n    } else {\n        return rb_ivar_get(self, rb_intern_str(rb_str_concat(rb_str_new2(\"@\"), name)));\n    }\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":46503,"func":"bool Jsi_ValueIsUndef(Jsi_Interp *interp, Jsi_Value *pv)\n{\n    return (pv->vt == JSI_VT_UNDEF);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":286188,"func":"static void copy_asoundrc(void) {\n\tchar *src = RUN_ASOUNDRC_FILE ;\n\tchar *dest;\n\tif (asprintf(&dest, \"%s\/.asoundrc\", cfg.homedir) == -1)\n\t\terrExit(\"asprintf\");\n\t\n\tif (is_link(dest)) {\n\t\tfprintf(stderr, \"Error: %s is a symbolic link\\n\", dest);\n\t\texit(1);\n\t}\n\n\tcopy_file_as_user(src, dest, getuid(), getgid(), S_IRUSR | S_IWUSR);\n\tfs_logger2(\"clone\", dest);\n\n\tunlink(src);\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":238958,"func":"static bool isCandidateForOpaquenessTest(RenderBox* childBox)\n{\n    RenderStyle* childStyle = childBox->style();\n    if (childStyle->position() != StaticPosition && childBox->containingBlock() != childBox->parent())\n        return false;\n    if (childStyle->visibility() != VISIBLE || childStyle->shapeOutside())\n        return false;\n    if (!childBox->width() || !childBox->height())\n        return false;\n    if (RenderLayer* childLayer = childBox->layer()) {\n        if (childLayer->compositingState() != NotComposited)\n            return false;\n        if (!childStyle->hasAutoZIndex())\n            return false;\n        if (childLayer->hasTransform() || childLayer->isTransparent() || childLayer->hasFilter())\n            return false;\n        if (childBox->hasOverflowClip() && childStyle->hasBorderRadius())\n            return false;\n    }\n    return true;\n}\n","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":455710,"func":"TEST_F(QueryPlannerTest, MultikeyDoubleDottedElemMatch) {\n    \/\/ true means multikey\n    addIndex(BSON(\"a.b.x\" << 1 << \"a.b.y\" << 1), true);\n    runQuery(fromjson(\"{a: {$elemMatch: {b: {$elemMatch: {x: 1, y: 1}}}}}\"));\n\n    assertNumSolutions(2U);\n    assertSolutionExists(\"{cscan: {dir: 1}}\");\n    assertSolutionExists(\n        \"{fetch: {node: {ixscan: {pattern: {'a.b.x':1,'a.b.y':1}, bounds: \"\n        \"{'a.b.x': [[1,1,true,true]], \"\n        \" 'a.b.y': [[1,1,true,true]]}}}}}\");\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":490695,"func":"storageVolDelete(virStorageVolPtr vol,\n                 unsigned int flags)\n{\n    virStoragePoolObj *obj;\n    virStorageBackend *backend;\n    virStorageVolDef *voldef = NULL;\n    int ret = -1;\n\n    if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))\n        return -1;\n\n    if (virStorageVolDeleteEnsureACL(vol->conn, virStoragePoolObjGetDef(obj),\n                                     voldef) < 0)\n        goto cleanup;\n\n    if (voldef->in_use) {\n        virReportError(VIR_ERR_OPERATION_INVALID,\n                       _(\"volume '%s' is still in use.\"),\n                       voldef->name);\n        goto cleanup;\n    }\n\n    if (voldef->building) {\n        virReportError(VIR_ERR_OPERATION_INVALID,\n                       _(\"volume '%s' is still being allocated.\"),\n                       voldef->name);\n        goto cleanup;\n    }\n\n    if (storageVolDeleteInternal(backend, obj, voldef, flags, true) < 0)\n        goto cleanup;\n\n    ret = 0;\n\n cleanup:\n    virStoragePoolObjEndAPI(&obj);\n    return ret;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":423987,"func":"free_tree (void *extra, bin_tree_t *node)\n{\n  free_token (&node->token);\n  return REG_NOERROR;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":199137,"func":"static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring)\n{\n  unsigned error = 0;\n  size_t i;\n  ucvector text;\n  ucvector_init(&text);\n  for(i = 0; keyword[i] != 0; i++) ucvector_push_back(&text, (unsigned char)keyword[i]);\n  if(i < 1 || i > 79) return 89; \/*error: invalid keyword size*\/\n  ucvector_push_back(&text, 0); \/*0 termination char*\/\n  for(i = 0; textstring[i] != 0; i++) ucvector_push_back(&text, (unsigned char)textstring[i]);\n  error = addChunk(out, \"tEXt\", text.data, text.size);\n  ucvector_cleanup(&text);\n\n  return error;\n}\n","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":510827,"func":"inline bool Http2Session::CanAddStream() {\n  uint32_t maxConcurrentStreams =\n      nghttp2_session_get_local_settings(\n          session_, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS);\n  size_t maxSize =\n      std::min(streams_.max_size(), static_cast<size_t>(maxConcurrentStreams));\n  \/\/ We can add a new stream so long as we are less than the current\n  \/\/ maximum on concurrent streams\n  return streams_.size() < maxSize;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":277935,"func":"void Document::ViewportDefiningElementDidChange() {\n  HTMLBodyElement* body = FirstBodyElement();\n  if (!body)\n    return;\n  if (body->NeedsReattachLayoutTree())\n    return;\n  LayoutObject* layout_object = body->GetLayoutObject();\n  if (layout_object && layout_object->IsLayoutBlock()) {\n    layout_object->SetStyle(ComputedStyle::Clone(*layout_object->Style()));\n    if (layout_object->HasLayer()) {\n      ToLayoutBoxModelObject(layout_object)\n          ->Layer()\n          ->SetNeedsCompositingReasonsUpdate();\n    }\n  }\n}\n","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":20619,"func":"static int dissect_h225_INTEGER_0_65535 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 0U , 65535U , NULL , FALSE ) ;\n return offset ;\n }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":171627,"func":"void PepperPlatformAudioInput::StopCapture() {\n  DCHECK(main_message_loop_proxy_->BelongsToCurrentThread());\n\n  io_message_loop_proxy_->PostTask(\n      FROM_HERE,\n      base::Bind(&PepperPlatformAudioInput::StopCaptureOnIOThread, this));\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":236718,"func":"void RenderView::ShowModalHTMLDialogForPlugin(\n    const GURL& url,\n    const gfx::Size& size,\n    const std::string& json_arguments,\n    std::string* json_retval) {\n  SendAndRunNestedMessageLoop(new ViewHostMsg_ShowModalHTMLDialog(\n      routing_id_, url, size.width(), size.height(), json_arguments,\n      json_retval));\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":274425,"func":"static inline spinlock_t *pmd_lockptr(struct mm_struct *mm, pmd_t *pmd)\n{\n\treturn ptlock_ptr(pmd_to_page(pmd));\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":187344,"func":"  void ReportResultsIfComplete() {\n    CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));\n\n    if (!icon_decode_complete_ || !manifest_parse_complete_)\n      return;\n\n    utility_host_->EndBatchMode();\n    utility_host_ = NULL;\n\n    BrowserThread::PostTask(\n        BrowserThread::UI,\n        FROM_HERE,\n        NewRunnableMethod(this,\n                          &SafeBeginInstallHelper::ReportResultFromUIThread));\n  }\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":176255,"func":"FrameFetchContext::GetPreviewsResourceLoadingHints() const {\n  if (IsDetached())\n    return nullptr;\n  DocumentLoader* document_loader = MasterDocumentLoader();\n  if (!document_loader)\n    return nullptr;\n  return document_loader->GetPreviewsResourceLoadingHints();\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":500855,"func":"GF_Err mvcg_box_size(GF_Box *s)\n{\n\tu32 i;\n\tGF_MultiviewGroupBox *ptr = (GF_MultiviewGroupBox *) s;\n\n\tptr->size += 7;\n\tfor (i=0; i<ptr->num_entries; i++) {\n\t\tswitch (ptr->entries[i].entry_type) {\n\t\tcase 0:\n\t\t\tptr->size += 1 + 4;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tptr->size += 1 + 6;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tptr->size += 1 + 2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tptr->size += 1 + 4;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":245487,"func":" void set_num_buffers(int num_buffers) { num_buffers_ = num_buffers; }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":414764,"func":"static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,\n\t\t\t\t\t\t\tktime_t now)\n{\n\tstruct k_itimer *ptr = container_of(alarm, struct k_itimer,\n\t\t\t\t\t    it.alarm.alarmtimer);\n\tenum alarmtimer_restart result = ALARMTIMER_NORESTART;\n\tunsigned long flags;\n\tint si_private = 0;\n\n\tspin_lock_irqsave(&ptr->it_lock, flags);\n\n\tptr->it_active = 0;\n\tif (ptr->it_interval)\n\t\tsi_private = ++ptr->it_requeue_pending;\n\n\tif (posix_timer_event(ptr, si_private) && ptr->it_interval) {\n\t\t\/*\n\t\t * Handle ignored signals and rearm the timer. This will go\n\t\t * away once we handle ignored signals proper.\n\t\t *\/\n\t\tptr->it_overrun += alarm_forward_now(alarm, ptr->it_interval);\n\t\t++ptr->it_requeue_pending;\n\t\tptr->it_active = 1;\n\t\tresult = ALARMTIMER_RESTART;\n\t}\n\tspin_unlock_irqrestore(&ptr->it_lock, flags);\n\n\treturn result;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":428789,"func":"XML_SetReturnNSTriplet(XML_Parser parser, int do_nst)\n{\n  if (parser == NULL)\n    return;\n  \/* block after XML_Parse()\/XML_ParseBuffer() has been called *\/\n  if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED)\n    return;\n  parser->m_ns_triplets = do_nst ? XML_TRUE : XML_FALSE;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":75503,"func":"rend_service_derive_key_digests(struct rend_service_t *s)\n{\n  if (rend_get_service_id(s->private_key, s->service_id)<0) {\n    log_warn(LD_BUG, \"Internal error: couldn't encode service ID.\");\n    return -1;\n  }\n  if (crypto_pk_get_digest(s->private_key, s->pk_digest)<0) {\n    log_warn(LD_BUG, \"Couldn't compute hash of public key.\");\n    return -1;\n  }\n\n  return 0;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":421251,"func":"static NOINLINE void read_config(const char *file)\n{\n\tparser_t *parser;\n\tconst struct config_keyword *k;\n\tunsigned i;\n\tchar *token[2];\n\n\tfor (i = 0; i < KWS_WITH_DEFAULTS; i++)\n\t\tkeywords[i].handler(keywords[i].def, (char*)&server_config + keywords[i].ofs);\n\n\tparser = config_open(file);\n\twhile (config_read(parser, token, 2, 2, \"# \\t\", PARSE_NORMAL)) {\n\t\tfor (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) {\n\t\t\tif (strcasecmp(token[0], k->keyword) == 0) {\n\t\t\t\tif (!k->handler(token[1], (char*)&server_config + k->ofs)) {\n\t\t\t\t\tbb_error_msg(\"can't parse line %u in %s\",\n\t\t\t\t\t\t\tparser->lineno, file);\n\t\t\t\t\t\/* reset back to the default value *\/\n\t\t\t\t\tk->handler(k->def, (char*)&server_config + k->ofs);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tconfig_close(parser);\n\n\tserver_config.start_ip = ntohl(server_config.start_ip);\n\tserver_config.end_ip = ntohl(server_config.end_ip);\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":54365,"func":"static void http_log(const char *fmt, ...)\n{\n    va_list vargs;\n    va_start(vargs, fmt);\n    http_vlog(fmt, vargs);\n    va_end(vargs);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":178277,"func":"void OxideQQuickWebViewPrivate::NavigationRequested(\n    OxideQNavigationRequest* request) {\n  Q_Q(OxideQQuickWebView);\n\n  emit q->navigationRequested(request);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":184233,"func":"bool SyncManager::IsUsingExplicitPassphrase() {\n  return data_ && data_->IsUsingExplicitPassphrase();\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":394924,"func":"static CURLMcode multi_addmsg(struct Curl_multi *multi,\n                              struct Curl_message *msg)\n{\n  if(!Curl_llist_insert_next(multi->msglist, multi->msglist->tail, msg))\n    return CURLM_OUT_OF_MEMORY;\n\n  return CURLM_OK;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":328058,"func":"float64 helper_fqtod(CPUSPARCState *env)\n\n{\n\n    float64 ret;\n\n    clear_float_exceptions(env);\n\n    ret = float128_to_float64(QT1, &env->fp_status);\n\n    check_ieee_exceptions(env);\n\n    return ret;\n\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":451610,"func":"static void StoreSymbolWithContext(BlockEncoder* self, size_t symbol,\n    size_t context, const uint32_t* context_map, size_t* storage_ix,\n    uint8_t* storage, const size_t context_bits) {\n  if (self->block_len_ == 0) {\n    size_t block_ix = ++self->block_ix_;\n    uint32_t block_len = self->block_lengths_[block_ix];\n    uint8_t block_type = self->block_types_[block_ix];\n    self->block_len_ = block_len;\n    self->entropy_ix_ = (size_t)block_type << context_bits;\n    StoreBlockSwitch(&self->block_split_code_, block_len, block_type, 0,\n        storage_ix, storage);\n  }\n  --self->block_len_;\n  {\n    size_t histo_ix = context_map[self->entropy_ix_ + context];\n    size_t ix = histo_ix * self->histogram_length_ + symbol;\n    BrotliWriteBits(self->depths_[ix], self->bits_[ix], storage_ix, storage);\n  }\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":257912,"func":"static inline void NVRAM_set_lword ( m48t59_t * nvram , uint32_t addr , uint32_t value ) {\n m48t59_set_addr ( nvram , addr ) ;\n m48t59_write ( nvram , value >> 24 ) ;\n m48t59_set_addr ( nvram , addr + 1 ) ;\n m48t59_write ( nvram , ( value >> 16 ) & 0xFF ) ;\n m48t59_set_addr ( nvram , addr + 2 ) ;\n m48t59_write ( nvram , ( value >> 8 ) & 0xFF ) ;\n m48t59_set_addr ( nvram , addr + 3 ) ;\n m48t59_write ( nvram , value & 0xFF ) ;\n }","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":483970,"func":"static struct device *wakeup_source_device_create(struct device *parent,\n\t\t\t\t\t\t  struct wakeup_source *ws)\n{\n\tstruct device *dev = NULL;\n\tint retval = -ENODEV;\n\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev) {\n\t\tretval = -ENOMEM;\n\t\tgoto error;\n\t}\n\n\tdevice_initialize(dev);\n\tdev->devt = MKDEV(0, 0);\n\tdev->class = wakeup_class;\n\tdev->parent = parent;\n\tdev->groups = wakeup_source_groups;\n\tdev->release = device_create_release;\n\tdev_set_drvdata(dev, ws);\n\tdevice_set_pm_not_required(dev);\n\n\tretval = kobject_set_name(&dev->kobj, \"wakeup%d\", ws->id);\n\tif (retval)\n\t\tgoto error;\n\n\tretval = device_add(dev);\n\tif (retval)\n\t\tgoto error;\n\n\treturn dev;\n\nerror:\n\tput_device(dev);\n\treturn ERR_PTR(retval);\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":501169,"func":"GF_Err stvi_box_size(GF_Box *s)\n{\n\tGF_StereoVideoBox *ptr = (GF_StereoVideoBox *)s;\n\n\tptr->size+= 12 + ptr->sit_len;\n\treturn GF_OK;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":114804,"func":"static struct hash_cell *__get_name_cell(const char *str)\n{\n\tstruct hash_cell *hc;\n\tunsigned int h = hash_str(str);\n\n\tlist_for_each_entry (hc, _name_buckets + h, name_list)\n\t\tif (!strcmp(hc->name, str)) {\n\t\t\tdm_get(hc->md);\n\t\t\treturn hc;\n\t\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":291464,"func":"mrb_obj_freeze(mrb_state *mrb, mrb_value self)\n{\n  struct RBasic *b;\n\n  switch (mrb_type(self)) {\n    case MRB_TT_FALSE:\n    case MRB_TT_TRUE:\n    case MRB_TT_FIXNUM:\n    case MRB_TT_SYMBOL:\n#ifndef MRB_WITHOUT_FLOAT\n    case MRB_TT_FLOAT:\n#endif\n      return self;\n    default:\n      break;\n  }\n\n  b = mrb_basic_ptr(self);\n  if (!MRB_FROZEN_P(b)) {\n    MRB_SET_FROZEN_FLAG(b);\n  }\n  return self;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":297481,"func":"int mnt_fs_set_bindsrc(struct libmnt_fs *fs, const char *src)\n{\n\treturn strdup_to_struct_member(fs, bindsrc, src);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":399605,"func":"static inline void init_timer_on_stack_key(struct timer_list *timer,\n\t\t\t\t\t   unsigned int flags, const char *name,\n\t\t\t\t\t   struct lock_class_key *key)\n{\n\tinit_timer_key(timer, flags, name, key);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":165412,"func":"void WebContentsImpl::GetRenderViewHostAtPosition(\n    int x,\n    int y,\n    const base::Callback<void(RenderViewHost*, int, int)>& callback) {\n  BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();\n  if (embedder)\n    embedder->GetRenderViewHostAtPosition(x, y, callback);\n  else\n    callback.Run(GetRenderViewHost(), x, y);\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":197414,"func":" void GLES2DecoderImpl::DoTexStorage2DEXT(GLenum target,\n                                         GLsizei levels,\n                                         GLenum internal_format,\n                                         GLsizei width,\n                                         GLsizei height) {\n  TRACE_EVENT2(\"gpu\", \"GLES2DecoderImpl::DoTexStorage2D\",\n      \"width\", width, \"height\", height);\n  TexStorageImpl(target, levels, internal_format, width, height, 1,\n                 ContextState::k2D, \"glTexStorage2D\");\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":320057,"func":"void *qemu_realloc(void *ptr, size_t size)\n\n{\n\n    if (!size && !allow_zero_malloc()) {\n\n        abort();\n\n    }\n\n    return oom_check(realloc(ptr, size ? size : 1));\n\n}\n","target":1,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":483660,"func":"static ssize_t print_cpus_nohz_full(struct device *dev,\n\t\t\t\t  struct device_attribute *attr, char *buf)\n{\n\treturn sysfs_emit(buf, \"%*pbl\\n\", cpumask_pr_args(tick_nohz_full_mask));\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":73106,"func":"void qeth_trace_features(struct qeth_card *card)\n{\n\tQETH_CARD_TEXT(card, 2, \"features\");\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->options.ipa4.supported_funcs);\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->options.ipa4.enabled_funcs);\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->options.ipa6.supported_funcs);\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->options.ipa6.enabled_funcs);\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->options.adp.supported_funcs);\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->options.adp.enabled_funcs);\n\tQETH_CARD_TEXT_(card, 2, \"%x\", card->info.diagass_support);\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":137971,"func":"String HHVM_FUNCTION(number_format,\n                     double number,\n                     int decimals \/* = 0 *\/,\n                     const Variant& dec_point_in \/* = \".\" *\/,\n                     const Variant& thousands_sep_in \/* = \",\" *\/) {\n\n  String dec_point(\".\");\n  if (!dec_point_in.isNull()) {\n    dec_point = dec_point_in.toString();\n  }\n  String thousands_sep(\",\");\n  if (!thousands_sep_in.isNull()) {\n    thousands_sep = thousands_sep_in.toString();\n  }\n\n  return string_number_format(number, decimals, dec_point, thousands_sep);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":159623,"func":"static inline uint16_t vring_used_event(VirtQueue *vq)\n{\n    return vring_avail_ring(vq, vq->vring.num);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":191676,"func":"  offline_pages::RequestStats* GetRequestStats() {\n    return offliner_->GetRequestStatsForTest();\n  }\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":511501,"func":"num_fifos ()\n{\n  return nfds;\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":78314,"func":"get_callout_arg_type_by_name_id(int name_id, int index)\n{\n  return GlobalCalloutNameList->v[name_id].arg_types[index];\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":166371,"func":"long sched_getaffinity(pid_t pid, struct cpumask *mask)\n{\n\tstruct task_struct *p;\n\tunsigned long flags;\n\tint retval;\n\n\trcu_read_lock();\n\n\tretval = -ESRCH;\n\tp = find_process_by_pid(pid);\n\tif (!p)\n\t\tgoto out_unlock;\n\n\tretval = security_task_getscheduler(p);\n\tif (retval)\n\t\tgoto out_unlock;\n\n\traw_spin_lock_irqsave(&p->pi_lock, flags);\n\tcpumask_and(mask, &p->cpus_allowed, cpu_active_mask);\n\traw_spin_unlock_irqrestore(&p->pi_lock, flags);\n\nout_unlock:\n\trcu_read_unlock();\n\n\treturn retval;\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":402234,"func":"static void ahci_init_d2h(AHCIDevice *ad)\n{\n    IDEState *ide_state = &ad->port.ifs[0];\n    AHCIPortRegs *pr = &ad->port_regs;\n\n    if (ad->init_d2h_sent) {\n        return;\n    }\n\n    if (ahci_write_fis_d2h(ad)) {\n        ad->init_d2h_sent = true;\n        \/* We're emulating receiving the first Reg H2D Fis from the device;\n         * Update the SIG register, but otherwise proceed as normal. *\/\n        pr->sig = ((uint32_t)ide_state->hcyl << 24) |\n            (ide_state->lcyl << 16) |\n            (ide_state->sector << 8) |\n            (ide_state->nsector & 0xFF);\n    }\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":285519,"func":"static const OSExchangeData::CustomFormat& GetRendererTaintCustomType() {\n  CR_DEFINE_STATIC_LOCAL(\n      ui::OSExchangeData::CustomFormat,\n      format,\n      (ui::Clipboard::GetFormatType(\"chromium\/x-renderer-taint\")));\n  return format;\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":152094,"func":"static int ssb_prctl_get(struct task_struct *task)\n{\n\tswitch (ssb_mode) {\n\tcase SPEC_STORE_BYPASS_DISABLE:\n\t\treturn PR_SPEC_DISABLE;\n\tcase SPEC_STORE_BYPASS_SECCOMP:\n\tcase SPEC_STORE_BYPASS_PRCTL:\n\t\tif (task_spec_ssb_force_disable(task))\n\t\t\treturn PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE;\n\t\tif (task_spec_ssb_disable(task))\n\t\t\treturn PR_SPEC_PRCTL | PR_SPEC_DISABLE;\n\t\treturn PR_SPEC_PRCTL | PR_SPEC_ENABLE;\n\tdefault:\n\t\tif (boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))\n\t\t\treturn PR_SPEC_ENABLE;\n\t\treturn PR_SPEC_NOT_AFFECTED;\n\t}\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":222140,"func":"PHP_FUNCTION(mb_ereg_search_getregs)\n{\n\tint n, i, len, beg, end;\n\tOnigUChar *str;\n\n\tif (MBREX(search_regs) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING && Z_STRVAL_P(MBREX(search_str)) != NULL) {\n\t\tarray_init(return_value);\n\n\t\tstr = (OnigUChar *)Z_STRVAL_P(MBREX(search_str));\n\t\tlen = Z_STRLEN_P(MBREX(search_str));\n\t\tn = MBREX(search_regs)->num_regs;\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tbeg = MBREX(search_regs)->beg[i];\n\t\t\tend = MBREX(search_regs)->end[i];\n\t\t\tif (beg >= 0 && beg <= end && end <= len) {\n\t\t\t\tadd_index_stringl(return_value, i, (char *)&str[beg], end - beg, 1);\n\t\t\t} else {\n\t\t\t\tadd_index_bool(return_value, i, 0);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tRETVAL_FALSE;\n\t}\n}\n","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":208356,"func":"static void CallWithScriptStateVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  ScriptState* script_state = ScriptState::ForRelevantRealm(info);\n\n  impl->callWithScriptStateVoidMethod(script_state);\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":110624,"func":"static int mov_write_mdta_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,\n                                   AVFormatContext *s)\n{\n    AVDictionaryEntry *t = NULL;\n    int64_t pos = avio_tell(pb);\n    int count = 1; \/* keys are 1-index based *\/\n\n    avio_wb32(pb, 0); \/* size *\/\n    ffio_wfourcc(pb, \"ilst\");\n\n    while (t = av_dict_get(s->metadata, \"\", t, AV_DICT_IGNORE_SUFFIX)) {\n        int64_t entry_pos = avio_tell(pb);\n        avio_wb32(pb, 0); \/* size *\/\n        avio_wb32(pb, count); \/* key *\/\n        mov_write_string_data_tag(pb, t->value, 0, 1);\n        update_size(pb, entry_pos);\n        count += 1;\n    }\n    return update_size(pb, pos);\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":209944,"func":"void OfflineLoadPage::GetAppOfflineStrings(\n    const Extension* app,\n    const string16& failed_url,\n    DictionaryValue* strings) const {\n  strings->SetString(\"title\", app->name());\n\n  GURL icon_url = app->GetIconURL(Extension::EXTENSION_ICON_LARGE,\n                                  ExtensionIconSet::MATCH_EXACTLY);\n  if (icon_url.is_empty()) {\n    strings->SetString(\"display_icon\", \"none\");\n    strings->SetString(\"icon\", string16());\n  } else {\n    strings->SetString(\"display_icon\", \"block\");\n    strings->SetString(\"icon\", icon_url.spec());\n  }\n\n  strings->SetString(\n      \"msg\",\n      l10n_util::GetStringFUTF16(IDS_APP_OFFLINE_LOAD_DESCRIPTION,\n                                 failed_url));\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":263666,"func":"AVCPBProperties *av_cpb_properties_alloc(size_t *size)\n{\n    AVCPBProperties *props = av_mallocz(sizeof(AVCPBProperties));\n    if (!props)\n        return NULL;\n\n    if (size)\n        *size = sizeof(*props);\n\n    props->vbv_delay = UINT64_MAX;\n\n    return props;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":6687,"func":"_PyMem_RawFree(void *ctx, void *ptr)\n{\n    free(ptr);\n}","target":1,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":439407,"func":"static void sas_suspend_devices(struct work_struct *work)\n{\n\tstruct asd_sas_phy *phy;\n\tstruct domain_device *dev;\n\tstruct sas_discovery_event *ev = to_sas_discovery_event(work);\n\tstruct asd_sas_port *port = ev->port;\n\tstruct Scsi_Host *shost = port->ha->core.shost;\n\tstruct sas_internal *si = to_sas_internal(shost->transportt);\n\n\tclear_bit(DISCE_SUSPEND, &port->disc.pending);\n\n\tsas_suspend_sata(port);\n\n\t\/* lldd is free to forget the domain_device across the\n\t * suspension, we force the issue here to keep the reference\n\t * counts aligned\n\t *\/\n\tlist_for_each_entry(dev, &port->dev_list, dev_list_node)\n\t\tsas_notify_lldd_dev_gone(dev);\n\n\t\/* we are suspending, so we know events are disabled and\n\t * phy_list is not being mutated\n\t *\/\n\tlist_for_each_entry(phy, &port->phy_list, port_phy_el) {\n\t\tif (si->dft->lldd_port_deformed)\n\t\t\tsi->dft->lldd_port_deformed(phy);\n\t\tphy->suspended = 1;\n\t\tport->suspended = 1;\n\t}\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":95928,"func":"static void edge_release(struct usb_serial *serial)\n{\n\tkfree(usb_get_serial_data(serial));\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":325806,"func":"static const char *pxb_host_root_bus_path(PCIHostState *host_bridge,\n\n                                          PCIBus *rootbus)\n\n{\n\n    PXBBus *bus = PXB_BUS(rootbus);\n\n\n\n    snprintf(bus->bus_path, 8, \"0000:%02x\", pxb_bus_num(rootbus));\n\n    return bus->bus_path;\n\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":12725,"func":"static Frame* ReuseExistingWindow(LocalFrame& active_frame,\n                                  LocalFrame& lookup_frame,\n                                  const AtomicString& frame_name,\n                                  NavigationPolicy policy,\n                                  const KURL& destination_url) {\n  if (!frame_name.IsEmpty() && !EqualIgnoringASCIICase(frame_name, \"_blank\") &&\n      policy == kNavigationPolicyIgnore) {\n    if (Frame* frame = lookup_frame.FindFrameForNavigation(\n            frame_name, active_frame, destination_url)) {\n      if (!EqualIgnoringASCIICase(frame_name, \"_self\")) {\n        if (Page* page = frame->GetPage()) {\n           if (page == active_frame.GetPage())\n             page->GetFocusController().SetFocusedFrame(frame);\n           else\n            page->GetChromeClient().Focus();\n         }\n       }\n       return frame;\n    }\n  }\n  return nullptr;\n}\n","target":1,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":152571,"func":"static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx)\n{\n\tu32 exit_intr_info;\n\n\tif (!(vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY\n\t      || vmx->exit_reason == EXIT_REASON_EXCEPTION_NMI))\n\t\treturn;\n\n\tvmx->exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);\n\texit_intr_info = vmx->exit_intr_info;\n\n\t\/* Handle machine checks before interrupts are enabled *\/\n\tif (is_machine_check(exit_intr_info))\n\t\tkvm_machine_check();\n\n\t\/* We need to handle NMIs before interrupts are enabled *\/\n\tif (is_nmi(exit_intr_info)) {\n\t\tkvm_before_handle_nmi(&vmx->vcpu);\n\t\tasm(\"int $2\");\n\t\tkvm_after_handle_nmi(&vmx->vcpu);\n\t}\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":520662,"func":"  Item** addr(uint i) { return arg_count ? args + i : NULL; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":331193,"func":"static void channel_load_d(struct fs_dma_ctrl *ctrl, int c)\n\n{\n\n\ttarget_phys_addr_t addr = channel_reg(ctrl, c, RW_SAVED_DATA);\n\n\n\n\t\/* Load and decode. FIXME: handle endianness.  *\/\n\n\tD(printf(\"%s ch=%d addr=\" TARGET_FMT_plx \"\\n\", __func__, c, addr));\n\n\tcpu_physical_memory_read (addr,\n\n\t\t\t\t  (void *) &ctrl->channels[c].current_d, \n\n\t\t\t\t  sizeof ctrl->channels[c].current_d);\n\n\n\n\tD(dump_d(c, &ctrl->channels[c].current_d));\n\n\tctrl->channels[c].regs[RW_DATA] = addr;\n\n}\n","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":112544,"func":"uint8_t* SecureElementGetPin( void )\n{\n    return SeNvmCtx.Pin;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":451865,"func":"static void rbd_img_capture_header(struct rbd_img_request *img_req)\n{\n\tstruct rbd_device *rbd_dev = img_req->rbd_dev;\n\n\tlockdep_assert_held(&rbd_dev->header_rwsem);\n\n\tif (rbd_img_is_write(img_req))\n\t\timg_req->snapc = ceph_get_snap_context(rbd_dev->header.snapc);\n\telse\n\t\timg_req->snap_id = rbd_dev->spec->snap_id;\n\n\tif (rbd_dev_parent_get(rbd_dev))\n\t\timg_request_layered_set(img_req);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":312092,"func":"void AppCacheHost::PrepareForTransfer() {\n  DCHECK(!associated_cache());\n  DCHECK(!is_selection_pending());\n  DCHECK(!group_being_updated_.get());\n  host_id_ = kAppCacheNoHostId;\n  frontend_ = NULL;\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":421825,"func":"flatpak_dir_get_default_locale_languages (FlatpakDir *self)\n{\n  g_autoptr(GPtrArray) langs = g_ptr_array_new_with_free_func (g_free);\n  g_autoptr(GDBusProxy) localed_proxy = NULL;\n  g_autoptr(GDBusProxy) accounts_proxy = NULL;\n\n  if (flatpak_dir_is_user (self))\n    return flatpak_get_current_locale_langs ();\n\n  \/* First get the system default locales *\/\n  localed_proxy = get_localed_dbus_proxy ();\n  if (localed_proxy != NULL)\n    get_locale_langs_from_localed_dbus (localed_proxy, langs);\n\n  \/* Now add the user account locales from AccountsService. If accounts_proxy is\n   * not NULL, it means that AccountsService exists *\/\n  accounts_proxy = get_accounts_dbus_proxy ();\n  if (accounts_proxy != NULL)\n    get_locale_langs_from_accounts_dbus (accounts_proxy, langs);\n\n  \/* If none were found, fall back to using all languages *\/\n  if (langs->len == 0)\n    return g_new0 (char *, 1);\n\n  g_ptr_array_sort (langs, flatpak_strcmp0_ptr);\n  g_ptr_array_add (langs, NULL);\n\n  return (char **) g_ptr_array_free (g_steal_pointer (&langs), FALSE);\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":498829,"func":"smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t   struct cifsFileInfo *cfile)\n{\n\treturn SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid,\n\t\t\t    cfile->fid.volatile_fid);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":289407,"func":"IN_PROC_BROWSER_TEST_F ( ContentSettingBubbleDialogTest , InvokeDialog_mediastream_mic ) {\n RunDialog ( ) ;\n }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":27599,"func":"static int dissect_h225_SEQUENCE_OF_ServiceControlSession ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h225_SEQUENCE_OF_ServiceControlSession , SEQUENCE_OF_ServiceControlSession_sequence_of ) ;\n return offset ;\n }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":521566,"func":"Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table,\n                                    bool keep_type)\n{\n  Field *field;\n  if (type() != MYSQL_TYPE_VAR_STRING || keep_type)\n    field= Field::make_new_field(root, new_table, keep_type);\n  else if ((field= new (root) Field_varstring(field_length, maybe_null(),\n                                              field_name,\n                                              new_table->s, charset())))\n  {\n    \/*\n      Old VARCHAR field which should be modified to a VARCHAR on copy\n      This is done to ensure that ALTER TABLE will convert old VARCHAR fields\n      to now VARCHAR fields.\n    *\/\n    field->init_for_make_new_field(new_table, orig_table);\n  }\n  return field;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":503681,"func":"WebContents::WebContents(v8::Isolate* isolate,\n                         std::unique_ptr<content::WebContents> web_contents,\n                         Type type)\n    : content::WebContentsObserver(web_contents.get()),\n      type_(type),\n      id_(GetAllWebContents().Add(this)),\n      devtools_file_system_indexer_(\n          base::MakeRefCounted<DevToolsFileSystemIndexer>()),\n      file_task_runner_(\n          base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))\n#if BUILDFLAG(ENABLE_PRINTING)\n      ,\n      print_task_runner_(CreatePrinterHandlerTaskRunner())\n#endif\n{\n  DCHECK(type != Type::kRemote)\n      << \"Can't take ownership of a remote WebContents\";\n  auto session = Session::CreateFrom(isolate, GetBrowserContext());\n  session_.Reset(isolate, session.ToV8());\n  InitWithSessionAndOptions(isolate, std::move(web_contents), session,\n                            gin::Dictionary::CreateEmpty(isolate));\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":431463,"func":"    Status acquireUserForSessionRefresh(OperationContext*,\n                                        const UserName&,\n                                        const User::UserId&,\n                                        User**) override {\n        UASSERT_NOT_IMPLEMENTED;\n    }","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":515528,"func":"int setup_tests(void)\n{\n#ifdef OPENSSL_NO_SM2\n    TEST_note(\"SM2 is disabled.\");\n#else\n    ADD_TEST(sm2_crypt_test);\n    ADD_TEST(sm2_sig_test);\n#endif\n    return 1;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":206111,"func":"void DelegatedFrameHost::WillDrawSurface(const viz::LocalSurfaceId& id,\n                                         const gfx::Rect& damage_rect) {\n  if (id != local_surface_id_)\n    return;\n  AttemptFrameSubscriberCapture(damage_rect);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":46059,"func":"fiber_resume(mrb_state *mrb, mrb_value self)\n{\n  const mrb_value *a;\n  mrb_int len;\n  mrb_bool vmexec = FALSE;\n\n  mrb_get_args(mrb, \"*!\", &a, &len);\n  if (mrb->c->ci->cci > 0) {\n    vmexec = TRUE;\n  }\n  return fiber_switch(mrb, self, len, a, TRUE, vmexec);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":390768,"func":"static PHP_INI_MH(OnUpdateInternalEncoding)\n{\n\tif (new_value) {\n\t\tOnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);\n\t}\n\treturn SUCCESS;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":168405,"func":"void GpuCommandBufferStub::SetMemoryAllocation(\n    const GpuMemoryAllocation& allocation) {\n  Send(new GpuCommandBufferMsg_SetMemoryAllocation(\n      route_id_, allocation.renderer_allocation));\n  if (!surface_ || !MakeCurrent())\n    return;\n  surface_->SetFrontbufferAllocation(\n      allocation.browser_allocation.suggest_have_frontbuffer);\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":105915,"func":"static u8 *uvesafb_vbe_state_save(struct uvesafb_par *par)\n{\n\tstruct uvesafb_ktask *task;\n\tu8 *state;\n\tint err;\n\n\tif (!par->vbe_state_size)\n\t\treturn NULL;\n\n\tstate = kmalloc(par->vbe_state_size, GFP_KERNEL);\n\tif (!state)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\ttask = uvesafb_prep();\n\tif (!task) {\n\t\tkfree(state);\n\t\treturn NULL;\n\t}\n\n\ttask->t.regs.eax = 0x4f04;\n\ttask->t.regs.ecx = 0x000f;\n\ttask->t.regs.edx = 0x0001;\n\ttask->t.flags = TF_BUF_RET | TF_BUF_ESBX;\n\ttask->t.buf_len = par->vbe_state_size;\n\ttask->buf = state;\n\terr = uvesafb_exec(task);\n\n\tif (err || (task->t.regs.eax & 0xffff) != 0x004f) {\n\t\tpr_warn(\"VBE get state call failed (eax=0x%x, err=%d)\\n\",\n\t\t\ttask->t.regs.eax, err);\n\t\tkfree(state);\n\t\tstate = NULL;\n\t}\n\n\tuvesafb_free(task);\n\treturn state;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":370127,"func":"static PHP_FUNCTION(libxml_get_last_error)\n{\n\txmlErrorPtr error;\n\n\terror = xmlGetLastError();\n\t\n\tif (error) {\n\t\tobject_init_ex(return_value, libxmlerror_class_entry);\n\t\tadd_property_long(return_value, \"level\", error->level);\n\t\tadd_property_long(return_value, \"code\", error->code);\n\t\tadd_property_long(return_value, \"column\", error->int2);\n\t\tif (error->message) {\n\t\t\tadd_property_string(return_value, \"message\", error->message, 1);\n\t\t} else {\n\t\t\tadd_property_stringl(return_value, \"message\", \"\", 0, 1);\n\t\t}\n\t\tif (error->file) {\n\t\t\tadd_property_string(return_value, \"file\", error->file, 1);\n\t\t} else {\n\t\t\tadd_property_stringl(return_value, \"file\", \"\", 0, 1);\n\t\t}\n\t\tadd_property_long(return_value, \"line\", error->line);\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":442870,"func":"CreateMultiStringPopUp (\r\n  IN  UINTN                       RequestedWidth,\r\n  IN  UINTN                       NumberOfLines,\r\n  ...\r\n  )\r\n{\r\n  VA_LIST Marker;\r\n\r\n  VA_START (Marker, NumberOfLines);\r\n\r\n  CreateSharedPopUp (RequestedWidth, NumberOfLines, Marker);\r\n\r\n  VA_END (Marker);\r\n}\r","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":520644,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_ref_null_helper>(thd, this); }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":49285,"func":"long qemu_maxrampagesize(void)\n{\n    long pagesize = 0;\n    Object *memdev_root = object_resolve_path(\"\/objects\", NULL);\n\n    object_child_foreach(memdev_root, find_max_backend_pagesize, &pagesize);\n    return pagesize;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":269299,"func":"void remove_remote_root()\n{\n  int reply;\n  reply= get_response((const char *) \"\\n\\nNormally, root should only be \"\n                                     \"allowed to connect from\\n'localhost'. \"\n\t\t\t\t     \"This ensures that someone cannot guess at\"\n\t\t\t\t     \"\\nthe root password from the network.\\n\\n\"\n\t\t\t\t     \"Disallow root login remotely? (Press y|Y \"\n\t\t\t\t     \"for Yes, any other key for No) : \");\n  if (reply == (int) 'y' || reply == (int) 'Y')\n  {\n    const char *query;\n    query= \"SELECT USER, HOST FROM mysql.user WHERE USER='root' \"\n\t   \"AND HOST NOT IN ('localhost', '127.0.0.1', '::1')\";\n    if (!execute_query(&query, strlen(query)))\n      DBUG_PRINT(\"info\", (\"query success!\"));\n    MYSQL_RES *result= mysql_store_result(&mysql);\n    if (result)\n      drop_users(result);\n    mysql_free_result(result);\n    fprintf(stdout, \"Done.. Moving on..\\n\\n\");\n  }\n  else\n    fprintf(stdout, \"\\n ... skipping.\\n\");\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":377755,"func":"int tcf_action_destroy(struct list_head *actions, int bind)\n{\n\tstruct tc_action *a, *tmp;\n\tint ret = 0;\n\n\tlist_for_each_entry_safe(a, tmp, actions, list) {\n\t\tret = tcf_hash_release(a, bind);\n\t\tif (ret == ACT_P_DELETED)\n\t\t\tmodule_put(a->ops->owner);\n\t\telse if (ret < 0)\n\t\t\treturn ret;\n\t\tlist_del(&a->list);\n\t\tkfree(a);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":121473,"func":"static void skb_recv_done(struct virtqueue *rvq)\n{\n\tstruct virtnet_info *vi = rvq->vdev->priv;\n\tstruct receive_queue *rq = &vi->rq[vq2rxq(rvq)];\n\n\t\/* Schedule NAPI, Suppress further interrupts if successful. *\/\n\tif (napi_schedule_prep(&rq->napi)) {\n\t\tvirtqueue_disable_cb(rvq);\n\t\t__napi_schedule(&rq->napi);\n\t}\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":206956,"func":"JsVar *jsvGetArrayItem(const JsVar *arr, JsVarInt index) {\n  return jsvSkipNameAndUnLock(jsvGetArrayIndex(arr,index));\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":460422,"func":"static void hidinput_cleanup_hidinput(struct hid_device *hid,\n\t\tstruct hid_input *hidinput)\n{\n\tstruct hid_report *report;\n\tint i, k;\n\n\tlist_del(&hidinput->list);\n\tinput_free_device(hidinput->input);\n\tkfree(hidinput->name);\n\n\tfor (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {\n\t\tif (k == HID_OUTPUT_REPORT &&\n\t\t\thid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS)\n\t\t\tcontinue;\n\n\t\tlist_for_each_entry(report, &hid->report_enum[k].report_list,\n\t\t\t\t    list) {\n\n\t\t\tfor (i = 0; i < report->maxfield; i++)\n\t\t\t\tif (report->field[i]->hidinput == hidinput)\n\t\t\t\t\treport->field[i]->hidinput = NULL;\n\t\t}\n\t}\n\n\tkfree(hidinput);\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":427412,"func":"static void libopenjpeg_error_callback(const char *msg, void * \/*client_data*\/) {\n  error(errSyntaxError, -1, \"{0:s}\", msg);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":433503,"func":"int validate_sp(unsigned long sp, struct task_struct *p,\n\t\t       unsigned long nbytes)\n{\n\tunsigned long stack_page = (unsigned long)task_stack_page(p);\n\n\tif (sp < THREAD_SIZE)\n\t\treturn 0;\n\n\tif (sp >= stack_page && sp <= stack_page + THREAD_SIZE - nbytes)\n\t\treturn 1;\n\n\treturn valid_irq_stack(sp, p, nbytes);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":18440,"func":"static int dissect_h245_INTEGER ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_integer ( tvb , offset , actx , tree , hf_index , NULL ) ;\n return offset ;\n }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":390432,"func":"void SSL_CTX::setFailNoCert()\n{\n    method_->setFailNoCert();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":129875,"func":"int am_has_header(request_rec *r, const char *h, const char *v)\n{\n    return (am_get_header_attr(r, h, v, NULL) != NULL);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":199401,"func":"ScreenRecorder::ScreenRecorder(\n    MessageLoop* capture_loop,\n    MessageLoop* encode_loop,\n    base::MessageLoopProxy* network_loop,\n    Capturer* capturer,\n    Encoder* encoder)\n    : capture_loop_(capture_loop),\n      encode_loop_(encode_loop),\n      network_loop_(network_loop),\n      capturer_(capturer),\n      encoder_(encoder),\n      is_recording_(false),\n      network_stopped_(false),\n      encoder_stopped_(false),\n      max_recordings_(kMaxRecordings),\n      recordings_(0),\n      frame_skipped_(false),\n      sequence_number_(0) {\n  DCHECK(capture_loop_);\n  DCHECK(encode_loop_);\n  DCHECK(network_loop_);\n}\n","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":152409,"func":" *\/\nvoid skb_condense(struct sk_buff *skb)\n{\n\tif (skb->data_len) {\n\t\tif (skb->data_len > skb->end - skb->tail ||\n\t\t    skb_cloned(skb))\n\t\t\treturn;\n\n\t\t\/* Nice, we can free page frag(s) right now *\/\n\t\t__pskb_pull_tail(skb, skb->data_len);\n\t}\n\t\/* At this point, skb->truesize might be over estimated,\n\t * because skb had a fragment, and fragments do not tell\n\t * their truesize.\n\t * When we pulled its content into skb->head, fragment\n\t * was freed, but __pskb_pull_tail() could not possibly\n\t * adjust skb->truesize, not knowing the frag truesize.\n\t *\/\n\tskb->truesize = SKB_TRUESIZE(skb_end_offset(skb));","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":478155,"func":"    T cubic_atXYZ_c(const float fx, const float fy, const float fz, const int c, const T& out_value) const {\n      return cimg::type<T>::cut(cubic_atXYZ(fx,fy,fz,c,out_value));\n    }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":186752,"func":"void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type)\n{\n    EmptyMsgPipeItem *item = spice_new(EmptyMsgPipeItem, 1);\n\n    red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_EMPTY_MSG);\n    item->msg = msg_type;\n    red_channel_client_pipe_add(rcc, &item->base);\n    red_channel_client_push(rcc);\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":130022,"func":"\nGF_Err void_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tif (s->size) return GF_ISOM_INVALID_FILE;\n\treturn GF_OK;","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":218674,"func":"bool ShellDelegateImpl::IsForceMaximizeOnFirstRun() const {\n  return false;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":463561,"func":"\nstatic int io_sqpoll_wait_sq(struct io_ring_ctx *ctx)\n{\n\tint ret = 0;\n\tDEFINE_WAIT(wait);\n\n\tdo {\n\t\tif (!io_sqring_full(ctx))\n\t\t\tbreak;\n\n\t\tprepare_to_wait(&ctx->sqo_sq_wait, &wait, TASK_INTERRUPTIBLE);\n\n\t\tif (unlikely(ctx->sqo_dead)) {\n\t\t\tret = -EOWNERDEAD;\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (!io_sqring_full(ctx))\n\t\t\tbreak;\n\n\t\tschedule();\n\t} while (!signal_pending(current));\n\n\tfinish_wait(&ctx->sqo_sq_wait, &wait);\nout:\n\treturn ret;","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":399157,"func":"static void\nadd_fifo_list (pathname)\n     char *pathname;\n{\n  if (nfifo >= fifo_list_size - 1)\n    {\n      fifo_list_size += FIFO_INCR;\n      fifo_list = (struct temp_fifo *)xrealloc (fifo_list,\n\t\t\t\tfifo_list_size * sizeof (struct temp_fifo));\n    }\n\n  fifo_list[nfifo].file = savestring (pathname);\n  nfifo++;","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":379687,"func":"static int ZEND_FASTCALL  ZEND_FETCH_DIM_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op2;\n\tzval *dim = _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);\n\tzval **container = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_IS TSRMLS_CC);\n\n\tif (IS_CV == IS_VAR && !container) {\n\t\tzend_error_noreturn(E_ERROR, \"Cannot use string offset as an array\");\n\t}\n\tzend_fetch_dimension_address_read(&EX_T(opline->result.u.var), container, dim, 1, BP_VAR_IS TSRMLS_CC);\n\tzval_dtor(free_op2.var);\n\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":56860,"func":"void Vertex(double *args)\n{\n    SetTransferMatrix(1,0,0,1,args[0],args[1]);\n    BezierCircle(args[2],\"f\");\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":232420,"func":"SWFShape_addBitmapFillStyle(SWFShape shape, SWFBitmap bitmap, byte flags)\n{\n\tSWFFillStyle fill;\n\n\tif ( bitmap )\n\t{\n\t\tSWFCharacter_addDependency((SWFCharacter)shape,\n\t\t                           (SWFCharacter)bitmap);\n\t}\n\n\tfill = newSWFBitmapFillStyle(bitmap, flags);\n\tif(addFillStyle(shape, fill) < 0)\n\t{\n\t\tdestroySWFFillStyle(fill);\n\t\treturn NULL;\n\t}\n\treturn fill;\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":51649,"func":"flatpak_repo_set_homepage (OstreeRepo *repo,\n                           const char *homepage,\n                           GError    **error)\n{\n  g_autoptr(GKeyFile) config = NULL;\n\n  config = ostree_repo_copy_config (repo);\n\n  if (homepage)\n    g_key_file_set_string (config, \"flatpak\", \"homepage\", homepage);\n  else\n    g_key_file_remove_key (config, \"flatpak\", \"homepage\", NULL);\n\n  if (!ostree_repo_write_config (repo, config, error))\n    return FALSE;\n\n  return TRUE;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":313531,"func":"void BluetoothAdapter::RemoveDiscoverySession(\n    BluetoothDiscoverySession* discovery_session,\n    const base::Closure& callback,\n    DiscoverySessionErrorCallback error_callback) {\n  size_t erased = discovery_sessions_.erase(discovery_session);\n  DCHECK_EQ(1u, erased);\n\n  std::unique_ptr<StartOrStopDiscoveryCallback> removal_callbacks(\n      new StartOrStopDiscoveryCallback(callback, std::move(error_callback)));\n\n  discovery_callback_queue_.push(std::move(removal_callbacks));\n\n  if (discovery_request_pending_) {\n    return;\n  }\n\n  ProcessDiscoveryQueue();\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":236375,"func":"XcursorLibraryShape (const char *library)\n{\n    int\tlow, high;\n    int\tmid;\n    int\tc;\n\n    low = 0;\n    high = NUM_STANDARD_NAMES - 1;\n    while (low < high - 1)\n    {\n\tmid = (low + high) >> 1;\n\tc = strcmp (library, STANDARD_NAME (mid));\n\tif (c == 0)\n\t    return (mid << 1);\n\tif (c > 0)\n\t    low = mid;\n\telse\n\t    high = mid;\n    }\n    while (low <= high)\n    {\n\tif (!strcmp (library, STANDARD_NAME (low)))\n\t    return (low << 1);\n\tlow++;\n    }\n    return -1;\n}\n","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":514666,"func":"void StreamResource::EmitRead(ssize_t nread, const uv_buf_t& buf) {\n  DebugSealHandleScope seal_handle_scope;\n  if (nread > 0)\n    bytes_read_ += static_cast<uint64_t>(nread);\n  listener_->OnStreamRead(nread, buf);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":200288,"func":"CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *data,\n\t\t\t\tconst EVP_CIPHER *cipher, unsigned int flags)\n\t{\n\tCMS_ContentInfo *cms;\n\tint i;\n\tX509 *recip;\n\tcms = CMS_EnvelopedData_create(cipher);\n\tif (!cms)\n\t\tgoto merr;\n\tfor (i = 0; i < sk_X509_num(certs); i++)\n\t\t{\n\t\trecip = sk_X509_value(certs, i);\n\t\tif (!CMS_add1_recipient_cert(cms, recip, flags))\n\t\t\t{\n\t\t\tCMSerr(CMS_F_CMS_ENCRYPT, CMS_R_RECIPIENT_ERROR);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\n\tif(!(flags & CMS_DETACHED))\n\t\tCMS_set_detached(cms, 0);\n\n\tif ((flags & (CMS_STREAM|CMS_PARTIAL))\n\t\t|| CMS_final(cms, data, NULL, flags))\n\t\treturn cms;\n\telse\n\t\tgoto err;\n\n\tmerr:\n\tCMSerr(CMS_F_CMS_ENCRYPT, ERR_R_MALLOC_FAILURE);\n\terr:\n\tif (cms)\n\t\tCMS_ContentInfo_free(cms);\n\treturn NULL;\n\t}\n","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":112681,"func":"static struct timing_generator *dce112_timing_generator_create(\n\t\tstruct dc_context *ctx,\n\t\tuint32_t instance,\n\t\tconst struct dce110_timing_generator_offsets *offsets)\n{\n\tstruct dce110_timing_generator *tg110 =\n\t\tkzalloc(sizeof(struct dce110_timing_generator), GFP_KERNEL);\n\n\tif (!tg110)\n\t\treturn NULL;\n\n\tdce110_timing_generator_construct(tg110, ctx, instance, offsets);\n\treturn &tg110->base;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":474695,"func":"process (GeglOperation         *operation,\n         GeglOperationContext  *context,\n         const gchar           *output_pad,\n         const GeglRectangle   *result,\n         gint                   level)\n{\n  GeglProperties *o = GEGL_PROPERTIES (operation);\n\n  if (!o->user_data)\n    return FALSE;\n  \/* overriding the predefined behavior *\/\n  g_object_ref (o->user_data);\n  gegl_operation_context_take_object (context, \"output\", G_OBJECT (o->user_data));\n  return  TRUE;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":62298,"func":"last_search_pattern(void)\n{\n    return spats[RE_SEARCH].pat;\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":121874,"func":"static ut64 binobj_a2b(RBinObject *bo, ut64 addr) {\n\treturn addr + (bo ? bo->baddr_shift : 0);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":189460,"func":"ZEND_API void *zend_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC)\n{\n\treturn EG(objects_store).object_buckets[handle].bucket.obj.object;\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":244317,"func":"static vm_fault_t hugetlb_vm_op_fault(struct vm_fault *vmf)\n{\n\tBUG();\n\treturn 0;\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":112881,"func":"static int unix_accept(struct socket *sock, struct socket *newsock, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sock *tsk;\n\tstruct sk_buff *skb;\n\tint err;\n\n\terr = -EOPNOTSUPP;\n\tif (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET)\n\t\tgoto out;\n\n\terr = -EINVAL;\n\tif (sk->sk_state != TCP_LISTEN)\n\t\tgoto out;\n\n\t\/* If socket state is TCP_LISTEN it cannot change (for now...),\n\t * so that no locks are necessary.\n\t *\/\n\n\tskb = skb_recv_datagram(sk, 0, flags&O_NONBLOCK, &err);\n\tif (!skb) {\n\t\t\/* This means receive shutdown. *\/\n\t\tif (err == 0)\n\t\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\ttsk = skb->sk;\n\tskb_free_datagram(sk, skb);\n\twake_up_interruptible(&unix_sk(sk)->peer_wait);\n\n\t\/* attach accepted sock to socket *\/\n\tunix_state_lock(tsk);\n\tnewsock->state = SS_CONNECTED;\n\tsock_graft(tsk, newsock);\n\tunix_state_unlock(tsk);\n\treturn 0;\n\nout:\n\treturn err;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":402034,"func":"e1000e_start_recv(E1000ECore *core)\n{\n    int i;\n\n    trace_e1000e_rx_start_recv();\n\n    for (i = 0; i <= core->max_queue_num; i++) {\n        qemu_flush_queued_packets(qemu_get_subqueue(core->owner_nic, i));\n    }\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":353105,"func":"rsvg_new_use (void)\n{\n    RsvgNodeUse *use;\n    use = g_new (RsvgNodeUse, 1);\n    _rsvg_node_init (&use->super);\n    use->super.draw = rsvg_node_use_draw;\n    use->super.set_atts = rsvg_node_use_set_atts;\n    use->x = _rsvg_css_parse_length (\"0\");\n    use->y = _rsvg_css_parse_length (\"0\");\n    use->w = _rsvg_css_parse_length (\"0\");\n    use->h = _rsvg_css_parse_length (\"0\");\n    use->link = NULL;\n    return (RsvgNode *) use;\n}","target":1,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":454153,"func":"TEST(FieldPath, NoOptimizationForRootFieldPathWithDottedPath) {\n    intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());\n    intrusive_ptr<ExpressionFieldPath> expression =\n        ExpressionFieldPath::parse(expCtx, \"$$ROOT.x.y\", expCtx->variablesParseState);\n\n    \/\/ An attempt to optimize returns the Expression itself.\n    ASSERT_EQUALS(expression, expression->optimize());\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":46241,"func":"GF_Err sdtp_Read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_SampleDependencyTypeBox *ptr = (GF_SampleDependencyTypeBox*)s;\n\n\t\/*out-of-order sdtp, assume no padding at the end*\/\n\tif (!ptr->sampleCount) ptr->sampleCount = (u32) ptr->size;\n\telse if (ptr->sampleCount > (u32) ptr->size) return GF_ISOM_INVALID_FILE;\n\n\tptr->sample_info = (u8 *) gf_malloc(sizeof(u8)*ptr->sampleCount);\n\tgf_bs_read_data(bs, (char*)ptr->sample_info, ptr->sampleCount);\n\tISOM_DECREASE_SIZE(ptr, ptr->sampleCount);\n\treturn GF_OK;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":380843,"func":"void XMLRPC_Free(void* mem) {\n   my_free(mem);\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":446850,"func":"_dbus_read_socket (DBusSocket        fd,\n                   DBusString       *buffer,\n                   int               count)\n{\n  return _dbus_read (fd.fd, buffer, count);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":326644,"func":"static uint32_t nvdimm_get_max_xfer_label_size(void)\n\n{\n\n    uint32_t max_get_size, max_set_size, dsm_memory_size = 4096;\n\n\n\n    \/*\n\n     * the max data ACPI can read one time which is transferred by\n\n     * the response of 'Get Namespace Label Data' function.\n\n     *\/\n\n    max_get_size = dsm_memory_size - sizeof(NvdimmFuncGetLabelDataOut);\n\n\n\n    \/*\n\n     * the max data ACPI can write one time which is transferred by\n\n     * 'Set Namespace Label Data' function.\n\n     *\/\n\n    max_set_size = dsm_memory_size - offsetof(NvdimmDsmIn, arg3) -\n\n                   sizeof(NvdimmFuncSetLabelDataIn);\n\n\n\n    return MIN(max_get_size, max_set_size);\n\n}\n","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":189962,"func":"void TabHelper::CreateApplicationShortcuts() {\n  DCHECK(CanCreateApplicationShortcuts());\n  if (pending_web_app_action_ != NONE)\n    return;\n\n  GetApplicationInfo(CREATE_SHORTCUT);\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":173061,"func":"    SynchronizeVisualPropertiesMessageFilter()\n    : content::BrowserMessageFilter(kMessageClassesToFilter,\n                                    arraysize(kMessageClassesToFilter)),\n      screen_space_rect_run_loop_(std::make_unique<base::RunLoop>()),\n      screen_space_rect_received_(false) {}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":389283,"func":"NCR_ModifyMaxpoll(NCR_Instance inst, int new_maxpoll)\n{\n  if (new_maxpoll < MIN_POLL || new_maxpoll > MAX_POLL)\n    return;\n  inst->maxpoll = new_maxpoll;\n  LOG(LOGS_INFO, LOGF_NtpCore, \"Source %s new maxpoll %d\", UTI_IPToString(&inst->remote_addr.ip_addr), new_maxpoll);\n  if (inst->minpoll > inst->maxpoll)\n    NCR_ModifyMinpoll(inst, inst->maxpoll);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":45643,"func":"static inline ut16 r_read_at_be16(const void *src, size_t offset) {\n\tconst ut8 *s = (const ut8*)src + offset;\n\treturn r_read_be16 (s);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":151609,"func":"static void clear_exception(struct pstore *ps, uint32_t index)\n{\n\tstruct disk_exception *de = get_exception(ps, index);\n\n\t\/* clear it *\/\n\tde->old_chunk = 0;\n\tde->new_chunk = 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":206217,"func":" void SyncManager::SyncInternal::OnServerConnectionEvent(\n    const ServerConnectionEvent& event) {\n  DCHECK(thread_checker_.CalledOnValidThread());\n  allstatus_.HandleServerConnectionEvent(event);\n  if (event.connection_code ==\n      browser_sync::HttpResponse::SERVER_CONNECTION_OK) {\n    ObserverList<SyncManager::Observer> temp_obs_list;\n    CopyObservers(&temp_obs_list);\n    FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,\n                      OnAuthError(AuthError::None()));\n  }\n\n  if (event.connection_code == browser_sync::HttpResponse::SYNC_AUTH_ERROR) {\n    observing_ip_address_changes_ = false;\n    ObserverList<SyncManager::Observer> temp_obs_list;\n    CopyObservers(&temp_obs_list);\n    FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,\n        OnAuthError(AuthError(AuthError::INVALID_GAIA_CREDENTIALS)));\n  }\n\n  if (event.connection_code ==\n      browser_sync::HttpResponse::SYNC_SERVER_ERROR) {\n    ObserverList<SyncManager::Observer> temp_obs_list;\n    CopyObservers(&temp_obs_list);\n    FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,\n        OnAuthError(AuthError(AuthError::CONNECTION_FAILED)));\n  }\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":284523,"func":"static void cmdproc_thread_cleanup(void *arg)\n{\n\tstruct tcmu_device *dev = arg;\n\tstruct tcmur_handler *rhandler = tcmu_get_runner_handler(dev);\n\n\trhandler->close(dev);\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":475621,"func":"START_TEST(virgl_test_transfer_read_unbound_res)\n{\n  int ret;\n  struct virgl_box box;\n\n  ret = virgl_renderer_transfer_read_iov(1, 1, 0, 1, 1, &box, 0, NULL, 0);\n  ck_assert_int_eq(ret, EINVAL);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":296608,"func":"ia64_patch (u64 insn_addr, u64 mask, u64 val)\n{\n\tu64 m0, m1, v0, v1, b0, b1, *b = (u64 *) (insn_addr & -16);\n#\tdefine insn_mask ((1UL << 41) - 1)\n\tunsigned long shift;\n\n\tb0 = b[0]; b1 = b[1];\n\tshift = 5 + 41 * (insn_addr % 16); \/* 5 bits of template, then 3 x 41-bit instructions *\/\n\tif (shift >= 64) {\n\t\tm1 = mask << (shift - 64);\n\t\tv1 = val << (shift - 64);\n\t} else {\n\t\tm0 = mask << shift; m1 = mask >> (64 - shift);\n\t\tv0 = val  << shift; v1 = val >> (64 - shift);\n\t\tb[0] = (b0 & ~m0) | (v0 & m0);\n\t}\n\tb[1] = (b1 & ~m1) | (v1 & m1);\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":451159,"func":"  void clearInline() override { memset(inline_headers_, 0, inlineHeadersSize()); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":520018,"func":"  inline ulong query_start_sec_part()\n  { query_start_sec_part_used=1; return start_time_sec_part; }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":341082,"func":"static AVRational update_sar(int old_w, int old_h, AVRational sar, int new_w, int new_h)\n\n{\n\n    \/\/ attempt to keep aspect during typical resolution switches\n\n    if (!sar.num)\n\n        sar = (AVRational){1, 1};\n\n\n\n    sar = av_mul_q(sar, (AVRational){new_h * old_w, new_w * old_h});\n\n    return sar;\n\n}\n","target":1,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":483764,"func":"void topology_normalize_cpu_scale(void)\n{\n\tu64 capacity;\n\tu64 capacity_scale;\n\tint cpu;\n\n\tif (!raw_capacity)\n\t\treturn;\n\n\tcapacity_scale = 1;\n\tfor_each_possible_cpu(cpu) {\n\t\tcapacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu);\n\t\tcapacity_scale = max(capacity, capacity_scale);\n\t}\n\n\tpr_debug(\"cpu_capacity: capacity_scale=%llu\\n\", capacity_scale);\n\tfor_each_possible_cpu(cpu) {\n\t\tcapacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu);\n\t\tcapacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT,\n\t\t\tcapacity_scale);\n\t\ttopology_set_cpu_scale(cpu, capacity);\n\t\tpr_debug(\"cpu_capacity: CPU%d cpu_capacity=%lu\\n\",\n\t\t\tcpu, topology_get_cpu_scale(cpu));\n\t}\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":120137,"func":"static int mpeg4_update_thread_context(AVCodecContext *dst,\n                                       const AVCodecContext *src)\n{\n    Mpeg4DecContext *s = dst->priv_data;\n    const Mpeg4DecContext *s1 = src->priv_data;\n    int init = s->m.context_initialized;\n\n    int ret = ff_mpeg_update_thread_context(dst, src);\n\n    if (ret < 0)\n        return ret;\n\n    memcpy(((uint8_t*)s) + sizeof(MpegEncContext), ((uint8_t*)s1) + sizeof(MpegEncContext), sizeof(Mpeg4DecContext) - sizeof(MpegEncContext));\n\n    if (CONFIG_MPEG4_DECODER && !init && s1->xvid_build >= 0)\n        ff_xvid_idct_init(&s->m.idsp, dst);\n\n    return 0;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":130079,"func":"static GFINLINE void flac_dmx_update_cts(GF_FLACDmxCtx *ctx, u32 nb_samp)\n{\n\tif (ctx->timescale) {\n\t\tu64 inc = nb_samp;\n\t\tinc *= ctx->timescale;\n\t\tinc \/= ctx->sample_rate;\n\t\tctx->cts += inc;\n\t} else {\n\t\tctx->cts += nb_samp;\n\t}\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":254493,"func":"ofputil_protocols_to_version_bitmap(enum ofputil_protocol protocols)\n{\n    uint32_t bitmap = 0;\n\n    for (; protocols; protocols = zero_rightmost_1bit(protocols)) {\n        enum ofputil_protocol protocol = rightmost_1bit(protocols);\n\n        bitmap |= 1u << ofputil_protocol_to_ofp_version(protocol);\n    }\n\n    return bitmap;\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":310674,"func":"  virtual void TearDown() {\n    adapter_ = NULL;\n    DBusThreadManager::Shutdown();\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":476170,"func":"bool InstanceKlass::is_record() const {\n  return _record_components != NULL &&\n         is_final() &&\n         java_super() == vmClasses::Record_klass();\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":208707,"func":"_crypt_extended(const char *key, const char *setting)\n{\n\tstatic int initialized = 0;\n\tstatic struct php_crypt_extended_data data;\n\n\tif (!initialized) {\n\t\t_crypt_extended_init();\n\t\tinitialized = 1;\n\t\tdata.initialized = 0;\n\t}\n\treturn _crypt_extended_r(key, setting, &data);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":196941,"func":"void GpuCommandBufferStub::PollWork() {\n  TRACE_EVENT0(\"gpu\", \"GpuCommandBufferStub::PollWork\");\n  delayed_work_scheduled_ = false;\n  FastSetActiveURL(active_url_, active_url_hash_);\n  if (decoder_.get() && !MakeCurrent())\n    return;\n  if (scheduler_.get())\n    scheduler_->PollUnscheduleFences();\n  ScheduleDelayedWork(kHandleMoreWorkPeriodBusyMs);\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":252318,"func":"void ExtensionTabUtil::ForEachTab(\n    const base::Callback<void(WebContents*)>& callback) {\n  for (TabContentsIterator iterator; !iterator.done(); ++iterator)\n    callback.Run(*iterator);\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":317116,"func":"void V8DOMWindow::eventAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n{\n    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));\n    if (holder.IsEmpty())\n        return;\n\n    Frame* frame = V8DOMWindow::toNative(holder)->frame();\n    if (!BindingSecurity::shouldAllowAccessToFrame(frame))\n        return;\n\n    ASSERT(frame);\n    v8::Local<v8::Context> context = frame->script()->currentWorldContext();\n    if (context.IsEmpty())\n        return;\n\n    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();\n    context->Global()->SetHiddenValue(eventSymbol, value);\n}\n","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":310781,"func":"static void stroke_config(private_stroke_socket_t *this,\n\t\t\t\t\t\t  stroke_msg_t *msg, FILE *out)\n{\n\tthis->cred->cachecrl(this->cred, msg->config.cachecrl);\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":42565,"func":"static int __init crypto_user_init(void)\n{\n\tstruct netlink_kernel_cfg cfg = {\n\t\t.input\t= crypto_netlink_rcv,\n\t};\n\n\tcrypto_nlsk = netlink_kernel_create(&init_net, NETLINK_CRYPTO, &cfg);\n\tif (!crypto_nlsk)\n\t\treturn -ENOMEM;\n\n\treturn 0;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":200446,"func":"void AutofillExternalDelegate::OnPopupShown() {\n  manager_->DidShowSuggestions(has_autofill_suggestions_, query_form_,\n                               query_field_);\n\n  if (should_show_scan_credit_card_) {\n    AutofillMetrics::LogScanCreditCardPromptMetric(\n        AutofillMetrics::SCAN_CARD_ITEM_SHOWN);\n  }\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":200005,"func":"bool FrameLoader::isLoadingMainFrame() const\n{\n    Page* page = m_frame->page();\n    return page && m_frame == page->mainFrame();\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":274738,"func":"void Monitor::health_tick_stop()\n{\n  dout(15) << __func__ << dendl;\n\n  if (health_tick_event) {\n    timer.cancel_event(health_tick_event);\n    health_tick_event = NULL;\n  }\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":449327,"func":"SCK_AcceptConnection(int sock_fd, IPSockAddr *remote_addr)\n{\n  union sockaddr_all saddr;\n  socklen_t saddr_len = sizeof (saddr);\n  int conn_fd;\n\n  conn_fd = accept(sock_fd, &saddr.sa, &saddr_len);\n  if (conn_fd < 0) {\n    DEBUG_LOG(\"accept() failed : %s\", strerror(errno));\n    return INVALID_SOCK_FD;\n  }\n\n  if (!UTI_FdSetCloexec(conn_fd) || !set_socket_nonblock(conn_fd)) {\n    close(conn_fd);\n    return INVALID_SOCK_FD;\n  }\n\n  SCK_SockaddrToIPSockAddr(&saddr.sa, saddr_len, remote_addr);\n\n  return conn_fd;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":394707,"func":"static size_t php_bz2iop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)\n{\n\tstruct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;\n\tint bz2_ret;\n\n\tbz2_ret = BZ2_bzread(self->bz_file, buf, count);\n\n\tif (bz2_ret < 0) {\n\t\tstream->eof = 1;\n\t\treturn -1;\n\t}\n\tif (bz2_ret == 0) {\n\t\tstream->eof = 1;\n\t}\n\n\treturn (size_t)bz2_ret;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":285492,"func":"status_t CameraClient::checkPidAndHardware() const {\n status_t result = checkPid();\n if (result != NO_ERROR) return result;\n if (mHardware == 0) {\n        ALOGE(\"attempt to use a camera after disconnect() (pid %d)\", getCallingPid());\n return INVALID_OPERATION;\n }\n return NO_ERROR;\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":451576,"func":"static BROTLI_INLINE uint32_t BrotliGetAvailableBits(\n    const BrotliBitReader* br) {\n  return (BROTLI_64_BITS ? 64 : 32) - br->bit_pos_;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":316467,"func":"copy_buckets_for_remove_bucket(const struct ofgroup *ofgroup,\n                               struct ofgroup *new_ofgroup,\n                               uint32_t command_bucket_id)\n{\n    const struct ofputil_bucket *skip = NULL;\n\n    if (command_bucket_id == OFPG15_BUCKET_ALL) {\n        return 0;\n    }\n\n    if (command_bucket_id == OFPG15_BUCKET_FIRST) {\n        if (!ovs_list_is_empty(&ofgroup->buckets)) {\n            skip = ofputil_bucket_list_front(&ofgroup->buckets);\n        }\n    } else if (command_bucket_id == OFPG15_BUCKET_LAST) {\n        if (!ovs_list_is_empty(&ofgroup->buckets)) {\n            skip = ofputil_bucket_list_back(&ofgroup->buckets);\n        }\n    } else {\n        skip = ofputil_bucket_find(&ofgroup->buckets, command_bucket_id);\n        if (!skip) {\n            return OFPERR_OFPGMFC_UNKNOWN_BUCKET;\n        }\n    }\n\n    ofputil_bucket_clone_list(CONST_CAST(struct ovs_list *,\n                                         &new_ofgroup->buckets),\n                              &ofgroup->buckets, skip);\n\n    return 0;\n}\n","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":402765,"func":"ModuleExport size_t RegisterMIFFImage(void)\n{\n  char\n    version[MagickPathExtent];\n\n  MagickInfo\n    *entry;\n\n  *version='\\0';\n#if defined(MagickImageCoderSignatureText)\n  (void) CopyMagickString(version,MagickLibVersionText,MagickPathExtent);\n#if defined(ZLIB_VERSION)\n  (void) ConcatenateMagickString(version,\" with Zlib \",MagickPathExtent);\n  (void) ConcatenateMagickString(version,ZLIB_VERSION,MagickPathExtent);\n#endif\n#if defined(MAGICKCORE_BZLIB_DELEGATE)\n  (void) ConcatenateMagickString(version,\" and BZlib\",MagickPathExtent);\n#endif\n#endif\n  entry=AcquireMagickInfo(\"MIFF\",\"MIFF\",\"Magick Image File Format\");\n  entry->decoder=(DecodeImageHandler *) ReadMIFFImage;\n  entry->encoder=(EncodeImageHandler *) WriteMIFFImage;\n  entry->magick=(IsImageFormatHandler *) IsMIFF;\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  if (*version != '\\0')\n    entry->version=ConstantString(version);\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":292078,"func":"AP_DECLARE(void) ap_clear_auth_internal(void)\n{\n    auth_internal_per_conf_hooks = 0;\n    auth_internal_per_conf_providers = 0;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":377560,"func":"static int ide_drive_pio_post_load(void *opaque, int version_id)\n{\n    IDEState *s = opaque;\n\n    if (s->end_transfer_fn_idx >= ARRAY_SIZE(transfer_end_table)) {\n        return -EINVAL;\n    }\n    s->end_transfer_func = transfer_end_table[s->end_transfer_fn_idx];\n    s->data_ptr = s->io_buffer + s->cur_io_buffer_offset;\n    s->data_end = s->data_ptr + s->cur_io_buffer_len;\n\n    return 0;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":82478,"func":"static void svm_vcpu_reset(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tu32 dummy;\n\tu32 eax = 1;\n\n\tinit_vmcb(svm);\n\n\tkvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy);\n\tkvm_register_write(vcpu, VCPU_REGS_RDX, eax);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":331962,"func":"static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,\n\n                              ram_addr_t *ram_addr_abs)\n\n{\n\n    RAMBlock *block = NULL;\n\n\n\n    qemu_mutex_lock(&rs->src_page_req_mutex);\n\n    if (!QSIMPLEQ_EMPTY(&rs->src_page_requests)) {\n\n        struct RAMSrcPageRequest *entry =\n\n                                QSIMPLEQ_FIRST(&rs->src_page_requests);\n\n        block = entry->rb;\n\n        *offset = entry->offset;\n\n        *ram_addr_abs = (entry->offset + entry->rb->offset) &\n\n                        TARGET_PAGE_MASK;\n\n\n\n        if (entry->len > TARGET_PAGE_SIZE) {\n\n            entry->len -= TARGET_PAGE_SIZE;\n\n            entry->offset += TARGET_PAGE_SIZE;\n\n        } else {\n\n            memory_region_unref(block->mr);\n\n            QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);\n\n            g_free(entry);\n\n        }\n\n    }\n\n    qemu_mutex_unlock(&rs->src_page_req_mutex);\n\n\n\n    return block;\n\n}\n","target":1,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":292891,"func":"        nonce64 getNextNonce() {\n            SimpleMutex::scoped_lock lk(_randMutex);\n            return _random->nextInt64();\n        }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":313358,"func":"void ChromeContentBrowserClient::UpdateInspectorSetting(\n    RenderViewHost* rvh, const std::string& key, const std::string& value) {\n  content::BrowserContext* browser_context =\n      rvh->GetProcess()->GetBrowserContext();\n  DictionaryPrefUpdate update(\n      Profile::FromBrowserContext(browser_context)->GetPrefs(),\n      prefs::kWebKitInspectorSettings);\n  DictionaryValue* inspector_settings = update.Get();\n  inspector_settings->SetWithoutPathExpansion(key,\n                                              Value::CreateStringValue(value));\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":179962,"func":"CSPHandler::CSPHandler(bool is_platform_app)\n    : is_platform_app_(is_platform_app) {\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":451951,"func":"static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result)\n{\n\tif (__rbd_obj_handle_request(obj_req, &result))\n\t\trbd_img_handle_request(obj_req->img_request, result);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":333973,"func":"static struct omap_mpuio_s *omap_mpuio_init(MemoryRegion *memory,\n\n                hwaddr base,\n\n                qemu_irq kbd_int, qemu_irq gpio_int, qemu_irq wakeup,\n\n                omap_clk clk)\n\n{\n\n    struct omap_mpuio_s *s = (struct omap_mpuio_s *)\n\n            g_malloc0(sizeof(struct omap_mpuio_s));\n\n\n\n    s->irq = gpio_int;\n\n    s->kbd_irq = kbd_int;\n\n    s->wakeup = wakeup;\n\n    s->in = qemu_allocate_irqs(omap_mpuio_set, s, 16);\n\n    omap_mpuio_reset(s);\n\n\n\n    memory_region_init_io(&s->iomem, NULL, &omap_mpuio_ops, s,\n\n                          \"omap-mpuio\", 0x800);\n\n    memory_region_add_subregion(memory, base, &s->iomem);\n\n\n\n    omap_clk_adduser(clk, qemu_allocate_irq(omap_mpuio_onoff, s, 0));\n\n\n\n    return s;\n\n}\n","target":1,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":141349,"func":"void set_task_comm(struct task_struct *tsk, char *buf)\n{\n\ttask_lock(tsk);\n\n\ttrace_task_rename(tsk, buf);\n\n\t\/*\n\t * Threads may access current->comm without holding\n\t * the task lock, so write the string carefully.\n\t * Readers without a lock may see incomplete new\n\t * names but are safe from non-terminating string reads.\n\t *\/\n\tmemset(tsk->comm, 0, TASK_COMM_LEN);\n\twmb();\n\tstrlcpy(tsk->comm, buf, sizeof(tsk->comm));\n\ttask_unlock(tsk);\n\tperf_event_comm(tsk);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":502002,"func":"bool samdb_set_ntds_settings_dn(struct ldb_context *ldb, struct ldb_dn *ntds_settings_dn_in)\n{\n\tTALLOC_CTX *tmp_ctx;\n\tstruct ldb_dn *ntds_settings_dn_new;\n\tstruct ldb_dn *ntds_settings_dn_old;\n\n\t\/* see if we have a forced copy from provision *\/\n\tntds_settings_dn_old = talloc_get_type(ldb_get_opaque(ldb, \n\t\t\t\t\t\t\t      \"forced.ntds_settings_dn\"), struct ldb_dn);\n\n\ttmp_ctx = talloc_new(ldb);\n\tif (tmp_ctx == NULL) {\n\t\tgoto failed;\n\t}\n\n\tntds_settings_dn_new = ldb_dn_copy(tmp_ctx, ntds_settings_dn_in);\n\tif (!ntds_settings_dn_new) {\n\t\tgoto failed;\n\t}\n\n\t\/* set the DN in the ldb to avoid lookups during provision *\/\n\tif (ldb_set_opaque(ldb, \"forced.ntds_settings_dn\", ntds_settings_dn_new) != LDB_SUCCESS) {\n\t\tgoto failed;\n\t}\n\n\ttalloc_steal(ldb, ntds_settings_dn_new);\n\ttalloc_free(tmp_ctx);\n\ttalloc_free(ntds_settings_dn_old);\n\n\treturn true;\n\nfailed:\n\tDEBUG(1,(\"Failed to set our NTDS Settings DN in the ldb!\\n\"));\n\ttalloc_free(tmp_ctx);\n\treturn false;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":40876,"func":"flatpak_dir_current_ref (FlatpakDir   *self,\n                         const char   *name,\n                         GCancellable *cancellable)\n{\n  g_autoptr(GFile) base = NULL;\n  g_autoptr(GFile) dir = NULL;\n  g_autoptr(GFile) current_link = NULL;\n  g_autoptr(GFileInfo) file_info = NULL;\n  FlatpakDecomposed *decomposed;\n  char *ref;\n\n  base = g_file_get_child (flatpak_dir_get_path (self), \"app\");\n  dir = g_file_get_child (base, name);\n\n  current_link = g_file_get_child (dir, \"current\");\n\n  file_info = g_file_query_info (current_link, OSTREE_GIO_FAST_QUERYINFO,\n                                 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,\n                                 cancellable, NULL);\n  if (file_info == NULL)\n    return NULL;\n\n  ref = g_strconcat (\"app\/\", name, \"\/\", g_file_info_get_symlink_target (file_info), NULL);\n  decomposed = flatpak_decomposed_new_from_ref_take (ref, NULL);\n  if (decomposed == NULL)\n    g_free (ref);\n\n  return decomposed;\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":396439,"func":"do_device_not_available(struct pt_regs *regs, long error_code)\n{\n\tRCU_LOCKDEP_WARN(!rcu_is_watching(), \"entry code didn't wake RCU\");\n\tBUG_ON(use_eager_fpu());\n\n#ifdef CONFIG_MATH_EMULATION\n\tif (read_cr0() & X86_CR0_EM) {\n\t\tstruct math_emu_info info = { };\n\n\t\tconditional_sti(regs);\n\n\t\tinfo.regs = regs;\n\t\tmath_emulate(&info);\n\t\treturn;\n\t}\n#endif\n\tfpu__restore(¤t->thread.fpu); \/* interrupts still off *\/\n#ifdef CONFIG_X86_32\n\tconditional_sti(regs);\n#endif\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":27595,"func":"static char * _get_user_from_associd ( mysql_conn_t * mysql_conn , char * cluster , uint32_t associd ) {\n char * user = NULL ;\n char * query = NULL ;\n MYSQL_RES * result = NULL ;\n MYSQL_ROW row ;\n query = xstrdup_printf ( \"select user from \\\"%s_%s\\\" where id_assoc=%u\" , cluster , assoc_table , associd ) ;\n debug4 ( \"%d(%s:%d) query\\n%s\" , mysql_conn -> conn , THIS_FILE , __LINE__ , query ) ;\n if ( ! ( result = mysql_db_query_ret ( mysql_conn , query , 0 ) ) ) {\n xfree ( query ) ;\n return NULL ;\n }\n xfree ( query ) ;\n if ( ( row = mysql_fetch_row ( result ) ) && row [ 0 ] [ 0 ] ) user = xstrdup ( row [ 0 ] ) ;\n mysql_free_result ( result ) ;\n return user ;\n }","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":434942,"func":"MockReadFilterCallbacks::MockReadFilterCallbacks() {\n  ON_CALL(*this, connection()).WillByDefault(ReturnRef(connection_));\n  ON_CALL(*this, upstreamHost()).WillByDefault(ReturnPointee(&host_));\n  ON_CALL(*this, upstreamHost(_)).WillByDefault(SaveArg<0>(&host_));\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":501984,"func":"int samdb_reference_dn_is_our_ntdsa(struct ldb_context *ldb, struct ldb_dn *base,\n\t\t\t\t    const char *attribute, bool *is_ntdsa)\n{\n\tint ret;\n\tstruct ldb_dn *referenced_dn;\n\tTALLOC_CTX *tmp_ctx = talloc_new(ldb);\n\tif (tmp_ctx == NULL) {\n\t\treturn LDB_ERR_OPERATIONS_ERROR;\n\t}\n\tret = samdb_reference_dn(ldb, tmp_ctx, base, attribute, &referenced_dn);\n\tif (ret != LDB_SUCCESS) {\n\t\tDEBUG(0, (\"Failed to find object %s for attribute %s - %s\\n\", ldb_dn_get_linearized(base), attribute, ldb_errstring(ldb)));\n\t\treturn ret;\n\t}\n\n\tret = samdb_dn_is_our_ntdsa(ldb, referenced_dn, is_ntdsa);\n\t\n\ttalloc_free(tmp_ctx);\n\treturn ret;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":367991,"func":"impl_pause (DBusConnection * bus, DBusMessage * message, void *user_data)\n{\n  return NULL;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":361807,"func":"u32 ethtool_op_get_tx_csum(struct net_device *dev)\n{\n\treturn (dev->features & NETIF_F_ALL_CSUM) != 0;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":85590,"func":"static void digestNtoStr(const unsigned char digest[], int n, char *output)\n{\n    int i;\n    for (i = 0; i<n; ++i) {\n        pj_val_to_hex_digit(digest[i], output);\n        output += 2;\n    }\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":24831,"func":"SPL_METHOD ( SplFileInfo , func_name ) \\ {\n \\ spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;\n \\ zend_error_handling error_handling ;\n \\ if ( zend_parse_parameters_none ( ) == FAILURE ) {\n \\ return ;\n \\ }\n \\ \\ zend_replace_error_handling ( EH_THROW , spl_ce_RuntimeException , & error_handling TSRMLS_CC ) ;\n \\ spl_filesystem_object_get_file_name ( intern TSRMLS_CC ) ;\n \\ php_stat ( intern -> file_name , intern -> file_name_len , func_num , return_value TSRMLS_CC ) ;\n \\ zend_restore_error_handling ( & error_handling TSRMLS_CC ) ;\n \\ }\n FileInfoFunction ( getPerms , FS_PERMS ) FileInfoFunction ( getInode , FS_INODE ) FileInfoFunction ( getSize , FS_SIZE ) FileInfoFunction ( getOwner , FS_OWNER )","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":214675,"func":"std::string GetIdFromImeSpec(const std::string& ime_spec) {\n  static const std::string kPrefix(\"m17n:\");\n  return base::StartsWith(ime_spec, kPrefix, base::CompareCase::SENSITIVE)\n             ? ime_spec.substr(kPrefix.length())\n             : std::string();\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":262334,"func":"static inline struct sk_buff *tcp_send_head(const struct sock *sk)\n{\n\treturn sk->sk_send_head;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":304879,"func":"static struct dm_table *dm_get_live_table_fast(struct mapped_device *md) __acquires(RCU)\n{\n\trcu_read_lock();\n\treturn rcu_dereference(md->map);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":457895,"func":"static int io_poll_double_wake(struct wait_queue_entry *wait, unsigned mode,\n\t\t\t       int sync, void *key)\n{\n\tstruct io_kiocb *req = wait->private;\n\tstruct io_poll_iocb *poll = io_poll_get_single(req);\n\t__poll_t mask = key_to_poll(key);\n\n\t\/* for instances that support it check for an event match first: *\/\n\tif (mask && !(mask & poll->events))\n\t\treturn 0;\n\n\tlist_del_init(&wait->entry);\n\n\tif (poll && poll->head) {\n\t\tbool done;\n\n\t\tspin_lock(&poll->head->lock);\n\t\tdone = list_empty(&poll->wait.entry);\n\t\tif (!done)\n\t\t\tlist_del_init(&poll->wait.entry);\n\t\t\/* make sure double remove sees this as being gone *\/\n\t\twait->private = NULL;\n\t\tspin_unlock(&poll->head->lock);\n\t\tif (!done)\n\t\t\t__io_async_wake(req, poll, mask, io_poll_task_func);\n\t}\n\trefcount_dec(&req->refs);\n\treturn 1;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":490937,"func":"void ThreadCommand::count(uint32_t count) {\n  count_ = count;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":302237,"func":"void kfree_skb(struct sk_buff *skb)\n{\n\tif (unlikely(!skb))\n\t\treturn;\n\tif (likely(atomic_read(&skb->users) == 1))\n\t\tsmp_rmb();\n\telse if (likely(!atomic_dec_and_test(&skb->users)))\n\t\treturn;\n\ttrace_kfree_skb(skb, __builtin_return_address(0));\n\t__kfree_skb(skb);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":277881,"func":"void InputImeEventRouterFactory::RemoveProfile(Profile* profile) {\n  if (!profile || router_map_.empty())\n    return;\n  auto it = router_map_.find(profile);\n  if (it != router_map_.end() && it->first == profile) {\n    delete it->second;\n    router_map_.erase(it);\n  }\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":246666,"func":"bool RenderLayerCompositor::isMainFrame() const\n{\n    return !m_renderView->document().ownerElement();\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":513164,"func":"void Gfx::opSave(Object args[], int numArgs) {\n  saveState();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":87710,"func":"send_lock_cancel(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t\tstruct smb_hdr *in_buf,\n\t\t\tstruct smb_hdr *out_buf)\n{\n\tint bytes_returned;\n\tstruct cifs_ses *ses = tcon->ses;\n\tLOCK_REQ *pSMB = (LOCK_REQ *)in_buf;\n\n\t\/* We just modify the current in_buf to change\n\t   the type of lock from LOCKING_ANDX_SHARED_LOCK\n\t   or LOCKING_ANDX_EXCLUSIVE_LOCK to\n\t   LOCKING_ANDX_CANCEL_LOCK. *\/\n\n\tpSMB->LockType = LOCKING_ANDX_CANCEL_LOCK|LOCKING_ANDX_LARGE_FILES;\n\tpSMB->Timeout = 0;\n\tpSMB->hdr.Mid = get_next_mid(ses->server);\n\n\treturn SendReceive(xid, ses, in_buf, out_buf,\n\t\t\t&bytes_returned, 0);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":289124,"func":"void vp9_restore_layer_context ( VP9_COMP * const cpi ) {\n LAYER_CONTEXT * const lc = get_layer_context ( cpi ) ;\n const int old_frame_since_key = cpi -> rc . frames_since_key ;\n const int old_frame_to_key = cpi -> rc . frames_to_key ;\n cpi -> rc = lc -> rc ;\n cpi -> twopass = lc -> twopass ;\n cpi -> oxcf . target_bandwidth = lc -> target_bandwidth ;\n cpi -> alt_ref_source = lc -> alt_ref_source ;\n if ( cpi -> svc . number_temporal_layers > 1 ) {\n cpi -> rc . frames_since_key = old_frame_since_key ;\n cpi -> rc . frames_to_key = old_frame_to_key ;\n }\n }","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":277856,"func":"PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {\n  DCHECK(CanHaveTilingWithScale(contents_scale)) <<\n      \"contents_scale: \" << contents_scale;\n\n  PictureLayerTiling* tiling =\n      tilings_->AddTiling(contents_scale, raster_source_->GetSize());\n\n  DCHECK(raster_source_->HasRecordings());\n\n  return tiling;\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":103220,"func":"static void ca8210_dev_com_clear(struct ca8210_priv *priv)\n{\n\tflush_workqueue(priv->mlme_workqueue);\n\tdestroy_workqueue(priv->mlme_workqueue);\n\tflush_workqueue(priv->irq_workqueue);\n\tdestroy_workqueue(priv->irq_workqueue);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":425701,"func":"void *idr_replace(struct idr *idp, void *ptr, int id)\n{\n\tint n;\n\tstruct idr_layer *p, *old_p;\n\n\tp = idp->top;\n\tif (!p)\n\t\treturn ERR_PTR(-EINVAL);\n\n\tn = (p->layer+1) * IDR_BITS;\n\n\tid &= MAX_ID_MASK;\n\n\tif (id >= (1 << n))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tn -= IDR_BITS;\n\twhile ((n > 0) && p) {\n\t\tp = p->ary[(id >> n) & IDR_MASK];\n\t\tn -= IDR_BITS;\n\t}\n\n\tn = id & IDR_MASK;\n\tif (unlikely(p == NULL || !test_bit(n, &p->bitmap)))\n\t\treturn ERR_PTR(-ENOENT);\n\n\told_p = p->ary[n];\n\trcu_assign_pointer(p->ary[n], ptr);\n\n\treturn old_p;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":324129,"func":"void rgb8tobgr8(const uint8_t *src, uint8_t *dst, long src_size)\n\n{\n\n\tlong i;\n\n\tlong num_pixels = src_size;\n\n\tfor(i=0; i<num_pixels; i++)\n\n\t{\n\n\t    unsigned b,g,r;\n\n\t    register uint8_t rgb;\n\n\t    rgb = src[i];\n\n\t    r = (rgb&0x07);\n\n\t    g = (rgb&0x38)>>3;\n\n\t    b = (rgb&0xC0)>>6;\n\n\t    dst[i] = ((b<<1)&0x07) | ((g&0x07)<<3) | ((r&0x03)<<6);\n\n\t}\n\n}\n","target":1,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":491108,"func":"xfs_ioc_getlabel(\n\tstruct xfs_mount\t*mp,\n\tchar\t\t\t__user *user_label)\n{\n\tstruct xfs_sb\t\t*sbp = &mp->m_sb;\n\tchar\t\t\tlabel[XFSLABEL_MAX + 1];\n\n\t\/* Paranoia *\/\n\tBUILD_BUG_ON(sizeof(sbp->sb_fname) > FSLABEL_MAX);\n\n\t\/* 1 larger than sb_fname, so this ensures a trailing NUL char *\/\n\tmemset(label, 0, sizeof(label));\n\tspin_lock(&mp->m_sb_lock);\n\tstrncpy(label, sbp->sb_fname, XFSLABEL_MAX);\n\tspin_unlock(&mp->m_sb_lock);\n\n\tif (copy_to_user(user_label, label, sizeof(label)))\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":64125,"func":"small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon,\n\t\tvoid **request_buf)\n{\n\tint rc;\n\tunsigned int total_len;\n\tstruct smb2_pdu *pdu;\n\n\trc = smb2_reconnect(smb2_command, tcon);\n\tif (rc)\n\t\treturn rc;\n\n\t\/* BB eventually switch this to SMB2 specific small buf size *\/\n\t*request_buf = cifs_small_buf_get();\n\tif (*request_buf == NULL) {\n\t\t\/* BB should we add a retry in here if not a writepage? *\/\n\t\treturn -ENOMEM;\n\t}\n\n\tpdu = (struct smb2_pdu *)(*request_buf);\n\n\tfill_small_buf(smb2_command, tcon, get_sync_hdr(pdu), &total_len);\n\n\t\/* Note this is only network field converted to big endian *\/\n\tpdu->hdr.smb2_buf_length = cpu_to_be32(total_len);\n\n\tif (tcon != NULL) {\n#ifdef CONFIG_CIFS_STATS2\n\t\tuint16_t com_code = le16_to_cpu(smb2_command);\n\t\tcifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]);\n#endif\n\t\tcifs_stats_inc(&tcon->num_smbs_sent);\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":417822,"func":"Init_pack(void)\n{\n    rb_define_method(rb_cArray, \"pack\", pack_pack, -1);\n    rb_define_method(rb_cString, \"unpack\", pack_unpack, 1);\n    rb_define_method(rb_cString, \"unpack1\", pack_unpack1, 1);\n\n    id_associated = rb_make_internal_id();\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":519545,"func":"  virtual ulonglong get_max_int_value() const\n  {\n    return unsigned_flag ? 0xFFULL : 0x7FULL;\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":252478,"func":"int DownloadManagerImpl::NonMaliciousInProgressCount() const {\n  int count = 0;\n  for (const auto& it : downloads_) {\n    if (it.second->GetState() == download::DownloadItem::IN_PROGRESS &&\n        it.second->GetDangerType() !=\n            download::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL &&\n        it.second->GetDangerType() !=\n            download::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT &&\n        it.second->GetDangerType() !=\n            download::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST &&\n        it.second->GetDangerType() !=\n            download::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) {\n      ++count;\n    }\n  }\n  return count;\n}\n","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":31068,"func":"static int add_one_ref ( const char * path , const struct object_id * oid , int flag , void * cb_data ) {\n struct rev_info * revs = ( struct rev_info * ) cb_data ;\n struct object * object ;\n if ( ( flag & REF_ISSYMREF ) && ( flag & REF_ISBROKEN ) ) {\n warning ( \"symbolic ref is dangling: %s\" , path ) ;\n return 0 ;\n }\n object = parse_object_or_die ( oid -> hash , path ) ;\n add_pending_object ( revs , object , \"\" ) ;\n return 0 ;\n }","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":224226,"func":"void Tab::SetClosing(bool closing) {\n  closing_ = closing;\n  ActiveStateChanged();\n\n  if (closing) {\n    focus_ring_.reset();\n   }\n }\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":284644,"func":"ProcUnmapSubwindows(ClientPtr client)\n{\n    WindowPtr pWin;\n\n    REQUEST(xResourceReq);\n    int rc;\n\n    REQUEST_SIZE_MATCH(xResourceReq);\n    rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);\n    if (rc != Success)\n        return rc;\n    UnmapSubwindows(pWin);\n    return Success;\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":275384,"func":"HarfBuzzShaper::HarfBuzzRun::~HarfBuzzRun()\n{\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":16636,"func":"static void hscroll ( AVCodecContext * avctx ) {\n AnsiContext * s = avctx -> priv_data ;\n int i ;\n if ( s -> y < avctx -> height - s -> font_height ) {\n s -> y += s -> font_height ;\n return ;\n }\n i = 0 ;\n for ( ;\n i < avctx -> height - s -> font_height ;\n i ++ ) memcpy ( s -> frame -> data [ 0 ] + i * s -> frame -> linesize [ 0 ] , s -> frame -> data [ 0 ] + ( i + s -> font_height ) * s -> frame -> linesize [ 0 ] , avctx -> width ) ;\n for ( ;\n i < avctx -> height ;\n i ++ ) memset ( s -> frame -> data [ 0 ] + i * s -> frame -> linesize [ 0 ] , DEFAULT_BG_COLOR , avctx -> width ) ;\n }","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":156888,"func":"__napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)\n{\n\tstruct sk_buff *p;\n\n\tif (netpoll_rx_on(skb))\n\t\treturn GRO_NORMAL;\n\n\tfor (p = napi->gro_list; p; p = p->next) {\n\t\tNAPI_GRO_CB(p)->same_flow =\n\t\t\t(p->dev == skb->dev) &&\n\t\t\t!compare_ether_header(skb_mac_header(p),\n\t\t\t\t\t      skb_gro_mac_header(skb));\n\t\tNAPI_GRO_CB(p)->flush = 0;\n\t}\n\n\treturn dev_gro_receive(napi, skb);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":121740,"func":"mrb_io_close_on_exec_p(mrb_state *mrb, mrb_value self)\n{\n#if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)\n  struct mrb_io *fptr;\n  int ret;\n\n  fptr = io_get_open_fptr(mrb, self);\n\n  if (fptr->fd2 >= 0) {\n    if ((ret = fcntl(fptr->fd2, F_GETFD)) == -1) mrb_sys_fail(mrb, \"F_GETFD failed\");\n    if (!(ret & FD_CLOEXEC)) return mrb_false_value();\n  }\n\n  if ((ret = fcntl(fptr->fd, F_GETFD)) == -1) mrb_sys_fail(mrb, \"F_GETFD failed\");\n  if (!(ret & FD_CLOEXEC)) return mrb_false_value();\n  return mrb_true_value();\n\n#else\n  mrb_raise(mrb, E_NOTIMP_ERROR, \"IO#close_on_exec? is not supported on the platform\");\n  return mrb_false_value();\n#endif\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":400965,"func":"static LEX_CSTRING event_to_str(unsigned int event_class,\n                                unsigned long event_subclass)\n{\n  int count;\n  for (count= 0; event_subclass; count++, event_subclass >>= 1);\n\n  return event_names[event_class][count - 1];\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":180648,"func":"void ResourceMessageFilter::OnClipboardWriteObjectsSync(\n    const Clipboard::ObjectMap& objects,\n    base::SharedMemoryHandle bitmap_handle) {\n  DCHECK(base::SharedMemory::IsHandleValid(bitmap_handle))\n      << \"Bad bitmap handle\";\n  Clipboard::ObjectMap* long_living_objects = new Clipboard::ObjectMap(objects);\n\n  Clipboard::ReplaceSharedMemHandle(long_living_objects, bitmap_handle,\n                                    handle());\n\n  ChromeThread::PostTask(\n      ChromeThread::UI,\n      FROM_HERE,\n      new WriteClipboardTask(long_living_objects));\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":112141,"func":"static int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){\n  int isDifferentRow, rc;\n  assert( p->eCurType==CURTYPE_BTREE );\n  assert( p->uc.pCursor!=0 );\n  assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );\n  rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);\n  p->cacheStatus = CACHE_STALE;\n  if( isDifferentRow ) p->nullRow = 1;\n  return rc;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":430371,"func":"ippGetStatusCode(ipp_t *ipp)\t\t\/* I - IPP response or event message *\/\n{\n \/*\n  * Range check input...\n  *\/\n\n  if (!ipp)\n    return (IPP_STATUS_ERROR_INTERNAL);\n\n \/*\n  * Return the value...\n  *\/\n\n  return (ipp->request.status.status_code);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":2817,"func":"Pl_Count::write(unsigned char* buf, size_t len)\n{\n    if (len)\n    {\n\tthis->m->count += QIntC::to_offset(len);\n\tgetNext()->write(buf, len);\n\tthis->m->last_char = buf[len - 1];\n    }\n}","target":1,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":4736,"func":"static inline int xsave_state_booting(struct xsave_struct *fx, u64 mask)\n{\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\tint err = 0;\n\n\tWARN_ON(system_state != SYSTEM_BOOTING);\n\n\tif (boot_cpu_has(X86_FEATURE_XSAVES))\n\t\tasm volatile(\"1:\"XSAVES\"\\n\\t\"\n\t\t\t\"2:\\n\\t\"\n\t\t\t: : \"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t\t:   \"memory\");\n\telse\n\t\tasm volatile(\"1:\"XSAVE\"\\n\\t\"\n\t\t\t\"2:\\n\\t\"\n\t\t\t: : \"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t\t:   \"memory\");\n\n\tasm volatile(xstate_fault\n\t\t     : \"0\" (0)\n\t\t     : \"memory\");\n\n\treturn err;\n}","target":1,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":483309,"func":"struct cgroup *cgroup_get_from_path(const char *path)\n{\n\tstruct kernfs_node *kn;\n\tstruct cgroup *cgrp = ERR_PTR(-ENOENT);\n\n\tkn = kernfs_walk_and_get(cgrp_dfl_root.cgrp.kn, path);\n\tif (!kn)\n\t\tgoto out;\n\n\tif (kernfs_type(kn) != KERNFS_DIR) {\n\t\tcgrp = ERR_PTR(-ENOTDIR);\n\t\tgoto out_kernfs;\n\t}\n\n\trcu_read_lock();\n\n\tcgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);\n\tif (!cgrp || !cgroup_tryget(cgrp))\n\t\tcgrp = ERR_PTR(-ENOENT);\n\n\trcu_read_unlock();\n\nout_kernfs:\n\tkernfs_put(kn);\nout:\n\treturn cgrp;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":322437,"func":"void pci_bridge_exitfn(PCIDevice *pci_dev)\n\n{\n\n    PCIBridge *s = DO_UPCAST(PCIBridge, dev, pci_dev);\n\n    assert(QLIST_EMPTY(&s->sec_bus.child));\n\n    QLIST_REMOVE(&s->sec_bus, sibling);\n\n    pci_bridge_region_cleanup(s);\n\n    memory_region_destroy(&s->address_space_mem);\n\n    memory_region_destroy(&s->address_space_io);\n\n    \/* qbus_free() is called automatically by qdev_free() *\/\n\n}\n","target":1,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":157254,"func":"PG::RecoveryCtx OSD::create_context()\n{\n  ObjectStore::Transaction *t = new ObjectStore::Transaction;\n  C_Contexts *on_applied = new C_Contexts(cct);\n  C_Contexts *on_safe = new C_Contexts(cct);\n  map<int, map<spg_t,pg_query_t> > *query_map =\n    new map<int, map<spg_t, pg_query_t> >;\n  map<int,vector<pair<pg_notify_t, PastIntervals> > > *notify_list =\n    new map<int, vector<pair<pg_notify_t, PastIntervals> > >;\n  map<int,vector<pair<pg_notify_t, PastIntervals> > > *info_map =\n    new map<int,vector<pair<pg_notify_t, PastIntervals> > >;\n  PG::RecoveryCtx rctx(query_map, info_map, notify_list,\n\t\t       on_applied, on_safe, t);\n  return rctx;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":188261,"func":"int bdrv_commit_all(void)\n{\n    BlockDriverState *bs;\n\n    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {\n        if (bs->drv && bs->backing_hd) {\n            int ret = bdrv_commit(bs);\n            if (ret < 0) {\n                return ret;\n            }\n        }\n    }\n    return 0;\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":96470,"func":"static inline void ModulateHCLp(const double percent_hue,\n  const double percent_chroma,const double percent_luma,double *red,\n  double *green,double *blue)\n{\n  double\n    hue,\n    luma,\n    chroma;\n\n  \/*\n    Increase or decrease color luma, chroma, or hue.\n  *\/\n  ConvertRGBToHCLp(*red,*green,*blue,&hue,&chroma,&luma);\n  hue+=fmod((percent_hue-100.0),200.0)\/200.0;\n  chroma*=0.01*percent_chroma;\n  luma*=0.01*percent_luma;\n  ConvertHCLpToRGB(hue,chroma,luma,red,green,blue);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":250208,"func":"static void removeEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    TestObjectPythonV8Internal::removeEventListenerMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":397459,"func":"static void ringbuf_chr_close(struct CharDriverState *chr)\n{\n    RingBufCharDriver *d = chr->opaque;\n\n    g_free(d->cbuf);\n    g_free(d);\n    chr->opaque = NULL;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":81034,"func":"static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)\n{\n\tswitch (p->share) {\n\tcase XFRM_SHARE_ANY:\n\tcase XFRM_SHARE_SESSION:\n\tcase XFRM_SHARE_USER:\n\tcase XFRM_SHARE_UNIQUE:\n\t\tbreak;\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tswitch (p->action) {\n\tcase XFRM_POLICY_ALLOW:\n\tcase XFRM_POLICY_BLOCK:\n\t\tbreak;\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tswitch (p->sel.family) {\n\tcase AF_INET:\n\t\tbreak;\n\n\tcase AF_INET6:\n#if IS_ENABLED(CONFIG_IPV6)\n\t\tbreak;\n#else\n\t\treturn  -EAFNOSUPPORT;\n#endif\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\treturn verify_policy_dir(p->dir);\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":496552,"func":"  static Plane_3 convert(Plane_3 p){return p;}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":181644,"func":"FileTransfer::addFileToExeptionList( const char* filename )\n{\n\tif ( !ExceptionFiles ) {\n\t\tExceptionFiles = new StringList;\n\t\tASSERT ( NULL != ExceptionFiles );\n\t} else if ( ExceptionFiles->file_contains ( filename ) ) {\n\t\treturn true;\n\t}\n\tExceptionFiles->append ( filename );\n\treturn true;\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":358597,"func":"static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,\n\t\t\t\t\t struct desc_struct *seg_desc)\n{\n\tgpa_t gpa;\n\tstruct descriptor_table dtable;\n\tu16 index = selector >> 3;\n\n\tget_segment_descriptor_dtable(vcpu, selector, &dtable);\n\n\tif (dtable.limit < index * 8 + 7) {\n\t\tkvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc);\n\t\treturn 1;\n\t}\n\tgpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base);\n\tgpa += index * 8;\n\treturn kvm_read_guest(vcpu->kvm, gpa, seg_desc, 8);\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":393438,"func":"referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)\n{\n    callbacks++;\n    if (quiet)\n\treturn;\n    fprintf(SAXdebug, \"SAX.reference(%s)\\n\", name);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":519586,"func":"void Field_varstring::sql_rpl_type(String *res) const\n{\n  CHARSET_INFO *cs=charset();\n  if (Field_varstring::has_charset())\n  {\n    size_t length= cs->cset->snprintf(cs, (char*) res->ptr(),\n                                      res->alloced_length(),\n                                      \"varchar(%u octets) character set %s\",\n                                      field_length,\n                                      charset()->csname);\n    res->length(length);\n  }\n  else\n    Field_varstring::sql_type(*res);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":398284,"func":"void js_pushlstring(js_State *J, const char *v, int n)\n{\n\tCHECKSTACK(1);\n\tif (n <= soffsetof(js_Value, type)) {\n\t\tchar *s = STACK[TOP].u.shrstr;\n\t\twhile (n--) *s++ = *v++;\n\t\t*s = 0;\n\t\tSTACK[TOP].type = JS_TSHRSTR;\n\t} else {\n\t\tSTACK[TOP].type = JS_TMEMSTR;\n\t\tSTACK[TOP].u.memstr = jsV_newmemstring(J, v, n);\n\t}\n\t++TOP;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":107368,"func":"ovsinst_bitmap_from_openflow(ovs_be32 ofpit_bitmap, enum ofp_version version)\n{\n    uint32_t ovsinst_bitmap = 0;\n    const struct ovsinst_map *x;\n\n    for (x = get_ovsinst_map(version); x->ofpit >= 0; x++) {\n        if (ofpit_bitmap & htonl(1u << x->ofpit)) {\n            ovsinst_bitmap |= 1u << x->ovsinst;\n        }\n    }\n    return ovsinst_bitmap;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":453468,"func":"group_sched_out(struct perf_event *group_event,\n\t\tstruct perf_cpu_context *cpuctx,\n\t\tstruct perf_event_context *ctx)\n{\n\tstruct perf_event *event;\n\n\tif (group_event->state != PERF_EVENT_STATE_ACTIVE)\n\t\treturn;\n\n\tperf_pmu_disable(ctx->pmu);\n\n\tevent_sched_out(group_event, cpuctx, ctx);\n\n\t\/*\n\t * Schedule out siblings (if any):\n\t *\/\n\tfor_each_sibling_event(event, group_event)\n\t\tevent_sched_out(event, cpuctx, ctx);\n\n\tperf_pmu_enable(ctx->pmu);\n\n\tif (group_event->attr.exclusive)\n\t\tcpuctx->exclusive = 0;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":333718,"func":"static void pc_xen_hvm_init(QEMUMachineInitArgs *args)\n\n{\n\n    if (xen_hvm_init() != 0) {\n\n        hw_error(\"xen hardware virtual machine initialisation failed\");\n\n    }\n\n    pc_init_pci(args);\n\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":428526,"func":"replace_rw_async_data_free (ReplaceRWAsyncData *data)\n{\n  g_free (data->etag);\n  g_free (data);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":239129,"func":"    virtual void drawLayers()\n    {\n        CCLayerTreeHostImpl::drawLayers();\n        m_testHooks->drawLayersOnCCThread(this);\n    }\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":212725,"func":"static bool VerifyNumber(const uint8* buffer,\n                         int buffer_size,\n                         int* offset,\n                         int max_digits) {\n  RCHECK(*offset < buffer_size);\n\n  while (isspace(buffer[*offset])) {\n    ++(*offset);\n    RCHECK(*offset < buffer_size);\n  }\n\n  int numSeen = 0;\n  while (--max_digits >= 0 && isdigit(buffer[*offset])) {\n    ++numSeen;\n    ++(*offset);\n    if (*offset >= buffer_size)\n      return true;  \/\/ Out of space but seen a digit.\n  }\n\n  return (numSeen > 0);\n}\n","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":431946,"func":"static inline unsigned int xfrm_expire_msgsize(void)\n{\n\treturn NLMSG_ALIGN(sizeof(struct xfrm_user_expire))\n\t       + nla_total_size(sizeof(struct xfrm_mark));\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":457470,"func":"int ring_buffer_print_entry_header(struct trace_seq *s)\n{\n\ttrace_seq_puts(s, \"# compressed entry header\\n\");\n\ttrace_seq_puts(s, \"\\ttype_len    :    5 bits\\n\");\n\ttrace_seq_puts(s, \"\\ttime_delta  :   27 bits\\n\");\n\ttrace_seq_puts(s, \"\\tarray       :   32 bits\\n\");\n\ttrace_seq_putc(s, '\\n');\n\ttrace_seq_printf(s, \"\\tpadding     : type == %d\\n\",\n\t\t\t RINGBUF_TYPE_PADDING);\n\ttrace_seq_printf(s, \"\\ttime_extend : type == %d\\n\",\n\t\t\t RINGBUF_TYPE_TIME_EXTEND);\n\ttrace_seq_printf(s, \"\\ttime_stamp : type == %d\\n\",\n\t\t\t RINGBUF_TYPE_TIME_STAMP);\n\ttrace_seq_printf(s, \"\\tdata max type_len  == %d\\n\",\n\t\t\t RINGBUF_TYPE_DATA_TYPE_LEN_MAX);\n\n\treturn !trace_seq_has_overflowed(s);\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":208334,"func":"void OmniboxViewViews::OnFocus() {\n  views::Textfield::OnFocus();\n  model()->OnSetFocus(false);\n\n  if (saved_selection_for_focus_change_.IsValid()) {\n    SelectRange(saved_selection_for_focus_change_);\n    saved_selection_for_focus_change_ = gfx::Range::InvalidRange();\n  }\n\n  GetRenderText()->SetElideBehavior(gfx::NO_ELIDE);\n\n  if (model()->is_keyword_hint())\n    location_bar_view_->Layout();\n\n#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)\n  if (controller()->GetToolbarModel()->ShouldDisplayURL()) {\n    feature_engagement::NewTabTrackerFactory::GetInstance()\n        ->GetForProfile(location_bar_view_->profile())\n        ->OnOmniboxFocused();\n  }\n#endif\n}\n","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":383329,"func":"gpgsm_get_fingerprint_string (ksba_cert_t cert, int algo)\n{\n  unsigned char digest[MAX_DIGEST_LEN];\n  char *buf;\n  int len;\n\n  if (!algo)\n    algo = GCRY_MD_SHA1;\n\n  len = gcry_md_get_algo_dlen (algo);\n  assert (len <= MAX_DIGEST_LEN );\n  gpgsm_get_fingerprint (cert, algo, digest, NULL);\n  buf = xmalloc (len*3+1);\n  bin2hexcolon (digest, len, buf);\n  return buf;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":251003,"func":"void Performance::BuildJSONValue(V8ObjectBuilder& builder) const {\n  builder.AddNumber(\"timeOrigin\", timeOrigin());\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":37270,"func":"static void se_io_cb(void *context, u8 *apdu, size_t apdu_len, int err)\n{\n\tstruct se_io_ctx *ctx = context;\n\tstruct sk_buff *msg;\n\tvoid *hdr;\n\n\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);\n\tif (!msg) {\n\t\tkfree(ctx);\n\t\treturn;\n\t}\n\n\thdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,\n\t\t\t  NFC_CMD_SE_IO);\n\tif (!hdr)\n\t\tgoto free_msg;\n\n\tif (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, ctx->dev_idx) ||\n\t    nla_put_u32(msg, NFC_ATTR_SE_INDEX, ctx->se_idx) ||\n\t    nla_put(msg, NFC_ATTR_SE_APDU, apdu_len, apdu))\n\t\tgoto nla_put_failure;\n\n\tgenlmsg_end(msg, hdr);\n\n\tgenlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);\n\n\tkfree(ctx);\n\n\treturn;\n\nnla_put_failure:\nfree_msg:\n\tnlmsg_free(msg);\n\tkfree(ctx);\n\n\treturn;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":253692,"func":"void WebSettingsImpl::setStandardFontFamily(const WebString& font)\n{\n    m_settings->setStandardFontFamily(font);\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":238803,"func":"DictionaryValue* BrowserEventRouter::TabEntry::DidNavigate(\n    const WebContents* contents) {\n  complete_waiting_on_load_ = true;\n  DictionaryValue* changed_properties = new DictionaryValue();\n  changed_properties->SetString(tab_keys::kStatusKey,\n      tab_keys::kStatusValueLoading);\n\n  if (contents->GetURL() != url_) {\n    url_ = contents->GetURL();\n    changed_properties->SetString(tab_keys::kUrlKey, url_.spec());\n  }\n\n  return changed_properties;\n}\n","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":147953,"func":"static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)\n{\n\tstruct ucma_context *ctx;\n\n\tmutex_lock(&mut);\n\tctx = _ucma_find_context(id, file);\n\tif (!IS_ERR(ctx)) {\n\t\tif (ctx->closing)\n\t\t\tctx = ERR_PTR(-EIO);\n\t\telse\n\t\t\tatomic_inc(&ctx->ref);\n\t}\n\tmutex_unlock(&mut);\n\treturn ctx;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":337601,"func":"static int vnc_display_connect(VncDisplay *vd,\n\n                               SocketAddressLegacy **saddr,\n\n                               size_t nsaddr,\n\n                               SocketAddressLegacy **wsaddr,\n\n                               size_t nwsaddr,\n\n                               Error **errp)\n\n{\n\n    \/* connect to viewer *\/\n\n    QIOChannelSocket *sioc = NULL;\n\n    if (nwsaddr != 0) {\n\n        error_setg(errp, \"Cannot use websockets in reverse mode\");\n\n        return -1;\n\n    }\n\n    if (nsaddr != 1) {\n\n        error_setg(errp, \"Expected a single address in reverse mode\");\n\n        return -1;\n\n    }\n\n    \/* TODO SOCKET_ADDRESS_LEGACY_KIND_FD when fd has AF_UNIX *\/\n\n    vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX;\n\n    sioc = qio_channel_socket_new();\n\n    qio_channel_set_name(QIO_CHANNEL(sioc), \"vnc-reverse\");\n\n    if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) {\n\n        return -1;\n\n    }\n\n    vnc_connect(vd, sioc, false, false);\n\n    object_unref(OBJECT(sioc));\n\n    return 0;\n\n}\n","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":382021,"func":"void *zend_shared_alloc(size_t size)\n{\n\tint i;\n\tunsigned int block_size = ZEND_ALIGNED_SIZE(size);\n\n#if 1\n\tif (!ZCG(locked)) {\n\t\tzend_accel_error(ACCEL_LOG_ERROR, \"Shared memory lock not obtained\");\n\t}\n#endif\n\tif (block_size > ZSMMG(shared_free)) { \/* No hope to find a big-enough block *\/\n\t\tSHARED_ALLOC_FAILED();\n\t\treturn NULL;\n\t}\n\tfor (i = 0; i < ZSMMG(shared_segments_count); i++) {\n\t\tif (ZSMMG(shared_segments)[i]->size - ZSMMG(shared_segments)[i]->pos >= block_size) { \/* found a valid block *\/\n\t\t\tvoid *retval = (void *) (((char *) ZSMMG(shared_segments)[i]->p) + ZSMMG(shared_segments)[i]->pos);\n\n\t\t\tZSMMG(shared_segments)[i]->pos += block_size;\n\t\t\tZSMMG(shared_free) -= block_size;\n\t\t\tmemset(retval, 0, block_size);\n\t\t\treturn retval;\n\t\t}\n\t}\n\tSHARED_ALLOC_FAILED();\n\treturn NULL;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":203015,"func":" NodeIterator::~NodeIterator()\n {\n    if (!root()->isAttributeNode())\n        root()->document().detachNodeIterator(this);\n }\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":374411,"func":"fmgr(Oid procedureId,...)\n{\n\tFmgrInfo\tflinfo;\n\tFunctionCallInfoData fcinfo;\n\tint\t\t\tn_arguments;\n\tDatum\t\tresult;\n\n\tfmgr_info(procedureId, &flinfo);\n\n\tMemSet(&fcinfo, 0, sizeof(fcinfo));\n\tfcinfo.flinfo = &flinfo;\n\tfcinfo.nargs = flinfo.fn_nargs;\n\tn_arguments = fcinfo.nargs;\n\n\tif (n_arguments > 0)\n\t{\n\t\tva_list\t\tpvar;\n\t\tint\t\t\ti;\n\n\t\tif (n_arguments > FUNC_MAX_ARGS)\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_TOO_MANY_ARGUMENTS),\n\t\t\t errmsg(\"function %u has too many arguments (%d, maximum is %d)\",\n\t\t\t\t\tflinfo.fn_oid, n_arguments, FUNC_MAX_ARGS)));\n\t\tva_start(pvar, procedureId);\n\t\tfor (i = 0; i < n_arguments; i++)\n\t\t\tfcinfo.arg[i] = PointerGetDatum(va_arg(pvar, char *));\n\t\tva_end(pvar);\n\t}\n\n\tresult = FunctionCallInvoke(&fcinfo);\n\n\t\/* Check for null result, since caller is clearly not expecting one *\/\n\tif (fcinfo.isnull)\n\t\telog(ERROR, \"function %u returned NULL\", flinfo.fn_oid);\n\n\treturn DatumGetPointer(result);\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":448019,"func":"int sftp_reply_attr(sftp_client_message msg, sftp_attributes attr) {\n  ssh_buffer out;\n\n  out = ssh_buffer_new();\n  if (out == NULL) {\n    return -1;\n  }\n\n  if (ssh_buffer_add_u32(out, msg->id) < 0 ||\n      buffer_add_attributes(out, attr) < 0 ||\n      sftp_packet_write(msg->sftp, SSH_FXP_ATTRS, out) < 0) {\n    SSH_BUFFER_FREE(out);\n    return -1;\n  }\n  SSH_BUFFER_FREE(out);\n\n  return 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":26588,"func":"static uint64_t byte_budget ( const EVP_CIPHER * cipher ) {\n int ivlen = EVP_CIPHER_iv_length ( cipher ) ;\n int blklen = EVP_CIPHER_block_size ( cipher ) ;\n int len = blklen > 1 ? blklen : ivlen > 1 ? ivlen : 8 ;\n int bits = len * 4 - 1 ;\n return bits < 64 ? UINT64_C ( 1 ) << bits : UINT64_MAX ;\n }","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":69295,"func":"archive_wstring_ensure(struct archive_wstring *as, size_t s)\n{\n\treturn (struct archive_wstring *)\n\t\tarchive_string_ensure((struct archive_string *)as,\n\t\t\t\t\ts * sizeof(wchar_t));\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":444074,"func":"TEST_P(Http2CodecImplTest, LargeRequestHeadersAtMaxConfigurable) {\n  \/\/ Raising the limit past this triggers some unexpected nghttp2 error.\n  \/\/ Further debugging required to increase past ~96 KiB.\n  max_request_headers_kb_ = 96;\n  initialize();\n\n  TestRequestHeaderMapImpl request_headers;\n  HttpTestUtility::addDefaultHeaders(request_headers);\n  std::string long_string = std::string(1024, 'q');\n  for (int i = 0; i < 95; i++) {\n    request_headers.addCopy(std::to_string(i), long_string);\n  }\n\n  EXPECT_CALL(request_decoder_, decodeHeaders_(_, _)).Times(1);\n  EXPECT_CALL(server_stream_callbacks_, onResetStream(_, _)).Times(0);\n  request_encoder_->encodeHeaders(request_headers, true);\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":166459,"func":"void GLES2DecoderWithShaderTestBase::SetupIndexBuffer() {\n  DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER,\n               client_element_buffer_id_,\n               kServiceElementBufferId);\n  static const GLshort indices[] = {100, 1, 2, 3, 4, 5, 6, 7, 100, 9};\n  COMPILE_ASSERT(arraysize(indices) == kNumIndices, Indices_is_not_10);\n  DoBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices));\n  DoBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(indices), indices);\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":79914,"func":"static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)\n{\n\tstruct nfs4_exception exception = { };\n\tint err;\n\n\tdo {\n\t\terr = nfs4_handle_exception(NFS_SERVER(state->inode),\n\t\t\t\t_nfs4_proc_setlk(state, cmd, request),\n\t\t\t\t&exception);\n\t} while (exception.retry);\n\treturn err;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":63844,"func":"inline void TransposeConv(\n    const ConvParams& params, const RuntimeShape& input_shape,\n    const float* input_data, const RuntimeShape& filter_shape,\n    const float* filter_data, const RuntimeShape& output_shape,\n    float* output_data, const RuntimeShape& im2col_shape, float* im2col_data) {\n  ruy::profiler::ScopeLabel label(\"TransposeConv\");\n  \/\/ Note we could use transposed weights with forward conv for unstrided\n  \/\/ cases. But we are already getting good performance with this code as-is.\n  TFLITE_DCHECK(im2col_data);\n  TransposeIm2col(params, 0, input_shape, input_data, filter_shape,\n                  output_shape, im2col_data);\n\n  const auto im2col_matrix_map =\n      MapAsMatrixWithLastDimAsRows(im2col_data, im2col_shape);\n  const auto filter_matrix_map =\n      MapAsMatrixWithFirstDimAsCols(filter_data, filter_shape);\n  auto output_matrix_map =\n      MapAsMatrixWithLastDimAsRows(output_data, output_shape);\n\n  Gemm(filter_matrix_map.transpose(), im2col_matrix_map, &output_matrix_map);\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":149065,"func":"DEFUN(linend, LINE_END, \"Go to the end of the line\")\n{\n    if (Currentbuf->firstLine == NULL)\n\treturn;\n    while (Currentbuf->currentLine->next\n\t   && Currentbuf->currentLine->next->bpos)\n\tcursorDown0(Currentbuf, 1);\n    Currentbuf->pos = Currentbuf->currentLine->len - 1;\n    arrangeCursor(Currentbuf);\n    displayBuffer(Currentbuf, B_NORMAL);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":357448,"func":"int audit_match_class(int class, unsigned syscall)\n{\n\tif (unlikely(syscall >= AUDIT_BITMASK_SIZE * 32))\n\t\treturn 0;\n\tif (unlikely(class >= AUDIT_SYSCALL_CLASSES || !classes[class]))\n\t\treturn 0;\n\treturn classes[class][AUDIT_WORD(syscall)] & AUDIT_BIT(syscall);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":230453,"func":"exsltDateAddDurationFunction (xmlXPathParserContextPtr ctxt, int nargs)\n{\n    xmlChar *ret, *xstr, *ystr;\n\n    if (nargs != 2) {\n\txmlXPathSetArityError(ctxt);\n\treturn;\n    }\n    ystr = xmlXPathPopString(ctxt);\n    if (xmlXPathCheckError(ctxt))\n\treturn;\n\n    xstr = xmlXPathPopString(ctxt);\n    if (xmlXPathCheckError(ctxt)) {\n        xmlFree(ystr);\n\treturn;\n    }\n\n    ret = exsltDateAddDuration(xstr, ystr);\n\n    xmlFree(ystr);\n    xmlFree(xstr);\n\n    if (ret == NULL)\n        xmlXPathReturnEmptyString(ctxt);\n    else\n\txmlXPathReturnString(ctxt, ret);\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":480259,"func":"\nstatic bool io_cancel_defer_files(struct io_ring_ctx *ctx,\n\t\t\t\t  struct task_struct *task, bool cancel_all)\n{\n\tstruct io_defer_entry *de;\n\tLIST_HEAD(list);\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tlist_for_each_entry_reverse(de, &ctx->defer_list, list) {\n\t\tif (io_match_task(de->req, task, cancel_all)) {\n\t\t\tlist_cut_position(&list, &ctx->defer_list, &de->list);\n\t\t\tbreak;\n\t\t}\n\t}\n\tspin_unlock_irq(&ctx->completion_lock);\n\tif (list_empty(&list))\n\t\treturn false;\n\n\twhile (!list_empty(&list)) {\n\t\tde = list_first_entry(&list, struct io_defer_entry, list);\n\t\tlist_del_init(&de->list);\n\t\tio_req_complete_failed(de->req, -ECANCELED);\n\t\tkfree(de);\n\t}\n\treturn true;","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":86870,"func":"user_func_error(int error, char_u *name, funcexe_T *funcexe)\n{\n    switch (error)\n    {\n\tcase FCERR_UNKNOWN:\n\t\tif (funcexe->fe_found_var)\n\t\t    semsg(_(e_not_callable_type_str), name);\n\t\telse\n\t\t    emsg_funcname(e_unknown_function_str, name);\n\t\tbreak;\n\tcase FCERR_NOTMETHOD:\n\t\temsg_funcname(\n\t\t\tN_(e_cannot_use_function_as_method_str), name);\n\t\tbreak;\n\tcase FCERR_DELETED:\n\t\temsg_funcname(e_function_was_deleted_str, name);\n\t\tbreak;\n\tcase FCERR_TOOMANY:\n\t\temsg_funcname(e_too_many_arguments_for_function_str, name);\n\t\tbreak;\n\tcase FCERR_TOOFEW:\n\t\temsg_funcname(e_not_enough_arguments_for_function_str, name);\n\t\tbreak;\n\tcase FCERR_SCRIPT:\n\t\temsg_funcname(\n\t\t    e_using_sid_not_in_script_context_str, name);\n\t\tbreak;\n\tcase FCERR_DICT:\n\t\temsg_funcname(e_calling_dict_function_without_dictionary_str,\n\t\t\t\t\t\t\t\t\t name);\n\t\tbreak;\n    }\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":55094,"func":"gc_generational_mode_set(mrb_state *mrb, mrb_value self)\n{\n  mrb_bool enable;\n\n  mrb_get_args(mrb, \"b\", &enable);\n  if (mrb->gc.generational != enable)\n    change_gen_gc_mode(mrb, &mrb->gc, enable);\n\n  return mrb_bool_value(enable);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":402916,"func":"string t_cpp_generator::namespace_open(string ns) {\n  if (ns.size() == 0) {\n    return \"\";\n  }\n  string result = \"\";\n  string separator = \"\";\n  string::size_type loc;\n  while ((loc = ns.find(\".\")) != string::npos) {\n    result += separator;\n    result += \"namespace \";\n    result += ns.substr(0, loc);\n    result += \" {\";\n    separator = \" \";\n    ns = ns.substr(loc + 1);\n  }\n  if (ns.size() > 0) {\n    result += separator + \"namespace \" + ns + \" {\";\n  }\n  return result;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":285110,"func":"  Ins_ODD( INS_ARG )\n  {\n    DO_ODD\n  }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":123233,"func":"vrrp_netlink_cmd_rcv_bufs_force_handler(vector_t *strvec)\n{\n\tint res = true;\n\n\tif (!strvec)\n\t\treturn;\n\n\tif (vector_size(strvec) >= 2) {\n\t\tres = check_true_false(strvec_slot(strvec,1));\n\t\tif (res < 0) {\n\t\t\treport_config_error(CONFIG_GENERAL_ERROR, \"Invalid value '%s' for global vrrp_netlink_cmd_rcv_bufs_force specified\", FMT_STR_VSLOT(strvec, 1));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tglobal_data->vrrp_netlink_cmd_rcv_bufs_force = res;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":116289,"func":"static int x509_name_oneline(X509_NAME *a, char *buf, size_t size)\n{\n  BIO *bio_out = BIO_new(BIO_s_mem());\n  BUF_MEM *biomem;\n  int rc;\n\n  if(!bio_out)\n    return 1; \/* alloc failed! *\/\n\n  rc = X509_NAME_print_ex(bio_out, a, 0, XN_FLAG_SEP_SPLUS_SPC);\n  BIO_get_mem_ptr(bio_out, &biomem);\n\n  if((size_t)biomem->length < size)\n    size = biomem->length;\n  else\n    size--; \/* don't overwrite the buffer end *\/\n\n  memcpy(buf, biomem->data, size);\n  buf[size] = 0;\n\n  BIO_free(bio_out);\n\n  return !rc;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":389426,"func":"void cgit_stats_link(const char *name, const char *title, const char *class,\n\t\t     const char *head, const char *path)\n{\n\treporevlink(\"stats\", name, title, class, head, NULL, path);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":480105,"func":"evdev_device_get_sysname(struct evdev_device *device)\n{\n\treturn device->sysname;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":446492,"func":"void virDomainHostdevDefFree(virDomainHostdevDefPtr def)\n{\n    if (!def)\n        return;\n\n    \/* free all subordinate objects *\/\n    virDomainHostdevDefClear(def);\n\n    \/* If there is a parentnet device object, it will handle freeing\n     * the memory.\n     *\/\n    if (!def->parentnet)\n        VIR_FREE(def);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":506781,"func":"static char *sapi_cli_server_read_cookies(TSRMLS_D) \/* {{{ *\/\n{\n\tphp_cli_server_client *client = SG(server_context);\n\tchar **val;\n\tif (FAILURE == zend_hash_find(&client->request.headers, \"Cookie\", sizeof(\"Cookie\"), (void**)&val)) {\n\t\treturn NULL;\n\t}\n\treturn *val;\n} \/* }}} *\/","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":323258,"func":"static void i440fx_realize(PCIDevice *dev, Error **errp)\n\n{\n\n    dev->config[I440FX_SMRAM] = 0x02;\n\n\n\n    if (object_property_get_bool(qdev_get_machine(), \"iommu\", NULL)) {\n\n        error_report(\"warning: i440fx doesn't support emulated iommu\");\n\n    }\n\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":117089,"func":"static TEE_Result map_kinit(struct user_ta_ctx *utc __maybe_unused)\n{\n\tTEE_Result res;\n\tstruct mobj *mobj;\n\tsize_t offs;\n\tvaddr_t va;\n\tsize_t sz;\n\n\tthread_get_user_kcode(&mobj, &offs, &va, &sz);\n\tif (sz) {\n\t\tres = vm_map(utc, &va, sz, TEE_MATTR_PRX | TEE_MATTR_PERMANENT,\n\t\t\t     mobj, offs);\n\t\tif (res)\n\t\t\treturn res;\n\t}\n\n\tthread_get_user_kdata(&mobj, &offs, &va, &sz);\n\tif (sz)\n\t\treturn vm_map(utc, &va, sz, TEE_MATTR_PRW | TEE_MATTR_PERMANENT,\n\t\t\t      mobj, offs);\n\n\treturn TEE_SUCCESS;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":133671,"func":"static void save_xattr_block(long long start, int offset)\n{\n\tstruct hash_entry *hash_entry = malloc(sizeof(*hash_entry));\n\tint hash = start & 0xffff;\n\n\tTRACE(\"save_xattr_block: start %lld, offset %d\\n\", start, offset);\n\n\tif(hash_entry == NULL)\n\t\tMEM_ERROR();\n\n\thash_entry->start = start;\n\thash_entry->offset = offset;\n\thash_entry->next = hash_table[hash];\n\thash_table[hash] = hash_entry;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":142894,"func":"struct ares_addrinfo_node *ares__malloc_addrinfo_node()\n{\n  struct ares_addrinfo_node *node =\n      ares_malloc(sizeof(struct ares_addrinfo_node));\n  if (!node)\n    return NULL;\n\n  *node = empty_addrinfo_node;\n  return node;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":28159,"func":"static void libschroedinger_flush ( AVCodecContext * avctx ) {\n SchroDecoderParams * p_schro_params = avctx -> priv_data ;\n ff_schro_queue_free ( & p_schro_params -> dec_frame_queue , libschroedinger_decode_frame_free ) ;\n ff_schro_queue_init ( & p_schro_params -> dec_frame_queue ) ;\n schro_decoder_reset ( p_schro_params -> decoder ) ;\n p_schro_params -> eos_pulled = 0 ;\n p_schro_params -> eos_signalled = 0 ;\n }","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":129753,"func":"cockpit_web_response_gerror (CockpitWebResponse *self,\n                             GHashTable *headers,\n                             GError *error)\n{\n  int code;\n\n  g_return_if_fail (COCKPIT_IS_WEB_RESPONSE (self));\n\n  if (g_error_matches (error,\n                       COCKPIT_ERROR, COCKPIT_ERROR_AUTHENTICATION_FAILED))\n    code = 401;\n  else if (g_error_matches (error,\n                       COCKPIT_ERROR, COCKPIT_ERROR_PERMISSION_DENIED))\n    code = 403;\n  else if (g_error_matches (error,\n                            G_IO_ERROR, G_IO_ERROR_INVALID_DATA))\n    code = 400;\n  else if (g_error_matches (error,\n                            G_IO_ERROR, G_IO_ERROR_NO_SPACE))\n    code = 413;\n  else\n    code = 500;\n\n  cockpit_web_response_error (self, code, headers, \"%s\", error->message);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":164652,"func":"void DevToolsWindow::InspectElementCompleted() {\n  if (!inspect_element_start_time_.is_null()) {\n    UMA_HISTOGRAM_TIMES(\"DevTools.InspectElement\",\n        base::TimeTicks::Now() - inspect_element_start_time_);\n    inspect_element_start_time_ = base::TimeTicks();\n  }\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":470194,"func":"static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)\n{\n\tif (!kvm_pause_in_guest(vcpu->kvm))\n\t\tshrink_ple_window(vcpu);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":278450,"func":"bool BrowserCommandController::IsShowingMainUI() {\n  return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":168545,"func":"void Browser::OpenOptionsDialog() {\n  UserMetrics::RecordAction(UserMetricsAction(\"ShowOptions\"));\n  ShowOptionsTab(\"\");\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":137895,"func":"flatpak_filesystem_key_in_home (const char *filesystem)\n{\n  \/* \"home\" is definitely in home *\/\n  if (strcmp (filesystem, \"home\") == 0)\n    return TRUE;\n\n  \/* All the other special fs:es are non-home.\n   * Note: This considers absolute paths that are in the homedir as non-home.\n   *\/\n  if (g_strv_contains (flatpak_context_special_filesystems, filesystem) ||\n      g_str_has_prefix (filesystem, \"\/\"))\n    return FALSE;\n\n  \/* Files in xdg-run are not in home *\/\n  if (g_str_has_prefix (filesystem, \"xdg-run\"))\n    return FALSE;\n\n  \/* All remaining keys (~\/, xdg-data, etc) are considered in home,\n   * Note: technically $XDG_HOME_DATA could point outside the homedir, but we ignore that.\n   *\/\n  return TRUE;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":133212,"func":"void meta_box_del(GF_Box *s)\n{\n\tmeta_reset(s);\n\tgf_free(s);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":377007,"func":"static int get_dpifindex(struct datapath *dp)\n{\n\tstruct vport *local;\n\tint ifindex;\n\n\trcu_read_lock();\n\n\tlocal = ovs_vport_rcu(dp, OVSP_LOCAL);\n\tif (local)\n\t\tifindex = netdev_vport_priv(local)->dev->ifindex;\n\telse\n\t\tifindex = 0;\n\n\trcu_read_unlock();\n\n\treturn ifindex;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":18445,"func":"static bool check_grant_db_routine ( THD * thd , const char * db , HASH * hash ) {\n Security_context * sctx = thd -> security_ctx ;\n for ( uint idx = 0 ;\n idx < hash -> records ;\n ++ idx ) {\n GRANT_NAME * item = ( GRANT_NAME * ) hash_element ( hash , idx ) ;\n if ( strcmp ( item -> user , sctx -> priv_user ) == 0 && strcmp ( item -> db , db ) == 0 && compare_hostname ( & item -> host , sctx -> host , sctx -> ip ) ) {\n return FALSE ;\n }\n }\n return TRUE ;\n }","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":308055,"func":"static ssize_t kernel_readv(struct file *file, const struct kvec *vec,\n\t\t\t    unsigned long vlen, loff_t offset)\n{\n\tmm_segment_t old_fs;\n\tloff_t pos = offset;\n\tssize_t res;\n\n\told_fs = get_fs();\n\tset_fs(KERNEL_DS);\n\t\/* The cast to a user pointer is valid due to the set_fs() *\/\n\tres = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos, 0);\n\tset_fs(old_fs);\n\n\treturn res;\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":205454,"func":"WORD32 ih264d_set_degrade(iv_obj_t *ps_codec_obj,\n void *pv_api_ip,\n void *pv_api_op)\n{\n ih264d_ctl_degrade_ip_t *ps_ip;\n ih264d_ctl_degrade_op_t *ps_op;\n dec_struct_t *ps_codec = (dec_struct_t *)ps_codec_obj->pv_codec_handle;\n\n    ps_ip = (ih264d_ctl_degrade_ip_t *)pv_api_ip;\n    ps_op = (ih264d_ctl_degrade_op_t *)pv_api_op;\n\n    ps_codec->i4_degrade_type = ps_ip->i4_degrade_type;\n    ps_codec->i4_nondegrade_interval = ps_ip->i4_nondegrade_interval;\n    ps_codec->i4_degrade_pics = ps_ip->i4_degrade_pics;\n\n    ps_op->u4_error_code = 0;\n    ps_codec->i4_degrade_pic_cnt = 0;\n\n return IV_SUCCESS;\n}\n","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":179913,"func":"bool ImageLoader::GetImageAnimationPolicy(ImageAnimationPolicy& policy) {\n  if (!GetElement()->GetDocument().GetSettings())\n    return false;\n\n  policy = GetElement()->GetDocument().GetSettings()->GetImageAnimationPolicy();\n  return true;\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":437114,"func":"static void atusb_in(struct urb *urb)\n{\n\tstruct usb_device *usb_dev = urb->dev;\n\tstruct sk_buff *skb = urb->context;\n\tstruct atusb *atusb = SKB_ATUSB(skb);\n\n\tdev_dbg(&usb_dev->dev, \"%s: status %d len %d\\n\", __func__,\n\t\turb->status, urb->actual_length);\n\tif (urb->status) {\n\t\tif (urb->status == -ENOENT) { \/* being killed *\/\n\t\t\tkfree_skb(skb);\n\t\t\turb->context = NULL;\n\t\t\treturn;\n\t\t}\n\t\tdev_dbg(&usb_dev->dev, \"%s: URB error %d\\n\", __func__, urb->status);\n\t} else {\n\t\tatusb_in_good(urb);\n\t}\n\n\tusb_anchor_urb(urb, &atusb->idle_urbs);\n\tif (!atusb->shutdown)\n\t\tschedule_delayed_work(&atusb->work, 0);\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":111376,"func":"int ff_unlock_avcodec(const AVCodec *codec)\n\n{\n\n    if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)\n\n        return 0;\n\n\n\n    av_assert0(ff_avcodec_locked);\n\n    ff_avcodec_locked = 0;\n\n    atomic_fetch_add(&entangled_thread_counter, -1);\n\n    if (lockmgr_cb) {\n\n        if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))\n\n            return -1;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":236079,"func":"smp_fetch_hdr_val(const struct arg *args, struct sample *smp, const char *kw, void *private)\n{\n\tint ret = smp_fetch_hdr(args, smp, kw, private);\n\n\tif (ret > 0) {\n\t\tsmp->data.type = SMP_T_SINT;\n\t\tsmp->data.u.sint = strl2ic(smp->data.u.str.str, smp->data.u.str.len);\n\t}\n\n\treturn ret;\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":113932,"func":"process_mkdir(u_int32_t id)\n{\n\tAttrib a;\n\tchar *name;\n\tint r, mode, status = SSH2_FX_FAILURE;\n\n\tif ((r = sshbuf_get_cstring(iqueue, &name, NULL)) != 0 ||\n\t    (r = decode_attrib(iqueue, &a)) != 0)\n\t\tfatal(\"%s: buffer error: %s\", __func__, ssh_err(r));\n\n\tmode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?\n\t    a.perm & 07777 : 0777;\n\tdebug3(\"request %u: mkdir\", id);\n\tlogit(\"mkdir name \\\"%s\\\" mode 0%o\", name, mode);\n\tr = mkdir(name, mode);\n\tstatus = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK;\n\tsend_status(id, status);\n\tfree(name);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":206789,"func":"ModuleExport void UnregisterRAWImage(void)\n{\n  (void) UnregisterMagickInfo(\"R\");\n  (void) UnregisterMagickInfo(\"C\");\n  (void) UnregisterMagickInfo(\"G\");\n  (void) UnregisterMagickInfo(\"M\");\n  (void) UnregisterMagickInfo(\"B\");\n  (void) UnregisterMagickInfo(\"Y\");\n  (void) UnregisterMagickInfo(\"A\");\n  (void) UnregisterMagickInfo(\"O\");\n  (void) UnregisterMagickInfo(\"K\");\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":50233,"func":"int get_unused_fd_flags(unsigned flags)\n{\n\treturn __get_unused_fd_flags(flags, rlimit(RLIMIT_NOFILE));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":496951,"func":"cached_h_origin(hb_font_t *font, void *font_data, hb_codepoint_t glyph,\n                hb_position_t *x, hb_position_t *y, void *user_data)\n{\n    return true;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":322286,"func":"static void sdp_parse_fmtp_config(AVCodecContext *codec, char *attr, char *value)\n\n{\n\n    switch (codec->codec_id) {\n\n        case CODEC_ID_MPEG4:\n\n        case CODEC_ID_AAC:\n\n            if (!strcmp(attr, \"config\")) {\n\n                \/* decode the hexa encoded parameter *\/\n\n                int len = hex_to_data(NULL, value);\n\n\n\n                codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);\n\n                if (!codec->extradata)\n\n                    return;\n\n                codec->extradata_size = len;\n\n                hex_to_data(codec->extradata, value);\n\n            }\n\n            break;\n\n        default:\n\n            break;\n\n    }\n\n    return;\n\n}","target":1,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":130419,"func":"static void *perf_mmap_alloc_page(int cpu)\n{\n\tstruct page *page;\n\tint node;\n\n\tnode = (cpu == -1) ? cpu : cpu_to_node(cpu);\n\tpage = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);\n\tif (!page)\n\t\treturn NULL;\n\n\treturn page_address(page);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":405961,"func":"netdev_port_features_from_ofp10(ovs_be32 ofp10_)\n{\n    uint32_t ofp10 = ntohl(ofp10_);\n    return (ofp10 & 0x7f) | ((ofp10 & 0xf80) << 4);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":335084,"func":"static int count_contiguous_clusters_by_type(int nb_clusters,\n\n                                             uint64_t *l2_table,\n\n                                             int wanted_type)\n\n{\n\n    int i;\n\n\n\n    for (i = 0; i < nb_clusters; i++) {\n\n        int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i]));\n\n\n\n        if (type != wanted_type) {\n\n            break;\n\n        }\n\n    }\n\n\n\n    return i;\n\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":103109,"func":"void npw_close_all_open_files(void)\n{\n  const int min_fd = 3;\n\n#if defined(__linux__)\n  DIR *dir = opendir(\"\/proc\/self\/fd\");\n  if (dir) {\n\tconst int dfd = dirfd(dir);\n\tstruct dirent *d;\n\twhile ((d = readdir(dir)) != NULL) {\n\t  char *end;\n\t  long n = strtol(d->d_name, &end, 10);\n\t  if (*end == '\\0') {\n\t\tint fd = n;\n\t\tif (fd >= min_fd && fd != dfd)\n\t\t  close(fd);\n\t  }\n\t}\n\tclosedir(dir);\n\treturn;\n  }\n#endif\n\n  const int open_max = get_open_max();\n  for (int fd = min_fd; fd < open_max; fd++)\n\tclose(fd);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":478769,"func":"    T& atXYZ(const int x, const int y, const int z, const int c, const T& out_value) {\n      return (x<0 || y<0 || z<0 || x>=width() || y>=height() || z>=depth())?\n        (cimg::temporary(out_value)=out_value):(*this)(x,y,z,c);\n    }","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":57404,"func":"static int packet_rcv_has_room(struct packet_sock *po, struct sk_buff *skb)\n{\n\tint ret;\n\tbool has_room;\n\n\tspin_lock_bh(&po->sk.sk_receive_queue.lock);\n\tret = __packet_rcv_has_room(po, skb);\n\thas_room = ret == ROOM_NORMAL;\n\tif (po->pressure == has_room)\n\t\tpo->pressure = !has_room;\n\tspin_unlock_bh(&po->sk.sk_receive_queue.lock);\n\n\treturn ret;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":351949,"func":"static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesW(PCredHandle phCredential,\n                                                                     ULONG ulAttribute,\n                                                                     void* pBuffer, ULONG cbBuffer)\n{\n\tMechCred* creds;\n\n\tcreds = sspi_SecureHandleGetLowerPointer(phCredential);\n\n\tif (!creds)\n\t\treturn SEC_E_INVALID_HANDLE;\n\n\tfor (size_t i = 0; i < MECH_COUNT; i++)\n\t{\n\t\tMechCred* cred = &creds[i];\n\n\t\tif (!cred->valid)\n\t\t\tcontinue;\n\n\t\tWINPR_ASSERT(cred->mech);\n\t\tWINPR_ASSERT(cred->mech->pkg);\n\t\tWINPR_ASSERT(cred->mech->pkg->table);\n\t\tWINPR_ASSERT(cred->mech->pkg->table_w->SetCredentialsAttributesW);\n\t\tcred->mech->pkg->table_w->SetCredentialsAttributesW(&cred->cred, ulAttribute, pBuffer,\n\t\t                                                    cbBuffer);\n\t}\n\n\treturn SEC_E_OK;\n}","target":1,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":486028,"func":"struct my_mntent *my_getmntent (mntFILE *mfp) { return NULL; }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":251341,"func":" vpx_codec_err_t SetFrameBufferFunctions(\n int num_buffers,\n vpx_get_frame_buffer_cb_fn_t cb_get,\n vpx_release_frame_buffer_cb_fn_t cb_release) {\n if (num_buffers > 0) {\n      num_buffers_ = num_buffers;\n      EXPECT_TRUE(fb_list_.CreateBufferList(num_buffers_));\n }\n\n return decoder_->SetFrameBufferFunctions(cb_get, cb_release, &fb_list_);\n }\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":175692,"func":"bool InputHandler::setSpannableTextAndRelativeCursor(spannable_string_t* spannableString, int relativeCursorPosition, bool markTextAsComposing)\n{\n    InputLog(LogLevelInfo, \"InputHandler::setSpannableTextAndRelativeCursor(%d, %d, %d)\", spannableString->length, relativeCursorPosition, markTextAsComposing);\n    int insertionPoint = compositionActive() ? m_composingTextStart : selectionStart();\n\n    ProcessingChangeGuard guard(this);\n\n    if (!setText(spannableString))\n        return false;\n\n    if (!setTextAttributes(insertionPoint, spannableString))\n        return false;\n\n    if (!setRelativeCursorPosition(insertionPoint, relativeCursorPosition))\n        return false;\n\n    if (markTextAsComposing) {\n        m_composingTextStart = insertionPoint;\n        m_composingTextEnd = insertionPoint + spannableString->length;\n    }\n\n    return true;\n}\n","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":299925,"func":"static string getRubberWhaleFrame2() { return getDataDir() + \"optflow\/RubberWhale2.png\"; }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":308818,"func":"static XHCIEPContext *xhci_alloc_epctx(XHCIState *xhci,\n                                       unsigned int slotid,\n                                       unsigned int epid)\n{\n    XHCIEPContext *epctx;\n    int i;\n\n    epctx = g_new0(XHCIEPContext, 1);\n    epctx->xhci = xhci;\n    epctx->slotid = slotid;\n    epctx->epid = epid;\n\n    for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) {\n        epctx->transfers[i].xhci = xhci;\n        epctx->transfers[i].slotid = slotid;\n        epctx->transfers[i].epid = epid;\n        usb_packet_init(&epctx->transfers[i].packet);\n    }\n    epctx->kick_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_ep_kick_timer, epctx);\n\n    return epctx;\n}\n","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":26349,"func":"X509_CRL * d2i_X509_CRL_bio ( BIO * bp , X509_CRL * * crl ) {\n return ASN1_item_d2i_bio ( ASN1_ITEM_rptr ( X509_CRL ) , bp , crl ) ;\n }","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":189065,"func":"bool PasswordAutofillAgent::DidClearAutofillSelection(\n    const WebFormControlElement& control_element) {\n  const WebInputElement* element = ToWebInputElement(&control_element);\n  if (!element)\n    return false;\n\n  WebInputElement username_element;\n  WebInputElement password_element;\n  PasswordInfo* password_info;\n\n  if (!FindPasswordInfoForElement(*element, &username_element,\n                                  &password_element, &password_info)) {\n    return false;\n  }\n\n  ClearPreview(&username_element, &password_element);\n  return true;\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":401311,"func":"cr_input_set_line_num (CRInput * a_this, glong a_line_num)\n{\n        g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR);\n\n        PRIVATE (a_this)->line = a_line_num;\n\n        return CR_OK;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":141925,"func":"static void srpt_get_svc_entries(u64 ioc_guid,\n\t\t\t\t u16 slot, u8 hi, u8 lo, struct ib_dm_mad *mad)\n{\n\tstruct ib_dm_svc_entries *svc_entries;\n\n\tWARN_ON(!ioc_guid);\n\n\tif (!slot || slot > 16) {\n\t\tmad->mad_hdr.status\n\t\t\t= cpu_to_be16(DM_MAD_STATUS_INVALID_FIELD);\n\t\treturn;\n\t}\n\n\tif (slot > 2 || lo > hi || hi > 1) {\n\t\tmad->mad_hdr.status\n\t\t\t= cpu_to_be16(DM_MAD_STATUS_NO_IOC);\n\t\treturn;\n\t}\n\n\tsvc_entries = (struct ib_dm_svc_entries *)mad->data;\n\tmemset(svc_entries, 0, sizeof *svc_entries);\n\tsvc_entries->service_entries[0].id = cpu_to_be64(ioc_guid);\n\tsnprintf(svc_entries->service_entries[0].name,\n\t\t sizeof(svc_entries->service_entries[0].name),\n\t\t \"%s%016llx\",\n\t\t SRP_SERVICE_NAME_PREFIX,\n\t\t ioc_guid);\n\n\tmad->mad_hdr.status = 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":319781,"func":"static inline int get_ue_code(GetBitContext *gb, int order)\n\n{\n\n    if (order) {\n\n        int ret = get_ue_golomb(gb) << order;\n\n        return ret + get_bits(gb, order);\n\n    }\n\n    return get_ue_golomb(gb);\n\n}\n","target":1,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":508522,"func":"BIO *SSL_get_wbio(const SSL *s)\n{\n    return (s->wbio);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":432890,"func":"backend_can_flush (struct backend *b, struct connection *conn)\n{\n  struct b_conn_handle *h = &conn->handles[b->i];\n\n  debug (\"%s: can_flush\", b->name);\n\n  if (h->can_flush == -1)\n    h->can_flush = b->can_flush (b, conn);\n  return h->can_flush;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":270452,"func":"OpGradFactory* GetOpGradFactory() {\n  static OpGradFactory* factory = new OpGradFactory;\n  return factory;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":87704,"func":"megasas_check_reset_ppc(struct megasas_instance *instance,\n\t\t\tstruct megasas_register_set __iomem *regs)\n{\n\tif (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)\n\t\treturn 1;\n\n\treturn 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":383244,"func":"dbg_search_packet (IOBUF inp, PACKET * pkt, off_t * retpos, int with_uid,\n\t\t   const char *dbg_f, int dbg_l)\n{\n  int skip, rc;\n\n  do\n    {\n      rc =\n\tparse (inp, pkt, with_uid ? 2 : 1, retpos, &skip, NULL, 0, \"search\",\n\t       dbg_f, dbg_l);\n    }\n  while (skip);\n  return rc;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":241549,"func":"void ObserveKeychainEvents() {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n  net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents();\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":137646,"func":"void ipv6FlushDnsServerList(NetInterface *interface)\n{\n   \/\/Clear the list of DNS servers\n   osMemset(interface->ipv6Context.dnsServerList, 0,\n      sizeof(interface->ipv6Context.dnsServerList));\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":30249,"func":"void * TSHttpTxnArgGet ( TSHttpTxn txnp , int arg_idx ) {\n sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;\n sdk_assert ( arg_idx >= 0 && arg_idx < HTTP_SSN_TXN_MAX_USER_ARG ) ;\n HttpSM * sm = ( HttpSM * ) txnp ;\n return sm -> t_state . user_args [ arg_idx ] ;\n }","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":516518,"func":"bool Alter_table_prelocking_strategy::\nhandle_table(THD *thd, Query_tables_list *prelocking_ctx,\n             TABLE_LIST *table_list, bool *need_prelocking)\n{\n  return FALSE;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":208948,"func":"bool VerifyMAC(const std::string& key, const std::string& mac,\n               const char* data, int data_length) {\n  std::string key_copy = key;\n  DecodeWebSafe(&key_copy);\n  std::string decoded_key;\n  base::Base64Decode(key_copy, &decoded_key);\n\n  std::string mac_copy = mac;\n  DecodeWebSafe(&mac_copy);\n  std::string decoded_mac;\n  base::Base64Decode(mac_copy, &decoded_mac);\n\n  base::HMAC hmac(base::HMAC::SHA1);\n  if (!hmac.Init(decoded_key))\n    return false;\n  const std::string data_str(data, data_length);\n  unsigned char digest[kSafeBrowsingMacDigestSize];\n  if (!hmac.Sign(data_str, digest, kSafeBrowsingMacDigestSize))\n    return false;\n\n  return !memcmp(digest, decoded_mac.data(), kSafeBrowsingMacDigestSize);\n}\n","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":262438,"func":"void conn_free(conn *c) {\n    if (c) {\n        assert(c != NULL);\n        assert(c->sfd >= 0 && c->sfd < max_fds);\n\n        MEMCACHED_CONN_DESTROY(c);\n        conns[c->sfd] = NULL;\n        if (c->hdrbuf)\n            free(c->hdrbuf);\n        if (c->msglist)\n            free(c->msglist);\n        if (c->rbuf)\n            free(c->rbuf);\n        if (c->wbuf)\n            free(c->wbuf);\n        if (c->ilist)\n            free(c->ilist);\n        if (c->suffixlist)\n            free(c->suffixlist);\n        if (c->iov)\n            free(c->iov);\n#ifdef TLS\n        if (c->ssl_wbuf)\n            c->ssl_wbuf = NULL;\n#endif\n\n        free(c);\n    }\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":26765,"func":"static int dissect_h245_RedundancyEncodingDTMode ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h245_RedundancyEncodingDTMode , RedundancyEncodingDTMode_sequence ) ;\n return offset ;\n }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":445566,"func":"  void addDrainTracker(std::function<void()> drain_tracker) override {\n    \/\/ Not implemented well.\n    ASSERT(false);\n    drain_tracker();\n  }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":370683,"func":"static void process_bin_flush(conn *c) {\n    time_t exptime = 0;\n    protocol_binary_request_flush* req = binary_get_request(c);\n\n    if (c->binary_header.request.extlen == sizeof(req->message.body)) {\n        exptime = ntohl(req->message.body.expiration);\n    }\n\n    if (exptime > 0) {\n        settings.oldest_live = realtime(exptime) - 1;\n    } else {\n        settings.oldest_live = current_time - 1;\n    }\n    item_flush_expired();\n\n    pthread_mutex_lock(&c->thread->stats.mutex);\n    c->thread->stats.flush_cmds++;\n    pthread_mutex_unlock(&c->thread->stats.mutex);\n\n    write_bin_response(c, NULL, 0, 0, 0);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":389744,"func":"ram_addr_t qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,\n                                   void (*resized)(const char*,\n                                                   uint64_t length,\n                                                   void *host),\n                                   void *host, bool resizeable,\n                                   MemoryRegion *mr, Error **errp)\n{\n    RAMBlock *new_block;\n    ram_addr_t addr;\n    Error *local_err = NULL;\n\n    size = TARGET_PAGE_ALIGN(size);\n    max_size = TARGET_PAGE_ALIGN(max_size);\n    new_block = g_malloc0(sizeof(*new_block));\n    new_block->mr = mr;\n    new_block->resized = resized;\n    new_block->used_length = size;\n    new_block->max_length = max_size;\n    assert(max_size >= size);\n    new_block->fd = -1;\n    new_block->host = host;\n    if (host) {\n        new_block->flags |= RAM_PREALLOC;\n    }\n    if (resizeable) {\n        new_block->flags |= RAM_RESIZEABLE;\n    }\n    addr = ram_block_add(new_block, &local_err);\n    if (local_err) {\n        g_free(new_block);\n        error_propagate(errp, local_err);\n        return -1;\n    }\n    return addr;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":308218,"func":"bool CSPSource::matches(const KURL& url, ContentSecurityPolicy::RedirectStatus redirectStatus) const\n{\n    if (!schemeMatches(url))\n        return false;\n    if (isSchemeOnly())\n        return true;\n    bool pathsMatch = (redirectStatus == ContentSecurityPolicy::DidRedirect) || pathMatches(url);\n    return hostMatches(url) && portMatches(url) && pathsMatch;\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":458689,"func":"parse_vlan(const void **datap, size_t *sizep, union flow_vlan_hdr *vlan_hdrs)\n{\n    const ovs_be16 *eth_type;\n\n    memset(vlan_hdrs, 0, sizeof(union flow_vlan_hdr) * FLOW_MAX_VLAN_HEADERS);\n    data_pull(datap, sizep, ETH_ADDR_LEN * 2);\n\n    eth_type = *datap;\n\n    size_t n;\n    for (n = 0; eth_type_vlan(*eth_type) && n < flow_vlan_limit; n++) {\n        if (OVS_UNLIKELY(*sizep < sizeof(ovs_be32) + sizeof(ovs_be16))) {\n            break;\n        }\n\n        const ovs_16aligned_be32 *qp = data_pull(datap, sizep, sizeof *qp);\n        vlan_hdrs[n].qtag = get_16aligned_be32(qp);\n        vlan_hdrs[n].tci |= htons(VLAN_CFI);\n        eth_type = *datap;\n    }\n    return n;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":111813,"func":"static bool __head check_la57_support(unsigned long physaddr)\n{\n\t\/*\n\t * 5-level paging is detected and enabled at kernel decompression\n\t * stage. Only check if it has been enabled there.\n\t *\/\n\tif (!(native_read_cr4() & X86_CR4_LA57))\n\t\treturn false;\n\n\t*fixup_int(&__pgtable_l5_enabled, physaddr) = 1;\n\t*fixup_int(&pgdir_shift, physaddr) = 48;\n\t*fixup_int(&ptrs_per_p4d, physaddr) = 512;\n\t*fixup_long(&page_offset_base, physaddr) = __PAGE_OFFSET_BASE_L5;\n\t*fixup_long(&vmalloc_base, physaddr) = __VMALLOC_BASE_L5;\n\t*fixup_long(&vmemmap_base, physaddr) = __VMEMMAP_BASE_L5;\n\n\treturn true;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":250247,"func":"PPB_URLLoader_API* PPB_URLLoader_Impl::AsPPB_URLLoader_API() {\n   return this;\n }\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":445822,"func":"*to_usb_os_desc_ext_prop(struct config_item *item)\n{\n\treturn container_of(item, struct usb_os_desc_ext_prop, item);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":229060,"func":"void UsageTracker::GetHostUsage(\n    const std::string& host, HostUsageCallback* callback) {\n  if (client_tracker_map_.size() == 0) {\n    callback->Run(host, type_, 0);\n    delete callback;\n    return;\n  }\n  if (host_usage_callbacks_.Add(host, callback)) {\n    DCHECK(outstanding_host_usage_.find(host) == outstanding_host_usage_.end());\n    outstanding_host_usage_[host].pending_clients = client_tracker_map_.size();\n    for (ClientTrackerMap::iterator iter = client_tracker_map_.begin();\n         iter != client_tracker_map_.end();\n         ++iter) {\n      iter->second->GetHostUsage(host, callback_factory_.NewCallback(\n          &UsageTracker::DidGetClientHostUsage));\n    }\n  }\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":153009,"func":"MapNto1(SDL_PixelFormat * src, SDL_PixelFormat * dst, int *identical)\n{\n    \/* Generate a 256 color dither palette *\/\n    SDL_Palette dithered;\n    SDL_Color colors[256];\n    SDL_Palette *pal = dst->palette;\n\n    dithered.ncolors = 256;\n    SDL_DitherColors(colors, 8);\n    dithered.colors = colors;\n    return (Map1to1(&dithered, pal, identical));\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":247031,"func":"bool Document::IsDelayingLoadEvent() {\n  if (ThreadState::Current()->SweepForbidden()) {\n    if (!load_event_delay_count_)\n      CheckLoadEventSoon();\n    return true;\n  }\n  return load_event_delay_count_;\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":349976,"func":"int hugetlb_overcommit_handler(struct ctl_table *table, int write,\n\t\tvoid *buffer, size_t *length, loff_t *ppos)\n{\n\tstruct hstate *h = &default_hstate;\n\tunsigned long tmp;\n\tint ret;\n\n\tif (!hugepages_supported())\n\t\treturn -EOPNOTSUPP;\n\n\ttmp = h->nr_overcommit_huge_pages;\n\n\tif (write && hstate_is_gigantic(h))\n\t\treturn -EINVAL;\n\n\ttable->data = &tmp;\n\ttable->maxlen = sizeof(unsigned long);\n\tret = proc_doulongvec_minmax(table, write, buffer, length, ppos);\n\tif (ret)\n\t\tgoto out;\n\n\tif (write) {\n\t\tspin_lock(&hugetlb_lock);\n\t\th->nr_overcommit_huge_pages = tmp;\n\t\tspin_unlock(&hugetlb_lock);\n\t}\nout:\n\treturn ret;\n}","target":1,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":45885,"func":"\/* Called with irq disabled *\/\nstatic inline void ____napi_schedule(struct softnet_data *sd,\n\t\t\t\t     struct napi_struct *napi)\n{\n\tlist_add_tail(&napi->poll_list, &sd->poll_list);\n\t__raise_softirq_irqoff(NET_RX_SOFTIRQ);","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":249004,"func":"    virtual void performInternal(WebPagePrivate* webPagePrivate)\n    {\n        webPagePrivate->setPageVisibilityState();\n    }\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":437749,"func":"static char *sieve_srs_forward(char *return_path)\n{\n    const char *srs_domain = config_getstring(IMAPOPT_SRS_DOMAIN);\n    char *srs_return_path = NULL;\n    int srs_status;\n\n    if (!srs_engine) {\n        \/* SRS not enabled *\/\n        return NULL;\n    }\n\n    srs_status = srs_forward_alloc(srs_engine, &srs_return_path,\n                                   return_path, srs_domain);\n\n    if (srs_status != SRS_SUCCESS) {\n        syslog(LOG_ERR, \"sieve SRS forward failed (%s, %s): %s\",\n               return_path, srs_domain, srs_strerror(srs_status));\n        if (srs_return_path) {\n            free(srs_return_path);\n            srs_return_path = NULL;\n        }\n    }\n\n    return srs_return_path;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":358350,"func":"static int handle_triple_fault(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)\n{\n\tkvm_run->exit_reason = KVM_EXIT_SHUTDOWN;\n\treturn 0;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":186121,"func":"void RenderWidgetHostViewAura::BeginFrameSubscription(\n    scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {\n  frame_subscriber_ = subscriber.Pass();\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":71467,"func":"builtin_bin(PyObject *module, PyObject *number)\n\/*[clinic end generated code: output=b6fc4ad5e649f4f7 input=53f8a0264bacaf90]*\/\n{\n    return PyNumber_ToBase(number, 2);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":442474,"func":"static long task_close_fd(struct binder_proc *proc, unsigned int fd)\n{\n\tint retval;\n\n\tmutex_lock(&proc->files_lock);\n\tif (proc->files == NULL) {\n\t\tretval = -ESRCH;\n\t\tgoto err;\n\t}\n\tretval = __close_fd(proc->files, fd);\n\t\/* can't restart close syscall because file table entry was cleared *\/\n\tif (unlikely(retval == -ERESTARTSYS ||\n\t\t     retval == -ERESTARTNOINTR ||\n\t\t     retval == -ERESTARTNOHAND ||\n\t\t     retval == -ERESTART_RESTARTBLOCK))\n\t\tretval = -EINTR;\nerr:\n\tmutex_unlock(&proc->files_lock);\n\treturn retval;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":175712,"func":"void CustomButton::OnEnabledChanged() {\n  if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED))\n    return;\n\n  if (enabled())\n    SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL);\n  else\n    SetState(STATE_DISABLED);\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":34829,"func":"static u64 btrfs_dev_stats_value(const struct extent_buffer *eb,\n\t\t\t\t const struct btrfs_dev_stats_item *ptr,\n\t\t\t\t int index)\n{\n\tu64 val;\n\n\tread_extent_buffer(eb, &val,\n\t\t\t   offsetof(struct btrfs_dev_stats_item, values) +\n\t\t\t    ((unsigned long)ptr) + (index * sizeof(u64)),\n\t\t\t   sizeof(val));\n\treturn val;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":107211,"func":"static void __free_resource(void *resource) {\n\tr_ne_resource *res = (r_ne_resource *)resource;\n\tfree (res->name);\n\tr_list_free (res->entry);\n\tfree (res);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":72496,"func":"flatpak_dir_get_remote_default_branch (FlatpakDir *self,\n                                       const char *remote_name)\n{\n  GKeyFile *config = flatpak_dir_get_repo_config (self);\n  g_autofree char *group = get_group (remote_name);\n\n  if (config)\n    return g_key_file_get_string (config, group, \"xa.default-branch\", NULL);\n\n  return NULL;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":258080,"func":"static void initial_reordering ( const hb_ot_shape_plan_t * plan , hb_font_t * font , hb_buffer_t * buffer ) {\n update_consonant_positions ( plan , font , buffer ) ;\n insert_dotted_circles ( plan , font , buffer ) ;\n foreach_syllable ( buffer , start , end ) initial_reordering_syllable ( plan , font -> face , buffer , start , end ) ;\n }","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":62749,"func":"l_noret luaG_callerror (lua_State *L, const TValue *o) {\n  CallInfo *ci = L->ci;\n  const char *name = NULL;  \/* to avoid warnings *\/\n  const char *kind = funcnamefromcall(L, ci, &name);\n  const char *extra = kind ? formatvarinfo(L, kind, name) : varinfo(L, o);\n  typeerror(L, o, \"call\", extra);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":51598,"func":"EIGEN_STRONG_INLINE QInt32 operator-(const QInt32 a, const QUInt8 b) {\n  return QInt32(a.value - static_cast<int32_t>(b.value));\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":258587,"func":"static int rtp_event_packet ( void * ptr _U_ , packet_info * pinfo , epan_dissect_t * edt _U_ , const void * rtp_event_info ) {\n const struct _rtp_event_info * pi = ( const struct _rtp_event_info * ) rtp_event_info ;\n if ( pi -> info_setup_frame_num == 0 ) {\n return 0 ;\n }\n rtp_evt_frame_num = pinfo -> fd -> num ;\n rtp_evt = pi -> info_rtp_evt ;\n rtp_evt_end = pi -> info_end ;\n return 0 ;\n }","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":282423,"func":"void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  if (delegate_) {\n    delegate_->GetNextId(callback);\n    return;\n  }\n  static uint32_t next_id = content::DownloadItem::kInvalidId + 1;\n  callback.Run(next_id++);\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":350371,"func":"static void rtps_util_detect_coherent_set_end_empty_data_case(\n\n  coherent_set_entity_info *coherent_set_entity_info_object) {\n  coherent_set_entity_info *coherent_set_entry = NULL;\n\n  coherent_set_entry = (coherent_set_entity_info*) wmem_map_lookup(coherent_set_tracking.entities_using_map, &coherent_set_entity_info_object->guid);\n  if (coherent_set_entry) {\n    coherent_set_info *coherent_set_info_entry;\n    coherent_set_key key;\n\n    key.guid = coherent_set_entity_info_object->guid;\n    key.coherent_set_seq_number = coherent_set_entry->coherent_set_seq_number;\n\n    coherent_set_info_entry = (coherent_set_info*)wmem_map_lookup(coherent_set_tracking.coherent_set_registry_map, &key);\n    if (coherent_set_info_entry) {\n      if (coherent_set_entry->expected_coherent_set_end_writers_seq_number == coherent_set_entity_info_object->writer_seq_number) {\n\n        coherent_set_info_entry->is_set = TRUE;\n        coherent_set_info_entry->writer_seq_number = coherent_set_entry->expected_coherent_set_end_writers_seq_number - 1;\n      }\n    }\n  }\n}","target":1,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":441659,"func":"static void __init __map_memblock(pgd_t *pgdp, phys_addr_t start,\n\t\t\t\t  phys_addr_t end, pgprot_t prot, int flags)\n{\n\t__create_pgd_mapping(pgdp, start, __phys_to_virt(start), end - start,\n\t\t\t     prot, early_pgtable_alloc, flags);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":248613,"func":"DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {\n  return GetDefaultWebClientStateFromShellUtilDefaultState(\n      ShellUtil::GetChromeDefaultProtocolClientState(\n          base::UTF8ToUTF16(protocol)));\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":170625,"func":"  bool destroyed() const { return destroyed_; }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":223742,"func":"int GetChangedMouseButtonFlagsFromNative(\n    const base::NativeEvent& native_event) {\n  switch (GetNativeMouseKey(native_event)) {\n    case MK_LBUTTON:\n      return EF_LEFT_MOUSE_BUTTON;\n    case MK_MBUTTON:\n      return EF_MIDDLE_MOUSE_BUTTON;\n    case MK_RBUTTON:\n      return EF_RIGHT_MOUSE_BUTTON;\n    default:\n      break;\n  }\n  return 0;\n }\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":68830,"func":"static void ff_jref_idct1_put(uint8_t *dest, ptrdiff_t line_size, int16_t *block)\n{\n    dest[0] = av_clip_uint8((block[0] + 4)>>3);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":276572,"func":"float GetTouchForce(const base::NativeEvent& native_event) {\n  NOTIMPLEMENTED();\n  return 0.0;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":252019,"func":"  bool initial_sync_ended_for_type(syncable::ModelType type) {\n    return directory()->initial_sync_ended_for_type(type);\n  }\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":184917,"func":"bool jsvIsArray(const JsVar *v) { return v && (v->flags&JSV_VARTYPEMASK)==JSV_ARRAY; }\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":258280,"func":"static void virtio_net_reset ( VirtIODevice * vdev ) {\n VirtIONet * n = to_virtio_net ( vdev ) ;\n n -> promisc = 1 ;\n n -> allmulti = 0 ;\n n -> alluni = 0 ;\n n -> nomulti = 0 ;\n n -> nouni = 0 ;\n n -> nobcast = 0 ;\n n -> mac_table . in_use = 0 ;\n n -> mac_table . first_multi = 0 ;\n n -> mac_table . multi_overflow = 0 ;\n n -> mac_table . uni_overflow = 0 ;\n memset ( n -> mac_table . macs , 0 , MAC_TABLE_ENTRIES * ETH_ALEN ) ;\n memset ( n -> vlans , 0 , MAX_VLAN >> 3 ) ;\n }","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":176380,"func":"WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(\n    WebGLProgram* program,\n    const String& name) {\n  if (!ValidateWebGLProgramOrShader(\"getUniformLocation\", program))\n    return nullptr;\n  if (!ValidateLocationLength(\"getUniformLocation\", name))\n    return nullptr;\n  if (!ValidateString(\"getUniformLocation\", name))\n    return nullptr;\n  if (IsPrefixReserved(name))\n    return nullptr;\n  if (!program->LinkStatus(this)) {\n    SynthesizeGLError(GL_INVALID_OPERATION, \"getUniformLocation\",\n                      \"program not linked\");\n    return nullptr;\n  }\n  GLint uniform_location = ContextGL()->GetUniformLocation(\n      ObjectOrZero(program), name.Utf8().data());\n  if (uniform_location == -1)\n    return nullptr;\n  return WebGLUniformLocation::Create(program, uniform_location);\n}\n","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":511040,"func":"int BN_num_bits(const BIGNUM *a)\n{\n    int i = a->top - 1;\n    bn_check_top(a);\n\n    if (BN_is_zero(a))\n        return 0;\n    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":491194,"func":"TPMS_KDF_SCHEME_KDF1_SP800_56A_Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size); \n    }\n    return rc;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":278541,"func":"  virtual ~FakeRegistrationManager() {}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":234669,"func":"event_clear_no_set_filter_flag(struct trace_event_file *file)\n{\n\tfile->flags &= ~EVENT_FILE_FL_NO_SET_FILTER;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":504701,"func":"kssl_krb5_cc_get_principal\n    (krb5_context context, krb5_ccache cache,\n      krb5_principal *principal)\n\t{\n\tif ( p_krb5_cc_get_principal )\n\t\treturn(p_krb5_cc_get_principal(context,cache,principal));\n\telse\n\t\treturn(krb5_x\n\t\t\t((cache)->ops->get_princ,(context, cache, principal)));\n\t}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":68725,"func":"mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,\n\t\t  int len, bool more)\n{\n\tstruct page *page = virt_to_head_page(data);\n\tint offset = data - page_address(page);\n\tstruct sk_buff *skb = q->rx_head;\n\tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n\n\tif (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {\n\t\toffset += q->buf_offset;\n\t\tskb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len,\n\t\t\t\tq->buf_size);\n\t}\n\n\tif (more)\n\t\treturn;\n\n\tq->rx_head = NULL;\n\tdev->drv->rx_skb(dev, q - dev->q_rx, skb);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":191643,"func":"void DrawingBuffer::ResolveMultisampleFramebufferInternal() {\n  DCHECK(state_restorer_);\n  state_restorer_->SetFramebufferBindingDirty();\n  if (WantExplicitResolve()) {\n    state_restorer_->SetClearStateDirty();\n    gl_->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, multisample_fbo_);\n    gl_->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, fbo_);\n    gl_->Disable(GL_SCISSOR_TEST);\n\n    int width = size_.Width();\n    int height = size_.Height();\n    GLuint filter = GL_NEAREST;\n\n    gl_->BlitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, height,\n                                 GL_COLOR_BUFFER_BIT, filter);\n\n    if (DefaultBufferRequiresAlphaChannelToBePreserved() &&\n        ContextProvider()\n            ->GetCapabilities()\n            .disable_multisampling_color_mask_usage) {\n      gl_->ClearColor(0, 0, 0, 1);\n      gl_->ColorMask(false, false, false, true);\n      gl_->Clear(GL_COLOR_BUFFER_BIT);\n    }\n  }\n\n  gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);\n  if (anti_aliasing_mode_ == kScreenSpaceAntialiasing)\n    gl_->ApplyScreenSpaceAntialiasingCHROMIUM();\n}\n","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":375831,"func":"static void put_int16(QEMUFile *f, void *pv, size_t size)\n{\n    int16_t *v = pv;\n    qemu_put_sbe16s(f, v);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":164969,"func":"void DevToolsWindow::OpenDevToolsWindow(\n    content::WebContents* inspected_web_contents) {\n  ToggleDevToolsWindow(\n        inspected_web_contents, true, DevToolsToggleAction::Show(), \"\");\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":123398,"func":"static int slcan_ioctl(struct tty_struct *tty, struct file *file,\n\t\t       unsigned int cmd, unsigned long arg)\n{\n\tstruct slcan *sl = (struct slcan *) tty->disc_data;\n\tunsigned int tmp;\n\n\t\/* First make sure we're connected. *\/\n\tif (!sl || sl->magic != SLCAN_MAGIC)\n\t\treturn -EINVAL;\n\n\tswitch (cmd) {\n\tcase SIOCGIFNAME:\n\t\ttmp = strlen(sl->dev->name) + 1;\n\t\tif (copy_to_user((void __user *)arg, sl->dev->name, tmp))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\n\tcase SIOCSIFHWADDR:\n\t\treturn -EINVAL;\n\n\tdefault:\n\t\treturn tty_mode_ioctl(tty, file, cmd, arg);\n\t}\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":215581,"func":"const binder_size_t* Parcel::objects() const\n{\n return mObjects;\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":427507,"func":"merge_queue_lists(queue_filename *a, queue_filename *b)\n{\nqueue_filename *first = NULL;\nqueue_filename **append = &first;\n\nwhile (a && b)\n  {\n  int d;\n  if ((d = Ustrncmp(a->text, b->text, 6)) == 0)\n    d = Ustrcmp(a->text + 14, b->text + 14);\n  if (d < 0)\n    {\n    *append = a;\n    append= &a->next;\n    a = a->next;\n    }\n  else\n    {\n    *append = b;\n    append= &b->next;\n    b = b->next;\n    }\n  }\n\n*append = a ? a : b;\nreturn first;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":225265,"func":"void AudioRendererHost::OnNotifyPacketReady(\n    const IPC::Message& msg, int stream_id, uint32 packet_size) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));\n\n  AudioEntry* entry = LookupById(msg.routing_id(), stream_id);\n  if (!entry) {\n    SendErrorMessage(msg.routing_id(), stream_id);\n    return;\n  }\n\n  DCHECK(!entry->controller->LowLatencyMode());\n  CHECK(packet_size <= entry->shared_memory.created_size());\n\n  if (!entry->pending_buffer_request) {\n    NOTREACHED() << \"Buffer received but no such pending request\";\n  }\n  entry->pending_buffer_request = false;\n\n  entry->controller->EnqueueData(\n      reinterpret_cast<uint8*>(entry->shared_memory.memory()),\n      packet_size);\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":308995,"func":"void RemoteFrame::SetCcLayer(cc::Layer* cc_layer,\n                             bool prevent_contents_opaque_changes,\n                             bool is_surface_layer) {\n  DCHECK(Owner());\n\n  if (cc_layer_)\n    GraphicsLayer::UnregisterContentsLayer(cc_layer_);\n  cc_layer_ = cc_layer;\n  prevent_contents_opaque_changes_ = prevent_contents_opaque_changes;\n  is_surface_layer_ = is_surface_layer;\n  if (cc_layer_) {\n    GraphicsLayer::RegisterContentsLayer(cc_layer_);\n    PointerEventsChanged();\n  }\n\n  ToHTMLFrameOwnerElement(Owner())->SetNeedsCompositingUpdate();\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":495563,"func":"const u8 *gf_isom_get_mpegh_compatible_profiles(GF_ISOFile *movie, u32 trackNumber, u32 sampleDescIndex, u32 *nb_compat_profiles)\n{\n\tGF_SampleEntryBox *ent;\n\tGF_MHACompatibleProfilesBox *mhap;\n\tGF_TrackBox *trak;\n\n\ttrak = gf_isom_get_track_from_file(movie, trackNumber);\n\tif (!trak || !trak->Media || !nb_compat_profiles) return NULL;\n\t*nb_compat_profiles = 0;\n\tent = gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, sampleDescIndex-1);\n\tif (!ent) return NULL;\n\tmhap = (GF_MHACompatibleProfilesBox *) gf_isom_box_find_child(ent->child_boxes, GF_ISOM_BOX_TYPE_MHAP);\n\tif (!mhap) return NULL;\n\t*nb_compat_profiles = mhap->num_profiles;\n\treturn mhap->compat_profiles;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":314049,"func":"bool LiveSyncTest::SetUpLocalTestServer() {\n  CommandLine* cl = CommandLine::ForCurrentProcess();\n  CommandLine::StringType server_cmdline_string = cl->GetSwitchValueNative(\n      switches::kSyncServerCommandLine);\n  CommandLine::StringVector server_cmdline_vector;\n  CommandLine::StringType delimiters(FILE_PATH_LITERAL(\" \"));\n  Tokenize(server_cmdline_string, delimiters, &server_cmdline_vector);\n  CommandLine server_cmdline(server_cmdline_vector);\n  if (!base::LaunchApp(server_cmdline, false, true, &test_server_handle_))\n    LOG(ERROR) << \"Could not launch local test server.\";\n\n  const int kMaxWaitTime = TestTimeouts::live_operation_timeout_ms();\n  const int kNumIntervals = 15;\n  if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) {\n    VLOG(1) << \"Started local test server at \"\n            << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << \".\";\n    return true;\n  } else {\n    LOG(ERROR) << \"Could not start local test server at \"\n               << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << \".\";\n    return false;\n  }\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":44829,"func":"    **\/\n    const CImg<T>& save_dlm(const char *const filename) const {\n      return _save_dlm(0,filename);","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":278105,"func":"bool ContextualSearchFieldTrial::IsSendBasePageURLDisabled() {\n  return GetBooleanParam(kContextualSearchSendURLDisabledParamName,\n                         &is_send_base_page_url_disabled_cached_,\n                         &is_send_base_page_url_disabled_);\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":312013,"func":"PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& ec)\n{\n    RefPtr<Event> event = EventFactory::create(eventType);\n    if (event)\n        return event.release();\n\n    ec = NOT_SUPPORTED_ERR;\n    return 0;\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":354681,"func":"pfm_context_free(pfm_context_t *ctx)\n{\n\tif (ctx) {\n\t\tDPRINT((\"free ctx @%p\\n\", ctx));\n\t\tkfree(ctx);\n\t}\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":164702,"func":"void HTMLFormControlElement::DidChangeForm() {\n  ListedElement::DidChangeForm();\n  if (formOwner() && isConnected() && CanBeSuccessfulSubmitButton())\n    formOwner()->InvalidateDefaultButtonStyle();\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":453292,"func":"perf_cgroup_event_disable(struct perf_event *event, struct perf_event_context *ctx)\n{\n\tstruct perf_cpu_context *cpuctx;\n\n\tif (!is_cgroup_event(event))\n\t\treturn;\n\n\t\/*\n\t * Because cgroup events are always per-cpu events,\n\t * @ctx == &cpuctx->ctx.\n\t *\/\n\tcpuctx = container_of(ctx, struct perf_cpu_context, ctx);\n\n\tif (--ctx->nr_cgroups)\n\t\treturn;\n\n\tif (ctx->is_active && cpuctx->cgrp)\n\t\tcpuctx->cgrp = NULL;\n\n\tlist_del(&cpuctx->cgrp_cpuctx_entry);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":82083,"func":"static void virtnet_config_changed_work(struct work_struct *work)\n{\n\tstruct virtnet_info *vi =\n\t\tcontainer_of(work, struct virtnet_info, config_work);\n\tu16 v;\n\n\tif (virtio_cread_feature(vi->vdev, VIRTIO_NET_F_STATUS,\n\t\t\t\t struct virtio_net_config, status, &v) < 0)\n\t\treturn;\n\n\tif (v & VIRTIO_NET_S_ANNOUNCE) {\n\t\tnetdev_notify_peers(vi->dev);\n\t\tvirtnet_ack_link_announce(vi);\n\t}\n\n\t\/* Ignore unknown (future) status bits *\/\n\tv &= VIRTIO_NET_S_LINK_UP;\n\n\tif (vi->status == v)\n\t\treturn;\n\n\tvi->status = v;\n\n\tif (vi->status & VIRTIO_NET_S_LINK_UP) {\n\t\tnetif_carrier_on(vi->dev);\n\t\tnetif_tx_wake_all_queues(vi->dev);\n\t} else {\n\t\tnetif_carrier_off(vi->dev);\n\t\tnetif_tx_stop_all_queues(vi->dev);\n\t}\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":477197,"func":"nwfilterBindingLookupByPortDev(virConnectPtr conn,\n                               const char *portdev)\n{\n    virNWFilterBindingPtr ret = NULL;\n    virNWFilterBindingObj *obj;\n    virNWFilterBindingDef *def;\n\n    obj = virNWFilterBindingObjListFindByPortDev(driver->bindings,\n                                                 portdev);\n    if (!obj) {\n        virReportError(VIR_ERR_NO_NWFILTER_BINDING,\n                       _(\"no nwfilter binding for port dev '%s'\"), portdev);\n        goto cleanup;\n    }\n\n    def = virNWFilterBindingObjGetDef(obj);\n    if (virNWFilterBindingLookupByPortDevEnsureACL(conn, def) < 0)\n        goto cleanup;\n\n    ret = virGetNWFilterBinding(conn, def->portdevname, def->filter);\n\n cleanup:\n    virNWFilterBindingObjEndAPI(&obj);\n    return ret;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":295135,"func":"static unsigned long scale_rt_capacity(struct sched_domain *sd, int cpu)\n{\n\tstruct rq *rq = cpu_rq(cpu);\n\tunsigned long max = arch_scale_cpu_capacity(sd, cpu);\n\tunsigned long used, free;\n\tunsigned long irq;\n\n\tirq = cpu_util_irq(rq);\n\n\tif (unlikely(irq >= max))\n\t\treturn 1;\n\n\tused = READ_ONCE(rq->avg_rt.util_avg);\n\tused += READ_ONCE(rq->avg_dl.util_avg);\n\n\tif (unlikely(used >= max))\n\t\treturn 1;\n\n\tfree = max - used;\n\n\treturn scale_irq_capacity(free, irq, max);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":240991,"func":"bool AccessibilityUIElement::addNotificationListener(JSValueRef functionCallback)\n{\n    return true;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":120852,"func":"QPDFObjectHandle::ParserCallbacks::terminateParsing()\n{\n    throw TerminateParsing();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":230751,"func":"InvalidationNotifier::~InvalidationNotifier() {\n  DCHECK(CalledOnValidThread());\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":160399,"func":"mono_reflection_parse_type (char *name, MonoTypeNameParse *info)\n{\n\treturn _mono_reflection_parse_type (name, NULL, FALSE, info);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":410264,"func":"                void readMetadata()\n                {\n\n                }","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":513435,"func":"RefreshArea(xs, ys, xe, ye, isblank)\nint xs, ys, xe, ye, isblank;\n{\n  int y;\n  ASSERT(display);\n  debug2(\"Refresh Area: %d,%d\", xs, ys);\n  debug3(\" - %d,%d (isblank=%d)\\n\", xe, ye, isblank);\n  if (!isblank && xs == 0 && xe == D_width - 1 && ye == D_height - 1 && (ys == 0 || D_CD))\n    {\n      ClearArea(xs, ys, xs, xe, xe, ye, 0, 0);\n      isblank = 1;\n    }\n  for (y = ys; y <= ye; y++)\n    RefreshLine(y, xs, xe, isblank);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":275877,"func":"static void perWorldBindingsReadonlyTestInterfaceEmptyAttributeAttributeGetterCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TestInterfaceNodeV8Internal::perWorldBindingsReadonlyTestInterfaceEmptyAttributeAttributeGetterForMainWorld(info);\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":157875,"func":"void Pipe::handle_ack(uint64_t seq)\n{\n  lsubdout(msgr->cct, ms, 15) << \"reader got ack seq \" << seq << dendl;\n  \/\/ trim sent list\n  while (!sent.empty() &&\n\t sent.front()->get_seq() <= seq) {\n    Message *m = sent.front();\n    sent.pop_front();\n    lsubdout(msgr->cct, ms, 10) << \"reader got ack seq \"\n\t\t\t\t<< seq << \" >= \" << m->get_seq() << \" on \" << m << \" \" << *m << dendl;\n    m->put();\n  }\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":253558,"func":"static int netjoin_set_nickmode(IRC_SERVER_REC *server, NETJOIN_REC *rec,\n\t\t\t\tconst char *channel, char prefix)\n{\n\tGSList *pos;\n\tconst char *flags;\n\tchar *found_chan = NULL;\n\n\tfor (pos = rec->now_channels; pos != NULL; pos = pos->next) {\n\t\tchar *chan = pos->data;\n\t\tif (strcasecmp(chan+1, channel) == 0) {\n\t\t\tfound_chan = chan;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (found_chan == NULL)\n\t\treturn FALSE;\n\n\tflags = server->get_nick_flags(SERVER(server));\n\twhile (*flags != '\\0') {\n\t\tif (found_chan[0] == *flags)\n\t\t\tbreak;\n\t\tif (prefix == *flags) {\n\t\t\tfound_chan[0] = prefix;\n\t\t\tbreak;\n\t\t}\n\t\tflags++;\n\t}\n\treturn TRUE;\n}\n","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":94963,"func":"static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,\n\t\tint cfgno, int inum, int asnum, struct usb_host_endpoint *ep,\n\t\tunsigned char *buffer, int size)\n{\n\tstruct usb_ssp_isoc_ep_comp_descriptor *desc;\n\n\t\/*\n\t * The SuperSpeedPlus Isoc endpoint companion descriptor immediately\n\t * follows the SuperSpeed Endpoint Companion descriptor\n\t *\/\n\tdesc = (struct usb_ssp_isoc_ep_comp_descriptor *) buffer;\n\tif (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP ||\n\t    size < USB_DT_SSP_ISOC_EP_COMP_SIZE) {\n\t\tdev_warn(ddev, \"Invalid SuperSpeedPlus isoc endpoint companion\"\n\t\t\t \"for config %d interface %d altsetting %d ep %d.\\n\",\n\t\t\t cfgno, inum, asnum, ep->desc.bEndpointAddress);\n\t\treturn;\n\t}\n\tmemcpy(&ep->ssp_isoc_ep_comp, desc, USB_DT_SSP_ISOC_EP_COMP_SIZE);\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":160354,"func":"ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)\n{\n\tstruct file *lower_file = ecryptfs_file_to_lower(file);\n\tlong rc = -ENOIOCTLCMD;\n\n\tif (!lower_file->f_op->compat_ioctl)\n\t\treturn rc;\n\n\tswitch (cmd) {\n\tcase FS_IOC32_GETFLAGS:\n\tcase FS_IOC32_SETFLAGS:\n\tcase FS_IOC32_GETVERSION:\n\tcase FS_IOC32_SETVERSION:\n\t\trc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg);\n\t\tfsstack_copy_attr_all(file_inode(file), file_inode(lower_file));\n\n\t\treturn rc;\n\tdefault:\n\t\treturn rc;\n\t}\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":126299,"func":"DisplayNameValueList(char * buffer, int bufsize)\n{\n    struct NameValueParserData pdata;\n    struct NameValue * nv;\n    ParseNameValue(buffer, bufsize, &pdata);\n    for(nv = pdata.l_head;\n        nv != NULL;\n        nv = nv->l_next)\n    {\n        printf(\"%s = %s\\n\", nv->name, nv->value);\n    }\n    ClearNameValueList(&pdata);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":423725,"func":"setmodtime(dns_zone_t *zone, isc_time_t *expiretime) {\n\tisc_result_t result;\n\tisc_time_t when;\n\tisc_interval_t i;\n\n\tisc_interval_set(&i, zone->expire, 0);\n\tresult = isc_time_subtract(expiretime, &i, &when);\n\tif (result != ISC_R_SUCCESS)\n\t\treturn;\n\n\tresult = ISC_R_FAILURE;\n\tif (zone->journal != NULL)\n\t\tresult = isc_file_settime(zone->journal, &when);\n\tif (result == ISC_R_SUCCESS &&\n\t    !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP) &&\n\t    !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP))\n\t\tresult = isc_file_settime(zone->masterfile, &when);\n\telse if (result != ISC_R_SUCCESS)\n\t\tresult = isc_file_settime(zone->masterfile, &when);\n\n\t\/*\n\t * Someone removed the file from underneath us!\n\t *\/\n\tif (result == ISC_R_FILENOTFOUND) {\n\t\tzone_needdump(zone, DNS_DUMP_DELAY);\n\t} else if (result != ISC_R_SUCCESS)\n\t\tdns_zone_log(zone, ISC_LOG_ERROR, \"refresh: could not set \"\n\t\t\t     \"file modification time of '%s': %s\",\n\t\t\t     zone->masterfile, dns_result_totext(result));\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":470451,"func":"    void CrwMap::decode0x180e(const CiffComponent& ciffComponent,\n                              const CrwMapping*    pCrwMapping,\n                                    Image&         image,\n                                    ByteOrder      byteOrder)\n    {\n        if (ciffComponent.size() < 8 || ciffComponent.typeId() != unsignedLong) {\n            return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder);\n        }\n        assert(pCrwMapping != 0);\n        ULongValue v;\n        v.read(ciffComponent.pData(), 8, byteOrder);\n        time_t t = v.value_[0];\n        struct tm* tm = std::localtime(&t);\n        if (tm) {\n            const size_t m = 20;\n            char s[m];\n            std::strftime(s, m, \"%Y:%m:%d %H:%M:%S\", tm);\n\n            ExifKey key(pCrwMapping->tag_, Internal::groupName(pCrwMapping->ifdId_));\n            AsciiValue value;\n            value.read(std::string(s));\n            image.exifData().add(key, &value);\n        }\n    } \/\/ CrwMap::decode0x180e","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":194646,"func":"RenderThreadImpl::~RenderThreadImpl() {\n  for (std::map<int, mojo::MessagePipeHandle>::iterator it =\n           pending_render_frame_connects_.begin();\n       it != pending_render_frame_connects_.end();\n       ++it) {\n    mojo::CloseRaw(it->second);\n  }\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":393765,"func":"system_read(gnutls_transport_ptr_t ptr, void *data, size_t data_size)\n{\n\treturn recv(GNUTLS_POINTER_TO_INT(ptr), data, data_size, 0);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":282725,"func":"void Document::ProcessJavaScriptUrl(\n    const KURL& url,\n    ContentSecurityPolicyDisposition disposition) {\n  DCHECK(url.ProtocolIsJavaScript());\n  if (frame_->Loader().StateMachine()->IsDisplayingInitialEmptyDocument())\n    load_event_progress_ = kLoadEventNotRun;\n  frame_->Loader().Progress().ProgressStarted();\n  if (frame_->Loader().StateMachine()->IsDisplayingInitialEmptyDocument() &&\n      (url == \"javascript:''\" || url == \"javascript:\\\"\\\"\")) {\n    ExecuteJavaScriptUrl(url, disposition);\n    return;\n  }\n  javascript_url_task_handle_ = PostCancellableTask(\n      *GetTaskRunner(TaskType::kNetworking), FROM_HERE,\n      WTF::Bind(&Document::ExecuteJavaScriptUrl, WrapWeakPersistent(this), url,\n                disposition));\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":505955,"func":"STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s)\n\t{\n\tSTACK_OF(X509) *r;\n\t\n\tif ((s == NULL) || (s->session == NULL) || (s->session->sess_cert == NULL))\n\t\tr=NULL;\n\telse\n\t\tr=s->session->sess_cert->cert_chain;\n\n\t\/* If we are a client, cert_chain includes the peer's own\n\t * certificate; if we are a server, it does not. *\/\n\t\n\treturn(r);\n\t}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":473414,"func":"PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object)\n{\n\tint ret_refcount = -1;\n\tphp_libxml_node_ptr *obj_node;\n\n\tif (object != NULL && object->node != NULL) {\n\t\tobj_node = (php_libxml_node_ptr *) object->node;\n\t\tret_refcount = --obj_node->refcount;\n\t\tif (ret_refcount == 0) {\n\t\t\tif (obj_node->node != NULL) {\n\t\t\t\tobj_node->node->_private = NULL;\n\t\t\t}\n\t\t\tefree(obj_node);\n\t\t}\n\t\tobject->node = NULL;\n\t}\n\n\treturn ret_refcount;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":467679,"func":"Client::adjustBodyBytesRead(const int64_t delta)\n{\n    int64_t &bodyBytesRead = originalRequest()->hier.bodyBytesRead;\n\n    \/\/ if we got here, do not log a dash even if we got nothing from the server\n    if (bodyBytesRead < 0)\n        bodyBytesRead = 0;\n\n    bodyBytesRead += delta; \/\/ supports negative and zero deltas\n\n    \/\/ check for overflows (\"infinite\" response?) and underflows (a bug)\n    Must(bodyBytesRead >= 0);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":156757,"func":"static int quit_callback(sd_event_source *event, void *userdata) {\n        sd_bus *bus = userdata;\n\n        assert(event);\n\n        if (bus->close_on_exit) {\n                sd_bus_flush(bus);\n                sd_bus_close(bus);\n        }\n\n        return 1;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":296669,"func":"static bool get_reqs_available(struct kioctx *ctx)\n{\n\tstruct kioctx_cpu *kcpu;\n\tbool ret = false;\n\n\tpreempt_disable();\n\tkcpu = this_cpu_ptr(ctx->cpu);\n\n\tif (!kcpu->reqs_available) {\n\t\tint old, avail = atomic_read(&ctx->reqs_available);\n\n\t\tdo {\n\t\t\tif (avail < ctx->req_batch)\n\t\t\t\tgoto out;\n\n\t\t\told = avail;\n\t\t\tavail = atomic_cmpxchg(&ctx->reqs_available,\n\t\t\t\t\t       avail, avail - ctx->req_batch);\n\t\t} while (avail != old);\n\n\t\tkcpu->reqs_available += ctx->req_batch;\n\t}\n\n\tret = true;\n\tkcpu->reqs_available--;\nout:\n\tpreempt_enable();\n\treturn ret;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":100366,"func":"update_curswant(void)\n{\n    if (curwin->w_set_curswant)\n    {\n\tvalidate_virtcol();\n\tcurwin->w_curswant = curwin->w_virtcol;\n\tcurwin->w_set_curswant = FALSE;\n    }\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":193368,"func":"static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)\n{\n    if (style->fontDescription().smallCaps())\n        return cssValuePool().createIdentifierValue(CSSValueSmallCaps);\n    return cssValuePool().createIdentifierValue(CSSValueNormal);\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":480580,"func":"void DL_Dxf::addLine(DL_CreationInterface* creationInterface) {\n    DL_LineData d(getRealValue(10, 0.0),\n                  getRealValue(20, 0.0),\n                  getRealValue(30, 0.0),\n                  getRealValue(11, 0.0),\n                  getRealValue(21, 0.0),\n                  getRealValue(31, 0.0));\n\n    creationInterface->addLine(d);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":383580,"func":"static int do_sect_fault(unsigned long addr, unsigned int esr,\n\t\t\t struct pt_regs *regs)\n{\n\tdo_bad_area(addr, esr, regs);\n\treturn 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":279343,"func":"  GpuRasterizationSucceedsWithLargeImage()\n      : viewport_size_(1024, 2048), large_image_size_(20000, 10) {}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":359584,"func":"applet_get_all_connections (NMApplet *applet)\n{\n\tGSList *list;\n\tGSList *connections = NULL;\n\n\tlist = nm_settings_list_connections (NM_SETTINGS (applet->dbus_settings));\n\tg_slist_foreach (list, exported_connection_to_connection, &connections);\n\tg_slist_free (list);\n\n\tlist = nm_settings_list_connections (NM_SETTINGS (applet->gconf_settings));\n\tg_slist_foreach (list, exported_connection_to_connection, &connections);\n\tg_slist_free (list);\n\n\treturn connections;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":503996,"func":"  const std::string& clientSecret() const override {\n    CONSTRUCT_ON_FIRST_USE(std::string, \"asdf_client_secret_fdsa\");\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":114616,"func":"njs_generator_stack_pop(njs_vm_t *vm, njs_generator_t *generator, void *ctx)\n{\n    njs_queue_link_t             *link;\n    njs_generator_stack_entry_t  *entry;\n\n    entry = njs_queue_link_data(njs_queue_first(&generator->stack),\n                                njs_generator_stack_entry_t, link);\n\n    link = njs_queue_first(&generator->stack);\n    njs_queue_remove(link);\n\n    if (ctx != NULL) {\n        njs_mp_free(vm->mem_pool, ctx);\n    }\n\n    generator->context = entry->context;\n\n    njs_generator_next(generator, entry->state, entry->node);\n\n    njs_mp_free(vm->mem_pool, entry);\n\n    return NJS_OK;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":505843,"func":"dtls1_hm_fragment_free(hm_fragment *frag)\n\t{\n\n\tif (frag->msg_header.is_ccs)\n\t\t{\n\t\tEVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx);\n\t\tEVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash);\n\t\t}\n\tif (frag->fragment) OPENSSL_free(frag->fragment);\n\tif (frag->reassembly) OPENSSL_free(frag->reassembly);\n\tOPENSSL_free(frag);\n\t}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":453240,"func":"bool  wsrep_sst_receive_address_check (sys_var *self, THD* thd, set_var* var)\n{\n    const char* c_str = var->value->str_value.c_ptr();\n\n    if (sst_receive_address_check (c_str))\n    {\n        my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), \"wsrep_sst_receive_address\", c_str ? c_str : \"NULL\");\n        return 1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":185795,"func":"int __trace_bputs(unsigned long ip, const char *str)\n{\n\tstruct ring_buffer_event *event;\n\tstruct ring_buffer *buffer;\n\tstruct bputs_entry *entry;\n\tunsigned long irq_flags;\n\tint size = sizeof(struct bputs_entry);\n\tint pc;\n\n\tif (!(global_trace.trace_flags & TRACE_ITER_PRINTK))\n\t\treturn 0;\n\n\tpc = preempt_count();\n\n\tif (unlikely(tracing_selftest_running || tracing_disabled))\n\t\treturn 0;\n\n\tlocal_save_flags(irq_flags);\n\tbuffer = global_trace.trace_buffer.buffer;\n\tevent = __trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,\n\t\t\t\t\t    irq_flags, pc);\n\tif (!event)\n\t\treturn 0;\n\n\tentry = ring_buffer_event_data(event);\n\tentry->ip\t\t\t= ip;\n\tentry->str\t\t\t= str;\n\n\t__buffer_unlock_commit(buffer, event);\n\tftrace_trace_stack(&global_trace, buffer, irq_flags, 4, pc, NULL);\n\n\treturn 1;\n}\n","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":275396,"func":"RAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent)\n{\n    return rand_drbg_new(1, type, flags, parent);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":510299,"func":"int Item_param::save_in_field(Field *field, bool no_conversions)\n{\n  field->set_notnull();\n\n  switch (state) {\n  case INT_VALUE:\n    return field->store(value.integer, unsigned_flag);\n  case REAL_VALUE:\n    return field->store(value.real);\n  case DECIMAL_VALUE:\n    return field->store_decimal(&decimal_value);\n  case TIME_VALUE:\n    field->store_time_dec(&value.time, decimals);\n    return 0;\n  case STRING_VALUE:\n  case LONG_DATA_VALUE:\n    return field->store(str_value.ptr(), str_value.length(),\n                        str_value.charset());\n  case NULL_VALUE:\n    return set_field_to_null_with_conversions(field, no_conversions);\n  case NO_VALUE:\n  default:\n    DBUG_ASSERT(0);\n  }\n  return 1;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":182996,"func":"std::string DevToolsAgentHostImpl::GetParentId() {\n  return std::string();\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":232624,"func":"void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *rmsgp, int chunks)\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":38763,"func":"int mod_timer(struct timer_list *timer, unsigned long expires)\n{\n\treturn __mod_timer(timer, expires, 0);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":254214,"func":"_PUBLIC_ char *strlower_talloc_handle(struct smb_iconv_handle *iconv_handle,\n\t\t\t\t      TALLOC_CTX *ctx, const char *src)\n{\n\tsize_t size=0;\n\tchar *dest;\n\n\tif(src == NULL) {\n\t\treturn NULL;\n\t}\n\n\t\/* this takes advantage of the fact that upper\/lower can't\n\t   change the length of a character by more than 1 byte *\/\n\tdest = talloc_array(ctx, char, 2*(strlen(src))+1);\n\tif (dest == NULL) {\n\t\treturn NULL;\n\t}\n\n\twhile (*src) {\n\t\tsize_t c_size;\n\t\tcodepoint_t c = next_codepoint_handle(iconv_handle, src, &c_size);\n\t\tsrc += c_size;\n\n\t\tc = tolower_m(c);\n\n\t\tc_size = push_codepoint_handle(iconv_handle, dest+size, c);\n\t\tif (c_size == -1) {\n\t\t\ttalloc_free(dest);\n\t\t\treturn NULL;\n\t\t}\n\t\tsize += c_size;\n\t}\n\n\tdest[size] = 0;\n\n\t\/* trim it so talloc_append_string() works *\/\n\tdest = talloc_realloc(ctx, dest, char, size+1);\n\n\ttalloc_set_name_const(dest, dest);\n\n\treturn dest;\n}\n","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":454933,"func":"TEST_F(QueryPlannerTest, ExistsTrueSparseIndexOnOtherField) {\n    addIndex(BSON(\"x\" << 1), false, true);\n\n    runQuery(fromjson(\"{x: 1, y: {$exists: true}}\"));\n\n    assertNumSolutions(2U);\n    assertSolutionExists(\"{cscan: {dir: 1}}\");\n    assertSolutionExists(\"{fetch: {node: {ixscan: {pattern: {x: 1}}}}}\");\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":99110,"func":"static RList *sections(RBinFile *bf) {\n\treturn MACH0_(get_segments) (bf);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":120543,"func":"fst_process_int_work_q(unsigned long \/*void **\/work_q)\n{\n\tunsigned long flags;\n\tu64 work_intq;\n\tint i;\n\n\t\/*\n\t * Grab the queue exclusively\n\t *\/\n\tdbg(DBG_INTR, \"fst_process_int_work_q\\n\");\n\tspin_lock_irqsave(&fst_work_q_lock, flags);\n\twork_intq = fst_work_intq;\n\tfst_work_intq = 0;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);\n\n\t\/*\n\t * Call the bottom half for each card with work waiting\n\t *\/\n\tfor (i = 0; i < FST_MAX_CARDS; i++) {\n\t\tif (work_intq & 0x01) {\n\t\t\tif (fst_card_array[i] != NULL) {\n\t\t\t\tdbg(DBG_INTR,\n\t\t\t\t    \"Calling rx & tx bh for card %d\\n\", i);\n\t\t\t\tdo_bottom_half_rx(fst_card_array[i]);\n\t\t\t\tdo_bottom_half_tx(fst_card_array[i]);\n\t\t\t}\n\t\t}\n\t\twork_intq = work_intq >> 1;\n\t}\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":32225,"func":"static void infolistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) {\n    FontView *fv = (FontView *) GDrawGetUserData(gw);\n    int anychars = FVAnyCharSelected(fv);\n\n    for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) {\n\tswitch ( mi->mid ) {\n\t  case MID_StrikeInfo:\n\t    mi->ti.disabled = fv->b.sf->bitmaps==NULL;\n\t  break;\n\t  case MID_MassRename:\n\t    mi->ti.disabled = anychars==-1;\n\t  break;\n\t  case MID_SetColor:\n\t    mi->ti.disabled = anychars==-1;\n\t  break;\n\t}\n    }\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":518036,"func":"void Item_field::cleanup()\n{\n  DBUG_ENTER(\"Item_field::cleanup\");\n  Item_ident::cleanup();\n  depended_from= NULL;\n  \/*\n    Even if this object was created by direct link to field in setup_wild()\n    it will be linked correctly next time by name of field and table alias.\n    I.e. we can drop 'field'.\n   *\/\n  field= 0;\n  item_equal= NULL;\n  null_value= FALSE;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":442779,"func":"connect_blocking(void *data)\n{\n    struct connect_arg *arg = data;\n    return (VALUE)connect(arg->fd, arg->sockaddr, arg->len);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":387604,"func":"static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,\n\t\t\t      uid_t uid, gid_t gid)\n{\n\ttime_t timestamp;\n\tchar *stripped;\n\tint ret, saved_errno;\n\tchar *conv;\n\n\tif (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,\n\t\t\t\t\t ×tamp, &stripped)) {\n\t\treturn -1;\n\t}\n\tif (timestamp == 0) {\n\t\treturn SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);\n\t}\n\tconv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);\n\tTALLOC_FREE(stripped);\n\tif (conv == NULL) {\n\t\treturn -1;\n\t}\n\tret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);\n\tsaved_errno = errno;\n\tTALLOC_FREE(conv);\n\terrno = saved_errno;\n\treturn ret;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":234671,"func":"static void enforcedRangeUnsignedShortAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    ExceptionState exceptionState(ExceptionState::SetterContext, \"enforcedRangeUnsignedShortAttr\", \"TestObject\", info.Holder(), info.GetIsolate());\n    TestObject* imp = V8TestObject::toNative(info.Holder());\n    V8TRYCATCH_EXCEPTION_VOID(unsigned, cppValue, toUInt16(jsValue, EnforceRange, exceptionState), exceptionState);\n    imp->setEnforcedRangeUnsignedShortAttr(cppValue);\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":19755,"func":"static void virtio_net_handle_tx_bh ( VirtIODevice * vdev , VirtQueue * vq ) {\n VirtIONet * n = to_virtio_net ( vdev ) ;\n if ( unlikely ( n -> tx_waiting ) ) {\n return ;\n }\n n -> tx_waiting = 1 ;\n if ( ! n -> vdev . vm_running ) {\n return ;\n }\n virtio_queue_set_notification ( vq , 0 ) ;\n qemu_bh_schedule ( n -> tx_bh ) ;\n }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":514716,"func":"int llhttp__internal__c_is_equal_upgrade(\n    llhttp__internal_t* state,\n    const unsigned char* p,\n    const unsigned char* endp) {\n  return state->upgrade == 1;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":33865,"func":"  void skipPortUsageValidation() { skip_port_usage_validation_ = true; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":454824,"func":"void __init udbg_init_rtas_console(void)\n{\n\tudbg_putc = udbg_rtascon_putc;\n\tudbg_getc = udbg_rtascon_getc;\n\tudbg_getc_poll = udbg_rtascon_getc_poll;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":239803,"func":"void smp_send_keypress_notification(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {\n  p_cb->local_keypress_notification = *(uint8_t*)p_data;\n  smp_send_cmd(SMP_OPCODE_PAIR_KEYPR_NOTIF, p_cb);\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":306283,"func":"assembly_add_resource_manifest (MonoReflectionModuleBuilder *mb, MonoDynamicImage *assembly, MonoReflectionResource *rsrc, guint32 implementation)\n{\n\tMonoDynamicTable *table;\n\tguint32 *values;\n\n\ttable = &assembly->tables [MONO_TABLE_MANIFESTRESOURCE];\n\ttable->rows++;\n\talloc_table (table, table->rows);\n\tvalues = table->values + table->next_idx * MONO_MANIFEST_SIZE;\n\tvalues [MONO_MANIFEST_OFFSET] = rsrc->offset;\n\tvalues [MONO_MANIFEST_FLAGS] = rsrc->attrs;\n\tvalues [MONO_MANIFEST_NAME] = string_heap_insert_mstring (&assembly->sheap, rsrc->name);\n\tvalues [MONO_MANIFEST_IMPLEMENTATION] = implementation;\n\ttable->next_idx++;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":65336,"func":"\nstatic enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)\n{\n\tstruct io_timeout_data *data = container_of(timer,\n\t\t\t\t\t\tstruct io_timeout_data, timer);\n\tstruct io_kiocb *req = data->req;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&ctx->timeout_lock, flags);\n\tlist_del_init(&req->timeout.list);\n\tatomic_set(&req->ctx->cq_timeouts,\n\t\tatomic_read(&req->ctx->cq_timeouts) + 1);\n\tspin_unlock_irqrestore(&ctx->timeout_lock, flags);\n\n\tif (!(data->flags & IORING_TIMEOUT_ETIME_SUCCESS))\n\t\treq_set_fail(req);\n\n\treq->result = -ETIME;\n\treq->io_task_work.func = io_req_task_complete;\n\tio_req_task_work_add(req, false);\n\treturn HRTIMER_NORESTART;","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":283424,"func":"AttestationPermissionRequestSheetModel::AttestationPermissionRequestSheetModel(\n    AuthenticatorRequestDialogModel* dialog_model)\n    : AuthenticatorSheetModelBase(dialog_model) {}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":175397,"func":"bool GDataDirectory::RemoveEntry(GDataEntry* entry) {\n  DCHECK(entry);\n\n  if (!RemoveChild(entry))\n    return false;\n\n  delete entry;\n  return true;\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":494575,"func":"flow_hash_table_t *flow_hash_table_init(size_t n)\n{\n    flow_hash_table_t *fht;\n    if (!is_power_of_2(n))\n        errx(-1, \"invalid table size: %zu\", n);\n\n    fht = safe_malloc(sizeof(*fht));\n    fht->num_buckets = n;\n    fht->buckets = safe_malloc(sizeof(flow_hash_entry_t) * n);\n\n    return fht;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":403262,"func":"RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,\n                                   MemoryRegion *mr, Error **errp)\n{\n    return qemu_ram_alloc_internal(size, size, NULL, host, false, mr, errp);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":199809,"func":"void AutomationProvider::GetEnabledExtensions(\n    std::vector<FilePath>* result) {\n  ExtensionService* service = profile_->GetExtensionService();\n  DCHECK(service);\n  if (service->extensions_enabled()) {\n    const ExtensionList* extensions = service->extensions();\n    DCHECK(extensions);\n    for (size_t i = 0; i < extensions->size(); ++i) {\n      const Extension* extension = (*extensions)[i];\n      DCHECK(extension);\n      if (!extension->is_app() &&\n          (extension->location() == Extension::INTERNAL ||\n           extension->location() == Extension::LOAD)) {\n        result->push_back(extension->path());\n      }\n    }\n  }\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":228180,"func":" static void GrowCapacityAndConvertImpl(Handle<JSObject> object,\n uint32_t capacity) {\n    UNREACHABLE();\n }\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":172847,"func":"String referrerPolicy(net::URLRequest::ReferrerPolicy referrer_policy) {\n  switch (referrer_policy) {\n    case net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE:\n      return Network::Request::ReferrerPolicyEnum::NoReferrerWhenDowngrade;\n    case net::URLRequest::\n        REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN:\n      return Network::Request::ReferrerPolicyEnum::StrictOriginWhenCrossOrigin;\n    case net::URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN:\n      return Network::Request::ReferrerPolicyEnum::OriginWhenCrossOrigin;\n    case net::URLRequest::NEVER_CLEAR_REFERRER:\n      return Network::Request::ReferrerPolicyEnum::Origin;\n    case net::URLRequest::ORIGIN:\n      return Network::Request::ReferrerPolicyEnum::Origin;\n    case net::URLRequest::NO_REFERRER:\n      return Network::Request::ReferrerPolicyEnum::NoReferrer;\n    default:\n      break;\n  }\n  NOTREACHED();\n  return Network::Request::ReferrerPolicyEnum::NoReferrerWhenDowngrade;\n}\n","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":315508,"func":"parse_SET_TUNNEL(char *arg, struct ofpbuf *ofpacts,\n                 enum ofputil_protocol *usable_protocols OVS_UNUSED)\n{\n    return parse_set_tunnel(arg, ofpacts, NXAST_RAW_SET_TUNNEL);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":340718,"func":"static void aer915_class_init(ObjectClass *klass, void *data)\n\n{\n\n    DeviceClass *dc = DEVICE_CLASS(klass);\n\n    I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);\n\n\n\n    k->init = aer915_init;\n\n    k->event = aer915_event;\n\n    k->recv = aer915_recv;\n\n    k->send = aer915_send;\n\n    dc->vmsd = &vmstate_aer915_state;\n\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":44695,"func":"static int ip_vs_genl_set_daemon(struct sk_buff *skb, struct genl_info *info)\n{\n\tint ret = 0, cmd;\n\tstruct net *net;\n\tstruct netns_ipvs *ipvs;\n\n\tnet = skb_sknet(skb);\n\tipvs = net_ipvs(net);\n\tcmd = info->genlhdr->cmd;\n\n\tif (cmd == IPVS_CMD_NEW_DAEMON || cmd == IPVS_CMD_DEL_DAEMON) {\n\t\tstruct nlattr *daemon_attrs[IPVS_DAEMON_ATTR_MAX + 1];\n\n\t\tmutex_lock(&ipvs->sync_mutex);\n\t\tif (!info->attrs[IPVS_CMD_ATTR_DAEMON] ||\n\t\t    nla_parse_nested(daemon_attrs, IPVS_DAEMON_ATTR_MAX,\n\t\t\t\t     info->attrs[IPVS_CMD_ATTR_DAEMON],\n\t\t\t\t     ip_vs_daemon_policy)) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (cmd == IPVS_CMD_NEW_DAEMON)\n\t\t\tret = ip_vs_genl_new_daemon(net, daemon_attrs);\n\t\telse\n\t\t\tret = ip_vs_genl_del_daemon(net, daemon_attrs);\nout:\n\t\tmutex_unlock(&ipvs->sync_mutex);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":419720,"func":"\nvoid server_maybe_append_tags(Server *s) {\n#if HAVE_GCRYPT\n        JournalFile *f;\n        Iterator i;\n        usec_t n;\n\n        n = now(CLOCK_REALTIME);\n\n        if (s->system_journal)\n                journal_file_maybe_append_tag(s->system_journal, n);\n\n        ORDERED_HASHMAP_FOREACH(f, s->user_journals, i)\n                journal_file_maybe_append_tag(f, n);\n#endif","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":168521,"func":"int64 MakeFolderWithParent(UserShare* share,\n                           ModelType model_type,\n                           int64 parent_id,\n                           BaseNode* predecessor) {\n  WriteTransaction trans(FROM_HERE, share);\n  ReadNode parent_node(&trans);\n  EXPECT_TRUE(parent_node.InitByIdLookup(parent_id));\n  WriteNode node(&trans);\n  EXPECT_TRUE(node.InitByCreation(model_type, parent_node, predecessor));\n  node.SetIsFolder(true);\n  return node.GetId();\n}\n","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":493619,"func":"static struct fuse_module *fuse_find_module(const char *module)\n{\n    struct fuse_module *m;\n    for (m = fuse_modules; m; m = m->next) {\n        if (strcmp(module, m->name) == 0) {\n            m->ctr++;\n            break;\n        }\n    }\n    return m;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":11950,"func":"TargetThread::TargetThread()\n     : thread_started_event_(false, false), finish_event_(false, false),\n      id_(0) {}\n","target":1,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":457377,"func":"rpc_C_DigestUpdate (CK_X_FUNCTION_LIST *self,\n                    p11_rpc_message *msg)\n{\n\tCK_SESSION_HANDLE session;\n\tCK_BYTE_PTR part;\n\tCK_ULONG part_len;\n\n\tBEGIN_CALL (DigestUpdate);\n\t\tIN_ULONG (session);\n\t\tIN_BYTE_ARRAY (part, part_len);\n\tPROCESS_CALL ((self, session, part, part_len));\n\tEND_CALL;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":28859,"func":"int jbig2_end_of_stripe ( Jbig2Ctx * ctx , Jbig2Segment * segment , const uint8_t * segment_data ) {\n Jbig2Page page = ctx -> pages [ ctx -> current_page ] ;\n uint32_t end_row ;\n end_row = jbig2_get_uint32 ( segment_data ) ;\n if ( end_row < page . end_row ) {\n jbig2_error ( ctx , JBIG2_SEVERITY_WARNING , segment -> number , \"end of stripe segment with non-positive end row advance\" \" (new end row %d vs current end row %d)\" , end_row , page . end_row ) ;\n }\n else {\n jbig2_error ( ctx , JBIG2_SEVERITY_INFO , segment -> number , \"end of stripe: advancing end row to %d\" , end_row ) ;\n }\n page . end_row = end_row ;\n return 0 ;\n }","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":482630,"func":"static void set_cursor(struct vc_data *vc)\n{\n\tif (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS)\n\t\treturn;\n\tif (vc->vc_deccm) {\n\t\tif (vc_is_sel(vc))\n\t\t\tclear_selection();\n\t\tadd_softcursor(vc);\n\t\tif ((vc->vc_cursor_type & 0x0f) != 1)\n\t\t\tvc->vc_sw->con_cursor(vc, CM_DRAW);\n\t} else\n\t\thide_cursor(vc);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":361793,"func":"int ethtool_op_set_flags(struct net_device *dev, u32 data)\n{\n\tconst struct ethtool_ops *ops = dev->ethtool_ops;\n\tunsigned long features = dev->features;\n\n\tif (data & ETH_FLAG_LRO)\n\t\tfeatures |= NETIF_F_LRO;\n\telse\n\t\tfeatures &= ~NETIF_F_LRO;\n\n\tif (data & ETH_FLAG_NTUPLE) {\n\t\tif (!ops->set_rx_ntuple)\n\t\t\treturn -EOPNOTSUPP;\n\t\tfeatures |= NETIF_F_NTUPLE;\n\t} else {\n\t\t\/* safe to clear regardless *\/\n\t\tfeatures &= ~NETIF_F_NTUPLE;\n\t}\n\n\tif (data & ETH_FLAG_RXHASH)\n\t\tfeatures |= NETIF_F_RXHASH;\n\telse\n\t\tfeatures &= ~NETIF_F_RXHASH;\n\n\tdev->features = features;\n\treturn 0;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":185820,"func":"fbCombineDisjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)\n{\n    fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":461411,"func":"static void add_option(gpointer key, gpointer value, gpointer user_data)\n{\n\tconst char *option_value = value;\n\tuint8_t option_code = GPOINTER_TO_INT(key);\n\tstruct in_addr nip;\n\tstruct dhcp_packet *packet = user_data;\n\n\tif (!option_value)\n\t\treturn;\n\n\tswitch (option_code) {\n\tcase G_DHCP_SUBNET:\n\tcase G_DHCP_ROUTER:\n\tcase G_DHCP_DNS_SERVER:\n\t\tif (inet_aton(option_value, &nip) == 0)\n\t\t\treturn;\n\n\t\tdhcp_add_option_uint32(packet, (uint8_t) option_code,\n\t\t\t\t\t\t\tntohl(nip.s_addr));\n\t\tbreak;\n\tdefault:\n\t\treturn;\n\t}\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":55135,"func":"static void tracked_request_begin(BdrvTrackedRequest *req,\n\n                                  BlockDriverState *bs,\n\n                                  int64_t sector_num,\n\n                                  int nb_sectors, bool is_write)\n\n{\n\n    *req = (BdrvTrackedRequest){\n\n        .bs = bs,\n\n        .sector_num = sector_num,\n\n        .nb_sectors = nb_sectors,\n\n        .is_write = is_write,\n\n\n    };\n\n\n\n    qemu_co_queue_init(&req->wait_queue);\n\n\n\n    QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);\n\n}","target":1,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":316414,"func":"  void RegisterDumpProvider(\n      MemoryDumpProvider* mdp,\n      scoped_refptr<base::SingleThreadTaskRunner> task_runner) {\n    RegisterDumpProvider(mdp, task_runner, MemoryDumpProvider::Options());\n  }\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":70249,"func":"\t\t\tvoid push(char_t_to val)\n\t\t\t{\n\t\t\t\tassert(to_next != to_end);\n\t\t\t\t*to_next++  = val;\n\t\t\t}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":37306,"func":"static void established_upcall(struct iwch_ep *ep)\n{\n\tstruct iw_cm_event event;\n\n\tPDBG(\"%s ep %p\\n\", __func__, ep);\n\tmemset(&event, 0, sizeof(event));\n\tevent.event = IW_CM_EVENT_ESTABLISHED;\n\t\/*\n\t * Until ird\/ord negotiation via MPAv2 support is added, send max\n\t * supported values\n\t *\/\n\tevent.ird = event.ord = 8;\n\tif (ep->com.cm_id) {\n\t\tPDBG(\"%s ep %p tid %d\\n\", __func__, ep, ep->hwtid);\n\t\tep->com.cm_id->event_handler(ep->com.cm_id, &event);\n\t}\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":289026,"func":"int qemuAssignDeviceNetAlias ( virDomainDefPtr def , virDomainNetDefPtr net , int idx ) {\n if ( networkGetActualType ( net ) == VIR_DOMAIN_NET_TYPE_HOSTDEV ) return qemuAssignDeviceHostdevAlias ( def , & net -> info . alias , - 1 ) ;\n if ( idx == - 1 ) {\n size_t i ;\n idx = 0 ;\n for ( i = 0 ;\n i < def -> nnets ;\n i ++ ) {\n int thisidx ;\n if ( ( thisidx = qemuDomainDeviceAliasIndex ( & def -> nets [ i ] -> info , \"net\" ) ) < 0 ) continue ;\n if ( thisidx >= idx ) idx = thisidx + 1 ;\n }\n }\n if ( virAsprintf ( & net -> info . alias , \"net%d\" , idx ) < 0 ) return - 1 ;\n return 0 ;\n }","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":279995,"func":"  static void  Ins_POP( INS_ARG )\n  { (void)exc; (void)args;\n    \/* nothing to do *\/\n  }\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":256252,"func":"static int spl_filesystem_file_read_line(zval * this_ptr, spl_filesystem_object *intern, int silent TSRMLS_DC) \/* {{{ *\/\n{\n\tint ret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent TSRMLS_CC);\n\n\twhile (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY) && ret == SUCCESS && spl_filesystem_file_is_empty_line(intern TSRMLS_CC)) {\n \t\tspl_filesystem_file_free_line(intern TSRMLS_CC);\n \t\tret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent TSRMLS_CC);\n \t}\n \treturn ret;\n }\n \/* }}} *\/\n","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":59331,"func":"void rds_conn_connect_if_down(struct rds_connection *conn)\n{\n\tWARN_ON(conn->c_trans->t_mp_capable);\n\trds_conn_path_connect_if_down(&conn->c_path[0]);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":490581,"func":"const char *gf_filter_get_dst_args(GF_Filter *filter)\n{\n\treturn gf_filter_get_args_stripped(filter->session, filter->dst_args, GF_TRUE);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":378557,"func":"static void *wsgi_create_server_config(apr_pool_t *p, server_rec *s)\n{\n    WSGIServerConfig *config = NULL;\n\n    config = newWSGIServerConfig(p);\n\n    return config;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":221945,"func":"filter_report_error(stream_state * st, const char *str)\n{\n    if_debug1m('s', st->memory, \"[s]stream error: %s\\n\", str);\n    strncpy(st->error_string, str, STREAM_MAX_ERROR_STRING);\n    \/* Ensure null termination. *\/\n    st->error_string[STREAM_MAX_ERROR_STRING] = 0;\n    return 0;\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":8765,"func":"static bool is_legal_file(const std::string &filename)\n{\n\tDBG_FS << \"Looking for '\" << filename << \"'.\\n\";\n\n\tif (filename.empty()) {\n\t\tLOG_FS << \"  invalid filename\\n\";\n\t\treturn false;\n\t}\n\n\tif (filename.find(\"..\") != std::string::npos) {\n\t\tERR_FS << \"Illegal path '\" << filename << \"' (\\\"..\\\" not allowed).\\n\";\n\t\treturn false;\n\t}\n\n\tif (ends_with(filename, \".pbl\")) {\n\t\tERR_FS << \"Illegal path '\" << filename << \"' (.pbl files are not allowed).\" << std::endl;\n\t\treturn false;\n\t}\n\n\treturn true;\n}","target":1,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":25458,"func":"static inline uint16_t tswap16 ( uint16_t s ) {\n return s ;\n }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":58903,"func":"void HeaderMapImpl::HeaderEntryImpl::value(uint64_t value) { value_.setInteger(value); }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":83757,"func":"static char *fix_table_name(char *dest, char *src)\n{\n  *dest++= '`';\n  for (; *src; src++)\n  {\n    switch (*src) {\n    case '.':            \/* add backticks around '.' *\/\n      *dest++= '`';\n      *dest++= '.';\n      *dest++= '`';\n      break;\n    case '`':            \/* escape backtick character *\/\n      *dest++= '`';\n      \/* fall through *\/\n    default:\n      *dest++= *src;\n    }\n  }\n  *dest++= '`';\n  return dest;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":448283,"func":"static int nfsd_buffered_filldir(struct dir_context *ctx, const char *name,\n\t\t\t\t int namlen, loff_t offset, u64 ino,\n\t\t\t\t unsigned int d_type)\n{\n\tstruct readdir_data *buf =\n\t\tcontainer_of(ctx, struct readdir_data, ctx);\n\tstruct buffered_dirent *de = (void *)(buf->dirent + buf->used);\n\tunsigned int reclen;\n\n\treclen = ALIGN(sizeof(struct buffered_dirent) + namlen, sizeof(u64));\n\tif (buf->used + reclen > PAGE_SIZE) {\n\t\tbuf->full = 1;\n\t\treturn -EINVAL;\n\t}\n\n\tde->namlen = namlen;\n\tde->offset = offset;\n\tde->ino = ino;\n\tde->d_type = d_type;\n\tmemcpy(de->name, name, namlen);\n\tbuf->used += reclen;\n\n\treturn 0;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":210859,"func":"net::CertStatus ChromePasswordManagerClient::GetMainFrameCertStatus() const {\n  content::NavigationEntry* entry =\n      web_contents()->GetController().GetLastCommittedEntry();\n  if (!entry)\n    return 0;\n  return entry->GetSSL().cert_status;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":306849,"func":"static int read_ahead(struct archive_read* a, size_t how_many,\n    const uint8_t** ptr)\n{\n\tssize_t avail = -1;\n\tif(!ptr)\n\t\treturn 0;\n\n\t*ptr = __archive_read_ahead(a, how_many, &avail);\n\tif(*ptr == NULL) {\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":165724,"func":"void LocalDOMWindow::RemovedEventListener(\n    const AtomicString& event_type,\n    const RegisteredEventListener& registered_listener) {\n  DOMWindow::RemovedEventListener(event_type, registered_listener);\n  if (GetFrame() && GetFrame()->GetPage())\n    GetFrame()->GetPage()->GetEventHandlerRegistry().DidRemoveEventHandler(\n        *this, event_type, registered_listener.Options());\n\n  for (auto& it : event_listener_observers_) {\n    it->DidRemoveEventListener(this, event_type);\n  }\n\n  if (event_type == EventTypeNames::unload) {\n    UntrackUnloadEventListener(this);\n  } else if (event_type == EventTypeNames::beforeunload) {\n    UntrackBeforeUnloadEventListener(this);\n  }\n}\n","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":494365,"func":"static char *skip_space(char *ptr)\n{\n\tfor(; *ptr; ptr++)\n\t\tif (*ptr != ' ' && *ptr != '\\t')\n\t\t\tbreak;\n\treturn ptr;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":254389,"func":"void FrameView::flushAnyPendingPostLayoutTasks()\n{\n    ASSERT(!isInPerformLayout());\n    if (m_postLayoutTasksTimer.isActive())\n        performPostLayoutTasks();\n    if (m_updateWidgetsTimer.isActive())\n        updateWidgetsTimerFired(0);\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":252676,"func":"  virtual bool ethernet_enabled() const {\n    return enabled_devices_ & (1 << TYPE_ETHERNET);\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":469456,"func":"static void intel_hda_set_ics(IntelHDAState *d, const IntelHDAReg *reg, uint32_t old)\n{\n    if (d->ics & ICH6_IRS_BUSY) {\n        intel_hda_corb_run(d);\n    }\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":460967,"func":"vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx,\n                           struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)\n{\n    PCIDevice *d = PCI_DEVICE(s);\n\n    Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];\n    *didx = vmxnet3_ring_curr_cell_idx(ring);\n    vmxnet3_ring_read_curr_cell(d, ring, dbuf);\n    dbuf->addr = le64_to_cpu(dbuf->addr);\n    dbuf->val1 = le32_to_cpu(dbuf->val1);\n    dbuf->ext1 = le32_to_cpu(dbuf->ext1);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":249163,"func":"void AudioRendererHost::OnPlayStream(int stream_id) {\n  DCHECK_CURRENTLY_ON(BrowserThread::IO);\n\n  AudioOutputDelegate* delegate = LookupById(stream_id);\n  if (!delegate) {\n    SendErrorMessage(stream_id);\n    return;\n  }\n\n  delegate->OnPlayStream();\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":325398,"func":"static void virtio_blk_rw_complete(void *opaque, int ret)\n\n{\n\n    VirtIOBlockReq *req = opaque;\n\n\n\n    trace_virtio_blk_rw_complete(req, ret);\n\n\n\n    if (ret) {\n\n        int p = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type);\n\n        bool is_read = !(p & VIRTIO_BLK_T_OUT);\n\n        if (virtio_blk_handle_rw_error(req, -ret, is_read))\n\n            return;\n\n    }\n\n\n\n    virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);\n\n    block_acct_done(bdrv_get_stats(req->dev->bs), &req->acct);\n\n    virtio_blk_free_request(req);\n\n}\n","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":149541,"func":"void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long len)\n{\n\tsk_reset_timer(sk, &sk->sk_timer, jiffies + len);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":10810,"func":" void PluginChannel::OnChannelError() {\n  base::CloseProcessHandle(renderer_handle_);\n  renderer_handle_ = 0;\n   NPChannelBase::OnChannelError();\n   CleanUp();\n }\n","target":1,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":426197,"func":"flatpak_add_bus_filters (GPtrArray      *dbus_proxy_argv,\n                         GHashTable     *ht,\n                         const char     *app_id,\n                         FlatpakContext *context)\n{\n  GHashTableIter iter;\n  gpointer key, value;\n\n  g_ptr_array_add (dbus_proxy_argv, g_strdup (\"--filter\"));\n  if (app_id)\n    {\n      g_ptr_array_add (dbus_proxy_argv, g_strdup_printf (\"--own=%s\", app_id));\n      g_ptr_array_add (dbus_proxy_argv, g_strdup_printf (\"--own=%s.*\", app_id));\n    }\n\n  g_hash_table_iter_init (&iter, ht);\n  while (g_hash_table_iter_next (&iter, &key, &value))\n    {\n      FlatpakPolicy policy = GPOINTER_TO_INT (value);\n\n      if (policy > 0)\n        g_ptr_array_add (dbus_proxy_argv, g_strdup_printf (\"--%s=%s\", flatpak_policy_to_string (policy), (char *) key));\n    }\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":202421,"func":"void InputDispatcher::traceWaitQueueLengthLocked(const sp<Connection>& connection) {\n if (ATRACE_ENABLED()) {\n char counterName[40];\n        snprintf(counterName, sizeof(counterName), \"wq:%s\", connection->getWindowName());\n        ATRACE_INT(counterName, connection->waitQueue.count());\n }\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":368643,"func":"dirvote_get_start_of_next_interval(time_t now, int interval)\n{\n  struct tm tm;\n  time_t midnight_today=0;\n  time_t midnight_tomorrow;\n  time_t next;\n\n  tor_gmtime_r(&now, &tm);\n  tm.tm_hour = 0;\n  tm.tm_min = 0;\n  tm.tm_sec = 0;\n\n  if (tor_timegm(&tm, &midnight_today) < 0) {\n    log_warn(LD_BUG, \"Ran into an invalid time when trying to find midnight.\");\n  }\n  midnight_tomorrow = midnight_today + (24*60*60);\n\n  next = midnight_today + ((now-midnight_today)\/interval + 1)*interval;\n\n  \/* Intervals never cross midnight. *\/\n  if (next > midnight_tomorrow)\n    next = midnight_tomorrow;\n\n  \/* If the interval would only last half as long as it's supposed to, then\n   * skip over to the next day. *\/\n  if (next + interval\/2 > midnight_tomorrow)\n    next = midnight_tomorrow;\n\n  return next;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":423568,"func":"dns_zone_setviewrevert(dns_zone_t *zone) {\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\n\tLOCK_ZONE(zone);\n\tif (zone->prev_view != NULL) {\n\t\tdns_zone_setview_helper(zone, zone->prev_view);\n\t\tdns_view_weakdetach(&zone->prev_view);\n\t}\n\tUNLOCK_ZONE(zone);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":261036,"func":"circuit_guard_state_free(circuit_guard_state_t *state)\n{\n  if (!state)\n    return;\n  entry_guard_restriction_free(state->restrictions);\n  entry_guard_handle_free(state->guard);\n  tor_free(state);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":327262,"func":"static void test_validate_list(TestInputVisitorData *data,\n\n                                const void *unused)\n\n{\n\n    UserDefOneList *head = NULL;\n\n    Visitor *v;\n\n\n\n    v = validate_test_init(data, \"[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]\");\n\n\n\n    visit_type_UserDefOneList(v, NULL, &head, &error_abort);\n\n    qapi_free_UserDefOneList(head);\n\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":481219,"func":"void kvm_mmu_unload(struct kvm_vcpu *vcpu)\n{\n\tstruct kvm *kvm = vcpu->kvm;\n\n\tkvm_mmu_free_roots(kvm, &vcpu->arch.root_mmu, KVM_MMU_ROOTS_ALL);\n\tWARN_ON(VALID_PAGE(vcpu->arch.root_mmu.root.hpa));\n\tkvm_mmu_free_roots(kvm, &vcpu->arch.guest_mmu, KVM_MMU_ROOTS_ALL);\n\tWARN_ON(VALID_PAGE(vcpu->arch.guest_mmu.root.hpa));\n\tvcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":401913,"func":"ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_SUB, (op1_info == MAY_BE_LONG && op2_info == MAY_BE_LONG), ZEND_SUB_LONG, CONST|TMPVARCV, CONST|TMPVARCV, SPEC(NO_CONST_CONST))\n{\n\tUSE_OPLINE\n\tzval *op1, *op2, *result;\n\n\top1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);\n\top2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);\n\tresult = EX_VAR(opline->result.var);\n\tfast_long_sub_function(result, op1, op2);\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":179751,"func":"bool HTMLFormElement::HasLegalLinkAttribute(const QualifiedName& name) const {\n  return name == actionAttr || HTMLElement::HasLegalLinkAttribute(name);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":202512,"func":"  virtual ~MockVideoCaptureImplManager() {}\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":354336,"func":"static void cirrus_cursor_invalidate(VGAState *s1)\n{\n    CirrusVGAState *s = (CirrusVGAState *)s1;\n    int size;\n\n    if (!s->sr[0x12] & CIRRUS_CURSOR_SHOW) {\n        size = 0;\n    } else {\n        if (s->sr[0x12] & CIRRUS_CURSOR_LARGE)\n            size = 64;\n        else\n            size = 32;\n    }\n    \/* invalidate last cursor and new cursor if any change *\/\n    if (s->last_hw_cursor_size != size ||\n        s->last_hw_cursor_x != s->hw_cursor_x ||\n        s->last_hw_cursor_y != s->hw_cursor_y) {\n\n        invalidate_cursor1(s);\n\n        s->last_hw_cursor_size = size;\n        s->last_hw_cursor_x = s->hw_cursor_x;\n        s->last_hw_cursor_y = s->hw_cursor_y;\n        \/* compute the real cursor min and max y *\/\n        cirrus_cursor_compute_yrange(s);\n        invalidate_cursor1(s);\n    }\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":215354,"func":"void JSTestInterface::finishCreation(JSGlobalData& globalData)\n{\n    Base::finishCreation(globalData);\n    ASSERT(inherits(&s_info));\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":365477,"func":"rsRetVal rsCStrTrimTrailingWhiteSpace(cstr_t *pThis)\n{\n\tregister int i;\n\tregister uchar *pC;\n\trsCHECKVALIDOBJECT(pThis, OIDrsCStr);\n\n\ti = pThis->iStrLen;\n\tpC = pThis->pBuf + i - 1;\n\twhile(i > 0 && isspace((int)*pC)) {\n\t\t--pC;\n\t\t--i;\n\t}\n\t\/* i now is the new string length! *\/\n\tpThis->iStrLen = i;\n\n\treturn RS_RET_OK;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":318874,"func":"static void gen_tlbre_440(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n    gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n#else\n\n    if (unlikely(ctx->pr)) {\n\n        gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n        return;\n\n    }\n\n    switch (rB(ctx->opcode)) {\n\n    case 0:\n\n    case 1:\n\n    case 2:\n\n        {\n\n            TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));\n\n            gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env,\n\n                                 t0, cpu_gpr[rA(ctx->opcode)]);\n\n            tcg_temp_free_i32(t0);\n\n        }\n\n        break;\n\n    default:\n\n        gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);\n\n        break;\n\n    }\n\n#endif\n\n}\n","target":1,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":521108,"func":"  String *val_str(String *to)\n  {\n    return has_value() ? Datetime(this).to_string(to, decimals) : NULL;\n  }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":195800,"func":"static void TIFFWarnings(const char *module,const char *format,va_list warning)\n{\n  char\n    message[MaxTextExtent];\n\n  ExceptionInfo\n    *exception;\n\n#if defined(MAGICKCORE_HAVE_VSNPRINTF)\n  (void) vsnprintf(message,MaxTextExtent,format,warning);\n#else\n  (void) vsprintf(message,format,warning);\n#endif\n  (void) ConcatenateMagickString(message,\".\",MaxTextExtent);\n  exception=(ExceptionInfo *) GetMagickThreadValue(tiff_exception);\n  if (exception != (ExceptionInfo *) NULL)\n    (void) ThrowMagickException(exception,GetMagickModule(),CoderWarning,\n      message,\"`%s'\",module);\n}\n","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":243479,"func":"void ChromeClientImpl::ShowVirtualKeyboardOnElementFocus(LocalFrame& frame) {\n  WebLocalFrameImpl::FromFrame(frame.LocalFrameRoot())\n      ->FrameWidget()\n      ->Client()\n      ->ShowVirtualKeyboardOnElementFocus();\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":232975,"func":"cc::EffectTree& PropertyTreeManager::GetEffectTree() {\n  return property_trees_.effect_tree;\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":185358,"func":"void InputMethodLinuxX11::Init(bool focused) {\n  CHECK(LinuxInputMethodContextFactory::instance());\n  input_method_context_ =\n      LinuxInputMethodContextFactory::instance()->CreateInputMethodContext(\n          this);\n  CHECK(input_method_context_.get());\n\n  InputMethodBase::Init(focused);\n\n  if (focused) {\n    input_method_context_->OnTextInputTypeChanged(\n        GetTextInputClient() ?\n        GetTextInputClient()->GetTextInputType() :\n        TEXT_INPUT_TYPE_TEXT);\n  }\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":181573,"func":"void UnloadController::ClearUnloadState(content::WebContents* web_contents,\n                                        bool process_now) {\n  if (is_attempting_to_close_browser_) {\n    RemoveFromSet(&tabs_needing_before_unload_fired_, web_contents);\n    RemoveFromSet(&tabs_needing_unload_fired_, web_contents);\n    if (process_now) {\n      ProcessPendingTabs();\n    } else {\n      MessageLoop::current()->PostTask(\n          FROM_HERE,\n          base::Bind(&UnloadController::ProcessPendingTabs,\n                     weak_factory_.GetWeakPtr()));\n    }\n  }\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":239231,"func":"void TestShelfBackgroundObserver::UpdateShelfBackground(SkColor color) {\n  background_color_ = color;\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":217864,"func":"void BrowserActionButton::SetButtonPushed() {\n  SetState(views::CustomButton::BS_PUSHED);\n  menu_visible_ = true;\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":455689,"func":"TEST_F(QueryPlannerTest, MultikeyElemMatchValue) {\n    \/\/ true means multikey\n    addIndex(BSON(\"a.b\" << 1), true);\n    runQuery(fromjson(\"{'a.b': {$elemMatch: {$gte: 1, $lte: 1}}}}}\"));\n\n    assertNumSolutions(2U);\n    assertSolutionExists(\"{cscan: {dir: 1}}\");\n    assertSolutionExists(\n        \"{fetch: {node: {ixscan: {pattern: {'a.b': 1}, bounds: \"\n        \"{'a.b': [[1, 1, true, true]]}}}}}\");\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":190046,"func":"void WebLocalFrameImpl::MixedContentFound(\n    const WebURL& main_resource_url,\n    const WebURL& mixed_content_url,\n    WebURLRequest::RequestContext request_context,\n    bool was_allowed,\n    bool had_redirect,\n    const WebSourceLocation& source_location) {\n  DCHECK(GetFrame());\n  std::unique_ptr<SourceLocation> source;\n  if (!source_location.url.IsNull()) {\n    source =\n        SourceLocation::Create(source_location.url, source_location.line_number,\n                               source_location.column_number, nullptr);\n  }\n  MixedContentChecker::MixedContentFound(\n      GetFrame(), main_resource_url, mixed_content_url, request_context,\n      was_allowed, had_redirect, std::move(source));\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":295223,"func":"ex_popup(exarg_T *eap)\n{\n# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)\n    if (gui.in_use)\n\tgui_make_popup(eap->arg, eap->forceit);\n#  ifdef FEAT_TERM_POPUP_MENU\n    else\n#  endif\n# endif\n# ifdef FEAT_TERM_POPUP_MENU\n\tpum_make_popup(eap->arg, eap->forceit);\n# endif\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":45395,"func":"static int __pyx_CyFunction_init(void) {\n    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);\n    if (unlikely(__pyx_CyFunctionType == NULL)) {\n        return -1;\n    }\n    return 0;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":158727,"func":"\t\tvoid commit() {\n\t\t\tcommitted = true;\n\t\t}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":445315,"func":"    Network::ActiveUdpListenerFactory* udpListenerFactory() override {\n      NOT_REACHED_GCOVR_EXCL_LINE;\n    }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":150324,"func":"    virtual ~CoalesceProvider()\n    {\n    }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":77138,"func":"R_API RList *r_bin_get_symbols(RBin *bin) {\n\tRBinObject *o = r_bin_cur_object (bin);\n\treturn o? o->symbols: NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":159556,"func":"int CClient::SendMsg(CMsgPacker *pMsg, int Flags)\n{\n\treturn SendMsgEx(pMsg, Flags, false);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":396090,"func":"DSA_PublicKey::DSA_PublicKey(Source& source)\n{\n    Initialize(source);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":40522,"func":"static void __mark_reg_known(struct bpf_reg_state *reg, u64 imm)\n{\n\t\/* Clear id, off, and union(map_ptr, range) *\/\n\tmemset(((u8 *)reg) + sizeof(reg->type), 0,\n\t       offsetof(struct bpf_reg_state, var_off) - sizeof(reg->type));\n\treg->var_off = tnum_const(imm);\n\treg->smin_value = (s64)imm;\n\treg->smax_value = (s64)imm;\n\treg->umin_value = imm;\n\treg->umax_value = imm;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":19303,"func":"void TSHttpTxnTransformedRespCache ( TSHttpTxn txnp , int on ) {\n sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;\n HttpSM * sm = ( HttpSM * ) txnp ;\n sm -> t_state . api_info . cache_transformed = ( on ? true : false ) ;\n }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":251440,"func":"void SecurityHandler::Wire(UberDispatcher* dispatcher) {\n  frontend_.reset(new Security::Frontend(dispatcher->channel()));\n  Security::Dispatcher::wire(dispatcher, this);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":44638,"func":"GF_Err dimC_dump(GF_Box *a, FILE * trace)\n{\n\tGF_DIMSSceneConfigBox *p = (GF_DIMSSceneConfigBox *)a;\n\tgf_isom_box_dump_start(a, \"DIMSSceneConfigBox\", trace);\n\tfprintf(trace, \"profile=\\\"%d\\\" level=\\\"%d\\\" pathComponents=\\\"%d\\\" useFullRequestHosts=\\\"%d\\\" streamType=\\\"%d\\\" containsRedundant=\\\"%d\\\" textEncoding=\\\"%s\\\" contentEncoding=\\\"%s\\\" >\\n\",\n\t        p->profile, p->level, p->pathComponents, p->fullRequestHost, p->streamType, p->containsRedundant, p->textEncoding, p->contentEncoding);\n\tgf_isom_box_dump_done(\"DIMSSceneConfigBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":181547,"func":"void RenderViewImpl::showContextMenu(\n    WebFrame* frame, const WebContextMenuData& data) {\n  content::ContextMenuParams params(data);\n\n  if (frame)\n    params.frame_id = frame->identifier();\n\n  if (params.src_url.spec().size() > content::kMaxURLChars)\n    params.src_url = GURL();\n  context_menu_node_ = data.node;\n  Send(new ViewHostMsg_ContextMenu(routing_id_, params));\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":212738,"func":"Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, float textZoomFactor)\n{\n    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);\n    return ewk_frame_text_zoom_set(smartData->main_frame, textZoomFactor);\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":522979,"func":"void LEX::stmt_install_plugin(const LEX_CSTRING &soname)\n{\n  sql_command= SQLCOM_INSTALL_PLUGIN;\n  comment= null_clex_str;\n  ident= soname;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":157458,"func":"int load_uimage(const char *filename, hwaddr *ep, hwaddr *loadaddr,\n                int *is_linux,\n                uint64_t (*translate_fn)(void *, uint64_t),\n                void *translate_opaque)\n{\n    return load_uboot_image(filename, ep, loadaddr, is_linux, IH_TYPE_KERNEL,\n                            translate_fn, translate_opaque, NULL);\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":45979,"func":"int LuaSettings::l_write(lua_State* L)\n{\n\tNO_MAP_LOCK_REQUIRED;\n\tLuaSettings* o = checkobject(L, 1);\n\n\tif (!o->m_write_allowed) {\n\t\tthrow LuaError(\"Settings: writing \" + o->m_filename +\n\t\t\t\t\" not allowed with mod security on.\");\n\t}\n\n\tbool success = o->m_settings->updateConfigFile(o->m_filename.c_str());\n\tlua_pushboolean(L, success);\n\n\treturn 1;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":399041,"func":"static int\nshouldexp_replacement (s)\n     char *s;\n{\n  register char *p;\n\n  for (p = s; p && *p; p++)\n    {\n      if (*p == '\\\\')\n\tp++;\n      else if (*p == '&')\n\treturn 1;\n    }\n  return 0;","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":220225,"func":"status_t SoftMPEG2::resetPlugin() {\n    mIsInFlush = false;\n    mReceivedEOS = false;\n    memset(mTimeStamps, 0, sizeof(mTimeStamps));\n    memset(mTimeStampsValid, 0, sizeof(mTimeStampsValid));\n\n \/* Initialize both start and end times *\/\n    gettimeofday(&mTimeStart, NULL);\n    gettimeofday(&mTimeEnd, NULL);\n\n return OK;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":257495,"func":"static void unset_active_map ( const vpx_codec_enc_cfg_t * cfg , vpx_codec_ctx_t * codec ) {\n vpx_active_map_t map = {\n 0 , 0 , 0 }\n ;\n map . rows = ( cfg -> g_h + 15 ) \/ 16 ;\n map . cols = ( cfg -> g_w + 15 ) \/ 16 ;\n map . active_map = NULL ;\n if ( vpx_codec_control ( codec , VP8E_SET_ACTIVEMAP , & map ) ) die_codec ( codec , \"Failed to set active map\" ) ;\n }","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":522206,"func":"bool Item_func_get_user_var::set_value(THD *thd,\n                                       sp_rcontext * \/*ctx*\/, Item **it)\n{\n  Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, get_name(), *it);\n  \/*\n    Item_func_set_user_var is not fixed after construction, call\n    fix_fields().\n  *\/\n  return (!suv || suv->fix_fields(thd, it) || suv->check(0) || suv->update());\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":62169,"func":"static void __exit fini(void)\n{\n\treclaim_dma_bufs();\n\n\tunregister_virtio_driver(&virtio_console);\n\tunregister_virtio_driver(&virtio_rproc_serial);\n\n\tclass_destroy(pdrvdata.class);\n\tdebugfs_remove_recursive(pdrvdata.debugfs_dir);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":44160,"func":"ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr,\n\t\t\tchar *buf)\n{\n\tcap_t cap;\n\tssize_t rc;\n\n\trc = tpm_getcap(dev, TPM_CAP_FLAG_PERM, &cap,\n\t\t\t \"attempting to determine the permanent enabled state\");\n\tif (rc)\n\t\treturn 0;\n\n\trc = sprintf(buf, \"%d\\n\", !cap.perm_flags.disable);\n\treturn rc;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":184886,"func":"   ~ResourceClientProxy() {\n   }\n","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":132288,"func":"static void nfnl_err_deliver(struct list_head *err_list, struct sk_buff *skb)\n{\n\tstruct nfnl_err *nfnl_err, *next;\n\n\tlist_for_each_entry_safe(nfnl_err, next, err_list, head) {\n\t\tnetlink_ack(skb, nfnl_err->nlh, nfnl_err->err);\n\t\tnfnl_err_del(nfnl_err);\n\t}\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":360594,"func":"mount_added_callback (GVolumeMonitor *monitor,\n\t\t      GMount *mount,\n\t\t      NautilusApplication *application)\n{\n\tNautilusDirectory *directory;\n\tGFile *root;\n\t\t\n\troot = g_mount_get_root (mount);\n\tdirectory = nautilus_directory_get_existing (root);\n\tg_object_unref (root);\n\tif (directory != NULL) {\n\t\tnautilus_directory_force_reload (directory);\n\t\tnautilus_directory_unref (directory);\n\t}\n\n\tnautilus_autorun (mount, autorun_show_window, application);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":12932,"func":"void AppListControllerDelegate::DoShowAppInfoFlow(\n     Profile* profile,\n     const std::string& extension_id) {\n   DCHECK(CanDoShowAppInfoFlow());\n  ExtensionService* service =\n      extensions::ExtensionSystem::Get(profile)->extension_service();\n  DCHECK(service);\n  const extensions::Extension* extension = service->GetInstalledExtension(\n      extension_id);\n   DCHECK(extension);\n \n   OnShowChildDialog();\n\n  UMA_HISTOGRAM_ENUMERATION(\"Apps.AppInfoDialog.Launches\",\n                            AppInfoLaunchSource::FROM_APP_LIST,\n                            AppInfoLaunchSource::NUM_LAUNCH_SOURCES);\n\n  ShowAppInfoInAppList(\n      GetAppListWindow(),\n      GetAppListBounds(),\n      profile,\n      extension,\n      base::Bind(&AppListControllerDelegate::OnCloseChildDialog,\n                 base::Unretained(this)));\n}\n","target":1,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":304395,"func":"static bool verify_dotgit_hfs(const char *path, size_t len)\n{\n\treturn verify_dotgit_hfs_generic(path, len, \"git\", CONST_STRLEN(\"git\"));\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":509362,"func":"tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){\n\n\tuint32 sample_count=0;\n\tuint16 component_count=0;\n\tuint32 palette_offset=0;\n\tuint32 sample_offset=0;\n\tuint32 i=0;\n\tuint32 j=0;\n\tsample_count=t2p->tiff_width*t2p->tiff_length;\n\tcomponent_count=t2p->tiff_samplesperpixel;\n        if( sample_count * component_count > t2p->tiff_datasize )\n        {\n            TIFFError(TIFF2PDF_MODULE,  \"Error: sample_count * component_count > t2p->tiff_datasize\");\n            t2p->t2p_error = T2P_ERR_ERROR;\n            return 1;\n        }\n\t\n\tfor(i=sample_count;i>0;i--){\n\t\tpalette_offset=buffer[i-1] * component_count;\n\t\tsample_offset= (i-1) * component_count;\n\t\tfor(j=0;j<component_count;j++){\n\t\t\tbuffer[sample_offset+j]=t2p->pdf_palette[palette_offset+j];\n\t\t}\n\t}\n\n\treturn(0);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":502588,"func":"unsigned VvcUnit::extractUEGolombCode()\n{\n    int cnt = 0;\n    for (; m_reader.getBits(1) == 0; cnt++)\n        ;\n    if (cnt > INT_BIT)\n        THROW_BITSTREAM_ERR;\n    return (1 << cnt) - 1 + m_reader.getBits(cnt);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":62441,"func":"void static InvalidChainFound(CBlockIndex* pindexNew)\n{\n    if (pindexNew->bnChainWork > bnBestInvalidWork)\n    {\n        bnBestInvalidWork = pindexNew->bnChainWork;\n        CTxDB().WriteBestInvalidWork(bnBestInvalidWork);\n        MainFrameRepaint();\n    }\n    printf(\"InvalidChainFound: invalid block=%s  height=%d  work=%s\\n\", pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, pindexNew->bnChainWork.ToString().c_str());\n    printf(\"InvalidChainFound:  current best=%s  height=%d  work=%s\\n\", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());\n    if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6)\n        printf(\"InvalidChainFound: WARNING: Displayed transactions may not be correct!  You may need to upgrade, or other nodes may need to upgrade.\\n\");\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":171907,"func":" void FileDescriptorSet::CommitAll() {\n   for (std::vector<base::FileDescriptor>::iterator\n        i = descriptors_.begin(); i != descriptors_.end(); ++i) {\n    if (i->auto_close)\n      HANDLE_EINTR(close(i->fd));\n  }\n  descriptors_.clear();\n  consumed_descriptor_highwater_ = 0;\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":474293,"func":"int LUKS2_reencrypt_lock_by_dm_uuid(struct crypt_device *cd, const char *dm_uuid,\n\tstruct crypt_lock_handle **reencrypt_lock)\n{\n\tint r;\n\tchar hdr_uuid[37];\n\tconst char *uuid = crypt_get_uuid(cd);\n\n\tif (!dm_uuid)\n\t\treturn -EINVAL;\n\n\tif (!uuid) {\n\t\tr = snprintf(hdr_uuid, sizeof(hdr_uuid), \"%.8s-%.4s-%.4s-%.4s-%.12s\",\n\t\t\t dm_uuid + 6, dm_uuid + 14, dm_uuid + 18, dm_uuid + 22, dm_uuid + 26);\n\t\tif (r < 0 || (size_t)r != (sizeof(hdr_uuid) - 1))\n\t\t\treturn -EINVAL;\n\t} else if (crypt_uuid_cmp(dm_uuid, uuid))\n\t\treturn -EINVAL;\n\n\treturn reencrypt_lock_internal(cd, uuid, reencrypt_lock);\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":311937,"func":"status_t CameraClient::connect(const sp<ICameraClient>& client) {\n int callingPid = getCallingPid();\n    LOG1(\"connect E (pid %d)\", callingPid);\n Mutex::Autolock lock(mLock);\n\n if (mClientPid != 0 && checkPid() != NO_ERROR) {\n        ALOGW(\"Tried to connect to a locked camera (old pid %d, new pid %d)\",\n                mClientPid, callingPid);\n return EBUSY;\n }\n\n if (mRemoteCallback != 0 &&\n (client->asBinder() == mRemoteCallback->asBinder())) {\n        LOG1(\"Connect to the same client\");\n return NO_ERROR;\n }\n\n    mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;\n    mClientPid = callingPid;\n    mRemoteCallback = client;\n\n    LOG1(\"connect X (pid %d)\", callingPid);\n return NO_ERROR;\n}\n","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":119572,"func":"static void * u_zalloc(void * q, unsigned n, unsigned m) {\n  (void)q;\n  return o_malloc((size_t) n * m);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":18693,"func":"static int dissect_h245_RequestChannelCloseRejectCause ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_RequestChannelCloseRejectCause , RequestChannelCloseRejectCause_choice , NULL ) ;\n return offset ;\n }","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":31475,"func":"\tModResult OnUserRegister(LocalUser *user)\n\t{\n\t\tSaslAuthenticator *sasl_ = authExt.get(user);\n\t\tif (sasl_)\n\t\t{\n\t\t\tsasl_->Abort();\n\t\t\tauthExt.unset(user);\n\t\t}\n\n\t\treturn MOD_RES_PASSTHRU;\n\t}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":505138,"func":"static int srp_Verify_N_and_g(const BIGNUM *N, const BIGNUM *g)\n\t{\n\tBN_CTX *bn_ctx = BN_CTX_new();\n\tBIGNUM *p = BN_new();\n\tBIGNUM *r = BN_new();\n\tint ret =\n\t\tg != NULL && N != NULL && bn_ctx != NULL && BN_is_odd(N) &&\n\t\tBN_is_prime_ex(N, SRP_NUMBER_ITERATIONS_FOR_PRIME, bn_ctx, NULL) &&\n\t\tp != NULL && BN_rshift1(p, N) &&\n\n\t\t\/* p = (N-1)\/2 *\/\n\t\tBN_is_prime_ex(p, SRP_NUMBER_ITERATIONS_FOR_PRIME, bn_ctx, NULL) &&\n\t\tr != NULL &&\n\n\t\t\/* verify g^((N-1)\/2) == -1 (mod N) *\/\n\t\tBN_mod_exp(r, g, p, N, bn_ctx) &&\n\t\tBN_add_word(r, 1) &&\n\t\tBN_cmp(r, N) == 0;\n\n\tif(r)\n\t\tBN_free(r);\n\tif(p)\n\t\tBN_free(p);\n\tif(bn_ctx)\n\t\tBN_CTX_free(bn_ctx);\n\treturn ret;\n\t}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":90006,"func":"static inline bool d_is_autodir(const struct dentry *dentry)\n{\n\treturn __d_entry_type(dentry) == DCACHE_AUTODIR_TYPE;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":426563,"func":"ZEND_INI_MH(OnUpdateEncode)\n{\n\tif (new_value && ZSTR_LEN(new_value)) {\n\t\tconst zend_encoding **return_list;\n\t\tsize_t return_size;\n\t\tif (FAILURE == zend_multibyte_parse_encoding_list(ZSTR_VAL(new_value), ZSTR_LEN(new_value),\n\t&return_list, &return_size, 0)) {\n\t\t\tphp_error_docref(NULL, E_WARNING, \"Illegal encoding ignored: '%s'\", ZSTR_VAL(new_value));\n\t\t\treturn FAILURE;\n\t\t}\n\t\tefree(return_list);\n\t}\n\treturn OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":289560,"func":"static int dissect_mac_fdd_pch ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) {\n proto_tree * pch_tree = NULL ;\n proto_item * channel_type ;\n col_set_str ( pinfo -> cinfo , COL_PROTOCOL , \"MAC\" ) ;\n col_set_str ( pinfo -> cinfo , COL_INFO , \"PCCH\" ) ;\n if ( tree ) {\n proto_item * ti ;\n ti = proto_tree_add_item ( tree , proto_umts_mac , tvb , 0 , - 1 , ENC_NA ) ;\n pch_tree = proto_item_add_subtree ( ti , ett_mac_pch ) ;\n proto_item_append_text ( ti , \" (PCCH)\" ) ;\n channel_type = proto_tree_add_uint ( pch_tree , hf_mac_channel , tvb , 0 , 0 , MAC_PCCH ) ;\n PROTO_ITEM_SET_GENERATED ( channel_type ) ;\n }\n call_dissector_with_data ( rlc_pcch_handle , tvb , pinfo , tree , data ) ;\n return tvb_captured_length ( tvb ) ;\n }","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":493738,"func":"int fuse_fs_releasedir(struct fuse_fs *fs, const char *path,\n                       struct fuse_file_info *fi)\n{\n    fuse_get_context()->private_data = fs->user_data;\n    if (fs->op.releasedir)\n        return fs->op.releasedir(path, fi);\n    else\n        return 0;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":249508,"func":"void RenderViewImpl::OnSetEditableSelectionOffsets(int start, int end) {\n  base::AutoReset<bool> handling_select_range(&handling_select_range_, true);\n  DCHECK(!handling_ime_event_);\n  handling_ime_event_ = true;\n  webview()->setEditableSelectionOffsets(start, end);\n  handling_ime_event_ = false;\n  UpdateTextInputState(DO_NOT_SHOW_IME);\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":163999,"func":"void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock)\n{\n    if (isTableCell()) {\n        setMarginBefore(0);\n        setMarginAfter(0);\n        return;\n    }\n\n    int cw = containingBlockLogicalWidthForContent();\n\n    RenderStyle* containingBlockStyle = containingBlock->style();\n    containingBlock->setMarginBeforeForChild(this, style()->marginBeforeUsing(containingBlockStyle).calcMinValue(cw));\n    containingBlock->setMarginAfterForChild(this, style()->marginAfterUsing(containingBlockStyle).calcMinValue(cw));\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":388090,"func":"gdm_session_handle_client_cancel (GdmDBusUserVerifier    *user_verifier_interface,\n                                  GDBusMethodInvocation  *invocation,\n                                  GdmSession             *self)\n{\n        gdm_dbus_user_verifier_complete_cancel (user_verifier_interface,\n                                                invocation);\n        gdm_session_cancel (self);\n        return TRUE;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":71790,"func":"frame_diff(u16 left, u16 right)\n{\n\treturn ((unsigned) (left - right)) % (USB_MAX_FRAME_NUMBER + 1);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":249155,"func":"void PasswordAutofillManager::ClearPreviewedForm() {\n  password_manager_driver_->ClearPreviewedForm();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":195106,"func":"BackgroundLoaderOffliner* BackgroundLoaderOffliner::FromWebContents(\n    content::WebContents* contents) {\n  Offliner* offliner = OfflinerUserData::OfflinerFromWebContents(contents);\n  if (offliner)\n    return static_cast<BackgroundLoaderOffliner*>(offliner);\n  return nullptr;\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":77130,"func":"static uint8_t pfkey_proto_from_xfrm(uint8_t proto)\n{\n\treturn proto ? proto : IPSEC_PROTO_ANY;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":352230,"func":"static void test_strncspn(void) {\n        size_t len;\n\n        len = c_shquote_strncspn(NULL, 0, \"a\");\n        c_assert(len == 0);\n\n        len = c_shquote_strncspn(\"a\", 1, \"\");\n        c_assert(len == 1);\n\n        len = c_shquote_strncspn(\"ab\", 2, \"ac\");\n        c_assert(len == 0);\n\n        len = c_shquote_strncspn(\"ab\", 2, \"bc\");\n        c_assert(len == 1);\n\n        len = c_shquote_strncspn(\"ab\", 2, \"cd\");\n        c_assert(len == 2);\n}","target":1,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":383996,"func":"gnutls_x509_crt_get_verify_algorithm(gnutls_x509_crt_t crt,\n\t\t\t\t     const gnutls_datum_t * signature,\n\t\t\t\t     gnutls_digest_algorithm_t * hash)\n{\n\tgnutls_pk_params_st issuer_params;\n\tint ret;\n\n\tif (crt == NULL) {\n\t\tgnutls_assert();\n\t\treturn GNUTLS_E_INVALID_REQUEST;\n\t}\n\n\tret = _gnutls_x509_crt_get_mpis(crt, &issuer_params);\n\tif (ret < 0) {\n\t\tgnutls_assert();\n\t\treturn ret;\n\t}\n\n\tret = _gnutls_x509_verify_algorithm(hash,\n\t\t\t\t\t    signature,\n\t\t\t\t\t    gnutls_x509_crt_get_pk_algorithm\n\t\t\t\t\t    (crt, NULL), &issuer_params);\n\n\t\/* release allocated mpis *\/\n\tgnutls_pk_params_release(&issuer_params);\n\n\treturn ret;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":235755,"func":"        CreateFileResult()\n            : m_failed(false)\n             , m_code(0)\n         {\n         }\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":351919,"func":"    if (sz + idx > maxSz) {\n        return WS_BUFFER_E;\n    }","target":1,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":128489,"func":"  static StackAllocator& instance() {\n    \/\/ Avoid using true dynamic memory allocation to be portable to bare metal.\n    static char inst_memory[sizeof(StackAllocator)];\n    static StackAllocator* inst = new (inst_memory) StackAllocator;\n    return *inst;\n  }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":186392,"func":"EmbeddedWorkerContextClient::~EmbeddedWorkerContextClient() {\n  DCHECK(g_worker_client_tls.Pointer()->Get() != NULL);\n  g_worker_client_tls.Pointer()->Set(NULL);\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":402340,"func":"static void xhci_xfer_unmap(XHCITransfer *xfer)\n{\n    usb_packet_unmap(&xfer->packet, &xfer->sgl);\n    qemu_sglist_destroy(&xfer->sgl);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":165149,"func":"dtls1_copy_record(SSL *s, pitem *item)\n    {\n    DTLS1_RECORD_DATA *rdata;\n\n    rdata = (DTLS1_RECORD_DATA *)item->data;\n    \n    if (s->s3->rbuf.buf != NULL)\n        OPENSSL_free(s->s3->rbuf.buf);\n    \n    s->packet = rdata->packet;\n    s->packet_length = rdata->packet_length;\n    memcpy(&(s->s3->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER));\n    memcpy(&(s->s3->rrec), &(rdata->rrec), sizeof(SSL3_RECORD));\n\t\n\t\/* Set proper sequence number for mac calculation *\/\n\tmemcpy(&(s->s3->read_sequence[2]), &(rdata->packet[5]), 6);\n    \n    return(1);\n    }\n","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":234935,"func":"void ContainerNode::attach(const AttachContext& context)\n{\n    attachChildren(context);\n    clearChildNeedsStyleRecalc();\n    Node::attach(context);\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":253087,"func":"BackingStore* RenderWidgetHostViewGuest::AllocBackingStore(\n    const gfx::Size& size) {\n  NOTIMPLEMENTED();\n  return NULL;\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":474529,"func":"libxlDomainDefNamespaceFormatXML(virBuffer *buf,\n                                 void *nsdata)\n{\n    libxlDomainXmlNsDef *cmd = nsdata;\n    size_t i;\n\n    if (!cmd->num_args)\n        return 0;\n\n    virBufferAddLit(buf, \"<xen:commandline>\\n\");\n    virBufferAdjustIndent(buf, 2);\n\n    for (i = 0; i < cmd->num_args; i++)\n        virBufferEscapeString(buf, \"<xen:arg value='%s'\/>\\n\",\n                              cmd->args[i]);\n\n    virBufferAdjustIndent(buf, -2);\n    virBufferAddLit(buf, \"<\/xen:commandline>\\n\");\n\n    return 0;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":373817,"func":"    TEST(BSONValidateFast, Simple2 ) {\n        char buf[64];\n        for ( int i=1; i<=JSTypeMax; i++ ) {\n            BSONObjBuilder b;\n            sprintf( buf, \"foo%d\", i );\n            b.appendMinForType( buf, i );\n            sprintf( buf, \"bar%d\", i );\n            b.appendMaxForType( buf, i );\n            BSONObj x = b.obj();\n            ASSERT( validateBSON( x.objdata(), x.objsize() ).isOK() );\n        }\n    }","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":18962,"func":"static gsize label_fill ( char * label_str , gsize pos , const header_field_info * hfinfo , const char * text ) {\n gsize name_pos ;\n name_pos = pos = label_concat ( label_str , pos , hfinfo -> name ) ;\n pos = label_concat ( label_str , pos , \": \" ) ;\n pos = label_concat ( label_str , pos , text ? text : \"(null)\" ) ;\n if ( pos >= ITEM_LABEL_LENGTH ) {\n label_mark_truncated ( label_str , name_pos ) ;\n }\n return pos ;\n }","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":82415,"func":"int dcb_setapp(struct net_device *dev, struct dcb_app *new)\n{\n\tstruct dcb_app_type *itr;\n\tstruct dcb_app_type event;\n\tint err = 0;\n\n\tevent.ifindex = dev->ifindex;\n\tmemcpy(&event.app, new, sizeof(event.app));\n\tif (dev->dcbnl_ops->getdcbx)\n\t\tevent.dcbx = dev->dcbnl_ops->getdcbx(dev);\n\n\tspin_lock(&dcb_lock);\n\t\/* Search for existing match and replace *\/\n\tif ((itr = dcb_app_lookup(new, dev->ifindex, 0))) {\n\t\tif (new->priority)\n\t\t\titr->app.priority = new->priority;\n\t\telse {\n\t\t\tlist_del(&itr->list);\n\t\t\tkfree(itr);\n\t\t}\n\t\tgoto out;\n\t}\n\t\/* App type does not exist add new application type *\/\n\tif (new->priority)\n\t\terr = dcb_app_add(new, dev->ifindex);\nout:\n\tspin_unlock(&dcb_lock);\n\tif (!err)\n\t\tcall_dcbevent_notifiers(DCB_APP_EVENT, &event);\n\treturn err;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":219312,"func":"void setPictographFontFamilyWrapper(WebSettings* settings,\n                               const string16& font,\n                               UScriptCode script) {\n  settings->setPictographFontFamily(font, script);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":492956,"func":"static int ssl_parse_inner_plaintext( unsigned char const *content,\n                                          size_t *content_size,\n                                          uint8_t *rec_type )\n{\n    size_t remaining = *content_size;\n\n    \/* Determine length of padding by skipping zeroes from the back. *\/\n    do\n    {\n        if( remaining == 0 )\n            return( -1 );\n        remaining--;\n    } while( content[ remaining ] == 0 );\n\n    *content_size = remaining;\n    *rec_type = content[ remaining ];\n\n    return( 0 );\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":26576,"func":"IN_PROC_BROWSER_TEST_F ( ExtensionPreferenceApiTest , PersistentIncognito ) {\n PrefService * prefs = profile_ -> GetPrefs ( ) ;\n prefs -> SetBoolean ( prefs : : kBlockThirdPartyCookies , false ) ;\n EXPECT_TRUE ( RunExtensionTestIncognito ( \"preference\/persistent_incognito\" ) ) << message_ ;\n EXPECT_FALSE ( profile_ -> HasOffTheRecordProfile ( ) ) ;\n PrefService * otr_prefs = profile_ -> GetOffTheRecordProfile ( ) -> GetPrefs ( ) ;\n const PrefService : : Preference * pref = otr_prefs -> FindPreference ( prefs : : kBlockThirdPartyCookies ) ;\n ASSERT_TRUE ( pref ) ;\n EXPECT_TRUE ( pref -> IsExtensionControlled ( ) ) ;\n EXPECT_TRUE ( otr_prefs -> GetBoolean ( prefs : : kBlockThirdPartyCookies ) ) ;\n pref = prefs -> FindPreference ( prefs : : kBlockThirdPartyCookies ) ;\n ASSERT_TRUE ( pref ) ;\n EXPECT_FALSE ( pref -> IsExtensionControlled ( ) ) ;\n EXPECT_FALSE ( prefs -> GetBoolean ( prefs : : kBlockThirdPartyCookies ) ) ;\n }","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":358198,"func":"static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)\n{\n\tstruct iattr attr;\n\tint error;\n\n\tdfprintk(VFS, \"NFS: mkdir(%s\/%ld), %s\\n\",\n\t\t\tdir->i_sb->s_id, dir->i_ino, dentry->d_name.name);\n\n\tattr.ia_valid = ATTR_MODE;\n\tattr.ia_mode = mode | S_IFDIR;\n\n\tlock_kernel();\n\tnfs_begin_data_update(dir);\n\terror = NFS_PROTO(dir)->mkdir(dir, dentry, &attr);\n\tnfs_end_data_update(dir);\n\tif (error != 0)\n\t\tgoto out_err;\n\tnfs_renew_times(dentry);\n\tnfs_set_verifier(dentry, nfs_save_change_attribute(dir));\n\tunlock_kernel();\n\treturn 0;\nout_err:\n\td_drop(dentry);\n\tunlock_kernel();\n\treturn error;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":256357,"func":"static void serial_update_parameters(SerialState *s)\n{\n     int speed, parity, data_bits, stop_bits, frame_size;\n     QEMUSerialSetParams ssp;\n \n    if (s->divider == 0)\n         return;\n \n     \/* Start bit. *\/\n     frame_size = 1;\n        \/* Parity bit. *\/\n        frame_size++;\n        if (s->lcr & 0x10)\n            parity = 'E';\n        else\n            parity = 'O';\n    } else {\n            parity = 'N';\n    }\n","target":1,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":168107,"func":"void LocalFrameClientImpl::DispatchDidReceiveResponse(\n    const ResourceResponse& response) {\n  if (web_frame_->Client()) {\n    WrappedResourceResponse webresp(response);\n    web_frame_->Client()->DidReceiveResponse(webresp);\n  }\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":7231,"func":"int net_get(int s, void *arg, int *len)\n{\n\tstruct net_hdr nh;\n\tint plen;\n\n\tif (net_read_exact(s, &nh, sizeof(nh)) == -1)\n        {\n\t\treturn -1;\n        }\n\n\tplen = ntohl(nh.nh_len);\n\tif (!(plen <= *len))\n\t\tprintf(\"PLEN %d type %d len %d\\n\",\n\t\t\tplen, nh.nh_type, *len);\n\tassert(plen <= *len); \/* XXX *\/\n\n\t*len = plen;\n\tif ((*len) && (net_read_exact(s, arg, *len) == -1))\n        {\n            return -1;\n        }\n\n\treturn nh.nh_type;\n}","target":1,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":469846,"func":"icmp_match(const struct sk_buff *skb,\n\t   const struct net_device *in,\n\t   const struct net_device *out,\n\t   const struct xt_match *match,\n\t   const void *matchinfo,\n\t   int offset,\n\t   unsigned int protoff,\n\t   int *hotdrop)\n{\n\tstruct icmphdr _icmph, *ic;\n\tconst struct ipt_icmp *icmpinfo = matchinfo;\n\n\t\/* Must not be a fragment. *\/\n\tif (offset)\n\t\treturn 0;\n\n\tic = skb_header_pointer(skb, protoff, sizeof(_icmph), &_icmph);\n\tif (ic == NULL) {\n\t\t\/* We've been asked to examine this packet, and we\n\t\t * can't.  Hence, no choice but to drop.\n\t\t *\/\n\t\tduprintf(\"Dropping evil ICMP tinygram.\\n\");\n\t\t*hotdrop = 1;\n\t\treturn 0;\n\t}\n\n\treturn icmp_type_code_match(icmpinfo->type,\n\t\t\t\t    icmpinfo->code[0],\n\t\t\t\t    icmpinfo->code[1],\n\t\t\t\t    ic->type, ic->code,\n\t\t\t\t    !!(icmpinfo->invflags&IPT_ICMP_INV));\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":192557,"func":"Eina_Bool ewk_view_back(Evas_Object* ewkView)\n{\n    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);\n    return ewk_frame_back(smartData->main_frame);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":173545,"func":"void LayoutBlockFlow::checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight)\n{\n    if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {\n        LayoutUnit columnHeight;\n        if (hasDefiniteLogicalHeight() || isLayoutView()) {\n            LogicalExtentComputedValues computedValues;\n            computeLogicalHeight(LayoutUnit(), logicalTop(), computedValues);\n            columnHeight = computedValues.m_extent - borderAndPaddingLogicalHeight() - scrollbarLogicalHeight();\n        }\n        pageLogicalHeightChanged = columnHeight != flowThread->columnHeightAvailable();\n        flowThread->setColumnHeightAvailable(std::max(columnHeight, LayoutUnit()));\n    } else if (isLayoutFlowThread()) {\n        LayoutFlowThread* flowThread = toLayoutFlowThread(this);\n\n        pageLogicalHeight = flowThread->isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit();\n\n        pageLogicalHeightChanged = flowThread->pageLogicalSizeChanged();\n    }\n}\n","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":70219,"func":"static int pragmaVtabEof(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  return (pCsr->pPragma==0);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":57269,"func":"void fmtutil_get_bmp_compression_name(u32 code, char *s, size_t s_len,\n\tint is_os2v2)\n{\n\tconst char *name1 = \"?\";\n\tswitch(code) {\n\tcase 0: name1 = \"BI_RGB, uncompressed\"; break;\n\tcase 1: name1 = \"BI_RLE8\"; break;\n\tcase 2: name1 = \"BI_RLE4\"; break;\n\tcase 3:\n\t\tif(is_os2v2)\n\t\t\tname1 = \"Huffman 1D\";\n\t\telse\n\t\t\tname1 = \"BI_BITFIELDS, uncompressed\";\n\t\tbreak;\n\tcase 4:\n\t\tif(is_os2v2)\n\t\t\tname1 = \"RLE24\";\n\t\telse\n\t\t\tname1 = \"BI_JPEG\";\n\t\tbreak;\n\tcase 5: name1 = \"BI_PNG\"; break;\n\t}\n\tde_strlcpy(s, name1, s_len);\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":190638,"func":"msg_fifo_pop (struct msg_fifo *fifo)\n{\n  struct msg *msg;\n\n  msg = fifo->head;\n  if (msg)\n    {\n      fifo->head = msg->next;\n\n      if (fifo->head == NULL)\n\tfifo->tail = NULL;\n\n      fifo->count--;\n    }\n  return msg;\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":299528,"func":"AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream, \n                                       AP4_LargeSize   bytes_available,\n                                       AP4_AtomParent& atoms)\n{\n    AP4_Result result;\n    do {\n        AP4_Atom* atom = NULL;\n        result = CreateAtomFromStream(stream, bytes_available, atom);\n        if (AP4_SUCCEEDED(result) && atom != NULL) {\n            atoms.AddChild(atom);\n        }\n    } while (AP4_SUCCEEDED(result));\n    \n    return AP4_SUCCESS;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":608,"func":"const xmlChar * xsltEvalStaticAttrValueTemplate ( xsltStylesheetPtr style , xmlNodePtr inst , const xmlChar * name , const xmlChar * ns , int * found ) {\n const xmlChar * ret ;\n xmlChar * expr ;\n if ( ( style == NULL ) || ( inst == NULL ) || ( name == NULL ) ) return ( NULL ) ;\n expr = xsltGetNsProp ( inst , name , ns ) ;\n if ( expr == NULL ) {\n * found = 0 ;\n return ( NULL ) ;\n }\n * found = 1 ;\n ret = xmlStrchr ( expr , '{\n' ) ;\n if ( ret != NULL ) {\n xmlFree ( expr ) ;\n return ( NULL ) ;\n }\n ret = xmlDictLookup ( style -> dict , expr , - 1 ) ;\n xmlFree ( expr ) ;\n return ( ret ) ;\n }","target":1,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":247494,"func":"static void vnc_set_share_mode(VncState *vs, VncShareMode mode)\n{\n#ifdef _VNC_DEBUG\n    static const char *mn[] = {\n        [0]                           = \"undefined\",\n        [VNC_SHARE_MODE_CONNECTING]   = \"connecting\",\n        [VNC_SHARE_MODE_SHARED]       = \"shared\",\n        [VNC_SHARE_MODE_EXCLUSIVE]    = \"exclusive\",\n        [VNC_SHARE_MODE_DISCONNECTED] = \"disconnected\",\n    };\n    fprintf(stderr, \"%s\/%d: %s -> %s\\n\", __func__,\n            vs->csock, mn[vs->share_mode], mn[mode]);\n#endif\n\n    if (vs->share_mode == VNC_SHARE_MODE_EXCLUSIVE) {\n        vs->vd->num_exclusive--;\n    }\n    vs->share_mode = mode;\n    if (vs->share_mode == VNC_SHARE_MODE_EXCLUSIVE) {\n        vs->vd->num_exclusive++;\n    }\n}\n","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":147854,"func":"dataiterator_match(Dataiterator *di, Datamatcher *ma)\n{\n  const char *str;\n  if (!(str = repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags)))\n    return 0;\n  return ma ? datamatcher_match(ma, str) : 1;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":209586,"func":"void DevToolsUIBindings::SendPortForwardingStatus(const base::Value& status) {\n  CallClientFunction(\"DevToolsAPI.devicesPortForwardingStatusChanged\", &status,\n                     nullptr, nullptr);\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":489191,"func":"\nvoid qjs_module_init_gpaccore(JSContext *ctx)\n{\n\tJSModuleDef *m;\n\tm = JS_NewCModule(ctx, \"gpaccore\", js_gpaccore_init);\n\tif (!m) return;\n\n\tJS_AddModuleExport(ctx, m, \"Sys\");\n\tJS_AddModuleExport(ctx, m, \"Bitstream\");\n\tJS_AddModuleExport(ctx, m, \"SHA1\");\n\tJS_AddModuleExport(ctx, m, \"File\");\n\tJS_AddModuleExport(ctx, m, \"FileIO\");\n\tJS_AddModuleExport(ctx, m, \"AudioMixer\");\n\treturn;","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":41842,"func":"Error Box_clap::parse(BitstreamRange& range)\n{\n  \/\/parse_full_box_header(range);\n\n  m_clean_aperture_width.numerator   = range.read32();\n  m_clean_aperture_width.denominator = range.read32();\n  m_clean_aperture_height.numerator   = range.read32();\n  m_clean_aperture_height.denominator = range.read32();\n  m_horizontal_offset.numerator   = range.read32();\n  m_horizontal_offset.denominator = range.read32();\n  m_vertical_offset.numerator   = range.read32();\n  m_vertical_offset.denominator = range.read32();\n  if (!m_clean_aperture_width.is_valid() || !m_clean_aperture_height.is_valid() ||\n      !m_horizontal_offset.is_valid() || !m_vertical_offset.is_valid()) {\n    return Error(heif_error_Invalid_input,\n                 heif_suberror_Invalid_fractional_number);\n  }\n\n  return range.get_error();\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":339548,"func":"static void ogg_free(AVFormatContext *s)\n\n{\n\n    int i;\n\n\n\n    for (i = 0; i < s->nb_streams; i++) {\n\n        AVStream *st = s->streams[i];\n\n        OGGStreamContext *oggstream = st->priv_data;\n\n\n\n        if (st->codecpar->codec_id == AV_CODEC_ID_FLAC ||\n\n            st->codecpar->codec_id == AV_CODEC_ID_SPEEX ||\n\n            st->codecpar->codec_id == AV_CODEC_ID_OPUS ||\n\n            st->codecpar->codec_id == AV_CODEC_ID_VP8) {\n\n            av_freep(&oggstream->header[0]);\n\n        }\n\n        av_freep(&oggstream->header[1]);\n\n        av_freep(&st->priv_data);\n\n    }\n\n}","target":1,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":478203,"func":"    CImg<t>& move_to(CImg<t>& img) {\n      img.assign(*this);\n      assign();\n      return img;\n    }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":306014,"func":"static inline int sctp_v6_addr_match_len(union sctp_addr *s1,\n\t\t\t\t\t union sctp_addr *s2)\n{\n\treturn ipv6_addr_diff(&s1->v6.sin6_addr, &s2->v6.sin6_addr);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":118976,"func":"SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,\n\t\tint, addrlen)\n{\n\treturn __sys_connect(fd, uservaddr, addrlen);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":77226,"func":"SCTP_STATIC void sctp_shutdown(struct sock *sk, int how)\n{\n\tstruct net *net = sock_net(sk);\n\tstruct sctp_endpoint *ep;\n\tstruct sctp_association *asoc;\n\n\tif (!sctp_style(sk, TCP))\n\t\treturn;\n\n\tif (how & SEND_SHUTDOWN) {\n\t\tep = sctp_sk(sk)->ep;\n\t\tif (!list_empty(&ep->asocs)) {\n\t\t\tasoc = list_entry(ep->asocs.next,\n\t\t\t\t\t  struct sctp_association, asocs);\n\t\t\tsctp_primitive_SHUTDOWN(net, asoc, NULL);\n\t\t}\n\t}\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":89640,"func":"point_add(PG_FUNCTION_ARGS)\n{\n\tPoint\t   *p1 = PG_GETARG_POINT_P(0);\n\tPoint\t   *p2 = PG_GETARG_POINT_P(1);\n\tPoint\t   *result;\n\n\tresult = (Point *) palloc(sizeof(Point));\n\n\tresult->x = (p1->x + p2->x);\n\tresult->y = (p1->y + p2->y);\n\n\tPG_RETURN_POINT_P(result);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":334013,"func":"static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)\n\n{\n\n#if defined(TARGET_I386)\n\n    cpu_synchronize_state(s->c_cpu);\n\n    s->c_cpu->eip = pc;\n\n#elif defined (TARGET_PPC)\n\n    s->c_cpu->nip = pc;\n\n#elif defined (TARGET_SPARC)\n\n    s->c_cpu->pc = pc;\n\n    s->c_cpu->npc = pc + 4;\n\n#elif defined (TARGET_ARM)\n\n    s->c_cpu->regs[15] = pc;\n\n#elif defined (TARGET_SH4)\n\n    s->c_cpu->pc = pc;\n\n#elif defined (TARGET_MIPS)\n\n    s->c_cpu->active_tc.PC = pc;\n\n#elif defined (TARGET_MICROBLAZE)\n\n    s->c_cpu->sregs[SR_PC] = pc;\n\n#elif defined (TARGET_CRIS)\n\n    s->c_cpu->pc = pc;\n\n#elif defined (TARGET_ALPHA)\n\n    s->c_cpu->pc = pc;\n\n#elif defined (TARGET_S390X)\n\n    cpu_synchronize_state(s->c_cpu);\n\n    s->c_cpu->psw.addr = pc;\n\n#endif\n\n}\n","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":123552,"func":"pw_error(char *name, int err, int eval)\n{\n\tif (err) {\n\t\tif (name)\n\t\t\twarn(\"%s: \", name);\n\t\telse\n\t\t\twarn(NULL);\n\t}\n\twarnx(_(\"%s unchanged\"), orig_file);\n\tunlink(tmp_file);\n\tulckpwdf();\n\texit(eval);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":29442,"func":"static inline void uprv_arrayCopy ( const int8_t * src , int8_t * dst , int32_t count ) {\n uprv_memcpy ( dst , src , ( size_t ) count * sizeof ( * src ) ) ;\n }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":410788,"func":"static void cmd_window_hide(const char *data)\n{\n\tWINDOW_REC *window;\n\n\tif (mainwindows->next == NULL) {\n\t\tprintformat_window(active_win, MSGLEVEL_CLIENTNOTICE,\n\t\t\t\t   TXT_CANT_HIDE_LAST);\n\t\treturn;\n\t}\n\n\tif (*data == '\\0')\n\t\twindow = active_win;\n\telse if (is_numeric(data, 0)) {\n\t\twindow = window_find_refnum(atoi(data));\n\t\tif (window == NULL) {\n\t\t\tprintformat_window(active_win, MSGLEVEL_CLIENTERROR,\n\t\t\t\t\t   TXT_REFNUM_NOT_FOUND, data);\n\t\t}\n\t} else {\n\t\twindow = window_find_item(active_win->active_server, data);\n\t}\n\n\tif (window == NULL || !is_window_visible(window))\n\t\treturn;\n\n\tif (WINDOW_MAIN(window)->sticky_windows) {\n\t\tif (!settings_get_bool(\"autounstick_windows\")) {\n\t\t\tprintformat_window(active_win, MSGLEVEL_CLIENTERROR,\n\t\t\t\t\t   TXT_CANT_HIDE_STICKY_WINDOWS);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tmainwindow_destroy(WINDOW_MAIN(window));\n\n\tif (active_mainwin == NULL) {\n\t\tactive_mainwin = WINDOW_MAIN(active_win);\n\t\twindow_set_active(active_mainwin->active);\n\t}\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":424530,"func":"distance_add(OnigDistance d1, OnigDistance d2)\n{\n  if (d1 == ONIG_INFINITE_DISTANCE || d2 == ONIG_INFINITE_DISTANCE)\n    return ONIG_INFINITE_DISTANCE;\n  else {\n    if (d1 <= ONIG_INFINITE_DISTANCE - d2) return d1 + d2;\n    else return ONIG_INFINITE_DISTANCE;\n  }\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":242056,"func":"void HTMLTextAreaElement::setSuggestedValue(const String& value)\n{\n    m_suggestedValue = value;\n    setInnerTextValue(m_suggestedValue);\n    updatePlaceholderVisibility(false);\n    setNeedsStyleRecalc();\n    setFormControlValueMatchesRenderer(true);\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":309205,"func":"bool LayoutBlockFlow::containsFloat(LayoutBox* layoutBox) const\n{\n    return m_floatingObjects && m_floatingObjects->set().contains<FloatingObjectHashTranslator>(layoutBox);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":244968,"func":"void Document::setBgColor(const AtomicString& value) {\n  if (!IsFrameSet())\n    SetBodyAttribute(kBgcolorAttr, value);\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":173219,"func":"static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) \/* {{{ *\/\n{\n\tzval                 *object   = (zval*)((zend_user_iterator *)iter)->it.data;\n\tspl_heap_it          *iterator = (spl_heap_it *)iter;\n\tspl_ptr_heap_element elem;\n\n\tif (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {\n\t\tzend_throw_exception(spl_ce_RuntimeException, \"Heap is corrupted, heap properties are no longer ensured.\", 0 TSRMLS_CC);\n\t\treturn;\n\t}\n\n\telem = spl_ptr_heap_delete_top(iterator->object->heap, object TSRMLS_CC);\n\n\tif (elem != NULL) {\n\t\tzval_ptr_dtor((zval **)&elem);\n\t}\n\n\tzend_user_it_invalidate_current(iter TSRMLS_CC);\n}\n\/* }}} *\/\n","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":32410,"func":"static bool list_key_handler(int ch)\n{\n\tstruct le *le;\n\n\t(void) ch;\n\n\toutput(\"Conversation list\");\n\tif (conv_data.archived)\n\t\toutput(\" with archive\");\n\toutput(\" (%u entries)\", list_count(&conv_data.convl));\n\toutput(\":\\n\");\n\tLIST_FOREACH(&conv_data.convl, le) {\n\t\tstruct engine_conv *conv = le->data;\n\n\t\tif (conv->archived && !conv_data.archived)\n\t\t\tcontinue;\n\n\t\tprint_conv_list_entry(conv);\n\t}\n\toutput(\"EOL\\n\");\n\n\treturn true;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":377915,"func":"int tcf_hash_search(struct tc_action *a, u32 index)\n{\n\tstruct tcf_hashinfo *hinfo = a->ops->hinfo;\n\tstruct tcf_common *p = tcf_hash_lookup(index, hinfo);\n\n\tif (p) {\n\t\ta->priv = p;\n\t\treturn 1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":209104,"func":"PHP_FUNCTION(stream_socket_get_name)\n{\n\tphp_stream *stream;\n\tzval *zstream;\n\tzend_bool want_peer;\n\tchar *name = NULL;\n\tint name_len;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rb\", &zstream, &want_peer) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tphp_stream_from_zval(stream, &zstream);\n\n\tif (0 != php_stream_xport_get_name(stream, want_peer,\n\t\t\t\t&name,\n\t\t\t\t&name_len,\n\t\t\t\tNULL, NULL\n\t\t\t\tTSRMLS_CC)) {\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_STRINGL(name, name_len, 0);\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":296035,"func":"  bool IsSupported(const NodeDef* node) const override {\n    return IsAnySparseSegmentReduction(*node);\n  }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":110567,"func":"string dotConcat(const std::string& a, const std::string &b)\n{\n  if(a.empty() || b.empty())\n    return a+b;\n  else \n    return a+\".\"+b;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":316213,"func":"sp<MetaData> MyOggExtractor::getFormat() const {\n return mMeta;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":213788,"func":"static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, long *result TSRMLS_DC) { \/* {{{ *\/\n\t\tzval *result_p = NULL;\n\n\t\tzend_call_method_with_2_params(&object, heap_object->std.ce, &heap_object->fptr_cmp, \"compare\", &result_p, a, b);\n\n\t\tif (EG(exception)) {\n\t\t\treturn FAILURE;\n\t\t}\n\n\t\tconvert_to_long(result_p);\n\t\t*result = Z_LVAL_P(result_p);\n\n\t\tzval_ptr_dtor(&result_p);\n\n\t\treturn SUCCESS;\n}\n\/* }}} *\/\n","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":263228,"func":"static GF_Err DumpLSRActivate(GF_SceneDumper *sdump, GF_Command *com)\n{\n\tchar szID[1024];\n\tchar *lsrns = sd_get_lsr_namespace(com->in_scene);\n\tDUMP_IND(sdump);\n\tif (com->tag==GF_SG_LSR_ACTIVATE) {\n\t\tgf_fprintf(sdump->trace, \"<%sActivate ref=\\\"%s\\\" \/>\\n\", lsrns, lsr_format_node_id(com->node, com->RouteID, szID));\n\t} else {\n\t\tgf_fprintf(sdump->trace, \"<%sDeactivate ref=\\\"%s\\\" \/>\\n\", lsrns, lsr_format_node_id(com->node, com->RouteID, szID));\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":339815,"func":"void cpu_exec_init(CPUState *env)\n\n{\n\n    CPUState **penv;\n\n    int cpu_index;\n\n\n\n#if defined(CONFIG_USER_ONLY)\n\n    cpu_list_lock();\n\n#endif\n\n    env->next_cpu = NULL;\n\n    penv = &first_cpu;\n\n    cpu_index = 0;\n\n    while (*penv != NULL) {\n\n        penv = &(*penv)->next_cpu;\n\n        cpu_index++;\n\n    }\n\n    env->cpu_index = cpu_index;\n\n    env->numa_node = 0;\n\n    TAILQ_INIT(&env->breakpoints);\n\n    TAILQ_INIT(&env->watchpoints);\n\n    *penv = env;\n\n#if defined(CONFIG_USER_ONLY)\n\n    cpu_list_unlock();\n\n#endif\n\n#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)\n\n    vmstate_register(cpu_index, &vmstate_cpu_common, env);\n\n    register_savevm(\"cpu\", cpu_index, CPU_SAVE_VERSION,\n\n                    cpu_save, cpu_load, env);\n\n#endif\n\n}\n","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":76686,"func":"hexval(char c)\n{\n  if (c >= 'A' && c <= 'F')\n    return c - 'A' + 10;\n  else if (c >= 'a' && c <= 'f')\n    return c - 'a' + 10;\n  else if (c >= '0' && c <= '9')\n    return c - '0';\n  else\n    return 0;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":166104,"func":"void BrowserActionsContainer::BubbleBrowserWindowClosing(\n    BrowserBubble* bubble) {\n  HidePopup();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":234772,"func":"static void activityLoggingSetterForAllWorldsLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n    TestObjectPythonV8Internal::activityLoggingSetterForAllWorldsLongAttributeAttributeGetter(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":103299,"func":"rb_iter_head_event(struct ring_buffer_iter *iter)\n{\n\treturn __rb_page_index(iter->head_page, iter->head);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":262055,"func":"  const envoy::config::listener::v3::Listener& listener() const { return listener_; }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":496237,"func":"field_deprecation_reason(agooErr err, gqlDoc doc, gqlCobj obj, gqlField field, gqlSel sel, gqlValue result, int depth) {\n    const char\t*reason = deprecation_reason(((gqlField)obj->ptr)->dir);\n    const char\t*key = sel->name;\n    gqlValue\trv;\n\n    if (NULL != sel->alias) {\n\tkey = sel->alias;\n    }\n    if (NULL == reason) {\n\trv = gql_null_create(err);\n    } else {\n\trv = gql_string_create(err, reason, -1);\n    }\n    return gql_object_set(err, result, key, rv);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":360374,"func":"link_info_stop (NautilusDirectory *directory)\n{\n\tNautilusFile *file;\n\n\tif (directory->details->link_info_read_state != NULL) {\n\t\tfile = directory->details->link_info_read_state->file;\n\n\t\tif (file != NULL) {\n\t\t\tg_assert (NAUTILUS_IS_FILE (file));\n\t\t\tg_assert (file->details->directory == directory);\n\t\t\tif (is_needy (file,\n\t\t\t\t      lacks_link_info,\n\t\t\t\t      REQUEST_LINK_INFO)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t\/* The link info is not wanted, so stop it. *\/\n\t\tlink_info_cancel (directory);\n\t}\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":115636,"func":"static int invlpg_interception(struct vcpu_svm *svm)\n{\n\tif (!static_cpu_has(X86_FEATURE_DECODEASSISTS))\n\t\treturn emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE;\n\n\tkvm_mmu_invlpg(&svm->vcpu, svm->vmcb->control.exit_info_1);\n\tskip_emulated_instruction(&svm->vcpu);\n\treturn 1;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":403247,"func":"krb5_ticket_get_authorization_data_type(krb5_context context,\n\t\t\t\t\tkrb5_ticket *ticket,\n\t\t\t\t\tint type,\n\t\t\t\t\tkrb5_data *data)\n{\n    AuthorizationData *ad;\n    krb5_error_code ret;\n    krb5_boolean found = FALSE;\n\n    krb5_data_zero(data);\n\n    ad = ticket->ticket.authorization_data;\n    if (ticket->ticket.authorization_data == NULL) {\n\tkrb5_set_error_message(context, ENOENT,\n\t\t\t       N_(\"Ticket have not authorization data\", \"\"));\n\treturn ENOENT; \/* XXX *\/\n    }\n\n    ret = find_type_in_ad(context, type, data, &found, TRUE,\n\t\t\t  &ticket->ticket.key, ad, 0);\n    if (ret)\n\treturn ret;\n    if (!found) {\n\tkrb5_set_error_message(context, ENOENT,\n\t\t\t       N_(\"Ticket have not \"\n\t\t\t\t  \"authorization data of type %d\", \"\"),\n\t\t\t       type);\n\treturn ENOENT; \/* XXX *\/\n    }\n    return 0;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":466363,"func":"TEST_F(HttpConnectionManagerImplTest, DateHeaderPresent) {\n  setup(false, \"\");\n  setUpEncoderAndDecoder(false, false);\n  sendRequestHeadersAndData();\n  const std::string expected_date{\"Tue, 15 Nov 1994 08:12:31 GMT\"};\n  const auto* modified_headers =\n      sendResponseHeaders(ResponseHeaderMapPtr{new TestResponseHeaderMapImpl{\n          {\":status\", \"200\"}, {\"server\", \"foo\"}, {\"date\", expected_date.c_str()}}});\n  ASSERT_TRUE(modified_headers);\n  ASSERT_TRUE(modified_headers->Date());\n  EXPECT_EQ(expected_date, modified_headers->getDateValue());\n  doRemoteClose();\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":79659,"func":"static int http_stream_write_single(\n\tgit_smart_subtransport_stream *stream,\n\tconst char *buffer,\n\tsize_t len)\n{\n\thttp_stream *s = (http_stream *)stream;\n\thttp_subtransport *t = OWNING_SUBTRANSPORT(s);\n\tgit_buf request = GIT_BUF_INIT;\n\n\tassert(t->connected);\n\n\tif (s->sent_request) {\n\t\tgiterr_set(GITERR_NET, \"Subtransport configured for only one write\");\n\t\treturn -1;\n\t}\n\n\tclear_parser_state(t);\n\n\tif (gen_request(&request, s, len) < 0)\n\t\treturn -1;\n\n\tif (git_stream_write(t->io, request.ptr, request.size, 0) < 0)\n\t\tgoto on_error;\n\n\tif (len && git_stream_write(t->io, buffer, len, 0) < 0)\n\t\tgoto on_error;\n\n\tgit_buf_free(&request);\n\ts->sent_request = 1;\n\n\treturn 0;\n\non_error:\n\tgit_buf_free(&request);\n\treturn -1;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":270061,"func":"void ZipFile::Builder::addEntry (InputStream* stream, int compression, const String& path, Time time)\r\n{\r\n    jassert (stream != nullptr); \/\/ must not be null!\r\n    jassert (path.isNotEmpty());\r\n    items.add (new Item ({}, stream, compression, path, time));\r\n}\r","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":490207,"func":"static int piv_is_object_present(sc_card_t *card, u8 *ptr)\n{\n\tpiv_private_data_t * priv = PIV_DATA(card);\n\tint r = 0;\n\tint enumtag;\n\n\tenumtag = piv_find_obj_by_containerid(card, ptr);\n\tif (enumtag >= 0 && priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_NOT_PRESENT)\n\t\tr = 1;\n\n\tLOG_FUNC_RETURN(card->ctx, r);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":50094,"func":"  static size_t NumElements(const TensorProto& proto) {\n    return proto.variant_val().size();\n  }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":363468,"func":"gdm_session_settings_new (void)\n{\n        GdmSessionSettings *settings;\n\n        settings = g_object_new (GDM_TYPE_SESSION_SETTINGS,\n                                 NULL);\n\n        return settings;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":246058,"func":"bool DownloadRequestLimiter::TabDownloadState::is_showing_prompt() const {\n  return factory_.HasWeakPtrs();\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":358063,"func":"static int create_watch(struct inotify_device *dev, struct inode *inode,\n\t\t\tu32 mask)\n{\n\tstruct inotify_user_watch *watch;\n\tint ret;\n\n\tif (atomic_read(&dev->user->inotify_watches) >=\n\t\t\tinotify_max_user_watches)\n\t\treturn -ENOSPC;\n\n\twatch = kmem_cache_alloc(watch_cachep, GFP_KERNEL);\n\tif (unlikely(!watch))\n\t\treturn -ENOMEM;\n\n\t\/* save a reference to device and bump the count to make it official *\/\n\tget_inotify_dev(dev);\n\twatch->dev = dev;\n\n\tatomic_inc(&dev->user->inotify_watches);\n\n\tinotify_init_watch(&watch->wdata);\n\tret = inotify_add_watch(dev->ih, &watch->wdata, inode, mask);\n\tif (ret < 0)\n\t\tfree_inotify_user_watch(&watch->wdata);\n\n\treturn ret;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":491872,"func":"static int mxf_set_audio_pts(MXFContext *mxf, AVCodecContext *codec,\n                             AVPacket *pkt)\n{\n    MXFTrack *track = mxf->fc->streams[pkt->stream_index]->priv_data;\n    int64_t bits_per_sample = codec->bits_per_coded_sample;\n\n    if (!bits_per_sample)\n        bits_per_sample = av_get_bits_per_sample(codec->codec_id);\n\n    pkt->pts = track->sample_count;\n\n    if (   codec->channels <= 0\n        || bits_per_sample <= 0\n        || codec->channels * (int64_t)bits_per_sample < 8)\n        return AVERROR(EINVAL);\n    track->sample_count += pkt->size \/ (codec->channels * (int64_t)bits_per_sample \/ 8);\n    return 0;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":360863,"func":"window_map_event_cb (GSWindow  *window,\n                     GdkEvent  *event,\n                     GSManager *manager)\n{\n        gs_debug (\"Handling window map_event event\");\n\n        manager_maybe_grab_window (manager, window);\n\n        manager_maybe_start_job_for_window (manager, window);\n\n        return FALSE;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":483348,"func":"static void cgroup_apply_control_disable(struct cgroup *cgrp)\n{\n\tstruct cgroup *dsct;\n\tstruct cgroup_subsys_state *d_css;\n\tstruct cgroup_subsys *ss;\n\tint ssid;\n\n\tcgroup_for_each_live_descendant_post(dsct, d_css, cgrp) {\n\t\tfor_each_subsys(ss, ssid) {\n\t\t\tstruct cgroup_subsys_state *css = cgroup_css(dsct, ss);\n\n\t\t\tif (!css)\n\t\t\t\tcontinue;\n\n\t\t\tWARN_ON_ONCE(percpu_ref_is_dying(&css->refcnt));\n\n\t\t\tif (css->parent &&\n\t\t\t    !(cgroup_ss_mask(dsct) & (1 << ss->id))) {\n\t\t\t\tkill_css(css);\n\t\t\t} else if (!css_visible(css)) {\n\t\t\t\tcss_clear_dir(css);\n\t\t\t\tif (ss->css_reset)\n\t\t\t\t\tss->css_reset(css);\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":412917,"func":"PHP_FUNCTION(iconv_get_encoding)\n{\n\tchar *type = \"all\";\n\tint type_len = sizeof(\"all\")-1;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"|s\", &type, &type_len) == FAILURE)\n\t\treturn;\n\n\tif (!strcasecmp(\"all\", type)) {\n\t\tarray_init(return_value);\n\t\tadd_assoc_string(return_value, \"input_encoding\",    get_input_encoding(TSRMLS_C), 1);\n\t\tadd_assoc_string(return_value, \"output_encoding\",   get_output_encoding(TSRMLS_C), 1);\n\t\tadd_assoc_string(return_value, \"internal_encoding\", get_internal_encoding(TSRMLS_C), 1);\n\t} else if (!strcasecmp(\"input_encoding\", type)) {\n\t\tRETVAL_STRING(get_input_encoding(TSRMLS_C), 1);\n\t} else if (!strcasecmp(\"output_encoding\", type)) {\n\t\tRETVAL_STRING(get_output_encoding(TSRMLS_C), 1);\n\t} else if (!strcasecmp(\"internal_encoding\", type)) {\n\t\tRETVAL_STRING(get_internal_encoding(TSRMLS_C), 1);\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":389250,"func":"set_wildcard_reuse(\n\tu_short\tfamily,\n\tint\ton\n\t)\n{\n\tstruct interface *any;\n\tSOCKET fd = INVALID_SOCKET;\n\n\tany = ANY_INTERFACE_BYFAM(family);\n\tif (any != NULL)\n\t\tfd = any->fd;\n\n\tif (fd != INVALID_SOCKET) {\n\t\tif (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,\n\t\t\t       (char *)&on, sizeof(on)))\n\t\t\tmsyslog(LOG_ERR,\n\t\t\t\t\"set_wildcard_reuse: setsockopt(SO_REUSEADDR, %s) failed: %m\",\n\t\t\t\ton ? \"on\" : \"off\");\n\n\t\tDPRINTF(4, (\"set SO_REUSEADDR to %s on %s\\n\",\n\t\t\t    on ? \"on\" : \"off\",\n\t\t\t    stoa(&any->sin)));\n\t}\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":24748,"func":"static int mem_read ( jas_stream_obj_t * obj , char * buf , int cnt ) {\n int n ;\n assert ( cnt >= 0 ) ;\n assert ( buf ) ;\n jas_stream_memobj_t * m = ( jas_stream_memobj_t * ) obj ;\n n = m -> len_ - m -> pos_ ;\n cnt = JAS_MIN ( n , cnt ) ;\n memcpy ( buf , & m -> buf_ [ m -> pos_ ] , cnt ) ;\n m -> pos_ += cnt ;\n return cnt ;\n }","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":440201,"func":"onig_regset_search(OnigRegSet* set, const UChar* str, const UChar* end,\n                   const UChar* start, const UChar* range,\n                   OnigRegSetLead lead, OnigOptionType option, int* rmatch_pos)\n{\n  int r;\n  int i;\n  OnigMatchParam* mp;\n  OnigMatchParam** mps;\n\n  mps = (OnigMatchParam** )xmalloc((sizeof(OnigMatchParam*) + sizeof(OnigMatchParam)) * set->n);\n  CHECK_NULL_RETURN_MEMERR(mps);\n\n  mp = (OnigMatchParam* )(mps + set->n);\n\n  for (i = 0; i < set->n; i++) {\n    onig_initialize_match_param(mp + i);\n    mps[i] = mp + i;\n  }\n\n  r = onig_regset_search_with_param(set, str, end, start, range, lead, option, mps,\n                                    rmatch_pos);\n  for (i = 0; i < set->n; i++)\n    onig_free_match_param_content(mp + i);\n\n  xfree(mps);\n\n  return r;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":342999,"func":"static int acpi_pcihp_get_bsel(PCIBus *bus)\n\n{\n\n    QObject *o = object_property_get_qobject(OBJECT(bus),\n\n                                             ACPI_PCIHP_PROP_BSEL, NULL);\n\n    int64_t bsel = -1;\n\n    if (o) {\n\n        bsel = qint_get_int(qobject_to_qint(o));\n\n    }\n\n    if (bsel < 0) {\n\n        return -1;\n\n    }\n\n    return bsel;\n\n}\n","target":1,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":163182,"func":"static void treatNullAsNullStringStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    v8SetReturnValueString(info, imp->treatNullAsNullStringStringAttribute(), info.GetIsolate());\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":378118,"func":"int apparmor_bprm_secureexec(struct linux_binprm *bprm)\n{\n\tint ret = cap_bprm_secureexec(bprm);\n\n\t\/* the decision to use secure exec is computed in set_creds\n\t * and stored in bprm->unsafe.\n\t *\/\n\tif (!ret && (bprm->unsafe & AA_SECURE_X_NEEDED))\n\t\tret = 1;\n\n\treturn ret;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":182562,"func":"static void nfs_set_fh(struct inode *inode, struct nfs_fh *fh)\n{\n\tstruct nfs_inode *ninode = nfsi(inode);\n\n\tninode->fh = *fh;\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":510263,"func":"my_decimal *Item_null::val_decimal(my_decimal *decimal_value)\n{\n  return 0;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":257214,"func":"TSReturnCode sdk_sanity_check_mime_hdr_handle ( TSMLoc field ) {\n if ( field == TS_NULL_MLOC ) {\n return TS_ERROR ;\n }\n MIMEFieldSDKHandle * field_handle = ( MIMEFieldSDKHandle * ) field ;\n if ( field_handle -> m_type != HDR_HEAP_OBJ_MIME_HEADER ) {\n return TS_ERROR ;\n }\n return TS_SUCCESS ;\n }","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":504694,"func":"kssl_krb5_kt_default(krb5_context con,\n                    krb5_keytab * kt)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_kt_default )\n\t\treturn(p_krb5_kt_default(con,kt));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":441988,"func":"static void create_power_zone_common_attributes(\n\t\t\t\t\tstruct powercap_zone *power_zone)\n{\n\tint count = 0;\n\n\tpower_zone->zone_dev_attrs[count++] = &dev_attr_name.attr;\n\tif (power_zone->ops->get_max_energy_range_uj)\n\t\tpower_zone->zone_dev_attrs[count++] =\n\t\t\t\t\t&dev_attr_max_energy_range_uj.attr;\n\tif (power_zone->ops->get_energy_uj) {\n\t\tif (power_zone->ops->reset_energy_uj)\n\t\t\tdev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUSR;\n\t\telse\n\t\t\tdev_attr_energy_uj.attr.mode = S_IRUSR;\n\t\tpower_zone->zone_dev_attrs[count++] =\n\t\t\t\t\t&dev_attr_energy_uj.attr;\n\t}\n\tif (power_zone->ops->get_power_uw)\n\t\tpower_zone->zone_dev_attrs[count++] =\n\t\t\t\t\t&dev_attr_power_uw.attr;\n\tif (power_zone->ops->get_max_power_range_uw)\n\t\tpower_zone->zone_dev_attrs[count++] =\n\t\t\t\t\t&dev_attr_max_power_range_uw.attr;\n\tpower_zone->zone_dev_attrs[count] = NULL;\n\tpower_zone->zone_attr_count = count;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":218305,"func":"void OnDestroy(GtkDialog* dialog, PageInfoWindowGtk* page_info) {\n  delete page_info;\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":18915,"func":"static char * * subsystems_from_mount_options ( const char * mount_options , char * * kernel_list ) {\n char * token , * str , * saveptr = NULL ;\n char * * result = NULL ;\n size_t result_capacity = 0 ;\n size_t result_count = 0 ;\n int saved_errno ;\n int r ;\n str = alloca ( strlen ( mount_options ) + 1 ) ;\n strcpy ( str , mount_options ) ;\n for ( ;\n ( token = strtok_r ( str , \",\" , & saveptr ) ) ;\n str = NULL ) {\n if ( ! strncmp ( token , \"name=\" , 5 ) || lxc_string_in_array ( token , ( const char * * ) kernel_list ) ) {\n r = lxc_grow_array ( ( void * * * ) & result , & result_capacity , result_count + 1 , 12 ) ;\n if ( r < 0 ) goto out_free ;\n result [ result_count + 1 ] = NULL ;\n result [ result_count ] = strdup ( token ) ;\n if ( ! result [ result_count ] ) goto out_free ;\n result_count ++ ;\n }\n }\n return result ;\n out_free : saved_errno = errno ;\n lxc_free_array ( ( void * * ) result , free ) ;\n errno = saved_errno ;\n return NULL ;\n }","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":439304,"func":"static u8 dccp_feat_sp_list_ok(u8 feat_num, u8 const *sp_list, u8 sp_len)\n{\n\tif (sp_list == NULL || sp_len < 1)\n\t\treturn 0;\n\twhile (sp_len--)\n\t\tif (!dccp_feat_is_valid_sp_val(feat_num, *sp_list++))\n\t\t\treturn 0;\n\treturn 1;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":339643,"func":"static void mov_update_dts_shift(MOVStreamContext *sc, int duration)\n\n{\n\n    if (duration < 0) {\n\n\n\n\n\n        sc->dts_shift = FFMAX(sc->dts_shift, -duration);\n\n","target":1,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":176772,"func":"static void RunAutofocusTask(ExecutionContext* context) {\n  if (!context)\n    return;\n\n  Document* document = To<Document>(context);\n  if (Element* element = document->AutofocusElement()) {\n    document->SetAutofocusElement(nullptr);\n    element->focus();\n  }\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":348426,"func":"static struct db_arg_chain_tree *_db_tree_get(struct db_arg_chain_tree *tree)\n{\n\tstruct db_arg_chain_tree *iter;\n\n\tif (tree->nxt_t) {\n\t\titer = tree->nxt_t;\n\t\twhile (iter->lvl_prv != NULL)\n\t\t\titer = iter->lvl_prv;\n\t\tdo {\n\t\t\t_db_tree_get(iter);\n\t\t\titer = iter->lvl_nxt;\n\t\t} while (iter != NULL);\n\t}\n\n\tif (tree->nxt_f) {\n\t\titer = tree->nxt_f;\n\t\twhile (iter->lvl_prv != NULL)\n\t\t\titer = iter->lvl_prv;\n\t\tdo {\n\t\t\t_db_tree_get(iter);\n\t\t\titer = iter->lvl_nxt;\n\t\t} while (iter != NULL);\n\t}\n\n\treturn _db_node_get(tree);\n}","target":1,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":97737,"func":"static int r_cmd_java_print_field_summary (RBinJavaObj *obj, ut16 idx) {\n\tint res = r_bin_java_print_field_idx_summary (obj, idx);\n\tif (res == false) {\n\t\teprintf (\"Error: Field or Method @ index (%d) not found in the RBinJavaObj.\\n\", idx);\n\t\tres = true;\n\t}\n\treturn res;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":235500,"func":"  void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) {\n    TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(\n        profile(),\n        base::BindRepeating(&TemplateURLServiceFactory::BuildInstanceFor));\n    TemplateURLService* template_url_service =\n        TemplateURLServiceFactory::GetForProfile(browser()->profile());\n    search_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);\n\n    TemplateURLData data;\n    data.SetShortName(base::ASCIIToUTF16(\"foo.com\"));\n    data.SetURL(\"http:\/\/foo.com\/url?bar={searchTerms}\");\n    data.new_tab_url = new_tab_page_url.spec();\n    TemplateURL* template_url =\n        template_url_service->Add(std::make_unique<TemplateURL>(data));\n    template_url_service->SetUserSelectedDefaultSearchProvider(template_url);\n  }\n","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":137696,"func":"void ConvolutionOpBuilder::FillCoreMLWeights() {\n  if (conv_type_ == ConvolutionType::kDepthwiseConv) {\n    layer_->mutable_convolution()->set_kernelchannels(1);\n    layer_->mutable_convolution()->set_outputchannels(weights_->dims->data[3]);\n  } else {\n    layer_->mutable_convolution()->set_kernelchannels(weights_->dims->data[3]);\n    layer_->mutable_convolution()->set_outputchannels(weights_->dims->data[0]);\n  }\n  layer_->mutable_convolution()->add_kernelsize(weights_->dims->data[1]);\n  layer_->mutable_convolution()->add_kernelsize(weights_->dims->data[2]);\n\n  TransposeKernelWeights();  \/\/ Should be called after CoreML shape is set.\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":174860,"func":"InspectorOverlay::InspectorOverlay(Page* page, InspectorClient* client)\n    : m_page(page)\n    , m_client(client)\n    , m_inspectModeEnabled(false)\n    , m_drawViewSize(false)\n     , m_drawViewSizeWithGrid(false)\n     , m_timer(this, &InspectorOverlay::onTimer)\n     , m_overlayHost(InspectorOverlayHost::create())\n {\n }\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":268816,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  const TfLiteEvalTensor* input =\n      tflite::micro::GetEvalInput(context, node, kInputTensor);\n  TfLiteEvalTensor* output =\n      tflite::micro::GetEvalOutput(context, node, kOutputTensor);\n\n  reference_ops::Ceil(tflite::micro::GetTensorShape(input),\n                      tflite::micro::GetTensorData<float>(input),\n                      tflite::micro::GetTensorShape(output),\n                      tflite::micro::GetTensorData<float>(output));\n\n  return kTfLiteOk;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":152152,"func":"const Model* GetSimpleStatefulModel() {\n  static Model* model = nullptr;\n  if (!model) {\n    model = const_cast<Model*>(BuildSimpleStatefulModel());\n  }\n  return model;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":30776,"func":"TSReturnCode TSCacheKeyHostNameSet ( TSCacheKey key , const char * hostname , int host_len ) {\n sdk_assert ( sdk_sanity_check_cachekey ( key ) == TS_SUCCESS ) ;\n sdk_assert ( sdk_sanity_check_null_ptr ( ( void * ) hostname ) == TS_SUCCESS ) ;\n sdk_assert ( host_len > 0 ) ;\n if ( ( ( CacheInfo * ) key ) -> magic != CACHE_INFO_MAGIC_ALIVE ) {\n return TS_ERROR ;\n }\n CacheInfo * i = ( CacheInfo * ) key ;\n i -> hostname = ( char * ) ats_malloc ( host_len ) ;\n memcpy ( i -> hostname , hostname , host_len ) ;\n i -> len = host_len ;\n return TS_SUCCESS ;\n }","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":37667,"func":"static void kvm_vcpu_ioctl_x86_get_xcrs(struct kvm_vcpu *vcpu,\n\t\t\t\t\tstruct kvm_xcrs *guest_xcrs)\n{\n\tif (!cpu_has_xsave) {\n\t\tguest_xcrs->nr_xcrs = 0;\n\t\treturn;\n\t}\n\n\tguest_xcrs->nr_xcrs = 1;\n\tguest_xcrs->flags = 0;\n\tguest_xcrs->xcrs[0].xcr = XCR_XFEATURE_ENABLED_MASK;\n\tguest_xcrs->xcrs[0].value = vcpu->arch.xcr0;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":274855,"func":"  osd_stat_t get_osd_stat() {\n    Mutex::Locker l(stat_lock);\n    ++seq;\n    osd_stat.up_from = up_epoch;\n    osd_stat.seq = ((uint64_t)osd_stat.up_from << 32) + seq;\n    return osd_stat;\n  }","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":459733,"func":"dissect_kafka_offset_delete_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,\n                                        kafka_api_version_t api_version)\n{\n    proto_item *subti;\n    proto_tree *subtree;\n\n    offset = dissect_kafka_string(tree, hf_kafka_consumer_group, tvb, pinfo, offset, 0, NULL, NULL);\n\n    subtree = proto_tree_add_subtree(tree, tvb, offset, -1,\n                                     ett_kafka_topics,\n                                     &subti, \"Topics\");\n\n    offset = dissect_kafka_array(subtree, tvb, pinfo, offset, 0, api_version,\n                                 &dissect_kafka_offset_delete_request_topic, NULL);\n\n    proto_item_set_end(subti, tvb, offset);\n\n    return offset;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":434823,"func":"pdf_filter_Do_image(fz_context *ctx, pdf_processor *proc, const char *name, fz_image *image)\n{\n\tpdf_filter_processor *p = (pdf_filter_processor*)proc;\n\tfilter_flush(ctx, p, FLUSH_ALL);\n\tif (p->chain->op_Do_image)\n\t\tp->chain->op_Do_image(ctx, p->chain, name, image);\n\tcopy_resource(ctx, p, PDF_NAME(XObject), name);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":161554,"func":"generic_arguments_respect_constraints (VerifyContext *ctx, MonoGenericContainer *gc, MonoGenericContext *context, MonoGenericInst *ginst)\n{\n\tint i;\n\tfor (i = 0; i < ginst->type_argc; ++i) {\n\t\tMonoType *type = ginst->type_argv [i];\n\t\tMonoGenericParam *target = mono_generic_container_get_param (gc, i);\n\t\tMonoGenericParam *candidate;\n\t\tMonoClass *candidate_class;\n\n\t\tif (!mono_type_is_generic_argument (type))\n\t\t\tcontinue;\n\n\t\tif (!is_valid_type_in_context (ctx, type))\n\t\t\treturn FALSE;\n\n\t\tcandidate = verifier_get_generic_param_from_type (ctx, type);\n\t\tcandidate_class = mono_class_from_mono_type (type);\n\n\t\tif (!mono_generic_param_is_constraint_compatible (ctx, target, candidate, candidate_class, context))\n\t\t\treturn FALSE;\n\t}\n\treturn TRUE;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":165512,"func":"ProCamera2Client::ProCamera2Client(const sp<CameraService>& cameraService,\n const sp<IProCameraCallbacks>& remoteCallback,\n const String16& clientPackageName,\n int cameraId,\n int cameraFacing,\n int clientPid,\n uid_t clientUid,\n int servicePid) :\n Camera2ClientBase(cameraService, remoteCallback, clientPackageName,\n                cameraId, cameraFacing, clientPid, clientUid, servicePid)\n{\n    ATRACE_CALL();\n    ALOGI(\"ProCamera %d: Opened\", cameraId);\n\n    mExclusiveLock = false;\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":418854,"func":"poppler_document_set_modification_date (PopplerDocument *document,\n                                        time_t modification_date)\n{\n  g_return_if_fail (POPPLER_IS_DOCUMENT (document));\n\n  GooString *str = modification_date == (time_t)-1 ? nullptr : timeToDateString (&modification_date);\n  document->doc->setDocInfoModDate (str);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":35171,"func":"DeepScanLineInputFile::lastScanLineInChunk(int y) const\n{\n    int minY = firstScanLineInChunk(y);\n    return min(minY+_data->linesInBuffer-1,_data->maxY);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":401044,"func":"jbig2_sd_glyph(Jbig2SymbolDict *dict, unsigned int id)\n{\n    if (dict == NULL)\n        return NULL;\n    return dict->glyphs[id];\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":400316,"func":"scheme_leading_string (enum url_scheme scheme)\n{\n  return supported_schemes[scheme].leading_string;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":166935,"func":"static void perform_renew(void)\n{\n\tbb_info_msg(\"Performing a DHCP renew\");\n\tswitch (state) {\n\tcase BOUND:\n\t\tchange_listen_mode(LISTEN_KERNEL);\n\tcase RENEWING:\n\tcase REBINDING:\n\t\tstate = RENEW_REQUESTED;\n\t\tbreak;\n\tcase RENEW_REQUESTED: \/* impatient are we? fine, square 1 *\/\n\t\tudhcp_run_script(NULL, \"deconfig\");\n\tcase REQUESTING:\n\tcase RELEASED:\n\t\tchange_listen_mode(LISTEN_RAW);\n\t\tstate = INIT_SELECTING;\n\t\tbreak;\n\tcase INIT_SELECTING:\n\t\tbreak;\n\t}\n}\n","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":165499,"func":"RenderFrameHostImpl::GetNavigationClientFromInterfaceProvider() {\n  mojom::NavigationClientAssociatedPtr navigation_client_ptr;\n  GetRemoteAssociatedInterfaces()->GetInterface(&navigation_client_ptr);\n  return navigation_client_ptr;\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":238714,"func":"  bool Allowed(const Extension* extension, const GURL& url) {\n    return Allowed(extension, url, -1);\n  }\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":300917,"func":"  void requestInit() override {\n    current_language = language;\n    current_internal_encoding = internal_encoding;\n    current_http_output_encoding = http_output_encoding;\n    current_filter_illegal_mode = filter_illegal_mode;\n    current_filter_illegal_substchar = filter_illegal_substchar;\n    if (!encoding_translation) {\n      illegalchars = 0;\n    }\n\n    mbfl_encoding **entry = nullptr;\n    int n = 0;\n    if (current_detect_order_list) {\n      return;\n    }\n\n    if (detect_order_list && detect_order_list_size > 0) {\n      n = detect_order_list_size;\n      entry = (mbfl_encoding **)malloc(n * sizeof(mbfl_encoding*));\n      std::copy(detect_order_list,\n                detect_order_list + (n * sizeof(mbfl_encoding*)), entry);\n    } else {\n      mbfl_no_encoding *src = default_detect_order_list;\n      n = default_detect_order_list_size;\n      entry = (mbfl_encoding **)malloc(n * sizeof(mbfl_encoding*));\n      for (int i = 0; i < n; i++) {\n        entry[i] = (mbfl_encoding*) mbfl_no2encoding(src[i]);\n      }\n    }\n\n    current_detect_order_list = entry;\n    current_detect_order_list_size = n;\n  }","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":390973,"func":"static int ntop_host_reset_periodic_stats(lua_State* vm) {\n  NetworkInterfaceView *ntop_interface = getCurrentInterface(vm);\n  char *host_ip;\n  u_int16_t vlan_id = 0;\n  char buf[64];\n  Host *h;\n\n  ntop->getTrace()->traceEvent(TRACE_INFO, \"%s() called\", __FUNCTION__);\n\n  if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING)) return(CONST_LUA_ERROR);\n  get_host_vlan_info((char*)lua_tostring(vm, 1), &host_ip, &vlan_id, buf, sizeof(buf));\n\n  \/* Optional VLAN id *\/\n  if(lua_type(vm, 2) == LUA_TNUMBER) vlan_id = (u_int16_t)lua_tonumber(vm, 2);\n\n  if((!ntop_interface)\n     || ((h = ntop_interface->findHostsByIP(get_allowed_nets(vm), host_ip, vlan_id)) == NULL))\n    return(CONST_LUA_ERROR);\n\n  h->resetPeriodicStats();\n  return(CONST_LUA_OK);\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":419532,"func":"int sa_fread(int ifd, void *buffer, size_t size, int mode, int oneof)\n{\n\tssize_t n;\n\n\tif ((n = read(ifd, buffer, size)) < 0) {\n\t\tfprintf(stderr, _(\"Error while reading system activity file: %s\\n\"),\n\t\t\tstrerror(errno));\n\t\tclose(ifd);\n\t\texit(2);\n\t}\n\n\tif (!n && (mode == SOFT_SIZE))\n\t\treturn 1;\t\/* EOF *\/\n\n\tif (n < size) {\n\t\tfprintf(stderr, _(\"End of system activity file unexpected\\n\"));\n\t\tif (oneof == UEOF_CONT)\n\t\t\treturn 2;\n\t\tclose(ifd);\n\t\texit(2);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":428558,"func":"g_file_unmount_mountable_with_operation_finish (GFile         *file,\n                                                GAsyncResult  *result,\n                                                GError       **error)\n{\n  GFileIface *iface;\n\n  g_return_val_if_fail (G_IS_FILE (file), FALSE);\n  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);\n\n  if (g_async_result_legacy_propagate_error (result, error))\n    return FALSE;\n  else if (g_async_result_is_tagged (result, g_file_unmount_mountable_with_operation))\n    return g_task_propagate_boolean (G_TASK (result), error);\n\n  iface = G_FILE_GET_IFACE (file);\n  if (iface->unmount_mountable_with_operation_finish != NULL)\n    return (* iface->unmount_mountable_with_operation_finish) (file, result, error);\n  else\n    return (* iface->unmount_mountable_finish) (file, result, error);\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":205843,"func":"  explicit FrameFactoryImpl(const service_manager::BindSourceInfo& source_info)\n      : source_info_(source_info), routing_id_highmark_(-1) {}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":348515,"func":"void brcmf_rx_event(struct device *dev, struct sk_buff *skb)\n{\n\tstruct brcmf_if *ifp;\n\tstruct brcmf_bus *bus_if = dev_get_drvdata(dev);\n\tstruct brcmf_pub *drvr = bus_if->drvr;\n\n\tbrcmf_dbg(EVENT, \"Enter: %s: rxp=%p\\n\", dev_name(dev), skb);\n\n\tif (brcmf_rx_hdrpull(drvr, skb, &ifp))\n\t\treturn;\n\n\tbrcmf_fweh_process_skb(ifp->drvr, skb);\n\tbrcmu_pkt_buf_free_skb(skb);\n}","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":67585,"func":"void TNEFInitAttachment(Attachment *p) {\n  INITDTR(p->Date);\n  INITVARLENGTH(p->Title);\n  INITVARLENGTH(p->MetaFile);\n  INITDTR(p->CreateDate);\n  INITDTR(p->ModifyDate);\n  INITVARLENGTH(p->TransportFilename);\n  INITVARLENGTH(p->FileData);\n  INITVARLENGTH(p->IconData);\n  memset(&(p->RenderData), 0, sizeof(renddata));\n  TNEFInitMapi(&(p->MAPI));\n  p->next = NULL;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":440245,"func":"str_node_split_last_char(Node* node, OnigEncoding enc)\n{\n  const UChar *p;\n  Node* rn;\n  StrNode* sn;\n\n  sn = STR_(node);\n  rn = NULL_NODE;\n  if (sn->end > sn->s) {\n    p = onigenc_get_prev_char_head(enc, sn->s, sn->end);\n    if (p && p > sn->s) { \/* can be split. *\/\n      rn = node_new_str(p, sn->end);\n      CHECK_NULL_RETURN(rn);\n      if (NODE_STRING_IS_CRUDE(node))\n        NODE_STRING_SET_CRUDE(rn);\n\n      sn->end = (UChar* )p;\n    }\n  }\n  return rn;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":178631,"func":"void js_setglobal(js_State *J, const char *name)\n{\n\tjsR_setproperty(J, J->G, name);\n\tjs_pop(J, 1);\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":385667,"func":"PHP_NAMED_FUNCTION(php_inet_ntop)\n{\n\tchar *address;\n\tint address_len, af = AF_INET;\n\tchar buffer[40];\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &address, &address_len) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n#ifdef HAVE_IPV6\n\tif (address_len == 16) {\n\t\taf = AF_INET6;\n\t} else\n#endif\n\tif (address_len != 4) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid in_addr value\");\n\t\tRETURN_FALSE;\n\t}\n\n\tif (!inet_ntop(af, address, buffer, sizeof(buffer))) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"An unknown error occurred\");\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_STRING(buffer, 1);\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":89451,"func":"bool HHVM_FUNCTION(image2wbmp, const Resource& image,\n                   const String& filename \/* = null_string *\/,\n                   int64_t threshold \/* = -1 *\/) {\n  return _php_image_output(image, filename, threshold, -1,\n                           PHP_GDIMG_CONVERT_WBM, \"WBMP\",\n                           (void (*)())_php_image_bw_convert);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":114541,"func":"SWFRect SWFShape_getEdgeBounds(SWFShape shape)\n{\n\tif(shape->useVersion == SWF_SHAPE4)\n\t\treturn shape->edgeBounds;\n\telse\n\t\treturn NULL;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":207475,"func":"xsltApplyFallbacks(xsltTransformContextPtr ctxt, xmlNodePtr node,\n\t           xmlNodePtr inst) {\n\n    xmlNodePtr child;\n    int ret = 0;\n\n    if ((ctxt == NULL) || (node == NULL) || (inst == NULL) ||\n\t(inst->children == NULL))\n\treturn(0);\n\n    child = inst->children;\n    while (child != NULL) {\n        if ((IS_XSLT_ELEM(child)) &&\n            (xmlStrEqual(child->name, BAD_CAST \"fallback\"))) {\n#ifdef WITH_XSLT_DEBUG_PARSING\n\t    xsltGenericDebug(xsltGenericDebugContext,\n\t\t\t     \"applying xsl:fallback\\n\");\n#endif\n\t    ret++;\n\t    xsltApplySequenceConstructor(ctxt, node, child->children,\n\t\tNULL);\n\t}\n\tchild = child->next;\n    }\n    return(ret);\n}\n","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":386925,"func":"dns_sd_resolver_changed (GVfsDnsSdResolver *resolver,\n                         GVfsBackendDav    *dav_backend)\n{\n  \/* TODO: handle when DNS-SD data changes *\/\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":107383,"func":"SWFInput_length(SWFInput input)\n{\n\tint pos = SWFInput_tell(input);\n\n\tSWFInput_seek(input, 0, SEEK_END);\n\tSWFInput_seek(input, pos, SEEK_SET);\n\n\treturn input->length;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":358179,"func":"static inline unsigned int dt_type(struct inode *inode)\n{\n\treturn (inode->i_mode >> 12) & 15;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":423634,"func":"dns_zone_set_parentcatz(dns_zone_t *zone, dns_catz_zone_t *catz) {\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\tREQUIRE(catz != NULL);\n\tLOCK_ZONE(zone);\n\tINSIST(zone->parentcatz == NULL || zone->parentcatz == catz);\n\tzone->parentcatz = catz;\n\tUNLOCK_ZONE(zone);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":204240,"func":"http_Setup(struct http *hp, struct ws *ws)\n{\n\tuint16_t shd;\n\ttxt *hd;\n\tunsigned char *hdf;\n\n\t\/* XXX: This is not elegant, is it efficient ? *\/\n\tshd = hp->shd;\n\thd = hp->hd;\n\thdf = hp->hdf;\n\tmemset(hp, 0, sizeof *hp);\n\tmemset(hd, 0, sizeof *hd * shd);\n\tmemset(hdf, 0, sizeof *hdf * shd);\n\thp->magic = HTTP_MAGIC;\n\thp->ws = ws;\n\thp->nhd = HTTP_HDR_FIRST;\n\thp->shd = shd;\n\thp->hd = hd;\n\thp->hdf = hdf;\n}\n","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":337848,"func":"static inline uint32_t reloc_26_val(tcg_insn_unit *pc, tcg_insn_unit *target)\n\n{\n\n    assert((((uintptr_t)pc ^ (uintptr_t)target) & 0xf0000000) == 0);\n\n    return ((uintptr_t)target >> 2) & 0x3ffffff;\n\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":354796,"func":"void make_bad_inode(struct inode *inode)\n{\n\tremove_inode_hash(inode);\n\n\tinode->i_mode = S_IFREG;\n\tinode->i_atime = inode->i_mtime = inode->i_ctime =\n\t\tcurrent_fs_time(inode->i_sb);\n\tinode->i_op = &bad_inode_ops;\t\n\tinode->i_fop = &bad_file_ops;\t\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":186571,"func":"bool RenderProcessHostImpl::FastShutdownForPageCount(size_t count) {\n  if (render_widget_hosts_.size() == count)\n    return FastShutdownIfPossible();\n  return false;\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":428237,"func":"static bool tcp_has_tx_tstamp(const struct sk_buff *skb)\n{\n\treturn TCP_SKB_CB(skb)->txstamp_ack ||\n\t\t(skb_shinfo(skb)->tx_flags & SKBTX_ANY_TSTAMP);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":355177,"func":"int raw_notifier_chain_unregister(struct raw_notifier_head *nh,\n\t\tstruct notifier_block *n)\n{\n\treturn notifier_chain_unregister(&nh->head, n);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":377927,"func":"static void cgw_csum_xor_pos(struct can_frame *cf, struct cgw_csum_xor *xor)\n{\n\tu8 val = xor->init_xor_val;\n\tint i;\n\n\tfor (i = xor->from_idx; i <= xor->to_idx; i++)\n\t\tval ^= cf->data[i];\n\n\tcf->data[xor->result_idx] = val;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":64880,"func":"void __cpuinit set_uncached_handler(unsigned long offset, void *addr,\n\tunsigned long size)\n{\n\tunsigned long uncached_ebase = CKSEG1ADDR(ebase);\n\n\tif (!addr)\n\t\tpanic(panic_null_cerr);\n\n\tmemcpy((void *)(uncached_ebase + offset), addr, size);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":65458,"func":"ExprResolveInteger(struct xkb_context *ctx, const ExprDef *expr,\n                   int *val_rtrn)\n{\n    return ExprResolveIntegerLookup(ctx, expr, val_rtrn, NULL, NULL);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":113049,"func":"ModuleExport void UnregisterPDBImage(void)\n{\n  (void) UnregisterMagickInfo(\"PDB\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":133176,"func":"sec_dist_func4 (xd3_stream *stream, xd3_output *data)\n{\n  int i, ret, x;\n  for (i = 0; i < ALPHABET_SIZE*20; i += 1)\n    {\n      x = mt_exp_rand (10, ALPHABET_SIZE\/2);\n      if ((ret = xd3_emit_byte (stream, & data, x))) { return ret; }\n    }\n  return 0;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":259036,"func":"static void reparent_thread(struct task_struct *p, struct task_struct *father)\n{\n\tif (p->pdeath_signal)\n\t\t\/* We already hold the tasklist_lock here.  *\/\n\t\tgroup_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p);\n\n\tlist_move_tail(&p->sibling, &p->real_parent->children);\n\n\t\/* If this is a threaded reparent there is no need to\n\t * notify anyone anything has happened.\n\t *\/\n\tif (same_thread_group(p->real_parent, father))\n\t\treturn;\n\n\t\/* We don't want people slaying init.  *\/\n\tif (!task_detached(p))\n\t\tp->exit_signal = SIGCHLD;\n\n\t\/* If we'd notified the old parent about this child's death,\n\t * also notify the new parent.\n\t *\/\n\tif (!ptrace_reparented(p) &&\n\t    p->exit_state == EXIT_ZOMBIE &&\n\t    !task_detached(p) && thread_group_empty(p))\n\t\tdo_notify_parent(p, p->exit_signal);\n\n\tkill_orphaned_pgrp(p, father);\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":436087,"func":"onig_free_shared_cclass_table(void)\n{\n  if (IS_NOT_NULL(OnigTypeCClassTable)) {\n    onig_st_foreach(OnigTypeCClassTable, i_free_shared_class, 0);\n    onig_st_free_table(OnigTypeCClassTable);\n    OnigTypeCClassTable = NULL;\n  }\n\n  return 0;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":369595,"func":"PHP_FUNCTION(openssl_cipher_iv_length)\n{\n\tchar *method;\n\tint method_len;\n\tconst EVP_CIPHER *cipher_type;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &method, &method_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (!method_len) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown cipher algorithm\");\n\t\tRETURN_FALSE;\n\t}\n\n\tcipher_type = EVP_get_cipherbyname(method);\n\tif (!cipher_type) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown cipher algorithm\");\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_LONG(EVP_CIPHER_iv_length(cipher_type));\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":33000,"func":"static void get_kvmclock(struct kvm *kvm, struct kvm_clock_data *data)\n{\n\tstruct kvm_arch *ka = &kvm->arch;\n\tunsigned seq;\n\n\tdo {\n\t\tseq = read_seqcount_begin(&ka->pvclock_sc);\n\t\t__get_kvmclock(kvm, data);\n\t} while (read_seqcount_retry(&ka->pvclock_sc, seq));\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":177576,"func":"void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) {\n  DCHECK(!frame_ || frame_ == frame);\n  if (!frame->parent()) {\n    FrameMsg_UILoadMetricsReportType::Value report_type =\n        static_cast<FrameMsg_UILoadMetricsReportType::Value>(\n            frame->dataSource()->request().inputPerfMetricReportPolicy());\n    base::TimeTicks ui_timestamp = base::TimeTicks() +\n        base::TimeDelta::FromSecondsD(\n            frame->dataSource()->request().uiStartTime());\n\n    Send(new FrameHostMsg_DocumentOnLoadCompleted(\n        routing_id_, report_type, ui_timestamp));\n  }\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":424150,"func":"void exec_status_dump(const ExecStatus *s, FILE *f, const char *prefix) {\n        char buf[FORMAT_TIMESTAMP_MAX];\n\n        assert(s);\n        assert(f);\n\n        if (s->pid <= 0)\n                return;\n\n        prefix = strempty(prefix);\n\n        fprintf(f,\n                \"%sPID: \"PID_FMT\"\\n\",\n                prefix, s->pid);\n\n        if (dual_timestamp_is_set(&s->start_timestamp))\n                fprintf(f,\n                        \"%sStart Timestamp: %s\\n\",\n                        prefix, format_timestamp(buf, sizeof(buf), s->start_timestamp.realtime));\n\n        if (dual_timestamp_is_set(&s->exit_timestamp))\n                fprintf(f,\n                        \"%sExit Timestamp: %s\\n\"\n                        \"%sExit Code: %s\\n\"\n                        \"%sExit Status: %i\\n\",\n                        prefix, format_timestamp(buf, sizeof(buf), s->exit_timestamp.realtime),\n                        prefix, sigchld_code_to_string(s->code),\n                        prefix, s->status);\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":195790,"func":"UNCURL_EXPORT int32_t uncurl_ws_close(struct uncurl_conn *ucc, uint16_t status_code)\n{\n\tuint16_t status_code_be = htons(status_code);\n\n\treturn uncurl_ws_write(ucc, (char *) &status_code_be, sizeof(uint16_t), UNCURL_WSOP_CLOSE);\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":277870,"func":"nfsd4_free_slabs(void)\n{\n\tkmem_cache_destroy(odstate_slab);\n\tkmem_cache_destroy(openowner_slab);\n\tkmem_cache_destroy(lockowner_slab);\n\tkmem_cache_destroy(file_slab);\n\tkmem_cache_destroy(stateid_slab);\n\tkmem_cache_destroy(deleg_slab);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":408223,"func":"int uprobe_apply(struct inode *inode, loff_t offset,\n\t\t\tstruct uprobe_consumer *uc, bool add)\n{\n\tstruct uprobe *uprobe;\n\tstruct uprobe_consumer *con;\n\tint ret = -ENOENT;\n\n\tuprobe = find_uprobe(inode, offset);\n\tif (WARN_ON(!uprobe))\n\t\treturn ret;\n\n\tdown_write(&uprobe->register_rwsem);\n\tfor (con = uprobe->consumers; con && con != uc ; con = con->next)\n\t\t;\n\tif (con)\n\t\tret = register_for_each_vma(uprobe, add ? uc : NULL);\n\tup_write(&uprobe->register_rwsem);\n\tput_uprobe(uprobe);\n\n\treturn ret;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":120002,"func":"static int genl_lock_done(struct netlink_callback *cb)\n{\n\t\/* our ops are always const - netlink API doesn't propagate that *\/\n\tconst struct genl_ops *ops = cb->data;\n\tint rc = 0;\n\n\tif (ops->done) {\n\t\tgenl_lock();\n\t\trc = ops->done(cb);\n\t\tgenl_unlock();\n\t}\n\treturn rc;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":488426,"func":"static void ma_put(struct ifmcaddr6 *mc)\n{\n\tif (refcount_dec_and_test(&mc->mca_refcnt)) {\n\t\tin6_dev_put(mc->idev);\n\t\tkfree_rcu(mc, rcu);\n\t}\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":519646,"func":"longlong Field_datetime_with_dec::val_int(void)\n{\n  MYSQL_TIME ltime;\n  get_date(<ime, 0);\n  return TIME_to_ulonglong_datetime(<ime);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":130873,"func":"static int shash_async_update(struct ahash_request *req)\n{\n\treturn shash_ahash_update(req, ahash_request_ctx(req));\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":149366,"func":"int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)\n\n{\n\n    int64_t deadline = -1;\n\n    QEMUClockType type;\n\n    bool play = replay_mode == REPLAY_MODE_PLAY;\n\n    for (type = 0; type < QEMU_CLOCK_MAX; type++) {\n\n        if (qemu_clock_use_for_deadline(type)) {\n\n            if (!play || type == QEMU_CLOCK_REALTIME) {\n\n                deadline = qemu_soonest_timeout(deadline,\n\n                                                timerlist_deadline_ns(tlg->tl[type]));\n\n            } else {\n\n                \/* Read clock from the replay file and\n\n                   do not calculate the deadline, based on virtual clock. *\/\n\n                qemu_clock_get_ns(type);\n\n            }\n\n        }\n\n    }\n\n    return deadline;\n\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":373096,"func":"void PostgreSqlStorage::removeIdentity(UserId user, IdentityId identityId)\n{\n    QSqlDatabase db = logDb();\n    if (!db.transaction()) {\n        qWarning() << \"PostgreSqlStorage::removeIdentity(): Unable to start Transaction!\";\n        qWarning() << \" -\" << qPrintable(db.lastError().text());\n        return;\n    }\n\n    QSqlQuery query(db);\n    query.prepare(queryString(\"delete_identity\"));\n    query.bindValue(\":identityid\", identityId.toInt());\n    query.bindValue(\":userid\", user.toInt());\n    safeExec(query);\n    if (!watchQuery(query)) {\n        db.rollback();\n    }\n    else {\n        db.commit();\n    }\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":382605,"func":"keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr)\n{\n  KEYDB_SEARCH_DESC desc;\n\n  memset (&desc, 0, sizeof desc);\n  desc.mode = KEYDB_SEARCH_MODE_FPR;\n  memcpy (desc.u.fpr, fpr, MAX_FINGERPRINT_LEN);\n  return keydb_search (hd, &desc, 1, NULL);\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":32564,"func":"  ParamsRegions ParamsWeightRegions() const override {\n    return params_desc_.params_weights();\n  }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":398510,"func":"static void megasas_write_sense(MegasasCmd *cmd, SCSISense sense)\n{\n    uint8_t sense_buf[SCSI_SENSE_BUF_SIZE];\n    uint8_t sense_len = 18;\n\n    memset(sense_buf, 0, sense_len);\n    sense_buf[0] = 0xf0;\n    sense_buf[2] = sense.key;\n    sense_buf[7] = 10;\n    sense_buf[12] = sense.asc;\n    sense_buf[13] = sense.ascq;\n    megasas_build_sense(cmd, sense_buf, sense_len);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":404235,"func":"static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)\n{\n\tstruct ethtool_coalesce coalesce;\n\n\tif (!dev->ethtool_ops->set_coalesce)\n\t\treturn -EOPNOTSUPP;\n\n\tif (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))\n\t\treturn -EFAULT;\n\n\treturn dev->ethtool_ops->set_coalesce(dev, &coalesce);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":24186,"func":"static VALUE ossl_cipher_initialize ( VALUE self , VALUE str ) {\n EVP_CIPHER_CTX * ctx ;\n const EVP_CIPHER * cipher ;\n char * name ;\n name = StringValueCStr ( str ) ;\n GetCipherInit ( self , ctx ) ;\n if ( ctx ) {\n ossl_raise ( rb_eRuntimeError , \"Cipher already inititalized!\" ) ;\n }\n AllocCipher ( self , ctx ) ;\n if ( ! ( cipher = EVP_get_cipherbyname ( name ) ) ) {\n ossl_raise ( rb_eRuntimeError , \"unsupported cipher algorithm (%\" PRIsVALUE \")\" , str ) ;\n }\n if ( EVP_CipherInit_ex ( ctx , cipher , NULL , NULL , NULL , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ;\n return self ;\n }","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":42316,"func":"int wc_ecc_export_private_raw(ecc_key* key, byte* qx, word32* qxLen,\n                              byte* qy, word32* qyLen, byte* d, word32* dLen)\n{\n    return wc_ecc_export_ex(key, qx, qxLen, qy, qyLen, d, dLen,\n        WC_TYPE_UNSIGNED_BIN);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":301691,"func":"static gboolean property_get_roles(const GDBusPropertyTable *property,\n\t\t\t\t\tDBusMessageIter *iter, void *user_data)\n{\n\tstruct btd_adapter *adapter = user_data;\n\tDBusMessageIter entry;\n\n\tdbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,\n\t\t\t\t\tDBUS_TYPE_STRING_AS_STRING, &entry);\n\n\tif (adapter->supported_settings & MGMT_SETTING_LE) {\n\t\tconst char *str = \"central\";\n\t\tdbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str);\n\t}\n\n\tif (adapter->supported_settings & MGMT_SETTING_ADVERTISING) {\n\t\tconst char *str = \"peripheral\";\n\t\tdbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str);\n\t}\n\n\tif (adapter->le_simult_roles_supported) {\n\t\tconst char *str = \"central-peripheral\";\n\t\tdbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str);\n\t}\n\n\tdbus_message_iter_close_container(iter, &entry);\n\n\treturn TRUE;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":94310,"func":"LineBitmapRequester::~LineBitmapRequester(void)\n{\n  UBYTE i;\n\n  if (m_ppDownsampler) {\n    for(i = 0;i < m_ucCount;i++) {\n      delete m_ppDownsampler[i];\n    }\n    m_pEnviron->FreeMem(m_ppDownsampler,m_ucCount * sizeof(class DownsamplerBase *));\n  }\n\n  if (m_ppUpsampler) {\n    for(i = 0;i < m_ucCount;i++) {\n      delete m_ppUpsampler[i];\n    }\n    m_pEnviron->FreeMem(m_ppUpsampler,m_ucCount * sizeof(class UpsamplerBase *));\n  }\n\n  if (m_ppTempIBM) {\n    for(i = 0;i < m_ucCount;i++) {\n      delete m_ppTempIBM[i];\n    }\n    m_pEnviron->FreeMem(m_ppTempIBM,m_ucCount * sizeof(struct ImageBitMap *));\n  }\n  \n  if (m_pulReadyLines)\n    m_pEnviron->FreeMem(m_pulReadyLines,m_ucCount * sizeof(ULONG));\n\n  if (m_pppImage)\n    m_pEnviron->FreeMem(m_pppImage,m_ucCount * sizeof(struct Line **));\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":408880,"func":"page_objects_dump(pdf_write_state *opts)\n{\n\tpage_objects_list *pol = opts->page_object_lists;\n\tint i, j;\n\n\tfor (i = 0; i < pol->len; i++)\n\t{\n\t\tpage_objects *p = pol->page[i];\n\t\tfprintf(stderr, \"Page %d\\n\", i+1);\n\t\tfor (j = 0; j < p->len; j++)\n\t\t{\n\t\t\tint o = p->object[j];\n\t\t\tfprintf(stderr, \"\\tObject %d: use=%x\\n\", o, opts->use_list[o]);\n\t\t}\n\t\tfprintf(stderr, \"Byte range=%d->%d\\n\", p->min_ofs, p->max_ofs);\n\t\tfprintf(stderr, \"Number of objects=%d, Number of shared objects=%d\\n\", p->num_objects, p->num_shared);\n\t\tfprintf(stderr, \"Page object number=%d\\n\", p->page_object_number);\n\t}\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":513581,"func":"uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *session)\n{\n    return session->ext.max_fragment_len_mode;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":312429,"func":"xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,\n\t     xmlNodePtr insert, int literal)\n{\n    return(xsltCopyTreeInternal(ctxt, node, node, insert, literal, 0));\n\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":309701,"func":"u64 gf_net_get_ntp_ts()\n{\n\tu64 res;\n\tu32 sec, frac;\n\tgf_net_get_ntp(&sec, &frac);\n\tres = sec;\n\tres<<= 32;\n\tres |= frac;\n\treturn res;\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":63374,"func":"static void sco_sock_timeout(unsigned long arg)\n{\n\tstruct sock *sk = (struct sock *) arg;\n\n\tBT_DBG(\"sock %p state %d\", sk, sk->sk_state);\n\n\tbh_lock_sock(sk);\n\tsk->sk_err = ETIMEDOUT;\n\tsk->sk_state_change(sk);\n\tbh_unlock_sock(sk);\n\n\tsco_sock_kill(sk);\n\tsock_put(sk);\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":487223,"func":"ephy_string_collate_key_for_domain (const char *str,\n                                    gssize      len)\n{\n  GString *result;\n  const char *dot;\n  gssize newlen;\n\n  if (len < 0)\n    len = strlen (str);\n\n  result = g_string_sized_new (len + 6 * strlen (COLLATION_SENTINEL));\n\n  \/* Note that we could do even better by using\n   * g_utf8_collate_key_for_filename on the dot-separated\n   * components, but this seems good enough for now.\n   *\/\n  while ((dot = g_strrstr_len (str, len, \".\")) != NULL) {\n    newlen = dot - str;\n\n    g_string_append_len (result, dot + 1, len - newlen - 1);\n    g_string_append (result, COLLATION_SENTINEL);\n\n    len = newlen;\n  }\n\n  if (len > 0)\n    g_string_append_len (result, str, len);\n\n  return g_string_free (result, FALSE);\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":296347,"func":"hfs_cat_get_record_offset(HFS_INFO * hfs, const hfs_btree_key_cat * needle)\n{\n    HFS_CAT_GET_RECORD_OFFSET_DATA offset_data;\n    offset_data.off = 0;\n    offset_data.targ_key = needle;\n    if (hfs_cat_traverse(hfs, hfs_cat_get_record_offset_cb, &offset_data)) {\n        return 0;\n    }\n    return offset_data.off;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":489582,"func":"GF_Err trak_box_dump(GF_Box *a, FILE * trace)\n{\n\tGF_TrackBox *p;\n\n\tp = (GF_TrackBox *)a;\n\tgf_isom_box_dump_start(a, \"TrackBox\", trace);\n\tgf_fprintf(trace, \">\\n\");\n\tif (p->size && !p->Header) {\n\t\tgf_fprintf(trace, \"<!--INVALID FILE: Missing Track Header-->\\n\");\n\t}\n\tgf_isom_box_dump_done(\"TrackBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":317530,"func":"FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(\n\tFLAC__StreamDecoder *decoder,\n FILE *file,\n\tFLAC__StreamDecoderWriteCallback write_callback,\n\tFLAC__StreamDecoderMetadataCallback metadata_callback,\n\tFLAC__StreamDecoderErrorCallback error_callback,\n void *client_data\n)\n{\n return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, \/*is_ogg=*\/false);\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":312258,"func":"  cff_parser_done( CFF_Parser  parser )\n  {\n    FT_Memory  memory = parser->library->memory;    \/* for FT_FREE *\/\n\n\n    FT_FREE( parser->stack );\n  }\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":248463,"func":"int OBJ_new_nid(int num)\n\t{\n\tint i;\n\n\ti=new_nid;\n\tnew_nid+=num;\n\treturn(i);\n\t}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":218599,"func":"bool Plugin::HandleDocumentLoad(const pp::URLLoader& url_loader) {\n  PLUGIN_PRINTF((\"Plugin::HandleDocumentLoad (this=%p)\\n\",\n                 static_cast<void*>(this)));\n  if (!BrowserPpp::is_valid(ppapi_proxy_)) {\n    document_load_to_replay_ = url_loader;\n    return true;\n  } else {\n    return PP_ToBool(\n        ppapi_proxy_->ppp_instance_interface()->HandleDocumentLoad(\n            pp_instance(), url_loader.pp_resource()));\n  }\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":449944,"func":"static void futex_cleanup(struct task_struct *tsk)\n{\n\tif (unlikely(tsk->robust_list)) {\n\t\texit_robust_list(tsk);\n\t\ttsk->robust_list = NULL;\n\t}\n\n#ifdef CONFIG_COMPAT\n\tif (unlikely(tsk->compat_robust_list)) {\n\t\tcompat_exit_robust_list(tsk);\n\t\ttsk->compat_robust_list = NULL;\n\t}\n#endif\n\n\tif (unlikely(!list_empty(&tsk->pi_state_list)))\n\t\texit_pi_state_list(tsk);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":393585,"func":"xmlRegCopyRange(xmlRegParserCtxtPtr ctxt, xmlRegRangePtr range) {\n    xmlRegRangePtr ret;\n\n    if (range == NULL)\n\treturn(NULL);\n\n    ret = xmlRegNewRange(ctxt, range->neg, range->type, range->start,\n                         range->end);\n    if (ret == NULL)\n        return(NULL);\n    if (range->blockName != NULL) {\n\tret->blockName = xmlStrdup(range->blockName);\n\tif (ret->blockName == NULL) {\n\t    xmlRegexpErrMemory(ctxt, \"allocating range\");\n\t    xmlRegFreeRange(ret);\n\t    return(NULL);\n\t}\n    }\n    return(ret);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":7043,"func":"static inline void fsnotify_oldname_free(const unsigned char *old_name)\n{\n\tkfree(old_name);\n}","target":1,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":186200,"func":"FoFiType1::FoFiType1(char *fileA, int lenA, GBool freeFileDataA):\n  FoFiBase(fileA, lenA, freeFileDataA)\n{\n  name = NULL;\n  encoding = NULL;\n  parsed = gFalse;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":310694,"func":" void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) {\n   std::string path;\n   CHECK(args->GetString(0, &path));\n  DCHECK(StartsWithASCII(path, \"chrome:\/\/favicon\/size\/32\/\", false)) <<\n      \"path is \" << path;\n  path = path.substr(arraysize(\"chrome:\/\/favicon\/size\/32\/\") - 1);\n \n   double id;\n   CHECK(args->GetDouble(1, &id));\n\n  FaviconService* favicon_service =\n      web_ui_->GetProfile()->GetFaviconService(Profile::EXPLICIT_ACCESS);\n  if (!favicon_service || path.empty())\n    return;\n\n  FaviconService::Handle handle = favicon_service->GetFaviconForURL(\n      GURL(path),\n      history::FAVICON,\n      &consumer_,\n      NewCallback(this, &FaviconWebUIHandler::OnFaviconDataAvailable));\n  consumer_.SetClientData(favicon_service, handle, static_cast<int>(id));\n}\n","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":131064,"func":"void __stop_tty(struct tty_struct *tty)\n{\n\tif (tty->stopped)\n\t\treturn;\n\ttty->stopped = 1;\n\tif (tty->ops->stop)\n\t\ttty->ops->stop(tty);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":245261,"func":"void Browser::ResetTryToCloseWindow() {\n  cancel_download_confirmation_state_ = NOT_PROMPTED;\n  if (IsFastTabUnloadEnabled())\n    fast_unload_controller_->ResetTryToCloseWindow();\n  else\n    unload_controller_->ResetTryToCloseWindow();\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":21785,"func":"static char * make_fast_import_path ( const char * path ) {\n if ( ! relative_marks_paths || is_absolute_path ( path ) ) return xstrdup ( path ) ;\n return xstrdup ( git_path ( \"info\/fast-import\/%s\" , path ) ) ;\n }","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":386168,"func":"SPL_METHOD(MultipleIterator, getFlags)\n{\n\tspl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\tRETURN_LONG(intern->flags);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":156070,"func":"struct task_struct * __cpuinit fork_idle(int cpu)\n{\n\tstruct task_struct *task;\n\ttask = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0);\n\tif (!IS_ERR(task)) {\n\t\tinit_idle_pids(task->pids);\n\t\tinit_idle(task, cpu);\n\t}\n\n\treturn task;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":227275,"func":"void WebGL2RenderingContextBase::texImage3D(GLenum target,\n                                            GLint level,\n                                            GLint internalformat,\n                                            GLsizei width,\n                                            GLsizei height,\n                                            GLsizei depth,\n                                            GLint border,\n                                            GLenum format,\n                                            GLenum type,\n                                            ImageBitmap* bitmap,\n                                            ExceptionState& exception_state) {\n  if (isContextLost())\n    return;\n  if (bound_pixel_unpack_buffer_) {\n    SynthesizeGLError(GL_INVALID_OPERATION, \"texImage3D\",\n                      \"a buffer is bound to PIXEL_UNPACK_BUFFER\");\n    return;\n  }\n  TexImageHelperImageBitmap(kTexImage3D, target, level, internalformat, format,\n                            type, 0, 0, 0, bitmap,\n                            GetTextureSourceSubRectangle(width, height), depth,\n                            unpack_image_height_, exception_state);\n}\n","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":190530,"func":"MojoResult Core::FuseMessagePipes(MojoHandle handle0, MojoHandle handle1) {\n  RequestContext request_context;\n  scoped_refptr<Dispatcher> dispatcher0;\n  scoped_refptr<Dispatcher> dispatcher1;\n\n  bool valid_handles = true;\n  {\n    base::AutoLock lock(handles_->GetLock());\n    MojoResult result0 =\n        handles_->GetAndRemoveDispatcher(handle0, &dispatcher0);\n    MojoResult result1 =\n        handles_->GetAndRemoveDispatcher(handle1, &dispatcher1);\n    if (result0 != MOJO_RESULT_OK || result1 != MOJO_RESULT_OK ||\n        dispatcher0->GetType() != Dispatcher::Type::MESSAGE_PIPE ||\n        dispatcher1->GetType() != Dispatcher::Type::MESSAGE_PIPE)\n      valid_handles = false;\n  }\n\n  if (!valid_handles) {\n    if (dispatcher0)\n      dispatcher0->Close();\n    if (dispatcher1)\n      dispatcher1->Close();\n    return MOJO_RESULT_INVALID_ARGUMENT;\n  }\n\n  MessagePipeDispatcher* mpd0 =\n      static_cast<MessagePipeDispatcher*>(dispatcher0.get());\n  MessagePipeDispatcher* mpd1 =\n      static_cast<MessagePipeDispatcher*>(dispatcher1.get());\n\n  if (!mpd0->Fuse(mpd1))\n    return MOJO_RESULT_FAILED_PRECONDITION;\n\n  return MOJO_RESULT_OK;\n}\n","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":241783,"func":"void WebFrameLoaderClient::postProgressFinishedNotification() {\n  WebViewImpl* webview = webframe_->GetWebViewImpl();\n  if (webview && webview->client())\n    webview->client()->didStopLoading();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":347283,"func":"static inline void drbg_set_testdata(struct drbg_state *drbg,\n\t\t\t\t     struct drbg_test_data *test_data)\n{\n\tif (!test_data || !test_data->testentropy)\n\t\treturn;\n\tmutex_lock(&drbg->drbg_mutex);;\n\tdrbg->test_data = test_data;\n\tmutex_unlock(&drbg->drbg_mutex);\n}","target":1,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":439505,"func":"static void __exit sfb_module_exit(void)\n{\n\tunregister_qdisc(&sfb_qdisc_ops);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":213186,"func":"static WeakDocumentSet& liveDocumentSet() {\n  DEFINE_STATIC_LOCAL(blink::Persistent<WeakDocumentSet>, set,\n                      (blink::MakeGarbageCollected<WeakDocumentSet>()));\n  return *set;\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":24135,"func":"static inline void take_option ( char * * to , char * from , int * first , int len ) {\n if ( ! * first ) {\n * * to = ',' ;\n * to += 1 ;\n }\n else * first = 0 ;\n memcpy ( * to , from , len ) ;\n * to += len ;\n }","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":480138,"func":"evdev_device_has_key(struct evdev_device *device, uint32_t code)\n{\n\tif (!(device->seat_caps & EVDEV_DEVICE_KEYBOARD))\n\t\treturn -1;\n\n\treturn libevdev_has_event_code(device->evdev, EV_KEY, code);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":208267,"func":"  RenderViewImplTest() {\n    mock_keyboard_.reset(new MockKeyboard());\n  }\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":113118,"func":"static inline size_t ColorTo565(const DDSVector3 point)\n{\n  size_t r = ClampToLimit(31.0f*point.x,31);\n  size_t g = ClampToLimit(63.0f*point.y,63);\n  size_t b = ClampToLimit(31.0f*point.z,31);\n\n  return (r << 11) | (g << 5) | b;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":505834,"func":"int main(int argc, char *argv[])\n    {\n    printf(\"No FIPS support\\n\");\n    return(0);\n    }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":21319,"func":"static inline void vmsvga_update_rect_delayed ( struct vmsvga_state_s * s , int x , int y , int w , int h ) {\n struct vmsvga_rect_s * rect = & s -> redraw_fifo [ s -> redraw_fifo_last ++ ] ;\n s -> redraw_fifo_last &= REDRAW_FIFO_LEN - 1 ;\n rect -> x = x ;\n rect -> y = y ;\n rect -> w = w ;\n rect -> h = h ;\n }","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":248284,"func":"status_t OMXNodeInstance::updateGraphicBufferInMeta(\n        OMX_U32 portIndex, const sp<GraphicBuffer>& graphicBuffer,\n        OMX::buffer_id buffer) {\n Mutex::Autolock autoLock(mLock);\n    OMX_BUFFERHEADERTYPE *header = findBufferHeader(buffer, portIndex);\n return updateGraphicBufferInMeta_l(\n            portIndex, graphicBuffer, buffer, header,\n true \/* updateCodecBuffer *\/);\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":480608,"func":"void DL_Dxf::writeBlock(DL_WriterA& dw, const DL_BlockData& data) {\n    if (data.name.empty()) {\n        std::cerr << \"DL_Dxf::writeBlock: \"\n        << \"Block name must not be empty\\n\";\n        return;\n    }\n\n    std::string n = data.name;\n    std::transform(n.begin(), n.end(), n.begin(), ::toupper);\n\n    if (n==\"*PAPER_SPACE\") {\n        dw.sectionBlockEntry(0x1C);\n    } else if (n==\"*MODEL_SPACE\") {\n        dw.sectionBlockEntry(0x20);\n    } else if (n==\"*PAPER_SPACE0\") {\n        dw.sectionBlockEntry(0x24);\n    } else {\n        dw.sectionBlockEntry();\n    }\n    dw.dxfString(2, data.name);\n    dw.dxfInt(70, 0);\n    dw.coord(10, data.bpx, data.bpy, data.bpz);\n    dw.dxfString(3, data.name);\n    dw.dxfString(1, \"\");\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":21527,"func":"static void encode_scan_format ( VC2EncContext * s ) {\n put_bits ( & s -> pb , 1 , ! s -> strict_compliance ) ;\n if ( ! s -> strict_compliance ) put_vc2_ue_uint ( & s -> pb , s -> interlaced ) ;\n }","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":170046,"func":"expand_string_copy(uschar *string)\n{\nuschar *yield = expand_string(string);\nif (yield == string) yield = string_copy(string);\nreturn yield;\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":513132,"func":"  virtual void updateFillOpacity(GfxState * \/*state*\/) {}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":55057,"func":"static int iwbmp_write_bmp_header(struct iwbmpwcontext *wctx)\n{\n\tif(wctx->bmpversion==2) {\n\t\treturn iwbmp_write_bmp_v2header(wctx);\n\t}\n\telse if(wctx->bmpversion==5) {\n\t\tif(!iwbmp_write_bmp_v3header(wctx)) return 0;\n\t\treturn iwbmp_write_bmp_v45header_fields(wctx);\n\t}\n\treturn iwbmp_write_bmp_v3header(wctx);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":275774,"func":"bool Extension::ShowConfigureContextMenus() const {\n  return location() != Manifest::COMPONENT;\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":171106,"func":"internal_sanitize_pin_info(struct sc_pin_cmd_pin *pin, unsigned int num)\n{\n\tpin->encoding = SC_PIN_ENCODING_ASCII;\n\tpin->min_length = 4;\n\tpin->max_length = 16;\n\tpin->pad_length = 16;\n\tpin->offset = 5 + num * 16;\n\tpin->pad_char = 0x00;\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":109701,"func":"  absl::Status IsSupported(const TfLiteContext* context,\n                           const TfLiteNode* tflite_node,\n                           const TfLiteRegistration* registration) final {\n    RETURN_IF_ERROR(CheckMaxSupportedOpVersion(registration, 1));\n    RETURN_IF_ERROR(CheckInputsOutputs(context, tflite_node,\n                                       \/*runtime_inputs=*\/1, \/*outputs=*\/1));\n    \/\/ TODO(eignasheva): add shape checking\n    return absl::OkStatus();\n  }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":476923,"func":"bool swiotlb_free(struct device *dev, struct page *page, size_t size)\n{\n\tphys_addr_t tlb_addr = page_to_phys(page);\n\n\tif (!is_swiotlb_buffer(dev, tlb_addr))\n\t\treturn false;\n\n\tswiotlb_release_slots(dev, tlb_addr);\n\n\treturn true;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":422889,"func":"static void tcp_enter_recovery(struct sock *sk, bool ece_ack)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint mib_idx;\n\n\tif (tcp_is_reno(tp))\n\t\tmib_idx = LINUX_MIB_TCPRENORECOVERY;\n\telse\n\t\tmib_idx = LINUX_MIB_TCPSACKRECOVERY;\n\n\tNET_INC_STATS_BH(sock_net(sk), mib_idx);\n\n\ttp->prior_ssthresh = 0;\n\ttp->undo_marker = tp->snd_una;\n\ttp->undo_retrans = tp->retrans_out;\n\n\tif (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) {\n\t\tif (!ece_ack)\n\t\t\ttp->prior_ssthresh = tcp_current_ssthresh(sk);\n\t\ttcp_init_cwnd_reduction(sk, true);\n\t}\n\ttcp_set_ca_state(sk, TCP_CA_Recovery);\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":462702,"func":"void RegexMatchExpression::_init() {\n    uassert(\n        ErrorCodes::BadValue, \"Regular expression is too long\", _regex.size() <= kMaxPatternSize);\n\n    uassert(ErrorCodes::BadValue,\n            \"Regular expression cannot contain an embedded null byte\",\n            _regex.find('\\0') == std::string::npos);\n\n    uassert(ErrorCodes::BadValue,\n            \"Regular expression options string cannot contain an embedded null byte\",\n            _flags.find('\\0') == std::string::npos);\n\n    \/\/ isValidUTF8() checks for UTF-8 which does not map to a series of codepoints but does not\n    \/\/ check the validity of the code points themselves. These situations do not cause problems\n    \/\/ downstream so we do not do additional work to enforce that the code points are valid.\n    uassert(\n        5108300, \"Regular expression is invalid UTF-8\", isValidUTF8(_regex) && isValidUTF8(_flags));\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":431282,"func":"    std::vector<uint8_t> _binDataVector() const {\n        if (binDataType() != ByteArrayDeprecated) {\n            return std::vector<uint8_t>(reinterpret_cast<const uint8_t*>(value()) + 5,\n                                        reinterpret_cast<const uint8_t*>(value()) + 5 +\n                                            valuestrsize());\n        } else {\n            \/\/ Skip the extra int32 size\n            return std::vector<uint8_t>(reinterpret_cast<const uint8_t*>(value()) + 4,\n                                        reinterpret_cast<const uint8_t*>(value()) + 4 +\n                                            valuestrsize() - 4);\n        }\n    }","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":262144,"func":"static const char *phase_name(int phase) {\n    switch(phase) {\n        case 1 :\n            return \"REQUEST_HEADERS\";\n            break;\n        case 2 :\n            return \"REQUEST_BODY\";\n            break;\n        case 3 :\n            return \"RESPONSE_HEADERS\";\n            break;\n        case 4 :\n            return \"RESPONSE_BODY\";\n            break;\n        case 5 :\n            return \"LOGGING\";\n            break;\n    }\n    \n    return \"INVALID\";\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":363975,"func":"static void virtio_submit_multiwrite(BlockDriverState *bs, MultiReqBuffer *mrb)\n{\n    int i, ret;\n\n    if (!mrb->num_writes) {\n        return;\n    }\n\n    ret = bdrv_aio_multiwrite(bs, mrb->blkreq, mrb->num_writes);\n    if (ret != 0) {\n        for (i = 0; i < mrb->num_writes; i++) {\n            if (mrb->blkreq[i].error) {\n                virtio_blk_rw_complete(mrb->blkreq[i].opaque, -EIO);\n            }\n        }\n    }\n\n    mrb->num_writes = 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":484700,"func":"static int snd_ctl_elem_user_enum_info(struct snd_kcontrol *kcontrol,\n\t\t\t\t       struct snd_ctl_elem_info *uinfo)\n{\n\tstruct user_element *ue = kcontrol->private_data;\n\tconst char *names;\n\tunsigned int item;\n\tunsigned int offset;\n\n\titem = uinfo->value.enumerated.item;\n\n\toffset = snd_ctl_get_ioff(kcontrol, &uinfo->id);\n\t*uinfo = ue->info;\n\tsnd_ctl_build_ioff(&uinfo->id, kcontrol, offset);\n\n\titem = min(item, uinfo->value.enumerated.items - 1);\n\tuinfo->value.enumerated.item = item;\n\n\tnames = ue->priv_data;\n\tfor (; item > 0; --item)\n\t\tnames += strlen(names) + 1;\n\tstrcpy(uinfo->value.enumerated.name, names);\n\n\treturn 0;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":209207,"func":"static void overloadedMethodBMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    TestObjectPythonV8Internal::overloadedMethodBMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":23627,"func":"int main ( int argc , char * * argv ) {\n struct event signal_int ;\n struct event_base * base = event_base_new ( ) ;\n event_set ( & signal_int , SIGINT , EV_SIGNAL | EV_PERSIST , signal_cb , & signal_int ) ;\n event_base_set ( base , & signal_int ) ;\n event_add ( & signal_int , NULL ) ;\n event_base_dispatch ( base ) ;\n event_base_free ( base ) ;\n return ( 0 ) ;\n }","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":91441,"func":"static int opfidiv(RAsm *a, ut8 *data, const Opcode *op) {\n\tint l = 0;\n\tswitch (op->operands_count) {\n\tcase 1:\n\t\tif ( op->operands[0].type & OT_MEMORY ) {\n\t\t\tif ( op->operands[0].type & OT_DWORD ) {\n\t\t\t\tdata[l++] = 0xda;\n\t\t\t\tdata[l++] = 0x30 | op->operands[0].regs[0];\n\t\t\t} else if ( op->operands[0].type & OT_WORD ) {\n\t\t\t\tdata[l++] = 0xde;\n\t\t\t\tdata[l++] = 0x30 | op->operands[0].regs[0];\n\t\t\t} else {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\treturn -1;\n\t}\n\treturn l;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":390762,"func":"static PHP_INI_MH(OnUpdateOutputEncoding)\n{\n\tif (new_value) {\n\t\tOnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);\n\t}\n\treturn SUCCESS;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":71738,"func":"  void readField(T& t, FieldType \/* fieldType *\/) {\n    readRawInto(t);\n  }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":372851,"func":"getkey_byname (getkey_ctx_t *retctx, PKT_public_key *pk,\n               const char *name, int want_secret, kbnode_t *ret_keyblock)\n{\n  gpg_error_t err;\n  strlist_t namelist = NULL;\n  int with_unusable = 1;\n\n  if (want_secret && !name && opt.def_secret_key && *opt.def_secret_key)\n    add_to_strlist (&namelist, opt.def_secret_key);\n  else if (name)\n    add_to_strlist (&namelist, name);\n  else\n    with_unusable = 0;\n\n  err = key_byname (retctx, namelist, pk, want_secret, with_unusable,\n                    ret_keyblock, NULL);\n\n  \/* FIXME: Check that we really return GPG_ERR_NO_SECKEY if\n     WANT_SECRET has been used.  *\/\n\n  free_strlist (namelist);\n\n  return err;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":294745,"func":"inline int ComputePadding(int stride, int dilation_rate, int in_size,\n                          int filter_size, int out_size) {\n  int effective_filter_size = (filter_size - 1) * dilation_rate + 1;\n  int padding = ((out_size - 1) * stride + effective_filter_size - in_size) \/ 2;\n  return padding > 0 ? padding : 0;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":82221,"func":"static int xfrm_dump_policy(struct sk_buff *skb, struct netlink_callback *cb)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct xfrm_policy_walk *walk = (struct xfrm_policy_walk *)cb->args;\n\tstruct xfrm_dump_info info;\n\n\tinfo.in_skb = cb->skb;\n\tinfo.out_skb = skb;\n\tinfo.nlmsg_seq = cb->nlh->nlmsg_seq;\n\tinfo.nlmsg_flags = NLM_F_MULTI;\n\n\t(void) xfrm_policy_walk(net, walk, dump_one_policy, &info);\n\n\treturn skb->len;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":254502,"func":"void SessionService::TabClosed(const SessionID& window_id,\n                               const SessionID& tab_id,\n                               bool closed_by_user_gesture) {\n  if (!tab_id.id())\n    return;  \/\/ Hapens when the tab is replaced.\n\n  if (!ShouldTrackChangesToWindow(window_id))\n    return;\n\n  IdToRange::iterator i = tab_to_available_range_.find(tab_id.id());\n  if (i != tab_to_available_range_.end())\n    tab_to_available_range_.erase(i);\n\n  if (find(pending_window_close_ids_.begin(), pending_window_close_ids_.end(),\n           window_id.id()) != pending_window_close_ids_.end()) {\n    pending_tab_close_ids_.insert(tab_id.id());\n  } else if (find(window_closing_ids_.begin(), window_closing_ids_.end(),\n                  window_id.id()) != window_closing_ids_.end() ||\n             !IsOnlyOneTabLeft() ||\n             closed_by_user_gesture) {\n    ScheduleCommand(CreateTabClosedCommand(tab_id.id()));\n  } else {\n    pending_tab_close_ids_.insert(tab_id.id());\n    has_open_trackable_browsers_ = false;\n  }\n}\n","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":83591,"func":"  virtual void visit(Capture & \/*ope*\/) {}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":246122,"func":"NetworkChangeNotifier::~NetworkChangeNotifier() {\n  DCHECK_EQ(this, g_network_change_notifier);\n  g_network_change_notifier = NULL;\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":134975,"func":"void Type_ProfileSequenceId_Free(struct _cms_typehandler_struct* self, void* Ptr)\n{\n    cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);\n    return;\n\n    cmsUNUSED_PARAMETER(self);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":72886,"func":"static int network_dispatch_notification (notification_t *n) \/* {{{ *\/\n{\n  int status;\n\n  assert (n->meta == NULL);\n\n  status = plugin_notification_meta_add_boolean (n, \"network:received\", 1);\n  if (status != 0)\n  {\n    ERROR (\"network plugin: plugin_notification_meta_add_boolean failed.\");\n    plugin_notification_meta_free (n->meta);\n    n->meta = NULL;\n    return (status);\n  }\n\n  status = plugin_dispatch_notification (n);\n\n  plugin_notification_meta_free (n->meta);\n  n->meta = NULL;\n\n  return (status);\n} \/* }}} int network_dispatch_notification *\/","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":275897,"func":"bool GetPostData(const net::URLRequest* request, std::string* post_data) {\n  if (!request->has_upload())\n    return false;\n\n  const net::UploadDataStream* stream = request->get_upload();\n  if (!stream->GetElementReaders())\n    return false;\n\n  const auto* element_readers = stream->GetElementReaders();\n\n  if (element_readers->empty())\n    return false;\n\n  *post_data = \"\";\n  for (const auto& element_reader : *element_readers) {\n    const net::UploadBytesElementReader* reader =\n        element_reader->AsBytesReader();\n    if (!reader) {\n      *post_data = \"\";\n      return false;\n    }\n    *post_data += std::string(reader->bytes(), reader->length());\n  }\n  return true;\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":290154,"func":"static int isoent_make_sorted_files ( struct archive_write * a , struct isoent * isoent , struct idr * idr ) {\n struct archive_rb_node * rn ;\n struct isoent * * children ;\n children = malloc ( isoent -> children . cnt * sizeof ( struct isoent * ) ) ;\n if ( children == NULL ) {\n archive_set_error ( & a -> archive , ENOMEM , \"Can't allocate memory\" ) ;\n return ( ARCHIVE_FATAL ) ;\n }\n isoent -> children_sorted = children ;\n ARCHIVE_RB_TREE_FOREACH ( rn , & ( idr -> rbtree ) ) {\n struct idrent * idrent = ( struct idrent * ) rn ;\n * children ++ = idrent -> isoent ;\n }\n return ( ARCHIVE_OK ) ;\n }","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":489434,"func":"}\nstatic JSValue js_sys_basename(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)\n{\n\treturn js_sys_file_opt(ctx, this_val, argc, argv, OPT_FILEBASENAME);","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":153999,"func":"ff_free_stack_element(ff_stack_T *stack_ptr)\n{\n    \/\/ vim_free handles possible NULL pointers\n    vim_free(stack_ptr->ffs_fix_path);\n#ifdef FEAT_PATH_EXTRA\n    vim_free(stack_ptr->ffs_wc_path);\n#endif\n\n    if (stack_ptr->ffs_filearray != NULL)\n\tFreeWild(stack_ptr->ffs_filearray_size, stack_ptr->ffs_filearray);\n\n    vim_free(stack_ptr);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":20800,"func":"static void pdf_clear_stack ( fz_context * ctx , pdf_csi * csi ) {\n int i ;\n pdf_drop_obj ( ctx , csi -> obj ) ;\n csi -> obj = NULL ;\n csi -> name [ 0 ] = 0 ;\n csi -> string_len = 0 ;\n for ( i = 0 ;\n i < csi -> top ;\n i ++ ) csi -> stack [ i ] = 0 ;\n csi -> top = 0 ;\n }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":180609,"func":"void gs_lib_ctx_set_cms_context( const gs_memory_t *mem, void *cms_context )\n{\n    if (mem == NULL)\n        return;\n    mem->gs_lib_ctx->cms_context = cms_context;\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":237925,"func":"bool RenderBlock::updateLogicalWidthAndColumnWidth()\n{\n    LayoutUnit oldWidth = logicalWidth();\n    LayoutUnit oldColumnWidth = desiredColumnWidth();\n\n    updateLogicalWidth();\n    calcColumnWidth();\n\n    bool hasBorderOrPaddingLogicalWidthChanged = m_hasBorderOrPaddingLogicalWidthChanged;\n    m_hasBorderOrPaddingLogicalWidthChanged = false;\n\n    return oldWidth != logicalWidth() || oldColumnWidth != desiredColumnWidth() || hasBorderOrPaddingLogicalWidthChanged;\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":164266,"func":"void TabStripGtk::StartMiniMoveTabAnimation(int from_index,\n                                            int to_index,\n                                            const gfx::Rect& start_bounds) {\n  StopAnimation();\n  active_animation_.reset(\n      new MiniMoveAnimation(this, from_index, to_index, start_bounds));\n  active_animation_->Start();\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":482187,"func":"ciInstance* ciEnv::ClassCastException_instance() {\n  if (_ClassCastException_instance == NULL) {\n    _ClassCastException_instance\n          = get_or_create_exception(_ClassCastException_handle,\n          vmSymbols::java_lang_ClassCastException());\n  }\n  return _ClassCastException_instance;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":235473,"func":"float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame,\n                                            int page_number,\n                                            const gfx::Rect& canvas_area,\n                                            const gfx::Rect& content_area,\n                                            double scale_factor,\n                                            blink::WebCanvas* canvas) {\n  SkAutoCanvasRestore auto_restore(canvas, true);\n  canvas->translate((content_area.x() - canvas_area.x()) \/ scale_factor,\n                    (content_area.y() - canvas_area.y()) \/ scale_factor);\n  return frame->printPage(page_number, canvas);\n}\n","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":145421,"func":"static int index_entry_isrch_path(const void *path, const void *array_member)\n{\n\tconst git_index_entry *entry = array_member;\n\n\treturn strcasecmp((const char *)path, entry->path);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":344694,"func":"static int myrand( void *rng_state, unsigned char *output, size_t len )\n{\n    size_t i;\n\n    if( rng_state != NULL )\n        rng_state  = NULL;\n\n    for( i = 0; i < len; ++i )\n        output[i] = rand();\n    \n    return( 0 );\n}","target":1,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":118975,"func":"static __poll_t hci_uart_tty_poll(struct tty_struct *tty,\n\t\t\t\t      struct file *filp, poll_table *wait)\n{\n\treturn 0;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":432800,"func":"next_trim (void *nxdata, uint32_t count, uint64_t offset, uint32_t flags,\n           int *err)\n{\n  struct b_conn *b_conn = nxdata;\n  return backend_trim (b_conn->b, b_conn->conn, count, offset, flags, err);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":109669,"func":"void ksz9131DisableIrq(NetInterface *interface)\n{\n   \/\/Disable PHY transceiver interrupts\n   if(interface->extIntDriver != NULL)\n   {\n      interface->extIntDriver->disableIrq();\n   }\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":165002,"func":"static void lsi_memcpy(LSIState *s, uint32_t dest, uint32_t src, int count)\n{\n    int n;\n    uint8_t buf[LSI_BUF_SIZE];\n\n    trace_lsi_memcpy(dest, src, count);\n    while (count) {\n        n = (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count;\n        lsi_mem_read(s, src, buf, n);\n        lsi_mem_write(s, dest, buf, n);\n        src += n;\n        dest += n;\n        count -= n;\n    }\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":2468,"func":"static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,\n\t\t\t\t\t  struct xfrm_state *x, u32 seq)\n{\n\tstruct xfrm_dump_info info;\n\tstruct sk_buff *skb;\n\n\tskb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\n\tif (!skb)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tinfo.in_skb = in_skb;\n\tinfo.out_skb = skb;\n\tinfo.nlmsg_seq = seq;\n\tinfo.nlmsg_flags = 0;\n\n\tif (dump_one_state(x, 0, &info)) {\n\t\tkfree_skb(skb);\n\t\treturn NULL;\n\t}\n\n\treturn skb;\n}","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":163152,"func":"void Browser::SelectNextTab() {\n  UserMetrics::RecordAction(UserMetricsAction(\"SelectNextTab\"));\n  tab_handler_->GetTabStripModel()->SelectNextTab();\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":298919,"func":"static void scrub_free_parity(struct scrub_parity *sparity)\n{\n\tstruct scrub_ctx *sctx = sparity->sctx;\n\tstruct scrub_page *curr, *next;\n\tint nbits;\n\n\tnbits = bitmap_weight(sparity->ebitmap, sparity->nsectors);\n\tif (nbits) {\n\t\tspin_lock(&sctx->stat_lock);\n\t\tsctx->stat.read_errors += nbits;\n\t\tsctx->stat.uncorrectable_errors += nbits;\n\t\tspin_unlock(&sctx->stat_lock);\n\t}\n\n\tlist_for_each_entry_safe(curr, next, &sparity->spages, list) {\n\t\tlist_del_init(&curr->list);\n\t\tscrub_page_put(curr);\n\t}\n\n\tkfree(sparity);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":73407,"func":"PHP_FUNCTION(imagesetbrush)\n{\n\tzval *IM, *TILE;\n\tgdImagePtr im, tile;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rr\", &IM, &TILE) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\tZEND_FETCH_RESOURCE(tile, gdImagePtr, &TILE, -1, \"Image\", le_gd);\n\n\tgdImageSetBrush(im, tile);\n\n\tRETURN_TRUE;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":246715,"func":"HTMLImportLoader* Document::ImportLoader() const {\n  if (!imports_controller_)\n    return 0;\n  return imports_controller_->LoaderFor(*this);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":357739,"func":"static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,\n\t\tint family)\n{\n\tstruct sock *sk;\n\tstruct kmem_cache *slab;\n\n\tslab = prot->slab;\n\tif (slab != NULL)\n\t\tsk = kmem_cache_alloc(slab, priority);\n\telse\n\t\tsk = kmalloc(prot->obj_size, priority);\n\n\tif (sk != NULL) {\n\t\tif (security_sk_alloc(sk, family, priority))\n\t\t\tgoto out_free;\n\n\t\tif (!try_module_get(prot->owner))\n\t\t\tgoto out_free_sec;\n\t}\n\n\treturn sk;\n\nout_free_sec:\n\tsecurity_sk_free(sk);\nout_free:\n\tif (slab != NULL)\n\t\tkmem_cache_free(slab, sk);\n\telse\n\t\tkfree(sk);\n\treturn NULL;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":247402,"func":"SProcRenderSetPictureFilter (ClientPtr client)\n{\n    register int n;\n    REQUEST (xRenderSetPictureFilterReq);\n    REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq);\n\n    swaps(&stuff->length, n);\n    swapl(&stuff->picture, n);\n    swaps(&stuff->nbytes, n);\n    return (*ProcRenderVector[stuff->renderReqType]) (client);\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":193941,"func":"static void set_load_weight(struct task_struct *p)\n{\n\tint prio = p->static_prio - MAX_RT_PRIO;\n\tstruct load_weight *load = &p->se.load;\n\n\t\/*\n\t * SCHED_IDLE tasks get minimal weight:\n\t *\/\n\tif (idle_policy(p->policy)) {\n\t\tload->weight = scale_load(WEIGHT_IDLEPRIO);\n\t\tload->inv_weight = WMULT_IDLEPRIO;\n\t\treturn;\n\t}\n\n\tload->weight = scale_load(sched_prio_to_weight[prio]);\n\tload->inv_weight = sched_prio_to_wmult[prio];\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":175303,"func":"ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(Profile* profile,\n                                                         Delegate* delegate)\n  : profile_(profile),\n    delegate_(delegate) {\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":303648,"func":"Variant HHVM_FUNCTION(imagecreatetruecolor, int64_t width, int64_t height) {\n  gdImagePtr im;\n\n  if (width <= 0 || height <= 0 || width >= INT_MAX || height >= INT_MAX) {\n    raise_warning(\"Invalid image dimensions\");\n    return false;\n  }\n\n  im = gdImageCreateTrueColor(width, height);\n\n  if (!im) {\n    return false;\n  }\n  return Variant(req::make<Image>(im));\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":206944,"func":"PHP_FUNCTION(connection_aborted)\n{\n\tRETURN_LONG(PG(connection_status) & PHP_CONNECTION_ABORTED);\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":254449,"func":"ContentSecurityPolicy::~ContentSecurityPolicy() {}\n","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":339839,"func":"static int add_tonal_components(float *spectrum, int num_components,\n\n                                TonalComponent *components)\n\n{\n\n    int i, j, last_pos = -1;\n\n    float *input, *output;\n\n\n\n    for (i = 0; i < num_components; i++) {\n\n        last_pos = FFMAX(components[i].pos + components[i].num_coefs, last_pos);\n\n        input    = components[i].coef;\n\n        output   = &spectrum[components[i].pos];\n\n\n\n        for (j = 0; j < components[i].num_coefs; j++)\n\n            output[i] += input[i];\n\n    }\n\n\n\n    return last_pos;\n\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":518486,"func":"static int add_keyword_path(String *str, const char *keyword,\n                            const char *path)\n{\n  char temp_path[FN_REFLEN];\n  strcpy(temp_path, path);\n#ifdef __WIN__\n  \/* Convert \\ to \/ to be able to create table on unix *\/\n  char *pos, *end;\n  size_t length= strlen(temp_path);\n  for (pos= temp_path, end= pos+length ; pos < end ; pos++)\n  {\n    if (*pos == '\\\\')\n      *pos = '\/';\n  }\n#endif\n\n  \/*\n  If the partition file name with its \"#P#\" identifier\n  is found after the last slash, truncate that filename.\n  *\/\n  truncate_partition_filename(temp_path);\n\n  return add_keyword_string(str, keyword, true, temp_path);\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":445893,"func":"static UINT video_control_on_close(IWTSVirtualChannelCallback* pChannelCallback)\n{\n\tfree(pChannelCallback);\n\treturn CHANNEL_RC_OK;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":346209,"func":"char *get_56_lenc_string(char **buffer,\n                         size_t *max_bytes_available,\n                         size_t *string_length)\n{\n  static char empty_string[1]= { '\\0' };\n  char *begin= *buffer;\n\n  if (*max_bytes_available == 0)\n    return NULL;\n\n  \/*\n    If the length encoded string has the length 0\n    the total size of the string is only one byte long (the size byte)\n  *\/\n  if (*begin == 0)\n  {\n    *string_length= 0;\n    --*max_bytes_available;\n    ++*buffer;\n    \/*\n      Return a pointer to the \\0 character so the return value will be\n      an empty string.\n    *\/\n    return empty_string;\n  }\n\n  *string_length= (size_t)net_field_length_ll((uchar **)buffer);\n\n  size_t len_len= (size_t)(*buffer - begin);\n  \n  if (*string_length + len_len > *max_bytes_available)\n    return NULL;\n\n  *max_bytes_available -= *string_length + len_len;\n  *buffer += *string_length;\n  return (char *)(begin + len_len);\n}","target":1,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":37481,"func":"TRIO_PUBLIC void trio_locale_set_decimal_point TRIO_ARGS1((decimalPoint), char* decimalPoint)\n{\n#if defined(USE_LOCALE)\n\tif (NULL == internalLocaleValues)\n\t{\n\t\tTrioSetLocale();\n\t}\n#endif\n\tinternalDecimalPointLength = trio_length(decimalPoint);\n\tif (internalDecimalPointLength == 1)\n\t{\n\t\tinternalDecimalPoint = *decimalPoint;\n\t}\n\telse\n\t{\n\t\tinternalDecimalPoint = NIL;\n\t\ttrio_copy_max(internalDecimalPointString, sizeof(internalDecimalPointString), decimalPoint);\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":352488,"func":"static CURLcode hsts_create(struct hsts *h,\n                            const char *hostname,\n                            bool subdomains,\n                            curl_off_t expires)\n{\n  struct stsentry *sts = hsts_entry();\n  if(!sts)\n    return CURLE_OUT_OF_MEMORY;\n\n  sts->expires = expires;\n  sts->includeSubDomains = subdomains;\n  sts->host = strdup(hostname);\n  if(!sts->host) {\n    free(sts);\n    return CURLE_OUT_OF_MEMORY;\n  }\n  Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);\n  return CURLE_OK;\n}","target":1,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":470551,"func":"tape_clear_rest_of_block (int out_file_des)\n{\n  write_nuls_to_file (io_block_size - output_size, out_file_des, \n                      tape_buffered_write);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":396285,"func":"ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, uint length, int duplicate TSRMLS_DC) \/* {{{ *\/\n{\n\tzval *tmp;\n\tzval *z_key;\n\n\tif (UNEXPECTED(length > INT_MAX)) {\n\t\tzend_error_noreturn(E_ERROR, \"String overflow, max size is %d\", INT_MAX);\n\t}\n\n\tMAKE_STD_ZVAL(tmp);\n\tZVAL_STRINGL(tmp, str, length, duplicate);\n\n\tMAKE_STD_ZVAL(z_key);\n\tZVAL_STRINGL(z_key, key, key_len-1, 1);\n\n\tZ_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);\n\tzval_ptr_dtor(&tmp); \/* write_property will add 1 to refcount *\/\n\tzval_ptr_dtor(&z_key);\n\treturn SUCCESS;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":122146,"func":"    TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )\r\n    {\r\n        TaskHandle_t pxReturn;\r\n\r\n        configASSERT( xSemaphore );\r\n\r\n        \/* Mutexes cannot be used in interrupt service routines, so the mutex\r\n         * holder should not change in an ISR, and therefore a critical section is\r\n         * not required here. *\/\r\n        if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r\n        {\r\n            pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder;\r\n        }\r\n        else\r\n        {\r\n            pxReturn = NULL;\r\n        }\r\n\r\n        return pxReturn;\r\n    } \/*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. *\/\r","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":448081,"func":"void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages)\n{\n\tint i;\n\n\tfor(i = 0; i < num_pages; i++) {\n\t\tif (pages[i]) {\n\t\t\tunlock_page(pages[i]);\n\t\t\tmark_page_accessed(pages[i]);\n\t\t\tpage_cache_release(pages[i]);\n\t\t}\n\t}\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":303571,"func":"nfs4_find_client_ident(struct net *net, int cb_ident)\n{\n\tstruct nfs_client *clp;\n\tstruct nfs_net *nn = net_generic(net, nfs_net_id);\n\n\tspin_lock(&nn->nfs_client_lock);\n\tclp = idr_find(&nn->cb_ident_idr, cb_ident);\n\tif (clp)\n\t\trefcount_inc(&clp->cl_count);\n\tspin_unlock(&nn->nfs_client_lock);\n\treturn clp;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":57397,"func":"static void set_extent_mask_and_shift(struct ecryptfs_crypt_stat *crypt_stat)\n{\n\tint extent_size_tmp;\n\n\tcrypt_stat->extent_mask = 0xFFFFFFFF;\n\tcrypt_stat->extent_shift = 0;\n\tif (crypt_stat->extent_size == 0)\n\t\treturn;\n\textent_size_tmp = crypt_stat->extent_size;\n\twhile ((extent_size_tmp & 0x01) == 0) {\n\t\textent_size_tmp >>= 1;\n\t\tcrypt_stat->extent_mask <<= 1;\n\t\tcrypt_stat->extent_shift++;\n\t}\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":462079,"func":"void *zrealloc_usable(void *ptr, size_t size, size_t *usable) {\n    ptr = ztryrealloc_usable(ptr, size, usable);\n    if (!ptr && size != 0) zmalloc_oom_handler(size);\n    return ptr;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":23262,"func":"void set_server_version ( void ) {\n char * version_end = server_version + sizeof ( server_version ) - 1 ;\n char * end = strxnmov ( server_version , sizeof ( server_version ) - 1 , MYSQL_SERVER_VERSION , MYSQL_SERVER_SUFFIX_STR , NullS ) ;\n # ifdef EMBEDDED_LIBRARY end = strnmov ( end , \"-embedded\" , ( version_end - end ) ) ;\n # endif # ifndef DBUG_OFF if ( ! strstr ( MYSQL_SERVER_SUFFIX_STR , \"-debug\" ) ) end = strnmov ( end , \"-debug\" , ( version_end - end ) ) ;\n # endif if ( opt_log || opt_slow_log || opt_bin_log ) strnmov ( end , \"-log\" , ( version_end - end ) ) ;\n * end = 0 ;\n }","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":216519,"func":"error::Error GLES2DecoderImpl::HandleStencilFillPathCHROMIUM(\n    uint32_t immediate_data_size,\n    const volatile void* cmd_data) {\n  static const char kFunctionName[] = \"glStencilFillPathCHROMIUM\";\n  const volatile gles2::cmds::StencilFillPathCHROMIUM& c =\n      *static_cast<const volatile gles2::cmds::StencilFillPathCHROMIUM*>(\n          cmd_data);\n  if (!features().chromium_path_rendering)\n    return error::kUnknownCommand;\n  PathCommandValidatorContext v(this, kFunctionName);\n  GLenum fill_mode = GL_COUNT_UP_CHROMIUM;\n  GLuint mask = 0;\n  if (!v.GetFillModeAndMask(c, &fill_mode, &mask))\n    return v.error();\n  GLuint service_id = 0;\n  if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) {\n    return error::kNoError;\n  }\n  if (!CheckBoundDrawFramebufferValid(kFunctionName))\n    return error::kNoError;\n  ApplyDirtyState();\n  api()->glStencilFillPathNVFn(service_id, fill_mode, mask);\n  return error::kNoError;\n}\n","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":364736,"func":"httpServeObjectStreamHandler(int status,\n                             FdEventHandlerPtr event,\n                             StreamRequestPtr srequest)\n{\n    return httpServeObjectStreamHandlerCommon(1, status, event, srequest);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":283401,"func":"std::string FormatLog(const char* fmt, va_list args) {\n  std::string msg = base::StringPrintV(fmt, args);\n  if (!msg.empty() && msg[msg.size() - 1] == '\\n')\n    msg.erase(msg.end() - 1, msg.end());\n  return msg;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":452459,"func":"static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag)\n{\n\tif (up_flag)\n\t\treturn;\t\t\/* no action, if this is a key release *\/\n\n\tif (diacr)\n\t\tvalue = handle_diacr(vc, value);\n\n\tif (dead_key_next) {\n\t\tdead_key_next = false;\n\t\tdiacr = value;\n\t\treturn;\n\t}\n\tif (kbd->kbdmode == VC_UNICODE)\n\t\tto_utf8(vc, value);\n\telse {\n\t\tint c = conv_uni_to_8bit(value);\n\t\tif (c != -1)\n\t\t\tput_queue(vc, c);\n\t}\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":239671,"func":"  testing::AssertionResult ScriptAllowedExclusivelyOnTab(\n      const Extension* extension,\n      const std::set<GURL>& allowed_urls,\n      int tab_id) {\n    std::vector<std::string> errors;\n    for (const GURL& url : urls_) {\n      AccessType access = GetExtensionAccess(extension, url, tab_id);\n      AccessType expected_access =\n          allowed_urls.count(url) ? ALLOWED_SCRIPT_ONLY : DISALLOWED;\n      if (access != expected_access) {\n        errors.push_back(\n            base::StringPrintf(\"Error for url '%s': expected %d, found %d\",\n                               url.spec().c_str(), expected_access, access));\n      }\n    }\n\n    if (!errors.empty())\n      return testing::AssertionFailure() << base::JoinString(errors, \"\\n\");\n    return testing::AssertionSuccess();\n  }\n","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":69970,"func":"static void br_multicast_router_expired(unsigned long data)\n{\n\tstruct net_bridge_port *port = (void *)data;\n\tstruct net_bridge *br = port->br;\n\n\tspin_lock(&br->multicast_lock);\n\tif (port->multicast_router != 1 ||\n\t    timer_pending(&port->multicast_router_timer) ||\n\t    hlist_unhashed(&port->rlist))\n\t\tgoto out;\n\n\thlist_del_init_rcu(&port->rlist);\n\nout:\n\tspin_unlock(&br->multicast_lock);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":120214,"func":"static int esp4_rcv_cb(struct sk_buff *skb, int err)\n{\n\treturn 0;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":346788,"func":"static bool check_solid_tile(VncState *vs, int x, int y, int w, int h,\n                             uint32_t* color, bool samecolor)\n{\n    VncDisplay *vd = vs->vd;\n\n    switch(vd->server->pf.bytes_per_pixel) {\n    case 4:\n        return check_solid_tile32(vs, x, y, w, h, color, samecolor);\n    case 2:\n        return check_solid_tile16(vs, x, y, w, h, color, samecolor);\n    default:\n        return check_solid_tile8(vs, x, y, w, h, color, samecolor);\n    }\n}","target":1,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":459595,"func":"dissect_kafka_describe_log_dirs_response_topic(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,\n                                                    int offset, kafka_api_version_t api_version)\n{\n    proto_item *subti, *subsubti;\n    proto_tree *subtree, *subsubtree;\n    int topic_start, topic_len;\n\n    subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_kafka_topic, &subti, \"Topic\");\n\n    offset = dissect_kafka_string(subtree, hf_kafka_topic_name, tvb, pinfo, offset, 0, &topic_start, &topic_len);\n\n    subsubtree = proto_tree_add_subtree(subtree, tvb, offset, -1, ett_kafka_partitions, &subsubti, \"Partitions\");\n\n    offset = dissect_kafka_array(subsubtree, tvb, pinfo, offset, 0, api_version,\n                                 &dissect_kafka_describe_log_dirs_response_partition, NULL);\n\n    proto_item_set_end(subti, tvb, offset);\n    proto_item_append_text(subti, \" (Name=%s)\",\n                           tvb_get_string_enc(wmem_packet_scope(), tvb,\n                                              topic_start, topic_len, ENC_UTF_8));\n\n    return offset;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":325162,"func":"static void adb_register_types(void)\n\n{\n\n    type_register_static(&adb_bus_type_info);\n\n    type_register_static(&adb_device_type_info);\n\n    type_register_static(&adb_kbd_type_info);\n\n    type_register_static(&adb_mouse_type_info);\n\n}\n","target":1,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":244632,"func":"void WebLocalFrameImpl::SetIsolatedWorldContentSecurityPolicy(\n    int world_id,\n    const WebString& policy) {\n  DCHECK(GetFrame());\n  DOMWrapperWorld::SetIsolatedWorldContentSecurityPolicy(world_id, policy);\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":128446,"func":"const char *am_filepath_dirname(apr_pool_t *p, const char *path) \n{\n    char *cp;\n\n    \/*\n     * Try Unix and then Windows style. Borrowed from\n     * apr_match_glob(), it seems it cannot be made more\n     * portable.\n     *\/\n    if (((cp = strrchr(path, (int)'\/')) == NULL) &&\n        ((cp = strrchr(path, (int)'\\\\')) == NULL))\n            return \".\";\n   \n    return apr_pstrndup(p, path, cp - path);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":120215,"func":"void DecimalQuantity::appendDigit(int8_t value, int32_t leadingZeros, bool appendAsInteger) {\n    U_ASSERT(leadingZeros >= 0);\n\n    \/\/ Zero requires special handling to maintain the invariant that the least-significant digit\n    \/\/ in the BCD is nonzero.\n    if (value == 0) {\n        if (appendAsInteger && precision != 0) {\n            scale += leadingZeros + 1;\n        }\n        return;\n    }\n\n    \/\/ Deal with trailing zeros\n    if (scale > 0) {\n        leadingZeros += scale;\n        if (appendAsInteger) {\n            scale = 0;\n        }\n    }\n\n    \/\/ Append digit\n    shiftLeft(leadingZeros + 1);\n    setDigitPos(0, value);\n\n    \/\/ Fix scale if in integer mode\n    if (appendAsInteger) {\n        scale += leadingZeros + 1;\n    }\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":117342,"func":"xmlSetEntityReferenceFunc(xmlEntityReferenceFunc func)\n{\n    xmlEntityRefFunc = func;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":404417,"func":"static void ipa_flood_interior(wmfAPI * API, wmfFlood_t * flood)\n{\n  \/* Save graphic wand *\/\n  (void) PushDrawingWand(WmfDrawingWand);\n\n  draw_fill_color_rgb(API,&(flood->color));\n\n  DrawColor(WmfDrawingWand,XC(flood->pt.x), YC(flood->pt.y),\n            FillToBorderMethod);\n\n  \/* Restore graphic wand *\/\n  (void) PopDrawingWand(WmfDrawingWand);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":319786,"func":"static void apic_common_class_init(ObjectClass *klass, void *data)\n\n{\n\n    ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass);\n\n    DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n    dc->vmsd = &vmstate_apic_common;\n\n    dc->reset = apic_reset_common;\n\n    dc->no_user = 1;\n\n    dc->props = apic_properties_common;\n\n    idc->init = apic_init_common;\n\n}\n","target":1,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":155344,"func":"DEFUN(defCSet, DEFAULT_CHARSET, \"Change the default character encoding\")\n{\n    char *cs;\n    wc_ces charset;\n\n    cs = searchKeyData();\n    if (cs == NULL || *cs == '\\0')\n\t\/* FIXME: gettextize? *\/\n\tcs = inputStr(\"Default document charset: \",\n\t\t      wc_ces_to_charset(DocumentCharset));\n    charset = wc_guess_charset_short(cs, 0);\n    if (charset != 0)\n\tDocumentCharset = charset;\n    displayBuffer(Currentbuf, B_NORMAL);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":223825,"func":"    RenderFrameHostImpl::GetOrCreateBrowserAccessibilityManager() {\n  RenderWidgetHostViewBase* view = GetViewForAccessibility();\n  if (view &&\n      !browser_accessibility_manager_ &&\n      !no_create_browser_accessibility_manager_for_testing_) {\n    bool is_root_frame = !frame_tree_node()->parent();\n    browser_accessibility_manager_.reset(\n        view->CreateBrowserAccessibilityManager(this, is_root_frame));\n  }\n  return browser_accessibility_manager_.get();\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":410338,"func":"    MemIo::~MemIo()\n    {\n        if (p_->isMalloced_) {\n            std::free(p_->data_);\n        }\n        delete p_;\n    }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":440110,"func":"ModuleExport void UnregisterPS2Image(void)\n{\n  (void) UnregisterMagickInfo(\"EPS2\");\n  (void) UnregisterMagickInfo(\"PS2\");\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":364017,"func":"void get_agp_version(struct agp_bridge_data *bridge)\n{\n\tu32 ncapid;\n\n\t\/* Exit early if already set by errata workarounds. *\/\n\tif (bridge->major_version != 0)\n\t\treturn;\n\n\tpci_read_config_dword(bridge->dev, bridge->capndx, &ncapid);\n\tbridge->major_version = (ncapid >> AGP_MAJOR_VERSION_SHIFT) & 0xf;\n\tbridge->minor_version = (ncapid >> AGP_MINOR_VERSION_SHIFT) & 0xf;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":327280,"func":"build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm,\n\n           unsigned facs, unsigned dsdt,\n\n           const char *oem_id, const char *oem_table_id)\n\n{\n\n    AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt));\n\n\n\n    fadt->firmware_ctrl = cpu_to_le32(facs);\n\n    \/* FACS address to be filled by Guest linker *\/\n\n    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,\n\n                                   ACPI_BUILD_TABLE_FILE,\n\n                                   &fadt->firmware_ctrl,\n\n                                   sizeof fadt->firmware_ctrl);\n\n\n\n    fadt->dsdt = cpu_to_le32(dsdt);\n\n    \/* DSDT address to be filled by Guest linker *\/\n\n    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,\n\n                                   ACPI_BUILD_TABLE_FILE,\n\n                                   &fadt->dsdt,\n\n                                   sizeof fadt->dsdt);\n\n\n\n    fadt_setup(fadt, pm);\n\n\n\n    build_header(linker, table_data,\n\n                 (void *)fadt, \"FACP\", sizeof(*fadt), 1, oem_id, oem_table_id);\n\n}\n","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":245793,"func":"mac_init (digest_hd_st* td, gnutls_mac_algorithm_t mac, opaque * secret, int secret_size,\n\t  int ver)\n{\nint ret =  0;\n\n  if (mac == GNUTLS_MAC_NULL)\n    {\n      gnutls_assert();\n      return GNUTLS_E_HASH_FAILED;\n    }\n\n  if (ver == GNUTLS_SSL3)\n    {\t\t\t\t\/* SSL 3.0 *\/\n      ret = _gnutls_mac_init_ssl3 (td, mac, secret, secret_size);\n    }\n  else\n    {\t\t\t\t\/* TLS 1.x *\/\n      ret = _gnutls_hmac_init (td, mac, secret, secret_size);\n    }\n\n  return ret;\n}\n","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":27152,"func":"void ptvcursor_set_tree ( ptvcursor_t * ptvc , proto_tree * tree ) {\n ptvc -> tree = tree ;\n }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":82155,"func":"int split_huge_page(struct page *page)\n{\n\tstruct anon_vma *anon_vma;\n\tint ret = 1;\n\n\tBUG_ON(!PageAnon(page));\n\tanon_vma = page_lock_anon_vma(page);\n\tif (!anon_vma)\n\t\tgoto out;\n\tret = 0;\n\tif (!PageCompound(page))\n\t\tgoto out_unlock;\n\n\tBUG_ON(!PageSwapBacked(page));\n\t__split_huge_page(page, anon_vma);\n\tcount_vm_event(THP_SPLIT);\n\n\tBUG_ON(PageCompound(page));\nout_unlock:\n\tpage_unlock_anon_vma(anon_vma);\nout:\n\treturn ret;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":125643,"func":"    \/\/! Return a pointer to a located pixel value \\const.\n    const T* data(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int c=0) const {\n      return const_cast<CImg<T>*>(this)->data(x,y,z,c);","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":318284,"func":"static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)\n{\n    unsigned char buf[4096];\n    int r = 0, i;\n    BIO *tmpout;\n\n    tmpout = cms_get_text_bio(out, flags);\n\n    if (tmpout == NULL) {\n        CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    \/* Read all content through chain to process digest, decrypt etc *\/\n    for (;;) {\n        i = BIO_read(in, buf, sizeof(buf));\n        if (i <= 0) {\n            if (BIO_method_type(in) == BIO_TYPE_CIPHER) {\n                if (!BIO_get_cipher_status(in))\n                    goto err;\n            }\n            if (i < 0)\n                goto err;\n            break;\n        }\n\n        if (tmpout && (BIO_write(tmpout, buf, i) != i))\n            goto err;\n    }\n\n    if (flags & CMS_TEXT) {\n        if (!SMIME_text(tmpout, out)) {\n            CMSerr(CMS_F_CMS_COPY_CONTENT, CMS_R_SMIME_TEXT_ERROR);\n            goto err;\n        }\n    }\n\n    r = 1;\n\n err:\n    if (tmpout != out)\n        BIO_free(tmpout);\n    return r;\n\n}\n","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":43463,"func":"base64_flush(TScreen *screen)\n{\n    Char x;\n\n    TRACE((\"base64_flush count %d, pad %d (%d)\\n\",\n\t   screen->base64_count,\n\t   screen->base64_pad,\n\t   screen->base64_pad & 3));\n\n    switch (screen->base64_count) {\n    case 0:\n\tbreak;\n    case 2:\n\tx = CharOf(base64_code[screen->base64_accu << 4]);\n\ttty_vwrite(screen->respond, &x, 1);\n\tbreak;\n    case 4:\n\tx = CharOf(base64_code[screen->base64_accu << 2]);\n\ttty_vwrite(screen->respond, &x, 1);\n\tbreak;\n    }\n    if (screen->base64_pad & 3) {\n\ttty_vwrite(screen->respond,\n\t\t   (const Char *) \"===\",\n\t\t   (unsigned) (3 - (screen->base64_pad & 3)));\n    }\n    screen->base64_count = 0;\n    screen->base64_accu = 0;\n    screen->base64_pad = 0;\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":164519,"func":"error::Error GLES2DecoderPassthroughImpl::DoGetTexParameterfv(GLenum target,\n                                                              GLenum pname,\n                                                              GLsizei bufsize,\n                                                              GLsizei* length,\n                                                              GLfloat* params) {\n  api()->glGetTexParameterfvRobustANGLEFn(target, pname, bufsize, length,\n                                          params);\n  return error::kNoError;\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":358166,"func":"int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)\n{\n\tint\t\tloop_count = 0;\n\tint\t\tres;\n\n\t\/* Always search-by-index from the beginning of the cache *\/\n\tif (*desc->dir_cookie == 0) {\n\t\tdfprintk(DIRCACHE, \"NFS: readdir_search_pagecache() searching for offset %Ld\\n\",\n\t\t\t\t(long long)desc->file->f_pos);\n\t\tdesc->page_index = 0;\n\t\tdesc->entry->cookie = desc->entry->prev_cookie = 0;\n\t\tdesc->entry->eof = 0;\n\t\tdesc->current_index = 0;\n\t} else\n\t\tdfprintk(DIRCACHE, \"NFS: readdir_search_pagecache() searching for cookie %Lu\\n\",\n\t\t\t\t(unsigned long long)*desc->dir_cookie);\n\n\tfor (;;) {\n\t\tres = find_dirent_page(desc);\n\t\tif (res != -EAGAIN)\n\t\t\tbreak;\n\t\t\/* Align to beginning of next page *\/\n\t\tdesc->page_index ++;\n\t\tif (loop_count++ > 200) {\n\t\t\tloop_count = 0;\n\t\t\tschedule();\n\t\t}\n\t}\n\n\tdfprintk(DIRCACHE, \"NFS: %s: returns %d\\n\", __FUNCTION__, res);\n\treturn res;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":97968,"func":"static void mip6_addr_swap(struct sk_buff *skb)\n{\n\tstruct ipv6hdr *iph = ipv6_hdr(skb);\n\tstruct inet6_skb_parm *opt = IP6CB(skb);\n\tstruct ipv6_destopt_hao *hao;\n\tstruct in6_addr tmp;\n\tint off;\n\n\tif (opt->dsthao) {\n\t\toff = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO);\n\t\tif (likely(off >= 0)) {\n\t\t\thao = (struct ipv6_destopt_hao *)\n\t\t\t\t\t(skb_network_header(skb) + off);\n\t\t\ttmp = iph->saddr;\n\t\t\tiph->saddr = hao->addr;\n\t\t\thao->addr = tmp;\n\t\t}\n\t}\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":122605,"func":"enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":461365,"func":"int g_dhcp_server_start(GDHCPServer *dhcp_server)\n{\n\tGIOChannel *listener_channel;\n\tint listener_sockfd;\n\n\tif (dhcp_server->started)\n\t\treturn 0;\n\n\tlistener_sockfd = dhcp_l3_socket(SERVER_PORT,\n\t\t\t\t\tdhcp_server->interface, AF_INET);\n\tif (listener_sockfd < 0)\n\t\treturn -EIO;\n\n\tlistener_channel = g_io_channel_unix_new(listener_sockfd);\n\tif (!listener_channel) {\n\t\tclose(listener_sockfd);\n\t\treturn -EIO;\n\t}\n\n\tdhcp_server->listener_sockfd = listener_sockfd;\n\tdhcp_server->listener_channel = listener_channel;\n\n\tg_io_channel_set_close_on_unref(listener_channel, TRUE);\n\tdhcp_server->listener_watch =\n\t\t\tg_io_add_watch_full(listener_channel, G_PRIORITY_HIGH,\n\t\t\t\tG_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP,\n\t\t\t\t\t\tlistener_event, dhcp_server,\n\t\t\t\t\t\t\t\tNULL);\n\tg_io_channel_unref(dhcp_server->listener_channel);\n\n\tdhcp_server->started = TRUE;\n\n\treturn 0;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":487670,"func":"  void SendToHost(v8::Isolate* isolate,\n                  gin_helper::ErrorThrower thrower,\n                  const std::string& channel,\n                  v8::Local<v8::Value> arguments) {\n    if (!electron_ipc_remote_) {\n      thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);\n      return;\n    }\n    blink::CloneableMessage message;\n    if (!electron::SerializeV8Value(isolate, arguments, &message)) {\n      return;\n    }\n    electron_ipc_remote_->MessageHost(channel, std::move(message));\n  }","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":51976,"func":"static void kvmclock_update_fn(struct work_struct *work)\n{\n\tint i;\n\tstruct delayed_work *dwork = to_delayed_work(work);\n\tstruct kvm_arch *ka = container_of(dwork, struct kvm_arch,\n\t\t\t\t\t   kvmclock_update_work);\n\tstruct kvm *kvm = container_of(ka, struct kvm, arch);\n\tstruct kvm_vcpu *vcpu;\n\n\tkvm_for_each_vcpu(i, vcpu, kvm) {\n\t\tkvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);\n\t\tkvm_vcpu_kick(vcpu);\n\t}\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":270767,"func":"int cil_resolve_classmapping(struct cil_tree_node *current, void *extra_args)\n{\n\tint rc = SEPOL_ERR;\n\tstruct cil_classmapping *mapping = current->data;\n\tstruct cil_class *map = NULL;\n\tstruct cil_perm *mp = NULL;\n\tstruct cil_symtab_datum *datum = NULL;\n\tstruct cil_list_item *curr;\n\n\trc = cil_resolve_name(current, mapping->map_class_str, CIL_SYM_CLASSES, extra_args, &datum);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\tmap = (struct cil_class*)datum;\n\n\trc = cil_symtab_get_datum(&map->perms, mapping->map_perm_str, &datum);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tmp = (struct cil_perm*)datum;\n\n\trc = cil_resolve_classperms_list(current, mapping->classperms, extra_args);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tif (mp->classperms == NULL) {\n\t\tcil_list_init(&mp->classperms, CIL_CLASSPERMS);\n\t}\n\n\tcil_list_for_each(curr, mapping->classperms) {\n\t\tcil_list_append(mp->classperms, curr->flavor, curr->data);\n\t}\n\n\treturn SEPOL_OK;\n\nexit:\n\treturn rc;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":267992,"func":"SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size)\n{\n\tint err;\n\n\tstruct kernel_clone_args kargs;\n\tpid_t set_tid[MAX_PID_NS_LEVEL];\n\n\tkargs.set_tid = set_tid;\n\n\terr = copy_clone_args_from_user(&kargs, uargs, size);\n\tif (err)\n\t\treturn err;\n\n\tif (!clone3_args_valid(&kargs))\n\t\treturn -EINVAL;\n\n\treturn kernel_clone(&kargs);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":5583,"func":"static int amd_gpio_remove(struct platform_device *pdev)\n{\n\tstruct amd_gpio *gpio_dev;\n\n\tgpio_dev = platform_get_drvdata(pdev);\n\n\tgpiochip_remove(&gpio_dev->gc);\n\tpinctrl_unregister(gpio_dev->pctrl);\n\n\treturn 0;\n}","target":1,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":264665,"func":"void bpf_register_map_type(struct bpf_map_type_list *tl)\n{\n\tlist_add(&tl->list_node, &bpf_map_types);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":5351,"func":"static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)\n{\n\tstruct rtnl_link_ifmap map = {\n\t\t.mem_start   = dev->mem_start,\n\t\t.mem_end     = dev->mem_end,\n\t\t.base_addr   = dev->base_addr,\n\t\t.irq         = dev->irq,\n\t\t.dma         = dev->dma,\n\t\t.port        = dev->if_port,\n\t};\n\tif (nla_put(skb, IFLA_MAP, sizeof(map), &map))\n\t\treturn -EMSGSIZE;\n\n\treturn 0;\n}","target":1,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":94499,"func":"static BOOL rdp_write_desktop_composition_capability_set(wStream* s, const rdpSettings* settings)\n{\n\tsize_t header;\n\tUINT16 compDeskSupportLevel;\n\n\tif (!Stream_EnsureRemainingCapacity(s, 32))\n\t\treturn FALSE;\n\n\theader = rdp_capability_set_start(s);\n\tcompDeskSupportLevel =\n\t    (settings->AllowDesktopComposition) ? COMPDESK_SUPPORTED : COMPDESK_NOT_SUPPORTED;\n\tStream_Write_UINT16(s, compDeskSupportLevel); \/* compDeskSupportLevel (2 bytes) *\/\n\trdp_capability_set_finish(s, header, CAPSET_TYPE_COMP_DESK);\n\treturn TRUE;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":12720,"func":"GURL GetFileManagerBaseUrl() {\n  return GetFileManagerUrl(\"\/\");\n}\n","target":1,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":491234,"func":"TPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_CC) {\n\t    rc = TPM_RC_SIZE;\n\t    target->count = 0; \/\/ libtpms added\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPM_CC_Unmarshal(&target->commandCodes[i], buffer, size);\n    }\n    return rc;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":10150,"func":" std::unique_ptr<SymmetricKey> CopyDefaultPaddingKey() {\n  return SymmetricKey::Import(kPaddingKeyAlgorithm, (*GetPaddingKey())->key());\n }\n","target":1,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":420078,"func":"check_and_set_stop_copy(struct nfsd4_copy *copy)\n{\n\tbool value;\n\n\tspin_lock(©->cp_clp->async_lock);\n\tvalue = copy->stopped;\n\tif (!copy->stopped)\n\t\tcopy->stopped = true;\n\tspin_unlock(©->cp_clp->async_lock);\n\treturn value;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":144965,"func":"static int aac_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))\n{\n\tstruct Scsi_Host *host = cmd->device->host;\n\tstruct aac_dev *dev = (struct aac_dev *)host->hostdata;\n\tu32 count = 0;\n\tcmd->scsi_done = done;\n\tfor (; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {\n\t\tstruct fib * fib = &dev->fibs[count];\n\t\tstruct scsi_cmnd * command;\n\t\tif (fib->hw_fib_va->header.XferState &&\n\t\t    ((command = fib->callback_data)) &&\n\t\t    (command == cmd) &&\n\t\t    (cmd->SCp.phase == AAC_OWNER_FIRMWARE))\n\t\t\treturn 0; \/* Already owned by Adapter *\/\n\t}\n\tcmd->SCp.phase = AAC_OWNER_LOWLEVEL;\n\treturn (aac_scsi_cmd(cmd) ? FAILED : 0);\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":49357,"func":"void Parser::TrackAssignment(ParseNodePtr pnodeT, IdentToken* pToken)\n{\n    if (buildAST)\n    {\n        Assert(pnodeT != nullptr);\n        if (pnodeT->nop == knopName)\n        {\n            PidRefStack *ref = pnodeT->sxPid.pid->GetTopRef();\n            Assert(ref);\n            ref->isAsg = true;\n        }\n    }\n    else\n    {\n        Assert(pToken != nullptr);\n        if (pToken->tk == tkID)\n        {\n            PidRefStack *ref = pToken->pid->GetTopRef();\n            Assert(ref);\n            ref->isAsg = true;\n        }\n    }\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":132876,"func":"Pl_AES_PDF::useStaticIV()\n{\n    use_static_iv = true;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":166422,"func":"e1000e_is_tcp_ack(E1000ECore *core, struct NetRxPkt *rx_pkt)\n{\n    if (!net_rx_pkt_is_tcp_ack(rx_pkt)) {\n        return false;\n    }\n\n    if (core->mac[RFCTL] & E1000_RFCTL_ACK_DATA_DIS) {\n        return !net_rx_pkt_has_tcp_data(rx_pkt);\n    }\n\n    return true;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":193549,"func":"bool RenderThreadImpl::IsElasticOverscrollEnabled() {\n  return is_elastic_overscroll_enabled_;\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":54545,"func":"set_alignment(struct readbuffer *obuf, struct parsed_tag *tag)\n{\n    long flag = -1;\n    int align;\n\n    if (parsedtag_get_value(tag, ATTR_ALIGN, &align)) {\n\tswitch (align) {\n\tcase ALIGN_CENTER:\n\t    flag = RB_CENTER;\n\t    break;\n\tcase ALIGN_RIGHT:\n\t    flag = RB_RIGHT;\n\t    break;\n\tcase ALIGN_LEFT:\n\t    flag = RB_LEFT;\n\t}\n    }\n    RB_SAVE_FLAG(obuf);\n    if (flag != -1) {\n\tRB_SET_ALIGN(obuf, flag);\n    }\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":164497,"func":"  LayerTreeHostTestSetNeedsRedrawRect()\n      : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":401836,"func":"ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV)\n{\n\tUSE_OPLINE\n\tzend_free_op free_op1, free_op2;\n\tzval *container;\n\n\tSAVE_OPLINE();\n\tcontainer = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);\n\tzend_fetch_dimension_address_RW(container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE OPLINE_CC EXECUTE_DATA_CC);\n\tFREE_OP2();\n\tif (OP1_TYPE == IS_VAR) {\n\t\tzval *result = EX_VAR(opline->result.var);\n\t\tFREE_VAR_PTR_AND_EXTRACT_RESULT_IF_NECESSARY(free_op1, result);\n\t}\n\tZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":521404,"func":"bool sys_var_pluginvar::session_update(THD *thd, set_var *var)\n{\n  DBUG_ASSERT(!is_readonly());\n  DBUG_ASSERT(plugin_var->flags & PLUGIN_VAR_THDLOCAL);\n  DBUG_ASSERT(thd == current_thd);\n\n  mysql_mutex_lock(&LOCK_global_system_variables);\n  void *tgt= real_value_ptr(thd, OPT_SESSION);\n  const void *src= var->value ? (void*)&var->save_result\n                              : (void*)real_value_ptr(thd, OPT_GLOBAL);\n  mysql_mutex_unlock(&LOCK_global_system_variables);\n\n  plugin_var->update(thd, plugin_var, tgt, src);\n\n  return false;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":110519,"func":"static inline __be16 pppoe_proto(const struct sk_buff *skb)\n{\n\treturn *((__be16 *)(skb_mac_header(skb) + ETH_HLEN +\n\t\t\t    sizeof(struct pppoe_hdr)));\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":276634,"func":"bool IsAppLauncherEnabledAtLevel(InstallationLevel level) {\n  string16 uninstall_arguments;\n  if (GetClientStateValue(level,\n                          kAppHostAppId,\n                          kUninstallArgumentsField,\n                          &uninstall_arguments)) {\n    return CommandLine::FromString(L\"dummy.exe \" + uninstall_arguments)\n        .HasSwitch(kChromeAppLauncher) &&\n        !GetAppHostPathForInstallationLevel(level).empty();\n  }\n  return false;\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":214942,"func":"void GLES2DecoderImpl::OnOutOfMemoryError() {\n  if (lose_context_when_out_of_memory_) {\n    group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB);\n  }\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":281867,"func":"MagickExport ssize_t WriteBlobSignedLong(Image *image,const signed int value)\n{\n  union\n  {\n    unsigned int\n      unsigned_value;\n\n    signed int\n      signed_value;\n  } quantum;\n\n  unsigned char\n    buffer[4];\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  quantum.signed_value=value;\n  if (image->endian == LSBEndian)\n    {\n      buffer[0]=(unsigned char) quantum.unsigned_value;\n      buffer[1]=(unsigned char) (quantum.unsigned_value >> 8);\n      buffer[2]=(unsigned char) (quantum.unsigned_value >> 16);\n      buffer[3]=(unsigned char) (quantum.unsigned_value >> 24);\n      return(WriteBlobStream(image,4,buffer));\n    }\n  buffer[0]=(unsigned char) (quantum.unsigned_value >> 24);\n  buffer[1]=(unsigned char) (quantum.unsigned_value >> 16);\n  buffer[2]=(unsigned char) (quantum.unsigned_value >> 8);\n  buffer[3]=(unsigned char) quantum.unsigned_value;\n  return(WriteBlobStream(image,4,buffer));\n}\n","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":422247,"func":"ews_store_ensure_unique_path (CamelEwsStore *ews_store,\n\t\t\t      gchar **ppath)\n{\n\tgboolean done;\n\tguint counter = 0;\n\tgchar *base_path = NULL;\n\n\tg_return_if_fail (ews_store != NULL);\n\tg_return_if_fail (ews_store->summary != NULL);\n\tg_return_if_fail (ppath != NULL);\n\tg_return_if_fail (*ppath != NULL);\n\n\tdone = FALSE;\n\twhile (!done) {\n\t\tgchar *fid;\n\n\t\tdone = TRUE;\n\n\t\tfid = camel_ews_store_summary_get_folder_id_from_name (ews_store->summary, *ppath);\n\t\tif (fid) {\n\t\t\tg_free (fid);\n\n\t\t\tdone = FALSE;\n\t\t\tcounter++;\n\t\t\tif (!counter) {\n\t\t\t\tg_debug (\"%s: Counter overflow\", G_STRFUNC);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!base_path)\n\t\t\t\tbase_path = *ppath;\n\t\t\telse\n\t\t\t\tg_free (*ppath);\n\n\t\t\t*ppath = g_strdup_printf (\"%s_%u\", base_path, counter);\n\t\t}\n\t}\n\n\tg_free (base_path);\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":434008,"func":"static void vrend_renderer_use_threaded_sync(void)\n{\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":167464,"func":"static inline float fung(float x)\n{\n\tif (x >= 6.0f \/ 29.0f)\n\t\treturn x * x * x;\n\treturn (108.0f \/ 841.0f) * (x - (4.0f \/ 29.0f));\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":447632,"func":"UINT rdpgfx_write_color32(wStream* s, const RDPGFX_COLOR32* color32)\n{\n\tStream_Write_UINT8(s, color32->B);  \/* B (1 byte) *\/\n\tStream_Write_UINT8(s, color32->G);  \/* G (1 byte) *\/\n\tStream_Write_UINT8(s, color32->R);  \/* R (1 byte) *\/\n\tStream_Write_UINT8(s, color32->XA); \/* XA (1 byte) *\/\n\treturn CHANNEL_RC_OK;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":97926,"func":"error_t socketBind(Socket *socket, const IpAddr *localIpAddr, uint16_t localPort)\n{\n   \/\/Check input parameters\n   if(!socket || !localIpAddr)\n      return ERROR_INVALID_PARAMETER;\n   \/\/Make sure the socket type is correct\n   if(socket->type != SOCKET_TYPE_STREAM && socket->type != SOCKET_TYPE_DGRAM)\n      return ERROR_INVALID_SOCKET;\n\n   \/\/Associate the specified IP address and port number\n   socket->localIpAddr = *localIpAddr;\n   socket->localPort = localPort;\n\n   \/\/No error to report\n   return NO_ERROR;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":261791,"func":"i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf)\n{\n\tstruct i40e_aqc_configure_partition_bw_data bw_data;\n\ti40e_status status;\n\n\t\/* Set the valid bit for this PF *\/\n\tbw_data.pf_valid_bits = cpu_to_le16(BIT(pf->hw.pf_id));\n\tbw_data.max_bw[pf->hw.pf_id] = pf->max_bw & I40E_ALT_BW_VALUE_MASK;\n\tbw_data.min_bw[pf->hw.pf_id] = pf->min_bw & I40E_ALT_BW_VALUE_MASK;\n\n\t\/* Set the new bandwidths *\/\n\tstatus = i40e_aq_configure_partition_bw(&pf->hw, &bw_data, NULL);\n\n\treturn status;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":515613,"func":"int setup_tests(void)\n{\n    ADD_TEST(test_x509_cmp_time_current);\n    ADD_ALL_TESTS(test_x509_cmp_time, OSSL_NELEM(x509_cmp_tests));\n    ADD_ALL_TESTS(test_x509_time, OSSL_NELEM(x509_format_tests));\n    ADD_ALL_TESTS(test_days, OSSL_NELEM(day_of_week_tests));\n    ADD_ALL_TESTS(test_x509_time_print, OSSL_NELEM(x509_print_tests));\n    return 1;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":500907,"func":"void dvcC_box_del(GF_Box *s)\n{\n\tGF_DOVIConfigurationBox *ptr = (GF_DOVIConfigurationBox*)s;\n\tgf_free(ptr);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":106179,"func":"unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *writable)\n{\n\tstruct kvm_memory_slot *slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);\n\n\treturn gfn_to_hva_memslot_prot(slot, gfn, writable);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":233482,"func":"Document* Document::ParentDocument() const {\n  if (!frame_)\n    return nullptr;\n  Frame* parent = frame_->Tree().Parent();\n  if (!parent || !parent->IsLocalFrame())\n    return nullptr;\n  return ToLocalFrame(parent)->GetDocument();\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":431853,"func":"int kvm_coalesced_mmio_init(struct kvm *kvm)\n{\n\tstruct page *page;\n\tint ret;\n\n\tret = -ENOMEM;\n\tpage = alloc_page(GFP_KERNEL | __GFP_ZERO);\n\tif (!page)\n\t\tgoto out_err;\n\n\tret = 0;\n\tkvm->coalesced_mmio_ring = page_address(page);\n\n\t\/*\n\t * We're using this spinlock to sync access to the coalesced ring.\n\t * The list doesn't need it's own lock since device registration and\n\t * unregistration should only happen when kvm->slots_lock is held.\n\t *\/\n\tspin_lock_init(&kvm->ring_lock);\n\tINIT_LIST_HEAD(&kvm->coalesced_zones);\n\nout_err:\n\treturn ret;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":477398,"func":"static void apic_sync_pv_eoi_from_guest(struct kvm_vcpu *vcpu,\n\t\t\t\t\tstruct kvm_lapic *apic)\n{\n\tint vector;\n\t\/*\n\t * PV EOI state is derived from KVM_APIC_PV_EOI_PENDING in host\n\t * and KVM_PV_EOI_ENABLED in guest memory as follows:\n\t *\n\t * KVM_APIC_PV_EOI_PENDING is unset:\n\t * \t-> host disabled PV EOI.\n\t * KVM_APIC_PV_EOI_PENDING is set, KVM_PV_EOI_ENABLED is set:\n\t * \t-> host enabled PV EOI, guest did not execute EOI yet.\n\t * KVM_APIC_PV_EOI_PENDING is set, KVM_PV_EOI_ENABLED is unset:\n\t * \t-> host enabled PV EOI, guest executed EOI.\n\t *\/\n\tBUG_ON(!pv_eoi_enabled(vcpu));\n\n\tif (pv_eoi_test_and_clr_pending(vcpu))\n\t\treturn;\n\tvector = apic_set_eoi(apic);\n\ttrace_kvm_pv_eoi(apic, vector);\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":339777,"func":"const char *qemu_opt_get(QemuOpts *opts, const char *name)\n\n{\n\n    QemuOpt *opt = qemu_opt_find(opts, name);\n\n\n\n    if (!opt) {\n\n        const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);\n\n        if (desc && desc->def_value_str) {\n\n            return desc->def_value_str;\n\n        }\n\n    }\n\n    return opt ? opt->str : NULL;\n\n}\n","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":404926,"func":"static void l2cap_pass_to_tx_fbit(struct l2cap_chan *chan,\n\t\t\t\t  struct l2cap_ctrl *control)\n{\n\tBT_DBG(\"chan %p, control %p\", chan, control);\n\tl2cap_tx(chan, control, NULL, L2CAP_EV_RECV_FBIT);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":291046,"func":"TEST(HostsPerLocalityImpl, Empty) {\n  EXPECT_FALSE(HostsPerLocalityImpl::empty()->hasLocalLocality());\n  EXPECT_EQ(0, HostsPerLocalityImpl::empty()->get().size());\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":258338,"func":"static void lance_init ( NICInfo * nd , hwaddr leaddr , void * dma_opaque , qemu_irq irq ) {\n DeviceState * dev ;\n SysBusDevice * s ;\n qemu_irq reset ;\n qemu_check_nic_model ( & nd_table [ 0 ] , \"lance\" ) ;\n dev = qdev_create ( NULL , \"lance\" ) ;\n qdev_set_nic_properties ( dev , nd ) ;\n qdev_prop_set_ptr ( dev , \"dma\" , dma_opaque ) ;\n qdev_init_nofail ( dev ) ;\n s = SYS_BUS_DEVICE ( dev ) ;\n sysbus_mmio_map ( s , 0 , leaddr ) ;\n sysbus_connect_irq ( s , 0 , irq ) ;\n reset = qdev_get_gpio_in ( dev , 0 ) ;\n qdev_connect_gpio_out ( dma_opaque , 0 , reset ) ;\n }","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":60165,"func":"void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f)\n{\n\tif (!f)\n\t\treturn;\n\n\t\/* If the filter was never added to firmware then we can just delete it\n\t * directly and we don't want to set the status to remove or else an\n\t * admin queue command will unnecessarily fire.\n\t *\/\n\tif ((f->state == I40E_FILTER_FAILED) ||\n\t    (f->state == I40E_FILTER_NEW)) {\n\t\thash_del(&f->hlist);\n\t\tkfree(f);\n\t} else {\n\t\tf->state = I40E_FILTER_REMOVE;\n\t}\n\n\tvsi->flags |= I40E_VSI_FLAG_FILTER_CHANGED;\n\tset_bit(__I40E_MACVLAN_SYNC_PENDING, vsi->back->state);\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":452174,"func":"tcpip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip)\n{\n    conv_hash_t *hash = (conv_hash_t*) pct;\n    const struct tcpheader *tcphdr=(const struct tcpheader *)vip;\n\n    add_conversation_table_data_with_conv_id(hash, &tcphdr->ip_src, &tcphdr->ip_dst, tcphdr->th_sport, tcphdr->th_dport, (conv_id_t) tcphdr->th_stream, 1, pinfo->fd->pkt_len,\n                                              &pinfo->rel_ts, &pinfo->abs_ts, &tcp_ct_dissector_info, ENDPOINT_TCP);\n\n    return TAP_PACKET_REDRAW;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":419555,"func":"void copy_structures(struct activity *act[], unsigned int id_seq[],\n\t\t     struct record_header record_hdr[], int dest, int src)\n{\n\tint i, p;\n\n\tmemcpy(&record_hdr[dest], &record_hdr[src], RECORD_HEADER_SIZE);\n\n\tfor (i = 0; i < NR_ACT; i++) {\n\n\t\tif (!id_seq[i])\n\t\t\tcontinue;\n\n\t\tp = get_activity_position(act, id_seq[i], EXIT_IF_NOT_FOUND);\n\n\t\tmemcpy(act[p]->buf[dest], act[p]->buf[src],\n\t\t       (size_t) act[p]->msize * (size_t) act[p]->nr[src] * (size_t) act[p]->nr2);\n\t\tact[p]->nr[dest] = act[p]->nr[src];\n\t}\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":392486,"func":"static inline void Process_ipfix_template_withdraw(exporter_ipfix_domain_t *exporter, void *DataPtr, uint32_t size_left, FlowSource_t *fs) {\nipfix_template_record_t *ipfix_template_record;\n\n\t\/\/ a template flowset can contain multiple records ( templates )\n\twhile ( size_left ) {\n\t\tuint32_t id, count;\n\n\t\t\/\/ map next record.\n\t\tipfix_template_record = (ipfix_template_record_t *)DataPtr;\n\t\tsize_left \t\t-= 4;\n\n\t\tid \t  = ntohs(ipfix_template_record->TemplateID);\n\t\tcount = ntohs(ipfix_template_record->FieldCount);\n\n\t\tif ( id == IPFIX_TEMPLATE_FLOWSET_ID ) {\n\t\t\t\/\/ withdraw all templates\n\t\t\tremove_all_translation_tables(exporter);\n\t\t\tReInitExtensionMapList(fs);\n\t\t} else {\n\t\t\tremove_translation_table(fs, exporter, id);\n\t\t}\n\n\t\tDataPtr = DataPtr + 4;\n\t\tif ( size_left < 4 ) {\n\t\t\t\/\/ pading\n\t\t\tdbg_printf(\"Skip %u bytes padding\\n\", size_left);\n\t\t\tsize_left = 0;\n\t\t}\n\t}\n \n} \/\/ End of Process_ipfix_template_withdraw","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":153220,"func":"static Jsi_OpCodes *code_jtrue_np(int off) { JSI_NEW_CODES(0,OP_JTRUE_NP, off); }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":275117,"func":"  render_state_set_size( RenderState  state,\n                         float        char_size )\n  {\n    state->char_size    = char_size;\n    state->need_rescale = 1;\n  }\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":468499,"func":"testcase_resetsolverflags(Solver *solv)\n{\n  int i;\n  for (i = 0; solverflags2str[i].str; i++)\n    solver_set_flag(solv, solverflags2str[i].flag, solverflags2str[i].def);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":47583,"func":"destroy_string_fifo(\n\tstring_fifo *\tfifo\n\t)\n{\n\tstring_node *\tsn;\n\n\tif (fifo != NULL) {\n\t\tdo {\n\t\t\tUNLINK_FIFO(sn, *fifo, link);\n\t\t\tif (sn != NULL) {\n\t\t\t\tif (sn->s != NULL)\n\t\t\t\t\tfree(sn->s);\n\t\t\t\tfree(sn);\n\t\t\t}\n\t\t} while (sn != NULL);\n\t\tfree(fifo);\n\t}\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":480308,"func":"static inline void req_set_fail(struct io_kiocb *req)\n{\n\treq->flags |= REQ_F_FAIL;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":317469,"func":"_dbus_header_cache_check (DBusHeader    *header,\n                          int            field)\n{\n  _dbus_assert (field <= DBUS_HEADER_FIELD_LAST);\n\n  if (header->fields[field].value_pos == _DBUS_HEADER_FIELD_VALUE_UNKNOWN)\n    _dbus_header_cache_revalidate (header);\n\n  if (header->fields[field].value_pos == _DBUS_HEADER_FIELD_VALUE_NONEXISTENT)\n    return FALSE;\n\n  return TRUE;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":427593,"func":"void __init old_map_region(efi_memory_desc_t *md)\n{\n\tu64 start_pfn, end_pfn, end;\n\tunsigned long size;\n\tvoid *va;\n\n\tstart_pfn = PFN_DOWN(md->phys_addr);\n\tsize\t  = md->num_pages << PAGE_SHIFT;\n\tend\t  = md->phys_addr + size;\n\tend_pfn   = PFN_UP(end);\n\n\tif (pfn_range_is_mapped(start_pfn, end_pfn)) {\n\t\tva = __va(md->phys_addr);\n\n\t\tif (!(md->attribute & EFI_MEMORY_WB))\n\t\t\tefi_memory_uc((u64)(unsigned long)va, size);\n\t} else\n\t\tva = efi_ioremap(md->phys_addr, size,\n\t\t\t\t md->type, md->attribute);\n\n\tmd->virt_addr = (u64) (unsigned long) va;\n\tif (!va)\n\t\tpr_err(\"ioremap of 0x%llX failed!\\n\",\n\t\t       (unsigned long long)md->phys_addr);\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":438444,"func":"void SegmentInfo::set_writing_app(const char* app) {\n  if (app) {\n    const size_t length = strlen(app) + 1;\n    char* temp_str = new (std::nothrow) char[length];  \/\/ NOLINT\n    if (!temp_str)\n      return;\n\n#ifdef _MSC_VER\n    strcpy_s(temp_str, length, app);\n#else\n    strcpy(temp_str, app);\n#endif\n\n    delete[] writing_app_;\n    writing_app_ = temp_str;\n  }\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":157045,"func":"DECLAREContigPutFunc(put4bitcmaptile)\n{\n    uint32** PALmap = img->PALmap;\n\n    (void) x; (void) y;\n    fromskew \/= 2;\n    for( ; h > 0; --h) {\n\tuint32* bw;\n\tUNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++);\n\tcp += toskew;\n\tpp += fromskew;\n    }\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":482071,"func":"\nprivate void\nrestore_cont(struct magic_set *ms, struct cont *c)\n{\n\tefree(ms->c.li);","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":25047,"func":"static gcry_module_t gcry_pk_lookup_name ( const char * name ) {\n gcry_module_t pubkey ;\n pubkey = _gcry_module_lookup ( pubkeys_registered , ( void * ) name , gcry_pk_lookup_func_name ) ;\n return pubkey ;\n }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":296592,"func":"void i40e_vsi_remove_pvid(struct i40e_vsi *vsi)\n{\n\tvsi->info.pvid = 0;\n\n\ti40e_vlan_stripping_disable(vsi);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":300106,"func":"static int fastrpc_map_find(struct fastrpc_user *fl, int fd,\n\t\t\t    struct fastrpc_map **ppmap)\n{\n\tstruct fastrpc_map *map = NULL;\n\n\tmutex_lock(&fl->mutex);\n\tlist_for_each_entry(map, &fl->maps, node) {\n\t\tif (map->fd == fd) {\n\t\t\tfastrpc_map_get(map);\n\t\t\t*ppmap = map;\n\t\t\tmutex_unlock(&fl->mutex);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tmutex_unlock(&fl->mutex);\n\n\treturn -ENOENT;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":145885,"func":"bool CudnnSupport::DoXYPad(Stream* stream,\n                           const dnn::BatchDescriptor& dimensions,\n                           const DeviceMemory<float>& input_data,\n                           int64 left_pad, int64 right_pad, int64 top_pad,\n                           int64 bottom_pad, DeviceMemory<float>* output_data) {\n  LOG(FATAL) << \"not yet implemented\";  \/\/ TODO(leary)\n  return false;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":367043,"func":"int security_inode_setxattr(struct dentry *dentry, const char *name,\n\t\t\t    const void *value, size_t size, int flags)\n{\n\tif (unlikely(IS_PRIVATE(dentry->d_inode)))\n\t\treturn 0;\n\treturn security_ops->inode_setxattr(dentry, name, value, size, flags);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":412567,"func":"pk_transaction_get_packages (PkTransaction *transaction,\n\t\t\t     GVariant *params,\n\t\t\t     GDBusMethodInvocation *context)\n{\n\tPkBitfield filter;\n\tg_autoptr(GError) error = NULL;\n\n\tg_return_if_fail (PK_IS_TRANSACTION (transaction));\n\tg_return_if_fail (transaction->priv->tid != NULL);\n\n\tg_variant_get (params, \"(t)\",\n\t\t       &filter);\n\n\tg_debug (\"GetPackages method called: %\" G_GUINT64_FORMAT, filter);\n\n\t\/* not implemented yet *\/\n\tif (!pk_backend_is_implemented (transaction->priv->backend,\n\t\t\t\t\tPK_ROLE_ENUM_GET_PACKAGES)) {\n\t\tg_set_error (&error,\n\t\t\t     PK_TRANSACTION_ERROR,\n\t\t\t     PK_TRANSACTION_ERROR_NOT_SUPPORTED,\n\t\t\t     \"GetPackages not supported by backend\");\n\t\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR);\n\t\tgoto out;\n\t}\n\n\t\/* save so we can run later *\/\n\ttransaction->priv->cached_filters = filter;\n\tpk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_PACKAGES);\n\tpk_transaction_set_state (transaction, PK_TRANSACTION_STATE_READY);\nout:\n\tpk_transaction_dbus_return (context, error);\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":294094,"func":"static inline bool tcp_too_many_orphans(struct sock *sk, int shift)\n{\n\tstruct percpu_counter *ocp = sk->sk_prot->orphan_count;\n\tint orphans = percpu_counter_read_positive(ocp);\n\n\tif (orphans << shift > sysctl_tcp_max_orphans) {\n\t\torphans = percpu_counter_sum_positive(ocp);\n\t\tif (orphans << shift > sysctl_tcp_max_orphans)\n\t\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":159205,"func":"const char * CLASS foveon_camf_param (const char *block, const char *param)\n{\n  unsigned idx, num;\n  char *pos, *cp, *dp;\n\n  for (idx=0; idx < meta_length; idx += sget4(pos+8)) {\n    pos = meta_data + idx;\n    if (strncmp (pos, \"CMb\", 3)) break;\n    if (pos[3] != 'P') continue;\n    if (strcmp (block, pos+sget4(pos+12))) continue;\n    cp = pos + sget4(pos+16);\n    num = sget4(cp);\n    dp = pos + sget4(cp+4);\n    while (num--) {\n      cp += 8;\n      if (!strcmp (param, dp+sget4(cp)))\n\treturn dp+sget4(cp+4);\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":29829,"func":"static int dissect_h245_T_controlFieldOctets ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n # line 323 \"..\/..\/asn1\/h245\/h245.cnf\" guint32 value ;\n offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 0U , 2U , & value , FALSE ) ;\n if ( h223_lc_params_temp && h223_lc_params_temp -> al_params ) ( ( h223_al3_params * ) h223_lc_params_temp -> al_params ) -> control_field_octets = value & 3 ;\n return offset ;\n }","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":423461,"func":"dns_zone_getclass(dns_zone_t *zone) {\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\n\treturn (zone->rdclass);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":456210,"func":"get_root_window (xcb_connection_t *connection,\n                 int               screen_number)\n{\n        xcb_screen_t *screen = NULL;\n        xcb_screen_iterator_t iter;\n\n        iter = xcb_setup_roots_iterator (xcb_get_setup (connection));\n        while (iter.rem) {\n                if (screen_number == 0)\n                        screen = iter.data;\n                screen_number--;\n                xcb_screen_next (&iter);\n        }\n\n        if (screen != NULL) {\n                return screen->root;\n        }\n\n        return XCB_WINDOW_NONE;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":153108,"func":"  const FunctionDefLibrary* library() const override {\n    return &graph_def_.library();\n  }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":231280,"func":"void BaseAudioContext::ScheduleMainThreadCleanup() {\n  if (has_posted_cleanup_task_)\n    return;\n  PostCrossThreadTask(\n      *task_runner_, FROM_HERE,\n      CrossThreadBind(&BaseAudioContext::PerformCleanupOnMainThread,\n                      WrapCrossThreadPersistent(this)));\n  has_posted_cleanup_task_ = true;\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":85387,"func":"PHP_FUNCTION(imagedestroy)\n{\n\tzval *IM;\n\tgdImagePtr im;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"r\", &IM) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), \"Image\", le_gd)) == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\tzend_list_close(Z_RES_P(IM));\n\n\tRETURN_TRUE;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":168939,"func":"static void float32ArrayMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    v8SetReturnValue(info, imp->float32ArrayMethod());\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":230011,"func":"void DelegatedFrameHost::DidNotProduceFrame(const viz::BeginFrameAck& ack) {\n  DCHECK(!ack.has_damage);\n  support_->DidNotProduceFrame(ack);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":410635,"func":"static NETJOIN_REC *netjoin_find(IRC_SERVER_REC *server, const char *nick)\n{\n\tNETJOIN_SERVER_REC *srec;\n\tGSList *tmp;\n\n\tg_return_val_if_fail(server != NULL, NULL);\n\tg_return_val_if_fail(nick != NULL, NULL);\n\n\tsrec = netjoin_find_server(server);\n        if (srec == NULL) return NULL;\n\n\tfor (tmp = srec->netjoins; tmp != NULL; tmp = tmp->next) {\n\t\tNETJOIN_REC *rec = tmp->data;\n\n\t\tif (g_ascii_strcasecmp(rec->nick, nick) == 0)\n\t\t\treturn rec;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":75817,"func":"R_API RList *r_bin_get_mem(RBin *bin) {\n\tRBinObject *o = r_bin_cur_object (bin);\n\treturn o? o->mem: NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":100484,"func":"mariadb_field_attr(MARIADB_CONST_STRING *attr,\n                   const MYSQL_FIELD *field,\n                   enum mariadb_field_attr_t type)\n{\n  MA_FIELD_EXTENSION *ext= (MA_FIELD_EXTENSION*) field->extension;\n  if (!ext || type > MARIADB_FIELD_ATTR_LAST)\n  {\n    *attr= null_const_string;\n    return 1;\n  }\n  *attr= ext->metadata[type];\n  return 0;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":216898,"func":"void LoginDisplayHostWebUI::OnUserSwitchAnimationFinished() {\n  ShutdownDisplayHost();\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":320315,"func":"static gboolean nbd_negotiate_continue(QIOChannel *ioc,\n\n                                       GIOCondition condition,\n\n                                       void *opaque)\n\n{\n\n    qemu_coroutine_enter(opaque, NULL);\n\n    return TRUE;\n\n}\n","target":1,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":432152,"func":"static void line6_unlink_audio_urbs(struct snd_line6_pcm *line6pcm,\n\t\t\t\t    struct line6_pcm_stream *pcms)\n{\n\tint i;\n\n\tfor (i = 0; i < line6pcm->line6->iso_buffers; i++) {\n\t\tif (test_bit(i, &pcms->active_urbs)) {\n\t\t\tif (!test_and_set_bit(i, &pcms->unlink_urbs))\n\t\t\t\tusb_unlink_urb(pcms->urbs[i]);\n\t\t}\n\t}\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":241696,"func":"bool xmp_has_property(XmpPtr xmp, const char *schema, const char *name)\n{\n    CHECK_PTR(xmp, false);\n    RESET_ERROR;\n\n    bool ret = true;\n    auto txmp = reinterpret_cast<const SXMPMeta *>(xmp);\n    try {\n        ret = txmp->DoesPropertyExist(schema, name);\n    }\n    catch (const XMP_Error &e) {\n        set_error(e);\n        ret = false;\n    }\n    catch (...) {\n        ret = false;\n    }\n    return ret;\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":109354,"func":"static int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,\n\t\t\t   struct ndpi_flow_struct *flow) {\n  struct ndpi_packet_struct *packet = &flow->packet;\n\n  switch(packet->payload[0] \/* block type *\/) {\n  case 0x01: \/* Client Hello *\/\n  case 0x02: \/* Server Hello *\/\n    processClientServerHello(ndpi_struct, flow);\n    flow->l4.tcp.tls.hello_processed = 1;\n    ndpi_int_tls_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_TLS);\n    break;\n\n  case 0x0b: \/* Certificate *\/\n    \/* Important: populate the tls union fields only after\n     * ndpi_int_tls_add_connection has been called *\/\n    if(flow->l4.tcp.tls.hello_processed) {\n      processCertificate(ndpi_struct, flow);\n      flow->l4.tcp.tls.certificate_processed = 1;\n    }\n    break;\n\n  default:\n    return(-1);\n  }\n\n  return(0);\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":169886,"func":"sc_get_driver(void)\n{\n\tstruct sc_card_driver *iso_drv;\n\n\tiso_drv = sc_get_iso7816_driver();\n\tiso_ops = iso_drv->ops;\n\tgpk_ops = *iso_ops;\n\n\tgpk_ops.match_card\t= gpk_match_card;\n\tgpk_ops.init\t\t= gpk_init;\n\tgpk_ops.finish\t\t= gpk_finish;\n\tgpk_ops.select_file\t= gpk_select_file;\n\tgpk_ops.read_binary\t= gpk_read_binary;\n\tgpk_ops.write_binary\t= gpk_write_binary;\n\tgpk_ops.update_binary\t= gpk_update_binary;\n\tgpk_ops.create_file\t= gpk_create_file;\n\t\/* gpk_ops.check_sw\t= gpk_check_sw; *\/\n\tgpk_ops.card_ctl\t= gpk_card_ctl;\n\tgpk_ops.set_security_env= gpk_set_security_env;\n\tgpk_ops.restore_security_env= gpk_restore_security_env;\n\tgpk_ops.compute_signature= gpk_compute_signature;\n\tgpk_ops.decipher\t= gpk_decipher;\n\tgpk_ops.pin_cmd\t\t= gpk_pin_cmd;\n\n\treturn &gpk_drv;\n}\n","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":503736,"func":"void PacketBypassCallback(Packet *p)\n{\n    \/* Don't try to bypass if flow is already out or\n     * if we have failed to do it once *\/\n    int state = SC_ATOMIC_GET(p->flow->flow_state);\n    if ((state == FLOW_STATE_LOCAL_BYPASSED) ||\n           (state == FLOW_STATE_CAPTURE_BYPASSED)) {\n        return;\n    }\n\n    if (p->BypassPacketsFlow && p->BypassPacketsFlow(p)) {\n        FlowUpdateState(p->flow, FLOW_STATE_CAPTURE_BYPASSED);\n    } else {\n        FlowUpdateState(p->flow, FLOW_STATE_LOCAL_BYPASSED);\n    }\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":439588,"func":"__u32 skb_get_hash_perturb(const struct sk_buff *skb,\n\t\t\t   const siphash_key_t *perturb)\n{\n\tstruct flow_keys keys;\n\n\treturn ___skb_get_hash(skb, &keys, perturb);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":187755,"func":"bool TopSitesImpl::IsKnownURL(const GURL& url) {\n  return loaded_ && cache_->IsKnownURL(url);\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":433160,"func":"static int rds_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct rds_sock *rs;\n\n\tif (!sk)\n\t\tgoto out;\n\n\trs = rds_sk_to_rs(sk);\n\n\tsock_orphan(sk);\n\t\/* Note - rds_clear_recv_queue grabs rs_recv_lock, so\n\t * that ensures the recv path has completed messing\n\t * with the socket. *\/\n\trds_clear_recv_queue(rs);\n\trds_cong_remove_socket(rs);\n\n\trds_remove_bound(rs);\n\n\trds_send_drop_to(rs, NULL);\n\trds_rdma_drop_keys(rs);\n\trds_notify_queue_get(rs, NULL);\n\n\tspin_lock_bh(&rds_sock_lock);\n\tlist_del_init(&rs->rs_item);\n\trds_sock_count--;\n\tspin_unlock_bh(&rds_sock_lock);\n\n\trds_trans_put(rs->rs_transport);\n\n\tsock->sk = NULL;\n\tsock_put(sk);\nout:\n\treturn 0;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":244338,"func":"void ReportPrintSettingsStats(const DictionaryValue& settings) {\n  bool landscape;\n  if (settings.GetBoolean(printing::kSettingLandscape, &landscape))\n    ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT);\n\n  bool collate;\n  if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate)\n    ReportPrintSettingHistogram(COLLATE);\n\n  int duplex_mode;\n  if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))\n    ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX);\n\n  int color_mode;\n  if (settings.GetInteger(printing::kSettingColor, &color_mode)) {\n    ReportPrintSettingHistogram(\n        printing::isColorModelSelected(color_mode) ? COLOR : BLACK_AND_WHITE);\n  }\n}\n","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":306844,"func":"static inline pg_data_t *page_pgdat(const struct page *page)\n{\n\treturn NODE_DATA(page_to_nid(page));\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":279,"func":"static _Bool have_gcrypt ( void ) {\n static _Bool result = 0 ;\n static _Bool need_init = 1 ;\n if ( ! need_init ) return ( result ) ;\n need_init = 0 ;\n # if HAVE_LIBGCRYPT # if GCRYPT_VERSION_NUMBER < 0x010600 gcry_control ( GCRYCTL_SET_THREAD_CBS , & gcry_threads_pthread ) ;\n # endif if ( ! gcry_check_version ( GCRYPT_VERSION ) ) return ( 0 ) ;\n gcry_control ( GCRYCTL_INIT_SECMEM , 32768 , 0 ) ;\n gcry_control ( GCRYCTL_INITIALIZATION_FINISHED , 0 ) ;\n result = 1 ;\n return ( 1 ) ;\n # else return ( 0 ) ;\n # endif }","target":1,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":70201,"func":"void __perf_event_task_sched_in(struct task_struct *prev,\n\t\t\t\tstruct task_struct *task)\n{\n\tstruct perf_event_context *ctx;\n\tint ctxn;\n\n\tfor_each_task_context_nr(ctxn) {\n\t\tctx = task->perf_event_ctxp[ctxn];\n\t\tif (likely(!ctx))\n\t\t\tcontinue;\n\n\t\tperf_event_context_sched_in(ctx, task);\n\t}\n\t\/*\n\t * if cgroup events exist on this CPU, then we need\n\t * to check if we have to switch in PMU state.\n\t * cgroup event are system-wide mode only\n\t *\/\n\tif (atomic_read(&__get_cpu_var(perf_cgroup_events)))\n\t\tperf_cgroup_sched_in(prev, task);\n\n\t\/* check for system-wide branch_stack events *\/\n\tif (atomic_read(&__get_cpu_var(perf_branch_stack_events)))\n\t\tperf_branch_stack_sched_in(prev, task);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":517810,"func":"my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)\n{\n  DBUG_ASSERT(fixed == 1);\n  MYSQL_TIME ltime;\n  if (get_temporal_with_sql_mode(<ime))\n  {\n    my_decimal_set_zero(decimal_value);\n    null_value= 1;                               \/\/ set NULL, stop processing\n    return 0;\n  }\n  return date2my_decimal(<ime, decimal_value);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":10587,"func":"method_invocation_get_uid (GDBusMethodInvocation *context)\n{\n  const gchar *sender;\n  PolkitSubject *busname;\n  PolkitSubject *process;\n  uid_t uid;\n  sender = g_dbus_method_invocation_get_sender (context);\n  busname = polkit_system_bus_name_new (sender);\n  process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);\n  uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));\n  g_object_unref (busname);\n  g_object_unref (process);\n  return uid;\n}\n","target":1,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":368654,"func":"dir_networkstatus_download_failed(smartlist_t *failed, int status_code)\n{\n  if (status_code == 503)\n    return;\n  SMARTLIST_FOREACH(failed, const char *, fp,\n  {\n    char digest[DIGEST_LEN];\n    trusted_dir_server_t *dir;\n    if (base16_decode(digest, DIGEST_LEN, fp, strlen(fp))<0) {\n      log_warn(LD_BUG, \"Called with bad fingerprint in list: %s\",\n               escaped(fp));\n      continue;\n    }\n    dir = router_get_trusteddirserver_by_digest(digest);\n\n    if (dir)\n      download_status_failed(&dir->v2_ns_dl_status, status_code);\n  });\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":286327,"func":"static int compareNumbersForQSort(const void* a, const void* b)\n{\n    double da = static_cast<const JSValue*>(a)->uncheckedGetNumber();\n    double db = static_cast<const JSValue*>(b)->uncheckedGetNumber();\n    return (da > db) - (da < db);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":372535,"func":"\tint endBlockingModDir(request_rec *r) {\n\t\tRequestNote *note = getRequestNote(r);\n\t\tif (note != 0 && hasModDir()) {\n\t\t\tr->finfo.filetype = note->oldFileType;\n\t\t}\n\t\treturn DECLINED;\n\t}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":14102,"func":"void SafeBrowsingBlockingPage::DontProceed() {\n  DCHECK(action_taken() != DONT_PROCEED_ACTION);\n  if (action_taken() == PROCEED_ACTION) {\n    InterstitialPage::DontProceed();\n    return;\n  }\n\n  RecordUserAction(DONT_PROCEED);\n  FinishMalwareDetails(0);  \/\/ No delay\n\n  NotifySafeBrowsingService(sb_service_, unsafe_resources_, false);\n\n  UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();\n  UnsafeResourceMap::iterator iter = unsafe_resource_map->find(tab());\n  if (iter != unsafe_resource_map->end() && !iter->second.empty()) {\n    NotifySafeBrowsingService(sb_service_, iter->second, false);\n    unsafe_resource_map->erase(iter);\n  }\n \n  if (navigation_entry_index_to_remove_ != -1 && !tab()->is_being_destroyed()) {\n    tab()->controller().RemoveEntryAtIndex(navigation_entry_index_to_remove_,\n                                           GURL(chrome::kChromeUINewTabURL));\n     navigation_entry_index_to_remove_ = -1;\n   }\n   InterstitialPage::DontProceed();\n}\n","target":1,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":233570,"func":"void HTMLFormElement::associate(FormAssociatedElement& e) {\n  m_associatedElementsAreDirty = true;\n  m_associatedElements.clear();\n  if (toHTMLElement(e).fastHasAttribute(formAttr))\n    m_hasElementsAssociatedByFormAttribute = true;\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":65632,"func":"static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk)\n{\n\tstruct sighand_struct *sig;\n\n\tif (clone_flags & (CLONE_SIGHAND | CLONE_THREAD)) {\n\t\tatomic_inc(¤t->sighand->count);\n\t\treturn 0;\n\t}\n\tsig = kmem_cache_alloc(sighand_cachep, GFP_KERNEL);\n\trcu_assign_pointer(tsk->sighand, sig);\n\tif (!sig)\n\t\treturn -ENOMEM;\n\tatomic_set(&sig->count, 1);\n\tmemcpy(sig->action, current->sighand->action, sizeof(sig->action));\n\treturn 0;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":114430,"func":"struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,\n\t\t\t    struct ovl_entry *oe)\n{\n\tstruct inode *inode;\n\n\tinode = new_inode(sb);\n\tif (!inode)\n\t\treturn NULL;\n\n\tmode &= S_IFMT;\n\n\tinode->i_ino = get_next_ino();\n\tinode->i_mode = mode;\n\tinode->i_flags |= S_NOATIME | S_NOCMTIME;\n\n\tswitch (mode) {\n\tcase S_IFDIR:\n\t\tinode->i_private = oe;\n\t\tinode->i_op = &ovl_dir_inode_operations;\n\t\tinode->i_fop = &ovl_dir_operations;\n\t\tbreak;\n\n\tcase S_IFLNK:\n\t\tinode->i_op = &ovl_symlink_inode_operations;\n\t\tbreak;\n\n\tcase S_IFREG:\n\tcase S_IFSOCK:\n\tcase S_IFBLK:\n\tcase S_IFCHR:\n\tcase S_IFIFO:\n\t\tinode->i_op = &ovl_file_inode_operations;\n\t\tbreak;\n\n\tdefault:\n\t\tWARN(1, \"illegal file type: %i\\n\", mode);\n\t\tiput(inode);\n\t\tinode = NULL;\n\t}\n\n\treturn inode;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":338885,"func":"static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor)\n\n{\n\n    int code, value, ofs = 0;\n\n    char layout[16] = {};\n\n\n\n    do {\n\n        code = get_byte(pb);\n\n        value = get_byte(pb);\n\n        dprintf(NULL, \"pixel layout: code %#x\\n\", code);\n\n\n\n        if (ofs < 16) {\n\n            layout[ofs++] = code;\n\n            layout[ofs++] = value;\n\n        }\n\n    } while (code != 0); \/* SMPTE 377M E.2.46 *\/\n\n\n\n    ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt);\n\n}\n","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":188913,"func":"bool ChromeNetworkDelegate::OnCanGetCookies(\n    const net::URLRequest& request,\n    const net::CookieList& cookie_list) {\n  if (!cookie_settings_.get())\n    return true;\n\n  bool allow = cookie_settings_->IsReadingCookieAllowed(\n      request.url(), request.first_party_for_cookies());\n\n  int render_process_id = -1;\n  int render_view_id = -1;\n  if (content::ResourceRequestInfo::GetRenderViewForRequest(\n          &request, &render_process_id, &render_view_id)) {\n    BrowserThread::PostTask(\n        BrowserThread::UI, FROM_HERE,\n        base::Bind(&TabSpecificContentSettings::CookiesRead,\n                   render_process_id, render_view_id,\n                   request.url(), request.first_party_for_cookies(),\n                   cookie_list, !allow));\n  }\n\n  return allow;\n}\n","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":106724,"func":"static void cmd_anal_aad(RCore *core, const char *input) {\n\tRListIter *iter;\n\tRAnalRef *ref;\n\tRList *list = r_list_newf (NULL);\n\tr_anal_xrefs_from (core->anal, list, \"xref\", R_ANAL_REF_TYPE_DATA, UT64_MAX);\n\tr_list_foreach (list, iter, ref) {\n\t\tif (r_io_is_valid_offset (core->io, ref->addr, false)) {\n\t\t\tr_core_anal_fcn (core, ref->at, ref->addr, R_ANAL_REF_TYPE_NULL, 1);\n\t\t}\n\t}\n\tr_list_free (list);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":186212,"func":"void GLES2Implementation::DeleteSamplersStub(GLsizei n,\n                                             const GLuint* samplers) {\n  helper_->DeleteSamplersImmediate(n, samplers);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":509376,"func":"EC_POINT *EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group)\n\t{\n\tEC_POINT *t;\n\tint r;\n\n\tif (a == NULL) return NULL;\n\n\tt = EC_POINT_new(group);\n\tif (t == NULL) return(NULL);\n\tr = EC_POINT_copy(t, a);\n\tif (!r)\n\t\t{\n\t\tEC_POINT_free(t);\n\t\treturn NULL;\n\t\t}\n\telse return t;\n\t}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":420502,"func":"sparse_scan_file (struct tar_sparse_file *file)\n{\n  \/* always check for completely sparse files *\/\n  if (sparse_scan_file_wholesparse (file))\n    return true;\n\n  switch (hole_detection)\n    {\n    case HOLE_DETECTION_DEFAULT:\n    case HOLE_DETECTION_SEEK:\n#ifdef SEEK_HOLE\n      if (sparse_scan_file_seek (file))\n        return true;\n#else\n      if (hole_detection == HOLE_DETECTION_SEEK)\n\tWARN((0, 0,\n\t      _(\"\\\"seek\\\" hole detection is not supported, using \\\"raw\\\".\")));\n      \/* fall back to \"raw\" for this and all other files *\/\n      hole_detection = HOLE_DETECTION_RAW;\n#endif\n      FALLTHROUGH;\n    case HOLE_DETECTION_RAW:\n      if (sparse_scan_file_raw (file))\n\treturn true;\n    }\n\n  return false;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":144736,"func":"txInteger fxGetArrayBufferLength(txMachine* the, txSlot* slot)\n{\n\ttxSlot* instance = fxCheckArrayBufferInstance(the, slot);\n\ttxSlot* arrayBuffer = instance->next;\n\ttxSlot* bufferInfo = arrayBuffer->next;\n\treturn bufferInfo->value.bufferInfo.length;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":128313,"func":"check_for_string_or_number_or_list_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_STRING\n\t    && args[idx].v_type != VAR_NUMBER\n\t    && args[idx].v_type != VAR_LIST)\n    {\n\tsemsg(_(e_string_number_or_list_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":97665,"func":"static int io_shutdown(struct io_kiocb *req, unsigned int issue_flags)\n{\n#if defined(CONFIG_NET)\n\tstruct socket *sock;\n\tint ret;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tret = __sys_shutdown_sock(sock, req->shutdown.how);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":65543,"func":"TRIO_PUBLIC_STRING char* trio_string_index_last TRIO_ARGS2((self, character), trio_string_t* self,\n                                                           int character)\n{\n\tassert(self);\n\n\treturn trio_index_last(self->content, character);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":473150,"func":"tmx_m_of(union DateData *x)\n{\n    return m_of(x);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":88699,"func":"NodeDebugInfo::NodeDebugInfo(const Node& n) : NodeDebugInfo(n.def()) {}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":226575,"func":"static ZEND_RESULT_CODE parse_idn2(struct parse_state *state, size_t prev_len)\n{\n\tchar *idn = NULL;\n\tint rv = -1;\n\tTSRMLS_FETCH_FROM_CTX(state->ts);\n\n\tif (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) {\n\t\trv = idn2_lookup_u8((const unsigned char *) state->url.host, (unsigned char **) &idn, IDN2_NFC_INPUT);\n\t}\n#\tifdef PHP_HTTP_HAVE_WCHAR\n\telse if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) {\n\t\trv = idn2_lookup_ul(state->url.host, &idn, 0);\n\t}\n#\tendif\n\tif (rv != IDN2_OK) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Failed to parse IDN; %s\", idn2_strerror(rv));\n\t\treturn FAILURE;\n\t} else {\n\t\tsize_t idnlen = strlen(idn);\n\t\tmemcpy(state->url.host, idn, idnlen + 1);\n\t\tfree(idn);\n\t\tstate->offset += idnlen - prev_len;\n\t\treturn SUCCESS;\n\t}\n}\n","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":426621,"func":"static void locking_callback(int mode, int n, const char *file, int line) {\n  if(mode & CRYPTO_LOCK)\n    pni_mutex_lock(&locks[n]);\n  else\n    pni_mutex_unlock(&locks[n]);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":319601,"func":"static CharDriverState *qemu_chr_open_udp_fd(int fd)\n\n{\n\n    CharDriverState *chr = NULL;\n\n    NetCharDriver *s = NULL;\n\n\n\n    chr = g_malloc0(sizeof(CharDriverState));\n\n    s = g_malloc0(sizeof(NetCharDriver));\n\n\n\n    s->fd = fd;\n\n    s->chan = io_channel_from_socket(s->fd);\n\n    s->bufcnt = 0;\n\n    s->bufptr = 0;\n\n    chr->opaque = s;\n\n    chr->chr_write = udp_chr_write;\n\n    chr->chr_update_read_handler = udp_chr_update_read_handler;\n\n    chr->chr_close = udp_chr_close;\n\n    \/* be isn't opened until we get a connection *\/\n\n    chr->explicit_be_open = true;\n\n    return chr;\n\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":18371,"func":"static int selinux_tun_dev_alloc_security ( void * * security ) {\n struct tun_security_struct * tunsec ;\n tunsec = kzalloc ( sizeof ( * tunsec ) , GFP_KERNEL ) ;\n if ( ! tunsec ) return - ENOMEM ;\n tunsec -> sid = current_sid ( ) ;\n * security = tunsec ;\n return 0 ;\n }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":360107,"func":"nautilus_file_get_activation_uri (NautilusFile *file)\n{\n\tg_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);\n\n\tif (file->details->activation_location != NULL) {\n\t\treturn g_file_get_uri (file->details->activation_location);\n\t}\n\t\n\treturn nautilus_file_get_uri (file);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":86966,"func":"static TEE_Result load_elf(const TEE_UUID *uuid, struct user_ta_ctx *utc)\n{\n\tTEE_Result res;\n\tconst struct user_ta_store_ops *op = NULL;\n\n\tSCATTERED_ARRAY_FOREACH(op, ta_stores, struct user_ta_store_ops) {\n\t\tDMSG(\"Lookup user TA ELF %pUl (%s)\", (void *)uuid,\n\t\t     op->description);\n\n\t\tres = load_elf_from_store(uuid, op, utc);\n\t\tif (res == TEE_ERROR_ITEM_NOT_FOUND)\n\t\t\tcontinue;\n\t\tif (res) {\n\t\t\tDMSG(\"res=0x%x\", res);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn res;\n\t}\n\n\treturn TEE_ERROR_ITEM_NOT_FOUND;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":510740,"func":"int ha_partition::index_prev(uchar * buf)\n{\n  DBUG_ENTER(\"ha_partition::index_prev\");\n  decrement_statistics(&SSV::ha_read_prev_count);\n\n  \/* TODO: read comment in index_next *\/\n  DBUG_ASSERT(m_index_scan_type != partition_index_first);\n  DBUG_RETURN(handle_ordered_prev(buf));\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":166657,"func":"gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const {\n#if defined(OS_WIN)\n  aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();\n  if (dispatcher)\n    return reinterpret_cast<gfx::NativeViewId>(\n        dispatcher->host()->GetAcceleratedWidget());\n#endif\n  return static_cast<gfx::NativeViewId>(NULL);\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":131071,"func":"static void voice_link(struct VOICE_S *p_voice)\n{\n\tstruct VOICE_S *p_voice2;\n\n\tp_voice2 = first_voice;\n\tfor (;;) {\n\t\tif (p_voice2 == p_voice)\n\t\t\treturn;\n\t\tif (!p_voice2->next)\n\t\t\tbreak;\n\t\tp_voice2 = p_voice2->next;\n\t}\n\tp_voice2->next = p_voice;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":258324,"func":"static char * ReadBlobStringWithLongSize ( Image * image , char * string , size_t max , ExceptionInfo * exception ) {\n int c ;\n MagickOffsetType offset ;\n register ssize_t i ;\n size_t length ;\n assert ( image != ( Image * ) NULL ) ;\n assert ( image -> signature == MagickCoreSignature ) ;\n assert ( max != 0 ) ;\n if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , \"%s\" , image -> filename ) ;\n length = ReadBlobMSBLong ( image ) ;\n for ( i = 0 ;\n i < ( ssize_t ) MagickMin ( length , max - 1 ) ;\n i ++ ) {\n c = ReadBlobByte ( image ) ;\n if ( c == EOF ) return ( ( char * ) NULL ) ;\n string [ i ] = ( char ) c ;\n }\n string [ i ] = '\\0' ;\n offset = SeekBlob ( image , ( MagickOffsetType ) ( length - i ) , SEEK_CUR ) ;\n if ( offset < 0 ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , \"ImproperImageHeader\" , \"`%s'\" , image -> filename ) ;\n return ( string ) ;\n }","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":203117,"func":"bool PDFiumEngine::OnKeyUp(const pp::KeyboardInputEvent& event) {\n  if (last_page_mouse_down_ == -1)\n    return false;\n\n  return !!FORM_OnKeyUp(\n      form_, pages_[last_page_mouse_down_]->GetPage(),\n      event.GetKeyCode(), event.GetModifiers());\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":446417,"func":"virDomainDiskSourceFormatPrivateData(virBufferPtr buf,\n                                     virStorageSourcePtr src,\n                                     unsigned int flags,\n                                     virDomainXMLOptionPtr xmlopt)\n{\n    g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);\n\n    if (!(flags & VIR_DOMAIN_DEF_FORMAT_STATUS) ||\n        !xmlopt || !xmlopt->privateData.storageFormat)\n        return 0;\n\n    if (xmlopt->privateData.storageFormat(src, &childBuf) < 0)\n        return -1;\n\n    virXMLFormatElement(buf, \"privateData\", NULL, &childBuf);\n    return 0;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":209982,"func":"JSRetainPtr<JSStringRef> AccessibilityUIElement::description()\n{\n    if (!m_element || !ATK_IS_OBJECT(m_element))\n        return JSStringCreateWithCharacters(0, 0);\n\n    const gchar* description = atk_object_get_description(ATK_OBJECT(m_element));\n    if (!description)\n        return JSStringCreateWithCharacters(0, 0);\n\n    GOwnPtr<gchar> axDesc(g_strdup_printf(\"AXDescription: %s\", description));\n\n    return JSStringCreateWithUTF8CString(axDesc.get());\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":321736,"func":"static inline int vec_reg_offset(int regno, int element, TCGMemOp size)\n\n{\n\n    int offs = offsetof(CPUARMState, vfp.regs[regno * 2]);\n\n#ifdef HOST_WORDS_BIGENDIAN\n\n    \/* This is complicated slightly because vfp.regs[2n] is\n\n     * still the low half and  vfp.regs[2n+1] the high half\n\n     * of the 128 bit vector, even on big endian systems.\n\n     * Calculate the offset assuming a fully bigendian 128 bits,\n\n     * then XOR to account for the order of the two 64 bit halves.\n\n     *\/\n\n    offs += (16 - ((element + 1) * (1 << size)));\n\n    offs ^= 8;\n\n#else\n\n    offs += element * (1 << size);\n\n#endif\n\n    return offs;\n\n}\n","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":415285,"func":"vpnc_cleanup (NMVPNCPlugin *self, gboolean killit)\n{\n\tNMVPNCPluginPrivate *priv = NM_VPNC_PLUGIN_GET_PRIVATE (self);\n\n\tif (priv->infd >= 0) {\n\t\tclose (priv->infd);\n\t\tpriv->infd = -1;\n\t}\n\n\tpipe_cleanup (&priv->out);\n\tpipe_cleanup (&priv->err);\n\tg_string_truncate (priv->server_message, 0);\n\tpriv->server_message_done = FALSE;\n\n\tif (priv->watch_id) {\n\t\tg_source_remove (priv->watch_id);\n\t\tpriv->watch_id = 0;\n\t}\n\n\tif (priv->pid) {\n\t\tif (killit) {\n\t\t\t\/* Try giving it some time to disconnect cleanly *\/\n\t\t\tif (kill (priv->pid, SIGTERM) == 0)\n\t\t\t\tg_timeout_add (2000, ensure_killed, GINT_TO_POINTER (priv->pid));\n\t\t\t_LOGI (\"Terminated vpnc daemon with PID %d.\", priv->pid);\n\t\t} else {\n\t\t\t\/* Already quit, just reap the child *\/\n\t\t\twaitpid (priv->pid, NULL, WNOHANG);\n\t\t}\n\t\tpriv->pid = 0;\n\t}\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":428536,"func":"replace_contents_open_callback (GObject      *obj,\n                                GAsyncResult *open_res,\n                                gpointer      user_data)\n{\n  GFile *file = G_FILE (obj);\n  GFileOutputStream *stream;\n  ReplaceContentsData *data = user_data;\n  GError *error = NULL;\n\n  stream = g_file_replace_finish (file, open_res, &error);\n\n  if (stream)\n    {\n      const gchar *content;\n      gsize length;\n\n      content = g_bytes_get_data (data->content, &length);\n      g_output_stream_write_async (G_OUTPUT_STREAM (stream),\n                                   content + data->pos,\n                                   length - data->pos,\n                                   0,\n                                   g_task_get_cancellable (data->task),\n                                   replace_contents_write_callback,\n                                   data);\n    }\n  else\n    {\n      g_task_return_error (data->task, error);\n      g_object_unref (data->task);\n    }\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":413823,"func":"  Mixin_Call_Obj Parser::parse_include_directive()\n  {\n    \/\/ lex identifier into `lexed` var\n    lex_identifier(); \/\/ may error out\n    \/\/ normalize underscores to hyphens\n    std::string name(Util::normalize_underscores(lexed));\n    \/\/ create the initial mixin call object\n    Mixin_Call_Obj call = SASS_MEMORY_NEW(Mixin_Call, pstate, name, {}, {});\n    \/\/ parse mandatory arguments\n    call->arguments(parse_arguments());\n    \/\/ parse optional block\n    if (peek < exactly <'{'> >()) {\n      call->block(parse_block());\n    }\n    \/\/ return ast node\n    return call.detach();\n  }","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":51544,"func":"inline void StringData::checkStack() const {\n  assertx(uintptr_t(this) - s_stackLimit >= s_stackSize);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":264688,"func":"static void qemu_init_child_watch(void)\n\n{\n\n    struct sigaction act;\n\n    sigchld_bh = qemu_bh_new(sigchld_bh_handler, NULL);\n\n\n\n    memset(&act, 0, sizeof(act));\n\n    act.sa_handler = sigchld_handler;\n\n    act.sa_flags = SA_NOCLDSTOP;\n\n    sigaction(SIGCHLD, &act, NULL);\n\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":51790,"func":"purgeline(struct html_feed_environ *h_env)\n{\n    char *p, *q;\n    Str tmp;\n\n    if (h_env->buf == NULL || h_env->blank_lines == 0)\n\treturn;\n\n    p = rpopTextLine(h_env->buf)->line->ptr;\n    tmp = Strnew();\n    while (*p) {\n\tq = p;\n\tif (sloppy_parse_line(&p)) {\n\t    Strcat_charp_n(tmp, q, p - q);\n\t}\n    }\n    appendTextLine(h_env->buf, tmp, 0);\n    h_env->blank_lines--;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":399073,"func":"WORD_LIST *\nexpand_words_shellexp (list)\n     WORD_LIST *list;\n{\n  return (expand_word_list_internal (list, WEXP_SHELLEXP));","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":132545,"func":"static unsigned long mem_cgroup_recursive_stat(struct mem_cgroup *memcg,\n\t\t\t\t\t       enum mem_cgroup_stat_index idx)\n{\n\tstruct mem_cgroup *iter;\n\tlong val = 0;\n\n\t\/* Per-cpu values can be negative, use a signed accumulator *\/\n\tfor_each_mem_cgroup_tree(iter, memcg)\n\t\tval += mem_cgroup_read_stat(iter, idx);\n\n\tif (val < 0) \/* race ? *\/\n\t\tval = 0;\n\treturn val;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":134132,"func":"static int __net_init ping_v4_proc_init_net(struct net *net)\n{\n\treturn ping_proc_register(net, &ping_v4_seq_afinfo);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":204719,"func":"void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) {\n  ContextMenuParams params = ContextMenuParamsBuilder::Build(data);\n  params.source_type = GetRenderWidget()->context_menu_source_type();\n  GetRenderWidget()->OnShowHostContextMenu(¶ms);\n  if (GetRenderWidget()->has_host_context_menu_location()) {\n    params.x = GetRenderWidget()->host_context_menu_location().x();\n    params.y = GetRenderWidget()->host_context_menu_location().y();\n  }\n\n  if (params.src_url.spec().size() > GetMaxURLChars())\n    params.src_url = GURL();\n  context_menu_node_ = data.node;\n\n#if defined(OS_ANDROID)\n  gfx::Rect start_rect;\n  gfx::Rect end_rect;\n  GetRenderWidget()->GetSelectionBounds(&start_rect, &end_rect);\n  params.selection_start = gfx::Point(start_rect.x(), start_rect.bottom());\n  params.selection_end = gfx::Point(end_rect.right(), end_rect.bottom());\n#endif\n\n  Send(new FrameHostMsg_ContextMenu(routing_id_, params));\n}\n","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":274561,"func":"const wchar_t *LibRaw_bigfile_datastream::wfname()\n{\n  return wfilename.size()>0?wfilename.c_str():NULL;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":255779,"func":"pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len,\n\t\t      int atomic)\n{\n\tunsigned long copy;\n\n\twhile (len > 0) {\n\t\twhile (!iov->iov_len)\n\t\t\tiov++;\n\t\tcopy = min_t(unsigned long, len, iov->iov_len);\n\n\t\tif (atomic) {\n\t\t\tif (__copy_to_user_inatomic(iov->iov_base, from, copy))\n\t\t\t\treturn -EFAULT;\n\t\t} else {\n\t\t\tif (copy_to_user(iov->iov_base, from, copy))\n\t\t\t\treturn -EFAULT;\n\t\t}\n\t\tfrom += copy;\n\t\tlen -= copy;\n\t\tiov->iov_base += copy;\n\t\tiov->iov_len -= copy;\n\t}\n\treturn 0;\n}","target":1,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":291884,"func":"CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)\n{\n    return (const char*) (global_error.json + global_error.position);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":33583,"func":"xml2_error_hdr(void *arg, const char *msg, xmlParserSeverities severity,\n    xmlTextReaderLocatorPtr locator)\n{\n\tstruct archive_read *a;\n\n\t(void)locator; \/* UNUSED *\/\n\ta = (struct archive_read *)arg;\n\tswitch (severity) {\n\tcase XML_PARSER_SEVERITY_VALIDITY_WARNING:\n\tcase XML_PARSER_SEVERITY_WARNING:\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t    \"XML Parsing error: %s\", msg);\n\t\tbreak;\n\tcase XML_PARSER_SEVERITY_VALIDITY_ERROR:\n\tcase XML_PARSER_SEVERITY_ERROR:\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t    \"XML Parsing error: %s\", msg);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":443921,"func":"socket_client_timed_out_write_connected (GObject      *source,\n                                         GAsyncResult *result,\n                                         gpointer      user_data)\n{\n  TestConnection *test = user_data;\n  GSocketConnection *connection;\n  GError *error = NULL;\n\n  connection = g_socket_client_connect_finish (G_SOCKET_CLIENT (source),\n                                               result, &error);\n  g_assert_no_error (error);\n  test->client_connection = G_IO_STREAM (connection);\n\n  \/* We need to use an idle callback here to guarantee that the upcoming call\n   * to g_input_stream_read() executes on the next iteration of the main\n   * context. Otherwise, we could deadlock ourselves: the read would not be able\n   * to complete if GTask executes socket_client_timed_out_write_connected()\n   * using g_task_return_now() instead of posting the invocation to the next\n   * iteration of the main context, because the server will not progress until\n   * the main context is iterated, but iteration would be blocked waiting for\n   * client's read to complete.\n   *\/\n  g_idle_add (socket_client_timed_out_write, test);\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":251703,"func":"static void methodWithEnforceRangeInt64Method(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    ExceptionState exceptionState(ExceptionState::ExecutionContext, \"methodWithEnforceRangeInt64\", \"TestObject\", info.Holder(), info.GetIsolate());\n    if (UNLIKELY(info.Length() < 1)) {\n        exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));\n        exceptionState.throwIfNeeded();\n        return;\n    }\n    TestObject* imp = V8TestObject::toNative(info.Holder());\n    V8TRYCATCH_EXCEPTION_VOID(long long, value, toInt64(info[0], EnforceRange, exceptionState), exceptionState);\n    imp->methodWithEnforceRangeInt64(value);\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":314305,"func":"void HTMLInputElement::setFiles(FileList* files) {\n  input_type_->SetFiles(files);\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":403398,"func":"static void store_param_double(NET *net, MYSQL_BIND *param)\n{\n  double value= *(double*) param->buffer;\n  float8store(net->write_pos, value);\n  net->write_pos+= 8;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":57275,"func":"eval_fname_script(char_u *p)\n{\n    \/\/ Use MB_STRICMP() because in Turkish comparing the \"I\" may not work with\n    \/\/ the standard library function.\n    if (p[0] == '<' && (MB_STRNICMP(p + 1, \"SID>\", 4) == 0\n\t\t\t\t       || MB_STRNICMP(p + 1, \"SNR>\", 4) == 0))\n\treturn 5;\n    if (p[0] == 's' && p[1] == ':')\n\treturn 2;\n    return 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":396278,"func":"ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRMLS_DC) \/* {{{ *\/\n{\n\tzend_fcall_info_cache fcc;\n\n\tif (zend_is_callable_ex(callable, NULL, IS_CALLABLE_STRICT, callable_name, NULL, &fcc, NULL TSRMLS_CC)) {\n\t\tif (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) {\n\t\t\tzval_dtor(callable);\n\t\t\tarray_init(callable);\n\t\t\tadd_next_index_string(callable, fcc.calling_scope->name, 1);\n\t\t\tadd_next_index_string(callable, fcc.function_handler->common.function_name, 1);\n\t\t}\n\t\tif (fcc.function_handler &&\n\t\t\t((fcc.function_handler->type == ZEND_INTERNAL_FUNCTION &&\n\t\t      (fcc.function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||\n\t\t     fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||\n\t\t     fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) {\n\t\t\tif (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) {\n\t\t\t\tefree((char*)fcc.function_handler->common.function_name);\n\t\t\t}\n\t\t\tefree(fcc.function_handler);\n\t\t}\n\t\treturn 1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":377057,"func":"void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops,\n                      void *opaque)\n{\n    bs->dev_ops = ops;\n    bs->dev_opaque = opaque;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":88801,"func":"NOEXPORT void name_list_append(NAME_LIST **ptr, char *name) {\n    while(*ptr) \/* find the null pointer *\/\n        ptr=&(*ptr)->next;\n    *ptr=str_alloc_detached(sizeof(NAME_LIST));\n    (*ptr)->name=str_dup_detached(name);\n    (*ptr)->next=NULL;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":401397,"func":"void Smb4KUnmountJob::setupUnmount( const QList<Smb4KShare *> &shares, bool force, bool silent, bool synchron, QWidget* parent )\n{\n  QListIterator<Smb4KShare *> it( shares );\n\n  while ( it.hasNext() )\n  {\n    Smb4KShare *share = it.next();\n    Q_ASSERT( share );\n    m_shares << new Smb4KShare( *share );\n  }\n\n  m_force = force;\n  m_silent = silent;\n  m_synchron = synchron;\n  m_parent_widget = parent;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":488250,"func":"njs_value_method(njs_vm_t *vm, njs_value_t *value, njs_value_t *key,\n    njs_value_t *retval)\n{\n    njs_int_t  ret;\n\n    ret = njs_value_to_object(vm, value);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_value_property(vm, value, key, retval);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return (ret == NJS_DECLINED) ? NJS_OK : ret;\n    }\n\n    if (njs_slow_path(!njs_is_function(retval))) {\n        njs_type_error(vm, \"method is not callable\");\n        return NJS_ERROR;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":120922,"func":"void CoreUserInputHandler::handleBan(const BufferInfo &bufferInfo, const QString &msg)\n{\n    banOrUnban(bufferInfo, msg, true);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":327366,"func":"static void do_wav_capture(Monitor *mon, const QDict *qdict)\n\n{\n\n    const char *path = qdict_get_str(qdict, \"path\");\n\n    int has_freq = qdict_haskey(qdict, \"freq\");\n\n    int freq = qdict_get_try_int(qdict, \"freq\", -1);\n\n    int has_bits = qdict_haskey(qdict, \"bits\");\n\n    int bits = qdict_get_try_int(qdict, \"bits\", -1);\n\n    int has_channels = qdict_haskey(qdict, \"nchannels\");\n\n    int nchannels = qdict_get_try_int(qdict, \"nchannels\", -1);\n\n    CaptureState *s;\n\n\n\n    s = qemu_mallocz (sizeof (*s));\n\n\n\n    freq = has_freq ? freq : 44100;\n\n    bits = has_bits ? bits : 16;\n\n    nchannels = has_channels ? nchannels : 2;\n\n\n\n    if (wav_start_capture (s, path, freq, bits, nchannels)) {\n\n        monitor_printf(mon, \"Faied to add wave capture\\n\");\n\n        qemu_free (s);\n\n    }\n\n    QLIST_INSERT_HEAD (&capture_head, s, entries);\n\n}\n","target":1,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":521736,"func":"bool Item_func_locate::fix_length_and_dec()\n{\n  max_length= MY_INT32_NUM_DECIMAL_DIGITS;\n  return agg_arg_charsets_for_comparison(cmp_collation, args, 2);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":71342,"func":"int wc_PubKeyPemToDer(const unsigned char* pem, int pemSz,\n                           unsigned char* buff, int buffSz)\n{\n    int ret;\n    DerBuffer* der = NULL;\n\n    WOLFSSL_ENTER(\"wc_PubKeyPemToDer\");\n\n    if (pem == NULL || buff == NULL || buffSz <= 0) {\n        WOLFSSL_MSG(\"Bad pem der args\");\n        return BAD_FUNC_ARG;\n    }\n\n    ret = PemToDer(pem, pemSz, PUBLICKEY_TYPE, &der, NULL, NULL, NULL);\n    if (ret < 0 || der == NULL) {\n        WOLFSSL_MSG(\"Bad Pem To Der\");\n    }\n    else {\n        if (der->length <= (word32)buffSz) {\n            XMEMCPY(buff, der->buffer, der->length);\n            ret = der->length;\n        }\n        else {\n            WOLFSSL_MSG(\"Bad der length\");\n            ret = BAD_FUNC_ARG;\n        }\n    }\n\n    FreeDer(&der);\n    return ret;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":521086,"func":"  bool group() const { return m_group; }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":116193,"func":"PHP_FUNCTION(imagefilledarc)\n{\n\tzval *IM;\n\tlong cx, cy, w, h, ST, E, col, style;\n\tgdImagePtr im;\n\tint e, st;\n\t\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rllllllll\", &IM, &cx, &cy, &w, &h, &ST, &E, &col, &style) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\n\te = E;\n\tif (e < 0) {\n\t\te %= 360;\n\t}\n\n\tst = ST;\n\tif (st < 0) {\n\t\tst %= 360;\n\t}\n\n\tgdImageFilledArc(im, cx, cy, w, h, st, e, col, style);\n\n\tRETURN_TRUE;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":182451,"func":"static void testObjectPythonAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n    TestObjectPythonV8Internal::testObjectPythonAttributeAttributeSetter(jsValue, info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":459158,"func":"MagickPrivate void ConvertRGBToLab(const double red,const double green,\n  const double blue,double *L,double *a,double *b)\n{\n  double\n    X,\n    Y,\n    Z;\n\n  ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);\n  ConvertXYZToLab(X,Y,Z,L,a,b);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":267097,"func":"void ftrace_profile_free_filter(struct perf_event *event)\n{\n\tstruct event_filter *filter = event->filter;\n\n\tevent->filter = NULL;\n\t__free_filter(filter);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":121861,"func":"static sraSpan* sraNextSpan(sraRectangleIterator *i)\n{\n  if(sraReverse(i))\n    return(i->sPtrs[i->ptrPos]->_prev);\n  else\n    return(i->sPtrs[i->ptrPos]->_next);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":517929,"func":"bool Item_param::convert_str_value(THD *thd)\n{\n  bool rc= FALSE;\n  if ((state == SHORT_DATA_VALUE || state == LONG_DATA_VALUE) &&\n      value.type_handler()->cmp_type() == STRING_RESULT)\n  {\n    rc= value.cs_info.convert_if_needed(thd, &value.m_string);\n    \/* Here str_value is guaranteed to be in final_character_set_of_str_value *\/\n\n    \/*\n      str_value_ptr is returned from val_str(). It must be not alloced\n      to prevent it's modification by val_str() invoker.\n    *\/\n    value.m_string_ptr.set(value.m_string.ptr(), value.m_string.length(),\n                           value.m_string.charset());\n    \/* Synchronize item charset and length with value charset *\/\n    fix_charset_and_length_from_str_value(value.m_string, DERIVATION_COERCIBLE);\n  }\n  return rc;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":80111,"func":"IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,\n                                            bool is_write, MemTxAttrs attrs)\n{\n    MemoryRegionSection section;\n    hwaddr xlat, page_mask;\n\n    \/*\n     * This can never be MMIO, and we don't really care about plen,\n     * but page mask.\n     *\/\n    section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat,\n                                    NULL, &page_mask, is_write, false, &as,\n                                    attrs);\n\n    \/* Illegal translation *\/\n    if (section.mr == &io_mem_unassigned) {\n        goto iotlb_fail;\n    }\n\n    \/* Convert memory region offset into address space offset *\/\n    xlat += section.offset_within_address_space -\n        section.offset_within_region;\n\n    return (IOMMUTLBEntry) {\n        .target_as = as,\n        .iova = addr & ~page_mask,\n        .translated_addr = xlat & ~page_mask,\n        .addr_mask = page_mask,\n        \/* IOTLBs are for DMAs, and DMA only allows on RAMs. *\/\n        .perm = IOMMU_RW,\n    };\n\niotlb_fail:\n    return (IOMMUTLBEntry) {0};\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":59447,"func":"static inline void schedule_debug(struct task_struct *prev)\n{\n\t\/*\n\t * Test if we are atomic. Since do_exit() needs to call into\n\t * schedule() atomically, we ignore that path for now.\n\t * Otherwise, whine if we are scheduling when we should not be.\n\t *\/\n\tif (unlikely(in_atomic_preempt_off() && !prev->exit_state))\n\t\t__schedule_bug(prev);\n\n\tprofile_hit(SCHED_PROFILING, __builtin_return_address(0));\n\n\tschedstat_inc(this_rq(), sched_count);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":211081,"func":"    setSwapBuffersCompleteCallbackCHROMIUM(\n    WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* cb) {\n  swapbuffers_complete_callback_ = cb;\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":234613,"func":"void PageSnapshotTaker::Observe(int type,\n                                const content::NotificationSource& source,\n                                const content::NotificationDetails& details) {\n  SendMessage(false, \"a modal dialog is active\");\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":428523,"func":"g_file_enumerate_children_async (GFile               *file,\n                                 const char          *attributes,\n                                 GFileQueryInfoFlags  flags,\n                                 int                  io_priority,\n                                 GCancellable        *cancellable,\n                                 GAsyncReadyCallback  callback,\n                                 gpointer             user_data)\n{\n  GFileIface *iface;\n\n  g_return_if_fail (G_IS_FILE (file));\n\n  iface = G_FILE_GET_IFACE (file);\n  (* iface->enumerate_children_async) (file,\n                                       attributes,\n                                       flags,\n                                       io_priority,\n                                       cancellable,\n                                       callback,\n                                       user_data);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":170301,"func":"DirectGLImageTransportFactory::DirectGLImageTransportFactory() {\n  WebKit::WebGraphicsContext3D::Attributes attrs;\n  attrs.shareResources = false;\n  attrs.noAutomaticFlushes = true;\n  context_.reset(\n      webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWindow(\n          attrs,\n          NULL,\n          NULL));\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":205813,"func":"media::AudioParameters TryToFixAudioParameters(\n    const media::AudioParameters& params) {\n  DCHECK(!params.IsValid());\n  media::AudioParameters params_copy(params);\n\n  if (params.channels() > media::limits::kMaxChannels) {\n    DCHECK(params.channel_layout() == media::CHANNEL_LAYOUT_DISCRETE);\n    params_copy.set_channels_for_discrete(media::limits::kMaxChannels);\n  }\n\n  return params_copy.IsValid()\n             ? params_copy\n              : media::AudioParameters::UnavailableDeviceParams();\n }\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":511942,"func":"vapply (func)\n     sh_var_map_func_t *func;\n{\n  SHELL_VAR **list;\n\n  list = map_over (func, shell_variables);\n  if (list \/* && posixly_correct *\/)\n    sort_variables (list);\n  return (list);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":206834,"func":"CGaiaCredentialBase::~CGaiaCredentialBase() {}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":469579,"func":"Mat_VarReadData(mat_t *mat,matvar_t *matvar,void *data,\n      int *start,int *stride,int *edge)\n{\n    int err = 0;\n\n    switch ( matvar->class_type ) {\n        case MAT_C_DOUBLE:\n        case MAT_C_SINGLE:\n        case MAT_C_INT64:\n        case MAT_C_UINT64:\n        case MAT_C_INT32:\n        case MAT_C_UINT32:\n        case MAT_C_INT16:\n        case MAT_C_UINT16:\n        case MAT_C_INT8:\n        case MAT_C_UINT8:\n            break;\n        default:\n            return -1;\n    }\n\n    switch ( mat->version ) {\n        case MAT_FT_MAT5:\n            err = Mat_VarReadData5(mat,matvar,data,start,stride,edge);\n            break;\n        case MAT_FT_MAT73:\n#if defined(MAT73) && MAT73\n            err = Mat_VarReadData73(mat,matvar,data,start,stride,edge);\n#else\n            err = 1;\n#endif\n            break;\n        case MAT_FT_MAT4:\n            err = Mat_VarReadData4(mat,matvar,data,start,stride,edge);\n            break;\n        default:\n            err = 2;\n            break;\n    }\n\n    return err;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":324808,"func":"static void t_gen_lsl(TCGv d, TCGv a, TCGv b)\n\n{\n\n\tTCGv t0, t_31;\n\n\n\n\tt0 = tcg_temp_new(TCG_TYPE_TL);\n\n\tt_31 = tcg_temp_new(TCG_TYPE_TL);\n\n\ttcg_gen_shl_tl(d, a, b);\n\n\n\n\ttcg_gen_movi_tl(t_31, 31);\n\n\ttcg_gen_sub_tl(t0, t_31, b);\n\n\ttcg_gen_sar_tl(t0, t0, t_31);\n\n\ttcg_gen_and_tl(t0, t0, d);\n\n\ttcg_gen_xor_tl(d, d, t0);\n\n\ttcg_temp_free(t0);\n\n\ttcg_temp_free(t_31);\n\n}\n","target":1,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":294189,"func":"static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)\n{\n\tint rc;\n\n\tif (!ipv6_addr_any(&sk->sk_v6_daddr)) {\n\t\tsock_rps_save_rxhash(sk, skb);\n\t\tsk_mark_napi_id(sk, skb);\n\t}\n\n\trc = sock_queue_rcv_skb(sk, skb);\n\tif (rc < 0) {\n\t\tint is_udplite = IS_UDPLITE(sk);\n\n\t\t\/* Note that an ENOMEM error is charged twice *\/\n\t\tif (rc == -ENOMEM)\n\t\t\tUDP6_INC_STATS_BH(sock_net(sk),\n\t\t\t\t\tUDP_MIB_RCVBUFERRORS, is_udplite);\n\t\tUDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);\n\t\tkfree_skb(skb);\n\t\treturn -1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":441083,"func":"CtPtr ProtocolV2::handle_reconnect_ok(ceph::bufferlist &payload)\n{\n  ldout(cct, 20) << __func__\n\t\t << \" payload.length()=\" << payload.length() << dendl;\n\n  if (state != SESSION_RECONNECTING) {\n    lderr(cct) << __func__ << \" not in session reconnect state!\" << dendl;\n    return _fault();\n  }\n\n  auto reconnect_ok = ReconnectOkFrame::Decode(payload);\n  ldout(cct, 5) << __func__\n                << \" reconnect accepted: sms=\" << reconnect_ok.msg_seq()\n                << dendl;\n\n  out_seq = discard_requeued_up_to(out_seq, reconnect_ok.msg_seq());\n\n  backoff = utime_t();\n  ldout(cct, 10) << __func__ << \" reconnect success \" << connect_seq\n                 << \", lossy = \" << connection->policy.lossy << \", features \"\n                 << connection->get_features() << dendl;\n\n  if (connection->delay_state) {\n    ceph_assert(connection->delay_state->ready());\n  }\n\n  connection->dispatch_queue->queue_connect(connection);\n  messenger->ms_deliver_handle_fast_connect(connection);\n\n  return ready();\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":163353,"func":"Parcel::Blob::Blob() :\n        mMapped(false), mData(NULL), mSize(0) {\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":437506,"func":"static void __io_free_req(struct io_kiocb *req)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\n\tif (req->flags & REQ_F_FREE_SQE)\n\t\tkfree(req->submit.sqe);\n\tif (req->file && !(req->flags & REQ_F_FIXED_FILE))\n\t\tfput(req->file);\n\tif (req->flags & REQ_F_INFLIGHT) {\n\t\tunsigned long flags;\n\n\t\tspin_lock_irqsave(&ctx->inflight_lock, flags);\n\t\tlist_del(&req->inflight_entry);\n\t\tif (waitqueue_active(&ctx->inflight_wait))\n\t\t\twake_up(&ctx->inflight_wait);\n\t\tspin_unlock_irqrestore(&ctx->inflight_lock, flags);\n\t}\n\tif (req->flags & REQ_F_TIMEOUT)\n\t\tkfree(req->timeout.data);\n\tpercpu_ref_put(&ctx->refs);\n\tif (likely(!io_is_fallback_req(req)))\n\t\tkmem_cache_free(req_cachep, req);\n\telse\n\t\tclear_bit_unlock(0, (unsigned long *) ctx->fallback_req);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":153521,"func":"BOOL Parser::PnodeLabelNoAST(IdentToken* pToken, LabelId* pLabelIdList)\n{\n    StmtNest* pStmt;\n    LabelId* pLabelId;\n\n    \/\/ Look in the label stack.\n    for (pStmt = m_pstmtCur; pStmt != nullptr; pStmt = pStmt->pstmtOuter)\n    {\n        for (pLabelId = pStmt->pLabelId; pLabelId != nullptr; pLabelId = pLabelId->next)\n        {\n            if (pLabelId->pid == pToken->pid)\n                return TRUE;\n        }\n    }\n\n    \/\/ Also look in the pnodeLabels list.\n    for (pLabelId = pLabelIdList; pLabelId != nullptr; pLabelId = pLabelId->next)\n    {\n        if (pLabelId->pid == pToken->pid)\n            return TRUE;\n    }\n\n    return FALSE;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":185125,"func":"void webkit_web_frame_load_alternate_string(WebKitWebFrame* frame, const gchar* content, const gchar* baseURL, const gchar* unreachableURL)\n{\n    g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));\n    g_return_if_fail(content);\n\n    webkit_web_frame_load_data(frame, content, NULL, NULL, baseURL, unreachableURL);\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":395389,"func":"stmt_has_updated_trans_table(Ha_trx_info* ha_list)\n{\n  Ha_trx_info *ha_info;\n  for (ha_info= ha_list; ha_info; ha_info= ha_info->next())\n  {\n    if (ha_info->is_trx_read_write() && ha_info->ht() != binlog_hton)\n      return (TRUE);\n  }\n  return (FALSE);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":155970,"func":"static int mov_write_smhd_tag(AVIOContext *pb)\n{\n    avio_wb32(pb, 16); \/* size *\/\n    ffio_wfourcc(pb, \"smhd\");\n    avio_wb32(pb, 0); \/* version & flags *\/\n    avio_wb16(pb, 0); \/* reserved (balance, normally = 0) *\/\n    avio_wb16(pb, 0); \/* reserved *\/\n    return 16;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":211767,"func":"void PaymentHandlerWebFlowViewController::DidFinishNavigation(\n    content::NavigationHandle* navigation_handle) {\n  if (navigation_handle->IsSameDocument())\n    return;\n\n  if (!OriginSecurityChecker::IsOriginSecure(navigation_handle->GetURL()) ||\n      (!OriginSecurityChecker::IsSchemeCryptographic(\n           navigation_handle->GetURL()) &&\n       !OriginSecurityChecker::IsOriginLocalhostOrFile(\n           navigation_handle->GetURL()) &&\n       !navigation_handle->GetURL().IsAboutBlank()) ||\n      !SslValidityChecker::IsSslCertificateValid(\n          navigation_handle->GetWebContents())) {\n    if (!net::IsLocalhost(navigation_handle->GetURL())) {\n      log_.Error(\"Aborting payment handler window \\\"\" + target_.spec() +\n                 \"\\\" because of navigation to an insecure url \\\"\" +\n                 navigation_handle->GetURL().spec() + \"\\\"\");\n      AbortPayment();\n      return;\n    }\n  }\n\n  if (first_navigation_complete_callback_) {\n    std::move(first_navigation_complete_callback_)\n        .Run(true, web_contents()->GetMainFrame()->GetProcess()->GetID(),\n             web_contents()->GetMainFrame()->GetRoutingID());\n    first_navigation_complete_callback_ = PaymentHandlerOpenWindowCallback();\n  }\n\n  UpdateHeaderView();\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":314321,"func":"void GfxSubpath::close() {\n  if (x[n-1] != x[0] || y[n-1] != y[0]) {\n    lineTo(x[0], y[0]);\n  }\n  closed = gTrue;\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":335618,"func":"static int check_empty_sectors(BlockBackend *blk, int64_t sect_num,\n\n                               int sect_count, const char *filename,\n\n                               uint8_t *buffer, bool quiet)\n\n{\n\n    int pnum, ret = 0;\n\n    ret = blk_pread(blk, sect_num << BDRV_SECTOR_BITS, buffer,\n\n                    sect_count << BDRV_SECTOR_BITS);\n\n    if (ret < 0) {\n\n        error_report(\"Error while reading offset %\" PRId64 \" of %s: %s\",\n\n                     sectors_to_bytes(sect_num), filename, strerror(-ret));\n\n        return ret;\n\n    }\n\n    ret = is_allocated_sectors(buffer, sect_count, &pnum);\n\n    if (ret || pnum != sect_count) {\n\n        qprintf(quiet, \"Content mismatch at offset %\" PRId64 \"!\\n\",\n\n                sectors_to_bytes(ret ? sect_num : sect_num + pnum));\n\n        return 1;\n\n    }\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":147892,"func":"\/*this is using chpl format according to some NeroRecode samples*\/\nGF_Err tfdt_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_TFBaseMediaDecodeTimeBox *ptr = (GF_TFBaseMediaDecodeTimeBox *)s;\n\n\tif (ptr->version==1) {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->baseMediaDecodeTime = gf_bs_read_u64(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->baseMediaDecodeTime = (u32) gf_bs_read_u32(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":378666,"func":"static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path)\n{\n\treturn sys_acl_delete_def_file(handle, path);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":460522,"func":"static int reverse_path_check(void)\n{\n\tint error = 0;\n\tstruct file *current_file;\n\n\t\/* let's call this for all tfiles *\/\n\tlist_for_each_entry(current_file, &tfile_check_list, f_tfile_llink) {\n\t\tpath_count_init();\n\t\terror = ep_call_nested(&poll_loop_ncalls,\n\t\t\t\t\treverse_path_check_proc, current_file,\n\t\t\t\t\tcurrent_file, current);\n\t\tif (error)\n\t\t\tbreak;\n\t}\n\treturn error;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":283850,"func":"void SoundPool::moveToFront_l(SoundChannel* channel)\n{\n for (List<SoundChannel*>::iterator iter = mChannels.begin(); iter != mChannels.end(); ++iter) {\n if (*iter == channel) {\n            mChannels.erase(iter);\n            mChannels.push_front(channel);\n break;\n }\n }\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":305204,"func":"void btreeFree(struct BTREE *btree) {\n\tfree(btree->records);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":25830,"func":"static int avi_probe ( AVProbeData * p ) {\n int i ;\n for ( i = 0 ;\n avi_headers [ i ] [ 0 ] ;\n i ++ ) if ( AV_RL32 ( p -> buf ) == AV_RL32 ( avi_headers [ i ] ) && AV_RL32 ( p -> buf + 8 ) == AV_RL32 ( avi_headers [ i ] + 4 ) ) return AVPROBE_SCORE_MAX ;\n return 0 ;\n }","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":91532,"func":"\tTEST_METHOD(9) {\n\t\t\/\/ getNewestGeneration returns null if there are no generations.\n\t\tServerInstanceDir dir(parentDir + \"\/passenger-test.1234\");\n\t\tensure(dir.getNewestGeneration() == NULL);\n\t}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":139778,"func":"static FontSizeSpec fontSizeSpec(QStringView spec)\n{\n    switch (spec.at(0).unicode()) {\n    case 'x':\n        if (spec == QLatin1String(\"xx-small\"))\n            return XXSmall;\n        if (spec == QLatin1String(\"x-small\"))\n            return XSmall;\n        if (spec == QLatin1String(\"x-large\"))\n            return XLarge;\n        if (spec == QLatin1String(\"xx-large\"))\n            return XXLarge;\n        break;\n    case 's':\n        if (spec == QLatin1String(\"small\"))\n            return Small;\n        break;\n    case 'm':\n        if (spec == QLatin1String(\"medium\"))\n            return Medium;\n        break;\n    case 'l':\n        if (spec == QLatin1String(\"large\"))\n            return Large;\n        break;\n    case 'n':\n        if (spec == QLatin1String(\"none\"))\n            return FontSizeNone;\n        break;\n    default:\n        break;\n    }\n    return FontSizeValue;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":299501,"func":"int cipso_v4_doi_walk(u32 *skip_cnt,\n\t\t     int (*callback) (struct cipso_v4_doi *doi_def, void *arg),\n\t\t     void *cb_arg)\n{\n\tint ret_val = -ENOENT;\n\tu32 doi_cnt = 0;\n\tstruct cipso_v4_doi *iter_doi;\n\n\trcu_read_lock();\n\tlist_for_each_entry_rcu(iter_doi, &cipso_v4_doi_list, list)\n\t\tif (atomic_read(&iter_doi->refcount) > 0) {\n\t\t\tif (doi_cnt++ < *skip_cnt)\n\t\t\t\tcontinue;\n\t\t\tret_val = callback(iter_doi, cb_arg);\n\t\t\tif (ret_val < 0) {\n\t\t\t\tdoi_cnt--;\n\t\t\t\tgoto doi_walk_return;\n\t\t\t}\n\t\t}\n\ndoi_walk_return:\n\trcu_read_unlock();\n\t*skip_cnt = doi_cnt;\n\treturn ret_val;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":396332,"func":"static void emitfunction(JF, js_Function *fun)\n{\n\temit(J, F, OP_CLOSURE);\n\temitraw(J, F, addfunction(J, F, fun));\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":237446,"func":"void DaemonProcessTest::QuitMessageLoop() {\n  message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":130793,"func":"void CModule::OnQuit(const CNick& Nick, const CString& sMessage,\n                     const vector<CChan*>& vChans) {}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":354904,"func":"static void isdn_header_cache_update(struct hh_cache *hh,\n\t\t\t\t     const struct net_device *dev,\n\t\t\t\t     const unsigned char *haddr)\n{\n\tisdn_net_local *lp = dev->priv;\n\tif (lp->p_encap == ISDN_NET_ENCAP_ETHER)\n\t\treturn eth_header_cache_update(hh, dev, haddr);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":256710,"func":"static void ohci_process_lists ( OHCIState * ohci , int completion ) {\n if ( ( ohci -> ctl & OHCI_CTL_CLE ) && ( ohci -> status & OHCI_STATUS_CLF ) ) {\n if ( ohci -> ctrl_cur && ohci -> ctrl_cur != ohci -> ctrl_head ) {\n trace_usb_ohci_process_lists ( ohci -> ctrl_head , ohci -> ctrl_cur ) ;\n }\n if ( ! ohci_service_ed_list ( ohci , ohci -> ctrl_head , completion ) ) {\n ohci -> ctrl_cur = 0 ;\n ohci -> status &= ~ OHCI_STATUS_CLF ;\n }\n }\n if ( ( ohci -> ctl & OHCI_CTL_BLE ) && ( ohci -> status & OHCI_STATUS_BLF ) ) {\n if ( ! ohci_service_ed_list ( ohci , ohci -> bulk_head , completion ) ) {\n ohci -> bulk_cur = 0 ;\n ohci -> status &= ~ OHCI_STATUS_BLF ;\n }\n }\n }","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":195372,"func":"static void VoidMethodDOMStringOrArrayBufferOrArrayBufferViewArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, \"TestObject\", \"voidMethodDOMStringOrArrayBufferOrArrayBufferViewArg\");\n\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  if (UNLIKELY(info.Length() < 1)) {\n    exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));\n    return;\n  }\n\n  StringOrArrayBufferOrArrayBufferView arg;\n  V8StringOrArrayBufferOrArrayBufferView::ToImpl(info.GetIsolate(), info[0], arg, UnionTypeConversionMode::kNotNullable, exception_state);\n  if (exception_state.HadException())\n    return;\n\n  impl->voidMethodDOMStringOrArrayBufferOrArrayBufferViewArg(arg);\n}\n","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":183770,"func":"  bool Connected() const { return true; }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":34502,"func":"EmitButtonCode(XtermWidget xw,\n\t       Char *line,\n\t       unsigned count,\n\t       XButtonEvent *event,\n\t       int button)\n{\n    TScreen *screen = TScreenOf(xw);\n    int value;\n\n    if (okSendMousePos(xw) == X10_MOUSE) {\n\tvalue = CharOf(' ' + button);\n    } else {\n\tvalue = BtnCode(xw, event, button);\n    }\n\n    switch (screen->extend_coords) {\n    default:\n\tline[count++] = CharOf(value);\n\tbreak;\n    case SET_SGR_EXT_MODE_MOUSE:\n    case SET_PIXEL_POSITION_MOUSE:\n\tvalue -= 32;\t\t\/* encoding starts at zero *\/\n\t\/* FALLTHRU *\/\n    case SET_URXVT_EXT_MODE_MOUSE:\n\tcount += (unsigned) sprintf((char *) line + count, \"%d\", value);\n\tbreak;\n    case SET_EXT_MODE_MOUSE:\n\tif (value < 128) {\n\t    line[count++] = CharOf(value);\n\t} else {\n\t    line[count++] = CharOf(0xC0 + (value >> 6));\n\t    line[count++] = CharOf(0x80 + (value & 0x3F));\n\t}\n\tbreak;\n    }\n    return count;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":452428,"func":"static void fn_null(struct vc_data *vc)\n{\n\tdo_compute_shiftstate();\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":442606,"func":"static void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb)\n{\n\tstruct hci_ev_mode_change *ev = (void *) skb->data;\n\tstruct hci_conn *conn;\n\n\tBT_DBG(\"%s status 0x%2.2x\", hdev->name, ev->status);\n\n\thci_dev_lock(hdev);\n\n\tconn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));\n\tif (conn) {\n\t\tconn->mode = ev->mode;\n\n\t\tif (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND,\n\t\t\t\t\t&conn->flags)) {\n\t\t\tif (conn->mode == HCI_CM_ACTIVE)\n\t\t\t\tset_bit(HCI_CONN_POWER_SAVE, &conn->flags);\n\t\t\telse\n\t\t\t\tclear_bit(HCI_CONN_POWER_SAVE, &conn->flags);\n\t\t}\n\n\t\tif (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))\n\t\t\thci_sco_setup(conn, ev->status);\n\t}\n\n\thci_dev_unlock(hdev);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":421234,"func":"static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast)\n{\n\tif (dhcp_pkt->gateway_nip)\n\t\tsend_packet_to_relay(dhcp_pkt);\n\telse\n\t\tsend_packet_to_client(dhcp_pkt, force_broadcast);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":14793,"func":"EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec)\n{\n    JSValue thisValue = exec->hostThisValue();\n    if (!thisValue.inherits(&JSTestObj::s_info))\n        return throwVMTypeError(exec);\n    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));\n     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);\n     TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n     if (exec->argumentCount() < 1)\n        return throwVMError(exec, createTypeError(exec, \"Not enough arguments\"));\n     RefPtr<SerializedScriptValue> serializedArg(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));\n     if (exec->hadException())\n         return JSValue::encode(jsUndefined());\n    impl->serializedValue(serializedArg);\n    return JSValue::encode(jsUndefined());\n}\n","target":1,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":276344,"func":"void V8TestObject::CachedAttributeRaisesExceptionGetterAnyAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_cachedAttributeRaisesExceptionGetterAnyAttribute_Getter\");\n\n  test_object_v8_internal::CachedAttributeRaisesExceptionGetterAnyAttributeAttributeGetter(info);\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":307198,"func":"static int __init printk_late_init(void)\n{\n\tstruct console *con;\n\n\tfor_each_console(con) {\n\t\tif (!keep_bootcon && con->flags & CON_BOOT) {\n\t\t\tprintk(KERN_INFO \"turn off boot console %s%d\\n\",\n\t\t\t\tcon->name, con->index);\n\t\t\tunregister_console(con);\n\t\t}\n\t}\n\thotcpu_notifier(console_cpu_notify, 0);\n\treturn 0;\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":329537,"func":"static int get_qcc(J2kDecoderContext *s, int n, J2kQuantStyle *q, uint8_t *properties)\n\n{\n\n    int compno;\n\n\n\n    if (s->buf_end - s->buf < 1)\n\n        return AVERROR(EINVAL);\n\n\n\n    compno = bytestream_get_byte(&s->buf);\n\n    properties[compno] |= HAD_QCC;\n\n    return get_qcx(s, n-1, q+compno);\n\n}\n","target":1,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":406006,"func":"ofputil_queue_stats_from_ofp11(struct ofputil_queue_stats *oqs,\n                               const struct ofp11_queue_stats *qs11)\n{\n    enum ofperr error;\n\n    error = ofputil_port_from_ofp11(qs11->port_no, &oqs->port_no);\n    if (error) {\n        return error;\n    }\n\n    oqs->queue_id = ntohl(qs11->queue_id);\n    oqs->tx_bytes = ntohll(qs11->tx_bytes);\n    oqs->tx_packets = ntohll(qs11->tx_packets);\n    oqs->tx_errors = ntohll(qs11->tx_errors);\n    oqs->duration_sec = oqs->duration_nsec = UINT32_MAX;\n\n    return 0;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":378351,"func":"int sys_pclose(int fd)\n{\n\tint wstatus;\n\tpopen_list **ptr = &popen_chain;\n\tpopen_list *entry = NULL;\n\tpid_t wait_pid;\n\tint status = -1;\n\n\t\/* Unlink from popen_chain. *\/\n\tfor ( ; *ptr != NULL; ptr = &(*ptr)->next) {\n\t\tif ((*ptr)->fd == fd) {\n\t\t\tentry = *ptr;\n\t\t\t*ptr = (*ptr)->next;\n\t\t\tstatus = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (status < 0 || close(entry->fd) < 0)\n\t\treturn -1;\n\n\t\/*\n\t * As Samba is catching and eating child process\n\t * exits we don't really care about the child exit\n\t * code, a -1 with errno = ECHILD will do fine for us.\n\t *\/\n\n\tdo {\n\t\twait_pid = sys_waitpid (entry->child_pid, &wstatus, 0);\n\t} while (wait_pid == -1 && errno == EINTR);\n\n\tSAFE_FREE(entry);\n\n\tif (wait_pid == -1)\n\t\treturn -1;\n\treturn wstatus;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":426915,"func":"ModuleExport void UnregisterTIFFImage(void)\n{\n  (void) UnregisterMagickInfo(\"TIFF64\");\n  (void) UnregisterMagickInfo(\"TIFF\");\n  (void) UnregisterMagickInfo(\"TIF\");\n  (void) UnregisterMagickInfo(\"PTIF\");\n  if (tiff_semaphore == (SemaphoreInfo *) NULL)\n    ActivateSemaphoreInfo(&tiff_semaphore);\n  LockSemaphoreInfo(tiff_semaphore);\n  if (instantiate_key != MagickFalse)\n    {\n      if (DeleteMagickThreadKey(tiff_exception) == MagickFalse)\n        ThrowFatalException(ResourceLimitFatalError,\"MemoryAllocationFailed\");\n#if defined(MAGICKCORE_HAVE_TIFFMERGEFIELDINFO) && defined(MAGICKCORE_HAVE_TIFFSETTAGEXTENDER)\n      if (tag_extender == (TIFFExtendProc) NULL)\n        (void) TIFFSetTagExtender(tag_extender);\n#endif\n      (void) TIFFSetWarningHandler(warning_handler);\n      (void) TIFFSetErrorHandler(error_handler);\n      instantiate_key=MagickFalse;\n    }\n  UnlockSemaphoreInfo(tiff_semaphore);\n  DestroySemaphoreInfo(&tiff_semaphore);\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":31608,"func":"QPDF::replaceReserved(QPDFObjectHandle reserved,\n                      QPDFObjectHandle replacement)\n{\n    QTC::TC(\"qpdf\", \"QPDF replaceReserved\");\n    reserved.assertReserved();\n    replaceObject(reserved.getObjGen(), replacement);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":21179,"func":"static int dissect_h245_ME_finiteRepeatCount ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n # line 116 \"..\/..\/asn1\/h245\/h245.cnf\" guint32 value ;\n offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 1U , 65535U , & value , FALSE ) ;\n h223_me -> repeat_count = value & 0xffff ;\n return offset ;\n }","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":335805,"func":"static void quantize_and_encode_band_cost_ZERO_mips(struct AACEncContext *s,\n\n                                                         PutBitContext *pb, const float *in, float *out,\n\n                                                         const float *scaled, int size, int scale_idx,\n\n                                                         int cb, const float lambda, const float uplim,\n\n                                                         int *bits, const float ROUNDING) {\n\n    int i;\n\n    if (bits)\n\n        *bits = 0;\n\n    if (out) {\n\n        for (i = 0; i < size; i += 4) {\n\n           out[i  ] = 0.0f;\n\n           out[i+1] = 0.0f;\n\n           out[i+2] = 0.0f;\n\n           out[i+3] = 0.0f;\n\n        }\n\n    }\n\n}\n","target":1,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":216339,"func":"void DisplayItemList::appendToWebDisplayItemList(WebDisplayItemList* list)\n{\n    for (const DisplayItem& item : m_currentDisplayItems)\n        item.appendToWebDisplayItemList(list);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":347762,"func":"static int init_dumping(char *database, int init_func(char*))\n{\n  if (mysql_select_db(mysql, database))\n  {\n    DB_error(mysql, \"when selecting the database\");\n    return 1;                   \/* If --force *\/\n  }\n  if (!path && !opt_xml)\n  {\n    if (opt_databases || opt_alldbs)\n    {\n      \/*\n        length of table name * 2 (if name contains quotes), 2 quotes and 0\n      *\/\n      char quoted_database_buf[NAME_LEN*2+3];\n      char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);\n\n      print_comment(md_result_file, 0,\n                    \"\\n--\\n-- Current Database: %s\\n--\\n\",\n                    fix_identifier_with_newline(qdatabase));\n\n      \/* Call the view or table specific function *\/\n      init_func(qdatabase);\n\n      fprintf(md_result_file,\"\\nUSE %s;\\n\", qdatabase);\n      check_io(md_result_file);\n    }\n  }\n  if (extended_insert)\n    init_dynamic_string_checked(&extended_row, \"\", 1024, 1024);\n  return 0;\n} \/* init_dumping *\/","target":1,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":280060,"func":"OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":44010,"func":"static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec)\n{\n\t\/* dock delta_exec before expiring quota (as it could span periods) *\/\n\tcfs_rq->runtime_remaining -= delta_exec;\n\texpire_cfs_rq_runtime(cfs_rq);\n\n\tif (likely(cfs_rq->runtime_remaining > 0))\n\t\treturn;\n\n\t\/*\n\t * if we're unable to extend our runtime we resched so that the active\n\t * hierarchy can be throttled\n\t *\/\n\tif (!assign_cfs_rq_runtime(cfs_rq) && likely(cfs_rq->curr))\n\t\tresched_curr(rq_of(cfs_rq));\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":72562,"func":"  static void launch(OpKernelContext* context, const Tensor& tensor_in,\n                     const std::array<int64, 3>& window,\n                     const std::array<int64, 3>& stride,\n                     const std::array<int64, 3>& padding,\n                     TensorFormat data_format, Padding padding_type,\n                     Tensor* output) {\n    DnnPooling3dOp<T>::Compute(context, se::dnn::PoolingMode::kMaximum, window,\n                               stride, padding, data_format, tensor_in, output);\n  }","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":512032,"func":"sv_mail (name)\n     char *name;\n{\n  \/* If the time interval for checking the files has changed, then\n     reset the mail timer.  Otherwise, one of the pathname vars\n     to the users mailbox has changed, so rebuild the array of\n     filenames. *\/\n  if (name[4] == 'C')  \/* if (strcmp (name, \"MAILCHECK\") == 0) *\/\n    reset_mail_timer ();\n  else\n    {\n      free_mail_files ();\n      remember_mail_dates ();\n    }\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":179148,"func":"aspath_finish (void)\n{\n  hash_clean (ashash, (void (*)(void *))aspath_free);\n  hash_free (ashash);\n  ashash = NULL;\n  \n  if (snmp_stream)\n    stream_free (snmp_stream);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":40902,"func":"void blk_mq_tag_busy_iter(struct blk_mq_hw_ctx *hctx, busy_iter_fn *fn,\n\t\tvoid *priv)\n{\n\tstruct blk_mq_tags *tags = hctx->tags;\n\n\tif (tags->nr_reserved_tags)\n\t\tbt_for_each(hctx, &tags->breserved_tags, 0, fn, priv, true);\n\tbt_for_each(hctx, &tags->bitmap_tags, tags->nr_reserved_tags, fn, priv,\n\t\t\tfalse);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":476018,"func":"time_t base64totime_t(char* s, database* db, const char* field_name){\n  \n  if(strcmp(s,\"0\")==0){\n      return 0;\n  }\n  byte* b=decode_base64(s,strlen(s),NULL);\n  char* endp;\n  \n  if (b==NULL) {\n    \n    \/* Should we print error here? *\/\n    \n    return 0;\n  } else {\n    time_t t = strtol((char *)b,&endp,10);\n    \n    if (endp[0]!='\\0') {\n      LOG_DB_FORMAT_LINE(LOG_LEVEL_WARNING, could not read '%s' from database: strtoll failed for '%s' (base64 encoded value: '%s'), field_name, b, s)\n      free(b);\n      return 0;\n    }\n    log_msg(LOG_LEVEL_DEBUG, \"base64totime_t: converted '%s': '%s' to %lld (base64 encoded value '%s')\", field_name, b, (long long) t, s);\n    free(b);\n    return t;\n  }\n  \n  \n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":26865,"func":"static int dsa_copy_parameters ( EVP_PKEY * to , const EVP_PKEY * from ) {\n BIGNUM * a ;\n if ( to -> pkey . dsa == NULL ) {\n to -> pkey . dsa = DSA_new ( ) ;\n if ( to -> pkey . dsa == NULL ) return 0 ;\n }\n if ( ( a = BN_dup ( from -> pkey . dsa -> p ) ) == NULL ) return 0 ;\n BN_free ( to -> pkey . dsa -> p ) ;\n to -> pkey . dsa -> p = a ;\n if ( ( a = BN_dup ( from -> pkey . dsa -> q ) ) == NULL ) return 0 ;\n BN_free ( to -> pkey . dsa -> q ) ;\n to -> pkey . dsa -> q = a ;\n if ( ( a = BN_dup ( from -> pkey . dsa -> g ) ) == NULL ) return 0 ;\n BN_free ( to -> pkey . dsa -> g ) ;\n to -> pkey . dsa -> g = a ;\n return 1 ;\n }","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":252094,"func":"oftable_set_name(struct oftable *table, const char *name)\n{\n    if (name && name[0]) {\n        int len = strnlen(name, OFP_MAX_TABLE_NAME_LEN);\n        if (!table->name || strncmp(name, table->name, len)) {\n            free(table->name);\n            table->name = xmemdup0(name, len);\n        }\n    } else {\n        free(table->name);\n        table->name = NULL;\n    }\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":472117,"func":"static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel)\n{\n   int slice;\n   int slice_size = w * h * bytes_per_pixel;\n\n   stbi_uc *bytes = (stbi_uc *)image;\n   for (slice = 0; slice < z; ++slice) {\n      stbi__vertical_flip(bytes, w, h, bytes_per_pixel);\n      bytes += slice_size;\n   }\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":295858,"func":"bool HHVM_FUNCTION(imageantialias, const Resource& image, bool on) {\n  gdImagePtr im = get_valid_image_resource(image);\n  if (!im) return false;\n  SetAntiAliased(im, on);\n  return true;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":110448,"func":"static void AttachPSDLayers(Image *image,LayerInfo *layer_info,\n  ssize_t number_layers)\n{\n  register ssize_t\n    i;\n\n  ssize_t\n    j;\n\n  for (i=0; i < number_layers; i++)\n  {\n    if (layer_info[i].image == (Image *) NULL)\n      {\n        for (j=i; j < number_layers - 1; j++)\n          layer_info[j] = layer_info[j+1];\n        number_layers--;\n        i--;\n      }\n  }\n  if (number_layers == 0)\n    {\n      layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info);\n      return;\n    }\n  for (i=0; i < number_layers; i++)\n  {\n    if (i > 0)\n      layer_info[i].image->previous=layer_info[i-1].image;\n    if (i < (number_layers-1))\n      layer_info[i].image->next=layer_info[i+1].image;\n    layer_info[i].image->page=layer_info[i].page;\n  }\n  image->next=layer_info[0].image;\n  layer_info[0].image->previous=image;\n  layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info);\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":178447,"func":"int parse_qvalue(const char *qvalue, const char **end)\n{\n\tint q = 1000;\n\n\tif (!isdigit((unsigned char)*qvalue))\n\t\tgoto out;\n\tq = (*qvalue++ - '0') * 1000;\n\n\tif (*qvalue++ != '.')\n\t\tgoto out;\n\n\tif (!isdigit((unsigned char)*qvalue))\n\t\tgoto out;\n\tq += (*qvalue++ - '0') * 100;\n\n\tif (!isdigit((unsigned char)*qvalue))\n\t\tgoto out;\n\tq += (*qvalue++ - '0') * 10;\n\n\tif (!isdigit((unsigned char)*qvalue))\n\t\tgoto out;\n\tq += (*qvalue++ - '0') * 1;\n out:\n\tif (q > 1000)\n\t\tq = 1000;\n\tif (end)\n\t\t*end = qvalue;\n\treturn q;\n}\n","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":77372,"func":"void ceph_release_acls_info(struct ceph_acls_info *info)\n{\n\tposix_acl_release(info->acl);\n\tposix_acl_release(info->default_acl);\n\tif (info->pagelist)\n\t\tceph_pagelist_release(info->pagelist);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":443674,"func":"static int selinux_is_genfs_special_handling(struct super_block *sb)\n{\n\t\/* Special handling. Genfs but also in-core setxattr handler *\/\n\treturn\t!strcmp(sb->s_type->name, \"sysfs\") ||\n\t\t!strcmp(sb->s_type->name, \"pstore\") ||\n\t\t!strcmp(sb->s_type->name, \"debugfs\") ||\n\t\t!strcmp(sb->s_type->name, \"tracefs\") ||\n\t\t!strcmp(sb->s_type->name, \"rootfs\") ||\n\t\t(selinux_policycap_cgroupseclabel() &&\n\t\t (!strcmp(sb->s_type->name, \"cgroup\") ||\n\t\t  !strcmp(sb->s_type->name, \"cgroup2\")));\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":210083,"func":"static u8 process_acl_entry(sc_file_t *in, unsigned int method, unsigned int in_def)\n{\n\tu8 def = (u8)in_def;\n\tconst sc_acl_entry_t *entry = sc_file_get_acl_entry(in, method);\n\tif (!entry)\n\t{\n\t\treturn def;\n\t}\n\telse if (entry->method & SC_AC_CHV)\n\t{\n\t\tunsigned int key_ref = entry->key_ref;\n\t\tif (key_ref == SC_AC_KEY_REF_NONE)\n\t\t\treturn def;\n\t\telse\n\t\t\treturn ENTERSAFE_AC_ALWAYS&0x04;\n\t}\n\telse if (entry->method & SC_AC_NEVER)\n\t{\n\t\treturn ENTERSAFE_AC_NEVER;\n\t}\n\telse\n\t{\n\t\treturn def;\n\t}\n}\n","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":122539,"func":"ex_change(exarg_T *eap)\n{\n    linenr_T\tlnum;\n\n#ifdef FEAT_EVAL\n    if (not_in_vim9(eap) == FAIL)\n\treturn;\n#endif\n    if (eap->line2 >= eap->line1\n\t    && u_save(eap->line1 - 1, eap->line2 + 1) == FAIL)\n\treturn;\n\n    \/\/ the ! flag toggles autoindent\n    if (eap->forceit ? !curbuf->b_p_ai : curbuf->b_p_ai)\n\tappend_indent = get_indent_lnum(eap->line1);\n\n    for (lnum = eap->line2; lnum >= eap->line1; --lnum)\n    {\n\tif (curbuf->b_ml.ml_flags & ML_EMPTY)\t    \/\/ nothing to delete\n\t    break;\n\tml_delete(eap->line1);\n    }\n\n    \/\/ make sure the cursor is not beyond the end of the file now\n    check_cursor_lnum();\n    deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum));\n\n    \/\/ \":append\" on the line above the deleted lines.\n    eap->line2 = eap->line1;\n    ex_append(eap);\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":141814,"func":"psf_d2s_array (const double *src, short *dest, int count, int normalize)\n{\tdouble \t\t\tnormfact ;\n\n\tnormfact = normalize ? (1.0 * 0x7FFF) : 1.0 ;\n\twhile (--count >= 0)\n\t\tdest [count] = lrint (src [count] * normfact) ;\n\n\treturn ;\n} \/* psf_f2s_array *\/","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":65531,"func":"static inline void ext4_xattr_hash_entry(struct ext4_xattr_header *header,\n\t\t\t\t\t struct ext4_xattr_entry *entry)\n{\n\t__u32 hash = 0;\n\tchar *name = entry->e_name;\n\tint n;\n\n\tfor (n = 0; n < entry->e_name_len; n++) {\n\t\thash = (hash << NAME_HASH_SHIFT) ^\n\t\t       (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^\n\t\t       *name++;\n\t}\n\n\tif (entry->e_value_block == 0 && entry->e_value_size != 0) {\n\t\t__le32 *value = (__le32 *)((char *)header +\n\t\t\tle16_to_cpu(entry->e_value_offs));\n\t\tfor (n = (le32_to_cpu(entry->e_value_size) +\n\t\t     EXT4_XATTR_ROUND) >> EXT4_XATTR_PAD_BITS; n; n--) {\n\t\t\thash = (hash << VALUE_HASH_SHIFT) ^\n\t\t\t       (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^\n\t\t\t       le32_to_cpu(*value++);\n\t\t}\n\t}\n\tentry->e_hash = cpu_to_le32(hash);\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":345121,"func":"PHP_FUNCTION(readfile)\n{\n\tchar *filename;\n\tint filename_len;\n\tint size = 0;\n\tzend_bool use_include_path = 0;\n\tzval *zcontext = NULL;\n\tphp_stream *stream;\n\tphp_stream_context *context = NULL;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s|br!\", &filename, &filename_len, &use_include_path, &zcontext) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tcontext = php_stream_context_from_zval(zcontext, 0);\n\n\tstream = php_stream_open_wrapper_ex(filename, \"rb\", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);\n\tif (stream) {\n\t\tsize = php_stream_passthru(stream);\n\t\tphp_stream_close(stream);\n\t\tRETURN_LONG(size);\n\t}\n\n\tRETURN_FALSE;\n}","target":1,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":36368,"func":"flatpak_bwrap_steal_fds (FlatpakBwrap *bwrap,\n                         gsize        *len_out)\n{\n  gsize len = bwrap->fds->len;\n  int *res = (int *) g_array_free (bwrap->fds, FALSE);\n\n  bwrap->fds = g_array_new (FALSE, TRUE, sizeof (int));\n  *len_out = len;\n  return res;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":452579,"func":"CtPtr ProtocolV1::read_message_front() {\n  ldout(cct, 20) << __func__ << dendl;\n\n  unsigned front_len = current_header.front_len;\n  if (front_len) {\n    if (!front.length()) {\n      front.push_back(buffer::create(front_len));\n    }\n    return READB(front_len, front.c_str(), handle_message_front);\n  }\n  return read_message_middle();\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":258714,"func":"    template<typename T>\n    inline T& temporary(const T&) {\n      static T temp;\n      return temp;","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":325803,"func":"static void change_parent_backing_link(BlockDriverState *from,\n\n                                       BlockDriverState *to)\n\n{\n\n    BdrvChild *c, *next, *to_c;\n\n\n\n    QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {\n\n        if (c->role->stay_at_node) {\n\n            continue;\n\n        }\n\n        if (c->role == &child_backing) {\n\n            \/* @from is generally not allowed to be a backing file, except for\n\n             * when @to is the overlay. In that case, @from may not be replaced\n\n             * by @to as @to's backing node. *\/\n\n            QLIST_FOREACH(to_c, &to->children, next) {\n\n                if (to_c == c) {\n\n                    break;\n\n                }\n\n            }\n\n            if (to_c) {\n\n                continue;\n\n            }\n\n        }\n\n\n\n        assert(c->role != &child_backing);\n\n        bdrv_ref(to);\n\n        \/* FIXME Are we sure that bdrv_replace_child() can't run into\n\n         * &error_abort because of permissions? *\/\n\n        bdrv_replace_child(c, to, true);\n\n        bdrv_unref(from);\n\n    }\n\n}\n","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":221179,"func":"void ContentSecurityPolicy::ReportMissingReportURI(const String& policy) {\n  LogToConsole(\"The Content Security Policy '\" + policy +\n               \"' was delivered in report-only mode, but does not specify a \"\n               \"'report-uri'; the policy will have no effect. Please either \"\n               \"add a 'report-uri' directive, or deliver the policy via the \"\n               \"'Content-Security-Policy' header.\");\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":437863,"func":"static void set_default_ppflags(vp8_postproc_cfg_t *cfg) {\n  cfg->post_proc_flag = VP8_DEBLOCK | VP8_DEMACROBLOCK;\n  cfg->deblocking_level = 4;\n  cfg->noise_level = 0;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":245502,"func":"void RenderFrameHostImpl::FrameSizeChanged(const gfx::Size& frame_size) {\n  frame_size_ = frame_size;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":314964,"func":"static std::string selectionAsString(WebFrame* frame)\n{\n    return frame->selectionAsText().utf8();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":273995,"func":"ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,\n\t\t const struct isakmp_gen *ext, u_int item_len _U_,\n\t\t const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,\n\t\t uint32_t proto _U_, int depth _U_)\n{\n\tstruct isakmp_gen e;\n\n\tND_PRINT((ndo,\"%s:\", NPSTR(ISAKMP_NPTYPE_HASH)));\n\n\tND_TCHECK(*ext);\n\tUNALIGNED_MEMCPY(&e, ext, sizeof(e));\n\tND_PRINT((ndo,\" len=%d\", ntohs(e.len) - 4));\n\tif (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {\n\t\t\/* Print the entire payload in hex *\/\n\t\tND_PRINT((ndo,\" \"));\n\t\tif (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))\n\t\t\tgoto trunc;\n\t}\n\treturn (const u_char *)ext + ntohs(e.len);\ntrunc:\n\tND_PRINT((ndo,\" [|%s]\", NPSTR(ISAKMP_NPTYPE_HASH)));\n\treturn NULL;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":431947,"func":"static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,\n\t\tstruct nlattr **attrs)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct sk_buff *r_skb;\n\tu32 *flags = nlmsg_data(nlh);\n\tu32 sportid = NETLINK_CB(skb).portid;\n\tu32 seq = nlh->nlmsg_seq;\n\tint err;\n\n\tr_skb = nlmsg_new(xfrm_spdinfo_msgsize(), GFP_ATOMIC);\n\tif (r_skb == NULL)\n\t\treturn -ENOMEM;\n\n\terr = build_spdinfo(r_skb, net, sportid, seq, *flags);\n\tBUG_ON(err < 0);\n\n\treturn nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":391365,"func":"unsigned int cl_retflevel(void)\n{\n    return CL_FLEVEL;\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":264839,"func":"static inline void setsck(const struct spi_device *spi, int is_on)\n{\n\tstruct spi_gpio *spi_gpio = spi_to_spi_gpio(spi);\n\n\tgpiod_set_value_cansleep(spi_gpio->sck, is_on);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":314764,"func":" image_transform_png_set_expand_add(image_transform *this,\n    const image_transform **that, png_byte colour_type, png_byte bit_depth)\n {\n    UNUSED(bit_depth)\n \n this->next = *that;\n *that = this;\n\n \/* 'expand' should do nothing for RGBA or GA input - no tRNS and the bit\n    * depth is at least 8 already.\n    *\/\n return (colour_type & PNG_COLOR_MASK_ALPHA) == 0;\n}\n","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":198906,"func":"void GLES2DecoderPassthroughImpl::ClearAllAttributes() const {}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":104188,"func":"reset_VIsual_and_resel(void)\n{\n    if (VIsual_active)\n    {\n\tend_visual_mode();\n\tredraw_curbuf_later(INVERTED);\t\/\/ delete the inversion later\n    }\n    VIsual_reselect = FALSE;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":75121,"func":"xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what,\n\t\t        xmlChar end, xmlChar  end2, xmlChar end3) {\n    if ((ctxt == NULL) || (str == NULL)) return(NULL);\n    return(xmlStringLenDecodeEntities(ctxt, str, xmlStrlen(str), what,\n           end, end2, end3));\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":85843,"func":"void FS_TouchFile_f( void ) {\n\tfileHandle_t f;\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"Usage: touchFile <file>\\n\" );\n\t\treturn;\n\t}\n\n\tFS_FOpenFileRead( Cmd_Argv( 1 ), &f, qfalse );\n\tif ( f ) {\n\t\tFS_FCloseFile( f );\n\t}\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":33968,"func":"static int __hrtick_restart(struct rq *rq)\n{\n\tstruct hrtimer *timer = &rq->hrtick_timer;\n\tktime_t time = hrtimer_get_softexpires(timer);\n\n\treturn __hrtimer_start_range_ns(timer, time, 0, HRTIMER_MODE_ABS_PINNED, 0);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":189507,"func":"PHP_FUNCTION(pg_fetch_row)\n{\n\tphp_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_NUM, 0);\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":491997,"func":"void BrotliContext::finalizeOutput(Buffer::Instance& output_buffer) {\n  const size_t n_output = chunk_size_ - avail_out_;\n  if (n_output > 0) {\n    output_buffer.add(static_cast<void*>(chunk_ptr_.get()), n_output);\n  }\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":413923,"func":"  Statement_Ptr Expand::operator()(Return_Ptr r)\n  {\n    error(\"@return may only be used within a function\", r->pstate(), traces);\n    return 0;\n  }","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":262598,"func":"static void tg3_stop(struct tg3 *tp)\n{\n\tint i;\n\n\ttg3_reset_task_cancel(tp);\n\ttg3_netif_stop(tp);\n\n\ttg3_timer_stop(tp);\n\n\ttg3_hwmon_close(tp);\n\n\ttg3_phy_stop(tp);\n\n\ttg3_full_lock(tp, 1);\n\n\ttg3_disable_ints(tp);\n\n\ttg3_halt(tp, RESET_KIND_SHUTDOWN, 1);\n\ttg3_free_rings(tp);\n\ttg3_flag_clear(tp, INIT_COMPLETE);\n\n\ttg3_full_unlock(tp);\n\n\tfor (i = tp->irq_cnt - 1; i >= 0; i--) {\n\t\tstruct tg3_napi *tnapi = &tp->napi[i];\n\t\tfree_irq(tnapi->irq_vec, tnapi);\n\t}\n\n\ttg3_ints_fini(tp);\n\n\ttg3_napi_fini(tp);\n\n\ttg3_free_consistent(tp);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":118218,"func":"  Event::Dispatcher& dispatcher() override { return dispatcher_; }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":12010,"func":"void DistillerNativeJavaScript::AddJavaScriptObjectToFrame(\n    v8::Local<v8::Context> context) {\n  v8::Isolate* isolate = blink::mainThreadIsolate();\n  v8::HandleScope handle_scope(isolate);\n  if (context.IsEmpty())\n    return;\n\n  v8::Context::Scope context_scope(context);\n\n   v8::Local<v8::Object> distiller_obj =\n       GetOrCreateDistillerObject(isolate, context->Global());\n \n   BindFunctionToObject(\n       distiller_obj,\n       \"echo\",\n       base::Bind(\n           &DistillerNativeJavaScript::DistillerEcho, base::Unretained(this)));\n \n   BindFunctionToObject(\n       distiller_obj,\n       \"sendFeedback\",\n       base::Bind(\n          &DistillerNativeJavaScript::DistillerSendFeedback,\n          base::Unretained(this)));\n \n   BindFunctionToObject(\n       distiller_obj,\n       \"closePanel\",\n       base::Bind(\n          &DistillerNativeJavaScript::DistillerClosePanel,\n          base::Unretained(this)));\n }\n","target":1,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":185885,"func":"TestURLFetcher::~TestURLFetcher() {\n}\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":138274,"func":"    template<typename T>","target":0,"code_token_length":5,"total_token_length":241,"max_tokens_setting":512}
+{"idx":8035,"func":"void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {\n  global_State *g = G(L);\n  lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));\n  if (keepinvariant(g)) {  \/* must keep invariant? *\/\n    reallymarkobject(g, v);  \/* restore invariant *\/\n    if (isold(o)) {\n      lua_assert(!isold(v));  \/* white object could not be old *\/\n      setage(v, G_OLD0);  \/* restore generational invariant *\/\n    }\n  }\n  else {  \/* sweep phase *\/\n    lua_assert(issweepphase(g));\n    makewhite(g, o);  \/* mark main obj. as white to avoid other barriers *\/\n  }\n}","target":1,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":230288,"func":"void Location::setHref(LocalDOMWindow* current_window,\n                       LocalDOMWindow* entered_window,\n                       const USVStringOrTrustedURL& stringOrUrl,\n                       ExceptionState& exception_state) {\n  String url = GetStringFromTrustedURL(stringOrUrl, current_window->document(),\n                                       exception_state);\n  if (!exception_state.HadException()) {\n    SetLocation(url, current_window, entered_window, &exception_state);\n  }\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":310829,"func":"void NEVER_INLINE FreeList::ZapFreedMemory(Address address, size_t size) {\n  for (size_t i = 0; i < size; i++) {\n    if (address[i] != kReuseAllowedZapValue)\n      address[i] = kReuseForbiddenZapValue;\n  }\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":489501,"func":"\t\tds->request_period_switch = new_period_request ? 2 : 1;\n\t\treturn GF_OK;\n\t}\n\t\/\/done for this stream\n\treturn dasher_stream_period_changed(filter, ctx, ds, new_period_request);\n}\n\nstatic void\tdasher_check_chaining(GF_DasherCtx *ctx, char *scheme_id, char *url)\n{\n\tGF_MPD_Descriptor *d = gf_mpd_get_descriptor(ctx->mpd->supplemental_properties, scheme_id);\n\tif (!d && !url) return;\n\tif (!url) {\n\t\tgf_list_del_item(ctx->mpd->supplemental_properties, d);\n\t\tgf_mpd_descriptor_free(d);\n\t\treturn;\n\t}\n\tif (d) {\n\t\tgf_free(d->value);\n\t\td->value = gf_strdup(url);\n\t\treturn;","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":120619,"func":"spnego_gss_wrap_aead(OM_uint32 *minor_status,\n\t\t     gss_ctx_id_t context_handle,\n\t\t     int conf_req_flag,\n\t\t     gss_qop_t qop_req,\n\t\t     gss_buffer_t input_assoc_buffer,\n\t\t     gss_buffer_t input_payload_buffer,\n\t\t     int *conf_state,\n\t\t     gss_buffer_t output_message_buffer)\n{\n\tOM_uint32 ret;\n\tspnego_gss_ctx_id_t sc = (spnego_gss_ctx_id_t)context_handle;\n\n\tif (sc->ctx_handle == GSS_C_NO_CONTEXT)\n\t\treturn (GSS_S_NO_CONTEXT);\n\n\tret = gss_wrap_aead(minor_status,\n\t\t\t    sc->ctx_handle,\n\t\t\t    conf_req_flag,\n\t\t\t    qop_req,\n\t\t\t    input_assoc_buffer,\n\t\t\t    input_payload_buffer,\n\t\t\t    conf_state,\n\t\t\t    output_message_buffer);\n\n\treturn (ret);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":284727,"func":"pattern_instance_uses_base_space(const gs_pattern_instance_t * pinst)\n{\n    return pinst->type->procs.uses_base_space(\n                   pinst->type->procs.get_pattern(pinst) );\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":151810,"func":"bit_read_BS (Bit_Chain *dat)\n{\n  const unsigned char two_bit_code = bit_read_BB (dat);\n  if (two_bit_code == 0)\n    return bit_read_RS (dat);\n  else if (two_bit_code == 1)\n    return (BITCODE_BS)bit_read_RC (dat) & 0xFF;\n  else if (two_bit_code == 2)\n    return 0;\n  else \/* if (two_bit_code == 3) *\/\n    return 256;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":431087,"func":"bool AuthorizationSessionImpl::isAuthorizedForActionsOnResource(const ResourcePattern& resource,\n                                                                ActionType action) {\n    return isAuthorizedForPrivilege(Privilege(resource, action));\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":158966,"func":"bool WebContents::IsGuest() const {\n  return type_ == Type::WEB_VIEW;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":25488,"func":"static int config_filter_parser_cmp ( struct config_filter_parser * const * p1 , struct config_filter_parser * const * p2 ) {\n const struct config_filter * f1 = & ( * p1 ) -> filter , * f2 = & ( * p2 ) -> filter ;\n if ( f1 -> local_name != NULL && f2 -> local_name == NULL ) return - 1 ;\n if ( f1 -> local_name == NULL && f2 -> local_name != NULL ) return 1 ;\n if ( f1 -> local_bits > f2 -> local_bits ) return - 1 ;\n if ( f1 -> local_bits < f2 -> local_bits ) return 1 ;\n if ( f1 -> remote_bits > f2 -> remote_bits ) return - 1 ;\n if ( f1 -> remote_bits < f2 -> remote_bits ) return 1 ;\n if ( f1 -> service != NULL && f2 -> service == NULL ) return - 1 ;\n if ( f1 -> service == NULL && f2 -> service != NULL ) return 1 ;\n return 0 ;\n }","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":273817,"func":"static int finish_open_channel (lua_State *L, int status, lua_KContext ctx) {\n    ssh_userdata *state = (ssh_userdata *)lua_touserdata(L, 1);\n    LIBSSH2_CHANNEL **channel = (LIBSSH2_CHANNEL **) lua_touserdata(L, 2);\n\n    while ((*channel = libssh2_channel_open_session(state->session)) == NULL\n    && libssh2_session_last_errno(state->session) == LIBSSH2_ERROR_EAGAIN) {\n        luaL_getmetafield(L, 1, \"filter\");\n        lua_pushvalue(L, 1);\n        lua_callk(L, 1, 0, 0, finish_open_channel);\n    }\n    if (channel == NULL)\n        return luaL_error(L, \"Opening channel\");\n\n    return setup_channel(L, 0, 0);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":457838,"func":"static void io_cancel_defer_files(struct io_ring_ctx *ctx,\n\t\t\t\t  struct files_struct *files)\n{\n\tstruct io_defer_entry *de = NULL;\n\tLIST_HEAD(list);\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tlist_for_each_entry_reverse(de, &ctx->defer_list, list) {\n\t\tif (io_match_link_files(de->req, files)) {\n\t\t\tlist_cut_position(&list, &ctx->defer_list, &de->list);\n\t\t\tbreak;\n\t\t}\n\t}\n\tspin_unlock_irq(&ctx->completion_lock);\n\n\twhile (!list_empty(&list)) {\n\t\tde = list_first_entry(&list, struct io_defer_entry, list);\n\t\tlist_del_init(&de->list);\n\t\treq_set_fail_links(de->req);\n\t\tio_put_req(de->req);\n\t\tio_req_complete(de->req, -ECANCELED);\n\t\tkfree(de);\n\t}\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":417048,"func":"ofputil_decode_ofp10_phy_port(struct ofputil_phy_port *pp,\n                              const struct ofp10_phy_port *opp)\n{\n    pp->port_no = u16_to_ofp(ntohs(opp->port_no));\n    pp->hw_addr = opp->hw_addr;\n    ovs_strlcpy(pp->name, opp->name, OFP_MAX_PORT_NAME_LEN);\n\n    pp->config = ntohl(opp->config) & OFPPC10_ALL;\n    pp->state = ntohl(opp->state) & OFPPS10_ALL;\n\n    pp->curr = netdev_port_features_from_ofp10(opp->curr);\n    pp->advertised = netdev_port_features_from_ofp10(opp->advertised);\n    pp->supported = netdev_port_features_from_ofp10(opp->supported);\n    pp->peer = netdev_port_features_from_ofp10(opp->peer);\n\n    pp->curr_speed = netdev_features_to_bps(pp->curr, 0) \/ 1000;\n    pp->max_speed = netdev_features_to_bps(pp->supported, 0) \/ 1000;\n\n    return 0;\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":319191,"func":"bool qemu_clock_expired(QEMUClockType type)\n\n{\n\n    return timerlist_expired(\n\n        main_loop_tlg.tl[type]);\n\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":101224,"func":"static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,\n\t\t\t int what)\n{\n\tswitch (i->type) {\n\tcase PACKET_MR_MULTICAST:\n\t\tif (i->alen != dev->addr_len)\n\t\t\treturn -EINVAL;\n\t\tif (what > 0)\n\t\t\treturn dev_mc_add(dev, i->addr);\n\t\telse\n\t\t\treturn dev_mc_del(dev, i->addr);\n\t\tbreak;\n\tcase PACKET_MR_PROMISC:\n\t\treturn dev_set_promiscuity(dev, what);\n\tcase PACKET_MR_ALLMULTI:\n\t\treturn dev_set_allmulti(dev, what);\n\tcase PACKET_MR_UNICAST:\n\t\tif (i->alen != dev->addr_len)\n\t\t\treturn -EINVAL;\n\t\tif (what > 0)\n\t\t\treturn dev_uc_add(dev, i->addr);\n\t\telse\n\t\t\treturn dev_uc_del(dev, i->addr);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":135819,"func":"static void init_dequant_tables(H264Context *h)\n{\n    int i, x;\n    init_dequant4_coeff_table(h);\n    if (h->pps.transform_8x8_mode)\n        init_dequant8_coeff_table(h);\n    if (h->sps.transform_bypass) {\n        for (i = 0; i < 6; i++)\n            for (x = 0; x < 16; x++)\n                h->dequant4_coeff[i][0][x] = 1 << 6;\n        if (h->pps.transform_8x8_mode)\n            for (i = 0; i < 6; i++)\n                for (x = 0; x < 64; x++)\n                    h->dequant8_coeff[i][0][x] = 1 << 6;\n    }\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":212324,"func":"gx_dc_shading_path_add_box(gx_path *ppath, const gx_device_color * pdevc)\n{\n    gs_pattern2_instance_t *pinst = (gs_pattern2_instance_t *)pdevc->ccolor.pattern;\n    const gs_shading_t *psh = pinst->templat.Shading;\n\n    if (!psh->params.have_BBox)\n        return_error(gs_error_unregistered); \/* Do not call in this case. *\/\n    else {\n        gs_gstate *pgs = pinst->saved;\n\n        return gs_shading_path_add_box(ppath, &psh->params.BBox, &pgs->ctm);\n    }\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":7230,"func":"static void vgacon_scrolldelta(struct vc_data *c, int lines)\n{\n\tvc_scrolldelta_helper(c, lines, vga_rolled_over, (void *)vga_vram_base,\n\t\t\tvga_vram_size);\n\tvga_set_mem_top(c);\n}","target":1,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":104577,"func":"int STDCALL\nmysql_send_query(MYSQL* mysql, const char* query, ulong length)\n{\n  DBUG_ENTER(\"mysql_send_query\");\n  DBUG_RETURN(simple_command(mysql, COM_QUERY, (uchar*) query, length, 1));","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":270044,"func":"dir_is_locked (GFile *dir)\n{\n  glnx_autofd int ref_fd = -1;\n  struct flock lock = {0};\n  g_autoptr(GFile) reffile = NULL;\n\n  reffile = g_file_resolve_relative_path (dir, \"files\/.ref\");\n\n  ref_fd = open (flatpak_file_get_path_cached (reffile), O_RDWR | O_CLOEXEC);\n  if (ref_fd != -1)\n    {\n      lock.l_type = F_WRLCK;\n      lock.l_whence = SEEK_SET;\n      lock.l_start = 0;\n      lock.l_len = 0;\n\n      if (fcntl (ref_fd, F_GETLK, &lock) == 0)\n        return lock.l_type != F_UNLCK;\n    }\n\n  return FALSE;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":310922,"func":"run_selftests (int algo, int extended, selftest_report_func_t report)\n{\n  (void)extended;\n\n  if (algo != GCRY_PK_ECC)\n    return GPG_ERR_PUBKEY_ALGO;\n\n  return selftests_ecdsa (report);\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":439167,"func":"static void inode_dnode_free(dnode_t *node,\n\t\t\t     void *context EXT2FS_ATTR((unused)))\n{\n\tstruct dup_inode\t*di;\n\tstruct cluster_el\t\t*p, *next;\n\n\tdi = (struct dup_inode *) dnode_get(node);\n\tfor (p = di->cluster_list; p; p = next) {\n\t\tnext = p->next;\n\t\tfree(p);\n\t}\n\tfree(di);\n\tfree(node);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":67905,"func":"static struct dm_table *dm_get_inactive_table(struct mapped_device *md, int *srcu_idx)\n{\n\tstruct hash_cell *hc;\n\tstruct dm_table *table = NULL;\n\n\t\/* increment rcu count, we don't care about the table pointer *\/\n\tdm_get_live_table(md, srcu_idx);\n\n\tdown_read(&_hash_lock);\n\thc = dm_get_mdptr(md);\n\tif (!hc || hc->md != md) {\n\t\tDMWARN(\"device has been removed from the dev hash table.\");\n\t\tgoto out;\n\t}\n\n\ttable = hc->new_map;\n\nout:\n\tup_read(&_hash_lock);\n\n\treturn table;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":415319,"func":"disconnect_callback (GDBusProxy   *proxy,\n\t\t     GAsyncResult *res,\n\t\t     GSimpleAsyncResult *simple)\n{\n\tgboolean retval;\n\tGError *error = NULL;\n\n\tretval = device1_call_disconnect_finish (DEVICE1(proxy), res, &error);\n\tif (retval == FALSE) {\n\t\tg_debug (\"Disconnect failed for %s: %s\",\n\t\t\t g_dbus_proxy_get_object_path (proxy),\n\t\t\t error->message);\n\t\tg_simple_async_result_take_error (simple, error);\n\t} else {\n\t\tg_debug (\"Disconnect succeeded for %s\",\n\t\t\t g_dbus_proxy_get_object_path (proxy));\n\t\tg_simple_async_result_set_op_res_gboolean (simple, retval);\n\t}\n\n\tg_simple_async_result_complete_in_idle (simple);\n\n\tg_object_unref (simple);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":430048,"func":"int htp_hdr_valcb(llhttp_t *htp, const char *data, size_t len) {\n  auto upstream = static_cast<HttpsUpstream *>(htp->data);\n  auto downstream = upstream->get_downstream();\n  auto &req = downstream->request();\n\n  if (req.fs.buffer_size() + len >\n      get_config()->http.request_header_field_buffer) {\n    if (LOG_ENABLED(INFO)) {\n      ULOG(INFO, upstream) << \"Too large header block size=\"\n                           << req.fs.buffer_size() + len;\n    }\n    if (downstream->get_request_state() == DownstreamState::INITIAL) {\n      downstream->set_request_state(\n          DownstreamState::HTTP1_REQUEST_HEADER_TOO_LARGE);\n    }\n    llhttp_set_error_reason(htp, \"too large header\");\n    return HPE_USER;\n  }\n  if (downstream->get_request_state() == DownstreamState::INITIAL) {\n    req.fs.append_last_header_value(data, len);\n  } else {\n    req.fs.append_last_trailer_value(data, len);\n  }\n  return 0;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":80427,"func":"void rcuwait_wake_up(struct rcuwait *w)\n{\n\tstruct task_struct *task;\n\n\trcu_read_lock();\n\n\t\/*\n\t * Order condition vs @task, such that everything prior to the load\n\t * of @task is visible. This is the condition as to why the user called\n\t * rcuwait_trywake() in the first place. Pairs with set_current_state()\n\t * barrier (A) in rcuwait_wait_event().\n\t *\n\t *    WAIT                WAKE\n\t *    [S] tsk = current\t  [S] cond = true\n\t *        MB (A)\t      MB (B)\n\t *    [L] cond\t\t  [L] tsk\n\t *\/\n\tsmp_rmb(); \/* (B) *\/\n\n\t\/*\n\t * Avoid using task_rcu_dereference() magic as long as we are careful,\n\t * see comment in rcuwait_wait_event() regarding ->exit_state.\n\t *\/\n\ttask = rcu_dereference(w->task);\n\tif (task)\n\t\twake_up_process(task);\n\trcu_read_unlock();\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":467640,"func":"static int _annotate_rewrite(struct mailbox *oldmailbox,\n                             uint32_t olduid,\n                             const char *olduserid,\n                             struct mailbox *newmailbox,\n                             uint32_t newuid,\n                             const char *newuserid,\n                             int copy)\n{\n    struct rename_rock rrock;\n\n    rrock.oldmailbox = oldmailbox;\n    rrock.newmailbox = newmailbox;\n    rrock.olduserid = olduserid;\n    rrock.newuserid = newuserid;\n    rrock.olduid = olduid;\n    rrock.newuid = newuid;\n    rrock.copy = copy;\n\n    return annotatemore_findall(oldmailbox->name, olduid, \"*\", \/*modseq*\/0,\n                                &rename_cb, &rrock, \/*flags*\/0);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":340513,"func":"CPUMIPSState *cpu_mips_init (const char *cpu_model)\n\n{\n\n    CPUMIPSState *env;\n\n    const mips_def_t *def;\n\n\n\n    def = cpu_mips_find_by_name(cpu_model);\n\n    if (!def)\n\n        return NULL;\n\n    env = qemu_mallocz(sizeof(CPUMIPSState));\n\n    env->cpu_model = def;\n\n\n\n    cpu_exec_init(env);\n\n    env->cpu_model_str = cpu_model;\n\n    mips_tcg_init();\n\n    cpu_reset(env);\n\n    qemu_init_vcpu(env);\n\n    return env;\n\n}\n","target":1,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":304949,"func":"  void flushRequestsAndLoopN(uint64_t n,\n    bool eof=false, milliseconds eofDelay=milliseconds(0),\n    milliseconds initialDelay=milliseconds(0),\n    std::function<void()> extraEventsFn = std::function<void()>()) {\n    flushRequests(eof, eofDelay, initialDelay, extraEventsFn);\n    for (uint64_t i = 0; i < n; i++) {\n      eventBase_.loopOnce();\n    }\n  }","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":162903,"func":"std::unique_ptr<TracedValue> InspectorPaintImageEvent::Data(\n    const LayoutImage& layout_image,\n    const FloatRect& src_rect,\n    const FloatRect& dest_rect) {\n  std::unique_ptr<TracedValue> value = TracedValue::Create();\n  SetGeneratingNodeInfo(value.get(), &layout_image, \"nodeId\");\n  if (const ImageResourceContent* resource = layout_image.CachedImage())\n    value->SetString(\"url\", resource->Url().GetString());\n\n  value->SetInteger(\"x\", dest_rect.X());\n  value->SetInteger(\"y\", dest_rect.Y());\n  value->SetInteger(\"width\", dest_rect.Width());\n  value->SetInteger(\"height\", dest_rect.Height());\n  value->SetInteger(\"srcWidth\", src_rect.Width());\n  value->SetInteger(\"srcHeight\", src_rect.Height());\n\n  return value;\n}\n","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":238738,"func":"void RenderFrameHostManager::SetRWHViewForInnerContents(\n    RenderWidgetHostView* child_rwhv) {\n  DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame());\n  GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv, nullptr);\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":139286,"func":"int jffs2_init_acl_post(struct inode *inode)\n{\n\tint rc;\n\n\tif (inode->i_default_acl) {\n\t\trc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_DEFAULT, inode->i_default_acl);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tif (inode->i_acl) {\n\t\trc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_ACCESS, inode->i_acl);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":508450,"func":"int SSL_state(const SSL *ssl)\n{\n    return (ssl->state);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":359398,"func":"check_mountpoint(const char *progname, char *mountpoint)\n{\n\tint err;\n\tstruct stat statbuf;\n\n\t\/* does mountpoint exist and is it a directory? *\/\n\terr = stat(\".\", &statbuf);\n\tif (err) {\n\t\tfprintf(stderr, \"%s: failed to stat %s: %s\\n\", progname,\n\t\t\t\tmountpoint, strerror(errno));\n\t\treturn EX_USAGE;\n\t}\n\n\tif (!S_ISDIR(statbuf.st_mode)) {\n\t\tfprintf(stderr, \"%s: %s is not a directory!\", progname,\n\t\t\t\tmountpoint);\n\t\treturn EX_USAGE;\n\t}\n\n#if CIFS_LEGACY_SETUID_CHECK\n\t\/* do extra checks on mountpoint for legacy setuid behavior *\/\n\tif (!getuid() || geteuid())\n\t\treturn 0;\n\n\tif (statbuf.st_uid != getuid()) {\n\t\tfprintf(stderr, \"%s: %s is not owned by user\\n\", progname,\n\t\t\tmountpoint);\n\t\treturn EX_USAGE;\n\t}\n\n\tif ((statbuf.st_mode & S_IRWXU) != S_IRWXU) {\n\t\tfprintf(stderr, \"%s: invalid permissions on %s\\n\", progname,\n\t\t\tmountpoint);\n\t\treturn EX_USAGE;\n\t}\n#endif \/* CIFS_LEGACY_SETUID_CHECK *\/\n\n\treturn 0;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":275191,"func":"unsigned long SSL_CIPHER_get_id(const SSL_CIPHER* cipher) { return cipher->id; }\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":155186,"func":"static struct sched_domain *__build_book_sched_domain(struct s_data *d,\n\tconst struct cpumask *cpu_map, struct sched_domain_attr *attr,\n\tstruct sched_domain *parent, int i)\n{\n\tstruct sched_domain *sd = parent;\n#ifdef CONFIG_SCHED_BOOK\n\tsd = &per_cpu(book_domains, i).sd;\n\tSD_INIT(sd, BOOK);\n\tset_domain_attribute(sd, attr);\n\tcpumask_and(sched_domain_span(sd), cpu_map, cpu_book_mask(i));\n\tsd->parent = parent;\n\tparent->child = sd;\n\tcpu_to_book_group(i, cpu_map, &sd->groups, d->tmpmask);\n#endif\n\treturn sd;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":152574,"func":"static void json_tokener_reset_level(struct json_tokener *tok, int depth)\n{\n  tok->stack[depth].state = json_tokener_state_eatws;\n  tok->stack[depth].saved_state = json_tokener_state_start;\n  json_object_put(tok->stack[depth].current);\n  tok->stack[depth].current = NULL;\n  free(tok->stack[depth].obj_field_name);\n  tok->stack[depth].obj_field_name = NULL;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":225125,"func":"gchar* webkit_web_view_get_selected_text(WebKitWebView* webView)\n{\n    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);\n\n    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();\n    return g_strdup(frame->editor()->selectedText().utf8().data());\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":417042,"func":"ofputil_encode_port_status(const struct ofputil_port_status *ps,\n                           enum ofputil_protocol protocol)\n{\n    struct ofp_port_status *ops;\n    struct ofpbuf *b;\n    enum ofp_version version;\n    enum ofpraw raw;\n\n    version = ofputil_protocol_to_ofp_version(protocol);\n    switch (version) {\n    case OFP10_VERSION:\n        raw = OFPRAW_OFPT10_PORT_STATUS;\n        break;\n\n    case OFP11_VERSION:\n    case OFP12_VERSION:\n    case OFP13_VERSION:\n        raw = OFPRAW_OFPT11_PORT_STATUS;\n        break;\n\n    case OFP14_VERSION:\n    case OFP15_VERSION:\n    case OFP16_VERSION:\n        raw = OFPRAW_OFPT14_PORT_STATUS;\n        break;\n\n    default:\n        OVS_NOT_REACHED();\n    }\n\n    b = ofpraw_alloc_xid(raw, version, htonl(0), 0);\n    ops = ofpbuf_put_zeros(b, sizeof *ops);\n    ops->reason = ps->reason;\n    ofputil_put_phy_port(version, &ps->desc, b);\n    ofpmsg_update_length(b);\n    return b;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":186484,"func":"void InspectorResourceAgent::didReceiveData(LocalFrame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)\n{\n    String requestId = IdentifiersFactory::requestId(identifier);\n\n    if (data) {\n        NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->data(requestId);\n        if (resourceData && (!resourceData->cachedResource() || resourceData->cachedResource()->dataBufferingPolicy() == DoNotBufferData || isErrorStatusCode(resourceData->httpStatusCode())))\n            m_resourcesData->maybeAddResourceData(requestId, data, dataLength);\n    }\n\n    m_frontend->dataReceived(requestId, currentTime(), dataLength, encodedDataLength);\n}\n","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":235246,"func":"  gfx::SelectionBound GetSelectionBoundFromRect(const gfx::Rect& rect) {\n    gfx::SelectionBound bound;\n    bound.SetEdge(gfx::PointF(rect.origin()), gfx::PointF(rect.bottom_left()));\n    return bound;\n  }\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":449106,"func":"check_socket_flag(int sock_flag, int fd_flag, int fs_flag)\n{\n  int sock_fd, fd_flags, fs_flags;\n\n  sock_fd = socket(AF_INET, SOCK_DGRAM | sock_flag, 0);\n  if (sock_fd < 0)\n    return 0;\n\n  fd_flags = fcntl(sock_fd, F_GETFD);\n  fs_flags = fcntl(sock_fd, F_GETFL);\n\n  close(sock_fd);\n\n  if (fd_flags == -1 || (fd_flags & fd_flag) != fd_flag ||\n      fs_flags == -1 || (fs_flags & fs_flag) != fs_flag)\n    return 0;\n\n  return 1;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":293226,"func":"static gboolean property_exists_modalias(const GDBusPropertyTable *property,\n\t\t\t\t\t\t\tvoid *user_data)\n{\n\tstruct btd_adapter *adapter = user_data;\n\n\treturn adapter->modalias ? TRUE : FALSE;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":462019,"func":"void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p)\n{\n\tdrm_printf(p, \"%s firmware: %s\\n\",\n\t\t   intel_uc_fw_type_repr(uc_fw->type), uc_fw->path);\n\tdrm_printf(p, \"\\tstatus: %s\\n\",\n\t\t   intel_uc_fw_status_repr(uc_fw->status));\n\tdrm_printf(p, \"\\tversion: wanted %u.%u, found %u.%u\\n\",\n\t\t   uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted,\n\t\t   uc_fw->major_ver_found, uc_fw->minor_ver_found);\n\tdrm_printf(p, \"\\tuCode: %u bytes\\n\", uc_fw->ucode_size);\n\tdrm_printf(p, \"\\tRSA: %u bytes\\n\", uc_fw->rsa_size);\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":2827,"func":"static bool states_equal(struct bpf_verifier_env *env,\n\t\t\t struct bpf_verifier_state *old,\n\t\t\t struct bpf_verifier_state *cur)\n{\n\tint i;\n\n\tif (old->curframe != cur->curframe)\n\t\treturn false;\n\n\t\/* for states to be equal callsites have to be the same\n\t * and all frame states need to be equivalent\n\t *\/\n\tfor (i = 0; i <= old->curframe; i++) {\n\t\tif (old->frame[i]->callsite != cur->frame[i]->callsite)\n\t\t\treturn false;\n\t\tif (!func_states_equal(old->frame[i], cur->frame[i]))\n\t\t\treturn false;\n\t}\n\treturn true;\n}","target":1,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":276745,"func":"  count_faces_sfnt( char*  fond_data )\n  {\n    \/* The count is 1 greater than the value in the FOND.  *\/\n    \/* Isn't that cute? :-)                                *\/\n\n    return EndianS16_BtoN( *( (short*)( fond_data +\n                                        sizeof ( FamRec ) ) ) ) + 1;\n  }\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":418939,"func":"ZEND_METHOD(Generator, next)\n{\n\tzend_generator *generator;\n\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tgenerator = (zend_generator *) Z_OBJ_P(getThis());\n\n\tzend_generator_ensure_initialized(generator);\n\n\tzend_generator_resume(generator);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":370746,"func":"static void tripmate_event_hook(struct gps_device_t *session, event_t event)\n{\n    if (session->context->readonly)\n\treturn;\n    \/* TripMate requires this response to the ASTRAL it sends at boot time *\/\n    if (event == event_identified)\n\t(void)nmea_send(session, \"$IIGPQ,ASTRAL\");\n    \/* stop it sending PRWIZCH *\/\n    if (event == event_identified || event == event_reactivate)\n\t(void)nmea_send(session, \"$PRWIILOG,ZCH,V,,\");\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":440044,"func":"MagickExport void XDestroyResourceInfo(XResourceInfo *resource_info)\n{\n  if (resource_info->image_geometry != (char *) NULL)\n    resource_info->image_geometry=(char *)\n      RelinquishMagickMemory(resource_info->image_geometry);\n  if (resource_info->quantize_info != (QuantizeInfo *) NULL)\n    resource_info->quantize_info=DestroyQuantizeInfo(\n      resource_info->quantize_info);\n  if (resource_info->client_name != (char *) NULL)\n    resource_info->client_name=(char *)\n      RelinquishMagickMemory(resource_info->client_name);\n  if (resource_info->name != (char *) NULL)\n    resource_info->name=DestroyString(resource_info->name);\n  (void) memset(resource_info,0,sizeof(*resource_info));\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":130117,"func":"  void accept(std::shared_ptr<ServerTransportParametersExtension>) override {}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":414231,"func":"GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)\n{\n    error_setg(errp, QERR_UNSUPPORTED);\n\n    return 0;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":25379,"func":"static int ilbc_encode_frame ( AVCodecContext * avctx , AVPacket * avpkt , const AVFrame * frame , int * got_packet_ptr ) {\n ILBCEncContext * s = avctx -> priv_data ;\n int ret ;\n if ( ( ret = ff_alloc_packet ( avpkt , 50 ) ) ) {\n av_log ( avctx , AV_LOG_ERROR , \"Error getting output packet\\n\" ) ;\n return ret ;\n }\n WebRtcIlbcfix_EncodeImpl ( ( WebRtc_UWord16 * ) avpkt -> data , ( const WebRtc_Word16 * ) frame -> data [ 0 ] , & s -> encoder ) ;\n avpkt -> size = s -> encoder . no_of_bytes ;\n * got_packet_ptr = 1 ;\n return 0 ;\n }","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":465723,"func":"static void fuse_prepare_release(struct fuse_inode *fi, struct fuse_file *ff,\n\t\t\t\t int flags, int opcode)\n{\n\tstruct fuse_conn *fc = ff->fm->fc;\n\tstruct fuse_release_args *ra = ff->release_args;\n\n\t\/* Inode is NULL on error path of fuse_create_open() *\/\n\tif (likely(fi)) {\n\t\tspin_lock(&fi->lock);\n\t\tlist_del(&ff->write_entry);\n\t\tspin_unlock(&fi->lock);\n\t}\n\tspin_lock(&fc->lock);\n\tif (!RB_EMPTY_NODE(&ff->polled_node))\n\t\trb_erase(&ff->polled_node, &fc->polled_files);\n\tspin_unlock(&fc->lock);\n\n\twake_up_interruptible_all(&ff->poll_wait);\n\n\tra->inarg.fh = ff->fh;\n\tra->inarg.flags = flags;\n\tra->args.in_numargs = 1;\n\tra->args.in_args[0].size = sizeof(struct fuse_release_in);\n\tra->args.in_args[0].value = &ra->inarg;\n\tra->args.opcode = opcode;\n\tra->args.nodeid = ff->nodeid;\n\tra->args.force = true;\n\tra->args.nocreds = true;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":55881,"func":"bool __fastcall TCommandSet::GetOneLineCommand(TFSCommand \/*Cmd*\/)\r\n{\r\n  \/\/CHECK_CMD;\r\n  \/\/ #56: we send \"echo last line\" from all commands on same line\r\n  \/\/ just as it was in 1.0\r\n  return True; \/\/CommandSet[Cmd].OneLineCommand;\r\n}\r","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":338012,"func":"static void gen_dccci(DisasContext *ctx)\n\n{\n\n#if defined(CONFIG_USER_ONLY)\n\n    gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n#else\n\n    if (unlikely(ctx->pr)) {\n\n        gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);\n\n        return;\n\n    }\n\n    \/* interpreted as no-op *\/\n\n#endif\n\n}\n","target":1,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":41674,"func":"NO_INLINE JsVar *__jspePostfixExpression(JsVar *a) {\n  while (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) {\n    int op = lex->tk;\n    JSP_ASSERT_MATCH(op);\n    if (JSP_SHOULD_EXECUTE) {\n      JsVar *one = jsvNewFromInteger(1);\n      JsVar *oldValue = jsvAsNumberAndUnLock(jsvSkipName(a)); \/\/ keep the old value (but convert to number)\n      JsVar *res = jsvMathsOpSkipNames(oldValue, one, op==LEX_PLUSPLUS ? '+' : '-');\n      jsvUnLock(one);\n\n      \/\/ in-place add\/subtract\n      jsvReplaceWith(a, res);\n      jsvUnLock(res);\n      \/\/ but then use the old value\n      jsvUnLock(a);\n      a = oldValue;\n    }\n  }\n  return a;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":259766,"func":"md_process_table_cell(MD_CTX* ctx, MD_BLOCKTYPE cell_type, MD_ALIGN align, OFF beg, OFF end)\n{\n    MD_LINE line;\n    MD_BLOCK_TD_DETAIL det;\n    int ret = 0;\n\n    while(beg < end  &&  ISWHITESPACE(beg))\n        beg++;\n    while(end > beg  &&  ISWHITESPACE(end-1))\n        end--;\n\n    det.align = align;\n    line.beg = beg;\n    line.end = end;\n\n    MD_ENTER_BLOCK(cell_type, &det);\n    MD_CHECK(md_process_normal_block_contents(ctx, &line, 1));\n    MD_LEAVE_BLOCK(cell_type, &det);\n\nabort:\n    return ret;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":420641,"func":"modify_param_name(param_token *name)\n{\n  const char *delim1 = memchr (name->b, '*', name->e - name->b);\n  const char *delim2 = memrchr (name->b, '*', name->e - name->b);\n\n  int result;\n\n  if(delim1 == NULL)\n    {\n      result = NOT_RFC2231;\n    }\n  else if(delim1 == delim2)\n    {\n      if ((name->e - 1) == delim1)\n        {\n          result = RFC2231_ENCODING;\n        }\n      else\n        {\n          result = RFC2231_NOENCODING;\n        }\n      name->e = delim1;\n    }\n  else\n    {\n      name->e = delim1;\n      result = RFC2231_ENCODING;\n    }\n  return result;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":69361,"func":"static int do_stop_slave_sql(MYSQL *mysql_con)\n{\n  MYSQL_RES *slave;\n  \/* We need to check if the slave sql is running in the first place *\/\n  if (mysql_query_with_error_report(mysql_con, &slave, \"SHOW SLAVE STATUS\"))\n    return(1);\n  else\n  {\n    MYSQL_ROW row= mysql_fetch_row(slave);\n    if (row && row[11])\n    {\n      \/* if SLAVE SQL is not running, we don't stop it *\/\n      if (!strcmp(row[11],\"No\"))\n      {\n        mysql_free_result(slave);\n        \/* Silently assume that they don't have the slave running *\/\n        return(0);\n      }\n    }\n  }\n  mysql_free_result(slave);\n\n  \/* now, stop slave if running *\/\n  if (mysql_query_with_error_report(mysql_con, 0, \"STOP SLAVE SQL_THREAD\"))\n    return(1);\n\n  return(0);\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":354082,"func":"main(int argc GCC_UNUSED,\n     char *argv[]GCC_UNUSED)\n{\n    fprintf(stderr, \"This program requires terminfo\\n\");\n    exit(EXIT_FAILURE);\n}","target":1,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":76125,"func":"static ssize_t pstr_store(struct device *kdev,\n\t\t\t  struct device_attribute *kattr, const char *buf,\n\t\t\t  size_t count)\n{\n\tstruct hid_device *hdev = to_hid_device(kdev);\n\tstruct cp2112_pstring_attribute *attr =\n\t\tcontainer_of(kattr, struct cp2112_pstring_attribute, attr);\n\tstruct cp2112_string_report report;\n\tint ret;\n\n\tmemset(&report, 0, sizeof(report));\n\n\tret = utf8s_to_utf16s(buf, count, UTF16_LITTLE_ENDIAN,\n\t\t\t      report.string, ARRAY_SIZE(report.string));\n\treport.report = attr->report;\n\treport.length = ret * sizeof(report.string[0]) + 2;\n\treport.type = USB_DT_STRING;\n\n\tret = cp2112_hid_output(hdev, &report.report, report.length + 1,\n\t\t\t\tHID_FEATURE_REPORT);\n\tif (ret != report.length + 1) {\n\t\thid_err(hdev, \"error writing %s string: %d\\n\", kattr->attr.name,\n\t\t\tret);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\treturn -EIO;\n\t}\n\n\tchmod_sysfs_attrs(hdev);\n\treturn count;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":293488,"func":"hotremove_migrate_alloc(struct page *page, unsigned long private, int **x)\n{\n\t\/* This should be improooooved!! *\/\n\treturn alloc_page(GFP_HIGHUSER_MOVABLE);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":288372,"func":"v8::Handle<v8::Value> V8WebGLRenderingContext::getExtensionCallback(const v8::Arguments& args)\n{\n     INC_STATS(\"DOM.WebGLRenderingContext.getExtensionCallback()\");\n     WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder());\n     if (args.Length() < 1)\n        return V8Proxy::throwNotEnoughArgumentsError();\n     STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, name, args[0]);\n     WebGLExtension* extension = imp->getExtension(name);\n     return toV8Object(extension, args.Holder(), args.GetIsolate());\n}\n","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":179673,"func":"void Browser::Zoom(PageZoom::Function zoom_function) {\n  static const UserMetricsAction kActions[] = {\n                      UserMetricsAction(\"ZoomMinus\"),\n                      UserMetricsAction(\"ZoomNormal\"),\n                      UserMetricsAction(\"ZoomPlus\")\n                      };\n\n  UserMetrics::RecordAction(kActions[zoom_function - PageZoom::ZOOM_OUT],\n                            profile_);\n  TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper();\n  tab_contents->render_view_host()->Zoom(zoom_function);\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":211976,"func":"ALuint S_AL_Format(int width, int channels)\n{\n\tALuint format = AL_FORMAT_MONO16;\n\n\tif(width == 1)\n\t{\n\t\tif(channels == 1)\n\t\t\tformat = AL_FORMAT_MONO8;\n\t\telse if(channels == 2)\n\t\t\tformat = AL_FORMAT_STEREO8;\n\t}\n\telse if(width == 2)\n\t{\n\t\tif(channels == 1)\n\t\t\tformat = AL_FORMAT_MONO16;\n\t\telse if(channels == 2)\n\t\t\tformat = AL_FORMAT_STEREO16;\n\t}\n\n\treturn format;\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":23340,"func":"static int dissect_h245_H2250MaximumSkewIndication ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h245_H2250MaximumSkewIndication , H2250MaximumSkewIndication_sequence ) ;\n return offset ;\n }","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":147657,"func":"sort_page_names (gconstpointer a,\n                 gconstpointer b)\n{\n  gchar *temp1, *temp2;\n  gint ret;\n\n  temp1 = g_utf8_collate_key_for_filename (* (const char **) a, -1);\n  temp2 = g_utf8_collate_key_for_filename (* (const char **) b, -1);\n\n  ret = strcmp (temp1, temp2);\n\n  g_free (temp1);\n  g_free (temp2);\n\n  return ret;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":405485,"func":"static void setup_per_zone_lowmem_reserve(void)\n{\n\tstruct pglist_data *pgdat;\n\tenum zone_type j, idx;\n\n\tfor_each_online_pgdat(pgdat) {\n\t\tfor (j = 0; j < MAX_NR_ZONES; j++) {\n\t\t\tstruct zone *zone = pgdat->node_zones + j;\n\t\t\tunsigned long managed_pages = zone->managed_pages;\n\n\t\t\tzone->lowmem_reserve[j] = 0;\n\n\t\t\tidx = j;\n\t\t\twhile (idx) {\n\t\t\t\tstruct zone *lower_zone;\n\n\t\t\t\tidx--;\n\n\t\t\t\tif (sysctl_lowmem_reserve_ratio[idx] < 1)\n\t\t\t\t\tsysctl_lowmem_reserve_ratio[idx] = 1;\n\n\t\t\t\tlower_zone = pgdat->node_zones + idx;\n\t\t\t\tlower_zone->lowmem_reserve[j] = managed_pages \/\n\t\t\t\t\tsysctl_lowmem_reserve_ratio[idx];\n\t\t\t\tmanaged_pages += lower_zone->managed_pages;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* update totalreserve_pages *\/\n\tcalculate_totalreserve_pages();\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":500104,"func":"static void test05(char const* infile,\n\t\t   char const* password,\n\t\t   char const* outfile,\n\t\t   char const* outfile2)\n{\n    qpdf_read(qpdf, infile, password);\n    qpdf_init_write(qpdf, outfile);\n    qpdf_set_static_ID(qpdf, QPDF_TRUE);\n    qpdf_set_linearization(qpdf, QPDF_TRUE);\n    qpdf_write(qpdf);\n    report_errors();\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":232808,"func":"void TreeView::StartEditing(TreeModelNode* node) {\n  DCHECK(node && tree_view_);\n  CancelEdit();\n  if (model_->GetParent(node))\n    Expand(model_->GetParent(node));\n  const NodeDetails* details = GetNodeDetails(node);\n  SetFocus(tree_view_);\n  SetSelectedNode(node);\n  TreeView_EditLabel(tree_view_, details->tree_item);\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":365919,"func":"static inline struct sigqueue *get_task_cache(struct task_struct *t)\n{\n\treturn NULL;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":360992,"func":"gs_window_real_unrealize (GtkWidget *widget)\n{\n        g_signal_handlers_disconnect_by_func (gtk_window_get_screen (GTK_WINDOW (widget)),\n                                              screen_size_changed,\n                                              widget);\n\n        if (GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize) {\n                GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize (widget);\n        }\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":494149,"func":"rapidjson::CrtAllocator &GetAllocator() { return s_CrtAllocator; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":96546,"func":"TEST_P(SslSocketTest, GetNoUriWithDnsSan) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n)EOF\";\n\n  \/\/ The SAN field only has DNS, expect \"\" for uriSanPeerCertificate().\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedSerialNumber(TEST_SAN_DNS_CERT_SERIAL));\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":33139,"func":"size_t coolkey_list_meter(const void *el) {\n\treturn sizeof(sc_cardctl_coolkey_object_t);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":499251,"func":"static av_cold void flush(AVCodecContext *avctx)\n{\n    ALSDecContext *ctx = avctx->priv_data;\n\n    ctx->frame_id = 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":126215,"func":"void CoreUserInputHandler::handleVoice(const BufferInfo &bufferInfo, const QString &msg)\n{\n    QStringList nicks = msg.split(' ', QString::SkipEmptyParts);\n    QString m = \"+\"; for (int i = 0; i < nicks.count(); i++) m += 'v';\n    QStringList params;\n    params << bufferInfo.bufferName() << m << nicks;\n    emit putCmd(\"MODE\", serverEncode(params));\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":499376,"func":"static void reset_session(sasl_session_t *p)\n{\n\tif (p->mechptr && p->mechptr->mech_finish)\n\t\tp->mechptr->mech_finish(p);\n\n\tp->mechptr = NULL;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":158175,"func":"void CLASS ciff_block_1030()\n{\n  static const ushort key[] = { 0x410, 0x45f3 };\n  int i, bpp, row, col, vbits=0;\n  unsigned long bitbuf=0;\n\n  if ((get2(),get4()) != 0x80008 || !get4()) return;\n  bpp = get2();\n  if (bpp != 10 && bpp != 12) return;\n  for (i=row=0; row < 8; row++)\n    for (col=0; col < 8; col++) {\n      if (vbits < bpp) {\n\tbitbuf = bitbuf << 16 | (get2() ^ key[i++ & 1]);\n\tvbits += 16;\n      }\n      white[row][col] =\n\tbitbuf << (LONG_BIT - vbits) >> (LONG_BIT - bpp);\n      vbits -= bpp;\n    }\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":196347,"func":"GahpClient::check_pending_timeout(const char *,const char *)\n{\n\n\tif ( pending_reqid == 0 ) {\n\t\treturn false;\n\t}\n\n\tif ( pending_submitted_to_gahp == false ) {\n\t\treturn false;\n\t}\n\n\tif ( pending_timeout && (time(NULL) > pending_timeout) ) {\n\t\tclear_pending();\t\/\/ we no longer want to hear about it...\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":286328,"func":"void CastDetailedView::AppendSettingsEntries() {\n  const bool userAddingRunning = Shell::GetInstance()\n                                     ->session_state_delegate()\n                                     ->IsInSecondaryLoginScreen();\n\n  if (login_ == user::LOGGED_IN_NONE || login_ == user::LOGGED_IN_LOCKED ||\n      userAddingRunning)\n    return;\n\n  ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();\n  HoverHighlightView* container = new HoverHighlightView(this);\n  container->AddLabel(rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAST_OPTIONS),\n                      gfx::ALIGN_LEFT, false \/* highlight *\/);\n\n  AddChildView(container);\n  options_ = container;\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":65189,"func":"BlockDriverState *bdrv_all_find_vmstate_bs(void)\n\n{\n\n    bool not_found = true;\n\n    BlockDriverState *bs;\n\n    BdrvNextIterator *it = NULL;\n\n\n\n    while (not_found && (it = bdrv_next(it, &bs))) {\n\n        AioContext *ctx = bdrv_get_aio_context(bs);\n\n\n\n        aio_context_acquire(ctx);\n\n        not_found = !bdrv_can_snapshot(bs);\n\n        aio_context_release(ctx);\n\n    }\n\n    return bs;\n\n}\n","target":1,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":255903,"func":"    OVS_REQUIRES(ofproto_mutex)\n{\n     const struct rule_actions *actions = rule_get_actions(rule);\n \n     \/* A rule may not be reinserted. *\/\n    ovs_assert(rule->state == RULE_INITIALIZED);\n \n     if (rule->hard_timeout || rule->idle_timeout) {\n         ovs_list_insert(&ofproto->expirable, &rule->expirable);\n    }\n    cookies_insert(ofproto, rule);\n    eviction_group_add_rule(rule);\n    if (actions->has_meter) {\n        meter_insert_rule(rule);\n    }\n    if (actions->has_groups) {\n        const struct ofpact_group *a;\n        OFPACT_FOR_EACH_TYPE_FLATTENED (a, GROUP, actions->ofpacts,\n                                        actions->ofpacts_len) {\n            struct ofgroup *group;\n\n            group = ofproto_group_lookup(ofproto, a->group_id, OVS_VERSION_MAX,\n                                         false);\n            ovs_assert(group != NULL);\n            group_add_rule(group, rule);\n        }\n    }\n\n    rule->state = RULE_INSERTED;\n}\n","target":1,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":518498,"func":"bool compare_partition_options(HA_CREATE_INFO *table_create_info,\n                               partition_element *part_elem)\n{\n#define MAX_COMPARE_PARTITION_OPTION_ERRORS 5\n  const char *option_diffs[MAX_COMPARE_PARTITION_OPTION_ERRORS + 1];\n  int i, errors= 0;\n  DBUG_ENTER(\"compare_partition_options\");\n\n  \/*\n    Note that there are not yet any engine supporting tablespace together\n    with partitioning. TODO: when there are, add compare.\n  *\/\n  if (part_elem->tablespace_name || table_create_info->tablespace)\n    option_diffs[errors++]= \"TABLESPACE\";\n  if (part_elem->part_max_rows != table_create_info->max_rows)\n    option_diffs[errors++]= \"MAX_ROWS\";\n  if (part_elem->part_min_rows != table_create_info->min_rows)\n    option_diffs[errors++]= \"MIN_ROWS\";\n\n  for (i= 0; i < errors; i++)\n    my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),\n             option_diffs[i]);\n  DBUG_RETURN(errors != 0);\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":183138,"func":"OMX_U32 omx_venc::dev_start_done(void)\n{\n return handle->venc_start_done();\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":198503,"func":"int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)\n{\n    xGLXGetDrawableAttributesSGIXReq *req =\n\t(xGLXGetDrawableAttributesSGIXReq *)pc;\n    \n    return DoGetDrawableAttributes(cl, req->drawable);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":313537,"func":"size_t mptsas_config_ioc_2(MPTSASState *s, uint8_t **data, int address)\n{\n    return MPTSAS_CONFIG_PACK(2, MPI_CONFIG_PAGETYPE_IOC, 0x04,\n                              \"*l*b*b*b*b\");\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":155596,"func":"decoding_fgets(char *s, int size, struct tok_state *tok)\n{\n    return fgets(s, size, tok->fp);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":446181,"func":"void virDomainVideoDefFree(virDomainVideoDefPtr def)\n{\n    if (!def)\n        return;\n\n    virDomainVideoDefClear(def);\n    VIR_FREE(def);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":53303,"func":"static int tcm_loop_driver_probe(struct device *dev)\n{\n\tstruct tcm_loop_hba *tl_hba;\n\tstruct Scsi_Host *sh;\n\tint error;\n\n\ttl_hba = to_tcm_loop_hba(dev);\n\n\tsh = scsi_host_alloc(&tcm_loop_driver_template,\n\t\t\tsizeof(struct tcm_loop_hba));\n\tif (!sh) {\n\t\tprintk(KERN_ERR \"Unable to allocate struct scsi_host\\n\");\n\t\treturn -ENODEV;\n\t}\n\ttl_hba->sh = sh;\n\n\t\/*\n\t * Assign the struct tcm_loop_hba pointer to struct Scsi_Host->hostdata\n\t *\/\n\t*((struct tcm_loop_hba **)sh->hostdata) = tl_hba;\n\t\/*\n\t * Setup single ID, Channel and LUN for now..\n\t *\/\n\tsh->max_id = 2;\n\tsh->max_lun = 0;\n\tsh->max_channel = 0;\n\tsh->max_cmd_len = TL_SCSI_MAX_CMD_LEN;\n\n\terror = scsi_add_host(sh, &tl_hba->dev);\n\tif (error) {\n\t\tprintk(KERN_ERR \"%s: scsi_add_host failed\\n\", __func__);\n\t\tscsi_host_put(sh);\n\t\treturn -ENODEV;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":454893,"func":"TEST_F(ExprMatchTest, NullMatchesCorrectly) {\n    createMatcher(fromjson(\"{$expr: {$eq: ['$x', null]}}\"));\n\n    ASSERT_TRUE(matches(BSON(\"x\" << BSONNULL)));\n\n    ASSERT_FALSE(matches(BSON(\"x\" << BSONUndefined)));\n    ASSERT_FALSE(matches(BSONObj()));\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":403685,"func":"void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)\n{\n\twhile ((dst = dst->child) && dst->xfrm && dst->dev == dev) {\n\t\tdst->dev = dev_net(dev)->loopback_dev;\n\t\tdev_hold(dst->dev);\n\t\tdev_put(dev);\n\t}\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":338011,"func":"static av_cold int pcx_end(AVCodecContext *avctx) {\n\n    PCXContext *s = avctx->priv_data;\n\n\n\n    if(s->picture.data[0])\n\n        avctx->release_buffer(avctx, &s->picture);\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":347543,"func":"zzip_mem_disk_open(char* filename)\n{\n    ZZIP_DISK* disk = zzip_disk_open(filename);\n    if (! disk) { perror(error[_zzip_mem_disk_open_fail]); return 0; }\n    ___ ZZIP_MEM_DISK* dir = calloc(1, sizeof(*dir)); \n    zzip_mem_disk_load(dir, disk);\n    return dir; ____;\n}","target":1,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":74732,"func":"megasas_make_sgl_skinny(struct megasas_instance *instance,\n\t\tstruct scsi_cmnd *scp, union megasas_sgl *mfi_sgl)\n{\n\tint i;\n\tint sge_count;\n\tstruct scatterlist *os_sgl;\n\n\tsge_count = scsi_dma_map(scp);\n\n\tif (sge_count) {\n\t\tscsi_for_each_sg(scp, os_sgl, sge_count, i) {\n\t\t\tmfi_sgl->sge_skinny[i].length =\n\t\t\t\tcpu_to_le32(sg_dma_len(os_sgl));\n\t\t\tmfi_sgl->sge_skinny[i].phys_addr =\n\t\t\t\tcpu_to_le64(sg_dma_address(os_sgl));\n\t\t\tmfi_sgl->sge_skinny[i].flag = cpu_to_le32(0);\n\t\t}\n\t}\n\treturn sge_count;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":266824,"func":"u32 _cdk_pkt_get_keyid(cdk_packet_t pkt, u32 * keyid)\n{\n\tu32 lowbits;\n\n\tif (!pkt)\n\t\treturn 0;\n\n\tswitch (pkt->pkttype) {\n\tcase CDK_PKT_PUBLIC_KEY:\n\tcase CDK_PKT_PUBLIC_SUBKEY:\n\t\tlowbits = cdk_pk_get_keyid(pkt->pkt.public_key, keyid);\n\t\tbreak;\n\n\tcase CDK_PKT_SECRET_KEY:\n\tcase CDK_PKT_SECRET_SUBKEY:\n\t\tlowbits = cdk_sk_get_keyid(pkt->pkt.secret_key, keyid);\n\t\tbreak;\n\n\tcase CDK_PKT_SIGNATURE:\n\t\tlowbits = cdk_sig_get_keyid(pkt->pkt.signature, keyid);\n\t\tbreak;\n\n\tdefault:\n\t\tlowbits = 0;\n\t\tbreak;\n\t}\n\n\treturn lowbits;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":488535,"func":"static void virtio_net_vnet_endian_status(VirtIONet *n, uint8_t status)\n{\n    VirtIODevice *vdev = VIRTIO_DEVICE(n);\n    int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;\n\n    if (virtio_net_started(n, status)) {\n        \/* Before using the device, we tell the network backend about the\n         * endianness to use when parsing vnet headers. If the backend\n         * can't do it, we fallback onto fixing the headers in the core\n         * virtio-net code.\n         *\/\n        n->needs_vnet_hdr_swap = virtio_net_set_vnet_endian(vdev, n->nic->ncs,\n                                                            queue_pairs, true);\n    } else if (virtio_net_started(n, vdev->status)) {\n        \/* After using the device, we need to reset the network backend to\n         * the default (guest native endianness), otherwise the guest may\n         * lose network connectivity if it is rebooted into a different\n         * endianness.\n         *\/\n        virtio_net_set_vnet_endian(vdev, n->nic->ncs, queue_pairs, false);\n    }\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":80572,"func":"static int orinoco_ioctl_setrate(struct net_device *dev,\n\t\t\t\t struct iw_request_info *info,\n\t\t\t\t struct iw_param *rrq,\n\t\t\t\t char *extra)\n{\n\tstruct orinoco_private *priv = ndev_priv(dev);\n\tint ratemode;\n\tint bitrate; \/* 100s of kilobits *\/\n\tunsigned long flags;\n\n\t\/* As the user space doesn't know our highest rate, it uses -1\n\t * to ask us to set the highest rate.  Test it using \"iwconfig\n\t * ethX rate auto\" - Jean II *\/\n\tif (rrq->value == -1)\n\t\tbitrate = 110;\n\telse {\n\t\tif (rrq->value % 100000)\n\t\t\treturn -EINVAL;\n\t\tbitrate = rrq->value \/ 100000;\n\t}\n\n\tratemode = orinoco_get_bitratemode(bitrate, !rrq->fixed);\n\n\tif (ratemode == -1)\n\t\treturn -EINVAL;\n\n\tif (orinoco_lock(priv, &flags) != 0)\n\t\treturn -EBUSY;\n\tpriv->bitratemode = ratemode;\n\torinoco_unlock(priv, &flags);\n\n\treturn -EINPROGRESS;\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":263255,"func":"bool CommandData::CheckWinSize()\n{\n  \/\/ Define 0x100000000 as macro to avoid troubles with older compilers.\n  const uint64 MaxDictSize=INT32TO64(1,0);\n  \/\/ Limit the dictionary size to 4 GB.\n  for (uint64 I=0x10000;I<=MaxDictSize;I*=2)\n    if (WinSize==I)\n      return true;\n  WinSize=0x400000;\n  return false;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":145295,"func":"ves_icall_System_Threading_Thread_VolatileWrite2 (void *ptr, gint16 value)\n{\n\t*((volatile gint16 *) ptr) = value;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":32799,"func":"xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {\n    int ret;\n    xmlDtdPtr oldExt, oldInt;\n    xmlNodePtr root;\n\n    if (dtd == NULL) return(0);\n    if (doc == NULL) return(0);\n    oldExt = doc->extSubset;\n    oldInt = doc->intSubset;\n    doc->extSubset = dtd;\n    doc->intSubset = NULL;\n    ret = xmlValidateRoot(ctxt, doc);\n    if (ret == 0) {\n\tdoc->extSubset = oldExt;\n\tdoc->intSubset = oldInt;\n\treturn(ret);\n    }\n    if (doc->ids != NULL) {\n          xmlFreeIDTable(doc->ids);\n          doc->ids = NULL;\n    }\n    if (doc->refs != NULL) {\n          xmlFreeRefTable(doc->refs);\n          doc->refs = NULL;\n    }\n    root = xmlDocGetRootElement(doc);\n    ret = xmlValidateElement(ctxt, doc, root);\n    ret &= xmlValidateDocumentFinal(ctxt, doc);\n    doc->extSubset = oldExt;\n    doc->intSubset = oldInt;\n    return(ret);\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":145240,"func":"tok2strbuf(register const struct tok *lp, register const char *fmt,\n\t   register u_int v, char *buf, size_t bufsize)\n{\n\tif (lp != NULL) {\n\t\twhile (lp->s != NULL) {\n\t\t\tif (lp->v == v)\n\t\t\t\treturn (lp->s);\n\t\t\t++lp;\n\t\t}\n\t}\n\tif (fmt == NULL)\n\t\tfmt = \"#%d\";\n\n\t(void)snprintf(buf, bufsize, fmt, v);\n\treturn (const char *)buf;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":29992,"func":"static hb_bool_t hb_shape_plan_matches ( const hb_shape_plan_t * shape_plan , const hb_shape_plan_proposal_t * proposal ) {\n return hb_segment_properties_equal ( & shape_plan -> props , & proposal -> props ) && hb_shape_plan_user_features_match ( shape_plan , proposal ) && ( ( shape_plan -> default_shaper_list && proposal -> shaper_list == NULL ) || ( shape_plan -> shaper_func == proposal -> shaper_func ) ) ;\n }","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":226406,"func":"pp::Rect PDFiumEngine::GetVisibleRect() const {\n  pp::Rect rv;\n  rv.set_x(static_cast<int>(position_.x() \/ current_zoom_));\n  rv.set_y(static_cast<int>(position_.y() \/ current_zoom_));\n  rv.set_width(static_cast<int>(ceil(plugin_size_.width() \/ current_zoom_)));\n  rv.set_height(static_cast<int>(ceil(plugin_size_.height() \/ current_zoom_)));\n  return rv;\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":451805,"func":"static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev)\n{\n\tstruct {\n\t\t__le64 stripe_unit;\n\t\t__le64 stripe_count;\n\t} __attribute__ ((packed)) striping_info_buf = { 0 };\n\tsize_t size = sizeof (striping_info_buf);\n\tvoid *p;\n\tint ret;\n\n\tret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid,\n\t\t\t\t&rbd_dev->header_oloc, \"get_stripe_unit_count\",\n\t\t\t\tNULL, 0, &striping_info_buf, size);\n\tdout(\"%s: rbd_obj_method_sync returned %d\\n\", __func__, ret);\n\tif (ret < 0)\n\t\treturn ret;\n\tif (ret < size)\n\t\treturn -ERANGE;\n\n\tp = &striping_info_buf;\n\trbd_dev->header.stripe_unit = ceph_decode_64(&p);\n\trbd_dev->header.stripe_count = ceph_decode_64(&p);\n\treturn 0;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":75780,"func":"static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)\n{\n    PadContext *s = inlink->dst->priv;\n\n    AVFrame *frame = ff_get_video_buffer(inlink->dst->outputs[0],\n                                         w + (s->w - s->in_w),\n                                         h + (s->h - s->in_h));\n    int plane;\n\n    if (!frame)\n        return NULL;\n\n    frame->width  = w;\n    frame->height = h;\n\n    for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) {\n        int hsub = s->draw.hsub[plane];\n        int vsub = s->draw.vsub[plane];\n        frame->data[plane] += (s->x >> hsub) * s->draw.pixelstep[plane] +\n                              (s->y >> vsub) * frame->linesize[plane];\n    }\n\n    return frame;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":310795,"func":"static void raisesExceptionLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n    TestObjectPythonV8Internal::raisesExceptionLongAttributeAttributeGetter(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":263375,"func":"R_API RList *r_bin_get_sections(RBin *bin) {\n\tRBinObject *o = r_bin_cur_object (bin);\n\treturn o? o->sections: NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":320017,"func":"uint32_t lduw_phys(target_phys_addr_t addr)\n\n{\n\n    return lduw_phys_internal(addr, DEVICE_NATIVE_ENDIAN);\n\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":442418,"func":"LineBuffer::~LineBuffer ()\n{\n    delete compressor;\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":38032,"func":"static int cipso_v4_map_lvl_ntoh(const struct cipso_v4_doi *doi_def,\n\t\t\t\t u32 net_lvl,\n\t\t\t\t u32 *host_lvl)\n{\n\tstruct cipso_v4_std_map_tbl *map_tbl;\n\n\tswitch (doi_def->type) {\n\tcase CIPSO_V4_MAP_PASS:\n\t\t*host_lvl = net_lvl;\n\t\treturn 0;\n\tcase CIPSO_V4_MAP_TRANS:\n\t\tmap_tbl = doi_def->map.std;\n\t\tif (net_lvl < map_tbl->lvl.cipso_size &&\n\t\t    map_tbl->lvl.cipso[net_lvl] < CIPSO_V4_INV_LVL) {\n\t\t\t*host_lvl = doi_def->map.std->lvl.cipso[net_lvl];\n\t\t\treturn 0;\n\t\t}\n\t\treturn -EPERM;\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":225885,"func":"  int activated_command_id() const { return activated_command_id_; }\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":410133,"func":"zzip_disk_fclose(ZZIP_DISK_FILE * file)\n{\n    if (file)\n    {\n        if (! file->stored)\n            inflateEnd(&file->zlib);\n        free(file);\n    }\n    return 0;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":343644,"func":"static void maybe_unmark_and_push(struct sock *x)\n{\n\tstruct unix_sock *u = unix_sk(x);\n\n\tif (u->gc_tree != GC_ORPHAN)\n\t\treturn;\n\tsock_hold(x);\n\tu->gc_tree = gc_current;\n\tgc_current = x;\n}","target":1,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":401889,"func":"ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_EQUAL, (op1_info == MAY_BE_LONG && op2_info == MAY_BE_LONG), ZEND_IS_EQUAL_LONG, CONST|TMPVARCV, CONST|TMPVARCV, SPEC(SMART_BRANCH,NO_CONST_CONST,COMMUTATIVE))\n{\n\tUSE_OPLINE\n\tzval *op1, *op2;\n\tint result;\n\n\top1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);\n\top2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);\n\tresult = (Z_LVAL_P(op1) == Z_LVAL_P(op2));\n\tZEND_VM_SMART_BRANCH(result, 0);\n\tZVAL_BOOL(EX_VAR(opline->result.var), result);\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":450643,"func":"static int nfs41_test_and_free_expired_stateid(struct nfs_server *server,\n\t\tnfs4_stateid *stateid,\n\t\tconst struct cred *cred)\n{\n\tint status;\n\n\tswitch (stateid->type) {\n\tdefault:\n\t\tbreak;\n\tcase NFS4_INVALID_STATEID_TYPE:\n\tcase NFS4_SPECIAL_STATEID_TYPE:\n\t\treturn -NFS4ERR_BAD_STATEID;\n\tcase NFS4_REVOKED_STATEID_TYPE:\n\t\tgoto out_free;\n\t}\n\n\tstatus = nfs41_test_stateid(server, stateid, cred);\n\tswitch (status) {\n\tcase -NFS4ERR_EXPIRED:\n\tcase -NFS4ERR_ADMIN_REVOKED:\n\tcase -NFS4ERR_DELEG_REVOKED:\n\t\tbreak;\n\tdefault:\n\t\treturn status;\n\t}\nout_free:\n\t\/* Ack the revoked state to the server *\/\n\tnfs41_free_stateid(server, stateid, cred, true);\n\treturn -NFS4ERR_EXPIRED;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":218208,"func":"void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) {\n  NOTREACHED();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":388838,"func":"static uint8_t *smbXcli_iov_concat(TALLOC_CTX *mem_ctx,\n\t\t\t\t   const struct iovec *iov,\n\t\t\t\t   int count)\n{\n\tssize_t buflen;\n\tuint8_t *buf;\n\n\tbuflen = iov_buflen(iov, count);\n\tif (buflen == -1) {\n\t\treturn NULL;\n\t}\n\n\tbuf = talloc_array(mem_ctx, uint8_t, buflen);\n\tif (buf == NULL) {\n\t\treturn NULL;\n\t}\n\n\tiov_buf(iov, count, buf, buflen);\n\n\treturn buf;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":194837,"func":"format_SET_VLAN_VID(const struct ofpact_vlan_vid *a, struct ds *s)\n{\n    ds_put_format(s, \"%s%s:%s%\"PRIu16, colors.param,\n                  a->push_vlan_if_needed ? \"mod_vlan_vid\" : \"set_vlan_vid\",\n                  colors.end, a->vlan_vid);\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":368178,"func":"release_ts_cell(TimestampCell *node)\n{\n  node->next = free_ts_list;\n  free_ts_list = node;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":434359,"func":"static void matches_ensure_morespace(int current)\n{\n  int base_space, extra_space, space;\n\n  if (current > Matches_listsize - 2)\n  {\n    base_space = MAX(NUMVARS,NUMCOMMANDS) + 1; \n    extra_space = Matches_listsize - base_space;\n    extra_space *= 2;\n    space = base_space + extra_space;\n    safe_realloc (&Matches, space * sizeof (char *));\n    memset (&Matches[current + 1], 0, space - current);\n    Matches_listsize = space;\n  }\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":52470,"func":"void __put_net(struct net *net)\n{\n\t\/* Cleanup the network namespace in process context *\/\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&cleanup_list_lock, flags);\n\tlist_add(&net->cleanup_list, &cleanup_list);\n\tspin_unlock_irqrestore(&cleanup_list_lock, flags);\n\n\tqueue_work(netns_wq, &net_cleanup_work);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":418244,"func":"std::string RGWPostObj_ObjStore::get_part_str(parts_collection_t& parts,\n                                              const std::string& name,\n                                              const std::string& def_val)\n{\n  std::string val;\n\n  if (part_str(parts, name, &val)) {\n    return val;\n  } else {\n    return rgw_trim_whitespace(def_val);\n  }\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":179195,"func":"void TaskManagerView::ExecuteCommand(int id) {\n  tab_table_->SetColumnVisibility(id, !tab_table_->IsColumnVisible(id));\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":205147,"func":"gfx::Size SoftwareFrameManager::GetCurrentFrameSizeInDIP() const {\n  DCHECK(HasCurrentFrame());\n  return ConvertSizeToDIP(current_frame_->frame_device_scale_factor_,\n                          current_frame_->frame_size_pixels_);\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":117446,"func":"check_enough_stack_size(int recurse_level)\n{\n  uchar stack_top;\n  if (recurse_level % 16 != 0)\n    return 0;\n\n  THD *my_thd= current_thd;\n  if (my_thd != NULL)\n    return check_stack_overrun(my_thd, STACK_MIN_SIZE * 2, &stack_top);\n  return 0;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":477494,"func":"__tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp)\n{\n\tu32 prio = 0;\n\n\tASSERT_RTNL();\n\tmutex_lock(&chain->filter_chain_lock);\n\n\tif (!tp) {\n\t\ttp = tcf_chain_dereference(chain->filter_chain, chain);\n\t} else if (tcf_proto_is_deleting(tp)) {\n\t\t\/* 'deleting' flag is set and chain->filter_chain_lock was\n\t\t * unlocked, which means next pointer could be invalid. Restart\n\t\t * search.\n\t\t *\/\n\t\tprio = tp->prio + 1;\n\t\ttp = tcf_chain_dereference(chain->filter_chain, chain);\n\n\t\tfor (; tp; tp = tcf_chain_dereference(tp->next, chain))\n\t\t\tif (!tp->deleting && tp->prio >= prio)\n\t\t\t\tbreak;\n\t} else {\n\t\ttp = tcf_chain_dereference(tp->next, chain);\n\t}\n\n\tif (tp)\n\t\ttcf_proto_get(tp);\n\n\tmutex_unlock(&chain->filter_chain_lock);\n\n\treturn tp;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":476219,"func":"Array<int>* InstanceKlass::create_new_default_vtable_indices(int len, TRAPS) {\n  Array<int>* vtable_indices = MetadataFactory::new_array<int>(class_loader_data(), len, CHECK_NULL);\n  assert(default_vtable_indices() == NULL, \"only create once\");\n  set_default_vtable_indices(vtable_indices);\n  return vtable_indices;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":166154,"func":"cmpstrp(const void *p1, const void *p2)\n{\n        return strcmp(*(char *const *)p1, *(char *const *)p2);\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":479759,"func":"    T& atXYZ(const int x, const int y, const int z, const int c=0) {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"atXYZ(): Empty instance.\",\n                                    cimg_instance);\n      return _atXYZ(x,y,z,c);\n    }","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":380610,"func":"int tm_finalize(void)\n  {\n  event_info *e;\n  int   i = 0;\n\n  if (!init_done)\n    return TM_BADINIT;\n\n  while (event_count && (i < EVENT_HASH))\n    {\n    while ((e = event_hash[i]) != NULL)\n      {\n      del_event(e);\n      }\n\n    ++i; \/* check next slot in hash table *\/\n    }\n\n  init_done = 0;\n\n  return TM_SUCCESS; \/* what else *\/\n  }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":430724,"func":"static int parse_audio_processing_unit(struct mixer_build *state, int unitid,\n\t\t\t\t       void *raw_desc)\n{\n\tswitch (state->mixer->protocol) {\n\tcase UAC_VERSION_1:\n\tcase UAC_VERSION_2:\n\tdefault:\n\t\treturn build_audio_procunit(state, unitid, raw_desc,\n\t\t\t\t\t    procunits, false);\n\tcase UAC_VERSION_3:\n\t\treturn build_audio_procunit(state, unitid, raw_desc,\n\t\t\t\t\t    uac3_procunits, false);\n\t}\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":109033,"func":"    **\/\n    CImgList<T>& assign(const char *const filename) {\n      return load(filename);","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":418435,"func":"  RGWOpType get_type() override { return RGW_OP_GET_BUCKET_VERSIONING; }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":249184,"func":"bool WebMediaPlayerImpl::SupportsOverlayFullscreenVideo() {\n#if defined(OS_ANDROID)\n  return !using_media_player_renderer_ &&\n         overlay_mode_ == OverlayMode::kUseContentVideoView;\n#else\n  return false;\n#endif\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":204337,"func":"IntRect ChromeClientImpl::RootWindowRect() {\n  WebRect rect;\n  if (web_view_->Client()) {\n    rect = web_view_->Client()->RootWindowRect();\n  } else {\n    rect.width = web_view_->Size().width;\n    rect.height = web_view_->Size().height;\n  }\n  return IntRect(rect);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":458327,"func":"dp_packet_hwol_is_tso(const struct dp_packet *b)\n{\n    return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_TCP_SEG);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":431420,"func":"    std::string help() const override {\n        return \"Grants roles to another role.\";\n    }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":86233,"func":"static char *revealextraspc(char * const s_)\n{\n    unsigned char *s = (unsigned char *) s_;\n    unsigned char *sn;\n    \n    if (s == NULL) {\n        return s_;\n    }\n    simplify(s_);\n    while (*s != 0U && isspace(*s)) {\n        *s++ = '_';\n    }\n    if (*s == 0U) {\n        return s_;\n    }\n    sn = s;\n    do {\n        sn++;\n    } while (*sn != 0U);\n    do {\n        sn--;        \n        if (!isspace(*sn)) {\n            break;\n        }\n        *sn = '_';\n    } while (sn != s);\n    \n    return s_;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":460030,"func":"proto_registrar_get_ftype(const int n)\n{\n\theader_field_info *hfinfo;\n\n\tPROTO_REGISTRAR_GET_NTH(n, hfinfo);\n\treturn hfinfo->type;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":445294,"func":"void ConnectionHandlerImpl::ActiveTcpListener::updateListenerConfig(\n    Network::ListenerConfig& config) {\n  ENVOY_LOG(trace, \"replacing listener \", config_->listenerTag(), \" by \", config.listenerTag());\n  config_ = &config;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":266350,"func":"void __init hugetlb_add_hstate(unsigned int order)\n{\n\tstruct hstate *h;\n\tunsigned long i;\n\n\tif (size_to_hstate(PAGE_SIZE << order)) {\n\t\tpr_warn(\"hugepagesz= specified twice, ignoring\\n\");\n\t\treturn;\n\t}\n\tBUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE);\n\tBUG_ON(order == 0);\n\th = &hstates[hugetlb_max_hstate++];\n\th->order = order;\n\th->mask = ~((1ULL << (order + PAGE_SHIFT)) - 1);\n\th->nr_huge_pages = 0;\n\th->free_huge_pages = 0;\n\tfor (i = 0; i < MAX_NUMNODES; ++i)\n\t\tINIT_LIST_HEAD(&h->hugepage_freelists[i]);\n\tINIT_LIST_HEAD(&h->hugepage_activelist);\n\th->next_nid_to_alloc = first_memory_node;\n\th->next_nid_to_free = first_memory_node;\n\tsnprintf(h->name, HSTATE_NAME_LEN, \"hugepages-%lukB\",\n\t\t\t\t\thuge_page_size(h)\/1024);\n\n\tparsed_hstate = h;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":62450,"func":"void mono_threads_install_notify_pending_exc (MonoThreadNotifyPendingExcFunc func)\n{\n\tmono_thread_notify_pending_exc_fn = func;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":39822,"func":"void __detach_mounts(struct dentry *dentry)\n{\n\tstruct mountpoint *mp;\n\tstruct mount *mnt;\n\n\tnamespace_lock();\n\tmp = lookup_mountpoint(dentry);\n\tif (!mp)\n\t\tgoto out_unlock;\n\n\tlock_mount_hash();\n\twhile (!hlist_empty(&mp->m_list)) {\n\t\tmnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);\n\t\tif (mnt->mnt.mnt_flags & MNT_UMOUNT) {\n\t\t\tstruct mount *p, *tmp;\n\t\t\tlist_for_each_entry_safe(p, tmp, &mnt->mnt_mounts,  mnt_child) {\n\t\t\t\thlist_add_head(&p->mnt_umount.s_list, &unmounted);\n\t\t\t\tumount_mnt(p);\n\t\t\t}\n\t\t}\n\t\telse umount_tree(mnt, 0);\n\t}\n\tunlock_mount_hash();\n\tput_mountpoint(mp);\nout_unlock:\n\tnamespace_unlock();\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":251163,"func":"void SyncTest::TearDown() {\n  InProcessBrowserTest::TearDown();\n\n  TearDownLocalPythonTestServer();\n\n  TearDownLocalTestServer();\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":173803,"func":"void V8TestObject::DeprecateAsSameValueMeasureAsSameValueOverloadedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_deprecateAsSameValueMeasureAsSameValueOverloadedMethod\");\n\n  test_object_v8_internal::DeprecateAsSameValueMeasureAsSameValueOverloadedMethodMethod(info);\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":388913,"func":"static uint8_t *msix_pending_byte(PCIDevice *dev, int vector)\n{\n    return dev->msix_pba + vector \/ 8;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":219973,"func":"void SplashOutputDev::clipToStrokePath(GfxState *state) {\n  SplashPath *path, *path2;\n\n  path = convertPath(state, state->getPath());\n  path2 = splash->makeStrokePath(path);\n  delete path;\n  splash->clipToPath(path2, gFalse);\n  delete path2;\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":415381,"func":"cupsdFindJob(int id)\t\t\t\/* I - Job ID *\/\n{\n  cupsd_job_t\tkey;\t\t\t\/* Search key *\/\n\n\n  key.id = id;\n\n  return ((cupsd_job_t *)cupsArrayFind(Jobs, &key));\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":212640,"func":"bool Document::hasFocus() const {\n  return GetPage() && GetPage()->GetFocusController().IsDocumentFocused(*this);\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":474703,"func":"struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp)\n{\n\tstruct sk_buff *skb;\n\tunsigned int total_size;\n\n\ttotal_size = size + 1;\n\tskb = alloc_skb(total_size, gfp);\n\n\tif (skb)\n\t\tskb_reserve(skb, 1);\n\n\treturn skb;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":355957,"func":"static inline int is_cow_mapping(unsigned int flags)\n{\n\treturn (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":155843,"func":"njs_lvlhsh_alloc(void *data, size_t size)\n{\n    return njs_mp_align(data, size, size);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":318442,"func":"static void test_validate_struct_nested(TestInputVisitorData *data,\n\n                                         const void *unused)\n\n{\n\n    UserDefTwo *udp = NULL;\n\n    Visitor *v;\n\n\n\n    v = validate_test_init(data, \"{ 'string0': 'string0', \"\n\n                           \"'dict1': { 'string1': 'string1', \"\n\n                           \"'dict2': { 'userdef': { 'integer': 42, \"\n\n                           \"'string': 'string' }, 'string': 'string2'}}}\");\n\n\n\n    visit_type_UserDefTwo(v, NULL, &udp, &error_abort);\n\n    qapi_free_UserDefTwo(udp);\n\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":302964,"func":"    **\/\n    const CImg<T>& save_cpp(const char *const filename) const {\n      return _save_cpp(0,filename);","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":359928,"func":"is_anyone_waiting_for_metafile (NautilusDirectory *directory)\n{\n\tif (directory->details->call_when_ready_counters[REQUEST_METAFILE] > 0) {\n\t\treturn TRUE;\n\t}\n\n\tif (directory->details->monitor_counters[REQUEST_METAFILE] > 0) {\n\t\treturn TRUE;\n\t}\n\n\treturn FALSE;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":124700,"func":"static int snd_usb_audio_dev_free(struct snd_device *device)\n{\n\tstruct snd_usb_audio *chip = device->device_data;\n\treturn snd_usb_audio_free(chip);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":174587,"func":"bool PulseAudioMixer::InitThread() {\nbool AudioMixerPulse::InitThread() {\n   AutoLock lock(mixer_state_lock_);\n \n   if (mixer_state_ != UNINITIALIZED)\n     return false;\n\n   if (thread_ == NULL) {\n    thread_.reset(new base::Thread(\"AudioMixerPulse\"));\n     if (!thread_->Start()) {\n       thread_.reset();\n       return false;\n    }\n  }\n  mixer_state_ = INITIALIZING;\n  return true;\n }\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":123515,"func":"\tbool resolve(const std::string& moduleName,\n\t\t\t\t const std::string& exportName,\n\t\t\t\t ObjectType type,\n\t\t\t\t Object*& outObject) override\n\t{\n\t\tauto namedInstance = moduleNameToInstanceMap.get(moduleName);\n\t\tif(namedInstance)\n\t\t{\n\t\t\toutObject = getInstanceExport(*namedInstance, exportName);\n\t\t\tif(outObject)\n\t\t\t{\n\t\t\t\tif(isA(outObject, type)) { return true; }\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tLog::printf(Log::error,\n\t\t\t\t\t\t\t\t\"Resolved import %s.%s to a %s, but was expecting %s\\n\",\n\t\t\t\t\t\t\t\tmoduleName.c_str(),\n\t\t\t\t\t\t\t\texportName.c_str(),\n\t\t\t\t\t\t\t\tasString(getObjectType(outObject)).c_str(),\n\t\t\t\t\t\t\t\tasString(type).c_str());\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tLog::printf(Log::error,\n\t\t\t\t\t\"Generated stub for missing import %s.%s : %s\\n\",\n\t\t\t\t\tmoduleName.c_str(),\n\t\t\t\t\texportName.c_str(),\n\t\t\t\t\tasString(type).c_str());\n\t\toutObject = getStubObject(exportName, type);\n\t\treturn true;\n\t}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":192964,"func":"void LocalFrame::ForceSynchronousDocumentInstall(\n    const AtomicString& mime_type,\n    scoped_refptr<SharedBuffer> data) {\n  CHECK(loader_.StateMachine()->IsDisplayingInitialEmptyDocument());\n  DCHECK(!Client()->IsLocalFrameClientImpl());\n\n  GetDocument()->Shutdown();\n\n  DomWindow()->InstallNewDocument(\n      mime_type, DocumentInit::Create().WithFrame(this), false);\n  loader_.StateMachine()->AdvanceTo(\n      FrameLoaderStateMachine::kCommittedFirstRealLoad);\n\n  GetDocument()->OpenForNavigation(kForceSynchronousParsing, mime_type,\n                                   AtomicString(\"UTF-8\"));\n  data->ForEachSegment(\n      [this](const char* segment, size_t segment_size, size_t segment_offset) {\n        GetDocument()->Parser()->AppendBytes(segment, segment_size);\n        return true;\n      });\n  GetDocument()->Parser()->Finish();\n\n  if (GetPage() && GetDocument()->IsSVGDocument())\n    GetPage()->GetUseCounter().DidCommitLoad(this);\n}\n","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":284258,"func":"SkColor TabStrip::GetTabForegroundColor(TabState tab_state,\n                                        SkColor background_color) const {\n  const ui::ThemeProvider* tp = GetThemeProvider();\n  if (!tp)\n    return SK_ColorBLACK;\n\n  const bool is_active_frame = ShouldPaintAsActiveFrame();\n\n  SkColor default_color;\n  if (tab_state == TAB_ACTIVE) {\n    default_color = tp->GetColor(ThemeProperties::COLOR_TAB_TEXT);\n  } else {\n    if (!is_active_frame &&\n        tp->HasCustomColor(\n            ThemeProperties::COLOR_BACKGROUND_TAB_TEXT_INACTIVE)) {\n      return tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB_TEXT_INACTIVE);\n    }\n\n    const int color_id = ThemeProperties::COLOR_BACKGROUND_TAB_TEXT;\n    default_color =\n        tp->HasCustomColor(color_id)\n            ? tp->GetColor(color_id)\n            : color_utils::PickContrastingColor(\n                  gfx::kGoogleGrey400, gfx::kGoogleGrey800, background_color);\n  }\n\n  if (!is_active_frame) {\n    default_color =\n        color_utils::AlphaBlend(default_color, background_color, 0.75f);\n  }\n\n  return color_utils::GetColorWithMinimumContrast(default_color,\n                                                  background_color);\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":33189,"func":"static\nvoid php_mysqlnd_sha256_pk_request_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)\n{\n\tif (!stack_allocation) {\n\t\tMYSQLND_PACKET_SHA256_PK_REQUEST * p = (MYSQLND_PACKET_SHA256_PK_REQUEST *) _packet;\n\t\tmnd_pefree(p, p->header.persistent);\n\t}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":340469,"func":"static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs)\n\n{\n\n    FsCred cred;\n\n    int flags;\n\n\n\n    cred_init(&cred);\n\n    cred.fc_uid = vs->fidp->uid;\n\n    cred.fc_mode = vs->perm & 0777;\n\n    flags = omode_to_uflags(vs->mode) | O_CREAT;\n\n\n\n    return s->ops->open2(&s->ctx, vs->fullname.data, flags, &cred);\n\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":127783,"func":"static inline void *f2fs_kvzalloc(struct f2fs_sb_info *sbi,\n\t\t\t\t\tsize_t size, gfp_t flags)\n{\n\treturn f2fs_kvmalloc(sbi, size, flags | __GFP_ZERO);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":19214,"func":"static int vorbis_parse_setup_hdr_tdtransforms ( vorbis_context * vc ) {\n GetBitContext * gb = & vc -> gb ;\n unsigned i , vorbis_time_count = get_bits ( gb , 6 ) + 1 ;\n for ( i = 0 ;\n i < vorbis_time_count ;\n ++ i ) {\n unsigned vorbis_tdtransform = get_bits ( gb , 16 ) ;\n av_dlog ( NULL , \" Vorbis time domain transform %u: %u\\n\" , vorbis_time_count , vorbis_tdtransform ) ;\n if ( vorbis_tdtransform ) {\n av_log ( vc -> avctx , AV_LOG_ERROR , \"Vorbis time domain transform data nonzero. \\n\" ) ;\n return AVERROR_INVALIDDATA ;\n }\n }\n return 0 ;\n }","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":410570,"func":"QPDFWriter::Members::~Members()\n{\n    if (file && close_file)\n    {\n\tfclose(file);\n    }\n    if (output_buffer)\n    {\n\tdelete output_buffer;\n    }\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":209864,"func":"process_pa_info(krb5_context context,\n\t\tconst krb5_principal client,\n\t\tconst AS_REQ *asreq,\n\t\tstruct pa_info_data *paid,\n\t\tMETHOD_DATA *md)\n{\n    struct pa_info_data *p = NULL;\n    size_t i;\n\n    for (i = 0; p == NULL && i < sizeof(pa_prefs)\/sizeof(pa_prefs[0]); i++) {\n\tPA_DATA *pa = find_pa_data(md, pa_prefs[i].type);\n\tif (pa == NULL)\n\t    continue;\n\tpaid->salt.salttype = (krb5_salttype)pa_prefs[i].type;\n\tp = (*pa_prefs[i].salt_info)(context, client, asreq,\n\t\t\t\t     paid, &pa->padata_value);\n    }\n    return p;\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":460600,"func":"dnIsSuffixScope( struct berval *ndn, struct berval *nbase, int scope )\n{\n\tif ( !dnIsSuffix( ndn, nbase ) ) {\n\t\treturn 0;\n\t}\n\n\treturn dnIsWithinScope( ndn, nbase, scope );\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":328773,"func":"static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){\n\n    int i;\n\n    for(i=16; i<16+8; i++){\n\n        if(nnzc[ scan8[i] ] || block[i*16])\n\n            ff_h264_idct_add_mmx    (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);\n\n    }\n\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":79707,"func":"void pdf_delete(pdf_t *pdf)\n{\n    int i;\n\n    for (i=0; i<pdf->n_xrefs; i++)\n    {\n        free(pdf->xrefs[i].creator);\n        free(pdf->xrefs[i].entries);\n        free(pdf->xrefs[i].kids);\n    }\n\n    free(pdf->name);\n    free(pdf->xrefs);\n    free(pdf);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":182067,"func":"void OmniboxViewWin::OnTemporaryTextMaybeChanged(const string16& display_text,\n                                                 bool save_original_selection) {\n  if (save_original_selection)\n    GetSelection(original_selection_);\n\n  ScopedFreeze freeze(this, GetTextObjectModel());\n  SetWindowTextAndCaretPos(display_text, display_text.length());\n  TextChanged();\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":68078,"func":"static inline RzBinDwarfLocList *create_loc_list(ut64 offset) {\n\tRzBinDwarfLocList *list = RZ_NEW0(RzBinDwarfLocList);\n\tif (list) {\n\t\tlist->list = rz_list_new();\n\t\tlist->offset = offset;\n\t}\n\treturn list;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":425681,"func":"static int round_event_name_len(struct fsnotify_event *fsn_event)\n{\n\tstruct inotify_event_info *event;\n\n\tevent = INOTIFY_E(fsn_event);\n\tif (!event->name_len)\n\t\treturn 0;\n\treturn roundup(event->name_len + 1, sizeof(struct inotify_event));\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":282882,"func":"xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)\n{\n    xsltStackElemPtr variable;\n\n    if (ctxt->varsNr <= 0)\n        return;\n\n    do {\n\tif (ctxt->varsNr <= limitNr)\n\t    break;\n\tvariable = ctxt->varsTab[ctxt->varsNr - 1];\n\tif (variable->level <= level)\n\t    break;\n\tif (variable->level >= 0)\n\t    xsltFreeStackElemList(variable);\n\tctxt->varsNr--;\n    } while (ctxt->varsNr != 0);\n    if (ctxt->varsNr > 0)\n        ctxt->vars = ctxt->varsTab[ctxt->varsNr - 1];\n    else\n        ctxt->vars = NULL;\n}\n","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":244164,"func":"void Element::updateNamedItemRegistration(const AtomicString& oldName, const AtomicString& newName)\n{\n    if (!document()->isHTMLDocument())\n        return;\n\n    if (!oldName.isEmpty())\n        toHTMLDocument(document())->removeNamedItem(oldName);\n\n    if (!newName.isEmpty())\n        toHTMLDocument(document())->addNamedItem(newName);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":399324,"func":"static inline void debug_deactivate(struct hrtimer *timer)\n{\n\tdebug_hrtimer_deactivate(timer);\n\ttrace_hrtimer_cancel(timer);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":143231,"func":"static int snd_timer_user_release(struct inode *inode, struct file *file)\n{\n\tstruct snd_timer_user *tu;\n\n\tif (file->private_data) {\n\t\ttu = file->private_data;\n\t\tfile->private_data = NULL;\n\t\tmutex_lock(&tu->ioctl_lock);\n\t\tif (tu->timeri)\n\t\t\tsnd_timer_close(tu->timeri);\n\t\tmutex_unlock(&tu->ioctl_lock);\n\t\tkfree(tu->queue);\n\t\tkfree(tu->tqueue);\n\t\tkfree(tu);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":4765,"func":"TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n  TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n  TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n  const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n  TfLiteIntArray* input_dims = input->dims;\n  int input_dims_size = input_dims->size;\n  TF_LITE_ENSURE(context, input_dims_size >= 1);\n\n  TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n  \/\/ Resize the output tensor.\n  TfLiteIntArray* output_shape = TfLiteIntArrayCreate(input_dims_size + 1);\n  for (int i = 0; i < input_dims_size; i++) {\n    output_shape->data[i] = input_dims->data[i];\n  }\n  \/\/ Last dimension in the output is the same as the last dimension in the\n  \/\/ input.\n  output_shape->data[input_dims_size] = input_dims->data[input_dims_size - 1];\n  output->type = input->type;\n  TF_LITE_ENSURE_OK(context,\n                    context->ResizeTensor(context, output, output_shape));\n\n  return kTfLiteOk;\n}","target":1,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":308753,"func":"static void xhci_port_update(XHCIPort *port, int is_detach)\n{\n    uint32_t pls = PLS_RX_DETECT;\n\n    port->portsc = PORTSC_PP;\n    if (!is_detach && xhci_port_have_device(port)) {\n        port->portsc |= PORTSC_CCS;\n        switch (port->uport->dev->speed) {\n        case USB_SPEED_LOW:\n            port->portsc |= PORTSC_SPEED_LOW;\n            pls = PLS_POLLING;\n            break;\n        case USB_SPEED_FULL:\n            port->portsc |= PORTSC_SPEED_FULL;\n            pls = PLS_POLLING;\n            break;\n        case USB_SPEED_HIGH:\n            port->portsc |= PORTSC_SPEED_HIGH;\n            pls = PLS_POLLING;\n            break;\n        case USB_SPEED_SUPER:\n            port->portsc |= PORTSC_SPEED_SUPER;\n            port->portsc |= PORTSC_PED;\n            pls = PLS_U0;\n            break;\n        }\n    }\n    set_field(&port->portsc, pls, PORTSC_PLS);\n    trace_usb_xhci_port_link(port->portnr, pls);\n    xhci_port_notify(port, PORTSC_CSC);\n}\n","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":374025,"func":"static int count_commas(char *s)\n{\n\tint n = 0;\n\twhile (*s)\n\t{\n\t\tif (*s == ',')\n\t\t\tn ++;\n\t\ts ++;\n\t}\n\treturn n;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":220370,"func":"  void ResetMonitoredUrls() {\n    base::AutoLock lock(lock_);\n    monitored_urls_.clear();\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":37120,"func":"did_set_spell_option(int is_spellfile)\n{\n    char_u  *errmsg = NULL;\n    win_T   *wp;\n    int\t    l;\n\n    if (is_spellfile)\n    {\n\tl = (int)STRLEN(curwin->w_s->b_p_spf);\n\tif (l > 0 && (l < 4\n\t\t\t|| STRCMP(curwin->w_s->b_p_spf + l - 4, \".add\") != 0))\n\t    errmsg = e_invarg;\n    }\n\n    if (errmsg == NULL)\n    {\n\tFOR_ALL_WINDOWS(wp)\n\t    if (wp->w_buffer == curbuf && wp->w_p_spell)\n\t    {\n\t\terrmsg = did_set_spelllang(wp);\n# ifdef FEAT_WINDOWS\n\t\tbreak;\n# endif\n\t    }\n    }\n    return errmsg;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":218928,"func":"qboolean FS_FilenameCompare( const char *s1, const char *s2 ) {\n\tint c1, c2;\n\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( Q_islower( c1 ) ) {\n\t\t\tc1 -= ( 'a' - 'A' );\n\t\t}\n\t\tif ( Q_islower( c2 ) ) {\n\t\t\tc2 -= ( 'a' - 'A' );\n\t\t}\n\n\t\tif ( c1 == '\\\\' || c1 == ':' ) {\n\t\t\tc1 = '\/';\n\t\t}\n\t\tif ( c2 == '\\\\' || c2 == ':' ) {\n\t\t\tc2 = '\/';\n\t\t}\n\n\t\tif ( c1 != c2 ) {\n\t\t\treturn qtrue;      \/\/ strings not equal\n\t\t}\n\t} while ( c1 );\n\n\treturn qfalse;       \/\/ strings are equal\n}\n","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":165873,"func":"  void ClearState() {\n    context_menu_request_received_ = false;\n    context_menu_params_.source_type = ui::MENU_SOURCE_NONE;\n  }\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":459689,"func":"dissect_kafka_offset_commit_response_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,\n                                              int offset, kafka_api_version_t api_version)\n{\n    proto_item *subti;\n    proto_tree *subtree;\n    int topic_start, topic_len;\n\n    subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_kafka_topic, &subti, \"Topic\");\n\n    \/* topic *\/\n    offset = dissect_kafka_string(subtree, hf_kafka_topic_name, tvb, pinfo, offset, api_version >= 8,\n                                  &topic_start, &topic_len);\n\n    \/* [partition_response] *\/\n    offset = dissect_kafka_array(subtree, tvb, pinfo, offset, api_version >= 8, api_version,\n                                 &dissect_kafka_offset_commit_response_partition_response, NULL);\n\n    if (api_version >= 8) {\n        offset = dissect_kafka_tagged_fields(tvb, pinfo, subtree, offset, 0);\n    }\n\n    proto_item_set_end(subti, tvb, offset);\n    proto_item_append_text(subti, \" (Name=%s)\",\n                           tvb_get_string_enc(wmem_packet_scope(), tvb,\n                                              topic_start, topic_len, ENC_UTF_8));\n\n    return offset;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":18830,"func":"static long timelib_parse_tz_cor ( char * * ptr ) {\n char * begin = * ptr , * end ;\n long tmp ;\n while ( isdigit ( * * ptr ) || * * ptr == ':' ) {\n ++ * ptr ;\n }\n end = * ptr ;\n switch ( end - begin ) {\n case 1 : case 2 : return HOUR ( strtol ( begin , NULL , 10 ) ) ;\n break ;\n case 3 : case 4 : if ( begin [ 1 ] == ':' ) {\n tmp = HOUR ( strtol ( begin , NULL , 10 ) ) + strtol ( begin + 2 , NULL , 10 ) ;\n return tmp ;\n }\n else if ( begin [ 2 ] == ':' ) {\n tmp = HOUR ( strtol ( begin , NULL , 10 ) ) + strtol ( begin + 3 , NULL , 10 ) ;\n return tmp ;\n }\n else {\n tmp = strtol ( begin , NULL , 10 ) ;\n return HOUR ( tmp \/ 100 ) + tmp % 100 ;\n }\n case 5 : tmp = HOUR ( strtol ( begin , NULL , 10 ) ) + strtol ( begin + 3 , NULL , 10 ) ;\n return tmp ;\n }\n return 0 ;\n }","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":441892,"func":"static void ptrace_do_notify(int signr, int exit_code, int why)\n{\n\tkernel_siginfo_t info;\n\n\tclear_siginfo(&info);\n\tinfo.si_signo = signr;\n\tinfo.si_code = exit_code;\n\tinfo.si_pid = task_pid_vnr(current);\n\tinfo.si_uid = from_kuid_munged(current_user_ns(), current_uid());\n\n\t\/* Let the debugger run.  *\/\n\tptrace_stop(exit_code, why, 1, &info);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":440231,"func":"onig_node_str_clear(Node* node)\n{\n  if (STR_(node)->capacity != 0 &&\n      IS_NOT_NULL(STR_(node)->s) && STR_(node)->s != STR_(node)->buf) {\n    xfree(STR_(node)->s);\n  }\n\n  STR_(node)->flag     = 0;\n  STR_(node)->s        = STR_(node)->buf;\n  STR_(node)->end      = STR_(node)->buf;\n  STR_(node)->capacity = 0;\n  STR_(node)->case_min_len = 0;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":446337,"func":"virDomainDiskSourceNVMeFormat(virBufferPtr attrBuf,\n                              virBufferPtr childBuf,\n                              const virStorageSourceNVMeDef *nvme)\n{\n    virBufferAddLit(attrBuf, \" type='pci'\");\n    if (nvme->managed != VIR_TRISTATE_BOOL_ABSENT)\n        virBufferAsprintf(attrBuf, \" managed='%s'\",\n                          virTristateBoolTypeToString(nvme->managed));\n    virBufferAsprintf(attrBuf, \" namespace='%llu'\", nvme->namespc);\n    virPCIDeviceAddressFormat(childBuf, nvme->pciAddr, false);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":379200,"func":"static inline void php_sqlite_strtoupper(char *s)\n{\n\twhile (*s!='\\0') {\n\t\t*s = toupper(*s);\n\t\ts++;\n\t}\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":137312,"func":"inline internal::NamedArgWithType<char, T> arg(StringRef name, const T &arg) {\n  return internal::NamedArgWithType<char, T>(name, arg);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":282623,"func":"static int ehci_state_fetchitd(EHCIState *ehci, int async)\n{\n    uint32_t entry;\n    EHCIitd itd;\n\n    assert(!async);\n    entry = ehci_get_fetch_addr(ehci, async);\n\n    if (get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &itd,\n                   sizeof(EHCIitd) >> 2) < 0) {\n        return -1;\n    }\n    ehci_trace_itd(ehci, entry, &itd);\n\n    if (ehci_process_itd(ehci, &itd, entry) != 0) {\n        return -1;\n    }\n\n    put_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &itd,\n               sizeof(EHCIitd) >> 2);\n    ehci_set_fetch_addr(ehci, async, itd.next);\n    ehci_set_state(ehci, async, EST_FETCHENTRY);\n\n    return 1;\n}\n","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":355215,"func":"do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)\n{\n#ifdef DEBUG_SIG\n\tprintk(\"do_notify_resume flags:%x ip:%lx sp:%lx caller:%p pending:%x\\n\",\n\t       thread_info_flags, regs->ip, regs->sp, __builtin_return_address(0),signal_pending(current));\n#endif\n\t       \n\t\/* Pending single-step? *\/\n\tif (thread_info_flags & _TIF_SINGLESTEP) {\n\t\tregs->flags |= X86_EFLAGS_TF;\n\t\tclear_thread_flag(TIF_SINGLESTEP);\n\t}\n\n#ifdef CONFIG_X86_MCE\n\t\/* notify userspace of pending MCEs *\/\n\tif (thread_info_flags & _TIF_MCE_NOTIFY)\n\t\tmce_notify_user();\n#endif \/* CONFIG_X86_MCE *\/\n\n\t\/* deal with pending signal delivery *\/\n\tif (thread_info_flags & (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK))\n\t\tdo_signal(regs);\n\n\tif (thread_info_flags & _TIF_HRTICK_RESCHED)\n\t\thrtick_resched();\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":519267,"func":"int Field_short::store(const char *from,size_t len,CHARSET_INFO *cs)\n{\n  ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;\n  int store_tmp;\n  int error;\n  longlong rnd;\n  \n  error= get_int(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, INT_MAX16);\n  store_tmp= unsigned_flag ? (int) (ulonglong) rnd : (int) rnd;\n  int2store(ptr, store_tmp);\n  return error;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":516863,"func":"alloc_group_fields(JOIN *join,ORDER *group)\n{\n  if (group)\n  {\n    for (; group ; group=group->next)\n    {\n      Cached_item *tmp=new_Cached_item(join->thd, *group->item, TRUE);\n      if (!tmp || join->group_fields.push_front(tmp))\n\treturn TRUE;\n    }\n  }\n  join->sort_and_group=1;\t\t\t\/* Mark for do_select *\/\n  return FALSE;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":94333,"func":"static struct ib_ucontext *hns_roce_alloc_ucontext(struct ib_device *ib_dev,\n\t\t\t\t\t\t   struct ib_udata *udata)\n{\n\tint ret = 0;\n\tstruct hns_roce_ucontext *context;\n\tstruct hns_roce_ib_alloc_ucontext_resp resp = {};\n\tstruct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);\n\n\tresp.qp_tab_size = hr_dev->caps.num_qps;\n\n\tcontext = kmalloc(sizeof(*context), GFP_KERNEL);\n\tif (!context)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tret = hns_roce_uar_alloc(hr_dev, &context->uar);\n\tif (ret)\n\t\tgoto error_fail_uar_alloc;\n\n\tif (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) {\n\t\tINIT_LIST_HEAD(&context->page_list);\n\t\tmutex_init(&context->page_mutex);\n\t}\n\n\tret = ib_copy_to_udata(udata, &resp, sizeof(resp));\n\tif (ret)\n\t\tgoto error_fail_copy_to_udata;\n\n\treturn &context->ibucontext;\n\nerror_fail_copy_to_udata:\n\thns_roce_uar_free(hr_dev, &context->uar);\n\nerror_fail_uar_alloc:\n\tkfree(context);\n\n\treturn ERR_PTR(ret);\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":25180,"func":"static void encode_signal_range ( VC2EncContext * s ) {\n put_bits ( & s -> pb , 1 , ! s -> strict_compliance ) ;\n if ( ! s -> strict_compliance ) put_vc2_ue_uint ( & s -> pb , s -> bpp_idx ) ;\n }","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":219972,"func":"void V8TestObject::ReflectedNameAttributeSetterCallback(\n    const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_reflectedName_Setter\");\n\n  v8::Local<v8::Value> v8_value = info[0];\n\n  test_object_v8_internal::ReflectedNameAttributeSetter(v8_value, info);\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":47367,"func":"static int r_core_cmd_nullcallback(void *data) {\n\tRCore *core = (RCore*) data;\n\tif (core->cons->context->breaked) {\n\t\tcore->cons->context->breaked = false;\n\t\treturn 0;\n\t}\n\tif (!core->cmdrepeat) {\n\t\treturn 0;\n\t}\n\tr_core_cmd_repeat (core, true);\n\treturn 1;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":396571,"func":"GC_API void GC_CALL GC_enable(void)\n{\n    DCL_LOCK_STATE;\n\n    LOCK();\n    GC_ASSERT(GC_dont_gc != 0); \/* ensure no counter underflow *\/\n    GC_dont_gc--;\n    UNLOCK();\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":306609,"func":"DEFINE_TEST(test_read_format_rar5_multiarchive_skip_all)\n{\n\tconst char* reffiles[] = {\n\t\t\"test_read_format_rar5_multiarchive.part01.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part02.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part03.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part04.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part05.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part06.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part07.rar\",\n\t\t\"test_read_format_rar5_multiarchive.part08.rar\",\n\t\tNULL\n\t};\n\n\tPROLOGUE_MULTI(reffiles);\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"home\/antek\/temp\/build\/unrar5\/libarchive\/bin\/bsdcat_test\", archive_entry_pathname(ae));\n\tassertA(0 == archive_read_next_header(a, &ae));\n\tassertEqualString(\"home\/antek\/temp\/build\/unrar5\/libarchive\/bin\/bsdtar_test\", archive_entry_pathname(ae));\n\tassertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));\n\tEPILOGUE();\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":394098,"func":"static void __sched notrace preempt_schedule_common(void)\n{\n\tdo {\n\t\tpreempt_disable_notrace();\n\t\t__schedule(true);\n\t\tpreempt_enable_no_resched_notrace();\n\n\t\t\/*\n\t\t * Check again in case we missed a preemption opportunity\n\t\t * between schedule and now.\n\t\t *\/\n\t} while (need_resched());\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":407928,"func":"void FAST_FUNC dealloc_bunzip(bunzip_data *bd)\n{\n\tfree(bd->dbuf);\n\tfree(bd);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":319092,"func":"void qemu_cond_init(QemuCond *cond)\n\n{\n\n    memset(cond, 0, sizeof(*cond));\n\n\n\n    cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);\n\n    if (!cond->sema) {\n\n        error_exit(GetLastError(), __func__);\n\n    }\n\n    cond->continue_event = CreateEvent(NULL,    \/* security *\/\n\n                                       FALSE,   \/* auto-reset *\/\n\n                                       FALSE,   \/* not signaled *\/\n\n                                       NULL);   \/* name *\/\n\n    if (!cond->continue_event) {\n\n        error_exit(GetLastError(), __func__);\n\n    }\n\n}\n","target":1,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":43130,"func":"mrb_mod_module_function(mrb_state *mrb, mrb_value mod)\n{\n  mrb_value *argv;\n  mrb_int argc, i;\n  mrb_sym mid;\n  mrb_method_t m;\n  struct RClass *rclass;\n  int ai;\n\n  mrb_check_type(mrb, mod, MRB_TT_MODULE);\n\n  mrb_get_args(mrb, \"*\", &argv, &argc);\n  if (argc == 0) {\n    \/* set MODFUNC SCOPE if implemented *\/\n    return mod;\n  }\n\n  \/* set PRIVATE method visibility if implemented *\/\n  \/* mrb_mod_dummy_visibility(mrb, mod); *\/\n\n  for (i=0; i<argc; i++) {\n    mrb_check_type(mrb, argv[i], MRB_TT_SYMBOL);\n\n    mid = mrb_symbol(argv[i]);\n    rclass = mrb_class_ptr(mod);\n    m = mrb_method_search(mrb, rclass, mid);\n\n    prepare_singleton_class(mrb, (struct RBasic*)rclass);\n    ai = mrb_gc_arena_save(mrb);\n    mrb_define_method_raw(mrb, rclass->c, mid, m);\n    mrb_gc_arena_restore(mrb, ai);\n  }\n\n  return mod;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":373063,"func":"AbstractSqlMigrator::AbstractSqlMigrator()\n    : _query(0)\n{\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":331019,"func":"static int usb_host_init(void)\n\n{\n\n    const struct libusb_pollfd **poll;\n\n    int i, rc;\n\n\n\n    if (ctx) {\n\n        return 0;\n\n    }\n\n    rc = libusb_init(&ctx);\n\n    if (rc != 0) {\n\n        return -1;\n\n    }\n\n    libusb_set_debug(ctx, loglevel);\n\n\n\n    libusb_set_pollfd_notifiers(ctx, usb_host_add_fd,\n\n                                usb_host_del_fd,\n\n                                ctx);\n\n    poll = libusb_get_pollfds(ctx);\n\n    if (poll) {\n\n        for (i = 0; poll[i] != NULL; i++) {\n\n            usb_host_add_fd(poll[i]->fd, poll[i]->events, ctx);\n\n        }\n\n    }\n\n    free(poll);\n\n    return 0;\n\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":298468,"func":"static size_t inet_nlmsg_size(void)\n{\n\treturn NLMSG_ALIGN(sizeof(struct ifaddrmsg))\n\t       + nla_total_size(4) \/* IFA_ADDRESS *\/\n\t       + nla_total_size(4) \/* IFA_LOCAL *\/\n\t       + nla_total_size(4) \/* IFA_BROADCAST *\/\n\t       + nla_total_size(IFNAMSIZ) \/* IFA_LABEL *\/\n\t       + nla_total_size(4)  \/* IFA_FLAGS *\/\n\t       + nla_total_size(sizeof(struct ifa_cacheinfo)); \/* IFA_CACHEINFO *\/\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":31528,"func":"static inline void last_modified(TSRMLS_D) \/* {{{ *\/\n{\n\tconst char *path;\n\tstruct stat sb;\n\tchar buf[MAX_STR + 1];\n\n\tpath = SG(request_info).path_translated;\n\tif (path) {\n\t\tif (VCWD_STAT(path, &sb) == -1) {\n\t\t\treturn;\n\t\t}\n\n#define LAST_MODIFIED \"Last-Modified: \"\n\t\tmemcpy(buf, LAST_MODIFIED, sizeof(LAST_MODIFIED) - 1);\n\t\tstrcpy_gmt(buf + sizeof(LAST_MODIFIED) - 1, &sb.st_mtime);\n\t\tADD_HEADER(buf);\n\t}\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":509211,"func":"int unit_add_node_link(Unit *u, const char *what, bool wants) {\n        Unit *device;\n        _cleanup_free_ char *e = NULL;\n        int r;\n\n        assert(u);\n\n        if (!what)\n                return 0;\n\n        \/* Adds in links to the device node that this unit is based on *\/\n\n        if (!is_device_path(what))\n                return 0;\n\n        e = unit_name_from_path(what, \".device\");\n        if (!e)\n                return -ENOMEM;\n\n        r = manager_load_unit(u->manager, e, NULL, NULL, &device);\n\n        if (r < 0)\n                return r;\n\n        r = unit_add_two_dependencies(u, UNIT_AFTER, UNIT_BINDS_TO, device, true);\n        if (r < 0)\n                return r;\n\n        if (wants) {\n                r = unit_add_dependency(device, UNIT_WANTS, u, false);\n                if (r < 0)\n                        return r;\n        }\n\n        return 0;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":414712,"func":"}\nstatic inline bool ext4_has_incompat_features(struct super_block *sb)\n{\n\treturn (EXT4_SB(sb)->s_es->s_feature_incompat != 0);","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":125527,"func":"static BOOL rdp_recv_server_set_keyboard_ime_status_pdu(rdpRdp* rdp, wStream* s)\n{\n\tUINT16 unitId;\n\tUINT32 imeState;\n\tUINT32 imeConvMode;\n\n\tif (!rdp || !rdp->input)\n\t\treturn FALSE;\n\n\tif (Stream_GetRemainingLength(s) < 10)\n\t\treturn FALSE;\n\n\tStream_Read_UINT16(s, unitId);      \/* unitId (2 bytes) *\/\n\tStream_Read_UINT32(s, imeState);    \/* imeState (4 bytes) *\/\n\tStream_Read_UINT32(s, imeConvMode); \/* imeConvMode (4 bytes) *\/\n\tIFCALL(rdp->update->SetKeyboardImeStatus, rdp->context, unitId, imeState, imeConvMode);\n\treturn TRUE;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":210431,"func":"zdoneshowpage(i_ctx_t *i_ctx_p)\n{\n    gx_device *dev = gs_currentdevice(igs);\n    gx_device *tdev = (*dev_proc(dev, get_page_device)) (dev);\n\n    if (tdev != 0)\n        tdev->ShowpageCount++;\n    return 0;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":179837,"func":"void LocalFrameClientImpl::UpdateDocumentLoader(\n    DocumentLoader* document_loader,\n    std::unique_ptr<WebDocumentLoader::ExtraData> extra_data) {\n  static_cast<WebDocumentLoaderImpl*>(document_loader)\n      ->SetExtraData(std::move(extra_data));\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":99979,"func":"int keysym2scancode(void *kbd_layout, int keysym)\n\n{\n\n    kbd_layout_t *k = kbd_layout;\n\n    if (keysym < MAX_NORMAL_KEYCODE) {\n\n        if (k->keysym2keycode[keysym] == 0) {\n\n            trace_keymap_unmapped(keysym);\n\n            fprintf(stderr, \"Warning: no scancode found for keysym %d\\n\",\n\n                    keysym);\n\n        }\n\n        return k->keysym2keycode[keysym];\n\n    } else {\n\n        int i;\n\n#ifdef XK_ISO_Left_Tab\n\n        if (keysym == XK_ISO_Left_Tab) {\n\n            keysym = XK_Tab;\n\n        }\n\n#endif\n\n        for (i = 0; i < k->extra_count; i++) {\n\n            if (k->keysym2keycode_extra[i].keysym == keysym) {\n\n                return k->keysym2keycode_extra[i].keycode;\n\n            }\n\n        }\n\n    }\n\n    return 0;\n\n}\n","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":330198,"func":"static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,\n\n                                 ptrdiff_t line_size)\n\n{\n\n    int i;\n\n\n\n    \/* read the pixels *\/\n\n    for (i = 0; i < 8; i++) {\n\n        pixels[0] = av_clip_uint8(block[0]);\n\n        pixels[1] = av_clip_uint8(block[1]);\n\n        pixels[2] = av_clip_uint8(block[2]);\n\n        pixels[3] = av_clip_uint8(block[3]);\n\n        pixels[4] = av_clip_uint8(block[4]);\n\n        pixels[5] = av_clip_uint8(block[5]);\n\n        pixels[6] = av_clip_uint8(block[6]);\n\n        pixels[7] = av_clip_uint8(block[7]);\n\n\n\n        pixels += line_size;\n\n        block  += 8;\n\n    }\n\n}\n","target":1,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":360828,"func":"gs_manager_set_user_switch_enabled (GSManager *manager,\n                                    gboolean   user_switch_enabled)\n{\n        g_return_if_fail (GS_IS_MANAGER (manager));\n\n        if (manager->priv->user_switch_enabled != user_switch_enabled) {\n                GSList *l;\n\n                manager->priv->user_switch_enabled = user_switch_enabled;\n                for (l = manager->priv->windows; l; l = l->next) {\n                        gs_window_set_user_switch_enabled (l->data, user_switch_enabled);\n                }\n        }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":63189,"func":"snmp_set_var_objid(netsnmp_variable_list * vp,\n                   const oid * objid, size_t name_length)\n{\n    size_t          len = sizeof(oid) * name_length;\n\n    if (vp->name != vp->name_loc && vp->name != NULL) {\n        \/*\n         * Probably previously-allocated \"big storage\".  Better free it\n         * else memory leaks possible.  \n         *\/\n        free(vp->name);\n    }\n\n    \/*\n     * use built-in storage for smaller values \n     *\/\n    if (len <= sizeof(vp->name_loc)) {\n        vp->name = vp->name_loc;\n    } else {\n        vp->name = (oid *) malloc(len);\n        if (!vp->name)\n            return 1;\n    }\n    if (objid)\n        memmove(vp->name, objid, len);\n    vp->name_length = name_length;\n    return 0;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":323274,"func":"static void test_hash_digest(void)\n\n{\n\n    size_t i;\n\n\n\n    g_assert(qcrypto_init(NULL) == 0);\n\n\n\n    for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {\n\n        int ret;\n\n        char *digest;\n\n        size_t digestsize;\n\n\n\n        digestsize = qcrypto_hash_digest_len(i);\n\n\n\n        g_assert_cmpint(digestsize * 2, ==, strlen(expected_outputs[i]));\n\n\n\n        ret = qcrypto_hash_digest(i,\n\n                                  INPUT_TEXT,\n\n                                  strlen(INPUT_TEXT),\n\n                                  &digest,\n\n                                  NULL);\n\n        g_assert(ret == 0);\n\n        g_assert(g_str_equal(digest, expected_outputs[i]));\n\n        g_free(digest);\n\n    }\n\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":315641,"func":"static int mem_cgroup_swappiness_write(struct cgroup *cgrp, struct cftype *cft,\n\t\t\t\t       u64 val)\n{\n\tstruct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);\n\tstruct mem_cgroup *parent;\n\n\tif (val > 100)\n\t\treturn -EINVAL;\n\n\tif (cgrp->parent == NULL)\n\t\treturn -EINVAL;\n\n\tparent = mem_cgroup_from_cont(cgrp->parent);\n\n\tcgroup_lock();\n\n\t\/* If under hierarchy, only empty-root can set this value *\/\n\tif ((parent->use_hierarchy) ||\n\t    (memcg->use_hierarchy && !list_empty(&cgrp->children))) {\n\t\tcgroup_unlock();\n\t\treturn -EINVAL;\n\t}\n\n\tmemcg->swappiness = val;\n\n\tcgroup_unlock();\n\n\treturn 0;\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":52443,"func":"static void *__netlink_seq_next(struct seq_file *seq)\n{\n\tstruct nl_seq_iter *iter = seq->private;\n\tstruct netlink_sock *nlk;\n\n\tdo {\n\t\tfor (;;) {\n\t\t\tint err;\n\n\t\t\tnlk = rhashtable_walk_next(&iter->hti);\n\n\t\t\tif (IS_ERR(nlk)) {\n\t\t\t\tif (PTR_ERR(nlk) == -EAGAIN)\n\t\t\t\t\tcontinue;\n\n\t\t\t\treturn nlk;\n\t\t\t}\n\n\t\t\tif (nlk)\n\t\t\t\tbreak;\n\n\t\t\tnetlink_walk_stop(iter);\n\t\t\tif (++iter->link >= MAX_LINKS)\n\t\t\t\treturn NULL;\n\n\t\t\terr = netlink_walk_start(iter);\n\t\t\tif (err)\n\t\t\t\treturn ERR_PTR(err);\n\t\t}\n\t} while (sock_net(&nlk->sk) != seq_file_net(seq));\n\n\treturn nlk;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":255622,"func":"writefile(const char *name, struct string *s)\n{\n\tFILE *f;\n\tint ret;\n\n\tf = fopen(name, \"w\");\n\tif (!f) {\n\t\twarn(\"open %s:\", name);\n\t\treturn -1;\n\t}\n\tret = 0;\n\tif (fwrite(s->s, 1, s->n, f) != s->n || fflush(f) != 0) {\n\t\twarn(\"write %s:\", name);\n\t\tret = -1;\n\t}\n\tfclose(f);\n\n\treturn ret;\n}","target":1,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":41921,"func":"static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)\n{\n\t__be32 *p;\n\tint status = 0;\n\n\t*res = 0;\n\tif (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))\n\t\treturn -EIO;\n\tif (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {\n\t\tREAD_BUF(8);\n\t\tREAD64(*res);\n\t\tbitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;\n\t}\n\tdprintk(\"%s: files avail=%Lu\\n\", __func__, (unsigned long long)*res);\n\treturn status;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":89754,"func":"void Commissioner::HandleMgmtCommissionerSetResponse(void *               aContext,\n                                                     otMessage *          aMessage,\n                                                     const otMessageInfo *aMessageInfo,\n                                                     otError              aResult)\n{\n    static_cast<Commissioner *>(aContext)->HandleMgmtCommissionerSetResponse(\n        static_cast<Coap::Message *>(aMessage), static_cast<const Ip6::MessageInfo *>(aMessageInfo), aResult);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":254337,"func":"status_t Camera3Device::getInputBufferProducer(\n        sp<IGraphicBufferProducer> *producer) {\n Mutex::Autolock il(mInterfaceLock);\n Mutex::Autolock l(mLock);\n\n if (producer == NULL) {\n return BAD_VALUE;\n } else if (mInputStream == NULL) {\n return INVALID_OPERATION;\n }\n\n return mInputStream->getInputBufferProducer(producer);\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":282517,"func":"GLenum Framebuffer::GetColorAttachmentFormat() const {\n  AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0);\n  if (it == attachments_.end()) {\n    return 0;\n  }\n  const Attachment* attachment = it->second.get();\n  return attachment->internal_format();\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":219196,"func":"WebPlugin* WebLocalFrameImpl::FocusedPluginIfInputMethodSupported() {\n  WebPluginContainerImpl* container = GetFrame()->GetWebPluginContainer();\n  if (container && container->SupportsInputMethod())\n    return container->Plugin();\n  return 0;\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":299788,"func":"evdns_nameserver_add(unsigned long int address) {\n\tif (!current_base)\n\t\tcurrent_base = evdns_base_new(NULL, 0);\n\treturn evdns_base_nameserver_add(current_base, address);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":87787,"func":"\tnamespace { bool numeric(char c) { return c >= '0' && c <= '9'; } }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":215085,"func":"static void ucvector_init_buffer(ucvector* p, unsigned char* buffer, size_t size)\n{\n  p->data = buffer;\n  p->allocsize = p->size = size;\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":204025,"func":"void WebContentsAndroid::SetupTransitionView(JNIEnv* env,\n                                             jobject jobj,\n                                             jstring markup) {\n  web_contents_->GetMainFrame()->Send(new FrameMsg_SetupTransitionView(\n      web_contents_->GetMainFrame()->GetRoutingID(),\n      ConvertJavaStringToUTF8(env, markup)));\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":259795,"func":"static void mem_cgroup_destroy(struct cgroup_subsys *ss,\n\t\t\t\tstruct cgroup *cont)\n{\n\tstruct mem_cgroup *memcg = mem_cgroup_from_cont(cont);\n\n\tkmem_cgroup_destroy(ss, cont);\n\n\tmem_cgroup_put(memcg);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":364749,"func":"httpClientDelayedShutdown(HTTPConnectionPtr connection)\n{\n    TimeEventHandlerPtr handler;\n\n    assert(connection->flags & CONN_READER);\n    handler = scheduleTimeEvent(1, httpClientDelayedShutdownHandler,\n                                sizeof(connection), &connection);\n    if(!handler) {\n        do_log(L_ERROR, \n               \"Couldn't schedule delayed shutdown -- freeing memory.\");\n        free_chunk_arenas();\n        handler = scheduleTimeEvent(1, httpClientDelayedShutdownHandler,\n                                    sizeof(connection), &connection);\n        if(!handler) {\n            do_log(L_ERROR, \n                   \"Couldn't schedule delayed shutdown -- aborting.\\n\");\n            polipoExit();\n        }\n    }\n    return 1;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":50054,"func":"static void ion_free_nolock(struct ion_client *client, struct ion_handle *handle)\n{\n\tbool valid_handle;\n\n\tBUG_ON(client != handle->client);\n\n\tvalid_handle = ion_handle_validate(client, handle);\n\n\tif (!valid_handle) {\n\t\tWARN(1, \"%s: invalid handle passed to free.\\n\", __func__);\n\t\treturn;\n\t}\n\tion_handle_put_nolock(handle);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":117643,"func":"evdns_config_windows_nameservers(void)\n{\n\tif (!current_base) {\n\t\tcurrent_base = evdns_base_new(NULL, 1);\n\t\treturn current_base == NULL ? -1 : 0;\n\t} else {\n\t\treturn evdns_base_config_windows_nameservers(current_base);\n\t}\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":448155,"func":"apr_array_header_t *h2_push_collect_update(h2_stream *stream, \n                                           const struct h2_request *req, \n                                           const struct h2_headers *res)\n{\n    apr_array_header_t *pushes;\n    \n    pushes = h2_push_collect(stream->pool, req, stream->push_policy, res);\n    return h2_push_diary_update(stream->session, pushes);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":517028,"func":"st_select_lex_node *st_select_lex_node:: insert_chain_before(\n\t\t\t\t         st_select_lex_node **ptr_pos_to_insert,\n                                         st_select_lex_node *end_chain_node)\n{\n  end_chain_node->link_next= *ptr_pos_to_insert;\n  (*ptr_pos_to_insert)->link_prev= &end_chain_node->link_next;\n  this->link_prev= ptr_pos_to_insert;\n  return this;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":259350,"func":"  const std::string& expectedPeerCert() const { return expected_peer_cert_; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":463170,"func":"    ReadWriteType getReadWriteType() const {\n        return ReadWriteType::kRead;\n    }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":298255,"func":"static void sas_unregister_ex_tree(struct asd_sas_port *port, struct domain_device *dev)\n{\n\tstruct expander_device *ex = &dev->ex_dev;\n\tstruct domain_device *child, *n;\n\n\tlist_for_each_entry_safe(child, n, &ex->children, siblings) {\n\t\tset_bit(SAS_DEV_GONE, &child->state);\n\t\tif (child->dev_type == SAS_EDGE_EXPANDER_DEVICE ||\n\t\t    child->dev_type == SAS_FANOUT_EXPANDER_DEVICE)\n\t\t\tsas_unregister_ex_tree(port, child);\n\t\telse\n\t\t\tsas_unregister_dev(port, child);\n\t}\n\tsas_unregister_dev(port, dev);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":131512,"func":"static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char *ct, unsigned tcount)\n{\n\tunsigned long a,b,mask;\n\n\tfor (;;) {\n\t\ta = *(unsigned long *)cs;\n\t\tb = load_unaligned_zeropad(ct);\n\t\tif (tcount < sizeof(unsigned long))\n\t\t\tbreak;\n\t\tif (unlikely(a != b))\n\t\t\treturn 1;\n\t\tcs += sizeof(unsigned long);\n\t\tct += sizeof(unsigned long);\n\t\ttcount -= sizeof(unsigned long);\n\t\tif (!tcount)\n\t\t\treturn 0;\n\t}\n\tmask = bytemask_from_count(tcount);\n\treturn unlikely(!!((a ^ b) & mask));\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":262346,"func":"\n    T& _at(const int offset) {\n      const unsigned int siz = (unsigned int)size();\n      return (*this)[offset<0?0:(unsigned int)offset>=siz?siz - 1:offset];","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":118802,"func":"    bool JavascriptArray::HasNoMissingValues() const\n    {\n        return !!(GetFlags() & DynamicObjectFlags::HasNoMissingValues);\n    }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":91439,"func":"u_update_save_nr(buf_T *buf)\n{\n    u_header_T\t*uhp;\n\n    ++buf->b_u_save_nr_last;\n    buf->b_u_save_nr_cur = buf->b_u_save_nr_last;\n    uhp = buf->b_u_curhead;\n    if (uhp != NULL)\n\tuhp = uhp->uh_next.ptr;\n    else\n\tuhp = buf->b_u_newhead;\n    if (uhp != NULL)\n\tuhp->uh_save_nr = buf->b_u_save_nr_last;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":136990,"func":"static void intel_pmu_disable_all(void)\n{\n\tstruct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);\n\n\twrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);\n\n\tif (test_bit(X86_PMC_IDX_FIXED_BTS, cpuc->active_mask))\n\t\tintel_pmu_disable_bts();\n\n\tintel_pmu_pebs_disable_all();\n\tintel_pmu_lbr_disable_all();\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":277367,"func":"void RenderViewTest::SimulatePointClick(const gfx::Point& point) {\n  WebMouseEvent mouse_event;\n  mouse_event.type = WebInputEvent::MouseDown;\n  mouse_event.button = WebMouseEvent::ButtonLeft;\n  mouse_event.x = point.x();\n  mouse_event.y = point.y();\n  mouse_event.clickCount = 1;\n  RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);\n  impl->OnMessageReceived(\n      InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false));\n  mouse_event.type = WebInputEvent::MouseUp;\n  impl->OnMessageReceived(\n      InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false));\n}\n","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":156487,"func":"static MonoBoolean\nmono_declsec_get_method_demands_params (MonoMethod *method, MonoDeclSecurityActions* demands, \n\tguint32 id_std, guint32 id_noncas, guint32 id_choice)\n{\n\tguint32 idx = mono_method_get_index (method);\n\tidx <<= MONO_HAS_DECL_SECURITY_BITS;\n\tidx |= MONO_HAS_DECL_SECURITY_METHODDEF;\n\treturn fill_actions_from_index (method->klass->image, idx, demands, id_std, id_noncas, id_choice);","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":198287,"func":"static int composite_exit(int sub_api)\n{\n\treturn LIBUSB_SUCCESS;\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":218212,"func":"  GestureEventConsumeDelegate()\n      : tap_(false),\n        tap_down_(false),\n        tap_cancel_(false),\n        begin_(false),\n        end_(false),\n        scroll_begin_(false),\n        scroll_update_(false),\n        scroll_end_(false),\n        pinch_begin_(false),\n        pinch_update_(false),\n        pinch_end_(false),\n        long_press_(false),\n        fling_(false),\n        two_finger_tap_(false),\n        show_press_(false),\n        swipe_left_(false),\n        swipe_right_(false),\n        swipe_up_(false),\n        swipe_down_(false),\n        scroll_x_(0),\n        scroll_y_(0),\n        scroll_velocity_x_(0),\n        scroll_velocity_y_(0),\n        velocity_x_(0),\n        velocity_y_(0),\n        scroll_x_hint_(0),\n        scroll_y_hint_(0),\n        tap_count_(0),\n        flags_(0),\n        wait_until_event_(ui::ET_UNKNOWN) {}\n","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":99851,"func":"int ToTraditional_ex(byte* input, word32 sz, word32* algId)\n{\n    word32 inOutIdx = 0;\n    int    length;\n\n    if (input == NULL)\n        return BAD_FUNC_ARG;\n\n    length = ToTraditionalInline_ex(input, &inOutIdx, sz, algId);\n    if (length < 0)\n        return length;\n\n    if (length + inOutIdx > sz)\n        return BUFFER_E;\n\n    XMEMMOVE(input, input + inOutIdx, length);\n\n    return length;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":41611,"func":"void free_hist_patterns()\n{\n  delete_dynamic(&histignore_patterns);\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":269753,"func":"static bool arg_type_is_alloc_mem_ptr(enum bpf_arg_type type)\n{\n\treturn type == ARG_PTR_TO_ALLOC_MEM ||\n\t       type == ARG_PTR_TO_ALLOC_MEM_OR_NULL;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":114760,"func":"SPL_METHOD(Array, offsetSet)\n{\n\tzval *index, *value;\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"zz\", &index, &value) == FAILURE) {\n\t\treturn;\n\t}\n\tspl_array_write_dimension_ex(0, getThis(), index, value TSRMLS_CC);\n} \/* }}} *\/","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":265457,"func":"static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)\n{\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":379181,"func":"static int ZEND_FASTCALL  ZEND_INIT_ARRAY_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\n\tarray_init(&EX_T(opline->result.u.var).tmp_var);\n\tif (IS_CV == IS_UNUSED) {\n\t\tZEND_VM_NEXT_OPCODE();\n#if 0 || IS_CV != IS_UNUSED\n\t} else {\n\t\treturn ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n#endif\n\t}\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":414839,"func":"process_set_cookie_header (SoupMessage *msg, gpointer user_data)\n{\n\tSoupCookieJar *jar = user_data;\n\tSoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);\n\tGSList *new_cookies, *nc;\n\n\tif (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER)\n\t\treturn;\n\n\tnew_cookies = soup_cookies_from_response (msg);\n\tfor (nc = new_cookies; nc; nc = nc->next) {\n\t\tSoupURI *first_party = soup_message_get_first_party (msg);\n\t\t\n\t\tif ((priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY &&\n\t\t     !incoming_cookie_is_third_party (nc->data, first_party)) ||\n\t\t    priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_ALWAYS)\n\t\t\tsoup_cookie_jar_add_cookie (jar, nc->data);\n\t\telse\n\t\t\tsoup_cookie_free (nc->data);\n\t}\n\tg_slist_free (new_cookies);\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":270071,"func":"vma_address(struct page *page, struct vm_area_struct *vma)\n{\n\tunsigned long address = __vma_address(page, vma);\n\n\t\/* page should be within @vma mapping range *\/\n\tVM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);\n\n\treturn address;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":94999,"func":"repodata_setpos_kv(Repodata *data, KeyValue *kv)\n{\n  Pool *pool = data->repo->pool;\n  if (!kv)\n    pool_clear_pos(pool);\n  else\n    {\n      pool->pos.repo = data->repo;\n      pool->pos.repodataid = data - data->repo->repodata;\n      pool->pos.dp = (unsigned char *)kv->str - data->incoredata;\n      pool->pos.schema = kv->id;\n    }\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":286057,"func":"ProcSetFontPath(ClientPtr client)\n{\n    unsigned char *ptr;\n    unsigned long nbytes, total;\n    long nfonts;\n    int n;\n\n    REQUEST(xSetFontPathReq);\n\n    REQUEST_AT_LEAST_SIZE(xSetFontPathReq);\n\n    nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);\n    total = nbytes;\n    ptr = (unsigned char *) &stuff[1];\n    nfonts = stuff->nFonts;\n    while (--nfonts >= 0) {\n        if ((total == 0) || (total < (n = (*ptr + 1))))\n            return BadLength;\n        total -= n;\n        ptr += n;\n    }\n    if (total >= 4)\n        return BadLength;\n    return SetFontPath(client, stuff->nFonts, (unsigned char *) &stuff[1]);\n}\n","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":479966,"func":"evdev_scroll_set_button_lock(struct libinput_device *device,\n\t\t\t     enum libinput_config_scroll_button_lock_state state)\n{\n\tstruct evdev_device *evdev = evdev_device(device);\n\n\tswitch (state) {\n\tcase LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED:\n\t\tevdev->scroll.want_lock_enabled = false;\n\t\tbreak;\n\tcase LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED:\n\t\tevdev->scroll.want_lock_enabled = true;\n\t\tbreak;\n\tdefault:\n\t\treturn LIBINPUT_CONFIG_STATUS_INVALID;\n\t}\n\n\tevdev->scroll.change_scroll_method(evdev);\n\n\treturn LIBINPUT_CONFIG_STATUS_SUCCESS;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":35849,"func":"static int rtnl_net_get_size(void)\n{\n\treturn NLMSG_ALIGN(sizeof(struct rtgenmsg))\n\t       + nla_total_size(sizeof(s32)) \/* NETNSA_NSID *\/\n\t       + nla_total_size(sizeof(s32)) \/* NETNSA_CURRENT_NSID *\/\n\t       ;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":143078,"func":"void stsz_box_del(GF_Box *s)\n{\n\tGF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->sizes) gf_free(ptr->sizes);\n\tgf_free(ptr);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":149442,"func":"  static TensorBuffer* Decode(Allocator* a, const Source& in, int64_t n) {\n    auto* buf = new Buffer<ResourceHandle>(a, n);\n    ResourceHandle* ps = buf->template base<ResourceHandle>();\n    if (ps == nullptr ||\n        !DecodeResourceHandleList(port::NewStringListDecoder(in), ps, n)) {\n      buf->Unref();\n      return nullptr;\n    }\n    return buf;\n  }","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":354160,"func":"bool Virtual_column_info::fix_session_expr(THD *thd)\n{\n  DBUG_ENTER(\"fix_session_vcol_expr\");\n  if (!(flags & (VCOL_TIME_FUNC|VCOL_SESSION_FUNC)))\n    DBUG_RETURN(0);\n\n  expr->walk(&Item::cleanup_excluding_fields_processor, 0, 0);\n  DBUG_ASSERT(!expr->fixed);\n  DBUG_RETURN(fix_expr(thd));\n}","target":1,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":230766,"func":"void HTMLMediaElement::enterPictureInPicture(\n    WebMediaPlayer::PipWindowSizeCallback callback) {\n  if (GetWebMediaPlayer())\n    GetWebMediaPlayer()->EnterPictureInPicture(std::move(callback));\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":269353,"func":"static int vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)\n{\n\tstruct page *page;\n\n\tpage = vmalloc_to_page((void *)(vmf->pgoff << PAGE_SHIFT));\n\tif (!page)\n\t\treturn VM_FAULT_SIGBUS;\n\n\tget_page(page);\n\tvmf->page = page;\n\n\treturn 0;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":143392,"func":"uint32_t BinaryProtocolWriter::serializedSizeMapBegin(\n    TType \/*keyType*\/,\n    TType \/*valType*\/,\n    uint32_t \/*size*\/) const {\n  return serializedSizeByte() + serializedSizeByte() + serializedSizeI32();\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":352707,"func":"ArgParser::argOiMinArea(char* parameter)\n{\n    o.oi_min_area = QUtil::string_to_int(parameter);\n}","target":1,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":250069,"func":"rc_pdf14_maskbuf_free(gs_memory_t * mem, void *ptr_in, client_name_t cname)\n{\n    \/* Ending the mask buffer. *\/\n    pdf14_rcmask_t *rcmask = (pdf14_rcmask_t * ) ptr_in;\n    \/* free the pdf14 buffer. *\/\n    if ( rcmask->mask_buf != NULL ){\n        pdf14_buf_free(rcmask->mask_buf, mem);\n    }\n    gs_free_object(mem, rcmask, \"rc_pdf14_maskbuf_free\");\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":417732,"func":"int link_set_hostname(Link *link, const char *hostname) {\n        int r;\n\n        assert(link);\n        assert(link->manager);\n\n        log_link_debug(link, \"Setting transient hostname: '%s'\", strna(hostname));\n\n        if (!link->manager->bus) {\n                \/* TODO: replace by assert when we can rely on kdbus *\/\n                log_link_info(link, \"Not connected to system bus, ignoring transient hostname.\");\n                return 0;\n        }\n\n        r = sd_bus_call_method_async(\n                        link->manager->bus,\n                        NULL,\n                        \"org.freedesktop.hostname1\",\n                        \"\/org\/freedesktop\/hostname1\",\n                        \"org.freedesktop.hostname1\",\n                        \"SetHostname\",\n                        set_hostname_handler,\n                        link,\n                        \"sb\",\n                        hostname,\n                        false);\n\n        if (r < 0)\n                return log_link_error_errno(link, r, \"Could not set transient hostname: %m\");\n\n        link_ref(link);\n\n        return 0;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":295539,"func":"iperf_reporter_callback(struct iperf_test *test)\n{\n    switch (test->state) {\n        case TEST_RUNNING:\n        case STREAM_RUNNING:\n            \/* print interval results for each stream *\/\n            iperf_print_intermediate(test);\n            break;\n        case TEST_END:\n        case DISPLAY_RESULTS:\n            iperf_print_intermediate(test);\n            iperf_print_results(test);\n            break;\n    } \n\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":129035,"func":"TEST_F(AllowMissingInAndOfOrListTest, OneGoodJwt) {\n  EXPECT_CALL(mock_cb_, onComplete(Status::Ok));\n  auto headers = Http::TestRequestHeaderMapImpl{{kExampleHeader, GoodToken}};\n  context_ = Verifier::createContext(headers, parent_span_, &mock_cb_);\n  verifier_->verify(context_);\n  EXPECT_THAT(headers, JwtOutputSuccess(kExampleHeader));\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":357147,"func":"void __scm_destroy(struct scm_cookie *scm)\n{\n\tstruct scm_fp_list *fpl = scm->fp;\n\tint i;\n\n\tif (fpl) {\n\t\tscm->fp = NULL;\n\t\tif (current->scm_work_list) {\n\t\t\tlist_add_tail(&fpl->list, current->scm_work_list);\n\t\t} else {\n\t\t\tLIST_HEAD(work_list);\n\n\t\t\tcurrent->scm_work_list = &work_list;\n\n\t\t\tlist_add(&fpl->list, &work_list);\n\t\t\twhile (!list_empty(&work_list)) {\n\t\t\t\tfpl = list_first_entry(&work_list, struct scm_fp_list, list);\n\n\t\t\t\tlist_del(&fpl->list);\n\t\t\t\tfor (i=fpl->count-1; i>=0; i--)\n\t\t\t\t\tfput(fpl->fp[i]);\n\t\t\t\tkfree(fpl);\n\t\t\t}\n\n\t\t\tcurrent->scm_work_list = NULL;\n\t\t}\n\t}\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":295655,"func":"load_list(UnpicklerObject *self)\n{\n    PyObject *list;\n    Py_ssize_t i;\n\n    if ((i = marker(self)) < 0)\n        return -1;\n\n    list = Pdata_poplist(self->stack, i);\n    if (list == NULL)\n        return -1;\n    PDATA_PUSH(self->stack, list, -1);\n    return 0;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":495485,"func":"njs_string_create(njs_vm_t *vm, njs_value_t *value, const char *src,\n    size_t size)\n{\n    njs_str_t  str;\n\n    str.start = (u_char *) src;\n    str.length = size;\n\n    return njs_string_decode_utf8(vm, value, &str);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":214367,"func":"WebDriverCommand::~WebDriverCommand() {}\n","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":42631,"func":"static void ReadBlobDoublesMSB(Image * image, size_t len, double *data)\n{\n  while (len >= 8)\n  {\n    *data++ = ReadBlobDouble(image);\n    len -= sizeof(double);\n  }\n  if (len > 0)\n    (void) SeekBlob(image, len, SEEK_CUR);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":465965,"func":"static bool cpu_has_sgx(void)\n{\n\treturn cpuid_eax(0) >= 0x12 && (cpuid_eax(0x12) & BIT(0));\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":298450,"func":"static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs,\n                                   void *pBuf, size_t n) {\n  mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;\n  size_t s = (file_ofs >= pZip->m_archive_size)\n                 ? 0\n                 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n);\n  memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s);\n  return s;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":71453,"func":"enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream)\n{\n\tenum dc_status status = DC_OK;\n\tstruct pipe_ctx *pipe_ctx = resource_get_head_pipe_for_stream(&context->res_ctx, stream);\n\n\t\/*TODO Seems unneeded anymore *\/\n\t\/*\tif (old_context && resource_is_stream_unchanged(old_context, stream)) {\n\t\t\tif (stream != NULL && old_context->streams[i] != NULL) {\n\t\t\t\t todo: shouldn't have to copy missing parameter here\n\t\t\t\tresource_build_bit_depth_reduction_params(stream,\n\t\t\t\t\t\t&stream->bit_depth_params);\n\t\t\t\tstream->clamping.pixel_encoding =\n\t\t\t\t\t\tstream->timing.pixel_encoding;\n\n\t\t\t\tresource_build_bit_depth_reduction_params(stream,\n\t\t\t\t\t\t\t\t&stream->bit_depth_params);\n\t\t\t\tbuild_clamping_params(stream);\n\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t*\/\n\n\tif (!pipe_ctx)\n\t\treturn DC_ERROR_UNEXPECTED;\n\n\n\tstatus = build_pipe_hw_param(pipe_ctx);\n\n\treturn status;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":454809,"func":"int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)\n{\n\tva_list list;\n\tstruct rtas_args *args;\n\tunsigned long flags;\n\tint i, ret = 0;\n\n\tif (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)\n\t\treturn -1;\n\n\tlocal_irq_save(flags);\n\tpreempt_disable();\n\n\t\/* We use the per-cpu (PACA) rtas args buffer *\/\n\targs = local_paca->rtas_args_reentrant;\n\n\tva_start(list, outputs);\n\tva_rtas_call_unlocked(args, token, nargs, nret, list);\n\tva_end(list);\n\n\tif (nret > 1 && outputs)\n\t\tfor (i = 0; i < nret - 1; ++i)\n\t\t\toutputs[i] = be32_to_cpu(args->rets[i + 1]);\n\n\tif (nret > 0)\n\t\tret = be32_to_cpu(args->rets[0]);\n\n\tlocal_irq_restore(flags);\n\tpreempt_enable();\n\n\treturn ret;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":71594,"func":"R_API st64 r_buf_fread(RBuffer *b, ut8 *buf, const char *fmt, int n) {\n\tr_return_val_if_fail (b && buf && fmt, -1);\n\t\/\/ XXX: we assume the caller knows what he's doing\n\tRBuffer *dst = r_buf_new_with_pointers (buf, UT64_MAX, false);\n\tst64 res = buf_format (dst, b, fmt, n);\n\tr_buf_free (dst);\n\treturn res;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":394772,"func":"CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) \/* {{{ *\/\n{\n\tcwd_state new_state;\n\tint retval;\n\n\tCWD_STATE_COPY(&new_state, &CWDG(cwd));\n\tif (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) {\n\t\tCWD_STATE_FREE(&new_state);\n\t\treturn -1;\n\t}\n\n\tretval = php_sys_lstat(new_state.cwd, buf);\n\n\tCWD_STATE_FREE(&new_state);\n\treturn retval;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":188985,"func":"int RenderViewImpl::historyForwardListCount() {\n  return history_list_length_ - historyBackListCount() - 1;\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":369527,"func":"get_provider_group (GoaProvider *_provider)\n{\n  return GOA_PROVIDER_GROUP_BRANDED;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":11190,"func":"void LinkChangeSerializerMarkupAccumulator::appendElement(StringBuilder& result, Element* element, Namespaces* namespaces)\n{\n    if (element->hasTagName(HTMLNames::baseTag)) {\n        result.append(\"<!--\");\n    } else if (element->hasTagName(HTMLNames::htmlTag)) {\n        result.append(String::format(\"\\n<!-- saved from url=(%04d)%s -->\\n\",\n            static_cast<int>(m_document->url().string().utf8().length()),\n            m_document->url().string().utf8().data()));\n    }\n    SerializerMarkupAccumulator::appendElement(result, element, namespaces);\n    if (element->hasTagName(HTMLNames::baseTag)) {\n        result.appendLiteral(\"-->\");\n        result.appendLiteral(\"<base href=\\\".\\\"\");\n        if (!m_document->baseTarget().isEmpty()) {\n            result.appendLiteral(\" target=\\\"\");\n            result.append(m_document->baseTarget());\n            result.append('\"');\n        }\n        if (m_document->isXHTMLDocument())\n            result.appendLiteral(\" \/>\");\n        else\n            result.appendLiteral(\">\");\n    }\n}\n","target":1,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":336421,"func":"static void spr_write_403_pbr (void *opaque, int sprn)\n\n{\n\n    DisasContext *ctx = opaque;\n\n\n\n    gen_op_store_403_pb(sprn - SPR_403_PBL1);\n\n    RET_STOP(ctx);\n\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":438955,"func":"static void SFDDumpEncoding(FILE *sfd,Encoding *encname,const char *keyword) {\n    fprintf(sfd, \"%s: %s\\n\", keyword, encname->enc_name );\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":18170,"func":"void qdev_register ( DeviceInfo * info ) {\n assert ( info -> size >= sizeof ( DeviceState ) ) ;\n assert ( ! info -> next ) ;\n info -> next = device_info_list ;\n device_info_list = info ;\n }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":492356,"func":"callbacks_zoom_out_activate                   (GtkMenuItem     *menuitem,\n                                        gpointer         user_data)\n{\n\trender_zoom_display (ZOOM_OUT, 0, 0, 0);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":125308,"func":"static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)\n{\n\tif (nfs4_setup_sequence(NFS_SERVER(data->dir),\n\t\t\t\t&data->args.seq_args,\n\t\t\t\t&data->res.seq_res,\n\t\t\t\ttask))\n\t\treturn;\n\trpc_call_start(task);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":217250,"func":"void RenderWidgetHostViewAura::DetachFromInputMethod() {\n  ui::InputMethod* input_method = GetInputMethod();\n  if (input_method && input_method->GetTextInputClient() == this)\n    input_method->SetFocusedTextInputClient(NULL);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":85450,"func":"static int32_t modplugresamplingmode_to_filterlength(int mode)\n{\n\tif(mode<0){\n\t\treturn 1;\n\t}\n\tswitch(mode){\n\tcase MODPLUG_RESAMPLE_NEAREST: return 1; break;\n\tcase MODPLUG_RESAMPLE_LINEAR: return 2; break;\n\tcase MODPLUG_RESAMPLE_SPLINE: return 4; break;\n\tcase MODPLUG_RESAMPLE_FIR: return 8; break;\n\t}\n\treturn 8;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":186408,"func":"static struct sc_card_driver *sc_get_driver(void)\n{\n\tstruct sc_card_driver *iso_drv = sc_get_iso7816_driver();\n\n\tsetcos_ops = *iso_drv->ops;\n\tsetcos_ops.match_card = setcos_match_card;\n\tsetcos_ops.init = setcos_init;\n\tif (iso_ops == NULL)\n\t\tiso_ops = iso_drv->ops;\n\tsetcos_ops.create_file = setcos_create_file;\n\tsetcos_ops.set_security_env = setcos_set_security_env;\n\tsetcos_ops.select_file = setcos_select_file;\n\tsetcos_ops.list_files = setcos_list_files;\n\tsetcos_ops.process_fci = setcos_process_fci;\n\tsetcos_ops.construct_fci = setcos_construct_fci;\n\tsetcos_ops.card_ctl = setcos_card_ctl;\n\n\treturn &setcos_drv;\n}\n","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":103650,"func":"void ConnectionManagerImpl::onIdleTimeout() {\n  ENVOY_CONN_LOG(debug, \"idle timeout\", read_callbacks_->connection());\n  stats_.named_.downstream_cx_idle_timeout_.inc();\n  if (!codec_) {\n    \/\/ No need to delay close after flushing since an idle timeout has already fired. Attempt to\n    \/\/ write out buffered data one last time and issue a local close if successful.\n    read_callbacks_->connection().close(Network::ConnectionCloseType::FlushWrite);\n  } else if (drain_state_ == DrainState::NotDraining) {\n    startDrainSequence();\n  }\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":283427,"func":"nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,\n\t    struct nfsd4_putfh *putfh)\n{\n\tfh_put(&cstate->current_fh);\n\tcstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen;\n\tmemcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval,\n\t       putfh->pf_fhlen);\n\treturn fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_BYPASS_GSS);\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":9299,"func":" void DevToolsSession::ReceivedBadMessage() {\n   MojoConnectionDestroyed();\n  if (process_) {\n     bad_message::ReceivedBadMessage(\n        process_, bad_message::RFH_INCONSISTENT_DEVTOOLS_MESSAGE);\n   }\n }\n","target":1,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":285854,"func":"uint32_t BpMemoryHeap::getOffset() const {\n    assertMapped();\n return mOffset;\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":522353,"func":"  void next_row()\n  {\n    if (move)\n    {\n      \/*\n        Our cursor is pointing at the first row that was a peer of the previous\n        current row. Or, it was the first row in the partition.\n      *\/\n      if (cursor.fetch())\n        return;\n\n      \/\/ todo: need the following check ?\n      if (!peer_tracker.compare_with_cache())\n        return;\n      remove_value_from_items();\n\n      do\n      {\n        if (cursor.next() || cursor.fetch())\n          return;\n        if (!peer_tracker.compare_with_cache())\n          return;\n        remove_value_from_items();\n      }\n      while (1);\n    }\n  }","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":185285,"func":"bool DevToolsDataSource::ShouldAddContentSecurityPolicy() const {\n  return false;\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":103252,"func":"int snd_seq_kernel_client_ctl(int clientid, unsigned int cmd, void *arg)\n{\n\tconst struct ioctl_handler *handler;\n\tstruct snd_seq_client *client;\n\n\tclient = clientptr(clientid);\n\tif (client == NULL)\n\t\treturn -ENXIO;\n\n\tfor (handler = ioctl_handlers; handler->cmd > 0; ++handler) {\n\t\tif (handler->cmd == cmd)\n\t\t\treturn handler->func(client, arg);\n\t}\n\n\tpr_debug(\"ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\\n\",\n\t\t cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));\n\treturn -ENOTTY;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":220685,"func":"  void VerifyPrintPreviewCancelled(bool did_cancel) {\n    bool print_preview_cancelled =\n        (render_thread_->sink().GetUniqueMessageMatching(\n            PrintHostMsg_PrintPreviewCancelled::ID) != NULL);\n    EXPECT_EQ(did_cancel, print_preview_cancelled);\n  }\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":303880,"func":"void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu,\n\t\t      int oif, u32 mark, u8 protocol, int flow_flags)\n{\n\tconst struct iphdr *iph = (const struct iphdr *) skb->data;\n\tstruct flowi4 fl4;\n\tstruct rtable *rt;\n\n\tif (!mark)\n\t\tmark = IP4_REPLY_MARK(net, skb->mark);\n\n\t__build_flow_key(&fl4, NULL, iph, oif,\n\t\t\t RT_TOS(iph->tos), protocol, mark, flow_flags);\n\trt = __ip_route_output_key(net, &fl4);\n\tif (!IS_ERR(rt)) {\n\t\t__ip_rt_update_pmtu(rt, &fl4, mtu);\n\t\tip_rt_put(rt);\n\t}\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":469177,"func":"void xfrm_flowi_addr_get(const struct flowi *fl,\n\t\t\t xfrm_address_t *saddr, xfrm_address_t *daddr,\n\t\t\t unsigned short family)\n{\n\tswitch(family) {\n\tcase AF_INET:\n\t\tmemcpy(&saddr->a4, &fl->u.ip4.saddr, sizeof(saddr->a4));\n\t\tmemcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4));\n\t\tbreak;\n\tcase AF_INET6:\n\t\tsaddr->in6 = fl->u.ip6.saddr;\n\t\tdaddr->in6 = fl->u.ip6.daddr;\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":248570,"func":"static bool AllDescendantsAreComplete(Frame* frame) {\n  if (!frame)\n    return true;\n  for (Frame* child = frame->Tree().FirstChild(); child;\n       child = child->Tree().TraverseNext(frame)) {\n    if (child->IsLoading())\n      return false;\n  }\n  return true;\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":376777,"func":"HInstruction* HGraphBuilder::PreProcessCall(Instruction* call) {\n  int count = call->argument_count();\n  ZoneList<HValue*> arguments(count, zone());\n  for (int i = 0; i < count; ++i) {\n    arguments.Add(Pop(), zone());\n  }\n\n  while (!arguments.is_empty()) {\n    AddInstruction(new(zone()) HPushArgument(arguments.RemoveLast()));\n  }\n  return call;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":53317,"func":"static size_t ssl_rsa_key_len( void *ctx )\n{\n    return ( (rsa_context *) ctx )->len;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":415933,"func":"gs_deviceinitialmatrix(gx_device * dev, gs_matrix * pmat)\n{\n    fill_dev_proc(dev, get_initial_matrix, gx_default_get_initial_matrix);\n    (*dev_proc(dev, get_initial_matrix)) (dev, pmat);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":501873,"func":"static bool replmd_recyclebin_enabled(struct ldb_module *module)\n{\n\tbool enabled = false;\n\tstruct replmd_private *replmd_private =\n\t\ttalloc_get_type_abort(ldb_module_get_private(module),\n\t\t\t\t      struct replmd_private);\n\n\t\/*\n\t * only lookup the recycle-bin state once per replication, then cache\n\t * the result. This can save us 1000s of DB searches\n\t *\/\n\tif (!replmd_private->recyclebin_state_known) {\n\t\tint ret = dsdb_recyclebin_enabled(module, &enabled);\n\t\tif (ret != LDB_SUCCESS) {\n\t\t\treturn false;\n\t\t}\n\n\t\treplmd_private->recyclebin_enabled = enabled;\n\t\treplmd_private->recyclebin_state_known = true;\n\t}\n\n\treturn replmd_private->recyclebin_enabled;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":118385,"func":"rend_service_poison_new_single_onion_dir(const rend_service_t *s,\n                                         const or_options_t* options)\n{\n  \/* Passing a NULL service is a bug *\/\n  if (BUG(!s)) {\n    return -1;\n  }\n\n  \/* We must only poison directories if we're in Single Onion mode *\/\n  tor_assert(rend_service_non_anonymous_mode_enabled(options));\n\n  \/* Ephemeral services aren't allowed in non-anonymous mode *\/\n  if (BUG(rend_service_is_ephemeral(s))) {\n    return -1;\n  }\n\n  \/* Service is expected to have a directory *\/\n  if (BUG(!s->directory)) {\n    return -1;\n  }\n\n  if (!rend_service_private_key_exists(s)) {\n    if (poison_new_single_onion_hidden_service_dir_impl(s, options)\n        < 0) {\n      return -1;\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":250237,"func":"static int update_stream_output_window(h2o_http2_stream_t *stream, ssize_t delta)\n{\n    ssize_t cur = h2o_http2_window_get_window(&stream->output_window);\n    if (h2o_http2_window_update(&stream->output_window, delta) != 0)\n        return -1;\n    if (cur <= 0 && h2o_http2_window_get_window(&stream->output_window) > 0 && h2o_http2_stream_has_pending_data(stream)) {\n        assert(!h2o_linklist_is_linked(&stream->_refs.link));\n        h2o_http2_scheduler_activate(&stream->_refs.scheduler);\n    }\n    return 0;\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":361890,"func":"bool Server::unregisterUserDB(int id) {\n\tif (id <= 0)\n\t\treturn false;\n\n\tQMap<int, QString> info = getRegistration(id);\n\n\tif (info.isEmpty())\n\t\treturn false;\n\n\tqhUserIDCache.remove(info.value(ServerDB::User_Name));\n\tqhUserNameCache.remove(id);\n\n\tint res = -2;\n\temit unregisterUserSig(res, id);\n\tif (res == 0) {\n\t\treturn false;\n\t}\n\n\tTransactionHolder th;\n\n\tQSqlQuery &query = *th.qsqQuery;\n\tSQLPREP(\"DELETE FROM `%1users` WHERE `server_id` = ? AND `user_id` = ?\");\n\tquery.addBindValue(iServerNum);\n\tquery.addBindValue(id);\n\tSQLEXEC();\n\n\tSQLPREP(\"DELETE FROM `%1user_info` WHERE `server_id` = ? AND `user_id` = ?\");\n\tquery.addBindValue(iServerNum);\n\tquery.addBindValue(id);\n\tSQLEXEC();\n\n\treturn true;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":253996,"func":"choose_kex(struct kex *k, char *client, char *server)\n{\n\tconst struct kexalg *kexalg;\n\n\tk->name = match_list(client, server, NULL);\n\n\tdebug(\"kex: algorithm: %s\", k->name ? k->name : \"(no match)\");\n\tif (k->name == NULL)\n\t\treturn SSH_ERR_NO_KEX_ALG_MATCH;\n\tif ((kexalg = kex_alg_by_name(k->name)) == NULL)\n\t\treturn SSH_ERR_INTERNAL_ERROR;\n\tk->kex_type = kexalg->type;\n\tk->hash_alg = kexalg->hash_alg;\n\tk->ec_nid = kexalg->ec_nid;\n\treturn 0;\n}\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":408326,"func":"string_rfind(PyStringObject *self, PyObject *args)\n{\n    Py_ssize_t result = string_find_internal(self, args, -1);\n    if (result == -2)\n        return NULL;\n    return PyInt_FromSsize_t(result);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":467806,"func":"\nstatic int io_poll_double_wake(struct wait_queue_entry *wait, unsigned mode,\n\t\t\t       int sync, void *key)\n{\n\tstruct io_kiocb *req = wait->private;\n\tstruct io_poll_iocb *poll = io_poll_get_single(req);\n\t__poll_t mask = key_to_poll(key);\n\n\t\/* for instances that support it check for an event match first: *\/\n\tif (mask && !(mask & poll->events))\n\t\treturn 0;\n\tif (!(poll->events & EPOLLONESHOT))\n\t\treturn poll->wait.func(&poll->wait, mode, sync, key);\n\n\tlist_del_init(&wait->entry);\n\n\tif (poll && poll->head) {\n\t\tbool done;\n\n\t\tspin_lock(&poll->head->lock);\n\t\tdone = list_empty(&poll->wait.entry);\n\t\tif (!done)\n\t\t\tlist_del_init(&poll->wait.entry);\n\t\t\/* make sure double remove sees this as being gone *\/\n\t\twait->private = NULL;\n\t\tspin_unlock(&poll->head->lock);\n\t\tif (!done) {\n\t\t\t\/* use wait func handler, so it matches the rq type *\/\n\t\t\tpoll->wait.func(&poll->wait, mode, sync, key);\n\t\t}\n\t}\n\treq_ref_put(req);\n\treturn 1;","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":383349,"func":"checksum( byte *p, unsigned n )\n{\n    u16 a;\n\n    for(a=0; n; n-- )\n\ta += *p++;\n    return a;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":67316,"func":"SWFInput_getSInt16(SWFInput input)\n{\n\tint num = SWFInput_getChar(input);\n\tnum += SWFInput_getChar(input) * 256;\n\treturn num;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":397172,"func":"tta_type_find (GstTypeFind * tf, gpointer unused)\n{\n  const guint8 *data = gst_type_find_peek (tf, 0, 3);\n\n  if (data) {\n    if (memcmp (data, \"TTA\", 3) == 0) {\n      gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, TTA_CAPS);\n      return;\n    }\n  }\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":98318,"func":"create_unpeer_node(\n\taddress_node *addr\n\t)\n{\n\tunpeer_node *\tmy_node;\n\tu_int\t\tu;\n\tchar *\t\tpch;\n\n\tmy_node = emalloc_zero(sizeof(*my_node));\n\n\t\/*\n\t * From the parser's perspective an association ID fits into\n\t * its generic T_String definition of a name\/address \"address\".\n\t * We treat all valid 16-bit numbers as association IDs.\n\t *\/\n\tpch = addr->address;\n\twhile (*pch && isdigit(*pch))\n\t\tpch++;\n\n\tif (!*pch \n\t    && 1 == sscanf(addr->address, \"%u\", &u)\n\t    && u <= ASSOCID_MAX) {\n\t\tmy_node->assocID = (associd_t)u;\n\t\tdestroy_address_node(addr);\n\t\tmy_node->addr = NULL;\n\t} else {\n\t\tmy_node->assocID = 0;\n\t\tmy_node->addr = addr;\n\t}\n\n\treturn my_node;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":258524,"func":"static void exsltObjectTypeFunction ( xmlXPathParserContextPtr ctxt , int nargs ) {\n xmlXPathObjectPtr obj , ret ;\n if ( nargs != 1 ) {\n xmlXPathSetArityError ( ctxt ) ;\n return ;\n }\n obj = valuePop ( ctxt ) ;\n switch ( obj -> type ) {\n case XPATH_STRING : ret = xmlXPathNewCString ( \"string\" ) ;\n break ;\n case XPATH_NUMBER : ret = xmlXPathNewCString ( \"number\" ) ;\n break ;\n case XPATH_BOOLEAN : ret = xmlXPathNewCString ( \"boolean\" ) ;\n break ;\n case XPATH_NODESET : ret = xmlXPathNewCString ( \"node-set\" ) ;\n break ;\n case XPATH_XSLT_TREE : ret = xmlXPathNewCString ( \"RTF\" ) ;\n break ;\n case XPATH_USERS : ret = xmlXPathNewCString ( \"external\" ) ;\n break ;\n default : xsltGenericError ( xsltGenericErrorContext , \"object-type() invalid arg\\n\" ) ;\n ctxt -> error = XPATH_INVALID_TYPE ;\n xmlXPathFreeObject ( obj ) ;\n return ;\n }\n xmlXPathFreeObject ( obj ) ;\n valuePush ( ctxt , ret ) ;\n }","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":141981,"func":"void NumberFormatTest::TestFormatCurrencyPlural() {\n    UErrorCode status = U_ZERO_ERROR;\n    Locale locale = Locale::createCanonical(\"en_US\");\n    NumberFormat *fmt = NumberFormat::createInstance(locale, UNUM_CURRENCY_PLURAL, status);\n    if (U_FAILURE(status)) {\n        dataerrln(\"Error creating NumberFormat - %s\", u_errorName(status));\n        return;\n    }\n   UnicodeString formattedNum;\n   fmt->format(11234.567, formattedNum, NULL, status);\n   assertEquals(\"\", \"11,234.57 US dollars\", formattedNum);\n   delete fmt;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":168257,"func":"smp_fetch_url(const struct arg *args, struct sample *smp, const char *kw, void *private)\n{\n\tstruct http_txn *txn;\n\n\tCHECK_HTTP_MESSAGE_FIRST();\n\n\ttxn = smp->strm->txn;\n\tsmp->data.type = SMP_T_STR;\n\tsmp->data.u.str.len = txn->req.sl.rq.u_l;\n\tsmp->data.u.str.str = txn->req.chn->buf->p + txn->req.sl.rq.u;\n\tsmp->flags = SMP_F_VOL_1ST | SMP_F_CONST;\n\treturn 1;\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":215145,"func":"GLvoid StubGLDrawElements(GLenum mode, GLsizei count, GLenum type,\n                          const void* indices) {\n  glDrawElements(mode, count, type, indices);\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":138595,"func":"void *UntrustedCacheMalloc::Malloc(size_t size) {\n  \/\/ Don't access UnturstedCacheMalloc if not running on normal heap, otherwise\n  \/\/ it will cause error when UntrustedCacheMalloc tries to free the memory on\n  \/\/ the normal heap.\n  if (is_destroyed_ || (size > kPoolEntrySize) || GetSwitchedHeapNext()) {\n    return primitives::TrustedPrimitives::UntrustedLocalAlloc(size);\n  }\n  return GetBuffer();\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":159976,"func":"string_heap_init (MonoDynamicStream *sh)\n{\n\tsh->index = 0;\n\tsh->alloc_size = 4096;\n\tsh->data = g_malloc (4096);\n\tsh->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);\n\tstring_heap_insert (sh, \"\");\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":201635,"func":"BrowserLauncherItemController::~BrowserLauncherItemController() {\n  tab_model_->RemoveObserver(this);\n  window_->RemoveObserver(this);\n  if (launcher_id() > 0)\n    launcher_controller()->CloseLauncherItem(launcher_id());\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":37535,"func":"  BasicStringRef(\n\t  const std::experimental::basic_string_view<Char, std::char_traits<Char>> &s)\n\t  : data_(s.data()), size_(s.size()) {}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":141189,"func":"PJ_DEF(pj_xml_attr*) pj_xml_find_attr( const pj_xml_node *node, \n\t\t\t\t       const pj_str_t *name,\n\t\t\t\t       const pj_str_t *value)\n{\n    const pj_xml_attr *attr = node->attr_head.next;\n    while (attr != (void*)&node->attr_head) {\n\tif (pj_stricmp(&attr->name, name)==0) {\n\t    if (value) {\n\t\tif (pj_stricmp(&attr->value, value)==0)\n\t\t    return (pj_xml_attr*)attr;\n\t    } else {\n\t\treturn (pj_xml_attr*)attr;\n\t    }\n\t}\n\tattr = attr->next;\n    }\n    return NULL;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":140767,"func":"set_last_insert(int c)\n{\n    char_u\t*s;\n\n    vim_free(last_insert);\n    last_insert = alloc(MB_MAXBYTES * 3 + 5);\n    if (last_insert != NULL)\n    {\n\ts = last_insert;\n\t\/\/ Use the CTRL-V only when entering a special char\n\tif (c < ' ' || c == DEL)\n\t    *s++ = Ctrl_V;\n\ts = add_char2buf(c, s);\n\t*s++ = ESC;\n\t*s++ = NUL;\n\tlast_insert_skip = 0;\n    }\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":70218,"func":"static void xmlrpc_append_char_encode(mowgli_string_t *s, const char *s1)\n{\n\tlong unsigned int i;\n\tunsigned char c;\n\tchar buf2[15];\n\n\tif ((!(s1) || (*(s1) == '\\0')))\n\t{\n\t\treturn;\n\t}\n\n\tfor (i = 0; s1[i] != '\\0'; i++)\n\t{\n\t\tc = s1[i];\n\t\tif (c > 127)\n\t\t{\n\t\t\tsnprintf(buf2, sizeof buf2, \"&#%d;\", c);\n\t\t\ts->append(s, buf2, strlen(buf2));\n\t\t}\n\t\telse if (c == '&')\n\t\t{\n\t\t\ts->append(s, \"&\", 5);\n\t\t}\n\t\telse if (c == '<')\n\t\t{\n\t\t\ts->append(s, \"<\", 4);\n\t\t}\n\t\telse if (c == '>')\n\t\t{\n\t\t\ts->append(s, \">\", 4);\n\t\t}\n\t\telse if (c == '\"')\n\t\t{\n\t\t\ts->append(s, \""\", 6);\n\t\t}\n\t\telse\n\t\t{\n\t\t\ts->append_char(s, c);\n\t\t}\n\t}\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":30518,"func":"static tmsize_t _tiffWriteProc ( thandle_t fd , void * buf , tmsize_t size ) {\n uint8 * ma ;\n uint64 mb ;\n DWORD n ;\n DWORD o ;\n tmsize_t p ;\n ma = ( uint8 * ) buf ;\n mb = size ;\n p = 0 ;\n while ( mb > 0 ) {\n n = 0x80000000UL ;\n if ( ( uint64 ) n > mb ) n = ( DWORD ) mb ;\n if ( ! WriteFile ( fd , ( LPVOID ) ma , n , & o , NULL ) ) return ( 0 ) ;\n ma += o ;\n mb -= o ;\n p += o ;\n if ( o != n ) break ;\n }\n return ( p ) ;\n }","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":471754,"func":"void quicklistInsertAfter(quicklist *quicklist, quicklistEntry *entry,\n                          void *value, const size_t sz) {\n    _quicklistInsert(quicklist, entry, value, sz, 1);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":148419,"func":"bool HHVM_FUNCTION(imagejpeg, const Resource& image,\n    const String& filename \/* = null_string *\/, int64_t quality \/* = -1 *\/) {\n  return _php_image_output_ctx(image, filename, quality, -1,\n                               PHP_GDIMG_TYPE_JPG, \"JPEG\",\n                               (void (*)())gdImageJpegCtx);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":411821,"func":"zzip_mem_entry_find_extra_block(ZZIP_MEM_ENTRY * entry, short datatype, zzip_size_t blocksize)\n{\n    int i = 2;\n    while (1)\n    {\n        char* ext = (char*)( entry->zz_ext[i] );\n        char* ext_end = ext + entry->zz_extlen[i];\n        if (ext)\n        {\n\t    \/*\n\t     * Make sure that\n\t     * 1) the extra block header\n\t     * AND\n\t     * 2) the block we're looking for\n\t     * fit into the extra block!\n\t     *\/\n            while (ext + zzip_extra_block_headerlength + blocksize <= ext_end)\n            {\n                if (datatype == zzip_extra_block_get_datatype(ext))\n                {\n                    if (blocksize <= zzip_extra_block_get_datasize(ext) + zzip_extra_block_headerlength)\n                    {\n                        return ((ZZIP_EXTRA_BLOCK*) ext);\n                    }\n                }\n                \/* skip to start of next extra_block *\/\n                ___ zzip_size_t datasize = zzip_extra_block_get_datasize(ext);\n                ext += zzip_extra_block_headerlength;\n                ext += datasize;\n                ____;\n            }\n        }\n        if (! i)\n            return 0;\n        i--;\n    }\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":115344,"func":"  TestUtilOptions& setExpectNoCert() {\n    expect_no_cert_ = true;\n    return *this;\n  }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":130825,"func":"removable(char_u *name)\n{\n    char_u  *p;\n    char_u  part[51];\n    int\t    retval = FALSE;\n    size_t  n;\n\n    name = home_replace_save(NULL, name);\n    if (name != NULL)\n    {\n\tfor (p = p_viminfo; *p; )\n\t{\n\t    copy_option_part(&p, part, 51, \", \");\n\t    if (part[0] == 'r')\n\t    {\n\t\tn = STRLEN(part + 1);\n\t\tif (MB_STRNICMP(part + 1, name, n) == 0)\n\t\t{\n\t\t    retval = TRUE;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n\tvim_free(name);\n    }\n    return retval;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":475894,"func":"void nft_data_release(const struct nft_data *data, enum nft_data_types type)\n{\n\tif (type < NFT_DATA_VERDICT)\n\t\treturn;\n\tswitch (type) {\n\tcase NFT_DATA_VERDICT:\n\t\treturn nft_verdict_uninit(data);\n\tdefault:\n\t\tWARN_ON(1);\n\t}\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":210592,"func":"void HostCache::OnNetworkChange() {\n  ++network_changes_;\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":165703,"func":"void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase* webkitWebViewBase, const WKFullScreenClientGtk* wkClient)\n{\n    webkitWebViewBase->priv->fullScreenClient.initialize(wkClient);\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":237600,"func":"static void virtio_net_instance_init(Object *obj)\n{\n    VirtIONet *n = VIRTIO_NET(obj);\n\n    \/*\n     * The default config_size is sizeof(struct virtio_net_config).\n     * Can be overriden with virtio_net_set_config_size.\n     *\/\n    n->config_size = sizeof(struct virtio_net_config);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":208196,"func":"void IPCThreadState::blockUntilThreadAvailable()\n{\n    pthread_mutex_lock(&mProcess->mThreadCountLock);\n while (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads) {\n        ALOGW(\"Waiting for thread to be free. mExecutingThreadsCount=%lu mMaxThreads=%lu\\n\",\n static_cast<unsigned long>(mProcess->mExecutingThreadsCount),\n static_cast<unsigned long>(mProcess->mMaxThreads));\n        pthread_cond_wait(&mProcess->mThreadCountDecrement, &mProcess->mThreadCountLock);\n }\n    pthread_mutex_unlock(&mProcess->mThreadCountLock);\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":302802,"func":"static inline void paravirt_release_pte(unsigned long pfn)\n{\n\tPVOP_VCALL1(mmu.release_pte, pfn);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":210594,"func":"void Element::unregisterNamedFlowContentNode()\n{\n    if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document()->renderView())\n        document()->renderView()->flowThreadController()->unregisterNamedFlowContentNode(this);\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":6308,"func":"ConnectClientToUnixSock(const char *sockFile)\n{\n#ifdef WIN32\n  rfbClientErr(\"Windows doesn't support UNIX sockets\\n\");\n  return -1;\n#else\n  int sock;\n  struct sockaddr_un addr;\n  addr.sun_family = AF_UNIX;\n  strcpy(addr.sun_path, sockFile);\n\n  sock = socket(AF_UNIX, SOCK_STREAM, 0);\n  if (sock < 0) {\n    rfbClientErr(\"ConnectToUnixSock: socket (%s)\\n\",strerror(errno));\n    return -1;\n  }\n\n  if (connect(sock, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path)) < 0) {\n    rfbClientErr(\"ConnectToUnixSock: connect\\n\");\n    close(sock);\n    return -1;\n  }\n\n  return sock;\n#endif\n}","target":1,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":200083,"func":"static void addBitsToStream(size_t* bitpointer, ucvector* bitstream, unsigned value, size_t nbits)\n{\n  size_t i;\n  for(i = 0; i < nbits; i++) addBitToStream(bitpointer, bitstream, (unsigned char)((value >> i) & 1));\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":90914,"func":"void VariableUnserializer::addSleepingObject(const Object& o) {\n  m_sleepingObjects.emplace_back(o);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":231783,"func":"SPL_METHOD(FilesystemIterator, __construct)\n{\n\tspl_filesystem_object_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, DIT_CTOR_FLAGS | SPL_FILE_DIR_SKIPDOTS);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":469953,"func":"pa2la(UINT8 *out, const UINT8 *in, int xsize, const UINT8 *palette) {\n    int x;\n    \/* FIXME: precalculate greyscale palette? *\/\n    for (x = 0; x < xsize; x++, in += 4, out += 4) {\n        out[0] = out[1] = out[2] = L(&palette[in[0] * 4]) \/ 1000;\n        out[3] = in[3];\n    }\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":104483,"func":"sector_t bmap(struct inode *inode, sector_t block)\n{\n\tsector_t res = 0;\n\tif (inode->i_mapping->a_ops->bmap)\n\t\tres = inode->i_mapping->a_ops->bmap(inode->i_mapping, block);\n\treturn res;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":105325,"func":"void megaraid_sas_kill_hba(struct megasas_instance *instance)\n{\n\t\/* Set critical error to block I\/O & ioctls in case caller didn't *\/\n\tatomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);\n\t\/* Wait 1 second to ensure IO or ioctls in build have posted *\/\n\tmsleep(1000);\n\tif ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||\n\t\t(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||\n\t\t(instance->adapter_type != MFI_SERIES)) {\n\t\tif (!instance->requestorId) {\n\t\t\twritel(MFI_STOP_ADP, &instance->reg_set->doorbell);\n\t\t\t\/* Flush *\/\n\t\t\treadl(&instance->reg_set->doorbell);\n\t\t}\n\t\tif (instance->requestorId && instance->peerIsPresent)\n\t\t\tmemset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);\n\t} else {\n\t\twritel(MFI_STOP_ADP,\n\t\t\t&instance->reg_set->inbound_doorbell);\n\t}\n\t\/* Complete outstanding ioctls when adapter is killed *\/\n\tmegasas_complete_outstanding_ioctls(instance);\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":468953,"func":"static int __kvm_write_guest_page(struct kvm *kvm,\n\t\t\t\t  struct kvm_memory_slot *memslot, gfn_t gfn,\n\t\t\t          const void *data, int offset, int len)\n{\n\tint r;\n\tunsigned long addr;\n\n\taddr = gfn_to_hva_memslot(memslot, gfn);\n\tif (kvm_is_error_hva(addr))\n\t\treturn -EFAULT;\n\tr = __copy_to_user((void __user *)addr + offset, data, len);\n\tif (r)\n\t\treturn -EFAULT;\n\tmark_page_dirty_in_slot(kvm, memslot, gfn);\n\treturn 0;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":50302,"func":"   would have been.  *\/\nstatic YYSIZE_T\nyytnamerr (char *yyres, const char *yystr)\n{\n  if (*yystr == '\"')\n    {\n      YYSIZE_T yyn = 0;\n      char const *yyp = yystr;\n\n      for (;;)\n        switch (*++yyp)\n          {\n          case '\\'':\n          case ',':\n            goto do_not_strip_quotes;\n\n          case '\\\\':\n            if (*++yyp != '\\\\')\n              goto do_not_strip_quotes;\n            \/* Fall through.  *\/\n          default:\n            if (yyres)\n              yyres[yyn] = *yyp;\n            yyn++;\n            break;\n\n          case '\"':\n            if (yyres)\n              yyres[yyn] = '\\0';\n            return yyn;\n          }\n    do_not_strip_quotes: ;\n    }\n\n  if (! yyres)\n    return yystrlen (yystr);\n","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":138286,"func":"  explicit BoostedTreesPredictOp(OpKernelConstruction* const context)\n      : OpKernel(context) {\n    OP_REQUIRES_OK(context, context->GetAttr(\"num_bucketized_features\",\n                                             &num_bucketized_features_));\n    OP_REQUIRES_OK(context,\n                   context->GetAttr(\"logits_dimension\", &logits_dimension_));\n  }","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":243351,"func":"void HostNPScriptObject::OnSignallingConnected(SignalStrategy* signal_strategy,\n                                               const std::string& full_jid) {\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":420249,"func":"initIoQ(void)\n{\n\tDEFiRet;\n\tCHKiConcCtrl(pthread_mutex_init(&io_q.mut, NULL));\n\tCHKiConcCtrl(pthread_cond_init(&io_q.wakeup_worker, NULL));\n\tSTAILQ_INIT(&io_q.q);\n\tio_q.sz = 0;\n\tio_q.ctrMaxSz = 0; \/* TODO: discuss this and fix potential concurrent read\/write issues *\/\n\tCHKiRet(statsobj.Construct(&io_q.stats));\n\tCHKiRet(statsobj.SetName(io_q.stats, (uchar*) \"io-work-q\"));\n\tCHKiRet(statsobj.SetOrigin(io_q.stats, (uchar*) \"imptcp\"));\n\tSTATSCOUNTER_INIT(io_q.ctrEnq, io_q.mutCtrEnq);\n\tCHKiRet(statsobj.AddCounter(io_q.stats, UCHAR_CONSTANT(\"enqueued\"),\n\t\t\t\t\t\t\t\tctrType_IntCtr, CTR_FLAG_RESETTABLE, &io_q.ctrEnq));\n\tCHKiRet(statsobj.AddCounter(io_q.stats, UCHAR_CONSTANT(\"maxqsize\"),\n\t\t\t\t\t\t\t\tctrType_Int, CTR_FLAG_NONE, &io_q.ctrMaxSz));\n\tCHKiRet(statsobj.ConstructFinalize(io_q.stats));\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":317222,"func":"void RenderWidgetHostImpl::StartInputEventAckTimeout(TimeDelta delay) {\n  if (!input_event_ack_timeout_)\n    return;\n  input_event_ack_timeout_->Start(delay);\n  input_event_ack_start_time_ = clock_->NowTicks();\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":112336,"func":"spell_valid_case(\n    int\t    wordflags,\t    \/\/ flags for the checked word.\n    int\t    treeflags)\t    \/\/ flags for the word in the spell tree\n{\n    return ((wordflags == WF_ALLCAP && (treeflags & WF_FIXCAP) == 0)\n\t    || ((treeflags & (WF_ALLCAP | WF_KEEPCAP)) == 0\n\t\t&& ((treeflags & WF_ONECAP) == 0\n\t\t\t\t\t   || (wordflags & WF_ONECAP) != 0)));\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":72245,"func":"cdf_tole2(uint16_t sv)\n{\n\treturn CDF_TOLE2(sv);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":40046,"func":"static void cqspi_config_baudrate_div(struct cqspi_st *cqspi)\n{\n\tconst unsigned int ref_clk_hz = cqspi->master_ref_clk_hz;\n\tvoid __iomem *reg_base = cqspi->iobase;\n\tu32 reg, div;\n\n\t\/* Recalculate the baudrate divisor based on QSPI specification. *\/\n\tdiv = DIV_ROUND_UP(ref_clk_hz, 2 * cqspi->sclk) - 1;\n\n\treg = readl(reg_base + CQSPI_REG_CONFIG);\n\treg &= ~(CQSPI_REG_CONFIG_BAUD_MASK << CQSPI_REG_CONFIG_BAUD_LSB);\n\treg |= (div & CQSPI_REG_CONFIG_BAUD_MASK) << CQSPI_REG_CONFIG_BAUD_LSB;\n\twritel(reg, reg_base + CQSPI_REG_CONFIG);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":436089,"func":"mbc_case_fold(OnigCaseFoldType flag,\n\t      const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower)\n{\n  const UChar* p = *pp;\n\n  if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    *lower++ = 's';\n    *lower   = 's';\n    (*pp)++;\n    return 2;\n  }\n\n  *lower = ENC_ISO_8859_15_TO_LOWER_CASE(*p);\n  (*pp)++;\n  return 1; \/* return byte length of converted char to lower *\/\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":176589,"func":"void AutoFillManager::OnInfoBarClosed(bool should_save) {\n  if (should_save)\n    personal_data_->SaveImportedCreditCard();\n  UploadFormData();\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":455389,"func":"TEST_F(QueryPlannerTest, SparseIndexCannotSupportEqualsNull) {\n    addIndex(BSON(\"i\" << 1),\n             false,  \/\/ multikey\n             true    \/\/ sparse\n    );\n\n    runQuery(fromjson(\"{i: {$eq: null}}\"));\n    assertHasOnlyCollscan();\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":307883,"func":"void RenderFrameImpl::FocusedNodeChanged(const WebNode& node) {\n  FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FocusedNodeChanged(node));\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":272262,"func":"static void task_ctx_sched_out(struct perf_cpu_context *cpuctx,\n\t\t\t       struct perf_event_context *ctx,\n\t\t\t       enum event_type_t event_type)\n{\n\tif (!cpuctx->task_ctx)\n\t\treturn;\n\n\tif (WARN_ON_ONCE(ctx != cpuctx->task_ctx))\n\t\treturn;\n\n\tctx_sched_out(ctx, cpuctx, event_type);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":125552,"func":"static int __net_init tcpv6_net_init(struct net *net)\n{\n\treturn inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6,\n\t\t\t\t    SOCK_RAW, IPPROTO_TCP, net);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":205231,"func":"  void SetIdealBoundsFromPositions(const std::vector<int>& positions) {\n    if (static_cast<size_t>(GetTabCount()) != positions.size())\n      return;\n\n    for (int i = 0; i < GetTabCount(); ++i) {\n      gfx::Rect bounds(ideal_bounds(i));\n      bounds.set_x(positions[i]);\n      tab_strip_->tabs_.set_ideal_bounds(i, bounds);\n    }\n  }\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":459545,"func":"dissect_kafka_offsets_response_topic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,\n                                     kafka_api_version_t api_version)\n{\n    proto_item *ti;\n    proto_tree *subtree;\n\n    subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_kafka_topic, &ti, \"Topic\");\n\n    offset = dissect_kafka_string(subtree, hf_kafka_topic_name, tvb, pinfo, offset, 0, NULL, NULL);\n    offset = dissect_kafka_array(subtree, tvb, pinfo, offset, 0, api_version,\n                                 &dissect_kafka_offsets_response_partition, NULL);\n\n    proto_item_set_end(ti, tvb, offset);\n\n    return offset;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":75706,"func":"CString CAuthBase::GetRemoteIP() const {\n    if (m_pSock) return m_pSock->GetRemoteIP();\n    return \"\";\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":206353,"func":"void webViewEnterFullscreen(WebKitWebView* webView, Node* node)\n{\n    if (!node->hasTagName(HTMLNames::videoTag))\n        return;\n\n#if ENABLE(VIDEO)\n    HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node);\n    WebKitWebViewPrivate* priv = webView->priv;\n\n    if (priv->fullscreenVideoController)\n        priv->fullscreenVideoController->exitFullscreen();\n\n    priv->fullscreenVideoController = new FullscreenVideoController;\n    priv->fullscreenVideoController->setMediaElement(videoElement);\n    priv->fullscreenVideoController->enterFullscreen();\n#endif\n}\n","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":325041,"func":"static void xen_pci_passthrough_class_init(ObjectClass *klass, void *data)\n\n{\n\n    DeviceClass *dc = DEVICE_CLASS(klass);\n\n    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);\n\n\n\n    k->realize = xen_pt_realize;\n\n    k->exit = xen_pt_unregister_device;\n\n    k->config_read = xen_pt_pci_read_config;\n\n    k->config_write = xen_pt_pci_write_config;\n\n\n    set_bit(DEVICE_CATEGORY_MISC, dc->categories);\n\n    dc->desc = \"Assign an host PCI device with Xen\";\n\n    dc->props = xen_pci_passthrough_properties;\n\n};","target":1,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":95357,"func":"uint32_t millis(void)\n{\n    return (((uint32_t)TIM6->CNT) + (__90_ms * 90));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":360677,"func":"_g_key_file_save_to_gfile (GKeyFile *key_file,\n\t\t\t   GFile *file,\n\t\t\t   GError  **error)\n{\n\tchar *data;\n\tgsize len;\n\n\tdata = g_key_file_to_data (key_file, &len, error);\n\tif (data == NULL) {\n\t\treturn FALSE;\n\t}\n\t\t\n\tif (!g_file_replace_contents (file,\n\t\t\t\t      data, len,\n\t\t\t\t      NULL, FALSE,\n\t\t\t\t      G_FILE_CREATE_NONE,\n\t\t\t\t      NULL, NULL, error)) {\n\t\tg_free (data);\n\t\treturn FALSE;\n\t}\n\tg_free (data);\n\treturn TRUE;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":32879,"func":"void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,\n\t\t       u64 nodeid, u64 nlookup)\n{\n\tstruct fuse_iqueue *fiq = &fc->iq;\n\n\tforget->forget_one.nodeid = nodeid;\n\tforget->forget_one.nlookup = nlookup;\n\n\tspin_lock(&fiq->waitq.lock);\n\tif (fiq->connected) {\n\t\tfiq->forget_list_tail->next = forget;\n\t\tfiq->forget_list_tail = forget;\n\t\twake_up_locked(&fiq->waitq);\n\t\tkill_fasync(&fiq->fasync, SIGIO, POLL_IN);\n\t} else {\n\t\tkfree(forget);\n\t}\n\tspin_unlock(&fiq->waitq.lock);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":299111,"func":"validate_keywords(asdl_seq *keywords)\n{\n    Py_ssize_t i;\n    for (i = 0; i < asdl_seq_LEN(keywords); i++)\n        if (!validate_expr(((keyword_ty)asdl_seq_GET(keywords, i))->value, Load))\n            return 0;\n    return 1;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":190871,"func":"WebPluginDelegatePepper::~WebPluginDelegatePepper() {\n  DestroyInstance();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":92378,"func":"static struct snd_seq_client_port *get_client_port(struct snd_seq_addr *addr,\n\t\t\t\t\t\t   struct snd_seq_client **cp)\n{\n\tstruct snd_seq_client_port *p;\n\t*cp = snd_seq_client_use_ptr(addr->client);\n\tif (*cp) {\n\t\tp = snd_seq_port_use_ptr(*cp, addr->port);\n\t\tif (! p) {\n\t\t\tsnd_seq_client_unlock(*cp);\n\t\t\t*cp = NULL;\n\t\t}\n\t\treturn p;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":390208,"func":"Parameters& Security::use_parms()\n{\n    return parms_;\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":448659,"func":"tiff_set_cmyk_fields(gx_device_printer *pdev, TIFF *tif,\n                     short bits_per_sample,\n                     uint16 compression,\n                     long max_strip_size)\n{\n    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits_per_sample);\n    TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);\n    TIFFSetField(tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);\n    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);\n\n    tiff_set_compression(pdev, tif, compression, max_strip_size);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":407720,"func":"ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf)\n{\n\t\/* period is the number of seconds *\/\n\tif (ldns_rdf_size(rdf) != 4) {\n\t\treturn LDNS_STATUS_WIRE_RDATA_ERR;\n\t}\n\tldns_buffer_printf(output, \"%u\", ldns_read_uint32(ldns_rdf_data(rdf)));\n\treturn ldns_buffer_status(output);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":293160,"func":"static int qrtr_tun_send(struct qrtr_endpoint *ep, struct sk_buff *skb)\n{\n\tstruct qrtr_tun *tun = container_of(ep, struct qrtr_tun, ep);\n\n\tskb_queue_tail(&tun->queue, skb);\n\n\t\/* wake up any blocking processes, waiting for new data *\/\n\twake_up_interruptible(&tun->readq);\n\n\treturn 0;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":133430,"func":"void jbd2_journal_lock_updates(journal_t *journal)\n{\n\tjbd2_might_wait_for_commit(journal);\n\n\twrite_lock(&journal->j_state_lock);\n\t++journal->j_barrier_count;\n\n\t\/* Wait until there are no reserved handles *\/\n\tif (atomic_read(&journal->j_reserved_credits)) {\n\t\twrite_unlock(&journal->j_state_lock);\n\t\twait_event(journal->j_wait_reserved,\n\t\t\t   atomic_read(&journal->j_reserved_credits) == 0);\n\t\twrite_lock(&journal->j_state_lock);\n\t}\n\n\t\/* Wait until there are no running t_updates *\/\n\tjbd2_journal_wait_updates(journal);\n\n\twrite_unlock(&journal->j_state_lock);\n\n\t\/*\n\t * We have now established a barrier against other normal updates, but\n\t * we also need to barrier against other jbd2_journal_lock_updates() calls\n\t * to make sure that we serialise special journal-locked operations\n\t * too.\n\t *\/\n\tmutex_lock(&journal->j_barrier);\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":392585,"func":"gdAlphaOverlayColor( int src, int dst, int max )\n{\n\t\/* this function implements the algorithm\n\t * \n\t * for dst[rgb] < 0.5,\n\t *   c[rgb] = 2.src[rgb].dst[rgb]\n\t * and for dst[rgb] > 0.5,\n\t *   c[rgb] = -2.src[rgb].dst[rgb] + 2.dst[rgb] + 2.src[rgb] - 1\n\t *   \n\t *\/\n\n\tdst = dst << 1;\n\tif( dst > max ) {\n\t\t\/* in the \"light\" zone *\/\n\t\treturn dst + (src << 1) - (dst * src \/ max) - max;\n\t} else {\n\t\t\/* in the \"dark\" zone *\/\n\t\treturn dst * src \/ max;\n\t}\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":434840,"func":"filter_show_space(fz_context *ctx, pdf_filter_processor *p, float tadj)\n{\n\tfilter_gstate *gstate = p->gstate;\n\tpdf_font_desc *fontdesc = gstate->pending.text.font;\n\n\tif (fontdesc->wmode == 0)\n\t\tp->tos.tm = fz_pre_translate(p->tos.tm, tadj * gstate->pending.text.scale, 0);\n\telse\n\t\tp->tos.tm = fz_pre_translate(p->tos.tm, 0, tadj);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":367161,"func":"static int cap_inode_getxattr(struct dentry *dentry, const char *name)\n{\n\treturn 0;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":458554,"func":"zone_limit_update(struct conntrack *ct, int32_t zone, uint32_t limit)\n{\n    int err = 0;\n    ovs_mutex_lock(&ct->ct_lock);\n    struct zone_limit *zl = zone_limit_lookup(ct, zone);\n    if (zl) {\n        zl->czl.limit = limit;\n        VLOG_INFO(\"Changed zone limit of %u for zone %d\", limit, zone);\n    } else {\n        err = zone_limit_create(ct, zone, limit);\n        if (!err) {\n            VLOG_INFO(\"Created zone limit of %u for zone %d\", limit, zone);\n        } else {\n            VLOG_WARN(\"Request to create zone limit for invalid zone %d\",\n                      zone);\n        }\n    }\n    ovs_mutex_unlock(&ct->ct_lock);\n    return err;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":188717,"func":"ProcFreeGC(ClientPtr client)\n{\n    GC *pGC;\n    int rc;\n\n    REQUEST(xResourceReq);\n    REQUEST_SIZE_MATCH(xResourceReq);\n\n    rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess);\n    if (rc != Success)\n        return rc;\n\n    FreeResource(stuff->id, RT_NONE);\n    return Success;\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":237332,"func":"bool HTMLButtonElement::isInteractiveContent() const\n{\n     return true;\n }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":220630,"func":"  explicit InterceptAndCancelDidCommitProvisionalLoad(WebContents* web_contents)\n      : DidCommitProvisionalLoadInterceptor(web_contents) {}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":262821,"func":"static void yam_set_uart(struct net_device *dev)\n{\n\tstruct yam_port *yp = netdev_priv(dev);\n\tint divisor = 115200 \/ yp->baudrate;\n\n\toutb(0, IER(dev->base_addr));\n\toutb(LCR_DLAB | LCR_BIT8, LCR(dev->base_addr));\n\toutb(divisor, DLL(dev->base_addr));\n\toutb(0, DLM(dev->base_addr));\n\toutb(LCR_BIT8, LCR(dev->base_addr));\n\toutb(PTT_OFF, MCR(dev->base_addr));\n\toutb(0x00, FCR(dev->base_addr));\n\n\t\/* Flush pending irq *\/\n\n\tinb(RBR(dev->base_addr));\n\tinb(MSR(dev->base_addr));\n\n\t\/* Enable rx irq *\/\n\n\toutb(ENABLE_RTXINT, IER(dev->base_addr));\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":123175,"func":"static Jsi_RC freeFuncsTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {\n    Jsi_Func *func = (Jsi_Func *)ptr;\n    if (!func) return JSI_OK;\n    SIGASSERT(func,FUNC);\n    func->hPtr = NULL;\n    jsi_FuncFree(interp, func);\n    return JSI_OK;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":487632,"func":"void ElectronRenderFrameObserver::CreateIsolatedWorldContext() {\n  auto* frame = render_frame_->GetWebFrame();\n  blink::WebIsolatedWorldInfo info;\n  \/\/ This maps to the name shown in the context combo box in the Console tab\n  \/\/ of the dev tools.\n  info.human_readable_name =\n      blink::WebString::FromUTF8(\"Electron Isolated Context\");\n  \/\/ Setup document's origin policy in isolated world\n  info.security_origin = frame->GetDocument().GetSecurityOrigin();\n  blink::SetIsolatedWorldInfo(WorldIDs::ISOLATED_WORLD_ID, info);\n\n  \/\/ Create initial script context in isolated world\n  blink::WebScriptSource source(\"void 0\");\n  frame->ExecuteScriptInIsolatedWorld(\n      WorldIDs::ISOLATED_WORLD_ID, source,\n      blink::BackForwardCacheAware::kPossiblyDisallow);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":170211,"func":"on_error(void *user_data, Evas_Object *webview, void *event_info)\n{\n    Eina_Strbuf* buffer;\n    const Ewk_Error *error = (const Ewk_Error *)event_info;\n\n    \/* This is a cancellation, do not display the error page *\/\n    if (ewk_error_cancellation_get(error))\n        return;\n\n    buffer = eina_strbuf_new();\n    eina_strbuf_append_printf(buffer, \"<html><body><div style=\\\"color:#ff0000\\\">ERROR!<\/div><br><div>Code: %d<br>Description: %s<br>URL: %s<\/div><\/body<\/html>\",\n        ewk_error_code_get(error), ewk_error_description_get(error), ewk_error_url_get(error));\n\n    ewk_view_html_string_load(webview, eina_strbuf_string_get(buffer), 0, ewk_error_url_get(error));\n    eina_strbuf_free(buffer);\n}\n","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":489327,"func":"GF_Err dmax_box_dump(GF_Box *a, FILE * trace)\n{\n\tGF_DMAXBox *p;\n\tp = (GF_DMAXBox *)a;\n\tgf_isom_box_dump_start(a, \"MaxPacketDurationBox\", trace);\n\tgf_fprintf(trace, \"MaximumDuration=\\\"%d\\\">\\n\", p->maxDur);\n\tgf_isom_box_dump_done(\"MaxPacketDurationBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":168625,"func":"void FakeCentral::IsNotifying(const std::string& characteristic_id,\n                              const std::string& service_id,\n                              const std::string& peripheral_address,\n                              IsNotifyingCallback callback) {\n  FakeRemoteGattCharacteristic* fake_remote_gatt_characteristic =\n      GetFakeRemoteGattCharacteristic(peripheral_address, service_id,\n                                      characteristic_id);\n  if (!fake_remote_gatt_characteristic) {\n    std::move(callback).Run(false, false);\n  }\n\n  std::move(callback).Run(true, fake_remote_gatt_characteristic->IsNotifying());\n}\n","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":369326,"func":"static char *sanitize_path(const char *path)\n{\n\tchar *p;\n\n\tif (!path)\n\t\treturn NULL;\n\n\tp = canonicalize_path_restricted(path);\n\tif (!p)\n\t\terr(MOUNT_EX_USAGE, \"%s\", path);\n\n\treturn p;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":208135,"func":"void WebContentsImpl::RendererUnresponsive(\n    RenderWidgetHostImpl* render_widget_host,\n    base::RepeatingClosure hang_monitor_restarter) {\n  for (auto& observer : observers_)\n    observer.OnRendererUnresponsive(render_widget_host->GetProcess());\n\n  if (ShouldIgnoreUnresponsiveRenderer())\n    return;\n\n  if (!render_widget_host->renderer_initialized())\n    return;\n\n  if (delegate_)\n    delegate_->RendererUnresponsive(this, render_widget_host,\n                                    std::move(hang_monitor_restarter));\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":399645,"func":"static void mark_work_canceling(struct work_struct *work)\n{\n\tunsigned long pool_id = get_work_pool_id(work);\n\n\tpool_id <<= WORK_OFFQ_POOL_SHIFT;\n\tset_work_data(work, pool_id | WORK_OFFQ_CANCELING, WORK_STRUCT_PENDING);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":296640,"func":"BOOL security_encrypt(BYTE* data, int length, rdpRdp* rdp)\n{\n\tif (rdp->encrypt_use_count >= 4096)\n\t{\n\t\tsecurity_key_update(rdp->encrypt_key, rdp->encrypt_update_key, rdp->rc4_key_len);\n\t\tcrypto_rc4_free(rdp->rc4_encrypt_key);\n\t\trdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len);\n\t\trdp->encrypt_use_count = 0;\n\t}\n\tcrypto_rc4(rdp->rc4_encrypt_key, length, data, data);\n\trdp->encrypt_use_count++;\n\trdp->encrypt_checksum_use_count++;\n\treturn TRUE;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":264710,"func":"static void jas_icclut16_destroy(jas_iccattrval_t *attrval)\n{\n\tjas_icclut16_t *lut16 = &attrval->data.lut16;\n\tif (lut16->clut) {\n\t\tjas_free(lut16->clut);\n\t\tlut16->clut = 0;\n\t}\n\tif (lut16->intabs) {\n\t\tjas_free(lut16->intabs);\n\t\tlut16->intabs = 0;\n\t}\n\tif (lut16->intabsbuf) {\n\t\tjas_free(lut16->intabsbuf);\n\t\tlut16->intabsbuf = 0;\n\t}\n\tif (lut16->outtabs) {\n\t\tjas_free(lut16->outtabs);\n\t\tlut16->outtabs = 0;\n\t}\n\tif (lut16->outtabsbuf) {\n\t\tjas_free(lut16->outtabsbuf);\n\t\tlut16->outtabsbuf = 0;\n\t}\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":3768,"func":"bumpserialno(void)\n{\n    ++serialno;\n}","target":1,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":156026,"func":"cmp_func_intel (const void *elem1, const void *elem2)\n{\n\treturn cmp_func ((const unsigned char *) elem1,\n\t\t\t (const unsigned char *) elem2, EXIF_BYTE_ORDER_INTEL);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":517247,"func":"  double val_real() { return (double)val_int(); }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":216261,"func":"bool RenderViewImpl::IsEditableNode(const WebNode& node) const {\n  if (node.isNull())\n    return false;\n\n  if (node.isContentEditable())\n    return true;\n\n  if (node.isElementNode()) {\n    const WebElement& element = node.toConst<WebElement>();\n    if (element.isTextFormControlElement())\n      return true;\n\n    for (unsigned i = 0; i < element.attributeCount(); ++i) {\n      if (LowerCaseEqualsASCII(element.attributeLocalName(i), \"role\")) {\n        if (LowerCaseEqualsASCII(element.attributeValue(i), \"textbox\"))\n          return true;\n        break;\n      }\n    }\n  }\n\n  return false;\n}\n","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":230343,"func":"  virtual void DoSetUp() {\n    RenderViewImplTest::SetUp();\n  }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":50548,"func":"    inline void writeS8( S8  s) { writeU8((U8)s); }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":517156,"func":"  bool agg_arg_charsets_for_comparison(CHARSET_INFO **cs, Item **a, Item **b)\n  {\n    DTCollation tmp;\n    if (tmp.set((*a)->collation, (*b)->collation, MY_COLL_CMP_CONV) ||\n        tmp.derivation == DERIVATION_NONE)\n    {\n      my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),\n               (*a)->collation.collation->name,\n               (*a)->collation.derivation_name(),\n               (*b)->collation.collation->name,\n               (*b)->collation.derivation_name(),\n               func_name());\n      return true;\n    }\n    if (agg_item_set_converter(tmp, func_name(),\n                               a, 1, MY_COLL_CMP_CONV, 1) ||\n        agg_item_set_converter(tmp, func_name(),\n                               b, 1, MY_COLL_CMP_CONV, 1))\n      return true;\n    *cs= tmp.collation;\n    return false;\n  }","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":155462,"func":"inline void BroadcastAddFivefold(const ArithmeticParams& params,\n                                 const RuntimeShape& unswitched_input1_shape,\n                                 const float* unswitched_input1_data,\n                                 const RuntimeShape& unswitched_input2_shape,\n                                 const float* unswitched_input2_data,\n                                 const RuntimeShape& output_shape,\n                                 float* output_data) {\n  BroadcastAddDispatch(params, unswitched_input1_shape, unswitched_input1_data,\n                       unswitched_input2_shape, unswitched_input2_data,\n                       output_shape, output_data);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":362914,"func":"static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)\n{\n\t__skb_unlink(skb, &sk->sk_receive_queue);\n\t__kfree_skb(skb);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":289416,"func":"void raw6_icmp_error ( struct sk_buff * skb , int nexthdr , u8 type , u8 code , int inner_offset , __be32 info ) {\n struct sock * sk ;\n int hash ;\n struct in6_addr * saddr , * daddr ;\n struct net * net ;\n hash = nexthdr & ( RAW_HTABLE_SIZE - 1 ) ;\n read_lock ( & raw_v6_hashinfo . lock ) ;\n sk = sk_head ( & raw_v6_hashinfo . ht [ hash ] ) ;\n if ( sk != NULL ) {\n struct ipv6hdr * ip6h = ( struct ipv6hdr * ) skb -> data ;\n saddr = & ip6h -> saddr ;\n daddr = & ip6h -> daddr ;\n net = dev_net ( skb -> dev ) ;\n while ( ( sk = __raw_v6_lookup ( net , sk , nexthdr , saddr , daddr , IP6CB ( skb ) -> iif ) ) ) {\n rawv6_err ( sk , skb , NULL , type , code , inner_offset , info ) ;\n sk = sk_next ( sk ) ;\n }\n }\n read_unlock ( & raw_v6_hashinfo . lock ) ;\n }","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":512506,"func":"int setup_tests(void)\n{\n    app_data_index = RAND_DRBG_get_ex_new_index(0L, NULL, NULL, NULL, NULL);\n\n    ADD_ALL_TESTS(test_kats, OSSL_NELEM(drbg_test));\n    ADD_ALL_TESTS(test_error_checks, OSSL_NELEM(drbg_test));\n    ADD_TEST(test_rand_drbg_reseed);\n    ADD_TEST(test_rand_seed);\n    ADD_TEST(test_rand_add);\n#if defined(OPENSSL_THREADS)\n    ADD_TEST(test_multi_thread);\n#endif\n    return 1;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":162162,"func":"  explicit C_handle_write(AsyncConnectionRef c): conn(c) {}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":347468,"func":"static void sig_chatnet_read(IRC_CHATNET_REC *rec, CONFIG_NODE *node)\n{\n\tif (!IS_IRC_CHATNET(rec))\n\t\treturn;\n\n\trec->usermode = g_strdup(config_node_get_str(node, \"usermode\", NULL));\n\n\trec->max_cmds_at_once = config_node_get_int(node, \"cmdmax\", 0);\n\trec->cmd_queue_speed = config_node_get_int(node, \"cmdspeed\", 0);\n\trec->max_query_chans = config_node_get_int(node, \"max_query_chans\", 0);\n\n\trec->max_kicks = config_node_get_int(node, \"max_kicks\", 0);\n\trec->max_msgs = config_node_get_int(node, \"max_msgs\", 0);\n\trec->max_modes = config_node_get_int(node, \"max_modes\", 0);\n\trec->max_whois = config_node_get_int(node, \"max_whois\", 0);\n}","target":1,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":94889,"func":"static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp)\n{\n\t\/* Mark all delegations for reclaim *\/\n\tnfs_delegation_mark_reclaim(clp);\n\tnfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":123393,"func":"void address_space_destroy(AddressSpace *as)\n{\n    MemoryRegion *root = as->root;\n\n    \/* Flush out anything from MemoryListeners listening in on this *\/\n    memory_region_transaction_begin();\n    as->root = NULL;\n    memory_region_transaction_commit(root);\n    QTAILQ_REMOVE(&as->uc->address_spaces, as, address_spaces_link);\n\n    \/* At this point, as->dispatch and as->current_map are dummy\n     * entries that the guest should never use.  Wait for the old\n     * values to expire before freeing the data.\n     *\/\n    as->root = root;\n    flatview_unref(as->current_map);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":77601,"func":"static void xen_machine_power_off(void)\n{\n\tdo_kernel_power_off();\n\txen_reboot(SHUTDOWN_poweroff);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":230562,"func":"transit_hash_alloc (void *p)\n{\n  \/* Transit structure is already allocated.  *\/\n  return p;\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":195417,"func":"bool RenderWidgetHostViewAura::HasHitTestMask() const {\n  return false;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":318207,"func":"error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM(\n    uint32 immediate_data_size,\n    const gles2::DestroyStreamTextureCHROMIUM& c) {\n  GLuint client_id = c.texture;\n  TextureManager::TextureInfo* info =\n      texture_manager()->GetTextureInfo(client_id);\n  if (info && info->IsStreamTexture()) {\n    if (!stream_texture_manager_)\n      return error::kInvalidArguments;\n\n    stream_texture_manager_->DestroyStreamTexture(info->service_id());\n    info->SetStreamTexture(false);\n    texture_manager()->SetInfoTarget(info, 0);\n  } else {\n    SetGLError(GL_INVALID_VALUE,\n               \"glDestroyStreamTextureCHROMIUM\", \"bad texture id.\");\n  }\n\n  return error::kNoError;\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":200121,"func":"bool WebView::shouldInitializeTrackPointHack()\n{\n    static bool shouldCreateScrollbars;\n    static bool hasRunTrackPointCheck;\n\n    if (hasRunTrackPointCheck)\n        return shouldCreateScrollbars;\n\n    hasRunTrackPointCheck = true;\n    const wchar_t* trackPointKeys[] = { \n        L\"Software\\\\Lenovo\\\\TrackPoint\",\n        L\"Software\\\\Lenovo\\\\UltraNav\",\n        L\"Software\\\\Alps\\\\Apoint\\\\TrackPoint\",\n        L\"Software\\\\Synaptics\\\\SynTPEnh\\\\UltraNavUSB\",\n        L\"Software\\\\Synaptics\\\\SynTPEnh\\\\UltraNavPS2\"\n    };\n\n    for (size_t i = 0; i < WTF_ARRAY_LENGTH(trackPointKeys); ++i) {\n        HKEY trackPointKey;\n        int readKeyResult = ::RegOpenKeyExW(HKEY_CURRENT_USER, trackPointKeys[i], 0, KEY_READ, &trackPointKey);\n        ::RegCloseKey(trackPointKey);\n        if (readKeyResult == ERROR_SUCCESS) {\n            shouldCreateScrollbars = true;\n            return shouldCreateScrollbars;\n        }\n    }\n\n    return shouldCreateScrollbars;\n}\n","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":519120,"func":"void Field_num::make_send_field(Send_field *field)\n{\n  Field::make_send_field(field);\n  field->decimals= dec;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":435309,"func":"static int ws_echo(struct buf *inbuf, struct buf *outbuf,\n                   struct buf *logbuf __attribute__((unused)),\n                   void **rock __attribute__((unused)))\n{\n    buf_init_ro(outbuf, buf_base(inbuf), buf_len(inbuf));\n\n    return 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":323767,"func":"static void sd_set_status(SDState *sd)\n\n{\n\n    switch (sd->state) {\n\n    case sd_inactive_state:\n\n        sd->mode = sd_inactive;\n\n        break;\n\n\n\n    case sd_idle_state:\n\n    case sd_ready_state:\n\n    case sd_identification_state:\n\n        sd->mode = sd_card_identification_mode;\n\n        break;\n\n\n\n    case sd_standby_state:\n\n    case sd_transfer_state:\n\n    case sd_sendingdata_state:\n\n    case sd_receivingdata_state:\n\n    case sd_programming_state:\n\n    case sd_disconnect_state:\n\n        sd->mode = sd_data_transfer_mode;\n\n        break;\n\n    }\n\n\n\n    sd->card_status &= ~CURRENT_STATE;\n\n    sd->card_status |= sd->state << 9;\n\n}\n","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":358299,"func":"static void fixup_rmode_irq(struct vcpu_vmx *vmx)\n{\n\tvmx->rmode.irq.pending = 0;\n\tif (kvm_rip_read(&vmx->vcpu) + 1 != vmx->rmode.irq.rip)\n\t\treturn;\n\tkvm_rip_write(&vmx->vcpu, vmx->rmode.irq.rip);\n\tif (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) {\n\t\tvmx->idt_vectoring_info &= ~VECTORING_INFO_TYPE_MASK;\n\t\tvmx->idt_vectoring_info |= INTR_TYPE_EXT_INTR;\n\t\treturn;\n\t}\n\tvmx->idt_vectoring_info =\n\t\tVECTORING_INFO_VALID_MASK\n\t\t| INTR_TYPE_EXT_INTR\n\t\t| vmx->rmode.irq.vector;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":260930,"func":"static unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)\n{\n\tstruct desc_struct desc;\n\tunsigned long limit;\n\tshort sel;\n\n\tsel = get_segment_selector(regs, seg_reg_idx);\n\tif (sel < 0)\n\t\treturn 0;\n\n\tif (user_64bit_mode(regs) || v8086_mode(regs))\n\t\treturn -1L;\n\n\tif (!sel)\n\t\treturn 0;\n\n\tif (!get_desc(&desc, sel))\n\t\treturn 0;\n\n\t\/*\n\t * If the granularity bit is set, the limit is given in multiples\n\t * of 4096. This also means that the 12 least significant bits are\n\t * not tested when checking the segment limits. In practice,\n\t * this means that the segment ends in (limit << 12) + 0xfff.\n\t *\/\n\tlimit = get_desc_limit(&desc);\n\tif (desc.g)\n\t\tlimit = (limit << 12) + 0xfff;\n\n\treturn limit;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":242069,"func":"BrowserTabStripController::BrowserTabStripController(Browser* browser,\n                                                     TabStripModel* model)\n    : model_(model),\n      tabstrip_(NULL),\n      browser_(browser),\n      hover_tab_selector_(model) {\n  model_->AddObserver(this);\n\n  local_pref_registrar_.Init(g_browser_process->local_state());\n  local_pref_registrar_.Add(prefs::kTabStripLayoutType, this);\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":469356,"func":"__be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)\n{\n\t__be16 port;\n\tswitch(fl->flowi_proto) {\n\tcase IPPROTO_TCP:\n\tcase IPPROTO_UDP:\n\tcase IPPROTO_UDPLITE:\n\tcase IPPROTO_SCTP:\n\t\tport = uli->ports.dport;\n\t\tbreak;\n\tcase IPPROTO_ICMP:\n\tcase IPPROTO_ICMPV6:\n\t\tport = htons(uli->icmpt.code);\n\t\tbreak;\n\tcase IPPROTO_GRE:\n\t\tport = htons(ntohl(uli->gre_key) & 0xffff);\n\t\tbreak;\n\tdefault:\n\t\tport = 0;\t\/*XXX*\/\n\t}\n\treturn port;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":263849,"func":"wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se)\n{\n\ts64 gran, vdiff = curr->vruntime - se->vruntime;\n\n\tif (vdiff <= 0)\n\t\treturn -1;\n\n\tgran = wakeup_gran(se);\n\tif (vdiff > gran)\n\t\treturn 1;\n\n\treturn 0;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":26468,"func":"static int remaining_bits ( WMAProDecodeCtx * s , GetBitContext * gb ) {\n return s -> buf_bit_size - get_bits_count ( gb ) ;\n }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":28385,"func":"static void update_unicast_addr ( unicast_addr_t * req_addr , unicast_addr_t * ack_addr ) {\n if ( ack_addr -> addr . type != AT_NONE && ack_addr -> port != 0 ) {\n memcpy ( req_addr -> addr_buf , ack_addr -> addr_buf , sizeof ( req_addr -> addr_buf ) ) ;\n SET_ADDRESS ( & req_addr -> addr , ack_addr -> addr . type , ack_addr -> addr . len , req_addr -> addr_buf ) ;\n req_addr -> port = ack_addr -> port ;\n }\n }","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":398205,"func":"lib_eventloop_main_core(args)\n    VALUE args;\n{\n    struct evloop_params *params = (struct evloop_params *)args;\n\n    check_rootwidget_flag = params->check_root;\n\n    Tcl_CreateEventSource(rbtk_EventSetupProc, rbtk_EventCheckProc, (ClientData)args);\n\n    if (lib_eventloop_core(params->check_root,\n                           params->update_flag,\n                           params->check_var,\n                           params->interp)) {\n        return Qtrue;\n    } else {\n        return Qfalse;\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":174496,"func":"bool PaintController::CacheIsAllInvalid() const {\n  DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV2Enabled());\n  return current_paint_artifact_.IsEmpty() &&\n         current_cache_generation_.GetPaintInvalidationReason() !=\n             PaintInvalidationReason::kNone;\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":521334,"func":"my_bool mark_changed(int, const struct my_option *opt, char *)\n{\n  if (opt->app_type)\n  {\n    sys_var *var= (sys_var*) opt->app_type;\n    var->value_origin= sys_var::CONFIG;\n  }\n  return 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":36197,"func":"GF_Err edts_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":448316,"func":"SProcXkbGetNames(ClientPtr client)\n{\n    REQUEST(xkbGetNamesReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbGetNamesReq);\n    swaps(&stuff->deviceSpec);\n    swapl(&stuff->which);\n    return ProcXkbGetNames(client);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":236785,"func":"void Document::setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, DOMWrapperWorld* isolatedWorld)\n{\n    DOMWindow* domWindow = this->domWindow();\n    if (!domWindow)\n        return;\n    domWindow->setAttributeEventListener(eventType, listener, isolatedWorld);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":215925,"func":"Tab* TabStrip::FindTabForEvent(const gfx::Point& point) {\n  DCHECK(touch_layout_);\n  int active_tab_index = touch_layout_->active_index();\n  Tab* tab = FindTabForEventFrom(point, active_tab_index, -1);\n  return tab ? tab : FindTabForEventFrom(point, active_tab_index + 1, 1);\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":408251,"func":"static void __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)\n{\n\tint err;\n\n\tif (WARN_ON(!consumer_del(uprobe, uc)))\n\t\treturn;\n\n\terr = register_for_each_vma(uprobe, NULL);\n\t\/* TODO : cant unregister? schedule a worker thread *\/\n\tif (!uprobe->consumers && !err)\n\t\tdelete_uprobe(uprobe);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":389247,"func":"test_HaveKeyIncorrect(void)\n{\n\tconst keyid_t KEYNO = 2;\n\n\tTEST_ASSERT_FALSE(auth_havekey(KEYNO));\n\tTEST_ASSERT_FALSE(authhavekey(KEYNO));\n\n\treturn;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":53873,"func":"static void __iommu_free_atomic(struct device *dev, void *cpu_addr,\n\t\t\t\tdma_addr_t handle, size_t size)\n{\n\t__iommu_remove_mapping(dev, handle, size);\n\t__free_from_pool(cpu_addr, size);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":375818,"func":"static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,\n                                    void *opaque)\n{\n    const VMStateSubsection *sub = vmsd->subsections;\n\n    while (sub && sub->needed) {\n        if (sub->needed(opaque)) {\n            const VMStateDescription *vmsd = sub->vmsd;\n            uint8_t len;\n\n            qemu_put_byte(f, QEMU_VM_SUBSECTION);\n            len = strlen(vmsd->name);\n            qemu_put_byte(f, len);\n            qemu_put_buffer(f, (uint8_t *)vmsd->name, len);\n            qemu_put_be32(f, vmsd->version_id);\n            vmstate_save_state(f, vmsd, opaque);\n        }\n        sub++;\n    }\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":59376,"func":"static void nfs4_free_pages(struct page **pages, size_t size)\n{\n\tint i;\n\n\tif (!pages)\n\t\treturn;\n\n\tfor (i = 0; i < size; i++) {\n\t\tif (!pages[i])\n\t\t\tbreak;\n\t\t__free_page(pages[i]);\n\t}\n\tkfree(pages);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":490922,"func":"static void free_filters(filter_rule *ent)\n{\n\twhile (ent) {\n\t\tfilter_rule *next = ent->next;\n\t\tfree_filter(ent);\n\t\tent = next;\n\t}\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":119744,"func":"SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newname)\n{\n\treturn sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":243381,"func":"void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) {\n  DestroyTouchSelection();\n  switch (command_id) {\n    case IDC_PASTE_AND_GO:\n      model()->PasteAndGo(GetClipboardText());\n      return;\n    case IDS_SHOW_URL:\n      model()->Unelide(true \/* exit_query_in_omnibox *\/);\n      return;\n    case IDC_EDIT_SEARCH_ENGINES:\n      location_bar_view_->command_updater()->ExecuteCommand(command_id);\n      return;\n    case IDC_SEND_TAB_TO_SELF:\n      send_tab_to_self::RecordSendTabToSelfClickResult(\n          send_tab_to_self::kOmniboxMenu, SendTabToSelfClickResult::kClickItem);\n      send_tab_to_self::CreateNewEntry(location_bar_view_->GetWebContents());\n      return;\n\n    case IDS_APP_PASTE:\n      ExecuteTextEditCommand(ui::TextEditCommand::PASTE);\n      return;\n    default:\n      if (Textfield::IsCommandIdEnabled(command_id)) {\n        Textfield::ExecuteCommand(command_id, event_flags);\n        return;\n      }\n      OnBeforePossibleChange();\n      location_bar_view_->command_updater()->ExecuteCommand(command_id);\n      OnAfterPossibleChange(true);\n      return;\n  }\n}\n","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":75804,"func":"GF_Err gf_isom_remove_edits(GF_ISOFile *movie, u32 trackNumber)\n{\n\tGF_Err e;\n\tGF_TrackBox *trak;\n\ttrak = gf_isom_get_track_from_file(movie, trackNumber);\n\tif (!trak) return GF_BAD_PARAM;\n\n\te = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE);\n\tif (e) return e;\n\n\tif (!trak->editBox || !trak->editBox->editList) return GF_OK;\n\n\twhile (gf_list_count(trak->editBox->editList->entryList)) {\n\t\tGF_EdtsEntry *ent = (GF_EdtsEntry*)gf_list_get(trak->editBox->editList->entryList, 0);\n\t\tgf_free(ent);\n\t\te = gf_list_rem(trak->editBox->editList->entryList, 0);\n\t\tif (e) return e;\n\t}\n\t\/\/then delete the GF_EditBox...\n\tgf_isom_box_del_parent(&trak->child_boxes, (GF_Box *)trak->editBox);\n\ttrak->editBox = NULL;\n\treturn SetTrackDuration(trak);\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":32853,"func":"void Filter::setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) {\n  callbacks_ = &callbacks;\n  \/\/ As the decoder filter only pushes back via watermarks once data has reached\n  \/\/ it, it can latch the current buffer limit and does not need to update the\n  \/\/ limit if another filter increases it.\n  buffer_limit_ = callbacks_->decoderBufferLimit();\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":253898,"func":"std::string GetFileNameFromCD(const std::string& header,\n                              const std::string& referrer_charset) {\n  std::string decoded;\n  std::string param_value = GetHeaderParamValue(header, \"filename*\",\n                                                QuoteRule::KEEP_OUTER_QUOTES);\n  if (!param_value.empty()) {\n    if (param_value.find('\"') == std::string::npos) {\n      std::string charset;\n      std::string value;\n      if (DecodeCharset(param_value, &charset, &value)) {\n        if (!IsStringASCII(value))\n          return std::string();\n        std::string tmp = UnescapeURLComponent(\n            value,\n            UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);\n        if (base::ConvertToUtf8AndNormalize(tmp, charset, &decoded))\n          return decoded;\n      }\n    }\n  }\n  param_value = GetHeaderParamValue(header, \"filename\",\n                                    QuoteRule::REMOVE_OUTER_QUOTES);\n  if (param_value.empty()) {\n    param_value = GetHeaderParamValue(header, \"name\",\n                                      QuoteRule::REMOVE_OUTER_QUOTES);\n  }\n  if (param_value.empty())\n    return std::string();\n  if (DecodeParamValue(param_value, referrer_charset, &decoded))\n    return decoded;\n  return std::string();\n}\n","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":522075,"func":"Field *Type_handler_blob_common::make_conversion_table_field(TABLE *table,\n                                                            uint metadata,\n                                                            const Field *target)\n                                                            const\n{\n  uint pack_length= metadata & 0x00ff;\n  if (pack_length < 1 || pack_length > 4)\n    return NULL; \/\/ Broken binary log?\n  return new(table->in_use->mem_root)\n         Field_blob(NULL, (uchar *) \"\", 1, Field::NONE, TMPNAME,\n                    table->s, pack_length, target->charset());\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":279505,"func":"void FramebufferManager::CreateFramebuffer(\n    GLuint client_id, GLuint service_id) {\n  std::pair<FramebufferMap::iterator, bool> result =\n      framebuffers_.insert(\n          std::make_pair(\n              client_id,\n              scoped_refptr<Framebuffer>(\n                  new Framebuffer(this, service_id))));\n  DCHECK(result.second);\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":494486,"func":"CURLcode Curl_unencode_write(struct Curl_easy *data,\n                             struct contenc_writer *writer,\n                             const char *buf, size_t nbytes)\n{\n  (void) data;\n  (void) writer;\n  (void) buf;\n  (void) nbytes;\n  return CURLE_NOT_BUILT_IN;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":368904,"func":"string_strcasestr (const char *string, const char *search)\n{\n    int length_search;\n\n    length_search = utf8_strlen (search);\n\n    if (!string || !search || (length_search == 0))\n        return NULL;\n\n    while (string[0])\n    {\n        if (string_strncasecmp (string, search, length_search) == 0)\n            return (char *)string;\n\n        string = utf8_next_char (string);\n    }\n\n    return NULL;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":309681,"func":"const char* BrowserRootView::GetClassName() const {\n  return kViewClassName;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":76278,"func":"void __perf_event_task_sched_out(struct task_struct *task,\n\t\t\t\t struct task_struct *next)\n{\n\tint ctxn;\n\n\tif (__this_cpu_read(perf_sched_cb_usages))\n\t\tperf_pmu_sched_task(task, next, false);\n\n\tif (atomic_read(&nr_switch_events))\n\t\tperf_event_switch(task, next, false);\n\n\tfor_each_task_context_nr(ctxn)\n\t\tperf_event_context_sched_out(task, ctxn, next);\n\n\t\/*\n\t * if cgroup events exist on this CPU, then we need\n\t * to check if we have to switch out PMU state.\n\t * cgroup event are system-wide mode only\n\t *\/\n\tif (atomic_read(this_cpu_ptr(&perf_cgroup_events)))\n\t\tperf_cgroup_sched_out(task, next);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":354189,"func":"Type_handler_decimal_result::make_num_distinct_aggregator_field(\n                                                            MEM_ROOT *mem_root,\n                                                            const Item *item)\n                                                            const\n{\n  DBUG_ASSERT(item->decimals <= DECIMAL_MAX_SCALE);\n  return new (mem_root)\n         Field_new_decimal(NULL, item->max_length,\n                           (uchar *) (item->maybe_null ? \"\" : 0),\n                           item->maybe_null ? 1 : 0, Field::NONE,\n                           item->name, item->decimals, 0, item->unsigned_flag);\n}","target":1,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":404737,"func":"static ssize_t raw_preadv(struct bdev *bdev, struct iovec *iov, int iovcnt, off_t offset)\n{\n\treturn preadv(bdev->fd, iov, iovcnt, offset);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":312789,"func":"void RenderFrameHostImpl::FlushNetworkAndNavigationInterfacesForTesting() {\n  DCHECK(network_service_connection_error_handler_holder_);\n  network_service_connection_error_handler_holder_.FlushForTesting();\n\n  if (!navigation_control_)\n    GetNavigationControl();\n  DCHECK(navigation_control_);\n  navigation_control_.FlushForTesting();\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":125872,"func":"static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value)\n{\n\tif (value>0xFFFF)\n\t\treturn(TIFFReadDirEntryErrRange);\n\telse\n\t\treturn(TIFFReadDirEntryErrOk);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":226093,"func":"LayoutUnit RenderBox::containingBlockAvailableLineWidth() const\n{\n    RenderBlock* cb = containingBlock();\n    if (cb->isRenderBlockFlow())\n        return toRenderBlockFlow(cb)->availableLogicalWidthForLine(logicalTop(), false, availableLogicalHeight(IncludeMarginBorderPadding));\n    return 0;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":113733,"func":"static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)\n{\n\tstruct socket *sock = sk->sk_socket;\n\tstruct tipc_msg *msg = buf_msg(buf);\n\tunsigned int limit = rcvbuf_limit(sk, buf);\n\tu32 res = TIPC_OK;\n\n\t\/* Reject message if it is wrong sort of message for socket *\/\n\tif (msg_type(msg) > TIPC_DIRECT_MSG)\n\t\treturn TIPC_ERR_NO_PORT;\n\n\tif (sock->state == SS_READY) {\n\t\tif (msg_connected(msg))\n\t\t\treturn TIPC_ERR_NO_PORT;\n\t} else {\n\t\tres = filter_connect(tipc_sk(sk), &buf);\n\t\tif (res != TIPC_OK || buf == NULL)\n\t\t\treturn res;\n\t}\n\n\t\/* Reject message if there isn't room to queue it *\/\n\tif (sk_rmem_alloc_get(sk) + buf->truesize >= limit)\n\t\treturn TIPC_ERR_OVERLOAD;\n\n\t\/* Enqueue message *\/\n\tTIPC_SKB_CB(buf)->handle = NULL;\n\t__skb_queue_tail(&sk->sk_receive_queue, buf);\n\tskb_set_owner_r(buf, sk);\n\n\tsk->sk_data_ready(sk, 0);\n\treturn TIPC_OK;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":133322,"func":"GF_EXPORT\nvoid gf_isom_box_del(GF_Box *a)\n{\n\tGF_List *child_boxes;\n\tconst struct box_registry_entry *a_box_registry;\n\tif (!a) return;\n\n\tchild_boxes\t= a->child_boxes;\n\ta->child_boxes = NULL;\n\n\ta_box_registry = a->registry;\n\tif (!a_box_registry) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Delete invalid box type %s without registry\\n\", gf_4cc_to_str(a->type) ));\n\t} else {\n\t\ta_box_registry->del_fn(a);\n\t}\n\t\/\/delete the other boxes after deleting the box for dumper case where all child boxes are stored in otherbox\n\tif (child_boxes) {\n\t\tgf_isom_box_array_del(child_boxes);\n\t}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":215632,"func":"bool ContentSecurityPolicy::IsActive() const {\n  return !policies_.IsEmpty();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":195969,"func":"  explicit MultiPartResponseClient(WebPluginResourceClient* resource_client)\n      : resource_client_(resource_client) {\n    Clear();\n  }\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":485358,"func":"peer_default_originate_set_vty (struct vty *vty, const char *peer_str, \n                                afi_t afi, safi_t safi, \n                                const char *rmap, int set)\n{\n  int ret;\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, peer_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  if (set)\n    ret = peer_default_originate_set (peer, afi, safi, rmap);\n  else\n    ret = peer_default_originate_unset (peer, afi, safi);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":511855,"func":"static void test_json_append_escaped(void)\n{\n\tstring_t *str = t_str_new(32);\n\n\ttest_begin(\"json_append_escaped()\");\n\tjson_append_escaped(str, \"\\b\\f\\r\\n\\t\\\"\\\\\\001\\002-\\xC3\\xA4\\xf0\\x90\\x90\\xb7\\xff\");\n\ttest_assert(strcmp(str_c(str), \"\\\\b\\\\f\\\\r\\\\n\\\\t\\\\\\\"\\\\\\\\\\\\u0001\\\\u0002-\\\\u00e4\\\\ud801\\\\udc37\" UNICODE_REPLACEMENT_CHAR_UTF8) == 0);\n\ttest_end();\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":330227,"func":"static int tta_get_unary(GetBitContext *gb)\n\n{\n\n    int ret = 0;\n\n\n\n    \/\/ count ones\n\n    while(get_bits1(gb))\n\n        ret++;\n\n    return ret;\n\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":445732,"func":"char *getusername_malloc(void) {\n        const char *e;\n\n        e = secure_getenv(\"USER\");\n        if (e)\n                return strdup(e);\n\n        return uid_to_name(getuid());\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":294427,"func":"static unsigned zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                              size_t insize, const LodePNGCompressSettings* settings)\n{\n  if (!settings->custom_zlib) return 87; \/*no custom zlib function provided *\/\n  return settings->custom_zlib(out, outsize, in, insize, settings);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":283154,"func":"newimage(Image *image)\n{\n   memset(image, 0, sizeof *image);\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":206268,"func":"void PrintWebViewHelper::PrintPreviewContext::FinalizePrintReadyDocument() {\n  DCHECK(IsRendering());\n\n  base::TimeTicks begin_time = base::TimeTicks::Now();\n  metafile_->FinishDocument();\n\n  if (print_ready_metafile_page_count_ <= 0) {\n    NOTREACHED();\n    return;\n  }\n\n  UMA_HISTOGRAM_MEDIUM_TIMES(\"PrintPreview.RenderToPDFTime\",\n                             document_render_time_);\n  base::TimeDelta total_time =\n      (base::TimeTicks::Now() - begin_time) + document_render_time_;\n  UMA_HISTOGRAM_MEDIUM_TIMES(\"PrintPreview.RenderAndGeneratePDFTime\",\n                             total_time);\n  UMA_HISTOGRAM_MEDIUM_TIMES(\"PrintPreview.RenderAndGeneratePDFTimeAvgPerPage\",\n                             total_time \/ pages_to_render_.size());\n}\n","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":235428,"func":"static void methodWithSequenceArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    TestObjectV8Internal::methodWithSequenceArgMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":372711,"func":"void CLASS fuji_load_raw()\n{\n#ifndef LIBRAW_LIBRARY_BUILD\n  ushort *pixel;\n  int wide, row, col, r, c;\n\n  fseek (ifp, (top_margin*raw_width + left_margin) * 2, SEEK_CUR);\n  wide = fuji_width << !fuji_layout;\n  pixel = (ushort *) calloc (wide, sizeof *pixel);\n  merror (pixel, \"fuji_load_raw()\");\n  for (row=0; row < raw_height; row++) {\n    read_shorts (pixel, wide);\n    fseek (ifp, 2*(raw_width - wide), SEEK_CUR);\n    for (col=0; col < wide; col++) {\n      if (fuji_layout) {\n\tr = fuji_width - 1 - col + (row >> 1);\n\tc = col + ((row+1) >> 1);\n      } else {\n\tr = fuji_width - 1 + row - (col >> 1);\n\tc = row + ((col+1) >> 1);\n      }\n      BAYER(r,c) = pixel[col];\n    }\n  }\n  free (pixel);\n#else\n  read_shorts(raw_image,raw_width*raw_height);\n#endif\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":441513,"func":"static __always_inline void __vma_unlink_common(struct mm_struct *mm,\n\t\t\t\t\t\tstruct vm_area_struct *vma,\n\t\t\t\t\t\tstruct vm_area_struct *ignore)\n{\n\tvma_rb_erase_ignore(vma, &mm->mm_rb, ignore);\n\t__vma_unlink_list(mm, vma);\n\t\/* Kill the cache *\/\n\tvmacache_invalidate(mm);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":260340,"func":"flatpak_proxy_client_get_policy (FlatpakProxyClient *client, const char *source)\n{\n  if (source == NULL)\n    return FLATPAK_POLICY_TALK; \/* All clients can talk to the bus itself *\/\n\n  if (source[0] == ':')\n    return GPOINTER_TO_UINT (g_hash_table_lookup (client->unique_id_policy, source));\n\n  return flatpak_proxy_get_policy (client->proxy, source);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":71723,"func":"QString Utility::Substring(int start_index, int end_index, const QString &string)\n{\n    return string.mid(start_index, end_index - start_index);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":397455,"func":"static CharDriverState *qemu_chr_open_pipe(const char *id,\n                                           ChardevBackend *backend,\n                                           ChardevReturn *ret,\n                                           Error **errp)\n{\n    ChardevHostdev *opts = backend->u.pipe.data;\n    const char *filename = opts->device;\n    CharDriverState *chr;\n    WinCharState *s;\n    ChardevCommon *common = qapi_ChardevHostdev_base(opts);\n\n    chr = qemu_chr_alloc(common, errp);\n    if (!chr) {\n        return NULL;\n    }\n    s = g_new0(WinCharState, 1);\n    chr->opaque = s;\n    chr->chr_write = win_chr_write;\n    chr->chr_close = win_chr_close;\n\n    if (win_chr_pipe_init(chr, filename, errp) < 0) {\n        g_free(s);\n        qemu_chr_free_common(chr);\n        return NULL;\n    }\n    return chr;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":412938,"func":"PHP_FUNCTION(ldap_dn2ufn)\n{\n\tchar *dn, *ufn;\n\tint dn_len;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &dn, &dn_len) != SUCCESS) {\n\t\treturn;\n\t}\n\n\tufn = ldap_dn2ufn(dn);\n\n\tif (ufn != NULL) {\n\t\tRETVAL_STRING(ufn, 1);\n#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS\n\t\tldap_memfree(ufn);\n#endif\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":45440,"func":"static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)\n{\n    *count = avio_rb32(pb);\n    *refs = av_calloc(*count, sizeof(UID));\n    if (!*refs) {\n        *count = 0;\n        return AVERROR(ENOMEM);\n    }\n    avio_skip(pb, 4); \/* useless size of objects, always 16 according to specs *\/\n    avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID));\n    return 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":280978,"func":"LayoutUnit RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, bool includeMaxWidth) const\n{\n    LayoutUnit minLogicalWidth = computeReplacedLogicalWidthUsing(style()->logicalMinWidth());\n    LayoutUnit maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth());\n    return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth));\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":336896,"func":"static void trigger_prot_fault(CPUS390XState *env, target_ulong vaddr,\n\n                               uint64_t mode)\n\n{\n\n    CPUState *cs = CPU(s390_env_get_cpu(env));\n\n    int ilen = ILEN_LATER_INC;\n\n    int bits = trans_bits(env, mode) | 4;\n\n\n\n    DPRINTF(\"%s: vaddr=%016\" PRIx64 \" bits=%d\\n\", __func__, vaddr, bits);\n\n\n\n    stq_phys(cs->as,\n\n             env->psa + offsetof(LowCore, trans_exc_code), vaddr | bits);\n\n    trigger_pgm_exception(env, PGM_PROTECTION, ilen);\n\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":410768,"func":"static void bans_show_channel(IRC_CHANNEL_REC *channel, IRC_SERVER_REC *server)\n{\n\tGSList *tmp;\n        int counter;\n\n\tif (channel->banlist == NULL) {\n\t\tprintformat(server, channel->visible_name,\n\t\t\t    MSGLEVEL_CLIENTNOTICE,\n\t\t\t    IRCTXT_NO_BANS, channel->visible_name);\n\t\treturn;\n\t}\n\n\t\/* show bans.. *\/\n        counter = 1;\n\tfor (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) {\n\t\tBAN_REC *rec = tmp->data;\n\n\t\tprintformat(server, channel->visible_name, MSGLEVEL_CRAP,\n\t\t\t    (rec->setby == NULL || *rec->setby == '\\0') ?\n\t\t\t    IRCTXT_BANLIST : IRCTXT_BANLIST_LONG,\n\t\t\t    counter, channel->visible_name,\n\t\t\t    rec->ban, rec->setby,\n\t\t\t    (int) (time(NULL)-rec->time));\n                counter++;\n\t}\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":69078,"func":"static struct fsnotify_event *inotify_merge(struct list_head *list,\n\t\t\t\t\t    struct fsnotify_event *event)\n{\n\tstruct fsnotify_event_holder *last_holder;\n\tstruct fsnotify_event *last_event;\n\n\t\/* and the list better be locked by something too *\/\n\tspin_lock(&event->lock);\n\n\tlast_holder = list_entry(list->prev, struct fsnotify_event_holder, event_list);\n\tlast_event = last_holder->event;\n\tif (event_compare(last_event, event))\n\t\tfsnotify_get_event(last_event);\n\telse\n\t\tlast_event = NULL;\n\n\tspin_unlock(&event->lock);\n\n\treturn last_event;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":429994,"func":"  int64_t get_next_session_id() {\n    auto session_id = next_session_id_;\n    if (next_session_id_ == std::numeric_limits<int64_t>::max()) {\n      next_session_id_ = 1;\n    } else {\n      ++next_session_id_;\n    }\n    return session_id;\n  }","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":388687,"func":"int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,\n\t\t\t     const char *path, const char *name)\n{\n\tVFS_FIND(removexattr);\n\treturn handle->fns->removexattr_fn(handle, path, name);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":202012,"func":"void Com_EndRedirect( void ) {\n\tif ( rd_flush ) {\n\t\trd_flush( rd_buffer );\n\t}\n\n\trd_buffer = NULL;\n\trd_buffersize = 0;\n\trd_flush = NULL;\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":247333,"func":"void ExpandableContainerView::DetailsView::AddDetail(\n    const base::string16& detail) {\n  layout_->StartRowWithPadding(0, 0,\n                               0, views::kRelatedControlSmallVerticalSpacing);\n  views::Label* detail_label =\n      new views::Label(PrepareForDisplay(detail, false));\n  detail_label->SetMultiLine(true);\n  detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);\n  layout_->AddView(detail_label);\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":366792,"func":"static int smack_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)\n{\n\tstruct smk_audit_info ad;\n\n\tsmk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS);\n\tsmk_ad_setfield_u_fs_path_dentry(&ad, dentry);\n\tsmk_ad_setfield_u_fs_path_mnt(&ad, mnt);\n\treturn smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":328049,"func":"static void timerblock_write(void *opaque, target_phys_addr_t addr,\n\n                             uint64_t value, unsigned size)\n\n{\n\n    timerblock *tb = (timerblock *)opaque;\n\n    int64_t old;\n\n    switch (addr) {\n\n    case 0: \/* Load *\/\n\n        tb->load = value;\n\n        \/* Fall through.  *\/\n\n    case 4: \/* Counter.  *\/\n\n        if ((tb->control & 1) && tb->count) {\n\n            \/* Cancel the previous timer.  *\/\n\n            qemu_del_timer(tb->timer);\n\n        }\n\n        tb->count = value;\n\n        if (tb->control & 1) {\n\n            timerblock_reload(tb, 1);\n\n        }\n\n        break;\n\n    case 8: \/* Control.  *\/\n\n        old = tb->control;\n\n        tb->control = value;\n\n        if (((old & 1) == 0) && (value & 1)) {\n\n            if (tb->count == 0 && (tb->control & 2)) {\n\n                tb->count = tb->load;\n\n            }\n\n            timerblock_reload(tb, 1);\n\n        }\n\n        break;\n\n    case 12: \/* Interrupt status.  *\/\n\n        tb->status &= ~value;\n\n        timerblock_update_irq(tb);\n\n        break;\n\n    }\n\n}\n","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":283199,"func":"bool FeatureInfo::IsWebGL2OrES3OrHigherContext() const {\n  return IsWebGL2OrES3OrHigherContextType(context_type_);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":164907,"func":"void Document::didUpdateSecurityOrigin()\n{\n    if (!m_frame)\n        return;\n    m_frame->script().updateSecurityOrigin(getSecurityOrigin());\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":164215,"func":"void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp)\n{\n\tint f2t = FrequencyToTranspose(psmp->nC4Speed);\n\tint transp = f2t >> 7;\n\tint ftune = f2t & 0x7F;\n\tif (ftune > 80)\n\t{\n\t\ttransp++;\n\t\tftune -= 128;\n\t}\n\tif (transp > 127) transp = 127;\n\tif (transp < -127) transp = -127;\n\tpsmp->RelativeTone = transp;\n\tpsmp->nFineTune = ftune;\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":313909,"func":"UtilityServiceFactory::UtilityServiceFactory()\n    : network_registry_(base::MakeUnique<service_manager::BinderRegistry>()) {}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":304353,"func":"static void recalloc_sock(struct pool *pool, size_t len)\n{\n\tsize_t old, new;\n\n\told = strlen(pool->sockbuf);\n\tnew = old + len + 1;\n\tif (new < pool->sockbuf_size)\n\t\treturn;\n\tnew = new + (RBUFSIZE - (new % RBUFSIZE));\n\tapplog(LOG_DEBUG, \"Recallocing pool sockbuf to %lu\", (unsigned long)new);\n\tpool->sockbuf = realloc(pool->sockbuf, new);\n\tif (!pool->sockbuf)\n\t\tquit(1, \"Failed to realloc pool sockbuf in recalloc_sock\");\n\tmemset(pool->sockbuf + old, 0, new - old);\n\tpool->sockbuf_size = new;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":225983,"func":"void rfc_send_nsc(tRFC_MCB* p_mcb) {\n uint8_t* p_data;\n  BT_HDR* p_buf = (BT_HDR*)osi_malloc(RFCOMM_CMD_BUF_SIZE);\n\n  p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;\n  p_data = (uint8_t*)(p_buf + 1) + p_buf->offset;\n\n *p_data++ = RFCOMM_EA | RFCOMM_I_CR(false) | RFCOMM_MX_NSC;\n *p_data++ = RFCOMM_EA | (RFCOMM_MX_NSC_LEN << 1);\n\n *p_data++ = rfc_cb.rfc.rx_frame.ea |\n (rfc_cb.rfc.rx_frame.cr << RFCOMM_SHIFT_CR) |\n              rfc_cb.rfc.rx_frame.type;\n\n \/* Total length is sizeof NSC data + mx header 2 *\/\n  p_buf->len = RFCOMM_MX_NSC_LEN + 2;\n\n  rfc_send_buf_uih(p_mcb, RFCOMM_MX_DLCI, p_buf);\n}\n","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":394900,"func":"static _Bool have_gcrypt (void) \/* {{{ *\/\n{\n  static _Bool result = 0;\n  static _Bool need_init = 1;\n\n  if (!need_init)\n    return (result);\n  need_init = 0;\n\n#if HAVE_LIBGCRYPT\n# if GCRYPT_VERSION_NUMBER < 0x010600\n  if (gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))\n    return (0);\n# endif\n\n  if (!gcry_check_version (GCRYPT_VERSION))\n    return (0);\n\n  if (!gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0))\n    return (0);\n\n  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);\n\n  result = 1;\n  return (1);\n#else\n  return(0);\n#endif\n} \/* }}} _Bool have_gcrypt *\/","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":108745,"func":"void tja1100DumpPhyReg(NetInterface *interface)\n{\n   uint8_t i;\n\n   \/\/Loop through PHY registers\n   for(i = 0; i < 32; i++)\n   {\n      \/\/Display current PHY register\n      TRACE_DEBUG(\"%02\" PRIu8 \": 0x%04\" PRIX16 \"\\r\\n\", i,\n         tja1100ReadPhyReg(interface, i));\n   }\n\n   \/\/Terminate with a line feed\n   TRACE_DEBUG(\"\\r\\n\");\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":16961,"func":"static void parse_palette_segment ( AVCodecContext * avctx , const uint8_t * buf , int buf_size ) {\n PGSSubContext * ctx = avctx -> priv_data ;\n const uint8_t * buf_end = buf + buf_size ;\n const uint8_t * cm = ff_cropTbl + MAX_NEG_CROP ;\n int color_id ;\n int y , cb , cr , alpha ;\n int r , g , b , r_add , g_add , b_add ;\n buf += 2 ;\n while ( buf < buf_end ) {\n color_id = bytestream_get_byte ( & buf ) ;\n y = bytestream_get_byte ( & buf ) ;\n cr = bytestream_get_byte ( & buf ) ;\n cb = bytestream_get_byte ( & buf ) ;\n alpha = bytestream_get_byte ( & buf ) ;\n YUV_TO_RGB1 ( cb , cr ) ;\n YUV_TO_RGB2 ( r , g , b , y ) ;\n av_dlog ( avctx , \"Color %d := (%d,%d,%d,%d)\\n\" , color_id , r , g , b , alpha ) ;\n ctx -> clut [ color_id ] = RGBA ( r , g , b , alpha ) ;\n }\n }","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":10077,"func":" static inline int btif_hl_select_close_connected(void){\n     char sig_on = btif_hl_signal_select_close_connected;\n     BTIF_TRACE_DEBUG(\"btif_hl_select_close_connected\");\n    return send(signal_fds[1], &sig_on, sizeof(sig_on), 0);\n }\n","target":1,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":67288,"func":"int rad_packet_send(struct rad_packet_t *pack, int fd, struct sockaddr_in *addr)\n{\n\tint n;\n\n\tclock_gettime(CLOCK_MONOTONIC, &pack->tv);\n\n\twhile (1) {\n\t\tif (addr)\n\t\t\tn = sendto(fd, pack->buf, pack->len, 0, addr, sizeof(*addr));\n\t\telse\n\t\t\tn = write(fd, pack->buf, pack->len);\n\t\tif (n < 0) {\n\t\t\tif (errno == EINTR)\n\t\t\t\tcontinue;\n\t\t\tlog_ppp_error(\"radius:write: %s\\n\", strerror(errno));\n\t\t\treturn -1;\n\t\t} else if (n != pack->len) {\n\t\t\tlog_ppp_error(\"radius:write: short write %i, excpected %i\\n\", n, pack->len);\n\t\t\treturn -1;\n\t\t}\n\t\tbreak;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":146482,"func":"file_cookies(const char *s)\t\t\/* I - Cookie string or NULL *\/\n{\n  if (s)\n    strlcpy(cookies, s, sizeof(cookies));\n  else\n    cookies[0] = '\\0';\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":177842,"func":"void InspectorAgentRegistry::discardAgents()\n{\n    for (size_t i = 0; i < m_agents.size(); i++)\n        m_agents[i]->discardAgent();\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":258600,"func":"static void dtap_bcc_setup ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {\n guint32 curr_offset ;\n guint32 consumed ;\n guint curr_len ;\n curr_offset = offset ;\n curr_len = len ;\n ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_BCC_CALL_REF , \"(Broadcast identity)\" ) ;\n ELEM_OPT_TLV ( 0x7e , GSM_A_PDU_TYPE_DTAP , DE_USER_USER , \"(Originator-to-dispatcher information)\" ) ;\n }","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":95881,"func":"void kernel_sigaction(int sig, __sighandler_t action)\n{\n\tspin_lock_irq(¤t->sighand->siglock);\n\tcurrent->sighand->action[sig - 1].sa.sa_handler = action;\n\tif (action == SIG_IGN) {\n\t\tsigset_t mask;\n\n\t\tsigemptyset(&mask);\n\t\tsigaddset(&mask, sig);\n\n\t\tflush_sigqueue_mask(&mask, ¤t->signal->shared_pending);\n\t\tflush_sigqueue_mask(&mask, ¤t->pending);\n\t\trecalc_sigpending();\n\t}\n\tspin_unlock_irq(¤t->sighand->siglock);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":160768,"func":"  int accept_conn(AsyncConnectionRef conn) {\n    Mutex::Locker l(lock);\n    auto it = conns.find(conn->peer_addr);\n    if (it != conns.end()) {\n      AsyncConnectionRef existing = it->second;\n\n      \/\/ lazy delete, see \"deleted_conns\"\n      \/\/ If conn already in, we will return 0\n      Mutex::Locker l(deleted_lock);\n      if (deleted_conns.erase(existing)) {\n        existing->get_perf_counter()->dec(l_msgr_active_connections);\n        conns.erase(it);\n      } else if (conn != existing) {\n        return -1;\n      }\n    }\n    conns[conn->peer_addr] = conn;\n    conn->get_perf_counter()->inc(l_msgr_active_connections);\n    accepting_conns.erase(conn);\n    return 0;\n  }","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":268763,"func":"static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,\n\t\t\tunsigned long end, struct mm_walk *walk)\n{\n#ifdef CONFIG_HUGETLB_PAGE\n\tunsigned char present;\n\tunsigned char *vec = walk->private;\n\n\t\/*\n\t * Hugepages under user process are always in RAM and never\n\t * swapped out, but theoretically it needs to be checked.\n\t *\/\n\tpresent = pte && !huge_pte_none(huge_ptep_get(pte));\n\tfor (; addr != end; vec++, addr += PAGE_SIZE)\n\t\t*vec = present;\n\twalk->private = vec;\n#else\n\tBUG();\n#endif\n\treturn 0;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":405136,"func":"EXPORTED int mboxlist_findsub(struct namespace *namespace,\n                              const char *pattern, int isadmin,\n                              const char *userid, const struct auth_state *auth_state,\n                              findall_cb *proc, void *rock,\n                              int force)\n{\n    strarray_t patterns = STRARRAY_INITIALIZER;\n    strarray_append(&patterns, pattern);\n\n    int r = mboxlist_findsubmulti(namespace, &patterns, isadmin, userid, auth_state, proc, rock, force);\n\n    strarray_fini(&patterns);\n\n    return r;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":367572,"func":"static inline int security_inode_getattr(struct vfsmount *mnt,\n\t\t\t\t\t  struct dentry *dentry)\n{\n\treturn 0;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":281316,"func":"spnego_gss_inquire_context(\n\t\t\tOM_uint32\t*minor_status,\n\t\t\tconst gss_ctx_id_t context_handle,\n\t\t\tgss_name_t\t*src_name,\n\t\t\tgss_name_t\t*targ_name,\n\t\t\tOM_uint32\t*lifetime_rec,\n\t\t\tgss_OID\t\t*mech_type,\n\t\t\tOM_uint32\t*ctx_flags,\n\t\t\tint\t\t*locally_initiated,\n\t\t\tint\t\t*opened)\n{\n\tOM_uint32 ret = GSS_S_COMPLETE;\n\n\tret = gss_inquire_context(minor_status,\n\t\t\t\tcontext_handle,\n\t\t\t\tsrc_name,\n\t\t\t\ttarg_name,\n\t\t\t\tlifetime_rec,\n\t\t\t\tmech_type,\n\t\t\t\tctx_flags,\n\t\t\t\tlocally_initiated,\n\t\t\t\topened);\n\n\treturn (ret);\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":495744,"func":"void Curl_free_idnconverted_hostname(struct hostname *host)\n{\n#if defined(USE_LIBIDN2)\n  if(host->encalloc) {\n    idn2_free(host->encalloc); \/* must be freed with idn2_free() since this was\n                                 allocated by libidn *\/\n    host->encalloc = NULL;\n  }\n#elif defined(USE_WIN32_IDN)\n  free(host->encalloc); \/* must be freed with free() since this was\n                           allocated by curl_win32_idn_to_ascii *\/\n  host->encalloc = NULL;\n#else\n  (void)host;\n#endif\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":294147,"func":"int gnutls_x509_ext_import_private_key_usage_period(const gnutls_datum_t * ext,\n\t\t\t\t\t\t time_t * activation,\n\t\t\t\t\t\t time_t * expiration)\n{\n\tint result, ret;\n\tASN1_TYPE c2 = ASN1_TYPE_EMPTY;\n\n\tresult = asn1_create_element\n\t    (_gnutls_get_pkix(), \"PKIX1.PrivateKeyUsagePeriod\", &c2);\n\tif (result != ASN1_SUCCESS) {\n\t\tgnutls_assert();\n\t\tret = _gnutls_asn2err(result);\n\t\tgoto cleanup;\n\t}\n\n\tresult = _asn1_strict_der_decode(&c2, ext->data, ext->size, NULL);\n\tif (result != ASN1_SUCCESS) {\n\t\tgnutls_assert();\n\t\tret = _gnutls_asn2err(result);\n\t\tgoto cleanup;\n\t}\n\n\tif (activation)\n\t\t*activation = _gnutls_x509_get_time(c2, \"notBefore\", 1);\n\n\tif (expiration)\n\t\t*expiration = _gnutls_x509_get_time(c2, \"notAfter\", 1);\n\n\tret = 0;\n\n cleanup:\n\tasn1_delete_structure(&c2);\n\n\treturn ret;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":140875,"func":"int sc_mutex_create(const sc_context_t *ctx, void **mutex)\n{\n\tif (ctx == NULL)\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\tif (ctx->thread_ctx != NULL && ctx->thread_ctx->create_mutex != NULL)\n\t\treturn ctx->thread_ctx->create_mutex(mutex);\n\telse\n\t\treturn SC_SUCCESS;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":436152,"func":"big5_left_adjust_char_head(const UChar* start, const UChar* s)\n{\n  const UChar *p;\n  int len;\n\n  if (s <= start) return (UChar* )s;\n  p = s;\n\n  if (BIG5_ISMB_TRAIL(*p)) {\n    while (p > start) {\n      if (! BIG5_ISMB_FIRST(*--p)) {\n\tp++;\n\tbreak;\n      }\n    } \n  }\n  len = enclen(ONIG_ENCODING_BIG5, p);\n  if (p + len > s) return (UChar* )p;\n  p += len;\n  return (UChar* )(p + ((s - p) & ~1));\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":477959,"func":"    T& operator()(const unsigned int x, const unsigned int y, const unsigned int z) {\n      return _data[x + y*(ulongT)_width + z*(ulongT)_width*_height];\n   }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":56306,"func":"  std::chrono::milliseconds streamIdleTimeout() const override { return stream_idle_timeout_; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":14624,"func":"SpeechRecognitionManagerImpl::SpeechRecognitionManagerImpl(\n    media::AudioSystem* audio_system,\n    MediaStreamManager* media_stream_manager)\n    : audio_system_(audio_system),\n      media_stream_manager_(media_stream_manager),\n      primary_session_id_(kSessionIDInvalid),\n      last_session_id_(kSessionIDInvalid),\n      is_dispatching_event_(false),\n       delegate_(GetContentClient()\n                     ->browser()\n                     ->CreateSpeechRecognitionManagerDelegate()),\n       weak_factory_(this) {\n   DCHECK(!g_speech_recognition_manager_impl);\n   g_speech_recognition_manager_impl = this;\n\n  frame_deletion_observer_.reset(new FrameDeletionObserver(\n      base::BindRepeating(&SpeechRecognitionManagerImpl::AbortSessionImpl,\n                          weak_factory_.GetWeakPtr())));\n}\n","target":1,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":462934,"func":"TEST(EqOp, MatchesMinKey) {\n    BSONObj operand = BSON(\"a\" << MinKey);\n    EqualityMatchExpression eq;\n    eq.init(\"a\", operand[\"a\"]).transitional_ignore();\n    ASSERT(eq.matchesBSON(BSON(\"a\" << MinKey), NULL));\n    ASSERT(!eq.matchesBSON(BSON(\"a\" << MaxKey), NULL));\n    ASSERT(!eq.matchesBSON(BSON(\"a\" << 4), NULL));\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":257976,"func":"Datum eqsel ( PG_FUNCTION_ARGS ) {\n PlannerInfo * root = ( PlannerInfo * ) PG_GETARG_POINTER ( 0 ) ;\n Oid operator = PG_GETARG_OID ( 1 ) ;\n List * args = ( List * ) PG_GETARG_POINTER ( 2 ) ;\n int varRelid = PG_GETARG_INT32 ( 3 ) ;\n VariableStatData vardata ;\n Node * other ;\n bool varonleft ;\n double selec ;\n if ( ! get_restriction_variable ( root , args , varRelid , & vardata , & other , & varonleft ) ) PG_RETURN_FLOAT8 ( DEFAULT_EQ_SEL ) ;\n if ( IsA ( other , Const ) ) selec = var_eq_const ( & vardata , operator , ( ( Const * ) other ) -> constvalue , ( ( Const * ) other ) -> constisnull , varonleft ) ;\n else selec = var_eq_non_const ( & vardata , operator , other , varonleft ) ;\n ReleaseVariableStats ( vardata ) ;\n PG_RETURN_FLOAT8 ( ( float8 ) selec ) ;\n }","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":33975,"func":"void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm)\n{\n\t\/* It's safe to write the exe_file pointer without exe_file_lock because\n\t * this is called during fork when the task is not yet in \/proc *\/\n\tnewmm->exe_file = get_mm_exe_file(oldmm);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":94731,"func":"int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup)\n{\n\tstruct ext4_sb_info *sbi = EXT4_SB(sb);\n\tstruct flex_groups *new_groups;\n\tint size;\n\n\tif (!sbi->s_log_groups_per_flex)\n\t\treturn 0;\n\n\tsize = ext4_flex_group(sbi, ngroup - 1) + 1;\n\tif (size <= sbi->s_flex_groups_allocated)\n\t\treturn 0;\n\n\tsize = roundup_pow_of_two(size * sizeof(struct flex_groups));\n\tnew_groups = ext4_kvzalloc(size, GFP_KERNEL);\n\tif (!new_groups) {\n\t\text4_msg(sb, KERN_ERR, \"not enough memory for %d flex groups\",\n\t\t\t size \/ (int) sizeof(struct flex_groups));\n\t\treturn -ENOMEM;\n\t}\n\n\tif (sbi->s_flex_groups) {\n\t\tmemcpy(new_groups, sbi->s_flex_groups,\n\t\t       (sbi->s_flex_groups_allocated *\n\t\t\tsizeof(struct flex_groups)));\n\t\tkvfree(sbi->s_flex_groups);\n\t}\n\tsbi->s_flex_groups = new_groups;\n\tsbi->s_flex_groups_allocated = size \/ sizeof(struct flex_groups);\n\treturn 0;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":333832,"func":"static void dmg_refresh_limits(BlockDriverState *bs, Error **errp)\n\n{\n\n    bs->request_alignment = BDRV_SECTOR_SIZE; \/* No sub-sector I\/O supported *\/\n\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":148187,"func":"  PathMatcherImpl(const RequirementRule& rule)\n      : BaseMatcherImpl(rule), path_(rule.match().path()),\n        path_matcher_(Matchers::PathMatcher::createExact(path_, !case_sensitive_)) {}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":83744,"func":"void cil_destroy_category(struct cil_cat *cat)\n{\n\tif (cat == NULL) {\n\t\treturn;\n\t}\n\n\tcil_symtab_datum_destroy(&cat->datum);\n\tfree(cat);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":20542,"func":"static int bind_socket_ai ( struct addrinfo * ai , int reuse ) {\n int fd , on = 1 , r ;\n int serrno ;\n fd = socket ( AF_INET , SOCK_STREAM , 0 ) ;\n if ( fd == - 1 ) {\n event_warn ( \"socket\" ) ;\n return ( - 1 ) ;\n }\n if ( evutil_make_socket_nonblocking ( fd ) < 0 ) goto out ;\n # ifndef WIN32 if ( fcntl ( fd , F_SETFD , 1 ) == - 1 ) {\n event_warn ( \"fcntl(F_SETFD)\" ) ;\n goto out ;\n }\n # endif setsockopt ( fd , SOL_SOCKET , SO_KEEPALIVE , ( void * ) & on , sizeof ( on ) ) ;\n if ( reuse ) {\n setsockopt ( fd , SOL_SOCKET , SO_REUSEADDR , ( void * ) & on , sizeof ( on ) ) ;\n }\n if ( ai != NULL ) {\n r = bind ( fd , ai -> ai_addr , ai -> ai_addrlen ) ;\n if ( r == - 1 ) goto out ;\n }\n return ( fd ) ;\n out : serrno = EVUTIL_SOCKET_ERROR ( ) ;\n EVUTIL_CLOSESOCKET ( fd ) ;\n EVUTIL_SET_SOCKET_ERROR ( serrno ) ;\n return ( - 1 ) ;\n }","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":253545,"func":"MultiBufferBlockId ResourceMultiBufferDataProvider::Tell() const {\n  return pos_;\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":31193,"func":"gchar * proto_find_undecoded_data ( proto_tree * tree , guint length ) {\n gchar * decoded = ( gchar * ) wmem_alloc0 ( wmem_packet_scope ( ) , length \/ 8 + 1 ) ;\n proto_tree_traverse_pre_order ( tree , check_for_undecoded , decoded ) ;\n return decoded ;\n }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":192144,"func":"LayoutUnit RenderFlexibleBox::childIntrinsicWidth(RenderBox* child) const\n{\n    if (!child->isHorizontalWritingMode() && needToStretchChildLogicalHeight(child))\n        return constrainedChildIntrinsicContentLogicalHeight(child);\n    return child->width();\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":192181,"func":"UserShare* SyncManager::GetUserShare() const {\n  return data_->GetUserShare();\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":118096,"func":"lookup_installation_for_path (GFile *path, GError **error)\n{\n  FlatpakInstallation *installation;\n\n  if (installation_cache == NULL)\n    installation_cache = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, g_object_unref);\n\n  installation = g_hash_table_lookup (installation_cache, path);\n  if (installation == NULL)\n    {\n      g_autoptr(FlatpakDir) dir = NULL;\n\n      dir = flatpak_dir_get_by_path (path);\n      installation = flatpak_installation_new_for_dir (dir, NULL, error);\n      if (installation == NULL)\n        return NULL;\n\n      flatpak_installation_set_no_interaction (installation, TRUE);\n\n      g_hash_table_insert (installation_cache, g_object_ref (path), installation);\n    }\n\n  return g_object_ref (installation);\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":304915,"func":"\nGF_Err pdin_Write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tfor (i=0; i<ptr->count; i++) {\n\t\tgf_bs_write_u32(bs, ptr->rates[i]);\n\t\tgf_bs_write_u32(bs, ptr->times[i]);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":168751,"func":"DrawingBuffer* WebGLRenderingContextBase::GetDrawingBuffer() const {\n  return drawing_buffer_.get();\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":33575,"func":"mono_verifier_is_signature_compatible (MonoMethodSignature *target, MonoMethodSignature *candidate)\n{\n\treturn mono_delegate_signature_equal (target, candidate, FALSE);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":333785,"func":"static void test_visitor_in_native_list_uint16(TestInputVisitorData *data,\n\n                                               const void *unused)\n\n{\n\n    test_native_list_integer_helper(data, unused,\n\n                                    USER_DEF_NATIVE_LIST_UNION_KIND_U16);\n\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":271764,"func":"void MessageWrapper::Wrap(const std::string& message, std::string& out)\n{\n\t\/\/ If there is a fixed message, it is stored in prefix. Otherwise prefix contains\n\t\/\/ only the prefix, so append the message and the suffix\n\tout.assign(prefix);\n\tif (!fixed)\n\t\tout.append(message).append(suffix);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":289069,"func":"static int dissect_h225_INTEGER_1_65535 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 1U , 65535U , NULL , FALSE ) ;\n return offset ;\n }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":478791,"func":"    CImg<intT> get_select(CImgDisplay &disp,\n                          const unsigned int feature_type=2, unsigned int *const XYZ=0,\n                          const bool exit_on_anykey=false,\n                          const bool is_deep_selection_default=false) const {\n      return _select(disp,0,feature_type,XYZ,0,0,0,exit_on_anykey,true,false,is_deep_selection_default);\n    }","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":320682,"func":"bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *pkt, hwaddr pa,\n\n    size_t len)\n\n{\n\n    hwaddr mapped_len = 0;\n\n    struct iovec *ventry;\n\n    assert(pkt);\n\n    assert(pkt->max_raw_frags > pkt->raw_frags);\n\n\n\n    if (!len) {\n\n        return true;\n\n     }\n\n\n\n    ventry = &pkt->raw[pkt->raw_frags];\n\n    mapped_len = len;\n\n\n\n    ventry->iov_base = cpu_physical_memory_map(pa, &mapped_len, false);\n\n    ventry->iov_len = mapped_len;\n\n    pkt->raw_frags += !!ventry->iov_base;\n\n\n\n    if ((ventry->iov_base == NULL) || (len != mapped_len)) {\n\n        return false;\n\n    }\n\n\n\n    return true;\n\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":374693,"func":"AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)\n{\n\treturn RangeVarGetRelidExtended(stmt->relation, lockmode, stmt->missing_ok, false,\n\t\t\t\t\t\t\t\t\tRangeVarCallbackForAlterRelation,\n\t\t\t\t\t\t\t\t\t(void *) stmt);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":413541,"func":"static int _find_update_object_in_list(void *x, void *key)\n{\n\tslurmdb_update_object_t *object = (slurmdb_update_object_t *)x;\n\tslurmdb_update_type_t type = *(slurmdb_update_type_t *)key;\n\n\tif (object->type == type)\n\t\treturn 1;\n\n\treturn 0;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":461229,"func":"autoar_extractor_check_file_conflict (GFile  *file,\n                                      mode_t  extracted_filetype)\n{\n  GFileType file_type;\n  gboolean conflict = FALSE;\n\n  file_type = g_file_query_file_type (file,\n                                      G_FILE_QUERY_INFO_NONE,\n                                      NULL);\n  \/* If there is no file with the given name, there will be no conflict *\/\n  if (file_type == G_FILE_TYPE_UNKNOWN) {\n    return FALSE;\n  }\n\n  switch (extracted_filetype) {\n    case AE_IFDIR:\n      break;\n    case AE_IFREG:\n    case AE_IFLNK:\n#if defined HAVE_MKFIFO || defined HAVE_MKNOD\n    case AE_IFIFO:\n#endif\n#ifdef HAVE_MKNOD\n    case AE_IFSOCK:\n    case AE_IFBLK:\n    case AE_IFCHR:\n#endif\n      conflict = TRUE;\n      break;\n    default:\n      break;\n  }\n\n  return conflict;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":244144,"func":"static void aio_fput_routine(struct work_struct *data)\n{\n\tspin_lock_irq(&fput_lock);\n\twhile (likely(!list_empty(&fput_head))) {\n\t\tstruct kiocb *req = list_kiocb(fput_head.next);\n\t\tstruct kioctx *ctx = req->ki_ctx;\n\n\t\tlist_del(&req->ki_list);\n\t\tspin_unlock_irq(&fput_lock);\n\n\t\t\/* Complete the fput(s) *\/\n\t\tif (req->ki_filp != NULL)\n\t\t\tfput(req->ki_filp);\n\n\t\t\/* Link the iocb into the context's free list *\/\n\t\tspin_lock_irq(&ctx->ctx_lock);\n\t\treally_put_req(ctx, req);\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\n\t\tput_ioctx(ctx);\n\t\tspin_lock_irq(&fput_lock);\n\t}\n\tspin_unlock_irq(&fput_lock);\n}\n","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":419675,"func":"static int determine_space(Server *s, uint64_t *available, uint64_t *limit) {\n        JournalStorage *js;\n        int r;\n\n        assert(s);\n\n        js = s->system_journal ? &s->system_storage : &s->runtime_storage;\n\n        r = cache_space_refresh(s, js);\n        if (r >= 0) {\n                if (available)\n                        *available = js->space.available;\n                if (limit)\n                        *limit = js->space.limit;\n        }\n        return r;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":251787,"func":"GDataEntry* GDataEntry::FromDocumentEntry(GDataDirectory* parent,\n                                          DocumentEntry* doc,\n                                          GDataRootDirectory* root) {\n  DCHECK(doc);\n  if (doc->is_folder())\n    return GDataDirectory::FromDocumentEntry(parent, doc, root);\n  else if (doc->is_hosted_document() || doc->is_file())\n    return GDataFile::FromDocumentEntry(parent, doc, root);\n\n  return NULL;\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":445408,"func":"TEST_P(ConnectionLimitIntegrationTest, TestEmptyGlobalCxRuntimeLimit) {\n  const std::string log_line = \"no configured limit to the number of allowed active connections.\";\n  EXPECT_LOG_CONTAINS(\"warn\", log_line, { initialize(); });\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":163596,"func":"net::Error CallbackAndReturn(\n    const DownloadResourceHandler::OnStartedCallback& started_cb,\n    net::Error net_error) {\n  if (started_cb.is_null())\n    return net_error;\n  BrowserThread::PostTask(\n      BrowserThread::UI, FROM_HERE,\n      base::Bind(started_cb, static_cast<DownloadItem*>(NULL), net_error));\n\n  return net_error;\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":137604,"func":"static int llc_ui_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct llc_sock *llc;\n\n\tif (unlikely(sk == NULL))\n\t\tgoto out;\n\tsock_hold(sk);\n\tlock_sock(sk);\n\tllc = llc_sk(sk);\n\tdprintk(\"%s: closing local(%02X) remote(%02X)\\n\", __func__,\n\t\tllc->laddr.lsap, llc->daddr.lsap);\n\tif (!llc_send_disc(sk))\n\t\tllc_ui_wait_for_disc(sk, sk->sk_rcvtimeo);\n\tif (!sock_flag(sk, SOCK_ZAPPED)) {\n\t\tstruct llc_sap *sap = llc->sap;\n\n\t\t\/* Hold this for release_sock(), so that llc_backlog_rcv()\n\t\t * could still use it.\n\t\t *\/\n\t\tllc_sap_hold(sap);\n\t\tllc_sap_remove_socket(llc->sap, sk);\n\t\trelease_sock(sk);\n\t\tllc_sap_put(sap);\n\t} else {\n\t\trelease_sock(sk);\n\t}\n\tdev_put_track(llc->dev, &llc->dev_tracker);\n\tsock_put(sk);\n\tllc_sk_free(sk);\nout:\n\treturn 0;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":464796,"func":"static void v4l_print_audioout(const void *arg, bool write_only)\n{\n\tconst struct v4l2_audioout *p = arg;\n\n\tif (write_only)\n\t\tpr_cont(\"index=%u\\n\", p->index);\n\telse\n\t\tpr_cont(\"index=%u, name=%.*s, capability=0x%x, mode=0x%x\\n\",\n\t\t\tp->index, (int)sizeof(p->name), p->name,\n\t\t\tp->capability, p->mode);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":53934,"func":"void mg_set_protocol_mqtt(struct mg_connection *nc) {\n  nc->proto_handler = mqtt_handler;\n  nc->proto_data = MG_CALLOC(1, sizeof(struct mg_mqtt_proto_data));\n  nc->proto_data_destructor = mg_mqtt_proto_data_destructor;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":508923,"func":"int tls1_ec_curve_id2nid(int curve_id)\n{\n    \/* ECC curves from RFC 4492 *\/\n    if ((curve_id < 1) || ((unsigned int)curve_id >\n                           sizeof(nid_list) \/ sizeof(nid_list[0])))\n        return 0;\n    return nid_list[curve_id - 1];\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":367316,"func":"static int smack_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)\n{\n\tchar **rule = (char **)vrule;\n\t*rule = NULL;\n\n\tif (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER)\n\t\treturn -EINVAL;\n\n\tif (op != Audit_equal && op != Audit_not_equal)\n\t\treturn -EINVAL;\n\n\t*rule = smk_import(rulestr, 0);\n\n\treturn 0;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":244610,"func":"static int ssl_method_error(const SSL *s, const SSL_METHOD *method)\n{\n    int version = method->version;\n\n    if ((s->min_proto_version != 0 &&\n         version_cmp(s, version, s->min_proto_version) < 0) ||\n        ssl_security(s, SSL_SECOP_VERSION, 0, version, NULL) == 0)\n        return SSL_R_VERSION_TOO_LOW;\n\n    if (s->max_proto_version != 0 &&\n        version_cmp(s, version, s->max_proto_version) > 0)\n        return SSL_R_VERSION_TOO_HIGH;\n\n    if ((s->options & method->mask) != 0)\n        return SSL_R_UNSUPPORTED_PROTOCOL;\n    if ((method->flags & SSL_METHOD_NO_SUITEB) != 0 && tls1_suiteb(s))\n        return SSL_R_AT_LEAST_TLS_1_2_NEEDED_IN_SUITEB_MODE;\n    else if ((method->flags & SSL_METHOD_NO_FIPS) != 0 && FIPS_mode())\n        return SSL_R_AT_LEAST_TLS_1_0_NEEDED_IN_FIPS_MODE;\n\n    return 0;\n}\n","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":207688,"func":"void ShellSurface::Close() {\n  if (!close_callback_.is_null())\n    close_callback_.Run();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":292425,"func":"static void client_init_reply_buf(void)\n{\n    replybuf_pos = replybuf;\n    replybuf_left = sizeof replybuf - 1U;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":396699,"func":"GC_INNER void GC_remove_header(struct hblk *h)\n{\n    hdr **ha;\n    GET_HDR_ADDR(h, ha);\n    free_hdr(*ha);\n    *ha = 0;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":323648,"func":"QList *qdict_get_qlist(const QDict *qdict, const char *key)\n\n{\n\n    return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));\n\n}\n","target":1,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":416561,"func":"gx_default_1_add_decode_color(\n    gx_device *     dev,\n    gx_color_index  color,\n    gx_color_value  cv[1] )\n{\n    gx_color_value  rgb[3];\n    int             code = dev_proc(dev, map_color_rgb)(dev, color, rgb);\n\n    cv[0] = rgb[0];\n    return code;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":28039,"func":"static void process_gitlink ( struct rev_info * revs , const unsigned char * sha1 , show_object_fn show , struct strbuf * path , const char * name , void * cb_data ) {\n }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":137985,"func":"long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,\n\t\t       unsigned long bitmap_size)\n{\n\tunsigned long nr_compat_longs;\n\n\t\/* align bitmap up to nearest compat_long_t boundary *\/\n\tbitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);\n\tnr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);\n\n\tif (!access_ok(VERIFY_WRITE, umask, bitmap_size \/ 8))\n\t\treturn -EFAULT;\n\n\tuser_access_begin();\n\twhile (nr_compat_longs > 1) {\n\t\tunsigned long m = *mask++;\n\t\tunsafe_put_user((compat_ulong_t)m, umask++, Efault);\n\t\tunsafe_put_user(m >> BITS_PER_COMPAT_LONG, umask++, Efault);\n\t\tnr_compat_longs -= 2;\n\t}\n\tif (nr_compat_longs)\n\t\tunsafe_put_user((compat_ulong_t)*mask, umask++, Efault);\n\tuser_access_end();\n\treturn 0;\nEfault:\n\tuser_access_end();\n\treturn -EFAULT;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":517762,"func":"ha_rows ha_maria::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,\n                                               void *seq_init_param,\n                                               uint n_ranges, uint *bufsz,\n                                               uint *flags, Cost_estimate *cost)\n{\n  \/*\n    This call is here because there is no location where this->table would\n    already be known.\n    TODO: consider moving it into some per-query initialization call.\n  *\/\n  ds_mrr.init(this, table);\n  return ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param, n_ranges, bufsz,\n                                 flags, cost);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":293416,"func":"static int incclasscanon(Reclass *cc, Rune c)\n{\n\tRune *p, r;\n\tfor (p = cc->spans; p < cc->end; p += 2)\n\t\tfor (r = p[0]; r <= p[1]; ++r)\n\t\t\tif (c == canon(r))\n\t\t\t\treturn 1;\n\treturn 0;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":88225,"func":"static void ath10k_usb_free_urb_to_pipe(struct ath10k_usb_pipe *pipe,\n\t\t\t\t\tstruct ath10k_urb_context *urb_context)\n{\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&pipe->ar_usb->cs_lock, flags);\n\n\tpipe->urb_cnt++;\n\tlist_add(&urb_context->link, &pipe->urb_list_head);\n\n\tspin_unlock_irqrestore(&pipe->ar_usb->cs_lock, flags);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":475777,"func":"static int nft_chain_parse_netdev(struct net *net,\n\t\t\t\t  struct nlattr *tb[],\n\t\t\t\t  struct list_head *hook_list)\n{\n\tstruct nft_hook *hook;\n\tint err;\n\n\tif (tb[NFTA_HOOK_DEV]) {\n\t\thook = nft_netdev_hook_alloc(net, tb[NFTA_HOOK_DEV]);\n\t\tif (IS_ERR(hook))\n\t\t\treturn PTR_ERR(hook);\n\n\t\tlist_add_tail(&hook->list, hook_list);\n\t} else if (tb[NFTA_HOOK_DEVS]) {\n\t\terr = nf_tables_parse_netdev_hooks(net, tb[NFTA_HOOK_DEVS],\n\t\t\t\t\t\t   hook_list);\n\t\tif (err < 0)\n\t\t\treturn err;\n\n\t\tif (list_empty(hook_list))\n\t\t\treturn -EINVAL;\n\t} else {\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":183105,"func":" static void locationReplaceableAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n {\n     TestObjectPython* proxyImp = V8TestObjectPython::toNative(info.Holder());\n    RefPtr<TestNode> imp = WTF::getPtr(proxyImp->locationReplaceable());\n     if (!imp)\n         return;\n     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);\n    imp->setHref(cppValue);\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":79833,"func":"GF_Err mp4s_AddBox(GF_Box *s, GF_Box *a)\n{\n\tGF_MPEGSampleEntryBox *ptr = (GF_MPEGSampleEntryBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_ESDS:\n\t\tif (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\t\tptr->esd = (GF_ESDBox *)a;\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_SINF:\n\t\tgf_list_add(ptr->protections, a);\n\t\tbreak;\n\tdefault:\n\t\treturn gf_isom_box_add_default(s, a);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":340323,"func":"static uint64_t megasas_port_read(void *opaque, target_phys_addr_t addr,\n\n                                  unsigned size)\n\n{\n\n    return megasas_mmio_read(opaque, addr & 0xff, size);\n\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":62467,"func":"static void __sctp_write_space(struct sctp_association *asoc)\n{\n\tstruct sock *sk = asoc->base.sk;\n\n\tif (sctp_wspace(asoc) <= 0)\n\t\treturn;\n\n\tif (waitqueue_active(&asoc->wait))\n\t\twake_up_interruptible(&asoc->wait);\n\n\tif (sctp_writeable(sk)) {\n\t\tstruct socket_wq *wq;\n\n\t\trcu_read_lock();\n\t\twq = rcu_dereference(sk->sk_wq);\n\t\tif (wq) {\n\t\t\tif (waitqueue_active(&wq->wait))\n\t\t\t\twake_up_interruptible(&wq->wait);\n\n\t\t\t\/* Note that we try to include the Async I\/O support\n\t\t\t * here by modeling from the current TCP\/UDP code.\n\t\t\t * We have not tested with it yet.\n\t\t\t *\/\n\t\t\tif (!(sk->sk_shutdown & SEND_SHUTDOWN))\n\t\t\t\tsock_wake_async(wq, SOCK_WAKE_SPACE, POLL_OUT);\n\t\t}\n\t\trcu_read_unlock();\n\t}\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":3276,"func":"static ssize_t _epoll_readv(\n    oe_fd_t* desc,\n    const struct oe_iovec* iov,\n    int iovcnt)\n{\n    ssize_t ret = -1;\n    epoll_t* file = _cast_epoll(desc);\n    void* buf = NULL;\n    size_t buf_size = 0;\n\n    if (!file || (iovcnt && !iov) || iovcnt < 0 || iovcnt > OE_IOV_MAX)\n        OE_RAISE_ERRNO(OE_EINVAL);\n\n    \/* Flatten the IO vector into contiguous heap memory. *\/\n    if (oe_iov_pack(iov, iovcnt, &buf, &buf_size) != 0)\n        OE_RAISE_ERRNO(OE_ENOMEM);\n\n    \/* Call the host. *\/\n    if (oe_syscall_readv_ocall(&ret, file->host_fd, buf, iovcnt, buf_size) !=\n        OE_OK)\n    {\n        OE_RAISE_ERRNO(OE_EINVAL);\n    }\n\n    \/* Synchronize data read with IO vector. *\/\n    if (oe_iov_sync(iov, iovcnt, buf, buf_size) != 0)\n        OE_RAISE_ERRNO(OE_EINVAL);\n\ndone:\n\n    if (buf)\n        oe_free(buf);\n\n    return ret;\n}","target":1,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":181585,"func":"HTREEITEM TreeView::GetTreeItemForNode(TreeModelNode* node) {\n  NodeDetails* details = GetNodeDetails(node);\n  return details ? details->tree_item : NULL;\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":189023,"func":"ShelfBackgroundAnimator::~ShelfBackgroundAnimator() {\n  if (wallpaper_controller_)\n    wallpaper_controller_->RemoveObserver(this);\n  if (shelf_)\n    shelf_->RemoveObserver(this);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":427251,"func":"thumbnail_failed_path (const char *uri)\n{\n  char *path, *file;\n\n  file = thumbnail_filename (uri);\n  \/* XXX: appname is only used for failed thumbnails. Is this a mistake? *\/\n  path = g_build_filename (g_get_user_cache_dir (),\n                           \"thumbnails\",\n                           \"fail\",\n                           appname,\n                           file,\n                           NULL);\n  g_free (file);\n  return path;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":28667,"func":"static struct passwd * current_getpwuid ( void ) {\n uid_t ruid ;\n errno = 0 ;\n ruid = getuid ( ) ;\n return errno == 0 ? getpwuid ( ruid ) : NULL ;\n }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":418070,"func":"bool RGWBulkDelete::Deleter::verify_permission(RGWBucketInfo& binfo,\n                                               map<string, bufferlist>& battrs,\n                                               ACLOwner& bucket_owner \/* out *\/)\n{\n  RGWAccessControlPolicy bacl(store->ctx());\n  int ret = read_bucket_policy(store, s, binfo, battrs, &bacl, binfo.bucket);\n  if (ret < 0) {\n    return false;\n  }\n\n  auto policy = get_iam_policy_from_attr(s->cct, store, battrs, binfo.bucket.tenant);\n\n  bucket_owner = bacl.get_owner();\n\n  \/* We can use global user_acl because each BulkDelete request is allowed\n   * to work on entities from a single account only. *\/\n  return verify_bucket_permission(s, binfo.bucket, s->user_acl.get(),\n\t\t\t\t  &bacl, policy, rgw::IAM::s3DeleteBucket);\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":470722,"func":"send_newstyle_option_reply (uint32_t option, uint32_t reply)\n{\n  GET_CONN;\n  struct nbd_fixed_new_option_reply fixed_new_option_reply;\n\n  fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC);\n  fixed_new_option_reply.option = htobe32 (option);\n  fixed_new_option_reply.reply = htobe32 (reply);\n  fixed_new_option_reply.replylen = htobe32 (0);\n\n  if (conn->send (&fixed_new_option_reply,\n                  sizeof fixed_new_option_reply, 0) == -1) {\n    \/* The protocol document says that the client is allowed to simply\n     * drop the connection after sending NBD_OPT_ABORT, or may read\n     * the reply.\n     *\/\n    if (option == NBD_OPT_ABORT)\n      debug (\"write: %s: %m\", name_of_nbd_opt (option));\n    else\n      nbdkit_error (\"write: %s: %m\", name_of_nbd_opt (option));\n    return -1;\n  }\n\n  return 0;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":58057,"func":"format_NOTE(const struct ofpact_note *a,\n            const struct ofpact_format_params *fp)\n{\n    ds_put_format(fp->s, \"%snote:%s\", colors.param, colors.end);\n    format_hex_arg(fp->s, a->data, a->length);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":522953,"func":"bool LEX::sp_declare_cursor(THD *thd, const LEX_CSTRING *name,\n                            sp_lex_cursor *cursor_stmt,\n                            sp_pcontext *param_ctx, bool add_cpush_instr)\n{\n  uint offp;\n  sp_instr_cpush *i;\n\n  if (spcont->find_cursor(name, &offp, true))\n  {\n    my_error(ER_SP_DUP_CURS, MYF(0), name->str);\n    return true;\n  }\n\n  if (unlikely(spcont->add_cursor(name, param_ctx, cursor_stmt)))\n    return true;\n\n  if (add_cpush_instr)\n  {\n    i= new (thd->mem_root)\n         sp_instr_cpush(sphead->instructions(), spcont, cursor_stmt,\n                        spcont->current_cursor_count() - 1);\n    return unlikely(i == NULL) || unlikely(sphead->add_instr(i));\n  }\n  return false;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":65975,"func":"void mg_mqtt_publish(struct mg_connection *nc, const char *topic,\n                     uint16_t message_id, int flags, const void *data,\n                     size_t len) {\n  uint16_t netbytes;\n  uint16_t topic_len = strlen(topic);\n\n  size_t total_len = 2 + topic_len + len;\n  if (MG_MQTT_GET_QOS(flags) > 0) {\n    total_len += 2;\n  }\n\n  mg_send_mqtt_header(nc, MG_MQTT_CMD_PUBLISH, flags, total_len);\n\n  netbytes = htons(topic_len);\n  mg_send(nc, &netbytes, 2);\n  mg_send(nc, topic, topic_len);\n\n  if (MG_MQTT_GET_QOS(flags) > 0) {\n    netbytes = htons(message_id);\n    mg_send(nc, &netbytes, 2);\n  }\n\n  mg_send(nc, data, len);\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":142228,"func":"current_func_returned(void)\n{\n    return current_funccal->returned;\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":521376,"func":"uchar *get_plugin_hash_key(const uchar *buff, size_t *length,\n                           my_bool not_used __attribute__((unused)))\n{\n  struct st_plugin_int *plugin= (st_plugin_int *)buff;\n  *length= (uint)plugin->name.length;\n  return((uchar *)plugin->name.str);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":306206,"func":"CotpConnection_getLocalRef(CotpConnection* self)\n{\n    return self->localRef;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":271582,"func":"TIFFLastDirectory(TIFF* tif)\n{\n\treturn (tif->tif_nextdiroff == 0);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":410901,"func":"bool WriteUint8(std::uint8_t val, std::FILE* fileptr) {\n  if (fileptr == nullptr)\n    return false;\n  return (std::fputc(val, fileptr) == val);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":98778,"func":"_zip_cdir_free(zip_cdir_t *cd)\n{\n    zip_uint64_t i;\n\n    if (!cd)\n\treturn;\n\n    for (i=0; i<cd->nentry; i++)\n\t_zip_entry_finalize(cd->entry+i);\n    free(cd->entry);\n    _zip_string_free(cd->comment);\n    free(cd);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":228063,"func":"const std::string Extension::VersionString() const {\n  return version()->GetString();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":211432,"func":"void HttpProxyClientSocket::OnIOComplete(int result) {\n  DCHECK_NE(STATE_NONE, next_state_);\n  DCHECK_NE(STATE_DONE, next_state_);\n  int rv = DoLoop(result);\n  if (rv != ERR_IO_PENDING)\n    DoCallback(rv);\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":107429,"func":"static void bond_setup_by_slave(struct net_device *bond_dev,\n\t\t\t\tstruct net_device *slave_dev)\n{\n\tstruct bonding *bond = netdev_priv(bond_dev);\n\n\tbond_dev->header_ops\t    = slave_dev->header_ops;\n\n\tbond_dev->type\t\t    = slave_dev->type;\n\tbond_dev->hard_header_len   = slave_dev->hard_header_len;\n\tbond_dev->addr_len\t    = slave_dev->addr_len;\n\n\tmemcpy(bond_dev->broadcast, slave_dev->broadcast,\n\t\tslave_dev->addr_len);\n\tbond->setup_by_slave = 1;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":378912,"func":"int usage_advanced()\n{\n    DISPLAY( \"\\nAdvanced options :\\n\");\n    DISPLAY( \" -c#    : test only compression function # [1-%i]\\n\", NB_COMPRESSION_ALGORITHMS);\n    DISPLAY( \" -d#    : test only decompression function # [1-%i]\\n\", NB_DECOMPRESSION_ALGORITHMS);\n    DISPLAY( \" -i#    : iteration loops [1-9](default : %i)\\n\", NBLOOPS);\n    DISPLAY( \" -B#    : Block size [4-7](default : 7)\\n\");\n    \/\/DISPLAY( \" -BD    : Block dependency (improve compression ratio)\\n\");\n    return 0;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":162528,"func":"ContainerChunk::ContainerChunk( ContainerChunk* parent, XMP_Uns32 id, XMP_Uns32 containerType ) : Chunk( NULL \/* !! *\/, chunk_CONTAINER, id )\n{\n\tXMP_Enforce( parent != NULL );\n\n\tthis->containerType = containerType;\n\tthis->newSize = 12;\n\tthis->parent = parent;\n\n\tchunkVect* siblings = &parent->children;\n\n\tsiblings->push_back( this );\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":279007,"func":"  int num_decoded_frames() { return num_decoded_frames_; }\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":415928,"func":"gx_device_set_media_from_hwsize(gx_device *dev)\n{\n    int rot = (dev->LeadingEdge & 1);\n    double x = dev->width * 72.0 \/ dev->HWResolution[0];\n    double y = dev->height * 72.0 \/ dev->HWResolution[1];\n\n    if (rot) {\n        dev->MediaSize[1] = x;\n        dev->MediaSize[0] = y;\n    } else {\n        dev->MediaSize[0] = x;\n        dev->MediaSize[1] = y;\n    }\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":277911,"func":"void RenderWidgetHostViewGtk::AccessibilityDoDefaultAction(int acc_obj_id) {\n  if (!host_)\n    return;\n\n  host_->AccessibilityDoDefaultAction(acc_obj_id);\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":416340,"func":"int hidp_connection_del(struct hidp_conndel_req *req)\n{\n\tu32 valid_flags = BIT(HIDP_VIRTUAL_CABLE_UNPLUG);\n\tstruct hidp_session *session;\n\n\tif (req->flags & ~valid_flags)\n\t\treturn -EINVAL;\n\n\tsession = hidp_session_find(&req->bdaddr);\n\tif (!session)\n\t\treturn -ENOENT;\n\n\tif (req->flags & BIT(HIDP_VIRTUAL_CABLE_UNPLUG))\n\t\thidp_send_ctrl_message(session,\n\t\t\t\t       HIDP_TRANS_HID_CONTROL |\n\t\t\t\t         HIDP_CTRL_VIRTUAL_CABLE_UNPLUG,\n\t\t\t\t       NULL, 0);\n\telse\n\t\tl2cap_unregister_user(session->conn, &session->user);\n\n\thidp_session_put(session);\n\n\treturn 0;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":170205,"func":"static void VoidMethodArrayBufferViewArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, \"TestObject\", \"voidMethodArrayBufferViewArg\");\n\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  if (UNLIKELY(info.Length() < 1)) {\n    exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));\n    return;\n  }\n\n  NotShared<TestArrayBufferView> array_buffer_view_arg;\n  array_buffer_view_arg = ToNotShared<NotShared<TestArrayBufferView>>(info.GetIsolate(), info[0], exception_state);\n  if (exception_state.HadException())\n    return;\n  if (!array_buffer_view_arg) {\n    exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(0, \"ArrayBufferView\"));\n    return;\n  }\n\n  impl->voidMethodArrayBufferViewArg(array_buffer_view_arg);\n}\n","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":73334,"func":"static bool hwsim_chans_compat(struct ieee80211_channel *c1,\n\t\t\t       struct ieee80211_channel *c2)\n{\n\tif (!c1 || !c2)\n\t\treturn false;\n\n\treturn c1->center_freq == c2->center_freq;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":100822,"func":"std::shared_ptr<Wasm> createThreadLocalWasm(Wasm& base_wasm, absl::string_view configuration,\n                                            Event::Dispatcher& dispatcher) {\n  auto wasm = std::make_shared<Wasm>(base_wasm, dispatcher);\n  Context* root_context = wasm->start();\n  if (!wasm->configure(root_context, configuration)) {\n    throw WasmException(\"Failed to configure WASM code\");\n  }\n  if (!wasm->vm_id().empty()) {\n    local_wasms[wasm->vm_id()] = wasm;\n  }\n  return wasm;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":186152,"func":"static inline void unmap_mapping_range_tree(struct prio_tree_root *root,\n\t\t\t\t\t    struct zap_details *details)\n{\n\tstruct vm_area_struct *vma;\n\tstruct prio_tree_iter iter;\n\tpgoff_t vba, vea, zba, zea;\n\n\tvma_prio_tree_foreach(vma, &iter, root,\n\t\t\tdetails->first_index, details->last_index) {\n\n\t\tvba = vma->vm_pgoff;\n\t\tvea = vba + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) - 1;\n\t\t\/* Assume for now that PAGE_CACHE_SHIFT == PAGE_SHIFT *\/\n\t\tzba = details->first_index;\n\t\tif (zba < vba)\n\t\t\tzba = vba;\n\t\tzea = details->last_index;\n\t\tif (zea > vea)\n\t\t\tzea = vea;\n\n\t\tunmap_mapping_range_vma(vma,\n\t\t\t((zba - vba) << PAGE_SHIFT) + vma->vm_start,\n\t\t\t((zea - vba + 1) << PAGE_SHIFT) + vma->vm_start,\n\t\t\t\tdetails);\n\t}\n}\n","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":38847,"func":"R_API RBinFile *r_bin_file_find_by_id(RBin *bin, ut32 binfile_id) {\n\tRBinFile *binfile = NULL;\n\tRListIter *iter = NULL;\n\tr_list_foreach (bin->binfiles, iter, binfile) {\n\t\tif (binfile->id == binfile_id) {\n\t\t\tbreak;\n\t\t}\n\t\tbinfile = NULL;\n\t}\n\treturn binfile;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":508792,"func":"discrete_component_transfer_func (gint C, RsvgNodeComponentTransferFunc * user_data)\n{\n    gint k;\n\n    if (!user_data->nbTableValues)\n        return C;\n\n    k = (C * user_data->nbTableValues) \/ 255;\n\n    return user_data->tableValues[CLAMP (k, 0, user_data->nbTableValues)];\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":192897,"func":"GrGLInterface* WebGraphicsContext3DCommandBufferImpl::onCreateGrGLInterface() {\n  return webkit_glue::CreateCommandBufferSkiaGLBinding();\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":208276,"func":"void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)\n{\n    if (isIdAttributeName(name))\n        updateId(oldValue, newValue);\n    else if (name == HTMLNames::nameAttr)\n        updateName(oldValue, newValue);\n    else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {\n        TreeScope* scope = treeScope();\n        if (scope->shouldCacheLabelsByForAttribute())\n            updateLabel(scope, oldValue, newValue);\n    }\n\n    if (oldValue != newValue) {\n        if (attached() && document()->styleResolver() && document()->styleResolver()->hasSelectorForAttribute(name.localName()))\n           setNeedsStyleRecalc();\n    }\n\n    if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInterestGroup::createForAttributesMutation(this, name))\n        recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));\n\n    InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue);\n}\n","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":167556,"func":"nm_ip4_config_get_ifindex (const NMIP4Config *config)\n{\n\treturn NM_IP4_CONFIG_GET_PRIVATE (config)->ifindex;\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":454876,"func":"TEST_F(QueryPlannerTest, SortSkipLimit) {\n    runQuerySortProjSkipNToReturn(BSONObj(), fromjson(\"{a: 1}\"), BSONObj(), 2, -3);\n    assertNumSolutions(1U);\n    \/\/ Limit in sort node should be adjusted by skip count\n    assertSolutionExists(\n        \"{skip: {n: 2, node: \"\n        \"{sort: {pattern: {a: 1}, limit: 5, node: {sortKeyGen: \"\n        \"{node: {cscan: {dir: 1}}}}}}}}\");\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":91108,"func":"static void tlb_flush_mmu_free(struct mmu_gather *tlb)\n{\n\tstruct mmu_gather_batch *batch;\n\n\tfor (batch = &tlb->local; batch && batch->nr; batch = batch->next) {\n\t\tfree_pages_and_swap_cache(batch->pages, batch->nr);\n\t\tbatch->nr = 0;\n\t}\n\ttlb->active = &tlb->local;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":310658,"func":"static void voidMethodArrayTestInterfaceEmptyArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    if (UNLIKELY(info.Length() < 1)) {\n        throwTypeError(ExceptionMessages::failedToExecute(\"voidMethodArrayTestInterfaceEmptyArg\", \"TestObjectPython\", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());\n        return;\n    }\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    V8TRYCATCH_VOID(Vector<RefPtr<TestInterfaceEmpty> >, arrayTestInterfaceEmptyArg, (toRefPtrNativeArray<TestInterfaceEmpty, V8TestInterfaceEmpty>(info[0], 1, info.GetIsolate())));\n    imp->voidMethodArrayTestInterfaceEmptyArg(arrayTestInterfaceEmptyArg);\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":59792,"func":"hts_idx_t *bcf_index_load3(const char *fn, const char *fnidx, int flags)\n{\n    return hts_idx_load3(fn, fnidx, HTS_FMT_CSI, flags);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":311747,"func":"void BrowserViewRenderer::CalculateTileMemoryPolicy() {\n  base::CommandLine* cl = base::CommandLine::ForCurrentProcess();\n\n  bool client_hard_limit_bytes_overridden =\n      cl->HasSwitch(switches::kForceGpuMemAvailableMb);\n  if (client_hard_limit_bytes_overridden) {\n    base::StringToUint64(\n        base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(\n            switches::kForceGpuMemAvailableMb),\n        &g_memory_override_in_bytes);\n    g_memory_override_in_bytes *= 1024 * 1024;\n  }\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":154333,"func":"termgui_mch_get_color(char_u *name)\n{\n    return gui_get_color_cmn(name);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":172818,"func":"void Gfx::opSetFlat(Object args[], int numArgs) {\n  state->setFlatness((int)args[0].getNum());\n  out->updateFlatness(state);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":464238,"func":"ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,\n                  LedFeedbackPtr l, xLedFeedbackCtl * f)\n{\n    LedCtrl lctrl;              \/* might get BadValue part way through *\/\n\n    if (client->swapped) {\n        swaps(&f->length);\n        swapl(&f->led_values);\n        swapl(&f->led_mask);\n    }\n\n    f->led_mask &= l->ctrl.led_mask;    \/* set only supported leds *\/\n    f->led_values &= l->ctrl.led_mask;  \/* set only supported leds *\/\n    if (mask & DvLed) {\n        lctrl.led_mask = f->led_mask;\n        lctrl.led_values = f->led_values;\n        (*l->CtrlProc) (dev, &lctrl);\n        l->ctrl.led_values &= ~(f->led_mask);   \/* zero changed leds *\/\n        l->ctrl.led_values |= (f->led_mask & f->led_values);    \/* OR in set leds *\/\n    }\n\n    return Success;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":151863,"func":"static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)\n{\n\treturn decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":438606,"func":"static u32 *gen12_emit_fini_breadcrumb(struct i915_request *request, u32 *cs)\n{\n\tcs = gen8_emit_ggtt_write(cs,\n\t\t\t\t  request->fence.seqno,\n\t\t\t\t  i915_request_active_timeline(request)->hwsp_offset,\n\t\t\t\t  0);\n\n\treturn gen12_emit_fini_breadcrumb_footer(request, cs);\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":206218,"func":"GLint GLES2Implementation::GetAttribLocation(GLuint program, const char* name) {\n  GPU_CLIENT_SINGLE_THREAD_CHECK();\n  GPU_CLIENT_LOG(\"[\" << GetLogPrefix() << \"] glGetAttribLocation(\" << program\n                     << \", \" << name << \")\");\n  TRACE_EVENT0(\"gpu\", \"GLES2::GetAttribLocation\");\n  GLint loc = share_group_->program_info_manager()->GetAttribLocation(\n      this, program, name);\n  GPU_CLIENT_LOG(\"returned \" << loc);\n  CheckGLError();\n  return loc;\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":351319,"func":"int ax25_fwd_ioctl(unsigned int cmd, struct ax25_fwd_struct *fwd)\n{\n\tax25_dev *ax25_dev, *fwd_dev;\n\n\tif ((ax25_dev = ax25_addr_ax25dev(&fwd->port_from)) == NULL)\n\t\treturn -EINVAL;\n\n\tswitch (cmd) {\n\tcase SIOCAX25ADDFWD:\n\t\tif ((fwd_dev = ax25_addr_ax25dev(&fwd->port_to)) == NULL)\n\t\t\treturn -EINVAL;\n\t\tif (ax25_dev->forward != NULL)\n\t\t\treturn -EINVAL;\n\t\tax25_dev->forward = fwd_dev->dev;\n\t\tax25_dev_put(fwd_dev);\n\t\tbreak;\n\n\tcase SIOCAX25DELFWD:\n\t\tif (ax25_dev->forward == NULL)\n\t\t\treturn -EINVAL;\n\t\tax25_dev->forward = NULL;\n\t\tbreak;\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tax25_dev_put(ax25_dev);\n\treturn 0;\n}","target":1,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":375904,"func":"void usb_device_handle_attach(USBDevice *dev)\n{\n    USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);\n    if (klass->handle_attach) {\n        klass->handle_attach(dev);\n    }\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":154813,"func":"ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)\n{\n\tchar *orig_page = page;\n\tunsigned int free, res;\n\n\tif (!tags)\n\t\treturn 0;\n\n\tpage += sprintf(page, \"nr_tags=%u, reserved_tags=%u, \"\n\t\t\t\"bits_per_word=%u\\n\",\n\t\t\ttags->nr_tags, tags->nr_reserved_tags,\n\t\t\ttags->bitmap_tags.bits_per_word);\n\n\tfree = bt_unused_tags(&tags->bitmap_tags);\n\tres = bt_unused_tags(&tags->breserved_tags);\n\n\tpage += sprintf(page, \"nr_free=%u, nr_reserved=%u\\n\", free, res);\n\tpage += sprintf(page, \"active_queues=%u\\n\", atomic_read(&tags->active_queues));\n\n\treturn page - orig_page;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":138877,"func":"pushval_asis(Datum opaque, TSQueryParserState state, char *strval, int lenval,\n\t\t\t int16 weight, bool prefix)\n{\n\tpushValue(state, strval, lenval, weight, prefix);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":194589,"func":"GLint GLES2Implementation::GetProgramResourceLocation(\n    GLuint program,\n    GLenum program_interface,\n    const char* name) {\n  GPU_CLIENT_SINGLE_THREAD_CHECK();\n  GPU_CLIENT_LOG(\"[\" << GetLogPrefix() << \"] glGetProgramResourceLocation(\"\n                     << program << \", \" << program_interface << \", \" << name\n                     << \")\");\n  TRACE_EVENT0(\"gpu\", \"GLES2::GetProgramResourceLocation\");\n  GLint location =\n      share_group_->program_info_manager()->GetProgramResourceLocation(\n          this, program, program_interface, name);\n  GPU_CLIENT_LOG(\"returned \" << location);\n  CheckGLError();\n  return location;\n}\n","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":99635,"func":"Variant c_SimpleXMLElementIterator::t_key() {\n  if (m_iter1) {\n    return m_iter1->first();\n  }\n  return uninit_null();\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":140710,"func":"void CL_DemoFilename( char *buf, int bufSize ) {\n\ttime_t rawtime;\n\tchar timeStr[32] = {0}; \/\/ should really only reach ~19 chars\n\n\ttime( &rawtime );\n\tstrftime( timeStr, sizeof( timeStr ), \"%Y-%m-%d_%H-%M-%S\", localtime( &rawtime ) ); \/\/ or gmtime\n\n\tCom_sprintf( buf, bufSize, \"demo%s\", timeStr );\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":394399,"func":"static void cli_connect_nb_done(struct tevent_req *subreq)\n{\n\tstruct tevent_req *req = tevent_req_callback_data(\n\t\tsubreq, struct tevent_req);\n\tstruct cli_connect_nb_state *state = tevent_req_data(\n\t\treq, struct cli_connect_nb_state);\n\tNTSTATUS status;\n\tint fd = 0;\n\tuint16_t port;\n\n\tstatus = cli_connect_sock_recv(subreq, &fd, &port);\n\tTALLOC_FREE(subreq);\n\tif (tevent_req_nterror(req, status)) {\n\t\treturn;\n\t}\n\n\tstate->cli = cli_state_create(state, fd, state->desthost, NULL,\n\t\t\t\t      state->signing_state, state->flags);\n\tif (tevent_req_nomem(state->cli, req)) {\n\t\tclose(fd);\n\t\treturn;\n\t}\n\ttevent_req_done(req);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":119775,"func":"ARN::ARN(const rgw_bucket& b)\n  : partition(Partition::aws),\n    service(Service::s3),\n    region(),\n    account(b.tenant),\n    resource(b.name) { }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":478711,"func":"      static int format(const short val) { return (int)val; }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":516391,"func":"void X509Certificate::Fingerprint512(const FunctionCallbackInfo<Value>& args) {\n  Environment* env = Environment::GetCurrent(args);\n  X509Certificate* cert;\n  ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());\n  Local<Value> ret;\n  if (GetFingerprintDigest(env, EVP_sha512(), cert->get()).ToLocal(&ret))\n    args.GetReturnValue().Set(ret);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":459718,"func":"dissect_kafka_create_partitions_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,\n                                         kafka_api_version_t api_version)\n{\n    proto_item *subti;\n    proto_tree *subtree;\n\n    offset = dissect_kafka_throttle_time(tvb, pinfo, tree, offset);\n\n    subtree = proto_tree_add_subtree(tree, tvb, offset, -1,\n                                     ett_kafka_topics,\n                                     &subti, \"Topics\");\n    offset = dissect_kafka_array(subtree, tvb, pinfo, offset, api_version >= 2, api_version,\n                                 &dissect_kafka_create_partitions_response_topic, NULL);\n    proto_item_set_end(subti, tvb, offset);\n\n    if (api_version >= 2) {\n        offset = dissect_kafka_tagged_fields(tvb, pinfo, tree, offset, 0);\n    }\n\n    return offset;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":380479,"func":"evbuffer_invoke_callbacks(struct evbuffer *buffer)\n{\n\tif (TAILQ_EMPTY(&buffer->callbacks)) {\n\t\tbuffer->n_add_for_cb = buffer->n_del_for_cb = 0;\n\t\treturn;\n\t}\n\n\tif (buffer->deferred_cbs) {\n\t\tif (buffer->deferred.queued)\n\t\t\treturn;\n\t\t_evbuffer_incref_and_lock(buffer);\n\t\tif (buffer->parent)\n\t\t\tbufferevent_incref(buffer->parent);\n\t\tEVBUFFER_UNLOCK(buffer);\n\t\tevent_deferred_cb_schedule(buffer->cb_queue, &buffer->deferred);\n\t}\n\n\tevbuffer_run_callbacks(buffer, 0);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":19334,"func":"static void guestfwd_read ( void * opaque , const uint8_t * buf , int size ) {\n struct GuestFwd * fwd = opaque ;\n slirp_socket_recv ( fwd -> slirp , fwd -> server , fwd -> port , buf , size ) ;\n }","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":81028,"func":"static int thread_cpu_nsleep(const clockid_t which_clock, int flags,\n\t\t\t      struct timespec *rqtp, struct timespec __user *rmtp)\n{\n\treturn -EINVAL;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":28737,"func":"static void e1000e_set_eitr ( E1000ECore * core , int index , uint32_t val ) {\n uint32_t interval = val & 0xffff ;\n uint32_t eitr_num = index - EITR ;\n trace_e1000e_irq_eitr_set ( eitr_num , val ) ;\n core -> eitr_guest_value [ eitr_num ] = interval ;\n core -> mac [ index ] = MAX ( interval , E1000E_MIN_XITR ) ;\n }","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":94624,"func":"static int usb_internal_control_msg(struct usb_device *usb_dev,\n\t\t\t\t    unsigned int pipe,\n\t\t\t\t    struct usb_ctrlrequest *cmd,\n\t\t\t\t    void *data, int len, int timeout)\n{\n\tstruct urb *urb;\n\tint retv;\n\tint length;\n\n\turb = usb_alloc_urb(0, GFP_NOIO);\n\tif (!urb)\n\t\treturn -ENOMEM;\n\n\tusb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data,\n\t\t\t     len, usb_api_blocking_completion, NULL);\n\n\tretv = usb_start_wait_urb(urb, timeout, &length);\n\tif (retv < 0)\n\t\treturn retv;\n\telse\n\t\treturn length;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":100786,"func":"svcauth_gss_set_svc_name(gss_name_t name)\n{\n\tOM_uint32\tmaj_stat, min_stat;\n\n\tlog_debug(\"in svcauth_gss_set_svc_name()\");\n\n\tif (svcauth_gss_name != NULL) {\n\t\tmaj_stat = gss_release_name(&min_stat, &svcauth_gss_name);\n\n\t\tif (maj_stat != GSS_S_COMPLETE) {\n\t\t\tlog_status(\"gss_release_name\", maj_stat, min_stat);\n\t\t\treturn (FALSE);\n\t\t}\n\t\tsvcauth_gss_name = NULL;\n\t}\n\tif (svcauth_gss_name == GSS_C_NO_NAME)\n\t\treturn (TRUE);\n\n\tmaj_stat = gss_duplicate_name(&min_stat, name, &svcauth_gss_name);\n\n\tif (maj_stat != GSS_S_COMPLETE) {\n\t\tlog_status(\"gss_duplicate_name\", maj_stat, min_stat);\n\t\treturn (FALSE);\n\t}\n\n\treturn (TRUE);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":377733,"func":"static void audit_buffer_free(struct audit_buffer *ab)\n{\n\tunsigned long flags;\n\n\tif (!ab)\n\t\treturn;\n\n\tif (ab->skb)\n\t\tkfree_skb(ab->skb);\n\n\tspin_lock_irqsave(&audit_freelist_lock, flags);\n\tif (audit_freelist_count > AUDIT_MAXFREE)\n\t\tkfree(ab);\n\telse {\n\t\taudit_freelist_count++;\n\t\tlist_add(&ab->list, &audit_freelist);\n\t}\n\tspin_unlock_irqrestore(&audit_freelist_lock, flags);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":237378,"func":"static bool ExecuteMoveUpAndModifySelection(LocalFrame& frame,\n                                            Event*,\n                                            EditorCommandSource,\n                                            const String&) {\n  frame.Selection().Modify(SelectionModifyAlteration::kExtend,\n                           SelectionModifyDirection::kBackward,\n                           TextGranularity::kLine, SetSelectionBy::kUser);\n  return true;\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":96204,"func":"  bool isSpace(char ch) const {\n    return ch == ' ' || ch == '\\n' || ch == '\\t' || ch == '\\f';\n  }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":121796,"func":"static pyc_object *get_int_object(RBuffer *buffer) {\n\tbool error = false;\n\tpyc_object *ret = NULL;\n\n\tst32 i = get_st32 (buffer, &error);\n\tif (error) {\n\t\treturn NULL;\n\t}\n\tret = R_NEW0 (pyc_object);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tret->type = TYPE_INT;\n\tret->data = r_str_newf (\"%d\", i);\n\tif (!ret->data) {\n\t\tR_FREE (ret);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":259309,"func":"void mg_mgr_free(struct mg_mgr *mgr) {\n  struct mg_connection *c;\n  for (c = mgr->conns; c != NULL; c = c->next) c->is_closing = 1;\n  mg_mgr_poll(mgr, 0);\n#if MG_ARCH == MG_ARCH_FREERTOS_TCP\n  FreeRTOS_DeleteSocketSet(mgr->ss);\n#endif\n  LOG(LL_INFO, (\"All connections closed\"));\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":325228,"func":"static int bdrv_inherited_flags(int flags)\n\n{\n\n    \/* Enable protocol handling, disable format probing for bs->file *\/\n\n    flags |= BDRV_O_PROTOCOL;\n\n\n\n    \/* Our block drivers take care to send flushes and respect unmap policy,\n\n     * so we can enable both unconditionally on lower layers. *\/\n\n    flags |= BDRV_O_CACHE_WB | BDRV_O_UNMAP;\n\n\n\n    \/* The backing file of a temporary snapshot is read-only *\/\n\n    if (flags & BDRV_O_SNAPSHOT) {\n\n        flags &= ~BDRV_O_RDWR;\n\n    }\n\n\n\n    \/* Clear flags that only apply to the top layer *\/\n\n    flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);\n\n\n\n    return flags;\n\n}\n","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":115213,"func":"ext4_xattr_create_cache(void)\n{\n\treturn mb2_cache_create(HASH_BUCKET_BITS);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":252124,"func":"void CL_Disconnect_f( void ) {\n\tSCR_StopCinematic();\n\tCvar_Set( \"savegame_loading\", \"0\" );\n\tCvar_Set( \"g_reloading\", \"0\" );\n\tif ( clc.state != CA_DISCONNECTED && clc.state != CA_CINEMATIC ) {\n\t\tCom_Error( ERR_DISCONNECT, \"Disconnected from server\" );\n\t}\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":47196,"func":"rfbBool TextChatOpen(rfbClient* client)\n{\n    rfbTextChatMsg chat;\n\n    if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n    chat.type = rfbTextChat;\n    chat.pad1 = 0;\n    chat.pad2 = 0;\n    chat.length = rfbClientSwap32IfLE(rfbTextChatOpen);\n    return  (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":152146,"func":"static int ipgre_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])\n{\n\t__be16 flags;\n\n\tif (!data)\n\t\treturn 0;\n\n\tflags = 0;\n\tif (data[IFLA_GRE_IFLAGS])\n\t\tflags |= nla_get_be16(data[IFLA_GRE_IFLAGS]);\n\tif (data[IFLA_GRE_OFLAGS])\n\t\tflags |= nla_get_be16(data[IFLA_GRE_OFLAGS]);\n\tif (flags & (GRE_VERSION|GRE_ROUTING))\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":488359,"func":"static void mld_send_initial_cr(struct inet6_dev *idev)\n{\n\tstruct sk_buff *skb;\n\tstruct ifmcaddr6 *pmc;\n\tint type;\n\n\tif (mld_in_v1_mode(idev))\n\t\treturn;\n\n\tskb = NULL;\n\tfor_each_mc_mclock(idev, pmc) {\n\t\tif (pmc->mca_sfcount[MCAST_EXCLUDE])\n\t\t\ttype = MLD2_CHANGE_TO_EXCLUDE;\n\t\telse\n\t\t\ttype = MLD2_ALLOW_NEW_SOURCES;\n\t\tskb = add_grec(skb, pmc, type, 0, 0, 1);\n\t}\n\tif (skb)\n\t\tmld_sendpack(skb);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":226549,"func":"status_t OMXNodeInstance::storeMetaDataInBuffers(\n        OMX_U32 portIndex, OMX_BOOL enable, MetadataBufferType *type) {\n Mutex::Autolock autolock(mLock);\n    CLOG_CONFIG(storeMetaDataInBuffers, \"%s:%u en:%d\", portString(portIndex), portIndex, enable);\n return storeMetaDataInBuffers_l(portIndex, enable, type);\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":184776,"func":"void BrowserWindowGtk::UpdateDevToolsSplitPosition() {\n  if (!window_has_shown_)\n    return;\n  GtkAllocation contents_rect;\n  gtk_widget_get_allocation(contents_vsplit_, &contents_rect);\n\n  if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {\n    int split_offset = contents_rect.width -\n        devtools_window_->GetWidth(contents_rect.width);\n    gtk_paned_set_position(GTK_PANED(contents_hsplit_), split_offset);\n  } else {\n    int split_offset = contents_rect.height -\n        devtools_window_->GetHeight(contents_rect.height);\n    gtk_paned_set_position(GTK_PANED(contents_vsplit_), split_offset);\n  }\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":237420,"func":"void RenderProcessImpl::FreeTransportDIB(TransportDIB* dib) {\n  if (!dib)\n    return;\n\n#if defined(OS_MACOSX)\n  IPC::Message* msg = new ViewHostMsg_FreeTransportDIB(dib->id());\n  main_thread()->Send(msg);\n#endif\n\n  delete dib;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":395921,"func":"gnutls_mac_algorithm_t gnutls_mac_get(gnutls_session_t session)\n{\n\trecord_parameters_st *record_params;\n\tint ret;\n\n\tret =\n\t    _gnutls_epoch_get(session, EPOCH_READ_CURRENT, &record_params);\n\tif (ret < 0)\n\t\treturn gnutls_assert_val(GNUTLS_MAC_NULL);\n\n\treturn record_params->mac->id;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":466327,"func":"TEST_F(ConnectionManagerUtilityTest, SkipMutateResponseHeadersReturnXRequestId) {\n  TestResponseHeaderMapImpl response_headers;\n  TestRequestHeaderMapImpl request_headers{{\"x-request-id\", \"request-id\"}};\n\n  EXPECT_CALL(*request_id_extension_,\n              setInResponse(testing::Ref(response_headers), testing::Ref(request_headers)))\n      .Times(0);\n  ConnectionManagerUtility::mutateResponseHeaders(response_headers, &request_headers, config_, \"\");\n  EXPECT_EQ(\"\", response_headers.get_(\"x-request-id\"));\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":100475,"func":"void gf_isom_sample_entry_predestroy(GF_SampleEntryBox *ptr)\n{\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":158224,"func":"  void* formal_count_address() { return &thread_local_top_.formal_count_; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":105652,"func":"int generic_update_time(struct inode *inode, struct timespec64 *time, int flags)\n{\n\tint iflags = I_DIRTY_TIME;\n\tbool dirty = false;\n\n\tif (flags & S_ATIME)\n\t\tinode->i_atime = *time;\n\tif (flags & S_VERSION)\n\t\tdirty = inode_maybe_inc_iversion(inode, false);\n\tif (flags & S_CTIME)\n\t\tinode->i_ctime = *time;\n\tif (flags & S_MTIME)\n\t\tinode->i_mtime = *time;\n\tif ((flags & (S_ATIME | S_CTIME | S_MTIME)) &&\n\t    !(inode->i_sb->s_flags & SB_LAZYTIME))\n\t\tdirty = true;\n\n\tif (dirty)\n\t\tiflags |= I_DIRTY_SYNC;\n\t__mark_inode_dirty(inode, iflags);\n\treturn 0;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":128813,"func":"set_cmdspos_cursor(void)\n{\n    int\t\ti, m, c;\n\n    set_cmdspos();\n    if (KeyTyped)\n    {\n\tm = Columns * Rows;\n\tif (m < 0)\t\/\/ overflow, Columns or Rows at weird value\n\t    m = MAXCOL;\n    }\n    else\n\tm = MAXCOL;\n    for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i)\n    {\n\tc = cmdline_charsize(i);\n\t\/\/ Count \">\" for double-wide multi-byte char that doesn't fit.\n\tif (has_mbyte)\n\t    correct_cmdspos(i, c);\n\t\/\/ If the cmdline doesn't fit, show cursor on last visible char.\n\t\/\/ Don't move the cursor itself, so we can still append.\n\tif ((ccline.cmdspos += c) >= m)\n\t{\n\t    ccline.cmdspos -= c;\n\t    break;\n\t}\n\tif (has_mbyte)\n\t    i += (*mb_ptr2len)(ccline.cmdbuff + i) - 1;\n    }\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":292304,"func":"static void create_src_dst(RAnalOp *op) {\n\top->src[0] = r_anal_value_new ();\n\top->src[1] = r_anal_value_new ();\n\top->src[2] = r_anal_value_new ();\n\top->dst = r_anal_value_new ();\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":330361,"func":"static void win32_rearm_timer(struct qemu_alarm_timer *t)\n\n{\n\n    struct qemu_alarm_win32 *data = t->priv;\n\n    uint64_t nearest_delta_us;\n\n\n\n    if (!active_timers[QEMU_TIMER_REALTIME] &&\n\n                !active_timers[QEMU_TIMER_VIRTUAL])\n\n        return;\n\n\n\n    nearest_delta_us = qemu_next_deadline_dyntick();\n\n    nearest_delta_us \/= 1000;\n\n\n\n    timeKillEvent(data->timerId);\n\n\n\n    data->timerId = timeSetEvent(1,\n\n                        data->period,\n\n                        host_alarm_handler,\n\n                        (DWORD)t,\n\n                        TIME_ONESHOT | TIME_PERIODIC);\n\n\n\n    if (!data->timerId) {\n\n        fprintf(stderr, \"Failed to re-arm win32 alarm timer %ld\\n\",\n\n                GetLastError());\n\n\n\n        timeEndPeriod(data->period);\n\n        exit(1);\n\n    }\n\n}\n","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":294990,"func":"static int query_raw_packet_qp_state(struct mlx5_ib_dev *dev,\n\t\t\t\t     struct mlx5_ib_qp *qp,\n\t\t\t\t     u8 *raw_packet_qp_state)\n{\n\tstruct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;\n\tstruct mlx5_ib_sq *sq = &raw_packet_qp->sq;\n\tstruct mlx5_ib_rq *rq = &raw_packet_qp->rq;\n\tint err;\n\tu8 sq_state = MLX5_SQ_STATE_NA;\n\tu8 rq_state = MLX5_RQ_STATE_NA;\n\n\tif (qp->sq.wqe_cnt) {\n\t\terr = query_raw_packet_qp_sq_state(dev, sq, &sq_state);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\tif (qp->rq.wqe_cnt) {\n\t\terr = query_raw_packet_qp_rq_state(dev, rq, &rq_state);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\treturn sqrq_state_to_qp_state(sq_state, rq_state, qp,\n\t\t\t\t      raw_packet_qp_state);\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":447418,"func":"char* RemoveCR(const char* txt)\n{\n    static char Buffer[2048];\n    char* pt;\n\n    strncpy(Buffer, txt, 2047);\n    Buffer[2047] = 0;\n    for (pt = Buffer; *pt; pt++)\n            if (*pt == '\\n' || *pt == '\\r') *pt = ' ';\n\n    return Buffer;\n\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":145860,"func":"handle_update_read(int handle, ssize_t bytes)\n{\n\tif (handle_is_ok(handle, HANDLE_FILE) && bytes > 0)\n\t\thandles[handle].bytes_read += bytes;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":59978,"func":"bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)\n{\n\tstruct f2fs_sb_info *sbi = F2FS_I_SB(inode);\n\n\tif (test_opt(sbi, LFS))\n\t\treturn true;\n\tif (S_ISDIR(inode->i_mode))\n\t\treturn true;\n\tif (IS_NOQUOTA(inode))\n\t\treturn true;\n\tif (f2fs_is_atomic_file(inode))\n\t\treturn true;\n\tif (fio) {\n\t\tif (is_cold_data(fio->page))\n\t\t\treturn true;\n\t\tif (IS_ATOMIC_WRITTEN_PAGE(fio->page))\n\t\t\treturn true;\n\t\tif (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED) &&\n\t\t\tf2fs_is_checkpointed_data(sbi, fio->old_blkaddr)))\n\t\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":138343,"func":"local void *malloc_track(struct mem_track_s *mem, size_t size)\n{\n    void *ptr;\n\n    ptr = malloc(size);\n    if (ptr != NULL) {\n        size = MALLOC_SIZE(ptr);\n        mem_track_grab(mem);\n        mem->num++;\n        mem->size += size;\n        if (mem->size > mem->max)\n            mem->max = mem->size;\n        mem_track_drop(mem);\n    }\n    return ptr;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":125485,"func":"cdf_unpack_header(cdf_header_t *h, char *buf)\n{\n\tsize_t i;\n\tsize_t len = 0;\n\n\tCDF_UNPACK(h->h_magic);\n\tCDF_UNPACKA(h->h_uuid);\n\tCDF_UNPACK(h->h_revision);\n\tCDF_UNPACK(h->h_version);\n\tCDF_UNPACK(h->h_byte_order);\n\tCDF_UNPACK(h->h_sec_size_p2);\n\tCDF_UNPACK(h->h_short_sec_size_p2);\n\tCDF_UNPACKA(h->h_unused0);\n\tCDF_UNPACK(h->h_num_sectors_in_sat);\n\tCDF_UNPACK(h->h_secid_first_directory);\n\tCDF_UNPACKA(h->h_unused1);\n\tCDF_UNPACK(h->h_min_size_standard_stream);\n\tCDF_UNPACK(h->h_secid_first_sector_in_short_sat);\n\tCDF_UNPACK(h->h_num_sectors_in_short_sat);\n\tCDF_UNPACK(h->h_secid_first_sector_in_master_sat);\n\tCDF_UNPACK(h->h_num_sectors_in_master_sat);\n\tfor (i = 0; i < __arraycount(h->h_master_sat); i++)\n\t\tCDF_UNPACK(h->h_master_sat[i]);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":461941,"func":"static int pin_ggtt_status_page(struct intel_engine_cs *engine,\n\t\t\t\tstruct i915_vma *vma)\n{\n\tunsigned int flags;\n\n\tif (!HAS_LLC(engine->i915) && i915_ggtt_has_aperture(engine->gt->ggtt))\n\t\t\/*\n\t\t * On g33, we cannot place HWS above 256MiB, so\n\t\t * restrict its pinning to the low mappable arena.\n\t\t * Though this restriction is not documented for\n\t\t * gen4, gen5, or byt, they also behave similarly\n\t\t * and hang if the HWS is placed at the top of the\n\t\t * GTT. To generalise, it appears that all !llc\n\t\t * platforms have issues with us placing the HWS\n\t\t * above the mappable region (even though we never\n\t\t * actually map it).\n\t\t *\/\n\t\tflags = PIN_MAPPABLE;\n\telse\n\t\tflags = PIN_HIGH;\n\n\treturn i915_ggtt_pin(vma, NULL, 0, flags);\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":427741,"func":"static void rtreeMatchArgFree(void *pArg){\n  int i;\n  RtreeMatchArg *p = (RtreeMatchArg*)pArg;\n  for(i=0; i<p->nParam; i++){\n    sqlite3_value_free(p->apSqlParam[i]);\n  }\n  sqlite3_free(p);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":295707,"func":"valid_filetype(char_u *val)\n{\n    return valid_name(val, \".-_\");\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":126880,"func":"TEST_F(HttpConnectionManagerImplTest, IdleTimeoutNoCodec) {\n  \/\/ Not used in the test.\n  delete codec_;\n\n  idle_timeout_ = (std::chrono::milliseconds(10));\n  Event::MockTimer* idle_timer = setUpTimer();\n  EXPECT_CALL(*idle_timer, enableTimer(_, _));\n  setup(false, \"\");\n\n  EXPECT_CALL(filter_callbacks_.connection_, close(Network::ConnectionCloseType::FlushWrite));\n  EXPECT_CALL(*idle_timer, disableTimer());\n  idle_timer->invokeCallback();\n\n  EXPECT_EQ(1U, stats_.named_.downstream_cx_idle_timeout_.value());\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":362708,"func":"xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {\n    xmlXPathObjectPtr obj;\n    void * ret;\n\n    if ((ctxt == NULL) || (ctxt->value == NULL)) {\n\txmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);\n\treturn(NULL);\n    }\n    if (ctxt->value->type != XPATH_USERS) {\n\txmlXPathSetTypeError(ctxt);\n\treturn(NULL);\n    }\n    obj = valuePop(ctxt);\n    ret = obj->user;\n    obj->user = NULL;\n    xmlXPathReleaseObject(ctxt->context, obj);\n    return(ret);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":44947,"func":"\nint TTF_GlyphMetrics32(TTF_Font *font, Uint32 ch,\n                     int *minx, int *maxx, int *miny, int *maxy, int *advance)\n{\n    c_glyph *glyph;\n\n    TTF_CHECK_POINTER(font, -1);\n\n    if (Find_GlyphMetrics(font, ch, &glyph) < 0) {\n        return -1;\n    }\n\n    if (minx) {\n        *minx = glyph->sz_left;\n    }\n    if (maxx) {\n        *maxx = glyph->sz_left + glyph->sz_width;\n        *maxx += 2 * font->outline_val;\n    }\n    if (miny) {\n        *miny = glyph->sz_top - glyph->sz_rows;\n    }\n    if (maxy) {\n        *maxy = glyph->sz_top;\n        *maxy += 2 * font->outline_val;\n    }\n    if (advance) {\n        *advance = FT_CEIL(glyph->advance);\n    }\n    return 0;","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":10173,"func":"bool WebRequestPermissions::HideRequest(\n    const extensions::InfoMap* extension_info_map,\n    const extensions::WebRequestInfo& request) {\n  if (request.is_web_view)\n    return false;\n\n  if (request.is_pac_request)\n    return true;\n \n  bool is_request_from_browser = request.render_process_id == -1;\n   bool is_request_from_webui_renderer = false;\n   if (!is_request_from_browser) {\n    if (request.is_web_view)\n      return false;\n\n    if (extension_info_map &&\n        extension_info_map->process_map().Contains(extensions::kWebStoreAppId,\n                                                   request.render_process_id)) {\n      return true;\n    }\n\n    is_request_from_webui_renderer =\n        content::ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(\n            request.render_process_id);\n  }\n\n  return IsSensitiveURL(request.url, is_request_from_browser ||\n                                         is_request_from_webui_renderer) ||\n         !HasWebRequestScheme(request.url);\n}\n","target":1,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":174944,"func":"bool Performance::HasObserverFor(\n    PerformanceEntry::EntryType filter_type) const {\n  return observer_filter_options_ & filter_type;\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":214316,"func":"static struct vm_area_struct* hugetlb_vma(unsigned long addr, struct mm_walk *walk)\n{\n\tstruct vm_area_struct *vma;\n\n\t\/* We don't need vma lookup at all. *\/\n\tif (!walk->hugetlb_entry)\n\t\treturn NULL;\n\n\tVM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem));\n\tvma = find_vma(walk->mm, addr);\n\tif (vma && vma->vm_start <= addr && is_vm_hugetlb_page(vma))\n\t\treturn vma;\n\n\treturn NULL;\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":268458,"func":"int wc_ecc_get_curve_idx_from_name(const char* curveName)\n{\n    int curve_idx;\n    word32 len;\n\n    if (curveName == NULL)\n        return BAD_FUNC_ARG;\n\n    len = (word32)XSTRLEN(curveName);\n\n    for (curve_idx = 0; ecc_sets[curve_idx].size != 0; curve_idx++) {\n        if (\n        #ifndef WOLFSSL_ECC_CURVE_STATIC\n            ecc_sets[curve_idx].name &&\n        #endif\n                XSTRNCASECMP(ecc_sets[curve_idx].name, curveName, len) == 0) {\n            break;\n        }\n    }\n    if (ecc_sets[curve_idx].size == 0) {\n        WOLFSSL_MSG(\"ecc_set curve name not found\");\n        return ECC_CURVE_INVALID;\n    }\n    return curve_idx;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":276506,"func":"static void UnsignedShortAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  v8::Local<v8::Object> holder = info.Holder();\n\n  TestObject* impl = V8TestObject::ToImpl(holder);\n\n  V8SetReturnValueUnsigned(info, impl->unsignedShortAttribute());\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":415891,"func":"extern int lxc_rmdir_onedev(const char *path, const char *exclude)\n{\n\tstruct stat mystat;\n\tbool onedev = true;\n\n\tif (is_native_overlayfs(path))\n\t\tonedev = false;\n\n\tif (lstat(path, &mystat) < 0) {\n\t\tif (errno == ENOENT)\n\t\t\treturn 0;\n\n\t\tERROR(\"Failed to stat %s\", path);\n\t\treturn -1;\n\t}\n\n\treturn _recursive_rmdir(path, mystat.st_dev, exclude, 0, onedev);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":74062,"func":"store_two(int c, char *s)\n{\n  s[0] = (char)((c >> 8) & 255);\n  s[1] = (char)(c & 255);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":240153,"func":"void RenderBox::clearContainingBlockOverrideSize()\n{\n    if (gOverrideContainingBlockLogicalWidthMap)\n        gOverrideContainingBlockLogicalWidthMap->remove(this);\n    clearOverrideContainingBlockContentLogicalHeight();\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":474996,"func":"static enum netdev_lag_hash bond_lag_hash_type(struct bonding *bond,\n\t\t\t\t\t       enum netdev_lag_tx_type type)\n{\n\tif (type != NETDEV_LAG_TX_TYPE_HASH)\n\t\treturn NETDEV_LAG_HASH_NONE;\n\n\tswitch (bond->params.xmit_policy) {\n\tcase BOND_XMIT_POLICY_LAYER2:\n\t\treturn NETDEV_LAG_HASH_L2;\n\tcase BOND_XMIT_POLICY_LAYER34:\n\t\treturn NETDEV_LAG_HASH_L34;\n\tcase BOND_XMIT_POLICY_LAYER23:\n\t\treturn NETDEV_LAG_HASH_L23;\n\tcase BOND_XMIT_POLICY_ENCAP23:\n\t\treturn NETDEV_LAG_HASH_E23;\n\tcase BOND_XMIT_POLICY_ENCAP34:\n\t\treturn NETDEV_LAG_HASH_E34;\n\tcase BOND_XMIT_POLICY_VLAN_SRCMAC:\n\t\treturn NETDEV_LAG_HASH_VLAN_SRCMAC;\n\tdefault:\n\t\treturn NETDEV_LAG_HASH_UNKNOWN;\n\t}\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":148299,"func":"set_default_router_id(data_t *data, char *new_id)\n{\n\tif (!new_id || !new_id[0])\n\t\treturn;\n\n\tdata->router_id = MALLOC(strlen(new_id)+1);\n\tstrcpy(data->router_id, new_id);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":161040,"func":"  Handle<GlobalObject> global_object() {\n    return Handle<GlobalObject>(context()->global_object());\n  }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":508261,"func":"void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int err)\n\t{\n\tctx->error=err;\n\t}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":118801,"func":"static int wait_for_vfork_done(struct task_struct *child,\n\t\t\t\tstruct completion *vfork)\n{\n\tint killed;\n\n\tfreezer_do_not_count();\n\tcgroup_enter_frozen();\n\tkilled = wait_for_completion_killable(vfork);\n\tcgroup_leave_frozen(false);\n\tfreezer_count();\n\n\tif (killed) {\n\t\ttask_lock(child);\n\t\tchild->vfork_done = NULL;\n\t\ttask_unlock(child);\n\t}\n\n\tput_task_struct(child);\n\treturn killed;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":10037,"func":"void OfflineAudioDestinationHandler::NotifyComplete() {\n  DCHECK(IsMainThread());\n \n   render_thread_.reset();\n \n   if (Context() && Context()->GetExecutionContext())\n     Context()->FireCompletionEvent();\n}\n","target":1,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":460781,"func":"gboolean reds_config_get_agent_mouse(const RedsState *reds)\n{\n    return reds->config->agent_mouse;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":34689,"func":"int splice_grow_spd(const struct pipe_inode_info *pipe, struct splice_pipe_desc *spd)\n{\n\tunsigned int buffers = ACCESS_ONCE(pipe->buffers);\n\n\tspd->nr_pages_max = buffers;\n\tif (buffers <= PIPE_DEF_BUFFERS)\n\t\treturn 0;\n\n\tspd->pages = kmalloc(buffers * sizeof(struct page *), GFP_KERNEL);\n\tspd->partial = kmalloc(buffers * sizeof(struct partial_page), GFP_KERNEL);\n\n\tif (spd->pages && spd->partial)\n\t\treturn 0;\n\n\tkfree(spd->pages);\n\tkfree(spd->partial);\n\treturn -ENOMEM;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":378545,"func":"static int wsgi_find_path_info(const char *uri, const char *path_info)\n{\n    int lu = strlen(uri);\n    int lp = strlen(path_info);\n\n    while (lu-- && lp-- && uri[lu] == path_info[lp]) {\n        if (path_info[lp] == '\/') {\n            while (lu && uri[lu-1] == '\/') lu--;\n        }\n    }\n\n    if (lu == -1) {\n        lu = 0;\n    }\n\n    while (uri[lu] != '\\0' && uri[lu] != '\/') {\n        lu++;\n    }\n    return lu;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":303797,"func":"static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)\n{\n\tint err;\n\tstruct netdev_phys_item_id ppid;\n\n\terr = dev_get_phys_port_id(dev, &ppid);\n\tif (err) {\n\t\tif (err == -EOPNOTSUPP)\n\t\t\treturn 0;\n\t\treturn err;\n\t}\n\n\tif (nla_put(skb, IFLA_PHYS_PORT_ID, ppid.id_len, ppid.id))\n\t\treturn -EMSGSIZE;\n\n\treturn 0;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":58082,"func":"#else","target":0,"code_token_length":1,"total_token_length":237,"max_tokens_setting":512}
+{"idx":494036,"func":"static void SerializeGltfBufferBin(Buffer &buffer, json &o,\n                                   std::vector<unsigned char> &binBuffer) {\n  SerializeNumberProperty(\"byteLength\", buffer.data.size(), o);\n  binBuffer = buffer.data;\n\n  if (buffer.name.size()) SerializeStringProperty(\"name\", buffer.name, o);\n\n  if (buffer.extras.Type() != NULL_TYPE) {\n    SerializeValue(\"extras\", buffer.extras, o);\n  }\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":101961,"func":"static ssize_t ipmi_interrupts_enabled_show(struct device *dev,\n\t\t\t\t\t    struct device_attribute *attr,\n\t\t\t\t\t    char *buf)\n{\n\tstruct smi_info *smi_info = dev_get_drvdata(dev);\n\tint enabled = smi_info->io.irq && !smi_info->interrupt_disabled;\n\n\treturn snprintf(buf, 10, \"%d\\n\", enabled);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":187321,"func":"void PictureLayer::ClearClient() {\n  client_ = nullptr;\n  UpdateDrawsContent(HasDrawableContent());\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":164682,"func":"bool PictureLayer::SupportsLCDText() const {\n  return true;\n}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":519375,"func":"  void set_stored_in_db_flag(bool stored)\n  {\n    stored_in_db= stored;\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":460821,"func":"static void reds_late_initialization(RedsState *reds)\n{\n    \/\/ do only once\n    if (reds->late_initialization_done) {\n        return;\n    }\n\n    \/\/ create stream channels for streaming devices\n    for (auto dev: reds->char_devices) {\n        auto stream_dev = dynamic_cast<StreamDevice*>(dev.get());\n        if (stream_dev) {\n            stream_dev->create_channel();\n        }\n    }\n    reds->late_initialization_done = true;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":211971,"func":"void TabStripGtk::UpdateDropIndex(GdkDragContext* context, gint x, gint y) {\n  x = gtk_util::MirroredXCoordinate(tabstrip_.get(), x);\n  for (int i = GetMiniTabCount(); i < GetTabCount(); ++i) {\n    TabGtk* tab = GetTabAt(i);\n    gfx::Rect bounds = tab->GetNonMirroredBounds(tabstrip_.get());\n    const int tab_max_x = bounds.x() + bounds.width();\n    const int hot_width = bounds.width() \/ kTabEdgeRatioInverse;\n    if (x < tab_max_x) {\n      if (x < bounds.x() + hot_width)\n        SetDropIndex(i, true);\n      else if (x >= tab_max_x - hot_width)\n        SetDropIndex(i + 1, true);\n      else\n        SetDropIndex(i, false);\n      return;\n    }\n  }\n\n  SetDropIndex(GetTabCount(), true);\n}\n","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":341810,"func":"int ffurl_register_protocol(URLProtocol *protocol, int size)\n\n{\n\n    URLProtocol **p;\n\n    if (size < sizeof(URLProtocol)) {\n\n        URLProtocol *temp = av_mallocz(sizeof(URLProtocol));\n\n        memcpy(temp, protocol, size);\n\n        protocol = temp;\n\n    }\n\n    p = &first_protocol;\n\n    while (*p != NULL)\n\n        p = &(*p)->next;\n\n    *p             = protocol;\n\n    protocol->next = NULL;\n\n    return 0;\n\n}\n","target":1,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":200367,"func":"void RenderViewImpl::OnEnumerateDirectoryResponse(\n    int id,\n    const std::vector<base::FilePath>& paths) {\n  if (!enumeration_completions_[id])\n    return;\n\n  WebVector<WebString> ws_file_names(paths.size());\n  for (size_t i = 0; i < paths.size(); ++i)\n    ws_file_names[i] = webkit_base::FilePathToWebString(paths[i]);\n\n  enumeration_completions_[id]->didChooseFile(ws_file_names);\n  enumeration_completions_.erase(id);\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":115835,"func":"\n      _cimg_math_parser():\n        code(_code),p_code_end(0),p_break((CImg<ulongT>*)(cimg_ulong)-2),\n        imgin(CImg<T>::const_empty()),listin(CImgList<T>::const_empty()),\n        imgout(CImg<T>::empty()),listout(CImgList<T>::empty()),\n        img_stats(_img_stats),list_stats(_list_stats),list_median(_list_median),debug_indent(0),\n        result_dim(0),break_type(0),constcache_size(0),is_parallelizable(true),is_fill(false),need_input_copy(false),\n        rng(0),calling_function(0) {\n        mem.assign(1 + _cimg_mp_slot_c,1,1,1,0); \/\/ Allow to skip 'is_empty?' test in operator()()\n        result = mem._data;","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":77201,"func":"static int fill_umem_pbl_tbl(struct ib_umem *umem, u64 *pbl_tbl_orig,\n\t\t\t     int page_shift)\n{\n\tu64 *pbl_tbl = pbl_tbl_orig;\n\tu64 page_size =  BIT_ULL(page_shift);\n\tstruct ib_block_iter biter;\n\n\trdma_for_each_block(umem->sg_head.sgl, &biter, umem->nmap, page_size)\n\t\t*pbl_tbl++ = rdma_block_iter_dma_address(&biter);\n\n\treturn pbl_tbl - pbl_tbl_orig;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":121316,"func":"void rose_start_idletimer(struct sock *sk)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\n\tsk_stop_timer(sk, &rose->idletimer);\n\n\tif (rose->idle > 0) {\n\t\trose->idletimer.function = rose_idletimer_expiry;\n\t\trose->idletimer.expires  = jiffies + rose->idle;\n\n\t\tsk_reset_timer(sk, &rose->idletimer, rose->idletimer.expires);\n\t}\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":449976,"func":"static int hdr_validate_tokens(struct crypt_device *cd, json_object *hdr_jobj)\n{\n\tjson_object *jobj;\n\n\tif (!json_object_object_get_ex(hdr_jobj, \"tokens\", &jobj)) {\n\t\tlog_dbg(cd, \"Missing tokens section.\");\n\t\treturn 1;\n\t}\n\n\tjson_object_object_foreach(jobj, key, val) {\n\t\tif (!numbered(cd, \"Token\", key))\n\t\t\treturn 1;\n\t\tif (LUKS2_token_validate(cd, hdr_jobj, val, key))\n\t\t\treturn 1;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":52670,"func":"irc_server_set_send_default_tags (const char *tags)\n{\n    irc_server_send_default_tags = tags;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":503793,"func":"  StreamInfoImpl(\n      TimeSource& time_source,\n      const Network::ConnectionInfoProviderSharedPtr& downstream_connection_info_provider,\n      FilterState::LifeSpan life_span = FilterState::LifeSpan::FilterChain)\n      : StreamInfoImpl(absl::nullopt, time_source, downstream_connection_info_provider,\n                       std::make_shared<FilterStateImpl>(life_span)) {}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":244860,"func":" PrintWebViewHelper::~PrintWebViewHelper() {}\n","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":244900,"func":"bool InputDispatcher::InputState::isNeutral() const {\n return mKeyMementos.isEmpty() && mMotionMementos.isEmpty();\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":185036,"func":"int GetPageCountFromSettingsDictionary(const DictionaryValue& settings) {\n  int count = 0;\n  const ListValue* page_range_array;\n  if (settings.GetList(printing::kSettingPageRange, &page_range_array)) {\n    for (size_t index = 0; index < page_range_array->GetSize(); ++index) {\n      const DictionaryValue* dict;\n      if (!page_range_array->GetDictionary(index, &dict))\n        continue;\n\n      printing::PageRange range;\n      if (!dict->GetInteger(printing::kSettingPageRangeFrom, &range.from) ||\n          !dict->GetInteger(printing::kSettingPageRangeTo, &range.to)) {\n        continue;\n      }\n      count += (range.to - range.from) + 1;\n    }\n  }\n  return count;\n}\n","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":474755,"func":"struct nci_conn_info *nci_get_conn_info_by_conn_id(struct nci_dev *ndev,\n\t\t\t\t\t\t   int conn_id)\n{\n\tstruct nci_conn_info *conn_info;\n\n\tlist_for_each_entry(conn_info, &ndev->conn_info_list, list) {\n\t\tif (conn_info->conn_id == conn_id)\n\t\t\treturn conn_info;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":407461,"func":"static void parse_chanmodes(IRC_SERVER_REC *server, const char *sptr)\n{\n\tmode_func_t *modefuncs[] = {\n\t\tmodes_type_a,\n\t\tmodes_type_b,\n\t\tmodes_type_c,\n\t\tmodes_type_d\n\t};\n\tchar **item, **chanmodes;\n\tint i;\n\n\tchanmodes = g_strsplit(sptr, \",\", 5); \/* ignore extras *\/\n\n\tfor (i = 0, item = chanmodes; *item != NULL && i < 4; item++, i++) {\n\t\tunsigned char *p = (unsigned char*) *item;\n\t\twhile (*p != '\\0') {\n\t\t\tserver->modes[(int)*p].func = modefuncs[i];\n\t\t\tp++;\n\t\t}\n\t}\n\n\tg_strfreev(chanmodes);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":230192,"func":"LinearHistogram::LinearHistogram(const std::string& name,\n                                 Sample minimum,\n                                 Sample maximum,\n                                 const BucketRanges* ranges)\n    : Histogram(name, minimum, maximum, ranges) {\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":253511,"func":"    TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {\n  return WindowOpenDisposition::CURRENT_TAB;\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":427643,"func":"static int rowidWrite(Rtree *pRtree, sqlite3_int64 iRowid, sqlite3_int64 iNode){\n  sqlite3_bind_int64(pRtree->pWriteRowid, 1, iRowid);\n  sqlite3_bind_int64(pRtree->pWriteRowid, 2, iNode);\n  sqlite3_step(pRtree->pWriteRowid);\n  return sqlite3_reset(pRtree->pWriteRowid);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":74147,"func":"static GFINLINE void av1dmx_update_cts(GF_AV1DmxCtx *ctx)\n{\n\tassert(ctx->cur_fps.num);\n\tassert(ctx->cur_fps.den);\n\n\tif (ctx->timescale) {\n\t\tu64 inc = ctx->cur_fps.den;\n\t\tinc *= ctx->timescale;\n\t\tinc \/= ctx->cur_fps.num;\n\t\tctx->cts += inc;\n\t} else {\n\t\tctx->cts += ctx->cur_fps.den;\n\t}\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":23056,"func":"static int cond_continue ( i_ctx_t * i_ctx_p ) {\n os_ptr op = osp ;\n es_ptr ep = esp ;\n int code ;\n check_type ( * op , t_boolean ) ;\n if ( op -> value . boolval ) {\n array_get ( imemory , ep , 1L , ep ) ;\n esfile_check_cache ( ) ;\n code = o_pop_estack ;\n }\n else if ( r_size ( ep ) > 2 ) {\n const ref_packed * elts = ep -> value . packed ;\n check_estack ( 2 ) ;\n r_dec_size ( ep , 2 ) ;\n elts = packed_next ( elts ) ;\n elts = packed_next ( elts ) ;\n ep -> value . packed = elts ;\n array_get ( imemory , ep , 0L , ep + 2 ) ;\n make_op_estack ( ep + 1 , cond_continue ) ;\n esp = ep + 2 ;\n esfile_check_cache ( ) ;\n code = o_push_estack ;\n }\n else {\n esp = ep - 1 ;\n code = o_pop_estack ;\n }\n pop ( 1 ) ;\n return code ;\n }","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":273764,"func":"void Context::scriptLog(spdlog::level::level_enum level, absl::string_view message) {\n  switch (level) {\n  case spdlog::level::trace:\n    ENVOY_LOG(trace, \"wasm log{}: {}\", log_prefix(), message);\n    return;\n  case spdlog::level::debug:\n    ENVOY_LOG(debug, \"wasm log{}: {}\", log_prefix(), message);\n    return;\n  case spdlog::level::info:\n    ENVOY_LOG(info, \"wasm log{}: {}\", log_prefix(), message);\n    return;\n  case spdlog::level::warn:\n    ENVOY_LOG(warn, \"wasm log{}: {}\", log_prefix(), message);\n    return;\n  case spdlog::level::err:\n    ENVOY_LOG(error, \"wasm log{}: {}\", log_prefix(), message);\n    return;\n  case spdlog::level::critical:\n    ENVOY_LOG(critical, \"wasm log{}: {}\", log_prefix(), message);\n    return;\n  case spdlog::level::off:\n    NOT_IMPLEMENTED_GCOVR_EXCL_LINE;\n  }\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":233064,"func":"  SimpleGetHelperResult SimpleGetHelper(base::span<const MockRead> data_reads) {\n    MockWrite data_writes[] = {\n        MockWrite(\"GET \/ HTTP\/1.1\\r\\n\"\n                  \"Host: www.example.org\\r\\n\"\n                  \"Connection: keep-alive\\r\\n\\r\\n\"),\n    };\n\n    StaticSocketDataProvider reads(data_reads, data_writes);\n    StaticSocketDataProvider* data[] = {&reads};\n    SimpleGetHelperResult out = SimpleGetHelperForData(data);\n\n    EXPECT_EQ(CountWriteBytes(data_writes), out.total_sent_bytes);\n    return out;\n  }\n","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":398978,"func":"static int selinux_task_setnice(struct task_struct *p, int nice)\n{\n\treturn current_has_perm(p, PROCESS__SETSCHED);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":318755,"func":"static void v9fs_renameat(void *opaque)\n{\n    ssize_t err = 0;\n    size_t offset = 7;\n    V9fsPDU *pdu = opaque;\n    V9fsState *s = pdu->s;\n    int32_t olddirfid, newdirfid;\n    V9fsString old_name, new_name;\n    v9fs_string_init(&old_name);\n    v9fs_string_init(&new_name);\n    err = pdu_unmarshal(pdu, offset, \"dsds\", &olddirfid,\n                        &old_name, &newdirfid, &new_name);\n    if (err < 0) {\n    if (name_is_illegal(old_name.data) || name_is_illegal(new_name.data)) {\n        err = -ENOENT;\n    v9fs_path_write_lock(s);\n    err = v9fs_complete_renameat(pdu, olddirfid,\n                                 &old_name, newdirfid, &new_name);\n    v9fs_path_unlock(s);\n    if (!err) {\n        err = offset;\nout_err:\n    pdu_complete(pdu, err);\n    v9fs_string_free(&old_name);\n    v9fs_string_free(&new_name);","target":1,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":342550,"func":"static void gen_window_check1(DisasContext *dc, unsigned r1)\n\n{\n\n    if (dc->tb->flags & XTENSA_TBFLAG_EXCM) {\n\n        return;\n\n    }\n\n    if (option_enabled(dc, XTENSA_OPTION_WINDOWED_REGISTER) &&\n\n            r1 \/ 4 > dc->used_window) {\n\n        TCGv_i32 pc = tcg_const_i32(dc->pc);\n\n        TCGv_i32 w = tcg_const_i32(r1 \/ 4);\n\n\n\n        dc->used_window = r1 \/ 4;\n\n        gen_advance_ccount(dc);\n\n        gen_helper_window_check(cpu_env, pc, w);\n\n\n\n        tcg_temp_free(w);\n\n        tcg_temp_free(pc);\n\n    }\n\n}\n","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":26742,"func":"static int jbig2_decode_get_code ( Jbig2MmrCtx * mmr , const mmr_table_node * table , int initial_bits ) {\n uint32_t word = mmr -> word ;\n int table_ix = word >> ( 32 - initial_bits ) ;\n int val = table [ table_ix ] . val ;\n int n_bits = table [ table_ix ] . n_bits ;\n if ( n_bits > initial_bits ) {\n int mask = ( 1 << ( 32 - initial_bits ) ) - 1 ;\n table_ix = val + ( ( word & mask ) >> ( 32 - n_bits ) ) ;\n val = table [ table_ix ] . val ;\n n_bits = initial_bits + table [ table_ix ] . n_bits ;\n }\n jbig2_decode_mmr_consume ( mmr , n_bits ) ;\n return val ;\n }","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":517904,"func":"bool Item::check_type_can_return_time(const char *opname) const\n{\n  const Type_handler *handler= type_handler();\n  if (handler->can_return_time())\n    return false;\n  my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),\n           handler->name().ptr(), opname);\n  return true;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":105855,"func":"static int __init init_nfs_fs(void)\n{\n\tint err;\n\n\terr = nfsiod_start();\n\tif (err)\n\t\tgoto out6;\n\n\terr = nfs_fs_proc_init();\n\tif (err)\n\t\tgoto out5;\n\n\terr = nfs_init_nfspagecache();\n\tif (err)\n\t\tgoto out4;\n\n\terr = nfs_init_inodecache();\n\tif (err)\n\t\tgoto out3;\n\n\terr = nfs_init_readpagecache();\n\tif (err)\n\t\tgoto out2;\n\n\terr = nfs_init_writepagecache();\n\tif (err)\n\t\tgoto out1;\n\n\terr = nfs_init_directcache();\n\tif (err)\n\t\tgoto out0;\n\n#ifdef CONFIG_PROC_FS\n\trpc_proc_register(&nfs_rpcstat);\n#endif\n\tif ((err = register_nfs_fs()) != 0)\n\t\tgoto out;\n\treturn 0;\nout:\n#ifdef CONFIG_PROC_FS\n\trpc_proc_unregister(\"nfs\");\n#endif\n\tnfs_destroy_directcache();\nout0:\n\tnfs_destroy_writepagecache();\nout1:\n\tnfs_destroy_readpagecache();\nout2:\n\tnfs_destroy_inodecache();\nout3:\n\tnfs_destroy_nfspagecache();\nout4:\n\tnfs_fs_proc_exit();\nout5:\n\tnfsiod_stop();\nout6:\n\treturn err;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":360789,"func":"static AsyncURB *async_alloc(void)\n{\n    return (AsyncURB *) qemu_mallocz(sizeof(AsyncURB));\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":189117,"func":"void OMXCodec::addCodecSpecificData(const void *data, size_t size) {\n CodecSpecificData *specific =\n (CodecSpecificData *)malloc(sizeof(CodecSpecificData) + size - 1);\n\n    specific->mSize = size;\n    memcpy(specific->mData, data, size);\n\n    mCodecSpecificData.push(specific);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":194283,"func":"void Gfx::opEndMarkedContent(Object args[], int numArgs) {\n  if (mcStack)\n    popMarkedContent();\n  out->endMarkedContent(state);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":188755,"func":"void RenderViewImpl::FocusedNodeChanged(const WebNode& fromNode,\n                                        const WebNode& toNode) {\n  RenderFrameImpl* previous_frame = nullptr;\n  if (!fromNode.IsNull())\n    previous_frame =\n        RenderFrameImpl::FromWebFrame(fromNode.GetDocument().GetFrame());\n  RenderFrameImpl* new_frame = nullptr;\n  if (!toNode.IsNull())\n    new_frame = RenderFrameImpl::FromWebFrame(toNode.GetDocument().GetFrame());\n\n  if (previous_frame && previous_frame != new_frame)\n    previous_frame->FocusedNodeChanged(WebNode());\n  if (new_frame)\n    new_frame->FocusedNodeChanged(toNode);\n\n  if (main_render_frame_)\n    main_render_frame_->FocusedNodeChangedForAccessibility(toNode);\n}\n","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":155132,"func":"size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect)\n{\n  return _get_chars(screen, 1, str, len, rect);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":97622,"func":"GF_Err elst_Write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tu32 nb_entries;\n\tGF_EdtsEntry *p;\n\tGF_EditListBox *ptr = (GF_EditListBox *)s;\n\tif (!ptr) return GF_BAD_PARAM;\n\n\tnb_entries = gf_list_count(ptr->entryList);\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, nb_entries);\n\tfor (i = 0; i < nb_entries; i++ ) {\n\t\tp = (GF_EdtsEntry*)gf_list_get(ptr->entryList, i);\n\t\tif (ptr->version == 1) {\n\t\t\tgf_bs_write_u64(bs, p->segmentDuration);\n\t\t\tgf_bs_write_u64(bs, p->mediaTime);\n\t\t} else {\n\t\t\tgf_bs_write_u32(bs, (u32) p->segmentDuration);\n\t\t\tgf_bs_write_u32(bs, (s32) p->mediaTime);\n\t\t}\n\t\tgf_bs_write_u16(bs, p->mediaRate);\n\t\tgf_bs_write_u16(bs, 0);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":385772,"func":"AttVal *TY_(NewAttribute)( TidyDocImpl* doc )\n{\n    AttVal *av = (AttVal*) TidyDocAlloc( doc, sizeof(AttVal) );\n    TidyClearMemory( av, sizeof(AttVal) );\n    return av;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":202056,"func":"  void ProcessBackingStore(HeapObjectHeader* header) {\n     EXPECT_TRUE(header->IsValid());\n     EXPECT_TRUE(header->IsMarked());\n     header->Unmark();\n    GCInfoTable::Get()\n        .GCInfoFromIndex(header->GcInfoIndex())\n        ->trace_(this, header->Payload());\n   }\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":33376,"func":"static int madvise_free_single_vma(struct vm_area_struct *vma,\n\t\t\tunsigned long start_addr, unsigned long end_addr)\n{\n\tunsigned long start, end;\n\tstruct mm_struct *mm = vma->vm_mm;\n\tstruct mmu_gather tlb;\n\n\t\/* MADV_FREE works for only anon vma at the moment *\/\n\tif (!vma_is_anonymous(vma))\n\t\treturn -EINVAL;\n\n\tstart = max(vma->vm_start, start_addr);\n\tif (start >= vma->vm_end)\n\t\treturn -EINVAL;\n\tend = min(vma->vm_end, end_addr);\n\tif (end <= vma->vm_start)\n\t\treturn -EINVAL;\n\n\tlru_add_drain();\n\ttlb_gather_mmu(&tlb, mm, start, end);\n\tupdate_hiwater_rss(mm);\n\n\tmmu_notifier_invalidate_range_start(mm, start, end);\n\tmadvise_free_page_range(&tlb, vma, start, end);\n\tmmu_notifier_invalidate_range_end(mm, start, end);\n\ttlb_finish_mmu(&tlb, start, end);\n\n\treturn 0;\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":177341,"func":"void GeolocationInspectorAgent::setGeolocationOverride(ErrorString* error, const double* latitude, const double* longitude, const double* accuracy)\n{\n    GeolocationPosition* position = m_controller->lastPosition();\n    if (!m_geolocationOverridden && position)\n        m_platformGeolocationPosition = position;\n\n    m_geolocationOverridden = true;\n    if (latitude && longitude && accuracy)\n        m_geolocationPosition = GeolocationPosition::create(currentTimeMS(), *latitude, *longitude, *accuracy);\n    else\n        m_geolocationPosition.clear();\n\n    m_controller->positionChanged(0); \/\/ Kick location update.\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":334238,"func":"static int vm_can_run(void)\n\n{\n\n    if (powerdown_requested)\n\n        return 0;\n\n    if (reset_requested)\n\n        return 0;\n\n    if (shutdown_requested)\n\n        return 0;\n\n    if (debug_requested)\n\n        return 0;\n\n    return 1;\n\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":206366,"func":"void QuicClientPromisedInfo::Reset(QuicRstStreamErrorCode error_code) {\n  QuicClientPushPromiseIndex::Delegate* delegate = client_request_delegate_;\n  session_->ResetPromised(id_, error_code);\n  session_->DeletePromised(this);\n  if (delegate) {\n    delegate->OnRendezvousResult(nullptr);\n  }\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":169633,"func":"void JSTestNamedConstructorNamedConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)\n{\n    Base::finishCreation(globalObject);\n    ASSERT(inherits(&s_info));\n    putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestNamedConstructorPrototype::self(exec, globalObject), None);\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":360322,"func":"compare_by_display_name (NautilusFile *file_1, NautilusFile *file_2)\n{\n\tconst char *name_1, *name_2;\n\tconst char *key_1, *key_2;\n\tgboolean sort_last_1, sort_last_2;\n\tint compare;\n\n\tname_1 = nautilus_file_peek_display_name (file_1);\n\tname_2 = nautilus_file_peek_display_name (file_2);\n\n\tsort_last_1 = name_1[0] == SORT_LAST_CHAR1 || name_1[0] == SORT_LAST_CHAR2;\n\tsort_last_2 = name_2[0] == SORT_LAST_CHAR1 || name_2[0] == SORT_LAST_CHAR2;\n\n\tif (sort_last_1 && !sort_last_2) {\n\t\tcompare = +1;\n\t} else if (!sort_last_1 && sort_last_2) {\n\t\tcompare = -1;\n\t} else {\n\t\tkey_1 = nautilus_file_peek_display_name_collation_key (file_1);\n\t\tkey_2 = nautilus_file_peek_display_name_collation_key (file_2);\n\t\tcompare = strcmp (key_1, key_2);\n\t}\n\n\treturn compare;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":448563,"func":"zonetype_fromconfig(const cfg_obj_t *map) {\n\tconst cfg_obj_t *obj = NULL;\n\tisc_result_t result;\n\n\tresult = cfg_map_get(map, \"type\", &obj);\n\tINSIST(result == ISC_R_SUCCESS && obj != NULL);\n\treturn (ns_config_getzonetype(obj));\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":65664,"func":"int FLTIsBinaryComparisonFilterType(const char *pszValue)\n{\n  if (pszValue) {\n    if (strcasecmp(pszValue, \"PropertyIsEqualTo\") == 0 ||\n        strcasecmp(pszValue, \"PropertyIsNotEqualTo\") == 0 ||\n        strcasecmp(pszValue, \"PropertyIsLessThan\") == 0 ||\n        strcasecmp(pszValue, \"PropertyIsGreaterThan\") == 0 ||\n        strcasecmp(pszValue, \"PropertyIsLessThanOrEqualTo\") == 0 ||\n        strcasecmp(pszValue, \"PropertyIsGreaterThanOrEqualTo\") == 0)\n      return MS_TRUE;\n  }\n\n  return MS_FALSE;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":139229,"func":"int tty_init_termios(struct tty_struct *tty)\n{\n\tstruct ktermios *tp;\n\tint idx = tty->index;\n\n\ttp = tty->driver->termios[idx];\n\tif (tp == NULL) {\n\t\ttp = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);\n\t\tif (tp == NULL)\n\t\t\treturn -ENOMEM;\n\t\tmemcpy(tp, &tty->driver->init_termios,\n\t\t\t\t\t\tsizeof(struct ktermios));\n\t\ttty->driver->termios[idx] = tp;\n\t}\n\ttty->termios = tp;\n\ttty->termios_locked = tp + 1;\n\n\t\/* Compatibility until drivers always set this *\/\n\ttty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios);\n\ttty->termios->c_ospeed = tty_termios_baud_rate(tty->termios);\n\treturn 0;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":213694,"func":"PHP_FUNCTION(pg_free_result)\n{\n\tzval *result;\n\tpgsql_result_handle *pg_result;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"r\", &result) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, &result, -1, \"PostgreSQL result\", le_result);\n\tif (Z_LVAL_P(result) == 0) {\n\t\tRETURN_FALSE;\n\t}\n\tzend_list_delete(Z_RESVAL_P(result));\n\tRETURN_TRUE;\n}\n","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":190968,"func":"void SoundTriggerHwService::recognitionCallback(struct sound_trigger_recognition_event *event,\n void *cookie)\n{\n Module *module = (Module *)cookie;\n if (module == NULL) {\n return;\n }\n    sp<SoundTriggerHwService> service = module->service().promote();\n if (service == 0) {\n return;\n }\n\n    service->sendRecognitionEvent(event, module);\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":285036,"func":"void ResourceDispatcherHostImpl::OnCancelRequest(int request_id) {\n  CancelRequest(filter_->child_id(), request_id, true);\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":253706,"func":"void MockGenerateRandom(uint8_t* output, size_t n) {\n  memset(output, 0xaa, n);\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":203138,"func":"bool IsEqualForTesting(const SendTabToSelfEntry& entry,\n                       const sync_pb::SendTabToSelfSpecifics& specifics) {\n  return (\n      entry.GetGUID() == specifics.guid() &&\n      entry.GetURL() == specifics.url() &&\n      entry.GetTitle() == specifics.title() &&\n      entry.GetDeviceName() == specifics.device_name() &&\n      entry.GetTargetDeviceSyncCacheGuid() ==\n          specifics.target_device_sync_cache_guid() &&\n      specifics.shared_time_usec() ==\n          entry.GetSharedTime().ToDeltaSinceWindowsEpoch().InMicroseconds() &&\n      specifics.navigation_time_usec() == entry.GetOriginalNavigationTime()\n                                              .ToDeltaSinceWindowsEpoch()\n                                              .InMicroseconds());\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":147655,"func":"static bool rt_cache_valid(const struct rtable *rt)\n{\n\treturn\trt &&\n\t\trt->dst.obsolete == DST_OBSOLETE_FORCE_CHK &&\n\t\t!rt_is_expired(rt);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":373228,"func":"_PUBLIC_ int strcmp_safe(const char *s1, const char *s2)\n{\n\tif (s1 == s2) {\n\t\treturn 0;\n\t}\n\tif (s1 == NULL || s2 == NULL) {\n\t\treturn s1?-1:1;\n\t}\n\treturn strcmp(s1, s2);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":18586,"func":"static const char * mgs_readable_cvm ( mgs_client_verification_method_e m ) {\n switch ( m ) {\n case mgs_cvm_unset : return \"unset\" ;\n case mgs_cvm_cartel : return \"cartel\" ;\n case mgs_cvm_msva : return \"msva\" ;\n }\n return \"unknown\" ;\n }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":380215,"func":"static int ZEND_FASTCALL  ZEND_FETCH_DIM_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op1;\n\tzval *dim = _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC);\n\tzval **container = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);\n\n\tif (IS_VAR == IS_VAR && !container) {\n\t\tzend_error_noreturn(E_ERROR, \"Cannot use string offset as an array\");\n\t}\n\tzend_fetch_dimension_address_read(&EX_T(opline->result.u.var), container, dim, 0, BP_VAR_IS TSRMLS_CC);\n\n\tif (free_op1.var) {zval_ptr_dtor(&free_op1.var);};\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":173063,"func":"void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) {\n  if (mode == accessibility_mode_)\n    return;\n\n  if (IsNeverVisible())\n    return;\n\n  accessibility_mode_ = mode;\n\n  for (FrameTreeNode* node : frame_tree_.Nodes()) {\n    UpdateAccessibilityModeOnFrame(node->current_frame_host());\n    RenderFrameHost* pending_frame_host =\n        node->render_manager()->pending_frame_host();\n    if (pending_frame_host)\n      UpdateAccessibilityModeOnFrame(pending_frame_host);\n  }\n}\n","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":88153,"func":"static void reload_tss(struct kvm_vcpu *vcpu)\n{\n\tint cpu = raw_smp_processor_id();\n\n\tstruct svm_cpu_data *sd = per_cpu(svm_data, cpu);\n\tsd->tss_desc->type = 9; \/* available 32\/64-bit TSS *\/\n\tload_TR_desc();\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":133633,"func":"\nvoid svhd_box_del(GF_Box *s)\n{\n\tGF_SphericalVideoInfoBox *ptr = (GF_SphericalVideoInfoBox *)s;\n\tif (ptr->string) gf_free(ptr->string);\n\tgf_free(s);","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":446137,"func":"virDomainHostdevSubsysSCSIClear(virDomainHostdevSubsysSCSIPtr scsisrc)\n{\n    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)\n        virDomainHostdevSubsysSCSIiSCSIClear(&scsisrc->u.iscsi);\n    else\n        VIR_FREE(scsisrc->u.host.adapter);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":111853,"func":"const char *configEnumGetName(configEnum *ce, int val) {\n    while(ce->name != NULL) {\n        if (ce->val == val) return ce->name;\n        ce++;\n    }\n    return NULL;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":367410,"func":"static int selinux_file_mmap(struct file *file, unsigned long reqprot,\n\t\t\t     unsigned long prot, unsigned long flags,\n\t\t\t     unsigned long addr, unsigned long addr_only)\n{\n\tint rc = 0;\n\tu32 sid = current_sid();\n\n\t\/*\n\t * notice that we are intentionally putting the SELinux check before\n\t * the secondary cap_file_mmap check.  This is such a likely attempt\n\t * at bad behaviour\/exploit that we always want to get the AVC, even\n\t * if DAC would have also denied the operation.\n\t *\/\n\tif (addr < CONFIG_LSM_MMAP_MIN_ADDR) {\n\t\trc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,\n\t\t\t\t  MEMPROTECT__MMAP_ZERO, NULL);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\t\/* do DAC check on address space usage *\/\n\trc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);\n\tif (rc || addr_only)\n\t\treturn rc;\n\n\tif (selinux_checkreqprot)\n\t\tprot = reqprot;\n\n\treturn file_map_prot_check(file, prot,\n\t\t\t\t   (flags & MAP_TYPE) == MAP_SHARED);\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":12917,"func":"int basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)\n{\n\tzval **login, **password;\n\n        zval **login, **password;\n \n        if (zend_hash_find(Z_OBJPROP_P(this_ptr), \"_login\", sizeof(\"_login\"), (void **)&login) == SUCCESS &&\n                       !zend_hash_exists(Z_OBJPROP_P(this_ptr), \"_digest\", sizeof(\"_digest\"))) {\n                unsigned char* buf;\n                int len;\n                smart_str auth = {0};\n \n                smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));\n                smart_str_appendc(&auth, ':');\n               if (zend_hash_find(Z_OBJPROP_P(this_ptr), \"_password\", sizeof(\"_password\"), (void **)&password) == SUCCESS) {\n                        smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));\n                }\n                smart_str_0(&auth);\n\t\tefree(buf);\n\t\tsmart_str_free(&auth);\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n","target":1,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":113731,"func":"ca_by_subjectpubkey(X509_STORE *ctx, uint8_t *sig, size_t siglen)\n{\n\tSTACK_OF(X509_OBJECT)\t*h;\n\tX509_OBJECT\t\t*xo;\n\tX509\t\t\t*ca;\n\tint\t\t\t i;\n\tunsigned int\t\t len;\n\tuint8_t\t\t\t md[EVP_MAX_MD_SIZE];\n\n\th = ctx->objs;\n\n\tfor (i = 0; i < sk_X509_OBJECT_num(h); i++) {\n\t\txo = sk_X509_OBJECT_value(h, i);\n\t\tif (xo->type != X509_LU_X509)\n\t\t\tcontinue;\n\n\t\tca = xo->data.x509;\n\t\tlen = sizeof(md);\n\t\tca_subjectpubkey_digest(ca, md, &len);\n\n\t\tif (len == siglen && memcmp(md, sig, len) == 0)\n\t\t\treturn (ca);\n\t}\n\n\treturn (NULL);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":68142,"func":"GF_Err rssr_Read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_ReceivedSsrcBox *ptr = (GF_ReceivedSsrcBox *)s;\n\tptr->ssrc = gf_bs_read_u32(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":172759,"func":"BackgroundContents* BackgroundContentsService::GetAppBackgroundContents(\n    const string16& application_id) {\n  BackgroundContentsMap::const_iterator it = contents_map_.find(application_id);\n  return (it != contents_map_.end()) ? it->second.contents : NULL;\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":522402,"func":"TABLE_LIST *st_select_lex::end_nested_join(THD *thd)\n{\n  TABLE_LIST *ptr;\n  NESTED_JOIN *nested_join;\n  DBUG_ENTER(\"end_nested_join\");\n\n  DBUG_ASSERT(embedding);\n  ptr= embedding;\n  join_list= ptr->join_list;\n  embedding= ptr->embedding;\n  nested_join= ptr->nested_join;\n  nested_join->nest_type= 0;\n  if (nested_join->join_list.elements == 1)\n  {\n    TABLE_LIST *embedded= nested_join->join_list.head();\n    join_list->pop();\n    embedded->join_list= join_list;\n    embedded->embedding= embedding;\n    join_list->push_front(embedded, thd->mem_root);\n    ptr= embedded;\n    embedded->lifted= 1;\n    if (embedded->nested_join)\n      embedded->nested_join->nest_type= 0;\n  }\n  else if (nested_join->join_list.elements == 0)\n  {\n    join_list->pop();\n    ptr= 0;                                     \/\/ return value\n  }\n  DBUG_RETURN(ptr);\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":181238,"func":"void RenderView::DidInitiatePaint() {\n  pepper_delegate_.ViewInitiatedPaint();\n\n  for (std::set<WebPluginDelegatePepper*>::iterator i =\n           current_oldstyle_pepper_plugins_.begin();\n       i != current_oldstyle_pepper_plugins_.end(); ++i)\n    (*i)->RenderViewInitiatedPaint();\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":470379,"func":"void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b) {\n    assert(b);\n\n    AVAHI_LLIST_REMOVE(AvahiSServiceTypeBrowser, browser, b->server->service_type_browsers, b);\n\n    if (b->record_browser)\n        avahi_s_record_browser_free(b->record_browser);\n\n    avahi_free(b->domain_name);\n    avahi_free(b);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":95051,"func":"static void tracked_request_end(BdrvTrackedRequest *req)\n\n{\n\n    if (req->serialising) {\n\n        req->bs->serialising_in_flight--;\n\n    }\n\n\n\n    QLIST_REMOVE(req, list);\n\n    qemu_co_queue_restart_all(&req->wait_queue);\n\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":375632,"func":"make_directory(const char *dir)\n{\n\tif (mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO) < 0)\n\t{\n\t\tfprintf(stderr, _(\"%s: could not create directory \\\"%s\\\": %s\\n\"),\n\t\t\t\tprogname, dir, strerror(errno));\n\t\texit(2);\n\t}\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":233084,"func":"bool ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Frame_Resource_Request* request)\n{\n    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, true);\n    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, true);\n\n    if (!smartData->api->navigation_policy_decision)\n        return true;\n\n    return smartData->api->navigation_policy_decision(smartData, request);\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":416798,"func":"void show_opcodes(struct pt_regs *regs, const char *loglvl)\n{\n#define PROLOGUE_SIZE 42\n#define EPILOGUE_SIZE 21\n#define OPCODE_BUFSIZE (PROLOGUE_SIZE + 1 + EPILOGUE_SIZE)\n\tu8 opcodes[OPCODE_BUFSIZE];\n\tunsigned long prologue = regs->ip - PROLOGUE_SIZE;\n\tbool bad_ip;\n\n\t\/*\n\t * Make sure userspace isn't trying to trick us into dumping kernel\n\t * memory by pointing the userspace instruction pointer at it.\n\t *\/\n\tbad_ip = user_mode(regs) &&\n\t\t__chk_range_not_ok(prologue, OPCODE_BUFSIZE, TASK_SIZE_MAX);\n\n\tif (bad_ip || probe_kernel_read(opcodes, (u8 *)prologue,\n\t\t\t\t\tOPCODE_BUFSIZE)) {\n\t\tprintk(\"%sCode: Bad RIP value.\\n\", loglvl);\n\t} else {\n\t\tprintk(\"%sCode: %\" __stringify(PROLOGUE_SIZE) \"ph <%02x> %\"\n\t\t       __stringify(EPILOGUE_SIZE) \"ph\\n\", loglvl, opcodes,\n\t\t       opcodes[PROLOGUE_SIZE], opcodes + PROLOGUE_SIZE + 1);\n\t}\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":130230,"func":"TEST_F(QuotedString_ExtractFrom_Tests, EscapedSolidus) {\n  whenInputIs(\"\\\"hello \\\\\/world\\\\\/\\\"\");\n  resultMustBe(\"hello \/world\/\");\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":209332,"func":"static PHP_FUNCTION(gzfile)\n{\n\tchar *filename;\n\tint filename_len;\n\tint flags = REPORT_ERRORS;\n\tchar buf[8192] = {0};\n\tregister int i = 0;\n\tlong use_include_path = 0;\n\tphp_stream *stream;\n\n\tif (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"p|l\", &filename, &filename_len, &use_include_path)) {\n\t\treturn;\n\t}\n\n\tif (use_include_path) {\n\t\tflags |= USE_PATH;\n\t}\n\n\t\/* using a stream here is a bit more efficient (resource wise) than php_gzopen_wrapper *\/\n\tstream = php_stream_gzopen(NULL, filename, \"rb\", flags, NULL, NULL STREAMS_CC TSRMLS_CC);\n\n\tif (!stream) {\n\t\t\/* Error reporting is already done by stream code *\/\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* Initialize return array *\/\n\tarray_init(return_value);\n\n\t\/* Now loop through the file and do the magic quotes thing if needed *\/\n\tmemset(buf, 0, sizeof(buf));\n\t    \n\twhile (php_stream_gets(stream, buf, sizeof(buf) - 1) != NULL) {\n\t\tadd_index_string(return_value, i++, buf, 1);\n\t}\n\tphp_stream_close(stream);\n}\n","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":306605,"func":"void CLASS eight_bit_load_raw()\n{\n  uchar *pixel;\n  unsigned row, col;\n\n  pixel = (uchar *) calloc (raw_width, sizeof *pixel);\n  merror (pixel, \"eight_bit_load_raw()\");\n#ifdef LIBRAW_LIBRARY_BUILD\n  try {\n#endif\n  for (row=0; row < raw_height; row++) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    if (fread (pixel, 1, raw_width, ifp) < raw_width) derror();\n    for (col=0; col < raw_width; col++)\n      RAW(row,col) = curve[pixel[col]];\n  }\n#ifdef LIBRAW_LIBRARY_BUILD\n  } catch(...) {\n    free (pixel);\n    throw;\n  }\n#endif\n  free (pixel);\n  maximum = curve[0xff];\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":25440,"func":"inline static HTTPKeepAlive is_header_keep_alive ( const HTTPVersion & http_version , const MIMEField * con_hdr ) {\n enum {\n CON_TOKEN_NONE = 0 , CON_TOKEN_KEEP_ALIVE , CON_TOKEN_CLOSE , }\n ;\n int con_token = CON_TOKEN_NONE ;\n HTTPKeepAlive keep_alive = HTTP_NO_KEEPALIVE ;\n if ( con_hdr ) {\n if ( con_hdr -> value_get_index ( \"keep-alive\" , 10 ) >= 0 ) con_token = CON_TOKEN_KEEP_ALIVE ;\n else if ( con_hdr -> value_get_index ( \"close\" , 5 ) >= 0 ) con_token = CON_TOKEN_CLOSE ;\n }\n if ( HTTPVersion ( 1 , 0 ) == http_version ) {\n keep_alive = ( con_token == CON_TOKEN_KEEP_ALIVE ) ? ( HTTP_KEEPALIVE ) : ( HTTP_NO_KEEPALIVE ) ;\n }\n else if ( HTTPVersion ( 1 , 1 ) == http_version ) {\n keep_alive = ( ( con_token == CON_TOKEN_KEEP_ALIVE ) || ( con_token == CON_TOKEN_NONE && HTTPVersion ( 1 , 1 ) == http_version ) ) ? ( HTTP_KEEPALIVE ) : ( HTTP_NO_KEEPALIVE ) ;\n }\n else {\n keep_alive = HTTP_NO_KEEPALIVE ;\n }\n return ( keep_alive ) ;\n }","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":280474,"func":"omx_video::omx_c2d_conv::omx_c2d_conv()\n{\n    c2dcc = NULL;\n    mLibHandle = NULL;\n    mConvertOpen = NULL;\n    mConvertClose = NULL;\n    src_format = NV12_128m;\n    pthread_mutex_init(&c_lock, NULL);\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":201990,"func":"bool OmniboxViewViews::TextAndUIDirectionMatch() const {\n  return (GetRenderText()->GetDisplayTextDirection() ==\n          base::i18n::RIGHT_TO_LEFT) == base::i18n::IsRTL();\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":124163,"func":"int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)\n{\n\tint nr_frames = 0;\n\tstruct nfc_llcp_local *local = sock->local;\n\n\tpr_debug(\"Remote ready %d tx queue len %d remote rw %d\",\n\t\t sock->remote_ready, skb_queue_len(&sock->tx_pending_queue),\n\t\t sock->remote_rw);\n\n\t\/* Try to queue some I frames for transmission *\/\n\twhile (sock->remote_ready &&\n\t       skb_queue_len(&sock->tx_pending_queue) < sock->remote_rw) {\n\t\tstruct sk_buff *pdu;\n\n\t\tpdu = skb_dequeue(&sock->tx_queue);\n\t\tif (pdu == NULL)\n\t\t\tbreak;\n\n\t\t\/* Update N(S)\/N(R) *\/\n\t\tnfc_llcp_set_nrns(sock, pdu);\n\n\t\tskb_queue_tail(&local->tx_queue, pdu);\n\t\tnr_frames++;\n\t}\n\n\treturn nr_frames;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":63679,"func":"g_NPN_ReleaseObject(NPObject *npobj)\n{\n  if (!thread_check()) {\n\tnpw_printf(\"WARNING: NPN_ReleaseObject not called from the main thread\\n\");\n\treturn;\n  }\n\t\n  if (npobj == NULL)\n\treturn;\n\n  if (rpc_method_invoke_possible(g_rpc_connection)) {\n\tD(bug(\"NPN_ReleaseObject <now>\\n\"));\n\tg_NPN_ReleaseObject_Now(npobj);\n  }\n  else {\n\tD(bug(\"NPN_ReleaseObject <delayed>\\n\"));\n\tg_NPN_ReleaseObject_Delayed(npobj);\n  }\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":463832,"func":"int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,\n\t\t\t    struct btrfs_root *root,\n\t\t\t    struct btrfs_path *path,\n\t\t\t    const struct btrfs_key *cpu_key, u32 *data_size,\n\t\t\t    int nr)\n{\n\tint ret = 0;\n\tint slot;\n\tint i;\n\tu32 total_size = 0;\n\tu32 total_data = 0;\n\n\tfor (i = 0; i < nr; i++)\n\t\ttotal_data += data_size[i];\n\n\ttotal_size = total_data + (nr * sizeof(struct btrfs_item));\n\tret = btrfs_search_slot(trans, root, cpu_key, path, total_size, 1);\n\tif (ret == 0)\n\t\treturn -EEXIST;\n\tif (ret < 0)\n\t\treturn ret;\n\n\tslot = path->slots[0];\n\tBUG_ON(slot < 0);\n\n\tsetup_items_for_insert(root, path, cpu_key, data_size, nr);\n\treturn 0;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":370156,"func":"int sctp_outq_is_empty(const struct sctp_outq *q)\n{\n\treturn q->empty;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":267671,"func":"  const Handle<StringPrimitive> &strPrim() const {\n    assert(isHandle_ && \"must be a handle\");\n    \/\/ Need to go through a variable to placate gcc4.9.\n    const char *buffer = strPrim_.buffer;\n    return *reinterpret_cast<const Handle<StringPrimitive> *>(buffer);\n  }","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":174473,"func":"   void DeleteTexture() {\n     if (texture_id_) {\n       host_context_->deleteTexture(texture_id_);\n      texture_id_ = 0;\n    }\n  }\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":503982,"func":"static int _sqlite3_escape_str(char *to, const char *from)\n{\n    char s;\n\n    while ( (s = *from++) != '\\0' ) {\n\tif (s == '\\'' || s == '\\\\') {\n\t    *to++ = '\\\\';\n\t}\n\t*to++ = s;\n    }\n    *to = '\\0';\n\n    return 0;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":268264,"func":"void imap_unmunge_mbox_name(bool unicode, char *s)\n{\n  imap_unquote_string(s);\n\n  char *buf = mutt_str_dup(s);\n  if (buf)\n  {\n    imap_utf_decode(unicode, &buf);\n    strncpy(s, buf, strlen(s));\n  }\n\n  FREE(&buf);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":175414,"func":"static void vrend_hw_emit_framebuffer_state(struct vrend_context *ctx)\n{\n   static const GLenum buffers[8] = {\n      GL_COLOR_ATTACHMENT0_EXT,\n      GL_COLOR_ATTACHMENT1_EXT,\n      GL_COLOR_ATTACHMENT2_EXT,\n      GL_COLOR_ATTACHMENT3_EXT,\n      GL_COLOR_ATTACHMENT4_EXT,\n      GL_COLOR_ATTACHMENT5_EXT,\n      GL_COLOR_ATTACHMENT6_EXT,\n      GL_COLOR_ATTACHMENT7_EXT,\n   };\n   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->sub->fb_id);\n\n   if (ctx->sub->nr_cbufs == 0) {\n      glReadBuffer(GL_NONE);\n      glDisable(GL_FRAMEBUFFER_SRGB_EXT);\n   } else {\n      struct vrend_surface *surf = NULL;\n      int i;\n      for (i = 0; i < ctx->sub->nr_cbufs; i++) {\n         if (ctx->sub->surf[i]) {\n            surf = ctx->sub->surf[i];\n         }\n      }\n      if (util_format_is_srgb(surf->format)) {\n         glEnable(GL_FRAMEBUFFER_SRGB_EXT);\n      } else {\n         glDisable(GL_FRAMEBUFFER_SRGB_EXT);\n      }\n   }\n   glDrawBuffers(ctx->sub->nr_cbufs, buffers);\n}\n","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":267002,"func":"static inline int mxf_read_utf16_string(AVIOContext *pb, int size, char** str, int be)\n\n{\n\n    int ret;\n\n    size_t buf_size;\n\n\n\n    if (size < 0)\n\n        return AVERROR(EINVAL);\n\n\n\n    buf_size = size + size \/ 2 + 1;\n\n    *str = av_malloc(buf_size);\n\n    if (!*str)\n\n        return AVERROR(ENOMEM);\n\n\n\n    if (be)\n\n        ret = avio_get_str16be(pb, size, *str, buf_size);\n\n    else\n\n        ret = avio_get_str16le(pb, size, *str, buf_size);\n\n\n\n    if (ret < 0) {\n\n        av_freep(str);\n\n        return ret;\n\n    }\n\n\n\n    return ret;\n\n}\n","target":1,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":210703,"func":"  bool IsMarked() const {\n    return HeapObjectHeader::FromPayload(this)->IsMarked();\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":236585,"func":"  AutoLockOnValidThread(base::Lock& lock, base::ThreadChecker* thread_checker)\n      : auto_lock_(lock) {\n    DCHECK(!thread_checker || thread_checker->CalledOnValidThread());\n  }\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":327353,"func":"static DWORD WINAPI do_suspend(LPVOID opaque)\n\n{\n\n    GuestSuspendMode *mode = opaque;\n\n    DWORD ret = 0;\n\n\n\n    if (!SetSuspendState(*mode == GUEST_SUSPEND_MODE_DISK, TRUE, TRUE)) {\n\n        slog(\"failed to suspend guest, %s\", GetLastError());\n\n        ret = -1;\n\n    }\n\n    g_free(mode);\n\n    return ret;\n\n}\n","target":1,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":130203,"func":"static int unlock_futex_pi(u32 __user *uaddr, u32 uval)\n{\n\tu32 oldval;\n\n\t\/*\n\t * There is no waiter, so we unlock the futex. The owner died\n\t * bit has not to be preserved here. We are the owner:\n\t *\/\n\toldval = cmpxchg_futex_value_locked(uaddr, uval, 0);\n\n\tif (oldval == -EFAULT)\n\t\treturn oldval;\n\tif (oldval != uval)\n\t\treturn -EAGAIN;\n\n\treturn 0;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":28885,"func":"static int pack_options_allow_reuse ( void ) {\n return allow_ofs_delta ;\n }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":346754,"func":"static int tstats_open(struct inode *inode, struct file *filp)\n{\n\treturn single_open(filp, tstats_show, NULL);\n}","target":1,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":4628,"func":"QStringList JlCompress::extractDir(QuaZip &zip, const QString &dir)\n{\n    if(!zip.open(QuaZip::mdUnzip)) {\n        return QStringList();\n    }\n\n    QDir directory(dir);\n    QStringList extracted;\n    if (!zip.goToFirstFile()) {\n        return QStringList();\n    }\n    do {\n        QString name = zip.getCurrentFileName();\n        QString absFilePath = directory.absoluteFilePath(name);\n        if (!extractFile(&zip, \"\", absFilePath)) {\n            removeFile(extracted);\n            return QStringList();\n        }\n        extracted.append(absFilePath);\n    } while (zip.goToNextFile());\n\n    \/\/ Chiudo il file zip\n    zip.close();\n    if(zip.getZipError()!=0) {\n        removeFile(extracted);\n        return QStringList();\n    }\n\n    return extracted;\n}","target":1,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":292561,"func":"static int bell(void *user)\n{\n  VTermScreen *screen = user;\n\n  if(screen->callbacks && screen->callbacks->bell)\n    return (*screen->callbacks->bell)(screen->cbdata);\n\n  return 0;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":368813,"func":"xsltTemplateProcess(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, xmlNodePtr node) {\n    if (node == NULL)\n\treturn(NULL);\n    \n    return(0);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":53293,"func":"static int binder_inc_node(struct binder_node *node, int strong, int internal,\n\t\t\t   struct list_head *target_list)\n{\n\tint ret;\n\n\tbinder_node_inner_lock(node);\n\tret = binder_inc_node_nilocked(node, strong, internal, target_list);\n\tbinder_node_inner_unlock(node);\n\n\treturn ret;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":166868,"func":"EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec)\n{\n    JSValue thisValue = exec->hostThisValue();\n    if (!thisValue.inherits(&JSTestObj::s_info))\n        return throwVMTypeError(exec);\n    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));\n    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);\n    TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n    ExceptionCode ec = 0;\n\n    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptStateObjException(exec, ec)));\n    setDOMException(exec, ec);\n    if (exec->hadException())\n        return JSValue::encode(jsUndefined());\n    return JSValue::encode(result);\n}\n","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":26145,"func":"static void dtap_gcc_term ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {\n guint32 curr_offset ;\n guint32 consumed ;\n guint curr_len ;\n curr_offset = offset ;\n curr_len = len ;\n ELEM_MAND_LV ( GSM_A_PDU_TYPE_DTAP , DE_GCC_CAUSE , NULL ) ;\n }","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":36989,"func":"UnicodeString::refCount() const {\n  return umtx_loadAcquire(*((u_atomic_int32_t *)fUnion.fFields.fArray - 1));\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":365783,"func":"g_file_delete(const char* filename)\n{\n#if defined(_WIN32)\n  return DeleteFileA(filename);\n#else\n  return unlink(filename) != -1;\n#endif\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":232422,"func":"SPL_METHOD(SplFileInfo, getBasename)\n{\n\tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tchar *fname, *suffix = 0;\n\tsize_t flen;\n\tint slen = 0, path_len;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"|s\", &suffix, &slen) == FAILURE) {\n\t\treturn;\n\t}\n\n\tspl_filesystem_object_get_path(intern, &path_len TSRMLS_CC);\n\n\tif (path_len && path_len < intern->file_name_len) {\n\t\tfname = intern->file_name + path_len + 1;\n\t\tflen = intern->file_name_len - (path_len + 1);\n\t} else {\n\t\tfname = intern->file_name;\n\t\tflen = intern->file_name_len;\n\t}\n\n\tphp_basename(fname, flen, suffix, slen, &fname, &flen TSRMLS_CC);\n \n \tRETURN_STRINGL(fname, flen, 0);\n }\n","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":352569,"func":"\tswitch (yych) {\n\t\tcase 'a': goto yy42;\n\t\tdefault: goto yy41;\n\t}","target":1,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":99734,"func":"isdn_net_close(struct net_device *dev)\n{\n\tstruct net_device *p;\n#ifdef CONFIG_ISDN_X25\n\tstruct concap_proto * cprot =\n\t\t((isdn_net_local *) netdev_priv(dev))->netdev->cprot;\n\t\/* printk(KERN_DEBUG \"isdn_net_close %s\\n\" , dev-> name ); *\/\n#endif\n\n#ifdef CONFIG_ISDN_X25\n\tif( cprot && cprot -> pops ) cprot -> pops -> close( cprot );\n#endif\n\tnetif_stop_queue(dev);\n\tp = MASTER_TO_SLAVE(dev);\n\tif (p) {\n\t\t\/* If this interface has slaves, stop them also *\/\n\t\twhile (p) {\n#ifdef CONFIG_ISDN_X25\n\t\t\tcprot = ((isdn_net_local *) netdev_priv(p))\n\t\t\t\t-> netdev -> cprot;\n\t\t\tif( cprot && cprot -> pops )\n\t\t\t\tcprot -> pops -> close( cprot );\n#endif\n\t\t\tisdn_net_hangup(p);\n\t\t\tp = MASTER_TO_SLAVE(p);\n\t\t}\n\t}\n\tisdn_net_hangup(dev);\n\tisdn_unlock_drivers();\n\treturn 0;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":269689,"func":"SWFInput_input_seek(SWFInput input, long offset, int whence)\n{\n\tif ( whence == SEEK_CUR )\n\t{\n\t\tif ( offset >= 0 )\n\t\t\tinput->offset = min(input->length, input->offset + offset);\n\t\telse\n\t\t\tinput->offset = max(0, input->offset + offset);\n\t}\n\n\telse if ( whence == SEEK_END )\n\t\tinput->offset = max(0, input->length - offset);\n\n\telse if ( whence == SEEK_SET )\n\t\tinput->offset = min(input->length, offset);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":37038,"func":"static int tg3_phy_reset_chanpat(struct tg3 *tp)\n{\n\tint chan;\n\n\tfor (chan = 0; chan < 4; chan++) {\n\t\tint i;\n\n\t\ttg3_writephy(tp, MII_TG3_DSP_ADDRESS,\n\t\t\t     (chan * 0x2000) | 0x0200);\n\t\ttg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0002);\n\t\tfor (i = 0; i < 6; i++)\n\t\t\ttg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000);\n\t\ttg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0202);\n\t\tif (tg3_wait_macro_done(tp))\n\t\t\treturn -EBUSY;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":60078,"func":"  ~TensorSliceReaderTable() override {\n    delete table_;\n    delete file_;\n  }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":63770,"func":"S_ssc_anything(pTHX_ regnode_ssc *ssc)\n{\n    \/* Set the SSC 'ssc' to match an empty string or any code point *\/\n\n    PERL_ARGS_ASSERT_SSC_ANYTHING;\n\n    assert(is_ANYOF_SYNTHETIC(ssc));\n\n    \/* mortalize so won't leak *\/\n    ssc->invlist = sv_2mortal(_add_range_to_invlist(NULL, 0, UV_MAX));\n    ANYOF_FLAGS(ssc) |= SSC_MATCHES_EMPTY_STRING;  \/* Plus matches empty *\/\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":370607,"func":"htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {\n    const xmlChar *name;\n    xmlChar *val = NULL;\n\n    *value = NULL;\n    name = htmlParseHTMLName(ctxt);\n    if (name == NULL) {\n\thtmlParseErr(ctxt, XML_ERR_NAME_REQUIRED,\n\t             \"error parsing attribute name\\n\", NULL, NULL);\n        return(NULL);\n    }\n\n    \/*\n     * read the value\n     *\/\n    SKIP_BLANKS;\n    if (CUR == '=') {\n        NEXT;\n\tSKIP_BLANKS;\n\tval = htmlParseAttValue(ctxt);\n    }\n\n    *value = val;\n    return(name);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":293707,"func":"void dm_set_mdptr(struct mapped_device *md, void *ptr)\n{\n\tmd->interface_ptr = ptr;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":93157,"func":"int sr_select_speed(struct cdrom_device_info *cdi, int speed)\n{\n\tScsi_CD *cd = cdi->handle;\n\tstruct packet_command cgc;\n\n\tif (speed == 0)\n\t\tspeed = 0xffff;\t\/* set to max *\/\n\telse\n\t\tspeed *= 177;\t\/* Nx to kbyte\/s *\/\n\n\tmemset(&cgc, 0, sizeof(struct packet_command));\n\tcgc.cmd[0] = GPCMD_SET_SPEED;\t\/* SET CD SPEED *\/\n\tcgc.cmd[2] = (speed >> 8) & 0xff;\t\/* MSB for speed (in kbytes\/sec) *\/\n\tcgc.cmd[3] = speed & 0xff;\t\/* LSB *\/\n\tcgc.data_direction = DMA_NONE;\n\tcgc.timeout = IOCTL_TIMEOUT;\n\n\tif (sr_do_ioctl(cd, &cgc))\n\t\treturn -EIO;\n\treturn 0;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":116327,"func":"void DeepScanLineInputFile::multiPartInitialize(InputPartData* part)\n{\n    \n    _data->_streamData = part->mutex;\n    _data->memoryMapped = _data->_streamData->is->isMemoryMapped();\n    _data->version = part->version;\n    \n    initialize(part->header);\n    \n    _data->lineOffsets = part->chunkOffsets;\n    \n    _data->partNumber = part->partNumber;\n    \n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":486590,"func":"void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt)\n{\n    QemuInputHandlerState *s;\n\n    qemu_input_event_trace(src, evt);\n\n    \/* pre processing *\/\n    if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) {\n            qemu_input_transform_abs_rotate(evt);\n    }\n\n    \/* send event *\/\n    s = qemu_input_find_handler(1 << evt->type, src);\n    if (!s) {\n        return;\n    }\n    s->handler->event(s->dev, src, evt);\n    s->events++;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":223337,"func":"handle_nxt_resume(struct ofconn *ofconn, const struct ofp_header *oh)\n{\n    struct ofproto *ofproto = ofconn_get_ofproto(ofconn);\n    struct ofputil_packet_in_private pin;\n    enum ofperr error;\n\n    error = ofputil_decode_packet_in_private(oh, false,\n                                             ofproto_get_tun_tab(ofproto),\n                                             &ofproto->vl_mff_map, &pin, NULL,\n                                             NULL);\n    if (error) {\n        return error;\n    }\n\n    error = (ofproto->ofproto_class->nxt_resume\n             ? ofproto->ofproto_class->nxt_resume(ofproto, &pin)\n             : OFPERR_NXR_NOT_SUPPORTED);\n\n    ofputil_packet_in_private_destroy(&pin);\n\n    return error;\n}\n","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":84956,"func":"bool imap_code(const char *s)\n{\n  return (cmd_status(s) == IMAP_CMD_OK);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":318012,"func":"static void incomplete_class_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) \/* {{{ *\/\n{\n\tincomplete_class_message(object, E_NOTICE TSRMLS_CC);\n}\n\/* }}} *\/\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":517062,"func":"int st_select_lex_unit::save_union_explain_part2(Explain_query *output)\n{\n  Explain_union *eu= output->get_union(first_select()->select_number);\n  if (fake_select_lex)\n  {\n    for (SELECT_LEX_UNIT *unit= fake_select_lex->first_inner_unit(); \n         unit; unit= unit->next_unit())\n    {\n      if (!(unit->item && unit->item->eliminated))\n      {\n        eu->add_child(unit->first_select()->select_number);\n      }\n    }\n    fake_select_lex->join->explain= &eu->fake_select_lex_explain;\n  }\n  return 0;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":435539,"func":"\nstatic int ql_create_send_free_list(struct ql3_adapter *qdev)\n{\n\tstruct ql_tx_buf_cb *tx_cb;\n\tint i;\n\tstruct ob_mac_iocb_req *req_q_curr = qdev->req_q_virt_addr;\n\n\t\/* Create free list of transmit buffers *\/\n\tfor (i = 0; i < NUM_REQ_Q_ENTRIES; i++) {\n\n\t\ttx_cb = &qdev->tx_buf[i];\n\t\ttx_cb->skb = NULL;\n\t\ttx_cb->queue_entry = req_q_curr;\n\t\treq_q_curr++;\n\t\ttx_cb->oal = kmalloc(512, GFP_KERNEL);\n\t\tif (tx_cb->oal == NULL)\n\t\t\treturn -ENOMEM;\n\t}\n\treturn 0;","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":419681,"func":"static void server_cache_boot_id(Server *s) {\n        sd_id128_t id;\n        int r;\n\n        assert(s);\n\n        r = sd_id128_get_boot(&id);\n        if (r < 0)\n                return;\n\n        sd_id128_to_string(id, stpcpy(s->boot_id_field, \"_BOOT_ID=\"));\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":446111,"func":"virDomainChrGetDomainPtrs(const virDomainDef *vmdef,\n                          virDomainChrDeviceType type,\n                          const virDomainChrDef ***arrPtr,\n                          size_t *cntPtr)\n{\n    virDomainChrDef ***arrVar = NULL;\n    size_t *cntVar = NULL;\n\n    \/* Cast away const; we add it back in the final assignment.  *\/\n    if (virDomainChrGetDomainPtrsInternal((virDomainDefPtr) vmdef, type,\n                                          &arrVar, &cntVar) < 0) {\n        *arrPtr = NULL;\n        *cntPtr = 0;\n    } else {\n        *arrPtr = (const virDomainChrDef **) *arrVar;\n        *cntPtr = *cntVar;\n    }\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":341561,"func":"static inline int signed_shift(int i, int shift) {\n\n    if (shift > 0)\n\n        return i << shift;\n\n    return i >> -shift;\n\n}\n","target":1,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":182238,"func":" PHP_FUNCTION(snmpset)\n {\n\tphp_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, SNMP_VERSION_1);\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":437246,"func":"static int ttusb_dec_set_interface(struct ttusb_dec *dec,\n\t\t\t\t   enum ttusb_dec_interface interface)\n{\n\tint result = 0;\n\tu8 b[] = { 0x05 };\n\n\tif (interface != dec->interface) {\n\t\tswitch (interface) {\n\t\tcase TTUSB_DEC_INTERFACE_INITIAL:\n\t\t\tresult = usb_set_interface(dec->udev, 0, 0);\n\t\t\tbreak;\n\t\tcase TTUSB_DEC_INTERFACE_IN:\n\t\t\tresult = ttusb_dec_send_command(dec, 0x80, sizeof(b),\n\t\t\t\t\t\t\tb, NULL, NULL);\n\t\t\tif (result)\n\t\t\t\treturn result;\n\t\t\tresult = usb_set_interface(dec->udev, 0, 8);\n\t\t\tbreak;\n\t\tcase TTUSB_DEC_INTERFACE_OUT:\n\t\t\tresult = usb_set_interface(dec->udev, 0, 1);\n\t\t\tbreak;\n\t\t}\n\n\t\tif (result)\n\t\t\treturn result;\n\n\t\tdec->interface = interface;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":28447,"func":"int TSHttpTxnBackgroundFillStarted ( TSHttpTxn txnp ) {\n sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;\n HttpSM * s = ( HttpSM * ) txnp ;\n return ( s -> background_fill == BACKGROUND_FILL_STARTED ) ;\n }","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":65098,"func":"word32 SetBitString(word32 len, byte unusedBits, byte* output)\n{\n    word32 idx = 0;\n\n    if (output)\n        output[idx] = ASN_BIT_STRING;\n    idx++;\n\n    idx += SetLength(len + 1, output ? output + idx : NULL);\n    if (output)\n        output[idx] = unusedBits;\n    idx++;\n\n    return idx;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":492182,"func":"deleteDependencyRecordsFor(Oid classId, Oid objectId,\n\t\t\t\t\t\t   bool skipExtensionDeps)\n{\n\tlong\t\tcount = 0;\n\tRelation\tdepRel;\n\tScanKeyData key[2];\n\tSysScanDesc scan;\n\tHeapTuple\ttup;\n\n\tdepRel = table_open(DependRelationId, RowExclusiveLock);\n\n\tScanKeyInit(&key[0],\n\t\t\t\tAnum_pg_depend_classid,\n\t\t\t\tBTEqualStrategyNumber, F_OIDEQ,\n\t\t\t\tObjectIdGetDatum(classId));\n\tScanKeyInit(&key[1],\n\t\t\t\tAnum_pg_depend_objid,\n\t\t\t\tBTEqualStrategyNumber, F_OIDEQ,\n\t\t\t\tObjectIdGetDatum(objectId));\n\n\tscan = systable_beginscan(depRel, DependDependerIndexId, true,\n\t\t\t\t\t\t\t  NULL, 2, key);\n\n\twhile (HeapTupleIsValid(tup = systable_getnext(scan)))\n\t{\n\t\tif (skipExtensionDeps &&\n\t\t\t((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)\n\t\t\tcontinue;\n\n\t\tCatalogTupleDelete(depRel, &tup->t_self);\n\t\tcount++;\n\t}\n\n\tsystable_endscan(scan);\n\n\ttable_close(depRel, RowExclusiveLock);\n\n\treturn count;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":332357,"func":"static void adb_mouse_realizefn(DeviceState *dev, Error **errp)\n\n{\n\n    MouseState *s = ADB_MOUSE(dev);\n\n    ADBMouseClass *amc = ADB_MOUSE_GET_CLASS(dev);\n\n\n\n    amc->parent_realize(dev, errp);\n\n\n\n    qemu_add_mouse_event_handler(adb_mouse_event, s, 0, \"QEMU ADB Mouse\");\n\n}\n","target":1,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":170093,"func":"WebMediaPlayer::NetworkState WebMediaPlayerImpl::GetNetworkState() const {\n  DCHECK(main_task_runner_->BelongsToCurrentThread());\n  return network_state_;\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":386574,"func":"\n\/* {{{ Timezone Cache functions *\/\nstatic timelib_tzinfo *php_date_parse_tzfile(char *formal_tzname, const timelib_tzdb *tzdb TSRMLS_DC)\n{\n\ttimelib_tzinfo *tzi, **ptzi;\n\n\tif(!DATEG(tzcache)) {\n\t\tALLOC_HASHTABLE(DATEG(tzcache));\n\t\tzend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0);\n\t}\n\n\tif (zend_hash_find(DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void **) &ptzi) == SUCCESS) {\n\t\treturn *ptzi;\n\t}\n\n\ttzi = timelib_parse_tzfile(formal_tzname, tzdb);\n\tif (tzi) {\n\t\tzend_hash_add(DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void *) &tzi, sizeof(timelib_tzinfo*), NULL);\n\t}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":85642,"func":"static void sync_entity_load_avg(struct sched_entity *se)\n{\n\tstruct cfs_rq *cfs_rq = cfs_rq_of(se);\n\tu64 last_update_time;\n\n\tlast_update_time = cfs_rq_last_update_time(cfs_rq);\n\t__update_load_avg_blocked_se(last_update_time, se);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":307491,"func":"void UsbChooserContext::OnDeviceRemoved(\n    device::mojom::UsbDeviceInfoPtr device_info) {\n  DCHECK(device_info);\n\n  for (auto& observer : observer_list_)\n    observer.OnDeviceRemoved(*device_info);\n\n  for (auto& map_entry : ephemeral_devices_)\n    map_entry.second.erase(device_info->guid);\n\n  ephemeral_dicts_.erase(device_info->guid);\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":461045,"func":"static void gic_dist_writew(void *opaque, hwaddr offset,\n                            uint32_t value, MemTxAttrs attrs)\n{\n    gic_dist_writeb(opaque, offset, value & 0xff, attrs);\n    gic_dist_writeb(opaque, offset + 1, value >> 8, attrs);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":418313,"func":"static void dump_status(struct req_state *s, int status,\n\t\t\tconst char *status_name)\n{\n  s->formatter->set_status(status, status_name);\n  try {\n    RESTFUL_IO(s)->send_status(status, status_name);\n  } catch (rgw::io::Exception& e) {\n    ldout(s->cct, 0) << \"ERROR: s->cio->send_status() returned err=\"\n                     << e.what() << dendl;\n  }\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":198146,"func":"status_t NuMediaExtractor::getSampleMeta(sp<MetaData> *sampleMeta) {\n Mutex::Autolock autoLock(mLock);\n\n *sampleMeta = NULL;\n\n ssize_t minIndex = fetchTrackSamples();\n\n if (minIndex < 0) {\n return ERROR_END_OF_STREAM;\n }\n\n TrackInfo *info = &mSelectedTracks.editItemAt(minIndex);\n *sampleMeta = info->mSample->meta_data();\n\n return OK;\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":272207,"func":"static PHP_MSHUTDOWN_FUNCTION(session) \/* {{{ *\/\n{\n\tUNREGISTER_INI_ENTRIES();\n\n#ifdef HAVE_LIBMM\n\tPHP_MSHUTDOWN(ps_mm) (SHUTDOWN_FUNC_ARGS_PASSTHRU);\n#endif\n\n\t\/* reset rfc1867 callbacks *\/\n\tphp_session_rfc1867_orig_callback = NULL;\n\tif (php_rfc1867_callback == php_session_rfc1867_callback) {\n\t\tphp_rfc1867_callback = NULL;\n\t}\n\n\tps_serializers[PREDEFINED_SERIALIZERS].name = NULL;\n\tmemset(&ps_modules[PREDEFINED_MODULES], 0, (MAX_MODULES-PREDEFINED_MODULES)*sizeof(ps_module *));\n\n\treturn SUCCESS;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":463551,"func":"\nstatic void io_wq_submit_work(struct io_wq_work *work)\n{\n\tstruct io_kiocb *req = container_of(work, struct io_kiocb, work);\n\tstruct io_kiocb *timeout;\n\tint ret = 0;\n\n\ttimeout = io_prep_linked_timeout(req);\n\tif (timeout)\n\t\tio_queue_linked_timeout(timeout);\n\n\tif (work->flags & IO_WQ_WORK_CANCEL)\n\t\tret = -ECANCELED;\n\n\tif (!ret) {\n\t\tdo {\n\t\t\tret = io_issue_sqe(req, 0);\n\t\t\t\/*\n\t\t\t * We can get EAGAIN for polled IO even though we're\n\t\t\t * forcing a sync submission from here, since we can't\n\t\t\t * wait for request slots on the block side.\n\t\t\t *\/\n\t\t\tif (ret != -EAGAIN)\n\t\t\t\tbreak;\n\t\t\tcond_resched();\n\t\t} while (1);\n\t}\n\n\t\/* avoid locking problems by failing it from a clean context *\/\n\tif (ret) {\n\t\t\/* io-wq is going to take one down *\/\n\t\trefcount_inc(&req->refs);\n\t\tio_req_task_queue_fail(req, ret);\n\t}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":10619,"func":"hash_foreach_mangle_dict_of_strings (gpointer key, gpointer val, gpointer user_data)\n{\n  GHashTable *out = (GHashTable*) user_data;\n  GHashTable *in_dict = (GHashTable *) val;\n  HashAndString *data = g_new0 (HashAndString, 1);\n  data->string = (gchar*) key;\n  data->hash = g_hash_table_new_full (g_str_hash, g_str_equal,\n                                            g_free, g_free);\n  g_hash_table_foreach (in_dict, hash_foreach_prepend_string, data);\n  g_hash_table_insert(out, g_strdup ((gchar*) key), data->hash);\n}\n","target":1,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":90815,"func":"int set_encryption_filter(const char* input)\n{\n    if(input == NULL) return 1;\n\n    if(strlen(input) < 3) return 1;\n\n    if(strcasecmp(input, \"opn\") == 0)\n        G.f_encrypt |= STD_OPN;\n\n    if(strcasecmp(input, \"wep\") == 0)\n        G.f_encrypt |= STD_WEP;\n\n    if(strcasecmp(input, \"wpa\") == 0)\n    {\n        G.f_encrypt |= STD_WPA;\n        G.f_encrypt |= STD_WPA2;\n    }\n\n    if(strcasecmp(input, \"wpa1\") == 0)\n        G.f_encrypt |= STD_WPA;\n\n    if(strcasecmp(input, \"wpa2\") == 0)\n        G.f_encrypt |= STD_WPA2;\n\n    return 0;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":486446,"func":"ossl_cipher_set_iv(VALUE self, VALUE iv)\n{\n    EVP_CIPHER_CTX *ctx;\n\n    StringValue(iv);\n    GetCipher(self, ctx);\n\n    if (RSTRING_LEN(iv) < EVP_CIPHER_CTX_iv_length(ctx))\n        ossl_raise(eCipherError, \"iv length too short\");\n\n    if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1)\n\tossl_raise(eCipherError, NULL);\n\n    return iv;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":190473,"func":"void UniqueElementData::addAttribute(const QualifiedName& attributeName, const AtomicString& value)\n{\n    m_attributeVector.append(Attribute(attributeName, value));\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":14098,"func":"void WebContentsImpl::RunJavaScriptDialog(RenderFrameHost* render_frame_host,\n                                          const base::string16& message,\n                                          const base::string16& default_prompt,\n                                           const GURL& frame_url,\n                                           JavaScriptDialogType dialog_type,\n                                           IPC::Message* reply_msg) {\n  bool suppress_this_message =\n      ShowingInterstitialPage() || !delegate_ ||\n      delegate_->ShouldSuppressDialogs(this) ||\n      !delegate_->GetJavaScriptDialogManager(this);\n\n  if (!suppress_this_message) {\n    is_showing_javascript_dialog_ = true;\n    dialog_manager_ = delegate_->GetJavaScriptDialogManager(this);\n    dialog_manager_->RunJavaScriptDialog(\n        this, frame_url, dialog_type, message, default_prompt,\n        base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this),\n                   render_frame_host->GetProcess()->GetID(),\n                   render_frame_host->GetRoutingID(), reply_msg, false),\n        &suppress_this_message);\n  }\n\n  if (suppress_this_message) {\n    OnDialogClosed(render_frame_host->GetProcess()->GetID(),\n                   render_frame_host->GetRoutingID(), reply_msg,\n                   true, false, base::string16());\n  }\n}\n","target":1,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":304315,"func":"static bool HHVM_METHOD(Memcache, close) {\n  auto data = Native::data<MemcacheData>(this_);\n  memcached_quit(&data->m_memcache);\n  return true;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":259582,"func":"u32 gf_isom_get_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber)\n{\n\tGF_TrackBox *trak;\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak) return 0;\n\treturn trak->Media->information->sampleTable->trackPriority;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":91136,"func":"static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)\n{\n\tstruct gfs2_inode *ip = GFS2_I(file->f_mapping->host);\n\n\tif (!(file->f_flags & O_NOATIME) &&\n\t    !IS_NOATIME(&ip->i_inode)) {\n\t\tstruct gfs2_holder i_gh;\n\t\tint error;\n\n\t\tgfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);\n\t\terror = gfs2_glock_nq(&i_gh);\n\t\tif (error == 0) {\n\t\t\tfile_accessed(file);\n\t\t\tgfs2_glock_dq(&i_gh);\n\t\t}\n\t\tgfs2_holder_uninit(&i_gh);\n\t\tif (error)\n\t\t\treturn error;\n\t}\n\tvma->vm_ops = &gfs2_vm_ops;\n\tvma->vm_flags |= VM_CAN_NONLINEAR;\n\n\treturn 0;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":361221,"func":"void reply_findclose(struct smb_request *req)\n{\n\tint dptr_num;\n\tstruct smbd_server_connection *sconn = smbd_server_conn;\n\n\tSTART_PROFILE(SMBfindclose);\n\n\tif (req->wct < 1) {\n\t\treply_nterror(req, NT_STATUS_INVALID_PARAMETER);\n\t\tEND_PROFILE(SMBfindclose);\n\t\treturn;\n\t}\n\n\tdptr_num = SVALS(req->vwv+0, 0);\n\n\tDEBUG(3,(\"reply_findclose, dptr_num = %d\\n\", dptr_num));\n\n\tdptr_close(sconn, &dptr_num);\n\n\treply_outbuf(req, 0, 0);\n\n\tDEBUG(3,(\"SMBfindclose dptr_num = %d\\n\", dptr_num));\n\n\tEND_PROFILE(SMBfindclose);\n\treturn;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":331328,"func":"static int find_pte64 (mmu_ctx_t *ctx, int h, int rw)\n\n{\n\n    return _find_pte(ctx, 1, h, rw);\n\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":122094,"func":"void btrfs_test_destroy_inode(struct inode *inode)\n{\n\tbtrfs_drop_extent_cache(inode, 0, (u64)-1, 0);\n\tkmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":67893,"func":"raptor_turtle_writer_increase_indent(raptor_turtle_writer *turtle_writer)\n{\n  turtle_writer->depth += turtle_writer->indent;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":378043,"func":"struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *tab)\n{\n\tstruct qdisc_rate_table *rtab;\n\n\tif (tab == NULL || r->rate == 0 || r->cell_log == 0 ||\n\t    nla_len(tab) != TC_RTAB_SIZE)\n\t\treturn NULL;\n\n\tfor (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) {\n\t\tif (!memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) &&\n\t\t    !memcmp(&rtab->data, nla_data(tab), 1024)) {\n\t\t\trtab->refcnt++;\n\t\t\treturn rtab;\n\t\t}\n\t}\n\n\trtab = kmalloc(sizeof(*rtab), GFP_KERNEL);\n\tif (rtab) {\n\t\trtab->rate = *r;\n\t\trtab->refcnt = 1;\n\t\tmemcpy(rtab->data, nla_data(tab), 1024);\n\t\tif (r->linklayer == TC_LINKLAYER_UNAWARE)\n\t\t\tr->linklayer = __detect_linklayer(r, rtab->data);\n\t\trtab->next = qdisc_rtab_list;\n\t\tqdisc_rtab_list = rtab;\n\t}\n\treturn rtab;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":233712,"func":"void HTMLMediaElement::stopPeriodicTimers() {\n  m_progressEventTimer.stop();\n  m_playbackProgressTimer.stop();\n  m_checkViewportIntersectionTimer.stop();\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":515467,"func":"void Http2Session::HandleAltSvcFrame(const nghttp2_frame* frame) {\n  if (!(js_fields_->bitfield & (1 << kSessionHasAltsvcListeners))) return;\n  Isolate* isolate = env()->isolate();\n  HandleScope scope(isolate);\n  Local<Context> context = env()->context();\n  Context::Scope context_scope(context);\n\n  int32_t id = GetFrameID(frame);\n\n  nghttp2_extension ext = frame->ext;\n  nghttp2_ext_altsvc* altsvc = static_cast<nghttp2_ext_altsvc*>(ext.payload);\n  Debug(this, \"handling altsvc frame\");\n\n  Local<Value> argv[3] = {\n    Integer::New(isolate, id),\n    OneByteString(isolate, altsvc->origin, altsvc->origin_len),\n    OneByteString(isolate, altsvc->field_value, altsvc->field_value_len)\n  };\n\n  MakeCallback(env()->http2session_on_altsvc_function(),\n               arraysize(argv), argv);\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":212341,"func":"void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t)\n{\n    X509_VERIFY_PARAM_set_time(ctx->param, t);\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":72246,"func":"static struct dentry *vfat_mount(struct file_system_type *fs_type,\n\t\t       int flags, const char *dev_name,\n\t\t       void *data)\n{\n\treturn mount_bdev(fs_type, flags, dev_name, data, vfat_fill_super);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":185947,"func":"void SocketStream::set_addresses(const AddressList& addresses) {\n  addresses_ = addresses;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":1011,"func":"void mt_init ( mtrand * mt , uint32_t seed ) {\n int i ;\n mt -> mt_buffer_ [ 0 ] = seed ;\n mt -> mt_index_ = MT_LEN ;\n for ( i = 1 ;\n i < MT_LEN ;\n i ++ ) {\n mt -> mt_buffer_ [ i ] = ( 1812433253UL * ( mt -> mt_buffer_ [ i - 1 ] ^ ( mt -> mt_buffer_ [ i - 1 ] >> 30 ) ) + i ) ;\n }\n }","target":1,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":155419,"func":"MONGO_EXPORT void gridfile_writer_init( gridfile *gfile, gridfs *gfs,\n                                        const char *remote_name, const char *content_type ) {\n    gfile->gfs = gfs;\n\n    bson_oid_gen( &( gfile->id ) );\n    gfile->chunk_num = 0;\n    gfile->length = 0;\n    gfile->pending_len = 0;\n    gfile->pending_data = NULL;\n\n    gfile->remote_name = ( char * )bson_malloc( strlen( remote_name ) + 1 );\n    strcpy( ( char * )gfile->remote_name, remote_name );\n\n    gfile->content_type = ( char * )bson_malloc( strlen( content_type ) + 1 );\n    strcpy( ( char * )gfile->content_type, content_type );\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":338652,"func":"static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,\n\n                              int width, int height)\n\n{\n\n    int src_wrap, x, y;\n\n    int r, g, b;\n\n    uint8_t *lum, *cb, *cr;\n\n    const uint8_t *p;\n\n\n\n    lum = dst->data[0];\n\n    cb = dst->data[1];\n\n    cr = dst->data[2];\n\n\n\n    src_wrap = src->linesize[0] - width * BPP;\n\n    p = src->data[0];\n\n    for(y=0;y<height;y++) {\n\n        for(x=0;x<width;x++) {\n\n            RGB_IN(r, g, b, p);\n\n            lum[0] = RGB_TO_Y(r, g, b);\n\n            cb[0] = RGB_TO_U(r, g, b, 0);\n\n            cr[0] = RGB_TO_V(r, g, b, 0);\n\n            cb++;\n\n            cr++;\n\n            lum++;\n\n        }\n\n        p += src_wrap;\n\n        lum += dst->linesize[0] - width;\n\n        cb += dst->linesize[1] - width;\n\n        cr += dst->linesize[2] - width;\n\n    }\n\n}\n","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":256289,"func":" SPL_METHOD(DirectoryIterator, getFilename)\n {\n \tspl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n \tif (zend_parse_parameters_none() == FAILURE) {\n \t\treturn;\n \t}\n\n\tRETURN_STRING(intern->u.dir.entry.d_name, 1);\n}\n","target":1,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":494462,"func":"start_unicast_message(struct neighbour *neigh, int type, int len)\n{\n    if(unicast_neighbour) {\n        if(neigh != unicast_neighbour ||\n           unicast_buffered + len + 2 >=\n           MIN(UNICAST_BUFSIZE, babel_get_if_nfo(neigh->ifp)->bufsize))\n            flush_unicast(0);\n    }\n    if(!unicast_buffer)\n        unicast_buffer = malloc(UNICAST_BUFSIZE);\n    if(!unicast_buffer) {\n        flog_err(EC_BABEL_MEMORY, \"malloc(unicast_buffer): %s\",\n\t\t  safe_strerror(errno));\n        return -1;\n    }\n\n    unicast_neighbour = neigh;\n\n    unicast_buffer[unicast_buffered++] = type;\n    unicast_buffer[unicast_buffered++] = len;\n    return 1;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":380679,"func":"varsearch(struct block *l, struct tbl **vpp, const char *vn, uint32_t h)\n{\n\tregister struct tbl *vp;\n\n\tif (l) {\n varsearch_loop:\n\t\tif ((vp = ktsearch(&l->vars, vn, h)) != NULL)\n\t\t\tgoto varsearch_out;\n\t\tif (l->next != NULL) {\n\t\t\tl = l->next;\n\t\t\tgoto varsearch_loop;\n\t\t}\n\t}\n\tvp = NULL;\n varsearch_out:\n\t*vpp = vp;\n\treturn (l);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":366704,"func":"static int cap_xfrm_state_pol_flow_match(struct xfrm_state *x,\n\t\t\t\t\t struct xfrm_policy *xp,\n\t\t\t\t\t struct flowi *fl)\n{\n\treturn 1;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":389069,"func":"static void read_final_goodbye(int f_in, int f_out)\n{\n\tint i, iflags, xlen;\n\tuchar fnamecmp_type;\n\tchar xname[MAXPATHLEN];\n\n\tshutting_down = True;\n\n\tif (protocol_version < 29)\n\t\ti = read_int(f_in);\n\telse {\n\t\ti = read_ndx_and_attrs(f_in, f_out, &iflags, &fnamecmp_type, xname, &xlen);\n\t\tif (protocol_version >= 31 && i == NDX_DONE) {\n\t\t\tif (am_sender)\n\t\t\t\twrite_ndx(f_out, NDX_DONE);\n\t\t\telse {\n\t\t\t\tif (batch_gen_fd >= 0) {\n\t\t\t\t\twhile (read_int(batch_gen_fd) != NDX_DEL_STATS) {}\n\t\t\t\t\tread_del_stats(batch_gen_fd);\n\t\t\t\t}\n\t\t\t\twrite_int(f_out, NDX_DONE);\n\t\t\t}\n\t\t\ti = read_ndx_and_attrs(f_in, f_out, &iflags, &fnamecmp_type, xname, &xlen);\n\t\t}\n\t}\n\n\tif (i != NDX_DONE) {\n\t\trprintf(FERROR, \"Invalid packet at end of run (%d) [%s]\\n\",\n\t\t\ti, who_am_i());\n\t\texit_cleanup(RERR_PROTOCOL);\n\t}\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":24183,"func":"static bool check_for_exec ( const_os_ptr op ) {\n if ( ! r_has_attr ( op , a_execute ) && ref_type_uses_access ( r_type ( op ) ) && ( r_has_attr ( op , a_executable ) || ! r_has_type ( op , t_dictionary ) ) ) {\n return_error ( gs_error_invalidaccess ) ;\n }\n return 0 ;\n }","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":497744,"func":"bool Binary::remove(LOAD_COMMAND_TYPES type) {\n  bool removed = false;\n\n  while (LoadCommand* cmd = get(type)) {\n    removed = remove(*cmd);\n  }\n  return removed;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":337847,"func":"static BlockDriver *find_protocol(const char *filename)\n\n{\n\n    BlockDriver *drv1;\n\n    char protocol[128];\n\n    int len;\n\n    const char *p;\n\n\n\n#ifdef _WIN32\n\n    if (is_windows_drive(filename) ||\n\n        is_windows_drive_prefix(filename))\n\n        return bdrv_find_format(\"raw\");\n\n#endif\n\n    p = strchr(filename, ':');\n\n    if (!p)\n\n        return bdrv_find_format(\"raw\");\n\n    len = p - filename;\n\n    if (len > sizeof(protocol) - 1)\n\n        len = sizeof(protocol) - 1;\n\n    memcpy(protocol, filename, len);\n\n    protocol[len] = '\\0';\n\n    QLIST_FOREACH(drv1, &bdrv_drivers, list) {\n\n        if (drv1->protocol_name &&\n\n            !strcmp(drv1->protocol_name, protocol)) {\n\n            return drv1;\n\n        }\n\n    }\n\n    return NULL;\n\n}\n","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":454410,"func":"const char* ExpressionLn::getOpName() const {\n    return \"$ln\";\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":29175,"func":"static int selinux_is_sblabel_mnt ( struct super_block * sb ) {\n struct superblock_security_struct * sbsec = sb -> s_security ;\n return sbsec -> behavior == SECURITY_FS_USE_XATTR || sbsec -> behavior == SECURITY_FS_USE_TRANS || sbsec -> behavior == SECURITY_FS_USE_TASK || sbsec -> behavior == SECURITY_FS_USE_NATIVE || ! strcmp ( sb -> s_type -> name , \"sysfs\" ) || ! strcmp ( sb -> s_type -> name , \"pstore\" ) || ! strcmp ( sb -> s_type -> name , \"debugfs\" ) || ! strcmp ( sb -> s_type -> name , \"rootfs\" ) ;\n }","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":144216,"func":"std::string Box_clap::dump(Indent& indent) const\n{\n  std::ostringstream sstr;\n  sstr << Box::dump(indent);\n\n  sstr << indent << \"clean_aperture: \" << m_clean_aperture_width.numerator\n       << \"\/\" << m_clean_aperture_width.denominator << \" x \"\n       << m_clean_aperture_height.numerator << \"\/\"\n       << m_clean_aperture_height.denominator << \"\\n\";\n  sstr << indent << \"offset: \" << m_horizontal_offset.numerator << \"\/\"\n       << m_horizontal_offset.denominator << \" ; \"\n       << m_vertical_offset.numerator << \"\/\"\n       << m_vertical_offset.denominator << \"\\n\";\n\n  return sstr.str();\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":355073,"func":"SProcShmQueryVersion(client)\n    register ClientPtr\tclient;\n{\n    register int n;\n    REQUEST(xShmQueryVersionReq);\n\n    swaps(&stuff->length, n);\n    return ProcShmQueryVersion(client);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":499939,"func":"QPDFFormFieldObjectHelper::getDefaultAppearance()\n{\n    return getInheritableFieldValueAsString(\"\/DA\");\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":346727,"func":"static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)\n{\n}","target":1,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":227838,"func":"void RootWindowHostWin::ShowCursor(bool show) {\n}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":67591,"func":"static int build_sched_domains(const struct cpumask *cpu_map)\n{\n\treturn __build_sched_domains(cpu_map, NULL);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":45020,"func":"f_sha256(typval_T *argvars, typval_T *rettv)\n{\n    char_u\t*p;\n\n    p = tv_get_string(&argvars[0]);\n    rettv->vval.v_string = vim_strsave(\n\t\t\t\t    sha256_bytes(p, (int)STRLEN(p), NULL, 0));\n    rettv->v_type = VAR_STRING;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":144891,"func":"kex_alg_list(char sep)\n{\n\tchar *ret = NULL, *tmp;\n\tsize_t nlen, rlen = 0;\n\tconst struct kexalg *k;\n\n\tfor (k = kexalgs; k->name != NULL; k++) {\n\t\tif (ret != NULL)\n\t\t\tret[rlen++] = sep;\n\t\tnlen = strlen(k->name);\n\t\tif ((tmp = realloc(ret, rlen + nlen + 2)) == NULL) {\n\t\t\tfree(ret);\n\t\t\treturn NULL;\n\t\t}\n\t\tret = tmp;\n\t\tmemcpy(ret + rlen, k->name, nlen + 1);\n\t\trlen += nlen;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":331728,"func":"static void test_visitor_out_bool(TestOutputVisitorData *data,\n\n                                  const void *unused)\n\n{\n\n    bool value = true;\n\n    QObject *obj;\n\n\n\n    visit_type_bool(data->ov, NULL, &value, &error_abort);\n\n\n\n    obj = visitor_get(data);\n\n    g_assert(qobject_type(obj) == QTYPE_QBOOL);\n\n    g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value);\n\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":228097,"func":"void SelectionController::SetCaretAtHitTestResult(\n    const HitTestResult& hit_test_result) {\n  Node* inner_node = hit_test_result.InnerNode();\n  const VisiblePositionInFlatTree& visible_hit_pos =\n      VisiblePositionOfHitTestResult(hit_test_result);\n  const VisiblePositionInFlatTree& visible_pos =\n      visible_hit_pos.IsNull()\n          ? CreateVisiblePosition(\n                PositionInFlatTree::FirstPositionInOrBeforeNode(inner_node))\n          : visible_hit_pos;\n\n  if (visible_pos.IsNull()) {\n    UpdateSelectionForMouseDownDispatchingSelectStart(\n        inner_node, SelectionInFlatTree(), TextGranularity::kCharacter,\n        HandleVisibility::kVisible);\n    return;\n  }\n  UpdateSelectionForMouseDownDispatchingSelectStart(\n      inner_node,\n      ExpandSelectionToRespectUserSelectAll(\n          inner_node, SelectionInFlatTree::Builder()\n                          .Collapse(visible_pos.ToPositionWithAffinity())\n                          .Build()),\n      TextGranularity::kCharacter, HandleVisibility::kVisible);\n}\n","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":405584,"func":"WandExport void DrawPathMoveToAbsolute(DrawingWand *wand,const double x,\n  const double y)\n{\n  assert(wand != (DrawingWand *) NULL);\n  assert(wand->signature == MagickWandSignature);\n  if (wand->debug != MagickFalse)\n    (void) LogMagickEvent(WandEvent,GetMagickModule(),\"%s\",wand->name);\n  DrawPathMoveTo(wand,AbsolutePathMode,x,y);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":520357,"func":"bool Item_param::convert_str_value(THD *thd)\n{\n  bool rc= FALSE;\n  if (state == STRING_VALUE || state == LONG_DATA_VALUE)\n  {\n    rc= value.cs_info.convert_if_needed(thd, &str_value);\n    \/* Here str_value is guaranteed to be in final_character_set_of_str_value *\/\n\n    \/*\n      str_value_ptr is returned from val_str(). It must be not alloced\n      to prevent it's modification by val_str() invoker.\n    *\/\n    str_value_ptr.set(str_value.ptr(), str_value.length(),\n                      str_value.charset());\n    \/* Synchronize item charset and length with value charset *\/\n    fix_charset_and_length_from_str_value(DERIVATION_COERCIBLE);\n  }\n  return rc;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":222063,"func":"  Ins_NOT( FT_Long*  args )\n  {\n    args[0] = !args[0];\n  }\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":205988,"func":"http2shmlog(const struct http *hp, int t)\n{\n\n\tCHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);\n\tif (t > HTTP_HDR_FIRST)\n\t\tt = HTTP_HDR_FIRST;\n\tassert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); \/*lint !e685*\/\n\tassert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST);\n\treturn (logmtx[hp->logtag][t]);\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":336515,"func":"static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args,\n\n                             const int *const_args)\n\n{\n\n    tcg_out_cmp2(s, args, const_args);\n\n    tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, args[5]);\n\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":393304,"func":"xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error,\n           const char *msg, const xmlChar * str1, const xmlChar * str2)\n{\n    xmlStructuredErrorFunc schannel = NULL;\n    xmlGenericErrorFunc channel = NULL;\n    void *data = NULL;\n\n    if (ctxt != NULL) {\n        if (ctxt->serror != NULL)\n\t    schannel = ctxt->serror;\n\telse\n\t    channel = ctxt->error;\n        data = ctxt->userData;\n        ctxt->nbErrors++;\n    }\n    __xmlRaiseError(schannel, channel, data,\n                    NULL, node, XML_FROM_RELAXNGV,\n                    error, XML_ERR_ERROR, NULL, 0,\n                    (const char *) str1, (const char *) str2, NULL, 0, 0,\n                    msg, str1, str2);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":423356,"func":"void af_alg_data_wakeup(struct sock *sk)\n{\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct af_alg_ctx *ctx = ask->private;\n\tstruct socket_wq *wq;\n\n\tif (!ctx->used)\n\t\treturn;\n\n\trcu_read_lock();\n\twq = rcu_dereference(sk->sk_wq);\n\tif (skwq_has_sleeper(wq))\n\t\twake_up_interruptible_sync_poll(&wq->wait, EPOLLOUT |\n\t\t\t\t\t\t\t   EPOLLRDNORM |\n\t\t\t\t\t\t\t   EPOLLRDBAND);\n\tsk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);\n\trcu_read_unlock();\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":514797,"func":"static int test_store_ctx(void)\n{\n    X509_STORE_CTX *sctx = NULL;\n    X509 *x = NULL;\n    BIO *bio = NULL;\n    int testresult = 0, ret;\n\n    bio = BIO_new_file(bad_f, \"r\");\n    if (bio == NULL)\n        goto err;\n\n    x = PEM_read_bio_X509(bio, NULL, 0, NULL);\n    if (x == NULL)\n        goto err;\n\n    sctx = X509_STORE_CTX_new();\n    if (sctx == NULL)\n        goto err;\n\n    if (!X509_STORE_CTX_init(sctx, NULL, x, NULL))\n        goto err;\n\n    \/* Verifying a cert where we have no trusted certs should fail *\/\n    ret = X509_verify_cert(sctx);\n\n    if (ret == 0) {\n        \/* This is the result we were expecting: Test passed *\/\n        testresult = 1;\n    }\n\n err:\n    X509_STORE_CTX_free(sctx);\n    X509_free(x);\n    BIO_free(bio);\n    return testresult;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":150498,"func":"  void getReadBuffer(void** bufReturn, size_t* lenReturn) override {\n    *bufReturn = buf_.get() + bytesRead_;\n    *lenReturn = bufSize_ - bytesRead_;\n  }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":226825,"func":"TestURLFetcherFactory::TestURLFetcherFactory() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":214335,"func":"gl::GLSurface* GLES2DecoderPassthroughImpl::GetGLSurface() {\n  return surface_.get();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":45537,"func":"\nstatic PHP_METHOD(PDOStatement, nextRowset)\n{\n\tPHP_STMT_GET_OBJ;\n\n\tif (!stmt->methods->next_rowset) {\n\t\tpdo_raise_impl_error(stmt->dbh, stmt, \"IM001\", \"driver does not support multiple rowsets\" TSRMLS_CC);\n\t\tRETURN_FALSE;\n\t}\n\n\tPDO_STMT_CLEAR_ERR();\n\n\tif (!pdo_stmt_do_next_rowset(stmt TSRMLS_CC)) {\n\t\tPDO_HANDLE_STMT_ERR();\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_TRUE;","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":334391,"func":"void acpi_memory_unplug_cb(MemHotplugState *mem_st,\n\n                           DeviceState *dev, Error **errp)\n\n{\n\n    MemStatus *mdev;\n\n\n\n    mdev = acpi_memory_slot_status(mem_st, dev, errp);\n\n    if (!mdev) {\n\n        return;\n\n    }\n\n\n\n    \/* nvdimm device hot unplug is not supported yet. *\/\n\n    assert(!object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM));\n\n    mdev->is_enabled = false;\n\n    mdev->dimm = NULL;\n\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":200076,"func":"    void expectDisplayListEnabled(bool displayListEnabled)\n    {\n        EXPECT_EQ(displayListEnabled, (bool)m_testSurface->m_currentFrame.get());\n        EXPECT_EQ(!displayListEnabled, (bool)m_testSurface->m_fallbackSurface.get());\n        int expectedSurfaceCreationCount = displayListEnabled ? 0 : 1;\n        EXPECT_EQ(expectedSurfaceCreationCount, m_surfaceFactory->createSurfaceCount());\n    }\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":325990,"func":"void cpu_reset (CPUCRISState *env)\n{\n\tmemset(env, 0, offsetof(CPUCRISState, breakpoints));\n\ttlb_flush(env, 1);\n\tenv->pregs[PR_VR] = 32;\n#if defined(CONFIG_USER_ONLY)\n\t\/* start in user mode with interrupts enabled.  *\/\n\tenv->pregs[PR_CCS] |= U_FLAG | I_FLAG;\n#else\n\tenv->pregs[PR_CCS] = 0;\n#endif","target":1,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":188001,"func":"void HTMLFormElement::getNamedElements(\n    const AtomicString& name,\n    HeapVector<Member<Element>>& namedItems) {\n  elements()->namedItems(name, namedItems);\n\n  Element* elementFromPast = elementFromPastNamesMap(name);\n  if (namedItems.size() && namedItems.first() != elementFromPast) {\n    addToPastNamesMap(namedItems.first().get(), name);\n  } else if (elementFromPast && namedItems.isEmpty()) {\n    namedItems.append(elementFromPast);\n    UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap);\n  }\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":181628,"func":"WebContentsViewAura::WebContentsViewAura(\n    WebContentsImpl* web_contents,\n    WebContentsViewDelegate* delegate)\n    : web_contents_(web_contents),\n      delegate_(delegate),\n      current_drag_op_(blink::WebDragOperationNone),\n      drag_dest_delegate_(NULL),\n      current_rvh_for_drag_(NULL),\n      overscroll_change_brightness_(false),\n      current_overscroll_gesture_(OVERSCROLL_NONE),\n      completed_overscroll_gesture_(OVERSCROLL_NONE),\n      touch_editable_(TouchEditableImplAura::Create()) {\n}\n","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":173647,"func":"void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)\n{\n    if (paintingDisabled())\n        return;\n\n    SkPath path = *pathToClip.platformPath();\n    if (!isPathSkiaSafe(getCTM(), path))\n        return;\n\n    path.setFillType(clipRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);\n    platformContext()->clipPathAntiAliased(path);\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":265790,"func":"  ByteVectorPrivate(TagLib::uint len, char value) : RefCounter(), data(len, value), size(len) {}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":505131,"func":"static int MS_CALLBACK ssl_servername_cb(SSL *s, int *ad, void *arg)\n\t{\n\ttlsextctx * p = (tlsextctx *) arg;\n\tconst char * servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);\n        if (servername && p->biodebug) \n\t\tBIO_printf(p->biodebug,\"Hostname in TLS extension: \\\"%s\\\"\\n\",servername);\n        \n\tif (!p->servername)\n\t\treturn SSL_TLSEXT_ERR_NOACK;\n\t\n\tif (servername)\n\t\t{\n    \t\tif (strcmp(servername,p->servername)) \n\t\t\treturn p->extension_error;\n\t\tif (ctx2)\n\t\t\t{\n\t\t\tBIO_printf(p->biodebug,\"Switching server context.\\n\");\n\t\t\tSSL_set_SSL_CTX(s,ctx2);\n\t\t\t}     \n\t\t}\n\treturn SSL_TLSEXT_ERR_OK;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":272749,"func":"static char *parse_acc(char *p,\n\t\t\tstruct SYMBOL *s)\n{\n\tint pit = 0, acc;\n\tunsigned nacc;\n\n\tnacc = 0;\n\tfor (;;) {\n\t\tif (nacc >= sizeof s->u.key.pits) {\n\t\t\tsyntax(\"Too many accidentals\", p);\n\t\t\tbreak;\n\t\t}\n\t\tp = parse_acc_pit(p, &pit, &acc);\n\t\tif (acc < 0)\n\t\t\tbreak;\n\t\ts->u.key.pits[nacc] = pit;\n\t\ts->u.key.accs[nacc++] = acc;\n\t\twhile (isspace((unsigned char) *p))\n\t\t\tp++;\n\t\tif (*p == '\\0')\n\t\t\tbreak;\n\t\tif (*p != '^' && *p != '_' && *p != '=')\n\t\t\tbreak;\n\t}\n\ts->u.key.microscale = microscale;\n\tif (s->u.key.empty != 2)\n\t\ts->u.key.nacc = nacc;\n\treturn p;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":384996,"func":"PHP_MINFO_FUNCTION(hash)\n{\n\tHashPosition pos;\n\tchar buffer[2048];\n\tchar *s = buffer, *e = s + sizeof(buffer), *str;\n\tulong idx;\n\tlong type;\n\n\tfor(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos);\n\t\t(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTENT;\n\t\tzend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {\n\t\ts += slprintf(s, e - s, \"%s \", str);\n\t}\n\t*s = 0;\n\n\tphp_info_print_table_start();\n\tphp_info_print_table_row(2, \"hash support\", \"enabled\");\n\tphp_info_print_table_row(2, \"Hashing Engines\", buffer);\n\tphp_info_print_table_end();\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":419015,"func":"system_call_script(thread_master_t *m, int (*func) (thread_t *), void * arg, unsigned long timer, notify_script_t* script)\n{\n\tpid_t pid;\n\n\t\/* Daemonization to not degrade our scheduling timer *\/\n#ifdef ENABLE_LOG_TO_FILE\n\tif (log_file_name)\n\t\tflush_log_file();\n#endif\n\n\tpid = local_fork();\n\n\tif (pid < 0) {\n\t\t\/* fork error *\/\n\t\tlog_message(LOG_INFO, \"Failed fork process\");\n\t\treturn -1;\n\t}\n\n\tif (pid) {\n\t\t\/* parent process *\/\n\t\tthread_add_child(m, func, arg, pid, timer);\n\t\treturn 0;\n\t}\n\n\t\/* Child process *\/\n#ifdef _MEM_CHECK_\n\tskip_mem_dump();\n#endif\n\n\tsystem_call(script);\n\n\texit(0); \/* Script errors aren't server errors *\/\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":208475,"func":"void FetchManager::Loader::Failed(const String& message) {\n  if (failed_ || finished_)\n    return;\n  failed_ = true;\n  if (execution_context_->IsContextDestroyed())\n    return;\n  if (!message.IsEmpty()) {\n    execution_context_->AddConsoleMessage(\n        ConsoleMessage::Create(kJSMessageSource, kErrorMessageLevel, message));\n  }\n  if (resolver_) {\n    ScriptState* state = resolver_->GetScriptState();\n    ScriptState::Scope scope(state);\n    resolver_->Reject(V8ThrowException::CreateTypeError(state->GetIsolate(),\n                                                        \"Failed to fetch\"));\n  }\n  probe::didFailFetch(execution_context_, this);\n  NotifyFinished();\n}\n","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":441931,"func":"COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, uset,\n\t\tcompat_size_t, sigsetsize)\n{\n\tsigset_t set;\n\n\tif (sigsetsize > sizeof(*uset))\n\t\treturn -EINVAL;\n\n\tdo_sigpending(&set);\n\n\treturn put_compat_sigset(uset, &set, sigsetsize);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":436675,"func":"static void option_export_marks(const char *marks)\n{\n\texport_marks_file = make_fast_import_path(marks);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":221347,"func":"void TranslateMessageInfoBar::ButtonPressed(views::Button* sender,\n                                            const views::Event& event) {\n  if (sender == button_) {\n    GetDelegate()->MessageInfoBarButtonPressed();\n    return;\n  }\n  TranslateInfoBarBase::ButtonPressed(sender, event);\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":190296,"func":"bt_status_t btif_storage_load_autopair_device_list() {\n if (btif_config_has_section(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST)) {\n return BT_STATUS_SUCCESS;\n }\n\n static const char *key_names[] = {\n        BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_ADDR,\n        BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_EXACTNAME,\n        BTIF_STORAGE_KEY_AUTOPAIR_FIXPIN_KBLIST,\n        BTIF_STORAGE_KEY_AUTOPAIR_BLACKLIST_PARTIALNAME,\n        BTIF_STORAGE_KEY_AUTOPAIR_DYNAMIC_BLACKLIST_ADDR,\n };\n\n config_t *config = config_new(BTIF_AUTO_PAIR_CONF_FILE);\n if (!config) {\n        LOG_ERROR(\"%s failed to open auto pair blacklist conf file '%s'.\", __func__, BTIF_AUTO_PAIR_CONF_FILE);\n return BT_STATUS_FAIL;\n }\n\n for (size_t i = 0; i < ARRAY_SIZE(key_names); ++i) {\n const char *value = config_get_string(config, CONFIG_DEFAULT_SECTION, key_names[i], NULL);\n if (value) {\n            btif_config_set_str(BTIF_STORAGE_PATH_AUTOPAIR_BLACKLIST, key_names[i], value);\n }\n }\n\n    config_free(config);\n return BT_STATUS_SUCCESS;\n}\n","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":28305,"func":"static void pxa2xx_i2c_class_init ( ObjectClass * klass , void * data ) {\n DeviceClass * dc = DEVICE_CLASS ( klass ) ;\n SysBusDeviceClass * k = SYS_BUS_DEVICE_CLASS ( klass ) ;\n k -> init = pxa2xx_i2c_initfn ;\n dc -> desc = \"PXA2xx I2C Bus Controller\" ;\n dc -> vmsd = & vmstate_pxa2xx_i2c ;\n dc -> props = pxa2xx_i2c_properties ;\n }","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":124118,"func":"static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)\n{\n\tstruct sock *sk = sock->sk;\n\tint rc;\n\n\tlock_sock(sk);\n\trc = __ipx_bind(sock, uaddr, addr_len);\n\trelease_sock(sk);\n\n\treturn rc;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":495673,"func":"static int modify_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,\n                     union pvrdma_cmd_resp *rsp)\n{\n    struct pvrdma_cmd_modify_qp *cmd = &req->modify_qp;\n    int rc;\n\n    \/* No need to verify sgid_index since it is u8 *\/\n\n    rc = rdma_rm_modify_qp(&dev->rdma_dev_res, &dev->backend_dev,\n                           cmd->qp_handle, cmd->attr_mask,\n                           cmd->attrs.ah_attr.grh.sgid_index,\n                           (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid,\n                           cmd->attrs.dest_qp_num,\n                           (enum ibv_qp_state)cmd->attrs.qp_state,\n                           cmd->attrs.qkey, cmd->attrs.rq_psn,\n                           cmd->attrs.sq_psn);\n\n    return rc;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":113625,"func":"RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)\n\t{\n\treturn ASN1_d2i_bio_of(RSA,RSA_new,d2i_RSA_PUBKEY,bp,rsa);\n\t}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":281229,"func":"  int64_t GetPrimaryDisplayId() {\n    return display::Screen::GetScreen()->GetPrimaryDisplay().id();\n  }\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":91411,"func":"static int cm_alloc_msg(struct cm_id_private *cm_id_priv,\n\t\t\tstruct ib_mad_send_buf **msg)\n{\n\tstruct ib_mad_agent *mad_agent;\n\tstruct ib_mad_send_buf *m;\n\tstruct ib_ah *ah;\n\n\tmad_agent = cm_id_priv->av.port->mad_agent;\n\tah = ib_create_ah(mad_agent->qp->pd, &cm_id_priv->av.ah_attr);\n\tif (IS_ERR(ah))\n\t\treturn PTR_ERR(ah);\n\n\tm = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn,\n\t\t\t       cm_id_priv->av.pkey_index,\n\t\t\t       0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,\n\t\t\t       GFP_ATOMIC);\n\tif (IS_ERR(m)) {\n\t\tib_destroy_ah(ah);\n\t\treturn PTR_ERR(m);\n\t}\n\n\t\/* Timeout set by caller if response is expected. *\/\n\tm->ah = ah;\n\tm->retries = cm_id_priv->max_cm_retries;\n\n\tatomic_inc(&cm_id_priv->refcount);\n\tm->context[0] = cm_id_priv;\n\t*msg = m;\n\treturn 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":400303,"func":"static inline int put_words(OHCIState *ohci,\n                            dma_addr_t addr, uint16_t *buf, int num)\n{\n    int i;\n\n    addr += ohci->localmem_base;\n\n    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {\n        uint16_t tmp = cpu_to_le16(*buf);\n        if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) {\n            return -1;\n        }\n    }\n\n    return 0;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":202521,"func":"void OmniboxEditModel::OnControlKeyChanged(bool pressed) {\n  if (pressed == (control_key_state_ == UP))\n    control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP;\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":240358,"func":"PanoramiXRenderSetPictureFilter(ClientPtr client)\n{\n    REQUEST(xRenderSetPictureFilterReq);\n    int result = Success, j;\n    PanoramiXRes *pict;\n\n    REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);\n\n    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);\n\n    FOR_NSCREENS_BACKWARD(j) {\n        stuff->picture = pict->info[j].id;\n        result =\n            (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);\n        if (result != Success)\n            break;\n    }\n\n    return result;\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":116330,"func":"nv_compare(const void *s1, const void *s2)\n{\n    int\t\tc1, c2;\n\n    \/\/ The commands are sorted on absolute value.\n    c1 = nv_cmds[*(const short *)s1].cmd_char;\n    c2 = nv_cmds[*(const short *)s2].cmd_char;\n    if (c1 < 0)\n\tc1 = -c1;\n    if (c2 < 0)\n\tc2 = -c2;\n    return c1 - c2;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":446878,"func":"void ldb_set_require_private_event_context(struct ldb_context *ldb)\n{\n\tldb->require_private_event_context = true;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":222776,"func":"static void gen_add_A0_im(DisasContext *s, int val)\n{\n    tcg_gen_addi_tl(cpu_A0, cpu_A0, val);\n    if (!CODE64(s)) {\n        tcg_gen_ext32u_tl(cpu_A0, cpu_A0);\n    }\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":154039,"func":"static int compare_thresholds(const void *a, const void *b)\n{\n\tconst struct mem_cgroup_threshold *_a = a;\n\tconst struct mem_cgroup_threshold *_b = b;\n\n\treturn _a->threshold - _b->threshold;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":9609,"func":"const Cluster* Segment::GetLast() const\n{\n    if ((m_clusters == NULL) || (m_clusterCount <= 0))\n        return &m_eos;\n \n    const long idx = m_clusterCount - 1;\n \n    Cluster* const pCluster = m_clusters[idx];\n    assert(pCluster);\n    return pCluster;\n }\n","target":1,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":12810,"func":"   bool ContainOnlyOneKeyboardLayout(\n      const ImeConfigValue& value) {\n    return (value.type == ImeConfigValue::kValueTypeStringList &&\n             value.string_list_value.size() == 1 &&\n            chromeos::input_method::IsKeyboardLayout(\n                 value.string_list_value[0]));\n   }\n","target":1,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":208117,"func":"PHP_METHOD(snmp, getnext)\n{\n\tphp_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GETNEXT, (-1));\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":306093,"func":"static long do_locks(unsigned int fd, unsigned int cmd,\n\t\t\t\t unsigned long arg)\n{\n\tstruct flock64 kernel;\n\tstruct oabi_flock64 user;\n\tmm_segment_t fs;\n\tlong ret;\n\n\tif (copy_from_user(&user, (struct oabi_flock64 __user *)arg,\n\t\t\t   sizeof(user)))\n\t\treturn -EFAULT;\n\tkernel.l_type\t= user.l_type;\n\tkernel.l_whence\t= user.l_whence;\n\tkernel.l_start\t= user.l_start;\n\tkernel.l_len\t= user.l_len;\n\tkernel.l_pid\t= user.l_pid;\n\n\tfs = get_fs();\n\tset_fs(KERNEL_DS);\n\tret = sys_fcntl64(fd, cmd, (unsigned long)&kernel);\n\tset_fs(fs);\n\n\tif (!ret && (cmd == F_GETLK64 || cmd == F_OFD_GETLK)) {\n\t\tuser.l_type\t= kernel.l_type;\n\t\tuser.l_whence\t= kernel.l_whence;\n\t\tuser.l_start\t= kernel.l_start;\n\t\tuser.l_len\t= kernel.l_len;\n\t\tuser.l_pid\t= kernel.l_pid;\n\t\tif (copy_to_user((struct oabi_flock64 __user *)arg,\n\t\t\t\t &user, sizeof(user)))\n\t\t\tret = -EFAULT;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":191274,"func":"int ChromeMockRenderThread::print_preview_pages_remaining() {\nint ChromeMockRenderThread::print_preview_pages_remaining() const {\n   return print_preview_pages_remaining_;\n }\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":288943,"func":"static void maybe_exit ( int error ) {\n if ( ! first_error ) first_error = error ;\n if ( ignore_errors ) return ;\n ignore_errors = 1 ;\n if ( opt_slave_data ) do_start_slave_sql ( mysql ) ;\n if ( mysql ) mysql_close ( mysql ) ;\n free_resources ( ) ;\n exit ( error ) ;\n }","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":471569,"func":"char *ldbGetSourceLine(int line) {\n    int idx = line-1;\n    if (idx < 0 || idx >= ldb.lines) return \"<out of range source code line>\";\n    return ldb.src[idx];\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":73355,"func":"static int ip_vs_genl_dump_service(struct sk_buff *skb,\n\t\t\t\t   struct ip_vs_service *svc,\n\t\t\t\t   struct netlink_callback *cb)\n{\n\tvoid *hdr;\n\n\thdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,\n\t\t\t  &ip_vs_genl_family, NLM_F_MULTI,\n\t\t\t  IPVS_CMD_NEW_SERVICE);\n\tif (!hdr)\n\t\treturn -EMSGSIZE;\n\n\tif (ip_vs_genl_fill_service(skb, svc) < 0)\n\t\tgoto nla_put_failure;\n\n\treturn genlmsg_end(skb, hdr);\n\nnla_put_failure:\n\tgenlmsg_cancel(skb, hdr);\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":199190,"func":"void GLES2DecoderImpl::LoseContext(uint32 reset_status) {\n  if (reset_status_ != GL_NO_ERROR) {\n    return;\n  }\n\n  if (workarounds().use_virtualized_gl_contexts) {\n    if (reset_status == GL_GUILTY_CONTEXT_RESET_ARB) {\n      reset_status = GL_UNKNOWN_CONTEXT_RESET_ARB;\n    }\n  } else if (reset_status == GL_UNKNOWN_CONTEXT_RESET_ARB &&\n             IsRobustnessSupported()) {\n    GLenum driver_status = glGetGraphicsResetStatusARB();\n    if (driver_status == GL_GUILTY_CONTEXT_RESET_ARB ||\n        driver_status == GL_INNOCENT_CONTEXT_RESET_ARB) {\n      reset_status = driver_status;\n    }\n  }\n\n  reset_status_ = reset_status;\n  current_decoder_error_ = error::kLostContext;\n}\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":433238,"func":"ax25_cb *ax25_create_cb(void)\n{\n\tax25_cb *ax25;\n\n\tif ((ax25 = kzalloc(sizeof(*ax25), GFP_ATOMIC)) == NULL)\n\t\treturn NULL;\n\n\trefcount_set(&ax25->refcount, 1);\n\n\tskb_queue_head_init(&ax25->write_queue);\n\tskb_queue_head_init(&ax25->frag_queue);\n\tskb_queue_head_init(&ax25->ack_queue);\n\tskb_queue_head_init(&ax25->reseq_queue);\n\n\tax25_setup_timers(ax25);\n\n\tax25_fillin_cb(ax25, NULL);\n\n\tax25->state = AX25_STATE_0;\n\n\treturn ax25;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":17708,"func":"static void prplcb_conv_write ( PurpleConversation * conv , const char * who , const char * alias , const char * message , PurpleMessageFlags flags , time_t mtime ) {\n if ( flags & PURPLE_MESSAGE_SEND ) {\n handle_conv_msg ( conv , who , message , OPT_SELFMESSAGE , mtime ) ;\n }\n }","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":381069,"func":"static void ram_migration_cancel(void *opaque)\n{\n    migration_end();\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":139031,"func":"void __exit bnep_sock_cleanup(void)\n{\n\tif (bt_sock_unregister(BTPROTO_BNEP) < 0)\n\t\tBT_ERR(\"Can't unregister BNEP socket\");\n\n\tproto_unregister(&bnep_proto);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":232250,"func":"    bool readArrayBuffer(v8::Handle<v8::Value>* value)\n    {\n        RefPtr<ArrayBuffer> arrayBuffer = doReadArrayBuffer();\n        if (!arrayBuffer)\n            return false;\n        *value = toV8(arrayBuffer.release(), m_scriptState->context()->Global(), isolate());\n        return true;\n    }\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":424531,"func":"copy_opt_map_info(OptMapInfo* to, OptMapInfo* from)\n{\n  *to = *from;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":286448,"func":"static void withScriptStateVoidExceptionMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    TestObjectV8Internal::withScriptStateVoidExceptionMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":183744,"func":"BluetoothSocketCreateFunction::BluetoothSocketCreateFunction() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":509968,"func":"prepare_JPEGTables(TIFF* tif)\n{\n\tJPEGState* sp = JState(tif);\n\n\t\/* Initialize quant tables for current quality setting *\/\n\tif (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))\n\t\treturn (0);\n\t\/* Mark only the tables we want for output *\/\n\t\/* NB: chrominance tables are currently used only with YCbCr *\/\n\tif (!TIFFjpeg_suppress_tables(sp, TRUE))\n\t\treturn (0);\n\tif (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) {\n\t\tunsuppress_quant_table(sp, 0);\n\t\tif (sp->photometric == PHOTOMETRIC_YCBCR)\n\t\t\tunsuppress_quant_table(sp, 1);\n\t}\n\tif (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) {\n\t\tunsuppress_huff_table(sp, 0);\n\t\tif (sp->photometric == PHOTOMETRIC_YCBCR)\n\t\t\tunsuppress_huff_table(sp, 1);\n\t}\n\t\/* Direct libjpeg output into jpegtables *\/\n\tif (!TIFFjpeg_tables_dest(sp, tif))\n\t\treturn (0);\n\t\/* Emit tables-only datastream *\/\n\tif (!TIFFjpeg_write_tables(sp))\n\t\treturn (0);\n\n\treturn (1);\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":211813,"func":"void RenderWidgetHostViewAura::ScrollOffsetChanged() {\n  aura::Window* root = window_->GetRootWindow();\n  if (!root)\n    return;\n  aura::client::CursorClient* cursor_client =\n      aura::client::GetCursorClient(root);\n  if (cursor_client && !cursor_client->IsCursorVisible())\n    cursor_client->DisableMouseEvents();\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":295396,"func":"check_symlinks(struct archive_write_disk *a)\n{\n\tstruct archive_string error_string;\n\tint error_number;\n\tint rc;\n\tarchive_string_init(&error_string);\n\trc = check_symlinks_fsobj(a->name, &error_number, &error_string, a->flags);\n\tif (rc != ARCHIVE_OK) {\n\t\tarchive_set_error(&a->archive, error_number, \"%s\", error_string.s);\n\t}\n\tarchive_string_free(&error_string);\n\ta->pst = NULL;\t\/* to be safe *\/\n\treturn rc;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":130874,"func":"int enc_untrusted_fsetxattr(int fd, const char *name, const void *value,\n                            size_t size, int flags) {\n  return EnsureInitializedAndDispatchSyscall(asylo::system_call::kSYS_fsetxattr,\n                                             fd, name, value, size, flags);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":319802,"func":"static void dss_sp_scale_vector(int32_t *vec, int bits, int size)\n\n{\n\n    int i;\n\n\n\n    if (bits < 0)\n\n        for (i = 0; i < size; i++)\n\n            vec[i] = vec[i] >> -bits;\n\n    else\n\n        for (i = 0; i < size; i++)\n\n            vec[i] = vec[i] << bits;\n\n}\n","target":1,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":108771,"func":" *\/\nstatic int wddx_stack_destroy(wddx_stack *stack)\n{\n\tregister int i;\n\n\tif (stack->elements) {\n\t\tfor (i = 0; i < stack->top; i++) {\n\t\t\tif (Z_TYPE(((st_entry *)stack->elements[i])->data) != IS_UNDEF\n\t\t\t\t\t&& ((st_entry *)stack->elements[i])->type != ST_FIELD)\t{\n\t\t\t\tzval_ptr_dtor(&((st_entry *)stack->elements[i])->data);\n\t\t\t}\n\t\t\tif (((st_entry *)stack->elements[i])->varname) {\n\t\t\t\tefree(((st_entry *)stack->elements[i])->varname);\n\t\t\t}\n\t\t\tefree(stack->elements[i]);\n\t\t}\n\t\tefree(stack->elements);\n\t}\n\treturn SUCCESS;","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":35418,"func":"poly_overabove(PG_FUNCTION_ARGS)\n{\n\tPOLYGON    *polya = PG_GETARG_POLYGON_P(0);\n\tPOLYGON    *polyb = PG_GETARG_POLYGON_P(1);\n\tbool\t\tresult;\n\n\tresult = polya->boundbox.low.y >= polyb->boundbox.low.y;\n\n\t\/*\n\t * Avoid leaking memory for toasted inputs ... needed for rtree indexes\n\t *\/\n\tPG_FREE_IF_COPY(polya, 0);\n\tPG_FREE_IF_COPY(polyb, 1);\n\n\tPG_RETURN_BOOL(result);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":182060,"func":"mux_master_control_cleanup_cb(int cid, void *unused)\n{\n\tChannel *sc, *c = channel_by_id(cid);\n\n\tdebug3(\"%s: entering for channel %d\", __func__, cid);\n\tif (c == NULL)\n\t\tfatal(\"%s: channel_by_id(%i) == NULL\", __func__, cid);\n\tif (c->remote_id != -1) {\n\t\tif ((sc = channel_by_id(c->remote_id)) == NULL)\n\t\t\tfatal(\"%s: channel %d missing session channel %d\",\n\t\t\t    __func__, c->self, c->remote_id);\n\t\tc->remote_id = -1;\n\t\tsc->ctl_chan = -1;\n\t\tif (sc->type != SSH_CHANNEL_OPEN &&\n\t\t    sc->type != SSH_CHANNEL_OPENING) {\n\t\t\tdebug2(\"%s: channel %d: not open\", __func__, sc->self);\n\t\t\tchan_mark_dead(sc);\n\t\t} else {\n\t\t\tif (sc->istate == CHAN_INPUT_OPEN)\n\t\t\t\tchan_read_failed(sc);\n\t\t\tif (sc->ostate == CHAN_OUTPUT_OPEN)\n\t\t\t\tchan_write_failed(sc);\n\t\t}\n\t}\n\tchannel_cancel_cleanup(c->self);\n}\n","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":148831,"func":"void msre_engine_reqbody_processor_register(msre_engine *engine,\n    const char *name, void *fn_init, void *fn_process, void *fn_complete)\n{\n    msre_reqbody_processor_metadata *metadata = \n        (msre_reqbody_processor_metadata *)apr_pcalloc(engine->mp,\n            sizeof(msre_reqbody_processor_metadata));\n    if (metadata == NULL) return;\n\n    metadata->name = name;\n    metadata->init = fn_init;\n    metadata->process = fn_process;\n    metadata->complete = fn_complete;\n    apr_table_setn(engine->reqbody_processors, name, (void *)metadata);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":12521,"func":"void HostPortAllocatorSession::SendSessionRequest(const std::string& host,\n                                                   int port) {\n   GURL url(\"https:\/\/\" + host + \":\" + base::IntToString(port) +\n            GetSessionRequestUrl() + \"&sn=1\");\n  scoped_ptr<UrlFetcher> url_fetcher(new UrlFetcher(url, UrlFetcher::GET));\n   url_fetcher->SetRequestContext(url_context_);\n  url_fetcher->SetHeader(\"X-Talk-Google-Relay-Auth\", relay_token());\n  url_fetcher->SetHeader(\"X-Google-Relay-Auth\", relay_token());\n  url_fetcher->SetHeader(\"X-Stream-Type\", \"chromoting\");\n  url_fetcher->Start(base::Bind(&HostPortAllocatorSession::OnSessionRequestDone,\n                                base::Unretained(this), url_fetcher.get()));\n   url_fetchers_.insert(url_fetcher.release());\n }\n","target":1,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":306608,"func":"int jemalloc_purge() {\n    return 0;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":235806,"func":"void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) {\n  extension_pref_value_map_->UnregisterExtension(extension_id);\n  content_settings_store_->UnregisterExtension(extension_id);\n  DictionaryPrefUpdate update(prefs_, kExtensionsPref);\n  DictionaryValue* dict = update.Get();\n  if (dict->HasKey(extension_id)) {\n    dict->Remove(extension_id, NULL);\n    SavePrefs();\n  }\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":20635,"func":"static int32_t U_CALLCONV uprv_copyArray64 ( const UDataSwapper * ds , const void * inData , int32_t length , void * outData , UErrorCode * pErrorCode ) {\n if ( pErrorCode == NULL || U_FAILURE ( * pErrorCode ) ) {\n return 0 ;\n }\n if ( ds == NULL || inData == NULL || length < 0 || ( length & 7 ) != 0 || outData == NULL ) {\n * pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ;\n return 0 ;\n }\n if ( length > 0 && inData != outData ) {\n uprv_memcpy ( outData , inData , length ) ;\n }\n return length ;\n }","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":133818,"func":"void xen_netbk_queue_tx_skb(struct xenvif *vif, struct sk_buff *skb)\n{\n\tstruct xen_netbk *netbk = vif->netbk;\n\n\tskb_queue_tail(&netbk->rx_queue, skb);\n\n\txen_netbk_kick_thread(netbk);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":23290,"func":"static UBool CnvExtAddTable ( NewConverter * cnvData , UCMTable * table , UConverterStaticData * staticData ) {\n CnvExtData * extData ;\n if ( table -> unicodeMask & UCNV_HAS_SURROGATES ) {\n fprintf ( stderr , \"error: contains mappings for surrogate code points\\n\" ) ;\n return FALSE ;\n }\n staticData -> conversionType = UCNV_MBCS ;\n extData = ( CnvExtData * ) cnvData ;\n return makeToUTable ( extData , table ) && makeFromUTable ( extData , table ) ;\n }","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":45115,"func":"static void f2fs_dio_submit_bio(struct bio *bio, struct inode *inode,\n\t\t\t\t\t\t\tloff_t file_offset)\n{\n\tstruct f2fs_private_dio *dio;\n\tbool write = (bio_op(bio) == REQ_OP_WRITE);\n\n\tdio = f2fs_kzalloc(F2FS_I_SB(inode),\n\t\t\tsizeof(struct f2fs_private_dio), GFP_NOFS);\n\tif (!dio)\n\t\tgoto out;\n\n\tdio->inode = inode;\n\tdio->orig_end_io = bio->bi_end_io;\n\tdio->orig_private = bio->bi_private;\n\tdio->write = write;\n\n\tbio->bi_end_io = f2fs_dio_end_io;\n\tbio->bi_private = dio;\n\n\tinc_page_count(F2FS_I_SB(inode),\n\t\t\twrite ? F2FS_DIO_WRITE : F2FS_DIO_READ);\n\n\tsubmit_bio(bio);\n\treturn;\nout:\n\tbio->bi_status = BLK_STS_IOERR;\n\tbio_endio(bio);\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":159851,"func":"double ytr(\n    image_desc_t *im,\n    double value)\n{\n    static double pixie;\n    double    yval;\n\n    if (isnan(value)) {\n        if (!im->logarithmic)\n            pixie = (double) im->ysize \/ (im->maxval - im->minval);\n        else\n            pixie =\n                (double) im->ysize \/ (log10(im->maxval) - log10(im->minval));\n        yval = im->yorigin;\n    } else if (!im->logarithmic) {\n        yval = im->yorigin - pixie * (value - im->minval);\n    } else {\n        if (value < im->minval) {\n            yval = im->yorigin;\n        } else {\n            yval = im->yorigin - pixie * (log10(value) - log10(im->minval));\n        }\n    }\n    return yval;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":228793,"func":"void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) {\n  if ((type() & TYPE_POPUP) == 0) {\n    NOTREACHED() << \"moving invalid browser type\";\n    return;\n  }\n  window_->SetBounds(pos);\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":396213,"func":"int stop_lru_maintainer_thread(void) {\n    int ret;\n    pthread_mutex_lock(&lru_maintainer_lock);\n    \/* LRU thread is a sleep loop, will die on its own *\/\n    do_run_lru_maintainer_thread = 0;\n    pthread_mutex_unlock(&lru_maintainer_lock);\n    if ((ret = pthread_join(lru_maintainer_tid, NULL)) != 0) {\n        fprintf(stderr, \"Failed to stop LRU maintainer thread: %s\\n\", strerror(ret));\n        return -1;\n    }\n    settings.lru_maintainer_thread = false;\n    return 0;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":306662,"func":"DECLARESepPutFunc(putRGBseparate16bittile)\n{\n\tuint16 *wr = (uint16*) r;\n\tuint16 *wg = (uint16*) g;\n\tuint16 *wb = (uint16*) b;\n\t(void) img; (void) y; (void) a;\n\tfor( ; h > 0; --h) {\n\t\tfor (x = 0; x < w; x++)\n\t\t\t*cp++ = PACK(img->Bitdepth16To8[*wr++],\n\t\t\t    img->Bitdepth16To8[*wg++],\n\t\t\t    img->Bitdepth16To8[*wb++]);\n\t\tSKEW(wr, wg, wb, fromskew);\n\t\tcp += toskew;\n\t}\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":464766,"func":"static void v4l_print_ext_controls(const void *arg, bool write_only)\n{\n\tconst struct v4l2_ext_controls *p = arg;\n\tint i;\n\n\tpr_cont(\"which=0x%x, count=%d, error_idx=%d, request_fd=%d\",\n\t\t\tp->which, p->count, p->error_idx, p->request_fd);\n\tfor (i = 0; i < p->count; i++) {\n\t\tunsigned int id = p->controls[i].id;\n\t\tconst char *name = v4l2_ctrl_get_name(id);\n\n\t\tif (name)\n\t\t\tpr_cont(\", name=%s\", name);\n\t\tif (!p->controls[i].size)\n\t\t\tpr_cont(\", id\/val=0x%x\/0x%x\", id, p->controls[i].value);\n\t\telse\n\t\t\tpr_cont(\", id\/size=0x%x\/%u\", id, p->controls[i].size);\n\t}\n\tpr_cont(\"\\n\");\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":205091,"func":"CStarter::ShutdownFast( void )\n{\n\tbool jobRunning = false;\n\tUserProc *job;\n\n\tdprintf(D_ALWAYS, \"ShutdownFast all jobs.\\n\");\n\t\n\tif ( this->deferral_tid != -1 ) {\n\t\tthis->removeDeferredJobs();\n\t}\n\n\tm_job_list.Rewind();\n\twhile ((job = m_job_list.Next()) != NULL) {\n\t\tif ( job->ShutdownFast() ) {\n\t\t\tm_job_list.DeleteCurrent();\n\t\t\tdelete job;\n\t\t} else {\n\t\t\tjobRunning = true;\n\t\t}\n\t}\n\tShuttingDown = TRUE;\n\tif (!jobRunning) {\n\t\tdprintf(D_FULLDEBUG, \n\t\t\t\t\"Got ShutdownFast when no jobs running.\\n\");\n\t\treturn ( this->allJobsDone() );\n\t}\t\n\treturn ( false );\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":87354,"func":"int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name,\n\t\t\t      u32 result)\n{\n\tstruct sk_buff *msg;\n\tvoid *hdr;\n\n\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);\n\tif (!msg)\n\t\treturn -ENOMEM;\n\n\thdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,\n\t\t\t  NFC_CMD_FW_DOWNLOAD);\n\tif (!hdr)\n\t\tgoto free_msg;\n\n\tif (nla_put_string(msg, NFC_ATTR_FIRMWARE_NAME, firmware_name) ||\n\t    nla_put_u32(msg, NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, result) ||\n\t    nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))\n\t\tgoto nla_put_failure;\n\n\tgenlmsg_end(msg, hdr);\n\n\tgenlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);\n\n\treturn 0;\n\nnla_put_failure:\nfree_msg:\n\tnlmsg_free(msg);\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":200404,"func":"  WallpaperManagerBrowserTest() : controller_(NULL),\n                                  local_state_(NULL) {\n  }\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":311770,"func":"void Clipboard::WriteWebSmartPaste() {\n  InsertMapping(kMimeTypeWebkitSmartPaste, NULL, 0);\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":118386,"func":"static unsigned long xen_get_debugreg(int reg)\n{\n\treturn HYPERVISOR_get_debugreg(reg);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":324758,"func":"static uint16_t pci_req_id_cache_extract(PCIReqIDCache *cache)\n\n{\n\n    uint8_t bus_n;\n\n    uint16_t result;\n\n\n\n    switch (cache->type) {\n\n    case PCI_REQ_ID_BDF:\n\n        result = pci_get_bdf(cache->dev);\n\n        break;\n\n    case PCI_REQ_ID_SECONDARY_BUS:\n\n        bus_n = pci_bus_num(cache->dev->bus);\n\n        result = PCI_BUILD_BDF(bus_n, 0);\n\n        break;\n\n    default:\n\n        error_printf(\"Invalid PCI requester ID cache type: %d\\n\",\n\n                     cache->type);\n\n        exit(1);\n\n        break;\n\n    }\n\n\n\n    return result;\n\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":469430,"func":"void udp_detach(struct socket *so)\n{\n    so->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);\n    closesocket(so->s);\n    sofree(so);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":172213,"func":"static void coin_cleanup(void* c)\n{\n  uivector_cleanup(&((Coin*)c)->symbols);\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":205402,"func":"native_handle* Parcel::readNativeHandle() const\n{\n int numFds, numInts;\n status_t err;\n    err = readInt32(&numFds);\n if (err != NO_ERROR) return 0;\n    err = readInt32(&numInts);\n if (err != NO_ERROR) return 0;\n\n    native_handle* h = native_handle_create(numFds, numInts);\n if (!h) {\n return 0;\n }\n\n for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {\n        h->data[i] = dup(readFileDescriptor());\n if (h->data[i] < 0) err = BAD_VALUE;\n }\n    err = read(h->data + numFds, sizeof(int)*numInts);\n if (err != NO_ERROR) {\n        native_handle_close(h);\n        native_handle_delete(h);\n        h = 0;\n }\n return h;\n}\n","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":40490,"func":"ASC_setPresentationAddresses(T_ASC_Parameters * params,\n                             const char* callingPresentationAddress,\n                             const char* calledPresentationAddress)\n{\n    if (callingPresentationAddress)\n        OFStandard::strlcpy(params->DULparams.callingPresentationAddress,\n                callingPresentationAddress,\n                sizeof(params->DULparams.callingPresentationAddress));\n    if (calledPresentationAddress)\n        OFStandard::strlcpy(params->DULparams.calledPresentationAddress,\n                calledPresentationAddress,\n                sizeof(params->DULparams.calledPresentationAddress));\n\n    return EC_Normal;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":238839,"func":"png_get_rows(png_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->row_pointers);\n\n   else\n      return(0);\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":275543,"func":"PHP_FUNCTION(openssl_x509_fingerprint)\n{\n\tX509 *cert;\n\tzval **zcert;\n\tlong certresource;\n\tzend_bool raw_output = 0;\n\tchar *method = \"sha1\";\n\tint method_len;\n\n\tchar *fingerprint;\n\tint fingerprint_len;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"Z|sb\", &zcert, &method, &method_len, &raw_output) == FAILURE) {\n\t\treturn;\n\t}\n\n\tcert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);\n\tif (cert == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"cannot get cert from parameter 1\");\n\t\tRETURN_FALSE;\n\t}\n\n\tif (php_openssl_x509_fingerprint(cert, method, raw_output, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) {\n\t\tRETVAL_STRINGL(fingerprint, fingerprint_len, 0);\n\t} else {\n\t\tRETVAL_FALSE;\n\t}\n\n\tif (certresource == -1 && cert) {\n\t\tX509_free(cert);\n\t}\n}\n","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":315215,"func":"  virtual bool ShouldRemoveSelectOnChange() const { return false; }\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":157559,"func":"static ZIPARCHIVE_METHOD(renameName)\n{\n\tstruct zip *intern;\n\tzval *self = getThis();\n\tstruct zip_stat sb;\n\tchar *name, *new_name;\n\tsize_t name_len, new_name_len;\n\n\tif (!self) {\n\t\tRETURN_FALSE;\n\t}\n\n\tZIP_FROM_OBJECT(intern, self);\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"ss\", &name, &name_len, &new_name, &new_name_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (new_name_len < 1) {\n\t\tphp_error_docref(NULL, E_NOTICE, \"Empty string as new entry name\");\n\t\tRETURN_FALSE;\n\t}\n\n\tPHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb);\n\n\tif (zip_rename(intern, sb.index, (const char *)new_name)) {\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_TRUE;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":30676,"func":"static void remap_codebooks ( RoqContext * enc , RoqTempdata * tempData ) {\n int i , j , idx = 0 ;\n for ( i = 0 ;\n i < MAX_CBS_4x4 ;\n i ++ ) {\n if ( tempData -> codebooks . usedCB4 [ i ] ) {\n tempData -> i2f4 [ i ] = idx ;\n tempData -> f2i4 [ idx ] = i ;\n for ( j = 0 ;\n j < 4 ;\n j ++ ) tempData -> codebooks . usedCB2 [ enc -> cb4x4 [ i ] . idx [ j ] ] ++ ;\n idx ++ ;\n }\n }\n tempData -> numCB4 = idx ;\n idx = 0 ;\n for ( i = 0 ;\n i < MAX_CBS_2x2 ;\n i ++ ) {\n if ( tempData -> codebooks . usedCB2 [ i ] ) {\n tempData -> i2f2 [ i ] = idx ;\n tempData -> f2i2 [ idx ] = i ;\n idx ++ ;\n }\n }\n tempData -> numCB2 = idx ;\n }","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":171506,"func":"status_t ProCamera2Client::getCameraInfo(int cameraId,\n \/*out*\/\n                                         camera_metadata** info)\n{\n if (cameraId != mCameraId) {\n return INVALID_OPERATION;\n }\n\n Mutex::Autolock icl(mBinderSerializationLock);\n\n if (!mDevice.get()) return DEAD_OBJECT;\n\n CameraMetadata deviceInfo = mDevice->info();\n *info = deviceInfo.release();\n\n return OK;\n\n }\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":159870,"func":"static inline void set_page_pfmemalloc(struct page *page)\n{\n\tpage->index = -1UL;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":303837,"func":"  size_t node_def_count() const override { return graph_def_.node().size(); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":219980,"func":"void TabStripModel::RemoveObserver(TabStripModelObserver* observer) {\n  observers_.RemoveObserver(observer);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":37628,"func":"void fsck_set_msg_types(struct fsck_options *options, const char *values)\n{\n\tchar *buf = xstrdup(values), *to_free = buf;\n\tint done = 0;\n\n\twhile (!done) {\n\t\tint len = strcspn(buf, \" ,|\"), equal;\n\n\t\tdone = !buf[len];\n\t\tif (!len) {\n\t\t\tbuf++;\n\t\t\tcontinue;\n\t\t}\n\t\tbuf[len] = '\\0';\n\n\t\tfor (equal = 0;\n\t\t     equal < len && buf[equal] != '=' && buf[equal] != ':';\n\t\t     equal++)\n\t\t\tbuf[equal] = tolower(buf[equal]);\n\t\tbuf[equal] = '\\0';\n\n\t\tif (!strcmp(buf, \"skiplist\")) {\n\t\t\tif (equal == len)\n\t\t\t\tdie(\"skiplist requires a path\");\n\t\t\tinit_skiplist(options, buf + equal + 1);\n\t\t\tbuf += len + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (equal == len)\n\t\t\tdie(\"Missing '=': '%s'\", buf);\n\n\t\tfsck_set_msg_type(options, buf, buf + equal + 1);\n\t\tbuf += len + 1;\n\t}\n\tfree(to_free);\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":499200,"func":"static void hevc_await_progress(HEVCContext *s, HEVCFrame *ref,\n                                const Mv *mv, int y0, int height)\n{\n    int y = (mv->y >> 2) + y0 + height + 9;\n    ff_thread_await_progress(&ref->tf, y, 0);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":106551,"func":"file_printedlen(const struct magic_set *ms)\n{\n\treturn ms->o.buf == NULL ? 0 : strlen(ms->o.buf);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":69749,"func":"static void *sysvipc_proc_next(struct seq_file *s, void *it, loff_t *pos)\n{\n\tstruct ipc_proc_iter *iter = s->private;\n\tstruct ipc_proc_iface *iface = iter->iface;\n\tstruct kern_ipc_perm *ipc = it;\n\n\t\/* If we had an ipc id locked before, unlock it *\/\n\tif (ipc && ipc != SEQ_START_TOKEN)\n\t\tipc_unlock(ipc);\n\n\treturn sysvipc_find_ipc(&iter->ns->ids[iface->ids], *pos, pos);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":11045,"func":"std::string SanitizeFrontendPath(const std::string& path) {\n  for (size_t i = 0; i < path.length(); i++) {\n    if (path[i] != '\/' && path[i] != '-' && path[i] != '_'\n        && path[i] != '.' && path[i] != '@'\n        && !(path[i] >= '0' && path[i] <= '9')\n        && !(path[i] >= 'a' && path[i] <= 'z')\n        && !(path[i] >= 'A' && path[i] <= 'Z')) {\n      return std::string();\n    }\n  }\n  return path;\n}\n","target":1,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":31390,"func":"HeaderTableRecord::HeaderTableRecord(const char *n) :\n    name(n), id(HdrType::BAD_HDR), type(HdrFieldType::ftInvalid),\n    list(false), request(false), reply(false), hopbyhop(false), denied304(false)\n{}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":40965,"func":"QPDFWriter::writeStringNoQDF(std::string const& str)\n{\n    if (! this->qdf_mode)\n    {\n\twriteString(str);\n    }\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":299729,"func":"static void dtls1_set_handshake_header(SSL *s, int htype, unsigned long len)\n\t{\n\tunsigned char *p = (unsigned char *)s->init_buf->data;\n\tdtls1_set_message_header(s, p, htype, len, 0, len);\n\ts->init_num = (int)len + DTLS1_HM_HEADER_LENGTH;\n\ts->init_off = 0;\n\t\/* Buffer the message to handle re-xmits *\/\n\tdtls1_buffer_message(s, 0);\n\t}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":43023,"func":"\nstatic void io_free_file_tables(struct io_file_table *table)\n{\n\tkvfree(table->files);\n\ttable->files = NULL;","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":121140,"func":"int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn)\n{\n\treturn _snd_ctl_unregister_ioctl(fcn, &snd_control_ioctls);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":317079,"func":" RenderFrameHost* WebContentsImpl::GetFocusedFrameIncludingInnerWebContents() {\n  WebContentsImpl* contents = this;\n  FrameTreeNode* focused_node = contents->frame_tree_.GetFocusedFrame();\n\n  if (!focused_node)\n    return nullptr;\n\n  while (true) {\n    contents = contents->node_.GetInnerWebContentsInFrame(focused_node);\n    if (!contents)\n      return focused_node->current_frame_host();\n\n    focused_node = contents->frame_tree_.GetFocusedFrame();\n    if (!focused_node)\n      return contents->GetMainFrame();\n  }\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":23235,"func":"char * add_var ( struct ctl_var * * kv , u_long size , u_short def ) {\n u_short c ;\n struct ctl_var * k ;\n char * buf ;\n c = count_var ( * kv ) ;\n * kv = erealloc ( * kv , ( c + 2 ) * sizeof ( * * kv ) ) ;\n k = * kv ;\n buf = emalloc ( size ) ;\n k [ c ] . code = c ;\n k [ c ] . text = buf ;\n k [ c ] . flags = def ;\n k [ c + 1 ] . code = 0 ;\n k [ c + 1 ] . text = NULL ;\n k [ c + 1 ] . flags = EOV ;\n return buf ;\n }","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":274687,"func":"  void add_map_inc_bl(epoch_t e, bufferlist& bl) {\n    return service.add_map_inc_bl(e, bl);\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":280624,"func":"void PrintPreviewDataService::RemoveEntry(\nvoid PrintPreviewDataService::RemoveEntry(int32 preview_ui_id) {\n  data_store_map_.erase(preview_ui_id);\n }\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":268923,"func":"static u16 llcp_tlv_wks(u8 *tlv)\n{\n\treturn llcp_tlv16(tlv, LLCP_TLV_WKS);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":513757,"func":"napi_status napi_get_named_property(napi_env env,\n                                    napi_value object,\n                                    const char* utf8name,\n                                    napi_value* result) {\n  NAPI_PREAMBLE(env);\n  CHECK_ARG(env, result);\n\n  v8::Local<v8::Context> context = env->context();\n\n  v8::Local<v8::Name> key;\n  CHECK_NEW_FROM_UTF8(env, key, utf8name);\n\n  v8::Local<v8::Object> obj;\n\n  CHECK_TO_OBJECT(env, context, obj, object);\n\n  auto get_maybe = obj->Get(context, key);\n\n  CHECK_MAYBE_EMPTY(env, get_maybe, napi_generic_failure);\n\n  v8::Local<v8::Value> val = get_maybe.ToLocalChecked();\n  *result = v8impl::JsValueFromV8LocalValue(val);\n  return GET_RETURN_STATUS(env);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":386363,"func":"PHP_FUNCTION(xsl_xsltprocessor_get_parameter)\n{\n\tzval *id;\n\tint name_len = 0, namespace_len = 0;\n\tchar *name, *namespace;\n\tzval **value;\n\txsl_object *intern;\n\n\tDOM_GET_THIS(id);\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"ss\", &namespace, &namespace_len, &name, &name_len) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\tif ( zend_hash_find(intern->parameter, name, name_len + 1,  (void**) &value) == SUCCESS) {\n\t\tconvert_to_string_ex(value);\n\t\tRETVAL_STRING(Z_STRVAL_PP(value),1);\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":405470,"func":"void zone_pcp_reset(struct zone *zone)\n{\n\tunsigned long flags;\n\tint cpu;\n\tstruct per_cpu_pageset *pset;\n\n\t\/* avoid races with drain_pages()  *\/\n\tlocal_irq_save(flags);\n\tif (zone->pageset != &boot_pageset) {\n\t\tfor_each_online_cpu(cpu) {\n\t\t\tpset = per_cpu_ptr(zone->pageset, cpu);\n\t\t\tdrain_zonestat(zone, pset);\n\t\t}\n\t\tfree_percpu(zone->pageset);\n\t\tzone->pageset = &boot_pageset;\n\t}\n\tlocal_irq_restore(flags);\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":453652,"func":"postalAddressValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tstruct berval bv = *in;\n\tber_len_t c;\n\n\tfor ( c = 0; c < in->bv_len; c++ ) {\n\t\tif ( in->bv_val[c] == '\\\\' ) {\n\t\t\tc++;\n\t\t\tif ( strncasecmp( &in->bv_val[c], \"24\", STRLENOF( \"24\" ) ) != 0\n\t\t\t\t&& strncasecmp( &in->bv_val[c], \"5C\", STRLENOF( \"5C\" ) ) != 0 )\n\t\t\t{\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( in->bv_val[c] == '$' ) {\n\t\t\tbv.bv_len = &in->bv_val[c] - bv.bv_val;\n\t\t\tif ( UTF8StringValidate( NULL, &bv ) != LDAP_SUCCESS ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\t\t\tbv.bv_val = &in->bv_val[c] + 1;\n\t\t}\n\t}\n\n\tbv.bv_len = &in->bv_val[c] - bv.bv_val;\n\treturn UTF8StringValidate( NULL, &bv );\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":150405,"func":"Buf EncryptedWriteRecordLayer::getBufToEncrypt(folly::IOBufQueue& queue) const {\n  if (queue.front()->length() > maxRecord_) {\n    return queue.splitAtMost(maxRecord_);\n  } else if (queue.front()->length() >= desiredMinRecord_) {\n    return queue.pop_front();\n  } else {\n    return queue.splitAtMost(desiredMinRecord_);\n  }\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":287658,"func":"static int find_high_bit(unsigned int x)\n{\n\tint i;\n\tfor(i=31;i>=0;i--) {\n\t\tif(x&(1<<i)) return i;\n\t}\n\treturn 0;\n}","target":1,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":195390,"func":"bool RenderViewImpl::Send(IPC::Message* message) {\n  return RenderWidget::Send(message);\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":467665,"func":"Client::noteMoreBodyDataAvailable(BodyPipe::Pointer bp)\n{\n#if USE_ADAPTATION\n    if (adaptedBodySource == bp) {\n        handleMoreAdaptedBodyAvailable();\n        return;\n    }\n#endif\n    if (requestBodySource == bp)\n        handleMoreRequestBodyAvailable();\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":398179,"func":"get_eventloop_weight(self)\n    VALUE self;\n{\n    return rb_ary_new3(2, INT2NUM(event_loop_max), INT2NUM(no_event_tick));\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":116644,"func":"int Jsi_HexStr(const uchar *data, int len, Jsi_DString *dStr, bool decode) {\n    int olen = (decode?(len\/2+1):(len*2+1));\n    Jsi_DSSetLength(dStr, olen);\n    if (!decode)\n        return jsi_FromHexStr((const char*)data, (uchar*)Jsi_DSValue(dStr));\n    jsi_ToHexStr((const uchar*)data, len, Jsi_DSValue(dStr));\n    return olen-1;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":275358,"func":"void DownloadItemImpl::DestinationError(\n    DownloadInterruptReason reason,\n    int64_t bytes_so_far,\n    std::unique_ptr<crypto::SecureHash> secure_hash) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL);\n  DVLOG(20) << __func__\n            << \"() reason:\" << DownloadInterruptReasonToString(reason)\n            << \" this:\" << DebugString(true);\n\n  InterruptWithPartialState(bytes_so_far, std::move(secure_hash), reason);\n  UpdateObservers();\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":146274,"func":"megasas_fire_cmd_xscale(struct megasas_instance *instance,\n\t\tdma_addr_t frame_phys_addr,\n\t\tu32 frame_count,\n\t\tstruct megasas_register_set __iomem *regs)\n{\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&instance->hba_lock, flags);\n\twritel((frame_phys_addr >> 3)|(frame_count),\n\t       &(regs)->inbound_queue_port);\n\tspin_unlock_irqrestore(&instance->hba_lock, flags);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":252444,"func":"nfs4_check_delegmode(struct nfs4_delegation *dp, int flags)\n{\n\tif ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ))\n\t\treturn nfserr_openmode;\n\telse\n\t\treturn nfs_ok;\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":461721,"func":"EXPORT_SYMBOL_GPL(iscsi_session_event);\n\nstatic int\niscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep,\n\t\t\tstruct iscsi_uevent *ev, pid_t pid,\n\t\t\tuint32_t initial_cmdsn,\tuint16_t cmds_max,\n\t\t\tuint16_t queue_depth)\n{\n\tstruct iscsi_transport *transport = priv->iscsi_transport;\n\tstruct iscsi_cls_session *session;\n\tstruct Scsi_Host *shost;\n\n\tsession = transport->create_session(ep, cmds_max, queue_depth,\n\t\t\t\t\t    initial_cmdsn);\n\tif (!session)\n\t\treturn -ENOMEM;\n\n\tsession->creator = pid;\n\tshost = iscsi_session_to_shost(session);\n\tev->r.c_session_ret.host_no = shost->host_no;\n\tev->r.c_session_ret.sid = session->sid;\n\tISCSI_DBG_TRANS_SESSION(session,","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":399607,"func":"static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx)\n{\n\tint node;\n\n\t\/* all pwqs have been created successfully, let's install'em *\/\n\tmutex_lock(&ctx->wq->mutex);\n\n\tcopy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs);\n\n\t\/* save the previous pwq and install the new one *\/\n\tfor_each_node(node)\n\t\tctx->pwq_tbl[node] = numa_pwq_tbl_install(ctx->wq, node,\n\t\t\t\t\t\t\t  ctx->pwq_tbl[node]);\n\n\t\/* @dfl_pwq might not have been used, ensure it's linked *\/\n\tlink_pwq(ctx->dfl_pwq);\n\tswap(ctx->wq->dfl_pwq, ctx->dfl_pwq);\n\n\tmutex_unlock(&ctx->wq->mutex);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":279099,"func":"void RenderView::OnSetDOMUIProperty(const std::string& name,\n                                    const std::string& value) {\n  DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_));\n  dom_ui_bindings_.SetProperty(name, value);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":449777,"func":"stdmac_file(const SMacro *s, Token **params, int nparams)\n{\n    (void)s;\n    (void)params;\n    (void)nparams;\n\n    return make_tok_qstr(NULL, src_get_fname());\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":103649,"func":"  explicit BlockingWriteClient(AsyncSSLSocket::UniquePtr socket)\n      : socket_(std::move(socket)), bufLen_(2500), iovCount_(2000) {\n    \/\/ Fill buf_\n    buf_ = std::make_unique<uint8_t[]>(bufLen_);\n    for (uint32_t n = 0; n < sizeof(buf_); ++n) {\n      buf_[n] = n % 0xff;\n    }\n\n    \/\/ Initialize iov_\n    iov_ = std::make_unique<struct iovec[]>(iovCount_);\n    for (uint32_t n = 0; n < iovCount_; ++n) {\n      iov_[n].iov_base = buf_.get() + n;\n      if (n & 0x1) {\n        iov_[n].iov_len = n % bufLen_;\n      } else {\n        iov_[n].iov_len = bufLen_ - (n % bufLen_);\n      }\n    }\n\n    socket_->sslConn(this, std::chrono::milliseconds(100));\n  }","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":139832,"func":"free_tang_keys_info(struct tang_keys_info* tki)\n{\n    if (!tki) {\n        return;\n    }\n\n    json_t* to_free[] = {tki->m_keys, tki->m_rotated_keys,\n                         tki->m_payload, tki->m_sign\n    };\n    size_t len = sizeof(to_free) \/ sizeof(to_free[0]);\n\n    for (size_t i = 0; i < len; i++) {\n        if (to_free[i] == NULL) {\n            continue;\n        }\n        json_decref(to_free[i]);\n    }\n    free(tki);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":403440,"func":"static int default_local_infile_read(void *ptr, char *buf, uint buf_len)\n{\n  int count;\n  default_local_infile_data*data = (default_local_infile_data *) ptr;\n\n  if ((count= (int) my_read(data->fd, (uchar *) buf, buf_len, MYF(0))) < 0)\n  {\n    data->error_num= EE_READ; \/* the errmsg for not entire file read *\/\n    my_snprintf(data->error_msg, sizeof(data->error_msg)-1,\n\t\tEE(EE_READ),\n\t\tdata->filename, my_errno);\n  }\n  return count;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":389852,"func":"opaque* ClientDiffieHellmanPublic::get_clientKey() const\n{\n    return Yc_;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":227731,"func":"status_t ACodec::submitOutputMetadataBuffer() {\n    CHECK(storingMetadataInDecodedBuffers());\n if (mMetadataBuffersToSubmit == 0)\n return OK;\n\n BufferInfo *info = dequeueBufferFromNativeWindow();\n if (info == NULL) {\n return ERROR_IO;\n }\n\n    ALOGV(\"[%s] submitting output meta buffer ID %u for graphic buffer %p\",\n          mComponentName.c_str(), info->mBufferID, info->mGraphicBuffer.get());\n\n --mMetadataBuffersToSubmit;\n    info->checkWriteFence(\"submitOutputMetadataBuffer\");\n status_t err = mOMX->fillBuffer(mNode, info->mBufferID, info->mFenceFd);\n    info->mFenceFd = -1;\n if (err == OK) {\n        info->mStatus = BufferInfo::OWNED_BY_COMPONENT;\n }\n\n return err;\n}\n","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":516482,"func":"static bool not_null_fields_have_null_values(TABLE *table)\n{\n  Field **orig_field= table->field;\n  Field **filled_field= table->field_to_fill();\n\n  if (filled_field != orig_field)\n  {\n    THD *thd=table->in_use;\n    for (uint i=0; i < table->s->fields; i++)\n    {\n      Field *of= orig_field[i];\n      Field *ff= filled_field[i];\n      if (ff != of)\n      {\n        \/\/ copy after-update flags to of, copy before-update flags to ff\n        swap_variables(uint32, of->flags, ff->flags);\n        if (ff->is_real_null())\n        {\n          ff->set_notnull(); \/\/ for next row WHERE condition in UPDATE\n          if (convert_null_to_field_value_or_error(of) || thd->is_error())\n            return true;\n        }\n      }\n    }\n  }\n\n  return false;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":26257,"func":"static bool hyperv_hypercall_available ( X86CPU * cpu ) {\n return cpu -> hyperv_vapic || ( cpu -> hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY ) ;\n }","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":86415,"func":"static int mem_close(jas_stream_obj_t *obj)\n{\n\tjas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;\n\tif (m->myalloc_ && m->buf_) {\n\t\tjas_free(m->buf_);\n\t\tm->buf_ = 0;\n\t}\n\tjas_free(obj);\n\treturn 0;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":244486,"func":"IntPoint AXObject::minimumScrollOffset() const {\n  ScrollableArea* area = getScrollableAreaIfScrollable();\n  if (!area)\n    return IntPoint();\n\n  return IntPoint(area->minimumScrollOffsetInt().width(),\n                  area->minimumScrollOffsetInt().height());\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":296751,"func":"static u64 core_reg_offset_from_id(u64 id)\n{\n\treturn id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_CORE);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":296014,"func":"void PackLinuxElf32mipsel::defineSymbols(Filter const *ft)\n{\n    PackLinuxElf32::defineSymbols(ft);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":307049,"func":"void AudioRendererHost::OnPauseStream(int stream_id) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));\n\n  AudioEntry* entry = LookupById(stream_id);\n  if (!entry) {\n    SendErrorMessage(stream_id);\n    return;\n  }\n\n  entry->controller->Pause();\n  if (media_observer_)\n    media_observer_->OnSetAudioStreamPlaying(this, stream_id, false);\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":401673,"func":"ZEND_API int ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) \/* {{{ *\/\n{\n\tZVAL_BOOL(result, !zend_is_identical(op1, op2));\n\treturn SUCCESS;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":473987,"func":"connection_set_ssl_ssf(Connection *conn)\n{\n    pthread_mutex_lock(&(conn->c_mutex));\n\n    if (conn->c_flags & CONN_FLAG_SSL) {\n        SSL_SecurityStatus(conn->c_prfd, NULL, NULL, NULL, &(conn->c_ssl_ssf), NULL, NULL);\n    } else {\n        conn->c_ssl_ssf = 0;\n    }\n\n    pthread_mutex_unlock(&(conn->c_mutex));\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":155927,"func":"set_std_definitions(void)\n{\n\tadd_std_definition(\"_PWD\", NULL, get_cwd);\n\tadd_std_definition(\"_INSTANCE\", NULL, get_instance);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":231293,"func":"void ExtensionRegistry::TriggerOnUnloaded(\n    const Extension* extension,\n    UnloadedExtensionInfo::Reason reason) {\n  CHECK(extension);\n  DCHECK(!enabled_extensions_.Contains(extension->id()));\n  FOR_EACH_OBSERVER(ExtensionRegistryObserver,\n                    observers_,\n                    OnExtensionUnloaded(browser_context_, extension, reason));\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":13154,"func":"int RecordStack(CONTEXT* context,\n                int max_stack_size,\n                const void* instruction_pointers[],\n                Win32StackFrameUnwinder* frame_unwinder) {\n #ifdef _WIN64\n   int i = 0;\n   for (; (i < max_stack_size) && context->Rip; ++i) {\n     instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip);\n    if (!frame_unwinder->TryUnwind(context))\n       return i + 1;\n   }\n   return i;\n#else\n  return 0;\n#endif\n}\n","target":1,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":247905,"func":"  LayerTreeHostTestKeepSwapPromiseMFBA() {}\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":359492,"func":"static unsigned long seg_base(struct x86_emulate_ctxt *ctxt, int seg)\n{\n\tif (ctxt->mode == X86EMUL_MODE_PROT64 && seg < VCPU_SREG_FS)\n\t\treturn 0;\n\n\treturn kvm_x86_ops->get_segment_base(ctxt->vcpu, seg);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":444521,"func":"TEST_P(Http2UpstreamIntegrationTest, RouterUpstreamResponseBeforeRequestComplete) {\n  testRouterUpstreamResponseBeforeRequestComplete();\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":40435,"func":"\tbool audio_io_osx::Recording() const {\n\t\treturn is_recording_;\n\t}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":408405,"func":"PyObject *PyString_AsEncodedString(PyObject *str,\n                                   const char *encoding,\n                                   const char *errors)\n{\n    PyObject *v;\n\n    v = PyString_AsEncodedObject(str, encoding, errors);\n    if (v == NULL)\n        goto onError;\n\n#ifdef Py_USING_UNICODE\n    \/* Convert Unicode to a string using the default encoding *\/\n    if (PyUnicode_Check(v)) {\n        PyObject *temp = v;\n        v = PyUnicode_AsEncodedString(v, NULL, NULL);\n        Py_DECREF(temp);\n        if (v == NULL)\n            goto onError;\n    }\n#endif\n    if (!PyString_Check(v)) {\n        PyErr_Format(PyExc_TypeError,\n                     \"encoder did not return a string object (type=%.400s)\",\n                     Py_TYPE(v)->tp_name);\n        Py_DECREF(v);\n        goto onError;\n    }\n\n    return v;\n\n onError:\n    return NULL;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":141454,"func":"tv_get_string(typval_T *varp)\n{\n    static char_u   mybuf[NUMBUFLEN];\n\n    return tv_get_string_buf(varp, mybuf);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":87181,"func":"  explicit ElementwiseOperationParser(OperationType operation_type)\n      : operation_type_(operation_type) {}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":361960,"func":"vte_sequence_handler_soft_reset (VteTerminal *terminal, GValueArray *params)\n{\n\tvte_terminal_reset(terminal, FALSE, FALSE);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":378348,"func":"int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev)\n{\n#if defined(HAVE_MKNOD)\n\treturn mknod(path, mode, dev);\n#else\n\t\/* No mknod system call. *\/\n\terrno = ENOSYS;\n\treturn -1;\n#endif\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":24548,"func":"bool not_clause ( Node * clause ) {\n return ( clause != NULL && IsA ( clause , BoolExpr ) && ( ( BoolExpr * ) clause ) -> boolop == NOT_EXPR ) ;\n }","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":71541,"func":"struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br,\n\tstruct net_bridge_port *port, struct br_ip *group)\n{\n\tstruct net_bridge_mdb_htable *mdb;\n\tstruct net_bridge_mdb_entry *mp;\n\tint hash;\n\tint err;\n\n\tmdb = rcu_dereference_protected(br->mdb, 1);\n\tif (!mdb) {\n\t\terr = br_mdb_rehash(&br->mdb, BR_HASH_SIZE, 0);\n\t\tif (err)\n\t\t\treturn ERR_PTR(err);\n\t\tgoto rehash;\n\t}\n\n\thash = br_ip_hash(mdb, group);\n\tmp = br_multicast_get_group(br, port, group, hash);\n\tswitch (PTR_ERR(mp)) {\n\tcase 0:\n\t\tbreak;\n\n\tcase -EAGAIN:\nrehash:\n\t\tmdb = rcu_dereference_protected(br->mdb, 1);\n\t\thash = br_ip_hash(mdb, group);\n\t\tbreak;\n\n\tdefault:\n\t\tgoto out;\n\t}\n\n\tmp = kzalloc(sizeof(*mp), GFP_ATOMIC);\n\tif (unlikely(!mp))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tmp->br = br;\n\tmp->addr = *group;\n\n\thlist_add_head_rcu(&mp->hlist[mdb->ver], &mdb->mhash[hash]);\n\tmdb->size++;\n\nout:\n\treturn mp;\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":198980,"func":"void TabClosedNotificationObserver::set_for_browser_command(\n    bool for_browser_command) {\n  for_browser_command_ = for_browser_command;\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":166961,"func":"bool ExtensionPrefs::ReadIntegerFromPref(\n    const DictionaryValue* ext, const std::string& pref_key, int* out_value) {\n  if (!ext->GetInteger(pref_key, out_value))\n    return false;\n\n  return out_value != NULL;\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":233706,"func":"static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) {\n\tif (server) {\n\t\tif (info) {\n\t\t\tserver->clients = atoi(Info_ValueForKey(info, \"clients\"));\n\t\t\tQ_strncpyz(server->hostName,Info_ValueForKey(info, \"hostname\"), MAX_NAME_LENGTH);\n\t\t\tQ_strncpyz(server->mapName, Info_ValueForKey(info, \"mapname\"), MAX_NAME_LENGTH);\n\t\t\tserver->maxClients = atoi(Info_ValueForKey(info, \"sv_maxclients\"));\n\t\t\tQ_strncpyz(server->game,Info_ValueForKey(info, \"game\"), MAX_NAME_LENGTH);\n\t\t\tserver->gameType = atoi(Info_ValueForKey(info, \"gametype\"));\n\t\t\tserver->netType = atoi(Info_ValueForKey(info, \"nettype\"));\n\t\t\tserver->minPing = atoi(Info_ValueForKey(info, \"minping\"));\n\t\t\tserver->maxPing = atoi(Info_ValueForKey(info, \"maxping\"));\n\t\t\tserver->punkbuster = atoi(Info_ValueForKey(info, \"punkbuster\"));\n\t\t\tserver->g_humanplayers = atoi(Info_ValueForKey(info, \"g_humanplayers\"));\n\t\t\tserver->g_needpass = atoi(Info_ValueForKey(info, \"g_needpass\"));\n\t\t}\n\t\tserver->ping = ping;\n\t}\n}\n","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":449430,"func":"static int ttm_tt_set_page_caching(struct page *p,\n\t\t\t\t   enum ttm_caching_state c_old,\n\t\t\t\t   enum ttm_caching_state c_new)\n{\n\tint ret = 0;\n\n\tif (PageHighMem(p))\n\t\treturn 0;\n\n\tif (c_old != tt_cached) {\n\t\t\/* p isn't in the default caching state, set it to\n\t\t * writeback first to free its current memtype. *\/\n\n\t\tret = ttm_set_pages_wb(p, 1);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tif (c_new == tt_wc)\n\t\tret = ttm_set_pages_wc(p, 1);\n\telse if (c_new == tt_uncached)\n\t\tret = ttm_set_pages_uc(p, 1);\n\n\treturn ret;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":155918,"func":"acpi_status acpi_os_wait_command_ready(void)\n{\n\tint ret;\n\n\tret = acpi_debugger_wait_command_ready();\n\tif (ret < 0)\n\t\treturn AE_ERROR;\n\treturn AE_OK;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":252005,"func":"EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionImmutablePointFunction(ExecState* exec)\n{\n    JSValue thisValue = exec->hostThisValue();\n    if (!thisValue.inherits(&JSTestObj::s_info))\n        return throwVMTypeError(exec);\n    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));\n    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);\n    TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n\n    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(impl->immutablePointFunction())));\n    return JSValue::encode(result);\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":304560,"func":"PackLinuxElf64ppcle::getFilters() const\n{\n    static const int filters[] = {\n        0xd0,\n    FT_END };\n    return filters;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":369882,"func":"void ssl_set_ciphersuites( ssl_context *ssl, const int *ciphersuites )\n{\n    ssl->ciphersuites    = ciphersuites;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":293120,"func":"gr_face* gr_make_face(const void* appFaceHandle\/*non-NULL*\/, gr_get_table_fn tablefn, unsigned int faceOptions)\n{\n    const gr_face_ops ops = {sizeof(gr_face_ops), tablefn, NULL};\n    return gr_make_face_with_ops(appFaceHandle, &ops, faceOptions);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":8963,"func":"lyd_new_leaf(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str)\n{\n    const struct lys_node *snode = NULL, *siblings;\n\n    if ((!parent && !module) || !name) {\n        LOGARG;\n        return NULL;\n    }\n\n    siblings = lyd_new_find_schema(parent, module, 0);\n    if (!siblings) {\n        LOGARG;\n        return NULL;\n    }\n\n    if (lys_getnext_data(module, lys_parent(siblings), name, strlen(name), LYS_LEAFLIST | LYS_LEAF, &snode) || !snode) {\n        LOGERR(siblings->module->ctx, LY_EINVAL, \"Failed to find \\\"%s\\\" as a sibling to \\\"%s:%s\\\".\",\n               name, lys_node_module(siblings)->name, siblings->name);\n        return NULL;\n    }\n\n    return _lyd_new_leaf(parent, snode, val_str, 0, 0);\n}","target":1,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":198437,"func":"void S_AL_SrcShutdown( void )\n{\n\tint i;\n\tsrc_t *curSource;\n\n\tif(!alSourcesInitialised)\n\t\treturn;\n\n\tfor(i = 0; i < srcCount; i++)\n\t{\n\t\tcurSource = &srcList[i];\n\t\t\n\t\tif(curSource->isLocked)\n\t\t\tCom_DPrintf( S_COLOR_YELLOW \"WARNING: Source %d is locked\\n\", i);\n\n\t\tif(curSource->entity > 0)\n\t\t\tentityList[curSource->entity].srcAllocated = qfalse;\n\n\t\tqalSourceStop(srcList[i].alSource);\n\t\tqalDeleteSources(1, &srcList[i].alSource);\n\t}\n\n\tmemset(srcList, 0, sizeof(srcList));\n\n\talSourcesInitialised = qfalse;\n}\n","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":458460,"func":"dp_packet_l3_size(const struct dp_packet *b)\n{\n    return OVS_LIKELY(b->l3_ofs != UINT16_MAX)\n        ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l3(b)\n        - dp_packet_l2_pad_size(b)\n        : 0;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":134392,"func":"  bool DefaultEnv::SetLogFile( const std::string &filepath )\n  {\n    Log *log = GetLog();\n    LogOutFile *out = new LogOutFile();\n\n    if( out->Open( filepath ) )\n    {\n      log->SetOutput( out );\n      return true;\n    }\n\n    delete out;\n    return false;\n  }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":410257,"func":"            int dataSize() const\n            {\n                assert(isValid());\n                return data_size_;\n            }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":144389,"func":"getftypest(stat_T *st)\n{\n    char    *t;\n\n    if (S_ISREG(st->st_mode))\n\tt = \"file\";\n    else if (S_ISDIR(st->st_mode))\n\tt = \"dir\";\n    else if (S_ISLNK(st->st_mode))\n\tt = \"link\";\n    else if (S_ISBLK(st->st_mode))\n\tt = \"bdev\";\n    else if (S_ISCHR(st->st_mode))\n\tt = \"cdev\";\n    else if (S_ISFIFO(st->st_mode))\n\tt = \"fifo\";\n    else if (S_ISSOCK(st->st_mode))\n\tt = \"socket\";\n    else\n\tt = \"other\";\n    return (char_u*)t;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":476841,"func":"void nft_flow_rule_destroy(struct nft_flow_rule *flow)\n{\n\tstruct flow_action_entry *entry;\n\tint i;\n\n\tflow_action_for_each(i, entry, &flow->rule->action) {\n\t\tswitch (entry->id) {\n\t\tcase FLOW_ACTION_REDIRECT:\n\t\tcase FLOW_ACTION_MIRRED:\n\t\t\tdev_put(entry->dev);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\tkfree(flow->rule);\n\tkfree(flow);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":487463,"func":"void ElectronBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker(\n    mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*\n        map) {\n  map->Add<blink::mojom::BadgeService>(\n      base::BindRepeating(&BindBadgeServiceForServiceWorker));\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":288193,"func":"void CrosLibrary::TestApi::SetBrightnessLibrary(\n    BrightnessLibrary* library, bool own) {\n  library_->brightness_lib_.SetImpl(library, own);\n}\n","target":1,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":243084,"func":"void ExtensionInstallPrompt::ConfirmPermissionsForDelegatedInstall(\n    Delegate* delegate,\n    const Extension* extension,\n    const std::string& delegated_username,\n    const SkBitmap* icon) {\n  DCHECK(ui_loop_ == base::MessageLoop::current());\n  delegate_ = delegate;\n  extension_ = extension;\n  delegated_username_ = delegated_username;\n  SetIcon(icon);\n  prompt_ = new Prompt(DELEGATED_PERMISSIONS_PROMPT);\n  ShowConfirmation();\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":168536,"func":" bool AXTableCell::computeAccessibilityIsIgnored(\n    IgnoredReasons* ignoredReasons) const {\n  AXObjectInclusion decision = defaultObjectInclusion(ignoredReasons);\n  if (decision == IncludeObject)\n    return false;\n  if (decision == IgnoreObject)\n    return true;\n\n  if (!isTableCell())\n    return AXLayoutObject::computeAccessibilityIsIgnored(ignoredReasons);\n\n  return false;\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":149685,"func":"static int bin_mem(RCore *r, int mode) {\n\tRList *mem = NULL;\n\tif (!r)\treturn false;\n\tif (!IS_MODE_JSON(mode)) {\n\t\tif (!(IS_MODE_RAD (mode) || IS_MODE_SET (mode))) {\n\t\t\tr_cons_println (\"[Memory]\\n\");\n\t\t}\n\t}\n\tif (!(mem = r_bin_get_mem (r->bin))) {\n\t\tif (IS_MODE_JSON (mode)) {\n\t\t\tr_cons_print(\"[]\");\n\t\t}\n\t\treturn false;\n\t}\n\tif (IS_MODE_JSON (mode)) {\n\t\tr_cons_print (\"[\");\n\t\tbin_mem_print (mem, 7, 0, R_CORE_BIN_JSON);\n\t\tr_cons_println (\"]\");\n\t\treturn true;\n\t} else if (!(IS_MODE_RAD (mode) || IS_MODE_SET (mode))) {\n\t\tbin_mem_print (mem, 7, 0, mode);\n\t}\n\treturn true;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":439413,"func":"int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,\n\t\t\t\t   struct drm_file *file)\n{\n\tstruct drm_i915_gem_context_destroy *args = data;\n\tstruct drm_i915_file_private *file_priv = file->driver_priv;\n\tstruct i915_gem_context *ctx;\n\n\tif (args->pad != 0)\n\t\treturn -EINVAL;\n\n\tif (args->ctx_id == DEFAULT_CONTEXT_HANDLE)\n\t\treturn -ENOENT;\n\n\tif (mutex_lock_interruptible(&file_priv->context_idr_lock))\n\t\treturn -EINTR;\n\n\tctx = idr_remove(&file_priv->context_idr, args->ctx_id);\n\tmutex_unlock(&file_priv->context_idr_lock);\n\tif (!ctx)\n\t\treturn -ENOENT;\n\n\tmutex_lock(&dev->struct_mutex);\n\tcontext_close(ctx);\n\tmutex_unlock(&dev->struct_mutex);\n\n\treturn 0;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":396222,"func":"ZEND_API int add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, uint length, void **dest, int duplicate) \/* {{{ *\/\n{\n\tzval *tmp;\n\n\tif (UNEXPECTED(length > INT_MAX)) {\n\t\tzend_error_noreturn(E_ERROR, \"String overflow, max size is %d\", INT_MAX);\n\t}\n\n\tMAKE_STD_ZVAL(tmp);\n\tZVAL_STRINGL(tmp, str, length, duplicate);\n\n\treturn zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":262986,"func":"static int is_neg_adv_abort(unsigned int status)\n{\n\treturn status == CPL_ERR_RTX_NEG_ADVICE ||\n\t       status == CPL_ERR_PERSIST_NEG_ADVICE;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":321764,"func":"static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length)\n\n{\n\n    GetBitContext gb;\n\n    int i;\n\n\n\n    init_get_bits(&gb, src, length * 8);\n\n\n\n    for (i = 0; i < 3; i++) {\n\n        if (read_len_table(s->len[i], &gb) < 0)\n\n            return -1;\n\n        if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0) {\n\n            return -1;\n\n        }\n\n        ff_free_vlc(&s->vlc[i]);\n\n        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,\n\n                 s->bits[i], 4, 4, 0);\n\n    }\n\n\n\n    generate_joint_tables(s);\n\n\n\n    return (get_bits_count(&gb) + 7) \/ 8;\n\n}\n","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":236009,"func":"int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)\n{\n    BIGNUM *num_bn;\n    int result = 0;\n    char *hex;\n\n    num_bn = BN_new();\n    if (num_bn == NULL)\n        return -1;\n    ASN1_INTEGER_to_BN(num, num_bn);\n    if ((hex = BN_bn2hex(num_bn))) {\n        result = BIO_write(bio, \"0x\", 2) > 0;\n        result = result && BIO_write(bio, hex, strlen(hex)) > 0;\n        OPENSSL_free(hex);\n    }\n    BN_free(num_bn);\n\n    return result;\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":15830,"func":"void rtadv_init ( struct zebra_vrf * zvrf ) {\n ;\n }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":345951,"func":"bool asn1_read_BOOLEAN_context(struct asn1_data *data, bool *v, int context)\n{\n\tuint8_t tmp = 0;\n\tasn1_start_tag(data, ASN1_CONTEXT_SIMPLE(context));\n\tasn1_read_uint8(data, &tmp);\n\tif (tmp == 0xFF) {\n\t\t*v = true;\n\t} else {\n\t\t*v = false;\n\t}\n\tasn1_end_tag(data);\n\treturn !data->has_error;\n}","target":1,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":218957,"func":"ofputil_encode_bundle_msgs(const struct ofputil_bundle_msg *bms,\n                           size_t n_bms, struct ovs_list *requests,\n                           enum ofputil_protocol protocol)\n{\n    enum ofp_version version = ofputil_protocol_to_ofp_version(protocol);\n\n    for (size_t i = 0; i < n_bms; i++) {\n        struct ofpbuf *request = NULL;\n\n        switch ((int)bms[i].type) {\n        case OFPTYPE_FLOW_MOD:\n            request = ofputil_encode_flow_mod(&bms[i].fm, protocol);\n            break;\n        case OFPTYPE_GROUP_MOD:\n            request = ofputil_encode_group_mod(version, &bms[i].gm);\n            break;\n        case OFPTYPE_PACKET_OUT:\n            request = ofputil_encode_packet_out(&bms[i].po, protocol);\n            break;\n        default:\n            break;\n        }\n        if (request) {\n            ovs_list_push_back(requests, &request->list_node);\n        }\n    }\n}\n","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":211184,"func":"void WebSocket::OnClose(SocketStream* socket_stream) {\n  origin_loop_->PostTask(FROM_HERE,\n                         NewRunnableMethod(this, &WebSocket::DoClose));\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":239477,"func":"void FrameView::setScrollPositionNonProgrammatically(const IntPoint& scrollPoint)\n{\n    IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);\n\n    if (newScrollPosition == scrollPosition())\n        return;\n\n    TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, false);\n    notifyScrollPositionChanged(newScrollPosition);\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":219062,"func":" horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc)\n {\n \tTIFFPredictorState* sp = PredictorState(tif);\n \ttmsize_t stride = sp->stride;\n \tuint32 *wp = (uint32*) cp0;\n \ttmsize_t wc = cc\/4;\n \n    if((cc%(4*stride))!=0)\n    {\n        TIFFErrorExt(tif->tif_clientdata, \"horDiff32\",\n                     \"%s\", \"(cc%(4*stride))!=0\");\n        return 0;\n    }\n \n \tif (wc > stride) {\n \t\twc -= stride;\n\t\twp += wc - 1;\n\t\tdo {\n\t\t\tREPEAT4(stride, wp[stride] -= wp[0]; wp--)\n \t\t\twc -= stride;\n \t\t} while (wc > 0);\n \t}\n\treturn 1;\n }\n","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":117032,"func":"static void FontView_ReformatOne(FontView *fv) {\n    FontView *fvs;\n\n    if ( fv->v==NULL || fv->colcnt==0 )\t\/* Can happen in scripts *\/\nreturn;\n\n    GDrawSetCursor(fv->v,ct_watch);\n    fv->rowltot = (fv->b.map->enccount+fv->colcnt-1)\/fv->colcnt;\n    GScrollBarSetBounds(fv->vsb,0,fv->rowltot,fv->rowcnt);\n    if ( fv->rowoff>fv->rowltot-fv->rowcnt ) {\n        fv->rowoff = fv->rowltot-fv->rowcnt;\n\tif ( fv->rowoff<0 ) fv->rowoff =0;\n\tGScrollBarSetPos(fv->vsb,fv->rowoff);\n    }\n    for ( fvs=(FontView *) (fv->b.sf->fv); fvs!=NULL; fvs=(FontView *) (fvs->b.nextsame) )\n\tif ( fvs!=fv && fvs->b.sf==fv->b.sf )\n    break;\n    GDrawRequestExpose(fv->v,NULL,false);\n    GDrawSetCursor(fv->v,ct_pointer);\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":449428,"func":"int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)\n{\n\tstruct ttm_bo_device *bdev = bo->bdev;\n\tuint32_t page_flags = 0;\n\n\tdma_resv_assert_held(bo->base.resv);\n\n\tif (bo->ttm)\n\t\treturn 0;\n\n\tif (bdev->need_dma32)\n\t\tpage_flags |= TTM_PAGE_FLAG_DMA32;\n\n\tif (bdev->no_retry)\n\t\tpage_flags |= TTM_PAGE_FLAG_NO_RETRY;\n\n\tswitch (bo->type) {\n\tcase ttm_bo_type_device:\n\t\tif (zero_alloc)\n\t\t\tpage_flags |= TTM_PAGE_FLAG_ZERO_ALLOC;\n\t\tbreak;\n\tcase ttm_bo_type_kernel:\n\t\tbreak;\n\tcase ttm_bo_type_sg:\n\t\tpage_flags |= TTM_PAGE_FLAG_SG;\n\t\tbreak;\n\tdefault:\n\t\tpr_err(\"Illegal buffer object type\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tbo->ttm = bdev->driver->ttm_tt_create(bo, page_flags);\n\tif (unlikely(bo->ttm == NULL))\n\t\treturn -ENOMEM;\n\n\treturn 0;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":299872,"func":"#ifdef cimg_use_half\n    inline half rol(const half a, const unsigned int n=1) {\n      return (half)rol((int)a,n);","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":206910,"func":"void AcknowledgeBufferForGpu(\n    int32 route_id,\n    int gpu_host_id,\n    const std::string& received_mailbox,\n    bool skip_frame,\n    const scoped_refptr<ui::Texture>& texture_to_produce) {\n  AcceleratedSurfaceMsg_BufferPresented_Params ack;\n  uint32 sync_point = 0;\n  DCHECK(!texture_to_produce.get() || !skip_frame);\n  if (texture_to_produce.get()) {\n    GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();\n    ack.mailbox_name = texture_to_produce->Produce();\n    sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0;\n  } else if (skip_frame) {\n    ack.mailbox_name = received_mailbox;\n    ack.sync_point = 0;\n  }\n\n  ack.sync_point = sync_point;\n  RenderWidgetHostImpl::AcknowledgeBufferPresent(\n      route_id, gpu_host_id, ack);\n}\n","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":2358,"func":"  static const char* ConvertScalar(PyObject* v, complex128* out) {\n    if (PyComplex_Check(v)) {\n      *out = complex128(PyComplex_RealAsDouble(v), PyComplex_ImagAsDouble(v));\n      return nullptr;\n    } else if (PyIsInstance(v, &PyComplexFloatingArrType_Type)) {  \/\/ NumPy\n      auto as_complex = PyComplex_AsCComplex(v);\n      *out = complex128(as_complex.real, as_complex.imag);\n      return nullptr;\n    }\n    return ErrorMixedTypes;\n  }","target":1,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":450216,"func":"ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)\n{\n\tstruct nlattr *nest_count;\n\tconst struct nf_conn_tstamp *tstamp;\n\n\ttstamp = nf_conn_tstamp_find(ct);\n\tif (!tstamp)\n\t\treturn 0;\n\n\tnest_count = nla_nest_start(skb, CTA_TIMESTAMP);\n\tif (!nest_count)\n\t\tgoto nla_put_failure;\n\n\tif (nla_put_be64(skb, CTA_TIMESTAMP_START, cpu_to_be64(tstamp->start),\n\t\t\t CTA_TIMESTAMP_PAD) ||\n\t    (tstamp->stop != 0 && nla_put_be64(skb, CTA_TIMESTAMP_STOP,\n\t\t\t\t\t       cpu_to_be64(tstamp->stop),\n\t\t\t\t\t       CTA_TIMESTAMP_PAD)))\n\t\tgoto nla_put_failure;\n\tnla_nest_end(skb, nest_count);\n\n\treturn 0;\n\nnla_put_failure:\n\treturn -1;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":179278,"func":"static void reflectedIntegralAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TestObject* imp = V8TestObject::toNative(info.Holder());\n    v8SetReturnValueInt(info, imp->getIntegralAttribute(HTMLNames::reflectedintegralattrAttr));\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":318516,"func":"static void put_swf_matrix(ByteIOContext *pb,\n\n                           int a, int b, int c, int d, int tx, int ty)\n\n{\n\n    PutBitContext p;\n\n    uint8_t buf[256];\n\n\n\n    init_put_bits(&p, buf, sizeof(buf));\n\n    \n\n    put_bits(&p, 1, 1); \/* a, d present *\/\n\n    put_bits(&p, 5, 20); \/* nb bits *\/\n\n    put_bits(&p, 20, a);\n\n    put_bits(&p, 20, d);\n\n    \n\n    put_bits(&p, 1, 1); \/* b, c present *\/\n\n    put_bits(&p, 5, 20); \/* nb bits *\/\n\n    put_bits(&p, 20, c);\n\n    put_bits(&p, 20, b);\n\n\n\n    put_bits(&p, 5, 20); \/* nb bits *\/\n\n    put_bits(&p, 20, tx);\n\n    put_bits(&p, 20, ty);\n\n\n\n    flush_put_bits(&p);\n\n    put_buffer(pb, buf, pbBufPtr(&p) - p.buf);\n\n}\n","target":1,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":368774,"func":"_compare_pairs(const void **a, const void **b)\n{\n  const fp_pair_t *fp1 = *a, *fp2 = *b;\n  int r;\n  if ((r = fast_memcmp(fp1->first, fp2->first, DIGEST_LEN)))\n    return r;\n  else\n    return fast_memcmp(fp1->second, fp2->second, DIGEST_LEN);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":493887,"func":"checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,\n                 const char *s, size_t len)\n{\n#ifndef CURL_DISABLE_RTSP\n  if(conn->handler->protocol & CURLPROTO_RTSP)\n    return checkrtspprefix(data, s, len);\n#else\n  (void)conn;\n#endif \/* CURL_DISABLE_RTSP *\/\n\n  return checkhttpprefix(data, s, len);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":240105,"func":"void CompareDrawQuad(DrawQuad* quad,\n                     DrawQuad* copy,\n                     SharedQuadState* copy_shared_state) {\n  EXPECT_EQ(quad->material, copy->material);\n  EXPECT_EQ(quad->rect, copy->rect);\n  EXPECT_EQ(quad->visible_rect, copy->visible_rect);\n  EXPECT_EQ(quad->opaque_rect, copy->opaque_rect);\n  EXPECT_EQ(quad->needs_blending, copy->needs_blending);\n  EXPECT_EQ(copy_shared_state, copy->shared_quad_state);\n}\n","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":429203,"func":"job_handler_callback (gpointer       data,\n\t\t      gpointer       user_data)\n{\n  GVfsJob *job = G_VFS_JOB (data);\n\n  g_vfs_job_run (job);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":378985,"func":"static int local_LZ4_decompress_fast_withPrefix64k(const char* in, char* out, int inSize, int outSize)\n{\n    (void)inSize;\n    LZ4_decompress_fast_withPrefix64k(in, out, outSize);\n    return outSize;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":262230,"func":"cherokee_validator_ldap_add_headers (cherokee_validator_ldap_t *ldap, cherokee_connection_t *conn, cherokee_buffer_t *buf)\n{\n\tUNUSED(ldap);\n\tUNUSED(conn);\n\tUNUSED(buf);\n\n\treturn ret_ok;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":168590,"func":"static int kvm_init_mmu_notifier(struct kvm *kvm)\n{\n\treturn 0;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":296276,"func":"static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,\n\t\t\t       struct nfs_closeargs *args)\n{\n\tstruct compound_hdr hdr = {\n\t\t.minorversion = nfs4_xdr_minorversion(&args->seq_args),\n\t};\n\n\tencode_compound_hdr(xdr, req, &hdr);\n\tencode_sequence(xdr, &args->seq_args, &hdr);\n\tencode_putfh(xdr, args->fh, &hdr);\n\tencode_close(xdr, args, &hdr);\n\tencode_getfattr(xdr, args->bitmask, &hdr);\n\tencode_nops(&hdr);\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":156504,"func":"int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)\n{\n\tskb_orphan(skb);\n\n\tif (!(dev->flags & IFF_UP) ||\n\t    (skb->len > (dev->mtu + dev->hard_header_len))) {\n\t\tkfree_skb(skb);\n\t\treturn NET_RX_DROP;\n\t}\n\tskb_set_dev(skb, dev);\n\tskb->tstamp.tv64 = 0;\n\tskb->pkt_type = PACKET_HOST;\n\tskb->protocol = eth_type_trans(skb, dev);\n\treturn netif_rx(skb);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":520456,"func":"  Longlong_null to_longlong_null()\n  {\n    longlong nr= val_int();\n    \/*\n      C++ does not guarantee the order of parameter evaluation,\n      so to make sure \"null_value\" is passed to the constructor\n      after the val_int() call, val_int() is caled on a separate line.\n    *\/\n    return Longlong_null(nr, null_value);\n  }","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":312928,"func":"void RenderFrameHostImpl::SimulateBeforeUnloadAck() {\n  DCHECK(is_waiting_for_beforeunload_ack_);\n  base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;\n  OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":116259,"func":"static bool generic_pkt_to_tuple(const struct sk_buff *skb,\n\t\t\t\t unsigned int dataoff,\n\t\t\t\t struct nf_conntrack_tuple *tuple)\n{\n\ttuple->src.u.all = 0;\n\ttuple->dst.u.all = 0;\n\n\treturn true;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":477218,"func":"static int virtbt_setup_zephyr(struct hci_dev *hdev)\n{\n\tstruct sk_buff *skb;\n\n\t\/* Read Build Information *\/\n\tskb = __hci_cmd_sync(hdev, 0xfc08, 0, NULL, HCI_INIT_TIMEOUT);\n\tif (IS_ERR(skb))\n\t\treturn PTR_ERR(skb);\n\n\tbt_dev_info(hdev, \"%s\", (char *)(skb->data + 1));\n\n\thci_set_fw_info(hdev, \"%s\", skb->data + 1);\n\n\tkfree_skb(skb);\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":289366,"func":"static void vb_decode_palette ( VBDecContext * c , int data_size ) {\n int start , size , i ;\n start = bytestream2_get_byte ( & c -> stream ) ;\n size = ( bytestream2_get_byte ( & c -> stream ) - 1 ) & 0xFF ;\n if ( start + size > 255 ) {\n av_log ( c -> avctx , AV_LOG_ERROR , \"Palette change runs beyond entry 256\\n\" ) ;\n return ;\n }\n if ( size * 3 + 2 > data_size ) {\n av_log ( c -> avctx , AV_LOG_ERROR , \"Palette data runs beyond chunk size\\n\" ) ;\n return ;\n }\n for ( i = start ;\n i <= start + size ;\n i ++ ) c -> pal [ i ] = bytestream2_get_be24 ( & c -> stream ) ;\n }","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":201239,"func":"  virtual ~MockFreeDiskSpaceGetter() {}\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":83945,"func":"static void init_slave_skip_errors()\n{\n  DBUG_ENTER(\"init_slave_skip_errors\");\n  DBUG_ASSERT(!use_slave_mask); \/\/ not already initialized\n\n  if (bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR,0))\n  {\n    fprintf(stderr, \"Badly out of memory, please check your system status\\n\");\n    exit(1);\n  }\n  use_slave_mask = 1;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":144997,"func":"    template<typename T>\n    inline void sgels(char & TRANS, int &M, int &N, int &NRHS, T* lapA, int &LDA,\n\t\t      T* lapB, int &LDB, T* WORK, int &LWORK, int &INFO){\n      dgels_(&TRANS, &M, &N, &NRHS, lapA, &LDA, lapB, &LDB, WORK, &LWORK, &INFO);","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":283560,"func":"pdf_init_csi(fz_context *ctx, pdf_csi *csi, pdf_document *doc, pdf_obj *rdb, pdf_lexbuf *buf, fz_cookie *cookie)\n{\n\tmemset(csi, 0, sizeof *csi);\n\tcsi->doc = doc;\n\tcsi->rdb = rdb;\n\tcsi->buf = buf;\n\tcsi->cookie = cookie;\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":327711,"func":"static int vhost_user_get_vring_base(struct vhost_dev *dev,\n\n                                     struct vhost_vring_state *ring)\n\n{\n\n    VhostUserMsg msg = {\n\n        .request = VHOST_USER_GET_VRING_BASE,\n\n        .flags = VHOST_USER_VERSION,\n\n        .state = *ring,\n\n        .size = sizeof(*ring),\n\n    };\n\n\n\n    vhost_user_write(dev, &msg, NULL, 0);\n\n\n\n    if (vhost_user_read(dev, &msg) < 0) {\n\n        return 0;\n\n    }\n\n\n\n    if (msg.request != VHOST_USER_GET_VRING_BASE) {\n\n        error_report(\"Received unexpected msg type. Expected %d received %d\",\n\n                     VHOST_USER_GET_VRING_BASE, msg.request);\n\n        return -1;\n\n    }\n\n\n\n    if (msg.size != sizeof(m.state)) {\n\n        error_report(\"Received bad msg size.\");\n\n        return -1;\n\n    }\n\n\n\n    *ring = msg.state;\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":405068,"func":"static int racls_del_cb(void *rock,\n                  const char *key, size_t keylen,\n                  const char *data __attribute__((unused)),\n                  size_t datalen __attribute__((unused)))\n{\n    struct txn **txn = (struct txn **)rock;\n    return cyrusdb_delete(mbdb, key, keylen, txn, \/*force*\/0);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":170887,"func":"String UrlForFrame(LocalFrame* frame) {\n  KURL url = frame->GetDocument()->Url();\n  url.RemoveFragmentIdentifier();\n  return url.GetString();\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":401557,"func":"GSList* menu_cache_list_all_apps(MenuCache* cache)\n{\n    GSList* list;\n    MENU_CACHE_LOCK;\n    if (G_UNLIKELY(!cache->root_dir)) \/* empty cache *\/\n        list = NULL;\n    else\n        list = list_app_in_dir(cache->root_dir, NULL);\n    MENU_CACHE_UNLOCK;\n    return list;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":58623,"func":"static int mnt_fs_get_flags(struct libmnt_fs *fs)\n{\n\treturn fs ? fs->flags : 0;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":240661,"func":"void Browser::TogglePresentationMode() {\n  window_->SetPresentationMode(!window_->InPresentationMode());\n  WindowFullscreenStateChanged();\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":66554,"func":"void f2fs_wait_on_block_writeback(struct f2fs_sb_info *sbi, block_t blkaddr)\n{\n\tstruct page *cpage;\n\n\tif (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR)\n\t\treturn;\n\n\tcpage = find_lock_page(META_MAPPING(sbi), blkaddr);\n\tif (cpage) {\n\t\tf2fs_wait_on_page_writeback(cpage, DATA, true);\n\t\tf2fs_put_page(cpage, 1);\n\t}\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":137916,"func":"static inline pte_t pte_mkglobal(pte_t pte)\n{\n\treturn pte_set_flags(pte, _PAGE_GLOBAL);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":332193,"func":"static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)\n\n{\n\n    outl(0xcf8, (1 << 31) | (devfn << 8) | offset);\n\n    outb(0xcfc, value);\n\n}\n","target":1,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":399412,"func":"static void create_kthread(struct kthread_create_info *create)\n{\n\tint pid;\n\n#ifdef CONFIG_NUMA\n\tcurrent->pref_node_fork = create->node;\n#endif\n\t\/* We want our own signal handler (we take no signals by default). *\/\n\tpid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);\n\tif (pid < 0) {\n\t\t\/* If user was SIGKILLed, I release the structure. *\/\n\t\tstruct completion *done = xchg(&create->done, NULL);\n\n\t\tif (!done) {\n\t\t\tkfree(create);\n\t\t\treturn;\n\t\t}\n\t\tcreate->result = ERR_PTR(pid);\n\t\tcomplete(done);\n\t}\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":28172,"func":"static void gs_heap_free_string ( gs_memory_t * mem , byte * data , uint nbytes , client_name_t cname ) {\n gs_heap_free_object ( mem , data , cname ) ;\n }","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":236658,"func":"void PushMessagingServiceImpl::Observe(\n    int type,\n    const content::NotificationSource& source,\n    const content::NotificationDetails& details) {\n  DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type);\n  shutdown_started_ = true;\n#if BUILDFLAG(ENABLE_BACKGROUND)\n  in_flight_keep_alive_.reset();\n#endif  \/\/ BUILDFLAG(ENABLE_BACKGROUND)\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":26220,"func":"void TSVConnActiveTimeoutCancel ( TSVConn connp ) {\n sdk_assert ( sdk_sanity_check_iocore_structure ( connp ) == TS_SUCCESS ) ;\n NetVConnection * vc = ( NetVConnection * ) connp ;\n vc -> cancel_active_timeout ( ) ;\n }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":43500,"func":"ssize_t proc_projid_map_write(struct file *file, const char __user *buf,\n\t\t\t      size_t size, loff_t *ppos)\n{\n\tstruct seq_file *seq = file->private_data;\n\tstruct user_namespace *ns = seq->private;\n\tstruct user_namespace *seq_ns = seq_user_ns(seq);\n\n\tif (!ns->parent)\n\t\treturn -EPERM;\n\n\tif ((seq_ns != ns) && (seq_ns != ns->parent))\n\t\treturn -EPERM;\n\n\t\/* Anyone can set any valid project id no capability needed *\/\n\treturn map_write(file, buf, size, ppos, -1,\n\t\t\t &ns->projid_map, &ns->parent->projid_map);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":68149,"func":"TEST_P(Http2CodecImplTest, TrailingHeaders) {\n  initialize();\n\n  TestHeaderMapImpl request_headers;\n  HttpTestUtility::addDefaultHeaders(request_headers);\n  EXPECT_CALL(request_decoder_, decodeHeaders_(_, false));\n  request_encoder_->encodeHeaders(request_headers, false);\n  EXPECT_CALL(request_decoder_, decodeData(_, false));\n  Buffer::OwnedImpl hello(\"hello\");\n  request_encoder_->encodeData(hello, false);\n  EXPECT_CALL(request_decoder_, decodeTrailers_(_));\n  request_encoder_->encodeTrailers(TestHeaderMapImpl{{\"trailing\", \"header\"}});\n\n  TestHeaderMapImpl response_headers{{\":status\", \"200\"}};\n  EXPECT_CALL(response_decoder_, decodeHeaders_(_, false));\n  response_encoder_->encodeHeaders(response_headers, false);\n  EXPECT_CALL(response_decoder_, decodeData(_, false));\n  Buffer::OwnedImpl world(\"world\");\n  response_encoder_->encodeData(world, false);\n  EXPECT_CALL(response_decoder_, decodeTrailers_(_));\n  response_encoder_->encodeTrailers(TestHeaderMapImpl{{\"trailing\", \"header\"}});\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":435954,"func":"void net_enable_timestamp(void)\n{\n#ifdef CONFIG_JUMP_LABEL\n\tint wanted;\n\n\twhile (1) {\n\t\twanted = atomic_read(&netstamp_wanted);\n\t\tif (wanted <= 0)\n\t\t\tbreak;\n\t\tif (atomic_cmpxchg(&netstamp_wanted, wanted, wanted + 1) == wanted)\n\t\t\treturn;\n\t}\n\tatomic_inc(&netstamp_needed_deferred);\n\tschedule_work(&netstamp_work);\n#else\n\tstatic_branch_inc(&netstamp_needed_key);\n#endif\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":178993,"func":"bool RenderFrameHostImpl::CreateNetworkServiceDefaultFactory(\n    network::mojom::URLLoaderFactoryRequest default_factory_request) {\n  return CreateNetworkServiceDefaultFactoryInternal(\n      last_committed_origin_, std::move(default_factory_request));\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":10244,"func":"static void BooleanOrNullAttributeAttributeSetter(\n    v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {\n  v8::Isolate* isolate = info.GetIsolate();\n  ALLOW_UNUSED_LOCAL(isolate);\n\n  v8::Local<v8::Object> holder = info.Holder();\n  ALLOW_UNUSED_LOCAL(holder);\n\n  TestObject* impl = V8TestObject::ToImpl(holder);\n \n   ExceptionState exception_state(isolate, ExceptionState::kSetterContext, \"TestObject\", \"booleanOrNullAttribute\");\n \n  bool cpp_value = NativeValueTraits<IDLBoolean>::NativeValue(info.GetIsolate(), v8_value, exception_state);\n   if (exception_state.HadException())\n     return;\n \n  bool is_null = IsUndefinedOrNull(v8_value);\n   impl->setBooleanOrNullAttribute(cpp_value, is_null);\n }\n","target":1,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":37308,"func":"static int orinoco_ioctl_setibssport(struct net_device *dev,\n\t\t\t\t     struct iw_request_info *info,\n\t\t\t\t     void *wrqu,\n\t\t\t\t     char *extra)\n\n{\n\tstruct orinoco_private *priv = ndev_priv(dev);\n\tint val = *((int *) extra);\n\tunsigned long flags;\n\n\tif (orinoco_lock(priv, &flags) != 0)\n\t\treturn -EBUSY;\n\n\tpriv->ibss_port = val;\n\n\t\/* Actually update the mode we are using *\/\n\tset_port_type(priv);\n\n\torinoco_unlock(priv, &flags);\n\treturn -EINPROGRESS;\t\t\/* Call commit handler *\/\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":404905,"func":"static struct sk_buff *l2cap_ertm_seq_in_queue(struct sk_buff_head *head,\n\t\t\t\t\t       u16 seq)\n{\n\tstruct sk_buff *skb;\n\n\tskb_queue_walk(head, skb) {\n\t\tif (bt_cb(skb)->l2cap.txseq == seq)\n\t\t\treturn skb;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":81701,"func":"  uint32_t writeI32(const int32_t i32) {\n    T_VIRTUAL_CALL();\n    return writeI32_virt(i32);\n  }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":241240,"func":"void RenderFrameHostImpl::OnBubbleLogicalScrollInParentFrame(\n    blink::WebScrollDirection direction,\n    blink::WebScrollGranularity granularity) {\n  if (!is_active())\n    return;\n\n  RenderFrameProxyHost* proxy =\n      frame_tree_node()->render_manager()->GetProxyToParent();\n  if (!proxy) {\n    bad_message::ReceivedBadMessage(GetProcess(),\n                                    bad_message::RFH_NO_PROXY_TO_PARENT);\n    return;\n  }\n\n  proxy->BubbleLogicalScroll(direction, granularity);\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":208921,"func":"AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager,\n                                                   AutofillDriver* driver)\n    : manager_(manager), driver_(driver) {\n  DCHECK(manager);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":343649,"func":"void unix_notinflight(struct file *fp)\n{\n\tstruct sock *s = unix_get_socket(fp);\n\tif(s) {\n\t\tatomic_dec(&unix_sk(s)->inflight);\n\t\tatomic_dec(&unix_tot_inflight);\n\t}\n}","target":1,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":255014,"func":"static void chs_assemble_msbs_lsbs(DCAXllDecoder *s, DCAXllChSet *c, int band)\n\n{\n\n    DCAXllBand *b = &c->bands[band];\n\n    int n, ch, nsamples = s->nframesamples;\n\n\n\n    for (ch = 0; ch < c->nchannels; ch++) {\n\n        int shift = chs_get_lsb_width(s, c, band, ch);\n\n        if (shift) {\n\n            int32_t *msb = b->msb_sample_buffer[ch];\n\n            if (b->nscalablelsbs[ch]) {\n\n                int32_t *lsb = b->lsb_sample_buffer[ch];\n\n                int adj = b->bit_width_adjust[ch];\n\n                for (n = 0; n < nsamples; n++)\n\n                    msb[n] = msb[n] * (1 << shift) + (lsb[n] << adj);\n\n            } else {\n\n                for (n = 0; n < nsamples; n++)\n\n                    msb[n] = msb[n] * (1 << shift);\n\n            }\n\n        }\n\n    }\n\n}\n","target":1,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":419113,"func":"format_create(struct client *c, struct cmdq_item *item, int tag, int flags)\n{\n\tstruct format_tree\t*ft;\n\n\tif (!event_initialized(&format_job_event)) {\n\t\tevtimer_set(&format_job_event, format_job_timer, NULL);\n\t\tformat_job_timer(-1, 0, NULL);\n\t}\n\n\tft = xcalloc(1, sizeof *ft);\n\tRB_INIT(&ft->tree);\n\n\tif (c != NULL) {\n\t\tft->client = c;\n\t\tft->client->references++;\n\t}\n\n\tft->tag = tag;\n\tft->flags = flags;\n\n\tformat_add_cb(ft, \"host\", format_cb_host);\n\tformat_add_cb(ft, \"host_short\", format_cb_host_short);\n\tformat_add_cb(ft, \"pid\", format_cb_pid);\n\tformat_add(ft, \"socket_path\", \"%s\", socket_path);\n\tformat_add_tv(ft, \"start_time\", &start_time);\n\n\tif (item != NULL) {\n\t\tif (item->cmd != NULL)\n\t\t\tformat_add(ft, \"command\", \"%s\", item->cmd->entry->name);\n\t\tif (item->shared != NULL && item->shared->formats != NULL)\n\t\t\tformat_merge(ft, item->shared->formats);\n\t}\n\n\treturn (ft);\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":441206,"func":"void RGWGetObjRetention_ObjStore_S3::send_response()\n{\n  if (op_ret) {\n    set_req_state_err(s, op_ret);\n  }\n  dump_errno(s);\n  end_header(s, this, \"application\/xml\");\n  dump_start(s);\n\n  if (op_ret) {\n    return;\n  }\n  encode_xml(\"Retention\", obj_retention, s->formatter);\n  rgw_flush_formatter_and_reset(s, s->formatter);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":105145,"func":"static void start_interleave_scan(struct hci_dev *hdev)\n{\n\thdev->interleave_scan_state = INTERLEAVE_SCAN_NO_FILTER;\n\tqueue_delayed_work(hdev->req_workqueue,\n\t\t\t   &hdev->interleave_scan, 0);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":288459,"func":"static int cli_scanfile ( const char * filename , cli_ctx * ctx ) {\n int fd , ret ;\n fd = safe_open ( filename , O_RDONLY | O_BINARY ) ;\n if ( fd < 0 ) return CL_EOPEN ;\n ret = cli_magic_scandesc ( fd , ctx ) ;\n close ( fd ) ;\n return ret ;\n }","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":394198,"func":"blkid_parttable blkid_partlist_get_table(blkid_partlist ls)\n{\n\tif (list_empty(&ls->l_tabs))\n\t\treturn NULL;\n\n\treturn list_entry(ls->l_tabs.next,\n\t\t\tstruct blkid_struct_parttable, t_tabs);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":312900,"func":"void HWNDMessageHandler::OnThemeChanged() {\n  ui::NativeThemeWin::instance()->CloseHandles();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":37315,"func":"    \/\/! Resize image to dimensions of a display window \\newinstance.\n    CImg<T> get_resize(const CImgDisplay& disp,\n                       const int interpolation_type=1, const unsigned int boundary_conditions=0,\n                       const float centering_x = 0, const float centering_y = 0,\n                       const float centering_z = 0, const float centering_c = 0) const {\n      return get_resize(disp.width(),disp.height(),_depth,_spectrum,interpolation_type,boundary_conditions,\n                        centering_x,centering_y,centering_z,centering_c);","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":453922,"func":"    string str() {\n        return string(\"a\\0b\", 3);\n    }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":235226,"func":"RenderView::~RenderView() {\n  if (decrement_shared_popup_at_destruction_)\n    shared_popup_counter_->data--;\n\n  for (ImageResourceFetcherSet::iterator i = image_fetchers_.begin();\n       i != image_fetchers_.end(); ++i) {\n    delete *i;\n  }\n\n  while (!file_chooser_completions_.empty()) {\n    if (file_chooser_completions_.front()->completion) {\n      file_chooser_completions_.front()->completion->didChooseFile(\n          WebVector<WebString>());\n    }\n    file_chooser_completions_.pop_front();\n  }\n\n#if defined(OS_MACOSX)\n  if (has_document_tag_)\n    Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_));\n#endif\n\n  render_thread_->RemoveFilter(audio_message_filter_);\n\n#ifndef NDEBUG\n  ViewMap* views = Singleton<ViewMap>::get();\n  for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)\n    DCHECK_NE(this, it->second) << \"Failed to call Close?\";\n#endif\n}\n","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":135030,"func":"void send_open_url(const char *url)\n{\n\tGF_Event evt;\n\tmemset(&evt, 0, sizeof(GF_Event));\n\tevt.type = GF_EVENT_NAVIGATE;\n\tevt.navigate.to_url = url;\n\tgf_term_send_event(term, &evt);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":410440,"func":"QUtil::setRandomDataProvider(RandomDataProvider* p)\n{\n    random_data_provider = p;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":374270,"func":"convert_tablespace_priv_string(text *priv_type_text)\n{\n\tstatic const priv_map tablespace_priv_map[] = {\n\t\t{\"CREATE\", ACL_CREATE},\n\t\t{\"CREATE WITH GRANT OPTION\", ACL_GRANT_OPTION_FOR(ACL_CREATE)},\n\t\t{NULL, 0}\n\t};\n\n\treturn convert_any_priv_string(priv_type_text, tablespace_priv_map);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":510806,"func":"void HttpErrorString(const FunctionCallbackInfo<Value>& args) {\n  Environment* env = Environment::GetCurrent(args);\n  uint32_t val = args[0]->Uint32Value(env->context()).ToChecked();\n  args.GetReturnValue().Set(\n      String::NewFromOneByte(\n          env->isolate(),\n          reinterpret_cast<const uint8_t*>(nghttp2_strerror(val)),\n          v8::NewStringType::kInternalized).ToLocalChecked());\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":301902,"func":"static Image *ReadMNGImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  return(ReadPNGImage(image_info,exception));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":484701,"func":"static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl,\n\t\t\t\t  struct snd_ctl_elem_info __user *_info)\n{\n\tstruct snd_ctl_elem_info info;\n\tint result;\n\n\tif (copy_from_user(&info, _info, sizeof(info)))\n\t\treturn -EFAULT;\n\tresult = snd_ctl_elem_info(ctl, &info);\n\tif (result < 0)\n\t\treturn result;\n\t\/* drop internal access flags *\/\n\tinfo.access &= ~(SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK|\n\t\t\t SNDRV_CTL_ELEM_ACCESS_LED_MASK);\n\tif (copy_to_user(_info, &info, sizeof(info)))\n\t\treturn -EFAULT;\n\treturn result;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":388081,"func":"gdm_session_handle_client_begin_verification_for_user (GdmDBusUserVerifier    *user_verifier_interface,\n                                                       GDBusMethodInvocation  *invocation,\n                                                       const char             *service_name,\n                                                       const char             *username,\n                                                       GdmSession             *self)\n{\n        GdmSessionConversation *conversation;\n\n        conversation = begin_verification_conversation (self, invocation, service_name);\n\n        if (conversation != NULL) {\n                conversation->starting_invocation = g_object_ref (invocation);\n                conversation->starting_username = g_strdup (username);\n        }\n\n        return TRUE;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":16913,"func":"static int check_authenticated_user_and_ip ( int userid , struct query * q ) {\n int res = check_user_and_ip ( userid , q ) ;\n if ( res ) return res ;\n if ( ! users [ userid ] . authenticated ) return 1 ;\n return 0 ;\n }","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":48794,"func":"  Status CalculateOutputIndex(OpKernelContext* context, int dimension,\n                              const vector<INDEX_TYPE>& parent_output_index,\n                              INDEX_TYPE output_index_multiplier,\n                              INDEX_TYPE output_size,\n                              vector<INDEX_TYPE>* result) {\n    const RowPartitionTensor row_partition_tensor =\n        GetRowPartitionTensor(context, dimension);\n    auto partition_type = GetRowPartitionTypeByDimension(dimension);\n    switch (partition_type) {\n      case RowPartitionType::VALUE_ROWIDS:\n        return CalculateOutputIndexValueRowID(\n            row_partition_tensor, parent_output_index, output_index_multiplier,\n            output_size, result);\n      case RowPartitionType::ROW_SPLITS:\n        if (row_partition_tensor.size() - 1 > parent_output_index.size()) {\n          return errors::InvalidArgument(\n              \"Row partition size is greater than output size: \",\n              row_partition_tensor.size() - 1, \" > \",\n              parent_output_index.size());\n        }\n        return CalculateOutputIndexRowSplit(\n            row_partition_tensor, parent_output_index, output_index_multiplier,\n            output_size, result);\n      default:\n        return errors::InvalidArgument(\n            \"Unsupported partition type:\",\n            RowPartitionTypeToString(partition_type));\n    }\n  }","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":432167,"func":"char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,\n\t\t\t       int size)\n{\n\tchar *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC);\n\n\tif (!buffer)\n\t\treturn NULL;\n\n\tbuffer[0] = LINE6_SYSEX_BEGIN;\n\tmemcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id));\n\tbuffer[sizeof(line6_midi_id) + 1] = code1;\n\tbuffer[sizeof(line6_midi_id) + 2] = code2;\n\tbuffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END;\n\treturn buffer;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":10852,"func":"get_caller_uid (GDBusMethodInvocation *context, gint *uid)\n {\n        PolkitSubject *subject;\n        PolkitSubject *process;\n \n        subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));\n        process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, NULL);\n        if (!process) {\n                g_object_unref (subject);\n                 return FALSE;\n         }\n \n        *uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));\n        g_object_unref (subject);\n        g_object_unref (process);\n \n         return TRUE;\n }\n","target":1,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":489588,"func":"GF_Err gf_lz_compress_payload(u8 **data, u32 data_len, u32 *max_size)\n{\n\t*max_size = 0;\n\treturn GF_NOT_SUPPORTED;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":183158,"func":"void CastDetailedView::AppendHeaderEntry() {\n  CreateSpecialRow(IDS_ASH_STATUS_TRAY_CAST, this);\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":91238,"func":"LogL16fromY(double Y, int em)\t\/* get 16-bit LogL from Y *\/\n{\n\tif (Y >= 1.8371976e19)\n\t\treturn (0x7fff);\n\tif (Y <= -1.8371976e19)\n\t\treturn (0xffff);\n\tif (Y > 5.4136769e-20)\n\t\treturn itrunc(256.*(log2(Y) + 64.), em);\n\tif (Y < -5.4136769e-20)\n\t\treturn (~0x7fff | itrunc(256.*(log2(-Y) + 64.), em));\n\treturn (0);\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":370219,"func":"void sctp_transport_burst_limited(struct sctp_transport *t)\n{\n\tstruct sctp_association *asoc = t->asoc;\n\tu32 old_cwnd = t->cwnd;\n\tu32 max_burst_bytes;\n\n\tif (t->burst_limited)\n\t\treturn;\n\n\tmax_burst_bytes = t->flight_size + (asoc->max_burst * asoc->pathmtu);\n\tif (max_burst_bytes < old_cwnd) {\n\t\tt->cwnd = max_burst_bytes;\n\t\tt->burst_limited = old_cwnd;\n\t}\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":306630,"func":"unsigned CLASS pana_bits (int nbits)\n{\n#ifndef LIBRAW_NOTHREADS\n#define buf tls->pana_bits.buf\n#define vbits tls->pana_bits.vbits\n#else\n  static uchar buf[0x4000];\n  static int vbits;\n#endif\n  int byte;\n\n  if (!nbits) return vbits=0;\n  if (!vbits) {\n    fread (buf+load_flags, 1, 0x4000-load_flags, ifp);\n    fread (buf, 1, load_flags, ifp);\n  }\n  vbits = (vbits - nbits) & 0x1ffff;\n  byte = vbits >> 3 ^ 0x3ff0;\n  return (buf[byte] | buf[byte+1] << 8) >> (vbits & 7) & ~((~0u) << nbits);\n#ifndef LIBRAW_NOTHREADS\n#undef buf\n#undef vbits\n#endif\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":482989,"func":"iter_ns_probability(struct ub_randstate* rnd, int n, int m)\n{\n\tint sel;\n\tif(n == m) \/* 100% chance *\/\n\t\treturn 1;\n\t\/* we do not need secure random numbers here, but\n\t * we do need it to be threadsafe, so we use this *\/\n\tsel = ub_random_max(rnd, m);\n\treturn (sel < n);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":139507,"func":"void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)\n{\n\tif (!evm_initialized)\n\t\treturn;\n\n\tif (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))\n\t\tevm_update_evmxattr(dentry, NULL, NULL, 0);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":362274,"func":"impl_get_certificates (EphyCertificateManager *manager,\n                       EphyX509CertType type)\n{\n  return NULL;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":205380,"func":"spnego_gss_inquire_mech_for_saslname(OM_uint32 *minor_status,\n                                     const gss_buffer_t sasl_mech_name,\n                                     gss_OID *mech_type)\n{\n\tif (sasl_mech_name->length == SPNEGO_SASL_NAME_LEN &&\n\t    memcmp(sasl_mech_name->value, SPNEGO_SASL_NAME,\n\t\t   SPNEGO_SASL_NAME_LEN) == 0) {\n\t\tif (mech_type != NULL)\n\t\t\t*mech_type = (gss_OID)gss_mech_spnego;\n\t\treturn (GSS_S_COMPLETE);\n\t}\n\n\treturn (GSS_S_BAD_MECH);\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":225082,"func":"void WorkerFetchContext::DispatchDidReceiveEncodedData(\n    unsigned long identifier,\n    int encoded_data_length) {\n  probe::didReceiveEncodedDataLength(global_scope_, identifier,\n                                     encoded_data_length);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":384250,"func":"static xmlNodePtr guess_array_map(encodeTypePtr type, zval *data, int style, xmlNodePtr parent TSRMLS_DC)\n{\n\tencodePtr enc = NULL;\n\n\tif (data && Z_TYPE_P(data) == IS_ARRAY) {\n\t\tif (is_map(data)) {\n\t\t\tenc = get_conversion(APACHE_MAP);\n\t\t} else {\n\t\t\tenc = get_conversion(SOAP_ENC_ARRAY);\n\t\t}\n\t}\n\tif (!enc) {\n\t\tenc = get_conversion(IS_NULL);\n\t}\n\n\treturn master_to_xml(enc, data, style, parent TSRMLS_CC);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":334864,"func":"static uint64_t memory_region_dispatch_read1(MemoryRegion *mr,\n\n                                             hwaddr addr,\n\n                                             unsigned size)\n\n{\n\n    uint64_t data = 0;\n\n\n\n    if (!memory_region_access_valid(mr, addr, size, false)) {\n\n        return -1U; \/* FIXME: better signalling *\/\n\n    }\n\n\n\n    if (!mr->ops->read) {\n\n        return mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);\n\n    }\n\n\n\n    \/* FIXME: support unaligned access *\/\n\n    access_with_adjusted_size(addr, &data, size,\n\n                              mr->ops->impl.min_access_size,\n\n                              mr->ops->impl.max_access_size,\n\n                              memory_region_read_accessor, mr);\n\n\n\n    return data;\n\n}\n","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":278336,"func":"  SetIsInertMessageFilter()\n      : content::BrowserMessageFilter(FrameMsgStart),\n        msg_received_(false) {}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":180106,"func":"gx_dc_colored_masked_get_dev_halftone(const gx_device_color * pdevc)\n{\n    return pdevc->colors.colored.c_ht;\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":364327,"func":"xmlCleanupCharEncodingHandlers(void) {\n    xmlCleanupEncodingAliases();\n\n    if (handlers == NULL) return;\n\n    for (;nbCharEncodingHandler > 0;) {\n        nbCharEncodingHandler--;\n\tif (handlers[nbCharEncodingHandler] != NULL) {\n\t    if (handlers[nbCharEncodingHandler]->name != NULL)\n\t\txmlFree(handlers[nbCharEncodingHandler]->name);\n\t    xmlFree(handlers[nbCharEncodingHandler]);\n\t}\n    }\n    xmlFree(handlers);\n    handlers = NULL;\n    nbCharEncodingHandler = 0;\n    xmlDefaultCharEncodingHandler = NULL;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":94569,"func":"static int unlock_request(struct fuse_req *req)\n{\n\tint err = 0;\n\tif (req) {\n\t\tspin_lock(&req->waitq.lock);\n\t\tif (test_bit(FR_ABORTED, &req->flags))\n\t\t\terr = -ENOENT;\n\t\telse\n\t\t\tclear_bit(FR_LOCKED, &req->flags);\n\t\tspin_unlock(&req->waitq.lock);\n\t}\n\treturn err;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":129777,"func":"const char *server_feature_value(const char *feature, int *len)\n{\n\treturn parse_feature_value(server_capabilities_v1, feature, len);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":53165,"func":"static void comedi_device_init(struct comedi_device *dev)\n{\n\tmemset(dev, 0, sizeof(struct comedi_device));\n\tspin_lock_init(&dev->spinlock);\n\tmutex_init(&dev->mutex);\n\tdev->minor = -1;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":400804,"func":"gs_is_pdf14trans_compositor(const gs_composite_t * pct)\n{\n    return (pct->type == &gs_composite_pdf14trans_type\n                || pct->type == &gs_composite_pdf14trans_no_clist_writer_type);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":370279,"func":"i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,\n\t\t\t\tstruct list_head *objects)\n{\n\tstruct drm_i915_gem_object *obj;\n\tuint32_t flush_domains = 0;\n\tint ret;\n\n\tlist_for_each_entry(obj, objects, exec_list) {\n\t\tret = i915_gem_object_sync(obj, ring);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tif (obj->base.write_domain & I915_GEM_DOMAIN_CPU)\n\t\t\ti915_gem_clflush_object(obj);\n\n\t\tflush_domains |= obj->base.write_domain;\n\t}\n\n\tif (flush_domains & I915_GEM_DOMAIN_CPU)\n\t\ti915_gem_chipset_flush(ring->dev);\n\n\tif (flush_domains & I915_GEM_DOMAIN_GTT)\n\t\twmb();\n\n\t\/* Unconditionally invalidate gpu caches and ensure that we do flush\n\t * any residual writes from the previous batch.\n\t *\/\n\treturn intel_ring_invalidate_all_caches(ring);\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":93357,"func":"static int smtp_auth_oauth(struct Connection *conn)\n{\n  mutt_message(_(\"Authenticating (OAUTHBEARER)...\"));\n\n  \/* We get the access token from the smtp_oauth_refresh_command *\/\n  char *oauthbearer = mutt_account_getoauthbearer(&conn->account);\n  if (!oauthbearer)\n    return SMTP_AUTH_FAIL;\n\n  size_t ilen = strlen(oauthbearer) + 30;\n  char *ibuf = mutt_mem_malloc(ilen);\n  snprintf(ibuf, ilen, \"AUTH OAUTHBEARER %s\\r\\n\", oauthbearer);\n\n  int rc = mutt_socket_send(conn, ibuf);\n  FREE(&oauthbearer);\n  FREE(&ibuf);\n\n  if (rc == -1)\n    return SMTP_AUTH_FAIL;\n  if (smtp_get_resp(conn) != 0)\n    return SMTP_AUTH_FAIL;\n\n  return SMTP_AUTH_SUCCESS;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":388904,"func":"static void msix_clear_all_vectors(PCIDevice *dev)\n{\n    int vector;\n\n    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {\n        msix_clr_pending(dev, vector);\n    }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":414135,"func":"free_mods (GPtrArray *mods)\n{\n\tgint i = 0;\n\tLDAPMod *mod;\n\n\twhile ((mod = g_ptr_array_index (mods, i++))) {\n\t\tgint j;\n\t\tg_free (mod->mod_type);\n\n\t\tif (mod->mod_op & LDAP_MOD_BVALUES && mod->mod_bvalues) {\n\t\t\tfor (j = 0; mod->mod_bvalues[j]; j++) {\n\t\t\t\tg_free (mod->mod_bvalues[j]->bv_val);\n\t\t\t\tg_free (mod->mod_bvalues[j]);\n\t\t\t}\n\t\t}\n\t\telse if (mod->mod_values) {\n\t\t\tfor (j = 0; mod->mod_values[j]; j++)\n\t\t\t\tg_free (mod->mod_values[j]);\n\t\t}\n\t\tg_free (mod);\n\t}\n\n\tg_ptr_array_free (mods, TRUE);\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":457621,"func":"static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,\n\t\tint write)\n{\n\tstruct page *page;\n\tint ret;\n\tunsigned int gup_flags = FOLL_FORCE;\n\n#ifdef CONFIG_STACK_GROWSUP\n\tif (write) {\n\t\tret = expand_downwards(bprm->vma, pos);\n\t\tif (ret < 0)\n\t\t\treturn NULL;\n\t}\n#endif\n\n\tif (write)\n\t\tgup_flags |= FOLL_WRITE;\n\n\t\/*\n\t * We are doing an exec().  'current' is the process\n\t * doing the exec and bprm->mm is the new process's mm.\n\t *\/\n\tret = get_user_pages_remote(bprm->mm, pos, 1, gup_flags,\n\t\t\t&page, NULL, NULL);\n\tif (ret <= 0)\n\t\treturn NULL;\n\n\tif (write)\n\t\tacct_arg_size(bprm, vma_pages(bprm->vma));\n\n\treturn page;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":475324,"func":"static int sev_send_cancel(struct kvm *kvm, struct kvm_sev_cmd *argp)\n{\n\tstruct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;\n\tstruct sev_data_send_cancel data;\n\n\tif (!sev_guest(kvm))\n\t\treturn -ENOTTY;\n\n\tdata.handle = sev->handle;\n\treturn sev_issue_cmd(kvm, SEV_CMD_SEND_CANCEL, &data, &argp->error);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":1054,"func":"void * xmlListReverseSearch ( xmlListPtr l , void * data ) {\n xmlLinkPtr lk ;\n if ( l == NULL ) return ( NULL ) ;\n lk = xmlListLinkReverseSearch ( l , data ) ;\n if ( lk ) return ( lk -> data ) ;\n return NULL ;\n }","target":1,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":364199,"func":"SendFullColorRect(rfbClientPtr cl,\n                  int w,\n                  int h)\n{\n    int streamId = 0;\n    int len;\n\n    if (cl->ublen + TIGHT_MIN_TO_COMPRESS + 1 > UPDATE_BUF_SIZE) {\n        if (!rfbSendUpdateBuf(cl))\n            return FALSE;\n    }\n\n    cl->updateBuf[cl->ublen++] = 0x00;  \/* stream id = 0, no flushing, no filter *\/\n    rfbStatRecordEncodingSentAdd(cl, rfbEncodingTight, 1);\n\n    if (usePixelFormat24) {\n        Pack24(cl, tightBeforeBuf, &cl->format, w * h);\n        len = 3;\n    } else\n        len = cl->format.bitsPerPixel \/ 8;\n\n    return CompressData(cl, streamId, w * h * len,\n                        tightConf[compressLevel].rawZlibLevel,\n                        Z_DEFAULT_STRATEGY);\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":420195,"func":"    ExifData::const_iterator focalLength(const ExifData& ed)\n    {\n        static const char* keys[] = {\n            \"Exif.Photo.FocalLength\",\n            \"Exif.Image.FocalLength\",\n            \"Exif.Canon.FocalLength\",\n            \"Exif.NikonLd2.FocalLength\",\n            \"Exif.NikonLd3.FocalLength\",\n            \"Exif.MinoltaCsNew.FocalLength\",\n            \"Exif.Pentax.FocalLength\",\n            \"Exif.PentaxDng.FocalLength\",\n            \"Exif.Casio2.FocalLength\"\n        };\n        return findMetadatum(ed, keys, EXV_COUNTOF(keys));\n    }","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":9406,"func":" std::string MasterPreferences::GetVariationsSeed() const {\n  return ExtractPrefString(prefs::kVariationsSeed);\n }\n","target":1,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":360565,"func":"message_received_cb (UniqueApp         *unique_app,\n                     UniqueCommand      command,\n                     UniqueMessageData *message,\n                     guint              time_,\n                     gpointer           user_data)\n{\n\tNautilusApplication *application;\n\tUniqueResponse res;\n\tchar **uris;\n\tchar *geometry;\n\t\n\tapplication =  user_data;\n\tres = UNIQUE_RESPONSE_OK;\n\t\n\tswitch (command) {\n\tcase UNIQUE_CLOSE:\n\t\tres = UNIQUE_RESPONSE_OK;\n\t\tnautilus_main_event_loop_quit (TRUE);\n\t\t\n\t\tbreak;\n\tcase UNIQUE_OPEN:\n\tcase COMMAND_OPEN_BROWSER:\n\t\turis = _unique_message_data_get_geometry_and_uris (message, &geometry);\n\t\topen_windows (application,\n\t\t\t      unique_message_data_get_startup_id (message),\n\t\t\t      uris,\n\t\t\t      geometry,\n\t\t\t      command == COMMAND_OPEN_BROWSER);\n\t\tg_strfreev (uris);\n\t\tg_free (geometry);\n\t\tbreak;\n\tcase COMMAND_START_DESKTOP:\n\t\tnautilus_application_open_desktop (application);\n\t\tbreak;\n\tcase COMMAND_STOP_DESKTOP:\n\t\tnautilus_application_close_desktop ();\n\t\tbreak;\n\tdefault:\n\t\tres = UNIQUE_RESPONSE_PASSTHROUGH;\n\t\tbreak;\n\t}\n\t\n\treturn res;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":446468,"func":"virDomainChrPreAlloc(virDomainDefPtr vmdef,\n                     virDomainChrDefPtr chr)\n{\n    virDomainChrDefPtr **arrPtr = NULL;\n    size_t *cntPtr = NULL;\n\n    if (virDomainChrGetDomainPtrsInternal(vmdef, chr->deviceType,\n                                          &arrPtr, &cntPtr) < 0)\n        return -1;\n\n    return VIR_REALLOC_N(*arrPtr, *cntPtr + 1);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":16350,"func":"int event_del ( struct event * ev ) {\n struct event_base * base ;\n event_debug ( ( \"event_del: %p, callback %p\" , ev , ev -> ev_callback ) ) ;\n if ( ev -> ev_base == NULL ) return ( - 1 ) ;\n base = ev -> ev_base ;\n assert ( ! ( ev -> ev_flags & ~ EVLIST_ALL ) ) ;\n if ( ev -> ev_ncalls && ev -> ev_pncalls ) {\n * ev -> ev_pncalls = 0 ;\n }\n if ( ev -> ev_flags & EVLIST_TIMEOUT ) event_queue_remove ( base , ev , EVLIST_TIMEOUT ) ;\n if ( ev -> ev_flags & EVLIST_ACTIVE ) event_queue_remove ( base , ev , EVLIST_ACTIVE ) ;\n if ( ev -> ev_flags & EVLIST_INSERTED ) {\n event_queue_remove ( base , ev , EVLIST_INSERTED ) ;\n return ( base -> evsel -> del ( base -> evbase , ev ) ) ;\n }\n return ( 0 ) ;\n }","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":38120,"func":"size_t HTTP2Codec::generateCertificateRequest(\n    folly::IOBufQueue& writeBuf,\n    uint16_t requestId,\n    std::unique_ptr<folly::IOBuf> certificateRequestData) {\n  VLOG(4) << \"generating CERTIFICATE_REQUEST with Request-ID=\" << requestId;\n  return http2::writeCertificateRequest(\n      writeBuf, requestId, std::move(certificateRequestData));\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":331430,"func":"void pl011_init(uint32_t base, qemu_irq irq,\n\n                CharDriverState *chr)\n\n{\n\n    int iomemtype;\n\n    pl011_state *s;\n\n\n\n    s = (pl011_state *)qemu_mallocz(sizeof(pl011_state));\n\n    iomemtype = cpu_register_io_memory(0, pl011_readfn,\n\n                                       pl011_writefn, s);\n\n    cpu_register_physical_memory(base, 0x00000fff, iomemtype);\n\n    s->base = base;\n\n    s->irq = irq;\n\n    s->chr = chr;\n\n    s->read_trigger = 1;\n\n    s->ifl = 0x12;\n\n    s->cr = 0x300;\n\n    s->flags = 0x90;\n\n    if (chr){ \n\n        qemu_chr_add_handlers(chr, pl011_can_recieve, pl011_recieve,\n\n                              pl011_event, s);\n\n    }\n\n    \/* ??? Save\/restore.  *\/\n\n}\n","target":1,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":163082,"func":"void bta_hl_co_get_tx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,\n                            UINT16 buf_size, UINT8 *p_buf,  UINT16 evt)\n{\n    UINT8 app_idx, mcl_idx, mdl_idx;\n btif_hl_mdl_cb_t *p_dcb;\n    tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;\n\n    BTIF_TRACE_DEBUG(\"%s app_id=%d mdl_handle=0x%x buf_size=%d\",\n                      __FUNCTION__, app_id, mdl_handle, buf_size);\n\n if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx))\n {\n        p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);\n\n if (p_dcb->tx_size <= buf_size )\n {\n            memcpy(p_buf, p_dcb->p_tx_pkt, p_dcb->tx_size);\n            btif_hl_free_buf((void **) &p_dcb->p_tx_pkt);\n            p_dcb->tx_size = 0;\n            status = BTA_HL_STATUS_OK;\n }\n }\n\n\n    bta_hl_ci_get_tx_data(mdl_handle,  status, evt);\n\n}\n","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":496889,"func":"ReturnCode_t DataWriterImpl::write(\n        void* data,\n        const fastrtps::rtps::InstanceHandle_t& handle)\n{\n    if (writer_ == nullptr)\n    {\n        return ReturnCode_t::RETCODE_NOT_ENABLED;\n    }\n\n    InstanceHandle_t instance_handle;\n    if (type_.get()->m_isGetKeyDefined)\n    {\n        bool is_key_protected = false;\n#if HAVE_SECURITY\n        is_key_protected = writer_->getAttributes().security_attributes().is_key_protected;\n#endif \/\/ if HAVE_SECURITY\n        type_.get()->getKey(data, &instance_handle, is_key_protected);\n    }\n\n    \/\/Check if the Handle is different from the special value HANDLE_NIL and\n    \/\/does not correspond with the instance referred by the data\n    if (handle.isDefined() && handle.value != instance_handle.value)\n    {\n        return ReturnCode_t::RETCODE_PRECONDITION_NOT_MET;\n    }\n    logInfo(DATA_WRITER, \"Writing new data with Handle\");\n    WriteParams wparams;\n    if (create_new_change_with_params(ALIVE, data, wparams, instance_handle))\n    {\n        return ReturnCode_t::RETCODE_OK;\n    }\n    return ReturnCode_t::RETCODE_ERROR;\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":216661,"func":"crypto_cert_get_count(krb5_context context,\n                      pkinit_plg_crypto_context plg_cryptoctx,\n                      pkinit_req_crypto_context req_cryptoctx,\n                      pkinit_identity_crypto_context id_cryptoctx,\n                      int *cert_count)\n{\n    int count;\n\n    if (id_cryptoctx == NULL || id_cryptoctx->creds[0] == NULL)\n        return EINVAL;\n\n    for (count = 0;\n         count <= MAX_CREDS_ALLOWED && id_cryptoctx->creds[count] != NULL;\n         count++);\n    *cert_count = count;\n    return 0;\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":287426,"func":"static inline int pmd_large(pmd_t pte)\n{\n\treturn (pmd_flags(pte) & (_PAGE_PSE | _PAGE_PRESENT)) ==\n\t\t(_PAGE_PSE | _PAGE_PRESENT);\n}","target":1,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":226156,"func":"  FocusCycler* focus_cycler() { return focus_cycler_; }\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":126540,"func":"static inline int tcp_may_update_window(const struct tcp_sock *tp,\n\t\t\t\t\tconst u32 ack, const u32 ack_seq,\n\t\t\t\t\tconst u32 nwin)\n{\n\treturn\tafter(ack, tp->snd_una) ||\n\t\tafter(ack_seq, tp->snd_wl1) ||\n\t\t(ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":192347,"func":"ZEND_API void zend_class_implements(zend_class_entry *class_entry TSRMLS_DC, int num_interfaces, ...) \/* {{{ *\/\n{\n\tzend_class_entry *interface_entry;\n\tva_list interface_list;\n\tva_start(interface_list, num_interfaces);\n\n\twhile (num_interfaces--) {\n\t\tinterface_entry = va_arg(interface_list, zend_class_entry *);\n\t\tzend_do_implement_interface(class_entry, interface_entry TSRMLS_CC);\n\t}\n\n\tva_end(interface_list);\n}\n\/* }}} *\/\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":178969,"func":"get_control(png_const_structrp png_ptr)\n{\n\n    \/* This just returns the (file*).  The chunk and idat control structures\n     * don't always exist.\n     *\/\n   struct control *control = voidcast(struct control*,\n       png_get_error_ptr(png_ptr));\n    return &control->file;\n }\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":228682,"func":" void Bluetooth::RequestDeviceCallback(\n     ScriptPromiseResolver* resolver,\n     mojom::blink::WebBluetoothResult result,\n    mojom::blink::WebBluetoothDevicePtr device) {\n  if (!resolver->GetExecutionContext() ||\n      resolver->GetExecutionContext()->IsContextDestroyed()) {\n    return;\n  }\n\n  if (result == mojom::blink::WebBluetoothResult::SUCCESS) {\n    BluetoothDevice* bluetooth_device = GetBluetoothDeviceRepresentingDevice(\n        std::move(device), resolver->GetExecutionContext());\n    resolver->Resolve(bluetooth_device);\n  } else {\n    resolver->Reject(BluetoothError::CreateDOMException(result));\n  }\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":214606,"func":"  DetectedLanguage(const std::string& language, int percentage)\n      : language(language), percentage(percentage) {}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":276928,"func":"static void staticReadOnlyLongAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    v8SetReturnValueInt(info, TestObject::staticReadOnlyLongAttr());\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":211447,"func":"void SessionService::RecordUpdatedNavEntryCommit(base::TimeDelta delta,\n                                                 bool use_long_period) {\n  std::string name(\"SessionRestore.NavEntryCommittedPeriod\");\n  UMA_HISTOGRAM_CUSTOM_TIMES(name,\n      delta,\n      save_delay_in_millis_,\n      save_delay_in_mins_,\n      50);\n  if (use_long_period) {\n    std::string long_name_(\"SessionRestore.NavEntryCommittedLongPeriod\");\n    UMA_HISTOGRAM_CUSTOM_TIMES(long_name_,\n        delta,\n        save_delay_in_mins_,\n        save_delay_in_hrs_,\n        50);\n  }\n}\n","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":285061,"func":"void Element::setSavedLayerScrollOffset(const IntSize& size)\n{\n    if (size.isZero() && !hasRareData())\n        return;\n    ensureElementRareData()->setSavedLayerScrollOffset(size);\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":518430,"func":"GRANT_INFO *Field_iterator_table_ref::grant()\n{\n  if (table_ref->view)\n    return &(table_ref->grant);\n  else if (table_ref->is_natural_join)\n    return natural_join_it.column_ref()->grant();\n  return &(table_ref->table->grant);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":144345,"func":"CAMLprim value caml_input_value(value vchan)\n{\n  CAMLparam1 (vchan);\n  struct channel * chan = Channel(vchan);\n  CAMLlocal1 (res);\n\n  Lock(chan);\n  res = caml_input_val(chan);\n  Unlock(chan);\n  CAMLreturn (res);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":128196,"func":"static void tg3_free_rings(struct tg3 *tp)\n{\n\tint i, j;\n\n\tfor (j = 0; j < tp->irq_cnt; j++) {\n\t\tstruct tg3_napi *tnapi = &tp->napi[j];\n\n\t\ttg3_rx_prodring_free(tp, &tnapi->prodring);\n\n\t\tif (!tnapi->tx_buffers)\n\t\t\tcontinue;\n\n\t\tfor (i = 0; i < TG3_TX_RING_SIZE; i++) {\n\t\t\tstruct sk_buff *skb = tnapi->tx_buffers[i].skb;\n\n\t\t\tif (!skb)\n\t\t\t\tcontinue;\n\n\t\t\ttg3_tx_skb_unmap(tnapi, i,\n\t\t\t\t\t skb_shinfo(skb)->nr_frags - 1);\n\n\t\t\tdev_kfree_skb_any(skb);\n\t\t}\n\t\tnetdev_tx_reset_queue(netdev_get_tx_queue(tp->dev, j));\n\t}\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":66723,"func":"static unsigned tget(GetByteContext *gb, int type, int le)\n\n{\n\n    switch (type) {\n\n    case TIFF_BYTE : return bytestream2_get_byteu(gb);\n\n    case TIFF_SHORT: return tget_short(gb, le);\n\n    case TIFF_LONG : return tget_long(gb, le);\n\n    default        : return UINT_MAX;\n\n    }\n\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":252939,"func":"void ChromeRenderMessageFilter::OnExtensionGenerateUniqueID(int* unique_id) {\n  static int next_unique_id = 1;\n   *unique_id = next_unique_id++;\n }\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":340350,"func":"static VirtIOSCSIReq *virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq)\n\n{\n\n    VirtIOSCSIReq *req;\n\n    req = g_malloc(sizeof(*req));\n\n\n\n    req->vq = vq;\n\n    req->dev = s;\n\n    req->sreq = NULL;\n\n    qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);\n\n    return req;\n\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":48640,"func":"static inline void compat_release_entry(struct compat_arpt_entry *e)\n{\n\tstruct xt_entry_target *t;\n\n\tt = compat_arpt_get_target(e);\n\tmodule_put(t->u.kernel.target->me);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":252361,"func":"static inline void boundaryNodeChildrenChanged(RangeBoundaryPoint& boundary, ContainerNode* container)\n{\n    if (!boundary.childBefore())\n        return;\n    if (boundary.container() != container)\n        return;\n    boundary.invalidateOffset();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":128907,"func":"vim_isNormalIDc(int c)\n{\n    return ASCII_ISALNUM(c) || c == '_';\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":228361,"func":"PHP_METHOD(domdocument, loadHTMLFile)\n{\n\tdom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE);\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":514384,"func":"Local<FunctionTemplate> LibuvStreamWrap::GetConstructorTemplate(\n    Environment* env) {\n  Local<FunctionTemplate> tmpl = env->libuv_stream_wrap_ctor_template();\n  if (tmpl.IsEmpty()) {\n    tmpl = env->NewFunctionTemplate(nullptr);\n    tmpl->SetClassName(\n        FIXED_ONE_BYTE_STRING(env->isolate(), \"LibuvStreamWrap\"));\n    tmpl->Inherit(HandleWrap::GetConstructorTemplate(env));\n    Local<FunctionTemplate> get_write_queue_size =\n        FunctionTemplate::New(env->isolate(),\n                              GetWriteQueueSize,\n                              env->as_external(),\n                              Signature::New(env->isolate(), tmpl));\n    tmpl->PrototypeTemplate()->SetAccessorProperty(\n        env->write_queue_size_string(),\n        get_write_queue_size,\n        Local<FunctionTemplate>(),\n        static_cast<PropertyAttribute>(ReadOnly | DontDelete));\n    env->SetProtoMethod(tmpl, \"setBlocking\", SetBlocking);\n    StreamBase::AddMethods<LibuvStreamWrap>(env, tmpl);\n    env->set_libuv_stream_wrap_ctor_template(tmpl);\n  }\n  return tmpl;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":279457,"func":" static void CopyArguments(Arguments* args, Handle<FixedArrayBase> dst_store,\n uint32_t copy_size, uint32_t src_index,\n uint32_t dst_index) {\n DisallowHeapAllocation no_gc;\n FixedArrayBase* raw_backing_store = *dst_store;\n WriteBarrierMode mode = raw_backing_store->GetWriteBarrierMode(no_gc);\n for (uint32_t i = 0; i < copy_size; i++) {\n Object* argument = (*args)[src_index + i];\n      DCHECK(!argument->IsTheHole(raw_backing_store->GetIsolate()));\n Subclass::SetImpl(raw_backing_store, dst_index + i, argument, mode);\n }\n }\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":423743,"func":"dns_zone_getrcvquerystats(dns_zone_t *zone) {\n\tif (zone->requeststats_on)\n\t\treturn (zone->rcvquerystats);\n\telse\n\t\treturn (NULL);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":420764,"func":"close_tls_session (http_session_t sess)\n{\n  if (sess->tls_session)\n    {\n# if HTTP_USE_NTBTLS\n      \/* FIXME!!\n         Possibly, ntbtls_get_transport and close those streams.\n         Somehow get SOCK to call my_socket_unref.\n      *\/\n      ntbtls_release (sess->tls_session);\n# elif HTTP_USE_GNUTLS\n      my_socket_t sock = gnutls_transport_get_ptr (sess->tls_session);\n      my_socket_unref (sock, NULL, NULL);\n      gnutls_deinit (sess->tls_session);\n      if (sess->certcred)\n        gnutls_certificate_free_credentials (sess->certcred);\n# endif \/*HTTP_USE_GNUTLS*\/\n      xfree (sess->servername);\n      sess->tls_session = NULL;\n    }\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":466732,"func":"static void vvalue_strbuf_append_str(wmem_strbuf_t *strbuf, void *ptr)\n{\n\tstruct data_str *str = (struct data_str*)ptr;\n\twmem_strbuf_append_printf(strbuf, \"\\\"%s\\\"\", str->str);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":327430,"func":"void ff_put_h264_qpel4_mc21_msa(uint8_t *dst, const uint8_t *src,\n\n                                ptrdiff_t stride)\n\n{\n\n    avc_luma_midv_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 0);\n\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":230728,"func":"TargetHandler::Throttle::~Throttle() {\n  CleanupPointers();\n}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":36889,"func":"static PHP_INI_MH(OnUpdateSaveDir) \/* {{{ *\/\n{\n\t\/* Only do the safemode\/open_basedir check at runtime *\/\n\tif (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) {\n\t\tchar *p;\n\n\t\tif (memchr(new_value, '\\0', new_value_length) != NULL) {\n\t\t\treturn FAILURE;\n\t\t}\n\n\t\t\/* we do not use zend_memrchr() since path can contain ; itself *\/\n\t\tif ((p = strchr(new_value, ';'))) {\n\t\t\tchar *p2;\n\t\t\tp++;\n\t\t\tif ((p2 = strchr(p, ';'))) {\n\t\t\t\tp = p2 + 1;\n\t\t\t}\n\t\t} else {\n\t\t\tp = new_value;\n\t\t}\n\n\t\tif (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) {\n\t\t\treturn FAILURE;\n\t\t}\n\t}\n\n\tOnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);\n\treturn SUCCESS;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":339373,"func":"static int v9fs_synth_mknod(FsContext *fs_ctx, V9fsPath *path,\n\n                       const char *buf, FsCred *credp)\n\n{\n\n    errno = EPERM;\n\n    return -1;\n\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":18624,"func":"static bool virtio_net_started ( VirtIONet * n , uint8_t status ) {\n return ( status & VIRTIO_CONFIG_S_DRIVER_OK ) && ( n -> status & VIRTIO_NET_S_LINK_UP ) && n -> vdev . vm_running ;\n }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":416921,"func":"static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)\n{\n\tint i, j, k;\n\tstruct hid_report *report;\n\tstruct hid_usage *usage;\n\n\tfor (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {\n\t\tlist_for_each_entry(report, &hid->report_enum[k].report_list, list) {\n\t\t\tfor (i = 0; i < report->maxfield; i++) {\n\t\t\t\tfor ( j = 0; j < report->field[i]->maxusage; j++) {\n\t\t\t\t\tusage = report->field[i]->usage + j;\n\t\t\t\t\thid_resolv_usage(usage->hid, f);\n\t\t\t\t\tseq_printf(f, \" ---> \");\n\t\t\t\t\thid_resolv_event(usage->type, usage->code, f);\n\t\t\t\t\tseq_printf(f, \"\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":146519,"func":"void Magick::Image::textUnderColor(const Color &underColor_)\n{\n  modifyImage();\n  options()->textUnderColor(underColor_);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":31220,"func":"void uprint ( const UChar * s , FILE * f , UErrorCode * status ) {\n UConverter * converter ;\n char buf [ BUF_SIZE ] ;\n int32_t sourceLen ;\n const UChar * mySource ;\n const UChar * mySourceEnd ;\n char * myTarget ;\n int32_t arraySize ;\n if ( s == 0 ) return ;\n sourceLen = u_strlen ( s ) ;\n mySource = s ;\n mySourceEnd = mySource + sourceLen ;\n myTarget = buf ;\n arraySize = BUF_SIZE ;\n converter = ucnv_open ( 0 , status ) ;\n if ( U_FAILURE ( * status ) ) goto finish ;\n do {\n * status = U_ZERO_ERROR ;\n ucnv_fromUnicode ( converter , & myTarget , myTarget + arraySize , & mySource , mySourceEnd , NULL , TRUE , status ) ;\n fwrite ( buf , sizeof ( char ) , myTarget - buf , f ) ;\n myTarget = buf ;\n arraySize = BUF_SIZE ;\n }\n while ( * status == U_BUFFER_OVERFLOW_ERROR ) ;\n finish : ucnv_close ( converter ) ;\n }","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":65505,"func":"xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode,\n                      xmlNodePtr lastNode)\n{\n    if (xmlEntityRefFunc != NULL) {\n        (*xmlEntityRefFunc) (ent, firstNode, lastNode);\n    }\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":182946,"func":"ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n  LazyInitialize();\n  if (!extensions_request_context_getter_) {\n    extensions_request_context_getter_ =\n        ChromeURLRequestContextGetter::CreateOriginalForExtensions(\n            profile_, io_data_);\n  }\n  return extensions_request_context_getter_;\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":366795,"func":"static int task_has_system(struct task_struct *tsk,\n\t\t\t   u32 perms)\n{\n\tu32 sid = task_sid(tsk);\n\n\treturn avc_has_perm(sid, SECINITSID_KERNEL,\n\t\t\t    SECCLASS_SYSTEM, perms, NULL);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":509723,"func":"gx_image1_mask_sput(const gs_image_common_t *pic, stream *s,\n                    const gs_color_space **ignore_ppcs)\n{\n    const gs_image_t *pim = (const gs_image_t *)pic;\n    uint control =\n        (gx_image_matrix_is_default((const gs_data_image_t *)pim) ? 0 :\n         MI_ImageMatrix) |\n        (pim->Decode[0] != 0 ? MI_Decode : 0) |\n        (pim->Interpolate ? MI_Interpolate : 0) |\n        (pim->adjust ? MI_adjust : 0) |\n        (pim->Alpha << MI_Alpha_SHIFT) |\n        ((pim->BitsPerComponent - 1) << MI_BPC_SHIFT);\n\n    sput_variable_uint(s, control);\n    sput_variable_uint(s, (uint)pim->Width);\n    sput_variable_uint(s, (uint)pim->Height);\n    if (control & MI_ImageMatrix)\n        sput_matrix(s, &pim->ImageMatrix);\n    return 0;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":459039,"func":"static void iscsi_detach_aio_context(BlockDriverState *bs)\n{\n    IscsiLun *iscsilun = bs->opaque;\n\n    aio_set_fd_handler(iscsilun->aio_context, iscsi_get_fd(iscsilun->iscsi),\n                       false, NULL, NULL, NULL, NULL);\n    iscsilun->events = 0;\n\n    if (iscsilun->nop_timer) {\n        timer_del(iscsilun->nop_timer);\n        timer_free(iscsilun->nop_timer);\n        iscsilun->nop_timer = NULL;\n    }\n    if (iscsilun->event_timer) {\n        timer_del(iscsilun->event_timer);\n        timer_free(iscsilun->event_timer);\n        iscsilun->event_timer = NULL;\n    }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":378831,"func":"static const char *wsgi_server_group(request_rec *r, const char *s)\n{\n    const char *name = NULL;\n\n    const char *h = NULL;\n    apr_port_t p = 0;\n\n    if (!s)\n        return \"\";\n\n    if (*s != '%')\n        return s;\n\n    name = s + 1;\n\n    if (*name) {\n        if (!strcmp(name, \"{SERVER}\")) {\n            h = r->server->server_hostname;\n            p = ap_get_server_port(r);\n\n            if (p != DEFAULT_HTTP_PORT && p != DEFAULT_HTTPS_PORT)\n                return apr_psprintf(r->pool, \"%s:%u\", h, p);\n            else\n                return h;\n        }\n\n        if (!strcmp(name, \"{GLOBAL}\"))\n            return \"\";\n    }\n\n    return s;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":257474,"func":"void prplcb_conv_free ( PurpleConversation * conv ) {\n struct groupchat * gc = conv -> ui_data ;\n imcb_chat_free ( gc ) ;\n }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":423210,"func":"static void tcp_send_challenge_ack(struct sock *sk)\n{\n\t\/* unprotected vars, we dont care of overwrites *\/\n\tstatic u32 challenge_timestamp;\n\tstatic unsigned int challenge_count;\n\tu32 now = jiffies \/ HZ;\n\n\tif (now != challenge_timestamp) {\n\t\tchallenge_timestamp = now;\n\t\tchallenge_count = 0;\n\t}\n\tif (++challenge_count <= sysctl_tcp_challenge_ack_limit) {\n\t\tNET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK);\n\t\ttcp_send_ack(sk);\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":143766,"func":"static void free_resources()\n{\n  if (md_result_file && md_result_file != stdout)\n    my_fclose(md_result_file, MYF(0));\n  my_free(opt_password);\n  if (my_hash_inited(&ignore_table))\n    my_hash_free(&ignore_table);\n  if (extended_insert)\n    dynstr_free(&extended_row);\n  if (insert_pat_inited)\n    dynstr_free(&insert_pat);\n  if (defaults_argv)\n    free_defaults(defaults_argv);\n  if (opt_ignore_error)\n    my_free(opt_ignore_error);\n  delete_dynamic(&ignore_error);\n  my_end(my_end_arg);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":260205,"func":"\tCmdResult Handle(const std::vector<std::string>& parameters, User *user)\n\t{\n\t\tUser* target = ServerInstance->FindNick(parameters[1]);\n\t\tif ((!target) || (IS_SERVER(target)))\n\t\t{\n\t\t\tServerInstance->Logs->Log(\"m_sasl\", DEBUG,\"User not found in sasl ENCAP event: %s\", parameters[1].c_str());\n\t\t\treturn CMD_FAILURE;\n\t\t}\n\n\t\tSaslAuthenticator *sasl = authExt.get(target);\n\t\tif (!sasl)\n\t\t\treturn CMD_FAILURE;\n\n\t\tSaslState state = sasl->ProcessInboundMessage(parameters);\n\t\tif (state == SASL_DONE)\n\t\t{\n\t\t\tsasl->AnnounceState();\n\t\t\tauthExt.unset(target);\n\t\t}\n\t\treturn CMD_SUCCESS;\n\t}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":365439,"func":"nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)\n{\n    if (ctxt == NULL) return(0);\n    if (ctxt->nodeNr >= ctxt->nodeMax) {\n        xmlNodePtr *tmp;\n\n\ttmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,\n                                      ctxt->nodeMax * 2 *\n                                      sizeof(ctxt->nodeTab[0]));\n        if (tmp == NULL) {\n            xmlErrMemory(ctxt, NULL);\n            return (-1);\n        }\n        ctxt->nodeTab = tmp;\n\tctxt->nodeMax *= 2;\n    }\n    if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&\n        ((ctxt->options & XML_PARSE_HUGE) == 0)) {\n\txmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,\n\t\t \"Excessive depth in document: %d use XML_PARSE_HUGE option\\n\",\n\t\t\t  xmlParserMaxDepth);\n\tctxt->instate = XML_PARSER_EOF;\n\treturn(-1);\n    }\n    ctxt->nodeTab[ctxt->nodeNr] = value;\n    ctxt->node = value;\n    return (ctxt->nodeNr++);\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":109114,"func":"static void perf_free_event(struct perf_event *event,\n\t\t\t    struct perf_event_context *ctx)\n{\n\tstruct perf_event *parent = event->parent;\n\n\tif (WARN_ON_ONCE(!parent))\n\t\treturn;\n\n\tmutex_lock(&parent->child_mutex);\n\tlist_del_init(&event->child_list);\n\tmutex_unlock(&parent->child_mutex);\n\n\tfput(parent->filp);\n\n\tperf_group_detach(event);\n\tlist_del_event(event, ctx);\n\tfree_event(event);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":319987,"func":"void cpu_exit(CPUState *cpu)\n\n{\n\n    cpu->exit_request = 1;\n\n    \/* Ensure cpu_exec will see the exit request after TCG has exited.  *\/\n\n    smp_wmb();\n\n    cpu->tcg_exit_req = 1;\n\n}\n","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":117004,"func":"char *http_content_type(ci_request_t * req)\n{\n     ci_headers_list_t *heads;\n     char *val;\n     if (!(heads =  ci_http_response_headers(req))) {\n          \/* Then maybe is a reqmod request, try to get request headers *\/\n          if (!(heads = ci_http_request_headers(req)))\n               return NULL;\n     }\n     if (!(val = ci_headers_value(heads, \"Content-Type\")))\n          return NULL;\n\n     return val;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":212965,"func":"static bool IsRequiredForInjection(UChar c) {\n  return (c == '\\'' || c == '\"' || c == '<' || c == '>');\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":125827,"func":"static int ext4_index_trans_blocks(struct inode *inode, int nrblocks, int chunk)\n{\n\tif (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))\n\t\treturn ext4_indirect_trans_blocks(inode, nrblocks, chunk);\n\treturn ext4_ext_index_trans_blocks(inode, nrblocks, chunk);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":458012,"func":"gdm_session_worker_handle_start_reauthentication (GdmDBusWorker         *object,\n                                                  GDBusMethodInvocation *invocation,\n                                                  int                    pid_of_caller,\n                                                  int                    uid_of_caller)\n{\n        GdmSessionWorker *worker = GDM_SESSION_WORKER (object);\n        ReauthenticationRequest *request;\n\n        if (worker->priv->state != GDM_SESSION_WORKER_STATE_SESSION_STARTED) {\n                g_dbus_method_invocation_return_error (invocation,\n                                                       GDM_SESSION_WORKER_ERROR,\n                                                       GDM_SESSION_WORKER_ERROR_WRONG_STATE,\n                                                       \"Cannot reauthenticate while in state %s\",\n                                                       get_state_name (worker->priv->state));\n                return TRUE;\n        }\n\n        g_debug (\"GdmSessionWorker: start reauthentication\");\n\n        request = reauthentication_request_new (worker, pid_of_caller, uid_of_caller, invocation);\n        g_hash_table_replace (worker->priv->reauthentication_requests,\n                              GINT_TO_POINTER (pid_of_caller),\n                              request);\n        return TRUE;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":269020,"func":"inline void ArgMax(const RuntimeShape& input1_shape, const T1* input1_data,\n                   const RuntimeShape& input2_shape, const T3* input2_data,\n                   const RuntimeShape& output_shape, T2* output_data) {\n  \/\/ Drop shape of second input: not needed.\n  ArgMax(input1_shape, input1_data, input2_data, output_shape, output_data);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":188222,"func":"void QQuickWebViewExperimental::setContentWidth(qreal width)\n{\n    Q_D(QQuickWebView);\n    ASSERT(d->flickProvider);\n    d->userDidOverrideContentWidth = true;\n    d->flickProvider->setContentWidth(width);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":422419,"func":"e_ews_calendar_period_new (void)\n{\n\treturn g_new0 (EEwsCalendarPeriod, 1);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":365743,"func":"g_random(char* data, int len)\n{\n#if defined(_WIN32)\n  int index;\n\n  srand(g_time1());\n  for (index = 0; index < len; index++)\n  {\n    data[index] = (char)rand(); \/* rand returns a number between 0 and\n                                   RAND_MAX *\/\n  }\n#else\n  int fd;\n\n  memset(data, 0x44, len);\n  fd = open(\"\/dev\/urandom\", O_RDONLY);\n  if (fd == -1)\n  {\n    fd = open(\"\/dev\/random\", O_RDONLY);\n  }\n  if (fd != -1)\n  {\n    if (read(fd, data, len) != len)\n    {\n    }\n    close(fd);\n  }\n#endif\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":130759,"func":"static void mspack_fmap_close(struct mspack_file *file)\n{\n\tstruct mspack_handle *mspack_handle = (struct mspack_handle *)file;\n\n\tif (!mspack_handle)\n\t\treturn;\n\n\tif (mspack_handle->type == FILETYPE_FILENAME)\n\t\tfclose(mspack_handle->f);\n\tfree(mspack_handle);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":53674,"func":"static inline void io_req_complete_state(struct io_kiocb *req, s32 res,\n\t\t\t\t\t u32 cflags)\n{\n\treq->result = res;\n\treq->cflags = cflags;\n\treq->flags |= REQ_F_COMPLETE_INLINE;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":390246,"func":"bool operator>(tm& a, tm& b)\n{\n    if (a.tm_year > b.tm_year)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon > b.tm_mon)\n        return true;\n    \n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon && a.tm_mday >b.tm_mday)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon &&\n        a.tm_mday == b.tm_mday && a.tm_hour > b.tm_hour)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon &&\n        a.tm_mday == b.tm_mday && a.tm_hour == b.tm_hour &&\n        a.tm_min > b.tm_min)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon &&\n        a.tm_mday == b.tm_mday && a.tm_hour == b.tm_hour &&\n        a.tm_min  == b.tm_min  && a.tm_sec > b.tm_sec)\n        return true;\n\n    return false;\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":383976,"func":"gnutls_x509_crt_get_proxy(gnutls_x509_crt_t cert,\n\t\t\t  unsigned int *critical,\n\t\t\t  int *pathlen,\n\t\t\t  char **policyLanguage,\n\t\t\t  char **policy, size_t * sizeof_policy)\n{\n\tint result;\n\tgnutls_datum_t proxyCertInfo;\n\n\tif (cert == NULL) {\n\t\tgnutls_assert();\n\t\treturn GNUTLS_E_INVALID_REQUEST;\n\t}\n\n\tif ((result =\n\t     _gnutls_x509_crt_get_extension(cert, \"1.3.6.1.5.5.7.1.14\", 0,\n\t\t\t\t\t    &proxyCertInfo, critical)) < 0)\n\t{\n\t\treturn result;\n\t}\n\n\tif (proxyCertInfo.size == 0 || proxyCertInfo.data == NULL) {\n\t\tgnutls_assert();\n\t\treturn GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;\n\t}\n\n\tresult = gnutls_x509_ext_import_proxy(&proxyCertInfo, pathlen,\n\t\t\t\t\t\t\tpolicyLanguage,\n\t\t\t\t\t\t\tpolicy,\n\t\t\t\t\t\t\tsizeof_policy);\n\t_gnutls_free_datum(&proxyCertInfo);\n\tif (result < 0) {\n\t\tgnutls_assert();\n\t\treturn result;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":376637,"func":"  ReachabilityAnalyzer(HBasicBlock* entry_block,\n                       int block_count,\n                       HBasicBlock* dont_visit)\n      : visited_count_(0),\n        stack_(16, entry_block->zone()),\n        reachable_(block_count, entry_block->zone()),\n        dont_visit_(dont_visit) {\n    PushBlock(entry_block);\n    Analyze();\n  }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":463011,"func":"        NamespaceString ns() const override {\n            \/\/ TODO get the ns from the parsed QueryRequest.\n            return NamespaceString(CommandHelpers::parseNsFromCommand(_dbName, _request.body));\n        }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":502289,"func":"bool is_attr_in_list(const char * const * attrs, const char *attr)\n{\n\tunsigned int i;\n\n\tfor (i = 0; attrs[i]; i++) {\n\t\tif (ldb_attr_cmp(attrs[i], attr) == 0)\n\t\t\treturn true;\n\t}\n\n\treturn false;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":272696,"func":"static handle_t *ext4_get_nojournal(void)\n{\n\thandle_t *handle = current->journal_info;\n\tunsigned long ref_cnt = (unsigned long)handle;\n\n\tBUG_ON(ref_cnt >= EXT4_NOJOURNAL_MAX_REF_COUNT);\n\n\tref_cnt++;\n\thandle = (handle_t *)ref_cnt;\n\n\tcurrent->journal_info = handle;\n\treturn handle;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":303120,"func":"guard_get_guardfraction_bandwidth(guardfraction_bandwidth_t *guardfraction_bw,\n                                  int orig_bandwidth,\n                                  uint32_t guardfraction_percentage)\n{\n  double guardfraction_fraction;\n\n  \/* Turn the percentage into a fraction. *\/\n  tor_assert(guardfraction_percentage <= 100);\n  guardfraction_fraction = guardfraction_percentage \/ 100.0;\n\n  long guard_bw = tor_lround(guardfraction_fraction * orig_bandwidth);\n  tor_assert(guard_bw <= INT_MAX);\n\n  guardfraction_bw->guard_bw = (int) guard_bw;\n\n  guardfraction_bw->non_guard_bw = orig_bandwidth - (int) guard_bw;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":234280,"func":"AppCache::AppCache(AppCacheStorage* storage, int64_t cache_id)\n    : cache_id_(cache_id),\n      owning_group_(nullptr),\n       online_whitelist_all_(false),\n       is_complete_(false),\n       cache_size_(0),\n      padding_size_(0),\n       storage_(storage) {\n   storage_->working_set()->AddCache(this);\n }\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":517332,"func":"  virtual bool mark_as_eliminated_processor(void *arg) { return 0; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":436784,"func":"char *mksnpath(char *buf, size_t n, const char *fmt, ...)\n{\n\tva_list args;\n\tunsigned len;\n\n\tva_start(args, fmt);\n\tlen = vsnprintf(buf, n, fmt, args);\n\tva_end(args);\n\tif (len >= n) {\n\t\tstrlcpy(buf, bad_path, n);\n\t\treturn buf;\n\t}\n\treturn (char *)cleanup_path(buf);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":511101,"func":"execute_command (command)\n     COMMAND *command;\n{\n  struct fd_bitmap *bitmap;\n  int result;\n\n  current_fds_to_close = (struct fd_bitmap *)NULL;\n  bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);\n  begin_unwind_frame (\"execute-command\");\n  add_unwind_protect (dispose_fd_bitmap, (char *)bitmap);\n\n  \/* Just do the command, but not asynchronously. *\/\n  result = execute_command_internal (command, 0, NO_PIPE, NO_PIPE, bitmap);\n\n  dispose_fd_bitmap (bitmap);\n  discard_unwind_frame (\"execute-command\");\n\n#if defined (PROCESS_SUBSTITUTION)\n  \/* don't unlink fifos if we're in a shell function; wait until the function\n     returns. *\/\n  if (variable_context == 0)\n    unlink_fifo_list ();\n#endif \/* PROCESS_SUBSTITUTION *\/\n\n  QUIT;\n  return (result);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":519896,"func":"  Diagnostics_area *get_stmt_da()\n  { return m_stmt_da; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":429212,"func":"void defer_leftover_input(__G)\n    __GDEF\n{\n    if ((zoff_t)G.incnt > G.csize) {\n        \/* (G.csize < MAXINT), we can safely cast it to int !! *\/\n        if (G.csize < 0L)\n            G.csize = 0L;\n        G.inptr_leftover = G.inptr + (int)G.csize;\n        G.incnt_leftover = G.incnt - (int)G.csize;\n        G.incnt = (int)G.csize;\n    } else\n        G.incnt_leftover = 0;\n    G.csize -= G.incnt;\n} \/* end function defer_leftover_input() *\/","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":123549,"func":"t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount)\n{\n\tuint32 i;\n\n\t\/* For the 3 first samples, there is overlap between source and\n\t * destination, so use memmove().\n\t * See http:\/\/bugzilla.maptools.org\/show_bug.cgi?id=2577\n\t *\/\n\tfor(i = 0; i < 3 && i < samplecount; i++)\n\t\tmemmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3);\n\tfor(; i < samplecount; i++)\n\t\tmemcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3);\n\n\treturn(i * 3);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":16460,"func":"static void e1000e_intrmgr_resume ( E1000ECore * core ) {\n int i ;\n e1000e_intmgr_timer_resume ( & core -> radv ) ;\n e1000e_intmgr_timer_resume ( & core -> rdtr ) ;\n e1000e_intmgr_timer_resume ( & core -> raid ) ;\n e1000e_intmgr_timer_resume ( & core -> tidv ) ;\n e1000e_intmgr_timer_resume ( & core -> tadv ) ;\n e1000e_intmgr_timer_resume ( & core -> itr ) ;\n for ( i = 0 ;\n i < E1000E_MSIX_VEC_NUM ;\n i ++ ) {\n e1000e_intmgr_timer_resume ( & core -> eitr [ i ] ) ;\n }\n }","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":277442,"func":"  DeprecatedAcceleratorNotificationDelegate() {}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":493586,"func":"EXPORTED int mailbox_open_irlnb(const char *name, struct mailbox **mailboxptr)\n{\n    return mailbox_open_advanced(name,\n                                 LOCK_SHARED|LOCK_NONBLOCK,\n                                 \/* cannot do nonblocking lock on index...why? *\/\n                                 LOCK_SHARED,\n                                 NULL, mailboxptr);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":206745,"func":"check_lock_length(u64 offset, u64 length)\n{\n\treturn ((length == 0) || ((length != NFS4_MAX_UINT64) &&\n\t\t(length > ~offset)));\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":484091,"func":"static int __maybe_unused i740fb_suspend(struct device *dev)\n{\n\tstruct fb_info *info = dev_get_drvdata(dev);\n\tstruct i740fb_par *par = info->par;\n\n\tconsole_lock();\n\tmutex_lock(&(par->open_lock));\n\n\t\/* do nothing if framebuffer is not active *\/\n\tif (par->ref_count == 0) {\n\t\tmutex_unlock(&(par->open_lock));\n\t\tconsole_unlock();\n\t\treturn 0;\n\t}\n\n\tfb_set_suspend(info, 1);\n\n\tmutex_unlock(&(par->open_lock));\n\tconsole_unlock();\n\n\treturn 0;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":193826,"func":"inline int Round(double x) {\n  return static_cast<int>(x + 0.5);\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":113884,"func":"static void free_buffers(struct v4l2_loopback_device *dev)\n{\n\tMARK();\n\tdprintk(\"freeing image@%p for dev:%p\\n\", dev ? dev->image : NULL, dev);\n\tif (dev->image) {\n\t\tvfree(dev->image);\n\t\tdev->image = NULL;\n\t}\n\tif (dev->timeout_image) {\n\t\tvfree(dev->timeout_image);\n\t\tdev->timeout_image = NULL;\n\t}\n\tdev->imagesize = 0;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":718,"func":"TEST_F ( ProtocolHandlerRegistryTest , TestIsSameOrigin ) {\n ProtocolHandler ph1 = CreateProtocolHandler ( \"mailto\" , GURL ( \"http:\/\/test.com\/%s\" ) , \"test1\" ) ;\n ProtocolHandler ph2 = CreateProtocolHandler ( \"mailto\" , GURL ( \"http:\/\/test.com\/updated-url\/%s\" ) , \"test2\" ) ;\n ProtocolHandler ph3 = CreateProtocolHandler ( \"mailto\" , GURL ( \"http:\/\/other.com\/%s\" ) , \"test\" ) ;\n ASSERT_EQ ( ph1 . url ( ) . GetOrigin ( ) == ph2 . url ( ) . GetOrigin ( ) , ph1 . IsSameOrigin ( ph2 ) ) ;\n ASSERT_EQ ( ph1 . url ( ) . GetOrigin ( ) == ph2 . url ( ) . GetOrigin ( ) , ph2 . IsSameOrigin ( ph1 ) ) ;\n ASSERT_EQ ( ph2 . url ( ) . GetOrigin ( ) == ph3 . url ( ) . GetOrigin ( ) , ph2 . IsSameOrigin ( ph3 ) ) ;\n ASSERT_EQ ( ph3 . url ( ) . GetOrigin ( ) == ph2 . url ( ) . GetOrigin ( ) , ph3 . IsSameOrigin ( ph2 ) ) ;\n }","target":1,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":356912,"func":"int filp_close(struct file *filp, fl_owner_t id)\n{\n\tint retval = 0;\n\n\tif (!file_count(filp)) {\n\t\tprintk(KERN_ERR \"VFS: Close: file count is 0\\n\");\n\t\treturn 0;\n\t}\n\n\tif (filp->f_op && filp->f_op->flush)\n\t\tretval = filp->f_op->flush(filp, id);\n\n\tdnotify_flush(filp, id);\n\tlocks_remove_posix(filp, id);\n\tfput(filp);\n\treturn retval;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":61873,"func":"static int maybe_start_packet(vorb *f)\n{\n   if (f->next_seg == -1) {\n      int x = get8(f);\n      if (f->eof) return FALSE; \/\/ EOF at page boundary is not an error!\n      if (0x4f != x      ) return error(f, VORBIS_missing_capture_pattern);\n      if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);\n      if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);\n      if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern);\n      if (!start_page_no_capturepattern(f)) return FALSE;\n      if (f->page_flag & PAGEFLAG_continued_packet) {\n         \/\/ set up enough state that we can read this packet if we want,\n         \/\/ e.g. during recovery\n         f->last_seg = FALSE;\n         f->bytes_in_seg = 0;\n         return error(f, VORBIS_continued_packet_flag_invalid);\n      }\n   }\n   return start_packet(f);\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":277731,"func":"NPError WebPluginDelegatePepper::Device3DDestroyBuffer(\n    NPDeviceContext3D* context,\n    int32 id) {\n#if defined(ENABLE_GPU)\n  command_buffer_->DestroyTransferBuffer(id);\n#endif  \/\/ ENABLE_GPU\n  return NPERR_NO_ERROR;\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":447929,"func":"_XimSetInnerICAttributes(\n    Xic\t\t\t ic,\n    XPointer\t\t top,\n    XIMArg\t\t*arg,\n    unsigned long\t mode)\n{\n    XIMResourceList\t res;\n    int\t\t\t check;\n\n    if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,\n\t\t\tic->private.proto.ic_num_inner_resources, arg->name)))\n\treturn False;\n\n    check = _XimCheckICMode(res, mode);\n    if(check == XIM_CHECK_INVALID)\n\treturn True;\n    else if(check == XIM_CHECK_ERROR)\n\treturn False;\n\n    return _XimEncodeLocalICAttr(ic, res, top, arg, mode);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":285568,"func":"void TestTransactionConsumer::DidFinish(int result) {\n  state_ = DONE;\n  error_ = result;\n  if (--quit_counter_ == 0)\n    base::MessageLoop::current()->QuitWhenIdle();\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":133513,"func":"DEFINE_IDTENTRY_RAW(exc_xen_unknown_trap)\n{\n\t\/* This should never happen and there is no way to handle it. *\/\n\tinstrumentation_begin();\n\tpr_err(\"Unknown trap in Xen PV mode.\");\n\tBUG();\n\tinstrumentation_end();\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":438084,"func":"long long VideoTrack::GetHeight() const { return m_height; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":248078,"func":"xsltGetXIncludeDefault(void) {\n    return(xsltDoXIncludeDefault);\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":20436,"func":"static void qio_channel_websock_unset_watch ( QIOChannelWebsock * ioc ) {\n if ( ioc -> io_tag ) {\n g_source_remove ( ioc -> io_tag ) ;\n ioc -> io_tag = 0 ;\n }\n }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":413889,"func":"  void Inspect::operator()(Error_Ptr error)\n  {\n    append_indentation();\n    append_token(\"@error\", error);\n    append_mandatory_space();\n    error->message()->perform(this);\n    append_delimiter();\n  }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":58268,"func":"static void *yam_seq_next(struct seq_file *seq, void *v, loff_t *pos)\n{\n\t++*pos;\n\treturn (*pos < NR_PORTS) ? yam_devs[*pos] : NULL;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":34442,"func":"static inline void user_fpu_begin(void)\n{\n\tpreempt_disable();\n\tif (!user_has_fpu())\n\t\t__thread_fpu_begin(current);\n\tpreempt_enable();\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":105843,"func":"wiki_show_edit_page(HttpResponse *res, char *wikitext, char *page)\n{\n  wiki_show_header(res, page, FALSE);\n\n  if (wikitext == NULL) wikitext = \"\";\n  http_response_printf(res, EDITFORM, page, wikitext);\n\t\t       \n  wiki_show_footer(res);\n\n  http_response_send(res);\n  exit(0);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":483586,"func":"int dev_vprintk_emit(int level, const struct device *dev,\n\t\t     const char *fmt, va_list args)\n{\n\tchar hdr[128];\n\tsize_t hdrlen;\n\n\thdrlen = create_syslog_header(dev, hdr, sizeof(hdr));\n\n\treturn vprintk_emit(0, level, hdrlen ? hdr : NULL, hdrlen, fmt, args);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":244823,"func":"void HTMLTextAreaElement::updateFocusAppearance(bool restorePreviousSelection)\n{\n    if (!restorePreviousSelection || !hasCachedSelection()) {\n        setSelectionRange(0, 0);\n    } else\n        restoreCachedSelection();\n\n    if (document().frame())\n        document().frame()->selection().revealSelection();\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":405839,"func":"mf_bitmap_to_of11(const struct mf_bitmap *fields)\n{\n    const struct ofp11_wc_map *p;\n    uint32_t wc11 = 0;\n\n    for (p = ofp11_wc_map; p < &ofp11_wc_map[ARRAY_SIZE(ofp11_wc_map)]; p++) {\n        if (bitmap_is_set(fields->bm, p->mf)) {\n            wc11 |= p->wc11;\n        }\n    }\n    return htonl(wc11);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":490267,"func":"destroyODBCStmt(ODBCStmt *stmt)\n{\n\tODBCStmt **stmtp;\n\n\tassert(isValidStmt(stmt));\n\n\t\/* first set this object to invalid *\/\n\tstmt->Type = 0;\n\n\t\/* remove this stmt from the dbc *\/\n\tassert(stmt->Dbc);\n\n\t\/* search for stmt in linked list *\/\n\tstmtp = &stmt->Dbc->FirstStmt;\n\n\twhile (*stmtp && *stmtp != stmt)\n\t\tstmtp = &(*stmtp)->next;\n\t\/* stmtp points to location in list where stmt is found, or\n\t * *stmtp is NULL in case it wasn't there (presumably not added\n\t * yet) *\/\n\n\tif (*stmtp) {\n\t\t\/* now remove it from the linked list *\/\n\t\t*stmtp = stmt->next;\n\t}\n\n\t\/* cleanup own managed data *\/\n\tdeleteODBCErrorList(&stmt->Error);\n\n\tdestroyODBCDesc(stmt->ImplParamDescr);\n\tdestroyODBCDesc(stmt->ImplRowDescr);\n\tdestroyODBCDesc(stmt->AutoApplParamDescr);\n\tdestroyODBCDesc(stmt->AutoApplRowDescr);\n\n\tif (stmt->hdl)\n\t\tmapi_close_handle(stmt->hdl);\n\n\tfree(stmt);\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":183293,"func":"ofproto_port_set_queues(struct ofproto *ofproto, ofp_port_t ofp_port,\n                        const struct ofproto_port_queue *queues,\n                        size_t n_queues)\n{\n    struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);\n\n    if (!ofport) {\n        VLOG_WARN(\"%s: cannot set queues on nonexistent port %\"PRIu32,\n                  ofproto->name, ofp_port);\n        return ENODEV;\n    }\n\n    return (ofproto->ofproto_class->set_queues\n            ? ofproto->ofproto_class->set_queues(ofport, queues, n_queues)\n            : EOPNOTSUPP);\n}\n","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":360274,"func":"nautilus_file_invalidate_attributes (NautilusFile *file,\n\t\t\t\t     NautilusFileAttributes file_attributes)\n{\n\t\/* Cancel possible in-progress loads of any of these attributes *\/\n\tnautilus_directory_cancel_loading_file_attributes (file->details->directory,\n\t\t\t\t\t\t\t   file,\n\t\t\t\t\t\t\t   file_attributes);\n\t\n\t\/* Actually invalidate the values *\/\n\tnautilus_file_invalidate_attributes_internal (file, file_attributes);\n\n\tnautilus_directory_add_file_to_work_queue (file->details->directory, file);\n\t\n\t\/* Kick off I\/O if necessary *\/\n\tnautilus_directory_async_state_changed (file->details->directory);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":464239,"func":"SProcXChangeFeedbackControl(ClientPtr client)\n{\n    REQUEST(xChangeFeedbackControlReq);\n    swaps(&stuff->length);\n    REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);\n    swapl(&stuff->mask);\n    return (ProcXChangeFeedbackControl(client));\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":340119,"func":"static void discard_vq_data(VirtQueue *vq, VirtIODevice *vdev)\n\n{\n\n    VirtQueueElement elem;\n\n\n\n    if (!virtio_queue_ready(vq)) {\n\n        return;\n\n    }\n\n    while (virtqueue_pop(vq, &elem)) {\n\n        virtqueue_push(vq, &elem, 0);\n\n    }\n\n    virtio_notify(vdev, vq);\n\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":414105,"func":"work_city_populate (EContact *card,\n                    gchar **values)\n{\n\tEContactAddress *contact_addr = getormakeEContactAddress (card, E_CONTACT_ADDRESS_WORK);\n\tcontact_addr->locality = g_strdup (values[0]);\n\te_contact_set (card, E_CONTACT_ADDRESS_WORK, contact_addr);\n\te_contact_address_free (contact_addr);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":405016,"func":"static void l2cap_send_srej_tail(struct l2cap_chan *chan)\n{\n\tstruct l2cap_ctrl control;\n\n\tBT_DBG(\"chan %p\", chan);\n\n\tif (chan->srej_list.tail == L2CAP_SEQ_LIST_CLEAR)\n\t\treturn;\n\n\tmemset(&control, 0, sizeof(control));\n\tcontrol.sframe = 1;\n\tcontrol.super = L2CAP_SUPER_SREJ;\n\tcontrol.reqseq = chan->srej_list.tail;\n\tl2cap_send_sframe(chan, &control);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":417338,"func":"    void CiffComponent::add(AutoPtr component)\n    {\n        doAdd(component);\n    }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":331340,"func":"void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)\n\n{\n\n    QIOChannel *ioc;\n\n    const char *argv[] = { \"\/bin\/sh\", \"-c\", command, NULL };\n\n\n\n    trace_migration_exec_outgoing(command);\n\n    ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,\n\n                                                    O_WRONLY,\n\n                                                    errp));\n\n    if (!ioc) {\n\n        return;\n\n    }\n\n\n\n    migration_set_outgoing_channel(s, ioc);\n\n    object_unref(OBJECT(ioc));\n\n}\n","target":1,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":217666,"func":"void PluginServiceImpl::AddExtraPluginDir(const FilePath& path) {\n  plugin_list_->AddExtraPluginDir(path);\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":428435,"func":"g_file_mount_mountable (GFile               *file,\n                        GMountMountFlags     flags,\n                        GMountOperation     *mount_operation,\n                        GCancellable        *cancellable,\n                        GAsyncReadyCallback  callback,\n                        gpointer             user_data)\n{\n  GFileIface *iface;\n\n  g_return_if_fail (G_IS_FILE (file));\n\n  iface = G_FILE_GET_IFACE (file);\n\n  if (iface->mount_mountable == NULL)\n    {\n      g_task_report_new_error (file, callback, user_data,\n                               g_file_mount_mountable,\n                               G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,\n                               _(\"Operation not supported\"));\n      return;\n    }\n\n  (* iface->mount_mountable) (file,\n                              flags,\n                              mount_operation,\n                              cancellable,\n                              callback,\n                              user_data);\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":208886,"func":"void PepperPlatformAudioInput::StartCaptureOnIOThread() {\n  DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());\n\n  if (ipc_)\n    ipc_->RecordStream();\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":136699,"func":"GF_Err hinf_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\/\/\tGF_HintInfoBox *ptr = (GF_HintInfoBox *)s;\n\tif (!s) return GF_BAD_PARAM;\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":440490,"func":"static int vxlan_nl2flag(struct vxlan_config *conf, struct nlattr *tb[],\n\t\t\t  int attrtype, unsigned long mask, bool changelink,\n\t\t\t  bool changelink_supported,\n\t\t\t  struct netlink_ext_ack *extack)\n{\n\tunsigned long flags;\n\n\tif (!tb[attrtype])\n\t\treturn 0;\n\n\tif (changelink && !changelink_supported) {\n\t\tvxlan_flag_attr_error(attrtype, extack);\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\tif (vxlan_policy[attrtype].type == NLA_FLAG)\n\t\tflags = conf->flags | mask;\n\telse if (nla_get_u8(tb[attrtype]))\n\t\tflags = conf->flags | mask;\n\telse\n\t\tflags = conf->flags & ~mask;\n\n\tconf->flags = flags;\n\n\treturn 0;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":73887,"func":"void __fastcall TOwnConsole::WindowStateTimer(TObject * \/*Sender*\/)\r\n{\r\n  DebugAssert(FConsoleWindow != NULL);\r\n  WINDOWPLACEMENT Placement;\r\n  memset(&Placement, 0, sizeof(Placement));\r\n  Placement.length = sizeof(Placement);\r\n  if (GetWindowPlacement(FConsoleWindow, &Placement))\r\n  {\r\n    bool Minimized = (Placement.showCmd == SW_SHOWMINIMIZED);\r\n    if (FMinimized != Minimized)\r\n    {\r\n      FMinimized = Minimized;\r\n\r\n      if (FMinimized && WinConfiguration->MinimizeToTray)\r\n      {\r\n        FTrayIcon->Visible = true;\r\n        ShowWindow(FConsoleWindow, SW_HIDE);\r\n      }\r\n      else\r\n      {\r\n        FTrayIcon->Visible = false;\r\n        ShowWindow(FConsoleWindow, SW_SHOW);\r\n      }\r\n    }\r\n  }\r\n  else\r\n  {\r\n    DebugFail();\r\n  }\r\n}\r","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":88947,"func":"static gboolean id_match_value(gpointer key, gpointer value, gpointer user_data)\n{\n  if (value == *(gpointer *)user_data) {\n\t*(int *)user_data = (uintptr_t)key;\n\treturn true;\n  }\n  return false;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":375076,"func":"decompile_conbin(HeapTuple contup, TupleDesc tupdesc)\n{\n\tForm_pg_constraint con;\n\tbool\t\tisnull;\n\tDatum\t\tattr;\n\tDatum\t\texpr;\n\n\tcon = (Form_pg_constraint) GETSTRUCT(contup);\n\tattr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull);\n\tif (isnull)\n\t\telog(ERROR, \"null conbin for constraint %u\", HeapTupleGetOid(contup));\n\n\texpr = DirectFunctionCall2(pg_get_expr, attr,\n\t\t\t\t\t\t\t   ObjectIdGetDatum(con->conrelid));\n\treturn TextDatumGetCString(expr);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":324295,"func":"static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)\n\n{\n\n    h264_loop_filter_chroma_intra_c(pix, 1, stride, alpha, beta);\n\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":13531,"func":"void MediaStreamDispatcherHost::DoGenerateStream(\n    int32_t page_request_id,\n    const StreamControls& controls,\n    bool user_gesture,\n    GenerateStreamCallback callback,\n    MediaDeviceSaltAndOrigin salt_and_origin) {\n  DCHECK_CURRENTLY_ON(BrowserThread::IO);\n  if (!MediaStreamManager::IsOriginAllowed(render_process_id_,\n                                           salt_and_origin.origin)) {\n    std::move(callback).Run(MEDIA_DEVICE_INVALID_SECURITY_ORIGIN, std::string(),\n                            MediaStreamDevices(), MediaStreamDevices());\n    return;\n   }\n \n   media_stream_manager_->GenerateStream(\n      render_process_id_, render_frame_id_, page_request_id, controls,\n      std::move(salt_and_origin), user_gesture, std::move(callback),\n       base::BindRepeating(&MediaStreamDispatcherHost::OnDeviceStopped,\n                           weak_factory_.GetWeakPtr()),\n       base::BindRepeating(&MediaStreamDispatcherHost::OnDeviceChanged,\n                          weak_factory_.GetWeakPtr()));\n}\n","target":1,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":280153,"func":"void ProfileImplIOData::Handle::LazyInitialize() const {\n  if (!initialized_) {\n    io_data_->InitializeOnUIThread(profile_);\n    PrefService* pref_service = profile_->GetPrefs();\n    io_data_->http_server_properties_manager_.reset(\n        new chrome_browser_net::HttpServerPropertiesManager(pref_service));\n    ChromeNetworkDelegate::InitializeReferrersEnabled(\n        io_data_->enable_referrers(), pref_service);\n    io_data_->clear_local_state_on_exit()->Init(\n        prefs::kClearSiteDataOnExit, pref_service, NULL);\n    io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO);\n#if defined(ENABLE_SAFE_BROWSING)\n    io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled,\n        pref_service, NULL);\n    io_data_->safe_browsing_enabled()->MoveToThread(BrowserThread::IO);\n#endif\n    initialized_ = true;\n  }\n}\n","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":388141,"func":"gdm_session_start_reauthentication (GdmSession *session,\n                                    GPid        pid_of_caller,\n                                    uid_t       uid_of_caller)\n{\n        GdmSessionConversation *conversation = session->priv->session_conversation;\n\n        g_return_if_fail (conversation != NULL);\n\n        conversation->reauth_pid_of_caller = pid_of_caller;\n\n        gdm_dbus_worker_call_start_reauthentication (conversation->worker_proxy,\n                                                     (int) pid_of_caller,\n                                                     (int) uid_of_caller,\n                                                     conversation->worker_cancellable,\n                                                     (GAsyncReadyCallback) on_reauthentication_started_cb,\n                                                     conversation);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":7543,"func":"size_t jsuGetFreeStack() {\n#ifdef ARM\n  void *frame = __builtin_frame_address(0);\n  size_t stackPos = (size_t)((char*)frame);\n  size_t stackEnd = (size_t)((char*)&LINKER_END_VAR);\n  if (stackPos < stackEnd) return 0; \/\/ should never happen, but just in case of overflow!\n  return  stackPos - stackEnd;\n#elif defined(LINUX)\n  \/\/ On linux, we set STACK_BASE from `main`.\n  char ptr; \/\/ this is on the stack\n  extern void *STACK_BASE;\n  uint32_t count =  (uint32_t)((size_t)STACK_BASE - (size_t)&ptr);\n  return 1000000 - count; \/\/ give it 1 megabyte of stack\n#else\n  \/\/ stack depth seems pretty platform-specific :( Default to a value that disables it\n  return 1000000; \/\/ no stack depth check on this platform\n#endif\n}","target":1,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":391308,"func":"PHP_FUNCTION(xml_error_string)\n{\n\tzend_long code;\n\tchar *str;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"l\", &code) == FAILURE) {\n\t\treturn;\n\t}\n\n\tstr = (char *)XML_ErrorString((int)code);\n\tif (str) {\n\t\tRETVAL_STRING(str);\n\t}\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":9139,"func":" void VRDisplay::OnPresentChange() {\n   if (is_presenting_ && !is_valid_device_for_presenting_) {\n     DVLOG(1) << __FUNCTION__ << \": device not valid, not sending event\";\n     return;\n  }\n  navigator_vr_->EnqueueVREvent(VRDisplayEvent::Create(\n      EventTypeNames::vrdisplaypresentchange, true, false, this, \"\"));\n}\n","target":1,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":461424,"func":"static int qid_inode_prefix_hash_bits(V9fsPDU *pdu, dev_t dev)\n{\n    QpdEntry lookup = {\n        .dev = dev\n    }, *val;\n    uint32_t hash = dev;\n    VariLenAffix affix;\n\n    val = qht_lookup(&pdu->s->qpd_table, &lookup, hash);\n    if (!val) {\n        val = g_malloc0(sizeof(QpdEntry));\n        *val = lookup;\n        affix = affixForIndex(pdu->s->qp_affix_next);\n        val->prefix_bits = affix.bits;\n        qht_insert(&pdu->s->qpd_table, val, hash, NULL);\n        pdu->s->qp_ndevices++;\n    }\n    return val->prefix_bits;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":57762,"func":"void imap_logout_all (void)\n{\n  CONNECTION* conn;\n  CONNECTION* tmp;\n\n  conn = mutt_socket_head ();\n\n  while (conn)\n  {\n    tmp = conn->next;\n\n    if (conn->account.type == MUTT_ACCT_TYPE_IMAP && conn->fd >= 0)\n    {\n      mutt_message (_(\"Closing connection to %s...\"), conn->account.host);\n      imap_logout ((IMAP_DATA**) (void*) &conn->data);\n      mutt_clear_error ();\n      mutt_socket_free (conn);\n    }\n\n    conn = tmp;\n  }\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":97211,"func":"static void mntns_put(struct ns_common *ns)\n{\n\tput_mnt_ns(to_mnt_ns(ns));\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":228130,"func":"void RuleFeatureSet::FeatureMetadata::add(const FeatureMetadata& other)\n{\n    usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules;\n    usesWindowInactiveSelector = usesWindowInactiveSelector || other.usesWindowInactiveSelector;\n    maxDirectAdjacentSelectors = std::max(maxDirectAdjacentSelectors, other.maxDirectAdjacentSelectors);\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":354586,"func":"void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)\n{\n\tstruct siginfo info;\n\n\ttsk->thread.trap_no = 1;\n\ttsk->thread.error_code = error_code;\n\n\tmemset(&info, 0, sizeof(info));\n\tinfo.si_signo = SIGTRAP;\n\tinfo.si_code = TRAP_BRKPT;\n\n\t\/* User-mode eip? *\/\n\tinfo.si_addr = user_mode_vm(regs) ? (void __user *) regs->eip : NULL;\n\n\t\/* Send us the fakey SIGTRAP *\/\n\tforce_sig_info(SIGTRAP, &info, tsk);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":477207,"func":"static int virtbt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)\n{\n\tstruct virtio_bluetooth *vbt = hci_get_drvdata(hdev);\n\tstruct scatterlist sg[1];\n\tint err;\n\n\tmemcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);\n\n\tsg_init_one(sg, skb->data, skb->len);\n\terr = virtqueue_add_outbuf(vbt->vqs[VIRTBT_VQ_TX], sg, 1, skb,\n\t\t\t\t   GFP_KERNEL);\n\tif (err) {\n\t\tkfree_skb(skb);\n\t\treturn err;\n\t}\n\n\tvirtqueue_kick(vbt->vqs[VIRTBT_VQ_TX]);\n\treturn 0;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":522507,"func":"void ha_checkpoint_state(bool disable)\n{\n  plugin_foreach(NULL, checkpoint_state_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, &disable);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":460427,"func":"void hidinput_disconnect(struct hid_device *hid)\n{\n\tstruct hid_input *hidinput, *next;\n\n\thidinput_cleanup_battery(hid);\n\n\tlist_for_each_entry_safe(hidinput, next, &hid->inputs, list) {\n\t\tlist_del(&hidinput->list);\n\t\tif (hidinput->registered)\n\t\t\tinput_unregister_device(hidinput->input);\n\t\telse\n\t\t\tinput_free_device(hidinput->input);\n\t\tkfree(hidinput->name);\n\t\tkfree(hidinput);\n\t}\n\n\t\/* led_work is spawned by input_dev callbacks, but doesn't access the\n\t * parent input_dev at all. Once all input devices are removed, we\n\t * know that led_work will never get restarted, so we can cancel it\n\t * synchronously and are safe. *\/\n\tcancel_work_sync(&hid->led_work);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":301216,"func":"GF_Err hnti_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_HintTrackInfoBox *ptr = (GF_HintTrackInfoBox *)s;\n\tif (!ptr || !a) return GF_BAD_PARAM;\n\n\tswitch (a->type) {\n\t\/\/this is the value for GF_RTPBox - same as HintSampleEntry for RTP !!!\n\tcase GF_ISOM_BOX_TYPE_RTP:\n\tcase GF_ISOM_BOX_TYPE_SDP:\n\t\tBOX_FIELD_ASSIGN(SDP, GF_Box)\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":336828,"func":"static int dnxhd_decode_dct_block_8(const DNXHDContext *ctx,\n\n                                    RowContext *row, int n)\n\n{\n\n    return dnxhd_decode_dct_block(ctx, row, n, 4, 32, 6);\n\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":434844,"func":"pdf_filter_gs_op(fz_context *ctx, pdf_processor *proc, int b)\n{\n\tpdf_filter_processor *p = (pdf_filter_processor*)proc;\n\tfilter_flush(ctx, p, 0);\n\tif (p->chain->op_gs_op)\n\t\tp->chain->op_gs_op(ctx, p->chain, b);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":504187,"func":"static int tipc_link_build_nack_msg(struct tipc_link *l,\n\t\t\t\t    struct sk_buff_head *xmitq)\n{\n\tu32 def_cnt = ++l->stats.deferred_recv;\n\tstruct sk_buff_head *dfq = &l->deferdq;\n\tu32 defq_len = skb_queue_len(dfq);\n\tint match1, match2;\n\n\tif (link_is_bc_rcvlink(l)) {\n\t\tmatch1 = def_cnt & 0xf;\n\t\tmatch2 = tipc_own_addr(l->net) & 0xf;\n\t\tif (match1 == match2)\n\t\t\treturn TIPC_LINK_SND_STATE;\n\t\treturn 0;\n\t}\n\n\tif (defq_len >= 3 && !((defq_len - 3) % 16)) {\n\t\tu16 rcvgap = buf_seqno(skb_peek(dfq)) - l->rcv_nxt;\n\n\t\ttipc_link_build_proto_msg(l, STATE_MSG, 0, 0,\n\t\t\t\t\t  rcvgap, 0, 0, xmitq);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":378794,"func":"answer_from_qmem(int dns_fd, struct query *q, unsigned char *qmem_cmc,\n\t\t unsigned short *qmem_type, int qmem_len,\n\t\t unsigned char *cmc_to_check)\n\/* Checks query memory and sends an (illegal) answer if this is a duplicate.\n   Returns: 1 = answer sent, drop this query, 0 = no answer sent, this is\n   not a duplicate. *\/\n{\n\tint i;\n\n\tfor (i = 0; i < qmem_len ; i++) {\n\n\t\tif (qmem_type[i] == T_UNSET)\n\t\t\tcontinue;\n\t\tif (qmem_type[i] != q->type)\n\t\t\tcontinue;\n\t\tif (memcmp(qmem_cmc + i * 4, cmc_to_check, 4))\n\t\t\tcontinue;\n\n\t\t\/* okay, match *\/\n\t\tif (debug >= 1)\n\t\t\tfprintf(stderr, \"OUT  from qmem for %s == duplicate, sending illegal reply\\n\", q->name);\n\n\t\twrite_dns(dns_fd, q, \"x\", 1, 'T');\n\n\t\tq->id = 0;\t\/* this query was used *\/\n\t\treturn 1;\n\t}\n\n\t\/* here only when no match found *\/\n\treturn 0;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":123962,"func":"static void trigger_start_discovery(struct btd_adapter *adapter, guint delay)\n{\n\n\tDBG(\"\");\n\n\tcancel_passive_scanning(adapter);\n\n\tif (adapter->discovery_idle_timeout > 0) {\n\t\ttimeout_remove(adapter->discovery_idle_timeout);\n\t\tadapter->discovery_idle_timeout = 0;\n\t}\n\n\t\/*\n\t * If the controller got powered down in between, then ensure\n\t * that we do not keep trying to restart discovery.\n\t *\n\t * This is safe-guard and should actually never trigger.\n\t *\/\n\tif (!btd_adapter_get_powered(adapter))\n\t\treturn;\n\n\tadapter->discovery_idle_timeout = timeout_add_seconds(delay,\n\t\t\t\t\tstart_discovery_timeout, adapter, NULL);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":379217,"func":"static int ZEND_FASTCALL  ZEND_IS_NOT_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\n\tzval *result = &EX_T(opline->result.u.var).tmp_var;\n\n\tcompare_function(result,\n\t\t&opline->op1.u.constant,\n\t\t&opline->op2.u.constant TSRMLS_CC);\n\tZVAL_BOOL(result, (Z_LVAL_P(result) != 0));\n\n\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":271294,"func":"qboolean FS_CreatePath (char *OSPath) {\n\tchar    *ofs;\n\tchar\tpath[MAX_OSPATH];\n\n\t\/\/ make absolutely sure that it can't back up the path\n\t\/\/ FIXME: is c: allowed???\n\tif ( strstr( OSPath, \"..\" ) || strstr( OSPath, \"::\" ) ) {\n\t\tCom_Printf( \"WARNING: refusing to create relative path \\\"%s\\\"\\n\", OSPath );\n\t\treturn qtrue;\n\t}\n\n\tQ_strncpyz( path, OSPath, sizeof( path ) );\n\tFS_ReplaceSeparators( path );\n\n\t\/\/ Skip creation of the root directory as it will always be there\n\tofs = strchr( path, PATH_SEP );\n\tif ( ofs != NULL ) {\n\t\tofs++;\n\t}\n\n\tfor (; ofs != NULL && *ofs ; ofs++) {\n\t\tif (*ofs == PATH_SEP) {\n\t\t\t\/\/ create the directory\n\t\t\t*ofs = 0;\n\t\t\tif (!Sys_Mkdir (path)) {\n\t\t\t\tCom_Error( ERR_FATAL, \"FS_CreatePath: failed to create path \\\"%s\\\"\",\n\t\t\t\t\tpath );\n\t\t\t}\n\t\t\t*ofs = PATH_SEP;\n\t\t}\n\t}\n\treturn qfalse;\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":47730,"func":"GF_Err gf_isom_freeze_order(GF_ISOFile *file)\n{\n\tu32 i=0;\n\tGF_Box *box;\n\tif (!file) return GF_BAD_PARAM;\n\twhile ((box=gf_list_enum(file->TopBoxes, &i))) {\n\t\tgf_isom_box_freeze_order(box);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":339514,"func":"static int udp_close(URLContext *h)\n\n{\n\n    UDPContext *s = h->priv_data;\n\n    int ret;\n\n\n\n    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))\n\n        udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);\n\n    closesocket(s->udp_fd);\n\n    av_fifo_free(s->fifo);\n\n#if HAVE_PTHREADS\n\n    if (s->thread_started) {\n\n        pthread_cancel(s->circular_buffer_thread);\n\n        ret = pthread_join(s->circular_buffer_thread, NULL);\n\n        if (ret != 0)\n\n            av_log(h, AV_LOG_ERROR, \"pthread_join(): %s\\n\", strerror(ret));\n\n    }\n\n\n\n    pthread_mutex_destroy(&s->mutex);\n\n    pthread_cond_destroy(&s->cond);\n\n#endif\n\n    return 0;\n\n}\n","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":354875,"func":"static int dccp_close_state(struct sock *sk)\n{\n\tconst int next = dccp_new_state[sk->sk_state];\n\tconst int ns = next & DCCP_STATE_MASK;\n\n\tif (ns != sk->sk_state)\n\t\tdccp_set_state(sk, ns);\n\n\treturn next & DCCP_ACTION_FIN;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":394849,"func":"static int php_zip_ops_flush(php_stream *stream TSRMLS_DC)\n{\n\tif (!stream) {\n\t\treturn 0;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":290839,"func":"bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)\n{\n\treturn false;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":520464,"func":"  my_decimal *val_decimal(my_decimal *to)\n  {\n    return has_value() ? Date(this).to_decimal(to) : NULL;\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":253803,"func":"PHP_FUNCTION(pg_result_seek)\n{\n\tzval *result;\n\tlong row;\n\tpgsql_result_handle *pg_result;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rl\", &result, &row) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, &result, -1, \"PostgreSQL result\", le_result);\n\n\tif (row < 0 || row >= PQntuples(pg_result->result)) {\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* seek to offset *\/\n\tpg_result->row = row;\n\tRETURN_TRUE;\n}\n","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":320127,"func":"static av_cold int yop_decode_init(AVCodecContext *avctx)\n{\n    YopDecContext *s = avctx->priv_data;\n    s->avctx = avctx;\n    if (avctx->width & 1 || avctx->height & 1 ||\n        av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {\n        av_log(avctx, AV_LOG_ERROR, \"YOP has invalid dimensions\\n\");\n        return -1;\n    avctx->pix_fmt = PIX_FMT_PAL8;\n    avcodec_get_frame_defaults(&s->frame);\n    s->num_pal_colors = avctx->extradata[0];\n    s->first_color[0] = avctx->extradata[1];\n    s->first_color[1] = avctx->extradata[2];\n    if (s->num_pal_colors + s->first_color[0] > 256 ||\n        s->num_pal_colors + s->first_color[1] > 256) {\n        av_log(avctx, AV_LOG_ERROR,\n               \"YOP: palette parameters invalid, header probably corrupt\\n\");\n    return 0;","target":1,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":363029,"func":"int\tsel_fontn(DviContext *dvi, int opcode)\n{\n\tInt32\targ;\n\tDviFontRef *ref;\n\t\n\targ = dugetn(dvi, opcode - DVI_FNT1 + 1);\n\tif(dvi->depth)\n\t\tref = font_find_flat(dvi, arg);\n\telse\n\t\tref = dvi->findref(dvi, arg);\n\tif(ref == NULL) {\n\t\tdvierr(dvi, _(\"font %d is not defined\\n\"), arg);\n\t\treturn -1;\n\t}\n\tSHOWCMD((dvi, \"fnt\", opcode - DVI_FNT1 + 1,\n\t\t\"current font is %s (id %d)\\n\", \n\t\tref->ref->fontname, arg));\n\tdvi->currfont = ref;\n\treturn 0;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":124631,"func":"static void tg3_hwmon_close(struct tg3 *tp)\n{\n\tif (tp->hwmon_dev) {\n\t\thwmon_device_unregister(tp->hwmon_dev);\n\t\ttp->hwmon_dev = NULL;\n\t\tsysfs_remove_group(&tp->pdev->dev.kobj, &tg3_group);\n\t}\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":218121,"func":"std::unique_ptr<net::test_server::HttpResponse> DrpBlockOnceHandler(\n    const std::string& server_name,\n    EventLog* event_log,\n    const net::test_server::HttpRequest& request) {\n  if (request.relative_url == \"\/favicon.ico\")\n    return nullptr;\n\n  event_log->Add(server_name + \" responded 502 for \" + request.relative_url);\n  auto response = std::make_unique<net::test_server::BasicHttpResponse>();\n  response->set_content_type(\"text\/plain\");\n  response->set_code(net::HTTP_BAD_GATEWAY);\n  response->AddCustomHeader(chrome_proxy_header(), \"block-once\");\n  return response;\n}\n","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":310221,"func":"bool OmniboxViewViews::HandleAccessibleAction(\n    const ui::AXActionData& action_data) {\n  if (read_only())\n    return Textfield::HandleAccessibleAction(action_data);\n\n  if (action_data.action == ui::AX_ACTION_SET_VALUE) {\n    SetUserText(action_data.value, true);\n    return true;\n  } else if (action_data.action == ui::AX_ACTION_REPLACE_SELECTED_TEXT) {\n    model()->SetInputInProgress(true);\n    if (saved_selection_for_focus_change_.IsValid()) {\n      SelectRange(saved_selection_for_focus_change_);\n      saved_selection_for_focus_change_ = gfx::Range::InvalidRange();\n    }\n    InsertOrReplaceText(action_data.value);\n    TextChanged();\n    return true;\n  }\n\n  return Textfield::HandleAccessibleAction(action_data);\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":444448,"func":"TEST_P(Http2UpstreamIntegrationTest, BidirectionalStreaming) { bidirectionalStreaming(1024); }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":148665,"func":"static void sync_child_event(struct perf_event *child_event,\n\t\t\t       struct task_struct *child)\n{\n\tstruct perf_event *parent_event = child_event->parent;\n\tu64 child_val;\n\n\tif (child_event->attr.inherit_stat)\n\t\tperf_event_read_event(child_event, child);\n\n\tchild_val = perf_event_count(child_event);\n\n\t\/*\n\t * Add back the child's count to the parent's count:\n\t *\/\n\tatomic64_add(child_val, &parent_event->child_count);\n\tatomic64_add(child_event->total_time_enabled,\n\t\t     &parent_event->child_total_time_enabled);\n\tatomic64_add(child_event->total_time_running,\n\t\t     &parent_event->child_total_time_running);\n\n\t\/*\n\t * Remove this event from the parent's list\n\t *\/\n\tWARN_ON_ONCE(parent_event->ctx->parent_ctx);\n\tmutex_lock(&parent_event->child_mutex);\n\tlist_del_init(&child_event->child_list);\n\tmutex_unlock(&parent_event->child_mutex);\n\n\t\/*\n\t * Release the parent event, if this was the last\n\t * reference to it.\n\t *\/\n\tput_event(parent_event);\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":276207,"func":"  static void  Ins_IF( INS_ARG )\n  {\n    Int   nIfs;\n    Bool  Out;\n\n    if ( args[0] != 0 )\n      return;\n\n    nIfs = 1;\n    Out = 0;\n\n    do\n    {\n      if ( SKIP_Code() == FAILURE )\n        return;\n\n      switch ( CUR.opcode )\n      {\n      case 0x58:      \/* IF *\/\n        nIfs++;\n        break;\n\n      case 0x1b:      \/* ELSE *\/\n        Out = (nIfs == 1);\n        break;\n\n      case 0x59:      \/* EIF *\/\n        nIfs--;\n        Out = (nIfs == 0);\n        break;\n      }\n    } while ( Out == 0 );\n  }\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":374358,"func":"hv_store_string(HV *hv, const char *key, SV *val)\n{\n\tint32\t\thlen;\n\tchar\t   *hkey;\n\tSV\t\t  **ret;\n\n\thkey = (char *)\n\t\tpg_do_encoding_conversion((unsigned char *) key, strlen(key),\n\t\t\t\t\t\t\t\t  GetDatabaseEncoding(), PG_UTF8);\n\n\t\/*\n\t * This seems nowhere documented, but under Perl 5.8.0 and up, hv_store()\n\t * recognizes a negative klen parameter as meaning a UTF-8 encoded key. It\n\t * does not appear that hashes track UTF-8-ness of keys at all in Perl\n\t * 5.6.\n\t *\/\n\thlen = -(int) strlen(hkey);\n\tret = hv_store(hv, hkey, hlen, val, 0);\n\n\tif (hkey != key)\n\t\tpfree(hkey);\n\n\treturn ret;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":488549,"func":"  ~edge_clone_summary ()\n  {\n    if (prev_clone)\n      edge_clone_summaries->get (prev_clone)->next_clone = next_clone;\n    if (next_clone)\n      edge_clone_summaries->get (next_clone)->prev_clone = prev_clone;\n  }","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":255114,"func":"static void kgdb_hw_overflow_handler(struct perf_event *event, int nmi,\n\t\tstruct perf_sample_data *data, struct pt_regs *regs)\n{\n\tstruct task_struct *tsk = current;\n\tint i;\n\n\tfor (i = 0; i < 4; i++)\n\t\tif (breakinfo[i].enabled)\n\t\t\ttsk->thread.debugreg6 |= (DR_TRAP0 << i);\n}","target":1,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":94909,"func":"inline void LogSoftmax(const uint8* input_data, const RuntimeShape& input_shape,\n                       int32 input_multiplier, int32 input_left_shift,\n                       int32 reverse_scaling_divisor,\n                       int32 reverse_scaling_right_shift, int diff_min,\n                       uint8* output_data, const RuntimeShape& output_shape) {\n  SoftmaxParams params;\n  params.input_multiplier = input_multiplier;\n  params.input_left_shift = input_left_shift;\n  params.reverse_scaling_divisor = reverse_scaling_divisor;\n  params.reverse_scaling_right_shift = reverse_scaling_right_shift;\n  params.diff_min = diff_min;\n  reference_ops::LogSoftmax(params, input_shape, input_data, output_shape,\n                            output_data);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":25476,"func":"void armv7m_nvic_complete_irq ( void * opaque , int irq ) {\n nvic_state * s = ( nvic_state * ) opaque ;\n if ( irq >= 16 ) irq += 16 ;\n gic_complete_irq ( & s -> gic , 0 , irq ) ;\n }","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":492245,"func":"currval_oid(PG_FUNCTION_ARGS)\n{\n\tOid\t\t\trelid = PG_GETARG_OID(0);\n\tint64\t\tresult;\n\tSeqTable\telm;\n\tRelation\tseqrel;\n\n\t\/* open and lock sequence *\/\n\tinit_sequence(relid, &elm, &seqrel);\n\n\tif (pg_class_aclcheck(elm->relid, GetUserId(),\n\t\t\t\t\t\t  ACL_SELECT | ACL_USAGE) != ACLCHECK_OK)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),\n\t\t\t\t errmsg(\"permission denied for sequence %s\",\n\t\t\t\t\t\tRelationGetRelationName(seqrel))));\n\n\tif (!elm->last_valid)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),\n\t\t\t\t errmsg(\"currval of sequence \\\"%s\\\" is not yet defined in this session\",\n\t\t\t\t\t\tRelationGetRelationName(seqrel))));\n\n\tresult = elm->last;\n\n\trelation_close(seqrel, NoLock);\n\n\tPG_RETURN_INT64(result);\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":160165,"func":"lyd_merge(struct lyd_node *target, const struct lyd_node *source, int options)\n{\n    if (!target || !source) {\n        LOGARG;\n        return -1;\n    }\n\n    return lyd_merge_to_ctx(&target, source, options, target->schema->module->ctx);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":482537,"func":"static LogEst whereRangeAdjust(WhereTerm *pTerm, LogEst nNew){\n  LogEst nRet = nNew;\n  if( pTerm ){\n    if( pTerm->truthProb<=0 ){\n      nRet += pTerm->truthProb;\n    }else if( (pTerm->wtFlags & TERM_VNULL)==0 ){\n      nRet -= 20;        assert( 20==sqlite3LogEst(4) );\n    }\n  }\n  return nRet;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":359395,"func":"static void print_cifs_mount_version(void)\n{\n\tprintf(\"mount.cifs version: %s.%s%s\\n\",\n\t\tMOUNT_CIFS_VERSION_MAJOR,\n\t\tMOUNT_CIFS_VERSION_MINOR,\n\t\tMOUNT_CIFS_VENDOR_SUFFIX);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":442315,"func":"    size_t size () const \n    {\n        \/\/ string length + \\0\n        size_t sizeBytes = _suffix.length() + 1;\n\n        \/\/ 1 byte for scheme \/ cscIdx \/ caseInsensitive, and 1 byte for type\n        sizeBytes += 2 * Xdr::size<char>();\n\n        return sizeBytes;\n    }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":299311,"func":"static bool can_checksum_protocol(unsigned long features, __be16 protocol)\n{\n\treturn ((features & NETIF_F_GEN_CSUM) ||\n\t\t((features & NETIF_F_V4_CSUM) &&\n\t\t protocol == htons(ETH_P_IP)) ||\n\t\t((features & NETIF_F_V6_CSUM) &&\n\t\t protocol == htons(ETH_P_IPV6)) ||\n\t\t((features & NETIF_F_FCOE_CRC) &&\n\t\t protocol == htons(ETH_P_FCOE)));\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":409061,"func":"static void automount_shutdown(Manager *m) {\n        assert(m);\n\n        m->dev_autofs_fd = safe_close(m->dev_autofs_fd);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":198255,"func":"WebContents* BrowserView::GetActiveWebContents() const {\n  return browser_->tab_strip_model()->GetActiveWebContents();\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":49718,"func":"static void analPathFollow(RCoreAnalPaths *p, ut64 addr, PJ *pj) {\n\tif (addr == UT64_MAX) {\n\t\treturn;\n\t}\n\tif (!dict_get (&p->visited, addr)) {\n\t\tp->cur = r_anal_bb_from_offset (p->core->anal, addr);\n\t\tanalPaths (p, pj);\n\t}\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":227394,"func":"  Ins_CLEAR( TT_ExecContext  exc )\n  {\n    exc->new_top = 0;\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":196396,"func":" void LauncherView::UpdateFirstButtonPadding() {\n   if (view_model_->view_size() > 0) {\n     view_model_->view_at(0)->set_border(views::Border::CreateEmptyBorder(\n        primary_axis_coordinate(0, leading_inset()),\n        primary_axis_coordinate(leading_inset(), 0),\n         0,\n         0));\n   }\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":190181,"func":"void RootWindowHostLinux::ReleaseCapture() {\n}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":406557,"func":"  Item_static_float_func(const char *str, double val_arg, uint decimal_par,\n                        uint length)\n    :Item_float(NullS, val_arg, decimal_par, length), func_name(str)\n  {}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":357115,"func":"void sctp_assoc_sync_pmtu(struct sctp_association *asoc)\n{\n\tstruct sctp_transport *t;\n\t__u32 pmtu = 0;\n\n\tif (!asoc)\n\t\treturn;\n\n\t\/* Get the lowest pmtu of all the transports. *\/\n\tlist_for_each_entry(t, &asoc->peer.transport_addr_list,\n\t\t\t\ttransports) {\n\t\tif (t->pmtu_pending && t->dst) {\n\t\t\tsctp_transport_update_pmtu(t, dst_mtu(t->dst));\n\t\t\tt->pmtu_pending = 0;\n\t\t}\n\t\tif (!pmtu || (t->pathmtu < pmtu))\n\t\t\tpmtu = t->pathmtu;\n\t}\n\n\tif (pmtu) {\n\t\tstruct sctp_sock *sp = sctp_sk(asoc->base.sk);\n\t\tasoc->pathmtu = pmtu;\n\t\tasoc->frag_point = sctp_frag_point(sp, pmtu);\n\t}\n\n\tSCTP_DEBUG_PRINTK(\"%s: asoc:%p, pmtu:%d, frag_point:%d\\n\",\n\t\t\t  __func__, asoc, asoc->pathmtu, asoc->frag_point);\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":433815,"func":"point_resize (mpi_point_t p, mpi_ec_t ctx)\n{\n  size_t nlimbs = ctx->p->nlimbs;\n\n  mpi_resize (p->x, nlimbs);\n  p->x->nlimbs = nlimbs;\n  mpi_resize (p->z, nlimbs);\n  p->z->nlimbs = nlimbs;\n\n  if (ctx->model != MPI_EC_MONTGOMERY)\n    {\n      mpi_resize (p->y, nlimbs);\n      p->y->nlimbs = nlimbs;\n    }\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":181283,"func":"static __init int init_trace_selftests(void)\n{\n\tstruct trace_selftests *p, *n;\n\tstruct tracer *t, **last;\n\tint ret;\n\n\tselftests_can_run = true;\n\n\tmutex_lock(&trace_types_lock);\n\n\tif (list_empty(&postponed_selftests))\n\t\tgoto out;\n\n\tpr_info(\"Running postponed tracer tests:\\n\");\n\n\tlist_for_each_entry_safe(p, n, &postponed_selftests, list) {\n\t\tret = run_tracer_selftest(p->type);\n\t\t\/* If the test fails, then warn and remove from available_tracers *\/\n\t\tif (ret < 0) {\n\t\t\tWARN(1, \"tracer: %s failed selftest, disabling\\n\",\n\t\t\t     p->type->name);\n\t\t\tlast = &trace_types;\n\t\t\tfor (t = trace_types; t; t = t->next) {\n\t\t\t\tif (t == p->type) {\n\t\t\t\t\t*last = t->next;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlast = &t->next;\n\t\t\t}\n\t\t}\n\t\tlist_del(&p->list);\n\t\tkfree(p);\n\t}\n\n out:\n\tmutex_unlock(&trace_types_lock);\n\n\treturn 0;\n}\n","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":186449,"func":"static void kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,\n\t\t\t\t\t\t    struct mm_struct *mm,\n\t\t\t\t\t\t    unsigned long start,\n\t\t\t\t\t\t    unsigned long end)\n{\n\tstruct kvm *kvm = mmu_notifier_to_kvm(mn);\n\tint need_tlb_flush = 0, idx;\n\n\tidx = srcu_read_lock(&kvm->srcu);\n\tspin_lock(&kvm->mmu_lock);\n\t\/*\n\t * The count increase must become visible at unlock time as no\n\t * spte can be established without taking the mmu_lock and\n\t * count is also read inside the mmu_lock critical section.\n\t *\/\n\tkvm->mmu_notifier_count++;\n\tfor (; start < end; start += PAGE_SIZE)\n\t\tneed_tlb_flush |= kvm_unmap_hva(kvm, start);\n\tneed_tlb_flush |= kvm->tlbs_dirty;\n\t\/* we've to flush the tlb before the pages can be freed *\/\n\tif (need_tlb_flush)\n\t\tkvm_flush_remote_tlbs(kvm);\n\n\tspin_unlock(&kvm->mmu_lock);\n\tsrcu_read_unlock(&kvm->srcu, idx);\n}\n","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":509174,"func":"void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg_format) {\n        manager_status_printf(u->manager, false, status, unit_status_msg_format, unit_description(u));\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":169247,"func":"static int setcos_construct_fci(sc_card_t *card, const sc_file_t *file, u8 *out, size_t *outlen)\n{\n\tif (card->type == SC_CARD_TYPE_SETCOS_44 || \n\t    card->type == SC_CARD_TYPE_SETCOS_NIDEL ||\n\t    SETCOS_IS_EID_APPLET(card))\n\t\treturn setcos_construct_fci_44(card, file, out, outlen);\n\telse\n\t\treturn iso_ops->construct_fci(card, file, out, outlen);\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":10827,"func":"    RTCVoidRequestTask(MockWebRTCPeerConnectionHandler* object, const WebKit::WebRTCVoidRequest& request, bool succeeded)\n        : MethodTask<MockWebRTCPeerConnectionHandler>(object)\n        , m_request(request)\n        , m_succeeded(succeeded)\n    {\n    }\n","target":1,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":222851,"func":"  const UsbDeviceHandle::ResultCallback& callback() const { return callback_; }\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":418243,"func":"  ~RGWPutObj() override {\n    delete slo_info;\n  }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":467406,"func":"void msetCommand(client *c) {\n    msetGenericCommand(c,0);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":352088,"func":"TPMI_SH_AUTH_SESSION_Unmarshal(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, INT32 *size, BOOL allowPwd)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotLegalPwd = (*target != TPM_RS_PW) || !allowPwd;\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotLegalPwd) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}","target":1,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":418075,"func":"  virtual int init_dest_policy() { return 0; }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":376911,"func":"static int write_reftable_entry(BlockDriverState *bs, int rt_index)\n{\n    BDRVQcowState *s = bs->opaque;\n    uint64_t buf[RT_ENTRIES_PER_SECTOR];\n    int rt_start_index;\n    int i, ret;\n\n    rt_start_index = rt_index & ~(RT_ENTRIES_PER_SECTOR - 1);\n    for (i = 0; i < RT_ENTRIES_PER_SECTOR; i++) {\n        buf[i] = cpu_to_be64(s->refcount_table[rt_start_index + i]);\n    }\n\n    ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_REFCOUNT_TABLE,\n            s->refcount_table_offset + rt_start_index * sizeof(uint64_t),\n            sizeof(buf));\n    if (ret < 0) {\n        return ret;\n    }\n\n    BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_UPDATE);\n    ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset +\n            rt_start_index * sizeof(uint64_t), buf, sizeof(buf));\n    if (ret < 0) {\n        return ret;\n    }\n\n    return 0;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":154703,"func":"static bool toggle_switch(Transport *transport, bool &setting) {\n  setting = !setting;\n  transport->sendString(setting ? \"On\\n\" : \"Off\\n\");\n  return true;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":216340,"func":"void RenderWidgetHostImpl::Init() {\n  DCHECK(process_->HasConnection());\n\n  renderer_initialized_ = true;\n\n  GpuSurfaceTracker::Get()->SetSurfaceHandle(\n      surface_id_, GetCompositingSurface());\n\n  Send(new ViewMsg_CreatingNew_ACK(routing_id_));\n  GetProcess()->ResumeRequestsForView(routing_id_);\n\n  WasResized();\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":359934,"func":"filter_hidden_and_backup_partition_callback (gpointer data,\n\t\t\t\t\t     gpointer callback_data)\n{\n\tNautilusFile *file;\n\tFilterOptions options;\n\n\tfile = NAUTILUS_FILE (data);\n\toptions = GPOINTER_TO_INT (callback_data);\n\n\treturn nautilus_file_should_show (file, \n\t\t\t\t\t  options & SHOW_HIDDEN,\n\t\t\t\t\t  options & SHOW_BACKUP,\n\t\t\t\t\t  TRUE);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":60129,"func":"char VariableUnserializer::peek() const {\n  check();\n  return *m_buf;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":191301,"func":"int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value)\n{\n\twddx_stack stack;\n\tXML_Parser parser;\n\tst_entry *ent;\n\tint retval;\n\n\twddx_stack_init(&stack);\n\tparser = XML_ParserCreate(\"UTF-8\");\n\n\tXML_SetUserData(parser, &stack);\n\tXML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element);\n\tXML_SetCharacterDataHandler(parser, php_wddx_process_data);\n\n\tXML_Parse(parser, value, vallen, 1);\n\n\tXML_ParserFree(parser);\n\n\tif (stack.top == 1) {\n\t\twddx_stack_top(&stack, (void**)&ent);\n\t\t*return_value = *(ent->data);\n\t\tzval_copy_ctor(return_value);\n\t\tretval = SUCCESS;\n\t} else {\n\t\tretval = FAILURE;\n\t}\n\n\twddx_stack_destroy(&stack);\n\n\treturn retval;\n}\n","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":92338,"func":"print_inode_name(FILE * hFile, TSK_FS_INFO * fs, TSK_INUM_T inum)\n{\n    HFS_INFO *hfs = (HFS_INFO *) fs;\n    char fn[HFS_MAXNAMLEN + 1];\n    HFS_ENTRY entry;\n\n    if (hfs_cat_file_lookup(hfs, inum, &entry, FALSE))\n        return 1;\n\n    if (hfs_UTF16toUTF8(fs, entry.thread.name.unicode,\n            tsk_getu16(fs->endian, entry.thread.name.length), fn,\n            HFS_MAXNAMLEN + 1, HFS_U16U8_FLAG_REPLACE_SLASH))\n        return 1;\n\n    tsk_fprintf(hFile, \"%s\", fn);\n\n    return 0;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":90604,"func":"bool vhost_dev_has_owner(struct vhost_dev *dev)\n{\n\treturn dev->mm;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":153158,"func":"static unsigned char port_inl(const struct si_sm_io *io, unsigned int offset)\n{\n\tunsigned int addr = io->addr_data;\n\n\treturn (inl(addr + (offset * io->regspacing)) >> io->regshift) & 0xff;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":170197,"func":"static void sequenceLongMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());\n    v8SetReturnValue(info, v8Array(imp->sequenceLongMethod(), info.GetIsolate()));\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":223091,"func":"LayoutObject* HTMLMediaElement::createLayoutObject(const ComputedStyle&) {\n  return new LayoutMedia(this);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":6432,"func":"test_js (void) {\n    GString *result = g_string_new(\"\");\n\n    \/* simple javascript can be evaluated and returned *\/\n    parse_cmd_line(\"js ('x' + 345).toUpperCase()\", result);\n    g_assert_cmpstr(\"X345\", ==, result->str);\n\n    \/* uzbl commands can be run from javascript *\/\n    uzbl.net.useragent = \"Test useragent\";\n    parse_cmd_line(\"js Uzbl.run('print @useragent').toUpperCase();\", result);\n    g_assert_cmpstr(\"TEST USERAGENT\", ==, result->str);\n\n    g_string_free(result, TRUE);\n}","target":1,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":80917,"func":"int ip_defrag(struct sk_buff *skb, u32 user)\n{\n\tstruct ipq *qp;\n\tstruct net *net;\n\n\tnet = skb->dev ? dev_net(skb->dev) : dev_net(skb_dst(skb)->dev);\n\tIP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS);\n\n\t\/* Start by cleaning up the memory. *\/\n\tif (atomic_read(&net->ipv4.frags.mem) > net->ipv4.frags.high_thresh)\n\t\tip_evictor(net);\n\n\t\/* Lookup (or create) queue header *\/\n\tif ((qp = ip_find(net, ip_hdr(skb), user)) != NULL) {\n\t\tint ret;\n\n\t\tspin_lock(&qp->q.lock);\n\n\t\tret = ip_frag_queue(qp, skb);\n\n\t\tspin_unlock(&qp->q.lock);\n\t\tipq_put(qp);\n\t\treturn ret;\n\t}\n\n\tIP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);\n\tkfree_skb(skb);\n\treturn -ENOMEM;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":489056,"func":"static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesA(PCredHandle phCredential,\n                                                                     ULONG ulAttribute,\n                                                                     void* pBuffer, ULONG cbBuffer)\n{\n\tMechCred* creds;\n\tBOOL success = FALSE;\n\tSECURITY_STATUS secStatus;\n\n\tcreds = sspi_SecureHandleGetLowerPointer(phCredential);\n\n\tif (!creds)\n\t\treturn SEC_E_INVALID_HANDLE;\n\n\tfor (size_t i = 0; i < MECH_COUNT; i++)\n\t{\n\t\tMechCred* cred = &creds[i];\n\n\t\tif (!cred->valid)\n\t\t\tcontinue;\n\n\t\tWINPR_ASSERT(cred->mech);\n\t\tWINPR_ASSERT(cred->mech->pkg);\n\t\tWINPR_ASSERT(cred->mech->pkg->table);\n\t\tWINPR_ASSERT(cred->mech->pkg->table->SetCredentialsAttributesA);\n\t\tsecStatus = cred->mech->pkg->table->SetCredentialsAttributesA(&cred->cred, ulAttribute,\n\t\t                                                              pBuffer, cbBuffer);\n\n\t\tif (secStatus == SEC_E_OK)\n\t\t{\n\t\t\tsuccess = TRUE;\n\t\t}\n\t}\n\n\t\/\/ return success if at least one submodule accepts the credential attribute\n\treturn (success ? SEC_E_OK : SEC_E_UNSUPPORTED_FUNCTION);\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":367624,"func":"dump_stack (void)\n{\n\tshow_stack(NULL, NULL);\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":470024,"func":"l2la(UINT8 *out, const UINT8 *in, int xsize) {\n    int x;\n    for (x = 0; x < xsize; x++) {\n        UINT8 v = *in++;\n        *out++ = v;\n        *out++ = v;\n        *out++ = v;\n        *out++ = 255;\n    }\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":418503,"func":"  RGWPutMetadataObject()\n    : dlo_manifest(NULL)\n  {}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":430952,"func":"static int zr364xx_vidioc_querycap(struct file *file, void *priv,\n\t\t\t\t   struct v4l2_capability *cap)\n{\n\tstruct zr364xx_camera *cam = video_drvdata(file);\n\n\tstrscpy(cap->driver, DRIVER_DESC, sizeof(cap->driver));\n\tif (cam->udev->product)\n\t\tstrscpy(cap->card, cam->udev->product, sizeof(cap->card));\n\tstrscpy(cap->bus_info, dev_name(&cam->udev->dev),\n\t\tsizeof(cap->bus_info));\n\tcap->device_caps = V4L2_CAP_VIDEO_CAPTURE |\n\t\t\t    V4L2_CAP_READWRITE |\n\t\t\t    V4L2_CAP_STREAMING;\n\tcap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;\n\n\treturn 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":210941,"func":"void LocalSiteCharacteristicsDataImpl::IncrementFeatureObservationDuration(\n    SiteCharacteristicsFeatureProto* feature_proto,\n    base::TimeDelta extra_observation_duration) {\n  if (!feature_proto->has_use_timestamp() ||\n      InternalRepresentationToTimeDelta(feature_proto->use_timestamp())\n          .is_zero()) {\n    feature_proto->set_observation_duration(TimeDeltaToInternalRepresentation(\n        InternalRepresentationToTimeDelta(\n            feature_proto->observation_duration()) +\n        extra_observation_duration));\n  }\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":423424,"func":"dns_zone_getkeyopts(dns_zone_t *zone) {\n\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\n\treturn (zone->keyopts);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":481507,"func":"static __cold int io_init_bl_list(struct io_ring_ctx *ctx)\n{\n\tint i;\n\n\tctx->io_bl = kcalloc(BGID_ARRAY, sizeof(struct io_buffer_list),\n\t\t\t\tGFP_KERNEL);\n\tif (!ctx->io_bl)\n\t\treturn -ENOMEM;\n\n\tfor (i = 0; i < BGID_ARRAY; i++) {\n\t\tINIT_LIST_HEAD(&ctx->io_bl[i].buf_list);\n\t\tctx->io_bl[i].bgid = i;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":359587,"func":"sort_vpn_connections (gconstpointer a, gconstpointer b)\n{\n\treturn strcmp (get_connection_id (NM_CONNECTION (a)), get_connection_id (NM_CONNECTION (b)));\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":173038,"func":"  explicit MultipleThreadMain(int16 id) : id_(id) {}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":348689,"func":"    DataLocId CiffComponent::dataLocation(uint16_t tag)\n    {\n        DataLocId di = invalidDataLocId;\n        switch (tag & 0xc000) {\n        case 0x0000: di = valueData; break;\n        case 0x4000: di = directoryData; break;\n        }\n        return di;\n    } \/\/ CiffComponent::dataLocation","target":1,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":226963,"func":"bool HTMLInputElement::isTelephoneField() const\n{\n    return m_inputType->isTelephoneField();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":415719,"func":"int sscanf(const char *buf, const char *fmt, ...)\n{\n\tva_list args;\n\tint i;\n\n\tva_start(args, fmt);\n\ti = vsscanf(buf, fmt, args);\n\tva_end(args);\n\n\treturn i;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":187823,"func":" virtual status_t queryKeyStatus(Vector<uint8_t> const &sessionId,\n KeyedVector<String8, String8> &infoMap) const {\n Parcel data, reply;\n        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());\n\n        writeVector(data, sessionId);\n status_t status = remote()->transact(QUERY_KEY_STATUS, data, &reply);\n if (status != OK) {\n return status;\n }\n\n        infoMap.clear();\n size_t count = reply.readInt32();\n for (size_t i = 0; i < count; i++) {\n String8 key = reply.readString8();\n String8 value = reply.readString8();\n            infoMap.add(key, value);\n }\n return reply.readInt32();\n }\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":520135,"func":"uint8 subselect_union_engine::uncacheable()\n{\n  return unit->uncacheable;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":233770,"func":"VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,\n                            void (*handle_output)(VirtIODevice *, VirtQueue *))\n{\n    int i;\n\n    for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {\n        if (vdev->vq[i].vring.num == 0)\n            break;\n    }\n\n    if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE)\n        abort();\n\n    vdev->vq[i].vring.num = queue_size;\n    vdev->vq[i].vring.align = VIRTIO_PCI_VRING_ALIGN;\n    vdev->vq[i].handle_output = handle_output;\n\n    return &vdev->vq[i];\n}\n","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":338070,"func":"static int socket_close(void *opaque)\n\n{\n\n    QEMUFileSocket *s = opaque;\n\n    closesocket(s->fd);\n\n    g_free(s);\n\n    return 0;\n\n}\n","target":1,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":65605,"func":"TEST_P(Http2FloodMitigationTest, ZerolenHeader) {\n  beginSession();\n\n  \/\/ Send invalid request.\n  uint32_t request_idx = 0;\n  auto request = Http2Frame::makeMalformedRequestWithZerolenHeader(request_idx, \"host\", \"\/\");\n  sendFame(request);\n\n  tcp_client_->waitForDisconnect();\n\n  EXPECT_EQ(1, test_server_->counter(\"http2.rx_messaging_error\")->value());\n  EXPECT_EQ(1,\n            test_server_->counter(\"http.config_test.downstream_cx_delayed_close_timeout\")->value());\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":104272,"func":"int emulator_write_emulated(struct x86_emulate_ctxt *ctxt,\n\t\t\t    unsigned long addr,\n\t\t\t    const void *val,\n\t\t\t    unsigned int bytes,\n\t\t\t    struct x86_exception *exception)\n{\n\treturn emulator_read_write(ctxt, addr, (void *)val, bytes,\n\t\t\t\t   exception, &write_emultor);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":369230,"func":"copyset (charclass const src, charclass dst)\n{\n  memcpy (dst, src, sizeof (charclass));\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":157709,"func":"  OSDMapRef get_nextmap_reserved() {\n    Mutex::Locker l(pre_publish_lock);\n    if (!next_osdmap)\n      return OSDMapRef();\n    epoch_t e = next_osdmap->get_epoch();\n    map<epoch_t, unsigned>::iterator i =\n      map_reservations.insert(make_pair(e, 0)).first;\n    i->second++;\n    return next_osdmap;\n  }","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":295563,"func":"CAMLexport mlsize_t caml_string_length(value s)\n{\n  mlsize_t temp;\n  temp = Bosize_val(s) - 1;\n  Assert (Byte (s, temp - Byte (s, temp)) == 0);\n  return temp - Byte (s, temp);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":252248,"func":"void Tab::SelectedStateChanged() {\n  UpdateForegroundColors();\n}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":43369,"func":"void handle_no_error(struct st_command *command)\n{\n  DBUG_ENTER(\"handle_no_error\");\n\n  if (command->expected_errors.err[0].type == ERR_ERRNO &&\n      command->expected_errors.err[0].code.errnum != 0)\n  {\n    \/* Error code we wanted was != 0, i.e. not an expected success *\/\n    die(\"query '%s' succeeded - should have failed with errno %d...\",\n        command->query, command->expected_errors.err[0].code.errnum);\n  }\n  else if (command->expected_errors.err[0].type == ERR_SQLSTATE &&\n           strcmp(command->expected_errors.err[0].code.sqlstate,\"00000\") != 0)\n  {\n    \/* SQLSTATE we wanted was != \"00000\", i.e. not an expected success *\/\n    die(\"query '%s' succeeded - should have failed with sqlstate %s...\",\n        command->query, command->expected_errors.err[0].code.sqlstate);\n  }\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":148374,"func":"static void TraceCircle(PrimitiveInfo *primitive_info,const PointInfo start,\n  const PointInfo end)\n{\n  double\n    alpha,\n    beta,\n    radius;\n\n  PointInfo\n    offset,\n    degrees;\n\n  alpha=end.x-start.x;\n  beta=end.y-start.y;\n  radius=hypot((double) alpha,(double) beta);\n  offset.x=(double) radius;\n  offset.y=(double) radius;\n  degrees.x=0.0;\n  degrees.y=360.0;\n  TraceEllipse(primitive_info,start,offset,degrees);\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":22204,"func":"static int check_vcdiff_header ( xd3_stream * stream , const char * input , const char * line_start , const char * matches , int yes_or_no ) {\n int ret ;\n char vcmd [ TESTBUFSIZE ] , gcmd [ TESTBUFSIZE ] ;\n snprintf_func ( vcmd , TESTBUFSIZE , \"%s printhdr -f %s %s\" , program_name , input , TEST_RECON2_FILE ) ;\n if ( ( ret = system ( vcmd ) ) != 0 ) {\n XPR ( NT \"printhdr command: %s\\n\" , vcmd ) ;\n stream -> msg = \"printhdr cmd failed\" ;\n return XD3_INTERNAL ;\n }\n snprintf_func ( gcmd , TESTBUFSIZE , \"grep \\\"%s.*%s.*\\\" %s > \/devull\" , line_start , matches , TEST_RECON2_FILE ) ;\n if ( yes_or_no ) {\n if ( ( ret = do_cmd ( stream , gcmd ) ) ) {\n XPR ( NT \"%s\\n\" , gcmd ) ;\n return ret ;\n }\n }\n else {\n if ( ( ret = do_fail ( stream , gcmd ) ) ) {\n XPR ( NT \"%s\\n\" , gcmd ) ;\n return ret ;\n }\n }\n return 0 ;\n }","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":519229,"func":"Field_bit::do_last_null_byte() const\n{\n  \/*\n    Code elsewhere is assuming that bytes are 8 bits, so I'm using\n    that value instead of the correct one: CHAR_BIT.\n\n    REFACTOR SUGGESTION (Matz): Change to use the correct number of\n    bits. On systems with CHAR_BIT > 8 (not very common), the storage\n    will lose the extra bits.\n  *\/\n  DBUG_PRINT(\"test\", (\"bit_ofs: %d, bit_len: %d  bit_ptr: %p\",\n                      bit_ofs, bit_len, bit_ptr));\n  uchar *result;\n  if (bit_len == 0)\n    result= null_ptr;\n  else if (bit_ofs + bit_len > 8)\n    result= bit_ptr + 1;\n  else\n    result= bit_ptr;\n\n  if (result)\n    return (size_t) (result - table->record[0]) + 1;\n  return LAST_NULL_BYTE_UNDEF;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":209800,"func":"PHP_FUNCTION(mb_ereg_search_setpos)\n{\n\tlong position;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &position) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (position < 0 || (MBREX(search_str) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN_P(MBREX(search_str)))) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Position is out of range\");\n\t\tMBREX(search_pos) = 0;\n\t\tRETURN_FALSE;\n\t}\n\n\tMBREX(search_pos) = position;\n\tRETURN_TRUE;\n}\n","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":303127,"func":"static size_t p_seek(void *fp, size_t offset) {\n#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) ||  \\\n    (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \\\n    (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)\n  fseeko((FILE *) fp, (off_t) offset, SEEK_SET);\n#else\n  fseek((FILE *) fp, (long) offset, SEEK_SET);\n#endif\n  return (size_t) ftell((FILE *) fp);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":294220,"func":"static void lsr_read_focus(GF_LASeRCodec *lsr, SVG_Focus *foc, const char *name)\n{\n\tu32 flag;\n\n\tif (foc->target.string) {\n\t\tgf_free(foc->target.string);\n\t\tfoc->target.string = NULL;\n\t}\n\tif (foc->target.target) foc->target.target = NULL;\n\tgf_node_unregister_iri(lsr->sg, &foc->target);\n\n\tGF_LSR_READ_INT(lsr, flag, 1, \"isEnum\");\n\tif (flag) {\n\t\tGF_LSR_READ_INT(lsr, foc->type, 1, \"enum\");\n\t} else {\n\t\tfoc->type = SVG_FOCUS_IRI;\n\t\tlsr_read_codec_IDREF(lsr, &foc->target, \"id\");\n\t}\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":263718,"func":"b64enc(bs, inp, inlen, outp)\nstruct b64state *bs;\nu_char *inp;\nint inlen;\nu_char *outp;\n{\n\tint outlen = 0;\n\n\twhile (inlen > 0) {\n\t\tbs->bs_bits = (bs->bs_bits << 8) | *inp++;\n\t\tinlen--;\n\t\tbs->bs_offs += 8;\n\t\tif (bs->bs_offs >= 24) {\n\t\t\t*outp++ = base64[(bs->bs_bits >> 18) & 0x3F];\n\t\t\t*outp++ = base64[(bs->bs_bits >> 12) & 0x3F];\n\t\t\t*outp++ = base64[(bs->bs_bits >> 6) & 0x3F];\n\t\t\t*outp++ = base64[bs->bs_bits & 0x3F];\n\t\t\toutlen += 4;\n\t\t\tbs->bs_offs = 0;\n\t\t\tbs->bs_bits = 0;\n\t\t}\n\t}\n\treturn (outlen);\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":326319,"func":"static void unplug_nic(PCIBus *b, PCIDevice *d)\n\n{\n\n    if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==\n\n            PCI_CLASS_NETWORK_ETHERNET) {\n\n        qdev_unplug(&(d->qdev), NULL);\n\n    }\n\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":407083,"func":"static CURLcode imap_block_statemach(struct connectdata *conn)\n{\n  CURLcode result = CURLE_OK;\n  struct imap_conn *imapc = &conn->proto.imapc;\n\n  while(imapc->state != IMAP_STOP && !result)\n    result = Curl_pp_statemach(&imapc->pp, TRUE);\n\n  return result;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":15602,"func":"static int load_matrix ( MpegEncContext * s , uint16_t matrix0 [ 64 ] , uint16_t matrix1 [ 64 ] , int intra ) {\n int i ;\n for ( i = 0 ;\n i < 64 ;\n i ++ ) {\n int j = s -> dsp . idct_permutation [ ff_zigzag_direct [ i ] ] ;\n int v = get_bits ( & s -> gb , 8 ) ;\n if ( v == 0 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"matrix damaged\\n\" ) ;\n return - 1 ;\n }\n if ( intra && i == 0 && v != 8 ) {\n av_log ( s -> avctx , AV_LOG_ERROR , \"intra matrix invalid, ignoring\\n\" ) ;\n v = 8 ;\n }\n matrix0 [ j ] = v ;\n if ( matrix1 ) matrix1 [ j ] = v ;\n }\n return 0 ;\n }","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":68415,"func":"TEST_F(QuotedString_ExtractFrom_Tests, EscapedNewline) {\n  whenInputIs(\"\\\"hello \\\\nworld\\\\n\\\"\");\n  resultMustBe(\"hello \\nworld\\n\");\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":242698,"func":"void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent(\n    const std::vector<EditCommand>& commands) {\n  Send(new ViewMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands));\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":203136,"func":"cricket::SessionDescription* JingleSessionManager::CreateHostSessionDescription(\n    const CandidateSessionConfig* config,\n    const std::string& certificate) {\n  cricket::SessionDescription* desc = new cricket::SessionDescription();\n  desc->AddContent(\n      ContentDescription::kChromotingContentName, kChromotingXmlNamespace,\n      new ContentDescription(config, \"\", certificate));\n  return desc;\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":173093,"func":"fbCombineConjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)\n{\n    fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":506267,"func":"SSL_CIPHER *SSL_get_current_cipher(const SSL *s)\n\t{\n\tif ((s->session != NULL) && (s->session->cipher != NULL))\n\t\treturn(s->session->cipher);\n\treturn(NULL);\n\t}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":57046,"func":"static Sg_device *sg_lookup_dev(int dev)\n{\n\treturn idr_find(&sg_index_idr, dev);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":307105,"func":"void TopSitesImpl::OnTopSitesAvailableFromHistory(\n    const MostVisitedURLList* pages) {\n  DCHECK(pages);\n  SetTopSites(*pages, CALL_LOCATION_FROM_OTHER_PLACES);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":220658,"func":"  MockAudioManager()\n      : AudioManagerPlatform(std::make_unique<media::TestAudioThread>(),\n                             &fake_audio_log_factory_),\n        num_output_devices_(2),\n        num_input_devices_(2) {}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":57016,"func":"Variant HHVM_FUNCTION(mcrypt_cfb, const String& cipher, const String& key,\n                                  const String& data, const Variant& mode,\n                                  const Variant& viv \/* = null_string *\/) {\n  raise_deprecated(\"Function mcrypt_cfb() is deprecated\");\n  String iv = viv.toString();\n  return php_mcrypt_do_crypt(cipher, key, data, \"cfb\", iv, mode.toInt32(),\n                             \"mcrypt_cfb\");\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":216501,"func":"bool ShouldUseClientLoFiForRequest(\n    const ResourceRequest& request,\n    WebURLRequest::PreviewsState frame_previews_state) {\n  if (request.GetPreviewsState() != WebURLRequest::kPreviewsUnspecified)\n    return request.GetPreviewsState() & WebURLRequest::kClientLoFiOn;\n\n  if (!(frame_previews_state & WebURLRequest::kClientLoFiOn))\n    return false;\n\n  if (frame_previews_state & WebURLRequest::kServerLoFiOn)\n    return request.Url().ProtocolIs(\"https\");\n\n  return true;\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":238559,"func":"int equalizer_get_band_level(equalizer_context_t *context, int32_t band)\n{\n    ALOGV(\"%s: band: %d level: %d\", __func__, band,\n           context->band_levels[band] * 100);\n return context->band_levels[band] * 100;\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":356117,"func":"static void *shmem_follow_link(struct dentry *dentry, struct nameidata *nd)\n{\n\tstruct page *page = NULL;\n\tint res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL);\n\tnd_set_link(nd, res ? ERR_PTR(res) : kmap(page));\n\tif (page)\n\t\tunlock_page(page);\n\treturn page;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":114799,"func":"static int __submit_flush_wait(struct f2fs_sb_info *sbi,\n\t\t\t\tstruct block_device *bdev)\n{\n\tstruct bio *bio = f2fs_bio_alloc(0);\n\tint ret;\n\n\tbio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;\n\tbio_set_dev(bio, bdev);\n\tret = submit_bio_wait(bio);\n\tbio_put(bio);\n\n\ttrace_f2fs_issue_flush(bdev, test_opt(sbi, NOBARRIER),\n\t\t\t\ttest_opt(sbi, FLUSH_MERGE), ret);\n\treturn ret;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":275412,"func":"bool JSTestEventTargetConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)\n{\n    return getStaticValueDescriptor<JSTestEventTargetConstructor, JSDOMWrapper>(exec, &JSTestEventTargetConstructorTable, jsCast<JSTestEventTargetConstructor*>(object), propertyName, descriptor);\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":42078,"func":"static void rdev_free(struct kobject *ko)\n{\n\tstruct md_rdev *rdev = container_of(ko, struct md_rdev, kobj);\n\tkfree(rdev);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":394036,"func":"static inline void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags)\n{\n\tactivate_task(rq, p, en_flags);\n\tp->on_rq = TASK_ON_RQ_QUEUED;\n\n\t\/* if a worker is waking up, notify workqueue *\/\n\tif (p->flags & PF_WQ_WORKER)\n\t\twq_worker_waking_up(p, cpu_of(rq));\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":161819,"func":"static int data_pkt(git_pkt **out, const char *line, size_t len)\n{\n\tgit_pkt_data *pkt;\n\tsize_t alloclen;\n\n\tline++;\n\tlen--;\n\n\tGITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);\n\tpkt = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt);\n\n\tpkt->type = GIT_PKT_DATA;\n\tpkt->len = (int) len;\n\tmemcpy(pkt->data, line, len);\n\n\t*out = (git_pkt *) pkt;\n\n\treturn 0;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":136139,"func":"  Config::~Config() {\n    del();\n  }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":253031,"func":"void on_firmware_memory_dump(char *buffer, int buffer_size) {\n\n JNIHelper helper(mVM);\n \/* ALOGD(\"on_firmware_memory_dump called, vm = %p, obj = %p, env = %p buffer_size = %d\"\n            , mVM, mCls, env, buffer_size); *\/\n\n if (buffer_size > 0) {\n JNIObject<jbyteArray> dump = helper.newByteArray(buffer_size);\n        jbyte *bytes = (jbyte *) (buffer);\n        helper.setByteArrayRegion(dump, 0, buffer_size, bytes);\n        helper.reportEvent(mCls,\"onWifiFwMemoryAvailable\",\"([B)V\", dump.get());\n }\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":136375,"func":"PJ_DEF(void) pj_dns_init_srv_rr( pj_dns_parsed_rr *rec,\n\t\t\t\t const pj_str_t *res_name,\n\t\t\t\t unsigned dnsclass,\n\t\t\t\t unsigned ttl,\n\t\t\t\t unsigned prio,\n\t\t\t\t unsigned weight,\n\t\t\t\t unsigned port,\n\t\t\t\t const pj_str_t *target)\n{\n    pj_bzero(rec, sizeof(*rec));\n    rec->name = *res_name;\n    rec->type = PJ_DNS_TYPE_SRV;\n    rec->dnsclass = (pj_uint16_t) dnsclass;\n    rec->ttl = ttl;\n    rec->rdata.srv.prio = (pj_uint16_t) prio;\n    rec->rdata.srv.weight = (pj_uint16_t) weight;\n    rec->rdata.srv.port = (pj_uint16_t) port;\n    rec->rdata.srv.target = *target;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":117054,"func":"bool HHVM_FUNCTION(natcasesort, VRefParam array) {\n  return php_asort(array, SORT_NATURAL_CASE, true, false);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":71867,"func":"backend_forkexec(Port *port)\n{\n\tchar\t   *av[4];\n\tint\t\t\tac = 0;\n\n\tav[ac++] = \"postgres\";\n\tav[ac++] = \"--forkbackend\";\n\tav[ac++] = NULL;\t\t\t\/* filled in by internal_forkexec *\/\n\n\tav[ac] = NULL;\n\tAssert(ac < lengthof(av));\n\n\treturn internal_forkexec(ac, av, port);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":71847,"func":"static inline int copy_user_to_xregs(struct xregs_state __user *buf, u64 mask)\n{\n\tstruct xregs_state *xstate = ((__force struct xregs_state *)buf);\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\tint err;\n\n\tstac();\n\tXSTATE_OP(XRSTOR, xstate, lmask, hmask, err);\n\tclac();\n\n\treturn err;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":309699,"func":"bool NormalPage::isEmpty() {\n  HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(payload());\n  return header->isFree() && header->size() == payloadSize();\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":335538,"func":"static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,\n\n                               unsigned int len)\n\n{\n\n    unsigned int offset;\n\n    int i;\n\n\n\n    offset = 0;\n\n    for (i = 0; i < elem->in_num; i++) {\n\n        size_t size = MIN(len - offset, elem->in_sg[i].iov_len);\n\n\n\n        cpu_physical_memory_unmap(elem->in_sg[i].iov_base,\n\n                                  elem->in_sg[i].iov_len,\n\n                                  1, size);\n\n\n\n        offset += size;\n\n    }\n\n\n\n    for (i = 0; i < elem->out_num; i++)\n\n        cpu_physical_memory_unmap(elem->out_sg[i].iov_base,\n\n                                  elem->out_sg[i].iov_len,\n\n                                  0, elem->out_sg[i].iov_len);\n\n}\n","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":331638,"func":"static void i82374_init(I82374State *s)\n\n{\n\n    DMA_init(1, NULL);\n\n    memset(s->commands, 0, sizeof(s->commands));\n\n}\n","target":1,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":24303,"func":"void hb_face_destroy ( hb_face_t * face ) {\n if ( ! hb_object_destroy ( face ) ) return ;\n for ( hb_face_t : : plan_node_t * node = face -> shape_plans ;\n node ;\n ) {\n hb_face_t : : plan_node_t * next = node -> next ;\n hb_shape_plan_destroy ( node -> shape_plan ) ;\n free ( node ) ;\n node = next ;\n }\n # define HB_SHAPER_IMPLEMENT ( shaper ) HB_SHAPER_DATA_DESTROY ( shaper , face ) ;\n # include \"hb-shaper-list.hh\" # undef HB_SHAPER_IMPLEMENT if ( face -> destroy ) face -> destroy ( face -> user_data ) ;\n free ( face ) ;\n }","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":329689,"func":"static void nbd_client_close(NBDClient *client)\n\n{\n\n    qemu_set_fd_handler2(client->sock, NULL, NULL, NULL, NULL);\n\n    close(client->sock);\n\n    client->sock = -1;\n\n    if (client->close) {\n\n        client->close(client);\n\n    }\n\n    nbd_client_put(client);\n\n}\n","target":1,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":94790,"func":"X509 *d2i_X509_bio(BIO *bp, X509 **x509)\n\t{\n\treturn ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509), bp, x509);\n\t}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":417660,"func":"static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {\n        _cleanup_link_unref_ Link *link = userdata;\n        int r;\n\n        log_link_debug(link, \"Set link\");\n\n        r = sd_netlink_message_get_errno(m);\n        if (r < 0 && r != -EEXIST) {\n                log_link_error_errno(link, r, \"Could not join netdev: %m\");\n                link_enter_failed(link);\n                return 1;\n        }\n\n        return 0;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":317930,"func":"int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey)\n\t{\n\treturn ASN1_i2d_fp_of(EC_KEY,i2d_ECPrivateKey,fp,eckey);\n\t}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":205183,"func":"void Document::EnforceSandboxFlags(SandboxFlags mask) {\n  scoped_refptr<const SecurityOrigin> stand_in_origin = GetSecurityOrigin();\n  bool is_potentially_trustworthy =\n      stand_in_origin && stand_in_origin->IsPotentiallyTrustworthy();\n  ApplySandboxFlags(mask, is_potentially_trustworthy);\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":374135,"func":"popup_dialog_idle (GSWindow *window)\n{\n        popup_dialog (window);\n\n        window->priv->popup_dialog_idle_id = 0;\n\n        return FALSE;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":19400,"func":"static void t38_defragment_init ( void ) {\n reassembly_table_init ( & data_reassembly_table , & addresses_reassembly_table_functions ) ;\n }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":295831,"func":"address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,\n                                    const void *buf, hwaddr len)\n{\n    hwaddr addr1, l;\n    MemoryRegion *mr;\n\n    l = len;\n    mr = address_space_translate_cached(cache, addr, &addr1, &l, true,\n                                        MEMTXATTRS_UNSPECIFIED);\n    return flatview_write_continue(cache->fv,\n                                   addr, MEMTXATTRS_UNSPECIFIED, buf, len,\n                                   addr1, l, mr);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":76615,"func":"COMPAT_SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,\n\t\tconst struct compat_itimerspec __user *, utmr,\n\t\tstruct compat_itimerspec __user *, otmr)\n{\n\tstruct itimerspec new, old;\n\tint ret;\n\n\tif (get_compat_itimerspec(&new, utmr))\n\t\treturn -EFAULT;\n\tret = do_timerfd_settime(ufd, flags, &new, &old);\n\tif (ret)\n\t\treturn ret;\n\tif (otmr && put_compat_itimerspec(otmr, &old))\n\t\treturn -EFAULT;\n\treturn ret;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":245707,"func":"JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {\n   base::android::InitVM(vm);\n   if (!content::android::OnJNIOnLoadInit())\n     return -1;\n  content::SetContentMainDelegate(new content::ShellMainDelegate(true));\n   return JNI_VERSION_1_4;\n }\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":438592,"func":"uint64_t Projection::PayloadSize() const {\n  uint64_t size =\n      EbmlElementSize(libwebm::kMkvProjection, static_cast<uint64>(type_));\n\n  if (private_data_length_ > 0 && private_data_ != NULL) {\n    size += EbmlElementSize(libwebm::kMkvProjectionPrivate, private_data_,\n                            private_data_length_);\n  }\n\n  size += EbmlElementSize(libwebm::kMkvProjectionPoseYaw, pose_yaw_);\n  size += EbmlElementSize(libwebm::kMkvProjectionPosePitch, pose_pitch_);\n  size += EbmlElementSize(libwebm::kMkvProjectionPoseRoll, pose_roll_);\n\n  return size;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":141010,"func":"void BytecodeFunctionGenerator::setJumpTable(\n    std::vector<uint32_t> &&jumpTable) {\n  assert(!jumpTable.empty() && \"invoked with no jump table\");\n\n  jumpTable_ = std::move(jumpTable);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":451357,"func":"TEST(HeaderMapImplTest, DoubleInlineSet) {\n  TestRequestHeaderMapImpl headers;\n  headers.setReferenceKey(Headers::get().ContentType, \"blah\");\n  headers.setReferenceKey(Headers::get().ContentType, \"text\/html\");\n  EXPECT_EQ(\"text\/html\", headers.getContentTypeValue());\n  EXPECT_EQ(1UL, headers.size());\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":363566,"func":"irc_server_set_nick (struct t_irc_server *server, const char *nick)\n{\n    struct t_irc_channel *ptr_channel;\n    \n    if (server->nick)\n        free (server->nick);\n    server->nick = (nick) ? strdup (nick) : NULL;\n    \n    \/* set local variable \"nick\" for server and all channels\/pv *\/\n    weechat_buffer_set (server->buffer, \"localvar_set_nick\", nick);\n    for (ptr_channel = server->channels; ptr_channel;\n         ptr_channel = ptr_channel->next_channel)\n    {\n        weechat_buffer_set (ptr_channel->buffer, \"localvar_set_nick\", nick);\n    }\n    \n    weechat_bar_item_update (\"input_prompt\");\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":82709,"func":"struct socket *tun_get_socket(struct file *file)\n{\n\tstruct tun_file *tfile;\n\tif (file->f_op != &tun_fops)\n\t\treturn ERR_PTR(-EINVAL);\n\ttfile = file->private_data;\n\tif (!tfile)\n\t\treturn ERR_PTR(-EBADFD);\n\treturn &tfile->socket;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":365144,"func":"dirserv_set_cached_directory(const char *directory, time_t published,\n                             int is_running_routers)\n{\n  time_t now = time(NULL);\n\n  if (is_running_routers) {\n    if (published >= now - MAX_V1_RR_AGE)\n      set_cached_dir(&cached_runningrouters, tor_strdup(directory), published);\n  } else {\n    if (published >= now - MAX_V1_DIRECTORY_AGE) {\n      cached_dir_decref(cached_directory);\n      cached_directory = new_cached_dir(tor_strdup(directory), published);\n    }\n  }\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":31186,"func":"static KeydbResourceType rt_from_file ( const char * filename , int * r_found , int * r_openpgp ) {\n u32 magic ;\n unsigned char verbuf [ 4 ] ;\n FILE * fp ;\n KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE ;\n * r_found = * r_openpgp = 0 ;\n fp = fopen ( filename , \"rb\" ) ;\n if ( fp ) {\n * r_found = 1 ;\n if ( fread ( & magic , 4 , 1 , fp ) == 1 ) {\n if ( magic == 0x13579ace || magic == 0xce9a5713 ) ;\n else if ( fread ( & verbuf , 4 , 1 , fp ) == 1 && verbuf [ 0 ] == 1 && fread ( & magic , 4 , 1 , fp ) == 1 && ! memcmp ( & magic , \"KBXf\" , 4 ) ) {\n if ( ( verbuf [ 3 ] & 0x02 ) ) * r_openpgp = 1 ;\n rt = KEYDB_RESOURCE_TYPE_KEYBOX ;\n }\n else rt = KEYDB_RESOURCE_TYPE_KEYRING ;\n }\n else rt = KEYDB_RESOURCE_TYPE_KEYRING ;\n fclose ( fp ) ;\n }\n return rt ;\n }","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":417378,"func":"static char *get_default_remote(void)\n{\n\tchar *dest = NULL, *ret;\n\tunsigned char sha1[20];\n\tstruct strbuf sb = STRBUF_INIT;\n\tconst char *refname = resolve_ref_unsafe(\"HEAD\", 0, sha1, NULL);\n\n\tif (!refname)\n\t\tdie(_(\"No such ref: %s\"), \"HEAD\");\n\n\t\/* detached HEAD *\/\n\tif (!strcmp(refname, \"HEAD\"))\n\t\treturn xstrdup(\"origin\");\n\n\tif (!skip_prefix(refname, \"refs\/heads\/\", &refname))\n\t\tdie(_(\"Expecting a full ref name, got %s\"), refname);\n\n\tstrbuf_addf(&sb, \"branch.%s.remote\", refname);\n\tif (git_config_get_string(sb.buf, &dest))\n\t\tret = xstrdup(\"origin\");\n\telse\n\t\tret = dest;\n\n\tstrbuf_release(&sb);\n\treturn ret;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":353956,"func":"set_gray_color_procs(gx_device * pdev,\n        dev_t_proc_encode_color((*encode_color), gx_device),\n        dev_t_proc_decode_color((*decode_color), gx_device))\n{\n    set_color_procs(pdev, encode_color, decode_color,\n        gx_default_DevGray_get_color_mapping_procs,\n        gx_default_DevGray_get_color_comp_index);\n}","target":1,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":83120,"func":"eval_init(void)\n{\n    evalvars_init();\n    func_init();\n\n#ifdef EBCDIC\n    \/*\n     * Sort the function table, to enable binary search.\n     *\/\n    sortFunctions();\n#endif\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":426341,"func":"DnD_TransportReqPacket(DnDTransportBuffer *buf,           \/\/ IN\n                       DnDTransportPacketHeader **packet) \/\/ OUT\n{\n   *packet = Util_SafeMalloc(DND_TRANSPORT_PACKET_HEADER_SIZE);\n\n   (*packet)->type = DND_TRANSPORT_PACKET_TYPE_REQUEST;\n   (*packet)->seqNum = buf->seqNum;\n   (*packet)->totalSize = buf->totalSize;\n   (*packet)->payloadSize = 0;\n   (*packet)->offset = buf->offset;\n   return DND_TRANSPORT_PACKET_HEADER_SIZE;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":13144,"func":"lib_file_open(gs_file_path_ptr  lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx_p,\n                       const char *fname, uint flen, char *buffer, int blen, uint *pclen, ref *pfile)\n{   \/* i_ctx_p is NULL running arg (@) files.\n     * lib_path and mem are never NULL\n     *\/\n    bool starting_arg_file = (i_ctx_p == NULL) ? true : i_ctx_p->starting_arg_file;\n    bool search_with_no_combine = false;\n    bool search_with_combine = false;\n    char fmode[2] = { 'r', 0};\n    gx_io_device *iodev = iodev_default(mem);\n     gs_main_instance *minst = get_minst_from_memory(mem);\n     int code;\n \n     \/* when starting arg files (@ files) iodev_default is not yet set *\/\n     if (iodev == 0)\n         iodev = (gx_io_device *)gx_io_device_table[0];\n       search_with_combine = false;\n    } else {\n       search_with_no_combine = starting_arg_file;\n       search_with_combine = true;\n    }\n","target":1,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":288275,"func":"void StyleResolver::matchUARules(ElementRuleCollector& collector)\n {\n     collector.setMatchingUARules(true);\n \n    if (CSSDefaultStyleSheets::simpleDefaultStyleSheet)\n        collector.matchedResult().isCacheable = false;\n     RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific(\"print\")\n         ? CSSDefaultStyleSheets::defaultPrintStyle : CSSDefaultStyleSheets::defaultStyle;\n     matchUARules(collector, userAgentStyleSheet);\n\n    if (document().inQuirksMode())\n        matchUARules(collector, CSSDefaultStyleSheets::defaultQuirksStyle);\n\n    if (document().isViewSource())\n        matchUARules(collector, CSSDefaultStyleSheets::viewSourceStyle());\n\n    collector.setMatchingUARules(false);\n\n    matchWatchSelectorRules(collector);\n}\n","target":1,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":185265,"func":"bool MatchFilter::MatchesDomain(const std::string& domain) {\n  if (!details_->HasKey(keys::kDomainKey))\n    return true;\n\n  std::string filter_value;\n  if (!details_->GetString(keys::kDomainKey, &filter_value))\n     return false;\n   if (net::CookieMonster::DomainIsHostOnly(filter_value))\n    filter_value.insert(0, \".\");\n \n   std::string sub_domain(domain);\n   if (!net::CookieMonster::DomainIsHostOnly(sub_domain))\n     sub_domain = sub_domain.substr(1);\n \n  \/\/ Now check whether the domain argument is a subdomain of the filter domain.\n  for (sub_domain.insert(0, \".\");\n       sub_domain.length() >= filter_value.length();) {\n     if (sub_domain == filter_value)\n       return true;\n     const size_t next_dot = sub_domain.find('.', 1);  \/\/ Skip over leading dot.\n    sub_domain.erase(0, next_dot);\n  }\n  return false;\n}\n","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":77266,"func":"static void dwc3_ep_inc_trb(u8 *index)\n{\n\t(*index)++;\n\tif (*index == (DWC3_TRB_NUM - 1))\n\t\t*index = 0;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":475630,"func":"static bool lockdep_commit_lock_is_held(const struct net *net)\n{\n#ifdef CONFIG_PROVE_LOCKING\n\tstruct nftables_pernet *nft_net = nft_pernet(net);\n\n\treturn lockdep_is_held(&nft_net->commit_mutex);\n#else\n\treturn true;\n#endif\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":25573,"func":"static void dtap_cc_notify ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {\n guint32 curr_offset ;\n guint32 consumed ;\n guint curr_len ;\n curr_offset = offset ;\n curr_len = len ;\n is_uplink = IS_UPLINK_FALSE ;\n ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_NOT_IND , NULL ) ;\n EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_dtap_extraneous_data ) ;\n }","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":386974,"func":"static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,\n\t\t\t       struct v4l2_format *vf)\n{\n\tstruct usb_usbvision *usbvision = video_drvdata(file);\n\tint ret;\n\n\tret = vidioc_try_fmt_vid_cap(file, priv, vf);\n\tif (ret)\n\t\treturn ret;\n\n\t\/* stop io in case it is already in progress *\/\n\tif (usbvision->streaming == stream_on) {\n\t\tret = usbvision_stream_interrupt(usbvision);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\tusbvision_frames_free(usbvision);\n\tusbvision_empty_framequeues(usbvision);\n\n\tusbvision->cur_frame = NULL;\n\n\t\/* by now we are committed to the new data... *\/\n\tusbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height);\n\n\treturn 0;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":207057,"func":"u8* h264bsdAllocateDpbImage(dpbStorage_t *dpb)\n{\n\n\/* Variables *\/\n\n\/* Code *\/\n\n    ASSERT( !dpb->buffer[dpb->dpbSize].toBeDisplayed &&\n !IS_REFERENCE(dpb->buffer[dpb->dpbSize]) );\n    ASSERT(dpb->fullness <=  dpb->dpbSize);\n\n    dpb->currentOut = dpb->buffer + dpb->dpbSize;\n\n return(dpb->currentOut->data);\n\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":424744,"func":"int isFileInDir(char *dir, char *file){\n\tsize_t length, dirLength;\n\tchar *fullpath = NULL;\n\tFILE *f = NULL;\n\tint foundFile = 0;\n\n\tdirLength = strlen(dir);\n\t\/* Constuct 'full' path *\/\n\tif (dir[dirLength-1] == DIR_SEPARATOR) {\n\t\t\/* remove trailing '\/' *\/\n\t\tdir[dirLength-1] = '\\0';\n\t\tdirLength--;\n\t}\n\n\tlength = dirLength + strlen(file) + 2; \/* 2= '\/' + null char *\/\n\tfullpath = malloc(length);\n\tif (NULL != fullpath) {\n\t\tstrcpy(fullpath, dir);\n\t\tfullpath[dirLength] = DIR_SEPARATOR;\n\t\tstrcpy(fullpath+dirLength+1, file);\n\n\t\t\/* See if file exists - use fopen() for portability *\/\n\t\tf = fopen(fullpath, \"rb\");\n\t\tif (NULL != f) {\n\t\t\tfoundFile = 1;\n\t\t\tfclose(f);\n\t\t}\n\t\tfree(fullpath);\n\t}\n\treturn foundFile;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":203250,"func":"void AudioContext::disposeOutputs(AudioNode& node)\n{\n    ASSERT(isGraphOwner());\n    ASSERT(isMainThread());\n    for (unsigned i = 0; i < node.numberOfOutputs(); ++i)\n        node.output(i)->dispose();\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":467317,"func":"TEST(QueryProjectionTest, IdExclusionWithExclusionProjectionDoesNotPreserveId) {\n    auto proj = createProjection(\"{}\", \"{_id: 0, a: 0}\");\n    ASSERT_FALSE(proj.isFieldRetainedExactly(\"_id\"));\n    ASSERT_TRUE(proj.isFieldRetainedExactly(\"b\"));\n    ASSERT_FALSE(proj.isFieldRetainedExactly(\"a\"));\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":26046,"func":"int mime_hdr_length_get ( MIMEHdrImpl * mh ) {\n unsigned int length , index ;\n MIMEFieldBlockImpl * fblock ;\n MIMEField * field ;\n length = 2 ;\n for ( fblock = & ( mh -> m_first_fblock ) ;\n fblock != nullptr ;\n fblock = fblock -> m_next ) {\n for ( index = 0 ;\n index < fblock -> m_freetop ;\n index ++ ) {\n field = & ( fblock -> m_field_slots [ index ] ) ;\n if ( field -> is_live ( ) ) {\n length += mime_field_length_get ( field ) ;\n }\n }\n }\n return length ;\n }","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":282929,"func":"const SSL_CIPHER *ssl3_get_cipher(unsigned int u)\n{\n    if (u < SSL3_NUM_CIPHERS)\n        return (&(ssl3_ciphers[SSL3_NUM_CIPHERS - 1 - u]));\n    else\n        return (NULL);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":520557,"func":"bool Arg_comparator::set_cmp_func_datetime()\n{\n  THD *thd= current_thd;\n  m_compare_collation= &my_charset_numeric;\n  func= is_owner_equal_func() ? &Arg_comparator::compare_e_datetime :\n                                &Arg_comparator::compare_datetime;\n  a= cache_converted_constant(thd, a, &a_cache, compare_type_handler());\n  b= cache_converted_constant(thd, b, &b_cache, compare_type_handler());\n  return false;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":163216,"func":"void ATSParser::Program::signalDiscontinuity(\n DiscontinuityType type, const sp<AMessage> &extra) {\n int64_t mediaTimeUs;\n if ((type & DISCONTINUITY_TIME)\n && extra != NULL\n && extra->findInt64(\n IStreamListener::kKeyMediaTimeUs, &mediaTimeUs)) {\n        mFirstPTSValid = false;\n }\n\n for (size_t i = 0; i < mStreams.size(); ++i) {\n        mStreams.editValueAt(i)->signalDiscontinuity(type, extra);\n }\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":403550,"func":"int __init early_acpi_boot_init(void)\n{\n\t\/*\n\t * If acpi_disabled, bail out\n\t *\/\n\tif (acpi_disabled)\n\t\treturn 1;\n\n\t\/*\n\t * Process the Multiple APIC Description Table (MADT), if present\n\t *\/\n\tearly_acpi_process_madt();\n\n\t\/*\n\t * Hardware-reduced ACPI mode initialization:\n\t *\/\n\tacpi_reduced_hw_init();\n\n\treturn 0;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":170035,"func":"reassemble_files_name(const char *certfile, const char *keyfile)\n{\n    char *ret;\n\n    if (keyfile != NULL) {\n        if (asprintf(&ret, \"FILE:%s,%s\", certfile, keyfile) < 0)\n            return NULL;\n    } else {\n        if (asprintf(&ret, \"FILE:%s\", certfile) < 0)\n            return NULL;\n    }\n    return ret;\n}\n","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":156314,"func":"dump_config_as_events() {\n    g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash_as_event, NULL);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":144667,"func":"static struct sock *ping_get_idx(struct seq_file *seq, loff_t pos)\n{\n\tstruct sock *sk = ping_get_first(seq, 0);\n\n\tif (sk)\n\t\twhile (pos && (sk = ping_get_next(seq, sk)) != NULL)\n\t\t\t--pos;\n\treturn pos ? NULL : sk;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":168571,"func":"void RenderViewImpl::OnDisableScrollbarsForSmallWindows(\n    const gfx::Size& disable_scrollbar_size_limit) {\n  disable_scrollbars_size_limit_ = disable_scrollbar_size_limit;\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":60508,"func":"int dir_size(const std::string& path)\n{\n\tstd::vector<std::string> files, dirs;\n\tget_files_in_dir(path, &files, &dirs, ENTIRE_FILE_PATH);\n\n\tint res = 0;\n\n\tBOOST_FOREACH(const std::string& file_path, files)\n\t{\n\t\tres += file_size(file_path);\n\t}\n\n\tBOOST_FOREACH(const std::string& dir_path, dirs)\n\t{\n\t\t\/\/ FIXME: this could result in infinite recursion with symlinks!!\n\t\tres += dir_size(dir_path);\n\t}\n\n\treturn res;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":474209,"func":"static void __attribute__((destructor)) libcryptsetup_exit(void)\n{\n\tcrypt_token_unload_external_all(NULL);\n\n\tcrypt_backend_destroy();\n\tcrypt_random_exit();\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":271218,"func":"static int ext2_unfreeze(struct super_block *sb)\n{\n\t\/* Just write sb to clear EXT2_VALID_FS flag *\/\n\text2_write_super(sb);\n\n\treturn 0;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":189265,"func":"TopSitesImpl::ThumbnailEvent TopSitesImpl::SetPageThumbnailImpl(\n    const GURL& url,\n    const gfx::Image& thumbnail,\n    const ThumbnailScore& score) {\n  DCHECK(thread_checker_.CalledOnValidThread());\n\n  if (!loaded_) {\n    return THUMBNAIL_FAILURE;\n  }\n\n  bool add_temp_thumbnail = false;\n  if (!IsKnownURL(url)) {\n    if (IsNonForcedFull()) {\n      return THUMBNAIL_TOPSITES_FULL;\n    }\n\n    add_temp_thumbnail = true;\n  }\n\n  if (!can_add_url_to_history_.Run(url))\n    return THUMBNAIL_FAILURE;  \/\/ It's not a real webpage.\n\n  scoped_refptr<base::RefCountedBytes> thumbnail_data;\n  if (!EncodeBitmap(thumbnail, &thumbnail_data))\n    return THUMBNAIL_FAILURE;\n\n  if (add_temp_thumbnail) {\n    RemoveTemporaryThumbnailByURL(url);\n    AddTemporaryThumbnail(url, thumbnail_data.get(), score);\n    return THUMBNAIL_ADDED_TEMP;\n  }\n\n  bool success = SetPageThumbnailEncoded(url, thumbnail_data.get(), score);\n  return success ? THUMBNAIL_ADDED_REGULAR : THUMBNAIL_KEPT_EXISTING;\n}\n","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":170719,"func":"void ImageLoader::timerFired(Timer<ImageLoader>*)\n{\n    m_element->deref();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":206313,"func":"static int dummydomain(i_ctx_t * i_ctx_p, ref *space, float *ptr)\n{\n    return 0;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":375220,"func":"_copyClosePortalStmt(const ClosePortalStmt *from)\n{\n\tClosePortalStmt *newnode = makeNode(ClosePortalStmt);\n\n\tCOPY_STRING_FIELD(portalname);\n\n\treturn newnode;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":241158,"func":"void ImageLoader::updatedHasPendingEvent() {\n  bool wasProtected = m_elementIsProtected;\n  m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent;\n  if (wasProtected == m_elementIsProtected)\n    return;\n\n  if (m_elementIsProtected) {\n    if (m_derefElementTimer.isActive())\n      m_derefElementTimer.stop();\n    else\n      m_keepAlive = m_element;\n  } else {\n    DCHECK(!m_derefElementTimer.isActive());\n    m_derefElementTimer.startOneShot(0, BLINK_FROM_HERE);\n  }\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":367081,"func":"static inline int security_inode_alloc(struct inode *inode)\n{\n\treturn 0;\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":405707,"func":"WandExport ClipPathUnits DrawGetClipUnits(const DrawingWand *wand)\n{\n  assert(wand != (const DrawingWand *) NULL);\n  assert(wand->signature == MagickWandSignature);\n  if (wand->debug != MagickFalse)\n    (void) LogMagickEvent(WandEvent,GetMagickModule(),\"%s\",wand->name);\n  return(CurrentContext->clip_units);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":164308,"func":"void Browser::FileSelectedWithExtraInfo(\n    const ui::SelectedFileInfo& file_info,\n    int index,\n    void* params) {\n  profile_->set_last_selected_directory(file_info.file_path.DirName());\n\n  const FilePath& path = file_info.local_path;\n  GURL file_url = net::FilePathToFileURL(path);\n\n#if defined(OS_CHROMEOS)\n  drive::util::ModifyDriveFileResourceUrl(profile_, path, &file_url);\n#endif\n\n  if (file_url.is_empty())\n    return;\n\n  OpenURL(OpenURLParams(\n      file_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED,\n      false));\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":403338,"func":"PHP_MINFO_FUNCTION(openssl)\n{\n\tphp_info_print_table_start();\n\tphp_info_print_table_row(2, \"OpenSSL support\", \"enabled\");\n\tphp_info_print_table_row(2, \"OpenSSL Library Version\", SSLeay_version(SSLEAY_VERSION));\n\tphp_info_print_table_row(2, \"OpenSSL Header Version\", OPENSSL_VERSION_TEXT);\n\tphp_info_print_table_row(2, \"Openssl default config\", default_ssl_conf_filename);\n\tphp_info_print_table_end();\n\tDISPLAY_INI_ENTRIES();\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":238089,"func":"void DiskCacheBackendTest::BackendInvalidRankings2() {\n  ASSERT_TRUE(CopyTestCache(\"bad_rankings\"));\n  DisableFirstCleanup();\n  InitCache();\n\n  disk_cache::Entry *entry1, *entry2;\n  EXPECT_NE(net::OK, OpenEntry(\"the first key\", &entry1));\n  ASSERT_THAT(OpenEntry(\"some other key\", &entry2), IsOk());\n  entry2->Close();\n\n  DisableIntegrityCheck();\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":65782,"func":"Status InferenceContext::Max(DimensionHandle first, DimensionOrConstant second,\n                             DimensionHandle* out) {\n  const int64_t first_value = Value(first);\n  const int64_t second_value = Value(second);\n  if (first_value == kUnknownDim || second_value == kUnknownDim) {\n    *out = UnknownDim();\n  } else {\n    if (first_value >= second_value) {\n      *out = first;\n    } else {\n      *out = MakeDim(second);\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":345108,"func":"PHP_FUNCTION(fnmatch)\n{\n\tchar *pattern, *filename;\n\tint pattern_len, filename_len;\n\tlong flags = 0;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"ss|l\", &pattern, &pattern_len, &filename, &filename_len, &flags) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (filename_len >= MAXPATHLEN) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Filename exceeds the maximum allowed length of %d characters\", MAXPATHLEN);\n\t\tRETURN_FALSE;\n\t}\n\tif (pattern_len >= MAXPATHLEN) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Pattern exceeds the maximum allowed length of %d characters\", MAXPATHLEN);\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_BOOL( ! fnmatch( pattern, filename, flags ));\n}","target":1,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":401038,"func":"inline SegmentBuilder::SegmentBuilder(\n    BuilderArena* arena, SegmentId id, const word* ptr, SegmentWordCount size,\n    ReadLimiter* readLimiter)\n    : SegmentReader(arena, id, ptr, size, readLimiter),\n      \/\/ const_cast is safe here because the member won't ever be dereferenced because it appears\n      \/\/ to point to the end of the segment anyway.\n      pos(const_cast<word*>(ptr + size)), readOnly(true) {}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":252266,"func":"cc::ScrollTree& PropertyTreeManager::GetScrollTree() {\n  return property_trees_.scroll_tree;\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":382502,"func":"FlushErrorState(void)\n{\n\t\/*\n\t * Reset stack to empty.  The only case where it would be more than one\n\t * deep is if we serviced an error that interrupted construction of\n\t * another message.  We assume control escaped out of that message\n\t * construction and won't ever go back.\n\t *\/\n\terrordata_stack_depth = -1;\n\trecursion_depth = 0;\n\t\/* Delete all data in ErrorContext *\/\n\tMemoryContextResetAndDeleteChildren(ErrorContext);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":512060,"func":"unbind_function_def (name)\n     const char *name;\n{\n  BUCKET_CONTENTS *elt;\n  FUNCTION_DEF *funcdef;\n\n  elt = hash_remove (name, shell_function_defs, 0);\n\n  if (elt == 0)\n    return -1;\n\n  funcdef = (FUNCTION_DEF *)elt->data;\n  if (funcdef)\n    dispose_function_def (funcdef);\n\n  free (elt->key);\n  free (elt);\n\n  return 0;  \n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":53518,"func":"xmlDumpNotationDecl(xmlBufferPtr buf, xmlNotationPtr nota) {\n    if ((buf == NULL) || (nota == NULL))\n        return;\n    xmlBufferWriteChar(buf, \"<!NOTATION \");\n    xmlBufferWriteCHAR(buf, nota->name);\n    if (nota->PublicID != NULL) {\n\txmlBufferWriteChar(buf, \" PUBLIC \");\n\txmlBufferWriteQuotedString(buf, nota->PublicID);\n\tif (nota->SystemID != NULL) {\n\t    xmlBufferWriteChar(buf, \" \");\n\t    xmlBufferWriteQuotedString(buf, nota->SystemID);\n\t}\n    } else {\n\txmlBufferWriteChar(buf, \" SYSTEM \");\n\txmlBufferWriteQuotedString(buf, nota->SystemID);\n    }\n    xmlBufferWriteChar(buf, \" >\\n\");\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":249408,"func":"bool WebPage::defersLoading() const\n{\n    return d->m_page->defersLoading();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":190938,"func":"bool HasEnvironmentVariable(const std::string& variable_name) {\n  return HasEnvironmentVariable16(UTF8ToUTF16(variable_name));\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":220923,"func":"cleanup (pam_handle_t *pamh UNUSED, void *data, int err UNUSED)\n{\n\tfree (data);\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":232730,"func":"bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(\n    const GURL& url,\n    const GURL& first_party_for_cookies) const {\n  if (!cookie_settings_.get())\n    return false;\n\n  bool reading_cookie_allowed = cookie_settings_->IsReadingCookieAllowed(\n      url, first_party_for_cookies);\n  bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed(\n      url, first_party_for_cookies);\n  bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed);\n  return privacy_mode;\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":373286,"func":"static struct socket_address *tls_socket_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)\n{\n\tstruct tls_context *tls = talloc_get_type(sock->private_data, struct tls_context);\n\treturn socket_get_peer_addr(tls->socket, mem_ctx);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":171378,"func":"DOMWindow* LocalDOMWindow::open(ExecutionContext* executionContext,\n                                LocalDOMWindow* current_window,\n                                LocalDOMWindow* entered_window,\n                                const String& url,\n                                const AtomicString& target,\n                                const String& features,\n                                ExceptionState& exception_state) {\n  if (!BindingSecurity::ShouldAllowAccessTo(entered_window, this,\n                                            exception_state)) {\n    UseCounter::Count(executionContext, WebFeature::kWindowOpenRealmMismatch);\n    return nullptr;\n  }\n  DCHECK(!target.IsNull());\n  return open(url, target, features, current_window, entered_window,\n              exception_state);\n}\n","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":8854,"func":"__be32 ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)\n{\n\tstatic u32 ip6_proxy_idents_hashrnd __read_mostly;\n\tstruct in6_addr buf[2];\n\tstruct in6_addr *addrs;\n\tu32 id;\n\n\taddrs = skb_header_pointer(skb,\n\t\t\t\t   skb_network_offset(skb) +\n\t\t\t\t   offsetof(struct ipv6hdr, saddr),\n\t\t\t\t   sizeof(buf), buf);\n\tif (!addrs)\n\t\treturn 0;\n\n\tnet_get_random_once(&ip6_proxy_idents_hashrnd,\n\t\t\t    sizeof(ip6_proxy_idents_hashrnd));\n\n\tid = __ipv6_select_ident(net, ip6_proxy_idents_hashrnd,\n\t\t\t\t &addrs[1], &addrs[0]);\n\treturn htonl(id);\n}","target":1,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":89836,"func":"static Variant HHVM_METHOD(SimpleXMLElement, __unset, const Variant& name) {\n  auto data = Native::data<SimpleXMLElement>(this_);\n  sxe_prop_dim_delete(data, name, true, false);\n  return init_null();\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":465189,"func":"int kvm_vcpu_map(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map)\n{\n\treturn __kvm_map_gfn(kvm_vcpu_memslots(vcpu), gfn, map,\n\t\tNULL, false);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":283829,"func":"void AutocompleteResult::CopyFrom(const AutocompleteResult& rhs) {\n  if (this == &rhs)\n    return;\n\n  matches_ = rhs.matches_;\n  default_match_ = (rhs.default_match_ == rhs.end()) ?\n      end() : (begin() + (rhs.default_match_ - rhs.begin()));\n\n  alternate_nav_url_ = rhs.alternate_nav_url_;\n}\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":384930,"func":"static PHP_FUNCTION(xmlwriter_end_dtd)\n{\n\tphp_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTD);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":474260,"func":"int crypt_resume_by_keyfile_offset(struct crypt_device *cd,\n\t\t\t\t   const char *name,\n\t\t\t\t   int keyslot,\n\t\t\t\t   const char *keyfile,\n\t\t\t\t   size_t keyfile_size,\n\t\t\t\t   size_t keyfile_offset)\n{\n\treturn crypt_resume_by_keyfile_device_offset(cd, name, keyslot,\n\t\t\t\t      keyfile, keyfile_size, keyfile_offset);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":363273,"func":"pango_ot_info_list_scripts (PangoOTInfo      *info,\n\t\t\t    PangoOTTableType  table_type)\n{\n  hb_ot_layout_table_type_t tt = get_hb_table_type (table_type);\n  PangoOTTag *result;\n  unsigned int count, i;\n\n  count = hb_ot_layout_table_get_script_count (info->layout, tt);\n\n  result = g_new (PangoOTTag, count + 1);\n\n  for (i = 0; i < count; i++)\n    result[i] = hb_ot_layout_table_get_script_tag (info->layout, tt, i);\n\n  result[i] = 0;\n\n  return result;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":118211,"func":"static void test_map_wrapping(void)\n{\n    uc_engine *uc;\n\n    OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));\n    uc_assert_err(UC_ERR_ARG, uc_mem_map(uc, (~0ll - 0x4000) & ~0xfff, 0x8000,\n                                         UC_PROT_ALL));\n\n    OK(uc_close(uc));\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":515880,"func":"get_number(NCURSES_CONST char *cap, const char *env)\n{\n    int result = tgetnum(cap);\n    char *value = env ? getenv(env) : 0;\n    if (value != 0 && *value != 0) {\n\tchar *next = 0;\n\tlong check = strtol(value, &next, 10);\n\tif (check > 0 && *next == '\\0')\n\t    result = (int) check;\n    }\n    return result;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":61623,"func":"flatpak_dir_new (GFile *path, gboolean user)\n{\n  \/* We are only interested on extra data for system-wide installations, in which\n     case we use _new_full() directly, so here we just call it passing NULL *\/\n  return flatpak_dir_new_full (path, user, NULL);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":321502,"func":"void av_parser_close(AVCodecParserContext *s)\n\n{\n\n    if(s){\n\n        if (s->parser->parser_close) {\n\n            ff_lock_avcodec(NULL);\n\n            s->parser->parser_close(s);\n\n            ff_unlock_avcodec();\n\n        }\n\n        av_free(s->priv_data);\n\n        av_free(s);\n\n    }\n\n}\n","target":1,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":243755,"func":"normalizePublicId(XML_Char *publicId)\n{\n  XML_Char *p = publicId;\n  XML_Char *s;\n  for (s = publicId; *s; s++) {\n    switch (*s) {\n    case 0x20:\n    case 0xD:\n    case 0xA:\n      if (p != publicId && p[-1] != 0x20)\n        *p++ = 0x20;\n      break;\n    default:\n      *p++ = *s;\n    }\n  }\n  if (p != publicId && p[-1] == 0x20)\n    --p;\n  *p = XML_T('\\0');\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":95687,"func":"\n      static double mp_complex_pow_vs(_cimg_math_parser& mp) {\n        const double *ptr1 = &_mp_arg(2) + 1, val2 = _mp_arg(3);\n        double *ptrd = &_mp_arg(1) + 1;\n        _mp_complex_pow(ptr1[0],ptr1[1],val2,0,ptrd);\n        return cimg::type<double>::nan();","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":443003,"func":"static bool svm_rdtscp_supported(void)\n{\n\treturn boot_cpu_has(X86_FEATURE_RDTSCP);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":125436,"func":"static void dce80_transform_destroy(struct transform **xfm)\n{\n\tkfree(TO_DCE_TRANSFORM(*xfm));\n\t*xfm = NULL;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":161020,"func":"static MonoMethodSignature*\nmethod_builder_to_signature (MonoImage *image, MonoReflectionMethodBuilder *method) {\n\tMonoMethodSignature *sig;\n\n\tsig = parameters_to_signature (image, method->parameters);\n\tsig->hasthis = method->attrs & METHOD_ATTRIBUTE_STATIC? 0: 1;\n\tsig->ret = method->rtype? mono_reflection_type_get_handle ((MonoReflectionType*)method->rtype): &mono_defaults.void_class->byval_arg;\n\tsig->generic_param_count = method->generic_params ? mono_array_length (method->generic_params) : 0;\n\treturn sig;","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":91572,"func":"static inline int __sctp_sstate(const struct sock *sk, sctp_sock_state_t state)\n{\n\treturn sk->sk_state == state;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":158181,"func":"unparse_filesystem_flags (const char           *path,\n                          FlatpakFilesystemMode mode)\n{\n  g_autoptr(GString) s = g_string_new (\"\");\n  const char *p;\n\n  for (p = path; *p != 0; p++)\n    {\n      if (*p == ':')\n        g_string_append (s, \"\\\\:\");\n      else if (*p == '\\\\')\n        g_string_append (s, \"\\\\\\\\\");\n      else\n        g_string_append_c (s, *p);\n    }\n\n  switch (mode)\n    {\n    case FLATPAK_FILESYSTEM_MODE_READ_ONLY:\n      g_string_append (s, \":ro\");\n      break;\n\n    case FLATPAK_FILESYSTEM_MODE_CREATE:\n      g_string_append (s, \":create\");\n      break;\n\n    case FLATPAK_FILESYSTEM_MODE_READ_WRITE:\n      break;\n\n    case FLATPAK_FILESYSTEM_MODE_NONE:\n      g_string_insert_c (s, 0, '!');\n      break;\n\n    default:\n      g_warning (\"Unexpected filesystem mode %d\", mode);\n      break;\n    }\n\n  return g_string_free (g_steal_pointer (&s), FALSE);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":99115,"func":"rdp_disconnect(void)\n{\n\tlogger(Protocol, Debug, \"%s()\", __func__);\n\tsec_disconnect();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":411306,"func":"    \/\/! Compute the absolute value of each pixel value \\newinstance.\n    CImg<Tfloat> get_abs() const {\n      return CImg<Tfloat>(*this,false).abs();","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":334069,"func":"struct omap_sdrc_s *omap_sdrc_init(MemoryRegion *sysmem,\n\n                                   hwaddr base)\n\n{\n\n    struct omap_sdrc_s *s = (struct omap_sdrc_s *)\n\n            g_malloc0(sizeof(struct omap_sdrc_s));\n\n\n\n    omap_sdrc_reset(s);\n\n\n\n    memory_region_init_io(&s->iomem, NULL, &omap_sdrc_ops, s, \"omap.sdrc\", 0x1000);\n\n    memory_region_add_subregion(sysmem, base, &s->iomem);\n\n\n\n    return s;\n\n}\n","target":1,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":264509,"func":"PJ_DEF(pj_status_t) pj_stun_msg_create_response(pj_pool_t *pool,\n\t\t\t\t\t\tconst pj_stun_msg *req_msg,\n\t\t\t\t\t\tunsigned err_code,\n\t\t\t\t\t\tconst pj_str_t *err_msg,\n\t\t\t\t\t\tpj_stun_msg **p_response)\n{\n    unsigned msg_type = req_msg->hdr.type;\n    pj_stun_msg *response = NULL;\n    pj_status_t status;\n\n    PJ_ASSERT_RETURN(pool && p_response, PJ_EINVAL);\n\n    PJ_ASSERT_RETURN(PJ_STUN_IS_REQUEST(msg_type), \n\t\t     PJNATH_EINSTUNMSGTYPE);\n\n    \/* Create response or error response *\/\n    if (err_code)\n\tmsg_type |= PJ_STUN_ERROR_RESPONSE_BIT;\n    else\n\tmsg_type |= PJ_STUN_SUCCESS_RESPONSE_BIT;\n\n    status = pj_stun_msg_create(pool, msg_type, req_msg->hdr.magic, \n\t\t\t\treq_msg->hdr.tsx_id, &response);\n    if (status != PJ_SUCCESS) {\n\treturn status;\n    }\n\n    \/* Add error code attribute *\/\n    if (err_code) {\n\tstatus = pj_stun_msg_add_errcode_attr(pool, response, \n\t\t\t\t\t      err_code, err_msg);\n\tif (status != PJ_SUCCESS) {\n\t    return status;\n\t}\n    }\n\n    *p_response = response;\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":245408,"func":"  ImageResourceInfoImpl(ImageResource* resource) : resource_(resource) {\n    DCHECK(resource_);\n  }\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":168290,"func":"void FillMiscNavigationParams(const CommonNavigationParams& common_params,\n                              const CommitNavigationParams& commit_params,\n                              blink::WebNavigationParams* navigation_params) {\n  navigation_params->navigation_timings = BuildNavigationTimings(\n      common_params.navigation_start, commit_params.navigation_timing,\n      common_params.input_start);\n\n  navigation_params->is_user_activated =\n      commit_params.was_activated == WasActivatedOption::kYes;\n\n  if (commit_params.origin_to_commit) {\n    navigation_params->origin_to_commit =\n        commit_params.origin_to_commit.value();\n  }\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":299263,"func":"void b43_dma_rx(struct b43_dmaring *ring)\n{\n\tconst struct b43_dma_ops *ops = ring->ops;\n\tint slot, current_slot;\n\tint used_slots = 0;\n\n\tB43_WARN_ON(ring->tx);\n\tcurrent_slot = ops->get_current_rxslot(ring);\n\tB43_WARN_ON(!(current_slot >= 0 && current_slot < ring->nr_slots));\n\n\tslot = ring->current_slot;\n\tfor (; slot != current_slot; slot = next_slot(ring, slot)) {\n\t\tdma_rx(ring, &slot);\n\t\tupdate_max_used_slots(ring, ++used_slots);\n\t}\n\tops->set_current_rxslot(ring, slot);\n\tring->current_slot = slot;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":16493,"func":"int TSMimeHdrFieldValuesCount ( TSMBuffer bufp , TSMLoc hdr , TSMLoc field ) {\n sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;\n sdk_assert ( ( sdk_sanity_check_mime_hdr_handle ( hdr ) == TS_SUCCESS ) || ( sdk_sanity_check_http_hdr_handle ( hdr ) == TS_SUCCESS ) ) ;\n sdk_assert ( sdk_sanity_check_field_handle ( field , hdr ) == TS_SUCCESS ) ;\n MIMEFieldSDKHandle * handle = ( MIMEFieldSDKHandle * ) field ;\n return mime_field_value_get_comma_val_count ( handle -> field_ptr ) ;\n }","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":306664,"func":"ServerItem::ServerItem(const BonjourRecord &br) : QTreeWidgetItem(QTreeWidgetItem::UserType) {\n\tsiParent = NULL;\n\tbParent = false;\n\titType = LANType;\n\tqsName = br.serviceName;\n\tqsBonjourHost = qsName;\n\tbrRecord = br;\n\tusPort = 0;\n\tbCA = false;\n\n\tinit();\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":447590,"func":"blobGetFilename(const blob *b)\n{\n    assert(b != NULL);\n#ifdef CL_DEBUG\n    assert(b->magic == BLOBCLASS);\n#endif\n\n    return b->name;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":486326,"func":"OFCondition DcmSCP::receiveDIMSEDataset(T_ASC_PresentationContextID *presID,\n                                        DcmDataset **dataObject)\n{\n  if (m_assoc == NULL)\n    return DIMSE_ILLEGALASSOCIATION;\n\n  OFCondition cond;\n  \/* call the corresponding DIMSE function to receive the dataset *\/\n  if (m_cfg->getProgressNotificationMode())\n  {\n    cond = DIMSE_receiveDataSetInMemory(m_assoc, m_cfg->getDIMSEBlockingMode(), m_cfg->getDIMSETimeout(),\n                                        presID, dataObject, callbackRECEIVEProgress, this \/*callbackData*\/);\n  } else {\n    cond = DIMSE_receiveDataSetInMemory(m_assoc, m_cfg->getDIMSEBlockingMode(), m_cfg->getDIMSETimeout(),\n                                        presID, dataObject, NULL \/*callback*\/, NULL \/*callbackData*\/);\n  }\n\n  if (cond.good())\n  {\n    DCMNET_DEBUG(\"Received dataset on presentation context \" << OFstatic_cast(unsigned int, *presID));\n  } else {\n    OFString tempStr;\n    DCMNET_ERROR(\"Unable to receive dataset on presentation context \"\n      << OFstatic_cast(unsigned int, *presID) << \": \" << DimseCondition::dump(tempStr, cond));\n  }\n  return cond;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":166807,"func":"static void DestroyXMLTreeOrdered(XMLTreeInfo *xml_info)\n{\n  XMLTreeInfo\n    *node,\n    *ordered;\n\n  ordered=xml_info->ordered;\n  while(ordered != (XMLTreeInfo *) NULL)\n  {\n    node=ordered;\n    ordered=node->ordered;\n    node->ordered=(XMLTreeInfo *) NULL;\n    (void) DestroyXMLTree(node);\n  }\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":179665,"func":"device_drive_inhibit_polling_authorized_cb (Daemon *daemon,\n                                            Device *device,\n                                            DBusGMethodInvocation *context,\n                                            const gchar *action_id,\n                                            guint num_user_data,\n                                            gpointer *user_data_elements)\n{\n  gchar **options = user_data_elements[0];\n  Inhibitor *inhibitor;\n  guint n;\n\n  for (n = 0; options[n] != NULL; n++)\n    {\n      const char *option = options[n];\n      throw_error (context, ERROR_INVALID_OPTION, \"Unknown option %s\", option);\n      goto out;\n    }\n\n  inhibitor = inhibitor_new (context);\n\n  device->priv->polling_inhibitors = g_list_prepend (device->priv->polling_inhibitors, inhibitor);\n  g_signal_connect (inhibitor, \"disconnected\", G_CALLBACK (polling_inhibitor_disconnected_cb), device);\n\n  update_info (device);\n  drain_pending_changes (device, FALSE);\n  daemon_local_update_poller (device->priv->daemon);\n\n  dbus_g_method_return (context, inhibitor_get_cookie (inhibitor));\n\n out:\n  ;\n}\n","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":138127,"func":"static Jsi_RC NumberIsIntegerCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n    Jsi_Value **ret, Jsi_Func *funcPtr) {\n    return jsi_NumberIsFiniteCmd(interp, args, _this, ret, funcPtr, 2);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":80201,"func":"int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n    int ret, size;\n\n\n\n    size = RAW_PACKET_SIZE;\n\n\n\n    if (av_new_packet(pkt, size) < 0)\n\n        return AVERROR(ENOMEM);\n\n\n\n    pkt->pos= avio_tell(s->pb);\n\n    pkt->stream_index = 0;\n\n    ret = ffio_read_partial(s->pb, pkt->data, size);\n\n    if (ret < 0) {\n\n        av_free_packet(pkt);\n\n        return ret;\n\n    }\n\n    pkt->size = ret;\n\n    return ret;\n\n}\n","target":1,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":210354,"func":"inline const KURL& Location::Url() const {\n  const KURL& url = GetDocument()->Url();\n  if (!url.IsValid()) {\n    return BlankURL();\n  }\n\n  return url;\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":76028,"func":"R_API bool r_cmd_desc_remove(RCmd *cmd, RCmdDesc *cd) {\n\tr_return_val_if_fail (cmd && cd, false);\n\tif (cd->parent) {\n\t\tcmd_desc_unset_parent (cd);\n\t}\n\tcmd_desc_remove_from_ht_cmds (cmd, cd);\n\tcmd_desc_free (cd);\n\treturn true;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":206979,"func":"ui::ModalType PrintPreviewDialogDelegate::GetDialogModalType() const {\n  NOTREACHED();\n  return ui::MODAL_TYPE_WINDOW;\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":54317,"func":"static void close_and_free_request(struct wsgi_request *wsgi_req) {\n\n\t\/\/ close the connection with the client\n        if (!wsgi_req->fd_closed) {\n                \/\/ NOTE, if we close the socket before receiving eventually sent data, socket layer will send a RST\n                wsgi_req->socket->proto_close(wsgi_req);\n        }\n\n        if (wsgi_req->post_file) {\n                fclose(wsgi_req->post_file);\n        }\n\n        if (wsgi_req->post_read_buf) {\n                free(wsgi_req->post_read_buf);\n        }\n\n        if (wsgi_req->post_readline_buf) {\n                free(wsgi_req->post_readline_buf);\n        }\n\n        if (wsgi_req->proto_parser_buf) {\n                free(wsgi_req->proto_parser_buf);\n        }\n\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":267553,"func":"my_suspend_hook(my_bool suspend, void *data)\n{\n  struct my_hook_data *hook_data= (struct my_hook_data *)data;\n  if (suspend)\n  {\n    hook_data->orig_pvio= hook_data->orig_mysql->net.pvio;\n    hook_data->orig_mysql->net.pvio= hook_data->new_mysql->net.pvio;\n  }\n  else\n    hook_data->orig_mysql->net.pvio= hook_data->orig_pvio;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":102163,"func":"void mp_encode_lua_table_as_array(lua_State *L, mp_buf *buf, int level) {\n#if LUA_VERSION_NUM < 502\n    size_t len = lua_objlen(L,-1), j;\n#else\n    size_t len = lua_rawlen(L,-1), j;\n#endif\n\n    mp_encode_array(L,buf,len);\n    luaL_checkstack(L, 1, \"in function mp_encode_lua_table_as_array\");\n    for (j = 1; j <= len; j++) {\n        lua_pushnumber(L,j);\n        lua_gettable(L,-2);\n        mp_encode_lua_type(L,buf,level+1);\n    }\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":257662,"func":"static int32_t U_CALLCONV uprv_swapArray32 ( const UDataSwapper * ds , const void * inData , int32_t length , void * outData , UErrorCode * pErrorCode ) {\n const uint32_t * p ;\n uint32_t * q ;\n int32_t count ;\n uint32_t x ;\n if ( pErrorCode == NULL || U_FAILURE ( * pErrorCode ) ) {\n return 0 ;\n }\n if ( ds == NULL || inData == NULL || length < 0 || ( length & 3 ) != 0 || outData == NULL ) {\n * pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ;\n return 0 ;\n }\n p = ( const uint32_t * ) inData ;\n q = ( uint32_t * ) outData ;\n count = length \/ 4 ;\n while ( count > 0 ) {\n x = * p ++ ;\n * q ++ = ( uint32_t ) ( ( x << 24 ) | ( ( x << 8 ) & 0xff0000 ) | ( ( x >> 8 ) & 0xff00 ) | ( x >> 24 ) ) ;\n -- count ;\n }\n return length ;\n }","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":188545,"func":"_exsltDateParseTime (exsltDateValDatePtr dt, const xmlChar **str)\n{\n    const xmlChar *cur = *str;\n    unsigned int hour = 0; \/* use temp var in case str is not xs:time *\/\n    int ret = 0;\n\n    PARSE_2_DIGITS(hour, cur, VALID_HOUR, ret);\n    if (ret != 0)\n\treturn ret;\n\n    if (*cur != ':')\n\treturn 1;\n    cur++;\n\n    \/* the ':' insures this string is xs:time *\/\n    dt->hour = hour;\n\n    PARSE_2_DIGITS(dt->min, cur, VALID_MIN, ret);\n    if (ret != 0)\n\treturn ret;\n\n    if (*cur != ':')\n\treturn 1;\n    cur++;\n\n    PARSE_FLOAT(dt->sec, cur, ret);\n    if (ret != 0)\n\treturn ret;\n\n    if (!VALID_TIME(dt))\n\treturn 2;\n\n    *str = cur;\n\n#ifdef DEBUG_EXSLT_DATE\n    xsltGenericDebug(xsltGenericDebugContext,\n\t\t     \"Parsed time %02i:%02i:%02.f\\n\",\n\t\t     dt->hour, dt->min, dt->sec);\n#endif\n\n    return 0;\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":90153,"func":"int wcall_set_proxy(const char *host, int port)\n{\n\treturn msystem_set_proxy(host, port);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":83246,"func":"\nstatic struct io_sq_data *io_attach_sq_data(struct io_uring_params *p)\n{\n\tstruct io_ring_ctx *ctx_attach;\n\tstruct io_sq_data *sqd;\n\tstruct fd f;\n\n\tf = fdget(p->wq_fd);\n\tif (!f.file)\n\t\treturn ERR_PTR(-ENXIO);\n\tif (f.file->f_op != &io_uring_fops) {\n\t\tfdput(f);\n\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\tctx_attach = f.file->private_data;\n\tsqd = ctx_attach->sq_data;\n\tif (!sqd) {\n\t\tfdput(f);\n\t\treturn ERR_PTR(-EINVAL);\n\t}\n\tif (sqd->task_tgid != current->tgid) {\n\t\tfdput(f);\n\t\treturn ERR_PTR(-EPERM);\n\t}\n\n\trefcount_inc(&sqd->refs);\n\tfdput(f);\n\treturn sqd;","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":472848,"func":"static BlockAIOCB *scsi_block_dma_readv(int64_t offset,\n                                        QEMUIOVector *iov,\n                                        BlockCompletionFunc *cb, void *cb_opaque,\n                                        void *opaque)\n{\n    SCSIBlockReq *r = opaque;\n    return scsi_block_do_sgio(r, offset, iov,\n                              SG_DXFER_FROM_DEV, cb, cb_opaque);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":31559,"func":"static void unpack_3(const uint8_t b[3], uint16_t s[16])\n{\n    int i;\n\n    s[0] = (b[0] << 8) | b[1];\n\n    if (s[0] & 0x8000)\n        s[0] &= 0x7fff;\n    else\n        s[0] = ~s[0];\n\n    for (i = 1; i < 16; i++)\n        s[i] = s[0];\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":206598,"func":"  Ins_Goto_CodeRange( EXEC_OP_ FT_Int    aRange,\n                               FT_ULong  aIP )\n  {\n    TT_CodeRange*  range;\n\n\n    if ( aRange < 1 || aRange > 3 )\n    {\n      CUR.error = TT_Err_Bad_Argument;\n      return FAILURE;\n    }\n\n    range = &CUR.codeRangeTable[aRange - 1];\n\n    if ( range->base == NULL )     \/* invalid coderange *\/\n    {\n      CUR.error = TT_Err_Invalid_CodeRange;\n      return FAILURE;\n    }\n\n    \/* NOTE: Because the last instruction of a program may be a CALL *\/\n    \/*       which will return to the first byte *after* the code    *\/\n    \/*       range, we test for AIP <= Size, instead of AIP < Size.  *\/\n\n    if ( aIP > range->size )\n    {\n      CUR.error = TT_Err_Code_Overflow;\n      return FAILURE;\n    }\n\n    CUR.code     = range->base;\n    CUR.codeSize = range->size;\n    CUR.IP       = aIP;\n    CUR.curRange = aRange;\n\n    return SUCCESS;\n  }\n","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":445398,"func":"  bool createUpgradeFilterChain(absl::string_view, const Http::FilterChainFactory::UpgradeMap*,\n                                Http::FilterChainFactoryCallbacks&) override {\n    return false;\n  }","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":376649,"func":"void HEnvironment::PrintTo(StringStream* stream) {\n  for (int i = 0; i < length(); i++) {\n    if (i == 0) stream->Add(\"parameters\\n\");\n    if (i == parameter_count()) stream->Add(\"specials\\n\");\n    if (i == parameter_count() + specials_count()) stream->Add(\"locals\\n\");\n    if (i == parameter_count() + specials_count() + local_count()) {\n      stream->Add(\"expressions\\n\");\n    }\n    HValue* val = values_.at(i);\n    stream->Add(\"%d: \", i);\n    if (val != NULL) {\n      val->PrintNameTo(stream);\n    } else {\n      stream->Add(\"NULL\");\n    }\n    stream->Add(\"\\n\");\n  }\n  PrintF(\"\\n\");\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":204243,"func":"void GDataFileSystem::OnTransferCompleted(\n    const FileOperationCallback& callback,\n    GDataFileError error,\n    scoped_ptr<UploadFileInfo> upload_file_info) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n  DCHECK(upload_file_info.get());\n\n  if (error == GDATA_FILE_OK && upload_file_info->entry.get()) {\n    AddUploadedFile(UPLOAD_NEW_FILE,\n                    upload_file_info->gdata_path.DirName(),\n                    upload_file_info->entry.Pass(),\n                    upload_file_info->file_path,\n                    GDataCache::FILE_OPERATION_COPY,\n                    base::Bind(&OnAddUploadFileCompleted, callback, error));\n  } else if (!callback.is_null()) {\n    callback.Run(error);\n  }\n}\n","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":368203,"func":"cached_resolves_eq(cached_resolve_t *a, cached_resolve_t *b)\n{\n  \/* make this smarter one day? *\/\n  assert_resolve_ok(a); \/\/ Not b; b may be just a search.\n  return !strncmp(a->address, b->address, MAX_ADDRESSLEN);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":145132,"func":"TEST(DenseOpticalFlow_DIS, ReferenceAccuracy)\n{\n    Mat frame1, frame2, GT;\n    ASSERT_TRUE(readRubberWhale(frame1, frame2, GT));\n    int presets[] = {DISOpticalFlow::PRESET_ULTRAFAST, DISOpticalFlow::PRESET_FAST, DISOpticalFlow::PRESET_MEDIUM};\n    float target_RMSE[] = {0.86f, 0.74f, 0.49f};\n    cvtColor(frame1, frame1, COLOR_BGR2GRAY);\n    cvtColor(frame2, frame2, COLOR_BGR2GRAY);\n\n    Ptr<DenseOpticalFlow> algo;\n\n    \/\/ iterate over presets:\n    for (int i = 0; i < 3; i++)\n    {\n        Mat flow;\n        algo = DISOpticalFlow::create(presets[i]);\n        algo->calc(frame1, frame2, flow);\n        ASSERT_EQ(GT.rows, flow.rows);\n        ASSERT_EQ(GT.cols, flow.cols);\n        EXPECT_LE(calcRMSE(GT, flow), target_RMSE[i]);\n    }\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":198215,"func":"static uint32_t div_frac(uint32_t dividend, uint32_t divisor)\n{\n\tuint32_t quotient, remainder;\n\n\t\/* Don't try to replace with do_div(), this one calculates\n\t * \"(dividend << 32) \/ divisor\" *\/\n\t__asm__ ( \"divl %4\"\n\t\t  : \"=a\" (quotient), \"=d\" (remainder)\n\t\t  : \"0\" (0), \"1\" (dividend), \"r\" (divisor) );\n\treturn quotient;\n}\n","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":428578,"func":"g_file_unmount_mountable (GFile               *file,\n                          GMountUnmountFlags   flags,\n                          GCancellable        *cancellable,\n                          GAsyncReadyCallback  callback,\n                          gpointer             user_data)\n{\n  GFileIface *iface;\n\n  g_return_if_fail (G_IS_FILE (file));\n\n  iface = G_FILE_GET_IFACE (file);\n\n  if (iface->unmount_mountable == NULL)\n    {\n      g_task_report_new_error (file, callback, user_data,\n                               g_file_unmount_mountable_with_operation,\n                               G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,\n                               _(\"Operation not supported\"));\n      return;\n    }\n\n  (* iface->unmount_mountable) (file,\n                                flags,\n                                cancellable,\n                                callback,\n                                user_data);\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":149097,"func":"vhost_user_unlock_all_queue_pairs(struct virtio_net *dev)\n{\n\tunsigned int i = 0;\n\tunsigned int vq_num = 0;\n\n\twhile (vq_num < dev->nr_vring) {\n\t\tstruct vhost_virtqueue *vq = dev->virtqueue[i];\n\n\t\tif (vq) {\n\t\t\trte_spinlock_unlock(&vq->access_lock);\n\t\t\tvq_num++;\n\t\t}\n\t\ti++;\n\t}\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":272959,"func":"static int _epoll_close(oe_fd_t* epoll_)\n{\n    int ret = -1;\n    epoll_t* epoll = _cast_epoll(epoll_);\n    int retval = -1;\n\n    oe_errno = 0;\n\n    if (!epoll)\n        OE_RAISE_ERRNO(OE_EINVAL);\n\n    \/* Close the file descriptor on the host side. *\/\n    if (oe_syscall_epoll_close_ocall(&retval, epoll->host_fd) != OE_OK)\n        OE_RAISE_ERRNO(OE_EINVAL);\n\n    if (retval == -1)\n        OE_RAISE_ERRNO(oe_errno);\n\n    if (epoll->map)\n        oe_free(epoll->map);\n\n    oe_free(epoll);\n\n    ret = 0;\n\ndone:\n    return ret;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":245185,"func":"static bool IsDangerousHTTPEquiv(const String& value) {\n  String equiv = value.StripWhiteSpace();\n  return DeprecatedEqualIgnoringCase(equiv, \"refresh\") ||\n         DeprecatedEqualIgnoringCase(equiv, \"set-cookie\");\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":41007,"func":"init_method_ref(PyObject *self, _Py_Identifier *name,\n                PyObject **method_func, PyObject **method_self)\n{\n    PyObject *func, *func2;\n    int ret;\n\n    \/* *method_func and *method_self should be consistent.  All refcount decrements\n       should be occurred after setting *method_self and *method_func. *\/\n    ret = _PyObject_LookupAttrId(self, name, &func);\n    if (func == NULL) {\n        *method_self = NULL;\n        Py_CLEAR(*method_func);\n        return ret;\n    }\n\n    if (PyMethod_Check(func) && PyMethod_GET_SELF(func) == self) {\n        \/* Deconstruct a bound Python method *\/\n        func2 = PyMethod_GET_FUNCTION(func);\n        Py_INCREF(func2);\n        *method_self = self; \/* borrowed *\/\n        Py_XSETREF(*method_func, func2);\n        Py_DECREF(func);\n        return 0;\n    }\n    else {\n        *method_self = NULL;\n        Py_XSETREF(*method_func, func);\n        return 0;\n    }\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":521775,"func":"String *Field_short::val_str(String *val_buffer,\n\t\t\t     String *val_ptr __attribute__((unused)))\n{\n  ASSERT_COLUMN_MARKED_FOR_READ;\n  CHARSET_INFO *cs= &my_charset_numeric;\n  uint length;\n  uint mlength=MY_MAX(field_length+1,7*cs->mbmaxlen);\n  val_buffer->alloc(mlength);\n  char *to=(char*) val_buffer->ptr();\n  short j;\n  j=sint2korr(ptr);\n\n  if (unsigned_flag)\n    length=(uint) cs->cset->long10_to_str(cs, to, mlength, 10, \n\t\t\t\t\t  (long) (uint16) j);\n  else\n    length=(uint) cs->cset->long10_to_str(cs, to, mlength,-10, (long) j);\n  val_buffer->length(length);\n  if (zerofill)\n    prepend_zeros(val_buffer);\n  val_buffer->set_charset(cs);\n  return val_buffer;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":513290,"func":"CalcCost(s)\nregister char *s;\n{\n  ASSERT(display);\n  if (s)\n    {\n      StrCost = 0;\n      ospeed = D_dospeed;\n      tputs(s, 1, CountChars);\n      return StrCost;\n    }\n  else\n    return EXPENSIVE;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":223387,"func":"static int set_password(struct parsed_mount_info *parsed_info, const char *src)\n{\n\tchar *dst = parsed_info->password;\n\tunsigned int i = 0, j = 0;\n\n\twhile (src[i]) {\n\t\tif (src[i] == ',')\n\t\t\tdst[j++] = ',';\n\t\tdst[j++] = src[i++];\n\t\tif (j > sizeof(parsed_info->password)) {\n\t\t\tfprintf(stderr, \"Converted password too long!\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\t}\n\tdst[j] = '\\0';\n\tparsed_info->got_password = 1;\n\treturn 0;\n}\n","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":271996,"func":"nv_operator(cmdarg_T *cap)\n{\n    int\t    op_type;\n\n    op_type = get_op_type(cap->cmdchar, cap->nchar);\n#ifdef FEAT_JOB_CHANNEL\n    if (bt_prompt(curbuf) && op_is_change(op_type) && !prompt_curpos_editable())\n    {\n\tclearopbeep(cap->oap);\n\treturn;\n    }\n#endif\n\n    if (op_type == cap->oap->op_type)\t    \/\/ double operator works on lines\n\tnv_lineop(cap);\n    else if (!checkclearop(cap->oap))\n    {\n\tcap->oap->start = curwin->w_cursor;\n\tcap->oap->op_type = op_type;\n#ifdef FEAT_EVAL\n\tset_op_var(op_type);\n#endif\n    }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":281382,"func":"error::Error GLES2DecoderImpl::HandleDeleteProgram(\n    uint32_t immediate_data_size,\n    const volatile void* cmd_data) {\n  const volatile gles2::cmds::DeleteProgram& c =\n      *static_cast<const volatile gles2::cmds::DeleteProgram*>(cmd_data);\n  GLuint client_id = c.program;\n  if (client_id) {\n    Program* program = GetProgram(client_id);\n    if (program) {\n      if (!program->IsDeleted()) {\n        program_manager()->MarkAsDeleted(shader_manager(), program);\n      }\n    } else {\n      LOCAL_SET_GL_ERROR(\n          GL_INVALID_VALUE, \"glDeleteProgram\", \"unknown program\");\n    }\n  }\n  return error::kNoError;\n}\n","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":136204,"func":"COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,\n\t\t       struct compat_timex __user *, utp)\n{\n\tconst struct k_clock *kc = clockid_to_kclock(which_clock);\n\tstruct timex ktx;\n\tint err;\n\n\tif (!kc)\n\t\treturn -EINVAL;\n\tif (!kc->clock_adj)\n\t\treturn -EOPNOTSUPP;\n\n\terr = compat_get_timex(&ktx, utp);\n\tif (err)\n\t\treturn err;\n\n\terr = kc->clock_adj(which_clock, &ktx);\n\n\tif (err >= 0)\n\t\terr = compat_put_timex(utp, &ktx);\n\n\treturn err;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":279842,"func":"VaapiWrapper::LazyProfileInfos::LazyProfileInfos() {\n  static_assert(arraysize(supported_profiles_) == kCodecModeMax,\n                \"The array size of supported profile is incorrect.\");\n  scoped_ptr<VaapiWrapper> vaapi_wrapper(new VaapiWrapper());\n  if (!vaapi_wrapper->VaInitialize(base::Bind(&base::DoNothing)))\n    return;\n  for (size_t i = 0; i < kCodecModeMax; ++i) {\n    supported_profiles_[i] =\n        vaapi_wrapper->GetSupportedProfileInfosForCodecModeInternal(\n            static_cast<CodecMode>(i));\n  }\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":283957,"func":"bool DocumentLoader::MaybeCreateArchive() {\n  if (!IsArchiveMIMEType(response_.MimeType()))\n    return false;\n\n  DCHECK(main_resource_);\n  ArchiveResource* main_resource =\n      fetcher_->CreateArchive(main_resource_.Get());\n  if (!main_resource)\n    return false;\n  EnsureWriter(main_resource->MimeType(), main_resource->Url());\n  if (!frame_)\n    return false;\n\n  frame_->GetDocument()->EnforceSandboxFlags(\n      kSandboxAll &\n      ~(kSandboxPopups | kSandboxPropagatesToAuxiliaryBrowsingContexts));\n\n  RefPtr<SharedBuffer> data(main_resource->Data());\n  data->ForEachSegment(\n      [this](const char* segment, size_t segment_size, size_t segment_offset) {\n        CommitData(segment, segment_size);\n        return true;\n      });\n  return true;\n}\n","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":177102,"func":"void QuotaManager::DidInitialize(int64* temporary_quota_override,\n                                 int64* desired_available_space,\n                                 bool success) {\n  temporary_quota_override_ = *temporary_quota_override;\n  desired_available_space_ = *desired_available_space;\n  temporary_quota_initialized_ = true;\n  DidDatabaseWork(success);\n\n  histogram_timer_.Start(FROM_HERE,\n                         base::TimeDelta::FromMilliseconds(\n                             kReportHistogramInterval),\n                         this, &QuotaManager::ReportHistogram);\n\n  DCHECK(temporary_quota_initialized_);\n\n  for (UsageAndQuotaDispatcherTaskMap::iterator iter =\n           usage_and_quota_dispatchers_.begin();\n       iter != usage_and_quota_dispatchers_.end(); ++iter) {\n    if (iter->second->IsStartable())\n      iter->second->Start();\n  }\n\n  GetTemporaryGlobalQuota(\n      base::Bind(&QuotaManager::DidGetInitialTemporaryGlobalQuota,\n                 weak_factory_.GetWeakPtr()));\n}\n","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":61706,"func":"bittok2str_nosep(register const struct tok *lp, register const char *fmt,\n\t   register u_int v)\n{\n    return (bittok2str_internal(lp, fmt, v, \"\"));\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":17072,"func":"static void afx_class_init ( ObjectClass * klass , void * data ) {\n SysBusDeviceClass * k = SYS_BUS_DEVICE_CLASS ( klass ) ;\n k -> init = afx_init1 ;\n }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":333428,"func":"static void test_reconnect(void)\n\n{\n\n    gchar *path = g_strdup_printf(\"\/%s\/vhost-user\/reconnect\/subprocess\",\n\n                                  qtest_get_arch());\n\n    g_test_trap_subprocess(path, 0, 0);\n\n    g_test_trap_assert_passed();\n\n\n}","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":33602,"func":"static void ClearBounds(Image *image,RectangleInfo *bounds)\n{\n  ExceptionInfo\n    *exception;\n\n  ssize_t\n    y;\n\n  if (bounds->x < 0)\n    return;\n  if (image->matte == MagickFalse)\n    (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);\n  exception=(&image->exception);\n  for (y=0; y < (ssize_t) bounds->height; y++)\n  {\n    register ssize_t\n      x;\n\n    register PixelPacket\n      *magick_restrict q;\n\n    q=GetAuthenticPixels(image,bounds->x,bounds->y+y,bounds->width,1,exception);\n    if (q == (PixelPacket *) NULL)\n      break;\n    for (x=0; x < (ssize_t) bounds->width; x++)\n    {\n      q->opacity=(Quantum) TransparentOpacity;\n      q++;\n    }\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n  }\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":359638,"func":"connection_removed (NMExportedConnection *connection, gpointer user_data)\n{\n\tNMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (user_data);\n\n\tpriv->connections = g_slist_remove (priv->connections, connection);\n\tg_object_unref (connection);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":152724,"func":"decode_OFPAT_RAW_SET_MPLS_LABEL(ovs_be32 label,\n                                enum ofp_version ofp_version OVS_UNUSED,\n                                struct ofpbuf *out)\n{\n    ofpact_put_SET_MPLS_LABEL(out)->label = label;\n    return 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":282446,"func":"SWFInput_seek(SWFInput input, long offset, int whence)\n{\n\tinput->seek(input, offset, whence);\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":132104,"func":"SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)\n{\n\tstruct siginfo info;\n\n\tinfo.si_signo = sig;\n\tinfo.si_errno = 0;\n\tinfo.si_code = SI_USER;\n\tinfo.si_pid = task_tgid_vnr(current);\n\tinfo.si_uid = current_uid();\n\n\treturn kill_something_info(sig, &info, pid);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":445462,"func":"bool ListenerImpl::rejectCxOverGlobalLimit() {\n  \/\/ Enforce the global connection limit if necessary, immediately closing the accepted connection.\n  Runtime::Loader* runtime = Runtime::LoaderSingleton::getExisting();\n\n  if (runtime == nullptr) {\n    \/\/ The runtime singleton won't exist in most unit tests that do not need global downstream limit\n    \/\/ enforcement. Therefore, there is no need to enforce limits if the singleton doesn't exist.\n    \/\/ TODO(tonya11en): Revisit this once runtime is made globally available.\n    return false;\n  }\n\n  \/\/ If the connection limit is not set, don't limit the connections, but still track them.\n  \/\/ TODO(tonya11en): In integration tests, threadsafeSnapshot is necessary since the FakeUpstreams\n  \/\/ use a listener and do not run in a worker thread. In practice, this code path will always be\n  \/\/ run on a worker thread, but to prevent failed assertions in test environments, threadsafe\n  \/\/ snapshots must be used. This must be revisited.\n  const uint64_t global_cx_limit = runtime->threadsafeSnapshot()->getInteger(\n      GlobalMaxCxRuntimeKey, std::numeric_limits<uint64_t>::max());\n  return AcceptedSocketImpl::acceptedSocketCount() >= global_cx_limit;\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":359524,"func":"static unsigned long es_base(struct x86_emulate_ctxt *ctxt)\n{\n\treturn seg_base(ctxt, VCPU_SREG_ES);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":309327,"func":"void btsnoop_net_write(const void *data, size_t length) {\n#if (!defined(BT_NET_DEBUG) || (BT_NET_DEBUG != TRUE))\n return; \/\/ Disable using network sockets for security reasons\n#endif\n\n \n   pthread_mutex_lock(&client_socket_lock_);\n   if (client_socket_ != -1) {\n    if (TEMP_FAILURE_RETRY(send(client_socket_, data, length, 0)) == -1 && errno == ECONNRESET) {\n       safe_close_(&client_socket_);\n     }\n   }\n  pthread_mutex_unlock(&client_socket_lock_);\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":41262,"func":"static int proc_setattr(struct dentry *dentry, struct iattr *attr)\n{\n\tint error;\n\tstruct inode *inode = dentry->d_inode;\n\n\tif (attr->ia_valid & ATTR_MODE)\n\t\treturn -EPERM;\n\n\terror = inode_change_ok(inode, attr);\n\tif (!error)\n\t\terror = inode_setattr(inode, attr);\n\treturn error;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":328496,"func":"static void nfs_file_close(BlockDriverState *bs)\n\n{\n\n    NFSClient *client = bs->opaque;\n\n    nfs_client_close(client);\n\n    qemu_mutex_destroy(&client->mutex);\n\n}\n","target":1,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":35415,"func":"struct passwd *enc_untrusted_getpwuid(uid_t uid) {\n  MessageWriter input;\n  MessageReader output;\n  input.Push<uid_t>(uid);\n  const auto status = NonSystemCallDispatcher(\n      ::asylo::host_call::kGetPwUidHandler, &input, &output);\n  CheckStatusAndParamCount(status, output, \"enc_untrusted_getpwuid\", 1,\n                           \/*match_exact_params=*\/false);\n\n  int klinux_errno = output.next<int>();\n  if (output.size() == 1) {\n    errno = FromkLinuxErrorNumber(klinux_errno);\n    return nullptr;\n  }\n\n  \/\/ Store the struct passwd members in a static passwd_holder, and direct the\n  \/\/ pointers in global_passwd to those members.\n  static struct passwd_holder passwd_buffers;\n  if (!DeserializePasswd(&output, &passwd_buffers) ||\n      !PasswdHolderToPasswd(&passwd_buffers, &global_passwd)) {\n    errno = EFAULT;\n    return nullptr;\n  }\n\n  return &global_passwd;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":153408,"func":"int GetSequence_ex(const byte* input, word32* inOutIdx, int* len,\n                           word32 maxIdx, int check)\n{\n    return GetASNHeader_ex(input, ASN_SEQUENCE | ASN_CONSTRUCTED, inOutIdx, len,\n                        maxIdx, check);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":403203,"func":"node_new_cclass(void)\n{\n  Node* node = node_new();\n  CHECK_NULL_RETURN(node);\n\n  SET_NODE_TYPE(node, NODE_CCLASS);\n  initialize_cclass(CCLASS_(node));\n  return node;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":465685,"func":"static void fuse_rdc_reset(struct inode *inode)\n{\n\tstruct fuse_inode *fi = get_fuse_inode(inode);\n\n\tfi->rdc.cached = false;\n\tfi->rdc.version++;\n\tfi->rdc.size = 0;\n\tfi->rdc.pos = 0;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":177616,"func":"  void SetVerdict(DownloadProtectionService::DownloadCheckResult result) {\n    verdict_ = result;\n    CompleteDownload();\n  }\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":106234,"func":"    template<typename t>\n    CImg(const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c,\n         const std::initializer_list<t> values,\n\t const bool repeat_values=true):\n      _width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) {\n#define _cimg_constructor_cpp11(repeat_values) \\\n  auto it = values.begin(); \\\n  size_t siz = size(); \\\n  if (repeat_values) for (T *ptrd = _data; siz--; ) { \\\n    *(ptrd++) = (T)(*(it++)); if (it==values.end()) it = values.begin(); } \\\n  else { siz = std::min(siz,values.size()); for (T *ptrd = _data; siz--; ) *(ptrd++) = (T)(*(it++)); }\n      assign(size_x,size_y,size_z,size_c);\n      _cimg_constructor_cpp11(repeat_values);","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":79427,"func":"decode_codec_id(const unsigned char *codecId, size_t id_size)\n{\n\tunsigned i;\n\tunsigned long id = 0;\n\n\tfor (i = 0; i < id_size; i++) {\n\t\tid <<= 8;\n\t\tid += codecId[i];\n\t}\n\treturn (id);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":502344,"func":"static NTSTATUS pdb_samba_dsdb_enum_group_mapping(struct pdb_methods *m,\n\t\t\t\t\t   const struct dom_sid *sid,\n\t\t\t\t\t   enum lsa_SidType sid_name_use,\n\t\t\t\t\t   GROUP_MAP ***pp_rmap,\n\t\t\t\t\t   size_t *p_num_entries,\n\t\t\t\t\t   bool unix_only)\n{\n\treturn NT_STATUS_NOT_IMPLEMENTED;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":212888,"func":"void NavigationControllerImpl::Restore(\n    int selected_navigation,\n    RestoreType type,\n    std::vector<std::unique_ptr<NavigationEntry>>* entries) {\n  DCHECK(GetEntryCount() == 0 && !GetPendingEntry());\n  DCHECK(selected_navigation >= 0 &&\n         selected_navigation < static_cast<int>(entries->size()));\n\n  needs_reload_ = true;\n  entries_.reserve(entries->size());\n  for (auto& entry : *entries)\n    entries_.push_back(\n        NavigationEntryImpl::FromNavigationEntry(std::move(entry)));\n\n  entries->clear();\n\n  FinishRestore(selected_navigation, type);\n}\n","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":221142,"func":"void PrintJobWorker::Stop() {\n  thread_.Stop();\n}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":522438,"func":"  bool is_outside_computation_bounds() const\n  {\n    \/*\n       The top bound can go over the current partition. In this case,\n       the sum function has 0 values added to it.\n    *\/\n    if (at_partition_end && is_top_bound)\n      return true;\n    return false;\n  }","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":22296,"func":"void remove_tap_listener_actrace_calls ( void ) {\n remove_tap_listener ( & ( the_tapinfo_struct . actrace_dummy ) ) ;\n have_actrace_tap_listener = FALSE ;\n }","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":141122,"func":"static int do_i2c(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n{\n\tstruct cmd_tbl *c;\n\n#ifdef CONFIG_NEEDS_MANUAL_RELOC\n\ti2c_reloc();\n#endif\n\n\tif (argc < 2)\n\t\treturn CMD_RET_USAGE;\n\n\t\/* Strip off leading 'i2c' command argument *\/\n\targc--;\n\targv++;\n\n\tc = find_cmd_tbl(argv[0], &cmd_i2c_sub[0], ARRAY_SIZE(cmd_i2c_sub));\n\n\tif (c)\n\t\treturn c->cmd(cmdtp, flag, argc, argv);\n\telse\n\t\treturn CMD_RET_USAGE;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":162799,"func":"    void setFlowThread(RenderFlowThread* thread) { m_flowThread = thread; }\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":118275,"func":"f_byteidxcomp(typval_T *argvars, typval_T *rettv)\n{\n    byteidx(argvars, rettv, TRUE);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":183120,"func":"bool AccessibilityUIElement::isEqual(AccessibilityUIElement* otherElement)\n{\n    return m_element == otherElement->platformUIElement();\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":55998,"func":"static int specific_minor(int minor)\n{\n\tint r;\n\n\tif (minor >= (1 << MINORBITS))\n\t\treturn -EINVAL;\n\n\tidr_preload(GFP_KERNEL);\n\tspin_lock(&_minor_lock);\n\n\tr = idr_alloc(&_minor_idr, MINOR_ALLOCED, minor, minor + 1, GFP_NOWAIT);\n\n\tspin_unlock(&_minor_lock);\n\tidr_preload_end();\n\tif (r < 0)\n\t\treturn r == -ENOSPC ? -EBUSY : r;\n\treturn 0;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":231121,"func":"SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (SSL *ssl,\n                                                       unsigned char *data,\n                                                       int len, int *copy) {\n    return ctx->get_session_cb;\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":100712,"func":"static void perf_nesting(void)\n\n{\n\n    unsigned int i, maxcycles, maxnesting;\n\n    double duration;\n\n\n\n    maxcycles = 10000;\n\n    maxnesting = 1000;\n\n    Coroutine *root;\n\n\n\n    g_test_timer_start();\n\n    for (i = 0; i < maxcycles; i++) {\n\n        NestData nd = {\n\n            .n_enter  = 0,\n\n            .n_return = 0,\n\n            .max      = maxnesting,\n\n        };\n\n        root = qemu_coroutine_create(nest);\n\n        qemu_coroutine_enter(root, &nd);\n\n    }\n\n    duration = g_test_timer_elapsed();\n\n\n\n    g_test_message(\"Nesting %u iterations of %u depth each: %f s\\n\",\n\n        maxcycles, maxnesting, duration);\n\n}\n","target":1,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":449011,"func":"UTI_IPNetworkToHost(IPAddr *src, IPAddr *dest)\n{\n  dest->family = ntohs(src->family);\n  dest->_pad = 0;\n\n  switch (dest->family) {\n    case IPADDR_INET4:\n      dest->addr.in4 = ntohl(src->addr.in4);\n      break;\n    case IPADDR_INET6:\n      memcpy(dest->addr.in6, src->addr.in6, sizeof (dest->addr.in6));\n      break;\n    default:\n      dest->family = IPADDR_UNSPEC;\n  }\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":221138,"func":"MockDataReductionProxyConfig::~MockDataReductionProxyConfig() {\n}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":367577,"func":"static void cap_inode_post_setxattr(struct dentry *dentry, const char *name,\n\t\t\t\t    const void *value, size_t size, int flags)\n{\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":113391,"func":"bool MaybeRemoveControlInput(const string& old_input, NodeDef* node,\n                             GraphDef* graph, NodeMap* node_map) {\n  bool removed_input = false;\n  bool update_node_map = true;\n  const string old_input_ctrl_dep = AsControlDependency(NodeName(old_input));\n  for (int i = 0; i < node->input_size(); ++i) {\n    const string& input = node->input(i);\n    if (old_input_ctrl_dep == input) {\n      if (IsControlInput(input)) {\n        node->mutable_input()->SwapElements(i, node->input_size() - 1);\n        node->mutable_input()->RemoveLast();\n        removed_input = true;\n      } else {\n        \/\/ There is a non-control input from the same node.\n        \/\/ Don't remove the output from the NodeMap.\n        update_node_map = false;\n      }\n    }\n  }\n  if (update_node_map) {\n    node_map->RemoveOutput(NodeName(old_input), node->name());\n  }\n  return removed_input;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":132702,"func":"static void netbk_tx_err(struct xenvif *vif,\n\t\t\t struct xen_netif_tx_request *txp, RING_IDX end)\n{\n\tRING_IDX cons = vif->tx.req_cons;\n\n\tdo {\n\t\tmake_tx_response(vif, txp, XEN_NETIF_RSP_ERROR);\n\t\tif (cons >= end)\n\t\t\tbreak;\n\t\ttxp = RING_GET_REQUEST(&vif->tx, cons++);\n\t} while (1);\n\tvif->tx.req_cons = cons;\n\txen_netbk_check_rx_xenvif(vif);\n\txenvif_put(vif);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":33291,"func":"static void kvp_acquire_lock(int pool)\n{\n\tstruct flock fl = {F_WRLCK, SEEK_SET, 0, 0, 0};\n\tfl.l_pid = getpid();\n\n\tif (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) {\n\t\tsyslog(LOG_ERR, \"Failed to acquire the lock pool: %d\", pool);\n\t\texit(EXIT_FAILURE);\n\t}\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":151656,"func":"av_cold int ff_vp8_decode_free(AVCodecContext *avctx)\n{\n    VP8Context *s = avctx->priv_data;\n    int i;\n\n    if (!s)\n        return 0;\n\n    vp8_decode_flush_impl(avctx, 1);\n    for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++)\n        av_frame_free(&s->frames[i].tf.f);\n\n    return 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":319109,"func":"static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)\n\n{\n\n    DeviceClass *dc = DEVICE_CLASS(klass);\n\n\n\n    dc->vmsd = &sdhci_vmstate;\n\n    dc->props = sdhci_sysbus_properties;\n\n    dc->realize = sdhci_sysbus_realize;\n\n    dc->reset = sdhci_poweron_reset;\n\n\n\n\n\n\n}","target":1,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":116027,"func":"void show_browser(char *br) {\n   if (stristr(br, \"opera\"))\n      rsprintf(\"var browser = \\\"Opera\\\";\\n\");\n   else if (stristr(br, \"konqueror\"))\n      rsprintf(\"var browser = \\\"Konqueror\\\";\\n\");\n   else if (stristr(br, \"Safari\"))\n      rsprintf(\"var browser = \\\"Safari\\\";\\n\");\n   else if (stristr(br, \"MSIE\"))\n      rsprintf(\"var browser = \\\"MSIE\\\";\\n\");\n   else if (stristr(br, \"Mozilla\"))\n      rsprintf(\"var browser = \\\"Mozilla\\\";\\n\");\n   else\n      rsprintf(\"var browser = \\\"Other\\\";\\n\");\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":150704,"func":"static void br_multicast_mark_router(struct net_bridge *br,\n\t\t\t\t     struct net_bridge_port *port)\n{\n\tunsigned long now = jiffies;\n\n\tif (!port) {\n\t\tif (br->multicast_router == 1)\n\t\t\tmod_timer(&br->multicast_router_timer,\n\t\t\t\t  now + br->multicast_querier_interval);\n\t\treturn;\n\t}\n\n\tif (port->multicast_router != 1)\n\t\treturn;\n\n\tif (!hlist_unhashed(&port->rlist))\n\t\tgoto timer;\n\n\tbr_multicast_add_router(br, port);\n\ntimer:\n\tmod_timer(&port->multicast_router_timer,\n\t\t  now + br->multicast_querier_interval);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":260781,"func":"R_API ut64 r_bin_get_baddr(RBin *bin) {\n\tRBinObject *o = r_bin_cur_object (bin);\n\treturn binobj_get_baddr (o);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":144890,"func":"static void hns_xgmac_init(void *mac_drv)\n{\n\tstruct mac_driver *drv = (struct mac_driver *)mac_drv;\n\tstruct dsaf_device *dsaf_dev\n\t\t= (struct dsaf_device *)dev_get_drvdata(drv->dev);\n\tu32 port = drv->mac_id;\n\n\tdsaf_dev->misc_op->xge_srst(dsaf_dev, port, 0);\n\tmdelay(100);\n\tdsaf_dev->misc_op->xge_srst(dsaf_dev, port, 1);\n\n\tmdelay(100);\n\thns_xgmac_lf_rf_control_init(drv);\n\thns_xgmac_exc_irq_en(drv, 0);\n\n\thns_xgmac_pma_fec_enable(drv, 0x0, 0x0);\n\n\thns_xgmac_disable(mac_drv, MAC_COMM_MODE_RX_AND_TX);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":44446,"func":"static void attach_mnt(struct mount *mnt,\n\t\t\tstruct mount *parent,\n\t\t\tstruct mountpoint *mp)\n{\n\tmnt_set_mountpoint(parent, mp, mnt);\n\thlist_add_head_rcu(&mnt->mnt_hash, m_hash(&parent->mnt, mp->m_dentry));\n\tlist_add_tail(&mnt->mnt_child, &parent->mnt_mounts);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":418504,"func":"int RGWDeleteObj::verify_permission()\n{\n  if (s->iam_policy) {\n    auto r = s->iam_policy->eval(s->env, *s->auth.identity,\n\t\t\t\t s->object.instance.empty() ?\n\t\t\t\t rgw::IAM::s3DeleteObject :\n\t\t\t\t rgw::IAM::s3DeleteObjectVersion,\n\t\t\t\t ARN(s->bucket, s->object.name));\n    if (r == Effect::Allow)\n      return true;\n    else if (r == Effect::Deny)\n      return false;\n  }\n\n  if (!verify_bucket_permission_no_policy(s, RGW_PERM_WRITE)) {\n    return -EACCES;\n  }\n\n  if (s->bucket_info.mfa_enabled() &&\n      !s->object.instance.empty() &&\n      !s->mfa_verified) {\n    ldout(s->cct, 5) << \"NOTICE: object delete request with a versioned object, mfa auth not provided\" << dendl;\n    return -ERR_MFA_REQUIRED;\n  }\n\n  return 0;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":339803,"func":"static int op_to_movi(int op)\n\n{\n\n    switch (op_bits(op)) {\n\n    case 32:\n\n        return INDEX_op_movi_i32;\n\n#if TCG_TARGET_REG_BITS == 64\n\n    case 64:\n\n        return INDEX_op_movi_i64;\n\n#endif\n\n    default:\n\n        fprintf(stderr, \"op_to_movi: unexpected return value of \"\n\n                \"function op_bits.\\n\");\n\n        tcg_abort();\n\n    }\n\n}\n","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":410882,"func":"char *theme_format_expand_data(THEME_REC *theme, const char **format, theme_rm_col default_fg,\n                               theme_rm_col default_bg, theme_rm_col *save_last_fg,\n                               theme_rm_col *save_last_bg, int flags)\n{\n\treturn theme_format_expand_data_rec(theme, format, default_fg, default_bg, save_last_bg,\n\t                                    save_last_bg, flags, NULL);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":212253,"func":"UploadProgress HttpStreamParser::GetUploadProgress() const {\n  if (!request_->upload_data_stream)\n    return UploadProgress();\n\n  return UploadProgress(request_->upload_data_stream->position(),\n                        request_->upload_data_stream->size());\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":30943,"func":"static bool init_cpuset_if_needed ( struct cgroup_mount_point * mp , const char * path ) {\n if ( ! lxc_string_in_array ( \"cpuset\" , ( const char * * ) mp -> hierarchy -> subsystems ) ) return true ;\n if ( ! mp -> need_cpuset_init ) return true ;\n return ( do_init_cpuset_file ( mp , path , \"\/cpuset.cpus\" ) && do_init_cpuset_file ( mp , path , \"\/cpuset.mems\" ) ) ;\n }","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":411845,"func":"zzip_disk_feof (ZZIP_DISK_FILE* file)\n{\n    return ! file || ! file->avail;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":249166,"func":"_dbus_close_socket (int        fd,\n                    DBusError *error)\n{\n  _DBUS_ASSERT_ERROR_IS_CLEAR (error);\n\n again:\n  if (closesocket (fd) == SOCKET_ERROR)\n    {\n      DBUS_SOCKET_SET_ERRNO ();\n      \n      if (errno == EINTR)\n        goto again;\n        \n      dbus_set_error (error, _dbus_error_from_errno (errno),\n                      \"Could not close socket: socket=%d, , %s\",\n                      fd, _dbus_strerror_from_errno ());\n      return FALSE;\n    }\n  _dbus_verbose (\"_dbus_close_socket: socket=%d, \\n\", fd);\n\n  return TRUE;\n}\n","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":420516,"func":"tar_sparse_init (struct tar_sparse_file *file)\n{\n  memset (file, 0, sizeof *file);\n\n  if (!sparse_select_optab (file))\n    return false;\n\n  if (file->optab->init)\n    return file->optab->init (file);\n\n  return true;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":282700,"func":"void NewTabButton::OnPaint(gfx::Canvas* canvas) {\n  gfx::ImageSkia image =\n      GetImageForScale(ui::GetSupportedScaleFactor(canvas->image_scale()));\n  canvas->DrawImageInt(image, 0, height() - image.height());\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":396200,"func":"void do_item_remove(item *it) {\n    MEMCACHED_ITEM_REMOVE(ITEM_key(it), it->nkey, it->nbytes);\n    assert((it->it_flags & ITEM_SLABBED) == 0);\n    assert(it->refcount > 0);\n\n    if (refcount_decr(&it->refcount) == 0) {\n        item_free(it);\n    }\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":136034,"func":"void copyCast(const FromT* in, ToT* out, int num_elements) {\n  std::transform(in, in + num_elements, out,\n                 [](FromT a) { return static_cast<ToT>(a); });\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":316793,"func":"string16 ShellContentClient::GetLocalizedString(int message_id) const {\n  return string16();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":403615,"func":"static int nbd_negotiate_handle_list(NBDClient *client, uint32_t length)\n{\n    NBDExport *exp;\n\n    if (length) {\n        if (nbd_drop(client->ioc, length, NULL) < 0) {\n            return -EIO;\n        }\n        return nbd_negotiate_send_rep_err(client->ioc,\n                                          NBD_REP_ERR_INVALID, NBD_OPT_LIST,\n                                          \"OPT_LIST should not have length\");\n    }\n\n    \/* For each export, send a NBD_REP_SERVER reply. *\/\n    QTAILQ_FOREACH(exp, &exports, next) {\n        if (nbd_negotiate_send_rep_list(client->ioc, exp)) {\n            return -EINVAL;\n        }\n    }\n    \/* Finish with a NBD_REP_ACK. *\/\n    return nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, NBD_OPT_LIST);\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":24923,"func":"TEST ( IdlCompiler , PropertyValues ) {\n EXPECT_EQ ( 42 , test : : api : : idl_properties : : first ) ;\n EXPECT_EQ ( 42.1 , test : : api : : idl_properties : : second ) ;\n EXPECT_STREQ ( \"hello world\" , test : : api : : idl_properties : : third ) ;\n }","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":503555,"func":"sstring to_string(const event::schema_change::change_type t) {\n    switch (t) {\n    case event::schema_change::change_type::CREATED: return \"CREATED\";\n    case event::schema_change::change_type::UPDATED: return \"UPDATED\";\n    case event::schema_change::change_type::DROPPED: return \"DROPPED\";\n    }\n    assert(false && \"unreachable\");\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":262578,"func":"Filter::UpstreamRequest::~UpstreamRequest() {\n  if (span_ != nullptr) {\n    Tracing::HttpTracerUtility::finalizeUpstreamSpan(*span_, upstream_headers_.get(),\n                                                     upstream_trailers_.get(), stream_info_,\n                                                     Tracing::EgressConfig::get());\n  }\n\n  if (per_try_timeout_ != nullptr) {\n    \/\/ Allows for testing.\n    per_try_timeout_->disableTimer();\n  }\n  clearRequestEncoder();\n\n  stream_info_.setUpstreamTiming(upstream_timing_);\n  stream_info_.onRequestComplete();\n  \/\/ Prior to logging, refresh the byte size of the HeaderMaps.\n  \/\/ TODO(asraa): Remove this when entries in HeaderMap can no longer be modified by reference and\n  \/\/ HeaderMap holds an accurate internal byte size count.\n  if (upstream_headers_ != nullptr) {\n    upstream_headers_->refreshByteSize();\n  }\n  if (upstream_trailers_ != nullptr) {\n    upstream_trailers_->refreshByteSize();\n  }\n  for (const auto& upstream_log : parent_.config_.upstream_logs_) {\n    upstream_log->log(parent_.downstream_headers_, upstream_headers_.get(),\n                      upstream_trailers_.get(), stream_info_);\n  }\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":49841,"func":"char_idx2byte(char_u *str, size_t str_len, varnumber_T idx)\n{\n    varnumber_T nchar = idx;\n    size_t\tnbyte = 0;\n\n    if (nchar >= 0)\n    {\n\twhile (nchar > 0 && nbyte < str_len)\n\t{\n\t    nbyte += mb_ptr2len(str + nbyte);\n\t    --nchar;\n\t}\n    }\n    else\n    {\n\tnbyte = str_len;\n\twhile (nchar < 0 && nbyte > 0)\n\t{\n\t    --nbyte;\n\t    nbyte -= mb_head_off(str, str + nbyte);\n\t    ++nchar;\n\t}\n\tif (nchar < 0)\n\t    return -1;\n    }\n    return (long)nbyte;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":322402,"func":"static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {\n\n    const unsigned int index_a = qp + h->slice_alpha_c0_offset;\n\n    const int alpha = alpha_table[index_a];\n\n    const int beta  = beta_table[qp + h->slice_beta_offset];\n\n    if (alpha ==0 || beta == 0) return;\n\n\n\n    if( bS[0] < 4 ) {\n\n        int8_t tc[4];\n\n        tc[0] = tc0_table[index_a][bS[0]]+1;\n\n        tc[1] = tc0_table[index_a][bS[1]]+1;\n\n        tc[2] = tc0_table[index_a][bS[2]]+1;\n\n        tc[3] = tc0_table[index_a][bS[3]]+1;\n\n        h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);\n\n    } else {\n\n        h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);\n\n    }\n\n}\n","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":390662,"func":"PHP_FUNCTION(log10)\n{\n\tdouble num;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"d\", &num) == FAILURE) {\n\t\treturn;\n\t}\n\tRETURN_DOUBLE(log10(num));\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":95058,"func":"CLASS ~DCRaw()\n{\nfree(ifname);\nfree(ifname_display);\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":419225,"func":"server_client_detach(struct client *c, enum msgtype msgtype)\n{\n\tstruct session\t*s = c->session;\n\n\tif (s == NULL || (c->flags & CLIENT_DETACHING))\n\t\treturn;\n\n\tc->flags |= CLIENT_DETACHING;\n\tnotify_client(\"client-detached\", c);\n\tproc_send(c->peer, msgtype, -1, s->name, strlen(s->name) + 1);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":449653,"func":"HttpStateData::closeServer()\n{\n    debugs(11,5, HERE << \"closing HTTP server \" << serverConnection << \" this \" << this);\n\n    if (Comm::IsConnOpen(serverConnection)) {\n        fwd->unregister(serverConnection);\n        comm_remove_close_handler(serverConnection->fd, closeHandler);\n        closeHandler = NULL;\n        serverConnection->close();\n    }\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":522571,"func":"void ha_close_connection(THD* thd)\n{\n  plugin_foreach_with_mask(thd, closecon_handlerton,\n                           MYSQL_STORAGE_ENGINE_PLUGIN,\n                           PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":316698,"func":"bool HTMLCanvasElement::IsWebGL2Enabled() const {\n  Document& document = GetDocument();\n  LocalFrame* frame = document.GetFrame();\n  if (!frame)\n    return false;\n  Settings* settings = frame->GetSettings();\n  return settings && settings->GetWebGL2Enabled();\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":377197,"func":"static void coroutine_fn bdrv_aio_discard_co_entry(void *opaque)\n{\n    BlockDriverAIOCBCoroutine *acb = opaque;\n    BlockDriverState *bs = acb->common.bs;\n\n    acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors);\n    acb->bh = qemu_bh_new(bdrv_co_em_bh, acb);\n    qemu_bh_schedule(acb->bh);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":143042,"func":"\nstatic int nl80211_set_cqm_rssi(struct genl_info *info,\n\t\t\t\ts32 threshold, u32 hysteresis)\n{\n\tstruct cfg80211_registered_device *rdev = info->user_ptr[0];\n\tstruct wireless_dev *wdev;\n\tstruct net_device *dev = info->user_ptr[1];\n\n\tif (threshold > 0)\n\t\treturn -EINVAL;\n\n\twdev = dev->ieee80211_ptr;\n\n\tif (!rdev->ops->set_cqm_rssi_config)\n\t\treturn -EOPNOTSUPP;\n\n\tif (wdev->iftype != NL80211_IFTYPE_STATION &&\n\t    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)\n\t\treturn -EOPNOTSUPP;\n\n\treturn rdev->ops->set_cqm_rssi_config(wdev->wiphy, dev,\n\t\t\t\t\t      threshold, hysteresis);","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":298026,"func":"static void gdImageVLine(gdImagePtr im, int x, int y1, int y2, int col)\n{\n  if (im->thick > 1) {\n    int thickhalf = im->thick >> 1;\n    gdImageFilledRectangle(im, x - thickhalf, y1, x + im->thick - thickhalf - 1, y2, col);\n  } else {\n    if (y2 < y1) {\n      int t = y1;\n      y1 = y2;\n      y2 = t;\n    }\n\n    for (;y1 <= y2; y1++) {\n      gdImageSetPixel(im, x, y1, col);\n    }\n  }\n  return;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":119068,"func":"static void CL_OldGame(void)\n{\n\tif(cl_oldGameSet)\n\t{\n\t\t\/\/ change back to previous fs_game\n\t\tcl_oldGameSet = qfalse;\n\t\tCvar_Set2(\"fs_game\", cl_oldGame, qtrue);\n\t\tFS_ConditionalRestart(clc.checksumFeed, qfalse);\n\t}\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":477003,"func":"void isis_notif_reject_adjacency(const struct isis_circuit *circuit,\n\t\t\t\t const char *reason, const char *raw_pdu,\n\t\t\t\t size_t raw_pdu_len)\n{\n\tconst char *xpath = \"\/frr-isisd:rejected-adjacency\";\n\tstruct list *arguments = yang_data_list_new();\n\tchar xpath_arg[XPATH_MAXLEN];\n\tstruct yang_data *data;\n\tstruct isis_area *area = circuit->area;\n\n\tnotif_prep_instance_hdr(xpath, area, \"default\", arguments);\n\tnotif_prepr_iface_hdr(xpath, circuit, arguments);\n\tsnprintf(xpath_arg, sizeof(xpath_arg), \"%s\/reason\", xpath);\n\tdata = yang_data_new_string(xpath_arg, reason);\n\tlistnode_add(arguments, data);\n\tsnprintf(xpath_arg, sizeof(xpath_arg), \"%s\/raw-pdu\", xpath);\n\tdata = yang_data_new_binary(xpath_arg, raw_pdu, raw_pdu_len);\n\tlistnode_add(arguments, data);\n\n\thook_call(isis_hook_reject_adjacency, circuit, raw_pdu, raw_pdu_len);\n\n\tnb_notification_send(xpath, arguments);\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":417942,"func":"int RGWSetRequestPayment::verify_permission()\n{\n  return verify_bucket_owner_or_policy(s, rgw::IAM::s3PutBucketRequestPayment);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":203840,"func":"void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) {\n  CompositorDependencies* compositor_deps = this;\n  is_scroll_animator_enabled_ = params->web_preferences.enable_scroll_animator;\n  RenderViewImpl::Create(compositor_deps, std::move(params),\n                         RenderWidget::ShowCallback());\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":301970,"func":"is_wc_option(optnam)\nconst char *optnam;\n{\n\tint k = 0;\n\twhile (wc_options[k].wc_name) {\n\t\tif (strcmp(wc_options[k].wc_name, optnam) == 0)\n\t\t\treturn TRUE;\n\t\tk++;\n\t}\n\treturn FALSE;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":121574,"func":"static struct mount *next_mnt(struct mount *p, struct mount *root)\n{\n\tstruct list_head *next = p->mnt_mounts.next;\n\tif (next == &p->mnt_mounts) {\n\t\twhile (1) {\n\t\t\tif (p == root)\n\t\t\t\treturn NULL;\n\t\t\tnext = p->mnt_child.next;\n\t\t\tif (next != &p->mnt_parent->mnt_mounts)\n\t\t\t\tbreak;\n\t\t\tp = p->mnt_parent;\n\t\t}\n\t}\n\treturn list_entry(next, struct mount, mnt_child);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":246997,"func":"void ChromeContentBrowserClient::AddNewCertificate(\n    net::URLRequest* request,\n    net::X509Certificate* cert,\n    int render_process_id,\n    int render_view_id) {\n  new SSLAddCertHandler(request, cert, render_process_id, render_view_id);\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":406568,"func":"  table_map not_null_tables() const { return (*ref)->not_null_tables(); }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":480130,"func":"strendswith(const char *str, const char *suffix)\n{\n\tsize_t slen = strlen(str);\n\tsize_t suffixlen = strlen(suffix);\n\tsize_t offset;\n\n\tif (slen == 0 || suffixlen == 0 || suffixlen > slen)\n\t\treturn false;\n\n\toffset = slen - suffixlen;\n\treturn strneq(&str[offset], suffix, suffixlen);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":508455,"func":"int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)\n{\n    return (X509_STORE_set_default_paths(ctx->cert_store));\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":142819,"func":"virConnectDomainEventDeregisterAny(virConnectPtr conn,\n                                   int callbackID)\n{\n    VIR_DEBUG(\"conn=%p, callbackID=%d\", conn, callbackID);\n\n    virResetLastError();\n\n    virCheckConnectReturn(conn, -1);\n    virCheckNonNegativeArgGoto(callbackID, error);\n\n    if (conn->driver && conn->driver->connectDomainEventDeregisterAny) {\n        int ret;\n        ret = conn->driver->connectDomainEventDeregisterAny(conn, callbackID);\n        if (ret < 0)\n            goto error;\n        return ret;\n    }\n\n    virReportUnsupportedError();\n error:\n    virDispatchError(conn);\n    return -1;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":153623,"func":"msg_home_replace_hl(char_u *fname)\n{\n    msg_home_replace_attr(fname, HL_ATTR(HLF_D));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":106934,"func":"void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, unsigned int size)\n{\n\tu8 *ptr = NULL;\n\n\tif (k >= SKF_NET_OFF)\n\t\tptr = skb_network_header(skb) + k - SKF_NET_OFF;\n\telse if (k >= SKF_LL_OFF)\n\t\tptr = skb_mac_header(skb) + k - SKF_LL_OFF;\n\n\tif (ptr >= skb->head && ptr + size <= skb_tail_pointer(skb))\n\t\treturn ptr;\n\n\treturn NULL;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":329015,"func":"static float get_band_cost_ZERO_mips(struct AACEncContext *s,\n\n                                     PutBitContext *pb, const float *in,\n\n                                     const float *scaled, int size, int scale_idx,\n\n                                     int cb, const float lambda, const float uplim,\n\n                                     int *bits)\n\n{\n\n    int i;\n\n    float cost = 0;\n\n\n\n    for (i = 0; i < size; i += 4) {\n\n        cost += in[i  ] * in[i  ];\n\n        cost += in[i+1] * in[i+1];\n\n        cost += in[i+2] * in[i+2];\n\n        cost += in[i+3] * in[i+3];\n\n    }\n\n    if (bits)\n\n        *bits = 0;\n\n    return cost * lambda;\n\n}\n","target":1,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":168540,"func":"static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv b)\n\n{\n\n    TCGv_i64 tmp64 = tcg_temp_new_i64();\n\n\n\n    tcg_gen_extu_i32_i64(tmp64, b);\n\n    dead_tmp(b);\n\n    tcg_gen_shli_i64(tmp64, tmp64, 32);\n\n    tcg_gen_add_i64(a, tmp64, a);\n\n\n\n    tcg_temp_free_i64(tmp64);\n\n    return a;\n\n}\n","target":1,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":521151,"func":"Item_func_regex::fix_length_and_dec()\n{\n  if (Item_bool_func::fix_length_and_dec() ||\n      agg_arg_charsets_for_comparison(cmp_collation, args, 2))\n    return TRUE;\n\n  re.init(cmp_collation.collation, 0);\n  re.fix_owner(this, args[0], args[1]);\n  return FALSE;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":498998,"func":"static const char *reg_name_for_access(RzAnalysisOp *op, RzAnalysisVarAccessType type) {\n\tif (type == RZ_ANALYSIS_VAR_ACCESS_TYPE_WRITE) {\n\t\tif (op->dst && op->dst->reg) {\n\t\t\treturn op->dst->reg->name;\n\t\t}\n\t} else {\n\t\tif (op->src[0] && op->src[0]->reg) {\n\t\t\treturn op->src[0]->reg->name;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":376672,"func":"void HInferRepresentation::InferBasedOnUses(HValue* value) {\n  Representation r = value->representation();\n  if (r.IsSpecialization() || value->HasNoUses()) return;\n  ASSERT(value->CheckFlag(HValue::kFlexibleRepresentation));\n  Representation new_rep = TryChange(value);\n  if (!new_rep.IsNone()) {\n    if (!value->representation().Equals(new_rep)) {\n      if (FLAG_trace_representation) {\n        PrintF(\"Changing #%d representation %s -> %s based on uses\\n\",\n               value->id(),\n               r.Mnemonic(),\n               new_rep.Mnemonic());\n      }\n      value->ChangeRepresentation(new_rep);\n      AddDependantsToWorklist(value);\n    }\n  }\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":379046,"func":"\nPHPAPI void php_info_print_box_end(void) \/* {{{ *\/\n{\n\tif (!sapi_module.phpinfo_as_text) {\n\t\tphp_info_print(\"<\/td><\/tr>\\n\");\n\t}\n\tphp_info_print_table_end();","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":122923,"func":"\n    inline void getrs(char &TRANS, int &N, float *lapA, int *IPIV, float *lapB, int &INFO) {\n      int one = 1;\n      sgetrs_(&TRANS,&N,&one,lapA,&N,IPIV,lapB,&N,&INFO);","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":189936,"func":"void RenderViewHostImpl::DragTargetDragOver(\n    const gfx::Point& client_pt,\n    const gfx::Point& screen_pt,\n    WebDragOperationsMask operations_allowed,\n    int key_modifiers) {\n  Send(new DragMsg_TargetDragOver(GetRoutingID(), client_pt, screen_pt,\n                                  operations_allowed, key_modifiers));\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":257777,"func":"static VALUE join_der ( VALUE enumerable ) {\n VALUE str = rb_str_new ( 0 , 0 ) ;\n rb_block_call ( enumerable , rb_intern ( \"each\" ) , 0 , 0 , join_der_i , str ) ;\n return str ;\n }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":309261,"func":"DownloadProtectionService::RegisterClientDownloadRequestCallback(\n    const ClientDownloadRequestCallback& callback) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  return client_download_request_callbacks_.Add(callback);\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":389525,"func":"loop_info(\n\tsockaddr_u *srcadr,\n\tendpt *inter,\n\tstruct req_pkt *inpkt\n\t)\n{\n\tstruct info_loop *li;\n\tl_fp ltmp;\n\n\tli = (struct info_loop *)prepare_pkt(srcadr, inter, inpkt,\n\t    sizeof(struct info_loop));\n\n\tDTOLFP(last_offset, <mp);\n\tHTONL_FP(<mp, &li->last_offset);\n\tDTOLFP(drift_comp * 1e6, <mp);\n\tHTONL_FP(<mp, &li->drift_comp);\n\tli->compliance = htonl((u_int32)(tc_counter));\n\tli->watchdog_timer = htonl((u_int32)(current_time - sys_epoch));\n\n\t(void) more_pkt();\n\tflush_pkt();\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":90896,"func":"TfLiteRegistration* Register_MATRIX_DIAG() {\n  static TfLiteRegistration r = {nullptr, nullptr, matrix_diag::Prepare,\n                                 matrix_diag::Eval};\n  return &r;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":165751,"func":"LayoutUnit RenderBox::computeReplacedLogicalHeight() const\n{\n    return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":162184,"func":"in_any_exception_block (MonoMethodHeader *header, guint offset)\n{\n\tint i;\n\tMonoExceptionClause *clause;\n\n\tfor (i = 0; i < header->num_clauses; ++i) {\n\t\tclause = &header->clauses [i];\n\t\tif (MONO_OFFSET_IN_HANDLER (clause, offset))\n\t\t\treturn TRUE;\n\t\tif (MONO_OFFSET_IN_FILTER (clause, offset))\n\t\t\treturn TRUE;\n\t}\n\treturn FALSE;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":126496,"func":"uint64_t ahotDefault() {\n  return RuntimeOption::RepoAuthoritative ? 4 << 20 : 0;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":61276,"func":"static int perf_event_period(struct perf_event *event, u64 __user *arg)\n{\n\tu64 value;\n\n\tif (!is_sampling_event(event))\n\t\treturn -EINVAL;\n\n\tif (copy_from_user(&value, arg, sizeof(value)))\n\t\treturn -EFAULT;\n\n\tif (!value)\n\t\treturn -EINVAL;\n\n\tif (event->attr.freq && value > sysctl_perf_event_sample_rate)\n\t\treturn -EINVAL;\n\n\tevent_function_call(event, __perf_event_period, &value);\n\n\treturn 0;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":519235,"func":"Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,\n                     uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,\n                     enum utype unireg_check_arg,\n                     const LEX_CSTRING *field_name_arg)\n  : Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,\n          unireg_check_arg, field_name_arg),\n    bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),\n    bytes_in_rec(len_arg \/ 8)\n{\n  DBUG_ENTER(\"Field_bit::Field_bit\");\n  DBUG_PRINT(\"enter\", (\"ptr_arg: %p, null_ptr_arg: %p, len_arg: %u, bit_len: %u, bytes_in_rec: %u\",\n                       ptr_arg, null_ptr_arg, len_arg, bit_len, bytes_in_rec));\n  flags|= UNSIGNED_FLAG;\n  \/*\n    Ensure that Field::eq() can distinguish between two different bit fields.\n    (two bit fields that are not null, may have same ptr and null_ptr)\n  *\/\n  if (!null_ptr_arg)\n    null_bit= bit_ofs_arg;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":345979,"func":"void recv_additional_file_list(int f)\n{\n\tstruct file_list *flist;\n\tint ndx = read_ndx(f);\n\tif (ndx == NDX_FLIST_EOF) {\n\t\tflist_eof = 1;\n\t\tif (DEBUG_GTE(FLIST, 3))\n\t\t\trprintf(FINFO, \"[%s] flist_eof=1\\n\", who_am_i());\n\t\tchange_local_filter_dir(NULL, 0, 0);\n\t} else {\n\t\tndx = NDX_FLIST_OFFSET - ndx;\n\t\tif (ndx < 0 || ndx >= dir_flist->used) {\n\t\t\tndx = NDX_FLIST_OFFSET - ndx;\n\t\t\trprintf(FERROR,\n\t\t\t\t\"[%s] Invalid dir index: %d (%d - %d)\\n\",\n\t\t\t\twho_am_i(), ndx, NDX_FLIST_OFFSET,\n\t\t\t\tNDX_FLIST_OFFSET - dir_flist->used + 1);\n\t\t\texit_cleanup(RERR_PROTOCOL);\n\t\t}\n\t\tif (DEBUG_GTE(FLIST, 3)) {\n\t\t\trprintf(FINFO, \"[%s] receiving flist for dir %d\\n\",\n\t\t\t\twho_am_i(), ndx);\n\t\t}\n\t\tflist = recv_file_list(f);\n\t\tflist->parent_ndx = ndx;\n\t}\n}","target":1,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":388046,"func":"stop_all_conversations (GdmSession *self)\n{\n        stop_all_other_conversations (self, NULL, TRUE);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":224097,"func":"void WebGLRenderingContextBase::DestroyContext() {\n  if (!GetDrawingBuffer())\n    return;\n\n  extensions_util_.reset();\n\n  WTF::RepeatingClosure null_closure;\n  WTF::RepeatingFunction<void(const char*, int32_t)> null_function;\n  GetDrawingBuffer()->ContextProvider()->SetLostContextCallback(\n      std::move(null_closure));\n  GetDrawingBuffer()->ContextProvider()->SetErrorMessageCallback(\n      std::move(null_function));\n\n  DCHECK(GetDrawingBuffer());\n  drawing_buffer_->BeginDestruction();\n  drawing_buffer_ = nullptr;\n}\n","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":365228,"func":"rb_str_resize(str, len)\n    VALUE str;\n    long len;\n{\n    if (len < 0) {\n\trb_raise(rb_eArgError, \"negative string size (or size too big)\");\n    }\n\n    rb_str_modify(str);\n    if (len != RSTRING(str)->len) {\n\tif (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {\n\t    REALLOC_N(RSTRING(str)->ptr, char, len+1);\n\t    if (!FL_TEST(str, STR_NOCAPA)) {\n\t\tRSTRING(str)->aux.capa = len;\n\t    }\n\t}\n\tRSTRING(str)->len = len;\n\tRSTRING(str)->ptr[len] = '\\0';\t\/* sentinel *\/\n    }\n    return str;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":47400,"func":"GF_ESD *gf_isom_get_esd(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex)\n{\n\tGF_ESD *esd;\n\tGF_Err e;\n\te = GetESD(movie->moov, gf_isom_get_track_id(movie, trackNumber), StreamDescriptionIndex, &esd);\n\tif (e && (e!= GF_ISOM_INVALID_MEDIA)) {\n\t\tmovie->LastError = e;\n\t\tif (esd) gf_odf_desc_del((GF_Descriptor *)esd);\n\t\treturn NULL;\n\t}\n\n\treturn esd;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":422959,"func":"static void tcp_push(struct sock *sk, int flags, int mss_now,\n\t\t     int nonagle, int size_goal)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *skb;\n\n\tif (!tcp_send_head(sk))\n\t\treturn;\n\n\tskb = tcp_write_queue_tail(sk);\n\tif (!(flags & MSG_MORE) || forced_push(tp))\n\t\ttcp_mark_push(tp, skb);\n\n\ttcp_mark_urg(tp, flags);\n\n\tif (tcp_should_autocork(sk, skb, size_goal)) {\n\n\t\t\/* avoid atomic op if TSQ_THROTTLED bit is already set *\/\n\t\tif (!test_bit(TSQ_THROTTLED, &tp->tsq_flags)) {\n\t\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAUTOCORKING);\n\t\t\tset_bit(TSQ_THROTTLED, &tp->tsq_flags);\n\t\t}\n\t\t\/* It is possible TX completion already happened\n\t\t * before we set TSQ_THROTTLED.\n\t\t *\/\n\t\tif (atomic_read(&sk->sk_wmem_alloc) > skb->truesize)\n\t\t\treturn;\n\t}\n\n\tif (flags & MSG_MORE)\n\t\tnonagle = TCP_NAGLE_CORK;\n\n\t__tcp_push_pending_frames(sk, mss_now, nonagle);\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":356112,"func":"static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)\n{\n\tstruct inode *inode = old_dentry->d_inode;\n\tint ret;\n\n\t\/*\n\t * No ordinary (disk based) filesystem counts links as inodes;\n\t * but each new link needs a new dentry, pinning lowmem, and\n\t * tmpfs dentries cannot be pruned until they are unlinked.\n\t *\/\n\tret = shmem_reserve_inode(inode->i_sb);\n\tif (ret)\n\t\tgoto out;\n\n\tdir->i_size += BOGO_DIRENT_SIZE;\n\tinode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;\n\tinc_nlink(inode);\n\tatomic_inc(&inode->i_count);\t\/* New dentry reference *\/\n\tdget(dentry);\t\t\/* Extra pinning count for the created dentry *\/\n\td_instantiate(dentry, inode);\nout:\n\treturn ret;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":62817,"func":"void rds_for_each_conn_info(struct socket *sock, unsigned int len,\n\t\t\t  struct rds_info_iterator *iter,\n\t\t\t  struct rds_info_lengths *lens,\n\t\t\t  int (*visitor)(struct rds_connection *, void *),\n\t\t\t  u64 *buffer,\n\t\t\t  size_t item_len)\n{\n\tstruct hlist_head *head;\n\tstruct rds_connection *conn;\n\tsize_t i;\n\n\trcu_read_lock();\n\n\tlens->nr = 0;\n\tlens->each = item_len;\n\n\tfor (i = 0, head = rds_conn_hash; i < ARRAY_SIZE(rds_conn_hash);\n\t     i++, head++) {\n\t\thlist_for_each_entry_rcu(conn, head, c_hash_node) {\n\n\t\t\t\/* XXX no c_lock usage.. *\/\n\t\t\tif (!visitor(conn, buffer))\n\t\t\t\tcontinue;\n\n\t\t\t\/* We copy as much as we can fit in the buffer,\n\t\t\t * but we count all items so that the caller\n\t\t\t * can resize the buffer. *\/\n\t\t\tif (len >= item_len) {\n\t\t\t\trds_info_copy(iter, buffer, item_len);\n\t\t\t\tlen -= item_len;\n\t\t\t}\n\t\t\tlens->nr++;\n\t\t}\n\t}\n\trcu_read_unlock();\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":354871,"func":"static void dccp_mib_exit(void)\n{\n\tfree_percpu(dccp_statistics[0]);\n\tfree_percpu(dccp_statistics[1]);\n\tdccp_statistics[0] = dccp_statistics[1] = NULL;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":261808,"func":"int cil_resolve_genfscon(struct cil_tree_node *current, void *extra_args)\n{\n\tstruct cil_genfscon *genfscon = current->data;\n\tstruct cil_symtab_datum *context_datum = NULL;\n\tint rc = SEPOL_ERR;\n\n\tif (genfscon->context_str != NULL) {\n\t\trc = cil_resolve_name(current, genfscon->context_str, CIL_SYM_CONTEXTS, extra_args, &context_datum);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\t\tgenfscon->context = (struct cil_context*)context_datum;\n\t} else {\n\t\trc = cil_resolve_context(current, genfscon->context, extra_args);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\t}\n\n\treturn SEPOL_OK;\n\nexit:\n\treturn rc;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":522105,"func":"void Item_func::count_decimal_length(Item **item, uint nitems)\n{\n  int max_int_part= 0;\n  decimals= 0;\n  unsigned_flag= 1;\n  for (uint i=0 ; i < nitems ; i++)\n  {\n    set_if_bigger(decimals, item[i]->decimals);\n    set_if_bigger(max_int_part, item[i]->decimal_int_part());\n    set_if_smaller(unsigned_flag, item[i]->unsigned_flag);\n  }\n  int precision= MY_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);\n  fix_char_length(my_decimal_precision_to_length_no_truncation(precision,\n                                                               decimals,\n                                                               unsigned_flag));\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":471411,"func":"void serverLog(int level, const char *fmt, ...) {\n    va_list ap;\n    char msg[LOG_MAX_LEN];\n\n    if ((level&0xff) < server.verbosity) return;\n\n    va_start(ap, fmt);\n    vsnprintf(msg, sizeof(msg), fmt, ap);\n    va_end(ap);\n\n    serverLogRaw(level,msg);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":153815,"func":"void IniSection::initValue (const string&key,const string&val,const string&comment,int rb)\n{\n    string k = ip->changeCase (key);\n    IniEntry e;\n    IniEntryIdxIterator exi;\n    if (!ip->repeatNames () && (exi = ivalues.find (k)) != ivalues.end ())\n\t{\n\t    IniIterator ei = exi->second;\n\t    \/\/ update existing value\n\t    \/\/ copy the old value\n\t    e = ei->e ();\n\t    \/\/ remove and unindex the old value\n\t    \/\/ This means that container needs to be a list, not vector,\n\t    \/\/ so that iterators kept in ivalues are still valid\n\t    container.erase (ei);\n\t    ivalues.erase (exi);\n\t}\n    else\n\t{\n\t    \/\/ nothing\n\t}\n    \/\/ create new value\n    e.init (k, comment, rb, val);\n    \/\/ insert it\n    IniContainerElement ce (e);\n    container.push_back (ce);\n    \/\/ index it\n    ivalues.insert (IniEntryIndex::value_type (k, --container.end ()));\n\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":172322,"func":"    InspectorOverlayChromeClient(ChromeClient& client, InspectorOverlay* overlay)\n        : m_client(client)\n        , m_overlay(overlay)\n    { }\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":292169,"func":"static pyc_object *get_none_object(void) {\n\tpyc_object *ret = R_NEW0 (pyc_object);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tret->type = TYPE_NONE;\n\tret->data = strdup (\"None\");\n\tif (!ret->data) {\n\t\tR_FREE (ret);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":472446,"func":"static int selinux_task_getsid(struct task_struct *p)\n{\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    current_sid(), task_sid_obj(p), SECCLASS_PROCESS,\n\t\t\t    PROCESS__GETSESSION, NULL);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":269505,"func":"ofpact_init(struct ofpact *ofpact, enum ofpact_type type, size_t len)\n{\n    memset(ofpact, 0, len);\n    ofpact->type = type;\n    ofpact->raw = -1;\n    ofpact->len = len;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":42765,"func":"static void ccp_process_data(struct ccp_data *src, struct ccp_data *dst,\n\t\t\t     struct ccp_op *op)\n{\n\top->init = 0;\n\n\tif (dst) {\n\t\tif (op->dst.u.dma.address == dst->dm_wa.dma.address)\n\t\t\tccp_empty_queue_buf(dst);\n\t\telse\n\t\t\tccp_update_sg_workarea(&dst->sg_wa,\n\t\t\t\t\t       op->dst.u.dma.length);\n\t}\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":397231,"func":"gst_mpegts_section_send_event (GstMpegtsSection * section, GstElement * element)\n{\n  GstEvent *event;\n\n  g_return_val_if_fail (section != NULL, FALSE);\n  g_return_val_if_fail (element != NULL, FALSE);\n\n  event = _mpegts_section_get_event (section);\n\n  if (!gst_element_send_event (element, event)) {\n    gst_event_unref (event);\n    return FALSE;\n  }\n\n  return TRUE;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":78030,"func":"u_save_line(undoline_T *ul, linenr_T lnum)\n{\n    char_u *line = ml_get(lnum);\n\n    if (curbuf->b_ml.ml_line_len == 0)\n    {\n\tul->ul_len = 1;\n\tul->ul_line = vim_strsave((char_u *)\"\");\n    }\n    else\n    {\n\t\/\/ This uses the length in the memline, thus text properties are\n\t\/\/ included.\n\tul->ul_len = curbuf->b_ml.ml_line_len;\n\tul->ul_line = vim_memsave(line, ul->ul_len);\n    }\n    return ul->ul_line == NULL ? FAIL : OK;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":88394,"func":"bool CZNC::AddListener(CListener* pListener) {\n    if (!pListener->GetRealListener()) {\n        \/\/ Listener doesn't actually listen\n        delete pListener;\n        return false;\n    }\n\n    \/\/ We don't check if there is an identical listener already listening\n    \/\/ since one can't listen on e.g. the same port multiple times\n\n    m_vpListeners.push_back(pListener);\n    return true;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":238756,"func":"  explicit LastMuteMetadata(content::WebContents* contents) {}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":282220,"func":"InlineBox* RenderBox::createInlineBox()\n{\n    return new (renderArena()) InlineBox(this);\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":88325,"func":"     **\/\n    explicit CImg(const CImgDisplay &disp):_width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) {\n      disp.snapshot(*this);","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":398110,"func":"ip_has_invalid_namespace_p(self)\n    VALUE self;\n{\n    struct tcltkip *ptr = get_ip(self);\n\n    if (ptr == (struct tcltkip *)NULL || ptr->ip == (Tcl_Interp *)NULL) {\n        \/* deleted IP *\/\n        return Qtrue;\n    }\n\n#if TCL_NAMESPACE_DEBUG\n    if (rbtk_invalid_namespace(ptr)) {\n        return Qtrue;\n    } else {\n        return Qfalse;\n    }\n#else\n    return Qfalse;\n#endif\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":521439,"func":"void JOIN::clear()\n{\n  clear_tables(this);\n  copy_fields(&tmp_table_param);\n\n  if (sum_funcs)\n  {\n    Item_sum *func, **func_ptr= sum_funcs;\n    while ((func= *(func_ptr++)))\n      func->clear();\n  }\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":9394,"func":"  ReleaseAccelerator(ui::KeyboardCode keycode,\n                     bool shift_pressed,\n                     bool ctrl_pressed,\n                     bool alt_pressed)\n      : ui::Accelerator(keycode, shift_pressed, ctrl_pressed, alt_pressed) {\n     set_type(ui::ET_KEY_RELEASED);\n   }\n","target":1,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":408860,"func":"objects_dump(fz_context *ctx, pdf_document *doc, pdf_write_state *opts)\n{\n\tint i;\n\n\tfor (i=0; i < pdf_xref_len(ctx, doc); i++)\n\t{\n\t\tfprintf(stderr, \"Object %d use=%x offset=%d\\n\", i, opts->use_list[i], (int)opts->ofs_list[i]);\n\t}\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":18884,"func":"static gboolean logcat_seek_read ( wtap * wth , gint64 seek_off , struct wtap_pkthdr * phdr , Buffer * buf , int * err , gchar * * err_info ) {\n if ( file_seek ( wth -> random_fh , seek_off , SEEK_SET , err ) == - 1 ) return FALSE ;\n if ( ! logcat_read_packet ( ( struct logcat_phdr * ) wth -> priv , wth -> random_fh , phdr , buf , err , err_info ) ) {\n if ( * err == 0 ) * err = WTAP_ERR_SHORT_READ ;\n return FALSE ;\n }\n return TRUE ;\n }","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":182599,"func":"LRESULT HWNDMessageHandler::OnKeyEvent(UINT message,\n                                       WPARAM w_param,\n                                       LPARAM l_param) {\n  MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime() };\n  ui::KeyEvent key(msg, message == WM_CHAR);\n  if (!delegate_->HandleUntranslatedKeyEvent(key))\n    DispatchKeyEventPostIME(key);\n  return 0;\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":115003,"func":"bool CommandData::ExclDirByAttr(uint FileAttr)\n{\n#ifdef _WIN_ALL\n  if ((FileAttr & FILE_ATTRIBUTE_REPARSE_POINT)!=0 &&\n      (ExclFileAttr & FILE_ATTRIBUTE_REPARSE_POINT)!=0)\n    return true;\n#endif\n  return false;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":86164,"func":"static void jsi_ValueToPrimitiveRes(Jsi_Interp *interp, Jsi_Value *v, Jsi_Value *rPtr)\n{\n    if (v->vt != JSI_VT_OBJECT) {\n#ifdef JSI_MEM_DEBUG\n    memcpy(rPtr, v, sizeof(*v)-sizeof(v->VD));\n#else\n    *rPtr = *v; \/\/TODO: usde only by ValueCompare, so refCnt doesn't matter?\n#endif\n        return;\n    }\n    Jsi_Obj *obj = v->d.obj;\n    switch(obj->ot) {\n        case JSI_OT_BOOL:\n            Jsi_ValueMakeBool(interp, &rPtr, obj->d.val);\n            break;\n        case JSI_OT_NUMBER:\n            Jsi_ValueMakeNumber(interp, &rPtr, obj->d.num);\n            break;\n        case JSI_OT_STRING:\n            rPtr->vt = JSI_VT_STRING;\n            rPtr->d.s = obj->d.s;\n            rPtr->f.bits.isstrkey = 1;\n            break;\n        default:\n            break;\n    }\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":85090,"func":"void d_move(struct dentry *dentry, struct dentry *target)\n{\n\twrite_seqlock(&rename_lock);\n\t__d_move(dentry, target, false);\n\twrite_sequnlock(&rename_lock);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":283742,"func":"bool SyncTest::WaitForTestServerToStart(int time_ms, int intervals) {\n  for (int i = 0; i < intervals; ++i) {\n    if (IsTestServerRunning())\n      return true;\n    base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(\n        time_ms \/ intervals));\n  }\n  return false;\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":153242,"func":"struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,\n\t\t\t\t      u32 mask)\n{\n\tstruct crypto_tfm *tfm = NULL;\n\tunsigned int tfm_size;\n\tint err = -ENOMEM;\n\n\ttfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask);\n\ttfm = kzalloc(tfm_size, GFP_KERNEL);\n\tif (tfm == NULL)\n\t\tgoto out_err;\n\n\ttfm->__crt_alg = alg;\n\n\terr = crypto_init_ops(tfm, type, mask);\n\tif (err)\n\t\tgoto out_free_tfm;\n\n\tif (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm)))\n\t\tgoto cra_init_failed;\n\n\tgoto out;\n\ncra_init_failed:\n\tcrypto_exit_ops(tfm);\nout_free_tfm:\n\tif (err == -EAGAIN)\n\t\tcrypto_shoot_alg(alg);\n\tkfree(tfm);\nout_err:\n\ttfm = ERR_PTR(err);\nout:\n\treturn tfm;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":189884,"func":"void PaymentHandlerWebFlowViewController::LoadProgressChanged(\n    content::WebContents* source,\n    double progress) {\n  DCHECK(source == web_contents());\n\n  progress_bar_->SetValue(progress);\n\n  if (progress == 1.0 && show_progress_bar_) {\n    show_progress_bar_ = false;\n    UpdateHeaderContentSeparatorView();\n    return;\n  }\n\n  if (progress < 1.0 && !show_progress_bar_) {\n    show_progress_bar_ = true;\n    UpdateHeaderContentSeparatorView();\n    return;\n  }\n}\n","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":420352,"func":"   Convert an 8bit string to a base64 string *\/\nPHP_FUNCTION(imap_binary)\n{\n\tchar *text, *decode;\n\tint text_len;\n\tunsigned long newlength;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &text, &text_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tdecode = rfc822_binary(text, text_len, &newlength);\n\n\tif (decode == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\tRETVAL_STRINGL_CHECK(decode, newlength, 1);\n\tfs_give((void**) &decode);","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":201544,"func":"void Browser::SwapTabContents(TabContentsWrapper* old_tab_contents,\n                              TabContentsWrapper* new_tab_contents) {\n  int index =\n      tab_handler_->GetTabStripModel()->GetIndexOfTabContents(old_tab_contents);\n  DCHECK_NE(TabStripModel::kNoTab, index);\n  tab_handler_->GetTabStripModel()->ReplaceTabContentsAt(index,\n                                                         new_tab_contents);\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":151147,"func":"int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, const u8 *addr)\n{\n\tstruct sta_info *sta;\n\tint ret;\n\n\tmutex_lock(&sdata->local->sta_mtx);\n\tsta = sta_info_get(sdata, addr);\n\tret = __sta_info_destroy(sta);\n\tmutex_unlock(&sdata->local->sta_mtx);\n\n\treturn ret;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":423020,"func":"static inline struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)\n{\n\treturn NULL;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":250287,"func":"void NTPResourceCache::CreateNewTabIncognitoCSS() {\n  ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);\n  DCHECK(tp);\n\n  SkColor color_background =\n      GetThemeColor(tp, ThemeProperties::COLOR_NTP_BACKGROUND);\n\n  std::vector<std::string> subst;\n\n  subst.push_back(\n      profile_->GetPrefs()->GetString(prefs::kCurrentThemeID));  \/\/ $1\n\n  subst.push_back(SkColorToRGBAString(color_background));  \/\/ $2\n  subst.push_back(GetNewTabBackgroundCSS(tp, false));  \/\/ $3\n  subst.push_back(GetNewTabBackgroundCSS(tp, true));  \/\/ $4\n  subst.push_back(GetNewTabBackgroundTilingCSS(tp));  \/\/ $5\n\n  static const base::StringPiece new_tab_theme_css(\n      ResourceBundle::GetSharedInstance().GetRawDataResource(\n          IDR_NEW_INCOGNITO_TAB_THEME_CSS));\n\n  std::string full_css = ReplaceStringPlaceholders(\n      new_tab_theme_css, subst, NULL);\n\n  new_tab_incognito_css_ = base::RefCountedString::TakeString(&full_css);\n}\n","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":432344,"func":"static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len,\n\t\t\t\t\t   struct ath6kl_vif *vif)\n{\n\tstruct wmi_tkip_micerr_event *ev;\n\n\tif (len < sizeof(struct wmi_tkip_micerr_event))\n\t\treturn -EINVAL;\n\n\tev = (struct wmi_tkip_micerr_event *) datap;\n\n\tath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast);\n\n\treturn 0;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":122124,"func":"static inline int vmcs12_write_any(struct kvm_vcpu *vcpu,\n\t\t\t\t   unsigned long field, u64 field_value){\n\tshort offset = vmcs_field_to_offset(field);\n\tchar *p = ((char *) get_vmcs12(vcpu)) + offset;\n\tif (offset < 0)\n\t\treturn offset;\n\n\tswitch (vmcs_field_type(field)) {\n\tcase VMCS_FIELD_TYPE_U16:\n\t\t*(u16 *)p = field_value;\n\t\treturn 0;\n\tcase VMCS_FIELD_TYPE_U32:\n\t\t*(u32 *)p = field_value;\n\t\treturn 0;\n\tcase VMCS_FIELD_TYPE_U64:\n\t\t*(u64 *)p = field_value;\n\t\treturn 0;\n\tcase VMCS_FIELD_TYPE_NATURAL_WIDTH:\n\t\t*(natural_width *)p = field_value;\n\t\treturn 0;\n\tdefault:\n\t\tWARN_ON(1);\n\t\treturn -ENOENT;\n\t}\n\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":150579,"func":"PHPAPI void\nmysqlnd_protocol_free(MYSQLND_PROTOCOL * const protocol TSRMLS_DC)\n{\n\tDBG_ENTER(\"mysqlnd_protocol_free\");\n\n\tif (protocol) {\n\t\tzend_bool pers = protocol->persistent;\n\t\tmnd_pefree(protocol, pers);\n\t}\n\tDBG_VOID_RETURN;","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":376075,"func":"static void openpic_init(Object *obj)\n{\n    OpenPICState *opp = OPENPIC(obj);\n\n    memory_region_init(&opp->mem, obj, \"openpic\", 0x40000);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":498541,"func":"DetectPrefilterBuildNonPrefilterList(DetectEngineThreadCtx *det_ctx, SignatureMask mask, uint8_t alproto)\n{\n    uint32_t x = 0;\n    for (x = 0; x < det_ctx->non_pf_store_cnt; x++) {\n        \/* only if the mask matches this rule can possibly match,\n         * so build the non_mpm array only for match candidates *\/\n        const SignatureMask rule_mask = det_ctx->non_pf_store_ptr[x].mask;\n        const uint8_t rule_alproto = det_ctx->non_pf_store_ptr[x].alproto;\n        if ((rule_mask & mask) == rule_mask && (rule_alproto == 0 || rule_alproto == alproto)) { \/\/ TODO dce?\n            det_ctx->non_pf_id_array[det_ctx->non_pf_id_cnt++] = det_ctx->non_pf_store_ptr[x].id;\n        }\n    }\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":499854,"func":"QPDFFormFieldObjectHelper::getQuadding()\n{\n    int result = 0;\n    QPDFObjectHandle fv = getInheritableFieldValue(\"\/Q\");\n    if (fv.isInteger())\n    {\n        QTC::TC(\"qpdf\", \"QPDFFormFieldObjectHelper Q present\");\n        result = QIntC::to_int(fv.getIntValue());\n    }\n    return result;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":330355,"func":"static int proxy_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)\n\n{\n\n    int retval;\n\n    retval = v9fs_request(s->private, T_STATFS, stbuf, \"s\", fs_path);\n\n    if (retval < 0) {\n\n        errno = -retval;\n\n        return -1;\n\n    }\n\n    return retval;\n\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":452057,"func":"static void php_openssl_add_method_or_alias(const OBJ_NAME *name, void *arg) \/* {{{ *\/\n{\n\tadd_next_index_string((zval*)arg, (char*)name->name);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":425094,"func":"static void init_fstein_dither(int line)\n{\n    ;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":173862,"func":"void PartialMagnificationController::SwitchTargetRootWindow(\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":208737,"func":"void HTMLSelectElement::defaultEventHandler(Event* event)\n{\n    if (!renderer())\n        return;\n\n    if (isDisabledFormControl()) {\n        HTMLFormControlElementWithState::defaultEventHandler(event);\n        return;\n    }\n\n    if (usesMenuList())\n        menuListDefaultEventHandler(event);\n    else\n        listBoxDefaultEventHandler(event);\n    if (event->defaultHandled())\n        return;\n\n    if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) {\n        KeyboardEvent* keyboardEvent = toKeyboardEvent(event);\n        if (!keyboardEvent->ctrlKey() && !keyboardEvent->altKey() && !keyboardEvent->metaKey() && isPrintableChar(keyboardEvent->charCode())) {\n            typeAheadFind(keyboardEvent);\n            event->setDefaultHandled();\n            return;\n        }\n    }\n    HTMLFormControlElementWithState::defaultEventHandler(event);\n}\n","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":365516,"func":"static struct dentry *proc_task_instantiate(struct inode *dir,\n\tstruct dentry *dentry, struct task_struct *task, const void *ptr)\n{\n\tstruct dentry *error = ERR_PTR(-ENOENT);\n\tstruct inode *inode;\n\tinode = proc_pid_make_inode(dir->i_sb, task);\n\n\tif (!inode)\n\t\tgoto out;\n\tinode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;\n\tinode->i_op = &proc_tid_base_inode_operations;\n\tinode->i_fop = &proc_tid_base_operations;\n\tinode->i_flags|=S_IMMUTABLE;\n\n\tset_nlink(inode, 2 + pid_entry_count_dirs(tid_base_stuff,\n\t\t\t\t\t\t  ARRAY_SIZE(tid_base_stuff)));\n\n\td_set_d_op(dentry, &pid_dentry_operations);\n\n\td_add(dentry, inode);\n\t\/* Close the race of the process dying before we return the dentry *\/\n\tif (pid_revalidate(dentry, NULL))\n\t\terror = NULL;\nout:\n\treturn error;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":253075,"func":"int Parcel::readParcelFileDescriptor(int& outCommChannel) const {\n int fd;\n    outCommChannel = -1;\n\n if (readInt32() == 0) {\n        fd = -1;\n } else {\n        fd = readFileDescriptor();\n if (fd >= 0 && readInt32() != 0) {\n            outCommChannel = readFileDescriptor();\n }\n }\n return fd;\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":23677,"func":"static inline char * w_newword ( size_t * actlen , size_t * maxlen ) {\n * actlen = * maxlen = 0 ;\n return NULL ;\n }","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":144330,"func":"static void __hrtick_start(void *arg)\n{\n\tstruct rq *rq = arg;\n\n\traw_spin_lock(&rq->lock);\n\thrtimer_restart(&rq->hrtick_timer);\n\trq->hrtick_csd_pending = 0;\n\traw_spin_unlock(&rq->lock);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":67690,"func":"static void persistent_dtr(struct dm_exception_store *store)\n{\n\tstruct pstore *ps = get_info(store);\n\n\tdestroy_workqueue(ps->metadata_wq);\n\n\t\/* Created in read_header *\/\n\tif (ps->io_client)\n\t\tdm_io_client_destroy(ps->io_client);\n\tfree_area(ps);\n\n\t\/* Allocated in persistent_read_metadata *\/\n\tif (ps->callbacks)\n\t\tvfree(ps->callbacks);\n\n\tkfree(ps);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":21673,"func":"static bool fpop_ip_dp_needed ( void * opaque ) {\n X86CPU * cpu = opaque ;\n CPUX86State * env = & cpu -> env ;\n return env -> fpop != 0 || env -> fpip != 0 || env -> fpdp != 0 ;\n }","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":99788,"func":"int key_update(key_ref_t key_ref, const void *payload, size_t plen)\n{\n\tstruct key_preparsed_payload prep;\n\tstruct key *key = key_ref_to_ptr(key_ref);\n\tint ret;\n\n\tkey_check(key);\n\n\t\/* the key must be writable *\/\n\tret = key_permission(key_ref, KEY_NEED_WRITE);\n\tif (ret < 0)\n\t\treturn ret;\n\n\t\/* attempt to update it if supported *\/\n\tif (!key->type->update)\n\t\treturn -EOPNOTSUPP;\n\n\tmemset(&prep, 0, sizeof(prep));\n\tprep.data = payload;\n\tprep.datalen = plen;\n\tprep.quotalen = key->type->def_datalen;\n\tprep.expiry = TIME_T_MAX;\n\tif (key->type->preparse) {\n\t\tret = key->type->preparse(&prep);\n\t\tif (ret < 0)\n\t\t\tgoto error;\n\t}\n\n\tdown_write(&key->sem);\n\n\tret = key->type->update(key, &prep);\n\tif (ret == 0)\n\t\t\/* Updating a negative key positively instantiates it *\/\n\t\tmark_key_instantiated(key, 0);\n\n\tup_write(&key->sem);\n\nerror:\n\tif (key->type->preparse)\n\t\tkey->type->free_preparse(&prep);\n\treturn ret;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":229785,"func":"void RenderFrameHostManager::OnDidStartLoading() {\n  for (const auto& pair : proxy_hosts_) {\n    pair.second->Send(\n        new FrameMsg_DidStartLoading(pair.second->GetRoutingID()));\n  }\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":237559,"func":"static inline ssize_t RandomY(RandomInfo *random_info,const size_t rows)\n{\n  return((ssize_t) (rows*GetPseudoRandomValue(random_info)));\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":398868,"func":"gst_date_time_get_minute (const GstDateTime * datetime)\n{\n  g_return_val_if_fail (datetime != NULL, 0);\n  g_return_val_if_fail (gst_date_time_has_time (datetime), 0);\n\n  return g_date_time_get_minute (datetime->datetime);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":227047,"func":"unsigned ImageInputType::height() const\n{\n    RefPtrWillBeRawPtr<HTMLInputElement> element(this->element());\n\n    if (!element->layoutObject()) {\n        unsigned height;\n        if (parseHTMLNonNegativeInteger(element->fastGetAttribute(heightAttr), height))\n            return height;\n\n        HTMLImageLoader* imageLoader = element->imageLoader();\n        if (imageLoader && imageLoader->image())\n            return imageLoader->image()->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), 1).height();\n    }\n\n    element->document().updateLayout();\n\n    LayoutBox* box = element->layoutBox();\n    return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0;\n}\n","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":174361,"func":"void RenderWidget::set_next_paint_is_repaint_ack() {\n  next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":224422,"func":"quint64 QQuickWebViewPrivate::exceededDatabaseQuota(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage)\n{\n    Q_Q(QQuickWebView);\n    QtDialogRunner dialogRunner(q);\n    if (!dialogRunner.initForDatabaseQuotaDialog(databaseName, displayName, securityOrigin, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage))\n        return 0;\n\n    dialogRunner.run();\n\n    return dialogRunner.wasAccepted() ? dialogRunner.databaseQuota() : 0;\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":500619,"func":"QPDF_BOOL qpdf_is_linearized(qpdf_data qpdf)\n{\n    QTC::TC(\"qpdf\", \"qpdf-c called qpdf_is_linearized\");\n    return (qpdf->qpdf->isLinearized() ? QPDF_TRUE : QPDF_FALSE);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":85289,"func":"static stb_vorbis * vorbis_alloc(stb_vorbis *f)\n{\n   stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p));\n   return p;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":216089,"func":"bool TabStripModel::WillContextMenuPin(int index) {\n  std::vector<int> indices = GetIndicesForCommand(index);\n  bool all_pinned = true;\n  for (size_t i = 0; i < indices.size() && all_pinned; ++i) {\n    if (!IsAppTab(index))  \/\/ We never change app tabs.\n      all_pinned = IsTabPinned(indices[i]);\n  }\n  return !all_pinned;\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":229468,"func":"GfxIndexedColorSpace::GfxIndexedColorSpace(GfxColorSpace *baseA,\n\t\t\t\t\t   int indexHighA) {\n  base = baseA;\n  indexHigh = indexHighA;\n  lookup = (Guchar *)gmallocn((indexHigh + 1) * base->getNComps(),\n\t\t\t      sizeof(Guchar));\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":313813,"func":"tar_sparse_fixup_header (struct tar_sparse_file *file)\n{\n  if (file->optab->fixup_header)\n    return file->optab->fixup_header (file);\n  return true;\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":438670,"func":"static void __execlists_submission_tasklet(struct intel_engine_cs *const engine)\n{\n\tlockdep_assert_held(&engine->active.lock);\n\tif (!engine->execlists.pending[0]) {\n\t\trcu_read_lock(); \/* protect peeking at execlists->active *\/\n\t\texeclists_dequeue(engine);\n\t\trcu_read_unlock();\n\t}\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":48034,"func":"void HttpFile::setFileName(const std::string &fileName)\n{\n    implPtr_->setFileName(fileName);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":244687,"func":"void RootWindow::ScheduleDraw() {\n  if (compositor_lock_) {\n    draw_on_compositor_unlock_ = true;\n  } else if (!defer_draw_scheduling_) {\n    defer_draw_scheduling_ = true;\n    MessageLoop::current()->PostTask(\n        FROM_HERE,\n        base::Bind(&RootWindow::Draw, schedule_paint_factory_.GetWeakPtr()));\n  }\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":497389,"func":"static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)\n{\n\tstruct sock *sk, *parent = chan->data;\n\n\tlock_sock(parent);\n\n\t\/* Check for backlog size *\/\n\tif (sk_acceptq_is_full(parent)) {\n\t\tBT_DBG(\"backlog full %d\", parent->sk_ack_backlog);\n\t\trelease_sock(parent);\n\t\treturn NULL;\n\t}\n\n\tsk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,\n\t\t\t      GFP_ATOMIC, 0);\n\tif (!sk) {\n\t\trelease_sock(parent);\n\t\treturn NULL;\n        }\n\n\tbt_sock_reclassify_lock(sk, BTPROTO_L2CAP);\n\n\tl2cap_sock_init(sk, parent);\n\n\tbt_accept_enqueue(parent, sk, false);\n\n\trelease_sock(parent);\n\n\treturn l2cap_pi(sk)->chan;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":282748,"func":"viz::FrameSinkId CompositorImpl::GetFrameSinkId() {\n  return frame_sink_id_;\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":83166,"func":"static int debugfs_apply_options(struct super_block *sb)\n{\n\tstruct debugfs_fs_info *fsi = sb->s_fs_info;\n\tstruct inode *inode = d_inode(sb->s_root);\n\tstruct debugfs_mount_opts *opts = &fsi->mount_opts;\n\n\tinode->i_mode &= ~S_IALLUGO;\n\tinode->i_mode |= opts->mode;\n\n\tinode->i_uid = opts->uid;\n\tinode->i_gid = opts->gid;\n\n\treturn 0;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":42638,"func":"static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) {\n  \/\/ Basic ZIP archive filename validity checks: Valid filenames cannot start\n  \/\/ with a forward slash, cannot contain a drive letter, and cannot use\n  \/\/ DOS-style backward slashes.\n  if (*pArchive_name == '\/') return MZ_FALSE;\n  while (*pArchive_name) {\n    if ((*pArchive_name == '\\\\') || (*pArchive_name == ':')) return MZ_FALSE;\n    pArchive_name++;\n  }\n  return MZ_TRUE;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":76988,"func":"static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)\n{\n  var->type= SHOW_LONG;\n  var->value= buff;\n  *((long *)buff)= (long) (thd->query_start() - server_start_time);\n  return 0;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":26938,"func":"static int proc_setintf ( struct usb_dev_state * ps , void __user * arg ) {\n struct usbdevfs_setinterface setintf ;\n int ret ;\n if ( copy_from_user ( & setintf , arg , sizeof ( setintf ) ) ) return - EFAULT ;\n ret = checkintf ( ps , setintf . interface ) ;\n if ( ret ) return ret ;\n destroy_async_on_interface ( ps , setintf . interface ) ;\n return usb_set_interface ( ps -> dev , setintf . interface , setintf . altsetting ) ;\n }","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":305766,"func":"int jpc_ppxstab_grow(jpc_ppxstab_t *tab, int maxents)\n{\n\tjpc_ppxstabent_t **newents;\n\tif (tab->maxents < maxents) {\n\t\tnewents = (tab->ents) ? jas_realloc2(tab->ents, maxents,\n\t\t  sizeof(jpc_ppxstabent_t *)) : jas_alloc2(maxents, sizeof(jpc_ppxstabent_t *));\n\t\tif (!newents) {\n\t\t\treturn -1;\n\t\t}\n\t\ttab->ents = newents;\n\t\ttab->maxents = maxents;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":55272,"func":"file_ff_differs(buf_T *buf, int ignore_empty)\n{\n    \/* In a buffer that was never loaded the options are not valid. *\/\n    if (buf->b_flags & BF_NEVERLOADED)\n\treturn FALSE;\n    if (ignore_empty\n\t    && (buf->b_flags & BF_NEW)\n\t    && buf->b_ml.ml_line_count == 1\n\t    && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)\n\treturn FALSE;\n    if (buf->b_start_ffc != *buf->b_p_ff)\n\treturn TRUE;\n    if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)\n\treturn TRUE;\n#ifdef FEAT_MBYTE\n    if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)\n\treturn TRUE;\n    if (buf->b_start_fenc == NULL)\n\treturn (*buf->b_p_fenc != NUL);\n    return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);\n#else\n    return FALSE;\n#endif\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":244946,"func":"EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodReturningSequence(ExecState* exec)\n{\n    JSValue thisValue = exec->hostThisValue();\n    if (!thisValue.inherits(&JSTestObj::s_info))\n        return throwVMTypeError(exec);\n    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));\n     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);\n     TestObj* impl = static_cast<TestObj*>(castedThis->impl());\n     if (exec->argumentCount() < 1)\n        return throwVMError(exec, createNotEnoughArgumentsError(exec));\n     int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec));\n     if (exec->hadException())\n         return JSValue::encode(jsUndefined());\n\n    JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->methodReturningSequence(intArg));\n    return JSValue::encode(result);\n}\n","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":7307,"func":"TfLiteStatus UseDynamicOutputTensors(TfLiteContext* context, TfLiteNode* node) {\n  for (int i = 0; i < NumOutputs(node); ++i) {\n    SetTensorToDynamic(GetOutput(context, node, i));\n  }\n  return kTfLiteOk;\n}","target":1,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":491992,"func":"  void chargeErrorStats(const int result) { decompressor_.chargeErrorStats(result); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":17160,"func":"int test_setup ( void ) {\n static int x = 0 ;\n x ++ ;\n snprintf_func ( TEST_TARGET_FILE , TESTFILESIZE , \"\/tmp\/xdtest.target.%d\" , x ) ;\n snprintf_func ( TEST_SOURCE_FILE , TESTFILESIZE , \"\/tmp\/xdtest.source.%d\" , x ) ;\n snprintf_func ( TEST_DELTA_FILE , TESTFILESIZE , \"\/tmp\/xdtest.delta.%d\" , x ) ;\n snprintf_func ( TEST_RECON_FILE , TESTFILESIZE , \"\/tmp\/xdtest.recon.%d\" , x ) ;\n snprintf_func ( TEST_RECON2_FILE , TESTFILESIZE , \"\/tmp\/xdtest.recon2.%d\" , x ) ;\n snprintf_func ( TEST_COPY_FILE , TESTFILESIZE , \"\/tmp\/xdtest.copy.%d\" , x ) ;\n snprintf_func ( TEST_NOPERM_FILE , TESTFILESIZE , \"\/tmp\/xdtest.noperm.%d\" , x ) ;\n test_cleanup ( ) ;\n return 0 ;\n }","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":278623,"func":"BarProp* LocalDOMWindow::menubar() const {\n  if (!menubar_)\n    menubar_ = BarProp::Create(GetFrame(), BarProp::kMenubar);\n  return menubar_.Get();\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":4333,"func":"PixarLogClose(TIFF* tif)\n{\n\tTIFFDirectory *td = &tif->tif_dir;\n\n\t\/* In a really sneaky (and really incorrect, and untruthful, and\n\t * troublesome, and error-prone) maneuver that completely goes against\n\t * the spirit of TIFF, and breaks TIFF, on close, we covertly\n\t * modify both bitspersample and sampleformat in the directory to\n\t * indicate 8-bit linear.  This way, the decode \"just works\" even for\n\t * readers that don't know about PixarLog, or how to set\n\t * the PIXARLOGDATFMT pseudo-tag.\n\t *\/\n\ttd->td_bitspersample = 8;\n\ttd->td_sampleformat = SAMPLEFORMAT_UINT;\n}","target":1,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":516868,"func":"join_read_prev_same(READ_RECORD *info)\n{\n  int error;\n  TABLE *table= info->table;\n  JOIN_TAB *tab=table->reginfo.join_tab;\n\n  if (unlikely((error= table->file->ha_index_prev(table->record[0]))))\n    return report_error(table, error);\n  if (key_cmp_if_same(table, tab->ref.key_buff, tab->ref.key,\n                      tab->ref.key_length))\n  {\n    table->status=STATUS_NOT_FOUND;\n    error= -1;\n  }\n  return error;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":348164,"func":"FileSpec::FileSpec(const Object *fileSpecA)\n{\n  ok = true;\n  fileName = nullptr;\n  platformFileName = nullptr;\n  embFile = nullptr;\n  desc = nullptr;\n  fileSpec = fileSpecA->copy();\n\n  Object obj1 = getFileSpecName(fileSpecA);\n  if (!obj1.isString()) {\n    ok = false;\n    error(errSyntaxError, -1, \"Invalid FileSpec\");\n    return;\n  }\n\n  fileName = obj1.getString()->copy();\n\n  if (fileSpec.isDict()) {\n    obj1 = fileSpec.dictLookup(\"EF\");\n    if (obj1.isDict()) {\n      fileStream = obj1.dictLookupNF(\"F\");\n      if (!fileStream.isRef()) {\n        ok = false;\n        fileStream.setToNull();\n        error(errSyntaxError, -1, \"Invalid FileSpec: Embedded file stream is not an indirect reference\");\n        return;\n      }\n    }\n  }\n\n  obj1 = fileSpec.dictLookup(\"Desc\");\n  if (obj1.isString())\n    desc = obj1.getString()->copy();\n}","target":1,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":21116,"func":"gboolean bluetooth_gatt_has_no_parameter ( guint8 opcode ) {\n return is_readable_request ( opcode ) || opcode == ATT_OPCODE_WRITE_RESPONSE || opcode == ATT_OPCODE_HANDLE_VALUE_CONFIRMATION ;\n }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":299183,"func":"\t__must_hold(&ctx->uring_lock)\n{\n\tstruct io_submit_state *state = &ctx->submit_state;\n\tgfp_t gfp = GFP_KERNEL | __GFP_NOWARN;\n\tvoid *reqs[IO_REQ_ALLOC_BATCH];\n\tstruct io_kiocb *req;\n\tint ret, i;\n\n\tif (likely(state->free_list.next || io_flush_cached_reqs(ctx)))\n\t\treturn true;\n\n\tret = kmem_cache_alloc_bulk(req_cachep, gfp, ARRAY_SIZE(reqs), reqs);\n\n\t\/*\n\t * Bulk alloc is all-or-nothing. If we fail to get a batch,\n\t * retry single alloc to be on the safe side.\n\t *\/\n\tif (unlikely(ret <= 0)) {\n\t\treqs[0] = kmem_cache_alloc(req_cachep, gfp);\n\t\tif (!reqs[0])\n\t\t\treturn false;\n\t\tret = 1;\n\t}\n\n\tpercpu_ref_get_many(&ctx->refs, ret);\n\tfor (i = 0; i < ret; i++) {\n\t\treq = reqs[i];\n\n\t\tio_preinit_req(req, ctx);\n\t\twq_stack_add_head(&req->comp_list, &state->free_list);\n\t}\n\treturn true;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":470284,"func":"static void open_uri_cb (GtkAction *action, TextView *textview)\n{\n\tClickableText *uri = g_object_get_data(G_OBJECT(textview->link_popup_menu),\n\t\t\t\t\t   \"menu_button\");\n\tconst gchar *raw_url = g_object_get_data(G_OBJECT(textview->link_popup_menu),\n\t\t\t\t\t   \"raw_url\");\n\n\tif (uri) {\n\t\tif (textview_uri_security_check(textview, uri) == TRUE) \n\t\t\topen_uri(uri->uri,\n\t\t\t\t prefs_common_get_uri_cmd());\n\t\tg_object_set_data(G_OBJECT(textview->link_popup_menu), \"menu_button\",\n\t\t\t\t  NULL);\n\t}\n\tif (raw_url) {\n\t\topen_uri(raw_url, prefs_common_get_uri_cmd());\n\t\tg_object_set_data(G_OBJECT(textview->link_popup_menu), \"raw_url\",\n\t\t\t\t  NULL);\n\t}\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":374659,"func":"_copyFieldSelect(const FieldSelect *from)\n{\n\tFieldSelect *newnode = makeNode(FieldSelect);\n\n\tCOPY_NODE_FIELD(arg);\n\tCOPY_SCALAR_FIELD(fieldnum);\n\tCOPY_SCALAR_FIELD(resulttype);\n\tCOPY_SCALAR_FIELD(resulttypmod);\n\tCOPY_SCALAR_FIELD(resultcollid);\n\n\treturn newnode;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":281849,"func":"void BackFramebuffer::AttachRenderTexture(BackTexture* texture) {\n  DCHECK_NE(id_, 0u);\n  ScopedGLErrorSuppressor suppressor(\n      \"BackFramebuffer::AttachRenderTexture\", decoder_->GetErrorState());\n  ScopedFramebufferBinder binder(decoder_, id_);\n  GLuint attach_id = texture ? texture->id() : 0;\n  api()->glFramebufferTexture2DEXTFn(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,\n                                     texture->Target(), attach_id, 0);\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":218207,"func":"RenderViewHostManager::RenderViewHostManager(\n    RenderViewHostDelegate* render_view_delegate,\n    RenderWidgetHostDelegate* render_widget_delegate,\n    Delegate* delegate)\n    : delegate_(delegate),\n      cross_navigation_pending_(false),\n      render_view_delegate_(render_view_delegate),\n      render_widget_delegate_(render_widget_delegate),\n      render_view_host_(NULL),\n      pending_render_view_host_(NULL),\n      interstitial_page_(NULL) {\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":472815,"func":"static void scsi_cd_change_media_cb(void *opaque, bool load, Error **errp)\n{\n    SCSIDiskState *s = opaque;\n\n    \/*\n     * When a CD gets changed, we have to report an ejected state and\n     * then a loaded state to guests so that they detect tray\n     * open\/close and media change events.  Guests that do not use\n     * GET_EVENT_STATUS_NOTIFICATION to detect such tray open\/close\n     * states rely on this behavior.\n     *\n     * media_changed governs the state machine used for unit attention\n     * report.  media_event is used by GET EVENT STATUS NOTIFICATION.\n     *\/\n    s->media_changed = load;\n    s->tray_open = !load;\n    scsi_device_set_ua(&s->qdev, SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM));\n    s->media_event = true;\n    s->eject_request = false;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":419854,"func":"\tGets the ACL for a given mailbox *\/\nPHP_FUNCTION(imap_getacl)\n{\n\tzval *streamind;\n\tzend_string *mailbox;\n\tpils *imap_le_struct;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"rS\", &streamind, &mailbox) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), \"imap\", le_imap)) == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* initializing the special array for the return values *\/\n\tarray_init(return_value);\n\n\tIMAPG(imap_acl_list) = return_value;\n\n\t\/* set the callback for the GET_ACL function *\/\n\tmail_parameters(NIL, SET_ACL, (void *) mail_getacl);\n\tif (!imap_getacl(imap_le_struct->imap_stream, ZSTR_VAL(mailbox))) {\n\t\tphp_error(E_WARNING, \"c-client imap_getacl failed\");\n\t\tzval_dtor(return_value);\n\t\tRETURN_FALSE;\n\t}\n\n\tIMAPG(imap_acl_list) = NIL;","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":73548,"func":"  static size_t BufferBytesForLength(int length) {\n    return (length + 1) * sizeof(TypedValue) \/ 2;  \/\/ Worst case: \"[0,0,...,0]\"\n  }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":277157,"func":"void DesktopWindowTreeHostX11::AfterActivationStateChanged() {\n  if (had_pointer_grab_ && !has_pointer_grab_)\n    dispatcher()->OnHostLostMouseGrab();\n\n  bool had_pointer_capture = had_pointer_ || had_pointer_grab_;\n  bool has_pointer_capture = has_pointer_ || has_pointer_grab_;\n  if (had_pointer_capture && !has_pointer_capture)\n    OnHostLostWindowCapture();\n\n  if (!was_active_ && IsActive()) {\n    FlashFrame(false);\n    open_windows().remove(xwindow_);\n    open_windows().insert(open_windows().begin(), xwindow_);\n  }\n\n  if (was_active_ != IsActive()) {\n    desktop_native_widget_aura_->HandleActivationChanged(IsActive());\n    native_widget_delegate_->AsWidget()->GetRootView()->SchedulePaint();\n  }\n}\n","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":438645,"func":"static u32 *emit_lri(u32 *batch, const struct lri *lri, unsigned int count)\n{\n\tGEM_BUG_ON(!count || count > 63);\n\n\t*batch++ = MI_LOAD_REGISTER_IMM(count);\n\tdo {\n\t\t*batch++ = i915_mmio_reg_offset(lri->reg);\n\t\t*batch++ = lri->value;\n\t} while (lri++, --count);\n\t*batch++ = MI_NOOP;\n\n\treturn batch;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":432880,"func":"filter_can_trim (struct backend *b, struct connection *conn)\n{\n  struct backend_filter *f = container_of (b, struct backend_filter, backend);\n  void *handle = connection_get_handle (conn, b->i);\n  struct b_conn nxdata = { .b = b->next, .conn = conn };\n\n  if (f->filter.can_trim)\n    return f->filter.can_trim (&next_ops, &nxdata, handle);\n  else\n    return backend_can_trim (b->next, conn);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":199657,"func":"size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams)\n{\n    ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);\n    return ZSTD_estimateCStreamSize_usingCCtxParams(¶ms);\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":65224,"func":"static void sctp_v4_ecn_capable(struct sock *sk)\n{\n\tINET_ECN_xmit(sk);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":438005,"func":"long Track::GetNumber() const { return m_info.number; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":205146,"func":"DragController::DragController(Page* page)\n    : page_(page),\n      document_under_mouse_(nullptr),\n      drag_initiator_(nullptr),\n      file_input_element_under_mouse_(nullptr),\n      document_is_handling_drag_(false),\n      drag_destination_action_(kDragDestinationActionNone),\n      did_initiate_drag_(false) {}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":424207,"func":"static int assess_restrict_namespaces(\n                const struct security_assessor *a,\n                const struct security_info *info,\n                const void *data,\n                uint64_t *ret_badness,\n                char **ret_description) {\n\n        assert(ret_badness);\n        assert(ret_description);\n\n        *ret_badness = !!(info->restrict_namespaces & a->parameter);\n        *ret_description = NULL;\n\n        return 0;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":253656,"func":"void ChromeWebContentsDelegateAndroid::FindReply(\n    WebContents* web_contents,\n    int request_id,\n    int number_of_matches,\n    const gfx::Rect& selection_rect,\n    int active_match_ordinal,\n    bool final_update) {\n  if (!notification_registrar_.IsRegistered(this,\n      chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,\n      content::Source<WebContents>(web_contents))) {\n    notification_registrar_.Add(this,\n        chrome::NOTIFICATION_FIND_RESULT_AVAILABLE,\n        content::Source<WebContents>(web_contents));\n  }\n\n  FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(web_contents);\n  find_tab_helper->HandleFindReply(request_id,\n                                   number_of_matches,\n                                   selection_rect,\n                                   active_match_ordinal,\n                                   final_update);\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":307115,"func":"  cf2_free_instance( void*  ptr )\n  {\n    CF2_Font  font = (CF2_Font)ptr;\n\n\n    if ( font )\n    {\n      FT_Memory  memory = font->memory;\n\n\n      (void)memory;\n    }\n  }\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":442492,"func":"const SecretSchema *docker_get_schema(void)\n{\n\tstatic const SecretSchema docker_schema = {\n\t\t\"io.docker.Credentials\", SECRET_SCHEMA_NONE,\n\t\t{\n\t\t    { \"label\", SECRET_SCHEMA_ATTRIBUTE_STRING },\n\t\t\t{ \"server\", SECRET_SCHEMA_ATTRIBUTE_STRING },\n\t\t\t{ \"username\", SECRET_SCHEMA_ATTRIBUTE_STRING },\n\t\t\t{ \"docker_cli\", SECRET_SCHEMA_ATTRIBUTE_STRING },\n\t\t\t{ \"NULL\", 0 },\n\t\t}\n\t};\n\treturn &docker_schema;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":513856,"func":"static UINT cliprdr_server_packet_send(CliprdrServerPrivate* cliprdr, wStream* s)\n{\n\tUINT rc;\n\tsize_t pos, size;\n\tBOOL status;\n\tUINT32 dataLen;\n\tUINT32 written;\n\tpos = Stream_GetPosition(s);\n\tif ((pos < 8) || (pos > UINT32_MAX))\n\t{\n\t\trc = ERROR_NO_DATA;\n\t\tgoto fail;\n\t}\n\n\tdataLen = (UINT32)(pos - 8);\n\tStream_SetPosition(s, 4);\n\tStream_Write_UINT32(s, dataLen);\n\tStream_SetPosition(s, pos);\n\tsize = Stream_Length(s);\n\tif (size > UINT32_MAX)\n\t{\n\t\trc = ERROR_INVALID_DATA;\n\t\tgoto fail;\n\t}\n\n\tstatus = WTSVirtualChannelWrite(cliprdr->ChannelHandle, (PCHAR)Stream_Buffer(s), (UINT32)size,\n\t                                &written);\n\trc = status ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;\nfail:\n\tStream_Free(s, TRUE);\n\treturn rc;\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":348068,"func":"int main(void) {\n        test_syslog_parse_identifier(\"pidu[111]: xxx\", \"pidu\", \"111\", 11);\n        test_syslog_parse_identifier(\"pidu: xxx\", \"pidu\", NULL, 6);\n        test_syslog_parse_identifier(\"pidu xxx\", NULL, NULL, 0);\n\n        return 0;\n}","target":1,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":374026,"func":"xps_lookup_font(xps_document *doc, char *name)\n{\n\txps_font_cache *cache;\n\tfor (cache = doc->font_table; cache; cache = cache->next)\n\t\tif (!xps_strcasecmp(cache->name, name))\n\t\t\treturn fz_keep_font(doc->ctx, cache->font);\n\treturn NULL;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":96210,"func":"static void emitline(JF, js_Ast *node)\n{\n\tF->lastline = node->line;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":505517,"func":"const char *CRYPTO_get_lock_name(int type)\n\t{\n\tif (type < 0)\n\t\treturn(\"dynamic\");\n\telse if (type < CRYPTO_NUM_LOCKS)\n\t\treturn(lock_names[type]);\n\telse if (type-CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks))\n\t\treturn(\"ERROR\");\n\telse\n\t\treturn(sk_OPENSSL_STRING_value(app_locks,type-CRYPTO_NUM_LOCKS));\n\t}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":441290,"func":"AWSBrowserUploadAbstractor::get_auth_data(const req_state* const s) const\n{\n  if (s->auth.s3_postobj_creds.x_amz_algorithm == AWS4_HMAC_SHA256_STR) {\n    ldpp_dout(s, 0) << \"Signature verification algorithm AWS v4\"\n                     << \" (AWS4-HMAC-SHA256)\" << dendl;\n    return get_auth_data_v4(s);\n  } else {\n    ldpp_dout(s, 0) << \"Signature verification algorithm AWS v2\" << dendl;\n    return get_auth_data_v2(s);\n  }\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":227250,"func":"void LayerWebKitThread::removeAll(Vector<RefPtr<LayerWebKitThread> >& vector)\n{\n    if (!vector.size())\n        return;\n\n    while (vector.size()) {\n        RefPtr<LayerWebKitThread> layer = vector[0].get();\n        ASSERT(layer->superlayer() == this);\n        layer->removeFromSuperlayer();\n    }\n\n    setNeedsCommit();\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":367406,"func":"static void selinux_shm_free_security(struct shmid_kernel *shp)\n{\n\tipc_free_security(&shp->shm_perm);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":173877,"func":"static int vrend_decode_set_constant_buffer(struct vrend_decode_ctx *ctx, uint16_t length)\n{\n   uint32_t shader;\n   uint32_t index;\n   int nc = (length - 2);\n\n   if (length < 2)\n      return EINVAL;\n\n   shader = get_buf_entry(ctx, VIRGL_SET_CONSTANT_BUFFER_SHADER_TYPE);\n   index = get_buf_entry(ctx, VIRGL_SET_CONSTANT_BUFFER_INDEX);\n\n   if (shader >= PIPE_SHADER_TYPES)\n      return EINVAL;\n\n   vrend_set_constants(ctx->grctx, shader, index, nc, get_buf_ptr(ctx, VIRGL_SET_CONSTANT_BUFFER_DATA_START));\n   return 0;\n}\n","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":245149,"func":"bool OmniboxViewViews::OnMousePressed(const ui::MouseEvent& event) {\n  select_all_on_mouse_release_ =\n      (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&\n      (!HasFocus() || (model()->focus_state() == OMNIBOX_FOCUS_INVISIBLE));\n  if (select_all_on_mouse_release_) {\n    model()->SetCaretVisibility(true);\n\n    saved_selection_for_focus_change_ = gfx::Range::InvalidRange();\n  }\n  return views::Textfield::OnMousePressed(event);\n}\n","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":515142,"func":"static void epsf_gencode(GVJ_t * job, node_t * n)\n{\n    obj_state_t *obj = job->obj;\n    epsf_t *desc;\n    int doMap = (obj->url || obj->explicit_tooltip);\n\n    desc = (epsf_t *) (ND_shape_info(n));\n    if (!desc)\n\treturn;\n\n    if (doMap && !(job->flags & EMIT_CLUSTERS_LAST))\n\tgvrender_begin_anchor(job,\n\t\t\t      obj->url, obj->tooltip, obj->target,\n\t\t\t      obj->id);\n    if (desc)\n\tfprintf(job->output_file,\n\t\t\"%.5g %.5g translate newpath user_shape_%d\\n\",\n\t\tND_coord(n).x + desc->offset.x,\n\t\tND_coord(n).y + desc->offset.y, desc->macro_id);\n    ND_label(n)->pos = ND_coord(n);\n\n    emit_label(job, EMIT_NLABEL, ND_label(n));\n    if (doMap) {\n\tif (job->flags & EMIT_CLUSTERS_LAST)\n\t    gvrender_begin_anchor(job,\n\t\t\t\t  obj->url, obj->tooltip, obj->target,\n\t\t\t\t  obj->id);\n\tgvrender_end_anchor(job);\n    }\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":387107,"func":"static bool vmxnet_tx_pkt_rebuild_payload(struct VmxnetTxPkt *pkt)\n{\n    size_t payload_len = iov_size(pkt->raw, pkt->raw_frags) - pkt->hdr_len;\n\n    pkt->payload_frags = iov_copy(&pkt->vec[VMXNET_TX_PKT_PL_START_FRAG],\n                                pkt->max_payload_frags,\n                                pkt->raw, pkt->raw_frags,\n                                pkt->hdr_len, payload_len);\n\n    if (pkt->payload_frags != (uint32_t) -1) {\n        pkt->payload_len = payload_len;\n        return true;\n    } else {\n        return false;\n    }\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":29421,"func":"static int cmp_hpel ( MpegEncContext * s , const int x , const int y , const int subx , const int suby , const int size , const int h , int ref_index , int src_index , me_cmp_func cmp_func , me_cmp_func chroma_cmp_func , const int flags ) {\n if ( flags & FLAG_DIRECT ) {\n return cmp_direct_inline ( s , x , y , subx , suby , size , h , ref_index , src_index , cmp_func , chroma_cmp_func , 0 ) ;\n }\n else {\n return cmp_inline ( s , x , y , subx , suby , size , h , ref_index , src_index , cmp_func , chroma_cmp_func , 0 , flags & FLAG_CHROMA ) ;\n }\n }","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":483673,"func":"void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)\n{\n\tof_node_put(dev->of_node);\n\tdev->of_node = of_node_get(dev2->of_node);\n\tdev->of_node_reused = true;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":169240,"func":"void Layer::SetClipParent(Layer* ancestor) {\n  DCHECK(IsPropertyChangeAllowed());\n  if (clip_parent_ == ancestor)\n    return;\n\n  if (clip_parent_)\n    clip_parent_->RemoveClipChild(this);\n\n  clip_parent_ = ancestor;\n\n  if (clip_parent_)\n    clip_parent_->AddClipChild(this);\n\n  SetNeedsCommit();\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":22385,"func":"void xmlCleanupGlobals ( void ) {\n if ( xmlThrDefMutex != NULL ) {\n xmlFreeMutex ( xmlThrDefMutex ) ;\n xmlThrDefMutex = NULL ;\n }\n __xmlGlobalInitMutexDestroy ( ) ;\n }","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":169530,"func":" PHP_METHOD(snmp, set)\n {\n\tphp_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1));\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":264133,"func":"wait_for_completion_interruptible_timeout(struct completion *x,\n\t\t\t\t\t  unsigned long timeout)\n{\n\treturn wait_for_common(x, timeout, TASK_INTERRUPTIBLE);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":144237,"func":"person_set_color(person_t* person, color_t mask)\n{\n\tperson->mask = mask;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":501936,"func":"static int dns_common_sort_zones(struct ldb_message **m1, struct ldb_message **m2)\n{\n\tconst char *n1, *n2;\n\tsize_t l1, l2;\n\n\tn1 = ldb_msg_find_attr_as_string(*m1, \"name\", NULL);\n\tn2 = ldb_msg_find_attr_as_string(*m2, \"name\", NULL);\n\tif (n1 == NULL || n2 == NULL) {\n\t\tif (n1 != NULL) {\n\t\t\treturn -1;\n\t\t} else if (n2 != NULL) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n\tl1 = strlen(n1);\n\tl2 = strlen(n2);\n\n\t\/* If the string lengths are not equal just sort by length *\/\n\tif (l1 != l2) {\n\t\t\/* If m1 is the larger zone name, return it first *\/\n\t\treturn l2 - l1;\n\t}\n\n\t\/*TODO: We need to compare DNs here, we want the DomainDNSZones first *\/\n\treturn 0;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":53573,"func":"check_METER(const struct ofpact_meter *a,\n            const struct ofpact_check_params *cp OVS_UNUSED)\n{\n    uint32_t mid = a->meter_id;\n    return mid == 0 || mid > OFPM13_MAX ? OFPERR_OFPMMFC_INVALID_METER : 0;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":387136,"func":"static void vmxnet3_pre_save(void *opaque)\n{\n    VMXNET3State *s = opaque;\n\n    s->mcast_list_buff_size = s->mcast_list_len * sizeof(MACAddr);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":419707,"func":"static int make_filename(const char *context[_CONTEXT_MAX], char **ret) {\n        _cleanup_free_ char *c = NULL, *u = NULL, *p = NULL, *t = NULL;\n        sd_id128_t boot = {};\n        int r;\n\n        assert(context);\n\n        c = filename_escape(context[CONTEXT_COMM]);\n        if (!c)\n                return -ENOMEM;\n\n        u = filename_escape(context[CONTEXT_UID]);\n        if (!u)\n                return -ENOMEM;\n\n        r = sd_id128_get_boot(&boot);\n        if (r < 0)\n                return r;\n\n        p = filename_escape(context[CONTEXT_PID]);\n        if (!p)\n                return -ENOMEM;\n\n        t = filename_escape(context[CONTEXT_TIMESTAMP]);\n        if (!t)\n                return -ENOMEM;\n\n        if (asprintf(ret,\n                     \"\/var\/lib\/systemd\/coredump\/core.%s.%s.\" SD_ID128_FORMAT_STR \".%s.%s000000\",\n                     c,\n                     u,\n                     SD_ID128_FORMAT_VAL(boot),\n                     p,\n                     t) < 0)\n                return -ENOMEM;\n\n        return 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":309526,"func":"InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin(\n    ScrollState* scroll_state,\n    InputHandler::ScrollInputType type) {\n  TRACE_EVENT0(\"cc\", \"LayerTreeHostImpl::RootScrollBegin\");\n\n  ClearCurrentlyScrollingNode();\n\n  return ScrollBeginImpl(scroll_state, OuterViewportScrollNode(), type);\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":284038,"func":"Response EmulationHandler::ClearGeolocationOverride() {\n  if (!GetWebContents())\n    return Response::InternalError();\n\n  auto* geolocation_context = GetWebContents()->GetGeolocationContext();\n  geolocation_context->ClearOverride();\n  return Response::OK();\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":136309,"func":"static int_fast32_t pgx_getword(jas_stream_t *in, bool bigendian, int prec)\n{\n\tuint_fast32_t val;\n\tint i;\n\tint j;\n\tint c;\n\tint wordsize;\n\n\twordsize = (prec + 7) \/ 8;\n\n\tif (prec > 32) {\n\t\tgoto error;\n\t}\n\n\tval = 0;\n\tfor (i = 0; i < wordsize; ++i) {\n\t\tif ((c = jas_stream_getc(in)) == EOF) {\n\t\t\tgoto error;\n\t\t}\n\t\tj = bigendian ? (wordsize - 1 - i) : i;\n\t\tval = val | ((c & 0xff) << (8 * j));\n\t}\n\tval &= (1 << prec) - 1;\n\treturn val;\n\nerror:\n\treturn -1;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":34875,"func":"static struct nfc_llcp_sock *nfc_llcp_sock_get_sn(struct nfc_llcp_local *local,\n\t\t\t\t\t\t  u8 *sn, size_t sn_len)\n{\n\tstruct nfc_llcp_sock *llcp_sock;\n\n\tllcp_sock = nfc_llcp_sock_from_sn(local, sn, sn_len);\n\n\tif (llcp_sock == NULL)\n\t\treturn NULL;\n\n\tsock_hold(&llcp_sock->sk);\n\n\treturn llcp_sock;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":6034,"func":"NOEXPORT char *pgsql_server(CLI *c, SERVICE_OPTIONS *opt, const PHASE phase) {\n    uint8_t buffer[8], ssl_ok[1]={'S'};\n\n    (void)opt; \/* squash the unused parameter warning *\/\n    if(phase!=PROTOCOL_EARLY)\n        return NULL;\n    memset(buffer, 0, sizeof buffer);\n    s_read(c, c->local_rfd.fd, buffer, sizeof buffer);\n    if(safe_memcmp(buffer, ssl_request, sizeof ssl_request)) {\n        s_log(LOG_ERR, \"PostgreSQL client did not request TLS, rejecting\");\n        \/* no way to send error on startup, so just drop the client *\/\n        throw_exception(c, 1);\n    }\n    s_write(c, c->local_wfd.fd, ssl_ok, sizeof ssl_ok);\n    return NULL;\n}","target":1,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":54031,"func":"static BOOL rdp_write_brush_capability_set(wStream* s, const rdpSettings* settings)\n{\n\tsize_t header;\n\n\tif (!Stream_EnsureRemainingCapacity(s, 32))\n\t\treturn FALSE;\n\n\theader = rdp_capability_set_start(s);\n\tif (header > UINT16_MAX)\n\t\treturn FALSE;\n\tStream_Write_UINT32(s, settings->BrushSupportLevel); \/* brushSupportLevel (4 bytes) *\/\n\trdp_capability_set_finish(s, (UINT16)header, CAPSET_TYPE_BRUSH);\n\treturn TRUE;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":448515,"func":"pk11_finalize(void) {\n\tpk11_token_t *token, *next;\n\tisc_result_t ret;\n\n\tret = free_all_sessions();\n\t(void) pkcs_C_Finalize(NULL_PTR);\n\ttoken = ISC_LIST_HEAD(tokens);\n\twhile (token != NULL) {\n\t\tnext = ISC_LIST_NEXT(token, link);\n\t\tISC_LIST_UNLINK(tokens, token, link);\n\t\tif (token == rand_token)\n\t\t\trand_token = NULL;\n\t\tif (token == best_rsa_token)\n\t\t\tbest_rsa_token = NULL;\n\t\tif (token == best_dsa_token)\n\t\t\tbest_dsa_token = NULL;\n\t\tif (token == best_dh_token)\n\t\t\tbest_dh_token = NULL;\n\t\tif (token == digest_token)\n\t\t\tdigest_token = NULL;\n\t\tif (token == best_ec_token)\n\t\t\tbest_ec_token = NULL;\n\t\tif (token == best_gost_token)\n\t\t\tbest_gost_token = NULL;\n\t\tif (token == aes_token)\n\t\t\taes_token = NULL;\n\t\tpk11_mem_put(token, sizeof(*token));\n\t\ttoken = next;\n\t}\n\tif (pk11_mctx != NULL)\n\t\tisc_mem_detach(&pk11_mctx);\n\tinitialized = false;\n\treturn (ret);\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":221999,"func":"void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) {\n  if (!static_cast<RenderViewHostImpl*>(render_view_host)->is_active())\n    return;\n\n  if (delegate_)\n    view_->SetOverscrollControllerEnabled(CanOverscrollContent());\n\n  NotificationService::current()->Notify(\n      NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,\n      Source<WebContents>(this),\n      Details<RenderViewHost>(render_view_host));\n\n  NavigationEntry* entry = controller_.GetPendingEntry();\n  if (entry && entry->IsViewSourceMode()) {\n    render_view_host->Send(\n        new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID()));\n  }\n\n  view_->RenderViewCreated(render_view_host);\n\n  FOR_EACH_OBSERVER(\n      WebContentsObserver, observers_, RenderViewCreated(render_view_host));\n}\n","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":138681,"func":"UpstreamDrainManager& Config::drainManager() {\n  return upstream_drain_manager_slot_->getTyped<UpstreamDrainManager>();\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":273475,"func":"static void afiucv_pm_complete(struct device *dev)\n{\n#ifdef CONFIG_PM_DEBUG\n\tprintk(KERN_WARNING \"afiucv_pm_complete\\n\");\n#endif\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":386944,"func":"static int vidioc_g_tuner(struct file *file, void *priv,\n\t\t\t\tstruct v4l2_tuner *vt)\n{\n\tstruct usb_usbvision *usbvision = video_drvdata(file);\n\n\tif (vt->index)\t\/* Only tuner 0 *\/\n\t\treturn -EINVAL;\n\tif (vt->type == V4L2_TUNER_RADIO)\n\t\tstrcpy(vt->name, \"Radio\");\n\telse\n\t\tstrcpy(vt->name, \"Television\");\n\n\t\/* Let clients fill in the remainder of this struct *\/\n\tcall_all(usbvision, tuner, g_tuner, vt);\n\n\treturn 0;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":154999,"func":"void nego_set_negotiation_enabled(rdpNego* nego, BOOL NegotiateSecurityLayer)\n{\n\tWLog_DBG(TAG, \"Enabling security layer negotiation: %s\",\n\t         NegotiateSecurityLayer ? \"TRUE\" : \"FALSE\");\n\tnego->NegotiateSecurityLayer = NegotiateSecurityLayer;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":467846,"func":"static void io_free_req_deferred(struct io_kiocb *req)\n{\n\treq->task_work.func = io_put_req_deferred_cb;\n\tif (unlikely(io_req_task_work_add(req)))\n\t\tio_req_task_work_add_fallback(req, io_put_req_deferred_cb);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":182091,"func":"    virtual void TearDown()\n    {\n    }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":241031,"func":"void esp_dma_enable(ESPState *s, int irq, int level)\n{\n    if (level) {\n        s->dma_enabled = 1;\n        trace_esp_dma_enable();\n        if (s->dma_cb) {\n            s->dma_cb(s);\n            s->dma_cb = NULL;\n        }\n    } else {\n        trace_esp_dma_disable();\n        s->dma_enabled = 0;\n    }\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":397898,"func":"static void check_query_changes(IRC_SERVER_REC *server, const char *nick,\n\t\t\t\tconst char *address, const char *target)\n{\n\tQUERY_REC *query;\n\n\tif (server_ischannel(SERVER(server), target))\n\t\treturn;\n\n\tquery = irc_query_find(server, nick);\n\tif (query == NULL)\n\t\treturn;\n\n\tif (g_strcmp0(query->name, nick) != 0) {\n\t\t\/* upper\/lowercase chars in nick changed *\/\n\t\tquery_change_nick(query, nick);\n\t}\n\n\tif (address != NULL && (query->address == NULL ||\n\t\t\t\tg_strcmp0(query->address, address) != 0)) {\n                \/* host changed *\/\n\t\tquery_change_address(query, address);\n\t}\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":70159,"func":"static Jsi_RC NumberConstructor(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n    Jsi_Value **ret, Jsi_Func *funcPtr)\n{\n    if (Jsi_FunctionIsConstructor(funcPtr)) {\n        Jsi_Number nv = 0.0;\n        Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, 0);\n        if (v) {\n            Jsi_ValueToNumber(interp, v);\n            nv = v->d.num;\n        }\n        _this->d.obj->ot = JSI_OT_NUMBER;\n        _this->d.obj->d.num = nv;\n        Jsi_ValueToObject(interp, _this);\n        Jsi_ValueMakeNumber(interp, ret, nv);\n        return JSI_OK;\n    }\n    Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, 0);\n    if (v) {\n        Jsi_ValueToNumber(interp, v);\n        Jsi_ValueDup2(interp, ret, v);\n        Jsi_ValueToObject(interp, *ret);\n        return JSI_OK;\n    }\n    Jsi_ValueMakeNumber(interp, ret, 0.0);\n    return JSI_OK;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":8130,"func":"static Variant HHVM_FUNCTION(bcsqrt, const String& operand,\n                             int64_t scale \/* = -1 *\/) {\n  if (scale < 0) scale = BCG(bc_precision);\n  bc_num result;\n  bc_init_num(&result);\n  SCOPE_EXIT {\n    bc_free_num(&result);\n  };\n  php_str2num(&result, (char*)operand.data());\n  Variant ret;\n  if (bc_sqrt(&result, scale) != 0) {\n    if (result->n_scale > scale) {\n      result->n_scale = scale;\n    }\n    ret = String(bc_num2str(result), AttachString);\n  } else {\n    raise_warning(\"Square root of negative number\");\n  }\n  return ret;\n}","target":1,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":271382,"func":"static double y2scr_pos(ASS_Renderer *render_priv, double y)\n{\n    return y * render_priv->orig_height \/ render_priv->track->PlayResY +\n        render_priv->settings.top_margin;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":445653,"func":"  static void commitReservation(Buffer::RawSlice* iovecs, uint64_t num_iovecs, OwnedImpl& buffer) {\n    buffer.commit(iovecs, num_iovecs);\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":246201,"func":"bool Element::rareDataChildrenAffectedByFirstChildRules() const\n{\n    ASSERT(hasRareData());\n    return elementRareData()->childrenAffectedByFirstChildRules();\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":511481,"func":"expand_string_to_string_internal (string, quoted, func)\n     char *string;\n     int quoted;\n     EXPFUNC *func;\n{\n  WORD_LIST *list;\n  char *ret;\n\n  if (string == 0 || *string == '\\0')\n    return ((char *)NULL);\n\n  list = (*func) (string, quoted);\n  if (list)\n    {\n      ret = string_list (list);\n      dispose_words (list);\n    }\n  else\n    ret = (char *)NULL;\n\n  return (ret);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":251156,"func":"bool on_tty(void) {\n\n        \/* We check both stdout and stderr, so that situations where pipes on the shell are used are reliably\n         * recognized, regardless if only the output or the errors are piped to some place. Since on_tty() is generally\n         * used to default to a safer, non-interactive, non-color mode of operation it's probably good to be defensive\n         * here, and check for both. Note that we don't check for STDIN_FILENO, because it should fine to use fancy\n         * terminal functionality when outputting stuff, even if the input is piped to us. *\/\n\n        if (cached_on_tty < 0)\n                cached_on_tty =\n                        isatty(STDOUT_FILENO) > 0 &&\n                        isatty(STDERR_FILENO) > 0;\n\n        return cached_on_tty;\n}\n","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":230953,"func":"void LogRendererKillCrashKeys(const GURL& site_url) {\n  static auto* site_url_key = base::debug::AllocateCrashKeyString(\n      \"current_site_url\", base::debug::CrashKeySize::Size64);\n  base::debug::SetCrashKeyString(site_url_key, site_url.spec());\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":226997,"func":"void FetchManager::Loader::PerformNetworkError(const String& message) {\n  Failed(message);\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":292141,"func":"COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)\n{\n\tsigset_t set;\n\tint err = do_sigpending(&set, sizeof(old_sigset_t)); \n\tif (err == 0)\n\t\tif (copy_to_user(set32, &set, sizeof(old_sigset_t)))\n\t\t\terr = -EFAULT;\n\treturn err;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":374837,"func":"_equalBooleanTest(const BooleanTest *a, const BooleanTest *b)\n{\n\tCOMPARE_NODE_FIELD(arg);\n\tCOMPARE_SCALAR_FIELD(booltesttype);\n\n\treturn true;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":261461,"func":"static bool bpf_map_ptr_unpriv(const struct bpf_insn_aux_data *aux)\n{\n\treturn aux->map_ptr_state & BPF_MAP_PTR_UNPRIV;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":401999,"func":"xmlCopyNotation(xmlNotationPtr nota) {\n    xmlNotationPtr cur;\n\n    cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));\n    if (cur == NULL) {\n\txmlVErrMemory(NULL, \"malloc failed\");\n\treturn(NULL);\n    }\n    if (nota->name != NULL)\n\tcur->name = xmlStrdup(nota->name);\n    else\n\tcur->name = NULL;\n    if (nota->PublicID != NULL)\n\tcur->PublicID = xmlStrdup(nota->PublicID);\n    else\n\tcur->PublicID = NULL;\n    if (nota->SystemID != NULL)\n\tcur->SystemID = xmlStrdup(nota->SystemID);\n    else\n\tcur->SystemID = NULL;\n    return(cur);\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":23836,"func":"char * Curl_checkheaders ( const struct connectdata * conn , const char * thisheader ) {\n struct curl_slist * head ;\n size_t thislen = strlen ( thisheader ) ;\n struct Curl_easy * data = conn -> data ;\n for ( head = data -> set . headers ;\n head ;\n head = head -> next ) {\n if ( Curl_raw_nequal ( head -> data , thisheader , thislen ) ) return head -> data ;\n }\n return NULL ;\n }","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":503202,"func":"TEST_F(OptimizePipeline, ExclusionProjectThenProjectPushDown) {\n    auto pipeline = Pipeline::parse(\n        makeVector(fromjson(\"{$_internalUnpackBucket: { exclude: [], timeField: 'time',\"\n                            \"metaField: 'myMeta', bucketMaxSpanSeconds: 3600}}\"),\n                   fromjson(\"{$project: {myMeta: 0}}\"),\n                   fromjson(\"{$project: {myMeta: 1, a: 1, _id: 0}}\")),\n        getExpCtx());\n    ASSERT_EQ(3u, pipeline->getSources().size());\n\n    pipeline->optimizePipeline();\n\n    \/\/ We should push down the exclusion project on the metaField then internalize the remaining\n    \/\/ project.\n    auto serialized = pipeline->serializeToBson();\n    ASSERT_EQ(2u, serialized.size());\n    ASSERT_BSONOBJ_EQ(fromjson(\"{$project: {meta: false, _id: true}}\"), serialized[0]);\n    ASSERT_BSONOBJ_EQ(\n        fromjson(\"{$_internalUnpackBucket: { include: ['a', 'myMeta'], timeField: 'time', \"\n                 \"metaField: 'myMeta', bucketMaxSpanSeconds: 3600}}\"),\n        serialized[1]);\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":195269,"func":"void Browser::OnContentSettingsChange(TabContents* source) {\n  if (source == GetSelectedTabContents())\n    window_->GetLocationBar()->UpdateContentSettingsIcons();\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":267197,"func":"set_arglist(char_u *str)\n{\n    do_arglist(str, AL_SET, 0, FALSE);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":357413,"func":"static struct audit_watch *audit_dupe_watch(struct audit_watch *old)\n{\n\tchar *path;\n\tstruct audit_watch *new;\n\n\tpath = kstrdup(old->path, GFP_KERNEL);\n\tif (unlikely(!path))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tnew = audit_init_watch(path);\n\tif (IS_ERR(new)) {\n\t\tkfree(path);\n\t\tgoto out;\n\t}\n\n\tnew->dev = old->dev;\n\tnew->ino = old->ino;\n\tget_inotify_watch(&old->parent->wdata);\n\tnew->parent = old->parent;\n\nout:\n\treturn new;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":66528,"func":"static inline char *upcase_string(char *dst, size_t dst_size, const char *src)\n{\n    int i;\n    for (i = 0; src[i] && i < dst_size-1; i++)\n        dst[i] = av_toupper(src[i]);\n    dst[i] = 0;\n    return dst;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":138414,"func":"static int watchdog_nmi_enable(int cpu) { return 0; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":433566,"func":"static u32 iwl_trans_pcie_get_cmdlen(struct iwl_trans *trans, void *tfd)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tu32 cmdlen = 0;\n\tint i;\n\n\tfor (i = 0; i < trans_pcie->max_tbs; i++)\n\t\tcmdlen += iwl_pcie_tfd_tb_get_len(trans, tfd, i);\n\n\treturn cmdlen;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":59144,"func":"static inline bool nested_cpu_has2(struct vmcs12 *vmcs12, u32 bit)\n{\n\treturn (vmcs12->cpu_based_vm_exec_control &\n\t\t\tCPU_BASED_ACTIVATE_SECONDARY_CONTROLS) &&\n\t\t(vmcs12->secondary_vm_exec_control & bit);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":172484,"func":"void VariationsService::RecordLastFetchTime() {\n  DCHECK(thread_checker_.CalledOnValidThread());\n\n  if (local_state_) {\n    local_state_->SetInt64(prefs::kVariationsLastFetchTime,\n                           base::Time::Now().ToInternalValue());\n  }\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":119070,"func":"void Tensor::FillDescription(TensorDescription* description) const {\n  description->set_dtype(dtype());\n  shape().AsProto(description->mutable_shape());\n  if (buf_ != nullptr && buf_->data() != nullptr) {\n    buf_->FillAllocationDescription(\n        description->mutable_allocation_description());\n  }\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":78868,"func":"static struct net_device_stats *veth_get_stats(struct net_device *dev)\n{\n\tstruct veth_priv *priv;\n\tint cpu;\n\tstruct veth_net_stats *stats, total = {0};\n\n\tpriv = netdev_priv(dev);\n\n\tfor_each_possible_cpu(cpu) {\n\t\tstats = per_cpu_ptr(priv->stats, cpu);\n\n\t\ttotal.rx_packets += stats->rx_packets;\n\t\ttotal.tx_packets += stats->tx_packets;\n\t\ttotal.rx_bytes   += stats->rx_bytes;\n\t\ttotal.tx_bytes   += stats->tx_bytes;\n\t\ttotal.tx_dropped += stats->tx_dropped;\n\t\ttotal.rx_dropped += stats->rx_dropped;\n\t}\n\tdev->stats.rx_packets = total.rx_packets;\n\tdev->stats.tx_packets = total.tx_packets;\n\tdev->stats.rx_bytes   = total.rx_bytes;\n\tdev->stats.tx_bytes   = total.tx_bytes;\n\tdev->stats.tx_dropped = total.tx_dropped;\n\tdev->stats.rx_dropped = total.rx_dropped;\n\n\treturn &dev->stats;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":423125,"func":"static void tcp_clamp_window(struct sock *sk)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\n\ticsk->icsk_ack.quick = 0;\n\n\tif (sk->sk_rcvbuf < sysctl_tcp_rmem[2] &&\n\t    !(sk->sk_userlocks & SOCK_RCVBUF_LOCK) &&\n\t    !sk_under_memory_pressure(sk) &&\n\t    sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0)) {\n\t\tsk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc),\n\t\t\t\t    sysctl_tcp_rmem[2]);\n\t}\n\tif (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf)\n\t\ttp->rcv_ssthresh = min(tp->window_clamp, 2U * tp->advmss);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":146973,"func":"njs_typed_array_get_u8(const void *a)\n{\n    return *(const uint8_t *) a;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":250505,"func":"PassOwnPtrWillBeRawPtr<LocalFileSystem> LocalFileSystem::create(PassOwnPtr<FileSystemClient> client)\n{\n    return adoptPtrWillBeNoop(new LocalFileSystem(client));\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":419233,"func":"input_osc_11(struct input_ctx *ictx, const char *p)\n{\n\tstruct window_pane\t*wp = ictx->wp;\n\tu_int\t\t\t r, g, b;\n\n\tif (sscanf(p, \"rgb:%2x\/%2x\/%2x\", &r, &g, &b) != 3)\n\t    goto bad;\n\n\twp->colgc.bg = colour_join_rgb(r, g, b);\n\twp->flags |= PANE_REDRAW;\n\n\treturn;\n\nbad:\n\tlog_debug(\"bad OSC 11: %s\", p);\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":394286,"func":"BGD_DECLARE(int) gdImageColorExact (gdImagePtr im, int r, int g, int b)\n{\n  return gdImageColorExactAlpha (im, r, g, b, gdAlphaOpaque);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":391213,"func":"static void rng_backend_free_requests(RngBackend *s)\n{\n    GSList *i;\n\n    for (i = s->requests; i; i = i->next) {\n        rng_backend_free_request(i->data);\n    }\n\n    g_slist_free(s->requests);\n    s->requests = NULL;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":97383,"func":"    \/\/! Load image from a BMP file \\newinstance.\n    static CImg<T> get_load_bmp(std::FILE *const file) {\n      return CImg<T>().load_bmp(file);","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":169180,"func":"  std::wstring LocaleWindowCaptionFromPageTitle(\n      const std::wstring& expected_title) {\n    std::wstring page_title = WindowCaptionFromPageTitle(expected_title);\n#if defined(OS_WIN)\n    std::string locale = g_browser_process->GetApplicationLocale();\n    if (base::i18n::GetTextDirectionForLocale(locale.c_str()) ==\n        base::i18n::RIGHT_TO_LEFT) {\n      base::i18n::WrapStringWithLTRFormatting(&page_title);\n    }\n\n    return page_title;\n#else\n    return page_title;\n#endif\n  }\n","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":444834,"func":"void StreamEncoderImpl::encodeHeader(const char* key, uint32_t key_size, const char* value,\n                                     uint32_t value_size) {\n\n  ASSERT(key_size > 0);\n\n  connection_.copyToBuffer(key, key_size);\n  connection_.addCharToBuffer(':');\n  connection_.addCharToBuffer(' ');\n  connection_.copyToBuffer(value, value_size);\n  connection_.addToBuffer(CRLF);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":423213,"func":" *\/\nstruct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,\n\t\t\t\t\tstruct rtnl_link_stats64 *storage)\n{\n\tconst struct net_device_ops *ops = dev->netdev_ops;\n\n\tif (ops->ndo_get_stats64) {\n\t\tmemset(storage, 0, sizeof(*storage));\n\t\tops->ndo_get_stats64(dev, storage);\n\t} else if (ops->ndo_get_stats) {\n\t\tnetdev_stats_to_stats64(storage, ops->ndo_get_stats(dev));\n\t} else {\n\t\tnetdev_stats_to_stats64(storage, &dev->stats);\n\t}\n\tstorage->rx_dropped += atomic_long_read(&dev->rx_dropped);\n\treturn storage;","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":331275,"func":"static void set_dirty_tracking(void)\n\n{\n\n    BlkMigDevState *bmds;\n\n\n\n    QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {\n\n        bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE);\n\n    }\n\n}\n","target":1,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":51186,"func":"static void srpt_unmap_sg_to_ib_sge(struct srpt_rdma_ch *ch,\n\t\t\t\t    struct srpt_send_ioctx *ioctx)\n{\n\tstruct scatterlist *sg;\n\tenum dma_data_direction dir;\n\n\tBUG_ON(!ch);\n\tBUG_ON(!ioctx);\n\tBUG_ON(ioctx->n_rdma && !ioctx->rdma_wrs);\n\n\twhile (ioctx->n_rdma)\n\t\tkfree(ioctx->rdma_wrs[--ioctx->n_rdma].wr.sg_list);\n\n\tkfree(ioctx->rdma_wrs);\n\tioctx->rdma_wrs = NULL;\n\n\tif (ioctx->mapped_sg_count) {\n\t\tsg = ioctx->sg;\n\t\tWARN_ON(!sg);\n\t\tdir = ioctx->cmd.data_direction;\n\t\tBUG_ON(dir == DMA_NONE);\n\t\tib_dma_unmap_sg(ch->sport->sdev->device, sg, ioctx->sg_cnt,\n\t\t\t\topposite_dma_dir(dir));\n\t\tioctx->mapped_sg_count = 0;\n\t}\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":477811,"func":"    CImg<T>& operator-=(const t value) {\n      if (is_empty()) return *this;\n      cimg_openmp_for(*this,*ptr - value,524288);\n      return *this;\n    }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":180968,"func":"  void InitializeSpdySsl() {\n    ssl_data_->SetNextProto(kProtoSPDY2);\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":510275,"func":"my_decimal *Item_ref::val_decimal_result(my_decimal *decimal_value)\n{\n  if (result_field)\n  {\n    if ((null_value= result_field->is_null()))\n      return 0;\n    return result_field->val_decimal(decimal_value);\n  }\n  return val_decimal(decimal_value);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":475660,"func":"static void nft_netdev_unregister_hooks(struct net *net,\n\t\t\t\t\tstruct list_head *hook_list)\n{\n\tstruct nft_hook *hook;\n\n\tlist_for_each_entry(hook, hook_list, list)\n\t\tnf_unregister_net_hook(net, &hook->ops);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":68003,"func":"static int handle_triple_fault(struct kvm_vcpu *vcpu)\n{\n\tvcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;\n\treturn 0;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":477478,"func":"static void tcf_block_owner_del(struct tcf_block *block,\n\t\t\t\tstruct Qdisc *q,\n\t\t\t\tenum flow_block_binder_type binder_type)\n{\n\tstruct tcf_block_owner_item *item;\n\n\tlist_for_each_entry(item, &block->owner_list, list) {\n\t\tif (item->q == q && item->binder_type == binder_type) {\n\t\t\tlist_del(&item->list);\n\t\t\tkfree(item);\n\t\t\treturn;\n\t\t}\n\t}\n\tWARN_ON(1);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":421396,"func":"add_to_client(struct i915_request *rq, struct drm_file *file)\n{\n\trq->file_priv = file->driver_priv;\n\tlist_add_tail(&rq->client_link, &rq->file_priv->mm.request_list);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":380026,"func":"static int ZEND_FASTCALL  ZEND_BW_NOT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\n\n\tbitwise_not_function(&EX_T(opline->result.u.var).tmp_var,\n\t\t_get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC) TSRMLS_CC);\n\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":360033,"func":"nautilus_file_get_parent_location (NautilusFile *file) \n{\n\tg_assert (NAUTILUS_IS_FILE (file));\n\t\n\tif (nautilus_file_is_self_owned (file)) {\n\t\t\/* Callers expect an empty string, not a NULL. *\/\n\t\treturn NULL;\n\t}\n\n\treturn nautilus_directory_get_location (file->details->directory);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":251339,"func":"static void overloadedStaticMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    ExceptionState exceptionState(ExceptionState::ExecutionContext, \"overloadedStaticMethod\", \"TestObjectPython\", info.Holder(), info.GetIsolate());\n    if (UNLIKELY(info.Length() < 2)) {\n        exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));\n        exceptionState.throwIfNeeded();\n        return;\n    }\n    V8TRYCATCH_EXCEPTION_VOID(int, longArg1, toInt32(info[0], exceptionState), exceptionState);\n    V8TRYCATCH_EXCEPTION_VOID(int, longArg2, toInt32(info[1], exceptionState), exceptionState);\n    TestObjectPython::overloadedStaticMethod(longArg1, longArg2);\n}\n","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":415860,"func":"bool switch_to_ns(pid_t pid, const char *ns) {\n\tint fd, ret;\n\tchar nspath[MAXPATHLEN];\n\n\t\/* Switch to new ns *\/\n\tret = snprintf(nspath, MAXPATHLEN, \"\/proc\/%d\/ns\/%s\", pid, ns);\n\tif (ret < 0 || ret >= MAXPATHLEN)\n\t\treturn false;\n\n\tfd = open(nspath, O_RDONLY);\n\tif (fd < 0) {\n\t\tSYSERROR(\"Failed to open %s\", nspath);\n\t\treturn false;\n\t}\n\n\tret = setns(fd, 0);\n\tif (ret) {\n\t\tSYSERROR(\"Failed to set process %d to %s of %d.\", pid, ns, fd);\n\t\tclose(fd);\n\t\treturn false;\n\t}\n\n\tclose(fd);\n\treturn true;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":509941,"func":"TIFFjpeg_alloc_sarray(JPEGState* sp, int pool_id,\n\t\t      JDIMENSION samplesperrow, JDIMENSION numrows)\n{\n\treturn CALLJPEG(sp, (JSAMPARRAY) NULL,\n\t    (*sp->cinfo.comm.mem->alloc_sarray)\n\t\t(&sp->cinfo.comm, pool_id, samplesperrow, numrows));\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":259264,"func":"static inline void blk_pm_put_request(struct request *rq) {}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":234055,"func":"void VideoCaptureManager::OnDeviceLaunchAborted() {\n  EmitLogMessage(\"Launching device has been aborted.\", 1);\n  device_start_request_queue_.pop_front();\n  ProcessDeviceStartRequestQueue();\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":364130,"func":"void rfbScheduleCopyRect(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2,int dx,int dy)\n{\n  sraRegionPtr region = sraRgnCreateRect(x1,y1,x2,y2);\n  rfbScheduleCopyRegion(screen,region,dx,dy);\n  sraRgnDestroy(region);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":172774,"func":"bool deleteFile(const String& path)\n{\n    String filename = path;\n    return !!DeleteFileW(filename.charactersWithNullTermination());\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":32614,"func":"TEST_P(DownstreamProtocolIntegrationTest, MissingHeadersLocalReplyWithBody) {\n  useAccessLog(\"%RESPONSE_CODE_DETAILS%\");\n  config_helper_.prependFilter(\"{ name: invalid-header-filter, typed_config: { \\\"@type\\\": \"\n                               \"type.googleapis.com\/google.protobuf.Empty } }\");\n  initialize();\n  codec_client_ = makeHttpConnection(lookupPort(\"http\"));\n\n  \/\/ Missing method\n  auto response =\n      codec_client_->makeRequestWithBody(Http::TestRequestHeaderMapImpl{{\":method\", \"GET\"},\n                                                                        {\":path\", \"\/test\/long\/url\"},\n                                                                        {\":scheme\", \"http\"},\n                                                                        {\":authority\", \"host\"},\n                                                                        {\"remove-method\", \"yes\"},\n                                                                        {\"send-reply\", \"yes\"}},\n                                         1024);\n  ASSERT_TRUE(response->waitForEndStream());\n  EXPECT_TRUE(response->complete());\n  EXPECT_EQ(\"200\", response->headers().getStatusValue());\n  EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr(\"invalid_header_filter_ready\\n\"));\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":265516,"func":"static void ParaNdis_RemoveDriverOKStatus(PPARANDIS_ADAPTER pContext )\n{\n    VirtIODeviceRemoveStatus(pContext->IODevice, VIRTIO_CONFIG_S_DRIVER_OK);\n\n    KeMemoryBarrier();\n\n    pContext->bDeviceInitialized = FALSE;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":442247,"func":"applyLut (const unsigned short lut[USHORT_RANGE],\n\t  unsigned short data[\/*nData*\/],\n\t  int nData)\n{\n    for (int i = 0; i < nData; ++i)\n\tdata[i] = lut[data[i]];\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":503979,"func":"static void *_sqlite_open(char *host __attribute__((unused)),\n\t\t\t  char *port __attribute__((unused)),\n\t\t\t  int usessl __attribute__((unused)),\n\t\t\t  const char *user __attribute__((unused)),\n\t\t\t  const char *password __attribute__((unused)),\n\t\t\t  const char *database, const sasl_utils_t *utils)\n{\n    int rc;\n    sqlite *db;\n    char *zErrMsg = NULL;\n\n    db = sqlite_open(database, 0, &zErrMsg);\n    if (db == NULL) {\n\tutils->log(utils->conn, SASL_LOG_ERR, \"sql plugin: %s\", zErrMsg);\n\tsqlite_freemem (zErrMsg);\n\treturn NULL;\n    }\n\n    rc = sqlite_exec(db, \"PRAGMA empty_result_callbacks = ON\", NULL, NULL, &zErrMsg);\n    if (rc != SQLITE_OK) {\n\tutils->log(utils->conn, SASL_LOG_ERR, \"sql plugin: %s\", zErrMsg);\n\tsqlite_freemem (zErrMsg);\n\tsqlite_close(db);\n\treturn NULL;\n    }\n\n    return (void*)db;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":156316,"func":"test_asnprintf ()\n{\n  test_function (asnprintf);\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":480771,"func":"static int kgdb_io_ready(int print_wait)\n{\n\tif (!dbg_io_ops)\n\t\treturn 0;\n\tif (kgdb_connected)\n\t\treturn 1;\n\tif (atomic_read(&kgdb_setting_breakpoint))\n\t\treturn 1;\n\tif (print_wait) {\n#ifdef CONFIG_KGDB_KDB\n\t\tif (!dbg_kdb_mode)\n\t\t\tpr_crit(\"waiting... or $3#33 for KDB\\n\");\n#else\n\t\tpr_crit(\"Waiting for remote debugger\\n\");\n#endif\n\t}\n\treturn 1;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":57022,"func":"nghttp2_stream *nghttp2_session_find_stream(nghttp2_session *session,\n                                            int32_t stream_id) {\n  if (stream_id == 0) {\n    return &session->root;\n  }\n\n  return nghttp2_session_get_stream_raw(session, stream_id);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":431131,"func":"static Status _extractRoleDocumentElements(const BSONObj& roleObject,\n                                           BSONElement* roleNameElement,\n                                           BSONElement* roleSourceElement) {\n    *roleNameElement = roleObject[ROLE_NAME_FIELD_NAME];\n    *roleSourceElement = roleObject[ROLE_DB_FIELD_NAME];\n\n    if (roleNameElement->type() != String || roleNameElement->valueStringData().empty()) {\n        return Status(ErrorCodes::UnsupportedFormat, \"Role names must be non-empty strings\");\n    }\n    if (roleSourceElement->type() != String || roleSourceElement->valueStringData().empty()) {\n        return Status(ErrorCodes::UnsupportedFormat, \"Role db must be non-empty strings\");\n    }\n\n    return Status::OK();\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":458439,"func":"handle_alg_ctl(struct conntrack *ct, const struct conn_lookup_ctx *ctx,\n               struct dp_packet *pkt, enum ct_alg_ctl_type ct_alg_ctl,\n               struct conn *conn, long long now, bool nat)\n{\n    \/* ALG control packet handling with expectation creation. *\/\n    if (OVS_UNLIKELY(alg_helpers[ct_alg_ctl] && conn && conn->alg)) {\n        ovs_mutex_lock(&conn->lock);\n        alg_helpers[ct_alg_ctl](ct, ctx, pkt, conn, now, CT_FTP_CTL_INTEREST,\n                                nat);\n        ovs_mutex_unlock(&conn->lock);\n    }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":419674,"func":"static int get_process_ns(pid_t pid, const char *namespace, ino_t *ns) {\n        const char *p;\n        struct stat stbuf;\n        _cleanup_close_ int proc_ns_dir_fd;\n\n        p = procfs_file_alloca(pid, \"ns\");\n\n        proc_ns_dir_fd = open(p, O_DIRECTORY | O_CLOEXEC | O_RDONLY);\n        if (proc_ns_dir_fd < 0)\n                return -errno;\n\n        if (fstatat(proc_ns_dir_fd, namespace, &stbuf, \/* flags *\/0) < 0)\n                return -errno;\n\n        *ns = stbuf.st_ino;\n        return 0;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":478377,"func":"    CImg<T>& set_matrix_at(const CImg<t>& mat, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) {\n      return set_vector_at(mat,x,y,z);\n    }","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":486764,"func":"void KrecipesView::translate()\n{\n\tbutton0->setTitle( i18n( \"Find\/Edit Recipes\" ) );\n\tbutton1->setTitle( i18n( \"Shopping List\" ) );\n\tbutton2->setTitle( i18n( \"Ingredients\" ) );\n\tbutton3->setTitle( i18n( \"Properties\" ) );\n\tbutton4->setTitle( i18n( \"Units\" ) );\n\tbutton9->setTitle( i18n( \"Preparation Methods\" ) );\n\tbutton5->setTitle( i18n( \"Categories\" ) );\n\tbutton6->setTitle( i18n( \"Authors\" ) );\n\tbutton7->setTitle( i18n( \"Diet Helper\" ) );\n\tbutton8->setTitle( i18n( \"Ingredient Matcher\" ) );\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":58775,"func":"crm_initiate_client_tls_handshake(void *session_data, int timeout_ms)\n{\n    int rc = 0;\n    int pollrc = 0;\n    time_t start = time(NULL);\n    gnutls_session *session = session_data;\n\n    do {\n        rc = gnutls_handshake(*session);\n        if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) {\n            pollrc = crm_recv_remote_ready(session, TRUE, 1000);\n            if (pollrc < 0) {\n                \/* poll returned error, there is no hope *\/\n                rc = -1;\n            }\n        }\n    } while (((time(NULL) - start) < (timeout_ms\/1000)) &&\n            (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN));\n\n    return rc;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":239673,"func":"GDataEntry* GDataDirectoryService::FindEntryByPathSync(\n    const FilePath& file_path) {\n  if (file_path == root_->GetFilePath())\n    return root_.get();\n\n  std::vector<FilePath::StringType> components;\n  file_path.GetComponents(&components);\n  GDataDirectory* current_dir = root_.get();\n\n  for (size_t i = 1; i < components.size() && current_dir; ++i) {\n    GDataEntry* entry = current_dir->FindChild(components[i]);\n    if (!entry)\n      return NULL;\n\n    if (i == components.size() - 1)  \/\/ Last component.\n      return entry;\n    else\n      current_dir = entry->AsGDataDirectory();\n  }\n  return NULL;\n}\n","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":456457,"func":"static inline int vt_unbind(struct con_driver *con)\n{\n\treturn 0;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":517792,"func":"Field *find_field_in_table_sef(TABLE *table, const char *name)\n{\n  Field **field_ptr;\n  if (table->s->name_hash.records)\n  {\n    field_ptr= (Field**)my_hash_search(&table->s->name_hash,(uchar*) name,\n                                       strlen(name));\n    if (field_ptr)\n    {\n      \/*\n        field_ptr points to field in TABLE_SHARE. Convert it to the matching\n        field in table\n      *\/\n      field_ptr= (table->field + (field_ptr - table->s->field));\n    }\n  }\n  else\n  {\n    if (!(field_ptr= table->field))\n      return (Field *)0;\n    for (; *field_ptr; ++field_ptr)\n      if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name.str,\n                         name))\n        break;\n  }\n  if (field_ptr)\n    return *field_ptr;\n  else\n    return (Field *)0;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":390440,"func":"X509::X509(const char* i, size_t iSz, const char* s, size_t sSz,\n           const char* b, int bSz, const char* a, int aSz, int issPos,\n           int issLen, int subPos, int subLen)\n    : issuer_(i, iSz, issPos, issLen), subject_(s, sSz, subPos, subLen),\n      beforeDate_(b, bSz), afterDate_(a, aSz)\n{}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":70000,"func":"qboolean CL_ConnectedToRemoteServer( void ) {\n\treturn (qboolean)( com_sv_running && !com_sv_running->integer && cls.state >= CA_CONNECTED && !clc.demoplaying );\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":470057,"func":"h2_rx_priority(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)\n{\n\n\tCHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);\n\tASSERT_RXTHR(h2);\n\tCHECK_OBJ_ORNULL(r2, H2_REQ_MAGIC);\n\treturn (0);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":271012,"func":"static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,\n\t\tconst struct ipc_ops *ops, struct ipc_params *params)\n{\n\tint err;\n\n\tdown_write(&ids->rwsem);\n\terr = ops->getnew(ns, params);\n\tup_write(&ids->rwsem);\n\treturn err;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":504976,"func":"rsvg_filter_primitive_gaussian_blur_free (RsvgNode * self)\n{\n    RsvgFilterPrimitiveGaussianBlur *upself;\n\n    upself = (RsvgFilterPrimitiveGaussianBlur *) self;\n    g_string_free (upself->super.result, TRUE);\n    g_string_free (upself->super.in, TRUE);\n    _rsvg_node_free (self);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":59609,"func":"PackLinuxElf64::check_pt_load(Elf64_Phdr const *const phdr)\n{\n    u64_t filesz = get_te64(&phdr->p_filesz);\n    u64_t offset = get_te64(&phdr->p_offset), offend = filesz + offset;\n    u64_t vaddr  = get_te64(&phdr->p_vaddr);\n    u64_t paddr  = get_te64(&phdr->p_paddr);\n    u64_t align  = get_te64(&phdr->p_align);\n\n    if ((-1+ align) & (paddr ^ vaddr)\n    ||  (u64_t)file_size <= (u64_t)offset\n    ||  (u64_t)file_size <  (u64_t)offend\n    ||  (u64_t)file_size <= (u64_t)filesz) {\n        char msg[50]; snprintf(msg, sizeof(msg), \"bad PT_LOAD phdr[%u]\",\n            (unsigned)(phdr - phdri));\n        throwCantPack(msg);\n    }\n    return offset;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":107479,"func":"void print_event_filter(struct trace_event_file *file, struct trace_seq *s)\n{\n\tstruct event_filter *filter = event_filter(file);\n\n\tif (filter && filter->filter_string)\n\t\ttrace_seq_printf(s, \"%s\\n\", filter->filter_string);\n\telse\n\t\ttrace_seq_puts(s, \"none\\n\");\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":103757,"func":"static inline int check_target(struct arpt_entry *e, const char *name)\n{\n\tstruct xt_entry_target *t = arpt_get_target(e);\n\tstruct xt_tgchk_param par = {\n\t\t.table     = name,\n\t\t.entryinfo = e,\n\t\t.target    = t->u.kernel.target,\n\t\t.targinfo  = t->data,\n\t\t.hook_mask = e->comefrom,\n\t\t.family    = NFPROTO_ARP,\n\t};\n\n\treturn xt_check_target(&par, t->u.target_size - sizeof(*t), 0, false);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":510565,"func":"void item_init(void)\n{\n  item_user_lock_init();\n  uuid_short_init();\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":47704,"func":"void socketRegisterEvents(Socket *socket, OsEvent *event, uint_t eventMask)\n{\n   \/\/Valid socket handle?\n   if(socket != NULL)\n   {\n      \/\/Get exclusive access\n      osAcquireMutex(&netMutex);\n\n      \/\/An user event may have been previously registered...\n      if(socket->userEvent != NULL)\n      {\n         socket->eventMask |= eventMask;\n      }\n      else\n      {\n         socket->eventMask = eventMask;\n      }\n\n      \/\/Suscribe to get notified of events\n      socket->userEvent = event;\n\n#if (TCP_SUPPORT == ENABLED)\n      \/\/Handle TCP specific events\n      if(socket->type == SOCKET_TYPE_STREAM)\n      {\n         tcpUpdateEvents(socket);\n      }\n#endif\n#if (UDP_SUPPORT == ENABLED)\n      \/\/Handle UDP specific events\n      if(socket->type == SOCKET_TYPE_DGRAM)\n      {\n         udpUpdateEvents(socket);\n      }\n#endif\n#if (RAW_SOCKET_SUPPORT == ENABLED)\n      \/\/Handle events that are specific to raw sockets\n      if(socket->type == SOCKET_TYPE_RAW_IP ||\n         socket->type == SOCKET_TYPE_RAW_ETH)\n      {\n         rawSocketUpdateEvents(socket);\n      }\n#endif\n\n      \/\/Release exclusive access\n      osReleaseMutex(&netMutex);\n   }\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":314457,"func":"void LauncherView::LayoutToIdealBounds() {\n  IdealBounds ideal_bounds;\n  CalculateIdealBounds(&ideal_bounds);\n\n  if (bounds_animator_->IsAnimating())\n    AnimateToIdealBounds();\n  else\n    views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_);\n\n  overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":476456,"func":"static void rtsx_usb_ms_handle_req(struct work_struct *work)\n{\n\tstruct rtsx_usb_ms *host = container_of(work,\n\t\t\tstruct rtsx_usb_ms, handle_req);\n\tstruct rtsx_ucr *ucr = host->ucr;\n\tstruct memstick_host *msh = host->msh;\n\tint rc;\n\n\tif (!host->req) {\n\t\tpm_runtime_get_sync(ms_dev(host));\n\t\tdo {\n\t\t\trc = memstick_next_req(msh, &host->req);\n\t\t\tdev_dbg(ms_dev(host), \"next req %d\\n\", rc);\n\n\t\t\tif (!rc) {\n\t\t\t\tmutex_lock(&ucr->dev_mutex);\n\n\t\t\t\tif (rtsx_usb_card_exclusive_check(ucr,\n\t\t\t\t\t\t\tRTSX_USB_MS_CARD))\n\t\t\t\t\thost->req->error = -EIO;\n\t\t\t\telse\n\t\t\t\t\thost->req->error =\n\t\t\t\t\t\trtsx_usb_ms_issue_cmd(host);\n\n\t\t\t\tmutex_unlock(&ucr->dev_mutex);\n\n\t\t\t\tdev_dbg(ms_dev(host), \"req result %d\\n\",\n\t\t\t\t\t\thost->req->error);\n\t\t\t}\n\t\t} while (!rc);\n\t\tpm_runtime_put_sync(ms_dev(host));\n\t}\n\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":393920,"func":"ext_t_1_wml_10(tvbuff_t *tvb, guint32 value, guint32 str_tbl)\n{\n\tchar *str = wmem_strdup_printf(wmem_packet_scope(), \"Variable substitution - unescaped: '%s'\",\n\t\t\t\t    tvb_get_const_stringz(tvb, str_tbl + value, NULL));\n\treturn str;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":148234,"func":"prepare_viminfo_registers(void)\n{\n     y_read_regs = ALLOC_CLEAR_MULT(yankreg_T, NUM_REGISTERS);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":446353,"func":"virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics)\n{\n    bool ret = false;\n\n    if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE ||\n        graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS)\n        ret = true;\n\n    return ret;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":378670,"func":"static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data,\n\t\t\tsize_t n, off_t offset)\n{\n\tssize_t result;\n\n#if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)\n\tSTART_PROFILE_BYTES(syscall_pwrite, n);\n\tresult = sys_pwrite(fsp->fh->fd, data, n, offset);\n\tEND_PROFILE(syscall_pwrite);\n\n\tif (result == -1 && errno == ESPIPE) {\n\t\t\/* Maintain the fiction that pipes can be sought on. *\/\n\t\tresult = SMB_VFS_WRITE(fsp, data, n);\n\t}\n\n#else \/* HAVE_PWRITE *\/\n\toff_t   curr;\n\tint         lerrno;\n\n\tcurr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);\n\tif (curr == -1) {\n\t\treturn -1;\n\t}\n\n\tif (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {\n\t\treturn -1;\n\t}\n\n\tresult = SMB_VFS_WRITE(fsp, data, n);\n\tlerrno = errno;\n\n\tSMB_VFS_LSEEK(fsp, curr, SEEK_SET);\n\terrno = lerrno;\n\n#endif \/* HAVE_PWRITE *\/\n\n\treturn result;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":52526,"func":"void kvm_arch_pre_destroy_vm(struct kvm *kvm)\n{\n\tkvm_mmu_pre_destroy_vm(kvm);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":249148,"func":"DevToolsWindow::~DevToolsWindow() {\n  content::DevToolsManager::GetInstance()->ClientHostClosing(\n      frontend_host_.get());\n  UpdateBrowserToolbar();\n\n  DevToolsWindows* instances = &g_instances.Get();\n  DevToolsWindows::iterator it(\n      std::find(instances->begin(), instances->end(), this));\n  DCHECK(it != instances->end());\n  instances->erase(it);\n\n  for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin());\n       jobs_it != indexing_jobs_.end(); ++jobs_it) {\n    jobs_it->second->Stop();\n  }\n  indexing_jobs_.clear();\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":424644,"func":"static int _php_mb_regex_globals_ctor(zend_mb_regex_globals *pglobals)\n{\n\tpglobals->default_mbctype = ONIG_ENCODING_UTF8;\n\tpglobals->current_mbctype = ONIG_ENCODING_UTF8;\n\tZVAL_UNDEF(&pglobals->search_str);\n\tpglobals->search_re = (php_mb_regex_t*)NULL;\n\tpglobals->search_pos = 0;\n\tpglobals->search_regs = (OnigRegion*)NULL;\n\tpglobals->regex_default_options = ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE;\n\tpglobals->regex_default_syntax = ONIG_SYNTAX_RUBY;\n\treturn SUCCESS;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":425661,"func":"CpuMpPeimInit (\r\n  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r\n  IN CONST EFI_PEI_SERVICES     **PeiServices\r\n  )\r\n{\r\n  EFI_STATUS           Status;\r\n\r\n  \/\/\r\n  \/\/ For the sake of special initialization needing to be done right after\r\n  \/\/ memory discovery.\r\n  \/\/\r\n  Status = PeiServicesNotifyPpi (&mPostMemNotifyList[0]);\r\n  ASSERT_EFI_ERROR (Status);\r\n\r\n  return Status;\r\n}\r","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":468300,"func":"subject_iface_init (PolkitSubjectIface *subject_iface)\n{\n  subject_iface->hash          = polkit_system_bus_name_hash;\n  subject_iface->equal         = polkit_system_bus_name_equal;\n  subject_iface->to_string     = polkit_system_bus_name_to_string;\n  subject_iface->exists        = polkit_system_bus_name_exists;\n  subject_iface->exists_finish = polkit_system_bus_name_exists_finish;\n  subject_iface->exists_sync   = polkit_system_bus_name_exists_sync;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":81088,"func":"int git_path_cmp(\n\tconst char *name1, size_t len1, int isdir1,\n\tconst char *name2, size_t len2, int isdir2,\n\tint (*compare)(const char *, const char *, size_t))\n{\n\tunsigned char c1, c2;\n\tsize_t len = len1 < len2 ? len1 : len2;\n\tint cmp;\n\n\tcmp = compare(name1, name2, len);\n\tif (cmp)\n\t\treturn cmp;\n\n\tc1 = name1[len];\n\tc2 = name2[len];\n\n\tif (c1 == '\\0' && isdir1)\n\t\tc1 = '\/';\n\n\tif (c2 == '\\0' && isdir2)\n\t\tc2 = '\/';\n\n\treturn (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":115645,"func":"static int crypto_report_shash(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_hash rhash;\n\n\tmemset(&rhash, 0, sizeof(rhash));\n\n\tstrscpy(rhash.type, \"shash\", sizeof(rhash.type));\n\n\trhash.stat_hash_cnt =  atomic64_read(&alg->stats.hash.hash_cnt);\n\trhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen);\n\trhash.stat_err_cnt = atomic64_read(&alg->stats.hash.err_cnt);\n\n\treturn nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":442651,"func":"static inline int hci_proto_disconn_ind(struct hci_conn *conn)\n{\n\tif (conn->type != ACL_LINK && conn->type != LE_LINK)\n\t\treturn HCI_ERROR_REMOTE_USER_TERM;\n\n\treturn l2cap_disconn_ind(conn);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":91515,"func":"static void pipe_destruct(struct sock *sk)\n{\n\tstruct pep_sock *pn = pep_sk(sk);\n\n\tskb_queue_purge(&sk->sk_receive_queue);\n\tskb_queue_purge(&pn->ctrlreq_queue);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":523222,"func":"void LEX::fix_first_select_number()\n{\n  SELECT_LEX *first= first_select_lex();\n  if (first && first->select_number != 1)\n  {\n    uint num= first->select_number;\n    for (SELECT_LEX *sel= all_selects_list;\n         sel;\n         sel= sel->next_select_in_list())\n    {\n      if (sel->select_number < num)\n        sel->select_number++;\n    }\n    first->select_number= 1;\n  }\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":344158,"func":"static inline void preempt_conditional_cli(struct pt_regs *regs)\n{\n\tif (regs->flags & X86_EFLAGS_IF)\n\t\tlocal_irq_disable();\n\tdec_preempt_count();\n}","target":1,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":208238,"func":"  virtual ~InlineLoginUIOAuth2Delegate() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":457805,"func":"static bool __io_uring_cancel_task_requests(struct io_ring_ctx *ctx,\n\t\t\t\t\t    struct task_struct *task,\n\t\t\t\t\t    struct files_struct *files)\n{\n\tbool ret;\n\n\tret = io_uring_cancel_files(ctx, files);\n\tif (!files) {\n\t\tenum io_wq_cancel cret;\n\n\t\tcret = io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb, task, true);\n\t\tif (cret != IO_WQ_CANCEL_NOTFOUND)\n\t\t\tret = true;\n\n\t\t\/* SQPOLL thread does its own polling *\/\n\t\tif (!(ctx->flags & IORING_SETUP_SQPOLL)) {\n\t\t\twhile (!list_empty_careful(&ctx->iopoll_list)) {\n\t\t\t\tio_iopoll_try_reap_events(ctx);\n\t\t\t\tret = true;\n\t\t\t}\n\t\t}\n\n\t\tret |= io_poll_remove_all(ctx, task);\n\t\tret |= io_kill_timeouts(ctx, task);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":294315,"func":"static int disk_events_set_dfl_poll_msecs(const char *val,\n\t\t\t\t\t  const struct kernel_param *kp)\n{\n\tstruct disk_events *ev;\n\tint ret;\n\n\tret = param_set_ulong(val, kp);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tmutex_lock(&disk_events_mutex);\n\n\tlist_for_each_entry(ev, &disk_events, node)\n\t\tdisk_flush_events(ev->disk, 0);\n\n\tmutex_unlock(&disk_events_mutex);\n\n\treturn 0;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":140543,"func":"\tNick(User* source, const std::string& newnick)\n\t\t: ClientProtocol::Message(\"NICK\", source)\n\t{\n\t\tPushParamRef(newnick);\n\t}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":37836,"func":"static int parser_errcb(struct libmnt_table *tb __attribute__ ((__unused__)),\n\t\t\tconst char *filename, int line)\n{\n\twarnx(_(\"%s: parse error at line %d -- ignored\"), filename, line);\n\t++parse_nerrors;\n\treturn 1;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":117272,"func":"    QString attribute(NodePtr node, const QString &name) const override\n    {\n        QSvgNode *n = svgNode(node);\n        if ((!n->nodeId().isEmpty() && (name == QLatin1String(\"id\") ||\n                                        name == QLatin1String(\"xml:id\"))))\n            return n->nodeId();\n        if (!n->xmlClass().isEmpty() && name == QLatin1String(\"class\"))\n            return n->xmlClass();\n        return QString();\n    }","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":241462,"func":"void CL_Clientinfo_f( void ) {\n\tCom_Printf( \"--------- Client Information ---------\\n\" );\n\tCom_Printf( \"state: %i\\n\", clc.state );\n\tCom_Printf( \"Server: %s\\n\", clc.servername );\n\tCom_Printf( \"User info settings:\\n\" );\n\tInfo_Print( Cvar_InfoString( CVAR_USERINFO ) );\n\tCom_Printf( \"--------------------------------------\\n\" );\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":281827,"func":"bool CanSaveAsComplete(const std::string& contents_mime_type) {\n  return contents_mime_type == \"text\/html\" ||\n         contents_mime_type == \"application\/xhtml+xml\";\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":387504,"func":"cooked(\n\tstruct parse *pcmd,\n\tFILE *fp\n\t)\n{\n\trawmode = 0;\n\t(void) fprintf(fp, \"Output set to cooked\\n\");\n\treturn;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":417964,"func":"int RGWSetBucketWebsite::verify_permission()\n{\n  return verify_bucket_owner_or_policy(s, rgw::IAM::s3PutBucketWebsite);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":485760,"func":"static int snd_pcm_oss_set_subdivide(struct snd_pcm_oss_file *pcm_oss_file, int subdivide)\n{\n\tint err = -EINVAL, idx;\n\n\tfor (idx = 1; idx >= 0; --idx) {\n\t\tstruct snd_pcm_substream *substream = pcm_oss_file->streams[idx];\n\t\tstruct snd_pcm_runtime *runtime;\n\n\t\tif (substream == NULL)\n\t\t\tcontinue;\n\t\truntime = substream->runtime;\n\t\terr = lock_params(runtime);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\terr = snd_pcm_oss_set_subdivide1(substream, subdivide);\n\t\tunlock_params(runtime);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn err;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":254241,"func":"base::FilePath WebRunnerBrowserContext::GetCachePath() const {\n  NOTIMPLEMENTED();\n  return base::FilePath();\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":39517,"func":"void QPaintEngineEx::drawLines(const QLineF *lines, int lineCount)\n{\n    int elementCount = lineCount << 1;\n    while (elementCount > 0) {\n        int count = qMin(elementCount, 32);\n\n        QVectorPath path((const qreal *) lines, count, qpaintengineex_line_types_16,\n                         QVectorPath::LinesHint);\n        stroke(path, state()->pen);\n\n        elementCount -= 32;\n        lines += 16;\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":299971,"func":"njs_vm_start(njs_vm_t *vm)\n{\n    njs_int_t  ret;\n\n    ret = njs_module_load(vm);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_vmcode_interpreter(vm, vm->start, NULL, NULL);\n\n    return (ret == NJS_ERROR) ? NJS_ERROR : NJS_OK;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":519857,"func":"  void begin_dataset() {}","target":0,"code_token_length":6,"total_token_length":242,"max_tokens_setting":512}
+{"idx":22512,"func":"void proto_reg_handoff_zbee_zcl_scenes ( void ) {\n dissector_handle_t scenes_handle ;\n scenes_handle = find_dissector ( ZBEE_PROTOABBREV_ZCL_SCENES ) ;\n dissector_add_uint ( \"zbee.zcl.cluster\" , ZBEE_ZCL_CID_SCENES , scenes_handle ) ;\n zbee_zcl_init_cluster ( proto_zbee_zcl_scenes , ett_zbee_zcl_scenes , ZBEE_ZCL_CID_SCENES , hf_zbee_zcl_scenes_attr_id , hf_zbee_zcl_scenes_srv_rx_cmd_id , hf_zbee_zcl_scenes_srv_tx_cmd_id , ( zbee_zcl_fn_attr_data ) dissect_zcl_scenes_attr_data ) ;\n }","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":96308,"func":"static int ieee80211_use_mfp(__le16 fc, struct sta_info *sta,\n\t\t\t     struct sk_buff *skb)\n{\n\tif (!ieee80211_is_mgmt(fc))\n\t\treturn 0;\n\n\tif (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP))\n\t\treturn 0;\n\n\tif (!ieee80211_is_robust_mgmt_frame(skb))\n\t\treturn 0;\n\n\treturn 1;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":77547,"func":"int cil_resolve_blockinherit_copy(struct cil_tree_node *current, void *extra_args)\n{\n\tstruct cil_block *block = current->data;\n\tstruct cil_args_resolve *args = extra_args;\n\tstruct cil_db *db = NULL;\n\tstruct cil_list_item *item = NULL;\n\tint rc = SEPOL_ERR;\n\n\t\/\/ This block is not inherited\n\tif (block->bi_nodes == NULL) {\n\t\trc = SEPOL_OK;\n\t\tgoto exit;\n\t}\n\n\tdb = args->db;\n\n\t\/\/ Make sure this is the original block and not a merged block from a blockinherit\n\tif (current != block->datum.nodes->head->data) {\n\t\trc = SEPOL_OK;\n\t\tgoto exit;\n\t}\n\n\tcil_list_for_each(item, block->bi_nodes) {\n\t\trc = cil_check_recursive_blockinherit(item->data);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tgoto exit;\n\t\t}\n\n\t\trc = cil_copy_ast(db, current, item->data);\n\t\tif (rc != SEPOL_OK) {\n\t\t\tcil_log(CIL_ERR, \"Failed to copy block contents into blockinherit\\n\");\n\t\t\tgoto exit;\n\t\t}\n\t}\n\n\treturn SEPOL_OK;\n\nexit:\n\treturn rc;\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":398847,"func":"gst_date_time_to_iso8601_string (GstDateTime * datetime)\n{\n  g_return_val_if_fail (datetime != NULL, NULL);\n\n  if (datetime->fields == GST_DATE_TIME_FIELDS_INVALID)\n    return NULL;\n\n  return __gst_date_time_serialize (datetime, FALSE);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":20138,"func":"static int dissect_h245_Ind_clockRecovery ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_Ind_clockRecovery , Ind_clockRecovery_choice , NULL ) ;\n return offset ;\n }","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":341357,"func":"char *g_strdup(const char *s)\n\n{\n\n    char *dup;\n\n    size_t i;\n\n\n\n    if (!s) {\n\n        return NULL;\n\n    }\n\n\n\n    __coverity_string_null_sink__(s);\n\n    __coverity_string_size_sink__(s);\n\n    dup = __coverity_alloc_nosize__();\n\n    __coverity_mark_as_afm_allocated__(dup, AFM_free);\n\n    for (i = 0; (dup[i] = s[i]); i++) ;\n\n    return dup;\n\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":371381,"func":"void ZrtpQueue::setSignSas(bool sasSignMode) {\n    signSas = sasSignMode;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":76366,"func":"int blosc_free_resources(void) {\n  \/* Return if Blosc is not initialized *\/\n  if (!g_initlib) return -1;\n\n  return release_threadpool(g_global_context);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":259157,"func":"static int ops_traces_mod(struct ftrace_ops *ops)\n{\n\tstruct ftrace_hash *hash;\n\n\thash = ops->filter_hash;\n\treturn ftrace_hash_empty(hash);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":295080,"func":"static inline void __set_fixmap(unsigned \/* enum fixed_addresses *\/ idx,\n\t\t\t\tphys_addr_t phys, pgprot_t flags)\n{\n\tpv_ops.mmu.set_fixmap(idx, phys, flags);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":232731,"func":"RenderFrameHostManager::RenderFrameHostManager(\n    FrameTreeNode* frame_tree_node,\n    RenderFrameHostDelegate* render_frame_delegate,\n    RenderWidgetHostDelegate* render_widget_delegate,\n    Delegate* delegate)\n    : frame_tree_node_(frame_tree_node),\n      delegate_(delegate),\n      render_frame_delegate_(render_frame_delegate),\n      render_widget_delegate_(render_widget_delegate),\n      weak_factory_(this) {\n  DCHECK(frame_tree_node_);\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":279669,"func":"void ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread(\n    int render_process_id,\n    int render_frame_id,\n    const GURL& url,\n    bool allowed_by_default,\n    const base::Callback<void(bool)>& callback) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  extensions::WebViewPermissionHelper* web_view_permission_helper =\n      extensions::WebViewPermissionHelper::FromFrameID(\n          render_process_id, render_frame_id);\n  web_view_permission_helper->RequestFileSystemPermission(url,\n                                                          allowed_by_default,\n                                                          callback);\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":50560,"func":"static int ext4_mknod(struct inode *dir, struct dentry *dentry,\n\t\t      umode_t mode, dev_t rdev)\n{\n\thandle_t *handle;\n\tstruct inode *inode;\n\tint err, retries = 0;\n\n\tif (!new_valid_dev(rdev))\n\t\treturn -EINVAL;\n\n\tdquot_initialize(dir);\n\nretry:\n\thandle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +\n\t\t\t\t\tEXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +\n\t\t\t\t\tEXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));\n\tif (IS_ERR(handle))\n\t\treturn PTR_ERR(handle);\n\n\tif (IS_DIRSYNC(dir))\n\t\text4_handle_sync(handle);\n\n\tinode = ext4_new_inode(handle, dir, mode, &dentry->d_name, 0, NULL);\n\terr = PTR_ERR(inode);\n\tif (!IS_ERR(inode)) {\n\t\tinit_special_inode(inode, inode->i_mode, rdev);\n\t\tinode->i_op = &ext4_special_inode_operations;\n\t\terr = ext4_add_nondir(handle, dentry, inode);\n\t}\n\text4_journal_stop(handle);\n\tif (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))\n\t\tgoto retry;\n\treturn err;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":149772,"func":"u64 dma_get_required_mask(struct device *dev)\n{\n\tu32 low_totalram = ((max_pfn - 1) << PAGE_SHIFT);\n\tu32 high_totalram = ((max_pfn - 1) >> (32 - PAGE_SHIFT));\n\tu64 mask;\n\n\tif (!high_totalram) {\n\t\t\/* convert to mask just covering totalram *\/\n\t\tlow_totalram = (1 << (fls(low_totalram) - 1));\n\t\tlow_totalram += low_totalram - 1;\n\t\tmask = low_totalram;\n\t} else {\n\t\thigh_totalram = (1 << (fls(high_totalram) - 1));\n\t\thigh_totalram += high_totalram - 1;\n\t\tmask = (((u64)high_totalram) << 32) + 0xffffffff;\n\t}\n\treturn mask;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":192367,"func":"handle_group_features_stats_request(struct ofconn *ofconn,\n                                    const struct ofp_header *request)\n{\n    struct ofproto *p = ofconn_get_ofproto(ofconn);\n    struct ofpbuf *msg;\n\n    msg = ofputil_encode_group_features_reply(&p->ogf, request);\n    if (msg) {\n        ofconn_send_reply(ofconn, msg);\n    }\n\n    return 0;\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":119057,"func":"nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,\n\t\tvoid *arg)\n{\n\tif (!cstate->save_fh.fh_dentry)\n\t\treturn nfserr_restorefh;\n\n\tfh_dup2(&cstate->current_fh, &cstate->save_fh);\n\tif (HAS_STATE_ID(cstate, SAVED_STATE_ID_FLAG)) {\n\t\tmemcpy(&cstate->current_stateid, &cstate->save_stateid, sizeof(stateid_t));\n\t\tSET_STATE_ID(cstate, CURRENT_STATE_ID_FLAG);\n\t}\n\treturn nfs_ok;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":139705,"func":"static int _nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,\n\t\tstruct nfs_pathconf *pathconf)\n{\n\tstruct nfs4_pathconf_arg args = {\n\t\t.fh = fhandle,\n\t\t.bitmask = server->attr_bitmask,\n\t};\n\tstruct rpc_message msg = {\n\t\t.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_PATHCONF],\n\t\t.rpc_argp = &args,\n\t\t.rpc_resp = pathconf,\n\t};\n\n\t\/* None of the pathconf attributes are mandatory to implement *\/\n\tif ((args.bitmask[0] & nfs4_pathconf_bitmap[0]) == 0) {\n\t\tmemset(pathconf, 0, sizeof(*pathconf));\n\t\treturn 0;\n\t}\n\n\tnfs_fattr_init(pathconf->fattr);\n\treturn rpc_call_sync(server->client, &msg, 0);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":95015,"func":"const Tensor* CreateQuantizedFlatbufferTensor(int size) {\n  using flatbuffers::Offset;\n  flatbuffers::FlatBufferBuilder* builder = BuilderInstance();\n  const Offset<QuantizationParameters> quant_params =\n      CreateQuantizationParameters(\n          *builder,\n          \/*min=*\/builder->CreateVector<float>({0.1f}),\n          \/*max=*\/builder->CreateVector<float>({0.2f}),\n          \/*scale=*\/builder->CreateVector<float>({0.3f}),\n          \/*zero_point=*\/builder->CreateVector<int64_t>({100ll}));\n\n  constexpr size_t tensor_shape_size = 1;\n  const int32_t tensor_shape[tensor_shape_size] = {size};\n  const Offset<Tensor> tensor_offset = CreateTensor(\n      *builder, builder->CreateVector(tensor_shape, tensor_shape_size),\n      TensorType_INT32, 0, builder->CreateString(\"test_tensor\"), quant_params,\n      false);\n  builder->Finish(tensor_offset);\n  void* tensor_pointer = builder->GetBufferPointer();\n  const Tensor* tensor = flatbuffers::GetRoot<Tensor>(tensor_pointer);\n  return tensor;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":347250,"func":"static SEND_DCC_REC *dcc_send_create(IRC_SERVER_REC *server,\n\t\t\t\t     CHAT_DCC_REC *chat,\n\t\t\t\t     const char *nick, const char *arg)\n{\n\tSEND_DCC_REC *dcc;\n\n\tdcc = g_new0(SEND_DCC_REC, 1);\n\tdcc->orig_type = module_get_uniq_id_str(\"DCC\", \"GET\");\n\tdcc->type = module_get_uniq_id_str(\"DCC\", \"SEND\");\n\tdcc->fhandle = -1;\n\tdcc->queue = -1;\n\n\tdcc_init_rec(DCC(dcc), server, chat, nick, arg);\n        return dcc;\n}","target":1,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":401033,"func":"inline word* SegmentBuilder::getPtrUnchecked(SegmentWordCount offset) {\n  return const_cast<word*>(ptr.begin() + offset);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":473124,"func":"date_s__httpdate(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, opt;\n\n    rb_scan_args(argc, argv, \"1:\", &str, &opt);\n    check_limit(str, opt);\n\n    return date__httpdate(str);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":456440,"func":"static void con_start(struct tty_struct *tty)\n{\n\tint console_num;\n\tif (!tty)\n\t\treturn;\n\tconsole_num = tty->index;\n\tif (!vc_cons_allocated(console_num))\n\t\treturn;\n\tvt_kbd_con_start(console_num);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":119619,"func":"void ctap_store_rk(int index,CTAP_residentKey * rk)\n{\n    ctap_overwrite_rk(index, rk);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":90656,"func":"static Jsi_OpCodes *code_efinal(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_EFINAL, 0); }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":373838,"func":"        void markReset( const char * toMark = 0) {\n            if( toMark == 0 ) toMark = mark;\n            verify( toMark );\n            nextjsobj = toMark;\n        }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":52751,"func":"void proto_unregister(struct proto *prot)\n{\n\tmutex_lock(&proto_list_mutex);\n\trelease_proto_idx(prot);\n\tlist_del(&prot->node);\n\tmutex_unlock(&proto_list_mutex);\n\n\tkmem_cache_destroy(prot->slab);\n\tprot->slab = NULL;\n\n\treq_prot_cleanup(prot->rsk_prot);\n\n\tif (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) {\n\t\tkmem_cache_destroy(prot->twsk_prot->twsk_slab);\n\t\tkfree(prot->twsk_prot->twsk_slab_name);\n\t\tprot->twsk_prot->twsk_slab = NULL;\n\t}\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":471789,"func":"unsigned long listTypeLength(const robj *subject) {\n    if (subject->encoding == OBJ_ENCODING_QUICKLIST) {\n        return quicklistCount(subject->ptr);\n    } else {\n        serverPanic(\"Unknown list encoding\");\n    }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":304724,"func":"    void JavascriptNativeIntArray::ExtractSnapObjectDataInto(TTD::NSSnapObjects::SnapObject* objData, TTD::SlabAllocator& alloc)\n    {\n        TTD::NSSnapObjects::SnapArrayInfo<int32>* sai = TTD::NSSnapObjects::ExtractArrayValues<int32>(this, alloc);\n        TTD::NSSnapObjects::StdExtractSetKindSpecificInfo<TTD::NSSnapObjects::SnapArrayInfo<int32>*, TTD::NSSnapObjects::SnapObjectType::SnapNativeIntArrayObject>(objData, sai);\n    }","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":488030,"func":"NTSTATUS refuse_symlink_fsp(const files_struct *fsp)\n{\n\n\tif (!VALID_STAT(fsp->fsp_name->st)) {\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\tif (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\tif (fsp_get_pathref_fd(fsp) == -1) {\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":158588,"func":"int DNS::GetIP6(const char *name)\n{\n\tDNSHeader h;\n\tint id;\n\tint length;\n\n\tif ((length = this->MakePayload(name, DNS_QUERY_AAAA, 1, (unsigned char*)&h.payload)) == -1)\n\t\treturn -1;\n\n\tDNSRequest* req = this->AddQuery(&h, id, name);\n\n\tif ((!req) || (req->SendRequests(&h, length, DNS_QUERY_AAAA) == -1))\n\t\treturn -1;\n\n\treturn id;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":124540,"func":"  MakeValue(typename WCharHelper<wchar_t, Char>::Supported value) {\n    int_value = value;\n  }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":194990,"func":"void QuicClientPromisedInfo::OnPromiseHeaders(const SpdyHeaderBlock& headers) {\n   SpdyHeaderBlock::const_iterator it = headers.find(kHttp2MethodHeader);\n  if (it == headers.end()) {\n    QUIC_DVLOG(1) << \"Promise for stream \" << id_ << \" has no method\";\n    Reset(QUIC_INVALID_PROMISE_METHOD);\n    return;\n  }\n   if (!(it->second == \"GET\" || it->second == \"HEAD\")) {\n     QUIC_DVLOG(1) << \"Promise for stream \" << id_ << \" has invalid method \"\n                   << it->second;\n    Reset(QUIC_INVALID_PROMISE_METHOD);\n    return;\n  }\n  if (!SpdyUtils::UrlIsValid(headers)) {\n    QUIC_DVLOG(1) << \"Promise for stream \" << id_ << \" has invalid URL \"\n                  << url_;\n    Reset(QUIC_INVALID_PROMISE_URL);\n    return;\n  }\n  if (!session_->IsAuthorized(SpdyUtils::GetHostNameFromHeaderBlock(headers))) {\n    Reset(QUIC_UNAUTHORIZED_PROMISE_URL);\n    return;\n  }\n  request_headers_.reset(new SpdyHeaderBlock(headers.Clone()));\n}\n","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":476379,"func":"void LIRGenerator::volatile_field_load(LIR_Address* address, LIR_Opr result,\n                                       CodeEmitInfo* info) {\n  if (address->type() == T_LONG) {\n    address = new LIR_Address(address->base(),\n                              address->index(), address->scale(),\n                              address->disp(), T_DOUBLE);\n    \/\/ Transfer the value atomically by using FP moves.  This means\n    \/\/ the value has to be moved between CPU and FPU registers.  In\n    \/\/ SSE0 and SSE1 mode it has to be moved through spill slot but in\n    \/\/ SSE2+ mode it can be moved directly.\n    LIR_Opr temp_double = new_register(T_DOUBLE);\n    __ volatile_move(LIR_OprFact::address(address), temp_double, T_LONG, info);\n    __ volatile_move(temp_double, result, T_LONG);\n    if (UseSSE < 2) {\n      \/\/ no spill slot needed in SSE2 mode because xmm->cpu register move is possible\n      set_vreg_flag(result, must_start_in_memory);\n    }\n  } else {\n    __ load(address, result, info);\n  }\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":432555,"func":"bgp_rx_packet(struct bgp_conn *conn, byte *pkt, unsigned len)\n{\n  byte type = pkt[18];\n\n  DBG(\"BGP: Got packet %02x (%d bytes)\\n\", type, len);\n\n  if (conn->bgp->p.mrtdump & MD_MESSAGES)\n    bgp_dump_message(conn, pkt, len);\n\n  switch (type)\n    {\n    case PKT_OPEN:\t\treturn bgp_rx_open(conn, pkt, len);\n    case PKT_UPDATE:\t\treturn bgp_rx_update(conn, pkt, len);\n    case PKT_NOTIFICATION:      return bgp_rx_notification(conn, pkt, len);\n    case PKT_KEEPALIVE:\t\treturn bgp_rx_keepalive(conn);\n    case PKT_ROUTE_REFRESH:\treturn bgp_rx_route_refresh(conn, pkt, len);\n    default:\t\t\tbgp_error(conn, 1, 3, pkt+18, 1);\n    }\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":171487,"func":"const char* AutofillDialogViews::NotificationArea::GetClassName() const {\n  return kNotificationAreaClassName;\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":150098,"func":"\tvoid testToStringCharsRequired() {\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/www.example.com\/\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/www.example.com:80\/\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/user:pass@www.example.com\/\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/www.example.com\/index.html\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/www.example.com\/?abc\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/www.example.com\/#def\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"http:\/\/www.example.com\/?abc#def\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"\/test\"));\n\t\tTEST_ASSERT(testToStringCharsRequiredHelper(L\"test\"));\n\t}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":82902,"func":"Variant HHVM_FUNCTION(mcrypt_enc_get_algorithms_name, const Resource& td) {\n  auto pm = get_valid_mcrypt_resource(td);\n  if (!pm) {\n    return false;\n  }\n\n  char *name = mcrypt_enc_get_algorithms_name(pm->m_td);\n  String ret(name, CopyString);\n  mcrypt_free(name);\n  return ret;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":141867,"func":"\nstatic void row_dim_write(zval *object, zval *member, zval *value TSRMLS_DC)\n{\n\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"This PDORow is not from a writable result set\");","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":200140,"func":"void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) {\n  EnsureWebKitInitialized();\n  RenderViewImpl::Create(\n      params.parent_window,\n      MSG_ROUTING_NONE,\n      params.renderer_preferences,\n      params.web_preferences,\n      new SharedRenderViewCounter(0),\n      params.view_id,\n      params.surface_id,\n      params.session_storage_namespace_id,\n      params.frame_name,\n      params.next_page_id,\n      params.screen_info,\n      params.guest);\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":253946,"func":"void FS_WriteFile( const char *qpath, const void *buffer, int size ) {\n\tfileHandle_t f;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\" );\n\t}\n\n\tif ( !qpath || !buffer ) {\n\t\tCom_Error( ERR_FATAL, \"FS_WriteFile: NULL parameter\" );\n\t}\n\n\tf = FS_FOpenFileWrite( qpath );\n\tif ( !f ) {\n\t\tCom_Printf( \"Failed to open %s\\n\", qpath );\n\t\treturn;\n\t}\n\n\tFS_Write( buffer, size, f );\n\n\tFS_FCloseFile( f );\n}\n","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":481901,"func":"static void caps_reset_bit(int nr) {\n\tuint64_t mask = 1LLU << nr;\n\tfilter &= ~mask;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":466652,"func":"  Http::StripPortType stripPortType() const override { return strip_port_type_; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":58316,"func":"Variant f_libxml_get_last_error() {\n  xmlErrorPtr error = xmlGetLastError();\n  if (error) {\n    return create_libxmlerror(*error);\n  }\n  return false;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":290182,"func":"static PyObject * string_new ( PyTypeObject * type , PyObject * args , PyObject * kwds ) {\n PyObject * x = NULL ;\n static char * kwlist [ ] = {\n \"object\" , 0 }\n ;\n if ( type != & PyString_Type ) return str_subtype_new ( type , args , kwds ) ;\n if ( ! PyArg_ParseTupleAndKeywords ( args , kwds , \"|O:str\" , kwlist , & x ) ) return NULL ;\n if ( x == NULL ) return PyString_FromString ( \"\" ) ;\n return PyObject_Str ( x ) ;\n }","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":147036,"func":"GF_Box *mdat_New()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MediaDataBox, GF_ISOM_BOX_TYPE_MDAT);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":22559,"func":"static void vmsvga_class_init ( ObjectClass * klass , void * data ) {\n DeviceClass * dc = DEVICE_CLASS ( klass ) ;\n PCIDeviceClass * k = PCI_DEVICE_CLASS ( klass ) ;\n k -> init = pci_vmsvga_initfn ;\n k -> romfile = \"vgabios-vmware.bin\" ;\n k -> vendor_id = PCI_VENDOR_ID_VMWARE ;\n k -> device_id = SVGA_PCI_DEVICE_ID ;\n k -> class_id = PCI_CLASS_DISPLAY_VGA ;\n k -> subsystem_vendor_id = PCI_VENDOR_ID_VMWARE ;\n k -> subsystem_id = SVGA_PCI_DEVICE_ID ;\n dc -> reset = vmsvga_reset ;\n dc -> vmsd = & vmstate_vmware_vga ;\n dc -> props = vga_vmware_properties ;\n dc -> hotpluggable = false ;\n set_bit ( DEVICE_CATEGORY_DISPLAY , dc -> categories ) ;\n }","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":412757,"func":"static int h2_parse_header_table_size(char **args, int section_type, struct proxy *curpx,\n                                      struct proxy *defpx, const char *file, int line,\n                                      char **err)\n{\n\tif (too_many_args(1, args, err, NULL))\n\t\treturn -1;\n\n\th2_settings_header_table_size = atoi(args[1]);\n\tif (h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {\n\t\tmemprintf(err, \"'%s' expects a numeric value between 4096 and 65536.\", args[0]);\n\t\treturn -1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":257860,"func":"static int vdpau_h264_end_frame ( AVCodecContext * avctx ) {\n AVVDPAUContext * hwctx = avctx -> hwaccel_context ;\n H264Context * h = avctx -> priv_data ;\n VdpVideoSurface surf = ff_vdpau_get_surface_id ( h -> cur_pic_ptr ) ;\n hwctx -> render ( hwctx -> decoder , surf , ( void * ) & hwctx -> info , hwctx -> bitstream_buffers_used , hwctx -> bitstream_buffers ) ;\n ff_h264_draw_horiz_band ( h , 0 , h -> avctx -> height ) ;\n hwctx -> bitstream_buffers_used = 0 ;\n return 0 ;\n }","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":96274,"func":"static void kvm_cpu_vmxoff(void)\n{\n\tasm volatile (__ex(ASM_VMX_VMXOFF) : : : \"cc\");\n\n\tintel_pt_handle_vmx(0);\n\tcr4_clear_bits(X86_CR4_VMXE);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":103107,"func":"rsvg_filter_get_bg (RsvgFilterContext * ctx)\n{\n    if (!ctx->bg_surface)\n        ctx->bg_surface = rsvg_compile_bg (ctx->ctx);\n\n    return ctx->bg_surface;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":160369,"func":"static void fips_expand_key_bits(BYTE* in, BYTE* out)\n{\n\tBYTE buf[21], c;\n\tint i, b, p, r;\n\n\t\/* reverse every byte in the key *\/\n\tfor (i = 0; i < 21; i++)\n\t\tbuf[i] = fips_reverse_table[in[i]];\n\n\t\/* insert a zero-bit after every 7th bit *\/\n\tfor (i = 0, b = 0; i < 24; i++, b += 7)\n\t{\n\t\tp = b \/ 8;\n\t\tr = b % 8;\n\n\t\tif (r <= 1)\n\t\t{\n\t\t\tout[i] = (buf[p] << r) & 0xfe;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\/* c is accumulator *\/\n\t\t\tc = buf[p] << r;\n\t\t\tc |= buf[p + 1] >> (8 - r);\n\t\t\tout[i] = c & 0xfe;\n\t\t}\n\t}\n\n\t\/* reverse every byte *\/\n\t\/* alter lsb so the byte has odd parity *\/\n\tfor (i = 0; i < 24; i++)\n\t\tout[i] = fips_oddparity_table[fips_reverse_table[out[i]]];\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":285782,"func":"void CSSStyleSheetResource::SaveParsedStyleSheet(StyleSheetContents* sheet) {\n  DCHECK(sheet);\n  DCHECK(sheet->IsCacheableForResource());\n\n  if (!GetMemoryCache()->Contains(this)) {\n    SetParsedStyleSheetCache(nullptr);\n    return;\n  }\n  SetParsedStyleSheetCache(sheet);\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":52286,"func":"f_float2nr(typval_T *argvars, typval_T *rettv)\n{\n    float_T\tf = 0.0;\n\n    if (get_float_arg(argvars, &f) == OK)\n    {\n\tif (f <= -VARNUM_MAX + DBL_EPSILON)\n\t    rettv->vval.v_number = -VARNUM_MAX;\n\telse if (f >= VARNUM_MAX - DBL_EPSILON)\n\t    rettv->vval.v_number = VARNUM_MAX;\n\telse\n\t    rettv->vval.v_number = (varnumber_T)f;\n    }\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":315119,"func":"RenderFrameImpl* RenderFrameImpl::FromRoutingID(int routing_id) {\n  DCHECK(RenderThread::IsMainThread());\n  auto iter = g_routing_id_frame_map.Get().find(routing_id);\n  if (iter != g_routing_id_frame_map.Get().end())\n    return iter->second;\n  return nullptr;\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":401116,"func":"glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,\n                                                         uint32_t dstaddr,\n                                                         uint32_t srcaddr,\n                                                         int dstpitch,\n                                                         int srcpitch,\n                                                         int bltwidth,\n                                                         int bltheight)\n{\n    int x,y;\n    uint16_t transp = s->vga.gr[0x34] | (uint16_t)s->vga.gr[0x35] << 8;\n    dstpitch += bltwidth;\n    srcpitch += bltwidth;\n    for (y = 0; y < bltheight; y++) {\n        for (x = 0; x < bltwidth; x+=2) {\n            ROP_OP_TR_16(s, dstaddr, cirrus_src16(s, srcaddr), transp);\n            dstaddr -= 2;\n            srcaddr -= 2;\n        }\n        dstaddr += dstpitch;\n        srcaddr += srcpitch;\n    }\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":375799,"func":"static void aer_log_del_err(PCIEAERLog *aer_log, PCIEAERErr *err)\n{\n    assert(aer_log->log_num);\n    *err = aer_log->log[0];\n    aer_log->log_num--;\n    memmove(&aer_log->log[0], &aer_log->log[1],\n            aer_log->log_num * sizeof *err);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":156733,"func":"mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj)\n{\n\tMonoObject *prev = mono_g_hash_table_lookup (assembly->tokens, GUINT_TO_POINTER (token));\n\tif (prev) {\n\t\t\/* There could be multiple MethodInfo objects with the same token *\/\n\t\t\/\/g_assert (prev == obj);\n\t} else {\n\t\tmono_g_hash_table_insert (assembly->tokens, GUINT_TO_POINTER (token), obj);\n\t}\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":93297,"func":"static MagickBooleanType IsJ2K(const unsigned char *magick,const size_t length)\n{\n  if (length < 4)\n    return(MagickFalse);\n  if (memcmp(magick,\"\\xff\\x4f\\xff\\x51\",4) == 0)\n    return(MagickTrue);\n  return(MagickFalse);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":222903,"func":"void Document::processViewport(const String& features, ViewportArguments::Type origin)\n{\n    ASSERT(!features.isNull());\n\n    if (origin < m_viewportArguments.type)\n        return;\n\n    m_viewportArguments = ViewportArguments(origin);\n    processArguments(features, (void*)&m_viewportArguments, &setViewportFeature);\n\n    updateViewportArguments();\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":496521,"func":"  moreLeft(T D) : T(D) {}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":458487,"func":"flow_compose_l7(struct dp_packet *p, const void *l7, size_t l7_len)\n{\n    if (l7_len) {\n        if (l7) {\n            dp_packet_put(p, l7, l7_len);\n        } else {\n            uint8_t *payload = dp_packet_put_uninit(p, l7_len);\n            for (size_t i = 0; i < l7_len; i++) {\n                payload[i] = i;\n            }\n        }\n    }\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":383324,"func":"ecdsa_qbits_from_Q (unsigned int qbits)\n{\n  if ((qbits%8) > 3)\n    {\n      log_error (_(\"ECDSA public key is expected to be in SEC encoding \"\n                   \"multiple of 8 bits\\n\"));\n      return 0;\n    }\n  qbits -= qbits%8;\n  qbits \/= 2;\n  return qbits;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":485245,"func":"safi2str (safi_t safi)\n{\n  if (safi == SAFI_UNICAST)\n    return \"SAFI_UNICAST\";\n  else if (safi == SAFI_MULTICAST)\n    return \"SAFI_MULTICAST\";\n  else if (safi == SAFI_MPLS_VPN || safi == BGP_SAFI_VPNV4)\n    return \"SAFI_MPLS_VPN\";\n  else\n    return \"Unknown SAFI\";\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":107670,"func":"    \/\/! Load image from a PANDORE-5 file \\newinstance.\n    static CImg<T> get_load_pandore(const char *const filename) {\n      return CImg<T>().load_pandore(filename);","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":277380,"func":"void AutomationProvider::OnChannelConnected(int pid) {\n  is_connected_ = true;\n  LOG(INFO) << \"Testing channel connected, sending hello message\";\n\n  channel_->Send(new AutomationMsg_Hello(GetProtocolVersion()));\n  if (initial_loads_complete_)\n    Send(new AutomationMsg_InitialLoadsComplete());\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":239768,"func":"free_realm_contexts(krb5_context context, pkinit_kdc_context *realm_contexts)\n{\n    int i;\n\n    if (realm_contexts == NULL)\n        return;\n    for (i = 0; realm_contexts[i] != NULL; i++)\n        pkinit_server_plugin_fini_realm(context, realm_contexts[i]);\n    pkiDebug(\"%s: freeing context at %p\\n\", __FUNCTION__, realm_contexts);\n    free(realm_contexts);\n}\n","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":354270,"func":"static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)\n{\n\tpdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;\n\tpdo_sqlite_stmt *S = ecalloc(1, sizeof(pdo_sqlite_stmt));\n\tint i;\n\tconst char *tail;\n\n\tS->H = H;\n\tstmt->driver_data = S;\n\tstmt->methods = &sqlite_stmt_methods;\n\tstmt->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL|PDO_PLACEHOLDER_NAMED;\n\n\tif (PDO_CURSOR_FWDONLY != pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY TSRMLS_CC)) {\n\t\tH->einfo.errcode = SQLITE_ERROR;\n\t\tpdo_sqlite_error(dbh);\n\t\treturn 0;\n\t}\n\n\ti = sqlite3_prepare(H->db, sql, sql_len, &S->stmt, &tail);\n\tif (i == SQLITE_OK) {\n\t\treturn 1;\n\t}\n\n\tpdo_sqlite_error(dbh);\n\n\treturn 0;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":164729,"func":"XML_SetParamEntityParsing(XML_Parser parser,\n                          enum XML_ParamEntityParsing peParsing)\n{\n  if (parser == NULL)\n    return 0;\n  \/* block after XML_Parse()\/XML_ParseBuffer() has been called *\/\n  if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED)\n    return 0;\n#ifdef XML_DTD\n  parser->m_paramEntityParsing = peParsing;\n  return 1;\n#else\n  return peParsing == XML_PARAM_ENTITY_PARSING_NEVER;\n#endif\n}\n","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":246572,"func":"static void _php_curl_close(zend_resource *rsrc)\n{\n\tphp_curl *ch = (php_curl *) rsrc->ptr;\n\t_php_curl_close_ex(ch);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":346394,"func":"static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)\n{\n\tstruct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract;\n\n\treturn BZ2_bzwrite(self->bz_file, (char*)buf, count); \n}","target":1,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":11661,"func":"void NaClProcessHost::OnProcessLaunched() {\n  FilePath irt_path;\n  const char* irt_path_var = getenv(\"NACL_IRT_LIBRARY\");\n  if (irt_path_var != NULL) {\n    FilePath::StringType string(irt_path_var,\n                                irt_path_var + strlen(irt_path_var));\n    irt_path = FilePath(string);\n  } else {\n    FilePath plugin_dir;\n    if (!PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &plugin_dir)) {\n      LOG(ERROR) << \"Failed to locate the plugins directory\";\n      delete this;\n      return;\n    }\n    irt_path = plugin_dir.Append(GetIrtLibraryFilename());\n  }\n\n  base::FileUtilProxy::CreateOrOpenCallback* callback =\n      callback_factory_.NewCallback(&NaClProcessHost::OpenIrtFileDone);\n  if (!base::FileUtilProxy::CreateOrOpen(\n           BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),\n            irt_path,\n            base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,\n            callback)) {\n    delete callback;\n     delete this;\n   }\n }\n","target":1,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":187912,"func":"String8::String8(const char32_t* o, size_t len)\n : mString(allocFromUTF32(o, len))\n{\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":315678,"func":"void GLES2Implementation::BindBufferRangeHelper(GLenum target,\n                                                GLuint index,\n                                                GLuint buffer_id,\n                                                GLintptr offset,\n                                                GLsizeiptr size) {\n  if (UpdateIndexedBufferState(target, index, buffer_id, \"glBindBufferRange\")) {\n    GetIdHandler(SharedIdNamespaces::kBuffers)\n        ->MarkAsUsedForBind(this, target, index, buffer_id, offset, size,\n                            &GLES2Implementation::BindBufferRangeStub);\n  }\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":45156,"func":"best_effort_strncat_from_utf16le(struct archive_string *as, const void *_p,\n    size_t bytes, struct archive_string_conv *sc)\n{\n\treturn (best_effort_strncat_from_utf16(as, _p, bytes, sc, 0));\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":116784,"func":"static void derive_crypt_complete(struct crypto_async_request *req, int rc)\n{\n\tstruct fscrypt_completion_result *ecr = req->data;\n\n\tif (rc == -EINPROGRESS)\n\t\treturn;\n\n\tecr->res = rc;\n\tcomplete(&ecr->completion);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":289262,"func":"long jas_stream_length ( jas_stream_t * stream ) {\n long oldpos ;\n long pos ;\n if ( ( oldpos = jas_stream_tell ( stream ) ) < 0 ) {\n return - 1 ;\n }\n if ( jas_stream_seek ( stream , 0 , SEEK_END ) < 0 ) {\n return - 1 ;\n }\n if ( ( pos = jas_stream_tell ( stream ) ) < 0 ) {\n return - 1 ;\n }\n if ( jas_stream_seek ( stream , oldpos , SEEK_SET ) < 0 ) {\n return - 1 ;\n }\n return pos ;\n }","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":54373,"func":"QPDF::getWarnings()\n{\n    std::vector<QPDFExc> result = this->m->warnings;\n    this->m->warnings.clear();\n    return result;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":281297,"func":"bool Extension::LoadManifestVersion(string16* error) {\n  if (manifest_->value()->HasKey(keys::kManifestVersion)) {\n    int manifest_version = 1;\n    if (!manifest_->GetInteger(keys::kManifestVersion, &manifest_version) ||\n        manifest_version < 1) {\n      *error = ASCIIToUTF16(errors::kInvalidManifestVersion);\n      return false;\n    }\n  }\n\n  manifest_version_ = manifest_->GetManifestVersion();\n  if (creation_flags_ & REQUIRE_MODERN_MANIFEST_VERSION &&\n      manifest_version_ < kModernManifestVersion &&\n      !CommandLine::ForCurrentProcess()->HasSwitch(\n          switches::kAllowLegacyExtensionManifests)) {\n    *error = ErrorUtils::FormatErrorMessageUTF16(\n        errors::kInvalidManifestVersionOld,\n        base::IntToString(kModernManifestVersion));\n    return false;\n  }\n\n  return true;\n}\n","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":104983,"func":"rdpsnd_queue_init(void)\n{\n\tqueue_pending = queue_lo = queue_hi = 0;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":21447,"func":"static void balloon_page(void *addr, int deflate)\n\n{\n\n#if defined(__linux__)\n\n    if (!kvm_enabled() || kvm_has_sync_mmu())\n\n        madvise(addr, TARGET_PAGE_SIZE,\n\n                deflate ? MADV_WILLNEED : MADV_DONTNEED);\n\n#endif\n\n}\n","target":1,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":236749,"func":"void RenderWidgetHostViewAura::OnInputMethodChanged() {\n  if (!host_)\n    return;\n\n  if (GetInputMethod())\n    host_->SetInputMethodActive(GetInputMethod()->IsActive());\n\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":512909,"func":"CairoImageOutputDev::~CairoImageOutputDev()\n{\n  int i;\n\n  for (i = 0; i < numImages; i++)\n    delete images[i];\n  gfree (images);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":235931,"func":"bool GetTabFunction::RunImpl() {\n  int tab_id;\n  EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));\n\n  TabStripModel* tab_strip = NULL;\n  TabContents* contents = NULL;\n  int tab_index = -1;\n  if (!GetTabById(tab_id, profile(), include_incognito(),\n                  NULL, &tab_strip, &contents, &tab_index, &error_))\n    return false;\n\n  result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip,\n      tab_index));\n  return true;\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":301961,"func":"check_entry(const struct ip6t_entry *e)\n{\n\tconst struct xt_entry_target *t;\n\n\tif (!ip6_checkentry(&e->ipv6))\n\t\treturn -EINVAL;\n\n\tif (e->target_offset + sizeof(struct xt_entry_target) >\n\t    e->next_offset)\n\t\treturn -EINVAL;\n\n\tt = ip6t_get_target_c(e);\n\tif (e->target_offset + t->u.target_size > e->next_offset)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":518341,"func":"longlong Item_cache_temporal::val_time_packed()\n{\n  DBUG_ASSERT(fixed == 1);\n  if (Item_cache_temporal::field_type() != MYSQL_TYPE_TIME)\n    return Item::val_time_packed(); \/\/ DATETIME-to-TIME conversion needed\n  if ((!value_cached && !cache_value()) || null_value)\n  {\n    null_value= TRUE;\n    return 0;\n  }\n  return value;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":296156,"func":"AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s)\n{\n    core_server_config *conf = ap_get_core_module_config(s->module_config);\n    return conf->protocol;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":450896,"func":"  bool is_nonempty() const { return (len > 0); }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":277449,"func":"issuer_key_hash (ksba_cert_t cert, unsigned char *sha1_buffer)\n{\n  gpg_error_t err;\n  const unsigned char *ptr;\n  size_t length, dummy;\n\n  err = _ksba_cert_get_public_key_ptr (cert, &ptr, &length);\n  if (!err)\n    {\n      err = _ksba_hash_buffer (NULL, ptr, length, 20, sha1_buffer, &dummy);\n      if (!err && dummy != 20)\n        err = gpg_error (GPG_ERR_BUG);\n    }\n  return err;\n}\n","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":106415,"func":"void put_transaction(struct btrfs_transaction *transaction)\n{\n\tWARN_ON(atomic_read(&transaction->use_count) == 0);\n\tif (atomic_dec_and_test(&transaction->use_count)) {\n\t\tBUG_ON(!list_empty(&transaction->list));\n\t\tWARN_ON(transaction->delayed_refs.root.rb_node);\n\t\tmemset(transaction, 0, sizeof(*transaction));\n\t\tkmem_cache_free(btrfs_transaction_cachep, transaction);\n\t}\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":113160,"func":"njs_array_handler_reduce(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    njs_int_t    ret;\n    njs_value_t  arguments[5];\n\n    if (njs_is_valid(entry)) {\n        if (!njs_is_valid(args->argument)) {\n            *(args->argument) = *entry;\n            return NJS_OK;\n        }\n\n        \/* GC: array elt, array *\/\n\n        njs_set_undefined(&arguments[0]);\n        arguments[1] = *args->argument;\n        arguments[2] = *entry;\n        njs_set_number(&arguments[3], n);\n        arguments[4] = *args->value;\n\n        ret =  njs_function_apply(vm, args->function, arguments, 5,\n                                  args->argument);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":485429,"func":"DEFUN (neighbor_default_originate_rmap,\n       neighbor_default_originate_rmap_cmd,\n       NEIGHBOR_CMD2 \"default-originate route-map WORD\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Originate default route to this neighbor\\n\"\n       \"Route-map to specify criteria to originate default\\n\"\n       \"route-map name\\n\")\n{\n  return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t\t bgp_node_safi (vty), argv[1], 1);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":496952,"func":"static void set_run_features(ASS_Shaper *shaper, GlyphInfo *info)\n{\n    \/\/ enable vertical substitutions for @font runs\n    if (info->font->desc.vertical)\n        shaper->features[VERT].value = shaper->features[VKNA].value = 1;\n    else\n        shaper->features[VERT].value = shaper->features[VKNA].value = 0;\n\n    \/\/ disable ligatures if horizontal spacing is non-standard\n    if (info->hspacing)\n        shaper->features[LIGA].value = shaper->features[CLIG].value = 0;\n    else\n        shaper->features[LIGA].value = shaper->features[CLIG].value = 1;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":484764,"func":"static int snd_ctl_dev_disconnect(struct snd_device *device)\n{\n\tstruct snd_card *card = device->device_data;\n\tstruct snd_ctl_file *ctl;\n\tstruct snd_ctl_layer_ops *lops;\n\tunsigned long flags;\n\n\tread_lock_irqsave(&card->ctl_files_rwlock, flags);\n\tlist_for_each_entry(ctl, &card->ctl_files, list) {\n\t\twake_up(&ctl->change_sleep);\n\t\tsnd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR);\n\t}\n\tread_unlock_irqrestore(&card->ctl_files_rwlock, flags);\n\n\tdown_read(&card->controls_rwsem);\n\tdown_read(&snd_ctl_layer_rwsem);\n\tfor (lops = snd_ctl_layer; lops; lops = lops->next)\n\t\tlops->ldisconnect(card);\n\tup_read(&snd_ctl_layer_rwsem);\n\tup_read(&card->controls_rwsem);\n\n\treturn snd_unregister_device(&card->ctl_dev);\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":523759,"func":"int BN_is_negative(const BIGNUM *a)\n{\n    return (a->neg != 0);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":223342,"func":"void WebContentsAndroid::OpenURL(JNIEnv* env,\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":466400,"func":"void ConnectionManagerImpl::doDeferredStreamDestroy(ActiveStream& stream) {\n  if (stream.max_stream_duration_timer_) {\n    stream.max_stream_duration_timer_->disableTimer();\n    stream.max_stream_duration_timer_ = nullptr;\n  }\n  if (stream.stream_idle_timer_ != nullptr) {\n    stream.stream_idle_timer_->disableTimer();\n    stream.stream_idle_timer_ = nullptr;\n  }\n  stream.filter_manager_.disarmRequestTimeout();\n  if (stream.request_header_timer_ != nullptr) {\n    stream.request_header_timer_->disableTimer();\n    stream.request_header_timer_ = nullptr;\n  }\n\n  stream.completeRequest();\n  stream.filter_manager_.onStreamComplete();\n  stream.filter_manager_.log();\n\n  stream.filter_manager_.destroyFilters();\n\n  read_callbacks_->connection().dispatcher().deferredDelete(stream.removeFromList(streams_));\n\n  if (connection_idle_timer_ && streams_.empty()) {\n    connection_idle_timer_->enableTimer(config_.idleTimeout().value());\n  }\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":270732,"func":"static void dwc3_ep_inc_enq(struct dwc3_ep *dep)\n{\n\tdwc3_ep_inc_trb(&dep->trb_enqueue);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":473054,"func":"k_rational_p(VALUE x)\n{\n    return f_kind_of_p(x, rb_cRational);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":292251,"func":"idtab_lookup(int version)\n{\n\tif (version < 1 || version > 2)\n\t\tfatal(\"internal error, bad protocol version %d\", version);\n\treturn &idtable[version];\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":428311,"func":"static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,\n\t\t\t    gfp_t gfp_mask)\n{\n\treturn __tcp_transmit_skb(sk, skb, clone_it, gfp_mask,\n\t\t\t\t  tcp_sk(sk)->rcv_nxt);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":307706,"func":"static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,\n\t\t\t\t\t bool file, int nr_pages)\n{\n\tpreempt_disable();\n\n\tif (file)\n\t\t__this_cpu_add(memcg->stat->count[MEM_CGROUP_STAT_CACHE],\n\t\t\t\tnr_pages);\n\telse\n\t\t__this_cpu_add(memcg->stat->count[MEM_CGROUP_STAT_RSS],\n\t\t\t\tnr_pages);\n\n\t\/* pagein of a big page is an event. So, ignore page size *\/\n\tif (nr_pages > 0)\n\t\t__this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PGPGIN]);\n\telse {\n\t\t__this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PGPGOUT]);\n\t\tnr_pages = -nr_pages; \/* for event *\/\n\t}\n\n\t__this_cpu_add(memcg->stat->events[MEM_CGROUP_EVENTS_COUNT], nr_pages);\n\n\tpreempt_enable();\n}\n","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":487964,"func":"    SampleEncrypter(AP4_CbcStreamCipher* stream_cipher, const AP4_UI08* iv):\n        m_StreamCipher(stream_cipher) {\n        AP4_CopyMemory(m_IV, iv, 16);\n    }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":44629,"func":"void credssp_free(rdpCredssp* credssp)\n{\n\tif (credssp != NULL)\n\t{\n\t\tif (credssp->table)\n\t\t\tcredssp->table->DeleteSecurityContext(&credssp->context);\n\n\t\tsspi_SecBufferFree(&credssp->PublicKey);\n\t\tsspi_SecBufferFree(&credssp->ts_credentials);\n\n\t\tfree(credssp->ServicePrincipalName);\n\n\t\tfree(credssp->identity.User);\n\t\tfree(credssp->identity.Domain);\n\t\tfree(credssp->identity.Password);\n\t\tfree(credssp);\n\t}\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":228096,"func":"void TabStripModel::SelectPreviousTab() {\n  SelectRelativeTab(false);\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":139178,"func":"void Magick::Image::affineTransform(const DrawableAffine &affine_)\n{\n  AffineMatrix\n    _affine;\n\n  MagickCore::Image\n    *newImage;\n\n  _affine.sx=affine_.sx();\n  _affine.sy=affine_.sy();\n  _affine.rx=affine_.rx();\n  _affine.ry=affine_.ry();\n  _affine.tx=affine_.tx();\n  _affine.ty=affine_.ty();\n\n  GetPPException;\n  newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);\n  replaceImage(newImage);\n  ThrowImageException;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":162608,"func":"void CommandBufferProxyImpl::CreateGpuFence(uint32_t gpu_fence_id,\n                                            ClientGpuFence source) {\n  CheckLock();\n  base::AutoLock lock(last_state_lock_);\n  if (last_state_.error != gpu::error::kNoError) {\n    DLOG(ERROR) << \"got error=\" << last_state_.error;\n    return;\n  }\n\n  gfx::GpuFence* gpu_fence = gfx::GpuFence::FromClientGpuFence(source);\n  gfx::GpuFenceHandle handle =\n      gfx::CloneHandleForIPC(gpu_fence->GetGpuFenceHandle());\n  Send(new GpuCommandBufferMsg_CreateGpuFenceFromHandle(route_id_, gpu_fence_id,\n                                                        handle));\n}\n","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":378203,"func":"static int selinux_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,\n\t\t\t\t    struct task_struct *target,\n\t\t\t\t    long type, int mode)\n{\n\tstruct ipc_security_struct *isec;\n\tstruct msg_security_struct *msec;\n\tstruct common_audit_data ad;\n\tstruct selinux_audit_data sad = {0,};\n\tu32 sid = task_sid(target);\n\tint rc;\n\n\tisec = msq->q_perm.security;\n\tmsec = msg->security;\n\n\tCOMMON_AUDIT_DATA_INIT(&ad, IPC);\n\tad.selinux_audit_data = &sad;\n\tad.u.ipc_id = msq->q_perm.key;\n\n\trc = avc_has_perm(sid, isec->sid,\n\t\t\t  SECCLASS_MSGQ, MSGQ__READ, &ad);\n\tif (!rc)\n\t\trc = avc_has_perm(sid, msec->sid,\n\t\t\t\t  SECCLASS_MSG, MSG__RECEIVE, &ad);\n\treturn rc;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":180610,"func":"bool StartupBrowserCreator::Start(const base::CommandLine& cmd_line,\n                                  const base::FilePath& cur_dir,\n                                  Profile* last_used_profile,\n                                  const Profiles& last_opened_profiles) {\n  TRACE_EVENT0(\"startup\", \"StartupBrowserCreator::Start\");\n  SCOPED_UMA_HISTOGRAM_TIMER(\"Startup.StartupBrowserCreator_Start\");\n  return ProcessCmdLineImpl(cmd_line, cur_dir, true, last_used_profile,\n                            last_opened_profiles);\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":42209,"func":"enum econn_state ecall_state(const struct ecall *ecall)\n{\n\tif (!ecall)\n\t\treturn ECONN_IDLE;\n\n\tif (ecall->econn) {\n\t\treturn econn_current_state(ecall->econn);\n\t}\n\telse {\n\t\treturn ECONN_IDLE;\n\t}\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":121320,"func":"static void t1_start_eexec(void)\n{\n    int i;\n    if (is_included(fm_cur)) {\n        get_length1();\n        save_offset();\n    }\n    if (!t1_pfa)\n        t1_check_block_len(false);\n    for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) {\n        edecrypt((byte)t1_getbyte());\n        *t1_line_ptr++ = 0;\n    }\n    t1_eexec_encrypt = true;\n    if (is_included(fm_cur))\n        t1_putline(); \/* to put the first four bytes *\/\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":83963,"func":"DecimalQuantity& DecimalQuantity::setToDecNum(const DecNum& decnum, UErrorCode& status) {\n    setBcdToZero();\n    flags = 0;\n\n    _setToDecNum(decnum, status);\n    return *this;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":491750,"func":"parser_set_continues_to_current_position (parser_context_t *context_p, \/**< context *\/\n                                          parser_branch_node_t *current_p) \/**< branch list *\/\n{\n  while (current_p != NULL)\n  {\n    if (current_p->branch.offset & CBC_HIGHEST_BIT_MASK)\n    {\n      parser_set_branch_to_current_position (context_p, ¤t_p->branch);\n    }\n    current_p = current_p->next_p;\n  }\n} \/* parser_set_continues_to_current_position *\/","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":174460,"func":"void ShelfLayoutManager::SetDockedMagnifierHeight(int height) {\n  docked_magnifier_height_ = height;\n  LayoutShelf();\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":393109,"func":"xmlSchemaAnnotDump(FILE * output, xmlSchemaAnnotPtr annot)\n{\n    xmlChar *content;\n\n    if (annot == NULL)\n        return;\n\n    content = xmlNodeGetContent(annot->content);\n    if (content != NULL) {\n        fprintf(output, \"  Annot: %s\\n\", content);\n        xmlFree(content);\n    } else\n        fprintf(output, \"  Annot: empty\\n\");\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":431641,"func":"bool AuthorizationSession::isAuthenticated() {\n    return _authenticatedUsers.begin() != _authenticatedUsers.end();\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":188609,"func":"void CoordinatorImpl::FinalizeGlobalMemoryDumpIfAllManagersReplied() {\n  TRACE_EVENT0(base::trace_event::MemoryDumpManager::kTraceCategory,\n               \"GlobalMemoryDump.Computation\");\n  DCHECK(!queued_memory_dump_requests_.empty());\n\n  QueuedRequest* request = &queued_memory_dump_requests_.front();\n  if (!request->dump_in_progress || request->pending_responses.size() > 0)\n    return;\n\n  QueuedRequestDispatcher::Finalize(request, tracing_observer_.get());\n\n  queued_memory_dump_requests_.pop_front();\n  request = nullptr;\n\n  if (!queued_memory_dump_requests_.empty()) {\n    base::SequencedTaskRunnerHandle::Get()->PostTask(\n        FROM_HERE,\n        base::Bind(&CoordinatorImpl::PerformNextQueuedGlobalMemoryDump,\n                   base::Unretained(this)));\n  }\n}\n","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":189978,"func":"  bool tap() const { return tap_; }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":170687,"func":"void PaletteTray::ClickedOutsideBubble() {\n  HidePalette();\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":209941,"func":"void ExtensionOptionsGuest::DidNavigateMainFrame(\n    const content::LoadCommittedDetails& details,\n    const content::FrameNavigateParams& params) {\n  if (attached()) {\n    auto guest_zoom_controller =\n        ui_zoom::ZoomController::FromWebContents(web_contents());\n    guest_zoom_controller->SetZoomMode(\n         ui_zoom::ZoomController::ZOOM_MODE_ISOLATED);\n     SetGuestZoomLevelToMatchEmbedder();\n \n    if (!url::IsSameOriginWith(params.url, options_page_)) {\n       bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(),\n                                       bad_message::EOG_BAD_ORIGIN);\n     }\n  }\n}\n","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":423493,"func":"dns_zone_getchecknames(dns_zone_t *zone) {\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\n\treturn (zone->check_names);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":273831,"func":"Lock_AF_UNIX(const char *unixSocketDir, const char *unixSocketPath)\n{\n\t\/* no lock file for abstract sockets *\/\n\tif (unixSocketPath[0] == '@')\n\t\treturn STATUS_OK;\n\n\t\/*\n\t * Grab an interlock file associated with the socket file.\n\t *\n\t * Note: there are two reasons for using a socket lock file, rather than\n\t * trying to interlock directly on the socket itself.  First, it's a lot\n\t * more portable, and second, it lets us remove any pre-existing socket\n\t * file without race conditions.\n\t *\/\n\tCreateSocketLockFile(unixSocketPath, true, unixSocketDir);\n\n\t\/*\n\t * Once we have the interlock, we can safely delete any pre-existing\n\t * socket file to avoid failure at bind() time.\n\t *\/\n\t(void) unlink(unixSocketPath);\n\n\t\/*\n\t * Remember socket file pathnames for later maintenance.\n\t *\/\n\tsock_paths = lappend(sock_paths, pstrdup(unixSocketPath));\n\n\treturn STATUS_OK;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":71932,"func":"size_t ConnectionImpl::dispatchSlice(const char* slice, size_t len) {\n  ssize_t rc = http_parser_execute(&parser_, &settings_, slice, len);\n  if (HTTP_PARSER_ERRNO(&parser_) != HPE_OK && HTTP_PARSER_ERRNO(&parser_) != HPE_PAUSED) {\n    sendProtocolError();\n    throw CodecProtocolException(\"http\/1.1 protocol error: \" +\n                                 std::string(http_errno_name(HTTP_PARSER_ERRNO(&parser_))));\n  }\n\n  return rc;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":73757,"func":"pq_discardbytes(size_t len)\n{\n\tsize_t\t\tamount;\n\n\tAssert(PqCommReadingMsg);\n\n\twhile (len > 0)\n\t{\n\t\twhile (PqRecvPointer >= PqRecvLength)\n\t\t{\n\t\t\tif (pq_recvbuf())\t\/* If nothing in buffer, then recv some *\/\n\t\t\t\treturn EOF;\t\t\/* Failed to recv data *\/\n\t\t}\n\t\tamount = PqRecvLength - PqRecvPointer;\n\t\tif (amount > len)\n\t\t\tamount = len;\n\t\tPqRecvPointer += amount;\n\t\tlen -= amount;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":95593,"func":"const Model* BuildModelWithOfflinePlanning(int number_of_tensors,\n                                           const int32_t* metadata_buffer,\n                                           NodeConnection* node_conn,\n                                           int num_conns,\n                                           int num_subgraph_inputs) {\n  using flatbuffers::Offset;\n  flatbuffers::FlatBufferBuilder* fb_builder = BuilderInstance();\n\n  ModelBuilder model_builder(fb_builder);\n\n  const int op_id =\n      model_builder.RegisterOp(BuiltinOperator_CUSTOM, \"mock_custom\",\n                               \/* version= *\/ 0);\n\n  for (int i = 0; i < number_of_tensors; ++i) {\n    model_builder.AddTensor(TensorType_FLOAT32, {2, 2, 3});\n  }\n\n  for (int i = 0; i < num_conns; ++i) {\n    model_builder.AddNode(op_id, node_conn[i].input, node_conn[i].output);\n  }\n\n  model_builder.AddMetadata(\n      \"OfflineMemoryAllocation\", metadata_buffer,\n      number_of_tensors + tflite::testing::kOfflinePlannerHeaderSize);\n\n  return model_builder.BuildModel(\n      node_conn[0].input, node_conn[num_conns - 1].output, num_subgraph_inputs);\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":267771,"func":"    template<typename t>\n    static int _isosurface3d_index(const unsigned int edge, const CImg<t>& indices1, const CImg<t>& indices2,\n                                    const unsigned int x, const unsigned int y,\n                                    const unsigned int nx, const unsigned int ny) {\n      switch (edge) {\n      case 0 : return indices1(x,y,0);\n      case 1 : return indices1(nx,y,1);\n      case 2 : return indices1(x,ny,0);\n      case 3 : return indices1(x,y,1);\n      case 4 : return indices2(x,y,0);\n      case 5 : return indices2(nx,y,1);\n      case 6 : return indices2(x,ny,0);\n      case 7 : return indices2(x,y,1);\n      case 8 : return indices1(x,y,2);\n      case 9 : return indices1(nx,y,2);\n      case 10 : return indices1(nx,ny,2);\n      case 11 : return indices1(x,ny,2);\n      }\n      return 0;","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":51446,"func":"\nstatic void pdo_stmt_iter_move_forwards(zend_object_iterator *iter TSRMLS_DC)\n{\n\tstruct php_pdo_iterator *I = (struct php_pdo_iterator*)iter->data;\n\n\tif (I->fetch_ahead) {\n\t\tzval_ptr_dtor(&I->fetch_ahead);\n\t\tI->fetch_ahead = NULL;\n\t}\n\n\tMAKE_STD_ZVAL(I->fetch_ahead);\n\n\tif (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT,\n\t\t\tPDO_FETCH_ORI_NEXT, 0, 0 TSRMLS_CC)) {\n\t\tpdo_stmt_t *stmt = I->stmt; \/* for PDO_HANDLE_STMT_ERR() *\/\n\n\t\tPDO_HANDLE_STMT_ERR();\n\t\tI->key = (ulong)-1;\n\t\tFREE_ZVAL(I->fetch_ahead);\n\t\tI->fetch_ahead = NULL;\n\n\t\treturn;\n\t}\n\n\tI->key++;","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":473537,"func":"xfs_iunpin(\n\tstruct xfs_inode\t*ip)\n{\n\tASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));\n\n\ttrace_xfs_inode_unpin_nowait(ip, _RET_IP_);\n\n\t\/* Give the log a push to start the unpinning I\/O *\/\n\txfs_log_force_lsn(ip->i_mount, ip->i_itemp->ili_last_lsn, 0, NULL);\n\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":109312,"func":"l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat, u_int length)\n{\n\tconst uint16_t *ptr = (const uint16_t *)dat;\n\n\tif (length < 2) {\n\t\tND_PRINT((ndo, \"AVP too short\"));\n\t\treturn;\n\t}\n\tND_PRINT((ndo, \"%s\", tok2str(l2tp_authentype2str,\n\t\t\t     \"AuthType-#%u\", EXTRACT_16BITS(ptr))));\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":69346,"func":"ipf_is_first_v6_frag(ovs_be16 ip6f_offlg)\n{\n    if (!(ip6f_offlg & IP6F_OFF_MASK) &&\n        ip6f_offlg & IP6F_MORE_FRAG) {\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":229267,"func":" virtual ~TileIndependenceTest() {\n delete fw_dec_;\n delete inv_dec_;\n }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":425106,"func":"static void mask2shift(uint32_t mask, int *right, int *left)\n{\n    int rshift = 0, lshift = 0;\n\n    if(!mask)\n    {\n        *right = *left = 0;\n        return;\n    }\n\n    while(!(mask & 1))\n    {\n        mask >>= 1;\n        rshift++;\n    }\n    *right = rshift;\n\n    while(mask & 1)\n    {\n        mask >>= 1;\n        lshift++;\n    }\n    *left = 12 - lshift;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":456788,"func":"static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page)\n{\n\treturn false;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":178585,"func":"nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p,\n\t\t\t\t\tstruct nfsd3_readdirres *resp)\n{\n\tp = encode_post_op_attr(rqstp, p, &resp->fh);\n\n\tif (resp->status == 0) {\n\t\t\/* stupid readdir cookie *\/\n\t\tmemcpy(p, resp->verf, 8); p += 2;\n\t\txdr_ressize_check(rqstp, p);\n\t\tif (rqstp->rq_res.head[0].iov_len + (2<<2) > PAGE_SIZE)\n\t\t\treturn 1; \/*No room for trailer *\/\n\t\trqstp->rq_res.page_len = (resp->count) << 2;\n\n\t\t\/* add the 'tail' to the end of the 'head' page - page 0. *\/\n\t\trqstp->rq_res.tail[0].iov_base = p;\n\t\t*p++ = 0;\t\t\/* no more entries *\/\n\t\t*p++ = htonl(resp->common.err == nfserr_eof);\n\t\trqstp->rq_res.tail[0].iov_len = 2<<2;\n\t\treturn 1;\n\t} else\n\t\treturn xdr_ressize_check(rqstp, p);\n}\n","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":296201,"func":"RandomCancelKey(int32 *cancel_key)\n{\n\treturn pg_strong_random(cancel_key, sizeof(int32));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":417843,"func":"static curl_off_t vms_realfilesize(const char * name,\n                                   const struct_stat * stat_buf)\n{\n  char buffer[8192];\n  curl_off_t count;\n  int ret_stat;\n  FILE * file;\n\n  file = fopen(name, \"r\"); \/* VMS *\/\n  if(file == NULL) {\n    return 0;\n  }\n  count = 0;\n  ret_stat = 1;\n  while(ret_stat > 0) {\n    ret_stat = fread(buffer, 1, sizeof(buffer), file);\n    if(ret_stat != 0)\n      count += ret_stat;\n  }\n  fclose(file);\n\n  return count;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":496583,"func":"void DataWriterImpl::disable()\n{\n    set_listener(nullptr);\n    if (writer_ != nullptr)\n    {\n        writer_->set_listener(nullptr);\n    }\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":68820,"func":"archive_read_support_format_mtree(struct archive *_a)\n{\n\tstruct archive_read *a = (struct archive_read *)_a;\n\tstruct mtree *mtree;\n\tint r;\n\n\tarchive_check_magic(_a, ARCHIVE_READ_MAGIC,\n\t    ARCHIVE_STATE_NEW, \"archive_read_support_format_mtree\");\n\n\tmtree = (struct mtree *)malloc(sizeof(*mtree));\n\tif (mtree == NULL) {\n\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t    \"Can't allocate mtree data\");\n\t\treturn (ARCHIVE_FATAL);\n\t}\n\tmemset(mtree, 0, sizeof(*mtree));\n\tmtree->fd = -1;\n\n\tr = __archive_read_register_format(a, mtree, \"mtree\",\n           mtree_bid, archive_read_format_mtree_options, read_header, read_data, skip, NULL, cleanup, NULL, NULL);\n\n\tif (r != ARCHIVE_OK)\n\t\tfree(mtree);\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":33208,"func":"void install_exec_creds(struct linux_binprm *bprm)\n{\n\tsecurity_bprm_committing_creds(bprm);\n\n\tcommit_creds(bprm->cred);\n\tbprm->cred = NULL;\n\t\/*\n\t * cred_guard_mutex must be held at least to this point to prevent\n\t * ptrace_attach() from altering our determination of the task's\n\t * credentials; any time after this it may be unlocked.\n\t *\/\n\tsecurity_bprm_committed_creds(bprm);\n\tmutex_unlock(¤t->signal->cred_guard_mutex);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":496441,"func":"getAutoExtensionsOfObject(Oid classId, Oid objectId)\n{\n\tList\t   *result = NIL;\n\tRelation\tdepRel;\n\tScanKeyData\tkey[2];\n\tSysScanDesc\tscan;\n\tHeapTuple\ttup;\n\n\tdepRel = table_open(DependRelationId, AccessShareLock);\n\n\tScanKeyInit(&key[0],\n\t\t\t\tAnum_pg_depend_classid,\n\t\t\t\tBTEqualStrategyNumber, F_OIDEQ,\n\t\t\t\tObjectIdGetDatum(classId));\n\tScanKeyInit(&key[1],\n\t\t\t\tAnum_pg_depend_objid,\n\t\t\t\tBTEqualStrategyNumber, F_OIDEQ,\n\t\t\t\tObjectIdGetDatum(objectId));\n\n\tscan = systable_beginscan(depRel, DependDependerIndexId, true,\n\t\t\t\t\t\t\t  NULL, 2, key);\n\n\twhile (HeapTupleIsValid((tup = systable_getnext(scan))))\n\t{\n\t\tForm_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);\n\n\t\tif (depform->refclassid == ExtensionRelationId &&\n\t\t\tdepform->deptype == DEPENDENCY_AUTO_EXTENSION)\n\t\t\tresult = lappend_oid(result, depform->refobjid);\n\t}\n\n\tsystable_endscan(scan);\n\n\ttable_close(depRel, AccessShareLock);\n\n\treturn result;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":192804,"func":"void ObjectBackedNativeHandler::RouteFunction(\n    const std::string& name,\n    const std::string& feature_name,\n    const HandlerFunction& handler_function) {\n  v8::Isolate* isolate = v8::Isolate::GetCurrent();\n  v8::HandleScope handle_scope(isolate);\n  v8::Context::Scope context_scope(context_->v8_context());\n\n  v8::Local<v8::Object> data = v8::Object::New(isolate);\n  SetPrivate(data, kHandlerFunction,\n             v8::External::New(isolate, new HandlerFunction(handler_function)));\n  DCHECK(feature_name.empty() ||\n         ExtensionAPI::GetSharedInstance()->GetFeatureDependency(feature_name))\n      << feature_name;\n  SetPrivate(data, kFeatureName,\n             v8_helpers::ToV8StringUnsafe(isolate, feature_name));\n  v8::Local<v8::FunctionTemplate> function_template =\n      v8::FunctionTemplate::New(isolate, Router, data);\n  v8::Local<v8::ObjectTemplate>::New(isolate, object_template_)\n      ->Set(isolate, name.c_str(), function_template);\n  router_data_.Append(data);\n}\n","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":70092,"func":"void CMSEXPORT cmsMLUfree(cmsMLU* mlu)\n{\n    if (mlu) {\n\n        if (mlu -> Entries) _cmsFree(mlu ->ContextID, mlu->Entries);\n        if (mlu -> MemPool) _cmsFree(mlu ->ContextID, mlu->MemPool);\n\n        _cmsFree(mlu ->ContextID, mlu);\n    }\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":141507,"func":"static void charstring_end(void)\n{\n  byte *bp;\n\n  sprintf(line, \"%d \", (int) (charstring_bp - charstring_buf));\n  eexec_string(line);\n  sprintf(line, \"%s \", cs_start);\n  eexec_string(line);\n  for (bp = charstring_buf; bp < charstring_bp; bp++)\n    eexec_byte(*bp);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":229925,"func":"void AutomationProvider::SelectAll(int tab_handle) {\n  RenderViewHost* view = GetViewForTab(tab_handle);\n  if (!view) {\n    NOTREACHED();\n    return;\n  }\n\n  view->SelectAll();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":304898,"func":"static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,\n\t\t\t\t\t     u32 mask)\n{\n\tstruct blkcipher_alg *cipher = &alg->cra_blkcipher;\n\tunsigned int len = alg->cra_ctxsize;\n\n\tif ((mask & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_MASK &&\n\t    cipher->ivsize) {\n\t\tlen = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);\n\t\tlen += cipher->ivsize;\n\t}\n\n\treturn len;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":298655,"func":"int install_process_keyring_to_cred(struct cred *new)\n{\n\tstruct key *keyring;\n\n\tif (new->process_keyring)\n\t\treturn -EEXIST;\n\n\tkeyring = keyring_alloc(\"_pid\", new->uid, new->gid, new,\n\t\t\t\tKEY_POS_ALL | KEY_USR_VIEW,\n\t\t\t\tKEY_ALLOC_QUOTA_OVERRUN, NULL);\n\tif (IS_ERR(keyring))\n\t\treturn PTR_ERR(keyring);\n\n\tnew->process_keyring = keyring;\n\treturn 0;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":17822,"func":"static void event_text ( const char * data , SERVER_REC * server , WI_ITEM_REC * item ) {\n char * line , * str , * target ;\n g_return_if_fail ( data != NULL ) ;\n if ( item == NULL ) return ;\n if ( * data == '\\0' ) {\n signal_stop ( ) ;\n return ;\n }\n line = settings_get_bool ( \"expand_escapes\" ) ? expand_escapes ( data , server , item ) : g_strdup ( data ) ;\n if ( completion_auto && IS_CHANNEL ( item ) ) {\n str = auto_complete ( CHANNEL ( item ) , line ) ;\n if ( str != NULL ) {\n g_free ( line ) ;\n line = str ;\n }\n }\n target = escape_string ( window_item_get_target ( item ) ) ;\n str = g_strdup_printf ( IS_CHANNEL ( item ) ? \"-channel \\\"%s\\\" %s\" : IS_QUERY ( item ) ? \"-nick \\\"%s\\\" %s\" : \"%s %s\" , target , line ) ;\n g_free ( target ) ;\n signal_emit ( \"command msg\" , 3 , str , server , item ) ;\n g_free ( str ) ;\n g_free ( line ) ;\n signal_stop ( ) ;\n }","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":148995,"func":"static int r_bin_print_xtrplugin_details(RBin *bin, RBinXtrPlugin *bx, int json) {\n\tif (json == 'q') {\n\t\tbin->cb_printf (\"%s\\n\", bx->name);\n\t} else if (json) {\n\t\tbin->cb_printf (\n\t\t\t\"{\\\"name\\\":\\\"%s\\\",\\\"description\\\":\\\"%s\\\",\"\n\t\t\t\"\\\"license\\\":\\\"%s\\\"}\\n\",\n\t\t\tbx->name, bx->desc, bx->license? bx->license: \"???\");\n\t} else {\n\t\tbin->cb_printf (\"Name: %s\\n\", bx->name);\n\t\tbin->cb_printf (\"Description: %s\\n\", bx->desc);\n\t\tif (bx->license) {\n\t\t\tbin->cb_printf (\"License: %s\\n\", bx->license);\n\t\t}\n\t}\n\treturn true;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":191183,"func":"name_owner_foreach (gpointer key, gpointer val, gpointer data)\n{\n  const char *owner;\n  DBusGProxyNameOwnerForeachData *foreach_data;\n  GSList *names;\n  GSList *link;\n\n  owner = key;\n  names = val;\n  foreach_data = data;\n\n  if (foreach_data->owner != NULL)\n    return;\n\n  g_assert (foreach_data->info == NULL);\n\n  link = g_slist_find_custom (names, foreach_data->name, find_name_in_info);\n  if (link)\n    {\n      foreach_data->owner = owner;\n      foreach_data->info = link->data;\n    }\n}\n","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":350210,"func":"static inline void io_req_work_drop_env(struct io_kiocb *req)\n{\n\tif (req->work.mm) {\n\t\tmmdrop(req->work.mm);\n\t\treq->work.mm = NULL;\n\t}\n\tif (req->work.creds) {\n\t\tput_cred(req->work.creds);\n\t\treq->work.creds = NULL;\n\t}\n}","target":1,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":198744,"func":"bool BaseArena::willObjectBeLazilySwept(BasePage* page,\n                                        void* objectPointer) const {\n  if (page != m_firstUnsweptPage)\n    return true;\n\n  DCHECK(!page->isLargeObjectPage());\n  NormalPage* normalPage = reinterpret_cast<NormalPage*>(page);\n  NormalPageArena* normalArena = normalPage->arenaForNormalPage();\n  if (!normalArena->isLazySweeping())\n    return true;\n\n  Address pageEnd = normalPage->payloadEnd();\n  for (Address headerAddress = normalPage->payload();\n       headerAddress < pageEnd;) {\n    HeapObjectHeader* header =\n        reinterpret_cast<HeapObjectHeader*>(headerAddress);\n    size_t size = header->size();\n    if (headerAddress > objectPointer)\n      return false;\n    if (!header->isFree() && header->isMarked()) {\n      DCHECK(headerAddress + size < pageEnd);\n      return true;\n    }\n    headerAddress += size;\n  }\n  NOTREACHED();\n  return true;\n}\n","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":169956,"func":"bool Document::IsValidName(const String& name) {\n  unsigned length = name.length();\n  if (!length)\n    return false;\n\n  if (name.Is8Bit()) {\n    const LChar* characters = name.Characters8();\n\n    if (IsValidNameASCII(characters, length))\n      return true;\n\n    return IsValidNameNonASCII(characters, length);\n  }\n\n  const UChar* characters = name.Characters16();\n\n  if (IsValidNameASCII(characters, length))\n    return true;\n\n  return IsValidNameNonASCII(characters, length);\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":181203,"func":"bool ChromeContentRendererClient::IsLinkVisited(unsigned long long link_hash) {\n  return visited_link_slave_->IsVisited(link_hash);\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":79254,"func":"bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,\n\t\t\t\t unsigned long *vcpu_bitmap, cpumask_var_t tmp)\n{\n\tint i, cpu, me;\n\tstruct kvm_vcpu *vcpu;\n\tbool called;\n\n\tme = get_cpu();\n\n\tkvm_for_each_vcpu(i, vcpu, kvm) {\n\t\tif (vcpu_bitmap && !test_bit(i, vcpu_bitmap))\n\t\t\tcontinue;\n\n\t\tkvm_make_request(req, vcpu);\n\t\tcpu = vcpu->cpu;\n\n\t\tif (!(req & KVM_REQUEST_NO_WAKEUP) && kvm_vcpu_wake_up(vcpu))\n\t\t\tcontinue;\n\n\t\tif (tmp != NULL && cpu != -1 && cpu != me &&\n\t\t    kvm_request_needs_ipi(vcpu, req))\n\t\t\t__cpumask_set_cpu(cpu, tmp);\n\t}\n\n\tcalled = kvm_kick_many_cpus(tmp, !!(req & KVM_REQUEST_WAIT));\n\tput_cpu();\n\n\treturn called;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":439749,"func":"static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest,\n\t\t\t\t SplashColorPtr blend, SplashColorMode cm) {\n  int i;\n\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n    }\n  }\n#endif\n  {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      blend[i] = dest[i] + src[i] - (dest[i] * src[i]) \/ 255;\n    }\n  }\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n      blend[i] = 255 - blend[i];\n    }\n  }\n#endif\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":339583,"func":"static int qsort_strcmp(const void *a, const void *b)\n\n{\n\n    return strcmp(a, b);\n\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":345880,"func":"_PUBLIC_ codepoint_t next_codepoint_ext(const char *str, charset_t src_charset,\n\t\t\t\t\tsize_t *size)\n{\n\treturn next_codepoint_handle_ext(get_iconv_handle(), str,\n\t\t\t\t\t      src_charset, size);\n}","target":1,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":248285,"func":"  void InitWaitForSelectionEvent(ui::SelectionEventType expected_event) {\n    DCHECK(!run_loop_);\n    expected_event_ = expected_event;\n    run_loop_.reset(new base::RunLoop());\n  }\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":308973,"func":"DEFINE_TRACE(RuleFeature)\n{\n    visitor->trace(rule);\n}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":184793,"func":"bool GetErrorQuery::End(base::subtle::Atomic32 submit_count) {\n  MarkAsPending(submit_count);\n  return MarkAsCompleted(manager()->decoder()->GetErrorState()->GetGLError());\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":389946,"func":"CertificateRequest::~CertificateRequest()\n{\n\n    STL::for_each(certificate_authorities_.begin(),\n                  certificate_authorities_.end(),\n                  del_ptr_zero()) ;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":508721,"func":"int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv)\n{\n    return EVP_CipherInit(ctx, cipher, key, iv, 0);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":10719,"func":"void ExtensionWebContentsObserver::RenderViewCreated(\n    content::RenderViewHost* render_view_host) {\n  const Extension* extension = GetExtension(render_view_host);\n   if (!extension)\n     return;\n \n  content::RenderProcessHost* process = render_view_host->GetProcess();\n  if (type == Manifest::TYPE_EXTENSION ||\n      type == Manifest::TYPE_LEGACY_PACKAGED_APP ||\n      (type == Manifest::TYPE_PLATFORM_APP &&\n       extension->location() == Manifest::COMPONENT)) {\n    content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(\n        process->GetID(), content::kChromeUIScheme);\n  }\n \n   if (type == Manifest::TYPE_EXTENSION ||\n       type == Manifest::TYPE_LEGACY_PACKAGED_APP) {\n     ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context_);\n     if (prefs->AllowFileAccess(extension->id())) {\n       content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(\n          process->GetID(), url::kFileScheme);\n     }\n   }\n \n  render_view_host->Send(new ExtensionMsg_ActivateExtension(extension->id()));\n}\n","target":1,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":246299,"func":"bool Extension::IsDisallowedExperimentalPermission(\n    ExtensionAPIPermission::ID permission) const {\n  return permission == ExtensionAPIPermission::kExperimental &&\n      !CommandLine::ForCurrentProcess()->HasSwitch(\n        switches::kEnableExperimentalExtensionApis);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":149593,"func":"add_msg_hist(\n    char_u\t*s,\n    int\t\tlen,\t\t\/\/ -1 for undetermined length\n    int\t\tattr)\n{\n    struct msg_hist *p;\n\n    if (msg_hist_off || msg_silent != 0)\n\treturn;\n\n    \/\/ Don't let the message history get too big\n    while (msg_hist_len > MAX_MSG_HIST_LEN)\n\t(void)delete_first_msg();\n\n    \/\/ allocate an entry and add the message at the end of the history\n    p = ALLOC_ONE(struct msg_hist);\n    if (p != NULL)\n    {\n\tif (len < 0)\n\t    len = (int)STRLEN(s);\n\t\/\/ remove leading and trailing newlines\n\twhile (len > 0 && *s == '\\n')\n\t{\n\t    ++s;\n\t    --len;\n\t}\n\twhile (len > 0 && s[len - 1] == '\\n')\n\t    --len;\n\tp->msg = vim_strnsave(s, len);\n\tp->next = NULL;\n\tp->attr = attr;\n\tif (last_msg_hist != NULL)\n\t    last_msg_hist->next = p;\n\tlast_msg_hist = p;\n\tif (first_msg_hist == NULL)\n\t    first_msg_hist = last_msg_hist;\n\t++msg_hist_len;\n    }\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":503846,"func":"Status ServerConnectionImpl::onMessageBeginBase() {\n  if (!resetStreamCalled()) {\n    ASSERT(active_request_ == nullptr);\n    active_request_ = std::make_unique<ActiveRequest>(*this, std::move(bytes_meter_before_stream_));\n    if (resetStreamCalled()) {\n      return codecClientError(\"cannot create new streams after calling reset\");\n    }\n    active_request_->request_decoder_ = &callbacks_.newStream(active_request_->response_encoder_);\n\n    \/\/ Check for pipelined request flood as we prepare to accept a new request.\n    \/\/ Parse errors that happen prior to onMessageBegin result in stream termination, it is not\n    \/\/ possible to overflow output buffers with early parse errors.\n    RETURN_IF_ERROR(doFloodProtectionChecks());\n  }\n  return okStatus();\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":173408,"func":"void OmniboxViewWin::OnCopy() {\n  string16 text(GetSelectedText());\n  if (text.empty())\n    return;\n\n  CHARRANGE sel;\n  GURL url;\n  bool write_url = false;\n  GetSel(sel);\n  model_->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url);\n  ui::ScopedClipboardWriter scw(g_browser_process->clipboard());\n  scw.WriteText(text);\n  if (write_url) {\n    scw.WriteBookmark(text, url.spec());\n    scw.WriteHyperlink(net::EscapeForHTML(text), url.spec());\n  }\n}\n","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":464366,"func":"static long vhost_vdpa_set_config(struct vhost_vdpa *v,\n\t\t\t\t  struct vhost_vdpa_config __user *c)\n{\n\tstruct vdpa_device *vdpa = v->vdpa;\n\tconst struct vdpa_config_ops *ops = vdpa->config;\n\tstruct vhost_vdpa_config config;\n\tunsigned long size = offsetof(struct vhost_vdpa_config, buf);\n\tu8 *buf;\n\n\tif (copy_from_user(&config, c, size))\n\t\treturn -EFAULT;\n\tif (vhost_vdpa_config_validate(v, &config))\n\t\treturn -EINVAL;\n\n\tbuf = vmemdup_user(c->buf, config.len);\n\tif (IS_ERR(buf))\n\t\treturn PTR_ERR(buf);\n\n\tops->set_config(vdpa, config.off, buf, config.len);\n\n\tkvfree(buf);\n\treturn 0;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":486839,"func":"void KrecipesView::showRecipes( const QList<int> &recipeIDs )\n{\n\tif ( viewPanel->loadRecipes( recipeIDs ) )\n\t\tslotSetPanel( RecipeView );\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":407262,"func":"aspath_add_seq (struct aspath *aspath, as_t asno)\n{\n  return aspath_add_asns (aspath, asno, AS_SEQUENCE, 1);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":405958,"func":"parse_port_mod_ethernet_property(struct ofpbuf *property,\n                                 struct ofputil_port_mod *pm)\n{\n    ovs_be32 advertise;\n    enum ofperr error;\n\n    error = ofpprop_parse_be32(property, &advertise);\n    if (!error) {\n        pm->advertise = netdev_port_features_from_ofp11(advertise);\n    }\n    return error;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":334875,"func":"static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c)\n\n{\n\n    const char *proto = avio_find_protocol_name(s->filename);\n\n    int http_base_proto = !av_strcasecmp(proto, \"http\") || !av_strcasecmp(proto, \"https\");\n\n\n\n    if (c->method) {\n\n        av_dict_set(options, \"method\", c->method, 0);\n\n    } else if (proto && http_base_proto) {\n\n        av_log(c, AV_LOG_WARNING, \"No HTTP method set, hls muxer defaulting to method PUT.\\n\");\n\n        av_dict_set(options, \"method\", \"PUT\", 0);\n\n    }\n\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":357287,"func":"int cap_netlink_recv(struct sk_buff *skb, int cap)\n{\n\tif (!cap_raised(NETLINK_CB(skb).eff_cap, cap))\n\t\treturn -EPERM;\n\treturn 0;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":79571,"func":"static VALUE cState_space_before(VALUE self)\n{\n    GET_STATE(self);\n    return state->space_before ? rb_str_new(state->space_before, state->space_before_len) : rb_str_new2(\"\");\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":186436,"func":"void TabSpecificContentSettings::OnGeolocationPermissionSet(\n    const GURL& requesting_origin,\n    bool allowed) {\n  geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,\n                                                         allowed);\n  content::NotificationService::current()->Notify(\n      chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,\n      content::Source<WebContents>(web_contents()),\n      content::NotificationService::NoDetails());\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":438253,"func":"  uint64_t matrix_coefficients() const { return matrix_coefficients_; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":193916,"func":"polling_inhibitor_disconnected_cb (Inhibitor *inhibitor,\n                                   Device *device)\n{\n  device->priv->polling_inhibitors = g_list_remove (device->priv->polling_inhibitors, inhibitor);\n  g_signal_handlers_disconnect_by_func (inhibitor, polling_inhibitor_disconnected_cb, device);\n  g_object_unref (inhibitor);\n\n  update_info (device);\n  drain_pending_changes (device, FALSE);\n  daemon_local_update_poller (device->priv->daemon);\n}\n","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":409345,"func":"static void bnx2x_pf_q_prep_general(struct bnx2x *bp,\n\tstruct bnx2x_fastpath *fp, struct bnx2x_general_setup_params *gen_init,\n\tu8 cos)\n{\n\tgen_init->stat_id = bnx2x_stats_id(fp);\n\tgen_init->spcl_id = fp->cl_id;\n\n\t\/* Always use mini-jumbo MTU for FCoE L2 ring *\/\n\tif (IS_FCOE_FP(fp))\n\t\tgen_init->mtu = BNX2X_FCOE_MINI_JUMBO_MTU;\n\telse\n\t\tgen_init->mtu = bp->dev->mtu;\n\n\tgen_init->cos = cos;\n\n\tgen_init->fp_hsi = ETH_FP_HSI_VERSION;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":449843,"func":"tok_match(const struct Token *a, const struct Token *b)\n{\n    return a->type == b->type && tok_text_match(a, b);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":275028,"func":"static void Float32ArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  v8::Local<v8::Object> holder = info.Holder();\n\n  TestObject* impl = V8TestObject::ToImpl(holder);\n\n  V8SetReturnValueFast(info, impl->float32ArrayAttribute(), impl);\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":142431,"func":"\n      static double mp_image_stats(_cimg_math_parser& mp) {\n        double *ptrd = &_mp_arg(1) + 1;\n        unsigned int ind = (unsigned int)mp.opcode[2];\n        if (ind==~0U) CImg<doubleT>(ptrd,14,1,1,1,true) = mp.imgout.get_stats();\n        else {\n          ind = (unsigned int)cimg::mod((int)_mp_arg(2),mp.listin.width());\n          CImg<doubleT>(ptrd,14,1,1,1,true) = mp.listout[ind].get_stats();\n        }\n        return cimg::type<double>::nan();","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":346390,"func":"static int mb86a20s_read_status(struct dvb_frontend *fe, enum fe_status *status)\n{\n\tstruct mb86a20s_state *state = fe->demodulator_priv;\n\tint val;\n\n\t*status = 0;\n\n\tval = mb86a20s_readreg(state, 0x0a) & 0xf;\n\tif (val < 0)\n\t\treturn val;\n\n\tif (val >= 2)\n\t\t*status |= FE_HAS_SIGNAL;\n\n\tif (val >= 4)\n\t\t*status |= FE_HAS_CARRIER;\n\n\tif (val >= 5)\n\t\t*status |= FE_HAS_VITERBI;\n\n\tif (val >= 7)\n\t\t*status |= FE_HAS_SYNC;\n\n\tif (val >= 8)\t\t\t\t\/* Maybe 9? *\/\n\t\t*status |= FE_HAS_LOCK;\n\n\tdev_dbg(&state->i2c->dev, \"%s: Status = 0x%02x (state = %d)\\n\",\n\t\t __func__, *status, val);\n\n\treturn val;\n}","target":1,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":373842,"func":"        void getQueryStuff(const char *&query, int& ntoreturn) {\n            int *i = (int *) (data + strlen(data) + 1);\n            ntoreturn = *i;\n            i++;\n            query = (const char *) i;\n        }","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":497260,"func":"static void parse_sec_attr(sc_file_t *file, const u8 *buf, size_t len)\n{\n\tsize_t i;\n\tconst int *idx;\n\n\tidx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;\n\n\t\/* acl defaults to 0xFF if unspecified *\/\n\tfor (i = 0; i < 9; i++)\n\t\tif (idx[i] != -1)\n\t\t\tadd_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF));\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":180365,"func":"void UserCloudPolicyManagerChromeOS::StartRefreshSchedulerIfReady() {\n  if (core()->refresh_scheduler())\n    return;  \/\/ Already started.\n\n  if (wait_for_policy_fetch_)\n    return;  \/\/ Still waiting for the initial, blocking fetch.\n\n  if (!service() || !local_state_)\n    return;  \/\/ Not connected.\n\n  if (component_policy_service() &&\n      !component_policy_service()->is_initialized()) {\n    return;\n  }\n\n  core()->StartRefreshScheduler();\n  core()->TrackRefreshDelayPref(local_state_,\n                                policy_prefs::kUserPolicyRefreshRate);\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":308255,"func":"static void ParseCharacterContent(XMLTreeRoot *root,char *xml,\n  const size_t length,const char state)\n{\n  XMLTreeInfo\n    *xml_info;\n\n  xml_info=root->node;\n  if ((xml_info == (XMLTreeInfo *) NULL) || (xml_info->tag == (char *) NULL) ||\n      (length == 0))\n    return;\n  xml[length]='\\0';\n  xml=ParseEntities(xml,root->entities,state);\n  if ((xml_info->content != (char *) NULL) && (*xml_info->content != '\\0'))\n    {\n      (void) ConcatenateString(&xml_info->content,xml);\n      xml=DestroyString(xml);\n    }\n  else\n    {\n      if (xml_info->content != (char *) NULL)\n        xml_info->content=DestroyString(xml_info->content);\n      xml_info->content=xml;\n    }\n}\n","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":124137,"func":"static inline bool is_invalid_opcode(u32 intr_info)\n{\n\treturn (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK |\n\t\t\t     INTR_INFO_VALID_MASK)) ==\n\t\t(INTR_TYPE_HARD_EXCEPTION | UD_VECTOR | INTR_INFO_VALID_MASK);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":172270,"func":"int FileStream::Read(IOBuffer* buf,\n                     int buf_len,\n                     const CompletionCallback& callback) {\n  if (!IsOpen())\n    return ERR_UNEXPECTED;\n\n  DCHECK_GT(buf_len, 0);\n\n  return context_->Read(buf, buf_len, callback);\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":179401,"func":"void ChromeContentUtilityClient::RegisterMojoServices(\n    content::ServiceRegistry* registry) {\n#if !defined(OS_ANDROID)\n  registry->AddService<net::interfaces::ProxyResolverFactory>(\n      base::Bind(CreateProxyResolverFactory));\n  registry->AddService<ResourceUsageReporter>(\n      base::Bind(CreateResourceUsageReporter));\n#endif\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":26664,"func":"static bool str_array_contains ( ARRAY_TYPE ( const_string ) * arr , const char * str ) {\n const char * const * p ;\n array_foreach ( arr , p ) {\n if ( strcmp ( * p , str ) == 0 ) return TRUE ;\n }\n return FALSE ;\n }","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":449432,"func":"void ttm_tt_unbind(struct ttm_tt *ttm)\n{\n\tif (ttm->state == tt_bound) {\n\t\tttm->func->unbind(ttm);\n\t\tttm->state = tt_unbound;\n\t}\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":366810,"func":"static int selinux_secmark_enabled(void)\n{\n\treturn (atomic_read(&selinux_secmark_refcount) > 0);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":401640,"func":"static zend_always_inline int add_function_fast(zval *result, zval *op1, zval *op2) \/* {{{ *\/\n{\n\tzend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2));\n\n\tif (EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_LONG))) {\n\t\tfast_long_add_function(result, op1, op2);\n\t\treturn SUCCESS;\n\t} else if (EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_DOUBLE))) {\n\t\tZVAL_DOUBLE(result, Z_DVAL_P(op1) + Z_DVAL_P(op2));\n\t\treturn SUCCESS;\n\t} else if (EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_DOUBLE))) {\n\t\tZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2));\n\t\treturn SUCCESS;\n\t} else if (EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_LONG))) {\n\t\tZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2)));\n\t\treturn SUCCESS;\n\t} else if (EXPECTED(type_pair == TYPE_PAIR(IS_ARRAY, IS_ARRAY))) {\n\t\tadd_function_array(result, op1, op2);\n\t\treturn SUCCESS;\n\t} else {\n\t\treturn FAILURE;\n\t}\n} \/* }}} *\/","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":104877,"func":"file_push_buffer(struct magic_set *ms)\n{\n\tfile_pushbuf_t *pb;\n\n\tif (ms->event_flags & EVENT_HAD_ERR)\n\t\treturn NULL;\n\n\tif ((pb = (CAST(file_pushbuf_t *, malloc(sizeof(*pb))))) == NULL)\n\t\treturn NULL;\n\n\tpb->buf = ms->o.buf;\n\tpb->offset = ms->offset;\n\n\tms->o.buf = NULL;\n\tms->offset = 0;\n\n\treturn pb;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":129679,"func":"\nstatic int ims_pcu_init_bootloader_mode(struct ims_pcu *pcu)\n{\n\tint error;\n\n\terror = ims_pcu_execute_bl_command(pcu, QUERY_DEVICE, NULL, 0,\n\t\t\t\t\t   IMS_PCU_CMD_RESPONSE_TIMEOUT);\n\tif (error) {\n\t\tdev_err(pcu->dev, \"Bootloader does not respond, aborting\\n\");\n\t\treturn error;\n\t}\n\n\tpcu->fw_start_addr =\n\t\tget_unaligned_le32(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET + 11]);\n\tpcu->fw_end_addr =\n\t\tget_unaligned_le32(&pcu->cmd_buf[IMS_PCU_DATA_OFFSET + 15]);\n\n\tdev_info(pcu->dev,\n\t\t \"Device is in bootloader mode (addr 0x%08x-0x%08x), requesting firmware\\n\",\n\t\t pcu->fw_start_addr, pcu->fw_end_addr);\n\n\terror = request_firmware_nowait(THIS_MODULE, true,\n\t\t\t\t\tIMS_PCU_FIRMWARE_NAME,\n\t\t\t\t\tpcu->dev, GFP_KERNEL, pcu,\n\t\t\t\t\tims_pcu_process_async_firmware);\n\tif (error) {\n\t\t\/* This error is not fatal, let userspace have another chance *\/\n\t\tcomplete(&pcu->async_firmware_done);\n\t}\n\n\treturn 0;","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":9105,"func":"char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags)\n{\n\/\/    if (!dd->locked)\n\/\/        error_msg_and_die(\"dump_dir is not opened\"); \/* bug *\/\n\n    \/* Compat with old abrt dumps. Remove in abrt-2.1 *\/\n    if (strcmp(name, \"release\") == 0)\n        name = FILENAME_OS_RELEASE;\n\n    char *full_path = concat_path_file(dd->dd_dirname, name);\n    char *ret = load_text_file(full_path, flags);\n    free(full_path);\n\n    return ret;\n}","target":1,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":519984,"func":"  void set_first_query_block(Query_cache_block *first_query_block_arg)\n  {\n    first_query_block= first_query_block_arg;\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":48134,"func":"static unsigned int hiddev_poll(struct file *file, poll_table *wait)\n{\n\tstruct hiddev_list *list = file->private_data;\n\n\tpoll_wait(file, &list->hiddev->wait, wait);\n\tif (list->head != list->tail)\n\t\treturn POLLIN | POLLRDNORM;\n\tif (!list->hiddev->exist)\n\t\treturn POLLERR | POLLHUP;\n\treturn 0;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":518610,"func":"  virtual void get_image(uchar *buff, uint length, CHARSET_INFO *cs)\n    { memcpy(buff,ptr,length); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":494910,"func":"static unsigned long snd_pcm_get_unmapped_area(struct file *file,\n\t\t\t\t\t       unsigned long addr,\n\t\t\t\t\t       unsigned long len,\n\t\t\t\t\t       unsigned long pgoff,\n\t\t\t\t\t       unsigned long flags)\n{\n\tstruct snd_pcm_file *pcm_file = file->private_data;\n\tstruct snd_pcm_substream *substream = pcm_file->substream;\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tunsigned long offset = pgoff << PAGE_SHIFT;\n\n\tswitch (offset) {\n\tcase SNDRV_PCM_MMAP_OFFSET_STATUS_NEW:\n\t\treturn (unsigned long)runtime->status;\n\tcase SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW:\n\t\treturn (unsigned long)runtime->control;\n\tdefault:\n\t\treturn (unsigned long)runtime->dma_area + offset;\n\t}\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":431062,"func":"static int sisusb_write_memio_byte(struct sisusb_usb_data *sisusb, int type,\n\t\tu32 addr, u8 data)\n{\n\tstruct sisusb_packet packet;\n\n\tpacket.header  = (1 << (addr & 3)) | (type << 6);\n\tpacket.address = addr & ~3;\n\tpacket.data    = data << ((addr & 3) << 3);\n\treturn sisusb_send_packet(sisusb, 10, &packet);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":307033,"func":"GDataFileSystem::~GDataFileSystem() {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n\n  feed_loader_->RemoveObserver(this);\n\n  documents_service_->CancelAll();\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":159757,"func":"CACHE_BITMAP_V2_ORDER* copy_cache_bitmap_v2_order(rdpContext* context,\n                                                  const CACHE_BITMAP_V2_ORDER* order)\n{\n\tCACHE_BITMAP_V2_ORDER* dst = calloc(1, sizeof(CACHE_BITMAP_V2_ORDER));\n\n\tif (!dst || !order)\n\t\tgoto fail;\n\n\t*dst = *order;\n\n\tif (order->bitmapLength > 0)\n\t{\n\t\tdst->bitmapDataStream = malloc(order->bitmapLength);\n\n\t\tif (!dst->bitmapDataStream)\n\t\t\tgoto fail;\n\n\t\tmemcpy(dst->bitmapDataStream, order->bitmapDataStream, order->bitmapLength);\n\t}\n\n\treturn dst;\nfail:\n\tfree_cache_bitmap_v2_order(context, dst);\n\treturn NULL;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":32701,"func":"static void init_cv_nb10_header(SCV_NB10_HEADER* cv_nb10_header) {\n\tmemset (cv_nb10_header, 0, sizeof (SCV_NB10_HEADER));\n\tcv_nb10_header->free = (void (*)(struct SCV_NB10_HEADER*))free_cv_nb10_header;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":288819,"func":"static void dissect_zcl_ota_file_version_field ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {\n static const int * file_version [ ] = {\n & hf_zbee_zcl_ota_file_version_appl_release , & hf_zbee_zcl_ota_file_version_appl_build , & hf_zbee_zcl_ota_file_version_stack_release , & hf_zbee_zcl_ota_file_version_stack_build , NULL }\n ;\n proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_ota_file_version , ett_zbee_zcl_ota_file_version , file_version , ENC_BIG_ENDIAN ) ;\n * offset += 4 ;\n }","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":147443,"func":"static int write_reuc_extension(git_index *index, git_filebuf *file)\n{\n\tgit_buf reuc_buf = GIT_BUF_INIT;\n\tgit_vector *out = &index->reuc;\n\tgit_index_reuc_entry *reuc;\n\tstruct index_extension extension;\n\tsize_t i;\n\tint error = 0;\n\n\tgit_vector_foreach(out, i, reuc) {\n\t\tif ((error = create_reuc_extension_data(&reuc_buf, reuc)) < 0)\n\t\t\tgoto done;\n\t}\n\n\tmemset(&extension, 0x0, sizeof(struct index_extension));\n\tmemcpy(&extension.signature, INDEX_EXT_UNMERGED_SIG, 4);\n\textension.extension_size = (uint32_t)reuc_buf.size;\n\n\terror = write_extension(file, &extension, &reuc_buf);\n\n\tgit_buf_free(&reuc_buf);\n\ndone:\n\treturn error;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":188771,"func":"  bool is_showing() const {\n    return static_cast<content::TestRenderWidgetHostView*>(\n        GetRenderViewHostForTesting()->GetView())->is_showing();\n  }\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":244234,"func":"  BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) {\n    DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER);\n    BufferManager::BufferInfo* info = target == GL_ARRAY_BUFFER ?\n        bound_array_buffer_ : bound_element_array_buffer_;\n    return info;\n  }\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":247973,"func":"Node::InsertionNotificationRequest HTMLInputElement::InsertedInto(\n    ContainerNode* insertion_point) {\n  TextControlElement::InsertedInto(insertion_point);\n  if (insertion_point->isConnected() && !Form())\n    AddToRadioButtonGroup();\n  ResetListAttributeTargetObserver();\n  LogAddElementIfIsolatedWorldAndInDocument(\"input\", typeAttr, formactionAttr);\n  return kInsertionShouldCallDidNotifySubtreeInsertions;\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":75512,"func":"qemuProcessHandleAgentEOF(qemuAgentPtr agent,\n                          virDomainObjPtr vm)\n{\n    qemuDomainObjPrivatePtr priv;\n\n    VIR_DEBUG(\"Received EOF from agent on %p '%s'\", vm, vm->def->name);\n\n    virObjectLock(vm);\n\n    priv = vm->privateData;\n\n    if (!priv->agent) {\n        VIR_DEBUG(\"Agent freed already\");\n        goto unlock;\n    }\n\n    if (priv->beingDestroyed) {\n        VIR_DEBUG(\"Domain is being destroyed, agent EOF is expected\");\n        goto unlock;\n    }\n\n    qemuAgentClose(agent);\n    priv->agent = NULL;\n    priv->agentError = false;\n\n    virObjectUnlock(vm);\n    return;\n\n unlock:\n    virObjectUnlock(vm);\n    return;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":165709,"func":"void WebContentsImpl::OnDidRunInsecureContent(\n    const std::string& security_origin, const GURL& target_url) {\n  LOG(WARNING) << security_origin << \" ran insecure content from \"\n               << target_url.possibly_invalid_spec();\n  RecordAction(base::UserMetricsAction(\"SSL.RanInsecureContent\"));\n  if (EndsWith(security_origin, kDotGoogleDotCom, false))\n    RecordAction(base::UserMetricsAction(\"SSL.RanInsecureContentGoogle\"));\n  controller_.ssl_manager()->DidRunInsecureContent(security_origin);\n  displayed_insecure_content_ = true;\n  SSLManager::NotifySSLInternalStateChanged(\n      GetController().GetBrowserContext());\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":15031,"func":"static int idr_start ( struct archive_write * a , struct idr * idr , int cnt , int ffmax , int num_size , int null_size , const struct archive_rb_tree_ops * rbt_ops ) {\n int r ;\n ( void ) ffmax ;\n r = idr_ensure_poolsize ( a , idr , cnt ) ;\n if ( r != ARCHIVE_OK ) return ( r ) ;\n __archive_rb_tree_init ( & ( idr -> rbtree ) , rbt_ops ) ;\n idr -> wait_list . first = NULL ;\n idr -> wait_list . last = & ( idr -> wait_list . first ) ;\n idr -> pool_idx = 0 ;\n idr -> num_size = num_size ;\n idr -> null_size = null_size ;\n return ( ARCHIVE_OK ) ;\n }","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":187751,"func":"void FrameLoader::detachFromParent()\n{\n    RefPtr<Frame> protect(m_frame);\n\n    closeURL();\n    stopAllLoaders();\n    history()->saveScrollPositionAndViewStateToItem(history()->currentItem());\n    detachChildren();\n\n#if ENABLE(INSPECTOR)\n    if (Page* page = m_frame->page())\n        page->inspectorController()->frameDetachedFromParent(m_frame);\n#endif\n\n    detachViewsAndDocumentLoader();\n\n    if (Frame* parent = m_frame->tree()->parent()) {\n        parent->loader()->closeAndRemoveChild(m_frame);\n        parent->loader()->scheduleCheckCompleted();\n    } else {\n        m_frame->setView(0);\n        m_frame->pageDestroyed();\n    }\n}\n","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":454514,"func":"TEST_F(DateExpressionTest, AcceptsObjectIds) {\n    auto expCtx = getExpCtx();\n    for (auto&& expName : dateExpressions) {\n        BSONObj spec = BSON(expName << \"$oid\");\n        auto dateExp = Expression::parseExpression(expCtx, spec, expCtx->variablesParseState);\n        auto contextDoc = Document{{\"oid\", OID::gen()}};\n        dateExp->evaluate(contextDoc);  \/\/ Should not throw.\n    }\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":158429,"func":"test_custom_timeout (Test *test,\n                     gconstpointer data)\n{\n  cockpit_expect_message (\"*session timed out*\");\n  test_custom_fail (test, data);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":384749,"func":"static char* get_executable(pid_t pid, int *fd_p)\n{\n    char buf[sizeof(\"\/proc\/%lu\/exe\") + sizeof(long)*3];\n\n    sprintf(buf, \"\/proc\/%lu\/exe\", (long)pid);\n    if (fd_p)\n        *fd_p = open(buf, O_RDONLY); \/* might fail and return -1, it's ok *\/\n    char *executable = malloc_readlink(buf);\n    if (!executable)\n        return NULL;\n    \/* find and cut off \" (deleted)\" from the path *\/\n    char *deleted = executable + strlen(executable) - strlen(\" (deleted)\");\n    if (deleted > executable && strcmp(deleted, \" (deleted)\") == 0)\n    {\n        *deleted = '\\0';\n        log(\"File '%s' seems to be deleted\", executable);\n    }\n    \/* find and cut off prelink suffixes from the path *\/\n    char *prelink = executable + strlen(executable) - strlen(\".#prelink#.XXXXXX\");\n    if (prelink > executable && strncmp(prelink, \".#prelink#.\", strlen(\".#prelink#.\")) == 0)\n    {\n        log(\"File '%s' seems to be a prelink temporary file\", executable);\n        *prelink = '\\0';\n    }\n    return executable;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":204701,"func":"static void activityLoggedAttrGetter2AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n    TestObjectV8Internal::activityLoggedAttrGetter2AttributeSetter(jsValue, info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":371656,"func":"context_offers_target (GdkDragContext *context,\n\t\t       GdkAtom target)\n{\n\treturn (g_list_find (gdk_drag_context_list_targets (context), target) != NULL);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":209353,"func":"UsbCloseDeviceFunction::UsbCloseDeviceFunction() {\n}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":143670,"func":"bool kvm_rdpmc(struct kvm_vcpu *vcpu)\n{\n\tu32 ecx = kvm_register_read(vcpu, VCPU_REGS_RCX);\n\tu64 data;\n\tint err;\n\n\terr = kvm_pmu_rdpmc(vcpu, ecx, &data);\n\tif (err)\n\t\treturn err;\n\tkvm_register_write(vcpu, VCPU_REGS_RAX, (u32)data);\n\tkvm_register_write(vcpu, VCPU_REGS_RDX, data >> 32);\n\treturn err;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":353661,"func":"rsvg_state_finalize (RsvgState * state)\n{\n    g_free (state->font_family);\n    g_free (state->lang);\n    rsvg_paint_server_unref (state->fill);\n    rsvg_paint_server_unref (state->stroke);\n\n    if (state->dash.n_dash != 0)\n        g_free (state->dash.dash);\n\n    if (state->styles) {\n        g_hash_table_unref (state->styles);\n        state->styles = NULL;\n    }\n}","target":1,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":58816,"func":"Perl_croak_no_modify(void)\n{\n    Perl_croak_nocontext( \"%s\", PL_no_modify);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":213503,"func":"Capturer* ScreenRecorder::capturer() {\n  DCHECK_EQ(capture_loop_, MessageLoop::current());\n  DCHECK(capturer_);\n  return capturer_;\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":143884,"func":"void *napi_alloc_frag(unsigned int fragsz)\n{\n\treturn __napi_alloc_frag(fragsz, GFP_ATOMIC | __GFP_COLD);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":270324,"func":"  explicit BoostedTreesQuantileStreamResourceFlushOp(\n      OpKernelConstruction* const context)\n      : OpKernel(context) {\n    OP_REQUIRES_OK(context,\n                   context->GetAttr(kGenerateQuantiles, &generate_quantiles_));\n  }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":41348,"func":"static bool exec_command_on_flag(RFlagItem *flg, void *u) {\n\tstruct exec_command_t *user = (struct exec_command_t *)u;\n\tr_core_block_size (user->core, flg->size);\n\tr_core_seek (user->core, flg->offset, 1);\n\tr_core_cmd0 (user->core, user->cmd);\n\treturn true;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":197276,"func":" static int uhid_write(int fd, const struct uhid_event *ev)\n {\n    ssize_t ret = TEMP_FAILURE_RETRY(write(fd, ev, sizeof(*ev)));\n     if (ret < 0){\n         int rtn = -errno;\n         APPL_TRACE_ERROR(\"%s: Cannot write to uhid:%s\",\n                         __FUNCTION__, strerror(errno));\n return rtn;\n } else if (ret != (ssize_t)sizeof(*ev)) {\n        APPL_TRACE_ERROR(\"%s: Wrong size written to uhid: %zd != %zu\",\n                         __FUNCTION__, ret, sizeof(*ev));\n return -EFAULT;\n }\n\n return 0;\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":439680,"func":"void SplashOutputDev::clearPatternOpacity(GfxState *state) {\n  splash->clearPatternAlpha();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":108798,"func":"static void test_bug10214()\n{\n  int   len;\n  char  out[8];\n\n  myheader(\"test_bug10214\");\n\n  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES));\n\n  len= mysql_real_escape_string(mysql, out, \"a'b\\\\c\", 5);\n  DIE_UNLESS(memcmp(out, \"a\\\\'b\\\\\\\\c\", len) == 0);\n\n  mysql_query(mysql, \"set sql_mode='NO_BACKSLASH_ESCAPES'\");\n  DIE_UNLESS(mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES);\n\n  len= mysql_real_escape_string(mysql, out, \"a'b\\\\c\", 5);\n  DIE_UNLESS(memcmp(out, \"a''b\\\\c\", len) == 0);\n\n  mysql_query(mysql, \"set sql_mode=''\");\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":23466,"func":"int jpc_pi_addpchg ( jpc_pi_t * pi , jpc_pocpchg_t * pchg ) {\n return jpc_pchglist_insert ( pi -> pchglist , - 1 , pchg ) ;\n }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":237817,"func":"bool Document::ChildTypeAllowed(NodeType type) const {\n  switch (type) {\n    case kAttributeNode:\n    case kCdataSectionNode:\n    case kDocumentFragmentNode:\n    case kDocumentNode:\n    case kTextNode:\n      return false;\n    case kCommentNode:\n    case kProcessingInstructionNode:\n      return true;\n    case kDocumentTypeNode:\n    case kElementNode:\n      for (Node& c : NodeTraversal::ChildrenOf(*this)) {\n        if (c.getNodeType() == type)\n          return false;\n      }\n      return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":98934,"func":"_tiffSizeProc(thandle_t fd)\n{\n\tULARGE_INTEGER m;\n\tm.LowPart=GetFileSize(fd,&m.HighPart);\n\treturn(m.QuadPart);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":109574,"func":"static u32 tcm_loop_sess_get_index(struct se_session *se_sess)\n{\n\treturn 1;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":188019,"func":"SelectFileDialog* SelectFileDialog::Create(Listener* listener) {\n  return new SelectFileDialogImpl(listener);\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":101721,"func":"PHP_FUNCTION(exif_tagname)\n{\n\tlong tag;\n\tchar *szTemp;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &tag) == FAILURE) {\n\t\treturn;\n\t}\n\n\tszTemp = exif_get_tagname(tag, NULL, 0, tag_table_IFD TSRMLS_CC);\n\n\tif (tag < 0 || !szTemp || !szTemp[0]) {\n\t\tRETURN_FALSE;\n\t}\n\n\tRETURN_STRING(szTemp, 1)\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":451352,"func":"  void clear() override { HeaderMapImpl::clear(); }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":236779,"func":"void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* param,\n                                FPDF_FILEHANDLER* file_handler,\n                                FPDF_WIDESTRING to,\n                                FPDF_WIDESTRING subject,\n                                FPDF_WIDESTRING cc,\n                                FPDF_WIDESTRING bcc,\n                                FPDF_WIDESTRING message) {\n  std::string to_str = WideStringToString(to);\n  std::string subject_str = WideStringToString(subject);\n  std::string cc_str = WideStringToString(cc);\n  std::string bcc_str = WideStringToString(bcc);\n  std::string message_str = WideStringToString(message);\n\n  PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);\n  engine->client_->Email(to_str, cc_str, bcc_str, subject_str, message_str);\n}\n","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":112700,"func":"uint Jsi_TreeSize(Jsi_Tree *treePtr) { return treePtr->numEntries; }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":234818,"func":"gfloat webkit_web_view_get_zoom_level(WebKitWebView* webView)\n{\n    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0f);\n\n    Frame* frame = core(webView)->mainFrame();\n    if (!frame)\n        return 1.0f;\n\n    WebKitWebViewPrivate* priv = webView->priv;\n    return priv->zoomFullContent ? frame->pageZoomFactor() : frame->textZoomFactor();\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":520029,"func":"  my_var_sp(const LEX_STRING& j, uint o, enum_field_types t, sp_head *s)\n    : my_var(j, LOCAL_VAR), offset(o), type(t), sp(s) { }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":152977,"func":"TRIO_PUBLIC_STRING int trio_equal_max TRIO_ARGS3((first, max, second), TRIO_CONST char* first,\n                                                 size_t max, TRIO_CONST char* second)\n{\n\tassert(first);\n\tassert(second);\n\n\tif ((first != NULL) && (second != NULL))\n\t{\n#if defined(USE_STRNCASECMP)\n\t\treturn (0 == strncasecmp(first, second, max));\n#else\n\t\t\/* Not adequately tested yet *\/\n\t\tsize_t cnt = 0;\n\t\twhile ((*first != NIL) && (*second != NIL) && (cnt <= max))\n\t\t{\n\t\t\tif (internal_to_upper(*first) != internal_to_upper(*second))\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfirst++;\n\t\t\tsecond++;\n\t\t\tcnt++;\n\t\t}\n\t\treturn ((cnt == max) || ((*first == NIL) && (*second == NIL)));\n#endif\n\t}\n\treturn FALSE;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":169799,"func":"int WebContentsImpl::SendToAllFrames(IPC::Message* message) {\n  int number_of_messages = 0;\n  for (RenderFrameHost* rfh : GetAllFrames()) {\n    if (!rfh->IsRenderFrameLive())\n      continue;\n\n    ++number_of_messages;\n    IPC::Message* message_copy = new IPC::Message(*message);\n    message_copy->set_routing_id(rfh->GetRoutingID());\n    rfh->Send(message_copy);\n  }\n  delete message;\n  return number_of_messages;\n}\n","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":294290,"func":"header_put_byte (SF_PRIVATE *psf, char x)\n{\tpsf->header.ptr [psf->header.indx++] = x ;\n} \/* header_put_byte *\/","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":254702,"func":"int HAL_load(void)\n{\n int err = 0;\n\n hw_module_t* module;\n hw_device_t* device;\n\n    bdt_log(\"Loading HAL lib + extensions\");\n\n    err = hw_get_module(BT_HARDWARE_MODULE_ID, (hw_module_t const**)&module);\n if (err == 0)\n {\n        err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);\n if (err == 0) {\n            bt_device = (bluetooth_device_t *)device;\n            sBtInterface = bt_device->get_bluetooth_interface();\n }\n }\n\n    bdt_log(\"HAL library loaded (%s)\", strerror(err));\n\n return err;\n}\n","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":40725,"func":"evutil_open_closeonexec_(const char *pathname, int flags, unsigned mode)\n{\n\tint fd;\n\n#ifdef O_CLOEXEC\n\tfd = open(pathname, flags|O_CLOEXEC, (mode_t)mode);\n\tif (fd >= 0 || errno == EINVAL)\n\t\treturn fd;\n\t\/* If we got an EINVAL, fall through and try without O_CLOEXEC *\/\n#endif\n\tfd = open(pathname, flags, (mode_t)mode);\n\tif (fd < 0)\n\t\treturn -1;\n\n#if defined(FD_CLOEXEC)\n\tif (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {\n\t\tclose(fd);\n\t\treturn -1;\n\t}\n#endif\n\n\treturn fd;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":455214,"func":"TEST(ExprMatchTest, OptimizingExprAbsorbsAndOfAnd) {\n    BSONObj exprBson = fromjson(\"{$expr: {$and: [{$eq: ['$a', 1]}, {$eq: ['$b', 2]}]}}\");\n\n    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());\n    auto matchExpr =\n        std::make_unique<ExprMatchExpression>(exprBson.firstElement(), std::move(expCtx));\n    auto optimized = MatchExpression::optimize(std::move(matchExpr));\n\n    \/\/ The optimized match expression should not have and AND children of AND nodes. This should be\n    \/\/ collapsed during optimization.\n    BSONObj serialized;\n    {\n        BSONObjBuilder builder;\n        optimized->serialize(&builder);\n        serialized = builder.obj();\n    }\n\n    BSONObj expectedSerialization = fromjson(\n        \"{$and: [{$expr: {$and: [{$eq: ['$a', {$const: 1}]}, {$eq: ['$b', {$const: 2}]}]}},\"\n        \"{a: {$_internalExprEq: 1}}, {b: {$_internalExprEq: 2}}]}\");\n    ASSERT_BSONOBJ_EQ(serialized, expectedSerialization);\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":200085,"func":"const CustomButton* CustomButton::AsCustomButton(const views::View* view) {\n  return AsCustomButton(const_cast<views::View*>(view));\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":516098,"func":"int llhttp__on_message_complete(llhttp_t* s, const char* p, const char* endp) {\n  int err;\n  CALLBACK_MAYBE(s, on_message_complete);\n  return err;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":246728,"func":"z2copy(i_ctx_t *i_ctx_p)\n{\n    os_ptr op = osp;\n    int code = zcopy(i_ctx_p);\n\n    if (code >= 0)\n        return code;\n    if (!r_has_type(op, t_astruct))\n        return code;\n    return z2copy_gstate(i_ctx_p);\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":41199,"func":"_pause_for_job_completion (uint32_t job_id, char *nodes, int max_time)\n{\n\tint sec = 0;\n\tint pause = 1;\n\tbool rc = false;\n\n\twhile ((sec < max_time) || (max_time == 0)) {\n\t\trc = _job_still_running (job_id);\n\t\tif (!rc)\n\t\t\tbreak;\n\t\tif ((max_time == 0) && (sec > 1)) {\n\t\t\t_terminate_all_steps(job_id, true);\n\t\t}\n\t\tif (sec > 10) {\n\t\t\t\/* Reduce logging frequency about unkillable tasks *\/\n\t\t\tif (max_time)\n\t\t\t\tpause = MIN((max_time - sec), 10);\n\t\t\telse\n\t\t\t\tpause = 10;\n\t\t}\n\t\tsleep(pause);\n\t\tsec += pause;\n\t}\n\n\t\/*\n\t * Return true if job is NOT running\n\t *\/\n\treturn (!rc);\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":482554,"func":"static int init_wvx_bitstream (WavpackStream *wps, WavpackMetadata *wpmd)\n{\n    unsigned char *cp = (unsigned char *)wpmd->data;\n\n    if (wpmd->byte_length <= 4 || (wpmd->byte_length & 1))\n        return FALSE;\n\n    wps->crc_wvx = *cp++;\n    wps->crc_wvx |= (uint32_t) *cp++ << 8;\n    wps->crc_wvx |= (uint32_t) *cp++ << 16;\n    wps->crc_wvx |= (uint32_t) *cp++ << 24;\n\n    bs_open_read (&wps->wvxbits, cp, (unsigned char *) wpmd->data + wpmd->byte_length);\n    return TRUE;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":82895,"func":"bool kvm_vcpu_yield_to(struct kvm_vcpu *target)\n{\n\tstruct pid *pid;\n\tstruct task_struct *task = NULL;\n\n\trcu_read_lock();\n\tpid = rcu_dereference(target->pid);\n\tif (pid)\n\t\ttask = get_pid_task(target->pid, PIDTYPE_PID);\n\trcu_read_unlock();\n\tif (!task)\n\t\treturn false;\n\tif (task->flags & PF_VCPU) {\n\t\tput_task_struct(task);\n\t\treturn false;\n\t}\n\tif (yield_to(task, 1)) {\n\t\tput_task_struct(task);\n\t\treturn true;\n\t}\n\tput_task_struct(task);\n\treturn false;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":459538,"func":"dissect_kafka_find_coordinator_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,\n                                         kafka_api_version_t api_version)\n{\n    if (api_version >= 1) {\n        offset = dissect_kafka_throttle_time(tvb, pinfo, tree, offset);\n    }\n\n    \/* error_code *\/\n    offset = dissect_kafka_error(tvb, pinfo, tree, offset);\n\n    if (api_version >= 1) {\n        offset = dissect_kafka_string(tree, hf_kafka_error_message, tvb, pinfo, offset, api_version >= 3,\n                                      NULL, NULL);\n    }\n\n    \/* coordinator *\/\n    offset = dissect_kafka_find_coordinator_response_coordinator(tvb, pinfo, tree, offset, api_version);\n\n    if (api_version >= 3) {\n        offset = dissect_kafka_tagged_fields(tvb, pinfo, tree, offset, 0);\n    }\n\n    return offset;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":409879,"func":"\nstatic inline unsigned char *skb_inner_network_header(const struct sk_buff *skb)\n{\n\treturn skb->head + skb->inner_network_header;","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":129271,"func":"void hrtick_start(struct rq *rq, u64 delay)\n{\n\t__hrtimer_start_range_ns(&rq->hrtick_timer, ns_to_ktime(delay), 0,\n\t\t\tHRTIMER_MODE_REL_PINNED, 0);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":523069,"func":"  find_thread_callback_arg(longlong id_arg, bool query_id_arg):\n    thd(0), id(id_arg), query_id(query_id_arg) {}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":445281,"func":"TimeSource& ListenerFactoryContextBaseImpl::timeSource() { return api().timeSource(); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":197559,"func":"WebContents* WebContents::CreateWithSessionStorage(\n    const WebContents::CreateParams& params,\n    const SessionStorageNamespaceMap& session_storage_namespace_map) {\n  WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context);\n  new_contents->SetOpenerForNewContents(FindOpener(params),\n                                        params.opener_suppressed);\n\n  for (SessionStorageNamespaceMap::const_iterator it =\n           session_storage_namespace_map.begin();\n       it != session_storage_namespace_map.end();\n       ++it) {\n    new_contents->GetController()\n        .SetSessionStorageNamespace(it->first, it->second.get());\n  }\n\n  new_contents->Init(params);\n  return new_contents;\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":516500,"func":"bool Locked_tables_list::restore_lock(THD *thd, TABLE_LIST *dst_table_list,\n                                      TABLE *table, MYSQL_LOCK *lock)\n{\n  MYSQL_LOCK *merged_lock;\n  DBUG_ENTER(\"restore_lock\");\n  DBUG_ASSERT(!strcmp(dst_table_list->table_name, table->s->table_name.str));\n\n  \/* Ensure we have the memory to add the table back *\/\n  if (!(merged_lock= mysql_lock_merge(thd->lock, lock)))\n    DBUG_RETURN(1);\n  thd->lock= merged_lock;\n\n  \/* Link to the new table *\/\n  dst_table_list->table= table;\n  \/*\n    The lock type may have changed (normally it should not as create\n    table will lock the table in write mode\n  *\/\n  dst_table_list->lock_type= table->reginfo.lock_type;\n  table->pos_in_locked_tables= dst_table_list;\n\n  add_back_last_deleted_lock(dst_table_list);\n\n  table->mdl_ticket->downgrade_lock(table->reginfo.lock_type >=\n                                    TL_WRITE_ALLOW_WRITE ? \n                                    MDL_SHARED_NO_READ_WRITE :\n                                    MDL_SHARED_READ);\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":330096,"func":"int event_notifier_init(EventNotifier *e, int active)\n\n{\n\n#ifdef CONFIG_EVENTFD\n\n    int fd = eventfd(!!active, EFD_NONBLOCK | EFD_CLOEXEC);\n\n    if (fd < 0)\n\n        return -errno;\n\n    e->fd = fd;\n\n    return 0;\n\n#else\n\n    return -ENOSYS;\n\n#endif\n\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":140424,"func":"static int ffm_write_write_index(int fd, int64_t pos)\n{\n    uint8_t buf[8];\n    int i;\n\n    for(i=0;i<8;i++)\n        buf[i] = (pos >> (56 - i * 8)) & 0xff;\n    if (lseek(fd, 8, SEEK_SET) < 0)\n        goto bail_eio;\n    if (write(fd, buf, 8) != 8)\n        goto bail_eio;\n\n    return 8;\n\nbail_eio:\n    return AVERROR(EIO);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":13717,"func":" void GDataDirectoryService::InitializeRootEntry(const std::string& root_id) {\n  root_.reset(new GDataDirectory(NULL, this));\n   root_->set_title(kGDataRootDirectory);\n   root_->SetBaseNameFromTitle();\n   root_->set_resource_id(root_id);\n  AddEntryToResourceMap(root_.get());\n}\n","target":1,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":329465,"func":"void net_hub_check_clients(void)\n\n{\n\n    NetHub *hub;\n\n    NetHubPort *port;\n\n    NetClientState *peer;\n\n\n\n    QLIST_FOREACH(hub, &hubs, next) {\n\n        int has_nic = 0, has_host_dev = 0;\n\n\n\n        QLIST_FOREACH(port, &hub->ports, next) {\n\n            peer = port->nc.peer;\n\n            if (!peer) {\n\n                fprintf(stderr, \"Warning: hub port %s has no peer\\n\",\n\n                        port->nc.name);\n\n                continue;\n\n            }\n\n\n\n            switch (peer->info->type) {\n\n            case NET_CLIENT_DRIVER_NIC:\n\n                has_nic = 1;\n\n                break;\n\n            case NET_CLIENT_DRIVER_USER:\n\n            case NET_CLIENT_DRIVER_TAP:\n\n            case NET_CLIENT_DRIVER_SOCKET:\n\n            case NET_CLIENT_DRIVER_VDE:\n\n            case NET_CLIENT_DRIVER_VHOST_USER:\n\n                has_host_dev = 1;\n\n                break;\n\n            default:\n\n                break;\n\n            }\n\n        }\n\n        if (has_host_dev && !has_nic) {\n\n            warn_report(\"vlan %d with no nics\", hub->id);\n\n        }\n\n        if (has_nic && !has_host_dev) {\n\n            fprintf(stderr,\n\n                    \"Warning: vlan %d is not connected to host network\\n\",\n\n                    hub->id);\n\n        }\n\n    }\n\n}\n","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":6831,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n  TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n  if (input->type != kTfLiteFloat32) {\n    TF_LITE_UNSUPPORTED_TYPE(context, input->type, \"Ceil\");\n  }\n\n  optimized_ops::Ceil(GetTensorShape(input), GetTensorData<float>(input),\n                      GetTensorShape(output), GetTensorData<float>(output));\n\n  return kTfLiteOk;\n}","target":1,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":58381,"func":"int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ecdsa)\n\t{\n\treturn ASN1_i2d_bio_of(EC_KEY,i2d_EC_PUBKEY,bp,ecdsa);\n\t}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":229341,"func":"GSList *gslist_find_string(GSList *list, const char *key)\n{\n\tfor (; list != NULL; list = list->next)\n\t\tif (g_strcmp0(list->data, key) == 0) return list;\n\n\treturn NULL;\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":425610,"func":"UsbHubCtrlClearPortFeature (\r\n  IN USB_DEVICE           *HubDev,\r\n  IN UINT8                Port,\r\n  IN UINT16               Feature\r\n  )\r\n{\r\n  EFI_STATUS              Status;\r\n\r\n  \/\/\r\n  \/\/ In USB bus, all the port index starts from 0. But HUB\r\n  \/\/ indexes its port from 1. So, port number is added one.\r\n  \/\/\r\n  Status = UsbCtrlRequest (\r\n             HubDev,\r\n             EfiUsbNoData,\r\n             USB_REQ_TYPE_CLASS,\r\n             USB_HUB_TARGET_PORT,\r\n             USB_HUB_REQ_CLEAR_FEATURE,\r\n             Feature,\r\n             (UINT16) (Port + 1),\r\n             NULL,\r\n             0\r\n             );\r\n\r\n  return Status;\r\n}\r","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":260220,"func":"static int netlbl_cipsov4_listall(struct sk_buff *skb,\n\t\t\t\t  struct netlink_callback *cb)\n{\n\tstruct netlbl_cipsov4_doiwalk_arg cb_arg;\n\tint doi_skip = cb->args[0];\n\n\tcb_arg.nl_cb = cb;\n\tcb_arg.skb = skb;\n\tcb_arg.seq = cb->nlh->nlmsg_seq;\n\n\tcipso_v4_doi_walk(&doi_skip, netlbl_cipsov4_listall_cb, &cb_arg);\n\n\tcb->args[0] = doi_skip;\n\treturn skb->len;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":149014,"func":"void ksz9131WritePhyReg(NetInterface *interface, uint8_t address,\n   uint16_t data)\n{\n   \/\/Write the specified PHY register\n   if(interface->smiDriver != NULL)\n   {\n      interface->smiDriver->writePhyReg(SMI_OPCODE_WRITE,\n         interface->phyAddr, address, data);\n   }\n   else\n   {\n      interface->nicDriver->writePhyReg(SMI_OPCODE_WRITE,\n         interface->phyAddr, address, data);\n   }\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":328286,"func":"void virtio_queue_notify(VirtIODevice *vdev, int n)\n\n{\n\n    if (n < VIRTIO_PCI_QUEUE_MAX && vdev->vq[n].vring.desc) {\n\n        trace_virtio_queue_notify(vdev, n, &vdev->vq[n]);\n\n        vdev->vq[n].handle_output(vdev, &vdev->vq[n]);\n\n    }\n\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":182053,"func":"SWFInput_dtor(SWFInput input)\n{\n#if TRACK_ALLOCS\n\tming_gc_remove_node(input->gcnode);\n#endif\n\tfree(input);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":495964,"func":"bool queueMicrotask(JSContext *cx, unsigned argc, Value *vp) {\n  CallArgs args = CallArgsFromVp(argc, vp);\n  if (!args.requireAtLeast(cx, \"queueMicrotask\", 1)) {\n    return false;\n  }\n\n  if (!args[0].isObject() || !JS::IsCallable(&args[0].toObject())) {\n    JS_ReportErrorLatin1(cx, \"queueMicrotask: Argument 1 is not a function\");\n    return false;\n  }\n\n  RootedObject callback(cx, &args[0].toObject());\n\n  RootedObject promise(cx, JS::CallOriginalPromiseResolve(cx, JS::UndefinedHandleValue));\n  if (!promise) {\n    return false;\n  }\n\n  if (!JS::AddPromiseReactions(cx, promise, callback, nullptr)) {\n    return false;\n  }\n\n  args.rval().setUndefined();\n  return true;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":244425,"func":"BluetoothRemoteGATTCharacteristic::BluetoothRemoteGATTCharacteristic(\n    ExecutionContext* context,\n    mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr characteristic,\n    BluetoothRemoteGATTService* service,\n    BluetoothDevice* device)\n    : ContextLifecycleObserver(context),\n      m_characteristic(std::move(characteristic)),\n      m_service(service),\n      m_stopped(false),\n      m_device(device) {\n  m_properties =\n      BluetoothCharacteristicProperties::create(m_characteristic->properties);\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":293789,"func":"GF_Err tsro_Write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TimeOffHintEntryBox *ptr = (GF_TimeOffHintEntryBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->TimeOffset);\n\treturn GF_OK;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":502447,"func":"static void descriptor_changes_parser(TDB_DATA key, TDB_DATA data, void *private_data)\n{\n\tstruct descriptor_changes **c_ptr = (struct descriptor_changes **)private_data;\n\tuintptr_t ptr = 0;\n\n\tSMB_ASSERT(data.dsize == sizeof(ptr));\n\n\tmemcpy(&ptr, data.dptr, data.dsize);\n\n\t*c_ptr = talloc_get_type_abort((void *)ptr, struct descriptor_changes);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":321180,"func":"void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)\n\n{\n\n    if (s->chr_read) {\n\n        s->chr_read(s->handler_opaque, buf, len);\n\n    }\n\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":329713,"func":"int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)\n\n{\n\n    graph->filters = av_realloc(graph->filters,\n\n                                sizeof(AVFilterContext*) * ++graph->filter_count);\n\n\n\n    if (!graph->filters)\n\n        return AVERROR(ENOMEM);\n\n\n\n    graph->filters[graph->filter_count - 1] = filter;\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":239289,"func":"bool WebContentsImpl::IsLoadingToDifferentDocument() const {\n  return IsLoading() && is_load_to_different_document_;\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":128291,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_media_add_attr( pjmedia_sdp_media *m,\n\t\t\t\t\t\tpjmedia_sdp_attr *attr)\n{\n    return pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":50131,"func":"void Context::removeHeaderMapValue(HeaderMapType type, absl::string_view key) {\n  auto map = getMap(type);\n  if (!map) {\n    return;\n  }\n  const Http::LowerCaseString lower_key(std::move(std::string(key)));\n  map->remove(lower_key);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":163317,"func":"bool WindowCanOpenTabs(Browser* browser) {\n  if (browser->tab_count() >= browser_defaults::kMaxTabCount)\n    return false;\n\n  return browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP) ||\n      browser->tabstrip_model()->empty();\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":118667,"func":"void HTTPSession::setByteEventTracker(\n  std::shared_ptr<ByteEventTracker> byteEventTracker) {\n  if (byteEventTracker && byteEventTracker_) {\n    byteEventTracker->absorb(std::move(*byteEventTracker_));\n  }\n  byteEventTracker_ = byteEventTracker;\n  if (byteEventTracker_) {\n    byteEventTracker_->setCallback(this);\n    byteEventTracker_->setTTLBAStats(sessionStats_);\n  }\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":477749,"func":"      float operator()(const float x, const float y) const {\n        return (float)ref((int)x,(int)y);\n      }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":506206,"func":"int tls12_get_req_sig_algs(SSL *s, unsigned char *p)\n\t{\n\tsize_t slen = sizeof(tls12_sigalgs);\n#ifdef OPENSSL_FIPS\n\t\/* If FIPS mode don't include MD5 which is last *\/\n\tif (FIPS_mode())\n\t\tslen -= 2;\n#endif\n\tif (p)\n\t\tmemcpy(p, tls12_sigalgs, slen);\n\treturn (int)slen;\n\t}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":459296,"func":"static void cmd_read(IDEState *s, uint8_t* buf)\n{\n    int nb_sectors, lba;\n\n    if (buf[0] == GPCMD_READ_10) {\n        nb_sectors = lduw_be_p(buf + 7);\n    } else {\n        nb_sectors = ldl_be_p(buf + 6);\n    }\n\n    lba = ldl_be_p(buf + 2);\n    if (nb_sectors == 0) {\n        ide_atapi_cmd_ok(s);\n        return;\n    }\n\n    ide_atapi_cmd_read(s, lba, nb_sectors, 2048);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":291723,"func":"smb2_echo_callback(struct mid_q_entry *mid)\n{\n\tstruct TCP_Server_Info *server = mid->callback_data;\n\tstruct smb2_echo_rsp *smb2 = (struct smb2_echo_rsp *)mid->resp_buf;\n\tunsigned int credits_received = 1;\n\n\tif (mid->mid_state == MID_RESPONSE_RECEIVED)\n\t\tcredits_received = le16_to_cpu(smb2->hdr.CreditRequest);\n\n\tDeleteMidQEntry(mid);\n\tadd_credits(server, credits_received, CIFS_ECHO_OP);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":87660,"func":"Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) :\n    Pipeline(identifier, next),\n    pos(0),\n    eod(false)\n{\n    this->inbuf[0] = '0';\n    this->inbuf[1] = '0';\n    this->inbuf[2] = '\\0';\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":429870,"func":"void ClientHandler::reset_upstream_read_timeout(ev_tstamp t) {\n  conn_.rt.repeat = t;\n  if (ev_is_active(&conn_.rt)) {\n    ev_timer_again(conn_.loop, &conn_.rt);\n  }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":431229,"func":"    CmdGrantRolesToRole() : BasicCommand(\"grantRolesToRole\") {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":199081,"func":"WebCookieJar* RenderViewImpl::GetCookieJar() {\n  return &cookie_jar_;\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":451398,"func":"void HeaderToMetadataFilter::applyKeyValue(std::string&& value, const Rule& rule,\n                                           const KeyValuePair& keyval, StructMap& np) {\n  if (!keyval.value().empty()) {\n    value = keyval.value();\n  } else {\n    const auto& matcher = rule.regexRewrite();\n    if (matcher != nullptr) {\n      value = matcher->replaceAll(value, rule.regexSubstitution());\n    }\n  }\n  if (!value.empty()) {\n    const auto& nspace = decideNamespace(keyval.metadata_namespace());\n    addMetadata(np, nspace, keyval.key(), value, keyval.type(), keyval.encode());\n  } else {\n    ENVOY_LOG(debug, \"value is empty, not adding metadata\");\n  }\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":489805,"func":"static GF_AUContext *gf_seng_create_new_au(GF_StreamContext *sc, u32 time)\n{\n\tGF_AUContext *new_au, *last_au;\n\tif (!sc) return NULL;\n\tlast_au = gf_list_last(sc->AUs);\n\tif (last_au && last_au->timing == time) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_SCENE, (\"[SceneEngine] Forcing new AU\\n\"));\n\t\ttime++;\n\t}\n\tnew_au = gf_sm_stream_au_new(sc, time, 0, 0);\n\treturn new_au;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":255885,"func":" void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths) {\n   paths->clear();\n  const std::string path = url.path();  \/\/ const sidesteps GCC bugs below!\n   if (path.empty())\n     return;\n \n  const size_t kMaxPathsToCheck = 4;\n  for (std::string::const_iterator i(path.begin());\n       i != path.end() && paths->size() < kMaxPathsToCheck; ++i) {\n    if (*i == '\/')\n      paths->push_back(std::string(path.begin(), i + 1));\n  }\n\n   if (paths->back() != path)\n     paths->push_back(path);\n \n  if (url.has_query())\n    paths->push_back(path + \"?\" + url.query());\n }\n","target":1,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":283831,"func":"Offliner::RequestStatus BackgroundLoaderOffliner::CanSavePageInBackground(\n    content::WebContents* web_contents) {\n  DCHECK(is_low_bar_met_)\n      << \"Minimum quality must have been reached before checking loaded page\";\n  std::unique_ptr<security_state::VisibleSecurityState> visible_security_state =\n      GetVisibleSecurityState(web_contents);\n  if (security_state::HasMajorCertificateError(*visible_security_state))\n    return Offliner::RequestStatus::LOADED_PAGE_HAS_CERTIFICATE_ERROR;\n\n  if (visible_security_state->malicious_content_status !=\n      security_state::MaliciousContentStatus::MALICIOUS_CONTENT_STATUS_NONE) {\n    return Offliner::RequestStatus::LOADED_PAGE_IS_BLOCKED;\n  }\n\n  if (GetPageType(web_contents) != content::PageType::PAGE_TYPE_NORMAL)\n    return Offliner::RequestStatus::LOADED_PAGE_IS_CHROME_INTERNAL;\n\n  return Offliner::RequestStatus::UNKNOWN;\n}\n","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":406551,"func":"  void init()\n  {\n    resolve_in_select_list= FALSE;\n    error_processor= &dummy_error_processor;\n    first_name_resolution_table= NULL;\n    last_name_resolution_table= NULL;\n  }","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":368140,"func":"process_cmd_maxdelayratio(CMD_Request *msg, char *line)\n{\n  IPAddr address;\n  double max_delay_ratio;\n  int ok;\n  \n  if (read_address_double(line, &address, &max_delay_ratio)) {\n    UTI_IPHostToNetwork(&address, &msg->data.modify_maxdelayratio.address);\n    msg->data.modify_maxdelayratio.new_max_delay_ratio = UTI_FloatHostToNetwork(max_delay_ratio);\n    msg->command = htons(REQ_MODIFY_MAXDELAYRATIO);\n    ok = 1;\n  } else {\n    ok = 0;\n  }\n\n  return ok;\n\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":294145,"func":"xfs_vn_symlink(\n\tstruct inode\t*dir,\n\tstruct dentry\t*dentry,\n\tconst char\t*symname)\n{\n\tstruct inode\t*inode;\n\tstruct xfs_inode *cip = NULL;\n\tstruct xfs_name\tname;\n\tint\t\terror;\n\tumode_t\t\tmode;\n\n\tmode = S_IFLNK |\n\t\t(irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);\n\terror = xfs_dentry_mode_to_name(&name, dentry, mode);\n\tif (unlikely(error))\n\t\tgoto out;\n\n\terror = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip);\n\tif (unlikely(error))\n\t\tgoto out;\n\n\tinode = VFS_I(cip);\n\n\terror = xfs_init_security(inode, dir, &dentry->d_name);\n\tif (unlikely(error))\n\t\tgoto out_cleanup_inode;\n\n\txfs_setup_iops(cip);\n\n\td_instantiate(dentry, inode);\n\txfs_finish_inode_setup(cip);\n\treturn 0;\n\n out_cleanup_inode:\n\txfs_finish_inode_setup(cip);\n\txfs_cleanup_inode(dir, inode, dentry);\n\txfs_irele(cip);\n out:\n\treturn error;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":90700,"func":"bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu)\n{\n\treturn vcpu->kvm->arch.bsp_vcpu_id == vcpu->vcpu_id;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":470645,"func":"static void htab_init_buckets(struct bpf_htab *htab)\n{\n\tunsigned i;\n\n\tfor (i = 0; i < htab->n_buckets; i++) {\n\t\tINIT_HLIST_NULLS_HEAD(&htab->buckets[i].head, i);\n\t\tif (htab_use_raw_lock(htab)) {\n\t\t\traw_spin_lock_init(&htab->buckets[i].raw_lock);\n\t\t\tlockdep_set_class(&htab->buckets[i].raw_lock,\n\t\t\t\t\t  &htab->lockdep_key);\n\t\t} else {\n\t\t\tspin_lock_init(&htab->buckets[i].lock);\n\t\t\tlockdep_set_class(&htab->buckets[i].lock,\n\t\t\t\t\t  &htab->lockdep_key);\n\t\t}\n\t\tcond_resched();\n\t}\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":505760,"func":"int ssl3_renegotiate(SSL *s)\n\t{\n\tif (s->handshake_func == NULL)\n\t\treturn(1);\n\n\tif (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)\n\t\treturn(0);\n\n\ts->s3->renegotiate=1;\n\treturn(1);\n\t}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":275737,"func":"DownloadInterruptReason DownloadItemImpl::GetLastReason() const {\n  return last_reason_;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":113449,"func":"sctp_disposition_t sctp_sf_cookie_echoed_prm_abort(\n\tstruct net *net,\n\tconst struct sctp_endpoint *ep,\n\tconst struct sctp_association *asoc,\n\tconst sctp_subtype_t type,\n\tvoid *arg,\n\tsctp_cmd_seq_t *commands)\n{\n\t\/* There is a single T1 timer, so we should be able to use\n\t * common function with the COOKIE-WAIT state.\n\t *\/\n\treturn sctp_sf_cookie_wait_prm_abort(net, ep, asoc, type, arg, commands);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":494051,"func":"static bool ParseExtensionsProperty(ExtensionMap *ret, std::string *err,\n                                    const json &o) {\n  (void)err;\n\n  json_const_iterator it;\n  if (!FindMember(o, \"extensions\", it)) {\n    return false;\n  }\n\n  auto &obj = GetValue(it);\n  if (!IsObject(obj)) {\n    return false;\n  }\n  ExtensionMap extensions;\n  json_const_iterator extIt = ObjectBegin(obj);  \/\/ it.value().begin();\n  json_const_iterator extEnd = ObjectEnd(obj);\n  for (; extIt != extEnd; ++extIt) {\n    auto &itObj = GetValue(extIt);\n    if (!IsObject(itObj)) continue;\n    std::string key(GetKey(extIt));\n    if (!ParseJsonAsValue(&extensions[key], itObj)) {\n      if (!key.empty()) {\n        \/\/ create empty object so that an extension object is still of type\n        \/\/ object\n        extensions[key] = Value{Value::Object{}};\n      }\n    }\n  }\n  if (ret) {\n    (*ret) = std::move(extensions);\n  }\n  return true;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":193519,"func":"double timeDelta(base::TimeTicks time,\n                 base::TimeTicks start,\n                 double invalid_value = -1) {\n  return time.is_null() ? invalid_value : (time - start).InMillisecondsF();\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":117377,"func":"ALWAYS_INLINE Variant preg_return_no_error(Variant&& return_value) {\n  *rl_last_error_code = PHP_PCRE_NO_ERROR;\n  return std::move(return_value);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":187785,"func":"  SafeBrowsingBlockingPage* CreateSafeBrowsingPage(\n      SafeBrowsingUIManager* ui_manager,\n      WebContents* web_contents,\n      const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) {\n    if (unsafe_resources.size() == 1 &&\n        (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE ||\n         unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) {\n      return new SafeBrowsingBlockingPageV2(ui_manager, web_contents,\n          unsafe_resources);\n    }\n    return new SafeBrowsingBlockingPageV1(ui_manager, web_contents,\n                                          unsafe_resources);\n  }\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":171391,"func":"BluetoothSocketUpdateFunction::BluetoothSocketUpdateFunction() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":61726,"func":"term_push_title(int which)\n{\n    if ((which & SAVE_RESTORE_TITLE) && T_CST != NULL && *T_CST != NUL)\n    {\n\tOUT_STR(T_CST);\n\tout_flush();\n    }\n\n    if ((which & SAVE_RESTORE_ICON) && T_SSI != NULL && *T_SSI != NUL)\n    {\n\tOUT_STR(T_SSI);\n\tout_flush();\n    }\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":16914,"func":"static int dissect_h245_IndR_multiplex ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_IndR_multiplex , IndR_multiplex_choice , NULL ) ;\n return offset ;\n }","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":239705,"func":"void ServiceWorkerContextCore::AddProviderHost(\n    std::unique_ptr<ServiceWorkerProviderHost> host) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));\n  int provider_id = host->provider_id();\n  providers_->emplace(provider_id, std::move(host));\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":138297,"func":"void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index)\n{\n\tbtrfs_dev_stat_inc(dev, index);\n\tbtrfs_dev_stat_print_on_error(dev);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":224951,"func":"param_cmp(const X509_VERIFY_PARAM * const *a,\n    const X509_VERIFY_PARAM * const *b)\n{\n\treturn strcmp((*a)->name, (*b)->name);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":220113,"func":"WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) {\n  RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh);\n  if (!rfh_impl)\n    return NULL;\n  return rfh_impl->delegate()->GetAsWebContents();\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":432842,"func":"backend_can_extents (struct backend *b, struct connection *conn)\n{\n  struct b_conn_handle *h = &conn->handles[b->i];\n\n  debug (\"%s: can_extents\", b->name);\n\n  if (h->can_extents == -1)\n    h->can_extents = b->can_extents (b, conn);\n  return h->can_extents;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":74024,"func":"void HTTPSession::onSessionParseError(const HTTPException& error) {\n  VLOG(4) << *this << \" session layer parse error. Terminate the session.\";\n  if (error.hasCodecStatusCode()) {\n    std::unique_ptr<folly::IOBuf> errorMsg =\n      folly::IOBuf::copyBuffer(error.what());\n    codec_->generateGoaway(writeBuf_,\n                           codec_->getLastIncomingStreamID(),\n                           error.getCodecStatusCode(),\n                           isHTTP2CodecProtocol(codec_->getProtocol()) ?\n                           std::move(errorMsg) : nullptr);\n    scheduleWrite();\n  }\n  setCloseReason(ConnectionCloseReason::SESSION_PARSE_ERROR);\n  shutdownTransport(true, true);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":250251,"func":"int HttpProxyClientSocket::DoDrainBody() {\n  DCHECK(drain_buf_.get());\n  DCHECK(transport_->is_initialized());\n  next_state_ = STATE_DRAIN_BODY_COMPLETE;\n  return http_stream_parser_->ReadResponseBody(\n      drain_buf_.get(), kDrainBodyBufferSize, io_callback_);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":134219,"func":"static int newlabelentry (LexState *ls, Labellist *l, TString *name,\n                          int line, int pc) {\n  int n = l->n;\n  luaM_growvector(ls->L, l->arr, n, l->size,\n                  Labeldesc, SHRT_MAX, \"labels\/gotos\");\n  l->arr[n].name = name;\n  l->arr[n].line = line;\n  l->arr[n].nactvar = ls->fs->nactvar;\n  l->arr[n].close = 0;\n  l->arr[n].pc = pc;\n  l->n = n + 1;\n  return n;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":419260,"func":"winlink_cmp(struct winlink *wl1, struct winlink *wl2)\n{\n\treturn (wl1->idx - wl2->idx);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":98064,"func":"int key_link(struct key *keyring, struct key *key)\n{\n\tstruct assoc_array_edit *edit;\n\tint ret;\n\n\tkenter(\"{%d,%d}\", keyring->serial, refcount_read(&keyring->usage));\n\n\tkey_check(keyring);\n\tkey_check(key);\n\n\tret = __key_link_begin(keyring, &key->index_key, &edit);\n\tif (ret == 0) {\n\t\tkdebug(\"begun {%d,%d}\", keyring->serial, refcount_read(&keyring->usage));\n\t\tret = __key_link_check_restriction(keyring, key);\n\t\tif (ret == 0)\n\t\t\tret = __key_link_check_live_key(keyring, key);\n\t\tif (ret == 0)\n\t\t\t__key_link(key, &edit);\n\t\t__key_link_end(keyring, &key->index_key, edit);\n\t}\n\n\tkleave(\" = %d {%d,%d}\", ret, keyring->serial, refcount_read(&keyring->usage));\n\treturn ret;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":435634,"func":"\nstatic u32 ql_get_speed(struct ql3_adapter *qdev)\n{\n\tu32 status;\n\tunsigned long hw_flags;\n\tspin_lock_irqsave(&qdev->hw_lock, hw_flags);\n\tif (ql_sem_spinlock(qdev, QL_PHY_GIO_SEM_MASK,\n\t\t\t    (QL_RESOURCE_BITS_BASE_CODE |\n\t\t\t     (qdev->mac_index) * 2) << 7)) {\n\t\tspin_unlock_irqrestore(&qdev->hw_lock, hw_flags);\n\t\treturn 0;\n\t}\n\tstatus = ql_get_link_speed(qdev);\n\tql_sem_unlock(qdev, QL_PHY_GIO_SEM_MASK);\n\tspin_unlock_irqrestore(&qdev->hw_lock, hw_flags);\n\treturn status;","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":204155,"func":"static void unsignedShortAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n    TestObjectV8Internal::unsignedShortAttrAttributeGetter(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":197532,"func":"void SyncBackendHost::Core::DoRequestConfig(\n    syncable::ModelTypeSet types_to_config,\n    sync_api::ConfigureReason reason) {\n  DCHECK_EQ(MessageLoop::current(), sync_loop_);\n  sync_manager_->RequestConfig(types_to_config, reason);\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":466450,"func":"TEST_F(ConnectionManagerUtilityTest, ViaEmpty) {\n  connection_.stream_info_.downstream_address_provider_->setRemoteAddress(\n      std::make_shared<Network::Address::Ipv4Instance>(\"10.0.0.1\"));\n  ON_CALL(config_, useRemoteAddress()).WillByDefault(Return(true));\n\n  TestRequestHeaderMapImpl request_headers;\n  EXPECT_EQ((MutateRequestRet{\"10.0.0.1:0\", true, Tracing::Reason::NotTraceable}),\n            callMutateRequestHeaders(request_headers, Protocol::Http2));\n  EXPECT_FALSE(request_headers.has(Headers::get().Via));\n\n  TestResponseHeaderMapImpl response_headers;\n  ConnectionManagerUtility::mutateResponseHeaders(response_headers, &request_headers, config_,\n                                                  via_);\n  EXPECT_FALSE(response_headers.has(Headers::get().Via));\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":363465,"func":"_gdm_user_show_full_display_name (GdmUser *user)\n{\n        char *uniq_name;\n\n        g_return_if_fail (GDM_IS_USER (user));\n\n        if (user->real_name != NULL) {\n                uniq_name = g_strdup_printf (\"%s (%s)\",\n                                             user->real_name,\n                                             user->user_name);\n        } else {\n                uniq_name = NULL;\n        }\n\n        if ((user->real_name && !user->display_name) ||\n            (!user->real_name && user->display_name) ||\n            (user->real_name &&\n             user->display_name &&\n             strcmp (uniq_name, user->display_name) != 0)) {\n                g_free (user->display_name);\n                user->display_name = uniq_name;\n                g_object_notify (G_OBJECT (user), \"display-name\");\n        } else {\n                g_free (uniq_name);\n        }\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":214389,"func":"gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() {\n  Framebuffer* framebuffer = GetBoundReadFramebuffer();\n  if (framebuffer) {\n    return framebuffer->GetFramebufferValidSize();\n  } else if (offscreen_target_frame_buffer_.get()) {\n    return offscreen_size_;\n  } else {\n    return surface_->GetSize();\n  }\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":419877,"func":"   Rename a mailbox *\/\nPHP_FUNCTION(imap_renamemailbox)\n{\n\tzval *streamind;\n\tzend_string *old_mailbox, *new_mailbox;\n\tpils *imap_le_struct;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"rSS\", &streamind, &old_mailbox, &new_mailbox) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), \"imap\", le_imap)) == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (mail_rename(imap_le_struct->imap_stream, ZSTR_VAL(old_mailbox), ZSTR_VAL(new_mailbox)) == T) {\n\t\tRETURN_TRUE;\n\t} else {\n\t\tRETURN_FALSE;\n\t}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":148373,"func":"char *Hub::inflate(char *data, size_t &length) {\n    dynamicInflationBuffer.clear();\n\n    inflationStream.next_in = (Bytef *) data;\n    inflationStream.avail_in = length;\n\n    int err;\n    do {\n        inflationStream.next_out = (Bytef *) inflationBuffer;\n        inflationStream.avail_out = LARGE_BUFFER_SIZE;\n        err = ::inflate(&inflationStream, Z_FINISH);\n        if (!inflationStream.avail_in) {\n            break;\n        }\n\n        dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n    } while (err == Z_BUF_ERROR && dynamicInflationBuffer.length() <= INFLATE_LESS_THAN_ROUGHLY);\n\n    inflateReset(&inflationStream);\n\n    if ((err != Z_BUF_ERROR && err != Z_OK) || dynamicInflationBuffer.length() > INFLATE_LESS_THAN_ROUGHLY) {\n        length = 0;\n        return nullptr;\n    }\n\n    if (dynamicInflationBuffer.length()) {\n        dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n\n        length = dynamicInflationBuffer.length();\n        return (char *) dynamicInflationBuffer.data();\n    }\n\n    length = LARGE_BUFFER_SIZE - inflationStream.avail_out;\n    return inflationBuffer;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":487556,"func":"  void WillReleaseScriptContext(v8::Local<v8::Context> context,\n                                int world_id) final {\n    \/\/ Unset spell checker when the script context is going to be released, as\n    \/\/ the spell check implementation lives there.\n    UnsetAndDestroy();\n  }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":292700,"func":"    inline void\t\tpost () {_sem.post();}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":152143,"func":"\n    const T* data(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int c=0) const {\n      return _data + x + (ulongT)y*_width + (ulongT)z*_width*_height + (ulongT)c*_width*_height*_depth;","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":35525,"func":"static inline const char *FxSubexpression(const char *expression,\n  ExceptionInfo *exception)\n{\n  const char\n    *subexpression;\n\n  register ssize_t\n    level;\n\n  level=0;\n  subexpression=expression;\n  while ((*subexpression != '\\0') &&\n         ((level != 1) || (strchr(\")\",(int) *subexpression) == (char *) NULL)))\n  {\n    if (strchr(\"(\",(int) *subexpression) != (char *) NULL)\n      level++;\n    else\n      if (strchr(\")\",(int) *subexpression) != (char *) NULL)\n        level--;\n    subexpression++;\n  }\n  if (*subexpression == '\\0')\n    (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n      \"UnbalancedParenthesis\",\"`%s'\",expression);\n  return(subexpression);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":389921,"func":"ServerKeyExchange::~ServerKeyExchange()\n{\n    ysDelete(server_key_);\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":464734,"func":"static int v4l_g_crop(const struct v4l2_ioctl_ops *ops,\n\t\t\t\tstruct file *file, void *fh, void *arg)\n{\n\tstruct video_device *vfd = video_devdata(file);\n\tstruct v4l2_crop *p = arg;\n\tstruct v4l2_selection s = {\n\t\t.type = p->type,\n\t};\n\tint ret;\n\n\t\/* simulate capture crop using selection api *\/\n\n\t\/* crop means compose for output devices *\/\n\tif (V4L2_TYPE_IS_OUTPUT(p->type))\n\t\ts.target = V4L2_SEL_TGT_COMPOSE;\n\telse\n\t\ts.target = V4L2_SEL_TGT_CROP;\n\n\tif (test_bit(V4L2_FL_QUIRK_INVERTED_CROP, &vfd->flags))\n\t\ts.target = s.target == V4L2_SEL_TGT_COMPOSE ?\n\t\t\tV4L2_SEL_TGT_CROP : V4L2_SEL_TGT_COMPOSE;\n\n\tret = v4l_g_selection(ops, file, fh, &s);\n\n\t\/* copying results to old structure on success *\/\n\tif (!ret)\n\t\tp->c = s.r;\n\treturn ret;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":438628,"func":"static u32 *gen8_emit_fini_breadcrumb(struct i915_request *request, u32 *cs)\n{\n\tcs = gen8_emit_ggtt_write(cs,\n\t\t\t\t  request->fence.seqno,\n\t\t\t\t  i915_request_active_timeline(request)->hwsp_offset,\n\t\t\t\t  0);\n\n\treturn gen8_emit_fini_breadcrumb_footer(request, cs);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":355095,"func":"ProcShmDispatch (client)\n    register ClientPtr\tclient;\n{\n    REQUEST(xReq);\n    switch (stuff->data)\n    {\n    case X_ShmQueryVersion:\n\treturn ProcShmQueryVersion(client);\n    case X_ShmAttach:\n\treturn ProcShmAttach(client);\n    case X_ShmDetach:\n\treturn ProcShmDetach(client);\n    case X_ShmPutImage:\n#ifdef PANORAMIX\n        if ( !noPanoramiXExtension )\n\t   return ProcPanoramiXShmPutImage(client);\n#endif\n\treturn ProcShmPutImage(client);\n    case X_ShmGetImage:\n#ifdef PANORAMIX\n        if ( !noPanoramiXExtension )\n\t   return ProcPanoramiXShmGetImage(client);\n#endif\n\treturn ProcShmGetImage(client);\n    case X_ShmCreatePixmap:\n#ifdef PANORAMIX\n        if ( !noPanoramiXExtension )\n\t   return ProcPanoramiXShmCreatePixmap(client);\n#endif\n\t   return ProcShmCreatePixmap(client);\n    default:\n\treturn BadRequest;\n    }\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":55083,"func":"static int proc_close( struct inode *inode, struct file *file )\n{\n\tstruct proc_data *data = file->private_data;\n\n\tif (data->on_close != NULL)\n\t\tdata->on_close(inode, file);\n\tkfree(data->rbuffer);\n\tkfree(data->wbuffer);\n\tkfree(data);\n\treturn 0;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":101156,"func":"static void *alloc_event_data(int cpu)\n{\n\tint size;\n\tcpumask_t *mask;\n\tstruct etm_event_data *event_data;\n\n\t\/* First get memory for the session's data *\/\n\tevent_data = kzalloc(sizeof(struct etm_event_data), GFP_KERNEL);\n\tif (!event_data)\n\t\treturn NULL;\n\n\t\/* Make sure nothing disappears under us *\/\n\tget_online_cpus();\n\tsize = num_online_cpus();\n\n\tmask = &event_data->mask;\n\tif (cpu != -1)\n\t\tcpumask_set_cpu(cpu, mask);\n\telse\n\t\tcpumask_copy(mask, cpu_online_mask);\n\tput_online_cpus();\n\n\t\/*\n\t * Each CPU has a single path between source and destination.  As such\n\t * allocate an array using CPU numbers as indexes.  That way a path\n\t * for any CPU can easily be accessed at any given time.  We proceed\n\t * the same way for sessions involving a single CPU.  The cost of\n\t * unused memory when dealing with single CPU trace scenarios is small\n\t * compared to the cost of searching through an optimized array.\n\t *\/\n\tevent_data->path = kcalloc(size,\n\t\t\t\t   sizeof(struct list_head *), GFP_KERNEL);\n\tif (!event_data->path) {\n\t\tkfree(event_data);\n\t\treturn NULL;\n\t}\n\n\treturn event_data;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":509266,"func":"static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) {\n        Manager *m = userdata;\n        Iterator i;\n        Unit *u;\n\n        assert(m);\n        assert(m->time_change_fd == fd);\n\n        log_struct(LOG_INFO,\n                   MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),\n                   \"MESSAGE=Time has been changed\",\n                   NULL);\n\n        \/* Restart the watch *\/\n        m->time_change_event_source = sd_event_source_unref(m->time_change_event_source);\n\n        close_nointr_nofail(m->time_change_fd);\n        m->time_change_fd = -1;\n\n        manager_setup_time_change(m);\n\n        HASHMAP_FOREACH(u, m->units, i)\n                if (UNIT_VTABLE(u)->time_change)\n                        UNIT_VTABLE(u)->time_change(u);\n\n        return 0;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":308590,"func":"tar_sparse_dump_region (struct tar_sparse_file *file, size_t i)\n{\n  if (file->optab->dump_region)\n    return file->optab->dump_region (file, i);\n  return false;\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":503120,"func":"static void connection_handle_shutdown(connection *con) {\n\tplugins_call_handle_connection_shut_wr(con);\n\n\tconnection_reset(con);\n\t++con->srv->con_closed;\n\n\t\/* close the connection *\/\n\tif (con->fd >= 0\n\t    && (con->is_ssl_sock || 0 == shutdown(con->fd, SHUT_WR))) {\n\t\tcon->close_timeout_ts = log_epoch_secs;\n\n\t\trequest_st * const r = &con->request;\n\t\tconnection_set_state(r, CON_STATE_CLOSE);\n\t\tif (r->conf.log_state_handling) {\n\t\t\tlog_error(r->conf.errh, __FILE__, __LINE__,\n\t\t\t  \"shutdown for fd %d\", con->fd);\n\t\t}\n\t} else {\n\t\tconnection_close(con);\n\t}\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":361657,"func":"_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm)\n{\n  ssize_t ret = -1;\n  GNUTLS_HASH_ALG_LOOP (ret = p->id);\n  if (ret >= 0)\n    ret = 0;\n  else\n    ret = 1;\n  return ret;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":374567,"func":"RangeVarCallbackOwnsTable(const RangeVar *relation,\n\t\t\t\t\t\t  Oid relId, Oid oldRelId, void *arg)\n{\n\tchar\t\trelkind;\n\n\t\/* Nothing to do if the relation was not found. *\/\n\tif (!OidIsValid(relId))\n\t\treturn;\n\n\t\/*\n\t * If the relation does exist, check whether it's an index.  But note that\n\t * the relation might have been dropped between the time we did the name\n\t * lookup and now.\tIn that case, there's nothing to do.\n\t *\/\n\trelkind = get_rel_relkind(relId);\n\tif (!relkind)\n\t\treturn;\n\tif (relkind != RELKIND_RELATION && relkind != RELKIND_TOASTVALUE &&\n\t\trelkind != RELKIND_MATVIEW)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_WRONG_OBJECT_TYPE),\n\t\t\t\t errmsg(\"\\\"%s\\\" is not a table or materialized view\", relation->relname)));\n\n\t\/* Check permissions *\/\n\tif (!pg_class_ownercheck(relId, GetUserId()))\n\t\taclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS, relation->relname);\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":471350,"func":"void addReplyHumanLongDouble(client *c, long double d) {\n    if (c->resp == 2) {\n        robj *o = createStringObjectFromLongDouble(d,1);\n        addReplyBulk(c,o);\n        decrRefCount(o);\n    } else {\n        char buf[MAX_LONG_DOUBLE_CHARS];\n        int len = ld2string(buf,sizeof(buf),d,LD_STR_HUMAN);\n        addReplyProto(c,\",\",1);\n        addReplyProto(c,buf,len);\n        addReplyProto(c,\"\\r\\n\",2);\n    }\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":83651,"func":"int pit_has_pending_timer(struct kvm_vcpu *vcpu)\n{\n\tstruct kvm_pit *pit = vcpu->kvm->arch.vpit;\n\n\tif (pit && kvm_vcpu_is_bsp(vcpu) && pit->pit_state.irq_ack)\n\t\treturn atomic_read(&pit->pit_state.pit_timer.pending);\n\treturn 0;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":375248,"func":"_copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)\n{\n\tAlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);\n\n\tCOPY_NODE_FIELD(dictname);\n\tCOPY_NODE_FIELD(options);\n\n\treturn newnode;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":422127,"func":"e_ews_connection_get_server_version (EEwsConnection *cnc)\n{\n\tg_return_val_if_fail (cnc != NULL, E_EWS_EXCHANGE_UNKNOWN);\n\tg_return_val_if_fail (cnc->priv != NULL, E_EWS_EXCHANGE_UNKNOWN);\n\n\treturn cnc->priv->version;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":239593,"func":"void RenderBox::addShadowOverflow()\n{\n    int shadowLeft;\n    int shadowRight;\n    int shadowTop;\n    int shadowBottom;\n    style()->getBoxShadowExtent(shadowTop, shadowRight, shadowBottom, shadowLeft);\n    IntRect borderBox = borderBoxRect();\n    int overflowLeft = borderBox.x() + shadowLeft;\n    int overflowRight = borderBox.maxX() + shadowRight;\n    int overflowTop = borderBox.y() + shadowTop;\n    int overflowBottom = borderBox.maxY() + shadowBottom;\n    addVisualOverflow(IntRect(overflowLeft, overflowTop, overflowRight - overflowLeft, overflowBottom - overflowTop));\n}\n","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":101725,"func":"static int kvm_get_msr_with_filter(struct kvm_vcpu *vcpu, u32 index, u64 *data)\n{\n\tif (!kvm_msr_allowed(vcpu, index, KVM_MSR_FILTER_READ))\n\t\treturn KVM_MSR_RET_FILTERED;\n\treturn kvm_get_msr_ignored_check(vcpu, index, data, false);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":388696,"func":"int smb_vfs_call_closedir(struct vfs_handle_struct *handle,\n\t\t\t  DIR *dir)\n{\n\tVFS_FIND(closedir);\n\treturn handle->fns->closedir_fn(handle, dir);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":194187,"func":"void UsbDevice::OpenInterface(int interface_id, const OpenCallback& callback) {\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":182756,"func":"void lbl_destroy()\n{\n    pthread_mutex_destroy(&(device.lbllock));\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":322344,"func":"static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin,\n\n\t\t\t\t     int off_pitch, int bytesperline,\n\n\t\t\t\t     int lines)\n\n{\n\n    int y;\n\n    int off_cur;\n\n    int off_cur_end;\n\n\n\n    for (y = 0; y < lines; y++) {\n\n\toff_cur = off_begin;\n\n\toff_cur_end = off_cur + bytesperline;\n\n\toff_cur &= TARGET_PAGE_MASK;\n\n\twhile (off_cur < off_cur_end) {\n\n\t    cpu_physical_memory_set_dirty(s->vram_offset + off_cur);\n\n\t    off_cur += TARGET_PAGE_SIZE;\n\n\t}\n\n\toff_begin += off_pitch;\n\n    }\n\n}\n","target":1,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":308487,"func":"CreateDownloadURLLoaderFactoryGetterFromURLLoaderFactory(\n    std::unique_ptr<network::mojom::URLLoaderFactory> factory) {\n  network::mojom::URLLoaderFactoryPtr factory_ptr;\n  mojo::MakeStrongBinding(std::move(factory), mojo::MakeRequest(&factory_ptr));\n  network::mojom::URLLoaderFactoryPtrInfo factory_ptr_info =\n      factory_ptr.PassInterface();\n\n  auto wrapper_factory =\n      std::make_unique<network::WrapperSharedURLLoaderFactoryInfo>(\n          std::move(factory_ptr_info));\n  return base::MakeRefCounted<download::DownloadURLLoaderFactoryGetterImpl>(\n      std::move(wrapper_factory));\n}\n","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":433039,"func":"static int v9fs_set_super(struct super_block *s, void *data)\n{\n\ts->s_fs_info = data;\n\treturn set_anon_super(s, data);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":199172,"func":"FPDF_PAGE PDFiumEngine::Form_GetCurrentPage(FPDF_FORMFILLINFO* param,\n                                            FPDF_DOCUMENT document) {\n  PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);\n  int index = engine->last_page_mouse_down_;\n  if (index == -1) {\n    index = engine->GetMostVisiblePage();\n    if (index == -1) {\n      NOTREACHED();\n      return nullptr;\n    }\n  }\n\n  return engine->pages_[index]->GetPage();\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":140688,"func":"static inline void hwsim_check_sta_magic(struct ieee80211_sta *sta)\n{\n\tstruct hwsim_sta_priv *sp = (void *)sta->drv_priv;\n\tWARN_ON(sp->magic != HWSIM_STA_MAGIC);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":115735,"func":"find_match_paren(int ind_maxparen)\t\/\/ XXX\n{\n    return find_match_char('(', ind_maxparen);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":173132,"func":"void HTMLMediaElement::AudioClientImpl::Trace(blink::Visitor* visitor) {\n  visitor->Trace(client_);\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":43729,"func":"int CL_ScaledMilliseconds( void ) {\n\treturn Sys_Milliseconds() * com_timescale->value;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":347409,"func":"static js_Ast *equality(js_State *J, int notin)\n{\n\tjs_Ast *a = relational(J, notin);\nloop:\n\tif (jsP_accept(J, TK_EQ)) { a = EXP2(EQ, a, relational(J, notin)); goto loop; }\n\tif (jsP_accept(J, TK_NE)) { a = EXP2(NE, a, relational(J, notin)); goto loop; }\n\tif (jsP_accept(J, TK_STRICTEQ)) { a = EXP2(STRICTEQ, a, relational(J, notin)); goto loop; }\n\tif (jsP_accept(J, TK_STRICTNE)) { a = EXP2(STRICTNE, a, relational(J, notin)); goto loop; }\n\treturn a;\n}","target":1,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":411190,"func":"    **\/\n    CImg<T>& acos() {\n      if (is_empty()) return *this;\n      cimg_pragma_openmp(parallel for cimg_openmp_if(size()>=8192))\n      cimg_rof(*this,ptrd,T) *ptrd = (T)std::acos((double)*ptrd);\n      return *this;","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":419354,"func":"window_pane_choose_best(struct window_pane **list, u_int size)\n{\n\tstruct window_pane\t*next, *best;\n\tu_int\t\t\t i;\n\n\tif (size == 0)\n\t\treturn (NULL);\n\n\tbest = list[0];\n\tfor (i = 1; i < size; i++) {\n\t\tnext = list[i];\n\t\tif (next->active_point > best->active_point)\n\t\t\tbest = next;\n\t}\n\treturn (best);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":324716,"func":"int bdrv_flush(BlockDriverState *bs)\n\n{\n\n    Coroutine *co;\n\n    FlushCo flush_co = {\n\n        .bs = bs,\n\n        .ret = NOT_DONE,\n\n    };\n\n\n\n    if (qemu_in_coroutine()) {\n\n        \/* Fast-path if already in coroutine context *\/\n\n        bdrv_flush_co_entry(&flush_co);\n\n    } else {\n\n        co = qemu_coroutine_create(bdrv_flush_co_entry, &flush_co);\n\n        qemu_coroutine_enter(co);\n\n        BDRV_POLL_WHILE(bs, flush_co.ret == NOT_DONE);\n\n    }\n\n\n\n    return flush_co.ret;\n\n}\n","target":1,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":105304,"func":"  const std::string getRepl() const {\n    return repl;\n  }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":95796,"func":"DEFUN(gorURL, GOTO_RELATIVE, \"Go to relative address\")\n{\n    goURL0(\"Goto relative URL: \", TRUE);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":266142,"func":"  bool CanOptimize(const NodeDef& node) const {\n    DataType dtype = GetDataTypeFromAttr(node, \"T\");\n    if (!IsSupported(node.op(), dtype)) {\n      return false;\n    }\n    if (IsInPreserveSet(node)) {\n      return false;\n    }\n    if (!NodeIsOnCpu(node)) {\n      return false;\n    }\n    if (NodeIsAlreadyFused(node)) {\n      return false;\n    }\n    return !(IsDrivenByControlDependency(node) ||\n             DrivesControlDependency(node));\n  }","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":428201,"func":"int tcp_mss_to_mtu(struct sock *sk, int mss)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tconst struct inet_connection_sock *icsk = inet_csk(sk);\n\tint mtu;\n\n\tmtu = mss +\n\t      tp->tcp_header_len +\n\t      icsk->icsk_ext_hdr_len +\n\t      icsk->icsk_af_ops->net_header_len;\n\n\t\/* IPv6 adds a frag_hdr in case RTAX_FEATURE_ALLFRAG is set *\/\n\tif (icsk->icsk_af_ops->net_frag_header_len) {\n\t\tconst struct dst_entry *dst = __sk_dst_get(sk);\n\n\t\tif (dst && dst_allfrag(dst))\n\t\t\tmtu += icsk->icsk_af_ops->net_frag_header_len;\n\t}\n\treturn mtu;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":142063,"func":"unsigned long long task_sched_runtime(struct task_struct *p)\n{\n\tunsigned long flags;\n\tstruct rq *rq;\n\tu64 ns = 0;\n\n\trq = task_rq_lock(p, &flags);\n\tns = p->se.sum_exec_runtime + do_task_delta_exec(p, rq);\n\ttask_rq_unlock(rq, &flags);\n\n\treturn ns;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":114159,"func":"tsqueryout(PG_FUNCTION_ARGS)\n{\n\tTSQuery\t\tquery = PG_GETARG_TSQUERY(0);\n\tINFIX\t\tnrm;\n\n\tif (query->size == 0)\n\t{\n\t\tchar\t   *b = palloc(1);\n\n\t\t*b = '\\0';\n\t\tPG_RETURN_POINTER(b);\n\t}\n\tnrm.curpol = GETQUERY(query);\n\tnrm.buflen = 32;\n\tnrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);\n\t*(nrm.cur) = '\\0';\n\tnrm.op = GETOPERAND(query);\n\tinfix(&nrm, true);\n\n\tPG_FREE_IF_COPY(query, 0);\n\tPG_RETURN_CSTRING(nrm.buf);\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":213141,"func":"void ScreenRecorder::EncodedDataAvailableCallback(VideoPacket* packet) {\n  DCHECK_EQ(encode_loop_, MessageLoop::current());\n\n  if (encoder_stopped_)\n    return;\n\n  bool last = (packet->flags() & VideoPacket::LAST_PACKET) != 0;\n  if (last) {\n    base::TimeDelta encode_time = base::Time::Now() - encode_start_time_;\n    int encode_time_ms =\n        static_cast<int>(encode_time.InMilliseconds());\n    packet->set_encode_time_ms(encode_time_ms);\n    scheduler_.RecordEncodeTime(encode_time);\n  }\n\n  network_loop_->PostTask(\n      FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, packet));\n}\n","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":189522,"func":"WtsSessionProcessDelegate::~WtsSessionProcessDelegate() {\n  core_->Stop();\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":438653,"func":"intel_virtual_engine_get_sibling(struct intel_engine_cs *engine,\n\t\t\t\t unsigned int sibling)\n{\n\tstruct virtual_engine *ve = to_virtual_engine(engine);\n\n\tif (sibling >= ve->num_siblings)\n\t\treturn NULL;\n\n\treturn ve->siblings[sibling];\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":116951,"func":"dnslabel_table_add(struct dnslabel_table *table, const char *label, off_t pos)\n{\n\tchar *v;\n\tint p;\n\tif (table->n_labels == MAX_LABELS)\n\t\treturn (-1);\n\tv = mm_strdup(label);\n\tif (v == NULL)\n\t\treturn (-1);\n\tp = table->n_labels++;\n\ttable->labels[p].v = v;\n\ttable->labels[p].pos = pos;\n\n\treturn (0);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":64454,"func":"nv_home(cmdarg_T *cap)\n{\n    \/\/ CTRL-HOME is like \"gg\"\n    if (mod_mask & MOD_MASK_CTRL)\n\tnv_goto(cap);\n    else\n    {\n\tcap->count0 = 1;\n\tnv_pipe(cap);\n    }\n    ins_at_eol = FALSE;\t    \/\/ Don't move cursor past eol (only necessary in a\n\t\t\t    \/\/ one-character line).\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":299776,"func":"static __net_init int proto_init_net(struct net *net)\n{\n\tif (!proc_net_fops_create(net, \"protocols\", S_IRUGO, &proto_seq_fops))\n\t\treturn -ENOMEM;\n\n\treturn 0;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":176339,"func":"OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len)\n{\n\tOJPEGState* sp=(OJPEGState*)tif->tif_data;\n\tassert(OJPEG_BUFFER>=6);\n\tif (sp->restart_interval!=0)\n\t{\n\t\tsp->out_buffer[0]=255;\n\t\tsp->out_buffer[1]=JPEG_MARKER_DRI;\n\t\tsp->out_buffer[2]=0;\n\t\tsp->out_buffer[3]=4;\n\t\tsp->out_buffer[4]=(sp->restart_interval>>8);\n\t\tsp->out_buffer[5]=(sp->restart_interval&255);\n\t\t*len=6;\n\t\t*mem=(void*)sp->out_buffer;\n\t}\n\tsp->out_state++;\n}\n","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":268254,"func":"int xdr_decode_array2(const struct xdr_buf *buf, unsigned int base,\n\t\t      struct xdr_array2_desc *desc)\n{\n\tif (base >= buf->len)\n\t\treturn -EINVAL;\n\n\treturn xdr_xcode_array2(buf, base, desc, 0);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":192128,"func":"void ShelfLayoutManager::OnLockStateEvent(LockStateObserver::EventType event) {\n  if (event == EVENT_LOCK_ANIMATION_STARTED) {\n    state_.pre_lock_screen_animation_active = true;\n    UpdateShelfVisibilityAfterLoginUIChange();\n  } else {\n    state_.pre_lock_screen_animation_active = false;\n  }\n  MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE);\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":236563,"func":"void ExtensionInstallPrompt::SetIcon(const SkBitmap* image) {\n  if (image)\n    icon_ = *image;\n  else\n    icon_ = SkBitmap();\n  if (icon_.empty()) {\n    icon_ = GetDefaultIconBitmapForMaxScaleFactor(\n        extension_ ? extension_->is_app() : false);\n  }\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":29769,"func":"static void append_user ( String * str , LEX_USER * user ) {\n if ( str -> length ( ) ) str -> append ( ',' ) ;\n str -> append ( '\\'' ) ;\n str -> append ( user -> user . str ) ;\n str -> append ( STRING_WITH_LEN ( \"'@'\" ) ) ;\n str -> append ( user -> host . str ) ;\n str -> append ( '\\'' ) ;\n }","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":296159,"func":"TEST_P(ProtocolIntegrationTest, TestDownstreamResetIdleTimeout) {\n  useAccessLog(\"%RESPONSE_FLAGS% %RESPONSE_CODE_DETAILS%\");\n  config_helper_.setDownstreamHttpIdleTimeout(std::chrono::milliseconds(100));\n\n  initialize();\n  codec_client_ = makeHttpConnection(lookupPort(\"http\"));\n\n  auto encoder_decoder = codec_client_->startRequest(default_request_headers_);\n\n  EXPECT_TRUE(fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, fake_upstream_connection_));\n\n  EXPECT_TRUE(fake_upstream_connection_->waitForNewStream(*dispatcher_, upstream_request_));\n\n  if (downstreamProtocol() == Http::CodecType::HTTP1) {\n    codec_client_->close();\n  } else {\n    codec_client_->sendReset(encoder_decoder.first);\n  }\n\n  if (upstreamProtocol() == Http::CodecType::HTTP1) {\n    ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect());\n  } else {\n    ASSERT_TRUE(upstream_request_->waitForReset());\n    ASSERT_TRUE(fake_upstream_connection_->close());\n    ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect());\n  }\n\n  ASSERT_TRUE(codec_client_->waitForDisconnect());\n  EXPECT_THAT(waitForAccessLog(access_log_name_), Not(HasSubstr(\"DPE\")));\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":61867,"func":"static void __perf_event_exit_context(void *__info)\n{\n\tstruct remove_event re = { .detach_group = true };\n\tstruct perf_event_context *ctx = __info;\n\n\tperf_pmu_rotate_stop(ctx->pmu);\n\n\trcu_read_lock();\n\tlist_for_each_entry_rcu(re.event, &ctx->event_list, event_entry)\n\t\t__perf_remove_from_context(&re);\n\trcu_read_unlock();\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":378939,"func":"int LZ4IO_setStreamChecksumMode(int xxhash)\n{\n    streamChecksum = (xxhash != 0);\n    return streamChecksum;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":221576,"func":"void mem_cgroup_split_huge_fixup(struct page *head)\n{\n\tstruct page_cgroup *head_pc = lookup_page_cgroup(head);\n\tstruct page_cgroup *pc;\n\tint i;\n\n\tif (mem_cgroup_disabled())\n\t\treturn;\n\tfor (i = 1; i < HPAGE_PMD_NR; i++) {\n\t\tpc = head_pc + i;\n\t\tpc->mem_cgroup = head_pc->mem_cgroup;\n\t\tsmp_wmb();\/* see __commit_charge() *\/\n\t\tpc->flags = head_pc->flags & ~PCGF_NOCOPY_AT_SPLIT;\n\t}\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":280767,"func":"bool FrameSelection::ShouldShowBlockCursor() const {\n  return frame_caret_->ShouldShowBlockCursor();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":245270,"func":"  void RegisterClient(MockStorageClient* client) {\n     quota_manager_->proxy()->RegisterClient(client);\n   }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":397875,"func":"static void event_privmsg(IRC_SERVER_REC *server, const char *data,\n\t\t\t  const char *nick, const char *address)\n{\n\tchar *params, *target, *msg;\n\n\tg_return_if_fail(data != NULL);\n\tif (nick == NULL)\n\t\treturn;\n\n\tparams = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);\n        check_query_changes(server, nick, address, target);\n\tg_free(params);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":248749,"func":"sysfs_get_string (const char *dir,\n                  const char *attribute)\n{\n  char *result;\n  char *filename;\n\n  result = NULL;\n  filename = g_build_filename (dir, attribute, NULL);\n  if (!g_file_get_contents (filename, &result, NULL, NULL))\n    {\n      result = g_strdup (\"\");\n    }\n  g_free (filename);\n\n  return result;\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":417611,"func":"LogClose(enum ExitCode error)\n{\n    if (logFile) {\n        int msgtype = (error == EXIT_NO_ERROR) ? X_INFO : X_ERROR;\n        LogMessageVerbSigSafe(msgtype, -1,\n                \"Server terminated %s (%d). Closing log file.\\n\",\n                (error == EXIT_NO_ERROR) ? \"successfully\" : \"with error\",\n                error);\n        fclose(logFile);\n        logFile = NULL;\n        logFileFd = -1;\n    }\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":31870,"func":"int x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size)\n{\n\tint r;\n\n\tmutex_lock(&kvm->slots_lock);\n\tr = __x86_set_memory_region(kvm, id, gpa, size);\n\tmutex_unlock(&kvm->slots_lock);\n\n\treturn r;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":255477,"func":"static long mem_seek(jas_stream_obj_t *obj, long offset, int origin)\n{\n\tjas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;\n\tlong newpos;\n\n\tJAS_DBGLOG(100, (\"mem_seek(%p, %ld, %d)\\n\", obj, offset, origin));\n\tswitch (origin) {\n\tcase SEEK_SET:\n\t\tnewpos = offset;\n\t\tbreak;\n\tcase SEEK_END:\n\t\tnewpos = m->len_ - offset;\n\t\tbreak;\n\tcase SEEK_CUR:\n\t\tnewpos = m->pos_ + offset;\n\t\tbreak;\n\tdefault:\n\t\tabort();\n\t\tbreak;\n\t}\n\tif (newpos < 0) {\n\t\treturn -1;\n\t}\n\tm->pos_ = newpos;\n\n\treturn m->pos_;\n}","target":1,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":244078,"func":"void Layer::RemoveScrollChild(Layer* child) {\n  scroll_children_->erase(child);\n  if (scroll_children_->empty())\n    scroll_children_.reset();\n  SetNeedsCommit();\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":501287,"func":"ZSTD_CStream* ZSTD_createCStream(void)\n{\n    DEBUGLOG(3, \"ZSTD_createCStream\");\n    return ZSTD_createCStream_advanced(ZSTD_defaultCMem);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":241464,"func":"bool AutocompleteEditModel::CreatedKeywordSearchByInsertingSpaceInMiddle(\n    const string16& old_text,\n    const string16& new_text,\n    size_t caret_position) const {\n  DCHECK_GE(new_text.length(), caret_position);\n\n  if ((paste_state_ != NONE) || (caret_position < 2) ||\n      (old_text.length() < caret_position) ||\n      (new_text.length() == caret_position))\n    return false;\n  size_t space_position = caret_position - 1;\n  if (!IsSpaceCharForAcceptingKeyword(new_text[space_position]) ||\n      IsWhitespace(new_text[space_position - 1]) ||\n      new_text.compare(0, space_position, old_text, 0, space_position) ||\n      !new_text.compare(space_position, new_text.length() - space_position,\n                        old_text, space_position,\n                        old_text.length() - space_position)) {\n    return false;\n  }\n\n  string16 keyword;\n  TrimWhitespace(new_text.substr(0, space_position), TRIM_LEADING, &keyword);\n  return !keyword.empty() &&\n      !autocomplete_controller_->keyword_provider()->\n          GetKeywordForText(keyword).empty();\n}\n","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":448455,"func":"dns_message_movename(dns_message_t *msg, dns_name_t *name,\n\t\t     dns_section_t fromsection,\n\t\t     dns_section_t tosection)\n{\n\tREQUIRE(msg != NULL);\n\tREQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER);\n\tREQUIRE(name != NULL);\n\tREQUIRE(VALID_NAMED_SECTION(fromsection));\n\tREQUIRE(VALID_NAMED_SECTION(tosection));\n\n\t\/*\n\t * Unlink the name from the old section\n\t *\/\n\tISC_LIST_UNLINK(msg->sections[fromsection], name, link);\n\tISC_LIST_APPEND(msg->sections[tosection], name, link);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":277305,"func":"void CustomButton::AnimationProgressed(const gfx::Animation* animation) {\n  SchedulePaint();\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":107361,"func":"static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)\n{\n    int64_t length, pos;\n    if (!mxf_read_sync(pb, mxf_klv_key, 4))\n        return AVERROR_INVALIDDATA;\n    klv->offset = avio_tell(pb) - 4;\n    memcpy(klv->key, mxf_klv_key, 4);\n    avio_read(pb, klv->key + 4, 12);\n    length = klv_decode_ber_length(pb);\n    if (length < 0)\n        return length;\n    klv->length = length;\n    pos = avio_tell(pb);\n    if (pos > INT64_MAX - length)\n        return AVERROR_INVALIDDATA;\n    klv->next_klv = pos + length;\n    return 0;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":210320,"func":"bool DecodeCharset(const std::string& input,\n                   std::string* decoded_charset,\n                   std::string* value) {\n  StringTokenizer t(input, \"'\");\n  t.set_options(StringTokenizer::RETURN_DELIMS);\n  std::string temp_charset;\n  std::string temp_value;\n  int numDelimsSeen = 0;\n  while (t.GetNext()) {\n    if (t.token_is_delim()) {\n      ++numDelimsSeen;\n      continue;\n    } else {\n      switch (numDelimsSeen) {\n        case 0:\n          temp_charset = t.token();\n          break;\n        case 1:\n          break;\n        case 2:\n          temp_value = t.token();\n          break;\n        default:\n          return false;\n      }\n    }\n  }\n  if (numDelimsSeen != 2)\n    return false;\n  if (temp_charset.empty() || temp_value.empty())\n    return false;\n  decoded_charset->swap(temp_charset);\n  value->swap(temp_value);\n  return true;\n}\n","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":459358,"func":"cb_syslog_badpri(const union sudo_defs_val *sd_un)\n{\n    debug_decl(cb_syslog_badpri, SUDOERS_DEBUG_PLUGIN);\n\n    eventlog_set_syslog_rejectpri(sd_un->ival);\n    eventlog_set_syslog_alertpri(sd_un->ival);\n\n    debug_return_bool(true);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":108088,"func":"static Jsi_OpCodes *code_pop(int n) { JSI_NEW_CODES(0,OP_POP, n); }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":179720,"func":"void SessionModelAssociator::OnGotSession(\n    int handle,\n    std::vector<SessionWindow*>* windows) {\n  DCHECK(CalledOnValidThread());\n  DCHECK(local_session_syncid_);\n\n  sync_pb::SessionSpecifics specifics;\n  specifics.set_session_tag(GetCurrentMachineTag());\n  sync_pb::SessionHeader* header_s = specifics.mutable_header();\n  PopulateSessionSpecificsHeader(*windows, header_s);\n\n  sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare());\n  sync_api::ReadNode root(&trans);\n  if (!root.InitByTagLookup(kSessionsTag)) {\n    LOG(ERROR) << kNoSessionsFolderError;\n    return;\n  }\n\n  sync_api::WriteNode header_node(&trans);\n  if (!header_node.InitByIdLookup(local_session_syncid_)) {\n    LOG(ERROR) << \"Failed to load local session header node.\";\n    return;\n  }\n\n  header_node.SetSessionSpecifics(specifics);\n}\n","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":153074,"func":"modifiers2keycode(int modifiers, int *key, char_u *string)\n{\n    int new_slen = 0;\n\n    if (modifiers != 0)\n    {\n\t\/\/ Some keys have the modifier included.  Need to handle that here to\n\t\/\/ make mappings work.  This may result in a special key, such as\n\t\/\/ K_S_TAB.\n\t*key = simplify_key(*key, &modifiers);\n\tif (modifiers != 0)\n\t{\n\t    string[new_slen++] = K_SPECIAL;\n\t    string[new_slen++] = (int)KS_MODIFIER;\n\t    string[new_slen++] = modifiers;\n\t}\n    }\n    return new_slen;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":94786,"func":"int mod_timer_pending(struct timer_list *timer, unsigned long expires)\n{\n\treturn __mod_timer(timer, expires, MOD_TIMER_PENDING_ONLY);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":322408,"func":"static void add_query_tests(QmpSchema *schema)\n\n{\n\n    SchemaInfoList *tail;\n\n    SchemaInfo *si, *arg_type, *ret_type;\n\n    const char *test_name;\n\n\n\n    \/* Test the query-like commands *\/\n\n    for (tail = schema->list; tail; tail = tail->next) {\n\n        si = tail->value;\n\n        if (si->meta_type != SCHEMA_META_TYPE_COMMAND) {\n\n            continue;\n\n        }\n\n\n\n        if (query_is_blacklisted(si->name)) {\n\n            continue;\n\n        }\n\n\n\n        arg_type = qmp_schema_lookup(schema, si->u.command.arg_type);\n\n        if (object_type_has_mandatory_members(arg_type)) {\n\n            continue;\n\n        }\n\n\n\n        ret_type = qmp_schema_lookup(schema, si->u.command.ret_type);\n\n        if (ret_type->meta_type == SCHEMA_META_TYPE_OBJECT\n\n            && !ret_type->u.object.members) {\n\n            continue;\n\n        }\n\n\n\n        test_name = g_strdup_printf(\"qmp\/%s\", si->name);\n\n        qtest_add_data_func(test_name, si->name, test_query);\n\n    }\n\n}\n","target":1,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":238265,"func":"virtio_gpu_fill_display_info(VirtIOGPU *g,\n                             struct virtio_gpu_resp_display_info *dpy_info)\n{\n    int i;\n\n    for (i = 0; i < g->conf.max_outputs; i++) {\n        if (g->enabled_output_bitmask & (1 << i)) {\n            dpy_info->pmodes[i].enabled = 1;\n            dpy_info->pmodes[i].r.width = g->req_state[i].width;\n            dpy_info->pmodes[i].r.height = g->req_state[i].height;\n        }\n    }\n}\n","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":243946,"func":"String HTMLInputElement::sanitizeValue(const String& proposedValue) const\n{\n    if (proposedValue.isNull())\n        return proposedValue;\n    return m_inputType->sanitizeValue(proposedValue);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":209540,"func":"bool ExtensionRegistry::AddTerminated(\n    const scoped_refptr<const Extension>& extension) {\n  return terminated_extensions_.Insert(extension);\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":128296,"func":"static RList * get_java_bin_obj_list(RAnal *anal) {\n\tRBinJavaObj *bin_obj = (RBinJavaObj * )get_java_bin_obj(anal);\n\t\/\/ See libr\/bin\/p\/bin_java.c to see what is happening here.  The original intention\n\t\/\/ was to use a shared global db variable from shlr\/java\/class.c, but the\n\t\/\/ BIN_OBJS_ADDRS variable kept getting corrupted on Mac, so I (deeso) switched the\n\t\/\/ way the access to the db was taking place by using the bin_obj as a proxy back\n\t\/\/ to the BIN_OBJS_ADDRS which is instantiated in libr\/bin\/p\/bin_java.c\n\t\/\/ not the easiest way to make sausage, but its getting made.\n\treturn  r_bin_java_get_bin_obj_list_thru_obj (bin_obj);\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":214956,"func":"void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) {\n  int width = std::min(size.width(), kMaxWindowWidth);\n  int height = std::min(size.height(), kMaxWindowHeight);\n  if (IsPopup()) {\n    gtk_widget_set_size_request(view_.get(), width, height);\n  }\n\n  if (requested_size_.width() != width ||\n      requested_size_.height() != height) {\n    requested_size_ = gfx::Size(width, height);\n    host_->SendScreenRects();\n    host_->WasResized();\n  }\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":238306,"func":"__be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 respsize)\n{\n\tstruct xdr_buf *buf = &resp->rqstp->rq_res;\n\tstruct nfsd4_slot *slot = resp->cstate.slot;\n\n\tif (buf->len + respsize <= buf->buflen)\n\t\treturn nfs_ok;\n\tif (!nfsd4_has_session(&resp->cstate))\n\t\treturn nfserr_resource;\n\tif (slot->sl_flags & NFSD4_SLOT_CACHETHIS) {\n\t\tWARN_ON_ONCE(1);\n\t\treturn nfserr_rep_too_big_to_cache;\n\t}\n\treturn nfserr_rep_too_big;\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":78240,"func":"smtp_proceed_connected(struct smtp_session *s)\n{\n\tif (s->listener->flags & F_SMTPS)\n\t\tsmtp_cert_init(s);\n\telse\n\t\tsmtp_send_banner(s);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":417202,"func":"parse_CT_CLEAR(char *arg OVS_UNUSED, struct ofpbuf *ofpacts,\n               enum ofputil_protocol *usable_protocols OVS_UNUSED)\n{\n    ofpact_put_CT_CLEAR(ofpacts);\n    return NULL;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":79895,"func":"wf_cliprdr_server_unlock_clipboard_data(CliprdrClientContext* context,\n                                        const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)\n{\n\t(void)context;\n\t(void)unlockClipboardData;\n\treturn CHANNEL_RC_OK;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":316906,"func":"SoftOpus::~SoftOpus() {\n if (mDecoder != NULL) {\n        opus_multistream_decoder_destroy(mDecoder);\n        mDecoder = NULL;\n }\n if (mHeader != NULL) {\n delete mHeader;\n        mHeader = NULL;\n }\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":144882,"func":"flatpak_dir_new_full (GFile *path, gboolean user, DirExtraData *extra_data)\n{\n  FlatpakDir *dir = g_object_new (FLATPAK_TYPE_DIR, \"path\", path, \"user\", user, NULL);\n\n  if (extra_data != NULL)\n    dir->extra_data = dir_extra_data_clone (extra_data);\n\n  return dir;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":437542,"func":"static void io_submit_state_end(struct io_submit_state *state)\n{\n\tblk_finish_plug(&state->plug);\n\tio_file_put(state);\n\tif (state->free_reqs)\n\t\tkmem_cache_free_bulk(req_cachep, state->free_reqs,\n\t\t\t\t\t&state->reqs[state->cur_req]);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":42064,"func":"ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip)\n{\n\treturn 1;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":54623,"func":"mp_sint32 PlayerGeneric::getCurrentBeatIndex()\n{\n\tif (player)\n\t\treturn player->getBeatIndexFromSamplePos(getCurrentSamplePosition());\n\t\n\treturn 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":136247,"func":"String StringUtil::Translate(const String& input, const String& from,\n                             const String& to) {\n  if (input.empty()) return input;\n\n  int len = input.size();\n  String retstr(len, ReserveString);\n  char *ret = retstr.mutableData();\n  memcpy(ret, input.data(), len);\n  auto trlen = std::min(from.size(), to.size());\n  string_translate(ret, len, from.data(), to.data(), trlen);\n  retstr.setSize(len);\n  return retstr;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":335302,"func":"static bool event_notifier_poll(void *opaque)\n\n{\n\n    EventNotifier *e = opaque;\n\n    AioContext *ctx = container_of(e, AioContext, notifier);\n\n\n\n    return atomic_read(&ctx->notified);\n\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":239822,"func":"void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) {\n  if (!owned_by_render_frame_host_) {\n    Destroy(true);\n  } else {\n    RendererExited(static_cast<base::TerminationStatus>(status), exit_code);\n  }\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":479557,"func":"      static cimg_int64 cut(const double val) {\n        return val<(double)min()?min():val>(double)max()?max():(cimg_int64)val;\n      }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":474807,"func":"static void __sock_set_timestamps(struct sock *sk, bool val, bool new, bool ns)\n{\n\tif (val)  {\n\t\tsock_valbool_flag(sk, SOCK_TSTAMP_NEW, new);\n\t\tsock_valbool_flag(sk, SOCK_RCVTSTAMPNS, ns);\n\t\tsock_set_flag(sk, SOCK_RCVTSTAMP);\n\t\tsock_enable_timestamp(sk, SOCK_TIMESTAMP);\n\t} else {\n\t\tsock_reset_flag(sk, SOCK_RCVTSTAMP);\n\t\tsock_reset_flag(sk, SOCK_RCVTSTAMPNS);\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":482534,"func":"  static void sqlite3WhereOpcodeRewriteTrace(\n    sqlite3 *db,\n    int pc,\n    VdbeOp *pOp\n  ){\n    if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;\n    sqlite3VdbePrintOp(0, pc, pOp);\n  }","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":271129,"func":"static void do_pcd_read(void)\n{\n\tpcd_busy = 1;\n\tpcd_retries = 0;\n\tpcd_transfer();\n\tif (!pcd_count) {\n\t\tnext_request(0);\n\t\treturn;\n\t}\n\n\tpi_do_claimed(pcd_current->pi, pcd_start);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":38806,"func":"Error Box::read_children(BitstreamRange& range, int max_number)\n{\n  int count = 0;\n\n  while (!range.eof() && !range.error()) {\n    std::shared_ptr<Box> box;\n    Error error = Box::read(range, &box);\n    if (error != Error::Ok) {\n      return error;\n    }\n\n    if (m_children.size() > MAX_CHILDREN_PER_BOX) {\n      std::stringstream sstr;\n      sstr << \"Maximum number of child boxes \" << MAX_CHILDREN_PER_BOX << \" exceeded.\";\n\n      \/\/ Sanity check.\n      return Error(heif_error_Memory_allocation_error,\n                   heif_suberror_Security_limit_exceeded,\n                   sstr.str());\n    }\n\n    m_children.push_back(std::move(box));\n\n\n    \/\/ count the new child and end reading new children when we reached the expected number\n\n    count++;\n\n    if (max_number != READ_CHILDREN_ALL &&\n        count == max_number) {\n      break;\n    }\n  }\n\n  return range.get_error();\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":272487,"func":"PHP_FUNCTION(imagecopymerge)\n{\n\tzval *SIM, *DIM;\n\tlong SX, SY, SW, SH, DX, DY, PCT;\n\tgdImagePtr im_dst, im_src;\n\tint srcH, srcW, srcY, srcX, dstY, dstX, pct;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rrlllllll\", &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im_src, gdImagePtr, &SIM, -1, \"Image\", le_gd);\n\tZEND_FETCH_RESOURCE(im_dst, gdImagePtr, &DIM, -1, \"Image\", le_gd);\n\n\tsrcX = SX;\n\tsrcY = SY;\n\tsrcH = SH;\n\tsrcW = SW;\n\tdstX = DX;\n\tdstY = DY;\n\tpct  = PCT;\n\n\tgdImageCopyMerge(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH, pct);\n\tRETURN_TRUE;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":356735,"func":"static jas_cmreal_t jas_cmshapmatlut_lookup(jas_cmshapmatlut_t *lut, jas_cmreal_t x)\n{\n\tjas_cmreal_t t;\n\tint lo;\n\tint hi;\n\tt = x * (lut->size - 1);\n\tlo = floor(t);\n\tif (lo < 0)\n\t\treturn lut->data[0];\n\thi = ceil(t);\n\tif (hi >= lut->size)\n\t\treturn lut->data[lut->size - 1];\n\treturn lut->data[lo] + (t - lo) * (lut->data[hi] - lut->data[lo]);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":385092,"func":"htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,\n                  const char *URL, const char *encoding, int options)\n{\n    xmlParserInputBufferPtr input;\n    xmlParserInputPtr stream;\n\n    if (ctxt == NULL)\n        return (NULL);\n    if (buffer == NULL)\n        return (NULL);\n    xmlInitParser();\n\n    htmlCtxtReset(ctxt);\n\n    input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);\n    if (input == NULL) {\n\treturn(NULL);\n    }\n\n    stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);\n    if (stream == NULL) {\n\txmlFreeParserInputBuffer(input);\n\treturn(NULL);\n    }\n\n    inputPush(ctxt, stream);\n    return (htmlDoRead(ctxt, URL, encoding, options, 1));\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":194448,"func":"void V4L2JpegEncodeAccelerator::EncodedInstanceDmaBuf::DestroyTask() {\n  DCHECK(parent_->encoder_task_runner_->BelongsToCurrentThread());\n  while (!input_job_queue_.empty())\n    input_job_queue_.pop();\n  while (!running_job_queue_.empty())\n    running_job_queue_.pop();\n\n  DestroyInputBuffers();\n  DestroyOutputBuffers();\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":454327,"func":"TEST(GetComputedPathsTest, ExpressionFieldPathDoesNotCountAsRenameWhenUsingRemoveBuiltin) {\n    intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());\n    auto expr = ExpressionFieldPath::parse(expCtx, \"$$REMOVE\", expCtx->variablesParseState);\n    auto computedPaths = expr->getComputedPaths(\"a\", Variables::kRootId);\n    ASSERT_EQ(computedPaths.paths.size(), 1u);\n    ASSERT_EQ(computedPaths.paths.count(\"a\"), 1u);\n    ASSERT(computedPaths.renames.empty());\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":218892,"func":"ScriptPromise BluetoothRemoteGATTCharacteristic::getDescriptors(\n    ScriptState* scriptState,\n    const StringOrUnsignedLong& descriptorUUID,\n    ExceptionState& exceptionState) {\n  String descriptor =\n      BluetoothUUID::getDescriptor(descriptorUUID, exceptionState);\n  if (exceptionState.hadException())\n    return exceptionState.reject(scriptState);\n\n  return getDescriptorsImpl(\n      scriptState, mojom::blink::WebBluetoothGATTQueryQuantity::MULTIPLE,\n      descriptor);\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":375070,"func":"_equalFieldStore(const FieldStore *a, const FieldStore *b)\n{\n\tCOMPARE_NODE_FIELD(arg);\n\tCOMPARE_NODE_FIELD(newvals);\n\tCOMPARE_NODE_FIELD(fieldnums);\n\tCOMPARE_SCALAR_FIELD(resulttype);\n\n\treturn true;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":291097,"func":"ptaaInitFull(PTAA  *ptaa,\n             PTA   *pta)\n{\nl_int32  n, i;\nPTA     *ptat;\n\n    PROCNAME(\"ptaaInitFull\");\n\n    if (!ptaa)\n        return ERROR_INT(\"ptaa not defined\", procName, 1);\n    if (!pta)\n        return ERROR_INT(\"pta not defined\", procName, 1);\n\n    n = ptaa->nalloc;\n    ptaa->n = n;\n    for (i = 0; i < n; i++) {\n        ptat = ptaCopy(pta);\n        ptaaReplacePta(ptaa, i, ptat);\n    }\n    return 0;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":107119,"func":"static inline bool nested_vmx_allowed(struct kvm_vcpu *vcpu)\n{\n\treturn nested && guest_cpuid_has(vcpu, X86_FEATURE_VMX);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":114663,"func":"static void sas_ata_set_dmamode(struct ata_port *ap, struct ata_device *ata_dev)\n{\n\tstruct domain_device *dev = ap->private_data;\n\tstruct sas_internal *i = dev_to_sas_internal(dev);\n\n\tif (i->dft->lldd_ata_set_dmamode)\n\t\ti->dft->lldd_ata_set_dmamode(dev);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":226618,"func":"void CalculatePageLayoutFromPrintParams(\n    const PrintMsg_Print_Params& params,\n    PageSizeMargins* page_layout_in_points) {\n  int dpi = GetDPI(¶ms);\n  int content_width = params.content_size.width();\n  int content_height = params.content_size.height();\n\n  int margin_bottom =\n      params.page_size.height() - content_height - params.margin_top;\n  int margin_right =\n      params.page_size.width() - content_width - params.margin_left;\n\n  page_layout_in_points->content_width =\n      ConvertUnit(content_width, dpi, kPointsPerInch);\n  page_layout_in_points->content_height =\n      ConvertUnit(content_height, dpi, kPointsPerInch);\n  page_layout_in_points->margin_top =\n      ConvertUnit(params.margin_top, dpi, kPointsPerInch);\n  page_layout_in_points->margin_right =\n      ConvertUnit(margin_right, dpi, kPointsPerInch);\n  page_layout_in_points->margin_bottom =\n      ConvertUnit(margin_bottom, dpi, kPointsPerInch);\n  page_layout_in_points->margin_left =\n      ConvertUnit(params.margin_left, dpi, kPointsPerInch);\n}\n","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":160597,"func":"IRC_PROTOCOL_CALLBACK(303)\n{\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        _(\"%sUsers online: %s%s\"),\n        weechat_prefix (\"network\"),\n        IRC_COLOR_CHAT_NICK,\n        (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":253370,"func":"  std::wstring GetUsageStatsKeyPath(bool medium) {\n    EXPECT_TRUE(!medium || system_level_);\n\n    std::wstring result(L\"Software\\\\\");\n    if (kUseGoogleUpdateIntegration) {\n      result.append(L\"Google\\\\Update\\\\ClientState\");\n      if (medium)\n        result.append(L\"Medium\");\n      result.push_back(L'\\\\');\n      result.append(mode_->app_guid);\n    } else {\n      result.append(kProductPathName);\n    }\n    return result;\n  }\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":302565,"func":"R_API const char *r_anal_function_get_var_reg_at(RAnalFunction *fcn, st64 delta, ut64 addr) {\n\tst64 offset = addr - fcn->addr;\n\tRPVector *inst_accesses = ht_up_find (fcn->inst_vars, offset, NULL);\n\tif (!inst_accesses) {\n\t\treturn NULL;\n\t}\n\tRAnalVar *var = NULL;\n\tvoid **it;\n\tr_pvector_foreach (inst_accesses, it) {\n\t\tRAnalVar *v = *it;\n\t\tif (v->delta == delta) {\n\t\t\tvar = v;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!var) {\n\t\treturn NULL;\n\t}\n\tsize_t index;\n\tr_vector_lower_bound (&var->accesses, offset, index, ACCESS_CMP);\n\tRAnalVarAccess *acc = NULL;\n\tif (index < var->accesses.len) {\n\t\tacc = r_vector_index_ptr (&var->accesses, index);\n\t}\n\tif (!acc || acc->offset != offset) {\n\t\treturn NULL;\n\t}\n\treturn acc->reg;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":460392,"func":"struct hid_field *hidinput_get_led_field(struct hid_device *hid)\n{\n\tstruct hid_report *report;\n\tstruct hid_field *field;\n\tint i, j;\n\n\tlist_for_each_entry(report,\n\t\t\t    &hid->report_enum[HID_OUTPUT_REPORT].report_list,\n\t\t\t    list) {\n\t\tfor (i = 0; i < report->maxfield; i++) {\n\t\t\tfield = report->field[i];\n\t\t\tfor (j = 0; j < field->maxusage; j++)\n\t\t\t\tif (field->usage[j].type == EV_LED)\n\t\t\t\t\treturn field;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":410880,"func":"static THEME_SEARCH_REC *theme_search(GSList *list, const char *module)\n{\n\tTHEME_SEARCH_REC *rec;\n\n\twhile (list != NULL) {\n\t\trec = list->data;\n\n\t\tif (g_strcasecmp(rec->short_name, module) == 0)\n\t\t\treturn rec;\n\t\tlist = list->next;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":316220,"func":"void ChromotingInstance::SendClipboardItem(const std::string& mime_type,\n                                           const std::string& item) {\n  if (!IsConnected()) {\n    return;\n  }\n  protocol::ClipboardEvent event;\n  event.set_mime_type(mime_type);\n  event.set_data(item);\n  host_connection_->clipboard_stub()->InjectClipboardEvent(event);\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":487541,"func":"ElectronBrowserClient::GetGeneratedCodeCacheSettings(\n    content::BrowserContext* context) {\n  \/\/ TODO(deepak1556): Use platform cache directory.\n  base::FilePath cache_path = context->GetPath();\n  \/\/ If we pass 0 for size, disk_cache will pick a default size using the\n  \/\/ heuristics based on available disk size. These are implemented in\n  \/\/ disk_cache::PreferredCacheSize in net\/disk_cache\/cache_util.cc.\n  return content::GeneratedCodeCacheSettings(true, 0, cache_path);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":283631,"func":"void V8TestObject::ActivityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeSetterCallbackForMainWorld(\n    const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_activityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttribute_Setter\");\n\n  v8::Local<v8::Value> v8_value = info[0];\n\n  test_object_v8_internal::ActivityLoggingAccessForIsolatedWorldsPerWorldBindingsLongAttributeAttributeSetterForMainWorld(v8_value, info);\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":160254,"func":"ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj)\n{\n\tMONO_ARCH_SAVE_REGS;\n\n\tif ((obj == NULL) || (! (obj->vtable->klass->valuetype)))\n\t\treturn obj;\n\telse\n\t\treturn mono_object_clone (obj);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":149184,"func":"multi_client_connect_post_plugin(struct multi_context *m,\n                                 struct multi_instance *mi,\n                                 const struct plugin_return *pr,\n                                 unsigned int option_permissions_mask,\n                                 unsigned int *option_types_found)\n{\n    struct plugin_return config;\n\n    plugin_return_get_column(pr, &config, \"config\");\n\n    \/* Did script generate a dynamic config file? *\/\n    if (plugin_return_defined(&config))\n    {\n        int i;\n        for (i = 0; i < config.n; ++i)\n        {\n            if (config.list[i] && config.list[i]->value)\n            {\n                options_string_import(&mi->context.options,\n                                      config.list[i]->value,\n                                      D_IMPORT_ERRORS|M_OPTERR,\n                                      option_permissions_mask,\n                                      option_types_found,\n                                      mi->context.c2.es);\n            }\n        }\n\n        \/*\n         * If the --client-connect script generates a config file\n         * with an --ifconfig-push directive, it will override any\n         * --ifconfig-push directive from the --client-config-dir\n         * directory or any --ifconfig-pool dynamic address.\n         *\/\n        multi_select_virtual_addr(m, mi);\n        multi_set_virtual_addr_env(mi);\n    }\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":401270,"func":"static int copy_tx_sa_stats(struct sk_buff *skb,\n\t\t\t     struct macsec_tx_sa_stats __percpu *pstats)\n{\n\tstruct macsec_tx_sa_stats sum = {0, };\n\tint cpu;\n\n\tfor_each_possible_cpu(cpu) {\n\t\tconst struct macsec_tx_sa_stats *stats = per_cpu_ptr(pstats, cpu);\n\n\t\tsum.OutPktsProtected += stats->OutPktsProtected;\n\t\tsum.OutPktsEncrypted += stats->OutPktsEncrypted;\n\t}\n\n\tif (nla_put_u32(skb, MACSEC_SA_STATS_ATTR_OUT_PKTS_PROTECTED, sum.OutPktsProtected) ||\n\t    nla_put_u32(skb, MACSEC_SA_STATS_ATTR_OUT_PKTS_ENCRYPTED, sum.OutPktsEncrypted))\n\t\treturn -EMSGSIZE;\n\n\treturn 0;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":512247,"func":"void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag)\n{\n    group->asn1_flag &= ~EC_GROUP_ASN1_FLAG_MASK;\n    group->asn1_flag |= flag & EC_GROUP_ASN1_FLAG_MASK;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":33125,"func":"static inline int iskeychar(int c)\n{\n\treturn isalnum(c) || c == '-';\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":496140,"func":"        ~Connection()\n        {\n            res.complete_request_handler_ = nullptr;\n            cancel_deadline_timer();\n#ifdef CROW_ENABLE_DEBUG\n            connectionCount--;\n            CROW_LOG_DEBUG << \"Connection (\" << this << \") freed, total: \" << connectionCount;\n#endif\n        }","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":16445,"func":"static void close_detect_cb ( struct evhttp_request * req , void * arg ) {\n struct evhttp_connection * evcon = arg ;\n struct timeval tv ;\n if ( req != NULL && req -> response_code != HTTP_OK ) {\n fprintf ( stderr , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n timerclear ( & tv ) ;\n tv . tv_sec = 3 ;\n event_once ( - 1 , EV_TIMEOUT , close_detect_launch , evcon , & tv ) ;\n }","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":386968,"func":"static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)\n{\n\tstruct usb_usbvision *usbvision = video_drvdata(file);\n\tint res;\n\n\tif (mutex_lock_interruptible(&usbvision->v4l2_lock))\n\t\treturn -ERESTARTSYS;\n\tres = usbvision_mmap(file, vma);\n\tmutex_unlock(&usbvision->v4l2_lock);\n\treturn res;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":514692,"func":"v8::Local<v8::Object> StreamReq::object() {\n  return GetAsyncWrap()->object();\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":223621,"func":"static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb,\n\t\t\t\t  u32 key)\n{\n\tstruct list_head *pos;\n\n\tassert_spin_locked(&ctx->ctx_lock);\n\n\t\/* TODO: use a hash or array, this sucks. *\/\n\tlist_for_each(pos, &ctx->active_reqs) {\n\t\tstruct kiocb *kiocb = list_kiocb(pos);\n\t\tif (kiocb->ki_obj.user == iocb && kiocb->ki_key == key)\n\t\t\treturn kiocb;\n\t}\n\treturn NULL;\n}\n","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":397535,"func":"static void csrhci_out_hci_packet_acl(void *opaque,\n                const uint8_t *data, int len)\n{\n    struct csrhci_s *s = (struct csrhci_s *) opaque;\n    uint8_t *pkt = csrhci_out_packet(s, (len + 2) & ~1);\t\/* Align *\/\n\n    *pkt ++ = H4_ACL_PKT;\n    pkt[len & ~1] = 0;\n    memcpy(pkt, data, len);\n\n    csrhci_fifo_wake(s);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":510693,"func":"ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share,\n                           partition_info *part_info_arg,\n                           ha_partition *clone_arg,\n                           MEM_ROOT *clone_mem_root_arg)\n  :handler(hton, share)\n{\n  DBUG_ENTER(\"ha_partition::ha_partition(clone)\");\n  init_alloc_root(&m_mem_root, 512, 512);\n  init_handler_variables();\n  m_part_info= part_info_arg;\n  m_create_handler= TRUE;\n  m_is_sub_partitioned= m_part_info->is_sub_partitioned();\n  m_is_clone_of= clone_arg;\n  m_clone_mem_root= clone_mem_root_arg;\n  m_pkey_is_clustered= clone_arg->primary_key_is_clustered(); \n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":235328,"func":"static void createAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n{\n    INC_STATS(\"DOM.TestObj.create._set\");\n    TestObj* imp = V8TestObj::toNative(info.Holder());\n    bool v = value->BooleanValue();\n    imp->setCreate(v);\n    return;\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":363260,"func":"_hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,\n\t\t\t\t  hb_codepoint_t  glyph,\n\t\t\t\t  unsigned int    property)\n{\n  hb_ot_layout_glyph_class_t klass;\n\n  if (property & LookupFlag::MarkAttachmentType)\n    klass = HB_OT_LAYOUT_GLYPH_CLASS_MARK;\n  else\n    klass = (hb_ot_layout_glyph_class_t) property;\n\n  hb_ot_layout_set_glyph_class (layout, glyph, klass);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":219383,"func":"  void DidGetUsageAndQuotaForEviction(QuotaStatusCode status,\n      int64 usage, int64 unlimited_usage, int64 quota, int64 available_space) {\n    quota_status_ = status;\n    usage_ = usage;\n    unlimited_usage_ = unlimited_usage;\n    quota_ = quota;\n    available_space_ = available_space;\n  }\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":60155,"func":"static codel_time_t codel_skb_time_func(const struct sk_buff *skb)\n{\n\tconst struct ieee80211_tx_info *info;\n\n\tinfo = (const struct ieee80211_tx_info *)skb->cb;\n\treturn info->control.enqueue_time;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":81928,"func":"flatpak_repo_parse_extra_data_sources (GVariant      *extra_data_sources,\n                                       int            index,\n                                       const char   **name,\n                                       guint64       *download_size,\n                                       guint64       *installed_size,\n                                       const guchar **sha256,\n                                       const char   **uri)\n{\n  g_autoptr(GVariant) sha256_v = NULL;\n  g_variant_get_child (extra_data_sources, index, \"(^aytt@ay&s)\",\n                       name,\n                       download_size,\n                       installed_size,\n                       &sha256_v,\n                       uri);\n\n  if (download_size)\n    *download_size = GUINT64_FROM_BE (*download_size);\n\n  if (installed_size)\n    *installed_size = GUINT64_FROM_BE (*installed_size);\n\n  if (sha256)\n    *sha256 = ostree_checksum_bytes_peek (sha256_v);\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":460091,"func":"proto_find_first_finfo(proto_tree *tree, const int id)\n{\n\tffdata_t ffdata;\n\n\tffdata.array = g_ptr_array_new();\n\tffdata.id = id;\n\n\tproto_tree_traverse_pre_order(tree, find_first_finfo, &ffdata);\n\n\treturn ffdata.array;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":83214,"func":"static int cmp_memslot(const void *slot1, const void *slot2)\n{\n\tstruct kvm_memory_slot *s1, *s2;\n\n\ts1 = (struct kvm_memory_slot *)slot1;\n\ts2 = (struct kvm_memory_slot *)slot2;\n\n\tif (s1->npages < s2->npages)\n\t\treturn 1;\n\tif (s1->npages > s2->npages)\n\t\treturn -1;\n\n\treturn 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":216020,"func":"  HeadlessDevToolsClientMinimizeWindowTest()\n      : HeadlessDevToolsClientChangeWindowStateTest(\n            browser::WindowState::MINIMIZED){};\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":32298,"func":"static void ffprobe_show_program_version(WriterContext *w)\n{\n    AVBPrint pbuf;\n    av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);\n\n    writer_print_section_header(w, SECTION_ID_PROGRAM_VERSION);\n    print_str(\"version\", FFMPEG_VERSION);\n    print_fmt(\"copyright\", \"Copyright (c) %d-%d the FFmpeg developers\",\n              program_birth_year, CONFIG_THIS_YEAR);\n    print_str(\"compiler_ident\", CC_IDENT);\n    print_str(\"configuration\", FFMPEG_CONFIGURATION);\n    writer_print_section_footer(w);\n\n    av_bprint_finalize(&pbuf, NULL);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":144553,"func":"static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)\n{\n\tgdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;\n\tUINT32 width = bitmap->right - bitmap->left + 1;\n\tUINT32 height = bitmap->bottom - bitmap->top + 1;\n\treturn gdi_BitBlt(context->gdi->primary->hdc,\n\t                  bitmap->left, bitmap->top,\n\t                  width, height, gdi_bitmap->hdc,\n\t                  0, 0, GDI_SRCCOPY, &context->gdi->palette);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":486929,"func":"symbol_make_alias (symbol *sym, symbol *str, location loc)\n{\n  if (sym->content->class != token_sym)\n    complain (&loc, complaint,\n              _(\"nonterminals cannot be given a string alias\"));\n  else if (str->alias)\n    complain (&loc, Wother,\n              _(\"symbol %s used more than once as a literal string\"), str->tag);\n  else if (sym->alias)\n    complain (&loc, Wother,\n              _(\"symbol %s given more than one literal string\"), sym->tag);\n  else\n    {\n      symbol_merge_properties (sym, str);\n      sym_content_free (str->content);\n      str->content = sym->content;\n      str->content->symbol = str;\n      str->is_alias = true;\n      str->alias = sym;\n      sym->alias = str;\n    }\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":7862,"func":"ast_for_decorator(struct compiling *c, const node *n)\n{\n    \/* decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE *\/\n    expr_ty d = NULL;\n    expr_ty name_expr;\n\n    REQ(n, decorator);\n    REQ(CHILD(n, 0), AT);\n    REQ(RCHILD(n, -1), NEWLINE);\n\n    name_expr = ast_for_dotted_name(c, CHILD(n, 1));\n    if (!name_expr)\n        return NULL;\n\n    if (NCH(n) == 3) { \/* No arguments *\/\n        d = name_expr;\n        name_expr = NULL;\n    }\n    else if (NCH(n) == 5) { \/* Call with no arguments *\/\n        d = Call(name_expr, NULL, NULL, LINENO(n),\n                 n->n_col_offset, c->c_arena);\n        if (!d)\n            return NULL;\n        name_expr = NULL;\n    }\n    else {\n        d = ast_for_call(c, CHILD(n, 3), name_expr);\n        if (!d)\n            return NULL;\n        name_expr = NULL;\n    }\n\n    return d;\n}","target":1,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":287845,"func":"void CrosLibrary::TestApi::SetMountLibrary(\n    MountLibrary* library, bool own) {\n  library_->mount_lib_.SetImpl(library, own);\n}\n","target":1,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":256790,"func":"static int read_intra_segment_id ( VP9_COMMON * const cm , MACROBLOCKD * const xd , int mi_row , int mi_col , vp9_reader * r ) {\n struct segmentation * const seg = & cm -> seg ;\n const BLOCK_SIZE bsize = xd -> mi [ 0 ] . src_mi -> mbmi . sb_type ;\n int segment_id ;\n if ( ! seg -> enabled ) return 0 ;\n if ( ! seg -> update_map ) return 0 ;\n segment_id = read_segment_id ( r , seg ) ;\n set_segment_id ( cm , bsize , mi_row , mi_col , segment_id ) ;\n return segment_id ;\n }","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":102712,"func":"sixel_output_t *sixel_output_create(Image *image)\n{\n    sixel_output_t *output;\n\n    output = (sixel_output_t *) AcquireQuantumMemory(sizeof(sixel_output_t) + SIXEL_OUTPUT_PACKET_SIZE * 2, 1);\n    output->has_8bit_control = 0;\n    output->save_pixel = 0;\n    output->save_count = 0;\n    output->active_palette = (-1);\n    output->node_top = NULL;\n    output->node_free = NULL;\n    output->image = image;\n    output->pos = 0;\n\n    return output;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":451198,"func":"  uint64_t byteSize() const override { return HeaderMapImpl::byteSize(); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":41411,"func":"static void vht_build_mcs_mask(u16 vht_mcs_map,\n\t\t\t       u16 vht_mcs_mask[NL80211_VHT_NSS_MAX])\n{\n\tu8 nss;\n\n\tfor (nss = 0; nss < NL80211_VHT_NSS_MAX; nss++) {\n\t\tvht_mcs_mask[nss] = vht_mcs_map_to_mcs_mask(vht_mcs_map & 0x03);\n\t\tvht_mcs_map >>= 2;\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":416903,"func":"static int rtnetlink_bind(struct net *net, int group)\n{\n\tswitch (group) {\n\tcase RTNLGRP_IPV4_MROUTE_R:\n\tcase RTNLGRP_IPV6_MROUTE_R:\n\t\tif (!ns_capable(net->user_ns, CAP_NET_ADMIN))\n\t\t\treturn -EPERM;\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":512097,"func":"sh_single_quote (string)\n     const char *string;\n{\n  register int c;\n  char *result, *r;\n  const char *s;\n\n  result = (char *)xmalloc (3 + (4 * strlen (string)));\n  r = result;\n  *r++ = '\\'';\n\n  for (s = string; s && (c = *s); s++)\n    {\n      *r++ = c;\n\n      if (c == '\\'')\n\t{\n\t  *r++ = '\\\\';\t\/* insert escaped single quote *\/\n\t  *r++ = '\\'';\n\t  *r++ = '\\'';\t\/* start new quoted string *\/\n\t}\n    }\n\n  *r++ = '\\'';\n  *r = '\\0';\n\n  return (result);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":325252,"func":"static int lance_init(SysBusDevice *dev)\n\n{\n\n    SysBusPCNetState *d = FROM_SYSBUS(SysBusPCNetState, dev);\n\n    PCNetState *s = &d->state;\n\n\n\n    memory_region_init_io(&s->mmio, &lance_mem_ops, s, \"lance-mmio\", 4);\n\n\n\n    qdev_init_gpio_in(&dev->qdev, parent_lance_reset, 1);\n\n\n\n    sysbus_init_mmio_region(dev, &s->mmio);\n\n\n\n    sysbus_init_irq(dev, &s->irq);\n\n\n\n    s->phys_mem_read = ledma_memory_read;\n\n    s->phys_mem_write = ledma_memory_write;\n\n    return pcnet_common_init(&dev->qdev, s, &net_lance_info);\n\n}\n","target":1,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":18529,"func":"const char * trunc_right ( const char * src , size_t width ) {\n size_t sl ;\n char * out ;\n sl = strlen ( src ) ;\n if ( sl > width && LIB_BUFLENGTH - 1 > width && width > 0 ) {\n LIB_GETBUF ( out ) ;\n memcpy ( out , src , width ) ;\n out [ width ] = '\\0' ;\n return out ;\n }\n return src ;\n }","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":93309,"func":"verbose_stop(void)\n{\n    if (verbose_fd != NULL)\n    {\n\tfclose(verbose_fd);\n\tverbose_fd = NULL;\n    }\n    verbose_did_open = FALSE;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":401303,"func":"cr_input_peek_char (CRInput const * a_this, guint32 * a_char)\n{\n        enum CRStatus status = CR_OK;\n        gulong consumed = 0,\n                nb_bytes_left = 0;\n\n        g_return_val_if_fail (a_this && PRIVATE (a_this)\n                              && a_char, CR_BAD_PARAM_ERROR);\n\n        if (PRIVATE (a_this)->next_byte_index >=\n            PRIVATE (a_this)->in_buf_size) {\n                return CR_END_OF_INPUT_ERROR;\n        }\n\n        nb_bytes_left = cr_input_get_nb_bytes_left (a_this);\n\n        if (nb_bytes_left < 1) {\n                return CR_END_OF_INPUT_ERROR;\n        }\n\n        status = cr_utils_read_char_from_utf8_buf\n                (PRIVATE (a_this)->in_buf +\n                 PRIVATE (a_this)->next_byte_index,\n                 nb_bytes_left, a_char, &consumed);\n\n        return status;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":332120,"func":"static void shpc_set_status(SHPCDevice *shpc,\n\n                            int slot, uint8_t value, uint16_t msk)\n\n{\n\n    uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot);\n\n    pci_word_test_and_clear_mask(status, msk);\n\n    pci_word_test_and_set_mask(status, value << (ffs(msk) - 1));\n\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":53276,"func":"static inline unsigned long tcp_probe0_when(const struct sock *sk,\n\t\t\t\t\t    unsigned long max_when)\n{\n\tu64 when = (u64)tcp_probe0_base(sk) << inet_csk(sk)->icsk_backoff;\n\n\treturn (unsigned long)min_t(u64, when, max_when);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":149588,"func":"static int network_config_set_interface (const oconfig_item_t *ci, \/* {{{ *\/\n    int *interface)\n{\n  if ((ci->values_num != 1)\n      || (ci->values[0].type != OCONFIG_TYPE_STRING))\n  {\n    WARNING (\"network plugin: The `Interface' config option needs exactly \"\n        \"one string argument.\");\n    return (-1);\n  }\n\n  if (interface == NULL)\n    return (-1);\n\n  *interface = if_nametoindex (ci->values[0].value.string);\n\n  return (0);\n} \/* }}} int network_config_set_interface *\/","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":165634,"func":"ofputil_encode_tlv_table_reply(const struct ofp_header *oh,\n                                  struct ofputil_tlv_table_reply *ttr)\n{\n    struct ofpbuf *b;\n    struct nx_tlv_table_reply *nx_ttr;\n\n    b = ofpraw_alloc_reply(OFPRAW_NXT_TLV_TABLE_REPLY, oh, 0);\n    nx_ttr = ofpbuf_put_zeros(b, sizeof *nx_ttr);\n    nx_ttr->max_option_space = htonl(ttr->max_option_space);\n    nx_ttr->max_fields = htons(ttr->max_fields);\n\n    encode_tlv_table_mappings(b, &ttr->mappings);\n\n    return b;\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":66951,"func":"static void pf_req_sense(struct pf_unit *pf, int quiet)\n{\n\tchar rs_cmd[12] =\n\t    { ATAPI_REQ_SENSE, pf->lun << 5, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0 };\n\tchar buf[16];\n\tint r;\n\n\tr = pf_command(pf, rs_cmd, 16, \"Request sense\");\n\tmdelay(1);\n\tif (!r)\n\t\tpf_completion(pf, buf, \"Request sense\");\n\n\tif ((!r) && (!quiet))\n\t\tprintk(\"%s: Sense key: %x, ASC: %x, ASQ: %x\\n\",\n\t\t       pf->name, buf[2] & 0xf, buf[12], buf[13]);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":39329,"func":"parse_string(struct xkb_compose_table *table, const char *string, size_t len,\n             const char *file_name)\n{\n    struct scanner s;\n    scanner_init(&s, table->ctx, string, len, file_name, NULL);\n    if (!parse(table, &s, 0))\n        return false;\n    \/* Maybe the allocator can use the excess space. *\/\n    darray_shrink(table->nodes);\n    darray_shrink(table->utf8);\n    return true;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":90235,"func":"R_API void r_bin_java_bootstrap_method_argument_free(void \/*RBinJavaBootStrapArgument*\/ *b) {\n\tRBinJavaBootStrapArgument *bsm_arg = b;\n\tif (bsm_arg) {\n\t\tRBinJavaCPTypeMetas *tm = (RBinJavaCPTypeMetas*)bsm_arg->argument_info_cp_obj;\n\t\tif (tm) {\n\t\t\tif (tm && (size_t)(tm->allocs) > 1024 && tm->allocs->delete_obj) {\n\t\t\t\ttm->allocs->delete_obj (tm);\n\t\t\t}\n\t\t\tbsm_arg->argument_info_cp_obj = NULL;\n\t\t}\n\t\tfree (bsm_arg);\n\t}\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":372443,"func":"cmsHPROFILE CMSEXPORT cmsOpenProfileFromIOhandlerTHR(cmsContext ContextID, cmsIOHANDLER* io)\n{\n    _cmsICCPROFILE* NewIcc;\n    cmsHPROFILE hEmpty = cmsCreateProfilePlaceholder(ContextID);\n\n    if (hEmpty == NULL) return NULL;\n\n    NewIcc = (_cmsICCPROFILE*) hEmpty;\n\n    NewIcc ->IOhandler = io;\n    if (!_cmsReadHeader(NewIcc)) goto Error;\n    return hEmpty;\n\nError:\n    cmsCloseProfile(hEmpty);\n    return NULL;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":106032,"func":"static size_t encode_block(char *str, char *buf, size_t buflen, const char *fromcode,\n                           const char *tocode, encoder_t encoder)\n{\n  if (!fromcode)\n  {\n    return (*encoder)(str, buf, buflen, tocode);\n  }\n\n  const iconv_t cd = mutt_ch_iconv_open(tocode, fromcode, 0);\n  assert(cd != (iconv_t)(-1));\n  const char *ib = buf;\n  size_t ibl = buflen;\n  char tmp[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];\n  char *ob = tmp;\n  size_t obl = sizeof(tmp) - strlen(tocode);\n  const size_t n1 = iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);\n  const size_t n2 = iconv(cd, NULL, NULL, &ob, &obl);\n  assert(n1 != (size_t)(-1) && n2 != (size_t)(-1));\n  iconv_close(cd);\n  return (*encoder)(str, tmp, ob - tmp, tocode);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":265213,"func":"R_API bool r_socket_is_connected (RSocket *s) {\n\treturn false;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":523770,"func":"int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return (0);\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    bn_check_top(a);\n    return (1);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":249442,"func":"void RenderFrameImpl::willRequestAfterPreconnect(\n    blink::WebLocalFrame* frame,\n    blink::WebURLRequest& request) {\n  DCHECK(!frame_ || frame_ == frame);\n  WebString custom_user_agent;\n\n  DCHECK(!request.extraData());\n\n  bool was_after_preconnect_request = true;\n  RequestExtraData* extra_data = new RequestExtraData();\n  extra_data->set_custom_user_agent(custom_user_agent);\n  extra_data->set_was_after_preconnect_request(was_after_preconnect_request);\n  request.setExtraData(extra_data);\n}\n","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":244151,"func":"char* menu_cache_item_get_file_path( MenuCacheItem* item )\n{\n    if( ! item->file_name || ! item->file_dir )\n        return NULL;\n    return g_build_filename( item->file_dir->dir + 1, item->file_name, NULL );\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":399501,"func":"void hrtimer_run_queues(void)\n{\n\tstruct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);\n\tktime_t now;\n\n\tif (__hrtimer_hres_active(cpu_base))\n\t\treturn;\n\n\t\/*\n\t * This _is_ ugly: We have to check periodically, whether we\n\t * can switch to highres and \/ or nohz mode. The clocksource\n\t * switch happens with xtime_lock held. Notification from\n\t * there only sets the check bit in the tick_oneshot code,\n\t * otherwise we might deadlock vs. xtime_lock.\n\t *\/\n\tif (tick_check_oneshot_change(!hrtimer_is_hres_enabled())) {\n\t\thrtimer_switch_to_hres();\n\t\treturn;\n\t}\n\n\traw_spin_lock(&cpu_base->lock);\n\tnow = hrtimer_update_base(cpu_base);\n\t__hrtimer_run_queues(cpu_base, now);\n\traw_spin_unlock(&cpu_base->lock);\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":482104,"func":"static int xennet_xdp(struct net_device *dev, struct netdev_bpf *xdp)\n{\n\tstruct netfront_info *np = netdev_priv(dev);\n\n\tif (np->broken)\n\t\treturn -ENODEV;\n\n\tswitch (xdp->command) {\n\tcase XDP_SETUP_PROG:\n\t\treturn xennet_xdp_set(dev, xdp->prog, xdp->extack);\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":444743,"func":"TEST_F(Http1ServerConnectionImplTest, ChunkedBody) {\n  initialize();\n\n  InSequence sequence;\n\n  MockRequestDecoder decoder;\n  EXPECT_CALL(callbacks_, newStream(_, _)).WillOnce(ReturnRef(decoder));\n\n  TestRequestHeaderMapImpl expected_headers{\n      {\":path\", \"\/\"},\n      {\":method\", \"POST\"},\n      {\"transfer-encoding\", \"chunked\"},\n  };\n  EXPECT_CALL(decoder, decodeHeaders_(HeaderMapEqual(&expected_headers), false));\n  Buffer::OwnedImpl expected_data(\"Hello World\");\n  EXPECT_CALL(decoder, decodeData(BufferEqual(&expected_data), false));\n  \/\/ Call to decodeData(\"\", true) happens after.\n  Buffer::OwnedImpl empty(\"\");\n  EXPECT_CALL(decoder, decodeData(BufferEqual(&empty), true));\n\n  Buffer::OwnedImpl buffer(\"POST \/ HTTP\/1.1\\r\\ntransfer-encoding: chunked\\r\\n\\r\\n\"\n                           \"6\\r\\nHello \\r\\n\"\n                           \"5\\r\\nWorld\\r\\n\"\n                           \"0\\r\\n\\r\\n\");\n  auto status = codec_->dispatch(buffer);\n  EXPECT_TRUE(status.ok());\n  EXPECT_EQ(0U, buffer.length());\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":383333,"func":"apdu_shutdown_reader (int slot)\n{\n  int sw;\n\n  if (DBG_READER)\n    log_debug (\"enter: apdu_shutdown_reader: slot=%d\\n\", slot);\n\n  if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )\n    {\n      if (DBG_READER)\n        log_debug (\"leave: apdu_shutdown_reader => SW_HOST_NO_DRIVER\\n\");\n      return SW_HOST_NO_DRIVER;\n    }\n  sw = apdu_disconnect (slot);\n  if (sw)\n    {\n      if (DBG_READER)\n        log_debug (\"leave: apdu_shutdown_reader => 0x%x (apdu_disconnect)\\n\",\n                   sw);\n      return sw;\n    }\n  if (reader_table[slot].shutdown_reader)\n    {\n      sw = reader_table[slot].shutdown_reader (slot);\n      if (DBG_READER)\n        log_debug (\"leave: apdu_shutdown_reader => 0x%x (close_reader)\\n\", sw);\n      return sw;\n    }\n  if (DBG_READER)\n    log_debug (\"leave: apdu_shutdown_reader => SW_HOST_NOT_SUPPORTED\\n\");\n  return SW_HOST_NOT_SUPPORTED;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":273441,"func":"getTiffCompressedFormat(l_uint16  tiffcomp)\n{\nl_int32  comptype;\n\n    switch (tiffcomp)\n    {\n    case COMPRESSION_CCITTFAX4:\n        comptype = IFF_TIFF_G4;\n        break;\n    case COMPRESSION_CCITTFAX3:\n        comptype = IFF_TIFF_G3;\n        break;\n    case COMPRESSION_CCITTRLE:\n        comptype = IFF_TIFF_RLE;\n        break;\n    case COMPRESSION_PACKBITS:\n        comptype = IFF_TIFF_PACKBITS;\n        break;\n    case COMPRESSION_LZW:\n        comptype = IFF_TIFF_LZW;\n        break;\n    case COMPRESSION_ADOBE_DEFLATE:\n        comptype = IFF_TIFF_ZIP;\n        break;\n    case COMPRESSION_JPEG:\n        comptype = IFF_TIFF_JPEG;\n        break;\n    default:\n        comptype = IFF_TIFF;\n        break;\n    }\n    return comptype;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":63733,"func":"static int foreach_comment(void *user, const char *k, const char *v) {\n\tRAnalMetaUserItem *ui = user;\n\tRCore *core = ui->anal->user;\n\tconst char *cmd = ui->user;\n\tif (!strncmp (k, \"meta.C.\", 7)) {\n\t\tchar *cmt = (char *)sdb_decode (v, 0);\n\t\tif (cmt) {\n\t\t\tr_core_cmdf (core, \"s %s\", k + 7);\n\t\t\tr_core_cmd0 (core, cmd);\n\t\t\tfree (cmt);\n\t\t}\n\t}\n\treturn 1;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":104436,"func":"static void TagToFilterModuleName(const char *tag,char *name)\n{\n  assert(tag != (char *) NULL);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",tag);\n  assert(name != (char *) NULL);\n#if defined(MAGICKCORE_WINDOWS_SUPPORT)\n  (void) FormatLocaleString(name,MagickPathExtent,\"FILTER_%s_.dll\",tag);\n#elif !defined(MAGICKCORE_LTDL_DELEGATE)\n  (void) FormatLocaleString(name,MagickPathExtent,\"%s.dll\",tag);\n#else\n  (void) FormatLocaleString(name,MagickPathExtent,\"%s.la\",tag);\n#endif\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":368905,"func":"hook_info_get_hashtable (struct t_weechat_plugin *plugin, const char *info_name,\n                         struct t_hashtable *hashtable)\n{\n    struct t_hook *ptr_hook, *next_hook;\n    struct t_hashtable *value;\n\n    \/* make C compiler happy *\/\n    (void) plugin;\n\n    if (!info_name || !info_name[0])\n        return NULL;\n\n    hook_exec_start ();\n\n    ptr_hook = weechat_hooks[HOOK_TYPE_INFO_HASHTABLE];\n    while (ptr_hook)\n    {\n        next_hook = ptr_hook->next_hook;\n\n        if (!ptr_hook->deleted\n            && !ptr_hook->running\n            && (string_strcasecmp (HOOK_INFO_HASHTABLE(ptr_hook, info_name),\n                                   info_name) == 0))\n        {\n            ptr_hook->running = 1;\n            value = (HOOK_INFO_HASHTABLE(ptr_hook, callback))\n                (ptr_hook->callback_data, info_name, hashtable);\n            ptr_hook->running = 0;\n\n            hook_exec_end ();\n            return value;\n        }\n\n        ptr_hook = next_hook;\n    }\n\n    hook_exec_end ();\n\n    \/* info not found *\/\n    return NULL;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":511173,"func":"array_value (s, quoted, flags, rtype, indp)\n     char *s;\n     int quoted, flags, *rtype;\n     arrayind_t *indp;\n{\n  return (array_value_internal (s, quoted, flags|AV_ALLOWALL, rtype, indp));\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":299457,"func":"unsigned long CjfifDecode::GetPosEmbedEnd()\r\n{\r\n\treturn m_nPosEmbedEnd;\r\n}\r","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":11858,"func":"void ExtensionTtsController::OnSpeechFinished(\n    int request_id, const std::string& error_message) {\n  if (!current_utterance_ || request_id != current_utterance_->id())\n    return;\n  current_utterance_->set_error(error_message);\n  FinishCurrentUtterance();\n  SpeakNextUtterance();\n}\n","target":1,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":393021,"func":"xmlSchemaFormatQName(xmlChar **buf,\n\t\t     const xmlChar *namespaceName,\n\t\t     const xmlChar *localName)\n{\n    FREE_AND_NULL(*buf)\n    if (namespaceName != NULL) {\n\t*buf = xmlStrdup(BAD_CAST \"{\");\n\t*buf = xmlStrcat(*buf, namespaceName);\n\t*buf = xmlStrcat(*buf, BAD_CAST \"}\");\n    }\n    if (localName != NULL) {\n\tif (namespaceName == NULL)\n\t    return(localName);\n\t*buf = xmlStrcat(*buf, localName);\n    } else {\n\t*buf = xmlStrcat(*buf, BAD_CAST \"(NULL)\");\n    }\n    return ((const xmlChar *) *buf);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":224142,"func":"void SoftAMR::onPortEnableCompleted(OMX_U32 portIndex, bool enabled) {\n if (portIndex != 1) {\n return;\n }\n\n switch (mOutputPortSettingsChange) {\n case NONE:\n break;\n\n case AWAITING_DISABLED:\n {\n            CHECK(!enabled);\n            mOutputPortSettingsChange = AWAITING_ENABLED;\n break;\n }\n\n default:\n {\n            CHECK_EQ((int)mOutputPortSettingsChange, (int)AWAITING_ENABLED);\n            CHECK(enabled);\n            mOutputPortSettingsChange = NONE;\n break;\n }\n }\n}\n","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":153221,"func":"static int lock_request(struct fuse_conn *fc, struct fuse_req *req)\n{\n\tint err = 0;\n\tif (req) {\n\t\tspin_lock(&fc->lock);\n\t\tif (req->aborted)\n\t\t\terr = -ENOENT;\n\t\telse\n\t\t\treq->locked = 1;\n\t\tspin_unlock(&fc->lock);\n\t}\n\treturn err;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":125566,"func":"static int tcos_init(sc_card_t *card)\n{\n\tunsigned long flags;\n\n\ttcos_data *data = malloc(sizeof(tcos_data));\n\tif (!data) return SC_ERROR_OUT_OF_MEMORY;\n\n\tcard->name = \"TCOS\";\n\tcard->drv_data = (void *)data;\n\tcard->cla = 0x00;\n\n\tflags = SC_ALGORITHM_RSA_RAW;\n\tflags |= SC_ALGORITHM_RSA_PAD_PKCS1;\n\tflags |= SC_ALGORITHM_RSA_HASH_NONE;\n\n\t_sc_card_add_rsa_alg(card, 512, flags, 0);\n\t_sc_card_add_rsa_alg(card, 768, flags, 0);\n\t_sc_card_add_rsa_alg(card, 1024, flags, 0);\n\n\tif (card->type == SC_CARD_TYPE_TCOS_V3) {\n\t\tcard->caps |= SC_CARD_CAP_APDU_EXT;\n\t\t_sc_card_add_rsa_alg(card, 1280, flags, 0);\n\t\t_sc_card_add_rsa_alg(card, 1536, flags, 0);\n\t\t_sc_card_add_rsa_alg(card, 1792, flags, 0);\n\t\t_sc_card_add_rsa_alg(card, 2048, flags, 0);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":57314,"func":"static int mmap_kmem(struct file *file, struct vm_area_struct *vma)\n{\n\tunsigned long pfn;\n\n\t\/* Turn a kernel-virtual address into a physical page frame *\/\n\tpfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;\n\n\t\/*\n\t * RED-PEN: on some architectures there is more mapped memory than\n\t * available in mem_map which pfn_valid checks for. Perhaps should add a\n\t * new macro here.\n\t *\n\t * RED-PEN: vmalloc is not supported right now.\n\t *\/\n\tif (!pfn_valid(pfn))\n\t\treturn -EIO;\n\n\tvma->vm_pgoff = pfn;\n\treturn mmap_mem(file, vma);\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":129036,"func":"static inline int fm10k_maybe_stop_tx(struct fm10k_ring *tx_ring, u16 size)\n{\n\tif (likely(fm10k_desc_unused(tx_ring) >= size))\n\t\treturn 0;\n\treturn __fm10k_maybe_stop_tx(tx_ring, size);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":196295,"func":"void RenderingHelper::DeleteTexture(GLuint texture_id) {\n  glDeleteTextures(1, &texture_id);\n  CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":434342,"func":"static void _alternates_clean (void)\n{\n  int i;\n  if (Context && Context->msgcount) \n  {\n    for (i = 0; i < Context->msgcount; i++)\n      Context->hdrs[i]->recip_valid = 0;\n  }\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":178149,"func":"void Range::processNodes(ActionType action, Vector<RefPtr<Node> >& nodes, PassRefPtr<Node> oldContainer, PassRefPtr<Node> newContainer, ExceptionCode& ec)\n{\n    for (unsigned i = 0; i < nodes.size(); i++) {\n        switch (action) {\n        case DELETE_CONTENTS:\n            oldContainer->removeChild(nodes[i].get(), ec);\n            break;\n        case EXTRACT_CONTENTS:\n            newContainer->appendChild(nodes[i].release(), ec); \/\/ will remove n from its parent\n            break;\n        case CLONE_CONTENTS:\n            newContainer->appendChild(nodes[i]->cloneNode(true), ec);\n            break;\n        }\n    }\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":469849,"func":"do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)\n{\n\tint ret;\n\n\tif (!capable(CAP_NET_ADMIN))\n\t\treturn -EPERM;\n\n\tswitch (cmd) {\n\tcase IPT_SO_GET_INFO:\n\t\tret = get_info(user, len, 0);\n\t\tbreak;\n\n\tcase IPT_SO_GET_ENTRIES:\n\t\tret = get_entries(user, len);\n\t\tbreak;\n\n\tcase IPT_SO_GET_REVISION_MATCH:\n\tcase IPT_SO_GET_REVISION_TARGET: {\n\t\tstruct ipt_get_revision rev;\n\t\tint target;\n\n\t\tif (*len != sizeof(rev)) {\n\t\t\tret = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\tif (copy_from_user(&rev, user, sizeof(rev)) != 0) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (cmd == IPT_SO_GET_REVISION_TARGET)\n\t\t\ttarget = 1;\n\t\telse\n\t\t\ttarget = 0;\n\n\t\ttry_then_request_module(xt_find_revision(AF_INET, rev.name,\n\t\t\t\t\t\t\t rev.revision,\n\t\t\t\t\t\t\t target, &ret),\n\t\t\t\t\t\"ipt_%s\", rev.name);\n\t\tbreak;\n\t}\n\n\tdefault:\n\t\tduprintf(\"do_ipt_get_ctl: unknown request %i\\n\", cmd);\n\t\tret = -EINVAL;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":220015,"func":"bool IsBlockedNavigation(net::Error error_code) {\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":437184,"func":"static void acm_port_destruct(struct tty_port *port)\n{\n\tstruct acm *acm = container_of(port, struct acm, port);\n\n\tacm_release_minor(acm);\n\tusb_put_intf(acm->control);\n\tkfree(acm->country_codes);\n\tkfree(acm);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":489097,"func":"BOOL nla_set_service_principal(rdpNla* nla, LPTSTR principal)\n{\n\tif (!nla || !principal)\n\t\treturn FALSE;\n\n\tnla->ServicePrincipalName = principal;\n\treturn TRUE;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":267210,"func":"static void JPEGProgressHandler(j_common_ptr jpeg_info)\n{\n  ErrorManager\n    *error_manager;\n\n  ExceptionInfo\n    *exception;\n\n  Image\n    *image;\n\n  error_manager=(ErrorManager *) jpeg_info->client_data;\n  image=error_manager->image;\n  exception=error_manager->exception;\n  if (jpeg_info->is_decompressor == 0)\n    return;\n  if (((j_decompress_ptr) jpeg_info)->input_scan_number < MaxJPEGScans)\n    return;\n  (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,\n    \"too many scans\",\"`%s'\",image->filename);\n  longjmp(error_manager->error_recovery,1);\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":283360,"func":"BlockedPlugin::~BlockedPlugin() {\n}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":514499,"func":"    ~CloseReq() {\n      uv_fs_req_cleanup(req());\n      promise_.Reset();\n      ref_.Reset();\n    }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":112879,"func":"static u64 fixed_mtrr_seg_unit_size(int seg)\n{\n\treturn 8 << fixed_seg_table[seg].range_shift;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":83642,"func":"static int __init acpi_enforce_resources_setup(char *str)\n{\n\tif (str == NULL || *str == '\\0')\n\t\treturn 0;\n\n\tif (!strcmp(\"strict\", str))\n\t\tacpi_enforce_resources = ENFORCE_RESOURCES_STRICT;\n\telse if (!strcmp(\"lax\", str))\n\t\tacpi_enforce_resources = ENFORCE_RESOURCES_LAX;\n\telse if (!strcmp(\"no\", str))\n\t\tacpi_enforce_resources = ENFORCE_RESOURCES_NO;\n\n\treturn 1;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":101277,"func":"static void kvm_free_physmem_slot(struct kvm_memory_slot *free,\n\t\t\t\t  struct kvm_memory_slot *dont)\n{\n\tif (!dont || free->dirty_bitmap != dont->dirty_bitmap)\n\t\tkvm_destroy_dirty_bitmap(free);\n\n\tkvm_arch_free_memslot(free, dont);\n\n\tfree->npages = 0;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":415294,"func":"_bluetooth_client_get_default_adapter_powered (BluetoothClient *self)\n{\n\tBluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE (self);\n\tGtkTreePath *path;\n\tGtkTreeIter iter;\n\tgboolean ret;\n\n\tif (priv->default_adapter == NULL)\n\t\treturn FALSE;\n\n\tpath = gtk_tree_row_reference_get_path (priv->default_adapter);\n\tgtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path);\n\tgtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, BLUETOOTH_COLUMN_POWERED, &ret, -1);\n\tgtk_tree_path_free (path);\n\n\treturn ret;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":204293,"func":"void ImageDataPlatformBackend::Unmap() {\n}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":41273,"func":"list_update_cgroup_event(struct perf_event *event,\n\t\t\t struct perf_event_context *ctx, bool add)\n{\n\tstruct perf_cpu_context *cpuctx;\n\tstruct list_head *cpuctx_entry;\n\n\tif (!is_cgroup_event(event))\n\t\treturn;\n\n\tif (add && ctx->nr_cgroups++)\n\t\treturn;\n\telse if (!add && --ctx->nr_cgroups)\n\t\treturn;\n\t\/*\n\t * Because cgroup events are always per-cpu events,\n\t * this will always be called from the right CPU.\n\t *\/\n\tcpuctx = __get_cpu_context(ctx);\n\tcpuctx_entry = &cpuctx->cgrp_cpuctx_entry;\n\t\/* cpuctx->cgrp is NULL unless a cgroup event is active in this CPU .*\/\n\tif (add) {\n\t\tlist_add(cpuctx_entry, this_cpu_ptr(&cgrp_cpuctx_list));\n\t\tif (perf_cgroup_from_task(current, ctx) == event->cgrp)\n\t\t\tcpuctx->cgrp = event->cgrp;\n\t} else {\n\t\tlist_del(cpuctx_entry);\n\t\tcpuctx->cgrp = NULL;\n\t}\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":280365,"func":"void FrameView::removeSlowRepaintObject()\n{\n    ASSERT(m_slowRepaintObjectCount > 0);\n    m_slowRepaintObjectCount--;\n    if (!m_slowRepaintObjectCount) {\n        if (Page* page = m_frame->page()) {\n            if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())\n                scrollingCoordinator->frameViewHasSlowRepaintObjectsDidChange(this);\n        }\n    }\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":428774,"func":"R_API int r_egg_encode(REgg *egg, const char *name) {\n\tREggPlugin *p;\n\tRListIter *iter;\n\tRBuffer *b;\n\tr_list_foreach (egg->plugins, iter, p) {\n\t\tif (p->type == R_EGG_PLUGIN_ENCODER && !strcmp (name, p->name)) {\n\t\t\tb = p->build (egg);\n\t\t\tif (!b) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tr_buf_free (egg->bin);\n\t\t\tegg->bin = b;\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":182943,"func":"GLint GLES2Implementation::GetFragDataIndexEXT(GLuint program,\n                                               const char* name) {\n  GPU_CLIENT_SINGLE_THREAD_CHECK();\n  GPU_CLIENT_LOG(\"[\" << GetLogPrefix() << \"] glGetFragDataIndexEXT(\" << program\n                     << \", \" << name << \")\");\n  TRACE_EVENT0(\"gpu\", \"GLES2::GetFragDataIndexEXT\");\n  GLint loc = share_group_->program_info_manager()->GetFragDataIndex(\n      this, program, name);\n  GPU_CLIENT_LOG(\"returned \" << loc);\n  CheckGLError();\n  return loc;\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":416301,"func":"int wait_for_token_by_slotlabel(pkcs11_handle_t *h,\n                   const char *wanted_slot_label,\n                   const char *wanted_token_label,\n                   unsigned int *slot_num)\n{\n  int rv;\n\n  do {\n    \/* see if the card we're looking for is inserted *\/\n    rv = find_slot_by_slotlabel_and_tokenlabel (h, wanted_slot_label,\n\twanted_token_label, slot_num);\n    if (rv !=  0) {\n      \/* could call C_WaitForSlotEvent, for now just poll *\/\n      sleep(10);\n      refresh_slots(h);\n      continue;\n    }\n  } while (rv != 0);\n\n  return rv;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":209418,"func":"const char* menu_cache_app_get_working_dir( MenuCacheApp* app )\n{\n    return app->working_dir;\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":465310,"func":"int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)\n{\n\tvcpu_load(vcpu);\n\tmemcpy(®s->gprs, &vcpu->run->s.regs.gprs, sizeof(regs->gprs));\n\tvcpu_put(vcpu);\n\treturn 0;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":467173,"func":"void RGWInfo_ObjStore_SWIFT::list_slo_data(Formatter& formatter,\n                                            const ConfigProxy& config,\n                                            RGWRados& store)\n{\n  formatter.open_object_section(\"slo\");\n  formatter.dump_int(\"max_manifest_segments\", config->rgw_max_slo_entries);\n  formatter.close_section();\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":238829,"func":"void SpeechRecognitionManagerImpl::OnSoundStart(int session_id) {\n  DCHECK_CURRENTLY_ON(BrowserThread::IO);\n  if (!SessionExists(session_id))\n    return;\n\n  DCHECK_EQ(primary_session_id_, session_id);\n  if (SpeechRecognitionEventListener* delegate_listener = GetDelegateListener())\n    delegate_listener->OnSoundStart(session_id);\n  if (SpeechRecognitionEventListener* listener = GetListener(session_id))\n    listener->OnSoundStart(session_id);\n}\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":176754,"func":"set_deny(u32 deny, struct nfs4_ol_stateid *stp)\n{\n\tunsigned char mask = 1 << deny;\n\n\tWARN_ON_ONCE(deny > NFS4_SHARE_DENY_BOTH);\n\tstp->st_deny_bmap |= mask;\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":36037,"func":"static int fuse_writepage(struct page *page, struct writeback_control *wbc)\n{\n\tint err;\n\n\tif (fuse_page_is_writeback(page->mapping->host, page->index)) {\n\t\t\/*\n\t\t * ->writepages() should be called for sync() and friends.  We\n\t\t * should only get here on direct reclaim and then we are\n\t\t * allowed to skip a page which is already in flight\n\t\t *\/\n\t\tWARN_ON(wbc->sync_mode == WB_SYNC_ALL);\n\n\t\tredirty_page_for_writepage(wbc, page);\n\t\treturn 0;\n\t}\n\n\terr = fuse_writepage_locked(page);\n\tunlock_page(page);\n\n\treturn err;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":417229,"func":"parse_SET_IP_ECN(char *arg, struct ofpbuf *ofpacts,\n                 enum ofputil_protocol *usable_protocols OVS_UNUSED)\n{\n    uint8_t ecn;\n    char *error;\n\n    error = str_to_u8(arg, \"ECN\", &ecn);\n    if (error) {\n        return error;\n    }\n\n    if (ecn & ~IP_ECN_MASK) {\n        return xasprintf(\"%s: not a valid ECN\", arg);\n    }\n    ofpact_put_SET_IP_ECN(ofpacts)->ecn = ecn;\n    return NULL;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":192529,"func":"void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) {\n  dest->Put(SERVER_NON_UNIQUE_NAME, src->Get(SERVER_NON_UNIQUE_NAME));\n  dest->Put(SERVER_PARENT_ID, src->Get(SERVER_PARENT_ID));\n  dest->Put(SERVER_MTIME, src->Get(SERVER_MTIME));\n  dest->Put(SERVER_CTIME, src->Get(SERVER_CTIME));\n  dest->Put(SERVER_VERSION, src->Get(SERVER_VERSION));\n  dest->Put(SERVER_IS_DIR, src->Get(SERVER_IS_DIR));\n  dest->Put(SERVER_IS_DEL, src->Get(SERVER_IS_DEL));\n  dest->Put(IS_UNAPPLIED_UPDATE, src->Get(IS_UNAPPLIED_UPDATE));\n  dest->Put(SERVER_SPECIFICS, src->Get(SERVER_SPECIFICS));\n  dest->Put(SERVER_POSITION_IN_PARENT, src->Get(SERVER_POSITION_IN_PARENT));\n}\n","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":78336,"func":"static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)\n{\n\tif (signal_pending(tsk) && !thread_group_empty(tsk)) {\n\t\tsigset_t newblocked;\n\t\t\/* A set of now blocked but previously unblocked signals. *\/\n\t\tsigandnsets(&newblocked, newset, ¤t->blocked);\n\t\tretarget_shared_pending(tsk, &newblocked);\n\t}\n\ttsk->blocked = *newset;\n\trecalc_sigpending();\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":69959,"func":"struct sc_card_driver *sc_get_epass2003_driver(void)\n{\n\treturn sc_get_driver();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":492817,"func":"void hugetlb_fix_reserve_counts(struct inode *inode)\n{\n\tstruct hugepage_subpool *spool = subpool_inode(inode);\n\tlong rsv_adjust;\n\tbool reserved = false;\n\n\trsv_adjust = hugepage_subpool_get_pages(spool, 1);\n\tif (rsv_adjust > 0) {\n\t\tstruct hstate *h = hstate_inode(inode);\n\n\t\tif (!hugetlb_acct_memory(h, 1))\n\t\t\treserved = true;\n\t} else if (!rsv_adjust) {\n\t\treserved = true;\n\t}\n\n\tif (!reserved)\n\t\tpr_warn(\"hugetlb: Huge Page Reserved count may go negative.\\n\");\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":172929,"func":"void ContextState::RestoreVertexAttribValues() const {\n  for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();\n       ++attrib) {\n    switch (attrib_values[attrib].type()) {\n      case SHADER_VARIABLE_FLOAT:\n        {\n          GLfloat v[4];\n          attrib_values[attrib].GetValues(v);\n          api()->glVertexAttrib4fvFn(attrib, v);\n        }\n        break;\n      case SHADER_VARIABLE_INT:\n        {\n          GLint v[4];\n          attrib_values[attrib].GetValues(v);\n          api()->glVertexAttribI4ivFn(attrib, v);\n        }\n        break;\n      case SHADER_VARIABLE_UINT:\n        {\n          GLuint v[4];\n          attrib_values[attrib].GetValues(v);\n          api()->glVertexAttribI4uivFn(attrib, v);\n        }\n        break;\n      default:\n        NOTREACHED();\n        break;\n    }\n  }\n}\n","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":370157,"func":"static inline struct sctp_chunk *sctp_outq_dequeue_data(struct sctp_outq *q)\n{\n\tstruct sctp_chunk *ch = NULL;\n\n\tif (!list_empty(&q->out_chunk_list)) {\n\t\tstruct list_head *entry = q->out_chunk_list.next;\n\n\t\tch = list_entry(entry, struct sctp_chunk, list);\n\t\tlist_del_init(entry);\n\t\tq->out_qlen -= ch->skb->len;\n\t}\n\treturn ch;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":174810,"func":"gfx::Rect LayerTreeHostImpl::DeviceViewport() const {\n  if (external_viewport_.IsEmpty())\n    return gfx::Rect(device_viewport_size_);\n\n  return external_viewport_;\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":240537,"func":"  ~SendLivePreviewTask() {\n  }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":449107,"func":"CNF_AddRefclocks(void)\n{\n  unsigned int i;\n\n  for (i = 0; i < ARR_GetSize(refclock_sources); i++) {\n    RCL_AddRefclock((RefclockParameters *)ARR_GetElement(refclock_sources, i));\n  }\n\n  ARR_SetSize(refclock_sources, 0);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":249429,"func":"WebKitWebDataSource* webkit_web_frame_get_data_source(WebKitWebFrame* frame)\n{\n    g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);\n\n    Frame* coreFrame = core(frame);\n    return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->documentLoader());\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":227864,"func":"static void HighEntropyMethodWithMeasureMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  impl->highEntropyMethodWithMeasure();\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":460711,"func":"void red_stream_set_core_interface(RedStream *stream, SpiceCoreInterfaceInternal *core)\n{\n    red_stream_remove_watch(stream);\n    stream->priv->core = core;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":129467,"func":"static struct hubp *dcn10_hubp_create(\n\tstruct dc_context *ctx,\n\tuint32_t inst)\n{\n\tstruct dcn10_hubp *hubp1 =\n\t\tkzalloc(sizeof(struct dcn10_hubp), GFP_KERNEL);\n\n\tif (!hubp1)\n\t\treturn NULL;\n\n\tdcn10_hubp_construct(hubp1, ctx, inst,\n\t\t\t     &hubp_regs[inst], &hubp_shift, &hubp_mask);\n\treturn &hubp1->base;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":15458,"func":"mtime_t decoder_GetDisplayDate ( decoder_t * p_dec , mtime_t i_ts ) {\n if ( ! p_dec -> pf_get_display_date ) return VLC_TS_INVALID ;\n return p_dec -> pf_get_display_date ( p_dec , i_ts ) ;\n }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":203887,"func":"void ImageLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const\n{\n    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Image);\n    info.addMember(m_element, \"element\");\n    info.addMember(m_image.get(), \"image\", WTF::RetainingPointer);\n    info.addMember(m_derefElementTimer, \"derefElementTimer\");\n    info.addMember(m_failedLoadURL, \"failedLoadURL\");\n}\n","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":290277,"func":"int ssl3_num_ciphers ( void ) {\n return ( SSL3_NUM_CIPHERS ) ;\n }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":310802,"func":"void TransportTexture::ReleaseTextures() {\n  texture_map_.clear();\n\n  bool ret = sender_->Send(new GpuTransportTextureHostMsg_ReleaseTextures(\n      host_id_));\n  if (!ret) {\n    LOG(ERROR) << \"GpuTransportTexture_ReleaseTextures failed\";\n  }\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":433376,"func":"static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m,\n\t\t\t\t       unsigned int flags)\n{\n\tbool tgid = flags & TRACE_ITER_RECORD_TGID;\n\tconst char tgid_space[] = \"          \";\n\tconst char space[] = \"  \";\n\n\tseq_printf(m, \"#                          %s  _-----=> irqs-off\\n\",\n\t\t   tgid ? tgid_space : space);\n\tseq_printf(m, \"#                          %s \/ _----=> need-resched\\n\",\n\t\t   tgid ? tgid_space : space);\n\tseq_printf(m, \"#                          %s| \/ _---=> hardirq\/softirq\\n\",\n\t\t   tgid ? tgid_space : space);\n\tseq_printf(m, \"#                          %s|| \/ _--=> preempt-depth\\n\",\n\t\t   tgid ? tgid_space : space);\n\tseq_printf(m, \"#                          %s||| \/     delay\\n\",\n\t\t   tgid ? tgid_space : space);\n\tseq_printf(m, \"#           TASK-PID   CPU#%s||||    TIMESTAMP  FUNCTION\\n\",\n\t\t   tgid ? \"   TGID   \" : space);\n\tseq_printf(m, \"#              | |       | %s||||       |         |\\n\",\n\t\t   tgid ? \"     |    \" : space);\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":137642,"func":"TEST_F(SslContextImplTest, TestExpiredCert) {\n  const std::string yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/expired_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/expired_key.pem\"\n)EOF\";\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), tls_context);\n  ClientContextConfigImpl cfg(tls_context, factory_context_);\n  Envoy::Ssl::ClientContextSharedPtr context(manager_.createSslClientContext(store_, cfg, nullptr));\n  EXPECT_EQ(0U, context->daysUntilFirstCertExpires());\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":195367,"func":"unsigned long GetFaceName(FPDF_SYSFONTINFO* sysfontinfo,\n                          void* hFont,\n                          char* buffer,\n                          unsigned long buffer_size) {\n  auto* fontinfo_with_metrics =\n      static_cast<FPDF_SYSFONTINFO_WITHMETRICS*>(sysfontinfo);\n  if (!fontinfo_with_metrics->default_sysfontinfo->GetFaceName)\n    return 0;\n  return fontinfo_with_metrics->default_sysfontinfo->GetFaceName(\n      fontinfo_with_metrics->default_sysfontinfo, hFont, buffer, buffer_size);\n}\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":504591,"func":"lstnActivity(ptcplstn_t *const pLstn)\n{\n\tint newSock = -1;\n\tprop_t *peerName;\n\tprop_t *peerIP;\n\trsRetVal localRet;\n\tDEFiRet;\n\n\tDBGPRINTF(\"imptcp: new connection on listen socket %d\\n\", pLstn->sock);\n\twhile(glbl.GetGlobalInputTermState() == 0) {\n\t\tlocalRet = AcceptConnReq(pLstn, &newSock, &peerName, &peerIP);\n\t\tDBGPRINTF(\"imptcp: AcceptConnReq on listen socket %d returned %d\\n\", pLstn->sock, localRet);\n\t\tif(localRet == RS_RET_NO_MORE_DATA || glbl.GetGlobalInputTermState() == 1) {\n\t\t\tbreak;\n\t\t}\n\t\tCHKiRet(localRet);\n\t\tlocalRet = addSess(pLstn, newSock, peerName, peerIP);\n\t\tif(localRet != RS_RET_OK) {\n\t\t\tclose(newSock);\n\t\t\tprop.Destruct(&peerName);\n\t\t\tprop.Destruct(&peerIP);\n\t\t\tABORT_FINALIZE(localRet);\n\t\t}\n\t}\n\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":469643,"func":"virSecuritySELinuxGetModel(virSecurityManager *mgr G_GNUC_UNUSED)\n{\n    return SECURITY_SELINUX_NAME;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":174501,"func":" static PropertyDetails GetDetailsImpl(JSObject* holder, uint32_t entry) {\n uint32_t length = static_cast<uint32_t>(GetString(holder)->length());\n if (entry < length) {\n PropertyAttributes attributes =\n static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);\n return PropertyDetails(kData, attributes, 0, PropertyCellType::kNoCell);\n }\n return BackingStoreAccessor::GetDetailsImpl(holder, entry - length);\n }\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":422899,"func":"static inline void dccp_mib_exit(void)\n{\n\tsnmp_mib_free((void __percpu **)dccp_statistics);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":394955,"func":"static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh,\n                                         curl_socket_t s,\n                                         struct Curl_easy *data)\n{\n  struct Curl_sh_entry *there = sh_getentry(sh, s);\n  struct Curl_sh_entry *check;\n\n  if(there)\n    \/* it is present, return fine *\/\n    return there;\n\n  \/* not present, add it *\/\n  check = calloc(1, sizeof(struct Curl_sh_entry));\n  if(!check)\n    return NULL; \/* major failure *\/\n\n  check->easy = data;\n  check->socket = s;\n\n  \/* make\/add new hash entry *\/\n  if(!Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) {\n    free(check);\n    return NULL; \/* major failure *\/\n  }\n\n  return check; \/* things are good in sockhash land *\/\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":286246,"func":"void RenderFrameImpl::WasHidden() {\n  for (auto& observer : observers_)\n    observer.WasHidden();\n\n#if BUILDFLAG(ENABLE_PLUGINS)\n  for (auto* plugin : active_pepper_instances_)\n    plugin->PageVisibilityChanged(false);\n#endif  \/\/ ENABLE_PLUGINS\n\n  if (GetWebFrame()->FrameWidget()) {\n    GetWebFrame()->FrameWidget()->SetVisibilityState(VisibilityState());\n  }\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":78675,"func":"TEST(ArrayWriterTest, WChar) {\n  wchar_t array[10];\n  fmt::WArrayWriter w(array);\n  w.write(L\"{}\", 42);\n  EXPECT_EQ(L\"42\", w.str());\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":305167,"func":"static void nfs4_layoutcommit_release(void *calldata)\n{\n\tstruct nfs4_layoutcommit_data *data = calldata;\n\tstruct pnfs_layout_segment *lseg, *tmp;\n\tunsigned long *bitlock = &NFS_I(data->args.inode)->flags;\n\n\tpnfs_cleanup_layoutcommit(data);\n\t\/* Matched by references in pnfs_set_layoutcommit *\/\n\tlist_for_each_entry_safe(lseg, tmp, &data->lseg_list, pls_lc_list) {\n\t\tlist_del_init(&lseg->pls_lc_list);\n\t\tif (test_and_clear_bit(NFS_LSEG_LAYOUTCOMMIT,\n\t\t\t\t       &lseg->pls_flags))\n\t\t\tput_lseg(lseg);\n\t}\n\n\tclear_bit_unlock(NFS_INO_LAYOUTCOMMITTING, bitlock);\n\tsmp_mb__after_clear_bit();\n\twake_up_bit(bitlock, NFS_INO_LAYOUTCOMMITTING);\n\n\tput_rpccred(data->cred);\n\tkfree(data);\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":445529,"func":"  NetworkListenSocket(IoHandlePtr&& io_handle, const Address::InstanceConstSharedPtr& address,\n                      const Network::Socket::OptionsSharedPtr& options)\n      : ListenSocketImpl(std::move(io_handle), address) {\n    setListenSocketOptions(options);\n  }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":202541,"func":"GLvoid StubGLVertexAttribPointer(GLuint indx, GLint size, GLenum type,\n                                 GLboolean normalized, GLsizei stride,\n                                 const void* ptr) {\n  glVertexAttribPointer(indx, size, type, normalized, stride, ptr);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":248472,"func":"void RenderViewTest::SimulatePointClick(const gfx::Point& point) {\n  WebMouseEvent mouse_event(WebInputEvent::kMouseDown,\n                            WebInputEvent::kNoModifiers,\n                            ui::EventTimeStampToSeconds(ui::EventTimeForNow()));\n  mouse_event.button = WebMouseEvent::Button::kLeft;\n  mouse_event.SetPositionInWidget(point.x(), point.y());\n  mouse_event.click_count = 1;\n  RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);\n  impl->OnMessageReceived(InputMsg_HandleInputEvent(\n      0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),\n      InputEventDispatchType::DISPATCH_TYPE_BLOCKING));\n  mouse_event.SetType(WebInputEvent::kMouseUp);\n  impl->OnMessageReceived(InputMsg_HandleInputEvent(\n      0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),\n      InputEventDispatchType::DISPATCH_TYPE_BLOCKING));\n}\n","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":194964,"func":"void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element)\n{\n    m_timeContainers.remove(element);\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":274408,"func":"  void Flush() {\n    HandleScope scope;\n\n    Local<Value> cb = handle_->Get(on_headers_sym);\n\n    if (!cb->IsFunction())\n      return;\n\n    Handle<Value> argv[2] = {\n      CreateHeaders(),\n      url_.ToString()\n    };\n\n    Local<Value> r = Local<Function>::Cast(cb)->Call(handle_, 2, argv);\n\n    if (r.IsEmpty())\n      got_exception_ = true;\n\n    url_.Reset();\n    have_flushed_ = true;\n  }","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":142751,"func":"void add_subst_list(char list[][NAME_LENGTH], char value[][NAME_LENGTH], char *item, char *str, int *i) {\n   strlcpy(list[*i], item, NAME_LENGTH);\n   strlcpy(value[(*i)++], str, NAME_LENGTH);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":497899,"func":"static void fix_index_entry_timestamps(AVStream* st, int end_index, int64_t end_ts,\n                                       int64_t* frame_duration_buffer,\n                                       int frame_duration_buffer_size) {\n    FFStream *const sti = ffstream(st);\n    int i = 0;\n    av_assert0(end_index >= 0 && end_index <= sti->nb_index_entries);\n    for (i = 0; i < frame_duration_buffer_size; i++) {\n        end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i];\n        sti->index_entries[end_index - 1 - i].timestamp = end_ts;\n    }\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":293068,"func":"int FLTValidForBBoxFilter(FilterEncodingNode *psFilterNode)\n{\n  int nCount = 0;\n\n  if (!psFilterNode || !psFilterNode->pszValue)\n    return 1;\n\n  nCount = FLTNumberOfFilterType(psFilterNode, \"BBOX\");\n\n  if (nCount > 1)\n    return 0;\n  else if (nCount == 0)\n    return 1;\n\n  \/* nCount ==1  *\/\n  if (strcasecmp(psFilterNode->pszValue, \"BBOX\") == 0)\n    return 1;\n\n  if (strcasecmp(psFilterNode->pszValue, \"AND\") == 0) {\n    return FLTValidForBBoxFilter(psFilterNode->psLeftNode) &&\n           FLTValidForBBoxFilter(psFilterNode->psRightNode);\n  }\n\n  return 0;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":100391,"func":"static int nfc_genl_setup_device_added(struct nfc_dev *dev, struct sk_buff *msg)\n{\n\tif (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) ||\n\t    nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||\n\t    nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) ||\n\t    nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up) ||\n\t    nla_put_u8(msg, NFC_ATTR_RF_MODE, dev->rf_mode))\n\t\treturn -1;\n\treturn 0;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":11526,"func":"void SocketStreamDispatcherHost::OnSSLCertificateError(\n    net::SocketStream* socket, const net::SSLInfo& ssl_info, bool fatal) {\n  int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);\n  DVLOG(1) << \"SocketStreamDispatcherHost::OnSSLCertificateError socket_id=\"\n           << socket_id;\n  if (socket_id == content::kNoSocketId) {\n    LOG(ERROR) << \"NoSocketId in OnSSLCertificateError\";\n    return;\n  }\n   SocketStreamHost* socket_stream_host = hosts_.Lookup(socket_id);\n   DCHECK(socket_stream_host);\n   content::GlobalRequestID request_id(-1, socket_id);\n  SSLManager::OnSSLCertificateError(ssl_delegate_weak_factory_.GetWeakPtr(),\n      request_id, ResourceType::SUB_RESOURCE, socket->url(),\n       render_process_id_, socket_stream_host->render_view_id(), ssl_info,\n       fatal);\n }\n","target":1,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":513694,"func":"napi_status napi_set_named_property(napi_env env,\n                                    napi_value object,\n                                    const char* utf8name,\n                                    napi_value value) {\n  NAPI_PREAMBLE(env);\n  CHECK_ARG(env, value);\n\n  v8::Local<v8::Context> context = env->context();\n  v8::Local<v8::Object> obj;\n\n  CHECK_TO_OBJECT(env, context, obj, object);\n\n  v8::Local<v8::Name> key;\n  CHECK_NEW_FROM_UTF8(env, key, utf8name);\n\n  v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);\n\n  v8::Maybe<bool> set_maybe = obj->Set(context, key, val);\n\n  RETURN_STATUS_IF_FALSE(env, set_maybe.FromMaybe(false), napi_generic_failure);\n  return GET_RETURN_STATUS(env);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":522031,"func":"double Item_func_mod::real_op()\n{\n  DBUG_ASSERT(fixed == 1);\n  double value= args[0]->val_real();\n  double val2=  args[1]->val_real();\n  if ((null_value= args[0]->null_value || args[1]->null_value))\n    return 0.0; \/* purecov: inspected *\/\n  if (val2 == 0.0)\n  {\n    signal_divide_by_null();\n    return 0.0;\n  }\n  return fmod(value,val2);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":114685,"func":"static SQInteger class_newmember(HSQUIRRELVM v)\n{\n    SQInteger top = sq_gettop(v);\n    SQBool bstatic = SQFalse;\n    if(top == 5)\n    {\n        sq_tobool(v,-1,&bstatic);\n        sq_pop(v,1);\n    }\n\n    if(top < 4) {\n        sq_pushnull(v);\n    }\n    return SQ_SUCCEEDED(sq_newmember(v,-4,bstatic))?1:SQ_ERROR;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":378979,"func":"static unsigned LZ4_count(const BYTE* pIn, const BYTE* pRef, const BYTE* pInLimit)\n{\n    const BYTE* const pStart = pIn;\n\n    while (likely(pIn<pInLimit-(STEPSIZE-1)))\n    {\n        size_t diff = AARCH(pRef) ^ AARCH(pIn);\n        if (!diff) { pIn+=STEPSIZE; pRef+=STEPSIZE; continue; }\n        pIn += LZ4_NbCommonBytes(diff);\n        return (unsigned)(pIn - pStart);\n    }\n    if (sizeof(void*)==8) if ((pIn<(pInLimit-3)) && (A32(pRef) == A32(pIn))) { pIn+=4; pRef+=4; }\n    if ((pIn<(pInLimit-1)) && (A16(pRef) == A16(pIn))) { pIn+=2; pRef+=2; }\n    if ((pIn<pInLimit) && (*pRef == *pIn)) pIn++;\n\n    return (unsigned)(pIn - pStart);\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":149928,"func":"size_t Magick::Image::totalColors(void) const\n{\n  size_t\n    colors;\n\n  GetPPException;\n  colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);\n  ThrowImageException;\n  return colors;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":118013,"func":"static BOOL rdp_write_draw_nine_grid_cache_capability_set(wStream* s, const rdpSettings* settings)\n{\n\tsize_t header;\n\tUINT32 drawNineGridSupportLevel;\n\n\tif (!Stream_EnsureRemainingCapacity(s, 32))\n\t\treturn FALSE;\n\n\theader = rdp_capability_set_start(s);\n\tdrawNineGridSupportLevel =\n\t    (settings->DrawNineGridEnabled) ? DRAW_NINEGRID_SUPPORTED_V2 : DRAW_NINEGRID_NO_SUPPORT;\n\tStream_Write_UINT32(s, drawNineGridSupportLevel); \/* drawNineGridSupportLevel (4 bytes) *\/\n\tStream_Write_UINT16(s, settings->DrawNineGridCacheSize); \/* drawNineGridCacheSize (2 bytes) *\/\n\tStream_Write_UINT16(\n\t    s, settings->DrawNineGridCacheEntries); \/* drawNineGridCacheEntries (2 bytes) *\/\n\trdp_capability_set_finish(s, header, CAPSET_TYPE_DRAW_NINE_GRID_CACHE);\n\treturn TRUE;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":284277,"func":"content::ResourceRequestInfo::WebContentsGetter GetWebContentsGetter(\n    content::WebContents* web_contents) {\n  int frame_tree_node_id = web_contents->GetMainFrame()->GetFrameTreeNodeId();\n  if (frame_tree_node_id != -1) {\n    return base::Bind(content::WebContents::FromFrameTreeNodeId,\n                      frame_tree_node_id);\n  }\n\n  return base::Bind(&GetWebContentsByFrameID,\n                    web_contents->GetMainFrame()->GetProcess()->GetID(),\n                    web_contents->GetMainFrame()->GetRoutingID());\n}\n","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":75747,"func":"static bool code_segment_valid(struct kvm_vcpu *vcpu)\n{\n\tstruct kvm_segment cs;\n\tunsigned int cs_rpl;\n\n\tvmx_get_segment(vcpu, &cs, VCPU_SREG_CS);\n\tcs_rpl = cs.selector & SELECTOR_RPL_MASK;\n\n\tif (cs.unusable)\n\t\treturn false;\n\tif (~cs.type & (AR_TYPE_CODE_MASK|AR_TYPE_ACCESSES_MASK))\n\t\treturn false;\n\tif (!cs.s)\n\t\treturn false;\n\tif (cs.type & AR_TYPE_WRITEABLE_MASK) {\n\t\tif (cs.dpl > cs_rpl)\n\t\t\treturn false;\n\t} else {\n\t\tif (cs.dpl != cs_rpl)\n\t\t\treturn false;\n\t}\n\tif (!cs.present)\n\t\treturn false;\n\n\t\/* TODO: Add Reserved field check, this'll require a new member in the kvm_segment_field structure *\/\n\treturn true;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":467087,"func":"parse_create_repinfo(struct msg_parse* msg, struct reply_info** rep,\n\tstruct regional* region)\n{\n\t*rep = construct_reply_info_base(region, msg->flags, msg->qdcount, 0, \n\t\t0, 0, msg->an_rrsets, msg->ns_rrsets, msg->ar_rrsets, \n\t\tmsg->rrset_count, sec_status_unchecked);\n\tif(!*rep)\n\t\treturn 0;\n\treturn 1;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":134613,"func":"static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)\n{\n\tconst struct nfs_inode *nfsi = NFS_I(inode);\n\n\treturn ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 ||\n\t\tnfs_ctime_need_update(inode, fattr) ||\n\t\tnfs_size_need_update(inode, fattr) ||\n\t\t((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":330611,"func":"static double lfo_get_value(SimpleLFO *lfo)\n\n{\n\n    double phs = FFMIN(100, lfo->phase \/ FFMIN(1.99, FFMAX(0.01, lfo->pwidth)) + lfo->offset);\n\n    double val;\n\n\n\n    if (phs > 1)\n\n        phs = fmod(phs, 1.);\n\n\n\n    switch (lfo->mode) {\n\n    case SINE:\n\n        val = sin(phs * 2 * M_PI);\n\n        break;\n\n    case TRIANGLE:\n\n        if (phs > 0.75)\n\n            val = (phs - 0.75) * 4 - 1;\n\n        else if (phs > 0.25)\n\n            val = -4 * phs + 2;\n\n        else\n\n            val = phs * 4;\n\n        break;\n\n    case SQUARE:\n\n        val = phs < 0.5 ? -1 : +1;\n\n        break;\n\n    case SAWUP:\n\n        val = phs * 2 - 1;\n\n        break;\n\n    case SAWDOWN:\n\n        val = 1 - phs * 2;\n\n        break;\n\n\n    }\n\n\n\n    return val * lfo->amount;\n\n}","target":1,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":309668,"func":"void NavigateToDataURLAndCheckForTerminationDisabler(\n    Shell* shell,\n    const std::string& html,\n    bool expect_onunload,\n    bool expect_onbeforeunload) {\n  NavigateToURL(shell, GURL(\"data:text\/html,\" + html));\n  RenderFrameHostImpl* rfh =\n      static_cast<RenderFrameHostImpl*>(shell->web_contents()->GetMainFrame());\n  EXPECT_EQ(expect_onunload,\n            rfh->GetSuddenTerminationDisablerState(blink::kUnloadHandler));\n  EXPECT_EQ(expect_onbeforeunload, rfh->GetSuddenTerminationDisablerState(\n                                       blink::kBeforeUnloadHandler));\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":440796,"func":"static int vxlan_fdb_notify_one(struct notifier_block *nb,\n\t\t\t\tconst struct vxlan_dev *vxlan,\n\t\t\t\tconst struct vxlan_fdb *f,\n\t\t\t\tconst struct vxlan_rdst *rdst,\n\t\t\t\tstruct netlink_ext_ack *extack)\n{\n\tstruct switchdev_notifier_vxlan_fdb_info fdb_info;\n\tint rc;\n\n\tvxlan_fdb_switchdev_notifier_info(vxlan, f, rdst, extack, &fdb_info);\n\trc = nb->notifier_call(nb, SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE,\n\t\t\t       &fdb_info);\n\treturn notifier_to_errno(rc);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":123719,"func":"static ssize_t regulator_print_state(char *buf, int state)\n{\n\tif (state > 0)\n\t\treturn sprintf(buf, \"enabled\\n\");\n\telse if (state == 0)\n\t\treturn sprintf(buf, \"disabled\\n\");\n\telse\n\t\treturn sprintf(buf, \"unknown\\n\");\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":35296,"func":"    **\/\n    CImgDisplay(const unsigned int width, const unsigned int height,\n                const char *const title=0, const unsigned int normalization=3,\n                const bool is_fullscreen=false, const bool is_closed=false):\n      _width(0),_height(0),_normalization(0),\n      _min(0),_max(0),\n      _is_fullscreen(false),\n      _title(0),\n      _window_width(0),_window_height(0),_button(0),\n      _keys(new unsigned int[128]),_released_keys(new unsigned int[128]),\n      _window_x(0),_window_y(0),_mouse_x(-1),_mouse_y(-1),_wheel(0),\n      _is_closed(true),_is_resized(false),_is_moved(false),_is_event(false) {\n      assign(width,height,title,normalization,is_fullscreen,is_closed);","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":359961,"func":"deep_count_one (DeepCountState *state,\n\t\tGFileInfo *info)\n{\n\tNautilusFile *file;\n\tGFile *subdir;\n\tgboolean is_seen_inode;\n\n\tif (should_skip_file (NULL, info)) {\n\t\treturn;\n\t}\n\n\tis_seen_inode = seen_inode (state, info);\n\tif (!is_seen_inode) {\n\t\tmark_inode_as_seen (state, info);\n\t}\n\n\tfile = state->directory->details->deep_count_file;\n\n\tif (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {\n\t\t\/* Count the directory. *\/\n\t\tfile->details->deep_directory_count += 1;\n\n\t\t\/* Record the fact that we have to descend into this directory. *\/\n\n\t\tsubdir = g_file_get_child (state->deep_count_location, g_file_info_get_name (info));\n\t\tstate->deep_count_subdirectories = g_list_prepend\n\t\t\t(state->deep_count_subdirectories, subdir);\n\t} else {\n\t\t\/* Even non-regular files count as files. *\/\n\t\tfile->details->deep_file_count += 1;\n\t}\n\n\t\/* Count the size. *\/\n\tif (!is_seen_inode && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE)) {\n\t\tfile->details->deep_size += g_file_info_get_size (info);\n\t}\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":488380,"func":"int __init igmp6_late_init(void)\n{\n\treturn register_netdevice_notifier(&igmp6_netdev_notifier);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":396508,"func":"searchAnchor(AnchorList *al, char *str)\n{\n    int i;\n    Anchor *a;\n    if (al == NULL)\n\treturn NULL;\n    for (i = 0; i < al->nanchor; i++) {\n\ta = &al->anchors[i];\n\tif (a->hseq < 0)\n\t  continue;\n\tif (!strcmp(a->url, str))\n\t    return a;\n    }\n    return NULL;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":260603,"func":"xfs_buf_vmap_len(\n\tstruct xfs_buf\t*bp)\n{\n\treturn (bp->b_page_count * PAGE_SIZE) - bp->b_offset;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":66359,"func":"void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t)\n{\n    X509_VERIFY_PARAM_set_time(ctx->param, t);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":320088,"func":"static void test_visitor_in_number(TestInputVisitorData *data,\n\n                                   const void *unused)\n\n{\n\n    double res = 0, value = 3.14;\n\n    Visitor *v;\n\n\n\n    v = visitor_input_test_init(data, \"%f\", value);\n\n\n\n    visit_type_number(v, NULL, &res, &error_abort);\n\n    g_assert_cmpfloat(res, ==, value);\n\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":191825,"func":"void GfxColorSpace::getDefaultRanges(double *decodeLow, double *decodeRange,\n\t\t\t\t     int maxImgPixel) {\n  int i;\n\n  for (i = 0; i < getNComps(); ++i) {\n    decodeLow[i] = 0;\n    decodeRange[i] = 1;\n  }\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":49219,"func":"int mingw_listen(int sockfd, int backlog)\n{\n\tSOCKET s = (SOCKET)_get_osfhandle(sockfd);\n\treturn listen(s, backlog);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":371761,"func":"file_leave_notify_callback (GtkWidget *widget,\n\t\t\t    GdkEventCrossing *event,\n\t\t\t    gpointer user_data)\n{\n\tFrWindow    *window = user_data;\n\tGtkTreeIter  iter;\n\n\tif (window->priv->single_click && (window->priv->list_hover_path != NULL)) {\n\t\tgtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store),\n\t\t\t\t\t &iter,\n\t\t\t\t\t window->priv->list_hover_path);\n\t\tgtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store),\n\t\t\t\t\t    window->priv->list_hover_path,\n\t\t\t\t\t    &iter);\n\n\t\tgtk_tree_path_free (window->priv->list_hover_path);\n\t\twindow->priv->list_hover_path = NULL;\n\t}\n\n\treturn FALSE;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":218923,"func":"blink::WebSpeechRecognizer* RenderViewImpl::SpeechRecognizer() {\n  if (!speech_recognition_dispatcher_)\n    speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this);\n  return speech_recognition_dispatcher_;\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":201518,"func":"long long jsvGetLongIntegerAndUnLock(JsVar *v) {\n  long long i = jsvGetLongInteger(v);\n  jsvUnLock(v);\n  return i;\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":451661,"func":"static inline void bvec_advance(const struct bio_vec *bvec,\n\t\t\t\tstruct bvec_iter_all *iter_all)\n{\n\tstruct bio_vec *bv = &iter_all->bv;\n\n\tif (iter_all->done) {\n\t\tbv->bv_page++;\n\t\tbv->bv_offset = 0;\n\t} else {\n\t\tbv->bv_page = bvec->bv_page + (bvec->bv_offset >> PAGE_SHIFT);\n\t\tbv->bv_offset = bvec->bv_offset & ~PAGE_MASK;\n\t}\n\tbv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset,\n\t\t\t   bvec->bv_len - iter_all->done);\n\titer_all->done += bv->bv_len;\n\n\tif (iter_all->done == bvec->bv_len) {\n\t\titer_all->idx++;\n\t\titer_all->done = 0;\n\t}\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":47262,"func":"static void nfp_flower_vnic_clean(struct nfp_app *app, struct nfp_net *nn)\n{\n\tstruct nfp_flower_priv *priv = app->priv;\n\n\tif (app->pf->num_vfs)\n\t\tnfp_reprs_clean_and_free_by_type(app, NFP_REPR_TYPE_VF);\n\tnfp_reprs_clean_and_free_by_type(app, NFP_REPR_TYPE_PF);\n\tnfp_reprs_clean_and_free_by_type(app, NFP_REPR_TYPE_PHYS_PORT);\n\n\tpriv->nn = NULL;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":417203,"func":"format_SET_VLAN_VID(const struct ofpact_vlan_vid *a, struct ds *s)\n{\n    ds_put_format(s, \"%s%s:%s%\"PRIu16, colors.param,\n                  a->push_vlan_if_needed ? \"mod_vlan_vid\" : \"set_vlan_vid\",\n                  colors.end, a->vlan_vid);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":464977,"func":"static inline void *ResizeBlock(void *block,size_t size)\n{\n  void\n    *memory;\n\n  if (block == (void *) NULL)\n    return(AcquireBlock(size));\n  memory=AcquireBlock(size);\n  if (memory == (void *) NULL)\n    return((void *) NULL);\n  if (size <= (SizeOfBlock(block)-sizeof(size_t)))\n    (void) memcpy(memory,block,size);\n  else\n    (void) memcpy(memory,block,SizeOfBlock(block)-sizeof(size_t));\n  memory_pool.allocation+=size;\n  return(memory);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":125029,"func":"static i40e_status i40e_del_macvlan_filter(struct i40e_hw *hw, u16 seid,\n\t\t\t\t\t   const u8 *macaddr, int *aq_err)\n{\n\tstruct i40e_aqc_remove_macvlan_element_data element;\n\ti40e_status status;\n\n\tmemset(&element, 0, sizeof(element));\n\tether_addr_copy(element.mac_addr, macaddr);\n\telement.vlan_tag = 0;\n\telement.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH;\n\tstatus = i40e_aq_remove_macvlan(hw, seid, &element, 1, NULL);\n\t*aq_err = hw->aq.asq_last_status;\n\n\treturn status;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":151389,"func":"static void __exit ecryptfs_exit(void)\n{\n\tint rc;\n\n\trc = ecryptfs_destroy_crypto();\n\tif (rc)\n\t\tprintk(KERN_ERR \"Failure whilst attempting to destroy crypto; \"\n\t\t       \"rc = [%d]\\n\", rc);\n\tecryptfs_release_messaging();\n\tecryptfs_destroy_kthread();\n\tdo_sysfs_unregistration();\n\tunregister_filesystem(&ecryptfs_fs_type);\n\tecryptfs_free_kmem_caches();\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":181030,"func":"void ChromePasswordManagerClient::ShowPasswordGenerationPopup(\n    password_manager::ContentPasswordManagerDriver* driver,\n    const autofill::password_generation::PasswordGenerationUIData& ui_data,\n    bool is_manually_triggered) {\n  DCHECK(driver);\n  gfx::RectF element_bounds_in_top_frame_space =\n      TransformToRootCoordinates(driver->render_frame_host(), ui_data.bounds);\n  if (!is_manually_triggered &&\n      driver->GetPasswordAutofillManager()\n          ->MaybeShowPasswordSuggestionsWithGeneration(\n              element_bounds_in_top_frame_space, ui_data.text_direction)) {\n    return;\n  }\n\n  gfx::RectF element_bounds_in_screen_space =\n      GetBoundsInScreenSpace(element_bounds_in_top_frame_space);\n  password_manager_.SetGenerationElementAndReasonForForm(\n      driver, ui_data.password_form, ui_data.generation_element,\n      is_manually_triggered);\n\n  popup_controller_ = PasswordGenerationPopupControllerImpl::GetOrCreate(\n      popup_controller_, element_bounds_in_screen_space, ui_data.password_form,\n      ui_data.generation_element, ui_data.max_length, &password_manager_,\n      driver->AsWeakPtr(), observer_, web_contents(),\n      web_contents()->GetNativeView());\n  popup_controller_->Show(PasswordGenerationPopupController::kOfferGeneration);\n}\n","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":205227,"func":"base::TimeDelta GetWakeUpDuration() {\n  int duration_ms;\n  if (!base::StringToInt(base::GetFieldTrialParamValue(kWakeUpThrottlingTrial,\n                                                       kWakeUpDurationParam),\n                         &duration_ms))\n    return kDefaultWakeUpDuration;\n  return base::TimeDelta::FromMilliseconds(duration_ms);\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":489453,"func":"static JSValue js_sys_crc32(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)\n{\n\tconst u8 *data;\n\tsize_t data_size;\n\n\tif (!argc) return GF_JS_EXCEPTION(ctx);\n\tif (JS_IsString(argv[0])) {\n\t\tu32 crc=0;\n\t\tconst char *str = JS_ToCString(ctx, argv[0]);\n\t\tif (str) {\n\t\t\tcrc = gf_crc_32(str, (u32) strlen(str) );\n\t\t\tJS_FreeCString(ctx, str);\n\t\t}\n\t\treturn JS_NewInt32(ctx, crc );\n\t} else {\n\t\tdata = JS_GetArrayBuffer(ctx, &data_size, argv[0] );\n\t\tif (!data) return GF_JS_EXCEPTION(ctx);\n\t\treturn JS_NewInt32(ctx, gf_crc_32(data, (u32) data_size) );\n\t}\n\treturn GF_JS_EXCEPTION(ctx);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":120769,"func":"  OpContext(TfLiteContext* context, TfLiteNode* node) {\n    input = GetInput(context, node, 0);\n    ref = GetInput(context, node, 1);\n  }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":227466,"func":"copy_xml(xmlNode * src)\n{\n    xmlDoc *doc = xmlNewDoc((const xmlChar *)\"1.0\");\n    xmlNode *copy = xmlDocCopyNode(src, doc, 1);\n\n    xmlDocSetRootElement(doc, copy);\n    xmlSetTreeDoc(copy, doc);\n    return copy;\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":337937,"func":"static void cris_alu(DisasContext *dc, int op,\n\n\t\t\t       TCGv d, TCGv op_a, TCGv op_b, int size)\n\n{\n\n\tTCGv tmp;\n\n\tint writeback;\n\n\n\n\twriteback = 1;\n\n\n\n\tif (op == CC_OP_BOUND || op == CC_OP_BTST)\n\n\t\ttmp = tcg_temp_local_new(TCG_TYPE_TL);\n\n\telse\n\n\t\ttmp = tcg_temp_new(TCG_TYPE_TL);\n\n\n\n\tif (op == CC_OP_CMP) {\n\n\t\twriteback = 0;\n\n\t} else if (size == 4) {\n\n\t\ttmp = d;\n\n\t\twriteback = 0;\n\n\t}\n\n\n\n\tcris_pre_alu_update_cc(dc, op, op_a, op_b, size);\n\n\tcris_alu_op_exec(dc, op, tmp, op_a, op_b, size);\n\n\tcris_update_result(dc, tmp);\n\n\n\n\t\/* Writeback.  *\/\n\n\tif (writeback) {\n\n\t\tif (size == 1)\n\n\t\t\ttcg_gen_andi_tl(d, d, ~0xff);\n\n\t\telse\n\n\t\t\ttcg_gen_andi_tl(d, d, ~0xffff);\n\n\t\ttcg_gen_or_tl(d, d, tmp);\n\n\t}\n\n\tif (tmp != d)\n\n\t\ttcg_temp_free(tmp);\n\n}\n","target":1,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":229181,"func":"void IPCThreadState::decWeakHandle(int32_t handle)\n{\n    LOG_REMOTEREFS(\"IPCThreadState::decWeakHandle(%d)\\n\", handle);\n    mOut.writeInt32(BC_DECREFS);\n    mOut.writeInt32(handle);\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":384162,"func":"            Status readCString( StringData* out ) {\n                const void* x = memchr( _buffer + _position, 0, _maxLength - _position );\n                if ( !x )\n                    return makeError(\"no end of c-string\", _idElem);\n                uint64_t len = static_cast<uint64_t>( static_cast<const char*>(x) - ( _buffer + _position ) );\n\n                StringData data( _buffer + _position, len );\n                _position += len + 1;\n\n                if ( out ) {\n                    *out = data;\n                }\n                return Status::OK();\n            }","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":311728,"func":"const char *sc_get_version(void)\n{\n    return sc_version;\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":436366,"func":"euckr_mbc_to_code(const UChar* p, const UChar* end)\n{\n  return onigenc_mbn_mbc_to_code(ONIG_ENCODING_EUC_KR, p, end);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":195934,"func":"  void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {\n    EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);\n    gesture_run_loop_->Quit();\n  }\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":39741,"func":"static struct kwajd_stream *lzh_init(struct mspack_system *sys,\n    struct mspack_file *in, struct mspack_file *out)\n{\n    struct kwajd_stream *lzh;\n\n    if (!sys || !in || !out) return NULL;\n    if (!(lzh = (struct kwajd_stream *) sys->alloc(sys, sizeof(struct kwajd_stream)))) return NULL;\n\n    lzh->sys    = sys;\n    lzh->input  = in;\n    lzh->output = out;\n    return lzh;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":302515,"func":"bool ethereum_getStandardERC20Amount(const EthereumSignTx *msg,\n                                     void **tx_out_amount) {\n  const ExchangeType *exchange = &msg->exchange_type;\n  size_t size =\n      exchange->signed_exchange_response.responseV2.deposit_amount.size;\n  if (32 < size) return false;\n\n  \/\/ Make sure the value in data_initial_chunk contains the correct number of\n  \/\/ leading zeroes (as compared to what the exchange contract wants).\n  char *value = (char *)msg->data_initial_chunk.bytes + 36;\n  if (memcmp(value,\n             \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n             \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n             32 - size) != 0)\n    return false;\n\n  *tx_out_amount = value + (32 - size);\n  return true;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":307081,"func":"PDFiumEngine::SelectionChangeInvalidator::SelectionChangeInvalidator(\n    PDFiumEngine* engine)\n    : engine_(engine),\n      previous_origin_(engine_->GetVisibleRect().point()),\n      old_selections_(GetVisibleSelections()) {}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":142380,"func":"static GF_ISOSAPType sap_type_from_nal_type(u8 nal_type) {\n\tswitch (nal_type) {\n\tcase GF_HEVC_NALU_SLICE_CRA:\n\t\treturn SAP_TYPE_3;\n\tcase GF_HEVC_NALU_SLICE_IDR_N_LP:\n\tcase GF_HEVC_NALU_SLICE_BLA_N_LP:\n\t\treturn SAP_TYPE_1;\n\tcase GF_HEVC_NALU_SLICE_IDR_W_DLP:\n\tcase GF_HEVC_NALU_SLICE_BLA_W_DLP:\n\tcase GF_HEVC_NALU_SLICE_BLA_W_LP:\n\t\treturn SAP_TYPE_2;\n\tdefault:\n\t\treturn RAP_NO;\n\t}\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":167101,"func":"ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC) \/* {{{ *\/\n{\n\tzval *tmp;\n\n\tALLOC_ZVAL(tmp);\n\tZ_UNSET_ISREF_P(tmp);\n\tZ_SET_REFCOUNT_P(tmp, 0);\n\tZVAL_DOUBLE(tmp, value);\n\treturn zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);\n}\n\/* }}} *\/\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":8488,"func":"psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf)\n{\tsf_count_t total = 0 ;\n\tssize_t\tcount ;\n\n\tif (psf->virtual_io)\n\t\treturn psf->vio.write (ptr, bytes*items, psf->vio_user_data) \/ bytes ;\n\n\titems *= bytes ;\n\n\t\/* Do this check after the multiplication above. *\/\n\tif (items <= 0)\n\t\treturn 0 ;\n\n\twhile (items > 0)\n\t{\t\/* Break the writes down to a sensible size. *\/\n\t\tcount = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ;\n\n\t\tcount = write (psf->file.filedes, ((const char*) ptr) + total, count) ;\n\n\t\tif (count == -1)\n\t\t{\tif (errno == EINTR)\n\t\t\t\tcontinue ;\n\n\t\t\tpsf_log_syserr (psf, errno) ;\n\t\t\tbreak ;\n\t\t\t} ;\n\n\t\tif (count == 0)\n\t\t\tbreak ;\n\n\t\ttotal += count ;\n\t\titems -= count ;\n\t\t} ;\n\n\treturn total \/ bytes ;\n} \/* psf_fwrite *\/","target":1,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":322582,"func":"int nbd_client_session_co_readv(NbdClientSession *client, int64_t sector_num,\n\n    int nb_sectors, QEMUIOVector *qiov)\n\n{\n\n    int offset = 0;\n\n    int ret;\n\n    while (nb_sectors > NBD_MAX_SECTORS) {\n\n        ret = nbd_co_readv_1(client, sector_num,\n\n                             NBD_MAX_SECTORS, qiov, offset);\n\n        if (ret < 0) {\n\n            return ret;\n\n        }\n\n        offset += NBD_MAX_SECTORS * 512;\n\n        sector_num += NBD_MAX_SECTORS;\n\n        nb_sectors -= NBD_MAX_SECTORS;\n\n    }\n\n    return nbd_co_readv_1(client, sector_num, nb_sectors, qiov, offset);\n\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":496515,"func":"  std::string index(Vertex_iterator v) const\n  { return VI(v,verbose); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":462757,"func":"TEST_F(QueryPlannerTest, NoMutationsForCollscan) {\n    params.options = QueryPlannerParams::KEEP_MUTATIONS;\n    runQuery(fromjson(\"\"));\n    assertSolutionExists(\"{cscan: {dir: 1}}\");\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":479384,"func":"    CImg<Tuchar> get_RGBtoCMY() const {\n      return CImg<Tfloat>(*this,false).RGBtoCMY();\n    }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":91695,"func":"void MainWindow::setPreviewScale(int scale)\n{\n    LOG_DEBUG() << scale;\n    switch (scale) {\n    case 360:\n        ui->actionPreview360->setChecked(true);\n        break;\n    case 540:\n        ui->actionPreview540->setChecked(true);\n        break;\n    case 720:\n        ui->actionPreview720->setChecked(true);\n        break;\n    default:\n        ui->actionPreviewNone->setChecked(true);\n        break;\n    }\n    MLT.setPreviewScale(scale);\n    MLT.refreshConsumer();\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":38041,"func":"void mg_unhex(const char *buf, size_t len, unsigned char *to) {\n  size_t i;\n  for (i = 0; i < len; i += 2) {\n    to[i >> 1] = (unsigned char) mg_unhexn(&buf[i], 2);\n  }\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":47980,"func":"static void xfrm_byidx_resize(struct net *net, int total)\n{\n\tunsigned int hmask = net->xfrm.policy_idx_hmask;\n\tunsigned int nhashmask = xfrm_new_hash_mask(hmask);\n\tunsigned int nsize = (nhashmask + 1) * sizeof(struct hlist_head);\n\tstruct hlist_head *oidx = net->xfrm.policy_byidx;\n\tstruct hlist_head *nidx = xfrm_hash_alloc(nsize);\n\tint i;\n\n\tif (!nidx)\n\t\treturn;\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\n\tfor (i = hmask; i >= 0; i--)\n\t\txfrm_idx_hash_transfer(oidx + i, nidx, nhashmask);\n\n\tnet->xfrm.policy_byidx = nidx;\n\tnet->xfrm.policy_idx_hmask = nhashmask;\n\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\n\txfrm_hash_free(oidx, (hmask + 1) * sizeof(struct hlist_head));\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":298733,"func":"sockaddr_getport(struct sockaddr *sa)\n{\n\tif (sa->sa_family == AF_INET) {\n\t\treturn ntohs(((struct sockaddr_in *)sa)->sin_port);\n\t} else if (sa->sa_family == AF_INET6) {\n\t\treturn ntohs(((struct sockaddr_in6 *)sa)->sin6_port);\n\t} else {\n\t\treturn 0;\n\t}\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":311031,"func":"jsonb_to_recordset(PG_FUNCTION_ARGS)\n{\n\treturn populate_recordset_worker(fcinfo, \"jsonb_to_recordset\", false);\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":410906,"func":"static int bufsize_v4l2_create(struct v4l2_create_buffers32 __user *up,\n\t\t\t       u32 *size)\n{\n\tif (!access_ok(VERIFY_READ, up, sizeof(*up)))\n\t\treturn -EFAULT;\n\treturn __bufsize_v4l2_format(&up->format, size);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":19650,"func":"static void send_version_response ( int fd , version_ack_t ack , uint32_t payload , int userid , struct query * q ) {\n char out [ 9 ] ;\n switch ( ack ) {\n case VERSION_ACK : strncpy ( out , \"VACK\" , sizeof ( out ) ) ;\n break ;\n case VERSION_NACK : strncpy ( out , \"VNAK\" , sizeof ( out ) ) ;\n break ;\n case VERSION_FULL : strncpy ( out , \"VFUL\" , sizeof ( out ) ) ;\n break ;\n }\n out [ 4 ] = ( ( payload >> 24 ) & 0xff ) ;\n out [ 5 ] = ( ( payload >> 16 ) & 0xff ) ;\n out [ 6 ] = ( ( payload >> 8 ) & 0xff ) ;\n out [ 7 ] = ( ( payload ) & 0xff ) ;\n out [ 8 ] = userid & 0xff ;\n write_dns ( fd , q , out , sizeof ( out ) , users [ userid ] . downenc ) ;\n }","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":208843,"func":"void InputMethodIMM32::OnDidChangeFocusedClient(TextInputClient* focused_before,\n                                                TextInputClient* focused) {\n  if (IsWindowFocused(focused)) {\n    OnTextInputTypeChanged(focused);\n\n    UpdateIMEState();\n\n    OnCaretBoundsChanged(focused);\n  }\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":30771,"func":"static gboolean gtkui_connections_scroll ( gpointer data ) {\n gint * type = data ;\n if ( type == NULL ) return FALSE ;\n if ( * type == 1 && textview1 && endmark1 && textview2 && endmark2 ) {\n gtk_text_view_scroll_to_mark ( GTK_TEXT_VIEW ( textview1 ) , endmark1 , 0 , FALSE , 0 , 0 ) ;\n gtk_text_view_scroll_to_mark ( GTK_TEXT_VIEW ( textview2 ) , endmark2 , 0 , FALSE , 0 , 0 ) ;\n }\n else if ( textview3 && endmark3 ) {\n gtk_text_view_scroll_to_mark ( GTK_TEXT_VIEW ( textview3 ) , endmark3 , 0 , FALSE , 0 , 0 ) ;\n }\n return ( FALSE ) ;\n }","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":64297,"func":"GF_Err cslg_box_size(GF_Box *s)\n{\n\tGF_CompositionToDecodeBox *ptr = (GF_CompositionToDecodeBox *)s;\n\n\tptr->size += 20;\n\treturn GF_OK;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":177817,"func":"  void Wait(size_t number_of_messages) {\n    while (intercepted_messages_.size() < number_of_messages) {\n      loop_.reset(new base::RunLoop);\n      loop_->Run();\n    }\n  }\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":47642,"func":"gid_t enc_untrusted_getgid() {\n  return EnsureInitializedAndDispatchSyscall(asylo::system_call::kSYS_getgid);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":273332,"func":"free_global ()\n{\n     xfree(clamd_local);\n     xfree(clamd_ip);\n     xfree(clamd_port);\n     xfree(clamd_curr_ip);\n     xfree(redirect_url);\n     if (patterns != NULL) {\n\twhile (pattc > 0) {\n\t   pattc--;\n\t   regfree(&patterns[pattc].regexv);\n\t   xfree(patterns[pattc].pattern);\n\t}\n\tfree(patterns);\n\tpatterns = NULL;\n     }\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":187732,"func":"static int wifi_get_multicast_id(wifi_handle handle, const char *name, const char *group)\n{\n GetMulticastIdCommand cmd(handle, name, group);\n int res = cmd.requestResponse();\n if (res < 0)\n return res;\n else\n return cmd.getId();\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":72992,"func":"SCTP_STATIC int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len)\n{\n\tint retval = 0;\n\n\tsctp_lock_sock(sk);\n\n\tSCTP_DEBUG_PRINTK(\"sctp_bind(sk: %p, addr: %p, addr_len: %d)\\n\",\n\t\t\t  sk, addr, addr_len);\n\n\t\/* Disallow binding twice. *\/\n\tif (!sctp_sk(sk)->ep->base.bind_addr.port)\n\t\tretval = sctp_do_bind(sk, (union sctp_addr *)addr,\n\t\t\t\t      addr_len);\n\telse\n\t\tretval = -EINVAL;\n\n\tsctp_release_sock(sk);\n\n\treturn retval;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":114330,"func":"static void claim_allocations(int cpu, struct sched_domain *sd)\n{\n\tstruct sd_data *sdd = sd->private;\n\n\tWARN_ON_ONCE(*per_cpu_ptr(sdd->sd, cpu) != sd);\n\t*per_cpu_ptr(sdd->sd, cpu) = NULL;\n\n\tif (atomic_read(&(*per_cpu_ptr(sdd->sg, cpu))->ref))\n\t\t*per_cpu_ptr(sdd->sg, cpu) = NULL;\n\n\tif (atomic_read(&(*per_cpu_ptr(sdd->sgp, cpu))->ref))\n\t\t*per_cpu_ptr(sdd->sgp, cpu) = NULL;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":293045,"func":"bool Socket::writeChunk( char *buffout, int len, int timeout){\n    std::stringstream stm;\n    stm << std::hex << len;\n    std::string hexs (stm.str());\n    \/\/int lw;\n    hexs += \"\\r\\n\";\n#ifdef NETDEBUG\n    std::cerr << thread_id << \"writeChunk  size=\" << hexs << std::endl;\n#endif\n    if(writeString(hexs.c_str()) && writeToSocket(buffout,len,0,timeout) && writeString(\"\\r\\n\"))\n        return true;\n    return false;\n};","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":20337,"func":"static int dissect_h225_Endpoint ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h225_Endpoint , Endpoint_sequence ) ;\n return offset ;\n }","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":149036,"func":"static int __init set_init_cxt(void)\n{\n\tstruct cred *cred = (struct cred *)current->real_cred;\n\tstruct aa_task_cxt *cxt;\n\n\tcxt = aa_alloc_task_context(GFP_KERNEL);\n\tif (!cxt)\n\t\treturn -ENOMEM;\n\n\tcxt->profile = aa_get_profile(root_ns->unconfined);\n\tcred_cxt(cred) = cxt;\n\n\treturn 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":450472,"func":"static void nfs4_setclientid_done(struct rpc_task *task, void *calldata)\n{\n\tstruct nfs4_setclientid *sc = calldata;\n\n\tif (task->tk_status == 0)\n\t\tsc->sc_cred = get_rpccred(task->tk_rqstp->rq_cred);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":166705,"func":"static char** Sys_ConcatenateFileLists( char **list0, char **list1 )\n{\n\tint totalLength = 0;\n\tchar** cat = NULL, **dst, **src;\n\n\ttotalLength += Sys_CountFileList(list0);\n\ttotalLength += Sys_CountFileList(list1);\n\n\t\/* Create new list. *\/\n\tdst = cat = Z_Malloc( ( totalLength + 1 ) * sizeof( char* ) );\n\n\t\/* Copy over lists. *\/\n\tif (list0)\n\t{\n\t\tfor (src = list0; *src; src++, dst++)\n\t\t\t*dst = *src;\n\t}\n\tif (list1)\n\t{\n\t\tfor (src = list1; *src; src++, dst++)\n\t\t\t*dst = *src;\n\t}\n\n\t*dst = NULL;\n\n\tif (list0) Z_Free( list0 );\n\tif (list1) Z_Free( list1 );\n\n\treturn cat;\n}\n","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":480178,"func":"static void sortGlobResult(glob_t *result, size_t prefix_len, const char *dformat) {\n    \/* TODO *\/\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":12103,"func":"PHP_METHOD(Phar, addFromString)\n{\n\tchar *localname, *cont_str;\n\tsize_t localname_len, cont_len;\n \n        PHAR_ARCHIVE_OBJECT();\n \n       if (zend_parse_parameters(ZEND_NUM_ARGS(), \"ss\", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {\n                return;\n        }\n \n\tphar_add_file(&(phar_obj->archive), localname, localname_len, cont_str, cont_len, NULL);\n}\n","target":1,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":213991,"func":"static int share_access_to_flags(u32 share_access)\n{\n\treturn share_access == NFS4_SHARE_ACCESS_READ ? RD_STATE : WR_STATE;\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":104609,"func":"MONGO_EXPORT void bson_iterator_code_scope( const bson_iterator *i, bson *scope ) {\n    if ( bson_iterator_type( i ) == BSON_CODEWSCOPE ) {\n        int code_len;\n        bson_little_endian32( &code_len, bson_iterator_value( i )+4 );\n        bson_init_data( scope, ( void * )( bson_iterator_value( i )+8+code_len ) );\n        _bson_reset( scope );\n        scope->finished = 1;\n    }\n    else {\n        bson_empty( scope );\n    }\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":338387,"func":"int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y)\n\n{\n\n    switch (mode) {\n\n    case DC_PRED8x8:\n\n        return check_dc_pred8x8_mode(mode, mb_x, mb_y);\n\n    case VERT_PRED8x8:\n\n        return !mb_y ? DC_127_PRED8x8 : mode;\n\n    case HOR_PRED8x8:\n\n        return !mb_x ? DC_129_PRED8x8 : mode;\n\n    case PLANE_PRED8x8: \/* TM *\/\n\n        return check_tm_pred8x8_mode(mode, mb_x, mb_y);\n\n    }\n\n    return mode;\n\n}\n","target":1,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":381430,"func":"cmd_getattr (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  const char *keyword;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  keyword = line;\n  for (; *line && !spacep (line); line++)\n    ;\n  if (*line)\n      *line++ = 0;\n\n  \/* (We ignore any garbage for now.) *\/\n\n  \/* FIXME: Applications should not return sensitive data if the card\n     is locked.  *\/\n  rc = app_getattr (ctrl->app_ctx, ctrl, keyword);\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":379531,"func":"static int ZEND_FASTCALL  ZEND_SEND_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\n\tif ((opline->extended_value == ZEND_DO_FCALL_BY_NAME)\n\t\t&& ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) {\n\t\treturn ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\t}\n\treturn zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":244788,"func":"static void reflectedTreatNullAsNullStringTreatUndefinedAsNullStringURLAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n    TestObjectV8Internal::reflectedTreatNullAsNullStringTreatUndefinedAsNullStringURLAttrAttributeGetter(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":290269,"func":"int ff_h263_decode_mba ( MpegEncContext * s ) {\n int i , mb_pos ;\n for ( i = 0 ;\n i < 6 ;\n i ++ ) {\n if ( s -> mb_num - 1 <= ff_mba_max [ i ] ) break ;\n }\n mb_pos = get_bits ( & s -> gb , ff_mba_length [ i ] ) ;\n s -> mb_x = mb_pos % s -> mb_width ;\n s -> mb_y = mb_pos \/ s -> mb_width ;\n return mb_pos ;\n }","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":494020,"func":"  TinyGLTF() : bin_data_(nullptr), bin_size_(0), is_binary_(false) {}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":465837,"func":"static void fuse_sb_defaults(struct super_block *sb)\n{\n\tsb->s_magic = FUSE_SUPER_MAGIC;\n\tsb->s_op = &fuse_super_operations;\n\tsb->s_xattr = fuse_xattr_handlers;\n\tsb->s_maxbytes = MAX_LFS_FILESIZE;\n\tsb->s_time_gran = 1;\n\tsb->s_export_op = &fuse_export_operations;\n\tsb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE;\n\tif (sb->s_user_ns != &init_user_ns)\n\t\tsb->s_iflags |= SB_I_UNTRUSTED_MOUNTER;\n\tsb->s_flags &= ~(SB_NOSEC | SB_I_VERSION);\n\n\t\/*\n\t * If we are not in the initial user namespace posix\n\t * acls must be translated.\n\t *\/\n\tif (sb->s_user_ns != &init_user_ns)\n\t\tsb->s_xattr = fuse_no_acl_xattr_handlers;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":304207,"func":"void _single_copy_from_wide( SQLCHAR *out, LPCWSTR in, int len )\n{\n    while ( len >= 0 )\n    {\n        *out = *in;\n        out++;\n        in++;\n        len --;\n    }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":480514,"func":"void DL_Dxf::addLayer(DL_CreationInterface* creationInterface) {\n    \/\/ correct some invalid attributes for layers:\n    attrib = creationInterface->getAttributes();\n    if (attrib.getColor()==256 || attrib.getColor()==0) {\n        attrib.setColor(7);\n    }\n    if (attrib.getWidth()<0) {\n        attrib.setWidth(1);\n    }\n\n    std::string linetype = attrib.getLinetype();\n    std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper);\n    if (linetype==\"BYLAYER\" || linetype==\"BYBLOCK\") {\n        attrib.setLinetype(\"CONTINUOUS\");\n    }\n\n    \/\/ add layer\n    std::string name = getStringValue(2, \"\");\n    if (name.length()==0) {\n        return;\n    }\n\n    creationInterface->addLayer(DL_LayerData(name, getIntValue(70, 0)));\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":226659,"func":"void GetLocalFileSizeOnBlockingPool(const FilePath& local_file,\n                                    GDataFileError* error,\n                                    int64* file_size) {\n  DCHECK(error);\n  DCHECK(file_size);\n\n  *file_size = 0;\n  *error = file_util::GetFileSize(local_file, file_size) ?\n      GDATA_FILE_OK :\n      GDATA_FILE_ERROR_NOT_FOUND;\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":302569,"func":"    **\/\n    static const CImg<Tuchar>& flag_LUT256() {\n      static CImg<Tuchar> colormap;\n      cimg::mutex(8);\n      if (!colormap) {\n        colormap.assign(1,4,1,3,(T)0);\n        colormap[0] = colormap[1] = colormap[5] = colormap[9] = colormap[10] = 255;\n        colormap.resize(1,256,1,3,0,2);\n      }\n      cimg::mutex(8,0);\n      return colormap;","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":361013,"func":"is_user_switch_enabled (GSWindow *window)\n{\n        return window->priv->user_switch_enabled;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":263735,"func":"static inline void write_gdt_entry(struct desc_struct *dt, int entry,\n\t\t\t\t   void *desc, int type)\n{\n\tPVOP_VCALL4(cpu.write_gdt_entry, dt, entry, desc, type);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":27746,"func":"static inline uint32_t vmsvga_fifo_read ( struct vmsvga_state_s * s ) {\n return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ;\n }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":211589,"func":"static int __gup_device_huge(unsigned long pfn, unsigned long addr,\n\t\tunsigned long end, struct page **pages, int *nr)\n{\n\tint nr_start = *nr;\n\tstruct dev_pagemap *pgmap = NULL;\n\n\tdo {\n\t\tstruct page *page = pfn_to_page(pfn);\n\n\t\tpgmap = get_dev_pagemap(pfn, pgmap);\n\t\tif (unlikely(!pgmap)) {\n\t\t\tundo_dev_pagemap(nr, nr_start, pages);\n\t\t\treturn 0;\n\t\t}\n\t\tSetPageReferenced(page);\n\t\tpages[*nr] = page;\n\t\tget_page(page);\n\t\t(*nr)++;\n\t\tpfn++;\n\t} while (addr += PAGE_SIZE, addr != end);\n\n\tif (pgmap)\n\t\tput_dev_pagemap(pgmap);\n\treturn 1;\n}\n","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":371297,"func":"uint8_t* ZRtp::getSasHash() {\n    return sasHash;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":177068,"func":"int equalizer_get_center_frequency(equalizer_context_t *context __unused, int32_t band)\n{\n    ALOGV(\"%s: band: %d\", __func__, band);\n return (equalizer_band_freq_range[band][0] +\n            equalizer_band_freq_range[band][1]) \/ 2;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":16884,"func":"static TRBCCode xhci_disable_ep ( XHCIState * xhci , unsigned int slotid , unsigned int epid ) {\n XHCISlot * slot ;\n XHCIEPContext * epctx ;\n trace_usb_xhci_ep_disable ( slotid , epid ) ;\n assert ( slotid >= 1 && slotid <= xhci -> numslots ) ;\n assert ( epid >= 1 && epid <= 31 ) ;\n slot = & xhci -> slots [ slotid - 1 ] ;\n if ( ! slot -> eps [ epid - 1 ] ) {\n DPRINTF ( \"xhci: slot %d ep %d already disabled\\n\" , slotid , epid ) ;\n return CC_SUCCESS ;\n }\n xhci_ep_nuke_xfers ( xhci , slotid , epid , 0 ) ;\n epctx = slot -> eps [ epid - 1 ] ;\n if ( epctx -> nr_pstreams ) {\n xhci_free_streams ( epctx ) ;\n }\n if ( xhci -> dcbaap_low || xhci -> dcbaap_high ) {\n xhci_set_ep_state ( xhci , epctx , NULL , EP_DISABLED ) ;\n }\n timer_free ( epctx -> kick_timer ) ;\n g_free ( epctx ) ;\n slot -> eps [ epid - 1 ] = NULL ;\n return CC_SUCCESS ;\n }","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":457007,"func":"static int io_fadvise(struct io_kiocb *req, struct io_kiocb **nxt,\n\t\t      bool force_nonblock)\n{\n\tstruct io_fadvise *fa = &req->fadvise;\n\tint ret;\n\n\tif (force_nonblock) {\n\t\tswitch (fa->advice) {\n\t\tcase POSIX_FADV_NORMAL:\n\t\tcase POSIX_FADV_RANDOM:\n\t\tcase POSIX_FADV_SEQUENTIAL:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EAGAIN;\n\t\t}\n\t}\n\n\tret = vfs_fadvise(req->file, fa->offset, fa->len, fa->advice);\n\tif (ret < 0)\n\t\treq_set_fail_links(req);\n\tio_cqring_add_event(req, ret);\n\tio_put_req_find_next(req, nxt);\n\treturn 0;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":403718,"func":"PHP_FUNCTION( msgfmt_parse )\n{\n\tchar *source;\n\tsize_t source_len;\n\tMSG_FORMAT_METHOD_INIT_VARS;\n\n\n\t\/* Parse parameters. *\/\n\tif( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), \"Os\",\n\t\t&object, MessageFormatter_ce_ptr,  &source, &source_len ) == FAILURE )\n\t{\n\t\tintl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,\n\t\t\t\"msgfmt_parse: unable to parse input params\", 0 );\n\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* Fetch the object. *\/\n\tMSG_FORMAT_METHOD_FETCH_OBJECT;\n\n\tmsgfmt_do_parse(mfo, source, source_len, return_value);\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":148496,"func":"PJ_DEF(int) pj_scan_stricmp( pj_scanner *scanner, const char *s, int len)\n{\n    if (scanner->curptr + len > scanner->end) {\n\tpj_scan_syntax_err(scanner);\n\treturn -1;\n    }\n    return pj_ansi_strnicmp(scanner->curptr, s, len);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":250717,"func":"poppler_page_init (PopplerPage *page)\n{\n}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":61581,"func":"mrb_obj_singleton_methods_m(mrb_state *mrb, mrb_value self)\n{\n  mrb_bool recur = TRUE;\n  mrb_get_args(mrb, \"|b\", &recur);\n  return mrb_obj_singleton_methods(mrb, recur, self);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":357715,"func":"static int key_get_type_from_user(char *type,\n\t\t\t\t  const char __user *_type,\n\t\t\t\t  unsigned len)\n{\n\tint ret;\n\n\tret = strncpy_from_user(type, _type, len);\n\n\tif (ret < 0)\n\t\treturn -EFAULT;\n\n\tif (ret == 0 || ret >= len)\n\t\treturn -EINVAL;\n\n\tif (type[0] == '.')\n\t\treturn -EPERM;\n\n\ttype[len - 1] = '\\0';\n\n\treturn 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":307191,"func":"bool NotificationsEngine::registerDBusService()\n{\n    QDBusConnection dbus = QDBusConnection::sessionBus();\n    bool so = dbus.registerService(QStringLiteral(\"org.freedesktop.Notifications\"));\n    if (so) {\n        bool ro = dbus.registerObject(QStringLiteral(\"\/org\/freedesktop\/Notifications\"), this);\n        if (ro) {\n            qDebug() << \"Notifications service registered\";\n            return true;\n        } else {\n            dbus.unregisterService(QStringLiteral(\"org.freedesktop.Notifications\"));\n        }\n    }\n\n    qDebug() << \"Failed to register Notifications service\";\n    return false;\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":97840,"func":"writeSWFShapeBlockToMethod(SWFBlock block, \n                           SWFByteOutputMethod method, void* data)\n{\n\tSWFOutput out = ((SWFShape)block)->out;\n\tSWFOutput_writeToMethod(out, method, data);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":316394,"func":"static bool CombineClip(const ClipPaintPropertyNode* clip,\n                        FloatRoundedRect& combined_clip_rect) {\n  if (clip->Parent()->ClipPath())\n    return false;\n\n  if (clip->LocalTransformSpace() != clip->Parent()->LocalTransformSpace() &&\n      !GeometryMapper::SourceToDestinationProjection(\n           clip->Parent()->LocalTransformSpace(), clip->LocalTransformSpace())\n           .IsIdentity())\n    return false;\n\n  bool clip_is_rounded = clip->ClipRect().IsRounded();\n  bool combined_is_rounded = combined_clip_rect.IsRounded();\n  if (clip_is_rounded && combined_is_rounded)\n    return false;\n\n  if (combined_is_rounded)\n    return clip->ClipRect().Rect().Contains(combined_clip_rect.Rect());\n  if (clip_is_rounded) {\n    if (combined_clip_rect.Rect().Contains(clip->ClipRect().Rect())) {\n      combined_clip_rect = clip->ClipRect();\n      return true;\n    }\n    return false;\n  }\n\n  DCHECK(!combined_is_rounded && !clip_is_rounded);\n  combined_clip_rect = FloatRoundedRect(\n      Intersection(combined_clip_rect.Rect(), clip->ClipRect().Rect()));\n  return true;\n}\n","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":76319,"func":"static void kvm_ioapic_inject_all(struct kvm_ioapic *ioapic, unsigned long irr)\n{\n\tu32 idx;\n\n\trtc_irq_eoi_tracking_reset(ioapic);\n\tfor_each_set_bit(idx, &irr, IOAPIC_NUM_PINS)\n\t\tioapic_set_irq(ioapic, idx, 1, true);\n\n\tkvm_rtc_eoi_tracking_restore_all(ioapic);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":430208,"func":"void Downstream::inspect_http1_response() {\n  auto transfer_encoding = resp_.fs.header(http2::HD_TRANSFER_ENCODING);\n  if (transfer_encoding) {\n    resp_.fs.content_length = -1;\n    if (util::iends_with_l(transfer_encoding->value, \"chunked\")) {\n      chunked_response_ = true;\n    }\n  }\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":45321,"func":"int wc_ecc_copy_point(ecc_point* p, ecc_point *r)\n{\n    int ret;\n\n    \/* prevents null arguments *\/\n    if (p == NULL || r == NULL)\n        return ECC_BAD_ARG_E;\n\n    ret = mp_copy(p->x, r->x);\n    if (ret != MP_OKAY)\n        return ret;\n    ret = mp_copy(p->y, r->y);\n    if (ret != MP_OKAY)\n        return ret;\n    ret = mp_copy(p->z, r->z);\n    if (ret != MP_OKAY)\n        return ret;\n\n    return MP_OKAY;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":98005,"func":"static void do_foot(HttpResponse res) {\n        StringBuffer_append(res->outputbuffer,\n                            \"<\/center><\/div><\/div>\"\n                            \"<div id='footer'>\"\n                            \"Copyright © 2001-2018 <a href=\\\"http:\/\/tildeslash.com\/\\\">Tildeslash<\/a>. All rights reserved. \"\n                            \"<span style='margin-left:5px;'><\/span>\"\n                            \"<a href=\\\"http:\/\/mmonit.com\/monit\/\\\">Monit web site<\/a> | \"\n                            \"<a href=\\\"http:\/\/mmonit.com\/wiki\/\\\">Monit Wiki<\/a> | \"\n                            \"<a href=\\\"http:\/\/mmonit.com\/\\\">M\/Monit<\/a>\"\n                            \"<\/div><\/body><\/html>\");\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":391285,"func":"PHP_FUNCTION(xml_get_current_line_number)\n{\n\txml_parser *parser;\n\tzval *pind;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"r\", &pind) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif ((parser = (xml_parser *)zend_fetch_resource(Z_RES_P(pind), \"XML Parser\", le_xml_parser)) == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\tRETVAL_LONG(XML_GetCurrentLineNumber(parser->parser));\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":464313,"func":"static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)\n{\n\tstruct net_device *ndev = priv->ndev;\n\tstruct phy_device *phydev = ndev->phydev;\n\tu32 val = 0;\n\n\tif (!phydev->duplex)\n\t\treturn val;\n\n\tif (!priv->pause_aneg_en) {\n\t\tif (priv->tx_pause_en)\n\t\t\tval |= MACCFG1_TX_FLOW;\n\t\tif (priv->rx_pause_en)\n\t\t\tval |= MACCFG1_RX_FLOW;\n\t} else {\n\t\tu16 lcl_adv, rmt_adv;\n\t\tu8 flowctrl;\n\t\t\/* get link partner capabilities *\/\n\t\trmt_adv = 0;\n\t\tif (phydev->pause)\n\t\t\trmt_adv = LPA_PAUSE_CAP;\n\t\tif (phydev->asym_pause)\n\t\t\trmt_adv |= LPA_PAUSE_ASYM;\n\n\t\tlcl_adv = linkmode_adv_to_lcl_adv_t(phydev->advertising);\n\t\tflowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);\n\t\tif (flowctrl & FLOW_CTRL_TX)\n\t\t\tval |= MACCFG1_TX_FLOW;\n\t\tif (flowctrl & FLOW_CTRL_RX)\n\t\t\tval |= MACCFG1_RX_FLOW;\n\t}\n\n\treturn val;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":158590,"func":"void WebContents::SetAudioMuted(bool muted) {\n  web_contents()->SetAudioMuted(muted);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":77759,"func":"int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,\n\t\t   unsigned int optlen)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\n\tif (level != SOL_TCP)\n\t\treturn icsk->icsk_af_ops->setsockopt(sk, level, optname,\n\t\t\t\t\t\t     optval, optlen);\n\treturn do_tcp_setsockopt(sk, level, optname, optval, optlen);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":276986,"func":"  void FailLoading() {\n    data_provider()->DidFail(response_generator_->GenerateError());\n    base::RunLoop().RunUntilIdle();\n  }\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":172867,"func":"cmd_http_timeout(CMD_ARGS)\n{\n\tstruct http *hp;\n\n\t(void)cmd;\n\t(void)vl;\n\tCAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);\n\tAN(av[1]);\n\tAZ(av[2]);\n\thp->timeout = (int)(strtod(av[1], NULL) * 1000.0);\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":54542,"func":"Status GetOutputDTypes(EagerOperation* op, DataTypeVector* output_dtypes) {\n  const auto& node_def = op->MutableAttrs()->BuildNodeDef();\n  const OpDef* op_def = nullptr;\n\n  const FunctionDef* function_def =\n      op->EagerContext().FuncLibDef()->Find(op->Name());\n  if (function_def != nullptr) {\n    op_def = &(function_def->signature());\n  } else {\n    TF_RETURN_IF_ERROR(OpDefForOp(op->Name().c_str(), &op_def));\n  }\n\n  TF_RETURN_IF_ERROR(OutputTypesForNode(node_def, *op_def, output_dtypes));\n\n  return Status::OK();\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":248632,"func":"void ThreadableBlobRegistry::finalizeStream(const KURL& url)\nvoid BlobRegistry::finalizeStream(const KURL& url)\n {\n     if (isMainThread()) {\n        if (WebBlobRegistry* registry = blobRegistry())\n            registry->finalizeStream(url);\n     } else {\n         OwnPtr<BlobRegistryContext> context = adoptPtr(new BlobRegistryContext(url));\n         callOnMainThread(&finalizeStreamTask, context.leakPtr());\n    }\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":8619,"func":"qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,\n\t     const char *fmt, ...)\n{\n\tva_list va;\n\tstruct va_format vaf;\n\tchar nfunc[32];\n\n\tmemset(nfunc, 0, sizeof(nfunc));\n\tmemcpy(nfunc, func, sizeof(nfunc) - 1);\n\n\tva_start(va, fmt);\n\n\tvaf.fmt = fmt;\n\tvaf.va = &va;\n\n\tif (likely(qedi) && likely(qedi->pdev))\n\t\tpr_err(\"[%s]:[%s:%d]:%d: %pV\", dev_name(&qedi->pdev->dev),\n\t\t       nfunc, line, qedi->host_no, &vaf);\n\telse\n\t\tpr_err(\"[0000:00:00.0]:[%s:%d]: %pV\", nfunc, line, &vaf);\n\n\tva_end(va);\n}","target":1,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":348664,"func":"void undefer_input(__G)\n    __GDEF\n{\n    if (G.incnt > 0)\n        G.csize += G.incnt;\n    if (G.incnt_leftover > 0) {\n        \/* We know that \"(G.csize < MAXINT)\" so we can cast G.csize to int:\n         * This condition was checked when G.incnt_leftover was set > 0 in\n         * defer_leftover_input(), and it is NOT allowed to touch G.csize\n         * before calling undefer_input() when (G.incnt_leftover > 0)\n         * (single exception: see read_byte()'s  \"G.csize <= 0\" handling) !!\n         *\/\n        G.incnt = G.incnt_leftover + (int)G.csize;\n        G.inptr = G.inptr_leftover - (int)G.csize;\n        G.incnt_leftover = 0;\n    } else if (G.incnt < 0)\n        G.incnt = 0;\n} \/* end function undefer_input() *\/","target":1,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":76917,"func":"ModuleExport void UnregisterPWPImage(void)\n{\n  (void) UnregisterMagickInfo(\"PWP\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":416335,"func":"static int hidp_session_wake_function(wait_queue_entry_t *wait,\n\t\t\t\t      unsigned int mode,\n\t\t\t\t      int sync, void *key)\n{\n\twake_up_interruptible(&hidp_session_wq);\n\treturn false;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":169877,"func":"void WebFrameLoaderClient::frameLoaderDestroyed() {\n  webframe_->Closing();\n  webframe_->Release();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":113031,"func":"static bool link_kind_filtered(const struct net_device *dev,\n\t\t\t       const struct rtnl_link_ops *kind_ops)\n{\n\tif (kind_ops && dev->rtnl_link_ops != kind_ops)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":187509,"func":"SelectionInDOMTree createSelection(const size_t start,\n                                   const size_t end,\n                                   const bool isDirectional,\n                                   Element* element) {\n  const EphemeralRange& startRange =\n      PlainTextRange(0, static_cast<int>(start)).createRange(*element);\n  DCHECK(startRange.isNotNull());\n  const Position& startPosition = startRange.endPosition();\n\n  const EphemeralRange& endRange =\n      PlainTextRange(0, static_cast<int>(end)).createRange(*element);\n  DCHECK(endRange.isNotNull());\n  const Position& endPosition = endRange.endPosition();\n\n  const SelectionInDOMTree& selection =\n      SelectionInDOMTree::Builder()\n          .setBaseAndExtent(startPosition, endPosition)\n          .setIsDirectional(isDirectional)\n          .build();\n  return selection;\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":119669,"func":"static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct dst_entry *dst;\n\n\tskb->dev = bridge_parent(skb->dev);\n\tif (!skb->dev)\n\t\tgoto free_skb;\n\tdst = skb_dst(skb);\n\tif (dst->hh) {\n\t\tneigh_hh_bridge(dst->hh, skb);\n\t\tskb->dev = nf_bridge->physindev;\n\t\treturn br_handle_frame_finish(skb);\n\t} else if (dst->neighbour) {\n\t\t\/* the neighbour function below overwrites the complete\n\t\t * MAC header, so we save the Ethernet source address and\n\t\t * protocol number. *\/\n\t\tskb_copy_from_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN), skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);\n\t\t\/* tell br_dev_xmit to continue with forwarding *\/\n\t\tnf_bridge->mask |= BRNF_BRIDGED_DNAT;\n\t\treturn dst->neighbour->output(skb);\n\t}\nfree_skb:\n\tkfree_skb(skb);\n\treturn 0;\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":252789,"func":"void BackendIO::OpenEntry(const std::string& key, Entry** entry) {\n  operation_ = OP_OPEN;\n  key_ = key;\n  entry_ptr_ = entry;\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":221864,"func":"MagickExport PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,\n  const ssize_t y,const size_t columns,const size_t rows,\n  ExceptionInfo *exception)\n{\n  CacheInfo\n    *restrict cache_info;\n\n  const int\n    id = GetOpenMPThreadId();\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickSignature);\n  assert(image->cache != (Cache) NULL);\n  cache_info=(CacheInfo *) image->cache;\n  assert(cache_info->signature == MagickSignature);\n  if (cache_info->methods.queue_authentic_pixels_handler !=\n       (QueueAuthenticPixelsHandler) NULL)\n    return(cache_info->methods.queue_authentic_pixels_handler(image,x,y,columns,\n      rows,exception));\n  assert(id < (int) cache_info->number_threads);\n  return(QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickFalse,\n    cache_info->nexus_info[id],exception));\n}\n","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":379189,"func":"static int ZEND_FASTCALL  ZEND_CONCAT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op1, free_op2;\n\n\tconcat_function(&EX_T(opline->result.u.var).tmp_var,\n\t\t_get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC),\n\t\t_get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) TSRMLS_CC);\n\tif (free_op1.var) {zval_ptr_dtor(&free_op1.var);};\n\tif (free_op2.var) {zval_ptr_dtor(&free_op2.var);};\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":110454,"func":"static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)\n{\n\t\/*\n\t * If still on the runqueue then deactivate_task()\n\t * was not called and update_curr() has to be done:\n\t *\/\n\tif (prev->on_rq)\n\t\tupdate_curr(cfs_rq);\n\n\t\/* throttle cfs_rqs exceeding runtime *\/\n\tcheck_cfs_rq_runtime(cfs_rq);\n\n\tcheck_spread(cfs_rq, prev);\n\n\tif (prev->on_rq) {\n\t\tupdate_stats_wait_start(cfs_rq, prev);\n\t\t\/* Put 'current' back into the tree. *\/\n\t\t__enqueue_entity(cfs_rq, prev);\n\t\t\/* in !on_rq case, update occurred at dequeue *\/\n\t\tupdate_load_avg(cfs_rq, prev, 0);\n\t}\n\tcfs_rq->curr = NULL;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":97275,"func":"static void edge_set_termios(struct tty_struct *tty,\n\t\tstruct usb_serial_port *port, struct ktermios *old_termios)\n{\n\tstruct edgeport_port *edge_port = usb_get_serial_port_data(port);\n\tunsigned int cflag;\n\n\tcflag = tty->termios.c_cflag;\n\n\tdev_dbg(&port->dev, \"%s - clfag %08x iflag %08x\\n\", __func__,\n\t\ttty->termios.c_cflag, tty->termios.c_iflag);\n\tdev_dbg(&port->dev, \"%s - old clfag %08x old iflag %08x\\n\", __func__,\n\t\told_termios->c_cflag, old_termios->c_iflag);\n\n\tif (edge_port == NULL)\n\t\treturn;\n\t\/* change the port settings to the new ones specified *\/\n\tchange_port_settings(tty, edge_port, old_termios);\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":5025,"func":"mm_zfree(struct mm_master *mm, void *address)\n{\n\tmm_free(mm, address);\n}","target":1,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":262370,"func":"static int ca8210_register_ext_clock(struct spi_device *spi)\n{\n\tstruct device_node *np = spi->dev.of_node;\n\tstruct ca8210_priv *priv = spi_get_drvdata(spi);\n\tstruct ca8210_platform_data *pdata = spi->dev.platform_data;\n\tint ret = 0;\n\n\tif (!np)\n\t\treturn -EFAULT;\n\n\tpriv->clk = clk_register_fixed_rate(\n\t\t&spi->dev,\n\t\tnp->name,\n\t\tNULL,\n\t\t0,\n\t\tpdata->extclockfreq\n\t);\n\n\tif (IS_ERR(priv->clk)) {\n\t\tdev_crit(&spi->dev, \"Failed to register external clk\\n\");\n\t\treturn PTR_ERR(priv->clk);\n\t}\n\tret = of_clk_add_provider(np, of_clk_src_simple_get, priv->clk);\n\tif (ret) {\n\t\tclk_unregister(priv->clk);\n\t\tdev_crit(\n\t\t\t&spi->dev,\n\t\t\t\"Failed to register external clock as clock provider\\n\"\n\t\t);\n\t} else {\n\t\tdev_info(&spi->dev, \"External clock set as clock provider\\n\");\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":119663,"func":"static BOOL update_read_scrblt_order(wStream* s, const ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt)\n{\n\tORDER_FIELD_COORD(1, scrblt->nLeftRect);\n\tORDER_FIELD_COORD(2, scrblt->nTopRect);\n\tORDER_FIELD_COORD(3, scrblt->nWidth);\n\tORDER_FIELD_COORD(4, scrblt->nHeight);\n\tORDER_FIELD_BYTE(5, scrblt->bRop);\n\tORDER_FIELD_COORD(6, scrblt->nXSrc);\n\tORDER_FIELD_COORD(7, scrblt->nYSrc);\n\treturn TRUE;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":123221,"func":"void xen_irq_resume(void)\n{\n\tunsigned int cpu;\n\tstruct irq_info *info;\n\n\t\/* New event-channel space is not 'live' yet. *\/\n\txen_evtchn_resume();\n\n\t\/* No IRQ <-> event-channel mappings. *\/\n\tlist_for_each_entry(info, &xen_irq_list_head, list)\n\t\tinfo->evtchn = 0; \/* zap event-channel binding *\/\n\n\tclear_evtchn_to_irq_all();\n\n\tfor_each_possible_cpu(cpu) {\n\t\trestore_cpu_virqs(cpu);\n\t\trestore_cpu_ipis(cpu);\n\t}\n\n\trestore_pirqs();\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":336484,"func":"int qemu_register_machine(QEMUMachine *m)\n\n{\n\n    TypeInfo ti = {\n\n        .name       = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL),\n\n        .parent     = TYPE_MACHINE,\n\n        .class_init = machine_class_init,\n\n        .class_data = (void *)m,\n\n    };\n\n\n\n    type_register(&ti);\n\n\n\n    return 0;\n\n}\n","target":1,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":385815,"func":"static void pit_realizefn(DeviceState *dev, Error **errp)\n{\n    PITCommonState *pit = PIT_COMMON(dev);\n    PITClass *pc = PIT_GET_CLASS(dev);\n    PITChannelState *s;\n\n    s = &pit->channels[0];\n    \/* the timer 0 is connected to an IRQ *\/\n    s->irq_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pit_irq_timer, s);\n    qdev_init_gpio_out(dev, &s->irq, 1);\n\n    memory_region_init_io(&pit->ioports, OBJECT(pit), &pit_ioport_ops,\n                          pit, \"pit\", 4);\n\n    qdev_init_gpio_in(dev, pit_irq_control, 1);\n\n    pc->parent_realize(dev, errp);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":489951,"func":"authentic_match_card(struct sc_card *card)\n{\n\tstruct sc_context *ctx = card->ctx;\n\tint i;\n\n\tsc_log_hex(ctx, \"try to match card with ATR\", card->atr.value, card->atr.len);\n\ti = _sc_match_atr(card, authentic_known_atrs, &card->type);\n\tif (i < 0)   {\n\t\tsc_log(ctx, \"card not matched\");\n\t\treturn 0;\n\t}\n\n\tsc_log(ctx, \"'%s' card matched\", authentic_known_atrs[i].name);\n\treturn 1;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":206617,"func":"void RenderViewHostImpl::OnDidStartLoading() {\n  delegate_->DidStartLoading(this);\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":514348,"func":"static int message_parse_stream(pool_t pool, struct istream *input,\n\t\t\t\tconst struct message_parser_settings *set,\n\t\t\t\tbool parse_data, struct message_part **parts_r)\n{\n\tint ret;\n\tstruct message_parser_ctx *parser;\n\tstruct message_block block;\n\n\ti_zero(&block);\n\tparser = message_parser_init(pool, input, set);\n\twhile ((ret = message_parser_parse_next_block(parser, &block)) > 0)\n\t\tif (parse_data)\n\t\t\tmessage_part_data_parse_from_header(pool, block.part,\n\t\t\t\t\t\t\t    block.hdr);\n\tmessage_parser_deinit(&parser, parts_r);\n\ttest_assert(input->stream_errno == 0);\n\treturn ret;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":394387,"func":"NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,\n\t\t\t  const char *dev, const char *pass, int passlen)\n{\n\tstruct tevent_context *ev;\n\tstruct tevent_req *req;\n\tNTSTATUS status = NT_STATUS_NO_MEMORY;\n\n\tif (smbXcli_conn_has_async_calls(cli->conn)) {\n\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t}\n\tev = samba_tevent_context_init(talloc_tos());\n\tif (ev == NULL) {\n\t\tgoto fail;\n\t}\n\treq = cli_tree_connect_send(ev, ev, cli, share, dev, pass, passlen);\n\tif (req == NULL) {\n\t\tgoto fail;\n\t}\n\tif (!tevent_req_poll_ntstatus(req, ev, &status)) {\n\t\tgoto fail;\n\t}\n\tstatus = cli_tree_connect_recv(req);\nfail:\n\tTALLOC_FREE(ev);\n\treturn status;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":461681,"func":"MagickExport MagickBooleanType SetResampleFilterVirtualPixelMethod(\n  ResampleFilter *resample_filter,const VirtualPixelMethod method)\n{\n  assert(resample_filter != (ResampleFilter *) NULL);\n  assert(resample_filter->signature == MagickCoreSignature);\n  assert(resample_filter->image != (Image *) NULL);\n  if (resample_filter->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      resample_filter->image->filename);\n  resample_filter->virtual_pixel=method;\n  if (method != UndefinedVirtualPixelMethod)\n    (void) SetCacheViewVirtualPixelMethod(resample_filter->view,method);\n  return(MagickTrue);\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":115199,"func":"code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped,\n\t\t ScanEnv* env)\n{\n  int in_esc;\n  OnigCodePoint code;\n  OnigEncoding enc = env->enc;\n  UChar* p = from;\n\n  in_esc = 0;\n  while (! PEND) {\n    if (ignore_escaped && in_esc) {\n      in_esc = 0;\n    }\n    else {\n      PFETCH_S(code);\n      if (code == c) return 1;\n      if (code == MC_ESC(env->syntax)) in_esc = 1;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":66503,"func":"void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,\n                       const uint8_t *elem_data)\n{\n    int nb = *nb_ptr, nb_alloc;\n    uint8_t *tab = *tab_ptr, *tab_elem_data;\n\n    if ((nb & (nb - 1)) == 0) {\n        if (nb == 0) {\n            nb_alloc = 1;\n        } else {\n            if (nb > INT_MAX \/ (2 * elem_size))\n                goto fail;\n            nb_alloc = nb * 2;\n        }\n        tab = av_realloc(tab, nb_alloc * elem_size);\n        if (!tab)\n            goto fail;\n        *tab_ptr = tab;\n    }\n    *nb_ptr = nb + 1;\n    tab_elem_data = tab + nb*elem_size;\n    if (elem_data)\n        memcpy(tab_elem_data, elem_data, elem_size);\n    else if (CONFIG_MEMORY_POISONING)\n        memset(tab_elem_data, FF_MEMORY_POISON, elem_size);\n    return tab_elem_data;\n\nfail:\n    av_freep(tab_ptr);\n    *nb_ptr = 0;\n    return NULL;\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":243406,"func":"static int grayvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps)\n{\n    os_ptr op = osp;\n\n    if (!r_has_type(op, t_integer) && !r_has_type(op, t_real))\n        return_error(gs_error_typecheck);\n\n    if (num_comps < 1)\n        return_error(gs_error_stackunderflow);\n\n    if (*values > 1.0)\n        *values = 1.0;\n\n    if ( *values < 0.0)\n        *values = 0.0;\n\n    return 0;\n}\n","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":215216,"func":"bool BlobURLRequestJob::ReadBytes(const BlobData::Item& item) {\n  DCHECK(read_buf_remaining_bytes_ >= bytes_to_read_);\n\n  memcpy(read_buf_->data() + read_buf_offset_,\n         &item.data().at(0) + item.offset() + current_item_offset_,\n         bytes_to_read_);\n\n  AdvanceBytesRead(bytes_to_read_);\n  return true;\n}\n","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":98557,"func":"static int tracing_trace_options_show(struct seq_file *m, void *v)\n{\n\tstruct tracer_opt *trace_opts;\n\tstruct trace_array *tr = m->private;\n\tu32 tracer_flags;\n\tint i;\n\n\tmutex_lock(&trace_types_lock);\n\ttracer_flags = tr->current_trace->flags->val;\n\ttrace_opts = tr->current_trace->flags->opts;\n\n\tfor (i = 0; trace_options[i]; i++) {\n\t\tif (tr->trace_flags & (1 << i))\n\t\t\tseq_printf(m, \"%s\\n\", trace_options[i]);\n\t\telse\n\t\t\tseq_printf(m, \"no%s\\n\", trace_options[i]);\n\t}\n\n\tfor (i = 0; trace_opts[i].name; i++) {\n\t\tif (tracer_flags & trace_opts[i].bit)\n\t\t\tseq_printf(m, \"%s\\n\", trace_opts[i].name);\n\t\telse\n\t\t\tseq_printf(m, \"no%s\\n\", trace_opts[i].name);\n\t}\n\tmutex_unlock(&trace_types_lock);\n\n\treturn 0;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":271086,"func":"static inline int ext4_handle_valid(handle_t *handle)\n{\n\tif ((unsigned long)handle < EXT4_NOJOURNAL_MAX_REF_COUNT)\n\t\treturn 0;\n\treturn 1;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":484096,"func":"static inline u8 i740inb(struct i740fb_par *par, u16 port)\n{\n\treturn vga_mm_r(par->regs, port);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":266167,"func":"static bool evtchn_2l_is_pending(evtchn_port_t port)\n{\n\tstruct shared_info *s = HYPERVISOR_shared_info;\n\treturn sync_test_bit(port, BM(&s->evtchn_pending[0]));\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":283331,"func":"void Editor::RegisterCommandGroup(CompositeEditCommand* command_group_wrapper) {\n  DCHECK(command_group_wrapper->IsCommandGroupWrapper());\n  last_edit_command_ = command_group_wrapper;\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":352572,"func":"\tswitch (yych) {\n\t\tcase 'a': goto yy35;\n\t\tdefault: goto yy33;\n\t}","target":1,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":455131,"func":"TEST_F(ExprMatchTest, ConstantNegativeNumberExpressionMatchesCorrectly) {\n    createMatcher(fromjson(\"{$expr: -1}\"));\n\n    ASSERT_TRUE(matches(BSON(\"x\" << 2)));\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":409434,"func":"static void bnx2x_update_eq_prod(struct bnx2x *bp, u16 prod)\n{\n\t\/* No memory barriers *\/\n\tstorm_memset_eq_prod(bp, prod, BP_FUNC(bp));\n\tmmiowb(); \/* keep prod updates ordered *\/\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":314859,"func":"  void ExpectDelegateCreation() {\n    delegate_ = new StrictMock<MockDelegate>();\n    mock_delegate_factory_.PrepareDelegateForCreation(\n        base::WrapUnique(delegate_));\n    EXPECT_TRUE(\n        base::CancelableSyncSocket::CreatePair(&local_, foreign_socket_.get()));\n    base::SharedMemoryCreateOptions shmem_options;\n    shmem_options.size = kShmemSize;\n    shmem_options.share_read_only = true;\n    EXPECT_TRUE(mem_.Create(shmem_options));\n    EXPECT_CALL(mock_delegate_factory_, MockCreateDelegate(NotNull()))\n        .WillOnce(SaveArg<0>(&delegate_event_handler_));\n  }\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":440377,"func":"CACHE_LIMITER_FUNC(public) \/* {{{ *\/\n{\n\tchar buf[MAX_STR + 1];\n\tstruct timeval tv;\n\ttime_t now;\n\n\tgettimeofday(&tv, NULL);\n\tnow = tv.tv_sec + PS(cache_expire) * 60;\n\tmemcpy(buf, EXPIRES, sizeof(EXPIRES) - 1);\n\tstrcpy_gmt(buf + sizeof(EXPIRES) - 1, &now);\n\tADD_HEADER(buf);\n\n\tsnprintf(buf, sizeof(buf) , \"Cache-Control: public, max-age=\" ZEND_LONG_FMT, PS(cache_expire) * 60); \/* SAFE *\/\n\tADD_HEADER(buf);\n\n\tlast_modified();\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":342083,"func":"static void pci_host_config_write(void *opaque, target_phys_addr_t addr,\n\n                                  uint64_t val, unsigned len)\n\n{\n\n    PCIHostState *s = opaque;\n\n\n\n    PCI_DPRINTF(\"%s addr \" TARGET_FMT_plx \" len %d val %\"PRIx64\"\\n\",\n\n                __func__, addr, len, val);\n\n\n\n\n    s->config_reg = val;\n","target":1,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":516421,"func":"static int test_smallsafeprime(int kBits)\n{\n    BIGNUM *r;\n    int st = 0;\n\n    if (!TEST_ptr(r = BN_new()))\n        goto err;\n\n    if (kBits <= 5 && kBits != 3) {\n        if (!TEST_false(BN_generate_prime_ex(r, kBits, 1,\n                                             NULL, NULL, NULL)))\n            goto err;\n    } else {\n        if (!TEST_true(BN_generate_prime_ex(r, kBits, 1,\n                                            NULL, NULL, NULL))\n                || !TEST_int_eq(BN_num_bits(r), kBits))\n            goto err;\n    }\n\n    st = 1;\n err:\n    BN_free(r);\n    return st;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":127457,"func":"static inline int show_tags(WriterContext *w, AVDictionary *tags, int section_id)\n{\n    AVDictionaryEntry *tag = NULL;\n    int ret = 0;\n\n    if (!tags)\n        return 0;\n    writer_print_section_header(w, section_id);\n\n    while ((tag = av_dict_get(tags, \"\", tag, AV_DICT_IGNORE_SUFFIX))) {\n        if ((ret = print_str_validate(tag->key, tag->value)) < 0)\n            break;\n    }\n    writer_print_section_footer(w);\n\n    return ret;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":38277,"func":"R_API bool r_bin_load_io_at_offset_as(RBin *bin, int fd, ut64 baseaddr,\n\t\tut64 loadaddr, int xtr_idx, ut64 offset, const char *name) {\n\t\/\/ adding file_sz to help reduce the performance impact on the system\n\t\/\/ in this case the number of bytes read will be limited to 2MB\n\t\/\/ (MIN_LOAD_SIZE)\n\t\/\/ if it fails, the whole file is loaded.\n\tconst ut64 MAX_LOAD_SIZE = 0;  \/\/ 0xfffff; \/\/128 * (1 << 10 << 10);\n\tint res = r_bin_load_io_at_offset_as_sz (bin, fd, baseaddr,\n\t\tloadaddr, xtr_idx, offset, name, MAX_LOAD_SIZE);\n\tif (!res) {\n\t\tres = r_bin_load_io_at_offset_as_sz (bin, fd, baseaddr,\n\t\t\tloadaddr, xtr_idx, offset, name, UT64_MAX);\n\t}\n\treturn res;\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":483250,"func":"_gsasl_gssapi_server_finish (Gsasl_session * sctx, void *mech_data)\n{\n  _Gsasl_gssapi_server_state *state = mech_data;\n  OM_uint32 min_stat;\n\n  if (!state)\n    return;\n\n  if (state->context != GSS_C_NO_CONTEXT)\n    gss_delete_sec_context (&min_stat, &state->context, GSS_C_NO_BUFFER);\n\n  if (state->cred != GSS_C_NO_CREDENTIAL)\n    gss_release_cred (&min_stat, &state->cred);\n\n  if (state->client != GSS_C_NO_NAME)\n    gss_release_name (&min_stat, &state->client);\n\n  free (state);\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":446594,"func":"virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev)\n{\n    return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&\n        hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":272960,"func":"static int mwifiex_register_dev(struct mwifiex_adapter *adapter)\n{\n\tstruct pcie_service_card *card = adapter->card;\n\n\t\/* save adapter pointer in card *\/\n\tcard->adapter = adapter;\n\n\tif (mwifiex_pcie_request_irq(adapter))\n\t\treturn -1;\n\n\tadapter->tx_buf_size = card->pcie.tx_buf_size;\n\tadapter->mem_type_mapping_tbl = card->pcie.mem_type_mapping_tbl;\n\tadapter->num_mem_types = card->pcie.num_mem_types;\n\tadapter->ext_scan = card->pcie.can_ext_scan;\n\tmwifiex_pcie_get_fw_name(adapter);\n\n\treturn 0;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":103078,"func":"path_center(PG_FUNCTION_ARGS)\n{\n#ifdef NOT_USED\n\tPATH\t   *path = PG_GETARG_PATH_P(0);\n#endif\n\n\tereport(ERROR,\n\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t errmsg(\"function \\\"path_center\\\" not implemented\")));\n\n\tPG_RETURN_NULL();\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":363721,"func":"static int __init ip6_tables_init(void)\n{\n\tint ret;\n\n\tret = register_pernet_subsys(&ip6_tables_net_ops);\n\tif (ret < 0)\n\t\tgoto err1;\n\n\t\/* Noone else will be downing sem now, so we won't sleep *\/\n\tret = xt_register_targets(ip6t_builtin_tg, ARRAY_SIZE(ip6t_builtin_tg));\n\tif (ret < 0)\n\t\tgoto err2;\n\tret = xt_register_matches(ip6t_builtin_mt, ARRAY_SIZE(ip6t_builtin_mt));\n\tif (ret < 0)\n\t\tgoto err4;\n\n\t\/* Register setsockopt *\/\n\tret = nf_register_sockopt(&ip6t_sockopts);\n\tif (ret < 0)\n\t\tgoto err5;\n\n\tpr_info(\"(C) 2000-2006 Netfilter Core Team\\n\");\n\treturn 0;\n\nerr5:\n\txt_unregister_matches(ip6t_builtin_mt, ARRAY_SIZE(ip6t_builtin_mt));\nerr4:\n\txt_unregister_targets(ip6t_builtin_tg, ARRAY_SIZE(ip6t_builtin_tg));\nerr2:\n\tunregister_pernet_subsys(&ip6_tables_net_ops);\nerr1:\n\treturn ret;\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":201443,"func":"static void RaisesExceptionVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, \"TestObject\", \"raisesExceptionVoidMethod\");\n\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  impl->raisesExceptionVoidMethod(exception_state);\n  if (exception_state.HadException()) {\n    return;\n  }\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":85616,"func":"static int pcrypt_create(struct crypto_template *tmpl, struct rtattr **tb)\n{\n\tstruct crypto_attr_type *algt;\n\n\talgt = crypto_get_attr_type(tb);\n\tif (IS_ERR(algt))\n\t\treturn PTR_ERR(algt);\n\n\tswitch (algt->type & algt->mask & CRYPTO_ALG_TYPE_MASK) {\n\tcase CRYPTO_ALG_TYPE_AEAD:\n\t\treturn pcrypt_create_aead(tmpl, tb, algt->type, algt->mask);\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":325360,"func":"static void stream_close(VideoState *is)\n\n{\n\n    VideoPicture *vp;\n\n    int i;\n\n    \/* XXX: use a special url_shutdown call to abort parse cleanly *\/\n\n    is->abort_request = 1;\n\n    SDL_WaitThread(is->read_tid, NULL);\n\n    SDL_WaitThread(is->refresh_tid, NULL);\n\n    packet_queue_destroy(&is->videoq);\n\n    packet_queue_destroy(&is->audioq);\n\n    packet_queue_destroy(&is->subtitleq);\n\n\n\n    \/* free all pictures *\/\n\n    for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {\n\n        vp = &is->pictq[i];\n\n#if CONFIG_AVFILTER\n\n        avfilter_unref_bufferp(&vp->picref);\n\n#endif\n\n        if (vp->bmp) {\n\n            SDL_FreeYUVOverlay(vp->bmp);\n\n            vp->bmp = NULL;\n\n        }\n\n    }\n\n    SDL_DestroyMutex(is->pictq_mutex);\n\n    SDL_DestroyCond(is->pictq_cond);\n\n    SDL_DestroyMutex(is->subpq_mutex);\n\n    SDL_DestroyCond(is->subpq_cond);\n\n    SDL_DestroyCond(is->continue_read_thread);\n\n#if !CONFIG_AVFILTER\n\n    sws_freeContext(is->img_convert_ctx);\n\n#endif\n\n    av_free(is);\n\n}\n","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":267425,"func":"static int hub_set_address(struct usb_device *udev, int devnum)\n{\n\tint retval;\n\tstruct usb_hcd *hcd = bus_to_hcd(udev->bus);\n\n\t\/*\n\t * The host controller will choose the device address,\n\t * instead of the core having chosen it earlier\n\t *\/\n\tif (!hcd->driver->address_device && devnum <= 1)\n\t\treturn -EINVAL;\n\tif (udev->state == USB_STATE_ADDRESS)\n\t\treturn 0;\n\tif (udev->state != USB_STATE_DEFAULT)\n\t\treturn -EINVAL;\n\tif (hcd->driver->address_device)\n\t\tretval = hcd->driver->address_device(hcd, udev);\n\telse\n\t\tretval = usb_control_msg(udev, usb_sndaddr0pipe(),\n\t\t\t\tUSB_REQ_SET_ADDRESS, 0, devnum, 0,\n\t\t\t\tNULL, 0, USB_CTRL_SET_TIMEOUT);\n\tif (retval == 0) {\n\t\tupdate_devnum(udev, devnum);\n\t\t\/* Device now using proper address. *\/\n\t\tusb_set_device_state(udev, USB_STATE_ADDRESS);\n\t\tusb_ep0_reinit(udev);\n\t}\n\treturn retval;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":495336,"func":"static void SFS_DecIndent(ScriptParser *pars) {\n\tpars->indent--;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":462976,"func":"TEST(EqOp, Equality1) {\n    EqualityMatchExpression eq1;\n    EqualityMatchExpression eq2;\n    EqualityMatchExpression eq3;\n\n    BSONObj operand = BSON(\"a\" << 5 << \"b\" << 5 << \"c\" << 4);\n\n    eq1.init(\"a\", operand[\"a\"]).transitional_ignore();\n    eq2.init(\"a\", operand[\"b\"]).transitional_ignore();\n    eq3.init(\"c\", operand[\"c\"]).transitional_ignore();\n\n    ASSERT(eq1.equivalent(&eq1));\n    ASSERT(eq1.equivalent(&eq2));\n    ASSERT(!eq1.equivalent(&eq3));\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":398308,"func":"void js_pushnull(js_State *J)\n{\n\tCHECKSTACK(1);\n\tSTACK[TOP].type = JS_TNULL;\n\t++TOP;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":81078,"func":"void CL_ForwardCommandToServer( void ) {\n\tconst char\t*cmd;\n\tchar\tstring[MAX_STRING_CHARS];\n\n\tcmd = Cmd_Argv(0);\n\n\t\/\/ ignore key up commands\n\tif ( cmd[0] == '-' ) {\n\t\treturn;\n\t}\n\n\tif ( cls.state != CA_ACTIVE || cmd[0] == '+' ) {\n\t\tCom_Printf (\"Unknown command \\\"%s\\\"\\n\", cmd);\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() > 1 ) {\n\t\tCom_sprintf( string, sizeof(string), \"%s %s\", cmd, Cmd_Args() );\n\t} else {\n\t\tQ_strncpyz( string, cmd, sizeof(string) );\n\t}\n\n\tCL_AddReliableCommand( string );\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":457634,"func":"static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries,\n\t\t\t\tsize_t *sq_offset)\n{\n\tstruct io_rings *rings;\n\tsize_t off, sq_array_size;\n\n\toff = struct_size(rings, cqes, cq_entries);\n\tif (off == SIZE_MAX)\n\t\treturn SIZE_MAX;\n\n#ifdef CONFIG_SMP\n\toff = ALIGN(off, SMP_CACHE_BYTES);\n\tif (off == 0)\n\t\treturn SIZE_MAX;\n#endif\n\n\tif (sq_offset)\n\t\t*sq_offset = off;\n\n\tsq_array_size = array_size(sizeof(u32), sq_entries);\n\tif (sq_array_size == SIZE_MAX)\n\t\treturn SIZE_MAX;\n\n\tif (check_add_overflow(off, sq_array_size, &off))\n\t\treturn SIZE_MAX;\n\n\treturn off;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":175486,"func":"ContentClient* RenderViewTest::CreateContentClient() {\n  return new TestContentClient;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":382481,"func":"log_disconnections(int code, Datum arg)\n{\n\tPort\t   *port = MyProcPort;\n\tlong\t\tsecs;\n\tint\t\t\tusecs;\n\tint\t\t\tmsecs;\n\tint\t\t\thours,\n\t\t\t\tminutes,\n\t\t\t\tseconds;\n\n\tTimestampDifference(port->SessionStartTime,\n\t\t\t\t\t\tGetCurrentTimestamp(),\n\t\t\t\t\t\t&secs, &usecs);\n\tmsecs = usecs \/ 1000;\n\n\thours = secs \/ SECS_PER_HOUR;\n\tsecs %= SECS_PER_HOUR;\n\tminutes = secs \/ SECS_PER_MINUTE;\n\tseconds = secs % SECS_PER_MINUTE;\n\n\tereport(LOG,\n\t\t\t(errmsg(\"disconnection: session time: %d:%02d:%02d.%03d \"\n\t\t\t\t\t\"user=%s database=%s host=%s%s%s\",\n\t\t\t\t\thours, minutes, seconds, msecs,\n\t\t\t\t\tport->user_name, port->database_name, port->remote_host,\n\t\t\t\t  port->remote_port[0] ? \" port=\" : \"\", port->remote_port)));\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":319512,"func":"static void qmp_output_type_number(Visitor *v, const char *name, double *obj,\n\n                                   Error **errp)\n\n{\n\n    QmpOutputVisitor *qov = to_qov(v);\n\n    qmp_output_add(qov, name, qfloat_from_double(*obj));\n\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":422295,"func":"ews_delegate_info_free (EwsDelegateInfo *info)\n{\n\tif (!info)\n\t\treturn;\n\n\tews_user_id_free (info->user_id);\n\tg_free (info);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":185563,"func":"SProcXFixesGetCursorImage(ClientPtr client)\n{\n    REQUEST(xXFixesGetCursorImageReq);\n    swaps(&stuff->length);\n    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":155841,"func":"QPDFObjectHandle::unparseResolved()\n{\n    if (this->reserved)\n    {\n        throw std::logic_error(\n            \"QPDFObjectHandle: attempting to unparse a reserved object\");\n    }\n    dereference();\n    return this->obj->unparse();\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":390150,"func":"void SSL_set_quiet_shutdown(SSL *ssl,int mode)\n{\n    ssl->SetQuietShutdown(mode != 0);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":429822,"func":"uint_t aubio_onset_set_delay(aubio_onset_t * o, uint_t delay) {\n  o->delay = delay;\n  return AUBIO_OK;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":23932,"func":"Jbig2WordStream * jbig2_word_stream_buf_new ( Jbig2Ctx * ctx , const byte * data , size_t size ) {\n Jbig2WordStreamBuf * result = jbig2_new ( ctx , Jbig2WordStreamBuf , 1 ) ;\n if ( result == NULL ) {\n jbig2_error ( ctx , JBIG2_SEVERITY_FATAL , - 1 , \"failed to allocate Jbig2WordStreamBuf in jbig2_word_stream_buf_new\" ) ;\n return NULL ;\n }\n result -> super . get_next_word = jbig2_word_stream_buf_get_next_word ;\n result -> data = data ;\n result -> size = size ;\n return & result -> super ;\n }","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":457242,"func":"proxy_C_SignRecoverInit (CK_X_FUNCTION_LIST *self,\n                         CK_SESSION_HANDLE handle,\n                         CK_MECHANISM_PTR mechanism,\n                         CK_OBJECT_HANDLE key)\n{\n\tState *state = (State *)self;\n\tMapping map;\n\tCK_RV rv;\n\n\trv = map_session_to_real (state->px, &handle, &map, NULL);\n\tif (rv != CKR_OK)\n\t\treturn rv;\n\treturn (map.funcs->C_SignRecoverInit) (handle, mechanism, key);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":412081,"func":"struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,\n\t\t\t       ext4_lblk_t block, int map_flags)\n{\n\tstruct buffer_head *bh;\n\n\tbh = ext4_getblk(handle, inode, block, map_flags);\n\tif (IS_ERR(bh))\n\t\treturn bh;\n\tif (!bh || buffer_uptodate(bh))\n\t\treturn bh;\n\tll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh);\n\twait_on_buffer(bh);\n\tif (buffer_uptodate(bh))\n\t\treturn bh;\n\tput_bh(bh);\n\treturn ERR_PTR(-EIO);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":132552,"func":"int luaD_pcall (lua_State *L, Pfunc func, void *u,\n                ptrdiff_t old_top, ptrdiff_t ef) {\n  int status;\n  CallInfo *old_ci = L->ci;\n  lu_byte old_allowhooks = L->allowhook;\n  ptrdiff_t old_errfunc = L->errfunc;\n  L->errfunc = ef;\n  status = luaD_rawrunprotected(L, func, u);\n  if (unlikely(status != LUA_OK)) {  \/* an error occurred? *\/\n    StkId oldtop = restorestack(L, old_top);\n    L->ci = old_ci;\n    L->allowhook = old_allowhooks;\n    status = luaF_close(L, oldtop, status);\n    oldtop = restorestack(L, old_top);  \/* previous call may change stack *\/\n    luaD_seterrorobj(L, status, oldtop);\n    luaD_shrinkstack(L);\n  }\n  L->errfunc = old_errfunc;\n  return status;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":334304,"func":"static void ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride,\n\n                             const uint8_t *table)\n\n{\n\n    int j;\n\n    int out = 0;\n\n    int c;\n\n    int t;\n\n    \n\n    for (j = 0; j < height; j++){\n\n        out = 0;\n\n        while (out < width){\n\n            c = ir2_get_code(&ctx->gb);\n\n            if(c > 0x80) { \/* we have a skip *\/\n\n                c -= 0x80;\n\n                out += c * 2;\n\n            } else { \/* add two deltas from table *\/\n\n                t = dst[out] + (table[c * 2] - 128);\n\n                CLAMP_TO_BYTE(t);\n\n                dst[out] = t;\n\n                out++;\n\n                t = dst[out] + (table[(c * 2) + 1] - 128);\n\n                CLAMP_TO_BYTE(t);\n\n                dst[out] = t;\n\n                out++;\n\n            }\n\n        }\n\n        dst += stride;\n\n    }\n\n}\n","target":1,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":189917,"func":"bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisampleAMD(\n    GLsizei samples,\n    GLsizei storageSamples,\n    GLenum internalformat,\n    GLsizei width,\n    GLsizei height) {\n  if (samples > renderbuffer_manager()->max_samples()) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, \"glRenderbufferStorageMultisample\",\n                       \"samples too large\");\n    return false;\n  }\n\n  if (width > renderbuffer_manager()->max_renderbuffer_size() ||\n      height > renderbuffer_manager()->max_renderbuffer_size()) {\n    LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, \"glRenderbufferStorageMultisample\",\n                       \"dimensions too large\");\n    return false;\n  }\n\n  uint32_t estimated_size = 0;\n  if (!renderbuffer_manager()->ComputeEstimatedRenderbufferSize(\n          width, height, samples, internalformat, &estimated_size)) {\n    LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, \"glRenderbufferStorageMultisample\",\n                       \"dimensions too large\");\n    return false;\n  }\n\n  return true;\n}\n","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":186959,"func":"  SitePerProcessIgnoreCertErrorsBrowserTest() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":13334,"func":"static X509_ALGOR *rsa_mgf1_decode(X509_ALGOR *alg)\n {\n     const unsigned char *p;\n     int plen;\n    if (alg == NULL)\n         return NULL;\n     if (OBJ_obj2nid(alg->algorithm) != NID_mgf1)\n         return NULL;\n    if (alg->parameter->type != V_ASN1_SEQUENCE)\n        return NULL;\n\n    p = alg->parameter->value.sequence->data;\n    plen = alg->parameter->value.sequence->length;\n    return d2i_X509_ALGOR(NULL, &p, plen);\n}\n","target":1,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":458661,"func":"dp_packet_hwol_l4_is_sctp(const struct dp_packet *b OVS_UNUSED)\n{\n    return false;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":266724,"func":"static inline int perf_intr_is_nmi(struct pt_regs *regs)\n{\n#ifdef __powerpc64__\n\treturn !regs->softe;\n#else\n\treturn 0;\n#endif\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":150591,"func":"cached_NPN_GetIntIdentifier(int32_t intid)\n{\n  NPIdentifier ident;\n  if (!use_npidentifier_cache())\n\tident = invoke_NPN_GetIntIdentifier(intid);\n#if USE_NPIDENTIFIER_CACHE\n  else if (!npidentifier_cache_has_int(intid, &ident)) {\n\tident = invoke_NPN_GetIntIdentifier(intid);\n\tnpidentifier_cache_reserve(1);\n\tnpidentifier_cache_add_int(ident, intid);\n  }\n#endif\n  return ident;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":393983,"func":"int __weak arch_update_cpu_topology(void)\n{\n\treturn 0;\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":249888,"func":"ReplaceCursor(CursorPtr pCursor, TestCursorFunc testCursor, void *closure)\n{\n    int clientIndex;\n    int resIndex;\n    ReplaceCursorLookupRec rcl;\n\n    \/*\n     * Cursors exist only in the resource database, windows and grabs.\n     * All of these are always pointed at by the resource database.  Walk\n     * the whole thing looking for cursors\n     *\/\n    rcl.testCursor = testCursor;\n    rcl.pNew = pCursor;\n    rcl.closure = closure;\n\n    \/* for each client *\/\n    for (clientIndex = 0; clientIndex < currentMaxClients; clientIndex++) {\n        if (!clients[clientIndex])\n            continue;\n        for (resIndex = 0; resIndex < NUM_CURSOR_RESTYPES; resIndex++) {\n            rcl.type = CursorRestypes[resIndex];\n            \/*\n             * This function walks the entire client resource database\n             *\/\n            LookupClientResourceComplex(clients[clientIndex],\n                                        rcl.type,\n                                        ReplaceCursorLookup, (void *) &rcl);\n        }\n    }\n    \/* this \"knows\" that WindowHasNewCursor doesn't depend on it's argument *\/\n    WindowHasNewCursor(screenInfo.screens[0]->root);\n}\n","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":91804,"func":"static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)\n{\n\tconst int base = 'z' - 'a' + 1;\n\tchar *begin = buf + strlen(prefix);\n\tchar *end = buf + buflen;\n\tchar *p;\n\tint unit;\n\n\tp = end - 1;\n\t*p = '\\0';\n\tunit = base;\n\tdo {\n\t\tif (p == begin)\n\t\t\treturn -EINVAL;\n\t\t*--p = 'a' + (index % unit);\n\t\tindex = (index \/ unit) - 1;\n\t} while (index >= 0);\n\n\tmemmove(begin, p, end - p);\n\tmemcpy(buf, prefix, strlen(prefix));\n\n\treturn 0;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":473606,"func":"static inline void apic_clear_isr(int vec, struct kvm_lapic *apic)\n{\n\tstruct kvm_vcpu *vcpu;\n\tif (!__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR))\n\t\treturn;\n\n\tvcpu = apic->vcpu;\n\n\t\/*\n\t * We do get here for APIC virtualization enabled if the guest\n\t * uses the Hyper-V APIC enlightenment.  In this case we may need\n\t * to trigger a new interrupt delivery by writing the SVI field;\n\t * on the other hand isr_count and highest_isr_cache are unused\n\t * and must be left alone.\n\t *\/\n\tif (unlikely(vcpu->arch.apicv_active))\n\t\tstatic_call(kvm_x86_hwapic_isr_update)(vcpu,\n\t\t\t\t\t\tapic_find_highest_isr(apic));\n\telse {\n\t\t--apic->isr_count;\n\t\tBUG_ON(apic->isr_count < 0);\n\t\tapic->highest_isr_cache = -1;\n\t}\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":278788,"func":"static void free_argv(char **argv, int argc)\n{\n\tint i;\n\n\tif (argv) {\n\t\tfor (i = 0; i < argc; i++) {\n\t\t\tif (argv[i]) {\n\t\t\t\tefree(argv[i]);\n\t\t\t}\n\t\t}\n\t\tefree(argv);\n\t}\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":400996,"func":"static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)\n{\n    int fd, ret;\n\n    fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0);\n    if (fd == -1) {\n        return -1;\n    }\n    ret = fstatfs(fd, stbuf);\n    close_preserve_errno(fd);\n    return ret;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":63548,"func":"_SSL_check_hostname (X509 *cert, const char *host)\n{\n\tint rv;\n\n\trv = _SSL_check_subject_altname (cert, host);\n\tif (rv == 0 || rv == -2)\n\t\treturn rv;\n\n\treturn _SSL_check_common_name (cert, host);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":62382,"func":"nfs4_init_nonuniform_client_string(const struct nfs_client *clp,\n\t\t\t\t   char *buf, size_t len)\n{\n\tunsigned int result;\n\n\trcu_read_lock();\n\tresult = scnprintf(buf, len, \"Linux NFSv4.0 %s\/%s %s\",\n\t\t\t\tclp->cl_ipaddr,\n\t\t\t\trpc_peeraddr2str(clp->cl_rpcclient,\n\t\t\t\t\t\t\tRPC_DISPLAY_ADDR),\n\t\t\t\trpc_peeraddr2str(clp->cl_rpcclient,\n\t\t\t\t\t\t\tRPC_DISPLAY_PROTO));\n\trcu_read_unlock();\n\treturn result;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":169207,"func":"void AeroPeekManager::TabDetachedAt(TabContents* contents, int index) {\n  TabClosingAt(contents, index);\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":312418,"func":"void WebMediaPlayerMS::RegisterContentsLayer(cc::Layer* layer) {\n  DCHECK(thread_checker_.CalledOnValidThread());\n  DCHECK(bridge_);\n\n  bridge_->SetContentsOpaque(opaque_);\n  client_->SetCcLayer(layer);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":402253,"func":"static void xhci_ep_free_xfer(XHCITransfer *xfer)\n{\n    QTAILQ_REMOVE(&xfer->epctx->transfers, xfer, next);\n    xfer->epctx->xfer_count--;\n\n    usb_packet_cleanup(&xfer->packet);\n    g_free(xfer->trbs);\n    g_free(xfer);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":357813,"func":"static int skfp_close(struct net_device *dev)\n{\n\tstruct s_smc *smc = netdev_priv(dev);\n\tskfddi_priv *bp = &smc->os;\n\n\tCLI_FBI();\n\tsmt_reset_defaults(smc, 1);\n\tcard_stop(smc);\n\tmac_drv_clear_tx_queue(smc);\n\tmac_drv_clear_rx_queue(smc);\n\n\tnetif_stop_queue(dev);\n\t\/* Deregister (free) IRQ *\/\n\tfree_irq(dev->irq, dev);\n\n\tskb_queue_purge(&bp->SendSkbQueue);\n\tbp->QueueSkb = MAX_TX_QUEUE_LEN;\n\n\treturn (0);\n}\t\t\t\t\/\/ skfp_close","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":233170,"func":"  void Clear() {\n    resource_response_.reset();\n    byte_range_lower_bound_ = 0;\n    byte_range_upper_bound_ = 0;\n  }\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":6329,"func":"static inline int copy_regset_from_user(struct task_struct *target,\n\t\t\t\t\tconst struct user_regset_view *view,\n\t\t\t\t\tunsigned int setno,\n\t\t\t\t\tunsigned int offset, unsigned int size,\n\t\t\t\t\tconst void __user *data)\n{\n\tconst struct user_regset *regset = &view->regsets[setno];\n\n\tif (!access_ok(VERIFY_READ, data, size))\n\t\treturn -EIO;\n\n\treturn regset->set(target, regset, offset, size, NULL, data);\n}","target":1,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":187268,"func":"long get_user_pages_locked(unsigned long start, unsigned long nr_pages,\n\t\t\t   unsigned int gup_flags, struct page **pages,\n\t\t\t   int *locked)\n{\n\treturn __get_user_pages_locked(current, current->mm, start, nr_pages,\n\t\t\t\t       pages, NULL, locked,\n\t\t\t\t       gup_flags | FOLL_TOUCH);\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":453431,"func":"__perf_remove_from_context(struct perf_event *event,\n\t\t\t   struct perf_cpu_context *cpuctx,\n\t\t\t   struct perf_event_context *ctx,\n\t\t\t   void *info)\n{\n\tunsigned long flags = (unsigned long)info;\n\n\tif (ctx->is_active & EVENT_TIME) {\n\t\tupdate_context_time(ctx);\n\t\tupdate_cgrp_time_from_cpuctx(cpuctx);\n\t}\n\n\tevent_sched_out(event, cpuctx, ctx);\n\tif (flags & DETACH_GROUP)\n\t\tperf_group_detach(event);\n\tlist_del_event(event, ctx);\n\n\tif (!ctx->nr_events && ctx->is_active) {\n\t\tctx->is_active = 0;\n\t\tctx->rotate_necessary = 0;\n\t\tif (ctx->task) {\n\t\t\tWARN_ON_ONCE(cpuctx->task_ctx != ctx);\n\t\t\tcpuctx->task_ctx = NULL;\n\t\t}\n\t}\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":197369,"func":"acl_to_ac_byte(struct sc_card *card, const struct sc_acl_entry *e)\n{\n\tif (e == NULL)\n\t\treturn SC_ERROR_OBJECT_NOT_FOUND;\n\n\tswitch (e->method) {\n\tcase SC_AC_NONE:\n\t\tLOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE);\n\tcase SC_AC_NEVER:\n\t\tLOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_NOONE);\n\tdefault:\n\t\tLOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER);\n\t}\n\n\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);\n}\n","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":156327,"func":"pci_populate_msixcap(struct msixcap *msixcap, int msgnum, int barnum,\n\t\t     uint32_t msix_tab_size)\n{\n\n\tassert(msix_tab_size % 4096 == 0);\n\n\tbzero(msixcap, sizeof(struct msixcap));\n\tmsixcap->capid = PCIY_MSIX;\n\n\t\/*\n\t * Message Control Register, all fields set to\n\t * zero except for the Table Size.\n\t * Note: Table size N is encoded as N-1\n\t *\/\n\tmsixcap->msgctrl = msgnum - 1;\n\n\t\/*\n\t * MSI-X BAR setup:\n\t * - MSI-X table start at offset 0\n\t * - PBA table starts at a 4K aligned offset after the MSI-X table\n\t *\/\n\tmsixcap->table_info = barnum & PCIM_MSIX_BIR_MASK;\n\tmsixcap->pba_info = msix_tab_size | (barnum & PCIM_MSIX_BIR_MASK);\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":460039,"func":"proto_set_cant_toggle(const int proto_id)\n{\n\tprotocol_t *protocol;\n\n\tprotocol = find_protocol_by_id(proto_id);\n\tprotocol->can_toggle = FALSE;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":136814,"func":"struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,\n\tstruct i2c_adapter *i2c)\n{\n\tstruct cx24116_state *state = NULL;\n\tint ret;\n\n\tdprintk(\"%s\\n\", __func__);\n\n\t\/* allocate memory for the internal state *\/\n\tstate = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL);\n\tif (state == NULL)\n\t\tgoto error1;\n\n\tstate->config = config;\n\tstate->i2c = i2c;\n\n\t\/* check if the demod is present *\/\n\tret = (cx24116_readreg(state, 0xFF) << 8) |\n\t\tcx24116_readreg(state, 0xFE);\n\tif (ret != 0x0501) {\n\t\tprintk(KERN_INFO \"Invalid probe, probably not a CX24116 device\\n\");\n\t\tgoto error2;\n\t}\n\n\t\/* create dvb_frontend *\/\n\tmemcpy(&state->frontend.ops, &cx24116_ops,\n\t\tsizeof(struct dvb_frontend_ops));\n\tstate->frontend.demodulator_priv = state;\n\treturn &state->frontend;\n\nerror2: kfree(state);\nerror1: return NULL;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":185760,"func":"void OmniboxViewViews::OnTemporaryTextMaybeChanged(\n    const base::string16& display_text,\n    const AutocompleteMatch& match,\n    bool save_original_selection,\n    bool notify_text_changed) {\n  if (save_original_selection)\n    saved_temporary_selection_ = GetSelectedRange();\n  SetAccessibilityLabel(display_text, match);\n  int caret_pos = TextAndUIDirectionMatch() ? display_text.length() : 0;\n  SetWindowTextAndCaretPos(display_text, caret_pos, false, notify_text_changed);\n}\n","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":418083,"func":"  void operator()(const T& v) const {\n    out << v;\n  }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":288242,"func":"void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease(\n    const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) {\n  RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID(\n       params.surface_id);\n   if (!view)\n     return;\n  view->AcceleratedSurfaceRelease(params.identifier);\n }\n","target":1,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":150196,"func":"static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)\n{\n\tstruct nfs_server *server = NFS_SERVER(dir);\n\tstruct nfs_removeargs *args = msg->rpc_argp;\n\tstruct nfs_removeres *res = msg->rpc_resp;\n\n\tres->server = server;\n\tmsg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];\n\tnfs41_init_sequence(&args->seq_args, &res->seq_res, 1);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":188061,"func":"Element* Document::rootScroller() const\n{\n    return m_rootScrollerController->get();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":314421,"func":"int sc_file_set_content(sc_file_t *file, const u8 *content,\n\t\t\t size_t content_len)\n{\n\tu8 *tmp;\n\tif (!sc_file_valid(file)) {\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\t}\n\n\tif (content == NULL) {\n\t\tif (file->encoded_content != NULL)\n\t\t\tfree(file->encoded_content);\n\t\tfile->encoded_content = NULL;\n\t\tfile->encoded_content_len = 0;\n\t\treturn SC_SUCCESS;\n\t}\n\n\ttmp = (u8 *) realloc(file->encoded_content, content_len);\n\tif (!tmp) {\n\t\tif (file->encoded_content)\n\t\t\tfree(file->encoded_content);\n\t\tfile->encoded_content = NULL;\n\t\tfile->encoded_content_len = 0;\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\t}\n\n\tfile->encoded_content = tmp;\n\tmemcpy(file->encoded_content, content, content_len);\n\tfile->encoded_content_len = content_len;\n\n\treturn SC_SUCCESS;\n}\n","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":344487,"func":"new_msg_lsa_change_notify (u_char msgtype,\n\t\t\t   u_int32_t seqnum,\n\t\t\t   struct in_addr ifaddr,\n\t\t\t   struct in_addr area_id,\n\t\t\t   u_char is_self_originated, struct lsa_header *data)\n{\n  u_char buf[OSPF_API_MAX_MSG_SIZE];\n  struct msg_lsa_change_notify *nmsg;\n  int len;\n\n  assert (data);\n\n  nmsg = (struct msg_lsa_change_notify *) buf;\n  len = ntohs (data->length) + sizeof (struct msg_lsa_change_notify)\n    - sizeof (struct lsa_header);\n  nmsg->ifaddr = ifaddr;\n  nmsg->area_id = area_id;\n  nmsg->is_self_originated = is_self_originated;\n  memset (&nmsg->pad, 0, sizeof (nmsg->pad));\n  memcpy (&nmsg->data, data, ntohs (data->length));\n\n  return msg_new (msgtype, nmsg, seqnum, len);\n}","target":1,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":122506,"func":"unixWarningHandler(const char* module, const char* fmt, va_list ap)\n{\n\tif (module != NULL)\n\t\tfprintf(stderr, \"%s: \", module);\n\tfprintf(stderr, \"Warning, \");\n\tvfprintf(stderr, fmt, ap);\n\tfprintf(stderr, \".\\n\");\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":204296,"func":"const AtomicString& ScreenOrientation::orientation(Screen& screen)\n{\n    ScreenOrientation& screenOrientation = ScreenOrientation::from(screen);\n    if (!screenOrientation.document()) {\n        return orientationToString(blink::WebScreenOrientationPortraitPrimary);\n    }\n    ScreenOrientationController& controller = ScreenOrientationController::from(*screenOrientation.document());\n    return orientationToString(controller.orientation());\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":148101,"func":"static void attr_show_all_iterator(struct hash_backet *backet, struct vty *vty)\n{\n\tstruct attr *attr = backet->data;\n\n\tvty_out(vty, \"attr[%ld] nexthop %s\\n\", attr->refcnt,\n\t\tinet_ntoa(attr->nexthop));\n\tvty_out(vty, \"\\tflags: %\" PRIu64 \" med: %u local_pref: %u origin: %u weight: %u label: %u\\n\",\n\t\tattr->flag, attr->med, attr->local_pref, attr->origin,\n\t\tattr->weight, attr->label);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":399311,"func":"void kthread_delayed_work_timer_fn(unsigned long __data)\n{\n\tstruct kthread_delayed_work *dwork =\n\t\t(struct kthread_delayed_work *)__data;\n\tstruct kthread_work *work = &dwork->work;\n\tstruct kthread_worker *worker = work->worker;\n\n\t\/*\n\t * This might happen when a pending work is reinitialized.\n\t * It means that it is used a wrong way.\n\t *\/\n\tif (WARN_ON_ONCE(!worker))\n\t\treturn;\n\n\tspin_lock(&worker->lock);\n\t\/* Work must not be used with >1 worker, see kthread_queue_work(). *\/\n\tWARN_ON_ONCE(work->worker != worker);\n\n\t\/* Move the work from worker->delayed_work_list. *\/\n\tWARN_ON_ONCE(list_empty(&work->node));\n\tlist_del_init(&work->node);\n\tkthread_insert_work(worker, work, &worker->work_list);\n\n\tspin_unlock(&worker->lock);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":94007,"func":"static void deliver_smi_err_response(struct ipmi_smi *intf,\n\t\t\t\t     struct ipmi_smi_msg *msg,\n\t\t\t\t     unsigned char err)\n{\n\tmsg->rsp[0] = msg->data[0] | 4;\n\tmsg->rsp[1] = msg->data[1];\n\tmsg->rsp[2] = err;\n\tmsg->rsp_size = 3;\n\t\/* It's an error, so it will never requeue, no need to check return. *\/\n\thandle_one_recv_msg(intf, msg);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":149821,"func":"static inline unsigned char read_buf(struct n_tty_data *ldata, size_t i)\n{\n\treturn ldata->read_buf[i & (N_TTY_BUF_SIZE - 1)];\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":518017,"func":"bool Item_cache_wrapper::send(Protocol *protocol, st_value *buffer)\n{\n  if (result_field)\n    return protocol->store(result_field);\n  return Item::send(protocol, buffer);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":75600,"func":"GF_Err hclr_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":240184,"func":"void GLES2Implementation::IssueBeginQuery(GLenum target,\n                                          GLuint id,\n                                          uint32_t sync_data_shm_id,\n                                          uint32_t sync_data_shm_offset) {\n  helper_->BeginQueryEXT(target, id, sync_data_shm_id, sync_data_shm_offset);\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":201854,"func":"void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag)\n{\n    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));\n\n    flag = flag != FALSE;\n    if (flag == webkit_web_view_get_editable(webView))\n        return;\n\n    core(webView)->setEditable(flag);\n\n    Frame* frame = core(webView)->mainFrame();\n    g_return_if_fail(frame);\n\n    if (flag) {\n        frame->editor()->applyEditingStyleToBodyElement();\n    }\n    g_object_notify(G_OBJECT(webView), \"editable\");\n}\n","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":1696,"func":"static void rlvl_destroy ( jpc_enc_rlvl_t * rlvl ) {\n jpc_enc_band_t * band ;\n uint_fast16_t bandno ;\n if ( rlvl -> bands ) {\n for ( bandno = 0 , band = rlvl -> bands ;\n bandno < rlvl -> numbands ;\n ++ bandno , ++ band ) {\n band_destroy ( band ) ;\n }\n jas_free ( rlvl -> bands ) ;\n }\n }","target":1,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":192076,"func":"  virtual ~BacktraceOutputHandler() {}\n","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":361864,"func":"void Server::msgReject(ServerUser *, MumbleProto::Reject &) {\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":239224,"func":"wifi_error wifi_set_nodfs_flag(wifi_interface_handle handle, u32 nodfs)\n{\n SetNodfsCommand command(handle, nodfs);\n return (wifi_error) command.requestResponse();\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":400130,"func":"router_get_fallback_dir_servers(void)\n{\n  if (!fallback_dir_servers)\n    fallback_dir_servers = smartlist_new();\n\n  return fallback_dir_servers;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":429509,"func":"file_changed (GFileMonitor      *monitor,\n              GFile             *file,\n              GFile             *other_file,\n              GFileMonitorEvent  event_type,\n              gpointer           user_data)\n{\n  GKeyfileSettingsBackend *kfsb = user_data;\n\n  \/* Ignore file deletions, let the GKeyFile content remain in tact. *\/\n  if (event_type != G_FILE_MONITOR_EVENT_DELETED)\n    g_keyfile_settings_backend_keyfile_reload (kfsb);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":230656,"func":"void FreeSprite(DeviceIntPtr dev)\n{\n    if (DevHasCursor(dev) && dev->spriteInfo->sprite) {\n        if (dev->spriteInfo->sprite->current)\n            FreeCursor(dev->spriteInfo->sprite->current, None);\n        free(dev->spriteInfo->sprite->spriteTrace);\n        free(dev->spriteInfo->sprite);\n    }\n    dev->spriteInfo->sprite = NULL;\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":194943,"func":"MojoResult Core::AcquireDispatchersForTransit(\n    const MojoHandle* handles,\n    size_t num_handles,\n    std::vector<Dispatcher::DispatcherInTransit>* dispatchers) {\n  base::AutoLock lock(handles_->GetLock());\n  MojoResult rv = handles_->BeginTransit(handles, num_handles, dispatchers);\n  if (rv != MOJO_RESULT_OK)\n    handles_->CancelTransit(*dispatchers);\n  return rv;\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":14496,"func":"  SiteInstance* parent_site_instance() const {\n    return parent_site_instance_.get();\n  }\n","target":1,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":69304,"func":"static unsigned long nested_ept_get_cr3(struct kvm_vcpu *vcpu)\n{\n\t\/* return the page table to be shadowed - in our case, EPT12 *\/\n\treturn get_vmcs12(vcpu)->ept_pointer;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":82212,"func":"R_API bool r_bin_file_set_cur_by_fd(RBin *bin, ut32 bin_fd) {\n\tRBinFile *bf = r_bin_file_find_by_fd (bin, bin_fd);\n\treturn bf? r_bin_file_set_cur_binfile (bin, bf): false;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":144464,"func":"static __always_inline void vmcs_write16(unsigned long field, u16 value)\n{\n\tvmcs_check16(field);\n\tif (static_branch_unlikely(&enable_evmcs))\n\t\treturn evmcs_write16(field, value);\n\n\t__vmcs_writel(field, value);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":104021,"func":"int wvlan_set_netname(struct net_device *dev,\n\t\t      struct iw_request_info *info,\n\t\t      union iwreq_data *wrqu,\n\t\t      char *extra)\n{\n\tstruct wl_private *lp = wl_priv(dev);\n\tunsigned long flags;\n\tint ret = 0;\n\t\/*------------------------------------------------------------------------*\/\n\n\n\tDBG_FUNC(\"wvlan_set_netname\");\n\tDBG_ENTER(DbgInfo);\n\n\twl_lock(lp, &flags);\n\n\tmemset(lp->NetworkName, 0, sizeof(lp->NetworkName));\n\tmemcpy(lp->NetworkName, extra, wrqu->data.length);\n\n\t\/* Commit the adapter parameters *\/\n\twl_apply(lp);\n\twl_unlock(lp, &flags);\n\n\tDBG_LEAVE(DbgInfo);\n\treturn ret;\n} \/* wvlan_set_netname *\/","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":168174,"func":"ULONG FormatEtcEnumerator::Release() {\n  if (InterlockedDecrement(&ref_count_) == 0) {\n    ULONG copied_refcnt = ref_count_;\n    delete this;\n    return copied_refcnt;\n  }\n  return ref_count_;\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":242214,"func":"bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const {\n  return media_web_contents_observer_->HasActiveEffectivelyFullscreenVideo();\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":35360,"func":"static int _regulator_is_enabled(struct regulator_dev *rdev)\n{\n\t\/* A GPIO control always takes precedence *\/\n\tif (rdev->ena_pin)\n\t\treturn rdev->ena_gpio_state;\n\n\t\/* If we don't know then assume that the regulator is always on *\/\n\tif (!rdev->desc->ops->is_enabled)\n\t\treturn 1;\n\n\treturn rdev->desc->ops->is_enabled(rdev);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":61897,"func":"    **\/\n    iterator begin() {\n      return _data;","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":394180,"func":"int blkid_is_nested_dimension(blkid_partition par,\n\t\t\tuint64_t start, uint64_t size)\n{\n\tuint64_t pstart;\n\tuint64_t psize;\n\n\tif (!par)\n\t\treturn 0;\n\n\tpstart = blkid_partition_get_start(par);\n\tpsize = blkid_partition_get_size(par);\n\n\tif (start < pstart || start + size > pstart + psize)\n\t\treturn 0;\n\n\treturn 1;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":173763,"func":"void RenderWidgetHostViewGuest::DidUpdateBackingStore(\n    const gfx::Rect& scroll_rect,\n    const gfx::Vector2d& scroll_delta,\n    const std::vector<gfx::Rect>& copy_rects) {\n  NOTIMPLEMENTED();\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":135205,"func":"static int __net_init xfrm6_tunnel_net_init(struct net *net)\n{\n\tstruct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);\n\tunsigned int i;\n\n\tfor (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)\n\t\tINIT_HLIST_HEAD(&xfrm6_tn->spi_byaddr[i]);\n\tfor (i = 0; i < XFRM6_TUNNEL_SPI_BYSPI_HSIZE; i++)\n\t\tINIT_HLIST_HEAD(&xfrm6_tn->spi_byspi[i]);\n\txfrm6_tn->spi = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":295653,"func":"const char *X86_group_name(csh handle, unsigned int id)\n{\n#ifndef CAPSTONE_DIET\n\treturn id2name(group_name_maps, ARR_SIZE(group_name_maps), id);\n#else\n\treturn NULL;\n#endif\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":205990,"func":" void BluetoothOptionsHandler::ValidatePasskeyCallback(\n    const base::ListValue* args) {\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":279917,"func":"bool SimplifiedBackwardsTextIterator::handleReplacedElement()\n{\n    unsigned index = m_node->nodeIndex();\n    emitCharacter(',', m_node->parentNode(), index, index + 1);\n    return true;\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":117154,"func":"static void credential_apply_config(struct credential *c)\n{\n\tif (!c->host)\n\t\tdie(_(\"refusing to work with credential missing host field\"));\n\tif (!c->protocol)\n\t\tdie(_(\"refusing to work with credential missing protocol field\"));\n\n\tif (c->configured)\n\t\treturn;\n\tgit_config(credential_config_callback, c);\n\tc->configured = 1;\n\n\tif (!c->use_http_path && proto_is_http(c->protocol)) {\n\t\tFREE_AND_NULL(c->path);\n\t}\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":385766,"func":"void TY_(InitMap)(void)\n{\n    MapStr(\"\\r\\n\\f\", newline|white);\n    MapStr(\" \\t\", white);\n    MapStr(\"-.:_\", namechar);\n    MapStr(\"0123456789\", digit|digithex|namechar);\n    MapStr(\"abcdefghijklmnopqrstuvwxyz\", lowercase|letter|namechar);\n    MapStr(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", uppercase|letter|namechar);\n    MapStr(\"abcdefABCDEF\", digithex);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":122570,"func":"  explicit UnravelIndexOp(OpKernelConstruction* ctx)\n      : OpKernel(ctx), dtidx_(DataTypeToEnum<Tidx>::v()) {}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":393271,"func":"xmlSchemaResolveAttrGroupReferences(xmlSchemaQNameRefPtr ref,\n\t\t\t\t    xmlSchemaParserCtxtPtr ctxt)\n{\n    xmlSchemaAttributeGroupPtr group;\n\n    if (ref->item != NULL)\n        return(0);\n    group = xmlSchemaGetAttributeGroup(ctxt->schema,\n\tref->name,\n\tref->targetNamespace);\n    if (group == NULL) {\n\txmlSchemaPResCompAttrErr(ctxt,\n\t    XML_SCHEMAP_SRC_RESOLVE,\n\t    NULL, ref->node,\n\t    \"ref\", ref->name, ref->targetNamespace,\n\t    ref->itemType, NULL);\n\treturn(ctxt->err);\n    }\n    ref->item = WXS_BASIC_CAST group;\n    return(0);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":339572,"func":"static void s390_pcihost_init_as(S390pciState *s)\n\n{\n\n    int i;\n\n    S390PCIBusDevice *pbdev;\n\n\n\n    for (i = 0; i < PCI_SLOT_MAX; i++) {\n\n        pbdev = &s->pbdev[i];\n\n        memory_region_init(&pbdev->mr, OBJECT(s),\n\n                           \"iommu-root-s390\", UINT64_MAX);\n\n        address_space_init(&pbdev->as, &pbdev->mr, \"iommu-pci\");\n\n    }\n\n\n\n    memory_region_init_io(&s->msix_notify_mr, OBJECT(s),\n\n                          &s390_msi_ctrl_ops, s, \"msix-s390\", UINT64_MAX);\n\n    address_space_init(&s->msix_notify_as, &s->msix_notify_mr, \"msix-pci\");\n\n}\n","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":46926,"func":"static void start_cfs_slack_bandwidth(struct cfs_bandwidth *cfs_b)\n{\n\tu64 min_left = cfs_bandwidth_slack_period + min_bandwidth_expiration;\n\n\t\/* if there's a quota refresh soon don't bother with slack *\/\n\tif (runtime_refresh_within(cfs_b, min_left))\n\t\treturn;\n\n\t\/* don't push forwards an existing deferred unthrottle *\/\n\tif (cfs_b->slack_started)\n\t\treturn;\n\tcfs_b->slack_started = true;\n\n\thrtimer_start(&cfs_b->slack_timer,\n\t\t\tns_to_ktime(cfs_bandwidth_slack_period),\n\t\t\tHRTIMER_MODE_REL);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":92207,"func":"size_t Magick::Image::scene(void) const\n{\n  return(constImage()->scene);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":33971,"func":"TEST_F(NgramKernelTest, TestSinglyPadded5gramsWithPreserveShort) {\n  MakeOp(\"|\", {5}, \"LP\", \"RP\", 1, true);\n  \/\/ Batch items are:\n  \/\/ 0: \"a\", \"b\", \"c\", \"d\"\n  \/\/ 1: \"e\", \"f\"\n  AddInputFromArray<tstring>(TensorShape({6}), {\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"});\n  AddInputFromArray<int64>(TensorShape({3}), {0, 4, 6});\n  TF_ASSERT_OK(RunOpKernel());\n\n  std::vector<tstring> expected_values(  \/\/\n      {\"LP|a|b|c|d\", \"a|b|c|d|RP\",       \/\/\n       \"LP|e|f|RP\"});\n  std::vector<int64> expected_splits({0, 2, 3});\n\n  assert_string_equal(expected_values, *GetOutput(0));\n  assert_int64_equal(expected_splits, *GetOutput(1));\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":521785,"func":"Field *Type_handler_double::make_conversion_table_field(TABLE *table,\n                                                        uint metadata,\n                                                        const Field *target)\n                                                        const\n{\n  return new (table->in_use->mem_root)\n         Field_double(NULL, 22 \/*max_length*\/, (uchar *) \"\", 1, Field::NONE,\n                      TMPNAME, 0\/*dec*\/, 0\/*zerofill*\/, 0\/*unsigned_flag*\/);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":77306,"func":"static void __init daring(int *ints, int param, int param2)\n{\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(default_drive_params); i++) {\n\t\tif (param) {\n\t\t\tdefault_drive_params[i].params.select_delay = 0;\n\t\t\tdefault_drive_params[i].params.flags |=\n\t\t\t    FD_SILENT_DCL_CLEAR;\n\t\t} else {\n\t\t\tdefault_drive_params[i].params.select_delay =\n\t\t\t    2 * HZ \/ 100;\n\t\t\tdefault_drive_params[i].params.flags &=\n\t\t\t    ~FD_SILENT_DCL_CLEAR;\n\t\t}\n\t}\n\tDPRINT(\"Assuming %s floppy hardware\\n\", param ? \"standard\" : \"broken\");\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":447764,"func":"idle_thread_data_free (gpointer ptr)\n{\n\tIdleThreadData *itd = ptr;\n\n\tif (itd) {\n\t\tg_clear_object (&itd->is);\n\t\tg_clear_object (&itd->idle_cancellable);\n\t\tg_slice_free (IdleThreadData, itd);\n\t}\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":8459,"func":"file_rlookup(const char *filename)\t\/* I - Filename *\/\n{\n  int\t\ti;\t\t\t\/* Looping var *\/\n  cache_t\t*wc;\t\t\t\/* Current cache file *\/\n\n\n  for (i = web_files, wc = web_cache; i > 0; i --, wc ++)\n    if (!strcmp(wc->name, filename))\n      return (wc->url);\n\n  return (filename);\n}","target":1,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":166806,"func":"void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index,\n                                                const Vector<GLfloat>& v) {\n  if (isContextLost())\n    return;\n  if (v.size() < 4) {\n    SynthesizeGLError(GL_INVALID_VALUE, \"vertexAttrib4fv\", \"invalid array\");\n    return;\n  }\n  ContextGL()->VertexAttrib4fv(index, v.data());\n  SetVertexAttribType(index, kFloat32ArrayType);\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":77886,"func":"GF_Box *trex_New()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackExtendsBox, GF_ISOM_BOX_TYPE_TREX);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":440608,"func":"static int vxlan_sock_add(struct vxlan_dev *vxlan)\n{\n\tbool metadata = vxlan->cfg.flags & VXLAN_F_COLLECT_METADATA;\n\tbool ipv6 = vxlan->cfg.flags & VXLAN_F_IPV6 || metadata;\n\tbool ipv4 = !ipv6 || metadata;\n\tint ret = 0;\n\n\tRCU_INIT_POINTER(vxlan->vn4_sock, NULL);\n#if IS_ENABLED(CONFIG_IPV6)\n\tRCU_INIT_POINTER(vxlan->vn6_sock, NULL);\n\tif (ipv6) {\n\t\tret = __vxlan_sock_add(vxlan, true);\n\t\tif (ret < 0 && ret != -EAFNOSUPPORT)\n\t\t\tipv4 = false;\n\t}\n#endif\n\tif (ipv4)\n\t\tret = __vxlan_sock_add(vxlan, false);\n\tif (ret < 0)\n\t\tvxlan_sock_release(vxlan);\n\treturn ret;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":114064,"func":"void put_task_stack(struct task_struct *tsk)\n{\n\tif (atomic_dec_and_test(&tsk->stack_refcount))\n\t\trelease_task_stack(tsk);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":307017,"func":"void log_error(const char *mesg)\n{\n    fprintf(stderr, \"%s%s\", get_commonlog_time(), mesg);\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":512669,"func":"char *ssh_get_user_home_dir(void)\n{\n    char *szPath = NULL;\n    struct passwd pwd;\n    struct passwd *pwdbuf = NULL;\n    char buf[NSS_BUFLEN_PASSWD] = {0};\n    int rc;\n\n    rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);\n    if (rc != 0 || pwdbuf == NULL ) {\n        szPath = getenv(\"HOME\");\n        if (szPath == NULL) {\n            return NULL;\n        }\n        snprintf(buf, sizeof(buf), \"%s\", szPath);\n\n        return strdup(buf);\n    }\n\n    szPath = strdup(pwd.pw_dir);\n\n    return szPath;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":188030,"func":"void DevToolsWindow::SetWindowBounds(int x, int y, int width, int height) {\n  if (!IsDocked())\n    browser_->window()->SetBounds(gfx::Rect(x, y, width, height));\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":204884,"func":"void Document::write(const SegmentedString& text, Document* ownerDocument)\n{\n    NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);\n\n    m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionIsTooDeep;\n    m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth) || m_writeRecursionIsTooDeep;\n\n    if (m_writeRecursionIsTooDeep)\n       return;\n\n    bool hasInsertionPoint = m_parser && m_parser->hasInsertionPoint();\n    if (!hasInsertionPoint && m_ignoreDestructiveWriteCount)\n        return;\n\n    if (!hasInsertionPoint)\n        open(ownerDocument);\n\n    ASSERT(m_parser);\n    m_parser->insert(text);\n}\n","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":446505,"func":"virDomainDefGetIOThreadSched(virDomainDefPtr def,\n                             unsigned int iothread)\n{\n    virDomainIOThreadIDDefPtr iothrinfo;\n\n    if (!(iothrinfo = virDomainIOThreadIDFind(def, iothread))) {\n        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,\n                       _(\"Cannot find 'iothread' : %u\"),\n                       iothread);\n        return NULL;\n    }\n\n    return &iothrinfo->sched;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":106862,"func":"static void vop_bh_handler(struct work_struct *work)\n{\n\tstruct vop_vdev *vdev = container_of(work, struct vop_vdev,\n\t\t\tvirtio_bh_work);\n\n\tif (vdev->dc->used_address_updated)\n\t\tvop_virtio_init_post(vdev);\n\n\tif (vdev->dc->vdev_reset)\n\t\tvop_virtio_device_reset(vdev);\n\n\tvdev->poll_wake = 1;\n\twake_up(&vdev->waitq);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":516361,"func":"MaybeLocal<Value> GetCipherVersion(Environment* env, const SSL_CIPHER* cipher) {\n  return GetCipherValue(env, cipher, SSL_CIPHER_get_version);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":16324,"func":"void irq_info ( Monitor * mon ) {\n }","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":113919,"func":"static int mailimf_minute_parse(const char * message, size_t length,\n\t\t\t\tsize_t * indx, int * result)\n{\n  uint32_t minute;\n  int r;\n\n  r = mailimf_number_parse(message, length, indx, &minute);\n  if (r != MAILIMF_NO_ERROR)\n    return r;\n\n  * result = minute;\n\n  return MAILIMF_NO_ERROR;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":19068,"func":"static void e1000e_set_rxcsum ( E1000ECore * core , int index , uint32_t val ) {\n core -> mac [ RXCSUM ] = val ;\n e1000e_update_rx_offloads ( core ) ;\n }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":424973,"func":"libssh2_hostkey_methods(void)\n{\n    return hostkey_methods;\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":408173,"func":"stdin_ungetc(int c)\n{\nreturn ungetc(c, stdin);\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":94842,"func":"String StringUtil::UUDecode(const String& input) {\n  if (!input.empty()) {\n    return string_uudecode(input.data(), input.size());\n  }\n  return String();\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":210645,"func":"bool ThreadSafeMatch(const Vector<UChar, inlineCapacity>& vector,\n                     const QualifiedName& qname) {\n  return EqualIgnoringNullity(vector, qname.LocalName().Impl());\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":35003,"func":"sc_get_iasecc_driver(void)\n{\n\treturn sc_get_driver();\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":282324,"func":"  bool IsReparentedNode(const AXNode* node) {\n    return IsNewNode(node) && IsRemovedNode(node);\n  }\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":203412,"func":"void JSArray::visitChildren(SlotVisitor& visitor)\n{\n    ASSERT_GC_OBJECT_INHERITS(this, &s_info);\n    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);\n    ASSERT(structure()->typeInfo().overridesVisitChildren());\n    visitChildrenDirect(visitor);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":452937,"func":"void notify_callback(struct smbd_server_connection *sconn,\n\t\t     void *private_data, struct timespec when,\n\t\t     const struct notify_event *e)\n{\n\tstruct notify_fsp_state state = {\n\t\t.notified_fsp = private_data, .when = when, .e = e\n\t};\n\tfiles_forall(sconn, notify_fsp_cb, &state);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":213486,"func":"base::string16 ChromeContentBrowserClient::GetAppContainerSidForSandboxType(\n    int sandbox_type) const {\n  switch (sandbox_type) {\n    case service_manager::SANDBOX_TYPE_RENDERER:\n      return base::string16(install_static::GetSandboxSidPrefix()) +\n             L\"129201922\";\n    case service_manager::SANDBOX_TYPE_UTILITY:\n      return base::string16();\n    case service_manager::SANDBOX_TYPE_GPU:\n      return base::string16();\n    case service_manager::SANDBOX_TYPE_PPAPI:\n      return base::string16(install_static::GetSandboxSidPrefix()) +\n             L\"129201925\";\n#if BUILDFLAG(ENABLE_NACL)\n    case PROCESS_TYPE_NACL_LOADER:\n      return base::string16();\n    case PROCESS_TYPE_NACL_BROKER:\n      return base::string16();\n#endif\n  }\n\n  CHECK(0);\n  return base::string16();\n}\n","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":252252,"func":"TransportDIB::Id TransportDIB::id() const {\n  return key_;\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":366580,"func":"MP4::Properties::~Properties()\n{\n  delete d;\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":212356,"func":"bool OMX::isSecure(node_id node) {\n OMXNodeInstance *instance = findInstance(node);\n return (instance == NULL ? false : instance->isSecure());\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":385673,"func":"ftp_rmdir(ftpbuf_t *ftp, const char *dir)\n{\n\tif (ftp == NULL) {\n\t\treturn 0;\n\t}\n\tif (!ftp_putcmd(ftp, \"RMD\", dir)) {\n\t\treturn 0;\n\t}\n\tif (!ftp_getresp(ftp) || ftp->resp != 250) {\n\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":441911,"func":"void task_join_group_stop(struct task_struct *task)\n{\n\t\/* Have the new thread join an on-going signal group stop *\/\n\tunsigned long jobctl = current->jobctl;\n\tif (jobctl & JOBCTL_STOP_PENDING) {\n\t\tstruct signal_struct *sig = current->signal;\n\t\tunsigned long signr = jobctl & JOBCTL_STOP_SIGMASK;\n\t\tunsigned long gstop = JOBCTL_STOP_PENDING | JOBCTL_STOP_CONSUME;\n\t\tif (task_set_jobctl_pending(task, signr | gstop)) {\n\t\t\tsig->group_stop_count++;\n\t\t}\n\t}\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":54002,"func":"append_ga_line(garray_T *gap)\n{\n    \/\/ Remove trailing CR.\n    if (gap->ga_len > 0\n\t    && !curbuf->b_p_bin\n\t    && ((char_u *)gap->ga_data)[gap->ga_len - 1] == CAR)\n\t--gap->ga_len;\n    ga_append(gap, NUL);\n    ml_append(curwin->w_cursor.lnum++, gap->ga_data, 0, FALSE);\n    gap->ga_len = 0;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":70117,"func":"f_assert_report(typval_T *argvars, typval_T *rettv)\n{\n    rettv->vval.v_number = assert_report(argvars);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":482086,"func":"static long ToL(unsigned char *puffer)\n{\n  return (puffer[0] | puffer[1] << 8 | puffer[2] << 16 | puffer[3] << 24);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":324308,"func":"static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len,\n\n    uint64_t prp1, uint64_t prp2)\n\n{\n\n    QEMUSGList qsg;\n\n    QEMUIOVector iov;\n\n    uint16_t status = NVME_SUCCESS;\n\n\n\n    if (nvme_map_prp(&qsg, &iov, prp1, prp2, len, n)) {\n\n        return NVME_INVALID_FIELD | NVME_DNR;\n\n    }\n\n    if (qsg.nsg > 0) {\n\n        if (dma_buf_read(ptr, len, &qsg)) {\n\n            status = NVME_INVALID_FIELD | NVME_DNR;\n\n        }\n\n        qemu_sglist_destroy(&qsg);\n\n    } else {\n\n        if (qemu_iovec_to_buf(&iov, 0, ptr, len) != len) {\n\n            status = NVME_INVALID_FIELD | NVME_DNR;\n\n        }\n\n        qemu_iovec_destroy(&iov);\n\n    }\n\n    return status;\n\n}\n","target":1,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":401984,"func":"xmlFreeElementTable(xmlElementTablePtr table) {\n    xmlHashFree(table, (xmlHashDeallocator) xmlFreeElement);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":462167,"func":"static void sungem_reset_rx(SunGEMState *s)\n{\n    trace_sungem_rx_reset();\n\n    \/* XXX Do RXCFG *\/\n    \/* XXX Check value *\/\n    s->rxdmaregs[RXDMA_FSZ >> 2] = 0x140;\n    s->rxdmaregs[RXDMA_DONE >> 2] = 0;\n    s->rxdmaregs[RXDMA_KICK >> 2] = 0;\n    s->rxdmaregs[RXDMA_CFG >> 2] = 0x1000010;\n    s->rxdmaregs[RXDMA_PTHRESH >> 2] = 0xf8;\n    s->rxdmaregs[RXDMA_BLANK >> 2] = 0;\n\n    sungem_update_masks(s);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":68031,"func":"static void cassignop2(JF, js_Ast *lhs, int postfix)\n{\n\tswitch (lhs->type) {\n\tcase EXP_IDENTIFIER:\n\t\temitline(J, F, lhs);\n\t\tif (postfix) emit(J, F, OP_ROT2);\n\t\temitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);\n\t\tbreak;\n\tcase EXP_INDEX:\n\t\temitline(J, F, lhs);\n\t\tif (postfix) emit(J, F, OP_ROT4);\n\t\temit(J, F, OP_SETPROP);\n\t\tbreak;\n\tcase EXP_MEMBER:\n\t\temitline(J, F, lhs);\n\t\tif (postfix) emit(J, F, OP_ROT3);\n\t\temitstring(J, F, OP_SETPROP_S, lhs->b->string);\n\t\tbreak;\n\tdefault:\n\t\tjsC_error(J, lhs, \"invalid l-value in assignment\");\n\t}\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":317091,"func":"  void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) {\n    modified_origins_ = origins;\n    modified_origins_type_ = type;\n  }\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":81071,"func":"bit_read_BL (Bit_Chain *dat)\n{\n  const unsigned char two_bit_code = bit_read_BB (dat);\n  if (two_bit_code == 0)\n    return bit_read_RL (dat);\n  else if (two_bit_code == 1)\n    return bit_read_RC (dat) & 0xFF;\n  else if (two_bit_code == 2)\n    return 0;\n  else \/* if (two_bit_code == 3) *\/\n    {\n      loglevel = dat->opts & DWG_OPTS_LOGLEVEL;\n      LOG_ERROR (\"bit_read_BL: unexpected 2-bit code: '11'\")\n      return 256;\n    }\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":91215,"func":"int generic_key_instantiate(struct key *key, struct key_preparsed_payload *prep)\n{\n\tint ret;\n\n\tpr_devel(\"==>%s()\\n\", __func__);\n\n\tret = key_payload_reserve(key, prep->quotalen);\n\tif (ret == 0) {\n\t\tkey->type_data.p[0] = prep->type_data[0];\n\t\tkey->type_data.p[1] = prep->type_data[1];\n\t\trcu_assign_keypointer(key, prep->payload[0]);\n\t\tkey->payload.data2[1] = prep->payload[1];\n\t\tprep->type_data[0] = NULL;\n\t\tprep->type_data[1] = NULL;\n\t\tprep->payload[0] = NULL;\n\t\tprep->payload[1] = NULL;\n\t}\n\tpr_devel(\"<==%s() = %d\\n\", __func__, ret);\n\treturn ret;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":441266,"func":"void RGWGetBucketPolicyStatus_ObjStore_S3::send_response()\n{\n  if (op_ret) {\n    set_req_state_err(s, op_ret);\n  }\n  dump_errno(s);\n  end_header(s, this, \"application\/xml\");\n  dump_start(s);\n\n  s->formatter->open_object_section_in_ns(\"PolicyStatus\", XMLNS_AWS_S3);\n  \/\/ https:\/\/docs.aws.amazon.com\/AmazonS3\/latest\/API\/RESTBucketGETPolicyStatus.html\n  \/\/ mentions TRUE and FALSE, but boto\/aws official clients seem to want lower\n  \/\/ case which is returned by AWS as well; so let's be bug to bug compatible\n  \/\/ with the API\n  s->formatter->dump_bool(\"IsPublic\", isPublic);\n  s->formatter->close_section();\n  rgw_flush_formatter_and_reset(s, s->formatter);\n\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":493897,"func":"static CURLcode expect100(struct Curl_easy *data,\n                          struct connectdata *conn,\n                          struct dynbuf *req)\n{\n  CURLcode result = CURLE_OK;\n  data->state.expect100header = FALSE; \/* default to false unless it is set\n                                          to TRUE below *\/\n  if(!data->state.disableexpect && Curl_use_http_1_1plus(data, conn) &&\n     (conn->httpversion < 20)) {\n    \/* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an\n       Expect: 100-continue to the headers which actually speeds up post\n       operations (as there is one packet coming back from the web server) *\/\n    const char *ptr = Curl_checkheaders(data, STRCONST(\"Expect\"));\n    if(ptr) {\n      data->state.expect100header =\n        Curl_compareheader(ptr, STRCONST(\"Expect:\"), STRCONST(\"100-continue\"));\n    }\n    else {\n      result = Curl_dyn_addn(req, STRCONST(\"Expect: 100-continue\\r\\n\"));\n      if(!result)\n        data->state.expect100header = TRUE;\n    }\n  }\n\n  return result;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":112971,"func":"  explicit SSLAcceptDestroyRunner(EventBase* evb, SSLHandshakeBase* base)\n      : SSLAcceptEvbRunner(evb), sslBase_(base) {}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":188945,"func":"NPObjectAccessorWithIdentifier::~NPObjectAccessorWithIdentifier() {\n  Var::PluginReleasePPVar(identifier_);\n}\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":320582,"func":"static void pmac_ide_writeb (void *opaque,\n\n                             target_phys_addr_t addr, uint32_t val)\n\n{\n\n    MACIOIDEState *d = opaque;\n\n\n\n    addr = (addr & 0xFFF) >> 4;\n\n    switch (addr) {\n\n    case 1 ... 7:\n\n        ide_ioport_write(&d->bus, addr, val);\n\n        break;\n\n    case 8:\n\n    case 22:\n\n        ide_cmd_write(&d->bus, 0, val);\n\n        break;\n\n    default:\n\n        break;\n\n    }\n\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":176688,"func":"CSSPaintValue::CSSPaintValue(\n    CSSCustomIdentValue* name,\n    Vector<scoped_refptr<CSSVariableData>>& variable_data)\n    : CSSPaintValue(name) {\n  argument_variable_data_.swap(variable_data);\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":485337,"func":"DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,\n       clear_ip_bgp_instance_all_ipv4_soft_in_cmd,\n       \"clear ip bgp view WORD * ipv4 (unicast|multicast) soft in\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"BGP view\\n\"\n       \"view name\\n\"\n       \"Clear all peers\\n\"\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  if (strncmp (argv[1], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,\n                          BGP_CLEAR_SOFT_IN, NULL);\n\n  return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,\n                        BGP_CLEAR_SOFT_IN, NULL);\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":411912,"func":"int ncp_dirhandle_free(struct ncp_server* server, __u8 dirhandle) {\n\tint result;\n\t\n\tncp_init_request_s(server, 20);\n\tncp_add_byte(server, dirhandle);\n\tresult = ncp_request(server, 22);\n\tncp_unlock_server(server);\n\treturn result;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":209619,"func":"bool MemBackendImpl::HasExceededStorageSize() const {\n  return current_size_ > max_size_;\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":220695,"func":"void ContentSecurityPolicy::EnforceStrictMixedContentChecking() {\n  insecure_request_policy_ |= kBlockAllMixedContent;\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":201599,"func":"void NavigationControllerImpl::CancelPendingReload() {\n  DCHECK(pending_reload_ != ReloadType::NONE);\n  pending_reload_ = ReloadType::NONE;\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":463038,"func":"Command* CommandHelpers::findCommand(StringData name) {\n    return globalCommandRegistry()->findCommand(name);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":483823,"func":"static ssize_t online_show(struct device *dev, struct device_attribute *attr,\n\t\t\t   char *buf)\n{\n\tbool val;\n\n\tdevice_lock(dev);\n\tval = !dev->offline;\n\tdevice_unlock(dev);\n\treturn sysfs_emit(buf, \"%u\\n\", val);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":217331,"func":"void GLES2Implementation::BufferSubDataHelperImpl(\n    GLenum target,\n    GLintptr offset,\n    GLsizeiptr size,\n    const void* data,\n    ScopedTransferBufferPtr* buffer) {\n  DCHECK(buffer);\n  DCHECK_GT(size, 0);\n\n  auto DoBufferSubData = [&](const std::array<uint32_t, 1>&,\n                             uint32_t copy_offset, uint32_t) {\n    helper_->BufferSubData(target, offset + copy_offset, buffer->size(),\n                           buffer->shm_id(), buffer->offset());\n    InvalidateReadbackBufferShadowDataCHROMIUM(GetBoundBufferHelper(target));\n  };\n\n  if (!TransferArraysAndExecute(size, buffer, DoBufferSubData,\n                                static_cast<const int8_t*>(data))) {\n    SetGLError(GL_OUT_OF_MEMORY, \"glBufferSubData\", \"out of memory\");\n  }\n}\n","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":17406,"func":"static unsigned char * extra_open_record ( unsigned char * bp , int dr_len , struct isoent * isoent , struct ctl_extr_rec * ctl ) {\n ctl -> bp = bp ;\n if ( bp != NULL ) bp += dr_len ;\n ctl -> use_extr = 0 ;\n ctl -> isoent = isoent ;\n ctl -> ce_ptr = NULL ;\n ctl -> cur_len = ctl -> dr_len = dr_len ;\n ctl -> limit = DR_LIMIT ;\n return ( bp ) ;\n }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":248887,"func":"   void CleanUp(DownloadId id) {\n    MockDownloadFile* file = download_file_factory_->GetExistingFile(id);\n    ASSERT_TRUE(file != NULL);\n\n    EXPECT_CALL(*file, Cancel());\n \n     download_file_manager_->CancelDownload(id);\n \n    EXPECT_EQ(NULL, download_file_manager_->GetDownloadFile(id));\n   }\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":450172,"func":"static int ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *ct)\n{\n\tif (nla_put_be32(skb, CTA_USE, htonl(atomic_read(&ct->ct_general.use))))\n\t\tgoto nla_put_failure;\n\treturn 0;\n\nnla_put_failure:\n\treturn -1;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":331746,"func":"static inline TCGv gen_ld16s(TCGv addr, int index)\n\n{\n\n    TCGv tmp = new_tmp();\n\n    tcg_gen_qemu_ld16s(tmp, addr, index);\n\n    return tmp;\n\n}\n","target":1,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":326110,"func":"QString *qstring_from_substr(const char *str, int start, int end)\n\n{\n\n    QString *qstring;\n\n\n\n    qstring = g_malloc(sizeof(*qstring));\n\n\n\n    qstring->length = end - start + 1;\n\n    qstring->capacity = qstring->length;\n\n\n\n    qstring->string = g_malloc(qstring->capacity + 1);\n\n    memcpy(qstring->string, str + start, qstring->length);\n\n    qstring->string[qstring->length] = 0;\n\n\n\n    QOBJECT_INIT(qstring, &qstring_type);\n\n\n\n    return qstring;\n\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":226111,"func":"Element* Document::createElement(const QualifiedName& q_name,\n                                 CreateElementFlags flags) {\n  Element* e = nullptr;\n\n  if (q_name.NamespaceURI() == xhtmlNamespaceURI)\n    e = HTMLElementFactory::createHTMLElement(q_name.LocalName(), *this, flags);\n  else if (q_name.NamespaceURI() == SVGNames::svgNamespaceURI)\n    e = SVGElementFactory::createSVGElement(q_name.LocalName(), *this, flags);\n\n  if (e)\n    saw_elements_in_known_namespaces_ = true;\n  else\n    e = Element::Create(q_name, this);\n\n  if (e->prefix() != q_name.Prefix())\n    e->SetTagNameForCreateElementNS(q_name);\n\n  DCHECK(q_name == e->TagQName());\n\n  return e;\n}\n","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":161524,"func":"static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension)\n{\n    \/* Fake a field iterator for the extension field.\n     * It is not actually safe to advance this iterator, but decode_field\n     * will not even try to. *\/\n    const pb_field_t *field = (const pb_field_t*)extension->type->arg;\n    (void)pb_field_iter_begin(iter, field, extension->dest);\n    iter->pData = extension->dest;\n    iter->pSize = &extension->found;\n    \n    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)\n    {\n        \/* For pointer extensions, the pointer is stored directly\n         * in the extension structure. This avoids having an extra\n         * indirection. *\/\n        iter->pData = &extension->dest;\n    }\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":425240,"func":"iommu_support_dev_iotlb (struct dmar_domain *domain, struct intel_iommu *iommu,\n\t\t\t u8 bus, u8 devfn)\n{\n\tstruct device_domain_info *info;\n\n\tassert_spin_locked(&device_domain_lock);\n\n\tif (!iommu->qi)\n\t\treturn NULL;\n\n\tlist_for_each_entry(info, &domain->devices, link)\n\t\tif (info->iommu == iommu && info->bus == bus &&\n\t\t    info->devfn == devfn) {\n\t\t\tif (info->ats_supported && info->dev)\n\t\t\t\treturn info;\n\t\t\tbreak;\n\t\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":213395,"func":"size_t HevcParameterSets::getSize(size_t index) {\n    CHECK_LT(index, mNalUnits.size());\n return mNalUnits[index]->size();\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":184570,"func":"bool OSExchangeData::HasString() const {\n  return provider_->HasString();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":132070,"func":"QPDFWriter::QPDFWriter(QPDF& pdf, char const* filename) :\n    pdf(pdf)\n{\n    init();\n    setOutputFilename(filename);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":434311,"func":"int mutt_remove_from_rx_list (RX_LIST **l, const char *str)\n{\n  RX_LIST *p, *last = NULL;\n  int rv = -1;\n\n  if (mutt_strcmp (\"*\", str) == 0)\n  {\n    mutt_free_rx_list (l);    \/* ``unCMD *'' means delete all current entries *\/\n    rv = 0;\n  }\n  else\n  {\n    p = *l;\n    last = NULL;\n    while (p)\n    {\n      if (ascii_strcasecmp (str, p->rx->pattern) == 0)\n      {\n\tmutt_free_regexp (&p->rx);\n\tif (last)\n\t  last->next = p->next;\n\telse\n\t  (*l) = p->next;\n\tFREE (&p);\n\trv = 0;\n      }\n      else\n      {\n\tlast = p;\n\tp = p->next;\n      }\n    }\n  }\n  return (rv);\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":272232,"func":"TEST(TensorSliceTest, UpdateToCover) {\n  \/\/ [2:4, :, 3:]\n  TensorSlice s({{2, 2}, {0, -1}, {3, 7}});\n  \/\/ [:, 1:4, 2:4]\n  TensorSlice other({{0, -1}, {1, 3}, {2, 2}});\n\n  s.UpdateToCover(other);\n  \/\/ [:, :, 2:]\n  EXPECT_EQ(\"-:-:2,8\", s.DebugString());\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":393268,"func":"xmlCharStrdup(const char *cur) {\n    const char *p = cur;\n\n    if (cur == NULL) return(NULL);\n    while (*p != '\\0') p++; \/* non input consuming *\/\n    return(xmlCharStrndup(cur, p - cur));\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":509407,"func":"size_t EC_GROUP_get_seed_len(const EC_GROUP *group)\n\t{\n\treturn group->seed_len;\n\t}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":152805,"func":"static int jpeg2000_read_bitstream_packets(Jpeg2000DecoderContext *s)\n{\n    int ret = 0;\n    int tileno;\n\n    for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) {\n        Jpeg2000Tile *tile = s->tile + tileno;\n\n        if (ret = init_tile(s, tileno))\n            return ret;\n\n        s->g = tile->tile_part[0].tpg;\n        if (ret = jpeg2000_decode_packets(s, tile))\n            return ret;\n    }\n\n    return 0;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":460613,"func":"LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx )\n{\n\tint \t\tiRDN;\n\tint \t\trc;\n\n\tassert( dn != NULL );\n\n\tfor ( iRDN = 0; dn[ iRDN ]; iRDN++ ) {\n\t\trc = LDAPRDN_rewrite( dn[ iRDN ], flags, ctx );\n\t\tif ( rc != LDAP_SUCCESS ) {\n\t\t\treturn rc;\n\t\t}\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":512239,"func":"void imap_parser_enable_literal_minus(struct imap_parser *parser)\n{\n\tparser->literal_minus = TRUE;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":450436,"func":"static void nfs4_open_done(struct rpc_task *task, void *calldata)\n{\n\tstruct nfs4_opendata *data = calldata;\n\n\tdata->rpc_status = task->tk_status;\n\n\tif (!nfs4_sequence_process(task, &data->o_res.seq_res))\n\t\treturn;\n\n\tif (task->tk_status == 0) {\n\t\tif (data->o_res.f_attr->valid & NFS_ATTR_FATTR_TYPE) {\n\t\t\tswitch (data->o_res.f_attr->mode & S_IFMT) {\n\t\t\tcase S_IFREG:\n\t\t\t\tbreak;\n\t\t\tcase S_IFLNK:\n\t\t\t\tdata->rpc_status = -ELOOP;\n\t\t\t\tbreak;\n\t\t\tcase S_IFDIR:\n\t\t\t\tdata->rpc_status = -EISDIR;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tdata->rpc_status = -ENOTDIR;\n\t\t\t}\n\t\t}\n\t\trenew_lease(data->o_res.server, data->timestamp);\n\t\tif (!(data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM))\n\t\t\tnfs_confirm_seqid(&data->owner->so_seqid, 0);\n\t}\n\tdata->rpc_done = true;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":206645,"func":"void RenderWidgetHostImpl::WasResized(bool scroll_focused_node_into_view) {\n  if (resize_ack_pending_ || !process_->HasConnection() || !view_ ||\n      !view_->HasSize() || !renderer_initialized_ || auto_resize_enabled_ ||\n      !delegate_) {\n    return;\n  }\n\n  std::unique_ptr<ResizeParams> params(new ResizeParams);\n  if (!GetResizeParams(params.get()))\n    return;\n  params->scroll_focused_node_into_view = scroll_focused_node_into_view;\n\n  ScreenInfo screen_info = params->screen_info;\n  bool width_changed =\n      !old_resize_params_ ||\n      old_resize_params_->new_size.width() != params->new_size.width();\n  if (Send(new ViewMsg_Resize(routing_id_, *params))) {\n    resize_ack_pending_ = params->needs_resize_ack;\n    next_resize_needs_resize_ack_ = false;\n    old_resize_params_.swap(params);\n  }\n\n  if (delegate_)\n    delegate_->RenderWidgetWasResized(this, screen_info, width_changed);\n}\n","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":329497,"func":"static void virtio_device_free_virtqueues(VirtIODevice *vdev)\n\n{\n\n    int i;\n\n    if (!vdev->vq) {\n\n        return;\n\n    }\n\n\n\n    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {\n\n        VRingMemoryRegionCaches *caches;\n\n        if (vdev->vq[i].vring.num == 0) {\n\n            break;\n\n        }\n\n        caches = atomic_read(&vdev->vq[i].vring.caches);\n\n        atomic_set(&vdev->vq[i].vring.caches, NULL);\n\n        virtio_free_region_cache(caches);\n\n    }\n\n    g_free(vdev->vq);\n\n}\n","target":1,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":139484,"func":"static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *field)\n{\n#ifdef PB_ENABLE_MALLOC\n    \/* When decoding an oneof field, check if there is old data that must be\n     * released first. *\/\n    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)\n    {\n        if (!pb_release_union_field(stream, field))\n            return false;\n    }\n#endif\n\n    switch (PB_ATYPE(field->type))\n    {\n        case PB_ATYPE_STATIC:\n            return decode_static_field(stream, wire_type, field);\n        \n        case PB_ATYPE_POINTER:\n            return decode_pointer_field(stream, wire_type, field);\n        \n        case PB_ATYPE_CALLBACK:\n            return decode_callback_field(stream, wire_type, field);\n        \n        default:\n            PB_RETURN_ERROR(stream, \"invalid field type\");\n    }\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":81795,"func":"  void Compute(OpKernelContext* ctx) override TF_LOCKS_EXCLUDED(mu_) {\n    mutex_lock l(mu_);\n    if (!initialized_) {\n      ResourceMgr* mgr = ctx->resource_manager();\n      OP_REQUIRES_OK(ctx, cinfo_.Init(mgr, def()));\n      ThreadPoolResource* resource;\n      OP_REQUIRES_OK(ctx, mgr->LookupOrCreate<ThreadPoolResource>(\n                              cinfo_.container(), cinfo_.name(), &resource,\n                              [this, ctx](ThreadPoolResource** ret)\n                                  TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {\n                                    *ret = new ThreadPoolResource(\n                                        ctx->env(), {}, display_name_,\n                                        num_threads_,\n                                        \/*low_latency_hint=*\/false,\n                                        max_intra_op_parallelism_);\n                                    return Status::OK();\n                                  }));\n      initialized_ = true;\n    }\n    OP_REQUIRES_OK(ctx, MakeResourceHandleToOutput(\n                            ctx, 0, cinfo_.container(), cinfo_.name(),\n                            TypeIndex::Make<ThreadPoolResource>()));\n  }","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":417274,"func":"static void update_child_status(h2_session *session, int status, const char *msg)\n{\n    \/* Assume that we also change code\/msg when something really happened and\n     * avoid updating the scoreboard in between *\/\n    if (session->last_status_code != status \n        || session->last_status_msg != msg) {\n        apr_snprintf(session->status, sizeof(session->status),\n                     \"%s, streams: %d\/%d\/%d\/%d\/%d (open\/recv\/resp\/push\/rst)\", \n                     msg? msg : \"-\",\n                     (int)session->open_streams, \n                     (int)session->remote.emitted_count,\n                     (int)session->responses_submitted,\n                     (int)session->pushes_submitted,\n                     (int)session->pushes_reset + session->streams_reset);\n        ap_update_child_status_descr(session->c->sbh, status, session->status);\n    }\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":190910,"func":"bool btif_config_get_str(const char *section, const char *key, char *value, int *size_bytes) {\n  assert(config != NULL);\n  assert(section != NULL);\n  assert(key != NULL);\n  assert(value != NULL);\n  assert(size_bytes != NULL);\n\n  pthread_mutex_lock(&lock);\n const char *stored_value = config_get_string(config, section, key, NULL);\n  pthread_mutex_unlock(&lock);\n\n if (!stored_value)\n return false;\n\n  strlcpy(value, stored_value, *size_bytes);\n *size_bytes = strlen(value) + 1;\n\n return true;\n}\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":357707,"func":"static status ParseList (AFfilehandle filehandle, AFvirtualfile *fp,\n\tuint32_t id, size_t size)\n{\n\tuint32_t\ttypeID;\n\n\taf_fread(&typeID, 4, 1, fp);\n\tsize-=4;\n\n\tif (memcmp(&typeID, \"adtl\", 4) == 0)\n\t{\n\t\t\/* Handle adtl sub-chunks. *\/\n\t\treturn ParseADTLSubChunk(filehandle, fp, typeID, size);\n\t}\n\telse if (memcmp(&typeID, \"INFO\", 4) == 0)\n\t{\n\t\t\/* Handle INFO sub-chunks. *\/\n\t\treturn ParseINFOSubChunk(filehandle, fp, typeID, size);\n\t}\n\telse\n\t{\n\t\t\/* Skip unhandled sub-chunks. *\/\n\t\taf_fseek(fp, size, SEEK_CUR);\n\t\treturn AF_SUCCEED;\n\t}\n\treturn AF_SUCCEED;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":220017,"func":"MockInvalidationStateTracker::~MockInvalidationStateTracker() {}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":143784,"func":"__mem_cgroup_remove_exceeded(struct mem_cgroup *memcg,\n\t\t\t\tstruct mem_cgroup_per_zone *mz,\n\t\t\t\tstruct mem_cgroup_tree_per_zone *mctz)\n{\n\tif (!mz->on_tree)\n\t\treturn;\n\trb_erase(&mz->tree_node, &mctz->rb_root);\n\tmz->on_tree = false;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":462931,"func":"Status InMatchExpression::init(StringData path) {\n    return setPath(path);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":35382,"func":"s32 gf_hevc_parse_nalu(u8 *data, u32 size, HEVCState *hevc, u8 *nal_unit_type, u8 *temporal_id, u8 *layer_id)\n{\n\tGF_BitStream *bs = NULL;\n\ts32 ret = -1;\n\n\tif (!hevc) {\n\t\tif (nal_unit_type) (*nal_unit_type) = (data[0] & 0x7E) >> 1;\n\t\tif (layer_id) {\n\t\t\tu8 id = data[0] & 1;\n\t\t\tid <<= 5;\n\t\t\tid |= (data[1] >> 3) & 0x1F;\n\t\t\t(*layer_id) = id;\n\t\t}\n\t\tif (temporal_id) (*temporal_id) = (data[1] & 0x7);\n\t\treturn -1;\n\t}\n\n\tbs = gf_bs_new(data, size, GF_BITSTREAM_READ);\n\tif (!bs) return -1;\n\tgf_bs_enable_emulation_byte_removal(bs, GF_TRUE);\n\n\tret = gf_hevc_parse_nalu_bs(bs, hevc, nal_unit_type, temporal_id, layer_id);\n\n\tgf_bs_del(bs);\n\treturn ret;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":270305,"func":"GF_Err chan_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_ChannelLayoutInfoBox *ptr = (GF_ChannelLayoutInfoBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\n\tgf_bs_write_u32(bs, ptr->layout_tag);\n\tgf_bs_write_u32(bs, ptr->bitmap);\n\tgf_bs_write_u32(bs, ptr->num_audio_description);\n\tfor (i=0; i<ptr->num_audio_description; i++) {\n\t\tGF_AudioChannelDescription *adesc = &ptr->audio_descs[i];\n\t\tgf_bs_write_u32(bs, adesc->label);\n\t\tgf_bs_write_u32(bs, adesc->flags);\n\t\tgf_bs_write_float(bs, adesc->coordinates[0]);\n\t\tgf_bs_write_float(bs, adesc->coordinates[1]);\n\t\tgf_bs_write_float(bs, adesc->coordinates[2]);\n\t}\n\n\treturn GF_OK;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":376762,"func":"HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object,\n                                                   HValue* key) {\n  HValue* context = environment()->LookupContext();\n  return new(zone()) HLoadKeyedGeneric(context, object, key);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":282160,"func":"OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() {\n  UserMetrics::RecordAction(UserMetricsAction(\"OutdatedPluginInfobar.Closed\"));\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":329306,"func":"int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1)\n\n{\n\n    int size, l;\n\n\n\n    if (f->is_write) {\n\n        abort();\n\n    }\n\n\n\n    size = size1;\n\n    while (size > 0) {\n\n        l = f->buf_size - f->buf_index;\n\n        if (l == 0) {\n\n            qemu_fill_buffer(f);\n\n            l = f->buf_size - f->buf_index;\n\n            if (l == 0) {\n\n                break;\n\n            }\n\n        }\n\n        if (l > size) {\n\n            l = size;\n\n        }\n\n        memcpy(buf, f->buf + f->buf_index, l);\n\n        f->buf_index += l;\n\n        buf += l;\n\n        size -= l;\n\n    }\n\n    return size1 - size;\n\n}\n","target":1,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":335251,"func":"static void test_visitor_in_native_list_uint64(TestInputVisitorData *data,\n\n                                               const void *unused)\n\n{\n\n    test_native_list_integer_helper(data, unused,\n\n                                    USER_DEF_NATIVE_LIST_UNION_KIND_U64);\n\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":42616,"func":"buf_slack(const buf_t *buf)\n{\n  if (!buf->tail)\n    return 0;\n  else\n    return CHUNK_REMAINING_CAPACITY(buf->tail);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":479254,"func":"    inline float abs(const float a) {\n      return (float)std::fabs((double)a);\n    }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":168687,"func":"void WebRTCVoidRequest::requestFailed(const WebString& error) const\n{\n    ASSERT(m_private.get());\n    m_private->requestFailed(error);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":481042,"func":"static bool is_obsolete_sp(struct kvm *kvm, struct kvm_mmu_page *sp)\n{\n\tif (sp->role.invalid)\n\t\treturn true;\n\n\t\/* TDP MMU pages due not use the MMU generation. *\/\n\treturn !sp->tdp_mmu_page &&\n\t       unlikely(sp->mmu_valid_gen != kvm->arch.mmu_valid_gen);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":52165,"func":"int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,\n\t\t\t const struct drm_framebuffer_funcs *funcs)\n{\n\tint ret;\n\n\tret = drm_mode_object_get(dev, &fb->base, DRM_MODE_OBJECT_FB);\n\tif (ret) {\n\t\treturn ret;\n\t}\n\n\tfb->dev = dev;\n\tfb->funcs = funcs;\n\tdev->mode_config.num_fb++;\n\tlist_add(&fb->head, &dev->mode_config.fb_list);\n\n\treturn 0;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":79450,"func":"uint Jsi_ListSize(Jsi_List *list) {\n    SIGASSERT(list, LIST);\n    return list->numEntries;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":502195,"func":"int samdb_msg_add_hash(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,\n\t\t       const char *attr_name, const struct samr_Password *hash)\n{\n\tstruct ldb_val val;\n\tval.data = talloc_memdup(mem_ctx, hash->hash, 16);\n\tif (!val.data) {\n\t\treturn ldb_oom(sam_ldb);\n\t}\n\tval.length = 16;\n\treturn ldb_msg_add_value(msg, attr_name, &val, NULL);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":474711,"func":"int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb)\n{\n\t\/* Only LLCP target mode for now *\/\n\tif (dev->dep_link_up == false) {\n\t\tkfree_skb(skb);\n\t\treturn -ENOLINK;\n\t}\n\n\treturn nfc_llcp_data_received(dev, skb);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":48143,"func":"mismatch_cnt_show(struct mddev *mddev, char *page)\n{\n\treturn sprintf(page, \"%llu\\n\",\n\t\t       (unsigned long long)\n\t\t       atomic64_read(&mddev->resync_mismatches));\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":294281,"func":"void prefetch_table(const void *tab, size_t len)\n{\n  const volatile byte *vtab = tab;\n  size_t i;\n\n  for (i = 0; len - i >= 8 * 32; i += 8 * 32)\n    {\n      (void)vtab[i + 0 * 32];\n      (void)vtab[i + 1 * 32];\n      (void)vtab[i + 2 * 32];\n      (void)vtab[i + 3 * 32];\n      (void)vtab[i + 4 * 32];\n      (void)vtab[i + 5 * 32];\n      (void)vtab[i + 6 * 32];\n      (void)vtab[i + 7 * 32];\n    }\n  for (; i < len; i += 32)\n    {\n      (void)vtab[i];\n    }\n\n  (void)vtab[len - 1];\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":132567,"func":"ZipFile::ZipFile (InputStream& stream)  : inputStream (&stream)\r\n{\r\n    init();\r\n}\r","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":31614,"func":"install_sublevel_end_handler(void (*handler) (void))\n{\n\tint i = 0;\n\tkeyword_t *keyword;\n\n\t\/* fetch last keyword *\/\n\tkeyword = vector_slot(keywords, vector_size(keywords) - 1);\n\n\tif (!keyword->active)\n\t\treturn;\n\n\t\/* position to last sub level *\/\n\tfor (i = 0; i < sublevel; i++)\n\t\tkeyword = vector_slot(keyword->sub, vector_size(keyword->sub) - 1);\n\tkeyword->sub_close_handler = handler;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":12527,"func":" void AcceleratedStaticBitmapImage::EnsureMailbox(MailboxSyncMode mode,\n                                                  GLenum filter) {\n   if (!texture_holder_->IsMailboxTextureHolder()) {\n     TRACE_EVENT0(\"blink\", \"AcceleratedStaticBitmapImage::EnsureMailbox\");\n \n    if (!original_skia_image_) {\n      RetainOriginalSkImage();\n    }\n\n    texture_holder_ = std::make_unique<MailboxTextureHolder>(\n        std::move(texture_holder_), filter);\n  }\n  texture_holder_->Sync(mode);\n }\n","target":1,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":483593,"func":"static inline void device_links_write_lock(void)\n{\n\tmutex_lock(&device_links_lock);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":196497,"func":"  SitePerProcessHighDPIBrowserTest() {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":523511,"func":"void st_select_lex::add_statistics(SELECT_LEX_UNIT *unit)\n{\n  for (;\n       unit;\n       unit= unit->next_unit())\n    for(SELECT_LEX *child= unit->first_select();\n        child;\n        child= child->next_select())\n    {\n      \/*\n        A subselect can add fields to an outer select.\n        Reserve space for them.\n      *\/\n      select_n_where_fields+= child->select_n_where_fields;\n      \/*\n        Aggregate functions in having clause may add fields\n        to an outer select. Count them also.\n      *\/\n      select_n_having_items+= child->select_n_having_items;\n    }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":455528,"func":"TEST_F(RenameCollectionTest, RenameDifferentDatabaseStayTempFalseSourceNotTemporary) {\n    _testRenameCollectionStayTemp(_opCtx.get(), _sourceNss, _targetNssDifferentDb, false, false);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":82258,"func":"SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)\n{\n\tzval *arr = (zval *) arg;\n\tphp_stream *s = SG(request_info).request_body;\n\tpost_var_data_t post_data;\n\n\tif (s && SUCCESS == php_stream_rewind(s)) {\n\t\tmemset(&post_data, 0, sizeof(post_data));\n\n\t\twhile (!php_stream_eof(s)) {\n\t\t\tchar buf[SAPI_POST_HANDLER_BUFSIZ] = {0};\n\t\t\tsize_t len = php_stream_read(s, buf, SAPI_POST_HANDLER_BUFSIZ);\n\n\t\t\tif (len && len != (size_t) -1) {\n\t\t\t\tsmart_str_appendl(&post_data.str, buf, len);\n\n\t\t\t\tif (SUCCESS != add_post_vars(arr, &post_data, 0 TSRMLS_CC)) {\n\t\t\t\t\tif (post_data.str.c) {\n\t\t\t\t\t\tefree(post_data.str.c);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (len != SAPI_POST_HANDLER_BUFSIZ){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tadd_post_vars(arr, &post_data, 1 TSRMLS_CC);\n\t\tif (post_data.str.c) {\n\t\t\tefree(post_data.str.c);\n\t\t}\n\t}\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":160949,"func":"void WebContents::WebContentsCreatedWithFullParams(\n    content::WebContents* source_contents,\n    int opener_render_process_id,\n    int opener_render_frame_id,\n    const content::mojom::CreateNewWindowParams& params,\n    content::WebContents* new_contents) {\n  ChildWebContentsTracker::CreateForWebContents(new_contents);\n  auto* tracker = ChildWebContentsTracker::FromWebContents(new_contents);\n  tracker->url = params.target_url;\n  tracker->frame_name = params.frame_name;\n  tracker->referrer = params.referrer.To<content::Referrer>();\n  tracker->raw_features = params.raw_features;\n  tracker->body = params.body;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":355873,"func":"const char *arch_vma_name(struct vm_area_struct *vma)\n{\n\tif (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso_base)\n\t\treturn \"[vdso]\";\n\treturn NULL;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":417551,"func":"bool MonCap::parse(const string& str, ostream *err)\n{\n  string s = str;\n  string::iterator iter = s.begin();\n  string::iterator end = s.end();\n\n  MonCapParser<string::iterator> g;\n  bool r = qi::parse(iter, end, g, *this);\n  \/\/MonCapGrant foo;\n  \/\/bool r = qi::phrase_parse(iter, end, g, ascii::space, foo);\n  if (r && iter == end) {\n    text = str;\n    return true;\n  }\n\n  \/\/ Make sure no grants are kept after parsing failed!\n  grants.clear();\n\n  if (err) {\n    if (iter != end)\n      *err << \"moncap parse failed, stopped at '\" << std::string(iter, end)\n\t   << \"' of '\" << str << \"'\\n\";\n    else\n      *err << \"moncap parse failed, stopped at end of '\" << str << \"'\\n\";\n  }\n\n  return false; \n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":201669,"func":"const URLPatternSet PermissionsData::policy_allowed_hosts() const {\n  base::AutoLock auto_lock(runtime_lock_);\n  return PolicyAllowedHostsUnsafe().Clone();\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":252755,"func":"WebPluginDelegatePepper::WebPluginDelegatePepper(\n    const base::WeakPtr<RenderView>& render_view,\n    NPAPI::PluginInstance *instance)\n    : render_view_(render_view),\n      plugin_(NULL),\n      instance_(instance),\n      nested_delegate_(NULL),\n#if defined(ENABLE_GPU)\n      command_buffer_(NULL),\n#endif\n      find_identifier_(-1),\n      method_factory3d_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),\n      current_choose_file_callback_(NULL),\n      current_choose_file_user_data_(NULL) {\n  memset(&window_, 0, sizeof(window_));\n  instance->set_windowless(true);\n  instance->set_transparent(true);\n}\n","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":369274,"func":"print_import_check (PKT_public_key * pk, PKT_user_id * id)\n{\n    char * buf;\n    byte fpr[24];\n    u32 keyid[2];\n    size_t i, pos = 0, n;\n\n    buf = xmalloc (17+41+id->len+32);\n    keyid_from_pk (pk, keyid);\n    sprintf (buf, \"%08X%08X \", keyid[0], keyid[1]);\n    pos = 17;\n    fingerprint_from_pk (pk, fpr, &n);\n    for (i = 0; i < n; i++, pos += 2)\n        sprintf (buf+pos, \"%02X\", fpr[i]);\n    strcat (buf, \" \");\n    pos += 1;\n    strcat (buf, id->name);\n    write_status_text (STATUS_IMPORT_CHECK, buf);\n    xfree (buf);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":97320,"func":"int gridfs_find_query( gridfs *gfs, bson *query,\n                       gridfile *gfile ) {\n\n    bson uploadDate;\n    bson finalQuery;\n    bson out;\n    int i;\n\n    bson_init( &uploadDate );\n    bson_append_int( &uploadDate, \"uploadDate\", -1 );\n    bson_finish( &uploadDate );\n\n    bson_init( &finalQuery );\n    bson_append_bson( &finalQuery, \"query\", query );\n    bson_append_bson( &finalQuery, \"orderby\", &uploadDate );\n    bson_finish( &finalQuery );\n\n    i = ( mongo_find_one( gfs->client, gfs->files_ns,\n                          &finalQuery, NULL, &out ) == MONGO_OK );\n    bson_destroy( &uploadDate );\n    bson_destroy( &finalQuery );\n    if ( !i )\n        return MONGO_ERROR;\n    else {\n        gridfile_init( gfs, &out, gfile );\n        bson_destroy( &out );\n        return MONGO_OK;\n    }\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":16042,"func":"bool contain_mutable_functions ( Node * clause ) {\n return contain_mutable_functions_walker ( clause , NULL ) ;\n }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":411922,"func":"static inline u8 BVAL(const void *data)\n{\n\treturn *(const u8 *)data;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":214263,"func":"BrowserChildProcessHost* BrowserChildProcessHost::FromID(int child_process_id) {\n  DCHECK_CURRENTLY_ON(BrowserThread::IO);\n  BrowserChildProcessHostImpl::BrowserChildProcessList* process_list =\n      g_child_process_list.Pointer();\n  for (BrowserChildProcessHostImpl* host : *process_list) {\n    if (host->GetData().id == child_process_id)\n      return host;\n  }\n  return nullptr;\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":494034,"func":"bool TinyGLTF::LoadASCIIFromString(Model *model, std::string *err,\n                                   std::string *warn, const char *str,\n                                   unsigned int length,\n                                   const std::string &base_dir,\n                                   unsigned int check_sections) {\n  is_binary_ = false;\n  bin_data_ = nullptr;\n  bin_size_ = 0;\n\n  return LoadFromString(model, err, warn, str, length, base_dir,\n                        check_sections);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":267830,"func":"iakerb_gss_wrap(OM_uint32 *minor_status, gss_ctx_id_t context_handle,\n                int conf_req_flag, gss_qop_t qop_req,\n                gss_buffer_t input_message_buffer, int *conf_state,\n                gss_buffer_t output_message_buffer)\n{\n    iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle;\n\n    if (ctx->gssc == GSS_C_NO_CONTEXT)\n        return GSS_S_NO_CONTEXT;\n\n    return krb5_gss_wrap(minor_status, ctx->gssc, conf_req_flag, qop_req,\n                         input_message_buffer, conf_state,\n                         output_message_buffer);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":200448,"func":"int EmbedStream::getChars(int nChars, Guchar *buffer) {\n  if (nChars <= 0) {\n    return 0;\n  }\n  if (limited && length < (Guint)nChars) {\n    nChars = (int)length;\n  }\n  return str->doGetChars(nChars, buffer);\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":98888,"func":"check_if_same_cert (gnutls_x509_crt_t cert1, gnutls_x509_crt_t cert2)\n{\n  gnutls_datum_t cert1bin = { NULL, 0 }, cert2bin =\n  {\n  NULL, 0};\n  int result;\n\n  result = _gnutls_x509_der_encode (cert1->cert, \"\", &cert1bin, 0);\n  if (result < 0)\n    {\n      gnutls_assert ();\n      goto cleanup;\n    }\n\n  result = _gnutls_x509_der_encode (cert2->cert, \"\", &cert2bin, 0);\n  if (result < 0)\n    {\n      gnutls_assert ();\n      goto cleanup;\n    }\n\n  if ((cert1bin.size == cert2bin.size) &&\n      (memcmp (cert1bin.data, cert2bin.data, cert1bin.size) == 0))\n    result = 0;\n  else\n    result = 1;\n\ncleanup:\n  _gnutls_free_datum (&cert1bin);\n  _gnutls_free_datum (&cert2bin);\n  return result;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":519179,"func":"void Field_time_hires::store_TIME(const MYSQL_TIME *ltime)\n{\n  DBUG_ASSERT(ltime->year == 0);\n  DBUG_ASSERT(ltime->month == 0);\n  ulonglong packed= sec_part_shift(pack_time(ltime), dec) + zero_point;\n  store_bigendian(packed, ptr, Field_time_hires::pack_length());\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":187046,"func":"void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback)\n{\n    RefPtr<DataCallback> callback = prpCallback;\n    if (!isValid()) {\n        callback->invalidate();\n        return;\n    }\n    \n    uint64_t callbackID = callback->callbackID();\n    m_dataCallbacks.set(callbackID, callback.get());\n    process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);\n}\n","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":257999,"func":"static char * main_format_millis ( long millis , shortbuf * buf ) {\n if ( millis < 1000 ) {\n short_sprintf ( * buf , \"%lu ms\" , millis ) ;\n }\n else if ( millis < 10000 ) {\n short_sprintf ( * buf , \"%.1f sec\" , millis \/ 1000.0 ) ;\n }\n else {\n short_sprintf ( * buf , \"%lu sec\" , millis \/ 1000L ) ;\n }\n return buf -> buf ;\n }","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":68103,"func":"bool Scanner::read(size_t want)\n{\n    DASSERT(!files.empty());\n    for (size_t i = files.size(); i --> 0; ) {\n        Input *in = files[i];\n        const size_t have = fread(lim, 1, want, in->file);\n        in->so = lim;\n        lim += have;\n        in->eo = lim;\n        want -= have;\n\n        \/\/ buffer filled\n        if (want == 0) return true;\n    }\n    return false;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":194048,"func":"void AddIncompatibleApplicationsStrings(content::WebUIDataSource* html_source) {\n  LocalizedString localized_strings[] = {\n      {\"incompatibleApplicationsResetCardTitle\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_RESET_CARD_TITLE},\n      {\"incompatibleApplicationsSubpageSubtitle\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_SUBPAGE_SUBTITLE},\n      {\"incompatibleApplicationsSubpageSubtitleNoAdminRights\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_SUBPAGE_SUBTITLE_NO_ADMIN_RIGHTS},\n      {\"incompatibleApplicationsListTitle\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_LIST_TITLE},\n      {\"incompatibleApplicationsRemoveButton\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_REMOVE_BUTTON},\n      {\"incompatibleApplicationsUpdateButton\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_UPDATE_BUTTON},\n      {\"incompatibleApplicationsDone\",\n       IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_DONE},\n  };\n  AddLocalizedStringsBulk(html_source, localized_strings,\n                          arraysize(localized_strings));\n  base::string16 learn_how_text = l10n_util::GetStringFUTF16(\n      IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_SUBPAGE_LEARN_HOW,\n      base::ASCIIToUTF16(\"chrome:\/\/placeholder\"));\n  html_source->AddString(\"incompatibleApplicationsSubpageLearnHow\",\n                         learn_how_text);\n}\n","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":494592,"func":"jwe_t * r_jwe_quick_parse(const char * jwe_str, uint32_t parse_flags, int x5u_flags) {\n  return r_jwe_quick_parsen(jwe_str, o_strlen(jwe_str), parse_flags, x5u_flags);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":197370,"func":"void FFmpegVideoDecodeEngine::ProduceVideoFrame(\n    scoped_refptr<VideoFrame> frame) {\n  DCHECK(frame.get() && !frame->IsEndOfStream());\n\n  pending_output_buffers_++;\n\n  frame_queue_available_.push_back(frame);\n\n  if (flush_pending_) {\n    TryToFinishPendingFlush();\n  } else if (!output_eos_reached_) {\n    ReadInput();\n  }\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":302784,"func":"_Unpickler_NewMemo(Py_ssize_t new_size)\n{\n    PyObject **memo = PyMem_NEW(PyObject *, new_size);\n    if (memo == NULL) {\n        PyErr_NoMemory();\n        return NULL;\n    }\n    memset(memo, 0, new_size * sizeof(PyObject *));\n    return memo;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":224664,"func":"void HWNDMessageHandler::OnInputLangChange(DWORD character_set,\n                                           HKL input_language_id) {\n  delegate_->HandleInputLanguageChange(character_set, input_language_id);\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":361027,"func":"maybe_kill_dialog (GSWindow *window)\n{\n        if (!window->priv->dialog_shake_in_progress\n            && window->priv->dialog_quit_requested\n            && window->priv->lock_pid > 0) {\n                kill (window->priv->lock_pid, SIGTERM);\n        }\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":208429,"func":"void WebContentsImpl::OnFindMatchRectsReply(\n    int version,\n    const std::vector<gfx::RectF>& rects,\n    const gfx::RectF& active_rect) {\n  if (delegate_)\n    delegate_->FindMatchRectsReply(this, version, rects, active_rect);\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":39217,"func":"static VOID SendDeviceIoControlRequestWorkItemRoutine (PDEVICE_OBJECT rootDeviceObject, SendDeviceIoControlRequestWorkItemArgs *arg)\n{\n\targ->Status = SendDeviceIoControlRequest (arg->deviceObject, arg->ioControlCode, arg->inputBuffer, arg->inputBufferSize, arg->outputBuffer, arg->outputBufferSize);\n\tKeSetEvent (&arg->WorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":87772,"func":"static void reply_pending_requests(struct btd_adapter *adapter)\n{\n\tGSList *l;\n\n\tif (!adapter)\n\t\treturn;\n\n\t\/* pending bonding *\/\n\tfor (l = adapter->devices; l; l = l->next) {\n\t\tstruct btd_device *device = l->data;\n\n\t\tif (device_is_bonding(device, NULL))\n\t\t\tdevice_bonding_failed(device,\n\t\t\t\t\t\tHCI_OE_USER_ENDED_CONNECTION);\n\t}\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":32499,"func":"GF_Box *cprt_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_CopyrightBox, GF_ISOM_BOX_TYPE_CPRT);\n\ttmp->packedLanguageCode[0] = 'u';\n\ttmp->packedLanguageCode[1] = 'n';\n\ttmp->packedLanguageCode[2] = 'd';\n\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":341638,"func":"static uint64_t mpc8544_guts_read(void *opaque, target_phys_addr_t addr,\n\n                                  unsigned size)\n\n{\n\n    uint32_t value = 0;\n\n    CPUPPCState *env = cpu_single_env;\n\n\n\n    addr &= MPC8544_GUTS_MMIO_SIZE - 1;\n\n    switch (addr) {\n\n    case MPC8544_GUTS_ADDR_PVR:\n\n        value = env->spr[SPR_PVR];\n\n        break;\n\n    case MPC8544_GUTS_ADDR_SVR:\n\n        value = env->spr[SPR_E500_SVR];\n\n        break;\n\n    default:\n\n        fprintf(stderr, \"guts: Unknown register read: %x\\n\", (int)addr);\n\n        break;\n\n    }\n\n\n\n    return value;\n\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":445960,"func":"static void rfx_profiler_free(RFX_CONTEXT* context)\n{\n\tPROFILER_FREE(context->priv->prof_rfx_decode_rgb)\n\tPROFILER_FREE(context->priv->prof_rfx_decode_component)\n\tPROFILER_FREE(context->priv->prof_rfx_rlgr_decode)\n\tPROFILER_FREE(context->priv->prof_rfx_differential_decode)\n\tPROFILER_FREE(context->priv->prof_rfx_quantization_decode)\n\tPROFILER_FREE(context->priv->prof_rfx_dwt_2d_decode)\n\tPROFILER_FREE(context->priv->prof_rfx_ycbcr_to_rgb)\n\tPROFILER_FREE(context->priv->prof_rfx_encode_rgb)\n\tPROFILER_FREE(context->priv->prof_rfx_encode_component)\n\tPROFILER_FREE(context->priv->prof_rfx_rlgr_encode)\n\tPROFILER_FREE(context->priv->prof_rfx_differential_encode)\n\tPROFILER_FREE(context->priv->prof_rfx_quantization_encode)\n\tPROFILER_FREE(context->priv->prof_rfx_dwt_2d_encode)\n\tPROFILER_FREE(context->priv->prof_rfx_rgb_to_ycbcr)\n\tPROFILER_FREE(context->priv->prof_rfx_encode_format_rgb)\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":24230,"func":"static ssize_t iso9660_write_data ( struct archive_write * a , const void * buff , size_t s ) {\n struct iso9660 * iso9660 = a -> format_data ;\n ssize_t r ;\n if ( iso9660 -> cur_file == NULL ) return ( 0 ) ;\n if ( archive_entry_filetype ( iso9660 -> cur_file -> entry ) != AE_IFREG ) return ( 0 ) ;\n if ( s > iso9660 -> bytes_remaining ) s = ( size_t ) iso9660 -> bytes_remaining ;\n if ( s == 0 ) return ( 0 ) ;\n r = write_iso9660_data ( a , buff , s ) ;\n if ( r > 0 ) iso9660 -> bytes_remaining -= r ;\n return ( r ) ;\n }","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":188376,"func":"static int assign_host_irq(struct kvm *kvm,\n\t\t\t   struct kvm_assigned_dev_kernel *dev,\n\t\t\t   __u32 host_irq_type)\n{\n\tint r = -EEXIST;\n\n\tif (dev->irq_requested_type & KVM_DEV_IRQ_HOST_MASK)\n\t\treturn r;\n\n\tsnprintf(dev->irq_name, sizeof(dev->irq_name), \"kvm:%s\",\n\t\t pci_name(dev->dev));\n\n\tswitch (host_irq_type) {\n\tcase KVM_DEV_IRQ_HOST_INTX:\n\t\tr = assigned_device_enable_host_intx(kvm, dev);\n\t\tbreak;\n#ifdef __KVM_HAVE_MSI\n\tcase KVM_DEV_IRQ_HOST_MSI:\n\t\tr = assigned_device_enable_host_msi(kvm, dev);\n\t\tbreak;\n#endif\n#ifdef __KVM_HAVE_MSIX\n\tcase KVM_DEV_IRQ_HOST_MSIX:\n\t\tr = assigned_device_enable_host_msix(kvm, dev);\n\t\tbreak;\n#endif\n\tdefault:\n\t\tr = -EINVAL;\n\t}\n\n\tif (!r)\n\t\tdev->irq_requested_type |= host_irq_type;\n\n\treturn r;\n}\n","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":251603,"func":"barrier_blocks_device(struct PointerBarrierClient *client,\n                      DeviceIntPtr dev)\n{\n    int i;\n    int master_id;\n\n    \/* Clients with no devices are treated as\n     * if they specified XIAllDevices. *\/\n    if (client->num_devices == 0)\n        return TRUE;\n\n    master_id = GetMaster(dev, POINTER_OR_FLOAT)->id;\n\n    for (i = 0; i < client->num_devices; i++) {\n        int device_id = client->device_ids[i];\n        if (device_id == XIAllDevices ||\n            device_id == XIAllMasterDevices ||\n            device_id == master_id)\n            return TRUE;\n    }\n\n    return FALSE;\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":374865,"func":"_copyBitmapAnd(const BitmapAnd *from)\n{\n\tBitmapAnd  *newnode = makeNode(BitmapAnd);\n\n\t\/*\n\t * copy node superclass fields\n\t *\/\n\tCopyPlanFields((const Plan *) from, (Plan *) newnode);\n\n\t\/*\n\t * copy remainder of node\n\t *\/\n\tCOPY_NODE_FIELD(bitmapplans);\n\n\treturn newnode;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":425536,"func":"static struct bpf_blk *_gen_bpf_action(struct bpf_state *state,\n\t\t\t\t       struct bpf_blk *blk, uint32_t action)\n{\n\tstruct bpf_instr instr;\n\n\t_BPF_INSTR(instr, _BPF_OP(state->arch, BPF_RET),\n\t\t   _BPF_JMP_NO, _BPF_JMP_NO, _BPF_K(state->arch, action));\n\treturn _blk_append(state, blk, &instr);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":172260,"func":"SVGDocumentExtensions& Document::AccessSVGExtensions() {\n  if (!svg_extensions_)\n    svg_extensions_ = new SVGDocumentExtensions(this);\n  return *svg_extensions_;\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":229673,"func":"std::string ExtensionWebContentsObserver::GetExtensionId(\n    content::RenderViewHost* render_view_host) {\n  const GURL& site = render_view_host->GetSiteInstance()->GetSiteURL();\n\n  if (!site.SchemeIs(kExtensionScheme))\n    return std::string();\n\n  return site.host();\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":442757,"func":"static void hci_cc_read_clock(struct hci_dev *hdev, struct sk_buff *skb)\n{\n\tstruct hci_rp_read_clock *rp = (void *) skb->data;\n\tstruct hci_cp_read_clock *cp;\n\tstruct hci_conn *conn;\n\n\tBT_DBG(\"%s\", hdev->name);\n\n\tif (skb->len < sizeof(*rp))\n\t\treturn;\n\n\tif (rp->status)\n\t\treturn;\n\n\thci_dev_lock(hdev);\n\n\tcp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK);\n\tif (!cp)\n\t\tgoto unlock;\n\n\tif (cp->which == 0x00) {\n\t\thdev->clock = le32_to_cpu(rp->clock);\n\t\tgoto unlock;\n\t}\n\n\tconn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));\n\tif (conn) {\n\t\tconn->clock = le32_to_cpu(rp->clock);\n\t\tconn->clock_accuracy = le16_to_cpu(rp->accuracy);\n\t}\n\nunlock:\n\thci_dev_unlock(hdev);\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":115020,"func":"static int snd_seq_ioctl_set_queue_tempo(struct snd_seq_client *client,\n\t\t\t\t\t void *arg)\n{\n\tstruct snd_seq_queue_tempo *tempo = arg;\n\tint result;\n\n\tresult = snd_seq_set_queue_tempo(client->number, tempo);\n\treturn result < 0 ? result : 0;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":315191,"func":"AppCacheResponseWriter* AppCacheUpdateJob::CreateResponseWriter() {\n  AppCacheResponseWriter* writer =\n      storage_->CreateResponseWriter(manifest_url_,\n                                                group_->group_id());\n  stored_response_ids_.push_back(writer->response_id());\n  return writer;\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":213285,"func":"void OneClickSigninHelper::ShowSigninErrorBubble(Browser* browser,\n                                                 const std::string& error) {\n  DCHECK(!error.empty());\n\n  browser->window()->ShowOneClickSigninBubble(\n      BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,\n      string16(), \/* no SAML email *\/\n      UTF8ToUTF16(error),\n      BrowserWindow::StartSyncCallback());\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":104542,"func":"cmsBool CMSEXPORT cmsIT8SetPropertyUncooked(cmsHANDLE hIT8, const char* Key, const char* Buffer)\n{\n    cmsIT8* it8 = (cmsIT8*) hIT8;\n\n    return AddToList(it8, &GetTable(it8)->HeaderList, Key, NULL, Buffer, WRITE_UNCOOKED) != NULL;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":199727,"func":" void BluetoothDeviceChromeOS::SetPasskey(uint32 passkey) {\n  if (!pairing_context_.get())\n     return;\n \n  pairing_context_->SetPasskey(passkey);\n }\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":521648,"func":"bool Field_geom::load_data_set_null(THD *thd)\n{\n  Field_blob::reset();\n  if (!maybe_null())\n  {\n    my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field_name,\n             thd->get_stmt_da()->current_row_for_warning());\n    return true;\n  }\n  set_null();\n  set_has_explicit_value(); \/\/ Do not auto-update this field\n  return false;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":403499,"func":"static void stmt_clear_error(MYSQL_STMT *stmt)\n{\n  if (stmt->last_errno)\n  {\n    stmt->last_errno= 0;\n    stmt->last_error[0]= '\\0';\n    strmov(stmt->sqlstate, not_error_sqlstate);\n  }\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":397273,"func":"static int ehci_get_fetch_addr(EHCIState *s, int async)\n{\n    return async ? s->a_fetch_addr : s->p_fetch_addr;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":281702,"func":"  void VerifyPrintPreviewFailed(bool did_fail) {\n    bool print_preview_failed = (render_thread_.sink().GetUniqueMessageMatching(\n        PrintHostMsg_PrintPreviewFailed::ID) != NULL);\n    EXPECT_EQ(did_fail, print_preview_failed);\n  }\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":291585,"func":"\nGF_Err jp2h_box_size(GF_Box *s)\n{\n\treturn GF_OK;","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":279773,"func":"size_t ZSTD_compress_advanced_internal(\n        ZSTD_CCtx* cctx,\n        void* dst, size_t dstCapacity,\n        const void* src, size_t srcSize,\n        const void* dict,size_t dictSize,\n        ZSTD_CCtx_params params)\n{\n    DEBUGLOG(4, \"ZSTD_compress_advanced_internal (srcSize:%u)\", (U32)srcSize);\n    CHECK_F( ZSTD_compressBegin_internal(cctx,\n                         dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast, NULL,\n                         params, srcSize, ZSTDb_not_buffered) );\n    return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize);\n}\n","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":153048,"func":"bool kvm_is_reserved_pfn(kvm_pfn_t pfn)\n{\n\tif (pfn_valid(pfn))\n\t\treturn PageReserved(pfn_to_page(pfn));\n\n\treturn true;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":254423,"func":"void AuthenticatorBlePowerOnManualSheetModel::OnAccept() {\n  dialog_model()->ContinueWithFlowAfterBleAdapterPowered();\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":441339,"func":"int RGWCompleteMultipart_ObjStore_S3::get_params()\n{\n  int ret = RGWCompleteMultipart_ObjStore::get_params();\n  if (ret < 0) {\n    return ret;\n  }\n\n  map_qs_metadata(s);\n\n  return do_aws4_auth_completion();\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":256883,"func":"static void print_xml_comment ( FILE * xml_file , size_t len , const char * comment_string ) {\n const char * end ;\n fputs ( \"<!-- \" , xml_file ) ;\n for ( end = comment_string + len ;\n comment_string != end ;\n comment_string ++ ) {\n switch ( * comment_string ) {\n case '-' : if ( * ( comment_string + 1 ) == '-' ) break ;\n default : fputc ( * comment_string , xml_file ) ;\n break ;\n }\n }\n fputs ( \" -->\\n\" , xml_file ) ;\n check_io ( xml_file ) ;\n }","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":521873,"func":"bool Item_func::count_string_result_length(enum_field_types field_type_arg,\n                                           Item **items, uint nitems)\n{\n  if (agg_arg_charsets_for_string_result(collation, items, nitems, 1))\n    return true;\n  if (is_temporal_type(field_type_arg))\n    count_datetime_length(field_type_arg, items, nitems);\n  else\n  {\n    count_only_length(items, nitems);\n    decimals= max_length ? NOT_FIXED_DEC : 0;\n  }\n  return false;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":282670,"func":"void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd,\n                                   const RendererPreferences& renderer_prefs,\n                                   const WebPreferences& webkit_prefs,\n                                   int32 view_id) {\n  EnsureWebKitInitialized();\n  RenderView::Create(\n      this, parent_hwnd, MSG_ROUTING_NONE, renderer_prefs,\n      webkit_prefs, new SharedRenderViewCounter(0), view_id);\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":380841,"func":"XMLRPC_VALUE XMLRPC_CreateValueDouble(const char* id, double d) {\n   XMLRPC_VALUE val = XMLRPC_CreateValueEmpty();\n   if(val) {\n      XMLRPC_SetValueDouble(val, d);\n      if(id) {\n         XMLRPC_SetValueID(val, id, 0);\n      }\n   }\n   return val;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":139073,"func":"static void *counter_func(void *arg){\n\n  {\n    set_pid_priority(0,SCHED_FIFO,sched_get_priority_min(SCHED_FIFO),\"Unable to set SCHED_FIFO for %d (\\\"%s\\\"). (%s)\", \"the counter_func\");\n  }\n\n  for(;;){\n    counter++;\n    if(verbose)\n      print_error(stderr,\"counter set to %d\",counter);\n    sleep(increasetime);\n  }\n  return NULL;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":153958,"func":"static struct hash_cell *__get_dev_cell(uint64_t dev)\n{\n\tstruct mapped_device *md;\n\tstruct hash_cell *hc;\n\n\tmd = dm_get_md(huge_decode_dev(dev));\n\tif (!md)\n\t\treturn NULL;\n\n\thc = dm_get_mdptr(md);\n\tif (!hc) {\n\t\tdm_put(md);\n\t\treturn NULL;\n\t}\n\n\treturn hc;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":171272,"func":"void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUM(GLuint program,\n                                                               GLsizei bufsize,\n                                                               GLsizei* size,\n                                                               void* info) {\n  GPU_CLIENT_SINGLE_THREAD_CHECK();\n  if (bufsize < 0) {\n    SetGLError(GL_INVALID_VALUE, \"glGetTransformFeedbackVaryingsCHROMIUM\",\n               \"bufsize less than 0.\");\n    return;\n  }\n  if (size == nullptr) {\n    SetGLError(GL_INVALID_VALUE, \"glGetTransformFeedbackVaryingsCHROMIUM\",\n               \"size is null.\");\n    return;\n  }\n  DCHECK_EQ(0, *size);\n  std::vector<int8_t> result;\n  GetTransformFeedbackVaryingsCHROMIUMHelper(program, &result);\n  if (result.empty()) {\n    return;\n  }\n  *size = result.size();\n  if (!info) {\n    return;\n  }\n  if (static_cast<size_t>(bufsize) < result.size()) {\n    SetGLError(GL_INVALID_OPERATION, \"glGetTransformFeedbackVaryingsCHROMIUM\",\n               \"bufsize is too small for result.\");\n    return;\n  }\n  memcpy(info, &result[0], result.size());\n}\n","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":90433,"func":"Word enqueueSharedQueueHandler(void* raw_context, Word token, Word data_ptr, Word data_size) {\n  auto context = WASM_CONTEXT(raw_context);\n  auto data = context->wasmVm()->getMemory(data_ptr.u64_, data_size.u64_);\n  if (!data) {\n    return wasmResultToWord(WasmResult::InvalidMemoryAccess);\n  }\n  return wasmResultToWord(context->enqueueSharedQueue(token.u32(), data.value()));\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":435201,"func":"psutil_boot_time(PyObject *self, PyObject *args) {\n    \/\/ fetch sysctl \"kern.boottime\"\n    static int request[2] = { CTL_KERN, KERN_BOOTTIME };\n    struct timeval boottime;\n    size_t len = sizeof(boottime);\n\n    if (sysctl(request, 2, &boottime, &len, NULL, 0) == -1)\n        return PyErr_SetFromErrno(PyExc_OSError);\n    return Py_BuildValue(\"d\", (double)boottime.tv_sec);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":201181,"func":" static sk_sp<SkImage> unPremulSkImageToPremul(SkImage* input) {\n  SkImageInfo info = SkImageInfo::Make(input->width(), input->height(),\n                                       kN32_SkColorType, kPremul_SkAlphaType);\n  RefPtr<Uint8Array> dstPixels = copySkImageData(input, info);\n  if (!dstPixels)\n     return nullptr;\n   return newSkImageFromRaster(\n       info, std::move(dstPixels),\n      static_cast<unsigned>(input->width()) * info.bytesPerPixel());\n }\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":68414,"func":"static int cipso_v4_bitmap_walk(const unsigned char *bitmap,\n\t\t\t\tu32 bitmap_len,\n\t\t\t\tu32 offset,\n\t\t\t\tu8 state)\n{\n\tu32 bit_spot;\n\tu32 byte_offset;\n\tunsigned char bitmask;\n\tunsigned char byte;\n\n\t\/* gcc always rounds to zero when doing integer division *\/\n\tbyte_offset = offset \/ 8;\n\tbyte = bitmap[byte_offset];\n\tbit_spot = offset;\n\tbitmask = 0x80 >> (offset % 8);\n\n\twhile (bit_spot < bitmap_len) {\n\t\tif ((state && (byte & bitmask) == bitmask) ||\n\t\t    (state == 0 && (byte & bitmask) == 0))\n\t\t\treturn bit_spot;\n\n\t\tbit_spot++;\n\t\tbitmask >>= 1;\n\t\tif (bitmask == 0) {\n\t\t\tbyte = bitmap[++byte_offset];\n\t\t\tbitmask = 0x80;\n\t\t}\n\t}\n\n\treturn -1;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":99724,"func":"static void binder_deferred_flush(struct binder_proc *proc)\n{\n\tstruct rb_node *n;\n\tint wake_count = 0;\n\n\tbinder_inner_proc_lock(proc);\n\tfor (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) {\n\t\tstruct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node);\n\n\t\tthread->looper_need_return = true;\n\t\tif (thread->looper & BINDER_LOOPER_STATE_WAITING) {\n\t\t\twake_up_interruptible(&thread->wait);\n\t\t\twake_count++;\n\t\t}\n\t}\n\tbinder_inner_proc_unlock(proc);\n\n\tbinder_debug(BINDER_DEBUG_OPEN_CLOSE,\n\t\t     \"binder_flush: %d woke %d threads\\n\", proc->pid,\n\t\t     wake_count);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":227643,"func":"PPVarArrayFromNPVariantArray::~PPVarArrayFromNPVariantArray() {\n  for (size_t i = 0; i < size_; i++)\n    Var::PluginReleasePPVar(array_[i]);\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":251022,"func":"static void *t_start(struct seq_file *m, loff_t *pos)\n{\n\tstruct trace_array *tr = m->private;\n\tstruct tracer *t;\n\tloff_t l = 0;\n\n\tmutex_lock(&trace_types_lock);\n\n\tt = get_tracer_for_array(tr, trace_types);\n\tfor (; t && l < *pos; t = t_next(m, t, &l))\n\t\t\t;\n\n\treturn t;\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":425417,"func":"static void __iommu_flush_context(struct intel_iommu *iommu,\n\t\t\t\t  u16 did, u16 source_id, u8 function_mask,\n\t\t\t\t  u64 type)\n{\n\tu64 val = 0;\n\tunsigned long flag;\n\n\tswitch (type) {\n\tcase DMA_CCMD_GLOBAL_INVL:\n\t\tval = DMA_CCMD_GLOBAL_INVL;\n\t\tbreak;\n\tcase DMA_CCMD_DOMAIN_INVL:\n\t\tval = DMA_CCMD_DOMAIN_INVL|DMA_CCMD_DID(did);\n\t\tbreak;\n\tcase DMA_CCMD_DEVICE_INVL:\n\t\tval = DMA_CCMD_DEVICE_INVL|DMA_CCMD_DID(did)\n\t\t\t| DMA_CCMD_SID(source_id) | DMA_CCMD_FM(function_mask);\n\t\tbreak;\n\tdefault:\n\t\tBUG();\n\t}\n\tval |= DMA_CCMD_ICC;\n\n\traw_spin_lock_irqsave(&iommu->register_lock, flag);\n\tdmar_writeq(iommu->reg + DMAR_CCMD_REG, val);\n\n\t\/* Make sure hardware complete it *\/\n\tIOMMU_WAIT_OP(iommu, DMAR_CCMD_REG,\n\t\tdmar_readq, (!(val & DMA_CCMD_ICC)), val);\n\n\traw_spin_unlock_irqrestore(&iommu->register_lock, flag);\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":111299,"func":"int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)\n{\n\tstruct sock *sk, *prev = NULL;\n\tint ret = NET_RX_SUCCESS;\n\tu16 pan_id, short_addr;\n\n\t\/* Data frame processing *\/\n\tBUG_ON(dev->type != ARPHRD_IEEE802154);\n\n\tpan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev);\n\tshort_addr = ieee802154_mlme_ops(dev)->get_short_addr(dev);\n\n\tread_lock(&dgram_lock);\n\tsk_for_each(sk, &dgram_head) {\n\t\tif (ieee802154_match_sock(dev->dev_addr, pan_id, short_addr,\n\t\t\t\t\tdgram_sk(sk))) {\n\t\t\tif (prev) {\n\t\t\t\tstruct sk_buff *clone;\n\t\t\t\tclone = skb_clone(skb, GFP_ATOMIC);\n\t\t\t\tif (clone)\n\t\t\t\t\tdgram_rcv_skb(prev, clone);\n\t\t\t}\n\n\t\t\tprev = sk;\n\t\t}\n\t}\n\n\tif (prev)\n\t\tdgram_rcv_skb(prev, skb);\n\telse {\n\t\tkfree_skb(skb);\n\t\tret = NET_RX_DROP;\n\t}\n\tread_unlock(&dgram_lock);\n\n\treturn ret;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":334650,"func":"static always_inline void gen_op_subfo_64 (void)\n\n{\n\n    gen_op_move_T2_T0();\n\n    gen_op_subf();\n\n    gen_op_check_subfo_64();\n\n}\n","target":1,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":184560,"func":" GURL GetFileManagerMainPageUrl() {\n   return GetFileManagerUrl(\"\/main.html\");\n }\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":129725,"func":"void rose_loopback_init(void)\n{\n\tskb_queue_head_init(&loopback_queue);\n\n\tinit_timer(&loopback_timer);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":280238,"func":"String8 Parcel::readString8() const\n{\n int32_t size = readInt32();\n if (size > 0 && size < INT32_MAX) {\n const char* str = (const char*)readInplace(size+1);\n if (str) return String8(str, size);\n }\n return String8();\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":409759,"func":" *\/\nbool skb_gso_validate_mtu(const struct sk_buff *skb, unsigned int mtu)\n{\n\treturn skb_gso_size_check(skb, skb_gso_network_seglen(skb), mtu);","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":438362,"func":"VideoTrack::~VideoTrack() {\n  delete colour_;\n  delete projection_;\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":245675,"func":"bool NPJSObject::NP_Construct(NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)\n{\n    return toNPJSObject(npObject)->construct(arguments, argumentCount, result);\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":483870,"func":"static int memory_block_change_state(struct memory_block *mem,\n\t\tunsigned long to_state, unsigned long from_state_req)\n{\n\tint ret = 0;\n\n\tif (mem->state != from_state_req)\n\t\treturn -EINVAL;\n\n\tif (to_state == MEM_OFFLINE)\n\t\tmem->state = MEM_GOING_OFFLINE;\n\n\tret = memory_block_action(mem->start_section_nr, to_state,\n\t\t\t\t  mem->online_type, mem->nid);\n\n\tmem->state = ret ? from_state_req : to_state;\n\n\treturn ret;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":475176,"func":"static bool check_transfer_iovec(struct vrend_resource *res,\n                                 const struct vrend_transfer_info *info)\n{\n   return (info->iovec && info->iovec_cnt) || res->iov;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":32547,"func":"void av_max_alloc(size_t max){\n    max_alloc_size = max;\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":117877,"func":"static void mpol_rebind_default(struct mempolicy *pol, const nodemask_t *nodes)\n{\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":58743,"func":"bool Router::Route(string_view url, ViewPtr view, const Strings& methods) {\n  assert(view);\n\n  \/\/ TODO: More error check\n\n  routes_.push_back({ ToString(url), {}, view, methods });\n\n  return true;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":478319,"func":"    CImg<T> get_fill(const T& val0, const T& val1, const T& val2) const {\n      return CImg<T>(_width,_height,_depth,_spectrum).fill(val0,val1,val2);\n    }","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":132416,"func":"static bool tcp_pause_early_retransmit(struct sock *sk, int flag)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tunsigned long delay;\n\n\t\/* Delay early retransmit and entering fast recovery for\n\t * max(RTT\/4, 2msec) unless ack has ECE mark, no RTT samples\n\t * available, or RTO is scheduled to fire first.\n\t *\/\n\tif (sysctl_tcp_early_retrans < 2 || sysctl_tcp_early_retrans > 3 ||\n\t    (flag & FLAG_ECE) || !tp->srtt_us)\n\t\treturn false;\n\n\tdelay = max(usecs_to_jiffies(tp->srtt_us >> 5),\n\t\t    msecs_to_jiffies(2));\n\n\tif (!time_after(inet_csk(sk)->icsk_timeout, (jiffies + delay)))\n\t\treturn false;\n\n\tinet_csk_reset_xmit_timer(sk, ICSK_TIME_EARLY_RETRANS, delay,\n\t\t\t\t  TCP_RTO_MAX);\n\treturn true;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":220950,"func":" static int is_handler(const struct dirent *dirent)\n {\n \tif (strncmp(dirent->d_name, \"handler_\", 8))\n\t\treturn 0;\n\n\treturn 1;\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":10234,"func":" string DecodeFile(const string& filename, int num_threads) {\n   libvpx_test::WebMVideoSource video(filename);\n   video.Init();\n \n  vpx_codec_dec_cfg_t cfg = {0};\n   cfg.threads = num_threads;\n   libvpx_test::VP9Decoder decoder(cfg, 0);\n \n  libvpx_test::MD5 md5;\n for (video.Begin(); video.cxdata(); video.Next()) {\n const vpx_codec_err_t res =\n        decoder.DecodeFrame(video.cxdata(), video.frame_size());\n if (res != VPX_CODEC_OK) {\n      EXPECT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError();\n break;\n }\n\n    libvpx_test::DxDataIterator dec_iter = decoder.GetDxData();\n const vpx_image_t *img = NULL;\n\n while ((img = dec_iter.Next())) {\n      md5.Add(img);\n }\n }\n\n   return string(md5.Get());\n }\n","target":1,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":415428,"func":"pwg_free_finishings(\n    _pwg_finishings_t *f)\t\t\/* I - Finishings value *\/\n{\n  cupsFreeOptions(f->num_options, f->options);\n  free(f);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":52620,"func":"  bool close() {\n    bool noError = true;\n    if (isValid()) {\n      if (zip_fclose(m_zipFile) != 0) {\n        noError = false;\n      }\n      m_zipFile = nullptr;\n    }\n    return noError;\n  }","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":41492,"func":"loff_t mem_lseek(struct file *file, loff_t offset, int orig)\n{\n\tswitch (orig) {\n\tcase 0:\n\t\tfile->f_pos = offset;\n\t\tbreak;\n\tcase 1:\n\t\tfile->f_pos += offset;\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\tforce_successful_syscall_return();\n\treturn file->f_pos;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":242907,"func":"static void specialuse_flags(const mbentry_t *mbentry, struct buf *attrib,\n                             int isxlist)\n{\n    if (!mbentry) return;\n\n    char *inbox = mboxname_user_mbox(imapd_userid, NULL);\n    int inboxlen = strlen(inbox);\n\n    \/* doesn't match inbox, not xlistable *\/\n    if (strncmp(mbentry->name, inbox, inboxlen)) {\n        free(inbox);\n        return;\n    }\n\n    \/* inbox - only print if command is XLIST *\/\n    if (mbentry->name[inboxlen] == '\\0') {\n        if (isxlist) buf_init_ro_cstr(attrib, \"\\\\Inbox\");\n    }\n    \/* subdir *\/\n    else if (mbentry->name[inboxlen] == '.') {\n        \/* check if there's a special use flag set *\/\n        annotatemore_lookup(mbentry->name, \"\/specialuse\", imapd_userid, attrib);\n    }\n    free(inbox);\n    \/* otherwise it's actually another user who matches for\n     * the substr.  Ok to just print nothing *\/\n}\n","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":84461,"func":"static inline void assert_list_leaf_cfs_rq(struct rq *rq)\n{\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":293777,"func":"static Jsi_RC Jsi_DoneWebSocket(Jsi_Interp *interp)\n{\n    Jsi_UserObjUnregister(interp, &websockobject);\n    Jsi_PkgProvide(interp, \"WebSocket\", -1, NULL);\n    return JSI_OK;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":130661,"func":"void rsprintf(const char *format, ...) {\n   va_list argptr;\n   char str[10000];\n\n   va_start(argptr, format);\n   vsprintf(str, (char *) format, argptr);\n   va_end(argptr);\n\n   if (strlen_retbuf + (int) strlen(str) + 1 >= return_buffer_size) {\n      return_buffer = xrealloc(return_buffer, return_buffer_size + 100000);\n      memset(return_buffer + return_buffer_size, 0, 100000);\n      return_buffer_size += 100000;\n   }\n\n   strcpy(return_buffer + strlen_retbuf, str);\n\n   strlen_retbuf += strlen(str);\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":15338,"func":"static int astream_end_of_part ( struct attachment_istream * astream , const char * * error_r ) {\n struct attachment_istream_part * part = & astream -> part ;\n size_t old_size ;\n int ret = 0 ;\n switch ( part -> state ) {\n case MAIL_ATTACHMENT_STATE_NO : break ;\n case MAIL_ATTACHMENT_STATE_MAYBE : if ( part -> part_buf != NULL ) {\n stream_add_data ( astream , part -> part_buf -> data , part -> part_buf -> used ) ;\n ret = part -> part_buf -> used > 0 ? 1 : 0 ;\n }\n break ;\n case MAIL_ATTACHMENT_STATE_YES : old_size = astream -> istream . pos - astream -> istream . skip ;\n if ( astream_part_finish ( astream , error_r ) < 0 ) ret = - 1 ;\n else {\n ret = astream -> istream . pos - astream -> istream . skip - old_size ;\n }\n break ;\n }\n part -> state = MAIL_ATTACHMENT_STATE_NO ;\n astream_part_reset ( astream ) ;\n return ret ;\n }","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":475667,"func":"static int nft_setelem_catchall_insert(const struct net *net,\n\t\t\t\t       struct nft_set *set,\n\t\t\t\t       const struct nft_set_elem *elem,\n\t\t\t\t       struct nft_set_ext **pext)\n{\n\tstruct nft_set_elem_catchall *catchall;\n\tu8 genmask = nft_genmask_next(net);\n\tstruct nft_set_ext *ext;\n\n\tlist_for_each_entry(catchall, &set->catchall_list, list) {\n\t\text = nft_set_elem_ext(set, catchall->elem);\n\t\tif (nft_set_elem_active(ext, genmask)) {\n\t\t\t*pext = ext;\n\t\t\treturn -EEXIST;\n\t\t}\n\t}\n\n\tcatchall = kmalloc(sizeof(*catchall), GFP_KERNEL);\n\tif (!catchall)\n\t\treturn -ENOMEM;\n\n\tcatchall->elem = elem->priv;\n\tlist_add_tail_rcu(&catchall->list, &set->catchall_list);\n\n\treturn 0;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":102572,"func":"static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp)\n{\n\tstruct xdr_stream xdr;\n\tstruct compound_hdr hdr = {\n\t\t.nops\t= 1,\n\t};\n\n\txdr_init_encode(&xdr, &req->rq_snd_buf, p);\n\tencode_compound_hdr(&xdr, &hdr);\n\treturn encode_renew(&xdr, clp);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":100682,"func":"const char *mz_version(void) { return MZ_VERSION; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":97452,"func":"ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)\n{\n\trr->_rr_type = rr_type;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":187656,"func":"  JBIG2Bitmap *getBitmap(Guint idx) { return (idx < size) ? bitmaps[idx] : NULL; }\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":53109,"func":"static int shash_compat_final(struct hash_desc *hdesc, u8 *out)\n{\n\tstruct shash_desc **descp = crypto_hash_ctx(hdesc->tfm);\n\n\treturn crypto_shash_final(*descp, out);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":364729,"func":"readFinished(HTTPConnectionPtr client)\n{\n    HTTPRequestPtr request = client->request;\n\n    if(client->reqlen - client->reqbegin >= client->bodylen) {\n        AtomPtr data;\n        data = internAtomN(client->reqbuf + client->reqbegin,\n                           client->reqlen - client->reqbegin);\n        client->reqbegin = 0;\n        client->reqlen = 0;\n        if(data == NULL) {\n            do_log(L_ERROR, \"Couldn't allocate data.\\n\");\n            httpClientError(request, 500,\n                            internAtom(\"Couldn't allocate data\"));\n            return 1;\n        }\n        httpSpecialDoSideFinish(data, request);\n        return 1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":378659,"func":"static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,\n\t\t\t       uint64_t *dfree, uint64_t *dsize)\n{\n\tuint64_t result;\n\n\tresult = sys_disk_free(handle->conn, path, small_query, bsize, dfree, dsize);\n\treturn result;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":236074,"func":"void DownloadManagerImpl::DownloadInterrupted(\n    download::DownloadItemImpl* download) {\n  WebContents* web_contents = DownloadItemUtils::GetWebContents(download);\n  if (!web_contents) {\n    download::RecordDownloadCountWithSource(\n        download::INTERRUPTED_WITHOUT_WEBCONTENTS, download->download_source());\n  }\n}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":493640,"func":"int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, int cmd, void *arg,\n\t\t  struct fuse_file_info *fi, unsigned int flags, void *data)\n{\n    fuse_get_context()->private_data = fs->user_data;\n    if (fs->op.ioctl) {\n\/*\n\tif (fs->debug)\n\t    fprintf(stderr, \"ioctl[%llu] 0x%x flags: 0x%x\\n\",\n\t\t    (unsigned long long) fi->fh, cmd, flags);\n*\/\n\treturn fs->op.ioctl(path, cmd, arg, fi, flags, data);\n    } else\n\treturn -ENOSYS;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":335858,"func":"static av_cold int libwebp_anim_encode_init(AVCodecContext *avctx)\n\n{\n\n    int ret = ff_libwebp_encode_init_common(avctx);\n\n    if (!ret) {\n\n        LibWebPAnimContext *s = avctx->priv_data;\n\n        WebPAnimEncoderOptions enc_options;\n\n        WebPAnimEncoderOptionsInit(&enc_options);\n\n        \/\/ TODO(urvang): Expose some options on command-line perhaps.\n\n        s->enc = WebPAnimEncoderNew(avctx->width, avctx->height, &enc_options);\n\n        if (!s->enc)\n\n            return AVERROR(EINVAL);\n\n        s->prev_frame_pts = -1;\n\n        s->done = 0;\n\n    }\n\n    return ret;\n\n}\n","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":127822,"func":"int _yr_scan_compare(\n    uint8_t* data,\n    size_t data_size,\n    uint8_t* string,\n    size_t string_length)\n{\n  uint8_t* s1 = data;\n  uint8_t* s2 = string;\n\n  size_t i = 0;\n\n  if (data_size < string_length)\n    return 0;\n\n  while (i < string_length && *s1++ == *s2++)\n    i++;\n\n  return (int) ((i == string_length) ? i : 0);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":183060,"func":"static void MeasureAsVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  impl->measureAsVoidMethod();\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":33896,"func":"static int proc_sys_revalidate(struct dentry *dentry, unsigned int flags)\n{\n\tif (flags & LOOKUP_RCU)\n\t\treturn -ECHILD;\n\treturn !PROC_I(d_inode(dentry))->sysctl->unregistering;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":24236,"func":"static int replace ( DYNAMIC_STRING * ds_str , const char * search_str , ulong search_len , const char * replace_str , ulong replace_len ) {\n DYNAMIC_STRING ds_tmp ;\n const char * start = strstr ( ds_str -> str , search_str ) ;\n if ( ! start ) return 1 ;\n init_dynamic_string_checked ( & ds_tmp , \"\" , ds_str -> length + replace_len , 256 ) ;\n dynstr_append_mem_checked ( & ds_tmp , ds_str -> str , start - ds_str -> str ) ;\n dynstr_append_mem_checked ( & ds_tmp , replace_str , replace_len ) ;\n dynstr_append_checked ( & ds_tmp , start + search_len ) ;\n dynstr_set_checked ( ds_str , ds_tmp . str ) ;\n dynstr_free ( & ds_tmp ) ;\n return 0 ;\n }","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":487929,"func":"static int64_t wav_get_length(pcm_reader_t *reader)\n{\n    return ((wav_reader_t *)reader)->length;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":223986,"func":"svc_exit_thread(struct svc_rqst *rqstp)\n{\n\tstruct svc_serv\t*serv = rqstp->rq_server;\n\tstruct svc_pool\t*pool = rqstp->rq_pool;\n\n\tspin_lock_bh(&pool->sp_lock);\n\tpool->sp_nrthreads--;\n\tif (!test_and_set_bit(RQ_VICTIM, &rqstp->rq_flags))\n\t\tlist_del_rcu(&rqstp->rq_all);\n\tspin_unlock_bh(&pool->sp_lock);\n\n\tsvc_rqst_free(rqstp);\n\n\t\/* Release the server *\/\n\tif (serv)\n\t\tsvc_destroy(serv);\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":381534,"func":"typedef void (*TransactEntryFunc_t) (HttpTransact::State* s);\n\ninline bool\nis_response_body_precluded(HTTPStatus status_code, int method)\n{\n\n  \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n  \/\/ the spec says about message body the following:    \/\/\n  \/\/ All responses to the HEAD request method MUST NOT  \/\/\n  \/\/ include a message-body, even though the presence   \/\/\n  \/\/ of entity-header fields might lead one to believe  \/\/\n  \/\/ they do. All 1xx (informational), 204 (no content),\/\/\n  \/\/ and 304 (not modified) responses MUST NOT include  \/\/\n  \/\/ a message-body.                                    \/\/\n  \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n  if (((status_code != HTTP_STATUS_OK) &&\n       ((status_code == HTTP_STATUS_NOT_MODIFIED) ||\n        ((status_code<HTTP_STATUS_OK) && (status_code>= HTTP_STATUS_CONTINUE)) ||\n        (status_code == 204))) || (method == HTTP_WKSIDX_HEAD)) {\n    return true;\n  } else {","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":32161,"func":"static inline bool d_is_reg(const struct dentry *dentry)\n{\n\treturn __d_entry_type(dentry) == DCACHE_REGULAR_TYPE;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":295087,"func":"Index(expr_ty value, PyArena *arena)\n{\n    slice_ty p;\n    if (!value) {\n        PyErr_SetString(PyExc_ValueError,\n                        \"field value is required for Index\");\n        return NULL;\n    }\n    p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));\n    if (!p)\n        return NULL;\n    p->kind = Index_kind;\n    p->v.Index.value = value;\n    return p;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":237803,"func":"void GLES2DecoderImpl::ApplyDirtyState() {\n  if (state_dirty_) {\n    glColorMask(\n        mask_red_, mask_green_, mask_blue_,\n        mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha());\n    bool have_depth = BoundFramebufferHasDepthAttachment();\n    glDepthMask(mask_depth_ && have_depth);\n    EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth);\n    bool have_stencil = BoundFramebufferHasStencilAttachment();\n    glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0);\n    glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0);\n    EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil);\n    EnableDisable(GL_CULL_FACE, enable_cull_face_);\n    EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_);\n    EnableDisable(GL_BLEND, enable_blend_);\n    state_dirty_ = false;\n  }\n}\n","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":170223,"func":"void PDFiumEngine::GetRegion(const pp::Point& location,\n                             pp::ImageData* image_data,\n                             void** region,\n                             int* stride) const {\n  if (image_data->is_null()) {\n    DCHECK(plugin_size_.IsEmpty());\n    *stride = 0;\n    *region = nullptr;\n    return;\n  }\n  char* buffer = static_cast<char*>(image_data->data());\n  *stride = image_data->stride();\n\n  pp::Point offset_location = location + page_offset_;\n  if (!buffer ||\n      !pp::Rect(page_offset_, plugin_size_).Contains(offset_location)) {\n    *region = nullptr;\n    return;\n  }\n\n  buffer += location.y() * (*stride);\n  buffer += (location.x() + page_offset_.x()) * 4;\n  *region = buffer;\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":331384,"func":"static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,\n\n                    uint64_t offset, uint64_t len)\n\n{\n\n    RDMALocalBlock *block =\n\n        &(rdma->local_ram_blocks.block[rdma->current_index]);\n\n    uint8_t *host_addr = block->local_host_addr + (offset - block->offset);\n\n    uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk);\n\n\n\n    if (rdma->current_length == 0) {\n\n        return 0;\n\n    }\n\n\n\n    \/*\n\n     * Only merge into chunk sequentially.\n\n     *\/\n\n    if (offset != (rdma->current_addr + rdma->current_length)) {\n\n        return 0;\n\n    }\n\n\n\n    if (rdma->current_index < 0) {\n\n        return 0;\n\n    }\n\n\n\n    if (offset < block->offset) {\n\n        return 0;\n\n    }\n\n\n\n    if ((offset + len) > (block->offset + block->length)) {\n\n        return 0;\n\n    }\n\n\n\n    if (rdma->current_chunk < 0) {\n\n        return 0;\n\n    }\n\n\n\n    if ((host_addr + len) > chunk_end) {\n\n        return 0;\n\n    }\n\n\n\n    return 1;\n\n}\n","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":296266,"func":"void putname(const char *name)\n{\n\tif (unlikely(!audit_dummy_context()))\n\t\taudit_putname(name);\n\telse\n\t\t__putname(name);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":65675,"func":"int __init raw6_proc_init(void)\n{\n\treturn register_pernet_subsys(&raw6_net_ops);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":74029,"func":"static int tg3_get_regs_len(struct net_device *dev)\n{\n\treturn TG3_REG_BLK_SIZE;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":269734,"func":"static int __init i8042_setup_kbd(void)\n{\n\tint error;\n\n\terror = i8042_create_kbd_port();\n\tif (error)\n\t\treturn error;\n\n\terror = request_irq(I8042_KBD_IRQ, i8042_interrupt, IRQF_SHARED,\n\t\t\t    \"i8042\", i8042_platform_device);\n\tif (error)\n\t\tgoto err_free_port;\n\n\terror = i8042_enable_kbd_port();\n\tif (error)\n\t\tgoto err_free_irq;\n\n\ti8042_kbd_irq_registered = true;\n\treturn 0;\n\n err_free_irq:\n\tfree_irq(I8042_KBD_IRQ, i8042_platform_device);\n err_free_port:\n\ti8042_free_kbd_port();\n\treturn error;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":510836,"func":"inline void Http2Stream::AddChunk(const uint8_t* data, size_t len) {\n  CHECK(!this->IsDestroyed());\n  if (this->statistics_.first_byte == 0)\n    this->statistics_.first_byte = uv_hrtime();\n  if (flags_ & NGHTTP2_STREAM_FLAG_EOS)\n    return;\n  char* buf = nullptr;\n  if (len > 0 && data != nullptr) {\n    buf = Malloc<char>(len);\n    memcpy(buf, data, len);\n  } else if (data == nullptr) {\n    flags_ |= NGHTTP2_STREAM_FLAG_EOS;\n  }\n  data_chunks_.emplace(uv_buf_init(buf, len));\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":60929,"func":"Jsi_OptionsCustomPrint(void* clientData, Jsi_Interp *interp, const char *name, void *rec, int offset)\n{\n    char *record = (char*)rec;\n    Jsi_Value *valuePtr;\n    valuePtr = *(Jsi_Value **)(record + offset);\n    return valuePtr;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":296588,"func":"circle_contain(PG_FUNCTION_ARGS)\n{\n\tCIRCLE\t   *circle1 = PG_GETARG_CIRCLE_P(0);\n\tCIRCLE\t   *circle2 = PG_GETARG_CIRCLE_P(1);\n\n\tPG_RETURN_BOOL(FPle((point_dt(&circle1->center, &circle2->center) + circle2->radius), circle1->radius));\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":412196,"func":"static int ext4_xattr_inode_dec_ref(handle_t *handle, struct inode *ea_inode)\n{\n\treturn ext4_xattr_inode_update_ref(handle, ea_inode, -1);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":510957,"func":"int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,\n                    unsigned char *sig, unsigned int *siglen,\n                    const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)\n{\n    ECDSA_SIG *s;\n    RAND_seed(dgst, dlen);\n    s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey);\n    if (s == NULL) {\n        *siglen = 0;\n        return 0;\n    }\n    *siglen = i2d_ECDSA_SIG(s, &sig);\n    ECDSA_SIG_free(s);\n    return 1;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":396832,"func":"  STATIC int GC_write(int fd, const char *buf, size_t len)\n  {\n#   if defined(ECOS) || defined(NOSYS)\n#     ifdef ECOS\n        \/* FIXME: This seems to be defined nowhere at present.  *\/\n        \/* _Jv_diag_write(buf, len); *\/\n#     else\n        \/* No writing.  *\/\n#     endif\n      return len;\n#   else\n      int bytes_written = 0;\n      int result;\n      IF_CANCEL(int cancel_state;)\n\n      DISABLE_CANCEL(cancel_state);\n      while ((size_t)bytes_written < len) {\n#        ifdef GC_SOLARIS_THREADS\n             result = syscall(SYS_write, fd, buf + bytes_written,\n                                             len - bytes_written);\n#        else\n             result = write(fd, buf + bytes_written, len - bytes_written);\n#        endif\n         if (-1 == result) {\n             RESTORE_CANCEL(cancel_state);\n             return(result);\n         }\n         bytes_written += result;\n      }\n      RESTORE_CANCEL(cancel_state);\n      return(bytes_written);\n#   endif\n  }","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":71322,"func":"void AsyncSSLSocket::connect(\n    ConnectCallback* callback,\n    const folly::SocketAddress& address,\n    std::chrono::milliseconds connectTimeout,\n    std::chrono::milliseconds totalConnectTimeout,\n    const OptionMap& options,\n    const folly::SocketAddress& bindAddr) noexcept {\n  assert(!server_);\n  assert(state_ == StateEnum::UNINIT);\n  assert(sslState_ == STATE_UNINIT || sslState_ == STATE_UNENCRYPTED);\n  noTransparentTls_ = true;\n  totalConnectTimeout_ = totalConnectTimeout;\n  if (sslState_ != STATE_UNENCRYPTED) {\n    callback = new AsyncSSLSocketConnector(this, callback, totalConnectTimeout);\n  }\n  AsyncSocket::connect(\n      callback, address, int(connectTimeout.count()), options, bindAddr);\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":386162,"func":"SPL_METHOD(SplObjectStorage, valid)\n{\n\tspl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tRETURN_BOOL(zend_hash_has_more_elements_ex(&intern->storage, &intern->pos) == SUCCESS);\n} \/* }}} *\/","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":134823,"func":"static unsigned parse_hex4(const unsigned char * const input)\n{\n    unsigned int h = 0;\n    size_t i = 0;\n\n    for (i = 0; i < 4; i++)\n    {\n        \/* parse digit *\/\n        if ((input[i] >= '0') && (input[i] <= '9'))\n        {\n            h += (unsigned int) input[i] - '0';\n        }\n        else if ((input[i] >= 'A') && (input[i] <= 'F'))\n        {\n            h += (unsigned int) 10 + input[i] - 'A';\n        }\n        else if ((input[i] >= 'a') && (input[i] <= 'f'))\n        {\n            h += (unsigned int) 10 + input[i] - 'a';\n        }\n        else \/* invalid *\/\n        {\n            return 0;\n        }\n\n        if (i < 3)\n        {\n            \/* shift left to make place for the next nibble *\/\n            h = h << 4;\n        }\n    }\n\n    return h;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":147862,"func":"invoke_NPN_SetProperty(PluginInstance *plugin, NPObject *npobj, NPIdentifier propertyName,\n\t\t\t\t\t   const NPVariant *value)\n{\n  npw_return_val_if_fail(rpc_method_invoke_possible(g_rpc_connection), false);\n\n  int error = rpc_method_invoke(g_rpc_connection,\n\t\t\t\t\t\t\t\tRPC_METHOD_NPN_SET_PROPERTY,\n\t\t\t\t\t\t\t\tRPC_TYPE_NPW_PLUGIN_INSTANCE, plugin,\n\t\t\t\t\t\t\t\tRPC_TYPE_NP_OBJECT, npobj,\n\t\t\t\t\t\t\t\tRPC_TYPE_NP_IDENTIFIER, &propertyName,\n\t\t\t\t\t\t\t\tRPC_TYPE_NP_VARIANT, value,\n\t\t\t\t\t\t\t\tRPC_TYPE_INVALID);\n\n  if (error != RPC_ERROR_NO_ERROR) {\n\tnpw_perror(\"NPN_SetProperty() invoke\", error);\n\treturn false;\n  }\n\n  uint32_t ret;\n  error = rpc_method_wait_for_reply(g_rpc_connection,\n\t\t\t\t\t\t\t\t\tRPC_TYPE_UINT32, &ret,\n\t\t\t\t\t\t\t\t\tRPC_TYPE_INVALID);\n\n  if (error != RPC_ERROR_NO_ERROR) {\n\tnpw_perror(\"NPN_SetProperty() wait for reply\", error);\n\treturn false;\n  }\n\n  return ret;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":419052,"func":"sigend_bfd(__attribute__ ((unused)) void *v,\n\t   __attribute__ ((unused)) int sig)\n{\n\tif (master)\n\t\tthread_add_terminate_event(master);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":166440,"func":"void AudioRendererHost::OnError(media::AudioOutputController* controller,\n                                int error_code) {\n  BrowserThread::PostTask(\n      BrowserThread::IO,\n      FROM_HERE,\n      NewRunnableMethod(this,\n                        &AudioRendererHost::DoHandleError,\n                        make_scoped_refptr(controller),\n                        error_code));\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":439699,"func":"bool SplashOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) {\n  SplashAxialPattern *pattern = new SplashAxialPattern(colorMode, state, shading);\n  bool retVal = univariateShadedFill(state, pattern, tMin, tMax);\n\n  delete pattern;\n\n  return retVal;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":61337,"func":"static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)\n{\n\telf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;\n\tint i = 0;\n\tdo\n\t\ti += 2;\n\twhile (auxv[i - 2] != AT_NULL);\n\tfill_note(note, \"CORE\", NT_AUXV, i * sizeof(elf_addr_t), auxv);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":192158,"func":"void AutofillExternalDelegate::OnQuery(int query_id,\n                                       const FormData& form,\n                                       const FormFieldData& field,\n                                       const gfx::RectF& element_bounds) {\n  query_form_ = form;\n  query_field_ = field;\n  query_id_ = query_id;\n  element_bounds_ = element_bounds;\n  should_show_scan_credit_card_ =\n      manager_->ShouldShowScanCreditCard(query_form_, query_field_);\n  popup_type_ = manager_->GetPopupType(query_form_, query_field_);\n  should_show_cc_signin_promo_ =\n      manager_->ShouldShowCreditCardSigninPromo(query_form_, query_field_);\n  should_show_cards_from_account_option_ =\n      manager_->ShouldShowCardsFromAccountOption(query_form_, query_field_);\n}\n","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":253434,"func":"void ServiceWorkerPaymentInstrument::InvokePaymentApp(Delegate* delegate) {\n  delegate_ = delegate;\n\n  if (needs_installation_) {\n    content::PaymentAppProvider::GetInstance()->InstallAndInvokePaymentApp(\n        web_contents_, CreatePaymentRequestEventData(),\n        installable_web_app_info_->name,\n        installable_web_app_info_->icon == nullptr\n            ? SkBitmap()\n            : *(installable_web_app_info_->icon),\n        installable_web_app_info_->sw_js_url,\n        installable_web_app_info_->sw_scope,\n        installable_web_app_info_->sw_use_cache, installable_enabled_method_,\n        base::BindOnce(&ServiceWorkerPaymentInstrument::OnPaymentAppInvoked,\n                       weak_ptr_factory_.GetWeakPtr()));\n  } else {\n    content::PaymentAppProvider::GetInstance()->InvokePaymentApp(\n        browser_context_, stored_payment_app_info_->registration_id,\n        CreatePaymentRequestEventData(),\n        base::BindOnce(&ServiceWorkerPaymentInstrument::OnPaymentAppInvoked,\n                       weak_ptr_factory_.GetWeakPtr()));\n  }\n\n   payment_request_delegate_->ShowProcessingSpinner();\n }\n","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":451280,"func":"void HeaderMapImpl::iterate(HeaderMap::ConstIterateCb cb) const {\n  for (const HeaderEntryImpl& header : headers_) {\n    if (cb(header) == HeaderMap::Iterate::Break) {\n      break;\n    }\n  }\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":173094,"func":"WebMediaPlayerMS::~WebMediaPlayerMS() {\n  DVLOG(1) << __func__;\n  DCHECK(thread_checker_.CalledOnValidThread());\n\n  if (!web_stream_.IsNull())\n    web_stream_.RemoveObserver(this);\n\n  get_client()->SetCcLayer(nullptr);\n  if (video_layer_) {\n    DCHECK(!surface_layer_for_video_enabled_);\n    video_layer_->StopUsingProvider();\n  }\n\n  if (frame_deliverer_)\n    io_task_runner_->DeleteSoon(FROM_HERE, frame_deliverer_.release());\n\n  if (compositor_)\n    compositor_->StopUsingProvider();\n\n  if (video_frame_provider_)\n    video_frame_provider_->Stop();\n\n  if (audio_renderer_)\n    audio_renderer_->Stop();\n\n  media_log_->AddEvent(\n      media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED));\n\n  delegate_->PlayerGone(delegate_id_);\n  delegate_->RemoveObserver(delegate_id_);\n}\n","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":15895,"func":"static guint composite_offset ( const tvbuff_t * tvb _U_ , const guint counter ) {\n return counter ;\n }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":241934,"func":"PanoramiXRenderSetPictureFilter (ClientPtr client)\n{\n    REQUEST(xRenderSetPictureFilterReq);\n    int\t\t    result = Success, j;\n    PanoramiXRes    *pict;\n\n    REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);\n    \n    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);\n    \n    FOR_NSCREENS_BACKWARD(j) {\n        stuff->picture = pict->info[j].id;\n        result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);\n        if(result != Success) break;\n    }\n\n    return result;\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":351237,"func":"file_asynch_zero (struct rw *rw, struct command *command,\n                  nbd_completion_callback cb, bool allocate)\n{\n  int dummy = 0;\n\n  if (!file_synch_zero (rw, command->offset, command->slice.len, allocate))\n    return false;\n  if (cb.callback (cb.user_data, &dummy) == -1) {\n    perror (rw->name);\n    exit (EXIT_FAILURE);\n  }\n  return true;\n}","target":1,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":418583,"func":"ACLSNMPCommunityStrategy::Instance()\n{\n    return &Instance_;\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":226339,"func":"void DesktopWindowTreeHostX11::OnDisplayMetricsChanged(\n    const display::Display& display,\n    uint32_t changed_metrics) {\n  aura::WindowTreeHost::OnDisplayMetricsChanged(display, changed_metrics);\n\n  if ((changed_metrics & DISPLAY_METRIC_DEVICE_SCALE_FACTOR) &&\n      display::Screen::GetScreen()->GetDisplayNearestWindow(window()).id() ==\n          display.id()) {\n    RestartDelayedResizeTask();\n  }\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":94219,"func":"static int handle_interrupt_window(struct kvm_vcpu *vcpu)\n{\n\tu32 cpu_based_vm_exec_control;\n\n\t\/* clear pending irq *\/\n\tcpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);\n\tcpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING;\n\tvmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);\n\n\tkvm_make_request(KVM_REQ_EVENT, vcpu);\n\n\t++vcpu->stat.irq_window_exits;\n\n\t\/*\n\t * If the user space waits to inject interrupts, exit as soon as\n\t * possible\n\t *\/\n\tif (!irqchip_in_kernel(vcpu->kvm) &&\n\t    vcpu->run->request_interrupt_window &&\n\t    !kvm_cpu_has_interrupt(vcpu)) {\n\t\tvcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;\n\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":361901,"func":"void Server::removeLink(Channel *c, Channel *l) {\n\tc->unlink(l);\n\n\tif (c->bTemporary || l->bTemporary)\n\t\treturn;\n\tTransactionHolder th;\n\n\tQSqlQuery &query = *th.qsqQuery;\n\n\tif (l) {\n\t\tSQLPREP(\"DELETE FROM `%1channel_links` WHERE `server_id` = ? AND `channel_id` = ? AND `link_id` = ?\");\n\t\tquery.addBindValue(iServerNum);\n\t\tquery.addBindValue(c->iId);\n\t\tquery.addBindValue(l->iId);\n\t\tSQLEXEC();\n\n\t\tquery.addBindValue(iServerNum);\n\t\tquery.addBindValue(l->iId);\n\t\tquery.addBindValue(c->iId);\n\t\tSQLEXEC();\n\t} else {\n\t\tSQLPREP(\"DELETE FROM `%1channel_links` WHERE `server_id` = ? AND (`channel_id` = ? OR `link_id` = ?)\");\n\t\tquery.addBindValue(iServerNum);\n\t\tquery.addBindValue(c->iId);\n\t\tquery.addBindValue(c->iId);\n\t\tSQLEXEC();\n\t}\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":83441,"func":"ShmemBackendArraySize(void)\n{\n\treturn mul_size(MaxLivePostmasterChildren(), sizeof(Backend));\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":89227,"func":"std::string HttpDate() {\n  std::time_t t = std::time(nullptr);\n  std::tm gmt = *std::gmtime(&t);\n\n  std::ostringstream date;\n  date.imbue(std::locale::classic());  \/\/ Use classic C locale\n  date << std::put_time(&gmt, \"%a, %d %b %Y %H:%M:%S GMT\");\n  return date.str();\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":44640,"func":"static void ie_destructor(void *arg)\n{\n\tstruct ident_entry *ie = arg;\n\n\tmem_deref(ie->content.publish);\n\tmem_deref(ie->content.accept);\n\tmem_deref(ie->ident);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":484281,"func":"ex_redrawstatus(exarg_T *eap UNUSED)\n{\n    int\t\tr = RedrawingDisabled;\n    int\t\tp = p_lz;\n\n    RedrawingDisabled = 0;\n    p_lz = FALSE;\n    if (eap->forceit)\n\tstatus_redraw_all();\n    else\n\tstatus_redraw_curbuf();\n    update_screen(VIsual_active ? UPD_INVERTED : 0);\n    RedrawingDisabled = r;\n    p_lz = p;\n    out_flush();\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":100361,"func":"static void multi_enable_ms(struct sb_uart_port *port)\n{\n\tstruct mp_port *mtpt = (struct mp_port *)port;\n\n\tmtpt->ier |= UART_IER_MSI;\n\tserial_out(mtpt, UART_IER, mtpt->ier);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":413531,"func":"static void _slurmctld_free_comp_msg_list(void *x)\n{\n\tslurm_msg_t *msg = (slurm_msg_t*)x;\n\tif (msg) {\n\t\tif (msg->msg_type == REQUEST_BATCH_JOB_LAUNCH) {\n\t\t\tslurm_free_job_launch_msg(msg->data);\n\t\t\tmsg->data = NULL;\n\t\t}\n\n\t\tslurm_free_comp_msg_list(msg);\n\t}\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":18075,"func":"static int dissect_h245_IA5String_SIZE_1_64 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_IA5String ( tvb , offset , actx , tree , hf_index , 1 , 64 , FALSE ) ;\n return offset ;\n }","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":50531,"func":"\nstatic void __exit bfq_exit(void)\n{\n\telv_unregister(&iosched_bfq_mq);\n#ifdef CONFIG_BFQ_GROUP_IOSCHED\n\tblkcg_policy_unregister(&blkcg_policy_bfq);\n#endif\n\tbfq_slab_kill();","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":510517,"func":"Item_ident::Item_ident(Name_resolution_context *context_arg,\n                       const char *db_name_arg,const char *table_name_arg,\n\t\t       const char *field_name_arg)\n  :orig_db_name(db_name_arg), orig_table_name(table_name_arg),\n   orig_field_name(field_name_arg), context(context_arg),\n   db_name(db_name_arg), table_name(table_name_arg),\n   field_name(field_name_arg),\n   alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),\n   cached_table(0), depended_from(0), can_be_depended(TRUE)\n{\n  name = (char*) field_name_arg;\n  name_length= name ? strlen(name) : 0;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":457358,"func":"sink_if_match (p11_index *index,\n               index_object *obj,\n               CK_ATTRIBUTE *match,\n               CK_ULONG count,\n               void *data)\n{\n\tindex_bucket *handles = data;\n\n\tif (p11_attrs_matchn (obj->attrs, match, count))\n\t\tbucket_push (handles, obj->handle);\n\treturn true;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":348919,"func":"plugin_close (struct backend *b, struct connection *conn)\n{\n  struct backend_plugin *p = container_of (b, struct backend_plugin, backend);\n\n  assert (connection_get_handle (conn, 0));\n\n  debug (\"close\");\n\n  if (p->plugin.close)\n    p->plugin.close (connection_get_handle (conn, 0));\n\n  backend_set_handle (b, conn, NULL);\n}","target":1,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":16979,"func":"static void vmsvga_invalidate_display ( void * opaque ) {\n struct vmsvga_state_s * s = opaque ;\n if ( ! s -> enable ) {\n s -> vga . hw_ops -> invalidate ( & s -> vga ) ;\n return ;\n }\n s -> invalidated = 1 ;\n }","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":305307,"func":"Bool gf_isom_box_is_file_level(GF_Box *s)\n{\n\tif (!s || !s->registry) return GF_FALSE;\n\tif (strstr(s->registry->parents_4cc, \"file\")!= NULL) return GF_TRUE;\n\tif (strstr(s->registry->parents_4cc, \"*\")!= NULL) return GF_TRUE;\n\treturn GF_FALSE;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":339696,"func":"static void vmsvga_bios_write(void *opaque, uint32_t address, uint32_t data)\n\n{\n\n    printf(\"%s: what are we supposed to do with (%08x)?\\n\",\n\n                    __FUNCTION__, data);\n\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":354788,"func":"static int bad_file_release(struct inode *inode, struct file *filp)\n{\n\treturn -EIO;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":162319,"func":"static int ipv6_inherit_eui64(u8 *eui, struct inet6_dev *idev)\n{\n\tint err = -1;\n\tstruct inet6_ifaddr *ifp;\n\n\tread_lock_bh(&idev->lock);\n\tlist_for_each_entry_reverse(ifp, &idev->addr_list, if_list) {\n\t\tif (ifp->scope > IFA_LINK)\n\t\t\tbreak;\n\t\tif (ifp->scope == IFA_LINK && !(ifp->flags&IFA_F_TENTATIVE)) {\n\t\t\tmemcpy(eui, ifp->addr.s6_addr+8, 8);\n\t\t\terr = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\tread_unlock_bh(&idev->lock);\n\treturn err;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":518535,"func":"void Field_new_decimal::sort_string(uchar *buff, uint length)\n{\n  memcpy(buff, ptr, length);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":418511,"func":"RGWBulkUploadOp::AlignedStreamGetter::~AlignedStreamGetter()\n{\n  const size_t aligned_legnth = length + (-length % alignment);\n  ceph::bufferlist junk;\n\n  DecoratedStreamGetter::get_exactly(aligned_legnth - position, junk);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":213762,"func":"static bool vmxnet3_verify_driver_magic(hwaddr dshmem)\n{\n    return (VMXNET3_READ_DRV_SHARED32(dshmem, magic) == VMXNET3_REV1_MAGIC);\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":122383,"func":"static ut64 p_ptr(ut64 decorated_addr, RKernelCacheObj *obj) {\n\tRParsedPointer ptr;\n\tr_parse_pointer (&ptr, decorated_addr, obj);\n\treturn ptr.address;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":382410,"func":"ProcWaitForSignal(void)\n{\n\tPGSemaphoreLock(&MyProc->sem, true);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":250389,"func":"getGnashExecutable()\n{\n    std::string procname;\n    bool process_found = false;\n    struct stat procstats;\n\n    char *gnash_env = std::getenv(\"GNASH_PLAYER\");\n\n    if (gnash_env) {\n        procname = gnash_env;\n        process_found = (0 == stat(procname.c_str(), &procstats));\n        if (!process_found) {\n            gnash::log_error(\"Invalid path to gnash executable: \");\n            return \"\";\n        }\n    }\n\n    if (!process_found) {\n        procname = GNASHBINDIR \"\/gtk-gnash\";\n        process_found = (0 == stat(procname.c_str(), &procstats));\n    }\n    if (!process_found) {\n        procname = GNASHBINDIR \"\/qt4-gnash\";\n        process_found = (0 == stat(procname.c_str(), &procstats));\n    }\n\n    if (!process_found) {\n        gnash::log_error(std::string(\"Unable to find Gnash in \") + GNASHBINDIR);\n        return \"\";\n    }\n\n    return procname;\n}\n","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":225035,"func":"LiveSyncTest::~LiveSyncTest() {}\n","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":80386,"func":"void disable_TSC(void)\n{\n\tpreempt_disable();\n\tif (!test_and_set_thread_flag(TIF_NOTSC))\n\t\t\/*\n\t\t * Must flip the CPU state synchronously with\n\t\t * TIF_NOTSC in the current running context.\n\t\t *\/\n\t\tcr4_set_bits(X86_CR4_TSD);\n\tpreempt_enable();\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":279791,"func":"  ScrollLatencyBrowserTest() {}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":258899,"func":"inline float PrintOneElement(bfloat16 f, bool print_v2) {\n  return static_cast<float>(f);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":202702,"func":" void ServiceWorkerPaymentInstrument::OnPaymentAppInvoked(\n     mojom::PaymentHandlerResponsePtr response) {\n   if (delegate_ != nullptr) {\n     delegate_->OnInstrumentDetailsReady(response->method_name,\n                                         response->stringified_details);\n    delegate_ = nullptr;\n  }\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":473390,"func":"clearenv (void)\n{\n        if (environ != NULL)\n                environ[0] = NULL;\n        return 0;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":87571,"func":"static inline uint8_t *bcf_unpack_fmt_core1(uint8_t *ptr, int n_sample, bcf_fmt_t *fmt)\n{\n    uint8_t *ptr_start = ptr;\n    fmt->id = bcf_dec_typed_int1(ptr, &ptr);\n    fmt->n = bcf_dec_size(ptr, &ptr, &fmt->type);\n    fmt->size = fmt->n << bcf_type_shift[fmt->type];\n    fmt->p = ptr;\n    fmt->p_off  = ptr - ptr_start;\n    fmt->p_free = 0;\n    ptr += n_sample * fmt->size;\n    fmt->p_len = ptr - fmt->p;\n    return ptr;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":64384,"func":"void user_enable_single_step(struct task_struct *task)\n{\n\tstruct pt_regs *regs = task->thread.regs;\n\n\tif (regs != NULL) {\n#ifdef CONFIG_PPC_ADV_DEBUG_REGS\n\t\ttask->thread.debug.dbcr0 &= ~DBCR0_BT;\n\t\ttask->thread.debug.dbcr0 |= DBCR0_IDM | DBCR0_IC;\n\t\tregs->msr |= MSR_DE;\n#else\n\t\tregs->msr &= ~MSR_BE;\n\t\tregs->msr |= MSR_SE;\n#endif\n\t}\n\tset_tsk_thread_flag(task, TIF_SINGLESTEP);\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":172099,"func":"AXObjectCache* Document::existingAXObjectCache() const\n{\n    if (!AXObjectCache::accessibilityEnabled())\n        return 0;\n\n    if (!topDocument()->renderer())\n        return 0;\n\n    return topDocument()->m_axObjectCache.get();\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":76597,"func":"static inline u64 paravirt_read_msr(unsigned msr)\n{\n\treturn PVOP_CALL1(u64, cpu.read_msr, msr);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":469861,"func":"struct xt_target *xt_find_target(int af, const char *name, u8 revision)\n{\n\tstruct xt_target *t;\n\tint err = 0;\n\n\tif (mutex_lock_interruptible(&xt[af].mutex) != 0)\n\t\treturn ERR_PTR(-EINTR);\n\n\tlist_for_each_entry(t, &xt[af].target, list) {\n\t\tif (strcmp(t->name, name) == 0) {\n\t\t\tif (t->revision == revision) {\n\t\t\t\tif (try_module_get(t->me)) {\n\t\t\t\t\tmutex_unlock(&xt[af].mutex);\n\t\t\t\t\treturn t;\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\terr = -EPROTOTYPE; \/* Found something. *\/\n\t\t}\n\t}\n\tmutex_unlock(&xt[af].mutex);\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":106069,"func":"static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,\n\n                              int sample)\n\n{\n\n    \/* No need to keep track of smaller samples, since describing them\n\n     * with immediates is more efficient. *\/\n\n    if (size <= 14)\n\n        return;\n\n    if (!queue->samples || queue->len >= queue->size) {\n\n        HintSample *samples;\n\n        samples = av_realloc(queue->samples, sizeof(HintSample) * (queue->size + 10));\n\n        if (!samples)\n\n            return;\n\n        queue->size += 10;\n\n        queue->samples = samples;\n\n    }\n\n    queue->samples[queue->len].data = data;\n\n    queue->samples[queue->len].size = size;\n\n    queue->samples[queue->len].sample_number = sample;\n\n    queue->samples[queue->len].offset   = 0;\n\n    queue->samples[queue->len].own_data = 0;\n\n    queue->len++;\n\n}\n","target":1,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":317519,"func":"int RenderLayerScrollableArea::scrollSize(ScrollbarOrientation orientation) const\n{\n    IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition();\n    return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scrollDimensions.height();\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":192102,"func":"lvm2_lv_create_found_device (Device *device,\n                             CreateLvm2LVData *data)\n{\n  if (strlen (data->fstype) > 0)\n    {\n      device_filesystem_create_internal (device,\n                                         data->fstype,\n                                         data->fsoptions,\n                                         lvm2_lv_create_filesystem_create_hook,\n                                         NULL,\n                                         data->context);\n    }\n  else\n    {\n      dbus_g_method_return (data->context, device->priv->object_path);\n    }\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":284868,"func":"bool ProfileSyncService::HasUnsyncedItems() const {\n  if (backend_.get() && backend_initialized_) {\n    return backend_->HasUnsyncedItems();\n  }\n  NOTREACHED();\n  return false;\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":55041,"func":"void put_futex_key(int fshared, union futex_key *key)\n{\n\tdrop_futex_key_refs(key);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":405448,"func":"static void reserve_highatomic_pageblock(struct page *page, struct zone *zone,\n\t\t\t\tunsigned int alloc_order)\n{\n\tint mt;\n\tunsigned long max_managed, flags;\n\n\t\/*\n\t * Limit the number reserved to 1 pageblock or roughly 1% of a zone.\n\t * Check is race-prone but harmless.\n\t *\/\n\tmax_managed = (zone->managed_pages \/ 100) + pageblock_nr_pages;\n\tif (zone->nr_reserved_highatomic >= max_managed)\n\t\treturn;\n\n\tspin_lock_irqsave(&zone->lock, flags);\n\n\t\/* Recheck the nr_reserved_highatomic limit under the lock *\/\n\tif (zone->nr_reserved_highatomic >= max_managed)\n\t\tgoto out_unlock;\n\n\t\/* Yoink! *\/\n\tmt = get_pageblock_migratetype(page);\n\tif (!is_migrate_highatomic(mt) && !is_migrate_isolate(mt)\n\t    && !is_migrate_cma(mt)) {\n\t\tzone->nr_reserved_highatomic += pageblock_nr_pages;\n\t\tset_pageblock_migratetype(page, MIGRATE_HIGHATOMIC);\n\t\tmove_freepages_block(zone, page, MIGRATE_HIGHATOMIC, NULL);\n\t}\n\nout_unlock:\n\tspin_unlock_irqrestore(&zone->lock, flags);\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":267030,"func":"bit_read_BOT (Bit_Chain *dat)\n{\n  unsigned char two_bit_code;\n\n  two_bit_code = bit_read_BB (dat);\n\n  if (two_bit_code == 0)\n    return bit_read_RC (dat);\n  else if (two_bit_code == 1)\n    return bit_read_RC (dat) + 0x1f0;\n  else\n    return bit_read_RS (dat);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":251502,"func":"find_share(sa_handle_impl_t impl_handle, const char *sharepath)\n{\n\tsa_share_impl_t impl_share;\n\n\timpl_share = impl_handle->shares;\n\twhile (impl_share != NULL) {\n\t\tif (strcmp(impl_share->sharepath, sharepath) == 0) {\n\t\t\tbreak;\n\t\t}\n\n\t\timpl_share = impl_share->next;\n\t}\n\n\treturn (impl_share);\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":300169,"func":"static int unregister_transfer_cb(int id, void *ptr, void *data)\n{\n\tstruct loop_device *lo = ptr;\n\tstruct loop_func_table *xfer = data;\n\n\tmutex_lock(&lo->lo_ctl_mutex);\n\tif (lo->lo_encryption == xfer)\n\t\tloop_release_xfer(lo);\n\tmutex_unlock(&lo->lo_ctl_mutex);\n\treturn 0;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":214118,"func":"static void perContextEnabledLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n    TestObjectPythonV8Internal::perContextEnabledLongAttributeAttributeGetter(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":442220,"func":"roundToNextMultiple(int n, int d)\n{\n    return ((n + d - 1) \/ d) * d;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":414384,"func":"static void intrinsicLatencyMode(void) {\n    long long test_end, run_time, max_latency = 0, runs = 0;\n\n    run_time = config.intrinsic_latency_duration*1000000;\n    test_end = ustime() + run_time;\n    signal(SIGINT, intrinsicLatencyModeStop);\n\n    while(1) {\n        long long start, end, latency;\n\n        start = ustime();\n        compute_something_fast();\n        end = ustime();\n        latency = end-start;\n        runs++;\n        if (latency <= 0) continue;\n\n        \/* Reporting *\/\n        if (latency > max_latency) {\n            max_latency = latency;\n            printf(\"Max latency so far: %lld microseconds.\\n\", max_latency);\n        }\n\n        double avg_us = (double)run_time\/runs;\n        double avg_ns = avg_us * 1e3;\n        if (force_cancel_loop || end > test_end) {\n            printf(\"\\n%lld total runs \"\n                \"(avg latency: \"\n                \"%.4f microseconds \/ %.2f nanoseconds per run).\\n\",\n                runs, avg_us, avg_ns);\n            printf(\"Worst run took %.0fx longer than the average latency.\\n\",\n                max_latency \/ avg_us);\n            exit(0);\n        }\n    }\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":214760,"func":"void BrowserRenderProcessHost::ReceivedBadMessage(uint16 msg_type) {\n  BadMessageTerminateProcess(msg_type, process_.handle());\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":240755,"func":" BlockEntry::BlockEntry(Cluster* p, long idx) : m_pCluster(p), m_index(idx) {}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":162315,"func":"static int cdeque_push_back(struct cdeque* d, void* item) {\n\tif(d == NULL)\n\t\treturn CDE_PARAM;\n\n\tif(d->size == d->cap_mask + 1)\n\t\treturn CDE_OUT_OF_BOUNDS;\n\n\td->arr[d->end_pos] = (size_t) item;\n\td->end_pos = (d->end_pos + 1) & d->cap_mask;\n\td->size++;\n\n\treturn CDE_OK;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":86340,"func":"int BlackPreservingGrayOnlySampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)\n{\n    GrayOnlyParams* bp = (GrayOnlyParams*) Cargo;\n\n    \/\/ If going across black only, keep black only\n    if (In[0] == 0 && In[1] == 0 && In[2] == 0) {\n\n        \/\/ TAC does not apply because it is black ink!\n        Out[0] = Out[1] = Out[2] = 0;\n        Out[3] = cmsEvalToneCurve16(bp->KTone, In[3]);\n        return TRUE;\n    }\n\n    \/\/ Keep normal transform for other colors\n    bp ->cmyk2cmyk ->Eval16Fn(In, Out, bp ->cmyk2cmyk->Data);\n    return TRUE;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":103964,"func":"mii_read (struct net_device *dev, int phy_addr, int reg_num)\n{\n\tu32 cmd;\n\tint i;\n\tu32 retval = 0;\n\n\t\/* Preamble *\/\n\tmii_send_bits (dev, 0xffffffff, 32);\n\t\/* ST(2), OP(2), ADDR(5), REG#(5), TA(2), Data(16) total 32 bits *\/\n\t\/* ST,OP = 0110'b for read operation *\/\n\tcmd = (0x06 << 10 | phy_addr << 5 | reg_num);\n\tmii_send_bits (dev, cmd, 14);\n\t\/* Turnaround *\/\n\tif (mii_getbit (dev))\n\t\tgoto err_out;\n\t\/* Read data *\/\n\tfor (i = 0; i < 16; i++) {\n\t\tretval |= mii_getbit (dev);\n\t\tretval <<= 1;\n\t}\n\t\/* End cycle *\/\n\tmii_getbit (dev);\n\treturn (retval >> 1) & 0xffff;\n\n      err_out:\n\treturn 0;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":289458,"func":"void qdev_init_nofail ( DeviceState * dev ) {\n DeviceInfo * info = dev -> info ;\n if ( qdev_init ( dev ) < 0 ) hw_error ( \"Initialization of device %s failed\\n\" , info -> name ) ;\n }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":290512,"func":"static int __dm_pr_register(struct dm_target *ti, struct dm_dev *dev,\n\t\t\t    sector_t start, sector_t len, void *data)\n{\n\tstruct dm_pr *pr = data;\n\tconst struct pr_ops *ops = dev->bdev->bd_disk->fops->pr_ops;\n\n\tif (!ops || !ops->pr_register)\n\t\treturn -EOPNOTSUPP;\n\treturn ops->pr_register(dev->bdev, pr->old_key, pr->new_key, pr->flags);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":66125,"func":"int32_t ByteArray::Size() { return storage_length_; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":284791,"func":"bool XSSAuditor::FilterCharacterToken(const FilterTokenRequest& request) {\n  DCHECK(script_tag_nesting_level_);\n  DCHECK_NE(state_, kUninitialized);\n  if (state_ == kPermittingAdjacentCharacterTokens)\n    return false;\n\n  if (state_ == kFilteringTokens && script_tag_found_in_request_) {\n    String snippet = CanonicalizedSnippetForJavaScript(request);\n    if (IsContainedInRequest(snippet))\n      state_ = kSuppressingAdjacentCharacterTokens;\n    else if (!snippet.IsEmpty())\n      state_ = kPermittingAdjacentCharacterTokens;\n  }\n  if (state_ == kSuppressingAdjacentCharacterTokens) {\n    request.token.EraseCharacters();\n    request.token.AppendToCharacter(' ');\n    return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":391453,"func":"static int snd_emu0204_ch_switch_update(struct usb_mixer_interface *mixer,\n\t\t\t\t\tint value)\n{\n\tstruct snd_usb_audio *chip = mixer->chip;\n\tint err;\n\tunsigned char buf[2];\n\n\terr = snd_usb_lock_shutdown(chip);\n\tif (err < 0)\n\t\treturn err;\n\n\tbuf[0] = 0x01;\n\tbuf[1] = value ? 0x02 : 0x01;\n\terr = snd_usb_ctl_msg(chip->dev,\n\t\t      usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,\n\t\t      USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,\n\t\t      0x0400, 0x0e00, buf, 2);\n\tsnd_usb_unlock_shutdown(chip);\n\treturn err;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":469495,"func":"static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf,\n\t\t\t       int in_len, int out_len)\n{\n\tstruct rdma_ucm_disconnect cmd;\n\tstruct ucma_context *ctx;\n\tint ret;\n\n\tif (copy_from_user(&cmd, inbuf, sizeof(cmd)))\n\t\treturn -EFAULT;\n\n\tctx = ucma_get_ctx_dev(file, cmd.id);\n\tif (IS_ERR(ctx))\n\t\treturn PTR_ERR(ctx);\n\n\tmutex_lock(&ctx->mutex);\n\tret = rdma_disconnect(ctx->cm_id);\n\tmutex_unlock(&ctx->mutex);\n\tucma_put_ctx(ctx);\n\treturn ret;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":235439,"func":"static void single_inst_client_free(SingleInstClient* client)\n{\n    g_io_channel_shutdown(client->channel, FALSE, NULL);\n    g_io_channel_unref(client->channel);\n    g_source_remove(client->watch);\n    g_free(client->cwd);\n    g_ptr_array_foreach(client->argv, (GFunc)g_free, NULL);\n    g_ptr_array_free(client->argv, TRUE);\n    g_slice_free(SingleInstClient, client);\n    \/* g_debug(\"free client\"); *\/\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":495005,"func":"static int snd_pcm_playback_open(struct inode *inode, struct file *file)\n{\n\tstruct snd_pcm *pcm;\n\tint err = nonseekable_open(inode, file);\n\tif (err < 0)\n\t\treturn err;\n\tpcm = snd_lookup_minor_data(iminor(inode),\n\t\t\t\t    SNDRV_DEVICE_TYPE_PCM_PLAYBACK);\n\terr = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK);\n\tif (pcm)\n\t\tsnd_card_unref(pcm->card);\n\treturn err;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":169453,"func":"void Pack<WebGLImageConversion::kDataFormatRGBA4444,\n          WebGLImageConversion::kAlphaDoNothing,\n          uint8_t,\n          uint16_t>(const uint8_t* source,\n                    uint16_t* destination,\n                    unsigned pixels_per_row) {\n#if WTF_CPU_ARM_NEON\n  SIMD::PackOneRowOfRGBA8ToUnsignedShort4444(source, destination,\n                                             pixels_per_row);\n#endif\n#if HAVE_MIPS_MSA_INTRINSICS\n  SIMD::packOneRowOfRGBA8ToUnsignedShort4444MSA(source, destination,\n                                                pixels_per_row);\n#endif\n  for (unsigned i = 0; i < pixels_per_row; ++i) {\n    *destination = (((source[0] & 0xF0) << 8) | ((source[1] & 0xF0) << 4) |\n                    (source[2] & 0xF0) | (source[3] >> 4));\n    source += 4;\n    destination += 1;\n  }\n}\n","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":281452,"func":"SPL_METHOD(SplObjectStorage, key)\n{\n\tspl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\t\n\tRETURN_LONG(intern->index);\n} \/* }}} *\/\n\n\/* {{{ proto mixed SplObjectStorage::current()\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":419195,"func":"control_notify_pane_mode_changed(int pane)\n{\n\tstruct client\t*c;\n\n\tTAILQ_FOREACH(c, &clients, entry) {\n\t\tif (!CONTROL_SHOULD_NOTIFY_CLIENT(c))\n\t\t\tcontinue;\n\n\t\tcontrol_write(c, \"%%pane-mode-changed %%%u\", pane);\n\t}\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":129228,"func":"int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)\n{\n\tstruct i40e_netdev_priv *np = netdev_priv(netdev);\n\tstruct i40e_pf *pf = np->vsi->back;\n\n\tswitch (cmd) {\n\tcase SIOCGHWTSTAMP:\n\t\treturn i40e_ptp_get_ts_config(pf, ifr);\n\tcase SIOCSHWTSTAMP:\n\t\treturn i40e_ptp_set_ts_config(pf, ifr);\n\tdefault:\n\t\treturn -EOPNOTSUPP;\n\t}\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":152900,"func":"void esp32EthDisableIrq(NetInterface *interface)\n{\n   \/\/Valid Ethernet PHY or switch driver?\n   if(interface->phyDriver != NULL)\n   {\n      \/\/Disable Ethernet PHY interrupts\n      interface->phyDriver->disableIrq(interface);\n   }\n   else if(interface->switchDriver != NULL)\n   {\n      \/\/Disable Ethernet switch interrupts\n      interface->switchDriver->disableIrq(interface);\n   }\n   else\n   {\n      \/\/Just for sanity\n   }\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":345673,"func":"SPL_METHOD(SplDoublyLinkedList, current)\n{\n\tspl_dllist_object     *intern  = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\tspl_ptr_llist_element *element = intern->traverse_pointer;\n\t\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (element == NULL || element->data == NULL) {\n\t\tRETURN_NULL();\n\t} else {\n\t\tzval *data    = (zval *)element->data;\n\t\tRETURN_ZVAL(data, 1, 0);\n\t}\n}","target":1,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":50380,"func":"Jsi_vtype Jsi_ValueTypeGet(Jsi_Value *pv) { return pv->vt; }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":436555,"func":"static void holtekff_send(struct holtekff_device *holtekff,\n\t\t\t  struct hid_device *hid,\n\t\t\t  const u8 data[HOLTEKFF_MSG_LENGTH])\n{\n\tint i;\n\n\tfor (i = 0; i < HOLTEKFF_MSG_LENGTH; i++) {\n\t\tholtekff->field->value[i] = data[i];\n\t}\n\n\tdbg_hid(\"sending %7ph\\n\", data);\n\n\thid_hw_request(hid, holtekff->field->report, HID_REQ_SET_REPORT);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":216123,"func":"format_CT_CLEAR(const struct ofpact_null *a OVS_UNUSED, struct ds *s)\n{\n    ds_put_format(s, \"%sct_clear%s\", colors.value, colors.end);\n}\f\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":84323,"func":"int fib6_tables_dump(struct net *net, struct notifier_block *nb)\n{\n\tstruct fib6_dump_arg arg;\n\tstruct fib6_walker *w;\n\tunsigned int h;\n\n\tw = kzalloc(sizeof(*w), GFP_ATOMIC);\n\tif (!w)\n\t\treturn -ENOMEM;\n\n\tw->func = fib6_node_dump;\n\targ.net = net;\n\targ.nb = nb;\n\tw->args = &arg;\n\n\tfor (h = 0; h < FIB6_TABLE_HASHSZ; h++) {\n\t\tstruct hlist_head *head = &net->ipv6.fib_table_hash[h];\n\t\tstruct fib6_table *tb;\n\n\t\thlist_for_each_entry_rcu(tb, head, tb6_hlist)\n\t\t\tfib6_table_dump(net, tb, w);\n\t}\n\n\tkfree(w);\n\n\treturn 0;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":185693,"func":"bool ChromeContentBrowserClient::LogWebUIUrl(const GURL& web_ui_url) const {\n  return webui::LogWebUIUrl(web_ui_url);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":56615,"func":"int fb_get_color_depth(struct fb_var_screeninfo *var,\n\t\t       struct fb_fix_screeninfo *fix)\n{\n\tint depth = 0;\n\n\tif (fix->visual == FB_VISUAL_MONO01 ||\n\t    fix->visual == FB_VISUAL_MONO10)\n\t\tdepth = 1;\n\telse {\n\t\tif (var->green.length == var->blue.length &&\n\t\t    var->green.length == var->red.length &&\n\t\t    var->green.offset == var->blue.offset &&\n\t\t    var->green.offset == var->red.offset)\n\t\t\tdepth = var->green.length;\n\t\telse\n\t\t\tdepth = var->green.length + var->red.length +\n\t\t\t\tvar->blue.length;\n\t}\n\n\treturn depth;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":224709,"func":"  ProfileLaunchObserver() {\n    registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,\n                   content::NotificationService::AllSources());\n    BrowserList::AddObserver(this);\n  }\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":99075,"func":"    **\/\n    static CImg<T> string(const char *const str, const bool is_last_zero=true, const bool is_shared=false) {\n      if (!str) return CImg<T>();\n      return CImg<T>(str,(unsigned int)std::strlen(str) + (is_last_zero?1:0),1,1,1,is_shared);","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":419074,"func":"server_client_set_key_table(struct client *c, const char *name)\n{\n\tif (name == NULL)\n\t\tname = server_client_get_key_table(c);\n\n\tkey_bindings_unref_table(c->keytable);\n\tc->keytable = key_bindings_get_table(name, 1);\n\tc->keytable->references++;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":259617,"func":"int modbus_set_error_recovery(modbus_t *ctx,\n                              modbus_error_recovery_mode error_recovery)\n{\n    if (ctx == NULL) {\n        errno = EINVAL;\n        return -1;\n    }\n\n    \/* The type of modbus_error_recovery_mode is unsigned enum *\/\n    ctx->error_recovery = (uint8_t) error_recovery;\n    return 0;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":317374,"func":"bool V8TestObject::HasInstance(v8::Local<v8::Value> v8_value, v8::Isolate* isolate) {\n  return V8PerIsolateData::From(isolate)->HasInstance(V8TestObject::GetWrapperTypeInfo(), v8_value);\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":130680,"func":"Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int _ind) {\n    spdlog::info(\"Entering {}\", __FUNCTION__);\n    INIT_RESULT(result)\n\n    try {\n        if (!checkName(_polyName, \"POLY\")) {\n            throw SGXException(INVALID_POLY_NAME, \"Invalid polynomial name\");\n        }\n\n        string shareG2_name = \"shareG2_\" + _polyName + \"_\" + to_string(_ind) + \":\";\n        shared_ptr <string> shareG2_ptr = readFromDb(shareG2_name);\n\n        string DHKey = decryptDHKey(_polyName, _ind);\n\n        result[\"share*G2\"] = *shareG2_ptr;\n        result[\"dhKey\"] = DHKey;\n    } HANDLE_SGX_EXCEPTION(result)\n\n    RETURN_SUCCESS(result);\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":161963,"func":"struct ctl_table_header *register_sysctl_table(struct ctl_table * table)\n{\n\treturn NULL;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":12281,"func":" KioskNextHomeInterfaceBrokerImpl::KioskNextHomeInterfaceBrokerImpl(\n     content::BrowserContext* context)\n    : connector_(content::BrowserContext::GetConnectorFor(context)->Clone()),\n      app_controller_(std::make_unique<AppControllerImpl>(\n          Profile::FromBrowserContext(context))) {}\n","target":1,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":76130,"func":"static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int hdrlen,\n\t\t  bool *fragstolen)\n{\n\tint eaten;\n\tstruct sk_buff *tail = skb_peek_tail(&sk->sk_receive_queue);\n\n\t__skb_pull(skb, hdrlen);\n\teaten = (tail &&\n\t\t tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0;\n\ttcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq);\n\tif (!eaten) {\n\t\t__skb_queue_tail(&sk->sk_receive_queue, skb);\n\t\tskb_set_owner_r(skb, sk);\n\t}\n\treturn eaten;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":461567,"func":"Header headerImport(void * blob, unsigned int bsize, headerImportFlags flags)\n{\n    Header h = NULL;\n    struct hdrblob_s hblob;\n    char *buf = NULL;\n    void * b = blob;\n\n    if (flags & HEADERIMPORT_COPY) {\n\tif (bsize == 0 && hdrblobInit(b, 0, 0, 0, &hblob, &buf) == RPMRC_OK)\n\t    bsize = hblob.pvlen;\n\tif (bsize == 0)\n\t    goto exit;\n\tb = memcpy(xmalloc(bsize), b, bsize);\n    }\n\n    \/* Sanity checks on header intro. *\/\n    if (hdrblobInit(b, bsize, 0, 0, &hblob, &buf) == RPMRC_OK)\n\thdrblobImport(&hblob, (flags & HEADERIMPORT_FAST), &h, &buf);\n\nexit:\n    if (h == NULL && b != blob)\n\tfree(b);\n    free(buf);\n\n    return h;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":216911,"func":"vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx,\n                           struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)\n{\n    PCIDevice *d = PCI_DEVICE(s);\n\n    Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];\n    *didx = vmxnet3_ring_curr_cell_idx(ring);\n    vmxnet3_ring_read_curr_cell(d, ring, dbuf);\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":121652,"func":"int propagate_mount_busy(struct mount *mnt, int refcnt)\n{\n\tstruct mount *m, *child;\n\tstruct mount *parent = mnt->mnt_parent;\n\tint ret = 0;\n\n\tif (mnt == parent)\n\t\treturn do_refcount_check(mnt, refcnt);\n\n\t\/*\n\t * quickly check if the current mount can be unmounted.\n\t * If not, we don't have to go checking for all other\n\t * mounts\n\t *\/\n\tif (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt))\n\t\treturn 1;\n\n\tfor (m = propagation_next(parent, parent); m;\n\t     \t\tm = propagation_next(m, parent)) {\n\t\tchild = __lookup_mnt_last(&m->mnt, mnt->mnt_mountpoint);\n\t\tif (child && list_empty(&child->mnt_mounts) &&\n\t\t    (ret = do_refcount_check(child, 1)))\n\t\t\tbreak;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":74652,"func":"const struct sched_avg *sched_trace_rq_avg_dl(struct rq *rq)\n{\n#ifdef CONFIG_SMP\n\treturn rq ? &rq->avg_dl : NULL;\n#else\n\treturn NULL;\n#endif\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":226725,"func":"static void TestInterfaceEmptyFrozenArrayAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  v8::Local<v8::Object> holder = info.Holder();\n\n  TestObject* impl = V8TestObject::ToImpl(holder);\n\n  V8SetReturnValue(info, FreezeV8Object(ToV8(impl->testInterfaceEmptyFrozenArrayAttribute(), info.Holder(), info.GetIsolate()), info.GetIsolate()));\n}\n","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":22263,"func":"fz_colorspace * pdf_xobject_colorspace ( fz_context * ctx , pdf_xobject * xobj ) {\n pdf_obj * group = pdf_dict_get ( ctx , xobj -> obj , PDF_NAME_Group ) ;\n if ( group ) {\n pdf_obj * cs = pdf_dict_get ( ctx , group , PDF_NAME_CS ) ;\n if ( cs ) {\n fz_colorspace * colorspace = NULL ;\n fz_try ( ctx ) colorspace = pdf_load_colorspace ( ctx , cs ) ;\n fz_catch ( ctx ) fz_warn ( ctx , \"cannot load xobject colorspace\" ) ;\n return colorspace ;\n }\n }\n return NULL ;\n }","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":228402,"func":"void V8Console::timelineEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    ConsoleHelper(info).reportDeprecatedCall(\"V8Console#timelineEnd\", \"'console.timelineEnd' is deprecated. Please use 'console.timeEnd' instead.\");\n    timeEndFunction(info, true);\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":388709,"func":"int SMB_VFS_FSYNC_RECV(struct tevent_req *req, int *perrno)\n{\n\tstruct smb_vfs_call_fsync_state *state = tevent_req_data(\n\t\treq, struct smb_vfs_call_fsync_state);\n\tint err;\n\n\tif (tevent_req_is_unix_error(req, &err)) {\n\t\t*perrno = err;\n\t\treturn -1;\n\t}\n\treturn state->retval;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":321550,"func":"uint64_t helper_mulqv (uint64_t op1, uint64_t op2)\n\n{\n\n    uint64_t tl, th;\n\n\n\n    muls64(&tl, &th, op1, op2);\n\n    \/* If th != 0 && th != -1, then we had an overflow *\/\n\n    if (unlikely((th + 1) > 1)) {\n\n        arith_excp(env, GETPC(), EXC_M_IOV, 0);\n\n    }\n\n    return tl;\n\n}\n","target":1,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":386903,"func":"node_get_content (xmlNodePtr node)\n{\n    if (node == NULL)\n      return NULL;\n\n    switch (node->type)\n      {\n        case XML_ELEMENT_NODE:\n          return node_get_content (node->children);\n          break;\n        case XML_TEXT_NODE:\n          return (const char *) node->content;\n          break;\n        default:\n          return NULL;\n      }\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":83816,"func":"ssize_t xdr_stream_decode_opaque(struct xdr_stream *xdr, void *ptr, size_t size)\n{\n\tssize_t ret;\n\tvoid *p;\n\n\tret = xdr_stream_decode_opaque_inline(xdr, &p, size);\n\tif (ret <= 0)\n\t\treturn ret;\n\tmemcpy(ptr, p, ret);\n\treturn ret;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":80531,"func":"int is_logbook(char *logbook) {\n   char str[256];\n\n   if (strieq(logbook, \"global\"))\n      return 0;\n\n   \/* check for 'global group' or 'global_xxx' *\/\n   strlcpy(str, logbook, sizeof(str));\n   str[7] = 0;\n   return !strieq(str, \"global \");\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":157316,"func":"void OSDService::shutdown()\n{\n  {\n    Mutex::Locker l(watch_lock);\n    watch_timer.shutdown();\n  }\n\n  objecter->shutdown();\n  objecter_finisher.wait_for_empty();\n  objecter_finisher.stop();\n\n  {\n    Mutex::Locker l(recovery_request_lock);\n    recovery_request_timer.shutdown();\n  }\n\n  {\n    Mutex::Locker l(snap_sleep_lock);\n    snap_sleep_timer.shutdown();\n  }\n\n  {\n    Mutex::Locker l(scrub_sleep_lock);\n    scrub_sleep_timer.shutdown();\n  }\n\n  osdmap = OSDMapRef();\n  next_osdmap = OSDMapRef();\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":319474,"func":"static int v9fs_synth_utimensat(FsContext *fs_ctx, V9fsPath *path,\n\n                                const struct timespec *buf)\n\n{\n\n    errno = EPERM;\n\n    return 0;\n\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":161395,"func":"cockpit_auth_check_cookie (CockpitAuth *self,\n                           const gchar *path,\n                           GHashTable *in_headers)\n{\n  CockpitSession *session;\n  CockpitCreds *creds;\n\n  session = session_for_headers (self, path, in_headers);\n  if (session)\n    {\n      creds = cockpit_web_service_get_creds (session->service);\n      g_debug (\"received %s credential cookie for session\",\n               cockpit_creds_get_application (creds));\n      return g_object_ref (session->service);\n    }\n  else\n    {\n      g_debug (\"received unknown\/invalid credential cookie\");\n      return NULL;\n    }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":49432,"func":"static int vma_has_reserves(struct vm_area_struct *vma)\n{\n\tif (vma->vm_flags & VM_MAYSHARE)\n\t\treturn 1;\n\tif (is_vma_resv_set(vma, HPAGE_RESV_OWNER))\n\t\treturn 1;\n\treturn 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":137820,"func":"static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb,\n                                            unsigned len, const char *key)\n{\n    \/* bypass padding bytes *\/\n    avio_r8(pb);\n    avio_r8(pb);\n    avio_r8(pb);\n\n    c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;\n    av_dict_set_int(&c->fc->metadata, key, avio_r8(pb), 0);\n\n    return 0;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":108934,"func":"CModule::EModRet CModule::OnChanBufferPlayLine(CChan& Chan, CClient& Client,\n                                               CString& sLine) {\n    return CONTINUE;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":201247,"func":"   void StartAnimation() {\n    animation_timer_.Start(FROM_HERE,\n                           base::TimeDelta::FromMilliseconds(\n                               base::TimeTicks::kMillisecondsPerSecond \/\n                               gfx::LinearAnimation::kDefaultFrameRate),\n                           this, &VoiceInteractionIcon::AnimationProgressed);\n   }\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":393955,"func":"static inline void check_class_changed(struct rq *rq, struct task_struct *p,\n\t\t\t\t       const struct sched_class *prev_class,\n\t\t\t\t       int oldprio)\n{\n\tif (prev_class != p->sched_class) {\n\t\tif (prev_class->switched_from)\n\t\t\tprev_class->switched_from(rq, p);\n\n\t\tp->sched_class->switched_to(rq, p);\n\t} else if (oldprio != p->prio || dl_task(p))\n\t\tp->sched_class->prio_changed(rq, p, oldprio);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":302618,"func":"  QInt16() : value(0) {}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":226698,"func":"static String capitalizeRFC822HeaderFieldName(const String& name)\n{\n    bool capitalizeCharacter = true;\n    String result;\n\n    for (unsigned i = 0; i < name.length(); i++) {\n        UChar c;\n\n        if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z')\n            c = toASCIIUpper(name[i]);\n        else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z')\n            c = toASCIILower(name[i]);\n        else\n            c = name[i];\n\n        if (name[i] == '-')\n            capitalizeCharacter = true;\n        else\n            capitalizeCharacter = false;\n\n        result.append(c);\n    }\n\n    return result;\n}\n","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":90960,"func":"static int double_lock_balance(struct rq *this_rq, struct rq *busiest)\n{\n\tif (unlikely(!irqs_disabled())) {\n\t\t\/* printk() doesn't work good under rq->lock *\/\n\t\traw_spin_unlock(&this_rq->lock);\n\t\tBUG_ON(1);\n\t}\n\n\treturn _double_lock_balance(this_rq, busiest);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":367309,"func":"update_pal_halt_status(int status)\n{\n\tcan_do_pal_halt = pal_halt && status;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":506451,"func":"static int sk_comp_cmp(const SSL_COMP * const *a,\n\t\t\tconst SSL_COMP * const *b)\n\t{\n\treturn((*a)->id-(*b)->id);\n\t}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":71740,"func":"void KaxInternalBlock::ReleaseFrames()\n{\n  \/\/ free the allocated Frames\n  int i;\n  for (i=myBuffers.size()-1; i>=0; i--) {\n    if (myBuffers[i] != NULL) {\n      myBuffers[i]->FreeBuffer(*myBuffers[i]);\n      delete myBuffers[i];\n      myBuffers[i] = NULL;\n    }\n  }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":52423,"func":"R_API void r_bin_java_print_constant_value_attr_summary(RBinJavaAttrInfo *attr) {\n\tif (!attr) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaAttrInfo *ConstantValue.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"Constant Value Attribute Information:\\n\");\n\tprintf (\"  Attribute Offset: 0x%08\"PFMT64x \"\\n\", attr->file_offset);\n\tprintf (\"  Attribute Name Index: %d (%s)\\n\", attr->name_idx, attr->name);\n\tprintf (\"  Attribute Length: %d\\n\", attr->length);\n\tprintf (\"  ConstantValue Index: %d\\n\", attr->info.constant_value_attr.constantvalue_idx);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":296853,"func":"int Jsi_Remove(Jsi_Interp *interp, Jsi_Value* path, int flags) {\n    void *data;\n    Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, path, &data);\n    if (fsPtr == NULL || !fsPtr->removeProc) return -1;\n    return fsPtr->removeProc(interp, path, flags);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":470468,"func":"copyin_file (struct cpio_file_stat *file_hdr, int in_file_des)\n{\n  bool existing_dir = false;\n\n  if (!to_stdout_option\n      && try_existing_file (file_hdr, in_file_des, &existing_dir) < 0)\n    return;\n\n  \/* Do the real copy or link.  *\/\n  switch (file_hdr->c_mode & CP_IFMT)\n    {\n    case CP_IFREG:\n      copyin_regular_file (file_hdr, in_file_des);\n      break;\n\n    case CP_IFDIR:\n      cpio_create_dir (file_hdr, existing_dir);\n      break;\n\n    case CP_IFCHR:\n    case CP_IFBLK:\n#ifdef CP_IFSOCK\n    case CP_IFSOCK:\n#endif\n#ifdef CP_IFIFO\n    case CP_IFIFO:\n#endif\n      copyin_device (file_hdr);\n      break;\n\n#ifdef CP_IFLNK\n    case CP_IFLNK:\n      copyin_link (file_hdr, in_file_des);\n      break;\n#endif\n\n    default:\n      error (0, 0, _(\"%s: unknown file type\"), file_hdr->c_name);\n      tape_toss_input (in_file_des, file_hdr->c_filesize);\n      tape_skip_padding (in_file_des, file_hdr->c_filesize);\n    }\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":504788,"func":"_rsvg_node_text_length_tref (RsvgNodeTref * self, RsvgDrawingCtx * ctx, gdouble * x,\n                             gboolean * lastwasspace)\n{\n    if (self->link)\n        return _rsvg_node_text_length_children (self->link, ctx, x, lastwasspace);\n    return FALSE;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":490103,"func":"static coolkey_private_data_t *coolkey_new_private_data(void)\n{\n\tcoolkey_private_data_t *priv;\n\t\/* allocate priv and zero all the fields *\/\n\tpriv = calloc(1, sizeof(coolkey_private_data_t));\n\tif (!priv)\n\t\treturn NULL;\n\t\/* set other fields as appropriate *\/\n\tpriv->key_id = COOLKEY_INVALID_KEY;\n\tlist_init(&priv->objects_list);\n\tlist_attributes_comparator(&priv->objects_list, coolkey_compare_id);\n\tlist_attributes_copy(&priv->objects_list, coolkey_list_meter, 1);\n\n\treturn priv;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":147388,"func":"static int xts_aesni_setkey(struct crypto_tfm *tfm, const u8 *key,\n\t\t\t    unsigned int keylen)\n{\n\tstruct aesni_xts_ctx *ctx = crypto_tfm_ctx(tfm);\n\tu32 *flags = &tfm->crt_flags;\n\tint err;\n\n\t\/* key consists of keys of equal size concatenated, therefore\n\t * the length must be even\n\t *\/\n\tif (keylen % 2) {\n\t\t*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;\n\t\treturn -EINVAL;\n\t}\n\n\t\/* first half of xts-key is for crypt *\/\n\terr = aes_set_key_common(tfm, ctx->raw_crypt_ctx, key, keylen \/ 2);\n\tif (err)\n\t\treturn err;\n\n\t\/* second half of xts-key is for tweak *\/\n\treturn aes_set_key_common(tfm, ctx->raw_tweak_ctx, key + keylen \/ 2,\n\t\t\t\t  keylen \/ 2);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":507242,"func":"static void s_server_init(void)\n\t{\n\taccept_socket=-1;\n\tcipher=NULL;\n\ts_server_verify=SSL_VERIFY_NONE;\n\ts_dcert_file=NULL;\n\ts_dkey_file=NULL;\n\ts_dchain_file=NULL;\n\ts_cert_file=TEST_CERT;\n\ts_key_file=NULL;\n\ts_chain_file=NULL;\n#ifndef OPENSSL_NO_TLSEXT\n\tcurves=NULL;\n\ts_cert_file2=TEST_CERT2;\n\ts_key_file2=NULL;\n\tctx2=NULL;\n#endif\n#ifdef FIONBIO\n\ts_nbio=0;\n#endif\n\ts_nbio_test=0;\n\tctx=NULL;\n\twww=0;\n\n\tbio_s_out=NULL;\n\ts_debug=0;\n\ts_msg=0;\n\ts_quiet=0;\n\thack=0;\n#ifndef OPENSSL_NO_ENGINE\n\tengine_id=NULL;\n#endif\n\t}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":219602,"func":"void AudioSource::trackMaxAmplitude(int16_t *data, int nSamples) {\n for (int i = nSamples; i > 0; --i) {\n int16_t value = *data++;\n if (value < 0) {\n            value = -value;\n }\n if (mMaxAmplitude < value) {\n            mMaxAmplitude = value;\n }\n }\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":175022,"func":"void MimeHandlerViewContainer::DidReceiveData(const char* data,\n                                              int data_length) {\n  view_id_ += std::string(data, data_length);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":140271,"func":"static int udf_read_extent_cache(struct inode *inode, loff_t bcount,\n\t\t\t\t loff_t *lbcount, struct extent_position *pos)\n{\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\tint ret = 0;\n\n\tspin_lock(&iinfo->i_extent_cache_lock);\n\tif ((iinfo->cached_extent.lstart <= bcount) &&\n\t    (iinfo->cached_extent.lstart != -1)) {\n\t\t\/* Cache hit *\/\n\t\t*lbcount = iinfo->cached_extent.lstart;\n\t\tmemcpy(pos, &iinfo->cached_extent.epos,\n\t\t       sizeof(struct extent_position));\n\t\tif (pos->bh)\n\t\t\tget_bh(pos->bh);\n\t\tret = 1;\n\t}\n\tspin_unlock(&iinfo->i_extent_cache_lock);\n\treturn ret;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":483557,"func":"bool kill_device(struct device *dev)\n{\n\t\/*\n\t * Require the device lock and set the \"dead\" flag to guarantee that\n\t * the update behavior is consistent with the other bitfields near\n\t * it and that we cannot have an asynchronous probe routine trying\n\t * to run while we are tearing out the bus\/class\/sysfs from\n\t * underneath the device.\n\t *\/\n\tlockdep_assert_held(&dev->mutex);\n\n\tif (dev->p->dead)\n\t\treturn false;\n\tdev->p->dead = true;\n\treturn true;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":485216,"func":"DEFUN (clear_ip_bgp_all_ipv4_soft,\n       clear_ip_bgp_all_ipv4_soft_cmd,\n       \"clear ip bgp * ipv4 (unicast|multicast) soft\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Address family\\n\"\n       \"Address Family Modifier\\n\"\n       \"Address Family Modifier\\n\"\n       \"Soft reconfig\\n\")\n{\n  if (strncmp (argv[0], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,\n\t\t\t  BGP_CLEAR_SOFT_BOTH, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_BOTH, NULL);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":76477,"func":"DNSRecordContent* DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass,\n                                               const string& content)\n{\n  zmakermap_t::const_iterator i=getZmakermap().find(make_pair(qclass, qtype));\n  if(i==getZmakermap().end()) {\n    return new UnknownRecordContent(content);\n  }\n\n  return i->second(content);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":431645,"func":"BSONArray roleSetToBSONArray(const unordered_set<RoleName>& roles) {\n    BSONArrayBuilder rolesArrayBuilder;\n    for (unordered_set<RoleName>::const_iterator it = roles.begin(); it != roles.end(); ++it) {\n        const RoleName& role = *it;\n        rolesArrayBuilder.append(BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME\n                                      << role.getRole()\n                                      << AuthorizationManager::ROLE_DB_FIELD_NAME\n                                      << role.getDB()));\n    }\n    return rolesArrayBuilder.arr();\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":503121,"func":"connection_handle_read_body_unknown (request_st * const r, chunkqueue * const cq, chunkqueue * const dst_cq)\n{\n    \/* r->conf.max_request_size is in kBytes *\/\n    const off_t max_request_size = (off_t)r->conf.max_request_size << 10;\n    chunkqueue_append_chunkqueue(dst_cq, cq);\n    if (0 != max_request_size && dst_cq->bytes_in > max_request_size) {\n        log_error(r->conf.errh, __FILE__, __LINE__,\n          \"request-size too long: %lld -> 413\", (long long)dst_cq->bytes_in);\n        \/* 413 Payload Too Large *\/\n        return http_response_reqbody_read_error(r, 413);\n    }\n    return HANDLER_GO_ON;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":94026,"func":"static void hci_req_clear_event_filter(struct hci_request *req)\n{\n\tstruct hci_cp_set_event_filter f;\n\n\tmemset(&f, 0, sizeof(f));\n\tf.flt_type = HCI_FLT_CLEAR_ALL;\n\thci_req_add(req, HCI_OP_SET_EVENT_FLT, 1, &f);\n\n\t\/* Update page scan state (since we may have modified it when setting\n\t * the event filter).\n\t *\/\n\t__hci_req_update_scan(req);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":510604,"func":"my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)\n{\n  \/\/ Item_copy_string is used without fix_fields call\n  if (null_value)\n    return (my_decimal *) 0;\n  string2my_decimal(E_DEC_FATAL_ERROR, &str_value, decimal_value);\n  return (decimal_value);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":78247,"func":"    setSanMatchers(std::vector<envoy::extensions::transport_sockets::tls::v3::SubjectAltNameMatcher>\n                       san_matchers) {\n      san_matchers_ = san_matchers;\n      return *this;\n    }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":168204,"func":"static void limitedWithMissingDefaultAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)\n{\n    TestObject* imp = V8TestObject::toNative(info.Holder());\n    String resultValue = imp->fastGetAttribute(HTMLNames::limitedwithmissingdefaultattributeAttr);\n    if (resultValue.isEmpty()) {\n        resultValue = \"rsa\";\n    } else if (equalIgnoringCase(resultValue, \"rsa\")) {\n        resultValue = \"rsa\";\n    } else if (equalIgnoringCase(resultValue, \"dsa\")) {\n        resultValue = \"dsa\";\n    } else {\n        resultValue = \"\";\n    }\n    v8SetReturnValueString(info, resultValue, info.GetIsolate());\n}\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":467479,"func":"j2k_error(const char *msg, void *client_data) {\n    JPEG2KDECODESTATE *state = (JPEG2KDECODESTATE *)client_data;\n    free((void *)state->error_msg);\n    state->error_msg = strdup(msg);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":341943,"func":"static void ppc_hash64_set_isi(CPUState *cs, CPUPPCState *env,\n\n                               uint64_t error_code)\n\n{\n\n    bool vpm;\n\n\n\n    if (msr_ir) {\n\n        vpm = !!(env->spr[SPR_LPCR] & LPCR_VPM1);\n\n    } else {\n\n        vpm = !!(env->spr[SPR_LPCR] & LPCR_VPM0);\n\n    }\n\n    if (vpm && !msr_hv) {\n\n        cs->exception_index = POWERPC_EXCP_HISI;\n\n    } else {\n\n        cs->exception_index = POWERPC_EXCP_ISI;\n\n    }\n\n    env->error_code = error_code;\n\n}\n","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":14415,"func":" z2grestore(i_ctx_t *i_ctx_p)\n {\n    if (!restore_page_device(igs, gs_gstate_saved(igs)))\n         return gs_grestore(igs);\n     return push_callout(i_ctx_p, \"%grestorepagedevice\");\n }\n","target":1,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":61147,"func":"static int spawn_next_command_in_evd(struct analyze_event_data *evd)\n{\n    evd->env_list = export_event_config(evd->event_name);\n    int r = spawn_next_command(evd->run_state, g_dump_dir_name, evd->event_name, EXECFLG_SETPGID);\n    if (r >= 0)\n    {\n        g_event_child_pid = evd->run_state->command_pid;\n    }\n    else\n    {\n        unexport_event_config(evd->env_list);\n        evd->env_list = NULL;\n    }\n    return r;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":275291,"func":"  RenderViewZoomer(const GURL& url, double zoom_level)\n      : zoom_level_(zoom_level) {\n    host_ = net::GetHostOrSpecFromURL(url);\n  }\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":186678,"func":"void RenderFrameHostImpl::DidReceiveFirstUserActivation() {\n  delegate_->DidReceiveFirstUserActivation(this);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":496073,"func":"is_nfs4_flags_w(const wchar_t *start, const wchar_t *end, int *permset)\n{\n\tconst wchar_t *p = start;\n\n\twhile (p < end) {\n\t\tswitch(*p++) {\n\t\tcase L'f':\n\t\t\t*permset |= ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT;\n\t\t\tbreak;\n\t\tcase L'd':\n\t\t\t*permset |= ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT;\n\t\t\tbreak;\n\t\tcase L'i':\n\t\t\t*permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY;\n\t\t\tbreak;\n\t\tcase L'n':\n\t\t\t*permset |=\n\t\t\t    ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT;\n\t\t\tbreak;\n\t\tcase L'S':\n\t\t\t*permset |= ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS;\n\t\t\tbreak;\n\t\tcase L'F':\n\t\t\t*permset |= ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS;\n\t\t\tbreak;\n\t\tcase L'I':\n\t\t\t*permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERITED;\n\t\t\tbreak;\n\t\tcase L'-':\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn (0);\n\t\t}\n\t}\n\treturn (1);\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":257832,"func":"void vp9_init_dsmotion_compensation ( search_site_config * cfg , int stride ) {\n int len , ss_count = 1 ;\n cfg -> ss [ 0 ] . mv . col = cfg -> ss [ 0 ] . mv . row = 0 ;\n cfg -> ss [ 0 ] . offset = 0 ;\n for ( len = MAX_FIRST_STEP ;\n len > 0 ;\n len \/= 2 ) {\n const MV ss_mvs [ ] = {\n {\n - len , 0 }\n , {\n len , 0 }\n , {\n 0 , - len }\n , {\n 0 , len }\n }\n ;\n int i ;\n for ( i = 0 ;\n i < 4 ;\n ++ i ) {\n search_site * const ss = & cfg -> ss [ ss_count ++ ] ;\n ss -> mv = ss_mvs [ i ] ;\n ss -> offset = ss -> mv . row * stride + ss -> mv . col ;\n }\n }\n cfg -> ss_count = ss_count ;\n cfg -> searches_per_step = 4 ;\n }","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":252058,"func":"void PrintPreviewDialogController::RemoveInitiator(\n    WebContents* initiator) {\n  WebContents* preview_dialog = GetPrintPreviewForContents(initiator);\n  DCHECK(preview_dialog);\n  preview_dialog_map_[preview_dialog] = nullptr;\n  RemoveObservers(initiator);\n\n  PrintViewManager::FromWebContents(initiator)->PrintPreviewDone();\n\n  if (content::WebUI* web_ui = preview_dialog->GetWebUI()) {\n    PrintPreviewUI* print_preview_ui =\n        static_cast<PrintPreviewUI*>(web_ui->GetController());\n    if (print_preview_ui)\n      print_preview_ui->OnInitiatorClosed();\n  }\n}\n","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":199421,"func":" static void GrowCapacityAndConvertImpl(Handle<JSObject> object,\n uint32_t capacity) {\n Handle<FixedArray> parameter_map(FixedArray::cast(object->elements()));\n Handle<FixedArray> old_elements(FixedArray::cast(parameter_map->get(1)));\n ElementsKind from_kind = object->GetElementsKind();\n    DCHECK(from_kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS ||\n static_cast<uint32_t>(old_elements->length()) < capacity);\n Handle<FixedArrayBase> elements =\n ConvertElementsWithCapacity(object, old_elements, from_kind, capacity);\n Handle<Map> new_map = JSObject::GetElementsTransitionMap(\n        object, FAST_SLOPPY_ARGUMENTS_ELEMENTS);\n JSObject::MigrateToMap(object, new_map);\n    parameter_map->set(1, *elements);\n JSObject::ValidateElements(object);\n }\n","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":265191,"func":"int tcp_filter(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct tcphdr *th = (struct tcphdr *)skb->data;\n\tunsigned int eaten = skb->len;\n\tint err;\n\n\terr = sk_filter_trim_cap(sk, skb, th->doff * 4);\n\tif (!err) {\n\t\teaten -= skb->len;\n\t\tTCP_SKB_CB(skb)->end_seq -= eaten;\n\t}\n\treturn err;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":481120,"func":"static bool kvm_zap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,\n\t\t\t  const struct kvm_memory_slot *slot)\n{\n\treturn pte_list_destroy(kvm, rmap_head);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":23012,"func":"static const char * hfinfo_number_value_format64 ( const header_field_info * hfinfo , char buf [ 64 ] , guint64 value ) {\n int display = hfinfo -> display ;\n if ( hfinfo -> type == FT_FRAMENUM ) {\n display = BASE_DEC ;\n }\n return hfinfo_number_value_format_display64 ( hfinfo , display , buf , value ) ;\n }","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":393460,"func":"parse_list(xmlChar *str) {\n    xmlChar **buffer;\n    xmlChar **out = NULL;\n    int buffer_size = 0;\n    int len;\n\n    if(str == NULL) {\n\treturn(NULL);\n    }\n\n    len = xmlStrlen(str);\n    if((str[0] == '\\'') && (str[len - 1] == '\\'')) {\n\tstr[len - 1] = '\\0';\n\tstr++;\n    }\n    \/*\n     * allocate an translation buffer.\n     *\/\n    buffer_size = 1000;\n    buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*));\n    if (buffer == NULL) {\n\tperror(\"malloc failed\");\n\treturn(NULL);\n    }\n    out = buffer;\n\n    while(*str != '\\0') {\n\tif (out - buffer > buffer_size - 10) {\n\t    int indx = out - buffer;\n\n\t    xxx_growBufferReentrant();\n\t    out = &buffer[indx];\n\t}\n\t(*out++) = str;\n\twhile(*str != ',' && *str != '\\0') ++str;\n\tif(*str == ',') *(str++) = '\\0';\n    }\n    (*out) = NULL;\n    return buffer;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":430548,"func":"static struct istream *quoted_string_istream_create\n(struct managesieve_parser *parser)\n{\n\tstruct quoted_string_istream *qsstream;\n\n\tqsstream = i_new(struct quoted_string_istream, 1);\n\tqsstream->istream.max_buffer_size =\n\t\tparser->input->real_stream->max_buffer_size;\n\tqsstream->istream.read = quoted_string_istream_read;\n\n\tqsstream->istream.istream.readable_fd = FALSE;\n\tqsstream->istream.istream.blocking = parser->input->blocking;\n\tqsstream->istream.istream.seekable = FALSE;\n\treturn i_stream_create(&qsstream->istream, parser->input,\n\t\t\t       i_stream_get_fd(parser->input), 0);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":56057,"func":"filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)\n{\n  binary FinalHead[4+8]; \/\/ Class D + 64 bits coded size\n  unsigned int FinalHeadSize;\n\n  FinalHeadSize = EBML_ID_LENGTH((const EbmlId&)*this);\n  EbmlId(*this).Fill(FinalHead);\n\n  int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite);\n  CodedValueLength(Size, CodedSize, &FinalHead[FinalHeadSize]);\n  FinalHeadSize += CodedSize;\n\n  output.writeFully(FinalHead, FinalHeadSize);\n  if (!bKeepPosition) {\n    ElementPosition = output.getFilePointer() - FinalHeadSize;\n    SizePosition = ElementPosition + EBML_ID_LENGTH((const EbmlId&)*this);\n  }\n\n  return FinalHeadSize;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":81548,"func":"static inline void SetPixelGray(const Image *restrict image,const Quantum gray,\n  Quantum *restrict pixel)\n{\n  pixel[image->channel_map[GrayPixelChannel].offset]=gray;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":84233,"func":"static void *cgm_init(const char *name)\n{\n\tstruct cgm_data *d;\n\n\tif (!cgm_dbus_connect()) {\n\t\tERROR(\"Error connecting to cgroup manager\");\n\t\treturn NULL;\n\t}\n\n\tcheck_supports_multiple_controllers(-1);\n\n\td = malloc(sizeof(*d));\n\tif (!d) {\n\t\tcgm_dbus_disconnect();\n\t\treturn NULL;\n\t}\n\n\tmemset(d, 0, sizeof(*d));\n\td->name = strdup(name);\n\tif (!d->name) {\n\t\tcgm_dbus_disconnect();\n\t\tgoto err1;\n\t}\n\n\td->cgroup_pattern = lxc_global_config_value(\"lxc.cgroup.pattern\");\n\n\t\/\/ cgm_create immediately gets called so keep the connection open\n\treturn d;\n\nerr1:\n\tfree(d);\n\treturn NULL;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":468263,"func":"llsec_dev_find_long(struct mac802154_llsec *sec, __le64 hwaddr)\n{\n\tstruct mac802154_llsec_device *dev;\n\tu64 key = llsec_dev_hash_long(hwaddr);\n\n\thash_for_each_possible_rcu(sec->devices_hw, dev, bucket_hw, key) {\n\t\tif (dev->dev.hwaddr == hwaddr)\n\t\t\treturn dev;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":103369,"func":"static int sctp_connect(struct sock *sk, struct sockaddr *addr,\n\t\t\tint addr_len)\n{\n\tint err = 0;\n\tstruct sctp_af *af;\n\n\tlock_sock(sk);\n\n\tpr_debug(\"%s: sk:%p, sockaddr:%p, addr_len:%d\\n\", __func__, sk,\n\t\t addr, addr_len);\n\n\t\/* Validate addr_len before calling common connect\/connectx routine. *\/\n\taf = sctp_get_af_specific(addr->sa_family);\n\tif (!af || addr_len < af->sockaddr_len) {\n\t\terr = -EINVAL;\n\t} else {\n\t\t\/* Pass correct addr len to common routine (so it knows there\n\t\t * is only one address being passed.\n\t\t *\/\n\t\terr = __sctp_connect(sk, addr, af->sockaddr_len, NULL);\n\t}\n\n\trelease_sock(sk);\n\treturn err;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":349922,"func":"  absl::string_view hostAndPort() const { return host_and_port_; }","target":1,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":329882,"func":"static int ast_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n    uint32_t type, size;\n\n    int64_t pos;\n\n    int ret;\n\n\n\n    if (avio_feof(s->pb))\n\n        return AVERROR_EOF;\n\n\n\n    pos  = avio_tell(s->pb);\n\n    type = avio_rl32(s->pb);\n\n    size = avio_rb32(s->pb);\n\n    if (size > INT_MAX \/ s->streams[0]->codecpar->channels)\n\n        return AVERROR_INVALIDDATA;\n\n\n\n    size *= s->streams[0]->codecpar->channels;\n\n    if ((ret = avio_skip(s->pb, 24)) < 0) \/\/ padding\n\n        return ret;\n\n\n\n    if (type == MKTAG('B','L','C','K')) {\n\n        ret = av_get_packet(s->pb, pkt, size);\n\n        pkt->stream_index = 0;\n\n        pkt->pos = pos;\n\n    } else {\n\n        av_log(s, AV_LOG_ERROR, \"unknown chunk %x\\n\", type);\n\n        avio_skip(s->pb, size);\n\n        ret = AVERROR_INVALIDDATA;\n\n    }\n\n\n\n    return ret;\n\n}\n","target":1,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":63319,"func":"\tvoid testCompareRangeHelper(const char * a, const char * b, int expected, bool avoidNullRange = true) {\n\t\tUriTextRangeA ra;\n\t\tUriTextRangeA rb;\n\n\t\tif (a) {\n\t\t\tra.first = a;\n\t\t\tra.afterLast = a + strlen(a);\n\t\t} else {\n\t\t\tra.first = NULL;\n\t\t\tra.afterLast = NULL;\n\t\t}\n\n\t\tif (b) {\n\t\t\trb.first = b;\n\t\t\trb.afterLast = b + strlen(b);\n\t\t} else {\n\t\t\trb.first = NULL;\n\t\t\trb.afterLast = NULL;\n\t\t}\n\n\t\tconst int received = uriCompareRangeA(\n\t\t\t\t((a == NULL) && avoidNullRange) ? NULL : &ra,\n\t\t\t\t((b == NULL) && avoidNullRange) ? NULL : &rb);\n\t\tif (received != expected) {\n\t\t\tprintf(\"Comparing <%s> to <%s> yields %d, expected %d.\\n\",\n\t\t\t\t\ta, b, received, expected);\n\t\t}\n\t\tASSERT_TRUE(received == expected);\n\t}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":53437,"func":"GF_Err iinf_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_ItemInfoBox *ptr = (GF_ItemInfoBox *)s;\n\tif (!s) return GF_BAD_PARAM;\n\tptr->size += (ptr->version == 0) ? 2 : 4;\n\tgf_isom_check_position_list(s, ptr->item_infos, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":463599,"func":"\nstatic int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)\n{\n\tstruct hlist_head *list;\n\tstruct io_kiocb *req;\n\n\tlist = &ctx->cancel_hash[hash_long(sqe_addr, ctx->cancel_hash_bits)];\n\thlist_for_each_entry(req, list, hash_node) {\n\t\tif (sqe_addr != req->user_data)\n\t\t\tcontinue;\n\t\tif (io_poll_remove_one(req))\n\t\t\treturn 0;\n\t\treturn -EALREADY;\n\t}\n\n\treturn -ENOENT;","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":42823,"func":"XMLReader::XMLReader() : m_ptr(nullptr), m_input(nullptr), m_schema(nullptr) {\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":111695,"func":"TEST(CombineHashes, TestHashOutputsDifferent) {\n  size_t output1 = CombineHashes({1, 2, 3, 4});\n  size_t output2 = CombineHashes({1, 2, 2, 4});\n  EXPECT_NE(output1, output2);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":268166,"func":"ex_scriptencoding(exarg_T *eap)\n{\n    source_cookie_T\t*sp;\n    char_u\t\t*name;\n\n    if (!sourcing_a_script(eap))\n    {\n\temsg(_(e_scriptencoding_used_outside_of_sourced_file));\n\treturn;\n    }\n\n    if (*eap->arg != NUL)\n    {\n\tname = enc_canonize(eap->arg);\n\tif (name == NULL)\t\/\/ out of memory\n\t    return;\n    }\n    else\n\tname = eap->arg;\n\n    \/\/ Setup for conversion from the specified encoding to 'encoding'.\n    sp = (source_cookie_T *)getline_cookie(eap->getline, eap->cookie);\n    convert_setup(&sp->conv, name, p_enc);\n\n    if (name != eap->arg)\n\tvim_free(name);\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":288424,"func":"void TSMimeParserClear ( TSMimeParser parser ) {\n sdk_assert ( sdk_sanity_check_mime_parser ( parser ) == TS_SUCCESS ) ;\n mime_parser_clear ( ( MIMEParser * ) parser ) ;\n }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":387997,"func":"xmlDictCreate(void) {\n    xmlDictPtr dict;\n\n    if (!xmlDictInitialized)\n        if (!__xmlInitializeDict())\n            return(NULL);\n\n#ifdef DICT_DEBUG_PATTERNS\n    fprintf(stderr, \"C\");\n#endif\n\n    dict = xmlMalloc(sizeof(xmlDict));\n    if (dict) {\n        dict->ref_counter = 1;\n        dict->limit = 0;\n\n        dict->size = MIN_DICT_SIZE;\n\tdict->nbElems = 0;\n        dict->dict = xmlMalloc(MIN_DICT_SIZE * sizeof(xmlDictEntry));\n\tdict->strings = NULL;\n\tdict->subdict = NULL;\n        if (dict->dict) {\n\t    memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));\n#ifdef DICT_RANDOMIZATION\n            dict->seed = __xmlRandom();\n#else\n            dict->seed = 0;\n#endif\n\t    return(dict);\n        }\n        xmlFree(dict);\n    }\n    return(NULL);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":523558,"func":"void SELECT_LEX::mark_const_derived(bool empty)\n{\n  TABLE_LIST *derived= master_unit()->derived;\n  \/* join == NULL in  DELETE ... RETURNING *\/\n  if (!(join && join->thd->lex->describe) && derived)\n  {\n    if (!empty)\n      increase_derived_records(1);\n    if (!master_unit()->is_unit_op() && !derived->is_merged_derived() &&\n        !(join && join->with_two_phase_optimization))\n      derived->fill_me= TRUE;\n  }\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":100943,"func":"static void gluster_cache_refresh(glfs_t *fs, const char *cfgstring)\n{\n\tstruct gluster_cacheconn **entry;\n\tchar** config;\n\tsize_t i = 0;\n\tsize_t j = 0;\n\n\tif (!fs)\n\t\treturn;\n\n\tdarray_foreach(entry, cache) {\n\t\tif ((*entry)->fs == fs) {\n\t\t\tif (cfgstring) {\n\t\t\t\tdarray_foreach(config, (*entry)->cfgstring) {\n\t\t\t\t\tif (!strcmp(*config, cfgstring)) {\n\t\t\t\t\t\tfree(*config);\n\t\t\t\t\t\tdarray_remove((*entry)->cfgstring, j);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (darray_size((*entry)->cfgstring))\n\t\t\t\treturn;\n\n\t\t\tfree((*entry)->volname);\n\t\t\tglfs_fini((*entry)->fs);\n\t\t\t(*entry)->fs = NULL;\n\t\t\tgluster_free_host((*entry)->server);\n\t\t\tfree((*entry)->server);\n\t\t\t(*entry)->server = NULL;\n\t\t\tfree((*entry));\n\n\t\t\tdarray_remove(cache, i);\n\t\t\treturn;\n\t\t} else {\n\t\t\ti++;\n\t\t}\n\t}\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":500670,"func":"static int cfg_print_pff_indent(cfg_t *cfg, FILE *fp,\n\t\t\t\tcfg_print_filter_func_t fb_pff, int indent)\n{\n\tint i, result = CFG_SUCCESS;\n\n\tfor (i = 0; cfg->opts[i].name; i++) {\n\t\tcfg_print_filter_func_t pff = cfg->pff ? cfg->pff : fb_pff;\n\t\tif (pff && pff(cfg, &cfg->opts[i]))\n\t\t\tcontinue;\n\t\tresult += cfg_opt_print_pff_indent(&cfg->opts[i], fp, pff, indent);\n\t}\n\n\treturn result;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":89702,"func":"qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mon G_GNUC_UNUSED,\n                                    virDomainObjPtr vm,\n                                    const char *devAlias,\n                                    void *opaque)\n{\n    virQEMUDriverPtr driver = opaque;\n    struct qemuProcessEvent *processEvent = NULL;\n    char *data;\n\n    virObjectLock(vm);\n\n    VIR_DEBUG(\"Device %s RX Filter changed in domain %p %s\",\n              devAlias, vm, vm->def->name);\n\n    processEvent = g_new0(struct qemuProcessEvent, 1);\n\n    processEvent->eventType = QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED;\n    data = g_strdup(devAlias);\n    processEvent->data = data;\n    processEvent->vm = virObjectRef(vm);\n\n    if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {\n        virObjectUnref(vm);\n        goto error;\n    }\n\n cleanup:\n    virObjectUnlock(vm);\n    return 0;\n error:\n    qemuProcessEventFree(processEvent);\n    goto cleanup;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":240405,"func":"  void OnIceCandidateImpl(const std::string& sdp, const std::string& sdp_mid,\n      int sdp_mline_index, int component, int address_family) {\n    DCHECK(main_thread_->BelongsToCurrentThread());\n    if (handler_) {\n      handler_->OnIceCandidate(sdp, sdp_mid, sdp_mline_index, component,\n          address_family);\n    }\n  }\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":161866,"func":"gboolean\nmono_verifier_is_enabled_for_class (MonoClass *klass)\n{\n\treturn verify_all || (verifier_mode > MONO_VERIFIER_MODE_OFF && !klass->image->assembly->in_gac && klass->image != mono_defaults.corlib);","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":105689,"func":"XML_SetBase(XML_Parser parser, const XML_Char *p) {\n  if (parser == NULL)\n    return XML_STATUS_ERROR;\n  if (p) {\n    p = poolCopyString(&parser->m_dtd->pool, p);\n    if (! p)\n      return XML_STATUS_ERROR;\n    parser->m_curBase = p;\n  } else\n    parser->m_curBase = NULL;\n  return XML_STATUS_OK;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":116454,"func":"static void futex_wait_queue_me(struct futex_hash_bucket *hb, struct futex_q *q,\n\t\t\t\tstruct hrtimer_sleeper *timeout)\n{\n\t\/*\n\t * The task state is guaranteed to be set before another task can\n\t * wake it. set_current_state() is implemented using smp_store_mb() and\n\t * queue_me() calls spin_unlock() upon completion, both serializing\n\t * access to the hash list and forcing another memory barrier.\n\t *\/\n\tset_current_state(TASK_INTERRUPTIBLE);\n\tqueue_me(q, hb);\n\n\t\/* Arm the timer *\/\n\tif (timeout)\n\t\thrtimer_start_expires(&timeout->timer, HRTIMER_MODE_ABS);\n\n\t\/*\n\t * If we have been removed from the hash list, then another task\n\t * has tried to wake us, and we can skip the call to schedule().\n\t *\/\n\tif (likely(!plist_node_empty(&q->list))) {\n\t\t\/*\n\t\t * If the timer has already expired, current will already be\n\t\t * flagged for rescheduling. Only call schedule if there\n\t\t * is no timeout, or if it has yet to expire.\n\t\t *\/\n\t\tif (!timeout || timeout->task)\n\t\t\tfreezable_schedule();\n\t}\n\t__set_current_state(TASK_RUNNING);\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":279777,"func":"  LayerTreeHostTestReadyToDrawEmpty()\n      : did_notify_ready_to_draw_(false),\n        all_tiles_required_for_draw_are_ready_to_draw_(false),\n        required_for_draw_count_(0) {}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":202435,"func":"GooString *ASCII85Stream::getPSFilter(int psLevel, const char *indent) {\n  GooString *s;\n\n  if (psLevel < 2) {\n    return NULL;\n  }\n  if (!(s = str->getPSFilter(psLevel, indent))) {\n    return NULL;\n  }\n  s->append(indent)->append(\"\/ASCII85Decode filter\\n\");\n  return s;\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":64430,"func":"void SetAttrValue(StringPiece value, AttrValue* out) {\n  out->set_s(value.data(), value.size());\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":277899,"func":"static void png_flush_data(png_structp png_ptr)\n{\n  (void) png_ptr;\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":368852,"func":"static void construct_client(void *obj)\n{\n\tPgSocket *client = obj;\n\n\tmemset(client, 0, sizeof(PgSocket));\n\tlist_init(&client->head);\n\tsbuf_init(&client->sbuf, client_proto);\n\tclient->state = CL_FREE;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":134253,"func":"TEST_F(SslContextImplTest, MustHaveSubjectOrSAN) {\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  const std::string tls_context_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_subject_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_subject_key.pem\"\n  )EOF\";\n  TestUtility::loadFromYaml(TestEnvironment::substitute(tls_context_yaml), tls_context);\n  ServerContextConfigImpl server_context_config(tls_context, factory_context_);\n  EXPECT_THROW_WITH_REGEX(\n      manager_.createSslServerContext(store_, server_context_config, {}, nullptr), EnvoyException,\n      \"has neither subject CN nor SAN names\");\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":435741,"func":"const struct submodule *submodule_from_ce(const struct cache_entry *ce)\n{\n\tif (!S_ISGITLINK(ce->ce_mode))\n\t\treturn NULL;\n\n\tif (!should_update_submodules())\n\t\treturn NULL;\n\n\treturn submodule_from_path(null_sha1, ce->name);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":62893,"func":"xfs_vm_releasepage(\n\tstruct page\t\t*page,\n\tgfp_t\t\t\tgfp_mask)\n{\n\tint\t\t\tdelalloc, unwritten;\n\n\ttrace_xfs_releasepage(page->mapping->host, page, 0, 0);\n\n\t\/*\n\t * mm accommodates an old ext3 case where clean pages might not have had\n\t * the dirty bit cleared. Thus, it can send actual dirty pages to\n\t * ->releasepage() via shrink_active_list(). Conversely,\n\t * block_invalidatepage() can send pages that are still marked dirty\n\t * but otherwise have invalidated buffers.\n\t *\n\t * We've historically freed buffers on the latter. Instead, quietly\n\t * filter out all dirty pages to avoid spurious buffer state warnings.\n\t * This can likely be removed once shrink_active_list() is fixed.\n\t *\/\n\tif (PageDirty(page))\n\t\treturn 0;\n\n\txfs_count_page_state(page, &delalloc, &unwritten);\n\n\tif (WARN_ON_ONCE(delalloc))\n\t\treturn 0;\n\tif (WARN_ON_ONCE(unwritten))\n\t\treturn 0;\n\n\treturn try_to_free_buffers(page);\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":225186,"func":"bool SessionModelAssociator::SessionWindowHasNoTabsToSync(\n    const SessionWindow& window) {\n  int num_populated = 0;\n  for (std::vector<SessionTab*>::const_iterator i = window.tabs.begin();\n      i != window.tabs.end(); ++i) {\n    const SessionTab* tab = *i;\n    if (IsValidSessionTab(*tab))\n      num_populated++;\n  }\n  if (num_populated == 0)\n    return true;\n  return false;\n}\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":214680,"func":"void NPN_ForceRedraw(NPP id) {\n\n  NOTIMPLEMENTED();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":292748,"func":"static inline void skb_orphan_try(struct sk_buff *skb)\n{\n\tstruct sock *sk = skb->sk;\n\n\tif (sk && !skb_shinfo(skb)->tx_flags) {\n\t\t\/* skb_tx_hash() wont be able to get sk.\n\t\t * We copy sk_hash into skb->rxhash\n\t\t *\/\n\t\tif (!skb->rxhash)\n\t\t\tskb->rxhash = sk->sk_hash;\n\t\tskb_orphan(skb);\n\t}\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":24935,"func":"bool one_thread_per_connection_end ( THD * thd , bool put_in_cache ) {\n DBUG_ENTER ( \"one_thread_per_connection_end\" ) ;\n unlink_thd ( thd ) ;\n my_pthread_setspecific_ptr ( THR_THD , 0 ) ;\n if ( put_in_cache ) {\n mysql_mutex_lock ( & LOCK_thread_count ) ;\n put_in_cache = cache_thread ( ) ;\n mysql_mutex_unlock ( & LOCK_thread_count ) ;\n if ( put_in_cache ) DBUG_RETURN ( 0 ) ;\n }\n DBUG_PRINT ( \"signal\" , ( \"Broadcasting COND_thread_count\" ) ) ;\n DBUG_LEAVE ;\n # if defined ( HAVE_OPENSSL ) && ! defined ( EMBEDDED_LIBRARY ) ERR_remove_state ( 0 ) ;\n # endif my_thread_end ( ) ;\n mysql_cond_broadcast ( & COND_thread_count ) ;\n pthread_exit ( 0 ) ;\n return 0 ;\n }","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":255952,"func":"MagickExport void *AcquireQuantumMemory(const size_t count,const size_t quantum)\n{\n   size_t\n     extent;\n \n  if (CheckMemoryOverflow(count,quantum) != MagickFalse)\n     return((void *) NULL);\n   extent=count*quantum;\n   return(AcquireMagickMemory(extent));\n}\n","target":1,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":81097,"func":"static int madvise_need_mmap_write(int behavior)\n{\n\tswitch (behavior) {\n\tcase MADV_REMOVE:\n\tcase MADV_WILLNEED:\n\tcase MADV_DONTNEED:\n\tcase MADV_FREE:\n\t\treturn 0;\n\tdefault:\n\t\t\/* be safe, default to 1. list exceptions explicitly *\/\n\t\treturn 1;\n\t}\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":332251,"func":"bool memory_region_is_unassigned(MemoryRegion *mr)\n\n{\n\n    return mr != &io_mem_ram && mr != &io_mem_rom\n\n        && mr != &io_mem_notdirty && !mr->rom_device\n\n        && mr != &io_mem_watch;\n\n}\n","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":465953,"func":"static inline int __hv_remote_flush_tlb_with_range(struct kvm *kvm,\n\t\tstruct kvm_vcpu *vcpu, struct kvm_tlb_range *range)\n{\n\tu64 ept_pointer = to_vmx(vcpu)->ept_pointer;\n\n\t\/*\n\t * FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE hypercall needs address\n\t * of the base of EPT PML4 table, strip off EPT configuration\n\t * information.\n\t *\/\n\tif (range)\n\t\treturn hyperv_flush_guest_mapping_range(ept_pointer & PAGE_MASK,\n\t\t\t\tkvm_fill_hv_flush_list_func, (void *)range);\n\telse\n\t\treturn hyperv_flush_guest_mapping(ept_pointer & PAGE_MASK);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":521392,"func":"static int check_func_double(THD *thd, struct st_mysql_sys_var *var,\n                             void *save, st_mysql_value *value)\n{\n  double v;\n  my_bool fixed;\n  struct my_option option;\n\n  value->val_real(value, &v);\n  plugin_opt_set_limits(&option, var);\n  *(double *) save= getopt_double_limit_value(v, &option, &fixed);\n\n  return throw_bounds_warning(thd, var->name, fixed, v);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":332189,"func":"static void v4l2_free_buffer(void *opaque, uint8_t *unused)\n\n{\n\n    V4L2Buffer* avbuf = opaque;\n\n    V4L2m2mContext *s = buf_to_m2mctx(avbuf);\n\n\n\n    atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);\n\n    if (s->reinit) {\n\n        if (!atomic_load(&s->refcount))\n\n            sem_post(&s->refsync);\n\n        return;\n\n    }\n\n\n\n    if (avbuf->context->streamon) {\n\n        ff_v4l2_buffer_enqueue(avbuf);\n\n        return;\n\n    }\n\n\n\n    if (!atomic_load(&s->refcount))\n\n        ff_v4l2_m2m_codec_end(s->avctx);\n\n}\n","target":1,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":248643,"func":"  MockTopSitesObserver() {}\n","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":153787,"func":"static int nfs3svc_release_getacl(struct svc_rqst *rqstp, __be32 *p,\n\t\tstruct nfsd3_getaclres *resp)\n{\n\tfh_put(&resp->fh);\n\tposix_acl_release(resp->acl_access);\n\tposix_acl_release(resp->acl_default);\n\treturn 1;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":75029,"func":"int get_compat_itimerspec64(struct itimerspec64 *its,\n\t\t\tconst struct compat_itimerspec __user *uits)\n{\n\n\tif (__compat_get_timespec64(&its->it_interval, &uits->it_interval) ||\n\t    __compat_get_timespec64(&its->it_value, &uits->it_value))\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":402371,"func":"static void lease_match_parser_new_file(\n\tuint32_t num_files,\n\tconst struct leases_db_file *files,\n\tstruct lease_match_state *state)\n{\n\tuint32_t i;\n\n\tfor (i = 0; i < num_files; i++) {\n\t\tconst struct leases_db_file *f = &files[i];\n\t\tif (strequal(state->servicepath, f->servicepath)) {\n\t\t\tstate->match_status = NT_STATUS_INVALID_PARAMETER;\n\t\t\treturn;\n\t\t}\n\t}\n\n\t\/* Dynamic share case. Break leases on all other files. *\/\n\tstate->match_status = leases_db_copy_file_ids(state->mem_ctx,\n\t\t\t\t\tnum_files,\n\t\t\t\t\tfiles,\n\t\t\t\t\t&state->ids);\n\tif (!NT_STATUS_IS_OK(state->match_status)) {\n\t\treturn;\n\t}\n\n\tstate->num_file_ids = num_files;\n\tstate->match_status = NT_STATUS_OPLOCK_NOT_GRANTED;\n\treturn;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":112561,"func":"cockpit_web_response_is_header_value (const gchar *string)\n{\n  string += strcspn (string, \"\\r\\n\\v\");\n  return string[0] == '\\0';\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":168460,"func":"StepRange HTMLInputElement::createStepRange(AnyStepHandling anyStepHandling) const\n{\n    return m_inputType->createStepRange(anyStepHandling);\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":243991,"func":"static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, unsigned short numzeros)\n{\n  hash->val[wpos] = (int)hashval;\n  if(hash->head[hashval] != -1) hash->chain[wpos] = hash->head[hashval];\n  hash->head[hashval] = wpos;\n\n  hash->zeros[wpos] = numzeros;\n  if(hash->headz[numzeros] != -1) hash->chainz[wpos] = hash->headz[numzeros];\n  hash->headz[numzeros] = wpos;\n}\n","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":207242,"func":"  explicit AlwaysDrawSwapPromise(const ui::LatencyInfo& latency_info)\n      : latency_info_(latency_info) {}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":354780,"func":"static unsigned int bad_file_poll(struct file *filp, poll_table *wait)\n{\n\treturn POLLERR;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":421192,"func":"static int hso_mux_serial_write_data(struct hso_serial *serial)\n{\n\tif (NULL == serial)\n\t\treturn -EINVAL;\n\n\treturn mux_device_request(serial,\n\t\t\t\t  USB_CDC_SEND_ENCAPSULATED_COMMAND,\n\t\t\t\t  serial->parent->port_spec & HSO_PORT_MASK,\n\t\t\t\t  serial->tx_urb,\n\t\t\t\t  &serial->ctrl_req_tx,\n\t\t\t\t  serial->tx_data, serial->tx_data_count);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":43999,"func":"MagickExport MagickBooleanType GetImageEntropy(const Image *image,\n  double *entropy,ExceptionInfo *exception)\n{\n  ChannelStatistics\n    *channel_statistics;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  channel_statistics=GetImageStatistics(image,exception);\n  if (channel_statistics == (ChannelStatistics *) NULL)\n    return(MagickFalse);\n  *entropy=channel_statistics[CompositePixelChannel].entropy;\n  channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(\n    channel_statistics);\n  return(MagickTrue);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":216246,"func":"AppListSyncableService::GetSyncItem(const std::string& id) const {\n  SyncItemMap::const_iterator iter = sync_items_.find(id);\n  if (iter != sync_items_.end())\n    return iter->second;\n  return NULL;\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":518295,"func":"void TABLE::use_index(int key_to_save)\n{\n  uint i= 1;\n  DBUG_ASSERT(!created && key_to_save < (int)s->keys);\n  if (key_to_save >= 0)\n    \/* Save the given key. *\/\n    memmove(key_info, key_info + key_to_save, sizeof(KEY));\n  else\n    \/* Drop all keys; *\/\n    i= 0;\n\n  s->keys= i;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":299037,"func":"AP4_MetaData::AddDcfStringEntry(AP4_DcfStringAtom* atom, const char* namespc)\n{\n    AP4_String key_name;\n    ResolveKeyName(atom->GetType(), key_name);\n    \n    AP4_MetaData::Value* value = new AP4_StringMetaDataValue(atom->GetValue().GetChars());\n    m_Entries.Add(new Entry(key_name.GetChars(), namespc, value));\n    \n    return AP4_SUCCESS;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":448287,"func":"static u32 nfsd_eof_on_read(struct file *file, loff_t offset, ssize_t len,\n\t\tsize_t expected)\n{\n\tif (expected != 0 && len == 0)\n\t\treturn 1;\n\tif (offset+len >= i_size_read(file_inode(file)))\n\t\treturn 1;\n\treturn 0;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":200777,"func":"void FileAPIMessageFilter::OnCloneBlob(\n    const GURL& url, const GURL& src_url) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));\n  blob_storage_context_->controller()->CloneBlob(url, src_url);\n  blob_urls_.insert(url.spec());\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":86529,"func":"static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr)\n{\n\tu8 rc = LLC_PDU_LEN_U;\n\n\tif (addr->sllc_test || addr->sllc_xid)\n\t\trc = LLC_PDU_LEN_U;\n\telse if (sk->sk_type == SOCK_STREAM)\n\t\trc = LLC_PDU_LEN_I;\n\treturn rc;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":117559,"func":"TEST_F(QuicServerTransportTest, DestroyWithoutClosing) {\n  StreamId streamId = server->createBidirectionalStream().value();\n\n  MockReadCallback readCb;\n  server->setReadCallback(streamId, &readCb);\n\n  EXPECT_CALL(connCallback, onConnectionError(_)).Times(0);\n  EXPECT_CALL(connCallback, onConnectionEnd()).Times(0);\n  MockDeliveryCallback deliveryCallback;\n  auto write = IOBuf::copyBuffer(\"no\");\n  server->writeChain(streamId, write->clone(), true, &deliveryCallback);\n\n  EXPECT_CALL(deliveryCallback, onCanceled(_, _));\n  EXPECT_CALL(readCb, readError(_, _));\n\n  server.reset();\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":302550,"func":"sctp_disposition_t sctp_sf_do_ecne(struct net *net,\n\t\t\t\t   const struct sctp_endpoint *ep,\n\t\t\t\t   const struct sctp_association *asoc,\n\t\t\t\t   const sctp_subtype_t type,\n\t\t\t\t   void *arg,\n\t\t\t\t   sctp_cmd_seq_t *commands)\n{\n\tsctp_ecnehdr_t *ecne;\n\tstruct sctp_chunk *chunk = arg;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);\n\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(net, ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\tecne = (sctp_ecnehdr_t *) chunk->skb->data;\n\tskb_pull(chunk->skb, sizeof(sctp_ecnehdr_t));\n\n\t\/* If this is a newer ECNE than the last CWR packet we sent out *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_ECN_ECNE,\n\t\t\tSCTP_U32(ntohl(ecne->lowest_tsn)));\n\n\treturn SCTP_DISPOSITION_CONSUME;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":249583,"func":"scoped_refptr<const PermissionSet> PermissionsData::GetTabSpecificPermissions(\n    int tab_id) const {\n  base::AutoLock auto_lock(runtime_lock_);\n  CHECK_GE(tab_id, 0);\n  TabPermissionsMap::const_iterator iter =\n      tab_specific_permissions_.find(tab_id);\n  return (iter != tab_specific_permissions_.end()) ? iter->second : NULL;\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":250075,"func":"void TabsUpdateFunction::OnExecuteCodeFinished(\n    const std::string& error,\n    const GURL& url,\n    const base::ListValue& script_result) {\n  if (error.empty())\n    PopulateResult();\n  else\n    error_ = error;\n  SendResponse(error.empty());\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":249577,"func":"void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) {\n  ListedElement::didMoveToNewDocument(oldDocument);\n  HTMLElement::didMoveToNewDocument(oldDocument);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":219869,"func":"cc::SnapFlingController::GestureScrollUpdateInfo GetGestureScrollUpdateInfo(\n    const WebGestureEvent& event) {\n  cc::SnapFlingController::GestureScrollUpdateInfo info;\n  info.delta = gfx::Vector2dF(-event.data.scroll_update.delta_x,\n                              -event.data.scroll_update.delta_y);\n  info.is_in_inertial_phase =\n      event.data.scroll_update.inertial_phase ==\n      blink::WebGestureEvent::InertialPhaseState::kMomentum;\n  info.event_time = event.TimeStamp();\n  return info;\n}\n","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":415262,"func":"pipe_echo_finish (Pipe *pipe)\n{\n\tGIOStatus status;\n\tgsize bytes_read;\n\tchar buf[512];\n\n\tdo {\n\t\tbytes_read = 0;\n\t\tstatus = g_io_channel_read_chars (pipe->channel,\n\t\t                                  buf,\n\t\t                                  sizeof (buf),\n\t\t                                  &bytes_read,\n\t\t                                  NULL);\n\t\tif (bytes_read) {\n\t\t\tfprintf (pipe->logf, \"%.*s\", (int) bytes_read, buf);\n\t\t\tfflush (pipe->logf);\n\t\t}\n\t} while (status == G_IO_STATUS_NORMAL);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":90506,"func":"libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)\n\n{\n    int width, height, colors, bps;\n    get_mem_image_format(&width, &height, &colors, &bps);\n    int stride = width * (bps\/8) * colors;\n    unsigned ds = height * stride;\n    libraw_processed_image_t *ret = (libraw_processed_image_t*)::malloc(sizeof(libraw_processed_image_t)+ds);\n    if(!ret)\n        {\n                if(errcode) *errcode= ENOMEM;\n                return NULL;\n        }\n    memset(ret,0,sizeof(libraw_processed_image_t));\n\n    \/\/ metadata init\n    ret->type   = LIBRAW_IMAGE_BITMAP;\n    ret->height = height;\n    ret->width  = width;\n    ret->colors = colors;\n    ret->bits   = bps;\n    ret->data_size = ds;\n    copy_mem_image(ret->data, stride, 0); \n\n    return ret;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":439120,"func":"static void SFDDumpLangName(FILE *sfd, struct ttflangname *ln) {\n    int i, end;\n    fprintf( sfd, \"LangName: %d\", ln->lang );\n    for ( end = ttf_namemax; end>0 && ln->names[end-1]==NULL; --end );\n    for ( i=0; i<end; ++i ) {\n        putc(' ',sfd);\n        SFDDumpUTF7Str(sfd,ln->names[i]);\n    }\n    putc('\\n',sfd);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":87286,"func":"const char *gf_m4v_get_profile_name(u8 video_pl)\n{\n\tu32 i, count = GF_ARRAY_LENGTH(M4VProfiles);\n\tfor (i=0; i<count; i++) {\n\t\tif ((u32)video_pl == M4VProfiles[i].value)\n\t\t\treturn M4VProfiles[i].name;\n\t}\n\treturn \"ISO Reserved Profile\";\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":258704,"func":"static void hns_gmac_get_tx_auto_pause_frames(void *mac_drv, u16 *newval)\n{\n\tstruct mac_driver *drv = (struct mac_driver *)mac_drv;\n\n\t*newval = dsaf_get_dev_field(drv, GMAC_FC_TX_TIMER_REG,\n\t\t\t\t     GMAC_FC_TX_TIMER_M, GMAC_FC_TX_TIMER_S);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":232017,"func":"GDataFile::GDataFile(GDataDirectory* parent, GDataRootDirectory* root)\n    : GDataEntry(parent, root),\n      kind_(DocumentEntry::UNKNOWN),\n      is_hosted_document_(false) {\n  file_info_.is_directory = false;\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":12038,"func":"void RTCSessionDescriptionRequestImpl::requestSucceeded(PassRefPtr<RTCSessionDescriptionDescriptor> descriptor)\n {\n     if (m_successCallback) {\n         RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::create(descriptor);\n        m_successCallback->handleEvent(sessionDescription.get());\n     }\n \n     clear();\n}\n","target":1,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":21958,"func":"static int dissect_h245_INTEGER_1_9216 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 1U , 9216U , NULL , FALSE ) ;\n return offset ;\n }","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":311887,"func":"bool HTMLMediaElement::textTracksAreReady() const {\n  for (const auto& textTrack : m_textTracksWhenResourceSelectionBegan) {\n    if (textTrack->getReadinessState() == TextTrack::Loading ||\n        textTrack->getReadinessState() == TextTrack::NotLoaded)\n      return false;\n  }\n\n  return true;\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":408009,"func":"static int dvb_frontend_get_event(struct dvb_frontend *fe,\n\t\t\t    struct dvb_frontend_event *event, int flags)\n{\n\tstruct dvb_frontend_private *fepriv = fe->frontend_priv;\n\tstruct dvb_fe_events *events = &fepriv->events;\n\n\tdev_dbg(fe->dvb->device, \"%s:\\n\", __func__);\n\n\tif (events->overflow) {\n\t\tevents->overflow = 0;\n\t\treturn -EOVERFLOW;\n\t}\n\n\tif (events->eventw == events->eventr) {\n\t\tint ret;\n\n\t\tif (flags & O_NONBLOCK)\n\t\t\treturn -EWOULDBLOCK;\n\n\t\tup(&fepriv->sem);\n\n\t\tret = wait_event_interruptible (events->wait_queue,\n\t\t\t\t\t\tevents->eventw != events->eventr);\n\n\t\tif (down_interruptible (&fepriv->sem))\n\t\t\treturn -ERESTARTSYS;\n\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\n\tmutex_lock(&events->mtx);\n\t*event = events->events[events->eventr];\n\tevents->eventr = (events->eventr + 1) % MAX_EVENT;\n\tmutex_unlock(&events->mtx);\n\n\treturn 0;\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":371682,"func":"_g_utf8_strstr (const char *haystack,\n\t\tconst char *needle)\n{\n\tconst char *s;\n\tgsize       i;\n\tgsize       haystack_len = g_utf8_strlen (haystack, -1);\n\tgsize       needle_len = g_utf8_strlen (needle, -1);\n\tint         needle_size = strlen (needle);\n\n\ts = haystack;\n\tfor (i = 0; i <= haystack_len - needle_len; i++) {\n\t\tif (strncmp (s, needle, needle_size) == 0)\n\t\t\treturn s;\n\t\ts = g_utf8_next_char(s);\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":111670,"func":"TRIO_PUBLIC_STRING int trio_xstring_append_char TRIO_ARGS2((self, character), trio_string_t* self,\n                                                           char character)\n{\n\tassert(self);\n\n\tif ((int)self->length >= trio_string_size(self))\n\t{\n\t\tif (!internal_string_grow(self, 0))\n\t\t\tgoto error;\n\t}\n\tself->content[self->length] = character;\n\tself->length++;\n\treturn TRUE;\n\nerror:\n\treturn FALSE;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":416506,"func":"pdf14_open(gx_device *dev)\n{\n    pdf14_device *pdev = (pdf14_device *)dev;\n    gs_int_rect rect;\n\n    if_debug2m('v', dev->memory, \"[v]pdf14_open: width = %d, height = %d\\n\",\n               dev->width, dev->height);\n    rect.p.x = 0;\n    rect.p.y = 0;\n    rect.q.x = dev->width;\n    rect.q.y = dev->height;\n    \/* If we are reenabling the device dont create a new ctx. Bug 697456 *\/\n    if (pdev->ctx == NULL)\n        pdev->ctx = pdf14_ctx_new(&rect, dev->color_info.num_components,\n            pdev->color_info.polarity != GX_CINFO_POLARITY_SUBTRACTIVE, dev);\n    if (pdev->ctx == NULL)\n        return_error(gs_error_VMerror);\n    pdev->free_devicen = true;\n    pdev->text_group = PDF14_TEXTGROUP_NO_BT;\n    return 0;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":182686,"func":"    virtual void afterTest()\n    {\n        EXPECT_GE(2, m_numDraws);\n        EXPECT_EQ(1, m_numCommits);\n    }\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":209392,"func":"void TestingAutomationProvider::OmniboxMovePopupSelection(\n    Browser* browser,\n    DictionaryValue* args,\n    IPC::Message* reply_message) {\n  int count;\n  AutomationJSONReply reply(this, reply_message);\n  if (!args->GetInteger(\"count\", &count)) {\n    reply.SendError(\"count missing\");\n    return;\n  }\n  LocationBar* loc_bar = browser->window()->GetLocationBar();\n  AutocompleteEditModel* model = loc_bar->location_entry()->model();\n  model->OnUpOrDownKeyPressed(count);\n  reply.SendSuccess(NULL);\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":223798,"func":"bool roleAllowsSort(AccessibilityRole role) {\n  return role == ColumnHeaderRole || role == RowHeaderRole;\n}\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":115484,"func":"PHP_FUNCTION(imagesetpixel)\n{\n\tzval *IM;\n\tlong x, y, col;\n\tgdImagePtr im;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"rlll\", &IM, &x, &y, &col) == FAILURE) {\n\t\treturn;\n\t}\n\n\tZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, \"Image\", le_gd);\n\tgdImageSetPixel(im, x, y, col);\n\tRETURN_TRUE;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":45294,"func":"TEST_F(TestCustomAllocation, ResizeTensorsWithoutEnoughMemory) {\n  \/\/ Set custom allocations for all input tensors.\n  AssignCustomAllocForTensor(interpreter_->inputs()[0],\n                             \/*required_alignment=*\/kDefaultTensorAlignment);\n  AssignCustomAllocForTensor(interpreter_->inputs()[1],\n                             \/*required_alignment=*\/kDefaultTensorAlignment);\n\n  ASSERT_EQ(interpreter_->AllocateTensors(), kTfLiteOk);\n\n  \/\/ Now resize tensors to double the size.\n  ASSERT_EQ(interpreter_->ResizeInputTensor(interpreter_->inputs()[0], {2, 3}),\n            kTfLiteOk);\n  ASSERT_EQ(interpreter_->ResizeInputTensor(interpreter_->inputs()[1], {2, 3}),\n            kTfLiteOk);\n\n  \/\/ Since the custom memory previously allocated isn't enough,\n  \/\/ AllocateTensors() will fail.\n  ASSERT_EQ(interpreter_->AllocateTensors(), kTfLiteError);\n  \/\/ Interpreter should no longer be in invokable state, so expect failure.\n  ASSERT_EQ(interpreter_->Invoke(), kTfLiteError);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":481102,"func":"reset_ept_shadow_zero_bits_mask(struct kvm_mmu *context, bool execonly)\n{\n\t__reset_rsvds_bits_mask_ept(&context->shadow_zero_check,\n\t\t\t\t    reserved_hpa_bits(), execonly,\n\t\t\t\t    max_huge_page_level);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":284846,"func":"void BrowserWindowGtk::ConnectAccelerators() {\n  accel_group_ = gtk_accel_group_new();\n  gtk_window_add_accel_group(window_, accel_group_);\n\n  AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance();\n  for (AcceleratorsGtk::const_iterator iter = accelerators->begin();\n       iter != accelerators->end(); ++iter) {\n    gtk_accel_group_connect(\n        accel_group_,\n        iter->second.GetGdkKeyCode(),\n        static_cast<GdkModifierType>(iter->second.modifiers()),\n        GtkAccelFlags(0),\n        g_cclosure_new(G_CALLBACK(OnGtkAccelerator),\n                       GINT_TO_POINTER(iter->first), NULL));\n  }\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":414987,"func":"void SoundTouch::setPitch(double newPitch)\r\n{\r\n    virtualPitch = newPitch;\r\n    calcEffectiveRateAndTempo();\r\n}\r","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":292812,"func":"    \/\/! Save image as a BMP file \\overloading.\n    const CImg<T>& save_bmp(std::FILE *const file) const {\n      return _save_bmp(file,0);","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":316096,"func":"void InitXKeyEventForTesting(EventType type,\n                             KeyboardCode key_code,\n                             int flags,\n                             XEvent* event) {\n  CHECK(event);\n  Display* display = GetXDisplay();\n  XKeyEvent key_event;\n  key_event.type = XKeyEventType(type);\n  CHECK_NE(0, key_event.type);\n  key_event.serial = 0;\n  key_event.send_event = 0;\n  key_event.display = display;\n  key_event.time = 0;\n  key_event.window = 0;\n  key_event.root = 0;\n  key_event.subwindow = 0;\n  key_event.x = 0;\n  key_event.y = 0;\n  key_event.x_root = 0;\n  key_event.y_root = 0;\n  key_event.state = XKeyEventState(flags);\n  key_event.keycode = XKeyEventKeyCode(key_code, flags, display);\n  key_event.same_screen = 1;\n  event->type = key_event.type;\n  event->xkey = key_event;\n}\n","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":499085,"func":"static void analPathFollow(RzCoreAnalPaths *p, ut64 addr, PJ *pj) {\n\tif (addr == UT64_MAX) {\n\t\treturn;\n\t}\n\tbool found;\n\tht_uu_find(p->visited, addr, &found);\n\tif (!found) {\n\t\tp->cur = rz_analysis_find_most_relevant_block_in(p->core->analysis, addr);\n\t\tanalPaths(p, pj);\n\t}\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":219683,"func":"PHP_FUNCTION(pg_transaction_status)\n{\n\tzval *pgsql_link = NULL;\n\tint id = -1;\n\tPGconn *pgsql;\n\n\tif (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), \"r\",\n\t\t\t\t\t\t\t\t &pgsql_link) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, \"PostgreSQL link\", le_link, le_plink);\n\n\tRETURN_LONG(PQtransactionStatus(pgsql));\n}\n","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":414090,"func":"psg_json_value_set_str_ne(PsgJsonValue *doc, const char *name,\n    const char *val, size_t size)\n{\n    if (size > 0) {\n        return psg_json_value_set_str(doc, name, val, size);\n    } else {\n        return NULL;\n    }\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":387255,"func":"static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb)\n{\n\tif (skb->len < 1)\n\t\treturn -1;\n\n\tif (skb->data[0] == 0xff) {\n\t\tif (skb->len < 2)\n\t\t\treturn -1;\n\n\t\tif (skb->data[1] != 0x03)\n\t\t\treturn -1;\n\n\t\t\/\/ skip address\/control (AC) field\n\t\tskb_pull(skb, 2);\n\t} else {\n\t\tif (is->pppcfg & SC_REJ_COMP_AC)\n\t\t\t\/\/ if AC compression was not negotiated, but used, discard packet\n\t\t\treturn -1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":143357,"func":"static Jsi_RC eventInfoCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n    Jsi_Value **ret, Jsi_Func *funcPtr)\n{\n    return InfoEventCmd(interp, args, _this, ret, funcPtr);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":147938,"func":"static char *print_string(cJSON *item,printbuffer *p)\t{return print_string_ptr(item->valuestring,p);}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":423006,"func":"static inline u64 ioat_chansts_32(struct ioat_chan_common *chan)\n{\n\tu8 ver = chan->device->version;\n\tu64 status;\n\tu32 status_lo;\n\n\t\/* We need to read the low address first as this causes the\n\t * chipset to latch the upper bits for the subsequent read\n\t *\/\n\tstatus_lo = readl(chan->reg_base + IOAT_CHANSTS_OFFSET_LOW(ver));\n\tstatus = readl(chan->reg_base + IOAT_CHANSTS_OFFSET_HIGH(ver));\n\tstatus <<= 32;\n\tstatus |= status_lo;\n\n\treturn status;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":58787,"func":"smb2_echo_callback(struct mid_q_entry *mid)\n{\n\tstruct TCP_Server_Info *server = mid->callback_data;\n\tstruct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf;\n\tstruct cifs_credits credits = { .value = 0, .instance = 0 };\n\n\tif (mid->mid_state == MID_RESPONSE_RECEIVED\n\t    || mid->mid_state == MID_RESPONSE_MALFORMED) {\n\t\tcredits.value = le16_to_cpu(rsp->sync_hdr.CreditRequest);\n\t\tcredits.instance = server->reconnect_instance;\n\t}\n\n\tDeleteMidQEntry(mid);\n\tadd_credits(server, &credits, CIFS_ECHO_OP);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":225258,"func":"void VideoRendererBase::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {\n  base::AutoLock auto_lock(lock_);\n  DCHECK_EQ(state_, kFlushed) << \"Must flush prior to seeking.\";\n  DCHECK(!cb.is_null());\n  DCHECK(seek_cb_.is_null());\n\n  state_ = kSeeking;\n  seek_cb_ = cb;\n  seek_timestamp_ = time;\n  AttemptRead_Locked();\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":516392,"func":"MaybeLocal<Value> GetIssuerString(\n    Environment* env,\n    const BIOPointer& bio,\n    X509* cert) {\n  X509_NAME* issuer_name = X509_get_issuer_name(cert);\n  if (X509_NAME_print_ex(bio.get(), issuer_name, 0, X509_NAME_FLAGS) <= 0) {\n    USE(BIO_reset(bio.get()));\n    return Undefined(env->isolate());\n  }\n\n  return ToV8Value(env, bio);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":416178,"func":"oparray_cleanup(i_ctx_t *i_ctx_p)\n{                               \/* esp points just below the cleanup procedure. *\/\n    es_ptr ep = esp;\n    uint ocount_old = (uint) ep[3].value.intval;\n    uint dcount_old = (uint) ep[4].value.intval;\n    uint ocount = ref_stack_count(&o_stack);\n    uint dcount = ref_stack_count(&d_stack);\n\n    if (ocount > ocount_old)\n        ref_stack_pop(&o_stack, ocount - ocount_old);\n    if (dcount > dcount_old) {\n        ref_stack_pop(&d_stack, dcount - dcount_old);\n        dict_set_top();\n    }\n    return 0;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":15133,"func":"TEST_F ( WebFrameSimTest , FindInPageSelectNextMatch ) {\n WebView ( ) . Resize ( WebSize ( 500 , 300 ) ) ;\n WebView ( ) . GetPage ( ) -> GetSettings ( ) . SetTextAutosizingEnabled ( false ) ;\n SimRequest request ( \"https:\/\/example.com\/test.html\" , \"text\/html\" ) ;\n LoadURL ( \"https:\/\/example.com\/test.html\" ) ;\n request . Complete ( R \"HTML( < ! DOCTYPE html > < style > body , html {\n width : 4000px ;\n height : 4000px ;\n margin : 0 ;\n }\n # box1 {\n position : absolute ;\n left : 800px ;\n top : 2000px ;\n }\n # box2 {\n position : absolute ;\n left : 1000px ;\n top : 3000px ;\n }","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":178853,"func":"  GLES2DecoderWithShaderTest()\n       : GLES2DecoderWithShaderTestBase() {\n   }\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":202422,"func":"static int create_system_filter(struct trace_subsystem_dir *dir,\n\t\t\t\tstruct trace_array *tr,\n\t\t\t\tchar *filter_str, struct event_filter **filterp)\n{\n\tstruct filter_parse_error *pe = NULL;\n\tint err;\n\n\terr = create_filter_start(filter_str, true, &pe, filterp);\n\tif (!err) {\n\t\terr = process_system_preds(dir, tr, pe, filter_str);\n\t\tif (!err) {\n\t\t\t\/* System filters just show a default message *\/\n\t\t\tkfree((*filterp)->filter_string);\n\t\t\t(*filterp)->filter_string = NULL;\n\t\t} else {\n\t\t\tappend_filter_err(pe, *filterp);\n\t\t}\n\t}\n\tcreate_filter_finish(pe);\n\n\treturn err;\n}\n","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":441816,"func":"static int post_copy_siginfo_from_user(kernel_siginfo_t *info,\n\t\t\t\t       const siginfo_t __user *from)\n{\n\tif (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) {\n\t\tchar __user *expansion = si_expansion(from);\n\t\tchar buf[SI_EXPANSION_SIZE];\n\t\tint i;\n\t\t\/*\n\t\t * An unknown si_code might need more than\n\t\t * sizeof(struct kernel_siginfo) bytes.  Verify all of the\n\t\t * extra bytes are 0.  This guarantees copy_siginfo_to_user\n\t\t * will return this data to userspace exactly.\n\t\t *\/\n\t\tif (copy_from_user(&buf, expansion, SI_EXPANSION_SIZE))\n\t\t\treturn -EFAULT;\n\t\tfor (i = 0; i < SI_EXPANSION_SIZE; i++) {\n\t\t\tif (buf[i] != 0)\n\t\t\t\treturn -E2BIG;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":249558,"func":"void DiscardableSharedMemoryManager::SetMemoryLimit(size_t limit) {\n  base::AutoLock lock(lock_);\n\n  memory_limit_ = limit;\n  ReduceMemoryUsageUntilWithinMemoryLimit();\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":309936,"func":"void FolderHeaderView::SetFolderItem(AppListFolderItem* folder_item) {\n  if (folder_item_)\n    folder_item_->RemoveObserver(this);\n\n  folder_item_ = folder_item;\n  if (!folder_item_)\n     return;\n   folder_item_->AddObserver(this);\n \n  folder_name_view_->SetEnabled(folder_item_->folder_type() !=\n                                 AppListFolderItem::FOLDER_TYPE_OEM);\n\n   Update();\n }\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":317343,"func":"png_crc_error(png_structp png_ptr)\n{\n   png_byte crc_bytes[4];\n   png_uint_32 crc;\n   int need_crc = 1;\n\n   if (png_ptr->chunk_name[0] & 0x20)                     \/* ancillary *\/\n   {\n      if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==\n          (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))\n         need_crc = 0;\n   }\n   else                                                    \/* critical *\/\n   {\n      if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)\n         need_crc = 0;\n   }\n\n   png_read_data(png_ptr, crc_bytes, 4);\n\n   if (need_crc)\n   {\n      crc = png_get_uint_32(crc_bytes);\n      return ((int)(crc != png_ptr->crc));\n   }\n   else\n      return (0);\n}\n","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":197754,"func":"MATCHER_P(Message, type, \"\") {\n  return arg.type() == static_cast<uint32>(type);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":388434,"func":"static bool encode_flag_request(void *mem_ctx, void *in, DATA_BLOB *out)\n{\n\tif (in) {\n\t\treturn false;\n\t}\n\n\t*out = data_blob(NULL, 0);\n\treturn true;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":132101,"func":"  void visit(CaptureScope &ope) override {\n    ope.ope_->accept(*this);\n    found_ope = csc(found_ope);\n  }","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":482180,"func":"ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) {\n  \/\/ For the case of <array>.clone(), the method holder can be a ciArrayKlass\n  \/\/ instead of a ciInstanceKlass.  For that case simply pretend that the\n  \/\/ declared holder is Object.clone since that's where the call will bottom out.\n  \/\/ A more correct fix would trickle out through many interfaces in CI,\n  \/\/ requiring ciInstanceKlass* to become ciKlass* and many more places would\n  \/\/ require checks to make sure the expected type was found.  Given that this\n  \/\/ only occurs for clone() the more extensive fix seems like overkill so\n  \/\/ instead we simply smear the array type into Object.\n  guarantee(method_holder != NULL, \"no method holder\");\n  if (method_holder->is_instance_klass()) {\n    return method_holder->as_instance_klass();\n  } else if (method_holder->is_array_klass()) {\n    return current()->Object_klass();\n  } else {\n    ShouldNotReachHere();\n  }\n  return NULL;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":97166,"func":"static void xen_free_ldt(struct desc_struct *ldt, unsigned entries)\n{\n\tconst unsigned entries_per_page = PAGE_SIZE \/ LDT_ENTRY_SIZE;\n\tint i;\n\n\tfor (i = 0; i < entries; i += entries_per_page)\n\t\tset_aliased_prot(ldt + i, PAGE_KERNEL);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":472996,"func":"datetime_to_date(VALUE self)\n{\n    get_d1a(self);\n\n    if (simple_dat_p(adat)) {\n\tVALUE new = d_lite_s_alloc_simple(cDate);\n\t{\n\t    get_d1b(new);\n\t    bdat->s = adat->s;\n\t    bdat->s.jd = m_local_jd(adat);\n\t    return new;\n\t}\n    }\n    else {\n\tVALUE new = d_lite_s_alloc_simple(cDate);\n\t{\n\t    get_d1b(new);\n\t    copy_complex_to_simple(new, &bdat->s, &adat->c);\n\t    bdat->s.jd = m_local_jd(adat);\n\t    bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT);\n\t    return new;\n\t}\n    }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":100404,"func":"static void clear_ftrace_pid_task(struct pid *pid)\n{\n\tif (pid == ftrace_swapper_pid)\n\t\tclear_ftrace_swapper();\n\telse\n\t\tclear_ftrace_pid(pid);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":226643,"func":"CurrentHistoryCleaner::~CurrentHistoryCleaner() {\n}\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":6114,"func":"static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) {\n\t\/\/ Skip whitespace\n\twhile (begin && isspace ((ut8)str[*begin])) {\n\t\t++(*begin);\n\t}\n\n\tif (!str[*begin]) {                \/\/ null byte\n\t\t*end = *begin;\n\t\treturn TT_EOF;\n\t} else if (isalpha ((ut8)str[*begin])) {   \/\/ word token\n\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) {\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_WORD;\n\t} else if (isdigit ((ut8)str[*begin])) {   \/\/ number token\n\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) {     \/\/ accept alphanumeric characters, because hex.\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_NUMBER;\n\t} else {                             \/\/ special character: [, ], +, *, ...\n\t\t*end = *begin + 1;\n\t\treturn TT_SPECIAL;\n\t}\n}","target":1,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":483692,"func":"void pm_qos_sysfs_remove_flags(struct device *dev)\n{\n\tsysfs_unmerge_group(&dev->kobj, &pm_qos_flags_attr_group);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":389335,"func":"static XMLRPC_VECTOR_TYPE determine_vector_type (HashTable *ht)\n{\n\tint bArray = 0, bStruct = 0, bMixed = 0;\n\tzend_ulong num_index, last_num = 0;\n\tzend_string* my_key;\n\n\tZEND_HASH_FOREACH_KEY(ht, num_index, my_key) {\n\t\tif (my_key == NULL) {\n\t\t\tif (bStruct) {\n\t\t\t\tbMixed = 1;\n\t\t\t\tbreak;\n\t\t\t} else if (last_num > 0 && last_num != num_index-1) {\n\t\t\t\tbStruct = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbArray = 1;\n\t\t\tlast_num = num_index;\n\t\t} else {\n\t\t\tif (bArray) {\n\t\t\t\tbMixed = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbStruct = 1;\n\t\t}\n\t} ZEND_HASH_FOREACH_END();\n\treturn bMixed ? xmlrpc_vector_mixed : (bStruct ? xmlrpc_vector_struct : xmlrpc_vector_array);\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":121886,"func":"Magick::EndianType Magick::Image::endian(void) const\n{\n  return(constImage()->endian);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":230366,"func":"PrintingContext::Result PrintingContextCairo::NewPage() {\n  if (abort_printing_)\n    return CANCEL;\n  DCHECK(in_print_job_);\n\n\n  return OK;\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":138065,"func":"int get_user_pages_fast(unsigned long start, int nr_pages, int write,\n\t\t\tstruct page **pages)\n{\n\tunsigned long addr, len, end;\n\tint nr = 0, ret = 0;\n\n\tstart &= PAGE_MASK;\n\taddr = start;\n\tlen = (unsigned long) nr_pages << PAGE_SHIFT;\n\tend = start + len;\n\n\tif (nr_pages <= 0)\n\t\treturn 0;\n\n\tif (unlikely(!access_ok((void __user *)start, len)))\n\t\treturn -EFAULT;\n\n\tif (gup_fast_permitted(start, nr_pages, write)) {\n\t\tlocal_irq_disable();\n\t\tgup_pgd_range(addr, end, write, pages, &nr);\n\t\tlocal_irq_enable();\n\t\tret = nr;\n\t}\n\n\tif (nr < nr_pages) {\n\t\t\/* Try to get the remaining pages with get_user_pages *\/\n\t\tstart += nr << PAGE_SHIFT;\n\t\tpages += nr;\n\n\t\tret = get_user_pages_unlocked(start, nr_pages - nr, pages,\n\t\t\t\twrite ? FOLL_WRITE : 0);\n\n\t\t\/* Have to be a bit careful with return values *\/\n\t\tif (nr > 0) {\n\t\t\tif (ret < 0)\n\t\t\t\tret = nr;\n\t\t\telse\n\t\t\t\tret += nr;\n\t\t}\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":48741,"func":"int config_error_nonbool(const char *var)\n{\n\treturn error(\"Missing value for '%s'\", var);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":385685,"func":"ftp_rename(ftpbuf_t *ftp, const char *src, const char *dest)\n{\n\tif (ftp == NULL) {\n\t\treturn 0;\n\t}\n\tif (!ftp_putcmd(ftp, \"RNFR\", src)) {\n\t\treturn 0;\n\t}\n\tif (!ftp_getresp(ftp) || ftp->resp != 350) {\n\t\treturn 0;\n\t}\n\tif (!ftp_putcmd(ftp, \"RNTO\", dest)) {\n\t\treturn 0;\n\t}\n\tif (!ftp_getresp(ftp) || ftp->resp != 250) {\n\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":257456,"func":"virLogPriority virLogGetDefaultPriority ( void ) {\n return virLogDefaultPriority ;\n }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":49916,"func":"search_param(char *name)\n{\n    size_t b, e, i;\n    int cmp;\n    int len = strlen(name);\n\n    for (b = 0, e = RC_table_size - 1; b <= e;) {\n\ti = (b + e) \/ 2;\n\tcmp = strncmp(name, RC_search_table[i].param->name, len);\n\n\tif (!cmp) {\n\t    if (len >= RC_search_table[i].uniq_pos) {\n\t\treturn RC_search_table[i].param;\n\t    }\n\t    else {\n\t\twhile ((cmp =\n\t\t\tstrcmp(name, RC_search_table[i].param->name)) <= 0)\n\t\t    if (!cmp)\n\t\t\treturn RC_search_table[i].param;\n\t\t    else if (i == 0)\n\t\t\treturn NULL;\n\t\t    else\n\t\t\ti--;\n\t\t\/* ambiguous *\/\n\t\treturn NULL;\n\t    }\n\t}\n\telse if (cmp < 0) {\n\t    if (i == 0)\n\t\treturn NULL;\n\t    e = i - 1;\n\t}\n\telse\n\t    b = i + 1;\n    }\n    return NULL;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":206032,"func":"void GDataFileSystem::TransferFileForResourceId(\n    const FilePath& local_file_path,\n    const FilePath& remote_dest_file_path,\n    const FileOperationCallback& callback,\n    std::string* resource_id) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n  DCHECK(resource_id);\n  DCHECK(!callback.is_null());\n\n  if (resource_id->empty()) {\n    TransferRegularFile(local_file_path, remote_dest_file_path, callback);\n    return;\n  }\n\n  CopyDocumentToDirectory(\n      remote_dest_file_path.DirName(),\n      *resource_id,\n      remote_dest_file_path.BaseName().RemoveExtension().value(),\n      callback);\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":357146,"func":"struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)\n{\n\tstruct scm_fp_list *new_fpl;\n\tint i;\n\n\tif (!fpl)\n\t\treturn NULL;\n\n\tnew_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL);\n\tif (new_fpl) {\n\t\tINIT_LIST_HEAD(&new_fpl->list);\n\t\tfor (i=fpl->count-1; i>=0; i--)\n\t\t\tget_file(fpl->fp[i]);\n\t\tmemcpy(new_fpl, fpl, sizeof(*fpl));\n\t}\n\treturn new_fpl;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":159323,"func":"static void testUmask077(CuTest *tc) {\n    testUmask(tc, 0077, 0600);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":338605,"func":"const char *avutil_configuration(void)\n\n{\n\n    return FFMPEG_CONFIGURATION;\n\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":472156,"func":"STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp)\n{\n   unsigned char *result;\n   stbi__context s;\n   stbi__start_mem(&s,buffer,len);\n\n   result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp);\n   if (stbi__vertically_flip_on_load) {\n      stbi__vertical_flip_slices( result, *x, *y, *z, *comp );\n   }\n\n   return result;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":213268,"func":"MagickExport void GetQuantizeInfo(QuantizeInfo *quantize_info)\n{\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"...\");\n  assert(quantize_info != (QuantizeInfo *) NULL);\n  (void) ResetMagickMemory(quantize_info,0,sizeof(*quantize_info));\n  quantize_info->number_colors=256;\n  quantize_info->dither=MagickTrue;\n  quantize_info->dither_method=RiemersmaDitherMethod;\n  quantize_info->colorspace=UndefinedColorspace;\n  quantize_info->measure_error=MagickFalse;\n  quantize_info->signature=MagickSignature;\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":54671,"func":"void rpc_put_task(struct rpc_task *task)\n{\n\trpc_do_put_task(task, NULL);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":499541,"func":"const char *RtmpProtocol::onSearchPacketTail(const char *data,size_t len){\n    \/\/\u79fb\u52a8\u62f7\u8d1d\u63d0\u9ad8\u6027\u80fd\n    auto next_step_func(std::move(_next_step_func));\n    \/\/\u6267\u884c\u4e0b\u4e00\u6b65\n    auto ret = next_step_func(data, len);\n    if (!_next_step_func) {\n        \/\/\u4e3a\u8bbe\u7f6e\u4e0b\u4e00\u6b65\uff0c\u6062\u590d\u4e4b\n        next_step_func.swap(_next_step_func);\n    }\n    return ret;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":15765,"func":"PyObject * PyString_AsDecodedString ( PyObject * str , const char * encoding , const char * errors ) {\n PyObject * v ;\n v = PyString_AsDecodedObject ( str , encoding , errors ) ;\n if ( v == NULL ) goto onError ;\n # ifdef Py_USING_UNICODE if ( PyUnicode_Check ( v ) ) {\n PyObject * temp = v ;\n v = PyUnicode_AsEncodedString ( v , NULL , NULL ) ;\n Py_DECREF ( temp ) ;\n if ( v == NULL ) goto onError ;\n }\n # endif if ( ! PyString_Check ( v ) ) {\n PyErr_Format ( PyExc_TypeError , \"decoder did not return a string object (type=%.400s)\" , Py_TYPE ( v ) -> tp_name ) ;\n Py_DECREF ( v ) ;\n goto onError ;\n }\n return v ;\n onError : return NULL ;\n }","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":177865,"func":"int PreProcessingLib_GetDescriptor(const effect_uuid_t *uuid,\n effect_descriptor_t *pDescriptor) {\n\n if (pDescriptor == NULL || uuid == NULL){\n return -EINVAL;\n }\n\n const effect_descriptor_t *desc = PreProc_GetDescriptor(uuid);\n if (desc == NULL) {\n        ALOGV(\"PreProcessingLib_GetDescriptor() not found\");\n return -EINVAL;\n }\n\n    ALOGV(\"PreProcessingLib_GetDescriptor() got fx %s\", desc->name);\n\n *pDescriptor = *desc;\n return 0;\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":306914,"func":"PasswordStoreLoginsChangedObserver::PasswordStoreLoginsChangedObserver(\n    AutomationProvider* automation,\n    IPC::Message* reply_message,\n    PasswordStoreChange::Type expected_type,\n    const std::string& result_key)\n    : automation_(automation->AsWeakPtr()),\n      reply_message_(reply_message),\n      expected_type_(expected_type),\n      result_key_(result_key),\n      done_event_(false, false) {\n  AddRef();\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":38459,"func":"static struct sk_filter *__sk_migrate_realloc(struct sk_filter *fp,\n\t\t\t\t\t      struct sock *sk,\n\t\t\t\t\t      unsigned int len)\n{\n\tstruct sk_filter *fp_new;\n\n\tif (sk == NULL)\n\t\treturn krealloc(fp, len, GFP_KERNEL);\n\n\tfp_new = sock_kmalloc(sk, len, GFP_KERNEL);\n\tif (fp_new) {\n\t\tmemcpy(fp_new, fp, sizeof(struct sk_filter));\n\t\t\/* As we're kepping orig_prog in fp_new along,\n\t\t * we need to make sure we're not evicting it\n\t\t * from the old fp.\n\t\t *\/\n\t\tfp->orig_prog = NULL;\n\t\tsk_filter_uncharge(sk, fp);\n\t}\n\n\treturn fp_new;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":242892,"func":"static req_table_t* req_subprocess_env(request_rec *r)\n{\n  req_table_t* t = apr_palloc(r->pool, sizeof(req_table_t));\n  t->r = r;\n  t->t = r->subprocess_env;\n  t->n = \"subprocess_env\";\n  return t;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":489360,"func":"GF_Err def_parent_full_box_dump(GF_Box *a, FILE *trace)\n{\n\tchar *name = \"GenericFullBox\";\n\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_MVCI:\n\t\tname = \"MultiviewInformationBox\";\n\t\tbreak;\n\t}\n\n\tgf_isom_box_dump_start(a, name, trace);\n\tgf_fprintf(trace, \">\\n\");\n\tgf_isom_box_dump_done(name, a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":419808,"func":"static int setup_raw_socket(RemoteServer *s, const char *address) {\n        int fd;\n\n        fd = make_socket_fd(LOG_INFO, address, SOCK_STREAM, SOCK_CLOEXEC);\n        if (fd < 0)\n                return fd;\n\n        return journal_remote_add_raw_socket(s, fd);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":72058,"func":"service_info *FindServiceControlURLPath(\n\tservice_table *table, const char *controlURLPath)\n{\n\tservice_info *finger = NULL;\n\turi_type parsed_url;\n\turi_type parsed_url_in;\n\n\tif (!table || !controlURLPath) {\n\t\treturn NULL;\n\t}\n\tif (parse_uri(controlURLPath, strlen(controlURLPath), &parsed_url_in) ==\n\t\tHTTP_SUCCESS) {\n\t\tfinger = table->serviceList;\n\t\twhile (finger) {\n\t\t\tif (finger->controlURL) {\n\t\t\t\tif (parse_uri(finger->controlURL,\n\t\t\t\t\t    strlen(finger->controlURL),\n\t\t\t\t\t    &parsed_url) == HTTP_SUCCESS) {\n\t\t\t\t\tif (!token_cmp(&parsed_url.pathquery,\n\t\t\t\t\t\t    &parsed_url_in.pathquery)) {\n\t\t\t\t\t\treturn finger;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinger = finger->next;\n\t\t}\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":249740,"func":"void WebContentsImpl::OnUpdateZoomLimits(RenderViewHostImpl* source,\n                                         int minimum_percent,\n                                         int maximum_percent) {\n  minimum_zoom_percent_ = minimum_percent;\n  maximum_zoom_percent_ = maximum_percent;\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":215931,"func":"xmlBufDetach(xmlBufPtr buf) {\n    xmlChar *ret;\n\n    if (buf == NULL)\n        return(NULL);\n    if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)\n        return(NULL);\n    if (buf->buffer != NULL)\n        return(NULL);\n    if (buf->error)\n        return(NULL);\n\n    ret = buf->content;\n    buf->content = NULL;\n    buf->size = 0;\n    buf->use = 0;\n    buf->compat_use = 0;\n    buf->compat_size = 0;\n\n    return ret;\n}\n","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":132972,"func":"static void FVSelectColor(FontView *fv, uint32 col, int merge) {\n    int i, doit;\n    uint32 sccol;\n    SplineChar **glyphs = fv->b.sf->glyphs;\n\n    for ( i=0; i<fv->b.map->enccount; ++i ) {\n\tint gid = fv->b.map->map[i];\n\tsccol =  ( gid==-1 || glyphs[gid]==NULL ) ? COLOR_DEFAULT : glyphs[gid]->color;\n\tdoit = sccol==col;\n\tfv->b.selected[i] = mergefunc[ merge + (fv->b.selected[i]?2:0) + doit ];\n    }\n    GDrawRequestExpose(fv->v,NULL,false);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":153426,"func":"filter_result_disconnect(uint64_t reqid, const char *message)\n{\n\tm_create(p_pony, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);\n\tm_add_id(p_pony, reqid);\n\tm_add_int(p_pony, FILTER_DISCONNECT);\n\tm_add_string(p_pony, message);\n\tm_close(p_pony);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":120802,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  \/\/ Just copy input to output.\n  const TfLiteTensor* input;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInput, &input));\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n  const TfLiteTensor* axis;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kAxis, &axis));\n  if (IsDynamicTensor(output)) {\n    int axis_value;\n    TF_LITE_ENSURE_OK(context,\n                      GetAxisValueFromTensor(context, *axis, &axis_value));\n    TF_LITE_ENSURE_OK(context,\n                      ExpandTensorDim(context, *input, axis_value, output));\n  }\n  if (output->type == kTfLiteString) {\n    TfLiteTensorRealloc(input->bytes, output);\n  }\n  memcpy(output->data.raw, input->data.raw, input->bytes);\n  return kTfLiteOk;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":481345,"func":"findCharacterClass(const CharsString *name, const TranslationTableHeader *table) {\n\t\/* Find a character class, whether predefined or user-defined *\/\n\tconst CharacterClass *class = table->characterClasses;\n\twhile (class) {\n\t\tif ((name->length == class->length) &&\n\t\t\t\t(memcmp(&name->chars[0], class->name, CHARSIZE * name->length) == 0))\n\t\t\treturn class;\n\t\tclass = class->next;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":286230,"func":"void AudioFlinger::EffectChain::process_l()\n{\n    sp<ThreadBase> thread = mThread.promote();\n if (thread == 0) {\n        ALOGW(\"process_l(): cannot promote mixer thread\");\n return;\n }\n bool isGlobalSession = (mSessionId == AUDIO_SESSION_OUTPUT_MIX) ||\n (mSessionId == AUDIO_SESSION_OUTPUT_STAGE);\n bool doProcess = (thread->type() != ThreadBase::OFFLOAD);\n if (!isGlobalSession) {\n bool tracksOnSession = (trackCnt() != 0);\n\n if (!tracksOnSession && mTailBufferCount == 0) {\n            doProcess = false;\n }\n\n if (activeTrackCnt() == 0) {\n if (tracksOnSession || mTailBufferCount > 0) {\n                clearInputBuffer_l(thread);\n if (mTailBufferCount > 0) {\n                    mTailBufferCount--;\n }\n }\n }\n }\n\n size_t size = mEffects.size();\n if (doProcess) {\n for (size_t i = 0; i < size; i++) {\n            mEffects[i]->process();\n }\n }\n for (size_t i = 0; i < size; i++) {\n        mEffects[i]->updateState();\n }\n}\n","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":67884,"func":"int64 KaxInternalBlock::GetFrameSize(size_t FrameNumber)\n{\n  int64 _Result = -1;\n\n  if (\/*bValueIsSet &&*\/ FrameNumber < SizeList.size()) {\n    _Result = SizeList[FrameNumber];\n  }\n\n  return _Result;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":270125,"func":"static void crypto_exit_shash_ops_compat(struct crypto_tfm *tfm)\n{\n\tstruct shash_desc **descp = crypto_tfm_ctx(tfm);\n\tstruct shash_desc *desc = *descp;\n\n\tcrypto_free_shash(desc->tfm);\n\tkzfree(desc);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":322327,"func":"static void text_console_resize(QemuConsole *s)\n\n{\n\n    TextCell *cells, *c, *c1;\n\n    int w1, x, y, last_width;\n\n\n\n    last_width = s->width;\n\n    s->width = surface_width(s->surface) \/ FONT_WIDTH;\n\n    s->height = surface_height(s->surface) \/ FONT_HEIGHT;\n\n\n\n    w1 = last_width;\n\n    if (s->width < w1)\n\n        w1 = s->width;\n\n\n\n    cells = g_malloc(s->width * s->total_height * sizeof(TextCell));\n\n    for(y = 0; y < s->total_height; y++) {\n\n        c = &cells[y * s->width];\n\n        if (w1 > 0) {\n\n            c1 = &s->cells[y * last_width];\n\n            for(x = 0; x < w1; x++) {\n\n                *c++ = *c1++;\n\n            }\n\n        }\n\n        for(x = w1; x < s->width; x++) {\n\n            c->ch = ' ';\n\n            c->t_attrib = s->t_attrib_default;\n\n            c++;\n\n        }\n\n    }\n\n    g_free(s->cells);\n\n    s->cells = cells;\n\n}\n","target":1,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":520707,"func":"  virtual bool with_subquery() const\n  {\n    return (*ref)->with_subquery();\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":470671,"func":"static struct htab_elem *prealloc_lru_pop(struct bpf_htab *htab, void *key,\n\t\t\t\t\t  u32 hash)\n{\n\tstruct bpf_lru_node *node = bpf_lru_pop_free(&htab->lru, hash);\n\tstruct htab_elem *l;\n\n\tif (node) {\n\t\tl = container_of(node, struct htab_elem, lru_node);\n\t\tmemcpy(l->key, key, htab->map.key_size);\n\t\treturn l;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":473343,"func":"static void bpf_prog_put_deferred(struct work_struct *work)\n{\n\tstruct bpf_prog_aux *aux;\n\tstruct bpf_prog *prog;\n\n\taux = container_of(work, struct bpf_prog_aux, work);\n\tprog = aux->prog;\n\tperf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0);\n\tbpf_audit_prog(prog, BPF_AUDIT_UNLOAD);\n\t__bpf_prog_put_noref(prog, true);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":32740,"func":"max3421_set_speed(struct usb_hcd *hcd, struct usb_device *dev)\n{\n\tstruct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd);\n\tu8 mode_lowspeed, mode_hubpre, mode = max3421_hcd->mode;\n\n\tmode_lowspeed = BIT(MAX3421_MODE_LOWSPEED_BIT);\n\tmode_hubpre   = BIT(MAX3421_MODE_HUBPRE_BIT);\n\tif (max3421_hcd->port_status & USB_PORT_STAT_LOW_SPEED) {\n\t\tmode |=  mode_lowspeed;\n\t\tmode &= ~mode_hubpre;\n\t} else if (dev->speed == USB_SPEED_LOW) {\n\t\tmode |= mode_lowspeed | mode_hubpre;\n\t} else {\n\t\tmode &= ~(mode_lowspeed | mode_hubpre);\n\t}\n\tif (mode != max3421_hcd->mode) {\n\t\tmax3421_hcd->mode = mode;\n\t\tspi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode);\n\t}\n\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":474820,"func":"static void __exit af_unix_exit(void)\n{\n\tsock_unregister(PF_UNIX);\n\tproto_unregister(&unix_dgram_proto);\n\tproto_unregister(&unix_stream_proto);\n\tunregister_pernet_subsys(&unix_net_ops);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":35823,"func":"int main(int argc, const char **argv)\n{\n    DCRaw *d = new DCRaw;\n    return d->main(argc, argv);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":376161,"func":"static int nf_ct_net_init(struct net *net)\n{\n\tnet->nf_frag.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;\n\tnet->nf_frag.frags.low_thresh = IPV6_FRAG_LOW_THRESH;\n\tnet->nf_frag.frags.timeout = IPV6_FRAG_TIMEOUT;\n\tinet_frags_init_net(&net->nf_frag.frags);\n\n\treturn nf_ct_frag6_sysctl_register(net);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":174955,"func":"bool ExtensionPrefs::IsOrphanedExtensionAcknowledged(\n    const std::string& extension_id) {\n  return ReadExtensionPrefBoolean(extension_id, kPrefOrphanAcknowledged);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":208234,"func":"void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,\n                    unsigned int len, unsigned int idx)\n{\n    unsigned int offset;\n    int i;\n\n    trace_virtqueue_fill(vq, elem, len, idx);\n\n    offset = 0;\n    for (i = 0; i < elem->in_num; i++) {\n        size_t size = MIN(len - offset, elem->in_sg[i].iov_len);\n\n        cpu_physical_memory_unmap(elem->in_sg[i].iov_base,\n                                  elem->in_sg[i].iov_len,\n                                  1, size);\n\n        offset += size;\n    }\n\n    for (i = 0; i < elem->out_num; i++)\n        cpu_physical_memory_unmap(elem->out_sg[i].iov_base,\n                                  elem->out_sg[i].iov_len,\n                                  0, elem->out_sg[i].iov_len);\n\n    idx = (idx + vring_used_idx(vq)) % vq->vring.num;\n\n    \/* Get a pointer to the next entry in the used ring. *\/\n    vring_used_ring_id(vq, idx, elem->index);\n    vring_used_ring_len(vq, idx, len);\n}\n","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":510426,"func":"void Item_name_const::print(String *str, enum_query_type query_type)\n{\n  str->append(STRING_WITH_LEN(\"NAME_CONST(\"));\n  name_item->print(str, query_type);\n  str->append(',');\n  value_item->print(str, query_type);\n  str->append(')');\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":113956,"func":"  void AddToFusedNodes(const string& name) { fused_nodes_.insert(name); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":148849,"func":"f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    if (rettv_list_alloc(rettv) == OK)\n    {\n#ifdef FEAT_SEARCH_EXTRA\n\tint\t    id = (int)tv_get_number(&argvars[0]);\n\tmatchitem_T *m;\n\n\tif (id >= 1 && id <= 3)\n\t{\n\t    if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)\n\t    {\n\t\tlist_append_string(rettv->vval.v_list,\n\t\t\t\t\t\tsyn_id2name(m->hlg_id), -1);\n\t\tlist_append_string(rettv->vval.v_list, m->pattern, -1);\n\t    }\n\t    else\n\t    {\n\t\tlist_append_string(rettv->vval.v_list, NULL, -1);\n\t\tlist_append_string(rettv->vval.v_list, NULL, -1);\n\t    }\n\t}\n#endif\n    }\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":462959,"func":"TEST(BitTestMatchExpression, MatchBinaryWithLongBitMask) {\n    long long bitMask = 54;\n\n    BSONObj match = fromjson(\"{a: {$binary: 'NgAAAAAAAAAAAAAAAAAAAAAAAAAA', $type: '00'}}\");\n\n    BitsAllSetMatchExpression balls;\n    BitsAllClearMatchExpression ballc;\n    BitsAnySetMatchExpression banys;\n    BitsAnyClearMatchExpression banyc;\n\n    ASSERT_OK(balls.init(\"a\", bitMask));\n    ASSERT_OK(ballc.init(\"a\", bitMask));\n    ASSERT_OK(banys.init(\"a\", bitMask));\n    ASSERT_OK(banyc.init(\"a\", bitMask));\n    std::vector<uint32_t> bitPositions = balls.getBitPositions();\n    ASSERT(balls.matchesSingleElement(match[\"a\"]));\n    ASSERT(!ballc.matchesSingleElement(match[\"a\"]));\n    ASSERT(banys.matchesSingleElement(match[\"a\"]));\n    ASSERT(!banyc.matchesSingleElement(match[\"a\"]));\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":123876,"func":"static int __swiotlb_map_sg_attrs(struct device *dev, struct scatterlist *sgl,\n\t\t\t\t  int nelems, enum dma_data_direction dir,\n\t\t\t\t  struct dma_attrs *attrs)\n{\n\tstruct scatterlist *sg;\n\tint i, ret;\n\n\tret = swiotlb_map_sg_attrs(dev, sgl, nelems, dir, attrs);\n\tif (!is_device_dma_coherent(dev))\n\t\tfor_each_sg(sgl, sg, ret, i)\n\t\t\t__dma_map_area(phys_to_virt(dma_to_phys(dev, sg->dma_address)),\n\t\t\t\t       sg->length, dir);\n\n\treturn ret;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":404669,"func":"int handler_init(void)\n{\n\treturn tcmur_register_handler(&qcow_handler);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":476264,"func":"void InstanceKlass::store_fingerprint(uint64_t fingerprint) {\n  address adr = adr_fingerprint();\n  if (adr != NULL) {\n    Bytes::put_native_u8(adr, (u8)fingerprint); \/\/ adr may not be 64-bit aligned\n\n    ResourceMark rm;\n    log_trace(class, fingerprint)(\"stored as \" PTR64_FORMAT \" for class %s\", fingerprint, external_name());\n  }\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":237079,"func":"void WebGL2RenderingContextBase::endTransformFeedback() {\n  if (isContextLost())\n    return;\n\n  ContextGL()->EndTransformFeedback();\n\n  if (current_program_)\n    current_program_->DecreaseActiveTransformFeedbackCount();\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":197758,"func":"unsigned lodepng_encode32(unsigned char** out, size_t* outsize, const unsigned char* image, unsigned w, unsigned h)\n{\n  return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGBA, 8);\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":232839,"func":"static void reply_sesssetup_blob(struct smb_request *req,\n\t\t\t\t DATA_BLOB blob,\n\t\t\t\t NTSTATUS nt_status)\n{\n\tif (!NT_STATUS_IS_OK(nt_status) &&\n\t    !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {\n\t\treply_nterror(req, nt_status_squash(nt_status));\n\t\treturn;\n\t}\n\n\tnt_status = nt_status_squash(nt_status);\n\tSIVAL(req->outbuf, smb_rcls, NT_STATUS_V(nt_status));\n\tSSVAL(req->outbuf, smb_vwv0, 0xFF); \/* no chaining possible *\/\n\tSSVAL(req->outbuf, smb_vwv3, blob.length);\n\n\tif ((message_push_blob(&req->outbuf, blob) == -1)\n\t    || (push_signature(&req->outbuf) == -1)) {\n\t\treply_nterror(req, NT_STATUS_NO_MEMORY);\n\t}\n}\n","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":225294,"func":"static bool LayerNodeMayNeedCompositedScrolling(const PaintLayer* layer) {\n  if (Node* node = layer->GetLayoutObject().GetNode()) {\n    if (IsHTMLSelectElement(node))\n      return false;\n    if (TextControlElement* text_control = EnclosingTextControl(node)) {\n      if (IsHTMLInputElement(text_control)) {\n        return false;\n      }\n    }\n  }\n  return true;\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":264450,"func":"f_visualmode(typval_T *argvars, typval_T *rettv)\n{\n    char_u\tstr[2];\n\n    rettv->v_type = VAR_STRING;\n    str[0] = curbuf->b_visual_mode_eval;\n    str[1] = NUL;\n    rettv->vval.v_string = vim_strsave(str);\n\n    \/* A non-zero number or non-empty string argument: reset mode. *\/\n    if (non_zero_arg(&argvars[0]))\n\tcurbuf->b_visual_mode_eval = NUL;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":163756,"func":"  static const char* GetNavigationType(WebNavigationType nav_type) {\n    switch (nav_type) {\n      case blink::WebNavigationTypeLinkClicked:\n        return \"LinkClicked\";\n      case blink::WebNavigationTypeFormSubmitted:\n        return \"FormSubmitted\";\n      case blink::WebNavigationTypeBackForward:\n        return \"BackForward\";\n      case blink::WebNavigationTypeReload:\n        return \"Reload\";\n      case blink::WebNavigationTypeFormResubmitted:\n        return \"Resubmitted\";\n      case blink::WebNavigationTypeOther:\n        return \"Other\";\n    }\n    return \"\";\n  }\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":155299,"func":"f_input(typval_T *argvars, typval_T *rettv)\n{\n    get_user_input(argvars, rettv, FALSE, inputsecret_flag);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":173379,"func":"static u64 buffer_ftrace_now(struct trace_buffer *buf, int cpu)\n{\n\tu64 ts;\n\n\t\/* Early boot up does not have a buffer yet *\/\n\tif (!buf->buffer)\n\t\treturn trace_clock_local();\n\n\tts = ring_buffer_time_stamp(buf->buffer, cpu);\n\tring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);\n\n\treturn ts;\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":325513,"func":"void qemu_mutex_unlock_iothread(void) {}\n","target":1,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":515710,"func":"_nc_mvcur_wrap(void)\n{\n    NCURSES_SP_NAME(_nc_mvcur_wrap) (CURRENT_SCREEN);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":157272,"func":"mono_array_get_byte_length (MonoArray *array)\n{\n\tMonoClass *klass;\n\tint length;\n\tint i;\n\n\tklass = array->obj.vtable->klass;\n\n\tif (array->bounds == NULL)\n\t\tlength = array->max_length;\n\telse {\n\t\tlength = 1;\n\t\tfor (i = 0; i < klass->rank; ++ i)\n\t\t\tlength *= array->bounds [i].length;\n\t}\n\n\tswitch (klass->element_class->byval_arg.type) {\n\tcase MONO_TYPE_I1:\n\tcase MONO_TYPE_U1:\n\tcase MONO_TYPE_BOOLEAN:\n\t\treturn length;\n\tcase MONO_TYPE_I2:\n\tcase MONO_TYPE_U2:\n\tcase MONO_TYPE_CHAR:\n\t\treturn length << 1;\n\tcase MONO_TYPE_I4:\n\tcase MONO_TYPE_U4:\n\tcase MONO_TYPE_R4:\n\t\treturn length << 2;\n\tcase MONO_TYPE_I:\n\tcase MONO_TYPE_U:\n\t\treturn length * sizeof (gpointer);\n\tcase MONO_TYPE_I8:\n\tcase MONO_TYPE_U8:\n\tcase MONO_TYPE_R8:\n\t\treturn length << 3;\n\tdefault:\n\t\treturn -1;\n\t}\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":119293,"func":"static __inline VOID CalculateTcpChecksumGivenPseudoCS(TCPHeader *pTcpHeader, tCompletePhysicalAddress *pDataPages, ULONG ulStartOffset, ULONG tcpLength)\n{\n    pTcpHeader->tcp_xsum = CheckSumCalculator(pDataPages, ulStartOffset, tcpLength);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":501337,"func":"int ZSTD_minCLevel(void) { return (int)-ZSTD_TARGETLENGTH_MAX; }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":399997,"func":"MOCK_IMPL(addr_policy_result_t,\ncompare_tor_addr_to_addr_policy,(const tor_addr_t *addr, uint16_t port,\n                                 const smartlist_t *policy))\n{\n  if (!policy) {\n    \/* no policy? accept all. *\/\n    return ADDR_POLICY_ACCEPTED;\n  } else if (addr == NULL || tor_addr_is_null(addr)) {\n    if (port == 0) {\n      log_info(LD_BUG, \"Rejecting null address with 0 port (family %d)\",\n               addr ? tor_addr_family(addr) : -1);\n      return ADDR_POLICY_REJECTED;\n    }\n    return compare_unknown_tor_addr_to_addr_policy(port, policy);\n  } else if (port == 0) {\n    return compare_known_tor_addr_to_addr_policy_noport(addr, policy);\n  } else {\n    return compare_known_tor_addr_to_addr_policy(addr, port, policy);\n  }\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":244493,"func":"void CalculatePrintCanvasSize(const PrintMsg_Print_Params& print_params,\n                              gfx::Size* result) {\n  int dpi = GetDPI(&print_params);\n  result->set_width(ConvertUnit(print_params.printable_size.width(), dpi,\n                                print_params.desired_dpi));\n\n  result->set_height(ConvertUnit(print_params.printable_size.height(), dpi,\n                                 print_params.desired_dpi));\n}\n","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":78054,"func":"static void *skcipher_bind(const char *name, u32 type, u32 mask)\n{\n\tstruct skcipher_tfm *tfm;\n\tstruct crypto_skcipher *skcipher;\n\n\ttfm = kzalloc(sizeof(*tfm), GFP_KERNEL);\n\tif (!tfm)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tskcipher = crypto_alloc_skcipher(name, type, mask);\n\tif (IS_ERR(skcipher)) {\n\t\tkfree(tfm);\n\t\treturn ERR_CAST(skcipher);\n\t}\n\n\ttfm->skcipher = skcipher;\n\n\treturn tfm;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":323496,"func":"static void guest_fsfreeze_cleanup(void)\n\n{\n\n    int64_t ret;\n\n    Error *err = NULL;\n\n\n\n    if (ga_is_frozen(ga_state) == GUEST_FSFREEZE_STATUS_FROZEN) {\n\n        ret = qmp_guest_fsfreeze_thaw(&err);\n\n        if (ret < 0 || err) {\n\n            slog(\"failed to clean up frozen filesystems\");\n\n        }\n\n    }\n\n}\n","target":1,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":147743,"func":"static inline int get_undo_list(struct sem_undo_list **undo_listp)\n{\n\tstruct sem_undo_list *undo_list;\n\n\tundo_list = current->sysvsem.undo_list;\n\tif (!undo_list) {\n\t\tundo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL);\n\t\tif (undo_list == NULL)\n\t\t\treturn -ENOMEM;\n\t\tspin_lock_init(&undo_list->lock);\n\t\tatomic_set(&undo_list->refcnt, 1);\n\t\tINIT_LIST_HEAD(&undo_list->list_proc);\n\n\t\tcurrent->sysvsem.undo_list = undo_list;\n\t}\n\t*undo_listp = undo_list;\n\treturn 0;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":311875,"func":"void WebstoreStandaloneInstaller::OnWebstoreParseFailure(\n    const std::string& id,\n    InstallHelperResultCode result_code,\n    const std::string& error_message) {\n  webstore_install::Result install_result = webstore_install::OTHER_ERROR;\n  switch (result_code) {\n    case WebstoreInstallHelper::Delegate::MANIFEST_ERROR:\n      install_result = webstore_install::INVALID_MANIFEST;\n      break;\n    case WebstoreInstallHelper::Delegate::ICON_ERROR:\n      install_result = webstore_install::ICON_ERROR;\n      break;\n    default:\n      break;\n  }\n\n  CompleteInstall(install_result, error_message);\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":175305,"func":"void ContainerNode::setRestyleFlag(DynamicRestyleFlags mask)\n{\n    ASSERT(isElementNode() || isShadowRoot());\n    ensureRareData().setRestyleFlag(mask);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":204960,"func":"void GpuProcessHost::EstablishChannelError(\n    const EstablishChannelCallback& callback,\n    const IPC::ChannelHandle& channel_handle,\n    base::ProcessHandle renderer_process_for_gpu,\n    const GPUInfo& gpu_info) {\n  callback.Run(channel_handle, gpu_info);\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":345914,"func":"send_environment_variable (const char             *key,\n                           const char             *value,\n                           GdmSessionConversation *conversation)\n{\n        gdm_dbus_worker_call_set_environment_variable (conversation->worker_proxy,\n                                                       key, value,\n                                                       NULL, NULL, NULL);\n}","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":473950,"func":"slapi_pblock_set_flag_operation_notes(Slapi_PBlock *pb, uint32_t opflag) {\n    _pblock_assert_pb_intop(pb);\n    pb->pb_intop->pb_operation_notes |= opflag;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":405224,"func":"obj_to_asn1str(VALUE obj)\n{\n    ASN1_STRING *str;\n\n    StringValue(obj);\n    if(!(str = ASN1_STRING_new()))\n\tossl_raise(eASN1Error, NULL);\n    ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj));\n\n    return str;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":147624,"func":"struct super_block *get_super_thawed(struct block_device *bdev)\n{\n\twhile (1) {\n\t\tstruct super_block *s = get_super(bdev);\n\t\tif (!s || s->s_writers.frozen == SB_UNFROZEN)\n\t\t\treturn s;\n\t\tup_read(&s->s_umount);\n\t\twait_event(s->s_writers.wait_unfrozen,\n\t\t\t   s->s_writers.frozen == SB_UNFROZEN);\n\t\tput_super(s);\n\t}\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":309667,"func":"_gnutls_send_finished (gnutls_session_t session, int again)\n{\n  uint8_t data[36];\n  int ret;\n  int data_size = 0;\n\n\n  if (again == 0)\n    {\n\n      \/* This is needed in order to hash all the required\n       * messages.\n       *\/\n      if ((ret = _gnutls_handshake_hash_pending (session)) < 0)\n\t{\n\t  gnutls_assert ();\n\t  return ret;\n\t}\n\n      if (gnutls_protocol_get_version (session) == GNUTLS_SSL3)\n\t{\n\t  ret =\n\t    _gnutls_ssl3_finished (session,\n\t\t\t\t   session->security_parameters.entity, data);\n\t  data_size = 36;\n\t}\n      else\n\t{\t\t\t\/* TLS 1.0 *\/\n\t  ret =\n\t    _gnutls_finished (session,\n\t\t\t      session->security_parameters.entity, data);\n\t  data_size = 12;\n\t}\n\n      if (ret < 0)\n\t{\n\t  gnutls_assert ();\n\t  return ret;\n\t}\n\n    }\n\n  ret =\n    _gnutls_send_handshake (session, data, data_size,\n\t\t\t    GNUTLS_HANDSHAKE_FINISHED);\n\n  return ret;\n}\n","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":96457,"func":"static inline void SetPixelChannels(Image *image,const size_t number_channels)\n{\n  image->number_channels=number_channels;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":203196,"func":"  ~ScopedClipboard() {\n    if (opened_) {\n      ::CloseClipboard();\n    }\n  }\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":61258,"func":"const Router::MetadataMatchCriteria* Filter::metadataMatchCriteria() {\n  const Router::MetadataMatchCriteria* route_criteria =\n      (route_ != nullptr) ? route_->metadataMatchCriteria() : nullptr;\n\n  const auto& request_metadata = getStreamInfo().dynamicMetadata().filter_metadata();\n  const auto filter_it = request_metadata.find(Envoy::Config::MetadataFilters::get().ENVOY_LB);\n\n  if (filter_it != request_metadata.end() && route_criteria != nullptr) {\n    metadata_match_criteria_ = route_criteria->mergeMatchCriteria(filter_it->second);\n    return metadata_match_criteria_.get();\n  } else if (filter_it != request_metadata.end()) {\n    metadata_match_criteria_ =\n        std::make_unique<Router::MetadataMatchCriteriaImpl>(filter_it->second);\n    return metadata_match_criteria_.get();\n  } else {\n    return route_criteria;\n  }\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":231225,"func":"void WebGLRenderingContextBase::RestoreScissorBox() {\n  if (isContextLost())\n    return;\n\n  ContextGL()->Scissor(scissor_box_[0], scissor_box_[1], scissor_box_[2],\n                       scissor_box_[3]);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":113773,"func":"  int64_t CardinalityInternal() const override {\n    return sparse_tensor_.shape()[0];\n  }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":413777,"func":"  static void sass_reset_options (struct Sass_Options* options)\n  {\n    \/\/ free pointer before\n    \/\/ or copy\/move them\n    options->input_path = 0;\n    options->output_path = 0;\n    options->plugin_path = 0;\n    options->include_path = 0;\n    options->source_map_file = 0;\n    options->source_map_root = 0;\n    options->c_functions = 0;\n    options->c_importers = 0;\n    options->c_headers = 0;\n    options->plugin_paths = 0;\n    options->include_paths = 0;\n  }","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":334349,"func":"int bdrv_pwrite(BlockDriverState *bs, int64_t offset,\n\n                const void *buf1, int count1)\n\n{\n\n    BlockDriver *drv = bs->drv;\n\n\n\n    if (!drv)\n\n        return -ENOMEDIUM;\n\n    if (!drv->bdrv_pwrite)\n\n        return bdrv_pwrite_em(bs, offset, buf1, count1);\n\n    if (bdrv_wr_badreq_bytes(bs, offset, count1))\n\n        return -EDOM;\n\n    return drv->bdrv_pwrite(bs, offset, buf1, count1);\n\n}\n","target":1,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":522863,"func":"static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req,\n                                const X509_NAME *nm, STACK_OF(X509) *certs,\n                                unsigned long flags)\n{\n    X509 *signer;\n\n    if ((flags & OCSP_NOINTERN) == 0) {\n        signer = X509_find_by_subject(req->optionalSignature->certs, nm);\n        if (signer != NULL) {\n            *psigner = signer;\n            return 1;\n        }\n    }\n\n    if ((signer = X509_find_by_subject(certs, nm)) != NULL) {\n        *psigner = signer;\n        return 2;\n    }\n    return 0;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":176532,"func":"  void SimulateError() {\n    EXPECT_EQ(1u, host_->delegates_.size())\n        << \"Calls Create() before calling this method\";\n\n    EXPECT_CALL(*host_.get(), WasNotifiedOfError(kStreamId));\n\n    host_->OnStreamError(kStreamId);\n    SyncWithAudioThread();\n\n    EXPECT_EQ(0u, host_->delegates_.size());\n  }\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":165810,"func":"std::unique_ptr<syncer::EntityData> MoveToEntityData(\n    const std::string& client_name,\n    SessionSpecifics* specifics) {\n  auto entity_data = std::make_unique<syncer::EntityData>();\n  entity_data->non_unique_name = client_name;\n  if (specifics->has_header()) {\n    entity_data->non_unique_name += \" (header)\";\n  } else if (specifics->has_tab()) {\n    entity_data->non_unique_name +=\n        base::StringPrintf(\" (tab node %d)\", specifics->tab_node_id());\n  }\n  entity_data->specifics.mutable_session()->Swap(specifics);\n  return entity_data;\n}\n","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":393384,"func":"xmlRelaxNGNewGrammar(xmlRelaxNGParserCtxtPtr ctxt)\n{\n    xmlRelaxNGGrammarPtr ret;\n\n    ret = (xmlRelaxNGGrammarPtr) xmlMalloc(sizeof(xmlRelaxNGGrammar));\n    if (ret == NULL) {\n        xmlRngPErrMemory(ctxt, NULL);\n        return (NULL);\n    }\n    memset(ret, 0, sizeof(xmlRelaxNGGrammar));\n\n    return (ret);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":286617,"func":"IN_PROC_BROWSER_TEST_F ( PrefsFunctionalTest , TestDownloadDirPref ) {\n ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;\n base : : ScopedAllowBlockingForTesting allow_blocking ;\n base : : ScopedTempDir new_download_dir ;\n ASSERT_TRUE ( new_download_dir . CreateUniqueTempDir ( ) ) ;\n base : : FilePath downloaded_pkg = new_download_dir . GetPath ( ) . AppendASCII ( \"a_zip_file.zip\" ) ;\n browser ( ) -> profile ( ) -> GetPrefs ( ) -> SetFilePath ( prefs : : kDownloadDefaultDirectory , new_download_dir . GetPath ( ) ) ;\n std : : unique_ptr < content : : DownloadTestObserver > downloads_observer ( CreateWaiter ( browser ( ) , 1 ) ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( \"\/downloads\/a_zip_file.zip\" ) ) ;\n downloads_observer -> WaitForFinished ( ) ;\n EXPECT_TRUE ( base : : PathExists ( downloaded_pkg ) ) ;\n }","target":1,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":415167,"func":"static apr_status_t beam_recv_cleanup(void *data)\n{\n    h2_bucket_beam *beam = data;\n    \/* receiver pool has gone away, clear references *\/\n    beam->recv_buffer = NULL;\n    beam->recv_pool = NULL;\n    return APR_SUCCESS;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":204749,"func":"bool HTMLInputElement::isTextButton() const\n{\n    return m_inputType->isTextButton();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":44397,"func":"GF_Err stsd_Size(GF_Box *s)\n{\n\tGF_SampleDescriptionBox *ptr = (GF_SampleDescriptionBox *)s;\n\tptr->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":472124,"func":"stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n)\n{\n   unsigned int k;\n   if (z->num_bits < n) stbi__fill_bits(z);\n   k = z->code_buffer & ((1 << n) - 1);\n   z->code_buffer >>= n;\n   z->num_bits -= n;\n   return k;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":510143,"func":"allocateSpaceInTable (FileInfo * nested, TranslationTableOffset * offset,\n\t\t      int count)\n{\n\/* allocate memory for translation table and expand previously allocated \n* memory if necessary *\/\n  int spaceNeeded = ((count + OFFSETSIZE - 1) \/ OFFSETSIZE) * OFFSETSIZE;\n  TranslationTableOffset size = tableUsed + spaceNeeded;\n  if (size > tableSize)\n    {\n      void *newTable;\n      size += (size \/ OFFSETSIZE);\n      newTable = realloc (table, size);\n      if (!newTable)\n\t{\n\t  compileError (nested, \"Not enough memory for translation table.\");\n\t  outOfMemory ();\n\t}\n      memset (((unsigned char *) newTable) + tableSize, 0, size - tableSize);\n      \/* update references to the old table *\/\n      {\n\tChainEntry *entry;\n\tfor (entry = tableChain; entry != NULL; entry = entry->next)\n\t  if (entry->table == table)\n\t    entry->table = (TranslationTableHeader *) newTable;\n      }\n      table = (TranslationTableHeader *) newTable;\n      tableSize = size;\n    }\n  if (offset != NULL)\n    {\n      *offset = (tableUsed - sizeof (*table)) \/ OFFSETSIZE;\n      tableUsed += spaceNeeded;\n    }\n  return 1;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":217304,"func":"static int megasas_map_dcmd(MegasasState *s, MegasasCmd *cmd)\n{\n    dma_addr_t iov_pa, iov_size;\n\n    cmd->flags = le16_to_cpu(cmd->frame->header.flags);\n    if (!cmd->frame->header.sge_count) {\n        trace_megasas_dcmd_zero_sge(cmd->index);\n        cmd->iov_size = 0;\n        return 0;\n    } else if (cmd->frame->header.sge_count > 1) {\n        trace_megasas_dcmd_invalid_sge(cmd->index,\n                                       cmd->frame->header.sge_count);\n        cmd->iov_size = 0;\n        return -1;\n    }\n    iov_pa = megasas_sgl_get_addr(cmd, &cmd->frame->dcmd.sgl);\n    iov_size = megasas_sgl_get_len(cmd, &cmd->frame->dcmd.sgl);\n    pci_dma_sglist_init(&cmd->qsg, PCI_DEVICE(s), 1);\n    qemu_sglist_add(&cmd->qsg, iov_pa, iov_size);\n    cmd->iov_size = iov_size;\n    return cmd->iov_size;\n}\n","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":390168,"func":"SignatureAlgorithm CertManager::get_keyType() const\n{\n    return keyType_;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":287824,"func":" void NetworkHandler::SetCookie(const std::string& name,\n                               const std::string& value,\n                               Maybe<std::string> url,\n                               Maybe<std::string> domain,\n                               Maybe<std::string> path,\n                               Maybe<bool> secure,\n                               Maybe<bool> http_only,\n                                Maybe<std::string> same_site,\n                                Maybe<double> expires,\n                                std::unique_ptr<SetCookieCallback> callback) {\n  if (!process_) {\n     callback->sendFailure(Response::InternalError());\n     return;\n   }\n\n  if (!url.isJust() && !domain.isJust()) {\n    callback->sendFailure(Response::InvalidParams(\n        \"At least one of the url and domain needs to be specified\"));\n  }\n\n  BrowserThread::PostTask(\n       BrowserThread::IO, FROM_HERE,\n       base::BindOnce(\n           &SetCookieOnIO,\n          base::Unretained(\n              process_->GetStoragePartition()->GetURLRequestContext()),\n          name, value, url.fromMaybe(\"\"), domain.fromMaybe(\"\"),\n          path.fromMaybe(\"\"), secure.fromMaybe(false),\n          http_only.fromMaybe(false), same_site.fromMaybe(\"\"),\n          expires.fromMaybe(-1),\n           base::BindOnce(&CookieSetOnIO, std::move(callback))));\n }\n","target":1,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":105264,"func":"PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)\n{\n    return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":342936,"func":"static uint64_t lsi_io_read(void *opaque, target_phys_addr_t addr,\n\n                            unsigned size)\n\n{\n\n    LSIState *s = opaque;\n\n    return lsi_reg_readb(s, addr & 0xff);\n\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":194421,"func":"fz_drop_default_colorspaces(fz_context *ctx, fz_default_colorspaces *default_cs)\n{\n\tif (fz_drop_imp(ctx, default_cs, &default_cs->refs))\n\t{\n\t\tfz_drop_colorspace(ctx, default_cs->gray);\n\t\tfz_drop_colorspace(ctx, default_cs->rgb);\n\t\tfz_drop_colorspace(ctx, default_cs->cmyk);\n\t\tfz_drop_colorspace(ctx, default_cs->oi);\n\t\tfz_free(ctx, default_cs);\n\t}\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":128695,"func":"static int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->fg.isTabFunc ){\n    sqlite3ErrorMsg(pParse, \"'%s' is not a function\", pFrom->zName);\n    return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":492794,"func":"bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr)\n{\n\treturn false;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":330005,"func":"static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)\n\n{\n\n    exit(0);\n\n    return 0;\n\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":430874,"func":"void snd_device_initialize(struct device *dev, struct snd_card *card)\n{\n\tdevice_initialize(dev);\n\tif (card)\n\t\tdev->parent = &card->card_dev;\n\tdev->class = sound_class;\n\tdev->release = default_release;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":153899,"func":"static struct dentry *proc_pident_instantiate(struct inode *dir,\n\tstruct dentry *dentry, struct task_struct *task, const void *ptr)\n{\n\tconst struct pid_entry *p = ptr;\n\tstruct inode *inode;\n\tstruct proc_inode *ei;\n\tstruct dentry *error = ERR_PTR(-ENOENT);\n\n\tinode = proc_pid_make_inode(dir->i_sb, task);\n\tif (!inode)\n\t\tgoto out;\n\n\tei = PROC_I(inode);\n\tinode->i_mode = p->mode;\n\tif (S_ISDIR(inode->i_mode))\n\t\tinode->i_nlink = 2;\t\/* Use getattr to fix if necessary *\/\n\tif (p->iop)\n\t\tinode->i_op = p->iop;\n\tif (p->fop)\n\t\tinode->i_fop = p->fop;\n\tei->op = p->op;\n\tdentry->d_op = &pid_dentry_operations;\n\td_add(dentry, inode);\n\t\/* Close the race of the process dying before we return the dentry *\/\n\tif (pid_revalidate(dentry, NULL))\n\t\terror = NULL;\nout:\n\treturn error;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":23606,"func":"static int do_stop_slave_sql ( MYSQL * mysql_con ) {\n MYSQL_RES * slave ;\n if ( mysql_query_with_error_report ( mysql_con , & slave , \"SHOW SLAVE STATUS\" ) ) return ( 1 ) ;\n else {\n MYSQL_ROW row = mysql_fetch_row ( slave ) ;\n if ( row && row [ 11 ] ) {\n if ( ! strcmp ( row [ 11 ] , \"No\" ) ) {\n mysql_free_result ( slave ) ;\n return ( 0 ) ;\n }\n }\n }\n mysql_free_result ( slave ) ;\n if ( mysql_query_with_error_report ( mysql_con , 0 , \"STOP SLAVE SQL_THREAD\" ) ) return ( 1 ) ;\n return ( 0 ) ;\n }","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":33801,"func":"cifs_relock_file(struct cifsFileInfo *cfile)\n{\n\tstruct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);\n\tstruct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);\n\tstruct cifs_tcon *tcon = tlink_tcon(cfile->tlink);\n\tint rc = 0;\n\n\tdown_read(&cinode->lock_sem);\n\tif (cinode->can_cache_brlcks) {\n\t\t\/* can cache locks - no need to relock *\/\n\t\tup_read(&cinode->lock_sem);\n\t\treturn rc;\n\t}\n\n\tif (cap_unix(tcon->ses) &&\n\t    (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&\n\t    ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))\n\t\trc = cifs_push_posix_locks(cfile);\n\telse\n\t\trc = tcon->ses->server->ops->push_mand_locks(cfile);\n\n\tup_read(&cinode->lock_sem);\n\treturn rc;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":489077,"func":"static SECURITY_STATUS SEC_ENTRY negotiate_ImpersonateSecurityContext(PCtxtHandle phContext)\n{\n\treturn SEC_E_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":517517,"func":"  my_decimal *val_decimal_from_item(Item *item, my_decimal *decimal_value)\n  {\n    DBUG_ASSERT(fixed == 1);\n    my_decimal *value= item->val_decimal(decimal_value);\n    if ((null_value= item->null_value))\n      value= NULL;\n    return value;\n  }","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":197166,"func":"static MagickBooleanType IsDPX(const unsigned char *magick,const size_t extent)\n{\n  if (extent < 4)\n    return(MagickFalse);\n  if (memcmp(magick,\"SDPX\",4) == 0)\n    return(MagickTrue);\n  if (memcmp(magick,\"XPDS\",4) == 0)\n    return(MagickTrue);\n  return(MagickFalse);\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":77013,"func":"OPJ_BOOL opj_tcd_rate_allocate_encode(  opj_tcd_t *p_tcd,\n                                                                            OPJ_BYTE * p_dest_data,\n                                                                            OPJ_UINT32 p_max_dest_size,\n                                                                            opj_codestream_info_t *p_cstr_info )\n{\n        opj_cp_t * l_cp = p_tcd->cp;\n        OPJ_UINT32 l_nb_written = 0;\n\n        if (p_cstr_info)  {\n                p_cstr_info->index_write = 0;\n        }\n\n        if (l_cp->m_specific_param.m_enc.m_disto_alloc|| l_cp->m_specific_param.m_enc.m_fixed_quality)  {\n                \/* fixed_quality *\/\n                \/* Normal Rate\/distortion allocation *\/\n                if (! opj_tcd_rateallocate(p_tcd, p_dest_data,&l_nb_written, p_max_dest_size, p_cstr_info)) {\n                        return OPJ_FALSE;\n                }\n        }\n        else {\n                \/* Fixed layer allocation *\/\n                opj_tcd_rateallocate_fixed(p_tcd);\n        }\n\n        return OPJ_TRUE;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":119544,"func":"static void mlx5_fpga_conn_notify_hw(struct mlx5_fpga_conn *conn, void *wqe)\n{\n\t\/* ensure wqe is visible to device before updating doorbell record *\/\n\tdma_wmb();\n\t*conn->qp.wq.sq.db = cpu_to_be32(conn->qp.sq.pc);\n\t\/* Make sure that doorbell record is visible before ringing *\/\n\twmb();\n\tmlx5_write64(wqe, conn->fdev->conn_res.uar->map + MLX5_BF_OFFSET);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":153526,"func":"R_API ut64 r_bin_java_element_pair_calc_size(RBinJavaElementValuePair *evp) {\n\tut64 sz = 2;\n\tif (evp && evp->value) {\n\t\t\/\/ evp->element_name_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\t\/\/ evp->value = r_bin_java_element_value_new (bin, offset+2);\n\t\tsz += r_bin_java_element_value_calc_size (evp->value);\n\t}\n\treturn sz;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":324469,"func":"void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint)\n\n{\n\n#if defined(TARGET_HAS_ICE)\n\n    QTAILQ_REMOVE(&cpu->breakpoints, breakpoint, entry);\n\n\n\n    breakpoint_invalidate(cpu, breakpoint->pc);\n\n\n\n    g_free(breakpoint);\n\n#endif\n\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":490593,"func":"GF_Err gf_filter_push_caps(GF_Filter *filter, u32 code, GF_PropertyValue *value, const char *name, u32 flags, u8 priority)\n{\n\tu32 nb_caps;\n\tGF_FilterCapability *caps;\n\tif (! (filter->freg->flags & GF_FS_REG_CUSTOM)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"Attempt to push cap on non custom filter %s\\n\", filter->freg->name));\n\t\treturn GF_BAD_PARAM;\n\t}\n\tcaps = (GF_FilterCapability *)filter->forced_caps;\n\tnb_caps = filter->nb_forced_caps;\n\tcaps = gf_realloc(caps, sizeof(GF_FilterCapability)*(nb_caps+1) );\n\tif (!caps) return GF_OUT_OF_MEM;\n\tcaps[nb_caps].code = code;\n\tcaps[nb_caps].val = *value;\n\tcaps[nb_caps].name = name ? gf_strdup(name) : NULL;\n\tcaps[nb_caps].priority = priority;\n\tcaps[nb_caps].flags = flags;\n\tfilter->nb_forced_caps++;\n\tfilter->forced_caps = caps;\n\treturn GF_OK;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":342807,"func":"static void pcnet_common_init(PCNetState *d, NICInfo *nd)\n\n{\n\n    d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d);\n\n\n\n    d->nd = nd;\n\n\n\n    if (nd && nd->vlan) {\n\n        d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,\n\n                                     pcnet_receive, pcnet_can_receive, d);\n\n\n\n        qemu_format_nic_info_str(d->vc, d->nd->macaddr);\n\n    } else {\n\n        d->vc = NULL;\n\n    }\n\n    pcnet_h_reset(d);\n\n    register_savevm(\"pcnet\", -1, 2, pcnet_save, pcnet_load, d);\n\n}\n","target":1,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":341435,"func":"uint64_t helper_cvttq_svic(CPUAlphaState *env, uint64_t a)\n\n{\n\n    return inline_cvttq(env, a, float_round_to_zero, 1);\n\n}\n","target":1,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":440718,"func":"static int vxlan_fdb_replace(struct vxlan_fdb *f,\n\t\t\t     union vxlan_addr *ip, __be16 port, __be32 vni,\n\t\t\t     __u32 ifindex, struct vxlan_rdst *oldrd)\n{\n\tstruct vxlan_rdst *rd;\n\n\trd = vxlan_fdb_find_rdst(f, ip, port, vni, ifindex);\n\tif (rd)\n\t\treturn 0;\n\n\trd = list_first_entry_or_null(&f->remotes, struct vxlan_rdst, list);\n\tif (!rd)\n\t\treturn 0;\n\n\t*oldrd = *rd;\n\tdst_cache_reset(&rd->dst_cache);\n\trd->remote_ip = *ip;\n\trd->remote_port = port;\n\trd->remote_vni = vni;\n\trd->remote_ifindex = ifindex;\n\trd->offloaded = false;\n\treturn 1;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":16630,"func":"static gboolean nautilus_mime_actions_check_if_required_attributes_ready ( NautilusFile * file ) {\n NautilusFileAttributes attributes ;\n gboolean ready ;\n attributes = nautilus_mime_actions_get_required_file_attributes ( ) ;\n ready = nautilus_file_check_if_ready ( file , attributes ) ;\n return ready ;\n }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":186251,"func":"void RendererSchedulerImpl::OnReportFineGrainedExpectedQueueingTime(\n    const char* split_description,\n    base::TimeDelta queueing_time) {\n  base::UmaHistogramCustomCounts(\n      split_description, queueing_time.InMicroseconds(),\n      kMinExpectedQueueingTimeBucket, kMaxExpectedQueueingTimeBucket,\n      kNumberExpectedQueueingTimeBuckets);\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":495188,"func":"inline uint8_t* WireFormatLite::WriteDoubleNoTagToArray(\n    const RepeatedField<double>& value, uint8_t* target) {\n  return WriteFixedNoTagToArray(value, WriteDoubleNoTagToArray, target);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":46367,"func":"static int ptrace_resume(struct task_struct *child, long request,\n\t\t\t unsigned long data)\n{\n\tif (!valid_signal(data))\n\t\treturn -EIO;\n\n\tif (request == PTRACE_SYSCALL)\n\t\tset_tsk_thread_flag(child, TIF_SYSCALL_TRACE);\n\telse\n\t\tclear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);\n\n#ifdef TIF_SYSCALL_EMU\n\tif (request == PTRACE_SYSEMU || request == PTRACE_SYSEMU_SINGLESTEP)\n\t\tset_tsk_thread_flag(child, TIF_SYSCALL_EMU);\n\telse\n\t\tclear_tsk_thread_flag(child, TIF_SYSCALL_EMU);\n#endif\n\n\tif (is_singleblock(request)) {\n\t\tif (unlikely(!arch_has_block_step()))\n\t\t\treturn -EIO;\n\t\tuser_enable_block_step(child);\n\t} else if (is_singlestep(request) || is_sysemu_singlestep(request)) {\n\t\tif (unlikely(!arch_has_single_step()))\n\t\t\treturn -EIO;\n\t\tuser_enable_single_step(child);\n\t} else {\n\t\tuser_disable_single_step(child);\n\t}\n\n\tchild->exit_code = data;\n\twake_up_state(child, __TASK_TRACED);\n\n\treturn 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":139081,"func":"int PE_(r_bin_pe_is_pie)(RBinPEObj* pe) {\n\tif (!pe || !pe->nt_headers) {\n\t\treturn false;\n\t}\n\treturn HASCHR (IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE);\n#if 0\n\tBOOL aslr = inh->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE;\n\/\/TODO: implement dep?\n\tBOOL dep = inh->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT;\n#endif\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":391134,"func":"static void put_reqs_available(struct kioctx *ctx, unsigned nr)\n{\n\tstruct kioctx_cpu *kcpu;\n\tunsigned long flags;\n\n\tpreempt_disable();\n\tkcpu = this_cpu_ptr(ctx->cpu);\n\n\tlocal_irq_save(flags);\n\tkcpu->reqs_available += nr;\n\n\twhile (kcpu->reqs_available >= ctx->req_batch * 2) {\n\t\tkcpu->reqs_available -= ctx->req_batch;\n\t\tatomic_add(ctx->req_batch, &ctx->reqs_available);\n\t}\n\n\tlocal_irq_restore(flags);\n\tpreempt_enable();\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":17559,"func":"int net_slirp_redir ( const char * redir_str ) {\n struct slirp_config_str * config ;\n if ( QTAILQ_EMPTY ( & slirp_stacks ) ) {\n config = g_malloc ( sizeof ( * config ) ) ;\n pstrcpy ( config -> str , sizeof ( config -> str ) , redir_str ) ;\n config -> flags = SLIRP_CFG_HOSTFWD | SLIRP_CFG_LEGACY ;\n config -> next = slirp_configs ;\n slirp_configs = config ;\n return 0 ;\n }\n return slirp_hostfwd ( QTAILQ_FIRST ( & slirp_stacks ) , redir_str , 1 ) ;\n }","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":14892,"func":"static int detect_flash ( const TWO_PASS * twopass , int offset ) {\n const FIRSTPASS_STATS * const next_frame = read_frame_stats ( twopass , offset ) ;\n return next_frame != NULL && next_frame -> pcnt_second_ref > next_frame -> pcnt_inter && next_frame -> pcnt_second_ref >= 0.5 ;\n }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":99996,"func":"static inline size_t WriteChannelSize(const PSDInfo *psd_info,Image *image,\n  const signed short channel)\n{\n  ssize_t\n    count;\n\n  count=WriteBlobMSBSignedShort(image,channel);\n  count+=SetPSDSize(psd_info,image,0);\n  return((size_t) count);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":301974,"func":"int loop_register_transfer(struct loop_func_table *funcs)\n{\n\tunsigned int n = funcs->number;\n\n\tif (n >= MAX_LO_CRYPT || xfer_funcs[n])\n\t\treturn -EINVAL;\n\txfer_funcs[n] = funcs;\n\treturn 0;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":349880,"func":"CNF_ReadFile(const char *filename)\n{\n  FILE *in;\n  char line[2048];\n  int i;\n\n  in = fopen(filename, \"r\");\n  if (!in) {\n    LOG_FATAL(\"Could not open configuration file %s : %s\",\n              filename, strerror(errno));\n    return;\n  }\n\n  DEBUG_LOG(\"Reading %s\", filename);\n\n  for (i = 1; fgets(line, sizeof(line), in); i++) {\n    CNF_ParseLine(filename, i, line);\n  }\n\n  fclose(in);\n}","target":1,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":118003,"func":"unsigned avcodec_version(void)\n{\n\/\/    av_assert0(AV_CODEC_ID_V410==164);\n    av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);\n    av_assert0(AV_CODEC_ID_ADPCM_G722==69660);\n\/\/     av_assert0(AV_CODEC_ID_BMV_AUDIO==86071);\n    av_assert0(AV_CODEC_ID_SRT==94216);\n    av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);\n\n    return LIBAVCODEC_VERSION_INT;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":141718,"func":"static void rdma_umap_close(struct vm_area_struct *vma)\n{\n\tstruct ib_uverbs_file *ufile = vma->vm_file->private_data;\n\tstruct rdma_umap_priv *priv = vma->vm_private_data;\n\n\tif (!priv)\n\t\treturn;\n\n\t\/*\n\t * The vma holds a reference on the struct file that created it, which\n\t * in turn means that the ib_uverbs_file is guaranteed to exist at\n\t * this point.\n\t *\/\n\tmutex_lock(&ufile->umap_lock);\n\tlist_del(&priv->list);\n\tmutex_unlock(&ufile->umap_lock);\n\tkfree(priv);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":7140,"func":"static void recovery_abort(void) {\n    if (!dry_run) {\n        storage_reset();\n    }\n\n    awaiting_character = false;\n    memzero(mnemonic, sizeof(mnemonic));\n    memzero(cipher, sizeof(cipher));\n}","target":1,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":215198,"func":"bool MessageLoop::DoIdleWork() {\n  if (ProcessNextDelayedNonNestableTask())\n    return true;\n\n  if (run_loop_client_->ShouldQuitWhenIdle())\n    pump_->Quit();\n\n#if defined(OS_WIN)\n  bool high_res = pending_high_res_tasks_ > 0;\n  if (high_res != in_high_res_mode_) {\n    in_high_res_mode_ = high_res;\n    Time::ActivateHighResolutionTimer(in_high_res_mode_);\n  }\n#endif\n  return false;\n}\n","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":33901,"func":"compile_tree_empty_check(Node* node, regex_t* reg, int empty_info, ScanEnv* env)\n{\n  int r;\n  int saved_num_null_check = reg->num_null_check;\n\n  if (empty_info != BODY_IS_NOT_EMPTY) {\n    r = add_op(reg, OP_EMPTY_CHECK_START);\n    if (r != 0) return r;\n    COP(reg)->empty_check_start.mem = reg->num_null_check; \/* NULL CHECK ID *\/\n    reg->num_null_check++;\n  }\n\n  r = compile_tree(node, reg, env);\n  if (r != 0) return r;\n\n  if (empty_info != BODY_IS_NOT_EMPTY) {\n    if (empty_info == BODY_IS_EMPTY)\n      r = add_op(reg, OP_EMPTY_CHECK_END);\n    else if (empty_info == BODY_IS_EMPTY_MEM)\n      r = add_op(reg, OP_EMPTY_CHECK_END_MEMST);\n    else if (empty_info == BODY_IS_EMPTY_REC)\n      r = add_op(reg, OP_EMPTY_CHECK_END_MEMST_PUSH);\n\n    if (r != 0) return r;\n    COP(reg)->empty_check_end.mem = saved_num_null_check; \/* NULL CHECK ID *\/\n  }\n  return r;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":66323,"func":"pid_t enc_untrusted_waitpid(pid_t pid, int *status, int options) {\n  int klinux_status;\n  pid_t result = EnsureInitializedAndDispatchSyscall(\n      asylo::system_call::kSYS_wait4, pid, &klinux_status,\n      TokLinuxWaitOption(options), \/*rusage=*\/nullptr);\n\n  if (status) {\n    *status = FromkLinuxToNewlibWstatus(klinux_status);\n  }\n  return result;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":152090,"func":"void lodepng_info_cleanup(LodePNGInfo* info)\n{\n  lodepng_color_mode_cleanup(&info->color);\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  LodePNGText_cleanup(info);\n  LodePNGIText_cleanup(info);\n\n  LodePNGUnknownChunks_cleanup(info);\n#endif \/*LODEPNG_COMPILE_ANCILLARY_CHUNKS*\/\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":336217,"func":"static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp)\n{\n    ChardevCommon *common = qapi_ChardevVC_base(vc);\n    CharDriverState *chr;\n    chr = qemu_chr_alloc(common, errp);\n    if (!chr) {\n    chr->chr_write = gd_vc_chr_write;\n    chr->chr_set_echo = gd_vc_chr_set_echo;\n    \/* Temporary, until gd_vc_vte_init runs.  *\/\n    chr->opaque = g_new0(VirtualConsole, 1);\n    vcs[nb_vcs++] = chr;\n    return chr;","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":455913,"func":"TEST(OverflowArithmetic, UnsignedSubtractionTests) {\n    using T = uint64_t;\n    static constexpr auto f = polySub;\n    ASSERT(test<T>(f, kMax<T>, 0, kMax<T>));\n    ASSERT(test<T>(f, kMax<T>, 1, kMax<T> - 1));\n    ASSERT(test<T>(f, kMax<T>, kMax<T>, 0));\n    ASSERT(test<T>(f, 0, 0, 0));\n    ASSERT(test<T>(f, 1, 1, 0));\n    ASSERT(testOflow<T>(f, 0, 1));\n    ASSERT(testOflow<T>(f, 0, kMax<T>));\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":254815,"func":"hb_unicode_funcs_t * hb_icu_get_unicode_funcs ( void ) {\n static const hb_unicode_funcs_t _hb_icu_unicode_funcs = {\n HB_OBJECT_HEADER_STATIC , NULL , true , {\n # define HB_UNICODE_FUNC_IMPLEMENT ( name ) hb_icu_unicode_ ## name , HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS # undef HB_UNICODE_FUNC_IMPLEMENT }\n }\n ;\n # if U_ICU_VERSION_MAJOR_NUM >= 49 if ( ! hb_atomic_ptr_get ( & normalizer ) ) {\n UErrorCode icu_err = U_ZERO_ERROR ;\n hb_atomic_ptr_cmpexch ( & normalizer , NULL , unorm2_getNFCInstance ( & icu_err ) ) ;\n }\n # endif return const_cast < hb_unicode_funcs_t * > ( & _hb_icu_unicode_funcs ) ;\n }","target":1,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":98158,"func":"static void show_vma_header_prefix(struct seq_file *m,\n\t\t\t\t   unsigned long start, unsigned long end,\n\t\t\t\t   vm_flags_t flags, unsigned long long pgoff,\n\t\t\t\t   dev_t dev, unsigned long ino)\n{\n\tseq_setwidth(m, 25 + sizeof(void *) * 6 - 1);\n\tseq_put_hex_ll(m, NULL, start, 8);\n\tseq_put_hex_ll(m, \"-\", end, 8);\n\tseq_putc(m, ' ');\n\tseq_putc(m, flags & VM_READ ? 'r' : '-');\n\tseq_putc(m, flags & VM_WRITE ? 'w' : '-');\n\tseq_putc(m, flags & VM_EXEC ? 'x' : '-');\n\tseq_putc(m, flags & VM_MAYSHARE ? 's' : 'p');\n\tseq_put_hex_ll(m, \" \", pgoff, 8);\n\tseq_put_hex_ll(m, \" \", MAJOR(dev), 2);\n\tseq_put_hex_ll(m, \":\", MINOR(dev), 2);\n\tseq_put_decimal_ull(m, \" \", ino);\n\tseq_putc(m, ' ');\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":338409,"func":"int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags,\n\n                          CPUBreakpoint **breakpoint)\n\n{\n\n#if defined(TARGET_HAS_ICE)\n\n    CPUBreakpoint *bp;\n\n\n\n    bp = qemu_malloc(sizeof(*bp));\n\n\n\n    bp->pc = pc;\n\n    bp->flags = flags;\n\n\n\n    \/* keep all GDB-injected breakpoints in front *\/\n\n    if (flags & BP_GDB)\n\n        TAILQ_INSERT_HEAD(&env->breakpoints, bp, entry);\n\n    else\n\n        TAILQ_INSERT_TAIL(&env->breakpoints, bp, entry);\n\n\n\n    breakpoint_invalidate(env, pc);\n\n\n\n    if (breakpoint)\n\n        *breakpoint = bp;\n\n    return 0;\n\n#else\n\n    return -ENOSYS;\n\n#endif\n\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":157216,"func":"rb_fiddle_handle_enable_close(VALUE self)\n{\n    struct dl_handle *fiddle_handle;\n\n    TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);\n    fiddle_handle->enable_close = 1;\n    return Qnil;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":81325,"func":"mrb_singleton_class(mrb_state *mrb, mrb_value v)\n{\n  struct RClass *c = mrb_singleton_class_ptr(mrb, v);\n\n  if (c == NULL) {\n    mrb_raise(mrb, E_TYPE_ERROR, \"can't define singleton\");\n  }\n  return mrb_obj_value(c);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":218938,"func":"    virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemEntry>& entries, bool hasMore)\n    {\n        ASSERT_NOT_REACHED();\n        delete this;\n    }\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":205895,"func":"int __pte_alloc_kernel(pmd_t *pmd, unsigned long address)\n{\n\tpte_t *new = pte_alloc_one_kernel(&init_mm, address);\n\tif (!new)\n\t\treturn -ENOMEM;\n\n\tsmp_wmb(); \/* See comment in __pte_alloc *\/\n\n\tspin_lock(&init_mm.page_table_lock);\n\tif (likely(pmd_none(*pmd))) {\t\/* Has another populated it ? *\/\n\t\tpmd_populate_kernel(&init_mm, pmd, new);\n\t\tnew = NULL;\n\t} else\n\t\tVM_BUG_ON(pmd_trans_splitting(*pmd));\n\tspin_unlock(&init_mm.page_table_lock);\n\tif (new)\n\t\tpte_free_kernel(&init_mm, new);\n\treturn 0;\n}\n","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":127401,"func":"unsigned char* lodepng_chunk_data(unsigned char* chunk)\n{\n  return &chunk[8];\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":5172,"func":"int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,\n\t\t      struct nlattr **attrs)\n{\n\tstruct net *net = sock_net(in_skb->sk);\n\tstruct crypto_user_alg *p = nlmsg_data(in_nlh);\n\tstruct crypto_alg *alg;\n\tstruct sk_buff *skb;\n\tstruct crypto_dump_info info;\n\tint err;\n\n\tif (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))\n\t\treturn -EINVAL;\n\n\talg = crypto_alg_match(p, 0);\n\tif (!alg)\n\t\treturn -ENOENT;\n\n\terr = -ENOMEM;\n\tskb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\n\tif (!skb)\n\t\tgoto drop_alg;\n\n\tinfo.in_skb = in_skb;\n\tinfo.out_skb = skb;\n\tinfo.nlmsg_seq = in_nlh->nlmsg_seq;\n\tinfo.nlmsg_flags = 0;\n\n\terr = crypto_reportstat_alg(alg, &info);\n\ndrop_alg:\n\tcrypto_mod_put(alg);\n\n\tif (err)\n\t\treturn err;\n\n\treturn nlmsg_unicast(net->crypto_nlsk, skb, NETLINK_CB(in_skb).portid);\n}","target":1,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":300507,"func":"void spl_array_iterator_key(zval *object, zval *return_value TSRMLS_DC) \/* {{{ *\/\n{\n\tspl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);\n\tHashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);\n\n\tif (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) {\n\t\treturn;\n\t}\n\n\tzend_hash_get_current_key_zval_ex(aht, return_value, &intern->pos);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":253751,"func":"void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val) {\n    return ctx->info_callback;\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":185870,"func":"void WebProcessProxy::interactionOccurredWhileUnresponsive(ResponsivenessTimer*)\n{\n    Vector<RefPtr<WebPageProxy> > pages;\n    copyValuesToVector(m_pageMap, pages);\n    for (size_t i = 0, size = pages.size(); i < size; ++i)\n        pages[i]->interactionOccurredWhileProcessUnresponsive();\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":211761,"func":"static int get_extra_state(QEMUFile *f, void *pv, size_t size)\n{\n    VirtIODevice *vdev = pv;\n    BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));\n    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n\n    if (!k->load_extra_state) {\n        return -1;\n    } else {\n        return k->load_extra_state(qbus->parent, f);\n    }\n}\n","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":102611,"func":"static void test_bug57058()\n{\n  MYSQL_RES *res;\n  int rc;\n\n  DBUG_ENTER(\"test_bug57058\");\n  myheader(\"test_bug57058\");\n\n  rc= mysql_query(mysql, \"set @@session.long_query_time=0.1\");\n  myquery(rc);\n\n  DIE_UNLESS(!(mysql->server_status & SERVER_QUERY_WAS_SLOW));\n\n  rc= mysql_query(mysql, \"select sleep(1)\");\n  myquery(rc);\n\n  \/*\n    Important: the flag is sent in the last EOF packet of\n    the query, the one which ends the result. Read the\n    result to see the \"slow\" status.\n  *\/\n  res= mysql_store_result(mysql);\n\n  DIE_UNLESS(mysql->server_status & SERVER_QUERY_WAS_SLOW);\n\n  mysql_free_result(res);\n\n  rc= mysql_query(mysql, \"set @@session.long_query_time=default\");\n  myquery(rc);\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":201273,"func":"    ~LocalSiteCharacteristicsWebContentsObserver() {\n  DCHECK(!writer_);\n}\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":172272,"func":"SPICE_GNUC_VISIBLE int spice_server_set_agent_copypaste(SpiceServer *s, int enable)\n{\n    spice_assert(reds == s);\n    agent_copypaste = enable;\n    reds->agent_state.write_filter.copy_paste_enabled = agent_copypaste;\n    reds->agent_state.read_filter.copy_paste_enabled = agent_copypaste;\n    return 0;\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":102361,"func":"static const char *jsi_TildePath(Jsi_Interp *interp, const char* path, Jsi_DString *dStr) {\n    if (*path != '~')\n        return path;\n    const char *homedir = jsi_GetHomeDir(interp);\n    if (!homedir)\n        return path;\n    Jsi_DSAppend(dStr, homedir, path[1] == '\/' ? \"\" : \"\/\", path+1, NULL);\n    return Jsi_DSValue(dStr);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":498251,"func":"static inline bool verify_client_lsn(struct ntfs_log *log,\n\t\t\t\t     const struct CLIENT_REC *client, u64 lsn)\n{\n\treturn lsn >= le64_to_cpu(client->oldest_lsn) &&\n\t       lsn <= le64_to_cpu(log->ra->current_lsn) && lsn;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":492516,"func":"void FunctionContextImpl::free_local_allocations() {\n    for (int i = 0; i < _local_allocations.size(); ++i) {\n        _pool->free(_local_allocations[i]);\n    }\n\n    _local_allocations.clear();\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":364321,"func":"static int ISO8859_8ToUTF8 (unsigned char* out, int *outlen,\n    const unsigned char* in, int *inlen) {\n    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_8);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":460713,"func":"static char *addr_to_string(const char *format,\n                            struct sockaddr_storage *sa,\n                            socklen_t salen)\n{\n    char host[NI_MAXHOST];\n    char serv[NI_MAXSERV];\n    int err;\n\n    if ((err = getnameinfo((struct sockaddr *)sa, salen,\n                           host, sizeof(host),\n                           serv, sizeof(serv),\n                           NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {\n        spice_warning(\"Cannot resolve address %d: %s\",\n                      err, gai_strerror(err));\n        return NULL;\n    }\n\n    return g_strdup_printf(format, host, serv);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":437652,"func":"PHPAPI char* spl_filesystem_object_get_path(spl_filesystem_object *intern, size_t *len) \/* {{{ *\/\n{\n#ifdef HAVE_GLOB\n\tif (intern->type == SPL_FS_DIR) {\n\t\tif (php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {\n\t\t\treturn php_glob_stream_get_path(intern->u.dir.dirp, 0, len);\n\t\t}\n\t}\n#endif\n\tif (len) {\n\t\t*len = intern->_path_len;\n\t}\n\treturn intern->_path;\n} \/* }}} *\/","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":87438,"func":"panel_set_option(struct parsed_tagarg *arg)\n{\n    FILE *f = NULL;\n    char *p;\n    Str s = Strnew(), tmp;\n\n    if (config_file == NULL) {\n\tdisp_message(\"There's no config file... config not saved\", FALSE);\n    }\n    else {\n\tf = fopen(config_file, \"wt\");\n\tif (f == NULL) {\n\t    disp_message(\"Can't write option!\", FALSE);\n\t}\n    }\n    while (arg) {\n\t\/*  InnerCharset -> SystemCharset *\/\n\tif (arg->value) {\n\t    p = conv_to_system(arg->value);\n\t    if (set_param(arg->arg, p)) {\n\t\ttmp = Sprintf(\"%s %s\\n\", arg->arg, p);\n\t\tStrcat(tmp, s);\n\t\ts = tmp;\n\t    }\n\t}\n\targ = arg->next;\n    }\n    if (f) {\n\tfputs(s->ptr, f);\n\tfclose(f);\n    }\n    sync_with_option();\n    backBf();\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":421628,"func":"static inline int u128_cmp(u128_t x, u128_t y) {\n    \/* return -1, 0, 1 on sort order *\/\n    if(x.h < y.h)\n        return -1;\n    if(x.h > y.h)\n        return 1;\n    if(x.l < y.l)\n        return -1;\n    if(x.l > y.l)\n        return 1;\n    return 0;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":444289,"func":"bool ConnectionManagerImpl::ActiveStreamFilterBase::commonHandleAfterDataCallback(\n    FilterDataStatus status, Buffer::Instance& provided_data, bool& buffer_was_streaming) {\n\n  if (status == FilterDataStatus::Continue) {\n    if (iteration_state_ == IterationState::StopSingleIteration) {\n      commonHandleBufferData(provided_data);\n      commonContinue();\n      return false;\n    } else {\n      ASSERT(headers_continued_);\n    }\n  } else {\n    iteration_state_ = IterationState::StopSingleIteration;\n    if (status == FilterDataStatus::StopIterationAndBuffer ||\n        status == FilterDataStatus::StopIterationAndWatermark) {\n      buffer_was_streaming = status == FilterDataStatus::StopIterationAndWatermark;\n      commonHandleBufferData(provided_data);\n    } else if (complete() && !hasTrailers() && !bufferedData()) {\n      \/\/ If this filter is doing StopIterationNoBuffer and this stream is terminated with a zero\n      \/\/ byte data frame, we need to create an empty buffer to make sure that when commonContinue\n      \/\/ is called, the pipeline resumes with an empty data frame with end_stream = true\n      ASSERT(end_stream_);\n      bufferedData() = createBuffer();\n    }\n\n    return false;\n  }\n\n  return true;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":359386,"func":"static inline u32 tcf_auto_prio(struct tcf_proto *tp)\n{\n\tu32 first = TC_H_MAKE(0xC0000000U, 0U);\n\n\tif (tp)\n\t\tfirst = tp->prio-1;\n\n\treturn first;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":24553,"func":"static inline bool is_ra ( hb_codepoint_t u ) {\n for ( unsigned int i = 0 ;\n i < ARRAY_LENGTH ( ra_chars ) ;\n i ++ ) if ( u == ra_chars [ i ] ) return true ;\n return false ;\n }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":208621,"func":"void ThreadHeap::VerifyMarking() {\n  for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i) {\n    arenas_[i]->VerifyMarking();\n  }\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":223932,"func":"bool Layer::Update(ResourceUpdateQueue* queue,\n                   const OcclusionTracker<Layer>* occlusion) {\n  DCHECK(layer_tree_host_);\n  DCHECK_EQ(layer_tree_host_->source_frame_number(),\n            paint_properties_.source_frame_number) <<\n      \"SavePaintProperties must be called for any layer that is painted.\";\n  return false;\n}\n","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":201471,"func":"void LocalDOMWindow::DocumentWasClosed() {\n  DispatchWindowLoadEvent();\n  EnqueuePageshowEvent(kPageshowEventNotPersisted);\n  if (pending_state_object_)\n    EnqueuePopstateEvent(std::move(pending_state_object_));\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":70757,"func":"static void MagickPNGErrorHandler(png_struct *ping,png_const_charp message)\n{\n  ExceptionInfo\n    *exception;\n\n  Image\n    *image;\n\n  PNGErrorInfo\n    *error_info;\n\n  error_info=(PNGErrorInfo *) png_get_error_ptr(ping);\n  image=error_info->image;\n  exception=error_info->exception;\n\n  (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n    \"  libpng-%s error: %s\", png_get_libpng_ver(NULL),message);\n\n  (void) ThrowMagickException(exception,GetMagickModule(),CoderError,message,\n    \"`%s'\",image->filename);\n\n#if (PNG_LIBPNG_VER < 10500)\n  \/* A warning about deprecated use of jmpbuf here is unavoidable if you\n   * are building with libpng-1.4.x and can be ignored.\n   *\/\n  longjmp(ping->jmpbuf,1);\n#else\n  png_longjmp(ping,1);\n#endif\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":308642,"func":"void Instance::CreateHorizontalScrollbar() {\n  if (h_scrollbar_.get())\n    return;\n\n  h_scrollbar_.reset(new pp::Scrollbar_Dev(this, false));\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":284342,"func":"WebContentsViewDelegate* ContentBrowserClient::GetWebContentsViewDelegate(\n    WebContents* web_contents) {\n  return NULL;\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":181973,"func":"fbStore_b5g6r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)\n{\n    int i;\n    CARD16  *pixel = ((CARD16 *) bits) + x;\n    for (i = 0; i < width; ++i) {\n        Split(READ(values + i));\n        WRITE(pixel++, ((b << 8) & 0xf800) |\n\t      ((g << 3) & 0x07e0) |\n\t      ((r >> 3)         ));\n    }\n}\n","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":252767,"func":"void Con_Close( void ) {\n\tif ( !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\tField_Clear( &g_consoleField );\n\tCon_ClearNotify();\n\tKey_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CONSOLE );\n\tcon.finalFrac = 0;              \/\/ none visible\n\tcon.displayFrac = 0;\n}\n","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":221008,"func":"  explicit FindAdapter(Plugin* plugin)\n    : pp::Find_Dev(plugin),\n      plugin_(plugin) {\n    BrowserPpp* proxy = plugin_->ppapi_proxy();\n    CHECK(proxy != NULL);\n    ppp_find_ = static_cast<const PPP_Find_Dev*>(\n        proxy->GetPluginInterface(PPP_FIND_DEV_INTERFACE));\n  }\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":214418,"func":"FakeRemoteGattService* FakeCentral::GetFakeRemoteGattService(\n    const std::string& peripheral_address,\n    const std::string& service_id) const {\n  FakePeripheral* fake_peripheral = GetFakePeripheral(peripheral_address);\n  if (fake_peripheral == nullptr) {\n    return nullptr;\n  }\n\n  return static_cast<FakeRemoteGattService*>(\n      fake_peripheral->GetGattService(service_id));\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":172082,"func":"  _bdf_list_ensure( _bdf_list_t*   list,\n                    unsigned long  num_items ) \/* same as _bdf_list_t.used *\/\n  {\n    FT_Error  error = BDF_Err_Ok;\n\n\n    if ( num_items > list->size )\n    {\n      unsigned long  oldsize = list->size; \/* same as _bdf_list_t.size *\/\n      unsigned long  newsize = oldsize + ( oldsize >> 1 ) + 5;\n      unsigned long  bigsize = (unsigned long)( FT_INT_MAX \/ sizeof ( char* ) );\n      FT_Memory      memory  = list->memory;\n\n\n      if ( oldsize == bigsize )\n      {\n        error = BDF_Err_Out_Of_Memory;\n        goto Exit;\n      }\n      else if ( newsize < oldsize || newsize > bigsize )\n        newsize = bigsize;\n\n      if ( FT_RENEW_ARRAY( list->field, oldsize, newsize ) )\n        goto Exit;\n\n      list->size = newsize;\n    }\n\n  Exit:\n    return error;\n  }\n","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":191931,"func":"static void ByteStringMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  TestObject* impl = V8TestObject::ToImpl(info.Holder());\n\n  V8SetReturnValueString(info, impl->byteStringMethod(), info.GetIsolate());\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":309421,"func":"PHP_FUNCTION(pg_num_fields)\n{\n\tphp_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_NUM_FIELDS);\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":57693,"func":"void str_to_file(const char *fname, char *str, int size)\n{\n  str_to_file2(fname, str, size, FALSE);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":476478,"func":"static int xattr_map_client(const struct lo_data *lo, const char *client_name,\n                            char **out_name)\n{\n    size_t i;\n    for (i = 0; i < lo->xattr_map_nentries; i++) {\n        const XattrMapEntry *cur_entry = lo->xattr_map_list + i;\n\n        if ((cur_entry->flags & XATTR_MAP_FLAG_CLIENT) &&\n            (strstart(client_name, cur_entry->key, NULL))) {\n            if (cur_entry->flags & XATTR_MAP_FLAG_BAD) {\n                return -EPERM;\n            }\n            if (cur_entry->flags & XATTR_MAP_FLAG_UNSUPPORTED) {\n                return -ENOTSUP;\n            }\n            if (cur_entry->flags & XATTR_MAP_FLAG_OK) {\n                \/* Unmodified name *\/\n                return 0;\n            }\n            if (cur_entry->flags & XATTR_MAP_FLAG_PREFIX) {\n                *out_name = g_try_malloc(strlen(client_name) +\n                                         strlen(cur_entry->prepend) + 1);\n                if (!*out_name) {\n                    return -ENOMEM;\n                }\n                sprintf(*out_name, \"%s%s\", cur_entry->prepend, client_name);\n                return 0;\n            }\n        }\n    }\n\n    return -EPERM;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":116403,"func":"x86_Init(struct _7zip *zip)\n{\n\tzip->bcj_state = 0;\n\tzip->bcj_prevPosT = (size_t)0 - 1;\n\tzip->bcj_prevMask = 0;\n\tzip->bcj_ip = 5;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":78158,"func":"static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,\n\t\t\t\t     unsigned int optlen)\n{\n\tstruct sctp_sock *sp = sctp_sk(sk);\n\n\t\/* Applicable to UDP-style socket only *\/\n\tif (sctp_style(sk, TCP))\n\t\treturn -EOPNOTSUPP;\n\tif (optlen != sizeof(int))\n\t\treturn -EINVAL;\n\tif (copy_from_user(&sp->autoclose, optval, optlen))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":216578,"func":"void _WM_do_control_channel_expression(struct _mdi *mdi,\n                                          struct _event_data *data) {\n    uint8_t ch = data->channel;\n    MIDI_EVENT_DEBUG(__FUNCTION__,ch, data->data.value);\n\n    mdi->channel[ch].expression = data->data.value;\n    _WM_AdjustChannelVolumes(mdi, ch);\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":215217,"func":"isofile_add_entry(struct iso9660 *iso9660, struct isofile *file)\n{\n\tfile->allnext = NULL;\n\t*iso9660->all_file_list.last = file;\n\tiso9660->all_file_list.last = &(file->allnext);\n}\n","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":173505,"func":"    ClampScrollableAreas() {\n  for (auto& scrollable_area : NeedsClampList())\n    scrollable_area->ClampScrollOffsetAfterOverflowChange();\n  NeedsClampList().clear();\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":389737,"func":"static inline bool cpu_watchpoint_address_matches(CPUWatchpoint *wp,\n                                                  vaddr addr,\n                                                  vaddr len)\n{\n    \/* We know the lengths are non-zero, but a little caution is\n     * required to avoid errors in the case where the range ends\n     * exactly at the top of the address space and so addr + len\n     * wraps round to zero.\n     *\/\n    vaddr wpend = wp->vaddr + wp->len - 1;\n    vaddr addrend = addr + len - 1;\n\n    return !(addr > wpend || wp->vaddr > addrend);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":235206,"func":"void FileSystemOperationRunner::OnCopyProgress(\n    const OperationID id,\n    const CopyProgressCallback& callback,\n    FileSystemOperation::CopyProgressType type,\n    const FileSystemURL& source_url,\n    const FileSystemURL& dest_url,\n    int64_t size) {\n  if (is_beginning_operation_) {\n    base::ThreadTaskRunnerHandle::Get()->PostTask(\n        FROM_HERE,\n        base::BindOnce(&FileSystemOperationRunner::OnCopyProgress, weak_ptr_,\n                       id, callback, type, source_url, dest_url, size));\n    return;\n  }\n  callback.Run(type, source_url, dest_url, size);\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":96363,"func":"int inet_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\n\tif (sk) {\n\t\tlong timeout;\n\n\t\tsock_rps_reset_flow(sk);\n\n\t\t\/* Applications forget to leave groups before exiting *\/\n\t\tip_mc_drop_socket(sk);\n\n\t\t\/* If linger is set, we don't return until the close\n\t\t * is complete.  Otherwise we return immediately. The\n\t\t * actually closing is done the same either way.\n\t\t *\n\t\t * If the close is due to the process exiting, we never\n\t\t * linger..\n\t\t *\/\n\t\ttimeout = 0;\n\t\tif (sock_flag(sk, SOCK_LINGER) &&\n\t\t    !(current->flags & PF_EXITING))\n\t\t\ttimeout = sk->sk_lingertime;\n\t\tsock->sk = NULL;\n\t\tsk->sk_prot->close(sk, timeout);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":69715,"func":"  void setHandshakeKeys() {\n    conn_.handshakeWriteCipher = createNoOpAead();\n    conn_.handshakeWriteHeaderCipher = createNoOpHeaderCipher();\n    handshakeReadCipher_ = createNoOpAead();\n    handshakeReadHeaderCipher_ = createNoOpHeaderCipher();\n  }","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":163389,"func":"bool AwContents::OnReceivedHttpAuthRequest(const JavaRef<jobject>& handler,\n                                           const std::string& host,\n                                           const std::string& realm) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  JNIEnv* env = AttachCurrentThread();\n  ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);\n  if (obj.is_null())\n    return false;\n\n  ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host);\n  ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm);\n  devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback(\n      \"onReceivedHttpAuthRequest\");\n  Java_AwContents_onReceivedHttpAuthRequest(env, obj.obj(), handler.obj(),\n      jhost.obj(), jrealm.obj());\n  return true;\n}\n","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":452338,"func":"static gboolean si_io_channel_cb(GIOChannel  *source,\n                                 GIOCondition condition,\n                                 gpointer     data)\n{\n    active_session = session_info_get_active_session(session_info);\n    update_active_session_connection(NULL);\n    return G_SOURCE_CONTINUE;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":463041,"func":"NamespaceString IDLParserErrorContext::parseNSCollectionRequired(StringData dbName,\n                                                                 const BSONElement& element) {\n    const bool isUUID = (element.canonicalType() == canonicalizeBSONType(mongo::BinData) &&\n                         element.binDataType() == BinDataType::newUUID);\n    uassert(ErrorCodes::BadValue,\n            str::stream() << \"Collection name must be provided. UUID is not valid in this \"\n                          << \"context\",\n            !isUUID);\n    uassert(ErrorCodes::BadValue,\n            str::stream() << \"collection name has invalid type \" << typeName(element.type()),\n            element.canonicalType() == canonicalizeBSONType(mongo::String));\n\n    const NamespaceString nss(dbName, element.valueStringData());\n\n    uassert(ErrorCodes::InvalidNamespace,\n            str::stream() << \"Invalid namespace specified '\" << nss.ns() << \"'\",\n            nss.isValid());\n\n    return nss;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":57526,"func":"    QString Display::sessionType() const {\n        return m_displayServer->sessionType();\n    }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":224343,"func":"void Document::updateStyleForNodeIfNeeded(Node* node)\n{\n    if (!hasPendingForcedStyleRecalc() && !childNeedsStyleRecalc() && !needsStyleRecalc())\n        return;\n\n    bool needsStyleRecalc = hasPendingForcedStyleRecalc();\n    for (Node* ancestor = node; ancestor && !needsStyleRecalc; ancestor = ancestor->parentOrShadowHostNode())\n        needsStyleRecalc = ancestor->needsStyleRecalc();\n    if (needsStyleRecalc)\n        updateStyleIfNeeded();\n}\n","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":496555,"func":"  std::string index(Volume_iterator c) const\n  { return CI(c,verbose); }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":339708,"func":"static int bt_hci_parse(const char *str)\n\n{\n\n    struct HCIInfo *hci;\n\n    bdaddr_t bdaddr;\n\n\n\n    if (nb_hcis >= MAX_NICS) {\n\n        fprintf(stderr, \"qemu: Too many bluetooth HCIs (max %i).\\n\", MAX_NICS);\n\n        return -1;\n\n    }\n\n\n\n    hci = hci_init(str);\n\n    if (!hci)\n\n        return -1;\n\n\n\n    bdaddr.b[0] = 0x52;\n\n    bdaddr.b[1] = 0x54;\n\n    bdaddr.b[2] = 0x00;\n\n    bdaddr.b[3] = 0x12;\n\n    bdaddr.b[4] = 0x34;\n\n    bdaddr.b[5] = 0x56 + nb_hcis;\n\n    hci->bdaddr_set(hci, bdaddr.b);\n\n\n\n    hci_table[nb_hcis++] = hci;\n\n\n\n    return 0;\n\n}\n","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":474713,"func":"int nfc_tm_deactivated(struct nfc_dev *dev)\n{\n\tdev->dep_link_up = false;\n\tdev->rf_mode = NFC_RF_NONE;\n\n\treturn nfc_genl_tm_deactivated(dev);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":491949,"func":"static void wstunnel_handler_ctx_free(void *gwhctx) {\n    handler_ctx *hctx = (handler_ctx *)gwhctx;\n    chunk_buffer_release(hctx->frame.payload);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":55440,"func":"static __always_inline u32 vmcs_read32(unsigned long field)\n{\n\tvmcs_check32(field);\n\treturn __vmcs_readl(field);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":503476,"func":"static void restore_rgb_planes10(AVFrame *frame, int width, int height)\n{\n    uint16_t *src_r = (uint16_t *)frame->data[2];\n    uint16_t *src_g = (uint16_t *)frame->data[0];\n    uint16_t *src_b = (uint16_t *)frame->data[1];\n    int r, g, b;\n    int i, j;\n\n    for (j = 0; j < height; j++) {\n        for (i = 0; i < width; i++) {\n            r = src_r[i];\n            g = src_g[i];\n            b = src_b[i];\n            src_r[i] = (r + g - 0x200) & 0x3FF;\n            src_b[i] = (b + g - 0x200) & 0x3FF;\n        }\n        src_r += frame->linesize[2] \/ 2;\n        src_g += frame->linesize[0] \/ 2;\n        src_b += frame->linesize[1] \/ 2;\n    }\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":27103,"func":"static void test_select_version ( ) {\n MYSQL_STMT * stmt ;\n int rc ;\n myheader ( \"test_select_version\" ) ;\n stmt = mysql_simple_prepare ( mysql , \"SELECT @@version\" ) ;\n check_stmt ( stmt ) ;\n verify_param_count ( stmt , 0 ) ;\n rc = mysql_stmt_execute ( stmt ) ;\n check_execute ( stmt , rc ) ;\n my_process_stmt_result ( stmt ) ;\n mysql_stmt_close ( stmt ) ;\n }","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":433269,"func":"static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len)\n{\n\tstruct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr;\n\tstruct ieee802154_addr haddr;\n\tstruct dgram_sock *ro = dgram_sk(sk);\n\tint err = -EINVAL;\n\tstruct net_device *dev;\n\n\tlock_sock(sk);\n\n\tro->bound = 0;\n\n\tif (len < sizeof(*addr))\n\t\tgoto out;\n\n\tif (addr->family != AF_IEEE802154)\n\t\tgoto out;\n\n\tieee802154_addr_from_sa(&haddr, &addr->addr);\n\tdev = ieee802154_get_dev(sock_net(sk), &haddr);\n\tif (!dev) {\n\t\terr = -ENODEV;\n\t\tgoto out;\n\t}\n\n\tif (dev->type != ARPHRD_IEEE802154) {\n\t\terr = -ENODEV;\n\t\tgoto out_put;\n\t}\n\n\tro->src_addr = haddr;\n\n\tro->bound = 1;\n\terr = 0;\nout_put:\n\tdev_put(dev);\nout:\n\trelease_sock(sk);\n\n\treturn err;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":443071,"func":"static void shrink_ple_window(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tstruct vmcb_control_area *control = &svm->vmcb->control;\n\tint old = control->pause_filter_count;\n\n\tcontrol->pause_filter_count =\n\t\t\t\t__shrink_ple_window(old,\n\t\t\t\t\t\t    pause_filter_count,\n\t\t\t\t\t\t    pause_filter_count_shrink,\n\t\t\t\t\t\t    pause_filter_count);\n\tif (control->pause_filter_count != old) {\n\t\tmark_dirty(svm->vmcb, VMCB_INTERCEPTS);\n\t\ttrace_kvm_ple_window_update(vcpu->vcpu_id,\n\t\t\t\t\t    control->pause_filter_count, old);\n\t}\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":155124,"func":"GF_Err fiin_dump(GF_Box *a, FILE * trace)\n{\n\tFDItemInformationBox *ptr = (FDItemInformationBox *) a;\n\tgf_isom_box_dump_start(a, \"FDItemInformationBox\", trace);\n\n\tfprintf(trace, \">\\n\");\n\tif (ptr->partition_entries)\n\t\tgf_isom_box_array_dump(ptr->partition_entries, trace);\n\n\tif (ptr->session_info)\n\t\tgf_isom_box_dump(ptr->session_info, trace);\n\n\tif (ptr->group_id_to_name)\n\t\tgf_isom_box_dump(ptr->group_id_to_name, trace);\n\n\tgf_isom_box_dump_done(\"FDItemInformationBox\", a, trace);\n\treturn GF_OK;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":69646,"func":"int cil_resolve_blockinherit_link(struct cil_tree_node *current, void *extra_args)\n{\n\tstruct cil_blockinherit *inherit = current->data;\n\tstruct cil_symtab_datum *block_datum = NULL;\n\tstruct cil_tree_node *node = NULL;\n\tint rc = SEPOL_ERR;\n\n\trc = cil_resolve_name(current, inherit->block_str, CIL_SYM_BLOCKS, extra_args, &block_datum);\n\tif (rc != SEPOL_OK) {\n\t\tgoto exit;\n\t}\n\n\tnode = NODE(block_datum);\n\n\tif (node->flavor != CIL_BLOCK) {\n\t\tcil_log(CIL_ERR, \"%s is not a block\\n\", cil_node_to_string(node));\n\t\trc = SEPOL_ERR;\n\t\tgoto exit;\n\t}\n\n\tinherit->block = (struct cil_block *)block_datum;\n\n\tif (inherit->block->bi_nodes == NULL) {\n\t\tcil_list_init(&inherit->block->bi_nodes, CIL_NODE);\n\t}\n\tcil_list_append(inherit->block->bi_nodes, CIL_NODE, current);\n\n\treturn SEPOL_OK;\n\nexit:\n\treturn rc;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":219089,"func":"HTMLCollection* Document::anchors()\n{\n    return ensureCachedCollection<HTMLCollection>(DocAnchors);\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":6755,"func":"static inline __u16\tinet_getid(struct inet_peer *p, int more)\n{\n\tmore++;\n\tinet_peer_refcheck(p);\n\treturn atomic_add_return(more, &p->ip_id_count) - more;\n}","target":1,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":9620,"func":"static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,\n\t\t\t\t\tunsigned long addr, unsigned long end,\n\t\t\t\t\tstruct mm_walk *walk)\n{\n\tstruct vm_area_struct *vma = walk->private;\n\tpte_t *pte;\n \tspinlock_t *ptl;\n \n \tsplit_huge_page_pmd(walk->mm, pmd);\n \n \tpte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);\n \tfor (; addr != end; pte++, addr += PAGE_SIZE)\n\t\tif (is_target_pte_for_mc(vma, addr, *pte, NULL))\n\t\t\tmc.precharge++;\t\/* increment precharge temporarily *\/\n\tpte_unmap_unlock(pte - 1, ptl);\n\tcond_resched();\n\n\treturn 0;\n}\n","target":1,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":240369,"func":"jlong AwContents::CapturePicture(JNIEnv* env,\n                                 jobject obj,\n                                 int width,\n                                 int height) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  return reinterpret_cast<intptr_t>(\n      new AwPicture(browser_view_renderer_.CapturePicture(width, height)));\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":30166,"func":"METHOD ( x509_t , create_name_constraint_enumerator , enumerator_t * , private_x509_cert_t * this , bool perm ) {\n if ( perm ) {\n return this -> permitted_names -> create_enumerator ( this -> permitted_names ) ;\n }\n return this -> excluded_names -> create_enumerator ( this -> excluded_names ) ;\n }","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":132591,"func":"static int sctp_v6_is_any(const union sctp_addr *addr)\n{\n\treturn ipv6_addr_any(&addr->v6.sin6_addr);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":474313,"func":"int crypt_metadata_locking(struct crypt_device *cd __attribute__((unused)), int enable)\n{\n\tif (enable && !_metadata_locking)\n\t\treturn -EPERM;\n\n\t_metadata_locking = enable ? 1 : 0;\n\treturn 0;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":232743,"func":"DomDistillerViewerSource::RequestViewerHandle::RequestViewerHandle(\n    content::WebContents* web_contents,\n    const std::string& expected_scheme,\n    const std::string& expected_request_path,\n    DistilledPagePrefs* distilled_page_prefs)\n    : DomDistillerRequestViewBase(distilled_page_prefs),\n      expected_scheme_(expected_scheme),\n      expected_request_path_(expected_request_path),\n      waiting_for_page_ready_(true) {\n  content::WebContentsObserver::Observe(web_contents);\n  distilled_page_prefs_->AddObserver(this);\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":333089,"func":"av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {\n\n    c->rv34_inv_transform    = rv34_inv_transform_noround_c;\n\n    c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c;\n\n\n\n    c->rv34_idct_add    = rv34_idct_add_c;\n\n    c->rv34_idct_dc_add = rv34_idct_dc_add_c;\n\n\n\n    if (HAVE_NEON)\n\n        ff_rv34dsp_init_neon(c, dsp);\n\n    if (ARCH_X86)\n\n        ff_rv34dsp_init_x86(c, dsp);\n\n}\n","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":306867,"func":"bool ShouldQuicMigrateSessionsEarlyV2(\n    const VariationParameters& quic_trial_params) {\n  return base::LowerCaseEqualsASCII(\n      GetVariationParam(quic_trial_params, \"migrate_sessions_early_v2\"),\n      \"true\");\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":301025,"func":"smb_ofile_disallow_fclose(smb_ofile_t *of)\n{\n\tASSERT(of);\n\tASSERT(of->f_magic == SMB_OFILE_MAGIC);\n\tASSERT(of->f_refcnt);\n\n\tswitch (of->f_ftype) {\n\tcase SMB_FTYPE_DISK:\n\t\tASSERT(of->f_tree);\n\t\treturn (of->f_node == of->f_tree->t_snode);\n\n\tcase SMB_FTYPE_MESG_PIPE:\n\t\tASSERT(of->f_pipe);\n\t\tif (smb_strcasecmp(of->f_pipe->p_name, \"SRVSVC\", 0) == 0)\n\t\t\treturn (B_TRUE);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn (B_FALSE);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":404147,"func":"void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)\n{\n\tint pos = skb_headlen(skb);\n\n\tif (len < pos)\t\/* Split line is inside header. *\/\n\t\tskb_split_inside_header(skb, skb1, len, pos);\n\telse\t\t\/* Second chunk has no header, nothing to copy. *\/\n\t\tskb_split_no_header(skb, skb1, len, pos);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":110109,"func":"    template<typename t>\n    CImg(const CImg<t>& img, const char *const dimensions, const T& value):\n      _width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) {\n      assign(img,dimensions).fill(value);","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":49908,"func":"static void cmd_handle_fatal (IMAP_DATA* idata)\n{\n  idata->status = IMAP_FATAL;\n\n  if ((idata->state >= IMAP_SELECTED) &&\n      (idata->reopen & IMAP_REOPEN_ALLOW))\n  {\n    mx_fastclose_mailbox (idata->ctx);\n    mutt_socket_close (idata->conn);\n    mutt_error (_(\"Mailbox %s@%s closed\"),\n\tidata->conn->account.login, idata->conn->account.host);\n    mutt_sleep (1);\n    idata->state = IMAP_DISCONNECTED;\n  }\n\n  if (idata->state < IMAP_SELECTED)\n    imap_close_connection (idata);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":186873,"func":"static void emitnumber(JF, double num)\n{\n\tif (num == 0) {\n\t\temit(J, F, OP_NUMBER_0);\n\t\tif (signbit(num))\n\t\t\temit(J, F, OP_NEG);\n\t} else if (num == 1) {\n\t\temit(J, F, OP_NUMBER_1);\n\t} else if (num == (js_Instruction)num) {\n\t\temit(J, F, OP_NUMBER_POS);\n\t\temitraw(J, F, (js_Instruction)num);\n\t} else if (num < 0 && -num == (js_Instruction)(-num)) {\n\t\temit(J, F, OP_NUMBER_NEG);\n\t\temitraw(J, F, (js_Instruction)(-num));\n\t} else {\n\t\temit(J, F, OP_NUMBER);\n\t\temitraw(J, F, addnumber(J, F, num));\n\t}\n}\n","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":304167,"func":"StreamClose(pgsocket sock)\n{\n\tclosesocket(sock);\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":456846,"func":"static inline void *get_freepointer(struct kmem_cache *s, void *object)\n{\n\treturn freelist_dereference(s, object + s->offset);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":53460,"func":"void btd_adapter_register_msd_cb(struct btd_adapter *adapter,\n\t\t\t\t\t\t\tbtd_msd_cb_t cb)\n{\n\tadapter->msd_callbacks = g_slist_prepend(adapter->msd_callbacks, cb);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":370653,"func":"void ga_command_state_init(GAState *s, GACommandState *cs)\n{\n#if defined(CONFIG_FSFREEZE)\n    ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup);\n#endif\n    ga_command_state_add(cs, guest_file_init, NULL);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":481175,"func":"static struct kvm_rmap_head *gfn_to_rmap(gfn_t gfn, int level,\n\t\t\t\t\t const struct kvm_memory_slot *slot)\n{\n\tunsigned long idx;\n\n\tidx = gfn_to_index(gfn, slot->base_gfn, level);\n\treturn &slot->arch.rmap[level - PG_LEVEL_4K][idx];\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":391240,"func":"static void rng_egd_finalize(Object *obj)\n{\n    RngEgd *s = RNG_EGD(obj);\n\n    if (s->chr) {\n        qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, NULL);\n        qemu_chr_fe_release(s->chr);\n    }\n\n    g_free(s->chr_name);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":379336,"func":"static int ZEND_FASTCALL  ZEND_BW_OR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n{\n\tzend_op *opline = EX(opline);\n\tzend_free_op free_op1;\n\n\tbitwise_or_function(&EX_T(opline->result.u.var).tmp_var,\n\t\t_get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC),\n\t\t_get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC) TSRMLS_CC);\n\tif (free_op1.var) {zval_ptr_dtor(&free_op1.var);};\n\n\tZEND_VM_NEXT_OPCODE();\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":512905,"func":"void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {\n  GfxColor color;\n  int i;\n\n  if (textHaveCSPattern && drawText) {\n    GBool needFill = out->deviceHasTextClip(state);\n    out->endTextObject(state);\n    if (needFill) {\n      doPatternFill(gTrue);\n    }\n    out->restoreState(state);\n  }\n  state->setFillPattern(NULL);\n  state->setFillColorSpace(new GfxDeviceCMYKColorSpace());\n  out->updateFillColorSpace(state);\n  for (i = 0; i < 4; ++i) {\n    color.c[i] = dblToCol(args[i].getNum());\n  }\n  state->setFillColor(&color);\n  out->updateFillColor(state);\n  if (textHaveCSPattern) {\n    out->beginTextObject(state);\n    out->updateRender(state);\n    out->updateTextMat(state);\n    out->updateTextPos(state);\n    textHaveCSPattern = gFalse;\n  }\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":278941,"func":"static inline void ohci_set_interrupt(OHCIState *ohci, uint32_t intr)\n{\n    ohci->intr_status |= intr;\n    ohci_intr_update(ohci);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":19833,"func":"static cmsBool ReadOneElem ( cmsIOHANDLER * io , _cmsDICelem * e , cmsUInt32Number i , cmsUInt32Number BaseOffset ) {\n if ( ! _cmsReadUInt32Number ( io , & e -> Offsets [ i ] ) ) return FALSE ;\n if ( ! _cmsReadUInt32Number ( io , & e -> Sizes [ i ] ) ) return FALSE ;\n if ( e -> Offsets [ i ] > 0 ) e -> Offsets [ i ] += BaseOffset ;\n return TRUE ;\n }","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":168503,"func":"bool RenderLayerCompositor::requiresCompositingForTransform(RenderObject* renderer) const\n{\n    if (!(m_compositingTriggers & ChromeClient::ThreeDTransformTrigger))\n        return false;\n\n    RenderStyle* style = renderer->style();\n    return renderer->hasTransform() && style->transform().has3DOperation();\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":108815,"func":"  ~KeyedDenseTensorColumn() override {}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":402356,"func":"static void ehci_class_init(ObjectClass *klass, void *data)\n{\n    DeviceClass *dc = DEVICE_CLASS(klass);\n    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);\n\n    k->realize = usb_ehci_pci_realize;\n    k->exit = usb_ehci_pci_exit;\n    k->class_id = PCI_CLASS_SERIAL_USB;\n    k->config_write = usb_ehci_pci_write_config;\n    dc->vmsd = &vmstate_ehci_pci;\n    dc->props = ehci_pci_properties;\n    dc->reset = usb_ehci_pci_reset;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":288911,"func":"static void Type_LUTA2B_Free ( struct _cms_typehandler_struct * self , void * Ptr ) {\n cmsPipelineFree ( ( cmsPipeline * ) Ptr ) ;\n return ;\n cmsUNUSED_PARAMETER ( self ) ;\n }","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":400324,"func":"void am_cache_delete(server_rec *s, am_cache_entry_t *cache)\n{\n    \/* We write a null-byte at the beginning of the key to\n     * mark this slot as unused. \n     *\/\n    cache->key[0] = '\\0';\n\n    \/* Unlock the entry. *\/\n    am_cache_unlock(s, cache);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":244099,"func":"void InputDispatcher::drainInboundQueueLocked() {\n while (! mInboundQueue.isEmpty()) {\n EventEntry* entry = mInboundQueue.dequeueAtHead();\n        releaseInboundEventLocked(entry);\n }\n    traceInboundQueueLengthLocked();\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":245148,"func":"RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {\n  DCHECK(task_runner_->RunsTasksInCurrentSequence());\n\n  Stop();\n\n  GetPeerConnectionHandlers()->erase(this);\n  if (peer_connection_tracker_)\n    peer_connection_tracker_->UnregisterPeerConnection(this);\n\n  UMA_HISTOGRAM_COUNTS_10000(\n      \"WebRTC.NumDataChannelsPerPeerConnection\", num_data_channels_created_);\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":80545,"func":"static int OGRExpatUnknownEncodingHandler(\n    void * \/* unused_encodingHandlerData *\/,\n    const XML_Char *name,\n    XML_Encoding *info )\n{\n    if( EQUAL(name, \"WINDOWS-1252\") )\n        FillWINDOWS1252(info);\n    else if( EQUAL(name, \"ISO-8859-15\") )\n        FillISO885915(info);\n    else\n    {\n        CPLDebug(\"OGR\", \"Unhandled encoding %s\", name);\n        return XML_STATUS_ERROR;\n    }\n\n    info->data    = nullptr;\n    info->convert = nullptr;\n    info->release = nullptr;\n\n    return XML_STATUS_OK;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":461113,"func":"static char* sdl_deserialize_string(char **in)\n{\n\tchar *s;\n\tint len;\n\n\tWSDL_CACHE_GET_INT(len, in);\n\tif (len == WSDL_NO_STRING_MARKER) {\n\t\treturn NULL;\n\t} else {\n\t\ts = emalloc(len+1);\n\t\tWSDL_CACHE_GET_N(s, len, in);\n\t\ts[len] = '\\0';\n\t\treturn s;\n\t}\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":9796,"func":" DirectoryEntrySync* DirectoryEntrySync::getDirectory(const String& path, const Dictionary& options, ExceptionState& exceptionState)\n {\n     FileSystemFlags flags(options);\n    RefPtr<EntrySyncCallbackHelper> helper = EntrySyncCallbackHelper::create();\n     m_fileSystem->getDirectory(this, path, flags, helper->successCallback(), helper->errorCallback(), DOMFileSystemBase::Synchronous);\n     return static_cast<DirectoryEntrySync*>(helper->getResult(exceptionState));\n }\n","target":1,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":214163,"func":"  explicit CloseWindowTask(Browser* browser) : browser_(browser) {}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":360026,"func":"find_monitor (NautilusDirectory *directory,\n\t      NautilusFile *file,\n\t      gconstpointer client)\n{\n\tMonitor monitor;\n\n\tmonitor.client = client;\n\tmonitor.file = file;\n\n\treturn g_list_find_custom (directory->details->monitor_list,\n\t\t\t\t   &monitor,\n\t\t\t\t   monitor_key_compare);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":302529,"func":"header_cache_t *nntp_hcache_open(struct NntpData *nntp_data)\n{\n  struct Url url;\n  char file[PATH_MAX];\n\n  if (!nntp_data->nserv || !nntp_data->nserv->cacheable ||\n      !nntp_data->nserv->conn || !nntp_data->group ||\n      !(nntp_data->newsrc_ent || nntp_data->subscribed || SaveUnsubscribed))\n  {\n    return NULL;\n  }\n\n  mutt_account_tourl(&nntp_data->nserv->conn->account, &url);\n  url.path = nntp_data->group;\n  url_tostring(&url, file, sizeof(file), U_PATH);\n  return mutt_hcache_open(NewsCacheDir, file, nntp_hcache_namer);\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":355590,"func":"init_sched_build_groups(const cpumask_t *span, const cpumask_t *cpu_map,\n\t\t\tint (*group_fn)(int cpu, const cpumask_t *cpu_map,\n\t\t\t\t\tstruct sched_group **sg,\n\t\t\t\t\tcpumask_t *tmpmask),\n\t\t\tcpumask_t *covered, cpumask_t *tmpmask)\n{\n\tstruct sched_group *first = NULL, *last = NULL;\n\tint i;\n\n\tcpus_clear(*covered);\n\n\tfor_each_cpu_mask(i, *span) {\n\t\tstruct sched_group *sg;\n\t\tint group = group_fn(i, cpu_map, &sg, tmpmask);\n\t\tint j;\n\n\t\tif (cpu_isset(i, *covered))\n\t\t\tcontinue;\n\n\t\tcpus_clear(sg->cpumask);\n\t\tsg->__cpu_power = 0;\n\n\t\tfor_each_cpu_mask(j, *span) {\n\t\t\tif (group_fn(j, cpu_map, NULL, tmpmask) != group)\n\t\t\t\tcontinue;\n\n\t\t\tcpu_set(j, *covered);\n\t\t\tcpu_set(j, sg->cpumask);\n\t\t}\n\t\tif (!first)\n\t\t\tfirst = sg;\n\t\tif (last)\n\t\t\tlast->next = sg;\n\t\tlast = sg;\n\t}\n\tlast->next = first;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":223690,"func":"  virtual void EnableWifiNetworkDevice(bool enable) {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":501537,"func":"TEST_F(TcpHealthCheckerImplTest, WrongData) {\n  InSequence s;\n\n  setupDataDontReuseConnection();\n  cluster_->prioritySet().getMockHostSet(0)->hosts_ = {\n      makeTestHost(cluster_->info_, \"tcp:\/\/127.0.0.1:80\", simTime())};\n  expectSessionCreate();\n  expectClientCreate();\n  EXPECT_CALL(*connection_, write(_, _));\n  EXPECT_CALL(*timeout_timer_, enableTimer(_, _));\n  health_checker_->start();\n\n  connection_->raiseEvent(Network::ConnectionEvent::Connected);\n\n  \/\/ Not the expected response\n  Buffer::OwnedImpl response;\n  addUint8(response, 3);\n  read_filter_->onData(response, false);\n\n  \/\/ These are the expected metric results after testing.\n  EXPECT_EQ(0UL, cluster_->info_->stats_store_.counter(\"health_check.success\").value());\n  \/\/ TODO(lilika): The TCP health checker does generic pattern matching so we can't differentiate\n  \/\/ between wrong data and not enough data. We could likely do better here and figure out cases in\n  \/\/ which a match is not possible but that is not done now.\n  EXPECT_EQ(0UL, cluster_->info_->stats_store_.counter(\"health_check.failure\").value());\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":295777,"func":"support_nvme_encapsulation_show(struct device_driver *dd, char *buf)\n{\n\treturn sprintf(buf, \"%u\\n\", support_nvme_encapsulation);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":67951,"func":"void __fastcall TSCPFileSystem::Source(\r\n  TLocalFileHandle & \/*Handle*\/, const UnicodeString & \/*TargetDir*\/, UnicodeString & \/*DestFileName*\/,\r\n  const TCopyParamType * \/*CopyParam*\/, int \/*Params*\/,\r\n  TFileOperationProgressType * \/*OperationProgress*\/, unsigned int \/*Flags*\/,\r\n  TUploadSessionAction & \/*Action*\/, bool & \/*ChildError*\/)\r\n{\r\n  DebugFail();\r\n}\r","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":193673,"func":"void BrowserView::CreateLauncherIcon() {\n#if defined(USE_ASH)\n  if (chrome::IsNativeWindowInAsh(GetNativeWindow()) &&\n      !launcher_item_controller_.get()) {\n    launcher_item_controller_.reset(\n        BrowserLauncherItemController::Create(browser_.get()));\n  }\n#endif  \/\/ defined(USE_ASH)\n}\n","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":466216,"func":"TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsDisarmedOnCompleteRequestWithData) {\n  request_timeout_ = std::chrono::milliseconds(10);\n  setup(false, \"\");\n\n  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> Http::Status {\n    Event::MockTimer* request_timer = setUpTimer();\n    EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _));\n\n    decoder_ = &conn_manager_->newStream(response_encoder_);\n    RequestHeaderMapPtr headers{\n        new TestRequestHeaderMapImpl{{\":authority\", \"host\"}, {\":path\", \"\/\"}, {\":method\", \"POST\"}}};\n    decoder_->decodeHeaders(std::move(headers), false);\n\n    EXPECT_CALL(*request_timer, disableTimer()).Times(2);\n    decoder_->decodeData(data, true);\n    return Http::okStatus();\n  }));\n\n  Buffer::OwnedImpl fake_input(\"1234\");\n  conn_manager_->onData(fake_input, false);\n\n  EXPECT_EQ(0U, stats_.named_.downstream_rq_timeout_.value());\n\n  expectOnDestroy();\n  filter_callbacks_.connection_.raiseEvent(Network::ConnectionEvent::RemoteClose);\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":402404,"func":"eddsa_encodempi (gcry_mpi_t mpi, unsigned int minlen,\n                 unsigned char **r_buffer, unsigned int *r_buflen)\n{\n  unsigned char *rawmpi;\n  unsigned int rawmpilen;\n\n  rawmpi = _gcry_mpi_get_buffer (mpi, minlen, &rawmpilen, NULL);\n  if (!rawmpi)\n    return gpg_err_code_from_syserror ();\n\n  *r_buffer = rawmpi;\n  *r_buflen = rawmpilen;\n  return 0;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":307624,"func":"AXObject* AXNodeObject::activeDescendant() {\n  if (!m_node || !m_node->isElementNode())\n    return nullptr;\n\n  const AtomicString& activeDescendantAttr =\n      getAttribute(aria_activedescendantAttr);\n  if (activeDescendantAttr.isNull() || activeDescendantAttr.isEmpty())\n    return nullptr;\n\n  Element* element = toElement(getNode());\n  Element* descendant =\n      element->treeScope().getElementById(activeDescendantAttr);\n  if (!descendant)\n    return nullptr;\n\n  AXObject* axDescendant = axObjectCache().getOrCreate(descendant);\n  return axDescendant;\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":257556,"func":"int vp8_update_reference ( VP8_COMP * cpi , int ref_frame_flags ) {\n if ( ref_frame_flags > 7 ) return - 1 ;\n cpi -> common . refresh_golden_frame = 0 ;\n cpi -> common . refresh_alt_ref_frame = 0 ;\n cpi -> common . refresh_last_frame = 0 ;\n if ( ref_frame_flags & VP8_LAST_FRAME ) cpi -> common . refresh_last_frame = 1 ;\n if ( ref_frame_flags & VP8_GOLD_FRAME ) cpi -> common . refresh_golden_frame = 1 ;\n if ( ref_frame_flags & VP8_ALTR_FRAME ) cpi -> common . refresh_alt_ref_frame = 1 ;\n return 0 ;\n }","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":219940,"func":"static void AddHistogramSample(void* hist, int sample) {\n  Histogram* histogram = static_cast<Histogram *>(hist);\n  histogram->Add(sample);\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":342231,"func":"static void report_unsupported_feature(BlockDriverState *bs,\n\n    Error **errp, Qcow2Feature *table, uint64_t mask)\n\n{\n\n    while (table && table->name[0] != '\\0') {\n\n        if (table->type == QCOW2_FEAT_TYPE_INCOMPATIBLE) {\n\n            if (mask & (1 << table->bit)) {\n\n                report_unsupported(bs, errp, \"%.46s\", table->name);\n\n                mask &= ~(1 << table->bit);\n\n            }\n\n        }\n\n        table++;\n\n    }\n\n\n\n    if (mask) {\n\n        report_unsupported(bs, errp, \"Unknown incompatible feature: %\" PRIx64,\n\n                           mask);\n\n    }\n\n}\n","target":1,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":271713,"func":"static u32 tcp_v6_init_ts_off(const struct sk_buff *skb)\n{\n\treturn secure_tcpv6_ts_off(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\t   ipv6_hdr(skb)->saddr.s6_addr32);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":221020,"func":"void ChildProcessSecurityPolicyImpl::Remove(int child_id) {\n  base::AutoLock lock(lock_);\n  if (!security_state_.count(child_id))\n    return;  \/\/ May be called multiple times.\n\n  delete security_state_[child_id];\n  security_state_.erase(child_id);\n  worker_map_.erase(child_id);\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":122770,"func":"static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff)\n{\n  var->type= SHOW_CHAR;\n  var->value= buff;\n  if (thd->vio_ok() && thd->net.vio->ssl_arg)\n  {\n    int i;\n    const char *p;\n    char *end= buff + SHOW_VAR_FUNC_BUFF_SIZE;\n    for (i=0; (p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i)) &&\n               buff < end; i++)\n    {\n      buff= strnmov(buff, p, end-buff-1);\n      *buff++= ':';\n    }\n    if (i)\n      buff--;\n  }\n  *buff=0;\n  return 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":425278,"func":"static void intel_iommu_get_resv_regions(struct device *device,\n\t\t\t\t\t struct list_head *head)\n{\n\tstruct iommu_resv_region *reg;\n\tstruct dmar_rmrr_unit *rmrr;\n\tstruct device *i_dev;\n\tint i;\n\n\trcu_read_lock();\n\tfor_each_rmrr_units(rmrr) {\n\t\tfor_each_active_dev_scope(rmrr->devices, rmrr->devices_cnt,\n\t\t\t\t\t  i, i_dev) {\n\t\t\tif (i_dev != device)\n\t\t\t\tcontinue;\n\n\t\t\tlist_add_tail(&rmrr->resv->list, head);\n\t\t}\n\t}\n\trcu_read_unlock();\n\n\treg = iommu_alloc_resv_region(IOAPIC_RANGE_START,\n\t\t\t\t      IOAPIC_RANGE_END - IOAPIC_RANGE_START + 1,\n\t\t\t\t      0, IOMMU_RESV_MSI);\n\tif (!reg)\n\t\treturn;\n\tlist_add_tail(®->list, head);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":240226,"func":"nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,\n\t     struct nfsd4_commit *commit)\n{\n\tgen_boot_verifier(&commit->co_verf, SVC_NET(rqstp));\n\treturn nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset,\n\t\t\t     commit->co_count);\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":399269,"func":"static void test_wl5968()\n{\n  int rc;\n\n  myheader(\"test_wl5968\");\n\n  rc= mysql_query(mysql, \"START TRANSACTION\");\n  myquery(rc);\n  DIE_UNLESS(mysql->server_status & SERVER_STATUS_IN_TRANS);\n  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS_READONLY));\n  rc= mysql_query(mysql, \"COMMIT\");\n  myquery(rc);\n  rc= mysql_query(mysql, \"START TRANSACTION READ ONLY\");\n  myquery(rc);\n  DIE_UNLESS(mysql->server_status & SERVER_STATUS_IN_TRANS);\n  DIE_UNLESS(mysql->server_status & SERVER_STATUS_IN_TRANS_READONLY);\n  rc= mysql_query(mysql, \"COMMIT\");\n  myquery(rc);\n  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS));\n  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS_READONLY));\n  rc= mysql_query(mysql, \"START TRANSACTION\");\n  myquery(rc);\n  DIE_UNLESS(mysql->server_status & SERVER_STATUS_IN_TRANS);\n  DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_IN_TRANS_READONLY));\n  rc= mysql_query(mysql, \"COMMIT\");\n  myquery(rc);\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":183114,"func":"void DocumentLoader::SetSubresourceFilter(\n    SubresourceFilter* subresource_filter) {\n  subresource_filter_ = subresource_filter;\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":479268,"func":"    bool containsXYZC(const int x, const int y=0, const int z=0, const int c=0) const {\n      return !is_empty() && x>=0 && x<width() && y>=0 && y<height() && z>=0 && z<depth() && c>=0 && c<spectrum();\n    }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":112945,"func":"static int common_timer_create(struct k_itimer *new_timer)\n{\n\thrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);\n\treturn 0;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":436821,"func":"void repo_read_gitmodules(struct repository *repo)\n{\n\tsubmodule_cache_check_init(repo);\n\n\tif (repo->worktree) {\n\t\tchar *gitmodules;\n\n\t\tif (repo_read_index(repo) < 0)\n\t\t\treturn;\n\n\t\tgitmodules = repo_worktree_path(repo, GITMODULES_FILE);\n\n\t\tif (!is_gitmodules_unmerged(repo->index))\n\t\t\tgit_config_from_file(gitmodules_cb, gitmodules, repo);\n\n\t\tfree(gitmodules);\n\t}\n\n\trepo->submodule_cache->gitmodules_read = 1;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":18207,"func":"static int parse_streaminfo ( FLACContext * s , const uint8_t * buf , int buf_size ) {\n int metadata_type , metadata_size , ret ;\n if ( buf_size < FLAC_STREAMINFO_SIZE + 8 ) {\n return 0 ;\n }\n avpriv_flac_parse_block_header ( & buf [ 4 ] , NULL , & metadata_type , & metadata_size ) ;\n if ( metadata_type != FLAC_METADATA_TYPE_STREAMINFO || metadata_size != FLAC_STREAMINFO_SIZE ) {\n return AVERROR_INVALIDDATA ;\n }\n avpriv_flac_parse_streaminfo ( s -> avctx , ( FLACStreaminfo * ) s , & buf [ 8 ] ) ;\n ret = allocate_buffers ( s ) ;\n if ( ret < 0 ) return ret ;\n flac_set_bps ( s ) ;\n ff_flacdsp_init ( & s -> dsp , s -> avctx -> sample_fmt , s -> bps ) ;\n s -> got_streaminfo = 1 ;\n return 0 ;\n }","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":366881,"func":"static int cap_tun_dev_attach(struct sock *sk)\n{\n\treturn 0;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":363371,"func":"gdm_session_settings_get_layout_name (GdmSessionSettings *settings)\n{\n        g_return_val_if_fail (GDM_IS_SESSION_SETTINGS (settings), NULL);\n        return g_strdup (settings->priv->layout_name);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":464702,"func":"int xt_find_revision(u8 af, const char *name, u8 revision, int target,\n\t\t     int *err)\n{\n\tint have_rev, best = -1;\n\n\tif (target == 1)\n\t\thave_rev = target_revfn(af, name, revision, &best);\n\telse\n\t\thave_rev = match_revfn(af, name, revision, &best);\n\n\t\/* Nothing at all?  Return 0 to try loading module. *\/\n\tif (best == -1) {\n\t\t*err = -ENOENT;\n\t\treturn 0;\n\t}\n\n\t*err = best;\n\tif (!have_rev)\n\t\t*err = -EPROTONOSUPPORT;\n\treturn 1;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":458588,"func":"dp_packet_set_l2_pad_size(struct dp_packet *b, uint16_t pad_size)\n{\n    ovs_assert(pad_size <= dp_packet_size(b));\n    b->l2_pad_size = pad_size;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":76588,"func":"convertToPassage(const int pass_start, const int pass_end, const int word_start,\n\t\tEmphasisInfo *buffer, const EmphRuleNumber emphRule, const EmphasisClass class,\n\t\tconst TranslationTableHeader *table, unsigned int *wordBuffer) {\n\tint i;\n\tconst TranslationTableRule *indicRule;\n\n\tfor (i = pass_start; i <= pass_end; i++)\n\t\tif (wordBuffer[i] & WORD_WHOLE) {\n\t\t\tbuffer[i].symbol &= ~class;\n\t\t\tbuffer[i].word &= ~class;\n\t\t\twordBuffer[i] &= ~WORD_WHOLE;\n\t\t}\n\n\tbuffer[pass_start].begin |= class;\n\tif (brailleIndicatorDefined(\n\t\t\t\ttable->emphRules[emphRule][endOffset], table, &indicRule) ||\n\t\t\tbrailleIndicatorDefined(\n\t\t\t\t\ttable->emphRules[emphRule][endPhraseAfterOffset], table, &indicRule))\n\t\tbuffer[pass_end].end |= class;\n\telse if (brailleIndicatorDefined(table->emphRules[emphRule][endPhraseBeforeOffset],\n\t\t\t\t\t table, &indicRule))\n\t\tbuffer[word_start].end |= class;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":333742,"func":"static int cmos_get_fd_drive_type(FloppyDriveType fd0)\n\n{\n\n    int val;\n\n\n\n    switch (fd0) {\n\n    case FLOPPY_DRIVE_TYPE_144:\n\n        \/* 1.44 Mb 3\"5 drive *\/\n\n        val = 4;\n\n        break;\n\n    case FLOPPY_DRIVE_TYPE_288:\n\n        \/* 2.88 Mb 3\"5 drive *\/\n\n        val = 5;\n\n        break;\n\n    case FLOPPY_DRIVE_TYPE_120:\n\n        \/* 1.2 Mb 5\"5 drive *\/\n\n        val = 2;\n\n        break;\n\n    case FLOPPY_DRIVE_TYPE_NONE:\n\n    default:\n\n        val = 0;\n\n        break;\n\n    }\n\n    return val;\n\n}\n","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":8032,"func":"PHP_FUNCTION(locale_accept_from_http)\n{\n\tUEnumeration *available;\n\tchar *http_accept = NULL;\n\tint http_accept_len;\n\tUErrorCode status = 0;\n\tint len;\n\tchar resultLocale[INTL_MAX_LOCALE_LEN+1];\n\tUAcceptResult outResult;\n\n\tif(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &http_accept, &http_accept_len) == FAILURE)\n\t{\n\t\tintl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,\n\t\t\"locale_accept_from_http: unable to parse input parameters\", 0 TSRMLS_CC );\n\t\tRETURN_FALSE;\n\t}\n\t\n\tavailable = ures_openAvailableLocales(NULL, &status);\n\tINTL_CHECK_STATUS(status, \"locale_accept_from_http: failed to retrieve locale list\");\n\tlen = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN, \n\t\t\t\t\t\t&outResult, http_accept, available, &status);\n\tuenum_close(available);\n\tINTL_CHECK_STATUS(status, \"locale_accept_from_http: failed to find acceptable locale\");\n\tif (len < 0 || outResult == ULOC_ACCEPT_FAILED) {\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_STRINGL(resultLocale, len, 1);\n}","target":1,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":193302,"func":"base::PendingTask TaskQueue::TakeTaskFromWorkQueue() {\n  base::PendingTask pending_task = work_queue_.front();\n  work_queue_.pop();\n  TraceQueueSize(false);\n  return pending_task;\n}\n","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":256391,"func":" void ScrollHitTestDisplayItem::Record(\n     GraphicsContext& context,\n     const DisplayItemClient& client,\n     DisplayItem::Type type,\n    scoped_refptr<const TransformPaintPropertyNode> scroll_offset_node) {\n   PaintController& paint_controller = context.GetPaintController();\n \n   DCHECK_NE(paint_controller.CurrentPaintChunkProperties().Transform(),\n            scroll_offset_node.get());\n \n   if (paint_controller.DisplayItemConstructionIsDisabled())\n     return;\n \n   paint_controller.CreateAndAppend<ScrollHitTestDisplayItem>(\n      client, type, std::move(scroll_offset_node));\n }\n","target":1,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":344388,"func":"static void qxl_reset_surfaces(PCIQXLDevice *d)\n{\n    dprint(d, 1, \"%s:\\n\", __FUNCTION__);\n    d->mode = QXL_MODE_UNDEFINED;\n    qxl_spice_destroy_surfaces(d);\n}","target":1,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":449389,"func":"size_t CanonicalQuery::countNodes(const MatchExpression* root, MatchExpression::MatchType type) {\n    size_t sum = 0;\n    if (type == root->matchType()) {\n        sum = 1;\n    }\n    for (size_t i = 0; i < root->numChildren(); ++i) {\n        sum += countNodes(root->getChild(i), type);\n    }\n    return sum;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":382190,"func":"is_next_separator(FormatNode *n)\n{\n\tif (n->type == NODE_TYPE_END)\n\t\treturn FALSE;\n\n\tif (n->type == NODE_TYPE_ACTION && S_THth(n->suffix))\n\t\treturn TRUE;\n\n\t\/*\n\t * Next node\n\t *\/\n\tn++;\n\n\t\/* end of format string is treated like a non-digit separator *\/\n\tif (n->type == NODE_TYPE_END)\n\t\treturn TRUE;\n\n\tif (n->type == NODE_TYPE_ACTION)\n\t{\n\t\tif (n->key->is_digit)\n\t\t\treturn FALSE;\n\n\t\treturn TRUE;\n\t}\n\telse if (isdigit((unsigned char) n->character))\n\t\treturn FALSE;\n\n\treturn TRUE;\t\t\t\t\/* some non-digit input (separator) *\/\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":138795,"func":"BGD_DECLARE(void) gdImageDestroy (gdImagePtr im)\n{\n\tint i;\n\tif (im->pixels) {\n\t\tfor (i = 0; (i < im->sy); i++) {\n\t\t\tgdFree (im->pixels[i]);\n\t\t}\n\t\tgdFree (im->pixels);\n\t}\n\tif (im->tpixels) {\n\t\tfor (i = 0; (i < im->sy); i++) {\n\t\t\tgdFree (im->tpixels[i]);\n\t\t}\n\t\tgdFree (im->tpixels);\n\t}\n\tif (im->polyInts) {\n\t\tgdFree (im->polyInts);\n\t}\n\tif (im->style) {\n\t\tgdFree (im->style);\n\t}\n\tgdFree (im);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":51608,"func":"rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)\n{\n\tint phy_addr;\n\tstruct netdev_private *np = netdev_priv(dev);\n\tstruct mii_ioctl_data *miidata = if_mii(rq);\n\n\tphy_addr = np->phy_addr;\n\tswitch (cmd) {\n\tcase SIOCGMIIPHY:\n\t\tmiidata->phy_id = phy_addr;\n\t\tbreak;\n\tcase SIOCGMIIREG:\n\t\tmiidata->val_out = mii_read (dev, phy_addr, miidata->reg_num);\n\t\tbreak;\n\tcase SIOCSMIIREG:\n\t\tif (!capable(CAP_NET_ADMIN))\n\t\t\treturn -EPERM;\n\t\tmii_write (dev, phy_addr, miidata->reg_num, miidata->val_in);\n\t\tbreak;\n\tdefault:\n\t\treturn -EOPNOTSUPP;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":116690,"func":"static void gen_leave(DisasContext *s)\n{\n    TCGMemOp d_ot = mo_pushpop(s, s->dflag);\n    TCGMemOp a_ot = mo_stacksize(s);\n\n    gen_lea_v_seg(s, a_ot, cpu_regs[R_EBP], R_SS, -1);\n    gen_op_ld_v(s, d_ot, cpu_T0, cpu_A0);\n\n    tcg_gen_addi_tl(cpu_T1, cpu_regs[R_EBP], 1 << d_ot);\n\n    gen_op_mov_reg_v(d_ot, R_EBP, cpu_T0);\n    gen_op_mov_reg_v(a_ot, R_ESP, cpu_T1);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":427613,"func":"static bool ipv4_datagram_support_cmsg(const struct sock *sk,\n\t\t\t\t       struct sk_buff *skb,\n\t\t\t\t       int ee_origin)\n{\n\tstruct in_pktinfo *info;\n\n\tif (ee_origin == SO_EE_ORIGIN_ICMP)\n\t\treturn true;\n\n\tif (ee_origin == SO_EE_ORIGIN_LOCAL)\n\t\treturn false;\n\n\t\/* Support IP_PKTINFO on tstamp packets if requested, to correlate\n\t * timestamp with egress dev. Not possible for packets without iif\n\t * or without payload (SOF_TIMESTAMPING_OPT_TSONLY).\n\t *\/\n\tinfo = PKTINFO_SKB_CB(skb);\n\tif (!(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_CMSG) ||\n\t    !info->ipi_ifindex)\n\t\treturn false;\n\n\tinfo->ipi_spec_dst.s_addr = ip_hdr(skb)->saddr;\n\treturn true;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":403241,"func":"krb5_ticket_get_endtime(krb5_context context,\n\t\t\tconst krb5_ticket *ticket)\n{\n    return ticket->ticket.endtime;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":81439,"func":"static NORETURN void die_startup(void)\n{\n\tfputs(\"fatal: not enough memory for initialization\", stderr);\n\texit(128);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":466721,"func":"create_syncinfo_value(int type, const char *cookie, const char **uuids)\n{\n    BerElement *ber;\n    struct berval *bvp = NULL;\n\n    if ((ber = der_alloc()) == NULL) {\n        return (NULL);\n    }\n\n    switch (type) {\n    case LDAP_TAG_SYNC_NEW_COOKIE:\n        ber_printf(ber, \"to\", type, cookie);\n        break;\n    case LDAP_TAG_SYNC_REFRESH_DELETE:\n    case LDAP_TAG_SYNC_REFRESH_PRESENT:\n        ber_printf(ber, \"t{\", type);\n        if (cookie)\n            ber_printf(ber, \"s\", cookie);\n        \/* ber_printf(ber, \"b\",1); *\/\n        ber_printf(ber, \"}\");\n        break;\n    case LDAP_TAG_SYNC_ID_SET:\n        ber_printf(ber, \"t{\", type);\n        if (cookie)\n            ber_printf(ber, \"s\", cookie);\n        if (uuids)\n            ber_printf(ber, \"b[v]\", 1, uuids);\n        ber_printf(ber, \"}\");\n        break;\n    default:\n        break;\n    }\n    ber_flatten(ber, &bvp);\n    ber_free(ber, 1);\n\n    return (bvp);\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":262188,"func":"int yr_re_ast_create(\n    RE_AST** re_ast)\n{\n  *re_ast = (RE_AST*) yr_malloc(sizeof(RE_AST));\n\n  if (*re_ast == NULL)\n    return ERROR_INSUFFICIENT_MEMORY;\n\n  (*re_ast)->flags = 0;\n  (*re_ast)->levels = 0;\n  (*re_ast)->root_node = NULL;\n\n  return ERROR_SUCCESS;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":49743,"func":"int kernel_read(struct file *file, loff_t offset,\n\t\tchar *addr, unsigned long count)\n{\n\tmm_segment_t old_fs;\n\tloff_t pos = offset;\n\tint result;\n\n\told_fs = get_fs();\n\tset_fs(get_ds());\n\t\/* The cast to a user pointer is valid due to the set_fs() *\/\n\tresult = vfs_read(file, (void __user *)addr, count, &pos);\n\tset_fs(old_fs);\n\treturn result;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":359886,"func":"static void context_stop(struct context *ctx)\n{\n\tu32 reg;\n\tint i;\n\n\treg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN);\n\tflush_writes(ctx->ohci);\n\n\tfor (i = 0; i < 10; i++) {\n\t\treg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs));\n\t\tif ((reg & CONTEXT_ACTIVE) == 0)\n\t\t\treturn;\n\n\t\tmdelay(1);\n\t}\n\tfw_error(\"Error: DMA context still active (0x%08x)\\n\", reg);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":459534,"func":"dissect_kafka_create_topics_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,\n                                     kafka_api_version_t api_version)\n{\n    proto_item *subti;\n    proto_tree *subtree;\n\n    if (api_version >= 2) {\n        offset = dissect_kafka_throttle_time(tvb, pinfo, tree, offset);\n    }\n\n    \/* [topic_error_code] *\/\n    subtree = proto_tree_add_subtree(tree, tvb, offset, -1,\n                                     ett_kafka_topics,\n                                     &subti, \"Topics\");\n    offset = dissect_kafka_array(subtree, tvb, pinfo, offset, api_version >= 5, api_version,\n                                 &dissect_kafka_create_topics_response_topic, NULL);\n    proto_item_set_end(subti, tvb, offset);\n\n    if (api_version >= 5) {\n        offset = dissect_kafka_tagged_fields(tvb, pinfo, tree, offset, 0);\n    }\n\n    return offset;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":518180,"func":"rename_file_ext(const char * from,const char * to,const char * ext)\n{\n  char from_b[FN_REFLEN],to_b[FN_REFLEN];\n  (void) strxmov(from_b,from,ext,NullS);\n  (void) strxmov(to_b,to,ext,NullS);\n  return mysql_file_rename(key_file_frm, from_b, to_b, MYF(0));\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":394341,"func":"static const char *parse_hier(struct parse_state *state)\n{\n\tif (*state->ptr == '\/') {\n\t\tif (state->end - state->ptr > 1) {\n\t\t\tif (*(state->ptr + 1) == '\/') {\n\t\t\t\tstate->ptr += 2;\n\t\t\t\tif (!(state->ptr = parse_authority(state))) {\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn parse_path(state);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":225261,"func":"chash_end(int type, void *base, uschar *string, int length, uschar *digest)\n{\nif (type == HMAC_MD5)\n  md5_end((md5 *)base, string, length, digest);\nelse\n  sha1_end((sha1 *)base, string, length, digest);\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":125079,"func":"ExitPostmaster(int status)\n{\n#ifdef HAVE_PTHREAD_IS_THREADED_NP\n\n\t\/*\n\t * There is no known cause for a postmaster to become multithreaded after\n\t * startup.  Recheck to account for the possibility of unknown causes.\n\t * This message uses LOG level, because an unclean shutdown at this point\n\t * would usually not look much different from a clean shutdown.\n\t *\/\n\tif (pthread_is_threaded_np() != 0)\n\t\tereport(LOG,\n\t\t\t\t(errcode(ERRCODE_INTERNAL_ERROR),\n\t\t\t\t errmsg_internal(\"postmaster became multithreaded\"),\n\t\t\t\t errdetail(\"Please report this to <%s>.\", PACKAGE_BUGREPORT)));\n#endif\n\n\t\/* should cleanup shared memory and kill all backends *\/\n\n\t\/*\n\t * Not sure of the semantics here.  When the Postmaster dies, should the\n\t * backends all be killed? probably not.\n\t *\n\t * MUST\t\t-- vadim 05-10-1999\n\t *\/\n\n\tproc_exit(status);\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":68587,"func":"OurModifiers(XtermWidget xw)\n{\n    return (ShiftMask\n\t    | ControlMask\n\t    | MetaMask(xw));\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":423089,"func":"struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,\n\t\t\t\t\t const union tcp_md5_addr *addr,\n\t\t\t\t\t int family)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct tcp_md5sig_key *key;\n\tunsigned int size = sizeof(struct in_addr);\n\tstruct tcp_md5sig_info *md5sig;\n\n\t\/* caller either holds rcu_read_lock() or socket lock *\/\n\tmd5sig = rcu_dereference_check(tp->md5sig_info,\n\t\t\t\t       sock_owned_by_user(sk) ||\n\t\t\t\t       lockdep_is_held(&sk->sk_lock.slock));\n\tif (!md5sig)\n\t\treturn NULL;\n#if IS_ENABLED(CONFIG_IPV6)\n\tif (family == AF_INET6)\n\t\tsize = sizeof(struct in6_addr);\n#endif\n\thlist_for_each_entry_rcu(key, &md5sig->head, node) {\n\t\tif (key->family != family)\n\t\t\tcontinue;\n\t\tif (!memcmp(&key->addr, addr, size))\n\t\t\treturn key;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":503546,"func":"void cql_server::connection::on_connection_close()\n{\n    _server._notifier->unregister_connection(this);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":178641,"func":"  explicit ConnectionFilterImpl(int gpu_process_id) {\n    auto task_runner = BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);\n    registry_.AddInterface(base::Bind(&FieldTrialRecorder::Create),\n                           task_runner);\n#if defined(OS_ANDROID)\n    registry_.AddInterface(\n        base::Bind(&BindJavaInterface<media::mojom::AndroidOverlayProvider>),\n        task_runner);\n#endif\n\n    registry_.AddInterface(\n        base::BindRepeating(&CreateMemoryCoordinatorHandleForGpuProcess,\n                            gpu_process_id),\n        task_runner);\n  }\n","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":294009,"func":"static TypedValue* add_vars_helper(ActRec* ar) {\n  int start_index = 1;\n  Resource packet_id = getArg<KindOfResource>(ar, 0);\n  auto wddxPacket = packet_id.getTyped<WddxPacket>();\n\n  for (int i = start_index; i < ar->numArgs(); i++) {\n    auto const tv = getArg(ar, i);\n    find_var_recursive(tv, wddxPacket);\n  }\n  return arReturn(ar, true);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":101500,"func":"void CL_StopVideo_f( void )\n{\n  CL_CloseAVI( );\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":93644,"func":"static inline struct htx_blk *htx_add_header(struct htx *htx, const struct ist name,\n\t\t\t\t\t     const struct ist value)\n{\n\tstruct htx_blk *blk;\n\n\tif (name.len > 255 || value.len > 1048575)\n\t\treturn NULL;\n\n\tblk = htx_add_blk(htx, HTX_BLK_HDR, name.len + value.len);\n\tif (!blk)\n\t\treturn NULL;\n\n\tblk->info += (value.len << 8) + name.len;\n\tist2bin_lc(htx_get_blk_ptr(htx, blk), name);\n\tmemcpy(htx_get_blk_ptr(htx, blk)  + name.len, value.ptr, value.len);\n\treturn blk;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":344919,"func":"  void RemoveZeroOperations() {\n    RemoveZeroAdd(&added_lower_index_, &added_lower_offset_);\n    RemoveZeroAdd(&added_upper_index_, &added_upper_offset_);\n  }","target":1,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":469510,"func":"static void __exit ucma_cleanup(void)\n{\n\tib_unregister_client(&rdma_cma_client);\n\tunregister_net_sysctl_table(ucma_ctl_table_hdr);\n\tdevice_remove_file(ucma_misc.this_device, &dev_attr_abi_version);\n\tmisc_deregister(&ucma_misc);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":382223,"func":"flushbuffer(PrintfTarget *target)\n{\n\tsize_t\t\tnc = target->bufptr - target->bufstart;\n\n\tif (nc > 0)\n\t\ttarget->nchars += fwrite(target->bufstart, 1, nc, target->stream);\n\ttarget->bufptr = target->bufstart;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":53528,"func":"virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)\n{\n    virConnectPtr conn;\n\n    VIR_DOMAIN_DEBUG(domain, \"memory=%lu\", memory);\n\n    virResetLastError();\n\n    virCheckDomainReturn(domain, -1);\n    conn = domain->conn;\n\n    virCheckReadOnlyGoto(conn->flags, error);\n    virCheckNonZeroArgGoto(memory, error);\n\n    if (virMemoryMaxValue(true) \/ 1024 <= memory) {\n        virReportError(VIR_ERR_OVERFLOW, _(\"input too large: %lu\"),\n                       memory);\n        goto error;\n    }\n\n    if (conn->driver->domainSetMaxMemory) {\n        int ret;\n        ret = conn->driver->domainSetMaxMemory(domain, memory);\n        if (ret < 0)\n            goto error;\n        return ret;\n    }\n\n    virReportUnsupportedError();\n\n error:\n    virDispatchError(domain->conn);\n    return -1;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":133376,"func":"smtp_proceed_commit(struct smtp_session *s, const char *args)\n{\n\tsmtp_message_end(s->tx);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":508479,"func":"void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,\n                        int (*cb) (int, X509_STORE_CTX *))\n{\n    ctx->verify_mode = mode;\n    ctx->default_verify_callback = cb;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":495500,"func":"njs_encode_base64(njs_str_t *dst, const njs_str_t *src)\n{\n    static u_char   basis64[] =\n        \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/\";\n\n    njs_encode_base64_core(dst, src, basis64, 1);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":518595,"func":"  ulonglong val_uint(void) { return (ulonglong) val_int_from_real(true); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":209337,"func":"BrowserContextIOData::GetTemporarySavedPermissionContext() const {\n  return temporary_saved_permission_context_.get();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":509279,"func":"SCM_DEFINE (scm_dirname, \"dirname\", 1, 0, 0, \n            (SCM filename),\n\t    \"Return the directory name component of the file name\\n\"\n\t    \"@var{filename}. If @var{filename} does not contain a directory\\n\"\n\t    \"component, @code{.} is returned.\")\n#define FUNC_NAME s_scm_dirname\n{\n  char *c_filename, *c_dirname;\n  SCM res;\n\n  scm_dynwind_begin (0);\n  c_filename = scm_to_utf8_string (filename);\n  scm_dynwind_free (c_filename);\n\n  c_dirname = mdir_name (c_filename);\n  if (!c_dirname)\n    SCM_SYSERROR;\n  scm_dynwind_free (c_dirname);\n\n  res = scm_from_utf8_string (c_dirname);\n  scm_dynwind_end ();\n\n  return res;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":120528,"func":"QPDFObjectHandle::getDictAsMap()\n{\n    std::map<std::string, QPDFObjectHandle> result;\n    if (isDictionary())\n    {\n        result = dynamic_cast<QPDF_Dictionary*>(\n            m->obj.getPointer())->getAsMap();\n    }\n    else\n    {\n        typeWarning(\"dictionary\", \"treating as empty\");\n        QTC::TC(\"qpdf\", \"QPDFObjectHandle dictionary empty map for asMap\");\n    }\n    return result;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":276451,"func":"ResourceLoadTiming* PerformanceNavigationTiming::GetResourceLoadTiming() const {\n  return resource_timing_info_->FinalResponse().GetResourceLoadTiming();\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":191355,"func":"static void gen_helper_fp_arith_STN_ST0(int op, int opreg)\n{\n    TCGv_i32 tmp = tcg_const_i32(opreg);\n    switch (op) {\n    case 0:\n        gen_helper_fadd_STN_ST0(cpu_env, tmp);\n        break;\n    case 1:\n        gen_helper_fmul_STN_ST0(cpu_env, tmp);\n        break;\n    case 4:\n        gen_helper_fsubr_STN_ST0(cpu_env, tmp);\n        break;\n    case 5:\n        gen_helper_fsub_STN_ST0(cpu_env, tmp);\n        break;\n    case 6:\n        gen_helper_fdivr_STN_ST0(cpu_env, tmp);\n        break;\n    case 7:\n        gen_helper_fdiv_STN_ST0(cpu_env, tmp);\n        break;\n    }\n}\n","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":237119,"func":"LogL16toY(int p16)\t\t\/* compute luminance from 16-bit LogL *\/\n{\n\tint\tLe = p16 & 0x7fff;\n\tdouble\tY;\n\n\tif (!Le)\n\t\treturn (0.);\n\tY = exp(M_LN2\/256.*(Le+.5) - M_LN2*64.);\n\treturn (!(p16 & 0x8000) ? Y : -Y);\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":377029,"func":"static int dp_register_genl(void)\n{\n\tint n_registered;\n\tint err;\n\tint i;\n\n\tn_registered = 0;\n\tfor (i = 0; i < ARRAY_SIZE(dp_genl_families); i++) {\n\t\tconst struct genl_family_and_ops *f = &dp_genl_families[i];\n\n\t\tf->family->ops = f->ops;\n\t\tf->family->n_ops = f->n_ops;\n\t\tf->family->mcgrps = f->group;\n\t\tf->family->n_mcgrps = f->group ? 1 : 0;\n\t\terr = genl_register_family(f->family);\n\t\tif (err)\n\t\t\tgoto error;\n\t\tn_registered++;\n\t}\n\n\treturn 0;\n\nerror:\n\tdp_unregister_genl(n_registered);\n\treturn err;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":146251,"func":"static int cmd_env(void *data, const char *input) {\n\tRCore *core = (RCore*)data;\n\tint ret = true;\n\tswitch (*input) {\n\tcase '?':\n\t\t{\n\t\tconst char* help_msg[] = {\n\t\t\t\"Usage:\", \"%[name[=value]]\", \"Set each NAME to VALUE in the environment\",\n\t\t\t\"%\", \"\", \"list all environment variables\",\n\t\t\t\"%\", \"SHELL\", \"prints SHELL value\",\n\t\t\t\"%\", \"TMPDIR=\/tmp\", \"sets TMPDIR value to \\\"\/tmp\\\"\",\n\t\t\tNULL};\n\t\tr_core_cmd_help (core, help_msg);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tret = r_core_cmdf (core, \"env %s\", input);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":71428,"func":"static void rebase_info2_free(RDyldRebaseInfo2 *rebase_info) {\n\tif (!rebase_info) {\n\t\treturn;\n\t}\n\n\tR_FREE (rebase_info->page_starts);\n\tR_FREE (rebase_info->page_extras);\n\tR_FREE (rebase_info);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":77156,"func":"}\n\nstatic inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi)\n{\n\treturn (test_opt(sbi, DISCARD) && f2fs_hw_support_discard(sbi)) ||","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":445427,"func":"  DnsImplTest()\n      : api_(Api::createApiForTest()), dispatcher_(api_->allocateDispatcher(\"test_thread\")) {}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":146917,"func":"static void tcp_fixup_rcvbuf(struct sock *sk)\n{\n\tu32 mss = tcp_sk(sk)->advmss;\n\tu32 icwnd = TCP_DEFAULT_INIT_RCVWND;\n\tint rcvmem;\n\n\t\/* Limit to 10 segments if mss <= 1460,\n\t * or 14600\/mss segments, with a minimum of two segments.\n\t *\/\n\tif (mss > 1460)\n\t\ticwnd = max_t(u32, (1460 * TCP_DEFAULT_INIT_RCVWND) \/ mss, 2);\n\n\trcvmem = SKB_TRUESIZE(mss + MAX_TCP_HEADER);\n\twhile (tcp_win_from_space(rcvmem) < mss)\n\t\trcvmem += 128;\n\n\trcvmem *= icwnd;\n\n\tif (sk->sk_rcvbuf < rcvmem)\n\t\tsk->sk_rcvbuf = min(rcvmem, sysctl_tcp_rmem[2]);\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":16830,"func":"const char * TSHttpTxnRedirectUrlGet ( TSHttpTxn txnp , int * url_len_ptr ) {\n sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;\n HttpSM * sm = ( HttpSM * ) txnp ;\n * url_len_ptr = sm -> redirect_url_len ;\n return sm -> redirect_url ;\n }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":383727,"func":"\nstatic void php_date_timezone_set(zval *object, zval *timezone_object, zval *return_value TSRMLS_DC)\n{\n\tphp_date_obj     *dateobj;\n\tphp_timezone_obj *tzobj;\n\n\tdateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);\n\tDATE_CHECK_INITIALIZED(dateobj->time, DateTime);\n\ttzobj = (php_timezone_obj *) zend_object_store_get_object(timezone_object TSRMLS_CC);\n\n\tswitch (tzobj->type) {\n\t\tcase TIMELIB_ZONETYPE_OFFSET:\n\t\t\ttimelib_set_timezone_from_offset(dateobj->time, tzobj->tzi.utc_offset);\n\t\t\tbreak;\n\t\tcase TIMELIB_ZONETYPE_ABBR:\n\t\t\ttimelib_set_timezone_from_abbr(dateobj->time, tzobj->tzi.z);\n\t\t\tbreak;\n\t\tcase TIMELIB_ZONETYPE_ID:\n\t\t\ttimelib_set_timezone(dateobj->time, tzobj->tzi.tz);\n\t\t\tbreak;\n\t}\n\ttimelib_unixtime2local(dateobj->time, dateobj->time->sse);","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":38068,"func":"static void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo *m,\n\t\t\t\tvoid *buf)\n{\n\tdprintk(DBGLVL_BUS, \"Dumping msg structure:\\n\");\n\tdprintk(DBGLVL_BUS, \" .id               = %d\\n\",   m->id);\n\tdprintk(DBGLVL_BUS, \" .flags            = 0x%x\\n\", m->flags);\n\tdprintk(DBGLVL_BUS, \" .size             = 0x%x\\n\", m->size);\n\tdprintk(DBGLVL_BUS, \" .command          = 0x%x\\n\", m->command);\n\tdprintk(DBGLVL_BUS, \" .controlselector  = 0x%x\\n\", m->controlselector);\n\tdprintk(DBGLVL_BUS, \" .seqno            = %d\\n\",   m->seqno);\n\tif (buf)\n\t\tdprintk(DBGLVL_BUS, \" .buffer (ignored)\\n\");\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":175073,"func":"void V8TestObject::ActivityLoggingGetterForAllWorldsLongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {\n  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), \"Blink_TestObject_activityLoggingGetterForAllWorldsLongAttribute_Getter\");\n\n  ScriptState* script_state = ScriptState::ForRelevantRealm(info);\n  V8PerContextData* context_data = script_state->PerContextData();\n  if (context_data && context_data->ActivityLogger()) {\n    context_data->ActivityLogger()->LogGetter(\"TestObject.activityLoggingGetterForAllWorldsLongAttribute\");\n  }\n\n  test_object_v8_internal::ActivityLoggingGetterForAllWorldsLongAttributeAttributeGetter(info);\n}\n","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":522233,"func":"  ha_rows get_rownum() const\n  {\n    if (io_cache)\n      return rownum;\n    else\n      return (cache_pos - cache_start) \/ ref_length;\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":383263,"func":"pubkey_letter( int algo )\n{\n  switch (algo)\n    {\n    case PUBKEY_ALGO_RSA:\treturn 'R' ;\n    case PUBKEY_ALGO_RSA_E:\treturn 'r' ;\n    case PUBKEY_ALGO_RSA_S:\treturn 's' ;\n    case PUBKEY_ALGO_ELGAMAL_E: return 'g' ;\n    case PUBKEY_ALGO_ELGAMAL:   return 'G' ;\n    case PUBKEY_ALGO_DSA:\treturn 'D' ;\n    case PUBKEY_ALGO_ECDH:\treturn 'e' ;\t\/* ECC DH (encrypt only) *\/\n    case PUBKEY_ALGO_ECDSA:\treturn 'E' ;\t\/* ECC DSA (sign only)   *\/\n    case PUBKEY_ALGO_EDDSA:\treturn 'E' ;\t\/* ECC EdDSA (sign only) *\/\n    default: return '?';\n    }\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":429603,"func":"ModuleExport size_t RegisterPCLImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=SetMagickInfo(\"PCL\");\n  entry->decoder=(DecodeImageHandler *) ReadPCLImage;\n  entry->encoder=(EncodeImageHandler *) WritePCLImage;\n  entry->magick=(IsImageFormatHandler *) IsPCL;\n  entry->blob_support=MagickFalse;\n  entry->seekable_stream=MagickTrue;\n  entry->thread_support=EncoderThreadSupport;\n  entry->description=ConstantString(\"Printer Control Language\");\n  entry->module=ConstantString(\"PCL\");\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":200267,"func":"const base::FilePath& DriveFsHost::GetMountPath() const {\n  DCHECK(IsMounted());\n  return mount_state_->mount_path();\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":79436,"func":"static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)\n{\n\tstruct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(sb);\n\tstruct hugetlbfs_inode_info *p;\n\n\tif (unlikely(!hugetlbfs_dec_free_inodes(sbinfo)))\n\t\treturn NULL;\n\tp = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);\n\tif (unlikely(!p)) {\n\t\thugetlbfs_inc_free_inodes(sbinfo);\n\t\treturn NULL;\n\t}\n\treturn &p->vfs_inode;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":520810,"func":"  bool save_in_value(THD *thd, struct st_value *value)\n  {\n    return type_handler()->Item_save_in_value(thd, this, value);\n  }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":42182,"func":"static inline bool cpu_has_vmx_ept(void)\n{\n\treturn vmcs_config.cpu_based_2nd_exec_ctrl &\n\t\tSECONDARY_EXEC_ENABLE_EPT;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":399505,"func":"SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,\n\t\tstruct timespec __user *, rmtp)\n{\n\tstruct timespec tu;\n\n\tif (copy_from_user(&tu, rqtp, sizeof(tu)))\n\t\treturn -EFAULT;\n\n\tif (!timespec_valid(&tu))\n\t\treturn -EINVAL;\n\n\treturn hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":151452,"func":"void MainWindow::dropEvent(QDropEvent *event)\n{\n    const QMimeData *mimeData = event->mimeData();\n    if (mimeData->hasFormat(\"application\/x-qabstractitemmodeldatalist\")) {\n        QByteArray encoded = mimeData->data(\"application\/x-qabstractitemmodeldatalist\");\n        QDataStream stream(&encoded, QIODevice::ReadOnly);\n        QMap<int,  QVariant> roleDataMap;\n        while (!stream.atEnd()) {\n            int row, col;\n            stream >> row >> col >> roleDataMap;\n        }\n        if (roleDataMap.contains(Qt::ToolTipRole)) {\n            \/\/ DisplayRole is just basename, ToolTipRole contains full path\n            open(roleDataMap[Qt::ToolTipRole].toString());\n            event->acceptProposedAction();\n        }\n    }\n    else if (mimeData->hasUrls()) {\n        openMultiple(mimeData->urls());\n        event->acceptProposedAction();\n    }\n    else if (mimeData->hasFormat(Mlt::XmlMimeType )) {\n        m_playlistDock->on_actionOpen_triggered();\n        event->acceptProposedAction();\n    }\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":360332,"func":"show_thumbnails_changed_callback (gpointer user_data)\n{\n\tshow_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);\n\n\t\/* Tell the world that icons might have changed. We could invent a narrower-scope\n\t * signal to mean only \"thumbnails might have changed\" if this ends up being slow\n\t * for some reason.\n\t *\/\n\temit_change_signals_for_all_files_in_all_directories ();\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":470610,"func":"void usbredirparser_send_alloc_bulk_streams(struct usbredirparser *parser,\n    uint64_t id,\n    struct usb_redir_alloc_bulk_streams_header *alloc_bulk_streams)\n{\n    usbredirparser_queue(parser, usb_redir_alloc_bulk_streams, id,\n                         alloc_bulk_streams, NULL, 0);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":98769,"func":"int imap_get_literal_count(const char *buf, unsigned int *bytes)\n{\n  char *pc;\n  char *pn;\n\n  if (!buf || !(pc = strchr (buf, '{')))\n    return -1;\n\n  pc++;\n  pn = pc;\n  while (isdigit ((unsigned char) *pc))\n    pc++;\n  *pc = 0;\n  if (mutt_atoui (pn, bytes) < 0)\n    return -1;\n\n  return 0;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":159375,"func":"static void add_mm_counter_fast(struct mm_struct *mm, int member, int val)\n{\n\tstruct task_struct *task = current;\n\n\tif (likely(task->mm == mm))\n\t\ttask->rss_stat.count[member] += val;\n\telse\n\t\tadd_mm_counter(mm, member, val);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":59954,"func":"int _yr_re_fiber_exists(\n    RE_FIBER_LIST* fiber_list,\n    RE_FIBER* target_fiber,\n    RE_FIBER* last_fiber)\n{\n  RE_FIBER* fiber = fiber_list->head;\n\n  int equal_stacks;\n  int i;\n\n\n  if (last_fiber == NULL)\n    return FALSE;\n\n  while (fiber != last_fiber->next)\n  {\n    if (fiber->ip == target_fiber->ip &&\n        fiber->sp == target_fiber->sp &&\n        fiber->rc == target_fiber->rc)\n    {\n      equal_stacks = TRUE;\n\n      for (i = 0; i <= fiber->sp; i++)\n      {\n        if (fiber->stack[i] != target_fiber->stack[i])\n        {\n          equal_stacks = FALSE;\n          break;\n        }\n      }\n\n      if (equal_stacks)\n        return TRUE;\n    }\n\n    fiber = fiber->next;\n  }\n\n  return FALSE;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":503028,"func":"static void hdb_samba4_free_entry_context(krb5_context context, struct HDB *db, hdb_entry *entry)\n{\n\t\/*\n\t * This function is now called for every HDB entry, not just those with\n\t * 'context' set, so we have to check that the context is not NULL.\n\t*\/\n\tif (entry->context != NULL) {\n\t\tstruct samba_kdc_entry *skdc_entry =\n\t\t\ttalloc_get_type_abort(entry->context,\n\t\t\tstruct samba_kdc_entry);\n\n\t\t\/* this function is called only from hdb_free_entry().\n\t\t * Make sure we neutralize the destructor or we will\n\t\t * get a double free later when hdb_free_entry() will\n\t\t * try to call free_hdb_entry() *\/\n\t\tentry->context = NULL;\n\t\tskdc_entry->kdc_entry = NULL;\n\t\tTALLOC_FREE(skdc_entry);\n\t}\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":40185,"func":"int puma_parser_is_finished(puma_parser *parser) {\n  return parser->cs >= puma_parser_first_final;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":103898,"func":"static int GetCertHeader(DecodedCert* cert)\n{\n    int ret = 0, len;\n\n    if (GetSequence(cert->source, &cert->srcIdx, &len, cert->maxIdx) < 0)\n        return ASN_PARSE_E;\n\n    \/* Reset the max index for the size indicated in the outer wrapper. *\/\n    cert->maxIdx = len + cert->srcIdx;\n    cert->certBegin = cert->srcIdx;\n\n    if (GetSequence(cert->source, &cert->srcIdx, &len, cert->maxIdx) < 0)\n        return ASN_PARSE_E;\n\n    cert->sigIndex = len + cert->srcIdx;\n    if (cert->sigIndex > cert->maxIdx)\n        return ASN_PARSE_E;\n\n    if (GetExplicitVersion(cert->source, &cert->srcIdx, &cert->version,\n                                                            cert->sigIndex) < 0)\n        return ASN_PARSE_E;\n\n    if (GetSerialNumber(cert->source, &cert->srcIdx, cert->serial,\n                                           &cert->serialSz, cert->sigIndex) < 0)\n        return ASN_PARSE_E;\n\n    return ret;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":354239,"func":"unsigned int X509v3_addr_get_afi(const IPAddressFamily *f)\n{\n    return ((f != NULL &&\n             f->addressFamily != NULL && f->addressFamily->data != NULL)\n            ? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1]))\n            : 0);\n}","target":1,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":458202,"func":"void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec)\n{\n    if (p_codec) {\n        opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;\n\n        if (l_codec->is_decompressor) {\n            l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec);\n        } else {\n            l_codec->m_codec_data.m_compression.opj_destroy(l_codec->m_codec);\n        }\n\n        l_codec->m_codec = 00;\n        opj_free(l_codec);\n    }\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":246702,"func":"bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) {\n  WebContents* wc = GetInspectedWebContents();\n  if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING)\n    return false;\n  base::FundamentalValue bypass_cache_value(bypass_cache);\n  bindings_->CallClientFunction(\"DevToolsAPI.reloadInspectedPage\",\n                                &bypass_cache_value, nullptr, nullptr);\n  return true;\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":210867,"func":"void ChromeDownloadManagerDelegate::AddItemToPersistentStore(\n    DownloadItem* item) {\n  download_history_->AddEntry(item,\n      base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore,\n                 base::Unretained(this)));\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":250365,"func":"size_t GetUTF8Offset(const std::wstring& wide_text, size_t wide_text_offset) {\n  return WideToUTF8(wide_text.substr(0, wide_text_offset)).size();\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":423737,"func":"dns_zone_getraw(dns_zone_t *zone, dns_zone_t **raw) {\n\tREQUIRE(DNS_ZONE_VALID(zone));\n\tREQUIRE(raw != NULL && *raw == NULL);\n\n\tLOCK(&zone->lock);\n\tINSIST(zone != zone->raw);\n\tif (zone->raw != NULL)\n\t\tdns_zone_attach(zone->raw, raw);\n\tUNLOCK(&zone->lock);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":188965,"func":"is_hex(const char *p, size_t len)\n{\n\twhile (len-- > 0) {\n\t\tif ((*p >= '0' && *p <= '9')\n\t\t    || (*p >= 'a' && *p <= 'f')\n\t\t    || (*p >= 'A' && *p <= 'F'))\n\t\t\t++p;\n\t\telse\n\t\t\treturn (0);\n\t}\n\treturn (1);\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":437635,"func":"static int spl_filesystem_dir_it_valid(zend_object_iterator *iter)\n{\n\tspl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter);\n\n\treturn object->u.dir.entry.d_name[0] != '\\0' ? SUCCESS : FAILURE;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":175217,"func":"  FT_Stream_TryRead( FT_Stream  stream,\n                     FT_Byte*   buffer,\n                     FT_ULong   count )\n  {\n    FT_ULong  read_bytes = 0;\n\n\n    if ( stream->pos >= stream->size )\n      goto Exit;\n\n    if ( stream->read )\n      read_bytes = stream->read( stream, stream->pos, buffer, count );\n    else\n    {\n      read_bytes = stream->size - stream->pos;\n      if ( read_bytes > count )\n        read_bytes = count;\n\n      FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );\n    }\n\n    stream->pos += read_bytes;\n\n  Exit:\n    return read_bytes;\n  }\n","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":277361,"func":"v8::Handle<v8::Value> V8ThrowException::createReferenceError(v8::Isolate* isolate, const String& message)\n{\n    return v8::Exception::ReferenceError(v8String(isolate, message.isNull() ? \"Reference error\" : message));\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":203401,"func":"void TabSpecificContentSettings::AddBlockedResource(\n    ContentSettingsType content_type,\n    const std::string& resource_identifier) {\n  if (!blocked_resources_[content_type].get())\n    blocked_resources_[content_type].reset(new std::set<std::string>());\n  blocked_resources_[content_type]->insert(resource_identifier);\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":104307,"func":"static int tg_set_bandwidth(struct task_group *tg,\n\t\tu64 rt_period, u64 rt_runtime)\n{\n\tint i, err = 0;\n\n\tmutex_lock(&rt_constraints_mutex);\n\tread_lock(&tasklist_lock);\n\terr = __rt_schedulable(tg, rt_period, rt_runtime);\n\tif (err)\n\t\tgoto unlock;\n\n\traw_spin_lock_irq(&tg->rt_bandwidth.rt_runtime_lock);\n\ttg->rt_bandwidth.rt_period = ns_to_ktime(rt_period);\n\ttg->rt_bandwidth.rt_runtime = rt_runtime;\n\n\tfor_each_possible_cpu(i) {\n\t\tstruct rt_rq *rt_rq = tg->rt_rq[i];\n\n\t\traw_spin_lock(&rt_rq->rt_runtime_lock);\n\t\trt_rq->rt_runtime = rt_runtime;\n\t\traw_spin_unlock(&rt_rq->rt_runtime_lock);\n\t}\n\traw_spin_unlock_irq(&tg->rt_bandwidth.rt_runtime_lock);\nunlock:\n\tread_unlock(&tasklist_lock);\n\tmutex_unlock(&rt_constraints_mutex);\n\n\treturn err;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":19275,"func":"fz_colorspace * fz_keep_colorspace ( fz_context * ctx , fz_colorspace * cs ) {\n return fz_keep_key_storable ( ctx , & cs -> key_storable ) ;\n }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":300826,"func":"static int common_perm_rm(int op, struct path *dir,\n\t\t\t  struct dentry *dentry, u32 mask)\n{\n\tstruct inode *inode = dentry->d_inode;\n\tstruct path_cond cond = { };\n\n\tif (!inode || !dir->mnt || !mediated_filesystem(inode))\n\t\treturn 0;\n\n\tcond.uid = inode->i_uid;\n\tcond.mode = inode->i_mode;\n\n\treturn common_perm_dir_dentry(op, dir, dentry, mask, &cond);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":258091,"func":"static void parse_context_init ( SchroParseUnitContext * parse_ctx , const uint8_t * buf , int buf_size ) {\n parse_ctx -> buf = buf ;\n parse_ctx -> buf_size = buf_size ;\n }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":284421,"func":"void GLES2Implementation::EnableVertexAttribArray(GLuint index) {\n  GPU_CLIENT_SINGLE_THREAD_CHECK();\n  GPU_CLIENT_LOG(\"[\" << GetLogPrefix() << \"] glEnableVertexAttribArray(\"\n                     << index << \")\");\n  vertex_array_object_manager_->SetAttribEnable(index, true);\n  helper_->EnableVertexAttribArray(index);\n  CheckGLError();\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":355449,"func":"ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)\n{\n\tstruct ip_tunnel_prl_entry *x, **p;\n\tint err = 0;\n\n\twrite_lock(&ipip6_lock);\n\n\tif (a && a->addr != htonl(INADDR_ANY)) {\n\t\tfor (p = &t->prl; *p; p = &(*p)->next) {\n\t\t\tif ((*p)->addr == a->addr) {\n\t\t\t\tx = *p;\n\t\t\t\t*p = x->next;\n\t\t\t\tkfree(x);\n\t\t\t\tt->prl_count--;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\terr = -ENXIO;\n\t} else {\n\t\twhile (t->prl) {\n\t\t\tx = t->prl;\n\t\t\tt->prl = t->prl->next;\n\t\t\tkfree(x);\n\t\t\tt->prl_count--;\n\t\t}\n\t}\nout:\n\twrite_unlock(&ipip6_lock);\n\treturn 0;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":514092,"func":"while_command()\n{\n    int do_start, do_end;\n    char *clause;\n    int save_token, end_token;\n    double exprval;\n\n    c_token++;\n    save_token = c_token;\n    exprval = real_expression();\n\n    if (!equals(c_token,\"{\"))\n\tint_error(c_token,\"expecting {while-clause}\");\n    end_token = find_clause(&do_start, &do_end);\n\n    clause = new_clause(do_start, do_end);\n    begin_clause();\n\n    iteration_depth++;\n    while (exprval != 0) {\n\trequested_continue = FALSE;\n\tdo_string(clause);\n\tif (command_exit_requested)\n\t    requested_break = TRUE;\n\tif (requested_break)\n\t    break;\n\tc_token = save_token;\n\texprval = real_expression();\n    };\n    iteration_depth--;\n\n    end_clause();\n    free(clause);\n    c_token = end_token;\n    requested_break = FALSE;\n    requested_continue = FALSE;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":42009,"func":"int ha_myisam::index_read_map(uchar *buf, const uchar *key,\n                              key_part_map keypart_map,\n                              enum ha_rkey_function find_flag)\n{\n  MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);\n  DBUG_ASSERT(inited==INDEX);\n  ha_statistic_increment(&SSV::ha_read_key_count);\n  int error=mi_rkey(file, buf, active_index, key, keypart_map, find_flag);\n  table->status=error ? STATUS_NOT_FOUND: 0;\n  MYSQL_INDEX_READ_ROW_DONE(error);\n  return error;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":225030,"func":"void GfxCalRGBColorSpace::getGray(GfxColor *color, GfxGray *gray) {\n  GfxRGB rgb;\n\n#ifdef USE_CMS\n  if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {\n    Guchar out[gfxColorMaxComps];\n    double in[gfxColorMaxComps];\n    double X, Y, Z;\n    \n    getXYZ(color,&X,&Y,&Z);\n    in[0] = clip01(X);\n    in[1] = clip01(Y);\n    in[2] = clip01(Z);\n    XYZ2DisplayTransform->doTransform(in,out,1);\n    *gray = byteToCol(out[0]);\n    return;\n  }\n#endif\n  getRGB(color, &rgb);\n  *gray = clip01((GfxColorComp)(0.299 * rgb.r +\n\t\t\t\t0.587 * rgb.g +\n\t\t\t\t0.114 * rgb.b + 0.5));\n}\n","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":263784,"func":"bool HHVM_FUNCTION(hash_equals, const Variant& known, const Variant& user) {\n  if (!known.isString()) {\n    raise_warning(\n      \"hash_equals(): Expected known_string to be a string, %s given\",\n      getDataTypeString(known.getType()).c_str()\n    );\n    return false;\n  }\n  if (!user.isString()) {\n    raise_warning(\n      \"hash_equals(): Expected user_string to be a string, %s given\",\n      getDataTypeString(user.getType()).c_str()\n    );\n    return false;\n  }\n  String known_str = known.toString();\n  String user_str = user.toString();\n  const auto known_len = known_str.size();\n  const auto known_limit = known_len - 1;\n  const auto user_len = user_str.size();\n  int64_t result = known_len ^ user_len;\n\n  int64_t ki = 0;\n  for (int64_t ui = 0; ui < user_len; ++ui) {\n    result |= user_str[ui] ^ known_str[ki];\n    if (ki < known_limit) {\n      ++ki;\n    }\n  }\n  return (result == 0);\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":486868,"func":"ffi_closure_alloc (size_t size, void **code)\n{\n  void *ptr;\n\n  if (!code)\n    return NULL;\n\n  ptr = dlmalloc (size);\n\n  if (ptr)\n    {\n      msegmentptr seg = segment_holding (gm, ptr);\n\n      *code = add_segment_exec_offset (ptr, seg);\n    }\n\n  return ptr;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":145938,"func":"int FLTIsTemporalFilterType(const char *pszValue)\n{\n  if (pszValue) {\n    if ( strcasecmp(pszValue, \"During\") == 0 )\n      return MS_TRUE;\n  }\n\n  return MS_FALSE;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":337437,"func":"static void spitz_i2c_setup(PXA2xxState *cpu)\n\n{\n\n    \/* Attach the CPU on one end of our I2C bus.  *\/\n\n    I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);\n\n\n\n    DeviceState *wm;\n\n\n\n    \/* Attach a WM8750 to the bus *\/\n\n    wm = i2c_create_slave(bus, \"wm8750\", 0);\n\n\n\n    spitz_wm8750_addr(wm, 0, 0);\n\n    qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM,\n\n                    qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]);\n\n    \/* .. and to the sound interface.  *\/\n\n    cpu->i2s->opaque = wm;\n\n    cpu->i2s->codec_out = wm8750_dac_dat;\n\n    cpu->i2s->codec_in = wm8750_adc_dat;\n\n    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);\n\n}\n","target":1,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":494270,"func":"static int handle_ping_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)\n{\n    h2o_http2_ping_payload_t payload;\n    int ret;\n\n    if ((ret = h2o_http2_decode_ping_payload(&payload, frame, err_desc)) != 0)\n        return ret;\n\n    h2o_http2_encode_ping_frame(&conn->_write.buf, 1, payload.data);\n    h2o_http2_conn_request_write(conn);\n\n    return 0;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":156154,"func":"  void visit(Sequence &ope) override {\n    for (auto op : ope.opes_) {\n      op->accept(*this);\n    }\n  }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":274772,"func":"static void rom_reset(void *unused)\n{\n    Rom *rom;\n\n    QTAILQ_FOREACH(rom, &roms, next) {\n        if (rom->fw_file) {\n            continue;\n        }\n        if (rom->data == NULL) {\n            continue;\n        }\n        if (rom->mr) {\n            void *host = memory_region_get_ram_ptr(rom->mr);\n            memcpy(host, rom->data, rom->datasize);\n        } else {\n            address_space_write_rom(rom->as, rom->addr, MEMTXATTRS_UNSPECIFIED,\n                                    rom->data, rom->datasize);\n        }\n        if (rom->isrom) {\n            \/* rom needs to be written only once *\/\n            g_free(rom->data);\n            rom->data = NULL;\n        }\n        \/*\n         * The rom loader is really on the same level as firmware in the guest\n         * shadowing a ROM into RAM. Such a shadowing mechanism needs to ensure\n         * that the instruction cache for that new region is clear, so that the\n         * CPU definitely fetches its instructions from the just written data.\n         *\/\n        cpu_flush_icache_range(rom->addr, rom->datasize);\n    }\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":349321,"func":"static inline u32 __flow_hash_from_keys(struct flow_keys *keys, u32 keyval)\n{\n\tu32 hash;\n\n\t__flow_hash_consistentify(keys);\n\n\thash = __flow_hash_words(flow_keys_hash_start(keys),\n\t\t\t\t flow_keys_hash_length(keys), keyval);\n\tif (!hash)\n\t\thash = 1;\n\n\treturn hash;\n}","target":1,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":106604,"func":"static int opficom(RAsm *a, ut8 *data, const Opcode *op) {\n\tint l = 0;\n\tswitch (op->operands_count) {\n\tcase 1:\n\t\tif ( op->operands[0].type & OT_MEMORY ) {\n\t\t\tif ( op->operands[0].type & OT_WORD ) {\n\t\t\t\tdata[l++] = 0xde;\n\t\t\t\tdata[l++] = 0x10 | op->operands[0].regs[0];\n\t\t\t} else if ( op->operands[0].type & OT_DWORD ) {\n\t\t\t\tdata[l++] = 0xda;\n\t\t\t\tdata[l++] = 0x10 | op->operands[0].regs[0];\n\t\t\t} else {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\treturn -1;\n\t}\n\treturn l;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":262810,"func":"showoneopt (\n    vimoption_T *p,\n    int opt_flags                          \/* OPT_LOCAL or OPT_GLOBAL *\/\n)\n{\n  char_u      *varp;\n  int save_silent = silent_mode;\n\n  silent_mode = FALSE;\n  info_message = TRUE;          \/* use mch_msg(), not mch_errmsg() *\/\n\n  varp = get_varp_scope(p, opt_flags);\n\n  \/\/ for 'modified' we also need to check if 'ff' or 'fenc' changed.\n  if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed\n                              ? !curbufIsChanged() : !*(int *)varp)) {\n    MSG_PUTS(\"no\");\n  } else if ((p->flags & P_BOOL) && *(int *)varp < 0) {\n    MSG_PUTS(\"--\");\n  } else {\n    MSG_PUTS(\"  \");\n  }\n  MSG_PUTS(p->fullname);\n  if (!(p->flags & P_BOOL)) {\n    msg_putchar('=');\n    \/* put value string in NameBuff *\/\n    option_value2string(p, opt_flags);\n    msg_outtrans(NameBuff);\n  }\n\n  silent_mode = save_silent;\n  info_message = FALSE;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":170430,"func":" void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,\n                               gfx::NativeView parent_view,\n                                int expected_page_count,\n                                bool has_selection,\n                                bool use_overlays,\n                               CancelableTask* callback) {\n  DCHECK_EQ(ui_message_loop_, MessageLoop::current());\n  DCHECK(!is_print_dialog_box_shown_);\n  DCHECK(!callback_.get());\n  DCHECK(worker_.get());\n  if (!worker_.get())\n    return;\n  if (!worker_->message_loop()) {\n    if (!worker_->Start()) {\n      if (callback) {\n        callback->Cancel();\n        delete callback;\n      }\n      NOTREACHED();\n      return;\n    }\n  }\n\n  callback_.reset(callback);\n  is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER;\n  worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(\n       worker_.get(),\n       &PrintJobWorker::GetSettings,\n       is_print_dialog_box_shown_,\n      parent_view,\n       expected_page_count,\n       has_selection,\n       use_overlays));\n}\n","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":388276,"func":"static int btrfs_ioctl_get_supported_features(struct file *file,\n\t\t\t\t\t      void __user *arg)\n{\n\tstatic struct btrfs_ioctl_feature_flags features[3] = {\n\t\tINIT_FEATURE_FLAGS(SUPP),\n\t\tINIT_FEATURE_FLAGS(SAFE_SET),\n\t\tINIT_FEATURE_FLAGS(SAFE_CLEAR)\n\t};\n\n\tif (copy_to_user(arg, &features, sizeof(features)))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":504623,"func":"static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)\n{\n\tstruct acpi_table_madt *madt = NULL;\n\n\tif (!phys_addr || !size || !cpu_has_apic)\n\t\treturn -EINVAL;\n\n\tmadt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);\n\tif (!madt) {\n\t\tprintk(KERN_WARNING PREFIX \"Unable to map MADT\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\tif (madt->lapic_address) {\n\t\tacpi_lapic_addr = (u64) madt->lapic_address;\n\n\t\tprintk(KERN_DEBUG PREFIX \"Local APIC address 0x%08x\\n\",\n\t\t       madt->lapic_address);\n\t}\n\n\tacpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);\n\n\treturn 0;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":89751,"func":"static inline u32 nfsd4_getfh_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)\n{\n\treturn (op_encode_hdr_size + 1) * sizeof(__be32) + NFS4_FHSIZE;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":388006,"func":"set_display_device (GdmSession *self,\n                    const char *name)\n{\n        g_debug (\"GdmSession: Setting display device: %s\", name);\n        g_free (self->priv->display_device);\n        self->priv->display_device = g_strdup (name);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":410022,"func":"\nstatic inline int skb_inner_transport_offset(const struct sk_buff *skb)\n{\n\treturn skb_inner_transport_header(skb) - skb->data;","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":244970,"func":"  virtual ~DisablePluginHelper() {}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":360098,"func":"get_pixbuf_for_content (goffset file_len,\n\t\t\tchar *file_contents)\n{\n\tgboolean res;\n\tGdkPixbuf *pixbuf, *pixbuf2;\n\tGdkPixbufLoader *loader;\n\tgsize chunk_len;\n\tpixbuf = NULL;\n\t\n\tloader = gdk_pixbuf_loader_new ();\n\tg_signal_connect (loader, \"size-prepared\",\n\t\t\t  G_CALLBACK (thumbnail_loader_size_prepared),\n\t\t\t  NULL);\n\n\t\/* For some reason we have to write in chunks, or gdk-pixbuf fails *\/\n\tres = TRUE;\n\twhile (res && file_len > 0) {\n\t\tchunk_len = file_len;\n\t\tres = gdk_pixbuf_loader_write (loader, file_contents, chunk_len, NULL);\n\t\tfile_contents += chunk_len;\n\t\tfile_len -= chunk_len;\n\t}\n\tif (res) {\n\t\tres = gdk_pixbuf_loader_close (loader, NULL);\n\t}\n\tif (res) {\n\t\tpixbuf = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader));\n\t}\n\tg_object_unref (G_OBJECT (loader));\n\n\tif (pixbuf) {\n\t\tpixbuf2 = gdk_pixbuf_apply_embedded_orientation (pixbuf);\n\t\tg_object_unref (pixbuf);\n\t\tpixbuf = pixbuf2;\n\t}\n\treturn pixbuf;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":352413,"func":"        void clear()\n        {\n            req = crow::request();\n            header_field.clear();\n            header_value.clear();\n            header_building_state = 0;\n            qs_point = 0;\n        }","target":1,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":122330,"func":"static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *group)\n{\n  struct NntpData *nntp_data = mutt_hash_find(nserv->groups_hash, group);\n  if (nntp_data)\n    return nntp_data;\n\n  size_t len = strlen(group) + 1;\n  \/* create NntpData structure and add it to hash *\/\n  nntp_data = mutt_mem_calloc(1, sizeof(struct NntpData) + len);\n  nntp_data->group = (char *) nntp_data + sizeof(struct NntpData);\n  mutt_str_strfcpy(nntp_data->group, group, len);\n  nntp_data->nserv = nserv;\n  nntp_data->deleted = true;\n  mutt_hash_insert(nserv->groups_hash, nntp_data->group, nntp_data);\n\n  \/* add NntpData to list *\/\n  if (nserv->groups_num >= nserv->groups_max)\n  {\n    nserv->groups_max *= 2;\n    mutt_mem_realloc(&nserv->groups_list, nserv->groups_max * sizeof(nntp_data));\n  }\n  nserv->groups_list[nserv->groups_num++] = nntp_data;\n\n  return nntp_data;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":483763,"func":"static inline void hugetlb_unregister_node(struct node *node) {}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":296686,"func":"repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned long long notfound)\n{\n  unsigned char *dp;\n  Repokey *key;\n  unsigned int high, low;\n\n  dp = find_key_data(data, solvid, keyname, &key);\n  if (!dp)\n    return notfound;\n  switch (key->type)\n    {\n    case REPOKEY_TYPE_NUM:\n      data_read_num64(dp, &low, &high);\n      return (unsigned long long)high << 32 | low;\n    case REPOKEY_TYPE_CONSTANT:\n      return key->size;\n    default:\n      return notfound;\n    }\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":330526,"func":"static void stop_tco(const TestData *d)\n\n{\n\n    uint32_t val;\n\n\n\n    val = qpci_io_readw(d->dev, d->tco_io_base + TCO1_CNT);\n\n    val |= TCO_TMR_HLT;\n\n    qpci_io_writew(d->dev, d->tco_io_base + TCO1_CNT, val);\n\n}\n","target":1,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":101804,"func":"static inline void syn_flood_warning(struct sk_buff *skb)\n{\n#ifdef CONFIG_SYN_COOKIES\n\tif (sysctl_tcp_syncookies)\n\t\tprintk(KERN_INFO\n\t\t       \"TCPv6: Possible SYN flooding on port %d. \"\n\t\t       \"Sending cookies.\\n\", ntohs(tcp_hdr(skb)->dest));\n\telse\n#endif\n\t\tprintk(KERN_INFO\n\t\t       \"TCPv6: Possible SYN flooding on port %d. \"\n\t\t       \"Dropping request.\\n\", ntohs(tcp_hdr(skb)->dest));\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":59592,"func":"static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)\n{\n\tatomic_inc(&bbio->error);\n\tif (atomic_dec_and_test(&bbio->stripes_pending)) {\n\t\t\/* Should be the original bio. *\/\n\t\tWARN_ON(bio != bbio->orig_bio);\n\n\t\tbtrfs_io_bio(bio)->mirror_num = bbio->mirror_num;\n\t\tbio->bi_iter.bi_sector = logical >> 9;\n\t\tif (atomic_read(&bbio->error) > bbio->max_errors)\n\t\t\tbio->bi_status = BLK_STS_IOERR;\n\t\telse\n\t\t\tbio->bi_status = BLK_STS_OK;\n\t\tbtrfs_end_bbio(bbio, bio);\n\t}\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":317131,"func":"static struct page *new_node_page(struct page *page, unsigned long node, int **x)\n{\n\treturn alloc_pages_exact_node(node, GFP_HIGHUSER_MOVABLE, 0);\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":290214,"func":"IN_PROC_BROWSER_TEST_F ( ExtensionMessageBubbleViewBrowserTest , ExtensionBubbleAnchoredToAppMenuWithOtherAction ) {\n TestBubbleAnchoredToAppMenuWithOtherAction ( ) ;\n }","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":84120,"func":"skip_stream(struct archive_read *a, size_t skip_bytes)\n{\n\tstruct _7zip *zip = (struct _7zip *)a->format->data;\n\tconst void *p;\n\tint64_t skipped_bytes;\n\tsize_t bytes = skip_bytes;\n\n\tif (zip->folder_index == 0) {\n\t\t\/*\n\t\t * Optimization for a list mode.\n\t\t * Avoid unncecessary decoding operations.\n\t\t *\/\n\t\tzip->si.ci.folders[zip->entry->folderIndex].skipped_bytes\n\t\t    += skip_bytes;\n\t\treturn (skip_bytes);\n\t}\n\n\twhile (bytes) {\n\t\tskipped_bytes = read_stream(a, &p, bytes, 0);\n\t\tif (skipped_bytes < 0)\n\t\t\treturn (skipped_bytes);\n\t\tif (skipped_bytes == 0) {\n\t\t\tarchive_set_error(&a->archive,\n\t\t\t    ARCHIVE_ERRNO_FILE_FORMAT,\n\t\t\t    \"Truncated 7-Zip file body\");\n\t\t\treturn (ARCHIVE_FATAL);\n\t\t}\n\t\tbytes -= (size_t)skipped_bytes;\n\t\tif (zip->pack_stream_bytes_unconsumed)\n\t\t\tread_consume(a);\n\t}\n\treturn (skip_bytes);\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":12028,"func":" int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc)\n {\n     xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;\n     __GLX_DECLARE_SWAP_VARIABLES;\n \n     __GLX_SWAP_SHORT(&req->length);\n     __GLX_SWAP_INT(&req->context);\n     __GLX_SWAP_INT(&req->visual);\n    return __glXDisp_CreateContext(cl, pc);\n}\n","target":1,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":177733,"func":"static int lua_ap_getdir(lua_State *L)\n{\n    request_rec    *r;\n    apr_dir_t      *thedir;\n    apr_finfo_t    file_info;\n    apr_status_t   status;\n    const char     *directory;\n\n    luaL_checktype(L, 1, LUA_TUSERDATA);\n    luaL_checktype(L, 2, LUA_TSTRING);\n    r = ap_lua_check_request_rec(L, 1);\n    directory = lua_tostring(L, 2);\n    if (apr_dir_open(&thedir, directory, r->pool) == APR_SUCCESS) {\n        int i = 0;\n        lua_newtable(L);\n        do {\n            status = apr_dir_read(&file_info, APR_FINFO_NAME, thedir);\n            if (APR_STATUS_IS_INCOMPLETE(status)) {\n                continue; \/* ignore un-stat()able files *\/\n            }\n            else if (status != APR_SUCCESS) {\n                break;\n            }\n            lua_pushinteger(L, ++i);\n            lua_pushstring(L, file_info.name);\n            lua_settable(L, -3);\n\n        } while (1);\n        apr_dir_close(thedir);\n        return 1;\n    }\n    else {\n        return 0;\n    }\n}\n","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":137847,"func":"static int mem_cgroup_oom_control_write(struct cgroup *cgrp,\n\tstruct cftype *cft, u64 val)\n{\n\tstruct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);\n\tstruct mem_cgroup *parent;\n\n\t\/* cannot set to root cgroup and only 0 and 1 are allowed *\/\n\tif (!cgrp->parent || !((val == 0) || (val == 1)))\n\t\treturn -EINVAL;\n\n\tparent = mem_cgroup_from_cont(cgrp->parent);\n\n\tcgroup_lock();\n\t\/* oom-kill-disable is a flag for subhierarchy. *\/\n\tif ((parent->use_hierarchy) ||\n\t    (memcg->use_hierarchy && !list_empty(&cgrp->children))) {\n\t\tcgroup_unlock();\n\t\treturn -EINVAL;\n\t}\n\tmemcg->oom_kill_disable = val;\n\tif (!val)\n\t\tmemcg_oom_recover(memcg);\n\tcgroup_unlock();\n\treturn 0;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":55347,"func":"static void expire_timers(struct timer_base *base, struct hlist_head *head)\n{\n\t\/*\n\t * This value is required only for tracing. base->clk was\n\t * incremented directly before expire_timers was called. But expiry\n\t * is related to the old base->clk value.\n\t *\/\n\tunsigned long baseclk = base->clk - 1;\n\n\twhile (!hlist_empty(head)) {\n\t\tstruct timer_list *timer;\n\t\tvoid (*fn)(struct timer_list *);\n\n\t\ttimer = hlist_entry(head->first, struct timer_list, entry);\n\n\t\tbase->running_timer = timer;\n\t\tdetach_timer(timer, true);\n\n\t\tfn = timer->function;\n\n\t\tif (timer->flags & TIMER_IRQSAFE) {\n\t\t\traw_spin_unlock(&base->lock);\n\t\t\tcall_timer_fn(timer, fn, baseclk);\n\t\t\tbase->running_timer = NULL;\n\t\t\traw_spin_lock(&base->lock);\n\t\t} else {\n\t\t\traw_spin_unlock_irq(&base->lock);\n\t\t\tcall_timer_fn(timer, fn, baseclk);\n\t\t\tbase->running_timer = NULL;\n\t\t\ttimer_sync_wait_running(base);\n\t\t\traw_spin_lock_irq(&base->lock);\n\t\t}\n\t}\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":405033,"func":"static void l2cap_send_move_chan_cfm(struct l2cap_chan *chan, u16 result)\n{\n\tstruct l2cap_move_chan_cfm cfm;\n\n\tBT_DBG(\"chan %p, result 0x%4.4x\", chan, result);\n\n\tchan->ident = l2cap_get_ident(chan->conn);\n\n\tcfm.icid = cpu_to_le16(chan->scid);\n\tcfm.result = cpu_to_le16(result);\n\n\tl2cap_send_cmd(chan->conn, chan->ident, L2CAP_MOVE_CHAN_CFM,\n\t\t       sizeof(cfm), &cfm);\n\n\t__set_chan_timer(chan, L2CAP_MOVE_TIMEOUT);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":326196,"func":"bool desc_ring_set_size(DescRing *ring, uint32_t size)\n\n{\n\n    int i;\n\n\n\n    if (size < 2 || size > 0x10000 || (size & (size - 1))) {\n\n        DPRINTF(\"ERROR: ring[%d] size (%d) not a power of 2 \"\n\n                \"or in range [2, 64K]\\n\", ring->index, size);\n\n        return false;\n\n    }\n\n\n\n    for (i = 0; i < ring->size; i++) {\n\n        if (ring->info[i].buf) {\n\n            g_free(ring->info[i].buf);\n\n        }\n\n    }\n\n\n\n    ring->size = size;\n\n    ring->head = ring->tail = 0;\n\n\n\n    ring->info = g_realloc(ring->info, size * sizeof(DescInfo));\n\n    if (!ring->info) {\n\n        return false;\n\n    }\n\n\n\n    memset(ring->info, 0, size * sizeof(DescInfo));\n\n\n\n    for (i = 0; i < size; i++) {\n\n        ring->info[i].ring = ring;\n\n    }\n\n\n\n    return true;\n\n}\n","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":206431,"func":"static void cirrus_mmio_write(void *opaque, hwaddr addr,\n                              uint64_t val, unsigned size)\n{\n    CirrusVGAState *s = opaque;\n\n    if (addr >= 0x100) {\n\tcirrus_mmio_blt_write(s, addr - 0x100, val);\n    } else {\n        cirrus_vga_ioport_write(s, addr + 0x10, val, size);\n    }\n}\n","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":402074,"func":"int\ne1000e_core_post_load(E1000ECore *core)\n{\n    NetClientState *nc = qemu_get_queue(core->owner_nic);\n\n    \/* nc.link_down can't be migrated, so infer link_down according\n     * to link status bit in core.mac[STATUS].\n     *\/\n    nc->link_down = (core->mac[STATUS] & E1000_STATUS_LU) == 0;\n\n    return 0;","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":19302,"func":"static int dissect_h245_SEQUENCE_OF_MediaDistributionCapability ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h245_SEQUENCE_OF_MediaDistributionCapability , SEQUENCE_OF_MediaDistributionCapability_sequence_of ) ;\n return offset ;\n }","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":363225,"func":"release_buffer (hb_buffer_t *buffer, gboolean free_buffer)\n{\n  if (G_LIKELY (!free_buffer))\n    {\n      hb_buffer_clear (buffer);\n      G_UNLOCK (cached_buffer);\n    }\n  else\n    hb_buffer_free (buffer);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":300606,"func":"static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)\n{\n\tint idx;\n\tint s_idx = cb->family;\n\n\tif (s_idx == 0)\n\t\ts_idx = 1;\n\tfor (idx = 1; idx <= RTNL_FAMILY_MAX; idx++) {\n\t\tint type = cb->nlh->nlmsg_type-RTM_BASE;\n\t\tif (idx < s_idx || idx == PF_PACKET)\n\t\t\tcontinue;\n\t\tif (rtnl_msg_handlers[idx] == NULL ||\n\t\t    rtnl_msg_handlers[idx][type].dumpit == NULL)\n\t\t\tcontinue;\n\t\tif (idx > s_idx) {\n\t\t\tmemset(&cb->args[0], 0, sizeof(cb->args));\n\t\t\tcb->prev_seq = 0;\n\t\t\tcb->seq = 0;\n\t\t}\n\t\tif (rtnl_msg_handlers[idx][type].dumpit(skb, cb))\n\t\t\tbreak;\n\t}\n\tcb->family = idx;\n\n\treturn skb->len;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":156355,"func":"  void ms_handle_fast_accept(Connection *con) override {\n    Session *s = static_cast<Session*>(con->get_priv());\n    if (!s) {\n      s = new Session(con);\n      con->set_priv(s->get());\n    }\n    s->put();\n  }","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":331637,"func":"static int64_t read_ts(const char *s)\n\n{\n\n    int hh, mm, ss, ms;\n\n    if (sscanf(s, \"%u:%u:%u.%u\", &hh, &mm, &ss, &ms) == 4) return (hh*3600 + mm*60 + ss) * 1000 + ms;\n\n    if (sscanf(s,    \"%u:%u.%u\",      &mm, &ss, &ms) == 3) return (          mm*60 + ss) * 1000 + ms;\n\n    return AV_NOPTS_VALUE;\n\n}\n","target":1,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":396627,"func":"  GC_API void * GC_CALL GC_generate_random_valid_address(void)\n  {\n    ptr_t result;\n    ptr_t base;\n    do {\n      result = GC_generate_random_heap_address();\n      base = GC_base(result);\n    } while (base == 0 || !GC_is_marked(base));\n    return result;\n  }","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":238898,"func":"static void create_certinfo(struct curl_certinfo *ci, zval *listcode)\n{\n\tint i;\n\n\tif (ci) {\n\t\tzval certhash;\n\n\t\tfor (i=0; i<ci->num_of_certs; i++) {\n\t\t\tstruct curl_slist *slist;\n\n\t\t\tarray_init(&certhash);\n\t\t\tfor (slist = ci->certinfo[i]; slist; slist = slist->next) {\n\t\t\t\tint len;\n\t\t\t\tchar s[64];\n\t\t\t\tchar *tmp;\n\t\t\t\tstrncpy(s, slist->data, 64);\n\t\t\t\ttmp = memchr(s, ':', 64);\n\t\t\t\tif(tmp) {\n\t\t\t\t\t*tmp = '\\0';\n\t\t\t\t\tlen = strlen(s);\n\t\t\t\t\tadd_assoc_string(&certhash, s, &slist->data[len+1]);\n\t\t\t\t} else {\n\t\t\t\t\tphp_error_docref(NULL, E_WARNING, \"Could not extract hash key from certificate info\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tadd_next_index_zval(listcode, &certhash);\n\t\t}\n\t}\n}\n","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":409489,"func":"static void bnx2x_remove_one(struct pci_dev *pdev)\n{\n\tstruct net_device *dev = pci_get_drvdata(pdev);\n\tstruct bnx2x *bp;\n\n\tif (!dev) {\n\t\tdev_err(&pdev->dev, \"BAD net device from bnx2x_init_one\\n\");\n\t\treturn;\n\t}\n\tbp = netdev_priv(dev);\n\n\t__bnx2x_remove(pdev, dev, bp, true);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":453276,"func":"static void add_event_to_ctx(struct perf_event *event,\n\t\t\t       struct perf_event_context *ctx)\n{\n\tlist_add_event(event, ctx);\n\tperf_group_attach(event);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":369771,"func":"void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)\n{\n#if SPICE_INTERFACE_QXL_MINOR >= 1\n    qxl_send_events(qxl, QXL_INTERRUPT_ERROR);\n#endif\n    if (qxl->guestdebug) {\n        va_list ap;\n        va_start(ap, msg);\n        fprintf(stderr, \"qxl-%d: guest bug: \", qxl->id);\n        vfprintf(stderr, msg, ap);\n        fprintf(stderr, \"\\n\");\n        va_end(ap);\n    }\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":459762,"func":"dissect_kafka_string(proto_tree *tree, int hf_item, tvbuff_t *tvb, packet_info *pinfo, int offset, int flexible,\n                             int *p_offset, int *p_length)\n{\n    if (flexible) {\n        return dissect_kafka_compact_string(tree, hf_item, tvb, pinfo, offset, p_offset, p_length);\n    } else {\n        return dissect_kafka_regular_string(tree, hf_item, tvb, pinfo, offset, p_offset, p_length);\n    }\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":435935,"func":"#endif\nstatic void netdev_unbind_all_sb_channels(struct net_device *dev)\n{\n\tstruct netdev_queue *txq = &dev->_tx[dev->num_tx_queues];\n\n\t\/* Unbind any subordinate channels *\/\n\twhile (txq-- != &dev->_tx[0]) {\n\t\tif (txq->sb_dev)\n\t\t\tnetdev_unbind_sb_channel(dev, txq->sb_dev);\n\t}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":335239,"func":"static int vc1_parse_init(AVCodecParserContext *s)\n\n{\n\n    VC1ParseContext *vpc = s->priv_data;\n\n    vpc->v.s.slice_context_count = 1;\n\n    return 0;\n\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":333488,"func":"static int cloop_read(BlockDriverState *bs, int64_t sector_num,\n\n                    uint8_t *buf, int nb_sectors)\n\n{\n\n    BDRVCloopState *s = bs->opaque;\n\n    int i;\n\n\n\n    for (i = 0; i < nb_sectors; i++) {\n\n        uint32_t sector_offset_in_block =\n\n            ((sector_num + i) % s->sectors_per_block),\n\n            block_num = (sector_num + i) \/ s->sectors_per_block;\n\n        if (cloop_read_block(bs, block_num) != 0) {\n\n            return -1;\n\n        }\n\n        memcpy(buf + i * 512,\n\n            s->uncompressed_block + sector_offset_in_block * 512, 512);\n\n    }\n\n    return 0;\n\n}\n","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":39674,"func":"void BytecodeFunctionGenerator::shrinkJump(offset_t loc) {\n  \/\/ We are shrinking a long jump into a short jump.\n  \/\/ The size of operand reduces from 4 bytes to 1 byte, a delta of 3.\n  const static int ShrinkOffset = 3;\n  std::rotate(\n      opcodes_.begin() + loc,\n      opcodes_.begin() + loc + ShrinkOffset,\n      opcodes_.end());\n  opcodes_.resize(opcodes_.size() - ShrinkOffset);\n\n  \/\/ Change this instruction from long jump to short jump.\n  longToShortJump(loc - 1);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":450177,"func":"static int ctnetlink_flush_conntrack(struct net *net,\n\t\t\t\t     const struct nlattr * const cda[],\n\t\t\t\t     u32 portid, int report, u8 family)\n{\n\tstruct ctnetlink_filter *filter = NULL;\n\n\tif (ctnetlink_needs_filter(family, cda)) {\n\t\tif (cda[CTA_FILTER])\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tfilter = ctnetlink_alloc_filter(cda, family);\n\t\tif (IS_ERR(filter))\n\t\t\treturn PTR_ERR(filter);\n\t}\n\n\tnf_ct_iterate_cleanup_net(net, ctnetlink_flush_iterate, filter,\n\t\t\t\t  portid, report);\n\tkfree(filter);\n\n\treturn 0;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":253428,"func":"  void DidDeleteOriginData(QuotaStatusCode status) {\n    DCHECK_GT(remaining_deleters_, 0);\n\n    if (status != kQuotaStatusOk)\n      ++error_count_;\n\n    if (--remaining_deleters_ == 0)\n      CallCompleted();\n  }\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":25668,"func":"static vpx_codec_err_t ctrl_set_roi_map ( vpx_codec_alg_priv_t * ctx , va_list args ) {\n ( void ) ctx ;\n ( void ) args ;\n return VPX_CODEC_INVALID_PARAM ;\n }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":413014,"func":"void __init set_proc_pid_nlink(void)\n{\n\tnlink_tid = pid_entry_nlink(tid_base_stuff, ARRAY_SIZE(tid_base_stuff));\n\tnlink_tgid = pid_entry_nlink(tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":520618,"func":"  bool const_item() const { return false; }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":108344,"func":"entry_guard_succeeded(circuit_guard_state_t **guard_state_p)\n{\n  if (BUG(*guard_state_p == NULL))\n    return GUARD_USABLE_NEVER;\n\n  entry_guard_t *guard = entry_guard_handle_get((*guard_state_p)->guard);\n  if (! guard || BUG(guard->in_selection == NULL))\n    return GUARD_USABLE_NEVER;\n\n  unsigned newstate =\n    entry_guards_note_guard_success(guard->in_selection, guard,\n                                    (*guard_state_p)->state);\n\n  (*guard_state_p)->state = newstate;\n  (*guard_state_p)->state_set_at = approx_time();\n\n  if (newstate == GUARD_CIRC_STATE_COMPLETE) {\n    return GUARD_USABLE_NOW;\n  } else {\n    return GUARD_MAYBE_USABLE_LATER;\n  }\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":15317,"func":"void fz_set_icc_bgr ( fz_context * ctx , fz_colorspace * cs ) {\n fz_iccprofile * profile ;\n if ( cs == NULL || ! fz_colorspace_is_icc ( ctx , cs ) ) return ;\n profile = cs -> data ;\n profile -> bgr = 1 ;\n return ;\n }","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":105361,"func":"static void *tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos)\n{\n\t(*pos)++;\n\treturn (*pos < NR_LDISCS) ? pos : NULL;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":203000,"func":"void GLSurfaceOzoneSurfacelessSurfaceImpl::SwapBuffersAsync(\n    const SwapCompletionCallback& callback) {\n  if (!images_[current_surface_]->ScheduleOverlayPlane(\n          widget_, 0, OverlayTransform::OVERLAY_TRANSFORM_NONE,\n          gfx::Rect(GetSize()), gfx::RectF(1, 1))) {\n    callback.Run(gfx::SwapResult::SWAP_FAILED);\n    return;\n  }\n  GLSurfaceOzoneSurfaceless::SwapBuffersAsync(callback);\n  current_surface_ ^= 1;\n  BindFramebuffer();\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":448181,"func":"static int netns_exec(int argc, char **argv)\n{\n\t\/* Setup the proper environment for apps that are not netns\n\t * aware, and execute a program in that environment.\n\t *\/\n\tconst char *cmd;\n\n\tif (argc < 1 && !do_all) {\n\t\tfprintf(stderr, \"No netns name specified\\n\");\n\t\treturn -1;\n\t}\n\tif ((argc < 2 && !do_all) || (argc < 1 && do_all)) {\n\t\tfprintf(stderr, \"No command specified\\n\");\n\t\treturn -1;\n\t}\n\n\tif (do_all)\n\t\treturn do_each_netns(on_netns_exec, --argv, 1);\n\n\tif (netns_switch(argv[0]))\n\t\treturn -1;\n\n\t\/* we just changed namespaces. clear any vrf association\n\t * with prior namespace before exec'ing command\n\t *\/\n\tvrf_reset();\n\n\t\/* ip must return the status of the child,\n\t * but do_cmd() will add a minus to this,\n\t * so let's add another one here to cancel it.\n\t *\/\n\tcmd = argv[1];\n\treturn -cmd_exec(cmd, argv + 1, !!batch_mode);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":96202,"func":"get_option_sctx(char *name)\n{\n    int idx = findoption((char_u *)name);\n\n    if (idx >= 0)\n\treturn &options[idx].script_ctx;\n    siemsg(\"no such option: %s\", name);\n    return NULL;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":159841,"func":"static inline void gen_neon_widen(TCGv_i64 dest, TCGv src, int size, int u)\n\n{\n\n    if (u) {\n\n        switch (size) {\n\n        case 0: gen_helper_neon_widen_u8(dest, src); break;\n\n        case 1: gen_helper_neon_widen_u16(dest, src); break;\n\n        case 2: tcg_gen_extu_i32_i64(dest, src); break;\n\n        default: abort();\n\n        }\n\n    } else {\n\n        switch (size) {\n\n        case 0: gen_helper_neon_widen_s8(dest, src); break;\n\n        case 1: gen_helper_neon_widen_s16(dest, src); break;\n\n        case 2: tcg_gen_ext_i32_i64(dest, src); break;\n\n        default: abort();\n\n        }\n\n    }\n\n    dead_tmp(src);\n\n}\n","target":1,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":138954,"func":"void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev)\n{\n\tstruct btrfs_fs_devices *fs_devices = tgtdev->fs_info->fs_devices;\n\n\tWARN_ON(!tgtdev);\n\tmutex_lock(&fs_devices->device_list_mutex);\n\n\tbtrfs_sysfs_rm_device_link(fs_devices, tgtdev);\n\n\tif (tgtdev->bdev)\n\t\tfs_devices->open_devices--;\n\n\tfs_devices->num_devices--;\n\n\tbtrfs_assign_next_active_device(tgtdev, NULL);\n\n\tlist_del_rcu(&tgtdev->dev_list);\n\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\t\/*\n\t * The update_dev_time() with in btrfs_scratch_superblocks()\n\t * may lead to a call to btrfs_show_devname() which will try\n\t * to hold device_list_mutex. And here this device\n\t * is already out of device list, so we don't have to hold\n\t * the device_list_mutex lock.\n\t *\/\n\tbtrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str);\n\n\tbtrfs_close_bdev(tgtdev);\n\tcall_rcu(&tgtdev->rcu, free_device_rcu);\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":248724,"func":"void WebLocalFrameImpl::StopFinding(StopFindAction action) {\n  bool clear_selection = action == kStopFindActionClearSelection;\n  if (clear_selection)\n    ExecuteCommand(WebString::FromUTF8(\"Unselect\"));\n\n  if (text_finder_) {\n    if (!clear_selection)\n      text_finder_->SetFindEndstateFocusAndSelection();\n    text_finder_->StopFindingAndClearSelection();\n  }\n\n  if (action == kStopFindActionActivateSelection && IsFocused()) {\n    WebDocument doc = GetDocument();\n    if (!doc.IsNull()) {\n      WebElement element = doc.FocusedElement();\n      if (!element.IsNull())\n        element.SimulateClick();\n    }\n  }\n}\n","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":438392,"func":"  void set_primaries(uint64_t primaries) { primaries_ = primaries; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":155193,"func":"static void announce_device(struct usb_device *udev)\n{\n\tdev_info(&udev->dev, \"New USB device found, idVendor=%04x, idProduct=%04x\\n\",\n\t\tle16_to_cpu(udev->descriptor.idVendor),\n\t\tle16_to_cpu(udev->descriptor.idProduct));\n\tdev_info(&udev->dev,\n\t\t\"New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\\n\",\n\t\tudev->descriptor.iManufacturer,\n\t\tudev->descriptor.iProduct,\n\t\tudev->descriptor.iSerialNumber);\n\tshow_string(udev, \"Product\", udev->product);\n\tshow_string(udev, \"Manufacturer\", udev->manufacturer);\n\tshow_string(udev, \"SerialNumber\", udev->serial);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":211832,"func":"static void reflectedTreatNullAsNullStringCustomURLAttrAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n    CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;\n    TestObjectV8Internal::reflectedTreatNullAsNullStringCustomURLAttrAttributeSetter(jsValue, info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":414189,"func":"email_compare (EContact *contact1,\n               EContact *contact2)\n{\n\tconst gchar *email1, *email2;\n\tgint i;\n\t\/*\n\tif (e_contact_get (contact1, E_CONTACT_IS_LIST))\n\t\treturn TRUE;\n\t*\/\n\n\tfor (i = 0; i < 4; i++) {\n\t\tgboolean equal;\n\t\temail1 = e_contact_get_const (contact1, email_ids[i]);\n\t\temail2 = e_contact_get_const (contact2, email_ids[i]);\n\n\t\tif (email1 && email2)\n\t\t\tequal = !strcmp (email1, email2);\n\t\telse\n\t\t\tequal = (!!email1 == !!email2);\n\n\t\tif (!equal)\n\t\t\treturn equal;\n\t}\n\n\treturn TRUE;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":517131,"func":"  Item_ignore_value(THD *thd, Name_resolution_context *context_arg)\n    :Item_default_value(thd, context_arg)\n  {};","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":368389,"func":"extrainfo_free(extrainfo_t *extrainfo)\n{\n  if (!extrainfo)\n    return;\n  tor_free(extrainfo->cache_info.signed_descriptor_body);\n  tor_free(extrainfo->pending_sig);\n\n  \/* XXXX remove this if it turns out to slow us down. *\/\n  memset(extrainfo, 88, sizeof(extrainfo_t)); \/* debug bad memory usage *\/\n  tor_free(extrainfo);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":168049,"func":"PHP_FUNCTION(pg_port)\n{\n\tphp_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_PORT);\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":231575,"func":"bool PrintViewManagerBase::OnMessageReceived(\n    const IPC::Message& message,\n    content::RenderFrameHost* render_frame_host) {\n  bool handled = true;\n  IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBase, message)\n    IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage)\n    IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,\n                        OnShowInvalidPrinterSettingsError)\n    IPC_MESSAGE_UNHANDLED(handled = false)\n  IPC_END_MESSAGE_MAP()\n  return handled || PrintManager::OnMessageReceived(message, render_frame_host);\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":29927,"func":"EC_KEY * d2i_ECParameters ( EC_KEY * * a , const unsigned char * * in , long len ) {\n EC_KEY * ret ;\n if ( in == NULL || * in == NULL ) {\n ECerr ( EC_F_D2I_ECPARAMETERS , ERR_R_PASSED_NULL_PARAMETER ) ;\n return NULL ;\n }\n if ( a == NULL || * a == NULL ) {\n if ( ( ret = EC_KEY_new ( ) ) == NULL ) {\n ECerr ( EC_F_D2I_ECPARAMETERS , ERR_R_MALLOC_FAILURE ) ;\n return NULL ;\n }\n if ( a ) * a = ret ;\n }\n else ret = * a ;\n if ( ! d2i_ECPKParameters ( & ret -> group , in , len ) ) {\n ECerr ( EC_F_D2I_ECPARAMETERS , ERR_R_EC_LIB ) ;\n return NULL ;\n }\n return ret ;\n }","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":69583,"func":"static int pop_check_mailbox (CONTEXT *ctx, int *index_hint)\n{\n  int ret;\n  POP_DATA *pop_data = (POP_DATA *)ctx->data;\n\n  if ((pop_data->check_time + PopCheckTimeout) > time (NULL))\n    return 0;\n\n  pop_logout (ctx);\n\n  mutt_socket_close (pop_data->conn);\n\n  if (pop_open_connection (pop_data) < 0)\n    return -1;\n\n  ctx->size = pop_data->size;\n\n  mutt_message _(\"Checking for new messages...\");\n\n  ret = pop_fetch_headers (ctx);\n  pop_clear_cache (pop_data);\n\n  if (ret < 0)\n    return -1;\n\n  if (ret > 0)\n    return MUTT_NEW_MAIL;\n\n  return 0;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":416067,"func":"zswapcolors(i_ctx_t * i_ctx_p)\n{\n    ref_colorspace tmp_cs;\n    ref            tmp_pat;\n\n    tmp_cs                = istate->colorspace[0];\n    istate->colorspace[0] = istate->colorspace[1];\n    istate->colorspace[1] = tmp_cs;\n\n    tmp_pat            = istate->pattern[0];\n    istate->pattern[0] = istate->pattern[1];\n    istate->pattern[1] = tmp_pat;\n\n    return gs_swapcolors(igs);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":269627,"func":"test_bson_append_deep (void)\n{\n   bson_t *a;\n   bson_t *tmp;\n   int i;\n\n   a = bson_new ();\n\n   for (i = 0; i < 100; i++) {\n      tmp = a;\n      a = bson_new ();\n      BSON_ASSERT (bson_append_document (a, \"a\", -1, tmp));\n      bson_destroy (tmp);\n   }\n\n   BSON_ASSERT_BSON_EQUAL_FILE (a, \"test38.bson\");\n\n   bson_destroy (a);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":30555,"func":"int kvm_device_intx_assign ( KVMState * s , uint32_t dev_id , bool use_host_msi , uint32_t guest_irq ) {\n uint32_t irq_type = KVM_DEV_IRQ_GUEST_INTX | ( use_host_msi ? KVM_DEV_IRQ_HOST_MSI : KVM_DEV_IRQ_HOST_INTX ) ;\n return kvm_assign_irq_internal ( s , dev_id , irq_type , guest_irq ) ;\n }","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":161995,"func":"MonoReflectionEvent *\nmono_reflection_event_builder_get_event_info (MonoReflectionTypeBuilder *tb, MonoReflectionEventBuilder *eb)\n{\n\tg_assert_not_reached ();\n\treturn NULL;","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":224689,"func":"  void OnJsExecutionDone(base::Closure callback, const base::Value* value) {\n    js_result_.reset(value->DeepCopy());\n    callback.Run();\n  }\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":17930,"func":"static unsigned int hc_entries ( unsigned int cnt ) {\n cnt = cnt & 7 ? ( cnt \/ 8 ) + 1 : cnt \/ 8 ;\n return cnt < avail_tree_table_sz ? cnt : avail_tree_table_sz - 1 ;\n }","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":384598,"func":"xmlTextReaderReadState(xmlTextReaderPtr reader) {\n    if (reader == NULL)\n\treturn(-1);\n    return(reader->mode);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":495556,"func":"u32 gf_isom_get_pssh_count(GF_ISOFile *file)\n{\n\tu32 count=0;\n\tu32 i=0;\n\tGF_Box *a_box;\n\tif (file->moov) {\n\t\twhile ((a_box = (GF_Box*)gf_list_enum(file->moov->child_boxes, &i))) {\n\t\t\tif (a_box->type != GF_ISOM_BOX_TYPE_PSSH) continue;\n\t\t\tcount++;\n\t\t}\n\t}\n\tif (file->meta) {\n\t\twhile ((a_box = (GF_Box*)gf_list_enum(file->meta->child_boxes, &i))) {\n\t\t\tif (a_box->type != GF_ISOM_BOX_TYPE_PSSH) continue;\n\t\t\tcount++;\n\t\t}\n\t}\n\treturn count;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":340526,"func":"static inline int writer_print_string(WriterContext *wctx,\n\n                                      const char *key, const char *val, int opt)\n\n{\n\n    const struct section *section = wctx->section[wctx->level];\n\n    int ret = 0;\n\n\n\n    if (opt && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS))\n\n        return 0;\n\n\n\n    if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {\n\n        wctx->writer->print_string(wctx, key, val);\n\n        wctx->nb_item[wctx->level]++;\n\n    }\n\n\n\n    return ret;\n\n}\n","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":66510,"func":"    inline unsigned int& exception_mode() {\n      return exception_mode(0,false);\n    }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":171557,"func":"static int auth_session_timeout_cb(CALLBACK_FRAME) {\n  pr_event_generate(\"core.timeout-session\", NULL);\n  pr_response_send_async(R_421,\n    _(\"Session Timeout (%d seconds): closing control connection\"),\n    TimeoutSession);\n\n  pr_log_pri(PR_LOG_INFO, \"%s\", \"FTP session timed out, disconnected\");\n  pr_session_disconnect(&auth_module, PR_SESS_DISCONNECT_TIMEOUT,\n    \"TimeoutSession\");\n\n  \/* no need to restart the timer -- session's over *\/\n  return 0;\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":178039,"func":"  bool HasPermissionsForFileSystem(const std::string& filesystem_id,\n                                   int permissions) {\n    FileSystemMap::const_iterator it =\n        filesystem_permissions_.find(filesystem_id);\n    if (it == filesystem_permissions_.end())\n      return false;\n    return (it->second & permissions) == permissions;\n  }\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":69473,"func":"bool CModules::OnUserCTCPReplyMessage(CCTCPMessage& Message) {\n    MODHALTCHK(OnUserCTCPReplyMessage(Message));\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":17602,"func":"static void g2rgb ( fz_context * ctx , fz_color_converter * cc , float * dv , const float * sv ) {\n dv [ 0 ] = sv [ 0 ] ;\n dv [ 1 ] = sv [ 0 ] ;\n dv [ 2 ] = sv [ 0 ] ;\n }","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":472028,"func":"STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__context s;\n   stbi__start_file(&s,f);\n   return stbi__loadf_main(&s,x,y,comp,req_comp);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":274732,"func":"static struct reg_code_blocks *\nS_alloc_code_blocks(pTHX_  int ncode)\n{\n     struct reg_code_blocks *cbs;\n    Newx(cbs, 1, struct reg_code_blocks);\n    cbs->count = ncode;\n    cbs->refcnt = 1;\n    SAVEDESTRUCTOR_X(S_free_codeblocks, cbs);\n    if (ncode)\n        Newx(cbs->cb, ncode, struct reg_code_block);\n    else\n        cbs->cb = NULL;\n    return cbs;","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":262064,"func":"static CPU_CONST *const_by_value(CPU_MODEL *cpu, int type, ut32 v) {\n\tCPU_CONST **clist, *citem;\n\n\tfor (clist = cpu->consts; *clist; clist++) {\n\t\tfor (citem = *clist; citem && citem->key; citem++) {\n\t\t\tif (citem->value == (MASK (citem->size * 8) & v)\n\t\t\t&& (type == CPU_CONST_NONE || type == citem->type)) {\n\t\t\t\treturn citem;\n\t\t\t}\n\t\t}\n\t}\n\tif (cpu->inherit_cpu_p)\n\t\treturn const_by_value (cpu->inherit_cpu_p, type, v);\n\treturn NULL;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":13031,"func":"     DisplayItemListTest()\n         : m_displayItemList(DisplayItemList::create())\n        , m_originalSlimmingPaintSubsequenceCachingEnabled(RuntimeEnabledFeatures::slimmingPaintSubsequenceCachingEnabled()) { }\n","target":1,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":9763,"func":"void AutofillPopupBaseView::AddExtraInitParams(\n    views::Widget::InitParams* params) {\n  params->opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;\n  params->shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;\n}\n","target":1,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":330915,"func":"static int inject_error(BlockDriverState *bs, BlkdebugRule *rule)\n\n{\n\n    BDRVBlkdebugState *s = bs->opaque;\n\n    int error = rule->options.inject.error;\n\n    bool immediately = rule->options.inject.immediately;\n\n\n\n    if (rule->options.inject.once) {\n\n        QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next);\n\n        remove_rule(rule);\n\n    }\n\n\n\n    if (!immediately) {\n\n        aio_bh_schedule_oneshot(bdrv_get_aio_context(bs), error_callback_bh,\n\n                                qemu_coroutine_self());\n\n        qemu_coroutine_yield();\n\n    }\n\n\n\n    return -error;\n\n}\n","target":1,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":88132,"func":"static int handle_interrupt_window(struct kvm_vcpu *vcpu)\n{\n\tvmcs_clear_bits(CPU_BASED_VM_EXEC_CONTROL,\n\t\t\tCPU_BASED_VIRTUAL_INTR_PENDING);\n\n\tkvm_make_request(KVM_REQ_EVENT, vcpu);\n\n\t++vcpu->stat.irq_window_exits;\n\treturn 1;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":252865,"func":"static int vcpu_mmio_read(struct kvm_vcpu *vcpu, gpa_t addr, int len, void *v)\n{\n\tint handled = 0;\n\tint n;\n\n\tdo {\n\t\tn = min(len, 8);\n\t\tif (!(vcpu->arch.apic &&\n\t\t      !kvm_iodevice_read(&vcpu->arch.apic->dev, addr, n, v))\n\t\t    && kvm_io_bus_read(vcpu->kvm, KVM_MMIO_BUS, addr, n, v))\n\t\t\tbreak;\n\t\ttrace_kvm_mmio(KVM_TRACE_MMIO_READ, n, addr, *(u64 *)v);\n\t\thandled += n;\n\t\taddr += n;\n\t\tlen -= n;\n\t\tv += n;\n\t} while (len);\n\n\treturn handled;\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":183767,"func":"void LocalFrameClientImpl::DidFinishSameDocumentNavigation(\n    HistoryItem* item,\n    WebHistoryCommitType commit_type,\n    bool content_initiated) {\n  bool should_create_history_entry = commit_type == kWebStandardCommit;\n  web_frame_->ViewImpl()->DidCommitLoad(should_create_history_entry, true);\n  if (web_frame_->Client()) {\n    web_frame_->Client()->DidFinishSameDocumentNavigation(\n        WebHistoryItem(item), commit_type, content_initiated);\n  }\n  virtual_time_pauser_.UnpauseVirtualTime();\n}\n","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":182905,"func":"void free_xbzrle_decoded_buf(void)\n{\n    g_free(xbzrle_decoded_buf);\n    xbzrle_decoded_buf = NULL;\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":466283,"func":"TEST_F(HttpConnectionManagerImplTest, Http10Rejected) {\n  setup(false, \"\");\n  EXPECT_CALL(*codec_, protocol()).Times(AnyNumber()).WillRepeatedly(Return(Protocol::Http10));\n  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> Http::Status {\n    decoder_ = &conn_manager_->newStream(response_encoder_);\n    RequestHeaderMapPtr headers{\n        new TestRequestHeaderMapImpl{{\":authority\", \"host\"}, {\":method\", \"GET\"}, {\":path\", \"\/\"}}};\n    decoder_->decodeHeaders(std::move(headers), true);\n    data.drain(4);\n    return Http::okStatus();\n  }));\n\n  EXPECT_CALL(response_encoder_, encodeHeaders(_, true))\n      .WillOnce(Invoke([](const ResponseHeaderMap& headers, bool) -> void {\n        EXPECT_EQ(\"426\", headers.getStatusValue());\n        EXPECT_EQ(\"close\", headers.getConnectionValue());\n      }));\n\n  Buffer::OwnedImpl fake_input(\"1234\");\n  conn_manager_->onData(fake_input, false);\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":465464,"func":"static void kvm_mmu_notifier_invalidate_range(struct mmu_notifier *mn,\n\t\t\t\t\t      struct mm_struct *mm,\n\t\t\t\t\t      unsigned long start, unsigned long end)\n{\n\tstruct kvm *kvm = mmu_notifier_to_kvm(mn);\n\tint idx;\n\n\tidx = srcu_read_lock(&kvm->srcu);\n\tkvm_arch_mmu_notifier_invalidate_range(kvm, start, end);\n\tsrcu_read_unlock(&kvm->srcu, idx);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":373378,"func":"static const char *plug_to_string(test_plug_t plug)\n{\n\tswitch (plug) {\n\t\tcase PLUG_NONE:\n\t\t\treturn \"open,   \";\n\t\tcase PLUG_RESET:\n\t\t\treturn \"closed, \";\n\t\tcase PLUG_TIMEOUT:\n\t\t\treturn \"timeout,\";\n\t\tdefault:\n\t\t\treturn \"unknown,\";\n\t}\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":60043,"func":"skip_for_lines(void *fi_void, evalarg_T *evalarg)\n{\n    forinfo_T\t*fi = (forinfo_T *)fi_void;\n    int\t\ti;\n\n    for (i = 0; i < fi->fi_break_count; ++i)\n\teval_next_line(evalarg);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":183542,"func":"bool BrowserRootView::CanDrop(const ui::OSExchangeData& data) {\n  if (!tabstrip() || !tabstrip()->visible())\n    return false;\n\n  if (data.HasURL())\n    return true;\n\n  return GetPasteAndGoURL(data, NULL);\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":67718,"func":"dist_pl(PG_FUNCTION_ARGS)\n{\n\tPoint\t   *pt = PG_GETARG_POINT_P(0);\n\tLINE\t   *line = PG_GETARG_LINE_P(1);\n\n\tPG_RETURN_FLOAT8(dist_pl_internal(pt, line));\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":274211,"func":"static const char *nfs_readdir_copy_name(const char *name, unsigned int len)\n{\n\tconst char *ret = kmemdup_nul(name, len, GFP_KERNEL);\n\n\t\/*\n\t * Avoid a kmemleak false positive. The pointer to the name is stored\n\t * in a page cache page which kmemleak does not scan.\n\t *\/\n\tif (ret != NULL)\n\t\tkmemleak_not_leak(ret);\n\treturn ret;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":475489,"func":"\nstatic unsigned long gfn_to_hva_many(struct kvm_memory_slot *slot, gfn_t gfn,\n\t\t\t\t     gfn_t *nr_pages)\n{\n\treturn __gfn_to_hva_many(slot, gfn, nr_pages, true);","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":11113,"func":"AccessibilityOrientation AXNodeObject::orientation() const {\n   const AtomicString& ariaOrientation =\n       getAOMPropertyOrARIAAttribute(AOMStringProperty::kOrientation);\n   AccessibilityOrientation orientation = AccessibilityOrientationUndefined;\n  if (equalIgnoringCase(ariaOrientation, \"horizontal\"))\n     orientation = AccessibilityOrientationHorizontal;\n  else if (equalIgnoringCase(ariaOrientation, \"vertical\"))\n     orientation = AccessibilityOrientationVertical;\n \n   switch (roleValue()) {\n    case ComboBoxRole:\n    case ListBoxRole:\n    case MenuRole:\n    case ScrollBarRole:\n    case TreeRole:\n      if (orientation == AccessibilityOrientationUndefined)\n        orientation = AccessibilityOrientationVertical;\n\n      return orientation;\n    case MenuBarRole:\n    case SliderRole:\n    case SplitterRole:\n    case TabListRole:\n    case ToolbarRole:\n      if (orientation == AccessibilityOrientationUndefined)\n        orientation = AccessibilityOrientationHorizontal;\n\n      return orientation;\n    case RadioGroupRole:\n    case TreeGridRole:\n    case TableRole:\n      return orientation;\n    default:\n      return AXObject::orientation();\n  }\n}\n","target":1,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":374320,"func":"plperl_event_trigger_handler(PG_FUNCTION_ARGS)\n{\n\tplperl_proc_desc *prodesc;\n\tSV\t\t   *svTD;\n\tErrorContextCallback pl_error_context;\n\n\t\/* Connect to SPI manager *\/\n\tif (SPI_connect() != SPI_OK_CONNECT)\n\t\telog(ERROR, \"could not connect to SPI manager\");\n\n\t\/* Find or compile the function *\/\n\tprodesc = compile_plperl_function(fcinfo->flinfo->fn_oid, false, true);\n\tcurrent_call_data->prodesc = prodesc;\n\tincrement_prodesc_refcount(prodesc);\n\n\t\/* Set a callback for error reporting *\/\n\tpl_error_context.callback = plperl_exec_callback;\n\tpl_error_context.previous = error_context_stack;\n\tpl_error_context.arg = prodesc->proname;\n\terror_context_stack = &pl_error_context;\n\n\tactivate_interpreter(prodesc->interp);\n\n\tsvTD = plperl_event_trigger_build_args(fcinfo);\n\tplperl_call_perl_event_trigger_func(prodesc, fcinfo, svTD);\n\n\tif (SPI_finish() != SPI_OK_FINISH)\n\t\telog(ERROR, \"SPI_finish() failed\");\n\n\t\/* Restore the previous error callback *\/\n\terror_context_stack = pl_error_context.previous;\n\n\tSvREFCNT_dec(svTD);\n\n\treturn;\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":184364,"func":"void GraphicsContext::setPlatformShouldAntialias(bool enable)\n{\n    if (paintingDisabled())\n        return;\n\n    platformContext()->setUseAntialiasing(enable);\n}\n","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":34762,"func":"f_test_garbagecollect_now(typval_T *argvars UNUSED, typval_T *rettv UNUSED)\n{\n    \/\/ This is dangerous, any Lists and Dicts used internally may be freed\n    \/\/ while still in use.\n    if (!get_vim_var_nr(VV_TESTING))\n\temsg(_(e_calling_test_garbagecollect_now_while_v_testing_is_not_set));\n    else\n\tgarbage_collect(TRUE);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":84613,"func":"TEST_F(SslServerContextImplTicketTest, CRLSuccess) {\n  const std::string yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      crl:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.crl\"\n)EOF\";\n  EXPECT_NO_THROW(loadConfigYaml(yaml));\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":403377,"func":"mysql_refresh(MYSQL *mysql,uint options)\n{\n  uchar bits[1];\n  DBUG_ENTER(\"mysql_refresh\");\n  bits[0]= (uchar) options;\n  DBUG_RETURN(simple_command(mysql, COM_REFRESH, bits, 1, 0));\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":249018,"func":"Extension::SyncType Extension::GetSyncType() const {\n  if (!IsSyncable()) {\n    return SYNC_TYPE_NONE;\n  }\n\n  if (!ManifestURL::GetUpdateURL(this).is_empty() && !UpdatesFromGallery())\n    return SYNC_TYPE_NONE;\n\n  if (!plugins().empty()) {\n    return SYNC_TYPE_NONE;\n  }\n\n  switch (GetType()) {\n    case Manifest::TYPE_EXTENSION:\n      return SYNC_TYPE_EXTENSION;\n\n    case Manifest::TYPE_USER_SCRIPT:\n      if (UpdatesFromGallery())\n        return SYNC_TYPE_EXTENSION;\n      else\n        return SYNC_TYPE_NONE;\n\n    case Manifest::TYPE_HOSTED_APP:\n    case Manifest::TYPE_LEGACY_PACKAGED_APP:\n    case Manifest::TYPE_PLATFORM_APP:\n        return SYNC_TYPE_APP;\n\n    default:\n      return SYNC_TYPE_NONE;\n  }\n}\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":36348,"func":"wkbConvCurvePolygonToShape(wkbObj *w, shapeObj *shape)\n{\n  int type, i, ncomponents;\n  int failures = 0;\n  int was_poly = ( shape->type == MS_SHAPE_POLYGON );\n\n  \/*endian = *\/wkbReadChar(w);\n  type = wkbTypeMap(w,wkbReadInt(w));\n  ncomponents = wkbReadInt(w);\n\n  if( type != WKB_CURVEPOLYGON ) return MS_FAILURE;\n\n  \/* Lower the allowed dimensionality so we can\n  *  catch the linear ring components *\/\n  shape->type = MS_SHAPE_LINE;\n\n  for ( i = 0; i < ncomponents; i++ ) {\n    if ( wkbConvGeometryToShape(w, shape) == MS_FAILURE ) {\n      wkbSkipGeometry(w);\n      failures++;\n    }\n  }\n\n  \/* Go back to expected dimensionality *\/\n  if ( was_poly) shape->type = MS_SHAPE_POLYGON;\n\n  if ( failures == ncomponents )\n    return MS_FAILURE;\n  else\n    return MS_SUCCESS;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":441760,"func":"static inline unsigned php_unicode_tolower_full(\n\t\tunsigned code, enum mbfl_no_encoding enc, unsigned *out) {\n\tcode = php_unicode_tolower_raw(code, enc);\n\tif (UNEXPECTED(code > 0xffffff)) {\n\t\tunsigned len = code >> 24;\n\t\tconst unsigned *p = &_uccase_extra_table[code & 0xffffff];\n\t\tmemcpy(out, p + 1, len * sizeof(unsigned));\n\t\treturn len;\n\t}\n\t*out = code;\n\treturn 1;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":134503,"func":"usm_get_userList(void)\n{\n    return userList;\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":218354,"func":"bool FeatureInfo::IsWebGL1OrES2Context() const {\n  return IsWebGL1OrES2ContextType(context_type_);\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":209331,"func":"  virtual void AddObserver(Observer* observer) {\n  virtual void AddObserver(InputMethodLibrary::Observer* observer) {\n     if (!observers_.size()) {\n       observer->FirstObserverIsAdded(this);\n     }\n     observers_.AddObserver(observer);\n   }\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":291121,"func":"void trace_buffered_event_enable(void)\n{\n\tstruct ring_buffer_event *event;\n\tstruct page *page;\n\tint cpu;\n\n\tWARN_ON_ONCE(!mutex_is_locked(&event_mutex));\n\n\tif (trace_buffered_event_ref++)\n\t\treturn;\n\n\tfor_each_tracing_cpu(cpu) {\n\t\tpage = alloc_pages_node(cpu_to_node(cpu),\n\t\t\t\t\tGFP_KERNEL | __GFP_NORETRY, 0);\n\t\tif (!page)\n\t\t\tgoto failed;\n\n\t\tevent = page_address(page);\n\t\tmemset(event, 0, sizeof(*event));\n\n\t\tper_cpu(trace_buffered_event, cpu) = event;\n\n\t\tpreempt_disable();\n\t\tif (cpu == smp_processor_id() &&\n\t\t    this_cpu_read(trace_buffered_event) !=\n\t\t    per_cpu(trace_buffered_event, cpu))\n\t\t\tWARN_ON_ONCE(1);\n\t\tpreempt_enable();\n\t}\n\n\treturn;\n failed:\n\ttrace_buffered_event_disable();\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":171740,"func":"Eina_Bool ewk_view_user_scalable_get(const Evas_Object* ewkView)\n{\n    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);\n    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);\n\n    return priv->settings.zoomRange.userScalable;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":311665,"func":"void webkit_web_view_unmark_text_matches(WebKitWebView* webView)\n{\n    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));\n\n    return core(webView)->unmarkAllTextMatches();\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":185903,"func":"void GDataDirectoryService::RemoveEntryFromResourceMap(GDataEntry* entry) {\n  resource_map_.erase(entry->resource_id());\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":36761,"func":"  ActiveStreamEncoderFilter(FilterManager& parent, StreamEncoderFilterSharedPtr filter,\n                            FilterMatchStateSharedPtr match_state, bool dual_filter)\n      : ActiveStreamFilterBase(parent, dual_filter, std::move(match_state)), handle_(filter) {}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":176174,"func":"static inline int put_dwords(EHCIState *ehci, uint32_t addr,\n                             uint32_t *buf, int num)\n{\n    int i;\n\n    if (!ehci->as) {\n        ehci_raise_irq(ehci, USBSTS_HSE);\n        ehci->usbcmd &= ~USBCMD_RUNSTOP;\n        trace_usb_ehci_dma_error();\n        return -1;\n    }\n\n    for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {\n        uint32_t tmp = cpu_to_le32(*buf);\n        dma_memory_write(ehci->as, addr, &tmp, sizeof(tmp));\n    }\n\n    return num;\n}\n","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":367086,"func":"static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)\n{\n\tstruct rlimit *old_rlim = current->signal->rlim + resource;\n\n\t\/* Control the ability to change the hard limit (whether\n\t   lowering or raising it), so that the hard limit can\n\t   later be used as a safe reset point for the soft limit\n\t   upon context transitions.  See selinux_bprm_committing_creds. *\/\n\tif (old_rlim->rlim_max != new_rlim->rlim_max)\n\t\treturn current_has_perm(current, PROCESS__SETRLIMIT);\n\n\treturn 0;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":50416,"func":"TypedValue HHVM_FUNCTION(array_merge_recursive,\n                         int64_t numArgs,\n                         const Variant& array1,\n                         const Variant& array2 \/* = null_variant *\/,\n                         const Array& args \/* = null array *\/) {\n  getCheckedArray(array1);\n  auto in1 = array1.asCArrRef();\n  auto ret = Array::attach(MixedArray::MakeReserveLike(in1.get(), 0));\n  PointerSet seen;\n  php_array_merge_recursive(seen, false, ret, arr_array1);\n  assert(seen.empty());\n\n  if (UNLIKELY(numArgs < 2)) return tvReturn(std::move(ret));\n\n  getCheckedArray(array2);\n  php_array_merge_recursive(seen, false, ret, arr_array2);\n  assert(seen.empty());\n\n  for (ArrayIter iter(args); iter; ++iter) {\n    Variant v = iter.second();\n    if (!v.isArray()) {\n      throw_expected_array_exception(\"array_merge_recursive\");\n      return make_tv<KindOfNull>();\n    }\n    const Array& arr_v = v.asCArrRef();\n    php_array_merge_recursive(seen, false, ret, arr_v);\n    assert(seen.empty());\n  }\n  return tvReturn(std::move(ret));\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":432266,"func":"static void __vhost_vq_meta_reset(struct vhost_virtqueue *vq)\n{\n\tint j;\n\n\tfor (j = 0; j < VHOST_NUM_ADDRS; j++)\n\t\tvq->meta_iotlb[j] = NULL;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":454963,"func":"TEST_F(QueryPlannerTest, BasicSkipNoIndex) {\n    addIndex(BSON(\"a\" << 1));\n\n    runQuerySkipNToReturn(BSON(\"x\" << 5), 3, 0);\n\n    ASSERT_EQUALS(getNumSolutions(), 1U);\n    assertSolutionExists(\"{skip: {n: 3, node: {cscan: {dir: 1, filter: {x: 5}}}}}\");\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":282155,"func":"WebInsecureRequestPolicy FrameLoader::getInsecureRequestPolicy() const\n{\n    Frame* parentFrame = m_frame->tree().parent();\n    if (!parentFrame)\n        return kLeaveInsecureRequestsAlone;\n\n    return parentFrame->securityContext()->getInsecureRequestPolicy();\n}\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":443412,"func":"gen_dns_msg(struct regional* region, struct query_info* q, size_t num)\n{\n\tstruct dns_msg* msg = (struct dns_msg*)regional_alloc(region, \n\t\tsizeof(struct dns_msg));\n\tif(!msg)\n\t\treturn NULL;\n\tmemcpy(&msg->qinfo, q, sizeof(struct query_info));\n\tmsg->qinfo.qname = regional_alloc_init(region, q->qname, q->qname_len);\n\tif(!msg->qinfo.qname)\n\t\treturn NULL;\n\t\/* allocate replyinfo struct and rrset key array separately *\/\n\tmsg->rep = (struct reply_info*)regional_alloc(region,\n\t\tsizeof(struct reply_info) - sizeof(struct rrset_ref));\n\tif(!msg->rep)\n\t\treturn NULL;\n\tif(num > RR_COUNT_MAX)\n\t\treturn NULL; \/* integer overflow protection *\/\n\tmsg->rep->rrsets = (struct ub_packed_rrset_key**)\n\t\tregional_alloc(region,\n\t\tnum * sizeof(struct ub_packed_rrset_key*));\n\tif(!msg->rep->rrsets)\n\t\treturn NULL;\n\treturn msg;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":321669,"func":"static void scsi_remove_request(SCSIDiskReq *r)\n\n{\n\n    qemu_free(r->iov.iov_base);\n\n    scsi_req_free(&r->req);\n\n}\n","target":1,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":285122,"func":"static int CMSError(int ecode, const char *msg)\n{\n    error(-1,const_cast<char *>(msg));\n    return 1;\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":465192,"func":"static inline bool kvm_vcpu_mapped(struct kvm_host_map *map)\n{\n\treturn !!map->hva;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":413199,"func":"static bool ldb_kv_index_unique(struct ldb_context *ldb,\n\t\t\t\tstruct ldb_kv_private *ldb_kv,\n\t\t\t\tconst char *attr)\n{\n\tconst struct ldb_schema_attribute *a;\n\tif (ldb_kv->cache->GUID_index_attribute != NULL) {\n\t\tif (ldb_attr_cmp(attr, ldb_kv->cache->GUID_index_attribute) ==\n\t\t    0) {\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (ldb_attr_dn(attr) == 0) {\n\t\treturn true;\n\t}\n\n\ta = ldb_schema_attribute_by_name(ldb, attr);\n\tif (a->flags & LDB_ATTR_FLAG_UNIQUE_INDEX) {\n\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":159869,"func":"guint32\nmono_declsec_flags_from_method (MonoMethod *method)\n{\n\tif (method->flags & METHOD_ATTRIBUTE_HAS_SECURITY) {\n\t\t\/* FIXME: No cache (for the moment) *\/\n\t\tguint32 idx = mono_method_get_index (method);\n\t\tidx <<= MONO_HAS_DECL_SECURITY_BITS;\n\t\tidx |= MONO_HAS_DECL_SECURITY_METHODDEF;\n\t\treturn mono_declsec_get_flags (method->klass->image, idx);\n\t}\n\treturn 0;","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":247906,"func":"xmlXPathNodeLeading (xmlNodeSetPtr nodes, xmlNodePtr node) {\n    xmlXPathNodeSetSort(nodes);\n    return(xmlXPathNodeLeadingSorted(nodes, node));\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":238436,"func":"void InputHandler::setInputModeEnabled(bool active)\n{\n    FocusLog(LogLevelInfo, \"InputHandler::setInputModeEnabled '%s', override is '%s'\"\n             , active ? \"true\" : \"false\"\n             , m_webPage->m_dumpRenderTree || Platform::Settings::instance()->alwaysShowKeyboardOnFocus() ? \"true\" : \"false\");\n\n    m_inputModeEnabled = active;\n\n    if (isInputModeEnabled() && isActiveTextEdit() && !m_currentFocusElement->document()->frame()->selection()->isFocused())\n        m_currentFocusElement->document()->frame()->selection()->setFocused(true);\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":478183,"func":"    CImg(const unsigned int size_x,\n         std::initializer_list<t> values,\n         const bool repeat_values=true):_width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) {\n      assign(size_x);\n      _cimg_constructor_cpp11(repeat_values);\n    }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":8101,"func":"decode_bytes_with_escapes(struct compiling *c, const node *n, const char *s,\n                          size_t len)\n{\n    return PyBytes_DecodeEscape(s, len, NULL, 0, NULL);\n}","target":1,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":400801,"func":"pdf14_compute_group_device_int_rect(const gs_matrix *ctm,\n                                    const gs_rect *pbbox, gs_int_rect *rect)\n{\n    gs_rect dev_bbox;\n    int code;\n\n    code = gs_bbox_transform(pbbox, ctm, &dev_bbox);\n    if (code < 0)\n        return code;\n    rect->p.x = (int)floor(dev_bbox.p.x);\n    rect->p.y = (int)floor(dev_bbox.p.y);\n    rect->q.x = (int)ceil(dev_bbox.q.x);\n    rect->q.y = (int)ceil(dev_bbox.q.y);\n    return 0;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":159614,"func":"  void encode(bufferlist& bl) const {\n    __u8 struct_v = 2;\n    ::encode(struct_v, bl);\n    ::encode(auid, bl);\n    ::encode(key, bl);\n    ::encode(caps, bl);\n  }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":470739,"func":"int svm_allocate_nested(struct vcpu_svm *svm)\n{\n\tstruct page *hsave_page;\n\n\tif (svm->nested.initialized)\n\t\treturn 0;\n\n\thsave_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);\n\tif (!hsave_page)\n\t\treturn -ENOMEM;\n\tsvm->nested.hsave = page_address(hsave_page);\n\n\tsvm->nested.msrpm = svm_vcpu_alloc_msrpm();\n\tif (!svm->nested.msrpm)\n\t\tgoto err_free_hsave;\n\tsvm_vcpu_init_msrpm(&svm->vcpu, svm->nested.msrpm);\n\n\tsvm->nested.initialized = true;\n\treturn 0;\n\nerr_free_hsave:\n\t__free_page(hsave_page);\n\treturn -ENOMEM;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":287624,"func":"validate_event(struct pmu_hw_events *hw_events,\n\t       struct perf_event *event)\n{\n\tstruct arm_pmu *armpmu = to_arm_pmu(event->pmu);\n\tstruct hw_perf_event fake_event = event->hw;\n\tstruct pmu *leader_pmu = event->group_leader->pmu;\n\n\tif (is_software_event(event))\n\t\treturn 1;\n\n\tif (event->pmu != leader_pmu || event->state < PERF_EVENT_STATE_OFF)\n\t\treturn 1;\n\n\tif (event->state == PERF_EVENT_STATE_OFF && !event->attr.enable_on_exec)\n\t\treturn 1;\n\n\treturn armpmu->get_event_idx(hw_events, &fake_event) >= 0;\n}","target":1,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":448036,"func":"int ssh_buffer_add_ssh_string(struct ssh_buffer_struct *buffer,\n    struct ssh_string_struct *string) {\n  uint32_t len = 0;\n\n  if (string == NULL) {\n      return -1;\n  }\n\n  len = ssh_string_len(string);\n  if (ssh_buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) {\n    return -1;\n  }\n\n  return 0;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":237451,"func":"static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)\n{\n    WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn);\n    g_value_set_enum(returnAccu, navigationResponse);\n\n    if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT)\n        return FALSE;\n\n    return TRUE;\n}\n","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":111413,"func":"int __export rad_packet_add_int(struct rad_packet_t *pack, const char *vendor_name, const char *name, int val)\n{\n\tstruct rad_attr_t *ra;\n\tstruct rad_dict_attr_t *attr;\n\tstruct rad_dict_vendor_t *vendor;\n\n\tif (pack->len + (vendor_name ? 8 : 2) + 4 >= REQ_LENGTH_MAX)\n\t\treturn -1;\n\n\tif (vendor_name) {\n\t\tvendor = rad_dict_find_vendor_name(vendor_name);\n\t\tif (!vendor)\n\t\t\treturn -1;\n\t\tattr = rad_dict_find_vendor_attr(vendor, name);\n\t} else {\n\t\tvendor = NULL;\n\t\tattr = rad_dict_find_attr(name);\n\t}\n\n\tif (!attr)\n\t\treturn -1;\n\n\tra = mempool_alloc(attr_pool);\n\tif (!ra)\n\t\treturn -1;\n\n\tmemset(ra, 0, sizeof(*ra));\n\tra->vendor = vendor;\n\tra->attr = attr;\n\tra->len = 4;\n\tra->val.integer = val;\n\tra->raw = &ra->val;\n\tlist_add_tail(&ra->entry, &pack->attrs);\n\tpack->len += (vendor_name ? 8 : 2) + 4;\n\n\treturn 0;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":345631,"func":"Utf8DecoderBase::Utf8DecoderBase()\n  : unbuffered_start_(NULL),\n    utf16_length_(0),\n    last_byte_of_buffer_unused_(false) {}","target":1,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":176630,"func":" ShellWindowFrameView::~ShellWindowFrameView() {\n }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":126836,"func":"smtp_getnameinfo_cb(void *arg, int gaierrno, const char *host, const char *serv)\n{\n\tstruct smtp_session *s = arg;\n\tstruct addrinfo hints;\n\n\tif (gaierrno) {\n\t\t(void)strlcpy(s->rdns, \"<unknown>\", sizeof(s->rdns));\n\n\t\tif (gaierrno == EAI_NODATA || gaierrno == EAI_NONAME)\n\t\t\ts->fcrdns = 0;\n\t\telse {\n\t\t\tlog_warnx(\"getnameinfo: %s: %s\", ss_to_text(&s->ss),\n\t\t\t    gai_strerror(gaierrno));\n\t\t\ts->fcrdns = -1;\n\t\t}\n\n\t\tsmtp_lookup_servername(s);\n\t\treturn;\n\t}\n\n\t(void)strlcpy(s->rdns, host, sizeof(s->rdns));\n\n\tmemset(&hints, 0, sizeof(hints));\n\thints.ai_family = s->ss.ss_family;\n\thints.ai_socktype = SOCK_STREAM;\n\tresolver_getaddrinfo(s->rdns, NULL, &hints, smtp_getaddrinfo_cb, s);\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":57276,"func":"static void module_enable_ro(const struct module *mod, bool after_init)\n{\n\tif (!rodata_enabled)\n\t\treturn;\n\n\tset_vm_flush_reset_perms(mod->core_layout.base);\n\tset_vm_flush_reset_perms(mod->init_layout.base);\n\tfrob_text(&mod->core_layout, set_memory_ro);\n\n\tfrob_rodata(&mod->core_layout, set_memory_ro);\n\tfrob_text(&mod->init_layout, set_memory_ro);\n\tfrob_rodata(&mod->init_layout, set_memory_ro);\n\n\tif (after_init)\n\t\tfrob_ro_after_init(&mod->core_layout, set_memory_ro);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":15671,"func":"static int dissect_h225_UnregistrationReject ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h225_UnregistrationReject , UnregistrationReject_sequence ) ;\n return offset ;\n }","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":295744,"func":"static void bond_mc_del(struct bonding *bond, void *addr)\n{\n\tif (USES_PRIMARY(bond->params.mode)) {\n\t\t\/* write lock already acquired *\/\n\t\tif (bond->curr_active_slave)\n\t\t\tdev_mc_del(bond->curr_active_slave->dev, addr);\n\t} else {\n\t\tstruct slave *slave;\n\t\tint i;\n\t\tbond_for_each_slave(bond, slave, i) {\n\t\t\tdev_mc_del(slave->dev, addr);\n\t\t}\n\t}\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":67167,"func":"int prism2_wds_del(local_info_t *local, u8 *remote_addr,\n\t\t   int rtnl_locked, int do_not_remove)\n{\n\tunsigned long flags;\n\tstruct list_head *ptr;\n\tstruct hostap_interface *iface, *selected = NULL;\n\n\twrite_lock_irqsave(&local->iface_lock, flags);\n\tlist_for_each(ptr, &local->hostap_interfaces) {\n\t\tiface = list_entry(ptr, struct hostap_interface, list);\n\t\tif (iface->type != HOSTAP_INTERFACE_WDS)\n\t\t\tcontinue;\n\n\t\tif (memcmp(iface->u.wds.remote_addr, remote_addr,\n\t\t\t   ETH_ALEN) == 0) {\n\t\t\tselected = iface;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (selected && !do_not_remove)\n\t\tlist_del(&selected->list);\n\twrite_unlock_irqrestore(&local->iface_lock, flags);\n\n\tif (selected) {\n\t\tif (do_not_remove)\n\t\t\tmemset(selected->u.wds.remote_addr, 0, ETH_ALEN);\n\t\telse {\n\t\t\thostap_remove_interface(selected->dev, rtnl_locked, 0);\n\t\t\tlocal->wds_connections--;\n\t\t}\n\t}\n\n\treturn selected ? 0 : -ENODEV;\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":211354,"func":"ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,\n\t\t struct pin_cookie cookie)\n{\n\tint en_flags = ENQUEUE_WAKEUP;\n\n\tlockdep_assert_held(&rq->lock);\n\n#ifdef CONFIG_SMP\n\tif (p->sched_contributes_to_load)\n\t\trq->nr_uninterruptible--;\n\n\tif (wake_flags & WF_MIGRATED)\n\t\ten_flags |= ENQUEUE_MIGRATED;\n#endif\n\n\tttwu_activate(rq, p, en_flags);\n\tttwu_do_wakeup(rq, p, wake_flags, cookie);\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":518544,"func":"  bool memcpy_field_possible(const Field *from) const\n  {\n    return Field_str::memcpy_field_possible(from) &&\n           !compression_method() == !from->compression_method() &&\n           !table->copy_blobs;\n  }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":206521,"func":"bool TemplateURLRef::EncodeFormData(const PostParams& post_params,\n                                    PostContent* post_content) const {\n  if (post_params.empty())\n    return true;\n  if (!post_content)\n    return false;\n\n  const char kUploadDataMIMEType[] = \"multipart\/form-data; boundary=\";\n  std::string boundary = net::GenerateMimeMultipartBoundary();\n  post_content->first = kUploadDataMIMEType;\n  post_content->first += boundary;\n  std::string* post_data = &post_content->second;\n  post_data->clear();\n  for (const auto& param : post_params) {\n    DCHECK(!param.name.empty());\n    net::AddMultipartValueForUpload(param.name, param.value, boundary,\n                                    param.content_type, post_data);\n  }\n  net::AddMultipartFinalDelimiterForUpload(boundary, post_data);\n  return true;\n}\n","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":172734,"func":"ofport_set_usage(struct ofproto *ofproto, ofp_port_t ofp_port,\n                 long long int last_used)\n{\n    struct ofport_usage *usage;\n    HMAP_FOR_EACH_IN_BUCKET (usage, hmap_node, hash_ofp_port(ofp_port),\n                             &ofproto->ofport_usage) {\n        if (usage->ofp_port == ofp_port) {\n            usage->last_used = last_used;\n            return;\n        }\n    }\n    ovs_assert(last_used == LLONG_MAX);\n\n    usage = xmalloc(sizeof *usage);\n    usage->ofp_port = ofp_port;\n    usage->last_used = last_used;\n    hmap_insert(&ofproto->ofport_usage, &usage->hmap_node,\n                hash_ofp_port(ofp_port));\n}\n","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":415448,"func":"uint WavInFile::getBytesPerSample() const\r\n{\r\n    return getNumChannels() * getNumBits() \/ 8;\r\n}\r","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":490914,"func":"void io_flush(int flush_type)\n{\n\tif (iobuf.out.len > iobuf.out_empty_len) {\n\t\tif (flush_type == FULL_FLUSH)\t\t\/* flush everything in the output buffers *\/\n\t\t\tperform_io(iobuf.out.size - iobuf.out_empty_len, PIO_NEED_OUTROOM);\n\t\telse if (flush_type == NORMAL_FLUSH)\t\/* flush at least 1 byte *\/\n\t\t\tperform_io(iobuf.out.size - iobuf.out.len + 1, PIO_NEED_OUTROOM);\n\t\t\t\t\t\t\t\/* MSG_FLUSH: flush iobuf.msg only *\/\n\t}\n\tif (iobuf.msg.len)\n\t\tperform_io(iobuf.msg.size, PIO_NEED_MSGROOM);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":86013,"func":"void kvm_ioapic_clear_all(struct kvm_ioapic *ioapic, int irq_source_id)\n{\n\tint i;\n\n\tspin_lock(&ioapic->lock);\n\tfor (i = 0; i < KVM_IOAPIC_NUM_PINS; i++)\n\t\t__clear_bit(irq_source_id, &ioapic->irq_states[i]);\n\tspin_unlock(&ioapic->lock);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":252063,"func":"bool venc_dev::venc_loaded_stop()\n{\n return true;\n}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":282064,"func":"  int GetTabPixel(int x, int y) const {\n    const int* tab_pixels = reinterpret_cast<int*>(tab_bitmap_.getPixels());\n    if (!tab_pixels || x >= tab_bitmap_.width() || y >= tab_bitmap_.height())\n      return 0xFFFFFFFF;\n\n    return 0xFF000000 | tab_pixels[y * tab_bitmap_.width() + x];\n  }\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":500298,"func":"QPDFAcroFormDocumentHelper::QPDFAcroFormDocumentHelper(QPDF& qpdf) :\n    QPDFDocumentHelper(qpdf),\n    m(new Members())\n{\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":274001,"func":"static struct page *try_to_merge_two_pages(struct rmap_item *rmap_item,\n\t\t\t\t\t   struct page *page,\n\t\t\t\t\t   struct rmap_item *tree_rmap_item,\n\t\t\t\t\t   struct page *tree_page)\n{\n\tint err;\n\n\terr = try_to_merge_with_ksm_page(rmap_item, page, NULL);\n\tif (!err) {\n\t\terr = try_to_merge_with_ksm_page(tree_rmap_item,\n\t\t\t\t\t\t\ttree_page, page);\n\t\t\/*\n\t\t * If that fails, we have a ksm page with only one pte\n\t\t * pointing to it: so break it.\n\t\t *\/\n\t\tif (err)\n\t\t\tbreak_cow(rmap_item);\n\t}\n\treturn err ? NULL : page;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":385244,"func":"char *re_eprint(int err)\n{\n  static char epbuf[100];\n  size_t len= my_regerror(REG_ITOA|err, (my_regex_t *)NULL,\n\t\t\t  epbuf, sizeof(epbuf));\n  assert(len <= sizeof(epbuf));\n  return(epbuf);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":247229,"func":"static void variadicNodeMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    if (UNLIKELY(info.Length() < 1)) {\n        throwTypeError(ExceptionMessages::failedToExecute(\"variadicNodeMethod\", \"TestObject\", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());\n        return;\n    }\n    TestObject* imp = V8TestObject::toNative(info.Holder());\n    V8TRYCATCH_VOID(Node*, head, V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]));\n    Vector<RefPtr<Node> > tail;\n    for (int i = 1; i < info.Length(); ++i) {\n        if (!V8Node::hasInstance(info[i], info.GetIsolate())) {\n            throwTypeError(ExceptionMessages::failedToExecute(\"variadicNodeMethod\", \"TestObject\", \"parameter 2 is not of type 'Node'.\"), info.GetIsolate());\n            return;\n        }\n        tail.append(V8Node::toNative(v8::Handle<v8::Object>::Cast(info[i])));\n    }\n    imp->variadicNodeMethod(head, tail);\n}\n","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":282953,"func":"bool GDataFile::FromProto(const GDataEntryProto& proto) {\n  DCHECK(!proto.file_info().is_directory());\n\n  if (!GDataEntry::FromProto(proto))\n    return false;\n\n  thumbnail_url_ = GURL(proto.file_specific_info().thumbnail_url());\n  alternate_url_ = GURL(proto.file_specific_info().alternate_url());\n  content_mime_type_ = proto.file_specific_info().content_mime_type();\n  file_md5_ = proto.file_specific_info().file_md5();\n  document_extension_ = proto.file_specific_info().document_extension();\n  is_hosted_document_ = proto.file_specific_info().is_hosted_document();\n\n  return true;\n}\n","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":94959,"func":"static void get_fs_root_rcu(struct fs_struct *fs, struct path *root)\n{\n\tunsigned seq;\n\n\tdo {\n\t\tseq = read_seqcount_begin(&fs->seq);\n\t\t*root = fs->root;\n\t} while (read_seqcount_retry(&fs->seq, seq));\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":434177,"func":"int vrend_renderer_execute(void *execute_args, uint32_t execute_size)\n{\n   struct virgl_renderer_hdr *hdr = execute_args;\n   if (hdr->stype_version != 0)\n      return -EINVAL;\n\n   switch (hdr->stype) {\n      case VIRGL_RENDERER_STRUCTURE_TYPE_SUPPORTED_STRUCTURES:\n         return vrend_renderer_supported_structures(execute_args, execute_size);\n      case VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY:\n         return vrend_renderer_export_query(execute_args, execute_size);\n      default:\n         return -EINVAL;\n   }\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":43921,"func":"void CLASS derror()\n{\n  if (!data_error) {\n    dcraw_message (DCRAW_WARNING, \"%s: \", ifname_display);\n    if (feof(ifp))\n      dcraw_message (DCRAW_WARNING,_(\"Unexpected end of file\\n\"));\n    else\n#ifdef HAVE_FSEEKO\n      dcraw_message (DCRAW_WARNING,_(\"Corrupt data near 0x%llx\\n\"),\n\t\t(INT64) ftello(ifp));\n#else\n      dcraw_message (DCRAW_WARNING,_(\"Corrupt data near 0x%lx\\n\"), ftell(ifp));\n#endif\n  }\n  data_error++;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":167625,"func":"SYSCALL_DEFINE2(sethostname, char __user *, name, int, len)\n{\n int errno;\n char tmp[__NEW_UTS_LEN];\n\n if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))\n return -EPERM;\n\n if (len < 0 || len > __NEW_UTS_LEN)\n return -EINVAL;\n\tdown_write(&uts_sem);\n\terrno = -EFAULT;\n if (!copy_from_user(tmp, name, len)) {\n struct new_utsname *u = utsname();\n\n\t\tmemcpy(u->nodename, tmp, len);\n\t\tmemset(u->nodename + len, 0, sizeof(u->nodename) - len);\n\t\terrno = 0;\n }\n\tuts_proc_notify(UTS_PROC_HOSTNAME);\n\tup_write(&uts_sem);\n return errno;\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":136344,"func":"short CLASS guess_byte_order(int words)\n{\n  uchar test[4][2];\n  int t = 2, msb;\n  double diff, sum[2] = {0, 0};\n\n  fread(test[0], 2, 2, ifp);\n  for (words -= 2; words--;)\n  {\n    fread(test[t], 2, 1, ifp);\n    for (msb = 0; msb < 2; msb++)\n    {\n      diff = (test[t ^ 2][msb] << 8 | test[t ^ 2][!msb]) - (test[t][msb] << 8 | test[t][!msb]);\n      sum[msb] += diff * diff;\n    }\n    t = (t + 1) & 3;\n  }\n  return sum[0] < sum[1] ? 0x4d4d : 0x4949;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":46071,"func":"TEST_P(DownstreamProtocolIntegrationTest, LargeRequestUrlAccepted) {\n  \/\/ Send one 95 kB URL with limit 96 kB headers.\n  testLargeRequestUrl(95, 96);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":199560,"func":"coolkey_logout(sc_card_t *card)\n{\n\t\/* when we add multi pin support here, how do we know which pin to logout? *\/\n\tcoolkey_private_data_t * priv = COOLKEY_DATA(card);\n\tu8 pin_ref = 0;\n\n\t(void) coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_LOGOUT, pin_ref, 0, NULL, 0, NULL, NULL,\n\t\tpriv->nonce, sizeof(priv->nonce));\n\t\/* even if logout failed on the card, flush the nonce and clear the nonce_valid and we are effectively\n\t * logged out... needing to login again to get a nonce back *\/\n\tmemset(priv->nonce, 0, sizeof(priv->nonce));\n\tpriv->nonce_valid = 0;\n\treturn SC_SUCCESS;\n}\n","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":481868,"func":"static void extract_umask(ProcessHandle sandbox) {\n\tint fd = process_rootfs_open(sandbox, RUN_UMASK_FILE);\n\tif (fd < 0) {\n\t\tfprintf(stderr, \"Error: cannot open umask file\\n\");\n\t\texit(1);\n\t}\n\n\tFILE *fp = fdopen(fd, \"r\");\n\tif (!fp)\n\t\terrExit(\"fdopen\");\n\n\tif (fscanf(fp, \"%3o\", &orig_umask) != 1) {\n\t\tfprintf(stderr, \"Error: cannot read umask\\n\");\n\t\texit(1);\n\t}\n\tfclose(fp);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":267704,"func":"struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval,\n\t\tint (*test)(struct inode *, void *), void *data)\n{\n\tstruct hlist_head *head = inode_hashtable + hash(sb, hashval);\n\tstruct inode *inode;\n\n\tspin_lock(&inode_hash_lock);\n\tinode = find_inode(sb, head, test, data);\n\tspin_unlock(&inode_hash_lock);\n\n\treturn inode;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":88303,"func":"static int vfat_hashi(const struct dentry *dentry, const struct inode *inode,\n\t\tstruct qstr *qstr)\n{\n\tstruct nls_table *t = MSDOS_SB(dentry->d_sb)->nls_io;\n\tconst unsigned char *name;\n\tunsigned int len;\n\tunsigned long hash;\n\n\tname = qstr->name;\n\tlen = vfat_striptail_len(qstr);\n\n\thash = init_name_hash();\n\twhile (len--)\n\t\thash = partial_name_hash(nls_tolower(t, *name++), hash);\n\tqstr->hash = end_name_hash(hash);\n\n\treturn 0;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":231187,"func":"spnego_gss_wrap(\n\t\tOM_uint32 *minor_status,\n\t\tgss_ctx_id_t context_handle,\n\t\tint conf_req_flag,\n\t\tgss_qop_t qop_req,\n\t\tgss_buffer_t input_message_buffer,\n\t\tint *conf_state,\n\t\tgss_buffer_t output_message_buffer)\n{\n\tOM_uint32 ret;\n\tret = gss_wrap(minor_status,\n\t\t    context_handle,\n\t\t    conf_req_flag,\n\t\t    qop_req,\n\t\t    input_message_buffer,\n\t\t    conf_state,\n\t\t    output_message_buffer);\n\n\treturn (ret);\n}\n","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":277771,"func":"void CairoOutputDev::clearSoftMask(GfxState * \/*state*\/) {\n  if (mask)\n    cairo_pattern_destroy(mask);\n  mask = NULL;\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":323612,"func":"OP(zerof64)\n\n{\n\n    set_opf64(PARAM1, 0);\n\n    FORCE_RET();\n\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":278158,"func":"SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC)\n{\n\tif (sapi_module.getenv) { \n\t\tchar *value, *tmp = sapi_module.getenv(name, name_len TSRMLS_CC);\n\t\tif (tmp) {\n\t\t\tvalue = estrdup(tmp);\n\t\t} else {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (sapi_module.input_filter) {\n\t\t\tsapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL TSRMLS_CC);\n\t\t}\n\t\treturn value;\n\t}\n\treturn NULL;\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":427276,"func":"remove_thumbnailer (GnomeDesktopThumbnailFactory *factory,\n                    const gchar                  *path)\n{\n  GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;\n  GList *l;\n  Thumbnailer *thumb;\n\n  g_mutex_lock (&priv->lock);\n\n  for (l = priv->thumbnailers; l; l = g_list_next (l))\n    {\n      thumb = (Thumbnailer *)l->data;\n\n      if (strcmp (thumb->path, path) == 0)\n        {\n          priv->thumbnailers = g_list_delete_link (priv->thumbnailers, l);\n          g_hash_table_foreach_remove (priv->mime_types_map,\n                                       (GHRFunc)remove_thumbnailer_from_mime_type_map,\n                                       (gpointer)path);\n          thumbnailer_unref (thumb);\n\n          break;\n        }\n    }\n\n  g_mutex_unlock (&priv->lock);\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":355527,"func":"pick_next(struct cfs_rq *cfs_rq, struct sched_entity *se)\n{\n\tif (!cfs_rq->next)\n\t\treturn se;\n\n\tif (wakeup_preempt_entity(cfs_rq->next, se) != 0)\n\t\treturn se;\n\n\treturn cfs_rq->next;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":142418,"func":"TIFFCvtNativeToIEEEDouble(TIFF* tif, u_int n, double* f)\n{\n\tdouble_t* fp = (double_t*) f;\n\n\twhile (n-- > 0) {\n\t\tNATIVE2IEEEDOUBLE(fp);\n\t\tfp++;\n\t}\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":310112,"func":"void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(\n    const GlobalRequestID& id) {\n  GetLoader(id)->MarkAsTransferring();\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":122376,"func":"void ByteCodeGenerator::EndStatement(ParseNode* node)\n{\n    m_writer.EndStatement(node);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":404617,"func":"ModuleExport void UnregisterSFWImage(void)\n{\n  (void) UnregisterMagickInfo(\"SFW\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":449813,"func":"static Token *set_text(struct Token *t, const char *text, size_t len)\n{\n    char *textp;\n\n    if (t->len > INLINE_TEXT)\n\tnasm_free(t->text.p.ptr);\n\n    nasm_zero(t->text);\n\n    t->len = len = tok_check_len(len);\n    textp = (len > INLINE_TEXT)\n\t? (t->text.p.ptr = nasm_malloc(len+1)) : t->text.a;\n    memcpy(textp, text, len);\n    textp[len] = '\\0';\n    return t;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":148046,"func":"xmlValidCtxtPtr xmlNewValidCtxt(void) {\n    xmlValidCtxtPtr ret;\n\n    if ((ret = xmlMalloc(sizeof (xmlValidCtxt))) == NULL) {\n\txmlVErrMemory(NULL, \"malloc failed\");\n\treturn (NULL);\n    }\n\n    (void) memset(ret, 0, sizeof (xmlValidCtxt));\n\n    return (ret);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":39426,"func":"    template<typename T>\n    CImgDisplay& display(const CImg<T>& img) {\n      return assign(img);","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":224592,"func":"void HttpProxyClientSocket::Disconnect() {\n  if (transport_.get())\n    transport_->socket()->Disconnect();\n\n  next_state_ = STATE_NONE;\n  user_callback_.Reset();\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":221225,"func":"  void CancelUnlockOperation() { cancel_unlock_ = true; }\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":138024,"func":"inline String& String::operator=(const StaticString& v) {\n  m_str = req::ptr<StringData>::attach(v.m_str.get());\n  return *this;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":84952,"func":"static int pcd_reset(struct pcd_unit *cd)\n{\n\tint i, k, flg;\n\tint expect[5] = { 1, 1, 1, 0x14, 0xeb };\n\n\tpi_connect(cd->pi);\n\twrite_reg(cd, 6, 0xa0 + 0x10 * cd->drive);\n\twrite_reg(cd, 7, 8);\n\n\tpcd_sleep(20 * HZ \/ 1000);\t\/* delay a bit *\/\n\n\tk = 0;\n\twhile ((k++ < PCD_RESET_TMO) && (status_reg(cd) & IDE_BUSY))\n\t\tpcd_sleep(HZ \/ 10);\n\n\tflg = 1;\n\tfor (i = 0; i < 5; i++)\n\t\tflg &= (read_reg(cd, i + 1) == expect[i]);\n\n\tif (verbose) {\n\t\tprintk(\"%s: Reset (%d) signature = \", cd->name, k);\n\t\tfor (i = 0; i < 5; i++)\n\t\t\tprintk(\"%3x\", read_reg(cd, i + 1));\n\t\tif (!flg)\n\t\t\tprintk(\" (incorrect)\");\n\t\tprintk(\"\\n\");\n\t}\n\n\tpi_disconnect(cd->pi);\n\treturn flg - 1;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":10364,"func":" const AXObject* AXObject::ariaHiddenRoot() const {\n   for (const AXObject* object = this; object; object = object->parentObject()) {\n    if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), \"true\"))\n       return object;\n   }\n \n  return 0;\n}\n","target":1,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":121123,"func":"void QSvgHandler::pushColorCopy()\n{\n    if (m_colorTagCount.count())\n        ++m_colorTagCount.top();\n    else\n        pushColor(Qt::black);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":252170,"func":"void RenderWidgetHostImpl::IncrementInFlightEventCount() {\n  ++in_flight_event_count_;\n  if (!is_hidden_)\n    StartHangMonitorTimeout(hung_renderer_delay_);\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":265676,"func":"win_setminwidth(void)\n{\n    int\t\troom;\n    int\t\tneeded;\n    int\t\tfirst = TRUE;\n\n    \/\/ loop until there is a 'winminheight' that is possible\n    while (p_wmw > 0)\n    {\n\troom = Columns;\n\tneeded = frame_minwidth(topframe, NULL);\n\tif (room >= needed)\n\t    break;\n\t--p_wmw;\n\tif (first)\n\t{\n\t    emsg(_(e_not_enough_room));\n\t    first = FALSE;\n\t}\n    }\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":483691,"func":"int driver_probe_device(struct device_driver *drv, struct device *dev)\n{\n\tint ret = 0;\n\n\tif (!device_is_registered(dev))\n\t\treturn -ENODEV;\n\n\tpr_debug(\"bus: '%s': %s: matched device %s with driver %s\\n\",\n\t\t drv->bus->name, __func__, dev_name(dev), drv->name);\n\n\tpm_runtime_get_suppliers(dev);\n\tif (dev->parent)\n\t\tpm_runtime_get_sync(dev->parent);\n\n\tpm_runtime_barrier(dev);\n\tif (initcall_debug)\n\t\tret = really_probe_debug(dev, drv);\n\telse\n\t\tret = really_probe(dev, drv);\n\tpm_request_idle(dev);\n\n\tif (dev->parent)\n\t\tpm_runtime_put(dev->parent);\n\n\tpm_runtime_put_suppliers(dev);\n\treturn ret;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":228040,"func":"AffineTransform& AffineTransform::multiply(const AffineTransform& other)\n{\n    if (other.isIdentityOrTranslation()) {\n        if (other.m_transform[4] || other.m_transform[5])\n            translate(other.m_transform[4], other.m_transform[5]);\n        return *this;\n    }\n\n    AffineTransform trans;\n    doMultiply(*this, other, &trans);\n    setMatrix(trans.m_transform);\n\n    return *this;\n}\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":258036,"func":"const char * keyring_get_resource_name ( KEYRING_HANDLE hd ) {\n if ( ! hd || ! hd -> resource ) return NULL ;\n return hd -> resource -> fname ;\n }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":224503,"func":"static void activityLoggedInIsolatedWorldMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)\n{\n    TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMMethod\");\n    V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->GetCurrentContext());\n    if (contextData && contextData->activityLogger()) {\n        Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle<v8::Value> >(info, 0);\n        contextData->activityLogger()->log(\"TestObject.activityLoggedInIsolatedWorldMethod\", info.Length(), loggerArgs.data(), \"Method\");\n    }\n    TestObjectV8Internal::activityLoggedInIsolatedWorldMethodMethod(info);\n    TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"V8Execution\");\n}\n","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":484741,"func":"static int read_tlv_buf(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id,\n\t\t\tunsigned int __user *buf, unsigned int size)\n{\n\tstruct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)];\n\tunsigned int len;\n\n\tif (!(vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ))\n\t\treturn -ENXIO;\n\n\tif (kctl->tlv.p == NULL)\n\t\treturn -ENXIO;\n\n\tlen = sizeof(unsigned int) * 2 + kctl->tlv.p[1];\n\tif (size < len)\n\t\treturn -ENOMEM;\n\n\tif (copy_to_user(buf, kctl->tlv.p, len))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":319791,"func":"static void monitor_data_destroy(Monitor *mon)\n\n{\n\n\n\n\n\n\n\n\n    QDECREF(mon->outbuf);\n\n    qemu_mutex_destroy(&mon->out_lock);\n","target":1,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":288325,"func":"int32_t PepperFlashRendererHost::OnNavigate(\n    ppapi::host::HostMessageContext* host_context,\n    const ppapi::URLRequestInfoData& data,\n    const std::string& target,\n    bool from_user_action) {\n  content::PepperPluginInstance* plugin_instance =\n      host_->GetPluginInstance(pp_instance());\n   if (!plugin_instance)\n     return PP_ERROR_FAILED;\n \n  ppapi::proxy::HostDispatcher* host_dispatcher =\n      ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());\n  host_dispatcher->set_allow_plugin_reentrancy();\n\n  base::WeakPtr<PepperFlashRendererHost> weak_ptr = weak_factory_.GetWeakPtr();\n  navigate_replies_.push_back(host_context->MakeReplyMessageContext());\n  plugin_instance->Navigate(data, target.c_str(), from_user_action);\n  if (weak_ptr.get()) {\n    SendReply(navigate_replies_.back(), IPC::Message());\n    navigate_replies_.pop_back();\n  }\n\n  return PP_OK_COMPLETIONPENDING;\n}\n","target":1,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":91535,"func":"extern \"C\" void slave_io_thread_detach_vio()\n{\n  THD *thd= current_thd;\n  if (thd && thd->slave_thread)\n    thd->clear_active_vio();\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":157001,"func":"static const char *dd_check(struct dump_dir *dd)\n{\n    dd->dd_time = parse_time_file_at(dd->dd_fd, FILENAME_TIME);\n    if (dd->dd_time < 0)\n    {\n        log_warning(\"Missing file: \"FILENAME_TIME);\n        return FILENAME_TIME;\n    }\n\n    dd->dd_type = load_text_file_at(dd->dd_fd, FILENAME_TYPE, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);\n    if (!dd->dd_type || (strlen(dd->dd_type) == 0))\n    {\n        log_warning(\"Missing or empty file: \"FILENAME_TYPE);\n        return FILENAME_TYPE;\n    }\n\n    return NULL;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":121463,"func":"void sc_mem_clear(void *ptr, size_t len)\n{\n\tif (len > 0)   {\n#ifdef ENABLE_OPENSSL\n\t\tOPENSSL_cleanse(ptr, len);\n#else\n\t\tmemset(ptr, 0, len);\n#endif\n\t}\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":194987,"func":"void RenderWidgetHostViewAndroid::SetCachedBackgroundColor(SkColor color) {\n  cached_background_color_ = color;\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":34974,"func":"void CModule::OnNick(const CNick& Nick, const CString& sNewNick,\n                     const vector<CChan*>& vChans) {}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":72521,"func":"load_binpersid(UnpicklerObject *self)\n{\n    PyObject *pid, *obj;\n\n    if (self->pers_func) {\n        PDATA_POP(self->stack, pid);\n        if (pid == NULL)\n            return -1;\n\n        obj = call_method(self->pers_func, self->pers_func_self, pid);\n        Py_DECREF(pid);\n        if (obj == NULL)\n            return -1;\n\n        PDATA_PUSH(self->stack, obj, -1);\n        return 0;\n    }\n    else {\n        PickleState *st = _Pickle_GetGlobalState();\n        PyErr_SetString(st->UnpicklingError,\n                        \"A load persistent id instruction was encountered,\\n\"\n                        \"but no persistent_load function was specified.\");\n        return -1;\n    }\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":331103,"func":"static void spapr_nvram_class_init(ObjectClass *klass, void *data)\n\n{\n\n    DeviceClass *dc = DEVICE_CLASS(klass);\n\n    VIOsPAPRDeviceClass *k = VIO_SPAPR_DEVICE_CLASS(klass);\n\n\n\n    k->realize = spapr_nvram_realize;\n\n    k->devnode = spapr_nvram_devnode;\n\n    k->dt_name = \"nvram\";\n\n    k->dt_type = \"nvram\";\n\n    k->dt_compatible = \"qemu,spapr-nvram\";\n\n    set_bit(DEVICE_CATEGORY_MISC, dc->categories);\n\n    dc->props = spapr_nvram_properties;\n\n    dc->vmsd = &vmstate_spapr_nvram;\n\n\n\n}","target":1,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":470910,"func":"void outflush(const gs_memory_t *mem)\n{\n    gs_lib_ctx_core_t *core = mem->gs_lib_ctx->core;\n    if (core->stdout_is_redirected) {\n        if (core->stdout_to_stderr) {\n            if (!core->stderr_fn)\n                fflush(core->fstderr);\n        }\n        else\n            gp_fflush(core->fstdout2);\n    }\n    else if (!core->stdout_fn)\n        fflush(core->fstdout);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":445262,"func":"LogRecordingSink::LogRecordingSink(Logger::DelegatingLogSinkSharedPtr log_sink)\n    : Logger::SinkDelegate(log_sink) {}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":54199,"func":"flatpak_dir_get_config_strv (FlatpakDir *self, char *key)\n{\n  GKeyFile *config = flatpak_dir_get_repo_config (self);\n  g_auto(GStrv) lang = NULL;\n\n  if (config)\n    {\n      if (g_key_file_has_key (config, \"core\", key, NULL))\n        {\n          lang = g_key_file_get_string_list (config, \"core\", key, NULL, NULL);\n          return g_steal_pointer (&lang);\n        }\n    }\n  return NULL;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":55241,"func":"static inline int apic_test_vector(int vec, void *bitmap)\n{\n\treturn test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":221904,"func":"void RenderBox::willBeDestroyed()\n{\n    clearOverrideSize();\n\n    if (style() && (style()->logicalHeight().isPercent() || style()->logicalMinHeight().isPercent() || style()->logicalMaxHeight().isPercent()))\n        RenderBlock::removePercentHeightDescendant(this);\n\n    ASSERT(!RenderBlock::hasPercentHeightDescendant(this));\n\n    RenderBoxModelObject::willBeDestroyed();\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":19421,"func":"int xmlHashRemoveEntry ( xmlHashTablePtr table , const xmlChar * name , xmlHashDeallocator f ) {\n return ( xmlHashRemoveEntry3 ( table , name , NULL , NULL , f ) ) ;\n }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":225289,"func":"unsigned HTMLInputElement::width() const\n{\n    return m_inputType->width();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":414133,"func":"work_address_populate (EContact *card,\n                       gchar **values)\n{\n\taddress_populate (card, values, E_CONTACT_ADDRESS_LABEL_WORK, E_CONTACT_ADDRESS_WORK);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":62139,"func":"static void default_print_str(WriterContext *wctx, const char *key, const char *value)\n{\n    DefaultContext *def = wctx->priv;\n\n    if (!def->nokey)\n        printf(\"%s%s=\", wctx->section_pbuf[wctx->level].str, key);\n    printf(\"%s\\n\", value);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":144328,"func":"    virtual void clean() { dirty = false; }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":200092,"func":" OMX_ERRORTYPE SoftMPEG4Encoder::releaseEncoder() {\n    if (mEncParams) {\n        delete mEncParams;\n        mEncParams = NULL;\n     }\n \n    if (mHandle) {\n        delete mHandle;\n        mHandle = NULL;\n    }\n \n     return OMX_ErrorNone;\n }\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":377873,"func":"static int audit_set_enabled(u32 state)\n{\n\tint rc;\n\tif (state < AUDIT_OFF || state > AUDIT_LOCKED)\n\t\treturn -EINVAL;\n\n\trc =  audit_do_config_change(\"audit_enabled\", &audit_enabled, state);\n\tif (!rc)\n\t\taudit_ever_enabled |= !!state;\n\n\treturn rc;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":365738,"func":"g_delete_wait_obj_from_socket(tbus wait_obj)\n{\n#ifdef _WIN32\n  if (wait_obj == 0)\n  {\n    return;\n  }\n  WSACloseEvent((HANDLE)wait_obj);\n#else\n#endif\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":229775,"func":"RenderFrameImpl::CreatePortal(mojo::ScopedInterfaceEndpointHandle pipe) {\n  int proxy_routing_id = MSG_ROUTING_NONE;\n  base::UnguessableToken portal_token;\n  GetFrameHost()->CreatePortal(\n      blink::mojom::PortalAssociatedRequest(std::move(pipe)), &proxy_routing_id,\n      &portal_token);\n  RenderFrameProxy* proxy =\n      RenderFrameProxy::CreateProxyForPortal(this, proxy_routing_id);\n  return std::make_pair(proxy->web_frame(), portal_token);\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":459419,"func":"static int uvc_resume(struct usb_interface *intf)\n{\n\treturn __uvc_resume(intf, 0);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":403691,"func":"static void xfrm_policy_fini(struct net *net)\n{\n\tunsigned int sz;\n\tint dir;\n\n\tflush_work(&net->xfrm.policy_hash_work);\n#ifdef CONFIG_XFRM_SUB_POLICY\n\txfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, false);\n#endif\n\txfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false);\n\n\tWARN_ON(!list_empty(&net->xfrm.policy_all));\n\n\tfor (dir = 0; dir < XFRM_POLICY_MAX; dir++) {\n\t\tstruct xfrm_policy_hash *htab;\n\n\t\tWARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir]));\n\n\t\thtab = &net->xfrm.policy_bydst[dir];\n\t\tsz = (htab->hmask + 1) * sizeof(struct hlist_head);\n\t\tWARN_ON(!hlist_empty(htab->table));\n\t\txfrm_hash_free(htab->table, sz);\n\t}\n\n\tsz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head);\n\tWARN_ON(!hlist_empty(net->xfrm.policy_byidx));\n\txfrm_hash_free(net->xfrm.policy_byidx, sz);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":120973,"func":"INST_HANDLER (add) {\t\/\/ ADD Rd, Rr\n\t\t\t\/\/ LSL Rd\n\tint d = ((buf[0] >> 4) & 0xf) | ((buf[1] & 1) << 4);\n\tint r = (buf[0] & 0xf) | ((buf[1] & 2) << 3);\n\tESIL_A (\"r%d,r%d,+,\", r, d);\t\t\t\/\/ Rd + Rr\n\t__generic_add_update_flags_rr(op, d, r);\t\/\/ FLAGS\n\tESIL_A (\"r%d,=,\", d);\t\t\t\t\/\/ Rd = result\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":326428,"func":"static int get_cluster_duration(MOVTrack *track, int cluster_idx)\n\n{\n\n    int64_t next_dts;\n\n\n\n    if (cluster_idx >= track->entry)\n\n        return 0;\n\n\n\n    if (cluster_idx + 1 == track->entry)\n\n        next_dts = track->track_duration + track->start_dts;\n\n    else\n\n        next_dts = track->cluster[cluster_idx + 1].dts;\n\n\n\n    return next_dts - track->cluster[cluster_idx].dts;\n\n}\n","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":271391,"func":"TEST_P(ConnectTerminationIntegrationTest, UpstreamClose) {\n  initialize();\n\n  setUpConnection();\n  sendBidirectionalData();\n\n  \/\/ Tear down by closing the upstream connection.\n  ASSERT_TRUE(fake_raw_upstream_connection_->close());\n  if (downstream_protocol_ == Http::CodecType::HTTP3) {\n    \/\/ In HTTP\/3 end stream will be sent when the upstream connection is closed, and\n    \/\/ STOP_SENDING frame sent instead of reset.\n    ASSERT_TRUE(response_->waitForEndStream());\n  } else {\n    ASSERT_TRUE(response_->waitForReset());\n  }\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":277382,"func":"SandboxPolicyFuchsia::~SandboxPolicyFuchsia() {\n  if (service_directory_) {\n    service_directory_task_runner_->DeleteSoon(FROM_HERE,\n                                               std::move(service_directory_));\n  }\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":328237,"func":"void qdev_prop_set_drive(DeviceState *dev, const char *name,\n\n                         BlockBackend *value, Error **errp)\n\n{\n\n    object_property_set_str(OBJECT(dev), value ? blk_name(value) : \"\",\n\n                            name, errp);\n\n}\n","target":1,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":394459,"func":"static void cli_connect_sock_done(struct tevent_req *subreq)\n{\n\tstruct tevent_req *req = tevent_req_callback_data(\n\t\tsubreq, struct tevent_req);\n\tstruct cli_connect_sock_state *state = tevent_req_data(\n\t\treq, struct cli_connect_sock_state);\n\tNTSTATUS status;\n\n\tstatus = smbsock_any_connect_recv(subreq, &state->fd, NULL,\n\t\t\t\t\t  &state->port);\n\tTALLOC_FREE(subreq);\n\tif (tevent_req_nterror(req, status)) {\n\t\treturn;\n\t}\n\tset_socket_options(state->fd, lp_socket_options());\n\ttevent_req_done(req);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":261410,"func":"static void l2cap_sock_destruct(struct sock *sk)\n{\n\tBT_DBG(\"sk %p\", sk);\n\n\tl2cap_chan_put(l2cap_pi(sk)->chan);\n\tif (l2cap_pi(sk)->rx_busy_skb) {\n\t\tkfree_skb(l2cap_pi(sk)->rx_busy_skb);\n\t\tl2cap_pi(sk)->rx_busy_skb = NULL;\n\t}\n\n\tskb_queue_purge(&sk->sk_receive_queue);\n\tskb_queue_purge(&sk->sk_write_queue);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":20095,"func":"IN_PROC_BROWSER_TEST_F ( PageLoadMetricsBrowserTest , PayloadSizeChildFrame ) {\n ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;\n auto waiter = CreatePageLoadMetricsWaiter ( ) ;\n waiter -> AddPageExpectation ( TimingField : : LOAD_EVENT ) ;\n ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( \"\/page_load_metrics\/large_iframe.html\" ) ) ;\n waiter -> Wait ( ) ;\n NavigateToUntrackedUrl ( ) ;\n histogram_tester_ . ExpectTotalCount ( internal : : kHistogramPageLoadTotalBytes , 1 ) ;\n histogram_tester_ . ExpectBucketCount ( internal : : kHistogramPageLoadTotalBytes , 10 , 1 ) ;\n }","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":357746,"func":"unsigned long sock_i_ino(struct sock *sk)\n{\n\tunsigned long ino;\n\n\tread_lock(&sk->sk_callback_lock);\n\tino = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_ino : 0;\n\tread_unlock(&sk->sk_callback_lock);\n\treturn ino;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":236277,"func":"void Browser::OpenBookmarkManagerWindow(Profile* profile) {\n  Browser* browser = Browser::Create(profile);\n  browser->ShowBookmarkManagerTab();\n  browser->window()->Show();\n}\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":285456,"func":"static js_Ast *funexp(js_State *J)\n{\n\tjs_Ast *a, *b, *c;\n\ta = identifieropt(J);\n\tjsP_expect(J, '(');\n\tb = parameters(J);\n\tjsP_expect(J, ')');\n\tc = funbody(J);\n\treturn EXP3(FUN, a, b, c);\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":230345,"func":"NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document)\n{\n    if (!document.frame() || !document.frame()->domWindow())\n        return nullptr;\n    Navigator& navigator = *document.frame()->domWindow()->navigator();\n    return &from(navigator);\n}\n","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":315506,"func":"void AudioOutputController::Close(Task* closed_task) {\n  DCHECK(closed_task);\n  DCHECK(message_loop_);\n  message_loop_->PostTask(\n      FROM_HERE,\n      NewRunnableMethod(this, &AudioOutputController::DoClose, closed_task));\n}\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":117264,"func":"static const char *req_log_id_field(request_rec *r)\n{\n    return r->log_id;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":257359,"func":"void _cmsAllocMPETypePluginChunk ( struct _cmsContext_struct * ctx , const struct _cmsContext_struct * src ) {\n if ( src != NULL ) {\n DupTagTypeList ( ctx , src , MPEPlugin ) ;\n }\n else {\n static _cmsTagTypePluginChunkType TagTypePluginChunk = {\n NULL }\n ;\n ctx -> chunks [ MPEPlugin ] = _cmsSubAllocDup ( ctx -> MemPool , & TagTypePluginChunk , sizeof ( _cmsTagTypePluginChunkType ) ) ;\n }\n }","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":304538,"func":"static struct mg_fd *packed_open(const char *path, int flags) {\n  size_t size = 0;\n  const char *data = mg_unpack(path, &size, NULL);\n  struct packed_file *fp = NULL;\n  struct mg_fd *fd = NULL;\n  if (data == NULL) return NULL;\n  if (flags & MG_FS_WRITE) return NULL;\n  fp = (struct packed_file *) calloc(1, sizeof(*fp));\n  fd = (struct mg_fd *) calloc(1, sizeof(*fd));\n  fp->size = size;\n  fp->data = data;\n  fd->fd = fp;\n  fd->fs = &mg_fs_packed;\n  return fd;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":39338,"func":"void MainWindow::openMultiple(const QList<QUrl>& urls)\n{\n    if (urls.size() > 1) {\n        m_multipleFiles = Util::sortedFileList(Util::expandDirectories(urls));\n        open(m_multipleFiles.first());\n    } else {\n        QUrl url = urls.first();\n        open(Util::removeFileScheme(url));\n    }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":130018,"func":"void nfs40_shutdown_client(struct nfs_client *clp)\n{\n\tif (clp->cl_slot_tbl) {\n\t\tnfs4_shutdown_slot_table(clp->cl_slot_tbl);\n\t\tkfree(clp->cl_slot_tbl);\n\t}\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":252888,"func":"void AutomationInternalCustomBindings::RouteTreeIDFunction(\n    const std::string& name,\n    TreeIDFunction callback) {\n  scoped_refptr<TreeIDWrapper> wrapper = new TreeIDWrapper(this, callback);\n  RouteFunction(name, base::Bind(&TreeIDWrapper::Run, wrapper));\n}\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":287496,"func":"static void perf_event_init_cpu(int cpu)\n{\n\tstruct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);\n\n\tmutex_lock(&swhash->hlist_mutex);\n\tswhash->online = true;\n\tif (swhash->hlist_refcount > 0) {\n\t\tstruct swevent_hlist *hlist;\n\n\t\thlist = kzalloc_node(sizeof(*hlist), GFP_KERNEL, cpu_to_node(cpu));\n\t\tWARN_ON(!hlist);\n\t\trcu_assign_pointer(swhash->swevent_hlist, hlist);\n\t}\n\tmutex_unlock(&swhash->hlist_mutex);\n}","target":1,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":239717,"func":"void RenderViewHostImpl::DisassociateFromPopupCount() {\n  Send(new ViewMsg_DisassociateFromPopupCount(GetRoutingID()));\n}\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":265163,"func":"  static Pipeline MakeExp(const int32* bias_data, int output_rows,\n                          int32 output_offset, int32 output_multiplier,\n                          int output_left_shift, int32 output_activation_min,\n                          int32 output_activation_max) {\n    ColVectorMap bias_vector(bias_data, output_rows);\n    gemmlowp::OutputStageBiasAddition<ColVectorMap> bias_addition_stage;\n    bias_addition_stage.bias_vector = bias_vector;\n    gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent quantize_down_stage;\n    quantize_down_stage.result_offset_after_shift = output_offset;\n    quantize_down_stage.result_fixedpoint_multiplier = output_multiplier;\n    quantize_down_stage.result_exponent = output_left_shift;\n    gemmlowp::OutputStageClamp clamp_stage;\n    clamp_stage.min = output_activation_min;\n    clamp_stage.max = output_activation_max;\n    gemmlowp::OutputStageSaturatingCastToUint8 saturating_cast_stage;\n    return std::make_tuple(bias_addition_stage, quantize_down_stage,\n                           clamp_stage, saturating_cast_stage);\n  }","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":73174,"func":"static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)\n{\n\tint len = name->len;\n\t__be32 *p;\n\n\tp = reserve_space(xdr, 8 + len);\n\t*p++ = cpu_to_be32(OP_LOOKUP);\n\txdr_encode_opaque(p, name->name, len);\n\thdr->nops++;\n\thdr->replen += decode_lookup_maxsz;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":419115,"func":"tty_free(struct tty *tty)\n{\n\ttty_close(tty);\n\n\tfree(tty->ccolour);\n\tfree(tty->term_name);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":117548,"func":"void gdImageGetClip (gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)\n{\n\t*x1P = im->cx1;\n\t*y1P = im->cy1;\n\t*x2P = im->cx2;\n\t*y2P = im->cy2;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":242722,"func":"xmlXPathRoot(xmlXPathParserContextPtr ctxt) {\n    if ((ctxt == NULL) || (ctxt->context == NULL))\n\treturn;\n    ctxt->context->node = (xmlNodePtr) ctxt->context->doc;\n    valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,\n\tctxt->context->node));\n}\n","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":254701,"func":"void PageHandler::PrintToPDF(Maybe<bool> landscape,\n                             Maybe<bool> display_header_footer,\n                             Maybe<bool> print_background,\n                             Maybe<double> scale,\n                             Maybe<double> paper_width,\n                             Maybe<double> paper_height,\n                             Maybe<double> margin_top,\n                             Maybe<double> margin_bottom,\n                             Maybe<double> margin_left,\n                             Maybe<double> margin_right,\n                             Maybe<String> page_ranges,\n                             Maybe<bool> ignore_invalid_page_ranges,\n                             Maybe<String> header_template,\n                             Maybe<String> footer_template,\n                             std::unique_ptr<PrintToPDFCallback> callback) {\n  callback->sendFailure(Response::Error(\"PrintToPDF is not implemented\"));\n  return;\n}\n","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":262928,"func":"static int build_mapping(struct sk_buff *skb, struct xfrm_state *x,\n\t\t\t xfrm_address_t *new_saddr, __be16 new_sport)\n{\n\tstruct xfrm_user_mapping *um;\n\tstruct nlmsghdr *nlh;\n\n\tnlh = nlmsg_put(skb, 0, 0, XFRM_MSG_MAPPING, sizeof(*um), 0);\n\tif (nlh == NULL)\n\t\treturn -EMSGSIZE;\n\n\tum = nlmsg_data(nlh);\n\n\tmemcpy(&um->id.daddr, &x->id.daddr, sizeof(um->id.daddr));\n\tum->id.spi = x->id.spi;\n\tum->id.family = x->props.family;\n\tum->id.proto = x->id.proto;\n\tmemcpy(&um->new_saddr, new_saddr, sizeof(um->new_saddr));\n\tmemcpy(&um->old_saddr, &x->props.saddr, sizeof(um->old_saddr));\n\tum->new_sport = new_sport;\n\tum->old_sport = x->encap->encap_sport;\n\tum->reqid = x->props.reqid;\n\n\tnlmsg_end(skb, nlh);\n\treturn 0;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":44683,"func":"struct file *filp_open(const char *filename, int flags, int mode)\n{\n\treturn do_filp_open(AT_FDCWD, filename, flags, mode, 0);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":45340,"func":"static int ti_vread_sync(struct usb_device *dev, __u8 request,\n\t\t\t\t__u16 value, __u16 index, u8 *data, int size)\n{\n\tint status;\n\n\tstatus = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,\n\t\t\t(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN),\n\t\t\tvalue, index, data, size, 1000);\n\tif (status < 0)\n\t\treturn status;\n\tif (status != size) {\n\t\tdev_dbg(&dev->dev, \"%s - wanted to write %d, but only wrote %d\\n\",\n\t\t\t__func__, size, status);\n\t\treturn -ECOMM;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":151282,"func":"    \/\/! Invert endianness of all pixel values \\newinstance.\n    CImg<T> get_invert_endianness() const {\n      return (+*this).invert_endianness();","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":406766,"func":"partition_element *ha_partition::find_partition_element(uint part_id)\n{\n  uint i;\n  uint curr_part_id= 0;\n  List_iterator_fast <partition_element> part_it(m_part_info->partitions);\n\n  for (i= 0; i < m_part_info->num_parts; i++)\n  {\n    partition_element *part_elem;\n    part_elem= part_it++;\n    if (m_is_sub_partitioned)\n    {\n      uint j;\n      List_iterator_fast <partition_element> sub_it(part_elem->subpartitions);\n      for (j= 0; j < m_part_info->num_subparts; j++)\n      {\n\tpart_elem= sub_it++;\n\tif (part_id == curr_part_id++)\n\t  return part_elem;\n      }\n    }\n    else if (part_id == curr_part_id++)\n      return part_elem;\n  }\n  DBUG_ASSERT(0);\n  my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));\n  return NULL;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":386637,"func":"static struct gfxinfo *php_handle_swf (php_stream * stream TSRMLS_DC)\n{\n\tstruct gfxinfo *result = NULL;\n\tlong bits;\n\tunsigned char a[32];\n\n\tif (php_stream_seek(stream, 5, SEEK_CUR))\n\t\treturn NULL;\n\n\tif (php_stream_read(stream, a, sizeof(a)) != sizeof(a))\n\t\treturn NULL;\n\n\tresult = (struct gfxinfo *) ecalloc (1, sizeof (struct gfxinfo));\n\tbits = php_swf_get_bits (a, 0, 5);\n\tresult->width = (php_swf_get_bits (a, 5 + bits, bits) -\n\t\tphp_swf_get_bits (a, 5, bits)) \/ 20;\n\tresult->height = (php_swf_get_bits (a, 5 + (3 * bits), bits) -\n\t\tphp_swf_get_bits (a, 5 + (2 * bits), bits)) \/ 20;\n\tresult->bits     = 0;\n\tresult->channels = 0;\n\treturn result;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":78412,"func":"void jspInit() {\n  jspSoftInit();\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":175744,"func":"static void* dvcman_get_rdp_settings(IDRDYNVC_ENTRY_POINTS* pEntryPoints)\n{\n\treturn (void*)((DVCMAN_ENTRY_POINTS*) pEntryPoints)->settings;\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":457626,"func":"static int io_sync_file_range(struct io_kiocb *req, bool force_nonblock)\n{\n\tint ret;\n\n\t\/* sync_file_range always requires a blocking context *\/\n\tif (force_nonblock)\n\t\treturn -EAGAIN;\n\n\tret = sync_file_range(req->file, req->sync.off, req->sync.len,\n\t\t\t\treq->sync.flags);\n\tif (ret < 0)\n\t\treq_set_fail_links(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":23418,"func":"static int dissect_h245_INTEGER_0_65535 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {\n offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 0U , 65535U , NULL , FALSE ) ;\n return offset ;\n }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":408839,"func":"static void fli_write_short(FILE *f, unsigned short w)\n{\n\tunsigned char b[2];\n\tb[0]=w&255;\n\tb[1]=(w>>8)&255;\n\tfwrite(&b,1,2,f);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":420851,"func":"deinit_sockets (void)\n{\n  WSACleanup();\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":238244,"func":"js_Function *jsC_compilefunction(js_State *J, js_Ast *prog)\n{\n\treturn newfun(J, prog->a, prog->b, prog->c, 0);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":194690,"func":"bool Extension::IdIsValid(const std::string& id) {\n  if (id.size() != (kIdSize * 2))\n    return false;\n\n  std::string temp = StringToLowerASCII(id);\n  for (size_t i = 0; i < temp.size(); i++)\n    if (temp[i] < 'a' || temp[i] > 'p')\n      return false;\n\n  return true;\n}\n","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":307538,"func":"SchedulerHelper::~SchedulerHelper() {\n}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":98481,"func":"epass2003_create_file(struct sc_card *card, sc_file_t * file)\n{\n\tint r;\n\tsize_t len;\n\tu8 sbuf[SC_MAX_APDU_BUFFER_SIZE] = { 0 };\n\tstruct sc_apdu apdu;\n\n\tlen = SC_MAX_APDU_BUFFER_SIZE;\n\n\tepass2003_hook_file(file, 1);\n\n\tif (card->ops->construct_fci == NULL)\n\t\tLOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);\n\n\tr = epass2003_construct_fci(card, file, sbuf, &len);\n\tLOG_TEST_RET(card->ctx, r, \"construct_fci() failed\");\n\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);\n\tapdu.lc = len;\n\tapdu.datalen = len;\n\tapdu.data = sbuf;\n\n\tr = sc_transmit_apdu_t(card, &apdu);\n\tLOG_TEST_RET(card->ctx, r, \"APDU transmit failed\");\n\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\tLOG_TEST_RET(card->ctx, r, \"APDU sw1\/2 wrong\");\n\n\tepass2003_hook_file(file, 0);\n\treturn r;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":254659,"func":"void RenderWidgetHostViewGuest::TextInputStateChanged(\n    const ViewHostMsg_TextInputState_Params& params) {\n  NOTIMPLEMENTED();\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":137316,"func":"bool TrustedPrimitives::IsOutsideEnclave(const void *addr, size_t size) {\n  return sgx_is_outside_enclave(addr, size) == 1;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":374985,"func":"_copyList(const List *from)\n{\n\tList\t   *new;\n\tListCell   *curr_old;\n\tListCell   *prev_new;\n\n\tAssert(list_length(from) >= 1);\n\n\tnew = makeNode(List);\n\tnew->length = from->length;\n\n\tCOPY_NODE_CELL(new->head, from->head);\n\tprev_new = new->head;\n\tcurr_old = lnext(from->head);\n\n\twhile (curr_old)\n\t{\n\t\tCOPY_NODE_CELL(prev_new->next, curr_old);\n\t\tprev_new = prev_new->next;\n\t\tcurr_old = curr_old->next;\n\t}\n\tprev_new->next = NULL;\n\tnew->tail = prev_new;\n\n\treturn new;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":112810,"func":"static void nf_conntrack_standalone_fini_sysctl(struct net *net)\n{\n\tstruct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id);\n\tstruct ctl_table *table;\n\n\ttable = cnet->sysctl_header->ctl_table_arg;\n\tunregister_net_sysctl_table(cnet->sysctl_header);\n\tkfree(table);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":166445,"func":"  cf2_getScaleAndHintFlag( CFF_Decoder*  decoder,\n                           CF2_Fixed*    x_scale,\n                           CF2_Fixed*    y_scale,\n                           FT_Bool*      hinted,\n                           FT_Bool*      scaled )\n  {\n    FT_ASSERT( decoder && decoder->builder.glyph );\n\n    \/* note: FreeType scale includes a factor of 64 *\/\n    *hinted = decoder->builder.glyph->hint;\n    *scaled = decoder->builder.glyph->scaled;\n\n    if ( *hinted )\n    {\n      *x_scale = FT_DivFix( decoder->builder.glyph->x_scale,\n                            cf2_intToFixed( 64 ) );\n      *y_scale = FT_DivFix( decoder->builder.glyph->y_scale,\n                            cf2_intToFixed( 64 ) );\n    }\n    else\n    {\n      \/* for unhinted outlines, `cff_slot_load' does the scaling, *\/\n      \/* thus render at `unity' scale                             *\/\n\n      *x_scale = 0x0400;   \/* 1\/64 as 16.16 *\/\n      *y_scale = 0x0400;\n    }\n  }\n","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":347295,"func":"CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,\n                                       const char *domain, size_t domlen,\n                                       unsigned char *ntlmhash,\n                                       unsigned char *ntlmv2hash)\n{\n  \/* Unicode representation *\/\n  size_t identity_len = (userlen + domlen) * 2;\n  unsigned char *identity = malloc(identity_len);\n  CURLcode result = CURLE_OK;\n\n  if(!identity)\n    return CURLE_OUT_OF_MEMORY;\n\n  ascii_uppercase_to_unicode_le(identity, user, userlen);\n  ascii_to_unicode_le(identity + (userlen << 1), domain, domlen);\n\n  result = Curl_hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len),\n                         ntlmv2hash);\n\n  free(identity);\n\n  return result;\n}","target":1,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":523318,"func":"  void cancel_delete_all_rows()\n  {\n    deleting_all_rows= false;\n  }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":423880,"func":"dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,\n\t     const char *type, const char *key, uint32_t keydatalen,\n\t     unsigned char *keydata, void *dbdata)\n{\n\tstruct dlz_example_data *state = (struct dlz_example_data *)dbdata;\n\n\tUNUSED(tcpaddr);\n\tUNUSED(type);\n\tUNUSED(key);\n\tUNUSED(keydatalen);\n\tUNUSED(keydata);\n\n\tif (strncmp(name, \"deny.\", 5) == 0) {\n\t\tif (state->log != NULL)\n\t\t\tstate->log(ISC_LOG_INFO, \"dlz_example: denying update \"\n\t\t\t\t   \"of name=%s by %s\", name, signer);\n\t\treturn (false);\n\t}\n\tif (state->log != NULL)\n\t\tstate->log(ISC_LOG_INFO, \"dlz_example: allowing update of \"\n\t\t\t   \"name=%s by %s\", name, signer);\n\treturn (true);\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":207324,"func":"PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* document)\n{\n    return adoptRef(new Element(tagName, document, CreateElement));\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":475428,"func":"static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)\n{\n\tstruct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;\n\tint asid, ret;\n\n\tif (kvm->created_vcpus)\n\t\treturn -EINVAL;\n\n\tret = -EBUSY;\n\tif (unlikely(sev->active))\n\t\treturn ret;\n\n\tsev->active = true;\n\tsev->es_active = argp->id == KVM_SEV_ES_INIT;\n\tasid = sev_asid_new(sev);\n\tif (asid < 0)\n\t\tgoto e_no_asid;\n\tsev->asid = asid;\n\n\tret = sev_platform_init(&argp->error);\n\tif (ret)\n\t\tgoto e_free;\n\n\tINIT_LIST_HEAD(&sev->regions_list);\n\tINIT_LIST_HEAD(&sev->mirror_vms);\n\n\tkvm_set_apicv_inhibit(kvm, APICV_INHIBIT_REASON_SEV);\n\n\treturn 0;\n\ne_free:\n\tsev_asid_free(sev);\n\tsev->asid = 0;\ne_no_asid:\n\tsev->es_active = false;\n\tsev->active = false;\n\treturn ret;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":309169,"func":"void InspectorOverlay::highlightQuad(PassOwnPtr<FloatQuad> quad, const HighlightConfig& highlightConfig)\n{\n    m_quadHighlightConfig = highlightConfig;\n    m_highlightQuad = quad;\n    update();\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":234053,"func":"void ScreenOrientationDispatcherHost::OnOrientationChange() {\n  if (provider_)\n    provider_->OnOrientationChange();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":240304,"func":"MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(\n    MediaControls& mediaControls) {\n  MediaControlPlayButtonElement* button =\n      new MediaControlPlayButtonElement(mediaControls);\n  button->ensureUserAgentShadowRoot();\n  button->setType(InputTypeNames::button);\n  button->setShadowPseudoId(AtomicString(\"-webkit-media-controls-play-button\"));\n  return button;\n}\n","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":202603,"func":"ofputil_count_port_stats(const struct ofp_header *oh)\n{\n    struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));\n    ofpraw_pull_assert(&b);\n\n    for (size_t n = 0; ; n++) {\n        struct ofputil_port_stats ps;\n        if (ofputil_decode_port_stats(&ps, &b)) {\n            return n;\n        }\n    }\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":176335,"func":"void DownloadItemImpl::OnContentCheckCompleted(\n    content::DownloadDangerType danger_type) {\n  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n  DCHECK(AllDataSaved());\n  SetDangerType(danger_type);\n}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":93617,"func":"static void substSelect(\n  SubstContext *pSubst, \/* Description of the substitution *\/\n  Select *p,            \/* SELECT statement in which to make substitutions *\/\n  int doPrior           \/* Do substitutes on p->pPrior too *\/\n){\n  SrcList *pSrc;\n  struct SrcList_item *pItem;\n  int i;\n  if( !p ) return;\n  do{\n    substExprList(pSubst, p->pEList);\n    substExprList(pSubst, p->pGroupBy);\n    substExprList(pSubst, p->pOrderBy);\n    p->pHaving = substExpr(pSubst, p->pHaving);\n    p->pWhere = substExpr(pSubst, p->pWhere);\n    pSrc = p->pSrc;\n    assert( pSrc!=0 );\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      substSelect(pSubst, pItem->pSelect, 1);\n      if( pItem->fg.isTabFunc ){\n        substExprList(pSubst, pItem->u1.pFuncArg);\n      }\n    }\n  }while( doPrior && (p = p->pPrior)!=0 );\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":140348,"func":"}\n\nvoid free_last_set(REP_SETS *sets)\n{\n  sets->count--;\n  sets->extra++;","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":7591,"func":"void Context::onDone() {\n  if (wasm_->onDone_) {\n    wasm_->onDone_(this, id_);\n  }\n}","target":1,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":449817,"func":"static void pp_error_list_macros(errflags severity)\n{\n    const MMacro *m;\n\n    severity |= ERR_PP_LISTMACRO | ERR_NO_SEVERITY | ERR_HERE;\n\n    while ((m = src_error_down())) {\n        if ((m->nolist & NL_LIST) || !m->where.filename)\n            break;\n\tnasm_error(severity, \"... from macro `%s' defined\", m->name);\n    }\n\n    src_error_reset();\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":385037,"func":"static void curl_free_string(void **string)\n{\n\tefree(*string);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":176858,"func":"  void InitializeSpdySsl() {\n    ssl_data_->SetNextProto(kProtoSPDY3);\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":390178,"func":"const char* SSL_get_cipher_list(SSL* ssl, int priority)\n{\n    if (priority < 0 || priority >= MAX_CIPHERS)\n        return 0;\n\n    if (ssl->getSecurity().get_parms().cipher_list_[priority][0])\n        return ssl->getSecurity().get_parms().cipher_list_[priority];\n\n    return 0;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":188087,"func":" virtual void TearDown() {\n delete[] modified_buf_;\n }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":104924,"func":"static void show_object(struct object *obj, const char *name, void *data)\n{\n\tadd_preferred_base_object(name);\n\tadd_object_entry(obj->oid.hash, obj->type, name, 0);\n\tobj->flags |= OBJECT_ADDED;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":297709,"func":"exif_mnote_data_pentax_count (ExifMnoteData *n)\n{\n\treturn n ? ((ExifMnoteDataPentax *) n)->count : 0;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":370167,"func":"static inline void sctp_outq_tail_data(struct sctp_outq *q,\n\t\t\t\t       struct sctp_chunk *ch)\n{\n\tlist_add_tail(&ch->list, &q->out_chunk_list);\n\tq->out_qlen += ch->skb->len;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":170127,"func":"void ResourceFetcher::MakePreloadedResourceBlockOnloadIfNeeded(\n    Resource* resource,\n    const FetchRequest& request) {\n  if (resource && resource->Loader() &&\n      resource->IsLoadEventBlockingResourceType() &&\n      resource->IsLinkPreload() && !request.IsLinkPreload() &&\n      non_blocking_loaders_.Contains(resource->Loader())) {\n    non_blocking_loaders_.erase(resource->Loader());\n    loaders_.insert(resource->Loader());\n  }\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":69767,"func":"static void vmx_disable_shadow_vmcs(struct vcpu_vmx *vmx)\n{\n\tvmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_SHADOW_VMCS);\n\tvmcs_write64(VMCS_LINK_POINTER, -1ull);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":160766,"func":"      bool operator()(const pair<spg_t, PGQueueable> &op) {\n\tif (op.first == pgid) {\n\t  accumulate(op.second);\n\t  return true;\n\t} else {\n\t  return false;\n\t}\n      }","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":157714,"func":"sigbuffer_init (SigBuffer *buf, int size)\n{\n\tbuf->buf = g_malloc (size);\n\tbuf->p = buf->buf;\n\tbuf->end = buf->buf + size;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":492867,"func":"static int PamLocalCallback(int num_msg,\n#if defined(__sun)\n                            struct pam_message** msgm,\n#else\n                            const struct pam_message** msgm,\n#endif\n                            struct pam_response** response,\n                            void* appdata_ptr)\n{\n  struct pam_response* resp = static_cast<pam_response*>(\n      calloc(num_msg, sizeof(struct pam_response)));\n\n  PamData* pam_data = static_cast<PamData*>(appdata_ptr);\n\n  if (num_msg == 1) {\n    resp[0].resp = strdup(pam_data->passwd_.c_str());\n    resp[0].resp_retcode = 0;\n  }\n\n  *response = resp;\n  return PAM_SUCCESS;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":39502,"func":"ar6000_sysfs_bmi_read(struct file *fp, struct kobject *kobj,\n                      struct bin_attribute *bin_attr,\n                      char *buf, loff_t pos, size_t count)\n{\n    int index;\n    struct ar6_softc *ar;\n    struct hif_device_os_device_info   *osDevInfo;\n\n    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(\"BMI: Read %d bytes\\n\", (u32)count));\n    for (index=0; index < MAX_AR6000; index++) {\n        ar = (struct ar6_softc *)ar6k_priv(ar6000_devices[index]);\n        osDevInfo = &ar->osDevInfo;\n        if (kobj == (&(((struct device *)osDevInfo->pOSDevice)->kobj))) {\n            break;\n        }\n    }\n\n    if (index == MAX_AR6000) return 0;\n\n    if ((BMIRawRead(ar->arHifDevice, (u8*)buf, count, true)) != 0) {\n        return 0;\n    }\n\n    return count;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":495716,"func":"void Curl_ssl_version(char *buffer, size_t size)\n{\n#ifdef CURL_WITH_MULTI_SSL\n  (void)multissl_version(buffer, size);\n#else\n  (void)Curl_ssl->version(buffer, size);\n#endif\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":473342,"func":"static void scrub_spilled_slot(u8 *stype)\n{\n\tif (*stype != STACK_INVALID)\n\t\t*stype = STACK_MISC;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":288977,"func":"static int selinux_inode_setsecurity ( struct inode * inode , const char * name , const void * value , size_t size , int flags ) {\n struct inode_security_struct * isec = inode_security_novalidate ( inode ) ;\n u32 newsid ;\n int rc ;\n if ( strcmp ( name , XATTR_SELINUX_SUFFIX ) ) return - EOPNOTSUPP ;\n if ( ! value || ! size ) return - EACCES ;\n rc = security_context_to_sid ( value , size , & newsid , GFP_KERNEL ) ;\n if ( rc ) return rc ;\n spin_lock ( & isec -> lock ) ;\n isec -> sclass = inode_mode_to_security_class ( inode -> i_mode ) ;\n isec -> sid = newsid ;\n isec -> initialized = LABEL_INITIALIZED ;\n spin_unlock ( & isec -> lock ) ;\n return 0 ;\n }","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":66592,"func":"viminfo_encoding(vir_T *virp)\n{\n    char_u\t*p;\n    int\t\ti;\n\n    if (get_viminfo_parameter('c') != 0)\n    {\n\tp = vim_strchr(virp->vir_line, '=');\n\tif (p != NULL)\n\t{\n\t    \/* remove trailing newline *\/\n\t    ++p;\n\t    for (i = 0; vim_isprintc(p[i]); ++i)\n\t\t;\n\t    p[i] = NUL;\n\n\t    convert_setup(&virp->vir_conv, p, p_enc);\n\t}\n    }\n    return viminfo_readline(virp);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":468361,"func":"urnStart(HttpRequest * r, StoreEntry * e)\n{\n    UrnState *anUrn = new UrnState();\n    anUrn->start (r, e);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":165717,"func":"void NotifyCacheOnIO(\n    scoped_refptr<net::URLRequestContextGetter> request_context,\n    const GURL& url,\n    const std::string& http_method) {\n  net::HttpCache* cache = request_context->GetURLRequestContext()->\n      http_transaction_factory()->GetCache();\n  if (cache)\n    cache->OnExternalCacheHit(url, http_method);\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":231882,"func":"void AwContents::RequestProtectedMediaIdentifierPermission(\n    const GURL& origin,\n    const base::Callback<void(bool)>& callback) {\n  permission_request_handler_->SendRequest(\n      scoped_ptr<AwPermissionRequestDelegate>(new SimplePermissionRequest(\n          origin, AwPermissionRequest::ProtectedMediaId, callback)));\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":367882,"func":"static int cap_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)\n{\n\treturn 0;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":273280,"func":"static int set_bit_to_user(int nr, void __user *addr)\n{\n\tunsigned long log = (unsigned long)addr;\n\tstruct page *page;\n\tvoid *base;\n\tint bit = nr + (log % PAGE_SIZE) * 8;\n\tint r;\n\n\tr = get_user_pages_fast(log, 1, 1, &page);\n\tif (r < 0)\n\t\treturn r;\n\tBUG_ON(r != 1);\n\tbase = kmap_atomic(page);\n\tset_bit(bit, base);\n\tkunmap_atomic(base);\n\tset_page_dirty_lock(page);\n\tput_page(page);\n\treturn 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":13519,"func":"const BlockEntry* Segment::GetBlock(const CuePoint& cp,\n const CuePoint::TrackPosition& tp) {\n Cluster** const ii = m_clusters;\n Cluster** i = ii;\n\n const long count = m_clusterCount + m_clusterPreloadCount;\n\n Cluster** const jj = ii + count;\n Cluster** j = jj;\n\n while (i < j) {\n\n Cluster** const k = i + (j - i) \/ 2;\n    assert(k < jj);\n\n Cluster* const pCluster = *k;\n    assert(pCluster);\n\n\n const long long pos = pCluster->GetPosition();\n    assert(pos >= 0);\n\n if (pos < tp.m_pos)\n      i = k + 1;\n else if (pos > tp.m_pos)\n      j = k;\n else\n return pCluster->GetEntry(cp, tp);\n }\n\n  assert(i == j);\n\n \n   Cluster* const pCluster = Cluster::Create(this, -1, tp.m_pos);  \/\/, -1);\n  assert(pCluster);\n \n   const ptrdiff_t idx = i - m_clusters;\n \n  PreloadCluster(pCluster, idx);\n   assert(m_clusters);\n   assert(m_clusterPreloadCount > 0);\n   assert(m_clusters[idx] == pCluster);\n\n return pCluster->GetEntry(cp, tp);\n}\n","target":1,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":440071,"func":"MagickExport void XHighlightLine(Display *display,Window window,\n  GC annotate_context,const XSegment *highlight_info)\n{\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"...\");\n  assert(display != (Display *) NULL);\n  assert(window != (Window) NULL);\n  assert(annotate_context != (GC) NULL);\n  assert(highlight_info != (XSegment *) NULL);\n  (void) XDrawLine(display,window,annotate_context,highlight_info->x1,\n    highlight_info->y1,highlight_info->x2,highlight_info->y2);\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":93544,"func":"static void arcmsr_hbaA_message_isr(struct AdapterControlBlock *acb)\n{\n\tstruct MessageUnit_A __iomem *reg  = acb->pmuA;\n\t\/*clear interrupt and message state*\/\n\twritel(ARCMSR_MU_OUTBOUND_MESSAGE0_INT, ®->outbound_intstatus);\n\tschedule_work(&acb->arcmsr_do_message_isr_bh);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":66270,"func":"static int nfs_size_need_update(const struct inode *inode, const struct nfs_fattr *fattr)\n{\n\treturn nfs_size_to_loff_t(fattr->size) > i_size_read(inode);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":233647,"func":"void GLManager::Initialize(const GLManager::Options& options) {\n  GpuDriverBugWorkarounds platform_workarounds(\n      g_gpu_feature_info.enabled_gpu_driver_bug_workarounds);\n  InitializeWithWorkaroundsImpl(options, platform_workarounds);\n}\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":521415,"func":"bool Item_subselect::exec()\n{\n  subselect_engine *org_engine= engine;\n\n  DBUG_ENTER(\"Item_subselect::exec\");\n  DBUG_ASSERT(fixed);\n  DBUG_ASSERT(!eliminated);\n\n  \/*\n    Do not execute subselect in case of a fatal error\n    or if the query has been killed.\n  *\/\n  if (thd->is_error() || thd->killed)\n    DBUG_RETURN(true);\n\n  DBUG_ASSERT(!thd->lex->context_analysis_only);\n  \/*\n    Simulate a failure in sub-query execution. Used to test e.g.\n    out of memory or query being killed conditions.\n  *\/\n  DBUG_EXECUTE_IF(\"subselect_exec_fail\", DBUG_RETURN(true););\n\n  bool res= engine->exec();\n\n#ifndef DBUG_OFF\n  ++exec_counter;\n#endif\n  if (engine != org_engine)\n  {\n    \/*\n      If the subquery engine changed during execution due to lazy subquery\n      optimization, or because the original engine found a more efficient other\n      engine, re-execute the subquery with the new engine.\n    *\/\n    DBUG_RETURN(exec());\n  }\n  DBUG_RETURN(res);\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":283830,"func":"void ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute(\n    const GlobalFrameRoutingId& global_routing_id) {\n  ProcessBlockedRequestsForRoute(global_routing_id, true);\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":228048,"func":"DownloadRequestLimiter::TabDownloadState::~TabDownloadState() {\n  DCHECK(callbacks_.empty());\n\n  DCHECK(!factory_.HasWeakPtrs());\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":188419,"func":"bool FileSystemPolicy::SetInformationFileAction(\n    EvalResult eval_result, const ClientInfo& client_info,\n    HANDLE target_file_handle, void* file_info, uint32 length,\n    uint32 info_class, IO_STATUS_BLOCK* io_block,\n    NTSTATUS* nt_status) {\n  if (ASK_BROKER != eval_result) {\n    *nt_status = STATUS_ACCESS_DENIED;\n    return true;\n  }\n\n  NtSetInformationFileFunction NtSetInformationFile = NULL;\n  ResolveNTFunctionPtr(\"NtSetInformationFile\", &NtSetInformationFile);\n\n  HANDLE local_handle = NULL;\n  if (!::DuplicateHandle(client_info.process, target_file_handle,\n                         ::GetCurrentProcess(), &local_handle, 0, FALSE,\n                         DUPLICATE_SAME_ACCESS)) {\n    *nt_status = STATUS_ACCESS_DENIED;\n    return true;\n  }\n\n  ScopedHandle handle(local_handle);\n\n  FILE_INFORMATION_CLASS file_info_class =\n      static_cast<FILE_INFORMATION_CLASS>(info_class);\n  *nt_status = NtSetInformationFile(local_handle, io_block, file_info, length,\n                                    file_info_class);\n\n  return true;\n}\n","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":291530,"func":"size_t ndp_msg_opt_slladdr_len(struct ndp_msg *msg, int offset)\n{\n\treturn ETH_ALEN;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":203806,"func":"bool SendReloadJSONRequest(\n    AutomationMessageSender* sender,\n    int browser_index,\n    int tab_index,\n    std::string* error_msg) {\n  DictionaryValue dict;\n  dict.SetString(\"command\", \"Reload\");\n  dict.SetInteger(\"windex\", browser_index);\n  dict.SetInteger(\"tab_index\", tab_index);\n  DictionaryValue reply_dict;\n  return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);\n}\n","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":471280,"func":"void rdbReportError(int corruption_error, int linenum, char *reason, ...) {\n    va_list ap;\n    char msg[1024];\n    int len;\n\n    len = snprintf(msg,sizeof(msg),\n        \"Internal error in RDB reading offset %llu, function at rdb.c:%d -> \",\n        (unsigned long long)server.loading_loaded_bytes, linenum);\n    va_start(ap,reason);\n    vsnprintf(msg+len,sizeof(msg)-len,reason,ap);\n    va_end(ap);\n\n    if (!rdbCheckMode) {\n        if (rdbFileBeingLoaded || corruption_error) {\n            serverLog(LL_WARNING, \"%s\", msg);\n            char *argv[2] = {\"\",rdbFileBeingLoaded};\n            redis_check_rdb_main(2,argv,NULL);\n        } else {\n            serverLog(LL_WARNING, \"%s. Failure loading rdb format from socket, assuming connection error, resuming operation.\", msg);\n            return;\n        }\n    } else {\n        rdbCheckError(\"%s\",msg);\n    }\n    serverLog(LL_WARNING, \"Terminating server after rdb file reading failure.\");\n    exit(1);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":362109,"func":"  usage( void )\n  {\n    fprintf( stderr,\n      \"ftdiff: a simple program to proof several text hinting modes\\n\"\n      \"-----------------------------------------------------------\\n\"\n      \"\\n\"\n      \"Usage: ftdiff [options] fontfile [fontfile2 ...]\\n\"\n      \"\\n\"\n      \"  -r R         use resolution R dpi (default: 72 dpi)\\n\"\n      \"  -s S         set character size to S points (default: 16 pt)\\n\"\n      \"  -f TEXTFILE  change displayed text, using text in TEXTFILE\\n\"\n      \"\\n\" );\n    exit( 1 );\n  }","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":387488,"func":"keytype(\n\tstruct parse *pcmd,\n\tFILE *fp\n\t)\n{\n\tconst char *\tdigest_name;\n\tsize_t\t\tdigest_len;\n\tint\t\tkey_type;\n\n\tif (!pcmd->nargs) {\n\t\tfprintf(fp, \"keytype is %s with %lu octet digests\\n\",\n\t\t\tkeytype_name(info_auth_keytype),\n\t\t\t(u_long)info_auth_hashlen);\n\t\treturn;\n\t}\n\n\tdigest_name = pcmd->argval[0].string;\n\tdigest_len = 0;\n\tkey_type = keytype_from_text(digest_name, &digest_len);\n\n\tif (!key_type) {\n\t\tfprintf(fp, \"keytype is not valid. \"\n#ifdef OPENSSL\n\t\t\t\"Type \\\"help keytype\\\" for the available digest types.\\n\");\n#else\n\t\t\t\"Only \\\"md5\\\" is available.\\n\");\n#endif\n\t\treturn;\n\t}\n\n\tinfo_auth_keytype = key_type;\n\tinfo_auth_hashlen = digest_len;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":60318,"func":"  static void mapNext(ArrayIter& it) { ++it; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":211180,"func":"bool RenderWidgetHostViewAura::GetCompositionTextRange(\n    gfx::Range* range) const {\n  NOTIMPLEMENTED();\n  return false;\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":69587,"func":"TensorShape PoolParameters::forward_output_shape() {\n  if (depth_window == 1) {\n    \/\/ Spatial pooling\n    return ShapeFromFormat(data_format, tensor_in_batch, out_height, out_width,\n                           depth);\n  } else {\n    \/\/ Depthwise pooling\n    return TensorShape(\n        {tensor_in_batch, tensor_in_rows, tensor_in_cols, out_depth});\n  }\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":338253,"func":"int qemu_opts_set(QemuOptsList *list, const char *id,\n\n                  const char *name, const char *value)\n\n{\n\n    QemuOpts *opts;\n\n\n\n    opts = qemu_opts_create(list, id, 1);\n\n    if (opts == NULL) {\n\n        return -1;\n\n    }\n\n    return qemu_opt_set(opts, name, value);\n\n}\n","target":1,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":81369,"func":"void Statement::Work_Run(napi_env e, void* data) {\n    STATEMENT_INIT(RunBaton);\n\n    STATEMENT_MUTEX(mtx);\n    sqlite3_mutex_enter(mtx);\n\n    \/\/ Make sure that we also reset when there are no parameters.\n    if (!baton->parameters.size()) {\n        sqlite3_reset(stmt->_handle);\n    }\n\n    if (stmt->Bind(baton->parameters)) {\n        stmt->status = sqlite3_step(stmt->_handle);\n\n        if (!(stmt->status == SQLITE_ROW || stmt->status == SQLITE_DONE)) {\n            stmt->message = std::string(sqlite3_errmsg(stmt->db->_handle));\n        }\n        else {\n            baton->inserted_id = sqlite3_last_insert_rowid(stmt->db->_handle);\n            baton->changes = sqlite3_changes(stmt->db->_handle);\n        }\n    }\n\n    sqlite3_mutex_leave(mtx);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":274343,"func":"static void flush_queued_data_bh(void *opaque)\n{\n    VirtIOSerialPort *port = opaque;\n\n    flush_queued_data(port);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":454834,"func":"void __init udbg_init_rtas_panel(void)\n{\n\tudbg_putc = call_rtas_display_status_delay;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":114647,"func":"static void kvm_destroy_vm(struct kvm *kvm)\n{\n\tint i;\n\tstruct mm_struct *mm = kvm->mm;\n\n\tkvm_arch_sync_events(kvm);\n\traw_spin_lock(&kvm_lock);\n\tlist_del(&kvm->vm_list);\n\traw_spin_unlock(&kvm_lock);\n\tkvm_free_irq_routing(kvm);\n\tfor (i = 0; i < KVM_NR_BUSES; i++)\n\t\tkvm_io_bus_destroy(kvm->buses[i]);\n\tkvm_coalesced_mmio_free(kvm);\n#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)\n\tmmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm);\n#else\n\tkvm_arch_flush_shadow_all(kvm);\n#endif\n\tkvm_arch_destroy_vm(kvm);\n\tkvm_free_physmem(kvm);\n\tcleanup_srcu_struct(&kvm->srcu);\n\tkvm_arch_free_vm(kvm);\n\thardware_disable_all();\n\tmmdrop(mm);\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":461198,"func":"bool vsock_find_cid(unsigned int cid)\n{\n\tif (transport_g2h && cid == transport_g2h->get_local_cid())\n\t\treturn true;\n\n\tif (transport_h2g && cid == VMADDR_CID_HOST)\n\t\treturn true;\n\n\tif (transport_local && cid == VMADDR_CID_LOCAL)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":212109,"func":"static int php_pgsql_fd_flush(php_stream *stream) \/* {{{ *\/\n{\n\treturn FAILURE;\n}\n\/* }}} *\/\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":146651,"func":"static const char *parse_value(cJSON *item,const char *value,const char **ep)\n{\n\tif (!value)\t\t\t\t\t\treturn 0;\t\/* Fail on null. *\/\n\tif (!strncmp(value,\"null\",4))\t{ item->type=cJSON_NULL;  return value+4; }\n\tif (!strncmp(value,\"false\",5))\t{ item->type=cJSON_False; return value+5; }\n\tif (!strncmp(value,\"true\",4))\t{ item->type=cJSON_True; item->valueint=1;\treturn value+4; }\n\tif (*value=='\\\"')\t\t\t\t{ return parse_string(item,value,ep); }\n\tif (*value=='-' || (*value>='0' && *value<='9'))\t{ return parse_number(item,value); }\n\tif (*value=='[')\t\t\t\t{ return parse_array(item,value,ep); }\n\tif (*value=='{')\t\t\t\t{ return parse_object(item,value,ep); }\n\n\t*ep=value;return 0;\t\/* failure. *\/\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":481837,"func":"char *split_comma(char *str) {\n\tEUID_ASSERT();\n\tif (str == NULL || *str == '\\0')\n\t\treturn NULL;\n\tchar *ptr = strchr(str, ',');\n\tif (!ptr)\n\t\treturn NULL;\n\t*ptr = '\\0';\n\tptr++;\n\tif (*ptr == '\\0')\n\t\treturn NULL;\n\treturn ptr;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":314702,"func":"static waiting_command_t *get_waiting_command(command_opcode_t opcode) {\n  pthread_mutex_lock(&commands_pending_response_lock);\n\n for (const list_node_t *node = list_begin(commands_pending_response);\n      node != list_end(commands_pending_response);\n      node = list_next(node)) {\n waiting_command_t *wait_entry = list_node(node);\n\n if (!wait_entry || wait_entry->opcode != opcode)\n continue;\n\n    list_remove(commands_pending_response, wait_entry);\n\n    pthread_mutex_unlock(&commands_pending_response_lock);\n return wait_entry;\n }\n\n  pthread_mutex_unlock(&commands_pending_response_lock);\n return NULL;\n}\n","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":206611,"func":"jlong AwContents::ReleasePopupAwContents(JNIEnv* env, jobject obj) {\n  DCHECK_CURRENTLY_ON(BrowserThread::UI);\n  return reinterpret_cast<intptr_t>(pending_contents_.release());\n}\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":23933,"func":"IN_PROC_BROWSER_TEST_F ( UnloadTest , BrowserCloseWithInnerFocusedFrame ) {\n NavigateToDataURL ( INNER_FRAME_WITH_FOCUS_HTML , \"innerframewithfocus\" ) ;\n content : : WindowedNotificationObserver window_observer ( chrome : : NOTIFICATION_BROWSER_CLOSED , content : : NotificationService : : AllSources ( ) ) ;\n chrome : : CloseWindow ( browser ( ) ) ;\n ClickModalDialogButton ( true ) ;\n window_observer . Wait ( ) ;\n }","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":45846,"func":"static av_cold int decode_end(AVCodecContext *avctx)\n{\n    Mpeg4DecContext *ctx = avctx->priv_data;\n    int i;\n\n    if (!avctx->internal->is_copy) {\n        for (i = 0; i < 12; i++)\n            ff_free_vlc(&ctx->studio_intra_tab[i]);\n\n        ff_free_vlc(&ctx->studio_luma_dc);\n        ff_free_vlc(&ctx->studio_chroma_dc);\n    }\n\n    return ff_h263_decode_end(avctx);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":311842,"func":"bool MediaControlPanelElement::isOpaque() const {\n  return m_opaque;\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":192110,"func":"Browser::~Browser() {\n  VLOG_IF(1, g_log_bug53991) << \"~Browser: \" << profile_->IsOffTheRecord()\n                             << \"; stillActive=\"\n                             << BrowserList::IsOffTheRecordSessionActive();\n\n  if (profile_->GetProfileSyncService())\n    profile_->GetProfileSyncService()->RemoveObserver(this);\n\n  BrowserList::RemoveBrowser(this);\n\n#if defined(OS_WIN) || defined(OS_LINUX)\n  if (!BrowserList::HasBrowserWithProfile(profile_)) {\n    profile_->ResetTabRestoreService();\n  }\n#endif\n\n  SessionService* session_service = profile_->GetSessionService();\n  if (session_service)\n    session_service->WindowClosed(session_id_);\n\n  TabRestoreService* tab_restore_service = profile()->GetTabRestoreService();\n  if (tab_restore_service)\n    tab_restore_service->BrowserClosed(this);\n\n  if (profile_->IsOffTheRecord() &&\n      !BrowserList::IsOffTheRecordSessionActive()) {\n    profile_->GetOriginalProfile()->DestroyOffTheRecordProfile();\n  }\n\n  if (select_file_dialog_.get())\n    select_file_dialog_->ListenerDestroyed();\n\n  TabRestoreServiceDestroyed(tab_restore_service_);\n}\n","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":78520,"func":"static int vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,\n                                        int jobnr, int threadnr)\n{\n    return decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 0);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":79484,"func":"was_set_insecurely(char_u *opt, int opt_flags)\n{\n    int\t    idx = findoption(opt);\n    long_u  *flagp;\n\n    if (idx >= 0)\n    {\n\tflagp = insecure_flag(idx, opt_flags);\n\treturn (*flagp & P_INSECURE) != 0;\n    }\n    internal_error(\"was_set_insecurely()\");\n    return -1;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":136472,"func":"static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {\n  PyObject *__pyx_r = 0;\n  __Pyx_RefNannyDeclarations\n  __Pyx_RefNannySetupContext(\"__setstate_cython__ (wrapper)\", 0);\n  __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));\n\n  \/* function exit code *\/\n  __Pyx_RefNannyFinishContext();\n  return __pyx_r;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":463614,"func":"\nstatic void free_fixed_rsrc_data(struct fixed_rsrc_data *data)\n{\n\tpercpu_ref_exit(&data->refs);\n\tkfree(data->table);\n\tkfree(data);","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":362793,"func":"static inline int sk_mem_pages(int amt)\n{\n\treturn (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":28653,"func":"char * qemuDomainGetSecretAESAlias ( const char * srcalias , bool isLuks ) {\n char * alias ;\n if ( ! srcalias ) {\n virReportError ( VIR_ERR_INVALID_ARG , \"%s\" , _ ( \"encrypted secret alias requires valid source alias\" ) ) ;\n return NULL ;\n }\n if ( isLuks ) ignore_value ( virAsprintf ( & alias , \"%s-luks-secret0\" , srcalias ) ) ;\n else ignore_value ( virAsprintf ( & alias , \"%s-secret0\" , srcalias ) ) ;\n return alias ;\n }","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":224735,"func":"void WebSettingsImpl::setLocalStorageEnabled(bool enabled)\n{\n    m_settings->setLocalStorageEnabled(enabled);\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":328112,"func":"static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt)\n\n{\n\n    struct dshow_ctx *ctx = s->priv_data;\n\n    AVPacketList *pktl = NULL;\n\n\n\n    while (!ctx->eof && !pktl) {\n\n        WaitForSingleObject(ctx->mutex, INFINITE);\n\n        pktl = ctx->pktl;\n\n        if (pktl) {\n\n            *pkt = pktl->pkt;\n\n            ctx->pktl = ctx->pktl->next;\n\n            av_free(pktl);\n\n            ctx->curbufsize -= pkt->size;\n\n        }\n\n        ResetEvent(ctx->event[1]);\n\n        ReleaseMutex(ctx->mutex);\n\n        if (!pktl) {\n\n            if (dshow_check_event_queue(ctx->media_event) < 0) {\n\n                ctx->eof = 1;\n\n            } else if (s->flags & AVFMT_FLAG_NONBLOCK) {\n\n                return AVERROR(EAGAIN);\n\n            } else {\n\n                WaitForMultipleObjects(2, ctx->event, 0, INFINITE);\n\n            }\n\n        }\n\n    }\n\n\n\n    return ctx->eof ? AVERROR(EIO) : pkt->size;\n\n}\n","target":1,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":483269,"func":"void cgroup_fork(struct task_struct *child)\n{\n\tRCU_INIT_POINTER(child->cgroups, &init_css_set);\n\tINIT_LIST_HEAD(&child->cg_list);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":146045,"func":"   if (err == MP_OKAY) {\n       mG = wc_ecc_new_point_h(key->heap);\n       mQ = wc_ecc_new_point_h(key->heap);\n       if (mQ  == NULL || mG == NULL)\n          err = MEMORY_E;\n   }","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":308820,"func":"void RecordOffliningPreviewsUMA(const ClientId& client_id,\n                                content::PreviewsState previews_state) {\n  bool is_previews_enabled =\n      (previews_state != content::PreviewsTypes::PREVIEWS_OFF &&\n       previews_state != content::PreviewsTypes::PREVIEWS_NO_TRANSFORM);\n\n  base::UmaHistogramBoolean(\n      AddHistogramSuffix(client_id,\n                         \"OfflinePages.Background.OffliningPreviewStatus\"),\n       is_previews_enabled);\n }\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":261537,"func":"static void nft_verdict_uninit(const struct nft_data *data)\n{\n\tswitch (data->verdict) {\n\tcase NFT_JUMP:\n\tcase NFT_GOTO:\n\t\tdata->chain->use--;\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":311694,"func":"static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, unsigned int flags)\n{\n\tif (!proc_pid_lookup(dir, dentry, flags))\n\t\treturn NULL;\n\t\n\treturn proc_lookup(dir, dentry, flags);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":488313,"func":"static int NAttrFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)\n{\n\tif (na->type == AT_DATA && na->name == AT_UNNAMED)\n\t\treturn (na->ni->flags & flag);\n\treturn 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":462784,"func":"TEST_F(QueryPlannerTest, IndexBoundsOrOfNegations) {\n    addIndex(BSON(\"a\" << 1));\n    runQuery(fromjson(\"{$or: [{a: {$ne: 3}}, {a: {$ne: 4}}]}\"));\n\n    assertNumSolutions(2U);\n    assertSolutionExists(\"{cscan: {dir: 1}}\");\n    assertSolutionExists(\n        \"{fetch: {filter: null, node: {ixscan: {pattern: {a:1}, \"\n        \"bounds: {a: [['MinKey','MaxKey',true,true]]}}}}}\");\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":513040,"func":"  virtual void endPage() {}","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":478391,"func":"    const char *what() const throw() { return _message; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":59308,"func":"fixup_appledouble(struct archive_write_disk *a, const char *pathname)\n{\n\t(void)a; \/* UNUSED *\/\n\t(void)pathname; \/* UNUSED *\/\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":438616,"func":"static void rcs_submission_override(struct intel_engine_cs *engine)\n{\n\tswitch (INTEL_GEN(engine->i915)) {\n\tcase 12:\n\t\tengine->emit_flush = gen12_emit_flush_render;\n\t\tengine->emit_fini_breadcrumb = gen12_emit_fini_breadcrumb_rcs;\n\t\tbreak;\n\tcase 11:\n\t\tengine->emit_flush = gen11_emit_flush_render;\n\t\tengine->emit_fini_breadcrumb = gen11_emit_fini_breadcrumb_rcs;\n\t\tbreak;\n\tdefault:\n\t\tengine->emit_flush = gen8_emit_flush_render;\n\t\tengine->emit_fini_breadcrumb = gen8_emit_fini_breadcrumb_rcs;\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":388676,"func":"NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle,\n\t\t\t\t      TALLOC_CTX *mem_ctx,\n\t\t\t\t      struct files_struct *fsp,\n\t\t\t\t      struct smb_filename *smb_fname,\n\t\t\t\t      uint16_t *_compression_fmt)\n{\n\tVFS_FIND(get_compression);\n\treturn handle->fns->get_compression_fn(handle, mem_ctx, fsp, smb_fname,\n\t\t\t\t\t       _compression_fmt);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":272217,"func":"void Archive::SeekToNext()\n{\n  Seek(NextBlockPos,SEEK_SET);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":38850,"func":"static int proc_pid_syscall(struct task_struct *task, char *buffer)\n{\n\tlong nr;\n\tunsigned long args[6], sp, pc;\n\tint res = lock_trace(task);\n\tif (res)\n\t\treturn res;\n\n\tif (task_current_syscall(task, &nr, args, 6, &sp, &pc))\n\t\tres = sprintf(buffer, \"running\\n\");\n\telse if (nr < 0)\n\t\tres = sprintf(buffer, \"%ld 0x%lx 0x%lx\\n\", nr, sp, pc);\n\telse\n\t\tres = sprintf(buffer,\n\t\t       \"%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\\n\",\n\t\t       nr,\n\t\t       args[0], args[1], args[2], args[3], args[4], args[5],\n\t\t       sp, pc);\n\tunlock_trace(task);\n\treturn res;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":59940,"func":"static ssize_t srpt_tpg_attrib_srp_max_rsp_size_show(struct config_item *item,\n\t\tchar *page)\n{\n\tstruct se_portal_group *se_tpg = attrib_to_tpg(item);\n\tstruct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);\n\n\treturn sprintf(page, \"%u\\n\", sport->port_attrib.srp_max_rsp_size);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":112040,"func":"static unsigned int hc_entries(unsigned int cnt)\n{\n\tcnt = cnt & 7 ? (cnt \/ 8) + 1 : cnt \/ 8;\n\treturn cnt < avail_tree_table_sz ? cnt : avail_tree_table_sz - 1;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":77921,"func":"void __sched wait_for_completion(struct completion *x)\n{\n\twait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":213495,"func":" OMXCodecObserver() {\n }\n","target":0,"code_token_length":6,"total_token_length":242,"max_tokens_setting":512}
+{"idx":92736,"func":"static void ext4_handle_error(struct super_block *sb)\n{\n\tstruct ext4_super_block *es = EXT4_SB(sb)->s_es;\n\n\tEXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;\n\tes->s_state |= cpu_to_le16(EXT4_ERROR_FS);\n\n\tif (sb->s_flags & MS_RDONLY)\n\t\treturn;\n\n\tif (!test_opt(sb, ERRORS_CONT)) {\n\t\tjournal_t *journal = EXT4_SB(sb)->s_journal;\n\n\t\tEXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED;\n\t\tif (journal)\n\t\t\tjbd2_journal_abort(journal, -EIO);\n\t}\n\tif (test_opt(sb, ERRORS_RO)) {\n\t\text4_msg(sb, KERN_CRIT, \"Remounting filesystem read-only\");\n\t\tsb->s_flags |= MS_RDONLY;\n\t}\n\text4_commit_super(sb, 1);\n\tif (test_opt(sb, ERRORS_PANIC))\n\t\tpanic(\"EXT4-fs (device %s): panic forced after error\\n\",\n\t\t\tsb->s_id);\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":228043,"func":"void InspectorPageAgent::navigateToHistoryEntry(ErrorString*, int)\n{ }\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":455223,"func":"TEST_F(QueryPlannerTest, IndexBoundsAndWithNestedOr) {\n    addIndex(BSON(\"a\" << 1));\n    runQuery(fromjson(\"{$and: [{a: 1, $or: [{a: 2}, {a: 3}]}]}\"));\n\n    \/\/ Given that the index over 'a' isn't multikey, we ideally won't generate any solutions\n    \/\/ since we know the query describes an empty set if 'a' isn't multikey.  Any solutions\n    \/\/ below are \"this is how it currently works\" instead of \"this is how it should work.\"\n\n    \/\/ It's kind of iffy to look for indexed solutions so we don't...\n    size_t matches = 0;\n    matches += numSolutionMatches(\n        \"{cscan: {dir: 1, filter: \"\n        \"{$or: [{a: 2, a:1}, {a: 3, a:1}]}}}\");\n    matches += numSolutionMatches(\n        \"{cscan: {dir: 1, filter: \"\n        \"{$and: [{$or: [{a: 2}, {a: 3}]}, {a: 1}]}}}\");\n    ASSERT_GREATER_THAN_OR_EQUALS(matches, 1U);\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":449027,"func":"UTI_TimespecToDouble(struct timespec *ts)\n{\n  return ts->tv_sec + 1.0e-9 * ts->tv_nsec;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":127932,"func":"static int foreach_comment(void *user, const char *k, const char *v) {\n\tRAnalMetaUserItem *ui = user;\n\tRCore *core = ui->anal->user;\n\tconst char *cmd = ui->user;\n\tif (!strncmp (k, \"meta.C.\", 7)) {\n\t\tchar *cmt = (char *)sdb_decode (v, 0);\n\t\tif (!cmt) cmt = strdup (\"\");\n\t\t\/\/eprintf (\"--> %s = %s\\n\", k + 7, cmt);\n\t\tr_core_cmdf (core, \"s %s\", k + 7);\n\t\tr_core_cmd0 (core, cmd);\n\t\tfree (cmt);\n\t}\n\treturn 1;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":149577,"func":"TEST(ComparisonsTest, NotEqualString) {\n  if (SingleOpModel::GetForceUseNnapi()) {\n    return;\n  }\n  ComparisonOpModel model({1, 1, 1, 1, 4}, {1, 1, 1, 1, 4}, TensorType_STRING,\n                          BuiltinOperator_NOT_EQUAL);\n  model.PopulateTensor<std::string>(model.input1(), {\"A\", \"B\", \"C\", \"D\"});\n  model.PopulateTensor<std::string>(model.input2(), {\"A\", \"C\", \"B\", \"D\"});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, true, false));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 1, 4));\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":362723,"func":" *\/\nxmlNodePtr\nxmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {\n    if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);\n    if ((cur != NULL) && (cur->type  != XML_ATTRIBUTE_NODE) &&\n        (cur->type != XML_NAMESPACE_DECL) && (cur->children != NULL))\n        return(cur->children);\n\n    if (cur == NULL) {\n        cur = ctxt->context->node;\n        if (cur->type == XML_NAMESPACE_DECL)\n            return(NULL);\n        if (cur->type == XML_ATTRIBUTE_NODE)\n            cur = cur->parent;\n    }\n    if (cur == NULL) return(NULL) ; \/* ERROR *\/\n    if (cur->next != NULL) return(cur->next) ;\n    do {\n        cur = cur->parent;\n        if (cur == NULL) break;\n        if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL);\n        if (cur->next != NULL) return(cur->next);\n    } while (cur != NULL);","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":69568,"func":"void tac_copy_addr_info(struct addrinfo *p_dst, const struct addrinfo *p_src) {\n    if (p_dst && p_src) {\n        p_dst->ai_flags = p_src->ai_flags;\n        p_dst->ai_family = p_src->ai_family;\n        p_dst->ai_socktype = p_src->ai_socktype;\n        p_dst->ai_protocol = p_src->ai_protocol;\n        p_dst->ai_addrlen = p_src->ai_addrlen;\n\n        \/* ipv6 check *\/\n        if (p_dst->ai_family == AF_INET6) {\n          memcpy (p_dst->ai_addr, p_src->ai_addr, sizeof(struct sockaddr_in6));\n          memset ((struct sockaddr_in6*)p_dst->ai_addr, 0 , sizeof(struct sockaddr_in6));\n          memcpy ((struct sockaddr_in6*)p_dst->ai_addr, (struct sockaddr_in6*)p_src->ai_addr, sizeof(struct sockaddr_in6));\n        } else {\n           memcpy (p_dst->ai_addr, p_src->ai_addr, sizeof(struct sockaddr)); \n        }\n\n        p_dst->ai_canonname = NULL; \/* we do not care it *\/\n        p_dst->ai_next = NULL;      \/* no more chain *\/\n    }\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":438680,"func":"static bool virtual_matches(const struct virtual_engine *ve,\n\t\t\t    const struct i915_request *rq,\n\t\t\t    const struct intel_engine_cs *engine)\n{\n\tconst struct intel_engine_cs *inflight;\n\n\tif (!(rq->execution_mask & engine->mask)) \/* We peeked too soon! *\/\n\t\treturn false;\n\n\t\/*\n\t * We track when the HW has completed saving the context image\n\t * (i.e. when we have seen the final CS event switching out of\n\t * the context) and must not overwrite the context image before\n\t * then. This restricts us to only using the active engine\n\t * while the previous virtualized request is inflight (so\n\t * we reuse the register offsets). This is a very small\n\t * hystersis on the greedy seelction algorithm.\n\t *\/\n\tinflight = intel_context_inflight(&ve->context);\n\tif (inflight && inflight != engine)\n\t\treturn false;\n\n\treturn true;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":369954,"func":"void in6_dev_finish_destroy(struct inet6_dev *idev)\n{\n\tstruct net_device *dev = idev->dev;\n\n\tWARN_ON(!list_empty(&idev->addr_list));\n\tWARN_ON(idev->mc_list != NULL);\n\tWARN_ON(timer_pending(&idev->rs_timer));\n\n#ifdef NET_REFCNT_DEBUG\n\tpr_debug(\"%s: %s\\n\", __func__, dev ? dev->name : \"NIL\");\n#endif\n\tdev_put(dev);\n\tif (!idev->dead) {\n\t\tpr_warn(\"Freeing alive inet6 device %p\\n\", idev);\n\t\treturn;\n\t}\n\tsnmp6_free_dev(idev);\n\tkfree_rcu(idev, rcu);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":465756,"func":"static void fuse_link_write_file(struct file *file)\n{\n\tstruct inode *inode = file_inode(file);\n\tstruct fuse_inode *fi = get_fuse_inode(inode);\n\tstruct fuse_file *ff = file->private_data;\n\t\/*\n\t * file may be written through mmap, so chain it onto the\n\t * inodes's write_file list\n\t *\/\n\tspin_lock(&fi->lock);\n\tif (list_empty(&ff->write_entry))\n\t\tlist_add(&ff->write_entry, &fi->write_files);\n\tspin_unlock(&fi->lock);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":231348,"func":"bool SendGetAppModalDialogMessageJSONRequest(\n    AutomationMessageSender* sender,\n    std::string* message,\n    std::string* error_msg) {\n  DictionaryValue dict;\n  dict.SetString(\"command\", \"GetAppModalDialogMessage\");\n  DictionaryValue reply_dict;\n  if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))\n    return false;\n  return reply_dict.GetString(\"message\", message);\n}\n","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":437228,"func":"static int ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed)\n{\n\tdprintk(\"%s\\n\", __func__);\n\n\tswitch (dvbdmxfeed->type) {\n\tcase DMX_TYPE_TS:\n\t\treturn ttusb_dec_stop_ts_feed(dvbdmxfeed);\n\t\tbreak;\n\n\tcase DMX_TYPE_SEC:\n\t\treturn ttusb_dec_stop_sec_feed(dvbdmxfeed);\n\t\tbreak;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":178011,"func":"  void GetLastSession() {\n    profile()->GetSessionService()->TabClosed(controller().window_id(),\n                                              controller().session_id(),\n                                              false);\n\n    ReopenDatabase();\n    Time close_time;\n\n    session_helper_.ReadWindows(&windows_);\n  }\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":388831,"func":"void smb2cli_session_stop_replay(struct smbXcli_session *session)\n{\n\tsession->smb2->replay_active = false;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":487662,"func":"void WebContents::IncrementCapturerCount(gin::Arguments* args) {\n  gfx::Size size;\n  bool stay_hidden = false;\n  bool stay_awake = false;\n\n  \/\/ get size arguments if they exist\n  args->GetNext(&size);\n  \/\/ get stayHidden arguments if they exist\n  args->GetNext(&stay_hidden);\n  \/\/ get stayAwake arguments if they exist\n  args->GetNext(&stay_awake);\n\n  std::ignore =\n      web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":425152,"func":"g_socket_client_get_socket_type (GSocketClient *client)\n{\n  return client->priv->type;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":167215,"func":"void SyncBackendHost::HandleClearServerDataSucceededOnFrontendLoop() {\n  if (!frontend_)\n    return;\n  frontend_->OnClearServerDataSucceeded();\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":427545,"func":"static efi_status_t efi_thunk_get_time(efi_time_t *tm, efi_time_cap_t *tc)\n{\n\tefi_status_t status;\n\tu32 phys_tm, phys_tc;\n\tunsigned long flags;\n\n\tspin_lock(&rtc_lock);\n\tspin_lock_irqsave(&efi_runtime_lock, flags);\n\n\tphys_tm = virt_to_phys_or_null(tm);\n\tphys_tc = virt_to_phys_or_null(tc);\n\n\tstatus = efi_thunk(get_time, phys_tm, phys_tc);\n\n\tspin_unlock_irqrestore(&efi_runtime_lock, flags);\n\tspin_unlock(&rtc_lock);\n\n\treturn status;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":103478,"func":"syscall_get_enter_fields(struct ftrace_event_call *call)\n{\n\tstruct syscall_metadata *entry = call->data;\n\n\treturn &entry->enter_fields;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":247175,"func":"void reference_dct_2d(int16_t input[64], double output[64]) {\n for (int i = 0; i < 8; ++i) {\n double temp_in[8], temp_out[8];\n for (int j = 0; j < 8; ++j)\n      temp_in[j] = input[j*8 + i];\n    reference_dct_1d(temp_in, temp_out);\n for (int j = 0; j < 8; ++j)\n      output[j*8 + i] = temp_out[j];\n }\n for (int i = 0; i < 8; ++i) {\n double temp_in[8], temp_out[8];\n for (int j = 0; j < 8; ++j)\n      temp_in[j] = output[j + i*8];\n    reference_dct_1d(temp_in, temp_out);\n for (int j = 0; j < 8; ++j)\n      output[j + i*8] = temp_out[j];\n }\n for (int i = 0; i < 64; ++i)\n    output[i] *= 2;\n}\n","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":461883,"func":"}\n\nstatic int\niscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":510978,"func":"static void patch_fn(struct cgit_context *ctx)\n{\n\tcgit_print_patch(ctx->qry.sha1);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":348057,"func":"static void prepare_cmd(struct argv_array *out, const struct child_process *cmd)\n{\n\tif (!cmd->argv[0])\n\t\tdie(\"BUG: command is empty\");\n\n\t\/*\n\t * Add SHELL_PATH so in the event exec fails with ENOEXEC we can\n\t * attempt to interpret the command with 'sh'.\n\t *\/\n\targv_array_push(out, SHELL_PATH);\n\n\tif (cmd->git_cmd) {\n\t\targv_array_push(out, \"git\");\n\t\targv_array_pushv(out, cmd->argv);\n\t} else if (cmd->use_shell) {\n\t\tprepare_shell_cmd(out, cmd->argv);\n\t} else {\n\t\targv_array_pushv(out, cmd->argv);\n\t}\n\n\t\/*\n\t * If there are no '\/' characters in the command then perform a path\n\t * lookup and use the resolved path as the command to exec.  If there\n\t * are no '\/' characters or if the command wasn't found in the path,\n\t * have exec attempt to invoke the command directly.\n\t *\/\n\tif (!strchr(out->argv[1], '\/')) {\n\t\tchar *program = locate_in_PATH(out->argv[1]);\n\t\tif (program) {\n\t\t\tfree((char *)out->argv[1]);\n\t\t\tout->argv[1] = program;\n\t\t}\n\t}\n}","target":1,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":243602,"func":"SPL_METHOD(Array, key)\n{\n\tif (zend_parse_parameters_none() == FAILURE) {\n\t\treturn;\n\t}\n\n\tspl_array_iterator_key(getThis(), return_value TSRMLS_CC);\n} \/* }}} *\/\n\nvoid spl_array_iterator_key(zval *object, zval *return_value TSRMLS_DC) \/* {{{ *\/\n","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":310205,"func":"pdf_show_shade(fz_context *ctx, pdf_run_processor *pr, fz_shade *shd)\n{\n\tpdf_gstate *gstate = pr->gstate + pr->gtop;\n\tfz_rect bbox;\n\tsoftmask_save softmask = { NULL };\n\n\tif (pr->super.hidden)\n\t\treturn;\n\n\tfz_bound_shade(ctx, shd, &gstate->ctm, &bbox);\n\n\tgstate = pdf_begin_group(ctx, pr, &bbox, &softmask);\n\n\t\/* FIXME: The gstate->ctm in the next line may be wrong; maybe\n\t * it should be the parent gstates ctm? *\/\n\tfz_fill_shade(ctx, pr->dev, shd, &gstate->ctm, gstate->fill.alpha, &gstate->fill.color_params);\n\n\tpdf_end_group(ctx, pr, &softmask);\n}\n","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":280973,"func":"void ContainerNode::insertBeforeCommon(Node* nextChild, Node* newChild)\n{\n    NoEventDispatchAssertion assertNoEventDispatch;\n\n    ASSERT(newChild);\n    ASSERT(!newChild->parentNode()); \/\/ Use insertBefore if you need to handle reparenting (and want DOM mutation events).\n    ASSERT(!newChild->nextSibling());\n    ASSERT(!newChild->previousSibling());\n    ASSERT(!newChild->isShadowRoot());\n\n    Node* prev = nextChild->previousSibling();\n    ASSERT(m_lastChild != prev);\n    nextChild->setPreviousSibling(newChild);\n    if (prev) {\n        ASSERT(m_firstChild != nextChild);\n        ASSERT(prev->nextSibling() == nextChild);\n        prev->setNextSibling(newChild);\n    } else {\n        ASSERT(m_firstChild == nextChild);\n        m_firstChild = newChild;\n    }\n    newChild->setParentOrShadowHostNode(this);\n    newChild->setPreviousSibling(prev);\n    newChild->setNextSibling(nextChild);\n}\n","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":384447,"func":"static int evdev_flush(struct file *file, fl_owner_t id)\n{\n\tstruct evdev_client *client = file->private_data;\n\tstruct evdev *evdev = client->evdev;\n\tint retval;\n\n\tretval = mutex_lock_interruptible(&evdev->mutex);\n\tif (retval)\n\t\treturn retval;\n\n\tif (!evdev->exist || client->revoked)\n\t\tretval = -ENODEV;\n\telse\n\t\tretval = input_flush_device(&evdev->handle, file);\n\n\tmutex_unlock(&evdev->mutex);\n\treturn retval;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":32845,"func":"static inline void activate_mm(struct mm_struct *prev,\n                               struct mm_struct *next)\n{\n\tswitch_mm(prev, next, current);\n\tcpumask_set_cpu(smp_processor_id(), mm_cpumask(next));\n\tset_user_asce(next);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":341550,"func":"void vnc_display_init(DisplayState *ds)\n\n{\n\n    VncDisplay *vs = g_malloc0(sizeof(*vs));\n\n\n\n    dcl = g_malloc0(sizeof(DisplayChangeListener));\n\n\n\n    ds->opaque = vs;\n\n    dcl->idle = 1;\n\n    vnc_display = vs;\n\n\n\n    vs->lsock = -1;\n\n#ifdef CONFIG_VNC_WS\n\n    vs->lwebsock = -1;\n\n#endif\n\n\n\n    vs->ds = ds;\n\n    QTAILQ_INIT(&vs->clients);\n\n    vs->expires = TIME_MAX;\n\n\n\n    if (keyboard_layout)\n\n        vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);\n\n    else\n\n        vs->kbd_layout = init_keyboard_layout(name2keysym, \"en-us\");\n\n\n\n    if (!vs->kbd_layout)\n\n        exit(1);\n\n\n\n    qemu_mutex_init(&vs->mutex);\n\n    vnc_start_worker_thread();\n\n\n\n    dcl->ops = &dcl_ops;\n\n    register_displaychangelistener(ds, dcl);\n\n}\n","target":1,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":520942,"func":"bool Item_func_like::find_selective_predicates_list_processor(void *arg)\n{\n  find_selective_predicates_list_processor_data *data=\n    (find_selective_predicates_list_processor_data *) arg;\n  if (use_sampling && used_tables() == data->table->map)\n  {\n    THD *thd= data->table->in_use;\n    COND_STATISTIC *stat;\n    Item *arg0;\n    if (!(stat= (COND_STATISTIC *) thd->alloc(sizeof(COND_STATISTIC))))\n      return TRUE;\n    stat->cond= this;\n    arg0= args[0]->real_item();\n    if (args[1]->const_item() && arg0->type() == FIELD_ITEM)\n      stat->field_arg= ((Item_field *)arg0)->field;\n    else\n      stat->field_arg= NULL;\n    data->list.push_back(stat, thd->mem_root);\n  }\n  return FALSE;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":256591,"func":"static void http_chunked_request_done ( struct evhttp_request * req , void * arg ) {\n if ( req -> response_code != HTTP_OK ) {\n fprintf ( stderr , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n if ( evhttp_find_header ( req -> input_headers , \"Transfer-Encoding\" ) == NULL ) {\n fprintf ( stderr , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n if ( EVBUFFER_LENGTH ( req -> input_buffer ) != 13 + 18 + 8 ) {\n fprintf ( stderr , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n if ( strncmp ( ( char * ) EVBUFFER_DATA ( req -> input_buffer ) , \"This is funnybut not hilarious.bwv 1052\" , + 18 + 8 ) ) {\n fprintf ( stderr , \"FAILED\\n\" ) ;\n exit ( 1 ) ;\n }\n test_ok = 1 ;\n event_loopexit ( NULL ) ;\n }","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":500486,"func":"QPDFWriter::writeHeader()\n{\n    writeString(\"%PDF-\");\n    writeString(this->m->final_pdf_version);\n    if (this->m->pclm)\n    {\n        \/\/ PCLm version\n        writeString(\"\\n%PCLm 1.0\\n\");\n    }\n    else\n    {\n        \/\/ This string of binary characters would not be valid UTF-8, so\n        \/\/ it really should be treated as binary.\n        writeString(\"\\n%\\xbf\\xf7\\xa2\\xfe\\n\");\n    }\n    writeStringQDF(\"%QDF-1.0\\n\\n\");\n\n    \/\/ Note: do not write extra header text here.  Linearized PDFs\n    \/\/ must include the entire linearization parameter dictionary\n    \/\/ within the first 1024 characters of the PDF file, so for\n    \/\/ linearized files, we have to write extra header text after the\n    \/\/ linearization parameter dictionary.\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":354093,"func":"set_attribute_9(TERMTYPE2 *tp, int flag)\n{\n    const char *value;\n    char *result;\n\n    value = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag);\n    if (PRESENT(value))\n\tresult = strdup(value);\n    else\n\tresult = 0;\n    return result;\n}","target":1,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":403357,"func":"PHP_FUNCTION(openssl_get_cert_locations)\n{\n\tarray_init(return_value);\n\n\tadd_assoc_string(return_value, \"default_cert_file\", (char *) X509_get_default_cert_file(), 1);\n\tadd_assoc_string(return_value, \"default_cert_file_env\", (char *) X509_get_default_cert_file_env(), 1);\n\tadd_assoc_string(return_value, \"default_cert_dir\", (char *) X509_get_default_cert_dir(), 1);\n\tadd_assoc_string(return_value, \"default_cert_dir_env\", (char *) X509_get_default_cert_dir_env(), 1);\n\tadd_assoc_string(return_value, \"default_private_dir\", (char *) X509_get_default_private_dir(), 1);\n\tadd_assoc_string(return_value, \"default_default_cert_area\", (char *) X509_get_default_cert_area(), 1);\n\tadd_assoc_string(return_value, \"ini_cafile\",\n\t\tzend_ini_string(\"openssl.cafile\", sizeof(\"openssl.cafile\"), 0), 1);\n\tadd_assoc_string(return_value, \"ini_capath\",\n\t\tzend_ini_string(\"openssl.capath\", sizeof(\"openssl.capath\"), 0), 1);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":405247,"func":"ossl_asn1_tag_class(VALUE obj)\n{\n    VALUE s;\n\n    s = ossl_asn1_get_tag_class(obj);\n    if (NIL_P(s) || s == sym_UNIVERSAL)\n\treturn V_ASN1_UNIVERSAL;\n    else if (s == sym_APPLICATION)\n\treturn V_ASN1_APPLICATION;\n    else if (s == sym_CONTEXT_SPECIFIC)\n\treturn V_ASN1_CONTEXT_SPECIFIC;\n    else if (s == sym_PRIVATE)\n\treturn V_ASN1_PRIVATE;\n    else\n\tossl_raise(eASN1Error, \"invalid tag class\");\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":381662,"func":"static __init int vdso_setup(char *s)\n{\n\tvdso64_enabled = simple_strtoul(s, NULL, 0);\n\treturn 0;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":168029,"func":"xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {\n  xmlXPathObjectPtr str;\n  xmlXPathObjectPtr find;\n  xmlBufferPtr target;\n  const xmlChar *point;\n  int offset;\n\n  CHECK_ARITY(2);\n  CAST_TO_STRING;\n  find = valuePop(ctxt);\n  CAST_TO_STRING;\n  str = valuePop(ctxt);\n\n  target = xmlBufferCreate();\n  if (target) {\n    point = xmlStrstr(str->stringval, find->stringval);\n    if (point) {\n      offset = (int)(point - str->stringval) + xmlStrlen(find->stringval);\n      xmlBufferAdd(target, &str->stringval[offset],\n\t\t   xmlStrlen(str->stringval) - offset);\n    }\n    valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,\n\txmlBufferContent(target)));\n    xmlBufferFree(target);\n  }\n  xmlXPathReleaseObject(ctxt->context, str);\n  xmlXPathReleaseObject(ctxt->context, find);\n}\n","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":231991,"func":"static Layer* FindFirstScrollableLayer(Layer* layer) {\n  if (!layer)\n    return NULL;\n\n  if (layer->scrollable())\n    return layer;\n\n  for (size_t i = 0; i < layer->children().size(); ++i) {\n    Layer* found = FindFirstScrollableLayer(layer->children()[i].get());\n    if (found)\n      return found;\n  }\n\n  return NULL;\n}\n","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":495539,"func":"Bool gf_isom_moov_first(GF_ISOFile *movie)\n{\n\tu32 i;\n\tfor (i=0; i<gf_list_count(movie->TopBoxes); i++) {\n\t\tGF_Box *b = (GF_Box*)gf_list_get(movie->TopBoxes, i);\n\t\tif (b->type == GF_ISOM_BOX_TYPE_MOOV) return GF_TRUE;\n\t\tif (b->type == GF_ISOM_BOX_TYPE_MDAT) return GF_FALSE;\n\t}\n\treturn GF_FALSE;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":152953,"func":"FunctionContext::~FunctionContext() {\n  irGen_->functionContext_ = oldContext_;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":464234,"func":"void *zrealloc_usable(void *ptr, size_t size, size_t *usable) {\n#ifndef HAVE_MALLOC_SIZE\n    void *realptr;\n#endif\n    size_t oldsize;\n    void *newptr;\n\n    if (size == 0 && ptr != NULL) {\n        zfree(ptr);\n        *usable = 0;\n        return NULL;\n    }\n    if (ptr == NULL) return zmalloc_usable(size, usable);\n#ifdef HAVE_MALLOC_SIZE\n    oldsize = zmalloc_size(ptr);\n    newptr = realloc(ptr,size);\n    if (!newptr) zmalloc_oom_handler(size);\n\n    update_zmalloc_stat_free(oldsize);\n    update_zmalloc_stat_alloc(*usable = zmalloc_size(newptr));\n    return newptr;\n#else\n    realptr = (char*)ptr-PREFIX_SIZE;\n    oldsize = *((size_t*)realptr);\n    newptr = realloc(realptr,size+PREFIX_SIZE);\n    if (!newptr) zmalloc_oom_handler(size);\n\n    *((size_t*)newptr) = *usable = size;\n    update_zmalloc_stat_free(oldsize);\n    update_zmalloc_stat_alloc(size);\n    return (char*)newptr+PREFIX_SIZE;\n#endif\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":237317,"func":"static std::string WrapWithTH(std::string text) {\n  return \"<th>\" + text + \"<\/th>\";\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":497492,"func":"struct razer_report razer_chroma_misc_get_scroll_mode(void)\n{\n    struct razer_report report = get_razer_report(0x02, 0x94, 0x02);\n\n    report.arguments[0] = VARSTORE;\n\n    return report;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":263861,"func":"static MagickBooleanType IsXWD(const unsigned char *magick,const size_t length)\n{\n  if (length < 8)\n    return(MagickFalse);\n  if (memcmp(magick+1,\"\\000\\000\",2) == 0)\n    {\n      if (memcmp(magick+4,\"\\007\\000\\000\",3) == 0)\n        return(MagickTrue);\n      if (memcmp(magick+5,\"\\000\\000\\007\",3) == 0)\n        return(MagickTrue);\n    }\n  return(MagickFalse);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":26870,"func":"static int virLogSetDefaultOutputToFile ( const char * filename , bool privileged ) {\n int ret = - 1 ;\n char * logdir = NULL ;\n mode_t old_umask ;\n if ( privileged ) {\n if ( virAsprintf ( & virLogDefaultOutput , \"%d:file:%s\/log\/libvirt\/%s\" , virLogDefaultPriority , LOCALSTATEDIR , filename ) < 0 ) goto cleanup ;\n }\n else {\n if ( ! ( logdir = virGetUserCacheDirectory ( ) ) ) goto cleanup ;\n old_umask = umask ( 077 ) ;\n if ( virFileMakePath ( logdir ) < 0 ) {\n umask ( old_umask ) ;\n goto cleanup ;\n }\n umask ( old_umask ) ;\n if ( virAsprintf ( & virLogDefaultOutput , \"%d:file:%s\/%s\" , virLogDefaultPriority , logdir , filename ) < 0 ) goto cleanup ;\n }\n ret = 0 ;\n cleanup : VIR_FREE ( logdir ) ;\n return ret ;\n }","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":213417,"func":"image_draw_decide_cb (int image_id, void *data)\n{\n  return (image_id == GPOINTER_TO_INT (data));\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":498404,"func":"TEST_F(RouterTest, HttpsInternalRedirectSucceeded) {\n  auto ssl_connection = std::make_shared<Ssl::MockConnectionInfo>();\n  enableRedirects(3);\n  setNumPreviousRedirect(1);\n\n  sendRequest();\n\n  redirect_headers_->setLocation(\"https:\/\/www.foo.com\");\n  EXPECT_CALL(connection_, ssl()).WillOnce(Return(ssl_connection));\n  EXPECT_CALL(callbacks_, clearRouteCache());\n  EXPECT_CALL(callbacks_, recreateStream(_)).WillOnce(Return(true));\n  response_decoder_->decodeHeaders(std::move(redirect_headers_), false);\n  EXPECT_EQ(1U, cm_.thread_local_cluster_.cluster_.info_->stats_store_\n                    .counter(\"upstream_internal_redirect_succeeded_total\")\n                    .value());\n\n  \/\/ In production, the HCM recreateStream would have called this.\n  router_.onDestroy();\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":405911,"func":"ofputil_protocol_is_valid(enum ofputil_protocol protocol)\n{\n    return protocol & OFPUTIL_P_ANY && is_pow2(protocol);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":501843,"func":"static void free_urlhandle(struct Curl_URL *u)\n{\n  free(u->scheme);\n  free(u->user);\n  free(u->password);\n  free(u->options);\n  free(u->host);\n  free(u->zoneid);\n  free(u->port);\n  free(u->path);\n  free(u->query);\n  free(u->fragment);\n  free(u->scratch);\n  free(u->temppath);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":449417,"func":"nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)\n{\n\tstruct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;\n\tstruct nouveau_mem *mem = nouveau_mem(reg);\n\tint ret;\n\n\tret = nouveau_mem_host(reg, &nvbe->ttm);\n\tif (ret)\n\t\treturn ret;\n\n\tret = nouveau_mem_map(mem, &mem->cli->vmm.vmm, &mem->vma[0]);\n\tif (ret) {\n\t\tnouveau_mem_fini(mem);\n\t\treturn ret;\n\t}\n\n\tnvbe->mem = mem;\n\treturn 0;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":213094,"func":"LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)\n{\n\ttmsize_t rowlen = TIFFScanlineSize(tif);\n\n        if (rowlen == 0)\n                return 0;\n\n\tassert(cc%rowlen == 0);\n\twhile (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) {\n\t\tbp += rowlen;\n\t\tcc -= rowlen;\n\t}\n\treturn (cc == 0);\n}\n","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":245057,"func":"void tst_QQuickWebView::removeFromCanvas()\n{\n    showWebView();\n\n    QQuickItem* parent = webView()->parentItem();\n    QQuickItem noCanvasItem;\n    webView()->setParentItem(&noCanvasItem);\n    QTest::qWait(200);\n    webView()->setParentItem(parent);\n    webView()->setVisible(true);\n    QTest::qWait(200);\n}\n","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":405545,"func":"test_bson_append_dbpointer (void)\n{\n   bson_oid_t oid;\n   bson_t *b;\n   bson_t *b2;\n\n   b = bson_new ();\n   bson_oid_init_from_string (&oid, \"0123abcd0123abcd0123abcd\");\n   BSON_ASSERT (bson_append_dbpointer (b, \"dbpointer\", -1, \"foo\", &oid));\n   b2 = get_bson (\"test28.bson\");\n   BSON_ASSERT_BSON_EQUAL (b, b2);\n   bson_destroy (b);\n   bson_destroy (b2);\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":370845,"func":"rb_str_new_shared(VALUE str)\n{\n    VALUE str2 = str_new3(rb_obj_class(str), str);\n\n    OBJ_INFECT(str2, str);\n    return str2;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":476143,"func":"void InstanceKlass::ensure_space_for_methodids(int start_offset) {\n  int new_jmeths = 0;\n  int length = methods()->length();\n  for (int index = start_offset; index < length; index++) {\n    Method* m = methods()->at(index);\n    jmethodID id = m->find_jmethod_id_or_null();\n    if (id == NULL) {\n      new_jmeths++;\n    }\n  }\n  if (new_jmeths != 0) {\n    Method::ensure_jmethod_ids(class_loader_data(), new_jmeths);\n  }\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":225209,"func":"int PrintWebViewHelper::PrintPreviewContext::total_page_count() const {\n  DCHECK(IsRendering());\n  return total_page_count_;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":420727,"func":"static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan)\n{\n\tstruct l2cap_conn *conn = chan->conn;\n\tstruct l2cap_le_conn_rsp rsp;\n\tu16 result;\n\n\tif (test_bit(FLAG_DEFER_SETUP, &chan->flags))\n\t\tresult = L2CAP_CR_LE_AUTHORIZATION;\n\telse\n\t\tresult = L2CAP_CR_LE_BAD_PSM;\n\n\tl2cap_state_change(chan, BT_DISCONN);\n\n\trsp.dcid    = cpu_to_le16(chan->scid);\n\trsp.mtu     = cpu_to_le16(chan->imtu);\n\trsp.mps     = cpu_to_le16(chan->mps);\n\trsp.credits = cpu_to_le16(chan->rx_credits);\n\trsp.result  = cpu_to_le16(result);\n\n\tl2cap_send_cmd(conn, chan->ident, L2CAP_LE_CONN_RSP, sizeof(rsp),\n\t\t       &rsp);\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":360226,"func":"invalidate_deep_counts (NautilusFile *file)\n{\n\tfile->details->deep_counts_status = NAUTILUS_REQUEST_NOT_STARTED;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":97231,"func":"void ptrace_disable(struct task_struct *task)\n{\n\tmemset(&task->thread.per_user, 0, sizeof(task->thread.per_user));\n\tmemset(&task->thread.per_event, 0, sizeof(task->thread.per_event));\n\tclear_tsk_thread_flag(task, TIF_SINGLE_STEP);\n\tclear_pt_regs_flag(task_pt_regs(task), PIF_PER_TRAP);\n\ttask->thread.per_flags = 0;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":217710,"func":" ErrorResilienceTestLarge()\n : EncoderTest(GET_PARAM(0)),\n        psnr_(0.0),\n        nframes_(0),\n        mismatch_psnr_(0.0),\n        mismatch_nframes_(0),\n        encoding_mode_(GET_PARAM(1)) {\n Reset();\n }\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":242791,"func":"ExtensionFunction* NewExtensionFunction() {\n  return new T();\n}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":166733,"func":"xps_parse_digits(char *s, int *digit)\n{\n\t*digit = 0;\n\twhile (*s >= '0' && *s <= '9')\n\t{\n\t\t*digit = *digit * 10 + (*s - '0');\n\t\ts ++;\n\t}\n\treturn s;\n}\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":449146,"func":"CNF_GetRtcOnUtc(void)\n{\n  return rtc_on_utc;\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":9060,"func":"static gboolean is_correct_filename(const char *value)\n{\n    return printable_str(value) && !strchr(value, '\/') && !strchr(value, '.');\n}","target":1,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":156324,"func":"flatpak_context_reset_non_permissions (FlatpakContext *context)\n{\n  g_hash_table_remove_all (context->env_vars);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":459379,"func":"cb_log_host(const union sudo_defs_val *sd_un)\n{\n    debug_decl(cb_syslog_maxlen, SUDOERS_DEBUG_PLUGIN);\n\n    eventlog_set_omit_hostname(!sd_un->flag);\n\n    debug_return_bool(true);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":103625,"func":"  void log() {\n    RequestHeaderMap* request_headers = nullptr;\n    if (filter_manager_callbacks_.requestHeaders()) {\n      request_headers = filter_manager_callbacks_.requestHeaders().ptr();\n    }\n    ResponseHeaderMap* response_headers = nullptr;\n    if (filter_manager_callbacks_.responseHeaders()) {\n      response_headers = filter_manager_callbacks_.responseHeaders().ptr();\n    }\n    ResponseTrailerMap* response_trailers = nullptr;\n    if (filter_manager_callbacks_.responseTrailers()) {\n      response_trailers = filter_manager_callbacks_.responseTrailers().ptr();\n    }\n\n    for (const auto& log_handler : access_log_handlers_) {\n      log_handler->log(request_headers, response_headers, response_trailers, stream_info_);\n    }\n  }","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":476579,"func":"evict_writes (struct rw_file *rwf, uint64_t offset, size_t len)\n{\n  static __thread struct write_window window[NR_WINDOWS];\n\n  \/* Evict the oldest window from the page cache. *\/\n  if (window[0].len > 0) {\n    sync_file_range (rwf->fd, window[0].offset, window[0].len,\n                     SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|\n                     SYNC_FILE_RANGE_WAIT_AFTER);\n    posix_fadvise (rwf->fd, window[0].offset, window[0].len,\n                   POSIX_FADV_DONTNEED);\n  }\n\n  \/* Move the Nth window to N-1. *\/\n  memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1));\n\n  \/* Set up the current window and tell Linux to start writing it out\n   * to disk (asynchronously).\n   *\/\n  sync_file_range (rwf->fd, offset, len, SYNC_FILE_RANGE_WRITE);\n  window[NR_WINDOWS-1].offset = offset;\n  window[NR_WINDOWS-1].len = len;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":204867,"func":"bool Syncer::ExitRequested() {\n  base::AutoLock lock(early_exit_requested_lock_);\n  return early_exit_requested_;\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":166906,"func":"void FrameLoader::loadArchive(PassRefPtr<Archive> prpArchive)\n{\n    RefPtr<Archive> archive = prpArchive;\n    \n    ArchiveResource* mainResource = archive->mainResource();\n    ASSERT(mainResource);\n    if (!mainResource)\n        return;\n        \n    SubstituteData substituteData(mainResource->data(), mainResource->mimeType(), mainResource->textEncoding(), KURL());\n    \n    ResourceRequest request(mainResource->url());\n#if PLATFORM(MAC)\n    request.applyWebArchiveHackForMail();\n#endif\n\n    RefPtr<DocumentLoader> documentLoader = m_client->createDocumentLoader(request, substituteData);\n    documentLoader->addAllArchiveResources(archive.get());\n    load(documentLoader.get());\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":224567,"func":"void WebFrame::startDownload(const WebCore::ResourceRequest& request)\n {\n     ASSERT(m_policyDownloadID);\n \n    DownloadManager::shared().startDownload(m_policyDownloadID, page(), request);\n \n     m_policyDownloadID = 0;\n }\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":206473,"func":"hb_shaper_get_run_language(ASS_Shaper *shaper, hb_script_t script)\n{\n    hb_language_t lang;\n\n    if (shaper->language != HB_LANGUAGE_INVALID)\n        return shaper->language;\n\n    lang = script_to_language(script);\n\n    if (lang == HB_LANGUAGE_INVALID)\n        lang = hb_language_get_default();\n\n    return lang;\n}\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":455788,"func":"void SdamServerSelector::_verifyMaxstalenessWireVersions(TopologyDescriptionPtr topologyDescription,\n                                                         Seconds maxStalenessSeconds) {\n    for (auto& server : topologyDescription->getServers()) {\n        uassert(ErrorCodes::IncompatibleServerVersion,\n                \"Incompatible wire version\",\n                server->getMaxWireVersion() >= WireVersion::COMMANDS_ACCEPT_WRITE_CONCERN);\n    }\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":141464,"func":"\nGF_Err stri_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tsize_t i;\n\tGF_SubTrackInformationBox *ptr = (GF_SubTrackInformationBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 8)\n\tptr->switch_group = gf_bs_read_u16(bs);\n\tptr->alternate_group = gf_bs_read_u16(bs);\n\tptr->sub_track_id = gf_bs_read_u32(bs);\n\tptr->attribute_count = ptr->size \/ 4;\n\tGF_SAFE_ALLOC_N(ptr->attribute_list, (size_t)ptr->attribute_count, u32);\n\tif (!ptr->attribute_list) return GF_OUT_OF_MEM;\n\tfor (i = 0; i < ptr->attribute_count; i++) {\n\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\tptr->attribute_list[i] = gf_bs_read_u32(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":70374,"func":"static void AuthPAMUserPwdStartFunc(rfbClientPtr cl)\n{\n  cl->state = RFB_AUTHENTICATION;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":477557,"func":"static void tcf_chain_head_change_item(struct tcf_filter_chain_list_item *item,\n\t\t\t\t       struct tcf_proto *tp_head)\n{\n\tif (item->chain_head_change)\n\t\titem->chain_head_change(tp_head, item->chain_head_change_priv);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":485882,"func":"sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep,\n\t\t\t\t     const struct sctp_association *asoc,\n\t\t\t\t     const sctp_subtype_t type,\n\t\t\t\t     void *arg,\n\t\t\t\t     sctp_cmd_seq_t *commands)\n{\n\treturn SCTP_DISPOSITION_VIOLATION;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":411433,"func":"      }\n      static double nan() {\n#ifdef NAN\n        return (double)NAN;\n#else\n        const double val_nan = -std::sqrt(-1.0); return val_nan;\n#endif","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":111301,"func":"static bool ptrace_freeze_traced(struct task_struct *task)\n{\n\tbool ret = false;\n\n\t\/* Lockless, nobody but us can set this flag *\/\n\tif (task->jobctl & JOBCTL_LISTENING)\n\t\treturn ret;\n\n\tspin_lock_irq(&task->sighand->siglock);\n\tif (task_is_traced(task) && !__fatal_signal_pending(task)) {\n\t\ttask->state = __TASK_TRACED;\n\t\tret = true;\n\t}\n\tspin_unlock_irq(&task->sighand->siglock);\n\n\treturn ret;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":217244,"func":"void RenderViewHostImpl::JavaScriptDialogClosed(IPC::Message* reply_msg,\n                                                bool success,\n                                                const string16& user_input) {\n  GetProcess()->SetIgnoreInputEvents(false);\n  bool is_waiting =\n      is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_;\n\n  if (is_waiting) {\n    StartHangMonitorTimeout(TimeDelta::FromMilliseconds(\n        success ? kUnloadTimeoutMS : hung_renderer_delay_ms_));\n  }\n\n  ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,\n                                                     success, user_input);\n  Send(reply_msg);\n\n  if (is_waiting && are_javascript_messages_suppressed_)\n    delegate_->RendererUnresponsive(this, is_waiting);\n}\n","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
diff --git a/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.pkl b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..a0e2928d5999c9b31ad2a5ad69721b954ab79e56
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:091ac096cc146323ad28cab68feaa328a8dbdc100940ef5c11cd6d06ac6a0c1b
+size 2955365
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..b547c9667ad4bc1ae8b1585087b4e7c53830d61e
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.jsonl
@@ -0,0 +1,768 @@
+{"idx":439495,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tsquashfs_dir_header_2 dirh;\n\tchar buffer[sizeof(squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tsquashfs_dir_entry_2 *dire = (squashfs_dir_entry_2 *) buffer;\n\tlong long start;\n\tint bytes;\n\tint dir_count, size;\n\tstruct dir_ent *new_dir;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: malloc failed!\\n\");\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = 0;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 0)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\t\t\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\tbytes = lookup_entry(directory_table_hash, start);\n\tif(bytes == -1)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: directory block %d not \"\n\t\t\t\"found!\\n\", block_start);\n\n\tbytes += (*i)->offset;\n\tsize = (*i)->data + bytes;\n\n\twhile(bytes < size) {\t\t\t\n\t\tif(swap) {\n\t\t\tsquashfs_dir_header_2 sdirh;\n\t\t\tmemcpy(&sdirh, directory_table + bytes, sizeof(sdirh));\n\t\t\tSQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);\n\t\t} else\n\t\t\tmemcpy(&dirh, directory_table + bytes, sizeof(dirh));\n\t\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_entry_2 sdire;\n\t\t\t\tmemcpy(&sdire, directory_table + bytes,\n\t\t\t\t\tsizeof(sdire));\n\t\t\t\tSQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);\n\t\t\t} else\n\t\t\t\tmemcpy(dire, directory_table + bytes,\n\t\t\t\t\tsizeof(*dire));\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tmemcpy(dire->name, directory_table + bytes,\n\t\t\t\tdire->size + 1);\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\n\t\t\t\/* check name for invalid characters (i.e \/, ., ..) *\/\n\t\t\tif(check_name(dire->name, dire->size + 1) == FALSE) {\n\t\t\t\tERROR(\"File system corrupted: invalid characters in name\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\t\t\tif((dir->dir_count % DIR_ENT_SIZE) == 0) {\n\t\t\t\tnew_dir = realloc(dir->dirs, (dir->dir_count +\n\t\t\t\t\tDIR_ENT_SIZE) * sizeof(struct dir_ent));\n\t\t\t\tif(new_dir == NULL)\n\t\t\t\t\tEXIT_UNSQUASH(\"squashfs_opendir: \"\n\t\t\t\t\t\t\"realloc failed!\\n\");\n\t\t\t\tdir->dirs = new_dir;\n\t\t\t}\n\t\t\tstrcpy(dir->dirs[dir->dir_count].name, dire->name);\n\t\t\tdir->dirs[dir->dir_count].start_block =\n\t\t\t\tdirh.start_block;\n\t\t\tdir->dirs[dir->dir_count].offset = dire->offset;\n\t\t\tdir->dirs[dir->dir_count].type = dire->type;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tfree(dir->dirs);\n\tfree(dir);\n\treturn NULL;\n}","target":0,"code_token_length":1035,"total_token_length":1271,"max_tokens_setting":2048}
+{"idx":95908,"func":"bool AppendPostInstallTasks(const InstallerState& installer_state,\n                            const FilePath& setup_path,\n                            const FilePath& new_chrome_exe,\n                            const Version* current_version,\n                            const Version& new_version,\n                            const FilePath& temp_path,\n                            WorkItemList* post_install_task_list) {\n  DCHECK(post_install_task_list);\n\n  HKEY root = installer_state.root_key();\n  const Products& products = installer_state.products();\n\n  {\n    scoped_ptr<WorkItemList> in_use_update_work_items(\n        WorkItem::CreateConditionalWorkItemList(\n            new ConditionRunIfFileExists(new_chrome_exe)));\n    in_use_update_work_items->set_log_message(\"InUseUpdateWorkItemList\");\n\n    FilePath installer_path(installer_state.GetInstallerDirectory(new_version)\n        .Append(setup_path.BaseName()));\n\n    CommandLine rename(installer_path);\n    rename.AppendSwitch(switches::kRenameChromeExe);\n    if (installer_state.system_install())\n      rename.AppendSwitch(switches::kSystemLevel);\n\n    if (installer_state.verbose_logging())\n      rename.AppendSwitch(switches::kVerboseLogging);\n\n    std::wstring version_key;\n    for (size_t i = 0; i < products.size(); ++i) {\n      BrowserDistribution* dist = products[i]->distribution();\n      version_key = dist->GetVersionKey();\n\n      if (current_version != NULL) {\n        in_use_update_work_items->AddSetRegValueWorkItem(root, version_key,\n            google_update::kRegOldVersionField,\n            UTF8ToWide(current_version->GetString()), true);\n      }\n\n      CommandLine product_rename_cmd(rename);\n      products[i]->AppendRenameFlags(&product_rename_cmd);\n      in_use_update_work_items->AddSetRegValueWorkItem(\n          root,\n          version_key,\n          google_update::kRegRenameCmdField,\n          product_rename_cmd.command_line_string(),\n          true);\n    }\n\n    if (current_version != NULL && installer_state.is_multi_install()) {\n      BrowserDistribution* dist =\n          installer_state.multi_package_binaries_distribution();\n      in_use_update_work_items->AddSetRegValueWorkItem(\n          root,\n          dist->GetVersionKey(),\n          google_update::kRegOldVersionField,\n          UTF8ToWide(current_version->GetString()),\n          true);\n    }\n\n    post_install_task_list->AddWorkItem(in_use_update_work_items.release());\n  }\n\n  {\n    scoped_ptr<WorkItemList> regular_update_work_items(\n        WorkItem::CreateConditionalWorkItemList(\n            new Not(new ConditionRunIfFileExists(new_chrome_exe))));\n    regular_update_work_items->set_log_message(\"RegularUpdateWorkItemList\");\n\n    for (size_t i = 0; i < products.size(); ++i) {\n      BrowserDistribution* dist = products[i]->distribution();\n      std::wstring version_key(dist->GetVersionKey());\n      regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,\n                                            google_update::kRegOldVersionField);\n      regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,\n                                            google_update::kRegRenameCmdField);\n    }\n\n    post_install_task_list->AddWorkItem(regular_update_work_items.release());\n  }\n\n  AddRegisterComDllWorkItemsForPackage(installer_state, current_version,\n                                       new_version, post_install_task_list);\n\n  if (installer_state.is_msi()) {\n    for (size_t i = 0; i < products.size(); ++i) {\n      const Product* product = products[i];\n      AddSetMsiMarkerWorkItem(installer_state, product->distribution(), true,\n                              post_install_task_list);\n\n      AddDeleteUninstallShortcutsForMSIWorkItems(installer_state, *product,\n                                                 temp_path,\n                                                 post_install_task_list);\n    }\n    if (installer_state.is_multi_install()) {\n      AddSetMsiMarkerWorkItem(installer_state,\n          installer_state.multi_package_binaries_distribution(), true,\n          post_install_task_list);\n    }\n  }\n\n  return true;\n}\n","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048}
+{"idx":508376,"func":"Open_table_context::\nrequest_backoff_action(enum_open_table_action action_arg,\n                       TABLE_LIST *table)\n{\n  \/*\n    A back off action may be one of three kinds:\n\n    * We met a broken table that needs repair, or a table that\n      is not present on this MySQL server and needs re-discovery.\n      To perform the action, we need an exclusive metadata lock on\n      the table. Acquiring X lock while holding other shared\n      locks can easily lead to deadlocks. We rely on MDL deadlock\n      detector to discover them. If this is a multi-statement\n      transaction that holds metadata locks for completed statements,\n      we should keep these locks after discovery\/repair.\n      The action type in this case is OT_DISCOVER or OT_REPAIR.\n    * Our attempt to acquire an MDL lock lead to a deadlock,\n      detected by the MDL deadlock detector. The current\n      session was chosen a victim. If this is a multi-statement\n      transaction that holds metadata locks taken by completed\n      statements, restarting locking for the current statement\n      may lead to a livelock. Releasing locks of completed\n      statements can not be done as will lead to violation\n      of ACID. Thus, again, if m_has_locks is set,\n      we report an error. Otherwise, when there are no metadata\n      locks other than which belong to this statement, we can\n      try to recover from error by releasing all locks and\n      restarting the pre-locking.\n      Similarly, a deadlock error can occur when the\n      pre-locking process met a TABLE_SHARE that is being\n      flushed, and unsuccessfully waited for the flush to\n      complete. A deadlock in this case can happen, e.g.,\n      when our session is holding a metadata lock that\n      is being waited on by a session which is using\n      the table which is being flushed. The only way\n      to recover from this error is, again, to close all\n      open tables, release all locks, and retry pre-locking.\n      Action type name is OT_REOPEN_TABLES. Re-trying\n      while holding some locks may lead to a livelock,\n      and thus we don't do it.\n    * Finally, this session has open TABLEs from different\n      \"generations\" of the table cache. This can happen, e.g.,\n      when, after this session has successfully opened one\n      table used for a statement, FLUSH TABLES interfered and\n      expelled another table used in it. FLUSH TABLES then\n      blocks and waits on the table already opened by this\n      statement.\n      We detect this situation by ensuring that table cache\n      version of all tables used in a statement is the same.\n      If it isn't, all tables needs to be reopened.\n      Note, that we can always perform a reopen in this case,\n      even if we already have metadata locks, since we don't\n      keep tables open between statements and a livelock\n      is not possible.\n  *\/\n  if (action_arg == OT_BACKOFF_AND_RETRY && m_has_locks)\n  {\n    my_error(ER_LOCK_DEADLOCK, MYF(0));\n    m_thd->mark_transaction_to_rollback(true);\n    return TRUE;\n  }\n  \/*\n    If auto-repair or discovery are requested, a pointer to table\n    list element must be provided.\n  *\/\n  if (table)\n  {\n    DBUG_ASSERT(action_arg == OT_DISCOVER || action_arg == OT_REPAIR);\n    m_failed_table= (TABLE_LIST*) m_thd->alloc(sizeof(TABLE_LIST));\n    if (m_failed_table == NULL)\n      return TRUE;\n    m_failed_table->init_one_table(table->db, table->db_length,\n                                   table->table_name,\n                                   table->table_name_length,\n                                   table->alias, TL_WRITE);\n    m_failed_table->open_strategy= table->open_strategy;\n    m_failed_table->mdl_request.set_type(MDL_EXCLUSIVE);\n  }\n  m_action= action_arg;\n  return FALSE;\n}","target":0,"code_token_length":842,"total_token_length":1078,"max_tokens_setting":2048}
+{"idx":355623,"func":"garbage_collect(int testing)\n{\n    int\t\tcopyID;\n    int\t\tabort = FALSE;\n    buf_T\t*buf;\n    win_T\t*wp;\n    int\t\tdid_free = FALSE;\n    tabpage_T\t*tp;\n\n    if (!testing)\n    {\n\t\/\/ Only do this once.\n\twant_garbage_collect = FALSE;\n\tmay_garbage_collect = FALSE;\n\tgarbage_collect_at_exit = FALSE;\n    }\n\n    \/\/ The execution stack can grow big, limit the size.\n    if (exestack.ga_maxlen - exestack.ga_len > 500)\n    {\n\tsize_t\tnew_len;\n\tchar_u\t*pp;\n\tint\tn;\n\n\t\/\/ Keep 150% of the current size, with a minimum of the growth size.\n\tn = exestack.ga_len \/ 2;\n\tif (n < exestack.ga_growsize)\n\t    n = exestack.ga_growsize;\n\n\t\/\/ Don't make it bigger though.\n\tif (exestack.ga_len + n < exestack.ga_maxlen)\n\t{\n\t    new_len = exestack.ga_itemsize * (exestack.ga_len + n);\n\t    pp = vim_realloc(exestack.ga_data, new_len);\n\t    if (pp == NULL)\n\t\treturn FAIL;\n\t    exestack.ga_maxlen = exestack.ga_len + n;\n\t    exestack.ga_data = pp;\n\t}\n    }\n\n    \/\/ We advance by two because we add one for items referenced through\n    \/\/ previous_funccal.\n    copyID = get_copyID();\n\n    \/*\n     * 1. Go through all accessible variables and mark all lists and dicts\n     *    with copyID.\n     *\/\n\n    \/\/ Don't free variables in the previous_funccal list unless they are only\n    \/\/ referenced through previous_funccal.  This must be first, because if\n    \/\/ the item is referenced elsewhere the funccal must not be freed.\n    abort = abort || set_ref_in_previous_funccal(copyID);\n\n    \/\/ script-local variables\n    abort = abort || garbage_collect_scriptvars(copyID);\n\n    \/\/ buffer-local variables\n    FOR_ALL_BUFFERS(buf)\n\tabort = abort || set_ref_in_item(&buf->b_bufvar.di_tv, copyID,\n\t\t\t\t\t\t\t\t  NULL, NULL);\n\n    \/\/ window-local variables\n    FOR_ALL_TAB_WINDOWS(tp, wp)\n\tabort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,\n\t\t\t\t\t\t\t\t  NULL, NULL);\n    if (aucmd_win != NULL)\n\tabort = abort || set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID,\n\t\t\t\t\t\t\t\t  NULL, NULL);\n#ifdef FEAT_PROP_POPUP\n    FOR_ALL_POPUPWINS(wp)\n\tabort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,\n\t\t\t\t\t\t\t\t  NULL, NULL);\n    FOR_ALL_TABPAGES(tp)\n\tFOR_ALL_POPUPWINS_IN_TAB(tp, wp)\n\t\tabort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,\n\t\t\t\t\t\t\t\t  NULL, NULL);\n#endif\n\n    \/\/ tabpage-local variables\n    FOR_ALL_TABPAGES(tp)\n\tabort = abort || set_ref_in_item(&tp->tp_winvar.di_tv, copyID,\n\t\t\t\t\t\t\t\t  NULL, NULL);\n    \/\/ global variables\n    abort = abort || garbage_collect_globvars(copyID);\n\n    \/\/ function-local variables\n    abort = abort || set_ref_in_call_stack(copyID);\n\n    \/\/ named functions (matters for closures)\n    abort = abort || set_ref_in_functions(copyID);\n\n    \/\/ function call arguments, if v:testing is set.\n    abort = abort || set_ref_in_func_args(copyID);\n\n    \/\/ funcstacks keep variables for closures\n    abort = abort || set_ref_in_funcstacks(copyID);\n\n    \/\/ v: vars\n    abort = abort || garbage_collect_vimvars(copyID);\n\n    \/\/ callbacks in buffers\n    abort = abort || set_ref_in_buffers(copyID);\n\n    \/\/ 'completefunc', 'omnifunc' and 'thesaurusfunc' callbacks\n    abort = abort || set_ref_in_insexpand_funcs(copyID);\n\n    \/\/ 'operatorfunc' callback\n    abort = abort || set_ref_in_opfunc(copyID);\n\n    \/\/ 'tagfunc' callback\n    abort = abort || set_ref_in_tagfunc(copyID);\n\n    \/\/ 'imactivatefunc' and 'imstatusfunc' callbacks\n    abort = abort || set_ref_in_im_funcs(copyID);\n\n#ifdef FEAT_LUA\n    abort = abort || set_ref_in_lua(copyID);\n#endif\n\n#ifdef FEAT_PYTHON\n    abort = abort || set_ref_in_python(copyID);\n#endif\n\n#ifdef FEAT_PYTHON3\n    abort = abort || set_ref_in_python3(copyID);\n#endif\n\n#ifdef FEAT_JOB_CHANNEL\n    abort = abort || set_ref_in_channel(copyID);\n    abort = abort || set_ref_in_job(copyID);\n#endif\n#ifdef FEAT_NETBEANS_INTG\n    abort = abort || set_ref_in_nb_channel(copyID);\n#endif\n\n#ifdef FEAT_TIMERS\n    abort = abort || set_ref_in_timer(copyID);\n#endif\n\n#ifdef FEAT_QUICKFIX\n    abort = abort || set_ref_in_quickfix(copyID);\n#endif\n\n#ifdef FEAT_TERMINAL\n    abort = abort || set_ref_in_term(copyID);\n#endif\n\n#ifdef FEAT_PROP_POPUP\n    abort = abort || set_ref_in_popups(copyID);\n#endif\n\n    if (!abort)\n    {\n\t\/*\n\t * 2. Free lists and dictionaries that are not referenced.\n\t *\/\n\tdid_free = free_unref_items(copyID);\n\n\t\/*\n\t * 3. Check if any funccal can be freed now.\n\t *    This may call us back recursively.\n\t *\/\n\tfree_unref_funccal(copyID, testing);\n    }\n    else if (p_verbose > 0)\n    {\n\tverb_msg(_(\"Not enough memory to set references, garbage collection aborted!\"));\n    }\n\n    return did_free;\n}","target":0,"code_token_length":1260,"total_token_length":1496,"max_tokens_setting":2048}
+{"idx":221675,"func":"int Socket::checkCertHostname(const std::string &_hostname)\n{\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n    String hostname = _hostname;\n\n    X509 *peercertificate = SSL_get_peer_certificate(ssl);\n    if (peercertificate == NULL) {\n#ifdef NETDEBUG\n        std::cout << thread_id << \"unable to get certificate for \" << hostname << std::endl;\n#endif\n        return -1;\n    }\n    \/\/force to lower case as domain names are not case sensetive\n    hostname.toLower();\n\n#ifdef NETDEBUG\n    std::cout << thread_id << \"checking certificate\" << hostname << std::endl;\n    std::cout << thread_id << \"Checking hostname against subjectAltNames\" << std::endl;\n#endif\n\n\n    bool matched = false;\n    bool hasaltname = false;\n\n    \/\/check the altname extension for additional valid names\n    STACK_OF(GENERAL_NAME) *gens = NULL;\n    gens = (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i(peercertificate, NID_subject_alt_name, 0, 0);\n    int r = sk_GENERAL_NAME_num(gens);\n    for (int i = 0; i < r; ++i) {\n        const GENERAL_NAME *gn = sk_GENERAL_NAME_value(gens, i);\n\n        \/\/if its not a dns entry we really dont care about it\n        if (gn->type != GEN_DNS) {\n            continue;\n        }\n\n        \/\/only mark hasaltname as true if it has a DNS altname\n        hasaltname = true;\n\n        \/\/an ASN1_IA5STRING is a define of an ASN1_STRING so we can do it this way\n        unsigned char *nameutf8;\n        int len = ASN1_STRING_to_UTF8(&nameutf8, gn->d.ia5);\n        if (len < 0) {\n            break;\n        }\n\n        String altname = std::string((char *)nameutf8, len);\n        OPENSSL_free(nameutf8);\n\n        \/\/force to lower case as domain names are not case sensetive\n        altname.toLower();\n\n#ifdef NETDEBUG\n        std::cout << thread_id << \"checking against alt name \" << altname << std::endl;\n#endif\n\n        if (hostname.compare(altname) == 0) {\n            matched = true;\n            break;\n        } else if (altname.contains(\"*\")) {\n#ifdef NETDEBUG\n            std::cout << thread_id << \"Wildcard certificate is in use\" << std::endl;\n#endif\n            String  anend;\n            anend = altname.after(\"*\"); \/\/ need to keep the \".\"\n            if (hostname.endsWith(anend)) {\n                bool part_match = true;\n                String anstart = altname.before(\"*\");\n                String t = hostname.before(anend.c_str());\n                if( anstart.length() > 0) {             \/\/ if something before * we must also match this\n                  if( hostname.startsWith(anstart)) {\n                    t = t.after(anstart.c_str());\n                  } else {\n                      part_match = false;    \/\/ even though after * matches, no match on before * - so cannot match\n                   }\n                 }\n                 \/\/    t now contains what is matched by the '*\"  - this must not contain a '.'\n                 if (part_match && !t.contains(\".\")) {\n                   matched = true;\n                   break;\n                }\n            }\n        }\n    }\n    sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free);\n\n    if (matched) {\n        X509_free(peercertificate);\n        return 0;\n    } else if (hasaltname) {\n        X509_free(peercertificate);\n        return -1;\n    }\n\n#ifdef NETDEBUG\n    std::cout << thread_id << \"checking hostname against the following common names\" << std::endl;\n#endif\n\n    X509_NAME *name = X509_get_subject_name(peercertificate);\n\n    int current_entry = -1;\n    while (1) {\n\n        \/\/get the common name from the certificate\n        current_entry = X509_NAME_get_index_by_NID(name, NID_commonName, current_entry);\n        if (current_entry == -1) {\n            \/\/if we've run out of common names then move on to altnames\n            break;\n        }\n\n        \/\/X509_NAME_get_entry result must not be freed\n        X509_NAME_ENTRY *entry = X509_NAME_get_entry(name, current_entry);\n\n        ASN1_STRING *asn1name = X509_NAME_ENTRY_get_data(entry);\n\n        unsigned char *nameutf8;\n        int len = ASN1_STRING_to_UTF8(&nameutf8, asn1name);\n        if (len < 0) {\n            break;\n        }\n        String commonname = std::string((char *)nameutf8, len);\n\n        OPENSSL_free(nameutf8);\n\n        \/\/force to lower case as domain names are not case sensetive\n        commonname.toLower();\n\n#ifdef NETDEBUG\n        std::cout << thread_id << \"checking against common name \" << commonname << std::endl;\n#endif\n\n        \/\/compare the hostname to the common name\n        if (hostname.compare(commonname) == 0) {\n            matched = true;\n            break;\n        }\n        \/\/see if its a wildcard certificate\n        else if (commonname.startsWith(\"*.\")) {\n#ifdef NETDEBUG\n            std::cout << thread_id << \"Wildcard certificate is in use\" << std::endl;\n#endif\n            commonname = commonname.after(\"*\"); \/\/ need to keep the \".\"\n\n            if (hostname.endsWith(commonname)) {\n                matched = true;\n                break;\n            }\n        }\n    }\n\n    if (matched) {\n        X509_free(peercertificate);\n        return 0;\n    }\n#else  \/\/ is openssl v1.1 or above\n    return 0;    \/\/TODO\n#endif\n    return -1;\n}","target":0,"code_token_length":1263,"total_token_length":1499,"max_tokens_setting":2048}
+{"idx":343160,"func":"static int esp_init_authenc(struct xfrm_state *x)\n{\n\tstruct crypto_aead *aead;\n\tstruct crypto_authenc_key_param *param;\n\tstruct rtattr *rta;\n\tchar *key;\n\tchar *p;\n\tchar authenc_name[CRYPTO_MAX_ALG_NAME];\n\tunsigned int keylen;\n\tint err;\n\n\terr = -EINVAL;\n\tif (!x->ealg)\n\t\tgoto error;\n\n\terr = -ENAMETOOLONG;\n\n\tif ((x->props.flags & XFRM_STATE_ESN)) {\n\t\tif (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,\n\t\t\t     \"%s%sauthencesn(%s,%s)%s\",\n\t\t\t     x->geniv ?: \"\", x->geniv ? \"(\" : \"\",\n\t\t\t     x->aalg ? x->aalg->alg_name : \"digest_null\",\n\t\t\t     x->ealg->alg_name,\n\t\t\t     x->geniv ? \")\" : \"\") >= CRYPTO_MAX_ALG_NAME)\n\t\t\tgoto error;\n\t} else {\n\t\tif (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,\n\t\t\t     \"%s%sauthenc(%s,%s)%s\",\n\t\t\t     x->geniv ?: \"\", x->geniv ? \"(\" : \"\",\n\t\t\t     x->aalg ? x->aalg->alg_name : \"digest_null\",\n\t\t\t     x->ealg->alg_name,\n\t\t\t     x->geniv ? \")\" : \"\") >= CRYPTO_MAX_ALG_NAME)\n\t\t\tgoto error;\n\t}\n\n\taead = crypto_alloc_aead(authenc_name, 0, 0);\n\terr = PTR_ERR(aead);\n\tif (IS_ERR(aead))\n\t\tgoto error;\n\n\tx->data = aead;\n\n\tkeylen = (x->aalg ? (x->aalg->alg_key_len + 7) \/ 8 : 0) +\n\t\t (x->ealg->alg_key_len + 7) \/ 8 + RTA_SPACE(sizeof(*param));\n\terr = -ENOMEM;\n\tkey = kmalloc(keylen, GFP_KERNEL);\n\tif (!key)\n\t\tgoto error;\n\n\tp = key;\n\trta = (void *)p;\n\trta->rta_type = CRYPTO_AUTHENC_KEYA_PARAM;\n\trta->rta_len = RTA_LENGTH(sizeof(*param));\n\tparam = RTA_DATA(rta);\n\tp += RTA_SPACE(sizeof(*param));\n\n\tif (x->aalg) {\n\t\tstruct xfrm_algo_desc *aalg_desc;\n\n\t\tmemcpy(p, x->aalg->alg_key, (x->aalg->alg_key_len + 7) \/ 8);\n\t\tp += (x->aalg->alg_key_len + 7) \/ 8;\n\n\t\taalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0);\n\t\tBUG_ON(!aalg_desc);\n\n\t\terr = -EINVAL;\n\t\tif (aalg_desc->uinfo.auth.icv_fullbits \/ 8 !=\n\t\t    crypto_aead_authsize(aead)) {\n\t\t\tpr_info(\"ESP: %s digestsize %u != %u\\n\",\n\t\t\t\tx->aalg->alg_name,\n\t\t\t\tcrypto_aead_authsize(aead),\n\t\t\t\taalg_desc->uinfo.auth.icv_fullbits \/ 8);\n\t\t\tgoto free_key;\n\t\t}\n\n\t\terr = crypto_aead_setauthsize(\n\t\t\taead, x->aalg->alg_trunc_len \/ 8);\n\t\tif (err)\n\t\t\tgoto free_key;\n\t}\n\n\tparam->enckeylen = cpu_to_be32((x->ealg->alg_key_len + 7) \/ 8);\n\tmemcpy(p, x->ealg->alg_key, (x->ealg->alg_key_len + 7) \/ 8);\n\n\terr = crypto_aead_setkey(aead, key, keylen);\n\nfree_key:\n\tkfree(key);\n\nerror:\n\treturn err;\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048}
+{"idx":195242,"func":"  void Compute(OpKernelContext *ctx) override {\n    const Tensor *indices_t, *values_t, *shape_t, *dense_t;\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_indices\", &indices_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_values\", &values_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_shape\", &shape_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"dense\", &dense_t));\n\n    \/\/ Validations.\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices_t->shape()),\n                errors::InvalidArgument(\n                    \"Input sp_indices should be a matrix but received shape: \",\n                    indices_t->shape().DebugString()));\n    OP_REQUIRES(ctx,\n                TensorShapeUtils::IsVector(values_t->shape()) &&\n                    TensorShapeUtils::IsVector(shape_t->shape()),\n                errors::InvalidArgument(\n                    \"Inputs sp_values and sp_shape should be vectors \"\n                    \"but received shapes: \",\n                    values_t->shape().DebugString(), \" and \",\n                    shape_t->shape().DebugString()));\n    OP_REQUIRES(\n        ctx, values_t->dim_size(0) == indices_t->dim_size(0),\n        errors::InvalidArgument(\n            \"The first dimension of values and indices should match. (\",\n            values_t->dim_size(0), \" vs. \", indices_t->dim_size(0), \")\"));\n\n    const auto indices_mat = indices_t->matrix<int64_t>();\n    const auto shape_vec = shape_t->vec<int64_t>();\n    const auto lhs_dims = BCast::FromShape(TensorShape(shape_vec));\n    const auto rhs_dims = BCast::FromShape(dense_t->shape());\n    BCast b(lhs_dims, rhs_dims, false);  \/\/ false for keeping the same num dims.\n\n    \/\/ True iff (size(lhs) >= size(rhs)) and all dims in lhs is greater or equal\n    \/\/ to dims in rhs (from right to left).\n    auto VecGreaterEq = [](ArraySlice<int64_t> lhs, ArraySlice<int64_t> rhs) {\n      if (lhs.size() < rhs.size()) return false;\n      for (size_t i = 0; i < rhs.size(); ++i) {\n        if (lhs[lhs.size() - 1 - i] < rhs[rhs.size() - 1 - i]) return false;\n      }\n      return true;\n    };\n    OP_REQUIRES(ctx, VecGreaterEq(lhs_dims, rhs_dims) && b.IsValid(),\n                errors::InvalidArgument(\n                    \"SparseDenseBinaryOpShared broadcasts dense to sparse \"\n                    \"only; got incompatible shapes: [\",\n                    absl::StrJoin(lhs_dims, \",\"), \"] vs. [\",\n                    absl::StrJoin(rhs_dims, \",\"), \"]\"));\n\n    Tensor *output_values = nullptr;\n    Tensor dense_gathered;\n    const int64_t nnz = indices_t->dim_size(0);\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(0, TensorShape({nnz}), &output_values));\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_temp(DataTypeToEnum<T>::value, TensorShape({nnz}),\n                                &dense_gathered));\n    bool op_is_div = false;\n    if (absl::StrContains(ctx->op_kernel().type_string_view(), \"Div\")) {\n      op_is_div = true;\n    }\n    \/\/ Pulls relevant entries from the dense side, with reshape and broadcasting\n    \/\/ *of the dense side* taken into account.  Use a TensorRef to avoid blowing\n    \/\/ up memory.\n    \/\/\n    \/\/ We can directly use the sparse indices to look up dense side, because\n    \/\/ \"b.y_reshape()\" and \"b.y_bcast()\" are guaranteed to have rank \"ndims\".\n    auto dense_gathered_flat = dense_gathered.flat<T>();\n    const int ndims = lhs_dims.size();\n    switch (ndims) {\n#define CASE(NDIM)                                                             \\\n  case NDIM: {                                                                 \\\n    TensorRef<Eigen::Tensor<const T, NDIM, Eigen::RowMajor>> rhs_ref =         \\\n        dense_t->shaped<T, NDIM>(b.y_reshape())                                \\\n            .broadcast(BCast::ToIndexArray<NDIM>(b.y_bcast()));                \\\n    Eigen::array<Eigen::DenseIndex, NDIM> idx;                                 \\\n    bool indices_valid = true;                                                 \\\n    for (int i = 0; i < nnz; ++i) {                                            \\\n      for (int d = 0; d < NDIM; ++d) {                                         \\\n        idx[d] = internal::SubtleMustCopy(indices_mat(i, d));                  \\\n        if (!FastBoundsCheck(idx[d], rhs_ref.dimension(d))) {                  \\\n          indices_valid = false;                                               \\\n        }                                                                      \\\n      }                                                                        \\\n      OP_REQUIRES(                                                             \\\n          ctx, indices_valid,                                                  \\\n          errors::InvalidArgument(\"Provided indices are out-of-bounds w.r.t. \" \\\n                                  \"dense side with broadcasted shape\"));       \\\n      dense_gathered_flat(i) = rhs_ref.coeff(idx);                             \\\n      if (op_is_div) {                                                         \\\n        OP_REQUIRES(ctx, dense_gathered_flat(i) != 0,                          \\\n                    errors::InvalidArgument(                                   \\\n                        \"SparseDenseCwiseDiv cannot divide by zero,\"           \\\n                        \"but input dense tensor contains zero \"));             \\\n      }                                                                        \\\n    }                                                                          \\\n    break;                                                                     \\\n  }\n\n      CASE(1);\n      CASE(2);\n      CASE(3);\n      CASE(4);\n      CASE(5);\n      default:\n        OP_REQUIRES(\n            ctx, false,\n            errors::InvalidArgument(\"Only tensors with ranks between 1 and 5 \"\n                                    \"are currently supported.  Tensor rank: \",\n                                    ndims));\n#undef CASE\n    }\n\n    output_values->flat<T>().device(ctx->eigen_device<Device>()) =\n        values_t->flat<T>().binaryExpr(dense_gathered_flat,\n                                       typename Functor::func());\n  }","target":1,"code_token_length":1286,"total_token_length":1522,"max_tokens_setting":2048}
+{"idx":369264,"func":"static int io_read(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_rw_state __s, *s = &__s;\n\tstruct iovec *iovec;\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\tstruct io_async_rw *rw;\n\tssize_t ret, ret2;\n\tloff_t *ppos;\n\n\tif (!req_has_async_data(req)) {\n\t\tret = io_import_iovec(READ, req, &iovec, s, issue_flags);\n\t\tif (unlikely(ret < 0))\n\t\t\treturn ret;\n\t} else {\n\t\t\/*\n\t\t * Safe and required to re-import if we're using provided\n\t\t * buffers, as we dropped the selected one before retry.\n\t\t *\/\n\t\tif (req->flags & REQ_F_BUFFER_SELECT) {\n\t\t\tret = io_import_iovec(READ, req, &iovec, s, issue_flags);\n\t\t\tif (unlikely(ret < 0))\n\t\t\t\treturn ret;\n\t\t}\n\n\t\trw = req->async_data;\n\t\ts = &rw->s;\n\t\t\/*\n\t\t * We come here from an earlier attempt, restore our state to\n\t\t * match in case it doesn't. It's cheap enough that we don't\n\t\t * need to make this conditional.\n\t\t *\/\n\t\tiov_iter_restore(&s->iter, &s->iter_state);\n\t\tiovec = NULL;\n\t}\n\tret = io_rw_init_file(req, FMODE_READ);\n\tif (unlikely(ret)) {\n\t\tkfree(iovec);\n\t\treturn ret;\n\t}\n\treq->result = iov_iter_count(&s->iter);\n\n\tif (force_nonblock) {\n\t\t\/* If the file doesn't support async, just async punt *\/\n\t\tif (unlikely(!io_file_supports_nowait(req))) {\n\t\t\tret = io_setup_async_rw(req, iovec, s, true);\n\t\t\treturn ret ?: -EAGAIN;\n\t\t}\n\t\tkiocb->ki_flags |= IOCB_NOWAIT;\n\t} else {\n\t\t\/* Ensure we clear previously set non-block flag *\/\n\t\tkiocb->ki_flags &= ~IOCB_NOWAIT;\n\t}\n\n\tppos = io_kiocb_update_pos(req);\n\n\tret = rw_verify_area(READ, req->file, ppos, req->result);\n\tif (unlikely(ret)) {\n\t\tkfree(iovec);\n\t\treturn ret;\n\t}\n\n\tret = io_iter_do_read(req, &s->iter);\n\n\tif (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\t\/* if we can poll, just do that *\/\n\t\tif (req->opcode == IORING_OP_READ && file_can_poll(req->file))\n\t\t\treturn -EAGAIN;\n\t\t\/* IOPOLL retry should happen for io-wq threads *\/\n\t\tif (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\t\tgoto done;\n\t\t\/* no retry on NONBLOCK nor RWF_NOWAIT *\/\n\t\tif (req->flags & REQ_F_NOWAIT)\n\t\t\tgoto done;\n\t\tret = 0;\n\t} else if (ret == -EIOCBQUEUED) {\n\t\tgoto out_free;\n\t} else if (ret == req->result || ret <= 0 || !force_nonblock ||\n\t\t   (req->flags & REQ_F_NOWAIT) || !need_read_all(req)) {\n\t\t\/* read all, failed, already did sync or don't want to retry *\/\n\t\tgoto done;\n\t}\n\n\t\/*\n\t * Don't depend on the iter state matching what was consumed, or being\n\t * untouched in case of error. Restore it and we'll advance it\n\t * manually if we need to.\n\t *\/\n\tiov_iter_restore(&s->iter, &s->iter_state);\n\n\tret2 = io_setup_async_rw(req, iovec, s, true);\n\tif (ret2)\n\t\treturn ret2;\n\n\tiovec = NULL;\n\trw = req->async_data;\n\ts = &rw->s;\n\t\/*\n\t * Now use our persistent iterator and state, if we aren't already.\n\t * We've restored and mapped the iter to match.\n\t *\/\n\n\tdo {\n\t\t\/*\n\t\t * We end up here because of a partial read, either from\n\t\t * above or inside this loop. Advance the iter by the bytes\n\t\t * that were consumed.\n\t\t *\/\n\t\tiov_iter_advance(&s->iter, ret);\n\t\tif (!iov_iter_count(&s->iter))\n\t\t\tbreak;\n\t\trw->bytes_done += ret;\n\t\tiov_iter_save_state(&s->iter, &s->iter_state);\n\n\t\t\/* if we can retry, do so with the callbacks armed *\/\n\t\tif (!io_rw_should_retry(req)) {\n\t\t\tkiocb->ki_flags &= ~IOCB_WAITQ;\n\t\t\treturn -EAGAIN;\n\t\t}\n\n\t\t\/*\n\t\t * Now retry read with the IOCB_WAITQ parts set in the iocb. If\n\t\t * we get -EIOCBQUEUED, then we'll get a notification when the\n\t\t * desired page gets unlocked. We can also get a partial read\n\t\t * here, and if we do, then just retry at the new offset.\n\t\t *\/\n\t\tret = io_iter_do_read(req, &s->iter);\n\t\tif (ret == -EIOCBQUEUED)\n\t\t\treturn 0;\n\t\t\/* we got some bytes, but not all. retry. *\/\n\t\tkiocb->ki_flags &= ~IOCB_WAITQ;\n\t\tiov_iter_restore(&s->iter, &s->iter_state);\n\t} while (ret > 0);\ndone:\n\tkiocb_done(req, ret, issue_flags);\nout_free:\n\t\/* it's faster to check here then delegate to kfree *\/\n\tif (iovec)\n\t\tkfree(iovec);\n\treturn 0;\n}","target":0,"code_token_length":1246,"total_token_length":1482,"max_tokens_setting":2048}
+{"idx":217557,"func":"static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)\n{\n  char\n    *attribute,\n    format[MaxTextExtent],\n    name[MaxTextExtent],\n    *resource;\n\n  const StringInfo\n    *profile;\n\n  const unsigned char\n    *info;\n\n  long\n    start,\n    stop;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    i;\n\n  size_t\n    length;\n\n  ssize_t\n    count,\n    id,\n    sub_number;\n\n  \/*\n    There are no newlines in path names, so it's safe as terminator.\n  *\/\n  profile=GetImageProfile(image,\"8bim\");\n  if (profile == (StringInfo *) NULL)\n    return(MagickFalse);\n  count=(ssize_t) sscanf(key,\"8BIM:%ld,%ld:%1024[^\\n]\\n%1024[^\\n]\",&start,&stop,\n    name,format);\n  if ((count != 2) && (count != 3) && (count != 4))\n    return(MagickFalse);\n  if (count < 4)\n    (void) CopyMagickString(format,\"SVG\",MaxTextExtent);\n  if (count < 3)\n    *name='\\0';\n  sub_number=1;\n  if (*name == '#')\n    sub_number=(ssize_t) StringToLong(&name[1]);\n  sub_number=MagickMax(sub_number,1L);\n  resource=(char *) NULL;\n  status=MagickFalse;\n  length=GetStringInfoLength(profile);\n  info=GetStringInfoDatum(profile);\n  while ((length > 0) && (status == MagickFalse))\n  {\n    if (ReadPropertyByte(&info,&length) != (unsigned char) '8')\n      continue;\n    if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')\n      continue;\n    if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')\n      continue;\n    if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')\n      continue;\n    id=(ssize_t) ReadPropertyMSBShort(&info,&length);\n    if (id < (ssize_t) start)\n      continue;\n    if (id > (ssize_t) stop)\n      continue;\n    if (resource != (char *) NULL)\n      resource=DestroyString(resource);\n    count=(ssize_t) ReadPropertyByte(&info,&length);\n    if ((count != 0) && ((size_t) count <= length))\n      {\n        resource=(char *) NULL;\n        if (~((size_t) count) >= (MaxTextExtent-1))\n          resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,\n            sizeof(*resource));\n        if (resource != (char *) NULL)\n          {\n            for (i=0; i < (ssize_t) count; i++)\n              resource[i]=(char) ReadPropertyByte(&info,&length);\n            resource[count]='\\0';\n          }\n      }\n    if ((count & 0x01) == 0)\n      (void) ReadPropertyByte(&info,&length);\n    count=(ssize_t) ReadPropertyMSBLong(&info,&length);\n    if ((count < 0) || ((size_t) count > length))\n      {\n        length=0;\n        continue;\n      }\n    if ((*name != '\\0') && (*name != '#'))\n      if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))\n        {\n          \/*\n            No name match, scroll forward and try next.\n          *\/\n          info+=count;\n          length-=MagickMin(count,(ssize_t) length);\n          continue;\n        }\n    if ((*name == '#') && (sub_number != 1))\n      {\n        \/*\n          No numbered match, scroll forward and try next.\n        *\/\n        sub_number--;\n        info+=count;\n        length-=MagickMin(count,(ssize_t) length);\n        continue;\n      }\n    \/*\n      We have the resource of interest.\n    *\/\n    attribute=(char *) NULL;\n    if (~((size_t) count) >= (MaxTextExtent-1))\n      attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,\n        sizeof(*attribute));\n    if (attribute != (char *) NULL)\n      {\n        (void) memcpy(attribute,(char *) info,(size_t) count);\n        attribute[count]='\\0';\n        info+=count;\n        length-=MagickMin(count,(ssize_t) length);\n        if ((id <= 1999) || (id >= 2999))\n          (void) SetImageProperty((Image *) image,key,(const char *) attribute);\n        else\n          {\n            char\n              *path;\n\n            if (LocaleCompare(format,\"svg\") == 0)\n              path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,\n                image->columns,image->rows);\n            else\n              path=TracePSClippath((unsigned char *) attribute,(size_t) count,\n                image->columns,image->rows);\n            (void) SetImageProperty((Image *) image,key,(const char *) path);\n            path=DestroyString(path);\n          }\n        attribute=DestroyString(attribute);\n        status=MagickTrue;\n      }\n  }\n  if (resource != (char *) NULL)\n    resource=DestroyString(resource);\n  return(status);\n}","target":0,"code_token_length":1149,"total_token_length":1385,"max_tokens_setting":2048}
+{"idx":231733,"func":"TEST_F(QuicServerTransportTest, TestOpenAckStreamFrame) {\n  StreamId streamId = server->createBidirectionalStream().value();\n\n  auto data = IOBuf::copyBuffer(\"Aloha\");\n\n  \/\/ Remove any packets that might have been queued.\n  server->getNonConstConn().outstandings.packets.clear();\n  server->getNonConstConn().outstandings.initialPacketsCount = 0;\n  server->getNonConstConn().outstandings.handshakePacketsCount = 0;\n  server->writeChain(streamId, data->clone(), false);\n  loopForWrites();\n  server->writeChain(streamId, data->clone(), false);\n  server->writeChain(streamId, data->clone(), false);\n  loopForWrites();\n\n  auto stream = server->getNonConstConn().streamManager->getStream(streamId);\n  ASSERT_FALSE(server->getConn().outstandings.packets.empty());\n  ASSERT_FALSE(stream->retransmissionBuffer.empty());\n  \/\/ We need more than one packet for this test.\n  ASSERT_FALSE(server->getConn().outstandings.packets.empty());\n\n  PacketNum packetNum1 =\n      getFirstOutstandingPacket(\n          server->getNonConstConn(), PacketNumberSpace::AppData)\n          ->packet.header.getPacketSequenceNum();\n\n  PacketNum lastPacketNum =\n      getLastOutstandingPacket(\n          server->getNonConstConn(), PacketNumberSpace::AppData)\n          ->packet.header.getPacketSequenceNum();\n\n  uint32_t buffersInPacket1 = 0;\n  for (size_t i = 0; i < server->getNonConstConn().outstandings.packets.size();\n       ++i) {\n    auto& packet = server->getNonConstConn().outstandings.packets[i];\n    if (packet.packet.header.getPacketNumberSpace() !=\n        PacketNumberSpace::AppData) {\n      continue;\n    }\n    PacketNum currentPacket = packet.packet.header.getPacketSequenceNum();\n    ASSERT_FALSE(packet.packet.frames.empty());\n    for (auto& quicFrame : packet.packet.frames) {\n      auto frame = quicFrame.asWriteStreamFrame();\n      if (!frame) {\n        continue;\n      }\n      auto it = stream->retransmissionBuffer.find(frame->offset);\n      ASSERT_TRUE(it != stream->retransmissionBuffer.end());\n      if (currentPacket == packetNum1 && frame->streamId == streamId) {\n        buffersInPacket1++;\n      }\n    }\n  }\n\n  auto originalRetransSize = stream->retransmissionBuffer.size();\n  AckBlocks acks = {{packetNum1, packetNum1}};\n  auto packet1 = createAckPacket(\n      server->getNonConstConn(),\n      ++clientNextAppDataPacketNum,\n      acks,\n      PacketNumberSpace::AppData);\n  deliverData(packetToBuf(packet1));\n  EXPECT_EQ(\n      stream->retransmissionBuffer.size(),\n      originalRetransSize - buffersInPacket1);\n  EXPECT_EQ(stream->sendState, StreamSendState::Open);\n  EXPECT_EQ(stream->recvState, StreamRecvState::Open);\n\n  \/\/ Dup ack\n  auto packet2 = createAckPacket(\n      server->getNonConstConn(),\n      ++clientNextAppDataPacketNum,\n      acks,\n      PacketNumberSpace::AppData);\n  deliverData(packetToBuf(packet2));\n\n  EXPECT_EQ(\n      stream->retransmissionBuffer.size(),\n      originalRetransSize - buffersInPacket1);\n  EXPECT_EQ(stream->sendState, StreamSendState::Open);\n  EXPECT_EQ(stream->recvState, StreamRecvState::Open);\n\n  AckBlocks acks2 = {{packetNum1, lastPacketNum}};\n  auto packet3 = createAckPacket(\n      server->getNonConstConn(),\n      ++clientNextAppDataPacketNum,\n      acks2,\n      PacketNumberSpace::AppData);\n  deliverData(packetToBuf(packet3));\n\n  EXPECT_EQ(stream->retransmissionBuffer.size(), 0);\n  EXPECT_EQ(stream->sendState, StreamSendState::Open);\n  EXPECT_EQ(stream->recvState, StreamRecvState::Open);\n\n  auto empty = IOBuf::create(0);\n  server->writeChain(streamId, std::move(empty), true);\n  loopForWrites();\n  ASSERT_FALSE(server->getConn().outstandings.packets.empty());\n\n  PacketNum finPacketNum =\n      getFirstOutstandingPacket(\n          server->getNonConstConn(), PacketNumberSpace::AppData)\n          ->packet.header.getPacketSequenceNum();\n\n  AckBlocks acks3 = {{lastPacketNum, finPacketNum}};\n  auto packet4 = createAckPacket(\n      server->getNonConstConn(),\n      ++clientNextAppDataPacketNum,\n      acks3,\n      PacketNumberSpace::AppData);\n  deliverData(packetToBuf(packet4));\n  EXPECT_EQ(stream->sendState, StreamSendState::Closed);\n  EXPECT_EQ(stream->recvState, StreamRecvState::Open);\n}","target":0,"code_token_length":1032,"total_token_length":1268,"max_tokens_setting":2048}
+{"idx":245159,"func":"write_xtrabackup_info(MYSQL *connection)\n{\n\tMYSQL_STMT *stmt;\n\tMYSQL_BIND bind[19];\n\tconst char *uuid = NULL;\n\tchar *server_version = NULL;\n\tchar* xtrabackup_info_data = NULL;\n\tint idx;\n\tmy_bool null = TRUE;\n\n\tconst char *ins_query = \"insert into PERCONA_SCHEMA.xtrabackup_history(\"\n\t\t\"uuid, name, tool_name, tool_command, tool_version, \"\n\t\t\"ibbackup_version, server_version, start_time, end_time, \"\n\t\t\"lock_time, binlog_pos, innodb_from_lsn, innodb_to_lsn, \"\n\t\t\"partial, incremental, format, compact, compressed, \"\n\t\t\"encrypted) \"\n\t\t\"values(?,?,?,?,?,?,?,from_unixtime(?),from_unixtime(?),\"\n\t\t\"?,?,?,?,?,?,?,?,?,?)\";\n\n\tut_ad((uint)xtrabackup_stream_fmt <\n\t\tarray_elements(xb_stream_format_name));\n\tconst char *stream_format_name =\n\t\txb_stream_format_name[xtrabackup_stream_fmt];\n\thistory_end_time = time(NULL);\n\n\txtrabackup_info_data = get_xtrabackup_info(connection);\n\tif (!backup_file_printf(XTRABACKUP_INFO, \"%s\", xtrabackup_info_data)) {\n\t\tgoto cleanup;\n\t}\n\n\tif (!opt_history) {\n\t\tgoto cleanup;\n\t}\n\n\tuuid = get_backup_uuid(connection);\n\tserver_version = read_mysql_one_value(connection, \"SELECT VERSION()\");\n\n\txb_mysql_query(connection,\n\t\t\"CREATE DATABASE IF NOT EXISTS PERCONA_SCHEMA\", false);\n\txb_mysql_query(connection,\n\t\t\"CREATE TABLE IF NOT EXISTS PERCONA_SCHEMA.xtrabackup_history(\"\n\t\t\"uuid VARCHAR(40) NOT NULL PRIMARY KEY,\"\n\t\t\"name VARCHAR(255) DEFAULT NULL,\"\n\t\t\"tool_name VARCHAR(255) DEFAULT NULL,\"\n\t\t\"tool_command TEXT DEFAULT NULL,\"\n\t\t\"tool_version VARCHAR(255) DEFAULT NULL,\"\n\t\t\"ibbackup_version VARCHAR(255) DEFAULT NULL,\"\n\t\t\"server_version VARCHAR(255) DEFAULT NULL,\"\n\t\t\"start_time TIMESTAMP NULL DEFAULT NULL,\"\n\t\t\"end_time TIMESTAMP NULL DEFAULT NULL,\"\n\t\t\"lock_time BIGINT UNSIGNED DEFAULT NULL,\"\n\t\t\"binlog_pos TEXT DEFAULT NULL,\"\n\t\t\"innodb_from_lsn BIGINT UNSIGNED DEFAULT NULL,\"\n\t\t\"innodb_to_lsn BIGINT UNSIGNED DEFAULT NULL,\"\n\t\t\"partial ENUM('Y', 'N') DEFAULT NULL,\"\n\t\t\"incremental ENUM('Y', 'N') DEFAULT NULL,\"\n\t\t\"format ENUM('file', 'tar', 'xbstream') DEFAULT NULL,\"\n\t\t\"compact ENUM('Y', 'N') DEFAULT NULL,\"\n\t\t\"compressed ENUM('Y', 'N') DEFAULT NULL,\"\n\t\t\"encrypted ENUM('Y', 'N') DEFAULT NULL\"\n\t\t\") CHARACTER SET utf8 ENGINE=innodb\", false);\n\n\t\/* Upgrade from previous versions *\/\n\txb_mysql_query(connection,\n\t\t\"ALTER TABLE PERCONA_SCHEMA.xtrabackup_history MODIFY COLUMN \"\n\t\t\"binlog_pos TEXT DEFAULT NULL\", false);\n\n\tstmt = mysql_stmt_init(connection);\n\n\tmysql_stmt_prepare(stmt, ins_query, strlen(ins_query));\n\n\tmemset(bind, 0, sizeof(bind));\n\tidx = 0;\n\n\t\/* uuid *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)uuid;\n\tbind[idx].buffer_length = strlen(uuid);\n\t++idx;\n\n\t\/* name *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(opt_history);\n\tbind[idx].buffer_length = strlen(opt_history);\n\tif (!(opt_history && *opt_history)) {\n\t\tbind[idx].is_null = &null;\n\t}\n\t++idx;\n\n\t\/* tool_name *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = tool_name;\n\tbind[idx].buffer_length = strlen(tool_name);\n\t++idx;\n\n\t\/* tool_command *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = tool_args;\n\tbind[idx].buffer_length = strlen(tool_args);\n\t++idx;\n\n\t\/* tool_version *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(XTRABACKUP_VERSION);\n\tbind[idx].buffer_length = strlen(XTRABACKUP_VERSION);\n\t++idx;\n\n\t\/* ibbackup_version *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(XTRABACKUP_VERSION);\n\tbind[idx].buffer_length = strlen(XTRABACKUP_VERSION);\n\t++idx;\n\n\t\/* server_version *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = server_version;\n\tbind[idx].buffer_length = strlen(server_version);\n\t++idx;\n\n\t\/* start_time *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_LONG;\n\tbind[idx].buffer = &history_start_time;\n\t++idx;\n\n\t\/* end_time *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_LONG;\n\tbind[idx].buffer = &history_end_time;\n\t++idx;\n\n\t\/* lock_time *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_LONG;\n\tbind[idx].buffer = &history_lock_time;\n\t++idx;\n\n\t\/* binlog_pos *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = mysql_binlog_position;\n\tif (mysql_binlog_position != NULL) {\n\t\tbind[idx].buffer_length = strlen(mysql_binlog_position);\n\t} else {\n\t\tbind[idx].is_null = &null;\n\t}\n\t++idx;\n\n\t\/* innodb_from_lsn *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_LONGLONG;\n\tbind[idx].buffer = (char*)(&incremental_lsn);\n\t++idx;\n\n\t\/* innodb_to_lsn *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_LONGLONG;\n\tbind[idx].buffer = (char*)(&metadata_to_lsn);\n\t++idx;\n\n\t\/* partial (Y | N) *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)((xtrabackup_tables\n\t\t\t\t    || xtrabackup_tables_exclude\n\t\t\t\t    || xtrabackup_tables_file\n\t\t\t\t    || xtrabackup_databases\n\t\t\t\t    || xtrabackup_databases_exclude\n\t\t\t\t    || xtrabackup_databases_file) ? \"Y\" : \"N\");\n\tbind[idx].buffer_length = 1;\n\t++idx;\n\n\t\/* incremental (Y | N) *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(\n\t\t(xtrabackup_incremental\n\t\t || xtrabackup_incremental_basedir\n\t\t || opt_incremental_history_name\n\t\t || opt_incremental_history_uuid) ? \"Y\" : \"N\");\n\tbind[idx].buffer_length = 1;\n\t++idx;\n\n\t\/* format (file | tar | xbstream) *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(stream_format_name);\n\tbind[idx].buffer_length = strlen(stream_format_name);\n\t++idx;\n\n\t\/* compact (Y | N) *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(xtrabackup_compact ? \"Y\" : \"N\");\n\tbind[idx].buffer_length = 1;\n\t++idx;\n\n\t\/* compressed (Y | N) *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(xtrabackup_compress ? \"Y\" : \"N\");\n\tbind[idx].buffer_length = 1;\n\t++idx;\n\n\t\/* encrypted (Y | N) *\/\n\tbind[idx].buffer_type = MYSQL_TYPE_STRING;\n\tbind[idx].buffer = (char*)(xtrabackup_encrypt ? \"Y\" : \"N\");\n\tbind[idx].buffer_length = 1;\n\t++idx;\n\n\tut_ad(idx == 19);\n\n\tmysql_stmt_bind_param(stmt, bind);\n\n\tmysql_stmt_execute(stmt);\n\tmysql_stmt_close(stmt);\n\ncleanup:\n\n\tfree(xtrabackup_info_data);\n\tfree(server_version);\n\n\treturn(true);\n}","target":0,"code_token_length":1746,"total_token_length":1982,"max_tokens_setting":2048}
+{"idx":390565,"func":"_XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff)\n{\n    XkbDescRec\t\t*xkb;\n    XkbNamesRec\t\t*names;\n    CARD32\t\t*tmp;\n    xkbNamesNotify\t nn;\n\n    tmp = (CARD32 *)&stuff[1];\n    xkb = dev->key->xkbInfo->desc;\n    names = xkb->names;\n\n    if (XkbAllocNames(xkb,stuff->which,stuff->nRadioGroups,\n                stuff->nKeyAliases)!=Success) {\n        return BadAlloc;\n    }\n\n    bzero(&nn,sizeof(xkbNamesNotify));\n    nn.changed= stuff->which;\n    tmp = (CARD32 *)&stuff[1];\n    if (stuff->which&XkbKeycodesNameMask)\n        names->keycodes= *tmp++;\n    if (stuff->which&XkbGeometryNameMask)\n        names->geometry= *tmp++;\n    if (stuff->which&XkbSymbolsNameMask)\n        names->symbols= *tmp++;\n    if (stuff->which&XkbPhysSymbolsNameMask)\n        names->phys_symbols= *tmp++;\n    if (stuff->which&XkbTypesNameMask)\n        names->types= *tmp++;\n    if (stuff->which&XkbCompatNameMask)\n        names->compat= *tmp++;\n    if ((stuff->which&XkbKeyTypeNamesMask)&&(stuff->nTypes>0)) {\n        register unsigned i;\n        register XkbKeyTypePtr type;\n\n        type= &xkb->map->types[stuff->firstType];\n        for (i=0;i<stuff->nTypes;i++,type++) {\n            type->name= *tmp++;\n        }\n        nn.firstType= stuff->firstType;\n        nn.nTypes= stuff->nTypes;\n    }\n    if (stuff->which&XkbKTLevelNamesMask) {\n        register XkbKeyTypePtr\ttype;\n        register unsigned i;\n        CARD8 *width;\n\n        width = (CARD8 *)tmp;\n        tmp= (CARD32 *)(((char *)tmp)+XkbPaddedSize(stuff->nKTLevels));\n        type= &xkb->map->types[stuff->firstKTLevel];\n        for (i=0;i<stuff->nKTLevels;i++,type++) {\n            if (width[i]>0) {\n                if (type->level_names) {\n                    register unsigned n;\n                    for (n=0;n<width[i];n++) {\n                        type->level_names[n]= tmp[n];\n                    }\n                }\n                tmp+= width[i];\n            }\n        }\n        nn.firstLevelName= 0;\n        nn.nLevelNames= stuff->nTypes;\n    }\n    if (stuff->which&XkbIndicatorNamesMask) {\n        tmp= _XkbCopyMaskedAtoms(tmp,names->indicators,XkbNumIndicators,\n                stuff->indicators);\n        nn.changedIndicators= stuff->indicators;\n    }\n    if (stuff->which&XkbVirtualModNamesMask) {\n        tmp= _XkbCopyMaskedAtoms(tmp,names->vmods,XkbNumVirtualMods,\n                stuff->virtualMods);\n        nn.changedVirtualMods= stuff->virtualMods;\n    }\n    if (stuff->which&XkbGroupNamesMask) {\n        tmp= _XkbCopyMaskedAtoms(tmp,names->groups,XkbNumKbdGroups,\n                stuff->groupNames);\n        nn.changedVirtualMods= stuff->groupNames;\n    }\n    if (stuff->which&XkbKeyNamesMask) {\n        memcpy((char*)&names->keys[stuff->firstKey],(char *)tmp,\n                stuff->nKeys*XkbKeyNameLength);\n        tmp+= stuff->nKeys;\n        nn.firstKey= stuff->firstKey;\n        nn.nKeys= stuff->nKeys;\n    }\n    if (stuff->which&XkbKeyAliasesMask) {\n        if (stuff->nKeyAliases>0) {\n            register int na= stuff->nKeyAliases;\t\n            if (XkbAllocNames(xkb,XkbKeyAliasesMask,0,na)!=Success)\n                return BadAlloc;\n            memcpy((char *)names->key_aliases,(char *)tmp,\n                    stuff->nKeyAliases*sizeof(XkbKeyAliasRec));\n            tmp+= stuff->nKeyAliases*2;\n        }\n        else if (names->key_aliases!=NULL) {\n            _XkbFree(names->key_aliases);\n            names->key_aliases= NULL;\n            names->num_key_aliases= 0;\n        }\n        nn.nAliases= names->num_key_aliases;\n    }\n    if (stuff->which&XkbRGNamesMask) {\n        if (stuff->nRadioGroups>0) {\n            register unsigned i,nrg;\n            nrg= stuff->nRadioGroups;\n            if (XkbAllocNames(xkb,XkbRGNamesMask,nrg,0)!=Success)\n                return BadAlloc;\n\n            for (i=0;i<stuff->nRadioGroups;i++) {\n                names->radio_groups[i]= tmp[i];\n            }\n            tmp+= stuff->nRadioGroups;\n        }\n        else if (names->radio_groups) {\n            _XkbFree(names->radio_groups);\n            names->radio_groups= NULL;\n            names->num_rg= 0;\n        }\n        nn.nRadioGroups= names->num_rg;\n    }\n    if (nn.changed) {\n        Bool needExtEvent;\n        needExtEvent= (nn.changed&XkbIndicatorNamesMask)!=0;\n        XkbSendNamesNotify(dev,&nn);\n        if (needExtEvent) {\n            XkbSrvLedInfoPtr\t\tsli;\n            xkbExtensionDeviceNotify\tedev;\n            register int\t\ti;\n            register unsigned\t\tbit;\n\n            sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,\n                    XkbXI_IndicatorsMask);\n            sli->namesPresent= 0;\n            for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {\n                if (names->indicators[i]!=None)\n                    sli->namesPresent|= bit;\n            }\n            bzero(&edev,sizeof(xkbExtensionDeviceNotify));\n            edev.reason=\tXkbXI_IndicatorNamesMask;\n            edev.ledClass=\tKbdFeedbackClass;\n            edev.ledID=\t\tdev->kbdfeed->ctrl.id;\n            edev.ledsDefined= \tsli->namesPresent|sli->mapsPresent;\n            edev.ledState=\tsli->effectiveState;\n            edev.firstBtn=\t0;\n            edev.nBtns=\t\t0;\n            edev.supported=\tXkbXI_AllFeaturesMask;\n            edev.unsupported=\t0;\n            XkbSendExtensionDeviceNotify(dev,client,&edev);\n        }\n    }\n    return Success;\n}","target":0,"code_token_length":1459,"total_token_length":1695,"max_tokens_setting":2048}
+{"idx":249983,"func":"static GF_Err WriteInterleaved(MovieWriter *mw, GF_BitStream *bs, Bool drift_inter)\n{\n\tGF_Err e;\n\tu32 i;\n\ts32 moov_meta_pos=-1;\n\tGF_Box *a, *cprt_box=NULL;\n\tu64 firstSize, finalSize, offset, finalOffset;\n\tGF_List *writers = gf_list_new();\n\tGF_ISOFile *movie = mw->movie;\n\n\t\/\/first setup the writers\n\te = SetupWriters(mw, writers, 1);\n\tif (e) goto exit;\n\n\n\tif (movie->is_jp2) {\n\t\tgf_bs_write_u32(bs, 12);\n\t\tgf_bs_write_u32(bs, GF_ISOM_BOX_TYPE_JP);\n\t\tgf_bs_write_u32(bs, 0x0D0A870A);\n\t}\n\tif (movie->brand) {\n\t\te = gf_isom_box_size((GF_Box *)movie->brand);\n\t\tif (e) goto exit;\n\t\te = gf_isom_box_write((GF_Box *)movie->brand, bs);\n\t\tif (e) goto exit;\n\t}\n\tif (movie->pdin) {\n\t\te = gf_isom_box_size((GF_Box *)movie->pdin);\n\t\tif (e) goto exit;\n\t\te = gf_isom_box_write((GF_Box *)movie->pdin, bs);\n\t\tif (e) goto exit;\n\t}\n\n\t\/\/write all boxes before moov\n\ti=0;\n\twhile ((a = (GF_Box*)gf_list_enum(movie->TopBoxes, &i))) {\n\t\tswitch (a->type) {\n\t\tcase GF_ISOM_BOX_TYPE_MOOV:\n\t\tcase GF_ISOM_BOX_TYPE_META:\n\t\t\tmoov_meta_pos = i-1;\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_FTYP:\n\t\tcase GF_ISOM_BOX_TYPE_PDIN:\n\t\tcase GF_ISOM_BOX_TYPE_MDAT:\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_FREE:\n\t\t\t\/\/for backward compat with old arch, keep copyright before moov\n\t\t\tif (((GF_FreeSpaceBox*)a)->dataSize>4) {\n\t\t\t\tGF_FreeSpaceBox *fr = (GF_FreeSpaceBox*) a;\n\t\t\t\tif ((fr->dataSize>20) && !strncmp(fr->data, \"IsoMedia File\", 13)) {\n\t\t\t\t\tcprt_box = a;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\tif (moov_meta_pos<0) {\n\t\t\t\te = gf_isom_box_size(a);\n\t\t\t\tif (e) goto exit;\n\t\t\t\te = gf_isom_box_write(a, bs);\n\t\t\t\tif (e) goto exit;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\te = DoInterleave(mw, writers, bs, 1, gf_bs_get_position(bs), drift_inter);\n\tif (e) goto exit;\n\n\tfirstSize = GetMoovAndMetaSize(movie, writers);\n\toffset = firstSize;\n\tif (movie->mdat && movie->mdat->dataSize) offset += 8 + (movie->mdat->dataSize > 0xFFFFFFFF ? 8 : 0);\n\te = ShiftOffset(movie, writers, offset);\n\tif (e) goto exit;\n\t\/\/get the size and see if it has changed (eg, we moved to 64 bit offsets)\n\tfinalSize = GetMoovAndMetaSize(movie, writers);\n\tif (firstSize != finalSize) {\n\t\tfinalOffset = finalSize;\n\t\tif (movie->mdat && movie->mdat->dataSize) finalOffset += 8 + (movie->mdat->dataSize > 0xFFFFFFFF ? 8 : 0);\n\t\t\/\/OK, now we're sure about the final size -> shift the offsets\n\t\t\/\/we don't need to re-emulate, as the only thing that changed is the offset\n\t\t\/\/so just shift the offset\n\t\te = ShiftOffset(movie, writers, finalOffset - offset);\n\t\tif (e) goto exit;\n\t\t\/*firstSize = *\/GetMoovAndMetaSize(movie, writers);\n\t}\n\t\/\/get real sample offsets for meta items\n\tif (movie->meta) {\n\t\tstore_meta_item_sample_ref_offsets(movie, writers, movie->meta);\n\t}\n\t\/\/now write our stuff\n\te = WriteMoovAndMeta(movie, writers, bs);\n\tif (e) goto exit;\n\n\t\/*we have 8 extra bytes for large size (not computed in gf_isom_box_size) *\/\n\tif (movie->mdat && movie->mdat->dataSize) {\n\t\tif (movie->mdat->dataSize > 0xFFFFFFFF) movie->mdat->dataSize += 8;\n\t\te = gf_isom_box_size((GF_Box *)movie->mdat);\n\t\tif (e) goto exit;\n\t\te = gf_isom_box_write((GF_Box *)movie->mdat, bs);\n\t\tif (e) goto exit;\n\t}\n\n\t\/\/we don't need the offset as we are writing...\n\tResetWriters(writers);\n\te = DoInterleave(mw, writers, bs, 0, 0, drift_inter);\n\tif (e) goto exit;\n\n\t\/\/then the rest\n\ti=0;\n\twhile ((a = (GF_Box*)gf_list_enum(movie->TopBoxes, &i))) {\n\t\tif ((i-1 < (u32) moov_meta_pos) && (a != cprt_box))\n\t\t\tcontinue;\n\t\tswitch (a->type) {\n\t\tcase GF_ISOM_BOX_TYPE_MOOV:\n\t\tcase GF_ISOM_BOX_TYPE_META:\n\t\tcase GF_ISOM_BOX_TYPE_FTYP:\n\t\tcase GF_ISOM_BOX_TYPE_PDIN:\n\t\tcase GF_ISOM_BOX_TYPE_MDAT:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\te = gf_isom_box_size(a);\n\t\t\tif (e) goto exit;\n\t\t\te = gf_isom_box_write(a, bs);\n\t\t\tif (e) goto exit;\n\t\t}\n\t}\n\nexit:\n\tCleanWriters(writers);\n\tgf_list_del(writers);\n\treturn e;\n}","target":0,"code_token_length":1265,"total_token_length":1501,"max_tokens_setting":2048}
+{"idx":224573,"func":"Status DepthwiseConv2DNativeShapeImpl(shape_inference::InferenceContext* c,\n                                      bool supports_explicit_padding) {\n  ShapeHandle input_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 4, &input_shape));\n  ShapeHandle filter_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 4, &filter_shape));\n\n  std::vector<int32> strides;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"strides\", &strides));\n\n  if (strides.size() != 4) {\n    return errors::InvalidArgument(\n        \"DepthwiseConv2D requires the stride attribute to contain 4 values, \"\n        \"but got: \",\n        strides.size());\n  }\n\n  std::vector<int32> dilations;\n  if (!c->GetAttr(\"dilations\", &dilations).ok()) {\n    dilations.resize(4, 1);\n  }\n\n  if (dilations.size() != 4) {\n    return errors::InvalidArgument(\n        \"DepthwiseConv2D requires the dilations attribute to contain 4 values, \"\n        \"but got: \",\n        dilations.size());\n  }\n\n  string data_format_str;\n  Status s = c->GetAttr(\"data_format\", &data_format_str);\n  TensorFormat data_format;\n  if (!s.ok() || !FormatFromString(data_format_str, &data_format)) {\n    data_format = FORMAT_NHWC;\n  }\n  int32_t stride_rows;\n  int32_t stride_cols;\n  int32_t dilation_rows;\n  int32_t dilation_cols;\n  if (data_format == FORMAT_NCHW) {\n    \/\/ Canonicalize input shape to NHWC so the shape inference code below can\n    \/\/ process it.\n    input_shape =\n        c->MakeShape({{c->Dim(input_shape, 0), c->Dim(input_shape, 2),\n                       c->Dim(input_shape, 3), c->Dim(input_shape, 1)}});\n    stride_rows = strides[2];\n    stride_cols = strides[3];\n    dilation_rows = dilations[2];\n    dilation_cols = dilations[3];\n  } else {\n    stride_rows = strides[1];\n    stride_cols = strides[2];\n    dilation_rows = dilations[1];\n    dilation_cols = dilations[2];\n  }\n\n  DimensionHandle batch_size_dim = c->Dim(input_shape, 0);\n  DimensionHandle in_rows_dim = c->Dim(input_shape, 1);\n  DimensionHandle in_cols_dim = c->Dim(input_shape, 2);\n\n  DimensionHandle filter_rows_dim = c->Dim(filter_shape, 0);\n  DimensionHandle filter_cols_dim = c->Dim(filter_shape, 1);\n  DimensionHandle input_depth = c->Dim(filter_shape, 2);\n  DimensionHandle depth_multiplier = c->Dim(filter_shape, 3);\n\n  \/\/ Check that the input depths are compatible.\n  TF_RETURN_IF_ERROR(\n      c->Merge(c->Dim(input_shape, 3), input_depth, &input_depth));\n\n  DimensionHandle output_depth;\n  TF_RETURN_IF_ERROR(c->Multiply(input_depth, depth_multiplier, &output_depth));\n\n  Padding padding;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"padding\", &padding));\n\n  std::vector<int64_t> explicit_paddings;\n  if (supports_explicit_padding) {\n    Status status = c->GetAttr(\"explicit_paddings\", &explicit_paddings);\n    \/\/ Use the default value, which is an empty list, if the attribute is not\n    \/\/ found. Otherwise return the error to the caller.\n    if (!status.ok() && !errors::IsNotFound(status)) {\n      return status;\n    }\n    TF_RETURN_IF_ERROR(CheckValidPadding(padding, explicit_paddings,\n                                         \/*num_dims=*\/4, data_format));\n  } else {\n    DCHECK(padding != Padding::EXPLICIT);\n  }\n\n  \/\/ TODO(mrry,shlens): Raise an error if the stride would cause\n  \/\/ information in the input to be ignored. This will require a change\n  \/\/ in the kernel implementation.\n  DimensionHandle output_rows, output_cols;\n  int64_t pad_rows_before = -1, pad_rows_after = -1;\n  int64_t pad_cols_before = -1, pad_cols_after = -1;\n  if (padding == Padding::EXPLICIT) {\n    GetExplicitPaddingForDim(explicit_paddings, data_format, 'H',\n                             &pad_rows_before, &pad_rows_after);\n    GetExplicitPaddingForDim(explicit_paddings, data_format, 'W',\n                             &pad_cols_before, &pad_cols_after);\n  }\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n      c, in_rows_dim, filter_rows_dim, dilation_rows, stride_rows, padding,\n      pad_rows_before, pad_rows_after, &output_rows));\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n      c, in_cols_dim, filter_cols_dim, dilation_cols, stride_cols, padding,\n      pad_cols_before, pad_cols_after, &output_cols));\n\n  ShapeHandle output_shape;\n  if (data_format == FORMAT_NCHW) {\n    output_shape =\n        c->MakeShape({batch_size_dim, output_depth, output_rows, output_cols});\n  } else {\n    output_shape =\n        c->MakeShape({batch_size_dim, output_rows, output_cols, output_depth});\n  }\n  c->set_output(0, output_shape);\n  return Status::OK();\n}","target":0,"code_token_length":1170,"total_token_length":1406,"max_tokens_setting":2048}
+{"idx":215262,"func":"static void gem_transmit(CadenceGEMState *s)\n{\n    uint32_t desc[DESC_MAX_NUM_WORDS];\n    hwaddr packet_desc_addr;\n    uint8_t     *p;\n    unsigned    total_bytes;\n    int q = 0;\n\n    \/* Do nothing if transmit is not enabled. *\/\n    if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) {\n        return;\n    }\n\n    DB_PRINT(\"\\n\");\n\n    \/* The packet we will hand off to QEMU.\n     * Packets scattered across multiple descriptors are gathered to this\n     * one contiguous buffer first.\n     *\/\n    p = s->tx_packet;\n    total_bytes = 0;\n\n    for (q = s->num_priority_queues - 1; q >= 0; q--) {\n        \/* read current descriptor *\/\n        packet_desc_addr = gem_get_tx_desc_addr(s, q);\n\n        DB_PRINT(\"read descriptor 0x%\" HWADDR_PRIx \"\\n\", packet_desc_addr);\n        address_space_read(&s->dma_as, packet_desc_addr,\n                           MEMTXATTRS_UNSPECIFIED, desc,\n                           sizeof(uint32_t) * gem_get_desc_len(s, false));\n        \/* Handle all descriptors owned by hardware *\/\n        while (tx_desc_get_used(desc) == 0) {\n\n            \/* Do nothing if transmit is not enabled. *\/\n            if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) {\n                return;\n            }\n            print_gem_tx_desc(desc, q);\n\n            \/* The real hardware would eat this (and possibly crash).\n             * For QEMU let's lend a helping hand.\n             *\/\n            if ((tx_desc_get_buffer(s, desc) == 0) ||\n                (tx_desc_get_length(desc) == 0)) {\n                DB_PRINT(\"Invalid TX descriptor @ 0x%\" HWADDR_PRIx \"\\n\",\n                         packet_desc_addr);\n                break;\n            }\n\n            if (tx_desc_get_length(desc) > gem_get_max_buf_len(s, true) -\n                                               (p - s->tx_packet)) {\n                qemu_log_mask(LOG_GUEST_ERROR, \"TX descriptor @ 0x%\" \\\n                         HWADDR_PRIx \" too large: size 0x%x space 0x%zx\\n\",\n                         packet_desc_addr, tx_desc_get_length(desc),\n                         gem_get_max_buf_len(s, true) - (p - s->tx_packet));\n                gem_set_isr(s, q, GEM_INT_AMBA_ERR);\n                break;\n            }\n\n            \/* Gather this fragment of the packet from \"dma memory\" to our\n             * contig buffer.\n             *\/\n            address_space_read(&s->dma_as, tx_desc_get_buffer(s, desc),\n                               MEMTXATTRS_UNSPECIFIED,\n                               p, tx_desc_get_length(desc));\n            p += tx_desc_get_length(desc);\n            total_bytes += tx_desc_get_length(desc);\n\n            \/* Last descriptor for this packet; hand the whole thing off *\/\n            if (tx_desc_get_last(desc)) {\n                uint32_t desc_first[DESC_MAX_NUM_WORDS];\n                hwaddr desc_addr = gem_get_tx_desc_addr(s, q);\n\n                \/* Modify the 1st descriptor of this packet to be owned by\n                 * the processor.\n                 *\/\n                address_space_read(&s->dma_as, desc_addr,\n                                   MEMTXATTRS_UNSPECIFIED, desc_first,\n                                   sizeof(desc_first));\n                tx_desc_set_used(desc_first);\n                address_space_write(&s->dma_as, desc_addr,\n                                    MEMTXATTRS_UNSPECIFIED, desc_first,\n                                    sizeof(desc_first));\n                \/* Advance the hardware current descriptor past this packet *\/\n                if (tx_desc_get_wrap(desc)) {\n                    s->tx_desc_addr[q] = gem_get_tx_queue_base_addr(s, q);\n                } else {\n                    s->tx_desc_addr[q] = packet_desc_addr +\n                                         4 * gem_get_desc_len(s, false);\n                }\n                DB_PRINT(\"TX descriptor next: 0x%08x\\n\", s->tx_desc_addr[q]);\n\n                s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL;\n                gem_set_isr(s, q, GEM_INT_TXCMPL);\n\n                \/* Handle interrupt consequences *\/\n                gem_update_int_status(s);\n\n                \/* Is checksum offload enabled? *\/\n                if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) {\n                    net_checksum_calculate(s->tx_packet, total_bytes, CSUM_ALL);\n                }\n\n                \/* Update MAC statistics *\/\n                gem_transmit_updatestats(s, s->tx_packet, total_bytes);\n\n                \/* Send the packet somewhere *\/\n                if (s->phy_loop || (s->regs[GEM_NWCTRL] &\n                                    GEM_NWCTRL_LOCALLOOP)) {\n                    gem_receive(qemu_get_queue(s->nic), s->tx_packet,\n                                total_bytes);\n                } else {\n                    qemu_send_packet(qemu_get_queue(s->nic), s->tx_packet,\n                                     total_bytes);\n                }\n\n                \/* Prepare for next packet *\/\n                p = s->tx_packet;\n                total_bytes = 0;\n            }\n\n            \/* read next descriptor *\/\n            if (tx_desc_get_wrap(desc)) {\n\n                if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) {\n                    packet_desc_addr = s->regs[GEM_TBQPH];\n                    packet_desc_addr <<= 32;\n                } else {\n                    packet_desc_addr = 0;\n                }\n                packet_desc_addr |= gem_get_tx_queue_base_addr(s, q);\n            } else {\n                packet_desc_addr += 4 * gem_get_desc_len(s, false);\n            }\n            DB_PRINT(\"read descriptor 0x%\" HWADDR_PRIx \"\\n\", packet_desc_addr);\n            address_space_read(&s->dma_as, packet_desc_addr,\n                               MEMTXATTRS_UNSPECIFIED, desc,\n                               sizeof(uint32_t) * gem_get_desc_len(s, false));\n        }\n\n        if (tx_desc_get_used(desc)) {\n            s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED;\n            \/* IRQ TXUSED is defined only for queue 0 *\/\n            if (q == 0) {\n                gem_set_isr(s, 0, GEM_INT_TXUSED);\n            }\n            gem_update_int_status(s);\n        }\n    }\n}","target":1,"code_token_length":1328,"total_token_length":1564,"max_tokens_setting":2048}
+{"idx":195218,"func":"gen_assignment(codegen_scope *s, node *tree, node *rhs, int sp, int val)\n{\n  int idx;\n  int type = nint(tree->car);\n\n  switch (type) {\n  case NODE_GVAR:\n  case NODE_ARG:\n  case NODE_LVAR:\n  case NODE_IVAR:\n  case NODE_CVAR:\n  case NODE_CONST:\n  case NODE_NIL:\n  case NODE_MASGN:\n    if (rhs) {\n      codegen(s, rhs, VAL);\n      pop();\n      sp = cursp();\n    }\n    break;\n\n  case NODE_COLON2:\n  case NODE_CALL:\n  case NODE_SCALL:\n    \/* keep evaluation order *\/\n    break;\n\n  case NODE_NVAR:\n    codegen_error(s, \"Can't assign to numbered parameter\");\n    break;\n\n  default:\n    codegen_error(s, \"unknown lhs\");\n    break;\n  }\n\n  tree = tree->cdr;\n  switch (type) {\n  case NODE_GVAR:\n    gen_setxv(s, OP_SETGV, sp, nsym(tree), val);\n    break;\n  case NODE_ARG:\n  case NODE_LVAR:\n    idx = lv_idx(s, nsym(tree));\n    if (idx > 0) {\n      if (idx != sp) {\n        gen_move(s, idx, sp, val);\n      }\n      break;\n    }\n    else {                      \/* upvar *\/\n      gen_setupvar(s, sp, nsym(tree));\n    }\n    break;\n  case NODE_IVAR:\n    gen_setxv(s, OP_SETIV, sp, nsym(tree), val);\n    break;\n  case NODE_CVAR:\n    gen_setxv(s, OP_SETCV, sp, nsym(tree), val);\n    break;\n  case NODE_CONST:\n    gen_setxv(s, OP_SETCONST, sp, nsym(tree), val);\n    break;\n  case NODE_COLON2:\n    if (sp) {\n      gen_move(s, cursp(), sp, 0);\n    }\n    sp = cursp();\n    push();\n    codegen(s, tree->car, VAL);\n    if (rhs) {\n      codegen(s, rhs, VAL); pop();\n      gen_move(s, sp, cursp(), 0);\n    }\n    pop_n(2);\n    idx = new_sym(s, nsym(tree->cdr));\n    genop_2(s, OP_SETMCNST, sp, idx);\n    break;\n\n  case NODE_CALL:\n  case NODE_SCALL:\n    {\n      int noself = 0, safe = (type == NODE_SCALL), skip = 0, top, call, n = 0;\n      mrb_sym mid = nsym(tree->cdr->car);\n\n      top = cursp();\n      if (val || sp == cursp()) {\n        push();                   \/* room for retval *\/\n      }\n      call = cursp();\n      if (!tree->car) {\n        noself = 1;\n        push();\n      }\n      else {\n        codegen(s, tree->car, VAL); \/* receiver *\/\n      }\n      if (safe) {\n        int recv = cursp()-1;\n        gen_move(s, cursp(), recv, 1);\n        skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n      }\n      tree = tree->cdr->cdr->car;\n      if (tree) {\n        if (tree->car) {            \/* positional arguments *\/\n          n = gen_values(s, tree->car, VAL, (tree->cdr->car)?13:14);\n          if (n < 0) {              \/* variable length *\/\n            n = 15;\n            push();\n          }\n        }\n        if (tree->cdr->car) {       \/* keyword arguments *\/\n          gen_hash(s, tree->cdr->car->cdr, VAL, 0);\n          if (n < 14) {\n            n++;\n            push();\n          }\n          else {\n            pop();\n            genop_2(s, OP_ARYPUSH, cursp(), 1);\n          }\n        }\n      }\n      if (rhs) {\n        codegen(s, rhs, VAL);\n        pop();\n      }\n      else {\n        gen_move(s, cursp(), sp, 0);\n      }\n      if (val) {\n        gen_move(s, top, cursp(), 1);\n      }\n      if (n < 14) {\n        n++;\n      }\n      else {\n        pop();\n        genop_2(s, OP_ARYPUSH, cursp(), 1);\n      }\n      s->sp = call;\n      if (mid == MRB_OPSYM_2(s->mrb, aref) && n == 2) {\n        genop_1(s, OP_SETIDX, cursp());\n      }\n      else {\n        genop_3(s, noself ? OP_SSEND : OP_SEND, cursp(), new_sym(s, attrsym(s, mid)), n);\n      }\n      if (safe) {\n        dispatch(s, skip);\n      }\n      s->sp = top;\n    }\n    break;\n\n  case NODE_MASGN:\n    gen_vmassignment(s, tree->car, sp, val);\n    break;\n\n  \/* splat without assignment *\/\n  case NODE_NIL:\n    break;\n\n  default:\n    codegen_error(s, \"unknown lhs\");\n    break;\n  }\n  if (val) push();\n}","target":1,"code_token_length":1139,"total_token_length":1375,"max_tokens_setting":2048}
+{"idx":195095,"func":"int Socket::startSslClient(const std::string &certificate_path, String hostname)\n{\n    if (isssl) {\n        stopSsl();\n    }\n\n    ERR_clear_error();\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n    ctx = SSL_CTX_new(SSLv23_client_method());\n#else\n    ctx = SSL_CTX_new(TLS_client_method());\n#endif\n\n    if (ctx == NULL) {\n#ifdef NETDEBUG\n        std::cout << thread_id << \"Error ssl context is null (check that openssl has been inited)\" << std::endl;\n#endif\n        log_ssl_errors(\"Error ssl context is null for %s\", hostname.c_str());\n        return -1;\n    }\n\n    \/\/set the timeout for the ssl session\n    if (SSL_CTX_set_timeout(ctx, 130l) < 1) {\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -1;\n    }\n\n    \/\/load certs\n    ERR_clear_error();\n    if (certificate_path.length()) {\n        if (!SSL_CTX_load_verify_locations(ctx, NULL, certificate_path.c_str())) {\n#ifdef NETDEBUG\n            std::cout << thread_id << \"couldnt load certificates\" << std::endl;\n#endif\n            log_ssl_errors(\"couldnt load certificates from %s\", certificate_path.c_str());\n            \/\/tidy up\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n            return -2;\n        }\n    } else if (!SSL_CTX_set_default_verify_paths(ctx)) \/\/use default if no certPpath given\n    {\n#ifdef NETDEBUG\n        std::cout << thread_id << \"couldnt load certificates\" << std::endl;\n#endif\n            log_ssl_errors(\"couldnt load default certificates for %s\", hostname.c_str());\n        \/\/tidy up\n        SSL_CTX_free(ctx);\n        ctx = NULL;\n        return -2;\n    }\n\n    \/\/ add validation params\n    ERR_clear_error();\n    X509_VERIFY_PARAM *x509_param = X509_VERIFY_PARAM_new();\n    if (!x509_param) {\n        log_ssl_errors(\"couldnt add validation params for %s\", hostname.c_str());\n        \/\/X509_VERIFY_PARAM_free(x509_param);\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -2;\n    }\n\n    ERR_clear_error();\n    if (!X509_VERIFY_PARAM_set_flags(x509_param, X509_V_FLAG_TRUSTED_FIRST)) {\n        log_ssl_errors(\"couldnt add validation params for %s\", hostname.c_str());\n        X509_VERIFY_PARAM_free(x509_param);\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -2;\n    }\n\n    ERR_clear_error();\n    if (!SSL_CTX_set1_param(ctx, x509_param)) {\n        log_ssl_errors(\"couldnt add validation params for %s\", hostname.c_str());\n        X509_VERIFY_PARAM_free(x509_param);\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -2;\n    }\n\n    X509_VERIFY_PARAM_free(x509_param);     \/\/ try not freeing this as SSL_CTX_free seems to be ring to free it\n\n    \/\/hand socket over to ssl lib\n    ERR_clear_error();\n    ssl = SSL_new(ctx);\n    SSL_set_options(ssl, SSL_OP_ALL);\n    SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);\n    SSL_set_connect_state(ssl);\n\n    \/\/fcntl(this->getFD() ,F_SETFL, O_NONBLOCK); \/\/ blocking mode used currently\n    SSL_set_fd(ssl, this->getFD());\n    SSL_set_tlsext_host_name(ssl, hostname.c_str());\n\n    \/\/make io non blocking as select wont tell us if we can do a read without blocking\n    \/\/BIO_set_nbio(SSL_get_rbio(ssl),1l);  \/\/ blocking mode used currently\n    \/\/BIO_set_nbio(SSL_get_wbio(ssl),1l); \/\/ blocking mode used currently\n    ERR_clear_error();\n    int rc = SSL_connect(ssl);\n    if (rc < 0) {\n        log_ssl_errors(\"ssl_connect failed to %s\", hostname.c_str());\n#ifdef NETDEBUG\n        std::cout << thread_id << \"ssl_connect failed with error \" << SSL_get_error(ssl, rc) << std::endl;\n#endif\n        \/\/ tidy up\n        SSL_free(ssl);\n        ssl = NULL;\n        SSL_CTX_free(ctx);\n        ctx = NULL;\n        return -3;\n    }\n\n    \/\/should be safer to do this last as nothing will ever try to use a ssl socket that isnt fully setup\n    isssl = true;\n    issslserver = false;\n    return 0;\n}","target":1,"code_token_length":1000,"total_token_length":1236,"max_tokens_setting":2048}
+{"idx":208533,"func":"xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,\n\t\t      int what, xmlChar end, xmlChar  end2, xmlChar end3) {\n    xmlChar *buffer = NULL;\n    size_t buffer_size = 0;\n    size_t nbchars = 0;\n\n    xmlChar *current = NULL;\n    xmlChar *rep = NULL;\n    const xmlChar *last;\n    xmlEntityPtr ent;\n    int c,l;\n\n    if ((ctxt == NULL) || (str == NULL) || (len < 0))\n\treturn(NULL);\n    last = str + len;\n\n    if (((ctxt->depth > 40) &&\n         ((ctxt->options & XML_PARSE_HUGE) == 0)) ||\n\t(ctxt->depth > 1024)) {\n\txmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);\n\treturn(NULL);\n    }\n\n    \/*\n     * allocate a translation buffer.\n     *\/\n    buffer_size = XML_PARSER_BIG_BUFFER_SIZE;\n    buffer = (xmlChar *) xmlMallocAtomic(buffer_size);\n    if (buffer == NULL) goto mem_error;\n\n    \/*\n     * OK loop until we reach one of the ending char or a size limit.\n     * we are operating on already parsed values.\n     *\/\n    if (str < last)\n\tc = CUR_SCHAR(str, l);\n    else\n        c = 0;\n    while ((c != 0) && (c != end) && \/* non input consuming loop *\/\n\t   (c != end2) && (c != end3)) {\n\n\tif (c == 0) break;\n        if ((c == '&') && (str[1] == '#')) {\n\t    int val = xmlParseStringCharRef(ctxt, &str);\n\t    if (val != 0) {\n\t\tCOPY_BUF(0,buffer,nbchars,val);\n\t    }\n\t    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {\n\t        growBuffer(buffer, XML_PARSER_BUFFER_SIZE);\n\t    }\n\t} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {\n\t    if (xmlParserDebugEntities)\n\t\txmlGenericError(xmlGenericErrorContext,\n\t\t\t\"String decoding Entity Reference: %.30s\\n\",\n\t\t\tstr);\n\t    ent = xmlParseStringEntityRef(ctxt, &str);\n\t    if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||\n\t        (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))\n\t        goto int_error;\n\t    xmlParserEntityCheck(ctxt, 0, ent, 0);\n\t    if (ent != NULL)\n\t        ctxt->nbentities += ent->checked \/ 2;\n\t    if ((ent != NULL) &&\n\t\t(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {\n\t\tif (ent->content != NULL) {\n\t\t    COPY_BUF(0,buffer,nbchars,ent->content[0]);\n\t\t    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {\n\t\t\tgrowBuffer(buffer, XML_PARSER_BUFFER_SIZE);\n\t\t    }\n\t\t} else {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,\n\t\t\t    \"predefined entity has no content\\n\");\n\t\t}\n\t    } else if ((ent != NULL) && (ent->content != NULL)) {\n\t\tctxt->depth++;\n\t\trep = xmlStringDecodeEntities(ctxt, ent->content, what,\n\t\t\t                      0, 0, 0);\n\t\tctxt->depth--;\n\n\t\tif ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||\n\t\t    (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))\n\t\t    goto int_error;\n\n\t\tif (rep != NULL) {\n\t\t    current = rep;\n\t\t    while (*current != 0) { \/* non input consuming loop *\/\n\t\t\tbuffer[nbchars++] = *current++;\n\t\t\tif (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {\n\t\t\t    if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))\n\t\t\t\tgoto int_error;\n\t\t\t    growBuffer(buffer, XML_PARSER_BUFFER_SIZE);\n\t\t\t}\n\t\t    }\n\t\t    xmlFree(rep);\n\t\t    rep = NULL;\n\t\t}\n\t    } else if (ent != NULL) {\n\t\tint i = xmlStrlen(ent->name);\n\t\tconst xmlChar *cur = ent->name;\n\n\t\tbuffer[nbchars++] = '&';\n\t\tif (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) {\n\t\t    growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE);\n\t\t}\n\t\tfor (;i > 0;i--)\n\t\t    buffer[nbchars++] = *cur++;\n\t\tbuffer[nbchars++] = ';';\n\t    }\n\t} else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) {\n\t    if (xmlParserDebugEntities)\n\t\txmlGenericError(xmlGenericErrorContext,\n\t\t\t\"String decoding PE Reference: %.30s\\n\", str);\n\t    ent = xmlParseStringPEReference(ctxt, &str);\n\t    if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)\n\t        goto int_error;\n\t    xmlParserEntityCheck(ctxt, 0, ent, 0);\n\t    if (ent != NULL)\n\t        ctxt->nbentities += ent->checked \/ 2;\n\t    if (ent != NULL) {\n                if (ent->content == NULL) {\n\t\t    xmlLoadEntityContent(ctxt, ent);\n\t\t}\n\t\tctxt->depth++;\n\t\trep = xmlStringDecodeEntities(ctxt, ent->content, what,\n\t\t\t                      0, 0, 0);\n\t\tctxt->depth--;\n\t\tif (rep != NULL) {\n\t\t    current = rep;\n\t\t    while (*current != 0) { \/* non input consuming loop *\/\n\t\t\tbuffer[nbchars++] = *current++;\n\t\t\tif (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {\n\t\t\t    if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))\n\t\t\t        goto int_error;\n\t\t\t    growBuffer(buffer, XML_PARSER_BUFFER_SIZE);\n\t\t\t}\n\t\t    }\n\t\t    xmlFree(rep);\n\t\t    rep = NULL;\n\t\t}\n\t    }\n\t} else {\n\t    COPY_BUF(l,buffer,nbchars,c);\n\t    str += l;\n\t    if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {\n\t        growBuffer(buffer, XML_PARSER_BUFFER_SIZE);\n\t    }\n\t}\n\tif (str < last)\n\t    c = CUR_SCHAR(str, l);\n\telse\n\t    c = 0;\n    }\n    buffer[nbchars] = 0;\n    return(buffer);\n\nmem_error:\n    xmlErrMemory(ctxt, NULL);\nint_error:\n    if (rep != NULL)\n        xmlFree(rep);\n    if (buffer != NULL)\n        xmlFree(buffer);\n    return(NULL);\n}","target":1,"code_token_length":1389,"total_token_length":1625,"max_tokens_setting":2048}
+{"idx":206044,"func":"void ZRLE_DECODE (const Rect& r, rdr::InStream* is,\n                  rdr::ZlibInStream* zis,\n                  const PixelFormat& pf, ModifiablePixelBuffer* pb)\n{\n  int length = is->readU32();\n  zis->setUnderlying(is, length);\n  Rect t;\n  PIXEL_T buf[64 * 64];\n\n  for (t.tl.y = r.tl.y; t.tl.y < r.br.y; t.tl.y += 64) {\n\n    t.br.y = __rfbmin(r.br.y, t.tl.y + 64);\n\n    for (t.tl.x = r.tl.x; t.tl.x < r.br.x; t.tl.x += 64) {\n\n      t.br.x = __rfbmin(r.br.x, t.tl.x + 64);\n\n      int mode = zis->readU8();\n      bool rle = mode & 128;\n      int palSize = mode & 127;\n      PIXEL_T palette[128];\n\n      for (int i = 0; i < palSize; i++) {\n        palette[i] = READ_PIXEL(zis);\n      }\n\n      if (palSize == 1) {\n        PIXEL_T pix = palette[0];\n        pb->fillRect(pf, t, &pix);\n        continue;\n      }\n\n      if (!rle) {\n        if (palSize == 0) {\n\n          \/\/ raw\n\n#ifdef CPIXEL\n          for (PIXEL_T* ptr = buf; ptr < buf+t.area(); ptr++) {\n            *ptr = READ_PIXEL(zis);\n          }\n#else\n          zis->readBytes(buf, t.area() * (BPP \/ 8));\n#endif\n\n        } else {\n\n          \/\/ packed pixels\n          int bppp = ((palSize > 16) ? 8 :\n                      ((palSize > 4) ? 4 : ((palSize > 2) ? 2 : 1)));\n\n          PIXEL_T* ptr = buf;\n\n          for (int i = 0; i < t.height(); i++) {\n            PIXEL_T* eol = ptr + t.width();\n            rdr::U8 byte = 0;\n            rdr::U8 nbits = 0;\n\n            while (ptr < eol) {\n              if (nbits == 0) {\n                byte = zis->readU8();\n                nbits = 8;\n              }\n              nbits -= bppp;\n              rdr::U8 index = (byte >> nbits) & ((1 << bppp) - 1) & 127;\n              *ptr++ = palette[index];\n            }\n          }\n        }\n\n      } else {\n\n        if (palSize == 0) {\n\n          \/\/ plain RLE\n\n          PIXEL_T* ptr = buf;\n          PIXEL_T* end = ptr + t.area();\n          while (ptr < end) {\n            PIXEL_T pix = READ_PIXEL(zis);\n            int len = 1;\n            int b;\n            do {\n              b = zis->readU8();\n              len += b;\n            } while (b == 255);\n\n            if (end - ptr < len) {\n              throw Exception (\"ZRLE decode error\");\n            }\n\n            while (len-- > 0) *ptr++ = pix;\n\n          }\n        } else {\n\n          \/\/ palette RLE\n\n          PIXEL_T* ptr = buf;\n          PIXEL_T* end = ptr + t.area();\n          while (ptr < end) {\n            int index = zis->readU8();\n            int len = 1;\n            if (index & 128) {\n              int b;\n              do {\n                b = zis->readU8();\n                len += b;\n              } while (b == 255);\n\n              if (end - ptr < len) {\n                throw Exception (\"ZRLE decode error\");\n              }\n            }\n\n            index &= 127;\n\n            PIXEL_T pix = palette[index];\n\n            while (len-- > 0) *ptr++ = pix;\n          }\n        }\n      }\n\n      pb->imageRect(pf, t, buf);\n    }\n  }\n\n  zis->removeUnderlying();\n}","target":1,"code_token_length":897,"total_token_length":1133,"max_tokens_setting":2048}
+{"idx":265062,"func":"set_colour_attribute(zattr atr, int fg_bg, int flags)\n{\n    char *ptr;\n    int do_free, is_prompt = (flags & TSC_PROMPT) ? 1 : 0;\n    int colour, tc, def, use_termcap, use_truecolor;\n    int is_default_zle_highlight = 1;\n\n    if (fg_bg == COL_SEQ_FG) {\n\tcolour = txtchangeget(atr, TXT_ATTR_FG_COL);\n\ttc = TCFGCOLOUR;\n\tdef = txtchangeisset(atr, TXTNOFGCOLOUR);\n\tuse_truecolor = txtchangeisset(atr, TXT_ATTR_FG_24BIT);\n\tuse_termcap = txtchangeisset(atr, TXT_ATTR_FG_TERMCAP);\n    } else {\n\tcolour = txtchangeget(atr, TXT_ATTR_BG_COL);\n\ttc = TCBGCOLOUR;\n\tdef = txtchangeisset(atr, TXTNOBGCOLOUR);\n\tuse_truecolor = txtchangeisset(atr, TXT_ATTR_BG_24BIT);\n\tuse_termcap = txtchangeisset(atr, TXT_ATTR_BG_TERMCAP);\n    }\n\n    \/* Test if current zle_highlight settings are customized, or\n     * the typical \"standard\" codes *\/\n    if (0 != strcmp(fg_bg_sequences[fg_bg].start, fg_bg == COL_SEQ_FG ? TC_COL_FG_START : TC_COL_BG_START) ||\n\t\/* the same in-fix for both FG and BG *\/\n\t0 != strcmp(fg_bg_sequences[fg_bg].def, TC_COL_FG_DEFAULT) ||\n\t\/* the same suffix for both FG and BG *\/\n\t0 != strcmp(fg_bg_sequences[fg_bg].end, TC_COL_FG_END))\n    {\n\tis_default_zle_highlight = 0;\n    }\n\n    \/*\n     * If we're not restoring the default, and either have a\n     * colour value that is too large for ANSI, or have been told\n     * to use the termcap sequence, try to use the termcap sequence.\n     * True color is not covered by termcap.\n     *\n     * We have already sanitised the values we allow from the\n     * highlighting variables, so much of this shouldn't be\n     * necessary at this point, but we might as well be safe.\n     *\/\n    if (!def && !use_truecolor &&\n\t(is_default_zle_highlight && (colour > 7 || use_termcap)))\n    {\n\t\/*\n\t * We can if it's available, and either we couldn't get\n\t * the maximum number of colours, or the colour is in range.\n\t *\/\n\tif (tccan(tc) && (tccolours < 0 || colour < tccolours))\n\t{\n\t    if (is_prompt)\n\t    {\n\t\tif (!bv->dontcount) {\n\t\t    addbufspc(1);\n\t\t    *bv->bp++ = Inpar;\n\t\t}\n\t\ttputs(tgoto(tcstr[tc], colour, colour), 1, putstr);\n\t\tif (!bv->dontcount) {\n\t\t    addbufspc(1);\n\t\t    *bv->bp++ = Outpar;\n\t\t}\n\t    } else {\n\t\ttputs(tgoto(tcstr[tc], colour, colour), 1, putshout);\n\t    }\n\t    \/* That worked. *\/\n\t    return;\n\t}\n\t\/*\n\t * Nope, that didn't work.\n\t * If 0 to 7, assume standard ANSI works, if 8 to 255, assume\n         * typical 256-color escapes works, otherwise it won't.\n\t *\/\n\tif (colour > 255)\n\t    return;\n    }\n\n    if ((do_free = (colseq_buf == NULL))) {\n\t\/* This can happen when moving the cursor in trashzle() *\/\n\tallocate_colour_buffer();\n    }\n\n    \/* Build the reset-code: .start + .def + . end\n     * or the typical true-color code: .start + 8;2;%d;%d;%d + .end\n     * or the typical 256-color code: .start + 8;5;%d + .end\n     *\/\n    if (use_truecolor)\n\tstrcpy(colseq_buf, fg_bg == COL_SEQ_FG ? TC_COL_FG_START : TC_COL_BG_START);\n    else\n\tstrcpy(colseq_buf, fg_bg_sequences[fg_bg].start);\n\n    ptr = colseq_buf + strlen(colseq_buf);\n    if (def) {\n\tif (use_truecolor)\n\t    strcpy(ptr, fg_bg == COL_SEQ_FG ? TC_COL_FG_DEFAULT : TC_COL_BG_DEFAULT);\n\telse\n\t    strcpy(ptr, fg_bg_sequences[fg_bg].def);\n\twhile (*ptr)\n\t    ptr++;\n    } else if (use_truecolor) {\n\tptr += sprintf(ptr, \"8;2;%d;%d;%d\", colour >> 16,\n\t\t(colour >> 8) & 0xff, colour & 0xff);\n    } else if (colour > 7 && colour <= 255) {\n\tptr += sprintf(ptr, \"%d\", colour);\n    } else\n\t*ptr++ = colour + '0';\n    if (use_truecolor)\n\tstrcpy(ptr, fg_bg == COL_SEQ_FG ? TC_COL_FG_END : TC_COL_BG_END);\n    else\n\tstrcpy(ptr, fg_bg_sequences[fg_bg].end);\n\n    if (is_prompt) {\n\tif (!bv->dontcount) {\n\t    addbufspc(1);\n\t    *bv->bp++ = Inpar;\n\t}\n\ttputs(colseq_buf, 1, putstr);\n\tif (!bv->dontcount) {\n\t    addbufspc(1);\n\t    *bv->bp++ = Outpar;\n\t}\n    } else\n\ttputs(colseq_buf, 1, putshout);\n\n    if (do_free)\n\tfree_colour_buffer();\n}","target":0,"code_token_length":1221,"total_token_length":1457,"max_tokens_setting":2048}
+{"idx":513171,"func":"int plugin_init(int *argc, char **argv, int flags)\n{\n  uint i;\n  struct st_maria_plugin **builtins;\n  struct st_maria_plugin *plugin;\n  struct st_plugin_int tmp, *plugin_ptr, **reap;\n  MEM_ROOT tmp_root;\n  bool reaped_mandatory_plugin= false;\n  bool mandatory= true;\n  LEX_STRING MyISAM= { C_STRING_WITH_LEN(\"MyISAM\") };\n  DBUG_ENTER(\"plugin_init\");\n\n  if (initialized)\n    DBUG_RETURN(0);\n\n  dlopen_count =0;\n\n  init_alloc_root(&plugin_mem_root, 4096, 4096, MYF(0));\n  init_alloc_root(&plugin_vars_mem_root, 4096, 4096, MYF(0));\n  init_alloc_root(&tmp_root, 4096, 4096, MYF(0));\n\n  if (my_hash_init(&bookmark_hash, &my_charset_bin, 32, 0, 0,\n                   get_bookmark_hash_key, NULL, HASH_UNIQUE))\n      goto err;\n\n  \/*\n    The 80 is from 2016-04-27 when we had 71 default plugins\n    Big enough to avoid many mallocs even in future\n  *\/\n  if (my_init_dynamic_array(&plugin_dl_array,\n                            sizeof(struct st_plugin_dl *), 16, 16, MYF(0)) ||\n      my_init_dynamic_array(&plugin_array,\n                            sizeof(struct st_plugin_int *), 80, 32, MYF(0)))\n    goto err;\n\n  for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)\n  {\n    if (my_hash_init(&plugin_hash[i], system_charset_info, 32, 0, 0,\n                     get_plugin_hash_key, NULL, HASH_UNIQUE))\n      goto err;\n  }\n\n  \/* prepare debug_sync service *\/\n  DBUG_ASSERT(strcmp(list_of_services[1].name, \"debug_sync_service\") == 0);\n  list_of_services[1].service= *(void**)&debug_sync_C_callback_ptr;\n\n  \/* prepare encryption_keys service *\/\n  finalize_encryption_plugin(0);\n\n  mysql_mutex_lock(&LOCK_plugin);\n\n  initialized= 1;\n\n  \/*\n    First we register builtin plugins\n  *\/\n  if (global_system_variables.log_warnings >= 9)\n    sql_print_information(\"Initializing built-in plugins\");\n\n  for (builtins= mysql_mandatory_plugins; *builtins || mandatory; builtins++)\n  {\n    if (!*builtins)\n    {\n      builtins= mysql_optional_plugins;\n      mandatory= false;\n      if (!*builtins)\n        break;\n    }\n    for (plugin= *builtins; plugin->info; plugin++)\n    {\n      if (opt_ignore_builtin_innodb &&\n          !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name,\n                        6, (const uchar*) \"InnoDB\", 6))\n        continue;\n\n      bzero(&tmp, sizeof(tmp));\n      tmp.plugin= plugin;\n      tmp.name.str= (char *)plugin->name;\n      tmp.name.length= strlen(plugin->name);\n      tmp.state= 0;\n      tmp.load_option= mandatory ? PLUGIN_FORCE : PLUGIN_ON;\n\n      for (i=0; i < array_elements(override_plugin_load_policy); i++)\n      {\n        if (!my_strcasecmp(&my_charset_latin1, plugin->name,\n                           override_plugin_load_policy[i].plugin_name))\n        {\n          tmp.load_option= override_plugin_load_policy[i].override;\n          break;\n        }\n      }\n\n      free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE));\n      tmp.state= PLUGIN_IS_UNINITIALIZED;\n      if (register_builtin(plugin, &tmp, &plugin_ptr))\n        goto err_unlock;\n    }\n  }\n\n  \/*\n    First, we initialize only MyISAM - that should almost always succeed\n    (almost always, because plugins can be loaded outside of the server, too).\n  *\/\n  plugin_ptr= plugin_find_internal(&MyISAM, MYSQL_STORAGE_ENGINE_PLUGIN);\n  DBUG_ASSERT(plugin_ptr || !mysql_mandatory_plugins[0]);\n  if (plugin_ptr)\n  {\n    DBUG_ASSERT(plugin_ptr->load_option == PLUGIN_FORCE);\n\n    if (plugin_initialize(&tmp_root, plugin_ptr, argc, argv, false))\n      goto err_unlock;\n\n    \/*\n      set the global default storage engine variable so that it will\n      not be null in any child thread.\n    *\/\n    global_system_variables.table_plugin =\n      intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr));\n      DBUG_ASSERT(plugin_ptr->ref_count == 1);\n\n  }\n  mysql_mutex_unlock(&LOCK_plugin);\n\n  \/* Register (not initialize!) all dynamic plugins *\/\n  if (!(flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING))\n  {\n    I_List_iterator<i_string> iter(opt_plugin_load_list);\n    i_string *item;\n    if (global_system_variables.log_warnings >= 9)\n      sql_print_information(\"Initializing plugins specified on the command line\");\n    while (NULL != (item= iter++))\n      plugin_load_list(&tmp_root, item->ptr);\n\n    if (!(flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE))\n    {\n      char path[FN_REFLEN + 1];\n      build_table_filename(path, sizeof(path) - 1, \"mysql\", \"plugin\", reg_ext, 0);\n      char engine_name_buf[NAME_CHAR_LEN + 1];\n      LEX_STRING maybe_myisam= { engine_name_buf, 0 };\n      frm_type_enum frm_type= dd_frm_type(NULL, path, &maybe_myisam);\n      \/* if mysql.plugin table is MyISAM - load it right away *\/\n      if (frm_type == FRMTYPE_TABLE && !strcasecmp(maybe_myisam.str, \"MyISAM\"))\n      {\n        plugin_load(&tmp_root);\n        flags|= PLUGIN_INIT_SKIP_PLUGIN_TABLE;\n      }\n    }\n  }\n\n  \/*\n    Now we initialize all remaining plugins\n  *\/\n\n  mysql_mutex_lock(&LOCK_plugin);\n  reap= (st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*));\n  *(reap++)= NULL;\n\n  for(;;)\n  {\n    for (i=0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)\n    {\n      HASH *hash= plugin_hash + plugin_type_initialization_order[i];\n      for (uint idx= 0; idx < hash->records; idx++)\n      {\n        plugin_ptr= (struct st_plugin_int *) my_hash_element(hash, idx);\n        if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED)\n        {\n          if (plugin_initialize(&tmp_root, plugin_ptr, argc, argv,\n                                (flags & PLUGIN_INIT_SKIP_INITIALIZATION)))\n          {\n            plugin_ptr->state= PLUGIN_IS_DYING;\n            *(reap++)= plugin_ptr;\n          }\n        }\n      }\n    }\n\n    \/* load and init plugins from the plugin table (unless done already) *\/\n    if (flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE)\n      break;\n\n    mysql_mutex_unlock(&LOCK_plugin);\n    plugin_load(&tmp_root);\n    flags|= PLUGIN_INIT_SKIP_PLUGIN_TABLE;\n    mysql_mutex_lock(&LOCK_plugin);\n  }\n\n  \/*\n    Check if any plugins have to be reaped\n  *\/\n  while ((plugin_ptr= *(--reap)))\n  {\n    mysql_mutex_unlock(&LOCK_plugin);\n    if (plugin_is_forced(plugin_ptr))\n      reaped_mandatory_plugin= TRUE;\n    plugin_deinitialize(plugin_ptr, true);\n    mysql_mutex_lock(&LOCK_plugin);\n    plugin_del(plugin_ptr);\n  }\n\n  mysql_mutex_unlock(&LOCK_plugin);\n  my_afree(reap);\n  if (reaped_mandatory_plugin)\n    goto err;\n\n  free_root(&tmp_root, MYF(0));\n\n  DBUG_RETURN(0);\n\nerr_unlock:\n  mysql_mutex_unlock(&LOCK_plugin);\nerr:\n  free_root(&tmp_root, MYF(0));\n  DBUG_RETURN(1);\n}","target":0,"code_token_length":1683,"total_token_length":1919,"max_tokens_setting":2048}
+{"idx":229310,"func":"process_batch_internal(service::client_state& client_state, distributed<cql3::query_processor>& qp, request_reader in,\n        uint16_t stream, cql_protocol_version_type version, cql_serialization_format serialization_format,\n        service_permit permit, tracing::trace_state_ptr trace_state, bool init_trace, cql3::computed_function_values cached_pk_fn_calls) {\n    if (version == 1) {\n        throw exceptions::protocol_exception(\"BATCH messages are not support in version 1 of the protocol\");\n    }\n\n    const auto type = in.read_byte();\n    const unsigned n = in.read_short();\n\n    std::vector<cql3::statements::batch_statement::single_statement> modifications;\n    std::vector<std::vector<cql3::raw_value_view>> values;\n    std::unordered_map<cql3::prepared_cache_key_type, cql3::authorized_prepared_statements_cache::value_type> pending_authorization_entries;\n\n    modifications.reserve(n);\n    values.reserve(n);\n\n    if (init_trace) {\n        tracing::begin(trace_state, \"Execute batch of CQL3 queries\", client_state.get_client_address());\n    }\n\n    for ([[gnu::unused]] auto i : boost::irange(0u, n)) {\n        const auto kind = in.read_byte();\n\n        std::unique_ptr<cql3::statements::prepared_statement> stmt_ptr;\n        cql3::statements::prepared_statement::checked_weak_ptr ps;\n        bool needs_authorization(kind == 0);\n\n        switch (kind) {\n        case 0: {\n            auto query = in.read_long_string_view();\n            stmt_ptr = qp.local().get_statement(query, client_state);\n            ps = stmt_ptr->checked_weak_from_this();\n            if (init_trace) {\n                tracing::add_query(trace_state, query);\n            }\n            break;\n        }\n        case 1: {\n            cql3::prepared_cache_key_type cache_key(in.read_short_bytes());\n            auto& id = cql3::prepared_cache_key_type::cql_id(cache_key);\n\n            \/\/ First, try to lookup in the cache of already authorized statements. If the corresponding entry is not found there\n            \/\/ look for the prepared statement and then authorize it.\n            ps = qp.local().get_prepared(client_state.user(), cache_key);\n            if (!ps) {\n                ps = qp.local().get_prepared(cache_key);\n                if (!ps) {\n                    throw exceptions::prepared_query_not_found_exception(id);\n                }\n                \/\/ authorize a particular prepared statement only once\n                needs_authorization = pending_authorization_entries.emplace(std::move(cache_key), ps->checked_weak_from_this()).second;\n            }\n            if (init_trace) {\n                tracing::add_query(trace_state, ps->statement->raw_cql_statement);\n            }\n            break;\n        }\n        default:\n            throw exceptions::protocol_exception(\n                    \"Invalid query kind in BATCH messages. Must be 0 or 1 but got \"\n                            + std::to_string(int(kind)));\n        }\n\n        if (dynamic_cast<cql3::statements::modification_statement*>(ps->statement.get()) == nullptr) {\n            throw exceptions::invalid_request_exception(\"Invalid statement in batch: only UPDATE, INSERT and DELETE statements are allowed.\");\n        }\n\n        ::shared_ptr<cql3::statements::modification_statement> modif_statement_ptr = static_pointer_cast<cql3::statements::modification_statement>(ps->statement);\n        if (init_trace) {\n            tracing::add_table_name(trace_state, modif_statement_ptr->keyspace(), modif_statement_ptr->column_family());\n            tracing::add_prepared_statement(trace_state, ps);\n        }\n\n        modifications.emplace_back(std::move(modif_statement_ptr), needs_authorization);\n\n        std::vector<cql3::raw_value_view> tmp;\n        in.read_value_view_list(version, tmp);\n\n        auto stmt = ps->statement;\n        if (stmt->get_bound_terms() != tmp.size()) {\n            throw exceptions::invalid_request_exception(format(\"There were {:d} markers(?) in CQL but {:d} bound variables\",\n                            stmt->get_bound_terms(), tmp.size()));\n        }\n        values.emplace_back(std::move(tmp));\n    }\n\n    auto q_state = std::make_unique<cql_query_state>(client_state, trace_state, std::move(permit));\n    auto& query_state = q_state->query_state;\n    \/\/ #563. CQL v2 encodes query_options in v1 format for batch requests.\n    q_state->options = std::make_unique<cql3::query_options>(cql3::query_options::make_batch_options(std::move(*in.read_options(version < 3 ? 1 : version, serialization_format,\n                                                                     qp.local().get_cql_config())), std::move(values)));\n    auto& options = *q_state->options;\n    if (!cached_pk_fn_calls.empty()) {\n        options.set_cached_pk_function_calls(std::move(cached_pk_fn_calls));\n    }\n\n    if (init_trace) {\n        tracing::set_consistency_level(trace_state, options.get_consistency());\n        tracing::set_optional_serial_consistency_level(trace_state, options.get_serial_consistency());\n        tracing::add_prepared_query_options(trace_state, options);\n        tracing::trace(trace_state, \"Creating a batch statement\");\n    }\n\n    auto batch = ::make_shared<cql3::statements::batch_statement>(cql3::statements::batch_statement::type(type), std::move(modifications), cql3::attributes::none(), qp.local().get_cql_stats());\n    return qp.local().execute_batch_without_checking_exception_message(batch, query_state, options, std::move(pending_authorization_entries))\n            .then([stream, batch, q_state = std::move(q_state), trace_state = query_state.get_trace_state(), version] (auto msg) {\n        if (msg->move_to_shard()) {\n            return process_fn_return_type(dynamic_pointer_cast<messages::result_message::bounce_to_shard>(msg));\n        } else if (msg->is_exception()) {\n            return process_fn_return_type(convert_error_message_to_coordinator_result(msg.get()));\n        } else {\n            tracing::trace(q_state->query_state.get_trace_state(), \"Done processing - preparing a result\");\n            return process_fn_return_type(make_foreign(make_result(stream, *msg, trace_state, version)));\n        }\n    });\n}","target":0,"code_token_length":1309,"total_token_length":1545,"max_tokens_setting":2048}
+{"idx":338225,"func":"void WasmBinaryBuilder::readImports() {\n  BYN_TRACE(\"== readImports\\n\");\n  size_t num = getU32LEB();\n  BYN_TRACE(\"num: \" << num << std::endl);\n  Builder builder(wasm);\n  size_t tableCounter = 0;\n  size_t memoryCounter = 0;\n  size_t functionCounter = 0;\n  size_t globalCounter = 0;\n  size_t tagCounter = 0;\n  for (size_t i = 0; i < num; i++) {\n    BYN_TRACE(\"read one\\n\");\n    auto module = getInlineString();\n    auto base = getInlineString();\n    auto kind = (ExternalKind)getU32LEB();\n    \/\/ We set a unique prefix for the name based on the kind. This ensures no\n    \/\/ collisions between them, which can't occur here (due to the index i) but\n    \/\/ could occur later due to the names section.\n    switch (kind) {\n      case ExternalKind::Function: {\n        Name name(std::string(\"fimport$\") + std::to_string(functionCounter++));\n        auto index = getU32LEB();\n        functionTypes.push_back(getTypeByIndex(index));\n        auto type = getTypeByIndex(index);\n        if (!type.isSignature()) {\n          throwError(std::string(\"Imported function \") + module.str + '.' +\n                     base.str +\n                     \"'s type must be a signature. Given: \" + type.toString());\n        }\n        auto curr = builder.makeFunction(name, type, {});\n        curr->module = module;\n        curr->base = base;\n        functionImports.push_back(curr.get());\n        wasm.addFunction(std::move(curr));\n        break;\n      }\n      case ExternalKind::Table: {\n        Name name(std::string(\"timport$\") + std::to_string(tableCounter++));\n        auto table = builder.makeTable(name);\n        table->module = module;\n        table->base = base;\n        table->type = getType();\n\n        bool is_shared;\n        Type indexType;\n        getResizableLimits(table->initial,\n                           table->max,\n                           is_shared,\n                           indexType,\n                           Table::kUnlimitedSize);\n        if (is_shared) {\n          throwError(\"Tables may not be shared\");\n        }\n        if (indexType == Type::i64) {\n          throwError(\"Tables may not be 64-bit\");\n        }\n\n        tableImports.push_back(table.get());\n        wasm.addTable(std::move(table));\n        break;\n      }\n      case ExternalKind::Memory: {\n        Name name(std::string(\"mimport$\") + std::to_string(memoryCounter++));\n        wasm.memory.module = module;\n        wasm.memory.base = base;\n        wasm.memory.name = name;\n        wasm.memory.exists = true;\n        getResizableLimits(wasm.memory.initial,\n                           wasm.memory.max,\n                           wasm.memory.shared,\n                           wasm.memory.indexType,\n                           Memory::kUnlimitedSize);\n        break;\n      }\n      case ExternalKind::Global: {\n        Name name(std::string(\"gimport$\") + std::to_string(globalCounter++));\n        auto type = getConcreteType();\n        auto mutable_ = getU32LEB();\n        auto curr =\n          builder.makeGlobal(name,\n                             type,\n                             nullptr,\n                             mutable_ ? Builder::Mutable : Builder::Immutable);\n        curr->module = module;\n        curr->base = base;\n        globalImports.push_back(curr.get());\n        wasm.addGlobal(std::move(curr));\n        break;\n      }\n      case ExternalKind::Tag: {\n        Name name(std::string(\"eimport$\") + std::to_string(tagCounter++));\n        getInt8(); \/\/ Reserved 'attribute' field\n        auto index = getU32LEB();\n        auto curr = builder.makeTag(name, getSignatureByTypeIndex(index));\n        curr->module = module;\n        curr->base = base;\n        wasm.addTag(std::move(curr));\n        break;\n      }\n      default: {\n        throwError(\"bad import kind\");\n      }\n    }\n  }\n}","target":0,"code_token_length":845,"total_token_length":1081,"max_tokens_setting":2048}
+{"idx":361763,"func":"static void em28xx_check_usb_descriptor(struct em28xx *dev,\n\t\t\t\t\tstruct usb_device *udev,\n\t\t\t\t\tstruct usb_interface *intf,\n\t\t\t\t\tint alt, int ep,\n\t\t\t\t\tbool *has_vendor_audio,\n\t\t\t\t\tbool *has_video,\n\t\t\t\t\tbool *has_dvb)\n{\n\tconst struct usb_endpoint_descriptor *e;\n\tint sizedescr, size;\n\n\t\/*\n\t * NOTE:\n\t *\n\t * Old logic with support for isoc transfers only was:\n\t *  0x82\tisoc\t\t=> analog\n\t *  0x83\tisoc\t\t=> audio\n\t *  0x84\tisoc\t\t=> digital\n\t *\n\t * New logic with support for bulk transfers\n\t *  0x82\tisoc\t\t=> analog\n\t *  0x82\tbulk\t\t=> analog\n\t *  0x83\tisoc*\t\t=> audio\n\t *  0x84\tisoc\t\t=> digital\n\t *  0x84\tbulk\t\t=> analog or digital**\n\t *  0x85\tisoc\t\t=> digital TS2\n\t *  0x85\tbulk\t\t=> digital TS2\n\t * (*: audio should always be isoc)\n\t * (**: analog, if ep 0x82 is isoc, otherwise digital)\n\t *\n\t * The new logic preserves backwards compatibility and\n\t * reflects the endpoint configurations we have seen\n\t * so far. But there might be devices for which this\n\t * logic is not sufficient...\n\t *\/\n\n\te = &intf->altsetting[alt].endpoint[ep].desc;\n\n\tif (!usb_endpoint_dir_in(e))\n\t\treturn;\n\n\tsizedescr = le16_to_cpu(e->wMaxPacketSize);\n\tsize = sizedescr & 0x7ff;\n\n\tif (udev->speed == USB_SPEED_HIGH)\n\t\tsize = size * hb_mult(sizedescr);\n\n\t\/* Only inspect input endpoints *\/\n\n\tswitch (e->bEndpointAddress) {\n\tcase 0x82:\n\t\t*has_video = true;\n\t\tif (usb_endpoint_xfer_isoc(e)) {\n\t\t\tdev->analog_ep_isoc = e->bEndpointAddress;\n\t\t\tdev->alt_max_pkt_size_isoc[alt] = size;\n\t\t} else if (usb_endpoint_xfer_bulk(e)) {\n\t\t\tdev->analog_ep_bulk = e->bEndpointAddress;\n\t\t}\n\t\treturn;\n\tcase 0x83:\n\t\tif (usb_endpoint_xfer_isoc(e))\n\t\t\t*has_vendor_audio = true;\n\t\telse\n\t\t\tdev_err(&intf->dev,\n\t\t\t\t\"error: skipping audio endpoint 0x83, because it uses bulk transfers !\\n\");\n\t\treturn;\n\tcase 0x84:\n\t\tif (*has_video && (usb_endpoint_xfer_bulk(e))) {\n\t\t\tdev->analog_ep_bulk = e->bEndpointAddress;\n\t\t} else {\n\t\t\tif (usb_endpoint_xfer_isoc(e)) {\n\t\t\t\tif (size > dev->dvb_max_pkt_size_isoc) {\n\t\t\t\t\t\/*\n\t\t\t\t\t * 2) some manufacturers (e.g. Terratec)\n\t\t\t\t\t * disable endpoints by setting\n\t\t\t\t\t * wMaxPacketSize to 0 bytes for all\n\t\t\t\t\t * alt settings. So far, we've seen\n\t\t\t\t\t * this for DVB isoc endpoints only.\n\t\t\t\t\t *\/\n\t\t\t\t\t*has_dvb = true;\n\t\t\t\t\tdev->dvb_ep_isoc = e->bEndpointAddress;\n\t\t\t\t\tdev->dvb_max_pkt_size_isoc = size;\n\t\t\t\t\tdev->dvb_alt_isoc = alt;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t*has_dvb = true;\n\t\t\t\tdev->dvb_ep_bulk = e->bEndpointAddress;\n\t\t\t}\n\t\t}\n\t\treturn;\n\tcase 0x85:\n\t\tif (usb_endpoint_xfer_isoc(e)) {\n\t\t\tif (size > dev->dvb_max_pkt_size_isoc_ts2) {\n\t\t\t\tdev->dvb_ep_isoc_ts2 = e->bEndpointAddress;\n\t\t\t\tdev->dvb_max_pkt_size_isoc_ts2 = size;\n\t\t\t\tdev->dvb_alt_isoc = alt;\n\t\t\t}\n\t\t} else {\n\t\t\tdev->dvb_ep_bulk_ts2 = e->bEndpointAddress;\n\t\t}\n\t\treturn;\n\t}\n}","target":0,"code_token_length":925,"total_token_length":1161,"max_tokens_setting":2048}
+{"idx":195965,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor* hypothesis_indices;\n    const Tensor* hypothesis_values;\n    const Tensor* hypothesis_shape;\n    const Tensor* truth_indices;\n    const Tensor* truth_values;\n    const Tensor* truth_shape;\n    OP_REQUIRES_OK(ctx, ctx->input(\"hypothesis_indices\", &hypothesis_indices));\n    OP_REQUIRES_OK(ctx, ctx->input(\"hypothesis_values\", &hypothesis_values));\n    OP_REQUIRES_OK(ctx, ctx->input(\"hypothesis_shape\", &hypothesis_shape));\n    OP_REQUIRES_OK(ctx, ctx->input(\"truth_indices\", &truth_indices));\n    OP_REQUIRES_OK(ctx, ctx->input(\"truth_values\", &truth_values));\n    OP_REQUIRES_OK(ctx, ctx->input(\"truth_shape\", &truth_shape));\n\n    OP_REQUIRES_OK(\n        ctx, ValidateShapes(ctx, *hypothesis_indices, *hypothesis_values,\n                            *hypothesis_shape, *truth_indices, *truth_values,\n                            *truth_shape));\n\n    TensorShape hypothesis_st_shape;\n    OP_REQUIRES_OK(ctx,\n                   TensorShapeUtils::MakeShape(\n                       hypothesis_shape->vec<int64_t>().data(),\n                       hypothesis_shape->NumElements(), &hypothesis_st_shape));\n    TensorShape truth_st_shape;\n    OP_REQUIRES_OK(ctx, TensorShapeUtils::MakeShape(\n                            truth_shape->vec<int64_t>().data(),\n                            truth_shape->NumElements(), &truth_st_shape));\n\n    \/\/ Assume indices are sorted in row-major order.\n    std::vector<int64_t> sorted_order(truth_st_shape.dims());\n    std::iota(sorted_order.begin(), sorted_order.end(), 0);\n\n    sparse::SparseTensor hypothesis;\n    OP_REQUIRES_OK(ctx, sparse::SparseTensor::Create(\n                            *hypothesis_indices, *hypothesis_values,\n                            hypothesis_st_shape, sorted_order, &hypothesis));\n\n    sparse::SparseTensor truth;\n    OP_REQUIRES_OK(ctx, sparse::SparseTensor::Create(\n                            *truth_indices, *truth_values, truth_st_shape,\n                            sorted_order, &truth));\n\n    \/\/ Group dims 0, 1, ..., RANK - 1.  The very last dim is assumed\n    \/\/ to store the variable length sequences.\n    std::vector<int64_t> group_dims(truth_st_shape.dims() - 1);\n    std::iota(group_dims.begin(), group_dims.end(), 0);\n\n    TensorShape output_shape;\n    for (int d = 0; d < static_cast<int>(group_dims.size()); ++d) {\n      output_shape.AddDim(std::max(hypothesis_st_shape.dim_size(d),\n                                   truth_st_shape.dim_size(d)));\n    }\n    const auto output_elements = output_shape.num_elements();\n    OP_REQUIRES(\n        ctx, output_elements > 0,\n        errors::InvalidArgument(\"Got output shape \", output_shape.DebugString(),\n                                \" which has 0 elements\"));\n\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"output\", output_shape, &output));\n    auto output_t = output->flat<float>();\n    output_t.setZero();\n\n    std::vector<int64_t> output_strides(output_shape.dims());\n    output_strides[output_shape.dims() - 1] = 1;\n    for (int d = output_shape.dims() - 2; d >= 0; --d) {\n      output_strides[d] = output_strides[d + 1] * output_shape.dim_size(d + 1);\n    }\n\n    auto hypothesis_grouper = hypothesis.group(group_dims);\n    auto truth_grouper = truth.group(group_dims);\n\n    auto hypothesis_iter = hypothesis_grouper.begin();\n    auto truth_iter = truth_grouper.begin();\n\n    auto cmp = std::equal_to<T>();\n\n    while (hypothesis_iter != hypothesis_grouper.end() &&\n           truth_iter != truth_grouper.end()) {\n      sparse::Group truth_i = *truth_iter;\n      sparse::Group hypothesis_j = *hypothesis_iter;\n      std::vector<int64_t> g_truth = truth_i.group();\n      std::vector<int64_t> g_hypothesis = hypothesis_j.group();\n      auto truth_seq = truth_i.values<T>();\n      auto hypothesis_seq = hypothesis_j.values<T>();\n\n      if (g_truth == g_hypothesis) {\n        auto loc = std::inner_product(g_truth.begin(), g_truth.end(),\n                                      output_strides.begin(), int64_t{0});\n        OP_REQUIRES(\n            ctx, loc < output_elements,\n            errors::Internal(\"Got an inner product \", loc,\n                             \" which would require in writing to outside of \"\n                             \"the buffer for the output tensor (max elements \",\n                             output_elements, \")\"));\n        output_t(loc) =\n            gtl::LevenshteinDistance<T>(truth_seq, hypothesis_seq, cmp);\n        if (normalize_) output_t(loc) \/= truth_seq.size();\n\n        ++hypothesis_iter;\n        ++truth_iter;\n      } else if (g_truth > g_hypothesis) {  \/\/ zero-length truth\n        auto loc = std::inner_product(g_hypothesis.begin(), g_hypothesis.end(),\n                                      output_strides.begin(), int64_t{0});\n        OP_REQUIRES(\n            ctx, loc < output_elements,\n            errors::Internal(\"Got an inner product \", loc,\n                             \" which would require in writing to outside of \"\n                             \"the buffer for the output tensor (max elements \",\n                             output_elements, \")\"));\n        output_t(loc) = hypothesis_seq.size();\n        if (normalize_ && output_t(loc) != 0.0f) {\n          output_t(loc) = std::numeric_limits<float>::infinity();\n        }\n        ++hypothesis_iter;\n      } else {  \/\/ zero-length hypothesis\n        auto loc = std::inner_product(g_truth.begin(), g_truth.end(),\n                                      output_strides.begin(), int64_t{0});\n        OP_REQUIRES(\n            ctx, loc < output_elements,\n            errors::Internal(\"Got an inner product \", loc,\n                             \" which would require in writing to outside of \"\n                             \"the buffer for the output tensor (max elements \",\n                             output_elements, \")\"));\n        output_t(loc) = (normalize_) ? 1.0 : truth_seq.size();\n        ++truth_iter;\n      }\n    }\n    while (hypothesis_iter != hypothesis_grouper.end()) {  \/\/ zero-length truths\n      sparse::Group hypothesis_j = *hypothesis_iter;\n      std::vector<int64_t> g_hypothesis = hypothesis_j.group();\n      auto hypothesis_seq = hypothesis_j.values<T>();\n      auto loc = std::inner_product(g_hypothesis.begin(), g_hypothesis.end(),\n                                    output_strides.begin(), int64_t{0});\n      OP_REQUIRES(\n          ctx, loc < output_elements,\n          errors::Internal(\"Got an inner product \", loc,\n                           \" which would require in writing to outside of the \"\n                           \"buffer for the output tensor (max elements \",\n                           output_elements, \")\"));\n      output_t(loc) = hypothesis_seq.size();\n      if (normalize_ && output_t(loc) != 0.0f) {\n        output_t(loc) = std::numeric_limits<float>::infinity();\n      }\n      ++hypothesis_iter;\n    }\n    while (truth_iter != truth_grouper.end()) {  \/\/ missing hypotheses\n      sparse::Group truth_i = *truth_iter;\n      std::vector<int64_t> g_truth = truth_i.group();\n      auto truth_seq = truth_i.values<T>();\n      auto loc = std::inner_product(g_truth.begin(), g_truth.end(),\n                                    output_strides.begin(), int64_t{0});\n      OP_REQUIRES(\n          ctx, loc < output_elements,\n          errors::Internal(\"Got an inner product \", loc,\n                           \" which would require in writing to outside of the \"\n                           \"buffer for the output tensor (max elements \",\n                           output_elements, \")\"));\n      output_t(loc) = (normalize_) ? 1.0 : truth_seq.size();\n      ++truth_iter;\n    }\n  }","target":1,"code_token_length":1702,"total_token_length":1938,"max_tokens_setting":2048}
+{"idx":219036,"func":"bool ConstantFolding::PartialAssocOpConstFolding(GraphDef* optimized_graph,\n                                                 GraphProperties* properties,\n                                                 NodeDef* node) {\n  \/\/ Partial constant folding for associative operators:\n  \/\/ Split AddN\/AccumulateNV2 to enable partial\n  \/\/ folding of ops when more than one but not all inputs are constant.\n  \/\/ For AddN and AccumulateNV2, we may furthermore reorder inputs, since\n  \/\/ addition is commutative.\n  if (!IsAggregate(*node) || !IsCommutative(*node)) return false;\n\n  const int num_non_control_inputs = NumNonControlInputs(*node);\n  if (num_non_control_inputs <= 2) return false;\n  const int num_control_inputs = node->input_size() - num_non_control_inputs;\n  std::vector<int> const_inputs;\n  std::vector<int> nonconst_inputs;\n  for (int i = 0; i < node->input_size(); ++i) {\n    const string& input = node->input(i);\n    const NodeDef* input_node = node_map_->GetNode(NodeName(input));\n    if (input_node == nullptr) return false;\n    if (!IsControlInput(input) && IsReallyConstant(*input_node)) {\n      const_inputs.push_back(i);\n    } else {\n      \/\/ Non-const and control inputs.\n      nonconst_inputs.push_back(i);\n    }\n  }\n  \/\/ Promote AccumulateNV2 with all constant inputs to AddN, since it is\n  \/\/ a fake node that cannot be constant folded by itself.\n  int const_inputs_size = const_inputs.size();\n  if (const_inputs_size == num_non_control_inputs &&\n      node->op() == \"AccumulateNV2\") {\n    node->set_op(\"AddN\");\n    node->mutable_attr()->erase(\"shape\");\n    return true;\n  }\n  const string new_node_name = OptimizedNodeName(\n      *node, strings::StrCat(\"_partial_split_\", const_inputs_size));\n  if (const_inputs_size > 1 && const_inputs_size < num_non_control_inputs &&\n      !node_map_->NodeExists(new_node_name)) {\n    NodeDef* added_node = optimized_graph->add_node();\n    *added_node = *node;\n    \/\/ Always use AddN for the constant node, since AccumulateNV2 is a fake\n    \/\/ node that cannot be constant folded, since it does not have a kernel.\n    added_node->set_op(\"AddN\");\n    added_node->mutable_attr()->erase(\"shape\");\n    added_node->set_name(new_node_name);\n    node_map_->AddNode(added_node->name(), added_node);\n    added_node->clear_input();\n    for (int i : const_inputs) {\n      added_node->add_input(node->input(i));\n      node_map_->UpdateOutput(NodeName(node->input(i)), node->name(),\n                              added_node->name());\n    }\n\n    \/\/ Overwrite the first const input with the added node.\n    node->set_input(const_inputs[0], added_node->name());\n    node_map_->AddOutput(added_node->name(), node->name());\n    nonconst_inputs.push_back(const_inputs[0]);\n    \/\/ Compact the remaining inputs to the original node.\n    std::sort(nonconst_inputs.begin(), nonconst_inputs.end());\n    int idx = 0;\n    for (int i : nonconst_inputs) {\n      if (idx != i) {\n        node->set_input(idx, node->input(i));\n      }\n      ++idx;\n    }\n    node->mutable_input()->DeleteSubrange(nonconst_inputs.size(),\n                                          const_inputs.size() - 1);\n    (*node->mutable_attr())[\"N\"].set_i(node->input_size() - num_control_inputs);\n    properties->ClearInputProperties(node->name());\n    (*added_node->mutable_attr())[\"N\"].set_i(const_inputs.size());\n    return true;\n  }\n  return false;\n}","target":0,"code_token_length":810,"total_token_length":1046,"max_tokens_setting":2048}
+{"idx":427731,"func":"cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)\n{\n\tsize_t i, j, k;\n\tsize_t ss = CDF_SEC_SIZE(h);\n\tcdf_secid_t *msa, mid, sec;\n\tsize_t nsatpersec = (ss \/ sizeof(mid)) - 1;\n\n\tfor (i = 0; i < __arraycount(h->h_master_sat); i++)\n\t\tif (h->h_master_sat[i] == CDF_SECID_FREE)\n\t\t\tbreak;\n\n#define CDF_SEC_LIMIT (UINT32_MAX \/ (64 * ss))\n\tif ((nsatpersec > 0 &&\n\t    h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT \/ nsatpersec) ||\n\t    i > CDF_SEC_LIMIT) {\n\t\tDPRINTF((\"Number of sectors in master SAT too big %u %\"\n\t\t    SIZE_T_FORMAT \"u\\n\", h->h_num_sectors_in_master_sat, i));\n\t\terrno = EFTYPE;\n\t\treturn -1;\n\t}\n\n\tsat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i;\n\tDPRINTF((\"sat_len = %\" SIZE_T_FORMAT \"u ss = %\" SIZE_T_FORMAT \"u\\n\",\n\t    sat->sat_len, ss));\n\tif ((sat->sat_tab = CAST(cdf_secid_t *, CDF_CALLOC(sat->sat_len, ss)))\n\t    == NULL)\n\t\treturn -1;\n\n\tfor (i = 0; i < __arraycount(h->h_master_sat); i++) {\n\t\tif (h->h_master_sat[i] < 0)\n\t\t\tbreak;\n\t\tif (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h,\n\t\t    h->h_master_sat[i]) != CAST(ssize_t, ss)) {\n\t\t\tDPRINTF((\"Reading sector %d\", h->h_master_sat[i]));\n\t\t\tgoto out1;\n\t\t}\n\t}\n\n\tif ((msa = CAST(cdf_secid_t *, CDF_CALLOC(1, ss))) == NULL)\n\t\tgoto out1;\n\n\tmid = h->h_secid_first_sector_in_master_sat;\n\tfor (j = 0; j < h->h_num_sectors_in_master_sat; j++) {\n\t\tif (mid < 0)\n\t\t\tgoto out;\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Reading master sector loop limit\"));\n\t\t\tgoto out3;\n\t\t}\n\t\tif (cdf_read_sector(info, msa, 0, ss, h, mid) !=\n\t\t    CAST(ssize_t, ss)) {\n\t\t\tDPRINTF((\"Reading master sector %d\", mid));\n\t\t\tgoto out2;\n\t\t}\n\t\tfor (k = 0; k < nsatpersec; k++, i++) {\n\t\t\tsec = CDF_TOLE4(CAST(uint32_t, msa[k]));\n\t\t\tif (sec < 0)\n\t\t\t\tgoto out;\n\t\t\tif (i >= sat->sat_len) {\n\t\t\t    DPRINTF((\"Out of bounds reading MSA %\"\n\t\t\t\tSIZE_T_FORMAT \"u >= %\" SIZE_T_FORMAT \"u\",\n\t\t\t\ti, sat->sat_len));\n\t\t\t    goto out3;\n\t\t\t}\n\t\t\tif (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h,\n\t\t\t    sec) != CAST(ssize_t, ss)) {\n\t\t\t\tDPRINTF((\"Reading sector %d\",\n\t\t\t\t    CDF_TOLE4(msa[k])));\n\t\t\t\tgoto out2;\n\t\t\t}\n\t\t}\n\t\tmid = CDF_TOLE4(CAST(uint32_t, msa[nsatpersec]));\n\t}\nout:\n\tsat->sat_len = i;\n\tfree(msa);\n\treturn 0;\nout3:\n\terrno = EFTYPE;\nout2:\n\tfree(msa);\nout1:\n\tfree(sat->sat_tab);\n\treturn -1;\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048}
+{"idx":359646,"func":"bgp_clear (struct vty *vty, struct bgp *bgp,  afi_t afi, safi_t safi,\n           enum clear_sort sort,enum bgp_clear_type stype, const char *arg)\n{\n  int ret;\n  struct peer *peer;\n  struct listnode *node, *nnode;\n\n  \/* Clear all neighbors. *\/\n  if (sort == clear_all)\n    {\n      for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))\n\t{\n\t  if (stype == BGP_CLEAR_SOFT_NONE)\n\t    ret = peer_clear (peer);\n\t  else\n\t    ret = peer_clear_soft (peer, afi, safi, stype);\n\n\t  if (ret < 0)\n\t    bgp_clear_vty_error (vty, peer, afi, safi, ret);\n\t}\n      return 0;\n    }\n\n  \/* Clear specified neighbors. *\/\n  if (sort == clear_peer)\n    {\n      union sockunion su;\n      int ret;\n\n      \/* Make sockunion for lookup. *\/\n      ret = str2sockunion (arg, &su);\n      if (ret < 0)\n\t{\n\t  vty_out (vty, \"Malformed address: %s%s\", arg, VTY_NEWLINE);\n\t  return -1;\n\t}\n      peer = peer_lookup (bgp, &su);\n      if (! peer)\n\t{\n\t  vty_out (vty, \"%%BGP: Unknown neighbor - \\\"%s\\\"%s\", arg, VTY_NEWLINE);\n\t  return -1;\n\t}\n\n      if (stype == BGP_CLEAR_SOFT_NONE)\n\tret = peer_clear (peer);\n      else\n\tret = peer_clear_soft (peer, afi, safi, stype);\n\n      if (ret < 0)\n\tbgp_clear_vty_error (vty, peer, afi, safi, ret);\n\n      return 0;\n    }\n\n  \/* Clear all peer-group members. *\/\n  if (sort == clear_group)\n    {\n      struct peer_group *group;\n\n      group = peer_group_lookup (bgp, arg);\n      if (! group)\n\t{\n\t  vty_out (vty, \"%%BGP: No such peer-group %s%s\", arg, VTY_NEWLINE);\n\t  return -1; \n\t}\n\n      for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))\n\t{\n\t  if (stype == BGP_CLEAR_SOFT_NONE)\n\t    {\n\t      ret = peer_clear (peer);\n\t      continue;\n\t    }\n\n\t  if (! peer->af_group[afi][safi])\n\t    continue;\n\n\t  ret = peer_clear_soft (peer, afi, safi, stype);\n\n\t  if (ret < 0)\n\t    bgp_clear_vty_error (vty, peer, afi, safi, ret);\n\t}\n      return 0;\n    }\n\n  if (sort == clear_external)\n    {\n      for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))\n\t{\n\t  if (peer_sort (peer) == BGP_PEER_IBGP) \n\t    continue;\n\n\t  if (stype == BGP_CLEAR_SOFT_NONE)\n\t    ret = peer_clear (peer);\n\t  else\n\t    ret = peer_clear_soft (peer, afi, safi, stype);\n\n\t  if (ret < 0)\n\t    bgp_clear_vty_error (vty, peer, afi, safi, ret);\n\t}\n      return 0;\n    }\n\n  if (sort == clear_as)\n    {\n      as_t as;\n      unsigned long as_ul;\n      char *endptr = NULL;\n      int find = 0;\n\n      as_ul = strtoul(arg, &endptr, 10);\n\n      if ((as_ul == ULONG_MAX) || (*endptr != '\\0') || (as_ul > USHRT_MAX))\n\t{\n\t  vty_out (vty, \"Invalid AS number%s\", VTY_NEWLINE); \n\t  return -1;\n\t}\n      as = (as_t) as_ul;\n\n      for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))\n\t{\n\t  if (peer->as != as) \n\t    continue;\n\n\t  find = 1;\n\t  if (stype == BGP_CLEAR_SOFT_NONE)\n\t    ret = peer_clear (peer);\n\t  else\n\t    ret = peer_clear_soft (peer, afi, safi, stype);\n\n\t  if (ret < 0)\n\t    bgp_clear_vty_error (vty, peer, afi, safi, ret);\n\t}\n      if (! find)\n\tvty_out (vty, \"%%BGP: No peer is configured with AS %s%s\", arg,\n\t\t VTY_NEWLINE);\n      return 0;\n    }\n\n  return 0;\n}","target":0,"code_token_length":1010,"total_token_length":1246,"max_tokens_setting":2048}
+{"idx":466122,"func":"static int decode_modrm(struct x86_emulate_ctxt *ctxt,\n\t\t\tstruct operand *op)\n{\n\tu8 sib;\n\tint index_reg = 0, base_reg = 0, scale;\n\tint rc = X86EMUL_CONTINUE;\n\tulong modrm_ea = 0;\n\n\tif (ctxt->rex_prefix) {\n\t\tctxt->modrm_reg = (ctxt->rex_prefix & 4) << 1;\t\/* REX.R *\/\n\t\tindex_reg = (ctxt->rex_prefix & 2) << 2; \/* REX.X *\/\n\t\tctxt->modrm_rm = base_reg = (ctxt->rex_prefix & 1) << 3; \/* REG.B *\/\n\t}\n\n\tctxt->modrm = insn_fetch(u8, ctxt);\n\tctxt->modrm_mod |= (ctxt->modrm & 0xc0) >> 6;\n\tctxt->modrm_reg |= (ctxt->modrm & 0x38) >> 3;\n\tctxt->modrm_rm |= (ctxt->modrm & 0x07);\n\tctxt->modrm_seg = VCPU_SREG_DS;\n\n\tif (ctxt->modrm_mod == 3) {\n\t\top->type = OP_REG;\n\t\top->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;\n\t\top->addr.reg = decode_register(ctxt->modrm_rm,\n\t\t\t\t\t       ctxt->regs, ctxt->d & ByteOp);\n\t\tif (ctxt->d & Sse) {\n\t\t\top->type = OP_XMM;\n\t\t\top->bytes = 16;\n\t\t\top->addr.xmm = ctxt->modrm_rm;\n\t\t\tread_sse_reg(ctxt, &op->vec_val, ctxt->modrm_rm);\n\t\t\treturn rc;\n\t\t}\n\t\tfetch_register_operand(op);\n\t\treturn rc;\n\t}\n\n\top->type = OP_MEM;\n\n\tif (ctxt->ad_bytes == 2) {\n\t\tunsigned bx = ctxt->regs[VCPU_REGS_RBX];\n\t\tunsigned bp = ctxt->regs[VCPU_REGS_RBP];\n\t\tunsigned si = ctxt->regs[VCPU_REGS_RSI];\n\t\tunsigned di = ctxt->regs[VCPU_REGS_RDI];\n\n\t\t\/* 16-bit ModR\/M decode. *\/\n\t\tswitch (ctxt->modrm_mod) {\n\t\tcase 0:\n\t\t\tif (ctxt->modrm_rm == 6)\n\t\t\t\tmodrm_ea += insn_fetch(u16, ctxt);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tmodrm_ea += insn_fetch(s8, ctxt);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmodrm_ea += insn_fetch(u16, ctxt);\n\t\t\tbreak;\n\t\t}\n\t\tswitch (ctxt->modrm_rm) {\n\t\tcase 0:\n\t\t\tmodrm_ea += bx + si;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tmodrm_ea += bx + di;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmodrm_ea += bp + si;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmodrm_ea += bp + di;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tmodrm_ea += si;\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tmodrm_ea += di;\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tif (ctxt->modrm_mod != 0)\n\t\t\t\tmodrm_ea += bp;\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tmodrm_ea += bx;\n\t\t\tbreak;\n\t\t}\n\t\tif (ctxt->modrm_rm == 2 || ctxt->modrm_rm == 3 ||\n\t\t    (ctxt->modrm_rm == 6 && ctxt->modrm_mod != 0))\n\t\t\tctxt->modrm_seg = VCPU_SREG_SS;\n\t\tmodrm_ea = (u16)modrm_ea;\n\t} else {\n\t\t\/* 32\/64-bit ModR\/M decode. *\/\n\t\tif ((ctxt->modrm_rm & 7) == 4) {\n\t\t\tsib = insn_fetch(u8, ctxt);\n\t\t\tindex_reg |= (sib >> 3) & 7;\n\t\t\tbase_reg |= sib & 7;\n\t\t\tscale = sib >> 6;\n\n\t\t\tif ((base_reg & 7) == 5 && ctxt->modrm_mod == 0)\n\t\t\t\tmodrm_ea += insn_fetch(s32, ctxt);\n\t\t\telse\n\t\t\t\tmodrm_ea += ctxt->regs[base_reg];\n\t\t\tif (index_reg != 4)\n\t\t\t\tmodrm_ea += ctxt->regs[index_reg] << scale;\n\t\t} else if ((ctxt->modrm_rm & 7) == 5 && ctxt->modrm_mod == 0) {\n\t\t\tif (ctxt->mode == X86EMUL_MODE_PROT64)\n\t\t\t\tctxt->rip_relative = 1;\n\t\t} else\n\t\t\tmodrm_ea += ctxt->regs[ctxt->modrm_rm];\n\t\tswitch (ctxt->modrm_mod) {\n\t\tcase 0:\n\t\t\tif (ctxt->modrm_rm == 5)\n\t\t\t\tmodrm_ea += insn_fetch(s32, ctxt);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tmodrm_ea += insn_fetch(s8, ctxt);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmodrm_ea += insn_fetch(s32, ctxt);\n\t\t\tbreak;\n\t\t}\n\t}\n\top->addr.mem.ea = modrm_ea;\ndone:\n\treturn rc;\n}","target":0,"code_token_length":1145,"total_token_length":1381,"max_tokens_setting":2048}
+{"idx":196726,"func":"njs_array_prototype_sort(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    int64_t                i, und, len, nlen, length;\n    njs_int_t              ret, fast_path;\n    njs_array_t            *array;\n    njs_value_t            *this, *comparefn, *start, *strings;\n    njs_array_sort_ctx_t   ctx;\n    njs_array_sort_slot_t  *p, *end, *slots, *nslots;\n\n    comparefn = njs_arg(args, nargs, 1);\n\n    if (njs_is_defined(comparefn)) {\n        if (njs_slow_path(!njs_is_function(comparefn))) {\n            njs_type_error(vm, \"comparefn must be callable or undefined\");\n            return NJS_ERROR;\n        }\n\n        ctx.function = njs_function(comparefn);\n\n    } else {\n        ctx.function = NULL;\n    }\n\n    this = njs_argument(args, 0);\n\n    ret = njs_value_to_object(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_value_length(vm, this, &length);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_slow_path(length < 2)) {\n        vm->retval = *this;\n        return NJS_OK;\n    }\n\n    slots = NULL;\n    ctx.vm = vm;\n    ctx.strings.separate = 0;\n    ctx.strings.pointer = 0;\n    ctx.exception = 0;\n\n    fast_path = njs_is_fast_array(this);\n\n    if (njs_fast_path(fast_path)) {\n        array = njs_array(this);\n        start = array->start;\n\n        slots = njs_mp_alloc(vm->mem_pool,\n                             sizeof(njs_array_sort_slot_t) * length);\n        if (njs_slow_path(slots == NULL)) {\n                return NJS_ERROR;\n        }\n\n        und = 0;\n        p = slots;\n\n        for (i = 0; i < length; i++) {\n            if (njs_slow_path(!njs_is_valid(&start[i]))) {\n                fast_path = 0;\n                njs_mp_free(vm->mem_pool, slots);\n                slots = NULL;\n                goto slow_path;\n            }\n\n            if (njs_slow_path(njs_is_undefined(&start[i]))) {\n                und++;\n                continue;\n            }\n\n            p->value = start[i];\n            p->pos = i;\n            p->str = NULL;\n            p++;\n        }\n\n        len = p - slots;\n\n    } else {\n\nslow_path:\n\n        und = 0;\n        p = NULL;\n        end = NULL;\n\n        for (i = 0; i < length; i++) {\n            if (p >= end) {\n                nlen = njs_min(njs_max((p - slots) * 2, 8), length);\n                nslots = njs_mp_alloc(vm->mem_pool,\n                                      sizeof(njs_array_sort_slot_t) * nlen);\n                if (njs_slow_path(nslots == NULL)) {\n                    njs_memory_error(vm);\n                    return NJS_ERROR;\n                }\n\n                if (slots != NULL) {\n                    p = (void *) njs_cpymem(nslots, slots,\n                                  sizeof(njs_array_sort_slot_t) * (p - slots));\n                    njs_mp_free(vm->mem_pool, slots);\n\n                } else {\n                    p = nslots;\n                }\n\n                slots = nslots;\n                end = slots + nlen;\n            }\n\n            ret = njs_value_property_i64(vm, this, i, &p->value);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                ret = NJS_ERROR;\n                goto exception;\n            }\n\n            if (ret == NJS_DECLINED) {\n                continue;\n            }\n\n            if (njs_is_undefined(&p->value)) {\n                und++;\n                continue;\n            }\n\n            p->pos = i;\n            p->str = NULL;\n            p++;\n        }\n\n        len = p - slots;\n    }\n\n    strings = njs_arr_init(vm->mem_pool, &ctx.strings, NULL, len + 1,\n                           sizeof(njs_value_t));\n    if (njs_slow_path(strings == NULL)) {\n        ret = NJS_ERROR;\n        goto exception;\n    }\n\n    njs_qsort(slots, len, sizeof(njs_array_sort_slot_t), njs_array_compare,\n              &ctx);\n\n    if (ctx.exception) {\n        ret = NJS_ERROR;\n        goto exception;\n    }\n\n    if (njs_fast_path(fast_path)) {\n        array = njs_array(this);\n        start = array->start;\n\n        for (i = 0; i < len; i++) {\n            start[i] = slots[i].value;\n        }\n\n        for (i = len; und-- > 0; i++) {\n            start[i] = njs_value_undefined;\n        }\n\n    } else {\n        for (i = 0; i < len; i++) {\n            if (slots[i].pos != i) {\n                ret = njs_value_property_i64_set(vm, this, i, &slots[i].value);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto exception;\n                }\n            }\n        }\n\n        for (i = len; und-- > 0; i++) {\n            ret = njs_value_property_i64_set(vm, this, i,\n                                          njs_value_arg(&njs_value_undefined));\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                goto exception;\n            }\n        }\n\n        for (; i < length; i++) {\n            ret = njs_value_property_i64_delete(vm, this, i, NULL);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                goto exception;\n            }\n        }\n    }\n\n    vm->retval = *this;\n\n    ret = NJS_OK;\n\nexception:\n\n    if (slots != NULL) {\n        njs_mp_free(vm->mem_pool, slots);\n    }\n\n    njs_arr_destroy(&ctx.strings);\n\n    return ret;\n}","target":1,"code_token_length":1317,"total_token_length":1553,"max_tokens_setting":2048}
+{"idx":329922,"func":"composite_glyphs_via_mask (void\t\t\t\t*_dst,\n\t\t\t   cairo_operator_t\t\t op,\n\t\t\t   cairo_surface_t\t\t*_src,\n\t\t\t   int\t\t\t\t src_x,\n\t\t\t   int\t\t\t\t src_y,\n\t\t\t   int\t\t\t\t dst_x,\n\t\t\t   int\t\t\t\t dst_y,\n\t\t\t   cairo_composite_glyphs_info_t *info)\n{\n    cairo_scaled_glyph_t *glyph_cache[64];\n    pixman_image_t *white = _pixman_image_for_color (CAIRO_COLOR_WHITE);\n    cairo_scaled_glyph_t *scaled_glyph;\n    uint8_t buf[2048];\n    pixman_image_t *mask;\n    pixman_format_code_t format;\n    cairo_status_t status;\n    int i;\n\n    TRACE ((stderr, \"%s\\n\", __FUNCTION__));\n\n    if (unlikely (white == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n    \/* XXX convert the glyphs to common formats a8\/a8r8g8b8 to hit\n     * optimised paths through pixman. Should we increase the bit\n     * depth of the target surface, we should reconsider the appropriate\n     * mask formats.\n     *\/\n\n    status = _cairo_scaled_glyph_lookup (info->font,\n\t\t\t\t\t info->glyphs[0].index,\n\t\t\t\t\t CAIRO_SCALED_GLYPH_INFO_SURFACE,\n\t\t\t\t\t &scaled_glyph);\n    if (unlikely (status)) {\n\tpixman_image_unref (white);\n\treturn status;\n    }\n\n    memset (glyph_cache, 0, sizeof (glyph_cache));\n    glyph_cache[info->glyphs[0].index % ARRAY_LENGTH (glyph_cache)] = scaled_glyph;\n\n    format = PIXMAN_a8;\n    i = (info->extents.width + 3) & ~3;\n    if (scaled_glyph->surface->base.content & CAIRO_CONTENT_COLOR) {\n\tformat = PIXMAN_a8r8g8b8;\n\ti = info->extents.width * 4;\n    }\n\n    if (i * info->extents.height > (int) sizeof (buf)) {\n\tmask = pixman_image_create_bits (format,\n\t\t\t\t\tinfo->extents.width,\n\t\t\t\t\tinfo->extents.height,\n\t\t\t\t\tNULL, 0);\n    } else {\n\tmemset (buf, 0, i * info->extents.height);\n\tmask = pixman_image_create_bits (format,\n\t\t\t\t\tinfo->extents.width,\n\t\t\t\t\tinfo->extents.height,\n\t\t\t\t\t(uint32_t *)buf, i);\n    }\n    if (unlikely (mask == NULL)) {\n\tpixman_image_unref (white);\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n    }\n\n    status = CAIRO_STATUS_SUCCESS;\n    for (i = 0; i < info->num_glyphs; i++) {\n\tunsigned long glyph_index = info->glyphs[i].index;\n\tint cache_index = glyph_index % ARRAY_LENGTH (glyph_cache);\n\tcairo_image_surface_t *glyph_surface;\n\tint x, y;\n\n\tscaled_glyph = glyph_cache[cache_index];\n\tif (scaled_glyph == NULL ||\n\t    _cairo_scaled_glyph_index (scaled_glyph) != glyph_index)\n\t{\n\t    status = _cairo_scaled_glyph_lookup (info->font, glyph_index,\n\t\t\t\t\t\t CAIRO_SCALED_GLYPH_INFO_SURFACE,\n\t\t\t\t\t\t &scaled_glyph);\n\n\t    if (unlikely (status)) {\n\t\tpixman_image_unref (mask);\n\t\tpixman_image_unref (white);\n\t\treturn status;\n\t    }\n\n\t    glyph_cache[cache_index] = scaled_glyph;\n\t}\n\n\tglyph_surface = scaled_glyph->surface;\n\tif (glyph_surface->width && glyph_surface->height) {\n\t    if (glyph_surface->base.content & CAIRO_CONTENT_COLOR &&\n\t\tformat == PIXMAN_a8) {\n\t\tpixman_image_t *ca_mask;\n\n\t\tformat = PIXMAN_a8r8g8b8;\n\t\tca_mask = pixman_image_create_bits (format,\n\t\t\t\t\t\t    info->extents.width,\n\t\t\t\t\t\t    info->extents.height,\n\t\t\t\t\t\t    NULL, 0);\n\t\tif (unlikely (ca_mask == NULL)) {\n\t\t    pixman_image_unref (mask);\n\t\t    pixman_image_unref (white);\n\t\t    return _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\t\t}\n\n\t\tpixman_image_composite32 (PIXMAN_OP_SRC,\n\t\t\t\t\t  white, mask, ca_mask,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  info->extents.width,\n\t\t\t\t\t  info->extents.height);\n\t\tpixman_image_unref (mask);\n\t\tmask = ca_mask;\n\t    }\n\n\t    \/* round glyph locations to the nearest pixel *\/\n\t    \/* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug? *\/\n\t    x = _cairo_lround (info->glyphs[i].x -\n\t\t\t       glyph_surface->base.device_transform.x0);\n\t    y = _cairo_lround (info->glyphs[i].y -\n\t\t\t       glyph_surface->base.device_transform.y0);\n\n\t    if (glyph_surface->pixman_format == format) {\n\t\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t\t  glyph_surface->pixman_image, NULL, mask,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x - info->extents.x, y - info->extents.y,\n\t\t\t\t\t  glyph_surface->width,\n\t\t\t\t\t  glyph_surface->height);\n\t    } else {\n\t\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t\t  white, glyph_surface->pixman_image, mask,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x - info->extents.x, y - info->extents.y,\n\t\t\t\t\t  glyph_surface->width,\n\t\t\t\t\t  glyph_surface->height);\n\t    }\n\t}\n    }\n\n    if (format == PIXMAN_a8r8g8b8)\n\tpixman_image_set_component_alpha (mask, TRUE);\n\n    pixman_image_composite32 (_pixman_operator (op),\n\t\t\t      ((cairo_image_source_t *)_src)->pixman_image,\n\t\t\t      mask,\n\t\t\t      to_pixman_image (_dst),\n\t\t\t      info->extents.x + src_x, info->extents.y + src_y,\n\t\t\t      0, 0,\n\t\t\t      info->extents.x - dst_x, info->extents.y - dst_y,\n\t\t\t      info->extents.width, info->extents.height);\n    pixman_image_unref (mask);\n    pixman_image_unref (white);\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":1327,"total_token_length":1563,"max_tokens_setting":2048}
+{"idx":369283,"func":"\nstatic int __init io_uring_init(void)\n{\n#define __BUILD_BUG_VERIFY_ELEMENT(stype, eoffset, etype, ename) do { \\\n\tBUILD_BUG_ON(offsetof(stype, ename) != eoffset); \\\n\tBUILD_BUG_ON(sizeof(etype) != sizeof_field(stype, ename)); \\\n} while (0)\n\n#define BUILD_BUG_SQE_ELEM(eoffset, etype, ename) \\\n\t__BUILD_BUG_VERIFY_ELEMENT(struct io_uring_sqe, eoffset, etype, ename)\n\tBUILD_BUG_ON(sizeof(struct io_uring_sqe) != 64);\n\tBUILD_BUG_SQE_ELEM(0,  __u8,   opcode);\n\tBUILD_BUG_SQE_ELEM(1,  __u8,   flags);\n\tBUILD_BUG_SQE_ELEM(2,  __u16,  ioprio);\n\tBUILD_BUG_SQE_ELEM(4,  __s32,  fd);\n\tBUILD_BUG_SQE_ELEM(8,  __u64,  off);\n\tBUILD_BUG_SQE_ELEM(8,  __u64,  addr2);\n\tBUILD_BUG_SQE_ELEM(16, __u64,  addr);\n\tBUILD_BUG_SQE_ELEM(16, __u64,  splice_off_in);\n\tBUILD_BUG_SQE_ELEM(24, __u32,  len);\n\tBUILD_BUG_SQE_ELEM(28,     __kernel_rwf_t, rw_flags);\n\tBUILD_BUG_SQE_ELEM(28, \/* compat *\/   int, rw_flags);\n\tBUILD_BUG_SQE_ELEM(28, \/* compat *\/ __u32, rw_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  fsync_flags);\n\tBUILD_BUG_SQE_ELEM(28, \/* compat *\/ __u16,  poll_events);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  poll32_events);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  sync_range_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  msg_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  timeout_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  accept_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  cancel_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  open_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  statx_flags);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  fadvise_advice);\n\tBUILD_BUG_SQE_ELEM(28, __u32,  splice_flags);\n\tBUILD_BUG_SQE_ELEM(32, __u64,  user_data);\n\tBUILD_BUG_SQE_ELEM(40, __u16,  buf_index);\n\tBUILD_BUG_SQE_ELEM(40, __u16,  buf_group);\n\tBUILD_BUG_SQE_ELEM(42, __u16,  personality);\n\tBUILD_BUG_SQE_ELEM(44, __s32,  splice_fd_in);\n\tBUILD_BUG_SQE_ELEM(44, __u32,  file_index);\n\n\tBUILD_BUG_ON(sizeof(struct io_uring_files_update) !=\n\t\t     sizeof(struct io_uring_rsrc_update));\n\tBUILD_BUG_ON(sizeof(struct io_uring_rsrc_update) >\n\t\t     sizeof(struct io_uring_rsrc_update2));\n\n\t\/* ->buf_index is u16 *\/\n\tBUILD_BUG_ON(IORING_MAX_REG_BUFFERS >= (1u << 16));\n\n\t\/* should fit into one byte *\/\n\tBUILD_BUG_ON(SQE_VALID_FLAGS >= (1 << 8));\n\tBUILD_BUG_ON(SQE_COMMON_FLAGS >= (1 << 8));\n\tBUILD_BUG_ON((SQE_VALID_FLAGS | SQE_COMMON_FLAGS) != SQE_VALID_FLAGS);\n\n\tBUILD_BUG_ON(ARRAY_SIZE(io_op_defs) != IORING_OP_LAST);\n\tBUILD_BUG_ON(__REQ_F_LAST_BIT > 8 * sizeof(int));\n\n\treq_cachep = KMEM_CACHE(io_kiocb, SLAB_HWCACHE_ALIGN | SLAB_PANIC |\n\t\t\t\tSLAB_ACCOUNT);\n\treturn 0;","target":0,"code_token_length":956,"total_token_length":1192,"max_tokens_setting":2048}
+{"idx":439164,"func":"static Image *ReadAAIImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  register ssize_t\n    x;\n\n  register PixelPacket\n    *q;\n\n  register unsigned char\n    *p;\n\n  size_t\n    height,\n    length,\n    width;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read AAI Dune image.\n  *\/\n  width=ReadBlobLSBLong(image);\n  height=ReadBlobLSBLong(image);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if ((width == 0UL) || (height == 0UL))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  do\n  {\n    \/*\n      Convert AAI raster image to pixel packets.\n    *\/\n    image->columns=width;\n    image->rows=height;\n    image->depth=8;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    pixels=(unsigned char *) AcquireQuantumMemory(image->columns,\n      4*sizeof(*pixels));\n    if (pixels == (unsigned char *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    length=(size_t) 4*image->columns;\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      count=ReadBlob(image,length,pixels);\n      if ((size_t) count != length)\n        {\n          pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n          ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n        }\n      p=pixels;\n      q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n      if (q == (PixelPacket *) NULL)\n        break;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        SetPixelBlue(q,ScaleCharToQuantum(*p++));\n        SetPixelGreen(q,ScaleCharToQuantum(*p++));\n        SetPixelRed(q,ScaleCharToQuantum(*p++));\n        if (*p == 254)\n          *p=255;\n        SetPixelAlpha(q,ScaleCharToQuantum(*p++));\n        if (q->opacity != OpaqueOpacity)\n          image->matte=MagickTrue;\n        q++;\n      }\n      if (SyncAuthenticPixels(image,exception) == MagickFalse)\n        break;\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    width=ReadBlobLSBLong(image);\n    height=ReadBlobLSBLong(image);\n    if ((width != 0UL) && (height != 0UL))\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            return((Image *) NULL);\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((width != 0UL) && (height != 0UL));\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":1098,"total_token_length":1334,"max_tokens_setting":2048}
+{"idx":477946,"func":"int qtm_decompress(struct qtm_stream *qtm, off_t out_bytes) {\n  unsigned int frame_start, frame_end, window_posn, match_offset, range;\n  unsigned char *window, *i_ptr, *i_end, *runsrc, *rundest;\n  int i, j, selector, extra, sym, match_length, ret;\n  unsigned short H, L, C, symf;\n\n  register unsigned int bit_buffer;\n  register unsigned char bits_left;\n  unsigned char bits_needed, bit_run;\n\n  \/* easy answers *\/\n  if (!qtm || (out_bytes < 0)) return CL_ENULLARG;\n  if (qtm->error) return qtm->error;\n\n  \/* flush out any stored-up bytes before we begin *\/\n  i = qtm->o_end - qtm->o_ptr;\n  if ((off_t) i > out_bytes) i = (int) out_bytes;\n  if (i) {\n    if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {\n      return qtm->error = ret;\n    }\n    qtm->o_ptr  += i;\n    out_bytes   -= i;\n  }\n  if (out_bytes == 0) return CL_SUCCESS;\n\n  \/* restore local state *\/\n  QTM_RESTORE_BITS;\n  window = qtm->window;\n  window_posn = qtm->window_posn;\n  frame_start = qtm->frame_start;\n  H = qtm->H;\n  L = qtm->L;\n  C = qtm->C;\n\n  \/* while we do not have enough decoded bytes in reserve: *\/\n  while ((qtm->o_end - qtm->o_ptr) < out_bytes) {\n\n    \/* read header if necessary. Initialises H, L and C *\/\n    if (!qtm->header_read) {\n      H = 0xFFFF; L = 0; QTM_READ_BITS(C, 16);\n      qtm->header_read = 1;\n    }\n\n    \/* decode more, at most up to to frame boundary *\/\n    frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr));\n    if ((frame_start + QTM_FRAME_SIZE) < frame_end) {\n      frame_end = frame_start + QTM_FRAME_SIZE;\n    }\n\n    while (window_posn < frame_end) {\n      QTM_GET_SYMBOL(qtm->model7, selector);\n      if (selector < 4) {\n\tstruct qtm_model *mdl = (selector == 0) ? &qtm->model0 :\n\t                        ((selector == 1) ? &qtm->model1 :\n\t\t\t\t((selector == 2) ? &qtm->model2 :\n                                                   &qtm->model3));\n\tQTM_GET_SYMBOL((*mdl), sym);\n\twindow[window_posn++] = sym;\n      }\n      else {\n\tswitch (selector) {\n\tcase 4: \/* selector 4 = fixed length match (3 bytes) *\/\n\t  QTM_GET_SYMBOL(qtm->model4, sym);\n\t  QTM_READ_BITS(extra, qtm->extra_bits[sym]);\n\t  match_offset = qtm->position_base[sym] + extra + 1;\n\t  match_length = 3;\n\t  break;\n\n\tcase 5: \/* selector 5 = fixed length match (4 bytes) *\/\n\t  QTM_GET_SYMBOL(qtm->model5, sym);\n\t  QTM_READ_BITS(extra, qtm->extra_bits[sym]);\n\t  match_offset = qtm->position_base[sym] + extra + 1;\n\t  match_length = 4;\n\t  break;\n\n\tcase 6: \/* selector 6 = variable length match *\/\n\t  QTM_GET_SYMBOL(qtm->model6len, sym);\n\t  QTM_READ_BITS(extra, qtm->length_extra[sym]);\n\t  match_length = qtm->length_base[sym] + extra + 5;\n\n\t  QTM_GET_SYMBOL(qtm->model6, sym);\n\t  QTM_READ_BITS(extra, qtm->extra_bits[sym]);\n\t  match_offset = qtm->position_base[sym] + extra + 1;\n\t  break;\n\n\tdefault:\n\t  \/* should be impossible, model7 can only return 0-6 *\/\n\t  return qtm->error = CL_EFORMAT;\n\t}\n\n\tif (window_posn + match_length > qtm->window_size) {\n\t  cli_dbgmsg(\"qtm_decompress: match ran over window wrap\\n\");\n\t  return qtm->error = CL_EFORMAT;\n\t}\n\n\trundest = &window[window_posn];\n\ti = match_length;\n\t\/* does match offset wrap the window? *\/\n\tif (match_offset > window_posn) {\n\t  \/* j = length from match offset to end of window *\/\n\t  j = match_offset - window_posn;\n\t  if (j > (int) qtm->window_size) {\n\t    cli_dbgmsg(\"qtm_decompress: match offset beyond window boundaries\\n\");\n\t    return qtm->error = CL_EFORMAT;\n\t  }\n\t  runsrc = &window[qtm->window_size - j];\n\t  if (j < i) {\n\t    \/* if match goes over the window edge, do two copy runs *\/\n\t    i -= j; while (j-- > 0) *rundest++ = *runsrc++;\n\t    runsrc = window;\n\t  }\n\t  while (i-- > 0) *rundest++ = *runsrc++;\n\t}\n\telse {\n\t  runsrc = rundest - match_offset;\n\t  if(i > (int) (qtm->window_size - window_posn))\n\t    i = qtm->window_size - window_posn;\n\t  while (i-- > 0) *rundest++ = *runsrc++;\n\t}\n\twindow_posn += match_length;\n      }\n    } \/* while (window_posn < frame_end) *\/\n\n    qtm->o_end = &window[window_posn];\n\n    \/* another frame completed? *\/\n    if ((window_posn - frame_start) >= QTM_FRAME_SIZE) {\n      if ((window_posn - frame_start) != QTM_FRAME_SIZE) {\n\tcli_dbgmsg(\"qtm_decompress: overshot frame alignment\\n\");\n\treturn qtm->error = CL_EFORMAT;\n      }\n\n      \/* re-align input *\/\n      if (bits_left & 7) QTM_REMOVE_BITS(bits_left & 7);\n      do { QTM_READ_BITS(i, 8); } while (i != 0xFF);\n      qtm->header_read = 0;\n\n      \/* window wrap? *\/\n      if (window_posn == qtm->window_size) {\n\t\/* flush all currently stored data *\/\n\ti = (qtm->o_end - qtm->o_ptr);\n\tif (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {\n\t  return qtm->error = ret;\n\t}\n\tout_bytes -= i;\n\tqtm->o_ptr = &window[0];\n\tqtm->o_end = &window[0];\n\twindow_posn = 0;\n      }\n\n      frame_start = window_posn;\n    }\n\n  } \/* while (more bytes needed) *\/\n\n  if (out_bytes) {\n    i = (int) out_bytes;\n    if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {\n      return qtm->error = ret;\n    }\n    qtm->o_ptr += i;\n  }\n\n  \/* store local state *\/\n  QTM_STORE_BITS;\n  qtm->window_posn = window_posn;\n  qtm->frame_start = frame_start;\n  qtm->H = H;\n  qtm->L = L;\n  qtm->C = C;\n\n  return CL_SUCCESS;\n}","target":0,"code_token_length":1674,"total_token_length":1910,"max_tokens_setting":2048}
+{"idx":245693,"func":"njs_array_prototype_unshift(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    double       idx;\n    int64_t      from, to, length;\n    njs_int_t    ret;\n    njs_uint_t   n;\n    njs_array_t  *array, *keys;\n    njs_value_t  *this, entry;\n\n    this = njs_argument(args, 0);\n    length = 0;\n    n = nargs - 1;\n\n    ret = njs_value_to_object(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_fast_path(njs_is_fast_array(this))) {\n        array = njs_array(this);\n\n        if (n != 0) {\n            ret = njs_array_expand(vm, array, n, 0);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            array->length += n;\n            n = nargs;\n\n            do {\n                n--;\n                \/* GC: njs_retain(&args[n]); *\/\n                array->start--;\n                array->start[0] = args[n];\n            } while (n > 1);\n        }\n\n        njs_set_number(&vm->retval, array->length);\n\n        return NJS_OK;\n    }\n\n    ret = njs_object_length(vm, this, &length);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    if (n == 0) {\n        goto done;\n    }\n\n    if (njs_slow_path((length + n) > NJS_MAX_LENGTH)) {\n        njs_type_error(vm, \"Invalid length\");\n        return NJS_ERROR;\n    }\n\n    if (!njs_fast_object(length)) {\n        keys = njs_array_indices(vm, this);\n        if (njs_slow_path(keys == NULL)) {\n            return NJS_ERROR;\n        }\n\n        from = keys->length;\n\n        while (from > 0) {\n            ret = njs_value_property_delete(vm, this, &keys->start[--from],\n                                            &entry, 1);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                njs_array_destroy(vm, keys);\n                return ret;\n            }\n\n            if (ret == NJS_OK) {\n                idx = njs_string_to_index(&keys->start[from]) + n;\n\n                ret = njs_value_property_i64_set(vm, this, idx, &entry);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    njs_array_destroy(vm, keys);\n                    return ret;\n                }\n            }\n        }\n\n        njs_array_destroy(vm, keys);\n\n        length += n;\n\n        goto copy;\n    }\n\n    from = length;\n    length += n;\n    to = length;\n\n    while (from > 0) {\n        ret = njs_value_property_i64_delete(vm, this, --from, &entry);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n\n        to--;\n\n        if (ret == NJS_OK) {\n            ret = njs_value_property_i64_set(vm, this, to, &entry);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return ret;\n            }\n        }\n    }\n\ncopy:\n\n    for (n = 1; n < nargs; n++) {\n        ret = njs_value_property_i64_set(vm, this, n - 1, &args[n]);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n    }\n\ndone:\n\n    ret = njs_object_length_set(vm, this, length);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    njs_set_number(&vm->retval, length);\n\n    return NJS_OK;\n}","target":0,"code_token_length":835,"total_token_length":1071,"max_tokens_setting":2048}
+{"idx":195039,"func":"  void operator()(OpKernelContext* ctx, const Tensor& input,\n                  const Tensor& filter, int row_stride, int col_stride,\n                  int row_dilation, int col_dilation, const Padding& padding,\n                  const std::vector<int64_t>& explicit_paddings, Tensor* output,\n                  TensorFormat data_format) {\n    DCHECK(data_format == FORMAT_NHWC)\n        << \"Grouped conv implementation only \"\n           \"supports NHWC tensor format for now.\";\n\n    const int64_t in_depth = input.dim_size(3);\n    const int64_t patch_depth = filter.dim_size(2);\n    const int64_t num_groups = in_depth \/ patch_depth;\n\n    \/\/ Shuffle input\/filter tensors to have group as a leading dimension.\n    std::array<int64_t, 5> shuffle({3, 0, 1, 2, 4});\n\n    \/\/ Compute pre shuffle dimemnsions.\n    auto pre_shuffle = [&](const Tensor& tensor) -> std::array<int64, 5> {\n      return {tensor.dim_size(0), tensor.dim_size(1), tensor.dim_size(2),\n              num_groups, tensor.dim_size(3) \/ num_groups};\n    };\n\n    \/\/ Compute post shuffle dimemnsions.\n    auto post_shuffle = [&](const Tensor& tensor) -> std::array<int64, 5> {\n      return {num_groups, tensor.dim_size(0), tensor.dim_size(1),\n              tensor.dim_size(2), tensor.dim_size(3) \/ num_groups};\n    };\n\n    auto& device = ctx->eigen_device<CPUDevice>();\n\n    absl::BlockingCounter shuffles_completed(2);\n    auto on_shuffled = [&]() { shuffles_completed.DecrementCount(); };\n\n    \/\/ Shuffle input into temporary tensor.\n    Tensor input_shuffled(input.dtype(), TensorShape(post_shuffle(input)));\n    input_shuffled.tensor<T, 5>().device(device, on_shuffled) =\n        input.shaped<T, 5>(pre_shuffle(input)).shuffle(shuffle);\n\n    \/\/ Shuffle filter into temporary tensor.\n    Tensor filter_shuffled(filter.dtype(), TensorShape(post_shuffle(filter)));\n    filter_shuffled.tensor<T, 5>().device(device, on_shuffled) =\n        filter.shaped<T, 5>(pre_shuffle(filter)).shuffle(shuffle);\n\n    \/\/ Wait for the completion of input\/filter shuffles.\n    shuffles_completed.Wait();\n\n    \/\/ Write group convolution results into temporary output tensor.\n    Tensor output_shuffled(output->dtype(), TensorShape(post_shuffle(*output)));\n\n    for (int64_t i = 0; i < num_groups; ++i) {\n      \/\/ TODO(ezhulenev): Run this loop using `parallelFor` (regular parallelFor\n      \/\/ will lead to deadlock, SpatialConvolution has to use async Eigen\n      \/\/ assignment). This requires small changes to Eigen to support async\n      \/\/ exeuction for tensor chipping operation.\n\n      \/\/ TODO(ezhulenev): Grouped convolution should also support 1x1 filter\n      \/\/ optimization.\n\n      auto input_slice = input_shuffled.tensor<T, 5>().template chip<0>(i);\n      auto filter_slice = filter_shuffled.tensor<T, 5>().template chip<0>(i);\n      auto output_slice = output_shuffled.tensor<T, 5>().template chip<0>(i);\n\n      if (padding == EXPLICIT) {\n        functor::SpatialConvolution<CPUDevice, T>()(\n            ctx->eigen_device<CPUDevice>(), output_slice, input_slice,\n            filter_slice, row_stride, col_stride, row_dilation, col_dilation,\n            static_cast<int>(explicit_paddings[2]),\n            static_cast<int>(explicit_paddings[3]),\n            static_cast<int>(explicit_paddings[4]),\n            static_cast<int>(explicit_paddings[5]));\n      } else {\n        functor::SpatialConvolution<CPUDevice, T>()(\n            ctx->eigen_device<CPUDevice>(), output_slice, input_slice,\n            filter_slice, row_stride, col_stride, row_dilation, col_dilation,\n            BrainPadding2EigenPadding(padding));\n      }\n    }\n\n    \/\/ Shuffle temporary output back into pre-shuffled shape.\n    std::array<int64_t, 5> rev_shuffle({1, 2, 3, 0, 4});\n    output->shaped<T, 5>(pre_shuffle(*output)).device(device) =\n        output_shuffled.tensor<T, 5>().shuffle(rev_shuffle);\n  }","target":1,"code_token_length":943,"total_token_length":1179,"max_tokens_setting":2048}
+{"idx":224862,"func":"  void Compute(OpKernelContext *ctx) override {\n    const Tensor *indices_t, *values_t, *shape_t, *dense_t;\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_indices\", &indices_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_values\", &values_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_shape\", &shape_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"dense\", &dense_t));\n\n    \/\/ Validations.\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices_t->shape()),\n                errors::InvalidArgument(\n                    \"Input sp_indices should be a matrix but received shape: \",\n                    indices_t->shape().DebugString()));\n    OP_REQUIRES(ctx,\n                TensorShapeUtils::IsVector(values_t->shape()) &&\n                    TensorShapeUtils::IsVector(shape_t->shape()),\n                errors::InvalidArgument(\n                    \"Inputs sp_values and sp_shape should be vectors \"\n                    \"but received shapes: \",\n                    values_t->shape().DebugString(), \" and \",\n                    shape_t->shape().DebugString()));\n    OP_REQUIRES(\n        ctx, TensorShapeUtils::IsVector(shape_t->shape()),\n        errors::InvalidArgument(\"Input sp_shape must be a vector. Got: \",\n                                shape_t->shape().DebugString()));\n    OP_REQUIRES(\n        ctx, values_t->dim_size(0) == indices_t->dim_size(0),\n        errors::InvalidArgument(\n            \"The first dimension of values and indices should match. (\",\n            values_t->dim_size(0), \" vs. \", indices_t->dim_size(0), \")\"));\n    OP_REQUIRES(\n        ctx, shape_t->shape().dim_size(0) == indices_t->shape().dim_size(1),\n        errors::InvalidArgument(\n            \"Number of dimensions must match second dimension of indices. \",\n            \"Got \", shape_t->shape().dim_size(0),\n            \" dimensions, indices shape: \", indices_t->shape().DebugString()));\n    OP_REQUIRES(ctx, shape_t->NumElements() > 0,\n                errors::InvalidArgument(\n                    \"The shape argument requires at least one element.\"));\n\n    const auto indices_mat = indices_t->matrix<int64_t>();\n    const auto shape_vec = shape_t->vec<int64_t>();\n    TensorShape lhs_shape;\n    OP_REQUIRES_OK(ctx, TensorShape::BuildTensorShape(shape_vec, &lhs_shape));\n    const auto lhs_dims = BCast::FromShape(lhs_shape);\n    const auto rhs_dims = BCast::FromShape(dense_t->shape());\n    BCast b(lhs_dims, rhs_dims, false);  \/\/ false for keeping the same num dims.\n\n    \/\/ True iff (size(lhs) >= size(rhs)) and all dims in lhs is greater or equal\n    \/\/ to dims in rhs (from right to left).\n    auto VecGreaterEq = [](ArraySlice<int64_t> lhs, ArraySlice<int64_t> rhs) {\n      if (lhs.size() < rhs.size()) return false;\n      for (size_t i = 0; i < rhs.size(); ++i) {\n        if (lhs[lhs.size() - 1 - i] < rhs[rhs.size() - 1 - i]) return false;\n      }\n      return true;\n    };\n    OP_REQUIRES(ctx, VecGreaterEq(lhs_dims, rhs_dims) && b.IsValid(),\n                errors::InvalidArgument(\n                    \"SparseDenseBinaryOpShared broadcasts dense to sparse \"\n                    \"only; got incompatible shapes: [\",\n                    absl::StrJoin(lhs_dims, \",\"), \"] vs. [\",\n                    absl::StrJoin(rhs_dims, \",\"), \"]\"));\n\n    Tensor *output_values = nullptr;\n    Tensor dense_gathered;\n    const int64_t nnz = indices_t->dim_size(0);\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(0, TensorShape({nnz}), &output_values));\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_temp(DataTypeToEnum<T>::value, TensorShape({nnz}),\n                                &dense_gathered));\n    bool op_is_div = false;\n    if (absl::StrContains(ctx->op_kernel().type_string_view(), \"Div\")) {\n      op_is_div = true;\n    }\n    \/\/ Pulls relevant entries from the dense side, with reshape and broadcasting\n    \/\/ *of the dense side* taken into account.  Use a TensorRef to avoid blowing\n    \/\/ up memory.\n    \/\/\n    \/\/ We can directly use the sparse indices to look up dense side, because\n    \/\/ \"b.y_reshape()\" and \"b.y_bcast()\" are guaranteed to have rank \"ndims\".\n    auto dense_gathered_flat = dense_gathered.flat<T>();\n    const int ndims = lhs_dims.size();\n    switch (ndims) {\n#define CASE(NDIM)                                                             \\\n  case NDIM: {                                                                 \\\n    TensorRef<Eigen::Tensor<const T, NDIM, Eigen::RowMajor>> rhs_ref =         \\\n        dense_t->shaped<T, NDIM>(b.y_reshape())                                \\\n            .broadcast(BCast::ToIndexArray<NDIM>(b.y_bcast()));                \\\n    Eigen::array<Eigen::DenseIndex, NDIM> idx;                                 \\\n    bool indices_valid = true;                                                 \\\n    for (int i = 0; i < nnz; ++i) {                                            \\\n      for (int d = 0; d < NDIM; ++d) {                                         \\\n        idx[d] = internal::SubtleMustCopy(indices_mat(i, d));                  \\\n        if (!FastBoundsCheck(idx[d], rhs_ref.dimension(d))) {                  \\\n          indices_valid = false;                                               \\\n        }                                                                      \\\n      }                                                                        \\\n      OP_REQUIRES(                                                             \\\n          ctx, indices_valid,                                                  \\\n          errors::InvalidArgument(\"Provided indices are out-of-bounds w.r.t. \" \\\n                                  \"dense side with broadcasted shape\"));       \\\n      dense_gathered_flat(i) = rhs_ref.coeff(idx);                             \\\n      if (op_is_div) {                                                         \\\n        OP_REQUIRES(ctx, dense_gathered_flat(i) != 0,                          \\\n                    errors::InvalidArgument(                                   \\\n                        \"SparseDenseCwiseDiv cannot divide by zero,\"           \\\n                        \"but input dense tensor contains zero \"));             \\\n      }                                                                        \\\n    }                                                                          \\\n    break;                                                                     \\\n  }\n\n      CASE(1);\n      CASE(2);\n      CASE(3);\n      CASE(4);\n      CASE(5);\n      default:\n        OP_REQUIRES(\n            ctx, false,\n            errors::InvalidArgument(\"Only tensors with ranks between 1 and 5 \"\n                                    \"are currently supported.  Tensor rank: \",\n                                    ndims));\n#undef CASE\n    }\n\n    output_values->flat<T>().device(ctx->eigen_device<Device>()) =\n        values_t->flat<T>().binaryExpr(dense_gathered_flat,\n                                       typename Functor::func());\n  }","target":0,"code_token_length":1466,"total_token_length":1702,"max_tokens_setting":2048}
+{"idx":484797,"func":"static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)\n{\n\tstruct netfront_info *np = netdev_priv(dev);\n\tstruct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats);\n\tstruct xen_netif_tx_request *first_tx;\n\tunsigned int i;\n\tint notify;\n\tint slots;\n\tstruct page *page;\n\tunsigned int offset;\n\tunsigned int len;\n\tunsigned long flags;\n\tstruct netfront_queue *queue = NULL;\n\tstruct xennet_gnttab_make_txreq info = { };\n\tunsigned int num_queues = dev->real_num_tx_queues;\n\tu16 queue_index;\n\tstruct sk_buff *nskb;\n\n\t\/* Drop the packet if no queues are set up *\/\n\tif (num_queues < 1)\n\t\tgoto drop;\n\tif (unlikely(np->broken))\n\t\tgoto drop;\n\t\/* Determine which queue to transmit this SKB on *\/\n\tqueue_index = skb_get_queue_mapping(skb);\n\tqueue = &np->queues[queue_index];\n\n\t\/* If skb->len is too big for wire format, drop skb and alert\n\t * user about misconfiguration.\n\t *\/\n\tif (unlikely(skb->len > XEN_NETIF_MAX_TX_SIZE)) {\n\t\tnet_alert_ratelimited(\n\t\t\t\"xennet: skb->len = %u, too big for wire format\\n\",\n\t\t\tskb->len);\n\t\tgoto drop;\n\t}\n\n\tslots = xennet_count_skb_slots(skb);\n\tif (unlikely(slots > MAX_XEN_SKB_FRAGS + 1)) {\n\t\tnet_dbg_ratelimited(\"xennet: skb rides the rocket: %d slots, %d bytes\\n\",\n\t\t\t\t    slots, skb->len);\n\t\tif (skb_linearize(skb))\n\t\t\tgoto drop;\n\t}\n\n\tpage = virt_to_page(skb->data);\n\toffset = offset_in_page(skb->data);\n\n\t\/* The first req should be at least ETH_HLEN size or the packet will be\n\t * dropped by netback.\n\t *\n\t * If the backend is not trusted bounce all data to zeroed pages to\n\t * avoid exposing contiguous data on the granted page not belonging to\n\t * the skb.\n\t *\/\n\tif (np->bounce || unlikely(PAGE_SIZE - offset < ETH_HLEN)) {\n\t\tnskb = bounce_skb(skb);\n\t\tif (!nskb)\n\t\t\tgoto drop;\n\t\tdev_consume_skb_any(skb);\n\t\tskb = nskb;\n\t\tpage = virt_to_page(skb->data);\n\t\toffset = offset_in_page(skb->data);\n\t}\n\n\tlen = skb_headlen(skb);\n\n\tspin_lock_irqsave(&queue->tx_lock, flags);\n\n\tif (unlikely(!netif_carrier_ok(dev) ||\n\t\t     (slots > 1 && !xennet_can_sg(dev)) ||\n\t\t     netif_needs_gso(skb, netif_skb_features(skb)))) {\n\t\tspin_unlock_irqrestore(&queue->tx_lock, flags);\n\t\tgoto drop;\n\t}\n\n\t\/* First request for the linear area. *\/\n\tinfo.queue = queue;\n\tinfo.skb = skb;\n\tinfo.page = page;\n\tfirst_tx = xennet_make_first_txreq(&info, offset, len);\n\toffset += info.tx_local.size;\n\tif (offset == PAGE_SIZE) {\n\t\tpage++;\n\t\toffset = 0;\n\t}\n\tlen -= info.tx_local.size;\n\n\tif (skb->ip_summed == CHECKSUM_PARTIAL)\n\t\t\/* local packet? *\/\n\t\tfirst_tx->flags |= XEN_NETTXF_csum_blank |\n\t\t\t\t   XEN_NETTXF_data_validated;\n\telse if (skb->ip_summed == CHECKSUM_UNNECESSARY)\n\t\t\/* remote but checksummed. *\/\n\t\tfirst_tx->flags |= XEN_NETTXF_data_validated;\n\n\t\/* Optional extra info after the first request. *\/\n\tif (skb_shinfo(skb)->gso_size) {\n\t\tstruct xen_netif_extra_info *gso;\n\n\t\tgso = (struct xen_netif_extra_info *)\n\t\t\tRING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++);\n\n\t\tfirst_tx->flags |= XEN_NETTXF_extra_info;\n\n\t\tgso->u.gso.size = skb_shinfo(skb)->gso_size;\n\t\tgso->u.gso.type = (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) ?\n\t\t\tXEN_NETIF_GSO_TYPE_TCPV6 :\n\t\t\tXEN_NETIF_GSO_TYPE_TCPV4;\n\t\tgso->u.gso.pad = 0;\n\t\tgso->u.gso.features = 0;\n\n\t\tgso->type = XEN_NETIF_EXTRA_TYPE_GSO;\n\t\tgso->flags = 0;\n\t}\n\n\t\/* Requests for the rest of the linear area. *\/\n\txennet_make_txreqs(&info, page, offset, len);\n\n\t\/* Requests for all the frags. *\/\n\tfor (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {\n\t\tskb_frag_t *frag = &skb_shinfo(skb)->frags[i];\n\t\txennet_make_txreqs(&info, skb_frag_page(frag),\n\t\t\t\t\tskb_frag_off(frag),\n\t\t\t\t\tskb_frag_size(frag));\n\t}\n\n\t\/* First request has the packet length. *\/\n\tfirst_tx->size = skb->len;\n\n\t\/* timestamp packet in software *\/\n\tskb_tx_timestamp(skb);\n\n\txennet_mark_tx_pending(queue);\n\n\tRING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify);\n\tif (notify)\n\t\tnotify_remote_via_irq(queue->tx_irq);\n\n\tu64_stats_update_begin(&tx_stats->syncp);\n\ttx_stats->bytes += skb->len;\n\ttx_stats->packets++;\n\tu64_stats_update_end(&tx_stats->syncp);\n\n\t\/* Note: It is not safe to access skb after xennet_tx_buf_gc()! *\/\n\txennet_tx_buf_gc(queue);\n\n\tif (!netfront_tx_slot_available(queue))\n\t\tnetif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id));\n\n\tspin_unlock_irqrestore(&queue->tx_lock, flags);\n\n\treturn NETDEV_TX_OK;\n\n drop:\n\tdev->stats.tx_dropped++;\n\tdev_kfree_skb_any(skb);\n\treturn NETDEV_TX_OK;\n}","target":0,"code_token_length":1278,"total_token_length":1514,"max_tokens_setting":2048}
+{"idx":366306,"func":"SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags,\n\t\tunsigned int, attr_flags)\n{\n\tstruct mnt_namespace *ns;\n\tstruct fs_context *fc;\n\tstruct file *file;\n\tstruct path newmount;\n\tstruct mount *mnt;\n\tstruct fd f;\n\tunsigned int mnt_flags = 0;\n\tlong ret;\n\n\tif (!may_mount())\n\t\treturn -EPERM;\n\n\tif ((flags & ~(FSMOUNT_CLOEXEC)) != 0)\n\t\treturn -EINVAL;\n\n\tif (attr_flags & ~FSMOUNT_VALID_FLAGS)\n\t\treturn -EINVAL;\n\n\tmnt_flags = attr_flags_to_mnt_flags(attr_flags);\n\n\tswitch (attr_flags & MOUNT_ATTR__ATIME) {\n\tcase MOUNT_ATTR_STRICTATIME:\n\t\tbreak;\n\tcase MOUNT_ATTR_NOATIME:\n\t\tmnt_flags |= MNT_NOATIME;\n\t\tbreak;\n\tcase MOUNT_ATTR_RELATIME:\n\t\tmnt_flags |= MNT_RELATIME;\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tf = fdget(fs_fd);\n\tif (!f.file)\n\t\treturn -EBADF;\n\n\tret = -EINVAL;\n\tif (f.file->f_op != &fscontext_fops)\n\t\tgoto err_fsfd;\n\n\tfc = f.file->private_data;\n\n\tret = mutex_lock_interruptible(&fc->uapi_mutex);\n\tif (ret < 0)\n\t\tgoto err_fsfd;\n\n\t\/* There must be a valid superblock or we can't mount it *\/\n\tret = -EINVAL;\n\tif (!fc->root)\n\t\tgoto err_unlock;\n\n\tret = -EPERM;\n\tif (mount_too_revealing(fc->root->d_sb, &mnt_flags)) {\n\t\tpr_warn(\"VFS: Mount too revealing\\n\");\n\t\tgoto err_unlock;\n\t}\n\n\tret = -EBUSY;\n\tif (fc->phase != FS_CONTEXT_AWAITING_MOUNT)\n\t\tgoto err_unlock;\n\n\tret = -EPERM;\n\tif ((fc->sb_flags & SB_MANDLOCK) && !may_mandlock())\n\t\tgoto err_unlock;\n\n\tnewmount.mnt = vfs_create_mount(fc);\n\tif (IS_ERR(newmount.mnt)) {\n\t\tret = PTR_ERR(newmount.mnt);\n\t\tgoto err_unlock;\n\t}\n\tnewmount.dentry = dget(fc->root);\n\tnewmount.mnt->mnt_flags = mnt_flags;\n\n\t\/* We've done the mount bit - now move the file context into more or\n\t * less the same state as if we'd done an fspick().  We don't want to\n\t * do any memory allocation or anything like that at this point as we\n\t * don't want to have to handle any errors incurred.\n\t *\/\n\tvfs_clean_context(fc);\n\n\tns = alloc_mnt_ns(current->nsproxy->mnt_ns->user_ns, true);\n\tif (IS_ERR(ns)) {\n\t\tret = PTR_ERR(ns);\n\t\tgoto err_path;\n\t}\n\tmnt = real_mount(newmount.mnt);\n\tmnt->mnt_ns = ns;\n\tns->root = mnt;\n\tns->mounts = 1;\n\tlist_add(&mnt->mnt_list, &ns->list);\n\tmntget(newmount.mnt);\n\n\t\/* Attach to an apparent O_PATH fd with a note that we need to unmount\n\t * it, not just simply put it.\n\t *\/\n\tfile = dentry_open(&newmount, O_PATH, fc->cred);\n\tif (IS_ERR(file)) {\n\t\tdissolve_on_fput(newmount.mnt);\n\t\tret = PTR_ERR(file);\n\t\tgoto err_path;\n\t}\n\tfile->f_mode |= FMODE_NEED_UNMOUNT;\n\n\tret = get_unused_fd_flags((flags & FSMOUNT_CLOEXEC) ? O_CLOEXEC : 0);\n\tif (ret >= 0)\n\t\tfd_install(ret, file);\n\telse\n\t\tfput(file);\n\nerr_path:\n\tpath_put(&newmount);\nerr_unlock:\n\tmutex_unlock(&fc->uapi_mutex);\nerr_fsfd:\n\tfdput(f);\n\treturn ret;\n}","target":0,"code_token_length":822,"total_token_length":1058,"max_tokens_setting":2048}
+{"idx":358129,"func":"START_TEST (test_send_sonmp)\n{\n\tint n;\n\t\/* Packet we should build:\nIEEE 802.3 Ethernet \n    Destination: Bay-Networks-(Synoptics)-autodiscovery (01:00:81:00:01:00)\n    Source: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)\n    Length: 19\nLogical-Link Control\n    DSAP: SNAP (0xaa)\n    IG Bit: Individual\n    SSAP: SNAP (0xaa)\n    CR Bit: Command\n    Control field: U, func=UI (0x03)\n        000. 00.. = Command: Unnumbered Information (0x00)\n        .... ..11 = Frame type: Unnumbered frame (0x03)\n    Organization Code: Nortel Networks SONMP (0x000081)\n    PID: SONMP segment hello (0x01a2)\nNortel Networks \/ SynOptics Network Management Protocol\n    NMM IP address: 172.17.142.37 (172.17.142.37)\n    Segment Identifier: 0x000004\n    Chassis type: Unknown (1)\n    Backplane type: ethernet, fast ethernet and gigabit ethernet (12)\n    NMM state: New (3)\n    Number of links: 1\n\nIEEE 802.3 Ethernet \n    Destination: Bay-Networks-(Synoptics)-autodiscovery (01:00:81:00:01:01)\n    Source: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)\n    Length: 19\nLogical-Link Control\n    DSAP: SNAP (0xaa)\n    IG Bit: Individual\n    SSAP: SNAP (0xaa)\n    CR Bit: Command\n    Control field: U, func=UI (0x03)\n        000. 00.. = Command: Unnumbered Information (0x00)\n        .... ..11 = Frame type: Unnumbered frame (0x03)\n    Organization Code: Nortel Networks SONMP (0x000081)\n    PID: SONMP flatnet hello (0x01a1)\nNortel Networks \/ SynOptics Network Management Protocol\n    NMM IP address: 172.17.142.37 (172.17.142.37)\n    Segment Identifier: 0x000004\n    Chassis type: Unknown (1)\n    Backplane type: ethernet, fast ethernet and gigabit ethernet (12)\n    NMM state: New (3)\n    Number of links: 1\n\t*\/\n\tchar pkt1[] = {\n\t\t0x01, 0x00, 0x81, 0x00, 0x01, 0x00, 0x5e, 0x10,\n\t\t0x8e, 0xe7, 0x84, 0xad, 0x00, 0x13, 0xaa, 0xaa,\n\t\t0x03, 0x00, 0x00, 0x81, 0x01, 0xa2, 0xac, 0x11,\n\t\t0x8e, 0x25, 0x00, 0x00, 0x04, 0x01, 0x0c, 0x03,\n\t\t0x01 };\n\tchar pkt2[] = {\n\t\t0x01, 0x00, 0x81, 0x00, 0x01, 0x01, 0x5e, 0x10,\n\t\t0x8e, 0xe7, 0x84, 0xad, 0x00, 0x13, 0xaa, 0xaa,\n\t\t0x03, 0x00, 0x00, 0x81, 0x01, 0xa1, 0xac, 0x11,\n\t\t0x8e, 0x25, 0x00, 0x00, 0x04, 0x01, 0x0c, 0x03,\n\t\t0x01 };\n\tstruct packet *pkt;\n\tin_addr_t addr;\t\n\tstruct lldpd_mgmt *mgmt;\n\n\t\/* Populate port and chassis *\/\n\thardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;\n\thardware.h_lport.p_id = \"Not used\";\n\thardware.h_lport.p_id_len = strlen(hardware.h_lport.p_id);\n\tchassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;\n\tchassis.c_id = macaddress;\n\tchassis.c_id_len = ETHER_ADDR_LEN;\n\tTAILQ_INIT(&chassis.c_mgmt);\n\taddr = inet_addr(\"172.17.142.37\");\n\tmgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4,\n\t\t\t\t&addr, sizeof(in_addr_t), 0);\n\tif (mgmt == NULL)\n\t\tck_abort();\n\tTAILQ_INSERT_TAIL(&chassis.c_mgmt, mgmt, m_entries);\n\n\t\/* Build packet *\/\n\tn = sonmp_send(NULL, &hardware);\n\tif (n != 0) {\n\t\tfail(\"unable to build packet\");\n\t\treturn;\n\t}\n\tif (TAILQ_EMPTY(&pkts)) {\n\t\tfail(\"no packets sent\");\n\t\treturn;\n\t}\n\tpkt = TAILQ_FIRST(&pkts);\n\tck_assert_int_eq(pkt->size, sizeof(pkt1));\n\tfail_unless(memcmp(pkt->data, pkt1, sizeof(pkt1)) == 0);\n\tpkt = TAILQ_NEXT(pkt, next);\n\tif (!pkt) {\n\t\tfail(\"need one more packet\");\n\t\treturn;\n\t}\n\tck_assert_int_eq(pkt->size, sizeof(pkt2));\n\tfail_unless(memcmp(pkt->data, pkt2, sizeof(pkt2)) == 0);\n\tfail_unless(TAILQ_NEXT(pkt, next) == NULL, \"more than two packets sent\");\n}","target":0,"code_token_length":1441,"total_token_length":1677,"max_tokens_setting":2048}
+{"idx":270357,"func":"parser_parse_export_statement (parser_context_t *context_p) \/**< context *\/\n{\n  JERRY_ASSERT (context_p->token.type == LEXER_KEYW_EXPORT);\n  JERRY_ASSERT (context_p->module_names_p == NULL);\n\n  parser_module_check_request_place (context_p);\n\n  bool consume_last_statement = false;\n\n  lexer_next_token (context_p);\n  switch (context_p->token.type)\n  {\n    case LEXER_KEYW_DEFAULT:\n    {\n      scanner_location_t location;\n      scanner_get_location (&location, context_p);\n\n      context_p->status_flags |= PARSER_MODULE_STORE_IDENT;\n\n      lexer_next_token (context_p);\n\n      if (context_p->token.type == LEXER_LITERAL\n          && lexer_token_is_async (context_p)\n          && context_p->next_scanner_info_p->source_p == context_p->source_p\n          && context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION)\n      {\n#if JERRY_FUNCTION_TO_STRING\n        context_p->function_start_p = context_p->token.lit_location.char_p;\n#endif \/* JERRY_FUNCTION_TO_STRING *\/\n        lexer_next_token (context_p);\n      }\n\n      if (context_p->token.type == LEXER_KEYW_CLASS)\n      {\n        context_p->status_flags |= PARSER_MODULE_DEFAULT_CLASS_OR_FUNC;\n        parser_parse_class (context_p, true);\n        consume_last_statement = true;\n      }\n      else if (context_p->token.type == LEXER_KEYW_FUNCTION)\n      {\n        context_p->status_flags |= PARSER_MODULE_DEFAULT_CLASS_OR_FUNC;\n        parser_parse_function_statement (context_p);\n        consume_last_statement = true;\n      }\n      else\n      {\n        \/* Assignment expression *\/\n        scanner_set_location (context_p, &location);\n\n        \/* 15.2.3.5 Use the synthetic name '*default*' as the identifier. *\/\n        lexer_construct_literal_object (context_p, &lexer_default_literal, lexer_default_literal.type);\n\n        context_p->token.lit_location.type = LEXER_IDENT_LITERAL;\n        parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);\n\n        \/* Do not overwrite this identifier. *\/\n        context_p->status_flags &= (uint32_t) ~PARSER_MODULE_STORE_IDENT;\n        context_p->module_identifier_lit_p = context_p->lit_object.literal_p;\n\n        \/* Fake an assignment to the default identifier *\/\n        context_p->token.type = LEXER_ASSIGN;\n\n        parser_parse_expression_statement (context_p, PARSE_EXPR_NO_COMMA | PARSE_EXPR_HAS_LITERAL);\n      }\n\n      ecma_string_t *name_p = parser_new_ecma_string_from_literal (context_p->module_identifier_lit_p);\n\n      ecma_string_t *export_name_p = ecma_get_magic_string (LIT_MAGIC_STRING_DEFAULT);\n\n      if (parser_module_check_duplicate_export (context_p, export_name_p))\n      {\n        ecma_deref_ecma_string (name_p);\n        ecma_deref_ecma_string (export_name_p);\n        parser_raise_error (context_p, PARSER_ERR_DUPLICATED_EXPORT_IDENTIFIER);\n      }\n\n      parser_module_add_names_to_node (context_p,\n                                       export_name_p,\n                                       name_p);\n      ecma_deref_ecma_string (name_p);\n      ecma_deref_ecma_string (export_name_p);\n      break;\n    }\n    case LEXER_MULTIPLY:\n    {\n      lexer_next_token (context_p);\n\n      ecma_module_node_t **target_node_list_p = &(JERRY_CONTEXT (module_current_p)->star_exports_p);\n\n      if (lexer_token_is_identifier (context_p, \"as\", 2))\n      {\n        target_node_list_p = &(JERRY_CONTEXT (module_current_p)->indirect_exports_p);\n\n        lexer_next_token (context_p);\n\n        if (context_p->token.type != LEXER_LITERAL\n            || context_p->token.lit_location.type != LEXER_IDENT_LITERAL)\n        {\n          parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_EXPECTED);\n        }\n\n        lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_NEW_IDENT_LITERAL);\n\n        lexer_literal_t *literal_p = PARSER_GET_LITERAL (context_p->lit_object.index);\n        ecma_string_t *export_name_p = parser_new_ecma_string_from_literal (literal_p);\n\n        if (parser_module_check_duplicate_export (context_p, export_name_p))\n        {\n          ecma_deref_ecma_string (export_name_p);\n          parser_raise_error (context_p, PARSER_ERR_DUPLICATED_EXPORT_IDENTIFIER);\n        }\n\n        ecma_string_t *local_name_p = ecma_get_magic_string (LIT_MAGIC_STRING_ASTERIX_CHAR);\n        parser_module_add_names_to_node (context_p, export_name_p, local_name_p);\n        ecma_deref_ecma_string (export_name_p);\n\n        lexer_next_token (context_p);\n      }\n\n      if (!lexer_token_is_identifier (context_p, \"from\", 4))\n      {\n        parser_raise_error (context_p, PARSER_ERR_FROM_EXPECTED);\n      }\n\n      lexer_next_token (context_p);\n      parser_module_handle_module_specifier (context_p, target_node_list_p);\n      return false;\n    }\n    case LEXER_KEYW_VAR:\n    case LEXER_KEYW_LET:\n    case LEXER_KEYW_CONST:\n    {\n      context_p->status_flags |= PARSER_MODULE_STORE_IDENT;\n      parser_parse_var_statement (context_p);\n      break;\n    }\n    case LEXER_KEYW_CLASS:\n    {\n      context_p->status_flags |= PARSER_MODULE_STORE_IDENT;\n      parser_parse_class (context_p, true);\n      consume_last_statement = true;\n      break;\n    }\n    case LEXER_KEYW_FUNCTION:\n    {\n      context_p->status_flags |= PARSER_MODULE_STORE_IDENT;\n      parser_parse_function_statement (context_p);\n      consume_last_statement = true;\n      break;\n    }\n    case LEXER_LEFT_BRACE:\n    {\n      parser_module_parse_export_clause (context_p);\n\n      if (lexer_token_is_identifier (context_p, \"from\", 4))\n      {\n        lexer_next_token (context_p);\n        parser_module_handle_module_specifier (context_p, &(JERRY_CONTEXT (module_current_p)->indirect_exports_p));\n        return false;\n      }\n      break;\n    }\n    default:\n    {\n      parser_raise_error (context_p, PARSER_ERR_LEFT_BRACE_MULTIPLY_LITERAL_EXPECTED);\n      break;\n    }\n  }\n\n  context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_DEFAULT_CLASS_OR_FUNC | PARSER_MODULE_STORE_IDENT);\n  parser_module_append_names (context_p, &(JERRY_CONTEXT (module_current_p)->local_exports_p));\n\n  return consume_last_statement;\n} \/* parser_parse_export_statement *\/","target":0,"code_token_length":1406,"total_token_length":1642,"max_tokens_setting":2048}
+{"idx":270116,"func":"TfLiteStatus PopulateConvolutionQuantizationParams(\n    TfLiteContext* context, const TfLiteTensor* input,\n    const TfLiteTensor* filter, const TfLiteTensor* bias, TfLiteTensor* output,\n    const TfLiteFusedActivation& activation, int32_t* multiplier, int* shift,\n    int32_t* output_activation_min, int32_t* output_activation_max,\n    int32_t* per_channel_multiplier, int32_t* per_channel_shift,\n    int num_channels) {\n  TF_LITE_ENSURE_EQ(context, input->quantization.type,\n                    kTfLiteAffineQuantization);\n  TF_LITE_ENSURE_EQ(context, filter->quantization.type,\n                    kTfLiteAffineQuantization);\n  \/\/ TODO(jianlijianli): Enable bias type check and bias scale == input scale\n  \/\/ * filter scale for each channel in affine quantization once bias\n  \/\/ quantization is properly populated.\n  \/\/ TF_LITE_ENSURE_EQ(context, bias->quantization.type,\n  \/\/ kTfLiteAffineQuantization);\n\n  \/\/ Check data type.\n  const auto* affine_quantization =\n      reinterpret_cast<TfLiteAffineQuantization*>(filter->quantization.params);\n  TF_LITE_ENSURE(context, affine_quantization);\n  TF_LITE_ENSURE(context, affine_quantization->scale);\n  const bool is_per_channel = affine_quantization->scale->size > 1;\n  if (is_per_channel) {\n    \/\/  Currently only Int8\/Int16 is supported for per channel quantization.\n    TF_LITE_ENSURE(context,\n                   input->type == kTfLiteInt8 || input->type == kTfLiteInt16);\n    TF_LITE_ENSURE_EQ(context, filter->type, kTfLiteInt8);\n    TF_LITE_ENSURE_EQ(context, affine_quantization->scale->size, num_channels);\n    TF_LITE_ENSURE_EQ(\n        context, num_channels,\n        filter->dims->data[affine_quantization->quantized_dimension]);\n  }\n\n  \/\/ Populate multiplier and shift using affine quantization.\n  const float input_scale = input->params.scale;\n  const float output_scale = output->params.scale;\n  const float* filter_scales = affine_quantization->scale->data;\n  for (int i = 0; i < num_channels; ++i) {\n    \/\/ If per-tensor quantization parameter is specified, broadcast it along the\n    \/\/ quantization dimension (channels_out).\n    const float scale = is_per_channel ? filter_scales[i] : filter_scales[0];\n    const double filter_scale = static_cast<double>(scale);\n    const double effective_output_scale = static_cast<double>(input_scale) *\n                                          filter_scale \/\n                                          static_cast<double>(output_scale);\n    int32_t significand;\n    int channel_shift;\n    QuantizeMultiplier(effective_output_scale, &significand, &channel_shift);\n    per_channel_multiplier[i] = significand;\n    per_channel_shift[i] = channel_shift;\n  }\n\n  \/\/ Populate scalar quantization parameters.\n  \/\/ This check on legacy quantization parameters is kept only for backward\n  \/\/ compatibility.\n  if (input->type == kTfLiteUInt8) {\n    \/\/ Check bias scale == input scale * filter scale.\n    double real_multiplier = 0.0;\n    TF_LITE_ENSURE_STATUS(GetQuantizedConvolutionMultipler(\n        context, input, filter, bias, output, &real_multiplier));\n    int exponent;\n\n    \/\/ Populate quantization parameters with multiplier and shift.\n    QuantizeMultiplier(real_multiplier, multiplier, &exponent);\n    *shift = -exponent;\n  }\n  if (input->type == kTfLiteInt8 || input->type == kTfLiteUInt8 ||\n      input->type == kTfLiteInt16) {\n    TF_LITE_ENSURE_STATUS(CalculateActivationRangeQuantized(\n        context, activation, output, output_activation_min,\n        output_activation_max));\n  }\n  return kTfLiteOk;\n}","target":0,"code_token_length":844,"total_token_length":1080,"max_tokens_setting":2048}
+{"idx":207990,"func":"static int get_recurse_data_length(compiler_common *common, PCRE2_SPTR cc, PCRE2_SPTR ccend,\n  BOOL *needs_control_head, BOOL *has_quit, BOOL *has_accept)\n{\nint length = 1;\nint size;\nPCRE2_SPTR alternative;\nBOOL quit_found = FALSE;\nBOOL accept_found = FALSE;\nBOOL setsom_found = FALSE;\nBOOL setmark_found = FALSE;\nBOOL capture_last_found = FALSE;\nBOOL control_head_found = FALSE;\n\n#if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD\nSLJIT_ASSERT(common->control_head_ptr != 0);\ncontrol_head_found = TRUE;\n#endif\n\n\/* Calculate the sum of the private machine words. *\/\nwhile (cc < ccend)\n  {\n  size = 0;\n  switch(*cc)\n    {\n    case OP_SET_SOM:\n    SLJIT_ASSERT(common->has_set_som);\n    setsom_found = TRUE;\n    cc += 1;\n    break;\n\n    case OP_RECURSE:\n    if (common->has_set_som)\n      setsom_found = TRUE;\n    if (common->mark_ptr != 0)\n      setmark_found = TRUE;\n    if (common->capture_last_ptr != 0)\n      capture_last_found = TRUE;\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_KET:\n    if (PRIVATE_DATA(cc) != 0)\n      {\n      length++;\n      SLJIT_ASSERT(PRIVATE_DATA(cc + 1) != 0);\n      cc += PRIVATE_DATA(cc + 1);\n      }\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_ASSERT:\n    case OP_ASSERT_NOT:\n    case OP_ASSERTBACK:\n    case OP_ASSERTBACK_NOT:\n    case OP_ASSERT_NA:\n    case OP_ASSERTBACK_NA:\n    case OP_ONCE:\n    case OP_SCRIPT_RUN:\n    case OP_BRAPOS:\n    case OP_SBRA:\n    case OP_SBRAPOS:\n    case OP_SCOND:\n    length++;\n    SLJIT_ASSERT(PRIVATE_DATA(cc) != 0);\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_CBRA:\n    case OP_SCBRA:\n    length += 2;\n    if (common->capture_last_ptr != 0)\n      capture_last_found = TRUE;\n    if (common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0)\n      length++;\n    cc += 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_CBRAPOS:\n    case OP_SCBRAPOS:\n    length += 2 + 2;\n    if (common->capture_last_ptr != 0)\n      capture_last_found = TRUE;\n    cc += 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_COND:\n    \/* Might be a hidden SCOND. *\/\n    alternative = cc + GET(cc, 1);\n    if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)\n      length++;\n    cc += 1 + LINK_SIZE;\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_1\n    if (PRIVATE_DATA(cc) != 0)\n      length++;\n    cc += 2;\n#ifdef SUPPORT_UNICODE\n    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_2A\n    if (PRIVATE_DATA(cc) != 0)\n      length += 2;\n    cc += 2;\n#ifdef SUPPORT_UNICODE\n    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_2B\n    if (PRIVATE_DATA(cc) != 0)\n      length += 2;\n    cc += 2 + IMM2_SIZE;\n#ifdef SUPPORT_UNICODE\n    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_1\n    if (PRIVATE_DATA(cc) != 0)\n      length++;\n    cc += 1;\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_2A\n    if (PRIVATE_DATA(cc) != 0)\n      length += 2;\n    cc += 1;\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_2B\n    if (PRIVATE_DATA(cc) != 0)\n      length += 2;\n    cc += 1 + IMM2_SIZE;\n    break;\n\n    case OP_CLASS:\n    case OP_NCLASS:\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8\n    case OP_XCLASS:\n    size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 \/ (int)sizeof(PCRE2_UCHAR);\n#else\n    size = 1 + 32 \/ (int)sizeof(PCRE2_UCHAR);\n#endif\n    if (PRIVATE_DATA(cc) != 0)\n      length += get_class_iterator_size(cc + size);\n    cc += size;\n    break;\n\n    case OP_MARK:\n    case OP_COMMIT_ARG:\n    case OP_PRUNE_ARG:\n    case OP_THEN_ARG:\n    SLJIT_ASSERT(common->mark_ptr != 0);\n    if (!setmark_found)\n      setmark_found = TRUE;\n    if (common->control_head_ptr != 0)\n      control_head_found = TRUE;\n    if (*cc != OP_MARK)\n      quit_found = TRUE;\n\n    cc += 1 + 2 + cc[1];\n    break;\n\n    case OP_PRUNE:\n    case OP_SKIP:\n    case OP_COMMIT:\n    quit_found = TRUE;\n    cc++;\n    break;\n\n    case OP_SKIP_ARG:\n    quit_found = TRUE;\n    cc += 1 + 2 + cc[1];\n    break;\n\n    case OP_THEN:\n    SLJIT_ASSERT(common->control_head_ptr != 0);\n    quit_found = TRUE;\n    if (!control_head_found)\n      control_head_found = TRUE;\n    cc++;\n    break;\n\n    case OP_ACCEPT:\n    case OP_ASSERT_ACCEPT:\n    accept_found = TRUE;\n    cc++;\n    break;\n\n    default:\n    cc = next_opcode(common, cc);\n    SLJIT_ASSERT(cc != NULL);\n    break;\n    }\n  }\nSLJIT_ASSERT(cc == ccend);\n\nif (control_head_found)\n  length++;\nif (capture_last_found)\n  length++;\nif (quit_found)\n  {\n  if (setsom_found)\n    length++;\n  if (setmark_found)\n    length++;\n  }\n\n*needs_control_head = control_head_found;\n*has_quit = quit_found;\n*has_accept = accept_found;\nreturn length;\n}","target":1,"code_token_length":1410,"total_token_length":1646,"max_tokens_setting":2048}
+{"idx":364771,"func":"findtags_add_match(\n    findtags_state_T\t*st,\n    tagptrs_T\t\t*tagpp,\n    findtags_match_args_T   *margs,\n    char_u\t\t*buf_ffname,\n    hash_T\t\t*hash)\n{\n#ifdef FEAT_CSCOPE\n    int\t\tuse_cscope = (st->flags & TAG_CSCOPE);\n#endif\n    int\t\tname_only = (st->flags & TAG_NAMES);\n    int\t\tmtt;\n    int\t\tlen = 0;\n    int\t\tis_current;\t\t\/\/ file name matches\n    int\t\tis_static;\t\t\/\/ current tag line is static\n    char_u\t*mfp;\n    char_u\t*p;\n    char_u\t*s;\n\n#ifdef FEAT_CSCOPE\n    if (use_cscope)\n    {\n\t\/\/ Don't change the ordering, always use the same table.\n\tmtt = MT_GL_OTH;\n    }\n    else\n#endif\n    {\n\t\/\/ Decide in which array to store this match.\n\tis_current = test_for_current(\n#ifdef FEAT_EMACS_TAGS\n\t\tst->is_etag,\n#endif\n\t\ttagpp->fname, tagpp->fname_end, st->tag_fname, buf_ffname);\n#ifdef FEAT_EMACS_TAGS\n\tis_static = FALSE;\n\tif (!st->is_etag)\t\/\/ emacs tags are never static\n#endif\n\t    is_static = test_for_static(tagpp);\n\n\t\/\/ decide in which of the sixteen tables to store this\n\t\/\/ match\n\tif (is_static)\n\t{\n\t    if (is_current)\n\t\tmtt = MT_ST_CUR;\n\t    else\n\t\tmtt = MT_ST_OTH;\n\t}\n\telse\n\t{\n\t    if (is_current)\n\t\tmtt = MT_GL_CUR;\n\t    else\n\t\tmtt = MT_GL_OTH;\n\t}\n\tif (st->orgpat->regmatch.rm_ic && !margs->match_no_ic)\n\t    mtt += MT_IC_OFF;\n\tif (margs->match_re)\n\t    mtt += MT_RE_OFF;\n    }\n\n    \/\/ Add the found match in ht_match[mtt] and ga_match[mtt].\n    \/\/ Store the info we need later, which depends on the kind of\n    \/\/ tags we are dealing with.\n    if (st->help_only)\n    {\n#ifdef FEAT_MULTI_LANG\n# define ML_EXTRA 3\n#else\n# define ML_EXTRA 0\n#endif\n\t\/\/ Append the help-heuristic number after the tagname, for\n\t\/\/ sorting it later.  The heuristic is ignored for\n\t\/\/ detecting duplicates.\n\t\/\/ The format is {tagname}@{lang}NUL{heuristic}NUL\n\t*tagpp->tagname_end = NUL;\n\tlen = (int)(tagpp->tagname_end - tagpp->tagname);\n\tmfp = alloc(sizeof(char_u) + len + 10 + ML_EXTRA + 1);\n\tif (mfp != NULL)\n\t{\n\t    int heuristic;\n\n\t    p = mfp;\n\t    STRCPY(p, tagpp->tagname);\n#ifdef FEAT_MULTI_LANG\n\t    p[len] = '@';\n\t    STRCPY(p + len + 1, st->help_lang);\n#endif\n\n\t    heuristic = help_heuristic(tagpp->tagname,\n\t\t\t\tmargs->match_re ? margs->matchoff : 0,\n\t\t\t\t!margs->match_no_ic);\n#ifdef FEAT_MULTI_LANG\n\t    heuristic += st->help_pri;\n#endif\n\t    sprintf((char *)p + len + 1 + ML_EXTRA, \"%06d\",\n\t\t    heuristic);\n\t}\n\t*tagpp->tagname_end = TAB;\n    }\n    else if (name_only)\n    {\n\tif (st->get_searchpat)\n\t{\n\t    char_u *temp_end = tagpp->command;\n\n\t    if (*temp_end == '\/')\n\t\twhile (*temp_end && *temp_end != '\\r'\n\t\t\t&& *temp_end != '\\n'\n\t\t\t&& *temp_end != '$')\n\t\t    temp_end++;\n\n\t    if (tagpp->command + 2 < temp_end)\n\t    {\n\t\tlen = (int)(temp_end - tagpp->command - 2);\n\t\tmfp = alloc(len + 2);\n\t\tif (mfp != NULL)\n\t\t    vim_strncpy(mfp, tagpp->command + 2, len);\n\t    }\n\t    else\n\t\tmfp = NULL;\n\t    st->get_searchpat = FALSE;\n\t}\n\telse\n\t{\n\t    len = (int)(tagpp->tagname_end - tagpp->tagname);\n\t    mfp = alloc(sizeof(char_u) + len + 1);\n\t    if (mfp != NULL)\n\t\tvim_strncpy(mfp, tagpp->tagname, len);\n\n\t    \/\/ if wanted, re-read line to get long form too\n\t    if (State & MODE_INSERT)\n\t\tst->get_searchpat = p_sft;\n\t}\n    }\n    else\n    {\n\tsize_t tag_fname_len = STRLEN(st->tag_fname);\n#ifdef FEAT_EMACS_TAGS\n\tsize_t ebuf_len = 0;\n#endif\n\n\t\/\/ Save the tag in a buffer.\n\t\/\/ Use 0x02 to separate fields (Can't use NUL because the\n\t\/\/ hash key is terminated by NUL, or Ctrl_A because that is\n\t\/\/ part of some Emacs tag files -- see parse_tag_line).\n\t\/\/ Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL>\n\t\/\/ other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL>\n\t\/\/ without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL>\n\t\/\/ Here <mtt> is the \"mtt\" value plus 1 to avoid NUL.\n\tlen = (int)tag_fname_len + (int)STRLEN(st->lbuf) + 3;\n#ifdef FEAT_EMACS_TAGS\n\tif (st->is_etag)\n\t{\n\t    ebuf_len = STRLEN(st->ebuf);\n\t    len += (int)ebuf_len + 1;\n\t}\n\telse\n\t    ++len;\n#endif\n\tmfp = alloc(sizeof(char_u) + len + 1);\n\tif (mfp != NULL)\n\t{\n\t    p = mfp;\n\t    p[0] = mtt + 1;\n\t    STRCPY(p + 1, st->tag_fname);\n#ifdef BACKSLASH_IN_FILENAME\n\t    \/\/ Ignore differences in slashes, avoid adding\n\t    \/\/ both path\/file and path\\file.\n\t    slash_adjust(p + 1);\n#endif\n\t    p[tag_fname_len + 1] = TAG_SEP;\n\t    s = p + 1 + tag_fname_len + 1;\n#ifdef FEAT_EMACS_TAGS\n\t    if (st->is_etag)\n\t    {\n\t\tSTRCPY(s, st->ebuf);\n\t\ts[ebuf_len] = TAG_SEP;\n\t\ts += ebuf_len + 1;\n\t    }\n\t    else\n\t\t*s++ = TAG_SEP;\n#endif\n\t    STRCPY(s, st->lbuf);\n\t}\n    }\n\n    if (mfp != NULL)\n    {\n\thashitem_T\t*hi;\n\n\t\/\/ Don't add identical matches.\n\t\/\/ Add all cscope tags, because they are all listed.\n\t\/\/ \"mfp\" is used as a hash key, there is a NUL byte to end\n\t\/\/ the part that matters for comparing, more bytes may\n\t\/\/ follow after it.  E.g. help tags store the priority\n\t\/\/ after the NUL.\n#ifdef FEAT_CSCOPE\n\tif (use_cscope)\n\t    ++*hash;\n\telse\n#endif\n\t    *hash = hash_hash(mfp);\n\thi = hash_lookup(&st->ht_match[mtt], mfp, *hash);\n\tif (HASHITEM_EMPTY(hi))\n\t{\n\t    if (hash_add_item(&st->ht_match[mtt], hi, mfp, *hash) == FAIL\n\t\t    || ga_grow(&st->ga_match[mtt], 1) != OK)\n\t    {\n\t\t\/\/ Out of memory! Just forget about the rest.\n\t\tst->stop_searching = TRUE;\n\t\treturn FAIL;\n\t    }\n\n\t    ((char_u **)(st->ga_match[mtt].ga_data))\n\t\t[st->ga_match[mtt].ga_len++] = mfp;\n\t    st->match_count++;\n\t}\n\telse\n\t    \/\/ duplicate tag, drop it\n\t    vim_free(mfp);\n    }\n\n    return OK;\n}","target":0,"code_token_length":1810,"total_token_length":2046,"max_tokens_setting":2048}
+{"idx":390534,"func":"ProcXkbSelectEvents(ClientPtr client)\n{\n    unsigned\t\tlegal;\n    DeviceIntPtr \tdev;\n    XkbInterestPtr\tmasks;\n    REQUEST(xkbSelectEventsReq);\n\n    REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixUseAccess);\n\n    if (((stuff->affectWhich&XkbMapNotifyMask)!=0)&&(stuff->affectMap)) {\n\tclient->mapNotifyMask&= ~stuff->affectMap;\n\tclient->mapNotifyMask|= (stuff->affectMap&stuff->map);\n    }\n    if ((stuff->affectWhich&(~XkbMapNotifyMask))==0) \n\treturn client->noClientException;\n\n    masks = XkbFindClientResource((DevicePtr)dev,client);\n    if (!masks){\n\tXID id = FakeClientID(client->index);\n\tAddResource(id,RT_XKBCLIENT,dev);\n\tmasks= XkbAddClientResource((DevicePtr)dev,client,id);\n    }\n    if (masks) {\n\tunion {\n\t    CARD8\t*c8;\n\t    CARD16\t*c16;\n\t    CARD32\t*c32;\n\t} from,to;\n\tregister unsigned bit,ndx,maskLeft,dataLeft,size;\n\n\tfrom.c8= (CARD8 *)&stuff[1];\n\tdataLeft= (stuff->length*4)-SIZEOF(xkbSelectEventsReq);\n\tmaskLeft= (stuff->affectWhich&(~XkbMapNotifyMask));\n\tfor (ndx=0,bit=1; (maskLeft!=0); ndx++, bit<<=1) {\n\t    if ((bit&maskLeft)==0)\n\t\tcontinue;\n\t    maskLeft&= ~bit;\n\t    switch (ndx) {\n\t\tcase XkbNewKeyboardNotify:\n\t\t    to.c16= &client->newKeyboardNotifyMask;\n\t\t    legal= XkbAllNewKeyboardEventsMask;\n\t\t    size= 2;\n\t\t    break;\n\t\tcase XkbStateNotify:\n\t\t    to.c16= &masks->stateNotifyMask;\n\t\t    legal= XkbAllStateEventsMask;\n\t\t    size= 2;\n\t\t    break;\n\t\tcase XkbControlsNotify:\n\t\t    to.c32= &masks->ctrlsNotifyMask;\n\t\t    legal= XkbAllControlEventsMask;\n\t\t    size= 4;\n\t\t    break;\n\t\tcase XkbIndicatorStateNotify:\n\t\t    to.c32= &masks->iStateNotifyMask;\n\t\t    legal= XkbAllIndicatorEventsMask;\n\t\t    size= 4;\n\t\t    break;\n\t\tcase XkbIndicatorMapNotify:\n\t\t    to.c32= &masks->iMapNotifyMask;\n\t\t    legal= XkbAllIndicatorEventsMask;\n\t\t    size= 4;\n\t\t    break;\n\t\tcase XkbNamesNotify:\n\t\t    to.c16= &masks->namesNotifyMask;\n\t\t    legal= XkbAllNameEventsMask;\n\t\t    size= 2;\n\t\t    break;\n\t\tcase XkbCompatMapNotify:\n\t\t    to.c8= &masks->compatNotifyMask;\n\t\t    legal= XkbAllCompatMapEventsMask;\n\t\t    size= 1;\n\t\t    break;\n\t\tcase XkbBellNotify:\n\t\t    to.c8= &masks->bellNotifyMask;\n\t\t    legal= XkbAllBellEventsMask;\n\t\t    size= 1;\n\t\t    break;\n\t\tcase XkbActionMessage:\n\t\t    to.c8= &masks->actionMessageMask;\n\t\t    legal= XkbAllActionMessagesMask;\n\t\t    size= 1;\n\t\t    break;\n\t\tcase XkbAccessXNotify:\n\t\t    to.c16= &masks->accessXNotifyMask;\n\t\t    legal= XkbAllAccessXEventsMask;\n\t\t    size= 2;\n\t\t    break;\n\t\tcase XkbExtensionDeviceNotify:\n\t\t    to.c16= &masks->extDevNotifyMask;\n\t\t    legal= XkbAllExtensionDeviceEventsMask;\n\t\t    size= 2;\n\t\t    break;\n\t\tdefault:\n\t\t    client->errorValue = _XkbErrCode2(33,bit);\n\t\t    return BadValue;\n\t    }\n\n\t    if (stuff->clear&bit) {\n\t\tif (size==2)\t\tto.c16[0]= 0;\n\t\telse if (size==4)\tto.c32[0]= 0;\n\t\telse\t\t\tto.c8[0]=  0;\n\t    }\n\t    else if (stuff->selectAll&bit) {\n\t\tif (size==2)\t\tto.c16[0]= ~0;\n\t\telse if (size==4)\tto.c32[0]= ~0;\n\t\telse\t\t\tto.c8[0]=  ~0;\n\t    }\n\t    else {\n\t\tif (dataLeft<(size*2))\n\t\t    return BadLength;\n\t\tif (size==2) {\n\t\t    CHK_MASK_MATCH(ndx,from.c16[0],from.c16[1]);\n\t\t    CHK_MASK_LEGAL(ndx,from.c16[0],legal);\n\t\t    to.c16[0]&= ~from.c16[0];\n\t\t    to.c16[0]|= (from.c16[0]&from.c16[1]);\n\t\t}\n\t\telse if (size==4) {\n\t\t    CHK_MASK_MATCH(ndx,from.c32[0],from.c32[1]);\n\t\t    CHK_MASK_LEGAL(ndx,from.c32[0],legal);\n\t\t    to.c32[0]&= ~from.c32[0];\n\t\t    to.c32[0]|= (from.c32[0]&from.c32[1]);\n\t\t}\n\t\telse  {\n\t\t    CHK_MASK_MATCH(ndx,from.c8[0],from.c8[1]);\n\t\t    CHK_MASK_LEGAL(ndx,from.c8[0],legal);\n\t\t    to.c8[0]&= ~from.c8[0];\n\t\t    to.c8[0]|= (from.c8[0]&from.c8[1]);\n\t\t    size= 2;\n\t\t}\n\t\tfrom.c8+= (size*2);\n\t\tdataLeft-= (size*2);\n\t    }\n\t}\n\tif (dataLeft>2) {\n\t    ErrorF(\"[xkb] Extra data (%d bytes) after SelectEvents\\n\",dataLeft);\n\t    return BadLength;\n\t}\n\treturn client->noClientException;\n    }\n    return BadAlloc;\n}","target":0,"code_token_length":1341,"total_token_length":1577,"max_tokens_setting":2048}
+{"idx":211842,"func":"change_indent(\n    int\t\ttype,\n    int\t\tamount,\n    int\t\tround,\n    int\t\treplaced,\t\/\/ replaced character, put on replace stack\n    int\t\tcall_changed_bytes)\t\/\/ call changed_bytes()\n{\n    int\t\tvcol;\n    int\t\tlast_vcol;\n    int\t\tinsstart_less;\t\t\/\/ reduction for Insstart.col\n    int\t\tnew_cursor_col;\n    int\t\ti;\n    char_u\t*ptr;\n    int\t\tsave_p_list;\n    int\t\tstart_col;\n    colnr_T\tvc;\n    colnr_T\torig_col = 0;\t\t\/\/ init for GCC\n    char_u\t*new_line, *orig_line = NULL;\t\/\/ init for GCC\n\n    \/\/ VREPLACE mode needs to know what the line was like before changing\n    if (State & VREPLACE_FLAG)\n    {\n\torig_line = vim_strsave(ml_get_curline());  \/\/ Deal with NULL below\n\torig_col = curwin->w_cursor.col;\n    }\n\n    \/\/ for the following tricks we don't want list mode\n    save_p_list = curwin->w_p_list;\n    curwin->w_p_list = FALSE;\n    vc = getvcol_nolist(&curwin->w_cursor);\n    vcol = vc;\n\n    \/\/ For Replace mode we need to fix the replace stack later, which is only\n    \/\/ possible when the cursor is in the indent.  Remember the number of\n    \/\/ characters before the cursor if it's possible.\n    start_col = curwin->w_cursor.col;\n\n    \/\/ determine offset from first non-blank\n    new_cursor_col = curwin->w_cursor.col;\n    beginline(BL_WHITE);\n    new_cursor_col -= curwin->w_cursor.col;\n\n    insstart_less = curwin->w_cursor.col;\n\n    \/\/ If the cursor is in the indent, compute how many screen columns the\n    \/\/ cursor is to the left of the first non-blank.\n    if (new_cursor_col < 0)\n\tvcol = get_indent() - vcol;\n\n    if (new_cursor_col > 0)\t    \/\/ can't fix replace stack\n\tstart_col = -1;\n\n    \/\/ Set the new indent.  The cursor will be put on the first non-blank.\n    if (type == INDENT_SET)\n\t(void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);\n    else\n    {\n\tint\tsave_State = State;\n\n\t\/\/ Avoid being called recursively.\n\tif (State & VREPLACE_FLAG)\n\t    State = INSERT;\n\tshift_line(type == INDENT_DEC, round, 1, call_changed_bytes);\n\tState = save_State;\n    }\n    insstart_less -= curwin->w_cursor.col;\n\n    \/\/ Try to put cursor on same character.\n    \/\/ If the cursor is at or after the first non-blank in the line,\n    \/\/ compute the cursor column relative to the column of the first\n    \/\/ non-blank character.\n    \/\/ If we are not in insert mode, leave the cursor on the first non-blank.\n    \/\/ If the cursor is before the first non-blank, position it relative\n    \/\/ to the first non-blank, counted in screen columns.\n    if (new_cursor_col >= 0)\n    {\n\t\/\/ When changing the indent while the cursor is touching it, reset\n\t\/\/ Insstart_col to 0.\n\tif (new_cursor_col == 0)\n\t    insstart_less = MAXCOL;\n\tnew_cursor_col += curwin->w_cursor.col;\n    }\n    else if (!(State & INSERT))\n\tnew_cursor_col = curwin->w_cursor.col;\n    else\n    {\n\t\/\/ Compute the screen column where the cursor should be.\n\tvcol = get_indent() - vcol;\n\tcurwin->w_virtcol = (colnr_T)((vcol < 0) ? 0 : vcol);\n\n\t\/\/ Advance the cursor until we reach the right screen column.\n\tvcol = last_vcol = 0;\n\tnew_cursor_col = -1;\n\tptr = ml_get_curline();\n\twhile (vcol <= (int)curwin->w_virtcol)\n\t{\n\t    last_vcol = vcol;\n\t    if (has_mbyte && new_cursor_col >= 0)\n\t\tnew_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col);\n\t    else\n\t\t++new_cursor_col;\n\t    vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);\n\t}\n\tvcol = last_vcol;\n\n\t\/\/ May need to insert spaces to be able to position the cursor on\n\t\/\/ the right screen column.\n\tif (vcol != (int)curwin->w_virtcol)\n\t{\n\t    curwin->w_cursor.col = (colnr_T)new_cursor_col;\n\t    i = (int)curwin->w_virtcol - vcol;\n\t    ptr = alloc(i + 1);\n\t    if (ptr != NULL)\n\t    {\n\t\tnew_cursor_col += i;\n\t\tptr[i] = NUL;\n\t\twhile (--i >= 0)\n\t\t    ptr[i] = ' ';\n\t\tins_str(ptr);\n\t\tvim_free(ptr);\n\t    }\n\t}\n\n\t\/\/ When changing the indent while the cursor is in it, reset\n\t\/\/ Insstart_col to 0.\n\tinsstart_less = MAXCOL;\n    }\n\n    curwin->w_p_list = save_p_list;\n\n    if (new_cursor_col <= 0)\n\tcurwin->w_cursor.col = 0;\n    else\n\tcurwin->w_cursor.col = (colnr_T)new_cursor_col;\n    curwin->w_set_curswant = TRUE;\n    changed_cline_bef_curs();\n\n    \/\/ May have to adjust the start of the insert.\n    if (State & INSERT)\n    {\n\tif (curwin->w_cursor.lnum == Insstart.lnum && Insstart.col != 0)\n\t{\n\t    if ((int)Insstart.col <= insstart_less)\n\t\tInsstart.col = 0;\n\t    else\n\t\tInsstart.col -= insstart_less;\n\t}\n\tif ((int)ai_col <= insstart_less)\n\t    ai_col = 0;\n\telse\n\t    ai_col -= insstart_less;\n    }\n\n    \/\/ For REPLACE mode, may have to fix the replace stack, if it's possible.\n    \/\/ If the number of characters before the cursor decreased, need to pop a\n    \/\/ few characters from the replace stack.\n    \/\/ If the number of characters before the cursor increased, need to push a\n    \/\/ few NULs onto the replace stack.\n    if (REPLACE_NORMAL(State) && start_col >= 0)\n    {\n\twhile (start_col > (int)curwin->w_cursor.col)\n\t{\n\t    replace_join(0);\t    \/\/ remove a NUL from the replace stack\n\t    --start_col;\n\t}\n\twhile (start_col < (int)curwin->w_cursor.col || replaced)\n\t{\n\t    replace_push(NUL);\n\t    if (replaced)\n\t    {\n\t\treplace_push(replaced);\n\t\treplaced = NUL;\n\t    }\n\t    ++start_col;\n\t}\n    }\n\n    \/\/ For VREPLACE mode, we also have to fix the replace stack.  In this case\n    \/\/ it is always possible because we backspace over the whole line and then\n    \/\/ put it back again the way we wanted it.\n    if (State & VREPLACE_FLAG)\n    {\n\t\/\/ If orig_line didn't allocate, just return.  At least we did the job,\n\t\/\/ even if you can't backspace.\n\tif (orig_line == NULL)\n\t    return;\n\n\t\/\/ Save new line\n\tnew_line = vim_strsave(ml_get_curline());\n\tif (new_line == NULL)\n\t    return;\n\n\t\/\/ We only put back the new line up to the cursor\n\tnew_line[curwin->w_cursor.col] = NUL;\n\n\t\/\/ Put back original line\n\tml_replace(curwin->w_cursor.lnum, orig_line, FALSE);\n\tcurwin->w_cursor.col = orig_col;\n\n\t\/\/ Backspace from cursor to start of line\n\tbackspace_until_column(0);\n\n\t\/\/ Insert new stuff into line again\n\tins_bytes(new_line);\n\n\tvim_free(new_line);\n    }\n}","target":1,"code_token_length":1724,"total_token_length":1960,"max_tokens_setting":2048}
+{"idx":232355,"func":"GF_Err GetMediaTime(GF_TrackBox *trak, Bool force_non_empty, u64 movieTime, u64 *MediaTime, s64 *SegmentStartTime, s64 *MediaOffset, u8 *useEdit, u64 *next_edit_start_plus_one)\n{\n#if 0\n\tGF_Err e;\n\tu32 sampleNumber, prevSampleNumber;\n\tu64 firstDTS;\n#endif\n\tu32 i, count;\n\tBool last_is_empty = 0;\n\tu64 time, lastSampleTime;\n\ts64 mtime;\n\tGF_EdtsEntry *ent;\n\tDouble scale_ts;\n\tGF_SampleTableBox *stbl = trak->Media->information->sampleTable;\n\n\tif (next_edit_start_plus_one) *next_edit_start_plus_one = 0;\n\t*useEdit = 1;\n\t*MediaTime = 0;\n\t\/\/no segment yet...\n\t*SegmentStartTime = -1;\n\t*MediaOffset = -1;\n\tif (!trak->moov->mvhd->timeScale || !trak->Media->mediaHeader->timeScale || !stbl->SampleSize) {\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\t\/\/no samples...\n\tif (!stbl->SampleSize->sampleCount) {\n\t\tlastSampleTime = 0;\n\t} else {\n\t\tlastSampleTime = trak->Media->mediaHeader->duration;\n\t}\n\n\t\/\/No edits, 1 to 1 mapping\n\tif (! trak->editBox || !trak->editBox->editList) {\n\t\t*MediaTime = movieTime;\n\t\t\/\/check this is in our media time line\n\t\tif ((*MediaTime > lastSampleTime)\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t        && !trak->moov->mov->moof\n#endif\n\t\t   ) {\n\t\t\t*MediaTime = lastSampleTime;\n\t\t}\n\t\t*useEdit = 0;\n\t\treturn GF_OK;\n\t}\n\t\/\/browse the edit list and get the time\n\tscale_ts = trak->Media->mediaHeader->timeScale;\n\tscale_ts \/= trak->moov->mvhd->timeScale;\n\n\ttime = 0;\n\tent = NULL;\n\tcount=gf_list_count(trak->editBox->editList->entryList);\n\tfor (i=0; i<count; i++) {\n\t\tent = (GF_EdtsEntry *)gf_list_get(trak->editBox->editList->entryList, i);\n\t\tif ( (time + ent->segmentDuration) * scale_ts > movieTime) {\n\t\t\tif (!force_non_empty || (ent->mediaTime >= 0)) {\n\t\t\t\tif (next_edit_start_plus_one) *next_edit_start_plus_one = 1 + (u64) ((time + ent->segmentDuration) * scale_ts);\n\t\t\t\tgoto ent_found;\n\t\t\t}\n\t\t}\n\t\ttime += ent->segmentDuration;\n\t\tlast_is_empty = ent->segmentDuration ? 0 : 1;\n\t}\n\n\tif (last_is_empty) {\n\t\tent = (GF_EdtsEntry *)gf_list_last(trak->editBox->editList->entryList);\n\t\tif (ent->mediaRate == 0x10000) {\n\t\t\t*MediaTime = movieTime + ent->mediaTime;\n\t\t} else {\n\t\t\tent = (GF_EdtsEntry *)gf_list_get(trak->editBox->editList->entryList, 0);\n\t\t\tif (ent->mediaRate == -0x10000) {\n\t\t\t\tu64 dur = (u64) (ent->segmentDuration * scale_ts);\n\t\t\t\t*MediaTime = (movieTime > dur) ? (movieTime-dur) : 0;\n\t\t\t}\n\t\t}\n\t\t*useEdit = 0;\n\t\treturn GF_OK;\n\t}\n\n\n\t\/\/we had nothing in the list (strange file but compliant...)\n\t\/\/return the 1 to 1 mapped vale of the last media sample\n\tif (!ent) {\n\t\t*MediaTime = movieTime;\n\t\t\/\/check this is in our media time line\n\t\tif (*MediaTime > lastSampleTime) *MediaTime = lastSampleTime;\n\t\t*useEdit = 0;\n\t\treturn GF_OK;\n\t}\n\t\/\/request for a bigger time that what we can give: return the last sample (undefined behavior...)\n\t*MediaTime = lastSampleTime;\n\treturn GF_OK;\n\nent_found:\n\t\/\/OK, we found our entry, set the SegmentTime\n\t*SegmentStartTime = time;\n\n\t\/\/we request an empty list, there's no media here...\n\tif (ent->mediaTime < 0) {\n\t\t*MediaTime = 0;\n\t\treturn GF_OK;\n\t}\n\t\/\/we request a dwell edit\n\tif (! ent->mediaRate) {\n\t\t*MediaTime = ent->mediaTime;\n\t\t\/\/no media offset\n\t\t*MediaOffset = 0;\n\t\t*useEdit = 2;\n\t\treturn GF_OK;\n\t}\n\n\t\/*WARNING: this can be \"-1\" when doing searchForward mode (to prevent jumping to next entry)*\/\n\tmtime = ent->mediaTime + movieTime - (time * trak->Media->mediaHeader->timeScale \/ trak->moov->mvhd->timeScale);\n\tif (mtime<0) mtime = 0;\n\t*MediaTime = (u64) mtime;\n\t*MediaOffset = ent->mediaTime;\n\n#if 0\n\t\/\/\n\t\/\/Sanity check: is the requested time valid ? This is to cope with wrong EditLists\n\t\/\/we have the translated time, but we need to make sure we have a sample at this time ...\n\t\/\/we have to find a COMPOSITION time\n\te = stbl_findEntryForTime(stbl, (u32) *MediaTime, 1, &sampleNumber, &prevSampleNumber);\n\tif (e) return e;\n\n\t\/\/first case: our time is after the last sample DTS (it's a broken editList somehow)\n\t\/\/set the media time to the last sample\n\tif (!sampleNumber && !prevSampleNumber) {\n\t\t*MediaTime = lastSampleTime;\n\t\treturn GF_OK;\n\t}\n\t\/\/get the appropriated sample\n\tif (!sampleNumber) sampleNumber = prevSampleNumber;\n\n\tstbl_GetSampleDTS(stbl->TimeToSample, sampleNumber, &DTS);\n\tCTS = 0;\n\tif (stbl->CompositionOffset) stbl_GetSampleCTS(stbl->CompositionOffset, sampleNumber, &CTS);\n\n\t\/\/now get the entry sample (the entry time gives the CTS, and we need the DTS\n\te = stbl_findEntryForTime(stbl, (u32) ent->mediaTime, 0, &sampleNumber, &prevSampleNumber);\n\tif (e) return e;\n\n\t\/\/oops, the mediaTime indicates a sample that is not in our media !\n\tif (!sampleNumber && !prevSampleNumber) {\n\t\t*MediaTime = lastSampleTime;\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tif (!sampleNumber) sampleNumber = prevSampleNumber;\n\n\tstbl_GetSampleDTS(stbl->TimeToSample, sampleNumber, &firstDTS);\n\n\t\/\/and store the \"time offset\" of the desired sample in this segment\n\t\/\/this is weird, used to rebuild the timeStamp when reading from the track, not the\n\t\/\/media ...\n\t*MediaOffset = firstDTS;\n#endif\n\treturn GF_OK;\n}","target":0,"code_token_length":1587,"total_token_length":1823,"max_tokens_setting":2048}
+{"idx":223412,"func":"static void set_private_data_ptrs(compiler_common *common, int *private_data_start, PCRE2_SPTR ccend)\n{\nPCRE2_SPTR cc = common->start;\nPCRE2_SPTR alternative;\nPCRE2_SPTR end = NULL;\nint private_data_ptr = *private_data_start;\nint space, size, bracketlen;\nBOOL repeat_check = TRUE;\n\nwhile (cc < ccend)\n  {\n  space = 0;\n  size = 0;\n  bracketlen = 0;\n  if (private_data_ptr > SLJIT_MAX_LOCAL_SIZE)\n    break;\n\n  \/* When the bracket is prefixed by a zero iteration, skip the repeat check (at this point). *\/\n  if (repeat_check && (*cc == OP_ONCE || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND))\n    {\n    if (detect_repeat(common, cc))\n      {\n      \/* These brackets are converted to repeats, so no global\n      based single character repeat is allowed. *\/\n      if (cc >= end)\n        end = bracketend(cc);\n      }\n    }\n  repeat_check = TRUE;\n\n  switch(*cc)\n    {\n    case OP_KET:\n    if (common->private_data_ptrs[cc + 1 - common->start] != 0)\n      {\n      common->private_data_ptrs[cc - common->start] = private_data_ptr;\n      private_data_ptr += sizeof(sljit_sw);\n      cc += common->private_data_ptrs[cc + 1 - common->start];\n      }\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_ASSERT:\n    case OP_ASSERT_NOT:\n    case OP_ASSERTBACK:\n    case OP_ASSERTBACK_NOT:\n    case OP_ASSERT_NA:\n    case OP_ASSERTBACK_NA:\n    case OP_ONCE:\n    case OP_SCRIPT_RUN:\n    case OP_BRAPOS:\n    case OP_SBRA:\n    case OP_SBRAPOS:\n    case OP_SCOND:\n    common->private_data_ptrs[cc - common->start] = private_data_ptr;\n    private_data_ptr += sizeof(sljit_sw);\n    bracketlen = 1 + LINK_SIZE;\n    break;\n\n    case OP_CBRAPOS:\n    case OP_SCBRAPOS:\n    common->private_data_ptrs[cc - common->start] = private_data_ptr;\n    private_data_ptr += sizeof(sljit_sw);\n    bracketlen = 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_COND:\n    \/* Might be a hidden SCOND. *\/\n    common->private_data_ptrs[cc - common->start] = 0;\n    alternative = cc + GET(cc, 1);\n    if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)\n      {\n      common->private_data_ptrs[cc - common->start] = private_data_ptr;\n      private_data_ptr += sizeof(sljit_sw);\n      }\n    bracketlen = 1 + LINK_SIZE;\n    break;\n\n    case OP_BRA:\n    bracketlen = 1 + LINK_SIZE;\n    break;\n\n    case OP_CBRA:\n    case OP_SCBRA:\n    bracketlen = 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_BRAZERO:\n    case OP_BRAMINZERO:\n    case OP_BRAPOSZERO:\n    size = 1;\n    repeat_check = FALSE;\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_1\n    size = -2;\n    space = 1;\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_2A\n    size = -2;\n    space = 2;\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_2B\n    size = -(2 + IMM2_SIZE);\n    space = 2;\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_1\n    size = 1;\n    space = 1;\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_2A\n    size = 1;\n    if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)\n      space = 2;\n    break;\n\n    case OP_TYPEUPTO:\n    size = 1 + IMM2_SIZE;\n    if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)\n      space = 2;\n    break;\n\n    case OP_TYPEMINUPTO:\n    size = 1 + IMM2_SIZE;\n    space = 2;\n    break;\n\n    case OP_CLASS:\n    case OP_NCLASS:\n    size = 1 + 32 \/ sizeof(PCRE2_UCHAR);\n    space = get_class_iterator_size(cc + size);\n    break;\n\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8\n    case OP_XCLASS:\n    size = GET(cc, 1);\n    space = get_class_iterator_size(cc + size);\n    break;\n#endif\n\n    default:\n    cc = next_opcode(common, cc);\n    SLJIT_ASSERT(cc != NULL);\n    break;\n    }\n\n  \/* Character iterators, which are not inside a repeated bracket,\n     gets a private slot instead of allocating it on the stack. *\/\n  if (space > 0 && cc >= end)\n    {\n    common->private_data_ptrs[cc - common->start] = private_data_ptr;\n    private_data_ptr += sizeof(sljit_sw) * space;\n    }\n\n  if (size != 0)\n    {\n    if (size < 0)\n      {\n      cc += -size;\n#ifdef SUPPORT_UNICODE\n      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n      }\n    else\n      cc += size;\n    }\n\n  if (bracketlen > 0)\n    {\n    if (cc >= end)\n      {\n      end = bracketend(cc);\n      if (end[-1 - LINK_SIZE] == OP_KET)\n        end = NULL;\n      }\n    cc += bracketlen;\n    }\n  }\n*private_data_start = private_data_ptr;\n}","target":0,"code_token_length":1271,"total_token_length":1507,"max_tokens_setting":2048}
+{"idx":424950,"func":"void iwl_trans_pcie_dump_regs(struct iwl_trans *trans)\n{\n#define PCI_DUMP_SIZE\t\t352\n#define PCI_MEM_DUMP_SIZE\t64\n#define PCI_PARENT_DUMP_SIZE\t524\n#define PREFIX_LEN\t\t32\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tstruct pci_dev *pdev = trans_pcie->pci_dev;\n\tu32 i, pos, alloc_size, *ptr, *buf;\n\tchar *prefix;\n\n\tif (trans_pcie->pcie_dbg_dumped_once)\n\t\treturn;\n\n\t\/* Should be a multiple of 4 *\/\n\tBUILD_BUG_ON(PCI_DUMP_SIZE > 4096 || PCI_DUMP_SIZE & 0x3);\n\tBUILD_BUG_ON(PCI_MEM_DUMP_SIZE > 4096 || PCI_MEM_DUMP_SIZE & 0x3);\n\tBUILD_BUG_ON(PCI_PARENT_DUMP_SIZE > 4096 || PCI_PARENT_DUMP_SIZE & 0x3);\n\n\t\/* Alloc a max size buffer *\/\n\talloc_size = PCI_ERR_ROOT_ERR_SRC +  4 + PREFIX_LEN;\n\talloc_size = max_t(u32, alloc_size, PCI_DUMP_SIZE + PREFIX_LEN);\n\talloc_size = max_t(u32, alloc_size, PCI_MEM_DUMP_SIZE + PREFIX_LEN);\n\talloc_size = max_t(u32, alloc_size, PCI_PARENT_DUMP_SIZE + PREFIX_LEN);\n\n\tbuf = kmalloc(alloc_size, GFP_ATOMIC);\n\tif (!buf)\n\t\treturn;\n\tprefix = (char *)buf + alloc_size - PREFIX_LEN;\n\n\tIWL_ERR(trans, \"iwlwifi transaction failed, dumping registers\\n\");\n\n\t\/* Print wifi device registers *\/\n\tsprintf(prefix, \"iwlwifi %s: \", pci_name(pdev));\n\tIWL_ERR(trans, \"iwlwifi device config registers:\\n\");\n\tfor (i = 0, ptr = buf; i < PCI_DUMP_SIZE; i += 4, ptr++)\n\t\tif (pci_read_config_dword(pdev, i, ptr))\n\t\t\tgoto err_read;\n\tprint_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0);\n\n\tIWL_ERR(trans, \"iwlwifi device memory mapped registers:\\n\");\n\tfor (i = 0, ptr = buf; i < PCI_MEM_DUMP_SIZE; i += 4, ptr++)\n\t\t*ptr = iwl_read32(trans, i);\n\tprint_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0);\n\n\tpos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);\n\tif (pos) {\n\t\tIWL_ERR(trans, \"iwlwifi device AER capability structure:\\n\");\n\t\tfor (i = 0, ptr = buf; i < PCI_ERR_ROOT_COMMAND; i += 4, ptr++)\n\t\t\tif (pci_read_config_dword(pdev, pos + i, ptr))\n\t\t\t\tgoto err_read;\n\t\tprint_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,\n\t\t\t       32, 4, buf, i, 0);\n\t}\n\n\t\/* Print parent device registers next *\/\n\tif (!pdev->bus->self)\n\t\tgoto out;\n\n\tpdev = pdev->bus->self;\n\tsprintf(prefix, \"iwlwifi %s: \", pci_name(pdev));\n\n\tIWL_ERR(trans, \"iwlwifi parent port (%s) config registers:\\n\",\n\t\tpci_name(pdev));\n\tfor (i = 0, ptr = buf; i < PCI_PARENT_DUMP_SIZE; i += 4, ptr++)\n\t\tif (pci_read_config_dword(pdev, i, ptr))\n\t\t\tgoto err_read;\n\tprint_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0);\n\n\t\/* Print root port AER registers *\/\n\tpos = 0;\n\tpdev = pcie_find_root_port(pdev);\n\tif (pdev)\n\t\tpos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);\n\tif (pos) {\n\t\tIWL_ERR(trans, \"iwlwifi root port (%s) AER cap structure:\\n\",\n\t\t\tpci_name(pdev));\n\t\tsprintf(prefix, \"iwlwifi %s: \", pci_name(pdev));\n\t\tfor (i = 0, ptr = buf; i <= PCI_ERR_ROOT_ERR_SRC; i += 4, ptr++)\n\t\t\tif (pci_read_config_dword(pdev, pos + i, ptr))\n\t\t\t\tgoto err_read;\n\t\tprint_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32,\n\t\t\t       4, buf, i, 0);\n\t}\n\tgoto out;\n\nerr_read:\n\tprint_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0);\n\tIWL_ERR(trans, \"Read failed at 0x%X\\n\", i);\nout:\n\ttrans_pcie->pcie_dbg_dumped_once = 1;\n\tkfree(buf);\n}","target":0,"code_token_length":1031,"total_token_length":1267,"max_tokens_setting":2048}
+{"idx":383947,"func":"cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,\n    size_t count, const uint64_t clsid[2])\n{\n        size_t i;\n        cdf_timestamp_t tp;\n        struct timespec ts;\n        char buf[64];\n        const char *str = NULL;\n        const char *s;\n        int len;\n\n        if (!NOTMIME(ms))\n\t\tstr = cdf_clsid_to_mime(clsid, clsid2mime);\n\n        for (i = 0; i < count; i++) {\n                cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);\n                switch (info[i].pi_type) {\n                case CDF_NULL:\n                        break;\n                case CDF_SIGNED16:\n                        if (NOTMIME(ms) && file_printf(ms, \", %s: %hd\", buf,\n                            info[i].pi_s16) == -1)\n                                return -1;\n                        break;\n                case CDF_SIGNED32:\n                        if (NOTMIME(ms) && file_printf(ms, \", %s: %d\", buf,\n                            info[i].pi_s32) == -1)\n                                return -1;\n                        break;\n                case CDF_UNSIGNED32:\n                        if (NOTMIME(ms) && file_printf(ms, \", %s: %u\", buf,\n                            info[i].pi_u32) == -1)\n                                return -1;\n                        break;\n                case CDF_FLOAT:\n                        if (NOTMIME(ms) && file_printf(ms, \", %s: %g\", buf,\n                            info[i].pi_f) == -1)\n                                return -1;\n                        break;\n                case CDF_DOUBLE:\n                        if (NOTMIME(ms) && file_printf(ms, \", %s: %g\", buf,\n                            info[i].pi_d) == -1)\n                                return -1;\n                        break;\n                case CDF_LENGTH32_STRING:\n                case CDF_LENGTH32_WSTRING:\n                        len = info[i].pi_str.s_len;\n                        if (len > 1) {\n                                char vbuf[1024];\n                                size_t j, k = 1;\n\n                                if (info[i].pi_type == CDF_LENGTH32_WSTRING)\n                                    k++;\n                                s = info[i].pi_str.s_buf;\n                                for (j = 0; j < sizeof(vbuf) && len--;\n                                    j++, s += k) {\n                                        if (*s == '\\0')\n                                                break;\n                                        if (isprint((unsigned char)*s))\n                                                vbuf[j] = *s;\n                                }\n                                if (j == sizeof(vbuf))\n                                        --j;\n                                vbuf[j] = '\\0';\n                                if (NOTMIME(ms)) {\n                                        if (vbuf[0]) {\n                                                if (file_printf(ms, \", %s: %s\",\n                                                    buf, vbuf) == -1)\n                                                        return -1;\n                                        }\n                                } else if (str == NULL && info[i].pi_id ==\n\t\t\t\t    CDF_PROPERTY_NAME_OF_APPLICATION) {\n\t\t\t\t\tstr = cdf_app_to_mime(vbuf, app2mime);\n\t\t\t\t}\n\t\t\t}\n                        break;\n                case CDF_FILETIME:\n                        tp = info[i].pi_tp;\n                        if (tp != 0) {\n\t\t\t\tchar tbuf[64];\n                                if (tp < 1000000000000000LL) {\n                                        cdf_print_elapsed_time(tbuf,\n                                            sizeof(tbuf), tp);\n                                        if (NOTMIME(ms) && file_printf(ms,\n                                            \", %s: %s\", buf, tbuf) == -1)\n                                                return -1;\n                                } else {\n                                        char *c, *ec;\n                                        cdf_timestamp_to_timespec(&ts, tp);\n                                        c = cdf_ctime(&ts.tv_sec, tbuf);\n                                        if (c != NULL &&\n\t\t\t\t\t    (ec = strchr(c, '\\n')) != NULL)\n\t\t\t\t\t\t*ec = '\\0';\n\n                                        if (NOTMIME(ms) && file_printf(ms,\n                                            \", %s: %s\", buf, c) == -1)\n                                                return -1;\n                                }\n                        }\n                        break;\n                case CDF_CLIPBOARD:\n                        break;\n                default:\n                        return -1;\n                }\n        }\n        if (!NOTMIME(ms)) {\n\t\tif (str == NULL)\n\t\t\treturn 0;\n                if (file_printf(ms, \"application\/%s\", str) == -1)\n                        return -1;\n        }\n        return 1;\n}","target":0,"code_token_length":960,"total_token_length":1196,"max_tokens_setting":2048}
+{"idx":197499,"func":"GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, GF_FieldInfo *field, Bool is_mem_com)\n{\n\tGF_Err e;\n\tu32 NbBits, nbFields;\n\tu32 i;\n\tGF_ChildNodeItem *last;\n\tu8 qp_local, qp_on, initial_qp;\n\tGF_FieldInfo sffield;\n\n\tmemset(&sffield, 0, sizeof(GF_FieldInfo));\n\tsffield.fieldIndex = field->fieldIndex;\n\tsffield.fieldType = gf_sg_vrml_get_sf_type(field->fieldType);\n\tsffield.NDTtype = field->NDTtype;\n\tsffield.name = field->name;\n\n\tinitial_qp = qp_local = qp_on = 0;\n\n\t\/\/vector description - alloc the MF size before\n\tNbBits = gf_bs_read_int(bs, 5);\n\tnbFields = gf_bs_read_int(bs, NbBits);\n\n\tif (codec->ActiveQP) {\n\t\tinitial_qp = 1;\n\t\t\/*this is for QP 14*\/\n\t\tgf_bifs_dec_qp14_set_length(codec, nbFields);\n\t}\n\n\tif (field->fieldType != GF_SG_VRML_MFNODE) {\n\t\te = gf_sg_vrml_mf_alloc(field->far_ptr, field->fieldType, nbFields);\n\t\tif (e) return e;\n\n\t\tfor (i=0; i<nbFields; i++) {\n\t\t\te = gf_sg_vrml_mf_get_item(field->far_ptr, field->fieldType, & sffield.far_ptr, i);\n\t\t\tif (e) return e;\n\t\t\te = gf_bifs_dec_sf_field(codec, bs, node, &sffield, GF_FALSE);\n\t\t\tif (e) return e;\n\t\t}\n\t} else {\n\t\tlast = NULL;\n\t\tfor (i=0; i<nbFields; i++) {\n\t\t\tGF_Node *new_node = gf_bifs_dec_node(codec, bs, field->NDTtype);\n\t\t\tif (new_node) {\n\t\t\t\te = gf_node_register(new_node, is_mem_com ? NULL : node);\n\t\t\t\tif (e) return e;\n\n\t\t\t\tif (node) {\n\t\t\t\t\t\/*special case for QP, register as the current QP*\/\n\t\t\t\t\tif (gf_node_get_tag(new_node) == TAG_MPEG4_QuantizationParameter) {\n\t\t\t\t\t\tqp_local = ((M_QuantizationParameter *)new_node)->isLocal;\n\t\t\t\t\t\t\/*we have a QP in the same scope, remove previous\n\t\t\t\t\t\tNB: we assume this is the right behavior, the spec doesn't say\n\t\t\t\t\t\twhether QP is cumulative or not*\/\n\t\t\t\t\t\tif (qp_on) gf_bifs_dec_qp_remove(codec, GF_FALSE);\n\n\t\t\t\t\t\te = gf_bifs_dec_qp_set(codec, new_node);\n\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\tqp_on = 1;\n\t\t\t\t\t\tif (qp_local) qp_local = 2;\n\t\t\t\t\t\tif (codec->force_keep_qp) {\n\t\t\t\t\t\t\te = gf_node_list_add_child_last(field->far_ptr, new_node, &last);\n\t\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgf_node_register(new_node, NULL);\n\t\t\t\t\t\t\tgf_node_unregister(new_node, node);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\te = gf_node_list_add_child_last(field->far_ptr, new_node, &last);\n\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\/*proto coding*\/\n\t\t\t\telse if (codec->pCurrentProto) {\n\t\t\t\t\t\/*TO DO: what happens if this is a QP node on the interface ?*\/\n\t\t\t\t\te = gf_node_list_add_child_last( (GF_ChildNodeItem **)field->far_ptr, new_node, &last);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn codec->LastError ? codec->LastError : GF_NON_COMPLIANT_BITSTREAM;\n\t\t\t}\n\t\t}\n\t\t\/*according to the spec, the QP applies to the current node itself, not just children.\n\t\tIf IsLocal is TRUE remove the node*\/\n\t\tif (qp_on && qp_local) {\n\t\t\tif (qp_local == 2) {\n\/\/\t\t\t\tqp_local = 1;\n\t\t\t} else {\n\t\t\t\t\/\/ask to get rid of QP and reactivate if we had a QP when entering the node\n\t\t\t\tgf_bifs_dec_qp_remove(codec, initial_qp);\n\/\/\t\t\t\tqp_local = 0;\n\t\t\t}\n\t\t}\n\t}\n\t\/*finally delete the QP if any (local or not) as we get out of this node*\/\n\tif (qp_on) gf_bifs_dec_qp_remove(codec, GF_TRUE);\n\treturn GF_OK;\n}","target":1,"code_token_length":996,"total_token_length":1232,"max_tokens_setting":2048}
+{"idx":293778,"func":"static void symbols_from_stubs(RList *ret, HtPP *kernel_syms_by_addr, RKernelCacheObj *obj, RBinFile *bf, RKext *kext, int ordinal) {\n\tRStubsInfo *stubs_info = get_stubs_info(kext->mach0, kext->range.offset, obj);\n\tif (!stubs_info) {\n\t\treturn;\n\t}\n\tut64 stubs_cursor = stubs_info->stubs.offset;\n\tut64 stubs_end = stubs_cursor + stubs_info->stubs.size;\n\n\tfor (; stubs_cursor < stubs_end; stubs_cursor += 12) {\n\t\tut8 arm64_code[8];\n\t\tif (r_buf_read_at (obj->cache_buf, stubs_cursor, arm64_code, 8) < 8) {\n\t\t\tbreak;\n\t\t}\n\n\t\tut64 vaddr = stubs_cursor + obj->pa2va_exec;\n\t\tut64 addr_in_got = extract_addr_from_code (arm64_code, vaddr);\n\n\t\tbool found = false;\n\t\tint level = 3;\n\n\t\tut64 target_addr = UT64_MAX;\n\n\t\twhile (!found && level-- > 0) {\n\t\t\tut64 offset_in_got = addr_in_got - obj->pa2va_exec;\n\t\t\tut64 addr;\n\t\t\tif (r_buf_read_at (obj->cache_buf, offset_in_got, (ut8*) &addr, 8) < 8) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (level == 2) {\n\t\t\t\ttarget_addr = addr;\n\t\t\t}\n\n\t\t\tr_strf_var (key, 32, \"%\"PFMT64x, addr);\n\t\t\tconst char *name = sdb_ht_find (kernel_syms_by_addr, key, &found);\n\n\t\t\tif (found) {\n\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tif (!sym) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsym->name = r_str_newf (\"stub.%s\", name);\n\t\t\t\tsym->vaddr = vaddr;\n\t\t\t\tsym->paddr = stubs_cursor;\n\t\t\t\tsym->size = 12;\n\t\t\t\tsym->forwarder = \"NONE\";\n\t\t\t\tsym->bind = \"LOCAL\";\n\t\t\t\tsym->type = \"FUNC\";\n\t\t\t\tsym->ordinal = ordinal ++;\n\t\t\t\tr_list_append (ret, sym);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\taddr_in_got = addr;\n\t\t}\n\n\t\tif (found || target_addr == UT64_MAX) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tensure_kexts_initialized (obj, bf);\n\t\tRKext *remote_kext = r_kext_index_vget (obj->kexts, target_addr);\n\t\tif (!remote_kext) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tRBinSymbol *remote_sym = R_NEW0 (RBinSymbol);\n\t\tif (!remote_sym) {\n\t\t\tbreak;\n\t\t}\n\n\t\tremote_sym->name = r_str_newf (\"exp.%s.0x%\"PFMT64x, kext_short_name (remote_kext), target_addr);\n\t\tremote_sym->vaddr = target_addr;\n\t\tremote_sym->paddr = target_addr - obj->pa2va_exec;\n\t\tremote_sym->size = 0;\n\t\tremote_sym->forwarder = \"NONE\";\n\t\tremote_sym->bind = \"GLOBAL\";\n\t\tremote_sym->type = \"FUNC\";\n\t\tremote_sym->ordinal = ordinal ++;\n\t\tr_list_append (ret, remote_sym);\n\n\t\tRBinSymbol *local_sym = R_NEW0 (RBinSymbol);\n\t\tif (!local_sym) {\n\t\t\tbreak;\n\t\t}\n\n\t\tlocal_sym->name = r_str_newf (\"stub.%s.0x%\"PFMT64x, kext_short_name (remote_kext), target_addr);\n\t\tlocal_sym->vaddr = vaddr;\n\t\tlocal_sym->paddr = stubs_cursor;\n\t\tlocal_sym->size = 12;\n\t\tlocal_sym->forwarder = \"NONE\";\n\t\tlocal_sym->bind = \"GLOBAL\";\n\t\tlocal_sym->type = \"FUNC\";\n\t\tlocal_sym->ordinal = ordinal ++;\n\t\tr_list_append (ret, local_sym);\n\t}\n\n\tR_FREE (stubs_info);\n}","target":0,"code_token_length":915,"total_token_length":1151,"max_tokens_setting":2048}
+{"idx":517443,"func":"static void do_home_process(HttpResponse res) {\n        char      buf[STRLEN];\n        boolean_t on = true;\n        boolean_t header = true;\n\n        for (Service_T s = servicelist_conf; s; s = s->next_conf) {\n                if (s->type != Service_Process)\n                        continue;\n                if (header) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<table id='header-row'>\"\n                                            \"<tr>\"\n                                            \"<th class='left' class='first'>Process<\/th>\"\n                                            \"<th class='left'>Status<\/th>\"\n                                            \"<th class='right'>Uptime<\/th>\"\n                                            \"<th class='right'>CPU Total<\/b><\/th>\"\n                                            \"<th class='right'>Memory Total<\/th>\"\n                                            \"<th class='right column'>Read<\/th>\"\n                                            \"<th class='right column'>Write<\/th>\"\n                                            \"<\/tr>\");\n                        header = false;\n                }\n                StringBuffer_append(res->outputbuffer,\n                                    \"<tr%s>\"\n                                    \"<td class='left'><a href='%s'>%s<\/a><\/td>\"\n                                    \"<td class='left'>%s<\/td>\",\n                                    on ? \" class='stripe'\" : \"\",\n                                    s->name, s->name,\n                                    get_service_status(HTML, s, buf, sizeof(buf)));\n                if (! (Run.flags & Run_ProcessEngineEnabled) || ! Util_hasServiceStatus(s) || s->inf.process->uptime < 0) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%s<\/td>\", _getUptime(s->inf.process->uptime, (char[256]){}));\n                }\n                if (! (Run.flags & Run_ProcessEngineEnabled) || ! Util_hasServiceStatus(s) || s->inf.process->total_cpu_percent < 0) {\n                                StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right%s'>%.1f%%<\/td>\", (s->error & Event_Resource) ? \" red-text\" : \"\", s->inf.process->total_cpu_percent);\n                }\n                if (! (Run.flags & Run_ProcessEngineEnabled) || ! Util_hasServiceStatus(s) || s->inf.process->total_mem_percent < 0) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right%s'>%.1f%% [%s]<\/td>\", (s->error & Event_Resource) ? \" red-text\" : \"\", s->inf.process->total_mem_percent, Fmt_bytes2str(s->inf.process->total_mem, buf));\n                }\n                boolean_t hasReadBytes = Statistics_initialized(&(s->inf.process->read.bytes));\n                boolean_t hasReadOperations = Statistics_initialized(&(s->inf.process->read.operations));\n                if (! (Run.flags & Run_ProcessEngineEnabled) || ! Util_hasServiceStatus(s) || (! hasReadBytes && ! hasReadOperations)) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right column'>-<\/td>\");\n                } else if (hasReadBytes) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right column%s'>%s\/s<\/td>\", (s->error & Event_Resource) ? \" red-text\" : \"\", Fmt_bytes2str(Statistics_deltaNormalize(&(s->inf.process->read.bytes)), (char[10]){}));\n                } else if (hasReadOperations) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right column%s'>%.1f\/s<\/td>\", (s->error & Event_Resource) ? \" red-text\" : \"\", Statistics_deltaNormalize(&(s->inf.process->read.operations)));\n                }\n                boolean_t hasWriteBytes = Statistics_initialized(&(s->inf.process->write.bytes));\n                boolean_t hasWriteOperations = Statistics_initialized(&(s->inf.process->write.operations));\n                if (! (Run.flags & Run_ProcessEngineEnabled) || ! Util_hasServiceStatus(s) || (! hasWriteBytes && ! hasWriteOperations)) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right column'>-<\/td>\");\n                } else if (hasWriteBytes) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right column%s'>%s\/s<\/td>\", (s->error & Event_Resource) ? \" red-text\" : \"\", Fmt_bytes2str(Statistics_deltaNormalize(&(s->inf.process->write.bytes)), (char[10]){}));\n                } else if (hasWriteOperations) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right column%s'>%.1f\/s<\/td>\", (s->error & Event_Resource) ? \" red-text\" : \"\", Statistics_deltaNormalize(&(s->inf.process->write.operations)));\n                }\n                StringBuffer_append(res->outputbuffer, \"<\/tr>\");\n                on = ! on;\n        }\n        if (! header)\n                StringBuffer_append(res->outputbuffer, \"<\/table>\");\n}","target":0,"code_token_length":1064,"total_token_length":1300,"max_tokens_setting":2048}
+{"idx":353189,"func":"void SplashOutputDev::setSoftMask(GfxState *state, const double *bbox,\n\t\t\t\t  bool alpha, Function *transferFunc,\n\t\t\t\t  GfxColor *backdropColor) {\n  SplashBitmap *softMask, *tBitmap;\n  Splash *tSplash;\n  SplashTransparencyGroup *transpGroup;\n  SplashColor color;\n  SplashColorPtr p;\n  GfxGray gray;\n  GfxRGB rgb;\n#ifdef SPLASH_CMYK\n  GfxCMYK cmyk;\n  GfxColor deviceN;\n#endif\n  double lum, lum2;\n  int tx, ty, x, y;\n\n  tx = transpGroupStack->tx;\n  ty = transpGroupStack->ty;\n  tBitmap = transpGroupStack->tBitmap;\n\n  \/\/ composite with backdrop color\n  if (!alpha && tBitmap->getMode() != splashModeMono1) {\n    \/\/~ need to correctly handle the case where no blending color\n    \/\/~ space is given\n    if (transpGroupStack->blendingColorSpace) {\n      tSplash = new Splash(tBitmap, vectorAntialias,\n\t\t\t   transpGroupStack->origSplash->getScreen());\n      switch (tBitmap->getMode()) {\n      case splashModeMono1:\n\t\/\/ transparency is not supported in mono1 mode\n\tbreak;\n      case splashModeMono8:\n\ttranspGroupStack->blendingColorSpace->getGray(backdropColor, &gray);\n\tcolor[0] = colToByte(gray);\n\ttSplash->compositeBackground(color);\n\tbreak;\n      case splashModeXBGR8:\n\tcolor[3] = 255;\n\t\/\/ fallthrough\n      case splashModeRGB8:\n      case splashModeBGR8:\n\ttranspGroupStack->blendingColorSpace->getRGB(backdropColor, &rgb);\n\tcolor[0] = colToByte(rgb.r);\n\tcolor[1] = colToByte(rgb.g);\n\tcolor[2] = colToByte(rgb.b);\n\ttSplash->compositeBackground(color);\n\tbreak;\n#ifdef SPLASH_CMYK\n      case splashModeCMYK8:\n\ttranspGroupStack->blendingColorSpace->getCMYK(backdropColor, &cmyk);\n\tcolor[0] = colToByte(cmyk.c);\n\tcolor[1] = colToByte(cmyk.m);\n\tcolor[2] = colToByte(cmyk.y);\n\tcolor[3] = colToByte(cmyk.k);\n\ttSplash->compositeBackground(color);\n\tbreak;\n      case splashModeDeviceN8:\n\ttranspGroupStack->blendingColorSpace->getDeviceN(backdropColor, &deviceN);\n  for (int cp=0; cp < SPOT_NCOMPS+4; cp++)\n    color[cp] = colToByte(deviceN.c[cp]);\n\ttSplash->compositeBackground(color);\n\tbreak;\n#endif\n      }\n      delete tSplash;\n    }\n  }\n\n  softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),\n\t\t\t      1, splashModeMono8, false);\n  unsigned char fill = 0;\n  if (transpGroupStack->blendingColorSpace) {\n\ttranspGroupStack->blendingColorSpace->getGray(backdropColor, &gray);\n\tfill = colToByte(gray);\n  }\n  memset(softMask->getDataPtr(), fill,\n\t softMask->getRowSize() * softMask->getHeight());\n  p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx;\n  int xMax = tBitmap->getWidth();\n  int yMax = tBitmap->getHeight();\n  if (xMax > bitmap->getWidth() - tx) xMax = bitmap->getWidth() - tx;\n  if (yMax > bitmap->getHeight() - ty) yMax = bitmap->getHeight() - ty;\n  for (y = 0; y < yMax; ++y) {\n    for (x = 0; x < xMax; ++x) {\n      if (alpha) {\n\tif (transferFunc) {\n\t  lum = tBitmap->getAlpha(x, y) \/ 255.0;\n\t  transferFunc->transform(&lum, &lum2);\n\t  p[x] = (int)(lum2 * 255.0 + 0.5);\n\t} else \n\t  p[x] = tBitmap->getAlpha(x, y);\n      } else {\n\t  tBitmap->getPixel(x, y, color);\n\t  \/\/ convert to luminosity\n\t  switch (tBitmap->getMode()) {\n\t  case splashModeMono1:\n\t  case splashModeMono8:\n\t    lum = color[0] \/ 255.0;\n\t    break;\n\t  case splashModeXBGR8:\n\t  case splashModeRGB8:\n\t  case splashModeBGR8:\n\t    lum = (0.3 \/ 255.0) * color[0] +\n\t          (0.59 \/ 255.0) * color[1] +\n\t          (0.11 \/ 255.0) * color[2];\n\t    break;\n#ifdef SPLASH_CMYK\n\t  case splashModeCMYK8:\n    case splashModeDeviceN8:\n\t    lum = (1 - color[3] \/ 255.0)\n\t          - (0.3 \/ 255.0) * color[0]\n\t          - (0.59 \/ 255.0) * color[1]\n\t          - (0.11 \/ 255.0) * color[2];\n\t    if (lum < 0) {\n\t      lum = 0;\n\t    }\n\t    break;\n#endif\n\t}\n\tif (transferFunc) {\n\t  transferFunc->transform(&lum, &lum2);\n\t} else {\n\t  lum2 = lum;\n\t}\n\tp[x] = (int)(lum2 * 255.0 + 0.5);\n      }\n    }\n\tp += softMask->getRowSize();\n  }\n  splash->setSoftMask(softMask);\n\n  \/\/ pop the stack\n  transpGroup = transpGroupStack;\n  transpGroupStack = transpGroup->next;\n  delete transpGroup;\n\n  delete tBitmap;\n}","target":0,"code_token_length":1311,"total_token_length":1547,"max_tokens_setting":2048}
+{"idx":365626,"func":"_asn1_check_identifier (asn1_node node)\n{\n  asn1_node p, p2;\n  char name2[ASN1_MAX_NAME_SIZE * 2 + 2];\n\n  if (node == NULL)\n    return ASN1_ELEMENT_NOT_FOUND;\n\n  p = node;\n  while (p)\n    {\n      if (p->value && type_field (p->type) == ASN1_ETYPE_IDENTIFIER)\n\t{\n\t  _asn1_str_cpy (name2, sizeof (name2), node->name);\n\t  _asn1_str_cat (name2, sizeof (name2), \".\");\n\t  _asn1_str_cat (name2, sizeof (name2), (char *) p->value);\n\t  p2 = asn1_find_node (node, name2);\n\t  if (p2 == NULL)\n\t    {\n\t      if (p->value)\n\t\t_asn1_strcpy (_asn1_identifierMissing, p->value);\n\t      else\n\t\t_asn1_strcpy (_asn1_identifierMissing, \"(null)\");\n\t      return ASN1_IDENTIFIER_NOT_FOUND;\n\t    }\n\t}\n      else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&\n\t       (p->type & CONST_DEFAULT))\n\t{\n\t  p2 = p->down;\n\t  if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))\n\t    {\n\t      _asn1_str_cpy (name2, sizeof (name2), node->name);\n\t      _asn1_str_cat (name2, sizeof (name2), \".\");\n\t      _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);\n\t      _asn1_strcpy (_asn1_identifierMissing, p2->value);\n\t      p2 = asn1_find_node (node, name2);\n\t      if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) ||\n\t\t  !(p2->type & CONST_ASSIGN))\n\t\treturn ASN1_IDENTIFIER_NOT_FOUND;\n\t      else\n\t\t_asn1_identifierMissing[0] = 0;\n\t    }\n\t}\n      else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&\n\t       (p->type & CONST_ASSIGN))\n\t{\n\t  p2 = p->down;\n\t  if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))\n\t    {\n\t      if (p2->value && !isdigit (p2->value[0]))\n\t\t{\n\t\t  _asn1_str_cpy (name2, sizeof (name2), node->name);\n\t\t  _asn1_str_cat (name2, sizeof (name2), \".\");\n\t\t  _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);\n\t\t  _asn1_strcpy (_asn1_identifierMissing, p2->value);\n\t\t  p2 = asn1_find_node (node, name2);\n\t\t  if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID)\n\t\t      || !(p2->type & CONST_ASSIGN))\n\t\t    return ASN1_IDENTIFIER_NOT_FOUND;\n\t\t  else\n\t\t    _asn1_identifierMissing[0] = 0;\n\t\t}\n\t    }\n\t}\n\n      if (p->down)\n\t{\n\t  p = p->down;\n\t}\n      else if (p->right)\n\tp = p->right;\n      else\n\t{\n\t  while (1)\n\t    {\n\t      p = _asn1_get_up (p);\n\t      if (p == node)\n\t\t{\n\t\t  p = NULL;\n\t\t  break;\n\t\t}\n\t      if (p->right)\n\t\t{\n\t\t  p = p->right;\n\t\t  break;\n\t\t}\n\t    }\n\t}\n    }\n\n  return ASN1_SUCCESS;\n}","target":0,"code_token_length":792,"total_token_length":1028,"max_tokens_setting":2048}
+{"idx":203902,"func":"get_one_sourceline(source_cookie_T *sp)\n{\n    garray_T\t\tga;\n    int\t\t\tlen;\n    int\t\t\tc;\n    char_u\t\t*buf;\n#ifdef USE_CRNL\n    int\t\t\thas_cr;\t\t\/\/ CR-LF found\n#endif\n    int\t\t\thave_read = FALSE;\n\n    \/\/ use a growarray to store the sourced line\n    ga_init2(&ga, 1, 250);\n\n    \/\/ Loop until there is a finished line (or end-of-file).\n    ++sp->sourcing_lnum;\n    for (;;)\n    {\n\t\/\/ make room to read at least 120 (more) characters\n\tif (ga_grow(&ga, 120) == FAIL)\n\t    break;\n\tif (sp->source_from_buf)\n\t{\n\t    if (sp->buf_lnum >= sp->buflines.ga_len)\n\t\tbreak;\t\t    \/\/ all the lines are processed\n\t    ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);\n\t    sp->buf_lnum++;\n\t    if (ga_grow(&ga, 1) == FAIL)\n\t\tbreak;\n\t    buf = (char_u *)ga.ga_data;\n\t    buf[ga.ga_len++] = NUL;\n\t}\n\telse\n\t{\n\t    buf = (char_u *)ga.ga_data;\n\t    if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,\n\t\t\tsp->fp) == NULL)\n\t\tbreak;\n\t}\n\tlen = ga.ga_len + (int)STRLEN(buf + ga.ga_len);\n#ifdef USE_CRNL\n\t\/\/ Ignore a trailing CTRL-Z, when in Dos mode.\tOnly recognize the\n\t\/\/ CTRL-Z by its own, or after a NL.\n\tif (\t   (len == 1 || (len >= 2 && buf[len - 2] == '\\n'))\n\t\t&& sp->fileformat == EOL_DOS\n\t\t&& buf[len - 1] == Ctrl_Z)\n\t{\n\t    buf[len - 1] = NUL;\n\t    break;\n\t}\n#endif\n\n\thave_read = TRUE;\n\tga.ga_len = len;\n\n\t\/\/ If the line was longer than the buffer, read more.\n\tif (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\\n')\n\t    continue;\n\n\tif (len >= 1 && buf[len - 1] == '\\n')\t\/\/ remove trailing NL\n\t{\n#ifdef USE_CRNL\n\t    has_cr = (len >= 2 && buf[len - 2] == '\\r');\n\t    if (sp->fileformat == EOL_UNKNOWN)\n\t    {\n\t\tif (has_cr)\n\t\t    sp->fileformat = EOL_DOS;\n\t\telse\n\t\t    sp->fileformat = EOL_UNIX;\n\t    }\n\n\t    if (sp->fileformat == EOL_DOS)\n\t    {\n\t\tif (has_cr)\t    \/\/ replace trailing CR\n\t\t{\n\t\t    buf[len - 2] = '\\n';\n\t\t    --len;\n\t\t    --ga.ga_len;\n\t\t}\n\t\telse\t    \/\/ lines like \":map xx yy^M\" will have failed\n\t\t{\n\t\t    if (!sp->error)\n\t\t    {\n\t\t\tmsg_source(HL_ATTR(HLF_W));\n\t\t\temsg(_(\"W15: Warning: Wrong line separator, ^M may be missing\"));\n\t\t    }\n\t\t    sp->error = TRUE;\n\t\t    sp->fileformat = EOL_UNIX;\n\t\t}\n\t    }\n#endif\n\t    \/\/ The '\\n' is escaped if there is an odd number of ^V's just\n\t    \/\/ before it, first set \"c\" just before the 'V's and then check\n\t    \/\/ len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo\n\t    for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--)\n\t\t;\n\t    if ((len & 1) != (c & 1))\t\/\/ escaped NL, read more\n\t    {\n\t\t++sp->sourcing_lnum;\n\t\tcontinue;\n\t    }\n\n\t    buf[len - 1] = NUL;\t\t\/\/ remove the NL\n\t}\n\n\t\/\/ Check for ^C here now and then, so recursive :so can be broken.\n\tline_breakcheck();\n\tbreak;\n    }\n\n    if (have_read)\n\treturn (char_u *)ga.ga_data;\n\n    vim_free(ga.ga_data);\n    return NULL;\n}","target":1,"code_token_length":943,"total_token_length":1179,"max_tokens_setting":2048}
+{"idx":411892,"func":"extrainfo_parse_entry_from_string(const char *s, const char *end,\n                           int cache_copy, struct digest_ri_map_t *routermap)\n{\n  extrainfo_t *extrainfo = NULL;\n  char digest[128];\n  smartlist_t *tokens = NULL;\n  directory_token_t *tok;\n  crypto_pk_env_t *key = NULL;\n  routerinfo_t *router = NULL;\n  memarea_t *area = NULL;\n  const char *s_dup = s;\n\n  if (!end) {\n    end = s + strlen(s);\n  }\n\n  \/* point 'end' to a point immediately after the final newline. *\/\n  while (end > s+2 && *(end-1) == '\\n' && *(end-2) == '\\n')\n    --end;\n\n  if (router_get_extrainfo_hash(s, digest) < 0) {\n    log_warn(LD_DIR, \"Couldn't compute router hash.\");\n    goto err;\n  }\n  tokens = smartlist_create();\n  area = memarea_new();\n  if (tokenize_string(area,s,end,tokens,extrainfo_token_table,0)) {\n    log_warn(LD_DIR, \"Error tokenizing extra-info document.\");\n    goto err;\n  }\n\n  if (smartlist_len(tokens) < 2) {\n    log_warn(LD_DIR, \"Impossibly short extra-info document.\");\n    goto err;\n  }\n\n  tok = smartlist_get(tokens,0);\n  if (tok->tp != K_EXTRA_INFO) {\n    log_warn(LD_DIR,\"Entry does not start with \\\"extra-info\\\"\");\n    goto err;\n  }\n\n  extrainfo = tor_malloc_zero(sizeof(extrainfo_t));\n  extrainfo->cache_info.is_extrainfo = 1;\n  if (cache_copy)\n    extrainfo->cache_info.signed_descriptor_body = tor_strndup(s, end-s);\n  extrainfo->cache_info.signed_descriptor_len = end-s;\n  memcpy(extrainfo->cache_info.signed_descriptor_digest, digest, DIGEST_LEN);\n\n  tor_assert(tok->n_args >= 2);\n  if (!is_legal_nickname(tok->args[0])) {\n    log_warn(LD_DIR,\"Bad nickname %s on \\\"extra-info\\\"\",escaped(tok->args[0]));\n    goto err;\n  }\n  strlcpy(extrainfo->nickname, tok->args[0], sizeof(extrainfo->nickname));\n  if (strlen(tok->args[1]) != HEX_DIGEST_LEN ||\n      base16_decode(extrainfo->cache_info.identity_digest, DIGEST_LEN,\n                    tok->args[1], HEX_DIGEST_LEN)) {\n    log_warn(LD_DIR,\"Invalid fingerprint %s on \\\"extra-info\\\"\",\n             escaped(tok->args[1]));\n    goto err;\n  }\n\n  tok = find_by_keyword(tokens, K_PUBLISHED);\n  if (parse_iso_time(tok->args[0], &extrainfo->cache_info.published_on)) {\n    log_warn(LD_DIR,\"Invalid published time %s on \\\"extra-info\\\"\",\n             escaped(tok->args[0]));\n    goto err;\n  }\n\n  if (routermap &&\n      (router = digestmap_get((digestmap_t*)routermap,\n                              extrainfo->cache_info.identity_digest))) {\n    key = router->identity_pkey;\n  }\n\n  tok = find_by_keyword(tokens, K_ROUTER_SIGNATURE);\n  if (strcmp(tok->object_type, \"SIGNATURE\") ||\n      tok->object_size < 128 || tok->object_size > 512) {\n    log_warn(LD_DIR, \"Bad object type or length on extra-info signature\");\n    goto err;\n  }\n\n  if (key) {\n    note_crypto_pk_op(VERIFY_RTR);\n    if (check_signature_token(digest, DIGEST_LEN, tok, key, 0,\n                              \"extra-info\") < 0)\n      goto err;\n\n    if (router)\n      extrainfo->cache_info.send_unencrypted =\n        router->cache_info.send_unencrypted;\n  } else {\n    extrainfo->pending_sig = tor_memdup(tok->object_body,\n                                        tok->object_size);\n    extrainfo->pending_sig_len = tok->object_size;\n  }\n\n  goto done;\n err:\n  dump_desc(s_dup, \"extra-info descriptor\");\n  extrainfo_free(extrainfo);\n  extrainfo = NULL;\n done:\n  if (tokens) {\n    SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));\n    smartlist_free(tokens);\n  }\n  if (area) {\n    DUMP_AREA(area, \"extrainfo\");\n    memarea_drop_all(area);\n  }\n  return extrainfo;\n}","target":0,"code_token_length":981,"total_token_length":1217,"max_tokens_setting":2048}
+{"idx":238588,"func":"static int check_atomic(struct bpf_verifier_env *env, int insn_idx, struct bpf_insn *insn)\n{\n\tint load_reg;\n\tint err;\n\n\tswitch (insn->imm) {\n\tcase BPF_ADD:\n\tcase BPF_ADD | BPF_FETCH:\n\tcase BPF_AND:\n\tcase BPF_AND | BPF_FETCH:\n\tcase BPF_OR:\n\tcase BPF_OR | BPF_FETCH:\n\tcase BPF_XOR:\n\tcase BPF_XOR | BPF_FETCH:\n\tcase BPF_XCHG:\n\tcase BPF_CMPXCHG:\n\t\tbreak;\n\tdefault:\n\t\tverbose(env, \"BPF_ATOMIC uses invalid atomic opcode %02x\\n\", insn->imm);\n\t\treturn -EINVAL;\n\t}\n\n\tif (BPF_SIZE(insn->code) != BPF_W && BPF_SIZE(insn->code) != BPF_DW) {\n\t\tverbose(env, \"invalid atomic operand size\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t\/* check src1 operand *\/\n\terr = check_reg_arg(env, insn->src_reg, SRC_OP);\n\tif (err)\n\t\treturn err;\n\n\t\/* check src2 operand *\/\n\terr = check_reg_arg(env, insn->dst_reg, SRC_OP);\n\tif (err)\n\t\treturn err;\n\n\tif (insn->imm == BPF_CMPXCHG) {\n\t\t\/* Check comparison of R0 with memory location *\/\n\t\tconst u32 aux_reg = BPF_REG_0;\n\n\t\terr = check_reg_arg(env, aux_reg, SRC_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (is_pointer_value(env, aux_reg)) {\n\t\t\tverbose(env, \"R%d leaks addr into mem\\n\", aux_reg);\n\t\t\treturn -EACCES;\n\t\t}\n\t}\n\n\tif (is_pointer_value(env, insn->src_reg)) {\n\t\tverbose(env, \"R%d leaks addr into mem\\n\", insn->src_reg);\n\t\treturn -EACCES;\n\t}\n\n\tif (is_ctx_reg(env, insn->dst_reg) ||\n\t    is_pkt_reg(env, insn->dst_reg) ||\n\t    is_flow_key_reg(env, insn->dst_reg) ||\n\t    is_sk_reg(env, insn->dst_reg)) {\n\t\tverbose(env, \"BPF_ATOMIC stores into R%d %s is not allowed\\n\",\n\t\t\tinsn->dst_reg,\n\t\t\treg_type_str(env, reg_state(env, insn->dst_reg)->type));\n\t\treturn -EACCES;\n\t}\n\n\tif (insn->imm & BPF_FETCH) {\n\t\tif (insn->imm == BPF_CMPXCHG)\n\t\t\tload_reg = BPF_REG_0;\n\t\telse\n\t\t\tload_reg = insn->src_reg;\n\n\t\t\/* check and record load of old value *\/\n\t\terr = check_reg_arg(env, load_reg, DST_OP);\n\t\tif (err)\n\t\t\treturn err;\n\t} else {\n\t\t\/* This instruction accesses a memory location but doesn't\n\t\t * actually load it into a register.\n\t\t *\/\n\t\tload_reg = -1;\n\t}\n\n\t\/* Check whether we can read the memory, with second call for fetch\n\t * case to simulate the register fill.\n\t *\/\n\terr = check_mem_access(env, insn_idx, insn->dst_reg, insn->off,\n\t\t\t       BPF_SIZE(insn->code), BPF_READ, -1, true);\n\tif (!err && load_reg >= 0)\n\t\terr = check_mem_access(env, insn_idx, insn->dst_reg, insn->off,\n\t\t\t\t       BPF_SIZE(insn->code), BPF_READ, load_reg,\n\t\t\t\t       true);\n\tif (err)\n\t\treturn err;\n\n\t\/* Check whether we can write into the same memory. *\/\n\terr = check_mem_access(env, insn_idx, insn->dst_reg, insn->off,\n\t\t\t       BPF_SIZE(insn->code), BPF_WRITE, -1, true);\n\tif (err)\n\t\treturn err;\n\n\treturn 0;\n}","target":0,"code_token_length":806,"total_token_length":1042,"max_tokens_setting":2048}
+{"idx":195023,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor* input_indices;\n    const Tensor* input_values;\n    const Tensor* input_shape;\n    SparseTensorsMap* map;\n\n    OP_REQUIRES_OK(context, context->input(\"sparse_indices\", &input_indices));\n    OP_REQUIRES_OK(context, context->input(\"sparse_values\", &input_values));\n    OP_REQUIRES_OK(context, context->input(\"sparse_shape\", &input_shape));\n    OP_REQUIRES_OK(context, GetMap(context, true \/* is_writing *\/, &map));\n\n    OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices->shape()),\n                errors::InvalidArgument(\n                    \"Input indices should be a matrix but received shape \",\n                    input_indices->shape().DebugString()));\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(input_values->shape()),\n                errors::InvalidArgument(\n                    \"Input values should be a vector but received shape \",\n                    input_values->shape().DebugString()));\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape->shape()),\n                errors::InvalidArgument(\n                    \"Input shape should be a vector but received shape \",\n                    input_shape->shape().DebugString()));\n    OP_REQUIRES(\n        context,\n        input_values->shape().dim_size(0) == input_indices->shape().dim_size(0),\n        errors::InvalidArgument(\n            \"Number of values must match first dimension of indices. \", \"Got \",\n            input_values->shape().dim_size(0),\n            \" values, indices shape: \", input_indices->shape().DebugString()));\n    OP_REQUIRES(\n        context,\n        input_shape->shape().dim_size(0) == input_indices->shape().dim_size(1),\n        errors::InvalidArgument(\n            \"Number of dimensions must match second dimension of indices. \",\n            \"Got \", input_shape->shape().dim_size(0),\n            \" dimensions, indices shape: \",\n            input_indices->shape().DebugString()));\n\n    int rank = input_shape->NumElements();\n\n    OP_REQUIRES(\n        context, rank > 1,\n        errors::InvalidArgument(\n            \"Rank of input SparseTensor should be > 1, but saw rank: \", rank));\n\n    auto input_shape_vec = input_shape->vec<int64_t>();\n    int new_num_elements = 1;\n    bool overflow_ocurred = false;\n    for (int i = 0; i < input_shape_vec.size(); i++) {\n      new_num_elements =\n          MultiplyWithoutOverflow(new_num_elements, input_shape_vec(i));\n      if (new_num_elements < 0) {\n        overflow_ocurred = true;\n        break;\n      }\n    }\n\n    OP_REQUIRES(\n        context, !overflow_ocurred,\n        errors::Internal(\"Encountered overflow from large input shape.\"));\n\n    TensorShape tensor_input_shape(input_shape_vec);\n    gtl::InlinedVector<int64_t, 8> std_order(rank);\n    std::iota(std_order.begin(), std_order.end(), 0);\n    SparseTensor input_st;\n    OP_REQUIRES_OK(context, SparseTensor::Create(*input_indices, *input_values,\n                                                 tensor_input_shape, std_order,\n                                                 &input_st));\n\n    const int64_t N = input_shape_vec(0);\n\n    Tensor sparse_handles(DT_INT64, TensorShape({N}));\n    auto sparse_handles_t = sparse_handles.vec<int64_t>();\n\n    OP_REQUIRES_OK(context, input_st.IndicesValid());\n\n    \/\/ We can generate the output shape proto string now, for all\n    \/\/ minibatch entries.\n    TensorShape output_shape;\n    OP_REQUIRES_OK(context, TensorShapeUtils::MakeShape(\n                                input_shape_vec.data() + 1,\n                                input_shape->NumElements() - 1, &output_shape));\n\n    \/\/ Get groups by minibatch dimension\n    std::unordered_set<int64_t> visited;\n    sparse::GroupIterable minibatch = input_st.group({0});\n    for (const auto& subset : minibatch) {\n      const int64_t b = subset.group()[0];\n      visited.insert(b);\n      OP_REQUIRES(\n          context, b > -1 && b < N,\n          errors::InvalidArgument(\n              \"Received unexpected column 0 value in input SparseTensor: \", b,\n              \" < 0 or >= N (= \", N, \")\"));\n\n      const auto indices = subset.indices();\n      const auto values = subset.values<T>();\n      const int64_t num_entries = values.size();\n\n      Tensor output_indices = Tensor(DT_INT64, {num_entries, rank - 1});\n      Tensor output_values = Tensor(DataTypeToEnum<T>::value, {num_entries});\n\n      auto output_indices_t = output_indices.matrix<int64_t>();\n      auto output_values_t = output_values.vec<T>();\n\n      for (int i = 0; i < num_entries; ++i) {\n        for (int d = 1; d < rank; ++d) {\n          output_indices_t(i, d - 1) = indices(i, d);\n        }\n        output_values_t(i) = values(i);\n      }\n\n      SparseTensor st_i;\n      OP_REQUIRES_OK(context,\n                     SparseTensor::Create(output_indices, output_values,\n                                          output_shape, &st_i));\n      int64_t handle;\n      OP_REQUIRES_OK(context, map->AddSparseTensor(context, st_i, &handle));\n      sparse_handles_t(b) = handle;\n    }\n\n    \/\/ Fill in any gaps; we must provide an empty ST for batch entries\n    \/\/ the grouper didn't find.\n    if (visited.size() < N) {\n      Tensor empty_indices(DT_INT64, {0, rank - 1});\n      Tensor empty_values(DataTypeToEnum<T>::value, {0});\n      SparseTensor empty_st;\n      OP_REQUIRES_OK(context, SparseTensor::Create(empty_indices, empty_values,\n                                                   output_shape, &empty_st));\n\n      for (int64_t b = 0; b < N; ++b) {\n        \/\/ We skipped this batch entry.\n        if (visited.find(b) == visited.end()) {\n          int64_t handle;\n          OP_REQUIRES_OK(context,\n                         map->AddSparseTensor(context, empty_st, &handle));\n          sparse_handles_t(b) = handle;\n        }\n      }\n    }\n\n    context->set_output(0, sparse_handles);\n  }","target":1,"code_token_length":1322,"total_token_length":1558,"max_tokens_setting":2048}
+{"idx":361306,"func":"stl_which_vertices_to_change(stl_file *stl, stl_hash_edge *edge_a,\n                             stl_hash_edge *edge_b, int *facet1, int *vertex1,\n                             int *facet2, int *vertex2,\n                             stl_vertex *new_vertex1, stl_vertex *new_vertex2) {\n  int v1a;\t\t\t\/* pair 1, facet a *\/\n  int v1b;\t\t\t\/* pair 1, facet b *\/\n  int v2a;\t\t\t\/* pair 2, facet a *\/\n  int v2b;\t\t\t\/* pair 2, facet b *\/\n\n  \/* Find first pair *\/\n  if(edge_a->which_edge < 3) {\n    v1a = edge_a->which_edge;\n    v2a = (edge_a->which_edge + 1) % 3;\n  } else {\n    v2a = edge_a->which_edge % 3;\n    v1a = (edge_a->which_edge + 1) % 3;\n  }\n  if(edge_b->which_edge < 3) {\n    v1b = edge_b->which_edge;\n    v2b = (edge_b->which_edge + 1) % 3;\n  } else {\n    v2b = edge_b->which_edge % 3;\n    v1b = (edge_b->which_edge + 1) % 3;\n  }\n\n  \/* Of the first pair, which vertex, if any, should be changed *\/\n  if(!memcmp(&stl->facet_start[edge_a->facet_number].vertex[v1a],\n             &stl->facet_start[edge_b->facet_number].vertex[v1b],\n             sizeof(stl_vertex))) {\n    \/* These facets are already equal.  No need to change. *\/\n    *facet1 = -1;\n  } else {\n    if(   (stl->neighbors_start[edge_a->facet_number].neighbor[v1a] == -1)\n          && (stl->neighbors_start[edge_a->facet_number].\n              neighbor[(v1a + 2) % 3] == -1)) {\n      \/* This vertex has no neighbors.  This is a good one to change *\/\n      *facet1 = edge_a->facet_number;\n      *vertex1 = v1a;\n      *new_vertex1 = stl->facet_start[edge_b->facet_number].vertex[v1b];\n    } else {\n      *facet1 = edge_b->facet_number;\n      *vertex1 = v1b;\n      *new_vertex1 = stl->facet_start[edge_a->facet_number].vertex[v1a];\n    }\n  }\n\n  \/* Of the second pair, which vertex, if any, should be changed *\/\n  if(!memcmp(&stl->facet_start[edge_a->facet_number].vertex[v2a],\n             &stl->facet_start[edge_b->facet_number].vertex[v2b],\n             sizeof(stl_vertex))) {\n    \/* These facets are already equal.  No need to change. *\/\n    *facet2 = -1;\n  } else {\n    if(   (stl->neighbors_start[edge_a->facet_number].neighbor[v2a] == -1)\n          && (stl->neighbors_start[edge_a->facet_number].\n              neighbor[(v2a + 2) % 3] == -1)) {\n      \/* This vertex has no neighbors.  This is a good one to change *\/\n      *facet2 = edge_a->facet_number;\n      *vertex2 = v2a;\n      *new_vertex2 = stl->facet_start[edge_b->facet_number].vertex[v2b];\n    } else {\n      *facet2 = edge_b->facet_number;\n      *vertex2 = v2b;\n      *new_vertex2 = stl->facet_start[edge_a->facet_number].vertex[v2a];\n    }\n  }\n}","target":0,"code_token_length":817,"total_token_length":1053,"max_tokens_setting":2048}
+{"idx":246647,"func":"static void naludmx_enqueue_or_dispatch(GF_NALUDmxCtx *ctx, GF_FilterPacket *n_pck, Bool flush_ref)\n{\n\t\/\/TODO: we are dispatching frames in \"negctts mode\", ie we may have DTS>CTS\n\t\/\/need to signal this for consumers using DTS (eg MPEG-2 TS)\n\tif (flush_ref && ctx->pck_queue && ctx->poc_diff) {\n\t\tu32 dts_inc=0;\n\t\ts32 last_poc = 0;\n\t\tBool patch_missing_frame = GF_FALSE;\n\t\t\/\/send all reference packet queued\n\t\tif (ctx->strict_poc==STRICT_POC_ERROR) {\n\t\t\tu32 i;\n\t\t\tu32 nb_bframes = 0;\n\t\t\tfor (i=0; i<gf_list_count(ctx->pck_queue); i++) {\n\t\t\t\ts32 poc;\n\t\t\t\tu64 poc_ts, dts;\n\t\t\t\tGF_FilterPacket *q_pck = gf_list_get(ctx->pck_queue, i);\n\n\t\t\t\tif (q_pck == ctx->first_pck_in_au) break;\n\n\t\t\t\tdts = gf_filter_pck_get_dts(q_pck);\n\t\t\t\tif (dts == GF_FILTER_NO_TS) continue;\n\t\t\t\tpoc_ts = gf_filter_pck_get_cts(q_pck);\n\t\t\t\tassert(poc_ts != GF_FILTER_NO_TS);\n\t\t\t\tpoc = (s32) ((s64) poc_ts - CTS_POC_OFFSET_SAFETY);\n\n\t\t\t\tif (i) {\n\t\t\t\t\tif (last_poc>poc) nb_bframes ++;\n\t\t\t\t\telse if (last_poc + ctx->poc_diff<poc)\n\t\t\t\t\t\tpatch_missing_frame = GF_TRUE;\n\t\t\t\t}\n\t\t\t\tlast_poc = poc;\n\t\t\t}\n\t\t\tif (nb_bframes>1)\n\t\t\t\tpatch_missing_frame = GF_FALSE;\n\t\t\telse if (nb_bframes)\n\t\t\t\tpatch_missing_frame = GF_TRUE;\n\t\t}\n\t\tlast_poc = GF_INT_MIN;\n\n\t\twhile (gf_list_count(ctx->pck_queue) ) {\n\t\t\tu64 dts;\n\t\t\tGF_FilterPacket *q_pck = gf_list_get(ctx->pck_queue, 0);\n\n\t\t\tif (q_pck == ctx->first_pck_in_au) break;\n\n\t\t\tdts = gf_filter_pck_get_dts(q_pck);\n\t\t\tif (dts != GF_FILTER_NO_TS) {\n\t\t\t\ts32 poc;\n\t\t\t\tu64 poc_ts, cts;\n\t\t\t\tu8 carousel_info = gf_filter_pck_get_carousel_version(q_pck);\n\n\t\t\t\t\/\/we reused timing from source packets\n\t\t\t\tif (!carousel_info) {\n\t\t\t\t\tassert(ctx->timescale);\n\t\t\t\t\tgf_list_rem(ctx->pck_queue, 0);\n\t\t\t\t\tgf_filter_pck_send(q_pck);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tgf_filter_pck_set_carousel_version(q_pck, 0);\n\n\n\t\t\t\tpoc_ts = gf_filter_pck_get_cts(q_pck);\n\t\t\t\tassert(poc_ts != GF_FILTER_NO_TS);\n\t\t\t\tpoc = (s32) ((s64) poc_ts - CTS_POC_OFFSET_SAFETY);\n\n\t\t\t\tif (patch_missing_frame) {\n\t\t\t\t\tif (last_poc!=GF_INT_MIN) {\n\t\t\t\t\t\t\/\/check if we missed an IDR (poc reset)\n\t\t\t\t\t\tif (poc && (last_poc > poc) ) {\n\t\t\t\t\t\t\tlast_poc = 0;\n\t\t\t\t\t\t\tdts_inc += ctx->cur_fps.den;\n\t\t\t\t\t\t\tctx->dts_last_IDR = dts;\n\t\t\t\t\t\t\tctx->dts += ctx->cur_fps.den;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/\/check if we miss a frame\n\t\t\t\t\t\twhile (last_poc + ctx->poc_diff < poc) {\n\t\t\t\t\t\t\tlast_poc += ctx->poc_diff;\n\t\t\t\t\t\t\tdts_inc += ctx->cur_fps.den;\n\t\t\t\t\t\t\tctx->dts += ctx->cur_fps.den;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlast_poc = poc;\n\t\t\t\t\tdts += dts_inc;\n\t\t\t\t}\n\t\t\t\t\/\/poc is stored as diff since last IDR which has min_poc\n\t\t\t\tcts = ( (ctx->min_poc + (s32) poc) * ctx->cur_fps.den ) \/ ctx->poc_diff + ctx->dts_last_IDR;\n\n\t\t\t\t\/*if PAFF, 2 pictures (eg poc) <=> 1 aggregated frame (eg sample), divide by 2*\/\n\t\t\t\tif (ctx->is_paff) {\n\t\t\t\t\tcts \/= 2;\n\t\t\t\t\t\/*in some cases the poc is not on the top field - if that is the case, round up*\/\n\t\t\t\t\tif (cts % ctx->cur_fps.den) {\n\t\t\t\t\t\tcts = ((cts\/ctx->cur_fps.den)+1) * ctx->cur_fps.den;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgf_filter_pck_set_cts(q_pck, cts);\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"[%s] Frame timestamps computed dts \"LLU\" cts \"LLU\" (poc %d min poc %d poc_diff %d last IDR DTS \"LLU\")\\n\", ctx->log_name, dts, cts, poc, ctx->min_poc, ctx->poc_diff, ctx->dts_last_IDR));\n\n\t\t\t\tif (ctx->importer && ctx->cur_fps.den) {\n\t\t\t\t\tpoc = (s32) ( (s64) cts - (s64) dts);\n\t\t\t\t\tif (poc<0) poc = -poc;\n\t\t\t\t\tpoc \/= ctx->cur_fps.den;\n\t\t\t\t\tif (poc > ctx->max_total_delay)\n\t\t\t\t\t\tctx->max_total_delay = poc;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_list_rem(ctx->pck_queue, 0);\n\t\t\tgf_filter_pck_send(q_pck);\n\t\t}\n\t}\n\tif (!n_pck) return;\n\n\tif (!ctx->pck_queue) ctx->pck_queue = gf_list_new();\n\tgf_list_add(ctx->pck_queue, n_pck);\n}","target":0,"code_token_length":1286,"total_token_length":1522,"max_tokens_setting":2048}
+{"idx":313732,"func":"nv_scroll(cmdarg_T *cap)\n{\n    int\t\tused = 0;\n    long\tn;\n#ifdef FEAT_FOLDING\n    linenr_T\tlnum;\n#endif\n    int\t\thalf;\n\n    cap->oap->motion_type = MLINE;\n    setpcmark();\n\n    if (cap->cmdchar == 'L')\n    {\n\tvalidate_botline();\t    \/\/ make sure curwin->w_botline is valid\n\tcurwin->w_cursor.lnum = curwin->w_botline - 1;\n\tif (cap->count1 - 1 >= curwin->w_cursor.lnum)\n\t    curwin->w_cursor.lnum = 1;\n\telse\n\t{\n#ifdef FEAT_FOLDING\n\t    if (hasAnyFolding(curwin))\n\t    {\n\t\t\/\/ Count a fold for one screen line.\n\t\tfor (n = cap->count1 - 1; n > 0\n\t\t\t    && curwin->w_cursor.lnum > curwin->w_topline; --n)\n\t\t{\n\t\t    (void)hasFolding(curwin->w_cursor.lnum,\n\t\t\t\t\t\t&curwin->w_cursor.lnum, NULL);\n\t\t    --curwin->w_cursor.lnum;\n\t\t}\n\t    }\n\t    else\n#endif\n\t\tcurwin->w_cursor.lnum -= cap->count1 - 1;\n\t}\n    }\n    else\n    {\n\tif (cap->cmdchar == 'M')\n\t{\n#ifdef FEAT_DIFF\n\t    \/\/ Don't count filler lines above the window.\n\t    used -= diff_check_fill(curwin, curwin->w_topline)\n\t\t\t\t\t\t\t  - curwin->w_topfill;\n#endif\n\t    validate_botline();\t    \/\/ make sure w_empty_rows is valid\n\t    half = (curwin->w_height - curwin->w_empty_rows + 1) \/ 2;\n\t    for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n)\n\t    {\n#ifdef FEAT_DIFF\n\t\t\/\/ Count half he number of filler lines to be \"below this\n\t\t\/\/ line\" and half to be \"above the next line\".\n\t\tif (n > 0 && used + diff_check_fill(curwin, curwin->w_topline\n\t\t\t\t\t\t\t     + n) \/ 2 >= half)\n\t\t{\n\t\t    --n;\n\t\t    break;\n\t\t}\n#endif\n\t\tused += plines(curwin->w_topline + n);\n\t\tif (used >= half)\n\t\t    break;\n#ifdef FEAT_FOLDING\n\t\tif (hasFolding(curwin->w_topline + n, NULL, &lnum))\n\t\t    n = lnum - curwin->w_topline;\n#endif\n\t    }\n\t    if (n > 0 && used > curwin->w_height)\n\t\t--n;\n\t}\n\telse \/\/ (cap->cmdchar == 'H')\n\t{\n\t    n = cap->count1 - 1;\n#ifdef FEAT_FOLDING\n\t    if (hasAnyFolding(curwin))\n\t    {\n\t\t\/\/ Count a fold for one screen line.\n\t\tlnum = curwin->w_topline;\n\t\twhile (n-- > 0 && lnum < curwin->w_botline - 1)\n\t\t{\n\t\t    (void)hasFolding(lnum, NULL, &lnum);\n\t\t    ++lnum;\n\t\t}\n\t\tn = lnum - curwin->w_topline;\n\t    }\n#endif\n\t}\n\tcurwin->w_cursor.lnum = curwin->w_topline + n;\n\tif (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t    curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n    }\n\n    \/\/ Correct for 'so', except when an operator is pending.\n    if (cap->oap->op_type == OP_NOP)\n\tcursor_correct();\n    beginline(BL_SOL | BL_FIX);\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048}
+{"idx":230146,"func":"static int validate_safetynet_ca_root(json_t * j_params, gnutls_x509_crt_t cert_leaf, json_t * j_header_x5c) {\n  gnutls_x509_crt_t cert_x509[(json_array_size(j_header_x5c)+1)], root_x509 = NULL;\n  gnutls_x509_trust_list_t tlist = NULL;\n  int ret = G_OK;\n  unsigned int result, i;\n  json_t * j_cert;\n  unsigned char * header_cert_decoded;\n  size_t header_cert_decoded_len;\n  gnutls_datum_t cert_dat;\n\n  cert_x509[0] = cert_leaf;\n  for (i=1; i<json_array_size(j_header_x5c); i++) {\n    j_cert = json_array_get(j_header_x5c, i);\n\n    if ((header_cert_decoded = o_malloc(json_string_length(j_cert))) != NULL) {\n      if (o_base64_decode((const unsigned char *)json_string_value(j_cert), json_string_length(j_cert), header_cert_decoded, &header_cert_decoded_len)) {\n        if (!gnutls_x509_crt_init(&cert_x509[i])) {\n          cert_dat.data = header_cert_decoded;\n          cert_dat.size = header_cert_decoded_len;\n          if ((ret = gnutls_x509_crt_import(cert_x509[i], &cert_dat, GNUTLS_X509_FMT_DER)) < 0) {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error gnutls_x509_crt_import: %d\", ret);\n            ret = G_ERROR;\n          }\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error gnutls_x509_crt_init\");\n          ret = G_ERROR;\n        }\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error o_base64_decode x5c leaf\");\n        ret = G_ERROR;\n      }\n      o_free(header_cert_decoded);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error allocating resources for header_cert_decoded\");\n      ret = G_ERROR_MEMORY;\n    }\n  }\n\n  if (ret == G_OK) {\n    cert_dat.data = (unsigned char *)json_string_value(json_object_get(json_object_get(j_params, \"google-root-ca-r2-content\"), \"x509\"));\n    cert_dat.size = json_string_length(json_object_get(json_object_get(j_params, \"google-root-ca-r2-content\"), \"x509\"));\n    if (!gnutls_x509_crt_init(&cert_x509[json_array_size(j_header_x5c)]) &&\n        !gnutls_x509_crt_import(cert_x509[json_array_size(j_header_x5c)], &cert_dat, GNUTLS_X509_FMT_PEM)) {\n      if (!gnutls_x509_crt_init(&root_x509) &&\n          !gnutls_x509_crt_import(root_x509, &cert_dat, GNUTLS_X509_FMT_PEM)) {\n        if (!gnutls_x509_trust_list_init(&tlist, 0)) {\n          if (gnutls_x509_trust_list_add_cas(tlist, &root_x509, 1, 0) >= 0) {\n            if (gnutls_x509_trust_list_verify_crt(tlist, cert_x509, (json_array_size(j_header_x5c)+1), 0, &result, NULL) >= 0) {\n              if (!result) {\n                ret = G_OK;\n              } else {\n                y_log_message(Y_LOG_LEVEL_DEBUG, \"validate_safetynet_ca_root - certificate chain invalid\");\n                ret = G_ERROR;\n              }\n            } else {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error gnutls_x509_trust_list_verify_crt\");\n              ret = G_ERROR;\n            }\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error gnutls_x509_trust_list_add_cas\");\n            ret = G_ERROR;\n          }\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error gnutls_x509_trust_list_init\");\n          ret = G_ERROR;\n        }\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error import root cert\");\n        ret = G_ERROR;\n      }\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"validate_safetynet_ca_root - Error import last cert\");\n      ret = G_ERROR;\n    }\n  }\n  \/\/ Clean after me\n  for (i=1; i<json_array_size(j_header_x5c); i++) {\n    gnutls_x509_crt_deinit(cert_x509[i]);\n  }\n  gnutls_x509_crt_deinit(cert_x509[json_array_size(j_header_x5c)]);\n  gnutls_x509_trust_list_deinit(tlist, 1);\n  return ret;\n}","target":0,"code_token_length":1166,"total_token_length":1402,"max_tokens_setting":2048}
+{"idx":310074,"func":"check_cursor(TERMTYPE2 *tp)\n{\n    int count;\n    char *list[4];\n\n    if (hard_copy) {\n\tcheck_noaddress(tp, \"hard_copy\");\n    } else if (generic_type) {\n\tcheck_noaddress(tp, \"generic_type\");\n    } else if (strchr(tp->term_names, '+') == 0) {\n\tint y = 0;\n\tint x = 0;\n\tif (PRESENT(column_address))\n\t    ++y;\n\tif (PRESENT(cursor_address))\n\t    y = x = 10;\n\tif (PRESENT(cursor_home))\n\t    ++y, ++x;\n\tif (PRESENT(cursor_mem_address))\n\t    y = x = 10;\n\tif (PRESENT(cursor_to_ll))\n\t    ++y, ++x;\n\tif (PRESENT(row_address))\n\t    ++x;\n\tif (PRESENT(cursor_down))\n\t    ++y;\n\tif (PRESENT(cursor_up))\n\t    ++y;\n\tif (PRESENT(cursor_left))\n\t    ++x;\n\tif (PRESENT(cursor_right))\n\t    ++x;\n\tif (x < 2 && y < 2) {\n\t    _nc_warning(\"terminal lacks cursor addressing\");\n\t} else {\n\t    if (x < 2)\n\t\t_nc_warning(\"terminal lacks cursor column-addressing\");\n\t    if (y < 2)\n\t\t_nc_warning(\"terminal lacks cursor row-addressing\");\n\t}\n    }\n\n    \/* it is rare to have an insert-line feature without a matching delete *\/\n    ANDMISSING(parm_insert_line, insert_line);\n    ANDMISSING(parm_delete_line, delete_line);\n    ANDMISSING(parm_insert_line, parm_delete_line);\n\n    \/* if we have a parameterized form, then the non-parameterized is easy *\/\n    ANDMISSING(parm_down_cursor, cursor_down);\n    ANDMISSING(parm_up_cursor, cursor_up);\n    ANDMISSING(parm_left_cursor, cursor_left);\n    ANDMISSING(parm_right_cursor, cursor_right);\n\n    \/* Given any of a set of cursor movement, the whole set should be present.\n     * Technically this is not true (we could use cursor_address to fill in\n     * unsupported controls), but it is likely.\n     *\/\n    count = 0;\n    if (PRESENT(parm_down_cursor)) {\n\tlist[count++] = parm_down_cursor;\n    }\n    if (PRESENT(parm_up_cursor)) {\n\tlist[count++] = parm_up_cursor;\n    }\n    if (PRESENT(parm_left_cursor)) {\n\tlist[count++] = parm_left_cursor;\n    }\n    if (PRESENT(parm_right_cursor)) {\n\tlist[count++] = parm_right_cursor;\n    }\n    if (count == 4) {\n\tcheck_ansi_cursor(list);\n    } else if (count != 0) {\n\tEXPECTED(parm_down_cursor);\n\tEXPECTED(parm_up_cursor);\n\tEXPECTED(parm_left_cursor);\n\tEXPECTED(parm_right_cursor);\n    }\n\n    count = 0;\n    if (PRESENT(cursor_down)) {\n\tlist[count++] = cursor_down;\n    }\n    if (PRESENT(cursor_up)) {\n\tlist[count++] = cursor_up;\n    }\n    if (PRESENT(cursor_left)) {\n\tlist[count++] = cursor_left;\n    }\n    if (PRESENT(cursor_right)) {\n\tlist[count++] = cursor_right;\n    }\n    if (count == 4) {\n\tcheck_ansi_cursor(list);\n    } else if (count != 0) {\n\tcount = 0;\n\tif (PRESENT(cursor_down) && strcmp(cursor_down, \"\\n\"))\n\t    ++count;\n\tif (PRESENT(cursor_left) && strcmp(cursor_left, \"\\b\"))\n\t    ++count;\n\tif (PRESENT(cursor_up) && strlen(cursor_up) > 1)\n\t    ++count;\n\tif (PRESENT(cursor_right) && strlen(cursor_right) > 1)\n\t    ++count;\n\tif (count) {\n\t    EXPECTED(cursor_down);\n\t    EXPECTED(cursor_up);\n\t    EXPECTED(cursor_left);\n\t    EXPECTED(cursor_right);\n\t}\n    }\n}","target":0,"code_token_length":798,"total_token_length":1034,"max_tokens_setting":2048}
+{"idx":279910,"func":"make_filter_cmd(\n    char_u\t*cmd,\t\t\/\/ command\n    char_u\t*itmp,\t\t\/\/ NULL or name of input file\n    char_u\t*otmp)\t\t\/\/ NULL or name of output file\n{\n    char_u\t*buf;\n    long_u\tlen;\n\n#if defined(UNIX)\n    int\t\tis_fish_shell;\n    char_u\t*shell_name = get_isolated_shell_name();\n\n    if (shell_name == NULL)\n\treturn NULL;\n\n    \/\/ Account for fish's different syntax for subshells\n    is_fish_shell = (fnamecmp(shell_name, \"fish\") == 0);\n    vim_free(shell_name);\n    if (is_fish_shell)\n\tlen = (long_u)STRLEN(cmd) + 13;\t\t\/\/ \"begin; \" + \"; end\" + NUL\n    else\n#endif\n\tlen = (long_u)STRLEN(cmd) + 3;\t\t\t\/\/ \"()\" + NUL\n    if (itmp != NULL)\n\tlen += (long_u)STRLEN(itmp) + 9;\t\t\/\/ \" { < \" + \" } \"\n    if (otmp != NULL)\n\tlen += (long_u)STRLEN(otmp) + (long_u)STRLEN(p_srr) + 2; \/\/ \"  \"\n    buf = alloc(len);\n    if (buf == NULL)\n\treturn NULL;\n\n#if defined(UNIX)\n    \/*\n     * Put braces around the command (for concatenated commands) when\n     * redirecting input and\/or output.\n     *\/\n    if (itmp != NULL || otmp != NULL)\n    {\n\tif (is_fish_shell)\n\t    vim_snprintf((char *)buf, len, \"begin; %s; end\", (char *)cmd);\n\telse\n\t    vim_snprintf((char *)buf, len, \"(%s)\", (char *)cmd);\n    }\n    else\n\tSTRCPY(buf, cmd);\n    if (itmp != NULL)\n    {\n\tSTRCAT(buf, \" < \");\n\tSTRCAT(buf, itmp);\n    }\n#else\n    \/\/ For shells that don't understand braces around commands, at least allow\n    \/\/ the use of commands in a pipe.\n    if (*p_sxe != NUL && *p_sxq == '(')\n    {\n\tif (itmp != NULL || otmp != NULL)\n\t    vim_snprintf((char *)buf, len, \"(%s)\", (char *)cmd);\n\telse\n\t    STRCPY(buf, cmd);\n\tif (itmp != NULL)\n\t{\n\t    STRCAT(buf, \" < \");\n\t    STRCAT(buf, itmp);\n\t}\n    }\n    else\n    {\n\tSTRCPY(buf, cmd);\n\tif (itmp != NULL)\n\t{\n\t    char_u\t*p;\n\n\t    \/\/ If there is a pipe, we have to put the '<' in front of it.\n\t    \/\/ Don't do this when 'shellquote' is not empty, otherwise the\n\t    \/\/ redirection would be inside the quotes.\n\t    if (*p_shq == NUL)\n\t    {\n\t\tp = find_pipe(buf);\n\t\tif (p != NULL)\n\t\t    *p = NUL;\n\t    }\n\t    STRCAT(buf, \" <\");\t\/\/ \" < \" causes problems on Amiga\n\t    STRCAT(buf, itmp);\n\t    if (*p_shq == NUL)\n\t    {\n\t\tp = find_pipe(cmd);\n\t\tif (p != NULL)\n\t\t{\n\t\t    STRCAT(buf, \" \");  \/\/ insert a space before the '|' for DOS\n\t\t    STRCAT(buf, p);\n\t\t}\n\t    }\n\t}\n    }\n#endif\n    if (otmp != NULL)\n\tappend_redir(buf, (int)len, p_srr, otmp);\n\n    return buf;\n}","target":0,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048}
+{"idx":248291,"func":"DLLIMPORT cfg_value_t *cfg_setopt(cfg_t *cfg, cfg_opt_t *opt, const char *value)\n{\n\tcfg_value_t *val = NULL;\n\tconst char *s;\n\tchar *endptr;\n\tlong int i;\n\tdouble f;\n\tvoid *p;\n\tint b;\n\n\tif (!cfg || !opt) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tif (opt->simple_value.ptr) {\n\t\tif (opt->type == CFGT_SEC) {\n\t\t\terrno = EINVAL;\n\t\t\treturn NULL;\n\t\t}\n\t\tval = (cfg_value_t *)opt->simple_value.ptr;\n\t} else {\n\t\tif (is_set(CFGF_RESET, opt->flags)) {\n\t\t\tcfg_free_value(opt);\n\t\t\topt->flags &= ~CFGF_RESET;\n\t\t}\n\n\t\tif (opt->nvalues == 0 || is_set(CFGF_MULTI, opt->flags) || is_set(CFGF_LIST, opt->flags)) {\n\t\t\tval = NULL;\n\n\t\t\tif (opt->type == CFGT_SEC && is_set(CFGF_TITLE, opt->flags)) {\n\t\t\t\tunsigned int i;\n\n\t\t\t\t\/* XXX: Check if there already is a section with the same title. *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Check there are either no sections at\n\t\t\t\t * all, or a non-NULL section title.\n\t\t\t\t *\/\n\t\t\t\tif (opt->nvalues != 0 && !value) {\n\t\t\t\t\terrno = EINVAL;\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\n\t\t\t\tfor (i = 0; i < opt->nvalues && val == NULL; i++) {\n\t\t\t\t\tcfg_t *sec = opt->values[i]->section;\n\n\t\t\t\t\tif (is_set(CFGF_NOCASE, cfg->flags)) {\n\t\t\t\t\t\tif (strcasecmp(value, sec->title) == 0)\n\t\t\t\t\t\t\tval = opt->values[i];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (strcmp(value, sec->title) == 0)\n\t\t\t\t\t\t\tval = opt->values[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (val && is_set(CFGF_NO_TITLE_DUPES, opt->flags)) {\n\t\t\t\t\tcfg_error(cfg, _(\"found duplicate title '%s'\"), value);\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!val) {\n\t\t\t\tval = cfg_addval(opt);\n\t\t\t\tif (!val)\n\t\t\t\t\treturn NULL;\n\t\t\t}\n\t\t} else {\n\t\t\tval = opt->values[0];\n\t\t}\n\t}\n\n\tswitch (opt->type) {\n\tcase CFGT_INT:\n\t\tif (opt->parsecb) {\n\t\t\tif ((*opt->parsecb) (cfg, opt, value, &i) != 0)\n\t\t\t\treturn NULL;\n\t\t} else {\n\t\t\tconst char *str;\n\t\t\tint radix = 0;\n\n\t\t\tif (!value) {\n\t\t\t\terrno = EINVAL;\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tstr = value;\n\t\t\tif (value[0] == '0') {\n\t\t\t\tswitch (value[1]) {\n\t\t\t\tcase 'b':\n\t\t\t\t\tradix = 2;\n\t\t\t\t\tstr = &value[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'x':\n\t\t\t\t\tradix = 16;\n\t\t\t\t\tstr = &value[2];\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tradix = 8;\n\t\t\t\t\tstr = &value[1];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ti = strtol(str, &endptr, radix);\n\t\t\tif (*endptr != '\\0') {\n\t\t\t\tcfg_error(cfg, _(\"invalid integer value for option '%s'\"), opt->name);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tif (errno == ERANGE) {\n\t\t\t\tcfg_error(cfg, _(\"integer value for option '%s' is out of range\"), opt->name);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tval->number = i;\n\t\tbreak;\n\n\tcase CFGT_FLOAT:\n\t\tif (opt->parsecb) {\n\t\t\tif ((*opt->parsecb) (cfg, opt, value, &f) != 0)\n\t\t\t\treturn NULL;\n\t\t} else {\n\t\t\tif (!value) {\n\t\t\t\terrno = EINVAL;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tf = strtod(value, &endptr);\n\t\t\tif (*endptr != '\\0') {\n\t\t\t\tcfg_error(cfg, _(\"invalid floating point value for option '%s'\"), opt->name);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (errno == ERANGE) {\n\t\t\t\tcfg_error(cfg, _(\"floating point value for option '%s' is out of range\"), opt->name);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tval->fpnumber = f;\n\t\tbreak;\n\n\tcase CFGT_STR:\n\t\tif (opt->parsecb) {\n\t\t\ts = NULL;\n\t\t\tif ((*opt->parsecb) (cfg, opt, value, &s) != 0)\n\t\t\t\treturn NULL;\n\t\t} else {\n\t\t\ts = value;\n\t\t}\n\n\t\tif (!s) {\n\t\t\terrno = EINVAL;\n\t\t\treturn NULL;\n\t\t}\n\n\t\tfree(val->string);\n\t\tval->string = strdup(s);\n\t\tif (!val->string)\n\t\t\treturn NULL;\n\t\tbreak;\n\n\tcase CFGT_SEC:\n\t\tif (is_set(CFGF_MULTI, opt->flags) || val->section == NULL) {\n\t\t\tif (val->section) {\n\t\t\t\tval->section->path = NULL; \/* Global search path *\/\n\t\t\t\tcfg_free(val->section);\n\t\t\t}\n\t\t\tval->section = calloc(1, sizeof(cfg_t));\n\t\t\tif (!val->section)\n\t\t\t\treturn NULL;\n\n\t\t\tval->section->name = strdup(opt->name);\n\t\t\tif (!val->section->name) {\n\t\t\t\tfree(val->section);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tval->section->flags = cfg->flags;\n\t\t\tif (is_set(CFGF_KEYSTRVAL, opt->flags))\n\t\t\t\tval->section->flags |= CFGF_KEYSTRVAL;\n\n\t\t\tval->section->filename = cfg->filename ? strdup(cfg->filename) : NULL;\n\t\t\tif (cfg->filename && !val->section->filename) {\n\t\t\t\tfree(val->section->name);\n\t\t\t\tfree(val->section);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tval->section->line = cfg->line;\n\t\t\tval->section->errfunc = cfg->errfunc;\n\t\t\tval->section->title = value ? strdup(value) : NULL;\n\t\t\tif (value && !val->section->title) {\n\t\t\t\tfree(val->section->filename);\n\t\t\t\tfree(val->section->name);\n\t\t\t\tfree(val->section);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tval->section->opts = cfg_dupopt_array(opt->subopts);\n\t\t\tif (!val->section->opts) {\n\t\t\t\tif (val->section->title)\n\t\t\t\t\tfree(val->section->title);\n\t\t\t\tif (val->section->filename)\n\t\t\t\t\tfree(val->section->filename);\n\t\t\t\tfree(val->section->name);\n\t\t\t\tfree(val->section);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tif (!is_set(CFGF_DEFINIT, opt->flags))\n\t\t\tcfg_init_defaults(val->section);\n\t\tbreak;\n\n\tcase CFGT_BOOL:\n\t\tif (opt->parsecb) {\n\t\t\tif ((*opt->parsecb) (cfg, opt, value, &b) != 0)\n\t\t\t\treturn NULL;\n\t\t} else {\n\t\t\tb = cfg_parse_boolean(value);\n\t\t\tif (b == -1) {\n\t\t\t\tcfg_error(cfg, _(\"invalid boolean value for option '%s'\"), opt->name);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tval->boolean = (cfg_bool_t)b;\n\t\tbreak;\n\n\tcase CFGT_PTR:\n\t\tif (!opt->parsecb) {\n\t\t\terrno = EINVAL;\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif ((*opt->parsecb) (cfg, opt, value, &p) != 0)\n\t\t\treturn NULL;\n\t\tif (val->ptr && opt->freecb)\n\t\t\topt->freecb(val->ptr);\n\t\tval->ptr = p;\n\t\tbreak;\n\n\tdefault:\n\t\tcfg_error(cfg, \"internal error in cfg_setopt(%s, %s)\", opt->name, (value) ? (value) : \"NULL\");\n\t\treturn NULL;\n\t}\n\n\topt->flags |= CFGF_MODIFIED;\n\n\treturn val;\n}","target":0,"code_token_length":1711,"total_token_length":1947,"max_tokens_setting":2048}
+{"idx":279914,"func":"ex_append(exarg_T *eap)\n{\n    char_u\t*theline;\n    int\t\tdid_undo = FALSE;\n    linenr_T\tlnum = eap->line2;\n    int\t\tindent = 0;\n    char_u\t*p;\n    int\t\tvcol;\n    int\t\tempty = (curbuf->b_ml.ml_flags & ML_EMPTY);\n\n#ifdef FEAT_EVAL\n    if (not_in_vim9(eap) == FAIL)\n\treturn;\n#endif\n    \/\/ the ! flag toggles autoindent\n    if (eap->forceit)\n\tcurbuf->b_p_ai = !curbuf->b_p_ai;\n\n    \/\/ First autoindent comes from the line we start on\n    if (eap->cmdidx != CMD_change && curbuf->b_p_ai && lnum > 0)\n\tappend_indent = get_indent_lnum(lnum);\n\n    if (eap->cmdidx != CMD_append)\n\t--lnum;\n\n    \/\/ when the buffer is empty need to delete the dummy line\n    if (empty && lnum == 1)\n\tlnum = 0;\n\n    State = INSERT;\t\t    \/\/ behave like in Insert mode\n    if (curbuf->b_p_iminsert == B_IMODE_LMAP)\n\tState |= LANGMAP;\n\n    for (;;)\n    {\n\tmsg_scroll = TRUE;\n\tneed_wait_return = FALSE;\n\tif (curbuf->b_p_ai)\n\t{\n\t    if (append_indent >= 0)\n\t    {\n\t\tindent = append_indent;\n\t\tappend_indent = -1;\n\t    }\n\t    else if (lnum > 0)\n\t\tindent = get_indent_lnum(lnum);\n\t}\n\tex_keep_indent = FALSE;\n\tif (eap->getline == NULL)\n\t{\n\t    \/\/ No getline() function, use the lines that follow. This ends\n\t    \/\/ when there is no more.\n\t    if (eap->nextcmd == NULL || *eap->nextcmd == NUL)\n\t\tbreak;\n\t    p = vim_strchr(eap->nextcmd, NL);\n\t    if (p == NULL)\n\t\tp = eap->nextcmd + STRLEN(eap->nextcmd);\n\t    theline = vim_strnsave(eap->nextcmd, p - eap->nextcmd);\n\t    if (*p != NUL)\n\t\t++p;\n\t    eap->nextcmd = p;\n\t}\n\telse\n\t{\n\t    int save_State = State;\n\n\t    \/\/ Set State to avoid the cursor shape to be set to INSERT mode\n\t    \/\/ when getline() returns.\n\t    State = CMDLINE;\n\t    theline = eap->getline(\n#ifdef FEAT_EVAL\n\t\t    eap->cstack->cs_looplevel > 0 ? -1 :\n#endif\n\t\t    NUL, eap->cookie, indent, TRUE);\n\t    State = save_State;\n\t}\n\tlines_left = Rows - 1;\n\tif (theline == NULL)\n\t    break;\n\n\t\/\/ Using ^ CTRL-D in getexmodeline() makes us repeat the indent.\n\tif (ex_keep_indent)\n\t    append_indent = indent;\n\n\t\/\/ Look for the \".\" after automatic indent.\n\tvcol = 0;\n\tfor (p = theline; indent > vcol; ++p)\n\t{\n\t    if (*p == ' ')\n\t\t++vcol;\n\t    else if (*p == TAB)\n\t\tvcol += 8 - vcol % 8;\n\t    else\n\t\tbreak;\n\t}\n\tif ((p[0] == '.' && p[1] == NUL)\n\t\t|| (!did_undo && u_save(lnum, lnum + 1 + (empty ? 1 : 0))\n\t\t\t\t\t\t\t\t     == FAIL))\n\t{\n\t    vim_free(theline);\n\t    break;\n\t}\n\n\t\/\/ don't use autoindent if nothing was typed.\n\tif (p[0] == NUL)\n\t    theline[0] = NUL;\n\n\tdid_undo = TRUE;\n\tml_append(lnum, theline, (colnr_T)0, FALSE);\n\tif (empty)\n\t    \/\/ there are no marks below the inserted lines\n\t    appended_lines(lnum, 1L);\n\telse\n\t    appended_lines_mark(lnum, 1L);\n\n\tvim_free(theline);\n\t++lnum;\n\n\tif (empty)\n\t{\n\t    ml_delete(2L);\n\t    empty = FALSE;\n\t}\n    }\n    State = NORMAL;\n\n    if (eap->forceit)\n\tcurbuf->b_p_ai = !curbuf->b_p_ai;\n\n    \/\/ \"start\" is set to eap->line2+1 unless that position is invalid (when\n    \/\/ eap->line2 pointed to the end of the buffer and nothing was appended)\n    \/\/ \"end\" is set to lnum when something has been appended, otherwise\n    \/\/ it is the same as \"start\"  -- Acevedo\n    if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)\n    {\n\tcurbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ?\n\t    eap->line2 + 1 : curbuf->b_ml.ml_line_count;\n\tif (eap->cmdidx != CMD_append)\n\t    --curbuf->b_op_start.lnum;\n\tcurbuf->b_op_end.lnum = (eap->line2 < lnum)\n\t\t\t\t\t      ? lnum : curbuf->b_op_start.lnum;\n\tcurbuf->b_op_start.col = curbuf->b_op_end.col = 0;\n    }\n    curwin->w_cursor.lnum = lnum;\n    check_cursor_lnum();\n    beginline(BL_SOL | BL_FIX);\n\n    need_wait_return = FALSE;\t\/\/ don't use wait_return() now\n    ex_no_reprint = TRUE;\n}","target":0,"code_token_length":1204,"total_token_length":1440,"max_tokens_setting":2048}
+{"idx":314477,"func":"static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,\n\t\t\t struct guest_walker *gw)\n{\n\tstruct kvm_mmu_page *sp = NULL;\n\tstruct kvm_shadow_walk_iterator it;\n\tunsigned int direct_access, access;\n\tint top_level, ret;\n\tgfn_t base_gfn = fault->gfn;\n\n\tWARN_ON_ONCE(gw->gfn != base_gfn);\n\tdirect_access = gw->pte_access;\n\n\ttop_level = vcpu->arch.mmu->root_level;\n\tif (top_level == PT32E_ROOT_LEVEL)\n\t\ttop_level = PT32_ROOT_LEVEL;\n\t\/*\n\t * Verify that the top-level gpte is still there.  Since the page\n\t * is a root page, it is either write protected (and cannot be\n\t * changed from now on) or it is invalid (in which case, we don't\n\t * really care if it changes underneath us after this point).\n\t *\/\n\tif (FNAME(gpte_changed)(vcpu, gw, top_level))\n\t\tgoto out_gpte_changed;\n\n\tif (WARN_ON(!VALID_PAGE(vcpu->arch.mmu->root.hpa)))\n\t\tgoto out_gpte_changed;\n\n\tfor (shadow_walk_init(&it, vcpu, fault->addr);\n\t     shadow_walk_okay(&it) && it.level > gw->level;\n\t     shadow_walk_next(&it)) {\n\t\tgfn_t table_gfn;\n\n\t\tclear_sp_write_flooding_count(it.sptep);\n\t\tdrop_large_spte(vcpu, it.sptep);\n\n\t\tsp = NULL;\n\t\tif (!is_shadow_present_pte(*it.sptep)) {\n\t\t\ttable_gfn = gw->table_gfn[it.level - 2];\n\t\t\taccess = gw->pt_access[it.level - 2];\n\t\t\tsp = kvm_mmu_get_page(vcpu, table_gfn, fault->addr,\n\t\t\t\t\t      it.level-1, false, access);\n\t\t\t\/*\n\t\t\t * We must synchronize the pagetable before linking it\n\t\t\t * because the guest doesn't need to flush tlb when\n\t\t\t * the gpte is changed from non-present to present.\n\t\t\t * Otherwise, the guest may use the wrong mapping.\n\t\t\t *\n\t\t\t * For PG_LEVEL_4K, kvm_mmu_get_page() has already\n\t\t\t * synchronized it transiently via kvm_sync_page().\n\t\t\t *\n\t\t\t * For higher level pagetable, we synchronize it via\n\t\t\t * the slower mmu_sync_children().  If it needs to\n\t\t\t * break, some progress has been made; return\n\t\t\t * RET_PF_RETRY and retry on the next #PF.\n\t\t\t * KVM_REQ_MMU_SYNC is not necessary but it\n\t\t\t * expedites the process.\n\t\t\t *\/\n\t\t\tif (sp->unsync_children &&\n\t\t\t    mmu_sync_children(vcpu, sp, false))\n\t\t\t\treturn RET_PF_RETRY;\n\t\t}\n\n\t\t\/*\n\t\t * Verify that the gpte in the page we've just write\n\t\t * protected is still there.\n\t\t *\/\n\t\tif (FNAME(gpte_changed)(vcpu, gw, it.level - 1))\n\t\t\tgoto out_gpte_changed;\n\n\t\tif (sp)\n\t\t\tlink_shadow_page(vcpu, it.sptep, sp);\n\t}\n\n\tkvm_mmu_hugepage_adjust(vcpu, fault);\n\n\ttrace_kvm_mmu_spte_requested(fault);\n\n\tfor (; shadow_walk_okay(&it); shadow_walk_next(&it)) {\n\t\tclear_sp_write_flooding_count(it.sptep);\n\n\t\t\/*\n\t\t * We cannot overwrite existing page tables with an NX\n\t\t * large page, as the leaf could be executable.\n\t\t *\/\n\t\tif (fault->nx_huge_page_workaround_enabled)\n\t\t\tdisallowed_hugepage_adjust(fault, *it.sptep, it.level);\n\n\t\tbase_gfn = fault->gfn & ~(KVM_PAGES_PER_HPAGE(it.level) - 1);\n\t\tif (it.level == fault->goal_level)\n\t\t\tbreak;\n\n\t\tvalidate_direct_spte(vcpu, it.sptep, direct_access);\n\n\t\tdrop_large_spte(vcpu, it.sptep);\n\n\t\tif (!is_shadow_present_pte(*it.sptep)) {\n\t\t\tsp = kvm_mmu_get_page(vcpu, base_gfn, fault->addr,\n\t\t\t\t\t      it.level - 1, true, direct_access);\n\t\t\tlink_shadow_page(vcpu, it.sptep, sp);\n\t\t\tif (fault->huge_page_disallowed &&\n\t\t\t    fault->req_level >= it.level)\n\t\t\t\taccount_huge_nx_page(vcpu->kvm, sp);\n\t\t}\n\t}\n\n\tif (WARN_ON_ONCE(it.level != fault->goal_level))\n\t\treturn -EFAULT;\n\n\tret = mmu_set_spte(vcpu, fault->slot, it.sptep, gw->pte_access,\n\t\t\t   base_gfn, fault->pfn, fault);\n\tif (ret == RET_PF_SPURIOUS)\n\t\treturn ret;\n\n\tFNAME(pte_prefetch)(vcpu, gw, it.sptep);\n\t++vcpu->stat.pf_fixed;\n\treturn ret;\n\nout_gpte_changed:\n\treturn RET_PF_RETRY;\n}","target":0,"code_token_length":1063,"total_token_length":1299,"max_tokens_setting":2048}
+{"idx":349525,"func":"static int virtbt_probe(struct virtio_device *vdev)\n{\n\tvq_callback_t *callbacks[VIRTBT_NUM_VQS] = {\n\t\t[VIRTBT_VQ_TX] = virtbt_tx_done,\n\t\t[VIRTBT_VQ_RX] = virtbt_rx_done,\n\t};\n\tconst char *names[VIRTBT_NUM_VQS] = {\n\t\t[VIRTBT_VQ_TX] = \"tx\",\n\t\t[VIRTBT_VQ_RX] = \"rx\",\n\t};\n\tstruct virtio_bluetooth *vbt;\n\tstruct hci_dev *hdev;\n\tint err;\n\t__u8 type;\n\n\tif (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1))\n\t\treturn -ENODEV;\n\n\ttype = virtio_cread8(vdev, offsetof(struct virtio_bt_config, type));\n\n\tswitch (type) {\n\tcase VIRTIO_BT_CONFIG_TYPE_PRIMARY:\n\tcase VIRTIO_BT_CONFIG_TYPE_AMP:\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tvbt = kzalloc(sizeof(*vbt), GFP_KERNEL);\n\tif (!vbt)\n\t\treturn -ENOMEM;\n\n\tvdev->priv = vbt;\n\tvbt->vdev = vdev;\n\n\tINIT_WORK(&vbt->rx, virtbt_rx_work);\n\n\terr = virtio_find_vqs(vdev, VIRTBT_NUM_VQS, vbt->vqs, callbacks,\n\t\t\t      names, NULL);\n\tif (err)\n\t\treturn err;\n\n\thdev = hci_alloc_dev();\n\tif (!hdev) {\n\t\terr = -ENOMEM;\n\t\tgoto failed;\n\t}\n\n\tvbt->hdev = hdev;\n\n\thdev->bus = HCI_VIRTIO;\n\thdev->dev_type = type;\n\thci_set_drvdata(hdev, vbt);\n\n\thdev->open  = virtbt_open;\n\thdev->close = virtbt_close;\n\thdev->flush = virtbt_flush;\n\thdev->send  = virtbt_send_frame;\n\n\tif (virtio_has_feature(vdev, VIRTIO_BT_F_VND_HCI)) {\n\t\t__u16 vendor;\n\n\t\tvirtio_cread(vdev, struct virtio_bt_config, vendor, &vendor);\n\n\t\tswitch (vendor) {\n\t\tcase VIRTIO_BT_CONFIG_VENDOR_ZEPHYR:\n\t\t\thdev->manufacturer = 1521;\n\t\t\thdev->setup = virtbt_setup_zephyr;\n\t\t\thdev->shutdown = virtbt_shutdown_generic;\n\t\t\thdev->set_bdaddr = virtbt_set_bdaddr_zephyr;\n\t\t\tbreak;\n\n\t\tcase VIRTIO_BT_CONFIG_VENDOR_INTEL:\n\t\t\thdev->manufacturer = 2;\n\t\t\thdev->setup = virtbt_setup_intel;\n\t\t\thdev->shutdown = virtbt_shutdown_generic;\n\t\t\thdev->set_bdaddr = virtbt_set_bdaddr_intel;\n\t\t\tset_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);\n\t\t\tset_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);\n\t\t\tset_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);\n\t\t\tbreak;\n\n\t\tcase VIRTIO_BT_CONFIG_VENDOR_REALTEK:\n\t\t\thdev->manufacturer = 93;\n\t\t\thdev->setup = virtbt_setup_realtek;\n\t\t\thdev->shutdown = virtbt_shutdown_generic;\n\t\t\tset_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);\n\t\t\tset_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (virtio_has_feature(vdev, VIRTIO_BT_F_MSFT_EXT)) {\n\t\t__u16 msft_opcode;\n\n\t\tvirtio_cread(vdev, struct virtio_bt_config,\n\t\t\t     msft_opcode, &msft_opcode);\n\n\t\thci_set_msft_opcode(hdev, msft_opcode);\n\t}\n\n\tif (virtio_has_feature(vdev, VIRTIO_BT_F_AOSP_EXT))\n\t\thci_set_aosp_capable(hdev);\n\n\tif (hci_register_dev(hdev) < 0) {\n\t\thci_free_dev(hdev);\n\t\terr = -EBUSY;\n\t\tgoto failed;\n\t}\n\n\treturn 0;\n\nfailed:\n\tvdev->config->del_vqs(vdev);\n\treturn err;\n}","target":0,"code_token_length":906,"total_token_length":1142,"max_tokens_setting":2048}
+{"idx":455351,"func":"bash_forward_shellword (count, key)\n     int count, key;\n{\n  size_t slen;\n  int c, p;\n  DECLARE_MBSTATE;\n\n  if (count < 0)\n    return (bash_backward_shellword (-count, key));\n\n  \/* The tricky part of this is deciding whether or not the first character\n     we're on is an unquoted metacharacter.  Not completely handled yet. *\/\n  \/* XXX - need to test this stuff with backslash-escaped shell\n     metacharacters and unclosed single- and double-quoted strings. *\/\n\n  p = rl_point;\n  slen = rl_end;\n\n  while (count)\n    {\n      if (p == rl_end)\n\t{\n\t  rl_point = rl_end;\n\t  return 0;\n\t}\n\n      \/* Are we in a quoted string?  If we are, move to the end of the quoted\n         string and continue the outer loop. We only want quoted strings, not\n         backslash-escaped characters, but char_is_quoted doesn't\n         differentiate. *\/\n      if (char_is_quoted (rl_line_buffer, p) && p > 0 && rl_line_buffer[p-1] != '\\\\')\n\t{\n\t  do\n\t    ADVANCE_CHAR (rl_line_buffer, slen, p);\n\t  while (p < rl_end && char_is_quoted (rl_line_buffer, p));\n\t  count--;\n\t  continue;\n\t}\n\n      \/* Rest of code assumes we are not in a quoted string. *\/\n      \/* Move forward until we hit a non-metacharacter. *\/\n      while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c))\n\t{\n\t  switch (c)\n\t    {\n\t    default:\n\t      ADVANCE_CHAR (rl_line_buffer, slen, p);\n\t      continue;\t\t\/* straight back to loop, don't increment p *\/\n\t    case '\\\\':\n\t      if (p < rl_end && rl_line_buffer[p])\n\t\tADVANCE_CHAR (rl_line_buffer, slen, p);\n\t      break;\n\t    case '\\'':\n\t      p = skip_to_delim (rl_line_buffer, ++p, \"'\", SD_NOJMP);\n\t      break;\n\t    case '\"':\n\t      p = skip_to_delim (rl_line_buffer, ++p, \"\\\"\", SD_NOJMP);\n\t      break;\n\t    }\n\n\t  if (p < rl_end)\n\t    p++;\n\t}\n\n      if (rl_line_buffer[p] == 0 || p == rl_end)\n        {\n\t  rl_point = rl_end;\n\t  rl_ding ();\n\t  return 0;\n        }\n\t\n      \/* Now move forward until we hit a non-quoted metacharacter or EOL *\/\n      while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c) == 0)\n\t{\n\t  switch (c)\n\t    {\n\t    default:\n\t      ADVANCE_CHAR (rl_line_buffer, slen, p);\n\t      continue;\t\t\/* straight back to loop, don't increment p *\/\n\t    case '\\\\':\n\t      if (p < rl_end && rl_line_buffer[p])\n\t\tADVANCE_CHAR (rl_line_buffer, slen, p);\n\t      break;\n\t    case '\\'':\n\t      p = skip_to_delim (rl_line_buffer, ++p, \"'\", SD_NOJMP);\n\t      break;\n\t    case '\"':\n\t      p = skip_to_delim (rl_line_buffer, ++p, \"\\\"\", SD_NOJMP);\n\t      break;\n\t    }\n\n\t  if (p < rl_end)\n\t    p++;\n\t}\n\n      if (p == rl_end || rl_line_buffer[p] == 0)\n\t{\n\t  rl_point = rl_end;\n\t  return (0);\n\t}\n\n      count--;      \n    }\n\n  rl_point = p;\n  return (0);\n}","target":0,"code_token_length":788,"total_token_length":1024,"max_tokens_setting":2048}
+{"idx":195074,"func":"GF_AV1Config *gf_odf_av1_cfg_read_bs_size(GF_BitStream *bs, u32 size)\n{\n#ifndef GPAC_DISABLE_AV_PARSERS\n\tAV1State state;\n\tu8 reserved;\n\tGF_AV1Config *cfg;\n\n\tif (!size) size = (u32) gf_bs_available(bs);\n\tif (!size) return NULL;\n\n\tcfg = gf_odf_av1_cfg_new();\n\tgf_av1_init_state(&state);\n\tstate.config = cfg;\n\n\tcfg->marker = gf_bs_read_int(bs, 1);\n\tcfg->version = gf_bs_read_int(bs, 7);\n\tcfg->seq_profile = gf_bs_read_int(bs, 3);\n\tcfg->seq_level_idx_0 = gf_bs_read_int(bs, 5);\n\tcfg->seq_tier_0 = gf_bs_read_int(bs, 1);\n\tcfg->high_bitdepth = gf_bs_read_int(bs, 1);\n\tcfg->twelve_bit = gf_bs_read_int(bs, 1);\n\tcfg->monochrome = gf_bs_read_int(bs, 1);\n\tcfg->chroma_subsampling_x = gf_bs_read_int(bs, 1);\n\tcfg->chroma_subsampling_y = gf_bs_read_int(bs, 1);\n\tcfg->chroma_sample_position = gf_bs_read_int(bs, 2);\n\n\treserved = gf_bs_read_int(bs, 3);\n\tif (reserved != 0 || cfg->marker != 1 || cfg->version != 1) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[AV1] wrong avcC reserved %d \/ marker %d \/ version %d expecting 0 1 1\\n\", reserved, cfg->marker, cfg->version));\n\t\tgf_odf_av1_cfg_del(cfg);\n\t\treturn NULL;\n\t}\n\tcfg->initial_presentation_delay_present = gf_bs_read_int(bs, 1);\n\tif (cfg->initial_presentation_delay_present) {\n\t\tcfg->initial_presentation_delay_minus_one = gf_bs_read_int(bs, 4);\n\t} else {\n\t\t\/*reserved = *\/gf_bs_read_int(bs, 4);\n\t\tcfg->initial_presentation_delay_minus_one = 0;\n\t}\n\tsize -= 4;\n\n\twhile (size) {\n\t\tu64 pos, obu_size;\n\t\tObuType obu_type;\n\t\tGF_AV1_OBUArrayEntry *a;\n\n\t\tpos = gf_bs_get_position(bs);\n\t\tobu_size = 0;\n\t\tif (gf_av1_parse_obu(bs, &obu_type, &obu_size, NULL, &state) != GF_OK) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[AV1] could not parse AV1 OBU at position \"LLU\". Leaving parsing.\\n\", pos));\n\t\t\tbreak;\n\t\t}\n\t\tassert(obu_size == gf_bs_get_position(bs) - pos);\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[AV1] parsed AV1 OBU type=%u size=\"LLU\" at position \"LLU\".\\n\", obu_type, obu_size, pos));\n\n\t\tif (!av1_is_obu_header(obu_type)) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[AV1] AV1 unexpected OBU type=%u size=\"LLU\" found at position \"LLU\". Forwarding.\\n\", pos));\n\t\t}\n\t\tGF_SAFEALLOC(a, GF_AV1_OBUArrayEntry);\n\t\tif (!a) break;\n\t\ta->obu = gf_malloc((size_t)obu_size);\n\t\tif (!a->obu) {\n\t\t\tgf_free(a);\n\t\t\tbreak;\n\t\t}\n\t\tgf_bs_seek(bs, pos);\n\t\tgf_bs_read_data(bs, (char *) a->obu, (u32)obu_size);\n\t\ta->obu_length = obu_size;\n\t\ta->obu_type = obu_type;\n\t\tgf_list_add(cfg->obu_array, a);\n\n\t\tif (size<obu_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[AV1] AV1 config misses %d bytes to fit the entire OBU\\n\", obu_size - size));\n\t\t\tbreak;\n\t\t}\n\t\tsize -= (u32) obu_size;\n\t}\n\tgf_av1_reset_state(& state, GF_TRUE);\n\treturn cfg;\n#else\n\treturn NULL;\n#endif\n}","target":1,"code_token_length":929,"total_token_length":1165,"max_tokens_setting":2048}
+{"idx":231785,"func":"void onServerReadDataFromClosed(\n    QuicServerConnectionState& conn,\n    ServerEvents::ReadData& readData) {\n  CHECK_EQ(conn.state, ServerState::Closed);\n  BufQueue udpData;\n  udpData.append(std::move(readData.networkData.data));\n  auto packetSize = udpData.empty() ? 0 : udpData.chainLength();\n  if (!conn.readCodec) {\n    \/\/ drop data. We closed before we even got the first packet. This is\n    \/\/ normally not possible but might as well.\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(\n          packetSize,\n          QuicTransportStatsCallback::toString(\n              PacketDropReason::SERVER_STATE_CLOSED));\n    }\n    QUIC_STATS(\n        conn.statsCallback,\n        onPacketDropped,\n        PacketDropReason::SERVER_STATE_CLOSED);\n    return;\n  }\n\n  if (conn.peerConnectionError) {\n    \/\/ We already got a peer error. We can ignore any futher peer errors.\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(\n          packetSize,\n          QuicTransportStatsCallback::toString(\n              PacketDropReason::SERVER_STATE_CLOSED));\n    }\n    QUIC_TRACE(packet_drop, conn, \"ignoring peer close\");\n    QUIC_STATS(\n        conn.statsCallback,\n        onPacketDropped,\n        PacketDropReason::SERVER_STATE_CLOSED);\n    return;\n  }\n  auto parsedPacket = conn.readCodec->parsePacket(udpData, conn.ackStates);\n  switch (parsedPacket.type()) {\n    case CodecResult::Type::CIPHER_UNAVAILABLE: {\n      VLOG(10) << \"drop cipher unavailable \" << conn;\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(packetSize, kCipherUnavailable);\n      }\n      QUIC_TRACE(packet_drop, conn, \"cipher_unavailable\");\n      break;\n    }\n    case CodecResult::Type::RETRY: {\n      VLOG(10) << \"drop because the server is not supposed to \"\n               << \"receive a retry \" << conn;\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(packetSize, kRetry);\n      }\n      QUIC_TRACE(packet_drop, conn, \"retry\");\n      break;\n    }\n    case CodecResult::Type::STATELESS_RESET: {\n      VLOG(10) << \"drop because reset \" << conn;\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(packetSize, kReset);\n      }\n      QUIC_TRACE(packet_drop, conn, \"reset\");\n      break;\n    }\n    case CodecResult::Type::NOTHING: {\n      VLOG(10) << \"drop cipher unavailable, no data \" << conn;\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(packetSize, kCipherUnavailable);\n      }\n      QUIC_TRACE(packet_drop, conn, \"cipher_unavailable\");\n      break;\n    }\n    case CodecResult::Type::REGULAR_PACKET:\n      break;\n  }\n  auto regularOptional = parsedPacket.regularPacket();\n  if (!regularOptional) {\n    \/\/ We were unable to parse the packet, drop for now.\n    VLOG(10) << \"Not able to parse QUIC packet \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(\n          packetSize,\n          QuicTransportStatsCallback::toString(PacketDropReason::PARSE_ERROR));\n    }\n    QUIC_STATS(\n        conn.statsCallback, onPacketDropped, PacketDropReason::PARSE_ERROR);\n    return;\n  }\n\n  auto& regularPacket = *regularOptional;\n  auto packetNum = regularPacket.header.getPacketSequenceNum();\n  auto pnSpace = regularPacket.header.getPacketNumberSpace();\n  if (conn.qLogger) {\n    conn.qLogger->addPacket(regularPacket, packetSize);\n  }\n\n  \/\/ Only process the close frames in the packet\n  for (auto& quicFrame : regularPacket.frames) {\n    switch (quicFrame.type()) {\n      case QuicFrame::Type::ConnectionCloseFrame: {\n        ConnectionCloseFrame& connFrame = *quicFrame.asConnectionCloseFrame();\n        auto errMsg = folly::to<std::string>(\n            \"Server closed by peer reason=\", connFrame.reasonPhrase);\n        VLOG(4) << errMsg << \" \" << conn;\n        if (conn.qLogger) {\n          conn.qLogger->addTransportStateUpdate(getPeerClose(errMsg));\n        }\n        \/\/ we want to deliver app callbacks with the peer supplied error,\n        \/\/ but send a NO_ERROR to the peer.\n        QUIC_TRACE(recvd_close, conn, errMsg.c_str());\n        conn.peerConnectionError = std::make_pair(\n            QuicErrorCode(connFrame.errorCode), std::move(errMsg));\n        break;\n      }\n      default:\n        break;\n    }\n  }\n\n  \/\/ We only need to set the largest received packet number in order to\n  \/\/ determine whether or not we need to send a new close.\n  auto& largestReceivedPacketNum =\n      getAckState(conn, pnSpace).largestReceivedPacketNum;\n  largestReceivedPacketNum = std::max<PacketNum>(\n      largestReceivedPacketNum.value_or(packetNum), packetNum);\n}","target":0,"code_token_length":1100,"total_token_length":1336,"max_tokens_setting":2048}
+{"idx":448562,"func":"static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,\n\t\t\t\t    bgp_size_t length)\n{\n\tuint8_t *end;\n\tstruct capability_mp_data mpc;\n\tstruct capability_header *hdr;\n\tuint8_t action;\n\tiana_afi_t pkt_afi;\n\tafi_t afi;\n\tiana_safi_t pkt_safi;\n\tsafi_t safi;\n\n\tend = pnt + length;\n\n\twhile (pnt < end) {\n\t\t\/* We need at least action, capability code and capability\n\t\t * length. *\/\n\t\tif (pnt + 3 > end) {\n\t\t\tzlog_info(\"%s Capability length error\", peer->host);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\t\taction = *pnt;\n\t\thdr = (struct capability_header *)(pnt + 1);\n\n\t\t\/* Action value check.  *\/\n\t\tif (action != CAPABILITY_ACTION_SET\n\t\t    && action != CAPABILITY_ACTION_UNSET) {\n\t\t\tzlog_info(\"%s Capability Action Value error %d\",\n\t\t\t\t  peer->host, action);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\n\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\tzlog_debug(\n\t\t\t\t\"%s CAPABILITY has action: %d, code: %u, length %u\",\n\t\t\t\tpeer->host, action, hdr->code, hdr->length);\n\n\t\tif (hdr->length < sizeof(struct capability_mp_data)) {\n\t\t\tzlog_info(\n\t\t\t\t\"%pBP Capability structure is not properly filled out, expected at least %zu bytes but header length specified is %d\",\n\t\t\t\tpeer, sizeof(struct capability_mp_data),\n\t\t\t\thdr->length);\n\t\t\treturn BGP_Stop;\n\t\t}\n\n\t\t\/* Capability length check. *\/\n\t\tif ((pnt + hdr->length + 3) > end) {\n\t\t\tzlog_info(\"%s Capability length error\", peer->host);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\n\t\t\/* Fetch structure to the byte stream. *\/\n\t\tmemcpy(&mpc, pnt + 3, sizeof(struct capability_mp_data));\n\t\tpnt += hdr->length + 3;\n\n\t\t\/* We know MP Capability Code. *\/\n\t\tif (hdr->code == CAPABILITY_CODE_MP) {\n\t\t\tpkt_afi = ntohs(mpc.afi);\n\t\t\tpkt_safi = mpc.safi;\n\n\t\t\t\/* Ignore capability when override-capability is set. *\/\n\t\t\tif (CHECK_FLAG(peer->flags,\n\t\t\t\t       PEER_FLAG_OVERRIDE_CAPABILITY))\n\t\t\t\tcontinue;\n\n\t\t\t\/* Convert AFI, SAFI to internal values. *\/\n\t\t\tif (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi,\n\t\t\t\t\t\t      &safi)) {\n\t\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\t\tzlog_debug(\n\t\t\t\t\t\t\"%s Dynamic Capability MP_EXT afi\/safi invalid (%s\/%s)\",\n\t\t\t\t\t\tpeer->host,\n\t\t\t\t\t\tiana_afi2str(pkt_afi),\n\t\t\t\t\t\tiana_safi2str(pkt_safi));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/* Address family check.  *\/\n\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\tzlog_debug(\n\t\t\t\t\t\"%s CAPABILITY has %s MP_EXT CAP for afi\/safi: %s\/%s\",\n\t\t\t\t\tpeer->host,\n\t\t\t\t\taction == CAPABILITY_ACTION_SET\n\t\t\t\t\t\t? \"Advertising\"\n\t\t\t\t\t\t: \"Removing\",\n\t\t\t\t\tiana_afi2str(pkt_afi),\n\t\t\t\t\tiana_safi2str(pkt_safi));\n\n\t\t\tif (action == CAPABILITY_ACTION_SET) {\n\t\t\t\tpeer->afc_recv[afi][safi] = 1;\n\t\t\t\tif (peer->afc[afi][safi]) {\n\t\t\t\t\tpeer->afc_nego[afi][safi] = 1;\n\t\t\t\t\tbgp_announce_route(peer, afi, safi,\n\t\t\t\t\t\t\t   false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpeer->afc_recv[afi][safi] = 0;\n\t\t\t\tpeer->afc_nego[afi][safi] = 0;\n\n\t\t\t\tif (peer_active_nego(peer))\n\t\t\t\t\tbgp_clear_route(peer, afi, safi);\n\t\t\t\telse\n\t\t\t\t\treturn BGP_Stop;\n\t\t\t}\n\t\t} else {\n\t\t\tflog_warn(\n\t\t\t\tEC_BGP_UNRECOGNIZED_CAPABILITY,\n\t\t\t\t\"%s unrecognized capability code: %d - ignored\",\n\t\t\t\tpeer->host, hdr->code);\n\t\t}\n\t}\n\n\t\/* No FSM action necessary *\/\n\treturn BGP_PACKET_NOOP;\n}","target":0,"code_token_length":1013,"total_token_length":1249,"max_tokens_setting":2048}
+{"idx":437334,"func":"print_indent_tree(FILE* f, Node* node, int indent)\n{\n  int i;\n  NodeType type;\n  UChar* p;\n  int add = 3;\n\n  Indent(f, indent);\n  if (IS_NULL(node)) {\n    fprintf(f, \"ERROR: null node!!!\\n\");\n    exit (0);\n  }\n\n  type = NODE_TYPE(node);\n  switch (type) {\n  case NODE_LIST:\n  case NODE_ALT:\n    if (type == NODE_LIST)\n      fprintf(f, \"<list:%p>\\n\", node);\n    else\n      fprintf(f, \"<alt:%p>\\n\", node);\n\n    print_indent_tree(f, NODE_CAR(node), indent + add);\n    while (IS_NOT_NULL(node = NODE_CDR(node))) {\n      if (NODE_TYPE(node) != type) {\n        fprintf(f, \"ERROR: list\/alt right is not a cons. %d\\n\", NODE_TYPE(node));\n        exit(0);\n      }\n      print_indent_tree(f, NODE_CAR(node), indent + add);\n    }\n    break;\n\n  case NODE_STRING:\n    fprintf(f, \"<string%s:%p>\", (NODE_STRING_IS_RAW(node) ? \"-raw\" : \"\"), node);\n    for (p = STR_(node)->s; p < STR_(node)->end; p++) {\n      if (*p >= 0x20 && *p < 0x7f)\n        fputc(*p, f);\n      else {\n        fprintf(f, \" 0x%02x\", *p);\n      }\n    }\n    break;\n\n  case NODE_CCLASS:\n    fprintf(f, \"<cclass:%p>\", node);\n    if (IS_NCCLASS_NOT(CCLASS_(node))) fputs(\" not\", f);\n    if (CCLASS_(node)->mbuf) {\n      BBuf* bbuf = CCLASS_(node)->mbuf;\n      for (i = 0; i < bbuf->used; i++) {\n        if (i > 0) fprintf(f, \",\");\n        fprintf(f, \"%0x\", bbuf->p[i]);\n      }\n    }\n    break;\n\n  case NODE_CTYPE:\n    fprintf(f, \"<ctype:%p> \", node);\n    switch (CTYPE_(node)->ctype) {\n    case CTYPE_ANYCHAR:\n      fprintf(f, \"<anychar:%p>\", node);\n      break;\n\n    case ONIGENC_CTYPE_WORD:\n      if (CTYPE_(node)->not != 0)\n        fputs(\"not word\", f);\n      else\n        fputs(\"word\",     f);\n\n      if (CTYPE_(node)->ascii_mode != 0)\n        fputs(\" (ascii)\", f);\n\n      break;\n\n    default:\n      fprintf(f, \"ERROR: undefined ctype.\\n\");\n      exit(0);\n    }\n    break;\n\n  case NODE_ANCHOR:\n    fprintf(f, \"<anchor:%p> \", node);\n    switch (ANCHOR_(node)->type) {\n    case ANCHOR_BEGIN_BUF:        fputs(\"begin buf\",      f); break;\n    case ANCHOR_END_BUF:          fputs(\"end buf\",        f); break;\n    case ANCHOR_BEGIN_LINE:       fputs(\"begin line\",     f); break;\n    case ANCHOR_END_LINE:         fputs(\"end line\",       f); break;\n    case ANCHOR_SEMI_END_BUF:     fputs(\"semi end buf\",   f); break;\n    case ANCHOR_BEGIN_POSITION:   fputs(\"begin position\", f); break;\n\n    case ANCHOR_WORD_BOUNDARY:    fputs(\"word boundary\",     f); break;\n    case ANCHOR_NO_WORD_BOUNDARY: fputs(\"not word boundary\", f); break;\n#ifdef USE_WORD_BEGIN_END\n    case ANCHOR_WORD_BEGIN:       fputs(\"word begin\", f);     break;\n    case ANCHOR_WORD_END:         fputs(\"word end\", f);       break;\n#endif\n    case ANCHOR_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY:\n      fputs(\"extended-grapheme-cluster boundary\", f); break;\n    case ANCHOR_NO_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY:\n      fputs(\"no-extended-grapheme-cluster boundary\", f); break;\n    case ANCHOR_PREC_READ:\n      fprintf(f, \"prec read\\n\");\n      print_indent_tree(f, NODE_BODY(node), indent + add);\n      break;\n    case ANCHOR_PREC_READ_NOT:\n      fprintf(f, \"prec read not\\n\");\n      print_indent_tree(f, NODE_BODY(node), indent + add);\n      break;\n    case ANCHOR_LOOK_BEHIND:\n      fprintf(f, \"look behind\\n\");\n      print_indent_tree(f, NODE_BODY(node), indent + add);\n      break;\n    case ANCHOR_LOOK_BEHIND_NOT:\n      fprintf(f, \"look behind not\\n\");\n      print_indent_tree(f, NODE_BODY(node), indent + add);\n      break;\n\n    default:\n      fprintf(f, \"ERROR: undefined anchor type.\\n\");\n      break;\n    }\n    break;\n\n  case NODE_BACKREF:\n    {\n      int* p;\n      BackRefNode* br = BACKREF_(node);\n      p = BACKREFS_P(br);\n      fprintf(f, \"<backref%s:%p>\", NODE_IS_CHECKER(node) ? \"-checker\" : \"\", node);\n      for (i = 0; i < br->back_num; i++) {\n        if (i > 0) fputs(\", \", f);\n        fprintf(f, \"%d\", p[i]);\n      }\n    }\n    break;\n\n#ifdef USE_CALL\n  case NODE_CALL:\n    {\n      CallNode* cn = CALL_(node);\n      fprintf(f, \"<call:%p>\", node);\n      p_string(f, cn->name_end - cn->name, cn->name);\n    }\n    break;\n#endif\n\n  case NODE_QUANT:\n    fprintf(f, \"<quantifier:%p>{%d,%d}%s\\n\", node,\n            QUANT_(node)->lower, QUANT_(node)->upper,\n            (QUANT_(node)->greedy ? \"\" : \"?\"));\n    print_indent_tree(f, NODE_BODY(node), indent + add);\n    break;\n\n  case NODE_ENCLOSURE:\n    fprintf(f, \"<enclosure:%p> \", node);\n    switch (ENCLOSURE_(node)->type) {\n    case ENCLOSURE_OPTION:\n      fprintf(f, \"option:%d\", ENCLOSURE_(node)->o.options);\n      break;\n    case ENCLOSURE_MEMORY:\n      fprintf(f, \"memory:%d\", ENCLOSURE_(node)->m.regnum);\n      break;\n    case ENCLOSURE_STOP_BACKTRACK:\n      fprintf(f, \"stop-bt\");\n      break;\n\n    default:\n      break;\n    }\n    fprintf(f, \"\\n\");\n    print_indent_tree(f, NODE_BODY(node), indent + add);\n    break;\n\n  case NODE_GIMMICK:\n    fprintf(f, \"<gimmick:%p> \", node);\n    switch (GIMMICK_(node)->type) {\n    case GIMMICK_FAIL:\n      fprintf(f, \"fail\");\n      break;\n    case GIMMICK_KEEP:\n      fprintf(f, \"keep:%d\", GIMMICK_(node)->id);\n      break;\n    case GIMMICK_SAVE:\n      fprintf(f, \"save:%d:%d\", GIMMICK_(node)->detail_type, GIMMICK_(node)->id);\n      break;\n    case GIMMICK_UPDATE_VAR:\n      fprintf(f, \"update_var:%d:%d\", GIMMICK_(node)->detail_type, GIMMICK_(node)->id);\n      break;\n#ifdef USE_CALLOUT\n    case GIMMICK_CALLOUT:\n      switch (GIMMICK_(node)->detail_type) {\n      case ONIG_CALLOUT_OF_CONTENTS:\n        fprintf(f, \"callout:contents:%d\", GIMMICK_(node)->num);\n        break;\n      case ONIG_CALLOUT_OF_NAME:\n        fprintf(f, \"callout:name:%d:%d\", GIMMICK_(node)->id, GIMMICK_(node)->num);\n        break;\n      }\n#endif\n    }\n    break;\n\n  default:\n    fprintf(f, \"print_indent_tree: undefined node type %d\\n\", NODE_TYPE(node));\n    break;\n  }\n\n  if (type != NODE_LIST && type != NODE_ALT && type != NODE_QUANT &&\n      type != NODE_ENCLOSURE)\n    fprintf(f, \"\\n\");\n  fflush(f);\n}","target":0,"code_token_length":1765,"total_token_length":2001,"max_tokens_setting":2048}
+{"idx":247738,"func":"TEST_P(SslSocketTest, RevokedIntermediateCertificateCRLInTrustedCA) {\n\n  \/\/ This should succeed, since the crl chain is complete.\n  \/\/\n  \/\/ Trust chain contains:\n  \/\/  - Root authority certificate (i.e., ca_cert.pem)\n  \/\/  - Root authority certificate revocation list (i.e., ca_cert.crl)\n  \/\/  - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n  \/\/  - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl)\n  const std::string complete_server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain_with_crl_chain.pem\"\n)EOF\";\n\n  \/\/ This should fail, since the crl chain is incomplete.\n  \/\/\n  \/\/ Trust chain contains:\n  \/\/  - Root authority certificate (i.e., ca_cert.pem)\n  \/\/  - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n  \/\/  - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl)\n  \/\/\n  \/\/ Trust chain omits:\n  \/\/  - Root authority certificate revocation list (i.e., ca_cert.crl)\n  const std::string incomplete_server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain_with_crl.pem\"\n)EOF\";\n\n  \/\/ This should fail, since the certificate has been revoked.\n  const std::string revoked_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_key.pem\"\n)EOF\";\n\n  \/\/ This should succeed, since the certificate has not been revoked.\n  const std::string unrevoked_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns4_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns4_key.pem\"\n)EOF\";\n\n  \/\/ Ensure that incomplete crl chains fail with revoked certificates.\n  TestUtilOptions incomplete_revoked_test_options(revoked_client_ctx_yaml,\n                                                  incomplete_server_ctx_yaml, false, GetParam());\n  testUtil(incomplete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n  \/\/ Ensure that incomplete crl chains fail with unrevoked certificates.\n  TestUtilOptions incomplete_unrevoked_test_options(unrevoked_client_ctx_yaml,\n                                                    incomplete_server_ctx_yaml, false, GetParam());\n  testUtil(incomplete_unrevoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_CRL));\n\n  \/\/ Ensure that complete crl chains fail with revoked certificates.\n  TestUtilOptions complete_revoked_test_options(revoked_client_ctx_yaml, complete_server_ctx_yaml,\n                                                false, GetParam());\n  testUtil(complete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n  \/\/ Ensure that complete crl chains succeed with unrevoked certificates.\n  TestUtilOptions complete_unrevoked_test_options(unrevoked_client_ctx_yaml,\n                                                  complete_server_ctx_yaml, true, GetParam());\n  testUtil(complete_unrevoked_test_options.setExpectedSerialNumber(TEST_SAN_DNS4_CERT_SERIAL));\n}","target":0,"code_token_length":958,"total_token_length":1194,"max_tokens_setting":2048}
+{"idx":259532,"func":"CURLUcode curl_url_get(CURLU *u, CURLUPart what,\n                       char **part, unsigned int flags)\n{\n  char *ptr;\n  CURLUcode ifmissing = CURLUE_UNKNOWN_PART;\n  char portbuf[7];\n  bool urldecode = (flags & CURLU_URLDECODE)?1:0;\n  bool urlencode = (flags & CURLU_URLENCODE)?1:0;\n  bool plusdecode = FALSE;\n  (void)flags;\n  if(!u)\n    return CURLUE_BAD_HANDLE;\n  if(!part)\n    return CURLUE_BAD_PARTPOINTER;\n  *part = NULL;\n\n  switch(what) {\n  case CURLUPART_SCHEME:\n    ptr = u->scheme;\n    ifmissing = CURLUE_NO_SCHEME;\n    urldecode = FALSE; \/* never for schemes *\/\n    break;\n  case CURLUPART_USER:\n    ptr = u->user;\n    ifmissing = CURLUE_NO_USER;\n    break;\n  case CURLUPART_PASSWORD:\n    ptr = u->password;\n    ifmissing = CURLUE_NO_PASSWORD;\n    break;\n  case CURLUPART_OPTIONS:\n    ptr = u->options;\n    ifmissing = CURLUE_NO_OPTIONS;\n    break;\n  case CURLUPART_HOST:\n    ptr = u->host;\n    ifmissing = CURLUE_NO_HOST;\n    break;\n  case CURLUPART_ZONEID:\n    ptr = u->zoneid;\n    ifmissing = CURLUE_NO_ZONEID;\n    break;\n  case CURLUPART_PORT:\n    ptr = u->port;\n    ifmissing = CURLUE_NO_PORT;\n    urldecode = FALSE; \/* never for port *\/\n    if(!ptr && (flags & CURLU_DEFAULT_PORT) && u->scheme) {\n      \/* there's no stored port number, but asked to deliver\n         a default one for the scheme *\/\n      const struct Curl_handler *h =\n        Curl_builtin_scheme(u->scheme);\n      if(h) {\n        msnprintf(portbuf, sizeof(portbuf), \"%u\", h->defport);\n        ptr = portbuf;\n      }\n    }\n    else if(ptr && u->scheme) {\n      \/* there is a stored port number, but ask to inhibit if\n         it matches the default one for the scheme *\/\n      const struct Curl_handler *h =\n        Curl_builtin_scheme(u->scheme);\n      if(h && (h->defport == u->portnum) &&\n         (flags & CURLU_NO_DEFAULT_PORT))\n        ptr = NULL;\n    }\n    break;\n  case CURLUPART_PATH:\n    ptr = u->path;\n    if(!ptr) {\n      ptr = u->path = strdup(\"\/\");\n      if(!u->path)\n        return CURLUE_OUT_OF_MEMORY;\n    }\n    break;\n  case CURLUPART_QUERY:\n    ptr = u->query;\n    ifmissing = CURLUE_NO_QUERY;\n    plusdecode = urldecode;\n    break;\n  case CURLUPART_FRAGMENT:\n    ptr = u->fragment;\n    ifmissing = CURLUE_NO_FRAGMENT;\n    break;\n  case CURLUPART_URL: {\n    char *url;\n    char *scheme;\n    char *options = u->options;\n    char *port = u->port;\n    char *allochost = NULL;\n    if(u->scheme && strcasecompare(\"file\", u->scheme)) {\n      url = aprintf(\"file:\/\/%s%s%s\",\n                    u->path,\n                    u->fragment? \"#\": \"\",\n                    u->fragment? u->fragment : \"\");\n    }\n    else if(!u->host)\n      return CURLUE_NO_HOST;\n    else {\n      const struct Curl_handler *h = NULL;\n      if(u->scheme)\n        scheme = u->scheme;\n      else if(flags & CURLU_DEFAULT_SCHEME)\n        scheme = (char *) DEFAULT_SCHEME;\n      else\n        return CURLUE_NO_SCHEME;\n\n      h = Curl_builtin_scheme(scheme);\n      if(!port && (flags & CURLU_DEFAULT_PORT)) {\n        \/* there's no stored port number, but asked to deliver\n           a default one for the scheme *\/\n        if(h) {\n          msnprintf(portbuf, sizeof(portbuf), \"%u\", h->defport);\n          port = portbuf;\n        }\n      }\n      else if(port) {\n        \/* there is a stored port number, but asked to inhibit if it matches\n           the default one for the scheme *\/\n        if(h && (h->defport == u->portnum) &&\n           (flags & CURLU_NO_DEFAULT_PORT))\n          port = NULL;\n      }\n\n      if(h && !(h->flags & PROTOPT_URLOPTIONS))\n        options = NULL;\n\n      if(u->host[0] == '[') {\n        if(u->zoneid) {\n          \/* make it '[ host %25 zoneid ]' *\/\n          size_t hostlen = strlen(u->host);\n          size_t alen = hostlen + 3 + strlen(u->zoneid) + 1;\n          allochost = malloc(alen);\n          if(!allochost)\n            return CURLUE_OUT_OF_MEMORY;\n          memcpy(allochost, u->host, hostlen - 1);\n          msnprintf(&allochost[hostlen - 1], alen - hostlen + 1,\n                    \"%%25%s]\", u->zoneid);\n        }\n      }\n      else if(urlencode) {\n        allochost = curl_easy_escape(NULL, u->host, 0);\n        if(!allochost)\n          return CURLUE_OUT_OF_MEMORY;\n      }\n      else {\n        \/* only encode '%' in output host name *\/\n        char *host = u->host;\n        size_t pcount = 0;\n        \/* first, count number of percents present in the name *\/\n        while(*host) {\n          if(*host == '%')\n            pcount++;\n          host++;\n        }\n        \/* if there were percents, encode the host name *\/\n        if(pcount) {\n          size_t hostlen = strlen(u->host);\n          size_t alen = hostlen + 2 * pcount + 1;\n          char *o = allochost = malloc(alen);\n          if(!allochost)\n            return CURLUE_OUT_OF_MEMORY;\n\n          host = u->host;\n          while(*host) {\n            if(*host == '%') {\n              memcpy(o, \"%25\", 3);\n              o += 3;\n              host++;\n              continue;\n            }\n            *o++ = *host++;\n          }\n          *o = '\\0';\n        }\n      }\n\n      url = aprintf(\"%s:\/\/%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\",\n                    scheme,\n                    u->user ? u->user : \"\",\n                    u->password ? \":\": \"\",\n                    u->password ? u->password : \"\",\n                    options ? \";\" : \"\",\n                    options ? options : \"\",\n                    (u->user || u->password || options) ? \"@\": \"\",\n                    allochost ? allochost : u->host,\n                    port ? \":\": \"\",\n                    port ? port : \"\",\n                    (u->path && (u->path[0] != '\/')) ? \"\/\": \"\",\n                    u->path ? u->path : \"\/\",\n                    (u->query && u->query[0]) ? \"?\": \"\",\n                    (u->query && u->query[0]) ? u->query : \"\",\n                    u->fragment? \"#\": \"\",\n                    u->fragment? u->fragment : \"\");\n      free(allochost);\n    }\n    if(!url)\n      return CURLUE_OUT_OF_MEMORY;\n    *part = url;\n    return CURLUE_OK;\n  }\n  default:\n    ptr = NULL;\n    break;\n  }\n  if(ptr) {\n    *part = strdup(ptr);\n    if(!*part)\n      return CURLUE_OUT_OF_MEMORY;\n    if(plusdecode) {\n      \/* convert + to space *\/\n      char *plus;\n      for(plus = *part; *plus; ++plus) {\n        if(*plus == '+')\n          *plus = ' ';\n      }\n    }\n    if(urldecode) {\n      char *decoded;\n      size_t dlen;\n      \/* this unconditional rejection of control bytes is documented\n         API behavior *\/\n      CURLcode res = Curl_urldecode(*part, 0, &decoded, &dlen, REJECT_CTRL);\n      free(*part);\n      if(res) {\n        *part = NULL;\n        return CURLUE_URLDECODE;\n      }\n      *part = decoded;\n    }\n    return CURLUE_OK;\n  }\n  else\n    return ifmissing;\n}","target":0,"code_token_length":1794,"total_token_length":2030,"max_tokens_setting":2048}
+{"idx":413677,"func":"static int fcn_print_legacy(RCore *core, RAnalFunction *fcn) {\n\tRListIter *iter;\n\tRAnalRef *refi;\n\tRList *refs, *xrefs;\n\tint ebbs = 0;\n\tchar *name = r_core_anal_fcn_name (core, fcn);\n\n\tr_cons_printf (\"#\\noffset: 0x%08\"PFMT64x\"\\nname: %s\\nsize: %\"PFMT64u,\n\t\t\tfcn->addr, name, r_anal_function_linear_size (fcn));\n\tr_cons_printf (\"\\nis-pure: %s\", r_str_bool (r_anal_function_purity (fcn)));\n\tr_cons_printf (\"\\nrealsz: %\" PFMT64d, r_anal_function_realsize (fcn));\n\tr_cons_printf (\"\\nstackframe: %d\", fcn->maxstack);\n\tif (fcn->cc) {\n\t\tr_cons_printf (\"\\ncall-convention: %s\", fcn->cc);\n\t}\n\tr_cons_printf (\"\\ncyclomatic-cost: %d\", r_anal_function_cost (fcn));\n\tr_cons_printf (\"\\ncyclomatic-complexity: %d\", r_anal_function_complexity (fcn));\n\tr_cons_printf (\"\\nbits: %d\", fcn->bits);\n\tr_cons_printf (\"\\ntype: %s\", r_anal_functiontype_tostring (fcn->type));\n\tif (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) {\n\t\tr_cons_printf (\" [%s]\",\n\t\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?\"MATCH\":\n\t\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?\"UNMATCH\":\"NEW\");\n\t}\n\tr_cons_printf (\"\\nnum-bbs: %d\", r_list_length (fcn->bbs));\n\tr_cons_printf (\"\\nedges: %d\", r_anal_function_count_edges (fcn, &ebbs));\n\tr_cons_printf (\"\\nend-bbs: %d\", ebbs);\n\tr_cons_printf (\"\\ncall-refs:\");\n\tint outdegree = 0;\n\trefs = r_anal_function_get_refs (fcn);\n\tr_list_foreach (refs, iter, refi) {\n\t\tif (refi->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\toutdegree++;\n\t\t}\n\t\tif (refi->type == R_ANAL_REF_TYPE_CODE || refi->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\tr_cons_printf (\" 0x%08\"PFMT64x\" %c\", refi->addr,\n\t\t\t\t\trefi->type == R_ANAL_REF_TYPE_CALL?'C':'J');\n\t\t}\n\t}\n\tr_cons_printf (\"\\ndata-refs:\");\n\tr_list_foreach (refs, iter, refi) {\n\t\t\/\/ global or local?\n\t\tif (refi->type == R_ANAL_REF_TYPE_DATA) {\n\t\t\tr_cons_printf (\" 0x%08\"PFMT64x, refi->addr);\n\t\t}\n\t}\n\tr_list_free (refs);\n\n\tint indegree = 0;\n\tr_cons_printf (\"\\ncode-xrefs:\");\n\txrefs = r_anal_function_get_xrefs (fcn);\n\tr_list_foreach (xrefs, iter, refi) {\n\t\tif (refi->type == R_ANAL_REF_TYPE_CODE || refi->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\tindegree++;\n\t\t\tr_cons_printf (\" 0x%08\"PFMT64x\" %c\", refi->addr,\n\t\t\t\t\trefi->type == R_ANAL_REF_TYPE_CALL?'C':'J');\n\t\t}\n\t}\n\tr_cons_printf (\"\\nnoreturn: %s\", r_str_bool (fcn->is_noreturn));\n\tr_cons_printf (\"\\nin-degree: %d\", indegree);\n\tr_cons_printf (\"\\nout-degree: %d\", outdegree);\n\tr_cons_printf (\"\\ndata-xrefs:\");\n\tr_list_foreach (xrefs, iter, refi) {\n\t\tif (refi->type == R_ANAL_REF_TYPE_DATA) {\n\t\t\tr_cons_printf (\" 0x%08\"PFMT64x, refi->addr);\n\t\t}\n\t}\n\tr_list_free (xrefs);\n\n\tif (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) {\n\t\tint args_count = r_anal_var_count_args (fcn);\n\t\tint var_count = r_anal_var_count_locals (fcn);\n\n\t\tr_cons_printf (\"\\nlocals: %d\\nargs: %d\\n\", var_count, args_count);\n\t\tr_anal_var_list_show (core->anal, fcn, 'b', 0, NULL);\n\t\tr_anal_var_list_show (core->anal, fcn, 's', 0, NULL);\n\t\tr_anal_var_list_show (core->anal, fcn, 'r', 0, NULL);\n\t\tr_cons_printf (\"diff: type: %s\",\n\t\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?\"match\":\n\t\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?\"unmatch\":\"new\");\n\t\tif (fcn->diff->addr != -1) {\n\t\t\tr_cons_printf (\"addr: 0x%\"PFMT64x, fcn->diff->addr);\n\t\t}\n\t\tif (fcn->diff->name) {\n\t\t\tr_cons_printf (\"function: %s\", fcn->diff->name);\n\t\t}\n\t}\n\tfree (name);\n\n\t\/\/ traced\n\tif (core->dbg->trace->enabled) {\n\t\tis_fcn_traced (core->dbg->trace, fcn);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":1186,"total_token_length":1422,"max_tokens_setting":2048}
+{"idx":204016,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tsquashfs_dir_header_2 dirh;\n\tchar buffer[sizeof(squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tsquashfs_dir_entry_2 *dire = (squashfs_dir_entry_2 *) buffer;\n\tlong long start;\n\tint bytes = 0;\n\tint dir_count, size, res;\n\tstruct dir_ent *ent, *cur_ent = NULL;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tMEM_ERROR();\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = NULL;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 0)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\toffset = (*i)->offset;\n\tsize = (*i)->data + bytes;\n\n\twhile(bytes < size) {\n\t\tif(swap) {\n\t\t\tsquashfs_dir_header_2 sdirh;\n\t\t\tres = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));\n\t\t\tif(res)\n\t\t\t\tSQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);\n\t\t} else\n\t\t\tres = read_directory_data(&dirh, &start, &offset, sizeof(dirh));\n\n\t\tif(res == FALSE)\n\t\t\tgoto corrupted;\n\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_entry_2 sdire;\n\t\t\t\tres = read_directory_data(&sdire, &start,\n\t\t\t\t\t&offset, sizeof(sdire));\n\t\t\t\tif(res)\n\t\t\t\t\tSQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);\n\t\t\t} else\n\t\t\t\tres = read_directory_data(dire, &start,\n\t\t\t\t\t&offset, sizeof(*dire));\n\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tres = read_directory_data(dire->name, &start, &offset,\n\t\t\t\t\t\t\t\tdire->size + 1);\n\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\n\t\t\t\/* check name for invalid characters (i.e \/, ., ..) *\/\n\t\t\tif(check_name(dire->name, dire->size + 1) == FALSE) {\n\t\t\t\tERROR(\"File system corrupted: invalid characters in name\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\n\t\t\tent = malloc(sizeof(struct dir_ent));\n\t\t\tif(ent == NULL)\n\t\t\t\tMEM_ERROR();\n\n\t\t\tent->name = strdup(dire->name);\n\t\t\tent->start_block = dirh.start_block;\n\t\t\tent->offset = dire->offset;\n\t\t\tent->type = dire->type;\n\t\t\tent->next = NULL;\n\t\t\tif(cur_ent == NULL)\n\t\t\t\tdir->dirs = ent;\n\t\t\telse\n\t\t\t\tcur_ent->next = ent;\n\t\t\tcur_ent = ent;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tsquashfs_closedir(dir);\n\treturn NULL;\n}","target":1,"code_token_length":998,"total_token_length":1234,"max_tokens_setting":2048}
+{"idx":195302,"func":"R_API bool r_io_bank_map_add_top(RIO *io, const ut32 bankid, const ut32 mapid) {\n\tRIOBank *bank = r_io_bank_get (io, bankid);\n\tRIOMap *map = r_io_map_get (io, mapid);\n\tr_return_val_if_fail (io && bank && map, false);\n\tRIOMapRef *mapref = _mapref_from_map (map);\n\tif (!mapref) {\n\t\treturn false;\n\t}\n\tRIOSubMap *sm = r_io_submap_new (io, mapref);\n\tif (!sm) {\n\t\tfree (mapref);\n\t\treturn false;\n\t}\n\tRRBNode *entry = _find_entry_submap_node (bank, sm);\n\tif (!entry) {\n\t\t\/\/ no intersection with any submap, so just insert\n\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tfree (sm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\tbank->last_used = NULL;\n\tRIOSubMap *bd = (RIOSubMap *)entry->data;\n\tif (r_io_submap_to (bd) == r_io_submap_to (sm) &&\n\t\tr_io_submap_from (bd) >= r_io_submap_from (sm)) {\n\t\t\/\/ _find_entry_submap_node guarantees, that there is no submap\n\t\t\/\/ prior to bd in the range of sm, so instead of deleting and inserting\n\t\t\/\/ we can just memcpy\n\t\tmemcpy (bd, sm, sizeof (RIOSubMap));\n\t\tfree (sm);\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm) &&\n\t\tr_io_submap_to (sm) < r_io_submap_to (bd)) {\n\t\t\/\/ split bd into 2 maps => bd and bdsm\n\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, bd);\n\t\tif (!bdsm) {\n\t\t\tfree (sm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_io_submap_set_from (bdsm, r_io_submap_to (sm) + 1);\n\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\t\/\/ TODO: insert and check return value, before adjusting sm size\n\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tfree (sm);\n\t\t\tfree (bdsm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tif (!r_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tr_crbtree_delete (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\tfree (sm);\n\t\t\tfree (bdsm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\n\t\/\/ guaranteed intersection\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm)) {\n\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\tentry = r_rbnode_next (entry);\n\t}\n\twhile (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\t\/\/delete all submaps that are completly included in sm\n\t\tRRBNode *next = r_rbnode_next (entry);\n\t\t\/\/ this can be optimized, there is no need to do search here\n\t\tr_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL);\n\t\tentry = next;\n\t}\n\tif (entry && r_io_submap_from (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\tbd = (RIOSubMap *)entry->data;\n\t\tr_io_submap_set_from (bd, r_io_submap_to (sm) + 1);\n\t}\n\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\tfree (sm);\n\t\tfree (mapref);\n\t\treturn false;\n\t}\n\tr_list_append (bank->maprefs, mapref);\n\treturn true;\n}","target":1,"code_token_length":995,"total_token_length":1231,"max_tokens_setting":2048}
+{"idx":300785,"func":"static int tipc_recvmsg(struct socket *sock, struct msghdr *m,\n\t\t\tsize_t buflen,\tint flags)\n{\n\tstruct sock *sk = sock->sk;\n\tbool connected = !tipc_sk_type_connectionless(sk);\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tint rc, err, hlen, dlen, copy;\n\tstruct tipc_skb_cb *skb_cb;\n\tstruct sk_buff_head xmitq;\n\tstruct tipc_msg *hdr;\n\tstruct sk_buff *skb;\n\tbool grp_evt;\n\tlong timeout;\n\n\t\/* Catch invalid receive requests *\/\n\tif (unlikely(!buflen))\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\tif (unlikely(connected && sk->sk_state == TIPC_OPEN)) {\n\t\trc = -ENOTCONN;\n\t\tgoto exit;\n\t}\n\ttimeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);\n\n\t\/* Step rcv queue to first msg with data or error; wait if necessary *\/\n\tdo {\n\t\trc = tipc_wait_for_rcvmsg(sock, &timeout);\n\t\tif (unlikely(rc))\n\t\t\tgoto exit;\n\t\tskb = skb_peek(&sk->sk_receive_queue);\n\t\tskb_cb = TIPC_SKB_CB(skb);\n\t\thdr = buf_msg(skb);\n\t\tdlen = msg_data_sz(hdr);\n\t\thlen = msg_hdr_sz(hdr);\n\t\terr = msg_errcode(hdr);\n\t\tgrp_evt = msg_is_grp_evt(hdr);\n\t\tif (likely(dlen || err))\n\t\t\tbreak;\n\t\ttsk_advance_rx_queue(sk);\n\t} while (1);\n\n\t\/* Collect msg meta data, including error code and rejected data *\/\n\ttipc_sk_set_orig_addr(m, skb);\n\trc = tipc_sk_anc_data_recv(m, skb, tsk);\n\tif (unlikely(rc))\n\t\tgoto exit;\n\thdr = buf_msg(skb);\n\n\t\/* Capture data if non-error msg, otherwise just set return value *\/\n\tif (likely(!err)) {\n\t\tint offset = skb_cb->bytes_read;\n\n\t\tcopy = min_t(int, dlen - offset, buflen);\n\t\trc = skb_copy_datagram_msg(skb, hlen + offset, m, copy);\n\t\tif (unlikely(rc))\n\t\t\tgoto exit;\n\t\tif (unlikely(offset + copy < dlen)) {\n\t\t\tif (flags & MSG_EOR) {\n\t\t\t\tif (!(flags & MSG_PEEK))\n\t\t\t\t\tskb_cb->bytes_read = offset + copy;\n\t\t\t} else {\n\t\t\t\tm->msg_flags |= MSG_TRUNC;\n\t\t\t\tskb_cb->bytes_read = 0;\n\t\t\t}\n\t\t} else {\n\t\t\tif (flags & MSG_EOR)\n\t\t\t\tm->msg_flags |= MSG_EOR;\n\t\t\tskb_cb->bytes_read = 0;\n\t\t}\n\t} else {\n\t\tcopy = 0;\n\t\trc = 0;\n\t\tif (err != TIPC_CONN_SHUTDOWN && connected && !m->msg_control) {\n\t\t\trc = -ECONNRESET;\n\t\t\tgoto exit;\n\t\t}\n\t}\n\n\t\/* Mark message as group event if applicable *\/\n\tif (unlikely(grp_evt)) {\n\t\tif (msg_grp_evt(hdr) == TIPC_WITHDRAWN)\n\t\t\tm->msg_flags |= MSG_EOR;\n\t\tm->msg_flags |= MSG_OOB;\n\t\tcopy = 0;\n\t}\n\n\t\/* Caption of data or error code\/rejected data was successful *\/\n\tif (unlikely(flags & MSG_PEEK))\n\t\tgoto exit;\n\n\t\/* Send group flow control advertisement when applicable *\/\n\tif (tsk->group && msg_in_group(hdr) && !grp_evt) {\n\t\t__skb_queue_head_init(&xmitq);\n\t\ttipc_group_update_rcv_win(tsk->group, tsk_blocks(hlen + dlen),\n\t\t\t\t\t  msg_orignode(hdr), msg_origport(hdr),\n\t\t\t\t\t  &xmitq);\n\t\ttipc_node_distr_xmit(sock_net(sk), &xmitq);\n\t}\n\n\tif (skb_cb->bytes_read)\n\t\tgoto exit;\n\n\ttsk_advance_rx_queue(sk);\n\n\tif (likely(!connected))\n\t\tgoto exit;\n\n\t\/* Send connection flow control advertisement when applicable *\/\n\ttsk->rcv_unacked += tsk_inc(tsk, hlen + dlen);\n\tif (tsk->rcv_unacked >= tsk->rcv_win \/ TIPC_ACK_RATE)\n\t\ttipc_sk_send_ack(tsk);\nexit:\n\trelease_sock(sk);\n\treturn rc ? rc : copy;\n}","target":0,"code_token_length":907,"total_token_length":1143,"max_tokens_setting":2048}
+{"idx":206677,"func":"unix_expandpath(\n    garray_T\t*gap,\n    char_u\t*path,\n    int\t\twildoff,\n    int\t\tflags,\t\t\/\/ EW_* flags\n    int\t\tdidstar)\t\/\/ expanded \"**\" once already\n{\n    char_u\t*buf;\n    char_u\t*path_end;\n    char_u\t*p, *s, *e;\n    int\t\tstart_len = gap->ga_len;\n    char_u\t*pat;\n    regmatch_T\tregmatch;\n    int\t\tstarts_with_dot;\n    int\t\tmatches;\n    int\t\tlen;\n    int\t\tstarstar = FALSE;\n    static int\tstardepth = 0;\t    \/\/ depth for \"**\" expansion\n\n    DIR\t\t*dirp;\n    struct dirent *dp;\n\n    \/\/ Expanding \"**\" may take a long time, check for CTRL-C.\n    if (stardepth > 0)\n    {\n\tui_breakcheck();\n\tif (got_int)\n\t    return 0;\n    }\n\n    \/\/ make room for file name\n    buf = alloc(STRLEN(path) + BASENAMELEN + 5);\n    if (buf == NULL)\n\treturn 0;\n\n    \/*\n     * Find the first part in the path name that contains a wildcard.\n     * When EW_ICASE is set every letter is considered to be a wildcard.\n     * Copy it into \"buf\", including the preceding characters.\n     *\/\n    p = buf;\n    s = buf;\n    e = NULL;\n    path_end = path;\n    while (*path_end != NUL)\n    {\n\t\/\/ May ignore a wildcard that has a backslash before it; it will\n\t\/\/ be removed by rem_backslash() or file_pat_to_reg_pat() below.\n\tif (path_end >= path + wildoff && rem_backslash(path_end))\n\t    *p++ = *path_end++;\n\telse if (*path_end == '\/')\n\t{\n\t    if (e != NULL)\n\t\tbreak;\n\t    s = p + 1;\n\t}\n\telse if (path_end >= path + wildoff\n\t\t\t && (vim_strchr((char_u *)\"*?[{~$\", *path_end) != NULL\n\t\t\t     || (!p_fic && (flags & EW_ICASE)\n\t\t\t\t\t     && isalpha(PTR2CHAR(path_end)))))\n\t    e = p;\n\tif (has_mbyte)\n\t{\n\t    len = (*mb_ptr2len)(path_end);\n\t    STRNCPY(p, path_end, len);\n\t    p += len;\n\t    path_end += len;\n\t}\n\telse\n\t    *p++ = *path_end++;\n    }\n    e = p;\n    *e = NUL;\n\n    \/\/ Now we have one wildcard component between \"s\" and \"e\".\n    \/\/ Remove backslashes between \"wildoff\" and the start of the wildcard\n    \/\/ component.\n    for (p = buf + wildoff; p < s; ++p)\n\tif (rem_backslash(p))\n\t{\n\t    STRMOVE(p, p + 1);\n\t    --e;\n\t    --s;\n\t}\n\n    \/\/ Check for \"**\" between \"s\" and \"e\".\n    for (p = s; p < e; ++p)\n\tif (p[0] == '*' && p[1] == '*')\n\t    starstar = TRUE;\n\n    \/\/ convert the file pattern to a regexp pattern\n    starts_with_dot = *s == '.';\n    pat = file_pat_to_reg_pat(s, e, NULL, FALSE);\n    if (pat == NULL)\n    {\n\tvim_free(buf);\n\treturn 0;\n    }\n\n    \/\/ compile the regexp into a program\n    if (flags & EW_ICASE)\n\tregmatch.rm_ic = TRUE;\t\t\/\/ 'wildignorecase' set\n    else\n\tregmatch.rm_ic = p_fic;\t\/\/ ignore case when 'fileignorecase' is set\n    if (flags & (EW_NOERROR | EW_NOTWILD))\n\t++emsg_silent;\n    regmatch.regprog = vim_regcomp(pat, RE_MAGIC);\n    if (flags & (EW_NOERROR | EW_NOTWILD))\n\t--emsg_silent;\n    vim_free(pat);\n\n    if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0)\n    {\n\tvim_free(buf);\n\treturn 0;\n    }\n\n    \/\/ If \"**\" is by itself, this is the first time we encounter it and more\n    \/\/ is following then find matches without any directory.\n    if (!didstar && stardepth < 100 && starstar && e - s == 2\n\t\t\t\t\t\t\t  && *path_end == '\/')\n    {\n\tSTRCPY(s, path_end + 1);\n\t++stardepth;\n\t(void)unix_expandpath(gap, buf, (int)(s - buf), flags, TRUE);\n\t--stardepth;\n    }\n\n    \/\/ open the directory for scanning\n    *s = NUL;\n    dirp = opendir(*buf == NUL ? \".\" : (char *)buf);\n\n    \/\/ Find all matching entries\n    if (dirp != NULL)\n    {\n\tfor (;;)\n\t{\n\t    dp = readdir(dirp);\n\t    if (dp == NULL)\n\t\tbreak;\n\t    if ((dp->d_name[0] != '.' || starts_with_dot\n\t\t\t|| ((flags & EW_DODOT)\n\t\t\t    && dp->d_name[1] != NUL\n\t\t\t    && (dp->d_name[1] != '.' || dp->d_name[2] != NUL)))\n\t\t && ((regmatch.regprog != NULL && vim_regexec(®match,\n\t\t\t\t\t     (char_u *)dp->d_name, (colnr_T)0))\n\t\t   || ((flags & EW_NOTWILD)\n\t\t     && fnamencmp(path + (s - buf), dp->d_name, e - s) == 0)))\n\t    {\n\t\tSTRCPY(s, dp->d_name);\n\t\tlen = STRLEN(buf);\n\n\t\tif (starstar && stardepth < 100)\n\t\t{\n\t\t    \/\/ For \"**\" in the pattern first go deeper in the tree to\n\t\t    \/\/ find matches.\n\t\t    STRCPY(buf + len, \"\/**\");\n\t\t    STRCPY(buf + len + 3, path_end);\n\t\t    ++stardepth;\n\t\t    (void)unix_expandpath(gap, buf, len + 1, flags, TRUE);\n\t\t    --stardepth;\n\t\t}\n\n\t\tSTRCPY(buf + len, path_end);\n\t\tif (mch_has_exp_wildcard(path_end)) \/\/ handle more wildcards\n\t\t{\n\t\t    \/\/ need to expand another component of the path\n\t\t    \/\/ remove backslashes for the remaining components only\n\t\t    (void)unix_expandpath(gap, buf, len + 1, flags, FALSE);\n\t\t}\n\t\telse\n\t\t{\n\t\t    stat_T  sb;\n\n\t\t    \/\/ no more wildcards, check if there is a match\n\t\t    \/\/ remove backslashes for the remaining components only\n\t\t    if (*path_end != NUL)\n\t\t\tbackslash_halve(buf + len + 1);\n\t\t    \/\/ add existing file or symbolic link\n\t\t    if ((flags & EW_ALLLINKS) ? mch_lstat((char *)buf, &sb) >= 0\n\t\t\t\t\t\t      : mch_getperm(buf) >= 0)\n\t\t    {\n#ifdef MACOS_CONVERT\n\t\t\tsize_t precomp_len = STRLEN(buf)+1;\n\t\t\tchar_u *precomp_buf =\n\t\t\t    mac_precompose_path(buf, precomp_len, &precomp_len);\n\n\t\t\tif (precomp_buf)\n\t\t\t{\n\t\t\t    mch_memmove(buf, precomp_buf, precomp_len);\n\t\t\t    vim_free(precomp_buf);\n\t\t\t}\n#endif\n\t\t\taddfile(gap, buf, flags);\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n\tclosedir(dirp);\n    }\n\n    vim_free(buf);\n    vim_regfree(regmatch.regprog);\n\n    matches = gap->ga_len - start_len;\n    if (matches > 0)\n\tqsort(((char_u **)gap->ga_data) + start_len, matches,\n\t\t\t\t\t\t   sizeof(char_u *), pstrcmp);\n    return matches;\n}","target":1,"code_token_length":1690,"total_token_length":1926,"max_tokens_setting":2048}
+{"idx":310155,"func":"_nc_mouse_event(SCREEN *sp)\n{\n    MEVENT *eventp = sp->_mouse_eventp;\n    bool result = FALSE;\n\n    (void) eventp;\n\n    switch (sp->_mouse_type) {\n    case M_XTERM:\n\t\/* xterm: never have to query, mouse events are in the keyboard stream *\/\n#if USE_EMX_MOUSE\n\t{\n\t    char kbuf[3];\n\n\t    int i, res = read(M_FD(sp), &kbuf, 3);\t\/* Eat the prefix *\/\n\t    if (res != 3)\n\t\tprintf(\"Got %d chars instead of 3 for prefix.\\n\", res);\n\t    for (i = 0; i < res; i++) {\n\t\tif (kbuf[i] != key_mouse[i])\n\t\t    printf(\"Got char %d instead of %d for prefix.\\n\",\n\t\t\t   (int) kbuf[i], (int) key_mouse[i]);\n\t    }\n\t    result = TRUE;\n\t}\n#endif \/* USE_EMX_MOUSE *\/\n\tbreak;\n\n#if USE_GPM_SUPPORT\n    case M_GPM:\n\tif (sp->_mouse_fd >= 0) {\n\t    \/* query server for event, return TRUE if we find one *\/\n\t    Gpm_Event ev;\n\n\t    switch (my_Gpm_GetEvent(&ev)) {\n\t    case 0:\n\t\t\/* Connection closed, drop the mouse. *\/\n\t\tsp->_mouse_fd = -1;\n\t\tbreak;\n\t    case 1:\n\t\t\/* there's only one mouse... *\/\n\t\teventp->id = NORMAL_EVENT;\n\n\t\teventp->bstate = 0;\n\t\tswitch (ev.type & 0x0f) {\n\t\tcase (GPM_DOWN):\n\t\t    if (ev.buttons & GPM_B_LEFT)\n\t\t\teventp->bstate |= BUTTON1_PRESSED;\n\t\t    if (ev.buttons & GPM_B_MIDDLE)\n\t\t\teventp->bstate |= BUTTON2_PRESSED;\n\t\t    if (ev.buttons & GPM_B_RIGHT)\n\t\t\teventp->bstate |= BUTTON3_PRESSED;\n\t\t    break;\n\t\tcase (GPM_UP):\n\t\t    if (ev.buttons & GPM_B_LEFT)\n\t\t\teventp->bstate |= BUTTON1_RELEASED;\n\t\t    if (ev.buttons & GPM_B_MIDDLE)\n\t\t\teventp->bstate |= BUTTON2_RELEASED;\n\t\t    if (ev.buttons & GPM_B_RIGHT)\n\t\t\teventp->bstate |= BUTTON3_RELEASED;\n\t\t    break;\n\t\tdefault:\n\t\t    eventp->bstate |= REPORT_MOUSE_POSITION;\n\t\t    break;\n\t\t}\n\n\t\teventp->x = ev.x - 1;\n\t\teventp->y = ev.y - 1;\n\t\teventp->z = 0;\n\n\t\t\/* bump the next-free pointer into the circular list *\/\n\t\tsp->_mouse_eventp = NEXT(eventp);\n\t\tresult = TRUE;\n\t\tbreak;\n\t    }\n\t}\n\tbreak;\n#endif\n\n#if USE_SYSMOUSE\n    case M_SYSMOUSE:\n\tif (sp->_sysmouse_head < sp->_sysmouse_tail) {\n\t    *eventp = sp->_sysmouse_fifo[sp->_sysmouse_head];\n\n\t    \/*\n\t     * Point the fifo-head to the next possible location.  If there\n\t     * are none, reset the indices.  This may be interrupted by the\n\t     * signal handler, doing essentially the same reset.\n\t     *\/\n\t    sp->_sysmouse_head += 1;\n\t    if (sp->_sysmouse_head == sp->_sysmouse_tail) {\n\t\tsp->_sysmouse_tail = 0;\n\t\tsp->_sysmouse_head = 0;\n\t    }\n\n\t    \/* bump the next-free pointer into the circular list *\/\n\t    sp->_mouse_eventp = eventp = NEXT(eventp);\n\t    result = TRUE;\n\t}\n\tbreak;\n#endif \/* USE_SYSMOUSE *\/\n\n#ifdef USE_TERM_DRIVER\n    case M_TERM_DRIVER:\n\twhile (sp->_drv_mouse_head < sp->_drv_mouse_tail) {\n\t    *eventp = sp->_drv_mouse_fifo[sp->_drv_mouse_head];\n\n\t    \/*\n\t     * Point the fifo-head to the next possible location.  If there\n\t     * are none, reset the indices.\n\t     *\/\n\t    sp->_drv_mouse_head += 1;\n\t    if (sp->_drv_mouse_head == sp->_drv_mouse_tail) {\n\t\tsp->_drv_mouse_tail = 0;\n\t\tsp->_drv_mouse_head = 0;\n\t    }\n\n\t    \/* bump the next-free pointer into the circular list *\/\n\t    sp->_mouse_eventp = eventp = NEXT(eventp);\n\t    result = TRUE;\n\t}\n\tbreak;\n#endif\n\n    case M_NONE:\n\tbreak;\n    }\n\n    return result;\t\t\/* true if we found an event *\/\n}","target":0,"code_token_length":954,"total_token_length":1190,"max_tokens_setting":2048}
+{"idx":209955,"func":"struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,\n\t\t\t       const struct pci_device_id *ent,\n\t\t\t       const struct iwl_cfg_trans_params *cfg_trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie;\n\tstruct iwl_trans *trans;\n\tint ret, addr_size;\n\n\tret = pcim_enable_device(pdev);\n\tif (ret)\n\t\treturn ERR_PTR(ret);\n\n\tif (cfg_trans->gen2)\n\t\ttrans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),\n\t\t\t\t\t&pdev->dev, &trans_ops_pcie_gen2);\n\telse\n\t\ttrans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),\n\t\t\t\t\t&pdev->dev, &trans_ops_pcie);\n\n\tif (!trans)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\ttrans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\n\ttrans_pcie->trans = trans;\n\ttrans_pcie->opmode_down = true;\n\tspin_lock_init(&trans_pcie->irq_lock);\n\tspin_lock_init(&trans_pcie->reg_lock);\n\tmutex_init(&trans_pcie->mutex);\n\tinit_waitqueue_head(&trans_pcie->ucode_write_waitq);\n\ttrans_pcie->tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page);\n\tif (!trans_pcie->tso_hdr_page) {\n\t\tret = -ENOMEM;\n\t\tgoto out_no_pci;\n\t}\n\ttrans_pcie->debug_rfkill = -1;\n\n\tif (!cfg_trans->base_params->pcie_l1_allowed) {\n\t\t\/*\n\t\t * W\/A - seems to solve weird behavior. We need to remove this\n\t\t * if we don't want to stay in L1 all the time. This wastes a\n\t\t * lot of power.\n\t\t *\/\n\t\tpci_disable_link_state(pdev, PCIE_LINK_STATE_L0S |\n\t\t\t\t       PCIE_LINK_STATE_L1 |\n\t\t\t\t       PCIE_LINK_STATE_CLKPM);\n\t}\n\n\ttrans_pcie->def_rx_queue = 0;\n\n\tif (cfg_trans->use_tfh) {\n\t\taddr_size = 64;\n\t\ttrans_pcie->max_tbs = IWL_TFH_NUM_TBS;\n\t\ttrans_pcie->tfd_size = sizeof(struct iwl_tfh_tfd);\n\t} else {\n\t\taddr_size = 36;\n\t\ttrans_pcie->max_tbs = IWL_NUM_OF_TBS;\n\t\ttrans_pcie->tfd_size = sizeof(struct iwl_tfd);\n\t}\n\ttrans->max_skb_frags = IWL_PCIE_MAX_FRAGS(trans_pcie);\n\n\tpci_set_master(pdev);\n\n\tret = pci_set_dma_mask(pdev, DMA_BIT_MASK(addr_size));\n\tif (!ret)\n\t\tret = pci_set_consistent_dma_mask(pdev,\n\t\t\t\t\t\t  DMA_BIT_MASK(addr_size));\n\tif (ret) {\n\t\tret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));\n\t\tif (!ret)\n\t\t\tret = pci_set_consistent_dma_mask(pdev,\n\t\t\t\t\t\t\t  DMA_BIT_MASK(32));\n\t\t\/* both attempts failed: *\/\n\t\tif (ret) {\n\t\t\tdev_err(&pdev->dev, \"No suitable DMA available\\n\");\n\t\t\tgoto out_no_pci;\n\t\t}\n\t}\n\n\tret = pcim_iomap_regions_request_all(pdev, BIT(0), DRV_NAME);\n\tif (ret) {\n\t\tdev_err(&pdev->dev, \"pcim_iomap_regions_request_all failed\\n\");\n\t\tgoto out_no_pci;\n\t}\n\n\ttrans_pcie->hw_base = pcim_iomap_table(pdev)[0];\n\tif (!trans_pcie->hw_base) {\n\t\tdev_err(&pdev->dev, \"pcim_iomap_table failed\\n\");\n\t\tret = -ENODEV;\n\t\tgoto out_no_pci;\n\t}\n\n\t\/* We disable the RETRY_TIMEOUT register (0x41) to keep\n\t * PCI Tx retries from interfering with C3 CPU state *\/\n\tpci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);\n\n\ttrans_pcie->pci_dev = pdev;\n\tiwl_disable_interrupts(trans);\n\n\ttrans->hw_rev = iwl_read32(trans, CSR_HW_REV);\n\tif (trans->hw_rev == 0xffffffff) {\n\t\tdev_err(&pdev->dev, \"HW_REV=0xFFFFFFFF, PCI issues?\\n\");\n\t\tret = -EIO;\n\t\tgoto out_no_pci;\n\t}\n\n\t\/*\n\t * In the 8000 HW family the format of the 4 bytes of CSR_HW_REV have\n\t * changed, and now the revision step also includes bit 0-1 (no more\n\t * \"dash\" value). To keep hw_rev backwards compatible - we'll store it\n\t * in the old format.\n\t *\/\n\tif (cfg_trans->device_family >= IWL_DEVICE_FAMILY_8000) {\n\t\ttrans->hw_rev = (trans->hw_rev & 0xfff0) |\n\t\t\t\t(CSR_HW_REV_STEP(trans->hw_rev << 2) << 2);\n\n\t\tret = iwl_pcie_prepare_card_hw(trans);\n\t\tif (ret) {\n\t\t\tIWL_WARN(trans, \"Exit HW not ready\\n\");\n\t\t\tgoto out_no_pci;\n\t\t}\n\n\t\t\/*\n\t\t * in-order to recognize C step driver should read chip version\n\t\t * id located at the AUX bus MISC address space.\n\t\t *\/\n\t\tret = iwl_finish_nic_init(trans, cfg_trans);\n\t\tif (ret)\n\t\t\tgoto out_no_pci;\n\n\t}\n\n\tIWL_DEBUG_INFO(trans, \"HW REV: 0x%0x\\n\", trans->hw_rev);\n\n\tiwl_pcie_set_interrupt_capa(pdev, trans, cfg_trans);\n\ttrans->hw_id = (pdev->device << 16) + pdev->subsystem_device;\n\tsnprintf(trans->hw_id_str, sizeof(trans->hw_id_str),\n\t\t \"PCI ID: 0x%04X:0x%04X\", pdev->device, pdev->subsystem_device);\n\n\t\/* Initialize the wait queue for commands *\/\n\tinit_waitqueue_head(&trans_pcie->wait_command_queue);\n\n\tinit_waitqueue_head(&trans_pcie->sx_waitq);\n\n\tif (trans_pcie->msix_enabled) {\n\t\tret = iwl_pcie_init_msix_handler(pdev, trans_pcie);\n\t\tif (ret)\n\t\t\tgoto out_no_pci;\n\t } else {\n\t\tret = iwl_pcie_alloc_ict(trans);\n\t\tif (ret)\n\t\t\tgoto out_no_pci;\n\n\t\tret = devm_request_threaded_irq(&pdev->dev, pdev->irq,\n\t\t\t\t\t\tiwl_pcie_isr,\n\t\t\t\t\t\tiwl_pcie_irq_handler,\n\t\t\t\t\t\tIRQF_SHARED, DRV_NAME, trans);\n\t\tif (ret) {\n\t\t\tIWL_ERR(trans, \"Error allocating IRQ %d\\n\", pdev->irq);\n\t\t\tgoto out_free_ict;\n\t\t}\n\t\ttrans_pcie->inta_mask = CSR_INI_SET_MASK;\n\t }\n\n\ttrans_pcie->rba.alloc_wq = alloc_workqueue(\"rb_allocator\",\n\t\t\t\t\t\t   WQ_HIGHPRI | WQ_UNBOUND, 1);\n\tINIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work);\n\n#ifdef CONFIG_IWLWIFI_DEBUGFS\n\ttrans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED;\n\tmutex_init(&trans_pcie->fw_mon_data.mutex);\n#endif\n\n\treturn trans;\n\nout_free_ict:\n\tiwl_pcie_free_ict(trans);\nout_no_pci:\n\tfree_percpu(trans_pcie->tso_hdr_page);\n\tiwl_trans_free(trans);\n\treturn ERR_PTR(ret);\n}","target":1,"code_token_length":1554,"total_token_length":1790,"max_tokens_setting":2048}
+{"idx":514295,"func":"bool multi_update::send_eof()\n{\n  char buff[STRING_BUFFER_USUAL_SIZE];\n  ulonglong id;\n  killed_state killed_status= NOT_KILLED;\n  DBUG_ENTER(\"multi_update::send_eof\");\n  THD_STAGE_INFO(thd, stage_updating_reference_tables);\n\n  \/* \n     Does updates for the last n - 1 tables, returns 0 if ok;\n     error takes into account killed status gained in do_updates()\n  *\/\n  int local_error= thd->is_error();\n  if (likely(!local_error))\n    local_error = (table_count) ? do_updates() : 0;\n  \/*\n    if local_error is not set ON until after do_updates() then\n    later carried out killing should not affect binlogging.\n  *\/\n  killed_status= (local_error == 0) ? NOT_KILLED : thd->killed;\n  THD_STAGE_INFO(thd, stage_end);\n\n  \/* We must invalidate the query cache before binlog writing and\n  ha_autocommit_... *\/\n\n  if (updated)\n  {\n    query_cache_invalidate3(thd, update_tables, 1);\n  }\n  \/*\n    Write the SQL statement to the binlog if we updated\n    rows and we succeeded or if we updated some non\n    transactional tables.\n    \n    The query has to binlog because there's a modified non-transactional table\n    either from the query's list or via a stored routine: bug#13270,23333\n  *\/\n\n  if (thd->transaction.stmt.modified_non_trans_table)\n    thd->transaction.all.modified_non_trans_table= TRUE;\n  thd->transaction.all.m_unsafe_rollback_flags|=\n    (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT);\n\n  if (likely(local_error == 0 ||\n             thd->transaction.stmt.modified_non_trans_table))\n  {\n    if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open())\n    {\n      int errcode= 0;\n      if (likely(local_error == 0))\n        thd->clear_error();\n      else\n        errcode= query_error_code(thd, killed_status == NOT_KILLED);\n\n      bool force_stmt= false;\n      for (TABLE *table= all_tables->table; table; table= table->next)\n      {\n        if (table->versioned(VERS_TRX_ID))\n        {\n          force_stmt= true;\n          break;\n        }\n      }\n      enum_binlog_format save_binlog_format;\n      save_binlog_format= thd->get_current_stmt_binlog_format();\n      if (force_stmt)\n        thd->set_current_stmt_binlog_format_stmt();\n\n      if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(),\n                            thd->query_length(), transactional_tables, FALSE,\n                            FALSE, errcode) > 0)\n\tlocal_error= 1;\t\t\t\t\/\/ Rollback update\n      thd->set_current_stmt_binlog_format(save_binlog_format);\n    }\n  }\n  DBUG_ASSERT(trans_safe || !updated ||\n              thd->transaction.stmt.modified_non_trans_table);\n\n  if (likely(local_error != 0))\n    error_handled= TRUE; \/\/ to force early leave from ::abort_result_set()\n\n  if (unlikely(local_error > 0)) \/\/ if the above log write did not fail ...\n  {\n    \/* Safety: If we haven't got an error before (can happen in do_updates) *\/\n    my_message(ER_UNKNOWN_ERROR, \"An error occurred in multi-table update\",\n\t       MYF(0));\n    DBUG_RETURN(TRUE);\n  }\n\n  if (!thd->lex->analyze_stmt)\n  {\n    id= thd->arg_of_last_insert_id_function ?\n    thd->first_successful_insert_id_in_prev_stmt : 0;\n    my_snprintf(buff, sizeof(buff), ER_THD(thd, ER_UPDATE_INFO),\n                (ulong) found, (ulong) updated, (ulong) thd->cuted_fields);\n    ::my_ok(thd, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,\n            id, buff);\n  }\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":889,"total_token_length":1125,"max_tokens_setting":2048}
+{"idx":361751,"func":"static int em28xx_hint_board(struct em28xx *dev)\n{\n\tint i;\n\n\tif (dev->is_webcam) {\n\t\tif (dev->em28xx_sensor == EM28XX_MT9V011) {\n\t\t\tdev->model = EM2820_BOARD_SILVERCREST_WEBCAM;\n\t\t} else if (dev->em28xx_sensor == EM28XX_MT9M001 ||\n\t\t\t   dev->em28xx_sensor == EM28XX_MT9M111) {\n\t\t\tdev->model = EM2750_BOARD_UNKNOWN;\n\t\t}\n\t\t\/* FIXME: IMPROVE ! *\/\n\n\t\treturn 0;\n\t}\n\n\t\/*\n\t * HINT method: EEPROM\n\t *\n\t * This method works only for boards with eeprom.\n\t * Uses a hash of all eeprom bytes. The hash should be\n\t * unique for a vendor\/tuner pair.\n\t * There are a high chance that tuners for different\n\t * video standards produce different hashes.\n\t *\/\n\tfor (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {\n\t\tif (dev->hash == em28xx_eeprom_hash[i].hash) {\n\t\t\tdev->model = em28xx_eeprom_hash[i].model;\n\t\t\tdev->tuner_type = em28xx_eeprom_hash[i].tuner;\n\n\t\t\tdev_err(&dev->intf->dev,\n\t\t\t\t\"Your board has no unique USB ID.\\n\"\n\t\t\t\t\"A hint were successfully done, based on eeprom hash.\\n\"\n\t\t\t\t\"This method is not 100%% failproof.\\n\"\n\t\t\t\t\"If the board were misdetected, please email this log to:\\n\"\n\t\t\t\t\"\\tV4L Mailing List  <linux-media@vger.kernel.org>\\n\"\n\t\t\t\t\"Board detected as %s\\n\",\n\t\t\t       em28xx_boards[dev->model].name);\n\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t\/*\n\t * HINT method: I2C attached devices\n\t *\n\t * This method works for all boards.\n\t * Uses a hash of i2c scanned devices.\n\t * Devices with the same i2c attached chips will\n\t * be considered equal.\n\t * This method is less precise than the eeprom one.\n\t *\/\n\n\t\/* user did not request i2c scanning => do it now *\/\n\tif (!dev->i2c_hash)\n\t\tem28xx_do_i2c_scan(dev, dev->def_i2c_bus);\n\n\tfor (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {\n\t\tif (dev->i2c_hash == em28xx_i2c_hash[i].hash) {\n\t\t\tdev->model = em28xx_i2c_hash[i].model;\n\t\t\tdev->tuner_type = em28xx_i2c_hash[i].tuner;\n\t\t\tdev_err(&dev->intf->dev,\n\t\t\t\t\"Your board has no unique USB ID.\\n\"\n\t\t\t\t\"A hint were successfully done, based on i2c devicelist hash.\\n\"\n\t\t\t\t\"This method is not 100%% failproof.\\n\"\n\t\t\t\t\"If the board were misdetected, please email this log to:\\n\"\n\t\t\t\t\"\\tV4L Mailing List  <linux-media@vger.kernel.org>\\n\"\n\t\t\t\t\"Board detected as %s\\n\",\n\t\t\t\tem28xx_boards[dev->model].name);\n\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tdev_err(&dev->intf->dev,\n\t\t\"Your board has no unique USB ID and thus need a hint to be detected.\\n\"\n\t\t\"You may try to use card=<n> insmod option to workaround that.\\n\"\n\t\t\"Please send an email with this log to:\\n\"\n\t\t\"\\tV4L Mailing List <linux-media@vger.kernel.org>\\n\"\n\t\t\"Board eeprom hash is 0x%08lx\\n\"\n\t\t\"Board i2c devicelist hash is 0x%08lx\\n\",\n\t\tdev->hash, dev->i2c_hash);\n\n\tdev_err(&dev->intf->dev,\n\t\t\"Here is a list of valid choices for the card=<n> insmod option:\\n\");\n\tfor (i = 0; i < em28xx_bcount; i++) {\n\t\tdev_err(&dev->intf->dev,\n\t\t\t\"    card=%d -> %s\\n\", i, em28xx_boards[i].name);\n\t}\n\treturn -1;\n}","target":0,"code_token_length":991,"total_token_length":1227,"max_tokens_setting":2048}
+{"idx":436066,"func":"static int io_read(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tstruct iov_iter __iter, *iter = &__iter;\n\tstruct io_async_rw *rw = req->async_data;\n\tssize_t io_size, ret, ret2;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tif (rw) {\n\t\titer = &rw->iter;\n\t\tiovec = NULL;\n\t} else {\n\t\tret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\tio_size = iov_iter_count(iter);\n\treq->result = io_size;\n\n\t\/* Ensure we clear previously set non-block flag *\/\n\tif (!force_nonblock)\n\t\tkiocb->ki_flags &= ~IOCB_NOWAIT;\n\telse\n\t\tkiocb->ki_flags |= IOCB_NOWAIT;\n\n\t\/* If the file doesn't support async, just async punt *\/\n\tif (force_nonblock && !io_file_supports_async(req, READ)) {\n\t\tret = io_setup_async_rw(req, iovec, inline_vecs, iter, true);\n\t\treturn ret ?: -EAGAIN;\n\t}\n\n\tret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size);\n\tif (unlikely(ret)) {\n\t\tkfree(iovec);\n\t\treturn ret;\n\t}\n\n\tret = io_iter_do_read(req, iter);\n\n\tif (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\t\/* IOPOLL retry should happen for io-wq threads *\/\n\t\tif (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\t\tgoto done;\n\t\t\/* no retry on NONBLOCK nor RWF_NOWAIT *\/\n\t\tif (req->flags & REQ_F_NOWAIT)\n\t\t\tgoto done;\n\t\t\/* some cases will consume bytes even on error returns *\/\n\t\tiov_iter_reexpand(iter, iter->count + iter->truncated);\n\t\tiov_iter_revert(iter, io_size - iov_iter_count(iter));\n\t\tret = 0;\n\t} else if (ret == -EIOCBQUEUED) {\n\t\tgoto out_free;\n\t} else if (ret <= 0 || ret == io_size || !force_nonblock ||\n\t\t   (req->flags & REQ_F_NOWAIT) || !(req->flags & REQ_F_ISREG)) {\n\t\t\/* read all, failed, already did sync or don't want to retry *\/\n\t\tgoto done;\n\t}\n\n\tret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true);\n\tif (ret2)\n\t\treturn ret2;\n\n\tiovec = NULL;\n\trw = req->async_data;\n\t\/* now use our persistent iterator, if we aren't already *\/\n\titer = &rw->iter;\n\n\tdo {\n\t\tio_size -= ret;\n\t\trw->bytes_done += ret;\n\t\t\/* if we can retry, do so with the callbacks armed *\/\n\t\tif (!io_rw_should_retry(req)) {\n\t\t\tkiocb->ki_flags &= ~IOCB_WAITQ;\n\t\t\treturn -EAGAIN;\n\t\t}\n\n\t\t\/*\n\t\t * Now retry read with the IOCB_WAITQ parts set in the iocb. If\n\t\t * we get -EIOCBQUEUED, then we'll get a notification when the\n\t\t * desired page gets unlocked. We can also get a partial read\n\t\t * here, and if we do, then just retry at the new offset.\n\t\t *\/\n\t\tret = io_iter_do_read(req, iter);\n\t\tif (ret == -EIOCBQUEUED)\n\t\t\treturn 0;\n\t\t\/* we got some bytes, but not all. retry. *\/\n\t\tkiocb->ki_flags &= ~IOCB_WAITQ;\n\t} while (ret > 0 && ret < io_size);\ndone:\n\tkiocb_done(kiocb, ret, issue_flags);\nout_free:\n\t\/* it's faster to check here then delegate to kfree *\/\n\tif (iovec)\n\t\tkfree(iovec);\n\treturn 0;\n}","target":0,"code_token_length":916,"total_token_length":1152,"max_tokens_setting":2048}
+{"idx":413827,"func":"void LinkResolver::runtime_resolve_special_method(CallInfo& result,\n                                                  const LinkInfo& link_info,\n                                                  const methodHandle& resolved_method,\n                                                  Handle recv, TRAPS) {\n\n  Klass* resolved_klass = link_info.resolved_klass();\n\n  \/\/ resolved method is selected method unless we have an old-style lookup\n  \/\/ for a superclass method\n  \/\/ Invokespecial for a superinterface, resolved method is selected method,\n  \/\/ no checks for shadowing\n  methodHandle sel_method(THREAD, resolved_method());\n\n  if (link_info.check_access() &&\n      \/\/ check if the method is not <init>\n      resolved_method->name() != vmSymbols::object_initializer_name()) {\n\n    Klass* current_klass = link_info.current_klass();\n\n    \/\/ Check if the class of the resolved_klass is a superclass\n    \/\/ (not supertype in order to exclude interface classes) of the current class.\n    \/\/ This check is not performed for super.invoke for interface methods\n    \/\/ in super interfaces.\n    if (current_klass->is_subclass_of(resolved_klass) &&\n        current_klass != resolved_klass) {\n      \/\/ Lookup super method\n      Klass* super_klass = current_klass->super();\n      Method* instance_method = lookup_instance_method_in_klasses(super_klass,\n                                                     resolved_method->name(),\n                                                     resolved_method->signature(),\n                                                     Klass::PrivateLookupMode::find);\n      sel_method = methodHandle(THREAD, instance_method);\n\n      \/\/ check if found\n      if (sel_method.is_null()) {\n        ResourceMark rm(THREAD);\n        stringStream ss;\n        ss.print(\"'\");\n        resolved_method->print_external_name(&ss);\n        ss.print(\"'\");\n        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());\n      \/\/ check loader constraints if found a different method\n      } else if (link_info.check_loader_constraints() && sel_method() != resolved_method()) {\n        check_method_loader_constraints(link_info, sel_method, \"method\", CHECK);\n      }\n    }\n\n    \/\/ Check that the class of objectref (the receiver) is the current class or interface,\n    \/\/ or a subtype of the current class or interface (the sender), otherwise invokespecial\n    \/\/ throws IllegalAccessError.\n    \/\/ The verifier checks that the sender is a subtype of the class in the I\/MR operand.\n    \/\/ The verifier also checks that the receiver is a subtype of the sender, if the sender is\n    \/\/ a class.  If the sender is an interface, the check has to be performed at runtime.\n    InstanceKlass* sender = InstanceKlass::cast(current_klass);\n    if (sender->is_interface() && recv.not_null()) {\n      Klass* receiver_klass = recv->klass();\n      if (!receiver_klass->is_subtype_of(sender)) {\n        ResourceMark rm(THREAD);\n        char buf[500];\n        jio_snprintf(buf, sizeof(buf),\n                     \"Receiver class %s must be the current class or a subtype of interface %s\",\n                     receiver_klass->external_name(),\n                     sender->external_name());\n        THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);\n      }\n    }\n  }\n\n  \/\/ check if not static\n  if (sel_method->is_static()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"Expecting non-static method '\");\n    resolved_method->print_external_name(&ss);\n    ss.print(\"'\");\n    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n\n  \/\/ check if abstract\n  if (sel_method->is_abstract()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"'\");\n    Method::print_external_name(&ss, resolved_klass, sel_method->name(), sel_method->signature());\n    ss.print(\"'\");\n    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());\n  }\n\n  if (log_develop_is_enabled(Trace, itables)) {\n    trace_method_resolution(\"invokespecial selected method: resolved-class:\",\n                            resolved_klass, resolved_klass, sel_method(), true);\n  }\n\n  \/\/ setup result\n  result.set_static(resolved_klass, sel_method, CHECK);\n}","target":0,"code_token_length":885,"total_token_length":1121,"max_tokens_setting":2048}
+{"idx":259235,"func":"static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    uint8_t intermediate_key[20];\n    uint8_t intermediate_iv[20];\n    uint8_t input[64];\n    uint8_t output[64];\n    uint8_t file_checksum[20];\n    uint8_t calculated_checksum[20];\n    char checksum_string[2 * sizeof(file_checksum) + 1];\n    struct AVSHA *sha;\n    int i;\n    int ret = 0;\n    uint8_t *activation_bytes = c->activation_bytes;\n    uint8_t *fixed_key = c->audible_fixed_key;\n\n    c->aax_mode = 1;\n\n    sha = av_sha_alloc();\n    if (!sha)\n        return AVERROR(ENOMEM);\n    av_free(c->aes_decrypt);\n    c->aes_decrypt = av_aes_alloc();\n    if (!c->aes_decrypt) {\n        ret = AVERROR(ENOMEM);\n        goto fail;\n    }\n\n    \/* drm blob processing *\/\n    avio_read(pb, output, 8); \/\/ go to offset 8, absolute position 0x251\n    avio_read(pb, input, DRM_BLOB_SIZE);\n    avio_read(pb, output, 4); \/\/ go to offset 4, absolute position 0x28d\n    avio_read(pb, file_checksum, 20);\n\n    \/\/ required by external tools\n    ff_data_to_hex(checksum_string, file_checksum, sizeof(file_checksum), 1);\n    av_log(c->fc, AV_LOG_INFO, \"[aax] file checksum == %s\\n\", checksum_string);\n\n    \/* verify activation data *\/\n    if (!activation_bytes) {\n        av_log(c->fc, AV_LOG_WARNING, \"[aax] activation_bytes option is missing!\\n\");\n        ret = 0;  \/* allow ffprobe to continue working on .aax files *\/\n        goto fail;\n    }\n    if (c->activation_bytes_size != 4) {\n        av_log(c->fc, AV_LOG_FATAL, \"[aax] activation_bytes value needs to be 4 bytes!\\n\");\n        ret = AVERROR(EINVAL);\n        goto fail;\n    }\n\n    \/* verify fixed key *\/\n    if (c->audible_fixed_key_size != 16) {\n        av_log(c->fc, AV_LOG_FATAL, \"[aax] audible_fixed_key value needs to be 16 bytes!\\n\");\n        ret = AVERROR(EINVAL);\n        goto fail;\n    }\n\n    \/* AAX (and AAX+) key derivation *\/\n    av_sha_init(sha, 160);\n    av_sha_update(sha, fixed_key, 16);\n    av_sha_update(sha, activation_bytes, 4);\n    av_sha_final(sha, intermediate_key);\n    av_sha_init(sha, 160);\n    av_sha_update(sha, fixed_key, 16);\n    av_sha_update(sha, intermediate_key, 20);\n    av_sha_update(sha, activation_bytes, 4);\n    av_sha_final(sha, intermediate_iv);\n    av_sha_init(sha, 160);\n    av_sha_update(sha, intermediate_key, 16);\n    av_sha_update(sha, intermediate_iv, 16);\n    av_sha_final(sha, calculated_checksum);\n    if (memcmp(calculated_checksum, file_checksum, 20)) { \/\/ critical error\n        av_log(c->fc, AV_LOG_ERROR, \"[aax] mismatch in checksums!\\n\");\n        ret = AVERROR_INVALIDDATA;\n        goto fail;\n    }\n    av_aes_init(c->aes_decrypt, intermediate_key, 128, 1);\n    av_aes_crypt(c->aes_decrypt, output, input, DRM_BLOB_SIZE >> 4, intermediate_iv, 1);\n    for (i = 0; i < 4; i++) {\n        \/\/ file data (in output) is stored in big-endian mode\n        if (activation_bytes[i] != output[3 - i]) { \/\/ critical error\n            av_log(c->fc, AV_LOG_ERROR, \"[aax] error in drm blob decryption!\\n\");\n            ret = AVERROR_INVALIDDATA;\n            goto fail;\n        }\n    }\n    memcpy(c->file_key, output + 8, 16);\n    memcpy(input, output + 26, 16);\n    av_sha_init(sha, 160);\n    av_sha_update(sha, input, 16);\n    av_sha_update(sha, c->file_key, 16);\n    av_sha_update(sha, fixed_key, 16);\n    av_sha_final(sha, c->file_iv);\n\nfail:\n    av_free(sha);\n\n    return ret;\n}","target":0,"code_token_length":1008,"total_token_length":1244,"max_tokens_setting":2048}
+{"idx":439153,"func":"static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  MemoryInfo\n    *pixel_info;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    x;\n\n  register unsigned char\n    *p;\n\n  size_t\n    height,\n    width;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read AVS X image.\n  *\/\n  width=ReadBlobMSBLong(image);\n  height=ReadBlobMSBLong(image);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if ((width == 0UL) || (height == 0UL))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  do\n  {\n    ssize_t\n      length;\n\n    \/*\n      Convert AVS raster image to pixel packets.\n    *\/\n    image->columns=width;\n    image->rows=height;\n    image->depth=8;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    pixel_info=AcquireVirtualMemory(image->columns,4*sizeof(*pixels));\n    if (pixel_info == (MemoryInfo *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    length=(size_t) 4*image->columns;\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      count=ReadBlob(image,length,pixels);\n      if (count != length)\n        {\n          pixel_info=RelinquishVirtualMemory(pixel_info);\n          ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n        }\n      p=pixels;\n      q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n      if (q == (PixelPacket *) NULL)\n        break;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        SetPixelAlpha(q,ScaleCharToQuantum(*p++));\n        SetPixelRed(q,ScaleCharToQuantum(*p++));\n        SetPixelGreen(q,ScaleCharToQuantum(*p++));\n        SetPixelBlue(q,ScaleCharToQuantum(*p++));\n        if (q->opacity != OpaqueOpacity)\n          image->matte=MagickTrue;\n        q++;\n      }\n      if (SyncAuthenticPixels(image,exception) == MagickFalse)\n        break;\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    width=ReadBlobMSBLong(image);\n    height=ReadBlobMSBLong(image);\n    if ((width != 0UL) && (height != 0UL))\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((width != 0UL) && (height != 0UL));\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":1104,"total_token_length":1340,"max_tokens_setting":2048}
+{"idx":505461,"func":"static int chacha20_poly1305_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                        const unsigned char *in, size_t len)\n{\n    EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);\n    size_t tail, tohash_len, buf_len, plen = actx->tls_payload_length;\n    unsigned char *buf, *tohash, *ctr, storage[sizeof(zero) + 32];\n\n    if (len != plen + POLY1305_BLOCK_SIZE)\n        return -1;\n\n    buf = storage + ((0 - (size_t)storage) & 15);   \/* align *\/\n    ctr = buf + CHACHA_BLK_SIZE;\n    tohash = buf + CHACHA_BLK_SIZE - POLY1305_BLOCK_SIZE;\n\n#   ifdef XOR128_HELPERS\n    if (plen <= 3 * CHACHA_BLK_SIZE) {\n        actx->key.counter[0] = 0;\n        buf_len = (plen + 2 * CHACHA_BLK_SIZE - 1) & (0 - CHACHA_BLK_SIZE);\n        ChaCha20_ctr32(buf, zero, buf_len, actx->key.key.d,\n                       actx->key.counter);\n        Poly1305_Init(POLY1305_ctx(actx), buf);\n        actx->key.partial_len = 0;\n        memcpy(tohash, actx->tls_aad, POLY1305_BLOCK_SIZE);\n        tohash_len = POLY1305_BLOCK_SIZE;\n        actx->len.aad = EVP_AEAD_TLS1_AAD_LEN;\n        actx->len.text = plen;\n\n        if (plen) {\n            if (ctx->encrypt)\n                ctr = xor128_encrypt_n_pad(out, in, ctr, plen);\n            else\n                ctr = xor128_decrypt_n_pad(out, in, ctr, plen);\n\n            in += plen;\n            out += plen;\n            tohash_len = (size_t)(ctr - tohash);\n        }\n    }\n#   else\n    if (plen <= CHACHA_BLK_SIZE) {\n        size_t i;\n\n        actx->key.counter[0] = 0;\n        ChaCha20_ctr32(buf, zero, (buf_len = 2 * CHACHA_BLK_SIZE),\n                       actx->key.key.d, actx->key.counter);\n        Poly1305_Init(POLY1305_ctx(actx), buf);\n        actx->key.partial_len = 0;\n        memcpy(tohash, actx->tls_aad, POLY1305_BLOCK_SIZE);\n        tohash_len = POLY1305_BLOCK_SIZE;\n        actx->len.aad = EVP_AEAD_TLS1_AAD_LEN;\n        actx->len.text = plen;\n\n        if (ctx->encrypt) {\n            for (i = 0; i < plen; i++) {\n                out[i] = ctr[i] ^= in[i];\n            }\n        } else {\n            for (i = 0; i < plen; i++) {\n                unsigned char c = in[i];\n                out[i] = ctr[i] ^ c;\n                ctr[i] = c;\n            }\n        }\n\n        in += i;\n        out += i;\n\n        tail = (0 - i) & (POLY1305_BLOCK_SIZE - 1);\n        memset(ctr + i, 0, tail);\n        ctr += i + tail;\n        tohash_len += i + tail;\n    }\n#   endif\n    else {\n        actx->key.counter[0] = 0;\n        ChaCha20_ctr32(buf, zero, (buf_len = CHACHA_BLK_SIZE),\n                       actx->key.key.d, actx->key.counter);\n        Poly1305_Init(POLY1305_ctx(actx), buf);\n        actx->key.counter[0] = 1;\n        actx->key.partial_len = 0;\n        Poly1305_Update(POLY1305_ctx(actx), actx->tls_aad, POLY1305_BLOCK_SIZE);\n        tohash = ctr;\n        tohash_len = 0;\n        actx->len.aad = EVP_AEAD_TLS1_AAD_LEN;\n        actx->len.text = plen;\n\n        if (ctx->encrypt) {\n            ChaCha20_ctr32(out, in, plen, actx->key.key.d, actx->key.counter);\n            Poly1305_Update(POLY1305_ctx(actx), out, plen);\n        } else {\n            Poly1305_Update(POLY1305_ctx(actx), in, plen);\n            ChaCha20_ctr32(out, in, plen, actx->key.key.d, actx->key.counter);\n        }\n\n        in += plen;\n        out += plen;\n        tail = (0 - plen) & (POLY1305_BLOCK_SIZE - 1);\n        Poly1305_Update(POLY1305_ctx(actx), zero, tail);\n    }\n\n    {\n        const union {\n            long one;\n            char little;\n        } is_endian = { 1 };\n\n        if (is_endian.little) {\n            memcpy(ctr, (unsigned char *)&actx->len, POLY1305_BLOCK_SIZE);\n        } else {\n            ctr[0]  = (unsigned char)(actx->len.aad);\n            ctr[1]  = (unsigned char)(actx->len.aad>>8);\n            ctr[2]  = (unsigned char)(actx->len.aad>>16);\n            ctr[3]  = (unsigned char)(actx->len.aad>>24);\n            ctr[4]  = (unsigned char)(actx->len.aad>>32);\n            ctr[5]  = (unsigned char)(actx->len.aad>>40);\n            ctr[6]  = (unsigned char)(actx->len.aad>>48);\n            ctr[7]  = (unsigned char)(actx->len.aad>>56);\n\n            ctr[8]  = (unsigned char)(actx->len.text);\n            ctr[9]  = (unsigned char)(actx->len.text>>8);\n            ctr[10] = (unsigned char)(actx->len.text>>16);\n            ctr[11] = (unsigned char)(actx->len.text>>24);\n            ctr[12] = (unsigned char)(actx->len.text>>32);\n            ctr[13] = (unsigned char)(actx->len.text>>40);\n            ctr[14] = (unsigned char)(actx->len.text>>48);\n            ctr[15] = (unsigned char)(actx->len.text>>56);\n        }\n        tohash_len += POLY1305_BLOCK_SIZE;\n    }\n\n    Poly1305_Update(POLY1305_ctx(actx), tohash, tohash_len);\n    OPENSSL_cleanse(buf, buf_len);\n    Poly1305_Final(POLY1305_ctx(actx), ctx->encrypt ? actx->tag\n                                                    : tohash);\n\n    actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;\n\n    if (ctx->encrypt) {\n        memcpy(out, actx->tag, POLY1305_BLOCK_SIZE);\n    } else {\n        if (CRYPTO_memcmp(tohash, in, POLY1305_BLOCK_SIZE)) {\n            memset(out - (len - POLY1305_BLOCK_SIZE), 0,\n                   len - POLY1305_BLOCK_SIZE);\n            return -1;\n        }\n    }\n\n    return len;\n}","target":0,"code_token_length":1693,"total_token_length":1929,"max_tokens_setting":2048}
+{"idx":238636,"func":"static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn)\n{\n\tconst struct btf_type *t, *func, *func_proto, *ptr_type;\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tconst char *func_name, *ptr_type_name;\n\tu32 i, nargs, func_id, ptr_type_id;\n\tstruct module *btf_mod = NULL;\n\tconst struct btf_param *args;\n\tstruct btf *desc_btf;\n\tint err;\n\n\t\/* skip for now, but return error when we find this in fixup_kfunc_call *\/\n\tif (!insn->imm)\n\t\treturn 0;\n\n\tdesc_btf = find_kfunc_desc_btf(env, insn->imm, insn->off, &btf_mod);\n\tif (IS_ERR(desc_btf))\n\t\treturn PTR_ERR(desc_btf);\n\n\tfunc_id = insn->imm;\n\tfunc = btf_type_by_id(desc_btf, func_id);\n\tfunc_name = btf_name_by_offset(desc_btf, func->name_off);\n\tfunc_proto = btf_type_by_id(desc_btf, func->type);\n\n\tif (!env->ops->check_kfunc_call ||\n\t    !env->ops->check_kfunc_call(func_id, btf_mod)) {\n\t\tverbose(env, \"calling kernel function %s is not allowed\\n\",\n\t\t\tfunc_name);\n\t\treturn -EACCES;\n\t}\n\n\t\/* Check the arguments *\/\n\terr = btf_check_kfunc_arg_match(env, desc_btf, func_id, regs);\n\tif (err)\n\t\treturn err;\n\n\tfor (i = 0; i < CALLER_SAVED_REGS; i++)\n\t\tmark_reg_not_init(env, regs, caller_saved[i]);\n\n\t\/* Check return type *\/\n\tt = btf_type_skip_modifiers(desc_btf, func_proto->type, NULL);\n\tif (btf_type_is_scalar(t)) {\n\t\tmark_reg_unknown(env, regs, BPF_REG_0);\n\t\tmark_btf_func_reg_size(env, BPF_REG_0, t->size);\n\t} else if (btf_type_is_ptr(t)) {\n\t\tptr_type = btf_type_skip_modifiers(desc_btf, t->type,\n\t\t\t\t\t\t   &ptr_type_id);\n\t\tif (!btf_type_is_struct(ptr_type)) {\n\t\t\tptr_type_name = btf_name_by_offset(desc_btf,\n\t\t\t\t\t\t\t   ptr_type->name_off);\n\t\t\tverbose(env, \"kernel function %s returns pointer type %s %s is not supported\\n\",\n\t\t\t\tfunc_name, btf_type_str(ptr_type),\n\t\t\t\tptr_type_name);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tmark_reg_known_zero(env, regs, BPF_REG_0);\n\t\tregs[BPF_REG_0].btf = desc_btf;\n\t\tregs[BPF_REG_0].type = PTR_TO_BTF_ID;\n\t\tregs[BPF_REG_0].btf_id = ptr_type_id;\n\t\tmark_btf_func_reg_size(env, BPF_REG_0, sizeof(void *));\n\t} \/* else { add_kfunc_call() ensures it is btf_type_is_void(t) } *\/\n\n\tnargs = btf_type_vlen(func_proto);\n\targs = (const struct btf_param *)(func_proto + 1);\n\tfor (i = 0; i < nargs; i++) {\n\t\tu32 regno = i + 1;\n\n\t\tt = btf_type_skip_modifiers(desc_btf, args[i].type, NULL);\n\t\tif (btf_type_is_ptr(t))\n\t\t\tmark_btf_func_reg_size(env, regno, sizeof(void *));\n\t\telse\n\t\t\t\/* scalar. ensured by btf_check_kfunc_arg_match() *\/\n\t\t\tmark_btf_func_reg_size(env, regno, t->size);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":790,"total_token_length":1026,"max_tokens_setting":2048}
+{"idx":195028,"func":"  void DecodePngV2(OpKernelContext* context, StringPiece input) {\n    int channel_bits = (data_type_ == DataType::DT_UINT8) ? 8 : 16;\n    png::DecodeContext decode;\n    OP_REQUIRES(\n        context, png::CommonInitDecode(input, channels_, channel_bits, &decode),\n        errors::InvalidArgument(\"Invalid PNG. Failed to initialize decoder.\"));\n\n    \/\/ Verify that width and height are not too large:\n    \/\/ - verify width and height don't overflow int.\n    \/\/ - width can later be multiplied by channels_ and sizeof(uint16), so\n    \/\/   verify single dimension is not too large.\n    \/\/ - verify when width and height are multiplied together, there are a few\n    \/\/   bits to spare as well.\n    const int width = static_cast<int>(decode.width);\n    const int height = static_cast<int>(decode.height);\n    const int64_t total_size =\n        static_cast<int64_t>(width) * static_cast<int64_t>(height);\n    if (width != static_cast<int64_t>(decode.width) || width <= 0 ||\n        width >= (1LL << 27) || height != static_cast<int64_t>(decode.height) ||\n        height <= 0 || height >= (1LL << 27) || total_size >= (1LL << 29)) {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\"PNG size too large for int: \",\n                                          decode.width, \" by \", decode.height));\n    }\n\n    Tensor* output = nullptr;\n    \/\/ By the existing API, we support decoding PNG with `DecodeGif` op.\n    \/\/ We need to make sure to return 4-D shapes when using `DecodeGif`.\n    if (op_type_ == \"DecodeGif\") {\n      OP_REQUIRES_OK(\n          context,\n          context->allocate_output(\n              0, TensorShape({1, height, width, decode.channels}), &output));\n    } else {\n      OP_REQUIRES_OK(\n          context,\n          context->allocate_output(\n              0, TensorShape({height, width, decode.channels}), &output));\n    }\n\n    if (op_type_ == \"DecodeBmp\") {\n      \/\/ TODO(b\/171060723): Only DecodeBmp as op_type_ is not acceptable here\n      \/\/ because currently `decode_(jpeg|png|gif)` ops can decode any one of\n      \/\/ jpeg, png or gif but not bmp. Similarly, `decode_bmp` cannot decode\n      \/\/ anything but bmp formats. This behavior needs to be revisited. For more\n      \/\/ details, please refer to the bug.\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"Trying to decode PNG format using DecodeBmp op. Use \"\n                      \"`decode_png` or `decode_image` instead.\"));\n    } else if (op_type_ == \"DecodeAndCropJpeg\") {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"DecodeAndCropJpeg operation can run on JPEG only, but \"\n                      \"detected PNG.\"));\n    }\n\n    if (data_type_ == DataType::DT_UINT8) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint8>().data()),\n              decode.channels * width * sizeof(uint8), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_UINT16) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint16>().data()),\n              decode.channels * width * sizeof(uint16), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_FLOAT) {\n      \/\/ `png::CommonFinishDecode` does not support `float`. First allocate\n      \/\/ uint16 buffer for the image and decode in uint16 (lossless). Wrap the\n      \/\/ buffer in `unique_ptr` so that we don't forget to delete the buffer.\n      std::unique_ptr<uint16[]> buffer(\n          new uint16[height * width * decode.channels]);\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(reinterpret_cast<png_bytep>(buffer.get()),\n                                  decode.channels * width * sizeof(uint16),\n                                  &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n\n      \/\/ Convert uint16 image data to desired data type.\n      \/\/ Use eigen threadpooling to speed up the copy operation.\n      const auto& device = context->eigen_device<Eigen::ThreadPoolDevice>();\n      TTypes<uint16, 3>::UnalignedConstTensor buf(buffer.get(), height, width,\n                                                  decode.channels);\n      float scale = 1. \/ std::numeric_limits<uint16>::max();\n      \/\/ Fill output tensor with desired dtype.\n      output->tensor<float, 3>().device(device) = buf.cast<float>() * scale;\n    }\n  }","target":1,"code_token_length":1090,"total_token_length":1326,"max_tokens_setting":2048}
+{"idx":230615,"func":"void derive_temporal_luma_vector_prediction(base_context* ctx,\n                                            de265_image* img,\n                                            const slice_segment_header* shdr,\n                                            int xP,int yP,\n                                            int nPbW,int nPbH,\n                                            int refIdxL,\n                                            int X, \/\/ which MV (L0\/L1) to get\n                                            MotionVector* out_mvLXCol,\n                                            uint8_t*      out_availableFlagLXCol)\n{\n  \/\/ --- no temporal MVP -> exit ---\n\n  if (shdr->slice_temporal_mvp_enabled_flag == 0) {\n    out_mvLXCol->x = 0;\n    out_mvLXCol->y = 0;\n    *out_availableFlagLXCol = 0;\n    return;\n  }\n\n\n  \/\/ --- find collocated reference image ---\n\n  int Log2CtbSizeY = img->get_sps().Log2CtbSizeY;\n\n  int colPic; \/\/ TODO: this is the same for the whole slice. We can precompute it.\n\n  if (shdr->slice_type == SLICE_TYPE_B &&\n      shdr->collocated_from_l0_flag == 0)\n    {\n      logtrace(LogMotion,\"collocated L1 ref_idx=%d\\n\",shdr->collocated_ref_idx);\n\n      colPic = shdr->RefPicList[1][ shdr->collocated_ref_idx ];\n    }\n  else\n    {\n      logtrace(LogMotion,\"collocated L0 ref_idx=%d\\n\",shdr->collocated_ref_idx);\n\n      colPic = shdr->RefPicList[0][ shdr->collocated_ref_idx ];\n    }\n\n\n  \/\/ check whether collocated reference picture exists\n\n  if (!ctx->has_image(colPic)) {\n    out_mvLXCol->x = 0;\n    out_mvLXCol->y = 0;\n    *out_availableFlagLXCol = 0;\n\n    ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);\n    return;\n  }\n\n\n  \/\/ --- get collocated MV either at bottom-right corner or from center of PB ---\n\n  int xColPb,yColPb;\n  int yColBr = yP + nPbH; \/\/ bottom right collocated motion vector position\n  int xColBr = xP + nPbW;\n\n  \/* If neighboring pixel at bottom-right corner is in the same CTB-row and inside the image,\n     use this (reduced down to 16 pixels resolution) as collocated MV position.\n\n     Note: see 2014, Sze, Sect. 5.2.1.2 why candidate C0 is excluded when on another CTB-row.\n     This is to reduce the memory bandwidth requirements.\n   *\/\n  if ((yP>>Log2CtbSizeY) == (yColBr>>Log2CtbSizeY) &&\n      xColBr < img->get_sps().pic_width_in_luma_samples &&\n      yColBr < img->get_sps().pic_height_in_luma_samples)\n    {\n      xColPb = xColBr & ~0x0F; \/\/ reduce resolution of collocated motion-vectors to 16 pixels grid\n      yColPb = yColBr & ~0x0F;\n\n      derive_collocated_motion_vectors(ctx,img,shdr, xP,yP, colPic, xColPb,yColPb, refIdxL, X,\n                                       out_mvLXCol, out_availableFlagLXCol);\n    }\n  else\n    {\n      out_mvLXCol->x = 0;\n      out_mvLXCol->y = 0;\n      *out_availableFlagLXCol = 0;\n    }\n\n\n  if (*out_availableFlagLXCol==0) {\n\n    int xColCtr = xP+(nPbW>>1);\n    int yColCtr = yP+(nPbH>>1);\n\n    xColPb = xColCtr & ~0x0F; \/\/ reduce resolution of collocated motion-vectors to 16 pixels grid\n    yColPb = yColCtr & ~0x0F;\n\n    derive_collocated_motion_vectors(ctx,img,shdr, xP,yP, colPic, xColPb,yColPb, refIdxL, X,\n                                     out_mvLXCol, out_availableFlagLXCol);\n  }\n}","target":0,"code_token_length":939,"total_token_length":1175,"max_tokens_setting":2048}
+{"idx":227036,"func":"IRC_PROTOCOL_CALLBACK(728)\n{\n    struct t_irc_channel *ptr_channel;\n    struct t_gui_buffer *ptr_buffer;\n    struct t_irc_modelist *ptr_modelist;\n    time_t datetime;\n    const char *nick_address;\n    char str_number[64];\n\n    IRC_PROTOCOL_MIN_ARGS(6);\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n    ptr_buffer = (ptr_channel && ptr_channel->nicks) ?\n        ptr_channel->buffer : server->buffer;\n    ptr_modelist = irc_modelist_search (ptr_channel, argv[4][0]);\n\n    if (ptr_modelist)\n    {\n        \/* start receiving new list *\/\n        if (ptr_modelist->state != IRC_MODELIST_STATE_RECEIVING)\n        {\n            irc_modelist_item_free_all (ptr_modelist);\n            ptr_modelist->state = IRC_MODELIST_STATE_RECEIVING;\n        }\n\n        snprintf (str_number, sizeof (str_number),\n                  \"%s[%s%d%s] \",\n                  IRC_COLOR_CHAT_DELIMITERS,\n                  IRC_COLOR_RESET,\n                  ((ptr_modelist->last_item) ? ptr_modelist->last_item->number + 1 : 0) + 1,\n                  IRC_COLOR_CHAT_DELIMITERS);\n    }\n    else\n        str_number[0] = '\\0';\n\n    if (argc >= 7)\n    {\n        nick_address = irc_protocol_nick_address (\n            server, 1, NULL, irc_message_get_nick_from_host (argv[6]),\n            irc_message_get_address_from_host (argv[6]));\n        if (argc >= 8)\n        {\n            datetime = (time_t)(atol ((argv[7][0] == ':') ? argv[7] + 1 : argv[7]));\n            if (ptr_modelist)\n                irc_modelist_item_new (ptr_modelist, argv[5], argv[6], datetime);\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, \"quietlist\", ptr_buffer),\n                date,\n                irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n                \/* TRANSLATORS: \"%s\" after \"on\" is a date *\/\n                _(\"%s%s[%s%s%s] %s%s%s%s quieted by %s on %s\"),\n                weechat_prefix (\"network\"),\n                IRC_COLOR_CHAT_DELIMITERS,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[3],\n                IRC_COLOR_CHAT_DELIMITERS,\n                str_number,\n                IRC_COLOR_CHAT_HOST,\n                argv[5],\n                IRC_COLOR_RESET,\n                (nick_address[0]) ? nick_address : \"?\",\n                weechat_util_get_time_string (&datetime));\n        }\n        else\n        {\n            if (ptr_modelist)\n                irc_modelist_item_new (ptr_modelist, argv[5], argv[6], 0);\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, \"quietlist\", ptr_buffer),\n                date,\n                irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n                _(\"%s%s[%s%s%s] %s%s%s%s quieted by %s\"),\n                weechat_prefix (\"network\"),\n                IRC_COLOR_CHAT_DELIMITERS,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[3],\n                IRC_COLOR_CHAT_DELIMITERS,\n                str_number,\n                IRC_COLOR_CHAT_HOST,\n                argv[5],\n                IRC_COLOR_RESET,\n                (nick_address[0]) ? nick_address : \"?\");\n        }\n    }\n    else\n    {\n        if (ptr_modelist)\n            irc_modelist_item_new (ptr_modelist, argv[5], NULL, 0);\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, NULL, command, \"quietlist\", ptr_buffer),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            _(\"%s%s[%s%s%s] %s%s%s%s quieted\"),\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_CHANNEL,\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            str_number,\n            IRC_COLOR_CHAT_HOST,\n            argv[5],\n            IRC_COLOR_RESET);\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":902,"total_token_length":1138,"max_tokens_setting":2048}
+{"idx":448559,"func":"static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)\n{\n\tstruct peer *peer;\n\n\t\/*\n\t * Upon receipt of an OPEN message, the local system must examine\n\t * all of its connections that are in the OpenConfirm state.  A BGP\n\t * speaker may also examine connections in an OpenSent state if it\n\t * knows the BGP Identifier of the peer by means outside of the\n\t * protocol.  If among these connections there is a connection to a\n\t * remote BGP speaker whose BGP Identifier equals the one in the\n\t * OPEN message, then the local system performs the following\n\t * collision resolution procedure:\n\t *\/\n\tpeer = new->doppelganger;\n\tif (peer == NULL)\n\t\treturn 0;\n\n\t\/*\n\t * Do not accept the new connection in Established or Clearing\n\t * states. Note that a peer GR is handled by closing the existing\n\t * connection upon receipt of new one.\n\t *\/\n\tif (peer_established(peer) || peer->status == Clearing) {\n\t\tbgp_notify_send(new, BGP_NOTIFY_CEASE,\n\t\t\t\tBGP_NOTIFY_CEASE_COLLISION_RESOLUTION);\n\t\treturn -1;\n\t}\n\n\tif ((peer->status != OpenConfirm) && (peer->status != OpenSent))\n\t\treturn 0;\n\n\t\/*\n\t * 1. The BGP Identifier of the local system is\n\t * compared to the BGP Identifier of the remote\n\t * system (as specified in the OPEN message).\n\t *\n\t * If the BGP Identifiers of the peers\n\t * involved in the connection collision\n\t * are identical, then the connection\n\t * initiated by the BGP speaker with the\n\t * larger AS number is preserved.\n\t *\/\n\tif (ntohl(peer->local_id.s_addr) < ntohl(remote_id.s_addr)\n\t    || (ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr)\n\t\t&& peer->local_as < peer->as))\n\t\tif (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER)) {\n\t\t\t\/*\n\t\t\t * 2. If the value of the local BGP\n\t\t\t * Identifier is less than the remote one,\n\t\t\t * the local system closes BGP connection\n\t\t\t * that already exists (the one that is\n\t\t\t * already in the OpenConfirm state),\n\t\t\t * and accepts BGP connection initiated by\n\t\t\t * the remote system.\n\t\t\t *\/\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_CEASE_COLLISION_RESOLUTION);\n\t\t\treturn 1;\n\t\t} else {\n\t\t\tbgp_notify_send(new, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_CEASE_COLLISION_RESOLUTION);\n\t\t\treturn -1;\n\t\t}\n\telse {\n\t\tif (ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr)\n\t\t    && peer->local_as == peer->as)\n\t\t\tflog_err(EC_BGP_ROUTER_ID_SAME,\n\t\t\t\t \"Peer's router-id %pI4 is the same as ours\",\n\t\t\t\t &remote_id);\n\n\t\t\/*\n\t\t * 3. Otherwise, the local system closes newly\n\t\t * created BGP connection (the one associated with the\n\t\t * newly received OPEN message), and continues to use\n\t\t * the existing one (the one that is already in the\n\t\t * OpenConfirm state).\n\t\t *\/\n\t\tif (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER)) {\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_CEASE_COLLISION_RESOLUTION);\n\t\t\treturn 1;\n\t\t} else {\n\t\t\tbgp_notify_send(new, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_CEASE_COLLISION_RESOLUTION);\n\t\t\treturn -1;\n\t\t}\n\t}\n}","target":0,"code_token_length":790,"total_token_length":1026,"max_tokens_setting":2048}
+{"idx":376682,"func":"void ZRLE_DECODE (const Rect& r, rdr::InStream* is,\n                  rdr::ZlibInStream* zis,\n                  const PixelFormat& pf, ModifiablePixelBuffer* pb)\n{\n  int length = is->readU32();\n  zis->setUnderlying(is, length);\n  Rect t;\n  PIXEL_T buf[64 * 64];\n\n  for (t.tl.y = r.tl.y; t.tl.y < r.br.y; t.tl.y += 64) {\n\n    t.br.y = __rfbmin(r.br.y, t.tl.y + 64);\n\n    for (t.tl.x = r.tl.x; t.tl.x < r.br.x; t.tl.x += 64) {\n\n      t.br.x = __rfbmin(r.br.x, t.tl.x + 64);\n\n      int mode = zis->readU8();\n      bool rle = mode & 128;\n      int palSize = mode & 127;\n      PIXEL_T palette[128];\n\n      for (int i = 0; i < palSize; i++) {\n        palette[i] = READ_PIXEL(zis);\n      }\n\n      if (palSize == 1) {\n        PIXEL_T pix = palette[0];\n        pb->fillRect(pf, t, &pix);\n        continue;\n      }\n\n      if (!rle) {\n        if (palSize == 0) {\n\n          \/\/ raw\n\n#ifdef CPIXEL\n          for (PIXEL_T* ptr = buf; ptr < buf+t.area(); ptr++) {\n            *ptr = READ_PIXEL(zis);\n          }\n#else\n          zis->readBytes(buf, t.area() * (BPP \/ 8));\n#endif\n\n        } else {\n\n          \/\/ packed pixels\n          int bppp = ((palSize > 16) ? 8 :\n                      ((palSize > 4) ? 4 : ((palSize > 2) ? 2 : 1)));\n\n          PIXEL_T* ptr = buf;\n\n          for (int i = 0; i < t.height(); i++) {\n            PIXEL_T* eol = ptr + t.width();\n            rdr::U8 byte = 0;\n            rdr::U8 nbits = 0;\n\n            while (ptr < eol) {\n              if (nbits == 0) {\n                byte = zis->readU8();\n                nbits = 8;\n              }\n              nbits -= bppp;\n              rdr::U8 index = (byte >> nbits) & ((1 << bppp) - 1) & 127;\n              *ptr++ = palette[index];\n            }\n          }\n        }\n\n      } else {\n\n        if (palSize == 0) {\n\n          \/\/ plain RLE\n\n          PIXEL_T* ptr = buf;\n          PIXEL_T* end = ptr + t.area();\n          while (ptr < end) {\n            PIXEL_T pix = READ_PIXEL(zis);\n            int len = 1;\n            int b;\n            do {\n              b = zis->readU8();\n              len += b;\n            } while (b == 255);\n\n            if (end - ptr < len) {\n              throw Exception (\"ZRLE decode error\");\n            }\n\n            while (len-- > 0) *ptr++ = pix;\n\n          }\n        } else {\n\n          \/\/ palette RLE\n\n          PIXEL_T* ptr = buf;\n          PIXEL_T* end = ptr + t.area();\n          while (ptr < end) {\n            int index = zis->readU8();\n            int len = 1;\n            if (index & 128) {\n              int b;\n              do {\n                b = zis->readU8();\n                len += b;\n              } while (b == 255);\n\n              if (end - ptr < len) {\n                throw Exception (\"ZRLE decode error\");\n              }\n            }\n\n            index &= 127;\n\n            PIXEL_T pix = palette[index];\n\n            while (len-- > 0) *ptr++ = pix;\n          }\n        }\n      }\n\n      pb->imageRect(pf, t, buf);\n    }\n  }\n\n  zis->flushUnderlying();\n  zis->setUnderlying(NULL, 0);\n}","target":0,"code_token_length":909,"total_token_length":1145,"max_tokens_setting":2048}
+{"idx":462409,"func":"processDataRcvd(ptcpsess_t *const __restrict__ pThis,\n\tchar **buff,\n\tconst int buffLen,\n\tstruct syslogTime *stTime,\n\tconst time_t ttGenTime,\n\tmulti_submit_t *pMultiSub,\n\tunsigned *const __restrict__ pnMsgs)\n{\n\tDEFiRet;\n\tchar c = **buff;\n\tint octatesToCopy, octatesToDiscard;\n\n\tif(pThis->inputState == eAtStrtFram) {\n\t\tif(pThis->bSuppOctetFram && isdigit((int) c)) {\n\t\t\tpThis->inputState = eInOctetCnt;\n\t\t\tpThis->iOctetsRemain = 0;\n\t\t\tpThis->eFraming = TCP_FRAMING_OCTET_COUNTING;\n\t\t} else if(pThis->bSPFramingFix && c == ' ') {\n\t\t\t\/* Cisco very occasionally sends a SP after a LF, which\n\t\t\t * thrashes framing if not taken special care of. Here,\n\t\t\t * we permit space *in front of the next frame* and\n\t\t\t * ignore it.\n\t\t\t *\/\n\t\t\t FINALIZE;\n\t\t} else {\n\t\t\tpThis->inputState = eInMsg;\n\t\t\tpThis->eFraming = TCP_FRAMING_OCTET_STUFFING;\n\t\t}\n\t}\n\n\tif(pThis->inputState == eInOctetCnt) {\n\t\tif(isdigit(c)) {\n\t\t\tif(pThis->iOctetsRemain <= 200000000) {\n\t\t\t\tpThis->iOctetsRemain = pThis->iOctetsRemain * 10 + c - '0';\n\t\t\t} else {\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"Framing Error in received TCP message: \"\n\t\t\t\t\t\t\"frame too large (at least %d%c), change to octet stuffing\",\n\t\t\t\t\t\tpThis->iOctetsRemain, c);\n\t\t\t\tpThis->eFraming = TCP_FRAMING_OCTET_STUFFING;\n\t\t\t\tpThis->inputState = eInMsg;\n\t\t\t}\n\t\t\t*(pThis->pMsg + pThis->iMsg++) = c;\n\t\t} else { \/* done with the octet count, so this must be the SP terminator *\/\n\t\t\tDBGPRINTF(\"TCP Message with octet-counter, size %d.\\n\", pThis->iOctetsRemain);\n\t\t\tif(c != ' ') {\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"Framing Error in received TCP message: \"\n\t\t\t\t\t    \"delimiter is not SP but has ASCII value %d.\", c);\n\t\t\t}\n\t\t\tif(pThis->iOctetsRemain < 1) {\n\t\t\t\t\/* TODO: handle the case where the octet count is 0! *\/\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"Framing Error in received TCP message: \"\n\t\t\t\t\t    \"invalid octet count %d.\", pThis->iOctetsRemain);\n\t\t\t\tpThis->eFraming = TCP_FRAMING_OCTET_STUFFING;\n\t\t\t} else if(pThis->iOctetsRemain > iMaxLine) {\n\t\t\t\t\/* while we can not do anything against it, we can at least log an indication\n\t\t\t\t * that something went wrong) -- rgerhards, 2008-03-14\n\t\t\t\t *\/\n\t\t\t\tDBGPRINTF(\"truncating message with %d octets - max msg size is %d\\n\",\n\t\t\t\t\t  pThis->iOctetsRemain, iMaxLine);\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"received oversize message: size is %d bytes, \"\n\t\t\t\t\t        \"max msg size is %d, truncating...\", pThis->iOctetsRemain, iMaxLine);\n\t\t\t}\n\t\t\tpThis->inputState = eInMsg;\n\t\t\tpThis->iMsg = 0;\n\t\t}\n\t} else {\n\t\tassert(pThis->inputState == eInMsg);\n\n\t\tif (pThis->eFraming == TCP_FRAMING_OCTET_STUFFING) {\n\t\t\tif(pThis->iMsg >= iMaxLine) {\n\t\t\t\t\/* emergency, we now need to flush, no matter if we are at end of message or not... *\/\n\t\t\t\tint i = 1;\n\t\t\t\tchar currBuffChar;\n\t\t\t\twhile(i < buffLen && ((currBuffChar = (*buff)[i]) != '\\n'\n\t\t\t\t\t&& (pThis->pLstn->pSrv->iAddtlFrameDelim == TCPSRV_NO_ADDTL_DELIMITER\n\t\t\t\t\t\t|| currBuffChar != pThis->pLstn->pSrv->iAddtlFrameDelim))) {\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tLogError(0, NO_ERRCODE, \"error: message received is at least %d byte larger than max msg\"\n\t\t\t\t\t\" size; message will be split starting at: \\\"%.*s\\\"\\n\", i, (i < 32) ? i : 32, *buff);\n\t\t\t\tdoSubmitMsg(pThis, stTime, ttGenTime, pMultiSub);\n\t\t\t\t++(*pnMsgs);\n\t\t\t\t\/* we might think if it is better to ignore the rest of the\n\t\t\t\t * message than to treat it as a new one. Maybe this is a good\n\t\t\t\t * candidate for a configuration parameter...\n\t\t\t\t * rgerhards, 2006-12-04\n\t\t\t\t *\/\n\t\t\t}\n\n\t\t\tif ((c == '\\n')\n\t\t\t\t   || ((pThis->pLstn->pSrv->iAddtlFrameDelim != TCPSRV_NO_ADDTL_DELIMITER)\n\t\t\t\t\t   && (c == pThis->pLstn->pSrv->iAddtlFrameDelim))\n\t\t\t\t   ) { \/* record delimiter? *\/\n\t\t\t\tdoSubmitMsg(pThis, stTime, ttGenTime, pMultiSub);\n\t\t\t\t++(*pnMsgs);\n\t\t\t\tpThis->inputState = eAtStrtFram;\n\t\t\t} else {\n\t\t\t\t\/* IMPORTANT: here we copy the actual frame content to the message - for BOTH framing modes!\n\t\t\t\t * If we have a message that is larger than the max msg size, we truncate it. This is the best\n\t\t\t\t * we can do in light of what the engine supports. -- rgerhards, 2008-03-14\n\t\t\t\t *\/\n\t\t\t\tif(pThis->iMsg < iMaxLine) {\n\t\t\t\t\t*(pThis->pMsg + pThis->iMsg++) = c;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tassert(pThis->eFraming == TCP_FRAMING_OCTET_COUNTING);\n\t\t\toctatesToCopy = pThis->iOctetsRemain;\n\t\t\toctatesToDiscard = 0;\n\t\t\tif (buffLen < octatesToCopy) {\n\t\t\t\toctatesToCopy = buffLen;\n\t\t\t}\n\t\t\tif (octatesToCopy + pThis->iMsg > iMaxLine) {\n\t\t\t\toctatesToDiscard = octatesToCopy - (iMaxLine - pThis->iMsg);\n\t\t\t\toctatesToCopy = iMaxLine - pThis->iMsg;\n\t\t\t}\n\n\t\t\tmemcpy(pThis->pMsg + pThis->iMsg, *buff, octatesToCopy);\n\t\t\tpThis->iMsg += octatesToCopy;\n\t\t\tpThis->iOctetsRemain -= (octatesToCopy + octatesToDiscard);\n\t\t\t*buff += (octatesToCopy + octatesToDiscard - 1);\n\t\t\tif (pThis->iOctetsRemain == 0) {\n\t\t\t\t\/* we have end of frame! *\/\n\t\t\t\tdoSubmitMsg(pThis, stTime, ttGenTime, pMultiSub);\n\t\t\t\t++(*pnMsgs);\n\t\t\t\tpThis->inputState = eAtStrtFram;\n\t\t\t}\n\t\t}\n\n\t}\n\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":1688,"total_token_length":1924,"max_tokens_setting":2048}
+{"idx":328827,"func":"R_API RBinJavaElementValue *r_bin_java_element_value_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0;\n\tut64 offset = 0;\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaElementValue *element_value = R_NEW0 (RBinJavaElementValue);\n\tif (!element_value) {\n\t\treturn NULL;\n\t}\n\tRBinJavaElementValuePair *evps = NULL;\n\telement_value->metas = R_NEW0 (RBinJavaMetaInfo);\n\tif (!element_value->metas) {\n\t\tR_FREE (element_value);\n\t\treturn NULL;\n\t}\n\telement_value->file_offset = buf_offset;\n\telement_value->tag = buffer[offset];\n\telement_value->size += 1;\n\toffset += 1;\n\telement_value->metas->type_info = (void *) r_bin_java_get_ev_meta_from_tag (element_value->tag);\n\tswitch (element_value->tag) {\n\tcase R_BIN_JAVA_EV_TAG_BYTE:\n\tcase R_BIN_JAVA_EV_TAG_CHAR:\n\tcase R_BIN_JAVA_EV_TAG_DOUBLE:\n\tcase R_BIN_JAVA_EV_TAG_FLOAT:\n\tcase R_BIN_JAVA_EV_TAG_INT:\n\tcase R_BIN_JAVA_EV_TAG_LONG:\n\tcase R_BIN_JAVA_EV_TAG_SHORT:\n\tcase R_BIN_JAVA_EV_TAG_BOOLEAN:\n\tcase R_BIN_JAVA_EV_TAG_STRING:\n\t\t\/\/ look up value in bin->cp_list\n\t\t\/\/ (ut16) read and set const_value.const_value_idx\n\t\telement_value->value.const_value.const_value_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\telement_value->size += 2;\n\t\t\/\/ look-up, deep copy, and set const_value.const_value_cp_obj\n\t\telement_value->value.const_value.const_value_cp_obj = r_bin_java_clone_cp_idx (R_BIN_JAVA_GLOBAL_BIN, element_value->value.const_value.const_value_idx);\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ENUM:\n\t\t\/\/ (ut16) read and set enum_const_value.type_name_idx\n\t\telement_value->value.enum_const_value.type_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\telement_value->size += 2;\n\t\toffset += 2;\n\t\t\/\/ (ut16) read and set enum_const_value.const_name_idx\n\t\telement_value->value.enum_const_value.const_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\telement_value->size += 2;\n\t\toffset += 2;\n\t\t\/\/ look up type_name_index in bin->cp_list\n\t\t\/\/ look-up, deep copy, and set enum_const_value.const_name_cp_obj\n\t\telement_value->value.enum_const_value.const_name_cp_obj = r_bin_java_clone_cp_idx (R_BIN_JAVA_GLOBAL_BIN, element_value->value.enum_const_value.const_name_idx);\n\t\t\/\/ look-up, deep copy, and set enum_const_value.type_name_cp_obj\n\t\telement_value->value.enum_const_value.type_name_cp_obj = r_bin_java_clone_cp_idx (R_BIN_JAVA_GLOBAL_BIN, element_value->value.enum_const_value.type_name_idx);\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_CLASS:\n\t\t\/\/ (ut16) read and set class_value.class_info_idx\n\t\telement_value->value.class_value.class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\telement_value->size += 2;\n\t\toffset += 2;\n\t\t\/\/ look up type_name_index in bin->cp_list\n\t\t\/\/ look-up, deep copy, and set class_value.class_info_cp_obj\n\t\telement_value->value.class_value.class_info_cp_obj = r_bin_java_clone_cp_idx (R_BIN_JAVA_GLOBAL_BIN, element_value->value.class_value.class_info_idx);\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ARRAY:\n\t\t\/\/ (ut16) read and set array_value.num_values\n\t\telement_value->value.array_value.num_values = R_BIN_JAVA_USHORT (buffer, offset);\n\t\telement_value->size += 2;\n\t\toffset += 2;\n\t\telement_value->value.array_value.values = r_list_new ();\n\t\tfor (i = 0; i < element_value->value.array_value.num_values; i++) {\n\t\t\tif (offset >= sz) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tRBinJavaElementValue *ev_element = r_bin_java_element_value_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\t\tif (ev_element) {\n\t\t\t\telement_value->size += ev_element->size;\n\t\t\t\toffset += ev_element->size;\n\t\t\t\t\/\/ read array_value.num_values, and append to array_value.values\n\t\t\t\tr_list_append (element_value->value.array_value.values, (void *) ev_element);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ANNOTATION:\n\t\t\/\/ annotation new is not used here.\n\t\t\/\/ (ut16) read and set annotation_value.type_idx;\n\t\tif (offset + 8 < sz) {\n\t\t\telement_value->value.annotation_value.type_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\t\telement_value->size += 2;\n\t\t\toffset += 2;\n\t\t\t\/\/ (ut16) read and set annotation_value.num_element_value_pairs;\n\t\t\telement_value->value.annotation_value.num_element_value_pairs = R_BIN_JAVA_USHORT (buffer, offset);\n\t\t\telement_value->size += 2;\n\t\t\toffset += 2;\n\t\t}\n\t\telement_value->value.annotation_value.element_value_pairs = r_list_newf (r_bin_java_element_pair_free);\n\t\t\/\/ read annotation_value.num_element_value_pairs, and append to annotation_value.element_value_pairs\n\t\tfor (i = 0; i < element_value->value.annotation_value.num_element_value_pairs; i++) {\n\t\t\tif (offset > sz) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tevps = r_bin_java_element_pair_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\t\tif (evps) {\n\t\t\t\telement_value->size += evps->size;\n\t\t\t\toffset += evps->size;\n\t\t\t}\n\t\t\tif (evps == NULL) {\n\t\t\t\t\/\/ TODO: eprintf error when reading element pair\n\t\t\t}\n\t\t\tr_list_append (element_value->value.annotation_value.element_value_pairs, (void *) evps);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\t\/\/ eprintf unable to handle tag\n\t\tbreak;\n\t}\n\treturn element_value;\n}","target":0,"code_token_length":1353,"total_token_length":1589,"max_tokens_setting":2048}
+{"idx":274660,"func":"static void aperture_state_report (gerbv_net_t *net,\n\t\tgerbv_image_t *img, gerbv_project_t *prj)\n{\n\tgerbv_layertype_t layer_type = img->layertype;\n\n\tgboolean show_length = FALSE;\n\tgboolean aperture_is_valid = FALSE;\n\tdouble x, y, len = 0;\n\n\tif (net->aperture > 0)\n\t\taperture_is_valid = TRUE;\n\n\tswitch (net->aperture_state) {\n\n\tcase GERBV_APERTURE_STATE_OFF:\n\t\tbreak;\n\n\tcase GERBV_APERTURE_STATE_ON:\n\t\tswitch (net->interpolation) {\n\n\t\tcase GERBV_INTERPOLATION_LINEARx1:\n\t\tcase GERBV_INTERPOLATION_LINEARx10:\n\t\tcase GERBV_INTERPOLATION_LINEARx01:\n\t\tcase GERBV_INTERPOLATION_LINEARx001:\n\t\t\tif (layer_type != GERBV_LAYERTYPE_DRILL)\n\t\t\t\tg_message (_(\"Object type: Line\"));\n\t\t\telse\n\t\t\t\tg_message (_(\"Object type: Slot (drilled)\"));\n\n\t\t\tlen = line_length(net->start_x, net->start_y,\n\t\t\t\t\tnet->stop_x, net->stop_y);\n\t\t\tshow_length = 1;\n\n\t\t\tbreak;\n\n\t\tcase GERBV_INTERPOLATION_CW_CIRCULAR:\n\t\tcase GERBV_INTERPOLATION_CCW_CIRCULAR:\n\t\t\tg_message (_(\"Object type: Arc\"));\n\t\t\tlen = arc_length(net->cirseg->width,\n\t\t\t\t\tfabs(net->cirseg->angle1 -\n\t\t\t\t\t\tnet->cirseg->angle2));\n\t\t\tshow_length = 1;\n\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tg_message (_(\"Object type: Unknown\"));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (layer_type != GERBV_LAYERTYPE_DRILL)\n\t\t\tg_message (_(\"    Exposure: On\"));\n\n\t\tif (aperture_is_valid) {\n\t\t\tif (layer_type != GERBV_LAYERTYPE_DRILL)\n\t\t\t\taperture_report(img->aperture, net->aperture,\n\t\t\t\t\t\tnet->start_x, net->start_y,\n\t\t\t\t\t\timg, prj);\n\t\t\telse\n\t\t\t\tdrill_report(img->aperture, net->aperture);\n\t\t}\n\n\t\tx = net->start_x;\n\t\ty = net->start_y;\n\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\tg_message (_(\"    Start: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x),\n\t\t\t\tscreen_units(y),\n\t\t\t\tscreen_units_str());\n\n\t\tx = net->stop_x;\n\t\ty = net->stop_y;\n\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\tg_message (_(\"    Stop: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x),\n\t\t\t\tscreen_units(y),\n\t\t\t\tscreen_units_str());\n\n\t\tswitch (net->interpolation) {\n\n\t\tcase GERBV_INTERPOLATION_CW_CIRCULAR:\n\t\tcase GERBV_INTERPOLATION_CCW_CIRCULAR:\n\t\t\tx = net->cirseg->cp_x;\n\t\t\ty = net->cirseg->cp_y;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Center: (%g, %g) %s\"),\n\t\t\t\t\tscreen_units(x),\n\t\t\t\t\tscreen_units(y),\n\t\t\t\t\tscreen_units_str());\n\n\t\t\tx = net->cirseg->width\/2;\n\t\t\ty = x;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Radius: %g %s\"),\n\t\t\t\t\tscreen_units(x),\n\t\t\t\t\tscreen_units_str());\n\n\t\t\tg_message (_(\"    Angle: %g deg\"),\n\t\t\t\t\tfabs(net->cirseg->angle1 -\n\t\t\t\t\t\tnet->cirseg->angle2));\n\t\t\tg_message (_(\"    Angles: (%g, %g) deg\"),\n\t\t\t\t\tnet->cirseg->angle1,\n\t\t\t\t\tnet->cirseg->angle2);\n\t\t\tg_message (_(\"    Direction: %s\"),\n\t\t\t\t\t(net->interpolation ==\n\t\t\t\t\t GERBV_INTERPOLATION_CW_CIRCULAR)?\n\t\t\t\t\t\t_(\"CW\"): _(\"CCW\"));\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t\tif (show_length) {\n\t\t\tgerbv_aperture_t *aper = img->aperture[net->aperture];\n\n\t\t\tif (layer_type == GERBV_LAYERTYPE_DRILL\n\t\t\t&&  aperture_is_valid\n\t\t\t&&  aper->type == GERBV_APTYPE_CIRCLE) {\n\t\t\t\tdouble dia = aper->parameter[0];\n\t\t\t\tg_message (_(\"    Slot length: %g %s\"),\n\t\t\t\t\t\tscreen_units(len + dia),\n\t\t\t\t\t\tscreen_units_str());\n\t\t\t}\n\n\t\t\tscreen.length_sum += len;\n\t\t\tg_message (_(\"    Length: %g (sum: %g) %s\"),\n\t\t\t\t\tscreen_units(len),\n\t\t\t\t\tscreen_units(screen.length_sum),\n\t\t\t\t\tscreen_units_str());\n\t\t}\n\n\t\tnet_layer_file_report (net, img, prj);\n\n\t\tbreak;\n\n\tcase GERBV_APERTURE_STATE_FLASH:\n\t\tif (layer_type != GERBV_LAYERTYPE_DRILL)\n\t\t\tg_message (_(\"Object type: Flashed aperture\"));\n\t\telse\n\t\t\tg_message (_(\"Object type: Drill\"));\n\n\t\tif (aperture_is_valid) {\n\t\t\tif (layer_type != GERBV_LAYERTYPE_DRILL)\n\t\t\t\taperture_report(img->aperture, net->aperture,\n\t\t\t\t\t\tnet->stop_x, net->stop_y,\n\t\t\t\t\t\timg, prj);\n\t\t\telse\n\t\t\t\tdrill_report(img->aperture, net->aperture);\n\t\t}\n\n\t\tx = net->stop_x;\n\t\ty = net->stop_y;\n\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\tg_message (_(\"    Location: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x),\n\t\t\t\tscreen_units(y),\n\t\t\t\tscreen_units_str());\n\n\t\tnet_layer_file_report (net, img, prj);\n\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":1252,"total_token_length":1488,"max_tokens_setting":2048}
+{"idx":489160,"func":"sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,\n\t\t\t\t\t const struct sctp_association *asoc,\n\t\t\t\t\t const sctp_subtype_t type, void *arg,\n\t\t\t\t\t sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk\t*asconf_ack = arg;\n\tstruct sctp_chunk\t*last_asconf = asoc->addip_last_asconf;\n\tstruct sctp_chunk\t*abort;\n\tstruct sctp_paramhdr\t*err_param = NULL;\n\tsctp_addiphdr_t\t\t*addip_hdr;\n\t__u32\t\t\tsent_serial, rcvd_serial;\n\n\tif (!sctp_vtag_verify(asconf_ack, asoc)) {\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG,\n\t\t\t\tSCTP_NULL());\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\t}\n\n\t\/* ADD-IP, Section 4.1.2:\n\t * This chunk MUST be sent in an authenticated way by using\n\t * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk\n\t * is received unauthenticated it MUST be silently discarded as\n\t * described in [I-D.ietf-tsvwg-sctp-auth].\n\t *\/\n\tif (!sctp_addip_noauth && !asconf_ack->auth)\n\t\treturn sctp_sf_discard_chunk(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the ADDIP chunk has a valid length.  *\/\n\tif (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\taddip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data;\n\trcvd_serial = ntohl(addip_hdr->serial);\n\n\t\/* Verify the ASCONF-ACK chunk before processing it. *\/\n\tif (!sctp_verify_asconf(asoc,\n\t    (sctp_paramhdr_t *)addip_hdr->params,\n\t    (void *)asconf_ack->chunk_end,\n\t    &err_param))\n\t\treturn sctp_sf_violation_paramlen(ep, asoc, type, arg,\n\t\t\t   (void *)err_param, commands);\n\n\tif (last_asconf) {\n\t\taddip_hdr = (sctp_addiphdr_t *)last_asconf->subh.addip_hdr;\n\t\tsent_serial = ntohl(addip_hdr->serial);\n\t} else {\n\t\tsent_serial = asoc->addip_serial - 1;\n\t}\n\n\t\/* D0) If an endpoint receives an ASCONF-ACK that is greater than or\n\t * equal to the next serial number to be used but no ASCONF chunk is\n\t * outstanding the endpoint MUST ABORT the association. Note that a\n\t * sequence number is greater than if it is no more than 2^^31-1\n\t * larger than the current sequence number (using serial arithmetic).\n\t *\/\n\tif (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) &&\n\t    !(asoc->addip_last_asconf)) {\n\t\tabort = sctp_make_abort(asoc, asconf_ack,\n\t\t\t\t\tsizeof(sctp_errhdr_t));\n\t\tif (abort) {\n\t\t\tsctp_init_cause(abort, SCTP_ERROR_ASCONF_ACK, 0);\n\t\t\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY,\n\t\t\t\t\tSCTP_CHUNK(abort));\n\t\t}\n\t\t\/* We are going to ABORT, so we might as well stop\n\t\t * processing the rest of the chunks in the packet.\n\t\t *\/\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,\n\t\t\t\tSCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,\n\t\t\t\tSCTP_ERROR(ECONNABORTED));\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,\n\t\t\t\tSCTP_PERR(SCTP_ERROR_ASCONF_ACK));\n\t\tSCTP_INC_STATS(SCTP_MIB_ABORTEDS);\n\t\tSCTP_DEC_STATS(SCTP_MIB_CURRESTAB);\n\t\treturn SCTP_DISPOSITION_ABORT;\n\t}\n\n\tif ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) {\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,\n\t\t\t\tSCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));\n\n\t\tif (!sctp_process_asconf_ack((struct sctp_association *)asoc,\n\t\t\t\t\t     asconf_ack))\n\t\t\treturn SCTP_DISPOSITION_CONSUME;\n\n\t\tabort = sctp_make_abort(asoc, asconf_ack,\n\t\t\t\t\tsizeof(sctp_errhdr_t));\n\t\tif (abort) {\n\t\t\tsctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0);\n\t\t\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY,\n\t\t\t\t\tSCTP_CHUNK(abort));\n\t\t}\n\t\t\/* We are going to ABORT, so we might as well stop\n\t\t * processing the rest of the chunks in the packet.\n\t\t *\/\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET,SCTP_NULL());\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,\n\t\t\t\tSCTP_ERROR(ECONNABORTED));\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,\n\t\t\t\tSCTP_PERR(SCTP_ERROR_ASCONF_ACK));\n\t\tSCTP_INC_STATS(SCTP_MIB_ABORTEDS);\n\t\tSCTP_DEC_STATS(SCTP_MIB_CURRESTAB);\n\t\treturn SCTP_DISPOSITION_ABORT;\n\t}\n\n\treturn SCTP_DISPOSITION_DISCARD;\n}","target":0,"code_token_length":1218,"total_token_length":1454,"max_tokens_setting":2048}
+{"idx":264696,"func":"lexer_construct_literal_object (parser_context_t *context_p, \/**< context *\/\n                                const lexer_lit_location_t *lit_location_p, \/**< literal location *\/\n                                uint8_t literal_type) \/**< final literal type *\/\n{\n  uint8_t local_byte_array[LEXER_MAX_LITERAL_LOCAL_BUFFER_SIZE];\n\n  const uint8_t *char_p =\n    lexer_convert_literal_to_chars (context_p, lit_location_p, local_byte_array, LEXER_STRING_NO_OPTS);\n\n  size_t length = lit_location_p->length;\n  parser_list_iterator_t literal_iterator;\n  lexer_literal_t *literal_p;\n  uint32_t literal_index = 0;\n  bool search_scope_stack = (literal_type == LEXER_IDENT_LITERAL);\n\n  if (JERRY_UNLIKELY (literal_type == LEXER_NEW_IDENT_LITERAL))\n  {\n    literal_type = LEXER_IDENT_LITERAL;\n  }\n\n  JERRY_ASSERT (literal_type == LEXER_IDENT_LITERAL || literal_type == LEXER_STRING_LITERAL);\n\n  JERRY_ASSERT (literal_type != LEXER_IDENT_LITERAL || length <= PARSER_MAXIMUM_IDENT_LENGTH);\n  JERRY_ASSERT (literal_type != LEXER_STRING_LITERAL || length <= PARSER_MAXIMUM_STRING_LENGTH);\n\n  parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);\n\n  while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)) != NULL)\n  {\n    if (literal_p->type == literal_type && literal_p->prop.length == length\n        && memcmp (literal_p->u.char_p, char_p, length) == 0)\n    {\n      context_p->lit_object.literal_p = literal_p;\n      context_p->lit_object.index = (uint16_t) literal_index;\n\n      parser_free_allocated_buffer (context_p);\n\n      if (search_scope_stack)\n      {\n        parser_scope_stack_t *scope_stack_start_p = context_p->scope_stack_p;\n        parser_scope_stack_t *scope_stack_p = scope_stack_start_p + context_p->scope_stack_top;\n\n        while (scope_stack_p > scope_stack_start_p)\n        {\n          scope_stack_p--;\n\n          if (scope_stack_p->map_from == literal_index)\n          {\n            JERRY_ASSERT (scanner_decode_map_to (scope_stack_p) >= PARSER_REGISTER_START\n                          || (literal_p->status_flags & LEXER_FLAG_USED));\n            context_p->lit_object.index = scanner_decode_map_to (scope_stack_p);\n            return;\n          }\n        }\n\n        literal_p->status_flags |= LEXER_FLAG_USED;\n      }\n      return;\n    }\n\n    literal_index++;\n  }\n\n  JERRY_ASSERT (literal_index == context_p->literal_count);\n\n  if (literal_index >= PARSER_MAXIMUM_NUMBER_OF_LITERALS)\n  {\n    parser_raise_error (context_p, PARSER_ERR_LITERAL_LIMIT_REACHED);\n  }\n\n  literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);\n  literal_p->prop.length = (prop_length_t) length;\n  literal_p->type = literal_type;\n\n  uint8_t status_flags = LEXER_FLAG_SOURCE_PTR;\n\n  if (length > 0 && char_p == local_byte_array)\n  {\n    literal_p->u.char_p = (uint8_t *) jmem_heap_alloc_block (length);\n    memcpy ((uint8_t *) literal_p->u.char_p, char_p, length);\n    status_flags = 0;\n  }\n  else\n  {\n    literal_p->u.char_p = char_p;\n\n    \/* Buffer is taken over when a new literal is constructed. *\/\n    if (context_p->u.allocated_buffer_p != NULL)\n    {\n      JERRY_ASSERT (char_p == context_p->u.allocated_buffer_p);\n\n      context_p->u.allocated_buffer_p = NULL;\n      status_flags = 0;\n    }\n  }\n\n  if (search_scope_stack)\n  {\n    status_flags |= LEXER_FLAG_USED;\n  }\n\n  if (lit_location_p->status_flags & LEXER_LIT_LOCATION_IS_ASCII)\n  {\n    literal_p->status_flags |= LEXER_FLAG_ASCII;\n  }\n\n  literal_p->status_flags = status_flags;\n\n  context_p->lit_object.literal_p = literal_p;\n  context_p->lit_object.index = (uint16_t) literal_index;\n  context_p->literal_count++;\n\n  JERRY_ASSERT (context_p->u.allocated_buffer_p == NULL);\n} \/* lexer_construct_literal_object *\/","target":0,"code_token_length":920,"total_token_length":1156,"max_tokens_setting":2048}
+{"idx":230456,"func":"uip_nd6_ra_output(uip_ipaddr_t * dest)\n{\n\n  UIP_IP_BUF->vtc = 0x60;\n  UIP_IP_BUF->tcflow = 0;\n  UIP_IP_BUF->flow = 0;\n  UIP_IP_BUF->proto = UIP_PROTO_ICMP6;\n  UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;\n\n  if(dest == NULL) {\n    uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);\n  } else {\n    \/* For sollicited RA *\/\n    uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, dest);\n  }\n  uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);\n\n  UIP_ICMP_BUF->type = ICMP6_RA;\n  UIP_ICMP_BUF->icode = 0;\n\n  UIP_ND6_RA_BUF->cur_ttl = uip_ds6_if.cur_hop_limit;\n\n  UIP_ND6_RA_BUF->flags_reserved =\n    (UIP_ND6_M_FLAG << 7) | (UIP_ND6_O_FLAG << 6);\n\n  UIP_ND6_RA_BUF->router_lifetime = uip_htons(UIP_ND6_ROUTER_LIFETIME);\n  \/\/UIP_ND6_RA_BUF->reachable_time = uip_htonl(uip_ds6_if.reachable_time);\n  \/\/UIP_ND6_RA_BUF->retrans_timer = uip_htonl(uip_ds6_if.retrans_timer);\n  UIP_ND6_RA_BUF->reachable_time = 0;\n  UIP_ND6_RA_BUF->retrans_timer = 0;\n\n  uip_len = UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_RA_LEN;\n  nd6_opt_offset = UIP_ND6_RA_LEN;\n\n\n  \/* Prefix list *\/\n  for(prefix = uip_ds6_prefix_list;\n      prefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; prefix++) {\n    if((prefix->isused) && (prefix->advertise)) {\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->type = UIP_ND6_OPT_PREFIX_INFO;\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->len = UIP_ND6_OPT_PREFIX_INFO_LEN \/ 8;\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->preflen = prefix->length;\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->flagsreserved1 = prefix->l_a_reserved;\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->validlt = uip_htonl(prefix->vlifetime);\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->preferredlt = uip_htonl(prefix->plifetime);\n      ND6_OPT_PREFIX_BUF(nd6_opt_offset)->reserved2 = 0;\n      uip_ipaddr_copy(&(ND6_OPT_PREFIX_BUF(nd6_opt_offset)->prefix), &(prefix->ipaddr));\n      nd6_opt_offset += UIP_ND6_OPT_PREFIX_INFO_LEN;\n      uip_len += UIP_ND6_OPT_PREFIX_INFO_LEN;\n    }\n  }\n\n  \/* Source link-layer option *\/\n  create_llao((uint8_t *)ND6_OPT_HDR_BUF(nd6_opt_offset), UIP_ND6_OPT_SLLAO);\n\n  uip_len += UIP_ND6_OPT_LLAO_LEN;\n  nd6_opt_offset += UIP_ND6_OPT_LLAO_LEN;\n\n  \/* MTU *\/\n  ND6_OPT_MTU_BUF(nd6_opt_offset)->type = UIP_ND6_OPT_MTU;\n  ND6_OPT_MTU_BUF(nd6_opt_offset)->len = UIP_ND6_OPT_MTU_LEN >> 3;\n  ND6_OPT_MTU_BUF(nd6_opt_offset)->reserved = 0;\n  \/\/ND6_OPT_MTU_BUF(nd6_opt_offset)->mtu = uip_htonl(uip_ds6_if.link_mtu);\n  ND6_OPT_MTU_BUF(nd6_opt_offset)->mtu = uip_htonl(1500);\n\n  uip_len += UIP_ND6_OPT_MTU_LEN;\n  nd6_opt_offset += UIP_ND6_OPT_MTU_LEN;\n\n#if UIP_ND6_RA_RDNSS\n  if(uip_nameserver_count() > 0) {\n    uint8_t i = 0;\n    uip_ipaddr_t *ip = &ND6_OPT_RDNSS_BUF(nd6_opt_offset)->ip;\n    uip_ipaddr_t *dns = NULL;\n    ND6_OPT_RDNSS_BUF(nd6_opt_offset)->type = UIP_ND6_OPT_RDNSS;\n    ND6_OPT_RDNSS_BUF(nd6_opt_offset)->reserved = 0;\n    ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime = uip_nameserver_next_expiration();\n    if(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime != UIP_NAMESERVER_INFINITE_LIFETIME) {\n      ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime -= clock_seconds();\n    }\n    while((dns = uip_nameserver_get(i)) != NULL) {\n      uip_ipaddr_copy(ip++, dns);\n      i++;\n    }\n    ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len = UIP_ND6_OPT_RDNSS_LEN + (i << 1);\n    LOG_INFO(\"%d nameservers reported\\n\", i);\n    uip_len += ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len << 3;\n    nd6_opt_offset += ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len << 3;\n  }\n#endif \/* UIP_ND6_RA_RDNSS *\/\n\n  uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);\n\n  \/*ICMP checksum *\/\n  UIP_ICMP_BUF->icmpchksum = 0;\n  UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();\n\n  UIP_STAT(++uip_stat.nd6.sent);\n  LOG_INFO(\"Sending RA to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\" from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\"\\n\");\n  return;\n}","target":0,"code_token_length":1295,"total_token_length":1531,"max_tokens_setting":2048}
+{"idx":237820,"func":"static int acurite_6045_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row)\n{\n    float tempf;\n    uint8_t humidity;\n    \/\/ uint8_t message_type, l_status;\n    char raw_str[31], *rawp;\n    uint16_t sensor_id;\n    uint8_t strike_count, strike_distance;\n    int battery_low, active, rfi_detect;\n    int exception = 0;\n    data_t *data;\n\n    int browlen = (bitbuffer->bits_per_row[row] + 7) \/ 8;\n    uint8_t *bb = bitbuffer->bb[row];\n\n    char const *channel_str = acurite_getChannel(bb[0]); \/\/ same as TXR\n\n    \/\/ Tower sensor ID is the last 14 bits of byte 0 and 1\n    \/\/ CCII IIII | IIII IIII\n    sensor_id = ((bb[0] & 0x3f) << 8) | bb[1]; \/\/ same as TXR\n    battery_low = (bb[2] & 0x40) == 0;\n    humidity = (bb[3] & 0x7f); \/\/ 1-99 %rH, same as TXR\n    active = (bb[4] & 0x40) == 0x40;    \/\/ Sensor is actively listening for strikes\n    \/\/message_type = bb[2] & 0x3f;\n\n    \/\/ 12 bits of temperature after removing parity and status bits.\n    \/\/ Message native format appears to be in 1\/10 of a degree Fahrenheit\n    \/\/ Device Specification: -40 to 158 F  \/ -40 to 70 C\n    \/\/ Available range given 12 bits with +1480 offset: -140.0 F to +261.5 F\n    int temp_raw = ((bb[4] & 0x1F) << 7) | (bb[5] & 0x7F);\n    tempf = (temp_raw - 1480) * 0.1f;\n\n    \/\/ Strike count is 8 bits, LSB in following byte\n    strike_count = ((bb[6] & 0x7f) << 1) | ((bb[7] & 0x40) >> 6);\n    strike_distance = bb[7] & 0x1f;\n    rfi_detect = (bb[7] & 0x20) == 0x20;\n    \/\/l_status = (bb[7] & 0x60) >> 5;\n\n    \/*\n     * 2018-04-21 rct - There are still a number of unknown bits in the\n     * message that need to be figured out. Add the raw message hex to\n     * to the structured data output to allow future analysis without\n     * having to enable debug for long running rtl_433 processes.\n     *\/\n    rawp = (char *)raw_str;\n    for (int i=0; i < MIN(browlen, 15); i++) {\n        sprintf(rawp,\"%02x\",bb[i]);\n        rawp += 2;\n    }\n    *rawp = '\\0';\n\n    \/\/ Flag whether this message might need further analysis\n    if (((bb[4] & 0x20) != 0) ||  \/\/ unknown status bits, always off\n        (humidity > 100) ||\n        (tempf > 158) ||\n        (tempf < -40)) {\n        exception++;\n    }\n\n    \/* clang-format off *\/\n    data = data_make(\n            \"model\",            \"\",                 DATA_STRING, \"Acurite-6045M\",\n            \"id\",               NULL,               DATA_INT,    sensor_id,\n            \"channel\",          NULL,               DATA_STRING, channel_str,\n            \"battery_ok\",       \"Battery\",          DATA_INT,    !battery_low,\n            \"temperature_F\",    \"temperature\",      DATA_FORMAT, \"%.1f F\",     DATA_DOUBLE,     tempf,\n            \"humidity\",         \"humidity\",         DATA_FORMAT, \"%u %%\", DATA_INT,    humidity,\n            \"strike_count\",     \"strike_count\",     DATA_INT,    strike_count,\n            \"storm_dist\",       \"storm_distance\",   DATA_INT,    strike_distance,\n            \"active\",           \"active_mode\",      DATA_INT,    active,    \/\/ @todo convert to bool\n            \"rfi\",              \"rfi_detect\",       DATA_INT,    rfi_detect,     \/\/ @todo convert to bool\n            \"exception\",        \"data_exception\",   DATA_INT,    exception,    \/\/ @todo convert to bool\n            \"raw_msg\",          \"raw_message\",      DATA_STRING, raw_str,\n            NULL);\n    \/* clang-format on *\/\n\n    decoder_output_data(decoder, data);\n    return 1;\n}","target":0,"code_token_length":1072,"total_token_length":1308,"max_tokens_setting":2048}
+{"idx":435409,"func":"jetp3852_print_page(gx_device_printer *pdev, gp_file *prn_stream)\n{\n#define DATA_SIZE (LINE_SIZE * 8)\n\n    unsigned int cnt_2prn;\n    unsigned int count,tempcnt;\n    unsigned char vtp,cntc1,cntc2;\n    int line_size_color_plane;\n\n    byte data[DATA_SIZE];\n    byte plane_data[LINE_SIZE * 3];\n\n    \/* Initialise data to zeros, otherwise later on, uninitialised bytes in\n    dp[] can be greater than 7, which breaks spr8[dp[]]. *\/\n    memset(data, 0x00, DATA_SIZE);\n\n    \/* Set initial condition for printer *\/\n    gp_fputs(\"\\033@\",prn_stream);\n\n    \/* Send each scan line in turn *\/\n    {\n        int lnum;\n        int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);\n        int num_blank_lines = 0;\n\n        if (line_size > DATA_SIZE) {\n            emprintf2(pdev->memory, \"invalid resolution and\/or width gives line_size = %d, max. is %d\\n\",\n                      line_size, DATA_SIZE);\n            return_error(gs_error_rangecheck);\n        }\n\n        for ( lnum = 0; lnum < pdev->height; lnum++ ) {\n            byte *end_data = data + line_size;\n            gdev_prn_copy_scan_lines(pdev, lnum,\n                                     (byte *)data, line_size);\n            \/* Remove trailing 0s. *\/\n            while ( end_data > data && end_data[-1] == 0 )\n                end_data--;\n            if ( end_data == data ) {\n                \/* Blank line *\/\n                num_blank_lines++;\n            } else {\n                int i;\n                byte *odp;\n                byte *row;\n\n                \/* Transpose the data to get pixel planes. *\/\n                for ( i = 0, odp = plane_data; i < DATA_SIZE;\n                      i += 8, odp++\n                    ) { \/* The following is for 16-bit machines *\/\n#define spread3(c)\\\n { 0, c, c*0x100, c*0x101, c*0x10000L, c*0x10001L, c*0x10100L, c*0x10101L }\n                    static ulong spr40[8] = spread3(0x40);\n                    static ulong spr8[8] = spread3(8);\n                    static ulong spr2[8] = spread3(2);\n                    register byte *dp = data + i;\n                    register ulong pword =\n                                     (spr40[dp[0]] << 1) +\n                                     (spr40[dp[1]]) +\n                                     (spr40[dp[2]] >> 1) +\n                                     (spr8[dp[3]] << 1) +\n                                     (spr8[dp[4]]) +\n                                     (spr8[dp[5]] >> 1) +\n                                     (spr2[dp[6]]) +\n                                     (spr2[dp[7]] >> 1);\n                    odp[0] = (byte)(pword >> 16);\n                    odp[LINE_SIZE] = (byte)(pword >> 8);\n                    odp[LINE_SIZE*2] = (byte)(pword);\n                }\n                \/* Skip blank lines if any *\/\n                if ( num_blank_lines > 0 ) {\n                    \/* Do \"dot skips\" *\/\n                    while(num_blank_lines > 255) {\n                        gp_fputs(\"\\033e\\377\",prn_stream);\n                        num_blank_lines -= 255;\n                    }\n                    vtp = num_blank_lines;\n                    gp_fprintf(prn_stream,\"\\033e%c\",vtp);\n                    num_blank_lines = 0;\n                }\n\n                \/* Transfer raster graphics in the order R, G, B. *\/\n                \/* Apparently it is stored in B, G, R *\/\n                \/* Calculate the amount of data to send by what *\/\n                \/* Ghostscript tells us the scan line_size in (bytes) *\/\n\n                count = line_size \/ 3;\n                line_size_color_plane = count \/ 3;\n                cnt_2prn = line_size_color_plane * 3 + 5;\n                tempcnt = cnt_2prn;\n                cntc1 = (tempcnt & 0xFF00) >> 8;\n                cntc2 = (tempcnt & 0x00FF);\n                gp_fprintf(prn_stream, \"\\033[O%c%c\\200\\037\",cntc2,cntc1);\n                gp_fputc('\\000',prn_stream);\n                gp_fputs(\"\\124\\124\",prn_stream);\n\n                for ( row = plane_data + LINE_SIZE * 2, i = 0;\n                      i < 3; row -= LINE_SIZE, i++ ) {\n                    int jj;\n                    byte ctemp;\n                    odp = row;\n                    \/* Complement bytes *\/\n                    for (jj=0; jj< line_size_color_plane; jj++) {\n                        ctemp = *odp;\n                        *odp++ = ~ctemp;\n                    }\n                    gp_fwrite(row, sizeof(byte),\n                              line_size_color_plane, prn_stream);\n                }\n            }\n        }\n    }\n\n    \/* eject page *\/\n    gp_fputs(\"\\014\", prn_stream);\n\n    return 0;\n}","target":0,"code_token_length":1162,"total_token_length":1398,"max_tokens_setting":2048}
+{"idx":235253,"func":"static bool test_write(struct torture_context *tctx,\n\t\t       struct smbcli_state *cli)\n{\n\tunion smb_write io;\n\tNTSTATUS status;\n\tbool ret = true;\n\tint fnum;\n\tuint8_t *buf;\n\tconst int maxsize = 90000;\n\tconst char *fname = BASEDIR \"\\\\test.txt\";\n\tunsigned int seed = time(NULL);\n\tunion smb_fileinfo finfo;\n\n\tbuf = talloc_zero_array(tctx, uint8_t, maxsize);\n\n\tif (!torture_setup_dir(cli, BASEDIR)) {\n\t\ttorture_fail(tctx, \"failed to setup basedir\");\n\t}\n\n\ttorture_comment(tctx, \"Testing RAW_WRITE_WRITE\\n\");\n\tio.generic.level = RAW_WRITE_WRITE;\n\n\tfnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);\n\tif (fnum == -1) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done,\n\t\t\ttalloc_asprintf(tctx, \"Failed to create %s - %s\\n\", fname, smbcli_errstr(cli->tree)));\n\t}\n\n\ttorture_comment(tctx, \"Trying zero write\\n\");\n\tio.write.in.file.fnum = fnum;\n\tio.write.in.count = 0;\n\tio.write.in.offset = 0;\n\tio.write.in.remaining = 0;\n\tio.write.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.write.out.nwritten, 0);\n\n\tsetup_buffer(buf, seed, maxsize);\n\n\ttorture_comment(tctx, \"Trying small write\\n\");\n\tio.write.in.count = 9;\n\tio.write.in.offset = 4;\n\tio.write.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.write.out.nwritten, io.write.in.count);\n\n\tmemset(buf, 0, maxsize);\n\tif (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf+4, seed, 9);\n\tCHECK_VALUE(IVAL(buf,0), 0);\n\n\tsetup_buffer(buf, seed, maxsize);\n\n\ttorture_comment(tctx, \"Trying large write\\n\");\n\tio.write.in.count = 4000;\n\tio.write.in.offset = 0;\n\tio.write.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.write.out.nwritten, 4000);\n\n\tmemset(buf, 0, maxsize);\n\tif (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf, seed, 4000);\n\n\ttorture_comment(tctx, \"Trying bad fnum\\n\");\n\tio.write.in.file.fnum = fnum+1;\n\tio.write.in.count = 4000;\n\tio.write.in.offset = 0;\n\tio.write.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);\n\n\ttorture_comment(tctx, \"Setting file as sparse\\n\");\n\tstatus = torture_set_sparse(cli->tree, fnum);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\n\tif (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {\n\t\ttorture_comment(tctx, \"skipping large file tests - CAP_LARGE_FILES not set\\n\");\n\t\tgoto done;\n\t}\n\n\ttorture_comment(tctx, \"Trying 2^32 offset\\n\");\n\tsetup_buffer(buf, seed, maxsize);\n\tio.write.in.file.fnum = fnum;\n\tio.write.in.count = 4000;\n\tio.write.in.offset = 0xFFFFFFFF - 2000;\n\tio.write.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.write.out.nwritten, 4000);\n\tCHECK_ALL_INFO(io.write.in.count + (uint64_t)io.write.in.offset, size);\n\n\tmemset(buf, 0, maxsize);\n\tif (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf, seed, 4000);\n\ndone:\n\tsmbcli_close(cli->tree, fnum);\n\tsmb_raw_exit(cli->session);\n\tsmbcli_deltree(cli->tree, BASEDIR);\n\treturn ret;\n}","target":0,"code_token_length":1061,"total_token_length":1297,"max_tokens_setting":2048}
+{"idx":259717,"func":"json_t * user_auth_scheme_module_init(struct config_module * config, json_t * j_parameters, const char * mod_name, void ** cls) {\n  UNUSED(config);\n  json_t * j_result = is_scheme_parameters_valid(j_parameters), * j_element = NULL, * j_return;\n  size_t index = 0;\n  char * message;\n  \n  if (check_result_value(j_result, G_OK)) {\n    *cls = json_pack(\"{sO sO sO sO sI sI sO ss so sO sO sO sO sO ss s[]}\",\n                     \"challenge-length\", json_object_get(j_parameters, \"challenge-length\"),\n                     \"rp-origin\", json_object_get(j_parameters, \"rp-origin\"),\n                     \"credential-expiration\", json_object_get(j_parameters, \"credential-expiration\"),\n                     \"credential-assertion\", json_object_get(j_parameters, \"credential-assertion\"),\n                     \"ctsProfileMatch\", json_object_get(j_parameters, \"ctsProfileMatch\")!=NULL?json_integer_value(json_object_get(j_parameters, \"ctsProfileMatch\")):-1,\n                     \"basicIntegrity\", json_object_get(j_parameters, \"basicIntegrity\")!=NULL?json_integer_value(json_object_get(j_parameters, \"basicIntegrity\")):-1,\n                     \"session-mandatory\", json_object_get(j_parameters, \"session-mandatory\")!=NULL?json_object_get(j_parameters, \"session-mandatory\"):json_true(),\n                     \"seed\", !json_string_length(json_object_get(j_parameters, \"seed\"))?\"\":json_string_value(json_object_get(j_parameters, \"seed\")),\n                     \"fmt\", json_object_get(j_parameters, \"fmt\")!=NULL?json_deep_copy(json_object_get(j_parameters, \"fmt\")):json_pack(\"{sosososososo}\", \"packed\", json_true(), \"tpm\", json_true(), \"android-key\", json_true(), \"android-safetynet\", json_true(), \"fido-u2f\", json_true(), \"none\", json_true()),\n                     \"force-fmt-none\", json_object_get(j_parameters, \"force-fmt-none\")!=NULL?json_object_get(j_parameters, \"force-fmt-none\"):json_false(),\n                     \"google-root-ca-r2\", json_string_length(json_object_get(j_parameters, \"google-root-ca-r2\"))?json_object_get(j_parameters, \"google-root-ca-r2\"):json_null(),\n                     \"google-root-ca-r2-content\", json_object_get(j_parameters, \"google-root-ca-r2-content\")!=NULL?json_object_get(j_parameters, \"google-root-ca-r2-content\"):json_null(),\n                     \"root-ca-list\", json_array_size(json_object_get(j_parameters, \"root-ca-list\"))?json_object_get(j_parameters, \"root-ca-list\"):json_null(),\n                     \"root-ca-array\", json_object_get(j_parameters, \"root-ca-array\")!=NULL?json_object_get(j_parameters, \"root-ca-array\"):json_null(),\n                     \"mod_name\", mod_name,\n                     \"pubKey-cred-params\");\n    json_array_foreach(json_object_get(j_parameters, \"pubKey-cred-params\"), index, j_element) {\n      json_array_append_new(json_object_get((json_t *)*cls, \"pubKey-cred-params\"), json_pack(\"{sssO}\", \"type\", \"public-key\", \"alg\", j_element));\n    }\n    j_return = json_pack(\"{si}\", \"result\", G_OK);\n  } else if (check_result_value(j_result, G_ERROR_PARAM)) {\n    message = json_dumps(json_object_get(j_result, \"error\"), JSON_COMPACT);\n    y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_init webauthn - Error input parameters: %s\", message);\n    o_free(message);\n    j_return = json_pack(\"{sisO}\", \"result\", G_ERROR_PARAM, \"error\", json_object_get(j_result, \"error\"));\n  } else {\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n  }\n  json_decref(j_result);\n  return j_return;\n}","target":0,"code_token_length":827,"total_token_length":1063,"max_tokens_setting":2048}
+{"idx":224200,"func":"gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)\n{\n  if (nopeep || no_peephole(s)) goto normal;\n  else if (dst == src) return;\n  else {\n    struct mrb_insn_data data = mrb_last_insn(s);\n\n    switch (data.insn) {\n    case OP_MOVE:\n      if (dst == src) return;   \/* remove useless MOVE *\/\n      if (data.a == src) {\n        if (data.b == dst)      \/* skip swapping MOVE *\/\n          return;\n        if (data.a < s->nlocals) goto normal;\n        rewind_pc(s);\n        s->lastpc = addr_pc(s, mrb_prev_pc(s, data.addr));\n        gen_move(s, dst, data.b, FALSE);\n        return;\n      }\n      if (dst == data.a) {      \/* skip overwritten move *\/\n        rewind_pc(s);\n        s->lastpc = addr_pc(s, mrb_prev_pc(s, data.addr));\n        gen_move(s, dst, src, FALSE);\n        return;\n      }\n      goto normal;\n    case OP_LOADNIL: case OP_LOADSELF: case OP_LOADT: case OP_LOADF:\n    case OP_LOADI__1:\n    case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3:\n    case OP_LOADI_4: case OP_LOADI_5: case OP_LOADI_6: case OP_LOADI_7:\n      if (data.a != src || data.a < s->nlocals) goto normal;\n      rewind_pc(s);\n      genop_1(s, data.insn, dst);\n      return;\n    case OP_HASH:\n      if (data.b != 0) goto normal;\n      \/* fall through *\/\n    case OP_LOADI: case OP_LOADINEG:\n    case OP_LOADL: case OP_LOADSYM:\n    case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV:\n    case OP_GETCONST: case OP_STRING:\n    case OP_LAMBDA: case OP_BLOCK: case OP_METHOD: case OP_BLKPUSH:\n      if (data.a != src || data.a < s->nlocals) goto normal;\n      rewind_pc(s);\n      genop_2(s, data.insn, dst, data.b);\n      return;\n    case OP_LOADI16:\n      if (data.a != src || data.a < s->nlocals) goto normal;\n      rewind_pc(s);\n      genop_2S(s, data.insn, dst, data.b);\n      return;\n    case OP_LOADI32:\n      if (data.a != src || data.a < s->nlocals) goto normal;\n      else {\n        uint32_t i = (uint32_t)data.b<<16|data.c;\n        rewind_pc(s);\n        genop_2SS(s, data.insn, dst, i);\n      }\n      return;\n    case OP_ARRAY:\n      if (data.a != src || data.a < s->nlocals || data.a < dst) goto normal;\n      rewind_pc(s);\n      if (data.b == 0 || dst == data.a)\n        genop_2(s, OP_ARRAY, dst, 0);\n      else\n        genop_3(s, OP_ARRAY2, dst, data.a, data.b);\n      return;\n    case OP_ARRAY2:\n      if (data.a != src || data.a < s->nlocals || data.a < dst) goto normal;\n      rewind_pc(s);\n      genop_3(s, OP_ARRAY2, dst, data.b, data.c);\n      return;\n    case OP_AREF:\n    case OP_GETUPVAR:\n      if (data.a != src || data.a < s->nlocals) goto normal;\n      rewind_pc(s);\n      genop_3(s, data.insn, dst, data.b, data.c);\n      return;\n    case OP_ADDI: case OP_SUBI:\n      if (addr_pc(s, data.addr) == s->lastlabel || data.a != src || data.a < s->nlocals) goto normal;\n      else {\n        struct mrb_insn_data data0 = mrb_decode_insn(mrb_prev_pc(s, data.addr));\n        if (data0.insn != OP_MOVE || data0.a != data.a || data0.b != dst) goto normal;\n        s->pc = addr_pc(s, data0.addr);\n        if (addr_pc(s, data0.addr) != s->lastlabel) {\n          \/* constant folding *\/\n          data0 = mrb_decode_insn(mrb_prev_pc(s, data0.addr));\n          mrb_int n;\n          if (data0.a == dst && get_int_operand(s, &data0, &n)) {\n            if ((data.insn == OP_ADDI && !mrb_int_add_overflow(n, data.b, &n)) ||\n                (data.insn == OP_SUBI && !mrb_int_sub_overflow(n, data.b, &n))) {\n              s->pc = addr_pc(s, data0.addr);\n              gen_int(s, dst, n);\n              return;\n            }\n          }\n        }\n      }\n      genop_2(s, data.insn, dst, data.b);\n      return;\n    default:\n      break;\n    }\n  }\n normal:\n  genop_2(s, OP_MOVE, dst, src);\n  return;\n}","target":0,"code_token_length":1139,"total_token_length":1375,"max_tokens_setting":2048}
+{"idx":522358,"func":"int GmfSetHONodesOrdering(int64_t MshIdx, int KwdCod, int *BasTab, int *OrdTab)\n{\n   int i, j, k, flg, NmbNod, NmbCrd;\n   GmfMshSct   *msh = (GmfMshSct *)MshIdx;\n   KwdSct      *kwd;\n   \n   \/\/ printf(\"\\n\\tGmfSetHONodesOrdering 0\\n\");\n\n   if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) )\n      return(0);\n\n   kwd = &msh->KwdTab[ KwdCod ];\n\n   \/\/ Find the Bezier indices dimension according to the element's kind\n   switch(KwdCod)\n   {\n      case GmfEdges   :          NmbNod =  2; NmbCrd = 1; break;\n      case GmfEdgesP2 :          NmbNod =  3; NmbCrd = 1; break;\n      case GmfEdgesP3 :          NmbNod =  4; NmbCrd = 1; break;\n      case GmfEdgesP4 :          NmbNod =  5; NmbCrd = 1; break;\n      case GmfTriangles   :      NmbNod =  3; NmbCrd = 3; break;\n      case GmfTrianglesP2 :      NmbNod =  6; NmbCrd = 3; break;\n      case GmfTrianglesP3 :      NmbNod = 10; NmbCrd = 3; break;\n      case GmfTrianglesP4 :      NmbNod = 15; NmbCrd = 3; break;\n      case GmfQuadrilaterals   : NmbNod =  4; NmbCrd = 2; break;\n      case GmfQuadrilateralsQ2 : NmbNod =  9; NmbCrd = 2; break;\n      case GmfQuadrilateralsQ3 : NmbNod = 16; NmbCrd = 2; break;\n      case GmfQuadrilateralsQ4 : NmbNod = 25; NmbCrd = 2; break;\n      case GmfTetrahedra   :     NmbNod =  4; NmbCrd = 4; break;\n      case GmfTetrahedraP2 :     NmbNod = 10; NmbCrd = 4; break;\n      case GmfTetrahedraP3 :     NmbNod = 20; NmbCrd = 4; break;\n      case GmfTetrahedraP4 :     NmbNod = 35; NmbCrd = 4; break;\n      case GmfPyramids   :       NmbNod =  5; NmbCrd = 3; break;\n      case GmfPyramidsP2 :       NmbNod = 14; NmbCrd = 3; break;\n      case GmfPyramidsP3 :       NmbNod = 30; NmbCrd = 3; break;\n      case GmfPyramidsP4 :       NmbNod = 55; NmbCrd = 3; break;\n      case GmfPrisms   :         NmbNod =  6; NmbCrd = 4; break;\n      case GmfPrismsP2 :         NmbNod = 18; NmbCrd = 4; break;\n      case GmfPrismsP3 :         NmbNod = 40; NmbCrd = 4; break;\n      case GmfPrismsP4 :         NmbNod = 75; NmbCrd = 4; break;\n      case GmfHexahedra   :      NmbNod =  8; NmbCrd = 3; break;\n      case GmfHexahedraQ2 :      NmbNod = 27; NmbCrd = 3; break;\n      case GmfHexahedraQ3 :      NmbNod = 64; NmbCrd = 3; break;\n      case GmfHexahedraQ4 :      NmbNod =125; NmbCrd = 3; break;\n      default : return(0);\n   }\n\n   \/\/ Free and rebuild the mapping table if there were already one\n   if(kwd->OrdTab)\n      free(kwd->OrdTab);\n\n   if(!(kwd->OrdTab = malloc(NmbNod * sizeof(int))))\n      return(0);\n\n   \/\/ Find the corresponding Bezier coordinates from the source table\n   for(i=0;i<NmbNod;i++)\n   {\n      for(j=0;j<NmbNod;j++)\n      {\n         flg = 1;\n\n         for(k=0;k<NmbCrd;k++)\n            if(BasTab[ i * NmbCrd + k ] != OrdTab[ j * NmbCrd + k ])\n            {\n               flg = 0;\n               break;\n            }\n\n         if(flg)\n            kwd->OrdTab[j] = i;\n      }\n   }\n\n   \/\/ Check the ordering consistency\n   for(i=0;i<NmbNod;i++)\n   {\n      flg = 0;\n\n      for(j=0;j<NmbNod;j++)\n         if(kwd->OrdTab[j] == i)\n         {\n            flg = 1;\n            break;\n         }\n\n      if(!flg)\n      {\n         for(j=0;j<NmbNod;j++)\n            kwd->OrdTab[j] = j;\n\n         return(0);\n      }\n   }\n\n   return(1);\n}","target":0,"code_token_length":1292,"total_token_length":1528,"max_tokens_setting":2048}
+{"idx":259610,"func":"void HierarchicalBitmapRequester::ReconstructRegion(const RectAngle<LONG> &orgregion,const struct RectangleRequest *rr)\n{\n#if ACCUSOFT_CODE\n  class ColorTrafo *ctrafo = ColorTrafoOf(false,!rr->rr_bColorTrafo);\n  UBYTE i;\n  \n  if (m_bSubsampling && rr->rr_bUpsampling) { \n    for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {\n      class Component *comp = m_pFrame->ComponentOf(i);\n      UBYTE subx            = comp->SubXOf();\n      UBYTE suby            = comp->SubYOf();\n      class UpsamplerBase *up;  \/\/ upsampler\n      LONG bx,by;\n      RectAngle<LONG> blocks;\n      \/\/\n      \/\/ Compute the region of blocks\n      assert(subx > 0 && suby > 0);\n      if ((up = m_ppUpsampler[i])) {\n        LONG bwidth           = ((m_ulPixelWidth  + subx - 1) \/ subx + 7) >> 3;\n        LONG bheight          = ((m_ulPixelHeight + suby - 1) \/ suby + 7) >> 3;\n        LONG rx               = (subx > 1)?(1):(0);\n        LONG ry               = (suby > 1)?(1):(0);\n        \/\/ The +\/-1 include additional lines required for subsampling expansion\n        blocks.ra_MinX        = ((orgregion.ra_MinX \/ subx - rx) >> 3);\n        blocks.ra_MaxX        = ((orgregion.ra_MaxX \/ subx + rx) >> 3);\n        blocks.ra_MinY        = ((orgregion.ra_MinY \/ suby - ry) >> 3);\n        blocks.ra_MaxY        = ((orgregion.ra_MaxY \/ suby + ry) >> 3);\n        \/\/ Clip.\n        if (blocks.ra_MinX < 0)        blocks.ra_MinX = 0;\n        if (blocks.ra_MaxX >= bwidth)  blocks.ra_MaxX = bwidth - 1;\n        if (blocks.ra_MinY < 0)        blocks.ra_MinY = 0;\n        if (blocks.ra_MaxY >= bheight) blocks.ra_MaxY = bheight - 1;\n        up->SetBufferedRegion(blocks); \/\/ also removes the rectangle of blocks already buffered.\n        \/\/\n        for(by = blocks.ra_MinY;by <= blocks.ra_MaxY;by++) {\n          Pull8Lines(i);\n          for(bx = blocks.ra_MinX;bx <= blocks.ra_MaxX;bx++) {\n            LONG dst[64];\n            FetchRegion(bx,m_ppDecodingMCU + (i << 3),dst);\n            up->DefineRegion(bx,by,dst);\n          }\n          Release8Lines(i);\n        }\n      } else {\n        \/\/ Load into the decoding MCU\n        Pull8Lines(i);\n      }\n    }\n    \/\/ Now push blocks into the color transformer from the upsampler.\n    {\n      RectAngle<LONG> r;\n      ULONG minx   = orgregion.ra_MinX >> 3;\n      ULONG maxx   = orgregion.ra_MaxX >> 3;\n      ULONG miny   = orgregion.ra_MinY >> 3;\n      ULONG maxy   = orgregion.ra_MaxY >> 3;\n      ULONG x,y;\n      \n      if (maxy > m_ulMaxMCU)\n        maxy = m_ulMaxMCU;\n\n      for(y = miny,r.ra_MinY = orgregion.ra_MinY;y <= maxy;y++,r.ra_MinY = r.ra_MaxY + 1) {\n        r.ra_MaxY = (r.ra_MinY & -8) + 7;\n        if (r.ra_MaxY > orgregion.ra_MaxY)\n          r.ra_MaxY = orgregion.ra_MaxY;\n        \n        for(x = minx,r.ra_MinX = orgregion.ra_MinX;x <= maxx;x++,r.ra_MinX = r.ra_MaxX + 1) {\n          r.ra_MaxX = (r.ra_MinX & -8) + 7;\n          if (r.ra_MaxX > orgregion.ra_MaxX)\n            r.ra_MaxX = orgregion.ra_MaxX;\n          \n          for(i = 0;i < m_ucCount;i++) {\n            if (i >= rr->rr_usFirstComponent && i <= rr->rr_usLastComponent) {\n              ExtractBitmap(m_ppTempIBM[i],r,i);\n              if (m_ppUpsampler[i]) {\n                \/\/ Upsampled case, take from the upsampler, transform\n                \/\/ into the color buffer.\n                m_ppUpsampler[i]->UpsampleRegion(r,m_ppCTemp[i]);\n              } else {\n                FetchRegion(x,m_ppDecodingMCU + (i << 3),m_ppCTemp[i]);\n              }\n            } else {\n              \/\/ Not requested, zero the buffer.\n              memset(m_ppCTemp[i],0,sizeof(LONG) * 64);\n            }\n          }\n          ctrafo->YCbCr2RGB(r,m_ppTempIBM,m_ppCTemp,NULL);\n        }\n        \/\/\n        \/\/ Advance the quantized rows for the non-subsampled components,\n        \/\/ upsampled components have been advanced above.\n        for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {\n          if (m_ppUpsampler[i] == NULL)\n            Release8Lines(i);\n        }\n      }\n    }\n  } else { \n    \/\/ direct case, no upsampling required, residual coding possible, but not applied here.\n    RectAngle<LONG> r;\n    RectAngle<LONG> region = orgregion;\n    SubsampledRegion(region,rr);\n    ULONG minx   = region.ra_MinX >> 3;\n    ULONG maxx   = region.ra_MaxX >> 3;\n    ULONG miny   = region.ra_MinY >> 3;\n    ULONG maxy   = region.ra_MaxY >> 3;\n    ULONG x,y;\n      \n    if (maxy > m_ulMaxMCU)\n      maxy = m_ulMaxMCU;\n\n    for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {\n      Pull8Lines(i);\n    }\n    \n    for(y = miny,r.ra_MinY = region.ra_MinY;y <= maxy;y++,r.ra_MinY = r.ra_MaxY + 1) {\n      r.ra_MaxY = (r.ra_MinY & -8) + 7;\n      if (r.ra_MaxY > region.ra_MaxY)\n        r.ra_MaxY = region.ra_MaxY;\n        \n      for(x = minx,r.ra_MinX = region.ra_MinX;x <= maxx;x++,r.ra_MinX = r.ra_MaxX + 1) {\n        r.ra_MaxX = (r.ra_MinX & -8) + 7;\n        if (r.ra_MaxX > region.ra_MaxX)\n          r.ra_MaxX = region.ra_MaxX;\n\n        for(i = 0;i < m_ucCount;i++) {      \n          LONG *dst = m_ppCTemp[i];\n          if (i >= rr->rr_usFirstComponent && i <= rr->rr_usLastComponent) {\n            ExtractBitmap(m_ppTempIBM[i],r,i);\n            FetchRegion(x,m_ppDecodingMCU + (i << 3),dst);\n          } else {\n            memset(dst,0,sizeof(LONG) * 64);\n          }\n        }\n        \/\/\n        \/\/ Perform the color transformation now.\n        ctrafo->YCbCr2RGB(r,m_ppTempIBM,m_ppCTemp,NULL);\n      } \/\/ of loop over x\n      \/\/\n      \/\/ Advance the rows.\n      for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {\n        Release8Lines(i);\n      }\n    }\n  }\n#else\n  NOREF(orgregion);\n  NOREF(rr);\n#endif\n}","target":0,"code_token_length":1678,"total_token_length":1914,"max_tokens_setting":2048}
+{"idx":445921,"func":"save_archive_thread (GSimpleAsyncResult *result,\n\t\t     GObject            *object,\n\t\t     GCancellable       *cancellable)\n{\n\tSaveData             *save_data;\n\tLoadData             *load_data;\n\tstruct archive       *a, *b;\n\tstruct archive_entry *r_entry;\n\tint                   ra, rb;\n\n\tsave_data = g_simple_async_result_get_op_res_gpointer (result);\n\tload_data = LOAD_DATA (save_data);\n\n\tsave_data->b = b = archive_write_new ();\n\t_archive_write_set_format_from_context (b, save_data);\n\tarchive_write_open (b, save_data, save_data_open, save_data_write, save_data_close);\n\tarchive_write_set_bytes_in_last_block (b, 1);\n\n\ta = archive_read_new ();\n\tarchive_read_support_filter_all (a);\n\tarchive_read_support_format_all (a);\n\tarchive_read_open (a, load_data, load_data_open, load_data_read, load_data_close);\n\n\tif (save_data->begin_operation != NULL)\n\t\tsave_data->begin_operation (save_data, save_data->user_data);\n\n\twhile ((load_data->error == NULL) && (ra = archive_read_next_header (a, &r_entry)) == ARCHIVE_OK) {\n\t\tstruct archive_entry *w_entry;\n\t\tWriteAction           action;\n\n\t\tif (g_cancellable_is_cancelled (cancellable))\n\t\t\tbreak;\n\n\t\taction = WRITE_ACTION_WRITE_ENTRY;\n\t\tw_entry = archive_entry_clone (r_entry);\n\t\tif (save_data->entry_action != NULL)\n\t\t\taction = save_data->entry_action (save_data, w_entry, save_data->user_data);\n\n\t\tif (action == WRITE_ACTION_WRITE_ENTRY) {\n\t\t\tconst void   *buffer;\n\t\t\tsize_t        buffer_size;\n\t\t\t__LA_INT64_T  offset;\n\n\t\t\trb = archive_write_header (b, w_entry);\n\t\t\tif (rb != ARCHIVE_OK)\n\t\t\t\tbreak;\n\n\t\t\tswitch (archive_entry_filetype (r_entry)) {\n\t\t\tcase AE_IFREG:\n\t\t\t\twhile ((ra = archive_read_data_block (a, &buffer, &buffer_size, &offset)) == ARCHIVE_OK) {\n\t\t\t\t\tarchive_write_data (b, buffer, buffer_size);\n\t\t\t\t\tfr_archive_progress_inc_completed_bytes (load_data->archive, buffer_size);\n\t\t\t\t}\n\n\t\t\t\tif (ra != ARCHIVE_EOF)\n\t\t\t\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\trb = archive_write_finish_entry (b);\n\t\t}\n\t\telse if (action == WRITE_ACTION_SKIP_ENTRY)\n\t\t\tfr_archive_progress_inc_completed_bytes (load_data->archive, archive_entry_size (r_entry));\n\n\t\tarchive_entry_free (w_entry);\n\t}\n\n\tif (g_error_matches (load_data->error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))\n\t\tra = ARCHIVE_EOF;\n\n\tif (save_data->end_operation != NULL)\n\t\tsave_data->end_operation (save_data, save_data->user_data);\n\n\trb = archive_write_close (b);\n\n\tif ((load_data->error == NULL) && (ra != ARCHIVE_EOF))\n\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));\n\tif ((load_data->error == NULL) && (rb != ARCHIVE_OK))\n\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (b));\n\tif (load_data->error == NULL)\n\t\tg_cancellable_set_error_if_cancelled (cancellable, &load_data->error);\n\tif (load_data->error != NULL)\n\t\tg_simple_async_result_set_from_error (result, load_data->error);\n\n\tarchive_read_free (a);\n\tarchive_write_free (b);\n\tsave_data_free (save_data);\n}","target":0,"code_token_length":791,"total_token_length":1027,"max_tokens_setting":2048}
+{"idx":223450,"func":"static BOOL optimize_class_ranges(compiler_common *common, const sljit_u8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks)\n{\n\/* May destroy TMP1. *\/\nDEFINE_COMPILER;\nint ranges[MAX_CLASS_RANGE_SIZE];\nsljit_u8 bit, cbit, all;\nint i, byte, length = 0;\n\nbit = bits[0] & 0x1;\n\/* All bits will be zero or one (since bit is zero or one). *\/\nall = -bit;\n\nfor (i = 0; i < 256; )\n  {\n  byte = i >> 3;\n  if ((i & 0x7) == 0 && bits[byte] == all)\n    i += 8;\n  else\n    {\n    cbit = (bits[byte] >> (i & 0x7)) & 0x1;\n    if (cbit != bit)\n      {\n      if (length >= MAX_CLASS_RANGE_SIZE)\n        return FALSE;\n      ranges[length] = i;\n      length++;\n      bit = cbit;\n      all = -cbit;\n      }\n    i++;\n    }\n  }\n\nif (((bit == 0) && nclass) || ((bit == 1) && !nclass))\n  {\n  if (length >= MAX_CLASS_RANGE_SIZE)\n    return FALSE;\n  ranges[length] = 256;\n  length++;\n  }\n\nif (length < 0 || length > 4)\n  return FALSE;\n\nbit = bits[0] & 0x1;\nif (invert) bit ^= 0x1;\n\n\/* No character is accepted. *\/\nif (length == 0 && bit == 0)\n  add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n\nswitch(length)\n  {\n  case 0:\n  \/* When bit != 0, all characters are accepted. *\/\n  return TRUE;\n\n  case 1:\n  add_jump(compiler, backtracks, CMP(bit == 0 ? SLJIT_LESS : SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));\n  return TRUE;\n\n  case 2:\n  if (ranges[0] + 1 != ranges[1])\n    {\n    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);\n    add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_LESS : SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));\n    }\n  else\n    add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_EQUAL : SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));\n  return TRUE;\n\n  case 3:\n  if (bit != 0)\n    {\n    add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));\n    if (ranges[0] + 1 != ranges[1])\n      {\n      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);\n      add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));\n      }\n    else\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));\n    return TRUE;\n    }\n\n  add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[0]));\n  if (ranges[1] + 1 != ranges[2])\n    {\n    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1]);\n    add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1]));\n    }\n  else\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1]));\n  return TRUE;\n\n  case 4:\n  if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2])\n      && (ranges[0] | (ranges[2] - ranges[0])) == ranges[2]\n      && (ranges[1] & (ranges[2] - ranges[0])) == 0\n      && is_powerof2(ranges[2] - ranges[0]))\n    {\n    SLJIT_ASSERT((ranges[0] & (ranges[2] - ranges[0])) == 0 && (ranges[2] & ranges[3] & (ranges[2] - ranges[0])) != 0);\n    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]);\n    if (ranges[2] + 1 != ranges[3])\n      {\n      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);\n      add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_LESS : SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));\n      }\n    else\n      add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_EQUAL : SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));\n    return TRUE;\n    }\n\n  if (bit != 0)\n    {\n    i = 0;\n    if (ranges[0] + 1 != ranges[1])\n      {\n      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);\n      add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));\n      i = ranges[0];\n      }\n    else\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));\n\n    if (ranges[2] + 1 != ranges[3])\n      {\n      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - i);\n      add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));\n      }\n    else\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2] - i));\n    return TRUE;\n    }\n\n  OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);\n  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[0]));\n  if (ranges[1] + 1 != ranges[2])\n    {\n    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]);\n    add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1]));\n    }\n  else\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));\n  return TRUE;\n\n  default:\n  SLJIT_UNREACHABLE();\n  return FALSE;\n  }\n}","target":0,"code_token_length":1741,"total_token_length":1977,"max_tokens_setting":2048}
+{"idx":215216,"func":"__zzip_fetch_disk_trailer(int fd, zzip_off_t filesize,\n                          struct _disk_trailer *_zzip_restrict trailer,\n                          zzip_plugin_io_t io)\n{\n#ifdef DEBUG\n#define return(val) { e=val; HINT2(\"%s\", zzip_strerror(e)); goto cleanup; }\n#else\n#define return(val) { e=val; goto cleanup; }\n#endif\n    register int e;\n\n#ifndef _LOWSTK\n    auto char buffer[2 * ZZIP_BUFSIZ];\n    char *buf = buffer;\n#else\n    char *buf = malloc(2 * ZZIP_BUFSIZ);\n#endif\n    zzip_off_t offset = 0;\n    zzip_ssize_t maplen = 0;    \/* mmap(),read(),getpagesize() use size_t !! *\/\n    char *fd_map = 0;\n\n    if (! trailer)\n        { return(EINVAL); }\n\n    if (filesize < __sizeof(struct zzip_disk_trailer))\n          { return(ZZIP_DIR_TOO_SHORT); }\n\n    if (! buf)\n        { return(ZZIP_OUTOFMEM); }\n\n    offset = filesize;          \/* a.k.a. old offset *\/\n    while (1)                   \/* outer loop *\/\n    {\n        register unsigned char *mapped;\n\n        if (offset <= 0)\n            { return(ZZIP_DIR_EDH_MISSING); }\n\n        \/* trailer cannot be farther away than 64K from fileend *\/\n        if (filesize - offset > 64 * 1024)\n            { return(ZZIP_DIR_EDH_MISSING); }\n\n        \/* the new offset shall overlap with the area after the old offset! *\/\n        if (USE_MMAP && io->fd.sys)\n        {\n            zzip_off_t mapoff = offset;\n            {\n                zzip_ssize_t pagesize = _zzip_getpagesize(io->fd.sys);\n                if (pagesize < ZZIP_BUFSIZ)\n                    goto non_mmap;      \/* an error? *\/\n                if (mapoff == filesize && filesize > pagesize)\n                    mapoff -= pagesize;\n                if (mapoff < pagesize)\n                {\n                    maplen = (zzip_ssize_t) mapoff + pagesize;\n                    mapoff = 0;\n                } else\n                {\n                    mapoff -= pagesize;\n                    maplen = 2 * pagesize;\n                    if ((zzip_ssize_t) mapoff & (pagesize - 1))\n                    {           \/*only 1. run *\/\n                        pagesize -= (zzip_ssize_t) mapoff & (pagesize - 1);\n                        mapoff += pagesize;\n                        maplen -= pagesize;\n                    }\n                }\n                if (mapoff + maplen > filesize)\n                    maplen = filesize - mapoff;\n            }\n\n            fd_map = _zzip_mmap(io->fd.sys, fd, mapoff, (zzip_size_t) maplen);\n            if (fd_map == MAP_FAILED)\n                goto non_mmap;\n            mapped = (unsigned char *) fd_map;\n            offset = mapoff;    \/* success *\/\n            HINT3(\"mapped *%p len=%li\", fd_map, (long) maplen);\n        } else\n        {\n          non_mmap:\n            fd_map = 0;         \/* have no mmap *\/\n            {\n                zzip_off_t pagesize = ZZIP_BUFSIZ;\n                if (offset == filesize && filesize > pagesize)\n                    offset -= pagesize;\n                if (offset < pagesize)\n                {\n                    maplen = (zzip_ssize_t) offset + pagesize;\n                    offset = 0;\n                } else\n                {\n                    offset -= pagesize;\n                    maplen = 2 * pagesize;\n                    if ((zzip_ssize_t) offset & (pagesize - 1))\n                    {           \/*on 1st run *\/\n                        pagesize -= (zzip_ssize_t) offset & (pagesize - 1);\n                        offset += pagesize;\n                        maplen -= pagesize;\n                    }\n                }\n                if (offset + maplen > filesize)\n                    maplen = filesize - offset;\n            }\n\n            if (io->fd.seeks(fd, offset, SEEK_SET) < 0)\n                { return(ZZIP_DIR_SEEK); }\n            if (io->fd.read(fd, buf, (zzip_size_t) maplen) < maplen)\n                { return(ZZIP_DIR_READ); }\n            mapped = (unsigned char *) buf;     \/* success *\/\n            HINT5(\"offs=$%lx len=%li filesize=%li pagesize=%i\",\n                  (long) offset, (long) maplen, (long) filesize, ZZIP_BUFSIZ);\n        }\n\n        {                       \/* now, check for the trailer-magic, hopefully near the end of file *\/\n            register unsigned char *end = mapped + maplen;\n            register unsigned char *tail;\n            for (tail = end - 1; (tail >= mapped); tail--)\n            {\n                if ((*tail == 'P') &&   \/* quick pre-check for trailer magic *\/\n                    end - tail >= __sizeof(struct zzip_disk_trailer) - 2 &&\n                    zzip_disk_trailer_check_magic(tail))\n                {\n#                  ifndef ZZIP_DISK64_TRAILER\n                    \/* if the file-comment is not present, it happens\n                       that the z_comment field often isn't either *\/\n                    if (end - tail >= __sizeof(*trailer))\n                    {\n                        memcpy(trailer, tail, sizeof(*trailer));\n                    } else\n                    {\n                        memcpy(trailer, tail, sizeof(*trailer) - 2);\n                        trailer->z_comment[0] = 0;\n                        trailer->z_comment[1] = 0;\n                    }\n#                  else\n                    struct zzip_disk_trailer *orig =\n                        (struct zzip_disk_trailer *) tail;\n                    trailer->zz_tail = tail;\n                    trailer->zz_entries = zzip_disk_trailer_localentries(orig);\n                    trailer->zz_finalentries =\n                        zzip_disk_trailer_finalentries(orig);\n                    trailer->zz_rootseek = zzip_disk_trailer_rootseek(orig);\n                    trailer->zz_rootsize = zzip_disk_trailer_rootsize(orig);\n#                  endif\n\n                    __fixup_rootseek(offset + tail - mapped, trailer);\n                    { return(0); }\n                } else if ((*tail == 'P') &&\n                           end - tail >=\n                           __sizeof(struct zzip_disk64_trailer) - 2\n                           && zzip_disk64_trailer_check_magic(tail))\n                {\n#                  ifndef ZZIP_DISK64_TRAILER\n                    return (ZZIP_DIR_LARGEFILE);\n#                  else\n                    struct zzip_disk64_trailer *orig =\n                        (struct zzip_disk64_trailer *) tail;\n                    trailer->zz_tail = tail;\n                    trailer->zz_entries =\n                        zzip_disk64_trailer_localentries(orig);\n                    trailer->zz_finalentries =\n                        zzip_disk64_trailer_finalentries(orig);\n                    trailer->zz_rootseek = zzip_disk64_trailer_rootseek(orig);\n                    trailer->zz_rootsize = zzip_disk64_trailer_rootsize(orig);\n                    { return(0); }\n#                  endif\n                }\n            }\n        }\n\n        if (USE_MMAP && fd_map)\n        {\n            HINT3(\"unmap *%p len=%li\", fd_map, (long) maplen);\n            _zzip_munmap(io->fd.sys, fd_map, (zzip_size_t) maplen);\n            fd_map = 0;\n        }\n    }                           \/*outer loop *\/\n\n  cleanup:\n    if (USE_MMAP && fd_map)\n    {\n        HINT3(\"unmap *%p len=%li\", fd_map, (long) maplen);\n        _zzip_munmap(io->fd.sys, fd_map, (zzip_size_t) maplen);\n    }\n#   ifdef _LOWSTK\n    free(buf);\n#   endif\n#   undef return\n    return e;\n}","target":1,"code_token_length":1671,"total_token_length":1907,"max_tokens_setting":2048}
+{"idx":291818,"func":"static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,\n\t\t\t\t       struct rdma_cm_event *ev)\n{\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\tstruct rtrs_clt_sess *clt = clt_path->clt;\n\tconst struct rtrs_msg_conn_rsp *msg;\n\tu16 version, queue_depth;\n\tint errno;\n\tu8 len;\n\n\tmsg = ev->param.conn.private_data;\n\tlen = ev->param.conn.private_data_len;\n\tif (len < sizeof(*msg)) {\n\t\trtrs_err(clt, \"Invalid RTRS connection response\\n\");\n\t\treturn -ECONNRESET;\n\t}\n\tif (le16_to_cpu(msg->magic) != RTRS_MAGIC) {\n\t\trtrs_err(clt, \"Invalid RTRS magic\\n\");\n\t\treturn -ECONNRESET;\n\t}\n\tversion = le16_to_cpu(msg->version);\n\tif (version >> 8 != RTRS_PROTO_VER_MAJOR) {\n\t\trtrs_err(clt, \"Unsupported major RTRS version: %d, expected %d\\n\",\n\t\t\t  version >> 8, RTRS_PROTO_VER_MAJOR);\n\t\treturn -ECONNRESET;\n\t}\n\terrno = le16_to_cpu(msg->errno);\n\tif (errno) {\n\t\trtrs_err(clt, \"Invalid RTRS message: errno %d\\n\",\n\t\t\t  errno);\n\t\treturn -ECONNRESET;\n\t}\n\tif (con->c.cid == 0) {\n\t\tqueue_depth = le16_to_cpu(msg->queue_depth);\n\n\t\tif (clt_path->queue_depth > 0 && queue_depth != clt_path->queue_depth) {\n\t\t\trtrs_err(clt, \"Error: queue depth changed\\n\");\n\n\t\t\t\/*\n\t\t\t * Stop any more reconnection attempts\n\t\t\t *\/\n\t\t\tclt_path->reconnect_attempts = -1;\n\t\t\trtrs_err(clt,\n\t\t\t\t\"Disabling auto-reconnect. Trigger a manual reconnect after issue is resolved\\n\");\n\t\t\treturn -ECONNRESET;\n\t\t}\n\n\t\tif (!clt_path->rbufs) {\n\t\t\tclt_path->rbufs = kcalloc(queue_depth,\n\t\t\t\t\t\t  sizeof(*clt_path->rbufs),\n\t\t\t\t\t\t  GFP_KERNEL);\n\t\t\tif (!clt_path->rbufs)\n\t\t\t\treturn -ENOMEM;\n\t\t}\n\t\tclt_path->queue_depth = queue_depth;\n\t\tclt_path->s.signal_interval = min_not_zero(queue_depth,\n\t\t\t\t\t\t(unsigned short) SERVICE_CON_QUEUE_DEPTH);\n\t\tclt_path->max_hdr_size = le32_to_cpu(msg->max_hdr_size);\n\t\tclt_path->max_io_size = le32_to_cpu(msg->max_io_size);\n\t\tclt_path->flags = le32_to_cpu(msg->flags);\n\t\tclt_path->chunk_size = clt_path->max_io_size + clt_path->max_hdr_size;\n\n\t\t\/*\n\t\t * Global IO size is always a minimum.\n\t\t * If while a reconnection server sends us a value a bit\n\t\t * higher - client does not care and uses cached minimum.\n\t\t *\n\t\t * Since we can have several sessions (paths) restablishing\n\t\t * connections in parallel, use lock.\n\t\t *\/\n\t\tmutex_lock(&clt->paths_mutex);\n\t\tclt->queue_depth = clt_path->queue_depth;\n\t\tclt->max_io_size = min_not_zero(clt_path->max_io_size,\n\t\t\t\t\t\tclt->max_io_size);\n\t\tmutex_unlock(&clt->paths_mutex);\n\n\t\t\/*\n\t\t * Cache the hca_port and hca_name for sysfs\n\t\t *\/\n\t\tclt_path->hca_port = con->c.cm_id->port_num;\n\t\tscnprintf(clt_path->hca_name, sizeof(clt_path->hca_name),\n\t\t\t  clt_path->s.dev->ib_dev->name);\n\t\tclt_path->s.src_addr = con->c.cm_id->route.addr.src_addr;\n\t\t\/* set for_new_clt, to allow future reconnect on any path *\/\n\t\tclt_path->for_new_clt = 1;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":859,"total_token_length":1095,"max_tokens_setting":2048}
+{"idx":432714,"func":"static void lite_font_map( wmfAPI* API, wmfFont* font)\n{\n  wmfFontData\n    *font_data;\n\n  wmf_magick_font_t\n    *magick_font;\n\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  ExceptionInfo\n    *exception;\n\n  const TypeInfo\n    *type_info,\n    *type_info_base;\n\n  const char\n    *wmf_font_name;\n\n  if (font == 0)\n    return;\n\n  font_data = (wmfFontData*)API->font_data;\n  font->user_data = font_data->user_data;\n  magick_font = (wmf_magick_font_t*)font->user_data;\n  wmf_font_name = WMF_FONT_NAME(font);\n\n  if (magick_font->ps_name != (char *) NULL)\n    magick_font->ps_name=DestroyString(magick_font->ps_name);\n\n  exception=ddata->exception;\n  type_info_base=GetTypeInfo(\"*\",exception);\n  if (type_info_base == 0)\n     return;\n\n  \/* Certain short-hand font names are not the proper Windows names\n     and should be promoted to the proper names *\/\n  if (LocaleCompare(wmf_font_name,\"Times\") == 0)\n    wmf_font_name = \"Times New Roman\";\n  else if (LocaleCompare(wmf_font_name,\"Courier\") == 0)\n    wmf_font_name = \"Courier New\";\n\n  \/* Look for a family-based best-match *\/\n  if (!magick_font->ps_name)\n    {\n      int\n        target_weight;\n\n      if (WMF_FONT_WEIGHT(font) == 0)\n        target_weight = 400;\n      else\n        target_weight = WMF_FONT_WEIGHT(font);\n      type_info=GetTypeInfoByFamily(wmf_font_name,AnyStyle,AnyStretch,\n        target_weight,exception);\n      if (type_info == (const TypeInfo *) NULL)\n        type_info=GetTypeInfoByFamily(wmf_font_name,AnyStyle,AnyStretch,0,\n          exception);\n      if (type_info != (const TypeInfo *) NULL)\n        CloneString(&magick_font->ps_name,type_info->name);\n    }\n\n  \/* Now let's try simple substitution mappings from WMFFontMap *\/\n  if (!magick_font->ps_name)\n    {\n      char\n        target[MagickPathExtent];\n\n      int\n        target_weight = 400,\n        want_italic = MagickFalse,\n        want_bold = MagickFalse,\n        i;\n\n      if ( WMF_FONT_WEIGHT(font) != 0 )\n        target_weight = WMF_FONT_WEIGHT(font);\n\n      if ( (target_weight > 550) || ((strstr(wmf_font_name,\"Bold\") ||\n                                     strstr(wmf_font_name,\"Heavy\") ||\n                                     strstr(wmf_font_name,\"Black\"))) )\n        want_bold = MagickTrue;\n\n      if ( (WMF_FONT_ITALIC(font)) || ((strstr(wmf_font_name,\"Italic\") ||\n                                       strstr(wmf_font_name,\"Oblique\"))) )\n        want_italic = MagickTrue;\n\n      (void) CopyMagickString(target,\"Times\",MagickPathExtent);\n      for( i=0; SubFontMap[i].name != NULL; i++ )\n        {\n          if (LocaleCompare(wmf_font_name, SubFontMap[i].name) == 0)\n            {\n              (void) CopyMagickString(target,SubFontMap[i].mapping,\n                MagickPathExtent);\n              break;\n            }\n        }\n\n      for( i=0; WMFFontMap[i].name != NULL; i++ )\n        {\n          if (LocaleNCompare(WMFFontMap[i].name,target,strlen(WMFFontMap[i].name)) == 0)\n            {\n              if (want_bold && want_italic)\n                CloneString(&magick_font->ps_name,WMFFontMap[i].bolditalic);\n              else if (want_italic)\n                CloneString(&magick_font->ps_name,WMFFontMap[i].italic);\n              else if (want_bold)\n                CloneString(&magick_font->ps_name,WMFFontMap[i].bold);\n              else\n                CloneString(&magick_font->ps_name,WMFFontMap[i].normal);\n            }\n        }\n    }\n\n#if 0\n  printf(\"\\nlite_font_map\\n\");\n  printf(\"WMF_FONT_NAME           = \\\"%s\\\"\\n\", WMF_FONT_NAME(font));\n  printf(\"WMF_FONT_WEIGHT         = %i\\n\",  WMF_FONT_WEIGHT(font));\n  printf(\"WMF_FONT_PSNAME         = \\\"%s\\\"\\n\", WMF_FONT_PSNAME(font));\n  fflush(stdout);\n#endif\n\n}","target":0,"code_token_length":982,"total_token_length":1218,"max_tokens_setting":2048}
+{"idx":439168,"func":"static Image *ReadRAWImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  const unsigned char\n    *pixels;\n\n  Image\n    *canvas_image,\n    *image;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  size_t\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  if ((image->columns == 0) || (image->rows == 0))\n    ThrowReaderException(OptionError,\"MustSpecifyImageSize\");\n  status=SetImageExtent(image,image->columns,image->rows);\n  if (status == MagickFalse)\n    {\n      InheritException(exception,&image->exception);\n      return(DestroyImageList(image));\n    }\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (DiscardBlobBytes(image,(MagickSizeType) image->offset) == MagickFalse)\n    ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  \/*\n    Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]).\n  *\/\n  canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,\n    exception);\n  if (canvas_image == (Image *) NULL)\n    ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n  (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod);\n  quantum_type=GrayQuantum;\n  quantum_info=AcquireQuantumInfo(image_info,canvas_image);\n  if (quantum_info == (QuantumInfo *) NULL)\n    {\n      canvas_image=DestroyImage(canvas_image);\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    }\n  pixels=(const unsigned char *) NULL;\n  if (image_info->number_scenes != 0)\n    while (image->scene < image_info->scene)\n    {\n      \/*\n        Skip to next image.\n      *\/\n      image->scene++;\n      length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);\n      for (y=0; y < (ssize_t) image->rows; y++)\n      {\n        pixels=(const unsigned char *) ReadBlobStream(image,length,\n          GetQuantumPixels(quantum_info),&count);\n        if (count != (ssize_t) length)\n          break;\n      }\n    }\n  scene=0;\n  count=0;\n  length=0;\n  status=MagickTrue;\n  do\n  {\n    \/*\n      Read pixels to virtual canvas image then push to image.\n    *\/\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      break;\n    if (scene == 0)\n      {\n        length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);\n        pixels=(const unsigned char *) ReadBlobStream(image,length,\n          GetQuantumPixels(quantum_info),&count);\n        if (count != (ssize_t) length)\n          break;\n      }\n    for (y=0; y < (ssize_t) image->extract_info.height; y++)\n    {\n      register const PixelPacket\n        *magick_restrict p;\n\n      register PixelPacket\n        *magick_restrict q;\n\n      register ssize_t\n        x;\n\n      if (count != (ssize_t) length)\n        {\n          status=MagickFalse;\n          ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n            image->filename);\n          break;\n        }\n      q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,exception);\n      if (q == (PixelPacket *) NULL)\n        break;\n      length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,quantum_info,\n        quantum_type,pixels,exception);\n      if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)\n        break;\n      if (((y-image->extract_info.y) >= 0) &&\n          ((y-image->extract_info.y) < (ssize_t) image->rows))\n        {\n          p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,\n            image->columns,1,exception);\n          q=QueueAuthenticPixels(image,0,y-image->extract_info.y,image->columns,\n            1,exception);\n          if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(q,GetPixelRed(p));\n            SetPixelGreen(q,GetPixelGreen(p));\n            SetPixelBlue(q,GetPixelBlue(p));\n            p++;\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n        }\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n      pixels=(const unsigned char *) ReadBlobStream(image,length,\n        GetQuantumPixels(quantum_info),&count);\n      if (count != (ssize_t) length)\n        break;\n    }\n    SetQuantumImageType(image,quantum_type);\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    if (count == (ssize_t) length)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n    scene++;\n  } while (count == (ssize_t) length);\n  quantum_info=DestroyQuantumInfo(quantum_info);\n  InheritException(exception,&canvas_image->exception);\n  InheritException(exception,&image->exception);\n  canvas_image=DestroyImage(canvas_image);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":1557,"total_token_length":1793,"max_tokens_setting":2048}
+{"idx":293757,"func":"static RList *filter_kexts(RKernelCacheObj *obj, RBinFile *bf) {\n\tRCFValueArray *kext_array = NULL;\n\tRListIter *iter;\n\tRCFKeyValue *item;\n\tr_list_foreach (obj->prelink_info->pairs, iter, item) {\n\t\tif (!strcmp (item->key, \"_PrelinkInfoDictionary\")) {\n\t\t\tkext_array = (RCFValueArray*) item->value;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!kext_array) {\n\t\treturn NULL;\n\t}\n\n\tRList *kexts = r_list_newf ((RListFree) &r_kext_free);\n\tif (!kexts) {\n\t\treturn NULL;\n\t}\n\n\tbool is_sorted = true;\n\tRKext *prev_kext = NULL;\n\tRCFValueDict *kext_item;\n\tr_list_foreach (kext_array->values, iter, kext_item) {\n\t\tRKext *kext = R_NEW0 (RKext);\n\t\tif (!kext) {\n\t\t\tR_FREE (kexts);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tint kext_incomplete = 5;\n\t\tRListIter *internal_iter;\n\t\tr_list_foreach (kext_item->pairs, internal_iter, item) {\n\t\t\tif (!strcmp (item->key, \"CFBundlePackageType\")) {\n\t\t\t\tif (item->value->type != R_CF_STRING) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tRCFValueString *type = (RCFValueString*) item->value;\n\t\t\t\tif (strcmp (type->value, \"KEXT\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tkext_incomplete--;\n\t\t\t}\n\n\t\t\tif (!strcmp (item->key, \"_PrelinkExecutableLoadAddr\")) {\n\t\t\t\tif (item->value->type == R_CF_INTEGER) {\n\t\t\t\t\tkext_incomplete--;\n\t\t\t\t\tkext->vaddr = ((RCFValueInteger*) item->value)->value;\n\t\t\t\t\tkext->range.offset = kext->vaddr - obj->pa2va_exec;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!strcmp (item->key, \"_PrelinkExecutableSize\")) {\n\t\t\t\tkext_incomplete--;\n\t\t\t\tif (item->value->type == R_CF_INTEGER) {\n\t\t\t\t\tkext->range.size = ((RCFValueInteger*) item->value)->value;\n\t\t\t\t} else {\n\t\t\t\t\tkext->range.size = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!strcmp (item->key, \"_PrelinkKmodInfo\")) {\n\t\t\t\tif (item->value->type == R_CF_INTEGER) {\n\t\t\t\t\tkext_incomplete--;\n\t\t\t\t\tkext->mod_info = ((RCFValueInteger*) item->value)->value;\n\t\t\t\t\tkext->mod_info -= obj->pa2va_data;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!strcmp (item->key, \"CFBundleIdentifier\")) {\n\t\t\t\tif (item->value->type == R_CF_STRING) {\n\t\t\t\t\tkext_incomplete--;\n\t\t\t\t\tkext->name = ((RCFValueString*) item->value)->value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (kext_incomplete) {\n\t\t\tr_kext_free (kext);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (prev_kext && kext->vaddr < prev_kext->vaddr) {\n\t\t\tis_sorted = false;\n\t\t}\n\t\tprev_kext = kext;\n\n\t\tkext->mach0 = create_kext_mach0 (obj, kext, bf);\n\t\tif (!kext->mach0) {\n\t\t\tr_kext_free (kext);\n\t\t\tcontinue;\n\t\t}\n\n\t\tr_kext_fill_text_range (kext);\n\n\t\tr_list_push (kexts, kext);\n\t}\n\n\tif (!is_sorted) {\n\t\teprintf (\"SORTING KEXTs...\\n\");\n\t\tr_list_sort (kexts, kexts_sort_vaddr_func);\n\t}\n\treturn kexts;\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048}
+{"idx":326635,"func":"restore_entry(struct archive_write_disk *a)\n{\n\tint ret = ARCHIVE_OK, en;\n\n\tif (a->flags & ARCHIVE_EXTRACT_UNLINK && !S_ISDIR(a->mode)) {\n\t\t\/*\n\t\t * TODO: Fix this.  Apparently, there are platforms\n\t\t * that still allow root to hose the entire filesystem\n\t\t * by unlinking a dir.  The S_ISDIR() test above\n\t\t * prevents us from using unlink() here if the new\n\t\t * object is a dir, but that doesn't mean the old\n\t\t * object isn't a dir.\n\t\t *\/\n\t\tif (a->flags & ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS)\n\t\t\t(void)clear_nochange_fflags(a);\n\t\tif (unlink(a->name) == 0) {\n\t\t\t\/* We removed it, reset cached stat. *\/\n\t\t\ta->pst = NULL;\n\t\t} else if (errno == ENOENT) {\n\t\t\t\/* File didn't exist, that's just as good. *\/\n\t\t} else if (rmdir(a->name) == 0) {\n\t\t\t\/* It was a dir, but now it's gone. *\/\n\t\t\ta->pst = NULL;\n\t\t} else {\n\t\t\t\/* We tried, but couldn't get rid of it. *\/\n\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t    \"Could not unlink\");\n\t\t\treturn(ARCHIVE_FAILED);\n\t\t}\n\t}\n\n\t\/* Try creating it first; if this fails, we'll try to recover. *\/\n\ten = create_filesystem_object(a);\n\n\tif ((en == ENOTDIR || en == ENOENT)\n\t    && !(a->flags & ARCHIVE_EXTRACT_NO_AUTODIR)) {\n\t\t\/* If the parent dir doesn't exist, try creating it. *\/\n\t\tcreate_parent_dir(a, a->name);\n\t\t\/* Now try to create the object again. *\/\n\t\ten = create_filesystem_object(a);\n\t}\n\n\tif ((en == ENOENT) && (archive_entry_hardlink(a->entry) != NULL)) {\n\t\tarchive_set_error(&a->archive, en,\n\t\t    \"Hard-link target '%s' does not exist.\",\n\t\t    archive_entry_hardlink(a->entry));\n\t\treturn (ARCHIVE_FAILED);\n\t}\n\n\tif ((en == EISDIR || en == EEXIST)\n\t    && (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {\n\t\t\/* If we're not overwriting, we're done. *\/\n\t\tif (S_ISDIR(a->mode)) {\n\t\t\t\/* Don't overwrite any settings on existing directories. *\/\n\t\t\ta->todo = 0;\n\t\t}\n\t\tarchive_entry_unset_size(a->entry);\n\t\treturn (ARCHIVE_OK);\n\t}\n\n\t\/*\n\t * Some platforms return EISDIR if you call\n\t * open(O_WRONLY | O_EXCL | O_CREAT) on a directory, some\n\t * return EEXIST.  POSIX is ambiguous, requiring EISDIR\n\t * for open(O_WRONLY) on a dir and EEXIST for open(O_EXCL | O_CREAT)\n\t * on an existing item.\n\t *\/\n\tif (en == EISDIR) {\n\t\t\/* A dir is in the way of a non-dir, rmdir it. *\/\n\t\tif (rmdir(a->name) != 0) {\n\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t    \"Can't remove already-existing dir\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\t\ta->pst = NULL;\n\t\t\/* Try again. *\/\n\t\ten = create_filesystem_object(a);\n\t} else if (en == EEXIST) {\n\t\t\/*\n\t\t * We know something is in the way, but we don't know what;\n\t\t * we need to find out before we go any further.\n\t\t *\/\n\t\tint r = 0;\n\t\t\/*\n\t\t * The SECURE_SYMLINKS logic has already removed a\n\t\t * symlink to a dir if the client wants that.  So\n\t\t * follow the symlink if we're creating a dir.\n\t\t *\/\n\t\tif (S_ISDIR(a->mode))\n\t\t\tr = la_stat(a->name, &a->st);\n\t\t\/*\n\t\t * If it's not a dir (or it's a broken symlink),\n\t\t * then don't follow it.\n\t\t *\/\n\t\tif (r != 0 || !S_ISDIR(a->mode))\n\t\t\tr = lstat(a->name, &a->st);\n\t\tif (r != 0) {\n\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t    \"Can't stat existing object\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\n\t\t\/*\n\t\t * NO_OVERWRITE_NEWER doesn't apply to directories.\n\t\t *\/\n\t\tif ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER)\n\t\t    &&  !S_ISDIR(a->st.st_mode)) {\n\t\t\tif (!older(&(a->st), a->entry)) {\n\t\t\t\tarchive_entry_unset_size(a->entry);\n\t\t\t\treturn (ARCHIVE_OK);\n\t\t\t}\n\t\t}\n\n\t\t\/* If it's our archive, we're done. *\/\n\t\tif (a->skip_file_set &&\n\t\t    a->st.st_dev == (dev_t)a->skip_file_dev &&\n\t\t    a->st.st_ino == (ino_t)a->skip_file_ino) {\n\t\t\tarchive_set_error(&a->archive, 0,\n\t\t\t    \"Refusing to overwrite archive\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\n\t\tif (!S_ISDIR(a->st.st_mode)) {\n\t\t\tif (a->flags & ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS)\n\t\t\t\t(void)clear_nochange_fflags(a);\n\n\t\t\tif ((a->flags & ARCHIVE_EXTRACT_SAFE_WRITES) &&\n\t\t\t    S_ISREG(a->st.st_mode)) {\n\t\t\t\t\/* Use a temporary file to extract *\/\n\t\t\t\tif ((a->fd = la_mktemp(a)) == -1) {\n\t\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t\t    \"Can't create temporary file\");\n\t\t\t\t\treturn ARCHIVE_FAILED;\n\t\t\t\t}\n\t\t\t\ta->pst = NULL;\n\t\t\t\ten = 0;\n\t\t\t} else {\n\t\t\t\t\/* A non-dir is in the way, unlink it. *\/\n\t\t\t\tif (unlink(a->name) != 0) {\n\t\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t\t    \"Can't unlink already-existing \"\n\t\t\t\t\t    \"object\");\n\t\t\t\t\treturn (ARCHIVE_FAILED);\n\t\t\t\t}\n\t\t\t\ta->pst = NULL;\n\t\t\t\t\/* Try again. *\/\n\t\t\t\ten = create_filesystem_object(a);\n\t\t\t}\n\t\t} else if (!S_ISDIR(a->mode)) {\n\t\t\t\/* A dir is in the way of a non-dir, rmdir it. *\/\n\t\t\tif (a->flags & ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS)\n\t\t\t\t(void)clear_nochange_fflags(a);\n\t\t\tif (rmdir(a->name) != 0) {\n\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t    \"Can't replace existing directory with non-directory\");\n\t\t\t\treturn (ARCHIVE_FAILED);\n\t\t\t}\n\t\t\t\/* Try again. *\/\n\t\t\ten = create_filesystem_object(a);\n\t\t} else {\n\t\t\t\/*\n\t\t\t * There's a dir in the way of a dir.  Don't\n\t\t\t * waste time with rmdir()\/mkdir(), just fix\n\t\t\t * up the permissions on the existing dir.\n\t\t\t * Note that we don't change perms on existing\n\t\t\t * dirs unless _EXTRACT_PERM is specified.\n\t\t\t *\/\n\t\t\tif ((a->mode != a->st.st_mode)\n\t\t\t    && (a->todo & TODO_MODE_FORCE))\n\t\t\t\ta->deferred |= (a->todo & TODO_MODE);\n\t\t\t\/* Ownership doesn't need deferred fixup. *\/\n\t\t\ten = 0; \/* Forget the EEXIST. *\/\n\t\t}\n\t}\n\n\tif (en) {\n\t\t\/* Everything failed; give up here. *\/\n\t\tif ((&a->archive)->error == NULL)\n\t\t\tarchive_set_error(&a->archive, en, \"Can't create '%s'\",\n\t\t\t    a->name);\n\t\treturn (ARCHIVE_FAILED);\n\t}\n\n\ta->pst = NULL; \/* Cached stat data no longer valid. *\/\n\treturn (ret);\n}","target":0,"code_token_length":1720,"total_token_length":1956,"max_tokens_setting":2048}
+{"idx":353160,"func":"bool SplashOutputDev::tilingBitmapSrc(void *data, SplashColorPtr colorLine,\n                                       unsigned char *alphaLine) {\n  TilingSplashOutBitmap *imgData = (TilingSplashOutBitmap *)data;\n\n  if (imgData->y == imgData->bitmap->getHeight()) {\n    imgData->repeatY--;\n    if (imgData->repeatY == 0)\n      return false;\n    imgData->y = 0;\n  }\n\n  if (imgData->paintType == 1) {\n    const SplashColorMode cMode = imgData->bitmap->getMode();\n    SplashColorPtr q = colorLine;\n    \/\/ For splashModeBGR8 and splashModeXBGR8 we need to use getPixel\n    \/\/ for the others we can use raw access\n    if (cMode == splashModeBGR8 || cMode == splashModeXBGR8) {\n      for (int m = 0; m < imgData->repeatX; m++) {\n        for (int x = 0; x < imgData->bitmap->getWidth(); x++) {\n          imgData->bitmap->getPixel(x, imgData->y, q);\n          q += splashColorModeNComps[cMode];\n        }\n      }\n    } else {\n      const int n = imgData->bitmap->getRowSize();\n      SplashColorPtr p;\n      for (int m = 0; m < imgData->repeatX; m++) {\n        p = imgData->bitmap->getDataPtr() + imgData->y * imgData->bitmap->getRowSize();\n        for (int x = 0; x < n; ++x) {\n          *q++ = *p++;\n        }\n      }\n    }\n    if (alphaLine != nullptr) {\n      SplashColorPtr aq = alphaLine;\n      SplashColorPtr p;\n      const int n = imgData->bitmap->getWidth() - 1;\n      for (int m = 0; m < imgData->repeatX; m++) {\n        p = imgData->bitmap->getAlphaPtr() + imgData->y * imgData->bitmap->getWidth();\n        for (int x = 0; x < n; ++x) {\n          *aq++ = *p++;\n        }\n        \/\/ This is a hack, because of how Splash antialias works if we overwrite the\n        \/\/ last alpha pixel of the tile most\/all of the files look much better\n        *aq++ = (n == 0) ? *p : *(p - 1);\n      }\n    }\n  } else {\n    SplashColor col, pat;\n    SplashColorPtr dest = colorLine;\n    for (int m = 0; m < imgData->repeatX; m++) {\n      for (int x = 0; x < imgData->bitmap->getWidth(); x++) {\n        imgData->bitmap->getPixel(x, imgData->y, col);\n        imgData->pattern->getColor(x, imgData->y, pat);\n        for (int i = 0; i < splashColorModeNComps[imgData->colorMode]; ++i) {\n#ifdef SPLASH_CMYK\n          if (imgData->colorMode == splashModeCMYK8 || imgData->colorMode == splashModeDeviceN8)\n            dest[i] = div255(pat[i] * (255 - col[0]));\n          else\n#endif\n            dest[i] = 255 - div255((255 - pat[i]) * (255 - col[0]));\n        }\n        dest += splashColorModeNComps[imgData->colorMode];\n      }\n    }\n    if (alphaLine != nullptr) {\n      const int y = (imgData->y == imgData->bitmap->getHeight() - 1 && imgData->y > 50) ? imgData->y - 1 : imgData->y;\n      SplashColorPtr aq = alphaLine;\n      SplashColorPtr p;\n      const int n = imgData->bitmap->getWidth();\n      for (int m = 0; m < imgData->repeatX; m++) {\n        p = imgData->bitmap->getAlphaPtr() + y * imgData->bitmap->getWidth();\n        for (int x = 0; x < n; ++x) {\n          *aq++ = *p++;\n        }\n      }\n    }\n  }\n  ++imgData->y;\n  return true;\n}","target":0,"code_token_length":942,"total_token_length":1178,"max_tokens_setting":2048}
+{"idx":255787,"func":"  void Compute(OpKernelContext* ctx) override {\n    try {\n      const Tensor& input = ctx->input(kInputTensorIndex);\n      OP_REQUIRES(\n          ctx, input.dims() == 4,\n          errors::InvalidArgument(\"Current RequantizePerChannel operator\"\n                                  \"supports 4D tensors only.\"));\n\n      const Tensor& input_min_vec = ctx->input(kInputMinVecIndex);\n      size_t depth = input_min_vec.NumElements();\n      float* input_min_vec_data = (float*)const_cast<void*>(\n          static_cast<const void*>(input_min_vec.flat<float>().data()));\n\n      const Tensor& input_max_vec = ctx->input(kInputMaxVecIndex);\n      OP_REQUIRES(\n          ctx, input_max_vec.NumElements() == depth,\n          errors::InvalidArgument(\"input_max has incorrect size, expected \",\n                                  depth, \" was \", input_max_vec.NumElements()));\n      float* input_max_vec_data = (float*)const_cast<void*>(\n          static_cast<const void*>(input_max_vec.flat<float>().data()));\n\n      const Tensor& input_requested_min = ctx->input(this->kRequestMinIndex);\n      OP_REQUIRES(\n          ctx, input_requested_min.NumElements() == 1,\n          errors::InvalidArgument(\"requested_output_min must be a scalar\"));\n      const float input_requested_min_float =\n          input_requested_min.flat<float>()(0);\n\n      const Tensor& input_requested_max = ctx->input(this->kRequestMaxIndex);\n      OP_REQUIRES(\n          ctx, input_requested_min.NumElements() == 1,\n          errors::InvalidArgument(\"requested_output_max must be a scalar\"));\n      const float input_requested_max_float =\n          input_requested_max.flat<float>()(0);\n\n      if (out_type_ == DT_QINT8) {\n        OP_REQUIRES(ctx, input_requested_min_float < 0.0f,\n                    errors::InvalidArgument(\n                        \"If out_type is QINT8, requested_output_max must be \"\n                        \"non negative, got \",\n                        input_requested_min_float));\n      }\n\n      const float factor = (out_type_ == DT_QINT8) ? 127.0f : 255.0f;\n      const float requested_min_max =\n          std::max(std::abs(input_requested_min_float),\n                   std::abs(input_requested_max_float));\n      Tensor* output = nullptr;\n      OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputTensorIndex,\n                                               input.shape(), &output));\n\n      std::vector<float> scales(depth);\n      for (int i = 0; i < depth; ++i) {\n        float min_max_from_vec = std::max(std::abs(input_min_vec_data[i]),\n                                          std::abs(input_max_vec_data[i]));\n        scales[i] = factor * (min_max_from_vec \/ requested_min_max \/\n                              static_cast<float>(1L << 31));\n      }\n\n      mkldnn::primitive_attr reorder_attr;\n      reorder_attr.set_output_scales(2, scales);\n\n      memory::dims dims_mkl_order =\n          TFShapeToMklDnnDimsInNCHW(input.shape(), FORMAT_NHWC);\n      memory::desc input_md = memory::desc(dims_mkl_order, MklDnnType<qint32>(),\n                                           memory::format_tag::nhwc);\n      memory::desc output_md =\n          (out_type_ == DT_QINT8)\n              ? memory::desc(dims_mkl_order, MklDnnType<qint8>(),\n                             memory::format_tag::nhwc)\n              : memory::desc(dims_mkl_order, MklDnnType<quint8>(),\n                             memory::format_tag::nhwc);\n\n      void* input_buf =\n          static_cast<void*>(const_cast<qint32*>(input.flat<qint32>().data()));\n      void* output_buf;\n      if (out_type_ == DT_QINT8) {\n        output_buf = static_cast<void*>(\n            const_cast<qint8*>(output->flat<qint8>().data()));\n      } else {\n        output_buf = static_cast<void*>(\n            const_cast<quint8*>(output->flat<quint8>().data()));\n      }\n\n      std::unique_ptr<memory> input_mem_prim(\n          new memory(input_md, cpu_engine_, input_buf));\n      std::unique_ptr<memory> output_mem_prim(\n          new memory(output_md, cpu_engine_, output_buf));\n\n      mkldnn::reorder::primitive_desc reorder_pd =\n          ReorderPd(cpu_engine_, input_mem_prim->get_desc(), cpu_engine_,\n                    output_mem_prim->get_desc(), reorder_attr);\n      std::shared_ptr<stream> reorder_stream;\n      MklDnnThreadPool eigen_tp(ctx);\n      reorder_stream.reset(CreateStream(&eigen_tp, cpu_engine_));\n      std::unordered_map<int, mkldnn::memory> reorder_args = {\n          {MKLDNN_ARG_FROM, *input_mem_prim},\n          {MKLDNN_ARG_TO, *output_mem_prim}};\n      std::unique_ptr<mkldnn::primitive> reorder_prim(\n          new mkldnn::reorder(reorder_pd));\n      reorder_prim->execute(*reorder_stream, reorder_args);\n\n      Tensor* output_min = nullptr;\n      Tensor* output_max = nullptr;\n      OP_REQUIRES_OK(ctx,\n                     ctx->allocate_output(kOutputMinIndex, {}, &output_min));\n      OP_REQUIRES_OK(ctx,\n                     ctx->allocate_output(kOutputMaxIndex, {}, &output_max));\n\n      output_min->flat<float>()(0) = input_requested_min_float;\n      output_max->flat<float>()(0) = input_requested_max_float;\n    } catch (mkldnn::error& e) {\n      string error_msg = \"Status: \" + std::to_string(e.status) +\n                         \", message: \" + std::string(e.message) + \", in file \" +\n                         std::string(__FILE__) + \":\" + std::to_string(__LINE__);\n      OP_REQUIRES_OK(\n          ctx, errors::Aborted(\"Operation received an exception:\", error_msg));\n    }\n  }","target":0,"code_token_length":1261,"total_token_length":1497,"max_tokens_setting":2048}
+{"idx":210090,"func":"cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,\n    uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)\n{\n\tconst cdf_section_header_t *shp;\n\tcdf_section_header_t sh;\n\tconst uint8_t *p, *q, *e;\n\tsize_t i, o4, nelements, j, slen, left;\n\tcdf_property_info_t *inp;\n\n\tif (offs > UINT32_MAX \/ 4) {\n\t\terrno = EFTYPE;\n\t\tgoto out;\n\t}\n\tshp = CAST(const cdf_section_header_t *,\n\t    cdf_offset(sst->sst_tab, offs));\n\tif (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1)\n\t\tgoto out;\n\tsh.sh_len = CDF_TOLE4(shp->sh_len);\n\tif (sh.sh_len > CDF_SHLEN_LIMIT) {\n\t\terrno = EFTYPE;\n\t\tgoto out;\n\t}\n\n\tif (cdf_check_stream_offset(sst, h, shp, sh.sh_len, __LINE__) == -1)\n\t\tgoto out;\n\n\tsh.sh_properties = CDF_TOLE4(shp->sh_properties);\n\tDPRINTF((\"section len: %u properties %u\\n\", sh.sh_len,\n\t    sh.sh_properties));\n\tif (sh.sh_properties > CDF_PROP_LIMIT)\n\t\tgoto out;\n\tinp = cdf_grow_info(info, maxcount, sh.sh_properties);\n\tif (inp == NULL)\n\t\tgoto out;\n\tinp += *count;\n\t*count += sh.sh_properties;\n\tp = CAST(const uint8_t *, cdf_offset(sst->sst_tab, offs + sizeof(sh)));\n\te = CAST(const uint8_t *, cdf_offset(shp, sh.sh_len));\n\tif (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)\n\t\tgoto out;\n\n\tfor (i = 0; i < sh.sh_properties; i++) {\n\t\tif ((q = cdf_get_property_info_pos(sst, h, p, e, i)) == NULL)\n\t\t\tgoto out;\n\t\tinp[i].pi_id = CDF_GETUINT32(p, i << 1);\n\t\tleft = CAST(size_t, e - q);\n\t\tif (left < sizeof(uint32_t)) {\n\t\t\tDPRINTF((\"short info (no type)_\\n\"));\n\t\t\tgoto out;\n\t\t}\n\t\tinp[i].pi_type = CDF_GETUINT32(q, 0);\n\t\tDPRINTF((\"%\" SIZE_T_FORMAT \"u) id=%#x type=%#x offs=%#tx,%#x\\n\",\n\t\t    i, inp[i].pi_id, inp[i].pi_type, q - p, offs));\n\t\tif (inp[i].pi_type & CDF_VECTOR) {\n\t\t\tif (left < sizeof(uint32_t) * 2) {\n\t\t\t\tDPRINTF((\"missing CDF_VECTOR length\\n\"));\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tnelements = CDF_GETUINT32(q, 1);\n\t\t\tif (nelements == 0) {\n\t\t\t\tDPRINTF((\"CDF_VECTOR with nelements == 0\\n\"));\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tslen = 2;\n\t\t} else {\n\t\t\tnelements = 1;\n\t\t\tslen = 1;\n\t\t}\n\t\to4 = slen * sizeof(uint32_t);\n\t\tif (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED))\n\t\t\tgoto unknown;\n\t\tswitch (inp[i].pi_type & CDF_TYPEMASK) {\n\t\tcase CDF_NULL:\n\t\tcase CDF_EMPTY:\n\t\t\tbreak;\n\t\tcase CDF_SIGNED16:\n\t\t\tif (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int16_t)))\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tcase CDF_SIGNED32:\n\t\tcase CDF_BOOL:\n\t\tcase CDF_UNSIGNED32:\n\t\tcase CDF_FLOAT:\n\t\t\tif (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int32_t)))\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tcase CDF_SIGNED64:\n\t\tcase CDF_UNSIGNED64:\n\t\tcase CDF_DOUBLE:\n\t\tcase CDF_FILETIME:\n\t\t\tif (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int64_t)))\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tcase CDF_LENGTH32_STRING:\n\t\tcase CDF_LENGTH32_WSTRING:\n\t\t\tif (nelements > 1) {\n\t\t\t\tsize_t nelem = inp - *info;\n\t\t\t\tinp = cdf_grow_info(info, maxcount, nelements);\n\t\t\t\tif (inp == NULL)\n\t\t\t\t\tgoto out;\n\t\t\t\tinp += nelem;\n\t\t\t}\n\t\t\tDPRINTF((\"nelements = %\" SIZE_T_FORMAT \"u\\n\",\n\t\t\t    nelements));\n\t\t\tfor (j = 0; j < nelements && i < sh.sh_properties;\n\t\t\t    j++, i++)\n\t\t\t{\n\t\t\t\tuint32_t l;\n\n\t\t\t\tif (o4 + sizeof(uint32_t) > left)\n\t\t\t\t\tgoto out;\n\n\t\t\t\tl = CDF_GETUINT32(q, slen);\n\t\t\t\to4 += sizeof(uint32_t);\n\t\t\t\tif (o4 + l > left)\n\t\t\t\t\tgoto out;\n\n\t\t\t\tinp[i].pi_str.s_len = l;\n\t\t\t\tinp[i].pi_str.s_buf = CAST(const char *,\n\t\t\t\t    CAST(const void *, &q[o4]));\n\n\t\t\t\tDPRINTF((\"o=%\" SIZE_T_FORMAT \"u l=%d(%\"\n\t\t\t\t    SIZE_T_FORMAT \"u), t=%\" SIZE_T_FORMAT\n\t\t\t\t    \"u s=%s\\n\", o4, l, CDF_ROUND(l, sizeof(l)),\n\t\t\t\t    left, inp[i].pi_str.s_buf));\n\n\t\t\t\tif (l & 1)\n\t\t\t\t\tl++;\n\n\t\t\t\tslen += l >> 1;\n\t\t\t\to4 = slen * sizeof(uint32_t);\n\t\t\t}\n\t\t\ti--;\n\t\t\tbreak;\n\t\tcase CDF_CLIPBOARD:\n\t\t\tif (inp[i].pi_type & CDF_VECTOR)\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tdefault:\n\t\tunknown:\n\t\t\tmemset(&inp[i].pi_val, 0, sizeof(inp[i].pi_val));\n\t\t\tDPRINTF((\"Don't know how to deal with %#x\\n\",\n\t\t\t    inp[i].pi_type));\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\nout:\n\tfree(*info);\n\t*info = NULL;\n\t*count = 0;\n\t*maxcount = 0;\n\terrno = EFTYPE;\n\treturn -1;\n}","target":1,"code_token_length":1401,"total_token_length":1637,"max_tokens_setting":2048}
+{"idx":211110,"func":"LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)\n{\n\tstatic const char module[] = \"LZWDecodeCompat\";\n\tLZWCodecState *sp = DecoderState(tif);\n\tchar *op = (char*) op0;\n\tlong occ = (long) occ0;\n\tchar *tp;\n\tunsigned char *bp;\n\tint code, nbits;\n\tlong nextbits, nextdata, nbitsmask;\n\tcode_t *codep, *free_entp, *maxcodep, *oldcodep;\n\n\t(void) s;\n\tassert(sp != NULL);\n\n\t\/*\n\t  Fail if value does not fit in long.\n\t*\/\n\tif ((tmsize_t) occ != occ0)\n\t        return (0);\n\n\t\/*\n\t * Restart interrupted output operation.\n\t *\/\n\tif (sp->dec_restart) {\n\t\tlong residue;\n\n\t\tcodep = sp->dec_codep;\n\t\tresidue = codep->length - sp->dec_restart;\n\t\tif (residue > occ) {\n\t\t\t\/*\n\t\t\t * Residue from previous decode is sufficient\n\t\t\t * to satisfy decode request.  Skip to the\n\t\t\t * start of the decoded string, place decoded\n\t\t\t * values in the output buffer, and return.\n\t\t\t *\/\n\t\t\tsp->dec_restart += occ;\n\t\t\tdo {\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--residue > occ);\n\t\t\ttp = op + occ;\n\t\t\tdo {\n\t\t\t\t*--tp = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--occ);\n\t\t\treturn (1);\n\t\t}\n\t\t\/*\n\t\t * Residue satisfies only part of the decode request.\n\t\t *\/\n\t\top += residue;\n\t\tocc -= residue;\n\t\ttp = op;\n\t\tdo {\n\t\t\t*--tp = codep->value;\n\t\t\tcodep = codep->next;\n\t\t} while (--residue);\n\t\tsp->dec_restart = 0;\n\t}\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n#ifdef LZW_CHECKEOS\n\tsp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);\n#endif\n\tnbits = sp->lzw_nbits;\n\tnextdata = sp->lzw_nextdata;\n\tnextbits = sp->lzw_nextbits;\n\tnbitsmask = sp->dec_nbitsmask;\n\toldcodep = sp->dec_oldcodep;\n\tfree_entp = sp->dec_free_entp;\n\tmaxcodep = sp->dec_maxcodep;\n\n\twhile (occ > 0) {\n\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\tif (code == CODE_EOI)\n\t\t\tbreak;\n\t\tif (code == CODE_CLEAR) {\n\t\t\tdo {\n\t\t\t\tfree_entp = sp->dec_codetab + CODE_FIRST;\n\t\t\t\t_TIFFmemset(free_entp, 0,\n\t\t\t\t\t    (CSIZE - CODE_FIRST) * sizeof (code_t));\n\t\t\t\tnbits = BITS_MIN;\n\t\t\t\tnbitsmask = MAXCODE(BITS_MIN);\n\t\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\t\t} while (code == CODE_CLEAR);\t\/* consecutive CODE_CLEAR codes *\/\n\t\t\tif (code == CODE_EOI)\n\t\t\t\tbreak;\n\t\t\tif (code > CODE_CLEAR) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, tif->tif_name,\n\t\t\t\t\"LZWDecode: Corrupted LZW table at scanline %d\",\n\t\t\t\t\t     tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t\toldcodep = sp->dec_codetab + code;\n\t\t\tcontinue;\n\t\t}\n\t\tcodep = sp->dec_codetab + code;\n\n\t\t\/*\n\t\t * Add the new entry to the code table.\n\t\t *\/\n\t\tif (free_entp < &sp->dec_codetab[0] ||\n\t\t    free_entp >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\n\t\tfree_entp->next = oldcodep;\n\t\tif (free_entp->next < &sp->dec_codetab[0] ||\n\t\t    free_entp->next >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\t\tfree_entp->firstchar = free_entp->next->firstchar;\n\t\tfree_entp->length = free_entp->next->length+1;\n\t\tfree_entp->value = (codep < free_entp) ?\n\t\t    codep->firstchar : free_entp->firstchar;\n\t\tif (++free_entp > maxcodep) {\n\t\t\tif (++nbits > BITS_MAX)\t\t\/* should not happen *\/\n\t\t\t\tnbits = BITS_MAX;\n\t\t\tnbitsmask = MAXCODE(nbits);\n\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t}\n\t\toldcodep = codep;\n\t\tif (code >= 256) {\n\t\t\t\/*\n\t\t\t * Code maps to a string, copy string\n\t\t\t * value to output (written in reverse).\n\t\t\t *\/\n\t\t\tif(codep->length == 0) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\t    \"Wrong length of decoded \"\n\t\t\t\t    \"string: data probably corrupted at scanline %d\",\n\t\t\t\t    tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\tif (codep->length > occ) {\n\t\t\t\t\/*\n\t\t\t\t * String is too long for decode buffer,\n\t\t\t\t * locate portion that will fit, copy to\n\t\t\t\t * the decode buffer, and setup restart\n\t\t\t\t * logic for the next decoding call.\n\t\t\t\t *\/\n\t\t\t\tsp->dec_codep = codep;\n\t\t\t\tdo {\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (codep->length > occ);\n\t\t\t\tsp->dec_restart = occ;\n\t\t\t\ttp = op + occ;\n\t\t\t\tdo  {\n\t\t\t\t\t*--tp = codep->value;\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t}  while (--occ);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tassert(occ >= codep->length);\n\t\t\top += codep->length;\n\t\t\tocc -= codep->length;\n\t\t\ttp = op;\n\t\t\tdo {\n\t\t\t\t*--tp = codep->value;\n\t\t\t} while( (codep = codep->next) != NULL );\n\t\t} else {\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t}\n\t}\n\n\ttif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );\n\ttif->tif_rawcp = (uint8*) bp;\n\tsp->lzw_nbits = (unsigned short)nbits;\n\tsp->lzw_nextdata = nextdata;\n\tsp->lzw_nextbits = nextbits;\n\tsp->dec_nbitsmask = nbitsmask;\n\tsp->dec_oldcodep = oldcodep;\n\tsp->dec_free_entp = free_entp;\n\tsp->dec_maxcodep = maxcodep;\n\n\tif (occ > 0) {\n#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %I64d bytes)\",\n\t\t\t     tif->tif_row, (unsigned __int64) occ);\n#else\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %llu bytes)\",\n\t\t\t     tif->tif_row, (unsigned long long) occ);\n#endif\n\t\treturn (0);\n\t}\n\treturn (1);\n}","target":1,"code_token_length":1713,"total_token_length":1949,"max_tokens_setting":2048}
+{"idx":386525,"func":"void DL_Dxf::writeHatchEdge(DL_WriterA& dw,\n                            const DL_HatchEdgeData& data) {\n\n    if (data.type<1 || data.type>4) {\n        printf(\"WARNING: unsupported hatch edge type: %d\", data.type);\n    }\n\n    dw.dxfInt(72, data.type);\n\n    switch (data.type) {\n    \/\/ line:\n    case 1:\n        dw.dxfReal(10, data.x1);\n        dw.dxfReal(20, data.y1);\n        dw.dxfReal(11, data.x2);\n        dw.dxfReal(21, data.y2);\n        break;\n\n    \/\/ arc:\n    case 2:\n        dw.dxfReal(10, data.cx);\n        dw.dxfReal(20, data.cy);\n        dw.dxfReal(40, data.radius);\n        dw.dxfReal(50, data.angle1\/(2*M_PI)*360.0);\n        dw.dxfReal(51, data.angle2\/(2*M_PI)*360.0);\n        dw.dxfInt(73, (int)(data.ccw));\n        break;\n\n    \/\/ ellipse arc:\n    case 3:\n        dw.dxfReal(10, data.cx);\n        dw.dxfReal(20, data.cy);\n        dw.dxfReal(11, data.mx);\n        dw.dxfReal(21, data.my);\n        dw.dxfReal(40, data.ratio);\n        dw.dxfReal(50, data.angle1\/(2*M_PI)*360.0);\n        dw.dxfReal(51, data.angle2\/(2*M_PI)*360.0);\n        dw.dxfInt(73, (int)(data.ccw));\n        break;\n\n    \/\/ spline:\n    case 4:\n        dw.dxfInt(94, data.degree);\n        dw.dxfBool(73, data.rational);\n        dw.dxfBool(74, data.periodic);\n        dw.dxfInt(95, data.nKnots);\n        dw.dxfInt(96, data.nControl);\n        for (unsigned int i=0; i<data.knots.size(); i++) {\n            dw.dxfReal(40, data.knots[i]);\n        }\n        for (unsigned int i=0; i<data.controlPoints.size(); i++) {\n            dw.dxfReal(10, data.controlPoints[i][0]);\n            dw.dxfReal(20, data.controlPoints[i][1]);\n        }\n        for (unsigned int i=0; i<data.weights.size(); i++) {\n            dw.dxfReal(42, data.weights[i]);\n        }\n        if (data.nFit>0) {\n            dw.dxfInt(97, data.nFit);\n            for (unsigned int i=0; i<data.fitPoints.size(); i++) {\n                dw.dxfReal(11, data.fitPoints[i][0]);\n                dw.dxfReal(21, data.fitPoints[i][1]);\n            }\n        }\n        if (fabs(data.startTangentX)>1.0e-4 || fabs(data.startTangentY)>1.0e-4) {\n            dw.dxfReal(12, data.startTangentX);\n            dw.dxfReal(22, data.startTangentY);\n        }\n        if (fabs(data.endTangentX)>1.0e-4 || fabs(data.endTangentY)>1.0e-4) {\n            dw.dxfReal(13, data.endTangentX);\n            dw.dxfReal(23, data.endTangentY);\n        }\n        break;\n\n    default:\n        break;\n    }\n}","target":0,"code_token_length":801,"total_token_length":1037,"max_tokens_setting":2048}
+{"idx":502713,"func":"SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket)\n{\n    SSL_SESSION *dest;\n\n    dest = OPENSSL_malloc(sizeof(*src));\n    if (dest == NULL) {\n        goto err;\n    }\n    memcpy(dest, src, sizeof(*dest));\n\n#ifndef OPENSSL_NO_KRB5\n    dest->krb5_client_princ_len = dest->krb5_client_princ_len;\n    if (src->krb5_client_princ_len > 0)\n        memcpy(dest->krb5_client_princ, src->krb5_client_princ,\n               src->krb5_client_princ_len);\n#endif\n\n#ifndef OPENSSL_NO_PSK\n    if (src->psk_identity_hint) {\n        dest->psk_identity_hint = BUF_strdup(src->psk_identity_hint);\n        if (dest->psk_identity_hint == NULL) {\n            goto err;\n        }\n    } else {\n        dest->psk_identity_hint = NULL;\n    }\n    if (src->psk_identity) {\n        dest->psk_identity = BUF_strdup(src->psk_identity);\n        if (dest->psk_identity == NULL) {\n            goto err;\n        }\n    } else {\n        dest->psk_identity = NULL;\n    }\n#endif\n\n    if (src->sess_cert != NULL)\n        CRYPTO_add(&src->sess_cert->references, 1, CRYPTO_LOCK_SSL_SESS_CERT);\n\n    if (src->peer != NULL)\n        CRYPTO_add(&src->peer->references, 1, CRYPTO_LOCK_X509);\n\n    dest->references = 1;\n\n    if(src->ciphers != NULL) {\n        dest->ciphers = sk_SSL_CIPHER_dup(src->ciphers);\n        if (dest->ciphers == NULL)\n            goto err;\n    } else {\n        dest->ciphers = NULL;\n    }\n\n    if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL_SESSION,\n                                            &dest->ex_data, &src->ex_data)) {\n        goto err;\n    }\n\n    \/* We deliberately don't copy the prev and next pointers *\/\n    dest->prev = NULL;\n    dest->next = NULL;\n\n#ifndef OPENSSL_NO_TLSEXT\n    if (src->tlsext_hostname) {\n        dest->tlsext_hostname = BUF_strdup(src->tlsext_hostname);\n        if (dest->tlsext_hostname == NULL) {\n            goto err;\n        }\n    } else {\n        dest->tlsext_hostname = NULL;\n    }\n# ifndef OPENSSL_NO_EC\n    if (src->tlsext_ecpointformatlist) {\n        dest->tlsext_ecpointformatlist =\n            BUF_memdup(src->tlsext_ecpointformatlist,\n                       src->tlsext_ecpointformatlist_length);\n        if (dest->tlsext_ecpointformatlist == NULL)\n            goto err;\n        dest->tlsext_ecpointformatlist_length =\n            src->tlsext_ecpointformatlist_length;\n    }\n    if (src->tlsext_ellipticcurvelist) {\n        dest->tlsext_ellipticcurvelist =\n            BUF_memdup(src->tlsext_ellipticcurvelist,\n                       src->tlsext_ellipticcurvelist_length);\n        if (dest->tlsext_ellipticcurvelist == NULL)\n            goto err;\n        dest->tlsext_ellipticcurvelist_length =\n            src->tlsext_ellipticcurvelist_length;\n    }\n# endif\n#endif\n\n    if (ticket != 0) {\n        dest->tlsext_tick_lifetime_hint = src->tlsext_tick_lifetime_hint;\n        dest->tlsext_ticklen = src->tlsext_ticklen;\n        if((dest->tlsext_tick = OPENSSL_malloc(src->tlsext_ticklen)) == NULL) {\n            goto err;\n        }\n    }\n\n#ifndef OPENSSL_NO_SRP\n    dest->srp_username = NULL;\n    if (src->srp_username) {\n        dest->srp_username = BUF_strdup(src->srp_username);\n        if (dest->srp_username == NULL) {\n            goto err;\n        }\n    } else {\n        dest->srp_username = NULL;\n    }\n#endif\n\n    return dest;\nerr:\n    SSLerr(SSL_F_SSL_SESSION_DUP, ERR_R_MALLOC_FAILURE);\n    SSL_SESSION_free(dest);\n    return NULL;\n}","target":0,"code_token_length":935,"total_token_length":1171,"max_tokens_setting":2048}
+{"idx":336559,"func":"static int reds_agent_state_restore(RedsState *reds, SpiceMigrateDataMain *mig_data)\n{\n    RedCharDeviceVDIPort *agent_dev = reds->agent_dev.get();\n    uint32_t chunk_header_remaining;\n\n    agent_dev->priv->vdi_chunk_header = mig_data->agent2client.chunk_header;\n    spice_assert(mig_data->agent2client.chunk_header_size <= sizeof(VDIChunkHeader));\n    chunk_header_remaining = sizeof(VDIChunkHeader) - mig_data->agent2client.chunk_header_size;\n    if (chunk_header_remaining) {\n        agent_dev->priv->read_state = VDI_PORT_READ_STATE_READ_HEADER;\n        agent_dev->priv->receive_pos = (uint8_t *)&agent_dev->priv->vdi_chunk_header +\n            mig_data->agent2client.chunk_header_size;\n        agent_dev->priv->receive_len = chunk_header_remaining;\n    } else {\n        agent_dev->priv->message_receive_len = agent_dev->priv->vdi_chunk_header.size;\n    }\n\n    if (!mig_data->agent2client.msg_header_done) {\n        uint8_t *partial_msg_header;\n\n        if (!chunk_header_remaining) {\n            uint32_t cur_buf_size;\n\n            agent_dev->priv->read_state = VDI_PORT_READ_STATE_READ_DATA;\n            agent_dev->priv->current_read_buf = vdi_port_get_read_buf(agent_dev);\n            spice_assert(agent_dev->priv->current_read_buf);\n            partial_msg_header = (uint8_t *)mig_data + mig_data->agent2client.msg_header_ptr -\n                sizeof(SpiceMiniDataHeader);\n            memcpy(agent_dev->priv->current_read_buf->data,\n                   partial_msg_header,\n                   mig_data->agent2client.msg_header_partial_len);\n            agent_dev->priv->receive_pos = agent_dev->priv->current_read_buf->data +\n                                      mig_data->agent2client.msg_header_partial_len;\n            cur_buf_size = sizeof(agent_dev->priv->current_read_buf->data) -\n                           mig_data->agent2client.msg_header_partial_len;\n            agent_dev->priv->receive_len = MIN(agent_dev->priv->message_receive_len, cur_buf_size);\n            agent_dev->priv->current_read_buf->len = agent_dev->priv->receive_len +\n                                                 mig_data->agent2client.msg_header_partial_len;\n            agent_dev->priv->message_receive_len -= agent_dev->priv->receive_len;\n        } else {\n            spice_assert(mig_data->agent2client.msg_header_partial_len == 0);\n        }\n    } else {\n            agent_dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;\n            agent_dev->priv->current_read_buf.reset();\n            agent_dev->priv->receive_pos = NULL;\n            agent_dev->priv->read_filter.msg_data_to_read = mig_data->agent2client.msg_remaining;\n            agent_dev->priv->read_filter.result = (AgentMsgFilterResult) mig_data->agent2client.msg_filter_result;\n    }\n\n    agent_dev->priv->read_filter.discard_all = FALSE;\n    agent_dev->priv->write_filter.discard_all = !mig_data->client_agent_started;\n    agent_dev->priv->client_agent_started = mig_data->client_agent_started;\n\n    agent_dev->priv->write_filter.msg_data_to_read = mig_data->client2agent.msg_remaining;\n    agent_dev->priv->write_filter.result = (AgentMsgFilterResult) mig_data->client2agent.msg_filter_result;\n\n    spice_debug(\"to agent filter: discard all %d, wait_msg %u, msg_filter_result %d\",\n                agent_dev->priv->write_filter.discard_all,\n                agent_dev->priv->write_filter.msg_data_to_read,\n                agent_dev->priv->write_filter.result);\n    spice_debug(\"from agent filter: discard all %d, wait_msg %u, msg_filter_result %d\",\n                agent_dev->priv->read_filter.discard_all,\n                agent_dev->priv->read_filter.msg_data_to_read,\n                agent_dev->priv->read_filter.result);\n    return agent_dev->restore(&mig_data->agent_base);\n}","target":0,"code_token_length":850,"total_token_length":1086,"max_tokens_setting":2048}
+{"idx":218750,"func":"static MagickBooleanType ReadPSDChannelZip(Image *image,const size_t channels,\n  const ssize_t type,const PSDCompressionType compression,\n  const size_t compact_size,ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  unsigned char\n    *p;\n\n  size_t\n    count,\n    length,\n    packet_size,\n    row_size;\n\n  ssize_t\n    y;\n\n  unsigned char\n    *compact_pixels,\n    *pixels;\n\n  z_stream\n    stream;\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n       \"      layer data is ZIP compressed\");\n\n  if ((MagickSizeType) compact_size > GetBlobSize(image))\n    ThrowBinaryException(CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  compact_pixels=(unsigned char *) AcquireQuantumMemory(compact_size,\n    sizeof(*compact_pixels));\n  if (compact_pixels == (unsigned char *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n\n  packet_size=GetPSDPacketSize(image);\n  row_size=image->columns*packet_size;\n  count=image->rows*row_size;\n\n  pixels=(unsigned char *) AcquireQuantumMemory(count,sizeof(*pixels));\n  if (pixels == (unsigned char *) NULL)\n    {\n      compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);\n      ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n        image->filename);\n    }\n  if (ReadBlob(image,compact_size,compact_pixels) != (ssize_t) compact_size)\n    {\n      pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n      compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);\n      ThrowBinaryException(CorruptImageError,\"UnexpectedEndOfFile\",\n        image->filename);\n    }\n\n  memset(&stream,0,sizeof(stream));\n  stream.data_type=Z_BINARY;\n  stream.next_in=(Bytef *)compact_pixels;\n  stream.avail_in=(uInt) compact_size;\n  stream.next_out=(Bytef *)pixels;\n  stream.avail_out=(uInt) count;\n\n  if (inflateInit(&stream) == Z_OK)\n    {\n      int\n        ret;\n\n      while (stream.avail_out > 0)\n      {\n        ret=inflate(&stream,Z_SYNC_FLUSH);\n        if ((ret != Z_OK) && (ret != Z_STREAM_END))\n          {\n            (void) inflateEnd(&stream);\n            compact_pixels=(unsigned char *) RelinquishMagickMemory(\n              compact_pixels);\n            pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n            return(MagickFalse);\n          }\n        if (ret == Z_STREAM_END)\n          break;\n      }\n      (void) inflateEnd(&stream);\n    }\n\n  if (compression == ZipWithPrediction)\n  {\n     p=pixels;\n     while (count > 0)\n     {\n       length=image->columns;\n       while (--length)\n       {\n         if (packet_size == 2)\n           {\n             p[2]+=p[0]+((p[1]+p[3]) >> 8);\n             p[3]+=p[1];\n           }\n         else\n          *(p+1)+=*p;\n         p+=packet_size;\n       }\n       p+=packet_size;\n       count-=row_size;\n     }\n  }\n\n  status=MagickTrue;\n  p=pixels;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    status=ReadPSDChannelPixels(image,channels,y,type,p,exception);\n    if (status == MagickFalse)\n      break;\n\n    p+=row_size;\n  }\n\n  compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);\n  pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n  return(status);\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048}
+{"idx":446055,"func":"LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)\n{\n\tregister LZWCodecState *sp = EncoderState(tif);\n\tregister long fcode;\n\tregister hash_t *hp;\n\tregister int h, c;\n\thcode_t ent;\n\tlong disp;\n\tlong incount, outcount, checkpoint;\n\tunsigned long nextdata;\n        long nextbits;\n\tint free_ent, maxcode, nbits;\n\tuint8* op;\n\tuint8* limit;\n\n\t(void) s;\n\tif (sp == NULL)\n\t\treturn (0);\n\n        assert(sp->enc_hashtab != NULL);\n\n\t\/*\n\t * Load local state.\n\t *\/\n\tincount = sp->enc_incount;\n\toutcount = sp->enc_outcount;\n\tcheckpoint = sp->enc_checkpoint;\n\tnextdata = sp->lzw_nextdata;\n\tnextbits = sp->lzw_nextbits;\n\tfree_ent = sp->lzw_free_ent;\n\tmaxcode = sp->lzw_maxcode;\n\tnbits = sp->lzw_nbits;\n\top = tif->tif_rawcp;\n\tlimit = sp->enc_rawlimit;\n\tent = (hcode_t)sp->enc_oldcode;\n\n\tif (ent == (hcode_t) -1 && cc > 0) {\n\t\t\/*\n\t\t * NB: This is safe because it can only happen\n\t\t *     at the start of a strip where we know there\n\t\t *     is space in the data buffer.\n\t\t *\/\n\t\tPutNextCode(op, CODE_CLEAR);\n\t\tent = *bp++; cc--; incount++;\n\t}\n\twhile (cc > 0) {\n\t\tc = *bp++; cc--; incount++;\n\t\tfcode = ((long)c << BITS_MAX) + ent;\n\t\th = (c << HSHIFT) ^ ent;\t\/* xor hashing *\/\n#ifdef _WINDOWS\n\t\t\/*\n\t\t * Check hash index for an overflow.\n\t\t *\/\n\t\tif (h >= HSIZE)\n\t\t\th -= HSIZE;\n#endif\n\t\thp = &sp->enc_hashtab[h];\n\t\tif (hp->hash == fcode) {\n\t\t\tent = hp->code;\n\t\t\tcontinue;\n\t\t}\n\t\tif (hp->hash >= 0) {\n\t\t\t\/*\n\t\t\t * Primary hash failed, check secondary hash.\n\t\t\t *\/\n\t\t\tdisp = HSIZE - h;\n\t\t\tif (h == 0)\n\t\t\t\tdisp = 1;\n\t\t\tdo {\n\t\t\t\t\/*\n\t\t\t\t * Avoid pointer arithmetic because of\n\t\t\t\t * wraparound problems with segments.\n\t\t\t\t *\/\n\t\t\t\tif ((h -= disp) < 0)\n\t\t\t\t\th += HSIZE;\n\t\t\t\thp = &sp->enc_hashtab[h];\n\t\t\t\tif (hp->hash == fcode) {\n\t\t\t\t\tent = hp->code;\n\t\t\t\t\tgoto hit;\n\t\t\t\t}\n\t\t\t} while (hp->hash >= 0);\n\t\t}\n\t\t\/*\n\t\t * New entry, emit code and add to table.\n\t\t *\/\n\t\t\/*\n\t\t * Verify there is space in the buffer for the code\n\t\t * and any potential Clear code that might be emitted\n\t\t * below.  The value of limit is setup so that there\n\t\t * are at least 4 bytes free--room for 2 codes.\n\t\t *\/\n\t\tif (op > limit) {\n\t\t\ttif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);\n\t\t\tif( !TIFFFlushData1(tif) )\n                            return 0;\n\t\t\top = tif->tif_rawdata;\n\t\t}\n\t\tPutNextCode(op, ent);\n\t\tent = (hcode_t)c;\n\t\thp->code = (hcode_t)(free_ent++);\n\t\thp->hash = fcode;\n\t\tif (free_ent == CODE_MAX-1) {\n\t\t\t\/* table is full, emit clear code and reset *\/\n\t\t\tcl_hash(sp);\n\t\t\tsp->enc_ratio = 0;\n\t\t\tincount = 0;\n\t\t\toutcount = 0;\n\t\t\tfree_ent = CODE_FIRST;\n\t\t\tPutNextCode(op, CODE_CLEAR);\n\t\t\tnbits = BITS_MIN;\n\t\t\tmaxcode = MAXCODE(BITS_MIN);\n\t\t} else {\n\t\t\t\/*\n\t\t\t * If the next entry is going to be too big for\n\t\t\t * the code size, then increase it, if possible.\n\t\t\t *\/\n\t\t\tif (free_ent > maxcode) {\n\t\t\t\tnbits++;\n\t\t\t\tassert(nbits <= BITS_MAX);\n\t\t\t\tmaxcode = (int) MAXCODE(nbits);\n\t\t\t} else if (incount >= checkpoint) {\n\t\t\t\tlong rat;\n\t\t\t\t\/*\n\t\t\t\t * Check compression ratio and, if things seem\n\t\t\t\t * to be slipping, clear the hash table and\n\t\t\t\t * reset state.  The compression ratio is a\n\t\t\t\t * 24+8-bit fractional number.\n\t\t\t\t *\/\n\t\t\t\tcheckpoint = incount+CHECK_GAP;\n\t\t\t\tCALCRATIO(sp, rat);\n\t\t\t\tif (rat <= sp->enc_ratio) {\n\t\t\t\t\tcl_hash(sp);\n\t\t\t\t\tsp->enc_ratio = 0;\n\t\t\t\t\tincount = 0;\n\t\t\t\t\toutcount = 0;\n\t\t\t\t\tfree_ent = CODE_FIRST;\n\t\t\t\t\tPutNextCode(op, CODE_CLEAR);\n\t\t\t\t\tnbits = BITS_MIN;\n\t\t\t\t\tmaxcode = MAXCODE(BITS_MIN);\n\t\t\t\t} else\n\t\t\t\t\tsp->enc_ratio = rat;\n\t\t\t}\n\t\t}\n\thit:\n\t\t;\n\t}\n\n\t\/*\n\t * Restore global state.\n\t *\/\n\tsp->enc_incount = incount;\n\tsp->enc_outcount = outcount;\n\tsp->enc_checkpoint = checkpoint;\n\tsp->enc_oldcode = ent;\n\tsp->lzw_nextdata = nextdata;\n\tsp->lzw_nextbits = nextbits;\n\tsp->lzw_free_ent = (unsigned short)free_ent;\n\tsp->lzw_maxcode = (unsigned short)maxcode;\n\tsp->lzw_nbits = (unsigned short)nbits;\n\ttif->tif_rawcp = op;\n\treturn (1);\n}","target":0,"code_token_length":1237,"total_token_length":1473,"max_tokens_setting":2048}
+{"idx":482692,"func":"gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)\n{\n  GstCaps *caps;\n  guint avail;\n  GstFlowReturn res = GST_FLOW_OK;\n\n  GstFlxDec *flxdec;\n  FlxHeader *flxh;\n\n  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);\n  flxdec = (GstFlxDec *) parent;\n  g_return_val_if_fail (flxdec != NULL, GST_FLOW_ERROR);\n\n  gst_adapter_push (flxdec->adapter, buf);\n  avail = gst_adapter_available (flxdec->adapter);\n\n  if (flxdec->state == GST_FLXDEC_READ_HEADER) {\n    if (avail >= FlxHeaderSize) {\n      const guint8 *data = gst_adapter_map (flxdec->adapter, FlxHeaderSize);\n      GstCaps *templ;\n\n      memcpy ((gchar *) & flxdec->hdr, data, FlxHeaderSize);\n      FLX_HDR_FIX_ENDIANNESS (&(flxdec->hdr));\n      gst_adapter_unmap (flxdec->adapter);\n      gst_adapter_flush (flxdec->adapter, FlxHeaderSize);\n\n      flxh = &flxdec->hdr;\n\n      \/* check header *\/\n      if (flxh->type != FLX_MAGICHDR_FLI &&\n          flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX)\n        goto wrong_type;\n\n      GST_LOG (\"size      :  %d\", flxh->size);\n      GST_LOG (\"frames    :  %d\", flxh->frames);\n      GST_LOG (\"width     :  %d\", flxh->width);\n      GST_LOG (\"height    :  %d\", flxh->height);\n      GST_LOG (\"depth     :  %d\", flxh->depth);\n      GST_LOG (\"speed     :  %d\", flxh->speed);\n\n      flxdec->next_time = 0;\n\n      if (flxh->type == FLX_MAGICHDR_FLI) {\n        flxdec->frame_time = JIFFIE * flxh->speed;\n      } else if (flxh->speed == 0) {\n        flxdec->frame_time = GST_SECOND \/ 70;\n      } else {\n        flxdec->frame_time = flxh->speed * GST_MSECOND;\n      }\n\n      flxdec->duration = flxh->frames * flxdec->frame_time;\n      GST_LOG (\"duration   :  %\" GST_TIME_FORMAT,\n          GST_TIME_ARGS (flxdec->duration));\n\n      templ = gst_pad_get_pad_template_caps (flxdec->srcpad);\n      caps = gst_caps_copy (templ);\n      gst_caps_unref (templ);\n      gst_caps_set_simple (caps,\n          \"width\", G_TYPE_INT, flxh->width,\n          \"height\", G_TYPE_INT, flxh->height,\n          \"framerate\", GST_TYPE_FRACTION, (gint) GST_MSECOND,\n          (gint) flxdec->frame_time \/ 1000, NULL);\n\n      gst_pad_set_caps (flxdec->srcpad, caps);\n      gst_caps_unref (caps);\n\n      if (flxh->depth <= 8)\n        flxdec->converter =\n            flx_colorspace_converter_new (flxh->width, flxh->height);\n\n      if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) {\n        GST_LOG (\"(FLC) aspect_dx :  %d\", flxh->aspect_dx);\n        GST_LOG (\"(FLC) aspect_dy :  %d\", flxh->aspect_dy);\n        GST_LOG (\"(FLC) oframe1   :  0x%08x\", flxh->oframe1);\n        GST_LOG (\"(FLC) oframe2   :  0x%08x\", flxh->oframe2);\n      }\n\n      flxdec->size = ((guint) flxh->width * (guint) flxh->height);\n\n      \/* create delta and output frame *\/\n      flxdec->frame_data = g_malloc (flxdec->size);\n      flxdec->delta_data = g_malloc (flxdec->size);\n\n      flxdec->state = GST_FLXDEC_PLAYING;\n    }\n  } else if (flxdec->state == GST_FLXDEC_PLAYING) {\n    GstBuffer *out;\n\n    \/* while we have enough data in the adapter *\/\n    while (avail >= FlxFrameChunkSize && res == GST_FLOW_OK) {\n      FlxFrameChunk flxfh;\n      guchar *chunk;\n      const guint8 *data;\n      GstMapInfo map;\n\n      chunk = NULL;\n      data = gst_adapter_map (flxdec->adapter, FlxFrameChunkSize);\n      memcpy (&flxfh, data, FlxFrameChunkSize);\n      FLX_FRAME_CHUNK_FIX_ENDIANNESS (&flxfh);\n      gst_adapter_unmap (flxdec->adapter);\n\n      switch (flxfh.id) {\n        case FLX_FRAME_TYPE:\n          \/* check if we have the complete frame *\/\n          if (avail < flxfh.size)\n            goto need_more_data;\n\n          \/* flush header *\/\n          gst_adapter_flush (flxdec->adapter, FlxFrameChunkSize);\n\n          chunk = gst_adapter_take (flxdec->adapter,\n              flxfh.size - FlxFrameChunkSize);\n          FLX_FRAME_TYPE_FIX_ENDIANNESS ((FlxFrameType *) chunk);\n          if (((FlxFrameType *) chunk)->chunks == 0)\n            break;\n\n          \/* create 32 bits output frame *\/\n\/\/          res = gst_pad_alloc_buffer_and_set_caps (flxdec->srcpad,\n\/\/              GST_BUFFER_OFFSET_NONE,\n\/\/              flxdec->size * 4, GST_PAD_CAPS (flxdec->srcpad), &out);\n\/\/          if (res != GST_FLOW_OK)\n\/\/            break;\n\n          out = gst_buffer_new_and_alloc (flxdec->size * 4);\n\n          \/* decode chunks *\/\n          if (!flx_decode_chunks (flxdec,\n                  ((FlxFrameType *) chunk)->chunks,\n                  chunk + FlxFrameTypeSize, flxdec->frame_data)) {\n            GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,\n                (\"%s\", \"Could not decode chunk\"), NULL);\n            return GST_FLOW_ERROR;\n          }\n\n          \/* save copy of the current frame for possible delta. *\/\n          memcpy (flxdec->delta_data, flxdec->frame_data, flxdec->size);\n\n          gst_buffer_map (out, &map, GST_MAP_WRITE);\n          \/* convert current frame. *\/\n          flx_colorspace_convert (flxdec->converter, flxdec->frame_data,\n              map.data);\n          gst_buffer_unmap (out, &map);\n\n          GST_BUFFER_TIMESTAMP (out) = flxdec->next_time;\n          flxdec->next_time += flxdec->frame_time;\n\n          res = gst_pad_push (flxdec->srcpad, out);\n          break;\n        default:\n          \/* check if we have the complete frame *\/\n          if (avail < flxfh.size)\n            goto need_more_data;\n\n          gst_adapter_flush (flxdec->adapter, flxfh.size);\n          break;\n      }\n\n      g_free (chunk);\n\n      avail = gst_adapter_available (flxdec->adapter);\n    }\n  }\nneed_more_data:\n  return res;\n\n  \/* ERRORS *\/\nwrong_type:\n  {\n    GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL),\n        (\"not a flx file (type %x)\", flxh->type));\n    return GST_FLOW_ERROR;\n  }\n}","target":0,"code_token_length":1672,"total_token_length":1908,"max_tokens_setting":2048}
+{"idx":289288,"func":"static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, \n\t\t\t\t   struct snd_pcm_hw_params *oss_params,\n\t\t\t\t   struct snd_pcm_hw_params *slave_params)\n{\n\tssize_t s;\n\tssize_t oss_buffer_size;\n\tssize_t oss_period_size, oss_periods;\n\tssize_t min_period_size, max_period_size;\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tsize_t oss_frame_size;\n\n\toss_frame_size = snd_pcm_format_physical_width(params_format(oss_params)) *\n\t\t\t params_channels(oss_params) \/ 8;\n\n\toss_buffer_size = snd_pcm_hw_param_value_max(slave_params,\n\t\t\t\t\t\t     SNDRV_PCM_HW_PARAM_BUFFER_SIZE,\n\t\t\t\t\t\t     NULL);\n\tif (oss_buffer_size <= 0)\n\t\treturn -EINVAL;\n\toss_buffer_size = snd_pcm_plug_client_size(substream,\n\t\t\t\t\t\t   oss_buffer_size * oss_frame_size);\n\tif (oss_buffer_size <= 0)\n\t\treturn -EINVAL;\n\toss_buffer_size = rounddown_pow_of_two(oss_buffer_size);\n\tif (atomic_read(&substream->mmap_count)) {\n\t\tif (oss_buffer_size > runtime->oss.mmap_bytes)\n\t\t\toss_buffer_size = runtime->oss.mmap_bytes;\n\t}\n\n\tif (substream->oss.setup.period_size > 16)\n\t\toss_period_size = substream->oss.setup.period_size;\n\telse if (runtime->oss.fragshift) {\n\t\toss_period_size = 1 << runtime->oss.fragshift;\n\t\tif (oss_period_size > oss_buffer_size \/ 2)\n\t\t\toss_period_size = oss_buffer_size \/ 2;\n\t} else {\n\t\tint sd;\n\t\tsize_t bytes_per_sec = params_rate(oss_params) * snd_pcm_format_physical_width(params_format(oss_params)) * params_channels(oss_params) \/ 8;\n\n\t\toss_period_size = oss_buffer_size;\n\t\tdo {\n\t\t\toss_period_size \/= 2;\n\t\t} while (oss_period_size > bytes_per_sec);\n\t\tif (runtime->oss.subdivision == 0) {\n\t\t\tsd = 4;\n\t\t\tif (oss_period_size \/ sd > 4096)\n\t\t\t\tsd *= 2;\n\t\t\tif (oss_period_size \/ sd < 4096)\n\t\t\t\tsd = 1;\n\t\t} else\n\t\t\tsd = runtime->oss.subdivision;\n\t\toss_period_size \/= sd;\n\t\tif (oss_period_size < 16)\n\t\t\toss_period_size = 16;\n\t}\n\n\tmin_period_size = snd_pcm_plug_client_size(substream,\n\t\t\t\t\t\t   snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));\n\tif (min_period_size > 0) {\n\t\tmin_period_size *= oss_frame_size;\n\t\tmin_period_size = roundup_pow_of_two(min_period_size);\n\t\tif (oss_period_size < min_period_size)\n\t\t\toss_period_size = min_period_size;\n\t}\n\n\tmax_period_size = snd_pcm_plug_client_size(substream,\n\t\t\t\t\t\t   snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));\n\tif (max_period_size > 0) {\n\t\tmax_period_size *= oss_frame_size;\n\t\tmax_period_size = rounddown_pow_of_two(max_period_size);\n\t\tif (oss_period_size > max_period_size)\n\t\t\toss_period_size = max_period_size;\n\t}\n\n\toss_periods = oss_buffer_size \/ oss_period_size;\n\n\tif (substream->oss.setup.periods > 1)\n\t\toss_periods = substream->oss.setup.periods;\n\n\ts = snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL);\n\tif (s > 0 && runtime->oss.maxfrags && s > runtime->oss.maxfrags)\n\t\ts = runtime->oss.maxfrags;\n\tif (oss_periods > s)\n\t\toss_periods = s;\n\n\ts = snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL);\n\tif (s < 2)\n\t\ts = 2;\n\tif (oss_periods < s)\n\t\toss_periods = s;\n\n\twhile (oss_period_size * oss_periods > oss_buffer_size)\n\t\toss_period_size \/= 2;\n\n\tif (oss_period_size < 16)\n\t\treturn -EINVAL;\n\n\t\/* don't allocate too large period; 1MB period must be enough *\/\n\tif (oss_period_size > 1024 * 1024)\n\t\treturn -ENOMEM;\n\n\truntime->oss.period_bytes = oss_period_size;\n\truntime->oss.period_frames = 1;\n\truntime->oss.periods = oss_periods;\n\treturn 0;\n}","target":0,"code_token_length":968,"total_token_length":1204,"max_tokens_setting":2048}
+{"idx":417480,"func":"virNodeDeviceDefFormat(const virNodeDeviceDef *def)\n{\n    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;\n    virNodeDevCapsDefPtr caps;\n    size_t i = 0;\n\n    virBufferAddLit(&buf, \"<device>\\n\");\n    virBufferAdjustIndent(&buf, 2);\n    virBufferEscapeString(&buf, \"<name>%s<\/name>\\n\", def->name);\n    virBufferEscapeString(&buf, \"<path>%s<\/path>\\n\", def->sysfs_path);\n    if (def->devnode)\n        virBufferEscapeString(&buf, \"<devnode type='dev'>%s<\/devnode>\\n\",\n                              def->devnode);\n    if (def->devlinks) {\n        for (i = 0; def->devlinks[i]; i++)\n            virBufferEscapeString(&buf, \"<devnode type='link'>%s<\/devnode>\\n\",\n                                  def->devlinks[i]);\n    }\n    if (def->parent)\n        virBufferEscapeString(&buf, \"<parent>%s<\/parent>\\n\", def->parent);\n    if (def->driver) {\n        virBufferAddLit(&buf, \"<driver>\\n\");\n        virBufferAdjustIndent(&buf, 2);\n        virBufferEscapeString(&buf, \"<name>%s<\/name>\\n\", def->driver);\n        virBufferAdjustIndent(&buf, -2);\n        virBufferAddLit(&buf, \"<\/driver>\\n\");\n    }\n\n    for (caps = def->caps; caps; caps = caps->next) {\n        virNodeDevCapDataPtr data = &caps->data;\n\n        virBufferAsprintf(&buf, \"<capability type='%s'>\\n\",\n                          virNodeDevCapTypeToString(caps->data.type));\n        virBufferAdjustIndent(&buf, 2);\n        switch (caps->data.type) {\n        case VIR_NODE_DEV_CAP_SYSTEM:\n            virNodeDeviceCapSystemDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_PCI_DEV:\n            virNodeDeviceCapPCIDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_USB_DEV:\n            virNodeDeviceCapUSBDevDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_USB_INTERFACE:\n            virNodeDeviceCapUSBInterfaceDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_NET:\n            virNodeDeviceCapNetDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_SCSI_HOST:\n            virNodeDeviceCapSCSIHostDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_SCSI_TARGET:\n            virBufferEscapeString(&buf, \"<target>%s<\/target>\\n\",\n                                  data->scsi_target.name);\n            if (data->scsi_target.flags & VIR_NODE_DEV_CAP_FLAG_FC_RPORT) {\n                virBufferAddLit(&buf, \"<capability type='fc_remote_port'>\\n\");\n                virBufferAdjustIndent(&buf, 2);\n                virBufferAsprintf(&buf, \"<rport>%s<\/rport>\\n\",\n                                  data->scsi_target.rport);\n                virBufferAsprintf(&buf, \"<wwpn>%s<\/wwpn>\\n\",\n                                  data->scsi_target.wwpn);\n                virBufferAdjustIndent(&buf, -2);\n                virBufferAddLit(&buf, \"<\/capability>\\n\");\n            }\n            break;\n        case VIR_NODE_DEV_CAP_SCSI:\n            virNodeDeviceCapSCSIDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_STORAGE:\n            virNodeDeviceCapStorageDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_SCSI_GENERIC:\n            virBufferEscapeString(&buf, \"<char>%s<\/char>\\n\",\n                                  data->sg.path);\n            break;\n        case VIR_NODE_DEV_CAP_DRM:\n            virBufferEscapeString(&buf, \"<type>%s<\/type>\\n\", virNodeDevDRMTypeToString(data->drm.type));\n            break;\n        case VIR_NODE_DEV_CAP_MDEV:\n            virNodeDeviceCapMdevDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_CCW_DEV:\n        case VIR_NODE_DEV_CAP_CSS_DEV:\n            virNodeDeviceCapCCWDefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_VDPA:\n            virNodeDeviceCapVDPADefFormat(&buf, data);\n            break;\n        case VIR_NODE_DEV_CAP_MDEV_TYPES:\n        case VIR_NODE_DEV_CAP_FC_HOST:\n        case VIR_NODE_DEV_CAP_VPORTS:\n        case VIR_NODE_DEV_CAP_LAST:\n            break;\n        }\n\n        virBufferAdjustIndent(&buf, -2);\n        virBufferAddLit(&buf, \"<\/capability>\\n\");\n    }\n\n    virBufferAdjustIndent(&buf, -2);\n    virBufferAddLit(&buf, \"<\/device>\\n\");\n\n    return virBufferContentAndReset(&buf);\n}","target":0,"code_token_length":1040,"total_token_length":1276,"max_tokens_setting":2048}
+{"idx":224227,"func":"static void _delete_submaps_from_bank_tree(RIO *io, RIOBank *bank, RListIter *prio, RIOMap *map) {\n\tRIOSubMap fake_sm;\n\tfake_sm.itv = map->itv;\n\tfake_sm.mapref.id = map->id;\n\tRRBNode *entry = _find_entry_submap_node (bank, &fake_sm);\n\tif (!entry) {\n\t\treturn;\n\t}\n\tRIOSubMap *bd = (RIOSubMap *)entry->data;\n\twhile (bd && r_io_submap_overlap (bd, (&fake_sm))) {\n\t\t\/\/ this loop deletes all affected submaps from the rbtree\n\t\t\/\/ and also enqueues them in bank->todo\n\t\tRRBNode *next = r_rbnode_next (entry);\n\t\tif (bd->mapref.id == fake_sm.mapref.id) {\n\t\t\tr_queue_enqueue (bank->todo, R_NEWCOPY (RIOSubMap, bd));\n\t\t\tr_crbtree_delete (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);\n\t\t}\n\t\tentry = next;\n\t\tbd = entry ? (RIOSubMap *)entry->data : NULL;\n\t}\n\tRListIter *iter = prio;\n\twhile (!r_queue_is_empty (bank->todo)) {\n\t\t\/\/ now check for each deleted submap if a lower map intersects with it\n\t\t\/\/ and create new submaps accordingly, and fill the gaps\n\t\tRIOSubMap *sm = r_queue_dequeue (bank->todo);\n\t\tRListIter *ator = r_list_iter_get_prev (iter);\n\t\twhile (ator) {\n\t\t\tmap = r_io_map_get_by_ref (io, (RIOMapRef *)ator->data);\n\t\t\tator = r_list_iter_get_prev (ator);\n\t\t\tif (!map) {\n\t\t\t\t\/\/ if this happens, something is fucked up, and no submap should be inserted\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/\/ if the map and sm intersect, the intersecting submap needs to be inserted in the tree\n\t\t\t\/\/ there are 5 cases to consider here\n\t\t\t\/\/ 1. no intersection: just continue to the next iteration\n\t\t\t\/\/ 2. map overlaps sm on both ends: insert submap for map with boundaries of sm\n\t\t\t\/\/ 3. map overlaps sm on the upper end: insert submap for map accordingly and adjust sm boundaries\n\t\t\t\/\/ 4. map overlaps sm on the lower end: insert submap for map accordingly and adjust sm boundaries\n\t\t\t\/\/ 5. sm overlaps sm on both ends: split sm into 2 submaps and enqueue new one in banks->todo; insert submap for map; adjust sm boundaries\n\t\t\tif (r_io_submap_to (sm) < r_io_map_from (map) || r_io_submap_from (sm) > r_io_map_to (map)) {\n\t\t\t\t\/\/ case 1\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tRIOMapRef *mapref = _mapref_from_map (map);\n\t\t\tbd = r_io_submap_new (io, mapref);\n\t\t\tfree (mapref);\n\t\t\tif (!bd) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (r_io_submap_from (sm) >= r_io_map_from (map)) {\n\t\t\t\t\/\/ case 4 and 2\n\t\t\t\tr_io_submap_set_from (bd, r_io_submap_from (sm));\n\t\t\t\tr_crbtree_insert (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\t\tif (r_io_submap_to (sm) <= r_io_map_to (map)) {\n\t\t\t\t\t\/\/ case 2\n\t\t\t\t\tr_io_submap_set_to (bd, r_io_submap_to (sm));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\/\/ case 4\n\t\t\t\tr_io_submap_set_from (sm, r_io_submap_to (bd) + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (r_io_submap_to (sm) <= r_io_map_to (map)) {\n\t\t\t\t\/\/ case 3\n\t\t\t\t\/\/ adjust bd upper boundary to avoid overlap with existing submaps\n\t\t\t\tr_io_submap_set_to (bd, r_io_submap_to (sm));\n\t\t\t\t\/\/ adjust sm upper boundary to avoid hitting again on sm in further iterations\n\t\t\t\tr_io_submap_set_to (sm, r_io_submap_from (bd) - 1);\n\t\t\t\tr_crbtree_insert (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/\/ case 5 because all other cases are already handled\n\t\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, sm);\n\t\t\tr_io_submap_set_to (sm, r_io_submap_from (bd) - 1);\n\t\t\tr_io_submap_set_from (bdsm, r_io_submap_to (bd) + 1);\n\t\t\tr_crbtree_insert (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\tr_queue_enqueue (bank->todo, bdsm);\n\t\t}\n\t\tfree (sm);\n\t}\n}","target":0,"code_token_length":1099,"total_token_length":1335,"max_tokens_setting":2048}
+{"idx":197796,"func":"static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)\n{\n    int i;\n    uint16_t limit;\n    VncDisplay *vd = vs->vd;\n\n    if (data[0] > 3) {\n        update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);\n    }\n\n    switch (data[0]) {\n    case VNC_MSG_CLIENT_SET_PIXEL_FORMAT:\n        if (len == 1)\n            return 20;\n\n        set_pixel_format(vs, read_u8(data, 4), read_u8(data, 5),\n                         read_u8(data, 6), read_u8(data, 7),\n                         read_u16(data, 8), read_u16(data, 10),\n                         read_u16(data, 12), read_u8(data, 14),\n                         read_u8(data, 15), read_u8(data, 16));\n        break;\n    case VNC_MSG_CLIENT_SET_ENCODINGS:\n        if (len == 1)\n            return 4;\n\n        if (len == 4) {\n            limit = read_u16(data, 2);\n            if (limit > 0)\n                return 4 + (limit * 4);\n        } else\n            limit = read_u16(data, 2);\n\n        for (i = 0; i < limit; i++) {\n            int32_t val = read_s32(data, 4 + (i * 4));\n            memcpy(data + 4 + (i * 4), &val, sizeof(val));\n        }\n\n        set_encodings(vs, (int32_t *)(data + 4), limit);\n        break;\n    case VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST:\n        if (len == 1)\n            return 10;\n\n        framebuffer_update_request(vs,\n                                   read_u8(data, 1), read_u16(data, 2), read_u16(data, 4),\n                                   read_u16(data, 6), read_u16(data, 8));\n        break;\n    case VNC_MSG_CLIENT_KEY_EVENT:\n        if (len == 1)\n            return 8;\n\n        key_event(vs, read_u8(data, 1), read_u32(data, 4));\n        break;\n    case VNC_MSG_CLIENT_POINTER_EVENT:\n        if (len == 1)\n            return 6;\n\n        pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4));\n        break;\n    case VNC_MSG_CLIENT_CUT_TEXT:\n        if (len == 1)\n            return 8;\n\n        if (len == 8) {\n            uint32_t dlen = read_u32(data, 4);\n            if (dlen > 0)\n                return 8 + dlen;\n        }\n\n        client_cut_text(vs, read_u32(data, 4), data + 8);\n        break;\n    case VNC_MSG_CLIENT_QEMU:\n        if (len == 1)\n            return 2;\n\n        switch (read_u8(data, 1)) {\n        case VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT:\n            if (len == 2)\n                return 12;\n\n            ext_key_event(vs, read_u16(data, 2),\n                          read_u32(data, 4), read_u32(data, 8));\n            break;\n        case VNC_MSG_CLIENT_QEMU_AUDIO:\n            if (len == 2)\n                return 4;\n\n            switch (read_u16 (data, 2)) {\n            case VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE:\n                audio_add(vs);\n                break;\n            case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE:\n                audio_del(vs);\n                break;\n            case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT:\n                if (len == 4)\n                    return 10;\n                switch (read_u8(data, 4)) {\n                case 0: vs->as.fmt = AUD_FMT_U8; break;\n                case 1: vs->as.fmt = AUD_FMT_S8; break;\n                case 2: vs->as.fmt = AUD_FMT_U16; break;\n                case 3: vs->as.fmt = AUD_FMT_S16; break;\n                case 4: vs->as.fmt = AUD_FMT_U32; break;\n                case 5: vs->as.fmt = AUD_FMT_S32; break;\n                default:\n                    printf(\"Invalid audio format %d\\n\", read_u8(data, 4));\n                    vnc_client_error(vs);\n                    break;\n                }\n                vs->as.nchannels = read_u8(data, 5);\n                if (vs->as.nchannels != 1 && vs->as.nchannels != 2) {\n                    printf(\"Invalid audio channel coount %d\\n\",\n                           read_u8(data, 5));\n                    vnc_client_error(vs);\n                    break;\n                }\n                vs->as.freq = read_u32(data, 6);\n                break;\n            default:\n                printf (\"Invalid audio message %d\\n\", read_u8(data, 4));\n                vnc_client_error(vs);\n                break;\n            }\n            break;\n\n        default:\n            printf(\"Msg: %d\\n\", read_u16(data, 0));\n            vnc_client_error(vs);\n            break;\n        }\n        break;\n    default:\n        printf(\"Msg: %d\\n\", data[0]);\n        vnc_client_error(vs);\n        break;\n    }\n\n    vnc_read_when(vs, protocol_client_msg, 1);\n    return 0;\n}","target":1,"code_token_length":1205,"total_token_length":1441,"max_tokens_setting":2048}
+{"idx":210520,"func":"get_lisp_indent(void)\n{\n    pos_T\t*pos, realpos, paren;\n    int\t\tamount;\n    char_u\t*that;\n    colnr_T\tcol;\n    colnr_T\tfirsttry;\n    int\t\tparencount, quotecount;\n    int\t\tvi_lisp;\n\n    \/\/ Set vi_lisp to use the vi-compatible method\n    vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);\n\n    realpos = curwin->w_cursor;\n    curwin->w_cursor.col = 0;\n\n    if ((pos = findmatch(NULL, '(')) == NULL)\n\tpos = findmatch(NULL, '[');\n    else\n    {\n\tparen = *pos;\n\tpos = findmatch(NULL, '[');\n\tif (pos == NULL || LT_POSP(pos, &paren))\n\t    pos = &paren;\n    }\n    if (pos != NULL)\n    {\n\t\/\/ Extra trick: Take the indent of the first previous non-white\n\t\/\/ line that is at the same () level.\n\tamount = -1;\n\tparencount = 0;\n\n\twhile (--curwin->w_cursor.lnum >= pos->lnum)\n\t{\n\t    if (linewhite(curwin->w_cursor.lnum))\n\t\tcontinue;\n\t    for (that = ml_get_curline(); *that != NUL; ++that)\n\t    {\n\t\tif (*that == ';')\n\t\t{\n\t\t    while (*(that + 1) != NUL)\n\t\t\t++that;\n\t\t    continue;\n\t\t}\n\t\tif (*that == '\\\\')\n\t\t{\n\t\t    if (*(that + 1) != NUL)\n\t\t\t++that;\n\t\t    continue;\n\t\t}\n\t\tif (*that == '\"' && *(that + 1) != NUL)\n\t\t{\n\t\t    while (*++that && *that != '\"')\n\t\t    {\n\t\t\t\/\/ skipping escaped characters in the string\n\t\t\tif (*that == '\\\\')\n\t\t\t{\n\t\t\t    if (*++that == NUL)\n\t\t\t\tbreak;\n\t\t\t    if (that[1] == NUL)\n\t\t\t    {\n\t\t\t\t++that;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t    if (*that == NUL)\n\t\t\tbreak;\n\t\t}\n\t\tif (*that == '(' || *that == '[')\n\t\t    ++parencount;\n\t\telse if (*that == ')' || *that == ']')\n\t\t    --parencount;\n\t    }\n\t    if (parencount == 0)\n\t    {\n\t\tamount = get_indent();\n\t\tbreak;\n\t    }\n\t}\n\n\tif (amount == -1)\n\t{\n\t    curwin->w_cursor.lnum = pos->lnum;\n\t    curwin->w_cursor.col = pos->col;\n\t    col = pos->col;\n\n\t    that = ml_get_curline();\n\n\t    if (vi_lisp && get_indent() == 0)\n\t\tamount = 2;\n\t    else\n\t    {\n\t\tchar_u *line = that;\n\n\t\tamount = 0;\n\t\twhile (*that && col)\n\t\t{\n\t\t    amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);\n\t\t    col--;\n\t\t}\n\n\t\t\/\/ Some keywords require \"body\" indenting rules (the\n\t\t\/\/ non-standard-lisp ones are Scheme special forms):\n\t\t\/\/\n\t\t\/\/ (let ((a 1))    instead    (let ((a 1))\n\t\t\/\/   (...))\t      of\t   (...))\n\n\t\tif (!vi_lisp && (*that == '(' || *that == '[')\n\t\t\t\t\t\t      && lisp_match(that + 1))\n\t\t    amount += 2;\n\t\telse\n\t\t{\n\t\t    that++;\n\t\t    amount++;\n\t\t    firsttry = amount;\n\n\t\t    while (VIM_ISWHITE(*that))\n\t\t    {\n\t\t\tamount += lbr_chartabsize(line, that, (colnr_T)amount);\n\t\t\t++that;\n\t\t    }\n\n\t\t    if (*that && *that != ';') \/\/ not a comment line\n\t\t    {\n\t\t\t\/\/ test *that != '(' to accommodate first let\/do\n\t\t\t\/\/ argument if it is more than one line\n\t\t\tif (!vi_lisp && *that != '(' && *that != '[')\n\t\t\t    firsttry++;\n\n\t\t\tparencount = 0;\n\t\t\tquotecount = 0;\n\n\t\t\tif (vi_lisp\n\t\t\t\t|| (*that != '\"'\n\t\t\t\t    && *that != '\\''\n\t\t\t\t    && *that != '#'\n\t\t\t\t    && (*that < '0' || *that > '9')))\n\t\t\t{\n\t\t\t    while (*that\n\t\t\t\t    && (!VIM_ISWHITE(*that)\n\t\t\t\t\t|| quotecount\n\t\t\t\t\t|| parencount)\n\t\t\t\t    && (!((*that == '(' || *that == '[')\n\t\t\t\t\t    && !quotecount\n\t\t\t\t\t    && !parencount\n\t\t\t\t\t    && vi_lisp)))\n\t\t\t    {\n\t\t\t\tif (*that == '\"')\n\t\t\t\t    quotecount = !quotecount;\n\t\t\t\tif ((*that == '(' || *that == '[')\n\t\t\t\t\t\t\t       && !quotecount)\n\t\t\t\t    ++parencount;\n\t\t\t\tif ((*that == ')' || *that == ']')\n\t\t\t\t\t\t\t       && !quotecount)\n\t\t\t\t    --parencount;\n\t\t\t\tif (*that == '\\\\' && *(that+1) != NUL)\n\t\t\t\t    amount += lbr_chartabsize_adv(\n\t\t\t\t\t\tline, &that, (colnr_T)amount);\n\t\t\t\tamount += lbr_chartabsize_adv(\n\t\t\t\t\t\tline, &that, (colnr_T)amount);\n\t\t\t    }\n\t\t\t}\n\t\t\twhile (VIM_ISWHITE(*that))\n\t\t\t{\n\t\t\t    amount += lbr_chartabsize(\n\t\t\t\t\t\t line, that, (colnr_T)amount);\n\t\t\t    that++;\n\t\t\t}\n\t\t\tif (!*that || *that == ';')\n\t\t\t    amount = firsttry;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n    else\n\tamount = 0;\t\/\/ no matching '(' or '[' found, use zero indent\n\n    curwin->w_cursor = realpos;\n\n    return amount;\n}","target":1,"code_token_length":1243,"total_token_length":1479,"max_tokens_setting":2048}
+{"idx":313735,"func":"normal_cmd_get_count(\n\tcmdarg_T\t*cap,\n\tint\t\tc,\n\tint\t\ttoplevel UNUSED,\n\tint\t\tset_prevcount UNUSED,\n\tint\t\t*ctrl_w,\n\tint\t\t*need_flushbuf UNUSED)\n{\ngetcount:\n    if (!(VIsual_active && VIsual_select))\n    {\n\t\/\/ Handle a count before a command and compute ca.count0.\n\t\/\/ Note that '0' is a command and not the start of a count, but it's\n\t\/\/ part of a count after other digits.\n\twhile ((c >= '1' && c <= '9')\n\t\t|| (cap->count0 != 0 && (c == K_DEL || c == K_KDEL\n\t\t\t|| c == '0')))\n\t{\n\t    if (c == K_DEL || c == K_KDEL)\n\t    {\n\t\tcap->count0 \/= 10;\n#ifdef FEAT_CMDL_INFO\n\t\tdel_from_showcmd(4);\t\/\/ delete the digit and ~@%\n#endif\n\t    }\n\t    else if (cap->count0 > 99999999L)\n\t    {\n\t\tcap->count0 = 999999999L;\n\t    }\n\t    else\n\t    {\n\t\tcap->count0 = cap->count0 * 10 + (c - '0');\n\t    }\n#ifdef FEAT_EVAL\n\t    \/\/ Set v:count here, when called from main() and not a stuffed\n\t    \/\/ command, so that v:count can be used in an expression mapping\n\t    \/\/ right after the count. Do set it for redo.\n\t    if (toplevel && readbuf1_empty())\n\t\tset_vcount_ca(cap, &set_prevcount);\n#endif\n\t    if (*ctrl_w)\n\t    {\n\t\t++no_mapping;\n\t\t++allow_keys;\t\t\/\/ no mapping for nchar, but keys\n\t    }\n\t    ++no_zero_mapping;\t\t\/\/ don't map zero here\n\t    c = plain_vgetc();\n\t    LANGMAP_ADJUST(c, TRUE);\n\t    --no_zero_mapping;\n\t    if (*ctrl_w)\n\t    {\n\t\t--no_mapping;\n\t\t--allow_keys;\n\t    }\n#ifdef FEAT_CMDL_INFO\n\t    *need_flushbuf |= add_to_showcmd(c);\n#endif\n\t}\n\n\t\/\/ If we got CTRL-W there may be a\/another count\n\tif (c == Ctrl_W && !*ctrl_w && cap->oap->op_type == OP_NOP)\n\t{\n\t    *ctrl_w = TRUE;\n\t    cap->opcount = cap->count0;\t\/\/ remember first count\n\t    cap->count0 = 0;\n\t    ++no_mapping;\n\t    ++allow_keys;\t\t\/\/ no mapping for nchar, but keys\n\t    c = plain_vgetc();\t\t\/\/ get next character\n\t    LANGMAP_ADJUST(c, TRUE);\n\t    --no_mapping;\n\t    --allow_keys;\n#ifdef FEAT_CMDL_INFO\n\t    *need_flushbuf |= add_to_showcmd(c);\n#endif\n\t    goto getcount;\t\t\/\/ jump back\n\t}\n    }\n\n    if (c == K_CURSORHOLD)\n    {\n\t\/\/ Save the count values so that ca.opcount and ca.count0 are exactly\n\t\/\/ the same when coming back here after handling K_CURSORHOLD.\n\tcap->oap->prev_opcount = cap->opcount;\n\tcap->oap->prev_count0 = cap->count0;\n    }\n    else if (cap->opcount != 0)\n    {\n\t\/\/ If we're in the middle of an operator (including after entering a\n\t\/\/ yank buffer with '\"') AND we had a count before the operator, then\n\t\/\/ that count overrides the current value of ca.count0.\n\t\/\/ What this means effectively, is that commands like \"3dw\" get turned\n\t\/\/ into \"d3w\" which makes things fall into place pretty neatly.\n\t\/\/ If you give a count before AND after the operator, they are\n\t\/\/ multiplied.\n\tif (cap->count0)\n\t{\n\t    if (cap->opcount >= 999999999L \/ cap->count0)\n\t\tcap->count0 = 999999999L;\n\t    else\n\t\tcap->count0 *= cap->opcount;\n\t}\n\telse\n\t    cap->count0 = cap->opcount;\n    }\n\n    \/\/ Always remember the count.  It will be set to zero (on the next call,\n    \/\/ above) when there is no pending operator.\n    \/\/ When called from main(), save the count for use by the \"count\" built-in\n    \/\/ variable.\n    cap->opcount = cap->count0;\n    cap->count1 = (cap->count0 == 0 ? 1 : cap->count0);\n\n#ifdef FEAT_EVAL\n    \/\/ Only set v:count when called from main() and not a stuffed command.\n    \/\/ Do set it for redo.\n    if (toplevel && readbuf1_empty())\n\tset_vcount(cap->count0, cap->count1, set_prevcount);\n#endif\n\n    return c;\n}","target":0,"code_token_length":1077,"total_token_length":1313,"max_tokens_setting":2048}
+{"idx":195343,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Here's the basic idea:\n    \/\/ Batch and depth dimension are independent from row and col dimension. And\n    \/\/ because FractionalAvgPool currently only support pooling along row and\n    \/\/ col, we can basically think of this 4D tensor backpropagation as\n    \/\/ operation of a series of 2D planes.\n    \/\/\n    \/\/ For each element of a 'slice' (2D plane) of output_backprop, we need to\n    \/\/ figure out its contributors when doing FractionalAvgPool operation. This\n    \/\/ can be done based on row_pooling_sequence, col_pooling_seq and\n    \/\/ overlapping.\n    \/\/ Once we figure out the original contributors, we just need to evenly\n    \/\/ divide the value of this element among these contributors.\n    \/\/\n    \/\/ Internally, we divide the out_backprop tensor and store it in a temporary\n    \/\/ tensor of double type. And cast it to the corresponding type.\n    typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        ConstEigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenDoubleMatrixMap;\n\n    \/\/ Grab the inputs.\n    const Tensor& orig_input_tensor_shape = context->input(0);\n    OP_REQUIRES(context,\n                orig_input_tensor_shape.dims() == 1 &&\n                    orig_input_tensor_shape.NumElements() == 4,\n                errors::InvalidArgument(\"original input tensor shape must be\"\n                                        \"1-dimensional and 4 elements\"));\n    const Tensor& out_backprop = context->input(1);\n    const Tensor& row_seq_tensor = context->input(2);\n    const Tensor& col_seq_tensor = context->input(3);\n\n    const int64_t out_batch = out_backprop.dim_size(0);\n    const int64_t out_rows = out_backprop.dim_size(1);\n    const int64_t out_cols = out_backprop.dim_size(2);\n    const int64_t out_depth = out_backprop.dim_size(3);\n\n    OP_REQUIRES(context, row_seq_tensor.NumElements() > out_rows,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", row_seq_tensor must have at least \",\n                                        out_rows + 1, \" elements, but got \",\n                                        row_seq_tensor.NumElements()));\n    OP_REQUIRES(context, col_seq_tensor.NumElements() > out_cols,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", col_seq_tensor must have at least \",\n                                        out_cols + 1, \" elements, but got \",\n                                        col_seq_tensor.NumElements()));\n\n    auto row_seq_tensor_flat = row_seq_tensor.flat<int64_t>();\n    auto col_seq_tensor_flat = col_seq_tensor.flat<int64_t>();\n    auto orig_input_tensor_shape_flat = orig_input_tensor_shape.flat<int64_t>();\n\n    const int64_t in_batch = orig_input_tensor_shape_flat(0);\n    const int64_t in_rows = orig_input_tensor_shape_flat(1);\n    const int64_t in_cols = orig_input_tensor_shape_flat(2);\n    const int64_t in_depth = orig_input_tensor_shape_flat(3);\n    OP_REQUIRES(\n        context, in_batch != 0,\n        errors::InvalidArgument(\"Batch dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_rows != 0,\n        errors::InvalidArgument(\"Rows dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_cols != 0,\n        errors::InvalidArgument(\"Columns dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_depth != 0,\n        errors::InvalidArgument(\"Depth dimension of input must not be 0\"));\n\n    constexpr int tensor_in_and_out_dims = 4;\n    \/\/ Transform orig_input_tensor_shape into TensorShape\n    TensorShape in_shape;\n    for (auto i = 0; i < tensor_in_and_out_dims; ++i) {\n      in_shape.AddDim(orig_input_tensor_shape_flat(i));\n    }\n\n    \/\/ Create intermediate in_backprop.\n    Tensor in_backprop_tensor_temp;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(\n                                {0}, DataTypeToEnum<double>::v(), in_shape,\n                                &in_backprop_tensor_temp));\n    in_backprop_tensor_temp.flat<double>().setZero();\n    \/\/ Transform 4D tensor to 2D matrix.\n    EigenDoubleMatrixMap in_backprop_tensor_temp_mat(\n        in_backprop_tensor_temp.flat<double>().data(), in_depth,\n        in_cols * in_rows * in_batch);\n    ConstEigenMatrixMap out_backprop_mat(out_backprop.flat<T>().data(),\n                                         out_depth,\n                                         out_cols * out_rows * out_batch);\n    \/\/ Loop through each element of out_backprop and evenly distribute the\n    \/\/ element to the corresponding pooling cell.\n    const int64_t in_max_row_index = in_rows - 1;\n    const int64_t in_max_col_index = in_cols - 1;\n    for (int64_t b = 0; b < out_batch; ++b) {\n      for (int64_t r = 0; r < out_rows; ++r) {\n        const int64_t in_row_start = row_seq_tensor_flat(r);\n        int64_t in_row_end = overlapping_ ? row_seq_tensor_flat(r + 1)\n                                          : row_seq_tensor_flat(r + 1) - 1;\n        in_row_end = std::min(in_row_end, in_max_row_index);\n        for (int64_t c = 0; c < out_cols; ++c) {\n          const int64_t in_col_start = col_seq_tensor_flat(c);\n          int64_t in_col_end = overlapping_ ? col_seq_tensor_flat(c + 1)\n                                            : col_seq_tensor_flat(c + 1) - 1;\n          in_col_end = std::min(in_col_end, in_max_col_index);\n\n          const int64_t num_elements_in_pooling_cell =\n              (in_row_end - in_row_start + 1) * (in_col_end - in_col_start + 1);\n          const int64_t out_index = (b * out_rows + r) * out_cols + c;\n          \/\/ Now we can evenly distribute out_backprop(b, h, w, *) to\n          \/\/ in_backprop(b, hs:he, ws:we, *).\n          for (int64_t in_r = in_row_start; in_r <= in_row_end; ++in_r) {\n            for (int64_t in_c = in_col_start; in_c <= in_col_end; ++in_c) {\n              const int64_t in_index = (b * in_rows + in_r) * in_cols + in_c;\n              \/\/ Walk through each channel (depth).\n              for (int64_t d = 0; d < out_depth; ++d) {\n                const double out_backprop_element = static_cast<double>(\n                    out_backprop_mat.coeffRef(d, out_index));\n                double& in_backprop_ref =\n                    in_backprop_tensor_temp_mat.coeffRef(d, in_index);\n                in_backprop_ref +=\n                    out_backprop_element \/ num_elements_in_pooling_cell;\n              }\n            }\n          }\n        }\n      }\n    }\n\n    \/\/ Depending on the type, cast double to type T.\n    Tensor* in_backprop_tensor = nullptr;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(\n                                {0}, 0, in_shape, &in_backprop_tensor));\n    auto in_backprop_tensor_flat = in_backprop_tensor->flat<T>();\n    auto in_backprop_tensor_temp_flat = in_backprop_tensor_temp.flat<double>();\n    for (int64_t i = 0; i < in_backprop_tensor_flat.size(); ++i) {\n      in_backprop_tensor_flat(i) =\n          static_cast<T>(in_backprop_tensor_temp_flat(i));\n    }\n  }","target":1,"code_token_length":1702,"total_token_length":1938,"max_tokens_setting":2048}
+{"idx":261391,"func":"bool read_pred_weight_table(bitreader* br, slice_segment_header* shdr, decoder_context* ctx)\n{\n  int vlc;\n\n  pic_parameter_set* pps = ctx->get_pps((int)shdr->slice_pic_parameter_set_id);\n  assert(pps);\n  seq_parameter_set* sps = ctx->get_sps((int)pps->seq_parameter_set_id);\n  assert(sps);\n\n  shdr->luma_log2_weight_denom = vlc = get_uvlc(br);\n  if (vlc<0 || vlc>7) return false;\n\n  if (sps->chroma_format_idc != 0) {\n    vlc = get_svlc(br);\n    vlc += shdr->luma_log2_weight_denom;\n    if (vlc<0 || vlc>7) return false;\n    shdr->ChromaLog2WeightDenom = vlc;\n  }\n\n  int sumWeightFlags = 0;\n\n  for (int l=0;l<=1;l++)\n    if (l==0 || (l==1 && shdr->slice_type == SLICE_TYPE_B))\n      {\n        int num_ref = (l==0 ? shdr->num_ref_idx_l0_active-1 : shdr->num_ref_idx_l1_active-1);\n\n        for (int i=0;i<=num_ref;i++) {\n          shdr->luma_weight_flag[l][i] = get_bits(br,1);\n          if (shdr->luma_weight_flag[l][i]) sumWeightFlags++;\n        }\n\n        if (sps->chroma_format_idc != 0) {\n          for (int i=0;i<=num_ref;i++) {\n            shdr->chroma_weight_flag[l][i] = get_bits(br,1);\n            if (shdr->chroma_weight_flag[l][i]) sumWeightFlags+=2;\n          }\n        }\n\n        for (int i=0;i<=num_ref;i++) {\n          if (shdr->luma_weight_flag[l][i]) {\n\n            \/\/ delta_luma_weight\n\n            vlc = get_svlc(br);\n            if (vlc < -128 || vlc > 127) return false;\n\n            shdr->LumaWeight[l][i] = (1<<shdr->luma_log2_weight_denom) + vlc;\n\n            \/\/ luma_offset\n\n            vlc = get_svlc(br);\n            if (vlc < -sps->WpOffsetHalfRangeY || vlc > sps->WpOffsetHalfRangeY-1) return false;\n            shdr->luma_offset[l][i] = vlc;\n          }\n          else {\n            shdr->LumaWeight[l][i] = 1<<shdr->luma_log2_weight_denom;\n            shdr->luma_offset[l][i] = 0;\n          }\n\n          if (shdr->chroma_weight_flag[l][i])\n            for (int j=0;j<2;j++) {\n              \/\/ delta_chroma_weight\n\n              vlc = get_svlc(br);\n              if (vlc < -128 || vlc >  127) return false;\n\n              shdr->ChromaWeight[l][i][j] = (1<<shdr->ChromaLog2WeightDenom) + vlc;\n\n              \/\/ delta_chroma_offset\n\n              vlc = get_svlc(br);\n              if (vlc < -4*sps->WpOffsetHalfRangeC ||\n                  vlc >  4*sps->WpOffsetHalfRangeC-1) return false;\n\n              vlc = Clip3(-sps->WpOffsetHalfRangeC,\n                          sps->WpOffsetHalfRangeC-1,\n                          (sps->WpOffsetHalfRangeC\n                           +vlc\n                           -((sps->WpOffsetHalfRangeC*shdr->ChromaWeight[l][i][j])\n                             >> shdr->ChromaLog2WeightDenom)));\n\n              shdr->ChromaOffset[l][i][j] = vlc;\n            }\n          else {\n            for (int j=0;j<2;j++) {\n              shdr->ChromaWeight[l][i][j] = 1<<shdr->ChromaLog2WeightDenom;\n              shdr->ChromaOffset[l][i][j] = 0;\n            }\n          }\n        }\n      }\n\n  \/\/ TODO: bitstream conformance requires that 'sumWeightFlags<=24'\n\n  return true;\n}","target":0,"code_token_length":954,"total_token_length":1190,"max_tokens_setting":2048}
+{"idx":513228,"func":"void plugin_shutdown(void)\n{\n  uint i, count= plugin_array.elements;\n  struct st_plugin_int **plugins, *plugin;\n  struct st_plugin_dl **dl;\n  DBUG_ENTER(\"plugin_shutdown\");\n\n  if (initialized)\n  {\n    mysql_mutex_lock(&LOCK_plugin);\n\n    reap_needed= true;\n\n    \/*\n      We want to shut down plugins in a reasonable order, this will\n      become important when we have plugins which depend upon each other.\n      Circular references cannot be reaped so they are forced afterwards.\n      TODO: Have an additional step here to notify all active plugins that\n      shutdown is requested to allow plugins to deinitialize in parallel.\n    *\/\n    while (reap_needed && (count= plugin_array.elements))\n    {\n      reap_plugins();\n      for (i= 0; i < count; i++)\n      {\n        plugin= *dynamic_element(&plugin_array, i, struct st_plugin_int **);\n        if (plugin->state == PLUGIN_IS_READY)\n        {\n          plugin->state= PLUGIN_IS_DELETED;\n          reap_needed= true;\n        }\n      }\n      if (!reap_needed)\n      {\n        \/*\n          release any plugin references held.\n        *\/\n        unlock_variables(NULL, &global_system_variables);\n        unlock_variables(NULL, &max_system_variables);\n      }\n    }\n\n    plugins= (struct st_plugin_int **) my_alloca(sizeof(void*) * (count+1));\n\n    \/*\n      If we have any plugins which did not die cleanly, we force shutdown\n    *\/\n    for (i= 0; i < count; i++)\n    {\n      plugins[i]= *dynamic_element(&plugin_array, i, struct st_plugin_int **);\n      \/* change the state to ensure no reaping races *\/\n      if (plugins[i]->state == PLUGIN_IS_DELETED)\n        plugins[i]->state= PLUGIN_IS_DYING;\n    }\n    mysql_mutex_unlock(&LOCK_plugin);\n\n    \/*\n      We loop through all plugins and call deinit() if they have one.\n    *\/\n    for (i= 0; i < count; i++)\n      if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED |\n                                 PLUGIN_IS_DISABLED)))\n      {\n        \/*\n          We are forcing deinit on plugins so we don't want to do a ref_count\n          check until we have processed all the plugins.\n        *\/\n        plugin_deinitialize(plugins[i], false);\n      }\n\n    \/*\n      It's perfectly safe not to lock LOCK_plugin, as there're no\n      concurrent threads anymore. But some functions called from here\n      use mysql_mutex_assert_owner(), so we lock the mutex to satisfy it\n    *\/\n    mysql_mutex_lock(&LOCK_plugin);\n\n    \/*\n      We defer checking ref_counts until after all plugins are deinitialized\n      as some may have worker threads holding on to plugin references.\n    *\/\n    for (i= 0; i < count; i++)\n    {\n      if (plugins[i]->ref_count)\n        sql_print_error(\"Plugin '%s' has ref_count=%d after shutdown.\",\n                        plugins[i]->name.str, plugins[i]->ref_count);\n      if (plugins[i]->state & PLUGIN_IS_UNINITIALIZED ||\n          plugins[i]->state & PLUGIN_IS_DISABLED)\n        plugin_del(plugins[i]);\n    }\n\n    \/*\n      Now we can deallocate all memory.\n    *\/\n\n    cleanup_variables(&global_system_variables);\n    cleanup_variables(&max_system_variables);\n    mysql_mutex_unlock(&LOCK_plugin);\n\n    initialized= 0;\n    mysql_mutex_destroy(&LOCK_plugin);\n\n    my_afree(plugins);\n  }\n\n  \/* Dispose of the memory *\/\n\n  for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)\n    my_hash_free(&plugin_hash[i]);\n  delete_dynamic(&plugin_array);\n\n  count= plugin_dl_array.elements;\n  dl= (struct st_plugin_dl **)my_alloca(sizeof(void*) * count);\n  for (i= 0; i < count; i++)\n    dl[i]= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);\n  for (i= 0; i < plugin_dl_array.elements; i++)\n    free_plugin_mem(dl[i]);\n  my_afree(dl);\n  delete_dynamic(&plugin_dl_array);\n\n  my_hash_free(&bookmark_hash);\n  free_root(&plugin_mem_root, MYF(0));\n  free_root(&plugin_vars_mem_root, MYF(0));\n\n  global_variables_dynamic_size= 0;\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":922,"total_token_length":1158,"max_tokens_setting":2048}
+{"idx":444900,"func":"add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstype)\n{\n\tint rc = 0, tmprc, fd;\n\tuid_t uid;\n\tchar *mount_user = NULL;\n\tstruct mntent mountent;\n\tstruct stat statbuf;\n\tFILE *pmntfile;\n\tsigset_t mask, oldmask;\n\n\tuid = getuid();\n\tif (uid != 0)\n\t\tmount_user = getusername(uid);\n\n\t\/*\n\t * Set the real uid to the effective uid. This prevents unprivileged\n\t * users from sending signals to this process, though ^c on controlling\n\t * terminal should still work.\n\t *\/\n\trc = setreuid(geteuid(), -1);\n\tif (rc != 0) {\n\t\tfprintf(stderr, \"Unable to set real uid to effective uid: %s\\n\",\n\t\t\t\tstrerror(errno));\n\t\treturn EX_FILEIO;\n\t}\n\n\trc = sigfillset(&mask);\n\tif (rc) {\n\t\tfprintf(stderr, \"Unable to set filled signal mask\\n\");\n\t\treturn EX_FILEIO;\n\t}\n\n\trc = sigprocmask(SIG_SETMASK, &mask, &oldmask);\n\tif (rc) {\n\t\tfprintf(stderr, \"Unable to make process ignore signals\\n\");\n\t\treturn EX_FILEIO;\n\t}\n\n\trc = toggle_dac_capability(1, 1);\n\tif (rc)\n\t\treturn EX_FILEIO;\n\n\tatexit(unlock_mtab);\n\trc = lock_mtab();\n\tif (rc) {\n\t\tfprintf(stderr, \"cannot lock mtab\");\n\t\trc = EX_FILEIO;\n\t\tgoto add_mtab_exit;\n\t}\n\n\tpmntfile = setmntent(MOUNTED, \"a+\");\n\tif (!pmntfile) {\n\t\tfprintf(stderr, \"could not update mount table\\n\");\n\t\tunlock_mtab();\n\t\trc = EX_FILEIO;\n\t\tgoto add_mtab_exit;\n\t}\n\n\tfd = fileno(pmntfile);\n\tif (fd < 0) {\n\t\tfprintf(stderr, \"mntent does not appear to be valid\\n\");\n\t\tunlock_mtab();\n\t\trc = EX_FILEIO;\n\t\tgoto add_mtab_exit;\n\t}\n\n\trc = fstat(fd, &statbuf);\n\tif (rc != 0) {\n\t\tfprintf(stderr, \"unable to fstat open mtab\\n\");\n\t\tendmntent(pmntfile);\n\t\tunlock_mtab();\n\t\trc = EX_FILEIO;\n\t\tgoto add_mtab_exit;\n\t}\n\n\tmountent.mnt_fsname = devname;\n\tmountent.mnt_dir = mountpoint;\n\tmountent.mnt_type = (char *)(void *)fstype;\n\tmountent.mnt_opts = (char *)calloc(MTAB_OPTIONS_LEN, 1);\n\tif (mountent.mnt_opts) {\n\t\tif (flags & MS_RDONLY)\n\t\t\tstrlcat(mountent.mnt_opts, \"ro\", MTAB_OPTIONS_LEN);\n\t\telse\n\t\t\tstrlcat(mountent.mnt_opts, \"rw\", MTAB_OPTIONS_LEN);\n\n\t\tif (flags & MS_MANDLOCK)\n\t\t\tstrlcat(mountent.mnt_opts, \",mand\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_NOEXEC)\n\t\t\tstrlcat(mountent.mnt_opts, \",noexec\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_NOSUID)\n\t\t\tstrlcat(mountent.mnt_opts, \",nosuid\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_NODEV)\n\t\t\tstrlcat(mountent.mnt_opts, \",nodev\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_SYNCHRONOUS)\n\t\t\tstrlcat(mountent.mnt_opts, \",sync\", MTAB_OPTIONS_LEN);\n\t\tif (mount_user) {\n\t\t\tstrlcat(mountent.mnt_opts, \",user=\", MTAB_OPTIONS_LEN);\n\t\t\tstrlcat(mountent.mnt_opts, mount_user,\n\t\t\t\tMTAB_OPTIONS_LEN);\n\t\t}\n\t}\n\tmountent.mnt_freq = 0;\n\tmountent.mnt_passno = 0;\n\trc = addmntent(pmntfile, &mountent);\n\tif (rc) {\n\t\tfprintf(stderr, \"unable to add mount entry to mtab\\n\");\n\t\tftruncate(fd, statbuf.st_size);\n\t\trc = EX_FILEIO;\n\t}\n\ttmprc = my_endmntent(pmntfile, statbuf.st_size);\n\tif (tmprc) {\n\t\tfprintf(stderr, \"error %d detected on close of mtab\\n\", tmprc);\n\t\trc = EX_FILEIO;\n\t}\n\tunlock_mtab();\n\tSAFE_FREE(mountent.mnt_opts);\nadd_mtab_exit:\n\ttoggle_dac_capability(1, 0);\n\tsigprocmask(SIG_SETMASK, &oldmask, NULL);\n\n\treturn rc;\n}","target":0,"code_token_length":990,"total_token_length":1226,"max_tokens_setting":2048}
+{"idx":312592,"func":"ex_helpgrep(exarg_T *eap)\n{\n    regmatch_T\tregmatch;\n    char_u\t*save_cpo;\n    int\t\tsave_cpo_allocated;\n    qf_info_T\t*qi = &ql_info;\n    int\t\tnew_qi = FALSE;\n    char_u\t*au_name =  NULL;\n    char_u\t*lang = NULL;\n    int\t\tupdated = FALSE;\n\n    switch (eap->cmdidx)\n    {\n\tcase CMD_helpgrep:  au_name = (char_u *)\"helpgrep\"; break;\n\tcase CMD_lhelpgrep: au_name = (char_u *)\"lhelpgrep\"; break;\n\tdefault: break;\n    }\n    if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,\n\t\t\t\t\t       curbuf->b_fname, TRUE, curbuf))\n    {\n#ifdef FEAT_EVAL\n\tif (aborting())\n\t    return;\n#endif\n    }\n\n    if (is_loclist_cmd(eap->cmdidx))\n    {\n\tqi = hgr_get_ll(&new_qi);\n\tif (qi == NULL)\n\t    return;\n    }\n\n    \/\/ Make 'cpoptions' empty, the 'l' flag should not be used here.\n    save_cpo = p_cpo;\n    save_cpo_allocated = is_option_allocated(\"cpo\");\n    p_cpo = empty_option;\n\n    incr_quickfix_busy();\n\n#ifdef FEAT_MULTI_LANG\n    \/\/ Check for a specified language\n    lang = check_help_lang(eap->arg);\n#endif\n    regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);\n    regmatch.rm_ic = FALSE;\n    if (regmatch.regprog != NULL)\n    {\n\tqf_list_T\t*qfl;\n\n\t\/\/ create a new quickfix list\n\tqf_new_list(qi, qf_cmdtitle(*eap->cmdlinep));\n\tqfl = qf_get_curlist(qi);\n\n\thgr_search_in_rtp(qfl, ®match, lang);\n\n\tvim_regfree(regmatch.regprog);\n\n\tqfl->qf_nonevalid = FALSE;\n\tqfl->qf_ptr = qfl->qf_start;\n\tqfl->qf_index = 1;\n\tqf_list_changed(qfl);\n\tupdated = TRUE;\n    }\n\n    if (p_cpo == empty_option)\n\tp_cpo = save_cpo;\n    else\n    {\n\t\/\/ Darn, some plugin changed the value.  If it's still empty it was\n\t\/\/ changed and restored, need to restore in the complicated way.\n\tif (*p_cpo == NUL)\n\t    set_option_value_give_err((char_u *)\"cpo\", 0L, save_cpo, 0);\n\tif (save_cpo_allocated)\n\t    free_string_option(save_cpo);\n    }\n\n    if (updated)\n\t\/\/ This may open a window and source scripts, do this after 'cpo' was\n\t\/\/ restored.\n\tqf_update_buffer(qi, NULL);\n\n    if (au_name != NULL)\n    {\n\tapply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,\n\t\t\t\t\t       curbuf->b_fname, TRUE, curbuf);\n\t\/\/ When adding a location list to an existing location list stack,\n\t\/\/ if the autocmd made the stack invalid, then just return.\n\tif (!new_qi && IS_LL_STACK(qi) && qf_find_win_with_loclist(qi) == NULL)\n\t{\n\t    decr_quickfix_busy();\n\t    return;\n\t}\n    }\n\n    \/\/ Jump to first match.\n    if (!qf_list_empty(qf_get_curlist(qi)))\n\tqf_jump(qi, 0, 0, FALSE);\n    else\n\tsemsg(_(e_no_match_str_2), eap->arg);\n\n    decr_quickfix_busy();\n\n    if (eap->cmdidx == CMD_lhelpgrep)\n    {\n\t\/\/ If the help window is not opened or if it already points to the\n\t\/\/ correct location list, then free the new location list.\n\tif (!bt_help(curwin->w_buffer) || curwin->w_llist == qi)\n\t{\n\t    if (new_qi)\n\t\tll_free_all(&qi);\n\t}\n\telse if (curwin->w_llist == NULL && new_qi)\n\t    \/\/ current window didn't have a location list associated with it\n\t    \/\/ before. Associate the new location list now.\n\t    curwin->w_llist = qi;\n    }\n}","target":0,"code_token_length":930,"total_token_length":1166,"max_tokens_setting":2048}
+{"idx":220166,"func":"  explicit DecodeImageV2Op(OpKernelConstruction* context) : OpKernel(context) {\n    \/\/ Keep track of op string information because:\n    \/\/ [1] Currently by the API, PNG, JPEG and GIF can decode each other and\n    \/\/     depending on the op type, we need to return either 3-D or 4-D shapes.\n    \/\/ [2] Different ops have different attributes. e.g. `DecodeImage` op has\n    \/\/     `expand_animations` attribute that other ops don't.\n    \/\/     `DecodeAndDropJpeg` also has additional attributes.\n    op_type_ = type_string();\n\n    \/\/ Validate op type.\n    OP_REQUIRES(context,\n                op_type_ == \"DecodeJpeg\" || op_type_ == \"DecodeAndCropJpeg\" ||\n                    op_type_ == \"DecodePng\" || op_type_ == \"DecodeGif\" ||\n                    op_type_ == \"DecodeBmp\" || op_type_ == \"DecodeImage\",\n                errors::InvalidArgument(\"Bad op type \", op_type_));\n\n    \/\/ Get attributes from `DecodeJpeg` and `DecodeAndCropJpeg` op\n    \/\/ invocations. For `DecodeImage` op, set JPEG decoding setting to TF\n    \/\/ default.\n    if (op_type_ == \"DecodeJpeg\" || op_type_ == \"DecodeAndCropJpeg\") {\n      OP_REQUIRES_OK(context, context->GetAttr(\"ratio\", &flags_.ratio));\n      OP_REQUIRES(context,\n                  flags_.ratio == 1 || flags_.ratio == 2 || flags_.ratio == 4 ||\n                      flags_.ratio == 8,\n                  errors::InvalidArgument(\"ratio must be 1, 2, 4, or 8, got \",\n                                          flags_.ratio));\n      OP_REQUIRES_OK(context, context->GetAttr(\"fancy_upscaling\",\n                                               &flags_.fancy_upscaling));\n      OP_REQUIRES_OK(context,\n                     context->GetAttr(\"try_recover_truncated\",\n                                      &flags_.try_recover_truncated_jpeg));\n      OP_REQUIRES_OK(context,\n                     context->GetAttr(\"acceptable_fraction\",\n                                      &flags_.min_acceptable_fraction));\n      string dct_method;\n      OP_REQUIRES_OK(context, context->GetAttr(\"dct_method\", &dct_method));\n      OP_REQUIRES(\n          context,\n          (dct_method.empty() || dct_method == \"INTEGER_FAST\" ||\n           dct_method == \"INTEGER_ACCURATE\"),\n          errors::InvalidArgument(\"dct_method must be one of \"\n                                  \"{'', 'INTEGER_FAST', 'INTEGER_ACCURATE'}\"));\n      \/\/ The TensorFlow-chosen default for JPEG decoding is IFAST, sacrificing\n      \/\/ image quality for speed.\n      if (dct_method.empty() || dct_method == \"INTEGER_FAST\") {\n        flags_.dct_method = JDCT_IFAST;\n      } else if (dct_method == \"INTEGER_ACCURATE\") {\n        flags_.dct_method = JDCT_ISLOW;\n      }\n    } else {\n      flags_ = jpeg::UncompressFlags();\n      flags_.dct_method = JDCT_IFAST;\n    }\n\n    \/\/ Get `dtype` attribute from `DecodePng` or `DecodeImage` op invocations.\n    if (op_type_ == \"DecodePng\" || op_type_ == \"DecodeImage\") {\n      OP_REQUIRES_OK(context, context->GetAttr(\"dtype\", &data_type_));\n      if (op_type_ == \"DecodePng\") {\n        OP_REQUIRES(\n            context,\n            data_type_ == DataType::DT_UINT8 ||\n                data_type_ == DataType::DT_UINT16,\n            errors::InvalidArgument(\n                \"`dtype` for `DecodePng` must be unit8, unit16 but got: \",\n                data_type_));\n      } else {\n        OP_REQUIRES(context,\n                    data_type_ == DataType::DT_UINT8 ||\n                        data_type_ == DataType::DT_UINT16 ||\n                        data_type_ == DataType::DT_FLOAT,\n                    errors::InvalidArgument(\"`dtype` for `DecodeImage` must be \"\n                                            \"unit8, unit16, float but got: \",\n                                            data_type_));\n        OP_REQUIRES_OK(context, context->GetAttr(\"expand_animations\",\n                                                 &expand_animations_));\n      }\n    }\n\n    \/\/ Get `channels` attribute for all ops except `DecodeGif` op.\n    \/\/ `DecodeGif` doesn't have `channels` attribute but it supports 3\n    \/\/ channels by default.\n    if (op_type_ != \"DecodeGif\") {\n      OP_REQUIRES_OK(context, context->GetAttr(\"channels\", &channels_));\n      OP_REQUIRES(\n          context,\n          channels_ == 0 || channels_ == 1 || channels_ == 3 || channels_ == 4,\n          errors::InvalidArgument(\"`channels` must be 0, 1, 3 or 4 but got \",\n                                  channels_));\n    } else {\n      channels_ = 3;\n    }\n  }","target":0,"code_token_length":1044,"total_token_length":1280,"max_tokens_setting":2048}
+{"idx":243007,"func":"int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n\n    \/*\n     * Handle particular types of records\n     *\/\n    if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )\n    {\n        if( ( ret = mbedtls_ssl_prepare_handshake_record( ssl ) ) != 0 )\n        {\n            return( ret );\n        }\n    }\n\n    if( ssl->in_msgtype == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC )\n    {\n        if( ssl->in_msglen != 1 )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"invalid CCS message, len: %\" MBEDTLS_PRINTF_SIZET,\n                           ssl->in_msglen ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n\n        if( ssl->in_msg[0] != 1 )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"invalid CCS message, content: %02x\",\n                                        ssl->in_msg[0] ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n        if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&\n            ssl->state != MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC    &&\n            ssl->state != MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC )\n        {\n            if( ssl->handshake == NULL )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"dropping ChangeCipherSpec outside handshake\" ) );\n                return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD );\n            }\n\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"received out-of-order ChangeCipherSpec - remember\" ) );\n            return( MBEDTLS_ERR_SSL_EARLY_MESSAGE );\n        }\n#endif\n    }\n\n    if( ssl->in_msgtype == MBEDTLS_SSL_MSG_ALERT )\n    {\n        if( ssl->in_msglen != 2 )\n        {\n            \/* Note: Standard allows for more than one 2 byte alert\n               to be packed in a single message, but Mbed TLS doesn't\n               currently support this. *\/\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"invalid alert message, len: %\" MBEDTLS_PRINTF_SIZET,\n                           ssl->in_msglen ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n\n        MBEDTLS_SSL_DEBUG_MSG( 2, ( \"got an alert message, type: [%u:%u]\",\n                       ssl->in_msg[0], ssl->in_msg[1] ) );\n\n        \/*\n         * Ignore non-fatal alerts, except close_notify and no_renegotiation\n         *\/\n        if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_FATAL )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"is a fatal alert message (msg %d)\",\n                           ssl->in_msg[1] ) );\n            return( MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE );\n        }\n\n        if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING &&\n            ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"is a close notify message\" ) );\n            return( MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY );\n        }\n\n#if defined(MBEDTLS_SSL_RENEGOTIATION_ENABLED)\n        if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING &&\n            ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"is a SSLv3 no renegotiation alert\" ) );\n            \/* Will be handled when trying to parse ServerHello *\/\n            return( 0 );\n        }\n#endif\n\n#if defined(MBEDTLS_SSL_PROTO_SSL3) && defined(MBEDTLS_SSL_SRV_C)\n        if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 &&\n            ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER &&\n            ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING &&\n            ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_NO_CERT )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"is a SSLv3 no_cert\" ) );\n            \/* Will be handled in mbedtls_ssl_parse_certificate() *\/\n            return( 0 );\n        }\n#endif \/* MBEDTLS_SSL_PROTO_SSL3 && MBEDTLS_SSL_SRV_C *\/\n\n        \/* Silently ignore: fetch new message *\/\n        return MBEDTLS_ERR_SSL_NON_FATAL;\n    }\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        \/* Drop unexpected ApplicationData records,\n         * except at the beginning of renegotiations *\/\n        if( ssl->in_msgtype == MBEDTLS_SSL_MSG_APPLICATION_DATA &&\n            ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER\n#if defined(MBEDTLS_SSL_RENEGOTIATION)\n            && ! ( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS &&\n                   ssl->state == MBEDTLS_SSL_SERVER_HELLO )\n#endif\n            )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"dropping unexpected ApplicationData\" ) );\n            return( MBEDTLS_ERR_SSL_NON_FATAL );\n        }\n\n        if( ssl->handshake != NULL &&\n            ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER  )\n        {\n            mbedtls_ssl_handshake_wrapup_free_hs_transform( ssl );\n        }\n    }\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\n    return( 0 );\n}","target":0,"code_token_length":1215,"total_token_length":1451,"max_tokens_setting":2048}
+{"idx":234848,"func":"static int read_one_chunk(struct btrfs_key *key, struct extent_buffer *leaf,\n\t\t\t  struct btrfs_chunk *chunk)\n{\n\tstruct btrfs_fs_info *fs_info = leaf->fs_info;\n\tstruct extent_map_tree *map_tree = &fs_info->mapping_tree;\n\tstruct map_lookup *map;\n\tstruct extent_map *em;\n\tu64 logical;\n\tu64 length;\n\tu64 devid;\n\tu64 type;\n\tu8 uuid[BTRFS_UUID_SIZE];\n\tint num_stripes;\n\tint ret;\n\tint i;\n\n\tlogical = key->offset;\n\tlength = btrfs_chunk_length(leaf, chunk);\n\ttype = btrfs_chunk_type(leaf, chunk);\n\tnum_stripes = btrfs_chunk_num_stripes(leaf, chunk);\n\n#if BITS_PER_LONG == 32\n\tret = check_32bit_meta_chunk(fs_info, logical, length, type);\n\tif (ret < 0)\n\t\treturn ret;\n\twarn_32bit_meta_chunk(fs_info, logical, length, type);\n#endif\n\n\t\/*\n\t * Only need to verify chunk item if we're reading from sys chunk array,\n\t * as chunk item in tree block is already verified by tree-checker.\n\t *\/\n\tif (leaf->start == BTRFS_SUPER_INFO_OFFSET) {\n\t\tret = btrfs_check_chunk_valid(leaf, chunk, logical);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tread_lock(&map_tree->lock);\n\tem = lookup_extent_mapping(map_tree, logical, 1);\n\tread_unlock(&map_tree->lock);\n\n\t\/* already mapped? *\/\n\tif (em && em->start <= logical && em->start + em->len > logical) {\n\t\tfree_extent_map(em);\n\t\treturn 0;\n\t} else if (em) {\n\t\tfree_extent_map(em);\n\t}\n\n\tem = alloc_extent_map();\n\tif (!em)\n\t\treturn -ENOMEM;\n\tmap = kmalloc(map_lookup_size(num_stripes), GFP_NOFS);\n\tif (!map) {\n\t\tfree_extent_map(em);\n\t\treturn -ENOMEM;\n\t}\n\n\tset_bit(EXTENT_FLAG_FS_MAPPING, &em->flags);\n\tem->map_lookup = map;\n\tem->start = logical;\n\tem->len = length;\n\tem->orig_start = 0;\n\tem->block_start = 0;\n\tem->block_len = em->len;\n\n\tmap->num_stripes = num_stripes;\n\tmap->io_width = btrfs_chunk_io_width(leaf, chunk);\n\tmap->io_align = btrfs_chunk_io_align(leaf, chunk);\n\tmap->stripe_len = btrfs_chunk_stripe_len(leaf, chunk);\n\tmap->type = type;\n\tmap->sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk);\n\tmap->verified_stripes = 0;\n\tem->orig_block_len = calc_stripe_length(type, em->len,\n\t\t\t\t\t\tmap->num_stripes);\n\tfor (i = 0; i < num_stripes; i++) {\n\t\tmap->stripes[i].physical =\n\t\t\tbtrfs_stripe_offset_nr(leaf, chunk, i);\n\t\tdevid = btrfs_stripe_devid_nr(leaf, chunk, i);\n\t\tread_extent_buffer(leaf, uuid, (unsigned long)\n\t\t\t\t   btrfs_stripe_dev_uuid_nr(chunk, i),\n\t\t\t\t   BTRFS_UUID_SIZE);\n\t\tmap->stripes[i].dev = btrfs_find_device(fs_info->fs_devices,\n\t\t\t\t\t\t\tdevid, uuid, NULL);\n\t\tif (!map->stripes[i].dev &&\n\t\t    !btrfs_test_opt(fs_info, DEGRADED)) {\n\t\t\tfree_extent_map(em);\n\t\t\tbtrfs_report_missing_device(fs_info, devid, uuid, true);\n\t\t\treturn -ENOENT;\n\t\t}\n\t\tif (!map->stripes[i].dev) {\n\t\t\tmap->stripes[i].dev =\n\t\t\t\tadd_missing_dev(fs_info->fs_devices, devid,\n\t\t\t\t\t\tuuid);\n\t\t\tif (IS_ERR(map->stripes[i].dev)) {\n\t\t\t\tfree_extent_map(em);\n\t\t\t\tbtrfs_err(fs_info,\n\t\t\t\t\t\"failed to init missing dev %llu: %ld\",\n\t\t\t\t\tdevid, PTR_ERR(map->stripes[i].dev));\n\t\t\t\treturn PTR_ERR(map->stripes[i].dev);\n\t\t\t}\n\t\t\tbtrfs_report_missing_device(fs_info, devid, uuid, false);\n\t\t}\n\t\tset_bit(BTRFS_DEV_STATE_IN_FS_METADATA,\n\t\t\t\t&(map->stripes[i].dev->dev_state));\n\n\t}\n\n\twrite_lock(&map_tree->lock);\n\tret = add_extent_mapping(map_tree, em, 0);\n\twrite_unlock(&map_tree->lock);\n\tif (ret < 0) {\n\t\tbtrfs_err(fs_info,\n\t\t\t  \"failed to add chunk map, start=%llu len=%llu: %d\",\n\t\t\t  em->start, em->len, ret);\n\t}\n\tfree_extent_map(em);\n\n\treturn ret;\n}","target":0,"code_token_length":998,"total_token_length":1234,"max_tokens_setting":2048}
+{"idx":195037,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor* input_indices;\n    const Tensor* input_values;\n    const Tensor* input_shape;\n    SparseTensorsMap* map;\n\n    OP_REQUIRES_OK(context, context->input(\"sparse_indices\", &input_indices));\n    OP_REQUIRES_OK(context, context->input(\"sparse_values\", &input_values));\n    OP_REQUIRES_OK(context, context->input(\"sparse_shape\", &input_shape));\n    OP_REQUIRES_OK(context, GetMap(context, true \/* is_writing *\/, &map));\n\n    OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices->shape()),\n                errors::InvalidArgument(\n                    \"Input indices should be a matrix but received shape \",\n                    input_indices->shape().DebugString()));\n\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(input_values->shape()),\n                errors::InvalidArgument(\n                    \"Input values should be a vector but received shape \",\n                    input_values->shape().DebugString()));\n\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape->shape()),\n                errors::InvalidArgument(\n                    \"Input shape should be a vector but received shape \",\n                    input_shape->shape().DebugString()));\n\n    int rank = input_shape->NumElements();\n\n    OP_REQUIRES(\n        context, rank > 1,\n        errors::InvalidArgument(\n            \"Rank of input SparseTensor should be > 1, but saw rank: \", rank));\n\n    auto input_shape_vec = input_shape->vec<int64_t>();\n    int new_num_elements = 1;\n    bool overflow_ocurred = false;\n    for (int i = 0; i < input_shape_vec.size(); i++) {\n      new_num_elements =\n          MultiplyWithoutOverflow(new_num_elements, input_shape_vec(i));\n      if (new_num_elements < 0) {\n        overflow_ocurred = true;\n        break;\n      }\n    }\n\n    OP_REQUIRES(\n        context, !overflow_ocurred,\n        errors::Internal(\"Encountered overflow from large input shape.\"));\n\n    TensorShape tensor_input_shape(input_shape_vec);\n    gtl::InlinedVector<int64_t, 8> std_order(rank);\n    std::iota(std_order.begin(), std_order.end(), 0);\n    SparseTensor input_st;\n    OP_REQUIRES_OK(context, SparseTensor::Create(*input_indices, *input_values,\n                                                 tensor_input_shape, std_order,\n                                                 &input_st));\n\n    const int64_t N = input_shape_vec(0);\n\n    Tensor sparse_handles(DT_INT64, TensorShape({N}));\n    auto sparse_handles_t = sparse_handles.vec<int64_t>();\n\n    OP_REQUIRES_OK(context, input_st.IndicesValid());\n\n    \/\/ We can generate the output shape proto string now, for all\n    \/\/ minibatch entries.\n    TensorShape output_shape;\n    OP_REQUIRES_OK(context, TensorShapeUtils::MakeShape(\n                                input_shape_vec.data() + 1,\n                                input_shape->NumElements() - 1, &output_shape));\n\n    \/\/ Get groups by minibatch dimension\n    std::unordered_set<int64_t> visited;\n    sparse::GroupIterable minibatch = input_st.group({0});\n    for (const auto& subset : minibatch) {\n      const int64_t b = subset.group()[0];\n      visited.insert(b);\n      OP_REQUIRES(\n          context, b > -1 && b < N,\n          errors::InvalidArgument(\n              \"Received unexpected column 0 value in input SparseTensor: \", b,\n              \" < 0 or >= N (= \", N, \")\"));\n\n      const auto indices = subset.indices();\n      const auto values = subset.values<T>();\n      const int64_t num_entries = values.size();\n\n      Tensor output_indices = Tensor(DT_INT64, {num_entries, rank - 1});\n      Tensor output_values = Tensor(DataTypeToEnum<T>::value, {num_entries});\n\n      auto output_indices_t = output_indices.matrix<int64_t>();\n      auto output_values_t = output_values.vec<T>();\n\n      for (int i = 0; i < num_entries; ++i) {\n        for (int d = 1; d < rank; ++d) {\n          output_indices_t(i, d - 1) = indices(i, d);\n        }\n        output_values_t(i) = values(i);\n      }\n\n      SparseTensor st_i;\n      OP_REQUIRES_OK(context,\n                     SparseTensor::Create(output_indices, output_values,\n                                          output_shape, &st_i));\n      int64_t handle;\n      OP_REQUIRES_OK(context, map->AddSparseTensor(context, st_i, &handle));\n      sparse_handles_t(b) = handle;\n    }\n\n    \/\/ Fill in any gaps; we must provide an empty ST for batch entries\n    \/\/ the grouper didn't find.\n    if (visited.size() < N) {\n      Tensor empty_indices(DT_INT64, {0, rank - 1});\n      Tensor empty_values(DataTypeToEnum<T>::value, {0});\n      SparseTensor empty_st;\n      OP_REQUIRES_OK(context, SparseTensor::Create(empty_indices, empty_values,\n                                                   output_shape, &empty_st));\n\n      for (int64_t b = 0; b < N; ++b) {\n        \/\/ We skipped this batch entry.\n        if (visited.find(b) == visited.end()) {\n          int64_t handle;\n          OP_REQUIRES_OK(context,\n                         map->AddSparseTensor(context, empty_st, &handle));\n          sparse_handles_t(b) = handle;\n        }\n      }\n    }\n\n    context->set_output(0, sparse_handles);\n  }","target":1,"code_token_length":1163,"total_token_length":1399,"max_tokens_setting":2048}
+{"idx":508797,"func":"void LEX::set_trg_event_type_for_tables()\n{\n  uint8 new_trg_event_map= 0;\n  DBUG_ENTER(\"LEX::set_trg_event_type_for_tables\");\n\n  \/*\n    Some auxiliary operations\n    (e.g. GRANT processing) create TABLE_LIST instances outside\n    the parser. Additionally, some commands (e.g. OPTIMIZE) change\n    the lock type for a table only after parsing is done. Luckily,\n    these do not fire triggers and do not need to pre-load them.\n    For these TABLE_LISTs set_trg_event_type is never called, and\n    trg_event_map is always empty. That means that the pre-locking\n    algorithm will ignore triggers defined on these tables, if\n    any, and the execution will either fail with an assert in\n    sql_trigger.cc or with an error that a used table was not\n    pre-locked, in case of a production build.\n\n    TODO: this usage pattern creates unnecessary module dependencies\n    and should be rewritten to go through the parser.\n    Table list instances created outside the parser in most cases\n    refer to mysql.* system tables. It is not allowed to have\n    a trigger on a system table, but keeping track of\n    initialization provides extra safety in case this limitation\n    is circumvented.\n  *\/\n\n  switch (sql_command) {\n  case SQLCOM_LOCK_TABLES:\n  \/*\n    On a LOCK TABLE, all triggers must be pre-loaded for this TABLE_LIST\n    when opening an associated TABLE.\n  *\/\n    new_trg_event_map= static_cast<uint8>\n                        (1 << static_cast<int>(TRG_EVENT_INSERT)) |\n                      static_cast<uint8>\n                        (1 << static_cast<int>(TRG_EVENT_UPDATE)) |\n                      static_cast<uint8>\n                        (1 << static_cast<int>(TRG_EVENT_DELETE));\n    break;\n  \/*\n    Basic INSERT. If there is an additional ON DUPLIATE KEY UPDATE\n    clause, it will be handled later in this method.\n  *\/\n  case SQLCOM_INSERT:                           \/* fall through *\/\n  case SQLCOM_INSERT_SELECT:\n  \/*\n    LOAD DATA ... INFILE is expected to fire BEFORE\/AFTER INSERT\n    triggers.\n    If the statement also has REPLACE clause, it will be\n    handled later in this method.\n  *\/\n  case SQLCOM_LOAD:                             \/* fall through *\/\n  \/*\n    REPLACE is semantically equivalent to INSERT. In case\n    of a primary or unique key conflict, it deletes the old\n    record and inserts a new one. So we also may need to\n    fire ON DELETE triggers. This functionality is handled\n    later in this method.\n  *\/\n  case SQLCOM_REPLACE:                          \/* fall through *\/\n  case SQLCOM_REPLACE_SELECT:\n  \/*\n    CREATE TABLE ... SELECT defaults to INSERT if the table or\n    view already exists. REPLACE option of CREATE TABLE ...\n    REPLACE SELECT is handled later in this method.\n  *\/\n  case SQLCOM_CREATE_TABLE:\n    new_trg_event_map|= static_cast<uint8>\n                          (1 << static_cast<int>(TRG_EVENT_INSERT));\n    break;\n  \/* Basic update and multi-update *\/\n  case SQLCOM_UPDATE:                           \/* fall through *\/\n  case SQLCOM_UPDATE_MULTI:\n    new_trg_event_map|= static_cast<uint8>\n                          (1 << static_cast<int>(TRG_EVENT_UPDATE));\n    break;\n  \/* Basic delete and multi-delete *\/\n  case SQLCOM_DELETE:                           \/* fall through *\/\n  case SQLCOM_DELETE_MULTI:\n    new_trg_event_map|= static_cast<uint8>\n                          (1 << static_cast<int>(TRG_EVENT_DELETE));\n    break;\n  default:\n    break;\n  }\n\n  switch (duplicates) {\n  case DUP_UPDATE:\n    new_trg_event_map|= static_cast<uint8>\n                          (1 << static_cast<int>(TRG_EVENT_UPDATE));\n    break;\n  case DUP_REPLACE:\n    new_trg_event_map|= static_cast<uint8>\n                          (1 << static_cast<int>(TRG_EVENT_DELETE));\n    break;\n  case DUP_ERROR:\n  default:\n    break;\n  }\n\n\n  \/*\n    Do not iterate over sub-selects, only the tables in the outermost\n    SELECT_LEX can be modified, if any.\n  *\/\n  TABLE_LIST *tables= select_lex.get_table_list();\n\n  while (tables)\n  {\n    \/*\n      This is a fast check to filter out statements that do\n      not change data, or tables  on the right side, in case of\n      INSERT .. SELECT, CREATE TABLE .. SELECT and so on.\n      Here we also filter out OPTIMIZE statement and non-updateable\n      views, for which lock_type is TL_UNLOCK or TL_READ after\n      parsing.\n    *\/\n    if (static_cast<int>(tables->lock_type) >=\n        static_cast<int>(TL_WRITE_ALLOW_WRITE))\n      tables->trg_event_map= new_trg_event_map;\n    tables= tables->next_local;\n  }\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":1029,"total_token_length":1265,"max_tokens_setting":2048}
+{"idx":211877,"func":"addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,\n           const XML_Char *uri, BINDING **bindingsPtr) {\n  static const XML_Char xmlNamespace[]\n      = {ASCII_h,      ASCII_t,     ASCII_t,     ASCII_p,      ASCII_COLON,\n         ASCII_SLASH,  ASCII_SLASH, ASCII_w,     ASCII_w,      ASCII_w,\n         ASCII_PERIOD, ASCII_w,     ASCII_3,     ASCII_PERIOD, ASCII_o,\n         ASCII_r,      ASCII_g,     ASCII_SLASH, ASCII_X,      ASCII_M,\n         ASCII_L,      ASCII_SLASH, ASCII_1,     ASCII_9,      ASCII_9,\n         ASCII_8,      ASCII_SLASH, ASCII_n,     ASCII_a,      ASCII_m,\n         ASCII_e,      ASCII_s,     ASCII_p,     ASCII_a,      ASCII_c,\n         ASCII_e,      '\\0'};\n  static const int xmlLen = (int)sizeof(xmlNamespace) \/ sizeof(XML_Char) - 1;\n  static const XML_Char xmlnsNamespace[]\n      = {ASCII_h,     ASCII_t,      ASCII_t, ASCII_p, ASCII_COLON,  ASCII_SLASH,\n         ASCII_SLASH, ASCII_w,      ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w,\n         ASCII_3,     ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g,      ASCII_SLASH,\n         ASCII_2,     ASCII_0,      ASCII_0, ASCII_0, ASCII_SLASH,  ASCII_x,\n         ASCII_m,     ASCII_l,      ASCII_n, ASCII_s, ASCII_SLASH,  '\\0'};\n  static const int xmlnsLen\n      = (int)sizeof(xmlnsNamespace) \/ sizeof(XML_Char) - 1;\n\n  XML_Bool mustBeXML = XML_FALSE;\n  XML_Bool isXML = XML_TRUE;\n  XML_Bool isXMLNS = XML_TRUE;\n\n  BINDING *b;\n  int len;\n\n  \/* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) *\/\n  if (*uri == XML_T('\\0') && prefix->name)\n    return XML_ERROR_UNDECLARING_PREFIX;\n\n  if (prefix->name && prefix->name[0] == XML_T(ASCII_x)\n      && prefix->name[1] == XML_T(ASCII_m)\n      && prefix->name[2] == XML_T(ASCII_l)) {\n    \/* Not allowed to bind xmlns *\/\n    if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s)\n        && prefix->name[5] == XML_T('\\0'))\n      return XML_ERROR_RESERVED_PREFIX_XMLNS;\n\n    if (prefix->name[3] == XML_T('\\0'))\n      mustBeXML = XML_TRUE;\n  }\n\n  for (len = 0; uri[len]; len++) {\n    if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len]))\n      isXML = XML_FALSE;\n\n    if (! mustBeXML && isXMLNS\n        && (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))\n      isXMLNS = XML_FALSE;\n  }\n  isXML = isXML && len == xmlLen;\n  isXMLNS = isXMLNS && len == xmlnsLen;\n\n  if (mustBeXML != isXML)\n    return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML\n                     : XML_ERROR_RESERVED_NAMESPACE_URI;\n\n  if (isXMLNS)\n    return XML_ERROR_RESERVED_NAMESPACE_URI;\n\n  if (parser->m_namespaceSeparator)\n    len++;\n  if (parser->m_freeBindingList) {\n    b = parser->m_freeBindingList;\n    if (len > b->uriAlloc) {\n      \/* Detect and prevent integer overflow *\/\n      if (len > INT_MAX - EXPAND_SPARE) {\n        return XML_ERROR_NO_MEMORY;\n      }\n\n      \/* Detect and prevent integer overflow.\n       * The preprocessor guard addresses the \"always false\" warning\n       * from -Wtype-limits on platforms where\n       * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. *\/\n#if UINT_MAX >= SIZE_MAX\n      if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) \/ sizeof(XML_Char)) {\n        return XML_ERROR_NO_MEMORY;\n      }\n#endif\n\n      XML_Char *temp = (XML_Char *)REALLOC(\n          parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));\n      if (temp == NULL)\n        return XML_ERROR_NO_MEMORY;\n      b->uri = temp;\n      b->uriAlloc = len + EXPAND_SPARE;\n    }\n    parser->m_freeBindingList = b->nextTagBinding;\n  } else {\n    b = (BINDING *)MALLOC(parser, sizeof(BINDING));\n    if (! b)\n      return XML_ERROR_NO_MEMORY;\n\n    \/* Detect and prevent integer overflow *\/\n    if (len > INT_MAX - EXPAND_SPARE) {\n      return XML_ERROR_NO_MEMORY;\n    }\n    \/* Detect and prevent integer overflow.\n     * The preprocessor guard addresses the \"always false\" warning\n     * from -Wtype-limits on platforms where\n     * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. *\/\n#if UINT_MAX >= SIZE_MAX\n    if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) \/ sizeof(XML_Char)) {\n      return XML_ERROR_NO_MEMORY;\n    }\n#endif\n\n    b->uri\n        = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE));\n    if (! b->uri) {\n      FREE(parser, b);\n      return XML_ERROR_NO_MEMORY;\n    }\n    b->uriAlloc = len + EXPAND_SPARE;\n  }\n  b->uriLen = len;\n  memcpy(b->uri, uri, len * sizeof(XML_Char));\n  if (parser->m_namespaceSeparator)\n    b->uri[len - 1] = parser->m_namespaceSeparator;\n  b->prefix = prefix;\n  b->attId = attId;\n  b->prevPrefixBinding = prefix->binding;\n  \/* NULL binding when default namespace undeclared *\/\n  if (*uri == XML_T('\\0') && prefix == &parser->m_dtd->defaultPrefix)\n    prefix->binding = NULL;\n  else\n    prefix->binding = b;\n  b->nextTagBinding = *bindingsPtr;\n  *bindingsPtr = b;\n  \/* if attId == NULL then we are not starting a namespace scope *\/\n  if (attId && parser->m_startNamespaceDeclHandler)\n    parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name,\n                                        prefix->binding ? uri : 0);\n  return XML_ERROR_NONE;\n}","target":1,"code_token_length":1442,"total_token_length":1678,"max_tokens_setting":2048}
+{"idx":261441,"func":"bool alloc_and_init_significant_coeff_ctxIdx_lookupTable()\n{\n  int tableSize = 4*4*(2) + 8*8*(2*2*4) + 16*16*(2*4) + 32*32*(2*4);\n\n  uint8_t* p = (uint8_t*)malloc(tableSize);\n  if (p==NULL) {\n    return false;\n  }\n\n  memset(p,0xFF,tableSize);  \/\/ just for debugging\n\n\n  \/\/ --- Set pointers to memory areas. Note that some parameters share the same memory. ---\n\n  \/\/ 4x4\n\n  for (int cIdx=0;cIdx<2;cIdx++) {\n    for (int scanIdx=0;scanIdx<2;scanIdx++)\n      for (int prevCsbf=0;prevCsbf<4;prevCsbf++)\n        ctxIdxLookup[0][cIdx][scanIdx][prevCsbf] = p;\n\n    p += 4*4;\n  }\n\n  \/\/ 8x8\n\n  for (int cIdx=0;cIdx<2;cIdx++)\n    for (int scanIdx=0;scanIdx<2;scanIdx++)\n      for (int prevCsbf=0;prevCsbf<4;prevCsbf++) {\n        ctxIdxLookup[1][cIdx][scanIdx][prevCsbf] = p;\n        p += 8*8;\n      }\n\n  \/\/ 16x16\n\n  for (int cIdx=0;cIdx<2;cIdx++)\n    for (int prevCsbf=0;prevCsbf<4;prevCsbf++) {\n      for (int scanIdx=0;scanIdx<2;scanIdx++) {\n        ctxIdxLookup[2][cIdx][scanIdx][prevCsbf] = p;\n      }\n\n      p += 16*16;\n    }\n\n  \/\/ 32x32\n\n  for (int cIdx=0;cIdx<2;cIdx++)\n    for (int prevCsbf=0;prevCsbf<4;prevCsbf++) {\n      for (int scanIdx=0;scanIdx<2;scanIdx++) {\n        ctxIdxLookup[3][cIdx][scanIdx][prevCsbf] = p;\n      }\n\n      p += 32*32;\n    }\n\n\n  \/\/ --- precompute ctxIdx tables ---\n\n  for (int log2w=2; log2w<=5 ; log2w++)\n    for (int cIdx=0;cIdx<2;cIdx++)\n      for (int scanIdx=0;scanIdx<2;scanIdx++)\n        for (int prevCsbf=0;prevCsbf<4;prevCsbf++)\n          {\n            for (int yC=0;yC<(1<<log2w);yC++)\n              for (int xC=0;xC<(1<<log2w);xC++)\n                {\n                  int w = 1<<log2w;\n                  int sbWidth = w>>2;\n\n                  int sigCtx;\n\n                  \/\/ if log2TrafoSize==2\n                  if (sbWidth==1) {\n                    sigCtx = ctxIdxMap[(yC<<2) + xC];\n                  }\n                  else if (xC+yC==0) {\n                    sigCtx = 0;\n                  }\n                  else {\n                    int xS = xC>>2;\n                    int yS = yC>>2;\n                    \/*\n                      int prevCsbf = 0;\n\n                      if (xS < sbWidth-1) { prevCsbf += coded_sub_block_flag[xS+1  +yS*sbWidth];    }\n                      if (yS < sbWidth-1) { prevCsbf += coded_sub_block_flag[xS+(1+yS)*sbWidth]<<1; }\n                    *\/\n                    int xP = xC & 3;\n                    int yP = yC & 3;\n\n                    \/\/logtrace(LogSlice,\"posInSubset: %d,%d\\n\",xP,yP);\n                    \/\/logtrace(LogSlice,\"prevCsbf: %d\\n\",prevCsbf);\n\n                    switch (prevCsbf) {\n                    case 0:\n                      sigCtx = (xP+yP>=3) ? 0 : (xP+yP>0) ? 1 : 2;\n                      break;\n                    case 1:\n                      sigCtx = (yP==0) ? 2 : (yP==1) ? 1 : 0;\n                      break;\n                    case 2:\n                      sigCtx = (xP==0) ? 2 : (xP==1) ? 1 : 0;\n                      break;\n                    default:\n                      sigCtx = 2;\n                      break;\n                    }\n\n                    \/\/logtrace(LogSlice,\"a) sigCtx=%d\\n\",sigCtx);\n\n                    if (cIdx==0) {\n                      if (xS+yS > 0) sigCtx+=3;\n\n                      \/\/logtrace(LogSlice,\"b) sigCtx=%d\\n\",sigCtx);\n\n                      \/\/ if log2TrafoSize==3\n                      if (sbWidth==2) { \/\/ 8x8 block\n                        sigCtx += (scanIdx==0) ? 9 : 15;\n                      } else {\n                        sigCtx += 21;\n                      }\n\n                      \/\/logtrace(LogSlice,\"c) sigCtx=%d\\n\",sigCtx);\n                    }\n                    else {\n                      \/\/ if log2TrafoSize==3\n                      if (sbWidth==2) { \/\/ 8x8 block\n                        sigCtx+=9;\n                      }\n                      else {\n                        sigCtx+=12;\n                      }\n                    }\n\n                  }\n\n                  int ctxIdxInc;\n                  if (cIdx==0) { ctxIdxInc=sigCtx; }\n                  else         { ctxIdxInc=27+sigCtx; }\n\n                  if (ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf][xC+(yC<<log2w)] != 0xFF) {\n                    assert(ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf][xC+(yC<<log2w)] == ctxIdxInc);\n                  }\n\n                  ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf][xC+(yC<<log2w)] = ctxIdxInc;\n\n                  \/\/NOTE: when using this option, we have to include all three scanIdx in the table\n                  \/\/ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf][s] = ctxIdxInc;\n                }\n          }\n\n  return true;\n}","target":0,"code_token_length":1410,"total_token_length":1646,"max_tokens_setting":2048}
+{"idx":436058,"func":"static int io_write(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tstruct iov_iter __iter, *iter = &__iter;\n\tstruct io_async_rw *rw = req->async_data;\n\tssize_t ret, ret2, io_size;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tif (rw) {\n\t\titer = &rw->iter;\n\t\tiovec = NULL;\n\t} else {\n\t\tret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\tio_size = iov_iter_count(iter);\n\treq->result = io_size;\n\n\t\/* Ensure we clear previously set non-block flag *\/\n\tif (!force_nonblock)\n\t\tkiocb->ki_flags &= ~IOCB_NOWAIT;\n\telse\n\t\tkiocb->ki_flags |= IOCB_NOWAIT;\n\n\t\/* If the file doesn't support async, just async punt *\/\n\tif (force_nonblock && !io_file_supports_async(req, WRITE))\n\t\tgoto copy_iov;\n\n\t\/* file path doesn't support NOWAIT for non-direct_IO *\/\n\tif (force_nonblock && !(kiocb->ki_flags & IOCB_DIRECT) &&\n\t    (req->flags & REQ_F_ISREG))\n\t\tgoto copy_iov;\n\n\tret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), io_size);\n\tif (unlikely(ret))\n\t\tgoto out_free;\n\n\t\/*\n\t * Open-code file_start_write here to grab freeze protection,\n\t * which will be released by another thread in\n\t * io_complete_rw().  Fool lockdep by telling it the lock got\n\t * released so that it doesn't complain about the held lock when\n\t * we return to userspace.\n\t *\/\n\tif (req->flags & REQ_F_ISREG) {\n\t\tsb_start_write(file_inode(req->file)->i_sb);\n\t\t__sb_writers_release(file_inode(req->file)->i_sb,\n\t\t\t\t\tSB_FREEZE_WRITE);\n\t}\n\tkiocb->ki_flags |= IOCB_WRITE;\n\n\tif (req->file->f_op->write_iter)\n\t\tret2 = call_write_iter(req->file, kiocb, iter);\n\telse if (req->file->f_op->write)\n\t\tret2 = loop_rw_iter(WRITE, req, iter);\n\telse\n\t\tret2 = -EINVAL;\n\n\tif (req->flags & REQ_F_REISSUE) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\tret2 = -EAGAIN;\n\t}\n\n\t\/*\n\t * Raw bdev writes will return -EOPNOTSUPP for IOCB_NOWAIT. Just\n\t * retry them without IOCB_NOWAIT.\n\t *\/\n\tif (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))\n\t\tret2 = -EAGAIN;\n\t\/* no retry on NONBLOCK nor RWF_NOWAIT *\/\n\tif (ret2 == -EAGAIN && (req->flags & REQ_F_NOWAIT))\n\t\tgoto done;\n\tif (!force_nonblock || ret2 != -EAGAIN) {\n\t\t\/* IOPOLL retry should happen for io-wq threads *\/\n\t\tif ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN)\n\t\t\tgoto copy_iov;\ndone:\n\t\tkiocb_done(kiocb, ret2, issue_flags);\n\t} else {\ncopy_iov:\n\t\t\/* some cases will consume bytes even on error returns *\/\n\t\tiov_iter_reexpand(iter, iter->count + iter->truncated);\n\t\tiov_iter_revert(iter, io_size - iov_iter_count(iter));\n\t\tret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);\n\t\treturn ret ?: -EAGAIN;\n\t}\nout_free:\n\t\/* it's reportedly faster than delegating the null check to kfree() *\/\n\tif (iovec)\n\t\tkfree(iovec);\n\treturn ret;\n}","target":0,"code_token_length":883,"total_token_length":1119,"max_tokens_setting":2048}
+{"idx":424521,"func":"static void video_timer(VideoClientContext* video, UINT64 now)\n{\n\tPresentationContext* presentation;\n\tVideoClientContextPriv* priv = video->priv;\n\tVideoFrame *peekFrame, *frame = NULL;\n\n\tEnterCriticalSection(&priv->framesLock);\n\tdo\n\t{\n\t\tpeekFrame = (VideoFrame*)Queue_Peek(priv->frames);\n\t\tif (!peekFrame)\n\t\t\tbreak;\n\n\t\tif (peekFrame->publishTime > now)\n\t\t\tbreak;\n\n\t\tif (frame)\n\t\t{\n\t\t\tWLog_DBG(TAG, \"dropping frame @%\" PRIu64, frame->publishTime);\n\t\t\tpriv->droppedFrames++;\n\t\t\tVideoFrame_free(&frame);\n\t\t}\n\t\tframe = peekFrame;\n\t\tQueue_Dequeue(priv->frames);\n\t} while (1);\n\tLeaveCriticalSection(&priv->framesLock);\n\n\tif (!frame)\n\t\tgoto treat_feedback;\n\n\tpresentation = frame->presentation;\n\n\tpriv->publishedFrames++;\n\tmemcpy(presentation->surfaceData, frame->surfaceData, frame->w * frame->h * 4);\n\n\tvideo->showSurface(video, presentation->surface);\n\n\tVideoFrame_free(&frame);\n\ntreat_feedback:\n\tif (priv->nextFeedbackTime < now)\n\t{\n\t\t\/* we can compute some feedback only if we have some published frames and\n\t\t * a current presentation\n\t\t *\/\n\t\tif (priv->publishedFrames && priv->currentPresentation)\n\t\t{\n\t\t\tUINT32 computedRate;\n\n\t\t\tInterlockedIncrement(&priv->currentPresentation->refCounter);\n\n\t\t\tif (priv->droppedFrames)\n\t\t\t{\n\t\t\t\t\/**\n\t\t\t\t * some dropped frames, looks like we're asking too many frames per seconds,\n\t\t\t\t * try lowering rate. We go directly from unlimited rate to 24 frames\/seconds\n\t\t\t\t * otherwise we lower rate by 2 frames by seconds\n\t\t\t\t *\/\n\t\t\t\tif (priv->lastSentRate == XF_VIDEO_UNLIMITED_RATE)\n\t\t\t\t\tcomputedRate = 24;\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcomputedRate = priv->lastSentRate - 2;\n\t\t\t\t\tif (!computedRate)\n\t\t\t\t\t\tcomputedRate = 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t\/**\n\t\t\t\t * we treat all frames ok, so either ask the server to send more,\n\t\t\t\t * or stay unlimited\n\t\t\t\t *\/\n\t\t\t\tif (priv->lastSentRate == XF_VIDEO_UNLIMITED_RATE)\n\t\t\t\t\tcomputedRate = XF_VIDEO_UNLIMITED_RATE; \/* stay unlimited *\/\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcomputedRate = priv->lastSentRate + 2;\n\t\t\t\t\tif (computedRate > XF_VIDEO_UNLIMITED_RATE)\n\t\t\t\t\t\tcomputedRate = XF_VIDEO_UNLIMITED_RATE;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (computedRate != priv->lastSentRate)\n\t\t\t{\n\t\t\t\tTSMM_CLIENT_NOTIFICATION notif;\n\t\t\t\tnotif.PresentationId = priv->currentPresentation->PresentationId;\n\t\t\t\tnotif.NotificationType = TSMM_CLIENT_NOTIFICATION_TYPE_FRAMERATE_OVERRIDE;\n\t\t\t\tif (computedRate == XF_VIDEO_UNLIMITED_RATE)\n\t\t\t\t{\n\t\t\t\t\tnotif.FramerateOverride.Flags = 0x01;\n\t\t\t\t\tnotif.FramerateOverride.DesiredFrameRate = 0x00;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnotif.FramerateOverride.Flags = 0x02;\n\t\t\t\t\tnotif.FramerateOverride.DesiredFrameRate = computedRate;\n\t\t\t\t}\n\n\t\t\t\tvideo_control_send_client_notification(video, ¬if);\n\t\t\t\tpriv->lastSentRate = computedRate;\n\n\t\t\t\tWLog_DBG(TAG, \"server notified with rate %d published=%d dropped=%d\",\n\t\t\t\t         priv->lastSentRate, priv->publishedFrames, priv->droppedFrames);\n\t\t\t}\n\n\t\t\tPresentationContext_unref(priv->currentPresentation);\n\t\t}\n\n\t\tWLog_DBG(TAG, \"currentRate=%d published=%d dropped=%d\", priv->lastSentRate,\n\t\t         priv->publishedFrames, priv->droppedFrames);\n\n\t\tpriv->droppedFrames = 0;\n\t\tpriv->publishedFrames = 0;\n\t\tpriv->nextFeedbackTime = now + 1000;\n\t}\n}","target":0,"code_token_length":862,"total_token_length":1098,"max_tokens_setting":2048}
+{"idx":253517,"func":"parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,\n\t\t\tsize_t buf_len,\n\t\t\tstruct cifs_server_iface **iface_list,\n\t\t\tsize_t *iface_count)\n{\n\tstruct network_interface_info_ioctl_rsp *p;\n\tstruct sockaddr_in *addr4;\n\tstruct sockaddr_in6 *addr6;\n\tstruct iface_info_ipv4 *p4;\n\tstruct iface_info_ipv6 *p6;\n\tstruct cifs_server_iface *info;\n\tssize_t bytes_left;\n\tsize_t next = 0;\n\tint nb_iface = 0;\n\tint rc = 0;\n\n\t*iface_list = NULL;\n\t*iface_count = 0;\n\n\t\/*\n\t * Fist pass: count and sanity check\n\t *\/\n\n\tbytes_left = buf_len;\n\tp = buf;\n\twhile (bytes_left >= sizeof(*p)) {\n\t\tnb_iface++;\n\t\tnext = le32_to_cpu(p->Next);\n\t\tif (!next) {\n\t\t\tbytes_left -= sizeof(*p);\n\t\t\tbreak;\n\t\t}\n\t\tp = (struct network_interface_info_ioctl_rsp *)((u8 *)p+next);\n\t\tbytes_left -= next;\n\t}\n\n\tif (!nb_iface) {\n\t\tcifs_dbg(VFS, \"%s: malformed interface info\\n\", __func__);\n\t\trc = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* Azure rounds the buffer size up 8, to a 16 byte boundary *\/\n\tif ((bytes_left > 8) || p->Next)\n\t\tcifs_dbg(VFS, \"%s: incomplete interface info\\n\", __func__);\n\n\n\t\/*\n\t * Second pass: extract info to internal structure\n\t *\/\n\n\t*iface_list = kcalloc(nb_iface, sizeof(**iface_list), GFP_KERNEL);\n\tif (!*iface_list) {\n\t\trc = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tinfo = *iface_list;\n\tbytes_left = buf_len;\n\tp = buf;\n\twhile (bytes_left >= sizeof(*p)) {\n\t\tinfo->speed = le64_to_cpu(p->LinkSpeed);\n\t\tinfo->rdma_capable = le32_to_cpu(p->Capability & RDMA_CAPABLE) ? 1 : 0;\n\t\tinfo->rss_capable = le32_to_cpu(p->Capability & RSS_CAPABLE) ? 1 : 0;\n\n\t\tcifs_dbg(FYI, \"%s: adding iface %zu\\n\", __func__, *iface_count);\n\t\tcifs_dbg(FYI, \"%s: speed %zu bps\\n\", __func__, info->speed);\n\t\tcifs_dbg(FYI, \"%s: capabilities 0x%08x\\n\", __func__,\n\t\t\t le32_to_cpu(p->Capability));\n\n\t\tswitch (p->Family) {\n\t\t\/*\n\t\t * The kernel and wire socket structures have the same\n\t\t * layout and use network byte order but make the\n\t\t * conversion explicit in case either one changes.\n\t\t *\/\n\t\tcase INTERNETWORK:\n\t\t\taddr4 = (struct sockaddr_in *)&info->sockaddr;\n\t\t\tp4 = (struct iface_info_ipv4 *)p->Buffer;\n\t\t\taddr4->sin_family = AF_INET;\n\t\t\tmemcpy(&addr4->sin_addr, &p4->IPv4Address, 4);\n\n\t\t\t\/* [MS-SMB2] 2.2.32.5.1.1 Clients MUST ignore these *\/\n\t\t\taddr4->sin_port = cpu_to_be16(CIFS_PORT);\n\n\t\t\tcifs_dbg(FYI, \"%s: ipv4 %pI4\\n\", __func__,\n\t\t\t\t &addr4->sin_addr);\n\t\t\tbreak;\n\t\tcase INTERNETWORKV6:\n\t\t\taddr6 =\t(struct sockaddr_in6 *)&info->sockaddr;\n\t\t\tp6 = (struct iface_info_ipv6 *)p->Buffer;\n\t\t\taddr6->sin6_family = AF_INET6;\n\t\t\tmemcpy(&addr6->sin6_addr, &p6->IPv6Address, 16);\n\n\t\t\t\/* [MS-SMB2] 2.2.32.5.1.2 Clients MUST ignore these *\/\n\t\t\taddr6->sin6_flowinfo = 0;\n\t\t\taddr6->sin6_scope_id = 0;\n\t\t\taddr6->sin6_port = cpu_to_be16(CIFS_PORT);\n\n\t\t\tcifs_dbg(FYI, \"%s: ipv6 %pI6\\n\", __func__,\n\t\t\t\t &addr6->sin6_addr);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t \"%s: skipping unsupported socket family\\n\",\n\t\t\t\t __func__);\n\t\t\tgoto next_iface;\n\t\t}\n\n\t\t(*iface_count)++;\n\t\tinfo++;\nnext_iface:\n\t\tnext = le32_to_cpu(p->Next);\n\t\tif (!next)\n\t\t\tbreak;\n\t\tp = (struct network_interface_info_ioctl_rsp *)((u8 *)p+next);\n\t\tbytes_left -= next;\n\t}\n\n\tif (!*iface_count) {\n\t\trc = -EINVAL;\n\t\tgoto out;\n\t}\n\nout:\n\tif (rc) {\n\t\tkfree(*iface_list);\n\t\t*iface_count = 0;\n\t\t*iface_list = NULL;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":1050,"total_token_length":1286,"max_tokens_setting":2048}
+{"idx":252378,"func":"static int tdefl_flush_block(tdefl_compressor *d, int flush) {\n  mz_uint saved_bit_buf, saved_bits_in;\n  mz_uint8 *pSaved_output_buf;\n  mz_bool comp_block_succeeded = MZ_FALSE;\n  int n, use_raw_block =\n             ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) &&\n             (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size;\n  mz_uint8 *pOutput_buf_start =\n      ((d->m_pPut_buf_func == NULL) &&\n       ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE))\n          ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs)\n          : d->m_output_buf;\n\n  d->m_pOutput_buf = pOutput_buf_start;\n  d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16;\n\n  MZ_ASSERT(!d->m_output_flush_remaining);\n  d->m_output_flush_ofs = 0;\n  d->m_output_flush_remaining = 0;\n\n  *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left);\n  d->m_pLZ_code_buf -= (d->m_num_flags_left == 8);\n\n  if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) {\n    TDEFL_PUT_BITS(0x78, 8);\n    TDEFL_PUT_BITS(0x01, 8);\n  }\n\n  TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1);\n\n  pSaved_output_buf = d->m_pOutput_buf;\n  saved_bit_buf = d->m_bit_buffer;\n  saved_bits_in = d->m_bits_in;\n\n  if (!use_raw_block)\n    comp_block_succeeded =\n        tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) ||\n                                    (d->m_total_lz_bytes < 48));\n\n  \/\/ If the block gets expanded, forget the current contents of the output\n  \/\/ buffer and send a raw block instead.\n  if (((use_raw_block) ||\n       ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >=\n                                  d->m_total_lz_bytes))) &&\n      ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size)) {\n    mz_uint i;\n    d->m_pOutput_buf = pSaved_output_buf;\n    d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;\n    TDEFL_PUT_BITS(0, 2);\n    if (d->m_bits_in) {\n      TDEFL_PUT_BITS(0, 8 - d->m_bits_in);\n    }\n    for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) {\n      TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16);\n    }\n    for (i = 0; i < d->m_total_lz_bytes; ++i) {\n      TDEFL_PUT_BITS(\n          d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK],\n          8);\n    }\n  }\n  \/\/ Check for the extremely unlikely (if not impossible) case of the compressed\n  \/\/ block not fitting into the output buffer when using dynamic codes.\n  else if (!comp_block_succeeded) {\n    d->m_pOutput_buf = pSaved_output_buf;\n    d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;\n    tdefl_compress_block(d, MZ_TRUE);\n  }\n\n  if (flush) {\n    if (flush == TDEFL_FINISH) {\n      if (d->m_bits_in) {\n        TDEFL_PUT_BITS(0, 8 - d->m_bits_in);\n      }\n      if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) {\n        mz_uint i, a = d->m_adler32;\n        for (i = 0; i < 4; i++) {\n          TDEFL_PUT_BITS((a >> 24) & 0xFF, 8);\n          a <<= 8;\n        }\n      }\n    } else {\n      mz_uint i, z = 0;\n      TDEFL_PUT_BITS(0, 3);\n      if (d->m_bits_in) {\n        TDEFL_PUT_BITS(0, 8 - d->m_bits_in);\n      }\n      for (i = 2; i; --i, z ^= 0xFFFF) {\n        TDEFL_PUT_BITS(z & 0xFFFF, 16);\n      }\n    }\n  }\n\n  MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end);\n\n  memset(&d->m_huff_count[0][0], 0,\n         sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);\n  memset(&d->m_huff_count[1][0], 0,\n         sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);\n\n  d->m_pLZ_code_buf = d->m_lz_code_buf + 1;\n  d->m_pLZ_flags = d->m_lz_code_buf;\n  d->m_num_flags_left = 8;\n  d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes;\n  d->m_total_lz_bytes = 0;\n  d->m_block_index++;\n\n  if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) {\n    if (d->m_pPut_buf_func) {\n      *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;\n      if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user))\n        return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED);\n    } else if (pOutput_buf_start == d->m_output_buf) {\n      int bytes_to_copy = (int)MZ_MIN(\n          (size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs));\n      memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf,\n             bytes_to_copy);\n      d->m_out_buf_ofs += bytes_to_copy;\n      if ((n -= bytes_to_copy) != 0) {\n        d->m_output_flush_ofs = bytes_to_copy;\n        d->m_output_flush_remaining = n;\n      }\n    } else {\n      d->m_out_buf_ofs += n;\n    }\n  }\n\n  return d->m_output_flush_remaining;\n}","target":0,"code_token_length":1554,"total_token_length":1790,"max_tokens_setting":2048}
+{"idx":326646,"func":"hfs_write_decmpfs_block(struct archive_write_disk *a, const char *buff,\n    size_t size)\n{\n\tconst char *buffer_to_write;\n\tsize_t bytes_to_write;\n\tint ret;\n\n\tif (a->decmpfs_block_count == (unsigned)-1) {\n\t\tvoid *new_block;\n\t\tsize_t new_size;\n\t\tunsigned int block_count;\n\n\t\tif (a->decmpfs_header_p == NULL) {\n\t\t\tnew_block = malloc(MAX_DECMPFS_XATTR_SIZE\n\t\t\t    + sizeof(uint32_t));\n\t\t\tif (new_block == NULL) {\n\t\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t\t    \"Can't allocate memory for decmpfs\");\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\ta->decmpfs_header_p = new_block;\n\t\t}\n\t\ta->decmpfs_attr_size = DECMPFS_HEADER_SIZE;\n\t\tarchive_le32enc(&a->decmpfs_header_p[DECMPFS_COMPRESSION_MAGIC],\n\t\t    DECMPFS_MAGIC);\n\t\tarchive_le32enc(&a->decmpfs_header_p[DECMPFS_COMPRESSION_TYPE],\n\t\t    CMP_RESOURCE_FORK);\n\t\tarchive_le64enc(&a->decmpfs_header_p[DECMPFS_UNCOMPRESSED_SIZE],\n\t\t    a->filesize);\n\n\t\t\/* Calculate a block count of the file. *\/\n\t\tblock_count =\n\t\t    (a->filesize + MAX_DECMPFS_BLOCK_SIZE -1) \/\n\t\t\tMAX_DECMPFS_BLOCK_SIZE;\n\t\t\/*\n\t\t * Allocate buffer for resource fork.\n\t\t * Set up related pointers;\n\t\t *\/\n\t\tnew_size =\n\t\t    RSRC_H_SIZE + \/* header *\/\n\t\t    4 + \/* Block count *\/\n\t\t    (block_count * sizeof(uint32_t) * 2) +\n\t\t    RSRC_F_SIZE; \/* footer *\/\n\t\tif (new_size > a->resource_fork_allocated_size) {\n\t\t\tnew_block = realloc(a->resource_fork, new_size);\n\t\t\tif (new_block == NULL) {\n\t\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t\t    \"Can't allocate memory for ResourceFork\");\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\ta->resource_fork_allocated_size = new_size;\n\t\t\ta->resource_fork = new_block;\n\t\t}\n\n\t\t\/* Allocate uncompressed buffer *\/\n\t\tif (a->uncompressed_buffer == NULL) {\n\t\t\tnew_block = malloc(MAX_DECMPFS_BLOCK_SIZE);\n\t\t\tif (new_block == NULL) {\n\t\t\t\tarchive_set_error(&a->archive, ENOMEM,\n\t\t\t\t    \"Can't allocate memory for decmpfs\");\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\ta->uncompressed_buffer = new_block;\n\t\t}\n\t\ta->block_remaining_bytes = MAX_DECMPFS_BLOCK_SIZE;\n\t\ta->file_remaining_bytes = a->filesize;\n\t\ta->compressed_buffer_remaining = a->compressed_buffer_size;\n\n\t\t\/*\n\t\t * Set up a resource fork.\n\t\t *\/\n\t\ta->rsrc_xattr_options = XATTR_CREATE;\n\t\t\/* Get the position where we are going to set a bunch\n\t\t * of block info. *\/\n\t\ta->decmpfs_block_info =\n\t\t    (uint32_t *)(a->resource_fork + RSRC_H_SIZE);\n\t\t\/* Set the block count to the resource fork. *\/\n\t\tarchive_le32enc(a->decmpfs_block_info++, block_count);\n\t\t\/* Get the position where we are going to set compressed\n\t\t * data. *\/\n\t\ta->compressed_rsrc_position =\n\t\t    RSRC_H_SIZE + 4 + (block_count * 8);\n\t\ta->compressed_rsrc_position_v = a->compressed_rsrc_position;\n\t\ta->decmpfs_block_count = block_count;\n\t}\n\n\t\/* Ignore redundant bytes. *\/\n\tif (a->file_remaining_bytes == 0)\n\t\treturn ((ssize_t)size);\n\n\t\/* Do not overrun a block size. *\/\n\tif (size > a->block_remaining_bytes)\n\t\tbytes_to_write = a->block_remaining_bytes;\n\telse\n\t\tbytes_to_write = size;\n\t\/* Do not overrun the file size. *\/\n\tif (bytes_to_write > a->file_remaining_bytes)\n\t\tbytes_to_write = a->file_remaining_bytes;\n\n\t\/* For efficiency, if a copy length is full of the uncompressed\n\t * buffer size, do not copy writing data to it. *\/\n\tif (bytes_to_write == MAX_DECMPFS_BLOCK_SIZE)\n\t\tbuffer_to_write = buff;\n\telse {\n\t\tmemcpy(a->uncompressed_buffer +\n\t\t    MAX_DECMPFS_BLOCK_SIZE - a->block_remaining_bytes,\n\t\t    buff, bytes_to_write);\n\t\tbuffer_to_write = a->uncompressed_buffer;\n\t}\n\ta->block_remaining_bytes -= bytes_to_write;\n\ta->file_remaining_bytes -= bytes_to_write;\n\n\tif (a->block_remaining_bytes == 0 || a->file_remaining_bytes == 0) {\n\t\tret = hfs_drive_compressor(a, buffer_to_write,\n\t\t    MAX_DECMPFS_BLOCK_SIZE - a->block_remaining_bytes);\n\t\tif (ret < 0)\n\t\t\treturn (ret);\n\t\ta->block_remaining_bytes = MAX_DECMPFS_BLOCK_SIZE;\n\t}\n\t\/* Ignore redundant bytes. *\/\n\tif (a->file_remaining_bytes == 0)\n\t\treturn ((ssize_t)size);\n\treturn (bytes_to_write);\n}","target":0,"code_token_length":1099,"total_token_length":1335,"max_tokens_setting":2048}
+{"idx":246692,"func":"static GF_Err do_compress_top_boxes(char *inName, char *outName)\n{\n\tFILE *in, *out;\n\tu8 *buf;\n\tu32 buf_alloc, comp_size;\n\ts32 bytes_comp=0;\n\ts32 bytes_uncomp=0;\n\tGF_Err e = GF_OK;\n\tu64 source_size, dst_size;\n\tu32 orig_box_overhead;\n\tu32 final_box_overhead;\n\tu32 nb_added_box_bytes=0;\n\tBool has_mov = GF_FALSE;\n\tBool replace_all = !strcmp(compress_top_boxes, \"*\");\n\tGF_BitStream *bs_in, *bs_out;\n\n\tif (!outName) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Missing output file name\\n\"));\n\t\treturn GF_BAD_PARAM;\n\t}\n\n\tin = gf_fopen(inName, \"rb\");\n\tif (!in) return GF_URL_ERROR;\n\tout = gf_fopen(outName, \"wb\");\n\tif (!out) return GF_IO_ERR;\n\n\tbuf_alloc = 4096;\n\tbuf = gf_malloc(buf_alloc);\n\n\tbs_in = gf_bs_from_file(in, GF_BITSTREAM_READ);\n\tsource_size = gf_bs_get_size(bs_in);\n\n\tbs_out = gf_bs_from_file(out, GF_BITSTREAM_WRITE);\n\n\torig_box_overhead = 0;\n\tfinal_box_overhead = 0;\n\twhile (gf_bs_available(bs_in)) {\n\t\tu32 size = gf_bs_read_u32(bs_in);\n\t\tu32 type = gf_bs_read_u32(bs_in);\n\t\tconst char *b4cc = gf_4cc_to_str(type);\n\t\tconst u8 *replace = (const u8 *) strstr(compress_top_boxes, b4cc);\n\t\tif (!strcmp(b4cc, \"moov\")) has_mov = GF_TRUE;\n\n\t\tif (!replace && !replace_all) {\n\t\t\tgf_bs_write_u32(bs_out, size);\n\t\t\tgf_bs_write_u32(bs_out, type);\n\n\t\t\tsize-=8;\n\t\t\twhile (size) {\n\t\t\t\tu32 nbytes = size;\n\t\t\t\tif (nbytes>buf_alloc) nbytes=buf_alloc;\n\t\t\t\tgf_bs_read_data(bs_in, buf, nbytes);\n\t\t\t\tgf_bs_write_data(bs_out, buf, nbytes);\n\t\t\t\tsize-=nbytes;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\torig_box_overhead += size;\n\n\t\tsize-=8;\n\n\t\tif (size>buf_alloc) {\n\t\t\tbuf_alloc = size;\n\t\t\tbuf = gf_realloc(buf, buf_alloc);\n\t\t}\n\t\tgf_bs_read_data(bs_in, buf, size);\n\n\t\treplace+=5;\n\n\t\tcomp_size = buf_alloc;\n\n\t\te = gf_gz_compress_payload(&buf, size, &comp_size);\n\t\tif (e) break;\n\n\t\tif (comp_size>buf_alloc) {\n\t\t\tbuf_alloc = comp_size;\n\t\t}\n\t\tbytes_uncomp += size;\n\t\tbytes_comp += comp_size;\n\n\t\t\/\/write size\n\t\tgf_bs_write_u32(bs_out, comp_size+8);\n\t\t\/\/write type\n\t\tgf_bs_write_data(bs_out, replace, 4);\n\t\t\/\/write data\n\t\tgf_bs_write_data(bs_out, buf, comp_size);\n\n\t\tfinal_box_overhead += 8+comp_size;\n\t}\n\tdst_size = gf_bs_get_position(bs_out);\n\n\tif (buf) gf_free(buf);\n\tgf_bs_del(bs_in);\n\tgf_bs_del(bs_out);\n\tgf_fclose(in);\n\tgf_fclose(out);\n\tif (e) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Error compressing: %s\\n\", gf_error_to_string(e)));\n\t\treturn e;\n\t}\n\n\tif (has_mov) {\n\t\tu32 i, nb_tracks, nb_samples;\n\t\tGF_ISOFile *mov;\n\t\tDouble rate, new_rate, duration;\n\n\t\tmov = gf_isom_open(inName, GF_ISOM_OPEN_READ, NULL);\n\t\tduration = (Double) gf_isom_get_duration(mov);\n\t\tduration \/= gf_isom_get_timescale(mov);\n\n\t\tnb_samples = 0;\n\t\tnb_tracks = gf_isom_get_track_count(mov);\n\t\tfor (i=0; i<nb_tracks; i++) {\n\t\t\tnb_samples += gf_isom_get_sample_count(mov, i+1);\n\t\t}\n\t\tgf_isom_close(mov);\n\n\t\trate = (Double) source_size;\n\t\trate \/= duration;\n\t\trate \/= 1000;\n\n\t\tnew_rate = (Double) dst_size;\n\t\tnew_rate \/= duration;\n\t\tnew_rate \/= 1000;\n\n\n\t\tfprintf(stderr, \"Log format:\\nname\\torig\\tcomp\\tgain\\tadded_bytes\\torate\\tcrate\\tsamples\\tduration\\tobbps\\tcbbps\\n\");\n\t\tfprintf(stdout, \"%s\\t%d\\t%d\\t%g\\t%d\\t%g\\t%g\\t%d\\t%g\\t%g\\t%g\\n\", inName, bytes_uncomp, bytes_comp, ((Double)(bytes_uncomp-bytes_comp)*100)\/bytes_uncomp, nb_added_box_bytes, rate, new_rate, nb_samples, duration, ((Double)orig_box_overhead)\/nb_samples, ((Double)final_box_overhead)\/nb_samples );\n\n\t\tfprintf(stderr, \"%s Compressing top-level boxes saved %d bytes out of %d (reduced by %g %%) additional bytes %d original rate %g kbps new rate %g kbps, orig %g box bytes\/sample final %g bytes\/sample\\n\", inName, bytes_uncomp-bytes_comp, bytes_uncomp, ((Double)(bytes_uncomp-bytes_comp)*100)\/bytes_uncomp, nb_added_box_bytes, rate, new_rate, ((Double)orig_box_overhead)\/nb_samples, ((Double)final_box_overhead)\/nb_samples );\n\n\t} else {\n\t\tfprintf(stderr, \"Log format:\\nname\\torig\\tcomp\\tgain\\tadded_bytes\\n\");\n\t\tfprintf(stdout, \"%s\\t%d\\t%d\\t%g\\t%d\\n\", inName, bytes_uncomp, bytes_comp, ((Double) (bytes_uncomp - bytes_comp)*100)\/(bytes_uncomp), nb_added_box_bytes);\n\n\t\tfprintf(stderr, \"%s Compressing top-level boxes saved %d bytes out of %d (reduced by %g %%) additional bytes %d\\n\", inName, bytes_uncomp-bytes_comp, bytes_uncomp, ((Double)(bytes_uncomp-bytes_comp)*100)\/bytes_uncomp, nb_added_box_bytes);\n\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":1374,"total_token_length":1610,"max_tokens_setting":2048}
+{"idx":238402,"func":"njs_function_lambda_frame(njs_vm_t *vm, njs_function_t *function,\n    const njs_value_t *this, const njs_value_t *args, njs_uint_t nargs,\n    njs_bool_t ctor)\n{\n    size_t                 n, frame_size;\n    uint32_t               args_count, value_count, value_size, temp_size;\n    njs_value_t            *value, *bound, **new, **temp;\n    njs_frame_t            *frame;\n    njs_function_t         *target;\n    njs_native_frame_t     *native_frame;\n    njs_function_lambda_t  *lambda;\n\n    bound = function->bound;\n\n    if (njs_fast_path(bound == NULL)) {\n        lambda = function->u.lambda;\n        target = function;\n\n    } else {\n        target = function->u.bound_target;\n\n        if (njs_slow_path(target->bound != NULL)) {\n\n            \/*\n             * FIXME: bound functions should call target function with\n             * bound \"this\" and bound args.\n             *\/\n\n            njs_internal_error(vm, \"chain of bound function are not supported\");\n            return NJS_ERROR;\n        }\n\n        lambda = target->u.lambda;\n    }\n\n    args_count = function->args_offset + njs_max(nargs, lambda->nargs);\n    value_count = args_count + njs_max(args_count, lambda->nlocal);\n\n    value_size = value_count * sizeof(njs_value_t *);\n    temp_size = lambda->temp * sizeof(njs_value_t *);\n\n    frame_size = value_size + temp_size\n                        + ((value_count + lambda->temp) * sizeof(njs_value_t));\n\n    native_frame = njs_function_frame_alloc(vm, NJS_FRAME_SIZE + frame_size);\n    if (njs_slow_path(native_frame == NULL)) {\n        return NJS_ERROR;\n    }\n\n    \/* Local *\/\n\n    new = (njs_value_t **) ((u_char *) native_frame + NJS_FRAME_SIZE);\n    value = (njs_value_t *) ((u_char *) new + value_size + temp_size);\n\n    n = value_count + lambda->temp;\n\n    while (n != 0) {\n        n--;\n        new[n] = &value[n];\n        njs_set_invalid(new[n]);\n    }\n\n    \/* Temp *\/\n\n    temp = (njs_value_t **) ((u_char *) native_frame + NJS_FRAME_SIZE\n                                                     + value_size);\n\n    native_frame->arguments = value;\n    native_frame->arguments_offset = value + (function->args_offset - 1);\n    native_frame->local = new + args_count;\n    native_frame->temp = temp;\n    native_frame->function = target;\n    native_frame->nargs = nargs;\n    native_frame->ctor = ctor;\n    native_frame->native = 0;\n    native_frame->pc = NULL;\n\n    \/* Set this and bound arguments. *\/\n    *native_frame->local[0] = *this;\n\n    if (njs_slow_path(function->global_this\n                      && njs_is_null_or_undefined(this)))\n    {\n        njs_set_object(native_frame->local[0], &vm->global_object);\n    }\n\n    if (bound != NULL) {\n        n = function->args_offset;\n        native_frame->nargs += n - 1;\n\n        if (!ctor) {\n            *native_frame->local[0] = *bound;\n        }\n\n        bound++;\n        n--;\n\n        while (n != 0) {\n            *value++ = *bound++;\n            n--;\n        };\n    }\n\n    \/* Copy arguments. *\/\n\n    if (args != NULL) {\n        while (nargs != 0) {\n            *value++ = *args++;\n            nargs--;\n        }\n    }\n\n    frame = (njs_frame_t *) native_frame;\n    frame->exception.catch = NULL;\n    frame->exception.next = NULL;\n    frame->previous_active_frame = vm->active_frame;\n\n    return NJS_OK;\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048}
+{"idx":437305,"func":"tree_min_len(Node* node, ScanEnv* env)\n{\n  OnigLen len;\n  OnigLen tmin;\n\n  len = 0;\n  switch (NODE_TYPE(node)) {\n  case NODE_BACKREF:\n    if (! NODE_IS_CHECKER(node)) {\n      int i;\n      int* backs;\n      MemEnv* mem_env = SCANENV_MEMENV(env);\n      BackRefNode* br = BACKREF_(node);\n      if (NODE_IS_RECURSION(node)) break;\n\n      backs = BACKREFS_P(br);\n      len = tree_min_len(mem_env[backs[0]].node, env);\n      for (i = 1; i < br->back_num; i++) {\n        tmin = tree_min_len(mem_env[backs[i]].node, env);\n        if (len > tmin) len = tmin;\n      }\n    }\n    break;\n\n#ifdef USE_CALL\n  case NODE_CALL:\n    {\n      Node* t = NODE_BODY(node);\n      if (NODE_IS_RECURSION(node)) {\n        if (NODE_IS_MIN_FIXED(t))\n          len = ENCLOSURE_(t)->min_len;\n      }\n      else\n        len = tree_min_len(t, env);\n    }\n    break;\n#endif\n\n  case NODE_LIST:\n    do {\n      tmin = tree_min_len(NODE_CAR(node), env);\n      len = distance_add(len, tmin);\n    } while (IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_ALT:\n    {\n      Node *x, *y;\n      y = node;\n      do {\n        x = NODE_CAR(y);\n        tmin = tree_min_len(x, env);\n        if (y == node) len = tmin;\n        else if (len > tmin) len = tmin;\n      } while (IS_NOT_NULL(y = NODE_CDR(y)));\n    }\n    break;\n\n  case NODE_STRING:\n    {\n      StrNode* sn = STR_(node);\n      len = (int )(sn->end - sn->s);\n    }\n    break;\n\n  case NODE_CTYPE:\n  case NODE_CCLASS:\n    len = ONIGENC_MBC_MINLEN(env->enc);\n    break;\n\n  case NODE_QUANT:\n    {\n      QuantNode* qn = QUANT_(node);\n\n      if (qn->lower > 0) {\n        len = tree_min_len(NODE_BODY(node), env);\n        len = distance_multiply(len, qn->lower);\n      }\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n      switch (en->type) {\n      case ENCLOSURE_MEMORY:\n        if (NODE_IS_MIN_FIXED(node))\n          len = en->min_len;\n        else {\n          if (NODE_IS_MARK1(node))\n            len = 0;  \/* recursive *\/\n          else {\n            NODE_STATUS_ADD(node, MARK1);\n            len = tree_min_len(NODE_BODY(node), env);\n            NODE_STATUS_REMOVE(node, MARK1);\n\n            en->min_len = len;\n            NODE_STATUS_ADD(node, MIN_FIXED);\n          }\n        }\n        break;\n\n      case ENCLOSURE_OPTION:\n      case ENCLOSURE_STOP_BACKTRACK:\n        len = tree_min_len(NODE_BODY(node), env);\n        break;\n      case ENCLOSURE_IF_ELSE:\n        {\n          OnigLen elen;\n\n          len = tree_min_len(NODE_BODY(node), env);\n          if (IS_NOT_NULL(en->te.Then))\n            len += tree_min_len(en->te.Then, env);\n          if (IS_NOT_NULL(en->te.Else))\n            elen = tree_min_len(en->te.Else, env);\n          else elen = 0;\n\n          if (elen < len) len = elen;\n        }\n        break;\n      }\n    }\n    break;\n\n  case NODE_GIMMICK:\n    {\n      GimmickNode* g = GIMMICK_(node);\n      if (g->type == GIMMICK_FAIL) {\n        len = INFINITE_LEN;\n        break;\n      }\n    }\n    \/* fall *\/\n  case NODE_ANCHOR:\n  default:\n    break;\n  }\n\n  return len;\n}","target":0,"code_token_length":877,"total_token_length":1113,"max_tokens_setting":2048}
+{"idx":242986,"func":"int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush )\n{\n    int ret, done = 0;\n    size_t len = ssl->out_msglen;\n    uint8_t flush = force_flush;\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> write record\" ) );\n\n#if defined(MBEDTLS_ZLIB_SUPPORT)\n    if( ssl->transform_out != NULL &&\n        ssl->session_out->compression == MBEDTLS_SSL_COMPRESS_DEFLATE )\n    {\n        if( ( ret = ssl_compress_buf( ssl ) ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"ssl_compress_buf\", ret );\n            return( ret );\n        }\n\n        len = ssl->out_msglen;\n    }\n#endif \/*MBEDTLS_ZLIB_SUPPORT *\/\n\n#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)\n    if( mbedtls_ssl_hw_record_write != NULL )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 2, ( \"going for mbedtls_ssl_hw_record_write()\" ) );\n\n        ret = mbedtls_ssl_hw_record_write( ssl );\n        if( ret != 0 && ret != MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_hw_record_write\", ret );\n            return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );\n        }\n\n        if( ret == 0 )\n            done = 1;\n    }\n#endif \/* MBEDTLS_SSL_HW_RECORD_ACCEL *\/\n    if( !done )\n    {\n        unsigned i;\n        size_t protected_record_size;\n#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)\n        size_t out_buf_len = ssl->out_buf_len;\n#else\n        size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN;\n#endif\n        \/* Skip writing the record content type to after the encryption,\n         * as it may change when using the CID extension. *\/\n\n        mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver,\n                           ssl->conf->transport, ssl->out_hdr + 1 );\n\n        memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 );\n        MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0);\n\n        if( ssl->transform_out != NULL )\n        {\n            mbedtls_record rec;\n\n            rec.buf         = ssl->out_iv;\n            rec.buf_len     = out_buf_len - ( ssl->out_iv - ssl->out_buf );\n            rec.data_len    = ssl->out_msglen;\n            rec.data_offset = ssl->out_msg - rec.buf;\n\n            memcpy( &rec.ctr[0], ssl->out_ctr, 8 );\n            mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver,\n                                       ssl->conf->transport, rec.ver );\n            rec.type = ssl->out_msgtype;\n\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)\n            \/* The CID is set by mbedtls_ssl_encrypt_buf(). *\/\n            rec.cid_len = 0;\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n\n            if( ( ret = mbedtls_ssl_encrypt_buf( ssl, ssl->transform_out, &rec,\n                                         ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 )\n            {\n                MBEDTLS_SSL_DEBUG_RET( 1, \"ssl_encrypt_buf\", ret );\n                return( ret );\n            }\n\n            if( rec.data_offset != 0 )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"should never happen\" ) );\n                return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n            }\n\n            \/* Update the record content type and CID. *\/\n            ssl->out_msgtype = rec.type;\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID )\n            memcpy( ssl->out_cid, rec.cid, rec.cid_len );\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n            ssl->out_msglen = len = rec.data_len;\n            MBEDTLS_PUT_UINT16_BE( rec.data_len, ssl->out_len, 0 );\n        }\n\n        protected_record_size = len + mbedtls_ssl_out_hdr_len( ssl );\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n        \/* In case of DTLS, double-check that we don't exceed\n         * the remaining space in the datagram. *\/\n        if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n        {\n            ret = ssl_get_remaining_space_in_datagram( ssl );\n            if( ret < 0 )\n                return( ret );\n\n            if( protected_record_size > (size_t) ret )\n            {\n                \/* Should never happen *\/\n                return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n            }\n        }\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\n        \/* Now write the potentially updated record content type. *\/\n        ssl->out_hdr[0] = (unsigned char) ssl->out_msgtype;\n\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"output record: msgtype = %u, \"\n                                    \"version = [%u:%u], msglen = %\" MBEDTLS_PRINTF_SIZET,\n                                    ssl->out_hdr[0], ssl->out_hdr[1],\n                                    ssl->out_hdr[2], len ) );\n\n        MBEDTLS_SSL_DEBUG_BUF( 4, \"output record sent to network\",\n                               ssl->out_hdr, protected_record_size );\n\n        ssl->out_left += protected_record_size;\n        ssl->out_hdr  += protected_record_size;\n        mbedtls_ssl_update_out_pointers( ssl, ssl->transform_out );\n\n        for( i = 8; i > mbedtls_ssl_ep_len( ssl ); i-- )\n            if( ++ssl->cur_out_ctr[i - 1] != 0 )\n                break;\n\n        \/* The loop goes to its end iff the counter is wrapping *\/\n        if( i == mbedtls_ssl_ep_len( ssl ) )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"outgoing message counter would wrap\" ) );\n            return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING );\n        }\n    }\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&\n        flush == SSL_DONT_FORCE_FLUSH )\n    {\n        size_t remaining;\n        ret = ssl_get_remaining_payload_in_datagram( ssl );\n        if( ret < 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"ssl_get_remaining_payload_in_datagram\",\n                                   ret );\n            return( ret );\n        }\n\n        remaining = (size_t) ret;\n        if( remaining == 0 )\n        {\n            flush = SSL_FORCE_FLUSH;\n        }\n        else\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Still %u bytes available in current datagram\", (unsigned) remaining ) );\n        }\n    }\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\n    if( ( flush == SSL_FORCE_FLUSH ) &&\n        ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 )\n    {\n        MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_flush_output\", ret );\n        return( ret );\n    }\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= write record\" ) );\n\n    return( 0 );\n}","target":0,"code_token_length":1520,"total_token_length":1756,"max_tokens_setting":2048}
+{"idx":313784,"func":"nv_put_opt(cmdarg_T *cap, int fix_indent)\n{\n    int\t\tregname = 0;\n    void\t*reg1 = NULL, *reg2 = NULL;\n    int\t\tempty = FALSE;\n    int\t\twas_visual = FALSE;\n    int\t\tdir;\n    int\t\tflags = 0;\n    int\t\tkeep_registers = FALSE;\n\n    if (cap->oap->op_type != OP_NOP)\n    {\n#ifdef FEAT_DIFF\n\t\/\/ \"dp\" is \":diffput\"\n\tif (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p')\n\t{\n\t    clearop(cap->oap);\n\t    nv_diffgetput(TRUE, cap->opcount);\n\t}\n\telse\n#endif\n\tclearopbeep(cap->oap);\n    }\n#ifdef FEAT_JOB_CHANNEL\n    else if (bt_prompt(curbuf) && !prompt_curpos_editable())\n    {\n\tclearopbeep(cap->oap);\n    }\n#endif\n    else\n    {\n\tif (fix_indent)\n\t{\n\t    dir = (cap->cmdchar == ']' && cap->nchar == 'p')\n\t\t\t\t\t\t\t ? FORWARD : BACKWARD;\n\t    flags |= PUT_FIXINDENT;\n\t}\n\telse\n\t    dir = (cap->cmdchar == 'P'\n\t\t    || ((cap->cmdchar == 'g' || cap->cmdchar == 'z')\n\t\t\t&& cap->nchar == 'P')) ? BACKWARD : FORWARD;\n\tprep_redo_cmd(cap);\n\tif (cap->cmdchar == 'g')\n\t    flags |= PUT_CURSEND;\n\telse if (cap->cmdchar == 'z')\n\t    flags |= PUT_BLOCK_INNER;\n\n\tif (VIsual_active)\n\t{\n\t    \/\/ Putting in Visual mode: The put text replaces the selected\n\t    \/\/ text.  First delete the selected text, then put the new text.\n\t    \/\/ Need to save and restore the registers that the delete\n\t    \/\/ overwrites if the old contents is being put.\n\t    was_visual = TRUE;\n\t    regname = cap->oap->regname;\n\t    keep_registers = cap->cmdchar == 'P';\n#ifdef FEAT_CLIPBOARD\n\t    adjust_clip_reg(®name);\n#endif\n\t   if (regname == 0 || regname == '\"'\n\t\t\t\t     || VIM_ISDIGIT(regname) || regname == '-'\n#ifdef FEAT_CLIPBOARD\n\t\t    || (clip_unnamed && (regname == '*' || regname == '+'))\n#endif\n\n\t\t    )\n\t    {\n\t\t\/\/ The delete is going to overwrite the register we want to\n\t\t\/\/ put, save it first.\n\t\treg1 = get_register(regname, TRUE);\n\t    }\n\n\t    \/\/ Now delete the selected text. Avoid messages here.\n\t    cap->cmdchar = 'd';\n\t    cap->nchar = NUL;\n\t    cap->oap->regname = keep_registers ? '_' : NUL;\n\t    ++msg_silent;\n\t    nv_operator(cap);\n\t    do_pending_operator(cap, 0, FALSE);\n\t    empty = (curbuf->b_ml.ml_flags & ML_EMPTY);\n\t    --msg_silent;\n\n\t    \/\/ delete PUT_LINE_BACKWARD;\n\t    cap->oap->regname = regname;\n\n\t    if (reg1 != NULL)\n\t    {\n\t\t\/\/ Delete probably changed the register we want to put, save\n\t\t\/\/ it first. Then put back what was there before the delete.\n\t\treg2 = get_register(regname, FALSE);\n\t\tput_register(regname, reg1);\n\t    }\n\n\t    \/\/ When deleted a linewise Visual area, put the register as\n\t    \/\/ lines to avoid it joined with the next line.  When deletion was\n\t    \/\/ characterwise, split a line when putting lines.\n\t    if (VIsual_mode == 'V')\n\t\tflags |= PUT_LINE;\n\t    else if (VIsual_mode == 'v')\n\t\tflags |= PUT_LINE_SPLIT;\n\t    if (VIsual_mode == Ctrl_V && dir == FORWARD)\n\t\tflags |= PUT_LINE_FORWARD;\n\t    dir = BACKWARD;\n\t    if ((VIsual_mode != 'V'\n\t\t\t&& curwin->w_cursor.col < curbuf->b_op_start.col)\n\t\t    || (VIsual_mode == 'V'\n\t\t\t&& curwin->w_cursor.lnum < curbuf->b_op_start.lnum))\n\t\t\/\/ cursor is at the end of the line or end of file, put\n\t\t\/\/ forward.\n\t\tdir = FORWARD;\n\t    \/\/ May have been reset in do_put().\n\t    VIsual_active = TRUE;\n\t}\n\tdo_put(cap->oap->regname, NULL, dir, cap->count1, flags);\n\n\t\/\/ If a register was saved, put it back now.\n\tif (reg2 != NULL)\n\t    put_register(regname, reg2);\n\n\t\/\/ What to reselect with \"gv\"?  Selecting the just put text seems to\n\t\/\/ be the most useful, since the original text was removed.\n\tif (was_visual)\n\t{\n\t    curbuf->b_visual.vi_start = curbuf->b_op_start;\n\t    curbuf->b_visual.vi_end = curbuf->b_op_end;\n\t    \/\/ need to adjust cursor position\n\t    if (*p_sel == 'e')\n\t\tinc(&curbuf->b_visual.vi_end);\n\t}\n\n\t\/\/ When all lines were selected and deleted do_put() leaves an empty\n\t\/\/ line that needs to be deleted now.\n\tif (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL)\n\t{\n\t    ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE);\n\t    deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);\n\n\t    \/\/ If the cursor was in that line, move it to the end of the last\n\t    \/\/ line.\n\t    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t    {\n\t\tcurwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n\t\tcoladvance((colnr_T)MAXCOL);\n\t    }\n\t}\n\tauto_format(FALSE, TRUE);\n    }\n}","target":0,"code_token_length":1273,"total_token_length":1509,"max_tokens_setting":2048}
+{"idx":452253,"func":"static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp TSRMLS_DC) \/* {{{ *\/\n{\n\txmlDocPtr newdocp = NULL;\n\txmlDocPtr doc = NULL;\n\txmlNodePtr node = NULL;\n\txsltTransformContextPtr ctxt;\n\tphp_libxml_node_object *object;\n\tchar **params = NULL;\n\tint clone;\n\tzval *doXInclude, *member;\n\tzend_object_handlers *std_hnd;\n\tFILE *f;\n\tint secPrefsError = 0;\n\tint secPrefsValue, secPrefsIni;\n\txsltSecurityPrefsPtr secPrefs = NULL;\n\n\tnode = php_libxml_import_node(docp TSRMLS_CC);\n\n\tif (node) {\n\t\tdoc = node->doc;\n\t}\n\tif (doc == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid Document\");\n\t\treturn NULL;\n\t}\n\n\tif (style == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"No stylesheet associated to this object\");\n\t\treturn NULL;\n\t}\n\n\tif (intern->profiling) {\n\t\tif (php_check_open_basedir(intern->profiling TSRMLS_CC)) {\n\t\t\tf = NULL;\n\t\t} else {\n\t\t\tf = VCWD_FOPEN(intern->profiling, \"w\");\n\t\t}\n\t} else {\n\t\tf = NULL;\n\t}\n\n\tif (intern->parameter) {\n\t\tparams = php_xsl_xslt_make_params(intern->parameter, 0 TSRMLS_CC);\n\t}\n\n\tintern->doc = emalloc(sizeof(php_libxml_node_object));\n\tmemset(intern->doc, 0, sizeof(php_libxml_node_object));\n\n\tif (intern->hasKeys == 1) {\n\t\tdoc = xmlCopyDoc(doc, 1);\n\t} else {\n\t\tobject = (php_libxml_node_object *)zend_object_store_get_object(docp TSRMLS_CC);\n\t\tintern->doc->document = object->document;\n\t}\n\n\tphp_libxml_increment_doc_ref(intern->doc, doc TSRMLS_CC);\n\n\tctxt = xsltNewTransformContext(style, doc);\n\tctxt->_private = (void *) intern;\n\n\tstd_hnd = zend_get_std_object_handlers();\n\n\tMAKE_STD_ZVAL(member);\n\tZVAL_STRING(member, \"doXInclude\", 0);\n\tdoXInclude = std_hnd->read_property(id, member, BP_VAR_IS, NULL TSRMLS_CC);\n\tif (Z_TYPE_P(doXInclude) != IS_NULL) {\n\t\tconvert_to_long(doXInclude);\n\t\tctxt->xinclude = Z_LVAL_P(doXInclude);\n\t}\n\tefree(member);\n\n\tsecPrefsValue = intern->securityPrefs;\n\n\t\/* This whole if block can be removed, when we remove the xsl.security_prefs php.ini option in PHP 6+ *\/\n\tsecPrefsIni= INI_INT(\"xsl.security_prefs\");\n\t\/* if secPrefsIni has the same value as secPrefsValue, all is fine *\/\n\tif (secPrefsIni != secPrefsValue) {\n\t\tif (secPrefsIni != XSL_SECPREF_DEFAULT) {\n\t\t\t\/* if the ini value is not set to the default, throw an E_DEPRECATED warning *\/\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_DEPRECATED, \"The xsl.security_prefs php.ini option is deprecated; use XsltProcessor->setSecurityPrefs() instead\");\n\t\t\tif (intern->securityPrefsSet == 0) {\n\t\t\t\t\/* if securityPrefs were not set through the setSecurityPrefs method, take the ini setting *\/\n\t\t\t\tsecPrefsValue = secPrefsIni;\n\t\t\t} else {\n\t\t\t\t\/* else throw a notice, that the ini setting was not used *\/\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_NOTICE, \"The xsl.security_prefs php.ini was not used, since the  XsltProcessor->setSecurityPrefs() method was used\");\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* if securityPrefs is set to NONE, we don't have to do any checks, but otherwise... *\/\n\tif (secPrefsValue != XSL_SECPREF_NONE) {\n\t\tsecPrefs = xsltNewSecurityPrefs();\n\t\tif (secPrefsValue & XSL_SECPREF_READ_FILE ) {\n\t\t\tif (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid)) {\n\t\t\t\tsecPrefsError = 1;\n\t\t\t}\n\t\t}\n\t\tif (secPrefsValue & XSL_SECPREF_WRITE_FILE ) {\n\t\t\tif (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid)) {\n\t\t\t\tsecPrefsError = 1;\n\t\t\t}\n\t\t}\n\t\tif (secPrefsValue & XSL_SECPREF_CREATE_DIRECTORY ) {\n\t\t\tif (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid)) {\n\t\t\t\tsecPrefsError = 1;\n\t\t\t}\n\t\t}\n\t\tif (secPrefsValue & XSL_SECPREF_READ_NETWORK) {\n\t\t\tif (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid)) {\n\t\t\t\tsecPrefsError = 1;\n\t\t\t}\n\t\t}\n\t\tif (secPrefsValue & XSL_SECPREF_WRITE_NETWORK) {\n\t\t\tif (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid)) {\n\t\t\t\tsecPrefsError = 1;\n\t\t\t}\n\t\t}\n\n\t\tif (0 != xsltSetCtxtSecurityPrefs(secPrefs, ctxt)) {\n\t\t\tsecPrefsError = 1;\n\t\t}\n\t}\n\n\tif (secPrefsError == 1) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Can't set libxslt security properties, not doing transformation for security reasons\");\n\t} else {\n\t\tnewdocp = xsltApplyStylesheetUser(style, doc, (const char**) params,  NULL, f, ctxt);\n\t}\n\tif (f) {\n\t\tfclose(f);\n\t}\n\n\txsltFreeTransformContext(ctxt);\n\tif (secPrefs) {\n\t\txsltFreeSecurityPrefs(secPrefs);\n\t}\n\n\tif (intern->node_list != NULL) {\n\t\tzend_hash_destroy(intern->node_list);\n\t\tFREE_HASHTABLE(intern->node_list);\n\t\tintern->node_list = NULL;\n\t}\n\n\tphp_libxml_decrement_doc_ref(intern->doc TSRMLS_CC);\n\tefree(intern->doc);\n\tintern->doc = NULL;\n\n\tif (params) {\n\t\tclone = 0;\n\t\twhile(params[clone]) {\n\t\t\tefree(params[clone++]);\n\t\t}\n\t\tefree(params);\n\t}\n\n\treturn newdocp;\n\n}","target":0,"code_token_length":1421,"total_token_length":1657,"max_tokens_setting":2048}
+{"idx":247516,"func":"int read_image_tga( gdIOCtx *ctx, oTga *tga )\n{\n\tint pixel_block_size = (tga->bits \/ 8);\n\tint image_block_size;\n\tint* decompression_buffer = NULL;\n\tunsigned char* conversion_buffer = NULL;\n\tint buffer_caret = 0;\n\tint bitmap_caret = 0;\n\tint i = 0;\n\tint encoded_pixels;\n\tint rle_size;\n\n\tif(overflow2(tga->width, tga->height)) {\n\t\treturn -1;\n\t}\n\n\tif(overflow2(tga->width * tga->height, pixel_block_size)) {\n\t\treturn -1;\n\t}\n\n\timage_block_size = (tga->width * tga->height) * pixel_block_size;\n\tif(overflow2(image_block_size, sizeof(int))) {\n\t\treturn -1;\n\t}\n\n\t\/*! \\todo Add more image type support.\n\t *\/\n\tif (tga->imagetype != TGA_TYPE_RGB && tga->imagetype != TGA_TYPE_RGB_RLE)\n\t\treturn -1;\n\n\t\/*!\t\\brief Allocate memmory for image block\n\t *  Allocate a chunk of memory for the image block to be passed into.\n\t *\/\n\ttga->bitmap = (int *) gdMalloc(image_block_size * sizeof(int));\n\tif (tga->bitmap == NULL)\n\t\treturn -1;\n\n\tswitch (tga->imagetype) {\n\tcase TGA_TYPE_RGB:\n\t\t\/*! \\brief Read in uncompressed RGB TGA\n\t\t *  Chunk load the pixel data from an uncompressed RGB type TGA.\n\t\t *\/\n\t\tconversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char));\n\t\tif (conversion_buffer == NULL) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) {\n\t\t\tgd_error(\"gd-tga: premature end of image data\\n\");\n\t\t\tgdFree(conversion_buffer);\n\t\t\treturn -1;\n\t\t}\n\n\t\twhile (buffer_caret < image_block_size) {\n\t\t\ttga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret];\n\t\t\tbuffer_caret++;\n\t\t}\n\n\t\tgdFree(conversion_buffer);\n\t\tbreak;\n\n\tcase TGA_TYPE_RGB_RLE:\n\t\t\/*! \\brief Read in RLE compressed RGB TGA\n\t\t *  Chunk load the pixel data from an RLE compressed RGB type TGA.\n\t\t *\/\n\t\tdecompression_buffer = (int*) gdMalloc(image_block_size * sizeof(int));\n\t\tif (decompression_buffer == NULL) {\n\t\t\treturn -1;\n\t\t}\n\t\tconversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char));\n\t\tif (conversion_buffer == NULL) {\n\t\t\tgd_error(\"gd-tga: premature end of image data\\n\");\n\t\t\tgdFree( decompression_buffer );\n\t\t\treturn -1;\n\t\t}\n\n\t\trle_size = gdGetBuf(conversion_buffer, image_block_size, ctx);\n\t\tif (rle_size <= 0) {\n\t\t\tgdFree(conversion_buffer);\n\t\t\tgdFree(decompression_buffer);\n\t\t\treturn -1;\n\t\t}\n\n\t\tbuffer_caret = 0;\n\n\t\twhile( buffer_caret < rle_size) {\n\t\t\tdecompression_buffer[buffer_caret] = (int)conversion_buffer[buffer_caret];\n\t\t\tbuffer_caret++;\n\t\t}\n\n\t\tbuffer_caret = 0;\n\n\t\twhile( bitmap_caret < image_block_size ) {\n\n\t\t\tif (buffer_caret + pixel_block_size > rle_size) {\n\t\t\t\tgdFree( decompression_buffer );\n\t\t\t\tgdFree( conversion_buffer );\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tif ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) {\n\t\t\t\tencoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 );\n\t\t\t\tbuffer_caret++;\n\n\t\t\t\tif ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size\n\t\t\t\t\t\t|| buffer_caret + pixel_block_size > rle_size) {\n\t\t\t\t\tgdFree( decompression_buffer );\n\t\t\t\t\tgdFree( conversion_buffer );\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\n\t\t\t\tfor (i = 0; i < encoded_pixels; i++) {\n\t\t\t\t\tmemcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size * sizeof(int));\n\t\t\t\t\tbitmap_caret += pixel_block_size;\n\t\t\t\t}\n\t\t\t\tbuffer_caret += pixel_block_size;\n\n\t\t\t} else {\n\t\t\t\tencoded_pixels = decompression_buffer[ buffer_caret ] + 1;\n\t\t\t\tbuffer_caret++;\n\n\t\t\t\tif ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size\n\t\t\t\t\t\t|| buffer_caret + (encoded_pixels * pixel_block_size) > rle_size) {\n\t\t\t\t\tgdFree( decompression_buffer );\n\t\t\t\t\tgdFree( conversion_buffer );\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\n\t\t\t\tmemcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size * sizeof(int));\n\t\t\t\tbitmap_caret += (encoded_pixels * pixel_block_size);\n\t\t\t\tbuffer_caret += (encoded_pixels * pixel_block_size);\n\t\t\t}\n\t\t}\n\t\tgdFree( decompression_buffer );\n\t\tgdFree( conversion_buffer );\n\t\tbreak;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":1130,"total_token_length":1366,"max_tokens_setting":2048}
+{"idx":390612,"func":"ProcXkbGetDeviceInfo(ClientPtr client)\n{\nDeviceIntPtr\t\tdev;\nxkbGetDeviceInfoReply\trep;\nint\t\t\tstatus,nDeviceLedFBs;\nunsigned\t\tlength,nameLen;\nCARD16\t\t\tledClass,ledID;\nunsigned\t\twanted,supported;\nchar *\t\t\tstr;\n\n    REQUEST(xkbGetDeviceInfoReq);\n    REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    wanted= stuff->wanted;\n\n    CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);\n    CHK_MASK_LEGAL(0x01,wanted,XkbXI_AllDeviceFeaturesMask);\n\n    if ((!dev->button)||((stuff->nBtns<1)&&(!stuff->allBtns)))\n\twanted&= ~XkbXI_ButtonActionsMask;\n    if ((!dev->kbdfeed)&&(!dev->leds))\n\twanted&= ~XkbXI_IndicatorsMask;\n\n    nameLen= XkbSizeCountedString(dev->name);\n    bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply));\n    rep.type = X_Reply;\n    rep.deviceID= dev->id;\n    rep.sequenceNumber = client->sequence;\n    rep.length = nameLen\/4;\n    rep.present = wanted;\n    rep.supported = XkbXI_AllDeviceFeaturesMask;\n    rep.unsupported = 0;\n    rep.firstBtnWanted = rep.nBtnsWanted = 0;\n    rep.firstBtnRtrn = rep.nBtnsRtrn = 0;\n    if (dev->button)\n\t rep.totalBtns= dev->button->numButtons;\n    else rep.totalBtns= 0;\n    rep.devType=\tdev->type;\n    rep.hasOwnState=\t(dev->key && dev->key->xkbInfo);\n    rep.nDeviceLedFBs = 0;\n    if (dev->kbdfeed)\trep.dfltKbdFB= dev->kbdfeed->ctrl.id;\n    else\t\trep.dfltKbdFB= XkbXINone;\n    if (dev->leds)\trep.dfltLedFB= dev->leds->ctrl.id;\n    else\t\trep.dfltLedFB= XkbXINone;\n\n    ledClass= stuff->ledClass;\n    ledID= stuff->ledID;\n\n    rep.firstBtnWanted= rep.nBtnsWanted= 0;\n    rep.firstBtnRtrn= rep.nBtnsRtrn= 0;\n    if (wanted&XkbXI_ButtonActionsMask) {\n\tif (stuff->allBtns) {\n\t    stuff->firstBtn= 0;\n\t    stuff->nBtns= dev->button->numButtons;\n\t}\n\n\tif ((stuff->firstBtn+stuff->nBtns)>dev->button->numButtons) {\n\t    client->errorValue = _XkbErrCode4(0x02,dev->button->numButtons,\n\t\t\t\t\t\t\tstuff->firstBtn,\n\t\t\t\t\t\t\tstuff->nBtns);\n\t    return BadValue;\n\t}\n\telse {\n\t    rep.firstBtnWanted= stuff->firstBtn;\n\t    rep.nBtnsWanted= stuff->nBtns;\n\t    if (dev->button->xkb_acts!=NULL) {\n\t\tXkbAction *act;\n\t\tregister int i;\n\n\t\trep.firstBtnRtrn= stuff->firstBtn;\n\t\trep.nBtnsRtrn= stuff->nBtns;\n\t\tact= &dev->button->xkb_acts[rep.firstBtnWanted];\n\t\tfor (i=0;i<rep.nBtnsRtrn;i++,act++) {\n\t\t    if (act->type!=XkbSA_NoAction)\n\t\t\tbreak;\n\t\t}\n\t\trep.firstBtnRtrn+=\ti;\n\t\trep.nBtnsRtrn-=\t\ti;\n\t\tact= &dev->button->xkb_acts[rep.firstBtnRtrn+rep.nBtnsRtrn-1];\n\t\tfor (i=0;i<rep.nBtnsRtrn;i++,act--) {\n\t\t    if (act->type!=XkbSA_NoAction)\n\t\t\tbreak;\n\t\t}\n\t\trep.nBtnsRtrn-=\t\ti;\n\t    }\n\t    rep.length+= (rep.nBtnsRtrn*SIZEOF(xkbActionWireDesc))\/4;\n\t}\n    }\n\n    if (wanted&XkbXI_IndicatorsMask) {\n\tstatus= CheckDeviceLedFBs(dev,ledClass,ledID,&rep,client);\n\tif (status!=Success)\n\t    return status;\n    }\n    length= rep.length*4;\n    supported= rep.supported;\n    nDeviceLedFBs = rep.nDeviceLedFBs;\n    if (client->swapped) {\n\tregister int n;\n\tswaps(&rep.sequenceNumber,n);\n\tswapl(&rep.length,n);\n\tswaps(&rep.present,n);\n\tswaps(&rep.supported,n);\n\tswaps(&rep.unsupported,n);\n\tswaps(&rep.nDeviceLedFBs,n);\n\tswapl(&rep.type,n);\n    }\n    WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep);\n\n    str= (char*) xalloc(nameLen);\n    if (!str) \n\treturn BadAlloc;\n    XkbWriteCountedString(str,dev->name,client->swapped);\n    WriteToClient(client,nameLen,str);\n    xfree(str);\n    length-= nameLen;\n\n    if (rep.nBtnsRtrn>0) {\n\tint\t\t\tsz;\n\txkbActionWireDesc *\tawire;\n\tsz= rep.nBtnsRtrn*SIZEOF(xkbActionWireDesc);\n\tawire= (xkbActionWireDesc *)&dev->button->xkb_acts[rep.firstBtnRtrn];\n\tWriteToClient(client,sz,(char *)awire);\n\tlength-= sz;\n    }\n    if (nDeviceLedFBs>0) {\n\tstatus= SendDeviceLedFBs(dev,ledClass,ledID,length,client);\n\tif (status!=Success)\n\t    return status;\n    }\n    else if (length!=0)  {\n\tErrorF(\"[xkb] Internal Error!  BadLength in ProcXkbGetDeviceInfo\\n\");\n\tErrorF(\"[xkb]                  Wrote %d fewer bytes than expected\\n\",length);\n\treturn BadLength;\n    }\n    if (stuff->wanted&(~supported)) {\n\txkbExtensionDeviceNotify ed;\n\tbzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));\n\ted.ledClass=\t\tledClass;\n\ted.ledID=\t\tledID;\n\ted.ledsDefined= \t0;\n\ted.ledState=\t\t0;\n\ted.firstBtn= ed.nBtns=\t0;\n\ted.reason=\t\tXkbXI_UnsupportedFeatureMask;\n\ted.supported=\t\tsupported;\n\ted.unsupported=\t\tstuff->wanted&(~supported);\n\tXkbSendExtensionDeviceNotify(dev,client,&ed);\n    }\n    return client->noClientException;\n}","target":0,"code_token_length":1480,"total_token_length":1716,"max_tokens_setting":2048}
+{"idx":413602,"func":"static int core_anal_graph_construct_edges(RCore *core, RAnalFunction *fcn, int opts, PJ *pj, Sdb *DB) {\n\tRAnalBlock *bbi;\n\tRListIter *iter;\n\tint is_keva = opts & R_CORE_ANAL_KEYVALUE;\n\tint is_star = opts & R_CORE_ANAL_STAR;\n\tint is_json = opts & R_CORE_ANAL_JSON;\n\tint is_html = r_cons_context ()->is_html;\n\tchar *pal_jump = palColorFor (\"graph.true\");\n\tchar *pal_fail = palColorFor (\"graph.false\");\n\tchar *pal_trfa = palColorFor (\"graph.trufae\");\n\tint nodes = 0;\n\tr_list_foreach (fcn->bbs, iter, bbi) {\n\t\tif (bbi->jump != UT64_MAX) {\n\t\t\tnodes++;\n\t\t\tif (is_keva) {\n\t\t\t\tchar key[128];\n\t\t\t\tchar val[128];\n\t\t\t\tsnprintf (key, sizeof (key), \"bb.0x%08\"PFMT64x\".to\", bbi->addr);\n\t\t\t\tif (bbi->fail != UT64_MAX) {\n\t\t\t\t\tsnprintf (val, sizeof (val), \"0x%08\"PFMT64x, bbi->jump);\n\t\t\t\t} else {\n\t\t\t\t\tsnprintf (val, sizeof (val), \"0x%08\"PFMT64x \",0x%08\"PFMT64x,\n\t\t\t\t\t\t\tbbi->jump, bbi->fail);\n\t\t\t\t}\n\t\t\t\t\/\/ bb.<addr>.to=<jump>,<fail>\n\t\t\t\tsdb_set (DB, key, val, 0);\n\t\t\t} else if (is_html) {\n\t\t\t\tr_cons_printf (\"<div class=\\\"connector _0x%08\"PFMT64x\" _0x%08\"PFMT64x\"\\\">\\n\"\n\t\t\t\t\t\t\"  <img class=\\\"connector-end\\\" src=\\\"img\/arrow.gif\\\" \/><\/div>\\n\",\n\t\t\t\t\t\tbbi->addr, bbi->jump);\n\t\t\t} else if (!is_json && !is_keva) {\n\t\t\t\tif (is_star) {\n\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\tchar *to = get_title (bbi->jump);\n\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from, to);\n\t\t\t\t\tfree (from);\n\t\t\t\t\tfree (to);\n\t\t\t\t} else {\n\t\t\t\t\tr_strf_buffer (128);\n\t\t\t\t\tconst char* edge_color = bbi->fail != -1 ? pal_jump : pal_trfa;\n\t\t\t\t\tif (sdb_const_get (core->sdb, r_strf (\"agraph.edge.0x%\"PFMT64x\"_0x%\"PFMT64x\".highlight\", bbi->addr, bbi->jump), 0)) {\n\t\t\t\t\t\tedge_color = \"cyan\";\n\t\t\t\t\t}\n\t\t\t\t\tr_cons_printf (\"        \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\", bbi->addr, bbi->jump, edge_color);\n\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (bbi->fail != -1) {\n\t\t\tnodes++;\n\t\t\tif (is_html) {\n\t\t\t\tr_cons_printf (\"<div class=\\\"connector _0x%08\"PFMT64x\" _0x%08\"PFMT64x\"\\\">\\n\"\n\t\t\t\t\t\t\"  <img class=\\\"connector-end\\\" src=\\\"img\/arrow.gif\\\"\/><\/div>\\n\",\n\t\t\t\t\t\tbbi->addr, bbi->fail);\n\t\t\t} else if (!is_keva && !is_json) {\n\t\t\t\tif (is_star) {\n\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\tchar *to = get_title (bbi->fail);\n\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from, to);\n\t\t\t\t\tfree(from);\n\t\t\t\t\tfree(to);\n\t\t\t\t} else {\n\t\t\t\t\tr_cons_printf (\"        \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\", bbi->addr, bbi->fail, pal_fail);\n\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (bbi->switch_op) {\n\t\t\tRAnalCaseOp *caseop;\n\t\t\tRListIter *iter;\n\n\t\t\tif (bbi->fail != UT64_MAX) {\n\t\t\t\tif (is_html) {\n\t\t\t\t\tr_cons_printf (\"<div class=\\\"connector _0x%08\"PFMT64x\" _0x%08\"PFMT64x\"\\\">\\n\"\n\t\t\t\t\t\t\t\"  <img class=\\\"connector-end\\\" src=\\\"img\/arrow.gif\\\"\/><\/div>\\n\",\n\t\t\t\t\t\t\tbbi->addr, bbi->fail);\n\t\t\t\t} else if (!is_keva && !is_json) {\n\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\t\tchar *to = get_title (bbi->fail);\n\t\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from, to);\n\t\t\t\t\t\tfree(from);\n\t\t\t\t\t\tfree(to);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr_cons_printf (\"        \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\", bbi->addr, bbi->fail, pal_fail);\n\t\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tr_list_foreach (bbi->switch_op->cases, iter, caseop) {\n\t\t\t\tnodes++;\n\t\t\t\tif (is_keva) {\n\t\t\t\t\tchar key[128];\n\t\t\t\t\tsnprintf (key, sizeof (key),\n\t\t\t\t\t\t\t\"bb.0x%08\"PFMT64x\".switch.%\"PFMT64d,\n\t\t\t\t\t\t\tbbi->addr, caseop->value);\n\t\t\t\t\tsdb_num_set (DB, key, caseop->jump, 0);\n\t\t\t\t\tsnprintf (key, sizeof (key),\n\t\t\t\t\t\t\t\"bb.0x%08\"PFMT64x\".switch\", bbi->addr);\n\t\t\t\t\t\t\tsdb_array_add_num (DB, key, caseop->value, 0);\n\t\t\t\t} else if (is_html) {\n\t\t\t\t\tr_cons_printf (\"<div class=\\\"connector _0x%08\" PFMT64x \" _0x%08\" PFMT64x \"\\\">\\n\"\n\t\t\t\t\t\t\t\"  <img class=\\\"connector-end\\\" src=\\\"img\/arrow.gif\\\"\/><\/div>\\n\",\n\t\t\t\t\t\t\tbbi->addr, caseop->addr);\n\t\t\t\t} else if (!is_json && !is_keva) {\n\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\tchar *from = get_title (bbi->addr);\n\t\t\t\t\t\tchar *to = get_title (caseop->addr);\n\t\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", from ,to);\n\t\t\t\t\t\tfree (from);\n\t\t\t\t\t\tfree (to);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr_cons_printf (\"        \\\"0x%08\" PFMT64x \"\\\" -> \\\"0x%08\" PFMT64x \"\\\" \"\n\t\t\t\t\t\t\t\t\"[color=\\\"%s\\\"];\\n\",\n\t\t\t\t\t\t\t\tbbi->addr, caseop->addr, pal_trfa);\n\t\t\t\t\t\tcore_anal_color_curr_node (core, bbi);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfree(pal_jump);\n\tfree(pal_fail);\n\tfree(pal_trfa);\n\treturn nodes;\n}","target":0,"code_token_length":1636,"total_token_length":1872,"max_tokens_setting":2048}
+{"idx":195056,"func":"inline void BiasAndClamp(float clamp_min, float clamp_max, int bias_size,\n                         const float* bias_data, int array_size,\n                         float* array_data) {\n  \/\/ Note: see b\/132215220: in May 2019 we thought it would be OK to replace\n  \/\/ this with the Eigen one-liner:\n  \/\/   return (array.colwise() + bias).cwiseMin(clamp_max).cwiseMin(clamp_max).\n  \/\/ This turned out to severely regress performance: +4ms (i.e. 8%) on\n  \/\/ MobileNet v2 \/ 1.0 \/ 224. So we keep custom NEON code for now.\n  TFLITE_DCHECK_EQ((array_size % bias_size), 0);\n#ifdef USE_NEON\n  float* array_ptr = array_data;\n  float* array_end_ptr = array_ptr + array_size;\n  const auto clamp_min_vec = vdupq_n_f32(clamp_min);\n  const auto clamp_max_vec = vdupq_n_f32(clamp_max);\n  for (; array_ptr != array_end_ptr; array_ptr += bias_size) {\n    int i = 0;\n    for (; i <= bias_size - 16; i += 16) {\n      auto b0 = vld1q_f32(bias_data + i);\n      auto b1 = vld1q_f32(bias_data + i + 4);\n      auto b2 = vld1q_f32(bias_data + i + 8);\n      auto b3 = vld1q_f32(bias_data + i + 12);\n      auto a0 = vld1q_f32(array_ptr + i);\n      auto a1 = vld1q_f32(array_ptr + i + 4);\n      auto a2 = vld1q_f32(array_ptr + i + 8);\n      auto a3 = vld1q_f32(array_ptr + i + 12);\n      auto x0 = vaddq_f32(a0, b0);\n      auto x1 = vaddq_f32(a1, b1);\n      auto x2 = vaddq_f32(a2, b2);\n      auto x3 = vaddq_f32(a3, b3);\n      x0 = vmaxq_f32(clamp_min_vec, x0);\n      x1 = vmaxq_f32(clamp_min_vec, x1);\n      x2 = vmaxq_f32(clamp_min_vec, x2);\n      x3 = vmaxq_f32(clamp_min_vec, x3);\n      x0 = vminq_f32(clamp_max_vec, x0);\n      x1 = vminq_f32(clamp_max_vec, x1);\n      x2 = vminq_f32(clamp_max_vec, x2);\n      x3 = vminq_f32(clamp_max_vec, x3);\n      vst1q_f32(array_ptr + i, x0);\n      vst1q_f32(array_ptr + i + 4, x1);\n      vst1q_f32(array_ptr + i + 8, x2);\n      vst1q_f32(array_ptr + i + 12, x3);\n    }\n    for (; i <= bias_size - 4; i += 4) {\n      auto b = vld1q_f32(bias_data + i);\n      auto a = vld1q_f32(array_ptr + i);\n      auto x = vaddq_f32(a, b);\n      x = vmaxq_f32(clamp_min_vec, x);\n      x = vminq_f32(clamp_max_vec, x);\n      vst1q_f32(array_ptr + i, x);\n    }\n    for (; i < bias_size; i++) {\n      array_ptr[i] = ActivationFunctionWithMinMax(array_ptr[i] + bias_data[i],\n                                                  clamp_min, clamp_max);\n    }\n  }\n#else  \/\/ not NEON\n  for (int array_offset = 0; array_offset < array_size;\n       array_offset += bias_size) {\n    for (int i = 0; i < bias_size; i++) {\n      array_data[array_offset + i] = ActivationFunctionWithMinMax(\n          array_data[array_offset + i] + bias_data[i], clamp_min, clamp_max);\n    }\n  }\n#endif\n}","target":1,"code_token_length":957,"total_token_length":1193,"max_tokens_setting":2048}
+{"idx":240595,"func":"  void DoCompute(OpKernelContext* c) {\n    core::RefCountPtr<Var> v;\n    OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n    Tensor* params = v->tensor();\n    const Tensor& indices = c->input(1);\n    const Tensor& updates = c->input(2);\n\n    \/\/ Check that rank(updates.shape) = rank(indices.shape + params.shape[1:])\n    OP_REQUIRES(c,\n                updates.dims() == 0 ||\n                    updates.dims() == indices.dims() + params->dims() - 1,\n                errors::InvalidArgument(\n                    \"Must have updates.shape = indices.shape + \"\n                    \"params.shape[1:] or updates.shape = [], got \",\n                    \"updates.shape \", updates.shape().DebugString(),\n                    \", indices.shape \", indices.shape().DebugString(),\n                    \", params.shape \", params->shape().DebugString()));\n\n    \/\/ Check that we have enough index space\n    const int64_t N_big = indices.NumElements();\n    OP_REQUIRES(\n        c, N_big <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"indices has too many elements for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", N_big, \" > \",\n                                std::numeric_limits<Index>::max()));\n    const Index N = static_cast<Index>(N_big);\n    OP_REQUIRES(\n        c, params->dim_size(0) <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"params.shape[0] too large for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", params->dim_size(0), \" > \",\n                                std::numeric_limits<Index>::max()));\n\n    \/\/ Prevent division by 0\n    if (isCPUDevice<Device>() && op == tensorflow::scatter_op::UpdateOp::DIV) {\n      OP_REQUIRES(c, ValidateInput<T>(updates),\n                  errors::InvalidArgument(\"updates must not contain 0\"));\n    }\n\n    if (N > 0) {\n      auto indices_flat = indices.flat<Index>();\n      auto params_flat = params->flat_outer_dims<T>();\n      if (TensorShapeUtils::IsScalar(updates.shape())) {\n        const auto update = updates.scalar<T>();\n\n        functor::ScatterScalarFunctor<Device, T, Index, op> functor;\n        const Index bad_i = functor(c, c->template eigen_device<Device>(),\n                                    params_flat, update, indices_flat);\n        OP_REQUIRES(c, bad_i < 0,\n                    errors::InvalidArgument(\n                        \"indices\", SliceDebugString(indices.shape(), bad_i),\n                        \" = \", indices_flat(bad_i), \" is not in [0, \",\n                        params->dim_size(0), \")\"));\n      } else {\n        int64_t num_updates = updates.NumElements();\n        OP_REQUIRES(\n            c, TensorShapeUtils::StartsWith(updates.shape(), indices.shape()),\n            errors::InvalidArgument(\n                \"The shape of indices (\", indices.shape().DebugString(),\n                \") must be a prefix of the shape of updates (\",\n                updates.shape().DebugString(), \")\"));\n        auto updates_flat = updates.shaped<T, 2>({N, num_updates \/ N});\n\n        functor::ScatterFunctor<Device, T, Index, op> functor;\n        const Index bad_i = functor(c, c->template eigen_device<Device>(),\n                                    params_flat, updates_flat, indices_flat);\n        OP_REQUIRES(c, bad_i < 0,\n                    errors::InvalidArgument(\n                        \"indices\", SliceDebugString(indices.shape(), bad_i),\n                        \" = \", indices_flat(bad_i), \" is not in [0, \",\n                        params->dim_size(0), \")\"));\n      }\n    }\n  }","target":0,"code_token_length":796,"total_token_length":1032,"max_tokens_setting":2048}
+{"idx":484805,"func":"static int talk_to_netback(struct xenbus_device *dev,\n\t\t\t   struct netfront_info *info)\n{\n\tconst char *message;\n\tstruct xenbus_transaction xbt;\n\tint err;\n\tunsigned int feature_split_evtchn;\n\tunsigned int i = 0;\n\tunsigned int max_queues = 0;\n\tstruct netfront_queue *queue = NULL;\n\tunsigned int num_queues = 1;\n\tu8 addr[ETH_ALEN];\n\n\tinfo->netdev->irq = 0;\n\n\t\/* Check if backend is trusted. *\/\n\tinfo->bounce = !xennet_trusted ||\n\t\t       !xenbus_read_unsigned(dev->nodename, \"trusted\", 1);\n\n\t\/* Check if backend supports multiple queues *\/\n\tmax_queues = xenbus_read_unsigned(info->xbdev->otherend,\n\t\t\t\t\t  \"multi-queue-max-queues\", 1);\n\tnum_queues = min(max_queues, xennet_max_queues);\n\n\t\/* Check feature-split-event-channels *\/\n\tfeature_split_evtchn = xenbus_read_unsigned(info->xbdev->otherend,\n\t\t\t\t\t\"feature-split-event-channels\", 0);\n\n\t\/* Read mac addr. *\/\n\terr = xen_net_read_mac(dev, addr);\n\tif (err) {\n\t\txenbus_dev_fatal(dev, err, \"parsing %s\/mac\", dev->nodename);\n\t\tgoto out_unlocked;\n\t}\n\teth_hw_addr_set(info->netdev, addr);\n\n\tinfo->netback_has_xdp_headroom = xenbus_read_unsigned(info->xbdev->otherend,\n\t\t\t\t\t\t\t      \"feature-xdp-headroom\", 0);\n\tif (info->netback_has_xdp_headroom) {\n\t\t\/* set the current xen-netfront xdp state *\/\n\t\terr = talk_to_netback_xdp(info, info->netfront_xdp_enabled ?\n\t\t\t\t\t  NETBACK_XDP_HEADROOM_ENABLE :\n\t\t\t\t\t  NETBACK_XDP_HEADROOM_DISABLE);\n\t\tif (err)\n\t\t\tgoto out_unlocked;\n\t}\n\n\trtnl_lock();\n\tif (info->queues)\n\t\txennet_destroy_queues(info);\n\n\t\/* For the case of a reconnect reset the \"broken\" indicator. *\/\n\tinfo->broken = false;\n\n\terr = xennet_create_queues(info, &num_queues);\n\tif (err < 0) {\n\t\txenbus_dev_fatal(dev, err, \"creating queues\");\n\t\tkfree(info->queues);\n\t\tinfo->queues = NULL;\n\t\tgoto out;\n\t}\n\trtnl_unlock();\n\n\t\/* Create shared ring, alloc event channel -- for each queue *\/\n\tfor (i = 0; i < num_queues; ++i) {\n\t\tqueue = &info->queues[i];\n\t\terr = setup_netfront(dev, queue, feature_split_evtchn);\n\t\tif (err)\n\t\t\tgoto destroy_ring;\n\t}\n\nagain:\n\terr = xenbus_transaction_start(&xbt);\n\tif (err) {\n\t\txenbus_dev_fatal(dev, err, \"starting transaction\");\n\t\tgoto destroy_ring;\n\t}\n\n\tif (xenbus_exists(XBT_NIL,\n\t\t\t  info->xbdev->otherend, \"multi-queue-max-queues\")) {\n\t\t\/* Write the number of queues *\/\n\t\terr = xenbus_printf(xbt, dev->nodename,\n\t\t\t\t    \"multi-queue-num-queues\", \"%u\", num_queues);\n\t\tif (err) {\n\t\t\tmessage = \"writing multi-queue-num-queues\";\n\t\t\tgoto abort_transaction_no_dev_fatal;\n\t\t}\n\t}\n\n\tif (num_queues == 1) {\n\t\terr = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); \/* flat *\/\n\t\tif (err)\n\t\t\tgoto abort_transaction_no_dev_fatal;\n\t} else {\n\t\t\/* Write the keys for each queue *\/\n\t\tfor (i = 0; i < num_queues; ++i) {\n\t\t\tqueue = &info->queues[i];\n\t\t\terr = write_queue_xenstore_keys(queue, &xbt, 1); \/* hierarchical *\/\n\t\t\tif (err)\n\t\t\t\tgoto abort_transaction_no_dev_fatal;\n\t\t}\n\t}\n\n\t\/* The remaining keys are not queue-specific *\/\n\terr = xenbus_printf(xbt, dev->nodename, \"request-rx-copy\", \"%u\",\n\t\t\t    1);\n\tif (err) {\n\t\tmessage = \"writing request-rx-copy\";\n\t\tgoto abort_transaction;\n\t}\n\n\terr = xenbus_printf(xbt, dev->nodename, \"feature-rx-notify\", \"%d\", 1);\n\tif (err) {\n\t\tmessage = \"writing feature-rx-notify\";\n\t\tgoto abort_transaction;\n\t}\n\n\terr = xenbus_printf(xbt, dev->nodename, \"feature-sg\", \"%d\", 1);\n\tif (err) {\n\t\tmessage = \"writing feature-sg\";\n\t\tgoto abort_transaction;\n\t}\n\n\terr = xenbus_printf(xbt, dev->nodename, \"feature-gso-tcpv4\", \"%d\", 1);\n\tif (err) {\n\t\tmessage = \"writing feature-gso-tcpv4\";\n\t\tgoto abort_transaction;\n\t}\n\n\terr = xenbus_write(xbt, dev->nodename, \"feature-gso-tcpv6\", \"1\");\n\tif (err) {\n\t\tmessage = \"writing feature-gso-tcpv6\";\n\t\tgoto abort_transaction;\n\t}\n\n\terr = xenbus_write(xbt, dev->nodename, \"feature-ipv6-csum-offload\",\n\t\t\t   \"1\");\n\tif (err) {\n\t\tmessage = \"writing feature-ipv6-csum-offload\";\n\t\tgoto abort_transaction;\n\t}\n\n\terr = xenbus_transaction_end(xbt, 0);\n\tif (err) {\n\t\tif (err == -EAGAIN)\n\t\t\tgoto again;\n\t\txenbus_dev_fatal(dev, err, \"completing transaction\");\n\t\tgoto destroy_ring;\n\t}\n\n\treturn 0;\n\n abort_transaction:\n\txenbus_dev_fatal(dev, err, \"%s\", message);\nabort_transaction_no_dev_fatal:\n\txenbus_transaction_end(xbt, 1);\n destroy_ring:\n\txennet_disconnect_backend(info);\n\trtnl_lock();\n\txennet_destroy_queues(info);\n out:\n\trtnl_unlock();\nout_unlocked:\n\tdevice_unregister(&dev->dev);\n\treturn err;\n}","target":0,"code_token_length":1266,"total_token_length":1502,"max_tokens_setting":2048}
+{"idx":224527,"func":"Status Conv3DShape(shape_inference::InferenceContext* c) {\n  ShapeHandle input_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 5, &input_shape));\n  ShapeHandle filter_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 5, &filter_shape));\n\n  string data_format;\n  Status s = c->GetAttr(\"data_format\", &data_format);\n\n  std::vector<int32> dilations;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"dilations\", &dilations));\n\n  if (dilations.size() != 5) {\n    return errors::InvalidArgument(\n        \"Conv3D requires the dilation attribute to contain 5 values, but got: \",\n        dilations.size());\n  }\n\n  std::vector<int32> strides;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"strides\", &strides));\n  if (strides.size() != 5) {\n    return errors::InvalidArgument(\n        \"Conv3D requires the stride attribute to contain 5 values, but got: \",\n        strides.size());\n  }\n\n  int32_t stride_planes, stride_rows, stride_cols;\n  int32_t dilation_planes, dilation_rows, dilation_cols;\n  if (s.ok() && data_format == \"NCDHW\") {\n    \/\/ Convert input_shape to NDHWC.\n    auto dim = [&](char dimension) {\n      return c->Dim(input_shape, GetTensorDimIndex<3>(FORMAT_NCHW, dimension));\n    };\n    input_shape =\n        c->MakeShape({{dim('N'), dim('0'), dim('1'), dim('2'), dim('C')}});\n    stride_planes = strides[2];\n    stride_rows = strides[3];\n    stride_cols = strides[4];\n    dilation_planes = dilations[2];\n    dilation_cols = dilations[3];\n    dilation_rows = dilations[4];\n  } else {\n    stride_planes = strides[1];\n    stride_rows = strides[2];\n    stride_cols = strides[3];\n    dilation_planes = dilations[1];\n    dilation_cols = dilations[2];\n    dilation_rows = dilations[3];\n  }\n\n  DimensionHandle batch_size_dim = c->Dim(input_shape, 0);\n  DimensionHandle in_planes_dim = c->Dim(input_shape, 1);\n  DimensionHandle in_rows_dim = c->Dim(input_shape, 2);\n  DimensionHandle in_cols_dim = c->Dim(input_shape, 3);\n  DimensionHandle input_depth_dim = c->Dim(input_shape, 4);\n\n  DimensionHandle filter_planes_dim = c->Dim(filter_shape, 0);\n  DimensionHandle filter_rows_dim = c->Dim(filter_shape, 1);\n  DimensionHandle filter_cols_dim = c->Dim(filter_shape, 2);\n  DimensionHandle filter_input_depth_dim = c->Dim(filter_shape, 3);\n  DimensionHandle output_depth_dim = c->Dim(filter_shape, 4);\n\n  \/\/ Check that the input tensor and the filter tensor agree on the channel\n  \/\/ count.\n  if (c->ValueKnown(input_depth_dim) && c->ValueKnown(filter_input_depth_dim)) {\n    int64_t input_depth_value = c->Value(input_depth_dim),\n            filter_input_depth_value = c->Value(filter_input_depth_dim);\n    if (filter_input_depth_value == 0)\n      return errors::InvalidArgument(\"Depth of filter must not be 0\");\n    if (input_depth_value % filter_input_depth_value != 0)\n      return errors::InvalidArgument(\n          \"Depth of input (\", input_depth_value,\n          \") is not a multiple of input depth of filter (\",\n          filter_input_depth_value, \")\");\n    if (input_depth_value != filter_input_depth_value) {\n      int64_t num_groups = input_depth_value \/ filter_input_depth_value;\n      if (c->ValueKnown(output_depth_dim)) {\n        int64_t output_depth_value = c->Value(output_depth_dim);\n        if (num_groups == 0)\n          return errors::InvalidArgument(\"Number of groups must not be 0\");\n        if (output_depth_value % num_groups != 0)\n          return errors::InvalidArgument(\n              \"Depth of output (\", output_depth_value,\n              \") is not a multiple of the number of groups (\", num_groups, \")\");\n      }\n    }\n  }\n\n  Padding padding;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"padding\", &padding));\n  DimensionHandle output_planes, output_rows, output_cols;\n\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n      c, in_planes_dim, filter_planes_dim, dilation_planes, stride_planes,\n      padding, -1, -1, &output_planes));\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n      c, in_rows_dim, filter_rows_dim, dilation_rows, stride_rows, padding, -1,\n      -1, &output_rows));\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDimsV2(\n      c, in_cols_dim, filter_cols_dim, dilation_cols, stride_cols, padding, -1,\n      -1, &output_cols));\n\n  ShapeHandle output_shape;\n  if (data_format == \"NCDHW\") {\n    output_shape = c->MakeShape({batch_size_dim, output_depth_dim,\n                                 output_planes, output_rows, output_cols});\n  } else {\n    output_shape = c->MakeShape({batch_size_dim, output_planes, output_rows,\n                                 output_cols, output_depth_dim});\n  }\n  c->set_output(0, output_shape);\n  return Status::OK();\n}","target":0,"code_token_length":1179,"total_token_length":1415,"max_tokens_setting":2048}
+{"idx":211126,"func":"static MOBI_RET mobi_parse_index_entry(MOBIIndx *indx, const MOBIIdxt idxt, const MOBITagx *tagx, const MOBIOrdt *ordt, MOBIBuffer *buf, const size_t curr_number) {\n    if (indx == NULL) {\n        debug_print(\"%s\", \"INDX structure not initialized\\n\");\n        return MOBI_INIT_FAILED;\n    }\n    const size_t entry_offset = indx->entries_count;\n    const size_t entry_length = idxt.offsets[curr_number + 1] - idxt.offsets[curr_number];\n    mobi_buffer_setpos(buf, idxt.offsets[curr_number]);\n    size_t entry_number = curr_number + entry_offset;\n    if (entry_number >= indx->total_entries_count) {\n        debug_print(\"Entry number beyond array: %zu\\n\", entry_number);\n        return MOBI_DATA_CORRUPT;\n    }\n    \/* save original record maxlen *\/\n    const size_t buf_maxlen = buf->maxlen;\n    if (buf->offset + entry_length >= buf_maxlen) {\n        debug_print(\"Entry length too long: %zu\\n\", entry_length);\n        return MOBI_DATA_CORRUPT;\n    }\n    buf->maxlen = buf->offset + entry_length;\n    size_t label_length = mobi_buffer_get8(buf);\n    if (label_length > entry_length) {\n        debug_print(\"Label length too long: %zu\\n\", label_length);\n        return MOBI_DATA_CORRUPT;\n    }\n    char text[INDX_LABEL_SIZEMAX];\n    \/* FIXME: what is ORDT1 for? *\/\n    if (ordt->ordt2) {\n        label_length = mobi_getstring_ordt(ordt, buf, (unsigned char*) text, label_length);\n    } else {\n        label_length = mobi_indx_get_label((unsigned char*) text, buf, label_length, indx->ligt_entries_count);\n    }\n    indx->entries[entry_number].label = malloc(label_length + 1);\n    if (indx->entries[entry_number].label == NULL) {\n        debug_print(\"Memory allocation failed (%zu bytes)\\n\", label_length);\n        return MOBI_MALLOC_FAILED;\n    }\n    strncpy(indx->entries[entry_number].label, text, label_length + 1);\n    \/\/debug_print(\"tag label[%zu]: %s\\n\", entry_number, indx->entries[entry_number].label);\n    unsigned char *control_bytes;\n    control_bytes = buf->data + buf->offset;\n    mobi_buffer_seek(buf, (int) tagx->control_byte_count);\n    indx->entries[entry_number].tags_count = 0;\n    indx->entries[entry_number].tags = NULL;\n    if (tagx->tags_count > 0) {\n        typedef struct {\n            uint8_t tag;\n            uint8_t tag_value_count;\n            uint32_t value_count;\n            uint32_t value_bytes;\n        } MOBIPtagx;\n        MOBIPtagx *ptagx = malloc(tagx->tags_count * sizeof(MOBIPtagx));\n        if (ptagx == NULL) {\n            debug_print(\"Memory allocation failed (%zu bytes)\\n\", tagx->tags_count * sizeof(MOBIPtagx));\n            return MOBI_MALLOC_FAILED;\n        }\n        uint32_t ptagx_count = 0;\n        size_t len;\n        size_t i = 0;\n        while (i < tagx->tags_count) {\n            if (tagx->tags[i].control_byte == 1) {\n                control_bytes++;\n                i++;\n                continue;\n            }\n            uint32_t value = control_bytes[0] & tagx->tags[i].bitmask;\n            if (value != 0) {\n                \/* FIXME: is it safe to use MOBI_NOTSET? *\/\n                uint32_t value_count = MOBI_NOTSET;\n                uint32_t value_bytes = MOBI_NOTSET;\n                \/* all bits of masked value are set *\/\n                if (value == tagx->tags[i].bitmask) {\n                    \/* more than 1 bit set *\/\n                    if (mobi_bitcount(tagx->tags[i].bitmask) > 1) {\n                        \/* read value bytes from entry *\/\n                        len = 0;\n                        value_bytes = mobi_buffer_get_varlen(buf, &len);\n                    } else {\n                        value_count = 1;\n                    }\n                } else {\n                    uint8_t mask = tagx->tags[i].bitmask;\n                    while ((mask & 1) == 0) {\n                        mask >>= 1;\n                        value >>= 1;\n                    }\n                    value_count = value;\n                }\n                ptagx[ptagx_count].tag = tagx->tags[i].tag;\n                ptagx[ptagx_count].tag_value_count = tagx->tags[i].values_count;\n                ptagx[ptagx_count].value_count = value_count;\n                ptagx[ptagx_count].value_bytes = value_bytes;\n                ptagx_count++;\n            }\n            i++;\n        }\n        indx->entries[entry_number].tags = malloc(tagx->tags_count * sizeof(MOBIIndexTag));\n        if (indx->entries[entry_number].tags == NULL) {\n            debug_print(\"Memory allocation failed (%zu bytes)\\n\", tagx->tags_count * sizeof(MOBIIndexTag));\n            free(ptagx);\n            return MOBI_MALLOC_FAILED;\n        }\n        i = 0;\n        while (i < ptagx_count) {\n            uint32_t tagvalues_count = 0;\n            \/* FIXME: is it safe to use MOBI_NOTSET? *\/\n            \/* value count is set *\/\n            uint32_t tagvalues[INDX_TAGVALUES_MAX];\n            if (ptagx[i].value_count != MOBI_NOTSET) {\n                size_t count = ptagx[i].value_count * ptagx[i].tag_value_count;\n                while (count-- && tagvalues_count < INDX_TAGVALUES_MAX) {\n                    len = 0;\n                    const uint32_t value_bytes = mobi_buffer_get_varlen(buf, &len);\n                    tagvalues[tagvalues_count++] = value_bytes;\n                }\n            \/* value count is not set *\/\n            } else {\n                \/* read value_bytes bytes *\/\n                len = 0;\n                while (len < ptagx[i].value_bytes && tagvalues_count < INDX_TAGVALUES_MAX) {\n                    const uint32_t value_bytes = mobi_buffer_get_varlen(buf, &len);\n                    tagvalues[tagvalues_count++] = value_bytes;\n                }\n            }\n            if (tagvalues_count) {\n                const size_t arr_size = tagvalues_count * sizeof(*indx->entries[entry_number].tags[i].tagvalues);\n                indx->entries[entry_number].tags[i].tagvalues = malloc(arr_size);\n                if (indx->entries[entry_number].tags[i].tagvalues == NULL) {\n                    debug_print(\"Memory allocation failed (%zu bytes)\\n\", arr_size);\n                    free(ptagx);\n                    return MOBI_MALLOC_FAILED;\n                }\n                memcpy(indx->entries[entry_number].tags[i].tagvalues, tagvalues, arr_size);\n            } else {\n                indx->entries[entry_number].tags[i].tagvalues = NULL;\n            }\n            indx->entries[entry_number].tags[i].tagid = ptagx[i].tag;\n            indx->entries[entry_number].tags[i].tagvalues_count = tagvalues_count;\n            indx->entries[entry_number].tags_count++;\n            i++;\n        }\n        free(ptagx);\n    }\n    \/* restore buffer maxlen *\/\n    buf->maxlen = buf_maxlen;\n    return MOBI_SUCCESS;\n}","target":1,"code_token_length":1632,"total_token_length":1868,"max_tokens_setting":2048}
+{"idx":210223,"func":"void vrend_renderer_blit(struct vrend_context *ctx,\n                         uint32_t dst_handle, uint32_t src_handle,\n                         const struct pipe_blit_info *info)\n{\n   struct vrend_resource *src_res, *dst_res;\n   src_res = vrend_renderer_ctx_res_lookup(ctx, src_handle);\n   dst_res = vrend_renderer_ctx_res_lookup(ctx, dst_handle);\n\n   if (!src_res) {\n      report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle);\n      return;\n   }\n   if (!dst_res) {\n      report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle);\n      return;\n   }\n\n   if (ctx->in_error)\n      return;\n\n   if (info->render_condition_enable == false)\n      vrend_pause_render_condition(ctx, true);\n\n   VREND_DEBUG(dbg_blit, ctx, \"BLIT: rc:%d scissor:%d filter:%d alpha:%d mask:0x%x\\n\"\n                                   \"  From %s(%s) ms:%d [%d, %d, %d]+[%d, %d, %d] lvl:%d\\n\"\n                                   \"  To   %s(%s) ms:%d [%d, %d, %d]+[%d, %d, %d] lvl:%d\\n\",\n                                   info->render_condition_enable, info->scissor_enable,\n                                   info->filter, info->alpha_blend, info->mask,\n                                   util_format_name(src_res->base.format),\n                                   util_format_name(info->src.format),\n                                   src_res->base.nr_samples,\n                                   info->src.box.x, info->src.box.y, info->src.box.z,\n                                   info->src.box.width, info->src.box.height, info->src.box.depth,\n                                   info->src.level,\n                                   util_format_name(dst_res->base.format),\n                                   util_format_name(info->dst.format),\n                                   dst_res->base.nr_samples,\n                                   info->dst.box.x, info->dst.box.y, info->dst.box.z,\n                                   info->dst.box.width, info->dst.box.height, info->dst.box.depth,\n                                   info->dst.level);\n\n   \/* The Gallium blit function can be called for a general blit that may\n    * scale, convert the data, and apply some rander states, or it is called via\n    * glCopyImageSubData. If the src or the dst image are equal, or the two\n    * images formats are the same, then Galliums such calles are redirected\n    * to resource_copy_region, in this case and if no render states etx need\n    * to be applied, forward the call to glCopyImageSubData, otherwise do a\n    * normal blit. *\/\n   if (has_feature(feat_copy_image) &&\n       (!info->render_condition_enable || !ctx->sub->cond_render_gl_mode) &&\n       format_is_copy_compatible(info->src.format,info->dst.format, false) &&\n       !info->scissor_enable && (info->filter == PIPE_TEX_FILTER_NEAREST) &&\n       !info->alpha_blend && (info->mask == PIPE_MASK_RGBA) &&\n       src_res->base.nr_samples == dst_res->base.nr_samples &&\n       info->src.box.width == info->dst.box.width &&\n       info->src.box.height == info->dst.box.height &&\n       info->src.box.depth == info->dst.box.depth) {\n      VREND_DEBUG(dbg_blit, ctx,  \"  Use glCopyImageSubData\\n\");\n      vrend_copy_sub_image(src_res, dst_res, info->src.level, &info->src.box,\n                           info->dst.level, info->dst.box.x, info->dst.box.y,\n                           info->dst.box.z);\n   } else {\n      VREND_DEBUG(dbg_blit, ctx, \"  Use blit_int\\n\");\n      vrend_renderer_blit_int(ctx, src_res, dst_res, info);\n   }\n\n   if (info->render_condition_enable == false)\n      vrend_pause_render_condition(ctx, false);\n}","target":1,"code_token_length":850,"total_token_length":1086,"max_tokens_setting":2048}
+{"idx":384803,"func":"unix_expandpath(\n    garray_T\t*gap,\n    char_u\t*path,\n    int\t\twildoff,\n    int\t\tflags,\t\t\/\/ EW_* flags\n    int\t\tdidstar)\t\/\/ expanded \"**\" once already\n{\n    char_u\t*buf;\n    char_u\t*path_end;\n    char_u\t*p, *s, *e;\n    int\t\tstart_len = gap->ga_len;\n    char_u\t*pat;\n    regmatch_T\tregmatch;\n    int\t\tstarts_with_dot;\n    int\t\tmatches;\n    int\t\tlen;\n    int\t\tstarstar = FALSE;\n    static int\tstardepth = 0;\t    \/\/ depth for \"**\" expansion\n\n    DIR\t\t*dirp;\n    struct dirent *dp;\n\n    \/\/ Expanding \"**\" may take a long time, check for CTRL-C.\n    if (stardepth > 0)\n    {\n\tui_breakcheck();\n\tif (got_int)\n\t    return 0;\n    }\n\n    \/\/ make room for file name\n    buf = alloc(STRLEN(path) + BASENAMELEN + 5);\n    if (buf == NULL)\n\treturn 0;\n\n    \/*\n     * Find the first part in the path name that contains a wildcard.\n     * When EW_ICASE is set every letter is considered to be a wildcard.\n     * Copy it into \"buf\", including the preceding characters.\n     *\/\n    p = buf;\n    s = buf;\n    e = NULL;\n    path_end = path;\n    while (*path_end != NUL)\n    {\n\t\/\/ May ignore a wildcard that has a backslash before it; it will\n\t\/\/ be removed by rem_backslash() or file_pat_to_reg_pat() below.\n\tif (path_end >= path + wildoff && rem_backslash(path_end))\n\t    *p++ = *path_end++;\n\telse if (*path_end == '\/')\n\t{\n\t    if (e != NULL)\n\t\tbreak;\n\t    s = p + 1;\n\t}\n\telse if (path_end >= path + wildoff\n\t\t\t && (vim_strchr((char_u *)\"*?[{~$\", *path_end) != NULL\n\t\t\t     || (!p_fic && (flags & EW_ICASE)\n\t\t\t\t\t  && vim_isalpha(PTR2CHAR(path_end)))))\n\t    e = p;\n\tif (has_mbyte)\n\t{\n\t    len = (*mb_ptr2len)(path_end);\n\t    STRNCPY(p, path_end, len);\n\t    p += len;\n\t    path_end += len;\n\t}\n\telse\n\t    *p++ = *path_end++;\n    }\n    e = p;\n    *e = NUL;\n\n    \/\/ Now we have one wildcard component between \"s\" and \"e\".\n    \/\/ Remove backslashes between \"wildoff\" and the start of the wildcard\n    \/\/ component.\n    for (p = buf + wildoff; p < s; ++p)\n\tif (rem_backslash(p))\n\t{\n\t    STRMOVE(p, p + 1);\n\t    --e;\n\t    --s;\n\t}\n\n    \/\/ Check for \"**\" between \"s\" and \"e\".\n    for (p = s; p < e; ++p)\n\tif (p[0] == '*' && p[1] == '*')\n\t    starstar = TRUE;\n\n    \/\/ convert the file pattern to a regexp pattern\n    starts_with_dot = *s == '.';\n    pat = file_pat_to_reg_pat(s, e, NULL, FALSE);\n    if (pat == NULL)\n    {\n\tvim_free(buf);\n\treturn 0;\n    }\n\n    \/\/ compile the regexp into a program\n    if (flags & EW_ICASE)\n\tregmatch.rm_ic = TRUE;\t\t\/\/ 'wildignorecase' set\n    else\n\tregmatch.rm_ic = p_fic;\t\/\/ ignore case when 'fileignorecase' is set\n    if (flags & (EW_NOERROR | EW_NOTWILD))\n\t++emsg_silent;\n    regmatch.regprog = vim_regcomp(pat, RE_MAGIC);\n    if (flags & (EW_NOERROR | EW_NOTWILD))\n\t--emsg_silent;\n    vim_free(pat);\n\n    if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0)\n    {\n\tvim_free(buf);\n\treturn 0;\n    }\n\n    \/\/ If \"**\" is by itself, this is the first time we encounter it and more\n    \/\/ is following then find matches without any directory.\n    if (!didstar && stardepth < 100 && starstar && e - s == 2\n\t\t\t\t\t\t\t  && *path_end == '\/')\n    {\n\tSTRCPY(s, path_end + 1);\n\t++stardepth;\n\t(void)unix_expandpath(gap, buf, (int)(s - buf), flags, TRUE);\n\t--stardepth;\n    }\n\n    \/\/ open the directory for scanning\n    *s = NUL;\n    dirp = opendir(*buf == NUL ? \".\" : (char *)buf);\n\n    \/\/ Find all matching entries\n    if (dirp != NULL)\n    {\n\tfor (;;)\n\t{\n\t    dp = readdir(dirp);\n\t    if (dp == NULL)\n\t\tbreak;\n\t    if ((dp->d_name[0] != '.' || starts_with_dot\n\t\t\t|| ((flags & EW_DODOT)\n\t\t\t    && dp->d_name[1] != NUL\n\t\t\t    && (dp->d_name[1] != '.' || dp->d_name[2] != NUL)))\n\t\t && ((regmatch.regprog != NULL && vim_regexec(®match,\n\t\t\t\t\t     (char_u *)dp->d_name, (colnr_T)0))\n\t\t   || ((flags & EW_NOTWILD)\n\t\t     && fnamencmp(path + (s - buf), dp->d_name, e - s) == 0)))\n\t    {\n\t\tSTRCPY(s, dp->d_name);\n\t\tlen = STRLEN(buf);\n\n\t\tif (starstar && stardepth < 100)\n\t\t{\n\t\t    \/\/ For \"**\" in the pattern first go deeper in the tree to\n\t\t    \/\/ find matches.\n\t\t    STRCPY(buf + len, \"\/**\");\n\t\t    STRCPY(buf + len + 3, path_end);\n\t\t    ++stardepth;\n\t\t    (void)unix_expandpath(gap, buf, len + 1, flags, TRUE);\n\t\t    --stardepth;\n\t\t}\n\n\t\tSTRCPY(buf + len, path_end);\n\t\tif (mch_has_exp_wildcard(path_end)) \/\/ handle more wildcards\n\t\t{\n\t\t    \/\/ need to expand another component of the path\n\t\t    \/\/ remove backslashes for the remaining components only\n\t\t    (void)unix_expandpath(gap, buf, len + 1, flags, FALSE);\n\t\t}\n\t\telse\n\t\t{\n\t\t    stat_T  sb;\n\n\t\t    \/\/ no more wildcards, check if there is a match\n\t\t    \/\/ remove backslashes for the remaining components only\n\t\t    if (*path_end != NUL)\n\t\t\tbackslash_halve(buf + len + 1);\n\t\t    \/\/ add existing file or symbolic link\n\t\t    if ((flags & EW_ALLLINKS) ? mch_lstat((char *)buf, &sb) >= 0\n\t\t\t\t\t\t      : mch_getperm(buf) >= 0)\n\t\t    {\n#ifdef MACOS_CONVERT\n\t\t\tsize_t precomp_len = STRLEN(buf)+1;\n\t\t\tchar_u *precomp_buf =\n\t\t\t    mac_precompose_path(buf, precomp_len, &precomp_len);\n\n\t\t\tif (precomp_buf)\n\t\t\t{\n\t\t\t    mch_memmove(buf, precomp_buf, precomp_len);\n\t\t\t    vim_free(precomp_buf);\n\t\t\t}\n#endif\n\t\t\taddfile(gap, buf, flags);\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n\tclosedir(dirp);\n    }\n\n    vim_free(buf);\n    vim_regfree(regmatch.regprog);\n\n    matches = gap->ga_len - start_len;\n    if (matches > 0)\n\tqsort(((char_u **)gap->ga_data) + start_len, matches,\n\t\t\t\t\t\t   sizeof(char_u *), pstrcmp);\n    return matches;\n}","target":0,"code_token_length":1691,"total_token_length":1927,"max_tokens_setting":2048}
+{"idx":212857,"func":"qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)\n{\n    linenr_T\tlnum;\n    qfline_T\t*qfp;\n    int\t\told_KeyTyped = KeyTyped;\n    list_T\t*qftf_list = NULL;\n    listitem_T\t*qftf_li = NULL;\n\n    if (old_last == NULL)\n    {\n\tif (buf != curbuf)\n\t{\n\t    internal_error(\"qf_fill_buffer()\");\n\t    return;\n\t}\n\n\t\/\/ delete all existing lines\n\twhile ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0)\n\t    (void)ml_delete((linenr_T)1);\n    }\n\n    \/\/ Check if there is anything to display\n    if (qfl != NULL)\n    {\n\tchar_u\t\tdirname[MAXPATHL];\n\tint\t\tinvalid_val = FALSE;\n\tint\t\tprev_bufnr = -1;\n\n\t*dirname = NUL;\n\n\t\/\/ Add one line for each error\n\tif (old_last == NULL)\n\t{\n\t    qfp = qfl->qf_start;\n\t    lnum = 0;\n\t}\n\telse\n\t{\n\t    if (old_last->qf_next != NULL)\n\t\tqfp = old_last->qf_next;\n\t    else\n\t\tqfp = old_last;\n\t    lnum = buf->b_ml.ml_line_count;\n\t}\n\n\tqftf_list = call_qftf_func(qfl, qf_winid, (long)(lnum + 1),\n\t\t\t\t\t\t\t(long)qfl->qf_count);\n\tif (qftf_list != NULL)\n\t    qftf_li = qftf_list->lv_first;\n\n\twhile (lnum < qfl->qf_count)\n\t{\n\t    char_u\t*qftf_str = NULL;\n\n\t    \/\/ Use the text supplied by the user defined function (if any).\n\t    \/\/ If the returned value is not string, then ignore the rest\n\t    \/\/ of the returned values and use the default.\n\t    if (qftf_li != NULL && !invalid_val)\n\t    {\n\t\tqftf_str = tv_get_string_chk(&qftf_li->li_tv);\n\t\tif (qftf_str == NULL)\n\t\t    invalid_val = TRUE;\n\t    }\n\n\t    if (qf_buf_add_line(buf, lnum, qfp, dirname,\n\t\t\tprev_bufnr != qfp->qf_fnum, qftf_str) == FAIL)\n\t\tbreak;\n\n\t    prev_bufnr = qfp->qf_fnum;\n\t    ++lnum;\n\t    qfp = qfp->qf_next;\n\t    if (qfp == NULL)\n\t\tbreak;\n\n\t    if (qftf_li != NULL)\n\t\tqftf_li = qftf_li->li_next;\n\t}\n\n\tif (old_last == NULL)\n\t    \/\/ Delete the empty line which is now at the end\n\t    (void)ml_delete(lnum + 1);\n    }\n\n    \/\/ correct cursor position\n    check_lnums(TRUE);\n\n    if (old_last == NULL)\n    {\n\t\/\/ Set the 'filetype' to \"qf\" each time after filling the buffer.\n\t\/\/ This resembles reading a file into a buffer, it's more logical when\n\t\/\/ using autocommands.\n\t++curbuf_lock;\n\tset_option_value_give_err((char_u *)\"ft\",\n\t\t\t\t\t\t0L, (char_u *)\"qf\", OPT_LOCAL);\n\tcurbuf->b_p_ma = FALSE;\n\n\tkeep_filetype = TRUE;\t\t\/\/ don't detect 'filetype'\n\tapply_autocmds(EVENT_BUFREADPOST, (char_u *)\"quickfix\", NULL,\n\t\t\t\t\t\t\t       FALSE, curbuf);\n\tapply_autocmds(EVENT_BUFWINENTER, (char_u *)\"quickfix\", NULL,\n\t\t\t\t\t\t\t       FALSE, curbuf);\n\tkeep_filetype = FALSE;\n\t--curbuf_lock;\n\n\t\/\/ make sure it will be redrawn\n\tredraw_curbuf_later(UPD_NOT_VALID);\n    }\n\n    \/\/ Restore KeyTyped, setting 'filetype' may reset it.\n    KeyTyped = old_KeyTyped;\n}","target":1,"code_token_length":862,"total_token_length":1098,"max_tokens_setting":2048}
+{"idx":237823,"func":"static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer)\n{\n    int result = 0;\n    bitbuffer_invert(bitbuffer);\n\n    \/\/ This sensor repeats a signal three times. Combine as fallback.\n    uint8_t *b_rows[3] = {0};\n    int n_rows         = 0;\n    for (int row = 0; row < bitbuffer->num_rows; ++row) {\n        if (n_rows < 3 && bitbuffer->bits_per_row[row] == 88) {\n            b_rows[n_rows] = bitbuffer->bb[row];\n            n_rows++;\n        }\n    }\n\n    \/\/ Combine signal if exactly three repeats were found\n    if (n_rows == 3) {\n        bitbuffer_add_row(bitbuffer);\n        uint8_t *b = bitbuffer->bb[bitbuffer->num_rows - 1];\n        for (int i = 0; i < 11; ++i) {\n            \/\/ The majority bit count wins\n            b[i] = (b_rows[0][i] & b_rows[1][i]) |\n                    (b_rows[1][i] & b_rows[2][i]) |\n                    (b_rows[2][i] & b_rows[0][i]);\n        }\n        bitbuffer->bits_per_row[bitbuffer->num_rows - 1] = 88;\n    }\n\n    \/\/ Output the first valid row\n    for (int row = 0; row < bitbuffer->num_rows; ++row) {\n        if (bitbuffer->bits_per_row[row] != 88) {\n            result = DECODE_ABORT_LENGTH;\n            continue; \/\/ return DECODE_ABORT_LENGTH;\n        }\n        uint8_t *b = bitbuffer->bb[row];\n\n        \/\/ Check CRC\n        if (crc16lsb(b, 11, 0x00b2, 0x00d0) != 0) {\n            decoder_log_bitrow(decoder, 1, __func__, b, 11 * 8, \"sensor bad CRC\");\n            result = DECODE_FAIL_MIC;\n            continue; \/\/ return DECODE_FAIL_MIC;\n        }\n\n        \/\/  Decode common fields\n        int id          = (b[0] << 16) | (b[1] << 8) | b[3];\n        int battery_low = (b[2] & 0x40) == 0;\n        int model_flag  = (b[2] & 1);\n        float tempc     = ((b[4] << 4) | (b[5] >> 4)) * 0.1 - 100;\n        int probe       = b[5] & 3;\n        int humidity    = ((b[6] & 0x1f) << 2) | (b[7] >> 6);\n\n        \/\/  Water probe (detects water leak)\n        int water = (b[7] & 0x0f) == 15; \/\/ valid only if (probe == 1)\n        \/\/  Soil probe (detects temperature)\n        float ptempc = (((b[7] & 0x0f) << 8) | b[8]) * 0.1 - 100; \/\/ valid only if (probe == 2 || probe == 3)\n        \/\/  Spot probe (detects temperature and humidity)\n        int phumidity = b[9] & 0x7f; \/\/ valid only if (probe == 3)\n\n        \/* clang-format off *\/\n        data_t *data = data_make(\n                \"model\",            \"\",             DATA_STRING,    model_flag ? \"Acurite-00275rm\" : \"Acurite-00276rm\",\n                \"subtype\",          \"Probe\",        DATA_INT,       probe,\n                \"id\",               \"\",             DATA_INT,       id,\n                \"battery_ok\",       \"Battery\",      DATA_INT,       !battery_low,\n                \"temperature_C\",    \"Celsius\",      DATA_FORMAT,    \"%.1f C\",  DATA_DOUBLE, tempc,\n                \"humidity\",         \"Humidity\",     DATA_FORMAT,    \"%u %%\", DATA_INT,      humidity,\n                \"water\",            \"\",             DATA_COND, probe == 1, DATA_INT,        water,\n                \"temperature_1_C\",  \"Celsius\",      DATA_COND, probe == 2, DATA_FORMAT, \"%.1f C\",   DATA_DOUBLE, ptempc,\n                \"temperature_1_C\",  \"Celsius\",      DATA_COND, probe == 3, DATA_FORMAT, \"%.1f C\",   DATA_DOUBLE, ptempc,\n                \"humidity_1\",       \"Humidity\",     DATA_COND, probe == 3, DATA_FORMAT, \"%u %%\",    DATA_INT,    phumidity,\n                \"mic\",              \"Integrity\",    DATA_STRING,    \"CRC\",\n                NULL);\n        \/* clang-format on *\/\n\n        decoder_output_data(decoder, data);\n\n        return 1;\n    }\n    \/\/ Only returns the latest result, but better than nothing.\n    return result;\n}","target":0,"code_token_length":1107,"total_token_length":1343,"max_tokens_setting":2048}
+{"idx":217563,"func":"MagickExport const char *GetImageProperty(const Image *image,\n  const char *property)\n{\n  double\n    alpha;\n\n  ExceptionInfo\n    *exception;\n\n  FxInfo\n    *fx_info;\n\n  MagickStatusType\n    status;\n\n  const char\n    *p;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  p=(const char *) NULL;\n  if (image->properties != (void *) NULL)\n    {\n      if (property == (const char *) NULL)\n        {\n          ResetSplayTreeIterator((SplayTreeInfo *) image->properties);\n          p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)\n            image->properties);\n          return(p);\n        }\n      if (LocaleNCompare(\"fx:\",property,3) != 0) \/* NOT fx: !!!! *\/\n        {\n          p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)\n            image->properties,property);\n          if (p != (const char *) NULL)\n            return(p);\n        }\n    }\n  if ((property == (const char *) NULL) ||\n      (strchr(property,':') == (char *) NULL))\n    return(p);\n  exception=(&((Image *) image)->exception);\n  switch (*property)\n  {\n    case '8':\n    {\n      if (LocaleNCompare(\"8bim:\",property,5) == 0)\n        {\n          (void) Get8BIMProperty(image,property);\n          break;\n        }\n      break;\n    }\n    case 'E':\n    case 'e':\n    {\n      if (LocaleNCompare(\"exif:\",property,5) == 0)\n        {\n          (void) GetEXIFProperty(image,property);\n          break;\n        }\n      break;\n    }\n    case 'F':\n    case 'f':\n    {\n      if (LocaleNCompare(\"fx:\",property,3) == 0)\n        {\n          if ((image->columns == 0) || (image->rows == 0))\n            break;\n          fx_info=AcquireFxInfo(image,property+3);\n          status=FxEvaluateChannelExpression(fx_info,DefaultChannels,0,0,&alpha,\n            exception);\n          fx_info=DestroyFxInfo(fx_info);\n          if (status != MagickFalse)\n            {\n              char\n                value[MaxTextExtent];\n\n              (void) FormatLocaleString(value,MaxTextExtent,\"%.*g\",\n                GetMagickPrecision(),(double) alpha);\n              (void) SetImageProperty((Image *) image,property,value);\n            }\n          break;\n        }\n      break;\n    }\n    case 'H':\n    case 'h':\n    {\n      if (LocaleNCompare(\"hex:\",property,4) == 0)\n        {\n          MagickPixelPacket\n            pixel;\n\n          if ((image->columns == 0) || (image->rows == 0))\n            break;\n          GetMagickPixelPacket(image,&pixel);\n          fx_info=AcquireFxInfo(image,property+4);\n          status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,\n            exception);\n          pixel.red=(MagickRealType) QuantumRange*alpha;\n          status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,\n            exception);\n          pixel.green=(MagickRealType) QuantumRange*alpha;\n          status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,\n            exception);\n          pixel.blue=(MagickRealType) QuantumRange*alpha;\n          status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,\n            exception);\n          pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);\n          if (image->colorspace == CMYKColorspace)\n            {\n              status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,\n                &alpha,exception);\n              pixel.index=(MagickRealType) QuantumRange*alpha;\n            }\n          fx_info=DestroyFxInfo(fx_info);\n          if (status != MagickFalse)\n            {\n              char\n                hex[MaxTextExtent];\n\n              GetColorTuple(&pixel,MagickTrue,hex);\n              (void) SetImageProperty((Image *) image,property,hex+1);\n            }\n          break;\n        }\n      break;\n    }\n    case 'I':\n    case 'i':\n    {\n      if ((LocaleNCompare(\"icc:\",property,4) == 0) ||\n          (LocaleNCompare(\"icm:\",property,4) == 0))\n        {\n          (void) GetICCProperty(image,property);\n          break;\n        }\n      if (LocaleNCompare(\"iptc:\",property,5) == 0)\n        {\n          (void) GetIPTCProperty(image,property);\n          break;\n        }\n      break;\n    }\n    case 'P':\n    case 'p':\n    {\n      if (LocaleNCompare(\"pixel:\",property,6) == 0)\n        {\n          MagickPixelPacket\n            pixel;\n\n          GetMagickPixelPacket(image,&pixel);\n          fx_info=AcquireFxInfo(image,property+6);\n          status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,\n            exception);\n          pixel.red=(MagickRealType) QuantumRange*alpha;\n          status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,\n            exception);\n          pixel.green=(MagickRealType) QuantumRange*alpha;\n          status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,\n            exception);\n          pixel.blue=(MagickRealType) QuantumRange*alpha;\n          status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,\n            exception);\n          pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);\n          if (image->colorspace == CMYKColorspace)\n            {\n              status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,\n                &alpha,exception);\n              pixel.index=(MagickRealType) QuantumRange*alpha;\n            }\n          fx_info=DestroyFxInfo(fx_info);\n          if (status != MagickFalse)\n            {\n              char\n                name[MaxTextExtent];\n\n              const char\n                *value;\n\n              GetColorTuple(&pixel,MagickFalse,name);\n              value=GetImageArtifact(image,\"pixel:compliance\");\n              if (value != (char *) NULL)\n                {\n                  ComplianceType compliance=(ComplianceType) ParseCommandOption(\n                    MagickComplianceOptions,MagickFalse,value);\n                  (void) QueryMagickColorname(image,&pixel,compliance,name,\n                    exception);\n                }\n              (void) SetImageProperty((Image *) image,property,name);\n            }\n          break;\n        }\n      break;\n    }\n    case 'X':\n    case 'x':\n    {\n      if (LocaleNCompare(\"xmp:\",property,4) == 0)\n        {\n          (void) GetXMPProperty(image,property);\n          break;\n        }\n      break;\n    }\n    default:\n      break;\n  }\n  if (image->properties != (void *) NULL)\n    {\n      p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)\n        image->properties,property);\n      return(p);\n    }\n  return((const char *) NULL);\n}","target":0,"code_token_length":1616,"total_token_length":1852,"max_tokens_setting":2048}
+{"idx":279940,"func":"do_shell(\n    char_u\t*cmd,\n    int\t\tflags)\t\/\/ may be SHELL_DOOUT when output is redirected\n{\n    buf_T\t*buf;\n#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)\n    int\t\tsave_nwr;\n#endif\n#ifdef MSWIN\n    int\t\twinstart = FALSE;\n#endif\n    int\t\tkeep_termcap = !termcap_active;\n\n    \/*\n     * Disallow shell commands for \"rvim\".\n     * Disallow shell commands from .exrc and .vimrc in current directory for\n     * security reasons.\n     *\/\n    if (check_restricted() || check_secure())\n    {\n\tmsg_end();\n\treturn;\n    }\n\n#ifdef MSWIN\n    \/*\n     * Check if \":!start\" is used.  This implies not stopping termcap mode.\n     *\/\n    if (cmd != NULL)\n\tkeep_termcap = winstart = (STRNICMP(cmd, \"start \", 6) == 0);\n\n# if defined(FEAT_GUI) && defined(FEAT_TERMINAL)\n    \/\/ Don't stop termcap mode when using a terminal window for the shell.\n    if (gui.in_use && vim_strchr(p_go, GO_TERMINAL) != NULL)\n\tkeep_termcap = TRUE;\n# endif\n#endif\n\n    \/*\n     * For autocommands we want to get the output on the current screen, to\n     * avoid having to type return below.\n     *\/\n    msg_putchar('\\r');\t\t\t\/\/ put cursor at start of line\n    if (!autocmd_busy)\n    {\n\tif (!keep_termcap)\n\t    stoptermcap();\n    }\n#ifdef MSWIN\n    if (!winstart)\n#endif\n\tmsg_putchar('\\n');\t\t\/\/ may shift screen one line up\n\n    \/\/ warning message before calling the shell\n    if (p_warn && !autocmd_busy && msg_silent == 0)\n\tFOR_ALL_BUFFERS(buf)\n\t    if (bufIsChangedNotTerm(buf))\n\t    {\n#ifdef FEAT_GUI_MSWIN\n\t\tif (!keep_termcap)\n\t\t    starttermcap();\t\/\/ don't want a message box here\n#endif\n\t\tmsg_puts(_(\"[No write since last change]\\n\"));\n#ifdef FEAT_GUI_MSWIN\n\t\tif (!keep_termcap)\n\t\t    stoptermcap();\n#endif\n\t\tbreak;\n\t    }\n\n    \/\/ This windgoto is required for when the '\\n' resulted in a \"delete line\n    \/\/ 1\" command to the terminal.\n    if (!swapping_screen())\n\twindgoto(msg_row, msg_col);\n    cursor_on();\n    (void)call_shell(cmd, SHELL_COOKED | flags);\n    did_check_timestamps = FALSE;\n    need_check_timestamps = TRUE;\n\n    \/*\n     * put the message cursor at the end of the screen, avoids wait_return()\n     * to overwrite the text that the external command showed\n     *\/\n    if (!swapping_screen())\n    {\n\tmsg_row = Rows - 1;\n\tmsg_col = 0;\n    }\n\n    if (autocmd_busy)\n    {\n\tif (msg_silent == 0)\n\t    redraw_later_clear();\n    }\n    else\n    {\n\t\/*\n\t * For \":sh\" there is no need to call wait_return(), just redraw.\n\t * Also for the Win32 GUI (the output is in a console window).\n\t * Otherwise there is probably text on the screen that the user wants\n\t * to read before redrawing, so call wait_return().\n\t *\/\n#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)\n# ifdef VIMDLL\n\tif (!gui.in_use)\n# endif\n\t{\n\t    if (cmd == NULL\n# ifdef MSWIN\n\t\t    || (keep_termcap && !need_wait_return)\n# endif\n\t       )\n\t    {\n\t\tif (msg_silent == 0)\n\t\t    redraw_later_clear();\n\t\tneed_wait_return = FALSE;\n\t    }\n\t    else\n\t    {\n\t\t\/*\n\t\t * If we switch screens when starttermcap() is called, we\n\t\t * really want to wait for \"hit return to continue\".\n\t\t *\/\n\t\tsave_nwr = no_wait_return;\n\t\tif (swapping_screen())\n\t\t    no_wait_return = FALSE;\n# ifdef AMIGA\n\t\twait_return(term_console ? -1 : msg_silent == 0); \/\/ see below\n# else\n\t\twait_return(msg_silent == 0);\n# endif\n\t\tno_wait_return = save_nwr;\n\t    }\n\t}\n#endif \/\/ FEAT_GUI_MSWIN\n\n\tif (!keep_termcap)\t\/\/ if keep_termcap is TRUE didn't stop termcap\n\t    starttermcap();\t\/\/ start termcap if not done by wait_return()\n\n\t\/*\n\t * In an Amiga window redrawing is caused by asking the window size.\n\t * If we got an interrupt this will not work. The chance that the\n\t * window size is wrong is very small, but we need to redraw the\n\t * screen.  Don't do this if ':' hit in wait_return().\tTHIS IS UGLY\n\t * but it saves an extra redraw.\n\t *\/\n#ifdef AMIGA\n\tif (skip_redraw)\t\t\/\/ ':' hit in wait_return()\n\t{\n\t    if (msg_silent == 0)\n\t\tredraw_later_clear();\n\t}\n\telse if (term_console)\n\t{\n\t    OUT_STR(IF_EB(\"\\033[0 q\", ESC_STR \"[0 q\"));\t\/\/ get window size\n\t    if (got_int && msg_silent == 0)\n\t\tredraw_later_clear();\t\/\/ if got_int is TRUE, redraw needed\n\t    else\n\t\tmust_redraw = 0;\t\/\/ no extra redraw needed\n\t}\n#endif\n    }\n\n    \/\/ display any error messages now\n    display_errors();\n\n    apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf);\n}","target":0,"code_token_length":1239,"total_token_length":1475,"max_tokens_setting":2048}
+{"idx":413650,"func":"static inline bool get_next_i(IterCtx *ctx, size_t *next_i) {\n\t(*next_i)++;\n\tut64 cur_addr = *next_i + ctx->start_addr;\n\tif (ctx->fcn) {\n\t\tif (!ctx->cur_bb) {\n\t\t\tctx->path = r_list_new ();\n\t\t\tctx->switch_path = r_list_new ();\n\t\t\tctx->bbl = r_list_clone (ctx->fcn->bbs);\n\t\t\tctx->cur_bb = r_anal_get_block_at (ctx->fcn->anal, ctx->fcn->addr);\n\t\t\tif (!ctx->cur_bb) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tr_list_push (ctx->path, ctx->cur_bb);\n\t\t}\n\t\tRAnalBlock *bb = ctx->cur_bb;\n\t\tif (cur_addr >= bb->addr + bb->size) {\n\t\t\tr_reg_arena_push (ctx->fcn->anal->reg);\n\t\t\tRListIter *bbit = NULL;\n\t\t\tif (bb->switch_op) {\n\t\t\t\tRAnalCaseOp *cop = r_list_first (bb->switch_op->cases);\n\t\t\t\tbbit = r_list_find (ctx->bbl, &cop->jump, (RListComparator)find_bb);\n\t\t\t\tif (bbit) {\n\t\t\t\t\tr_list_push (ctx->switch_path, bb->switch_op->cases->head);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbbit = r_list_find (ctx->bbl, &bb->jump, (RListComparator)find_bb);\n\t\t\t\tif (!bbit && bb->fail != UT64_MAX) {\n\t\t\t\t\tbbit = r_list_find (ctx->bbl, &bb->fail, (RListComparator)find_bb);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!bbit) {\n\t\t\t\tRListIter *cop_it = r_list_last (ctx->switch_path);\n\t\t\t\tRAnalBlock *prev_bb = NULL;\n\t\t\t\tdo {\n\t\t\t\t\tr_reg_arena_pop (ctx->fcn->anal->reg);\n\t\t\t\t\tprev_bb = r_list_pop (ctx->path);\n\t\t\t\t\tif (prev_bb->fail != UT64_MAX) {\n\t\t\t\t\t\tbbit = r_list_find (ctx->bbl, &prev_bb->fail, (RListComparator)find_bb);\n\t\t\t\t\t\tif (bbit) {\n\t\t\t\t\t\t\tr_reg_arena_push (ctx->fcn->anal->reg);\n\t\t\t\t\t\t\tr_list_push (ctx->path, prev_bb);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!bbit && cop_it) {\n\t\t\t\t\t\tRAnalCaseOp *cop = cop_it->data;\n\t\t\t\t\t\tif (cop->jump == prev_bb->addr && cop_it->n) {\n\t\t\t\t\t\t\tcop = cop_it->n->data;\n\t\t\t\t\t\t\tr_list_pop (ctx->switch_path);\n\t\t\t\t\t\t\tr_list_push (ctx->switch_path, cop_it->n);\n\t\t\t\t\t\t\tcop_it = cop_it->n;\n\t\t\t\t\t\t\tbbit = r_list_find (ctx->bbl, &cop->jump, (RListComparator)find_bb);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (cop_it && !cop_it->n) {\n\t\t\t\t\t\tr_list_pop (ctx->switch_path);\n\t\t\t\t\t\tcop_it = r_list_last (ctx->switch_path);\n\t\t\t\t\t}\n\t\t\t\t} while (!bbit && !r_list_empty (ctx->path));\n\t\t\t}\n\t\t\tif (!bbit) {\n\t\t\t\tr_list_free (ctx->path);\n\t\t\t\tr_list_free (ctx->switch_path);\n\t\t\t\tr_list_free (ctx->bbl);\n\t\t\t\tctx->path = NULL;\n\t\t\t\tctx->switch_path = NULL;\n\t\t\t\tctx->bbl = NULL;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!bbit->data) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!bbit->data) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tctx->cur_bb = bbit->data;\n\t\t\tr_list_push (ctx->path, ctx->cur_bb);\n\t\t\tr_list_delete (ctx->bbl, bbit);\n\t\t\t*next_i = ctx->cur_bb->addr - ctx->start_addr;\n\t\t}\n\t} else if (cur_addr >= ctx->end_addr) {\n\t\treturn false;\n\t}\n\tif (*next_i == 0) {\n\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":884,"total_token_length":1120,"max_tokens_setting":2048}
+{"idx":242938,"func":"static int ssl_prepare_record_content( mbedtls_ssl_context *ssl,\n                                       mbedtls_record *rec )\n{\n    int ret, done = 0;\n\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"input record from network\",\n                           rec->buf, rec->buf_len );\n\n#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)\n    if( mbedtls_ssl_hw_record_read != NULL )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 2, ( \"going for mbedtls_ssl_hw_record_read()\" ) );\n\n        ret = mbedtls_ssl_hw_record_read( ssl );\n        if( ret != 0 && ret != MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_hw_record_read\", ret );\n            return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );\n        }\n\n        if( ret == 0 )\n            done = 1;\n    }\n#endif \/* MBEDTLS_SSL_HW_RECORD_ACCEL *\/\n    if( !done && ssl->transform_in != NULL )\n    {\n        unsigned char const old_msg_type = rec->type;\n\n        if( ( ret = mbedtls_ssl_decrypt_buf( ssl, ssl->transform_in,\n                                             rec ) ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"ssl_decrypt_buf\", ret );\n\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)\n            if( ret == MBEDTLS_ERR_SSL_UNEXPECTED_CID &&\n                ssl->conf->ignore_unexpected_cid\n                    == MBEDTLS_SSL_UNEXPECTED_CID_IGNORE )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ignoring unexpected CID\" ) );\n                ret = MBEDTLS_ERR_SSL_CONTINUE_PROCESSING;\n            }\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n\n            return( ret );\n        }\n\n        if( old_msg_type != rec->type )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 4, ( \"record type after decrypt (before %d): %d\",\n                                        old_msg_type, rec->type ) );\n        }\n\n        MBEDTLS_SSL_DEBUG_BUF( 4, \"input payload after decrypt\",\n                               rec->buf + rec->data_offset, rec->data_len );\n\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)\n        \/* We have already checked the record content type\n         * in ssl_parse_record_header(), failing or silently\n         * dropping the record in the case of an unknown type.\n         *\n         * Since with the use of CIDs, the record content type\n         * might change during decryption, re-check the record\n         * content type, but treat a failure as fatal this time. *\/\n        if( ssl_check_record_type( rec->type ) )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"unknown record type\" ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n\n        if( rec->data_len == 0 )\n        {\n#if defined(MBEDTLS_SSL_PROTO_TLS1_2)\n            if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3\n                && rec->type != MBEDTLS_SSL_MSG_APPLICATION_DATA )\n            {\n                \/* TLS v1.2 explicitly disallows zero-length messages which are not application data *\/\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"invalid zero-length message type: %d\", ssl->in_msgtype ) );\n                return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n            }\n#endif \/* MBEDTLS_SSL_PROTO_TLS1_2 *\/\n\n            ssl->nb_zero++;\n\n            \/*\n             * Three or more empty messages may be a DoS attack\n             * (excessive CPU consumption).\n             *\/\n            if( ssl->nb_zero > 3 )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"received four consecutive empty \"\n                                            \"messages, possible DoS attack\" ) );\n                \/* Treat the records as if they were not properly authenticated,\n                 * thereby failing the connection if we see more than allowed\n                 * by the configured bad MAC threshold. *\/\n                return( MBEDTLS_ERR_SSL_INVALID_MAC );\n            }\n        }\n        else\n            ssl->nb_zero = 0;\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n        if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n        {\n            ; \/* in_ctr read from peer, not maintained internally *\/\n        }\n        else\n#endif\n        {\n            unsigned i;\n            for( i = 8; i > mbedtls_ssl_ep_len( ssl ); i-- )\n                if( ++ssl->in_ctr[i - 1] != 0 )\n                    break;\n\n            \/* The loop goes to its end iff the counter is wrapping *\/\n            if( i == mbedtls_ssl_ep_len( ssl ) )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"incoming message counter would wrap\" ) );\n                return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING );\n            }\n        }\n\n    }\n\n#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        mbedtls_ssl_dtls_replay_update( ssl );\n    }\n#endif\n\n    \/* Check actual (decrypted) record content length against\n     * configured maximum. *\/\n    if( ssl->in_msglen > MBEDTLS_SSL_IN_CONTENT_LEN )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad message length\" ) );\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n    }\n\n    return( 0 );\n}","target":0,"code_token_length":1164,"total_token_length":1400,"max_tokens_setting":2048}
+{"idx":195291,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& rhs = context->input(1);\n\n    \/\/ We always return the input ref.\n    context->forward_ref_input_to_ref_output(0, 0);\n\n    \/\/ We can't always know how this value will be used downstream, so make\n    \/\/ conservative assumptions in specifying constraints on the memory\n    \/\/ allocation attributes, unless the Grappler graph analysis determined that\n    \/\/ it was safe not to.\n    AllocatorAttributes attr;\n    if (!relax_constraints_) {\n      attr.set_gpu_compatible(true);\n      attr.set_nic_compatible(true);\n    }\n\n    {\n      mutex_lock l(*context->input_ref_mutex(0));\n      const Tensor& old_lhs = context->mutable_input(0, \/* lock_held *\/ true);\n      const bool same_shape = old_lhs.shape().IsSameSize(rhs.shape());\n      if (validate_shape_) {\n        OP_REQUIRES(context, same_shape,\n                    errors::InvalidArgument(\n                        \"Assign requires shapes of both tensors to match. \"\n                        \"lhs shape= \",\n                        old_lhs.shape().DebugString(),\n                        \" rhs shape= \", rhs.shape().DebugString()));\n      }\n\n      \/\/ In the code below we try to minimize the amount of memory allocation\n      \/\/ and copying by trying the following two shortcuts:\n      \/\/ 1. If the lhs is initialized and has the same number of elements as\n      \/\/    the rhs we can avoid a memory allocation.\n      \/\/ 2. If we can reuse the rhs buffer we avoid both a memory allocation\n      \/\/    and copying.\n\n      \/\/ 1. Try to copy into an existing buffer.\n      if (old_lhs.IsInitialized() &&\n          old_lhs.shape().num_elements() == rhs.shape().num_elements()) {\n        \/\/ The existing lhs tensor has already been initialized and the right\n        \/\/ hand side can fit in the underlying buffer.\n        Tensor reshaped_old_lhs;\n        if (same_shape) {\n          reshaped_old_lhs = old_lhs;\n        } else {\n          CHECK(reshaped_old_lhs.CopyFrom(old_lhs, rhs.shape()));\n          context->replace_ref_input(0, reshaped_old_lhs,\n                                     \/* lock_held *\/ true);\n        }\n        if (use_exclusive_lock_) {\n          Copy(context, &reshaped_old_lhs, rhs);\n          return;\n        }\n      } else {\n        \/\/ 2. Try to reuse the rhs.\n        std::unique_ptr<Tensor> input_alias = context->forward_input(\n            1, OpKernelContext::Params::kNoReservation \/*output_index*\/,\n            rhs.dtype(), rhs.shape(), DEVICE_MEMORY, attr);\n        if (input_alias != nullptr) {\n          \/\/ Update the ref to point to the new buffer.\n          context->replace_ref_input(0, *input_alias, \/* lock_held *\/ true);\n          return;\n        }\n\n        \/\/ Otherwise, create a new tensor whose shape matches the\n        \/\/ right hand side, hand off to lhs and copy the rhs into it.\n        Tensor copy_tensor;\n        OP_REQUIRES_OK(context,\n                       context->allocate_temp(old_lhs.dtype(), rhs.shape(),\n                                              ©_tensor, attr));\n        \/\/ We track memory of variables in variable ops instead of in this\n        \/\/ assign op.\n        context->clear_recorded_memory();\n        context->replace_ref_input(0, copy_tensor, \/* lock_held *\/ true);\n        if (use_exclusive_lock_) {\n          Copy(context, ©_tensor, rhs);\n          return;\n        }\n      }\n    }\n\n    \/\/ The tensor has already been initialized and the right hand side\n    \/\/ matches the left hand side's shape. We have been told to do the\n    \/\/ copy outside the lock.\n    Tensor old_unlocked_lhs = context->mutable_input(0, \/* lock_held *\/ false);\n    Copy(context, &old_unlocked_lhs, rhs);\n  }","target":1,"code_token_length":799,"total_token_length":1035,"max_tokens_setting":2048}
+{"idx":413611,"func":"R_API int r_core_anal_search_xrefs(RCore *core, ut64 from, ut64 to, PJ *pj, int rad) {\n\tconst bool cfg_debug = r_config_get_b (core->config, \"cfg.debug\");\n\tbool cfg_anal_strings = r_config_get_i (core->config, \"anal.strings\");\n\tut64 at;\n\tint count = 0;\n\tint bsz = 8096;\n\tRAnalOp op = { 0 };\n\n\tif (from == to) {\n\t\treturn -1;\n\t}\n\tif (from > to) {\n\t\teprintf (\"Invalid range (0x%\"PFMT64x\n\t\t\" >= 0x%\"PFMT64x\")\\n\", from, to);\n\t\treturn -1;\n\t}\n\n\tif (core->blocksize <= OPSZ) {\n\t\teprintf (\"Error: block size too small\\n\");\n\t\treturn -1;\n\t}\n\tut8 *buf = malloc (bsz);\n\tif (!buf) {\n\t\teprintf (\"Error: cannot allocate a block\\n\");\n\t\treturn -1;\n\t}\n\tut8 *block = malloc (bsz);\n\tif (!block) {\n\t\teprintf (\"Error: cannot allocate a temp block\\n\");\n\t\tfree (buf);\n\t\treturn -1;\n\t}\n\tr_cons_break_push (NULL, NULL);\n\tat = from;\n\tst64 asm_sub_varmin = r_config_get_i (core->config, \"asm.sub.varmin\");\n\tint maxopsz = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MAX_OP_SIZE);\n\tint minopsz = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE);\n\tif (maxopsz < 1) {\n\t\tmaxopsz = 4;\n\t}\n\tif (minopsz < 1) {\n\t\tminopsz = 1;\n\t}\n\tif (bsz < maxopsz) {\n\t\t\/\/ wtf\n\t\teprintf (\"Error: Something is really wrong deep inside\\n\");\n\t\tfree (block);\n\t\treturn -1;\n\t}\n\twhile (at < to && !r_cons_is_breaked ()) {\n\t\tint i = 0, ret = bsz;\n\t\tif (!r_io_is_valid_offset (core->io, at, R_PERM_X)) {\n\t\t\tbreak;\n\t\t}\n\t\tut64 left = to - at;\n\t\tif (bsz > left) {\n\t\t\tbsz = left;\n\t\t}\n\t\t(void)r_io_read_at (core->io, at, buf, bsz);\n\t\tmemset (block, -1, bsz);\n\t\tif (!memcmp (buf, block, bsz)) {\n\t\t\/\/\teprintf (\"Error: skipping uninitialized block \\n\");\n\t\t\tat += ret;\n\t\t\tcontinue;\n\t\t}\n\t\tmemset (block, 0, bsz);\n\t\tif (!memcmp (buf, block, bsz)) {\n\t\t\/\/\teprintf (\"Error: skipping uninitialized block \\n\");\n\t\t\tat += ret;\n\t\t\tcontinue;\n\t\t}\n\t\t(void) r_anal_op (core->anal, &op, at, buf, bsz, R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT);\n\t\twhile ((i + maxopsz) < bsz && !r_cons_is_breaked ()) {\n\t\t\tr_anal_op_fini (&op);\n\t\t\tret = r_anal_op (core->anal, &op, at + i, buf + i, bsz - i, R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT);\n\t\t\tif (ret < 1) {\n\t\t\t\ti += minopsz;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ti += ret;\n\t\t\tif (i > bsz) {\n\t\t\t\t\/\/ at += minopsz;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\/\/ find references\n\t\t\tif ((st64)op.val > asm_sub_varmin && op.val != UT64_MAX && op.val != UT32_MAX) {\n\t\t\t\tif (found_xref (core, op.addr, op.val, R_ANAL_REF_TYPE_DATA, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/\/ find references\n\t\t\tif (op.ptr && op.ptr != UT64_MAX && op.ptr != UT32_MAX) {\n\t\t\t\tif (found_xref (core, op.addr, op.ptr, R_ANAL_REF_TYPE_DATA, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/\/ find references\n\t\t\tif (op.addr > 512 && op.disp > 512 && op.disp && op.disp != UT64_MAX) {\n\t\t\t\tif (found_xref (core, op.addr, op.disp, R_ANAL_REF_TYPE_DATA, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (op.type) {\n\t\t\tcase R_ANAL_OP_TYPE_JMP:\n\t\t\tcase R_ANAL_OP_TYPE_CJMP:\n\t\t\t\tif (found_xref (core, op.addr, op.jump, R_ANAL_REF_TYPE_CODE, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_OP_TYPE_CALL:\n\t\t\tcase R_ANAL_OP_TYPE_CCALL:\n\t\t\t\tif (found_xref (core, op.addr, op.jump, R_ANAL_REF_TYPE_CALL, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_OP_TYPE_UJMP:\n\t\t\tcase R_ANAL_OP_TYPE_IJMP:\n\t\t\tcase R_ANAL_OP_TYPE_RJMP:\n\t\t\tcase R_ANAL_OP_TYPE_IRJMP:\n\t\t\tcase R_ANAL_OP_TYPE_MJMP:\n\t\t\tcase R_ANAL_OP_TYPE_UCJMP:\n\t\t\t\tcount++;\n\t\t\t\tif (found_xref (core, op.addr, op.ptr, R_ANAL_REF_TYPE_CODE, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_OP_TYPE_UCALL:\n\t\t\tcase R_ANAL_OP_TYPE_ICALL:\n\t\t\tcase R_ANAL_OP_TYPE_RCALL:\n\t\t\tcase R_ANAL_OP_TYPE_IRCALL:\n\t\t\tcase R_ANAL_OP_TYPE_UCCALL:\n\t\t\t\tif (found_xref (core, op.addr, op.ptr, R_ANAL_REF_TYPE_CALL, pj, rad, cfg_debug, cfg_anal_strings)) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tr_anal_op_fini (&op);\n\t\tif (i < 1) {\n\t\t\tbreak;\n\t\t}\n\t\tat += i + 1;\n\t}\n\tr_cons_break_pop ();\n\tfree (buf);\n\tfree (block);\n\treturn count;\n}","target":0,"code_token_length":1417,"total_token_length":1653,"max_tokens_setting":2048}
+{"idx":255784,"func":"create_user_authz(authz_full_t *authz,\n                  const char *repository,\n                  const char *user,\n                  apr_pool_t *result_pool,\n                  apr_pool_t *scratch_pool)\n{\n  int i;\n  node_t *root = create_node(NULL, result_pool);\n  construction_context_t *ctx = create_construction_context(scratch_pool);\n\n  \/* Use a separate sub-pool to keep memory usage tight. *\/\n  apr_pool_t *subpool = svn_pool_create(scratch_pool);\n\n  \/* Find all ACLs for REPOSITORY. *\/\n  apr_array_header_t *acls = apr_array_make(subpool, authz->acls->nelts,\n                                            sizeof(authz_acl_t *));\n  for (i = 0; i < authz->acls->nelts; ++i)\n    {\n      const authz_acl_t *acl = &APR_ARRAY_IDX(authz->acls, i, authz_acl_t);\n      if (svn_authz__acl_applies_to_repo(acl, repository))\n        {\n          \/* ACLs in the AUTHZ are sorted by path and repository.\n           * So, if there is a rule for the repo and a global rule for the\n           * same path, we will detect them here. *\/\n          if (acls->nelts)\n            {\n              const authz_acl_t *prev_acl\n                = APR_ARRAY_IDX(acls, acls->nelts - 1, const authz_acl_t *);\n              if (svn_authz__compare_paths(&prev_acl->rule, &acl->rule) == 0)\n                {\n                  svn_boolean_t global_acl_applies;\n                  svn_boolean_t repos_acl_applies;\n\n                  \/* Previous ACL is a global rule. *\/\n                  SVN_ERR_ASSERT_NO_RETURN(!strcmp(prev_acl->rule.repos,\n                                                   AUTHZ_ANY_REPOSITORY));\n                  \/* Current ACL is a per-repository rule. *\/\n                  SVN_ERR_ASSERT_NO_RETURN(strcmp(acl->rule.repos,\n                                                  AUTHZ_ANY_REPOSITORY));\n\n                  global_acl_applies =\n                    svn_authz__get_acl_access(NULL, prev_acl, user, repository);\n                  repos_acl_applies =\n                    svn_authz__get_acl_access(NULL, acl, user, repository);\n\n                  \/* Prefer rules which apply to both this user and this path\n                   * over rules which apply only to the path. In cases where\n                   * both rules apply to user and path, always prefer the\n                   * repository-specific rule. *\/\n                  if (!global_acl_applies || repos_acl_applies)\n                    {\n                      apr_array_pop(acls);\n                      APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl;\n                    }\n                }\n              else\n                APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl;\n            }\n          else\n            APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl;\n        }\n    }\n\n  \/* Filtering and tree construction. *\/\n  for (i = 0; i < acls->nelts; ++i)\n    process_acl(ctx, APR_ARRAY_IDX(acls, i, const authz_acl_t *),\n                root, repository, user, result_pool, subpool);\n\n  \/* If there is no relevant rule at the root node, the \"no access\" default\n   * applies. Give it a SEQUENCE_NUMBER that will never overrule others. *\/\n  if (!has_local_rule(&root->rights))\n    {\n      root->rights.access.sequence_number = 0;\n      root->rights.access.rights = authz_access_none;\n    }\n\n  \/* Trim the tree.\n   *\n   * We can't do pattern comparison, so for most pattern rules we cannot\n   * say that a set of rules \"eclipses\" \/ overrides a given other set of\n   * rules for all possible paths.  That limits the accuracy of our check\n   * for recursive access in similar ways than for non-pattern rules.\n   *\n   * However, the user expects a rule ending with \"**\" to eclipse any older\n   * rule in that sub-tree recursively.  So, this trim function removes\n   * eclipsed nodes from the tree.\n   *\/\n  svn_pool_clear(subpool);\n  trim_tree(root, NO_SEQUENCE_NUMBER, subpool);\n\n  \/* Calculate recursive rights.\n   *\n   * This is a bottom-up calculation of the range of access rights\n   * specified anywhere in  the respective sub-tree, including the base\n   * node itself.\n   *\n   * To prevent additional finalization passes, we piggy-back the addition\n   * of the ordering links of the prefix and suffix sub-node rules.\n   *\/\n  svn_pool_clear(subpool);\n  finalize_tree(root, &root->rights, subpool);\n\n  \/* Done. *\/\n  svn_pool_destroy(subpool);\n  return root;\n}","target":0,"code_token_length":992,"total_token_length":1228,"max_tokens_setting":2048}
+{"idx":210700,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tsquashfs_dir_header_2 dirh;\n\tchar buffer[sizeof(squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tsquashfs_dir_entry_2 *dire = (squashfs_dir_entry_2 *) buffer;\n\tlong long start;\n\tint bytes;\n\tint dir_count, size;\n\tstruct dir_ent *new_dir;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: malloc failed!\\n\");\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = 0;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 0)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\t\t\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\tbytes = lookup_entry(directory_table_hash, start);\n\tif(bytes == -1)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: directory block %d not \"\n\t\t\t\"found!\\n\", block_start);\n\n\tbytes += (*i)->offset;\n\tsize = (*i)->data + bytes;\n\n\twhile(bytes < size) {\t\t\t\n\t\tif(swap) {\n\t\t\tsquashfs_dir_header_2 sdirh;\n\t\t\tmemcpy(&sdirh, directory_table + bytes, sizeof(sdirh));\n\t\t\tSQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);\n\t\t} else\n\t\t\tmemcpy(&dirh, directory_table + bytes, sizeof(dirh));\n\t\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_entry_2 sdire;\n\t\t\t\tmemcpy(&sdire, directory_table + bytes,\n\t\t\t\t\tsizeof(sdire));\n\t\t\t\tSQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);\n\t\t\t} else\n\t\t\t\tmemcpy(dire, directory_table + bytes,\n\t\t\t\t\tsizeof(*dire));\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tmemcpy(dire->name, directory_table + bytes,\n\t\t\t\tdire->size + 1);\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\t\t\tif((dir->dir_count % DIR_ENT_SIZE) == 0) {\n\t\t\t\tnew_dir = realloc(dir->dirs, (dir->dir_count +\n\t\t\t\t\tDIR_ENT_SIZE) * sizeof(struct dir_ent));\n\t\t\t\tif(new_dir == NULL)\n\t\t\t\t\tEXIT_UNSQUASH(\"squashfs_opendir: \"\n\t\t\t\t\t\t\"realloc failed!\\n\");\n\t\t\t\tdir->dirs = new_dir;\n\t\t\t}\n\t\t\tstrcpy(dir->dirs[dir->dir_count].name, dire->name);\n\t\t\tdir->dirs[dir->dir_count].start_block =\n\t\t\t\tdirh.start_block;\n\t\t\tdir->dirs[dir->dir_count].offset = dire->offset;\n\t\t\tdir->dirs[dir->dir_count].type = dire->type;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tfree(dir->dirs);\n\tfree(dir);\n\treturn NULL;\n}","target":1,"code_token_length":977,"total_token_length":1213,"max_tokens_setting":2048}
+{"idx":247125,"func":"void gf_fs_print_stats(GF_FilterSession *fsess)\n{\n\tu64 run_time=0, active_time=0, nb_tasks=0, nb_filters=0;\n\tu32 i, count;\n\n\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\n\"));\n\tgf_mx_p(fsess->filters_mx);\n\n\tcount=gf_list_count(fsess->filters);\n\tfor (i=0; i<count; i++) {\n\t\tGF_Filter *f = gf_list_get(fsess->filters, i);\n\t\tif (f->multi_sink_target) continue;\n\t\tnb_filters++;\n\t}\n\n\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"Filter stats - %d filters\\n\", nb_filters));\n\tfor (i=0; i<count; i++) {\n\t\tu32 k, ipids, opids;\n\t\tGF_Filter *f = gf_list_get(fsess->filters, i);\n\t\tif (f->multi_sink_target) continue;\n\n\t\tgf_mx_p(f->tasks_mx);\n\n\t\tipids = f->num_input_pids;\n\t\topids = f->num_output_pids;\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\tFilter \"));\n\t\tprint_filter_name(f, GF_FALSE, GF_FALSE);\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" : %d input pids %d output pids \"LLU\" tasks \"LLU\" us process time\\n\", ipids, opids, f->nb_tasks_done, f->time_process));\n\n\t\tif (ipids) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t\"LLU\" packets processed \"LLU\" bytes processed\", f->nb_pck_processed, f->nb_bytes_processed));\n\t\t\tif (f->time_process) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" (%g pck\/sec %g mbps)\", (Double) f->nb_pck_processed*1000000\/f->time_process, (Double) f->nb_bytes_processed*8\/f->time_process));\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\n\"));\n\t\t}\n\t\tif (opids) {\n\t\t\tif (f->nb_hw_pck_sent) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t\"LLU\" hardware frames sent\", f->nb_hw_pck_sent));\n\t\t\t\tif (f->time_process) {\n\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" (%g pck\/sec)\", (Double) f->nb_hw_pck_sent*1000000\/f->time_process));\n\t\t\t\t}\n\n\t\t\t} else if (f->nb_pck_sent) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t\"LLU\" packets sent \"LLU\" bytes sent\", f->nb_pck_sent, f->nb_bytes_sent));\n\t\t\t\tif (f->time_process) {\n\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" (%g pck\/sec %g mbps)\", (Double) f->nb_pck_sent*1000000\/f->time_process, (Double) f->nb_bytes_sent*8\/f->time_process));\n\t\t\t\t}\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\n\"));\n\t\t}\n\n\t\tfor (k=0; k<ipids; k++) {\n\t\t\tGF_FilterPidInst *pid = gf_list_get(f->input_pids, k);\n\t\t\tif (!pid->pid) continue;\n\t\t\tif (pid->requires_full_data_block && (pid->nb_reagg_pck != pid->pid->nb_pck_sent) ) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t* input PID %s: %d frames (%d packets) received\\n\", pid->pid->name, pid->nb_reagg_pck, pid->pid->nb_pck_sent));\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t* input PID %s: %d packets received\\n\", pid->pid->name, pid->pid->nb_pck_sent));\n\t\t\t}\n\t\t}\n#ifndef GPAC_DISABLE_LOG\n\t\tfor (k=0; k<opids; k++) {\n\t\t\tGF_FilterPid *pid = gf_list_get(f->output_pids, k);\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t* output PID %s: %d packets sent\\n\", pid->name, pid->nb_pck_sent));\n\t\t}\n\t\tif (f->nb_errors) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\t\\t%d errors while processing\\n\", f->nb_errors));\n\t\t}\n#endif\n\n\t\tgf_mx_v(f->tasks_mx);\n\t}\n\tgf_mx_v(fsess->filters_mx);\n\n\tcount=gf_list_count(fsess->threads);\n\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"Session stats - threads %d\\n\", 1+count));\n\n\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\tThread %u: run_time \"LLU\" us active_time \"LLU\" us nb_tasks \"LLU\"\\n\", 1, fsess->main_th.run_time, fsess->main_th.active_time, fsess->main_th.nb_tasks));\n\n\trun_time+=fsess->main_th.run_time;\n\tactive_time+=fsess->main_th.active_time;\n\tnb_tasks+=fsess->main_th.nb_tasks;\n\n\tfor (i=0; i<count; i++) {\n\t\tGF_SessionThread *s = gf_list_get(fsess->threads, i);\n\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\tThread %u: run_time \"LLU\" us active_time \"LLU\" us nb_tasks \"LLU\"\\n\", i+2, s->run_time, s->active_time, s->nb_tasks));\n\n\t\trun_time+=s->run_time;\n\t\tactive_time+=s->active_time;\n\t\tnb_tasks+=s->nb_tasks;\n\t}\n\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\nTotal: run_time \"LLU\" us active_time \"LLU\" us nb_tasks \"LLU\"\\n\", run_time, active_time, nb_tasks));\n}","target":0,"code_token_length":1334,"total_token_length":1570,"max_tokens_setting":2048}
+{"idx":405376,"func":"static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,\n\t\t\t\t\t    struct xfrm_state **xfrm,\n\t\t\t\t\t    struct xfrm_dst **bundle,\n\t\t\t\t\t    int nx,\n\t\t\t\t\t    const struct flowi *fl,\n\t\t\t\t\t    struct dst_entry *dst)\n{\n\tconst struct xfrm_state_afinfo *afinfo;\n\tconst struct xfrm_mode *inner_mode;\n\tstruct net *net = xp_net(policy);\n\tunsigned long now = jiffies;\n\tstruct net_device *dev;\n\tstruct xfrm_dst *xdst_prev = NULL;\n\tstruct xfrm_dst *xdst0 = NULL;\n\tint i = 0;\n\tint err;\n\tint header_len = 0;\n\tint nfheader_len = 0;\n\tint trailer_len = 0;\n\tint tos;\n\tint family = policy->selector.family;\n\txfrm_address_t saddr, daddr;\n\n\txfrm_flowi_addr_get(fl, &saddr, &daddr, family);\n\n\ttos = xfrm_get_tos(fl, family);\n\n\tdst_hold(dst);\n\n\tfor (; i < nx; i++) {\n\t\tstruct xfrm_dst *xdst = xfrm_alloc_dst(net, family);\n\t\tstruct dst_entry *dst1 = &xdst->u.dst;\n\n\t\terr = PTR_ERR(xdst);\n\t\tif (IS_ERR(xdst)) {\n\t\t\tdst_release(dst);\n\t\t\tgoto put_states;\n\t\t}\n\n\t\tbundle[i] = xdst;\n\t\tif (!xdst_prev)\n\t\t\txdst0 = xdst;\n\t\telse\n\t\t\t\/* Ref count is taken during xfrm_alloc_dst()\n\t\t\t * No need to do dst_clone() on dst1\n\t\t\t *\/\n\t\t\txfrm_dst_set_child(xdst_prev, &xdst->u.dst);\n\n\t\tif (xfrm[i]->sel.family == AF_UNSPEC) {\n\t\t\tinner_mode = xfrm_ip2inner_mode(xfrm[i],\n\t\t\t\t\t\t\txfrm_af2proto(family));\n\t\t\tif (!inner_mode) {\n\t\t\t\terr = -EAFNOSUPPORT;\n\t\t\t\tdst_release(dst);\n\t\t\t\tgoto put_states;\n\t\t\t}\n\t\t} else\n\t\t\tinner_mode = &xfrm[i]->inner_mode;\n\n\t\txdst->route = dst;\n\t\tdst_copy_metrics(dst1, dst);\n\n\t\tif (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {\n\t\t\t__u32 mark = 0;\n\t\t\tint oif;\n\n\t\t\tif (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m)\n\t\t\t\tmark = xfrm_smark_get(fl->flowi_mark, xfrm[i]);\n\n\t\t\tfamily = xfrm[i]->props.family;\n\t\t\toif = fl->flowi_oif ? : fl->flowi_l3mdev;\n\t\t\tdst = xfrm_dst_lookup(xfrm[i], tos, oif,\n\t\t\t\t\t      &saddr, &daddr, family, mark);\n\t\t\terr = PTR_ERR(dst);\n\t\t\tif (IS_ERR(dst))\n\t\t\t\tgoto put_states;\n\t\t} else\n\t\t\tdst_hold(dst);\n\n\t\tdst1->xfrm = xfrm[i];\n\t\txdst->xfrm_genid = xfrm[i]->genid;\n\n\t\tdst1->obsolete = DST_OBSOLETE_FORCE_CHK;\n\t\tdst1->lastuse = now;\n\n\t\tdst1->input = dst_discard;\n\n\t\trcu_read_lock();\n\t\tafinfo = xfrm_state_afinfo_get_rcu(inner_mode->family);\n\t\tif (likely(afinfo))\n\t\t\tdst1->output = afinfo->output;\n\t\telse\n\t\t\tdst1->output = dst_discard_out;\n\t\trcu_read_unlock();\n\n\t\txdst_prev = xdst;\n\n\t\theader_len += xfrm[i]->props.header_len;\n\t\tif (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT)\n\t\t\tnfheader_len += xfrm[i]->props.header_len;\n\t\ttrailer_len += xfrm[i]->props.trailer_len;\n\t}\n\n\txfrm_dst_set_child(xdst_prev, dst);\n\txdst0->path = dst;\n\n\terr = -ENODEV;\n\tdev = dst->dev;\n\tif (!dev)\n\t\tgoto free_dst;\n\n\txfrm_init_path(xdst0, dst, nfheader_len);\n\txfrm_init_pmtu(bundle, nx);\n\n\tfor (xdst_prev = xdst0; xdst_prev != (struct xfrm_dst *)dst;\n\t     xdst_prev = (struct xfrm_dst *) xfrm_dst_child(&xdst_prev->u.dst)) {\n\t\terr = xfrm_fill_dst(xdst_prev, dev, fl);\n\t\tif (err)\n\t\t\tgoto free_dst;\n\n\t\txdst_prev->u.dst.header_len = header_len;\n\t\txdst_prev->u.dst.trailer_len = trailer_len;\n\t\theader_len -= xdst_prev->u.dst.xfrm->props.header_len;\n\t\ttrailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len;\n\t}\n\n\treturn &xdst0->u.dst;\n\nput_states:\n\tfor (; i < nx; i++)\n\t\txfrm_state_put(xfrm[i]);\nfree_dst:\n\tif (xdst0)\n\t\tdst_release_immediate(&xdst0->u.dst);\n\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":1070,"total_token_length":1306,"max_tokens_setting":2048}
+{"idx":353020,"func":"directoryStringSubstringsMatch(\n\tint *matchp,\n\tslap_mask_t flags,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *value,\n\tvoid *assertedValue )\n{\n\tint match = 0;\n\tSubstringsAssertion *sub = assertedValue;\n\tstruct berval left = *value;\n\tber_len_t i;\n\tint priorspace=0;\n\n\tif ( !BER_BVISNULL( &sub->sa_initial ) ) {\n\t\tif ( sub->sa_initial.bv_len > left.bv_len ) {\n\t\t\t\/* not enough left *\/\n\t\t\tmatch = 1;\n\t\t\tgoto done;\n\t\t}\n\n\t\tmatch = memcmp( sub->sa_initial.bv_val, left.bv_val,\n\t\t\tsub->sa_initial.bv_len );\n\n\t\tif ( match != 0 ) {\n\t\t\tgoto done;\n\t\t}\n\n\t\tleft.bv_val += sub->sa_initial.bv_len;\n\t\tleft.bv_len -= sub->sa_initial.bv_len;\n\n\t\tpriorspace = ASCII_SPACE(\n\t\t\tsub->sa_initial.bv_val[sub->sa_initial.bv_len] );\n\t}\n\n\tif ( sub->sa_any ) {\n\t\tfor ( i = 0; !BER_BVISNULL( &sub->sa_any[i] ); i++ ) {\n\t\t\tber_len_t idx;\n\t\t\tchar *p;\n\n\t\t\tif( priorspace && !BER_BVISEMPTY( &sub->sa_any[i] ) \n\t\t\t\t&& ASCII_SPACE( sub->sa_any[i].bv_val[0] ))\n\t\t\t{ \n\t\t\t\t\/* allow next space to match *\/\n\t\t\t\tleft.bv_val--;\n\t\t\t\tleft.bv_len++;\n\t\t\t}\n\t\t\tpriorspace=0;\n\nretry:\n\t\t\tif ( BER_BVISEMPTY( &sub->sa_any[i] ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( sub->sa_any[i].bv_len > left.bv_len ) {\n\t\t\t\t\/* not enough left *\/\n\t\t\t\tmatch = 1;\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\tp = memchr( left.bv_val, *sub->sa_any[i].bv_val, left.bv_len );\n\n\t\t\tif( p == NULL ) {\n\t\t\t\tmatch = 1;\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\tidx = p - left.bv_val;\n\n\t\t\tif ( idx >= left.bv_len ) {\n\t\t\t\t\/* this shouldn't happen *\/\n\t\t\t\treturn LDAP_OTHER;\n\t\t\t}\n\n\t\t\tleft.bv_val = p;\n\t\t\tleft.bv_len -= idx;\n\n\t\t\tif ( sub->sa_any[i].bv_len > left.bv_len ) {\n\t\t\t\t\/* not enough left *\/\n\t\t\t\tmatch = 1;\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\tmatch = memcmp( left.bv_val,\n\t\t\t\tsub->sa_any[i].bv_val,\n\t\t\t\tsub->sa_any[i].bv_len );\n\n\t\t\tif ( match != 0 ) {\n\t\t\t\tleft.bv_val++;\n\t\t\t\tleft.bv_len--;\n\t\t\t\tgoto retry;\n\t\t\t}\n\n\t\t\tleft.bv_val += sub->sa_any[i].bv_len;\n\t\t\tleft.bv_len -= sub->sa_any[i].bv_len;\n\n\t\t\tpriorspace = ASCII_SPACE(\n\t\t\t\tsub->sa_any[i].bv_val[sub->sa_any[i].bv_len] );\n\t\t}\n\t}\n\n\tif ( !BER_BVISNULL( &sub->sa_final ) ) {\n\t\tif( priorspace && !BER_BVISEMPTY( &sub->sa_final ) \n\t\t\t&& ASCII_SPACE( sub->sa_final.bv_val[0] ))\n\t\t{ \n\t\t\t\/* allow next space to match *\/\n\t\t\tleft.bv_val--;\n\t\t\tleft.bv_len++;\n\t\t}\n\n\t\tif ( sub->sa_final.bv_len > left.bv_len ) {\n\t\t\t\/* not enough left *\/\n\t\t\tmatch = 1;\n\t\t\tgoto done;\n\t\t}\n\n\t\tmatch = memcmp( sub->sa_final.bv_val,\n\t\t\t&left.bv_val[left.bv_len - sub->sa_final.bv_len],\n\t\t\tsub->sa_final.bv_len );\n\n\t\tif ( match != 0 ) {\n\t\t\tgoto done;\n\t\t}\n\t}\n\ndone:\n\t*matchp = match;\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":870,"total_token_length":1106,"max_tokens_setting":2048}
+{"idx":199834,"func":"ins_compl_stop(int c, int prev_mode, int retval)\n{\n    char_u\t*ptr;\n    int\t\twant_cindent;\n\n    \/\/ Get here when we have finished typing a sequence of ^N and\n    \/\/ ^P or other completion characters in CTRL-X mode.  Free up\n    \/\/ memory that was used, and make sure we can redo the insert.\n    if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E)\n    {\n\t\/\/ If any of the original typed text has been changed, eg when\n\t\/\/ ignorecase is set, we must add back-spaces to the redo\n\t\/\/ buffer.  We add as few as necessary to delete just the part\n\t\/\/ of the original text that has changed.\n\t\/\/ When using the longest match, edited the match or used\n\t\/\/ CTRL-E then don't use the current match.\n\tif (compl_curr_match != NULL && compl_used_match && c != Ctrl_E)\n\t    ptr = compl_curr_match->cp_str;\n\telse\n\t    ptr = NULL;\n\tins_compl_fixRedoBufForLeader(ptr);\n    }\n\n    want_cindent = (get_can_cindent() && cindent_on());\n\n    \/\/ When completing whole lines: fix indent for 'cindent'.\n    \/\/ Otherwise, break line if it's too long.\n    if (compl_cont_mode == CTRL_X_WHOLE_LINE)\n    {\n\t\/\/ re-indent the current line\n\tif (want_cindent)\n\t{\n\t    do_c_expr_indent();\n\t    want_cindent = FALSE;\t\/\/ don't do it again\n\t}\n    }\n    else\n    {\n\tint prev_col = curwin->w_cursor.col;\n\n\t\/\/ put the cursor on the last char, for 'tw' formatting\n\tif (prev_col > 0)\n\t    dec_cursor();\n\t\/\/ only format when something was inserted\n\tif (!arrow_used && !ins_need_undo_get() && c != Ctrl_E)\n\t    insertchar(NUL, 0, -1);\n\tif (prev_col > 0\n\t\t&& ml_get_curline()[curwin->w_cursor.col] != NUL)\n\t    inc_cursor();\n    }\n\n    \/\/ If the popup menu is displayed pressing CTRL-Y means accepting\n    \/\/ the selection without inserting anything.  When\n    \/\/ compl_enter_selects is set the Enter key does the same.\n    if ((c == Ctrl_Y || (compl_enter_selects\n\t\t    && (c == CAR || c == K_KENTER || c == NL)))\n\t    && pum_visible())\n\tretval = TRUE;\n\n    \/\/ CTRL-E means completion is Ended, go back to the typed text.\n    \/\/ but only do this, if the Popup is still visible\n    if (c == Ctrl_E)\n    {\n\tins_compl_delete();\n\tif (compl_leader != NULL)\n\t    ins_bytes(compl_leader + get_compl_len());\n\telse if (compl_first_match != NULL)\n\t    ins_bytes(compl_orig_text + get_compl_len());\n\tretval = TRUE;\n    }\n\n    auto_format(FALSE, TRUE);\n\n    \/\/ Trigger the CompleteDonePre event to give scripts a chance to\n    \/\/ act upon the completion before clearing the info, and restore\n    \/\/ ctrl_x_mode, so that complete_info() can be used.\n    ctrl_x_mode = prev_mode;\n    ins_apply_autocmds(EVENT_COMPLETEDONEPRE);\n\n    ins_compl_free();\n    compl_started = FALSE;\n    compl_matches = 0;\n    if (!shortmess(SHM_COMPLETIONMENU))\n\tmsg_clr_cmdline();\t\/\/ necessary for \"noshowmode\"\n    ctrl_x_mode = CTRL_X_NORMAL;\n    compl_enter_selects = FALSE;\n    if (edit_submode != NULL)\n    {\n\tedit_submode = NULL;\n\tshowmode();\n    }\n\n#ifdef FEAT_CMDWIN\n    if (c == Ctrl_C && cmdwin_type != 0)\n\t\/\/ Avoid the popup menu remains displayed when leaving the\n\t\/\/ command line window.\n\tupdate_screen(0);\n#endif\n    \/\/ Indent now if a key was typed that is in 'cinkeys'.\n    if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0)))\n\tdo_c_expr_indent();\n    \/\/ Trigger the CompleteDone event to give scripts a chance to act\n    \/\/ upon the end of completion.\n    ins_apply_autocmds(EVENT_COMPLETEDONE);\n\n    return retval;\n}","target":1,"code_token_length":909,"total_token_length":1145,"max_tokens_setting":2048}
+{"idx":253572,"func":"static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,\n\t\t\t    loff_t off, loff_t len, bool keep_size)\n{\n\tstruct inode *inode;\n\tstruct cifsInodeInfo *cifsi;\n\tstruct cifsFileInfo *cfile = file->private_data;\n\tlong rc = -EOPNOTSUPP;\n\tunsigned int xid;\n\t__le64 eof;\n\n\txid = get_xid();\n\n\tinode = d_inode(cfile->dentry);\n\tcifsi = CIFS_I(inode);\n\n\ttrace_smb3_falloc_enter(xid, cfile->fid.persistent_fid, tcon->tid,\n\t\t\t\ttcon->ses->Suid, off, len);\n\t\/* if file not oplocked can't be sure whether asking to extend size *\/\n\tif (!CIFS_CACHE_READ(cifsi))\n\t\tif (keep_size == false) {\n\t\t\ttrace_smb3_falloc_err(xid, cfile->fid.persistent_fid,\n\t\t\t\ttcon->tid, tcon->ses->Suid, off, len, rc);\n\t\t\tfree_xid(xid);\n\t\t\treturn rc;\n\t\t}\n\n\t\/*\n\t * Extending the file\n\t *\/\n\tif ((keep_size == false) && i_size_read(inode) < off + len) {\n\t\trc = inode_newsize_ok(inode, off + len);\n\t\tif (rc)\n\t\t\tgoto out;\n\n\t\tif ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0)\n\t\t\tsmb2_set_sparse(xid, tcon, cfile, inode, false);\n\n\t\teof = cpu_to_le64(off + len);\n\t\trc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,\n\t\t\t\t  cfile->fid.volatile_fid, cfile->pid, &eof);\n\t\tif (rc == 0) {\n\t\t\tcifsi->server_eof = off + len;\n\t\t\tcifs_setsize(inode, off + len);\n\t\t\tcifs_truncate_page(inode->i_mapping, inode->i_size);\n\t\t\ttruncate_setsize(inode, off + len);\n\t\t}\n\t\tgoto out;\n\t}\n\n\t\/*\n\t * Files are non-sparse by default so falloc may be a no-op\n\t * Must check if file sparse. If not sparse, and since we are not\n\t * extending then no need to do anything since file already allocated\n\t *\/\n\tif ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {\n\t\trc = 0;\n\t\tgoto out;\n\t}\n\n\tif (keep_size == true) {\n\t\t\/*\n\t\t * We can not preallocate pages beyond the end of the file\n\t\t * in SMB2\n\t\t *\/\n\t\tif (off >= i_size_read(inode)) {\n\t\t\trc = 0;\n\t\t\tgoto out;\n\t\t}\n\t\t\/*\n\t\t * For fallocates that are partially beyond the end of file,\n\t\t * clamp len so we only fallocate up to the end of file.\n\t\t *\/\n\t\tif (off + len > i_size_read(inode)) {\n\t\t\tlen = i_size_read(inode) - off;\n\t\t}\n\t}\n\n\tif ((keep_size == true) || (i_size_read(inode) >= off + len)) {\n\t\t\/*\n\t\t * At this point, we are trying to fallocate an internal\n\t\t * regions of a sparse file. Since smb2 does not have a\n\t\t * fallocate command we have two otions on how to emulate this.\n\t\t * We can either turn the entire file to become non-sparse\n\t\t * which we only do if the fallocate is for virtually\n\t\t * the whole file,  or we can overwrite the region with zeroes\n\t\t * using SMB2_write, which could be prohibitevly expensive\n\t\t * if len is large.\n\t\t *\/\n\t\t\/*\n\t\t * We are only trying to fallocate a small region so\n\t\t * just write it with zero.\n\t\t *\/\n\t\tif (len <= 1024 * 1024) {\n\t\t\trc = smb3_simple_fallocate_range(xid, tcon, cfile,\n\t\t\t\t\t\t\t off, len);\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/*\n\t\t * Check if falloc starts within first few pages of file\n\t\t * and ends within a few pages of the end of file to\n\t\t * ensure that most of file is being forced to be\n\t\t * fallocated now. If so then setting whole file sparse\n\t\t * ie potentially making a few extra pages at the beginning\n\t\t * or end of the file non-sparse via set_sparse is harmless.\n\t\t *\/\n\t\tif ((off > 8192) || (off + len + 8192 < i_size_read(inode))) {\n\t\t\trc = -EOPNOTSUPP;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tsmb2_set_sparse(xid, tcon, cfile, inode, false);\n\trc = 0;\n\nout:\n\tif (rc)\n\t\ttrace_smb3_falloc_err(xid, cfile->fid.persistent_fid, tcon->tid,\n\t\t\t\ttcon->ses->Suid, off, len, rc);\n\telse\n\t\ttrace_smb3_falloc_done(xid, cfile->fid.persistent_fid, tcon->tid,\n\t\t\t\ttcon->ses->Suid, off, len);\n\n\tfree_xid(xid);\n\treturn rc;\n}","target":0,"code_token_length":1126,"total_token_length":1362,"max_tokens_setting":2048}
+{"idx":362299,"func":"static int usb_audio_probe(struct usb_interface *intf,\n\t\t\t   const struct usb_device_id *usb_id)\n{\n\tstruct usb_device *dev = interface_to_usbdev(intf);\n\tconst struct snd_usb_audio_quirk *quirk =\n\t\t(const struct snd_usb_audio_quirk *)usb_id->driver_info;\n\tstruct snd_usb_audio *chip;\n\tint i, err;\n\tstruct usb_host_interface *alts;\n\tint ifnum;\n\tu32 id;\n\n\talts = &intf->altsetting[0];\n\tifnum = get_iface_desc(alts)->bInterfaceNumber;\n\tid = USB_ID(le16_to_cpu(dev->descriptor.idVendor),\n\t\t    le16_to_cpu(dev->descriptor.idProduct));\n\tif (get_alias_id(dev, &id))\n\t\tquirk = get_alias_quirk(dev, id);\n\tif (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum)\n\t\treturn -ENXIO;\n\n\terr = snd_usb_apply_boot_quirk(dev, intf, quirk, id);\n\tif (err < 0)\n\t\treturn err;\n\n\t\/*\n\t * found a config.  now register to ALSA\n\t *\/\n\n\t\/* check whether it's already registered *\/\n\tchip = NULL;\n\tmutex_lock(®ister_mutex);\n\tfor (i = 0; i < SNDRV_CARDS; i++) {\n\t\tif (usb_chip[i] && usb_chip[i]->dev == dev) {\n\t\t\tif (atomic_read(&usb_chip[i]->shutdown)) {\n\t\t\t\tdev_err(&dev->dev, \"USB device is in the shutdown state, cannot create a card instance\\n\");\n\t\t\t\terr = -EIO;\n\t\t\t\tgoto __error;\n\t\t\t}\n\t\t\tchip = usb_chip[i];\n\t\t\tatomic_inc(&chip->active); \/* avoid autopm *\/\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (! chip) {\n\t\t\/* it's a fresh one.\n\t\t * now look for an empty slot and create a new card instance\n\t\t *\/\n\t\tfor (i = 0; i < SNDRV_CARDS; i++)\n\t\t\tif (!usb_chip[i] &&\n\t\t\t    (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&\n\t\t\t    (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {\n\t\t\t\tif (enable[i]) {\n\t\t\t\t\terr = snd_usb_audio_create(intf, dev, i, quirk,\n\t\t\t\t\t\t\t\t   id, &chip);\n\t\t\t\t\tif (err < 0)\n\t\t\t\t\t\tgoto __error;\n\t\t\t\t\tchip->pm_intf = intf;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (vid[i] != -1 || pid[i] != -1) {\n\t\t\t\t\tdev_info(&dev->dev,\n\t\t\t\t\t\t \"device (%04x:%04x) is disabled\\n\",\n\t\t\t\t\t\t USB_ID_VENDOR(id),\n\t\t\t\t\t\t USB_ID_PRODUCT(id));\n\t\t\t\t\terr = -ENOENT;\n\t\t\t\t\tgoto __error;\n\t\t\t\t}\n\t\t\t}\n\t\tif (!chip) {\n\t\t\tdev_err(&dev->dev, \"no available usb audio device\\n\");\n\t\t\terr = -ENODEV;\n\t\t\tgoto __error;\n\t\t}\n\t}\n\tdev_set_drvdata(&dev->dev, chip);\n\n\t\/*\n\t * For devices with more than one control interface, we assume the\n\t * first contains the audio controls. We might need a more specific\n\t * check here in the future.\n\t *\/\n\tif (!chip->ctrl_intf)\n\t\tchip->ctrl_intf = alts;\n\n\tchip->txfr_quirk = 0;\n\terr = 1; \/* continue *\/\n\tif (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) {\n\t\t\/* need some special handlings *\/\n\t\terr = snd_usb_create_quirk(chip, intf, &usb_audio_driver, quirk);\n\t\tif (err < 0)\n\t\t\tgoto __error;\n\t}\n\n\tif (err > 0) {\n\t\t\/* create normal USB audio interfaces *\/\n\t\terr = snd_usb_create_streams(chip, ifnum);\n\t\tif (err < 0)\n\t\t\tgoto __error;\n\t\terr = snd_usb_create_mixer(chip, ifnum, ignore_ctl_error);\n\t\tif (err < 0)\n\t\t\tgoto __error;\n\t}\n\n\t\/* we are allowed to call snd_card_register() many times *\/\n\terr = snd_card_register(chip->card);\n\tif (err < 0)\n\t\tgoto __error;\n\n\tusb_chip[chip->index] = chip;\n\tchip->num_interfaces++;\n\tusb_set_intfdata(intf, chip);\n\tatomic_dec(&chip->active);\n\tmutex_unlock(®ister_mutex);\n\treturn 0;\n\n __error:\n\tif (chip) {\n\t\t\/* chip->active is inside the chip->card object,\n\t\t * decrement before memory is possibly returned.\n\t\t *\/\n\t\tatomic_dec(&chip->active);\n\t\tif (!chip->num_interfaces)\n\t\t\tsnd_card_free(chip->card);\n\t}\n\tmutex_unlock(®ister_mutex);\n\treturn err;\n}","target":0,"code_token_length":1012,"total_token_length":1248,"max_tokens_setting":2048}
+{"idx":346464,"func":"add_pack_dir_to_rtp(char_u *fname)\n{\n    char_u  *p4, *p3, *p2, *p1, *p;\n    char_u  *entry;\n    char_u  *insp = NULL;\n    int\t    c;\n    char_u  *new_rtp;\n    int\t    keep;\n    size_t  oldlen;\n    size_t  addlen;\n    size_t  new_rtp_len;\n    char_u  *afterdir = NULL;\n    size_t  afterlen = 0;\n    char_u  *after_insp = NULL;\n    char_u  *ffname = NULL;\n    size_t  fname_len;\n    char_u  *buf = NULL;\n    char_u  *rtp_ffname;\n    int\t    match;\n    int\t    retval = FAIL;\n\n    p4 = p3 = p2 = p1 = get_past_head(fname);\n    for (p = p1; *p; MB_PTR_ADV(p))\n\tif (vim_ispathsep_nocolon(*p))\n\t{\n\t    p4 = p3; p3 = p2; p2 = p1; p1 = p;\n\t}\n\n    \/\/ now we have:\n    \/\/ rtp\/pack\/name\/start\/name\n    \/\/    p4   p3   p2    p1\n    \/\/\n    \/\/ find the part up to \"pack\" in 'runtimepath'\n    c = *++p4; \/\/ append pathsep in order to expand symlink\n    *p4 = NUL;\n    ffname = fix_fname(fname);\n    *p4 = c;\n    if (ffname == NULL)\n\treturn FAIL;\n\n    \/\/ Find \"ffname\" in \"p_rtp\", ignoring '\/' vs '\\' differences.\n    \/\/ Also stop at the first \"after\" directory.\n    fname_len = STRLEN(ffname);\n    buf = alloc(MAXPATHL);\n    if (buf == NULL)\n\tgoto theend;\n    for (entry = p_rtp; *entry != NUL; )\n    {\n\tchar_u *cur_entry = entry;\n\n\tcopy_option_part(&entry, buf, MAXPATHL, \",\");\n\tif (insp == NULL)\n\t{\n\t    add_pathsep(buf);\n\t    rtp_ffname = fix_fname(buf);\n\t    if (rtp_ffname == NULL)\n\t\tgoto theend;\n\t    match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;\n\t    vim_free(rtp_ffname);\n\t    if (match)\n\t\t\/\/ Insert \"ffname\" after this entry (and comma).\n\t\tinsp = entry;\n\t}\n\n\tif ((p = (char_u *)strstr((char *)buf, \"after\")) != NULL\n\t\t&& p > buf\n\t\t&& vim_ispathsep(p[-1])\n\t\t&& (vim_ispathsep(p[5]) || p[5] == NUL || p[5] == ','))\n\t{\n\t    if (insp == NULL)\n\t\t\/\/ Did not find \"ffname\" before the first \"after\" directory,\n\t\t\/\/ insert it before this entry.\n\t\tinsp = cur_entry;\n\t    after_insp = cur_entry;\n\t    break;\n\t}\n    }\n\n    if (insp == NULL)\n\t\/\/ Both \"fname\" and \"after\" not found, append at the end.\n\tinsp = p_rtp + STRLEN(p_rtp);\n\n    \/\/ check if rtp\/pack\/name\/start\/name\/after exists\n    afterdir = concat_fnames(fname, (char_u *)\"after\", TRUE);\n    if (afterdir != NULL && mch_isdir(afterdir))\n\tafterlen = STRLEN(afterdir) + 1; \/\/ add one for comma\n\n    oldlen = STRLEN(p_rtp);\n    addlen = STRLEN(fname) + 1; \/\/ add one for comma\n    new_rtp = alloc(oldlen + addlen + afterlen + 1); \/\/ add one for NUL\n    if (new_rtp == NULL)\n\tgoto theend;\n\n    \/\/ We now have 'rtp' parts: {keep}{keep_after}{rest}.\n    \/\/ Create new_rtp, first: {keep},{fname}\n    keep = (int)(insp - p_rtp);\n    mch_memmove(new_rtp, p_rtp, keep);\n    new_rtp_len = keep;\n    if (*insp == NUL)\n\tnew_rtp[new_rtp_len++] = ',';  \/\/ add comma before\n    mch_memmove(new_rtp + new_rtp_len, fname, addlen - 1);\n    new_rtp_len += addlen - 1;\n    if (*insp != NUL)\n\tnew_rtp[new_rtp_len++] = ',';  \/\/ add comma after\n\n    if (afterlen > 0 && after_insp != NULL)\n    {\n\tint keep_after = (int)(after_insp - p_rtp);\n\n\t\/\/ Add to new_rtp: {keep},{fname}{keep_after},{afterdir}\n\tmch_memmove(new_rtp + new_rtp_len, p_rtp + keep,\n\t\t\t\t\t\t\tkeep_after - keep);\n\tnew_rtp_len += keep_after - keep;\n\tmch_memmove(new_rtp + new_rtp_len, afterdir, afterlen - 1);\n\tnew_rtp_len += afterlen - 1;\n\tnew_rtp[new_rtp_len++] = ',';\n\tkeep = keep_after;\n    }\n\n    if (p_rtp[keep] != NUL)\n\t\/\/ Append rest: {keep},{fname}{keep_after},{afterdir}{rest}\n\tmch_memmove(new_rtp + new_rtp_len, p_rtp + keep, oldlen - keep + 1);\n    else\n\tnew_rtp[new_rtp_len] = NUL;\n\n    if (afterlen > 0 && after_insp == NULL)\n    {\n\t\/\/ Append afterdir when \"after\" was not found:\n\t\/\/ {keep},{fname}{rest},{afterdir}\n\tSTRCAT(new_rtp, \",\");\n\tSTRCAT(new_rtp, afterdir);\n    }\n\n    set_option_value_give_err((char_u *)\"rtp\", 0L, new_rtp, 0);\n    vim_free(new_rtp);\n    retval = OK;\n\ntheend:\n    vim_free(buf);\n    vim_free(ffname);\n    vim_free(afterdir);\n    return retval;\n}","target":0,"code_token_length":1334,"total_token_length":1570,"max_tokens_setting":2048}
+{"idx":257457,"func":"TEST_F(AutoParallelTest, SimpleParallel) {\n  tensorflow::Scope s = tensorflow::Scope::DisabledShapeInferenceScope();\n  Output constant_a = ops::Const(s.WithOpName(\"constant_a\"), 1.0f, {1});\n  Output constant_b = ops::Const(s.WithOpName(\"constant_b\"), 1, {1});\n  Output var = ops::Variable(s.WithOpName(\"var\"), {1}, DT_FLOAT);\n  Output assign = ops::Assign(s.WithOpName(\"assign\"), {var}, {constant_a});\n  Output identity = ops::Identity(s.WithOpName(\"identity\"), {var});\n  Output fifo_queue = ops::FIFOQueue(s.WithOpName(\"fifo_queue\"), {DT_FLOAT});\n  auto dequeue = ops::QueueDequeueMany(s.WithOpName(\"dequeue\"), {fifo_queue},\n                                       {constant_b}, {DT_FLOAT});\n  Output add = ops::AddN(s.WithOpName(\"add\"), {constant_a, dequeue[0]});\n  Output learning_rate = ops::Const(s.WithOpName(\"learning_rate\"), 0.01f, {1});\n  Output apply_gradient = ops::ApplyGradientDescent(\n      s.WithOpName(\"apply_gradient\"), {var}, {learning_rate}, {add});\n\n  GrapplerItem item;\n  item.init_ops.push_back(\"assign\");\n  item.fetch.push_back(\"apply_gradient\");\n  item.init_ops.push_back(\"assign\");\n  TF_CHECK_OK(s.ToGraphDef(&item.graph));\n\n  AutoParallel parallel(2);\n  GraphDef output;\n  Status status = parallel.Optimize(nullptr, item, &output);\n  TF_EXPECT_OK(status);\n  EXPECT_EQ(21, output.node_size());\n\n  const NodeDef& node_assign = output.node(0);\n  EXPECT_EQ(\"assign\", node_assign.name());\n  EXPECT_EQ(\"AutoParallel-Replica-0\/constant_a\", node_assign.input(1));\n\n  const NodeDef& node_constant_b = output.node(1);\n  EXPECT_EQ(\"constant_b\", node_constant_b.name());\n\n  const NodeDef& node_fifo_queue = output.node(2);\n  EXPECT_EQ(\"fifo_queue\", node_fifo_queue.name());\n\n  const NodeDef& node_identity = output.node(3);\n  EXPECT_EQ(\"identity\", node_identity.name());\n  EXPECT_EQ(\"var\", node_identity.input(0));\n\n  const NodeDef& node_var = output.node(4);\n  EXPECT_EQ(\"var\", node_var.name());\n\n  const NodeDef& node_div_const0 = output.node(5);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/AutoParallel-Div-Const\",\n            node_div_const0.name());\n\n  const NodeDef& node_div0 = output.node(6);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/AutoParallel-Div-apply_gradient\",\n            node_div0.name());\n  const NodeDef& node_add0 = output.node(7);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/add\", node_add0.name());\n\n  const NodeDef& node_gradient0 = output.node(8);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/apply_gradient\", node_gradient0.name());\n\n  const NodeDef& node_constant_a0 = output.node(9);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/constant_a\", node_constant_a0.name());\n\n  const NodeDef& node_dequeue0 = output.node(10);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/dequeue\", node_dequeue0.name());\n\n  const NodeDef& node_learning_rate0 = output.node(11);\n  EXPECT_EQ(\"AutoParallel-Replica-0\/learning_rate\", node_learning_rate0.name());\n\n  const NodeDef& node_div_const1 = output.node(12);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/AutoParallel-Div-Const\",\n            node_div_const1.name());\n\n  const NodeDef& node_div1 = output.node(13);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/AutoParallel-Div-apply_gradient\",\n            node_div1.name());\n\n  const NodeDef& node_add1 = output.node(14);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/add\", node_add1.name());\n\n  const NodeDef& node_gradient1 = output.node(15);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/apply_gradient\", node_gradient1.name());\n\n  const NodeDef& node_constant_a1 = output.node(16);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/constant_a\", node_constant_a1.name());\n\n  const NodeDef& node_dequeue1 = output.node(17);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/dequeue\", node_dequeue1.name());\n\n  const NodeDef& node_learning_rate1 = output.node(18);\n  EXPECT_EQ(\"AutoParallel-Replica-1\/learning_rate\", node_learning_rate1.name());\n\n  const NodeDef& node_fetch = output.node(19);\n  EXPECT_EQ(\"AutoParallel-Control-Fetch\", node_fetch.name());\n  EXPECT_EQ(\"^AutoParallel-Replica-0\/apply_gradient\", node_fetch.input(0));\n  EXPECT_EQ(\"^AutoParallel-Replica-1\/apply_gradient\", node_fetch.input(1));\n\n  const NodeDef& node_gradient = output.node(20);\n  EXPECT_EQ(\"apply_gradient\", node_gradient.name());\n  EXPECT_EQ(\"^AutoParallel-Control-Fetch\", node_gradient.input(0));\n}","target":0,"code_token_length":1138,"total_token_length":1374,"max_tokens_setting":2048}
+{"idx":198146,"func":"  void Compute(OpKernelContext* const context) override {\n    \/\/ node_id_range\n    const Tensor* node_id_range_t;\n    OP_REQUIRES_OK(context, context->input(\"node_id_range\", &node_id_range_t));\n    const auto node_id_range = node_id_range_t->vec<int32>();\n    const int32_t node_id_first = node_id_range(0);  \/\/ inclusive\n    const int32_t node_id_last = node_id_range(1);   \/\/ exclusive\n\n    const Tensor* stats_summary_t;\n    OP_REQUIRES_OK(context, context->input(\"stats_summary\", &stats_summary_t));\n    TTypes<float, 4>::ConstTensor stats_summary =\n        stats_summary_t->tensor<float, 4>();\n    const int32_t feature_dims = stats_summary_t->dim_size(1);\n    \/\/ The last bucket is for default\/missing value.\n    const int32_t num_buckets = stats_summary_t->dim_size(2) - 1;\n    const int32_t logits_dim = logits_dim_;\n    const int32_t hessian_dim = stats_summary_t->dim_size(3) - logits_dim;\n    DCHECK_GT(hessian_dim, 0);\n    DCHECK_LE(hessian_dim, logits_dim * logits_dim);\n\n    const Tensor* l1_t;\n    OP_REQUIRES_OK(context, context->input(\"l1\", &l1_t));\n    const auto l1 = l1_t->scalar<float>()();\n    DCHECK_GE(l1, 0);\n    if (logits_dim_ > 1) {\n      \/\/ Multi-class L1 regularization not supported yet.\n      DCHECK_EQ(l1, 0);\n    }\n\n    const Tensor* l2_t;\n    OP_REQUIRES_OK(context, context->input(\"l2\", &l2_t));\n    const auto l2 = l2_t->scalar<float>()();\n    DCHECK_GE(l2, 0);\n\n    const Tensor* tree_complexity_t;\n    OP_REQUIRES_OK(context,\n                   context->input(\"tree_complexity\", &tree_complexity_t));\n    const auto tree_complexity = tree_complexity_t->scalar<float>()();\n\n    const Tensor* min_node_weight_t;\n    OP_REQUIRES_OK(context,\n                   context->input(\"min_node_weight\", &min_node_weight_t));\n    const auto min_node_weight = min_node_weight_t->scalar<float>()();\n\n    std::vector<int32> output_node_ids;\n    std::vector<float> output_gains;\n    std::vector<int32> output_feature_dimensions;\n    std::vector<int32> output_thresholds;\n    std::vector<Eigen::VectorXf> output_left_node_contribs;\n    std::vector<Eigen::VectorXf> output_right_node_contribs;\n    std::vector<string> output_split_types;\n\n    \/\/ TODO(tanzheny) parallelize the computation.\n    \/\/ Iterate each node and find the best gain per node.\n    for (int32_t node_id = node_id_first; node_id < node_id_last; ++node_id) {\n      float best_gain = std::numeric_limits<float>::lowest();\n      int32_t best_bucket = 0;\n      int32_t best_f_dim = 0;\n      string best_split_type;\n      Eigen::VectorXf best_contrib_for_left(logits_dim);\n      Eigen::VectorXf best_contrib_for_right(logits_dim);\n      float parent_gain;\n\n      \/\/ Including default bucket.\n      ConstMatrixMap stats_mat(&stats_summary(node_id, 0, 0, 0),\n                               num_buckets + 1, logits_dim + hessian_dim);\n      const Eigen::VectorXf total_grad =\n          stats_mat.leftCols(logits_dim).colwise().sum();\n      const Eigen::VectorXf total_hess =\n          stats_mat.rightCols(hessian_dim).colwise().sum();\n      if (total_hess.norm() < min_node_weight) {\n        continue;\n      }\n      Eigen::VectorXf parent_weight(logits_dim);\n      CalculateWeightsAndGains(total_grad, total_hess, l1, l2, &parent_weight,\n                               &parent_gain);\n\n      if (split_type_ == \"inequality\") {\n        CalculateBestInequalitySplit(\n            stats_summary, node_id, feature_dims, logits_dim, hessian_dim,\n            num_buckets, min_node_weight, l1, l2, &best_gain, &best_bucket,\n            &best_f_dim, &best_split_type, &best_contrib_for_left,\n            &best_contrib_for_right);\n      } else {\n        CalculateBestEqualitySplit(\n            stats_summary, total_grad, total_hess, node_id, feature_dims,\n            logits_dim, hessian_dim, num_buckets, l1, l2, &best_gain,\n            &best_bucket, &best_f_dim, &best_split_type, &best_contrib_for_left,\n            &best_contrib_for_right);\n      }\n\n      if (best_gain == std::numeric_limits<float>::lowest()) {\n        \/\/ Do not add the node if not split if found.\n        continue;\n      }\n      output_node_ids.push_back(node_id);\n      \/\/ Remove the parent gain for the parent node.\n      output_gains.push_back(best_gain - parent_gain);\n      output_feature_dimensions.push_back(best_f_dim);\n      \/\/ default direction is fixed for dense splits.\n      \/\/ TODO(tanzheny) account for default values.\n      output_split_types.push_back(best_split_type);\n      output_thresholds.push_back(best_bucket);\n      output_left_node_contribs.push_back(best_contrib_for_left);\n      output_right_node_contribs.push_back(best_contrib_for_right);\n    }  \/\/ for node id\n    const int num_nodes = output_node_ids.size();\n    \/\/ output_node_ids\n    Tensor* output_node_ids_t = nullptr;\n    OP_REQUIRES_OK(context, context->allocate_output(\"node_ids\", {num_nodes},\n                                                     &output_node_ids_t));\n    auto output_node_ids_vec = output_node_ids_t->vec<int32>();\n\n    \/\/ output_gains\n    Tensor* output_gains_t;\n    OP_REQUIRES_OK(context, context->allocate_output(\"gains\", {num_nodes},\n                                                     &output_gains_t));\n    auto output_gains_vec = output_gains_t->vec<float>();\n\n    \/\/ output_feature_dimensions\n    Tensor* output_feature_dimension_t;\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(\"feature_dimensions\", {num_nodes},\n                                            &output_feature_dimension_t));\n    auto output_feature_dimensions_vec =\n        output_feature_dimension_t->vec<int32>();\n\n    \/\/ output_thresholds\n    Tensor* output_thresholds_t;\n    OP_REQUIRES_OK(context, context->allocate_output(\"thresholds\", {num_nodes},\n                                                     &output_thresholds_t));\n    auto output_thresholds_vec = output_thresholds_t->vec<int32>();\n\n    \/\/ output_left_node_contribs\n    Tensor* output_left_node_contribs_t;\n    OP_REQUIRES_OK(context, context->allocate_output(\n                                \"left_node_contribs\", {num_nodes, logits_dim},\n                                &output_left_node_contribs_t));\n    auto output_left_node_contribs_matrix =\n        output_left_node_contribs_t->matrix<float>();\n\n    \/\/ output_right_node_contribs\n    Tensor* output_right_node_contribs_t;\n    OP_REQUIRES_OK(context, context->allocate_output(\n                                \"right_node_contribs\", {num_nodes, logits_dim},\n                                &output_right_node_contribs_t));\n    auto output_right_node_contribs_matrix =\n        output_right_node_contribs_t->matrix<float>();\n\n    \/\/ split type\n    Tensor* output_split_types_t;\n    OP_REQUIRES_OK(\n        context, context->allocate_output(\"split_with_default_directions\",\n                                          {num_nodes}, &output_split_types_t));\n    auto output_split_types_vec = output_split_types_t->vec<tstring>();\n\n    \/\/ Sets output tensors from vectors.\n    for (int i = 0; i < num_nodes; ++i) {\n      output_node_ids_vec(i) = output_node_ids[i];\n      \/\/ Adjust the gains to penalize by tree complexity.\n      output_gains_vec(i) = output_gains[i] - tree_complexity;\n      output_feature_dimensions_vec(i) = output_feature_dimensions[i];\n      output_thresholds_vec(i) = output_thresholds[i];\n      for (int j = 0; j < logits_dim; ++j) {\n        output_left_node_contribs_matrix(i, j) =\n            output_left_node_contribs[i][j];\n        output_right_node_contribs_matrix(i, j) =\n            output_right_node_contribs[i][j];\n      }\n      output_split_types_vec(i) = output_split_types[i];\n    }\n  }","target":1,"code_token_length":1790,"total_token_length":2026,"max_tokens_setting":2048}
+{"idx":439503,"func":"static struct inode *read_inode(unsigned int start_block, unsigned int offset)\n{\n\tstatic union squashfs_inode_header_3 header;\n\tlong long start = sBlk.s.inode_table_start + start_block;\n\tint bytes = lookup_entry(inode_table_hash, start);\n\tchar *block_ptr = inode_table + bytes + offset;\n\tstatic struct inode i;\n\n\tTRACE(\"read_inode: reading inode [%d:%d]\\n\", start_block,  offset);\n\n\tif(bytes == -1)\n\t\tEXIT_UNSQUASH(\"read_inode: inode table block %lld not found\\n\",\n\t\t\tstart); \n\n\tif(swap) {\n\t\tsquashfs_base_inode_header_3 sinode;\n\t\tmemcpy(&sinode, block_ptr, sizeof(header.base));\n\t\tSQUASHFS_SWAP_BASE_INODE_HEADER_3(&header.base, &sinode,\n\t\t\tsizeof(squashfs_base_inode_header_3));\n\t} else\n\t\tmemcpy(&header.base, block_ptr, sizeof(header.base));\n\n\ti.xattr = SQUASHFS_INVALID_XATTR;\n\ti.uid = (uid_t) uid_table[header.base.uid];\n\ti.gid = header.base.guid == SQUASHFS_GUIDS ? i.uid :\n\t\t(uid_t) guid_table[header.base.guid];\n\ti.mode = lookup_type[header.base.inode_type] | header.base.mode;\n\ti.type = header.base.inode_type;\n\ti.time = header.base.mtime;\n\ti.inode_number = header.base.inode_number;\n\n\tswitch(header.base.inode_type) {\n\t\tcase SQUASHFS_DIR_TYPE: {\n\t\t\tsquashfs_dir_inode_header_3 *inode = &header.dir;\n\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_inode_header_3 sinode;\n\t\t\t\tmemcpy(&sinode, block_ptr, sizeof(header.dir));\n\t\t\t\tSQUASHFS_SWAP_DIR_INODE_HEADER_3(&header.dir,\n\t\t\t\t\t&sinode);\n\t\t\t} else\n\t\t\t\tmemcpy(&header.dir, block_ptr,\n\t\t\t\t\tsizeof(header.dir));\n\n\t\t\ti.data = inode->file_size;\n\t\t\ti.offset = inode->offset;\n\t\t\ti.start = inode->start_block;\n\t\t\tbreak;\n\t\t}\n\t\tcase SQUASHFS_LDIR_TYPE: {\n\t\t\tsquashfs_ldir_inode_header_3 *inode = &header.ldir;\n\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_ldir_inode_header_3 sinode;\n\t\t\t\tmemcpy(&sinode, block_ptr, sizeof(header.ldir));\n\t\t\t\tSQUASHFS_SWAP_LDIR_INODE_HEADER_3(&header.ldir,\n\t\t\t\t\t&sinode);\n\t\t\t} else\n\t\t\t\tmemcpy(&header.ldir, block_ptr,\n\t\t\t\t\tsizeof(header.ldir));\n\n\t\t\ti.data = inode->file_size;\n\t\t\ti.offset = inode->offset;\n\t\t\ti.start = inode->start_block;\n\t\t\tbreak;\n\t\t}\n\t\tcase SQUASHFS_FILE_TYPE: {\n\t\t\tsquashfs_reg_inode_header_3 *inode = &header.reg;\n\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_reg_inode_header_3 sinode;\n\t\t\t\tmemcpy(&sinode, block_ptr, sizeof(sinode));\n\t\t\t\tSQUASHFS_SWAP_REG_INODE_HEADER_3(inode,\n\t\t\t\t\t&sinode);\n\t\t\t} else\n\t\t\t\tmemcpy(inode, block_ptr, sizeof(*inode));\n\n\t\t\ti.data = inode->file_size;\n\t\t\ti.frag_bytes = inode->fragment == SQUASHFS_INVALID_FRAG\n\t\t\t\t?  0 : inode->file_size % sBlk.s.block_size;\n\t\t\ti.fragment = inode->fragment;\n\t\t\ti.offset = inode->offset;\n\t\t\ti.blocks = inode->fragment == SQUASHFS_INVALID_FRAG ?\n\t\t\t\t(i.data + sBlk.s.block_size - 1) >>\n\t\t\t\tsBlk.s.block_log :\n\t\t\t\ti.data >> sBlk.s.block_log;\n\t\t\ti.start = inode->start_block;\n\t\t\ti.sparse = 1;\n\t\t\ti.block_ptr = block_ptr + sizeof(*inode);\n\t\t\tbreak;\n\t\t}\t\n\t\tcase SQUASHFS_LREG_TYPE: {\n\t\t\tsquashfs_lreg_inode_header_3 *inode = &header.lreg;\n\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_lreg_inode_header_3 sinode;\n\t\t\t\tmemcpy(&sinode, block_ptr, sizeof(sinode));\n\t\t\t\tSQUASHFS_SWAP_LREG_INODE_HEADER_3(inode,\n\t\t\t\t\t&sinode);\n\t\t\t} else\n\t\t\t\tmemcpy(inode, block_ptr, sizeof(*inode));\n\n\t\t\ti.data = inode->file_size;\n\t\t\ti.frag_bytes = inode->fragment == SQUASHFS_INVALID_FRAG\n\t\t\t\t?  0 : inode->file_size % sBlk.s.block_size;\n\t\t\ti.fragment = inode->fragment;\n\t\t\ti.offset = inode->offset;\n\t\t\ti.blocks = inode->fragment == SQUASHFS_INVALID_FRAG ?\n\t\t\t\t(inode->file_size + sBlk.s.block_size - 1) >>\n\t\t\t\tsBlk.s.block_log :\n\t\t\t\tinode->file_size >> sBlk.s.block_log;\n\t\t\ti.start = inode->start_block;\n\t\t\ti.sparse = 1;\n\t\t\ti.block_ptr = block_ptr + sizeof(*inode);\n\t\t\tbreak;\n\t\t}\t\n\t\tcase SQUASHFS_SYMLINK_TYPE: {\n\t\t\tsquashfs_symlink_inode_header_3 *inodep =\n\t\t\t\t&header.symlink;\n\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_symlink_inode_header_3 sinodep;\n\t\t\t\tmemcpy(&sinodep, block_ptr, sizeof(sinodep));\n\t\t\t\tSQUASHFS_SWAP_SYMLINK_INODE_HEADER_3(inodep,\n\t\t\t\t\t&sinodep);\n\t\t\t} else\n\t\t\t\tmemcpy(inodep, block_ptr, sizeof(*inodep));\n\n\t\t\ti.symlink = malloc(inodep->symlink_size + 1);\n\t\t\tif(i.symlink == NULL)\n\t\t\t\tEXIT_UNSQUASH(\"read_inode: failed to malloc \"\n\t\t\t\t\t\"symlink data\\n\");\n\t\t\tstrncpy(i.symlink, block_ptr +\n\t\t\t\tsizeof(squashfs_symlink_inode_header_3),\n\t\t\t\tinodep->symlink_size);\n\t\t\ti.symlink[inodep->symlink_size] = '\\0';\n\t\t\ti.data = inodep->symlink_size;\n\t\t\tbreak;\n\t\t}\n \t\tcase SQUASHFS_BLKDEV_TYPE:\n\t \tcase SQUASHFS_CHRDEV_TYPE: {\n\t\t\tsquashfs_dev_inode_header_3 *inodep = &header.dev;\n\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dev_inode_header_3 sinodep;\n\t\t\t\tmemcpy(&sinodep, block_ptr, sizeof(sinodep));\n\t\t\t\tSQUASHFS_SWAP_DEV_INODE_HEADER_3(inodep,\n\t\t\t\t\t&sinodep);\n\t\t\t} else\n\t\t\t\tmemcpy(inodep, block_ptr, sizeof(*inodep));\n\n\t\t\ti.data = inodep->rdev;\n\t\t\tbreak;\n\t\t\t}\n\t\tcase SQUASHFS_FIFO_TYPE:\n\t\tcase SQUASHFS_SOCKET_TYPE:\n\t\t\ti.data = 0;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tEXIT_UNSQUASH(\"Unknown inode type %d in read_inode!\\n\",\n\t\t\t\theader.base.inode_type);\n\t}\n\treturn &i;\n}","target":0,"code_token_length":1495,"total_token_length":1731,"max_tokens_setting":2048}
+{"idx":278281,"func":"copy_indent(int size, char_u *src)\n{\n    char_u\t*p = NULL;\n    char_u\t*line = NULL;\n    char_u\t*s;\n    int\t\ttodo;\n    int\t\tind_len;\n    int\t\tline_len = 0;\n    int\t\ttab_pad;\n    int\t\tind_done;\n    int\t\tround;\n#ifdef FEAT_VARTABS\n    int\t\tind_col;\n#endif\n\n    \/\/ Round 1: compute the number of characters needed for the indent\n    \/\/ Round 2: copy the characters.\n    for (round = 1; round <= 2; ++round)\n    {\n\ttodo = size;\n\tind_len = 0;\n\tind_done = 0;\n#ifdef FEAT_VARTABS\n\tind_col = 0;\n#endif\n\ts = src;\n\n\t\/\/ Count\/copy the usable portion of the source line\n\twhile (todo > 0 && VIM_ISWHITE(*s))\n\t{\n\t    if (*s == TAB)\n\t    {\n#ifdef FEAT_VARTABS\n\t\ttab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n#else\n\t\ttab_pad = (int)curbuf->b_p_ts\n\t\t\t\t\t   - (ind_done % (int)curbuf->b_p_ts);\n#endif\n\t\t\/\/ Stop if this tab will overshoot the target\n\t\tif (todo < tab_pad)\n\t\t    break;\n\t\ttodo -= tab_pad;\n\t\tind_done += tab_pad;\n#ifdef FEAT_VARTABS\n\t\tind_col += tab_pad;\n#endif\n\t    }\n\t    else\n\t    {\n\t\t--todo;\n\t\t++ind_done;\n#ifdef FEAT_VARTABS\n\t\t++ind_col;\n#endif\n\t    }\n\t    ++ind_len;\n\t    if (p != NULL)\n\t\t*p++ = *s;\n\t    ++s;\n\t}\n\n\t\/\/ Fill to next tabstop with a tab, if possible\n#ifdef FEAT_VARTABS\n\ttab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n#else\n\ttab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);\n#endif\n\tif (todo >= tab_pad && !curbuf->b_p_et)\n\t{\n\t    todo -= tab_pad;\n\t    ++ind_len;\n#ifdef FEAT_VARTABS\n\t    ind_col += tab_pad;\n#endif\n\t    if (p != NULL)\n\t\t*p++ = TAB;\n\t}\n\n\t\/\/ Add tabs required for indent\n\tif (!curbuf->b_p_et)\n\t{\n#ifdef FEAT_VARTABS\n\t    for (;;)\n\t    {\n\t\ttab_pad = tabstop_padding(ind_col, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n\t\tif (todo < tab_pad)\n\t\t    break;\n\t\ttodo -= tab_pad;\n\t\t++ind_len;\n\t\tind_col += tab_pad;\n\t\tif (p != NULL)\n\t\t    *p++ = TAB;\n\t    }\n#else\n\t    while (todo >= (int)curbuf->b_p_ts)\n\t    {\n\t\ttodo -= (int)curbuf->b_p_ts;\n\t\t++ind_len;\n\t\tif (p != NULL)\n\t\t    *p++ = TAB;\n\t    }\n#endif\n\t}\n\n\t\/\/ Count\/add spaces required for indent\n\twhile (todo > 0)\n\t{\n\t    --todo;\n\t    ++ind_len;\n\t    if (p != NULL)\n\t\t*p++ = ' ';\n\t}\n\n\tif (p == NULL)\n\t{\n\t    \/\/ Allocate memory for the result: the copied indent, new indent\n\t    \/\/ and the rest of the line.\n\t    line_len = (int)STRLEN(ml_get_curline()) + 1;\n\t    line = alloc(ind_len + line_len);\n\t    if (line == NULL)\n\t\treturn FALSE;\n\t    p = line;\n\t}\n    }\n\n    \/\/ Append the original line\n    mch_memmove(p, ml_get_curline(), (size_t)line_len);\n\n    \/\/ Replace the line\n    ml_replace(curwin->w_cursor.lnum, line, FALSE);\n\n    \/\/ Put the cursor after the indent.\n    curwin->w_cursor.col = ind_len;\n    return TRUE;\n}","target":0,"code_token_length":896,"total_token_length":1132,"max_tokens_setting":2048}
+{"idx":432352,"func":"vhost_user_get_inflight_fd(struct virtio_net **pdev,\n\t\t\t   struct vhu_msg_context *ctx,\n\t\t\t   int main_fd __rte_unused)\n{\n\tstruct rte_vhost_inflight_info_packed *inflight_packed;\n\tuint64_t pervq_inflight_size, mmap_size;\n\tuint16_t num_queues, queue_size;\n\tstruct virtio_net *dev = *pdev;\n\tint fd, i, j;\n\tint numa_node = SOCKET_ID_ANY;\n\tvoid *addr;\n\n\tif (validate_msg_fds(dev, ctx, 0) != 0)\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\n\tif (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) {\n\t\tVHOST_LOG_CONFIG(ERR, \"(%s) invalid get_inflight_fd message size is %d\\n\",\n\t\t\tdev->ifname, ctx->msg.size);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\t\/*\n\t * If VQ 0 has already been allocated, try to allocate on the same\n\t * NUMA node. It can be reallocated later in numa_realloc().\n\t *\/\n\tif (dev->nr_vring > 0)\n\t\tnuma_node = dev->virtqueue[0]->numa_node;\n\n\tif (dev->inflight_info == NULL) {\n\t\tdev->inflight_info = rte_zmalloc_socket(\"inflight_info\",\n\t\t\t\tsizeof(struct inflight_mem_info), 0, numa_node);\n\t\tif (!dev->inflight_info) {\n\t\t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to alloc dev inflight area\\n\",\n\t\t\t\t\tdev->ifname);\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\t\tdev->inflight_info->fd = -1;\n\t}\n\n\tnum_queues = ctx->msg.payload.inflight.num_queues;\n\tqueue_size = ctx->msg.payload.inflight.queue_size;\n\n\tVHOST_LOG_CONFIG(INFO, \"(%s) get_inflight_fd num_queues: %u\\n\",\n\t\tdev->ifname, ctx->msg.payload.inflight.num_queues);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) get_inflight_fd queue_size: %u\\n\",\n\t\tdev->ifname, ctx->msg.payload.inflight.queue_size);\n\n\tif (vq_is_packed(dev))\n\t\tpervq_inflight_size = get_pervq_shm_size_packed(queue_size);\n\telse\n\t\tpervq_inflight_size = get_pervq_shm_size_split(queue_size);\n\n\tmmap_size = num_queues * pervq_inflight_size;\n\taddr = inflight_mem_alloc(dev, \"vhost-inflight\", mmap_size, &fd);\n\tif (!addr) {\n\t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to alloc vhost inflight area\\n\", dev->ifname);\n\t\t\tctx->msg.payload.inflight.mmap_size = 0;\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\tmemset(addr, 0, mmap_size);\n\n\tif (dev->inflight_info->addr) {\n\t\tmunmap(dev->inflight_info->addr, dev->inflight_info->size);\n\t\tdev->inflight_info->addr = NULL;\n\t}\n\n\tif (dev->inflight_info->fd >= 0) {\n\t\tclose(dev->inflight_info->fd);\n\t\tdev->inflight_info->fd = -1;\n\t}\n\n\tdev->inflight_info->addr = addr;\n\tdev->inflight_info->size = ctx->msg.payload.inflight.mmap_size = mmap_size;\n\tdev->inflight_info->fd = ctx->fds[0] = fd;\n\tctx->msg.payload.inflight.mmap_offset = 0;\n\tctx->fd_num = 1;\n\n\tif (vq_is_packed(dev)) {\n\t\tfor (i = 0; i < num_queues; i++) {\n\t\t\tinflight_packed =\n\t\t\t\t(struct rte_vhost_inflight_info_packed *)addr;\n\t\t\tinflight_packed->used_wrap_counter = 1;\n\t\t\tinflight_packed->old_used_wrap_counter = 1;\n\t\t\tfor (j = 0; j < queue_size; j++)\n\t\t\t\tinflight_packed->desc[j].next = j + 1;\n\t\t\taddr = (void *)((char *)addr + pervq_inflight_size);\n\t\t}\n\t}\n\n\tVHOST_LOG_CONFIG(INFO, \"(%s) send inflight mmap_size: %\"PRIu64\"\\n\",\n\t\t\tdev->ifname, ctx->msg.payload.inflight.mmap_size);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) send inflight mmap_offset: %\"PRIu64\"\\n\",\n\t\t\tdev->ifname, ctx->msg.payload.inflight.mmap_offset);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) send inflight fd: %d\\n\", dev->ifname, ctx->fds[0]);\n\n\treturn RTE_VHOST_MSG_RESULT_REPLY;\n}","target":0,"code_token_length":995,"total_token_length":1231,"max_tokens_setting":2048}
+{"idx":220026,"func":"  void Compute(OpKernelContext* context) override {\n    SparseTensorsMap* map = nullptr;\n    OP_REQUIRES_OK(context, GetMap(context, false \/* is_writing *\/, &map));\n\n    const Tensor& sparse_handles = context->input(0);\n\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(sparse_handles.shape()),\n                errors::InvalidArgument(\n                    \"sparse_handles should be a vector but received shape \",\n                    sparse_handles.shape().DebugString()));\n\n    int64_t N = sparse_handles.shape().dim_size(0);\n\n    OP_REQUIRES(\n        context, N > 0,\n        errors::InvalidArgument(\"Must have at least 1 serialized SparseTensor, \"\n                                \"but input matrix has 0 rows\"));\n\n    std::vector<Tensor> indices_to_concat;\n    std::vector<Tensor> values_to_concat;\n    std::vector<TensorShape> shapes_to_concat;\n\n    const auto& sparse_handles_t = sparse_handles.vec<int64_t>();\n\n    std::vector<SparseTensor> sparse_tensors;\n\n    OP_REQUIRES_OK(context, map->RetrieveAndClearSparseTensors(\n                                context, sparse_handles_t, &sparse_tensors));\n\n    for (int64_t i = 0; i < N; ++i) {\n      const SparseTensor& st = sparse_tensors[i];\n      const Tensor& output_indices = st.indices();\n      const Tensor& output_values = st.values();\n      const auto output_shape = st.shape();\n\n      OP_REQUIRES(context, TensorShapeUtils::IsMatrix(output_indices.shape()),\n                  errors::InvalidArgument(\n                      \"Expected sparse_handles[\", i,\n                      \"] to represent an index matrix but received shape \",\n                      output_indices.shape().DebugString()));\n      OP_REQUIRES(context, TensorShapeUtils::IsVector(output_values.shape()),\n                  errors::InvalidArgument(\n                      \"Expected sparse_handles[\", i,\n                      \"] to represent a values vector but received shape \",\n                      output_values.shape().DebugString()));\n      OP_REQUIRES(\n          context, DataTypeToEnum<T>::value == output_values.dtype(),\n          errors::InvalidArgument(\n              \"Requested SparseTensor of type \",\n              DataTypeString(DataTypeToEnum<T>::value), \" but SparseTensor[\", i,\n              \"].values.dtype() == \", DataTypeString(output_values.dtype())));\n\n      int64_t num_entries = output_indices.dim_size(0);\n      OP_REQUIRES(context, num_entries == output_values.dim_size(0),\n                  errors::InvalidArgument(\n                      \"Expected row counts of SparseTensor[\", i,\n                      \"].indices and SparseTensor[\", i,\n                      \"].values to match but they do not: \", num_entries,\n                      \" vs. \", output_values.dim_size(0)));\n      int rank = output_indices.dim_size(1);\n      OP_REQUIRES(\n          context, rank == output_shape.size(),\n          errors::InvalidArgument(\"Expected column counts of SparseTensor[\", i,\n                                  \"].indices to match size of SparseTensor[\", i,\n                                  \"].shape \"\n                                  \"but they do not: \",\n                                  rank, \" vs. \", output_shape.size()));\n\n      \/\/ Now we expand each SparseTensors' indices and shape by\n      \/\/ prefixing a dimension\n      Tensor expanded_indices(\n          DT_INT64, TensorShape({num_entries, 1 + output_indices.dim_size(1)}));\n      Tensor expanded_shape(DT_INT64, TensorShape({1 + rank}));\n      const auto& output_indices_t = output_indices.matrix<int64_t>();\n      auto expanded_indices_t = expanded_indices.matrix<int64_t>();\n      auto expanded_shape_t = expanded_shape.vec<int64_t>();\n      expanded_indices_t.chip<1>(0).setZero();\n      Eigen::DSizes<Eigen::DenseIndex, 2> indices_start(0, 1);\n      Eigen::DSizes<Eigen::DenseIndex, 2> indices_sizes(num_entries, rank);\n      expanded_indices_t.slice(indices_start, indices_sizes) = output_indices_t;\n      expanded_shape_t(0) = 1;\n      \/\/ TODO: copy shape from TensorShape to &expanded_shape_t(1)\n      \/\/ std::copy_n(&output_shape_t(0), rank, &expanded_shape_t(1));\n      for (int i = 0; i < rank; ++i) {\n        expanded_shape_t(i + 1) = output_shape[i];\n      }\n      TensorShape expanded_tensor_shape(expanded_shape_t);\n\n      indices_to_concat.push_back(std::move(expanded_indices));\n      values_to_concat.push_back(output_values);\n      shapes_to_concat.push_back(std::move(expanded_tensor_shape));\n    }\n\n    int rank = -1;\n    for (int i = 0; i < N; ++i) {\n      if (rank < 0) rank = shapes_to_concat[i].dims();\n      OP_REQUIRES(context, rank == shapes_to_concat[i].dims(),\n                  errors::InvalidArgument(\n                      \"Inconsistent rank across SparseTensors: rank prior to \"\n                      \"SparseTensor[\",\n                      i, \"] was: \", rank, \" but rank of SparseTensor[\", i,\n                      \"] is: \", shapes_to_concat[i].dims()));\n    }\n\n    \/\/ SparseTensor::Concat requires consistent shape for all but the\n    \/\/ primary order dimension (dimension 0 in this case).  So we get\n    \/\/ the maximum value across all the input SparseTensors for each\n    \/\/ dimension and use that.\n    TensorShape preconcat_shape(shapes_to_concat[0]);\n    for (int i = 0; i < N; ++i) {\n      for (int d = 0; d < rank; ++d) {\n        preconcat_shape.set_dim(d, std::max(preconcat_shape.dim_size(d),\n                                            shapes_to_concat[i].dim_size(d)));\n      }\n    }\n\n    \/\/ Dimension 0 is the primary dimension.\n    gtl::InlinedVector<int64_t, 8> std_order(rank);\n    std::iota(std_order.begin(), std_order.end(), 0);\n\n    std::vector<SparseTensor> tensors_to_concat;\n    tensors_to_concat.reserve(N);\n    for (int i = 0; i < N; ++i) {\n      SparseTensor tensor;\n      OP_REQUIRES_OK(context,\n                     SparseTensor::Create(std::move(indices_to_concat[i]),\n                                          std::move(values_to_concat[i]),\n                                          preconcat_shape, std_order, &tensor));\n      tensors_to_concat.push_back(std::move(tensor));\n    }\n\n    auto output = SparseTensor::Concat<T>(tensors_to_concat);\n    Tensor final_output_shape(DT_INT64, TensorShape({output.dims()}));\n\n    std::copy_n(output.shape().data(), output.dims(),\n                final_output_shape.vec<int64_t>().data());\n\n    context->set_output(0, output.indices());\n    context->set_output(1, output.values());\n    context->set_output(2, final_output_shape);\n  }","target":0,"code_token_length":1434,"total_token_length":1670,"max_tokens_setting":2048}
+{"idx":212834,"func":"processDataRcvd(ptcpsess_t *const __restrict__ pThis,\n\tchar **buff,\n\tconst int buffLen,\n\tstruct syslogTime *stTime,\n\tconst time_t ttGenTime,\n\tmulti_submit_t *pMultiSub,\n\tunsigned *const __restrict__ pnMsgs)\n{\n\tDEFiRet;\n\tchar c = **buff;\n\tint octatesToCopy, octatesToDiscard;\n\n\tif(pThis->inputState == eAtStrtFram) {\n\t\tif(pThis->bSuppOctetFram && isdigit((int) c)) {\n\t\t\tpThis->inputState = eInOctetCnt;\n\t\t\tpThis->iOctetsRemain = 0;\n\t\t\tpThis->eFraming = TCP_FRAMING_OCTET_COUNTING;\n\t\t} else if(pThis->bSPFramingFix && c == ' ') {\n\t\t\t\/* Cisco very occasionally sends a SP after a LF, which\n\t\t\t * thrashes framing if not taken special care of. Here,\n\t\t\t * we permit space *in front of the next frame* and\n\t\t\t * ignore it.\n\t\t\t *\/\n\t\t\t FINALIZE;\n\t\t} else {\n\t\t\tpThis->inputState = eInMsg;\n\t\t\tpThis->eFraming = TCP_FRAMING_OCTET_STUFFING;\n\t\t}\n\t}\n\n\tif(pThis->inputState == eInOctetCnt) {\n\t\tif(isdigit(c)) {\n\t\t\tpThis->iOctetsRemain = pThis->iOctetsRemain * 10 + c - '0';\n\t\t} else { \/* done with the octet count, so this must be the SP terminator *\/\n\t\t\tDBGPRINTF(\"TCP Message with octet-counter, size %d.\\n\", pThis->iOctetsRemain);\n\t\t\tif(c != ' ') {\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"Framing Error in received TCP message: \"\n\t\t\t\t\t    \"delimiter is not SP but has ASCII value %d.\", c);\n\t\t\t}\n\t\t\tif(pThis->iOctetsRemain < 1) {\n\t\t\t\t\/* TODO: handle the case where the octet count is 0! *\/\n\t\t\t\tDBGPRINTF(\"Framing Error: invalid octet count\\n\");\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"Framing Error in received TCP message: \"\n\t\t\t\t\t    \"invalid octet count %d.\", pThis->iOctetsRemain);\n\t\t\t} else if(pThis->iOctetsRemain > iMaxLine) {\n\t\t\t\t\/* while we can not do anything against it, we can at least log an indication\n\t\t\t\t * that something went wrong) -- rgerhards, 2008-03-14\n\t\t\t\t *\/\n\t\t\t\tDBGPRINTF(\"truncating message with %d octets - max msg size is %d\\n\",\n\t\t\t\t\t  pThis->iOctetsRemain, iMaxLine);\n\t\t\t\terrmsg.LogError(0, NO_ERRCODE, \"received oversize message: size is %d bytes, \"\n\t\t\t\t\t        \"max msg size is %d, truncating...\", pThis->iOctetsRemain, iMaxLine);\n\t\t\t}\n\t\t\tpThis->inputState = eInMsg;\n\t\t}\n\t} else {\n\t\tassert(pThis->inputState == eInMsg);\n\n\t\tif (pThis->eFraming == TCP_FRAMING_OCTET_STUFFING) {\n\t\t\tif(pThis->iMsg >= iMaxLine) {\n\t\t\t\t\/* emergency, we now need to flush, no matter if we are at end of message or not... *\/\n\t\t\t\tint i = 1;\n\t\t\t\tchar currBuffChar;\n\t\t\t\twhile(i < buffLen && ((currBuffChar = (*buff)[i]) != '\\n'\n\t\t\t\t\t&& (pThis->pLstn->pSrv->iAddtlFrameDelim == TCPSRV_NO_ADDTL_DELIMITER\n\t\t\t\t\t\t|| currBuffChar != pThis->pLstn->pSrv->iAddtlFrameDelim))) {\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tLogError(0, NO_ERRCODE, \"error: message received is at least %d byte larger than max msg\"\n\t\t\t\t\t\" size; message will be split starting at: \\\"%.*s\\\"\\n\", i, (i < 32) ? i : 32, *buff);\n\t\t\t\tdoSubmitMsg(pThis, stTime, ttGenTime, pMultiSub);\n\t\t\t\t++(*pnMsgs);\n\t\t\t\t\/* we might think if it is better to ignore the rest of the\n\t\t\t\t * message than to treat it as a new one. Maybe this is a good\n\t\t\t\t * candidate for a configuration parameter...\n\t\t\t\t * rgerhards, 2006-12-04\n\t\t\t\t *\/\n\t\t\t}\n\n\t\t\tif ((c == '\\n')\n\t\t\t\t   || ((pThis->pLstn->pSrv->iAddtlFrameDelim != TCPSRV_NO_ADDTL_DELIMITER)\n\t\t\t\t\t   && (c == pThis->pLstn->pSrv->iAddtlFrameDelim))\n\t\t\t\t   ) { \/* record delimiter? *\/\n\t\t\t\tdoSubmitMsg(pThis, stTime, ttGenTime, pMultiSub);\n\t\t\t\t++(*pnMsgs);\n\t\t\t\tpThis->inputState = eAtStrtFram;\n\t\t\t} else {\n\t\t\t\t\/* IMPORTANT: here we copy the actual frame content to the message - for BOTH framing modes!\n\t\t\t\t * If we have a message that is larger than the max msg size, we truncate it. This is the best\n\t\t\t\t * we can do in light of what the engine supports. -- rgerhards, 2008-03-14\n\t\t\t\t *\/\n\t\t\t\tif(pThis->iMsg < iMaxLine) {\n\t\t\t\t\t*(pThis->pMsg + pThis->iMsg++) = c;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tassert(pThis->eFraming == TCP_FRAMING_OCTET_COUNTING);\n\t\t\toctatesToCopy = pThis->iOctetsRemain;\n\t\t\toctatesToDiscard = 0;\n\t\t\tif (buffLen < octatesToCopy) {\n\t\t\t\toctatesToCopy = buffLen;\n\t\t\t}\n\t\t\tif (octatesToCopy + pThis->iMsg > iMaxLine) {\n\t\t\t\toctatesToDiscard = octatesToCopy - (iMaxLine - pThis->iMsg);\n\t\t\t\toctatesToCopy = iMaxLine - pThis->iMsg;\n\t\t\t}\n\n\t\t\tmemcpy(pThis->pMsg + pThis->iMsg, *buff, octatesToCopy);\n\t\t\tpThis->iMsg += octatesToCopy;\n\t\t\tpThis->iOctetsRemain -= (octatesToCopy + octatesToDiscard);\n\t\t\t*buff += (octatesToCopy + octatesToDiscard - 1);\n\t\t\tif (pThis->iOctetsRemain == 0) {\n\t\t\t\t\/* we have end of frame! *\/\n\t\t\t\tdoSubmitMsg(pThis, stTime, ttGenTime, pMultiSub);\n\t\t\t\t++(*pnMsgs);\n\t\t\t\tpThis->inputState = eAtStrtFram;\n\t\t\t}\n\t\t}\n\n\t}\n\nfinalize_it:\n\tRETiRet;\n}","target":1,"code_token_length":1540,"total_token_length":1776,"max_tokens_setting":2048}
+{"idx":259154,"func":"static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)\n{\n    MOVContext *mov = s->priv_data;\n    MOVStreamContext *sc;\n    AVIndexEntry *sample;\n    AVStream *st = NULL;\n    int64_t current_index;\n    int ret;\n    mov->fc = s;\n retry:\n    sample = mov_find_next_sample(s, &st);\n    if (!sample || (mov->next_root_atom && sample->pos > mov->next_root_atom)) {\n        if (!mov->next_root_atom)\n            return AVERROR_EOF;\n        if ((ret = mov_switch_root(s, mov->next_root_atom, -1)) < 0)\n            return ret;\n        goto retry;\n    }\n    sc = st->priv_data;\n    \/* must be done just before reading, to avoid infinite loop on sample *\/\n    current_index = sc->current_index;\n    mov_current_sample_inc(sc);\n\n    if (mov->next_root_atom) {\n        sample->pos = FFMIN(sample->pos, mov->next_root_atom);\n        sample->size = FFMIN(sample->size, (mov->next_root_atom - sample->pos));\n    }\n\n    if (st->discard != AVDISCARD_ALL) {\n        int64_t ret64 = avio_seek(sc->pb, sample->pos, SEEK_SET);\n        if (ret64 != sample->pos) {\n            av_log(mov->fc, AV_LOG_ERROR, \"stream %d, offset 0x%\"PRIx64\": partial file\\n\",\n                   sc->ffindex, sample->pos);\n            if (should_retry(sc->pb, ret64)) {\n                mov_current_sample_dec(sc);\n            } else if (ret64 < 0) {\n                return (int)ret64;\n            }\n            return AVERROR_INVALIDDATA;\n        }\n\n        if (st->discard == AVDISCARD_NONKEY && !(sample->flags & AVINDEX_KEYFRAME)) {\n            av_log(mov->fc, AV_LOG_DEBUG, \"Nonkey frame from stream %d discarded due to AVDISCARD_NONKEY\\n\", sc->ffindex);\n            goto retry;\n        }\n\n        if (st->codecpar->codec_id == AV_CODEC_ID_EIA_608 && sample->size > 8)\n            ret = get_eia608_packet(sc->pb, pkt, sample->size);\n        else\n            ret = av_get_packet(sc->pb, pkt, sample->size);\n        if (ret < 0) {\n            if (should_retry(sc->pb, ret)) {\n                mov_current_sample_dec(sc);\n            }\n            return ret;\n        }\n#if CONFIG_DV_DEMUXER\n        if (mov->dv_demux && sc->dv_audio_container) {\n            ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);\n            av_packet_unref(pkt);\n            if (ret < 0)\n                return ret;\n            ret = avpriv_dv_get_packet(mov->dv_demux, pkt);\n            if (ret < 0)\n                return ret;\n        }\n#endif\n        if (sc->has_palette) {\n            uint8_t *pal;\n\n            pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);\n            if (!pal) {\n                av_log(mov->fc, AV_LOG_ERROR, \"Cannot append palette to packet\\n\");\n            } else {\n                memcpy(pal, sc->palette, AVPALETTE_SIZE);\n                sc->has_palette = 0;\n            }\n        }\n        if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !ffstream(st)->need_parsing && pkt->size > 4) {\n            if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0)\n                ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL;\n        }\n    }\n\n    pkt->stream_index = sc->ffindex;\n    pkt->dts = sample->timestamp;\n    if (sample->flags & AVINDEX_DISCARD_FRAME) {\n        pkt->flags |= AV_PKT_FLAG_DISCARD;\n    }\n    if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {\n        pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;\n        \/* update ctts context *\/\n        sc->ctts_sample++;\n        if (sc->ctts_index < sc->ctts_count &&\n            sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {\n            sc->ctts_index++;\n            sc->ctts_sample = 0;\n        }\n    } else {\n        int64_t next_dts = (sc->current_sample < ffstream(st)->nb_index_entries) ?\n            ffstream(st)->index_entries[sc->current_sample].timestamp : st->duration;\n\n        if (next_dts >= pkt->dts)\n            pkt->duration = next_dts - pkt->dts;\n        pkt->pts = pkt->dts;\n    }\n    if (st->discard == AVDISCARD_ALL)\n        goto retry;\n    if (sc->sdtp_data && sc->current_sample <= sc->sdtp_count) {\n        uint8_t sample_flags = sc->sdtp_data[sc->current_sample - 1];\n        uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3;\n        pkt->flags |= sample_is_depended_on == MOV_SAMPLE_DEPENDENCY_NO ? AV_PKT_FLAG_DISPOSABLE : 0;\n    }\n    pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;\n    pkt->pos = sample->pos;\n\n    \/* Multiple stsd handling. *\/\n    if (sc->stsc_data) {\n        if (sc->stsc_data[sc->stsc_index].id > 0 &&\n            sc->stsc_data[sc->stsc_index].id - 1 < sc->stsd_count &&\n            sc->stsc_data[sc->stsc_index].id - 1 != sc->last_stsd_index) {\n            ret = mov_change_extradata(sc, pkt);\n            if (ret < 0)\n                return ret;\n        }\n\n        \/* Update the stsc index for the next sample *\/\n        sc->stsc_sample++;\n        if (mov_stsc_index_valid(sc->stsc_index, sc->stsc_count) &&\n            mov_get_stsc_samples(sc, sc->stsc_index) == sc->stsc_sample) {\n            sc->stsc_index++;\n            sc->stsc_sample = 0;\n        }\n    }\n\n    if (mov->aax_mode)\n        aax_filter(pkt->data, pkt->size, mov);\n\n    ret = cenc_filter(mov, st, sc, pkt, current_index);\n    if (ret < 0) {\n        return ret;\n    }\n\n    return 0;\n}","target":0,"code_token_length":1486,"total_token_length":1722,"max_tokens_setting":2048}
+{"idx":230611,"func":"void mc_luma(const base_context* ctx,\n             const seq_parameter_set* sps, int mv_x, int mv_y,\n             int xP,int yP,\n             int16_t* out, int out_stride,\n             const pixel_t* ref, int ref_stride,\n             int nPbW, int nPbH, int bitDepth_L)\n{\n  int xFracL = mv_x & 3;\n  int yFracL = mv_y & 3;\n\n  int xIntOffsL = xP + (mv_x>>2);\n  int yIntOffsL = yP + (mv_y>>2);\n\n  \/\/ luma sample interpolation process (8.5.3.2.2.1)\n\n  \/\/const int shift1 = sps->BitDepth_Y-8;\n  \/\/const int shift2 = 6;\n  const int shift3 = 14 - sps->BitDepth_Y;\n\n  int w = sps->pic_width_in_luma_samples;\n  int h = sps->pic_height_in_luma_samples;\n\n  ALIGNED_16(int16_t) mcbuffer[MAX_CU_SIZE * (MAX_CU_SIZE+7)];\n\n  if (xFracL==0 && yFracL==0) {\n\n    if (xIntOffsL >= 0 && yIntOffsL >= 0 &&\n        nPbW+xIntOffsL <= w && nPbH+yIntOffsL <= h) {\n\n      ctx->acceleration.put_hevc_qpel(out, out_stride,\n                                      &ref[yIntOffsL*ref_stride + xIntOffsL],\n                                      ref_stride \/* sizeof(pixel_t)*\/,\n                                      nPbW,nPbH, mcbuffer, 0,0, bitDepth_L);\n    }\n    else {\n      for (int y=0;y<nPbH;y++)\n        for (int x=0;x<nPbW;x++) {\n\n          int xA = Clip3(0,w-1,x + xIntOffsL);\n          int yA = Clip3(0,h-1,y + yIntOffsL);\n\n          out[y*out_stride+x] = ref[ xA + yA*ref_stride ] << shift3;\n        }\n    }\n\n#ifdef DE265_LOG_TRACE\n    logtrace(LogMotion,\"---MC luma %d %d = direct---\\n\",xFracL,yFracL);\n\n    for (int y=0;y<nPbH;y++) {\n      for (int x=0;x<nPbW;x++) {\n\n        int xA = Clip3(0,w-1,x + xIntOffsL);\n        int yA = Clip3(0,h-1,y + yIntOffsL);\n\n        logtrace(LogMotion,\"%02x \", ref[ xA + yA*ref_stride ]);\n      }\n      logtrace(LogMotion,\"\\n\");\n    }\n\n    logtrace(LogMotion,\" -> \\n\");\n\n    for (int y=0;y<nPbH;y++) {\n      for (int x=0;x<nPbW;x++) {\n\n        logtrace(LogMotion,\"%02x \",out[y*out_stride+x] >> 6); \/\/ 6 will be used when summing predictions\n      }\n      logtrace(LogMotion,\"\\n\");\n    }\n#endif\n  }\n  else {\n    int extra_left   = extra_before[xFracL];\n    int extra_right  = extra_after [xFracL];\n    int extra_top    = extra_before[yFracL];\n    int extra_bottom = extra_after [yFracL];\n\n    \/\/int nPbW_extra = extra_left + nPbW + extra_right;\n    \/\/int nPbH_extra = extra_top  + nPbH + extra_bottom;\n\n\n    pixel_t padbuf[(MAX_CU_SIZE+16)*(MAX_CU_SIZE+7)];\n\n    const pixel_t* src_ptr;\n    int src_stride;\n\n    if (-extra_left + xIntOffsL >= 0 &&\n        -extra_top  + yIntOffsL >= 0 &&\n        nPbW+extra_right  + xIntOffsL < w &&\n        nPbH+extra_bottom + yIntOffsL < h) {\n      src_ptr = &ref[xIntOffsL + yIntOffsL*ref_stride];\n      src_stride = ref_stride;\n    }\n    else {\n      for (int y=-extra_top;y<nPbH+extra_bottom;y++) {\n        for (int x=-extra_left;x<nPbW+extra_right;x++) {\n\n          int xA = Clip3(0,w-1,x + xIntOffsL);\n          int yA = Clip3(0,h-1,y + yIntOffsL);\n\n          padbuf[x+extra_left + (y+extra_top)*(MAX_CU_SIZE+16)] = ref[ xA + yA*ref_stride ];\n        }\n      }\n\n      src_ptr = &padbuf[extra_top*(MAX_CU_SIZE+16) + extra_left];\n      src_stride = MAX_CU_SIZE+16;\n    }\n\n    ctx->acceleration.put_hevc_qpel(out, out_stride,\n                                    src_ptr, src_stride \/* sizeof(pixel_t) *\/,\n                                    nPbW,nPbH, mcbuffer, xFracL,yFracL, bitDepth_L);\n\n\n    logtrace(LogMotion,\"---V---\\n\");\n    for (int y=0;y<nPbH;y++) {\n      for (int x=0;x<nPbW;x++) {\n        logtrace(LogMotion,\"%04x \",out[x+y*out_stride]);\n      }\n      logtrace(LogMotion,\"\\n\");\n    }\n  }\n}","target":0,"code_token_length":1220,"total_token_length":1456,"max_tokens_setting":2048}
+{"idx":225007,"func":"parseServiceFile(const char *serviceFile,\n\t\t\t\t const char *service,\n\t\t\t\t PQconninfoOption *options,\n\t\t\t\t PQExpBuffer errorMessage,\n\t\t\t\t bool *group_found)\n{\n\tint\t\t\tresult = 0,\n\t\t\t\tlinenr = 0,\n\t\t\t\ti;\n\tFILE\t   *f;\n\tchar\t   *line;\n\tchar\t\tbuf[1024];\n\n\t*group_found = false;\n\n\tf = fopen(serviceFile, \"r\");\n\tif (f == NULL)\n\t{\n\t\tappendPQExpBuffer(errorMessage, libpq_gettext(\"service file \\\"%s\\\" not found\\n\"),\n\t\t\t\t\t\t  serviceFile);\n\t\treturn 1;\n\t}\n\n\twhile ((line = fgets(buf, sizeof(buf), f)) != NULL)\n\t{\n\t\tint\t\t\tlen;\n\n\t\tlinenr++;\n\n\t\tif (strlen(line) >= sizeof(buf) - 1)\n\t\t{\n\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"line %d too long in service file \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t  linenr,\n\t\t\t\t\t\t\t  serviceFile);\n\t\t\tresult = 2;\n\t\t\tgoto exit;\n\t\t}\n\n\t\t\/* ignore whitespace at end of line, especially the newline *\/\n\t\tlen = strlen(line);\n\t\twhile (len > 0 && isspace((unsigned char) line[len - 1]))\n\t\t\tline[--len] = '\\0';\n\n\t\t\/* ignore leading whitespace too *\/\n\t\twhile (*line && isspace((unsigned char) line[0]))\n\t\t\tline++;\n\n\t\t\/* ignore comments and empty lines *\/\n\t\tif (line[0] == '\\0' || line[0] == '#')\n\t\t\tcontinue;\n\n\t\t\/* Check for right groupname *\/\n\t\tif (line[0] == '[')\n\t\t{\n\t\t\tif (*group_found)\n\t\t\t{\n\t\t\t\t\/* end of desired group reached; return success *\/\n\t\t\t\tgoto exit;\n\t\t\t}\n\n\t\t\tif (strncmp(line + 1, service, strlen(service)) == 0 &&\n\t\t\t\tline[strlen(service) + 1] == ']')\n\t\t\t\t*group_found = true;\n\t\t\telse\n\t\t\t\t*group_found = false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (*group_found)\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Finally, we are in the right group and can parse the line\n\t\t\t\t *\/\n\t\t\t\tchar\t   *key,\n\t\t\t\t\t\t   *val;\n\t\t\t\tbool\t\tfound_keyword;\n\n#ifdef USE_LDAP\n\t\t\t\tif (strncmp(line, \"ldap\", 4) == 0)\n\t\t\t\t{\n\t\t\t\t\tint\t\t\trc = ldapServiceLookup(line, options, errorMessage);\n\n\t\t\t\t\t\/* if rc = 2, go on reading for fallback *\/\n\t\t\t\t\tswitch (rc)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\tgoto exit;\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\tresult = 3;\n\t\t\t\t\t\t\tgoto exit;\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\n\t\t\t\tkey = line;\n\t\t\t\tval = strchr(line, '=');\n\t\t\t\tif (val == NULL)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"syntax error in service file \\\"%s\\\", line %d\\n\"),\n\t\t\t\t\t\t\t\t\t  serviceFile,\n\t\t\t\t\t\t\t\t\t  linenr);\n\t\t\t\t\tresult = 3;\n\t\t\t\t\tgoto exit;\n\t\t\t\t}\n\t\t\t\t*val++ = '\\0';\n\n\t\t\t\tif (strcmp(key, \"service\") == 0)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"nested service specifications not supported in service file \\\"%s\\\", line %d\\n\"),\n\t\t\t\t\t\t\t\t\t  serviceFile,\n\t\t\t\t\t\t\t\t\t  linenr);\n\t\t\t\t\tresult = 3;\n\t\t\t\t\tgoto exit;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Set the parameter --- but don't override any previous\n\t\t\t\t * explicit setting.\n\t\t\t\t *\/\n\t\t\t\tfound_keyword = false;\n\t\t\t\tfor (i = 0; options[i].keyword; i++)\n\t\t\t\t{\n\t\t\t\t\tif (strcmp(options[i].keyword, key) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (options[i].val == NULL)\n\t\t\t\t\t\t\toptions[i].val = strdup(val);\n\t\t\t\t\t\tif (!options[i].val)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"out of memory\\n\"));\n\t\t\t\t\t\t\tresult = 3;\n\t\t\t\t\t\t\tgoto exit;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfound_keyword = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!found_keyword)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"syntax error in service file \\\"%s\\\", line %d\\n\"),\n\t\t\t\t\t\t\t\t\t  serviceFile,\n\t\t\t\t\t\t\t\t\t  linenr);\n\t\t\t\t\tresult = 3;\n\t\t\t\t\tgoto exit;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\nexit:\n\tfclose(f);\n\n\treturn result;\n}","target":0,"code_token_length":954,"total_token_length":1190,"max_tokens_setting":2048}
+{"idx":196885,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& input = ctx->input(kInputTensorIndex);\n    const Tensor& input_min = ctx->input(kInputMinIndex);\n    const Tensor& input_max = ctx->input(kInputMaxIndex);\n\n    const size_t depth = input_max.NumElements();\n    OP_REQUIRES(\n        ctx, input_min.dim_size(0) == depth,\n        errors::InvalidArgument(\"input_min has incorrect size, expected \",\n                                depth, \" was \", input_min.dim_size(0)));\n    OP_REQUIRES(\n        ctx, input_max.dim_size(0) == depth,\n        errors::InvalidArgument(\"input_max has incorrect size, expected \",\n                                depth, \" was \", input_max.dim_size(0)));\n\n    const float* input_min_data = input_min.flat<float>().data();\n    const float* input_max_data = input_max.flat<float>().data();\n    std::vector<float> ranges(depth);\n    bool is_non_negative = true;\n    Eigen::array<int, 2> shuffling({1, 0});\n    auto input_matrix = input.flat_inner_dims<qint32>();\n\n    \/\/ TODO: verify performance of not transposing and finding the min max\n    \/\/ directly from input_matrix vs the one presented below of transposing and\n    \/\/ using the transposed matrix as the transposing operation in itself might\n    \/\/ be more costly.\n    \/\/ Note that this operation is a calibration step for quantization and will\n    \/\/ cease to exist in the final inference graph(will exist as a const node).\n    auto transposed_input = input_matrix.shuffle(shuffling);\n\n    \/\/ Find the ranges of each channel in parallel.\n    float out_min_max = std::numeric_limits<float>::min();\n\n#ifdef ENABLE_ONEDNN_OPENMP\n#ifdef _MSC_VER\n#pragma omp parallel for\n#else\n#pragma omp parallel for reduction(max : out_min_max)\n#endif\n#endif  \/\/ ENABLE_ONEDNN_OPENMP\n    \/\/ TODO: Add eigen parallel_for\n    for (int64_t i = 0; i < depth; ++i) {\n      Eigen::Tensor<qint32, 0, Eigen::RowMajor> min =\n          transposed_input.chip<0>(i).minimum();\n      Eigen::Tensor<qint32, 0, Eigen::RowMajor> max =\n          transposed_input.chip<0>(i).maximum();\n      const int32_t min_per_channel = min();\n      const int32_t max_per_channel = max();\n      const int32_t abs_max =\n          std::max(std::abs(min_per_channel), std::abs(max_per_channel));\n      float scale =\n          std::max(std::abs(input_min_data[i]), std::abs(input_max_data[i]));\n      ranges[i] =\n          scale * static_cast<float>(abs_max) \/ static_cast<float>(1L << 31);\n      if (min_per_channel < 0) is_non_negative = false;\n\n      \/\/ Thread-local out_min_max.\n      out_min_max = std::max(out_min_max, ranges[i]);\n    }\n\n    \/\/ All local out_min_max gets max-reduced into one global out_min_max at\n    \/\/ the end of the loop by specifying reduction(max:out_min_max) along with\n    \/\/ omp parallel for.\n\n    \/\/ Fixing max to clip_value_max_ (example 6.0 to support relu6)\n    if (out_min_max > clip_value_max_) out_min_max = clip_value_max_;\n\n    Tensor* output_min = nullptr;\n    Tensor* output_max = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputMinIndex, {}, &output_min));\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputMaxIndex, {}, &output_max));\n    output_min->flat<float>()(0) = is_non_negative ? 0.0f : -out_min_max;\n    output_max->flat<float>()(0) = out_min_max;\n  }","target":1,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048}
+{"idx":234731,"func":"int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,\n\t\t    u64 devid)\n{\n\tstruct btrfs_device *device;\n\tstruct btrfs_fs_devices *cur_devices;\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tu64 num_devices;\n\tint ret = 0;\n\n\tmutex_lock(&uuid_mutex);\n\n\tnum_devices = btrfs_num_devices(fs_info);\n\n\tret = btrfs_check_raid_min_devices(fs_info, num_devices - 1);\n\tif (ret)\n\t\tgoto out;\n\n\tdevice = btrfs_find_device_by_devspec(fs_info, devid, device_path);\n\n\tif (IS_ERR(device)) {\n\t\tif (PTR_ERR(device) == -ENOENT &&\n\t\t    device_path && strcmp(device_path, \"missing\") == 0)\n\t\t\tret = BTRFS_ERROR_DEV_MISSING_NOT_FOUND;\n\t\telse\n\t\t\tret = PTR_ERR(device);\n\t\tgoto out;\n\t}\n\n\tif (btrfs_pinned_by_swapfile(fs_info, device)) {\n\t\tbtrfs_warn_in_rcu(fs_info,\n\t\t  \"cannot remove device %s (devid %llu) due to active swapfile\",\n\t\t\t\t  rcu_str_deref(device->name), device->devid);\n\t\tret = -ETXTBSY;\n\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) {\n\t\tret = BTRFS_ERROR_DEV_TGT_REPLACE;\n\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&\n\t    fs_info->fs_devices->rw_devices == 1) {\n\t\tret = BTRFS_ERROR_DEV_ONLY_WRITABLE;\n\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {\n\t\tmutex_lock(&fs_info->chunk_mutex);\n\t\tlist_del_init(&device->dev_alloc_list);\n\t\tdevice->fs_devices->rw_devices--;\n\t\tmutex_unlock(&fs_info->chunk_mutex);\n\t}\n\n\tmutex_unlock(&uuid_mutex);\n\tret = btrfs_shrink_device(device, 0);\n\tif (!ret)\n\t\tbtrfs_reada_remove_dev(device);\n\tmutex_lock(&uuid_mutex);\n\tif (ret)\n\t\tgoto error_undo;\n\n\t\/*\n\t * TODO: the superblock still includes this device in its num_devices\n\t * counter although write_all_supers() is not locked out. This\n\t * could give a filesystem state which requires a degraded mount.\n\t *\/\n\tret = btrfs_rm_dev_item(device);\n\tif (ret)\n\t\tgoto error_undo;\n\n\tclear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);\n\tbtrfs_scrub_cancel_dev(device);\n\n\t\/*\n\t * the device list mutex makes sure that we don't change\n\t * the device list while someone else is writing out all\n\t * the device supers. Whoever is writing all supers, should\n\t * lock the device list mutex before getting the number of\n\t * devices in the super block (super_copy). Conversely,\n\t * whoever updates the number of devices in the super block\n\t * (super_copy) should hold the device list mutex.\n\t *\/\n\n\t\/*\n\t * In normal cases the cur_devices == fs_devices. But in case\n\t * of deleting a seed device, the cur_devices should point to\n\t * its own fs_devices listed under the fs_devices->seed.\n\t *\/\n\tcur_devices = device->fs_devices;\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tlist_del_rcu(&device->dev_list);\n\n\tcur_devices->num_devices--;\n\tcur_devices->total_devices--;\n\t\/* Update total_devices of the parent fs_devices if it's seed *\/\n\tif (cur_devices != fs_devices)\n\t\tfs_devices->total_devices--;\n\n\tif (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))\n\t\tcur_devices->missing_devices--;\n\n\tbtrfs_assign_next_active_device(device, NULL);\n\n\tif (device->bdev) {\n\t\tcur_devices->open_devices--;\n\t\t\/* remove sysfs entry *\/\n\t\tbtrfs_sysfs_remove_device(device);\n\t}\n\n\tnum_devices = btrfs_super_num_devices(fs_info->super_copy) - 1;\n\tbtrfs_set_super_num_devices(fs_info->super_copy, num_devices);\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\t\/*\n\t * at this point, the device is zero sized and detached from\n\t * the devices list.  All that's left is to zero out the old\n\t * supers and free the device.\n\t *\/\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state))\n\t\tbtrfs_scratch_superblocks(fs_info, device->bdev,\n\t\t\t\t\t  device->name->str);\n\n\tbtrfs_close_bdev(device);\n\tsynchronize_rcu();\n\tbtrfs_free_device(device);\n\n\tif (cur_devices->open_devices == 0) {\n\t\tlist_del_init(&cur_devices->seed_list);\n\t\tclose_fs_devices(cur_devices);\n\t\tfree_fs_devices(cur_devices);\n\t}\n\nout:\n\tmutex_unlock(&uuid_mutex);\n\treturn ret;\n\nerror_undo:\n\tbtrfs_reada_undo_remove_dev(device);\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {\n\t\tmutex_lock(&fs_info->chunk_mutex);\n\t\tlist_add(&device->dev_alloc_list,\n\t\t\t &fs_devices->alloc_list);\n\t\tdevice->fs_devices->rw_devices++;\n\t\tmutex_unlock(&fs_info->chunk_mutex);\n\t}\n\tgoto out;\n}","target":0,"code_token_length":1120,"total_token_length":1356,"max_tokens_setting":2048}
+{"idx":307841,"func":"ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,\n                                          int index, Bytecodes::Code bc,\n                                          ciInstanceKlass* accessor) {\n  if (bc == Bytecodes::_invokedynamic) {\n    ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index);\n    bool is_resolved = !cpce->is_f1_null();\n    \/\/ FIXME: code generation could allow for null (unlinked) call site\n    \/\/ The call site could be made patchable as follows:\n    \/\/ Load the appendix argument from the constant pool.\n    \/\/ Test the appendix argument and jump to a known deopt routine if it is null.\n    \/\/ Jump through a patchable call site, which is initially a deopt routine.\n    \/\/ Patch the call site to the nmethod entry point of the static compiled lambda form.\n    \/\/ As with other two-component call sites, both values must be independently verified.\n\n    if (is_resolved) {\n      \/\/ Get the invoker Method* from the constant pool.\n      \/\/ (The appendix argument, if any, will be noted in the method's signature.)\n      Method* adapter = cpce->f1_as_method();\n      return get_method(adapter);\n    }\n\n    \/\/ Fake a method that is equivalent to a declared method.\n    ciInstanceKlass* holder    = get_instance_klass(SystemDictionary::MethodHandle_klass());\n    ciSymbol*        name      = ciSymbol::invokeBasic_name();\n    ciSymbol*        signature = get_symbol(cpool->signature_ref_at(index));\n    return get_unloaded_method(holder, name, signature, accessor);\n  } else {\n    const int holder_index = cpool->klass_ref_index_at(index);\n    bool holder_is_accessible;\n    ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);\n    ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);\n\n    \/\/ Get the method's name and signature.\n    Symbol* name_sym = cpool->name_ref_at(index);\n    Symbol* sig_sym  = cpool->signature_ref_at(index);\n\n    if (cpool->has_preresolution()\n        || (holder == ciEnv::MethodHandle_klass() &&\n            MethodHandles::is_signature_polymorphic_name(holder->get_Klass(), name_sym))) {\n      \/\/ Short-circuit lookups for JSR 292-related call sites.\n      \/\/ That is, do not rely only on name-based lookups, because they may fail\n      \/\/ if the names are not resolvable in the boot class loader (7056328).\n      switch (bc) {\n      case Bytecodes::_invokevirtual:\n      case Bytecodes::_invokeinterface:\n      case Bytecodes::_invokespecial:\n      case Bytecodes::_invokestatic:\n        {\n          Method* m = ConstantPool::method_at_if_loaded(cpool, index);\n          if (m != NULL) {\n            return get_method(m);\n          }\n        }\n        break;\n      }\n    }\n\n    if (holder_is_accessible) {  \/\/ Our declared holder is loaded.\n      InstanceKlass* lookup = declared_holder->get_instanceKlass();\n      Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);\n      if (m != NULL &&\n          (bc == Bytecodes::_invokestatic\n           ?  m->method_holder()->is_not_initialized()\n           : !m->method_holder()->is_loaded())) {\n        m = NULL;\n      }\n#ifdef ASSERT\n      if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {\n        m = NULL;\n      }\n#endif\n      if (m != NULL) {\n        \/\/ We found the method.\n        return get_method(m);\n      }\n    }\n\n    \/\/ Either the declared holder was not loaded, or the method could\n    \/\/ not be found.  Create a dummy ciMethod to represent the failed\n    \/\/ lookup.\n    ciSymbol* name      = get_symbol(name_sym);\n    ciSymbol* signature = get_symbol(sig_sym);\n    return get_unloaded_method(declared_holder, name, signature, accessor);\n  }\n}","target":0,"code_token_length":880,"total_token_length":1116,"max_tokens_setting":2048}
+{"idx":516243,"func":"static uint16_t virtio_net_handle_rss(VirtIONet *n,\n                                      struct iovec *iov,\n                                      unsigned int iov_cnt,\n                                      bool do_rss)\n{\n    VirtIODevice *vdev = VIRTIO_DEVICE(n);\n    struct virtio_net_rss_config cfg;\n    size_t s, offset = 0, size_get;\n    uint16_t queues, i;\n    struct {\n        uint16_t us;\n        uint8_t b;\n    } QEMU_PACKED temp;\n    const char *err_msg = \"\";\n    uint32_t err_value = 0;\n\n    if (do_rss && !virtio_vdev_has_feature(vdev, VIRTIO_NET_F_RSS)) {\n        err_msg = \"RSS is not negotiated\";\n        goto error;\n    }\n    if (!do_rss && !virtio_vdev_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT)) {\n        err_msg = \"Hash report is not negotiated\";\n        goto error;\n    }\n    size_get = offsetof(struct virtio_net_rss_config, indirection_table);\n    s = iov_to_buf(iov, iov_cnt, offset, &cfg, size_get);\n    if (s != size_get) {\n        err_msg = \"Short command buffer\";\n        err_value = (uint32_t)s;\n        goto error;\n    }\n    n->rss_data.hash_types = virtio_ldl_p(vdev, &cfg.hash_types);\n    n->rss_data.indirections_len =\n        virtio_lduw_p(vdev, &cfg.indirection_table_mask);\n    n->rss_data.indirections_len++;\n    if (!do_rss) {\n        n->rss_data.indirections_len = 1;\n    }\n    if (!is_power_of_2(n->rss_data.indirections_len)) {\n        err_msg = \"Invalid size of indirection table\";\n        err_value = n->rss_data.indirections_len;\n        goto error;\n    }\n    if (n->rss_data.indirections_len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {\n        err_msg = \"Too large indirection table\";\n        err_value = n->rss_data.indirections_len;\n        goto error;\n    }\n    n->rss_data.default_queue = do_rss ?\n        virtio_lduw_p(vdev, &cfg.unclassified_queue) : 0;\n    if (n->rss_data.default_queue >= n->max_queues) {\n        err_msg = \"Invalid default queue\";\n        err_value = n->rss_data.default_queue;\n        goto error;\n    }\n    offset += size_get;\n    size_get = sizeof(uint16_t) * n->rss_data.indirections_len;\n    g_free(n->rss_data.indirections_table);\n    n->rss_data.indirections_table = g_malloc(size_get);\n    if (!n->rss_data.indirections_table) {\n        err_msg = \"Can't allocate indirections table\";\n        err_value = n->rss_data.indirections_len;\n        goto error;\n    }\n    s = iov_to_buf(iov, iov_cnt, offset,\n                   n->rss_data.indirections_table, size_get);\n    if (s != size_get) {\n        err_msg = \"Short indirection table buffer\";\n        err_value = (uint32_t)s;\n        goto error;\n    }\n    for (i = 0; i < n->rss_data.indirections_len; ++i) {\n        uint16_t val = n->rss_data.indirections_table[i];\n        n->rss_data.indirections_table[i] = virtio_lduw_p(vdev, &val);\n    }\n    offset += size_get;\n    size_get = sizeof(temp);\n    s = iov_to_buf(iov, iov_cnt, offset, &temp, size_get);\n    if (s != size_get) {\n        err_msg = \"Can't get queues\";\n        err_value = (uint32_t)s;\n        goto error;\n    }\n    queues = do_rss ? virtio_lduw_p(vdev, &temp.us) : n->curr_queues;\n    if (queues == 0 || queues > n->max_queues) {\n        err_msg = \"Invalid number of queues\";\n        err_value = queues;\n        goto error;\n    }\n    if (temp.b > VIRTIO_NET_RSS_MAX_KEY_SIZE) {\n        err_msg = \"Invalid key size\";\n        err_value = temp.b;\n        goto error;\n    }\n    if (!temp.b && n->rss_data.hash_types) {\n        err_msg = \"No key provided\";\n        err_value = 0;\n        goto error;\n    }\n    if (!temp.b && !n->rss_data.hash_types) {\n        virtio_net_disable_rss(n);\n        return queues;\n    }\n    offset += size_get;\n    size_get = temp.b;\n    s = iov_to_buf(iov, iov_cnt, offset, n->rss_data.key, size_get);\n    if (s != size_get) {\n        err_msg = \"Can get key buffer\";\n        err_value = (uint32_t)s;\n        goto error;\n    }\n    n->rss_data.enabled = true;\n\n    if (!n->rss_data.populate_hash) {\n        if (!virtio_net_attach_epbf_rss(n)) {\n            \/* EBPF must be loaded for vhost *\/\n            if (get_vhost_net(qemu_get_queue(n->nic)->peer)) {\n                warn_report(\"Can't load eBPF RSS for vhost\");\n                goto error;\n            }\n            \/* fallback to software RSS *\/\n            warn_report(\"Can't load eBPF RSS - fallback to software RSS\");\n            n->rss_data.enabled_software_rss = true;\n        }\n    } else {\n        \/* use software RSS for hash populating *\/\n        \/* and detach eBPF if was loaded before *\/\n        virtio_net_detach_epbf_rss(n);\n        n->rss_data.enabled_software_rss = true;\n    }\n\n    trace_virtio_net_rss_enable(n->rss_data.hash_types,\n                                n->rss_data.indirections_len,\n                                temp.b);\n    return queues;\nerror:\n    trace_virtio_net_rss_error(err_msg, err_value);\n    virtio_net_disable_rss(n);\n    return 0;\n}","target":0,"code_token_length":1316,"total_token_length":1552,"max_tokens_setting":2048}
+{"idx":242582,"func":"relocate_coff (PE_COFF_LOADER_IMAGE_CONTEXT *context,\n\t       EFI_IMAGE_SECTION_HEADER *Section,\n\t       void *orig, void *data)\n{\n\tEFI_IMAGE_BASE_RELOCATION *RelocBase, *RelocBaseEnd;\n\tUINT64 Adjust;\n\tUINT16 *Reloc, *RelocEnd;\n\tchar *Fixup, *FixupBase;\n\tUINT16 *Fixup16;\n\tUINT32 *Fixup32;\n\tUINT64 *Fixup64;\n\tint size = context->ImageSize;\n\tvoid *ImageEnd = (char *)orig + size;\n\tint n = 0;\n\n\t\/* Alright, so here's how this works:\n\t *\n\t * context->RelocDir gives us two things:\n\t * - the VA the table of base relocation blocks are (maybe) to be\n\t *   mapped at (RelocDir->VirtualAddress)\n\t * - the virtual size (RelocDir->Size)\n\t *\n\t * The .reloc section (Section here) gives us some other things:\n\t * - the name! kind of. (Section->Name)\n\t * - the virtual size (Section->VirtualSize), which should be the same\n\t *   as RelocDir->Size\n\t * - the virtual address (Section->VirtualAddress)\n\t * - the file section size (Section->SizeOfRawData), which is\n\t *   a multiple of OptHdr->FileAlignment.  Only useful for image\n\t *   validation, not really useful for iteration bounds.\n\t * - the file address (Section->PointerToRawData)\n\t * - a bunch of stuff we don't use that's 0 in our binaries usually\n\t * - Flags (Section->Characteristics)\n\t *\n\t * and then the thing that's actually at the file address is an array\n\t * of EFI_IMAGE_BASE_RELOCATION structs with some values packed behind\n\t * them.  The SizeOfBlock field of this structure includes the\n\t * structure itself, and adding it to that structure's address will\n\t * yield the next entry in the array.\n\t *\/\n\tRelocBase = ImageAddress(orig, size, Section->PointerToRawData);\n\t\/* RelocBaseEnd here is the address of the first entry \/past\/ the\n\t * table.  *\/\n\tRelocBaseEnd = ImageAddress(orig, size, Section->PointerToRawData +\n\t\t\t\t\t\tSection->Misc.VirtualSize);\n\n\tif (!RelocBase && !RelocBaseEnd)\n\t\treturn EFI_SUCCESS;\n\n\tif (!RelocBase || !RelocBaseEnd) {\n\t\tperror(L\"Reloc table overflows binary\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tAdjust = (UINTN)data - context->ImageAddress;\n\n\tif (Adjust == 0)\n\t\treturn EFI_SUCCESS;\n\n\twhile (RelocBase < RelocBaseEnd) {\n\t\tReloc = (UINT16 *) ((char *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));\n\n\t\tif (RelocBase->SizeOfBlock == 0) {\n\t\t\tperror(L\"Reloc %d block size 0 is invalid\\n\", n);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t} else if (RelocBase->SizeOfBlock > context->RelocDir->Size) {\n\t\t\tperror(L\"Reloc %d block size %d greater than reloc dir\"\n\t\t\t\t\t\"size %d, which is invalid\\n\", n,\n\t\t\t\t\tRelocBase->SizeOfBlock,\n\t\t\t\t\tcontext->RelocDir->Size);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\tRelocEnd = (UINT16 *) ((char *) RelocBase + RelocBase->SizeOfBlock);\n\t\tif ((void *)RelocEnd < orig || (void *)RelocEnd > ImageEnd) {\n\t\t\tperror(L\"Reloc %d entry overflows binary\\n\", n);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\tFixupBase = ImageAddress(data, size, RelocBase->VirtualAddress);\n\t\tif (!FixupBase) {\n\t\t\tperror(L\"Reloc %d Invalid fixupbase\\n\", n);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\twhile (Reloc < RelocEnd) {\n\t\t\tFixup = FixupBase + (*Reloc & 0xFFF);\n\t\t\tswitch ((*Reloc) >> 12) {\n\t\t\tcase EFI_IMAGE_REL_BASED_ABSOLUTE:\n\t\t\t\tbreak;\n\n\t\t\tcase EFI_IMAGE_REL_BASED_HIGH:\n\t\t\t\tFixup16   = (UINT16 *) Fixup;\n\t\t\t\t*Fixup16 = (UINT16) (*Fixup16 + ((UINT16) ((UINT32) Adjust >> 16)));\n\t\t\t\tbreak;\n\n\t\t\tcase EFI_IMAGE_REL_BASED_LOW:\n\t\t\t\tFixup16   = (UINT16 *) Fixup;\n\t\t\t\t*Fixup16  = (UINT16) (*Fixup16 + (UINT16) Adjust);\n\t\t\t\tbreak;\n\n\t\t\tcase EFI_IMAGE_REL_BASED_HIGHLOW:\n\t\t\t\tFixup32   = (UINT32 *) Fixup;\n\t\t\t\t*Fixup32  = *Fixup32 + (UINT32) Adjust;\n\t\t\t\tbreak;\n\n\t\t\tcase EFI_IMAGE_REL_BASED_DIR64:\n\t\t\t\tFixup64 = (UINT64 *) Fixup;\n\t\t\t\t*Fixup64 = *Fixup64 + (UINT64) Adjust;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tperror(L\"Reloc %d Unknown relocation\\n\", n);\n\t\t\t\treturn EFI_UNSUPPORTED;\n\t\t\t}\n\t\t\tReloc += 1;\n\t\t}\n\t\tRelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\n\t\tn++;\n\t}\n\n\treturn EFI_SUCCESS;\n}","target":0,"code_token_length":1199,"total_token_length":1435,"max_tokens_setting":2048}
+{"idx":202810,"func":"_gcry_ecc_ecdsa_sign (gcry_mpi_t input, ECC_secret_key *skey,\n                      gcry_mpi_t r, gcry_mpi_t s,\n                      int flags, int hashalgo)\n{\n  gpg_err_code_t rc = 0;\n  int extraloops = 0;\n  gcry_mpi_t k, dr, sum, k_1, x;\n  mpi_point_struct I;\n  gcry_mpi_t hash;\n  const void *abuf;\n  unsigned int abits, qbits;\n  mpi_ec_t ctx;\n\n  if (DBG_CIPHER)\n    log_mpidump (\"ecdsa sign hash  \", input );\n\n  qbits = mpi_get_nbits (skey->E.n);\n\n  \/* Convert the INPUT into an MPI if needed.  *\/\n  rc = _gcry_dsa_normalize_hash (input, &hash, qbits);\n  if (rc)\n    return rc;\n\n  k = NULL;\n  dr = mpi_alloc (0);\n  sum = mpi_alloc (0);\n  k_1 = mpi_alloc (0);\n  x = mpi_alloc (0);\n  point_init (&I);\n\n  ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0,\n                                     skey->E.p, skey->E.a, skey->E.b);\n\n  \/* Two loops to avoid R or S are zero.  This is more of a joke than\n     a real demand because the probability of them being zero is less\n     than any hardware failure.  Some specs however require it.  *\/\n  do\n    {\n      do\n        {\n          mpi_free (k);\n          k = NULL;\n          if ((flags & PUBKEY_FLAG_RFC6979) && hashalgo)\n            {\n              \/* Use Pornin's method for deterministic DSA.  If this\n                 flag is set, it is expected that HASH is an opaque\n                 MPI with the to be signed hash.  That hash is also\n                 used as h1 from 3.2.a.  *\/\n              if (!mpi_is_opaque (input))\n                {\n                  rc = GPG_ERR_CONFLICT;\n                  goto leave;\n                }\n\n              abuf = mpi_get_opaque (input, &abits);\n              rc = _gcry_dsa_gen_rfc6979_k (&k, skey->E.n, skey->d,\n                                            abuf, (abits+7)\/8,\n                                            hashalgo, extraloops);\n              if (rc)\n                goto leave;\n              extraloops++;\n            }\n          else\n            k = _gcry_dsa_gen_k (skey->E.n, GCRY_STRONG_RANDOM);\n\n          _gcry_mpi_ec_mul_point (&I, k, &skey->E.G, ctx);\n          if (_gcry_mpi_ec_get_affine (x, NULL, &I, ctx))\n            {\n              if (DBG_CIPHER)\n                log_debug (\"ecc sign: Failed to get affine coordinates\\n\");\n              rc = GPG_ERR_BAD_SIGNATURE;\n              goto leave;\n            }\n          mpi_mod (r, x, skey->E.n);  \/* r = x mod n *\/\n        }\n      while (!mpi_cmp_ui (r, 0));\n\n      mpi_mulm (dr, skey->d, r, skey->E.n); \/* dr = d*r mod n  *\/\n      mpi_addm (sum, hash, dr, skey->E.n);  \/* sum = hash + (d*r) mod n  *\/\n      mpi_invm (k_1, k, skey->E.n);         \/* k_1 = k^(-1) mod n  *\/\n      mpi_mulm (s, k_1, sum, skey->E.n);    \/* s = k^(-1)*(hash+(d*r)) mod n *\/\n    }\n  while (!mpi_cmp_ui (s, 0));\n\n  if (DBG_CIPHER)\n    {\n      log_mpidump (\"ecdsa sign result r \", r);\n      log_mpidump (\"ecdsa sign result s \", s);\n    }\n\n leave:\n  _gcry_mpi_ec_free (ctx);\n  point_free (&I);\n  mpi_free (x);\n  mpi_free (k_1);\n  mpi_free (sum);\n  mpi_free (dr);\n  mpi_free (k);\n\n  if (hash != input)\n    mpi_free (hash);\n\n  return rc;\n}","target":1,"code_token_length":931,"total_token_length":1167,"max_tokens_setting":2048}
+{"idx":439056,"func":"static Image *ReadHEICImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  heif_item_id\n    exif_id;\n\n  Image\n    *image;\n\n  int\n    count,\n    stride_y,\n    stride_cb,\n    stride_cr;\n\n  MagickBooleanType\n    status;\n\n  MagickSizeType\n    length;\n\n  ssize_t\n    y;\n\n  struct heif_context\n    *heif_context;\n\n  struct heif_error\n    error;\n\n  struct heif_image\n    *heif_image;\n\n  struct heif_image_handle\n    *image_handle;\n\n  uint8_t\n    *p_y,\n    *p_cb,\n    *p_cr;\n\n  void\n    *file_data;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  length=GetBlobSize(image);\n  file_data=AcquireMagickMemory(length);\n  if (file_data == (void *) NULL)\n    ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n  if (ReadBlob(image,length,file_data) != (ssize_t) length)\n    {\n      file_data=RelinquishMagickMemory(file_data);\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    }\n  \/*\n    Decode HEIF file\n  *\/\n  heif_context=heif_context_alloc();\n  error=heif_context_read_from_memory(heif_context,file_data,length,NULL);\n  file_data=RelinquishMagickMemory(file_data);\n  if (IsHeifSuccess(&error,image) == MagickFalse)\n    {\n      heif_context_free(heif_context);\n      return(DestroyImageList(image));\n    }\n  image_handle=(struct heif_image_handle *) NULL;\n  error=heif_context_get_primary_image_handle(heif_context,&image_handle);\n  if (IsHeifSuccess(&error,image) == MagickFalse)\n    {\n      heif_context_free(heif_context);\n      return(DestroyImageList(image));\n    }\n  \/*\n    Read Exif data from HEIC file\n  *\/\n  count=heif_image_handle_get_list_of_metadata_block_IDs(image_handle,\"Exif\",\n    &exif_id,1);\n  if (count > 0)\n    {\n      size_t\n        exif_size;\n\n      void\n        *exif_buffer;\n\n      exif_size=heif_image_handle_get_metadata_size(image_handle,exif_id);\n      if (exif_size > GetBlobSize(image))\n        {\n          heif_image_handle_release(image_handle);\n          heif_context_free(heif_context);\n          ThrowReaderException(CorruptImageError,\n            \"InsufficientImageDataInFile\");\n        }\n      exif_buffer=AcquireMagickMemory(exif_size);\n      error=heif_image_handle_get_metadata(image_handle,exif_id,exif_buffer);\n      if (error.code == 0)\n        {\n          StringInfo\n            *profile;\n\n          profile=BlobToStringInfo(exif_buffer,exif_size);\n          SetImageProfile(image,\"exif\",profile);\n          profile=DestroyStringInfo(profile);\n      }\n      exif_buffer=RelinquishMagickMemory(exif_buffer);\n  }\n  \/*\n    Set image size\n   *\/\n  image->depth=8;\n  image->columns=(size_t) heif_image_handle_get_width(image_handle);\n  image->rows=(size_t) heif_image_handle_get_height(image_handle);\n  if (image_info->ping != MagickFalse)\n    {\n      image->colorspace=YCbCrColorspace;\n      heif_image_handle_release(image_handle);\n      heif_context_free(heif_context);\n      return(GetFirstImageInList(image));\n    }\n  status=SetImageExtent(image,image->columns,image->rows);\n  if (status == MagickFalse)\n    {\n      heif_image_handle_release(image_handle);\n      heif_context_free(heif_context);\n      return(DestroyImageList(image));\n    }\n  \/*\n    Copy HEIF image into ImageMagick data structures\n  *\/\n  (void) SetImageColorspace(image,YCbCrColorspace);\n  error=heif_decode_image(image_handle,&heif_image,heif_colorspace_YCbCr,\n    heif_chroma_420,NULL);\n  if (IsHeifSuccess(&error,image) == MagickFalse)\n    {\n      heif_image_handle_release(image_handle);\n      heif_context_free(heif_context);\n      return(DestroyImageList(image));\n    }\n  p_y=heif_image_get_plane(heif_image,heif_channel_Y,&stride_y);\n  p_cb=heif_image_get_plane(heif_image,heif_channel_Cb,&stride_cb);\n  p_cr=heif_image_get_plane(heif_image,heif_channel_Cr,&stride_cr);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    PixelPacket\n      *q;\n\n    register ssize_t\n      x;\n\n    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n    if (q == (PixelPacket *) NULL)\n      break;\n    for (x=0; x < (long) image->columns; x++)\n    {\n      SetPixelRed(q,ScaleCharToQuantum(p_y[y*stride_y + x]));\n      SetPixelGreen(q,ScaleCharToQuantum(p_cb[(y\/2)*stride_cb + x\/2]));\n      SetPixelBlue(q,ScaleCharToQuantum(p_cr[(y\/2)*stride_cr + x\/2]));\n      q++;\n    }\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n  }\n  heif_image_release(heif_image);\n  heif_image_handle_release(image_handle);\n  heif_context_free(heif_context);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":1336,"total_token_length":1572,"max_tokens_setting":2048}
+{"idx":391636,"func":"static bool share_conflict(struct share_mode_entry *entry,\n\t\t\t   uint32 access_mask,\n\t\t\t   uint32 share_access)\n{\n\tDEBUG(10,(\"share_conflict: entry->access_mask = 0x%x, \"\n\t\t  \"entry->share_access = 0x%x, \"\n\t\t  \"entry->private_options = 0x%x\\n\",\n\t\t  (unsigned int)entry->access_mask,\n\t\t  (unsigned int)entry->share_access,\n\t\t  (unsigned int)entry->private_options));\n\n\tif (server_id_is_disconnected(&entry->pid)) {\n\t\t\/*\n\t\t * note: cleanup should have been done by\n\t\t * delay_for_batch_oplocks()\n\t\t *\/\n\t\treturn false;\n\t}\n\n\tDEBUG(10,(\"share_conflict: access_mask = 0x%x, share_access = 0x%x\\n\",\n\t\t  (unsigned int)access_mask, (unsigned int)share_access));\n\n\tif ((entry->access_mask & (FILE_WRITE_DATA|\n\t\t\t\t   FILE_APPEND_DATA|\n\t\t\t\t   FILE_READ_DATA|\n\t\t\t\t   FILE_EXECUTE|\n\t\t\t\t   DELETE_ACCESS)) == 0) {\n\t\tDEBUG(10,(\"share_conflict: No conflict due to \"\n\t\t\t  \"entry->access_mask = 0x%x\\n\",\n\t\t\t  (unsigned int)entry->access_mask ));\n\t\treturn False;\n\t}\n\n\tif ((access_mask & (FILE_WRITE_DATA|\n\t\t\t    FILE_APPEND_DATA|\n\t\t\t    FILE_READ_DATA|\n\t\t\t    FILE_EXECUTE|\n\t\t\t    DELETE_ACCESS)) == 0) {\n\t\tDEBUG(10,(\"share_conflict: No conflict due to \"\n\t\t\t  \"access_mask = 0x%x\\n\",\n\t\t\t  (unsigned int)access_mask ));\n\t\treturn False;\n\t}\n\n#if 1 \/* JRA TEST - Superdebug. *\/\n#define CHECK_MASK(num, am, right, sa, share) \\\n\tDEBUG(10,(\"share_conflict: [%d] am (0x%x) & right (0x%x) = 0x%x\\n\", \\\n\t\t(unsigned int)(num), (unsigned int)(am), \\\n\t\t(unsigned int)(right), (unsigned int)(am)&(right) )); \\\n\tDEBUG(10,(\"share_conflict: [%d] sa (0x%x) & share (0x%x) = 0x%x\\n\", \\\n\t\t(unsigned int)(num), (unsigned int)(sa), \\\n\t\t(unsigned int)(share), (unsigned int)(sa)&(share) )); \\\n\tif (((am) & (right)) && !((sa) & (share))) { \\\n\t\tDEBUG(10,(\"share_conflict: check %d conflict am = 0x%x, right = 0x%x, \\\nsa = 0x%x, share = 0x%x\\n\", (num), (unsigned int)(am), (unsigned int)(right), (unsigned int)(sa), \\\n\t\t\t(unsigned int)(share) )); \\\n\t\treturn True; \\\n\t}\n#else\n#define CHECK_MASK(num, am, right, sa, share) \\\n\tif (((am) & (right)) && !((sa) & (share))) { \\\n\t\tDEBUG(10,(\"share_conflict: check %d conflict am = 0x%x, right = 0x%x, \\\nsa = 0x%x, share = 0x%x\\n\", (num), (unsigned int)(am), (unsigned int)(right), (unsigned int)(sa), \\\n\t\t\t(unsigned int)(share) )); \\\n\t\treturn True; \\\n\t}\n#endif\n\n\tCHECK_MASK(1, entry->access_mask, FILE_WRITE_DATA | FILE_APPEND_DATA,\n\t\t   share_access, FILE_SHARE_WRITE);\n\tCHECK_MASK(2, access_mask, FILE_WRITE_DATA | FILE_APPEND_DATA,\n\t\t   entry->share_access, FILE_SHARE_WRITE);\n\n\tCHECK_MASK(3, entry->access_mask, FILE_READ_DATA | FILE_EXECUTE,\n\t\t   share_access, FILE_SHARE_READ);\n\tCHECK_MASK(4, access_mask, FILE_READ_DATA | FILE_EXECUTE,\n\t\t   entry->share_access, FILE_SHARE_READ);\n\n\tCHECK_MASK(5, entry->access_mask, DELETE_ACCESS,\n\t\t   share_access, FILE_SHARE_DELETE);\n\tCHECK_MASK(6, access_mask, DELETE_ACCESS,\n\t\t   entry->share_access, FILE_SHARE_DELETE);\n\n\tDEBUG(10,(\"share_conflict: No conflict.\\n\"));\n\treturn False;\n}","target":0,"code_token_length":886,"total_token_length":1122,"max_tokens_setting":2048}
+{"idx":219949,"func":"int callback_glewlwyd_user_update_password (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_session, * j_password, * j_element = NULL;\n  char * session_uid = get_session_id(config, request);\n  const char ** passwords = NULL;\n  int res;\n  struct _user_module_instance * user_module;\n  size_t index = 0;\n\n  if (session_uid != NULL && o_strlen(session_uid)) {\n    j_session = get_current_user_for_session(config, session_uid);\n    if (check_result_value(j_session, G_OK)) {\n      j_password = ulfius_get_json_body_request(request, NULL);\n      user_module = get_user_module_instance(config, json_string_value(json_object_get(json_object_get(j_session, \"user\"), \"source\")));\n      if (user_module && user_module->multiple_passwords) {\n        if (json_string_length(json_object_get(j_password, \"old_password\")) && json_is_array(json_object_get(j_password, \"password\"))) {\n          if ((passwords = o_malloc(json_array_size(json_object_get(j_password, \"password\")) * sizeof(char *))) != NULL) {\n            json_array_foreach(json_object_get(j_password, \"password\"), index, j_element) {\n              passwords[index] = json_string_value(j_element);\n            }\n            if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, \"user\"), \"username\")), json_string_value(json_object_get(j_password, \"old_password\")), passwords, json_array_size(json_object_get(j_password, \"password\")))) == G_ERROR_PARAM) {\n              response->status = 400;\n            } else if (res != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_update_password - Error user_update_password (1)\");\n              response->status = 500;\n            }\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_update_password - Error allocating resources for passwords (1)\");\n            response->status = 500;\n          }\n          o_free(passwords);\n        } else {\n          response->status = 400;\n        }\n      } else {\n        if (json_string_length(json_object_get(j_password, \"old_password\")) && json_string_length(json_object_get(j_password, \"password\"))) {\n          if ((passwords = o_malloc(sizeof(char *))) != NULL) {\n            passwords[0] = json_string_value(json_object_get(j_password, \"password\"));\n            if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, \"user\"), \"username\")), json_string_value(json_object_get(j_password, \"old_password\")), passwords, 1)) == G_ERROR_PARAM) {\n              response->status = 400;\n            } else if (res != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_update_password - Error user_update_password (2)\");\n              response->status = 500;\n            }\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_update_password - Error allocating resources for passwords (2)\");\n            response->status = 500;\n          }\n          o_free(passwords);\n        } else {\n          response->status = 400;\n        }\n      }\n      json_decref(j_password);\n    } else if (check_result_value(j_session, G_ERROR_NOT_FOUND)) {\n      response->status = 401;\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_update_password - Error get_current_user_for_session\");\n      response->status = 500;\n    }\n    json_decref(j_session);\n  } else {\n    response->status = 401;\n  }\n  o_free(session_uid);\n  \n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":849,"total_token_length":1085,"max_tokens_setting":2048}
+{"idx":195670,"func":"static pj_xml_node *xml_parse_node( pj_pool_t *pool, pj_scanner *scanner)\n{\n    pj_xml_node *node;\n    pj_str_t end_name;\n\n    PJ_CHECK_STACK();\n\n    if (*scanner->curptr != '<')\n\ton_syntax_error(scanner);\n\n    \/* Handle Processing Instructino (PI) construct (i.e. \"<?\") *\/\n    if (*scanner->curptr == '<' && *(scanner->curptr+1) == '?') {\n\tpj_scan_advance_n(scanner, 2, PJ_FALSE);\n\tfor (;;) {\n\t    pj_str_t dummy;\n\t    pj_scan_get_until_ch(scanner, '?', &dummy);\n\t    if (*scanner->curptr=='?' && *(scanner->curptr+1)=='>') {\n\t\tpj_scan_advance_n(scanner, 2, PJ_TRUE);\n\t\tbreak;\n\t    } else {\n\t\tpj_scan_advance_n(scanner, 1, PJ_FALSE);\n\t    }\n\t}\n\treturn xml_parse_node(pool, scanner);\n    }\n\n    \/* Handle comments construct (i.e. \"<!\") *\/\n    if (pj_scan_strcmp(scanner, \"<!\", 2) == 0) {\n\tpj_scan_advance_n(scanner, 2, PJ_FALSE);\n\tfor (;;) {\n\t    pj_str_t dummy;\n\t    pj_scan_get_until_ch(scanner, '>', &dummy);\n\t    if (pj_scan_strcmp(scanner, \">\", 1) == 0) {\n\t\tpj_scan_advance_n(scanner, 1, PJ_TRUE);\n\t\tbreak;\n\t    } else {\n\t\tpj_scan_advance_n(scanner, 1, PJ_FALSE);\n\t    }\n\t}\n\treturn xml_parse_node(pool, scanner);\n    }\n\n    \/* Alloc node. *\/\n    node = alloc_node(pool);\n\n    \/* Get '<' *\/\n    pj_scan_get_char(scanner);\n\n    \/* Get node name. *\/\n    pj_scan_get_until_chr( scanner, \" \/>\\t\\r\\n\", &node->name);\n\n    \/* Get attributes. *\/\n    while (*scanner->curptr != '>' && *scanner->curptr != '\/') {\n\tpj_xml_attr *attr = alloc_attr(pool);\n\t\n\tpj_scan_get_until_chr( scanner, \"=> \\t\\r\\n\", &attr->name);\n\tif (*scanner->curptr == '=') {\n\t    pj_scan_get_char( scanner );\n            pj_scan_get_quotes(scanner, \"\\\"'\", \"\\\"'\", 2, &attr->value);\n\t    \/* remove quote characters *\/\n\t    ++attr->value.ptr;\n\t    attr->value.slen -= 2;\n\t}\n\t\n\tpj_list_push_back( &node->attr_head, attr );\n    }\n\n    if (*scanner->curptr == '\/') {\n\tpj_scan_get_char(scanner);\n\tif (pj_scan_get_char(scanner) != '>')\n\t    on_syntax_error(scanner);\n\treturn node;\n    }\n\n    \/* Enclosing bracket. *\/\n    if (pj_scan_get_char(scanner) != '>')\n\ton_syntax_error(scanner);\n\n    \/* Sub nodes. *\/\n    while (*scanner->curptr == '<' && *(scanner->curptr+1) != '\/'\n\t\t\t\t   && *(scanner->curptr+1) != '!')\n    {\n\tpj_xml_node *sub_node = xml_parse_node(pool, scanner);\n\tpj_list_push_back( &node->node_head, sub_node );\n    }\n\n    \/* Content. *\/\n    if (!pj_scan_is_eof(scanner) && *scanner->curptr != '<') {\n\tpj_scan_get_until_ch(scanner, '<', &node->content);\n    }\n\n    \/* CDATA content. *\/\n    if (*scanner->curptr == '<' && *(scanner->curptr+1) == '!' &&\n\tpj_scan_strcmp(scanner, \"<![CDATA[\", 9) == 0)\n    {\n\tpj_scan_advance_n(scanner, 9, PJ_FALSE);\n\tpj_scan_get_until_ch(scanner, ']', &node->content);\n\twhile (pj_scan_strcmp(scanner, \"]]>\", 3)) {\n\t    pj_str_t dummy;\n\t    pj_scan_get_until_ch(scanner, ']', &dummy);\n\t}\n\tnode->content.slen = scanner->curptr - node->content.ptr;\n\tpj_scan_advance_n(scanner, 3, PJ_TRUE);\n    }\n\n    \/* Enclosing node. *\/\n    if (pj_scan_get_char(scanner) != '<' || pj_scan_get_char(scanner) != '\/')\n\ton_syntax_error(scanner);\n\n    pj_scan_get_until_chr(scanner, \" \\t>\", &end_name);\n\n    \/* Compare name. *\/\n    if (pj_stricmp(&node->name, &end_name) != 0)\n\ton_syntax_error(scanner);\n\n    \/* Enclosing '>' *\/\n    if (pj_scan_get_char(scanner) != '>')\n\ton_syntax_error(scanner);\n\n    return node;\n}","target":1,"code_token_length":952,"total_token_length":1188,"max_tokens_setting":2048}
+{"idx":221488,"func":"flatpak_run_add_a11y_dbus_args (FlatpakBwrap   *app_bwrap,\n                                FlatpakBwrap   *proxy_arg_bwrap,\n                                FlatpakContext *context,\n                                FlatpakRunFlags flags)\n{\n  static const char sandbox_socket_path[] = \"\/run\/flatpak\/at-spi-bus\";\n  static const char sandbox_dbus_address[] = \"unix:path=\/run\/flatpak\/at-spi-bus\";\n  g_autoptr(GDBusConnection) session_bus = NULL;\n  g_autofree char *a11y_address = NULL;\n  g_autoptr(GError) local_error = NULL;\n  g_autoptr(GDBusMessage) reply = NULL;\n  g_autoptr(GDBusMessage) msg = NULL;\n  g_autofree char *proxy_socket = NULL;\n\n  if ((flags & FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY) != 0)\n    return FALSE;\n\n  session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);\n  if (session_bus == NULL)\n    return FALSE;\n\n  msg = g_dbus_message_new_method_call (\"org.a11y.Bus\", \"\/org\/a11y\/bus\", \"org.a11y.Bus\", \"GetAddress\");\n  g_dbus_message_set_body (msg, g_variant_new (\"()\"));\n  reply =\n    g_dbus_connection_send_message_with_reply_sync (session_bus, msg,\n                                                    G_DBUS_SEND_MESSAGE_FLAGS_NONE,\n                                                    30000,\n                                                    NULL,\n                                                    NULL,\n                                                    NULL);\n  if (reply)\n    {\n      if (g_dbus_message_to_gerror (reply, &local_error))\n        {\n          if (!g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN))\n            g_message (\"Can't find a11y bus: %s\", local_error->message);\n        }\n      else\n        {\n          g_variant_get (g_dbus_message_get_body (reply),\n                         \"(s)\", &a11y_address);\n        }\n    }\n\n  if (!a11y_address)\n    return FALSE;\n\n  proxy_socket = create_proxy_socket (\"a11y-bus-proxy-XXXXXX\");\n  if (proxy_socket == NULL)\n    return FALSE;\n\n  flatpak_bwrap_add_args (proxy_arg_bwrap,\n                          a11y_address,\n                          proxy_socket, \"--filter\", \"--sloppy-names\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.Socket.Embed@\/org\/a11y\/atspi\/accessible\/root\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.Socket.Unembed@\/org\/a11y\/atspi\/accessible\/root\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.Registry.GetRegisteredEvents@\/org\/a11y\/atspi\/registry\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.GetKeystrokeListeners@\/org\/a11y\/atspi\/registry\/deviceeventcontroller\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.GetDeviceEventListeners@\/org\/a11y\/atspi\/registry\/deviceeventcontroller\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.NotifyListenersSync@\/org\/a11y\/atspi\/registry\/deviceeventcontroller\",\n                          \"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.NotifyListenersAsync@\/org\/a11y\/atspi\/registry\/deviceeventcontroller\",\n                          NULL);\n\n  if ((flags & FLATPAK_RUN_FLAG_LOG_A11Y_BUS) != 0)\n    flatpak_bwrap_add_args (proxy_arg_bwrap, \"--log\", NULL);\n\n  flatpak_bwrap_add_args (app_bwrap,\n                          \"--ro-bind\", proxy_socket, sandbox_socket_path,\n                          NULL);\n  flatpak_bwrap_set_env (app_bwrap, \"AT_SPI_BUS_ADDRESS\", sandbox_dbus_address, TRUE);\n\n  return TRUE;\n}","target":0,"code_token_length":906,"total_token_length":1142,"max_tokens_setting":2048}
+{"idx":195404,"func":"  void Compute(OpKernelContext* context) override {\n    typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        ConstEigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenMatrixMap;\n\n    constexpr int tensor_in_and_out_dims = 4;\n\n    const Tensor& tensor_in = context->input(0);\n    OP_REQUIRES(context, tensor_in.dims() == tensor_in_and_out_dims,\n                errors::InvalidArgument(\"tensor_in must be 4-dimensional\"));\n\n    std::vector<int> input_size(tensor_in_and_out_dims);\n    std::vector<int> output_size(tensor_in_and_out_dims);\n    for (int i = 0; i < tensor_in_and_out_dims; ++i) {\n      input_size[i] = tensor_in.dim_size(i);\n    }\n    \/\/ Output size.\n    for (int i = 0; i < tensor_in_and_out_dims; ++i) {\n      \/\/ This must match the same logic in the shape function in\n      \/\/ core\/ops\/nn_ops.cc.\n      output_size[i] =\n          static_cast<int>(std::floor(input_size[i] \/ pooling_ratio_[i]));\n      DCHECK_GT(output_size[i], 0);\n    }\n\n    \/\/ Generate pooling sequence.\n    std::vector<int64_t> height_cum_seq;\n    std::vector<int64_t> width_cum_seq;\n    GuardedPhiloxRandom generator;\n    generator.Init(seed_, seed2_);\n    height_cum_seq = GeneratePoolingSequence(input_size[1], output_size[1],\n                                             &generator, pseudo_random_);\n    width_cum_seq = GeneratePoolingSequence(input_size[2], output_size[2],\n                                            &generator, pseudo_random_);\n\n    \/\/ Prepare output.\n    Tensor* output_tensor = nullptr;\n    OP_REQUIRES_OK(context, context->allocate_output(\n                                0,\n                                TensorShape({output_size[0], output_size[1],\n                                             output_size[2], output_size[3]}),\n                                &output_tensor));\n    Tensor* output_height_seq_tensor = nullptr;\n    OP_REQUIRES_OK(\n        context,\n        context->allocate_output(\n            1, TensorShape({static_cast<int64_t>(height_cum_seq.size())}),\n            &output_height_seq_tensor));\n    Tensor* output_width_seq_tensor = nullptr;\n    OP_REQUIRES_OK(\n        context,\n        context->allocate_output(\n            2, TensorShape({static_cast<int64_t>(width_cum_seq.size())}),\n            &output_width_seq_tensor));\n\n    ConstEigenMatrixMap in_mat(tensor_in.flat<T>().data(), input_size[3],\n                               input_size[2] * input_size[1] * input_size[0]);\n\n    EigenMatrixMap out_mat(output_tensor->flat<T>().data(), output_size[3],\n                           output_size[2] * output_size[1] * output_size[0]);\n\n    \/\/ Initializes the output tensor with MIN<T>.\n    output_tensor->flat<T>().setConstant(Eigen::NumTraits<T>::lowest());\n\n    auto output_height_seq_flat = output_height_seq_tensor->flat<int64_t>();\n    auto output_width_seq_flat = output_width_seq_tensor->flat<int64_t>();\n\n    \/\/ Set output tensors.\n    for (int i = 0; i < height_cum_seq.size(); ++i) {\n      output_height_seq_flat(i) = height_cum_seq[i];\n    }\n\n    for (int i = 0; i < width_cum_seq.size(); ++i) {\n      output_width_seq_flat(i) = width_cum_seq[i];\n    }\n\n    \/\/ For both input and output,\n    \/\/ 0: batch\n    \/\/ 1: height \/ row\n    \/\/ 2: width \/ col\n    \/\/ 3: depth \/ channel\n    const int64_t height_max = input_size[1] - 1;\n    const int64_t width_max = input_size[2] - 1;\n    for (int64_t b = 0; b < input_size[0]; ++b) {\n      \/\/ height sequence.\n      for (int64_t hs = 0; hs < height_cum_seq.size() - 1; ++hs) {\n        \/\/ height start and end.\n        const int64_t height_start = height_cum_seq[hs];\n        int64_t height_end =\n            overlapping_ ? height_cum_seq[hs + 1] : height_cum_seq[hs + 1] - 1;\n        height_end = std::min(height_end, height_max);\n\n        \/\/ width sequence.\n        for (int64_t ws = 0; ws < width_cum_seq.size() - 1; ++ws) {\n          const int64_t out_offset =\n              (b * output_size[1] + hs) * output_size[2] + ws;\n          \/\/ width start and end.\n          const int64_t width_start = width_cum_seq[ws];\n          int64_t width_end =\n              overlapping_ ? width_cum_seq[ws + 1] : width_cum_seq[ws + 1] - 1;\n          width_end = std::min(width_end, width_max);\n          for (int64_t h = height_start; h <= height_end; ++h) {\n            for (int64_t w = width_start; w <= width_end; ++w) {\n              const int64_t in_offset =\n                  (b * input_size[1] + h) * input_size[2] + w;\n              out_mat.col(out_offset) =\n                  out_mat.col(out_offset).cwiseMax(in_mat.col(in_offset));\n            }\n          }\n        }\n      }\n    }\n  }","target":1,"code_token_length":1185,"total_token_length":1421,"max_tokens_setting":2048}
+{"idx":195295,"func":"gen_assignment(codegen_scope *s, node *tree, node *rhs, int sp, int val)\n{\n  int idx;\n  int type = nint(tree->car);\n\n  switch (type) {\n  case NODE_GVAR:\n  case NODE_ARG:\n  case NODE_LVAR:\n  case NODE_IVAR:\n  case NODE_CVAR:\n  case NODE_CONST:\n  case NODE_NIL:\n  case NODE_MASGN:\n    if (rhs) {\n      codegen(s, rhs, VAL);\n      pop();\n      sp = cursp();\n    }\n    break;\n\n  case NODE_COLON2:\n  case NODE_CALL:\n  case NODE_SCALL:\n    \/* keep evaluation order *\/\n    break;\n\n  case NODE_NVAR:\n    codegen_error(s, \"Can't assign to numbered parameter\");\n    break;\n\n  default:\n    codegen_error(s, \"unknown lhs\");\n    break;\n  }\n\n  tree = tree->cdr;\n  switch (type) {\n  case NODE_GVAR:\n    gen_setxv(s, OP_SETGV, sp, nsym(tree), val);\n    break;\n  case NODE_ARG:\n  case NODE_LVAR:\n    idx = lv_idx(s, nsym(tree));\n    if (idx > 0) {\n      if (idx != sp) {\n        gen_move(s, idx, sp, val);\n      }\n      break;\n    }\n    else {                      \/* upvar *\/\n      gen_setupvar(s, sp, nsym(tree));\n    }\n    break;\n  case NODE_IVAR:\n    gen_setxv(s, OP_SETIV, sp, nsym(tree), val);\n    break;\n  case NODE_CVAR:\n    gen_setxv(s, OP_SETCV, sp, nsym(tree), val);\n    break;\n  case NODE_CONST:\n    gen_setxv(s, OP_SETCONST, sp, nsym(tree), val);\n    break;\n  case NODE_COLON2:\n    if (sp) {\n      gen_move(s, cursp(), sp, 0);\n    }\n    sp = cursp();\n    push();\n    codegen(s, tree->car, VAL);\n    if (rhs) {\n      codegen(s, rhs, VAL); pop();\n      gen_move(s, sp, cursp(), 0);\n    }\n    pop_n(2);\n    idx = new_sym(s, nsym(tree->cdr));\n    genop_2(s, OP_SETMCNST, sp, idx);\n    break;\n\n  case NODE_CALL:\n  case NODE_SCALL:\n    {\n      int noself = 0, safe = (type == NODE_SCALL), skip = 0, top, call, n = 0;\n      mrb_sym mid = nsym(tree->cdr->car);\n\n      top = cursp();\n      if (val || sp == cursp()) {\n        push();                   \/* room for retval *\/\n      }\n      call = cursp();\n      if (!tree->car) {\n        noself = 1;\n        push();\n      }\n      else {\n        codegen(s, tree->car, VAL); \/* receiver *\/\n      }\n      if (safe) {\n        int recv = cursp()-1;\n        gen_move(s, cursp(), recv, 1);\n        skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n      }\n      tree = tree->cdr->cdr->car;\n      if (tree) {\n        if (tree->car) {            \/* positional arguments *\/\n          n = gen_values(s, tree->car, VAL, (tree->cdr->car)?13:14);\n          if (n < 0) {              \/* variable length *\/\n            n = 15;\n            push();\n          }\n        }\n        if (tree->cdr->car) {       \/* keyword arguments *\/\n          if (n == 14) {\n            pop_n(n);\n            genop_2(s, OP_ARRAY, cursp(), n);\n            push();\n            n = 15;\n          }\n          gen_hash(s, tree->cdr->car->cdr, VAL, 0);\n          if (n < 14) {\n            n++;\n          }\n          else {\n            pop_n(2);\n            genop_2(s, OP_ARYPUSH, cursp(), 1);\n          }\n          push();\n        }\n      }\n      if (rhs) {\n        codegen(s, rhs, VAL);\n        pop();\n      }\n      else {\n        gen_move(s, cursp(), sp, 0);\n      }\n      if (val) {\n        gen_move(s, top, cursp(), 1);\n      }\n      if (n < 15) {\n        n++;\n        if (n == 15) {\n          pop_n(14);\n          genop_2(s, OP_ARRAY, cursp(), 15);\n        }\n      }\n      else {\n        pop();\n        genop_2(s, OP_ARYPUSH, cursp(), 1);\n      }\n      s->sp = call;\n      if (mid == MRB_OPSYM_2(s->mrb, aref) && n == 2) {\n        genop_1(s, OP_SETIDX, cursp());\n      }\n      else {\n        genop_3(s, noself ? OP_SSEND : OP_SEND, cursp(), new_sym(s, attrsym(s, mid)), n);\n      }\n      if (safe) {\n        dispatch(s, skip);\n      }\n      s->sp = top;\n    }\n    break;\n\n  case NODE_MASGN:\n    gen_massignment(s, tree->car, sp, val);\n    break;\n\n  \/* splat without assignment *\/\n  case NODE_NIL:\n    break;\n\n  default:\n    codegen_error(s, \"unknown lhs\");\n    break;\n  }\n  if (val) push();\n}","target":1,"code_token_length":1219,"total_token_length":1455,"max_tokens_setting":2048}
+{"idx":513249,"func":"static int test_if_order_by_key(JOIN *join,\n                                ORDER *order, TABLE *table, uint idx,\n\t\t\t\tuint *used_key_parts= NULL)\n{\n  KEY_PART_INFO *key_part,*key_part_end;\n  key_part=table->key_info[idx].key_part;\n  key_part_end=key_part + table->key_info[idx].ext_key_parts;\n  key_part_map const_key_parts=table->const_key_parts[idx];\n  uint user_defined_kp= table->key_info[idx].user_defined_key_parts;\n  int reverse=0;\n  uint key_parts;\n  bool have_pk_suffix= false;\n  uint pk= table->s->primary_key;\n  DBUG_ENTER(\"test_if_order_by_key\");\n \n  if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && \n      table->key_info[idx].ext_key_part_map &&\n      pk != MAX_KEY && pk != idx)\n  {\n    have_pk_suffix= true;\n  }\n\n  for (; order ; order=order->next, const_key_parts>>=1)\n  {\n    Item_field *item_field= ((Item_field*) (*order->item)->real_item());\n    Field *field= item_field->field;\n    int flag;\n\n    \/*\n      Skip key parts that are constants in the WHERE clause.\n      These are already skipped in the ORDER BY by const_expression_in_where()\n    *\/\n    for (; const_key_parts & 1 ; const_key_parts>>= 1)\n      key_part++; \n    \n    \/*\n      This check was in this function historically (although I think it's\n      better to check it outside of this function):\n\n      \"Test if the primary key parts were all const (i.e. there's one row).\n       The sorting doesn't matter\"\n\n       So, we're checking that \n       (1) this is an extended key\n       (2) we've reached its end\n    *\/\n    key_parts= (uint)(key_part - table->key_info[idx].key_part);\n    if (have_pk_suffix &&\n        reverse == 0 && \/\/ all were =const so far\n        key_parts == table->key_info[idx].ext_key_parts && \n        table->const_key_parts[pk] == PREV_BITS(uint, \n                                                table->key_info[pk].\n                                                user_defined_key_parts))\n    {\n      key_parts= 0;\n      reverse= 1;                           \/\/ Key is ok to use\n      goto ok;\n    }\n\n    if (key_part == key_part_end)\n    {\n      \/*\n        There are some items left in ORDER BY that we don't\n      *\/\n      DBUG_RETURN(0);\n    }\n\n    if (key_part->field != field)\n    {\n      \/*\n        Check if there is a multiple equality that allows to infer that field\n        and key_part->field are equal \n        (see also: compute_part_of_sort_key_for_equals)\n      *\/\n      if (item_field->item_equal && \n          item_field->item_equal->contains(key_part->field))\n        field= key_part->field;\n    }\n    if (key_part->field != field || !field->part_of_sortkey.is_set(idx))\n      DBUG_RETURN(0);\n\n    const ORDER::enum_order keypart_order= \n      (key_part->key_part_flag & HA_REVERSE_SORT) ? \n      ORDER::ORDER_DESC : ORDER::ORDER_ASC;\n    \/* set flag to 1 if we can use read-next on key, else to -1 *\/\n    flag= (order->direction == keypart_order) ? 1 : -1;\n    if (reverse && flag != reverse)\n      DBUG_RETURN(0);\n    reverse=flag;\t\t\t\t\/\/ Remember if reverse\n    if (key_part < key_part_end)\n      key_part++;\n  }\n\n  key_parts= (uint) (key_part - table->key_info[idx].key_part);\n\n  if (reverse == -1 && \n      !(table->file->index_flags(idx, user_defined_kp-1, 1) & HA_READ_PREV))\n    reverse= 0;                               \/\/ Index can't be used\n  \n  if (have_pk_suffix && reverse == -1)\n  {\n    uint pk_parts= table->key_info[pk].user_defined_key_parts;\n    if (!(table->file->index_flags(pk, pk_parts, 1) & HA_READ_PREV))\n      reverse= 0;                               \/\/ Index can't be used\n  }\n\nok:\n  if (used_key_parts != NULL)\n    *used_key_parts= key_parts;\n  DBUG_RETURN(reverse);\n}","target":0,"code_token_length":952,"total_token_length":1188,"max_tokens_setting":2048}
+{"idx":210551,"func":"expand_case_fold_string(Node* node, regex_t* reg)\n{\n#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION  8\n\n  int r, n, len, alt_num;\n  UChar *start, *end, *p;\n  Node *top_root, *root, *snode, *prev_node;\n  OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];\n  StrNode* sn = STR_(node);\n\n  if (NODE_STRING_IS_AMBIG(node)) return 0;\n\n  start = sn->s;\n  end   = sn->end;\n  if (start >= end) return 0;\n\n  r = 0;\n  top_root = root = prev_node = snode = NULL_NODE;\n  alt_num = 1;\n  p = start;\n  while (p < end) {\n    n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(reg->enc, reg->case_fold_flag, p, end,\n                                           items);\n    if (n < 0) {\n      r = n;\n      goto err;\n    }\n\n    len = enclen(reg->enc, p);\n\n    if (n == 0) {\n      if (IS_NULL(snode)) {\n        if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {\n          top_root = root = onig_node_list_add(NULL_NODE, prev_node);\n          if (IS_NULL(root)) {\n            onig_node_free(prev_node);\n            goto mem_err;\n          }\n        }\n\n        prev_node = snode = onig_node_new_str(NULL, NULL);\n        if (IS_NULL(snode)) goto mem_err;\n        if (IS_NOT_NULL(root)) {\n          if (IS_NULL(onig_node_list_add(root, snode))) {\n            onig_node_free(snode);\n            goto mem_err;\n          }\n        }\n      }\n\n      r = onig_node_str_cat(snode, p, p + len);\n      if (r != 0) goto err;\n    }\n    else {\n      alt_num *= (n + 1);\n      if (alt_num > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break;\n\n      if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {\n        top_root = root = onig_node_list_add(NULL_NODE, prev_node);\n        if (IS_NULL(root)) {\n          onig_node_free(prev_node);\n          goto mem_err;\n        }\n      }\n\n      r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node);\n      if (r < 0) goto mem_err;\n      if (r == 1) {\n        if (IS_NULL(root)) {\n          top_root = prev_node;\n        }\n        else {\n          if (IS_NULL(onig_node_list_add(root, prev_node))) {\n            onig_node_free(prev_node);\n            goto mem_err;\n          }\n        }\n\n        root = NODE_CAR(prev_node);\n      }\n      else { \/* r == 0 *\/\n        if (IS_NOT_NULL(root)) {\n          if (IS_NULL(onig_node_list_add(root, prev_node))) {\n            onig_node_free(prev_node);\n            goto mem_err;\n          }\n        }\n      }\n\n      snode = NULL_NODE;\n    }\n\n    p += len;\n  }\n\n  if (p < end) {\n    Node *srem;\n\n    r = expand_case_fold_make_rem_string(&srem, p, end, reg);\n    if (r != 0) goto mem_err;\n\n    if (IS_NOT_NULL(prev_node) && IS_NULL(root)) {\n      top_root = root = onig_node_list_add(NULL_NODE, prev_node);\n      if (IS_NULL(root)) {\n        onig_node_free(srem);\n        onig_node_free(prev_node);\n        goto mem_err;\n      }\n    }\n\n    if (IS_NULL(root)) {\n      prev_node = srem;\n    }\n    else {\n      if (IS_NULL(onig_node_list_add(root, srem))) {\n        onig_node_free(srem);\n        goto mem_err;\n      }\n    }\n  }\n\n  \/* ending *\/\n  top_root = (IS_NOT_NULL(top_root) ? top_root : prev_node);\n  swap_node(node, top_root);\n  onig_node_free(top_root);\n  return 0;\n\n mem_err:\n  r = ONIGERR_MEMORY;\n\n err:\n  onig_node_free(top_root);\n  return r;\n}","target":1,"code_token_length":921,"total_token_length":1157,"max_tokens_setting":2048}
+{"idx":207280,"func":"win_redr_status(win_T *wp, int ignore_pum UNUSED)\n{\n    int\t\trow;\n    char_u\t*p;\n    int\t\tlen;\n    int\t\tfillchar;\n    int\t\tattr;\n    int\t\tthis_ru_col;\n    static int  busy = FALSE;\n\n    \/\/ It's possible to get here recursively when 'statusline' (indirectly)\n    \/\/ invokes \":redrawstatus\".  Simply ignore the call then.\n    if (busy)\n\treturn;\n    busy = TRUE;\n\n    row = statusline_row(wp);\n\n    wp->w_redr_status = FALSE;\n    if (wp->w_status_height == 0)\n    {\n\t\/\/ no status line, can only be last window\n\tredraw_cmdline = TRUE;\n    }\n    else if (!redrawing()\n\t    \/\/ don't update status line when popup menu is visible and may be\n\t    \/\/ drawn over it, unless it will be redrawn later\n\t    || (!ignore_pum && pum_visible()))\n    {\n\t\/\/ Don't redraw right now, do it later.\n\twp->w_redr_status = TRUE;\n    }\n#ifdef FEAT_STL_OPT\n    else if (*p_stl != NUL || *wp->w_p_stl != NUL)\n    {\n\t\/\/ redraw custom status line\n\tredraw_custom_statusline(wp);\n    }\n#endif\n    else\n    {\n\tfillchar = fillchar_status(&attr, wp);\n\n\tget_trans_bufname(wp->w_buffer);\n\tp = NameBuff;\n\tlen = (int)STRLEN(p);\n\n\tif (bt_help(wp->w_buffer)\n#ifdef FEAT_QUICKFIX\n\t\t|| wp->w_p_pvw\n#endif\n\t\t|| bufIsChanged(wp->w_buffer)\n\t\t|| wp->w_buffer->b_p_ro)\n\t    *(p + len++) = ' ';\n\tif (bt_help(wp->w_buffer))\n\t{\n\t    STRCPY(p + len, _(\"[Help]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n#ifdef FEAT_QUICKFIX\n\tif (wp->w_p_pvw)\n\t{\n\t    STRCPY(p + len, _(\"[Preview]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n#endif\n\tif (bufIsChanged(wp->w_buffer)\n#ifdef FEAT_TERMINAL\n\t\t&& !bt_terminal(wp->w_buffer)\n#endif\n\t\t)\n\t{\n\t    STRCPY(p + len, \"[+]\");\n\t    len += 3;\n\t}\n\tif (wp->w_buffer->b_p_ro)\n\t{\n\t    STRCPY(p + len, _(\"[RO]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n\n\tthis_ru_col = ru_col - (Columns - wp->w_width);\n\tif (this_ru_col < (wp->w_width + 1) \/ 2)\n\t    this_ru_col = (wp->w_width + 1) \/ 2;\n\tif (this_ru_col <= 1)\n\t{\n\t    p = (char_u *)\"<\";\t\t\/\/ No room for file name!\n\t    len = 1;\n\t}\n\telse if (has_mbyte)\n\t{\n\t    int\tclen = 0, i;\n\n\t    \/\/ Count total number of display cells.\n\t    clen = mb_string2cells(p, -1);\n\n\t    \/\/ Find first character that will fit.\n\t    \/\/ Going from start to end is much faster for DBCS.\n\t    for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;\n\t\t    i += (*mb_ptr2len)(p + i))\n\t\tclen -= (*mb_ptr2cells)(p + i);\n\t    len = clen;\n\t    if (i > 0)\n\t    {\n\t\tp = p + i - 1;\n\t\t*p = '<';\n\t\t++len;\n\t    }\n\n\t}\n\telse if (len > this_ru_col - 1)\n\t{\n\t    p += len - (this_ru_col - 1);\n\t    *p = '<';\n\t    len = this_ru_col - 1;\n\t}\n\n\tscreen_puts(p, row, wp->w_wincol, attr);\n\tscreen_fill(row, row + 1, len + wp->w_wincol,\n\t\t\tthis_ru_col + wp->w_wincol, fillchar, fillchar, attr);\n\n\tif (get_keymap_str(wp, (char_u *)\"<%s>\", NameBuff, MAXPATHL)\n\t\t&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))\n\t    screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)\n\t\t\t\t\t\t   - 1 + wp->w_wincol), attr);\n\n#ifdef FEAT_CMDL_INFO\n\twin_redr_ruler(wp, TRUE, ignore_pum);\n#endif\n    }\n\n    \/*\n     * May need to draw the character below the vertical separator.\n     *\/\n    if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())\n    {\n\tif (stl_connected(wp))\n\t    fillchar = fillchar_status(&attr, wp);\n\telse\n\t    fillchar = fillchar_vsep(&attr);\n\tscreen_putchar(fillchar, row, W_ENDCOL(wp), attr);\n    }\n    busy = FALSE;\n}","target":1,"code_token_length":1100,"total_token_length":1336,"max_tokens_setting":2048}
+{"idx":197973,"func":"crun_command_exec (struct crun_global_arguments *global_args, int argc, char **argv, libcrun_error_t *err)\n{\n  int first_arg = 0, ret = 0;\n  libcrun_context_t crun_context = {\n    0,\n  };\n  cleanup_process_schema runtime_spec_schema_config_schema_process *process = NULL;\n  struct libcrun_container_exec_options_s exec_opts;\n\n  memset (&exec_opts, 0, sizeof (exec_opts));\n  exec_opts.struct_size = sizeof (exec_opts);\n\n  crun_context.preserve_fds = 0;\n  crun_context.listen_fds = 0;\n\n  argp_parse (&run_argp, argc, argv, ARGP_IN_ORDER, &first_arg, &exec_options);\n  crun_assert_n_args (argc - first_arg, exec_options.process ? 1 : 2, -1);\n\n  ret = init_libcrun_context (&crun_context, argv[first_arg], global_args, err);\n  if (UNLIKELY (ret < 0))\n    return ret;\n\n  crun_context.detach = exec_options.detach;\n  crun_context.console_socket = exec_options.console_socket;\n  crun_context.pid_file = exec_options.pid_file;\n  crun_context.preserve_fds = exec_options.preserve_fds;\n\n  if (getenv (\"LISTEN_FDS\"))\n    {\n      crun_context.listen_fds = strtoll (getenv (\"LISTEN_FDS\"), NULL, 10);\n      crun_context.preserve_fds += crun_context.listen_fds;\n    }\n\n  if (exec_options.process)\n    exec_opts.path = exec_options.process;\n  else\n    {\n      process = xmalloc0 (sizeof (*process));\n      int i;\n\n      process->args_len = argc;\n      process->args = xmalloc0 ((argc + 1) * sizeof (*process->args));\n      for (i = 0; i < argc - first_arg; i++)\n        process->args[i] = xstrdup (argv[first_arg + i + 1]);\n      process->args[i] = NULL;\n      if (exec_options.cwd)\n        process->cwd = exec_options.cwd;\n      process->terminal = exec_options.tty;\n      process->env = exec_options.env;\n      process->env_len = exec_options.env_size;\n      process->user = make_oci_process_user (exec_options.user);\n\n      if (exec_options.process_label != NULL)\n        process->selinux_label = exec_options.process_label;\n\n      if (exec_options.apparmor != NULL)\n        process->apparmor_profile = exec_options.apparmor;\n\n      if (exec_options.cap_size > 0)\n        {\n          runtime_spec_schema_config_schema_process_capabilities *capabilities\n              = xmalloc (sizeof (runtime_spec_schema_config_schema_process_capabilities));\n\n          capabilities->effective = exec_options.cap;\n          capabilities->effective_len = exec_options.cap_size;\n\n          capabilities->inheritable = dup_array (exec_options.cap, exec_options.cap_size);\n          capabilities->inheritable_len = exec_options.cap_size;\n\n          capabilities->bounding = dup_array (exec_options.cap, exec_options.cap_size);\n          capabilities->bounding_len = exec_options.cap_size;\n\n          capabilities->ambient = dup_array (exec_options.cap, exec_options.cap_size);\n          capabilities->ambient_len = exec_options.cap_size;\n\n          capabilities->permitted = dup_array (exec_options.cap, exec_options.cap_size);\n          capabilities->permitted_len = exec_options.cap_size;\n\n          process->capabilities = capabilities;\n        }\n\n      \/\/ noNewPriviledges will remain `false` if basespec has `false` unless specified\n      \/\/ Default is always `true` in generated basespec config\n      if (exec_options.no_new_privs)\n        process->no_new_privileges = 1;\n\n      exec_opts.process = process;\n    }\n\n  exec_opts.cgroup = exec_options.cgroup;\n\n  return libcrun_container_exec_with_options (&crun_context, argv[first_arg], &exec_opts, err);\n}","target":1,"code_token_length":824,"total_token_length":1060,"max_tokens_setting":2048}
+{"idx":235765,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor* hypothesis_indices;\n    const Tensor* hypothesis_values;\n    const Tensor* hypothesis_shape;\n    const Tensor* truth_indices;\n    const Tensor* truth_values;\n    const Tensor* truth_shape;\n    OP_REQUIRES_OK(ctx, ctx->input(\"hypothesis_indices\", &hypothesis_indices));\n    OP_REQUIRES_OK(ctx, ctx->input(\"hypothesis_values\", &hypothesis_values));\n    OP_REQUIRES_OK(ctx, ctx->input(\"hypothesis_shape\", &hypothesis_shape));\n    OP_REQUIRES_OK(ctx, ctx->input(\"truth_indices\", &truth_indices));\n    OP_REQUIRES_OK(ctx, ctx->input(\"truth_values\", &truth_values));\n    OP_REQUIRES_OK(ctx, ctx->input(\"truth_shape\", &truth_shape));\n\n    OP_REQUIRES_OK(\n        ctx, ValidateShapes(ctx, *hypothesis_indices, *hypothesis_values,\n                            *hypothesis_shape, *truth_indices, *truth_values,\n                            *truth_shape));\n\n    TensorShape hypothesis_st_shape;\n    OP_REQUIRES_OK(ctx,\n                   TensorShapeUtils::MakeShape(\n                       hypothesis_shape->vec<int64_t>().data(),\n                       hypothesis_shape->NumElements(), &hypothesis_st_shape));\n    TensorShape truth_st_shape;\n    OP_REQUIRES_OK(ctx, TensorShapeUtils::MakeShape(\n                            truth_shape->vec<int64_t>().data(),\n                            truth_shape->NumElements(), &truth_st_shape));\n\n    \/\/ Assume indices are sorted in row-major order.\n    std::vector<int64_t> sorted_order(truth_st_shape.dims());\n    std::iota(sorted_order.begin(), sorted_order.end(), 0);\n\n    sparse::SparseTensor hypothesis;\n    OP_REQUIRES_OK(ctx, sparse::SparseTensor::Create(\n                            *hypothesis_indices, *hypothesis_values,\n                            hypothesis_st_shape, sorted_order, &hypothesis));\n\n    sparse::SparseTensor truth;\n    OP_REQUIRES_OK(ctx, sparse::SparseTensor::Create(\n                            *truth_indices, *truth_values, truth_st_shape,\n                            sorted_order, &truth));\n\n    \/\/ Group dims 0, 1, ..., RANK - 1.  The very last dim is assumed\n    \/\/ to store the variable length sequences.\n    std::vector<int64_t> group_dims(truth_st_shape.dims() - 1);\n    std::iota(group_dims.begin(), group_dims.end(), 0);\n\n    TensorShape output_shape;\n    for (int d = 0; d < static_cast<int>(group_dims.size()); ++d) {\n      output_shape.AddDim(std::max(hypothesis_st_shape.dim_size(d),\n                                   truth_st_shape.dim_size(d)));\n    }\n    const auto output_elements = output_shape.num_elements();\n    OP_REQUIRES(\n        ctx, output_elements > 0,\n        errors::InvalidArgument(\"Got output shape \", output_shape.DebugString(),\n                                \" which has 0 elements\"));\n\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"output\", output_shape, &output));\n    auto output_t = output->flat<float>();\n    output_t.setZero();\n\n    std::vector<int64_t> output_strides(output_shape.dims());\n    output_strides[output_shape.dims() - 1] = 1;\n    for (int d = output_shape.dims() - 2; d >= 0; --d) {\n      output_strides[d] = output_strides[d + 1] * output_shape.dim_size(d + 1);\n    }\n\n    auto hypothesis_grouper = hypothesis.group(group_dims);\n    auto truth_grouper = truth.group(group_dims);\n\n    auto hypothesis_iter = hypothesis_grouper.begin();\n    auto truth_iter = truth_grouper.begin();\n\n    auto cmp = std::equal_to<T>();\n\n    while (hypothesis_iter != hypothesis_grouper.end() &&\n           truth_iter != truth_grouper.end()) {\n      sparse::Group truth_i = *truth_iter;\n      sparse::Group hypothesis_j = *hypothesis_iter;\n      std::vector<int64_t> g_truth = truth_i.group();\n      std::vector<int64_t> g_hypothesis = hypothesis_j.group();\n      auto truth_seq = truth_i.values<T>();\n      auto hypothesis_seq = hypothesis_j.values<T>();\n\n      if (g_truth == g_hypothesis) {\n        auto loc = std::inner_product(g_truth.begin(), g_truth.end(),\n                                      output_strides.begin(), int64_t{0});\n        OP_REQUIRES(\n            ctx, 0 <= loc && loc < output_elements,\n            errors::Internal(\"Got an inner product \", loc,\n                             \" which would require writing to outside of \"\n                             \"the buffer for the output tensor (max elements \",\n                             output_elements, \")\"));\n        output_t(loc) =\n            gtl::LevenshteinDistance<T>(truth_seq, hypothesis_seq, cmp);\n        if (normalize_) output_t(loc) \/= truth_seq.size();\n\n        ++hypothesis_iter;\n        ++truth_iter;\n      } else if (g_truth > g_hypothesis) {  \/\/ zero-length truth\n        auto loc = std::inner_product(g_hypothesis.begin(), g_hypothesis.end(),\n                                      output_strides.begin(), int64_t{0});\n        OP_REQUIRES(\n            ctx, 0 <= loc && loc < output_elements,\n            errors::Internal(\"Got an inner product \", loc,\n                             \" which would require writing to outside of \"\n                             \"the buffer for the output tensor (max elements \",\n                             output_elements, \")\"));\n        output_t(loc) = hypothesis_seq.size();\n        if (normalize_ && output_t(loc) != 0.0f) {\n          output_t(loc) = std::numeric_limits<float>::infinity();\n        }\n        ++hypothesis_iter;\n      } else {  \/\/ zero-length hypothesis\n        auto loc = std::inner_product(g_truth.begin(), g_truth.end(),\n                                      output_strides.begin(), int64_t{0});\n        OP_REQUIRES(\n            ctx, 0 <= loc && loc < output_elements,\n            errors::Internal(\"Got an inner product \", loc,\n                             \" which would require writing to outside of \"\n                             \"the buffer for the output tensor (max elements \",\n                             output_elements, \")\"));\n        output_t(loc) = (normalize_) ? 1.0 : truth_seq.size();\n        ++truth_iter;\n      }\n    }\n    while (hypothesis_iter != hypothesis_grouper.end()) {  \/\/ zero-length truths\n      sparse::Group hypothesis_j = *hypothesis_iter;\n      std::vector<int64_t> g_hypothesis = hypothesis_j.group();\n      auto hypothesis_seq = hypothesis_j.values<T>();\n      auto loc = std::inner_product(g_hypothesis.begin(), g_hypothesis.end(),\n                                    output_strides.begin(), int64_t{0});\n      OP_REQUIRES(\n          ctx, 0 <= loc && loc < output_elements,\n          errors::Internal(\"Got an inner product \", loc,\n                           \" which would require writing to outside of the \"\n                           \"buffer for the output tensor (max elements \",\n                           output_elements, \")\"));\n      output_t(loc) = hypothesis_seq.size();\n      if (normalize_ && output_t(loc) != 0.0f) {\n        output_t(loc) = std::numeric_limits<float>::infinity();\n      }\n      ++hypothesis_iter;\n    }\n    while (truth_iter != truth_grouper.end()) {  \/\/ missing hypotheses\n      sparse::Group truth_i = *truth_iter;\n      std::vector<int64_t> g_truth = truth_i.group();\n      auto truth_seq = truth_i.values<T>();\n      auto loc = std::inner_product(g_truth.begin(), g_truth.end(),\n                                    output_strides.begin(), int64_t{0});\n      OP_REQUIRES(\n          ctx, 0 <= loc && loc < output_elements,\n          errors::Internal(\"Got an inner product \", loc,\n                           \" which would require writing to outside of the \"\n                           \"buffer for the output tensor (max elements \",\n                           output_elements, \")\"));\n      output_t(loc) = (normalize_) ? 1.0 : truth_seq.size();\n      ++truth_iter;\n    }\n  }","target":0,"code_token_length":1722,"total_token_length":1958,"max_tokens_setting":2048}
+{"idx":218746,"func":"static void XDrawTriangleEast(Display *display,const XWindowInfo *window_info,\n  const XWidgetInfo *triangle_info)\n{\n  int\n    x1,\n    x2,\n    x3,\n    y1,\n    y2,\n    y3;\n\n  unsigned int\n    bevel_width;\n\n  XFontStruct\n    *font_info;\n\n  XPoint\n    points[4];\n\n  \/*\n    Draw triangle matte.\n  *\/\n  x1=triangle_info->x;\n  y1=triangle_info->y;\n  x2=triangle_info->x+triangle_info->width;\n  y2=triangle_info->y+(triangle_info->height >> 1);\n  x3=triangle_info->x;\n  y3=triangle_info->y+triangle_info->height;\n  bevel_width=triangle_info->bevel_width;\n  points[0].x=x1;\n  points[0].y=y1;\n  points[1].x=x2;\n  points[1].y=y2;\n  points[2].x=x3;\n  points[2].y=y3;\n  XSetMatteColor(display,window_info,triangle_info->raised);\n  (void) XFillPolygon(display,window_info->id,window_info->widget_context,\n    points,3,Complex,CoordModeOrigin);\n  \/*\n    Draw bottom bevel.\n  *\/\n  points[0].x=x2;\n  points[0].y=y2;\n  points[1].x=x3;\n  points[1].y=y3;\n  points[2].x=x3-bevel_width;\n  points[2].y=y3+bevel_width;\n  points[3].x=x2+bevel_width;\n  points[3].y=y2;\n  XSetBevelColor(display,window_info,!triangle_info->raised);\n  (void) XFillPolygon(display,window_info->id,window_info->widget_context,\n    points,4,Complex,CoordModeOrigin);\n  \/*\n    Draw Left bevel.\n  *\/\n  points[0].x=x3;\n  points[0].y=y3;\n  points[1].x=x1;\n  points[1].y=y1;\n  points[2].x=x1-bevel_width+1;\n  points[2].y=y1-bevel_width;\n  points[3].x=x3-bevel_width+1;\n  points[3].y=y3+bevel_width;\n  XSetBevelColor(display,window_info,triangle_info->raised);\n  (void) XFillPolygon(display,window_info->id,window_info->widget_context,\n    points,4,Complex,CoordModeOrigin);\n  \/*\n    Draw top bevel.\n  *\/\n  points[0].x=x1;\n  points[0].y=y1;\n  points[1].x=x2;\n  points[1].y=y2;\n  points[2].x=x2+bevel_width;\n  points[2].y=y2;\n  points[3].x=x1-bevel_width;\n  points[3].y=y1-bevel_width;\n  (void) XFillPolygon(display,window_info->id,window_info->widget_context,\n    points,4,Complex,CoordModeOrigin);\n  (void) XSetFillStyle(display,window_info->widget_context,FillSolid);\n  if (triangle_info->text == (char *) NULL)\n    return;\n  \/*\n    Write label to right of triangle.\n  *\/\n  font_info=window_info->font_info;\n  XSetTextColor(display,window_info,MagickTrue);\n  x1=triangle_info->x+triangle_info->width+triangle_info->bevel_width+\n    (QuantumMargin >> 1);\n  y1=triangle_info->y+((triangle_info->height-\n    (font_info->ascent+font_info->descent)) >> 1)+font_info->ascent;\n  (void) XDrawString(display,window_info->id,window_info->widget_context,x1,y1,\n    triangle_info->text,Extent(triangle_info->text));\n}","target":0,"code_token_length":862,"total_token_length":1098,"max_tokens_setting":2048}
+{"idx":211181,"func":"apprentice_load(struct magic_set *ms, const char *fn, int action)\n{\n\tint errs = 0;\n\tuint32_t i, j;\n\tsize_t files = 0, maxfiles = 0;\n\tchar **filearr = NULL;\n\tstruct stat st;\n\tstruct magic_map *map;\n\tstruct magic_entry_set mset[MAGIC_SETS];\n\tphp_stream *dir;\n\tphp_stream_dirent d;\n \n\tTSRMLS_FETCH();\n\n\tmemset(mset, 0, sizeof(mset));\n\tms->flags |= MAGIC_CHECK;\t\/* Enable checks for parsed files *\/\n\n\n\tif ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL)\n\t{\n\t\tfile_oomem(ms, sizeof(*map));\n\t\treturn NULL;\n\t}\n\n\t\/* print silly verbose header for USG compat. *\/\n\tif (action == FILE_CHECK)\n\t\t(void)fprintf(stderr, \"%s\\n\", usg_hdr);\n\n\t\/* load directory or file *\/\n\t\/* FIXME: Read file names and sort them to prevent\n\t   non-determinism. See Debian bug #488562. *\/\n\tif (php_sys_stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {\n\t\tint mflen;\n\t\tchar mfn[MAXPATHLEN];\n\n\t\tdir = php_stream_opendir((char *)fn, REPORT_ERRORS, NULL);\n\t\tif (!dir) {\n\t\t\terrs++;\n\t\t\tgoto out;\n\t\t}\n\t\twhile (php_stream_readdir(dir, &d)) {\n\t\t\tif ((mflen = snprintf(mfn, sizeof(mfn), \"%s\/%s\", fn, d.d_name)) < 0) {\n\t\t\t\tfile_oomem(ms,\n\t\t\t\tstrlen(fn) + strlen(d.d_name) + 2);\n\t\t\t\terrs++;\n\t\t\t\tphp_stream_closedir(dir);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tif (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (files >= maxfiles) {\n\t\t\t\tsize_t mlen;\n\t\t\t\tmaxfiles = (maxfiles + 1) * 2;\n\t\t\t\tmlen = maxfiles * sizeof(*filearr);\n\t\t\t\tif ((filearr = CAST(char **,\n\t\t\t\t    erealloc(filearr, mlen))) == NULL) {\n\t\t\t\t\tfile_oomem(ms, mlen);\n\t\t\t\t\tefree(mfn);\n\t\t\t\t\tphp_stream_closedir(dir);\n\t\t\t\t\terrs++;\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfilearr[files++] = estrndup(mfn, (mflen > sizeof(mfn) - 1)? sizeof(mfn) - 1: mflen);\n\t\t}\n\t\tphp_stream_closedir(dir);\n\t\tqsort(filearr, files, sizeof(*filearr), cmpstrp);\n\t\tfor (i = 0; i < files; i++) {\n\t\t\tload_1(ms, action, filearr[i], &errs, mset);\n\t\t\tefree(filearr[i]);\n\t\t}\n\t\tefree(filearr);\n\t} else\n\t\tload_1(ms, action, fn, &errs, mset);\n\tif (errs)\n\t\tgoto out;\n\n\tfor (j = 0; j < MAGIC_SETS; j++) {\n\t\t\/* Set types of tests *\/\n\t\tfor (i = 0; i < mset[j].count; ) {\n\t\t\tif (mset[j].me[i].mp->cont_level != 0) {\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ti = set_text_binary(ms, mset[j].me, mset[j].count, i);\n\t\t}\n\t\tqsort(mset[j].me, mset[j].count, sizeof(*mset[j].me),\n\t\t    apprentice_sort);\n\n\t\t\/*\n\t\t * Make sure that any level 0 \"default\" line is last\n\t\t * (if one exists).\n\t\t *\/\n\t\tset_last_default(ms, mset[j].me, mset[j].count);\n\n\t\t\/* coalesce per file arrays into a single one *\/\n\t\tif (coalesce_entries(ms, mset[j].me, mset[j].count,\n\t\t    &map->magic[j], &map->nmagic[j]) == -1) {\n\t\t\terrs++;\n\t\t\tgoto out;\n\t\t}\n\t}\n\nout:\n\tfor (j = 0; j < MAGIC_SETS; j++)\n\t\tmagic_entry_free(mset[j].me, mset[j].count);\n\n\tif (errs) {\n\t\tfor (j = 0; j < MAGIC_SETS; j++) {\n\t\t\tif (map->magic[j])\n\t\t\t\tefree(map->magic[j]);\n\t\t}\n\t\tefree(map);\n\t\treturn NULL;\n\t}\n\treturn map;\n}","target":1,"code_token_length":988,"total_token_length":1224,"max_tokens_setting":2048}
+{"idx":343218,"func":"static void standalone_server(void)\n{\n    int on;\n    struct addrinfo hints, *res, *res6;\n    fd_set rs;\n    int max_fd;\n\n# ifndef NO_INETD\n    standalone = 1;\n# endif\n    memset(&hints, 0, sizeof hints);\n    hints.ai_flags = AI_PASSIVE;\n    hints.ai_family = AF_INET;\n    hints.ai_socktype = SOCK_STREAM;\n    hints.ai_addr = NULL;\n    on = 1;\n    if (listenfd == -1 && no_ipv4 == 0 &&\n        getaddrinfo(standalone_ip, standalone_port, &hints, &res) == 0) {\n        if ((listenfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1 ||\n            setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR,\n                       (char *) &on, sizeof on) != 0) {\n            int old_errno;\n\n            freeaddrinfo(res);\n            cant_bind:\n            old_errno = errno;\n            perror(MSG_STANDALONE_FAILED);\n            logfile(LOG_ERR, MSG_STANDALONE_FAILED \": [%s]\",\n                    strerror(old_errno));\n            return;\n        }\n# ifdef TCP_FASTOPEN\n        {\n#  ifdef __APPLE__\n            int tfo = 1;\n#  else\n            int tfo = 5;\n#  endif\n            setsockopt(listenfd, IPPROTO_TCP, TCP_FASTOPEN,\n                       (void *) &tfo, sizeof tfo);\n        }\n# endif\n        if (bind(listenfd, res->ai_addr, (socklen_t) res->ai_addrlen) != 0 ||\n            listen(listenfd, maxusers > 0U ?\n                   3U + maxusers \/ 8U : DEFAULT_BACKLOG) != 0) {\n            freeaddrinfo(res);\n            goto cant_bind;\n        }\n        freeaddrinfo(res);\n        set_cloexec_flag(listenfd);\n    }\n    if (listenfd6 == -1 && v6ready != 0) {\n        hints.ai_family = AF_INET6;\n        if (getaddrinfo(standalone_ip, standalone_port, &hints, &res6) == 0) {\n            if ((listenfd6 = socket(AF_INET6,\n                                    SOCK_STREAM, IPPROTO_TCP)) == -1 ||\n                setsockopt(listenfd6, SOL_SOCKET, SO_REUSEADDR,\n                           (char *) &on, sizeof on) != 0) {\n                freeaddrinfo(res6);\n                goto cant_bind;\n            }\n# if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)\n            (void) setsockopt(listenfd6, IPPROTO_IPV6, IPV6_V6ONLY,\n                              (char *) &on, sizeof on);\n# endif\n# ifdef TCP_FASTOPEN\n            {\n                int tfo = maxusers > 0U ? 3U + maxusers \/ 8U : DEFAULT_BACKLOG;\n                setsockopt(listenfd6, IPPROTO_TCP, TCP_FASTOPEN,\n                           (void *) &tfo, sizeof tfo);\n            }\n# endif\n            if (bind(listenfd6, res6->ai_addr,\n                     (socklen_t) res6->ai_addrlen) != 0 ||\n                listen(listenfd6, maxusers > 0U ?\n                       3U + maxusers \/ 8U : DEFAULT_BACKLOG) != 0) {\n                freeaddrinfo(res6);\n                goto cant_bind;\n            }\n            freeaddrinfo(res6);\n            set_cloexec_flag(listenfd6);\n        }\n    }\n    if (listenfd == -1 && listenfd6 == -1) {\n# ifdef EADDRNOTAVAIL\n        errno = EADDRNOTAVAIL;\n# endif\n        goto cant_bind;\n    }\n    updatepidfile();\n    setprocessname(\"pure-ftpd (SERVER)\");\n    FD_ZERO(&rs);\n    if (listenfd > listenfd6) {\n        max_fd = listenfd;\n    } else {\n        max_fd = listenfd6;\n    }\n    max_fd++;\n    while (stop_server == 0) {\n        safe_fd_set(listenfd, &rs);\n        safe_fd_set(listenfd6, &rs);\n        if (select(max_fd, &rs, NULL, NULL, NULL) <= 0) {\n            if (errno != EINTR) {\n                (void) sleep(1);\n            }\n            continue;\n        }\n        if (safe_fd_isset(listenfd, &rs)) {\n            accept_client(listenfd);\n        }\n        if (safe_fd_isset(listenfd6, &rs)) {\n            accept_client(listenfd6);\n        }\n    }\n}","target":0,"code_token_length":978,"total_token_length":1214,"max_tokens_setting":2048}
+{"idx":411920,"func":"tokenize_string(memarea_t *area,\n                const char *start, const char *end, smartlist_t *out,\n                token_rule_t *table, int flags)\n{\n  const char **s;\n  directory_token_t *tok = NULL;\n  int counts[_NIL];\n  int i;\n  int first_nonannotation;\n  int prev_len = smartlist_len(out);\n  tor_assert(area);\n\n  s = &start;\n  if (!end)\n    end = start+strlen(start);\n  for (i = 0; i < _NIL; ++i)\n    counts[i] = 0;\n\n  SMARTLIST_FOREACH(out, const directory_token_t *, t, ++counts[t->tp]);\n\n  while (*s < end && (!tok || tok->tp != _EOF)) {\n    tok = get_next_token(area, s, end, table);\n    if (tok->tp == _ERR) {\n      log_warn(LD_DIR, \"parse error: %s\", tok->error);\n      token_clear(tok);\n      return -1;\n    }\n    ++counts[tok->tp];\n    smartlist_add(out, tok);\n    *s = eat_whitespace_eos(*s, end);\n  }\n\n  if (flags & TS_NOCHECK)\n    return 0;\n\n  if ((flags & TS_ANNOTATIONS_OK)) {\n    first_nonannotation = -1;\n    for (i = 0; i < smartlist_len(out); ++i) {\n      tok = smartlist_get(out, i);\n      if (tok->tp < MIN_ANNOTATION || tok->tp > MAX_ANNOTATION) {\n        first_nonannotation = i;\n        break;\n      }\n    }\n    if (first_nonannotation < 0) {\n      log_warn(LD_DIR, \"parse error: item contains only annotations\");\n      return -1;\n    }\n    for (i=first_nonannotation;  i < smartlist_len(out); ++i) {\n      tok = smartlist_get(out, i);\n      if (tok->tp >= MIN_ANNOTATION && tok->tp <= MAX_ANNOTATION) {\n        log_warn(LD_DIR, \"parse error: Annotations mixed with keywords\");\n        return -1;\n      }\n    }\n    if ((flags & TS_NO_NEW_ANNOTATIONS)) {\n      if (first_nonannotation != prev_len) {\n        log_warn(LD_DIR, \"parse error: Unexpected annotations.\");\n        return -1;\n      }\n    }\n  } else {\n    for (i=0;  i < smartlist_len(out); ++i) {\n      tok = smartlist_get(out, i);\n      if (tok->tp >= MIN_ANNOTATION && tok->tp <= MAX_ANNOTATION) {\n        log_warn(LD_DIR, \"parse error: no annotations allowed.\");\n        return -1;\n      }\n    }\n    first_nonannotation = 0;\n  }\n  for (i = 0; table[i].t; ++i) {\n    if (counts[table[i].v] < table[i].min_cnt) {\n      log_warn(LD_DIR, \"Parse error: missing %s element.\", table[i].t);\n      return -1;\n    }\n    if (counts[table[i].v] > table[i].max_cnt) {\n      log_warn(LD_DIR, \"Parse error: too many %s elements.\", table[i].t);\n      return -1;\n    }\n    if (table[i].pos & AT_START) {\n      if (smartlist_len(out) < 1 ||\n          (tok = smartlist_get(out, first_nonannotation))->tp != table[i].v) {\n        log_warn(LD_DIR, \"Parse error: first item is not %s.\", table[i].t);\n        return -1;\n      }\n    }\n    if (table[i].pos & AT_END) {\n      if (smartlist_len(out) < 1 ||\n          (tok = smartlist_get(out, smartlist_len(out)-1))->tp != table[i].v) {\n        log_warn(LD_DIR, \"Parse error: last item is not %s.\", table[i].t);\n        return -1;\n      }\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":870,"total_token_length":1106,"max_tokens_setting":2048}
+{"idx":198374,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor* x_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"x\", &x_tensor));\n\n    const Tensor* cs_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"cs_prev\", &cs_prev_tensor));\n\n    const Tensor* h_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"h_prev\", &h_prev_tensor));\n\n    const Tensor* w_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"w\", &w_tensor));\n\n    const Tensor* wci_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wci\", &wci_tensor));\n\n    const Tensor* wcf_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wcf\", &wcf_tensor));\n\n    const Tensor* wco_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wco\", &wco_tensor));\n\n    const Tensor* b_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"b\", &b_tensor));\n\n    const int64_t batch_size = x_tensor->dim_size(0);\n    const int64_t input_size = x_tensor->dim_size(1);\n    const int64_t cell_size = cs_prev_tensor->dim_size(1);\n\n    \/\/ Sanity checks for our input shapes.\n    OP_REQUIRES(ctx, cs_prev_tensor->dim_size(0) == batch_size,\n                errors::InvalidArgument(\"cs_prev.dims(0) != batch_size: \",\n                                        cs_prev_tensor->dim_size(0), \" vs. \",\n                                        batch_size));\n    OP_REQUIRES(ctx, cs_prev_tensor->dim_size(1) == cell_size,\n                errors::InvalidArgument(\"cs_prev.dims(1) != cell_size: \",\n                                        cs_prev_tensor->dim_size(1), \" vs. \",\n                                        cell_size));\n\n    OP_REQUIRES(ctx, h_prev_tensor->dim_size(0) == batch_size,\n                errors::InvalidArgument(\"h_prev.dims(0) != batch_size: \",\n                                        h_prev_tensor->dim_size(0), \" vs. \",\n                                        batch_size));\n    OP_REQUIRES(ctx, h_prev_tensor->dim_size(1) == cell_size,\n                errors::InvalidArgument(\n                    \"h_prev.dims(1) != cell_size: \", h_prev_tensor->dim_size(1),\n                    \" vs. \", cell_size));\n\n    OP_REQUIRES(ctx, w_tensor->dim_size(0) == input_size + cell_size,\n                errors::InvalidArgument(\n                    \"w.dim_size(0) != input_size + cell_size: \",\n                    w_tensor->dim_size(0), \" vs. \", input_size + cell_size));\n    OP_REQUIRES(ctx, w_tensor->dim_size(1) == cell_size * 4,\n                errors::InvalidArgument(\n                    \"w.dim_size(1) != cell_size * 4: \", w_tensor->dim_size(1),\n                    \" vs. \", cell_size * 4));\n\n    OP_REQUIRES(ctx, b_tensor->dim_size(0) == cell_size * 4,\n                errors::InvalidArgument(\n                    \"b.dim_size(0) != cell_size * 4: \", b_tensor->dim_size(0),\n                    \" vs. \", cell_size * 4));\n\n    \/\/ Allocate our output tensors.\n    Tensor* i_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n                            {\"h_prev\"}, \"i\",\n                            TensorShape({batch_size, cell_size}), &i_tensor));\n\n    Tensor* cs_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"cs\", TensorShape({batch_size, cell_size}),\n                                  &cs_tensor));\n\n    Tensor* f_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"f\", TensorShape({batch_size, cell_size}),\n                                  &f_tensor));\n\n    Tensor* o_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n                            {\"cs_prev\"}, \"o\",\n                            TensorShape({batch_size, cell_size}), &o_tensor));\n\n    Tensor* ci_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"ci\", TensorShape({batch_size, cell_size}),\n                                  &ci_tensor));\n\n    Tensor* co_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"co\", TensorShape({batch_size, cell_size}),\n                                  &co_tensor));\n\n    Tensor* h_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"h\", TensorShape({batch_size, cell_size}),\n                                  &h_tensor));\n\n    \/\/ Allocate our temp tensors.\n    Tensor xh_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(\n                            DataTypeToEnum<T>::v(),\n                            TensorShape({batch_size, input_size + cell_size}),\n                            &xh_tensor));\n\n    Tensor gates_tensor;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                      TensorShape({batch_size, cell_size * 4}),\n                                      &gates_tensor));\n\n    const Device& device = ctx->eigen_device<Device>();\n\n    functor::LSTMBlockCellFprop<Device, T, USE_CUBLAS, gate_layout>(\n        batch_size, input_size, cell_size)(\n        ctx, device, forget_bias_, cell_clip_, use_peephole_,\n        x_tensor->matrix<T>(), cs_prev_tensor->matrix<T>(),\n        h_prev_tensor->matrix<T>(), w_tensor->matrix<T>(), wci_tensor->vec<T>(),\n        wcf_tensor->vec<T>(), wco_tensor->vec<T>(), b_tensor->vec<T>(),\n        xh_tensor.matrix<T>(), i_tensor->matrix<T>(), cs_tensor->matrix<T>(),\n        f_tensor->matrix<T>(), o_tensor->matrix<T>(), ci_tensor->matrix<T>(),\n        co_tensor->matrix<T>(), gates_tensor.matrix<T>(),\n        h_tensor->matrix<T>());\n  }","target":1,"code_token_length":1261,"total_token_length":1497,"max_tokens_setting":2048}
+{"idx":299896,"func":"readconf_retries(void)\n{\nretry_config **chain = &retries;\nretry_config *next;\nuschar *p;\n\nwhile ((p = get_config_line()) != NULL)\n  {\n  retry_rule **rchain;\n  uschar *pp, *error;\n\n  next = store_get(sizeof(retry_config));\n  next->next = NULL;\n  *chain = next;\n  chain = &(next->next);\n  next->basic_errno = next->more_errno = 0;\n  next->senders = NULL;\n  next->rules = NULL;\n  rchain = &(next->rules);\n\n  next->pattern = string_dequote(&p);\n  while (isspace(*p)) p++;\n  pp = p;\n  while (mac_isgraph(*p)) p++;\n  if (p - pp <= 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"missing error type\");\n\n  \/* Test error names for things we understand. *\/\n\n  if ((error = readconf_retry_error(pp, p, &(next->basic_errno),\n       &(next->more_errno))) != NULL)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"%s\", error);\n\n  \/* There may be an optional address list of senders to be used as another\n  constraint on the rule. This was added later, so the syntax is a bit of a\n  fudge. Anything that is not a retry rule starting \"F,\" or \"G,\" is treated as\n  an address list. *\/\n\n  while (isspace(*p)) p++;\n  if (Ustrncmp(p, \"senders\", 7) == 0)\n    {\n    p += 7;\n    while (isspace(*p)) p++;\n    if (*p++ != '=') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"\\\"=\\\" expected after \\\"senders\\\" in retry rule\");\n    while (isspace(*p)) p++;\n    next->senders = string_dequote(&p);\n    }\n\n  \/* Now the retry rules. Keep the maximum timeout encountered. *\/\n\n  while (isspace(*p)) p++;\n\n  while (*p != 0)\n    {\n    retry_rule *rule = store_get(sizeof(retry_rule));\n    *rchain = rule;\n    rchain = &(rule->next);\n    rule->next = NULL;\n    rule->rule = toupper(*p++);\n    rule->timeout = retry_arg(&p, 0);\n    if (rule->timeout > retry_maximum_timeout)\n      retry_maximum_timeout = rule->timeout;\n\n    switch (rule->rule)\n      {\n      case 'F':   \/* Fixed interval *\/\n      rule->p1 = retry_arg(&p, 0);\n      break;\n\n      case 'G':   \/* Geometrically increasing intervals *\/\n      case 'H':   \/* Ditto, but with randomness *\/\n      rule->p1 = retry_arg(&p, 0);\n      rule->p2 = retry_arg(&p, 1);\n      break;\n\n      default:\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"unknown retry rule letter\");\n      break;\n      }\n\n    if (rule->timeout <= 0 || rule->p1 <= 0 ||\n          (rule->rule != 'F' && rule->p2 < 1000))\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n        \"bad parameters for retry rule\");\n\n    while (isspace(*p)) p++;\n    if (*p == ';')\n      {\n      p++;\n      while (isspace(*p)) p++;\n      }\n    else if (*p != 0)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"semicolon expected\");\n    }\n  }\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048}
+{"idx":210910,"func":"win_redr_status(win_T *wp, int ignore_pum UNUSED)\n{\n    int\t\trow;\n    char_u\t*p;\n    int\t\tlen;\n    int\t\tfillchar;\n    int\t\tattr;\n    int\t\tthis_ru_col;\n    static int  busy = FALSE;\n\n    \/\/ It's possible to get here recursively when 'statusline' (indirectly)\n    \/\/ invokes \":redrawstatus\".  Simply ignore the call then.\n    if (busy)\n\treturn;\n    busy = TRUE;\n\n    row = statusline_row(wp);\n\n    wp->w_redr_status = FALSE;\n    if (wp->w_status_height == 0)\n    {\n\t\/\/ no status line, can only be last window\n\tredraw_cmdline = TRUE;\n    }\n    else if (!redrawing()\n\t    \/\/ don't update status line when popup menu is visible and may be\n\t    \/\/ drawn over it, unless it will be redrawn later\n\t    || (!ignore_pum && pum_visible()))\n    {\n\t\/\/ Don't redraw right now, do it later.\n\twp->w_redr_status = TRUE;\n    }\n#ifdef FEAT_STL_OPT\n    else if (*p_stl != NUL || *wp->w_p_stl != NUL)\n    {\n\t\/\/ redraw custom status line\n\tredraw_custom_statusline(wp);\n    }\n#endif\n    else\n    {\n\tfillchar = fillchar_status(&attr, wp);\n\n\tget_trans_bufname(wp->w_buffer);\n\tp = NameBuff;\n\tlen = (int)STRLEN(p);\n\n\tif (bt_help(wp->w_buffer)\n#ifdef FEAT_QUICKFIX\n\t\t|| wp->w_p_pvw\n#endif\n\t\t|| bufIsChanged(wp->w_buffer)\n\t\t|| wp->w_buffer->b_p_ro)\n\t    *(p + len++) = ' ';\n\tif (bt_help(wp->w_buffer))\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", _(\"[Help]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n#ifdef FEAT_QUICKFIX\n\tif (wp->w_p_pvw)\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", _(\"[Preview]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n#endif\n\tif (bufIsChanged(wp->w_buffer)\n#ifdef FEAT_TERMINAL\n\t\t&& !bt_terminal(wp->w_buffer)\n#endif\n\t\t)\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", \"[+]\");\n\t    len += (int)STRLEN(p + len);\n\t}\n\tif (wp->w_buffer->b_p_ro)\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", _(\"[RO]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n\n\tthis_ru_col = ru_col - (Columns - wp->w_width);\n\tif (this_ru_col < (wp->w_width + 1) \/ 2)\n\t    this_ru_col = (wp->w_width + 1) \/ 2;\n\tif (this_ru_col <= 1)\n\t{\n\t    p = (char_u *)\"<\";\t\t\/\/ No room for file name!\n\t    len = 1;\n\t}\n\telse if (has_mbyte)\n\t{\n\t    int\tclen = 0, i;\n\n\t    \/\/ Count total number of display cells.\n\t    clen = mb_string2cells(p, -1);\n\n\t    \/\/ Find first character that will fit.\n\t    \/\/ Going from start to end is much faster for DBCS.\n\t    for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;\n\t\t    i += (*mb_ptr2len)(p + i))\n\t\tclen -= (*mb_ptr2cells)(p + i);\n\t    len = clen;\n\t    if (i > 0)\n\t    {\n\t\tp = p + i - 1;\n\t\t*p = '<';\n\t\t++len;\n\t    }\n\n\t}\n\telse if (len > this_ru_col - 1)\n\t{\n\t    p += len - (this_ru_col - 1);\n\t    *p = '<';\n\t    len = this_ru_col - 1;\n\t}\n\n\tscreen_puts(p, row, wp->w_wincol, attr);\n\tscreen_fill(row, row + 1, len + wp->w_wincol,\n\t\t\tthis_ru_col + wp->w_wincol, fillchar, fillchar, attr);\n\n\tif (get_keymap_str(wp, (char_u *)\"<%s>\", NameBuff, MAXPATHL)\n\t\t&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))\n\t    screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)\n\t\t\t\t\t\t   - 1 + wp->w_wincol), attr);\n\n#ifdef FEAT_CMDL_INFO\n\twin_redr_ruler(wp, TRUE, ignore_pum);\n#endif\n    }\n\n    \/*\n     * May need to draw the character below the vertical separator.\n     *\/\n    if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())\n    {\n\tif (stl_connected(wp))\n\t    fillchar = fillchar_status(&attr, wp);\n\telse\n\t    fillchar = fillchar_vsep(&attr);\n\tscreen_putchar(fillchar, row, W_ENDCOL(wp), attr);\n    }\n    busy = FALSE;\n}","target":1,"code_token_length":1154,"total_token_length":1390,"max_tokens_setting":2048}
+{"idx":249984,"func":"GF_Err DoWriteMeta(GF_ISOFile *file, GF_MetaBox *meta, GF_BitStream *bs, Bool Emulation, u64 baseOffset, u64 *mdatSize)\n{\n\tGF_ItemExtentEntry *entry;\n\tu64 maxExtendOffset, maxExtendSize;\n\tu32 i, j, count;\n\n\tmaxExtendOffset = 0;\n\tmaxExtendSize = 0;\n\tif (mdatSize) *mdatSize = 0;\n\tif (!meta->item_locations) return GF_OK;\n\n\tcount = gf_list_count(meta->item_locations->location_entries);\n\tfor (i=0; i<count; i++) {\n\t\tu64 it_size;\n\t\tGF_ItemLocationEntry *iloc = (GF_ItemLocationEntry *)gf_list_get(meta->item_locations->location_entries, i);\n\t\t\/*get item info*\/\n\t\tGF_ItemInfoEntryBox *iinf = NULL;\n\t\tj=0;\n\t\twhile ((iinf = (GF_ItemInfoEntryBox *)gf_list_enum(meta->item_infos->item_infos, &j))) {\n\t\t\tif (iinf->item_ID==iloc->item_ID) break;\n\t\t\tiinf = NULL;\n\t\t}\n\n\t\tif (!iloc->base_offset && (gf_list_count(iloc->extent_entries)==1)) {\n\t\t\tentry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0);\n\t\t\tif (!entry->extent_length && !entry->original_extent_offset && !entry->extent_index) {\n\t\t\t\tentry->extent_offset = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tit_size = 0;\n\t\t\/*for self contained only*\/\n\t\tif (!iloc->data_reference_index) {\n\t\t\tif (iloc->construction_method != 2) {\n\t\t\t\tiloc->base_offset = baseOffset;\n\t\t\t}\n\n\t\t\t\/*new resource*\/\n\t\t\tif (iinf && (iinf->full_path || (iinf->tk_id && iinf->sample_num))) {\n\t\t\t\tFILE *src=NULL;\n\n\t\t\t\tif (!iinf->data_len && iinf->full_path) {\n\t\t\t\t\tsrc = gf_fopen(iinf->full_path, \"rb\");\n\t\t\t\t\tif (!src) continue;\n\t\t\t\t\tit_size = gf_fsize(src);\n\t\t\t\t} else {\n\t\t\t\t\tit_size = iinf->data_len;\n\t\t\t\t}\n\t\t\t\tif (maxExtendSize<it_size) maxExtendSize = it_size;\n\n\t\t\t\tif (!gf_list_count(iloc->extent_entries)) {\n\t\t\t\t\tGF_SAFEALLOC(entry, GF_ItemExtentEntry);\n\t\t\t\t\tif (!entry) return GF_OUT_OF_MEM;\n\t\t\t\t\tgf_list_add(iloc->extent_entries, entry);\n\t\t\t\t}\n\t\t\t\tentry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0);\n\t\t\t\tentry->extent_offset = 0;\n\t\t\t\tentry->extent_length = it_size;\n\n\t\t\t\t\/\/shared data, do not count it\n\t\t\t\tif (iinf->tk_id && iinf->sample_num) {\n\t\t\t\t\tit_size = 0;\n\t\t\t\t\tmaxExtendOffset = 0xFFFFFFFFFFUL;\n\t\t\t\t\tif (Emulation) {\n\t\t\t\t\t\tmeta->use_item_sample_sharing = GF_TRUE;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/*OK write to mdat*\/\n\t\t\t\tif (!Emulation) {\n\t\t\t\t\tif (iinf->tk_id && iinf->sample_num) {\n\t\t\t\t\t}\n\t\t\t\t\telse if (src) {\n\t\t\t\t\t\tchar cache_data[4096];\n\t\t\t\t\t\tu64 remain = entry->extent_length;\n\t\t\t\t\t\twhile (remain) {\n\t\t\t\t\t\t\tu32 size_cache = (remain>4096) ? 4096 : (u32) remain;\n\t\t\t\t\t\t\tsize_t read = gf_fread(cache_data, size_cache, src);\n\t\t\t\t\t\t\tif (read ==(size_t) -1) break;\n\t\t\t\t\t\t\tgf_bs_write_data(bs, cache_data, (u32) read);\n\t\t\t\t\t\t\tremain -= (u32) read;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgf_bs_write_data(bs, iinf->full_path, iinf->data_len);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (src) gf_fclose(src);\n\t\t\t}\n\t\t\telse if (gf_list_count(iloc->extent_entries)) {\n\t\t\t\tj=0;\n\t\t\t\twhile ((entry = (GF_ItemExtentEntry *)gf_list_enum(iloc->extent_entries, &j))) {\n\t\t\t\t\tif (entry->extent_index) continue;\n\t\t\t\t\tif (j && (maxExtendOffset<it_size) ) maxExtendOffset = it_size;\n\t\t\t\t\t\/*compute new offset*\/\n\t\t\t\t\tentry->extent_offset = baseOffset + it_size;\n\n\t\t\t\t\tit_size += entry->extent_length;\n\t\t\t\t\tif (maxExtendSize<entry->extent_length) maxExtendSize = entry->extent_length;\n\n\t\t\t\t\t\/*Reading from the input file*\/\n\t\t\t\t\tif (!Emulation) {\n\t\t\t\t\t\tchar cache_data[4096];\n\t\t\t\t\t\tu64 remain = entry->extent_length;\n\t\t\t\t\t\tgf_bs_seek(file->movieFileMap->bs, entry->original_extent_offset + iloc->original_base_offset);\n\t\t\t\t\t\twhile (remain) {\n\t\t\t\t\t\t\tu32 size_cache = (remain>4096) ? 4096 : (u32) remain;\n\t\t\t\t\t\t\tgf_bs_read_data(file->movieFileMap->bs, cache_data, size_cache);\n\t\t\t\t\t\t\t\/*Writing to the output file*\/\n\t\t\t\t\t\t\tgf_bs_write_data(bs, cache_data, size_cache);\n\t\t\t\t\t\t\tremain -= size_cache;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbaseOffset += it_size;\n\t\t\tif (mdatSize)\n\t\t\t\t*mdatSize += it_size;\n\t\t} else {\n\t\t\t\/*we MUST have at least one extent for the dref data*\/\n\t\t\tif (!gf_list_count(iloc->extent_entries)) {\n\t\t\t\tGF_SAFEALLOC(entry, GF_ItemExtentEntry);\n\t\t\t\tif (!entry) return GF_OUT_OF_MEM;\n\t\t\t\tgf_list_add(iloc->extent_entries, entry);\n\t\t\t}\n\t\t\tentry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0);\n\t\t\tentry->extent_offset = 0;\n\t\t\t\/*0 means full length of referenced file*\/\n\t\t\tentry->extent_length = 0;\n\t\t}\n\t}\n\n\t\/*update offset & size length fields*\/\n\tif (baseOffset>0xFFFFFFFF) meta->item_locations->base_offset_size = 8;\n\telse if (baseOffset) meta->item_locations->base_offset_size = 4;\n\n\tif (maxExtendSize>0xFFFFFFFF) meta->item_locations->length_size = 8;\n\telse if (maxExtendSize) meta->item_locations->length_size = 4;\n\n\tif (maxExtendOffset>0xFFFFFFFF) meta->item_locations->offset_size = 8;\n\telse if (maxExtendOffset) meta->item_locations->offset_size = 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":1424,"total_token_length":1660,"max_tokens_setting":2048}
+{"idx":317315,"func":"static int selinux_setprocattr(const char *name, void *value, size_t size)\n{\n\tstruct task_security_struct *tsec;\n\tstruct cred *new;\n\tu32 mysid = current_sid(), sid = 0, ptsid;\n\tint error;\n\tchar *str = value;\n\n\t\/*\n\t * Basic control over ability to set these attributes at all.\n\t *\/\n\tif (!strcmp(name, \"exec\"))\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     mysid, mysid, SECCLASS_PROCESS,\n\t\t\t\t     PROCESS__SETEXEC, NULL);\n\telse if (!strcmp(name, \"fscreate\"))\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     mysid, mysid, SECCLASS_PROCESS,\n\t\t\t\t     PROCESS__SETFSCREATE, NULL);\n\telse if (!strcmp(name, \"keycreate\"))\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     mysid, mysid, SECCLASS_PROCESS,\n\t\t\t\t     PROCESS__SETKEYCREATE, NULL);\n\telse if (!strcmp(name, \"sockcreate\"))\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     mysid, mysid, SECCLASS_PROCESS,\n\t\t\t\t     PROCESS__SETSOCKCREATE, NULL);\n\telse if (!strcmp(name, \"current\"))\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     mysid, mysid, SECCLASS_PROCESS,\n\t\t\t\t     PROCESS__SETCURRENT, NULL);\n\telse\n\t\terror = -EINVAL;\n\tif (error)\n\t\treturn error;\n\n\t\/* Obtain a SID for the context, if one was specified. *\/\n\tif (size && str[0] && str[0] != '\\n') {\n\t\tif (str[size-1] == '\\n') {\n\t\t\tstr[size-1] = 0;\n\t\t\tsize--;\n\t\t}\n\t\terror = security_context_to_sid(&selinux_state, value, size,\n\t\t\t\t\t\t&sid, GFP_KERNEL);\n\t\tif (error == -EINVAL && !strcmp(name, \"fscreate\")) {\n\t\t\tif (!has_cap_mac_admin(true)) {\n\t\t\t\tstruct audit_buffer *ab;\n\t\t\t\tsize_t audit_size;\n\n\t\t\t\t\/* We strip a nul only if it is at the end, otherwise the\n\t\t\t\t * context contains a nul and we should audit that *\/\n\t\t\t\tif (str[size - 1] == '\\0')\n\t\t\t\t\taudit_size = size - 1;\n\t\t\t\telse\n\t\t\t\t\taudit_size = size;\n\t\t\t\tab = audit_log_start(audit_context(),\n\t\t\t\t\t\t     GFP_ATOMIC,\n\t\t\t\t\t\t     AUDIT_SELINUX_ERR);\n\t\t\t\tif (!ab)\n\t\t\t\t\treturn error;\n\t\t\t\taudit_log_format(ab, \"op=fscreate invalid_context=\");\n\t\t\t\taudit_log_n_untrustedstring(ab, value, audit_size);\n\t\t\t\taudit_log_end(ab);\n\n\t\t\t\treturn error;\n\t\t\t}\n\t\t\terror = security_context_to_sid_force(\n\t\t\t\t\t\t      &selinux_state,\n\t\t\t\t\t\t      value, size, &sid);\n\t\t}\n\t\tif (error)\n\t\t\treturn error;\n\t}\n\n\tnew = prepare_creds();\n\tif (!new)\n\t\treturn -ENOMEM;\n\n\t\/* Permission checking based on the specified context is\n\t   performed during the actual operation (execve,\n\t   open\/mkdir\/...), when we know the full context of the\n\t   operation.  See selinux_bprm_creds_for_exec for the execve\n\t   checks and may_create for the file creation checks. The\n\t   operation will then fail if the context is not permitted. *\/\n\ttsec = selinux_cred(new);\n\tif (!strcmp(name, \"exec\")) {\n\t\ttsec->exec_sid = sid;\n\t} else if (!strcmp(name, \"fscreate\")) {\n\t\ttsec->create_sid = sid;\n\t} else if (!strcmp(name, \"keycreate\")) {\n\t\tif (sid) {\n\t\t\terror = avc_has_perm(&selinux_state, mysid, sid,\n\t\t\t\t\t     SECCLASS_KEY, KEY__CREATE, NULL);\n\t\t\tif (error)\n\t\t\t\tgoto abort_change;\n\t\t}\n\t\ttsec->keycreate_sid = sid;\n\t} else if (!strcmp(name, \"sockcreate\")) {\n\t\ttsec->sockcreate_sid = sid;\n\t} else if (!strcmp(name, \"current\")) {\n\t\terror = -EINVAL;\n\t\tif (sid == 0)\n\t\t\tgoto abort_change;\n\n\t\t\/* Only allow single threaded processes to change context *\/\n\t\terror = -EPERM;\n\t\tif (!current_is_single_threaded()) {\n\t\t\terror = security_bounded_transition(&selinux_state,\n\t\t\t\t\t\t\t    tsec->sid, sid);\n\t\t\tif (error)\n\t\t\t\tgoto abort_change;\n\t\t}\n\n\t\t\/* Check permissions for the transition. *\/\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     tsec->sid, sid, SECCLASS_PROCESS,\n\t\t\t\t     PROCESS__DYNTRANSITION, NULL);\n\t\tif (error)\n\t\t\tgoto abort_change;\n\n\t\t\/* Check for ptracing, and update the task SID if ok.\n\t\t   Otherwise, leave SID unchanged and fail. *\/\n\t\tptsid = ptrace_parent_sid();\n\t\tif (ptsid != 0) {\n\t\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t\t     ptsid, sid, SECCLASS_PROCESS,\n\t\t\t\t\t     PROCESS__PTRACE, NULL);\n\t\t\tif (error)\n\t\t\t\tgoto abort_change;\n\t\t}\n\n\t\ttsec->sid = sid;\n\t} else {\n\t\terror = -EINVAL;\n\t\tgoto abort_change;\n\t}\n\n\tcommit_creds(new);\n\treturn size;\n\nabort_change:\n\tabort_creds(new);\n\treturn error;\n}","target":0,"code_token_length":1126,"total_token_length":1362,"max_tokens_setting":2048}
+{"idx":195338,"func":"static void naludmx_queue_param_set(GF_NALUDmxCtx *ctx, char *data, u32 size, u32 ps_type, s32 ps_id)\n{\n\tGF_List *list = NULL, *alt_list = NULL;\n\tGF_NALUFFParam *sl;\n\tu32 i, count;\n\tu32 crc = gf_crc_32(data, size);\n\n\tif (ctx->codecid==GF_CODECID_HEVC) {\n\t\tswitch (ps_type) {\n\t\tcase GF_HEVC_NALU_VID_PARAM:\n\t\t\tif (!ctx->vps) ctx->vps = gf_list_new();\n\t\t\tlist = ctx->vps;\n\t\t\tbreak;\n\t\tcase GF_HEVC_NALU_SEQ_PARAM:\n\t\t\tlist = ctx->sps;\n\t\t\tbreak;\n\t\tcase GF_HEVC_NALU_PIC_PARAM:\n\t\t\tlist = ctx->pps;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(0);\n\t\t\treturn;\n\t\t}\n\t} else if (ctx->codecid==GF_CODECID_VVC) {\n\t\tswitch (ps_type) {\n\t\tcase GF_VVC_NALU_VID_PARAM:\n\t\t\tif (!ctx->vps) ctx->vps = gf_list_new();\n\t\t\tlist = ctx->vps;\n\t\t\tbreak;\n\t\tcase GF_VVC_NALU_SEQ_PARAM:\n\t\t\tlist = ctx->sps;\n\t\t\tbreak;\n\t\tcase GF_VVC_NALU_PIC_PARAM:\n\t\t\tlist = ctx->pps;\n\t\t\tbreak;\n\t\tcase GF_VVC_NALU_DEC_PARAM:\n\t\t\tif (!ctx->vvc_dci) ctx->vvc_dci = gf_list_new();\n\t\t\tlist = ctx->vvc_dci;\n\t\t\tbreak;\n\t\tcase GF_VVC_NALU_APS_PREFIX:\n\t\t\tif (!ctx->vvc_aps_pre) ctx->vvc_aps_pre = gf_list_new();\n\t\t\tlist = ctx->vvc_aps_pre;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(0);\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tswitch (ps_type) {\n\t\tcase GF_AVC_NALU_SVC_SUBSEQ_PARAM:\n\t\tcase GF_AVC_NALU_SEQ_PARAM:\n\t\t\tlist = ctx->sps;\n\t\t\tbreak;\n\t\tcase GF_AVC_NALU_PIC_PARAM:\n\t\t\tlist = ctx->pps;\n\t\t\talt_list = ctx->pps_svc;\n\t\t\tbreak;\n\t\tcase GF_AVC_NALU_SEQ_PARAM_EXT:\n\t\t\tif (!ctx->sps_ext) ctx->sps_ext = gf_list_new();\n\t\t\tlist = ctx->sps_ext;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(0);\n\t\t\treturn;\n\t\t}\n\t}\n\tsl = NULL;\n\tcount = gf_list_count(list);\n\tfor (i=0; i<count; i++) {\n\t\tsl = gf_list_get(list, i);\n\t\tif (sl->id != ps_id) {\n\t\t\tsl = NULL;\n\t\t\tcontinue;\n\t\t}\n\t\t\/\/same ID, same CRC, we don't change our state\n\t\tif (sl->crc == crc) return;\n\t\tbreak;\n\t}\n\t\/\/handle alt PPS list for SVC\n\tif (!sl && alt_list) {\n\t\tcount = gf_list_count(alt_list);\n\t\tfor (i=0; i<count; i++) {\n\t\t\tsl = gf_list_get(alt_list, i);\n\t\t\tif (sl->id != ps_id) {\n\t\t\t\tsl = NULL;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/\/same ID, same CRC, we don't change our state\n\t\t\tif (sl->crc == crc) return;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (sl) {\n\t\t\/\/otherwise we keep this new param set\n\t\tsl->data = gf_realloc(sl->data, size);\n\t\tmemcpy(sl->data, data, size);\n\t\tsl->size = size;\n\t\tsl->crc = crc;\n\t\tctx->ps_modified = GF_TRUE;\n\t\treturn;\n\t}\n\t\/\/TODO we might want to purge the list after a while !!\n\n\tGF_SAFEALLOC(sl, GF_NALUFFParam);\n\tif (!sl) return;\n\tsl->data = gf_malloc(sizeof(char) * size);\n\tif (!sl->data) {\n\t\tgf_free(sl);\n\t\treturn;\n\t}\n\tmemcpy(sl->data, data, size);\n\tsl->size = size;\n\tsl->id = ps_id;\n\tsl->crc = crc;\n\n\tctx->ps_modified = GF_TRUE;\n\tgf_list_add(list, sl);\n}","target":1,"code_token_length":931,"total_token_length":1167,"max_tokens_setting":2048}
+{"idx":211471,"func":"static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,\n\t\t\t\t    bgp_size_t length)\n{\n\tuint8_t *end;\n\tstruct capability_mp_data mpc;\n\tstruct capability_header *hdr;\n\tuint8_t action;\n\tiana_afi_t pkt_afi;\n\tafi_t afi;\n\tiana_safi_t pkt_safi;\n\tsafi_t safi;\n\n\tend = pnt + length;\n\n\twhile (pnt < end) {\n\t\t\/* We need at least action, capability code and capability\n\t\t * length. *\/\n\t\tif (pnt + 3 > end) {\n\t\t\tzlog_info(\"%s Capability length error\", peer->host);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\t\taction = *pnt;\n\t\thdr = (struct capability_header *)(pnt + 1);\n\n\t\t\/* Action value check.  *\/\n\t\tif (action != CAPABILITY_ACTION_SET\n\t\t    && action != CAPABILITY_ACTION_UNSET) {\n\t\t\tzlog_info(\"%s Capability Action Value error %d\",\n\t\t\t\t  peer->host, action);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\n\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\tzlog_debug(\n\t\t\t\t\"%s CAPABILITY has action: %d, code: %u, length %u\",\n\t\t\t\tpeer->host, action, hdr->code, hdr->length);\n\n\t\t\/* Capability length check. *\/\n\t\tif ((pnt + hdr->length + 3) > end) {\n\t\t\tzlog_info(\"%s Capability length error\", peer->host);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\n\t\t\/* Fetch structure to the byte stream. *\/\n\t\tmemcpy(&mpc, pnt + 3, sizeof(struct capability_mp_data));\n\t\tpnt += hdr->length + 3;\n\n\t\t\/* We know MP Capability Code. *\/\n\t\tif (hdr->code == CAPABILITY_CODE_MP) {\n\t\t\tpkt_afi = ntohs(mpc.afi);\n\t\t\tpkt_safi = mpc.safi;\n\n\t\t\t\/* Ignore capability when override-capability is set. *\/\n\t\t\tif (CHECK_FLAG(peer->flags,\n\t\t\t\t       PEER_FLAG_OVERRIDE_CAPABILITY))\n\t\t\t\tcontinue;\n\n\t\t\t\/* Convert AFI, SAFI to internal values. *\/\n\t\t\tif (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi,\n\t\t\t\t\t\t      &safi)) {\n\t\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\t\tzlog_debug(\n\t\t\t\t\t\t\"%s Dynamic Capability MP_EXT afi\/safi invalid (%s\/%s)\",\n\t\t\t\t\t\tpeer->host,\n\t\t\t\t\t\tiana_afi2str(pkt_afi),\n\t\t\t\t\t\tiana_safi2str(pkt_safi));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/* Address family check.  *\/\n\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\tzlog_debug(\n\t\t\t\t\t\"%s CAPABILITY has %s MP_EXT CAP for afi\/safi: %s\/%s\",\n\t\t\t\t\tpeer->host,\n\t\t\t\t\taction == CAPABILITY_ACTION_SET\n\t\t\t\t\t\t? \"Advertising\"\n\t\t\t\t\t\t: \"Removing\",\n\t\t\t\t\tiana_afi2str(pkt_afi),\n\t\t\t\t\tiana_safi2str(pkt_safi));\n\n\t\t\tif (action == CAPABILITY_ACTION_SET) {\n\t\t\t\tpeer->afc_recv[afi][safi] = 1;\n\t\t\t\tif (peer->afc[afi][safi]) {\n\t\t\t\t\tpeer->afc_nego[afi][safi] = 1;\n\t\t\t\t\tbgp_announce_route(peer, afi, safi,\n\t\t\t\t\t\t\t   false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpeer->afc_recv[afi][safi] = 0;\n\t\t\t\tpeer->afc_nego[afi][safi] = 0;\n\n\t\t\t\tif (peer_active_nego(peer))\n\t\t\t\t\tbgp_clear_route(peer, afi, safi);\n\t\t\t\telse\n\t\t\t\t\treturn BGP_Stop;\n\t\t\t}\n\t\t} else {\n\t\t\tflog_warn(\n\t\t\t\tEC_BGP_UNRECOGNIZED_CAPABILITY,\n\t\t\t\t\"%s unrecognized capability code: %d - ignored\",\n\t\t\t\tpeer->host, hdr->code);\n\t\t}\n\t}\n\n\t\/* No FSM action necessary *\/\n\treturn BGP_PACKET_NOOP;\n}","target":1,"code_token_length":942,"total_token_length":1178,"max_tokens_setting":2048}
+{"idx":503985,"func":"auth_request_get_var_expand_table_full(const struct auth_request *auth_request,\n\t\t\t\t       auth_request_escape_func_t *escape_func,\n\t\t\t\t       unsigned int *count)\n{\n\tconst unsigned int auth_count =\n\t\tN_ELEMENTS(auth_request_var_expand_static_tab);\n\tstruct var_expand_table *tab, *ret_tab;\n\tconst char *orig_user, *auth_user, *username;\n\n\tif (escape_func == NULL)\n\t\tescape_func = escape_none;\n\n\t\/* keep the extra fields at the beginning. the last static_tab field\n\t   contains the ending NULL-fields. *\/\n\ttab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab));\n\tmemset(tab, 0, *count * sizeof(*tab));\n\ttab += *count;\n\t*count += auth_count;\n\n\tmemcpy(tab, auth_request_var_expand_static_tab,\n\t       auth_count * sizeof(*tab));\n\n\tusername = auth_request->user != NULL ? auth_request->user : \"\";\n\ttab[0].value = escape_func(username, auth_request);\n\ttab[1].value = escape_func(t_strcut(username, '@'),\n\t\t\t\t   auth_request);\n\ttab[2].value = strchr(username, '@');\n\tif (tab[2].value != NULL)\n\t\ttab[2].value = escape_func(tab[2].value+1, auth_request);\n\ttab[3].value = escape_func(auth_request->service, auth_request);\n\t\/* tab[4] = we have no home dir *\/\n\tif (auth_request->local_ip.family != 0)\n\t\ttab[5].value = net_ip2addr(&auth_request->local_ip);\n\tif (auth_request->remote_ip.family != 0)\n\t\ttab[6].value = net_ip2addr(&auth_request->remote_ip);\n\ttab[7].value = dec2str(auth_request->client_pid);\n\tif (auth_request->mech_password != NULL) {\n\t\ttab[8].value = escape_func(auth_request->mech_password,\n\t\t\t\t\t   auth_request);\n\t}\n\tif (auth_request->userdb_lookup) {\n\t\ttab[9].value = auth_request->userdb == NULL ? \"\" :\n\t\t\tdec2str(auth_request->userdb->userdb->id);\n\t} else {\n\t\ttab[9].value = auth_request->passdb == NULL ? \"\" :\n\t\t\tdec2str(auth_request->passdb->passdb->id);\n\t}\n\ttab[10].value = auth_request->mech_name == NULL ? \"\" :\n\t\tescape_func(auth_request->mech_name, auth_request);\n\ttab[11].value = auth_request->secured ? \"secured\" : \"\";\n\ttab[12].value = dec2str(auth_request->local_port);\n\ttab[13].value = dec2str(auth_request->remote_port);\n\ttab[14].value = auth_request->valid_client_cert ? \"valid\" : \"\";\n\n\tif (auth_request->requested_login_user != NULL) {\n\t\tconst char *login_user = auth_request->requested_login_user;\n\n\t\ttab[15].value = escape_func(login_user, auth_request);\n\t\ttab[16].value = escape_func(t_strcut(login_user, '@'),\n\t\t\t\t\t    auth_request);\n\t\ttab[17].value = strchr(login_user, '@');\n\t\tif (tab[17].value != NULL) {\n\t\t\ttab[17].value = escape_func(tab[17].value+1,\n\t\t\t\t\t\t    auth_request);\n\t\t}\n\t}\n\ttab[18].value = auth_request->session_id == NULL ? NULL :\n\t\tescape_func(auth_request->session_id, auth_request);\n\tif (auth_request->real_local_ip.family != 0)\n\t\ttab[19].value = net_ip2addr(&auth_request->real_local_ip);\n\tif (auth_request->real_remote_ip.family != 0)\n\t\ttab[20].value = net_ip2addr(&auth_request->real_remote_ip);\n\ttab[21].value = dec2str(auth_request->real_local_port);\n\ttab[22].value = dec2str(auth_request->real_remote_port);\n\ttab[23].value = strchr(username, '@');\n\tif (tab[23].value != NULL) {\n\t\ttab[23].value = escape_func(t_strcut(tab[23].value+1, '@'),\n\t\t\t\t\t    auth_request);\n\t}\n\ttab[24].value = strrchr(username, '@');\n\tif (tab[24].value != NULL)\n\t\ttab[24].value = escape_func(tab[24].value+1, auth_request);\n\ttab[25].value = auth_request->master_user == NULL ? NULL :\n\t\tescape_func(auth_request->master_user, auth_request);\n\ttab[26].value = auth_request->session_pid == (pid_t)-1 ? NULL :\n\t\tdec2str(auth_request->session_pid);\n\n\torig_user = auth_request->original_username != NULL ?\n\t\tauth_request->original_username : username;\n\ttab[27].value = escape_func(orig_user, auth_request);\n\ttab[28].value = escape_func(t_strcut(orig_user, '@'), auth_request);\n\ttab[29].value = strchr(orig_user, '@');\n\tif (tab[29].value != NULL)\n\t\ttab[29].value = escape_func(tab[29].value+1, auth_request);\n\n\tif (auth_request->master_user != NULL)\n\t\tauth_user = auth_request->master_user;\n\telse\n\t\tauth_user = orig_user;\n\ttab[30].value = escape_func(auth_user, auth_request);\n\ttab[31].value = escape_func(t_strcut(auth_user, '@'), auth_request);\n\ttab[32].value = strchr(auth_user, '@');\n\tif (tab[32].value != NULL)\n\t\ttab[32].value = escape_func(tab[32].value+1, auth_request);\n\tif (auth_request->local_name != NULL)\n\t\ttab[33].value = escape_func(auth_request->local_name, auth_request);\n\telse\n\t\ttab[33].value = \"\";\n\treturn ret_tab;\n}","target":0,"code_token_length":1248,"total_token_length":1484,"max_tokens_setting":2048}
+{"idx":317023,"func":"static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dentry)\n{\n\tstruct superblock_security_struct *sbsec = NULL;\n\tstruct inode_security_struct *isec = selinux_inode(inode);\n\tu32 task_sid, sid = 0;\n\tu16 sclass;\n\tstruct dentry *dentry;\n\tint rc = 0;\n\n\tif (isec->initialized == LABEL_INITIALIZED)\n\t\treturn 0;\n\n\tspin_lock(&isec->lock);\n\tif (isec->initialized == LABEL_INITIALIZED)\n\t\tgoto out_unlock;\n\n\tif (isec->sclass == SECCLASS_FILE)\n\t\tisec->sclass = inode_mode_to_security_class(inode->i_mode);\n\n\tsbsec = selinux_superblock(inode->i_sb);\n\tif (!(sbsec->flags & SE_SBINITIALIZED)) {\n\t\t\/* Defer initialization until selinux_complete_init,\n\t\t   after the initial policy is loaded and the security\n\t\t   server is ready to handle calls. *\/\n\t\tspin_lock(&sbsec->isec_lock);\n\t\tif (list_empty(&isec->list))\n\t\t\tlist_add(&isec->list, &sbsec->isec_head);\n\t\tspin_unlock(&sbsec->isec_lock);\n\t\tgoto out_unlock;\n\t}\n\n\tsclass = isec->sclass;\n\ttask_sid = isec->task_sid;\n\tsid = isec->sid;\n\tisec->initialized = LABEL_PENDING;\n\tspin_unlock(&isec->lock);\n\n\tswitch (sbsec->behavior) {\n\tcase SECURITY_FS_USE_NATIVE:\n\t\tbreak;\n\tcase SECURITY_FS_USE_XATTR:\n\t\tif (!(inode->i_opflags & IOP_XATTR)) {\n\t\t\tsid = sbsec->def_sid;\n\t\t\tbreak;\n\t\t}\n\t\t\/* Need a dentry, since the xattr API requires one.\n\t\t   Life would be simpler if we could just pass the inode. *\/\n\t\tif (opt_dentry) {\n\t\t\t\/* Called from d_instantiate or d_splice_alias. *\/\n\t\t\tdentry = dget(opt_dentry);\n\t\t} else {\n\t\t\t\/*\n\t\t\t * Called from selinux_complete_init, try to find a dentry.\n\t\t\t * Some filesystems really want a connected one, so try\n\t\t\t * that first.  We could split SECURITY_FS_USE_XATTR in\n\t\t\t * two, depending upon that...\n\t\t\t *\/\n\t\t\tdentry = d_find_alias(inode);\n\t\t\tif (!dentry)\n\t\t\t\tdentry = d_find_any_alias(inode);\n\t\t}\n\t\tif (!dentry) {\n\t\t\t\/*\n\t\t\t * this is can be hit on boot when a file is accessed\n\t\t\t * before the policy is loaded.  When we load policy we\n\t\t\t * may find inodes that have no dentry on the\n\t\t\t * sbsec->isec_head list.  No reason to complain as these\n\t\t\t * will get fixed up the next time we go through\n\t\t\t * inode_doinit with a dentry, before these inodes could\n\t\t\t * be used again by userspace.\n\t\t\t *\/\n\t\t\tgoto out_invalid;\n\t\t}\n\n\t\trc = inode_doinit_use_xattr(inode, dentry, sbsec->def_sid,\n\t\t\t\t\t    &sid);\n\t\tdput(dentry);\n\t\tif (rc)\n\t\t\tgoto out;\n\t\tbreak;\n\tcase SECURITY_FS_USE_TASK:\n\t\tsid = task_sid;\n\t\tbreak;\n\tcase SECURITY_FS_USE_TRANS:\n\t\t\/* Default to the fs SID. *\/\n\t\tsid = sbsec->sid;\n\n\t\t\/* Try to obtain a transition SID. *\/\n\t\trc = security_transition_sid(&selinux_state, task_sid, sid,\n\t\t\t\t\t     sclass, NULL, &sid);\n\t\tif (rc)\n\t\t\tgoto out;\n\t\tbreak;\n\tcase SECURITY_FS_USE_MNTPOINT:\n\t\tsid = sbsec->mntpoint_sid;\n\t\tbreak;\n\tdefault:\n\t\t\/* Default to the fs superblock SID. *\/\n\t\tsid = sbsec->sid;\n\n\t\tif ((sbsec->flags & SE_SBGENFS) &&\n\t\t     (!S_ISLNK(inode->i_mode) ||\n\t\t      selinux_policycap_genfs_seclabel_symlinks())) {\n\t\t\t\/* We must have a dentry to determine the label on\n\t\t\t * procfs inodes *\/\n\t\t\tif (opt_dentry) {\n\t\t\t\t\/* Called from d_instantiate or\n\t\t\t\t * d_splice_alias. *\/\n\t\t\t\tdentry = dget(opt_dentry);\n\t\t\t} else {\n\t\t\t\t\/* Called from selinux_complete_init, try to\n\t\t\t\t * find a dentry.  Some filesystems really want\n\t\t\t\t * a connected one, so try that first.\n\t\t\t\t *\/\n\t\t\t\tdentry = d_find_alias(inode);\n\t\t\t\tif (!dentry)\n\t\t\t\t\tdentry = d_find_any_alias(inode);\n\t\t\t}\n\t\t\t\/*\n\t\t\t * This can be hit on boot when a file is accessed\n\t\t\t * before the policy is loaded.  When we load policy we\n\t\t\t * may find inodes that have no dentry on the\n\t\t\t * sbsec->isec_head list.  No reason to complain as\n\t\t\t * these will get fixed up the next time we go through\n\t\t\t * inode_doinit() with a dentry, before these inodes\n\t\t\t * could be used again by userspace.\n\t\t\t *\/\n\t\t\tif (!dentry)\n\t\t\t\tgoto out_invalid;\n\t\t\trc = selinux_genfs_get_sid(dentry, sclass,\n\t\t\t\t\t\t   sbsec->flags, &sid);\n\t\t\tif (rc) {\n\t\t\t\tdput(dentry);\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\tif ((sbsec->flags & SE_SBGENFS_XATTR) &&\n\t\t\t    (inode->i_opflags & IOP_XATTR)) {\n\t\t\t\trc = inode_doinit_use_xattr(inode, dentry,\n\t\t\t\t\t\t\t    sid, &sid);\n\t\t\t\tif (rc) {\n\t\t\t\t\tdput(dentry);\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdput(dentry);\n\t\t}\n\t\tbreak;\n\t}\n\nout:\n\tspin_lock(&isec->lock);\n\tif (isec->initialized == LABEL_PENDING) {\n\t\tif (rc) {\n\t\t\tisec->initialized = LABEL_INVALID;\n\t\t\tgoto out_unlock;\n\t\t}\n\t\tisec->initialized = LABEL_INITIALIZED;\n\t\tisec->sid = sid;\n\t}\n\nout_unlock:\n\tspin_unlock(&isec->lock);\n\treturn rc;\n\nout_invalid:\n\tspin_lock(&isec->lock);\n\tif (isec->initialized == LABEL_PENDING) {\n\t\tisec->initialized = LABEL_INVALID;\n\t\tisec->sid = sid;\n\t}\n\tspin_unlock(&isec->lock);\n\treturn 0;\n}","target":0,"code_token_length":1361,"total_token_length":1597,"max_tokens_setting":2048}
+{"idx":212934,"func":"static int write_entry(struct mailbox *mailbox,\n                       unsigned int uid,\n                       const char *entry,\n                       const char *userid,\n                       const struct buf *value,\n                       int ignorequota,\n                       int silent,\n                       const struct annotate_metadata *mdata,\n                       int maywrite)\n\n{\n    char key[MAX_MAILBOX_PATH+1];\n    int keylen, r;\n    annotate_db_t *d = NULL;\n    struct buf oldval = BUF_INITIALIZER;\n    const char *mboxname = mailbox ? mailbox->name : \"\";\n    modseq_t modseq = mdata ? mdata->modseq : 0;\n\n    r = _annotate_getdb(mboxname, uid, CYRUSDB_CREATE, &d);\n    if (r)\n        return r;\n\n    \/* must be in a transaction to modify the db *\/\n    annotate_begin(d);\n\n    keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key));\n\n    if (mailbox) {\n        struct annotate_metadata oldmdata;\n        r = read_old_value(d, key, keylen, &oldval, &oldmdata);\n        if (r) goto out;\n\n        \/* if the value is identical, don't touch the mailbox *\/\n        if (oldval.len == value->len && (!value->len || !memcmp(oldval.s, value->s, value->len)))\n            goto out;\n\n        if (!ignorequota) {\n            quota_t qdiffs[QUOTA_NUMRESOURCES] = QUOTA_DIFFS_DONTCARE_INITIALIZER;\n            qdiffs[QUOTA_ANNOTSTORAGE] = value->len - (quota_t)oldval.len;\n            r = mailbox_quota_check(mailbox, qdiffs);\n            if (r) goto out;\n        }\n\n        if (!maywrite) {\n            r = IMAP_PERMISSION_DENIED;\n            if (r) goto out;\n        }\n\n        \/* do the annot-changed here before altering the DB *\/\n        mailbox_annot_changed(mailbox, uid, entry, userid, &oldval, value, silent);\n\n        \/* grab the message annotation modseq, if not overridden *\/\n        if (uid && !mdata) {\n            modseq = mailbox->i.highestmodseq;\n        }\n    }\n\n    \/* zero length annotation is deletion.\n     * keep tombstones for message annotations *\/\n    if (!value->len && !uid) {\n\n#if DEBUG\n        syslog(LOG_ERR, \"write_entry: deleting key %s from %s\",\n                key_as_string(d, key, keylen), d->filename);\n#endif\n\n        do {\n            r = cyrusdb_delete(d->db, key, keylen, tid(d), \/*force*\/1);\n        } while (r == CYRUSDB_AGAIN);\n    }\n    else {\n        struct buf data = BUF_INITIALIZER;\n        unsigned char flags = 0;\n        if (!value->len || value->s == NULL) {\n            flags |= ANNOTATE_FLAG_DELETED;\n        }\n        else {\n            \/\/ this is only here to allow cleanup of invalid values in the past...\n            \/\/ the calling of this API with a NULL \"userid\" is bogus, because that's\n            \/\/ supposed to be reserved for the make_key of prefixes - but there has\n            \/\/ been API abuse in the past, so some of these are in the wild.  *sigh*.\n            \/\/ Don't allow new ones to be written\n            if (!userid) goto out;\n        }\n        make_entry(&data, value, modseq, flags);\n\n#if DEBUG\n        syslog(LOG_ERR, \"write_entry: storing key %s (value: %s) to %s (modseq=\" MODSEQ_FMT \")\",\n                key_as_string(d, key, keylen), value->s, d->filename, modseq);\n#endif\n\n        do {\n            r = cyrusdb_store(d->db, key, keylen, data.s, data.len, tid(d));\n        } while (r == CYRUSDB_AGAIN);\n        buf_free(&data);\n    }\n\n    if (!mailbox)\n        sync_log_annotation(\"\");\n\nout:\n    annotate_putdb(&d);\n    buf_free(&oldval);\n\n    return r;\n}","target":1,"code_token_length":868,"total_token_length":1104,"max_tokens_setting":2048}
+{"idx":466168,"func":"static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,\n\t\t\t  unsigned d)\n{\n\tint rc = X86EMUL_CONTINUE;\n\n\tswitch (d) {\n\tcase OpReg:\n\t\tdecode_register_operand(ctxt, op,\n\t\t\t op == &ctxt->dst &&\n\t\t\t ctxt->twobyte && (ctxt->b == 0xb6 || ctxt->b == 0xb7));\n\t\tbreak;\n\tcase OpImmUByte:\n\t\trc = decode_imm(ctxt, op, 1, false);\n\t\tbreak;\n\tcase OpMem:\n\t\tctxt->memop.bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;\n\tmem_common:\n\t\t*op = ctxt->memop;\n\t\tctxt->memopp = op;\n\t\tif ((ctxt->d & BitOp) && op == &ctxt->dst)\n\t\t\tfetch_bit_operand(ctxt);\n\t\top->orig_val = op->val;\n\t\tbreak;\n\tcase OpMem64:\n\t\tctxt->memop.bytes = 8;\n\t\tgoto mem_common;\n\tcase OpAcc:\n\t\top->type = OP_REG;\n\t\top->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;\n\t\top->addr.reg = &ctxt->regs[VCPU_REGS_RAX];\n\t\tfetch_register_operand(op);\n\t\top->orig_val = op->val;\n\t\tbreak;\n\tcase OpDI:\n\t\top->type = OP_MEM;\n\t\top->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;\n\t\top->addr.mem.ea =\n\t\t\tregister_address(ctxt, ctxt->regs[VCPU_REGS_RDI]);\n\t\top->addr.mem.seg = VCPU_SREG_ES;\n\t\top->val = 0;\n\t\tbreak;\n\tcase OpDX:\n\t\top->type = OP_REG;\n\t\top->bytes = 2;\n\t\top->addr.reg = &ctxt->regs[VCPU_REGS_RDX];\n\t\tfetch_register_operand(op);\n\t\tbreak;\n\tcase OpCL:\n\t\top->bytes = 1;\n\t\top->val = ctxt->regs[VCPU_REGS_RCX] & 0xff;\n\t\tbreak;\n\tcase OpImmByte:\n\t\trc = decode_imm(ctxt, op, 1, true);\n\t\tbreak;\n\tcase OpOne:\n\t\top->bytes = 1;\n\t\top->val = 1;\n\t\tbreak;\n\tcase OpImm:\n\t\trc = decode_imm(ctxt, op, imm_size(ctxt), true);\n\t\tbreak;\n\tcase OpMem16:\n\t\tctxt->memop.bytes = 2;\n\t\tgoto mem_common;\n\tcase OpMem32:\n\t\tctxt->memop.bytes = 4;\n\t\tgoto mem_common;\n\tcase OpImmU16:\n\t\trc = decode_imm(ctxt, op, 2, false);\n\t\tbreak;\n\tcase OpImmU:\n\t\trc = decode_imm(ctxt, op, imm_size(ctxt), false);\n\t\tbreak;\n\tcase OpSI:\n\t\top->type = OP_MEM;\n\t\top->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;\n\t\top->addr.mem.ea =\n\t\t\tregister_address(ctxt, ctxt->regs[VCPU_REGS_RSI]);\n\t\top->addr.mem.seg = seg_override(ctxt);\n\t\top->val = 0;\n\t\tbreak;\n\tcase OpImmFAddr:\n\t\top->type = OP_IMM;\n\t\top->addr.mem.ea = ctxt->_eip;\n\t\top->bytes = ctxt->op_bytes + 2;\n\t\tinsn_fetch_arr(op->valptr, op->bytes, ctxt);\n\t\tbreak;\n\tcase OpMemFAddr:\n\t\tctxt->memop.bytes = ctxt->op_bytes + 2;\n\t\tgoto mem_common;\n\tcase OpES:\n\t\top->val = VCPU_SREG_ES;\n\t\tbreak;\n\tcase OpCS:\n\t\top->val = VCPU_SREG_CS;\n\t\tbreak;\n\tcase OpSS:\n\t\top->val = VCPU_SREG_SS;\n\t\tbreak;\n\tcase OpDS:\n\t\top->val = VCPU_SREG_DS;\n\t\tbreak;\n\tcase OpFS:\n\t\top->val = VCPU_SREG_FS;\n\t\tbreak;\n\tcase OpGS:\n\t\top->val = VCPU_SREG_GS;\n\t\tbreak;\n\tcase OpImplicit:\n\t\t\/* Special instructions do their own operand decoding. *\/\n\tdefault:\n\t\top->type = OP_NONE; \/* Disable writeback. *\/\n\t\tbreak;\n\t}\n\ndone:\n\treturn rc;\n}","target":0,"code_token_length":946,"total_token_length":1182,"max_tokens_setting":2048}
+{"idx":247124,"func":"GF_Filter *gf_fs_load_filter(GF_FilterSession *fsess, const char *name, GF_Err *err_code)\n{\n\tconst char *args=NULL;\n\tconst char *sep, *file_ext;\n\tu32 i, len, count = gf_list_count(fsess->registry);\n\tBool quiet = (err_code && (*err_code == GF_EOS)) ? GF_TRUE : GF_FALSE;\n\n\tassert(fsess);\n\tassert(name);\n\tif (err_code) *err_code = GF_OK;\n\n\tsep = gf_fs_path_escape_colon(fsess, name);\n\tif (sep) {\n\t\targs = sep+1;\n\t\tlen = (u32) (sep - name);\n\t} else len = (u32) strlen(name);\n\n\tif (!len) {\n\t\tif (!quiet) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"Missing filter name in %s\\n\", name));\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif (!strncmp(name, \"enc\", len)) {\n\t\treturn gf_fs_load_encoder(fsess, args);\n\t}\n\t\/*regular filter loading*\/\n\tfor (i=0;i<count;i++) {\n\t\tconst GF_FilterRegister *f_reg = gf_list_get(fsess->registry, i);\n\t\tif ((strlen(f_reg->name)==len) && !strncmp(f_reg->name, name, len)) {\n\t\t\tGF_Filter *filter;\n\t\t\tGF_FilterArgType argtype = GF_FILTER_ARG_EXPLICIT;\n\n\t\t\tif ((f_reg->flags & GF_FS_REG_REQUIRES_RESOLVER) && !fsess->max_resolve_chain_len) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"Filter %s requires graph resolver but it is disabled\\n\", name));\n\t\t\t\tif (err_code) *err_code = GF_BAD_PARAM;\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tif (f_reg->flags & GF_FS_REG_ACT_AS_SOURCE) argtype = GF_FILTER_ARG_EXPLICIT_SOURCE;\n\t\t\tfilter = gf_filter_new(fsess, f_reg, args, NULL, argtype, err_code, NULL, GF_FALSE);\n\t\t\tif (!filter) return NULL;\n\t\t\tif (!filter->num_output_pids) {\n\t\t\t\t\/\/check we have a src specified for the filter\n\t\t\t\tconst char *src_url = strstr(name, \"src\");\n\t\t\t\tif (src_url && (src_url[3]==fsess->sep_name)) {\n\t\t\t\t\tconst GF_FilterArgs *args = filter->instance_args ? filter->instance_args : f_reg->args;\n\t\t\t\t\t\/\/check the filter has an src argument\n\t\t\t\t\t\/\/we don't want to call process on a filter not acting as source until at least one input is connected\n\t\t\t\t\ti=0;\n\t\t\t\t\twhile (args && args[i].arg_name) {\n\t\t\t\t\t\tif (!strcmp(args[i].arg_name, \"src\")) {\n\t\t\t\t\t\t\tgf_filter_post_process_task(filter);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn filter;\n\t\t}\n\t}\n\t\/*check JS file*\/\n\tfile_ext = gf_file_ext_start(name);\n\tif (file_ext && (file_ext > sep) )\n\t\tfile_ext = NULL;\n\n\tif (!file_ext || strstr(name, \".js\") || strstr(name, \".jsf\") || strstr(name, \".mjs\") ) {\n\t\tBool file_exists = GF_FALSE;\n\t\tchar szName[10+GF_MAX_PATH];\n\t\tchar szPath[10+GF_MAX_PATH];\n\t\tif (len>GF_MAX_PATH)\n\t\t\treturn NULL;\n\n\t\tstrncpy(szPath, name, len);\n\t\tszPath[len]=0;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, (\"Trying JS filter %s\\n\", szPath));\n\t\tif (gf_file_exists(szPath)) {\n\t\t\tfile_exists = GF_TRUE;\n\t\t} else {\n\t\t\tstrcpy(szName, szPath);\n\t\t\tfile_exists = gf_fs_solve_js_script(szPath, szName, file_ext);\n\t\t\tif (!file_exists && !file_ext) {\n\t\t\t\tstrcat(szName, \".js\");\n\t\t\t\tif (gf_file_exists(szName)) {\n\t\t\t\t\tstrncpy(szPath, name, len);\n\t\t\t\t\tszPath[len]=0;\n\t\t\t\t\tstrcat(szPath, \".js\");\n\t\t\t\t\tfile_exists = GF_TRUE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (file_exists) {\n\t\t\tsprintf(szName, \"jsf%cjs%c\", fsess->sep_args, fsess->sep_name);\n\t\t\tstrcat(szName, szPath);\n\t\t\tif (name[len])\n\t\t\t\tstrcat(szName, name+len);\n\t\t\treturn gf_fs_load_filter(fsess, szName, err_code);\n\t\t}\n\t}\n\n\tif (!quiet) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, (\"Failed to load filter %s: no such filter registry\\n\", name));\n\t}\n\tif (err_code) *err_code = GF_FILTER_NOT_FOUND;\n\treturn NULL;\n}","target":0,"code_token_length":1015,"total_token_length":1251,"max_tokens_setting":2048}
+{"idx":313840,"func":"nv_visual(cmdarg_T *cap)\n{\n    if (cap->cmdchar == Ctrl_Q)\n\tcap->cmdchar = Ctrl_V;\n\n    \/\/ 'v', 'V' and CTRL-V can be used while an operator is pending to make it\n    \/\/ characterwise, linewise, or blockwise.\n    if (cap->oap->op_type != OP_NOP)\n    {\n\tmotion_force = cap->oap->motion_force = cap->cmdchar;\n\tfinish_op = FALSE;\t\/\/ operator doesn't finish now but later\n\treturn;\n    }\n\n    VIsual_select = cap->arg;\n    if (VIsual_active)\t    \/\/ change Visual mode\n    {\n\tif (VIsual_mode == cap->cmdchar)    \/\/ stop visual mode\n\t    end_visual_mode();\n\telse\t\t\t\t    \/\/ toggle char\/block mode\n\t{\t\t\t\t    \/\/\t   or char\/line mode\n\t    VIsual_mode = cap->cmdchar;\n\t    showmode();\n\t    may_trigger_modechanged();\n\t}\n\tredraw_curbuf_later(INVERTED);\t    \/\/ update the inversion\n    }\n    else\t\t    \/\/ start Visual mode\n    {\n\tcheck_visual_highlight();\n\tif (cap->count0 > 0 && resel_VIsual_mode != NUL)\n\t{\n\t    \/\/ use previously selected part\n\t    VIsual = curwin->w_cursor;\n\n\t    VIsual_active = TRUE;\n\t    VIsual_reselect = TRUE;\n\t    if (!cap->arg)\n\t\t\/\/ start Select mode when 'selectmode' contains \"cmd\"\n\t\tmay_start_select('c');\n\t    setmouse();\n\t    if (p_smd && msg_silent == 0)\n\t\tredraw_cmdline = TRUE;\t    \/\/ show visual mode later\n\t    \/\/ For V and ^V, we multiply the number of lines even if there\n\t    \/\/ was only one -- webb\n\t    if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1)\n\t    {\n\t\tcurwin->w_cursor.lnum +=\n\t\t\t\t    resel_VIsual_line_count * cap->count0 - 1;\n\t\tcheck_cursor();\n\t    }\n\t    VIsual_mode = resel_VIsual_mode;\n\t    if (VIsual_mode == 'v')\n\t    {\n\t\tif (resel_VIsual_line_count <= 1)\n\t\t{\n\t\t    validate_virtcol();\n\t\t    curwin->w_curswant = curwin->w_virtcol\n\t\t\t\t\t+ resel_VIsual_vcol * cap->count0 - 1;\n\t\t}\n\t\telse\n\t\t    curwin->w_curswant = resel_VIsual_vcol;\n\t\tcoladvance(curwin->w_curswant);\n\t    }\n\t    if (resel_VIsual_vcol == MAXCOL)\n\t    {\n\t\tcurwin->w_curswant = MAXCOL;\n\t\tcoladvance((colnr_T)MAXCOL);\n\t    }\n\t    else if (VIsual_mode == Ctrl_V)\n\t    {\n\t\tvalidate_virtcol();\n\t\tcurwin->w_curswant = curwin->w_virtcol\n\t\t\t\t\t+ resel_VIsual_vcol * cap->count0 - 1;\n\t\tcoladvance(curwin->w_curswant);\n\t    }\n\t    else\n\t\tcurwin->w_set_curswant = TRUE;\n\t    redraw_curbuf_later(INVERTED);\t\/\/ show the inversion\n\t}\n\telse\n\t{\n\t    if (!cap->arg)\n\t\t\/\/ start Select mode when 'selectmode' contains \"cmd\"\n\t\tmay_start_select('c');\n\t    n_start_visual_mode(cap->cmdchar);\n\t    if (VIsual_mode != 'V' && *p_sel == 'e')\n\t\t++cap->count1;  \/\/ include one more char\n\t    if (cap->count0 > 0 && --cap->count1 > 0)\n\t    {\n\t\t\/\/ With a count select that many characters or lines.\n\t\tif (VIsual_mode == 'v' || VIsual_mode == Ctrl_V)\n\t\t    nv_right(cap);\n\t\telse if (VIsual_mode == 'V')\n\t\t    nv_down(cap);\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":875,"total_token_length":1111,"max_tokens_setting":2048}
+{"idx":513265,"func":"remove_const(JOIN *join,ORDER *first_order, COND *cond,\n             bool change_list, bool *simple_order)\n{\n  *simple_order= join->rollup.state == ROLLUP::STATE_NONE;\n  if (join->only_const_tables())\n    return change_list ? 0 : first_order;\t\t\/\/ No need to sort\n\n  ORDER *order,**prev_ptr, *tmp_order;\n  table_map UNINIT_VAR(first_table); \/* protected by first_is_base_table *\/\n  table_map not_const_tables= ~join->const_table_map;\n  table_map ref;\n  bool first_is_base_table= FALSE;\n  DBUG_ENTER(\"remove_const\");\n  \n  \/*\n    Join tab is set after make_join_statistics() has been called.\n    In case of one table with GROUP BY this function is called before\n    join_tab is set for the GROUP_BY expression\n  *\/\n  if (join->join_tab)\n  {\n    if (join->join_tab[join->const_tables].table)\n    {\n      first_table= join->join_tab[join->const_tables].table->map;\n      first_is_base_table= TRUE;\n    }\n  \n    \/*\n      Cleanup to avoid interference of calls of this function for\n      ORDER BY and GROUP BY\n    *\/\n    for (JOIN_TAB *tab= join->join_tab + join->const_tables;\n         tab < join->join_tab + join->table_count;\n         tab++)\n      tab->cached_eq_ref_table= FALSE;\n\n    *simple_order= *join->join_tab[join->const_tables].on_expr_ref ? 0 : 1;\n  }\n  else\n  {\n    first_is_base_table= FALSE;\n    first_table= 0;                     \/\/ Not used, for gcc\n  }\n\n  prev_ptr= &first_order;\n\n  \/* NOTE: A variable of not_const_tables ^ first_table; breaks gcc 2.7 *\/\n\n  update_depend_map_for_order(join, first_order);\n  for (order=first_order; order ; order=order->next)\n  {\n    table_map order_tables=order->item[0]->used_tables();\n    if (order->item[0]->with_sum_func ||\n        order->item[0]->with_window_func ||\n        \/*\n          If the outer table of an outer join is const (either by itself or\n          after applying WHERE condition), grouping on a field from such a\n          table will be optimized away and filesort without temporary table\n          will be used unless we prevent that now. Filesort is not fit to\n          handle joins and the join condition is not applied. We can't detect\n          the case without an expensive test, however, so we force temporary\n          table for all queries containing more than one table, ROLLUP, and an\n          outer join.\n         *\/\n        (join->table_count > 1 && join->rollup.state == ROLLUP::STATE_INITED &&\n        join->outer_join))\n      *simple_order=0;\t\t\t\t\/\/ Must do a temp table to sort\n    else if (!(order_tables & not_const_tables))\n    {\n      if (order->item[0]->has_subquery())\n      {\n        \/*\n          Delay the evaluation of constant ORDER and\/or GROUP expressions that\n          contain subqueries until the execution phase.\n        *\/\n        join->exec_const_order_group_cond.push_back(order->item[0],\n                                                    join->thd->mem_root);\n      }\n      DBUG_PRINT(\"info\",(\"removing: %s\", order->item[0]->full_name()));\n      continue;\n    }\n    else\n    {\n      if (order_tables & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT))\n\t*simple_order=0;\n      else\n      {\n\tif (cond && const_expression_in_where(cond,order->item[0]))\n\t{\n\t  DBUG_PRINT(\"info\",(\"removing: %s\", order->item[0]->full_name()));\n\t  continue;\n\t}\n\tif (first_is_base_table &&\n            (ref=order_tables & (not_const_tables ^ first_table)))\n\t{\n\t  if (!(order_tables & first_table) &&\n              only_eq_ref_tables(join,first_order, ref))\n\t  {\n\t    DBUG_PRINT(\"info\",(\"removing: %s\", order->item[0]->full_name()));\n\t    continue;\n\t  }\n          \/*\n            UseMultipleEqualitiesToRemoveTempTable:\n            Can use multiple-equalities here to check that ORDER BY columns\n            can be used without tmp. table.\n          *\/\n          bool can_subst_to_first_table= false;\n          bool first_is_in_sjm_nest= false;\n          if (first_is_base_table)\n          {\n            TABLE_LIST *tbl_for_first=\n              join->join_tab[join->const_tables].table->pos_in_table_list;\n            first_is_in_sjm_nest= tbl_for_first->sj_mat_info &&\n                                  tbl_for_first->sj_mat_info->is_used;\n          }\n          \/*\n            Currently we do not employ the optimization that uses multiple\n            equalities for ORDER BY to remove tmp table in the case when\n            the first table happens to be the result of materialization of\n            a semi-join nest ( <=> first_is_in_sjm_nest == true).\n\n            When a semi-join nest is materialized and scanned to look for\n            possible matches in the remaining tables for every its row\n            the fields from the result of materialization are copied\n            into the record buffers of tables from the semi-join nest.\n            So these copies are used to access the remaining tables rather\n            than the fields from the result of materialization.\n\n            Unfortunately now this so-called 'copy back' technique is\n            supported only if the rows  are scanned with the rr_sequential\n            function, but not with other rr_* functions that are employed\n            when the result of materialization is required to be sorted.\n\n            TODO: either to support 'copy back' technique for the above case,\n                  or to get rid of this technique altogether.\n          *\/\n          if (optimizer_flag(join->thd, OPTIMIZER_SWITCH_ORDERBY_EQ_PROP) &&\n              first_is_base_table && !first_is_in_sjm_nest &&\n              order->item[0]->real_item()->type() == Item::FIELD_ITEM &&\n              join->cond_equal)\n          {\n            table_map first_table_bit=\n              join->join_tab[join->const_tables].table->map;\n\n            Item *item= order->item[0];\n\n            \/*\n              TODO: equality substitution in the context of ORDER BY is \n              sometimes allowed when it is not allowed in the general case.\n              \n              We make the below call for its side effect: it will locate the\n              multiple equality the item belongs to and set item->item_equal\n              accordingly.\n            *\/\n            Item *res= item->propagate_equal_fields(join->thd,\n                                                    Value_source::\n                                                    Context_identity(),\n                                                    join->cond_equal);\n            Item_equal *item_eq;\n            if ((item_eq= res->get_item_equal()))\n            {\n              Item *first= item_eq->get_first(NO_PARTICULAR_TAB, NULL);\n              if (first->const_item() || first->used_tables() ==\n                                         first_table_bit)\n              {\n                can_subst_to_first_table= true;\n              }\n            }\n          }\n\n          if (!can_subst_to_first_table)\n          {\n            *simple_order=0;\t\t\t\/\/ Must do a temp table to sort\n          }\n\t}\n      }\n    }\n    \/* Remove ORDER BY entries that we have seen before *\/\n    for (tmp_order= first_order;\n         tmp_order != order;\n         tmp_order= tmp_order->next)\n    {\n      if (tmp_order->item[0]->eq(order->item[0],1))\n        break;\n    }\n    if (tmp_order != order)\n      continue;                                \/\/ Duplicate order by. Remove\n    \n    if (change_list)\n      *prev_ptr= order;\t\t\t\t\/\/ use this entry\n    prev_ptr= &order->next;\n  }\n  if (change_list)\n    *prev_ptr=0;\n  if (prev_ptr == &first_order)\t\t\t\/\/ Nothing to sort\/group\n    *simple_order=1;\n#ifndef DBUG_OFF\n  if (join->thd->is_error())\n    DBUG_PRINT(\"error\",(\"Error from remove_const\"));\n#endif\n  DBUG_PRINT(\"exit\",(\"simple_order: %d\",(int) *simple_order));\n  DBUG_RETURN(first_order);\n}","target":0,"code_token_length":1753,"total_token_length":1989,"max_tokens_setting":2048}
+{"idx":224470,"func":"static GF_Err gf_text_process_sub(GF_Filter *filter, GF_TXTIn *ctx)\n{\n\tu32 i, j, len, line;\n\tGF_TextSample *samp;\n\tDouble ts_scale;\n\tchar szLine[2048], szTime[20], szText[2048];\n\n\t\/\/same setup as for srt\n\tif (!ctx->is_setup) {\n\t\tctx->is_setup = GF_TRUE;\n\t\treturn txtin_setup_srt(filter, ctx);\n\t}\n\tif (!ctx->opid) return GF_NOT_SUPPORTED;\n\tif (!ctx->playstate) return GF_OK;\n\telse if (ctx->playstate==2) return GF_EOS;\n\n\tif (ctx->seek_state==1) {\n\t\tctx->seek_state = 2;\n\t\tgf_fseek(ctx->src, 0, SEEK_SET);\n\t}\n\n\tif (ctx->fps.den && ctx->fps.num) {\n\t\tts_scale = ((Double) ctx->fps.num) \/ ctx->fps.den;\n\t} else {\n\t\tts_scale = 25;\n\t}\n\n\tline = 0;\n\n\twhile (1) {\n\t\tchar *sOK = gf_text_get_utf8_line(szLine, 2048, ctx->src, ctx->unicode_type);\n\t\tif (!sOK) break;\n\n\t\tREM_TRAIL_MARKS(szLine, \"\\r\\n\\t \")\n\n\t\tline++;\n\t\tlen = (u32) strlen(szLine);\n\t\tif (!len) continue;\n\n\t\ti=0;\n\t\tif (szLine[i] != '{') {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Bad SUB file (line %d): expecting \\\"{\\\" got \\\"%c\\\"\\n\", line, szLine[i]));\n\t\t\tcontinue;\n\t\t}\n\t\twhile (szLine[i+1] && szLine[i+1]!='}') {\n\t\t\tszTime[i] = szLine[i+1];\n\t\t\ti++;\n\t\t\tif (i>=19)\n\t\t\t\tbreak;\n\t\t}\n\t\tszTime[i] = 0;\n\t\tctx->start = atoi(szTime);\n\t\tif (ctx->start < ctx->end) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TXTIn] corrupted SUB frame (line %d) - starts (at %d ms) before end of previous one (%d ms) - adjusting time stamps\\n\", line, ctx->start, ctx->end));\n\t\t\tctx->start = ctx->end;\n\t\t}\n\t\tj=i+2;\n\t\ti=0;\n\t\tif (szLine[i+j] != '{') {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TXTIn] Bad SUB file - expecting \\\"{\\\" got \\\"%c\\\"\\n\", szLine[i]));\n\t\t\tcontinue;\n\t\t}\n\t\twhile (szLine[i+1+j] && szLine[i+1+j]!='}') {\n\t\t\tszTime[i] = szLine[i+1+j];\n\t\t\ti++;\n\t\t}\n\t\tszTime[i] = 0;\n\t\tctx->end = atoi(szTime);\n\t\tj+=i+2;\n\n\t\tif (ctx->start > ctx->end) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TXTIn] corrupted SUB frame (line %d) - ends (at %d ms) before start of current frame (%d ms) - skipping\\n\", line, ctx->end, ctx->start));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ctx->start && ctx->first_samp) {\n\t\t\tsamp = gf_isom_new_text_sample();\n\t\t\ttxtin_process_send_text_sample(ctx, samp, 0, (u32) (ts_scale*ctx->start), GF_TRUE);\n\t\t\tctx->first_samp = GF_FALSE;\n\t\t\tgf_isom_delete_text_sample(samp);\n\t\t}\n\n\t\tfor (i=j; i<len; i++) {\n\t\t\tif (szLine[i]=='|') {\n\t\t\t\tszText[i-j] = '\\n';\n\t\t\t} else {\n\t\t\t\tszText[i-j] = szLine[i];\n\t\t\t}\n\t\t}\n\t\tszText[i-j] = 0;\n\n\t\tif (ctx->prev_end) {\n\t\t\tsamp = gf_isom_new_text_sample();\n\t\t\ttxtin_process_send_text_sample(ctx, samp, (u64) (ts_scale*(s64)ctx->prev_end), (u32) (ts_scale*(ctx->start - ctx->prev_end)), GF_TRUE);\n\t\t\tgf_isom_delete_text_sample(samp);\n\t\t}\n\n\t\tsamp = gf_isom_new_text_sample();\n\t\tgf_isom_text_add_text(samp, szText, (u32) strlen(szText) );\n\t\ttxtin_process_send_text_sample(ctx, samp, (u64) (ts_scale*(s64)ctx->start), (u32) (ts_scale*(ctx->end - ctx->start)), GF_TRUE);\n\t\tgf_isom_delete_text_sample(samp);\n\n\t\tctx->prev_end = ctx->end;\n\n\t\tgf_filter_pid_set_info(ctx->opid, GF_PROP_PID_DOWN_BYTES, &PROP_LONGUINT( gf_ftell(ctx->src )) );\n\n\t\tif (gf_filter_pid_would_block(ctx->opid))\n\t\t\treturn GF_OK;\n\t}\n\t\/*final flush*\/\n\tif (ctx->end && !ctx->noflush) {\n\t\tsamp = gf_isom_new_text_sample();\n\t\ttxtin_process_send_text_sample(ctx, samp, (u64) (ts_scale*(s64)ctx->end), 0, GF_TRUE);\n\t\tgf_isom_delete_text_sample(samp);\n\t}\n\n\tgf_filter_pid_set_info_str( ctx->opid, \"ttxt:last_dur\", &PROP_UINT(0) );\n\n\treturn GF_EOS;\n}","target":0,"code_token_length":1220,"total_token_length":1456,"max_tokens_setting":2048}
+{"idx":477283,"func":"int tipc_crypto_xmit(struct net *net, struct sk_buff **skb,\n\t\t     struct tipc_bearer *b, struct tipc_media_addr *dst,\n\t\t     struct tipc_node *__dnode)\n{\n\tstruct tipc_crypto *__rx = tipc_node_crypto_rx(__dnode);\n\tstruct tipc_crypto *tx = tipc_net(net)->crypto_tx;\n\tstruct tipc_crypto_stats __percpu *stats = tx->stats;\n\tstruct tipc_msg *hdr = buf_msg(*skb);\n\tstruct tipc_key key = tx->key;\n\tstruct tipc_aead *aead = NULL;\n\tu32 user = msg_user(hdr);\n\tu32 type = msg_type(hdr);\n\tint rc = -ENOKEY;\n\tu8 tx_key = 0;\n\n\t\/* No encryption? *\/\n\tif (!tx->working)\n\t\treturn 0;\n\n\t\/* Pending key if peer has active on it or probing time *\/\n\tif (unlikely(key.pending)) {\n\t\ttx_key = key.pending;\n\t\tif (!tx->key_master && !key.active)\n\t\t\tgoto encrypt;\n\t\tif (__rx && atomic_read(&__rx->peer_rx_active) == tx_key)\n\t\t\tgoto encrypt;\n\t\tif (TIPC_SKB_CB(*skb)->xmit_type == SKB_PROBING) {\n\t\t\tpr_debug(\"%s: probing for key[%d]\\n\", tx->name,\n\t\t\t\t key.pending);\n\t\t\tgoto encrypt;\n\t\t}\n\t\tif (user == LINK_CONFIG || user == LINK_PROTOCOL)\n\t\t\ttipc_crypto_clone_msg(net, *skb, b, dst, __dnode,\n\t\t\t\t\t      SKB_PROBING);\n\t}\n\n\t\/* Master key if this is a *vital* message or in grace period *\/\n\tif (tx->key_master) {\n\t\ttx_key = KEY_MASTER;\n\t\tif (!key.active)\n\t\t\tgoto encrypt;\n\t\tif (TIPC_SKB_CB(*skb)->xmit_type == SKB_GRACING) {\n\t\t\tpr_debug(\"%s: gracing for msg (%d %d)\\n\", tx->name,\n\t\t\t\t user, type);\n\t\t\tgoto encrypt;\n\t\t}\n\t\tif (user == LINK_CONFIG ||\n\t\t    (user == LINK_PROTOCOL && type == RESET_MSG) ||\n\t\t    (user == MSG_CRYPTO && type == KEY_DISTR_MSG) ||\n\t\t    time_before(jiffies, tx->timer2 + TIPC_TX_GRACE_PERIOD)) {\n\t\t\tif (__rx && __rx->key_master &&\n\t\t\t    !atomic_read(&__rx->peer_rx_active))\n\t\t\t\tgoto encrypt;\n\t\t\tif (!__rx) {\n\t\t\t\tif (likely(!tx->legacy_user))\n\t\t\t\t\tgoto encrypt;\n\t\t\t\ttipc_crypto_clone_msg(net, *skb, b, dst,\n\t\t\t\t\t\t      __dnode, SKB_GRACING);\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Else, use the active key if any *\/\n\tif (likely(key.active)) {\n\t\ttx_key = key.active;\n\t\tgoto encrypt;\n\t}\n\n\tgoto exit;\n\nencrypt:\n\taead = tipc_aead_get(tx->aead[tx_key]);\n\tif (unlikely(!aead))\n\t\tgoto exit;\n\trc = tipc_ehdr_build(net, aead, tx_key, *skb, __rx);\n\tif (likely(rc > 0))\n\t\trc = tipc_aead_encrypt(aead, *skb, b, dst, __dnode);\n\nexit:\n\tswitch (rc) {\n\tcase 0:\n\t\tthis_cpu_inc(stats->stat[STAT_OK]);\n\t\tbreak;\n\tcase -EINPROGRESS:\n\tcase -EBUSY:\n\t\tthis_cpu_inc(stats->stat[STAT_ASYNC]);\n\t\t*skb = NULL;\n\t\treturn rc;\n\tdefault:\n\t\tthis_cpu_inc(stats->stat[STAT_NOK]);\n\t\tif (rc == -ENOKEY)\n\t\t\tthis_cpu_inc(stats->stat[STAT_NOKEYS]);\n\t\telse if (rc == -EKEYREVOKED)\n\t\t\tthis_cpu_inc(stats->stat[STAT_BADKEYS]);\n\t\tkfree_skb(*skb);\n\t\t*skb = NULL;\n\t\tbreak;\n\t}\n\n\ttipc_aead_put(aead);\n\treturn rc;\n}","target":0,"code_token_length":832,"total_token_length":1068,"max_tokens_setting":2048}
+{"idx":387149,"func":"static MagickBooleanType SetGrayscaleImage(Image *image,\n  ExceptionInfo *exception)\n{\n  CacheView\n    *image_view;\n\n  MagickBooleanType\n    status;\n\n  PixelInfo\n    *colormap;\n\n  register ssize_t\n    i;\n\n  ssize_t\n    *colormap_index,\n    j,\n    y;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->type != GrayscaleType)\n    (void) TransformImageColorspace(image,GRAYColorspace,exception);\n  if (image->storage_class == PseudoClass)\n    colormap_index=(ssize_t *) AcquireQuantumMemory(MagickMax(image->colors+1,\n      MaxMap),sizeof(*colormap_index));\n  else\n    colormap_index=(ssize_t *) AcquireQuantumMemory(MagickMax(MaxColormapSize+1,\n      MaxMap),sizeof(*colormap_index));\n  if (colormap_index == (ssize_t *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  if (image->storage_class != PseudoClass)\n    {\n      (void) memset(colormap_index,(-1),MaxColormapSize*\n        sizeof(*colormap_index));\n      if (AcquireImageColormap(image,MaxColormapSize,exception) == MagickFalse)\n        {\n          colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);\n          ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n            image->filename);\n        }\n      image->colors=0;\n      status=MagickTrue;\n      image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n      #pragma omp parallel for schedule(static) shared(status) \\\n        magick_number_threads(image,image,image->rows,1)\n#endif\n      for (y=0; y < (ssize_t) image->rows; y++)\n      {\n        register Quantum\n          *magick_restrict q;\n\n        register ssize_t\n          x;\n\n        if (status == MagickFalse)\n          continue;\n        q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,\n          exception);\n        if (q == (Quantum *) NULL)\n          {\n            status=MagickFalse;\n            continue;\n          }\n        for (x=0; x < (ssize_t) image->columns; x++)\n        {\n          register size_t\n            intensity;\n\n          intensity=ScaleQuantumToMap(GetPixelRed(image,q));\n          if (colormap_index[intensity] < 0)\n            {\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n              #pragma omp critical (MagickCore_SetGrayscaleImage)\n#endif\n              if (colormap_index[intensity] < 0)\n                {\n                  colormap_index[intensity]=(ssize_t) image->colors;\n                  image->colormap[image->colors].red=(double)\n                    GetPixelRed(image,q);\n                  image->colormap[image->colors].green=(double)\n                    GetPixelGreen(image,q);\n                  image->colormap[image->colors].blue=(double)\n                    GetPixelBlue(image,q);\n                  image->colors++;\n               }\n            }\n          SetPixelIndex(image,(Quantum) colormap_index[intensity],q);\n          q+=GetPixelChannels(image);\n        }\n        if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n          status=MagickFalse;\n      }\n      image_view=DestroyCacheView(image_view);\n    }\n  for (i=0; i < (ssize_t) image->colors; i++)\n    image->colormap[i].alpha=(double) i;\n  qsort((void *) image->colormap,image->colors,sizeof(PixelInfo),\n    IntensityCompare);\n  colormap=(PixelInfo *) AcquireQuantumMemory(image->colors,sizeof(*colormap));\n  if (colormap == (PixelInfo *) NULL)\n    {\n      colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);\n      ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n        image->filename);\n    }\n  j=0;\n  colormap[j]=image->colormap[0];\n  for (i=0; i < (ssize_t) image->colors; i++)\n  {\n    if (IsPixelInfoEquivalent(&colormap[j],&image->colormap[i]) == MagickFalse)\n      {\n        j++;\n        colormap[j]=image->colormap[i];\n      }\n    colormap_index[(ssize_t) image->colormap[i].alpha]=j;\n  }\n  image->colors=(size_t) (j+1);\n  image->colormap=(PixelInfo *) RelinquishMagickMemory(image->colormap);\n  image->colormap=colormap;\n  status=MagickTrue;\n  image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n  #pragma omp parallel for schedule(static) shared(status) \\\n    magick_number_threads(image,image,image->rows,1)\n#endif\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    register Quantum\n      *magick_restrict q;\n\n    register ssize_t\n      x;\n\n    if (status == MagickFalse)\n      continue;\n    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      {\n        status=MagickFalse;\n        continue;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      SetPixelIndex(image,(Quantum) colormap_index[ScaleQuantumToMap(\n        GetPixelIndex(image,q))],q);\n      q+=GetPixelChannels(image);\n    }\n    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n      status=MagickFalse;\n  }\n  image_view=DestroyCacheView(image_view);\n  colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);\n  image->type=GrayscaleType;\n  if (SetImageMonochrome(image,exception) != MagickFalse)\n    image->type=BilevelType;\n  return(status);\n}","target":0,"code_token_length":1302,"total_token_length":1538,"max_tokens_setting":2048}
+{"idx":301484,"func":"add_suggestion(\n    suginfo_T\t*su,\n    garray_T\t*gap,\t\t\/\/ either su_ga or su_sga\n    char_u\t*goodword,\n    int\t\tbadlenarg,\t\/\/ len of bad word replaced with \"goodword\"\n    int\t\tscore,\n    int\t\taltscore,\n    int\t\thad_bonus,\t\/\/ value for st_had_bonus\n    slang_T\t*slang,\t\t\/\/ language for sound folding\n    int\t\tmaxsf)\t\t\/\/ su_maxscore applies to soundfold score,\n\t\t\t\t\/\/ su_sfmaxscore to the total score.\n{\n    int\t\tgoodlen;\t\/\/ len of goodword changed\n    int\t\tbadlen;\t\t\/\/ len of bad word changed\n    suggest_T   *stp;\n    suggest_T   new_sug;\n    int\t\ti;\n    char_u\t*pgood, *pbad;\n\n    \/\/ Minimize \"badlen\" for consistency.  Avoids that changing \"the the\" to\n    \/\/ \"thee the\" is added next to changing the first \"the\" the \"thee\".\n    pgood = goodword + STRLEN(goodword);\n    pbad = su->su_badptr + badlenarg;\n    for (;;)\n    {\n\tgoodlen = (int)(pgood - goodword);\n\tbadlen = (int)(pbad - su->su_badptr);\n\tif (goodlen <= 0 || badlen <= 0)\n\t    break;\n\tMB_PTR_BACK(goodword, pgood);\n\tMB_PTR_BACK(su->su_badptr, pbad);\n\tif (has_mbyte)\n\t{\n\t    if (mb_ptr2char(pgood) != mb_ptr2char(pbad))\n\t\tbreak;\n\t}\n\telse if (*pgood != *pbad)\n\t\tbreak;\n    }\n\n    if (badlen == 0 && goodlen == 0)\n\t\/\/ goodword doesn't change anything; may happen for \"the the\" changing\n\t\/\/ the first \"the\" to itself.\n\treturn;\n\n    if (gap->ga_len == 0)\n\ti = -1;\n    else\n    {\n\t\/\/ Check if the word is already there.  Also check the length that is\n\t\/\/ being replaced \"thes,\" -> \"these\" is a different suggestion from\n\t\/\/ \"thes\" -> \"these\".\n\tstp = &SUG(*gap, 0);\n\tfor (i = gap->ga_len; --i >= 0; ++stp)\n\t    if (stp->st_wordlen == goodlen\n\t\t    && stp->st_orglen == badlen\n\t\t    && STRNCMP(stp->st_word, goodword, goodlen) == 0)\n\t    {\n\t\t\/\/ Found it.  Remember the word with the lowest score.\n\t\tif (stp->st_slang == NULL)\n\t\t    stp->st_slang = slang;\n\n\t\tnew_sug.st_score = score;\n\t\tnew_sug.st_altscore = altscore;\n\t\tnew_sug.st_had_bonus = had_bonus;\n\n\t\tif (stp->st_had_bonus != had_bonus)\n\t\t{\n\t\t    \/\/ Only one of the two had the soundalike score computed.\n\t\t    \/\/ Need to do that for the other one now, otherwise the\n\t\t    \/\/ scores can't be compared.  This happens because\n\t\t    \/\/ suggest_try_change() doesn't compute the soundalike\n\t\t    \/\/ word to keep it fast, while some special methods set\n\t\t    \/\/ the soundalike score to zero.\n\t\t    if (had_bonus)\n\t\t\trescore_one(su, stp);\n\t\t    else\n\t\t    {\n\t\t\tnew_sug.st_word = stp->st_word;\n\t\t\tnew_sug.st_wordlen = stp->st_wordlen;\n\t\t\tnew_sug.st_slang = stp->st_slang;\n\t\t\tnew_sug.st_orglen = badlen;\n\t\t\trescore_one(su, &new_sug);\n\t\t    }\n\t\t}\n\n\t\tif (stp->st_score > new_sug.st_score)\n\t\t{\n\t\t    stp->st_score = new_sug.st_score;\n\t\t    stp->st_altscore = new_sug.st_altscore;\n\t\t    stp->st_had_bonus = new_sug.st_had_bonus;\n\t\t}\n\t\tbreak;\n\t    }\n    }\n\n    if (i < 0 && ga_grow(gap, 1) == OK)\n    {\n\t\/\/ Add a suggestion.\n\tstp = &SUG(*gap, gap->ga_len);\n\tstp->st_word = vim_strnsave(goodword, goodlen);\n\tif (stp->st_word != NULL)\n\t{\n\t    stp->st_wordlen = goodlen;\n\t    stp->st_score = score;\n\t    stp->st_altscore = altscore;\n\t    stp->st_had_bonus = had_bonus;\n\t    stp->st_orglen = badlen;\n\t    stp->st_slang = slang;\n\t    ++gap->ga_len;\n\n\t    \/\/ If we have too many suggestions now, sort the list and keep\n\t    \/\/ the best suggestions.\n\t    if (gap->ga_len > SUG_MAX_COUNT(su))\n\t    {\n\t\tif (maxsf)\n\t\t    su->su_sfmaxscore = cleanup_suggestions(gap,\n\t\t\t\t      su->su_sfmaxscore, SUG_CLEAN_COUNT(su));\n\t\telse\n\t\t    su->su_maxscore = cleanup_suggestions(gap,\n\t\t\t\t\tsu->su_maxscore, SUG_CLEAN_COUNT(su));\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":1167,"total_token_length":1403,"max_tokens_setting":2048}
+{"idx":198282,"func":"void ReshapeSparseTensor(OpKernelContext *context,\n                         const Tensor &input_indices_in,\n                         const Tensor &input_shape_in,\n                         const Tensor &target_shape_in, int output_indices_idx,\n                         int output_shape_idx) {\n  OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices_in.shape()),\n              errors::InvalidArgument(\n                  \"Input indices should be a matrix but received shape \",\n                  input_indices_in.shape().DebugString()));\n  OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape_in.shape()),\n              errors::InvalidArgument(\n                  \"Input shape should be a vector but received shape \",\n                  input_shape_in.shape().DebugString()));\n  OP_REQUIRES(context, TensorShapeUtils::IsVector(target_shape_in.shape()),\n              errors::InvalidArgument(\n                  \"Target shape should be a vector but received shape \",\n                  target_shape_in.shape().DebugString()));\n\n  const int64_t output_rank = target_shape_in.NumElements();\n  const TensorShape input_shape(input_shape_in.vec<int64>());\n  const int64_t dense_size = input_shape.num_elements();\n  const int64_t nnz = input_indices_in.shape().dim_size(0);\n\n  \/\/ Compute the output shape. Determine product of specified dimensions, and\n  \/\/ find the index of the unspecified one.\n  TensorShape output_shape;\n  int64_t product = 1;\n  int unknown_index = -1;\n  auto target_shape = target_shape_in.vec<int64>();\n  for (int d = 0; d < output_rank; ++d) {\n    const int64_t size = target_shape(d);\n    if (size == -1) {\n      OP_REQUIRES(\n          context, unknown_index == -1,\n          errors::InvalidArgument(\"only one output dimension may be -1, \"\n                                  \"not both \",\n                                  unknown_index, \" and \", d));\n      unknown_index = d;\n      output_shape.AddDim(1);\n    } else {\n      OP_REQUIRES(context, size >= 0,\n                  errors::InvalidArgument(\"size \", d,\n                                          \" must be non-negative, not \", size));\n      product *= size;\n      output_shape.AddDim(size);\n    }\n  }\n  if (unknown_index != -1) {\n    OP_REQUIRES(\n        context, product > 0,\n        errors::InvalidArgument(\"reshape cannot infer the missing \"\n                                \"input size for an empty tensor unless all \"\n                                \"specified input sizes are non-zero\"));\n    const int64_t missing = dense_size \/ product;\n    OP_REQUIRES(\n        context, product * missing == dense_size,\n        errors::InvalidArgument(\n            \"Input to reshape is a SparseTensor with \", dense_size,\n            \" dense values, but the requested shape requires a multiple of \",\n            product, \". input_shape=\", input_shape.DebugString(),\n            \" output_shape=\", output_shape.DebugString()));\n    output_shape.set_dim(unknown_index, missing);\n  }\n\n  OP_REQUIRES(\n      context, output_shape.num_elements() == dense_size,\n      errors::InvalidArgument(\"Input to reshape is a tensor with \", dense_size,\n                              \" dense values, but the requested shape has \",\n                              output_shape.num_elements(),\n                              \". input_shape=\", input_shape.DebugString(),\n                              \" output_shape=\", output_shape.DebugString()));\n\n  \/\/ Optimize for reshaping to the same shape.\n  if (input_shape == output_shape) {\n    context->set_output(output_indices_idx, input_indices_in);\n    context->set_output(output_shape_idx, input_shape_in);\n    return;\n  }\n\n  Tensor *result_shape = nullptr;\n  OP_REQUIRES_OK(context, context->allocate_output(output_shape_idx,\n                                                   TensorShape({output_rank}),\n                                                   &result_shape));\n  auto output_shape_vec = result_shape->vec<int64>();\n  for (int j = 0; j < output_shape.dims(); ++j) {\n    output_shape_vec(j) = output_shape.dim_size(j);\n  }\n\n  Tensor *result_indices = nullptr;\n  OP_REQUIRES_OK(context,\n                 context->allocate_output(output_indices_idx,\n                                          TensorShape({nnz, output_rank}),\n                                          &result_indices));\n  if (nnz > 0) {\n    OP_REQUIRES_OK(context, functor::ReshapeSparseTensorFunctor<Device>()(\n                                context, input_shape, output_shape,\n                                input_indices_in.matrix<int64>(),\n                                result_indices->matrix<int64>()));\n  }\n}","target":1,"code_token_length":911,"total_token_length":1147,"max_tokens_setting":2048}
+{"idx":252317,"func":"static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr,\n                          size_t tmpBufSize, size_t inLen, int num_channels,\n                          const EXRChannelInfo *channels, int data_width,\n                          int num_lines) {\n  if (inLen == tmpBufSize) {\n    \/\/ Data is not compressed(Issue 40).\n    memcpy(outPtr, inPtr, inLen);\n    return true;\n  }\n\n  std::vector<unsigned char> bitmap(BITMAP_SIZE);\n  unsigned short minNonZero;\n  unsigned short maxNonZero;\n\n#if !MINIZ_LITTLE_ENDIAN\n  \/\/ @todo { PIZ compression on BigEndian architecture. }\n  assert(0);\n  return false;\n#endif\n\n  memset(bitmap.data(), 0, BITMAP_SIZE);\n\n  const unsigned char *ptr = inPtr;\n  \/\/ minNonZero = *(reinterpret_cast<const unsigned short *>(ptr));\n  tinyexr::cpy2(&minNonZero, reinterpret_cast<const unsigned short *>(ptr));\n  \/\/ maxNonZero = *(reinterpret_cast<const unsigned short *>(ptr + 2));\n  tinyexr::cpy2(&maxNonZero, reinterpret_cast<const unsigned short *>(ptr + 2));\n  ptr += 4;\n\n  if (maxNonZero >= BITMAP_SIZE) {\n    return false;\n  }\n\n  if (minNonZero <= maxNonZero) {\n    memcpy(reinterpret_cast<char *>(&bitmap[0] + minNonZero), ptr,\n           maxNonZero - minNonZero + 1);\n    ptr += maxNonZero - minNonZero + 1;\n  }\n\n  std::vector<unsigned short> lut(USHORT_RANGE);\n  memset(lut.data(), 0, sizeof(unsigned short) * USHORT_RANGE);\n  unsigned short maxValue = reverseLutFromBitmap(bitmap.data(), lut.data());\n\n  \/\/\n  \/\/ Huffman decoding\n  \/\/\n\n  int length;\n\n  \/\/ length = *(reinterpret_cast<const int *>(ptr));\n  tinyexr::cpy4(&length, reinterpret_cast<const int *>(ptr));\n  ptr += sizeof(int);\n\n  if (size_t((ptr - inPtr) + length) > inLen) {\n    return false;\n  }\n\n  std::vector<unsigned short> tmpBuffer(tmpBufSize);\n  hufUncompress(reinterpret_cast<const char *>(ptr), length, &tmpBuffer);\n\n  \/\/\n  \/\/ Wavelet decoding\n  \/\/\n\n  std::vector<PIZChannelData> channelData(static_cast<size_t>(num_channels));\n\n  unsigned short *tmpBufferEnd = &tmpBuffer.at(0);\n\n  for (size_t i = 0; i < static_cast<size_t>(num_channels); ++i) {\n    const EXRChannelInfo &chan = channels[i];\n\n    size_t pixelSize = sizeof(int);  \/\/ UINT and FLOAT\n    if (chan.pixel_type == TINYEXR_PIXELTYPE_HALF) {\n      pixelSize = sizeof(short);\n    }\n\n    channelData[i].start = tmpBufferEnd;\n    channelData[i].end = channelData[i].start;\n    channelData[i].nx = data_width;\n    channelData[i].ny = num_lines;\n    \/\/ channelData[i].ys = 1;\n    channelData[i].size = static_cast<int>(pixelSize \/ sizeof(short));\n\n    tmpBufferEnd += channelData[i].nx * channelData[i].ny * channelData[i].size;\n  }\n\n  for (size_t i = 0; i < channelData.size(); ++i) {\n    PIZChannelData &cd = channelData[i];\n\n    for (int j = 0; j < cd.size; ++j) {\n      wav2Decode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size,\n                 maxValue);\n    }\n  }\n\n  \/\/\n  \/\/ Expand the pixel data to their original range\n  \/\/\n\n  applyLut(lut.data(), &tmpBuffer.at(0), static_cast<int>(tmpBufSize));\n\n  for (int y = 0; y < num_lines; y++) {\n    for (size_t i = 0; i < channelData.size(); ++i) {\n      PIZChannelData &cd = channelData[i];\n\n      \/\/ if (modp (y, cd.ys) != 0)\n      \/\/    continue;\n\n      size_t n = static_cast<size_t>(cd.nx * cd.size);\n      memcpy(outPtr, cd.end, static_cast<size_t>(n * sizeof(unsigned short)));\n      outPtr += n * sizeof(unsigned short);\n      cd.end += n;\n    }\n  }\n\n  return true;\n}","target":0,"code_token_length":955,"total_token_length":1191,"max_tokens_setting":2048}
+{"idx":247122,"func":"void gf_fs_del(GF_FilterSession *fsess)\n{\n\tassert(fsess);\n\n\tgf_fs_stop(fsess);\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, (\"Session destroy begin\\n\"));\n\n\tif (fsess->parsed_args) {\n\t\twhile (gf_list_count(fsess->parsed_args)) {\n\t\t\tGF_FSArgItem *ai = gf_list_pop_back(fsess->parsed_args);\n\t\t\tgf_free(ai->argname);\n\t\t\tgf_free(ai);\n\t\t}\n\t\tgf_list_del(fsess->parsed_args);\n\t}\n\n\t\/\/temporary until we don't introduce fsess_stop\n\tassert(fsess->run_status != GF_OK);\n\tif (fsess->filters) {\n\t\tu32 i, count=gf_list_count(fsess->filters);\n\t\t\/\/first pass: disconnect all filters, since some may have references to property maps or packets \n\t\tfor (i=0; i<count; i++) {\n\t\t\tu32 j;\n\t\t\tGF_Filter *filter = gf_list_get(fsess->filters, i);\n\t\t\tfilter->process_th_id = 0;\n\t\t\tfilter->scheduled_for_next_task = GF_TRUE;\n\n\t\t\tif (filter->detached_pid_inst) {\n\t\t\t\twhile (gf_list_count(filter->detached_pid_inst)) {\n\t\t\t\t\tGF_FilterPidInst *pidi = gf_list_pop_front(filter->detached_pid_inst);\n\t\t\t\t\tgf_filter_pid_inst_del(pidi);\n\t\t\t\t}\n\t\t\t\tgf_list_del(filter->detached_pid_inst);\n\t\t\t\tfilter->detached_pid_inst = NULL;\n\t\t\t}\n\n\t\t\tif (filter->postponed_packets) {\n\t\t\t\twhile (gf_list_count(filter->postponed_packets)) {\n\t\t\t\t\tGF_FilterPacket *pck = gf_list_pop_front(filter->postponed_packets);\n\t\t\t\t\tgf_filter_packet_destroy(pck);\n\t\t\t\t}\n\t\t\t\tgf_list_del(filter->postponed_packets);\n\t\t\t\tfilter->postponed_packets = NULL;\n\t\t\t}\n\t\t\tgf_mx_p(filter->tasks_mx);\n\t\t\tfor (j=0; j<filter->num_input_pids; j++) {\n\t\t\t\tGF_FilterPidInst *pidi = gf_list_get(filter->input_pids, j);\n\t\t\t\tgf_filter_pid_inst_reset(pidi);\n\t\t\t}\n\t\t\tgf_mx_v(filter->tasks_mx);\n\t\t\tfilter->scheduled_for_next_task = GF_FALSE;\n\t\t}\n\t\t\/\/second pass, finalize all\n\t\tfor (i=0; i<count; i++) {\n\t\t\tGF_Filter *filter = gf_list_get(fsess->filters, i);\n\t\t\tif (filter->freg->finalize && !filter->finalized) {\n\t\t\t\tfilter->finalized = GF_TRUE;\n\t\t\t\tFSESS_CHECK_THREAD(filter)\n\t\t\t\tfilter->freg->finalize(filter);\n\t\t\t}\n\t\t}\n\n\t\twhile (gf_list_count(fsess->filters)) {\n\t\t\tGF_Filter *filter = gf_list_pop_back(fsess->filters);\n\n\t\t\tgf_filter_del(filter);\n\t\t}\n\t\tgf_list_del(fsess->filters);\n\t\tfsess->filters = NULL;\n\t}\n\n\tgf_fs_unload_script(fsess, NULL);\n\n\tif (fsess->download_manager) gf_dm_del(fsess->download_manager);\n#ifndef GPAC_DISABLE_PLAYER\n\tif (fsess->font_manager) gf_font_manager_del(fsess->font_manager);\n#endif\n\n\tif (fsess->registry) {\n\t\twhile (gf_list_count(fsess->registry)) {\n\t\t\tGF_FilterRegister *freg = gf_list_pop_back(fsess->registry);\n\t\t\tif (freg->register_free) freg->register_free(fsess, freg);\n\t\t}\n\t\tgf_list_del(fsess->registry);\n\t}\n\n\tif (fsess->tasks)\n\t\tgf_fq_del(fsess->tasks, gf_void_del);\n\n\tif (fsess->tasks_reservoir)\n\t\tgf_fq_del(fsess->tasks_reservoir, gf_void_del);\n\n\tif (fsess->threads) {\n\t\tif (fsess->main_thread_tasks)\n\t\t\tgf_fq_del(fsess->main_thread_tasks, gf_void_del);\n\n\t\twhile (gf_list_count(fsess->threads)) {\n\t\t\tGF_SessionThread *sess_th = gf_list_pop_back(fsess->threads);\n\t\t\tgf_th_del(sess_th->th);\n\t\t\tgf_free(sess_th);\n\t\t}\n\t\tgf_list_del(fsess->threads);\n\t}\n\n\tif (fsess->prop_maps_reservoir)\n\t\tgf_fq_del(fsess->prop_maps_reservoir, gf_propmap_del);\n#if GF_PROPS_HASHTABLE_SIZE\n\tif (fsess->prop_maps_list_reservoir)\n\t\tgf_fq_del(fsess->prop_maps_list_reservoir, (gf_destruct_fun) gf_list_del);\n#endif\n\tif (fsess->prop_maps_entry_reservoir)\n\t\tgf_fq_del(fsess->prop_maps_entry_reservoir, gf_void_del);\n\tif (fsess->prop_maps_entry_data_alloc_reservoir)\n\t\tgf_fq_del(fsess->prop_maps_entry_data_alloc_reservoir, gf_propalloc_del);\n\tif (fsess->pcks_refprops_reservoir)\n\t\tgf_fq_del(fsess->pcks_refprops_reservoir, gf_void_del);\n\n\n\tif (fsess->props_mx)\n\t\tgf_mx_del(fsess->props_mx);\n\n\tif (fsess->info_mx)\n\t\tgf_mx_del(fsess->info_mx);\n\n\tif (fsess->ui_mx)\n\t\tgf_mx_del(fsess->ui_mx);\n\n\tif (fsess->semaphore_other && (fsess->semaphore_other != fsess->semaphore_main) )\n\t\tgf_sema_del(fsess->semaphore_other);\n\n\tif (fsess->semaphore_main)\n\t\tgf_sema_del(fsess->semaphore_main);\n\n\tif (fsess->tasks_mx)\n\t\tgf_mx_del(fsess->tasks_mx);\n\n\tif (fsess->filters_mx)\n\t\tgf_mx_del(fsess->filters_mx);\n\n\tif (fsess->evt_mx) gf_mx_del(fsess->evt_mx);\n\tif (fsess->event_listeners) gf_list_del(fsess->event_listeners);\n\n\tif (fsess->links) {\n\t\tgf_filter_sess_reset_graph(fsess, NULL);\n\t\tgf_list_del(fsess->links);\n\t}\n\tif (fsess->links_mx) gf_mx_del(fsess->links_mx);\n\n#ifndef GPAC_DISABLE_3D\n\tgf_list_del(fsess->gl_providers);\n\tif (fsess->gl_driver) {\n\t\tfsess->gl_driver->Shutdown(fsess->gl_driver);\n\t\tgf_modules_close_interface((GF_BaseInterface *)fsess->gl_driver);\n\t}\n#endif\n\n\tif (fsess->auto_inc_nums) {\n\t\twhile(gf_list_count(fsess->auto_inc_nums)) {\n\t\t\tGF_FSAutoIncNum *aint = gf_list_pop_back(fsess->auto_inc_nums);\n\t\t\tgf_free(aint);\n\t\t}\n\t\tgf_list_del(fsess->auto_inc_nums);\n\t}\n\n#ifdef GF_FS_ENABLE_LOCALES\n\tif (fsess->uri_relocators) gf_list_del(fsess->uri_relocators);\n\tif (fsess->locales.szAbsRelocatedPath) gf_free(fsess->locales.szAbsRelocatedPath);\n#endif\n\n\tgf_free(fsess);\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, (\"Session destroyed\\n\"));\n}","target":0,"code_token_length":1536,"total_token_length":1772,"max_tokens_setting":2048}
+{"idx":513328,"func":"uint check_join_cache_usage(JOIN_TAB *tab,\n                            ulonglong options,\n                            uint no_jbuf_after,\n                            uint table_index,\n                            JOIN_TAB *prev_tab)\n{\n  Cost_estimate cost;\n  uint flags= 0;\n  ha_rows rows= 0;\n  uint bufsz= 4096;\n  JOIN_CACHE *prev_cache=0;\n  JOIN *join= tab->join;\n  MEM_ROOT *root= join->thd->mem_root;\n  uint cache_level= tab->used_join_cache_level;\n  bool force_unlinked_cache=\n         !(join->allowed_join_cache_types & JOIN_CACHE_INCREMENTAL_BIT);\n  bool no_hashed_cache=\n         !(join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT);\n  bool no_bka_cache= \n         !(join->allowed_join_cache_types & JOIN_CACHE_BKA_BIT);\n\n  join->return_tab= 0;\n\n  \/*\n    Don't use join cache if @@join_cache_level==0 or this table is the first\n    one join suborder (either at top level or inside a bush)\n  *\/\n  if (cache_level == 0 || !prev_tab)\n    return 0;\n\n  if (force_unlinked_cache && (cache_level%2 == 0))\n    cache_level--;\n\n  if (options & SELECT_NO_JOIN_CACHE)\n    goto no_join_cache;\n\n  if (tab->use_quick == 2)\n    goto no_join_cache;\n\n  if (tab->table->map & join->complex_firstmatch_tables)\n    goto no_join_cache;\n  \n  \/*\n    Don't use join cache if we're inside a join tab range covered by LooseScan\n    strategy (TODO: LooseScan is very similar to FirstMatch so theoretically it \n    should be possible to use join buffering in the same way we're using it for\n    multi-table firstmatch ranges).\n  *\/\n  if (tab->inside_loosescan_range)\n    goto no_join_cache;\n\n  if (tab->is_inner_table_of_semijoin() &&\n      !join->allowed_semijoin_with_cache)\n    goto no_join_cache;\n  if (tab->is_inner_table_of_outer_join() &&\n      !join->allowed_outer_join_with_cache)\n    goto no_join_cache;\n\n  \/*\n    Non-linked join buffers can't guarantee one match\n  *\/\n  if (tab->is_nested_inner())\n  {\n    if (force_unlinked_cache || cache_level == 1)\n      goto no_join_cache;\n    if (cache_level & 1)\n      cache_level--;\n  }\n    \n  \/*\n    Don't use BKA for materialized tables. We could actually have a\n    meaningful use of BKA when linked join buffers are used.\n\n    The problem is, the temp.table is not filled (actually not even opened\n    properly) yet, and this doesn't let us call\n    handler->multi_range_read_info(). It is possible to come up with\n    estimates, etc. without acessing the table, but it seems not to worth the\n    effort now.\n  *\/\n  if (tab->table->pos_in_table_list->is_materialized_derived())\n  {\n    no_bka_cache= true;\n    \/*\n      Don't use hash join algorithm if the temporary table for the rows\n      of the derived table will be created with an equi-join key.\n    *\/\n    if (tab->table->s->keys)\n      no_hashed_cache= true;\n  }\n\n  \/*\n    Don't use join buffering if we're dictated not to by no_jbuf_after\n    (This is not meaningfully used currently)\n  *\/\n  if (table_index > no_jbuf_after)\n    goto no_join_cache;\n  \n  \/*\n    TODO: BNL join buffer should be perfectly ok with tab->bush_children.\n  *\/\n  if (tab->loosescan_match_tab || tab->bush_children)\n    goto no_join_cache;\n\n  for (JOIN_TAB *first_inner= tab->first_inner; first_inner;\n       first_inner= first_inner->first_upper)\n  {\n    if (first_inner != tab && \n        (!first_inner->use_join_cache || !(tab-1)->use_join_cache))\n      goto no_join_cache;\n  }\n  if (tab->first_sj_inner_tab && tab->first_sj_inner_tab != tab &&\n      (!tab->first_sj_inner_tab->use_join_cache || !(tab-1)->use_join_cache))\n    goto no_join_cache;\n  if (!prev_tab->use_join_cache)\n  {\n    \/* \n      Check whether table tab and the previous one belong to the same nest of\n      inner tables and if so do not use join buffer when joining table tab. \n    *\/\n    if (tab->first_inner && tab != tab->first_inner)\n    {\n      for (JOIN_TAB *first_inner= tab[-1].first_inner;\n           first_inner;\n           first_inner= first_inner->first_upper)\n      {\n        if (first_inner == tab->first_inner)\n          goto no_join_cache;\n      }\n    }\n    else if (tab->first_sj_inner_tab && tab != tab->first_sj_inner_tab &&\n             tab->first_sj_inner_tab == tab[-1].first_sj_inner_tab)\n      goto no_join_cache; \n  }       \n\n  prev_cache= prev_tab->cache;\n\n  switch (tab->type) {\n  case JT_ALL:\n    if (cache_level == 1)\n      prev_cache= 0;\n    if ((tab->cache= new (root) JOIN_CACHE_BNL(join, tab, prev_cache)))\n    {\n      tab->icp_other_tables_ok= FALSE;\n      return (2 - MY_TEST(!prev_cache));\n    }\n    goto no_join_cache;\n  case JT_SYSTEM:\n  case JT_CONST:\n  case JT_REF:\n  case JT_EQ_REF:\n    if (cache_level <=2 || (no_hashed_cache && no_bka_cache))\n      goto no_join_cache;\n    if (tab->ref.is_access_triggered())\n      goto no_join_cache;\n\n    if (!tab->is_ref_for_hash_join() && !no_bka_cache)\n    {\n      flags= HA_MRR_NO_NULL_ENDPOINTS | HA_MRR_SINGLE_POINT;\n      if (tab->table->covering_keys.is_set(tab->ref.key))\n        flags|= HA_MRR_INDEX_ONLY;\n      rows= tab->table->file->multi_range_read_info(tab->ref.key, 10, 20,\n                                                    tab->ref.key_parts,\n                                                    &bufsz, &flags, &cost);\n    }\n\n    if ((cache_level <=4 && !no_hashed_cache) || no_bka_cache ||\n        tab->is_ref_for_hash_join() ||\n\t((flags & HA_MRR_NO_ASSOCIATION) && cache_level <=6))\n    {\n      if (!tab->hash_join_is_possible() ||\n          tab->make_scan_filter())\n        goto no_join_cache;\n      if (cache_level == 3)\n        prev_cache= 0;\n      if ((tab->cache= new (root) JOIN_CACHE_BNLH(join, tab, prev_cache)))\n      {\n        tab->icp_other_tables_ok= FALSE;        \n        return (4 - MY_TEST(!prev_cache));\n      }\n      goto no_join_cache;\n    }\n    if (cache_level > 4 && no_bka_cache)\n      goto no_join_cache;\n    \n    if ((flags & HA_MRR_NO_ASSOCIATION) &&\n\t(cache_level <= 6 || no_hashed_cache))\n      goto no_join_cache;\n\n    if ((rows != HA_POS_ERROR) && !(flags & HA_MRR_USE_DEFAULT_IMPL))\n    {\n      if (cache_level <= 6 || no_hashed_cache)\n      {\n        if (cache_level == 5)\n          prev_cache= 0;\n        if ((tab->cache= new (root) JOIN_CACHE_BKA(join, tab, flags, prev_cache)))\n          return (6 - MY_TEST(!prev_cache));\n        goto no_join_cache;\n      }\n      else\n      {\n        if (cache_level == 7)\n          prev_cache= 0;\n        if ((tab->cache= new (root) JOIN_CACHE_BKAH(join, tab, flags, prev_cache)))\n\t{\n          tab->idx_cond_fact_out= FALSE;\n          return (8 - MY_TEST(!prev_cache));\n        }\n        goto no_join_cache;\n      }\n    }\n    goto no_join_cache;\n  default : ;\n  }\n\nno_join_cache:\n  if (tab->type != JT_ALL && tab->is_ref_for_hash_join())\n  {\n    tab->type= JT_ALL;\n    tab->ref.key_parts= 0;\n  }\n  revise_cache_usage(tab); \n  return 0;\n}","target":0,"code_token_length":1806,"total_token_length":2042,"max_tokens_setting":2048}
+{"idx":230143,"func":"json_t * user_auth_scheme_module_trigger(struct config_module * config, const struct _u_request * http_request, const char * username, json_t * j_scheme_trigger, void * cls) {\n  UNUSED(j_scheme_trigger);\n  json_t * j_return = NULL, * j_session = config->glewlwyd_module_callback_check_user_session(config, http_request, username), * j_credential, * j_assertion, * j_user_id, * j_credential_fake;\n  unsigned char user_id_fake[64];\n\n  if (check_result_value(j_session, G_OK) || json_object_get((json_t *)cls, \"session-mandatory\") == json_false()) {\n    j_credential_fake = generate_credential_fake_list((json_t *)cls, username);\n    if (check_result_value(j_credential_fake, G_OK)) {\n      j_user_id = get_user_id_from_username(config, (json_t *)cls, username, 0);\n      if (check_result_value(j_user_id, G_OK)) {\n        j_credential = get_credential_list(config, (json_t *)cls, username, 1);\n        if (check_result_value(j_credential, G_OK)) {\n          j_assertion = generate_new_assertion(config, (json_t *)cls, username, 0);\n          if (check_result_value(j_assertion, G_OK)) {\n            j_return = json_pack(\"{sis{sOsOsOs{sOss}sOsssi}}\",\n                                \"result\", G_OK,\n                                \"response\",\n                                  \"allowCredentials\", json_object_get(j_credential, \"credential\"),\n                                  \"session\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"session\"),\n                                  \"challenge\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"challenge\"),\n                                  \"user\",\n                                    \"id\", json_object_get(j_user_id, \"user_id\"),\n                                    \"name\", username,\n                                  \"rpId\", json_object_get((json_t *)cls, \"rp-origin\"),\n                                  \"attestation-required\", json_object_get((json_t *)cls, \"force-fmt-none\")==json_true()?\"none\":\"direct\",\n                                  \"timeout\", 60000\n                                );\n            if (json_object_get((json_t *)cls, \"session-mandatory\") == json_false()) {\n              json_array_extend(json_object_get(json_object_get(j_return, \"response\"), \"allowCredentials\"), json_object_get(j_credential_fake, \"credential\"));\n            }\n          } else if (check_result_value(j_assertion, G_ERROR_UNAUTHORIZED)) {\n            j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error register_new_assertion\");\n            j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n          }\n          json_decref(j_assertion);\n        } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n          if (json_object_get((json_t *)cls, \"session-mandatory\") == json_false()) {\n            j_assertion = generate_new_assertion(config, (json_t *)cls, username, 2);\n            if (check_result_value(j_assertion, G_OK)) {\n              j_return = json_pack(\"{sis{sOsOsOs{sOss}sO}}\",\n                                  \"result\", G_OK,\n                                  \"response\",\n                                    \"allowCredentials\", json_object_get(j_credential_fake, \"credential\"),\n                                    \"session\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"session\"),\n                                    \"challenge\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"challenge\"),\n                                    \"user\",\n                                      \"id\", json_object_get(j_user_id, \"user_id\"),\n                                      \"name\", username,\n                                    \"rpId\", json_object_get((json_t *)cls, \"rp-origin\")\n                                  );\n            } else {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error register_new_assertion\");\n              j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n            }\n            json_decref(j_assertion);\n          } else {\n            j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n          }\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error get_credential_list\");\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n        }\n        json_decref(j_credential);\n      } else if (check_result_value(j_user_id, G_ERROR_NOT_FOUND)) {\n        if (json_object_get((json_t *)cls, \"session-mandatory\") == json_false()) {\n          if (generate_fake_user_id((json_t *)cls, username, user_id_fake) == G_OK) {\n            j_assertion = generate_new_assertion(config, (json_t *)cls, username, 2);\n            if (check_result_value(j_assertion, G_OK)) {\n              j_return = json_pack(\"{sis{sOsOsOs{ssss}sO}}\",\n                                  \"result\", G_OK,\n                                  \"response\",\n                                    \"allowCredentials\", json_object_get(j_credential_fake, \"credential\"),\n                                    \"session\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"session\"),\n                                    \"challenge\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"challenge\"),\n                                    \"user\",\n                                      \"id\", user_id_fake,\n                                      \"name\", username,\n                                    \"rpId\", json_object_get((json_t *)cls, \"rp-origin\")\n                                  );\n            } else {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error register_new_assertion\");\n              j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n            }\n            json_decref(j_assertion);\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error generate_fake_user_id\");\n            j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n          }\n        } else {\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n        }\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_user_id_from_username\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n      json_decref(j_user_id);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error generate_credential_fake\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_credential_fake);\n  } else if (check_result_value(j_session, G_ERROR_UNAUTHORIZED)) {\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error glewlwyd_module_callback_check_user_session\");\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n  }\n  json_decref(j_session);\n  return j_return;\n}","target":0,"code_token_length":1505,"total_token_length":1741,"max_tokens_setting":2048}
+{"idx":314533,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_parse( pj_pool_t *pool,\n\t\t\t\t       char *buf, pj_size_t len, \n\t\t\t\t       pjmedia_sdp_session **p_sdp)\n{\n    pj_scanner scanner;\n    pjmedia_sdp_session *session;\n    pjmedia_sdp_media *media = NULL;\n    pjmedia_sdp_attr *attr;\n    pjmedia_sdp_conn *conn;\n    pjmedia_sdp_bandw *bandw;\n    pj_str_t dummy;\n    int cur_name = 254;\n    volatile parse_context ctx;\n    PJ_USE_EXCEPTION;\n\n    ctx.last_error = PJ_SUCCESS;\n\n    init_sdp_parser();\n\n    pj_scan_init(&scanner, buf, len, 0, &on_scanner_error);\n    session = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session);\n    PJ_ASSERT_RETURN(session != NULL, PJ_ENOMEM);\n\n    \/* Ignore leading newlines *\/\n    while (*scanner.curptr=='\\r' || *scanner.curptr=='\\n')\n\tpj_scan_get_char(&scanner);\n\n    PJ_TRY {\n\twhile (!pj_scan_is_eof(&scanner)) {\n\t\tcur_name = *scanner.curptr;\n\t\tswitch (cur_name) {\n\t\tcase 'a':\n\t\t    attr = parse_attr(pool, &scanner, &ctx);\n\t\t    if (attr) {\n\t\t\tif (media) {\n\t\t\t    if (media->attr_count < PJMEDIA_MAX_SDP_ATTR)\n\t\t\t\tpjmedia_sdp_media_add_attr(media, attr);\n\t\t\t    else\n\t\t\t\tPJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,\n\t\t\t\t\t      \"Error adding media attribute, \"\n\t\t\t\t\t      \"attribute is ignored\"));\n\t\t\t} else {\n\t\t\t    if (session->attr_count < PJMEDIA_MAX_SDP_ATTR)\n\t\t\t\tpjmedia_sdp_session_add_attr(session, attr);\n\t\t\t    else\n\t\t\t\tPJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,\n\t\t\t\t\t      \"Error adding session attribute\"\n\t\t\t\t\t      \", attribute is ignored\"));\n\t\t\t}\n\t\t    }\n\t\t    break;\n\t\tcase 'o':\n\t\t    parse_origin(&scanner, session, &ctx);\n\t\t    break;\n\t\tcase 's':\n\t\t    parse_generic_line(&scanner, &session->name, &ctx);\n\t\t    break;\n\t\tcase 'c':\n\t\t    conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn);\n\t\t    parse_connection_info(&scanner, conn, &ctx);\n\t\t    if (media) {\n\t\t\tmedia->conn = conn;\n\t\t    } else {\n\t\t\tsession->conn = conn;\n\t\t    }\n\t\t    break;\n\t\tcase 't':\n\t\t    parse_time(&scanner, session, &ctx);\n\t\t    break;\n\t\tcase 'm':\n\t\t    media = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);\n\t\t    parse_media(&scanner, media, &ctx);\n\t\t    if (session->media_count < PJMEDIA_MAX_SDP_MEDIA)\n\t\t\tsession->media[ session->media_count++ ] = media;\n\t\t    else\n\t\t\tPJ_PERROR(2,(THIS_FILE, PJ_ETOOMANY,\n\t\t\t\t     \"Error adding media, media is ignored\"));\n\t\t    break;\n\t\tcase 'v':\n\t\t    parse_version(&scanner, &ctx);\n\t\t    break;\n\t\tcase 13:\n\t\tcase 10:\n\t\t    pj_scan_get_char(&scanner);\n\t\t    \/* Allow empty newlines at the end of the message *\/\n\t\t    while (!pj_scan_is_eof(&scanner)) {\n\t\t\tif (*scanner.curptr != 13 && *scanner.curptr != 10) {\n\t\t\t    ctx.last_error = PJMEDIA_SDP_EINSDP;\n\t\t\t    on_scanner_error(&scanner);\n\t\t\t}\n\t\t\tpj_scan_get_char(&scanner);\n\t\t    }\n\t\t    break;\n\t\tcase 'b':\n\t\t    bandw = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_bandw);\n\t\t    parse_bandwidth_info(&scanner, bandw, &ctx);\n\t\t    if (media) {\n\t\t\tif (media->bandw_count < PJMEDIA_MAX_SDP_BANDW)\n\t\t\t    media->bandw[media->bandw_count++] = bandw;\n\t\t\telse\n\t\t\t    PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,\n\t\t\t\t\t  \"Error adding media bandwidth \"\n\t\t\t\t\t  \"info, info is ignored\"));\n\t\t    } else {\n\t\t\tif (session->bandw_count < PJMEDIA_MAX_SDP_BANDW)\n\t\t\t    session->bandw[session->bandw_count++] = bandw;\n\t\t\telse\n\t\t\t    PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,\n\t\t\t\t\t  \"Error adding session bandwidth \"\n\t\t\t\t\t  \"info, info is ignored\"));\n\t\t    }\n\t\t    break;\n\t\tdefault:\n\t\t    if (cur_name >= 'a' && cur_name <= 'z')\n\t\t\tparse_generic_line(&scanner, &dummy, &ctx);\n\t\t    else  {\n\t\t\tctx.last_error = PJMEDIA_SDP_EINSDP;\n\t\t\ton_scanner_error(&scanner);\n\t\t    }\n\t\t    break;\n\t\t}\n\t}\n\n\tctx.last_error = PJ_SUCCESS;\n\n    }\n    PJ_CATCH_ANY {\t\t\n\tPJ_PERROR(4, (THIS_FILE, ctx.last_error,\n\t\t      \"Error parsing SDP in line %d col %d\",\n\t\t      scanner.line, pj_scan_get_col(&scanner)));\n\n\tsession = NULL;\n\n\tpj_assert(ctx.last_error != PJ_SUCCESS);\n    }\n    PJ_END;\n\n    pj_scan_fini(&scanner);\n\n    if (session)\n\tapply_media_direction(session);\n\n    *p_sdp = session;\n    return ctx.last_error;\n}","target":0,"code_token_length":1118,"total_token_length":1354,"max_tokens_setting":2048}
+{"idx":205838,"func":"get_one_sourceline(source_cookie_T *sp)\n{\n    garray_T\t\tga;\n    int\t\t\tlen;\n    int\t\t\tc;\n    char_u\t\t*buf;\n#ifdef USE_CRNL\n    int\t\t\thas_cr;\t\t\/\/ CR-LF found\n#endif\n    int\t\t\thave_read = FALSE;\n\n    \/\/ use a growarray to store the sourced line\n    ga_init2(&ga, 1, 250);\n\n    \/\/ Loop until there is a finished line (or end-of-file).\n    ++sp->sourcing_lnum;\n    for (;;)\n    {\n\t\/\/ make room to read at least 120 (more) characters\n\tif (ga_grow(&ga, 120) == FAIL)\n\t    break;\n\tif (sp->source_from_buf)\n\t{\n\t    if (sp->buf_lnum >= sp->buflines.ga_len)\n\t\tbreak;\t\t    \/\/ all the lines are processed\n\t    ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);\n\t    sp->buf_lnum++;\n\t    buf = (char_u *)ga.ga_data;\n\t}\n\telse\n\t{\n\t    buf = (char_u *)ga.ga_data;\n\t    if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,\n\t\t\tsp->fp) == NULL)\n\t\tbreak;\n\t}\n\tlen = ga.ga_len + (int)STRLEN(buf + ga.ga_len);\n#ifdef USE_CRNL\n\t\/\/ Ignore a trailing CTRL-Z, when in Dos mode.\tOnly recognize the\n\t\/\/ CTRL-Z by its own, or after a NL.\n\tif (\t   (len == 1 || (len >= 2 && buf[len - 2] == '\\n'))\n\t\t&& sp->fileformat == EOL_DOS\n\t\t&& buf[len - 1] == Ctrl_Z)\n\t{\n\t    buf[len - 1] = NUL;\n\t    break;\n\t}\n#endif\n\n\thave_read = TRUE;\n\tga.ga_len = len;\n\n\t\/\/ If the line was longer than the buffer, read more.\n\tif (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\\n')\n\t    continue;\n\n\tif (len >= 1 && buf[len - 1] == '\\n')\t\/\/ remove trailing NL\n\t{\n#ifdef USE_CRNL\n\t    has_cr = (len >= 2 && buf[len - 2] == '\\r');\n\t    if (sp->fileformat == EOL_UNKNOWN)\n\t    {\n\t\tif (has_cr)\n\t\t    sp->fileformat = EOL_DOS;\n\t\telse\n\t\t    sp->fileformat = EOL_UNIX;\n\t    }\n\n\t    if (sp->fileformat == EOL_DOS)\n\t    {\n\t\tif (has_cr)\t    \/\/ replace trailing CR\n\t\t{\n\t\t    buf[len - 2] = '\\n';\n\t\t    --len;\n\t\t    --ga.ga_len;\n\t\t}\n\t\telse\t    \/\/ lines like \":map xx yy^M\" will have failed\n\t\t{\n\t\t    if (!sp->error)\n\t\t    {\n\t\t\tmsg_source(HL_ATTR(HLF_W));\n\t\t\temsg(_(\"W15: Warning: Wrong line separator, ^M may be missing\"));\n\t\t    }\n\t\t    sp->error = TRUE;\n\t\t    sp->fileformat = EOL_UNIX;\n\t\t}\n\t    }\n#endif\n\t    \/\/ The '\\n' is escaped if there is an odd number of ^V's just\n\t    \/\/ before it, first set \"c\" just before the 'V's and then check\n\t    \/\/ len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo\n\t    for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--)\n\t\t;\n\t    if ((len & 1) != (c & 1))\t\/\/ escaped NL, read more\n\t    {\n\t\t++sp->sourcing_lnum;\n\t\tcontinue;\n\t    }\n\n\t    buf[len - 1] = NUL;\t\t\/\/ remove the NL\n\t}\n\n\t\/\/ Check for ^C here now and then, so recursive :so can be broken.\n\tline_breakcheck();\n\tbreak;\n    }\n\n    if (have_read)\n\treturn (char_u *)ga.ga_data;\n\n    vim_free(ga.ga_data);\n    return NULL;\n}","target":1,"code_token_length":914,"total_token_length":1150,"max_tokens_setting":2048}
+{"idx":218992,"func":"Status ConstantFolding::FoldMergeNode(NodeDef* node, GraphDef* output_graph) {\n  \/\/ Merge nodes are special, in the sense that they execute as soon as one of\n  \/\/ their input is ready. We can therefore fold a merge node iff it has at\n  \/\/ least one constant input without control dependency.\n  \/\/ We still need to ensure that the nodes in the fanin of the merge node are\n  \/\/ scheduled. We'll therefore add a control dependency from the merge node\n  \/\/ to the folded constant. We end up with:\n  \/\/  * the merge node and its inputs are preserved as is\n  \/\/  * a new constant node C1, driven by the merge node through a control\n  \/\/  dependency, initialized to the value of the folded input\n  \/\/  * a new constant node C2, driven by the merge node through a control\n  \/\/  dependency, initialized to the index of the folded input\n  \/\/  * the fanout of the merge nodes is rewired to be driven by either C1 or\n  \/\/  C2.\n  for (int input_index = 0; input_index < node->input_size(); ++input_index) {\n    const auto& input = node->input(input_index);\n    if (IsControlInput(input)) {\n      \/\/ Try the next input.\n      continue;\n    }\n    NodeDef* input_node = node_map_->GetNode(input);\n    if (!IsReallyConstant(*input_node)) {\n      continue;\n    }\n    bool valid_input = true;\n    for (const string& fanin_of_input : input_node->input()) {\n      if (IsControlInput(fanin_of_input)) {\n        valid_input = false;\n        break;\n      }\n    }\n    if (!valid_input) {\n      \/\/ Try the next input\n      continue;\n    }\n\n    string const_out_name = OptimizedNodeName(*node, \"_const\");\n    string const_index_name = OptimizedNodeName(*node, \"_index\");\n    if (node_map_->GetNode(const_out_name) ||\n        node_map_->GetNode(const_index_name)) {\n      \/\/ Intended name already exists.\n      return errors::AlreadyExists(\n          strings::StrCat(const_out_name, \" or \", const_index_name,\n                          \" already present in the graph\"));\n    }\n\n    NodeDef* const_out = output_graph->add_node();\n    *const_out = *input_node;\n    const_out->set_name(const_out_name);\n    const_out->set_device(node->device());\n    *const_out->add_input() = AsControlDependency(*node);\n    node_map_->AddNode(const_out->name(), const_out);\n    node_map_->AddOutput(node->name(), const_out->name());\n\n    NodeDef* const_index = output_graph->add_node();\n    const_index->set_op(\"Const\");\n    Tensor index(DT_INT32, TensorShape({}));\n    index.flat<int32>()(0) = input_index;\n    (*const_index->mutable_attr())[\"dtype\"].set_type(DT_INT32);\n    index.AsProtoTensorContent(\n        (*const_index->mutable_attr())[\"value\"].mutable_tensor());\n    const_index->set_name(const_index_name);\n    const_index->set_device(node->device());\n    *const_index->add_input() = AsControlDependency(*node);\n    node_map_->AddNode(const_index->name(), const_index);\n    node_map_->AddOutput(node->name(), const_index->name());\n\n    \/\/ We make a copy because we mutate the nodes.\n    auto outputs = node_map_->GetOutputs(node->name());\n    for (NodeDef* output : outputs) {\n      for (int i = 0; i < output->input_size(); i++) {\n        int port;\n        string node_name = ParseNodeName(output->input(i), &port);\n        if (node_name == node->name()) {\n          if (port == 0) {\n            *output->mutable_input(i) = const_out->name();\n            node_map_->AddOutput(const_out->name(), output->name());\n          } else if (port == 1) {\n            *output->mutable_input(i) = const_index->name();\n            node_map_->AddOutput(const_index->name(), output->name());\n          } else {\n            \/\/ This is a control dependency (or an invalid edge since the\n            \/\/ merge node has only 2 outputs): preserve them.\n          }\n        }\n      }\n    }\n    return Status::OK();\n  }\n  return Status::OK();\n}","target":0,"code_token_length":938,"total_token_length":1174,"max_tokens_setting":2048}
+{"idx":353002,"func":"serialNumberAndIssuerSerialNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *in,\n\tstruct berval *out,\n\tvoid *ctx )\n{\n\tstruct berval i, ni = BER_BVNULL,\n\t\tsn, sn2 = BER_BVNULL, sn3 = BER_BVNULL,\n\t\ti_sn, i_sn2 = BER_BVNULL, i_sn3 = BER_BVNULL;\n\tchar sbuf2[SLAP_SN_BUFLEN], i_sbuf2[SLAP_SN_BUFLEN],\n\t\tsbuf3[SLAP_SN_BUFLEN], i_sbuf3[SLAP_SN_BUFLEN];\n\tchar *p;\n\tint rc;\n\n\tassert( in != NULL );\n\tassert( out != NULL );\n\n\tDebug( LDAP_DEBUG_TRACE, \">>> serialNumberAndIssuerSerialNormalize: <%s>\\n\",\n\t\tin->bv_val );\n\n\trc = serialNumberAndIssuerSerialCheck( in, &sn, &i, &i_sn, ctx );\n\tif ( rc ) {\n\t\tgoto func_leave;\n\t}\n\n\trc = dnNormalize( usage, syntax, mr, &i, &ni, ctx );\n\n\tif ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) {\n\t\tslap_sl_free( i.bv_val, ctx );\n\t}\n\n\tif ( rc ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto func_leave;\n\t}\n\n\t\/* Convert sn to canonical hex *\/\n\tsn2.bv_val = sbuf2;\n\tsn2.bv_len = sn.bv_len;\n\tif ( sn.bv_len > sizeof( sbuf2 ) ) {\n\t\tsn2.bv_val = slap_sl_malloc( sn.bv_len, ctx );\n\t}\n\tif ( lutil_str2bin( &sn, &sn2, ctx ) ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto func_leave;\n\t}\n\n        \/* Convert i_sn to canonical hex *\/\n\ti_sn2.bv_val = i_sbuf2;\n\ti_sn2.bv_len = i_sn.bv_len;\n\tif ( i_sn.bv_len > sizeof( i_sbuf2 ) ) {\n\t\ti_sn2.bv_val = slap_sl_malloc( i_sn.bv_len, ctx );\n\t}\n\tif ( lutil_str2bin( &i_sn, &i_sn2, ctx ) ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto func_leave;\n\t}\n\n\tsn3.bv_val = sbuf3;\n\tsn3.bv_len = sizeof(sbuf3);\n\tif ( slap_bin2hex( &sn2, &sn3, ctx ) ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto func_leave;\n\t}\n\n\ti_sn3.bv_val = i_sbuf3;\n\ti_sn3.bv_len = sizeof(i_sbuf3);\n\tif ( slap_bin2hex( &i_sn2, &i_sn3, ctx ) ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto func_leave;\n\t}\n\n\tout->bv_len = STRLENOF(\"{ serialNumber , issuer { baseCertificateID { issuer { directoryName:rdnSequence:\\\"\\\" }, serial  } } }\")\n\t\t+ sn3.bv_len + ni.bv_len + i_sn3.bv_len;\n\tout->bv_val = slap_sl_malloc( out->bv_len + 1, ctx );\n\n\tif ( out->bv_val == NULL ) {\n\t\tout->bv_len = 0;\n\t\trc = LDAP_OTHER;\n\t\tgoto func_leave;\n\t}\n\n\tp = out->bv_val;\n\n\tp = lutil_strcopy( p, \"{ serialNumber \" );\n\tp = lutil_strbvcopy( p, &sn3 );\n\tp = lutil_strcopy( p, \", issuer { baseCertificateID { issuer { directoryName:rdnSequence:\\\"\" );\n\tp = lutil_strbvcopy( p, &ni );\n\tp = lutil_strcopy( p, \"\\\" }, serial \" );\n\tp = lutil_strbvcopy( p, &i_sn3 );\n\tp = lutil_strcopy( p, \" } } }\" );\n\n\tassert( p == &out->bv_val[out->bv_len] );\n\nfunc_leave:\n\tDebug( LDAP_DEBUG_TRACE, \"<<< serialNumberAndIssuerSerialNormalize: <%s> => <%s>\\n\",\n\t\tin->bv_val, rc == LDAP_SUCCESS ? out->bv_val : \"(err)\" );\n\n\tif ( sn2.bv_val != sbuf2 ) {\n\t\tslap_sl_free( sn2.bv_val, ctx );\n\t}\n\n\tif ( i_sn2.bv_val != i_sbuf2 ) {\n\t\tslap_sl_free( i_sn2.bv_val, ctx );\n\t}\n\n\tif ( sn3.bv_val != sbuf3 ) {\n\t\tslap_sl_free( sn3.bv_val, ctx );\n\t}\n\n\tif ( i_sn3.bv_val != i_sbuf3 ) {\n\t\tslap_sl_free( i_sn3.bv_val, ctx );\n\t}\n\n\tslap_sl_free( ni.bv_val, ctx );\n\n\treturn rc;\n}","target":0,"code_token_length":1054,"total_token_length":1290,"max_tokens_setting":2048}
+{"idx":390542,"func":"_XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,\n                 xkbSetCompatMapReq *req, char* data, BOOL dryRun)\n{\n    XkbSrvInfoPtr       xkbi;\n    XkbDescPtr          xkb;\n    XkbCompatMapPtr     compat;\n    int                 nGroups;\n    unsigned            i,bit;\n\n    xkbi = dev->key->xkbInfo;\n    xkb = xkbi->desc;\n    compat = xkb->compat;\n\n    if ((req->nSI>0)||(req->truncateSI)) {\n\txkbSymInterpretWireDesc *wire;\n\tif (req->firstSI>compat->num_si) {\n\t    client->errorValue = _XkbErrCode2(0x02,compat->num_si);\n\t    return BadValue;\n\t}\n\twire= (xkbSymInterpretWireDesc *)data;\n\twire+= req->nSI;\n\tdata = (char *)wire;\n    }\n\n    nGroups= 0;\n    if (req->groups!=0) {\n\tfor (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {\n\t    if ( req->groups&bit )\n\t\tnGroups++;\n\t}\n    }\n    data+= nGroups*SIZEOF(xkbModsWireDesc);\n    if (((data-((char *)req))\/4)!=req->length) {\n\treturn BadLength;\n    }\n\n    \/* Done all the checks we can do *\/\n    if (dryRun)\n        return Success;\n\n    data = (char *)&req[1];\n    if (req->nSI>0) {\n\txkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *)data;\n\tXkbSymInterpretPtr\tsym;\n\tif ((unsigned)(req->firstSI+req->nSI)>compat->num_si) {\n\t    compat->num_si= req->firstSI+req->nSI;\n\t    compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,\n\t\t\t\t\t\t   compat->num_si,\n\t\t\t\t\t\t   XkbSymInterpretRec);\n\t    if (!compat->sym_interpret) {\n\t\tcompat->num_si= 0;\n\t\treturn BadAlloc;\n\t    }\n\t}\n\telse if (req->truncateSI) {\n\t    compat->num_si = req->firstSI+req->nSI;\n\t}\n\tsym = &compat->sym_interpret[req->firstSI];\n\tfor (i=0;i<req->nSI;i++,wire++,sym++) {\n\t    if (client->swapped) {\n\t\tint n;\n\t\tswapl(&wire->sym,n);\n\t    }\n\t    sym->sym= wire->sym;\n\t    sym->mods= wire->mods;\n\t    sym->match= wire->match;\n\t    sym->flags= wire->flags;\n\t    sym->virtual_mod= wire->virtualMod;\n\t    memcpy((char *)&sym->act,(char *)&wire->act,\n                   SIZEOF(xkbActionWireDesc));\n\t}\n\tdata = (char *)wire;\n    }\n    else if (req->truncateSI) {\n\tcompat->num_si = req->firstSI;\n    }\n\n    if (req->groups!=0) {\n\tunsigned i, bit;\n\txkbModsWireDesc *wire = (xkbModsWireDesc *)data;\n\tfor (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {\n\t    if (req->groups & bit) {\n\t\tif (client->swapped) {\n\t\t    int n;\n\t\t    swaps(&wire->virtualMods,n);\n\t\t}\n\t\tcompat->groups[i].mask= wire->realMods;\n\t\tcompat->groups[i].real_mods= wire->realMods;\n\t\tcompat->groups[i].vmods= wire->virtualMods;\n\t\tif (wire->virtualMods!=0) {\n\t\t    unsigned tmp;\n\t\t    tmp= XkbMaskForVMask(xkb,wire->virtualMods);\n\t\t    compat->groups[i].mask|= tmp;\n\t\t}\n\t\tdata+= SIZEOF(xkbModsWireDesc);\n\t\twire= (xkbModsWireDesc *)data;\n\t    }\n\t}\n    }\n    i= XkbPaddedSize((data-((char *)req)));\n    if ((i\/4)!=req->length) {\n\tErrorF(\"[xkb] Internal length error on read in _XkbSetCompatMap\\n\");\n\treturn BadLength;\n    }\n\n    if (dev->xkb_interest) {\n\txkbCompatMapNotify ev;\n\tev.deviceID = dev->id;\n\tev.changedGroups = req->groups;\n\tev.firstSI = req->firstSI;\n\tev.nSI = req->nSI;\n\tev.nTotalSI = compat->num_si;\n\tXkbSendCompatMapNotify(dev,&ev);\n    }\n\n    if (req->recomputeActions) {\n\tXkbChangesRec\t\tchange;\n\tunsigned\t\tcheck;\n\tXkbEventCauseRec\tcause;\n\n\tXkbSetCauseXkbReq(&cause,X_kbSetCompatMap,client);\n\tbzero(&change,sizeof(XkbChangesRec));\n\tXkbUpdateActions(dev,xkb->min_key_code,XkbNumKeys(xkb),&change,&check,\n\t\t\t\t\t\t\t\t\t&cause);\n\tif (check)\n\t    XkbCheckSecondaryEffects(xkbi,check,&change,&cause);\n\tXkbUpdateCoreDescription(dev,False);\n\tXkbSendNotification(dev,&change,&cause);\n    }\n    return Success;\n}","target":0,"code_token_length":1132,"total_token_length":1368,"max_tokens_setting":2048}
+{"idx":221497,"func":"regenerate_ld_cache (GPtrArray    *base_argv_array,\n                     GArray       *base_fd_array,\n                     GFile        *app_id_dir,\n                     const char   *checksum,\n                     GFile        *runtime_files,\n                     gboolean      generate_ld_so_conf,\n                     GCancellable *cancellable,\n                     GError      **error)\n{\n  g_autoptr(FlatpakBwrap) bwrap = NULL;\n  g_autoptr(GArray) combined_fd_array = NULL;\n  g_autoptr(GFile) ld_so_cache = NULL;\n  g_autoptr(GFile) ld_so_cache_tmp = NULL;\n  g_autofree char *sandbox_cache_path = NULL;\n  g_autofree char *tmp_basename = NULL;\n  g_auto(GStrv) minimal_envp = NULL;\n  g_autofree char *commandline = NULL;\n  int exit_status;\n  glnx_autofd int ld_so_fd = -1;\n  g_autoptr(GFile) ld_so_dir = NULL;\n\n  if (app_id_dir)\n    ld_so_dir = g_file_get_child (app_id_dir, \".ld.so\");\n  else\n    {\n      g_autoptr(GFile) base_dir = g_file_new_for_path (g_get_user_cache_dir ());\n      ld_so_dir = g_file_resolve_relative_path (base_dir, \"flatpak\/ld.so\");\n    }\n\n  ld_so_cache = g_file_get_child (ld_so_dir, checksum);\n  ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache), O_RDONLY);\n  if (ld_so_fd >= 0)\n    return glnx_steal_fd (&ld_so_fd);\n\n  g_debug (\"Regenerating ld.so.cache %s\", flatpak_file_get_path_cached (ld_so_cache));\n\n  if (!flatpak_mkdir_p (ld_so_dir, cancellable, error))\n    return FALSE;\n\n  minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE);\n  bwrap = flatpak_bwrap_new (minimal_envp);\n\n  flatpak_bwrap_append_args (bwrap, base_argv_array);\n\n  flatpak_run_setup_usr_links (bwrap, runtime_files, NULL);\n\n  if (generate_ld_so_conf)\n    {\n      if (!add_ld_so_conf (bwrap, error))\n        return -1;\n    }\n  else\n    flatpak_bwrap_add_args (bwrap,\n                            \"--symlink\", \"..\/usr\/etc\/ld.so.conf\", \"\/etc\/ld.so.conf\",\n                            NULL);\n\n  tmp_basename = g_strconcat (checksum, \".XXXXXX\", NULL);\n  glnx_gen_temp_name (tmp_basename);\n\n  sandbox_cache_path = g_build_filename (\"\/run\/ld-so-cache-dir\", tmp_basename, NULL);\n  ld_so_cache_tmp = g_file_get_child (ld_so_dir, tmp_basename);\n\n  flatpak_bwrap_add_args (bwrap,\n                          \"--unshare-pid\",\n                          \"--unshare-ipc\",\n                          \"--unshare-net\",\n                          \"--proc\", \"\/proc\",\n                          \"--dev\", \"\/dev\",\n                          \"--bind\", flatpak_file_get_path_cached (ld_so_dir), \"\/run\/ld-so-cache-dir\",\n                          NULL);\n  flatpak_bwrap_sort_envp (bwrap);\n  flatpak_bwrap_envp_to_args (bwrap);\n\n  if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error))\n    return -1;\n\n  flatpak_bwrap_add_args (bwrap,\n                          \"ldconfig\", \"-X\", \"-C\", sandbox_cache_path, NULL);\n\n  flatpak_bwrap_finish (bwrap);\n\n  commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1);\n  g_debug (\"Running: '%s'\", commandline);\n\n  combined_fd_array = g_array_new (FALSE, TRUE, sizeof (int));\n  g_array_append_vals (combined_fd_array, base_fd_array->data, base_fd_array->len);\n  g_array_append_vals (combined_fd_array, bwrap->fds->data, bwrap->fds->len);\n\n  \/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_fds_workaround *\/\n  if (!g_spawn_sync (NULL,\n                     (char **) bwrap->argv->pdata,\n                     bwrap->envp,\n                     G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN,\n                     flatpak_bwrap_child_setup_cb, combined_fd_array,\n                     NULL, NULL,\n                     &exit_status,\n                     error))\n    return -1;\n\n  if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status) != 0)\n    {\n      flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED,\n                          _(\"ldconfig failed, exit status %d\"), exit_status);\n      return -1;\n    }\n\n  ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache_tmp), O_RDONLY);\n  if (ld_so_fd < 0)\n    {\n      flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Can't open generated ld.so.cache\"));\n      return -1;\n    }\n\n  if (app_id_dir == NULL)\n    {\n      \/* For runs without an app id dir we always regenerate the ld.so.cache *\/\n      unlink (flatpak_file_get_path_cached (ld_so_cache_tmp));\n    }\n  else\n    {\n      g_autoptr(GFile) active = g_file_get_child (ld_so_dir, \"active\");\n\n      \/* For app-dirs we keep one checksum alive, by pointing the active symlink to it *\/\n\n      \/* Rename to known name, possibly overwriting existing ref if race *\/\n      if (rename (flatpak_file_get_path_cached (ld_so_cache_tmp), flatpak_file_get_path_cached (ld_so_cache)) == -1)\n        {\n          glnx_set_error_from_errno (error);\n          return -1;\n        }\n\n      if (!flatpak_switch_symlink_and_remove (flatpak_file_get_path_cached (active),\n                                              checksum, error))\n        return -1;\n    }\n\n  return glnx_steal_fd (&ld_so_fd);\n}","target":0,"code_token_length":1281,"total_token_length":1517,"max_tokens_setting":2048}
+{"idx":312563,"func":"vgr_process_files(\n\twin_T\t\t*wp,\n\tqf_info_T\t*qi,\n\tvgr_args_T\t*cmd_args,\n\tint\t\t*redraw_for_dummy,\n\tbuf_T\t\t**first_match_buf,\n\tchar_u\t\t**target_dir)\n{\n    int\t\tstatus = FAIL;\n    int_u\tsave_qfid = qf_get_curlist(qi)->qf_id;\n    time_t\tseconds = 0;\n    char_u\t*fname;\n    int\t\tfi;\n    buf_T\t*buf;\n    int\t\tduplicate_name = FALSE;\n    int\t\tusing_dummy;\n    char_u\t*dirname_start = NULL;\n    char_u\t*dirname_now = NULL;\n    int\t\tfound_match;\n    aco_save_T\taco;\n\n    dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start);\n    dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now);\n    if (dirname_start == NULL || dirname_now == NULL)\n\tgoto theend;\n\n    \/\/ Remember the current directory, because a BufRead autocommand that does\n    \/\/ \":lcd %:p:h\" changes the meaning of short path names.\n    mch_dirname(dirname_start, MAXPATHL);\n\n    seconds = (time_t)0;\n    for (fi = 0; fi < cmd_args->fcount && !got_int && cmd_args->tomatch > 0;\n\t\t\t\t\t\t\t\t\t++fi)\n    {\n\tfname = shorten_fname1(cmd_args->fnames[fi]);\n\tif (time(NULL) > seconds)\n\t{\n\t    \/\/ Display the file name every second or so, show the user we are\n\t    \/\/ working on it.\n\t    seconds = time(NULL);\n\t    vgr_display_fname(fname);\n\t}\n\n\tbuf = buflist_findname_exp(cmd_args->fnames[fi]);\n\tif (buf == NULL || buf->b_ml.ml_mfp == NULL)\n\t{\n\t    \/\/ Remember that a buffer with this name already exists.\n\t    duplicate_name = (buf != NULL);\n\t    using_dummy = TRUE;\n\t    *redraw_for_dummy = TRUE;\n\n\t    buf = vgr_load_dummy_buf(fname, dirname_start, dirname_now);\n\t}\n\telse\n\t    \/\/ Use existing, loaded buffer.\n\t    using_dummy = FALSE;\n\n\t\/\/ Check whether the quickfix list is still valid. When loading a\n\t\/\/ buffer above, autocommands might have changed the quickfix list.\n\tif (!vgr_qflist_valid(wp, qi, save_qfid, cmd_args->qf_title))\n\t    goto theend;\n\n\tsave_qfid = qf_get_curlist(qi)->qf_id;\n\n\tif (buf == NULL)\n\t{\n\t    if (!got_int)\n\t\tsmsg(_(\"Cannot open file \\\"%s\\\"\"), fname);\n\t}\n\telse\n\t{\n\t    \/\/ Try for a match in all lines of the buffer.\n\t    \/\/ For \":1vimgrep\" look for first match only.\n\t    found_match = vgr_match_buflines(qf_get_curlist(qi),\n\t\t    fname, buf, cmd_args->spat, &cmd_args->regmatch,\n\t\t    &cmd_args->tomatch, duplicate_name, cmd_args->flags);\n\n\t    if (using_dummy)\n\t    {\n\t\tif (found_match && *first_match_buf == NULL)\n\t\t    *first_match_buf = buf;\n\t\tif (duplicate_name)\n\t\t{\n\t\t    \/\/ Never keep a dummy buffer if there is another buffer\n\t\t    \/\/ with the same name.\n\t\t    wipe_dummy_buffer(buf, dirname_start);\n\t\t    buf = NULL;\n\t\t}\n\t\telse if ((cmdmod.cmod_flags & CMOD_HIDE) == 0\n\t\t\t    || buf->b_p_bh[0] == 'u'\t\/\/ \"unload\"\n\t\t\t    || buf->b_p_bh[0] == 'w'\t\/\/ \"wipe\"\n\t\t\t    || buf->b_p_bh[0] == 'd')\t\/\/ \"delete\"\n\t\t{\n\t\t    \/\/ When no match was found we don't need to remember the\n\t\t    \/\/ buffer, wipe it out.  If there was a match and it\n\t\t    \/\/ wasn't the first one or we won't jump there: only\n\t\t    \/\/ unload the buffer.\n\t\t    \/\/ Ignore 'hidden' here, because it may lead to having too\n\t\t    \/\/ many swap files.\n\t\t    if (!found_match)\n\t\t    {\n\t\t\twipe_dummy_buffer(buf, dirname_start);\n\t\t\tbuf = NULL;\n\t\t    }\n\t\t    else if (buf != *first_match_buf\n\t\t\t\t\t|| (cmd_args->flags & VGR_NOJUMP)\n\t\t\t\t\t|| existing_swapfile(buf))\n\t\t    {\n\t\t\tunload_dummy_buffer(buf, dirname_start);\n\t\t\t\/\/ Keeping the buffer, remove the dummy flag.\n\t\t\tbuf->b_flags &= ~BF_DUMMY;\n\t\t\tbuf = NULL;\n\t\t    }\n\t\t}\n\n\t\tif (buf != NULL)\n\t\t{\n\t\t    \/\/ Keeping the buffer, remove the dummy flag.\n\t\t    buf->b_flags &= ~BF_DUMMY;\n\n\t\t    \/\/ If the buffer is still loaded we need to use the\n\t\t    \/\/ directory we jumped to below.\n\t\t    if (buf == *first_match_buf\n\t\t\t    && *target_dir == NULL\n\t\t\t    && STRCMP(dirname_start, dirname_now) != 0)\n\t\t\t*target_dir = vim_strsave(dirname_now);\n\n\t\t    \/\/ The buffer is still loaded, the Filetype autocommands\n\t\t    \/\/ need to be done now, in that buffer.  And the modelines\n\t\t    \/\/ need to be done (again).  But not the window-local\n\t\t    \/\/ options!\n\t\t    aucmd_prepbuf(&aco, buf);\n#if defined(FEAT_SYN_HL)\n\t\t    apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,\n\t\t\t\t\t\t     buf->b_fname, TRUE, buf);\n#endif\n\t\t    do_modelines(OPT_NOWIN);\n\t\t    aucmd_restbuf(&aco);\n\t\t}\n\t    }\n\t}\n    }\n\n    status = OK;\n\ntheend:\n    vim_free(dirname_now);\n    vim_free(dirname_start);\n    return status;\n}","target":0,"code_token_length":1244,"total_token_length":1480,"max_tokens_setting":2048}
+{"idx":197621,"func":"  void Compute(OpKernelContext* const context) override {\n    \/\/ node_id_range\n    const Tensor* node_id_range_t;\n    OP_REQUIRES_OK(context, context->input(\"node_id_range\", &node_id_range_t));\n    const auto node_id_range = node_id_range_t->vec<int32>();\n    const int32_t node_id_first = node_id_range(0);  \/\/ inclusive\n    const int32_t node_id_last = node_id_range(1);   \/\/ exclusive\n\n    const Tensor* stats_summary_indices_t;\n    OP_REQUIRES_OK(context, context->input(\"stats_summary_indices\",\n                                           &stats_summary_indices_t));\n    const auto stats_summary_indices = stats_summary_indices_t->matrix<int32>();\n    const int32_t num_sparse_entries = stats_summary_indices_t->dim_size(0);\n\n    const Tensor* stats_summary_values_t;\n    OP_REQUIRES_OK(context, context->input(\"stats_summary_values\",\n                                           &stats_summary_values_t));\n    const auto stats_summary_values = stats_summary_values_t->vec<float>();\n\n    const Tensor* stats_summary_shape_t;\n    OP_REQUIRES_OK(\n        context, context->input(\"stats_summary_shape\", &stats_summary_shape_t));\n    const auto stats_summary_shape = stats_summary_shape_t->vec<int32>();\n    const int32_t num_buckets = stats_summary_shape(2) - 1;\n    const int32_t stats_dims = stats_summary_shape(3);\n\n    const Tensor* l1_t;\n    OP_REQUIRES_OK(context, context->input(\"l1\", &l1_t));\n    const auto l1 = l1_t->scalar<float>()();\n\n    const Tensor* l2_t;\n    OP_REQUIRES_OK(context, context->input(\"l2\", &l2_t));\n    const auto l2 = l2_t->scalar<float>()();\n\n    const Tensor* tree_complexity_t;\n    OP_REQUIRES_OK(context,\n                   context->input(\"tree_complexity\", &tree_complexity_t));\n    const auto tree_complexity = tree_complexity_t->scalar<float>()();\n\n    const Tensor* min_node_weight_t;\n    OP_REQUIRES_OK(context,\n                   context->input(\"min_node_weight\", &min_node_weight_t));\n    const auto min_node_weight = min_node_weight_t->scalar<float>()();\n\n    std::vector<int32> output_node_ids;\n    std::vector<float> output_gains;\n    std::vector<int32> output_feature_dimensions;\n    std::vector<int32> output_thresholds;\n    std::vector<float> output_left_node_contribs;\n    std::vector<float> output_right_node_contribs;\n    std::vector<string> output_split_types;\n\n    FeatureMap f_map;\n\n    int32_t previous_node_id = -1;\n    for (int idx = 0; idx < num_sparse_entries; ++idx) {\n      int32_t node_id = stats_summary_indices(idx, 0);\n      if (node_id != previous_node_id) {\n        process_node(f_map, &output_node_ids, &output_gains,\n                     &output_feature_dimensions, &output_thresholds,\n                     &output_left_node_contribs, &output_right_node_contribs,\n                     &output_split_types, previous_node_id, min_node_weight, l1,\n                     l2, num_buckets);\n        f_map.clear();\n      }\n      previous_node_id = node_id;\n      DCHECK_LE(node_id_first, node_id);\n      DCHECK_LT(node_id, node_id_last);\n      const int32_t feature_dim = stats_summary_indices(idx, 1);\n      const int32_t bucket_id = stats_summary_indices(idx, 2);\n      const int32_t stat_dim = stats_summary_indices(idx, 3);\n      std::pair<FeatureMapIterator, bool> const& f_insert_result = f_map.insert(\n          FeatureMapIterator::value_type(feature_dim, BucketMap()));\n      auto& b_map = f_insert_result.first->second;\n      std::pair<BucketMapIterator, bool> const& b_insert_result =\n          b_map.insert(BucketMapIterator::value_type(\n              bucket_id, std::vector<float>(stats_dims)));\n      auto& stats = b_insert_result.first->second;\n      stats[stat_dim] = stats_summary_values(idx);\n    }  \/\/ for node_id\n    \/\/ process the last node id\n    process_node(f_map, &output_node_ids, &output_gains,\n                 &output_feature_dimensions, &output_thresholds,\n                 &output_left_node_contribs, &output_right_node_contribs,\n                 &output_split_types, previous_node_id, min_node_weight, l1, l2,\n                 num_buckets);\n\n    const int num_nodes = output_node_ids.size();\n    \/\/ output_node_ids\n    Tensor* output_node_ids_t = nullptr;\n    OP_REQUIRES_OK(context, context->allocate_output(\"node_ids\", {num_nodes},\n                                                     &output_node_ids_t));\n    auto output_node_ids_vec = output_node_ids_t->vec<int32>();\n\n    \/\/ output_gains\n    Tensor* output_gains_t;\n    OP_REQUIRES_OK(context, context->allocate_output(\"gains\", {num_nodes},\n                                                     &output_gains_t));\n    auto output_gains_vec = output_gains_t->vec<float>();\n\n    \/\/ output_feature_dimensions\n    Tensor* output_feature_dimension_t;\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(\"feature_dimensions\", {num_nodes},\n                                            &output_feature_dimension_t));\n    auto output_feature_dimensions_vec =\n        output_feature_dimension_t->vec<int32>();\n\n    \/\/ output_thresholds\n    Tensor* output_thresholds_t;\n    OP_REQUIRES_OK(context, context->allocate_output(\"thresholds\", {num_nodes},\n                                                     &output_thresholds_t));\n    auto output_thresholds_vec = output_thresholds_t->vec<int32>();\n\n    \/\/ output_left_node_contribs\n    Tensor* output_left_node_contribs_t;\n    OP_REQUIRES_OK(\n        context, context->allocate_output(\"left_node_contribs\", {num_nodes, 1},\n                                          &output_left_node_contribs_t));\n    auto output_left_node_contribs_matrix =\n        output_left_node_contribs_t->matrix<float>();\n\n    \/\/ output_right_node_contribs\n    Tensor* output_right_node_contribs_t;\n    OP_REQUIRES_OK(\n        context, context->allocate_output(\"right_node_contribs\", {num_nodes, 1},\n                                          &output_right_node_contribs_t));\n    auto output_right_node_contribs_matrix =\n        output_right_node_contribs_t->matrix<float>();\n\n    \/\/ split type\n    Tensor* output_split_types_t;\n    OP_REQUIRES_OK(\n        context, context->allocate_output(\"split_with_default_directions\",\n                                          {num_nodes}, &output_split_types_t));\n    auto output_split_types_vec = output_split_types_t->vec<tstring>();\n\n    \/\/ Sets output tensors from vectors.\n    for (int i = 0; i < num_nodes; ++i) {\n      output_node_ids_vec(i) = output_node_ids[i];\n      \/\/ Adjust the gains to penalize by tree complexity.\n      output_gains_vec(i) = output_gains[i] - tree_complexity;\n      output_feature_dimensions_vec(i) = output_feature_dimensions[i];\n      output_thresholds_vec(i) = output_thresholds[i];\n      \/\/ TODO(crawles): change this for multi-class.\n      output_left_node_contribs_matrix(i, 0) = output_left_node_contribs[i];\n      output_right_node_contribs_matrix(i, 0) = output_right_node_contribs[i];\n      output_split_types_vec(i) = output_split_types[i];\n    }\n  }","target":1,"code_token_length":1580,"total_token_length":1816,"max_tokens_setting":2048}
+{"idx":333545,"func":"int gdTransformAffineCopy(gdImagePtr dst,\n\t\t  int dst_x, int dst_y,\n\t\t  const gdImagePtr src,\n\t\t  gdRectPtr src_region,\n\t\t  const double affine[6])\n{\n\tint c1x,c1y,c2x,c2y;\n\tint backclip = 0;\n\tint backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2;\n\tregister int x, y, src_offset_x, src_offset_y;\n\tdouble inv[6];\n\tint *dst_p;\n\tgdPointF pt, src_pt;\n\tgdRect bbox;\n\tint end_x, end_y;\n\tgdInterpolationMethod interpolation_id_bak = GD_DEFAULT;\n\tinterpolation_method interpolation_bak;\n\n\t\/* These methods use special implementations *\/\n\tif (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) {\n\t\tinterpolation_id_bak = src->interpolation_id;\n\t\tinterpolation_bak = src->interpolation;\n\n\t\tgdImageSetInterpolationMethod(src, GD_BICUBIC);\n\t}\n\n\n\tgdImageClipRectangle(src, src_region);\n\n\tif (src_region->x > 0 || src_region->y > 0\n\t\t|| src_region->width < gdImageSX(src)\n\t\t|| src_region->height < gdImageSY(src)) {\n\t\tbackclip = 1;\n\n\t\tgdImageGetClip(src, &backup_clipx1, &backup_clipy1,\n\t\t&backup_clipx2, &backup_clipy2);\n\n\t\tgdImageSetClip(src, src_region->x, src_region->y,\n\t\t\tsrc_region->x + src_region->width - 1,\n\t\t\tsrc_region->y + src_region->height - 1);\n\t}\n\n\tif (!gdTransformAffineBoundingBox(src_region, affine, &bbox)) {\n\t\tif (backclip) {\n\t\t\tgdImageSetClip(src, backup_clipx1, backup_clipy1,\n\t\t\t\t\tbackup_clipx2, backup_clipy2);\n\t\t}\n\t\tgdImageSetInterpolationMethod(src, interpolation_id_bak);\n\t\treturn GD_FALSE;\n\t}\n\n\tgdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y);\n\n\tend_x = bbox.width  + (int) fabs(bbox.x);\n\tend_y = bbox.height + (int) fabs(bbox.y);\n\n\t\/* Get inverse affine to let us work with destination -> source *\/\n\tgdAffineInvert(inv, affine);\n\n\tsrc_offset_x =  src_region->x;\n\tsrc_offset_y =  src_region->y;\n\n\tif (dst->alphaBlendingFlag) {\n\t\tfor (y = bbox.y; y <= end_y; y++) {\n\t\t\tpt.y = y + 0.5;\n\t\t\tfor (x = 0; x <= end_x; x++) {\n\t\t\t\tpt.x = x + 0.5;\n\t\t\t\tgdAffineApplyToPointF(&src_pt, &pt, inv);\n\t\t\t\tgdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, 0));\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (y = 0; y <= end_y; y++) {\n\t\t\tpt.y = y + 0.5 + bbox.y;\n\t\t\tif ((dst_y + y) < 0 || ((dst_y + y) > gdImageSY(dst) -1)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdst_p = dst->tpixels[dst_y + y] + dst_x;\n\n\t\t\tfor (x = 0; x <= end_x; x++) {\n\t\t\t\tpt.x = x + 0.5 + bbox.x;\n\t\t\t\tgdAffineApplyToPointF(&src_pt, &pt, inv);\n\n\t\t\t\tif ((dst_x + x) < 0 || (dst_x + x) > (gdImageSX(dst) - 1)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t*(dst_p++) = getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, -1);\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Restore clip if required *\/\n\tif (backclip) {\n\t\tgdImageSetClip(src, backup_clipx1, backup_clipy1,\n\t\t\t\tbackup_clipx2, backup_clipy2);\n\t}\n\n\tgdImageSetInterpolationMethod(src, interpolation_id_bak);\n\treturn GD_TRUE;\n}","target":0,"code_token_length":965,"total_token_length":1201,"max_tokens_setting":2048}
+{"idx":237818,"func":"static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)\n{\n    data_t *data;\n    uint8_t *b;\n    int row;\n    int sensor_id;  \/\/ the sensor ID - basically a random number that gets reset whenever the battery is removed\n    int battery_ok; \/\/ the battery status: 1 is good, 0 is low\n    int channel;\n    int humidity;\n    int temp_raw; \/\/ temperature as read from the data packet\n    float temp_c; \/\/ temperature in C\n\n    row = bitbuffer_find_repeated_row(bitbuffer, 3, 25); \/\/ expected are min 3 rows\n    if (row < 0)\n        return DECODE_ABORT_EARLY;\n\n    if (bitbuffer->bits_per_row[row] > 25)\n        return DECODE_ABORT_LENGTH;\n\n    b = bitbuffer->bb[row];\n\n    if (b[4] != 0) \/\/ last byte should be zero\n        return DECODE_FAIL_SANITY;\n\n    \/\/ reject all blank messages\n    if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0)\n        return DECODE_FAIL_SANITY;\n\n    \/\/ parity check: odd parity on bits [0 .. 10]\n    \/\/ i.e. 8 bytes and another 2 bits.\n    uint8_t parity = b[0]; \/\/ parity as byte\n    parity = (parity >> 4) ^ (parity & 0xF); \/\/ fold to nibble\n    parity = (parity >> 2) ^ (parity & 0x3); \/\/ fold to 2 bits\n    parity ^= b[1] >> 6; \/\/ add remaining bits\n    parity = (parity >> 1) ^ (parity & 0x1); \/\/ fold to 1 bit\n\n    if (!parity) {\n        decoder_log(decoder, 1, __func__, \"parity check failed\");\n        return DECODE_FAIL_MIC;\n    }\n\n    \/\/ Processing the temperature:\n    \/\/ Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2\n    \/\/ upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)\n    sensor_id = b[0] & 0xFE; \/\/first 6 bits and it changes each time it resets or change the battery\n    battery_ok = (b[0] & 0x01); \/\/1=ok, 0=low battery\n    \/\/next 2 bits are checksum\n    \/\/next two bits are identify ID (maybe channel ?)\n    channel = (b[1] >> 4) & 0x03;\n\n    temp_raw = (int16_t)(((b[1] & 0x0F) << 12) | (b[2] << 4));\n    temp_raw = temp_raw >> 4;\n    temp_c   = (temp_raw - 500) * 0.1f; \/\/ NOTE: there seems to be a 50 degree offset?\n\n    if (temp_raw >= 0 && temp_raw <= 100) \/\/ NOTE: no other way to differentiate humidity from temperature?\n        humidity = temp_raw;\n    else\n        humidity = -1;\n\n    \/* clang-format off *\/\n     data = data_make(\n            \"model\",            \"\",             DATA_STRING, \"Acurite-590TX\",\n            \"id\",               \"\",             DATA_INT,    sensor_id,\n            \"battery_ok\",       \"Battery\",      DATA_INT,    battery_ok,\n            \"channel\",          \"Channel\",      DATA_INT,    channel,\n            \"humidity\",         \"Humidity\",     DATA_COND,   humidity != -1,    DATA_INT,    humidity,\n            \"temperature_C\",    \"Temperature\",  DATA_COND,   humidity == -1,    DATA_FORMAT, \"%.1f C\", DATA_DOUBLE, temp_c,\n            \"mic\",              \"Integrity\",    DATA_STRING, \"PARITY\",\n            NULL);\n    \/* clang-format on *\/\n\n    decoder_output_data(decoder, data);\n    return 1;\n}","target":0,"code_token_length":893,"total_token_length":1129,"max_tokens_setting":2048}
+{"idx":326090,"func":"bt_regexec_both(\n    char_u\t*line,\n    colnr_T\tcol,\t\t\/\/ column to start looking for match\n    proftime_T\t*tm,\t\t\/\/ timeout limit or NULL\n    int\t\t*timed_out)\t\/\/ flag set on timeout or NULL\n{\n    bt_regprog_T    *prog;\n    char_u\t    *s;\n    long\t    retval = 0L;\n\n    \/\/ Create \"regstack\" and \"backpos\" if they are not allocated yet.\n    \/\/ We allocate *_INITIAL amount of bytes first and then set the grow size\n    \/\/ to much bigger value to avoid many malloc calls in case of deep regular\n    \/\/ expressions.\n    if (regstack.ga_data == NULL)\n    {\n\t\/\/ Use an item size of 1 byte, since we push different things\n\t\/\/ onto the regstack.\n\tga_init2(®stack, 1, REGSTACK_INITIAL);\n\t(void)ga_grow(®stack, REGSTACK_INITIAL);\n\tregstack.ga_growsize = REGSTACK_INITIAL * 8;\n    }\n\n    if (backpos.ga_data == NULL)\n    {\n\tga_init2(&backpos, sizeof(backpos_T), BACKPOS_INITIAL);\n\t(void)ga_grow(&backpos, BACKPOS_INITIAL);\n\tbackpos.ga_growsize = BACKPOS_INITIAL * 8;\n    }\n\n    if (REG_MULTI)\n    {\n\tprog = (bt_regprog_T *)rex.reg_mmatch->regprog;\n\tline = reg_getline((linenr_T)0);\n\trex.reg_startpos = rex.reg_mmatch->startpos;\n\trex.reg_endpos = rex.reg_mmatch->endpos;\n    }\n    else\n    {\n\tprog = (bt_regprog_T *)rex.reg_match->regprog;\n\trex.reg_startp = rex.reg_match->startp;\n\trex.reg_endp = rex.reg_match->endp;\n    }\n\n    \/\/ Be paranoid...\n    if (prog == NULL || line == NULL)\n    {\n\tiemsg(_(e_null_argument));\n\tgoto theend;\n    }\n\n    \/\/ Check validity of program.\n    if (prog_magic_wrong())\n\tgoto theend;\n\n    \/\/ If the start column is past the maximum column: no need to try.\n    if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol)\n\tgoto theend;\n\n    \/\/ If pattern contains \"\\c\" or \"\\C\": overrule value of rex.reg_ic\n    if (prog->regflags & RF_ICASE)\n\trex.reg_ic = TRUE;\n    else if (prog->regflags & RF_NOICASE)\n\trex.reg_ic = FALSE;\n\n    \/\/ If pattern contains \"\\Z\" overrule value of rex.reg_icombine\n    if (prog->regflags & RF_ICOMBINE)\n\trex.reg_icombine = TRUE;\n\n    \/\/ If there is a \"must appear\" string, look for it.\n    if (prog->regmust != NULL)\n    {\n\tint c;\n\n\tif (has_mbyte)\n\t    c = (*mb_ptr2char)(prog->regmust);\n\telse\n\t    c = *prog->regmust;\n\ts = line + col;\n\n\t\/\/ This is used very often, esp. for \":global\".  Use three versions of\n\t\/\/ the loop to avoid overhead of conditions.\n\tif (!rex.reg_ic && !has_mbyte)\n\t    while ((s = vim_strbyte(s, c)) != NULL)\n\t    {\n\t\tif (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)\n\t\t    break;\t\t\/\/ Found it.\n\t\t++s;\n\t    }\n\telse if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1))\n\t    while ((s = vim_strchr(s, c)) != NULL)\n\t    {\n\t\tif (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)\n\t\t    break;\t\t\/\/ Found it.\n\t\tMB_PTR_ADV(s);\n\t    }\n\telse\n\t    while ((s = cstrchr(s, c)) != NULL)\n\t    {\n\t\tif (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)\n\t\t    break;\t\t\/\/ Found it.\n\t\tMB_PTR_ADV(s);\n\t    }\n\tif (s == NULL)\t\t\/\/ Not present.\n\t    goto theend;\n    }\n\n    rex.line = line;\n    rex.lnum = 0;\n    reg_toolong = FALSE;\n\n    \/\/ Simplest case: Anchored match need be tried only once.\n    if (prog->reganch)\n    {\n\tint\tc;\n\n\tif (has_mbyte)\n\t    c = (*mb_ptr2char)(rex.line + col);\n\telse\n\t    c = rex.line[col];\n\tif (prog->regstart == NUL\n\t\t|| prog->regstart == c\n\t\t|| (rex.reg_ic\n\t\t    && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))\n\t\t\t|| (c < 255 && prog->regstart < 255 &&\n\t\t\t    MB_TOLOWER(prog->regstart) == MB_TOLOWER(c)))))\n\t    retval = regtry(prog, col, tm, timed_out);\n\telse\n\t    retval = 0;\n    }\n    else\n    {\n#ifdef FEAT_RELTIME\n\tint tm_count = 0;\n#endif\n\t\/\/ Messy cases:  unanchored match.\n\twhile (!got_int)\n\t{\n\t    if (prog->regstart != NUL)\n\t    {\n\t\t\/\/ Skip until the char we know it must start with.\n\t\t\/\/ Used often, do some work to avoid call overhead.\n\t\tif (!rex.reg_ic && !has_mbyte)\n\t\t    s = vim_strbyte(rex.line + col, prog->regstart);\n\t\telse\n\t\t    s = cstrchr(rex.line + col, prog->regstart);\n\t\tif (s == NULL)\n\t\t{\n\t\t    retval = 0;\n\t\t    break;\n\t\t}\n\t\tcol = (int)(s - rex.line);\n\t    }\n\n\t    \/\/ Check for maximum column to try.\n\t    if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol)\n\t    {\n\t\tretval = 0;\n\t\tbreak;\n\t    }\n\n\t    retval = regtry(prog, col, tm, timed_out);\n\t    if (retval > 0)\n\t\tbreak;\n\n\t    \/\/ if not currently on the first line, get it again\n\t    if (rex.lnum != 0)\n\t    {\n\t\trex.lnum = 0;\n\t\trex.line = reg_getline((linenr_T)0);\n\t    }\n\t    if (rex.line[col] == NUL)\n\t\tbreak;\n\t    if (has_mbyte)\n\t\tcol += (*mb_ptr2len)(rex.line + col);\n\t    else\n\t\t++col;\n#ifdef FEAT_RELTIME\n\t    \/\/ Check for timeout once in a twenty times to avoid overhead.\n\t    if (tm != NULL && ++tm_count == 20)\n\t    {\n\t\ttm_count = 0;\n\t\tif (profile_passed_limit(tm))\n\t\t{\n\t\t    if (timed_out != NULL)\n\t\t\t*timed_out = TRUE;\n\t\t    break;\n\t\t}\n\t    }\n#endif\n\t}\n    }\n\ntheend:\n    \/\/ Free \"reg_tofree\" when it's a bit big.\n    \/\/ Free regstack and backpos if they are bigger than their initial size.\n    if (reg_tofreelen > 400)\n\tVIM_CLEAR(reg_tofree);\n    if (regstack.ga_maxlen > REGSTACK_INITIAL)\n\tga_clear(®stack);\n    if (backpos.ga_maxlen > BACKPOS_INITIAL)\n\tga_clear(&backpos);\n\n    if (retval > 0)\n    {\n\t\/\/ Make sure the end is never before the start.  Can happen when \\zs\n\t\/\/ and \\ze are used.\n\tif (REG_MULTI)\n\t{\n\t    lpos_T *start = &rex.reg_mmatch->startpos[0];\n\t    lpos_T *end = &rex.reg_mmatch->endpos[0];\n\n\t    if (end->lnum < start->lnum\n\t\t\t|| (end->lnum == start->lnum && end->col < start->col))\n\t\trex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];\n\t}\n\telse\n\t{\n\t    if (rex.reg_match->endp[0] < rex.reg_match->startp[0])\n\t\trex.reg_match->endp[0] = rex.reg_match->startp[0];\n\t}\n    }\n\n    return retval;\n}","target":0,"code_token_length":1805,"total_token_length":2041,"max_tokens_setting":2048}
+{"idx":261187,"func":"static int MqttClient_HandlePacket(MqttClient* client,\n    MqttPacketType packet_type, void *packet_obj, int timeout_ms)\n{\n    int rc = MQTT_CODE_SUCCESS;\n    MqttQoS packet_qos = MQTT_QOS_0;\n    word16 packet_id = 0;\n\n    if (client == NULL || packet_obj == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    switch (packet_type)\n    {\n        case MQTT_PACKET_TYPE_CONNECT_ACK:\n        {\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, packet_obj, &packet_type, &packet_qos,\n                &packet_id);\n            break;\n        }\n        case MQTT_PACKET_TYPE_PUBLISH:\n        {\n            MqttPublish *publish = (MqttPublish*)packet_obj;\n            MqttPacketType resp_type;\n\n            if (publish->stat == MQTT_MSG_BEGIN ||\n                publish->stat == MQTT_MSG_READ) {\n                rc = MqttClient_DecodePacket(client, client->rx_buf,\n                    client->packet.buf_len, packet_obj, &packet_type,\n                    &packet_qos, &packet_id);\n                if (rc <= 0) {\n                    return rc;\n                }\n            }\n            else {\n                \/* packet ID and QoS were already established *\/\n                packet_id = client->msg.publish.packet_id;\n                packet_qos = client->msg.publish.qos;\n            }\n\n            rc = MqttClient_Publish_ReadPayload(client, publish, timeout_ms);\n            if (rc < 0) {\n                break;\n            }\n\n            \/* Handle QoS *\/\n            if (packet_qos == MQTT_QOS_0) {\n                \/* we are done, no QoS response *\/\n                break;\n            }\n\n            \/* Determine packet type to write *\/\n            resp_type = (packet_qos == MQTT_QOS_1) ?\n                MQTT_PACKET_TYPE_PUBLISH_ACK :\n                MQTT_PACKET_TYPE_PUBLISH_REC;\n            publish->resp.packet_id = packet_id;\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Lock send socket mutex *\/\n            rc = wm_SemLock(&client->lockSend);\n            if (rc != 0) {\n                return rc;\n            }\n        #endif\n\n            \/* Encode publish response *\/\n            rc = MqttEncode_PublishResp(client->tx_buf, client->tx_buf_len,\n                resp_type, &publish->resp);\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d,\"\n                    \" QoS %d\",\n                rc, MqttPacket_TypeDesc(resp_type), resp_type, packet_id,\n                packet_qos);\n        #endif\n            if (rc <= 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n                return rc;\n            }\n            client->packet.buf_len = rc;\n\n            \/* Send publish response packet *\/\n            rc = MqttPacket_Write(client, client->tx_buf,\n                client->packet.buf_len);\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            break;\n        }\n        case MQTT_PACKET_TYPE_PUBLISH_ACK:\n        case MQTT_PACKET_TYPE_PUBLISH_REC:\n        case MQTT_PACKET_TYPE_PUBLISH_REL:\n        case MQTT_PACKET_TYPE_PUBLISH_COMP:\n        {\n            MqttPublishResp pubRespObj, *publish_resp = &pubRespObj;\n            XMEMSET(publish_resp, 0, sizeof(MqttPublishResp));\n\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, publish_resp, &packet_type,\n                &packet_qos, &packet_id);\n            if (rc <= 0) {\n                return rc;\n            }\n\n            \/* If publish Received or Release QoS then proceed *\/\n            if (packet_type != MQTT_PACKET_TYPE_PUBLISH_REC &&\n                packet_type != MQTT_PACKET_TYPE_PUBLISH_REL) {\n                break;\n            }\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Lock send socket mutex *\/\n            rc = wm_SemLock(&client->lockSend);\n            if (rc != 0) {\n                return rc;\n            }\n        #endif\n\n            \/* Encode publish response *\/\n            publish_resp->packet_id = packet_id;\n            packet_type = (MqttPacketType)((int)packet_type+1); \/* next ack *\/\n        #ifdef WOLFMQTT_V5\n            #ifdef WOLFMQTT_DEBUG_CLIENT\n                PRINTF(\"\\tPublish response: reason code %d, Type %s (%d),\"\n                        \" ID %d, QoS %d\",\n                        publish_resp->reason_code,\n                        MqttPacket_TypeDesc(packet_type),\n                        packet_type, packet_id, packet_qos);\n            #endif\n\n            \/* return reason code to caller *\/\n            if (packet_obj != NULL) {\n                MqttPublishResp* caller_rsp = (MqttPublishResp*)packet_obj;\n                caller_rsp->reason_code = publish_resp->reason_code;\n            }\n\n            \/* Publish QoS response needs success reason code,\n             * otherwise will cause disconnect at broker *\/\n            publish_resp->reason_code = MQTT_REASON_SUCCESS;\n        #endif\n\n            rc = MqttEncode_PublishResp(client->tx_buf, client->tx_buf_len,\n                packet_type, publish_resp);\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d,\"\n                    \" QoS %d\",\n                rc, MqttPacket_TypeDesc(packet_type), packet_type, packet_id,\n                packet_qos);\n        #endif\n            if (rc <= 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n                return rc;\n            }\n            client->packet.buf_len = rc;\n\n            \/* Send publish response packet *\/\n            rc = MqttPacket_Write(client, client->tx_buf,\n                client->packet.buf_len);\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            break;\n        }\n        case MQTT_PACKET_TYPE_SUBSCRIBE_ACK:\n        {\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, packet_obj, &packet_type, &packet_qos,\n                &packet_id);\n            break;\n        }\n        case MQTT_PACKET_TYPE_UNSUBSCRIBE_ACK:\n        {\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, packet_obj, &packet_type, &packet_qos,\n                &packet_id);\n            break;\n        }\n        case MQTT_PACKET_TYPE_PING_RESP:\n        {\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, packet_obj, &packet_type, &packet_qos,\n                &packet_id);\n            break;\n        }\n        case MQTT_PACKET_TYPE_AUTH:\n        {\n        #ifdef WOLFMQTT_V5\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, packet_obj, &packet_type, &packet_qos,\n                &packet_id);\n        #else\n            rc = MQTT_CODE_ERROR_PACKET_TYPE;\n        #endif\n            break;\n        }\n\n        case MQTT_PACKET_TYPE_DISCONNECT:\n        {\n        #ifdef WOLFMQTT_V5\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, packet_obj, &packet_type, &packet_qos,\n                &packet_id);\n        #else\n            rc = MQTT_CODE_ERROR_PACKET_TYPE;\n        #endif\n            break;\n        }\n        case MQTT_PACKET_TYPE_CONNECT:\n        case MQTT_PACKET_TYPE_SUBSCRIBE:\n        case MQTT_PACKET_TYPE_UNSUBSCRIBE:\n        case MQTT_PACKET_TYPE_PING_REQ:\n        case MQTT_PACKET_TYPE_ANY:\n        case MQTT_PACKET_TYPE_RESERVED:\n        default:\n            \/* these types are only sent from client and should not be sent\n             * by broker *\/\n            rc = MQTT_CODE_ERROR_PACKET_TYPE;\n            break;\n    } \/* switch (packet_type) *\/\n\n#ifdef WOLFMQTT_DEBUG_CLIENT\n    if (rc < 0) {\n        PRINTF(\"MqttClient_HandlePacket: Rc %d, Type %s (%d), QoS %d, ID %d\",\n            rc, MqttPacket_TypeDesc(packet_type), packet_type, packet_qos,\n            packet_id);\n    }\n#endif\n\n    return rc;\n}","target":0,"code_token_length":1803,"total_token_length":2039,"max_tokens_setting":2048}
+{"idx":281663,"func":"void CLASS redcine_load_raw()\n{\n#ifndef NO_JASPER\n  int c, row, col;\n  jas_stream_t *in;\n  jas_image_t *jimg;\n  jas_matrix_t *jmat;\n  jas_seqent_t *data;\n  ushort *img, *pix;\n\n  jas_init();\n#ifndef LIBRAW_LIBRARY_BUILD\n  in = jas_stream_fopen (ifname, \"rb\");\n#else\n  in = (jas_stream_t*)ifp->make_jas_stream();\n  if(!in)\n          throw LIBRAW_EXCEPTION_DECODE_JPEG2000;\n#endif\n  jas_stream_seek (in, data_offset+20, SEEK_SET);\n  jimg = jas_image_decode (in, -1, 0);\n#ifndef LIBRAW_LIBRARY_BUILD\n  if (!jimg) longjmp (failure, 3);\n#else\n  if(!jimg)\n      {\n          jas_stream_close (in);\n          throw LIBRAW_EXCEPTION_DECODE_JPEG2000;\n      }\n#endif\n  jmat = jas_matrix_create (height\/2, width\/2);\n  merror (jmat, \"redcine_load_raw()\");\n  img = (ushort *) calloc ((height+2), (width+2)*2);\n  merror (img, \"redcine_load_raw()\");\n#ifdef LIBRAW_LIBRARY_BUILD\n  bool fastexitflag = false;\n  try {\n#endif\n  FORC4 {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    jas_image_readcmpt (jimg, c, 0, 0, width\/2, height\/2, jmat);\n    data = jas_matrix_getref (jmat, 0, 0);\n    for (row = c >> 1; row < height; row+=2)\n      for (col = c & 1; col < width; col+=2)\n\timg[(row+1)*(width+2)+col+1] = data[(row\/2)*(width\/2)+col\/2];\n  }\n  for (col=1; col <= width; col++) {\n    img[col] = img[2*(width+2)+col];\n    img[(height+1)*(width+2)+col] = img[(height-1)*(width+2)+col];\n  }\n  for (row=0; row < height+2; row++) {\n    img[row*(width+2)] = img[row*(width+2)+2];\n    img[(row+1)*(width+2)-1] = img[(row+1)*(width+2)-3];\n  }\n  for (row=1; row <= height; row++) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    pix = img + row*(width+2) + (col = 1 + (FC(row,1) & 1));\n    for (   ; col <= width; col+=2, pix+=2) {\n      c = (((pix[0] - 0x800) << 3) +\n\tpix[-(width+2)] + pix[width+2] + pix[-1] + pix[1]) >> 2;\n      pix[0] = LIM(c,0,4095);\n    }\n  }\n  for (row=0; row < height; row++)\n  {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    for (col=0; col < width; col++)\n      RAW(row,col) = curve[img[(row+1)*(width+2)+col+1]];\n  }\n#ifdef LIBRAW_LIBRARY_BUILD\n  } catch (...) {\n    fastexitflag=true;\n  }\n#endif\n  free (img);\n  jas_matrix_destroy (jmat);\n  jas_image_destroy (jimg);\n  jas_stream_close (in);\n#ifdef LIBRAW_LIBRARY_BUILD\n  if(fastexitflag)\n    throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;\n#endif\n#endif\n}","target":0,"code_token_length":841,"total_token_length":1077,"max_tokens_setting":2048}
+{"idx":442959,"func":"win_redr_status(win_T *wp, int ignore_pum UNUSED)\n{\n    int\t\trow;\n    char_u\t*p;\n    int\t\tlen;\n    int\t\tfillchar;\n    int\t\tattr;\n    int\t\tthis_ru_col;\n    static int  busy = FALSE;\n\n    \/\/ It's possible to get here recursively when 'statusline' (indirectly)\n    \/\/ invokes \":redrawstatus\".  Simply ignore the call then.\n    if (busy)\n\treturn;\n    busy = TRUE;\n\n    row = statusline_row(wp);\n\n    wp->w_redr_status = FALSE;\n    if (wp->w_status_height == 0)\n    {\n\t\/\/ no status line, can only be last window\n\tredraw_cmdline = TRUE;\n    }\n    else if (!redrawing()\n\t    \/\/ don't update status line when popup menu is visible and may be\n\t    \/\/ drawn over it, unless it will be redrawn later\n\t    || (!ignore_pum && pum_visible()))\n    {\n\t\/\/ Don't redraw right now, do it later.\n\twp->w_redr_status = TRUE;\n    }\n#ifdef FEAT_STL_OPT\n    else if (*p_stl != NUL || *wp->w_p_stl != NUL)\n    {\n\t\/\/ redraw custom status line\n\tredraw_custom_statusline(wp);\n    }\n#endif\n    else\n    {\n\tfillchar = fillchar_status(&attr, wp);\n\n\tget_trans_bufname(wp->w_buffer);\n\tp = NameBuff;\n\tlen = (int)STRLEN(p);\n\n\tif ((bt_help(wp->w_buffer)\n#ifdef FEAT_QUICKFIX\n\t\t    || wp->w_p_pvw\n#endif\n\t\t    || bufIsChanged(wp->w_buffer)\n\t\t    || wp->w_buffer->b_p_ro)\n\t\t&& len < MAXPATHL - 1)\n\t    *(p + len++) = ' ';\n\tif (bt_help(wp->w_buffer))\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", _(\"[Help]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n#ifdef FEAT_QUICKFIX\n\tif (wp->w_p_pvw)\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", _(\"[Preview]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n#endif\n\tif (bufIsChanged(wp->w_buffer)\n#ifdef FEAT_TERMINAL\n\t\t&& !bt_terminal(wp->w_buffer)\n#endif\n\t\t)\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", \"[+]\");\n\t    len += (int)STRLEN(p + len);\n\t}\n\tif (wp->w_buffer->b_p_ro)\n\t{\n\t    vim_snprintf((char *)p + len, MAXPATHL - len, \"%s\", _(\"[RO]\"));\n\t    len += (int)STRLEN(p + len);\n\t}\n\n\tthis_ru_col = ru_col - (Columns - wp->w_width);\n\tif (this_ru_col < (wp->w_width + 1) \/ 2)\n\t    this_ru_col = (wp->w_width + 1) \/ 2;\n\tif (this_ru_col <= 1)\n\t{\n\t    p = (char_u *)\"<\";\t\t\/\/ No room for file name!\n\t    len = 1;\n\t}\n\telse if (has_mbyte)\n\t{\n\t    int\tclen = 0, i;\n\n\t    \/\/ Count total number of display cells.\n\t    clen = mb_string2cells(p, -1);\n\n\t    \/\/ Find first character that will fit.\n\t    \/\/ Going from start to end is much faster for DBCS.\n\t    for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;\n\t\t    i += (*mb_ptr2len)(p + i))\n\t\tclen -= (*mb_ptr2cells)(p + i);\n\t    len = clen;\n\t    if (i > 0)\n\t    {\n\t\tp = p + i - 1;\n\t\t*p = '<';\n\t\t++len;\n\t    }\n\n\t}\n\telse if (len > this_ru_col - 1)\n\t{\n\t    p += len - (this_ru_col - 1);\n\t    *p = '<';\n\t    len = this_ru_col - 1;\n\t}\n\n\tscreen_puts(p, row, wp->w_wincol, attr);\n\tscreen_fill(row, row + 1, len + wp->w_wincol,\n\t\t\tthis_ru_col + wp->w_wincol, fillchar, fillchar, attr);\n\n\tif (get_keymap_str(wp, (char_u *)\"<%s>\", NameBuff, MAXPATHL)\n\t\t&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))\n\t    screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)\n\t\t\t\t\t\t   - 1 + wp->w_wincol), attr);\n\n#ifdef FEAT_CMDL_INFO\n\twin_redr_ruler(wp, TRUE, ignore_pum);\n#endif\n    }\n\n    \/*\n     * May need to draw the character below the vertical separator.\n     *\/\n    if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())\n    {\n\tif (stl_connected(wp))\n\t    fillchar = fillchar_status(&attr, wp);\n\telse\n\t    fillchar = fillchar_vsep(&attr);\n\tscreen_putchar(fillchar, row, W_ENDCOL(wp), attr);\n    }\n    busy = FALSE;\n}","target":0,"code_token_length":1163,"total_token_length":1399,"max_tokens_setting":2048}
+{"idx":437318,"func":"compile_tree(Node* node, regex_t* reg, ScanEnv* env)\n{\n  int n, len, pos, r = 0;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n    do {\n      r = compile_tree(NODE_CAR(node), reg, env);\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_ALT:\n    {\n      Node* x = node;\n      len = 0;\n      do {\n        len += compile_length_tree(NODE_CAR(x), reg);\n        if (IS_NOT_NULL(NODE_CDR(x))) {\n          len += SIZE_OP_PUSH + SIZE_OP_JUMP;\n        }\n      } while (IS_NOT_NULL(x = NODE_CDR(x)));\n      pos = reg->used + len;  \/* goal position *\/\n\n      do {\n        len = compile_length_tree(NODE_CAR(node), reg);\n        if (IS_NOT_NULL(NODE_CDR(node))) {\n          enum OpCode push = NODE_IS_SUPER(node) ? OP_PUSH_SUPER : OP_PUSH;\n          r = add_opcode_rel_addr(reg, push, len + SIZE_OP_JUMP);\n          if (r != 0) break;\n        }\n        r = compile_tree(NODE_CAR(node), reg, env);\n        if (r != 0) break;\n        if (IS_NOT_NULL(NODE_CDR(node))) {\n          len = pos - (reg->used + SIZE_OP_JUMP);\n          r = add_opcode_rel_addr(reg, OP_JUMP, len);\n          if (r != 0) break;\n        }\n      } while (IS_NOT_NULL(node = NODE_CDR(node)));\n    }\n    break;\n\n  case NODE_STRING:\n    if (NODE_STRING_IS_RAW(node))\n      r = compile_string_raw_node(STR_(node), reg);\n    else\n      r = compile_string_node(node, reg);\n    break;\n\n  case NODE_CCLASS:\n    r = compile_cclass_node(CCLASS_(node), reg);\n    break;\n\n  case NODE_CTYPE:\n    {\n      int op;\n\n      switch (CTYPE_(node)->ctype) {\n      case CTYPE_ANYCHAR:\n        if (IS_MULTILINE(CTYPE_OPTION(node, reg)))\n          r = add_opcode(reg, OP_ANYCHAR_ML);\n        else\n          r = add_opcode(reg, OP_ANYCHAR);\n        break;\n\n      case ONIGENC_CTYPE_WORD:\n        if (CTYPE_(node)->ascii_mode == 0) {\n          op = CTYPE_(node)->not != 0 ? OP_NO_WORD : OP_WORD;\n        }\n        else {\n          op = CTYPE_(node)->not != 0 ? OP_NO_WORD_ASCII : OP_WORD_ASCII;\n        }\n        r = add_opcode(reg, op);\n        break;\n\n      default:\n        return ONIGERR_TYPE_BUG;\n        break;\n      }\n    }\n    break;\n\n  case NODE_BACKREF:\n    {\n      BackRefNode* br = BACKREF_(node);\n\n      if (NODE_IS_CHECKER(node)) {\n#ifdef USE_BACKREF_WITH_LEVEL\n        if (NODE_IS_NEST_LEVEL(node)) {\n          r = add_opcode(reg, OP_BACKREF_CHECK_WITH_LEVEL);\n          if (r != 0) return r;\n          r = add_length(reg, br->nest_level);\n          if (r != 0) return r;\n        }\n        else\n#endif\n          {\n            r = add_opcode(reg, OP_BACKREF_CHECK);\n            if (r != 0) return r;\n          }\n\n        goto add_bacref_mems;\n      }\n      else {\n#ifdef USE_BACKREF_WITH_LEVEL\n        if (NODE_IS_NEST_LEVEL(node)) {\n          r = add_opcode(reg, OP_BACKREF_WITH_LEVEL);\n          if (r != 0) return r;\n          r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE));\n          if (r != 0) return r;\n          r = add_length(reg, br->nest_level);\n          if (r != 0) return r;\n\n          goto add_bacref_mems;\n        }\n        else\n#endif\n        if (br->back_num == 1) {\n          n = br->back_static[0];\n          if (IS_IGNORECASE(reg->options)) {\n            r = add_opcode(reg, OP_BACKREF_N_IC);\n            if (r != 0) return r;\n            r = add_mem_num(reg, n);\n          }\n          else {\n            switch (n) {\n            case 1:  r = add_opcode(reg, OP_BACKREF1); break;\n            case 2:  r = add_opcode(reg, OP_BACKREF2); break;\n            default:\n              r = add_opcode(reg, OP_BACKREF_N);\n              if (r != 0) return r;\n              r = add_mem_num(reg, n);\n              break;\n            }\n          }\n        }\n        else {\n          int i;\n          int* p;\n\n          if (IS_IGNORECASE(reg->options)) {\n            r = add_opcode(reg, OP_BACKREF_MULTI_IC);\n          }\n          else {\n            r = add_opcode(reg, OP_BACKREF_MULTI);\n          }\n          if (r != 0) return r;\n\n        add_bacref_mems:\n          r = add_length(reg, br->back_num);\n          if (r != 0) return r;\n          p = BACKREFS_P(br);\n          for (i = br->back_num - 1; i >= 0; i--) {\n            r = add_mem_num(reg, p[i]);\n            if (r != 0) return r;\n          }\n        }\n      }\n    }\n    break;\n\n#ifdef USE_CALL\n  case NODE_CALL:\n    r = compile_call(CALL_(node), reg, env);\n    break;\n#endif\n\n  case NODE_QUANT:\n    r = compile_quantifier_node(QUANT_(node), reg, env);\n    break;\n\n  case NODE_ENCLOSURE:\n    r = compile_enclosure_node(ENCLOSURE_(node), reg, env);\n    break;\n\n  case NODE_ANCHOR:\n    r = compile_anchor_node(ANCHOR_(node), reg, env);\n    break;\n\n  case NODE_GIMMICK:\n    r = compile_gimmick_node(GIMMICK_(node), reg);\n    break;\n\n  default:\n#ifdef ONIG_DEBUG\n    fprintf(stderr, \"compile_tree: undefined node type %d\\n\", NODE_TYPE(node));\n#endif\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":1339,"total_token_length":1575,"max_tokens_setting":2048}
+{"idx":224891,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Here's the basic idea:\n    \/\/ Batch and depth dimension are independent from row and col dimension. And\n    \/\/ because FractionalAvgPool currently only support pooling along row and\n    \/\/ col, we can basically think of this 4D tensor backpropagation as\n    \/\/ operation of a series of 2D planes.\n    \/\/\n    \/\/ For each element of a 'slice' (2D plane) of output_backprop, we need to\n    \/\/ figure out its contributors when doing FractionalAvgPool operation. This\n    \/\/ can be done based on row_pooling_sequence, col_pooling_seq and\n    \/\/ overlapping.\n    \/\/ Once we figure out the original contributors, we just need to evenly\n    \/\/ divide the value of this element among these contributors.\n    \/\/\n    \/\/ Internally, we divide the out_backprop tensor and store it in a temporary\n    \/\/ tensor of double type. And cast it to the corresponding type.\n    typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        ConstEigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenDoubleMatrixMap;\n\n    \/\/ Grab the inputs.\n    const Tensor& orig_input_tensor_shape = context->input(0);\n    OP_REQUIRES(context,\n                orig_input_tensor_shape.dims() == 1 &&\n                    orig_input_tensor_shape.NumElements() == 4,\n                errors::InvalidArgument(\"original input tensor shape must be\"\n                                        \"1-dimensional and 4 elements\"));\n    const Tensor& out_backprop = context->input(1);\n    const Tensor& row_seq_tensor = context->input(2);\n    const Tensor& col_seq_tensor = context->input(3);\n\n    const int64_t out_batch = out_backprop.dim_size(0);\n    const int64_t out_rows = out_backprop.dim_size(1);\n    const int64_t out_cols = out_backprop.dim_size(2);\n    const int64_t out_depth = out_backprop.dim_size(3);\n\n    OP_REQUIRES(context, row_seq_tensor.NumElements() > out_rows,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", row_seq_tensor must have at least \",\n                                        out_rows + 1, \" elements, but got \",\n                                        row_seq_tensor.NumElements()));\n    OP_REQUIRES(context, col_seq_tensor.NumElements() > out_cols,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", col_seq_tensor must have at least \",\n                                        out_cols + 1, \" elements, but got \",\n                                        col_seq_tensor.NumElements()));\n\n    auto row_seq_tensor_flat = row_seq_tensor.flat<int64_t>();\n    auto col_seq_tensor_flat = col_seq_tensor.flat<int64_t>();\n    auto orig_input_tensor_shape_flat = orig_input_tensor_shape.flat<int64_t>();\n\n    const int64_t in_batch = orig_input_tensor_shape_flat(0);\n    const int64_t in_rows = orig_input_tensor_shape_flat(1);\n    const int64_t in_cols = orig_input_tensor_shape_flat(2);\n    const int64_t in_depth = orig_input_tensor_shape_flat(3);\n    OP_REQUIRES(\n        context, in_batch != 0,\n        errors::InvalidArgument(\"Batch dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_rows != 0,\n        errors::InvalidArgument(\"Rows dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_cols != 0,\n        errors::InvalidArgument(\"Columns dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_depth != 0,\n        errors::InvalidArgument(\"Depth dimension of input must not be 0\"));\n\n    constexpr int tensor_in_and_out_dims = 4;\n    \/\/ Transform orig_input_tensor_shape into TensorShape\n    TensorShape in_shape;\n    for (auto i = 0; i < tensor_in_and_out_dims; ++i) {\n      in_shape.AddDim(orig_input_tensor_shape_flat(i));\n    }\n\n    \/\/ Create intermediate in_backprop.\n    Tensor in_backprop_tensor_temp;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(\n                                {0}, DataTypeToEnum<double>::v(), in_shape,\n                                &in_backprop_tensor_temp));\n    in_backprop_tensor_temp.flat<double>().setZero();\n    \/\/ Transform 4D tensor to 2D matrix.\n    EigenDoubleMatrixMap in_backprop_tensor_temp_mat(\n        in_backprop_tensor_temp.flat<double>().data(), in_depth,\n        in_cols * in_rows * in_batch);\n    ConstEigenMatrixMap out_backprop_mat(out_backprop.flat<T>().data(),\n                                         out_depth,\n                                         out_cols * out_rows * out_batch);\n    \/\/ Loop through each element of out_backprop and evenly distribute the\n    \/\/ element to the corresponding pooling cell.\n    const int64_t in_max_row_index = in_rows - 1;\n    const int64_t in_max_col_index = in_cols - 1;\n    for (int64_t b = 0; b < out_batch; ++b) {\n      for (int64_t r = 0; r < out_rows; ++r) {\n        const int64_t in_row_start = row_seq_tensor_flat(r);\n\n        int64_t in_row_end = overlapping_ ? row_seq_tensor_flat(r + 1)\n                                          : row_seq_tensor_flat(r + 1) - 1;\n        in_row_end = std::min(in_row_end, in_max_row_index);\n        OP_REQUIRES(context, in_row_start >= 0 && in_row_end >= 0,\n                    errors::InvalidArgument(\n                        \"Row sequence tensor values must not be negative, got \",\n                        row_seq_tensor_flat));\n\n        for (int64_t c = 0; c < out_cols; ++c) {\n          const int64_t in_col_start = col_seq_tensor_flat(c);\n          int64_t in_col_end = overlapping_ ? col_seq_tensor_flat(c + 1)\n                                            : col_seq_tensor_flat(c + 1) - 1;\n          in_col_end = std::min(in_col_end, in_max_col_index);\n\n          OP_REQUIRES(\n              context, in_col_start >= 0 && in_col_end >= 0,\n              errors::InvalidArgument(\n                  \"Column sequence tensor values must not be negative, got \",\n                  col_seq_tensor_flat));\n          const int64_t num_elements_in_pooling_cell =\n              (in_row_end - in_row_start + 1) * (in_col_end - in_col_start + 1);\n          const int64_t out_index = (b * out_rows + r) * out_cols + c;\n          \/\/ Now we can evenly distribute out_backprop(b, h, w, *) to\n          \/\/ in_backprop(b, hs:he, ws:we, *).\n          for (int64_t in_r = in_row_start; in_r <= in_row_end; ++in_r) {\n            for (int64_t in_c = in_col_start; in_c <= in_col_end; ++in_c) {\n              const int64_t in_index = (b * in_rows + in_r) * in_cols + in_c;\n              \/\/ Walk through each channel (depth).\n              for (int64_t d = 0; d < out_depth; ++d) {\n                const double out_backprop_element = static_cast<double>(\n                    out_backprop_mat.coeffRef(d, out_index));\n                double& in_backprop_ref =\n                    in_backprop_tensor_temp_mat.coeffRef(d, in_index);\n                in_backprop_ref +=\n                    out_backprop_element \/ num_elements_in_pooling_cell;\n              }\n            }\n          }\n        }\n      }\n    }\n\n    \/\/ Depending on the type, cast double to type T.\n    Tensor* in_backprop_tensor = nullptr;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(\n                                {0}, 0, in_shape, &in_backprop_tensor));\n    auto in_backprop_tensor_flat = in_backprop_tensor->flat<T>();\n    auto in_backprop_tensor_temp_flat = in_backprop_tensor_temp.flat<double>();\n    for (int64_t i = 0; i < in_backprop_tensor_flat.size(); ++i) {\n      in_backprop_tensor_flat(i) =\n          static_cast<T>(in_backprop_tensor_temp_flat(i));\n    }\n  }","target":0,"code_token_length":1794,"total_token_length":2030,"max_tokens_setting":2048}
+{"idx":279903,"func":"ex_global(exarg_T *eap)\n{\n    linenr_T\tlnum;\t\t\/\/ line number according to old situation\n    int\t\tndone = 0;\n    int\t\ttype;\t\t\/\/ first char of cmd: 'v' or 'g'\n    char_u\t*cmd;\t\t\/\/ command argument\n\n    char_u\tdelim;\t\t\/\/ delimiter, normally '\/'\n    char_u\t*pat;\n    regmmatch_T\tregmatch;\n    int\t\tmatch;\n    int\t\twhich_pat;\n\n    \/\/ When nesting the command works on one line.  This allows for\n    \/\/ \":g\/found\/v\/notfound\/command\".\n    if (global_busy && (eap->line1 != 1\n\t\t\t\t  || eap->line2 != curbuf->b_ml.ml_line_count))\n    {\n\t\/\/ will increment global_busy to break out of the loop\n\temsg(_(e_cannot_do_global_recursive_with_range));\n\treturn;\n    }\n\n    if (eap->forceit)\t\t    \/\/ \":global!\" is like \":vglobal\"\n\ttype = 'v';\n    else\n\ttype = *eap->cmd;\n    cmd = eap->arg;\n    which_pat = RE_LAST;\t    \/\/ default: use last used regexp\n\n#ifdef FEAT_EVAL\n    if (in_vim9script() && check_global_and_subst(eap->cmd, eap->arg) == FAIL)\n\treturn;\n#endif\n\n    \/*\n     * undocumented vi feature:\n     *\t\"\\\/\" and \"\\?\": use previous search pattern.\n     *\t\t \"\\&\": use previous substitute pattern.\n     *\/\n    if (*cmd == '\\\\')\n    {\n\t++cmd;\n\tif (vim_strchr((char_u *)\"\/?&\", *cmd) == NULL)\n\t{\n\t    emsg(_(e_backslash_should_be_followed_by));\n\t    return;\n\t}\n\tif (*cmd == '&')\n\t    which_pat = RE_SUBST;\t\/\/ use previous substitute pattern\n\telse\n\t    which_pat = RE_SEARCH;\t\/\/ use previous search pattern\n\t++cmd;\n\tpat = (char_u *)\"\";\n    }\n    else if (*cmd == NUL)\n    {\n\temsg(_(e_regular_expression_missing_from_global));\n\treturn;\n    }\n    else if (check_regexp_delim(*cmd) == FAIL)\n    {\n\treturn;\n    }\n    else\n    {\n\tdelim = *cmd;\t\t\/\/ get the delimiter\n\tif (delim)\n\t    ++cmd;\t\t\/\/ skip delimiter if there is one\n\tpat = cmd;\t\t\/\/ remember start of pattern\n\tcmd = skip_regexp_ex(cmd, delim, magic_isset(), &eap->arg, NULL, NULL);\n\tif (cmd[0] == delim)\t\t    \/\/ end delimiter found\n\t    *cmd++ = NUL;\t\t    \/\/ replace it with a NUL\n    }\n\n    if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL)\n    {\n\temsg(_(e_invalid_command));\n\treturn;\n    }\n\n    if (global_busy)\n    {\n\tlnum = curwin->w_cursor.lnum;\n\tmatch = vim_regexec_multi(®match, curwin, curbuf, lnum,\n\t\t\t\t\t\t       (colnr_T)0, NULL, NULL);\n\tif ((type == 'g' && match) || (type == 'v' && !match))\n\t    global_exe_one(cmd, lnum);\n    }\n    else\n    {\n\t\/*\n\t * pass 1: set marks for each (not) matching line\n\t *\/\n\tfor (lnum = eap->line1; lnum <= eap->line2 && !got_int; ++lnum)\n\t{\n\t    \/\/ a match on this line?\n\t    match = vim_regexec_multi(®match, curwin, curbuf, lnum,\n\t\t\t\t\t\t       (colnr_T)0, NULL, NULL);\n\t    if (regmatch.regprog == NULL)\n\t\tbreak;  \/\/ re-compiling regprog failed\n\t    if ((type == 'g' && match) || (type == 'v' && !match))\n\t    {\n\t\tml_setmarked(lnum);\n\t\tndone++;\n\t    }\n\t    line_breakcheck();\n\t}\n\n\t\/*\n\t * pass 2: execute the command for each line that has been marked\n\t *\/\n\tif (got_int)\n\t    msg(_(e_interrupted));\n\telse if (ndone == 0)\n\t{\n\t    if (type == 'v')\n\t\tsmsg(_(\"Pattern found in every line: %s\"), pat);\n\t    else\n\t\tsmsg(_(\"Pattern not found: %s\"), pat);\n\t}\n\telse\n\t{\n#ifdef FEAT_CLIPBOARD\n\t    start_global_changes();\n#endif\n\t    global_exe(cmd);\n#ifdef FEAT_CLIPBOARD\n\t    end_global_changes();\n#endif\n\t}\n\n\tml_clearmarked();\t   \/\/ clear rest of the marks\n    }\n\n    vim_regfree(regmatch.regprog);\n}","target":0,"code_token_length":1030,"total_token_length":1266,"max_tokens_setting":2048}
+{"idx":414928,"func":"xmlXPathFormatNumber(double number, char buffer[], int buffersize)\n{\n    switch (xmlXPathIsInf(number)) {\n    case 1:\n\tif (buffersize > (int)sizeof(\"Infinity\"))\n\t    snprintf(buffer, buffersize, \"Infinity\");\n\tbreak;\n    case -1:\n\tif (buffersize > (int)sizeof(\"-Infinity\"))\n\t    snprintf(buffer, buffersize, \"-Infinity\");\n\tbreak;\n    default:\n\tif (xmlXPathIsNaN(number)) {\n\t    if (buffersize > (int)sizeof(\"NaN\"))\n\t\tsnprintf(buffer, buffersize, \"NaN\");\n\t} else if (number == 0 && xmlXPathGetSign(number) != 0) {\n\t    snprintf(buffer, buffersize, \"0\");\n\t} else if (number == ((int) number)) {\n\t    char work[30];\n\t    char *ptr, *cur;\n\t    int value = (int) number;\n\n            ptr = &buffer[0];\n\t    if (value == 0) {\n\t\t*ptr++ = '0';\n\t    } else {\n\t\tsnprintf(work, 29, \"%d\", value);\n\t\tcur = &work[0];\n\t\twhile ((*cur) && (ptr - buffer < buffersize)) {\n\t\t    *ptr++ = *cur++;\n\t\t}\n\t    }\n\t    if (ptr - buffer < buffersize) {\n\t\t*ptr = 0;\n\t    } else if (buffersize > 0) {\n\t\tptr--;\n\t\t*ptr = 0;\n\t    }\n\t} else {\n\t    \/*\n\t      For the dimension of work,\n\t          DBL_DIG is number of significant digits\n\t\t  EXPONENT is only needed for \"scientific notation\"\n\t          3 is sign, decimal point, and terminating zero\n\t\t  LOWER_DOUBLE_EXP is max number of leading zeroes in fraction\n\t      Note that this dimension is slightly (a few characters)\n\t      larger than actually necessary.\n\t    *\/\n\t    char work[DBL_DIG + EXPONENT_DIGITS + 3 + LOWER_DOUBLE_EXP];\n\t    int integer_place, fraction_place;\n\t    char *ptr;\n\t    char *after_fraction;\n\t    double absolute_value;\n\t    int size;\n\n\t    absolute_value = fabs(number);\n\n\t    \/*\n\t     * First choose format - scientific or regular floating point.\n\t     * In either case, result is in work, and after_fraction points\n\t     * just past the fractional part.\n\t    *\/\n\t    if ( ((absolute_value > UPPER_DOUBLE) ||\n\t\t  (absolute_value < LOWER_DOUBLE)) &&\n\t\t (absolute_value != 0.0) ) {\n\t\t\/* Use scientific notation *\/\n\t\tinteger_place = DBL_DIG + EXPONENT_DIGITS + 1;\n\t\tfraction_place = DBL_DIG - 1;\n\t\tsize = snprintf(work, sizeof(work),\"%*.*e\",\n\t\t\t integer_place, fraction_place, number);\n\t\twhile ((size > 0) && (work[size] != 'e')) size--;\n\n\t    }\n\t    else {\n\t\t\/* Use regular notation *\/\n\t\tif (absolute_value > 0.0) {\n\t\t    integer_place = (int)log10(absolute_value);\n\t\t    if (integer_place > 0)\n\t\t        fraction_place = DBL_DIG - integer_place - 1;\n\t\t    else\n\t\t        fraction_place = DBL_DIG - integer_place;\n\t\t} else {\n\t\t    fraction_place = 1;\n\t\t}\n\t\tsize = snprintf(work, sizeof(work), \"%0.*f\",\n\t\t\t\tfraction_place, number);\n\t    }\n\n\t    \/* Remove leading spaces sometimes inserted by snprintf *\/\n\t    while (work[0] == ' ') {\n\t        for (ptr = &work[0];(ptr[0] = ptr[1]);ptr++);\n\t\tsize--;\n\t    }\n\n\t    \/* Remove fractional trailing zeroes *\/\n\t    after_fraction = work + size;\n\t    ptr = after_fraction;\n\t    while (*(--ptr) == '0')\n\t\t;\n\t    if (*ptr != '.')\n\t        ptr++;\n\t    while ((*ptr++ = *after_fraction++) != 0);\n\n\t    \/* Finally copy result back to caller *\/\n\t    size = strlen(work) + 1;\n\t    if (size > buffersize) {\n\t\twork[buffersize - 1] = 0;\n\t\tsize = buffersize;\n\t    }\n\t    memmove(buffer, work, size);\n\t}\n\tbreak;\n    }\n}","target":0,"code_token_length":878,"total_token_length":1114,"max_tokens_setting":2048}
+{"idx":411913,"func":"networkstatus_parse_detached_signatures(const char *s, const char *eos)\n{\n  \/* XXXX there is too much duplicate shared between this function and\n   * networkstatus_parse_vote_from_string(). *\/\n  directory_token_t *tok;\n  memarea_t *area = NULL;\n  digests_t *digests;\n\n  smartlist_t *tokens = smartlist_create();\n  ns_detached_signatures_t *sigs =\n    tor_malloc_zero(sizeof(ns_detached_signatures_t));\n  sigs->digests = strmap_new();\n  sigs->signatures = strmap_new();\n\n  if (!eos)\n    eos = s + strlen(s);\n\n  area = memarea_new();\n  if (tokenize_string(area,s, eos, tokens,\n                      networkstatus_detached_signature_token_table, 0)) {\n    log_warn(LD_DIR, \"Error tokenizing detached networkstatus signatures\");\n    goto err;\n  }\n\n  \/* Grab all the digest-like tokens. *\/\n  SMARTLIST_FOREACH_BEGIN(tokens, directory_token_t *, _tok) {\n    const char *algname;\n    digest_algorithm_t alg;\n    const char *flavor;\n    const char *hexdigest;\n    size_t expected_length;\n\n    tok = _tok;\n\n    if (tok->tp == K_CONSENSUS_DIGEST) {\n      algname = \"sha1\";\n      alg = DIGEST_SHA1;\n      flavor = \"ns\";\n      hexdigest = tok->args[0];\n    } else if (tok->tp == K_ADDITIONAL_DIGEST) {\n      int a = crypto_digest_algorithm_parse_name(tok->args[1]);\n      if (a<0) {\n        log_warn(LD_DIR, \"Unrecognized algorithm name %s\", tok->args[0]);\n        continue;\n      }\n      alg = (digest_algorithm_t) a;\n      flavor = tok->args[0];\n      algname = tok->args[1];\n      hexdigest = tok->args[2];\n    } else {\n      continue;\n    }\n\n    expected_length =\n      (alg == DIGEST_SHA1) ? HEX_DIGEST_LEN : HEX_DIGEST256_LEN;\n\n    if (strlen(hexdigest) != expected_length) {\n      log_warn(LD_DIR, \"Wrong length on consensus-digest in detached \"\n               \"networkstatus signatures\");\n      goto err;\n    }\n    digests = detached_get_digests(sigs, flavor);\n    tor_assert(digests);\n    if (!tor_mem_is_zero(digests->d[alg], DIGEST256_LEN)) {\n      log_warn(LD_DIR, \"Multiple digests for %s with %s on detached \"\n               \"signatures document\", flavor, algname);\n      continue;\n    }\n    if (base16_decode(digests->d[alg], DIGEST256_LEN,\n                      hexdigest, strlen(hexdigest)) < 0) {\n      log_warn(LD_DIR, \"Bad encoding on consensus-digest in detached \"\n               \"networkstatus signatures\");\n      goto err;\n    }\n  } SMARTLIST_FOREACH_END(_tok);\n\n  tok = find_by_keyword(tokens, K_VALID_AFTER);\n  if (parse_iso_time(tok->args[0], &sigs->valid_after)) {\n    log_warn(LD_DIR, \"Bad valid-after in detached networkstatus signatures\");\n    goto err;\n  }\n\n  tok = find_by_keyword(tokens, K_FRESH_UNTIL);\n  if (parse_iso_time(tok->args[0], &sigs->fresh_until)) {\n    log_warn(LD_DIR, \"Bad fresh-until in detached networkstatus signatures\");\n    goto err;\n  }\n\n  tok = find_by_keyword(tokens, K_VALID_UNTIL);\n  if (parse_iso_time(tok->args[0], &sigs->valid_until)) {\n    log_warn(LD_DIR, \"Bad valid-until in detached networkstatus signatures\");\n    goto err;\n  }\n\n  SMARTLIST_FOREACH_BEGIN(tokens, directory_token_t *, _tok) {\n    const char *id_hexdigest;\n    const char *sk_hexdigest;\n    const char *algname;\n    const char *flavor;\n    digest_algorithm_t alg;\n\n    char id_digest[DIGEST_LEN];\n    char sk_digest[DIGEST_LEN];\n    smartlist_t *siglist;\n    document_signature_t *sig;\n    int is_duplicate;\n\n    tok = _tok;\n    if (tok->tp == K_DIRECTORY_SIGNATURE) {\n      tor_assert(tok->n_args >= 2);\n      flavor = \"ns\";\n      algname = \"sha1\";\n      id_hexdigest = tok->args[0];\n      sk_hexdigest = tok->args[1];\n    } else if (tok->tp == K_ADDITIONAL_SIGNATURE) {\n      tor_assert(tok->n_args >= 4);\n      flavor = tok->args[0];\n      algname = tok->args[1];\n      id_hexdigest = tok->args[2];\n      sk_hexdigest = tok->args[3];\n    } else {\n      continue;\n    }\n\n    {\n      int a = crypto_digest_algorithm_parse_name(algname);\n      if (a<0) {\n        log_warn(LD_DIR, \"Unrecognized algorithm name %s\", algname);\n        continue;\n      }\n      alg = (digest_algorithm_t) a;\n    }\n\n    if (!tok->object_type ||\n        strcmp(tok->object_type, \"SIGNATURE\") ||\n        tok->object_size < 128 || tok->object_size > 512) {\n      log_warn(LD_DIR, \"Bad object type or length on directory-signature\");\n      goto err;\n    }\n\n    if (strlen(id_hexdigest) != HEX_DIGEST_LEN ||\n        base16_decode(id_digest, sizeof(id_digest),\n                      id_hexdigest, HEX_DIGEST_LEN) < 0) {\n      log_warn(LD_DIR, \"Error decoding declared identity %s in \"\n               \"network-status vote.\", escaped(id_hexdigest));\n      goto err;\n    }\n    if (strlen(sk_hexdigest) != HEX_DIGEST_LEN ||\n        base16_decode(sk_digest, sizeof(sk_digest),\n                      sk_hexdigest, HEX_DIGEST_LEN) < 0) {\n      log_warn(LD_DIR, \"Error decoding declared signing key digest %s in \"\n               \"network-status vote.\", escaped(sk_hexdigest));\n      goto err;\n    }\n\n    siglist = detached_get_signatures(sigs, flavor);\n    is_duplicate = 0;\n    SMARTLIST_FOREACH(siglist, document_signature_t *, s, {\n      if (s->alg == alg &&\n          tor_memeq(id_digest, s->identity_digest, DIGEST_LEN) &&\n          tor_memeq(sk_digest, s->signing_key_digest, DIGEST_LEN)) {\n        is_duplicate = 1;\n      }\n    });\n    if (is_duplicate) {\n      log_warn(LD_DIR, \"Two signatures with identical keys and algorithm \"\n               \"found.\");\n      continue;\n    }\n\n    sig = tor_malloc_zero(sizeof(document_signature_t));\n    sig->alg = alg;\n    memcpy(sig->identity_digest, id_digest, DIGEST_LEN);\n    memcpy(sig->signing_key_digest, sk_digest, DIGEST_LEN);\n    if (tok->object_size >= INT_MAX || tok->object_size >= SIZE_T_CEILING) {\n      tor_free(sig);\n      goto err;\n    }\n    sig->signature = tor_memdup(tok->object_body, tok->object_size);\n    sig->signature_len = (int) tok->object_size;\n\n    smartlist_add(siglist, sig);\n  } SMARTLIST_FOREACH_END(_tok);\n\n  goto done;\n err:\n  ns_detached_signatures_free(sigs);\n  sigs = NULL;\n done:\n  SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));\n  smartlist_free(tokens);\n  if (area) {\n    DUMP_AREA(area, \"detached signatures\");\n    memarea_drop_all(area);\n  }\n  return sigs;\n}","target":0,"code_token_length":1635,"total_token_length":1871,"max_tokens_setting":2048}
+{"idx":206946,"func":"cmdopts_t *cmdopts_parse(int argc, char **argv)\n{\n\tenum {\n\t\tCMDOPT_HELP = 0,\n\t\tCMDOPT_VERBOSE,\n\t\tCMDOPT_QUIET,\n\t\tCMDOPT_INFILE,\n\t\tCMDOPT_INFMT,\n\t\tCMDOPT_INOPT,\n\t\tCMDOPT_OUTFILE,\n\t\tCMDOPT_OUTFMT,\n\t\tCMDOPT_OUTOPT,\n\t\tCMDOPT_VERSION,\n\t\tCMDOPT_DEBUG,\n\t\tCMDOPT_CMPTNO,\n\t\tCMDOPT_SRGB,\n\t\tCMDOPT_MAXMEM,\n\t\tCMDOPT_LIST_ENABLED_CODECS,\n\t\tCMDOPT_LIST_ALL_CODECS,\n\t\tCMDOPT_ENABLE_FORMAT,\n\t\tCMDOPT_ENABLE_ALL_FORMATS,\n\t};\n\n\tstatic const jas_opt_t cmdoptions[] = {\n\t\t{CMDOPT_HELP, \"help\", 0},\n\t\t{CMDOPT_VERBOSE, \"verbose\", 0},\n\t\t{CMDOPT_QUIET, \"quiet\", 0},\n\t\t{CMDOPT_QUIET, \"q\", 0},\n\t\t{CMDOPT_INFILE, \"input\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INFILE, \"f\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INFMT, \"input-format\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INFMT, \"t\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INOPT, \"input-option\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INOPT, \"o\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFILE, \"output\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFILE, \"F\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFMT, \"output-format\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFMT, \"T\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTOPT, \"output-option\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTOPT, \"O\", JAS_OPT_HASARG},\n\t\t{CMDOPT_VERSION, \"version\", 0},\n\t\t{CMDOPT_DEBUG, \"debug-level\", JAS_OPT_HASARG},\n\t\t{CMDOPT_CMPTNO, \"cmptno\", JAS_OPT_HASARG},\n\t\t{CMDOPT_SRGB, \"force-srgb\", 0},\n\t\t{CMDOPT_SRGB, \"S\", 0},\n\t\t{CMDOPT_MAXMEM, \"memory-limit\", JAS_OPT_HASARG},\n\t\t{CMDOPT_LIST_ENABLED_CODECS, \"list-enabled-formats\", 0},\n\t\t{CMDOPT_LIST_ALL_CODECS, \"list-all-formats\", 0},\n\t\t{CMDOPT_ENABLE_FORMAT, \"enable-format\", JAS_OPT_HASARG},\n\t\t{CMDOPT_ENABLE_ALL_FORMATS, \"enable-all-formats\", 0},\n\t\t{-1, 0, 0}\n\t};\n\n\tcmdopts_t *cmdopts;\n\tint c;\n\n\tif (!(cmdopts = malloc(sizeof(cmdopts_t)))) {\n\t\tfprintf(stderr, \"error: insufficient memory\\n\");\n\t\texit(EXIT_FAILURE);\n\t}\n\n\tcmdopts->infile = 0;\n\tcmdopts->infmt = -1;\n\tcmdopts->infmt_str = 0;\n\tcmdopts->inopts = 0;\n\tcmdopts->inoptsbuf[0] = '\\0';\n\tcmdopts->outfile = 0;\n\tcmdopts->outfmt = -1;\n\tcmdopts->outfmt_str = 0;\n\tcmdopts->outopts = 0;\n\tcmdopts->outoptsbuf[0] = '\\0';\n\tcmdopts->verbose = 0;\n\tcmdopts->version = 0;\n\tcmdopts->cmptno = -1;\n\tcmdopts->debug = 0;\n\tcmdopts->srgb = 0;\n\tcmdopts->list_codecs = 0;\n\tcmdopts->list_codecs_all = 0;\n\tcmdopts->help = 0;\n\tcmdopts->max_mem = get_default_max_mem_usage();\n\tcmdopts->enable_format = 0;\n\tcmdopts->enable_all_formats = 0;\n\n\twhile ((c = jas_getopt(argc, argv, cmdoptions)) != EOF) {\n\t\tswitch (c) {\n\t\tcase CMDOPT_HELP:\n\t\t\tcmdopts->help = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_VERBOSE:\n\t\t\tcmdopts->verbose = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_QUIET:\n\t\t\tcmdopts->verbose = -1;\n\t\t\tbreak;\n\t\tcase CMDOPT_VERSION:\n\t\t\tcmdopts->version = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_LIST_ENABLED_CODECS:\n\t\t\tcmdopts->list_codecs = 1;\n\t\t\tcmdopts->list_codecs_all = 0;\n\t\t\tbreak;\n\t\tcase CMDOPT_LIST_ALL_CODECS:\n\t\t\tcmdopts->list_codecs = 1;\n\t\t\tcmdopts->list_codecs_all = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_DEBUG:\n\t\t\tcmdopts->debug = atoi(jas_optarg);\n\t\t\tbreak;\n\t\tcase CMDOPT_INFILE:\n\t\t\tcmdopts->infile = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_INFMT:\n\t\t\tcmdopts->infmt_str= jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_INOPT:\n\t\t\taddopt(cmdopts->inoptsbuf, OPTSMAX, jas_optarg);\n\t\t\tcmdopts->inopts = cmdopts->inoptsbuf;\n\t\t\tbreak;\n\t\tcase CMDOPT_OUTFILE:\n\t\t\tcmdopts->outfile = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_OUTFMT:\n\t\t\tcmdopts->outfmt_str = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_OUTOPT:\n\t\t\taddopt(cmdopts->outoptsbuf, OPTSMAX, jas_optarg);\n\t\t\tcmdopts->outopts = cmdopts->outoptsbuf;\n\t\t\tbreak;\n\t\tcase CMDOPT_CMPTNO:\n\t\t\tcmdopts->cmptno = atoi(jas_optarg);\n\t\t\tbreak;\n\t\tcase CMDOPT_SRGB:\n\t\t\tcmdopts->srgb = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_MAXMEM:\n\t\t\tcmdopts->max_mem = strtoull(jas_optarg, 0, 10);\n\t\t\tbreak;\n\t\tcase CMDOPT_ENABLE_FORMAT:\n\t\t\tcmdopts->enable_format = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_ENABLE_ALL_FORMATS:\n\t\t\tcmdopts->enable_all_formats = 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbadusage();\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twhile (jas_optind < argc) {\n\t\tfprintf(stderr,\n\t\t  \"warning: ignoring bogus command line argument %s\\n\",\n\t\t  argv[jas_optind]);\n\t\t++jas_optind;\n\t}\n\n\tif (cmdopts->version || cmdopts->list_codecs || cmdopts->help) {\n\t\tgoto done;\n\t}\n\n\tif (!cmdopts->outfmt_str && !cmdopts->outfile) {\n\t\tfprintf(stderr, \"error: cannot determine output format\\n\");\n\t\tbadusage();\n\t}\n\ndone:\n\treturn cmdopts;\n}","target":1,"code_token_length":1533,"total_token_length":1769,"max_tokens_setting":2048}
+{"idx":509509,"func":"void ha_maria::start_bulk_insert(ha_rows rows, uint flags)\n{\n  DBUG_ENTER(\"ha_maria::start_bulk_insert\");\n  THD *thd= table->in_use;\n  MARIA_SHARE *share= file->s;\n  bool index_disabled= 0;\n  DBUG_PRINT(\"info\", (\"start_bulk_insert: rows %lu\", (ulong) rows));\n\n  \/* don't enable row cache if too few rows *\/\n  if ((!rows || rows > MARIA_MIN_ROWS_TO_USE_WRITE_CACHE) && !has_long_unique())\n  {\n    ulonglong size= thd->variables.read_buff_size, tmp;\n    if (rows)\n    {\n      if (file->state->records)\n      {\n        MARIA_INFO maria_info;\n        maria_status(file, &maria_info, HA_STATUS_NO_LOCK |HA_STATUS_VARIABLE);\n        set_if_smaller(size, maria_info.mean_reclength * rows);\n      }\n      else if (table->s->avg_row_length)\n        set_if_smaller(size, (size_t) (table->s->avg_row_length * rows));\n    }\n    tmp= (ulong) size;                          \/\/ Safe becasue of limits\n    maria_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &tmp);\n  }\n\n  can_enable_indexes= (maria_is_all_keys_active(share->state.key_map,\n                                                share->base.keys));\n  bulk_insert_single_undo= BULK_INSERT_NONE;\n\n  if (!(specialflag & SPECIAL_SAFE_MODE))\n  {\n    \/*\n       Only disable old index if the table was empty and we are inserting\n       a lot of rows.\n       We should not do this for only a few rows as this is slower and\n       we don't want to update the key statistics based of only a few rows.\n       Index file rebuild requires an exclusive lock, so if versioning is on\n       don't do it (see how ha_maria::store_lock() tries to predict repair).\n       We can repair index only if we have an exclusive (TL_WRITE) lock or\n       if this is inside an ALTER TABLE, in which case lock_type == TL_UNLOCK.\n\n       To see if table is empty, we shouldn't rely on the old record\n       count from our transaction's start (if that old count is 0 but\n       now there are records in the table, we would wrongly destroy\n       them).  So we need to look at share->state.state.records.  As a\n       safety net for now, we don't remove the test of\n       file->state->records, because there is uncertainty on what will\n       happen during repair if the two states disagree.\n\n       We also have to check in case of transactional tables that the\n       user has not used LOCK TABLE on the table twice.\n    *\/\n    if ((file->state->records == 0) &&\n        (share->state.state.records == 0) && can_enable_indexes &&\n        (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES) &&\n        (file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK) &&\n        (!share->have_versioning || !share->now_transactional ||\n         file->used_tables->use_count == 1))\n    {\n      \/**\n         @todo for a single-row INSERT SELECT, we will go into repair, which\n         is more costly (flushes, syncs) than a row write.\n      *\/\n      if (file->open_flags & HA_OPEN_INTERNAL_TABLE)\n      {\n        \/* Internal table; If we get a duplicate something is very wrong *\/\n        file->update|= HA_STATE_CHANGED;\n        index_disabled= share->base.keys > 0;\n        maria_clear_all_keys_active(file->s->state.key_map);\n      }\n      else\n      {\n        my_bool all_keys= MY_TEST(flags & HA_CREATE_UNIQUE_INDEX_BY_SORT);\n        \/*\n          Deactivate all indexes that can be recreated fast.\n          These include packed keys on which sorting will use more temporary\n          space than the max allowed file length or for which the unpacked keys\n          will take much more space than packed keys.\n          Note that 'rows' may be zero for the case when we don't know how many\n          rows we will put into the file.\n        *\/\n        MARIA_SHARE *share= file->s;\n        MARIA_KEYDEF    *key=share->keyinfo;\n        uint          i;\n\n        DBUG_ASSERT(share->state.state.records == 0 &&\n                    (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES));\n        for (i=0 ; i < share->base.keys ; i++,key++)\n        {\n          if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY | HA_RTREE_INDEX)) &&\n              ! maria_too_big_key_for_sort(key,rows) && share->base.auto_key != i+1 &&\n              (all_keys || !(key->flag & HA_NOSAME)) &&\n              table->key_info[i].algorithm != HA_KEY_ALG_LONG_HASH)\n          {\n            maria_clear_key_active(share->state.key_map, i);\n            index_disabled= 1;\n            file->update|= HA_STATE_CHANGED;\n            file->create_unique_index_by_sort= all_keys;\n          }\n        }\n      }\n      if (share->now_transactional)\n      {\n        bulk_insert_single_undo= BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR;\n        write_log_record_for_bulk_insert(file);\n        _ma_tmp_disable_logging_for_table(file, TRUE);\n        \/*\n          Pages currently in the page cache have type PAGECACHE_LSN_PAGE, we\n          are not allowed to overwrite them with PAGECACHE_PLAIN_PAGE, so\n          throw them away. It is not losing data, because we just wrote and\n          forced an UNDO which will for sure empty the table if we crash. The\n          upcoming unique-key insertions however need a proper index, so we\n          cannot leave the corrupted on-disk index file, thus we truncate it.\n        *\/\n        maria_delete_all_rows(file);\n      }\n    }\n    else if (!file->bulk_insert &&\n             (!rows || rows >= MARIA_MIN_ROWS_TO_USE_BULK_INSERT))\n    {\n      maria_init_bulk_insert(file,\n                             (size_t) thd->variables.bulk_insert_buff_size,\n                             rows);\n    }\n  }\n  can_enable_indexes= index_disabled;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":1332,"total_token_length":1568,"max_tokens_setting":2048}
+{"idx":216903,"func":"bool st_select_lex::optimize_unflattened_subqueries(bool const_only)\n{\n  SELECT_LEX_UNIT *next_unit= NULL;\n  for (SELECT_LEX_UNIT *un= first_inner_unit();\n       un;\n       un= next_unit ? next_unit : un->next_unit())\n  {\n    Item_subselect *subquery_predicate= un->item;\n    next_unit= NULL;\n\n    if (subquery_predicate)\n    {\n      if (!subquery_predicate->fixed)\n      {\n\t\/*\n\t This subquery was excluded as part of some expression so it is\n\t invisible from all prepared expression.\n       *\/\n\tnext_unit= un->next_unit();\n\tun->exclude_level();\n\tif (next_unit)\n\t  continue;\n\tbreak;\n      }\n      if (subquery_predicate->substype() == Item_subselect::IN_SUBS)\n      {\n        Item_in_subselect *in_subs= (Item_in_subselect*) subquery_predicate;\n        if (in_subs->is_jtbm_merged)\n          continue;\n      }\n\n      if (const_only && !subquery_predicate->const_item())\n      {\n        \/* Skip non-constant subqueries if the caller asked so. *\/\n        continue;\n      }\n\n      bool empty_union_result= true;\n      bool is_correlated_unit= false;\n      bool first= true;\n      bool union_plan_saved= false;\n      \/*\n        If the subquery is a UNION, optimize all the subqueries in the UNION. If\n        there is no UNION, then the loop will execute once for the subquery.\n      *\/\n      for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())\n      {\n        JOIN *inner_join= sl->join;\n        if (first)\n          first= false;\n        else\n        {\n          if (!union_plan_saved)\n          {\n            union_plan_saved= true;\n            if (un->save_union_explain(un->thd->lex->explain))\n              return true; \/* Failure *\/\n          }\n        }\n        if (!inner_join)\n          continue;\n        SELECT_LEX *save_select= un->thd->lex->current_select;\n        ulonglong save_options;\n        int res;\n        \/* We need only 1 row to determine existence *\/\n        un->set_limit(un->global_parameters());\n        un->thd->lex->current_select= sl;\n        save_options= inner_join->select_options;\n        if (options & SELECT_DESCRIBE)\n        {\n          \/* Optimize the subquery in the context of EXPLAIN. *\/\n          sl->set_explain_type(FALSE);\n          sl->options|= SELECT_DESCRIBE;\n          inner_join->select_options|= SELECT_DESCRIBE;\n        }\n        if ((res= inner_join->optimize()))\n          return TRUE;\n        if (!inner_join->cleaned)\n          sl->update_used_tables();\n        sl->update_correlated_cache();\n        is_correlated_unit|= sl->is_correlated;\n        inner_join->select_options= save_options;\n        un->thd->lex->current_select= save_select;\n\n        Explain_query *eq;\n        if ((eq= inner_join->thd->lex->explain))\n        {\n          Explain_select *expl_sel;\n          if ((expl_sel= eq->get_select(inner_join->select_lex->select_number)))\n          {\n            sl->set_explain_type(TRUE);\n            expl_sel->select_type= sl->type;\n          }\n        }\n\n        if (empty_union_result)\n        {\n          \/*\n            If at least one subquery in a union is non-empty, the UNION result\n            is non-empty. If there is no UNION, the only subquery is non-empy.\n          *\/\n          empty_union_result= inner_join->empty_result();\n        }\n        if (res)\n          return TRUE;\n      }\n      if (empty_union_result)\n        subquery_predicate->no_rows_in_result();\n      if (!is_correlated_unit)\n        un->uncacheable&= ~UNCACHEABLE_DEPENDENT;\n      subquery_predicate->is_correlated= is_correlated_unit;\n    }\n  }\n  return FALSE;\n}","target":1,"code_token_length":841,"total_token_length":1077,"max_tokens_setting":2048}
+{"idx":508920,"func":"void SELECT_LEX::update_used_tables()\n{\n  TABLE_LIST *tl;\n  List_iterator<TABLE_LIST> ti(leaf_tables);\n\n  while ((tl= ti++))\n  {\n    if (tl->table && !tl->is_view_or_derived())\n    {\n      TABLE_LIST *embedding= tl->embedding;\n      for (embedding= tl->embedding; embedding; embedding=embedding->embedding)\n      {\n        if (embedding->is_view_or_derived())\n\t{\n          DBUG_ASSERT(embedding->is_merged_derived());\n          TABLE *tab= tl->table;\n          tab->covering_keys= tab->s->keys_for_keyread;\n          tab->covering_keys.intersect(tab->keys_in_use_for_query);\n          \/*\n            View\/derived was merged. Need to recalculate read_set\/vcol_set\n            bitmaps here. For example:\n              CREATE VIEW v1 AS SELECT f1,f2,f3 FROM t1;\n              SELECT f1 FROM v1;\n            Initially, the view definition will put all f1,f2,f3 in the\n            read_set for t1. But after the view is merged, only f1 should\n            be in the read_set.\n          *\/\n          bitmap_clear_all(tab->read_set);\n          if (tab->vcol_set)\n            bitmap_clear_all(tab->vcol_set);\n          break;\n        }\n      }\n    }\n  }\n\n  ti.rewind();\n  while ((tl= ti++))\n  {\n    TABLE_LIST *embedding= tl;\n    do\n    {\n      bool maybe_null;\n      if ((maybe_null= MY_TEST(embedding->outer_join)))\n      {\n\ttl->table->maybe_null= maybe_null;\n        break;\n      }\n    }\n    while ((embedding= embedding->embedding));\n    if (tl->on_expr)\n    {\n      tl->on_expr->update_used_tables();\n      tl->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);\n    }\n    \/*\n      - There is no need to check sj_on_expr, because merged semi-joins inject\n        sj_on_expr into the parent's WHERE clase.\n      - For non-merged semi-joins (aka JTBMs), we need to check their\n        left_expr. There is no need to check the rest of the subselect, we know\n        it is uncorrelated and so cannot refer to any tables in this select.\n    *\/\n    if (tl->jtbm_subselect)\n    {\n      Item *left_expr= tl->jtbm_subselect->left_expr;\n      left_expr->walk(&Item::update_table_bitmaps_processor, FALSE, NULL);\n    }\n\n    embedding= tl->embedding;\n    while (embedding)\n    {\n      if (embedding->on_expr && \n          embedding->nested_join->join_list.head() == tl)\n      {\n        embedding->on_expr->update_used_tables();\n        embedding->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);\n      }\n      tl= embedding;\n      embedding= tl->embedding;\n    }\n  }\n\n  if (join->conds)\n  {\n    join->conds->update_used_tables();\n    join->conds->walk(&Item::eval_not_null_tables, 0, NULL);\n  }\n  if (join->having)\n  {\n    join->having->update_used_tables();\n  }\n\n  Item *item;\n  List_iterator_fast<Item> it(join->all_fields);\n  select_list_tables= 0;\n  while ((item= it++))\n  {\n    item->update_used_tables();\n    select_list_tables|= item->used_tables();\n  }\n  Item_outer_ref *ref;\n  List_iterator_fast<Item_outer_ref> ref_it(inner_refs_list);\n  while ((ref= ref_it++))\n  {\n    item= ref->outer_ref;\n    item->update_used_tables();\n  }\n  for (ORDER *order= group_list.first; order; order= order->next)\n    (*order->item)->update_used_tables();\n  if (!master_unit()->is_union() || master_unit()->global_parameters() != this)\n  {\n    for (ORDER *order= order_list.first; order; order= order->next)\n      (*order->item)->update_used_tables();\n  }\n  join->result->update_used_tables();\n}","target":0,"code_token_length":887,"total_token_length":1123,"max_tokens_setting":2048}
+{"idx":234755,"func":"static int find_free_dev_extent_start(struct btrfs_device *device,\n\t\t\t\tu64 num_bytes, u64 search_start, u64 *start,\n\t\t\t\tu64 *len)\n{\n\tstruct btrfs_fs_info *fs_info = device->fs_info;\n\tstruct btrfs_root *root = fs_info->dev_root;\n\tstruct btrfs_key key;\n\tstruct btrfs_dev_extent *dev_extent;\n\tstruct btrfs_path *path;\n\tu64 hole_size;\n\tu64 max_hole_start;\n\tu64 max_hole_size;\n\tu64 extent_end;\n\tu64 search_end = device->total_bytes;\n\tint ret;\n\tint slot;\n\tstruct extent_buffer *l;\n\n\tsearch_start = dev_extent_search_start(device, search_start);\n\n\tWARN_ON(device->zone_info &&\n\t\t!IS_ALIGNED(num_bytes, device->zone_info->zone_size));\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tmax_hole_start = search_start;\n\tmax_hole_size = 0;\n\nagain:\n\tif (search_start >= search_end ||\n\t\ttest_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) {\n\t\tret = -ENOSPC;\n\t\tgoto out;\n\t}\n\n\tpath->reada = READA_FORWARD;\n\tpath->search_commit_root = 1;\n\tpath->skip_locking = 1;\n\n\tkey.objectid = device->devid;\n\tkey.offset = search_start;\n\tkey.type = BTRFS_DEV_EXTENT_KEY;\n\n\tret = btrfs_search_backwards(root, &key, path);\n\tif (ret < 0)\n\t\tgoto out;\n\n\twhile (1) {\n\t\tl = path->nodes[0];\n\t\tslot = path->slots[0];\n\t\tif (slot >= btrfs_header_nritems(l)) {\n\t\t\tret = btrfs_next_leaf(root, path);\n\t\t\tif (ret == 0)\n\t\t\t\tcontinue;\n\t\t\tif (ret < 0)\n\t\t\t\tgoto out;\n\n\t\t\tbreak;\n\t\t}\n\t\tbtrfs_item_key_to_cpu(l, &key, slot);\n\n\t\tif (key.objectid < device->devid)\n\t\t\tgoto next;\n\n\t\tif (key.objectid > device->devid)\n\t\t\tbreak;\n\n\t\tif (key.type != BTRFS_DEV_EXTENT_KEY)\n\t\t\tgoto next;\n\n\t\tif (key.offset > search_start) {\n\t\t\thole_size = key.offset - search_start;\n\t\t\tdev_extent_hole_check(device, &search_start, &hole_size,\n\t\t\t\t\t      num_bytes);\n\n\t\t\tif (hole_size > max_hole_size) {\n\t\t\t\tmax_hole_start = search_start;\n\t\t\t\tmax_hole_size = hole_size;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * If this free space is greater than which we need,\n\t\t\t * it must be the max free space that we have found\n\t\t\t * until now, so max_hole_start must point to the start\n\t\t\t * of this free space and the length of this free space\n\t\t\t * is stored in max_hole_size. Thus, we return\n\t\t\t * max_hole_start and max_hole_size and go back to the\n\t\t\t * caller.\n\t\t\t *\/\n\t\t\tif (hole_size >= num_bytes) {\n\t\t\t\tret = 0;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\n\t\tdev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent);\n\t\textent_end = key.offset + btrfs_dev_extent_length(l,\n\t\t\t\t\t\t\t\t  dev_extent);\n\t\tif (extent_end > search_start)\n\t\t\tsearch_start = extent_end;\nnext:\n\t\tpath->slots[0]++;\n\t\tcond_resched();\n\t}\n\n\t\/*\n\t * At this point, search_start should be the end of\n\t * allocated dev extents, and when shrinking the device,\n\t * search_end may be smaller than search_start.\n\t *\/\n\tif (search_end > search_start) {\n\t\thole_size = search_end - search_start;\n\t\tif (dev_extent_hole_check(device, &search_start, &hole_size,\n\t\t\t\t\t  num_bytes)) {\n\t\t\tbtrfs_release_path(path);\n\t\t\tgoto again;\n\t\t}\n\n\t\tif (hole_size > max_hole_size) {\n\t\t\tmax_hole_start = search_start;\n\t\t\tmax_hole_size = hole_size;\n\t\t}\n\t}\n\n\t\/* See above. *\/\n\tif (max_hole_size < num_bytes)\n\t\tret = -ENOSPC;\n\telse\n\t\tret = 0;\n\nout:\n\tbtrfs_free_path(path);\n\t*start = max_hole_start;\n\tif (len)\n\t\t*len = max_hole_size;\n\treturn ret;\n}","target":0,"code_token_length":939,"total_token_length":1175,"max_tokens_setting":2048}
+{"idx":210453,"func":"jetp3852_print_page(gx_device_printer *pdev, gp_file *prn_stream)\n{\n#define DATA_SIZE (LINE_SIZE * 8)\n\n    unsigned int cnt_2prn;\n    unsigned int count,tempcnt;\n    unsigned char vtp,cntc1,cntc2;\n    int line_size_color_plane;\n\n    byte data[DATA_SIZE];\n    byte plane_data[LINE_SIZE * 3];\n\n    \/* Set initial condition for printer *\/\n    gp_fputs(\"\\033@\",prn_stream);\n\n    \/* Send each scan line in turn *\/\n    {\n        int lnum;\n        int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);\n        int num_blank_lines = 0;\n\n        if (line_size > DATA_SIZE) {\n            emprintf2(pdev->memory, \"invalid resolution and\/or width gives line_size = %d, max. is %d\\n\",\n                      line_size, DATA_SIZE);\n            return_error(gs_error_rangecheck);\n        }\n\n        for ( lnum = 0; lnum < pdev->height; lnum++ ) {\n            byte *end_data = data + line_size;\n            gdev_prn_copy_scan_lines(pdev, lnum,\n                                     (byte *)data, line_size);\n            \/* Remove trailing 0s. *\/\n            while ( end_data > data && end_data[-1] == 0 )\n                end_data--;\n            if ( end_data == data ) {\n                \/* Blank line *\/\n                num_blank_lines++;\n            } else {\n                int i;\n                byte *odp;\n                byte *row;\n\n                \/* Pad with 0s to fill out the last *\/\n                \/* block of 8 bytes. *\/\n                memset(end_data, 0, 7);\n\n                \/* Transpose the data to get pixel planes. *\/\n                for ( i = 0, odp = plane_data; i < DATA_SIZE;\n                      i += 8, odp++\n                    ) { \/* The following is for 16-bit machines *\/\n#define spread3(c)\\\n { 0, c, c*0x100, c*0x101, c*0x10000L, c*0x10001L, c*0x10100L, c*0x10101L }\n                    static ulong spr40[8] = spread3(0x40);\n                    static ulong spr8[8] = spread3(8);\n                    static ulong spr2[8] = spread3(2);\n                    register byte *dp = data + i;\n                    register ulong pword =\n                                     (spr40[dp[0]] << 1) +\n                                     (spr40[dp[1]]) +\n                                     (spr40[dp[2]] >> 1) +\n                                     (spr8[dp[3]] << 1) +\n                                     (spr8[dp[4]]) +\n                                     (spr8[dp[5]] >> 1) +\n                                     (spr2[dp[6]]) +\n                                     (spr2[dp[7]] >> 1);\n                    odp[0] = (byte)(pword >> 16);\n                    odp[LINE_SIZE] = (byte)(pword >> 8);\n                    odp[LINE_SIZE*2] = (byte)(pword);\n                }\n                \/* Skip blank lines if any *\/\n                if ( num_blank_lines > 0 ) {\n                    \/* Do \"dot skips\" *\/\n                    while(num_blank_lines > 255) {\n                        gp_fputs(\"\\033e\\377\",prn_stream);\n                        num_blank_lines -= 255;\n                    }\n                    vtp = num_blank_lines;\n                    gp_fprintf(prn_stream,\"\\033e%c\",vtp);\n                    num_blank_lines = 0;\n                }\n\n                \/* Transfer raster graphics in the order R, G, B. *\/\n                \/* Apparently it is stored in B, G, R *\/\n                \/* Calculate the amount of data to send by what *\/\n                \/* Ghostscript tells us the scan line_size in (bytes) *\/\n\n                count = line_size \/ 3;\n                line_size_color_plane = count \/ 3;\n                cnt_2prn = line_size_color_plane * 3 + 5;\n                tempcnt = cnt_2prn;\n                cntc1 = (tempcnt & 0xFF00) >> 8;\n                cntc2 = (tempcnt & 0x00FF);\n                gp_fprintf(prn_stream, \"\\033[O%c%c\\200\\037\",cntc2,cntc1);\n                gp_fputc('\\000',prn_stream);\n                gp_fputs(\"\\124\\124\",prn_stream);\n\n                for ( row = plane_data + LINE_SIZE * 2, i = 0;\n                      i < 3; row -= LINE_SIZE, i++ ) {\n                    int jj;\n                    byte ctemp;\n                    odp = row;\n                    \/* Complement bytes *\/\n                    for (jj=0; jj< line_size_color_plane; jj++) {\n                        ctemp = *odp;\n                        *odp++ = ~ctemp;\n                    }\n                    gp_fwrite(row, sizeof(byte),\n                              line_size_color_plane, prn_stream);\n                }\n            }\n        }\n    }\n\n    \/* eject page *\/\n    gp_fputs(\"\\014\", prn_stream);\n\n    return 0;\n}","target":1,"code_token_length":1146,"total_token_length":1382,"max_tokens_setting":2048}
+{"idx":224482,"func":"static s64 ttml_get_timestamp(GF_TXTIn *ctx, char *value)\n{\n\tu32 h, m, s, ms, f, sf;\n\ts64 ts = -1;\n\tu32 len = (u32) strlen(value);\n\n\t\/\/tick metrick - cannot be fractional\n\tif (len && (value[len-1]=='t')) {\n\t\tvalue[len-1] = 0;\n\t\tts = (s64) (atoi(value) * 1000);\n\t\tvalue[len-1] = 't';\n\t\tif (ctx->tick_rate)\n\t\t\tts \/= ctx->tick_rate;\n\t}\n\t\/\/hours metric, can be fractional\n\telse if (len && (value[len-1]=='h')) {\n\t\tvalue[len-1] = 0;\n\t\tts = (s64) (atof(value) * 1000 * 3600);\n\t\tvalue[len-1] = 'h';\n\t}\n\t\/\/minutes metric, can be fractional\n\telse if (len && (value[len-1]=='m')) {\n\t\tvalue[len-1] = 0;\n\t\tts = (s64) (atof(value) * 1000 * 60);\n\t\tvalue[len-1] = 'm';\n\t}\n\telse if (len && (value[len-1]=='s')) {\n\t\t\/\/milliseconds metric, can be fractional but we work at 1ms clock resolution anyway\n\t\tif ((len > 1) && (value[len-2]=='m')) {\n\t\t\tvalue[len-2] = 0;\n\t\t\tts = (s64) (atof(value));\n\t\t\tvalue[len-2] = 'm';\n\t\t}\n\t\t\/\/seconds metric, can be fractional\n\t\telse {\n\t\t\tvalue[len-1] = 0;\n\t\t\tts = (s64) (atof(value) * 1000);\n\t\t\tvalue[len-1] = 's';\n\t\t}\n\t}\n\t\/\/frames metric, can be fractional\n\telse if (len && (value[len-1]=='f')) {\n\t\tf = sf = 0;\n\t\tvalue[len-1] = 0;\n\t\tif (sscanf(value, \"%u.%u\", &f, &sf) != 2) {\n\t\t\tsscanf(value, \"%u\", &f);\n\t\t\tsf = 0;\n\t\t}\n\t\tvalue[len-1] = 'f';\n\n\t\tif (!ctx->ttml_fps_num) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] time indicates frames but no frame rate set, assuming 25 FPS\\n\"));\n\t\t\tctx->ttml_fps_num = 25;\n\t\t\tctx->ttml_fps_den = 1;\n\t\t}\n\t\tif (sf && !ctx->ttml_sfps) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] time indicates subframes but no subFrameRate set, assuming 1\\n\"));\n\t\t\tctx->ttml_sfps = 1;\n\t\t}\n\t\tts = ((s64) 1000 * f * ctx->ttml_fps_den) \/ ctx->ttml_fps_num;\n\t\tif (sf)\n\t\t\tts += ((s64) 1000 * sf * ctx->ttml_fps_den \/ ctx->ttml_sfps) \/ ctx->ttml_fps_num;\n\t}\n\telse if (sscanf(value, \"%u:%u:%u.%u\", &h, &m, &s, &ms) == 4) {\n\t\tts = (h*3600 + m*60+s)*1000+ms;\n\t}\n\telse if (sscanf(value, \"%u:%u:%u:%u.%u\", &h, &m, &s, &f, &sf) == 5) {\n\t\tts = (h*3600 + m*60+s)*1000;\n\t\tif (!ctx->ttml_fps_num) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] time indicates frames but no frame rate set, assuming 25 FPS\\n\"));\n\t\t\tctx->ttml_fps_num = 25;\n\t\t\tctx->ttml_fps_den = 1;\n\t\t}\n\t\tif (!ctx->ttml_sfps) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] time indicates subframes but no subFrameRate set, assuming 1\\n\"));\n\t\t\tctx->ttml_sfps = 1;\n\t\t}\n\t\tts += ((s64) 1000 * f * ctx->ttml_fps_den) \/ ctx->ttml_fps_num;\n\t\tts += ((s64) 1000 * sf * ctx->ttml_fps_den \/ ctx->ttml_sfps) \/ ctx->ttml_fps_num;\n\t}\n\telse if (sscanf(value, \"%u:%u:%u:%u\", &h, &m, &s, &f) == 4) {\n\t\tts = (h*3600 + m*60+s)*1000;\n\t\tif (!ctx->ttml_fps_num) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] time indicates frames but no frame rate set, assuming 25 FPS\\n\"));\n\t\t\tctx->ttml_fps_num = 25;\n\t\t\tctx->ttml_fps_den = 1;\n\t\t}\n\t\tts += ((s64) 1000 * f * ctx->ttml_fps_den) \/ ctx->ttml_fps_num;\n\t}\n\telse if (sscanf(value, \"%u:%u:%u\", &h, &m, &s) == 3) {\n\t\tts = (h*3600 + m*60+s)*1000;\n\t}\n\treturn ts;\n}","target":0,"code_token_length":1280,"total_token_length":1516,"max_tokens_setting":2048}
+{"idx":430435,"func":"static int ip_tun_from_nlattr(const struct nlattr *attr,\n\t\t\t      struct sw_flow_match *match, bool is_mask,\n\t\t\t      bool log)\n{\n\tbool ttl = false, ipv4 = false, ipv6 = false;\n\tbool info_bridge_mode = false;\n\t__be16 tun_flags = 0;\n\tint opts_type = 0;\n\tstruct nlattr *a;\n\tint rem;\n\n\tnla_for_each_nested(a, attr, rem) {\n\t\tint type = nla_type(a);\n\t\tint err;\n\n\t\tif (type > OVS_TUNNEL_KEY_ATTR_MAX) {\n\t\t\tOVS_NLERR(log, \"Tunnel attr %d out of range max %d\",\n\t\t\t\t  type, OVS_TUNNEL_KEY_ATTR_MAX);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (!check_attr_len(nla_len(a),\n\t\t\t\t    ovs_tunnel_key_lens[type].len)) {\n\t\t\tOVS_NLERR(log, \"Tunnel attr %d has unexpected len %d expected %d\",\n\t\t\t\t  type, nla_len(a), ovs_tunnel_key_lens[type].len);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tswitch (type) {\n\t\tcase OVS_TUNNEL_KEY_ATTR_ID:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.tun_id,\n\t\t\t\t\tnla_get_be64(a), is_mask);\n\t\t\ttun_flags |= TUNNEL_KEY;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_IPV4_SRC:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.u.ipv4.src,\n\t\t\t\t\tnla_get_in_addr(a), is_mask);\n\t\t\tipv4 = true;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_IPV4_DST:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.u.ipv4.dst,\n\t\t\t\t\tnla_get_in_addr(a), is_mask);\n\t\t\tipv4 = true;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_IPV6_SRC:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.u.ipv6.src,\n\t\t\t\t\tnla_get_in6_addr(a), is_mask);\n\t\t\tipv6 = true;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_IPV6_DST:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.u.ipv6.dst,\n\t\t\t\t\tnla_get_in6_addr(a), is_mask);\n\t\t\tipv6 = true;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_TOS:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.tos,\n\t\t\t\t\tnla_get_u8(a), is_mask);\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_TTL:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.ttl,\n\t\t\t\t\tnla_get_u8(a), is_mask);\n\t\t\tttl = true;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT:\n\t\t\ttun_flags |= TUNNEL_DONT_FRAGMENT;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_CSUM:\n\t\t\ttun_flags |= TUNNEL_CSUM;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_TP_SRC:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.tp_src,\n\t\t\t\t\tnla_get_be16(a), is_mask);\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_TP_DST:\n\t\t\tSW_FLOW_KEY_PUT(match, tun_key.tp_dst,\n\t\t\t\t\tnla_get_be16(a), is_mask);\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_OAM:\n\t\t\ttun_flags |= TUNNEL_OAM;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS:\n\t\t\tif (opts_type) {\n\t\t\t\tOVS_NLERR(log, \"Multiple metadata blocks provided\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\terr = genev_tun_opt_from_nlattr(a, match, is_mask, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\n\t\t\ttun_flags |= TUNNEL_GENEVE_OPT;\n\t\t\topts_type = type;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS:\n\t\t\tif (opts_type) {\n\t\t\t\tOVS_NLERR(log, \"Multiple metadata blocks provided\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\terr = vxlan_tun_opt_from_nlattr(a, match, is_mask, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\n\t\t\ttun_flags |= TUNNEL_VXLAN_OPT;\n\t\t\topts_type = type;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_PAD:\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS:\n\t\t\tif (opts_type) {\n\t\t\t\tOVS_NLERR(log, \"Multiple metadata blocks provided\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\terr = erspan_tun_opt_from_nlattr(a, match, is_mask,\n\t\t\t\t\t\t\t log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\n\t\t\ttun_flags |= TUNNEL_ERSPAN_OPT;\n\t\t\topts_type = type;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE:\n\t\t\tinfo_bridge_mode = true;\n\t\t\tipv4 = true;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tOVS_NLERR(log, \"Unknown IP tunnel attribute %d\",\n\t\t\t\t  type);\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\tSW_FLOW_KEY_PUT(match, tun_key.tun_flags, tun_flags, is_mask);\n\tif (is_mask)\n\t\tSW_FLOW_KEY_MEMSET_FIELD(match, tun_proto, 0xff, true);\n\telse\n\t\tSW_FLOW_KEY_PUT(match, tun_proto, ipv6 ? AF_INET6 : AF_INET,\n\t\t\t\tfalse);\n\n\tif (rem > 0) {\n\t\tOVS_NLERR(log, \"IP tunnel attribute has %d unknown bytes.\",\n\t\t\t  rem);\n\t\treturn -EINVAL;\n\t}\n\n\tif (ipv4 && ipv6) {\n\t\tOVS_NLERR(log, \"Mixed IPv4 and IPv6 tunnel attributes\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (!is_mask) {\n\t\tif (!ipv4 && !ipv6) {\n\t\t\tOVS_NLERR(log, \"IP tunnel dst address not specified\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (ipv4) {\n\t\t\tif (info_bridge_mode) {\n\t\t\t\tif (match->key->tun_key.u.ipv4.src ||\n\t\t\t\t    match->key->tun_key.u.ipv4.dst ||\n\t\t\t\t    match->key->tun_key.tp_src ||\n\t\t\t\t    match->key->tun_key.tp_dst ||\n\t\t\t\t    match->key->tun_key.ttl ||\n\t\t\t\t    match->key->tun_key.tos ||\n\t\t\t\t    tun_flags & ~TUNNEL_KEY) {\n\t\t\t\t\tOVS_NLERR(log, \"IPv4 tun info is not correct\");\n\t\t\t\t\treturn -EINVAL;\n\t\t\t\t}\n\t\t\t} else if (!match->key->tun_key.u.ipv4.dst) {\n\t\t\t\tOVS_NLERR(log, \"IPv4 tunnel dst address is zero\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\t\tif (ipv6 && ipv6_addr_any(&match->key->tun_key.u.ipv6.dst)) {\n\t\t\tOVS_NLERR(log, \"IPv6 tunnel dst address is zero\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (!ttl && !info_bridge_mode) {\n\t\t\tOVS_NLERR(log, \"IP tunnel TTL not specified.\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\treturn opts_type;\n}","target":0,"code_token_length":1514,"total_token_length":1750,"max_tokens_setting":2048}
+{"idx":359595,"func":"DEFUN (show_bgp_memory, \n       show_bgp_memory_cmd,\n       \"show bgp memory\",\n       SHOW_STR\n       BGP_STR\n       \"Global BGP memory statistics\\n\")\n{\n  char memstrbuf[MTYPE_MEMSTR_LEN];\n  unsigned long count;\n  \n  \/* RIB related usage stats *\/\n  count = mtype_stats_alloc (MTYPE_BGP_NODE);\n  vty_out (vty, \"%ld RIB nodes, using %s of memory%s\", count,\n           mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct bgp_node)),\n           VTY_NEWLINE);\n  \n  count = mtype_stats_alloc (MTYPE_BGP_ROUTE);\n  vty_out (vty, \"%ld BGP routes, using %s of memory%s\", count,\n           mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct bgp_info)),\n           VTY_NEWLINE);\n  if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))\n    vty_out (vty, \"%ld BGP route ancillaries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (struct bgp_info_extra)),\n             VTY_NEWLINE);\n  \n  if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))\n    vty_out (vty, \"%ld Static routes, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct bgp_static)),\n             VTY_NEWLINE);\n  \n  \/* Adj-In\/Out *\/\n  if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))\n    vty_out (vty, \"%ld Adj-In entries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (struct bgp_adj_in)),\n             VTY_NEWLINE);\n  if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))\n    vty_out (vty, \"%ld Adj-Out entries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (struct bgp_adj_out)),\n             VTY_NEWLINE);\n  \n  if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))\n    vty_out (vty, \"%ld Nexthop cache entries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct bgp_nexthop_cache)),\n             VTY_NEWLINE);\n\n  if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))\n    vty_out (vty, \"%ld Dampening entries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct bgp_damp_info)),\n             VTY_NEWLINE);\n\n  \/* Attributes *\/\n  count = attr_count();\n  vty_out (vty, \"%ld BGP attributes, using %s of memory%s\", count, \n           mtype_memstr (memstrbuf, sizeof (memstrbuf), \n                         count * sizeof(struct attr)), \n           VTY_NEWLINE);\n  if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))\n    vty_out (vty, \"%ld BGP extra attributes, using %s of memory%s\", count, \n             mtype_memstr (memstrbuf, sizeof (memstrbuf), \n                           count * sizeof(struct attr_extra)), \n             VTY_NEWLINE);\n  \n  if ((count = attr_unknown_count()))\n    vty_out (vty, \"%ld unknown attributes%s\", count, VTY_NEWLINE);\n  \n  \/* AS_PATH attributes *\/\n  count = aspath_count ();\n  vty_out (vty, \"%ld BGP AS-PATH entries, using %s of memory%s\", count,\n           mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct aspath)),\n           VTY_NEWLINE);\n  \n  count = mtype_stats_alloc (MTYPE_AS_SEG);\n  vty_out (vty, \"%ld BGP AS-PATH segments, using %s of memory%s\", count,\n           mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct assegment)),\n           VTY_NEWLINE);\n  \n  \/* Other attributes *\/\n  if ((count = community_count ()))\n    vty_out (vty, \"%ld BGP community entries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct community)),\n             VTY_NEWLINE);\n  if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))\n    vty_out (vty, \"%ld BGP community entries, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct ecommunity)),\n             VTY_NEWLINE);\n  \n  if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))\n    vty_out (vty, \"%ld Cluster lists, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct cluster_list)),\n             VTY_NEWLINE);\n  \n  \/* Peer related usage *\/\n  count = mtype_stats_alloc (MTYPE_BGP_PEER);\n  vty_out (vty, \"%ld peers, using %s of memory%s\", count,\n           mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                         count * sizeof (struct peer)),\n           VTY_NEWLINE);\n  \n  if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))\n    vty_out (vty, \"%ld peer groups, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (struct peer_group)),\n             VTY_NEWLINE);\n  \n  \/* Other *\/\n  if ((count = mtype_stats_alloc (MTYPE_HASH)))\n    vty_out (vty, \"%ld hash tables, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (struct hash)),\n             VTY_NEWLINE);\n  if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))\n    vty_out (vty, \"%ld hash buckets, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (struct hash_backet)),\n             VTY_NEWLINE);\n  if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))\n    vty_out (vty, \"%ld compiled regexes, using %s of memory%s\", count,\n             mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                           count * sizeof (regex_t)),\n             VTY_NEWLINE);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":1544,"total_token_length":1780,"max_tokens_setting":2048}
+{"idx":439057,"func":"ModuleExport size_t RegisterRAWImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=SetMagickInfo(\"R\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw red samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"C\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw cyan samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"G\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw green samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"M\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw magenta samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"B\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw blue samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"Y\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw yellow samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"A\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw alpha samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"O\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw opacity samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"K\");\n  entry->decoder=(DecodeImageHandler *) ReadRAWImage;\n  entry->encoder=(EncodeImageHandler *) WriteRAWImage;\n  entry->raw=MagickTrue;\n  entry->endian_support=MagickTrue;\n  entry->format_type=ImplicitFormatType;\n  entry->description=ConstantString(\"Raw black samples\");\n  entry->module=ConstantString(\"RAW\");\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":911,"total_token_length":1147,"max_tokens_setting":2048}
+{"idx":242970,"func":"int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl )\n{\n    if( ssl->in_msglen < mbedtls_ssl_hs_hdr_len( ssl ) )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"handshake message too short: %\" MBEDTLS_PRINTF_SIZET,\n                            ssl->in_msglen ) );\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n    }\n\n    ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + ssl_get_hs_total_len( ssl );\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"handshake message: msglen =\"\n                        \" %\" MBEDTLS_PRINTF_SIZET \", type = %u, hslen = %\" MBEDTLS_PRINTF_SIZET,\n                        ssl->in_msglen, ssl->in_msg[0], ssl->in_hslen ) );\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n        unsigned int recv_msg_seq = ( ssl->in_msg[4] << 8 ) | ssl->in_msg[5];\n\n        if( ssl_check_hs_header( ssl ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"invalid handshake header\" ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n\n        if( ssl->handshake != NULL &&\n            ( ( ssl->state   != MBEDTLS_SSL_HANDSHAKE_OVER &&\n                recv_msg_seq != ssl->handshake->in_msg_seq ) ||\n              ( ssl->state  == MBEDTLS_SSL_HANDSHAKE_OVER &&\n                ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) ) )\n        {\n            if( recv_msg_seq > ssl->handshake->in_msg_seq )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 2, ( \"received future handshake message of sequence number %u (next %u)\",\n                                            recv_msg_seq,\n                                            ssl->handshake->in_msg_seq ) );\n                return( MBEDTLS_ERR_SSL_EARLY_MESSAGE );\n            }\n\n            \/* Retransmit only on last message from previous flight, to avoid\n             * too many retransmissions.\n             * Besides, No sane server ever retransmits HelloVerifyRequest *\/\n            if( recv_msg_seq == ssl->handshake->in_flight_start_seq - 1 &&\n                ssl->in_msg[0] != MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 2, ( \"received message from last flight, \"\n                                    \"message_seq = %u, start_of_flight = %u\",\n                                    recv_msg_seq,\n                                    ssl->handshake->in_flight_start_seq ) );\n\n                if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 )\n                {\n                    MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_resend\", ret );\n                    return( ret );\n                }\n            }\n            else\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 2, ( \"dropping out-of-sequence message: \"\n                                    \"message_seq = %u, expected = %u\",\n                                    recv_msg_seq,\n                                    ssl->handshake->in_msg_seq ) );\n            }\n\n            return( MBEDTLS_ERR_SSL_CONTINUE_PROCESSING );\n        }\n        \/* Wait until message completion to increment in_msg_seq *\/\n\n        \/* Message reassembly is handled alongside buffering of future\n         * messages; the commonality is that both handshake fragments and\n         * future messages cannot be forwarded immediately to the\n         * handshake logic layer. *\/\n        if( ssl_hs_is_proper_fragment( ssl ) == 1 )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"found fragmented DTLS handshake message\" ) );\n            return( MBEDTLS_ERR_SSL_EARLY_MESSAGE );\n        }\n    }\n    else\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n    \/* With TLS we don't handle fragmentation (for now) *\/\n    if( ssl->in_msglen < ssl->in_hslen )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"TLS handshake fragmentation not supported\" ) );\n        return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );\n    }\n\n    return( 0 );\n}","target":0,"code_token_length":907,"total_token_length":1143,"max_tokens_setting":2048}
+{"idx":219010,"func":"Status ConstantFolding::MaterializeShapes(const GraphProperties& properties) {\n  \/\/ We may add some nodes to the graph to encode control dependencies and hold\n  \/\/ the materialized shapes: there is no need to process these added nodes, so\n  \/\/ only iterate over the nodes of the input graph.\n  const int node_count = graph_->node_size();\n  for (int node_idx = 0; node_idx < node_count; ++node_idx) {\n    NodeDef* node = graph_->mutable_node(node_idx);\n    const string op = node->op();\n    if (op != \"Shape\" && op != \"Size\" && op != \"Rank\" && op != \"ShapeN\" &&\n        op != \"TensorArraySizeV3\") {\n      continue;\n    }\n    const std::vector<OpInfo::TensorProperties>& output =\n        properties.GetOutputProperties(node->name());\n    const std::vector<OpInfo::TensorProperties>& input =\n        properties.GetInputProperties(node->name());\n    if (input.empty() || output.empty()) {\n      continue;\n    }\n\n    if (op == \"Shape\" || op == \"Size\" || op == \"Rank\") {\n      CHECK_EQ(1, output.size());\n      CHECK_EQ(1, input.size());\n\n      const DataType type = output[0].dtype();\n      CHECK(type == DT_INT32 || type == DT_INT64);\n      const PartialTensorShape shape(input[0].shape());\n\n      if ((op != \"Rank\" && !shape.IsFullyDefined()) ||\n          (op == \"Rank\" && shape.unknown_rank())) {\n        continue;\n      }\n\n      Tensor constant_value(type);\n      if (!ConvertShapeToConstant(op, type, shape, &constant_value).ok()) {\n        continue;\n      }\n\n      \/\/ TODO(rmlarsen): Remove this workaround for b\/150861569\n      \/\/ The bug involves an expression of the form Shape(ExpandDims(x)\n      \/\/ with an incorrectly inferred zero-size first dimension.\n      if (op == \"Shape\") {\n        if (shape.dims() > 0 && shape.dim_size(0) == 0) continue;\n      }\n\n      \/\/ Repurpose the existing node to be the constant.\n      \/\/ Device placement is preserved.\n      graph_modified_ = true;\n      node->set_op(\"Const\");\n      EraseRegularNodeAttributes(node);\n      (*node->mutable_attr())[\"dtype\"].set_type(type);\n      constant_value.AsProtoTensorContent(\n          (*node->mutable_attr())[\"value\"].mutable_tensor());\n\n      \/\/ Turn the data input into a control dependency: this is needed to\n      \/\/ ensure that the constant value will only be run in the\n      \/\/ cases where the shape\/rank\/size would have been run in\n      \/\/ the original graph.\n      string ctrl_dep =\n          AddControlDependency(node->input(0), graph_, node_map_.get());\n      node_map_->UpdateInput(node->name(), node->input(0), ctrl_dep);\n      node->set_input(0, ctrl_dep);\n      \/\/ Done with the Shape\/Size\/Rank node, move to the next node.\n      continue;\n    }\n\n    if (op == \"TensorArraySizeV3\") {\n      const NodeDef* array = CHECK_NOTNULL(node_map_->GetNode(node->input(0)));\n      if (array->input_size() == 0 ||\n          (array->attr().count(\"dynamic_size\") != 0 &&\n           array->attr().at(\"dynamic_size\").b())) {\n        continue;\n      }\n      const NodeDef* array_size =\n          CHECK_NOTNULL(node_map_->GetNode(array->input(0)));\n      if (IsReallyConstant(*array_size)) {\n        \/\/ Don't materialize 0 sizes to avoid triggering incorrect static\n        \/\/ checks. A 0 sized array that can't grow isn't useful anyway.\n        if (array_size->attr().count(\"value\") == 0) {\n          continue;\n        }\n        const TensorProto& raw_val = array_size->attr().at(\"value\").tensor();\n        if (raw_val.dtype() != DT_INT32) {\n          continue;\n        }\n        Tensor value(raw_val.dtype(), raw_val.tensor_shape());\n        if (!value.FromProto(raw_val)) {\n          continue;\n        }\n        if (value.flat<int32>()(0) == 0) {\n          continue;\n        }\n\n        graph_modified_ = true;\n        node->set_op(\"Const\");\n        *node->mutable_attr() = array_size->attr();\n        node->set_input(0, AsControlDependency(NodeName(node->input(0))));\n        node->set_input(1, AddControlDependency(NodeName(node->input(1)),\n                                                graph_, node_map_.get()));\n      }\n      continue;\n    }\n\n    \/\/ Handle ShapeN materialization case.\n    \/\/ It's possible that not all input tensors have known shapes.\n    CHECK_EQ(op, \"ShapeN\");\n    CHECK_EQ(input.size(), output.size());\n    const NodeDef* const shape_n_node = node;\n    for (int port_idx = 0, idx_limit = output.size(); port_idx < idx_limit;\n         ++port_idx) {\n      const DataType type = output[port_idx].dtype();\n      CHECK(type == DT_INT32 || type == DT_INT64);\n      const PartialTensorShape shape(input[port_idx].shape());\n      if (!shape.IsFullyDefined()) {\n        continue;\n      }\n      Tensor constant_value(type);\n      auto status = ConvertShapeToConstant(op, type, shape, &constant_value);\n      if (!status.ok()) {\n        continue;\n      }\n\n      \/\/ We make a copy because we mutate the nodes.\n      auto fanouts = node_map_->GetOutputs(shape_n_node->name());\n      \/\/ Find all nodes consuming this shape and connect them through the new\n      \/\/ constant node instead.\n      for (NodeDef* output : fanouts) {\n        \/\/ Track whether there are any direct edges left between shape_n_node\n        \/\/ and this output node after the transformation.\n        bool direct_edges_exist = false;\n        for (int k = 0; k < output->input_size(); ++k) {\n          int port;\n          const string node_name = ParseNodeName(output->input(k), &port);\n          if (node_name == shape_n_node->name() && port == port_idx) {\n            \/\/ Create a const node as ShapeN's output if not already.\n            const string const_name = OptimizedNodeName(\n                *shape_n_node, strings::StrCat(\"-matshapes-\", port_idx));\n            if (node_map_->GetNode(const_name) == nullptr) {\n              NodeDef* added_node = graph_->add_node();\n              added_node->set_name(const_name);\n              added_node->set_op(\"Const\");\n              added_node->set_device(shape_n_node->device());\n              node_map_->AddNode(added_node->name(), added_node);\n              (*added_node->mutable_attr())[\"dtype\"].set_type(type);\n              constant_value.AsProtoTensorContent(\n                  (*added_node->mutable_attr())[\"value\"].mutable_tensor());\n              \/\/ We add a control dependency to the original ShapeN node,\n              \/\/ so that the node will only be run if all inputs of the\n              \/\/ original ShapeN node are run.\n              string ctrl_dep = AddControlDependency(shape_n_node->name(),\n                                                     graph_, node_map_.get());\n              *added_node->add_input() = ctrl_dep;\n              node_map_->AddOutput(NodeName(ctrl_dep), added_node->name());\n            }\n            *output->mutable_input(k) = const_name;\n            node_map_->AddOutput(const_name, output->name());\n            graph_modified_ = true;\n          }\n          if (node_name == shape_n_node->name() && port != port_idx) {\n            direct_edges_exist = true;\n          }\n        }\n        if (!direct_edges_exist) {\n          node_map_->RemoveOutput(node->name(), output->name());\n        }\n      }\n    }\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":1659,"total_token_length":1895,"max_tokens_setting":2048}
+{"idx":267862,"func":"Status ModularFrameDecoder::DecodeGroup(const Rect& rect, BitReader* reader,\n                                        int minShift, int maxShift,\n                                        const ModularStreamId& stream,\n                                        bool zerofill,\n                                        PassesDecoderState* dec_state,\n                                        ImageBundle* output) {\n  JXL_DASSERT(stream.kind == ModularStreamId::kModularDC ||\n              stream.kind == ModularStreamId::kModularAC);\n  const size_t xsize = rect.xsize();\n  const size_t ysize = rect.ysize();\n  Image gi(xsize, ysize, full_image.bitdepth, 0);\n  \/\/ start at the first bigger-than-groupsize non-metachannel\n  size_t c = full_image.nb_meta_channels;\n  for (; c < full_image.channel.size(); c++) {\n    Channel& fc = full_image.channel[c];\n    if (fc.w > frame_dim.group_dim || fc.h > frame_dim.group_dim) break;\n  }\n  size_t beginc = c;\n  for (; c < full_image.channel.size(); c++) {\n    Channel& fc = full_image.channel[c];\n    int shift = std::min(fc.hshift, fc.vshift);\n    if (shift > maxShift) continue;\n    if (shift < minShift) continue;\n    Rect r(rect.x0() >> fc.hshift, rect.y0() >> fc.vshift,\n           rect.xsize() >> fc.hshift, rect.ysize() >> fc.vshift, fc.w, fc.h);\n    if (r.xsize() == 0 || r.ysize() == 0) continue;\n    if (zerofill && use_full_image) {\n      for (size_t y = 0; y < r.ysize(); ++y) {\n        pixel_type* const JXL_RESTRICT row_out = r.Row(&fc.plane, y);\n        memset(row_out, 0, r.xsize() * sizeof(*row_out));\n      }\n    } else {\n      Channel gc(r.xsize(), r.ysize());\n      if (zerofill) ZeroFillImage(&gc.plane);\n      gc.hshift = fc.hshift;\n      gc.vshift = fc.vshift;\n      gi.channel.emplace_back(std::move(gc));\n    }\n  }\n  if (zerofill && use_full_image) return true;\n  ModularOptions options;\n  if (!zerofill) {\n    if (!ModularGenericDecompress(\n            reader, gi, \/*header=*\/nullptr, stream.ID(frame_dim), &options,\n            \/*undo_transforms=*\/-1, &tree, &code, &context_map)) {\n      return JXL_FAILURE(\"Failed to decode modular group\");\n    }\n  }\n  \/\/ Undo global transforms that have been pushed to the group level\n  if (!use_full_image) {\n    for (auto t : global_transform) {\n      JXL_RETURN_IF_ERROR(t.Inverse(gi, global_header.wp_header));\n    }\n    JXL_RETURN_IF_ERROR(ModularImageToDecodedRect(\n        gi, dec_state, nullptr, output, rect.Crop(dec_state->decoded)));\n    return true;\n  }\n  int gic = 0;\n  for (c = beginc; c < full_image.channel.size(); c++) {\n    Channel& fc = full_image.channel[c];\n    int shift = std::min(fc.hshift, fc.vshift);\n    if (shift > maxShift) continue;\n    if (shift < minShift) continue;\n    Rect r(rect.x0() >> fc.hshift, rect.y0() >> fc.vshift,\n           rect.xsize() >> fc.hshift, rect.ysize() >> fc.vshift, fc.w, fc.h);\n    if (r.xsize() == 0 || r.ysize() == 0) continue;\n    JXL_ASSERT(use_full_image);\n    CopyImageTo(\/*rect_from=*\/Rect(0, 0, r.xsize(), r.ysize()),\n                \/*from=*\/gi.channel[gic].plane,\n                \/*rect_to=*\/r, \/*to=*\/&fc.plane);\n    gic++;\n  }\n  return true;\n}","target":0,"code_token_length":852,"total_token_length":1088,"max_tokens_setting":2048}
+{"idx":353195,"func":"void SplashOutputDev::type3D1(GfxState *state, double wx, double wy,\n\t\t\t      double llx, double lly, double urx, double ury) {\n  T3FontCache *t3Font;\n  SplashColor color;\n  double xt, yt, xMin, xMax, yMin, yMax, x1, y1;\n  int i, j;\n\n  \/\/ ignore multiple d0\/d1 operators\n  if (!t3GlyphStack || t3GlyphStack->haveDx) {\n    return;\n  }\n  t3GlyphStack->haveDx = true;\n  \/\/ don't cache if we got a gsave\/grestore before the d1\n  if (t3GlyphStack->doNotCache) {\n    return;\n  }\n\n  if (unlikely(t3GlyphStack == nullptr)) {\n    error(errSyntaxWarning, -1, \"t3GlyphStack was null in SplashOutputDev::type3D1\");\n    return;\n  }\n\n  if (unlikely(t3GlyphStack->origBitmap != nullptr)) {\n    error(errSyntaxWarning, -1, \"t3GlyphStack origBitmap was not null in SplashOutputDev::type3D1\");\n    return;\n  }\n\n  if (unlikely(t3GlyphStack->origSplash != nullptr)) {\n    error(errSyntaxWarning, -1, \"t3GlyphStack origSplash was not null in SplashOutputDev::type3D1\");\n    return;\n  }\n\n  t3Font = t3GlyphStack->cache;\n\n  \/\/ check for a valid bbox\n  state->transform(0, 0, &xt, &yt);\n  state->transform(llx, lly, &x1, &y1);\n  xMin = xMax = x1;\n  yMin = yMax = y1;\n  state->transform(llx, ury, &x1, &y1);\n  if (x1 < xMin) {\n    xMin = x1;\n  } else if (x1 > xMax) {\n    xMax = x1;\n  }\n  if (y1 < yMin) {\n    yMin = y1;\n  } else if (y1 > yMax) {\n    yMax = y1;\n  }\n  state->transform(urx, lly, &x1, &y1);\n  if (x1 < xMin) {\n    xMin = x1;\n  } else if (x1 > xMax) {\n    xMax = x1;\n  }\n  if (y1 < yMin) {\n    yMin = y1;\n  } else if (y1 > yMax) {\n    yMax = y1;\n  }\n  state->transform(urx, ury, &x1, &y1);\n  if (x1 < xMin) {\n    xMin = x1;\n  } else if (x1 > xMax) {\n    xMax = x1;\n  }\n  if (y1 < yMin) {\n    yMin = y1;\n  } else if (y1 > yMax) {\n    yMax = y1;\n  }\n  if (xMin - xt < t3Font->glyphX ||\n      yMin - yt < t3Font->glyphY ||\n      xMax - xt > t3Font->glyphX + t3Font->glyphW ||\n      yMax - yt > t3Font->glyphY + t3Font->glyphH) {\n    if (t3Font->validBBox) {\n      error(errSyntaxWarning, -1, \"Bad bounding box in Type 3 glyph\");\n    }\n    return;\n  }\n\n  if (t3Font->cacheTags == nullptr)\n    return;\n\n  \/\/ allocate a cache entry\n  i = (t3GlyphStack->code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc;\n  for (j = 0; j < t3Font->cacheAssoc; ++j) {\n    if ((t3Font->cacheTags[i+j].mru & 0x7fff) == t3Font->cacheAssoc - 1) {\n      t3Font->cacheTags[i+j].mru = 0x8000;\n      t3Font->cacheTags[i+j].code = t3GlyphStack->code;\n      t3GlyphStack->cacheTag = &t3Font->cacheTags[i+j];\n      t3GlyphStack->cacheData = t3Font->cacheData + (i+j) * t3Font->glyphSize;\n    } else {\n      ++t3Font->cacheTags[i+j].mru;\n    }\n  }\n\n  \/\/ save state\n  t3GlyphStack->origBitmap = bitmap;\n  t3GlyphStack->origSplash = splash;\n  const double *ctm = state->getCTM();\n  t3GlyphStack->origCTM4 = ctm[4];\n  t3GlyphStack->origCTM5 = ctm[5];\n\n  \/\/ create the temporary bitmap\n  if (colorMode == splashModeMono1) {\n    bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,\n\t\t\t      splashModeMono1, false);\n    splash = new Splash(bitmap, false,\n\t\t\tt3GlyphStack->origSplash->getScreen());\n    color[0] = 0;\n    splash->clear(color);\n    color[0] = 0xff;\n  } else {\n    bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,\n\t\t\t      splashModeMono8, false);\n    splash = new Splash(bitmap, vectorAntialias,\n\t\t\tt3GlyphStack->origSplash->getScreen());\n    color[0] = 0x00;\n    splash->clear(color);\n    color[0] = 0xff;\n  }\n  splash->setMinLineWidth(s_minLineWidth);\n  splash->setThinLineMode(splashThinLineDefault);\n  splash->setFillPattern(new SplashSolidColor(color));\n  splash->setStrokePattern(new SplashSolidColor(color));\n  \/\/~ this should copy other state from t3GlyphStack->origSplash?\n  state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3],\n\t\t-t3Font->glyphX, -t3Font->glyphY);\n  updateCTM(state, 0, 0, 0, 0, 0, 0);\n  ++nestCount;\n}","target":0,"code_token_length":1376,"total_token_length":1612,"max_tokens_setting":2048}
+{"idx":212829,"func":" *\/\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t**pce;\n\tzval\t\t\t\t*obj;\n\tzval\t\t\t\t*tmp;\n\tTSRMLS_FETCH();\n\n\/* OBJECTS_FIXME *\/\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||\n\t\t!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||\n\t  \t!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||\n\t\t!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||\n\t\t!strcmp(name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (!ent1->data) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp(name, EL_BINARY)) {\n\t\t\tint new_len=0;\n\t\t\tunsigned char *new_str;\n\n\t\t\tnew_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);\n\t\t\tSTR_FREE(Z_STRVAL_P(ent1->data));\n\t\t\tZ_STRVAL_P(ent1->data) = new_str;\n\t\t\tZ_STRLEN_P(ent1->data) = new_len;\n\t\t}\n\n\t\t\/* Call __wakeup() method on the object. *\/\n\t\tif (Z_TYPE_P(ent1->data) == IS_OBJECT) {\n\t\t\tzval *fname, *retval = NULL;\n\n\t\t\tMAKE_STD_ZVAL(fname);\n\t\t\tZVAL_STRING(fname, \"__wakeup\", 1);\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);\n\n\t\t\tzval_dtor(fname);\n\t\t\tFREE_ZVAL(fname);\n\t\t\tif (retval) {\n\t\t\t\tzval_ptr_dtor(&retval);\n\t\t\t}\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t\/* if non-existent field *\/\n\t\t\tif (ent2->type == ST_FIELD && ent2->data == NULL) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\tif (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),\n\t\t\t\t\t\t\t\t\t\t   Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = &PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\/* Initialize target object *\/\n\t\t\t\t\t\tMAKE_STD_ZVAL(obj);\n\t\t\t\t\t\tobject_init_ex(obj, *pce);\n\n\t\t\t\t\t\t\/* Merge current hashtable with object's default properties *\/\n\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP_P(obj),\n\t\t\t\t\t\t\t\t\t\tZ_ARRVAL_P(ent2->data),\n\t\t\t\t\t\t\t\t\t\t(void (*)(void *)) zval_add_ref,\n\t\t\t\t\t\t\t\t\t\t(void *) &tmp, sizeof(zval *), 0);\n\n\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\tphp_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\/* Clean up old array entry *\/\n\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t\/* Set stack entry to point to the newly created object *\/\n\t\t\t\t\t\tent2->data = obj;\n\n\t\t\t\t\t\t\/* Clean up class name var entry *\/\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE_P(ent2->data);\n\t\t\t\t\t\tZ_DELREF_P(ent1->data);\n\t\t\t\t\t\tadd_property_zval(ent2->data, ent1->varname, ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp(name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}","target":1,"code_token_length":1241,"total_token_length":1477,"max_tokens_setting":2048}
+{"idx":513313,"func":"make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,\n                              table_map tables, table_map used_table,\n                              int join_tab_idx_arg,\n                              bool exclude_expensive_cond __attribute__\n                              ((unused)),\n                              bool retain_ref_cond,\n                              bool is_top_and_level)\n\n{\n  table_map rand_table_bit= (table_map) RAND_TABLE_BIT;\n\n  if (used_table && !(cond->used_tables() & used_table))\n    return (COND*) 0;\t\t\t\t\/\/ Already checked\n\n  if (cond->type() == Item::COND_ITEM)\n  {\n    if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)\n    {\n      \/* Create new top level AND item *\/\n      Item_cond_and *new_cond=new (thd->mem_root) Item_cond_and(thd);\n      if (!new_cond)\n\treturn (COND*) 0;\t\t\t\/\/ OOM \/* purecov: inspected *\/\n      List_iterator<Item> li(*((Item_cond*) cond)->argument_list());\n      Item *item;\n      while ((item=li++))\n      {\n        \/*\n          Special handling of top level conjuncts with RAND_TABLE_BIT:\n          if such a conjunct contains a reference to a field that is not\n          an outer field then it is pushed to the corresponding table by\n          the same rule as all other conjuncts. Otherwise, if the conjunct\n          is used in WHERE is is pushed to the last joined table, if is it\n          is used in ON condition of an outer join it is pushed into the\n          last inner table of the outer join. Such conjuncts are pushed in\n          a call of make_cond_for_table_from_pred() with the\n          parameter 'used_table' equal to PSEUDO_TABLE_BITS.\n        *\/\n        if (is_top_and_level && used_table == rand_table_bit &&\n            (item->used_tables() & ~OUTER_REF_TABLE_BIT) != rand_table_bit)\n        {\n          \/* The conjunct with RAND_TABLE_BIT has been allready pushed *\/\n          continue;\n        }\n\tItem *fix=make_cond_for_table_from_pred(thd, root_cond, item, \n                                                tables, used_table,\n                                                join_tab_idx_arg,\n                                                exclude_expensive_cond,\n                                                retain_ref_cond, false);\n\tif (fix)\n\t  new_cond->argument_list()->push_back(fix, thd->mem_root);\n      }\n      switch (new_cond->argument_list()->elements) {\n      case 0:\n\treturn (COND*) 0;\t\t\t\/\/ Always true\n      case 1:\n\treturn new_cond->argument_list()->head();\n      default:\n\t\/*\n          Call fix_fields to propagate all properties of the children to\n          the new parent Item. This should not be expensive because all\n\t  children of Item_cond_and should be fixed by now.\n\t*\/\n\tif (new_cond->fix_fields(thd, 0))\n          return (COND*) 0;\n\tnew_cond->used_tables_cache=\n\t  ((Item_cond_and*) cond)->used_tables_cache &\n\t  tables;\n\treturn new_cond;\n      }\n    }\n    else\n    {\t\t\t\t\t\t\/\/ Or list\n      if (is_top_and_level && used_table == rand_table_bit &&\n          (cond->used_tables() & ~OUTER_REF_TABLE_BIT) != rand_table_bit)\n      {\n        \/* This top level formula with RAND_TABLE_BIT has been already pushed *\/\n        return (COND*) 0;\n      }\n\n      Item_cond_or *new_cond=new (thd->mem_root) Item_cond_or(thd);\n      if (!new_cond)\n\treturn (COND*) 0;\t\t\t\/\/ OOM \/* purecov: inspected *\/\n      List_iterator<Item> li(*((Item_cond*) cond)->argument_list());\n      Item *item;\n      while ((item=li++))\n      {\n\tItem *fix=make_cond_for_table_from_pred(thd, root_cond, item,\n                                                tables, 0L,\n                                                join_tab_idx_arg,\n                                                exclude_expensive_cond,\n                                                retain_ref_cond, false);\n\tif (!fix)\n\t  return (COND*) 0;\t\t\t\/\/ Always true\n\tnew_cond->argument_list()->push_back(fix, thd->mem_root);\n      }\n      \/*\n        Call fix_fields to propagate all properties of the children to\n        the new parent Item. This should not be expensive because all\n        children of Item_cond_and should be fixed by now.\n      *\/\n      new_cond->fix_fields(thd, 0);\n      new_cond->used_tables_cache= ((Item_cond_or*) cond)->used_tables_cache;\n      new_cond->top_level_item();\n      return new_cond;\n    }\n  }\n\n  if (is_top_and_level && used_table == rand_table_bit &&\n      (cond->used_tables() & ~OUTER_REF_TABLE_BIT) != rand_table_bit)\n  {\n    \/* This top level formula with RAND_TABLE_BIT has been already pushed *\/\n    return (COND*) 0;\n  }\n\n  \/*\n    Because the following test takes a while and it can be done\n    table_count times, we mark each item that we have examined with the result\n    of the test\n  *\/\n  if ((cond->marker == 3 && !retain_ref_cond) ||\n      (cond->used_tables() & ~tables))\n    return (COND*) 0;\t\t\t\t\/\/ Can't check this yet\n\n  if (cond->marker == 2 || cond->eq_cmp_result() == Item::COND_OK)\n  {\n    cond->set_join_tab_idx(join_tab_idx_arg);\n    return cond;\t\t\t\t\/\/ Not boolean op\n  }\n\n  if (cond->type() == Item::FUNC_ITEM && \n      ((Item_func*) cond)->functype() == Item_func::EQ_FUNC)\n  {\n    Item *left_item=\t((Item_func*) cond)->arguments()[0]->real_item();\n    Item *right_item= ((Item_func*) cond)->arguments()[1]->real_item();\n    if (left_item->type() == Item::FIELD_ITEM && !retain_ref_cond &&\n\ttest_if_ref(root_cond, (Item_field*) left_item,right_item))\n    {\n      cond->marker=3;\t\t\t\/\/ Checked when read\n      return (COND*) 0;\n    }\n    if (right_item->type() == Item::FIELD_ITEM && !retain_ref_cond &&\n\ttest_if_ref(root_cond, (Item_field*) right_item,left_item))\n    {\n      cond->marker=3;\t\t\t\/\/ Checked when read\n      return (COND*) 0;\n    }\n  }\n  cond->marker=2;\n  cond->set_join_tab_idx(join_tab_idx_arg);\n  return cond;\n}","target":0,"code_token_length":1377,"total_token_length":1613,"max_tokens_setting":2048}
+{"idx":281614,"func":"void CLASS apply_tiff()\n{\n  int max_samp=0, raw=-1, thm=-1, i;\n  struct jhead jh;\n\n  thumb_misc = 16;\n  if (thumb_offset) {\n    fseek (ifp, thumb_offset, SEEK_SET);\n    if (ljpeg_start (&jh, 1)) {\n      if((unsigned)jh.bits<17 && (unsigned)jh.wide < 0x10000 && (unsigned)jh.high < 0x10000)\n        {\n          thumb_misc   = jh.bits;\n          thumb_width  = jh.wide;\n          thumb_height = jh.high;\n        }\n    }\n  }\n  for (i=0; i < tiff_nifds; i++) {\n    if (max_samp < tiff_ifd[i].samples)\n\tmax_samp = tiff_ifd[i].samples;\n    if (max_samp > 3) max_samp = 3;\n    if ((tiff_ifd[i].comp != 6 || tiff_ifd[i].samples != 3) &&\n        unsigned(tiff_ifd[i].t_width | tiff_ifd[i].t_height) < 0x10000 &&\n        (unsigned)tiff_ifd[i].bps < 33 && (unsigned)tiff_ifd[i].samples < 13 &&\n\ttiff_ifd[i].t_width*tiff_ifd[i].t_height > raw_width*raw_height) {\n      raw_width     = tiff_ifd[i].t_width;\n      raw_height    = tiff_ifd[i].t_height;\n      tiff_bps      = tiff_ifd[i].bps;\n      tiff_compress = tiff_ifd[i].comp;\n      data_offset   = tiff_ifd[i].offset;\n      tiff_flip     = tiff_ifd[i].t_flip;\n      tiff_samples  = tiff_ifd[i].samples;\n      tile_width    = tiff_ifd[i].t_tile_width;\n      tile_length   = tiff_ifd[i].t_tile_length;\n#ifdef LIBRAW_LIBRARY_BUILD\n      data_size     = tile_length < INT_MAX && tile_length>0 ? tiff_ifd[i].tile_maxbytes: tiff_ifd[i].bytes;\n#endif\n      raw = i;\n    }\n  }\n  if (!tile_width ) tile_width  = INT_MAX;\n  if (!tile_length) tile_length = INT_MAX;\n  for (i=tiff_nifds; i--; )\n    if (tiff_ifd[i].t_flip) tiff_flip = tiff_ifd[i].t_flip;\n  if (raw >= 0 && !load_raw)\n    switch (tiff_compress) {\n      case 32767:\n\tif (tiff_ifd[raw].bytes == raw_width*raw_height) {\n\t  tiff_bps = 12;\n\t  load_raw = &CLASS sony_arw2_load_raw;\t\t\tbreak;\n\t}\n\tif (tiff_ifd[raw].bytes*8 != raw_width*raw_height*tiff_bps) {\n\t  raw_height += 8;\n\t  load_raw = &CLASS sony_arw_load_raw;\t\t\tbreak;\n\t}\n\tload_flags = 79;\n      case 32769:\n\tload_flags++;\n      case 32770:\n      case 32773: goto slr;\n      case 0:  case 1:\n\tif (!strncmp(make,\"OLYMPUS\",7) &&\n\t\ttiff_ifd[raw].bytes*2 == raw_width*raw_height*3)\n\t  load_flags = 24;\n\tif (tiff_ifd[raw].bytes*5 == raw_width*raw_height*8) {\n\t  load_flags = 81;\n\t  tiff_bps = 12;\n\t} slr:\n\tswitch (tiff_bps) {\n\t  case  8: load_raw = &CLASS eight_bit_load_raw;\tbreak;\n\t  case 12: if (tiff_ifd[raw].phint == 2)\n\t\t     load_flags = 6;\n\t\t   load_raw = &CLASS packed_load_raw;\t\tbreak;\n\t  case 14: load_flags = 0;\n\t  case 16: load_raw = &CLASS unpacked_load_raw;\n\t\t   if (!strncmp(make,\"OLYMPUS\",7) &&\n\t\t\ttiff_ifd[raw].bytes*7 > raw_width*raw_height)\n\t\t     load_raw = &CLASS olympus_load_raw;\n\t}\n\tbreak;\n      case 6:  case 7:  case 99:\n\tload_raw = &CLASS lossless_jpeg_load_raw;\t\tbreak;\n      case 262:\n\tload_raw = &CLASS kodak_262_load_raw;\t\t\tbreak;\n      case 34713:\n\tif ((raw_width+9)\/10*16*raw_height == tiff_ifd[raw].bytes) {\n\t  load_raw = &CLASS packed_load_raw;\n\t  load_flags = 1;\n\t} else if (raw_width*raw_height*2 == tiff_ifd[raw].bytes) {\n\t  load_raw = &CLASS unpacked_load_raw;\n\t  load_flags = 4;\n\t  order = 0x4d4d;\n\t} else\n\t  load_raw = &CLASS nikon_load_raw;\t\t\tbreak;\n      case 65535:\n\tload_raw = &CLASS pentax_load_raw;\t\t\tbreak;\n      case 65000:\n\tswitch (tiff_ifd[raw].phint) {\n\t  case 2: load_raw = &CLASS kodak_rgb_load_raw;   filters = 0;  break;\n\t  case 6: load_raw = &CLASS kodak_ycbcr_load_raw; filters = 0;  break;\n\t  case 32803: load_raw = &CLASS kodak_65000_load_raw;\n\t}\n      case 32867: case 34892: break;\n      default: is_raw = 0;\n    }\n  if (!dng_version)\n    if ( (tiff_samples == 3 && tiff_ifd[raw].bytes && tiff_bps != 14 &&\n\t  tiff_compress != 32769 && tiff_compress != 32770)\n      || (tiff_bps == 8 && !strcasestr(make,\"Kodak\") &&\n\t  !strstr(model2,\"DEBUG RAW\")))\n      is_raw = 0;\n  for (i=0; i < tiff_nifds; i++)\n    if (i != raw && tiff_ifd[i].samples == max_samp &&\n        tiff_ifd[i].bps>0 && tiff_ifd[i].bps < 33 &&\n        unsigned(tiff_ifd[i].t_width | tiff_ifd[i].t_height) < 0x10000 &&\n\ttiff_ifd[i].t_width * tiff_ifd[i].t_height \/ (SQR(tiff_ifd[i].bps)+1) >\n\t      thumb_width *       thumb_height \/ (SQR(thumb_misc)+1)\n\t&& tiff_ifd[i].comp != 34892) {\n      thumb_width  = tiff_ifd[i].t_width;\n      thumb_height = tiff_ifd[i].t_height;\n      thumb_offset = tiff_ifd[i].offset;\n      thumb_length = tiff_ifd[i].bytes;\n      thumb_misc   = tiff_ifd[i].bps;\n      thm = i;\n    }\n  if (thm >= 0) {\n    thumb_misc |= tiff_ifd[thm].samples << 5;\n    switch (tiff_ifd[thm].comp) {\n      case 0:\n\twrite_thumb = &CLASS layer_thumb;\n\tbreak;\n      case 1:\n\tif (tiff_ifd[thm].bps <= 8)\n\t  write_thumb = &CLASS ppm_thumb;\n\telse if (!strcmp(make,\"Imacon\"))\n\t  write_thumb = &CLASS ppm16_thumb;\n\telse\n\t  thumb_load_raw = &CLASS kodak_thumb_load_raw;\n\tbreak;\n      case 65000:\n\tthumb_load_raw = tiff_ifd[thm].phint == 6 ?\n\t\t&CLASS kodak_ycbcr_load_raw : &CLASS kodak_rgb_load_raw;\n    }\n  }\n}","target":0,"code_token_length":1799,"total_token_length":2035,"max_tokens_setting":2048}
+{"idx":326617,"func":"create_dir(struct archive_write_disk *a, char *path)\n{\n\tstruct stat st;\n\tstruct fixup_entry *le;\n\tchar *slash, *base;\n\tmode_t mode_final, mode;\n\tint r;\n\n\t\/* Check for special names and just skip them. *\/\n\tslash = strrchr(path, '\/');\n\tif (slash == NULL)\n\t\tbase = path;\n\telse\n\t\tbase = slash + 1;\n\n\tif (base[0] == '\\0' ||\n\t    (base[0] == '.' && base[1] == '\\0') ||\n\t    (base[0] == '.' && base[1] == '.' && base[2] == '\\0')) {\n\t\t\/* Don't bother trying to create null path, '.', or '..'. *\/\n\t\tif (slash != NULL) {\n\t\t\t*slash = '\\0';\n\t\t\tr = create_dir(a, path);\n\t\t\t*slash = '\/';\n\t\t\treturn (r);\n\t\t}\n\t\treturn (ARCHIVE_OK);\n\t}\n\n\t\/*\n\t * Yes, this should be stat() and not lstat().  Using lstat()\n\t * here loses the ability to extract through symlinks.  Also note\n\t * that this should not use the a->st cache.\n\t *\/\n\tif (la_stat(path, &st) == 0) {\n\t\tif (S_ISDIR(st.st_mode))\n\t\t\treturn (ARCHIVE_OK);\n\t\tif ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {\n\t\t\tarchive_set_error(&a->archive, EEXIST,\n\t\t\t    \"Can't create directory '%s'\", path);\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\t\tif (unlink(path) != 0) {\n\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t    \"Can't create directory '%s': \"\n\t\t\t    \"Conflicting file cannot be removed\",\n\t\t\t    path);\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\t} else if (errno != ENOENT && errno != ENOTDIR) {\n\t\t\/* Stat failed? *\/\n\t\tarchive_set_error(&a->archive, errno,\n\t\t    \"Can't test directory '%s'\", path);\n\t\treturn (ARCHIVE_FAILED);\n\t} else if (slash != NULL) {\n\t\t*slash = '\\0';\n\t\tr = create_dir(a, path);\n\t\t*slash = '\/';\n\t\tif (r != ARCHIVE_OK)\n\t\t\treturn (r);\n\t}\n\n\t\/*\n\t * Mode we want for the final restored directory.  Per POSIX,\n\t * implicitly-created dirs must be created obeying the umask.\n\t * There's no mention whether this is different for privileged\n\t * restores (which the rest of this code handles by pretending\n\t * umask=0).  I've chosen here to always obey the user's umask for\n\t * implicit dirs, even if _EXTRACT_PERM was specified.\n\t *\/\n\tmode_final = DEFAULT_DIR_MODE & ~a->user_umask;\n\t\/* Mode we want on disk during the restore process. *\/\n\tmode = mode_final;\n\tmode |= MINIMUM_DIR_MODE;\n\tmode &= MAXIMUM_DIR_MODE;\n\tif (mkdir(path, mode) == 0) {\n\t\tif (mode != mode_final) {\n\t\t\tle = new_fixup(a, path);\n\t\t\tif (le == NULL)\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\tle->fixup |=TODO_MODE_BASE;\n\t\t\tle->mode = mode_final;\n\t\t}\n\t\treturn (ARCHIVE_OK);\n\t}\n\n\t\/*\n\t * Without the following check, a\/b\/..\/b\/c\/d fails at the\n\t * second visit to 'b', so 'd' can't be created.  Note that we\n\t * don't add it to the fixup list here, as it's already been\n\t * added.\n\t *\/\n\tif (la_stat(path, &st) == 0 && S_ISDIR(st.st_mode))\n\t\treturn (ARCHIVE_OK);\n\n\tarchive_set_error(&a->archive, errno, \"Failed to create dir '%s'\",\n\t    path);\n\treturn (ARCHIVE_FAILED);\n}","target":0,"code_token_length":838,"total_token_length":1074,"max_tokens_setting":2048}
+{"idx":291813,"func":"static int create_con_cq_qp(struct rtrs_clt_con *con)\n{\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\tu32 max_send_wr, max_recv_wr, cq_num, max_send_sge, wr_limit;\n\tint err, cq_vector;\n\tstruct rtrs_msg_rkey_rsp *rsp;\n\n\tlockdep_assert_held(&con->con_mutex);\n\tif (con->c.cid == 0) {\n\t\tmax_send_sge = 1;\n\t\t\/* We must be the first here *\/\n\t\tif (WARN_ON(clt_path->s.dev))\n\t\t\treturn -EINVAL;\n\n\t\t\/*\n\t\t * The whole session uses device from user connection.\n\t\t * Be careful not to close user connection before ib dev\n\t\t * is gracefully put.\n\t\t *\/\n\t\tclt_path->s.dev = rtrs_ib_dev_find_or_add(con->c.cm_id->device,\n\t\t\t\t\t\t       &dev_pd);\n\t\tif (!clt_path->s.dev) {\n\t\t\trtrs_wrn(clt_path->clt,\n\t\t\t\t  \"rtrs_ib_dev_find_get_or_add(): no memory\\n\");\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tclt_path->s.dev_ref = 1;\n\t\tquery_fast_reg_mode(clt_path);\n\t\twr_limit = clt_path->s.dev->ib_dev->attrs.max_qp_wr;\n\t\t\/*\n\t\t * Two (request + registration) completion for send\n\t\t * Two for recv if always_invalidate is set on server\n\t\t * or one for recv.\n\t\t * + 2 for drain and heartbeat\n\t\t * in case qp gets into error state.\n\t\t *\/\n\t\tmax_send_wr =\n\t\t\tmin_t(int, wr_limit, SERVICE_CON_QUEUE_DEPTH * 2 + 2);\n\t\tmax_recv_wr = max_send_wr;\n\t} else {\n\t\t\/*\n\t\t * Here we assume that session members are correctly set.\n\t\t * This is always true if user connection (cid == 0) is\n\t\t * established first.\n\t\t *\/\n\t\tif (WARN_ON(!clt_path->s.dev))\n\t\t\treturn -EINVAL;\n\t\tif (WARN_ON(!clt_path->queue_depth))\n\t\t\treturn -EINVAL;\n\n\t\twr_limit = clt_path->s.dev->ib_dev->attrs.max_qp_wr;\n\t\t\/* Shared between connections *\/\n\t\tclt_path->s.dev_ref++;\n\t\tmax_send_wr = min_t(int, wr_limit,\n\t\t\t      \/* QD * (REQ + RSP + FR REGS or INVS) + drain *\/\n\t\t\t      clt_path->queue_depth * 3 + 1);\n\t\tmax_recv_wr = min_t(int, wr_limit,\n\t\t\t      clt_path->queue_depth * 3 + 1);\n\t\tmax_send_sge = 2;\n\t}\n\tatomic_set(&con->c.sq_wr_avail, max_send_wr);\n\tcq_num = max_send_wr + max_recv_wr;\n\t\/* alloc iu to recv new rkey reply when server reports flags set *\/\n\tif (clt_path->flags & RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) {\n\t\tcon->rsp_ius = rtrs_iu_alloc(cq_num, sizeof(*rsp),\n\t\t\t\t\t      GFP_KERNEL,\n\t\t\t\t\t      clt_path->s.dev->ib_dev,\n\t\t\t\t\t      DMA_FROM_DEVICE,\n\t\t\t\t\t      rtrs_clt_rdma_done);\n\t\tif (!con->rsp_ius)\n\t\t\treturn -ENOMEM;\n\t\tcon->queue_num = cq_num;\n\t}\n\tcq_num = max_send_wr + max_recv_wr;\n\tcq_vector = con->cpu % clt_path->s.dev->ib_dev->num_comp_vectors;\n\tif (con->c.cid >= clt_path->s.irq_con_num)\n\t\terr = rtrs_cq_qp_create(&clt_path->s, &con->c, max_send_sge,\n\t\t\t\t\tcq_vector, cq_num, max_send_wr,\n\t\t\t\t\tmax_recv_wr, IB_POLL_DIRECT);\n\telse\n\t\terr = rtrs_cq_qp_create(&clt_path->s, &con->c, max_send_sge,\n\t\t\t\t\tcq_vector, cq_num, max_send_wr,\n\t\t\t\t\tmax_recv_wr, IB_POLL_SOFTIRQ);\n\t\/*\n\t * In case of error we do not bother to clean previous allocations,\n\t * since destroy_con_cq_qp() must be called.\n\t *\/\n\treturn err;\n}","target":0,"code_token_length":901,"total_token_length":1137,"max_tokens_setting":2048}
+{"idx":210814,"func":"ins_compl_add(\n    char_u\t*str,\n    int\t\tlen,\n    char_u\t*fname,\n    char_u\t**cptext,\t    \/\/ extra text for popup menu or NULL\n    typval_T\t*user_data UNUSED,  \/\/ \"user_data\" entry or NULL\n    int\t\tcdir,\n    int\t\tflags_arg,\n    int\t\tadup)\t\t\/\/ accept duplicate match\n{\n    compl_T\t*match;\n    int\t\tdir = (cdir == 0 ? compl_direction : cdir);\n    int\t\tflags = flags_arg;\n\n    if (flags & CP_FAST)\n\tfast_breakcheck();\n    else\n\tui_breakcheck();\n    if (got_int)\n\treturn FAIL;\n    if (len < 0)\n\tlen = (int)STRLEN(str);\n\n    \/\/ If the same match is already present, don't add it.\n    if (compl_first_match != NULL && !adup)\n    {\n\tmatch = compl_first_match;\n\tdo\n\t{\n\t    if (!match_at_original_text(match)\n\t\t    && STRNCMP(match->cp_str, str, len) == 0\n\t\t    && match->cp_str[len] == NUL)\n\t\treturn NOTDONE;\n\t    match = match->cp_next;\n\t} while (match != NULL && !is_first_match(match));\n    }\n\n    \/\/ Remove any popup menu before changing the list of matches.\n    ins_compl_del_pum();\n\n    \/\/ Allocate a new match structure.\n    \/\/ Copy the values to the new match structure.\n    match = ALLOC_CLEAR_ONE(compl_T);\n    if (match == NULL)\n\treturn FAIL;\n    match->cp_number = -1;\n    if (flags & CP_ORIGINAL_TEXT)\n\tmatch->cp_number = 0;\n    if ((match->cp_str = vim_strnsave(str, len)) == NULL)\n    {\n\tvim_free(match);\n\treturn FAIL;\n    }\n\n    \/\/ match-fname is:\n    \/\/ - compl_curr_match->cp_fname if it is a string equal to fname.\n    \/\/ - a copy of fname, CP_FREE_FNAME is set to free later THE allocated mem.\n    \/\/ - NULL otherwise.\t--Acevedo\n    if (fname != NULL\n\t    && compl_curr_match != NULL\n\t    && compl_curr_match->cp_fname != NULL\n\t    && STRCMP(fname, compl_curr_match->cp_fname) == 0)\n\tmatch->cp_fname = compl_curr_match->cp_fname;\n    else if (fname != NULL)\n    {\n\tmatch->cp_fname = vim_strsave(fname);\n\tflags |= CP_FREE_FNAME;\n    }\n    else\n\tmatch->cp_fname = NULL;\n    match->cp_flags = flags;\n\n    if (cptext != NULL)\n    {\n\tint i;\n\n\tfor (i = 0; i < CPT_COUNT; ++i)\n\t    if (cptext[i] != NULL && *cptext[i] != NUL)\n\t\tmatch->cp_text[i] = vim_strsave(cptext[i]);\n    }\n#ifdef FEAT_EVAL\n    if (user_data != NULL)\n\tmatch->cp_user_data = *user_data;\n#endif\n\n    \/\/ Link the new match structure after (FORWARD) or before (BACKWARD) the\n    \/\/ current match in the list of matches .\n    if (compl_first_match == NULL)\n\tmatch->cp_next = match->cp_prev = NULL;\n    else if (dir == FORWARD)\n    {\n\tmatch->cp_next = compl_curr_match->cp_next;\n\tmatch->cp_prev = compl_curr_match;\n    }\n    else\t\/\/ BACKWARD\n    {\n\tmatch->cp_next = compl_curr_match;\n\tmatch->cp_prev = compl_curr_match->cp_prev;\n    }\n    if (match->cp_next)\n\tmatch->cp_next->cp_prev = match;\n    if (match->cp_prev)\n\tmatch->cp_prev->cp_next = match;\n    else\t\/\/ if there's nothing before, it is the first match\n\tcompl_first_match = match;\n    compl_curr_match = match;\n\n    \/\/ Find the longest common string if still doing that.\n    if (compl_get_longest && (flags & CP_ORIGINAL_TEXT) == 0)\n\tins_compl_longest_match(match);\n\n    return OK;\n}","target":1,"code_token_length":876,"total_token_length":1112,"max_tokens_setting":2048}
+{"idx":413615,"func":"R_API RCoreAnalStats* r_core_anal_get_stats(RCore *core, ut64 from, ut64 to, ut64 step) {\n\tRAnalFunction *F;\n\tRAnalBlock  *B;\n\tRBinSymbol *S;\n\tRListIter *iter, *iter2;\n\tRCoreAnalStats *as = NULL;\n\tint piece, as_size, blocks;\n\tut64 at;\n\n\tif (from == to || from == UT64_MAX || to == UT64_MAX) {\n\t\teprintf (\"Cannot alloc for this range\\n\");\n\t\treturn NULL;\n\t}\n\tas = R_NEW0 (RCoreAnalStats);\n\tif (!as) {\n\t\treturn NULL;\n\t}\n\tif (step < 1) {\n\t\tstep = 1;\n\t}\n\tblocks = (to - from) \/ step;\n\tas_size = (1 + blocks) * sizeof (RCoreAnalStatsItem);\n\tas->block = malloc (as_size);\n\tif (!as->block) {\n\t\tfree (as);\n\t\treturn NULL;\n\t}\n\tmemset (as->block, 0, as_size);\n\tfor (at = from; at < to; at += step) {\n\t\tRIOMap *map = r_io_map_get_at (core->io, at);\n\t\tpiece = (at - from) \/ step;\n\t\tas->block[piece].perm = map ? map->perm: (core->io->desc ? core->io->desc->perm: 0);\n\t}\n\t\/\/ iter all flags\n\tstruct block_flags_stat_t u = { .step = step, .from = from, .as = as };\n\tr_flag_foreach_range (core->flags, from, to + 1, block_flags_stat, &u);\n\t\/\/ iter all functions\n\tr_list_foreach (core->anal->fcns, iter, F) {\n\t\tif (F->addr < from || F->addr > to) {\n\t\t\tcontinue;\n\t\t}\n\t\tpiece = (F->addr - from) \/ step;\n\t\tas->block[piece].functions++;\n\t\tut64 last_piece = R_MIN ((F->addr + r_anal_function_linear_size (F) - 1) \/ step, blocks - 1);\n\t\tfor (; piece <= last_piece; piece++) {\n\t\t\tas->block[piece].in_functions++;\n\t\t}\n\t\t\/\/ iter all basic blocks\n\t\tr_list_foreach (F->bbs, iter2, B) {\n\t\t\tif (B->addr < from || B->addr > to) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpiece = (B->addr - from) \/ step;\n\t\t\tas->block[piece].blocks++;\n\t\t}\n\t}\n\t\/\/ iter all symbols\n\tr_list_foreach (r_bin_get_symbols (core->bin), iter, S) {\n\t\tif (S->vaddr < from || S->vaddr > to) {\n\t\t\tcontinue;\n\t\t}\n\t\tpiece = (S->vaddr - from) \/ step;\n\t\tas->block[piece].symbols++;\n\t}\n\tRPVector *metas = to > from ? r_meta_get_all_intersect (core->anal, from, to - from, R_META_TYPE_ANY) : NULL;\n\tif (metas) {\n\t\tvoid **it;\n\t\tr_pvector_foreach (metas, it) {\n\t\t\tRIntervalNode *node = *it;\n\t\t\tRAnalMetaItem *mi = node->data;\n\t\t\tif (node->start < from || node->end > to) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpiece = (node->start - from) \/ step;\n\t\t\tswitch (mi->type) {\n\t\t\tcase R_META_TYPE_STRING:\n\t\t\t\tas->block[piece].strings++;\n\t\t\t\tbreak;\n\t\t\tcase R_META_TYPE_COMMENT:\n\t\t\t\tas->block[piece].comments++;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tr_pvector_free (metas);\n\t}\n\treturn as;\n}","target":0,"code_token_length":832,"total_token_length":1068,"max_tokens_setting":2048}
+{"idx":310161,"func":"EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T *ntext, int num)\n{\n    int i;\n\n    TR(TRACE_CHARPUT, (\"EmitRange %d:%s\", num, _nc_viscbuf(ntext, num)));\n\n    if (erase_chars || repeat_char) {\n\twhile (num > 0) {\n\t    int runcount;\n\t    NCURSES_CH_T ntext0;\n\n\t    while (num > 1 && !CharEq(ntext[0], ntext[1])) {\n\t\tPutChar(NCURSES_SP_ARGx CHREF(ntext[0]));\n\t\tntext++;\n\t\tnum--;\n\t    }\n\t    ntext0 = ntext[0];\n\t    if (num == 1) {\n\t\tPutChar(NCURSES_SP_ARGx CHREF(ntext0));\n\t\treturn 0;\n\t    }\n\t    runcount = 2;\n\n\t    while (runcount < num && CharEq(ntext[runcount], ntext0))\n\t\truncount++;\n\n\t    \/*\n\t     * The cost expression in the middle isn't exactly right.\n\t     * _cup_ch_cost is an upper bound on the cost for moving to the\n\t     * end of the erased area, but not the cost itself (which we\n\t     * can't compute without emitting the move).  This may result\n\t     * in erase_chars not getting used in some situations for\n\t     * which it would be marginally advantageous.\n\t     *\/\n\t    if (erase_chars\n\t\t&& runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost\n\t\t&& can_clear_with(NCURSES_SP_ARGx CHREF(ntext0))) {\n\t\tUpdateAttrs(SP_PARM, ntext0);\n\t\tNCURSES_PUTP2(\"erase_chars\", TIPARM_1(erase_chars, runcount));\n\n\t\t\/*\n\t\t * If this is the last part of the given interval,\n\t\t * don't bother moving cursor, since it can be the\n\t\t * last update on the line.\n\t\t *\/\n\t\tif (runcount < num) {\n\t\t    GoTo(NCURSES_SP_ARGx\n\t\t\t SP_PARM->_cursrow,\n\t\t\t SP_PARM->_curscol + runcount);\n\t\t} else {\n\t\t    return 1;\t\/* cursor stays in the middle *\/\n\t\t}\n\t    } else if (repeat_char != 0 &&\n#if BSD_TPUTS\n\t\t       !isdigit(UChar(CharOf(ntext0))) &&\n#endif\n#if USE_WIDEC_SUPPORT\n\t\t       (!SP_PARM->_screen_unicode &&\n\t\t\t(CharOf(ntext0) < ((AttrOf(ntext0) & A_ALTCHARSET)\n\t\t\t\t\t   ? ACS_LEN\n\t\t\t\t\t   : 256))) &&\n#endif\n\t\t       runcount > SP_PARM->_rep_cost) {\n\t\tNCURSES_CH_T temp;\n\t\tbool wrap_possible = (SP_PARM->_curscol + runcount >=\n\t\t\t\t      screen_columns(SP_PARM));\n\t\tint rep_count = runcount;\n\n\t\tif (wrap_possible)\n\t\t    rep_count--;\n\n\t\tUpdateAttrs(SP_PARM, ntext0);\n\t\ttemp = ntext0;\n\t\tif ((AttrOf(temp) & A_ALTCHARSET) &&\n\t\t    SP_PARM->_acs_map != 0 &&\n\t\t    (SP_PARM->_acs_map[CharOf(temp)] & A_CHARTEXT) != 0) {\n\t\t    SetChar(temp,\n\t\t\t    (SP_PARM->_acs_map[CharOf(ntext0)] & A_CHARTEXT),\n\t\t\t    AttrOf(ntext0) | A_ALTCHARSET);\n\t\t}\n\t\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t\tTIPARM_2(repeat_char,\n\t\t\t\t\t\t CharOf(temp),\n\t\t\t\t\t\t rep_count),\n\t\t\t\t\t1,\n\t\t\t\t\tNCURSES_SP_NAME(_nc_outch));\n\t\tSP_PARM->_curscol += rep_count;\n\n\t\tif (wrap_possible)\n\t\t    PutChar(NCURSES_SP_ARGx CHREF(ntext0));\n\t    } else {\n\t\tfor (i = 0; i < runcount; i++)\n\t\t    PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));\n\t    }\n\t    ntext += runcount;\n\t    num -= runcount;\n\t}\n\treturn 0;\n    }\n\n    for (i = 0; i < num; i++)\n\tPutChar(NCURSES_SP_ARGx CHREF(ntext[i]));\n    return 0;\n}","target":0,"code_token_length":930,"total_token_length":1166,"max_tokens_setting":2048}
+{"idx":249988,"func":"GF_Err WriteToFile(GF_ISOFile *movie, Bool for_fragments)\n{\n\tMovieWriter mw;\n\tGF_Err e = GF_OK;\n\tif (!movie) return GF_BAD_PARAM;\n\n\tif (movie->openMode == GF_ISOM_OPEN_READ) return GF_BAD_PARAM;\n\n\te = gf_isom_insert_copyright(movie);\n\tif (e) return e;\n\n\tmemset(&mw, 0, sizeof(mw));\n\tmw.movie = movie;\n\n\n\tif (movie->moov) {\n\t\tu32 i;\n\t\tGF_TrackBox *trak;\n\t\tif (gf_sys_is_test_mode()) {\n\t\t\tmovie->moov->mvhd->creationTime = 0;\n\t\t\tmovie->moov->mvhd->modificationTime = 0;\n\t\t}\n\t\ti=0;\n\t\twhile ( (trak = gf_list_enum(movie->moov->trackList, &i))) {\n\t\t\tif (gf_sys_is_test_mode()) {\n\t\t\t\ttrak->Header->creationTime = 0;\n\t\t\t\ttrak->Header->modificationTime = 0;\n\t\t\t\tif (trak->Media->handler->nameUTF8 && strstr(trak->Media->handler->nameUTF8, \"@GPAC\")) {\n\t\t\t\t\tgf_free(trak->Media->handler->nameUTF8);\n\t\t\t\t\ttrak->Media->handler->nameUTF8 = gf_strdup(\"MediaHandler\");\n\t\t\t\t}\n\t\t\t\ttrak->Media->mediaHeader->creationTime = 0;\n\t\t\t\ttrak->Media->mediaHeader->modificationTime = 0;\n\t\t\t}\n\t\t\tif (trak->chunk_cache) {\n\t\t\t\tgf_isom_flush_chunk(trak, GF_TRUE);\n\t\t\t}\n\t\t}\n\t}\n\t\/\/capture mode: we don't need a new bitstream\n\tif (movie->openMode == GF_ISOM_OPEN_WRITE) {\n\t\tif (!strcmp(movie->fileName, \"_gpac_isobmff_redirect\")) {\n\t\t\tGF_BitStream *bs, *moov_bs=NULL;\n\t\t\tu64 mdat_end = gf_bs_get_position(movie->editFileMap->bs);\n\t\t\tu64 mdat_start = movie->mdat->bsOffset;\n\t\t\tu64 mdat_size = mdat_end - mdat_start;\n\n\t\t\tif (for_fragments) {\n\t\t\t\tif (!movie->on_block_out) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[ISOBMFF] Missing output block callback, cannot write\\n\"));\n\t\t\t\t\treturn GF_BAD_PARAM;\n\t\t\t\t}\n\t\t\t\tbs = gf_bs_new_cbk(movie->on_block_out, movie->on_block_out_usr_data, movie->on_block_out_block_size);\n\t\t\t\te = WriteFlat(&mw, 0, bs, GF_TRUE, GF_TRUE, NULL);\n\t\t\t\tmovie->fragmented_file_pos = gf_bs_get_position(bs);\n\t\t\t\tgf_bs_del(bs);\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\t\/\/seek at end in case we had a read of the file\n\t\t\tgf_bs_seek(movie->editFileMap->bs, gf_bs_get_size(movie->editFileMap->bs) );\n\n\t\t\tif ((movie->storageMode==GF_ISOM_STORE_FASTSTART) && mdat_start && mdat_size) {\n\t\t\t\tmoov_bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\t\t\t}\n\t\t\t\/\/write as non-seekable\n\t\t\te = WriteFlat(&mw, 0, movie->editFileMap->bs, GF_TRUE, GF_FALSE, moov_bs);\n\n\t\t\tmovie->fragmented_file_pos = gf_bs_get_position(movie->editFileMap->bs);\n\n\t\t\tif (mdat_start && mdat_size) {\n\t\t\t\tu8 data[16];\n\t\t\t\tif (!movie->on_block_out) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[ISOBMFF] Missing output block patch callback, cannot patch mdat size in flat storage\\n\"));\n\t\t\t\t\treturn GF_BAD_PARAM;\n\t\t\t\t}\n\n\t\t\t\t\/\/create a patch packet for mdat covering out 16 bytes (cf FlushCapture)\n\t\t\t\tbs = gf_bs_new(data, 16, GF_BITSTREAM_WRITE);\n\t\t\t\tgf_bs_write_u32(bs, (mdat_size>0xFFFFFFFF) ? 1 : (u32) mdat_size);\n\t\t\t\tgf_bs_write_u32(bs, GF_ISOM_BOX_TYPE_MDAT);\n\t\t\t\tif  (mdat_size>0xFFFFFFFF)\n\t\t\t\t\tgf_bs_write_u64(bs, mdat_size);\n\t\t\t\telse\n\t\t\t\t\tgf_bs_write_u64(bs, 0);\n\t\t\t\tgf_bs_del(bs);\n\t\t\t\tmovie->on_block_patch(movie->on_block_out_usr_data, data, 16, mdat_start, GF_FALSE);\n\t\t\t}\n\n\t\t\tif (moov_bs) {\n\t\t\t\tu8 *moov_data;\n\t\t\t\tu32 moov_size;\n\n\t\t\t\tgf_bs_get_content(moov_bs, &moov_data, &moov_size);\n\t\t\t\tgf_bs_del(moov_bs);\n\n\t\t\t\tmovie->on_block_patch(movie->on_block_out_usr_data, moov_data, moov_size, mdat_start, GF_TRUE);\n\t\t\t\tgf_free(moov_data);\n\t\t\t}\n\t\t} else {\n\t\t\tGF_BitStream *moov_bs = NULL;\n\t\t\tif ((movie->storageMode==GF_ISOM_STORE_STREAMABLE) || (movie->storageMode==GF_ISOM_STORE_FASTSTART) ) {\n\t\t\t\tmoov_bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\t\t\t}\n\t\t\te = WriteFlat(&mw, 0, movie->editFileMap->bs, GF_FALSE, GF_FALSE, moov_bs);\n\t\t\tif (moov_bs) {\n\t\t\t\tu8 *moov_data;\n\t\t\t\tu32 moov_size;\n\n\t\t\t\tgf_bs_get_content(moov_bs, &moov_data, &moov_size);\n\t\t\t\tgf_bs_del(moov_bs);\n\t\t\t\tif (!e)\n\t\t\t\t\te = gf_bs_insert_data(movie->editFileMap->bs, moov_data, moov_size, movie->mdat->bsOffset);\n\t\t\t\t\t\n\t\t\t\tgf_free(moov_data);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tFILE *stream=NULL;\n\t\tBool is_stdout = GF_FALSE;\n\t\tGF_BitStream *bs=NULL;\n\t\tif (!strcmp(movie->finalName, \"_gpac_isobmff_redirect\")) {\n\t\t\tif (!movie->on_block_out) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[ISOBMFF] Missing output block callback, cannot write\\n\"));\n\t\t\t\treturn GF_BAD_PARAM;\n\t\t\t}\n\t\t\tbs = gf_bs_new_cbk(movie->on_block_out, movie->on_block_out_usr_data, movie->on_block_out_block_size);\n\t\t\tis_stdout = GF_TRUE;\n\t\t} else {\n\t\t\tif (!strcmp(movie->finalName, \"std\"))\n\t\t\t\tis_stdout = GF_TRUE;\n\n\t\t\t\/\/OK, we need a new bitstream\n\t\t\tstream = is_stdout ? stdout : gf_fopen(movie->finalName, \"w+b\");\n\t\t\tif (!stream)\n\t\t\t\treturn GF_IO_ERR;\n\t\t\tbs = gf_bs_from_file(stream, GF_BITSTREAM_WRITE);\n\t\t}\n\t\tif (!bs) {\n\t\t\tif (!is_stdout)\n\t\t\t\tgf_fclose(stream);\n\t\t\treturn GF_OUT_OF_MEM;\n\t\t}\n\n\t\tswitch (movie->storageMode) {\n\t\tcase GF_ISOM_STORE_TIGHT:\n\t\tcase GF_ISOM_STORE_INTERLEAVED:\n\t\t\te = WriteInterleaved(&mw, bs, 0);\n\t\t\tbreak;\n\t\tcase GF_ISOM_STORE_DRIFT_INTERLEAVED:\n\t\t\te = WriteInterleaved(&mw, bs, 1);\n\t\t\tbreak;\n\t\tcase GF_ISOM_STORE_STREAMABLE:\n\t\t\te = WriteFlat(&mw, 1, bs, is_stdout, GF_FALSE, NULL);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\te = WriteFlat(&mw, 0, bs, is_stdout, GF_FALSE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tgf_bs_del(bs);\n\t\tif (!is_stdout)\n\t\t\tgf_fclose(stream);\n\t}\n\tif (mw.buffer) gf_free(mw.buffer);\n\tif (mw.nb_done<mw.total_samples) {\n\t\tmw.nb_done = mw.total_samples;\n\t\tmuxer_report_progress(&mw);\n\t}\n\treturn e;\n}","target":0,"code_token_length":1740,"total_token_length":1976,"max_tokens_setting":2048}
+{"idx":514289,"func":"bool Multiupdate_prelocking_strategy::handle_end(THD *thd)\n{\n  DBUG_ENTER(\"Multiupdate_prelocking_strategy::handle_end\");\n  if (done)\n    DBUG_RETURN(0);\n\n  LEX *lex= thd->lex;\n  SELECT_LEX *select_lex= &lex->select_lex;\n  TABLE_LIST *table_list= lex->query_tables, *tl;\n\n  done= true;\n\n  if (mysql_handle_derived(lex, DT_INIT) ||\n      mysql_handle_derived(lex, DT_MERGE_FOR_INSERT) ||\n      mysql_handle_derived(lex, DT_PREPARE))\n    DBUG_RETURN(1);\n\n  \/*\n    setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()\n    second time, but this call will do nothing (there are check for second\n    call in setup_tables()).\n  *\/\n\n  if (setup_tables_and_check_access(thd, &select_lex->context,\n      &select_lex->top_join_list, table_list, select_lex->leaf_tables,\n      FALSE, UPDATE_ACL, SELECT_ACL, TRUE))\n    DBUG_RETURN(1);\n\n  List<Item> *fields= &lex->select_lex.item_list;\n  if (setup_fields_with_no_wrap(thd, Ref_ptr_array(),\n                                *fields, MARK_COLUMNS_WRITE, 0, 0))\n    DBUG_RETURN(1);\n\n  \/\/ Check if we have a view in the list ...\n  for (tl= table_list; tl ; tl= tl->next_local)\n    if (tl->view)\n      break;\n  \/\/ ... and pass this knowlage in check_fields call\n  if (check_fields(thd, *fields, tl != NULL ))\n    DBUG_RETURN(1);\n\n  table_map tables_for_update= thd->table_map_for_update= get_table_map(fields);\n\n  if (unsafe_key_update(select_lex->leaf_tables, tables_for_update))\n    DBUG_RETURN(1);\n\n  \/*\n    Setup timestamp handling and locking mode\n  *\/\n  List_iterator<TABLE_LIST> ti(select_lex->leaf_tables);\n  const bool using_lock_tables= thd->locked_tables_mode != LTM_NONE;\n  while ((tl= ti++))\n  {\n    TABLE *table= tl->table;\n\n    if (tl->is_jtbm())\n      continue;\n\n    \/* if table will be updated then check that it is unique *\/\n    if (table->map & tables_for_update)\n    {\n      if (!tl->single_table_updatable() || check_key_in_view(thd, tl))\n      {\n        my_error(ER_NON_UPDATABLE_TABLE, MYF(0),\n                 tl->top_table()->alias.str, \"UPDATE\");\n        DBUG_RETURN(1);\n      }\n\n      DBUG_PRINT(\"info\",(\"setting table `%s` for update\",\n                         tl->top_table()->alias.str));\n      \/*\n        If table will be updated we should not downgrade lock for it and\n        leave it as is.\n      *\/\n      tl->updating= 1;\n      if (tl->belong_to_view)\n        tl->belong_to_view->updating= 1;\n      if (extend_table_list(thd, tl, this, has_prelocking_list))\n        DBUG_RETURN(1);\n    }\n    else\n    {\n      DBUG_PRINT(\"info\",(\"setting table `%s` for read-only\", tl->alias.str));\n      \/*\n        If we are using the binary log, we need TL_READ_NO_INSERT to get\n        correct order of statements. Otherwise, we use a TL_READ lock to\n        improve performance.\n        We don't downgrade metadata lock from SW to SR in this case as\n        there is no guarantee that the same ticket is not used by\n        another table instance used by this statement which is going to\n        be write-locked (for example, trigger to be invoked might try\n        to update this table).\n        Last argument routine_modifies_data for read_lock_type_for_table()\n        is ignored, as prelocking placeholder will never be set here.\n      *\/\n      DBUG_ASSERT(tl->prelocking_placeholder == false);\n      thr_lock_type lock_type= read_lock_type_for_table(thd, lex, tl, true);\n      if (using_lock_tables)\n        tl->lock_type= lock_type;\n      else\n        tl->set_lock_type(thd, lock_type);\n    }\n  }\n\n  \/*\n    Check access privileges for tables being updated or read.\n    Note that unlike in the above loop we need to iterate here not only\n    through all leaf tables but also through all view hierarchy.\n  *\/\n\n  for (tl= table_list; tl; tl= tl->next_local)\n  {\n    bool not_used= false;\n    if (tl->is_jtbm())\n      continue;\n    if (multi_update_check_table_access(thd, tl, tables_for_update, ¬_used))\n      DBUG_RETURN(TRUE);\n  }\n\n  \/* check single table update for view compound from several tables *\/\n  for (tl= table_list; tl; tl= tl->next_local)\n  {\n    TABLE_LIST *for_update= 0;\n    if (tl->is_jtbm())\n      continue;\n    if (tl->is_merged_derived() &&\n        tl->check_single_table(&for_update, tables_for_update, tl))\n    {\n      my_error(ER_VIEW_MULTIUPDATE, MYF(0), tl->view_db.str, tl->view_name.str);\n      DBUG_RETURN(1);\n    }\n  }\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":1145,"total_token_length":1381,"max_tokens_setting":2048}
+{"idx":314496,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_validate2(const pjmedia_sdp_session *sdp,\n\t\t\t\t\t  pj_bool_t strict)\n{\n    unsigned i;\n    const pj_str_t STR_RTPMAP = { \"rtpmap\", 6 };\n\n    CHECK( sdp != NULL, PJ_EINVAL);\n\n    \/* Validate origin line. *\/\n    CHECK( sdp->origin.user.slen != 0, PJMEDIA_SDP_EINORIGIN);\n    CHECK( pj_strcmp2(&sdp->origin.net_type, \"IN\")==0, \n\t   PJMEDIA_SDP_EINORIGIN);\n    CHECK( pj_strcmp2(&sdp->origin.addr_type, \"IP4\")==0 ||\n\t   pj_strcmp2(&sdp->origin.addr_type, \"IP6\")==0, \n\t   PJMEDIA_SDP_EINORIGIN);\n    CHECK( sdp->origin.addr.slen != 0, PJMEDIA_SDP_EINORIGIN);\n\n    \/* Validate subject line. *\/\n    CHECK( sdp->name.slen != 0, PJMEDIA_SDP_EINNAME);\n\n    \/* Ignore start and stop time. *\/\n\n    \/* If session level connection info is present, validate it. *\/\n    if (sdp->conn) {\n\tpj_status_t status = validate_sdp_conn(sdp->conn);\n\tif (status != PJ_SUCCESS)\n\t    return status;\n    }\n\n    \/* Validate each media. *\/\n    for (i=0; i<sdp->media_count; ++i) {\n\tconst pjmedia_sdp_media *m = sdp->media[i];\n\tunsigned j;\n\n\t\/* Validate the m= line. *\/\n\tCHECK( m->desc.media.slen != 0, PJMEDIA_SDP_EINMEDIA);\n\tCHECK( m->desc.transport.slen != 0, PJMEDIA_SDP_EINMEDIA);\n\tCHECK( m->desc.fmt_count != 0 || m->desc.port==0, PJMEDIA_SDP_ENOFMT);\n\n\t\/* If media level connection info is present, validate it. *\/\n\tif (m->conn) {\n\t    pj_status_t status = validate_sdp_conn(m->conn);\n\t    if (status != PJ_SUCCESS)\n\t\treturn status;\n\t}\n\n\t\/* If media doesn't have connection info, then connection info\n\t * must be present in the session.\n\t *\/\n\tif (m->conn == NULL) {\n\t    if (sdp->conn == NULL)\n\t\tif (strict || m->desc.port != 0)\n\t\t    return PJMEDIA_SDP_EMISSINGCONN;\n\t}\n\n\t\/* Verify payload type. *\/\n\tfor (j=0; j<m->desc.fmt_count; ++j) {\n\n\t    \/* Arrgh noo!! Payload type can be non-numeric!!\n\t     * RTC based programs sends \"null\" for instant messaging!\n\t     *\/\n\t    if (pj_isdigit(*m->desc.fmt[j].ptr)) {\n\t\tunsigned long pt;\n\t\tpj_status_t status = pj_strtoul3(&m->desc.fmt[j], &pt, 10);\n\n\t\t\/* Payload type is between 0 and 127. \n\t\t *\/\n\t\tCHECK( status == PJ_SUCCESS && pt <= 127, PJMEDIA_SDP_EINPT);\n\n\t\t\/* If port is not zero, then for each dynamic payload type, an\n\t\t * rtpmap attribute must be specified.\n\t\t *\/\n\t\tif (m->desc.port != 0 && pt >= 96) {\n\t\t    const pjmedia_sdp_attr *a;\n\n\t\t    a = pjmedia_sdp_media_find_attr(m, &STR_RTPMAP, \n\t\t\t\t\t\t    &m->desc.fmt[j]);\n\t\t    CHECK( a != NULL, PJMEDIA_SDP_EMISSINGRTPMAP);\n\t\t}\n\t    }\n\t}\n    }\n\n    \/* Looks good. *\/\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048}
+{"idx":376323,"func":"gpg_decrypt_sync (CamelCipherContext *context,\n                  CamelMimePart *ipart,\n                  CamelMimePart *opart,\n                  GCancellable *cancellable,\n                  GError **error)\n{\n\tstruct _GpgCtx *gpg = NULL;\n\tCamelCipherValidity *valid = NULL;\n\tCamelStream *ostream, *istream;\n\tCamelDataWrapper *content;\n\tCamelMimePart *encrypted;\n\tCamelMultipart *mp;\n\tCamelContentType *ct;\n\tgboolean success;\n\n\tif (!ipart) {\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t_(\"Cannot decrypt message: Incorrect message format\"));\n\t\treturn NULL;\n\t}\n\n\tcontent = camel_medium_get_content ((CamelMedium *) ipart);\n\n\tif (!content) {\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t_(\"Cannot decrypt message: Incorrect message format\"));\n\t\treturn NULL;\n\t}\n\n\tct = camel_data_wrapper_get_mime_type_field (content);\n\t\/* Encrypted part (using our fake mime type) or PGP\/Mime multipart *\/\n\tif (camel_content_type_is (ct, \"multipart\", \"encrypted\")) {\n\t\tmp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) ipart);\n\t\tif (!(encrypted = camel_multipart_get_part (mp, CAMEL_MULTIPART_ENCRYPTED_CONTENT))) {\n\t\t\tg_set_error (\n\t\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t\t_(\"Failed to decrypt MIME part: \"\n\t\t\t\t\"protocol error\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\tcontent = camel_medium_get_content ((CamelMedium *) encrypted);\n\t} else if (camel_content_type_is (ct, \"application\", \"x-inlinepgp-encrypted\")) {\n\t\tcontent = camel_medium_get_content ((CamelMedium *) ipart);\n\t} else {\n\t\t\/* Invalid Mimetype *\/\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t_(\"Cannot decrypt message: Incorrect message format\"));\n\t\treturn NULL;\n\t}\n\n\tistream = camel_stream_mem_new ();\n\tif (!camel_data_wrapper_decode_to_stream_sync (\n\t\tcontent, istream, cancellable, error)) {\n\t\tg_object_unref (istream);\n\t\treturn NULL;\n\t}\n\n\tg_seekable_seek (G_SEEKABLE (istream), 0, G_SEEK_SET, NULL, NULL);\n\n\tostream = camel_stream_mem_new ();\n\tcamel_stream_mem_set_secure ((CamelStreamMem *) ostream);\n\n\tgpg = gpg_ctx_new (context);\n\tgpg_ctx_set_mode (gpg, GPG_CTX_MODE_DECRYPT);\n\tgpg_ctx_set_istream (gpg, istream);\n\tgpg_ctx_set_ostream (gpg, ostream);\n\n\tif (!gpg_ctx_op_start (gpg, error))\n\t\tgoto fail;\n\n\twhile (!gpg_ctx_op_complete (gpg)) {\n\t\tif (gpg_ctx_op_step (gpg, cancellable, error) == -1) {\n\t\t\tgpg_ctx_op_cancel (gpg);\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\t\/* Report errors only if nothing was decrypted; missing sender's key used\n\t   for signature of a signed and encrypted messages causes GPG to return\n\t   failure, thus count with it.\n\t *\/\n\tif (gpg_ctx_op_wait (gpg) != 0 && gpg->nodata) {\n\t\tconst gchar *diagnostics;\n\n\t\tdiagnostics = gpg_ctx_get_diagnostics (gpg);\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC, \"%s\",\n\t\t\t(diagnostics != NULL && *diagnostics != '\\0') ?\n\t\t\tdiagnostics : _(\"Failed to execute gpg.\"));\n\t\tgoto fail;\n\t}\n\n\tg_seekable_seek (G_SEEKABLE (ostream), 0, G_SEEK_SET, NULL, NULL);\n\n\tif (camel_content_type_is (ct, \"multipart\", \"encrypted\")) {\n\t\tCamelDataWrapper *dw;\n\t\tCamelStream *null = camel_stream_null_new ();\n\n\t\t\/* Multipart encrypted - parse a full mime part *\/\n\t\tsuccess = camel_data_wrapper_construct_from_stream_sync (\n\t\t\tCAMEL_DATA_WRAPPER (opart),\n\t\t\tostream, NULL, error);\n\n\t\tdw = camel_medium_get_content ((CamelMedium *) opart);\n\t\tif (!camel_data_wrapper_decode_to_stream_sync (\n\t\t\tdw, null, cancellable, NULL)) {\n\t\t\t\/* nothing had been decoded from the stream, it doesn't\n\t\t\t * contain any header, like Content-Type or such, thus\n\t\t\t * write it as a message body *\/\n\t\t\tsuccess = camel_data_wrapper_construct_from_stream_sync (\n\t\t\t\tdw, ostream, cancellable, error);\n\t\t}\n\n\t\tg_object_unref (null);\n\t} else {\n\t\t\/* Inline signed - raw data (may not be a mime part) *\/\n\t\tCamelDataWrapper *dw;\n\t\tdw = camel_data_wrapper_new ();\n\t\tsuccess = camel_data_wrapper_construct_from_stream_sync (\n\t\t\tdw, ostream, NULL, error);\n\t\tcamel_data_wrapper_set_mime_type (dw, \"application\/octet-stream\");\n\t\tcamel_medium_set_content ((CamelMedium *) opart, dw);\n\t\tg_object_unref (dw);\n\t\t\/* Set mime\/type of this new part to application\/octet-stream to force type snooping *\/\n\t\tcamel_mime_part_set_content_type (opart, \"application\/octet-stream\");\n\t}\n\n\tif (success) {\n\t\tvalid = camel_cipher_validity_new ();\n\t\tvalid->encrypt.description = g_strdup (_(\"Encrypted content\"));\n\t\tvalid->encrypt.status = CAMEL_CIPHER_VALIDITY_ENCRYPT_ENCRYPTED;\n\n\t\tif (gpg->hadsig) {\n\t\t\tif (gpg->validsig) {\n\t\t\t\tif (gpg->trust == GPG_TRUST_UNDEFINED || gpg->trust == GPG_TRUST_NONE)\n\t\t\t\t\tvalid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_UNKNOWN;\n\t\t\t\telse if (gpg->trust != GPG_TRUST_NEVER)\n\t\t\t\t\tvalid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_GOOD;\n\t\t\t\telse\n\t\t\t\t\tvalid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;\n\t\t\t} else if (gpg->nopubkey) {\n\t\t\t\tvalid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_NEED_PUBLIC_KEY;\n\t\t\t} else {\n\t\t\t\tvalid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;\n\t\t\t}\n\n\t\t\tadd_signers (valid, gpg->signers);\n\t\t}\n\t}\n\n fail:\n\tg_object_unref (ostream);\n\tg_object_unref (istream);\n\tgpg_ctx_free (gpg);\n\n\treturn valid;\n}","target":0,"code_token_length":1387,"total_token_length":1623,"max_tokens_setting":2048}
+{"idx":439059,"func":"static Image *ReadTEXTImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  char\n    filename[MaxTextExtent],\n    geometry[MaxTextExtent],\n    *p,\n    text[MaxTextExtent];\n\n  DrawInfo\n    *draw_info;\n\n  Image\n    *image,\n    *texture;\n\n  MagickBooleanType\n    status;\n\n  PointInfo\n    delta;\n\n  RectangleInfo\n    page;\n\n  ssize_t\n    offset;\n\n  TypeMetric\n    metrics;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  (void) memset(text,0,sizeof(text));\n  (void) ReadBlobString(image,text);\n  \/*\n    Set the page geometry.\n  *\/\n  delta.x=DefaultResolution;\n  delta.y=DefaultResolution;\n  if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))\n    {\n      GeometryInfo\n        geometry_info;\n\n      MagickStatusType\n        flags;\n\n      flags=ParseGeometry(PSDensityGeometry,&geometry_info);\n      image->x_resolution=geometry_info.rho;\n      image->y_resolution=geometry_info.sigma;\n      if ((flags & SigmaValue) == 0)\n        image->y_resolution=image->x_resolution;\n    }\n  page.width=612;\n  page.height=792;\n  page.x=43;\n  page.y=43;\n  if (image_info->page != (char *) NULL)\n    (void) ParseAbsoluteGeometry(image_info->page,&page);\n  \/*\n    Initialize Image structure.\n  *\/\n  image->columns=(size_t) floor((((double) page.width*image->x_resolution)\/\n    delta.x)+0.5);\n  image->rows=(size_t) floor((((double) page.height*image->y_resolution)\/\n    delta.y)+0.5);\n  status=SetImageExtent(image,image->columns,image->rows);\n  if (status != MagickFalse)\n    status=ResetImagePixels(image,&image->exception);\n  if (status == MagickFalse)\n    {\n      InheritException(exception,&image->exception);\n      return(DestroyImageList(image));\n    }\n  image->page.x=0;\n  image->page.y=0;\n  texture=(Image *) NULL;\n  if (image_info->texture != (char *) NULL)\n    {\n      ImageInfo\n        *read_info;\n\n      read_info=CloneImageInfo(image_info);\n      SetImageInfoBlob(read_info,(void *) NULL,0);\n      (void) CopyMagickString(read_info->filename,image_info->texture,\n        MaxTextExtent);\n      texture=ReadImage(read_info,exception);\n      read_info=DestroyImageInfo(read_info);\n    }\n  \/*\n    Annotate the text image.\n  *\/\n  (void) SetImageBackgroundColor(image);\n  draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);\n  (void) CloneString(&draw_info->text,image_info->filename);\n  (void) FormatLocaleString(geometry,MaxTextExtent,\"%gx%g%+g%+g\",(double)\n    image->columns,(double) image->rows,(double) page.x,(double) page.y);\n  (void) CloneString(&draw_info->geometry,geometry);\n  status=GetTypeMetrics(image,draw_info,&metrics);\n  if (status == MagickFalse)\n    {\n      draw_info=DestroyDrawInfo(draw_info);\n      ThrowReaderException(TypeError,\"UnableToGetTypeMetrics\");\n    }\n  page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);\n  (void) FormatLocaleString(geometry,MaxTextExtent,\"%gx%g%+g%+g\",(double)\n    image->columns,(double) image->rows,(double) page.x,(double) page.y);\n  (void) CloneString(&draw_info->geometry,geometry);\n  (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);\n  if (*draw_info->text != '\\0')\n    *draw_info->text='\\0';\n  p=text;\n  for (offset=2*page.y; p != (char *) NULL; )\n  {\n    \/*\n      Annotate image with text.\n    *\/\n    (void) ConcatenateString(&draw_info->text,text);\n    (void) ConcatenateString(&draw_info->text,\"\\n\");\n    offset+=(ssize_t) (metrics.ascent-metrics.descent);\n    if (image->previous == (Image *) NULL)\n      {\n        status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset,\n          image->rows);\n        if (status == MagickFalse)\n          break;\n      }\n    p=ReadBlobString(image,text);\n    if ((offset < (ssize_t) image->rows) && (p != (char *) NULL))\n      continue;\n    if (texture != (Image *) NULL)\n      {\n        MagickProgressMonitor\n          progress_monitor;\n\n        progress_monitor=SetImageProgressMonitor(image,\n          (MagickProgressMonitor) NULL,image->client_data);\n        (void) TextureImage(image,texture);\n        (void) SetImageProgressMonitor(image,progress_monitor,\n          image->client_data);\n      }\n    (void) AnnotateImage(image,draw_info);\n    if (p == (char *) NULL)\n      break;\n    \/*\n      Page is full-- allocate next image structure.\n    *\/\n    *draw_info->text='\\0';\n    offset=2*page.y;\n    AcquireNextImage(image_info,image);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      {\n        image=DestroyImageList(image);\n        return((Image *) NULL);\n      }\n    image->next->columns=image->columns;\n    image->next->rows=image->rows;\n    image=SyncNextImageInList(image);\n    (void) CopyMagickString(image->filename,filename,MaxTextExtent);\n    (void) SetImageBackgroundColor(image);\n    status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n      GetBlobSize(image));\n    if (status == MagickFalse)\n      break;\n  }\n  if (texture != (Image *) NULL)\n    {\n      MagickProgressMonitor\n        progress_monitor;\n\n      progress_monitor=SetImageProgressMonitor(image,\n        (MagickProgressMonitor) NULL,image->client_data);\n      (void) TextureImage(image,texture);\n      (void) SetImageProgressMonitor(image,progress_monitor,image->client_data);\n    }\n  (void) AnnotateImage(image,draw_info);\n  if (texture != (Image *) NULL)\n    texture=DestroyImage(texture);\n  draw_info=DestroyDrawInfo(draw_info);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":1534,"total_token_length":1770,"max_tokens_setting":2048}
+{"idx":502714,"func":"int ssl_get_new_session(SSL *s, int session)\n{\n    \/* This gets used by clients and servers. *\/\n\n    unsigned int tmp;\n    SSL_SESSION *ss = NULL;\n    GEN_SESSION_CB cb = def_generate_session_id;\n\n    if ((ss = SSL_SESSION_new()) == NULL)\n        return (0);\n\n    \/* If the context has a default timeout, use it *\/\n    if (s->session_ctx->session_timeout == 0)\n        ss->timeout = SSL_get_default_timeout(s);\n    else\n        ss->timeout = s->session_ctx->session_timeout;\n\n    if (s->session != NULL) {\n        SSL_SESSION_free(s->session);\n        s->session = NULL;\n    }\n\n    if (session) {\n        if (s->version == SSL2_VERSION) {\n            ss->ssl_version = SSL2_VERSION;\n            ss->session_id_length = SSL2_SSL_SESSION_ID_LENGTH;\n        } else if (s->version == SSL3_VERSION) {\n            ss->ssl_version = SSL3_VERSION;\n            ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;\n        } else if (s->version == TLS1_VERSION) {\n            ss->ssl_version = TLS1_VERSION;\n            ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;\n        } else if (s->version == TLS1_1_VERSION) {\n            ss->ssl_version = TLS1_1_VERSION;\n            ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;\n        } else if (s->version == TLS1_2_VERSION) {\n            ss->ssl_version = TLS1_2_VERSION;\n            ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;\n        } else if (s->version == DTLS1_BAD_VER) {\n            ss->ssl_version = DTLS1_BAD_VER;\n            ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;\n        } else if (s->version == DTLS1_VERSION) {\n            ss->ssl_version = DTLS1_VERSION;\n            ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;\n        } else {\n            SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_UNSUPPORTED_SSL_VERSION);\n            SSL_SESSION_free(ss);\n            return (0);\n        }\n#ifndef OPENSSL_NO_TLSEXT\n        \/*-\n         * If RFC5077 ticket, use empty session ID (as server).\n         * Note that:\n         * (a) ssl_get_prev_session() does lookahead into the\n         *     ClientHello extensions to find the session ticket.\n         *     When ssl_get_prev_session() fails, s3_srvr.c calls\n         *     ssl_get_new_session() in ssl3_get_client_hello().\n         *     At that point, it has not yet parsed the extensions,\n         *     however, because of the lookahead, it already knows\n         *     whether a ticket is expected or not.\n         *\n         * (b) s3_clnt.c calls ssl_get_new_session() before parsing\n         *     ServerHello extensions, and before recording the session\n         *     ID received from the server, so this block is a noop.\n         *\/\n        if (s->tlsext_ticket_expected) {\n            ss->session_id_length = 0;\n            goto sess_id_done;\n        }\n#endif\n        \/* Choose which callback will set the session ID *\/\n        CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);\n        if (s->generate_session_id)\n            cb = s->generate_session_id;\n        else if (s->session_ctx->generate_session_id)\n            cb = s->session_ctx->generate_session_id;\n        CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);\n        \/* Choose a session ID *\/\n        tmp = ss->session_id_length;\n        if (!cb(s, ss->session_id, &tmp)) {\n            \/* The callback failed *\/\n            SSLerr(SSL_F_SSL_GET_NEW_SESSION,\n                   SSL_R_SSL_SESSION_ID_CALLBACK_FAILED);\n            SSL_SESSION_free(ss);\n            return (0);\n        }\n        \/*\n         * Don't allow the callback to set the session length to zero. nor\n         * set it higher than it was.\n         *\/\n        if (!tmp || (tmp > ss->session_id_length)) {\n            \/* The callback set an illegal length *\/\n            SSLerr(SSL_F_SSL_GET_NEW_SESSION,\n                   SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH);\n            SSL_SESSION_free(ss);\n            return (0);\n        }\n        \/* If the session length was shrunk and we're SSLv2, pad it *\/\n        if ((tmp < ss->session_id_length) && (s->version == SSL2_VERSION))\n            memset(ss->session_id + tmp, 0, ss->session_id_length - tmp);\n        else\n            ss->session_id_length = tmp;\n        \/* Finally, check for a conflict *\/\n        if (SSL_has_matching_session_id(s, ss->session_id,\n                                        ss->session_id_length)) {\n            SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_SSL_SESSION_ID_CONFLICT);\n            SSL_SESSION_free(ss);\n            return (0);\n        }\n#ifndef OPENSSL_NO_TLSEXT\n sess_id_done:\n        if (s->tlsext_hostname) {\n            ss->tlsext_hostname = BUF_strdup(s->tlsext_hostname);\n            if (ss->tlsext_hostname == NULL) {\n                SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);\n                SSL_SESSION_free(ss);\n                return 0;\n            }\n        }\n# ifndef OPENSSL_NO_EC\n        if (s->tlsext_ecpointformatlist) {\n            if (ss->tlsext_ecpointformatlist != NULL)\n                OPENSSL_free(ss->tlsext_ecpointformatlist);\n            if ((ss->tlsext_ecpointformatlist =\n                 OPENSSL_malloc(s->tlsext_ecpointformatlist_length)) ==\n                NULL) {\n                SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_MALLOC_FAILURE);\n                SSL_SESSION_free(ss);\n                return 0;\n            }\n            ss->tlsext_ecpointformatlist_length =\n                s->tlsext_ecpointformatlist_length;\n            memcpy(ss->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist,\n                   s->tlsext_ecpointformatlist_length);\n        }\n        if (s->tlsext_ellipticcurvelist) {\n            if (ss->tlsext_ellipticcurvelist != NULL)\n                OPENSSL_free(ss->tlsext_ellipticcurvelist);\n            if ((ss->tlsext_ellipticcurvelist =\n                 OPENSSL_malloc(s->tlsext_ellipticcurvelist_length)) ==\n                NULL) {\n                SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_MALLOC_FAILURE);\n                SSL_SESSION_free(ss);\n                return 0;\n            }\n            ss->tlsext_ellipticcurvelist_length =\n                s->tlsext_ellipticcurvelist_length;\n            memcpy(ss->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist,\n                   s->tlsext_ellipticcurvelist_length);\n        }\n# endif\n#endif\n    } else {\n        ss->session_id_length = 0;\n    }\n\n    if (s->sid_ctx_length > sizeof ss->sid_ctx) {\n        SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);\n        SSL_SESSION_free(ss);\n        return 0;\n    }\n    memcpy(ss->sid_ctx, s->sid_ctx, s->sid_ctx_length);\n    ss->sid_ctx_length = s->sid_ctx_length;\n    s->session = ss;\n    ss->ssl_version = s->version;\n    ss->verify_result = X509_V_OK;\n\n    return (1);\n}","target":0,"code_token_length":1639,"total_token_length":1875,"max_tokens_setting":2048}
+{"idx":225502,"func":"Status MutableGraphView::UpdateFanoutsInternal(NodeDef* from_node,\n                                               NodeDef* to_node) {\n  VLOG(2) << absl::Substitute(\"Update fanouts from '$0' to '$1'.\",\n                              from_node->name(), to_node->name());\n  if (from_node == to_node) {\n    return Status::OK();\n  }\n\n  \/\/ Update internal state with the new output_port->input_port edge.\n  const auto add_edge = [this](const OutputPort& output_port,\n                               const InputPort& input_port) {\n    fanouts()[output_port].insert(input_port);\n  };\n\n  \/\/ Remove invalidated edge from the internal state.\n  const auto remove_edge = [this](const OutputPort& output_port,\n                                  const InputPort& input_port) {\n    fanouts()[output_port].erase(input_port);\n  };\n\n  \/\/ For the control fanouts we do not know the input index in a NodeDef,\n  \/\/ so we have to traverse all control inputs.\n\n  auto control_fanouts =\n      GetFanout(GraphView::OutputPort(from_node, Graph::kControlSlot));\n\n  bool to_node_is_switch = IsSwitch(*to_node);\n  for (const InputPort& control_port : control_fanouts) {\n    \/\/ Node can't be control dependency of itself.\n    if (control_port.node == to_node) continue;\n\n    \/\/ Can't add Switch node as a control dependency.\n    if (to_node_is_switch) {\n      \/\/ Trying to add a Switch as a control dependency, which if allowed will\n      \/\/ make the graph invalid.\n      return UpdateFanoutsError(from_node->name(), to_node->name())(\n          absl::Substitute(\"can't update fanouts to node '$0' as it will \"\n                           \"become a Switch control dependency\",\n                           to_node->name()));\n    }\n\n    NodeDef* node = control_port.node;\n    RemoveControllingFaninInternal(node, from_node);\n    AddFaninInternal(node, {to_node, Graph::kControlSlot});\n  }\n\n  \/\/ First we update regular fanouts. For the regular fanouts\n  \/\/ `input_port:port_id` is the input index in NodeDef.\n\n  auto regular_edges =\n      GetFanoutEdges(*from_node, \/*include_controlled_edges=*\/false);\n\n  \/\/ Maximum index of the `from_node` output tensor that is still used as an\n  \/\/ input to some other node.\n  int keep_max_regular_output_port = -1;\n\n  for (const Edge& edge : regular_edges) {\n    const OutputPort output_port = edge.src;\n    const InputPort input_port = edge.dst;\n\n    \/\/ If the `to_node` reads from the `from_node`, skip this edge (see\n    \/\/ AddAndUpdateFanoutsWithoutSelfLoops test for an example).\n    if (input_port.node == to_node) {\n      keep_max_regular_output_port =\n          std::max(keep_max_regular_output_port, output_port.port_id);\n      continue;\n    }\n\n    \/\/ Update input at destination node.\n    input_port.node->set_input(\n        input_port.port_id,\n        TensorIdToString({to_node->name(), output_port.port_id}));\n\n    \/\/ Remove old edge between the `from_node` and the fanout node.\n    remove_edge(output_port, input_port);\n    \/\/ Add an edge between the `to_node` and new fanout node.\n    add_edge(OutputPort(to_node, output_port.port_id), input_port);\n    \/\/ Dedup control dependency.\n    if (CanDedupControlWithRegularInput(*this, *to_node)) {\n      RemoveControllingFaninInternal(input_port.node, to_node);\n    }\n  }\n\n  \/\/ Because we update all regular fanouts of `from_node`, we can just copy\n  \/\/ the value `num_regular_outputs`.\n  max_regular_output_port()[to_node] = max_regular_output_port()[from_node];\n\n  \/\/ Check if all fanouts were updated to read from the `to_node`.\n  if (keep_max_regular_output_port >= 0) {\n    max_regular_output_port()[from_node] = keep_max_regular_output_port;\n  } else {\n    max_regular_output_port().erase(from_node);\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":878,"total_token_length":1114,"max_tokens_setting":2048}
+{"idx":481285,"func":"struct mlx5_fpga_conn *mlx5_fpga_conn_create(struct mlx5_fpga_device *fdev,\n\t\t\t\t\t     struct mlx5_fpga_conn_attr *attr,\n\t\t\t\t\t     enum mlx5_ifc_fpga_qp_type qp_type)\n{\n\tstruct mlx5_fpga_conn *ret, *conn;\n\tu8 *remote_mac, *remote_ip;\n\tint err;\n\n\tif (!attr->recv_cb)\n\t\treturn ERR_PTR(-EINVAL);\n\n\tconn = kzalloc(sizeof(*conn), GFP_KERNEL);\n\tif (!conn)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tconn->fdev = fdev;\n\tINIT_LIST_HEAD(&conn->qp.sq.backlog);\n\n\tspin_lock_init(&conn->qp.sq.lock);\n\n\tconn->recv_cb = attr->recv_cb;\n\tconn->cb_arg = attr->cb_arg;\n\n\tremote_mac = MLX5_ADDR_OF(fpga_qpc, conn->fpga_qpc, remote_mac_47_32);\n\terr = mlx5_query_mac_address(fdev->mdev, remote_mac);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to query local MAC: %d\\n\", err);\n\t\tret = ERR_PTR(err);\n\t\tgoto err;\n\t}\n\n\t\/* Build Modified EUI-64 IPv6 address from the MAC address *\/\n\tremote_ip = MLX5_ADDR_OF(fpga_qpc, conn->fpga_qpc, remote_ip);\n\tremote_ip[0] = 0xfe;\n\tremote_ip[1] = 0x80;\n\taddrconf_addr_eui48(&remote_ip[8], remote_mac);\n\n\terr = mlx5_core_reserved_gid_alloc(fdev->mdev, &conn->qp.sgid_index);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to allocate SGID: %d\\n\", err);\n\t\tret = ERR_PTR(err);\n\t\tgoto err;\n\t}\n\n\terr = mlx5_core_roce_gid_set(fdev->mdev, conn->qp.sgid_index,\n\t\t\t\t     MLX5_ROCE_VERSION_2,\n\t\t\t\t     MLX5_ROCE_L3_TYPE_IPV6,\n\t\t\t\t     remote_ip, remote_mac, true, 0,\n\t\t\t\t     MLX5_FPGA_PORT_NUM);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to set SGID: %d\\n\", err);\n\t\tret = ERR_PTR(err);\n\t\tgoto err_rsvd_gid;\n\t}\n\tmlx5_fpga_dbg(fdev, \"Reserved SGID index %u\\n\", conn->qp.sgid_index);\n\n\t\/* Allow for one cqe per rx\/tx wqe, plus one cqe for the next wqe,\n\t * created during processing of the cqe\n\t *\/\n\terr = mlx5_fpga_conn_create_cq(conn,\n\t\t\t\t       (attr->tx_size + attr->rx_size) * 2);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to create CQ: %d\\n\", err);\n\t\tret = ERR_PTR(err);\n\t\tgoto err_gid;\n\t}\n\n\tmlx5_fpga_conn_arm_cq(conn);\n\n\terr = mlx5_fpga_conn_create_qp(conn, attr->tx_size, attr->rx_size);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to create QP: %d\\n\", err);\n\t\tret = ERR_PTR(err);\n\t\tgoto err_cq;\n\t}\n\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, state, MLX5_FPGA_QPC_STATE_INIT);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, qp_type, qp_type);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, st, MLX5_FPGA_QPC_ST_RC);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, ether_type, ETH_P_8021Q);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, vid, 0);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, next_rcv_psn, 1);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, next_send_psn, 0);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, pkey, MLX5_FPGA_PKEY);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, remote_qpn, conn->qp.mqp.qpn);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, rnr_retry, 7);\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, retry_count, 7);\n\n\terr = mlx5_fpga_create_qp(fdev->mdev, &conn->fpga_qpc,\n\t\t\t\t  &conn->fpga_qpn);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to create FPGA RC QP: %d\\n\", err);\n\t\tret = ERR_PTR(err);\n\t\tgoto err_qp;\n\t}\n\n\terr = mlx5_fpga_conn_connect(conn);\n\tif (err) {\n\t\tret = ERR_PTR(err);\n\t\tgoto err_conn;\n\t}\n\n\tmlx5_fpga_dbg(fdev, \"FPGA QPN is %u\\n\", conn->fpga_qpn);\n\tret = conn;\n\tgoto out;\n\nerr_conn:\n\tmlx5_fpga_destroy_qp(conn->fdev->mdev, conn->fpga_qpn);\nerr_qp:\n\tmlx5_fpga_conn_destroy_qp(conn);\nerr_cq:\n\tmlx5_fpga_conn_destroy_cq(conn);\nerr_gid:\n\tmlx5_core_roce_gid_set(fdev->mdev, conn->qp.sgid_index, 0, 0, NULL,\n\t\t\t       NULL, false, 0, MLX5_FPGA_PORT_NUM);\nerr_rsvd_gid:\n\tmlx5_core_reserved_gid_free(fdev->mdev, conn->qp.sgid_index);\nerr:\n\tkfree(conn);\nout:\n\treturn ret;\n}","target":0,"code_token_length":1270,"total_token_length":1506,"max_tokens_setting":2048}
+{"idx":270376,"func":"static bool ok_png_read_data(ok_png_decoder *decoder, uint32_t bytes_remaining) {\n    ok_png *png = decoder->png;\n    size_t inflate_buffer_size = 64 * 1024;\n    size_t num_passes = decoder->interlace_method == 0 ? 1 : 7;\n    uint8_t bits_per_pixel = decoder->bit_depth * OK_PNG_SAMPLES_PER_PIXEL[decoder->color_type];\n    uint8_t bytes_per_pixel = (bits_per_pixel + 7) \/ 8;\n    uint64_t max_bytes_per_scanline = 1 + ((uint64_t)png->width * bits_per_pixel + 7) \/ 8;\n    size_t platform_max_bytes_per_scanline = (size_t)max_bytes_per_scanline;\n\n    \/\/ Create buffers\n    if (!png->data) {\n        if (decoder->allocator.image_alloc) {\n            decoder->allocator.image_alloc(decoder->allocator_user_data,\n                                           png->width, png->height, png->bpp,\n                                           &png->data, &png->stride);\n        } else {\n            uint64_t size = (uint64_t)png->stride * png->height;\n            size_t platform_size = (size_t)size;\n            if (platform_size == size) {\n                png->data = ok_alloc(decoder, platform_size);\n            }\n        }\n        if (!png->data) {\n            ok_png_error(png, OK_PNG_ERROR_ALLOCATION, \"Couldn't allocate memory for image\");\n            return false;\n        }\n        if (png->stride < png->width * png->bpp) {\n            ok_png_error(png, OK_PNG_ERROR_API, \"Invalid stride\");\n            return false;\n        }\n    }\n    if (!decoder->prev_scanline) {\n        if (max_bytes_per_scanline == platform_max_bytes_per_scanline) {\n            decoder->prev_scanline = ok_alloc(decoder, platform_max_bytes_per_scanline);\n        }\n    }\n    if (!decoder->curr_scanline) {\n        if (max_bytes_per_scanline == platform_max_bytes_per_scanline) {\n            decoder->curr_scanline = ok_alloc(decoder, platform_max_bytes_per_scanline);\n        }\n    }\n    if (!decoder->inflate_buffer) {\n        decoder->inflate_buffer = ok_alloc(decoder, inflate_buffer_size);\n    }\n    if (decoder->interlace_method == 1 && !decoder->temp_data_row) {\n        decoder->temp_data_row = ok_alloc(decoder, png->width * png->bpp);\n    }\n    if (!decoder->curr_scanline || !decoder->prev_scanline || !decoder->inflate_buffer ||\n        (decoder->interlace_method == 1 && !decoder->temp_data_row)) {\n        ok_png_error(png, OK_PNG_ERROR_ALLOCATION, \"Couldn't allocate buffers\");\n        return false;\n    }\n\n    \/\/ Setup inflater\n    if (!decoder->inflater) {\n        decoder->inflater = ok_inflater_init(decoder->is_ios_format,\n                                             decoder->allocator, decoder->allocator_user_data);\n        if (!decoder->inflater) {\n            ok_png_error(png, OK_PNG_ERROR_ALLOCATION, \"Couldn't init inflater\");\n            return false;\n        }\n    }\n\n    \/\/ Sanity check - this happened with one file in the PNG suite\n    if (decoder->decoding_completed) {\n        if (bytes_remaining > 0) {\n            return ok_seek(decoder, (long)bytes_remaining);\n        } else {\n            return true;\n        }\n    }\n\n    \/\/ Read data\n    uint32_t curr_width = ok_png_get_width_for_pass(decoder);\n    uint32_t curr_height = ok_png_get_height_for_pass(decoder);\n    size_t curr_bytes_per_scanline = (size_t)(1 + ((uint64_t)curr_width * bits_per_pixel + 7) \/ 8);\n    while (true) {\n        \/\/ Setup pass\n        while (decoder->ready_for_next_interlace_pass) {\n            decoder->ready_for_next_interlace_pass = false;\n            decoder->scanline = 0;\n            decoder->interlace_pass++;\n            if (decoder->interlace_pass == num_passes + 1) {\n                \/\/ Done decoding - skip any remaining chunk data\n                decoder->decoding_completed = true;\n                if (bytes_remaining > 0) {\n                    return ok_seek(decoder, (long)bytes_remaining);\n                } else {\n                    return true;\n                }\n            }\n            curr_width = ok_png_get_width_for_pass(decoder);\n            curr_height = ok_png_get_height_for_pass(decoder);\n            curr_bytes_per_scanline = (size_t)(1 + ((uint64_t)curr_width * bits_per_pixel + 7) \/ 8);\n            if (curr_width == 0 || curr_height == 0) {\n                \/\/ No data for this pass - happens if width or height <= 4\n                decoder->ready_for_next_interlace_pass = true;\n            } else {\n                memset(decoder->curr_scanline, 0, curr_bytes_per_scanline);\n                memset(decoder->prev_scanline, 0, curr_bytes_per_scanline);\n                decoder->inflater_bytes_read = 0;\n            }\n        }\n\n        \/\/ Read compressed data\n        if (ok_inflater_needs_input(decoder->inflater)) {\n            if (bytes_remaining == 0) {\n                \/\/ Need more data, but there is no remaining data in this chunk.\n                \/\/ There may be another IDAT chunk.\n                return true;\n            }\n            const size_t len = min(inflate_buffer_size, bytes_remaining);\n            if (!ok_read(decoder, decoder->inflate_buffer, len)) {\n                return false;\n            }\n            bytes_remaining -= len;\n            ok_inflater_set_input(decoder->inflater, decoder->inflate_buffer, len);\n        }\n\n        \/\/ Decompress data\n        size_t len = ok_inflater_inflate(decoder->inflater,\n                                         decoder->curr_scanline + decoder->inflater_bytes_read,\n                                         curr_bytes_per_scanline - decoder->inflater_bytes_read);\n        if (len == OK_SIZE_MAX) {\n            ok_png_error(png, OK_PNG_ERROR_INFLATER, \"Inflater error\");\n            return false;\n        }\n        decoder->inflater_bytes_read += len;\n        if (decoder->inflater_bytes_read == curr_bytes_per_scanline) {\n            \/\/ Apply filter\n            const int filter = decoder->curr_scanline[0];\n            if (filter > 0 && filter < OK_PNG_NUM_FILTERS) {\n                ok_png_decode_filter(decoder->curr_scanline + 1, decoder->prev_scanline + 1,\n                                     curr_bytes_per_scanline - 1, filter, bytes_per_pixel);\n            } else if (filter != 0) {\n                ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid filter type\");\n                return false;\n            }\n\n            \/\/ Transform\n            ok_png_transform_scanline(decoder, decoder->curr_scanline + 1, curr_width);\n\n            \/\/ Setup for next scanline or pass\n            decoder->scanline++;\n            if (decoder->scanline == curr_height) {\n                decoder->ready_for_next_interlace_pass = true;\n            } else {\n                uint8_t *temp = decoder->curr_scanline;\n                decoder->curr_scanline = decoder->prev_scanline;\n                decoder->prev_scanline = temp;\n                decoder->inflater_bytes_read = 0;\n            }\n        }\n    }\n}","target":0,"code_token_length":1566,"total_token_length":1802,"max_tokens_setting":2048}
+{"idx":293749,"func":"static RList *resolve_mig_subsystem(RKernelCacheObj *obj) {\n\tstruct section_t *sections = NULL;\n\tif (!(sections = MACH0_(get_sections) (obj->mach0))) {\n\t\treturn NULL;\n\t}\n\n\tHtPP *mig_hash = NULL;\n\tRList *subsystem = NULL;\n\tut8 *data_const = NULL;\n\tut64 data_const_offset = 0, data_const_size = 0, data_const_vaddr = 0;\n\tut64 text_exec_offset = 0, text_exec_size = 0, text_exec_vaddr = 0;\n\tint incomplete = 2;\n\tint i = 0;\n\tfor (; !sections[i].last && incomplete > 0; i++) {\n\t\tif (strstr (sections[i].name, \"__DATA_CONST.__const\")) {\n\t\t\tdata_const_offset = sections[i].offset;\n\t\t\tdata_const_size = sections[i].size;\n\t\t\tdata_const_vaddr = K_PPTR (sections[i].addr);\n\t\t\tincomplete--;\n\t\t}\n\t\tif (strstr (sections[i].name, \"__TEXT_EXEC.__text\")) {\n\t\t\ttext_exec_offset = sections[i].offset;\n\t\t\ttext_exec_size = sections[i].size;\n\t\t\ttext_exec_vaddr = K_PPTR (sections[i].addr);\n\t\t\tincomplete--;\n\t\t}\n\t}\n\n\tif (!data_const_offset || !data_const_size || !data_const_vaddr ||\n\t\t!text_exec_offset || !text_exec_size || !text_exec_vaddr) {\n\t\tgoto beach;\n\t}\n\n\tdata_const = malloc (data_const_size);\n\tif (!data_const) {\n\t\tgoto beach;\n\t}\n\tif (r_buf_read_at (obj->cache_buf, data_const_offset, data_const, data_const_size) < data_const_size) {\n\t\tgoto beach;\n\t}\n\n\tsubsystem = r_list_newf (r_bin_symbol_free);\n\tif (!subsystem) {\n\t\tgoto beach;\n\t}\n\n\tmig_hash = mig_hash_new ();\n\tif (!mig_hash) {\n\t\tgoto beach;\n\t}\n\n\tut8 *cursor = data_const;\n\tut8 *end = data_const + data_const_size;\n\twhile (cursor < end) {\n\t\tut64 subs_p = K_PPTR (r_read_le64 (cursor));\n\t\tif (subs_p < text_exec_vaddr || subs_p >= text_exec_vaddr + text_exec_size) {\n\t\t\tcursor += 8;\n\t\t\tcontinue;\n\t\t}\n\t\tut32 subs_min_idx = r_read_le32 (cursor + 8);\n\t\tut32 subs_max_idx = r_read_le32 (cursor + 12);\n\t\tif (subs_min_idx >= subs_max_idx || (subs_max_idx - subs_min_idx) > K_MIG_MAX_ROUTINES) {\n\t\t\tcursor += 16;\n\t\t\tcontinue;\n\t\t}\n\n\t\tut32 n_routines = (subs_max_idx - subs_min_idx);\n\t\tut64 *routines = (ut64 *) calloc (n_routines, sizeof (ut64));\n\t\tif (!routines) {\n\t\t\tgoto beach;\n\t\t}\n\t\tut8 *array_cursor = cursor + K_MIG_SUBSYSTEM_SIZE;\n\t\tut8 *end_array = array_cursor + n_routines * K_MIG_ROUTINE_SIZE;\n\t\tbool is_consistent = true;\n\t\tint idx = 0;\n\t\twhile (array_cursor < end_array) {\n\t\t\tut64 should_be_null = r_read_le64 (array_cursor);\n\t\t\tif (should_be_null != 0) {\n\t\t\t\tis_consistent = false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tut64 routine_p = K_PPTR (r_read_le64 (array_cursor + 8));\n\t\t\tif (routine_p != 0 && (routine_p < text_exec_vaddr || routine_p >= text_exec_vaddr + text_exec_size)) {\n\t\t\t\tis_consistent = false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\troutines[idx++] = routine_p;\n\t\t\tarray_cursor += K_MIG_ROUTINE_SIZE;\n\t\t}\n\n\t\tif (is_consistent) {\n\t\t\tfor (idx = 0; idx < n_routines; idx++) {\n\t\t\t\tut64 routine_p = routines[idx];\n\t\t\t\tif (!routine_p) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tif (!sym) {\n\t\t\t\t\tR_FREE (routines);\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\n\t\t\t\tint num = idx + subs_min_idx;\n\t\t\t\tbool found = false;\n\t\t\t\tr_strf_var (key, 32, \"%d\", num);\n\t\t\t\tconst char *name = sdb_ht_find (mig_hash, key, &found);\n\t\t\t\tif (found && name && *name) {\n\t\t\t\t\tsym->name = r_str_newf (\"mig.%d.%s\", num, name);\n\t\t\t\t} else {\n\t\t\t\t\tsym->name = r_str_newf (\"mig.%d\", num);\n\t\t\t\t}\n\n\t\t\t\tsym->vaddr = routine_p;\n\t\t\t\tsym->paddr = sym->vaddr - text_exec_vaddr + text_exec_offset;\n\t\t\t\tsym->size = 0;\n\t\t\t\tsym->forwarder = \"NONE\";\n\t\t\t\tsym->bind = \"GLOBAL\";\n\t\t\t\tsym->type = \"OBJECT\";\n\t\t\t\tr_list_append (subsystem, sym);\n\t\t\t}\n\n\t\t\tcursor += K_MIG_SUBSYSTEM_SIZE + n_routines * K_MIG_ROUTINE_SIZE;\n\t\t} else {\n\t\t\tcursor += 8;\n\t\t}\n\n\t\tR_FREE (routines);\n\t}\n\n\tsdb_ht_free (mig_hash);\n\tR_FREE (data_const);\n\tR_FREE (sections);\n\treturn subsystem;\n\nbeach:\n\tif (subsystem) {\n\t\tr_list_free (subsystem);\n\t}\n\tif (mig_hash) {\n\t\tsdb_ht_free (mig_hash);\n\t}\n\tR_FREE (data_const);\n\tR_FREE (sections);\n\treturn NULL;\n}","target":0,"code_token_length":1240,"total_token_length":1476,"max_tokens_setting":2048}
+{"idx":355618,"func":"set_ref_in_item(\n    typval_T\t    *tv,\n    int\t\t    copyID,\n    ht_stack_T\t    **ht_stack,\n    list_stack_T    **list_stack)\n{\n    int\t\tabort = FALSE;\n\n    if (tv->v_type == VAR_DICT)\n    {\n\tdict_T\t*dd = tv->vval.v_dict;\n\n\tif (dd != NULL && dd->dv_copyID != copyID)\n\t{\n\t    \/\/ Didn't see this dict yet.\n\t    dd->dv_copyID = copyID;\n\t    if (ht_stack == NULL)\n\t    {\n\t\tabort = set_ref_in_ht(&dd->dv_hashtab, copyID, list_stack);\n\t    }\n\t    else\n\t    {\n\t\tht_stack_T *newitem = ALLOC_ONE(ht_stack_T);\n\n\t\tif (newitem == NULL)\n\t\t    abort = TRUE;\n\t\telse\n\t\t{\n\t\t    newitem->ht = &dd->dv_hashtab;\n\t\t    newitem->prev = *ht_stack;\n\t\t    *ht_stack = newitem;\n\t\t}\n\t    }\n\t}\n    }\n    else if (tv->v_type == VAR_LIST)\n    {\n\tlist_T\t*ll = tv->vval.v_list;\n\n\tif (ll != NULL && ll->lv_copyID != copyID)\n\t{\n\t    \/\/ Didn't see this list yet.\n\t    ll->lv_copyID = copyID;\n\t    if (list_stack == NULL)\n\t    {\n\t\tabort = set_ref_in_list_items(ll, copyID, ht_stack);\n\t    }\n\t    else\n\t    {\n\t\tlist_stack_T *newitem = ALLOC_ONE(list_stack_T);\n\n\t\tif (newitem == NULL)\n\t\t    abort = TRUE;\n\t\telse\n\t\t{\n\t\t    newitem->list = ll;\n\t\t    newitem->prev = *list_stack;\n\t\t    *list_stack = newitem;\n\t\t}\n\t    }\n\t}\n    }\n    else if (tv->v_type == VAR_FUNC)\n    {\n\tabort = set_ref_in_func(tv->vval.v_string, NULL, copyID);\n    }\n    else if (tv->v_type == VAR_PARTIAL)\n    {\n\tpartial_T\t*pt = tv->vval.v_partial;\n\tint\t\ti;\n\n\tif (pt != NULL && pt->pt_copyID != copyID)\n\t{\n\t    \/\/ Didn't see this partial yet.\n\t    pt->pt_copyID = copyID;\n\n\t    abort = set_ref_in_func(pt->pt_name, pt->pt_func, copyID);\n\n\t    if (pt->pt_dict != NULL)\n\t    {\n\t\ttypval_T dtv;\n\n\t\tdtv.v_type = VAR_DICT;\n\t\tdtv.vval.v_dict = pt->pt_dict;\n\t\tset_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t    }\n\n\t    for (i = 0; i < pt->pt_argc; ++i)\n\t\tabort = abort || set_ref_in_item(&pt->pt_argv[i], copyID,\n\t\t\t\t\t\t\tht_stack, list_stack);\n\t    \/\/ pt_funcstack is handled in set_ref_in_funcstacks()\n\t}\n    }\n#ifdef FEAT_JOB_CHANNEL\n    else if (tv->v_type == VAR_JOB)\n    {\n\tjob_T\t    *job = tv->vval.v_job;\n\ttypval_T    dtv;\n\n\tif (job != NULL && job->jv_copyID != copyID)\n\t{\n\t    job->jv_copyID = copyID;\n\t    if (job->jv_channel != NULL)\n\t    {\n\t\tdtv.v_type = VAR_CHANNEL;\n\t\tdtv.vval.v_channel = job->jv_channel;\n\t\tset_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t    }\n\t    if (job->jv_exit_cb.cb_partial != NULL)\n\t    {\n\t\tdtv.v_type = VAR_PARTIAL;\n\t\tdtv.vval.v_partial = job->jv_exit_cb.cb_partial;\n\t\tset_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t    }\n\t}\n    }\n    else if (tv->v_type == VAR_CHANNEL)\n    {\n\tchannel_T   *ch =tv->vval.v_channel;\n\tch_part_T   part;\n\ttypval_T    dtv;\n\tjsonq_T\t    *jq;\n\tcbq_T\t    *cq;\n\n\tif (ch != NULL && ch->ch_copyID != copyID)\n\t{\n\t    ch->ch_copyID = copyID;\n\t    for (part = PART_SOCK; part < PART_COUNT; ++part)\n\t    {\n\t\tfor (jq = ch->ch_part[part].ch_json_head.jq_next; jq != NULL;\n\t\t\t\t\t\t\t     jq = jq->jq_next)\n\t\t    set_ref_in_item(jq->jq_value, copyID, ht_stack, list_stack);\n\t\tfor (cq = ch->ch_part[part].ch_cb_head.cq_next; cq != NULL;\n\t\t\t\t\t\t\t     cq = cq->cq_next)\n\t\t    if (cq->cq_callback.cb_partial != NULL)\n\t\t    {\n\t\t\tdtv.v_type = VAR_PARTIAL;\n\t\t\tdtv.vval.v_partial = cq->cq_callback.cb_partial;\n\t\t\tset_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t\t    }\n\t\tif (ch->ch_part[part].ch_callback.cb_partial != NULL)\n\t\t{\n\t\t    dtv.v_type = VAR_PARTIAL;\n\t\t    dtv.vval.v_partial =\n\t\t\t\t      ch->ch_part[part].ch_callback.cb_partial;\n\t\t    set_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t\t}\n\t    }\n\t    if (ch->ch_callback.cb_partial != NULL)\n\t    {\n\t\tdtv.v_type = VAR_PARTIAL;\n\t\tdtv.vval.v_partial = ch->ch_callback.cb_partial;\n\t\tset_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t    }\n\t    if (ch->ch_close_cb.cb_partial != NULL)\n\t    {\n\t\tdtv.v_type = VAR_PARTIAL;\n\t\tdtv.vval.v_partial = ch->ch_close_cb.cb_partial;\n\t\tset_ref_in_item(&dtv, copyID, ht_stack, list_stack);\n\t    }\n\t}\n    }\n#endif\n    return abort;\n}","target":0,"code_token_length":1280,"total_token_length":1516,"max_tokens_setting":2048}
+{"idx":213037,"func":"mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter)\n{\n\tint k;\n\tint c1, w, c2;\n\n\tswitch (filter->status) {\n\tcase 0:\n\t\tif (filter->from->no_encoding == mbfl_no_encoding_cp950) {\n\t\t\tc1 = 0x80;\n\t\t} else {\n\t\t\tc1 = 0xa0;\n\t\t}\n\n\t\tif (c >= 0 && c <= 0x80) {\t\/* latin *\/\n\t\t\tCK((*filter->output_function)(c, filter->data));\n\t\t} else if (c == 0xff) {\n\t\t\tCK((*filter->output_function)(0xf8f8, filter->data));\n\t\t} else if (c > c1 && c < 0xff) {\t\/* dbcs lead byte *\/\n\t\t\tfilter->status = 1;\n\t\t\tfilter->cache = c;\n\t\t} else {\n\t\t\tw = c & MBFL_WCSGROUP_MASK;\n\t\t\tw |= MBFL_WCSGROUP_THROUGH;\n\t\t\tCK((*filter->output_function)(w, filter->data));\n\t\t}\n\t\tbreak;\n\n\tcase 1:\t\t\/* dbcs second byte *\/\n\t\tfilter->status = 0;\n\t\tc1 = filter->cache;\n\t\tif ((c > 0x39 && c < 0x7f) | (c > 0xa0 && c < 0xff)) {\n\t\t\tif (c < 0x7f){\n\t\t\t\tw = (c1 - 0xa1)*157 + (c - 0x40);\n\t\t\t} else {\n\t\t\t\tw = (c1 - 0xa1)*157 + (c - 0xa1) + 0x3f;\n\t\t\t}\n\t\t\tif (w >= 0 && w < big5_ucs_table_size) {\n\t\t\t\tw = big5_ucs_table[w];\n\t\t\t} else {\n\t\t\t\tw = 0;\n\t\t\t}\n\n\t\t\tif (filter->from->no_encoding == mbfl_no_encoding_cp950) {\n\t\t\t\t\/* PUA for CP950 *\/\n\t\t\t\tif (w <= 0 &&\n\t\t\t\t\t(((c1 >= 0xfa && c1 <= 0xfe) || (c1 >= 0x8e && c1 <= 0xa0) ||\n\t\t\t\t\t  (c1 >= 0x81 && c1 <= 0x8d) ||(c1 >= 0xc7 && c1 <= 0xc8))\n\t\t\t\t\t && ((c > 0x39 && c < 0x7f) || (c > 0xa0 && c < 0xff))) ||\n\t\t\t\t\t((c1 == 0xc6) && (c > 0xa0 && c < 0xff))) {\n\t\t\t\t\tc2 = c1 << 8 | c;\n\t\t\t\t\tfor (k = 0; k < sizeof(cp950_pua_tbl)\/(sizeof(unsigned short)*4); k++) {\n\t\t\t\t\t\tif (c2 >= cp950_pua_tbl[k][2] && c2 <= cp950_pua_tbl[k][3]) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((cp950_pua_tbl[k][2] & 0xff) == 0x40) {\n\t\t\t\t\t\tw = 157*(c1 - (cp950_pua_tbl[k][2]>>8)) + c - (c >= 0xa1 ? 0x62 : 0x40)\n\t\t\t\t\t\t\t+ cp950_pua_tbl[k][0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tw = c2 - cp950_pua_tbl[k][2] + cp950_pua_tbl[k][0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (w <= 0) {\n\t\t\t\tw = (c1 << 8) | c;\n\t\t\t\tw &= MBFL_WCSPLANE_MASK;\n\t\t\t\tw |= MBFL_WCSPLANE_BIG5;\n\t\t\t}\n\t\t\tCK((*filter->output_function)(w, filter->data));\n\t\t} else if ((c >= 0 && c < 0x21) || c == 0x7f) {\t\t\/* CTLs *\/\n\t\t\tCK((*filter->output_function)(c, filter->data));\n\t\t} else {\n\t\t\tw = (c1 << 8) | c;\n\t\t\tw &= MBFL_WCSGROUP_MASK;\n\t\t\tw |= MBFL_WCSGROUP_THROUGH;\n\t\t\tCK((*filter->output_function)(w, filter->data));\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tfilter->status = 0;\n\t\tbreak;\n\t}\n\n\treturn c;\n}","target":1,"code_token_length":1009,"total_token_length":1245,"max_tokens_setting":2048}
+{"idx":386508,"func":"void DL_Dxf::writeDimStyle(DL_WriterA& dw,\n                    double dimasz, double dimexe, double dimexo,\n                    double dimgap, double dimtxt) {\n\n    dw.dxfString(  0, \"TABLE\");\n    dw.dxfString(  2, \"DIMSTYLE\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfHex(5, 0xA);\n        dw.dxfString(100, \"AcDbSymbolTable\");\n    }\n    dw.dxfInt( 70, 1);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbDimStyleTable\");\n        dw.dxfInt( 71, 0);\n    }\n\n\n    dw.dxfString(  0, \"DIMSTYLE\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfHex(105, 0x27);\n    }\n    \/\/dw.handle(105);\n    \/\/dw.dxfHex(330, 0xA);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbSymbolTableRecord\");\n        dw.dxfString(100, \"AcDbDimStyleTableRecord\");\n    }\n    dw.dxfString(  2, \"Standard\");\n    if (version==DL_VERSION_R12) {\n        dw.dxfString(  3, \"\");\n        dw.dxfString(  4, \"\");\n        dw.dxfString(  5, \"\");\n        dw.dxfString(  6, \"\");\n        dw.dxfString(  7, \"\");\n        dw.dxfReal( 40, 1.0);\n    }\n\n    dw.dxfReal( 41, dimasz);\n    dw.dxfReal( 42, dimexo);\n    dw.dxfReal( 43, 3.75);\n    dw.dxfReal( 44, dimexe);\n    if (version==DL_VERSION_R12) {\n        dw.dxfReal( 45, 0.0);\n        dw.dxfReal( 46, 0.0);\n        dw.dxfReal( 47, 0.0);\n        dw.dxfReal( 48, 0.0);\n    }\n    dw.dxfInt( 70, 0);\n    if (version==DL_VERSION_R12) {\n        dw.dxfInt( 71, 0);\n        dw.dxfInt( 72, 0);\n    }\n    dw.dxfInt( 73, 0);\n    dw.dxfInt( 74, 0);\n    if (version==DL_VERSION_R12) {\n        dw.dxfInt( 75, 0);\n        dw.dxfInt( 76, 0);\n    }\n    dw.dxfInt( 77, 1);\n    dw.dxfInt( 78, 8);\n    dw.dxfReal(140, dimtxt);\n    dw.dxfReal(141, 2.5);\n    if (version==DL_VERSION_R12) {\n        dw.dxfReal(142, 0.0);\n    }\n    dw.dxfReal(143, 0.03937007874016);\n    if (version==DL_VERSION_R12) {\n        dw.dxfReal(144, 1.0);\n        dw.dxfReal(145, 0.0);\n        dw.dxfReal(146, 1.0);\n    }\n    dw.dxfReal(147, dimgap);\n    if (version==DL_VERSION_R12) {\n        dw.dxfInt(170, 0);\n    }\n    dw.dxfInt(171, 3);\n    dw.dxfInt(172, 1);\n    if (version==DL_VERSION_R12) {\n        dw.dxfInt(173, 0);\n        dw.dxfInt(174, 0);\n        dw.dxfInt(175, 0);\n        dw.dxfInt(176, 0);\n        dw.dxfInt(177, 0);\n        dw.dxfInt(178, 0);\n    }\n    if (version==DL_VERSION_2000) {\n        dw.dxfInt(271, 2);\n        dw.dxfInt(272, 2);\n        dw.dxfInt(274, 3);\n        dw.dxfInt(278, 44);\n        dw.dxfInt(283, 0);\n        dw.dxfInt(284, 8);\n        dw.dxfHex(340, styleHandleStd);\n        \/\/dw.dxfHex(340, 0x11);\n    }\n    \/\/ * \/\n    dw.dxfString(  0, \"ENDTAB\");\n}","target":0,"code_token_length":1110,"total_token_length":1346,"max_tokens_setting":2048}
+{"idx":473893,"func":"backward_search_range(regex_t* reg, const UChar* str, const UChar* end,\n\t\t      UChar* s, const UChar* range, UChar* adjrange,\n\t\t      UChar** low, UChar** high)\n{\n  int r;\n  UChar *p;\n\n  range += reg->dmin;\n  p = s;\n\n retry:\n  switch (reg->optimize) {\n  case ONIG_OPTIMIZE_EXACT:\n  exact_method:\n    p = slow_search_backward(reg->enc, reg->exact, reg->exact_end,\n\t\t\t     range, adjrange, end, p);\n    break;\n\n  case ONIG_OPTIMIZE_EXACT_IC:\n    p = slow_search_backward_ic(reg->enc, reg->case_fold_flag,\n                                reg->exact, reg->exact_end,\n                                range, adjrange, end, p);\n    break;\n\n  case ONIG_OPTIMIZE_EXACT_BM:\n  case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:\n    if (IS_NULL(reg->int_map_backward)) {\n      if (s - range < BM_BACKWARD_SEARCH_LENGTH_THRESHOLD)\n\tgoto exact_method;\n\n      r = set_bm_backward_skip(reg->exact, reg->exact_end, reg->enc,\n\t\t\t       &(reg->int_map_backward));\n      if (r) return r;\n    }\n    p = bm_search_backward(reg, reg->exact, reg->exact_end, range, adjrange,\n\t\t\t   end, p);\n    break;\n\n  case ONIG_OPTIMIZE_MAP:\n    p = map_search_backward(reg->enc, reg->map, range, adjrange, p, end);\n    break;\n  }\n\n  if (p) {\n    if (reg->sub_anchor) {\n      UChar* prev;\n\n      switch (reg->sub_anchor) {\n      case ANCHOR_BEGIN_LINE:\n\tif (!ON_STR_BEGIN(p)) {\n\t  prev = onigenc_get_prev_char_head(reg->enc, str, p, end);\n\t  if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {\n\t    p = prev;\n\t    goto retry;\n\t  }\n\t}\n\tbreak;\n\n      case ANCHOR_END_LINE:\n\tif (ON_STR_END(p)) {\n#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE\n\t  prev = onigenc_get_prev_char_head(reg->enc, adjrange, p);\n\t  if (IS_NULL(prev)) goto fail;\n\t  if (ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {\n\t    p = prev;\n\t    goto retry;\n\t  }\n#endif\n\t}\n\telse if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end)\n#ifdef USE_CRNL_AS_LINE_TERMINATOR\n              && ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)\n#endif\n                ) {\n\t  p = onigenc_get_prev_char_head(reg->enc, adjrange, p, end);\n\t  if (IS_NULL(p)) goto fail;\n\t  goto retry;\n\t}\n\tbreak;\n      }\n    }\n\n    \/* no needs to adjust *high, *high is used as range check only *\/\n    if (reg->dmax != ONIG_INFINITE_DISTANCE) {\n      *low  = p - reg->dmax;\n      *high = p - reg->dmin;\n      *high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high, end);\n    }\n\n#ifdef ONIG_DEBUG_SEARCH\n    fprintf(stderr, \"backward_search_range: low: %d, high: %d\\n\",\n\t    (int )(*low - str), (int )(*high - str));\n#endif\n    return 1; \/* success *\/\n  }\n\n fail:\n#ifdef ONIG_DEBUG_SEARCH\n  fprintf(stderr, \"backward_search_range: fail.\\n\");\n#endif\n  return 0; \/* fail *\/\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048}
+{"idx":379327,"func":"do_exedit(\n    exarg_T\t*eap,\n    win_T\t*old_curwin)\t    \/\/ curwin before doing a split or NULL\n{\n    int\t\tn;\n    int\t\tneed_hide;\n    int\t\texmode_was = exmode_active;\n\n    if ((eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW)\n\t\t\t\t\t\t || ERROR_IF_TERM_POPUP_WINDOW)\n\treturn;\n    \/*\n     * \":vi\" command ends Ex mode.\n     *\/\n    if (exmode_active && (eap->cmdidx == CMD_visual\n\t\t\t\t\t\t|| eap->cmdidx == CMD_view))\n    {\n\texmode_active = FALSE;\n\tex_pressedreturn = FALSE;\n\tif (*eap->arg == NUL)\n\t{\n\t    \/\/ Special case:  \":global\/pat\/visual\\NLvi-commands\"\n\t    if (global_busy)\n\t    {\n\t\tint\trd = RedrawingDisabled;\n\t\tint\tnwr = no_wait_return;\n\t\tint\tms = msg_scroll;\n#ifdef FEAT_GUI\n\t\tint\the = hold_gui_events;\n#endif\n\n\t\tif (eap->nextcmd != NULL)\n\t\t{\n\t\t    stuffReadbuff(eap->nextcmd);\n\t\t    eap->nextcmd = NULL;\n\t\t}\n\n\t\tif (exmode_was != EXMODE_VIM)\n\t\t    settmode(TMODE_RAW);\n\t\tRedrawingDisabled = 0;\n\t\tno_wait_return = 0;\n\t\tneed_wait_return = FALSE;\n\t\tmsg_scroll = 0;\n#ifdef FEAT_GUI\n\t\thold_gui_events = 0;\n#endif\n\t\tmust_redraw = CLEAR;\n\t\tpending_exmode_active = TRUE;\n\n\t\tmain_loop(FALSE, TRUE);\n\n\t\tpending_exmode_active = FALSE;\n\t\tRedrawingDisabled = rd;\n\t\tno_wait_return = nwr;\n\t\tmsg_scroll = ms;\n#ifdef FEAT_GUI\n\t\thold_gui_events = he;\n#endif\n\t    }\n\t    return;\n\t}\n    }\n\n    if ((eap->cmdidx == CMD_new\n\t\t|| eap->cmdidx == CMD_tabnew\n\t\t|| eap->cmdidx == CMD_tabedit\n\t\t|| eap->cmdidx == CMD_vnew) && *eap->arg == NUL)\n    {\n\t\/\/ \":new\" or \":tabnew\" without argument: edit a new empty buffer\n\tsetpcmark();\n\t(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,\n\t\t      ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),\n\t\t      old_curwin == NULL ? curwin : NULL);\n    }\n    else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit)\n\t    || *eap->arg != NUL\n#ifdef FEAT_BROWSE\n\t    || (cmdmod.cmod_flags & CMOD_BROWSE)\n#endif\n\t    )\n    {\n\t\/\/ Can't edit another file when \"textlock\" or \"curbuf_lock\" is set.\n\t\/\/ Only \":edit\" or \":script\" can bring us here, others are stopped\n\t\/\/ earlier.\n\tif (*eap->arg != NUL && text_or_buf_locked())\n\t    return;\n\n\tn = readonlymode;\n\tif (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview)\n\t    readonlymode = TRUE;\n\telse if (eap->cmdidx == CMD_enew)\n\t    readonlymode = FALSE;   \/\/ 'readonly' doesn't make sense in an\n\t\t\t\t    \/\/ empty buffer\n\tif (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd)\n\t    setpcmark();\n\tif (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),\n\t\t    NULL, eap,\n\t\t    \/\/ \":edit\" goes to first line if Vi compatible\n\t\t    (*eap->arg == NUL && eap->do_ecmd_lnum == 0\n\t\t\t\t      && vim_strchr(p_cpo, CPO_GOTO1) != NULL)\n\t\t\t\t\t       ? ECMD_ONE : eap->do_ecmd_lnum,\n\t\t    (buf_hide(curbuf) ? ECMD_HIDE : 0)\n\t\t    + (eap->forceit ? ECMD_FORCEIT : 0)\n\t\t      \/\/ after a split we can use an existing buffer\n\t\t    + (old_curwin != NULL ? ECMD_OLDBUF : 0)\n\t\t    + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0)\n\t\t    + (eap->cmdidx == CMD_balt ? ECMD_ALTBUF : 0)\n\t\t    , old_curwin == NULL ? curwin : NULL) == FAIL)\n\t{\n\t    \/\/ Editing the file failed.  If the window was split, close it.\n\t    if (old_curwin != NULL)\n\t    {\n\t\tneed_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);\n\t\tif (!need_hide || buf_hide(curbuf))\n\t\t{\n#if defined(FEAT_EVAL)\n\t\t    cleanup_T   cs;\n\n\t\t    \/\/ Reset the error\/interrupt\/exception state here so that\n\t\t    \/\/ aborting() returns FALSE when closing a window.\n\t\t    enter_cleanup(&cs);\n#endif\n#ifdef FEAT_GUI\n\t\t    need_mouse_correct = TRUE;\n#endif\n\t\t    win_close(curwin, !need_hide && !buf_hide(curbuf));\n\n#if defined(FEAT_EVAL)\n\t\t    \/\/ Restore the error\/interrupt\/exception state if not\n\t\t    \/\/ discarded by a new aborting error, interrupt, or\n\t\t    \/\/ uncaught exception.\n\t\t    leave_cleanup(&cs);\n#endif\n\t\t}\n\t    }\n\t}\n\telse if (readonlymode && curbuf->b_nwindows == 1)\n\t{\n\t    \/\/ When editing an already visited buffer, 'readonly' won't be set\n\t    \/\/ but the previous value is kept.  With \":view\" and \":sview\" we\n\t    \/\/ want the  file to be readonly, except when another window is\n\t    \/\/ editing the same buffer.\n\t    curbuf->b_p_ro = TRUE;\n\t}\n\treadonlymode = n;\n    }\n    else\n    {\n\tif (eap->do_ecmd_cmd != NULL)\n\t    do_cmd_argument(eap->do_ecmd_cmd);\n\tn = curwin->w_arg_idx_invalid;\n\tcheck_arg_idx(curwin);\n\tif (n != curwin->w_arg_idx_invalid)\n\t    maketitle();\n    }\n\n    \/*\n     * if \":split file\" worked, set alternate file name in old window to new\n     * file\n     *\/\n    if (old_curwin != NULL\n\t    && *eap->arg != NUL\n\t    && curwin != old_curwin\n\t    && win_valid(old_curwin)\n\t    && old_curwin->w_buffer != curbuf\n\t    && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)\n\told_curwin->w_alt_fnum = curbuf->b_fnum;\n\n    ex_no_reprint = TRUE;\n}","target":0,"code_token_length":1464,"total_token_length":1700,"max_tokens_setting":2048}
+{"idx":261923,"func":"njs_string_prototype_split(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    size_t             size;\n    uint32_t           limit;\n    njs_int_t          ret;\n    njs_utf8_t         utf8;\n    njs_bool_t         undefined;\n    njs_value_t        *this, *separator, *value;\n    njs_value_t        separator_lvalue, limit_lvalue, splitter;\n    njs_array_t        *array;\n    const u_char       *p, *start, *next, *last, *end;\n    njs_string_prop_t  string, split;\n    njs_value_t        arguments[3];\n\n    static const njs_value_t  split_key =\n                                        njs_wellknown_symbol(NJS_SYMBOL_SPLIT);\n\n    this = njs_argument(args, 0);\n\n    if (njs_slow_path(njs_is_null_or_undefined(this))) {\n        njs_type_error(vm, \"cannot convert \\\"%s\\\"to object\",\n                       njs_type_string(this->type));\n        return NJS_ERROR;\n    }\n\n    separator = njs_lvalue_arg(&separator_lvalue, args, nargs, 1);\n    value = njs_lvalue_arg(&limit_lvalue, args, nargs, 2);\n\n    if (!njs_is_null_or_undefined(separator)) {\n        ret = njs_value_method(vm, separator, njs_value_arg(&split_key),\n                               &splitter);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (njs_is_defined(&splitter)) {\n            arguments[0] = *this;\n            arguments[1] = *value;\n\n            return njs_function_call(vm, njs_function(&splitter), separator,\n                                     arguments, 2, &vm->retval);\n        }\n    }\n\n    ret = njs_value_to_string(vm, this, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    array = njs_array_alloc(vm, 0, 0, NJS_ARRAY_SPARE);\n    if (njs_slow_path(array == NULL)) {\n        return NJS_ERROR;\n    }\n\n    limit = UINT32_MAX;\n\n    if (njs_is_defined(value)) {\n        ret = njs_value_to_uint32(vm, value, &limit);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n    }\n\n    undefined = njs_is_undefined(separator);\n\n    ret = njs_value_to_string(vm, separator, separator);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_slow_path(limit == 0)) {\n        goto done;\n    }\n\n    if (njs_slow_path(undefined)) {\n        goto single;\n    }\n\n    (void) njs_string_prop(&string, this);\n    (void) njs_string_prop(&split, separator);\n\n    if (njs_slow_path(string.size == 0)) {\n        if (split.size != 0) {\n            goto single;\n        }\n\n        goto done;\n    }\n\n    utf8 = NJS_STRING_BYTE;\n\n    if (string.length != 0) {\n        utf8 = NJS_STRING_ASCII;\n\n        if (string.length != string.size) {\n            utf8 = NJS_STRING_UTF8;\n        }\n    }\n\n    start = string.start;\n    end = string.start + string.size;\n    last = end - split.size;\n\n    do {\n\n        for (p = start; p <= last; p++) {\n            if (memcmp(p, split.start, split.size) == 0) {\n                goto found;\n            }\n        }\n\n        p = end;\n\nfound:\n\n        next = p + split.size;\n\n        \/* Empty split string. *\/\n\n        if (p == next) {\n            p = (utf8 != NJS_STRING_BYTE) ? njs_utf8_next(p, end)\n                                          : p + 1;\n            next = p;\n        }\n\n        size = p - start;\n\n        ret = njs_string_split_part_add(vm, array, utf8, start, size);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        start = next;\n        limit--;\n\n    } while (limit != 0 && p < end);\n\n    goto done;\n\nsingle:\n\n    value = njs_array_push(vm, array);\n    if (njs_slow_path(value == NULL)) {\n        return NJS_ERROR;\n    }\n\n    *value = *this;\n\ndone:\n\n    njs_set_array(&vm->retval, array);\n\n    return NJS_OK;\n}","target":0,"code_token_length":987,"total_token_length":1223,"max_tokens_setting":2048}
+{"idx":384181,"func":"static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,\n\t\t\t      u8 policy, u32 flags,\n\t\t\t      struct netlink_ext_ack *extack)\n{\n\tconst struct nlattr * const *nla = ctx->nla;\n\tstruct nft_stats __percpu *stats = NULL;\n\tstruct nft_table *table = ctx->table;\n\tstruct nft_base_chain *basechain;\n\tstruct net *net = ctx->net;\n\tchar name[NFT_NAME_MAXLEN];\n\tstruct nft_rule_blob *blob;\n\tstruct nft_trans *trans;\n\tstruct nft_chain *chain;\n\tunsigned int data_size;\n\tint err;\n\n\tif (table->use == UINT_MAX)\n\t\treturn -EOVERFLOW;\n\n\tif (nla[NFTA_CHAIN_HOOK]) {\n\t\tstruct nft_chain_hook hook;\n\n\t\tif (flags & NFT_CHAIN_BINDING)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\terr = nft_chain_parse_hook(net, nla, &hook, family, extack,\n\t\t\t\t\t   true);\n\t\tif (err < 0)\n\t\t\treturn err;\n\n\t\tbasechain = kzalloc(sizeof(*basechain), GFP_KERNEL_ACCOUNT);\n\t\tif (basechain == NULL) {\n\t\t\tnft_chain_release_hook(&hook);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tchain = &basechain->chain;\n\n\t\tif (nla[NFTA_CHAIN_COUNTERS]) {\n\t\t\tstats = nft_stats_alloc(nla[NFTA_CHAIN_COUNTERS]);\n\t\t\tif (IS_ERR(stats)) {\n\t\t\t\tnft_chain_release_hook(&hook);\n\t\t\t\tkfree(basechain);\n\t\t\t\treturn PTR_ERR(stats);\n\t\t\t}\n\t\t\trcu_assign_pointer(basechain->stats, stats);\n\t\t}\n\n\t\terr = nft_basechain_init(basechain, family, &hook, flags);\n\t\tif (err < 0) {\n\t\t\tnft_chain_release_hook(&hook);\n\t\t\tkfree(basechain);\n\t\t\treturn err;\n\t\t}\n\t} else {\n\t\tif (flags & NFT_CHAIN_BASE)\n\t\t\treturn -EINVAL;\n\t\tif (flags & NFT_CHAIN_HW_OFFLOAD)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tchain = kzalloc(sizeof(*chain), GFP_KERNEL_ACCOUNT);\n\t\tif (chain == NULL)\n\t\t\treturn -ENOMEM;\n\n\t\tchain->flags = flags;\n\t}\n\tctx->chain = chain;\n\n\tINIT_LIST_HEAD(&chain->rules);\n\tchain->handle = nf_tables_alloc_handle(table);\n\tchain->table = table;\n\n\tif (nla[NFTA_CHAIN_NAME]) {\n\t\tchain->name = nla_strdup(nla[NFTA_CHAIN_NAME], GFP_KERNEL_ACCOUNT);\n\t} else {\n\t\tif (!(flags & NFT_CHAIN_BINDING)) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto err_destroy_chain;\n\t\t}\n\n\t\tsnprintf(name, sizeof(name), \"__chain%llu\", ++chain_id);\n\t\tchain->name = kstrdup(name, GFP_KERNEL_ACCOUNT);\n\t}\n\n\tif (!chain->name) {\n\t\terr = -ENOMEM;\n\t\tgoto err_destroy_chain;\n\t}\n\n\tif (nla[NFTA_CHAIN_USERDATA]) {\n\t\tchain->udata = nla_memdup(nla[NFTA_CHAIN_USERDATA], GFP_KERNEL_ACCOUNT);\n\t\tif (chain->udata == NULL) {\n\t\t\terr = -ENOMEM;\n\t\t\tgoto err_destroy_chain;\n\t\t}\n\t\tchain->udlen = nla_len(nla[NFTA_CHAIN_USERDATA]);\n\t}\n\n\tdata_size = offsetof(struct nft_rule_dp, data);\t\/* last rule *\/\n\tblob = nf_tables_chain_alloc_rules(data_size);\n\tif (!blob) {\n\t\terr = -ENOMEM;\n\t\tgoto err_destroy_chain;\n\t}\n\n\tRCU_INIT_POINTER(chain->blob_gen_0, blob);\n\tRCU_INIT_POINTER(chain->blob_gen_1, blob);\n\n\terr = nf_tables_register_hook(net, table, chain);\n\tif (err < 0)\n\t\tgoto err_destroy_chain;\n\n\ttrans = nft_trans_chain_add(ctx, NFT_MSG_NEWCHAIN);\n\tif (IS_ERR(trans)) {\n\t\terr = PTR_ERR(trans);\n\t\tgoto err_unregister_hook;\n\t}\n\n\tnft_trans_chain_policy(trans) = NFT_CHAIN_POLICY_UNSET;\n\tif (nft_is_base_chain(chain))\n\t\tnft_trans_chain_policy(trans) = policy;\n\n\terr = nft_chain_add(table, chain);\n\tif (err < 0) {\n\t\tnft_trans_destroy(trans);\n\t\tgoto err_unregister_hook;\n\t}\n\n\tif (stats)\n\t\tstatic_branch_inc(&nft_counters_enabled);\n\n\ttable->use++;\n\n\treturn 0;\nerr_unregister_hook:\n\tnf_tables_unregister_hook(net, table, chain);\nerr_destroy_chain:\n\tnf_tables_chain_destroy(ctx);\n\n\treturn err;\n}","target":0,"code_token_length":958,"total_token_length":1194,"max_tokens_setting":2048}
+{"idx":223471,"func":"static void do_utfreadnewline_invalid(compiler_common *common)\n{\n\/* Slow decoding a UTF-8 character, specialized for newlines.\nTMP1 contains the first byte of the character (>= 0xc0). Return\nchar value in TMP1. *\/\nDEFINE_COMPILER;\nstruct sljit_label *loop;\nstruct sljit_label *skip_start;\nstruct sljit_label *three_byte_exit;\nstruct sljit_jump *jump[5];\n\nsljit_emit_fast_enter(compiler, RETURN_ADDR, 0);\n\nif (common->nltype != NLTYPE_ANY)\n  {\n  SLJIT_ASSERT(common->nltype != NLTYPE_FIXED || common->newline < 128);\n\n  \/* All newlines are ascii, just skip intermediate octets. *\/\n  jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);\n  loop = LABEL();\n  if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_POST, TMP2, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)) == SLJIT_SUCCESS)\n    sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, TMP2, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));\n  else\n    {\n    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n    }\n\n  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc0);\n  CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0x80, loop);\n  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n  JUMPHERE(jump[0]);\n\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);\n  OP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n  return;\n  }\n\njump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\njump[1] = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0xc2);\njump[2] = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0xe2);\n\nskip_start = LABEL();\nOP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc0);\njump[3] = CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0x80);\n\n\/* Skip intermediate octets. *\/\nloop = LABEL();\njump[4] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\nOP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc0);\nCMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0x80, loop);\n\nJUMPHERE(jump[3]);\nOP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\nthree_byte_exit = LABEL();\nJUMPHERE(jump[0]);\nJUMPHERE(jump[4]);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\n\/* Two byte long newline: 0x85. *\/\nJUMPHERE(jump[1]);\nCMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0x85, skip_start);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0x85);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\n\/* Three byte long newlines: 0x2028 and 0x2029. *\/\nJUMPHERE(jump[2]);\nCMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0x80, skip_start);\nCMPTO(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0, three_byte_exit);\n\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\nOP2(SLJIT_SUB, TMP1, 0, TMP2, 0, SLJIT_IMM, 0x80);\nCMPTO(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x40, skip_start);\n\nOP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0x2000);\nOP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n}","target":0,"code_token_length":1328,"total_token_length":1564,"max_tokens_setting":2048}
+{"idx":216654,"func":"auth_request_get_var_expand_table_full(const struct auth_request *auth_request,\n\t\t\t\t       auth_request_escape_func_t *escape_func,\n\t\t\t\t       unsigned int *count)\n{\n\tconst unsigned int auth_count =\n\t\tN_ELEMENTS(auth_request_var_expand_static_tab);\n\tstruct var_expand_table *tab, *ret_tab;\n\tconst char *orig_user, *auth_user;\n\n\tif (escape_func == NULL)\n\t\tescape_func = escape_none;\n\n\t\/* keep the extra fields at the beginning. the last static_tab field\n\t   contains the ending NULL-fields. *\/\n\ttab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab));\n\tmemset(tab, 0, *count * sizeof(*tab));\n\ttab += *count;\n\t*count += auth_count;\n\n\tmemcpy(tab, auth_request_var_expand_static_tab,\n\t       auth_count * sizeof(*tab));\n\n\ttab[0].value = escape_func(auth_request->user, auth_request);\n\ttab[1].value = escape_func(t_strcut(auth_request->user, '@'),\n\t\t\t\t   auth_request);\n\ttab[2].value = strchr(auth_request->user, '@');\n\tif (tab[2].value != NULL)\n\t\ttab[2].value = escape_func(tab[2].value+1, auth_request);\n\ttab[3].value = escape_func(auth_request->service, auth_request);\n\t\/* tab[4] = we have no home dir *\/\n\tif (auth_request->local_ip.family != 0)\n\t\ttab[5].value = net_ip2addr(&auth_request->local_ip);\n\tif (auth_request->remote_ip.family != 0)\n\t\ttab[6].value = net_ip2addr(&auth_request->remote_ip);\n\ttab[7].value = dec2str(auth_request->client_pid);\n\tif (auth_request->mech_password != NULL) {\n\t\ttab[8].value = escape_func(auth_request->mech_password,\n\t\t\t\t\t   auth_request);\n\t}\n\tif (auth_request->userdb_lookup) {\n\t\ttab[9].value = auth_request->userdb == NULL ? \"\" :\n\t\t\tdec2str(auth_request->userdb->userdb->id);\n\t} else {\n\t\ttab[9].value = auth_request->passdb == NULL ? \"\" :\n\t\t\tdec2str(auth_request->passdb->passdb->id);\n\t}\n\ttab[10].value = auth_request->mech_name == NULL ? \"\" :\n\t\tescape_func(auth_request->mech_name, auth_request);\n\ttab[11].value = auth_request->secured ? \"secured\" : \"\";\n\ttab[12].value = dec2str(auth_request->local_port);\n\ttab[13].value = dec2str(auth_request->remote_port);\n\ttab[14].value = auth_request->valid_client_cert ? \"valid\" : \"\";\n\n\tif (auth_request->requested_login_user != NULL) {\n\t\tconst char *login_user = auth_request->requested_login_user;\n\n\t\ttab[15].value = escape_func(login_user, auth_request);\n\t\ttab[16].value = escape_func(t_strcut(login_user, '@'),\n\t\t\t\t\t    auth_request);\n\t\ttab[17].value = strchr(login_user, '@');\n\t\tif (tab[17].value != NULL) {\n\t\t\ttab[17].value = escape_func(tab[17].value+1,\n\t\t\t\t\t\t    auth_request);\n\t\t}\n\t}\n\ttab[18].value = auth_request->session_id == NULL ? NULL :\n\t\tescape_func(auth_request->session_id, auth_request);\n\tif (auth_request->real_local_ip.family != 0)\n\t\ttab[19].value = net_ip2addr(&auth_request->real_local_ip);\n\tif (auth_request->real_remote_ip.family != 0)\n\t\ttab[20].value = net_ip2addr(&auth_request->real_remote_ip);\n\ttab[21].value = dec2str(auth_request->real_local_port);\n\ttab[22].value = dec2str(auth_request->real_remote_port);\n\ttab[23].value = strchr(auth_request->user, '@');\n\tif (tab[23].value != NULL) {\n\t\ttab[23].value = escape_func(t_strcut(tab[23].value+1, '@'),\n\t\t\t\t\t    auth_request);\n\t}\n\ttab[24].value = strrchr(auth_request->user, '@');\n\tif (tab[24].value != NULL)\n\t\ttab[24].value = escape_func(tab[24].value+1, auth_request);\n\ttab[25].value = auth_request->master_user == NULL ? NULL :\n\t\tescape_func(auth_request->master_user, auth_request);\n\ttab[26].value = auth_request->session_pid == (pid_t)-1 ? NULL :\n\t\tdec2str(auth_request->session_pid);\n\n\torig_user = auth_request->original_username != NULL ?\n\t\tauth_request->original_username : auth_request->user;\n\ttab[27].value = escape_func(orig_user, auth_request);\n\ttab[28].value = escape_func(t_strcut(orig_user, '@'), auth_request);\n\ttab[29].value = strchr(orig_user, '@');\n\tif (tab[29].value != NULL)\n\t\ttab[29].value = escape_func(tab[29].value+1, auth_request);\n\n\tif (auth_request->master_user != NULL)\n\t\tauth_user = auth_request->master_user;\n\telse\n\t\tauth_user = orig_user;\n\ttab[30].value = escape_func(auth_user, auth_request);\n\ttab[31].value = escape_func(t_strcut(auth_user, '@'), auth_request);\n\ttab[32].value = strchr(auth_user, '@');\n\tif (tab[32].value != NULL)\n\t\ttab[32].value = escape_func(tab[32].value+1, auth_request);\n\tif (auth_request->local_name != NULL)\n\t\ttab[33].value = escape_func(auth_request->local_name, auth_request);\n\telse\n\t\ttab[33].value = \"\";\n\treturn ret_tab;\n}","target":1,"code_token_length":1248,"total_token_length":1484,"max_tokens_setting":2048}
+{"idx":384907,"func":"gen_expand_wildcards(\n    int\t\tnum_pat,\t\/\/ number of input patterns\n    char_u\t**pat,\t\t\/\/ array of input patterns\n    int\t\t*num_file,\t\/\/ resulting number of files\n    char_u\t***file,\t\/\/ array of resulting files\n    int\t\tflags)\t\t\/\/ EW_* flags\n{\n    int\t\t\ti;\n    garray_T\t\tga;\n    char_u\t\t*p;\n    static int\t\trecursive = FALSE;\n    int\t\t\tadd_pat;\n    int\t\t\tretval = OK;\n#if defined(FEAT_SEARCHPATH)\n    int\t\t\tdid_expand_in_path = FALSE;\n#endif\n\n    \/*\n     * expand_env() is called to expand things like \"~user\".  If this fails,\n     * it calls ExpandOne(), which brings us back here.  In this case, always\n     * call the machine specific expansion function, if possible.  Otherwise,\n     * return FAIL.\n     *\/\n    if (recursive)\n#ifdef SPECIAL_WILDCHAR\n\treturn mch_expand_wildcards(num_pat, pat, num_file, file, flags);\n#else\n\treturn FAIL;\n#endif\n\n#ifdef SPECIAL_WILDCHAR\n    \/*\n     * If there are any special wildcard characters which we cannot handle\n     * here, call machine specific function for all the expansion.  This\n     * avoids starting the shell for each argument separately.\n     * For `=expr` do use the internal function.\n     *\/\n    for (i = 0; i < num_pat; i++)\n    {\n\tif (has_special_wildchar(pat[i])\n# ifdef VIM_BACKTICK\n\t\t&& !(vim_backtick(pat[i]) && pat[i][1] == '=')\n# endif\n\t   )\n\t    return mch_expand_wildcards(num_pat, pat, num_file, file, flags);\n    }\n#endif\n\n    recursive = TRUE;\n\n    \/*\n     * The matching file names are stored in a growarray.  Init it empty.\n     *\/\n    ga_init2(&ga, sizeof(char_u *), 30);\n\n    for (i = 0; i < num_pat; ++i)\n    {\n\tadd_pat = -1;\n\tp = pat[i];\n\n#ifdef VIM_BACKTICK\n\tif (vim_backtick(p))\n\t{\n\t    add_pat = expand_backtick(&ga, p, flags);\n\t    if (add_pat == -1)\n\t\tretval = FAIL;\n\t}\n\telse\n#endif\n\t{\n\t    \/*\n\t     * First expand environment variables, \"~\/\" and \"~user\/\".\n\t     *\/\n\t    if ((has_env_var(p) && !(flags & EW_NOTENV)) || *p == '~')\n\t    {\n\t\tp = expand_env_save_opt(p, TRUE);\n\t\tif (p == NULL)\n\t\t    p = pat[i];\n#ifdef UNIX\n\t\t\/*\n\t\t * On Unix, if expand_env() can't expand an environment\n\t\t * variable, use the shell to do that.  Discard previously\n\t\t * found file names and start all over again.\n\t\t *\/\n\t\telse if (has_env_var(p) || *p == '~')\n\t\t{\n\t\t    vim_free(p);\n\t\t    ga_clear_strings(&ga);\n\t\t    i = mch_expand_wildcards(num_pat, pat, num_file, file,\n\t\t\t\t\t\t\t flags|EW_KEEPDOLLAR);\n\t\t    recursive = FALSE;\n\t\t    return i;\n\t\t}\n#endif\n\t    }\n\n\t    \/*\n\t     * If there are wildcards: Expand file names and add each match to\n\t     * the list.  If there is no match, and EW_NOTFOUND is given, add\n\t     * the pattern.\n\t     * If there are no wildcards: Add the file name if it exists or\n\t     * when EW_NOTFOUND is given.\n\t     *\/\n\t    if (mch_has_exp_wildcard(p))\n\t    {\n#if defined(FEAT_SEARCHPATH)\n\t\tif ((flags & EW_PATH)\n\t\t\t&& !mch_isFullName(p)\n\t\t\t&& !(p[0] == '.'\n\t\t\t    && (vim_ispathsep(p[1])\n\t\t\t\t|| (p[1] == '.' && vim_ispathsep(p[2]))))\n\t\t   )\n\t\t{\n\t\t    \/\/ :find completion where 'path' is used.\n\t\t    \/\/ Recursiveness is OK here.\n\t\t    recursive = FALSE;\n\t\t    add_pat = expand_in_path(&ga, p, flags);\n\t\t    recursive = TRUE;\n\t\t    did_expand_in_path = TRUE;\n\t\t}\n\t\telse\n#endif\n\t\t    add_pat = mch_expandpath(&ga, p, flags);\n\t    }\n\t}\n\n\tif (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND)))\n\t{\n\t    char_u\t*t = backslash_halve_save(p);\n\n\t    \/\/ When EW_NOTFOUND is used, always add files and dirs.  Makes\n\t    \/\/ \"vim c:\/\" work.\n\t    if (flags & EW_NOTFOUND)\n\t\taddfile(&ga, t, flags | EW_DIR | EW_FILE);\n\t    else\n\t\taddfile(&ga, t, flags);\n\n\t    if (t != p)\n\t\tvim_free(t);\n\t}\n\n#if defined(FEAT_SEARCHPATH)\n\tif (did_expand_in_path && ga.ga_len > 0 && (flags & EW_PATH))\n\t    uniquefy_paths(&ga, p);\n#endif\n\tif (p != pat[i])\n\t    vim_free(p);\n    }\n\n    \/\/ When returning FAIL the array must be freed here.\n    if (retval == FAIL)\n\tga_clear(&ga);\n\n    *num_file = ga.ga_len;\n    *file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data\n\t\t\t\t\t\t  : (char_u **)_(\"no matches\");\n\n    recursive = FALSE;\n\n    return ((flags & EW_EMPTYOK) || ga.ga_data != NULL) ? retval : FAIL;\n}","target":0,"code_token_length":1202,"total_token_length":1438,"max_tokens_setting":2048}
+{"idx":274752,"func":"int ntfs_attr_map_whole_runlist(ntfs_attr *na)\n{\n\tVCN next_vcn, last_vcn, highest_vcn;\n\tntfs_attr_search_ctx *ctx;\n\tntfs_volume *vol = na->ni->vol;\n\tATTR_RECORD *a;\n\tint ret = -1;\n\tint not_mapped;\n\n\tntfs_log_enter(\"Entering for inode %llu, attr 0x%x.\\n\",\n\t\t       (unsigned long long)na->ni->mft_no, le32_to_cpu(na->type));\n\n\t\t\/* avoid multiple full runlist mappings *\/\n\tif (NAttrFullyMapped(na)) {\n\t\tret = 0;\n\t\tgoto out;\n\t}\n\tctx = ntfs_attr_get_search_ctx(na->ni, NULL);\n\tif (!ctx)\n\t\tgoto out;\n\n\t\/* Map all attribute extents one by one. *\/\n\tnext_vcn = last_vcn = highest_vcn = 0;\n\ta = NULL;\n\twhile (1) {\n\t\trunlist_element *rl;\n\n\t\tnot_mapped = 0;\n\t\tif (ntfs_rl_vcn_to_lcn(na->rl, next_vcn) == LCN_RL_NOT_MAPPED)\n\t\t\tnot_mapped = 1;\n\n\t\tif (ntfs_attr_lookup(na->type, na->name, na->name_len,\n\t\t\t\tCASE_SENSITIVE, next_vcn, NULL, 0, ctx))\n\t\t\tbreak;\n\n\t\ta = ctx->attr;\n\n\t\tif (not_mapped) {\n\t\t\t\/* Decode the runlist. *\/\n\t\t\trl = ntfs_mapping_pairs_decompress(na->ni->vol,\n\t\t\t\t\t\t\t\ta, na->rl);\n\t\t\tif (!rl)\n\t\t\t\tgoto err_out;\n\t\t\tna->rl = rl;\n\t\t}\n\n\t\t\/* Are we in the first extent? *\/\n\t\tif (!next_vcn) {\n\t\t\t if (a->lowest_vcn) {\n\t\t\t\t errno = EIO;\n\t\t\t\t ntfs_log_perror(\"First extent of inode %llu \"\n\t\t\t\t\t\"attribute has non-zero lowest_vcn\",\n\t\t\t\t\t(unsigned long long)na->ni->mft_no);\n\t\t\t\t goto err_out;\n\t\t\t}\n\t\t\t\/* Get the last vcn in the attribute. *\/\n\t\t\tlast_vcn = sle64_to_cpu(a->allocated_size) >>\n\t\t\t\t\tvol->cluster_size_bits;\n\t\t}\n\n\t\t\/* Get the lowest vcn for the next extent. *\/\n\t\thighest_vcn = sle64_to_cpu(a->highest_vcn);\n\t\tnext_vcn = highest_vcn + 1;\n\n\t\t\/* Only one extent or error, which we catch below. *\/\n\t\tif (next_vcn <= 0) {\n\t\t\terrno = ENOENT;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Avoid endless loops due to corruption. *\/\n\t\tif (next_vcn < sle64_to_cpu(a->lowest_vcn)) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"Inode %llu has corrupt attribute list\",\n\t\t\t\t\t(unsigned long long)na->ni->mft_no);\n\t\t\tgoto err_out;\n\t\t}\n\t}\n\tif (!a) {\n\t\tntfs_log_perror(\"Couldn't find attribute for runlist mapping\");\n\t\tgoto err_out;\n\t}\n\t\t\/*\n\t\t * Cannot check highest_vcn when the last runlist has\n\t\t * been modified earlier, as runlists and sizes may be\n\t\t * updated without highest_vcn being in sync, when\n\t\t * HOLES_DELAY is used\n\t\t *\/\n\tif (not_mapped && highest_vcn && highest_vcn != last_vcn - 1) {\n\t\terrno = EIO;\n\t\tntfs_log_perror(\"Failed to load full runlist: inode: %llu \"\n\t\t\t\t\"highest_vcn: 0x%llx last_vcn: 0x%llx\",\n\t\t\t\t(unsigned long long)na->ni->mft_no, \n\t\t\t\t(long long)highest_vcn, (long long)last_vcn);\n\t\tgoto err_out;\n\t}\n\tif (errno == ENOENT) {\n\t\tNAttrSetFullyMapped(na);\n\t\tret = 0;\n\t}\nerr_out:\t\n\tntfs_attr_put_search_ctx(ctx);\nout:\n\tntfs_log_leave(\"\\n\");\n\treturn ret;\n}","target":0,"code_token_length":891,"total_token_length":1127,"max_tokens_setting":2048}
+{"idx":195340,"func":"  void Compute(OpKernelContext *ctx) override {\n    const Tensor *indices_t, *values_t, *shape_t, *dense_t;\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_indices\", &indices_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_values\", &values_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"sp_shape\", &shape_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"dense\", &dense_t));\n\n    \/\/ Validations.\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices_t->shape()),\n                errors::InvalidArgument(\n                    \"Input sp_indices should be a matrix but received shape: \",\n                    indices_t->shape().DebugString()));\n    OP_REQUIRES(ctx,\n                TensorShapeUtils::IsVector(values_t->shape()) &&\n                    TensorShapeUtils::IsVector(shape_t->shape()),\n                errors::InvalidArgument(\n                    \"Inputs sp_values and sp_shape should be vectors \"\n                    \"but received shapes: \",\n                    values_t->shape().DebugString(), \" and \",\n                    shape_t->shape().DebugString()));\n    OP_REQUIRES(\n        ctx, TensorShapeUtils::IsVector(shape_t->shape()),\n        errors::InvalidArgument(\"Input sp_shape must be a vector. Got: \",\n                                shape_t->shape().DebugString()));\n    OP_REQUIRES(\n        ctx, values_t->dim_size(0) == indices_t->dim_size(0),\n        errors::InvalidArgument(\n            \"The first dimension of values and indices should match. (\",\n            values_t->dim_size(0), \" vs. \", indices_t->dim_size(0), \")\"));\n    OP_REQUIRES(\n        ctx, shape_t->shape().dim_size(0) == indices_t->shape().dim_size(1),\n        errors::InvalidArgument(\n            \"Number of dimensions must match second dimension of indices. \",\n            \"Got \", shape_t->shape().dim_size(0),\n            \" dimensions, indices shape: \", indices_t->shape().DebugString()));\n    OP_REQUIRES(ctx, shape_t->NumElements() > 0,\n                errors::InvalidArgument(\n                    \"The shape argument requires at least one element.\"));\n\n    const auto indices_mat = indices_t->matrix<int64_t>();\n    const auto shape_vec = shape_t->vec<int64_t>();\n    const auto lhs_dims = BCast::FromShape(TensorShape(shape_vec));\n    const auto rhs_dims = BCast::FromShape(dense_t->shape());\n    BCast b(lhs_dims, rhs_dims, false);  \/\/ false for keeping the same num dims.\n\n    \/\/ True iff (size(lhs) >= size(rhs)) and all dims in lhs is greater or equal\n    \/\/ to dims in rhs (from right to left).\n    auto VecGreaterEq = [](ArraySlice<int64_t> lhs, ArraySlice<int64_t> rhs) {\n      if (lhs.size() < rhs.size()) return false;\n      for (size_t i = 0; i < rhs.size(); ++i) {\n        if (lhs[lhs.size() - 1 - i] < rhs[rhs.size() - 1 - i]) return false;\n      }\n      return true;\n    };\n    OP_REQUIRES(ctx, VecGreaterEq(lhs_dims, rhs_dims) && b.IsValid(),\n                errors::InvalidArgument(\n                    \"SparseDenseBinaryOpShared broadcasts dense to sparse \"\n                    \"only; got incompatible shapes: [\",\n                    absl::StrJoin(lhs_dims, \",\"), \"] vs. [\",\n                    absl::StrJoin(rhs_dims, \",\"), \"]\"));\n\n    Tensor *output_values = nullptr;\n    Tensor dense_gathered;\n    const int64_t nnz = indices_t->dim_size(0);\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(0, TensorShape({nnz}), &output_values));\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_temp(DataTypeToEnum<T>::value, TensorShape({nnz}),\n                                &dense_gathered));\n    bool op_is_div = false;\n    if (absl::StrContains(ctx->op_kernel().type_string_view(), \"Div\")) {\n      op_is_div = true;\n    }\n    \/\/ Pulls relevant entries from the dense side, with reshape and broadcasting\n    \/\/ *of the dense side* taken into account.  Use a TensorRef to avoid blowing\n    \/\/ up memory.\n    \/\/\n    \/\/ We can directly use the sparse indices to look up dense side, because\n    \/\/ \"b.y_reshape()\" and \"b.y_bcast()\" are guaranteed to have rank \"ndims\".\n    auto dense_gathered_flat = dense_gathered.flat<T>();\n    const int ndims = lhs_dims.size();\n    switch (ndims) {\n#define CASE(NDIM)                                                             \\\n  case NDIM: {                                                                 \\\n    TensorRef<Eigen::Tensor<const T, NDIM, Eigen::RowMajor>> rhs_ref =         \\\n        dense_t->shaped<T, NDIM>(b.y_reshape())                                \\\n            .broadcast(BCast::ToIndexArray<NDIM>(b.y_bcast()));                \\\n    Eigen::array<Eigen::DenseIndex, NDIM> idx;                                 \\\n    bool indices_valid = true;                                                 \\\n    for (int i = 0; i < nnz; ++i) {                                            \\\n      for (int d = 0; d < NDIM; ++d) {                                         \\\n        idx[d] = internal::SubtleMustCopy(indices_mat(i, d));                  \\\n        if (!FastBoundsCheck(idx[d], rhs_ref.dimension(d))) {                  \\\n          indices_valid = false;                                               \\\n        }                                                                      \\\n      }                                                                        \\\n      OP_REQUIRES(                                                             \\\n          ctx, indices_valid,                                                  \\\n          errors::InvalidArgument(\"Provided indices are out-of-bounds w.r.t. \" \\\n                                  \"dense side with broadcasted shape\"));       \\\n      dense_gathered_flat(i) = rhs_ref.coeff(idx);                             \\\n      if (op_is_div) {                                                         \\\n        OP_REQUIRES(ctx, dense_gathered_flat(i) != 0,                          \\\n                    errors::InvalidArgument(                                   \\\n                        \"SparseDenseCwiseDiv cannot divide by zero,\"           \\\n                        \"but input dense tensor contains zero \"));             \\\n      }                                                                        \\\n    }                                                                          \\\n    break;                                                                     \\\n  }\n\n      CASE(1);\n      CASE(2);\n      CASE(3);\n      CASE(4);\n      CASE(5);\n      default:\n        OP_REQUIRES(\n            ctx, false,\n            errors::InvalidArgument(\"Only tensors with ranks between 1 and 5 \"\n                                    \"are currently supported.  Tensor rank: \",\n                                    ndims));\n#undef CASE\n    }\n\n    output_values->flat<T>().device(ctx->eigen_device<Device>()) =\n        values_t->flat<T>().binaryExpr(dense_gathered_flat,\n                                       typename Functor::func());\n  }","target":1,"code_token_length":1443,"total_token_length":1679,"max_tokens_setting":2048}
+{"idx":259252,"func":"static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n    int ret;\n\n    st = avformat_new_stream(c->fc, NULL);\n    if (!st) return AVERROR(ENOMEM);\n    st->id = -1;\n    sc = av_mallocz(sizeof(MOVStreamContext));\n    if (!sc) return AVERROR(ENOMEM);\n\n    st->priv_data = sc;\n    st->codecpar->codec_type = AVMEDIA_TYPE_DATA;\n    sc->ffindex = st->index;\n    c->trak_index = st->index;\n\n    if ((ret = mov_read_default(c, pb, atom)) < 0)\n        return ret;\n\n    c->trak_index = -1;\n\n    \/\/ Here stsc refers to a chunk not described in stco. This is technically invalid,\n    \/\/ but we can overlook it (clearing stsc) whenever stts_count == 0 (indicating no samples).\n    if (!sc->chunk_count && !sc->stts_count && sc->stsc_count) {\n        sc->stsc_count = 0;\n        av_freep(&sc->stsc_data);\n    }\n\n    \/* sanity checks *\/\n    if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||\n                            (!sc->sample_size && !sc->sample_count))) ||\n        (!sc->chunk_count && sc->sample_count)) {\n        av_log(c->fc, AV_LOG_ERROR, \"stream %d, missing mandatory atoms, broken header\\n\",\n               st->index);\n        return 0;\n    }\n    if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {\n        av_log(c->fc, AV_LOG_ERROR, \"stream %d, contradictionary STSC and STCO\\n\",\n               st->index);\n        return AVERROR_INVALIDDATA;\n    }\n\n    fix_timescale(c, sc);\n\n    avpriv_set_pts_info(st, 64, 1, sc->time_scale);\n\n    mov_build_index(c, st);\n\n    if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {\n        MOVDref *dref = &sc->drefs[sc->dref_id - 1];\n        if (c->enable_drefs) {\n            if (mov_open_dref(c, &sc->pb, c->fc->url, dref) < 0)\n                av_log(c->fc, AV_LOG_ERROR,\n                       \"stream %d, error opening alias: path='%s', dir='%s', \"\n                       \"filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\\n\",\n                       st->index, dref->path, dref->dir, dref->filename,\n                       dref->volume, dref->nlvl_from, dref->nlvl_to);\n        } else {\n            av_log(c->fc, AV_LOG_WARNING,\n                   \"Skipped opening external track: \"\n                   \"stream %d, alias: path='%s', dir='%s', \"\n                   \"filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d.\"\n                   \"Set enable_drefs to allow this.\\n\",\n                   st->index, dref->path, dref->dir, dref->filename,\n                   dref->volume, dref->nlvl_from, dref->nlvl_to);\n        }\n    } else {\n        sc->pb = c->fc->pb;\n        sc->pb_is_copied = 1;\n    }\n\n    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {\n        if (!st->sample_aspect_ratio.num && st->codecpar->width && st->codecpar->height &&\n            sc->height && sc->width &&\n            (st->codecpar->width != sc->width || st->codecpar->height != sc->height)) {\n            st->sample_aspect_ratio = av_d2q(((double)st->codecpar->height * sc->width) \/\n                                             ((double)st->codecpar->width * sc->height), INT_MAX);\n        }\n\n#if FF_API_R_FRAME_RATE\n        if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1))\n            av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,\n                      sc->time_scale, sc->stts_data[0].duration, INT_MAX);\n#endif\n    }\n\n    \/\/ done for ai5q, ai52, ai55, ai1q, ai12 and ai15.\n    if (!st->codecpar->extradata_size && st->codecpar->codec_id == AV_CODEC_ID_H264 &&\n        TAG_IS_AVCI(st->codecpar->codec_tag)) {\n        ret = ff_generate_avci_extradata(st);\n        if (ret < 0)\n            return ret;\n    }\n\n    switch (st->codecpar->codec_id) {\n#if CONFIG_H261_DECODER\n    case AV_CODEC_ID_H261:\n#endif\n#if CONFIG_H263_DECODER\n    case AV_CODEC_ID_H263:\n#endif\n#if CONFIG_MPEG4_DECODER\n    case AV_CODEC_ID_MPEG4:\n#endif\n        st->codecpar->width = 0; \/* let decoder init width\/height *\/\n        st->codecpar->height= 0;\n        break;\n    }\n\n    \/\/ If the duration of the mp3 packets is not constant, then they could need a parser\n    if (st->codecpar->codec_id == AV_CODEC_ID_MP3\n        && sc->stts_count > 3\n        && sc->stts_count*10 > st->nb_frames\n        && sc->time_scale == st->codecpar->sample_rate) {\n            ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL;\n    }\n    \/* Do not need those anymore. *\/\n    av_freep(&sc->chunk_offsets);\n    av_freep(&sc->sample_sizes);\n    av_freep(&sc->keyframes);\n    av_freep(&sc->stts_data);\n    av_freep(&sc->stps_data);\n    av_freep(&sc->elst_data);\n    av_freep(&sc->rap_group);\n    av_freep(&sc->sync_group);\n    av_freep(&sc->sgpd_sync);\n\n    return 0;\n}","target":0,"code_token_length":1408,"total_token_length":1644,"max_tokens_setting":2048}
+{"idx":438671,"func":"static int rpmsg_probe(struct virtio_device *vdev)\n{\n\tvq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done };\n\tstatic const char * const names[] = { \"input\", \"output\" };\n\tstruct virtqueue *vqs[2];\n\tstruct virtproc_info *vrp;\n\tstruct virtio_rpmsg_channel *vch = NULL;\n\tstruct rpmsg_device *rpdev_ns, *rpdev_ctrl;\n\tvoid *bufs_va;\n\tint err = 0, i;\n\tsize_t total_buf_space;\n\tbool notify;\n\n\tvrp = kzalloc(sizeof(*vrp), GFP_KERNEL);\n\tif (!vrp)\n\t\treturn -ENOMEM;\n\n\tvrp->vdev = vdev;\n\n\tidr_init(&vrp->endpoints);\n\tmutex_init(&vrp->endpoints_lock);\n\tmutex_init(&vrp->tx_lock);\n\tinit_waitqueue_head(&vrp->sendq);\n\n\t\/* We expect two virtqueues, rx and tx (and in this order) *\/\n\terr = virtio_find_vqs(vdev, 2, vqs, vq_cbs, names, NULL);\n\tif (err)\n\t\tgoto free_vrp;\n\n\tvrp->rvq = vqs[0];\n\tvrp->svq = vqs[1];\n\n\t\/* we expect symmetric tx\/rx vrings *\/\n\tWARN_ON(virtqueue_get_vring_size(vrp->rvq) !=\n\t\tvirtqueue_get_vring_size(vrp->svq));\n\n\t\/* we need less buffers if vrings are small *\/\n\tif (virtqueue_get_vring_size(vrp->rvq) < MAX_RPMSG_NUM_BUFS \/ 2)\n\t\tvrp->num_bufs = virtqueue_get_vring_size(vrp->rvq) * 2;\n\telse\n\t\tvrp->num_bufs = MAX_RPMSG_NUM_BUFS;\n\n\tvrp->buf_size = MAX_RPMSG_BUF_SIZE;\n\n\ttotal_buf_space = vrp->num_bufs * vrp->buf_size;\n\n\t\/* allocate coherent memory for the buffers *\/\n\tbufs_va = dma_alloc_coherent(vdev->dev.parent,\n\t\t\t\t     total_buf_space, &vrp->bufs_dma,\n\t\t\t\t     GFP_KERNEL);\n\tif (!bufs_va) {\n\t\terr = -ENOMEM;\n\t\tgoto vqs_del;\n\t}\n\n\tdev_dbg(&vdev->dev, \"buffers: va %pK, dma %pad\\n\",\n\t\tbufs_va, &vrp->bufs_dma);\n\n\t\/* half of the buffers is dedicated for RX *\/\n\tvrp->rbufs = bufs_va;\n\n\t\/* and half is dedicated for TX *\/\n\tvrp->sbufs = bufs_va + total_buf_space \/ 2;\n\n\t\/* set up the receive buffers *\/\n\tfor (i = 0; i < vrp->num_bufs \/ 2; i++) {\n\t\tstruct scatterlist sg;\n\t\tvoid *cpu_addr = vrp->rbufs + i * vrp->buf_size;\n\n\t\trpmsg_sg_init(&sg, cpu_addr, vrp->buf_size);\n\n\t\terr = virtqueue_add_inbuf(vrp->rvq, &sg, 1, cpu_addr,\n\t\t\t\t\t  GFP_KERNEL);\n\t\tWARN_ON(err); \/* sanity check; this can't really happen *\/\n\t}\n\n\t\/* suppress \"tx-complete\" interrupts *\/\n\tvirtqueue_disable_cb(vrp->svq);\n\n\tvdev->priv = vrp;\n\n\trpdev_ctrl = rpmsg_virtio_add_ctrl_dev(vdev);\n\tif (IS_ERR(rpdev_ctrl)) {\n\t\terr = PTR_ERR(rpdev_ctrl);\n\t\tgoto free_coherent;\n\t}\n\n\t\/* if supported by the remote processor, enable the name service *\/\n\tif (virtio_has_feature(vdev, VIRTIO_RPMSG_F_NS)) {\n\t\tvch = kzalloc(sizeof(*vch), GFP_KERNEL);\n\t\tif (!vch) {\n\t\t\terr = -ENOMEM;\n\t\t\tgoto free_ctrldev;\n\t\t}\n\n\t\t\/* Link the channel to our vrp *\/\n\t\tvch->vrp = vrp;\n\n\t\t\/* Assign public information to the rpmsg_device *\/\n\t\trpdev_ns = &vch->rpdev;\n\t\trpdev_ns->ops = &virtio_rpmsg_ops;\n\t\trpdev_ns->little_endian = virtio_is_little_endian(vrp->vdev);\n\n\t\trpdev_ns->dev.parent = &vrp->vdev->dev;\n\t\trpdev_ns->dev.release = virtio_rpmsg_release_device;\n\n\t\terr = rpmsg_ns_register_device(rpdev_ns);\n\t\tif (err)\n\t\t\t\/* vch will be free in virtio_rpmsg_release_device() *\/\n\t\t\tgoto free_ctrldev;\n\t}\n\n\t\/*\n\t * Prepare to kick but don't notify yet - we can't do this before\n\t * device is ready.\n\t *\/\n\tnotify = virtqueue_kick_prepare(vrp->rvq);\n\n\t\/* From this point on, we can notify and get callbacks. *\/\n\tvirtio_device_ready(vdev);\n\n\t\/* tell the remote processor it can start sending messages *\/\n\t\/*\n\t * this might be concurrent with callbacks, but we are only\n\t * doing notify, not a full kick here, so that's ok.\n\t *\/\n\tif (notify)\n\t\tvirtqueue_notify(vrp->rvq);\n\n\tdev_info(&vdev->dev, \"rpmsg host is online\\n\");\n\n\treturn 0;\n\nfree_ctrldev:\n\trpmsg_virtio_del_ctrl_dev(rpdev_ctrl);\nfree_coherent:\n\tdma_free_coherent(vdev->dev.parent, total_buf_space,\n\t\t\t  bufs_va, vrp->bufs_dma);\nvqs_del:\n\tvdev->config->del_vqs(vrp->vdev);\nfree_vrp:\n\tkfree(vrp);\n\treturn err;\n}","target":0,"code_token_length":1197,"total_token_length":1433,"max_tokens_setting":2048}
+{"idx":211461,"func":"parse_cmd_address(exarg_T *eap, char **errormsg, int silent)\n{\n    int\t\taddress_count = 1;\n    linenr_T\tlnum;\n    int\t\tneed_check_cursor = FALSE;\n    int\t\tret = FAIL;\n\n    \/\/ Repeat for all ',' or ';' separated addresses.\n    for (;;)\n    {\n\teap->line1 = eap->line2;\n\teap->line2 = default_address(eap);\n\teap->cmd = skipwhite(eap->cmd);\n\tlnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,\n\t\t\t\t\teap->addr_count == 0, address_count++);\n\tif (eap->cmd == NULL)\t\/\/ error detected\n\t    goto theend;\n\tif (lnum == MAXLNUM)\n\t{\n\t    if (*eap->cmd == '%')   \/\/ '%' - all lines\n\t    {\n\t\t++eap->cmd;\n\t\tswitch (eap->addr_type)\n\t\t{\n\t\t    case ADDR_LINES:\n\t\t    case ADDR_OTHER:\n\t\t\teap->line1 = 1;\n\t\t\teap->line2 = curbuf->b_ml.ml_line_count;\n\t\t\tbreak;\n\t\t    case ADDR_LOADED_BUFFERS:\n\t\t\t{\n\t\t\t    buf_T\t*buf = firstbuf;\n\n\t\t\t    while (buf->b_next != NULL\n\t\t\t\t\t\t  && buf->b_ml.ml_mfp == NULL)\n\t\t\t\tbuf = buf->b_next;\n\t\t\t    eap->line1 = buf->b_fnum;\n\t\t\t    buf = lastbuf;\n\t\t\t    while (buf->b_prev != NULL\n\t\t\t\t\t\t  && buf->b_ml.ml_mfp == NULL)\n\t\t\t\tbuf = buf->b_prev;\n\t\t\t    eap->line2 = buf->b_fnum;\n\t\t\t    break;\n\t\t\t}\n\t\t    case ADDR_BUFFERS:\n\t\t\teap->line1 = firstbuf->b_fnum;\n\t\t\teap->line2 = lastbuf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_WINDOWS:\n\t\t    case ADDR_TABS:\n\t\t\tif (IS_USER_CMDIDX(eap->cmdidx))\n\t\t\t{\n\t\t\t    eap->line1 = 1;\n\t\t\t    eap->line2 = eap->addr_type == ADDR_WINDOWS\n\t\t\t\t\t\t  ? LAST_WIN_NR : LAST_TAB_NR;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ there is no Vim command which uses '%' and\n\t\t\t    \/\/ ADDR_WINDOWS or ADDR_TABS\n\t\t\t    *errormsg = _(e_invalid_range);\n\t\t\t    goto theend;\n\t\t\t}\n\t\t\tbreak;\n\t\t    case ADDR_TABS_RELATIVE:\n\t\t    case ADDR_UNSIGNED:\n\t\t    case ADDR_QUICKFIX:\n\t\t\t*errormsg = _(e_invalid_range);\n\t\t\tgoto theend;\n\t\t    case ADDR_ARGUMENTS:\n\t\t\tif (ARGCOUNT == 0)\n\t\t\t    eap->line1 = eap->line2 = 0;\n\t\t\telse\n\t\t\t{\n\t\t\t    eap->line1 = 1;\n\t\t\t    eap->line2 = ARGCOUNT;\n\t\t\t}\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX_VALID:\n#ifdef FEAT_QUICKFIX\n\t\t\teap->line1 = 1;\n\t\t\teap->line2 = qf_get_valid_size(eap);\n\t\t\tif (eap->line2 == 0)\n\t\t\t    eap->line2 = 1;\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_NONE:\n\t\t\t\/\/ Will give an error later if a range is found.\n\t\t\tbreak;\n\t\t}\n\t\t++eap->addr_count;\n\t    }\n\t    else if (*eap->cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)\n\t    {\n\t\tpos_T\t    *fp;\n\n\t\t\/\/ '*' - visual area\n\t\tif (eap->addr_type != ADDR_LINES)\n\t\t{\n\t\t    *errormsg = _(e_invalid_range);\n\t\t    goto theend;\n\t\t}\n\n\t\t++eap->cmd;\n\t\tif (!eap->skip)\n\t\t{\n\t\t    fp = getmark('<', FALSE);\n\t\t    if (check_mark(fp) == FAIL)\n\t\t\tgoto theend;\n\t\t    eap->line1 = fp->lnum;\n\t\t    fp = getmark('>', FALSE);\n\t\t    if (check_mark(fp) == FAIL)\n\t\t\tgoto theend;\n\t\t    eap->line2 = fp->lnum;\n\t\t    ++eap->addr_count;\n\t\t}\n\t    }\n\t}\n\telse\n\t    eap->line2 = lnum;\n\teap->addr_count++;\n\n\tif (*eap->cmd == ';')\n\t{\n\t    if (!eap->skip)\n\t    {\n\t\tcurwin->w_cursor.lnum = eap->line2;\n\n\t\t\/\/ Don't leave the cursor on an illegal line or column, but do\n\t\t\/\/ accept zero as address, so 0;\/PATTERN\/ works correctly.\n\t\t\/\/ Check the cursor position before returning.\n\t\tif (eap->line2 > 0)\n\t\t    check_cursor();\n\t\tneed_check_cursor = TRUE;\n\t    }\n\t}\n\telse if (*eap->cmd != ',')\n\t    break;\n\t++eap->cmd;\n    }\n\n    \/\/ One address given: set start and end lines.\n    if (eap->addr_count == 1)\n    {\n\teap->line1 = eap->line2;\n\t\/\/ ... but only implicit: really no address given\n\tif (lnum == MAXLNUM)\n\t    eap->addr_count = 0;\n    }\n    ret = OK;\n\ntheend:\n    if (need_check_cursor)\n\tcheck_cursor();\n    return ret;\n}","target":1,"code_token_length":1151,"total_token_length":1387,"max_tokens_setting":2048}
+{"idx":413343,"func":"static int netsnmp_session_init(php_snmp_session **session_p, int version, char *hostname, char *community, int timeout, int retries TSRMLS_DC)\n{\n\tphp_snmp_session *session;\n\tchar *pptr, *host_ptr;\n\tint force_ipv6 = FALSE;\n\tint n;\n\tstruct sockaddr **psal;\n\tstruct sockaddr **res;\n\n\t*session_p = (php_snmp_session *)emalloc(sizeof(php_snmp_session));\n\tsession = *session_p;\n\tif (session == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"emalloc() failed allocating session\");\n\t\treturn (-1);\n\t}\n\tmemset(session, 0, sizeof(php_snmp_session));\n\n\tsnmp_sess_init(session);\n\n\tsession->version = version;\n\tsession->remote_port = SNMP_PORT;\n\n\tsession->peername = emalloc(MAX_NAME_LEN);\n\tif (session->peername == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"emalloc() failed while copying hostname\");\n\t\treturn (-1);\n\t}\n\t\/* we copy original hostname for further processing *\/\n\tstrlcpy(session->peername, hostname, MAX_NAME_LEN);\n\thost_ptr = session->peername;\n\n\t\/* Reading the hostname and its optional non-default port number *\/\n\tif (*host_ptr == '[') { \/* IPv6 address *\/\n\t\tforce_ipv6 = TRUE;\n\t\thost_ptr++;\n\t\tif ((pptr = strchr(host_ptr, ']'))) {\n\t\t\tif (pptr[1] == ':') {\n\t\t\t\tsession->remote_port = atoi(pptr + 2);\n\t\t\t}\n\t\t\t*pptr = '\\0';\n\t\t} else {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"malformed IPv6 address, closing square bracket missing\");\n\t\t\treturn (-1);\n\t\t}\n\t} else { \/* IPv4 address *\/\n\t\tif ((pptr = strchr(host_ptr, ':'))) {\n\t\t\tsession->remote_port = atoi(pptr + 1);\n\t\t\t*pptr = '\\0';\n\t\t}\n\t}\n\n\t\/* since Net-SNMP library requires 'udp6:' prefix for all IPv6 addresses (in FQDN form too) we need to\n\t   perform possible name resolution before running any SNMP queries *\/\n\tif ((n = php_network_getaddresses(host_ptr, SOCK_DGRAM, &psal, NULL TSRMLS_CC)) == 0) { \/* some resolver error *\/\n\t\t\/* warnings sent, bailing out *\/\n\t\treturn (-1);\n\t}\n\n\t\/* we have everything we need in psal, flush peername and fill it properly *\/\n\t*(session->peername) = '\\0';\n\tres = psal;\n\twhile (n-- > 0) {\n\t\tpptr = session->peername;\n#if HAVE_GETADDRINFO && HAVE_IPV6 && HAVE_INET_NTOP\n\t\tif (force_ipv6 && (*res)->sa_family != AF_INET6) {\n\t\t\tres++;\n\t\t\tcontinue;\n\t\t}\n\t\tif ((*res)->sa_family == AF_INET6) {\n\t\t\tstrcpy(session->peername, \"udp6:[\");\n\t\t\tpptr = session->peername + strlen(session->peername);\n\t\t\tinet_ntop((*res)->sa_family, &(((struct sockaddr_in6*)(*res))->sin6_addr), pptr, MAX_NAME_LEN);\n\t\t\tstrcat(pptr, \"]\");\n\t\t} else if ((*res)->sa_family == AF_INET) {\n\t\t\tinet_ntop((*res)->sa_family, &(((struct sockaddr_in*)(*res))->sin_addr), pptr, MAX_NAME_LEN);\n\t\t} else {\n\t\t\tres++;\n\t\t\tcontinue;\n\t\t}\n#else\n\t\tif ((*res)->sa_family != AF_INET) {\n\t\t\tres++;\n\t\t\tcontinue;\n\t\t}\n\t\tstrcat(pptr, inet_ntoa(((struct sockaddr_in*)(*res))->sin_addr));\n#endif\n\t\tbreak;\n\t}\n\n\tif (strlen(session->peername) == 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown failure while resolving '%s'\", hostname);\n\t\treturn (-1);\n\t}\n\t\/* XXX FIXME\n\t\tThere should be check for non-empty session->peername!\n\t*\/\n\n\t\/* put back non-standard SNMP port *\/\n\tif (session->remote_port != SNMP_PORT) {\n\t\tpptr = session->peername + strlen(session->peername);\n\t\tsprintf(pptr, \":%d\", session->remote_port);\n\t}\n\n\tphp_network_freeaddresses(psal);\n\n\tif (version == SNMP_VERSION_3) {\n\t\t\/* Setting the security name. *\/\n\t\tsession->securityName = estrdup(community);\n\t\tsession->securityNameLen = strlen(session->securityName);\n\t} else {\n\t\tsession->authenticator = NULL;\n\t\tsession->community = (u_char *)estrdup(community);\n\t\tsession->community_len = strlen(community);\n\t}\n\n\tsession->retries = retries;\n\tsession->timeout = timeout;\n\treturn (0);\n}","target":0,"code_token_length":1020,"total_token_length":1256,"max_tokens_setting":2048}
+{"idx":195391,"func":"  void Compute(tensorflow::OpKernelContext* context) override {\n    for (int ngram_width : ngram_widths_) {\n      OP_REQUIRES(\n          context, ngram_width > 0,\n          errors::InvalidArgument(\"ngram_widths must contain positive values\"));\n    }\n\n    const tensorflow::Tensor* data;\n    OP_REQUIRES_OK(context, context->input(\"data\", &data));\n    const auto& input_data = data->flat<tstring>().data();\n\n    const tensorflow::Tensor* splits;\n    OP_REQUIRES_OK(context, context->input(\"data_splits\", &splits));\n    const auto& splits_vec = splits->flat<SPLITS_TYPE>();\n\n    \/\/ Validate that the splits are valid indices into data, only if there are\n    \/\/ splits specified.\n    const int input_data_size = data->flat<tstring>().size();\n    const int splits_vec_size = splits_vec.size();\n    if (splits_vec_size > 0) {\n      int prev_split = splits_vec(0);\n      OP_REQUIRES(context, prev_split == 0,\n                  errors::InvalidArgument(\"First split value must be 0, got \",\n                                          prev_split));\n      for (int i = 1; i < splits_vec_size; ++i) {\n        bool valid_splits = splits_vec(i) >= prev_split;\n        valid_splits = valid_splits && (splits_vec(i) <= input_data_size);\n        OP_REQUIRES(context, valid_splits,\n                    errors::InvalidArgument(\n                        \"Invalid split value \", splits_vec(i), \", must be in [\",\n                        prev_split, \", \", input_data_size, \"]\"));\n        prev_split = splits_vec(i);\n      }\n      OP_REQUIRES(context, prev_split == input_data_size,\n                  errors::InvalidArgument(\n                      \"Last split value must be data size. Expected \",\n                      input_data_size, \", got \", prev_split));\n    }\n\n    int num_batch_items = splits_vec.size() - 1;\n    tensorflow::Tensor* ngrams_splits;\n    OP_REQUIRES_OK(\n        context, context->allocate_output(1, splits->shape(), &ngrams_splits));\n    auto ngrams_splits_data = ngrams_splits->flat<SPLITS_TYPE>().data();\n\n    \/\/ If there is no data or size, return an empty RT.\n    if (data->flat<tstring>().size() == 0 || splits_vec.size() == 0) {\n      tensorflow::Tensor* empty;\n      OP_REQUIRES_OK(context,\n                     context->allocate_output(0, data->shape(), &empty));\n      for (int i = 0; i <= num_batch_items; ++i) {\n        ngrams_splits_data[i] = 0;\n      }\n      return;\n    }\n\n    ngrams_splits_data[0] = 0;\n    for (int i = 1; i <= num_batch_items; ++i) {\n      int length = splits_vec(i) - splits_vec(i - 1);\n      int num_ngrams = 0;\n      for (int ngram_width : ngram_widths_)\n        num_ngrams += get_num_ngrams(length, ngram_width);\n      if (preserve_short_ && length > 0 && num_ngrams == 0) {\n        num_ngrams = 1;\n      }\n      ngrams_splits_data[i] = ngrams_splits_data[i - 1] + num_ngrams;\n    }\n\n    tensorflow::Tensor* ngrams;\n    OP_REQUIRES_OK(\n        context,\n        context->allocate_output(\n            0, TensorShape({ngrams_splits_data[num_batch_items]}), &ngrams));\n    auto ngrams_data = ngrams->flat<tstring>().data();\n\n    for (int i = 0; i < num_batch_items; ++i) {\n      auto data_start = &input_data[splits_vec(i)];\n      int output_start_idx = ngrams_splits_data[i];\n      for (int ngram_width : ngram_widths_) {\n        auto output_start = &ngrams_data[output_start_idx];\n        int length = splits_vec(i + 1) - splits_vec(i);\n        int num_ngrams = get_num_ngrams(length, ngram_width);\n        CreateNgrams(data_start, output_start, num_ngrams, ngram_width);\n        output_start_idx += num_ngrams;\n      }\n      \/\/ If we're preserving short sequences, check to see if no sequence was\n      \/\/ generated by comparing the current output start idx to the original\n      \/\/ one (ngram_splits_data). If no ngrams were generated, then they will\n      \/\/ be equal (since we increment output_start_idx by num_ngrams every\n      \/\/ time we create a set of ngrams.)\n      if (preserve_short_ && output_start_idx == ngrams_splits_data[i]) {\n        int data_length = splits_vec(i + 1) - splits_vec(i);\n        \/\/ One legitimate reason to not have any ngrams when preserve_short_\n        \/\/ is true is if the sequence itself is empty. In that case, move on.\n        if (data_length == 0) {\n          continue;\n        }\n        \/\/ We don't have to worry about dynamic padding sizes here: if padding\n        \/\/ was dynamic, every sequence would have had sufficient padding to\n        \/\/ generate at least one ngram.\n        int ngram_width = data_length + 2 * pad_width_;\n        auto output_start = &ngrams_data[output_start_idx];\n        int num_ngrams = 1;\n        CreateNgrams(data_start, output_start, num_ngrams, ngram_width);\n      }\n    }\n  }","target":1,"code_token_length":1155,"total_token_length":1391,"max_tokens_setting":2048}
+{"idx":274651,"func":"callbacks_drawingarea_button_press_event (GtkWidget *widget, GdkEventButton *event)\n{\n\tGdkWindow *drawing_area_window = screen.drawing_area->window;\n\tGdkCursor *cursor;\n\t\n\tswitch (event->button) {\n\t\tcase 1 :\n\t\t\tif (screen.tool == POINTER) {\n\t\t\t\t\/* select *\/\n\t\t\t\t\/* selection will only work with cairo, so do nothing if it's\n\t\t\t\t   not compiled *\/\n\t\t\t\tscreen.state = IN_SELECTION_DRAG;\n\t\t\t\tscreen.start_x = event->x;\n\t\t\t\tscreen.start_y = event->y;\n\t\t\t}\n\t\t\telse if (screen.tool == PAN) {\n\t\t\t\t\/* Plain panning *\/\n\t\t\t\tscreen.state = IN_MOVE;\n\t\t\t\tscreen.last_x = event->x;\n\t\t\t\tscreen.last_y = event->y;\n\t\t\t}\n\t\t\telse if (screen.tool == ZOOM) {\n\t\t\t\tscreen.state = IN_ZOOM_OUTLINE;\n\t\t\t\t\/* Zoom outline mode initiated *\/\n\t\t\t\tscreen.start_x = event->x;\n\t\t\t\tscreen.start_y = event->y;\n\t\t\t\tscreen.centered_outline_zoom = event->state;\n\t\t\t}\n\t\t\telse if (screen.tool == MEASURE) {\n\t\t\t\tscreen.state = IN_MEASURE;\n\t\t\t\tcallbacks_screen2board(&(screen.measure_start_x), &(screen.measure_start_y),\n\t\t\t\t\t\t\t\tevent->x, event->y);\n\t\t\t\tscreen.measure_stop_x = screen.measure_start_x;\n\t\t\t\tscreen.measure_stop_y = screen.measure_start_y;\n\t\t\t\t\/* force an expose event to clear any previous measure lines *\/\n\t\t\t\tcallbacks_force_expose_event_for_screen ();\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 2 :\n\t\t\tscreen.state = IN_MOVE;\n\t\t\tscreen.last_x = event->x;\n\t\t\tscreen.last_y = event->y;\n\t\t\tcursor = gdk_cursor_new(GDK_FLEUR);\n\t\t\tgdk_window_set_cursor(drawing_area_window, cursor);\n\t\t\tgdk_cursor_destroy(cursor);\n\t\t\tbreak;\n\t\tcase 3 :\n\t\t\tif (screen.tool == POINTER) {\n\t\t\t\t\/* if no items are selected, try and find the item the user\n\t\t\t\t   is pointing at *\/\n\t\t\t\tif (selection_length (&screen.selectionInfo) == 0) {\n\t\t\t\t\tgint index=callbacks_get_selected_row_index();\n\t\t\t\t\tif ((index >= 0) && \n\t\t\t\t\t    (index <= mainProject->last_loaded) &&\n\t\t\t\t\t    (mainProject->file[index]->isVisible)) {\n\t\t\t\t\t  render_fill_selection_buffer_from_mouse_click(\n\t\t\t\t\t\t\t  event->x, event->y,\n\t\t\t\t\t\t\t  index, SELECTION_REPLACE);\n\t\t\t\t\t} else {\n\t\t\t\t\t    selection_clear (&screen.selectionInfo);\n\t\t\t\t\t    update_selected_object_message (FALSE);\n\t\t\t\t\t    render_refresh_rendered_image_on_screen ();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/* only show the popup if we actually have something selected now *\/\n\t\t\t\tif (selection_length (&screen.selectionInfo) != 0) {\n\t\t\t\t\tupdate_selected_object_message (TRUE);\n\t\t\t\t\tgtk_menu_popup(GTK_MENU(screen.win.drawWindowPopupMenu), NULL, NULL, NULL, NULL, \n\t\t\t\t\t\t\tevent->button, event->time);\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\t\/* Zoom outline mode initiated *\/\n\t\t\t\tscreen.state = IN_ZOOM_OUTLINE;\n\t\t\t\tscreen.start_x = event->x;\n\t\t\t\tscreen.start_y = event->y;\n\t\t\t\tscreen.centered_outline_zoom = event->state & GDK_SHIFT_MASK;\n\t\t\t\tcursor = gdk_cursor_new(GDK_SIZING);\n\t\t\t\tgdk_window_set_cursor(drawing_area_window, cursor);\n\t\t\t\tgdk_cursor_destroy(cursor);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 4 : \/* Scroll wheel *\/\n\t\t\trender_zoom_display (ZOOM_IN_CMOUSE, 0, event->x, event->y);\n\t\t\tbreak;\n\t\tcase 5 :  \/* Scroll wheel *\/\n\t\t\trender_zoom_display (ZOOM_OUT_CMOUSE, 0, event->x, event->y);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\tcallbacks_switch_to_correct_cursor ();\n\treturn TRUE;\n}","target":0,"code_token_length":797,"total_token_length":1033,"max_tokens_setting":2048}
+{"idx":195741,"func":"bool SingleComponentLSScan::ParseMCU(void)\n{ \n#if ACCUSOFT_CODE\n  int lines             = m_ulRemaining[0]; \/\/ total number of MCU lines processed.\n  UBYTE preshift        = m_ucLowBit + FractionalColorBitsOf();\n  struct Line *line     = CurrentLine(0);\n  \n  \/\/\n  \/\/ If a DNL marker is present, the number of remaining lines is zero. Fix it.\n  if (m_pFrame->HeightOf() == 0) {\n    assert(lines == 0);\n    lines = 8;\n  }\n\n  assert(m_ucCount == 1);\n\n  \/\/\n  \/\/ A \"MCU\" in respect to the code organization is eight lines.\n  if (lines > 8) {\n    lines = 8;\n  }\n  if (m_pFrame->HeightOf() > 0)\n    m_ulRemaining[0] -= lines;\n  \n  assert(lines > 0);\n\n  \/\/ Loop over lines and columns\n  do {\n    LONG length = m_ulWidth[0];\n    LONG *lp    = line->m_pData;\n\n#ifdef DEBUG_LS\n    int xpos    = 0;\n    static int linenumber = 0;\n    printf(\"\\n%4d : \",++linenumber);\n#endif\n     \n    StartLine(0);\n    if (BeginReadMCU(m_Stream.ByteStreamOf())) { \/\/ No error handling strategy. No RST in scans. Bummer!\n      do {\n        LONG a,b,c,d;   \/\/ neighbouring values.\n        LONG d1,d2,d3;  \/\/ local gradients.\n      \n        GetContext(0,a,b,c,d);\n        d1  = d - b;    \/\/ compute local gradients\n        d2  = b - c;\n        d3  = c - a;\n        \n        if (isRunMode(d1,d2,d3)) {\n          LONG run = DecodeRun(length,m_lRunIndex[0]);\n          \/\/\n          \/\/ Now fill the data.\n          while(run) {\n            \/\/ Update so that the next process gets the correct value.\n            UpdateContext(0,a);\n            \/\/ And insert the value into the target line as well.\n            *lp++ = a << preshift;\n#ifdef DEBUG_LS\n            printf(\"%4d:<%2x> \",xpos++,a);\n#endif\n            run--,length--;\n            \/\/ As long as there are pixels on the line.\n          }\n          \/\/\n          \/\/ More data on the line? I.e. the run did not cover the full m_lJ samples?\n          \/\/ Now decode the run interruption sample.\n          if (length) {\n            bool negative; \/\/ the sign variable\n            bool rtype;    \/\/ run interruption type\n            LONG errval;   \/\/ the prediction error\n            LONG merr;     \/\/ the mapped error (symbol)\n            LONG rx;       \/\/ the reconstructed value\n            UBYTE k;       \/\/ golomb parameter\n            \/\/ Get the neighbourhood.\n            GetContext(0,a,b,c,d);\n            \/\/ Get the prediction mode.\n            rtype  = InterruptedPredictionMode(negative,a,b);\n            \/\/ Get the golomb parameter for run interruption coding.\n            k      = GolombParameter(rtype);\n            \/\/ Golomb-decode the error symbol.\n            merr   = GolombDecode(k,m_lLimit - m_lJ[m_lRunIndex[0]] - 1);\n            \/\/ Inverse the error mapping procedure.\n            errval = InverseErrorMapping(merr + rtype,ErrorMappingOffset(rtype,rtype || merr,k));\n            \/\/ Compute the reconstructed value.\n            rx     = Reconstruct(negative,rtype?a:b,errval);\n            \/\/ Update so that the next process gets the correct value.\n            UpdateContext(0,rx);\n            \/\/ Fill in the value into the line\n            *lp    = rx << preshift;\n#ifdef DEBUG_LS\n            printf(\"%4d:<%2x> \",xpos++,*lp);\n#endif\n            \/\/ Update the variables of the run mode.\n            UpdateState(rtype,errval);\n            \/\/ Update the run index now. This is not part of\n            \/\/ EncodeRun because the non-reduced run-index is\n            \/\/ required for the golomb coder length limit. \n            if (m_lRunIndex[0] > 0)\n              m_lRunIndex[0]--;\n          } else break; \/\/ end of line.\n        } else {\n          UWORD ctxt;\n          bool  negative; \/\/ the sign variable.\n          LONG  px;       \/\/ the predicted variable.\n          LONG  rx;       \/\/ the reconstructed value.\n          LONG  errval;   \/\/ the error value.\n          LONG  merr;     \/\/ the mapped error value.\n          UBYTE k;        \/\/ the Golomb parameter.\n          \/\/ Quantize the gradients.\n          d1     = QuantizedGradient(d1);\n          d2     = QuantizedGradient(d2);\n          d3     = QuantizedGradient(d3);\n          \/\/ Compute the context.\n          ctxt   = Context(negative,d1,d2,d3); \n          \/\/ Compute the predicted value.\n          px     = Predict(a,b,c);\n          \/\/ Correct the prediction.\n          px     = CorrectPrediction(ctxt,negative,px);\n          \/\/ Compute the golomb parameter k from the context.\n          k      = GolombParameter(ctxt);\n          \/\/ Decode the error symbol.\n          merr   = GolombDecode(k,m_lLimit);\n          \/\/ Inverse the error symbol into an error value.\n          errval = InverseErrorMapping(merr,ErrorMappingOffset(ctxt,k));\n          \/\/ Update the variables.\n          UpdateState(ctxt,errval);\n          \/\/ Compute the reconstructed value.\n          rx     = Reconstruct(negative,px,errval);\n          \/\/ Update so that the next process gets the correct value.\n          UpdateContext(0,rx);\n          \/\/ And insert the value into the target line as well.\n          *lp    = rx << preshift;\n#ifdef DEBUG_LS\n          printf(\"%4d:<%2x> \",xpos++,*lp);\n#endif\n        }\n      } while(++lp,--length);\n    } \/\/ No error handling here.\n    EndLine(0);\n    line = line->m_pNext;\n  } while(--lines); \n  \/\/\n  \/\/ If this is the last line, gobble up all the\n  \/\/ bits from bitstuffing the last byte may have left.\n  \/\/ As SkipStuffing is idempotent, we can also do that\n  \/\/ all the time.\n  m_Stream.SkipStuffing();\n#endif  \n  return false;\n}","target":1,"code_token_length":1373,"total_token_length":1609,"max_tokens_setting":2048}
+{"idx":252463,"func":"mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip,\n                                 const char *pArchive_name, const void *pBuf,\n                                 size_t buf_size, const void *pComment,\n                                 mz_uint16 comment_size,\n                                 mz_uint level_and_flags, mz_uint64 uncomp_size,\n                                 mz_uint32 uncomp_crc32) {\n  mz_uint16 method = 0, dos_time = 0, dos_date = 0;\n  mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;\n  mz_uint64 local_dir_header_ofs = pZip->m_archive_size,\n            cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0;\n  size_t archive_name_size;\n  mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];\n  tdefl_compressor *pComp = NULL;\n  mz_bool store_data_uncompressed;\n  mz_zip_internal_state *pState;\n\n  if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL;\n  level = level_and_flags & 0xF;\n  store_data_uncompressed =\n      ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA));\n\n  if ((!pZip) || (!pZip->m_pState) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) ||\n      (!pArchive_name) || ((comment_size) && (!pComment)) ||\n      (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION))\n    return MZ_FALSE;\n\n  pState = pZip->m_pState;\n\n  if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size))\n    return MZ_FALSE;\n  \/\/ No zip64 support yet\n  if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) return MZ_FALSE;\n  if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE;\n\n#ifndef MINIZ_NO_TIME\n  {\n    time_t cur_time;\n    time(&cur_time);\n    mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date);\n  }\n#endif  \/\/ #ifndef MINIZ_NO_TIME\n\n  archive_name_size = strlen(pArchive_name);\n  if (archive_name_size > 0xFFFF) return MZ_FALSE;\n\n  num_alignment_padding_bytes =\n      mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);\n\n  \/\/ no zip64 support yet\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + num_alignment_padding_bytes +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n        comment_size + archive_name_size) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '\/')) {\n    \/\/ Set DOS Subdirectory attribute bit.\n    ext_attributes |= 0x10;\n    \/\/ Subdirectories cannot contain data.\n    if ((buf_size) || (uncomp_size)) return MZ_FALSE;\n  }\n\n  \/\/ Try to do any allocations before writing to the archive, so if an\n  \/\/ allocation fails the file remains unmodified. (A good idea if we're doing\n  \/\/ an in-place modification.)\n  if ((!mz_zip_array_ensure_room(\n          pZip, &pState->m_central_dir,\n          MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) ||\n      (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1)))\n    return MZ_FALSE;\n\n  if ((!store_data_uncompressed) && (buf_size)) {\n    if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(\n                     pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor))))\n      return MZ_FALSE;\n  }\n\n  if (!mz_zip_writer_write_zeros(\n          pZip, cur_archive_file_ofs,\n          num_alignment_padding_bytes + sizeof(local_dir_header))) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n    return MZ_FALSE;\n  }\n  local_dir_header_ofs += num_alignment_padding_bytes;\n  if (pZip->m_file_offset_alignment) {\n    MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) ==\n              0);\n  }\n  cur_archive_file_ofs +=\n      num_alignment_padding_bytes + sizeof(local_dir_header);\n\n  MZ_CLEAR_OBJ(local_dir_header);\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name,\n                     archive_name_size) != archive_name_size) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n    return MZ_FALSE;\n  }\n  cur_archive_file_ofs += archive_name_size;\n\n  if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) {\n    uncomp_crc32 =\n        (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size);\n    uncomp_size = buf_size;\n    if (uncomp_size <= 3) {\n      level = 0;\n      store_data_uncompressed = MZ_TRUE;\n    }\n  }\n\n  if (store_data_uncompressed) {\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf,\n                       buf_size) != buf_size) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n      return MZ_FALSE;\n    }\n\n    cur_archive_file_ofs += buf_size;\n    comp_size = buf_size;\n\n    if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) method = MZ_DEFLATED;\n  } else if (buf_size) {\n    mz_zip_writer_add_state state;\n\n    state.m_pZip = pZip;\n    state.m_cur_archive_file_ofs = cur_archive_file_ofs;\n    state.m_comp_size = 0;\n\n    if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state,\n                    tdefl_create_comp_flags_from_zip_params(\n                        level, -15, MZ_DEFAULT_STRATEGY)) !=\n         TDEFL_STATUS_OKAY) ||\n        (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) !=\n         TDEFL_STATUS_DONE)) {\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n      return MZ_FALSE;\n    }\n\n    comp_size = state.m_comp_size;\n    cur_archive_file_ofs = state.m_cur_archive_file_ofs;\n\n    method = MZ_DEFLATED;\n  }\n\n  pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n  pComp = NULL;\n\n  \/\/ no zip64 support yet\n  if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_create_local_dir_header(\n          pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size,\n          comp_size, uncomp_crc32, method, 0, dos_time, dos_date))\n    return MZ_FALSE;\n\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header,\n                     sizeof(local_dir_header)) != sizeof(local_dir_header))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_add_to_central_dir(\n          pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment,\n          comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0,\n          dos_time, dos_date, local_dir_header_ofs, ext_attributes))\n    return MZ_FALSE;\n\n  pZip->m_total_files++;\n  pZip->m_archive_size = cur_archive_file_ofs;\n\n  return MZ_TRUE;\n}","target":0,"code_token_length":1775,"total_token_length":2011,"max_tokens_setting":2048}
+{"idx":205570,"func":"RList *r_bin_ne_get_relocs(r_bin_ne_obj_t *bin) {\n\tRList *segments = bin->segments;\n\tif (!segments) {\n\t\treturn NULL;\n\t}\n\tRList *entries = bin->entries;\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *symbols = bin->symbols;\n\tif (!symbols) {\n\t\treturn NULL;\n\t}\n\n\tut16 *modref = calloc (bin->ne_header->ModRefs, sizeof (ut16));\n\tif (!modref) {\n\t\treturn NULL;\n\t}\n\tr_buf_read_at (bin->buf, (ut64)bin->ne_header->ModRefTable + bin->header_offset, (ut8 *)modref, bin->ne_header->ModRefs * sizeof (ut16));\n\n\tRList *relocs = r_list_newf (free);\n\tif (!relocs) {\n\t\tfree (modref);\n\t\treturn NULL;\n\t}\n\n\tRListIter *it;\n\tRBinSection *seg;\n\tint index = -1;\n\tr_list_foreach (segments, it, seg) {\n\t\tindex++;\n\t\tif (!(bin->segment_entries[index].flags & RELOCINFO)) {\n\t\t\tcontinue;\n\t\t}\n\t\tut32 off = seg->paddr + seg->size;\n\t\tut32 start = off;\n\t\tut16 length = r_buf_read_le16_at (bin->buf, off);\n\t\tif (!length) {\n\t\t\tcontinue;\n\t\t}\n\t\toff += 2;\n\t\t\/\/ size_t buf_size = r_buf_size (bin->buf);\n\t\twhile (off < start + length * sizeof (NE_image_reloc_item)) {\n\t\t\t\/\/ && off + sizeof (NE_image_reloc_item) < buf_size)\n\t\t\tNE_image_reloc_item rel = {0};\n\t\t\tif (r_buf_read_at (bin->buf, off, (ut8 *)&rel, sizeof (rel)) < 1) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tRBinReloc *reloc = R_NEW0 (RBinReloc);\n\t\t\tif (!reloc) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treloc->paddr = seg->paddr + rel.offset;\n\t\t\tswitch (rel.type) {\n\t\t\tcase LOBYTE:\n\t\t\t\treloc->type = R_BIN_RELOC_8;\n\t\t\t\tbreak;\n\t\t\tcase SEL_16:\n\t\t\tcase OFF_16:\n\t\t\t\treloc->type = R_BIN_RELOC_16;\n\t\t\t\tbreak;\n\t\t\tcase POI_32:\n\t\t\tcase OFF_32:\n\t\t\t\treloc->type = R_BIN_RELOC_32;\n\t\t\t\tbreak;\n\t\t\tcase POI_48:\n\t\t\t\treloc->type = R_BIN_RELOC_64;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tut32 offset;\n\t\t\tif (rel.flags & (IMPORTED_ORD | IMPORTED_NAME)) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\tif (!imp) {\n\t\t\t\t\tfree (reloc);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tchar *name;\n#if NE_BUG\n\t\t\t\tif (rel.index > 0 && rel.index < bin->ne_header->ModRefs) {\n\t\t\t\t\toffset = modref[rel.index - 1] + bin->header_offset + bin->ne_header->ImportNameTable;\n\t\t\t\t\tname = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t} else {\n\t\t\t\t\tname = r_str_newf (\"UnknownModule%d_%x\", rel.index, off); \/\/ ????\n\t\t\t\t}\n#else\n\t\t\t\tif (rel.index > bin->ne_header->ModRefs) {\n\t\t\t\t\tname = r_str_newf (\"UnknownModule%d_%x\", rel.index, off); \/\/ ????\n\t\t\t\t} else {\n\t\t\t\t\toffset = modref[rel.index - 1] + bin->header_offset + bin->ne_header->ImportNameTable;\n\t\t\t\t\tname = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t}\n#endif\n\t\t\t\tif (rel.flags & IMPORTED_ORD) {\n\t\t\t\t\timp->ordinal = rel.func_ord;\n\t\t\t\t\timp->name = r_str_newf (\"%s.%s\", name, __func_name_from_ord(name, rel.func_ord));\n\t\t\t\t} else {\n\t\t\t\t\toffset = bin->header_offset + bin->ne_header->ImportNameTable + rel.name_off;\n\t\t\t\t\tchar *func = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t\timp->name = r_str_newf (\"%s.%s\", name, func);\n\t\t\t\t\tfree (func);\n\t\t\t\t}\n\t\t\t\tfree (name);\n\t\t\t\treloc->import = imp;\n\t\t\t} else if (rel.flags & OSFIXUP) {\n\t\t\t\t\/\/ TODO\n\t\t\t} else {\n\t\t\t\tif (strstr (seg->name, \"FIXED\")) {\n\t\t\t\t\tRBinSection *s = r_list_get_n (segments, rel.segnum - 1);\n\t\t\t\t\tif (s) {\n\t\t\t\t\t\toffset = s->paddr + rel.segoff;\n\t\t\t\t\t} else {\n\t\t\t\t\t\toffset = -1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tRBinAddr *entry = r_list_get_n (entries, rel.entry_ordinal - 1);\n\t\t\t\t\tif (entry) {\n\t\t\t\t\t\toffset = entry->paddr;\n\t\t\t\t\t} else {\n\t\t\t\t\t\toffset = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treloc->addend = offset;\n\t\t\t\tRBinSymbol *sym = NULL;\n\t\t\t\tRListIter *sit;\n\t\t\t\tr_list_foreach (symbols, sit, sym) {\n\t\t\t\t\tif (sym->paddr == reloc->addend) {\n\t\t\t\t\t\treloc->symbol = sym;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rel.flags & ADDITIVE) {\n\t\t\t\treloc->additive = 1;\n\t\t\t\tr_list_append (relocs, reloc);\n\t\t\t} else {\n\t\t\t\tdo {\n#if NE_BUG\n\t\t\t\t\tif (reloc->paddr + 4 < r_buf_size (bin->buf)) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n#endif\n\t\t\t\t\tr_list_append (relocs, reloc);\n\t\t\t\t\toffset = r_buf_read_le16_at (bin->buf, reloc->paddr);\n\t\t\t\t\tRBinReloc *tmp = reloc;\n\t\t\t\t\treloc = R_NEW0 (RBinReloc);\n\t\t\t\t\tif (!reloc) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t*reloc = *tmp;\n\t\t\t\t\treloc->paddr = seg->paddr + offset;\n\t\t\t\t} while (offset != 0xFFFF);\n\t\t\t\tfree (reloc);\n\t\t\t}\n\n\t\t\toff += sizeof (NE_image_reloc_item);\n\t\t}\n\t}\n\tfree (modref);\n\treturn relocs;\n}","target":1,"code_token_length":1397,"total_token_length":1633,"max_tokens_setting":2048}
+{"idx":437364,"func":"setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)\n{\n  int r = 0;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n    {\n      Node* prev = NULL_NODE;\n      do {\n        r = setup_tree(NODE_CAR(node), reg, state, env);\n        if (IS_NOT_NULL(prev) && r == 0) {\n          r = next_setup(prev, NODE_CAR(node), reg);\n        }\n        prev = NODE_CAR(node);\n      } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    }\n    break;\n\n  case NODE_ALT:\n    do {\n      r = setup_tree(NODE_CAR(node), reg, (state | IN_ALT), env);\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_STRING:\n    if (IS_IGNORECASE(reg->options) && !NODE_STRING_IS_RAW(node)) {\n      r = expand_case_fold_string(node, reg);\n    }\n    break;\n\n  case NODE_BACKREF:\n    {\n      int i;\n      int* p;\n      BackRefNode* br = BACKREF_(node);\n      p = BACKREFS_P(br);\n      for (i = 0; i < br->back_num; i++) {\n        if (p[i] > env->num_mem)  return ONIGERR_INVALID_BACKREF;\n        MEM_STATUS_ON(env->backrefed_mem, p[i]);\n        MEM_STATUS_ON(env->bt_mem_start, p[i]);\n#ifdef USE_BACKREF_WITH_LEVEL\n        if (NODE_IS_NEST_LEVEL(node)) {\n          MEM_STATUS_ON(env->bt_mem_end, p[i]);\n        }\n#endif\n      }\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      switch (en->type) {\n      case ENCLOSURE_OPTION:\n        {\n          OnigOptionType options = reg->options;\n          reg->options = ENCLOSURE_(node)->o.options;\n          r = setup_tree(NODE_BODY(node), reg, state, env);\n          reg->options = options;\n        }\n        break;\n\n      case ENCLOSURE_MEMORY:\n#ifdef USE_CALL\n        state |= en->m.called_state;\n#endif\n\n        if ((state & (IN_ALT | IN_NOT | IN_VAR_REPEAT | IN_MULTI_ENTRY)) != 0\n            || NODE_IS_RECURSION(node)) {\n          MEM_STATUS_ON(env->bt_mem_start, en->m.regnum);\n        }\n        r = setup_tree(NODE_BODY(node), reg, state, env);\n        break;\n\n      case ENCLOSURE_STOP_BACKTRACK:\n        {\n          Node* target = NODE_BODY(node);\n          r = setup_tree(target, reg, state, env);\n          if (NODE_TYPE(target) == NODE_QUANT) {\n            QuantNode* tqn = QUANT_(target);\n            if (IS_REPEAT_INFINITE(tqn->upper) && tqn->lower <= 1 &&\n                tqn->greedy != 0) {  \/* (?>a*), a*+ etc... *\/\n              if (NODE_IS_SIMPLE_TYPE(NODE_BODY(target)))\n                NODE_STATUS_ADD(node, STOP_BT_SIMPLE_REPEAT);\n            }\n          }\n        }\n        break;\n\n      case ENCLOSURE_IF_ELSE:\n        r = setup_tree(NODE_BODY(node), reg, (state | IN_ALT), env);\n        if (r != 0) return r;\n        if (IS_NOT_NULL(en->te.Then)) {\n          r = setup_tree(en->te.Then, reg, (state | IN_ALT), env);\n          if (r != 0) return r;\n        }\n        if (IS_NOT_NULL(en->te.Else))\n          r = setup_tree(en->te.Else, reg, (state | IN_ALT), env);\n        break;\n      }\n    }\n    break;\n\n  case NODE_QUANT:\n    r = setup_quant(node, reg, state, env);\n    break;\n\n  case NODE_ANCHOR:\n    r = setup_anchor(node, reg, state, env);\n    break;\n\n#ifdef USE_CALL\n  case NODE_CALL:\n#endif\n  case NODE_CTYPE:\n  case NODE_CCLASS:\n  case NODE_GIMMICK:\n  default:\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":903,"total_token_length":1139,"max_tokens_setting":2048}
+{"idx":211522,"func":"parse_cmd_address(exarg_T *eap, char **errormsg, int silent)\n{\n    int\t\taddress_count = 1;\n    linenr_T\tlnum;\n\n    \/\/ Repeat for all ',' or ';' separated addresses.\n    for (;;)\n    {\n\teap->line1 = eap->line2;\n\teap->line2 = default_address(eap);\n\teap->cmd = skipwhite(eap->cmd);\n\tlnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,\n\t\t\t\t\teap->addr_count == 0, address_count++);\n\tif (eap->cmd == NULL)\t\/\/ error detected\n\t    return FAIL;\n\tif (lnum == MAXLNUM)\n\t{\n\t    if (*eap->cmd == '%')   \/\/ '%' - all lines\n\t    {\n\t\t++eap->cmd;\n\t\tswitch (eap->addr_type)\n\t\t{\n\t\t    case ADDR_LINES:\n\t\t    case ADDR_OTHER:\n\t\t\teap->line1 = 1;\n\t\t\teap->line2 = curbuf->b_ml.ml_line_count;\n\t\t\tbreak;\n\t\t    case ADDR_LOADED_BUFFERS:\n\t\t\t{\n\t\t\t    buf_T\t*buf = firstbuf;\n\n\t\t\t    while (buf->b_next != NULL\n\t\t\t\t\t\t  && buf->b_ml.ml_mfp == NULL)\n\t\t\t\tbuf = buf->b_next;\n\t\t\t    eap->line1 = buf->b_fnum;\n\t\t\t    buf = lastbuf;\n\t\t\t    while (buf->b_prev != NULL\n\t\t\t\t\t\t  && buf->b_ml.ml_mfp == NULL)\n\t\t\t\tbuf = buf->b_prev;\n\t\t\t    eap->line2 = buf->b_fnum;\n\t\t\t    break;\n\t\t\t}\n\t\t    case ADDR_BUFFERS:\n\t\t\teap->line1 = firstbuf->b_fnum;\n\t\t\teap->line2 = lastbuf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_WINDOWS:\n\t\t    case ADDR_TABS:\n\t\t\tif (IS_USER_CMDIDX(eap->cmdidx))\n\t\t\t{\n\t\t\t    eap->line1 = 1;\n\t\t\t    eap->line2 = eap->addr_type == ADDR_WINDOWS\n\t\t\t\t\t\t  ? LAST_WIN_NR : LAST_TAB_NR;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ there is no Vim command which uses '%' and\n\t\t\t    \/\/ ADDR_WINDOWS or ADDR_TABS\n\t\t\t    *errormsg = _(e_invalid_range);\n\t\t\t    return FAIL;\n\t\t\t}\n\t\t\tbreak;\n\t\t    case ADDR_TABS_RELATIVE:\n\t\t    case ADDR_UNSIGNED:\n\t\t    case ADDR_QUICKFIX:\n\t\t\t*errormsg = _(e_invalid_range);\n\t\t\treturn FAIL;\n\t\t    case ADDR_ARGUMENTS:\n\t\t\tif (ARGCOUNT == 0)\n\t\t\t    eap->line1 = eap->line2 = 0;\n\t\t\telse\n\t\t\t{\n\t\t\t    eap->line1 = 1;\n\t\t\t    eap->line2 = ARGCOUNT;\n\t\t\t}\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX_VALID:\n#ifdef FEAT_QUICKFIX\n\t\t\teap->line1 = 1;\n\t\t\teap->line2 = qf_get_valid_size(eap);\n\t\t\tif (eap->line2 == 0)\n\t\t\t    eap->line2 = 1;\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_NONE:\n\t\t\t\/\/ Will give an error later if a range is found.\n\t\t\tbreak;\n\t\t}\n\t\t++eap->addr_count;\n\t    }\n\t    else if (*eap->cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)\n\t    {\n\t\tpos_T\t    *fp;\n\n\t\t\/\/ '*' - visual area\n\t\tif (eap->addr_type != ADDR_LINES)\n\t\t{\n\t\t    *errormsg = _(e_invalid_range);\n\t\t    return FAIL;\n\t\t}\n\n\t\t++eap->cmd;\n\t\tif (!eap->skip)\n\t\t{\n\t\t    fp = getmark('<', FALSE);\n\t\t    if (check_mark(fp) == FAIL)\n\t\t\treturn FAIL;\n\t\t    eap->line1 = fp->lnum;\n\t\t    fp = getmark('>', FALSE);\n\t\t    if (check_mark(fp) == FAIL)\n\t\t\treturn FAIL;\n\t\t    eap->line2 = fp->lnum;\n\t\t    ++eap->addr_count;\n\t\t}\n\t    }\n\t}\n\telse\n\t    eap->line2 = lnum;\n\teap->addr_count++;\n\n\tif (*eap->cmd == ';')\n\t{\n\t    if (!eap->skip)\n\t    {\n\t\tcurwin->w_cursor.lnum = eap->line2;\n\t\t\/\/ Don't leave the cursor on an illegal line or column, but do\n\t\t\/\/ accept zero as address, so 0;\/PATTERN\/ works correctly.\n\t\tif (eap->line2 > 0)\n\t\t    check_cursor();\n\t    }\n\t}\n\telse if (*eap->cmd != ',')\n\t    break;\n\t++eap->cmd;\n    }\n\n    \/\/ One address given: set start and end lines.\n    if (eap->addr_count == 1)\n    {\n\teap->line1 = eap->line2;\n\t\/\/ ... but only implicit: really no address given\n\tif (lnum == MAXLNUM)\n\t    eap->addr_count = 0;\n    }\n    return OK;\n}","target":1,"code_token_length":1092,"total_token_length":1328,"max_tokens_setting":2048}
+{"idx":264675,"func":"lexer_convert_literal_to_chars (parser_context_t *context_p, \/**< context *\/\n                                const lexer_lit_location_t *literal_p, \/**< literal location *\/\n                                uint8_t *local_byte_array_p, \/**< local byte array to store chars *\/\n                                lexer_string_options_t opts) \/**< options *\/\n{\n  JERRY_ASSERT (context_p->u.allocated_buffer_p == NULL);\n\n  if (!(literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))\n  {\n    return literal_p->char_p;\n  }\n\n  uint8_t *destination_start_p;\n  if (literal_p->length > LEXER_MAX_LITERAL_LOCAL_BUFFER_SIZE)\n  {\n    context_p->u.allocated_buffer_p = (uint8_t *) parser_malloc_local (context_p, literal_p->length);\n    context_p->allocated_buffer_size = literal_p->length;\n    destination_start_p = context_p->u.allocated_buffer_p;\n  }\n  else\n  {\n    destination_start_p = local_byte_array_p;\n  }\n\n  if (literal_p->type == LEXER_IDENT_LITERAL)\n  {\n    lexer_convert_ident_to_cesu8 (destination_start_p, literal_p->char_p, literal_p->length);\n    return destination_start_p;\n  }\n\n  const uint8_t *source_p = literal_p->char_p;\n  uint8_t *destination_p = destination_start_p;\n\n  uint8_t str_end_character = source_p[-1];\n\n#if JERRY_ESNEXT\n  if (str_end_character == LIT_CHAR_RIGHT_BRACE)\n  {\n    str_end_character = LIT_CHAR_GRAVE_ACCENT;\n  }\n\n  bool is_raw = (opts & LEXER_STRING_RAW) != 0;\n#else \/* !JERRY_ESNEXT *\/\n  JERRY_UNUSED (opts);\n  bool is_raw = false;\n#endif \/* JERRY_ESNEXT *\/\n\n  while (true)\n  {\n    if (*source_p == str_end_character)\n    {\n      break;\n    }\n\n    if (*source_p == LIT_CHAR_BACKSLASH && !is_raw)\n    {\n      uint8_t conv_character;\n\n      source_p++;\n      JERRY_ASSERT (source_p < context_p->source_end_p);\n\n      \/* Newline is ignored. *\/\n      if (*source_p == LIT_CHAR_CR)\n      {\n        source_p++;\n        JERRY_ASSERT (source_p < context_p->source_end_p);\n\n        if (*source_p == LIT_CHAR_LF)\n        {\n          source_p++;\n        }\n        continue;\n      }\n      else if (*source_p == LIT_CHAR_LF)\n      {\n        source_p++;\n        continue;\n      }\n      else if (*source_p == LEXER_NEWLINE_LS_PS_BYTE_1 && LEXER_NEWLINE_LS_PS_BYTE_23 (source_p))\n      {\n        source_p += 3;\n        continue;\n      }\n\n      if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_3)\n      {\n        lit_code_point_t octal_number = (uint32_t) (*source_p - LIT_CHAR_0);\n\n        source_p++;\n        JERRY_ASSERT (source_p < context_p->source_end_p);\n\n        if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_7)\n        {\n          octal_number = octal_number * 8 + (uint32_t) (*source_p - LIT_CHAR_0);\n          source_p++;\n          JERRY_ASSERT (source_p < context_p->source_end_p);\n\n          if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_7)\n          {\n            octal_number = octal_number * 8 + (uint32_t) (*source_p - LIT_CHAR_0);\n            source_p++;\n            JERRY_ASSERT (source_p < context_p->source_end_p);\n          }\n        }\n\n        destination_p += lit_code_point_to_cesu8_bytes (destination_p, octal_number);\n        continue;\n      }\n\n      if (*source_p >= LIT_CHAR_4 && *source_p <= LIT_CHAR_7)\n      {\n        uint32_t octal_number = (uint32_t) (*source_p - LIT_CHAR_0);\n\n        source_p++;\n        JERRY_ASSERT (source_p < context_p->source_end_p);\n\n        if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_7)\n        {\n          octal_number = octal_number * 8 + (uint32_t) (*source_p - LIT_CHAR_0);\n          source_p++;\n          JERRY_ASSERT (source_p < context_p->source_end_p);\n        }\n\n        *destination_p++ = (uint8_t) octal_number;\n        continue;\n      }\n\n      if (*source_p == LIT_CHAR_LOWERCASE_X || *source_p == LIT_CHAR_LOWERCASE_U)\n      {\n        source_p++;\n        destination_p += lit_code_point_to_cesu8_bytes (destination_p, lexer_unchecked_hex_to_character (&source_p));\n        continue;\n      }\n\n      conv_character = *source_p;\n      switch (*source_p)\n      {\n        case LIT_CHAR_LOWERCASE_B:\n        {\n          conv_character = 0x08;\n          break;\n        }\n        case LIT_CHAR_LOWERCASE_T:\n        {\n          conv_character = 0x09;\n          break;\n        }\n        case LIT_CHAR_LOWERCASE_N:\n        {\n          conv_character = 0x0a;\n          break;\n        }\n        case LIT_CHAR_LOWERCASE_V:\n        {\n          conv_character = 0x0b;\n          break;\n        }\n        case LIT_CHAR_LOWERCASE_F:\n        {\n          conv_character = 0x0c;\n          break;\n        }\n        case LIT_CHAR_LOWERCASE_R:\n        {\n          conv_character = 0x0d;\n          break;\n        }\n      }\n\n      if (conv_character != *source_p)\n      {\n        *destination_p++ = conv_character;\n        source_p++;\n        continue;\n      }\n    }\n#if JERRY_ESNEXT\n    else if (str_end_character == LIT_CHAR_GRAVE_ACCENT)\n    {\n      if (source_p[0] == LIT_CHAR_DOLLAR_SIGN && source_p[1] == LIT_CHAR_LEFT_BRACE)\n      {\n        source_p++;\n        JERRY_ASSERT (source_p < context_p->source_end_p);\n        break;\n      }\n      if (*source_p == LIT_CHAR_CR)\n      {\n        *destination_p++ = LIT_CHAR_LF;\n        source_p++;\n        if (*source_p != str_end_character && *source_p == LIT_CHAR_LF)\n        {\n          source_p++;\n        }\n        continue;\n      }\n      if ((*source_p == LIT_CHAR_BACKSLASH) && is_raw)\n      {\n        JERRY_ASSERT (source_p + 1 < context_p->source_end_p);\n        if ((*(source_p + 1) == LIT_CHAR_GRAVE_ACCENT) || (*(source_p + 1) == LIT_CHAR_BACKSLASH))\n        {\n          *destination_p++ = *source_p++;\n          *destination_p++ = *source_p++;\n          continue;\n        }\n      }\n    }\n#endif \/* JERRY_ESNEXT *\/\n\n    if (*source_p >= LIT_UTF8_4_BYTE_MARKER)\n    {\n      \/* Processing 4 byte unicode sequence (even if it is\n       * after a backslash). Always converted to two 3 byte\n       * long sequence. *\/\n      lit_four_byte_utf8_char_to_cesu8 (destination_p, source_p);\n\n      destination_p += 6;\n      source_p += 4;\n      continue;\n    }\n\n    *destination_p++ = *source_p++;\n\n    \/* There is no need to check the source_end_p\n     * since the string is terminated by a quotation mark. *\/\n    while (IS_UTF8_INTERMEDIATE_OCTET (*source_p))\n    {\n      *destination_p++ = *source_p++;\n    }\n  }\n\n  JERRY_ASSERT (destination_p == destination_start_p + literal_p->length);\n\n  return destination_start_p;\n} \/* lexer_convert_literal_to_chars *\/","target":0,"code_token_length":1702,"total_token_length":1938,"max_tokens_setting":2048}
+{"idx":413586,"func":"static void hint_node_print(HintNode *node, int mode, PJ *pj) {\n\tswitch (mode) {\n\tcase '*':\n#define HINTCMD_ADDR(hint,fmt,x) r_cons_printf (fmt\" @ 0x%\"PFMT64x\"\\n\", x, (hint)->addr)\n\t\tswitch (node->type) {\n\t\tcase HINT_NODE_ADDR: {\n\t\t\tconst RAnalAddrHintRecord *record;\n\t\t\tr_vector_foreach (node->addr_hints, record) {\n\t\t\t\tswitch (record->type) {\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_IMMBASE:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahi %d\", record->immbase);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_JUMP:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahc 0x%\"PFMT64x, record->jump);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_FAIL:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahf 0x%\"PFMT64x, record->fail);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_STACKFRAME:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahF 0x%\"PFMT64x, record->stackframe);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_PTR:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahp 0x%\"PFMT64x, record->ptr);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_NWORD:\n\t\t\t\t\t\/\/ no command for this\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_RET:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahr 0x%\"PFMT64x, record->retval);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_NEW_BITS:\n\t\t\t\t\t\/\/ no command for this\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_SIZE:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahs 0x%\"PFMT64x, record->size);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_SYNTAX:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahS %s\", record->syntax); \/\/ TODO: escape for newcmd\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_OPTYPE: {\n\t\t\t\t\tconst char *type = r_anal_optype_to_string (record->optype);\n\t\t\t\t\tif (type) {\n\t\t\t\t\t\tHINTCMD_ADDR (node, \"aho %s\", type); \/\/ TODO: escape for newcmd\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_OPCODE:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahd %s\", record->opcode);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:\n\t\t\t\t\tHINTCMD_ADDR (node, \"aht %s\", record->type_offset); \/\/ TODO: escape for newcmd\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_ESIL:\n\t\t\t\t\tHINTCMD_ADDR (node, \"ahe %s\", record->esil); \/\/ TODO: escape for newcmd\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_HIGH:\n\t\t\t\t\tr_cons_printf (\"ahh @ 0x%\"PFMT64x\"\\n\", node->addr);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_VAL:\n\t\t\t\t\t\/\/ no command for this\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase HINT_NODE_ARCH:\n\t\t\tHINTCMD_ADDR (node, \"aha %s\", r_str_get_fail (node->arch, \"0\"));\n\t\t\tbreak;\n\t\tcase HINT_NODE_BITS:\n\t\t\tHINTCMD_ADDR (node, \"ahb %d\", node->bits);\n\t\t\tbreak;\n\t\t}\n#undef HINTCMD_ADDR\n\t\tbreak;\n\tcase 'j':\n\t\tswitch (node->type) {\n\t\tcase HINT_NODE_ADDR: {\n\t\t\tconst RAnalAddrHintRecord *record;\n\t\t\tr_vector_foreach (node->addr_hints, record) {\n\t\t\t\tswitch (record->type) {\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_IMMBASE:\n\t\t\t\t\tpj_ki (pj, \"immbase\", record->immbase);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_JUMP:\n\t\t\t\t\tpj_kn (pj, \"jump\", record->jump);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_FAIL:\n\t\t\t\t\tpj_kn (pj, \"fail\", record->fail);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_STACKFRAME:\n\t\t\t\t\tpj_kn (pj, \"stackframe\", record->stackframe);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_PTR:\n\t\t\t\t\tpj_kn (pj, \"ptr\", record->ptr);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_NWORD:\n\t\t\t\t\tpj_ki (pj, \"nword\", record->nword);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_RET:\n\t\t\t\t\tpj_kn (pj, \"ret\", record->retval);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_NEW_BITS:\n\t\t\t\t\tpj_ki (pj, \"newbits\", record->newbits);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_SIZE:\n\t\t\t\t\tpj_kn (pj, \"size\", record->size);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_SYNTAX:\n\t\t\t\t\tpj_ks (pj, \"syntax\", record->syntax);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_OPTYPE: {\n\t\t\t\t\tconst char *type = r_anal_optype_to_string (record->optype);\n\t\t\t\t\tif (type) {\n\t\t\t\t\t\tpj_ks (pj, \"type\", type);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_OPCODE:\n\t\t\t\t\tpj_ks (pj, \"opcode\", record->opcode);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:\n\t\t\t\t\tpj_ks (pj, \"offset\", record->type_offset);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_ESIL:\n\t\t\t\t\tpj_ks (pj, \"esil\", record->esil);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_HIGH:\n\t\t\t\t\tpj_kb (pj, \"high\", true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_ADDR_HINT_TYPE_VAL:\n\t\t\t\t\tpj_kn (pj, \"val\", record->val);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase HINT_NODE_ARCH:\n\t\t\tif (node->arch) {\n\t\t\t\tpj_ks (pj, \"arch\", node->arch);\n\t\t\t} else {\n\t\t\t\tpj_knull (pj, \"arch\");\n\t\t\t}\n\t\t\tbreak;\n\t\tcase HINT_NODE_BITS:\n\t\t\tpj_ki (pj, \"bits\", node->bits);\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tprint_hint_h_format (node);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":1416,"total_token_length":1652,"max_tokens_setting":2048}
+{"idx":328911,"func":"R_API void r_bin_java_print_element_value_summary(RBinJavaElementValue *element_value) {\n\tRBinJavaCPTypeObj *obj;\n\tRBinJavaElementValue *ev_element = NULL;\n\tRListIter *iter = NULL, *iter_tmp = NULL;\n\tchar *name;\n\tif (!element_value) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaElementValuePair *pair.\\n\");\n\t\treturn;\n\t}\n\tname = ((RBinJavaElementValueMetas *) element_value->metas->type_info)->name;\n\teprintf (\"Element Value information:\\n\");\n\teprintf (\"   EV Pair File Offset: 0x%08\"PFMT64x \"\\n\", element_value->file_offset);\n\teprintf (\"   EV Value Type (%d): %s\\n\", element_value->tag, name);\n\tswitch (element_value->tag) {\n\tcase R_BIN_JAVA_EV_TAG_BYTE:\n\tcase R_BIN_JAVA_EV_TAG_CHAR:\n\tcase R_BIN_JAVA_EV_TAG_DOUBLE:\n\tcase R_BIN_JAVA_EV_TAG_FLOAT:\n\tcase R_BIN_JAVA_EV_TAG_INT:\n\tcase R_BIN_JAVA_EV_TAG_LONG:\n\tcase R_BIN_JAVA_EV_TAG_SHORT:\n\tcase R_BIN_JAVA_EV_TAG_BOOLEAN:\n\tcase R_BIN_JAVA_EV_TAG_STRING:\n\t\teprintf (\"   EV Value Constant Value index: 0x%02x\\n\", element_value->value.const_value.const_value_idx);\n\t\teprintf (\"   EV Value Constant Value Information:\\n\");\n\t\tobj = element_value->value.const_value.const_value_cp_obj;\n\t\tif (obj && obj->metas && obj->metas->type_info) {\n\t\t\t((RBinJavaCPTypeMetas *) obj->metas->type_info)->allocs->print_summary (obj);\n\t\t}\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ENUM:\n\t\teprintf (\"   EV Value Enum Constant Value Const Name Index: 0x%02x\\n\", element_value->value.enum_const_value.const_name_idx);\n\t\teprintf (\"   EV Value Enum Constant Value Type Name Index: 0x%02x\\n\", element_value->value.enum_const_value.type_name_idx);\n\t\teprintf (\"   EV Value Enum Constant Value Const CP Information:\\n\");\n\t\tobj = element_value->value.enum_const_value.const_name_cp_obj;\n\t\tif (obj && obj->metas && obj->metas->type_info) {\n\t\t\t((RBinJavaCPTypeMetas *) obj->metas->type_info)->allocs->print_summary (obj);\n\t\t}\n\t\teprintf (\"   EV Value Enum Constant Value Type CP Information:\\n\");\n\t\tobj = element_value->value.enum_const_value.type_name_cp_obj;\n\t\tif (obj && obj->metas && obj->metas->type_info) {\n\t\t\t((RBinJavaCPTypeMetas *) obj->metas->type_info)->allocs->print_summary (obj);\n\t\t}\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_CLASS:\n\t\teprintf (\"   EV Value Class Info Index: 0x%02x\\n\", element_value->value.class_value.class_info_idx);\n\t\teprintf (\"   EV Value Class Info CP Information:\\n\");\n\t\tobj = element_value->value.class_value.class_info_cp_obj;\n\t\tif (obj && obj->metas && obj->metas->type_info) {\n\t\t\t((RBinJavaCPTypeMetas *) obj->metas->type_info)->allocs->print_summary (obj);\n\t\t}\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ARRAY:\n\t\teprintf (\"   EV Value Array Value Number of Values: 0x%04x\\n\", element_value->value.array_value.num_values);\n\t\teprintf (\"   EV Value Array Values\\n\");\n\t\tr_list_foreach_safe (element_value->value.array_value.values, iter, iter_tmp, ev_element) {\n\t\t\tr_bin_java_print_element_value_summary (ev_element);\n\t\t}\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ANNOTATION:\n\t\teprintf (\"   EV Annotation Information:\\n\");\n\t\tr_bin_java_print_annotation_summary (&element_value->value.annotation_value);\n\t\tbreak;\n\tdefault:\n\t\t\/\/ eprintf unable to handle tag\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":878,"total_token_length":1114,"max_tokens_setting":2048}
+{"idx":206815,"func":"static MagickBooleanType SetGrayscaleImage(Image *image,\n  ExceptionInfo *exception)\n{\n  CacheView\n    *image_view;\n\n  MagickBooleanType\n    status;\n\n  PixelInfo\n    *colormap;\n\n  register ssize_t\n    i;\n\n  ssize_t\n    *colormap_index,\n    j,\n    y;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->type != GrayscaleType)\n    (void) TransformImageColorspace(image,GRAYColorspace,exception);\n  if (image->storage_class == PseudoClass)\n    colormap_index=(ssize_t *) AcquireQuantumMemory(image->colors+1,\n      sizeof(*colormap_index));\n  else\n    colormap_index=(ssize_t *) AcquireQuantumMemory(MaxColormapSize+1,\n      sizeof(*colormap_index));\n  if (colormap_index == (ssize_t *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  if (image->storage_class != PseudoClass)\n    {\n      (void) memset(colormap_index,(-1),MaxColormapSize*\n        sizeof(*colormap_index));\n      if (AcquireImageColormap(image,MaxColormapSize,exception) == MagickFalse)\n        {\n          colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);\n          ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n            image->filename);\n        }\n      image->colors=0;\n      status=MagickTrue;\n      image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n      #pragma omp parallel for schedule(static) shared(status) \\\n        magick_number_threads(image,image,image->rows,1)\n#endif\n      for (y=0; y < (ssize_t) image->rows; y++)\n      {\n        register Quantum\n          *magick_restrict q;\n\n        register ssize_t\n          x;\n\n        if (status == MagickFalse)\n          continue;\n        q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,\n          exception);\n        if (q == (Quantum *) NULL)\n          {\n            status=MagickFalse;\n            continue;\n          }\n        for (x=0; x < (ssize_t) image->columns; x++)\n        {\n          register size_t\n            intensity;\n\n          intensity=ScaleQuantumToMap(GetPixelRed(image,q));\n          if (colormap_index[intensity] < 0)\n            {\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n              #pragma omp critical (MagickCore_SetGrayscaleImage)\n#endif\n              if (colormap_index[intensity] < 0)\n                {\n                  colormap_index[intensity]=(ssize_t) image->colors;\n                  image->colormap[image->colors].red=(double)\n                    GetPixelRed(image,q);\n                  image->colormap[image->colors].green=(double)\n                    GetPixelGreen(image,q);\n                  image->colormap[image->colors].blue=(double)\n                    GetPixelBlue(image,q);\n                  image->colors++;\n               }\n            }\n          SetPixelIndex(image,(Quantum) colormap_index[intensity],q);\n          q+=GetPixelChannels(image);\n        }\n        if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n          status=MagickFalse;\n      }\n      image_view=DestroyCacheView(image_view);\n    }\n  for (i=0; i < (ssize_t) image->colors; i++)\n    image->colormap[i].alpha=(double) i;\n  qsort((void *) image->colormap,image->colors,sizeof(PixelInfo),\n    IntensityCompare);\n  colormap=(PixelInfo *) AcquireQuantumMemory(image->colors,sizeof(*colormap));\n  if (colormap == (PixelInfo *) NULL)\n    {\n      colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);\n      ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n        image->filename);\n    }\n  j=0;\n  colormap[j]=image->colormap[0];\n  for (i=0; i < (ssize_t) image->colors; i++)\n  {\n    if (IsPixelInfoEquivalent(&colormap[j],&image->colormap[i]) == MagickFalse)\n      {\n        j++;\n        colormap[j]=image->colormap[i];\n      }\n    colormap_index[(ssize_t) image->colormap[i].alpha]=j;\n  }\n  image->colors=(size_t) (j+1);\n  image->colormap=(PixelInfo *) RelinquishMagickMemory(image->colormap);\n  image->colormap=colormap;\n  status=MagickTrue;\n  image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n  #pragma omp parallel for schedule(static) shared(status) \\\n    magick_number_threads(image,image,image->rows,1)\n#endif\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    register Quantum\n      *magick_restrict q;\n\n    register ssize_t\n      x;\n\n    if (status == MagickFalse)\n      continue;\n    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      {\n        status=MagickFalse;\n        continue;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      SetPixelIndex(image,(Quantum) colormap_index[ScaleQuantumToMap(\n        GetPixelIndex(image,q))],q);\n      q+=GetPixelChannels(image);\n    }\n    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n      status=MagickFalse;\n  }\n  image_view=DestroyCacheView(image_view);\n  colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);\n  image->type=GrayscaleType;\n  if (SetImageMonochrome(image,exception) != MagickFalse)\n    image->type=BilevelType;\n  return(status);\n}","target":1,"code_token_length":1288,"total_token_length":1524,"max_tokens_setting":2048}
+{"idx":234807,"func":"static int read_one_dev(struct extent_buffer *leaf,\n\t\t\tstruct btrfs_dev_item *dev_item)\n{\n\tstruct btrfs_fs_info *fs_info = leaf->fs_info;\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tstruct btrfs_device *device;\n\tu64 devid;\n\tint ret;\n\tu8 fs_uuid[BTRFS_FSID_SIZE];\n\tu8 dev_uuid[BTRFS_UUID_SIZE];\n\n\tdevid = btrfs_device_id(leaf, dev_item);\n\tread_extent_buffer(leaf, dev_uuid, btrfs_device_uuid(dev_item),\n\t\t\t   BTRFS_UUID_SIZE);\n\tread_extent_buffer(leaf, fs_uuid, btrfs_device_fsid(dev_item),\n\t\t\t   BTRFS_FSID_SIZE);\n\n\tif (memcmp(fs_uuid, fs_devices->metadata_uuid, BTRFS_FSID_SIZE)) {\n\t\tfs_devices = open_seed_devices(fs_info, fs_uuid);\n\t\tif (IS_ERR(fs_devices))\n\t\t\treturn PTR_ERR(fs_devices);\n\t}\n\n\tdevice = btrfs_find_device(fs_info->fs_devices, devid, dev_uuid,\n\t\t\t\t   fs_uuid);\n\tif (!device) {\n\t\tif (!btrfs_test_opt(fs_info, DEGRADED)) {\n\t\t\tbtrfs_report_missing_device(fs_info, devid,\n\t\t\t\t\t\t\tdev_uuid, true);\n\t\t\treturn -ENOENT;\n\t\t}\n\n\t\tdevice = add_missing_dev(fs_devices, devid, dev_uuid);\n\t\tif (IS_ERR(device)) {\n\t\t\tbtrfs_err(fs_info,\n\t\t\t\t\"failed to add missing dev %llu: %ld\",\n\t\t\t\tdevid, PTR_ERR(device));\n\t\t\treturn PTR_ERR(device);\n\t\t}\n\t\tbtrfs_report_missing_device(fs_info, devid, dev_uuid, false);\n\t} else {\n\t\tif (!device->bdev) {\n\t\t\tif (!btrfs_test_opt(fs_info, DEGRADED)) {\n\t\t\t\tbtrfs_report_missing_device(fs_info,\n\t\t\t\t\t\tdevid, dev_uuid, true);\n\t\t\t\treturn -ENOENT;\n\t\t\t}\n\t\t\tbtrfs_report_missing_device(fs_info, devid,\n\t\t\t\t\t\t\tdev_uuid, false);\n\t\t}\n\n\t\tif (!device->bdev &&\n\t\t    !test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) {\n\t\t\t\/*\n\t\t\t * this happens when a device that was properly setup\n\t\t\t * in the device info lists suddenly goes bad.\n\t\t\t * device->bdev is NULL, and so we have to set\n\t\t\t * device->missing to one here\n\t\t\t *\/\n\t\t\tdevice->fs_devices->missing_devices++;\n\t\t\tset_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state);\n\t\t}\n\n\t\t\/* Move the device to its own fs_devices *\/\n\t\tif (device->fs_devices != fs_devices) {\n\t\t\tASSERT(test_bit(BTRFS_DEV_STATE_MISSING,\n\t\t\t\t\t\t\t&device->dev_state));\n\n\t\t\tlist_move(&device->dev_list, &fs_devices->devices);\n\t\t\tdevice->fs_devices->num_devices--;\n\t\t\tfs_devices->num_devices++;\n\n\t\t\tdevice->fs_devices->missing_devices--;\n\t\t\tfs_devices->missing_devices++;\n\n\t\t\tdevice->fs_devices = fs_devices;\n\t\t}\n\t}\n\n\tif (device->fs_devices != fs_info->fs_devices) {\n\t\tBUG_ON(test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state));\n\t\tif (device->generation !=\n\t\t    btrfs_device_generation(leaf, dev_item))\n\t\t\treturn -EINVAL;\n\t}\n\n\tfill_device_from_item(leaf, dev_item, device);\n\tif (device->bdev) {\n\t\tu64 max_total_bytes = i_size_read(device->bdev->bd_inode);\n\n\t\tif (device->total_bytes > max_total_bytes) {\n\t\t\tbtrfs_err(fs_info,\n\t\t\t\"device total_bytes should be at most %llu but found %llu\",\n\t\t\t\t  max_total_bytes, device->total_bytes);\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\tset_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&\n\t   !test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) {\n\t\tdevice->fs_devices->total_rw_bytes += device->total_bytes;\n\t\tatomic64_add(device->total_bytes - device->bytes_used,\n\t\t\t\t&fs_info->free_chunk_space);\n\t}\n\tret = 0;\n\treturn ret;\n}","target":0,"code_token_length":895,"total_token_length":1131,"max_tokens_setting":2048}
+{"idx":508874,"func":"bool st_select_lex::optimize_unflattened_subqueries(bool const_only)\n{\n  SELECT_LEX_UNIT *next_unit= NULL;\n  for (SELECT_LEX_UNIT *un= first_inner_unit();\n       un;\n       un= next_unit ? next_unit : un->next_unit())\n  {\n    Item_subselect *subquery_predicate= un->item;\n    next_unit= NULL;\n\n    if (subquery_predicate)\n    {\n      if (!subquery_predicate->fixed)\n      {\n\t\/*\n\t This subquery was excluded as part of some expression so it is\n\t invisible from all prepared expression.\n       *\/\n\tnext_unit= un->next_unit();\n\tun->exclude_level();\n\tif (next_unit)\n\t  continue;\n\tbreak;\n      }\n      if (subquery_predicate->substype() == Item_subselect::IN_SUBS)\n      {\n        Item_in_subselect *in_subs= (Item_in_subselect*) subquery_predicate;\n        if (in_subs->is_jtbm_merged)\n          continue;\n      }\n\n      if (const_only && !subquery_predicate->const_item())\n      {\n        \/* Skip non-constant subqueries if the caller asked so. *\/\n        continue;\n      }\n\n      bool empty_union_result= true;\n      bool is_correlated_unit= false;\n      bool first= true;\n      bool union_plan_saved= false;\n      \/*\n        If the subquery is a UNION, optimize all the subqueries in the UNION. If\n        there is no UNION, then the loop will execute once for the subquery.\n      *\/\n      for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())\n      {\n        JOIN *inner_join= sl->join;\n        if (first)\n          first= false;\n        else\n        {\n          if (!union_plan_saved)\n          {\n            union_plan_saved= true;\n            if (un->save_union_explain(un->thd->lex->explain))\n              return true; \/* Failure *\/\n          }\n        }\n        if (!inner_join)\n          continue;\n        SELECT_LEX *save_select= un->thd->lex->current_select;\n        ulonglong save_options;\n        int res;\n        \/* We need only 1 row to determine existence *\/\n        un->set_limit(un->global_parameters());\n        un->thd->lex->current_select= sl;\n        save_options= inner_join->select_options;\n        if (options & SELECT_DESCRIBE)\n        {\n          \/* Optimize the subquery in the context of EXPLAIN. *\/\n          sl->set_explain_type(FALSE);\n          sl->options|= SELECT_DESCRIBE;\n          inner_join->select_options|= SELECT_DESCRIBE;\n        }\n        if ((res= inner_join->optimize()))\n          return TRUE;\n        if (!inner_join->cleaned)\n          sl->update_used_tables();\n        sl->update_correlated_cache();\n        is_correlated_unit|= sl->is_correlated;\n        inner_join->select_options= save_options;\n        un->thd->lex->current_select= save_select;\n\n        Explain_query *eq;\n        if ((eq= inner_join->thd->lex->explain))\n        {\n          Explain_select *expl_sel;\n          if ((expl_sel= eq->get_select(inner_join->select_lex->select_number)))\n          {\n            sl->set_explain_type(TRUE);\n            expl_sel->select_type= sl->type;\n          }\n        }\n\n        if (empty_union_result)\n        {\n          \/*\n            If at least one subquery in a union is non-empty, the UNION result\n            is non-empty. If there is no UNION, the only subquery is non-empy.\n          *\/\n          empty_union_result= inner_join->empty_result();\n        }\n        if (res)\n          return TRUE;\n      }\n      if (empty_union_result)\n        subquery_predicate->no_rows_in_result();\n\n      if (is_correlated_unit)\n      {\n        \/*\n          Some parts of UNION are not correlated. This means we will need to\n          re-execute the whole UNION every time. Mark all parts of the UNION\n          as correlated so that they are prepared to be executed multiple\n          times (if we don't do that, some part of the UNION may free its\n          execution data at the end of first execution and crash on the second\n          execution)\n        *\/\n        for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())\n          sl->uncacheable |= UNCACHEABLE_DEPENDENT;\n      }\n      else\n        un->uncacheable&= ~UNCACHEABLE_DEPENDENT;\n      subquery_predicate->is_correlated= is_correlated_unit;\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":971,"total_token_length":1207,"max_tokens_setting":2048}
+{"idx":292163,"func":"void LinkResolver::runtime_resolve_special_method(CallInfo& result,\n                                                  const LinkInfo& link_info,\n                                                  const methodHandle& resolved_method,\n                                                  Handle recv, TRAPS) {\n\n  Klass* resolved_klass = link_info.resolved_klass();\n\n  \/\/ resolved method is selected method unless we have an old-style lookup\n  \/\/ for a superclass method\n  \/\/ Invokespecial for a superinterface, resolved method is selected method,\n  \/\/ no checks for shadowing\n  methodHandle sel_method(THREAD, resolved_method());\n\n  if (link_info.check_access() &&\n      \/\/ check if the method is not <init>\n      resolved_method->name() != vmSymbols::object_initializer_name()) {\n\n     \/\/ check if this is an old-style super call and do a new lookup if so\n     \/\/ a) check if ACC_SUPER flag is set for the current class\n    Klass* current_klass = link_info.current_klass();\n    if ((current_klass->is_super() || !AllowNonVirtualCalls) &&\n        \/\/ b) check if the class of the resolved_klass is a superclass\n        \/\/ (not supertype in order to exclude interface classes) of the current class.\n        \/\/ This check is not performed for super.invoke for interface methods\n        \/\/ in super interfaces.\n        current_klass->is_subclass_of(resolved_klass) &&\n        current_klass != resolved_klass\n        ) {\n      \/\/ Lookup super method\n      Klass* super_klass = current_klass->super();\n      sel_method = lookup_instance_method_in_klasses(super_klass,\n                                                     resolved_method->name(),\n                                                     resolved_method->signature(),\n                                                     Klass::find_private, CHECK);\n      \/\/ check if found\n      if (sel_method.is_null()) {\n        ResourceMark rm(THREAD);\n        stringStream ss;\n        ss.print(\"'\");\n        resolved_method->print_external_name(&ss);\n        ss.print(\"'\");\n        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());\n      \/\/ check loader constraints if found a different method\n      } else if (sel_method() != resolved_method()) {\n        check_method_loader_constraints(link_info, sel_method, \"method\", CHECK);\n      }\n    }\n\n    \/\/ Check that the class of objectref (the receiver) is the current class or interface,\n    \/\/ or a subtype of the current class or interface (the sender), otherwise invokespecial\n    \/\/ throws IllegalAccessError.\n    \/\/ The verifier checks that the sender is a subtype of the class in the I\/MR operand.\n    \/\/ The verifier also checks that the receiver is a subtype of the sender, if the sender is\n    \/\/ a class.  If the sender is an interface, the check has to be performed at runtime.\n    InstanceKlass* sender = InstanceKlass::cast(current_klass);\n    sender = sender->is_anonymous() ? sender->host_klass() : sender;\n    if (sender->is_interface() && recv.not_null()) {\n      Klass* receiver_klass = recv->klass();\n      if (!receiver_klass->is_subtype_of(sender)) {\n        ResourceMark rm(THREAD);\n        char buf[500];\n        jio_snprintf(buf, sizeof(buf),\n                     \"Receiver class %s must be the current class or a subtype of interface %s\",\n                     receiver_klass->external_name(),\n                     sender->external_name());\n        THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);\n      }\n    }\n  }\n\n  \/\/ check if not static\n  if (sel_method->is_static()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"Expecting non-static method '\");\n    resolved_method->print_external_name(&ss);\n    ss.print(\"'\");\n    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n\n  \/\/ check if abstract\n  if (sel_method->is_abstract()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"'\");\n    Method::print_external_name(&ss, resolved_klass, sel_method->name(), sel_method->signature());\n    ss.print(\"'\");\n    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());\n  }\n\n  if (log_develop_is_enabled(Trace, itables)) {\n    trace_method_resolution(\"invokespecial selected method: resolved-class:\",\n                            resolved_klass, resolved_klass, sel_method, true);\n  }\n\n  \/\/ setup result\n  result.set_static(resolved_klass, sel_method, CHECK);\n}","target":0,"code_token_length":937,"total_token_length":1173,"max_tokens_setting":2048}
+{"idx":221463,"func":"check_parental_controls (FlatpakDecomposed *app_ref,\n                         FlatpakDeploy     *deploy,\n                         GCancellable      *cancellable,\n                         GError           **error)\n{\n#ifdef HAVE_LIBMALCONTENT\n  g_autoptr(MctManager) manager = NULL;\n  g_autoptr(MctAppFilter) app_filter = NULL;\n  g_autoptr(GDBusConnection) system_bus = NULL;\n  g_autoptr(GError) local_error = NULL;\n  g_autoptr(GDesktopAppInfo) app_info = NULL;\n  gboolean allowed = FALSE;\n\n  system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);\n  if (system_bus == NULL)\n    return FALSE;\n\n  manager = mct_manager_new (system_bus);\n  app_filter = mct_manager_get_app_filter (manager, getuid (),\n                                           MCT_GET_APP_FILTER_FLAGS_INTERACTIVE,\n                                           cancellable, &local_error);\n  if (g_error_matches (local_error, MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_DISABLED))\n    {\n      g_debug (\"Skipping parental controls check for %s since parental \"\n               \"controls are disabled globally\", flatpak_decomposed_get_ref (app_ref));\n      return TRUE;\n    }\n  else if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN) ||\n           g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER))\n    {\n      g_debug (\"Skipping parental controls check for %s since a required \"\n               \"service was not found\", flatpak_decomposed_get_ref (app_ref));\n      return TRUE;\n    }\n  else if (local_error != NULL)\n    {\n      g_propagate_error (error, g_steal_pointer (&local_error));\n      return FALSE;\n    }\n\n  \/* Always filter by app ID. Additionally, filter by app info (which runs\n   * multiple checks, including whether the app ID, executable path and\n   * content types are allowed) if available. If the flatpak contains\n   * multiple .desktop files, we use the main one. The app ID check is\n   * always done, as the binary executed by `flatpak run` isn\u2019t necessarily\n   * extracted from a .desktop file. *\/\n  allowed = mct_app_filter_is_flatpak_ref_allowed (app_filter, flatpak_decomposed_get_ref (app_ref));\n\n  \/* Look up the app\u2019s main .desktop file. *\/\n  if (deploy != NULL && allowed)\n    {\n      g_autoptr(GFile) deploy_dir = NULL;\n      const char *deploy_path;\n      g_autofree char *desktop_file_name = NULL;\n      g_autofree char *desktop_file_path = NULL;\n      g_autofree char *app_id = flatpak_decomposed_dup_id (app_ref);\n\n      deploy_dir = flatpak_deploy_get_dir (deploy);\n      deploy_path = flatpak_file_get_path_cached (deploy_dir);\n\n      desktop_file_name = g_strconcat (app_id, \".desktop\", NULL);\n      desktop_file_path = g_build_path (G_DIR_SEPARATOR_S,\n                                        deploy_path,\n                                        \"export\",\n                                        \"share\",\n                                        \"applications\",\n                                        desktop_file_name,\n                                        NULL);\n      app_info = g_desktop_app_info_new_from_filename (desktop_file_path);\n    }\n\n  if (app_info != NULL)\n    allowed = allowed && mct_app_filter_is_appinfo_allowed (app_filter,\n                                                            G_APP_INFO (app_info));\n\n  if (!allowed)\n    return flatpak_fail_error (error, FLATPAK_ERROR_PERMISSION_DENIED,\n                               \/* Translators: The placeholder is for an app ref. *\/\n                               _(\"Running %s is not allowed by the policy set by your administrator\"),\n                               flatpak_decomposed_get_ref (app_ref));\n#endif  \/* HAVE_LIBMALCONTENT *\/\n\n  return TRUE;\n}","target":0,"code_token_length":799,"total_token_length":1035,"max_tokens_setting":2048}
+{"idx":195231,"func":"s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)\n{\n\tu8 idr_flag;\n\ts32 slice, ret;\n\tu32 nal_hdr;\n\tAVCSliceInfo n_state;\n\n\tgf_bs_enable_emulation_byte_removal(bs, GF_TRUE);\n\n\tnal_hdr = gf_bs_read_u8(bs);\n\n\tslice = 0;\n\tmemcpy(&n_state, &avc->s_info, sizeof(AVCSliceInfo));\n\tavc->last_nal_type_parsed = n_state.nal_unit_type = nal_hdr & 0x1F;\n\tn_state.nal_ref_idc = (nal_hdr >> 5) & 0x3;\n\n\tidr_flag = 0;\n\n\tswitch (n_state.nal_unit_type) {\n\tcase GF_AVC_NALU_ACCESS_UNIT:\n\tcase GF_AVC_NALU_END_OF_SEQ:\n\tcase GF_AVC_NALU_END_OF_STREAM:\n\t\tret = 1;\n\t\tbreak;\n\n\tcase GF_AVC_NALU_SVC_SLICE:\n\t\tSVC_ReadNal_header_extension(bs, &n_state.NalHeader);\n\t\t\/\/ slice buffer - read the info and compare.\n\t\t\/*ret = *\/svc_parse_slice(bs, avc, &n_state);\n\t\tif (avc->s_info.nal_ref_idc) {\n\t\t\tn_state.poc_lsb_prev = avc->s_info.poc_lsb;\n\t\t\tn_state.poc_msb_prev = avc->s_info.poc_msb;\n\t\t}\n\t\tavc_compute_poc(&n_state);\n\n\t\tif (avc->s_info.poc != n_state.poc) {\n\t\t\tmemcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));\n\t\t\treturn 1;\n\t\t}\n\t\tmemcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_SVC_PREFIX_NALU:\n\t\tSVC_ReadNal_header_extension(bs, &n_state.NalHeader);\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_IDR_SLICE:\n\tcase GF_AVC_NALU_NON_IDR_SLICE:\n\tcase GF_AVC_NALU_DP_A_SLICE:\n\tcase GF_AVC_NALU_DP_B_SLICE:\n\tcase GF_AVC_NALU_DP_C_SLICE:\n\t\tslice = 1;\n\t\t\/* slice buffer - read the info and compare.*\/\n\t\tret = avc_parse_slice(bs, avc, idr_flag, &n_state);\n\t\tif (ret < 0) return ret;\n\t\tret = 0;\n\t\tif (\n\t\t\t((avc->s_info.nal_unit_type > GF_AVC_NALU_IDR_SLICE) || (avc->s_info.nal_unit_type < GF_AVC_NALU_NON_IDR_SLICE))\n\t\t\t&& (avc->s_info.nal_unit_type != GF_AVC_NALU_SVC_SLICE)\n\t\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tif (avc->s_info.frame_num != n_state.frame_num) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (avc->s_info.field_pic_flag != n_state.field_pic_flag) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif ((avc->s_info.nal_ref_idc != n_state.nal_ref_idc) &&\n\t\t\t(!avc->s_info.nal_ref_idc || !n_state.nal_ref_idc)) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\t\tassert(avc->s_info.sps);\n\n\t\tif (avc->s_info.sps->poc_type == n_state.sps->poc_type) {\n\t\t\tif (!avc->s_info.sps->poc_type) {\n\t\t\t\tif (!n_state.bottom_field_flag && (avc->s_info.poc_lsb != n_state.poc_lsb)) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (avc->s_info.delta_poc_bottom != n_state.delta_poc_bottom) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (avc->s_info.sps->poc_type == 1) {\n\t\t\t\tif (avc->s_info.delta_poc[0] != n_state.delta_poc[0]) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (avc->s_info.delta_poc[1] != n_state.delta_poc[1]) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (n_state.nal_unit_type == GF_AVC_NALU_IDR_SLICE) {\n\t\t\tif (avc->s_info.nal_unit_type != GF_AVC_NALU_IDR_SLICE) { \/*IdrPicFlag differs in value*\/\n\t\t\t\tret = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (avc->s_info.idr_pic_id != n_state.idr_pic_id) { \/*both IDR and idr_pic_id differs*\/\n\t\t\t\tret = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase GF_AVC_NALU_SEQ_PARAM:\n\t\tavc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 0, NULL, nal_hdr);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_PIC_PARAM:\n\t\tavc->last_ps_idx = gf_avc_read_pps_bs_internal(bs, avc, nal_hdr);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\tcase GF_AVC_NALU_SVC_SUBSEQ_PARAM:\n\t\tavc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 1, NULL, nal_hdr);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\tcase GF_AVC_NALU_SEQ_PARAM_EXT:\n\t\tavc->last_ps_idx = (s32) gf_bs_read_ue(bs);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_SEI:\n\tcase GF_AVC_NALU_FILLER_DATA:\n\t\treturn 0;\n\n\tdefault:\n\t\tif (avc->s_info.nal_unit_type <= GF_AVC_NALU_IDR_SLICE) ret = 1;\n\t\t\/\/To detect change of AU when multiple sps and pps in stream\n\t\telse if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEI && avc->s_info.nal_unit_type == GF_AVC_NALU_SVC_SLICE)\n\t\t\tret = 1;\n\t\telse if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEQ_PARAM && avc->s_info.nal_unit_type == GF_AVC_NALU_SVC_SLICE)\n\t\t\tret = 1;\n\t\telse\n\t\t\tret = 0;\n\t\tbreak;\n\t}\n\n\t\/* save _prev values *\/\n\tif (ret && avc->s_info.sps) {\n\t\tn_state.frame_num_offset_prev = avc->s_info.frame_num_offset;\n\t\tif ((avc->s_info.sps->poc_type != 2) || (avc->s_info.nal_ref_idc != 0))\n\t\t\tn_state.frame_num_prev = avc->s_info.frame_num;\n\t\tif (avc->s_info.nal_ref_idc) {\n\t\t\tn_state.poc_lsb_prev = avc->s_info.poc_lsb;\n\t\t\tn_state.poc_msb_prev = avc->s_info.poc_msb;\n\t\t}\n\t}\n\tif (slice)\n\t\tavc_compute_poc(&n_state);\n\tmemcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));\n\treturn ret;\n}","target":1,"code_token_length":1713,"total_token_length":1949,"max_tokens_setting":2048}
+{"idx":254880,"func":"MONGO_COMPILER_NOINLINE DocumentSource::GetNextResult DocumentSourceGroup::initializeSelf(\n    GetNextResult input) {\n    const size_t numAccumulators = _accumulatedFields.size();\n    \/\/ Barring any pausing, this loop exhausts 'pSource' and populates '_groups'.\n    for (; input.isAdvanced(); input = pSource->getNext()) {\n        if (_memoryTracker.shouldSpillWithAttemptToSaveMemory([this]() { return freeMemory(); })) {\n            _sortedFiles.push_back(spill());\n        }\n\n        \/\/ We release the result document here so that it does not outlive the end of this loop\n        \/\/ iteration. Not releasing could lead to an array copy when this group follows an unwind.\n        auto rootDocument = input.releaseDocument();\n        Value id = computeId(rootDocument);\n\n        \/\/ Look for the _id value in the map. If it's not there, add a new entry with a blank\n        \/\/ accumulator. This is done in a somewhat odd way in order to avoid hashing 'id' and\n        \/\/ looking it up in '_groups' multiple times.\n        const size_t oldSize = _groups->size();\n        vector<intrusive_ptr<AccumulatorState>>& group = (*_groups)[id];\n        const bool inserted = _groups->size() != oldSize;\n\n        if (inserted) {\n            _memoryTracker.memoryUsageBytes += id.getApproximateSize();\n\n            \/\/ Initialize and add the accumulators\n            Value expandedId = expandId(id);\n            Document idDoc =\n                expandedId.getType() == BSONType::Object ? expandedId.getDocument() : Document();\n            group.reserve(numAccumulators);\n            for (auto&& accumulatedField : _accumulatedFields) {\n                auto accum = accumulatedField.makeAccumulator();\n                Value initializerValue =\n                    accumulatedField.expr.initializer->evaluate(idDoc, &pExpCtx->variables);\n                accum->startNewGroup(initializerValue);\n                group.push_back(accum);\n            }\n        } else {\n            for (auto&& groupObj : group) {\n                \/\/ subtract old mem usage. New usage added back after processing.\n                _memoryTracker.memoryUsageBytes -= groupObj->memUsageForSorter();\n            }\n        }\n\n        \/* tickle all the accumulators for the group we found *\/\n        dassert(numAccumulators == group.size());\n\n        for (size_t i = 0; i < numAccumulators; i++) {\n            group[i]->process(\n                _accumulatedFields[i].expr.argument->evaluate(rootDocument, &pExpCtx->variables),\n                _doingMerge);\n\n            _memoryTracker.memoryUsageBytes += group[i]->memUsageForSorter();\n        }\n\n        if (kDebugBuild && !storageGlobalParams.readOnly) {\n            \/\/ In debug mode, spill every time we have a duplicate id to stress merge logic.\n            if (!inserted &&                     \/\/ is a dup\n                !pExpCtx->inMongos &&            \/\/ can't spill to disk in mongos\n                !_memoryTracker.allowDiskUse &&  \/\/ don't change behavior when testing external sort\n                _sortedFiles.size() < 20) {      \/\/ don't open too many FDs\n\n                _sortedFiles.push_back(spill());\n            }\n        }\n    }\n\n    switch (input.getStatus()) {\n        case DocumentSource::GetNextResult::ReturnStatus::kAdvanced: {\n            MONGO_UNREACHABLE;  \/\/ We consumed all advances above.\n        }\n        case DocumentSource::GetNextResult::ReturnStatus::kPauseExecution: {\n            return input;  \/\/ Propagate pause.\n        }\n        case DocumentSource::GetNextResult::ReturnStatus::kEOF: {\n            \/\/ Do any final steps necessary to prepare to output results.\n            if (!_sortedFiles.empty()) {\n                _spilled = true;\n                if (!_groups->empty()) {\n                    _sortedFiles.push_back(spill());\n                }\n\n                \/\/ We won't be using groups again so free its memory.\n                _groups = pExpCtx->getValueComparator().makeUnorderedValueMap<Accumulators>();\n\n                _sorterIterator.reset(Sorter<Value, Value>::Iterator::merge(\n                    _sortedFiles, SortOptions(), SorterComparator(pExpCtx->getValueComparator())));\n\n                \/\/ prepare current to accumulate data\n                _currentAccumulators.reserve(numAccumulators);\n                for (auto&& accumulatedField : _accumulatedFields) {\n                    _currentAccumulators.push_back(accumulatedField.makeAccumulator());\n                }\n\n                verify(_sorterIterator->more());  \/\/ we put data in, we should get something out.\n                _firstPartOfNextGroup = _sorterIterator->next();\n            } else {\n                \/\/ start the group iterator\n                groupsIterator = _groups->begin();\n            }\n\n            \/\/ This must happen last so that, unless control gets here, we will re-enter\n            \/\/ initialization after getting a GetNextResult::ResultState::kPauseExecution.\n            _initialized = true;\n            return input;\n        }\n    }\n    MONGO_UNREACHABLE;\n}","target":0,"code_token_length":1057,"total_token_length":1293,"max_tokens_setting":2048}
+{"idx":198117,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Here's the basic idea:\n    \/\/ Batch and depth dimension are independent from row and col dimension. And\n    \/\/ because FractionalAvgPool currently only support pooling along row and\n    \/\/ col, we can basically think of this 4D tensor backpropagation as\n    \/\/ operation of a series of 2D planes.\n    \/\/\n    \/\/ For each element of a 'slice' (2D plane) of output_backprop, we need to\n    \/\/ figure out its contributors when doing FractionalAvgPool operation. This\n    \/\/ can be done based on row_pooling_sequence, col_pooling_seq and\n    \/\/ overlapping.\n    \/\/ Once we figure out the original contributors, we just need to evenly\n    \/\/ divide the value of this element among these contributors.\n    \/\/\n    \/\/ Internally, we divide the out_backprop tensor and store it in a temporary\n    \/\/ tensor of double type. And cast it to the corresponding type.\n    typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        ConstEigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenDoubleMatrixMap;\n\n    \/\/ Grab the inputs.\n    const Tensor& orig_input_tensor_shape = context->input(0);\n    OP_REQUIRES(context,\n                orig_input_tensor_shape.dims() == 1 &&\n                    orig_input_tensor_shape.NumElements() == 4,\n                errors::InvalidArgument(\"original input tensor shape must be\"\n                                        \"1-dimensional and 4 elements\"));\n    const Tensor& out_backprop = context->input(1);\n    const Tensor& row_seq_tensor = context->input(2);\n    const Tensor& col_seq_tensor = context->input(3);\n\n    const int64_t out_batch = out_backprop.dim_size(0);\n    const int64_t out_rows = out_backprop.dim_size(1);\n    const int64_t out_cols = out_backprop.dim_size(2);\n    const int64_t out_depth = out_backprop.dim_size(3);\n\n    OP_REQUIRES(context, row_seq_tensor.NumElements() > out_rows,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", row_seq_tensor must have at least \",\n                                        out_rows + 1, \" elements, but got \",\n                                        row_seq_tensor.NumElements()));\n    OP_REQUIRES(context, col_seq_tensor.NumElements() > out_cols,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", col_seq_tensor must have at least \",\n                                        out_cols + 1, \" elements, but got \",\n                                        col_seq_tensor.NumElements()));\n\n    auto row_seq_tensor_flat = row_seq_tensor.flat<int64>();\n    auto col_seq_tensor_flat = col_seq_tensor.flat<int64>();\n    auto orig_input_tensor_shape_flat = orig_input_tensor_shape.flat<int64>();\n\n    const int64_t in_batch = orig_input_tensor_shape_flat(0);\n    const int64_t in_rows = orig_input_tensor_shape_flat(1);\n    const int64_t in_cols = orig_input_tensor_shape_flat(2);\n    const int64_t in_depth = orig_input_tensor_shape_flat(3);\n\n    constexpr int tensor_in_and_out_dims = 4;\n    \/\/ Transform orig_input_tensor_shape into TensorShape\n    TensorShape in_shape;\n    for (auto i = 0; i < tensor_in_and_out_dims; ++i) {\n      in_shape.AddDim(orig_input_tensor_shape_flat(i));\n    }\n\n    \/\/ Create intermediate in_backprop.\n    Tensor in_backprop_tensor_temp;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(\n                                {0}, DataTypeToEnum<double>::v(), in_shape,\n                                &in_backprop_tensor_temp));\n    in_backprop_tensor_temp.flat<double>().setZero();\n    \/\/ Transform 4D tensor to 2D matrix.\n    EigenDoubleMatrixMap in_backprop_tensor_temp_mat(\n        in_backprop_tensor_temp.flat<double>().data(), in_depth,\n        in_cols * in_rows * in_batch);\n    ConstEigenMatrixMap out_backprop_mat(out_backprop.flat<T>().data(),\n                                         out_depth,\n                                         out_cols * out_rows * out_batch);\n    \/\/ Loop through each element of out_backprop and evenly distribute the\n    \/\/ element to the corresponding pooling cell.\n    const int64_t in_max_row_index = in_rows - 1;\n    const int64_t in_max_col_index = in_cols - 1;\n    for (int64_t b = 0; b < out_batch; ++b) {\n      for (int64_t r = 0; r < out_rows; ++r) {\n        const int64_t in_row_start = row_seq_tensor_flat(r);\n        int64_t in_row_end = overlapping_ ? row_seq_tensor_flat(r + 1)\n                                          : row_seq_tensor_flat(r + 1) - 1;\n        in_row_end = std::min(in_row_end, in_max_row_index);\n        for (int64_t c = 0; c < out_cols; ++c) {\n          const int64_t in_col_start = col_seq_tensor_flat(c);\n          int64_t in_col_end = overlapping_ ? col_seq_tensor_flat(c + 1)\n                                            : col_seq_tensor_flat(c + 1) - 1;\n          in_col_end = std::min(in_col_end, in_max_col_index);\n\n          const int64_t num_elements_in_pooling_cell =\n              (in_row_end - in_row_start + 1) * (in_col_end - in_col_start + 1);\n          const int64_t out_index = (b * out_rows + r) * out_cols + c;\n          \/\/ Now we can evenly distribute out_backprop(b, h, w, *) to\n          \/\/ in_backprop(b, hs:he, ws:we, *).\n          for (int64_t in_r = in_row_start; in_r <= in_row_end; ++in_r) {\n            for (int64_t in_c = in_col_start; in_c <= in_col_end; ++in_c) {\n              const int64_t in_index = (b * in_rows + in_r) * in_cols + in_c;\n              \/\/ Walk through each channel (depth).\n              for (int64_t d = 0; d < out_depth; ++d) {\n                const double out_backprop_element = static_cast<double>(\n                    out_backprop_mat.coeffRef(d, out_index));\n                double& in_backprop_ref =\n                    in_backprop_tensor_temp_mat.coeffRef(d, in_index);\n                in_backprop_ref +=\n                    out_backprop_element \/ num_elements_in_pooling_cell;\n              }\n            }\n          }\n        }\n      }\n    }\n\n    \/\/ Depending on the type, cast double to type T.\n    Tensor* in_backprop_tensor = nullptr;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(\n                                {0}, 0, in_shape, &in_backprop_tensor));\n    auto in_backprop_tensor_flat = in_backprop_tensor->flat<T>();\n    auto in_backprop_tensor_temp_flat = in_backprop_tensor_temp.flat<double>();\n    for (int64_t i = 0; i < in_backprop_tensor_flat.size(); ++i) {\n      in_backprop_tensor_flat(i) =\n          static_cast<T>(in_backprop_tensor_temp_flat(i));\n    }\n  }","target":1,"code_token_length":1579,"total_token_length":1815,"max_tokens_setting":2048}
+{"idx":262027,"func":"ServiceProtoDispatchRequest(ServiceConnection *conn,\n                            ProtoRequest *req)\n{\n   VGAuthError err;\n   gchar *packet;\n\n\n   \/*\n    * Many requests must come across a superUser owned pipe.\n    * Verify that here.\n    *\/\n   err = Proto_SecurityCheckRequest(conn, req);\n   if (err != VGAUTH_E_OK) {\n      Warning(\"%s: security check failed for request type %d\\n\",\n              __FUNCTION__, req->reqType);\n      packet = Proto_MakeErrorReply(conn,\n                                    req,\n                                    err,\n                                    \"Security check failed\");\n      goto sendError;\n   }\n\n#ifdef _WIN32\n   \/*\n    * Check if we need to complete an earlier pid verification\n    *\/\n   if (conn->pidVerifyState == PID_VERIFY_PENDING) {\n      err = ServiceEndVerifyPid(conn);\n      if (err != VGAUTH_E_OK) {\n         VGAUTH_LOG_WARNING(\"ServiceEndVerifyPid() failed, pipe = %s\", conn->pipeName);\n         packet = Proto_MakeErrorReply(conn,\n                                       req,\n                                       err,\n                                       \"Pid verification failed\");\n         goto sendError;\n      }\n   }\n\n   \/*\n    * Check that we have the client proc handle to process the following\n    * requests.\n    *\/\n   switch(req->reqType) {\n   case PROTO_REQUEST_CREATETICKET:\n   case PROTO_REQUEST_VALIDATETICKET:\n   case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:\n      if (conn->hProc == NULL) {\n         VGAUTH_LOG_WARNING(\"Invalid client process HANDLE, possibly missing Connect, \"\n                            \"pipe = %s\", conn->pipeName);\n         err = VGAUTH_E_FAIL;\n         packet = Proto_MakeErrorReply(conn,\n                                       req,\n                                       err,\n                                       \"Client process handle check failed\");\n         goto sendError;\n      }\n\n      break;\n   default:\n      break;\n   }\n#endif\n\n   switch (req->reqType) {\n   case PROTO_REQUEST_SESSION_REQ:\n      err = ServiceProtoHandleSessionRequest(conn, req);\n      break;\n   case PROTO_REQUEST_CONN:\n      err = ServiceProtoHandleConnection(conn, req);\n      break;\n   case PROTO_REQUEST_ADDALIAS:\n      err = ServiceProtoAddAlias(conn, req);\n      break;\n   case PROTO_REQUEST_REMOVEALIAS:\n      err = ServiceProtoRemoveAlias(conn, req);\n      break;\n   case PROTO_REQUEST_QUERYALIASES:\n      err = ServiceProtoQueryAliases(conn, req);\n      break;\n   case PROTO_REQUEST_QUERYMAPPEDALIASES:\n      err = ServiceProtoQueryMappedAliases(conn, req);\n      break;\n   case PROTO_REQUEST_CREATETICKET:\n      err = ServiceProtoCreateTicket(conn, req);\n      break;\n   case PROTO_REQUEST_VALIDATETICKET:\n      err = ServiceProtoValidateTicket(conn, req);\n      break;\n   case PROTO_REQUEST_REVOKETICKET:\n      err = ServiceProtoRevokeTicket(conn, req);\n      break;\n   case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:\n      err = ServiceProtoValidateSamlBearerToken(conn, req);\n      break;\n   default:\n      \/*\n       * Be polite, send an error, and then fail cleanly\n       *\/\n      err = VGAUTH_E_NOTIMPLEMENTED;\n      packet = Proto_MakeErrorReply(conn,\n                                    req,\n                                    err,\n                                    \"Unrecognized request\");\nsendError:\n      \/*\n       * Don't really care if it works since we're about to\n       * shut it down anyways.\n       *\/\n      (void) ServiceNetworkWriteData(conn, strlen(packet), packet);\n      g_free(packet);\n      break;\n   }\n\n   \/\/ 'err' is from ServiceNetworkWriteData(), not from the operation\n   Log(\"%s: processed reqType %d(%s REQ), returning \"\n       VGAUTHERR_FMT64\" on connection %d\\n\", __FUNCTION__,\n       req->reqType, ProtoRequestTypeText(req->reqType), err, conn->connId);\n\n   return err;\n}","target":0,"code_token_length":834,"total_token_length":1070,"max_tokens_setting":2048}
+{"idx":222739,"func":"s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)\n{\n\tu8 idr_flag;\n\ts32 slice, ret;\n\tu32 nal_hdr;\n\tAVCSliceInfo n_state;\n\n\tgf_bs_enable_emulation_byte_removal(bs, GF_TRUE);\n\n\tnal_hdr = gf_bs_read_u8(bs);\n\n\tslice = 0;\n\tmemcpy(&n_state, &avc->s_info, sizeof(AVCSliceInfo));\n\tavc->last_nal_type_parsed = n_state.nal_unit_type = nal_hdr & 0x1F;\n\tn_state.nal_ref_idc = (nal_hdr >> 5) & 0x3;\n\n\tidr_flag = 0;\n\n\tswitch (n_state.nal_unit_type) {\n\tcase GF_AVC_NALU_ACCESS_UNIT:\n\tcase GF_AVC_NALU_END_OF_SEQ:\n\tcase GF_AVC_NALU_END_OF_STREAM:\n\t\tret = 1;\n\t\tbreak;\n\n\tcase GF_AVC_NALU_SVC_SLICE:\n\t\tSVC_ReadNal_header_extension(bs, &n_state.NalHeader);\n\t\t\/\/ slice buffer - read the info and compare.\n\t\t\/*ret = *\/svc_parse_slice(bs, avc, &n_state);\n\t\tif (avc->s_info.nal_ref_idc) {\n\t\t\tn_state.poc_lsb_prev = avc->s_info.poc_lsb;\n\t\t\tn_state.poc_msb_prev = avc->s_info.poc_msb;\n\t\t}\n\t\tavc_compute_poc(&n_state);\n\n\t\tif (avc->s_info.poc != n_state.poc) {\n\t\t\tmemcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));\n\t\t\treturn 1;\n\t\t}\n\t\tmemcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_SVC_PREFIX_NALU:\n\t\tSVC_ReadNal_header_extension(bs, &n_state.NalHeader);\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_IDR_SLICE:\n\tcase GF_AVC_NALU_NON_IDR_SLICE:\n\tcase GF_AVC_NALU_DP_A_SLICE:\n\tcase GF_AVC_NALU_DP_B_SLICE:\n\tcase GF_AVC_NALU_DP_C_SLICE:\n\t\tslice = 1;\n\t\t\/* slice buffer - read the info and compare.*\/\n\t\tret = avc_parse_slice(bs, avc, idr_flag, &n_state);\n\t\tif (ret < 0) return ret;\n\t\tret = 0;\n\t\tif (\n\t\t\t((avc->s_info.nal_unit_type > GF_AVC_NALU_IDR_SLICE) || (avc->s_info.nal_unit_type < GF_AVC_NALU_NON_IDR_SLICE))\n\t\t\t&& (avc->s_info.nal_unit_type != GF_AVC_NALU_SVC_SLICE)\n\t\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tif (avc->s_info.frame_num != n_state.frame_num) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (avc->s_info.field_pic_flag != n_state.field_pic_flag) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif ((avc->s_info.nal_ref_idc != n_state.nal_ref_idc) &&\n\t\t\t(!avc->s_info.nal_ref_idc || !n_state.nal_ref_idc)) {\n\t\t\tret = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif (!avc->s_info.sps)\n\t\t\treturn -1;\n\n\t\tif (avc->s_info.sps->poc_type == n_state.sps->poc_type) {\n\t\t\tif (!avc->s_info.sps->poc_type) {\n\t\t\t\tif (!n_state.bottom_field_flag && (avc->s_info.poc_lsb != n_state.poc_lsb)) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (avc->s_info.delta_poc_bottom != n_state.delta_poc_bottom) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (avc->s_info.sps->poc_type == 1) {\n\t\t\t\tif (avc->s_info.delta_poc[0] != n_state.delta_poc[0]) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (avc->s_info.delta_poc[1] != n_state.delta_poc[1]) {\n\t\t\t\t\tret = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (n_state.nal_unit_type == GF_AVC_NALU_IDR_SLICE) {\n\t\t\tif (avc->s_info.nal_unit_type != GF_AVC_NALU_IDR_SLICE) { \/*IdrPicFlag differs in value*\/\n\t\t\t\tret = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (avc->s_info.idr_pic_id != n_state.idr_pic_id) { \/*both IDR and idr_pic_id differs*\/\n\t\t\t\tret = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase GF_AVC_NALU_SEQ_PARAM:\n\t\tavc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 0, NULL, nal_hdr);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_PIC_PARAM:\n\t\tavc->last_ps_idx = gf_avc_read_pps_bs_internal(bs, avc, nal_hdr);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\tcase GF_AVC_NALU_SVC_SUBSEQ_PARAM:\n\t\tavc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 1, NULL, nal_hdr);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\tcase GF_AVC_NALU_SEQ_PARAM_EXT:\n\t\tavc->last_ps_idx = (s32) gf_bs_read_ue(bs);\n\t\tif (avc->last_ps_idx < 0) return -1;\n\t\treturn 0;\n\n\tcase GF_AVC_NALU_SEI:\n\tcase GF_AVC_NALU_FILLER_DATA:\n\t\treturn 0;\n\n\tdefault:\n\t\tif (avc->s_info.nal_unit_type <= GF_AVC_NALU_IDR_SLICE) ret = 1;\n\t\t\/\/To detect change of AU when multiple sps and pps in stream\n\t\telse if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEI && avc->s_info.nal_unit_type == GF_AVC_NALU_SVC_SLICE)\n\t\t\tret = 1;\n\t\telse if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEQ_PARAM && avc->s_info.nal_unit_type == GF_AVC_NALU_SVC_SLICE)\n\t\t\tret = 1;\n\t\telse\n\t\t\tret = 0;\n\t\tbreak;\n\t}\n\n\t\/* save _prev values *\/\n\tif (ret && avc->s_info.sps) {\n\t\tn_state.frame_num_offset_prev = avc->s_info.frame_num_offset;\n\t\tif ((avc->s_info.sps->poc_type != 2) || (avc->s_info.nal_ref_idc != 0))\n\t\t\tn_state.frame_num_prev = avc->s_info.frame_num;\n\t\tif (avc->s_info.nal_ref_idc) {\n\t\t\tn_state.poc_lsb_prev = avc->s_info.poc_lsb;\n\t\t\tn_state.poc_msb_prev = avc->s_info.poc_msb;\n\t\t}\n\t}\n\tif (slice)\n\t\tavc_compute_poc(&n_state);\n\tmemcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));\n\treturn ret;\n}","target":0,"code_token_length":1719,"total_token_length":1955,"max_tokens_setting":2048}
+{"idx":293501,"func":"gif_initialise_frame_extensions(gif_animation *gif, const int frame)\n{\n        const unsigned char *gif_data, *gif_end;\n        ssize_t gif_bytes;\n        ssize_t block_size;\n\n        \/* Get our buffer position etc.\t*\/\n        gif_data = (const unsigned char *)(gif->gif_data + gif->buffer_position);\n        gif_end = (const unsigned char *)(gif->gif_data + gif->buffer_size);\n\n        \/* Initialise the extensions *\/\n        while (gif_data < gif_end && gif_data[0] == GIF_EXTENSION_INTRODUCER) {\n                ++gif_data;\n                if ((gif_bytes = (gif_end - gif_data)) < 1) {\n                        return GIF_INSUFFICIENT_FRAME_DATA;\n                }\n\n                \/* Switch on extension label *\/\n                switch (gif_data[0]) {\n                case GIF_EXTENSION_GRAPHIC_CONTROL:\n                        \/* 6-byte Graphic Control Extension is:\n                         *\n                         *\t+0\tCHAR\tGraphic Control Label\n                         *\t+1\tCHAR\tBlock Size\n                         *\t+2\tCHAR\t__Packed Fields__\n                         *\t\t\t3BITS\tReserved\n                         *\t\t\t3BITS\tDisposal Method\n                         *\t\t\t1BIT\tUser Input Flag\n                         *\t\t\t1BIT\tTransparent Color Flag\n                         *\t+3\tSHORT\tDelay Time\n                         *\t+5\tCHAR\tTransparent Color Index\n                         *\/\n                        if (gif_bytes < 6) {\n                                return GIF_INSUFFICIENT_FRAME_DATA;\n                        }\n\n                        gif->frames[frame].frame_delay = gif_data[3] | (gif_data[4] << 8);\n                        if (gif_data[2] & GIF_TRANSPARENCY_MASK) {\n                                gif->frames[frame].transparency = true;\n                                gif->frames[frame].transparency_index = gif_data[5];\n                        }\n                        gif->frames[frame].disposal_method = ((gif_data[2] & GIF_DISPOSAL_MASK) >> 2);\n                        \/* I have encountered documentation and GIFs in the\n                         * wild that use 0x04 to restore the previous frame,\n                         * rather than the officially documented 0x03.  I\n                         * believe some (older?)  software may even actually\n                         * export this way.  We handle this as a type of\n                         * \"quirks\" mode.\n                         *\/\n                        if (gif->frames[frame].disposal_method == GIF_FRAME_QUIRKS_RESTORE) {\n                                gif->frames[frame].disposal_method = GIF_FRAME_RESTORE;\n                        }\n                        gif_data += (2 + gif_data[1]);\n                        break;\n\n                case GIF_EXTENSION_APPLICATION:\n                        \/* 14-byte+ Application Extension is:\n                         *\n                         *\t+0    CHAR    Application Extension Label\n                         *\t+1    CHAR    Block Size\n                         *\t+2    8CHARS  Application Identifier\n                         *\t+10   3CHARS  Appl. Authentication Code\n                         *\t+13   1-256   Application Data (Data sub-blocks)\n                         *\/\n                        if (gif_bytes < 17) {\n                                return GIF_INSUFFICIENT_FRAME_DATA;\n                        }\n                        if ((gif_data[1] == 0x0b) &&\n                            (strncmp((const char *) gif_data + 2,\n                                     \"NETSCAPE2.0\", 11) == 0) &&\n                            (gif_data[13] == 0x03) &&\n                            (gif_data[14] == 0x01)) {\n                                gif->loop_count = gif_data[15] | (gif_data[16] << 8);\n                        }\n                        gif_data += (2 + gif_data[1]);\n                        break;\n\n                case GIF_EXTENSION_COMMENT:\n                        \/* Move the pointer to the first data sub-block Skip 1\n                         * byte for the extension label\n                         *\/\n                        ++gif_data;\n                        break;\n\n                default:\n                        \/* Move the pointer to the first data sub-block Skip 2\n                         * bytes for the extension label and size fields Skip\n                         * the extension size itself\n                         *\/\n                        if (gif_bytes < 2) {\n                                return GIF_INSUFFICIENT_FRAME_DATA;\n                        }\n                        gif_data += (2 + gif_data[1]);\n                }\n\n                \/* Repeatedly skip blocks until we get a zero block or run out\n                 * of data This data is ignored by this gif decoder\n                 *\/\n                gif_bytes = (gif_end - gif_data);\n                block_size = 0;\n                while (gif_data < gif_end && gif_data[0] != GIF_BLOCK_TERMINATOR) {\n                        block_size = gif_data[0] + 1;\n                        if ((gif_bytes -= block_size) < 0) {\n                                return GIF_INSUFFICIENT_FRAME_DATA;\n                        }\n                        gif_data += block_size;\n                }\n                ++gif_data;\n        }\n\n        \/* Set buffer position and return *\/\n        gif->buffer_position = (gif_data - gif->gif_data);\n        return GIF_OK;\n}","target":0,"code_token_length":1049,"total_token_length":1285,"max_tokens_setting":2048}
+{"idx":278261,"func":"get_breakindent_win(\n    win_T\t*wp,\n    char_u\t*line) \/\/ start of the line\n{\n    static int\t    prev_indent = 0;\t\/\/ cached indent value\n    static long\t    prev_ts     = 0L;\t\/\/ cached tabstop value\n    static char_u   *prev_line = NULL;\t\/\/ cached pointer to line\n    static varnumber_T prev_tick = 0;   \/\/ changedtick of cached value\n# ifdef FEAT_VARTABS\n    static int      *prev_vts = NULL;   \/\/ cached vartabs values\n# endif\n    static int      prev_list = 0;\t\/\/ cached list value\n    static int      prev_listopt = 0;\t\/\/ cached w_p_briopt_list value\n    \/\/ cached formatlistpat value\n    static char_u   *prev_flp = NULL;\n    int\t\t    bri = 0;\n    \/\/ window width minus window margin space, i.e. what rests for text\n    const int\t    eff_wwidth = wp->w_width\n\t\t\t    - ((wp->w_p_nu || wp->w_p_rnu)\n\t\t\t\t&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)\n\t\t\t\t\t\t? number_width(wp) + 1 : 0);\n\n    \/\/ used cached indent, unless\n    \/\/ - line pointer changed\n    \/\/ - 'tabstop' changed\n    \/\/ - 'briopt_list changed' changed or\n    \/\/ - 'formatlistpattern' changed\n    if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts\n\t    || prev_tick != CHANGEDTICK(wp->w_buffer)\n\t    || prev_listopt != wp->w_briopt_list\n\t    || (prev_flp == NULL\n\t\t|| (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))\n# ifdef FEAT_VARTABS\n\t    || prev_vts != wp->w_buffer->b_p_vts_array\n# endif\n\t)\n    {\n\tprev_line = line;\n\tprev_ts = wp->w_buffer->b_p_ts;\n\tprev_tick = CHANGEDTICK(wp->w_buffer);\n# ifdef FEAT_VARTABS\n\tprev_vts = wp->w_buffer->b_p_vts_array;\n\tif (wp->w_briopt_vcol == 0)\n\t    prev_indent = get_indent_str_vtab(line,\n\t\t\t\t     (int)wp->w_buffer->b_p_ts,\n\t\t\t\t    wp->w_buffer->b_p_vts_array, wp->w_p_list);\n# else\n\tif (wp->w_briopt_vcol == 0)\n\t    prev_indent = get_indent_str(line,\n\t\t\t\t     (int)wp->w_buffer->b_p_ts, wp->w_p_list);\n# endif\n\tprev_listopt = wp->w_briopt_list;\n\tprev_list = 0;\n\tvim_free(prev_flp);\n\tprev_flp = vim_strsave(get_flp_value(wp->w_buffer));\n\t\/\/ add additional indent for numbered lists\n\tif (wp->w_briopt_list != 0 && wp->w_briopt_vcol == 0)\n\t{\n\t    regmatch_T\t    regmatch;\n\n\t    regmatch.regprog = vim_regcomp(prev_flp,\n\t\t\t\t   RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT);\n\n\t    if (regmatch.regprog != NULL)\n\t    {\n\t\tregmatch.rm_ic = FALSE;\n\t\tif (vim_regexec(®match, line, 0))\n\t\t{\n\t\t    if (wp->w_briopt_list > 0)\n\t\t\tprev_list = wp->w_briopt_list;\n\t\t    else\n\t\t\tprev_list = (*regmatch.endp - *regmatch.startp);\n\t\t}\n\t\tvim_regfree(regmatch.regprog);\n\t    }\n\t}\n    }\n    if (wp->w_briopt_vcol != 0)\n    {\n\t\/\/ column value has priority\n\tbri = wp->w_briopt_vcol;\n\tprev_list = 0;\n    }\n    else\n\tbri = prev_indent + wp->w_briopt_shift;\n\n    \/\/ Add offset for number column, if 'n' is in 'cpoptions'\n    bri += win_col_off2(wp);\n\n    \/\/ add additional indent for numbered lists\n    if (wp->w_briopt_list != 0)\n    {\n\tif (wp->w_briopt_list > 0)\n\t    bri += prev_list;\n\telse\n\t    bri = prev_list;\n    }\n\n    \/\/ indent minus the length of the showbreak string\n    if (wp->w_briopt_sbr)\n\tbri -= vim_strsize(get_showbreak_value(wp));\n\n\n    \/\/ never indent past left window margin\n    if (bri < 0)\n\tbri = 0;\n\n    \/\/ always leave at least bri_min characters on the left,\n    \/\/ if text width is sufficient\n    else if (bri > eff_wwidth - wp->w_briopt_min)\n\tbri = (eff_wwidth - wp->w_briopt_min < 0)\n\t\t\t\t\t   ? 0 : eff_wwidth - wp->w_briopt_min;\n\n    return bri;\n}","target":0,"code_token_length":1090,"total_token_length":1326,"max_tokens_setting":2048}
+{"idx":215122,"func":"getvcol(\n    win_T\t*wp,\n    pos_T\t*pos,\n    colnr_T\t*start,\n    colnr_T\t*cursor,\n    colnr_T\t*end)\n{\n    colnr_T\tvcol;\n    char_u\t*ptr;\t\t\/\/ points to current char\n    char_u\t*posptr;\t\/\/ points to char at pos->col\n    char_u\t*line;\t\t\/\/ start of the line\n    int\t\tincr;\n    int\t\thead;\n#ifdef FEAT_VARTABS\n    int\t\t*vts = wp->w_buffer->b_p_vts_array;\n#endif\n    int\t\tts = wp->w_buffer->b_p_ts;\n    int\t\tc;\n\n    vcol = 0;\n    line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);\n    if (pos->col == MAXCOL)\n\tposptr = NULL;  \/\/ continue until the NUL\n    else\n    {\n\t\/\/ Special check for an empty line, which can happen on exit, when\n\t\/\/ ml_get_buf() always returns an empty string.\n\tif (*ptr == NUL)\n\t    pos->col = 0;\n\tposptr = ptr + pos->col;\n\tif (has_mbyte)\n\t    \/\/ always start on the first byte\n\t    posptr -= (*mb_head_off)(line, posptr);\n    }\n\n    \/*\n     * This function is used very often, do some speed optimizations.\n     * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set\n     * use a simple loop.\n     * Also use this when 'list' is set but tabs take their normal size.\n     *\/\n    if ((!wp->w_p_list || wp->w_lcs_chars.tab1 != NUL)\n#ifdef FEAT_LINEBREAK\n\t    && !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri\n#endif\n       )\n    {\n\tfor (;;)\n\t{\n\t    head = 0;\n\t    c = *ptr;\n\t    \/\/ make sure we don't go past the end of the line\n\t    if (c == NUL)\n\t    {\n\t\tincr = 1;\t\/\/ NUL at end of line only takes one column\n\t\tbreak;\n\t    }\n\t    \/\/ A tab gets expanded, depending on the current column\n\t    if (c == TAB)\n#ifdef FEAT_VARTABS\n\t\tincr = tabstop_padding(vcol, ts, vts);\n#else\n\t\tincr = ts - (vcol % ts);\n#endif\n\t    else\n\t    {\n\t\tif (has_mbyte)\n\t\t{\n\t\t    \/\/ For utf-8, if the byte is >= 0x80, need to look at\n\t\t    \/\/ further bytes to find the cell width.\n\t\t    if (enc_utf8 && c >= 0x80)\n\t\t\tincr = utf_ptr2cells(ptr);\n\t\t    else\n\t\t\tincr = g_chartab[c] & CT_CELL_MASK;\n\n\t\t    \/\/ If a double-cell char doesn't fit at the end of a line\n\t\t    \/\/ it wraps to the next line, it's like this char is three\n\t\t    \/\/ cells wide.\n\t\t    if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1\n\t\t\t    && in_win_border(wp, vcol))\n\t\t    {\n\t\t\t++incr;\n\t\t\thead = 1;\n\t\t    }\n\t\t}\n\t\telse\n\t\t    incr = g_chartab[c] & CT_CELL_MASK;\n\t    }\n\n\t    if (posptr != NULL && ptr >= posptr) \/\/ character at pos->col\n\t\tbreak;\n\n\t    vcol += incr;\n\t    MB_PTR_ADV(ptr);\n\t}\n    }\n    else\n    {\n\tfor (;;)\n\t{\n\t    \/\/ A tab gets expanded, depending on the current column\n\t    head = 0;\n\t    incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);\n\t    \/\/ make sure we don't go past the end of the line\n\t    if (*ptr == NUL)\n\t    {\n\t\tincr = 1;\t\/\/ NUL at end of line only takes one column\n\t\tbreak;\n\t    }\n\n\t    if (posptr != NULL && ptr >= posptr) \/\/ character at pos->col\n\t\tbreak;\n\n\t    vcol += incr;\n\t    MB_PTR_ADV(ptr);\n\t}\n    }\n    if (start != NULL)\n\t*start = vcol + head;\n    if (end != NULL)\n\t*end = vcol + incr - 1;\n    if (cursor != NULL)\n    {\n\tif (*ptr == TAB\n\t\t&& (State & NORMAL)\n\t\t&& !wp->w_p_list\n\t\t&& !virtual_active()\n\t\t&& !(VIsual_active\n\t\t\t\t&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))\n\t\t)\n\t    *cursor = vcol + incr - 1;\t    \/\/ cursor at end\n\telse\n\t    *cursor = vcol + head;\t    \/\/ cursor at start\n    }\n}","target":1,"code_token_length":1072,"total_token_length":1308,"max_tokens_setting":2048}
+{"idx":231053,"func":"BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,\r\n                                     const void * const pvItemToQueue,\r\n                                     BaseType_t * const pxHigherPriorityTaskWoken,\r\n                                     const BaseType_t xCopyPosition )\r\n{\r\n    BaseType_t xReturn;\r\n    UBaseType_t uxSavedInterruptStatus;\r\n    Queue_t * const pxQueue = xQueue;\r\n\r\n    configASSERT( pxQueue );\r\n    configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r\n    configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r\n\r\n    \/* RTOS ports that support interrupt nesting have the concept of a maximum\r\n     * system call (or maximum API call) interrupt priority.  Interrupts that are\r\n     * above the maximum system call priority are kept permanently enabled, even\r\n     * when the RTOS kernel is in a critical section, but cannot make any calls to\r\n     * FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r\n     * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r\n     * failure if a FreeRTOS API function is called from an interrupt that has been\r\n     * assigned a priority above the configured maximum system call priority.\r\n     * Only FreeRTOS functions that end in FromISR can be called from interrupts\r\n     * that have been assigned a priority at or (logically) below the maximum\r\n     * system call interrupt priority.  FreeRTOS maintains a separate interrupt\r\n     * safe API to ensure interrupt entry is as fast and as simple as possible.\r\n     * More information (albeit Cortex-M specific) is provided on the following\r\n     * link: https:\/\/www.FreeRTOS.org\/RTOS-Cortex-M3-M4.html *\/\r\n    portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r\n\r\n    \/* Similar to xQueueGenericSend, except without blocking if there is no room\r\n     * in the queue.  Also don't directly wake a task that was blocked on a queue\r\n     * read, instead return a flag to say whether a context switch is required or\r\n     * not (i.e. has a task with a higher priority than us been woken by this\r\n     * post). *\/\r\n    uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r\n    {\r\n        if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r\n        {\r\n            const int8_t cTxLock = pxQueue->cTxLock;\r\n            const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;\r\n\r\n            traceQUEUE_SEND_FROM_ISR( pxQueue );\r\n\r\n            \/* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a\r\n             *  semaphore or mutex.  That means prvCopyDataToQueue() cannot result\r\n             *  in a task disinheriting a priority and prvCopyDataToQueue() can be\r\n             *  called here even though the disinherit function does not check if\r\n             *  the scheduler is suspended before accessing the ready lists. *\/\r\n            ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r\n\r\n            \/* The event list is not altered if the queue is locked.  This will\r\n             * be done when the queue is unlocked later. *\/\r\n            if( cTxLock == queueUNLOCKED )\r\n            {\r\n                #if ( configUSE_QUEUE_SETS == 1 )\r\n                    {\r\n                        if( pxQueue->pxQueueSetContainer != NULL )\r\n                        {\r\n                            if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )\r\n                            {\r\n                                \/* Do not notify the queue set as an existing item\r\n                                 * was overwritten in the queue so the number of items\r\n                                 * in the queue has not changed. *\/\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                            else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )\r\n                            {\r\n                                \/* The queue is a member of a queue set, and posting\r\n                                 * to the queue set caused a higher priority task to\r\n                                 * unblock.  A context switch is required. *\/\r\n                                if( pxHigherPriorityTaskWoken != NULL )\r\n                                {\r\n                                    *pxHigherPriorityTaskWoken = pdTRUE;\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                        else\r\n                        {\r\n                            if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                            {\r\n                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                                {\r\n                                    \/* The task waiting has a higher priority so\r\n                                     *  record that a context switch is required. *\/\r\n                                    if( pxHigherPriorityTaskWoken != NULL )\r\n                                    {\r\n                                        *pxHigherPriorityTaskWoken = pdTRUE;\r\n                                    }\r\n                                    else\r\n                                    {\r\n                                        mtCOVERAGE_TEST_MARKER();\r\n                                    }\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                    }\r\n                #else \/* configUSE_QUEUE_SETS *\/\r\n                    {\r\n                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                        {\r\n                            if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                            {\r\n                                \/* The task waiting has a higher priority so record that a\r\n                                 * context switch is required. *\/\r\n                                if( pxHigherPriorityTaskWoken != NULL )\r\n                                {\r\n                                    *pxHigherPriorityTaskWoken = pdTRUE;\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                        else\r\n                        {\r\n                            mtCOVERAGE_TEST_MARKER();\r\n                        }\r\n\r\n                        \/* Not used in this path. *\/\r\n                        ( void ) uxPreviousMessagesWaiting;\r\n                    }\r\n                #endif \/* configUSE_QUEUE_SETS *\/\r\n            }\r\n            else\r\n            {\r\n                \/* Increment the lock count so the task that unlocks the queue\r\n                 * knows that data was posted while it was locked. *\/\r\n                configASSERT( cTxLock != queueINT8_MAX );\r\n\r\n                pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 );\r\n            }\r\n\r\n            xReturn = pdPASS;\r\n        }\r\n        else\r\n        {\r\n            traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r\n            xReturn = errQUEUE_FULL;\r\n        }\r\n    }\r\n    portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r\n\r\n    return xReturn;\r\n}\r","target":0,"code_token_length":1421,"total_token_length":1657,"max_tokens_setting":2048}
+{"idx":500689,"func":"int sftp_symlink(sftp_session sftp, const char *target, const char *dest) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  ssh_string target_s;\n  ssh_string dest_s;\n  ssh_buffer buffer;\n  uint32_t id;\n\n  if (sftp == NULL)\n    return -1;\n  if (target == NULL || dest == NULL) {\n    ssh_set_error_invalid(sftp->session, __FUNCTION__);\n    return -1;\n  }\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return -1;\n  }\n\n  target_s = ssh_string_from_char(target);\n  if (target_s == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return -1;\n  }\n\n  dest_s = ssh_string_from_char(dest);\n  if (dest_s == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_string_free(target_s);\n    ssh_buffer_free(buffer);\n    return -1;\n  }\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    ssh_string_free(dest_s);\n    ssh_string_free(target_s);\n    return -1;\n  }\n  if (ssh_get_openssh_version(sftp->session)) {\n    \/* TODO check for version number if they ever fix it. *\/\n    if (buffer_add_ssh_string(buffer, target_s) < 0 ||\n      buffer_add_ssh_string(buffer, dest_s) < 0) {\n      ssh_set_error_oom(sftp->session);\n      ssh_buffer_free(buffer);\n      ssh_string_free(dest_s);\n      ssh_string_free(target_s);\n      return -1;\n    }\n  } else {\n    if (buffer_add_ssh_string(buffer, dest_s) < 0 ||\n      buffer_add_ssh_string(buffer, target_s) < 0) {\n      ssh_set_error_oom(sftp->session);\n      ssh_buffer_free(buffer);\n      ssh_string_free(dest_s);\n      ssh_string_free(target_s);\n      return -1;\n    }\n  }\n\n  if (sftp_packet_write(sftp, SSH_FXP_SYMLINK, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(dest_s);\n    ssh_string_free(target_s);\n    return -1;\n  }\n  ssh_buffer_free(buffer);\n  ssh_string_free(dest_s);\n  ssh_string_free(target_s);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      return -1;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  \/* By specification, this command only returns SSH_FXP_STATUS *\/\n  if (msg->packet_type == SSH_FXP_STATUS) {\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return -1;\n    }\n    sftp_set_error(sftp, status->status);\n    switch (status->status) {\n      case SSH_FX_OK:\n        status_msg_free(status);\n        return 0;\n      default:\n        break;\n    }\n    \/*\n     * The status should be SSH_FX_OK if the command was successful, if it\n     * didn't, then there was an error\n     *\/\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n    return -1;\n  } else {\n    ssh_set_error(sftp->session, SSH_FATAL,\n        \"Received message %d when attempting to set stats\", msg->packet_type);\n    sftp_message_free(msg);\n  }\n\n  return -1;\n}","target":0,"code_token_length":813,"total_token_length":1049,"max_tokens_setting":2048}
+{"idx":253721,"func":"ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)\n{\n\tstruct ccp_rsa_engine *rsa = &cmd->u.rsa;\n\tstruct ccp_dm_workarea exp, src, dst;\n\tstruct ccp_op op;\n\tunsigned int sb_count, i_len, o_len;\n\tint ret;\n\n\t\/* Check against the maximum allowable size, in bits *\/\n\tif (rsa->key_size > cmd_q->ccp->vdata->rsamax)\n\t\treturn -EINVAL;\n\n\tif (!rsa->exp || !rsa->mod || !rsa->src || !rsa->dst)\n\t\treturn -EINVAL;\n\n\tmemset(&op, 0, sizeof(op));\n\top.cmd_q = cmd_q;\n\top.jobid = CCP_NEW_JOBID(cmd_q->ccp);\n\n\t\/* The RSA modulus must precede the message being acted upon, so\n\t * it must be copied to a DMA area where the message and the\n\t * modulus can be concatenated.  Therefore the input buffer\n\t * length required is twice the output buffer length (which\n\t * must be a multiple of 256-bits).  Compute o_len, i_len in bytes.\n\t * Buffer sizes must be a multiple of 32 bytes; rounding up may be\n\t * required.\n\t *\/\n\to_len = 32 * ((rsa->key_size + 255) \/ 256);\n\ti_len = o_len * 2;\n\n\tsb_count = 0;\n\tif (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) {\n\t\t\/* sb_count is the number of storage block slots required\n\t\t * for the modulus.\n\t\t *\/\n\t\tsb_count = o_len \/ CCP_SB_BYTES;\n\t\top.sb_key = cmd_q->ccp->vdata->perform->sballoc(cmd_q,\n\t\t\t\t\t\t\t\tsb_count);\n\t\tif (!op.sb_key)\n\t\t\treturn -EIO;\n\t} else {\n\t\t\/* A version 5 device allows a modulus size that will not fit\n\t\t * in the LSB, so the command will transfer it from memory.\n\t\t * Set the sb key to the default, even though it's not used.\n\t\t *\/\n\t\top.sb_key = cmd_q->sb_key;\n\t}\n\n\t\/* The RSA exponent must be in little endian format. Reverse its\n\t * byte order.\n\t *\/\n\tret = ccp_init_dm_workarea(&exp, cmd_q, o_len, DMA_TO_DEVICE);\n\tif (ret)\n\t\tgoto e_sb;\n\n\tret = ccp_reverse_set_dm_area(&exp, 0, rsa->exp, 0, rsa->exp_len);\n\tif (ret)\n\t\tgoto e_exp;\n\n\tif (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) {\n\t\t\/* Copy the exponent to the local storage block, using\n\t\t * as many 32-byte blocks as were allocated above. It's\n\t\t * already little endian, so no further change is required.\n\t\t *\/\n\t\tret = ccp_copy_to_sb(cmd_q, &exp, op.jobid, op.sb_key,\n\t\t\t\t     CCP_PASSTHRU_BYTESWAP_NOOP);\n\t\tif (ret) {\n\t\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\t\tgoto e_exp;\n\t\t}\n\t} else {\n\t\t\/* The exponent can be retrieved from memory via DMA. *\/\n\t\top.exp.u.dma.address = exp.dma.address;\n\t\top.exp.u.dma.offset = 0;\n\t}\n\n\t\/* Concatenate the modulus and the message. Both the modulus and\n\t * the operands must be in little endian format.  Since the input\n\t * is in big endian format it must be converted.\n\t *\/\n\tret = ccp_init_dm_workarea(&src, cmd_q, i_len, DMA_TO_DEVICE);\n\tif (ret)\n\t\tgoto e_exp;\n\n\tret = ccp_reverse_set_dm_area(&src, 0, rsa->mod, 0, rsa->mod_len);\n\tif (ret)\n\t\tgoto e_src;\n\tret = ccp_reverse_set_dm_area(&src, o_len, rsa->src, 0, rsa->src_len);\n\tif (ret)\n\t\tgoto e_src;\n\n\t\/* Prepare the output area for the operation *\/\n\tret = ccp_init_dm_workarea(&dst, cmd_q, o_len, DMA_FROM_DEVICE);\n\tif (ret)\n\t\tgoto e_src;\n\n\top.soc = 1;\n\top.src.u.dma.address = src.dma.address;\n\top.src.u.dma.offset = 0;\n\top.src.u.dma.length = i_len;\n\top.dst.u.dma.address = dst.dma.address;\n\top.dst.u.dma.offset = 0;\n\top.dst.u.dma.length = o_len;\n\n\top.u.rsa.mod_size = rsa->key_size;\n\top.u.rsa.input_len = i_len;\n\n\tret = cmd_q->ccp->vdata->perform->rsa(&op);\n\tif (ret) {\n\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\tgoto e_dst;\n\t}\n\n\tccp_reverse_get_dm_area(&dst, 0, rsa->dst, 0, rsa->mod_len);\n\ne_dst:\n\tccp_dm_free(&dst);\n\ne_src:\n\tccp_dm_free(&src);\n\ne_exp:\n\tccp_dm_free(&exp);\n\ne_sb:\n\tif (sb_count)\n\t\tcmd_q->ccp->vdata->perform->sbfree(cmd_q, op.sb_key, sb_count);\n\n\treturn ret;\n}","target":0,"code_token_length":1126,"total_token_length":1362,"max_tokens_setting":2048}
+{"idx":299322,"func":"static Image *decompress_block(Image *orig, unsigned int *Size, ImageInfo *clone_info, ExceptionInfo *exception)\n{\n\nImage *image2;\nvoid *cache_block, *decompress_block;\nz_stream zip_info;\nFILE *mat_file;\nsize_t magick_size;\nsize_t extent;\nint file;\n\nint status;\nint zip_status;\nssize_t TotalSize = 0;\n\n  if(clone_info==NULL) return NULL;\n  if(clone_info->file)    \/* Close file opened from previous transaction. *\/\n  {\n    fclose(clone_info->file);\n    clone_info->file = NULL;\n    (void) remove_utf8(clone_info->filename);\n  }\n\n  cache_block = AcquireQuantumMemory((size_t)(*Size < 16384) ? *Size: 16384,sizeof(unsigned char *));\n  if(cache_block==NULL) return NULL;\n  decompress_block = AcquireQuantumMemory((size_t)(4096),sizeof(unsigned char *));\n  if(decompress_block==NULL)\n  {\n    RelinquishMagickMemory(cache_block);\n    return NULL;\n  }\n\n  mat_file=0;\n  file = AcquireUniqueFileResource(clone_info->filename);\n  if (file != -1)\n    mat_file = fdopen(file,\"w\");\n  if(!mat_file)\n  {\n    RelinquishMagickMemory(cache_block);\n    RelinquishMagickMemory(decompress_block);\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Cannot create file stream for decompressed image\");\n    return NULL;\n  }\n\n  zip_info.zalloc=AcquireZIPMemory;\n  zip_info.zfree=RelinquishZIPMemory;\n  zip_info.opaque = (voidpf) NULL;\n  zip_status = inflateInit(&zip_info);\n  if (zip_status != Z_OK)\n    {\n      RelinquishMagickMemory(cache_block);\n      RelinquishMagickMemory(decompress_block);\n      (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,\n        \"UnableToUncompressImage\",\"`%s'\",clone_info->filename);\n      (void) fclose(mat_file);\n      RelinquishUniqueFileResource(clone_info->filename);\n      return NULL;\n    }\n  \/* zip_info.next_out = 8*4;*\/\n\n  zip_info.avail_in = 0;\n  zip_info.total_out = 0;\n  while(*Size>0 && !EOFBlob(orig))\n  {\n    magick_size = ReadBlob(orig, (*Size < 16384) ? *Size : 16384, (unsigned char *) cache_block);\n    if (magick_size == 0)\n      break;\n    zip_info.next_in = (Bytef *) cache_block;\n    zip_info.avail_in = (uInt) magick_size;\n\n    while(zip_info.avail_in>0)\n    {\n      zip_info.avail_out = 4096;\n      zip_info.next_out = (Bytef *) decompress_block;\n      zip_status = inflate(&zip_info,Z_NO_FLUSH);\n      if ((zip_status != Z_OK) && (zip_status != Z_STREAM_END))\n        break;\n      extent=fwrite(decompress_block, 4096-zip_info.avail_out, 1, mat_file);\n      (void) extent;\n      TotalSize += 4096-zip_info.avail_out;\n\n      if(zip_status == Z_STREAM_END) goto DblBreak;\n    }\n    if ((zip_status != Z_OK) && (zip_status != Z_STREAM_END))\n      break;\n\n    *Size -= (unsigned int) magick_size;\n  }\nDblBreak:\n\n  inflateEnd(&zip_info);\n  (void)fclose(mat_file);\n  RelinquishMagickMemory(cache_block);\n  RelinquishMagickMemory(decompress_block);\n  *Size = TotalSize;\n\n  if((clone_info->file=fopen(clone_info->filename,\"rb\"))==NULL) goto UnlinkFile;\n  if( (image2 = AcquireImage(clone_info,exception))==NULL ) goto EraseFile;\n  status = OpenBlob(clone_info,image2,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n  {\n    DeleteImageFromList(&image2);\nEraseFile:\n    fclose(clone_info->file);\n    clone_info->file = NULL;\nUnlinkFile:\n    RelinquishUniqueFileResource(clone_info->filename);\n    return NULL;\n  }\n\n  return image2;\n}","target":0,"code_token_length":942,"total_token_length":1178,"max_tokens_setting":2048}
+{"idx":384796,"func":"getvcol(\n    win_T\t*wp,\n    pos_T\t*pos,\n    colnr_T\t*start,\n    colnr_T\t*cursor,\n    colnr_T\t*end)\n{\n    colnr_T\tvcol;\n    char_u\t*ptr;\t\t\/\/ points to current char\n    char_u\t*posptr;\t\/\/ points to char at pos->col\n    char_u\t*line;\t\t\/\/ start of the line\n    int\t\tincr;\n    int\t\thead;\n#ifdef FEAT_VARTABS\n    int\t\t*vts = wp->w_buffer->b_p_vts_array;\n#endif\n    int\t\tts = wp->w_buffer->b_p_ts;\n    int\t\tc;\n\n    vcol = 0;\n    line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);\n    if (pos->col == MAXCOL)\n\tposptr = NULL;  \/\/ continue until the NUL\n    else\n    {\n\tcolnr_T i;\n\n\t\/\/ In a few cases the position can be beyond the end of the line.\n\tfor (i = 0; i < pos->col; ++i)\n\t    if (ptr[i] == NUL)\n\t    {\n\t\tpos->col = i;\n\t\tbreak;\n\t    }\n\tposptr = ptr + pos->col;\n\tif (has_mbyte)\n\t    \/\/ always start on the first byte\n\t    posptr -= (*mb_head_off)(line, posptr);\n    }\n\n    \/*\n     * This function is used very often, do some speed optimizations.\n     * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set\n     * use a simple loop.\n     * Also use this when 'list' is set but tabs take their normal size.\n     *\/\n    if ((!wp->w_p_list || wp->w_lcs_chars.tab1 != NUL)\n#ifdef FEAT_LINEBREAK\n\t    && !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri\n#endif\n       )\n    {\n\tfor (;;)\n\t{\n\t    head = 0;\n\t    c = *ptr;\n\t    \/\/ make sure we don't go past the end of the line\n\t    if (c == NUL)\n\t    {\n\t\tincr = 1;\t\/\/ NUL at end of line only takes one column\n\t\tbreak;\n\t    }\n\t    \/\/ A tab gets expanded, depending on the current column\n\t    if (c == TAB)\n#ifdef FEAT_VARTABS\n\t\tincr = tabstop_padding(vcol, ts, vts);\n#else\n\t\tincr = ts - (vcol % ts);\n#endif\n\t    else\n\t    {\n\t\tif (has_mbyte)\n\t\t{\n\t\t    \/\/ For utf-8, if the byte is >= 0x80, need to look at\n\t\t    \/\/ further bytes to find the cell width.\n\t\t    if (enc_utf8 && c >= 0x80)\n\t\t\tincr = utf_ptr2cells(ptr);\n\t\t    else\n\t\t\tincr = g_chartab[c] & CT_CELL_MASK;\n\n\t\t    \/\/ If a double-cell char doesn't fit at the end of a line\n\t\t    \/\/ it wraps to the next line, it's like this char is three\n\t\t    \/\/ cells wide.\n\t\t    if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1\n\t\t\t    && in_win_border(wp, vcol))\n\t\t    {\n\t\t\t++incr;\n\t\t\thead = 1;\n\t\t    }\n\t\t}\n\t\telse\n\t\t    incr = g_chartab[c] & CT_CELL_MASK;\n\t    }\n\n\t    if (posptr != NULL && ptr >= posptr) \/\/ character at pos->col\n\t\tbreak;\n\n\t    vcol += incr;\n\t    MB_PTR_ADV(ptr);\n\t}\n    }\n    else\n    {\n\tfor (;;)\n\t{\n\t    \/\/ A tab gets expanded, depending on the current column\n\t    head = 0;\n\t    incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);\n\t    \/\/ make sure we don't go past the end of the line\n\t    if (*ptr == NUL)\n\t    {\n\t\tincr = 1;\t\/\/ NUL at end of line only takes one column\n\t\tbreak;\n\t    }\n\n\t    if (posptr != NULL && ptr >= posptr) \/\/ character at pos->col\n\t\tbreak;\n\n\t    vcol += incr;\n\t    MB_PTR_ADV(ptr);\n\t}\n    }\n    if (start != NULL)\n\t*start = vcol + head;\n    if (end != NULL)\n\t*end = vcol + incr - 1;\n    if (cursor != NULL)\n    {\n\tif (*ptr == TAB\n\t\t&& (State & NORMAL)\n\t\t&& !wp->w_p_list\n\t\t&& !virtual_active()\n\t\t&& !(VIsual_active\n\t\t\t\t&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))\n\t\t)\n\t    *cursor = vcol + incr - 1;\t    \/\/ cursor at end\n\telse\n\t    *cursor = vcol + head;\t    \/\/ cursor at start\n    }\n}","target":0,"code_token_length":1090,"total_token_length":1326,"max_tokens_setting":2048}
+{"idx":206942,"func":"eval_string(char_u **arg, typval_T *rettv, int evaluate, int interpolate)\n{\n    char_u\t*p;\n    char_u\t*end;\n    int\t\textra = interpolate ? 1 : 0;\n    int\t\toff = interpolate ? 0 : 1;\n    int\t\tlen;\n\n    \/\/ Find the end of the string, skipping backslashed characters.\n    for (p = *arg + off; *p != NUL && *p != '\"'; MB_PTR_ADV(p))\n    {\n\tif (*p == '\\\\' && p[1] != NUL)\n\t{\n\t    ++p;\n\t    \/\/ A \"\\<x>\" form occupies at least 4 characters, and produces up\n\t    \/\/ to 9 characters (6 for the char and 3 for a modifier):\n\t    \/\/ reserve space for 5 extra.\n\t    if (*p == '<')\n\t\textra += 5;\n\t}\n\telse if (interpolate && (*p == '{' || *p == '}'))\n\t{\n\t    if (*p == '{' && p[1] != '{') \/\/ start of expression\n\t\tbreak;\n\t    ++p;\n\t    if (p[-1] == '}' && *p != '}') \/\/ single '}' is an error\n\t    {\n\t\tsemsg(_(e_stray_closing_curly_str), *arg);\n\t\treturn FAIL;\n\t    }\n\t    --extra;  \/\/ \"{{\" becomes \"{\", \"}}\" becomes \"}\"\n\t}\n    }\n\n    if (*p != '\"' && !(interpolate && *p == '{'))\n    {\n\tsemsg(_(e_missing_double_quote_str), *arg);\n\treturn FAIL;\n    }\n\n    \/\/ If only parsing, set *arg and return here\n    if (!evaluate)\n    {\n\t*arg = p + off;\n\treturn OK;\n    }\n\n    \/\/ Copy the string into allocated memory, handling backslashed\n    \/\/ characters.\n    rettv->v_type = VAR_STRING;\n    len = (int)(p - *arg + extra);\n    rettv->vval.v_string = alloc(len);\n    if (rettv->vval.v_string == NULL)\n\treturn FAIL;\n    end = rettv->vval.v_string;\n\n    for (p = *arg + off; *p != NUL && *p != '\"'; )\n    {\n\tif (*p == '\\\\')\n\t{\n\t    switch (*++p)\n\t    {\n\t\tcase 'b': *end++ = BS; ++p; break;\n\t\tcase 'e': *end++ = ESC; ++p; break;\n\t\tcase 'f': *end++ = FF; ++p; break;\n\t\tcase 'n': *end++ = NL; ++p; break;\n\t\tcase 'r': *end++ = CAR; ++p; break;\n\t\tcase 't': *end++ = TAB; ++p; break;\n\n\t\tcase 'X': \/\/ hex: \"\\x1\", \"\\x12\"\n\t\tcase 'x':\n\t\tcase 'u': \/\/ Unicode: \"\\u0023\"\n\t\tcase 'U':\n\t\t\t  if (vim_isxdigit(p[1]))\n\t\t\t  {\n\t\t\t      int\tn, nr;\n\t\t\t      int\tc = toupper(*p);\n\n\t\t\t      if (c == 'X')\n\t\t\t\t  n = 2;\n\t\t\t      else if (*p == 'u')\n\t\t\t\t  n = 4;\n\t\t\t      else\n\t\t\t\t  n = 8;\n\t\t\t      nr = 0;\n\t\t\t      while (--n >= 0 && vim_isxdigit(p[1]))\n\t\t\t      {\n\t\t\t\t  ++p;\n\t\t\t\t  nr = (nr << 4) + hex2nr(*p);\n\t\t\t      }\n\t\t\t      ++p;\n\t\t\t      \/\/ For \"\\u\" store the number according to\n\t\t\t      \/\/ 'encoding'.\n\t\t\t      if (c != 'X')\n\t\t\t\t  end += (*mb_char2bytes)(nr, end);\n\t\t\t      else\n\t\t\t\t  *end++ = nr;\n\t\t\t  }\n\t\t\t  break;\n\n\t\t\t  \/\/ octal: \"\\1\", \"\\12\", \"\\123\"\n\t\tcase '0':\n\t\tcase '1':\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '4':\n\t\tcase '5':\n\t\tcase '6':\n\t\tcase '7': *end = *p++ - '0';\n\t\t\t  if (*p >= '0' && *p <= '7')\n\t\t\t  {\n\t\t\t      *end = (*end << 3) + *p++ - '0';\n\t\t\t      if (*p >= '0' && *p <= '7')\n\t\t\t\t  *end = (*end << 3) + *p++ - '0';\n\t\t\t  }\n\t\t\t  ++end;\n\t\t\t  break;\n\n\t\t\t  \/\/ Special key, e.g.: \"\\<C-W>\"\n\t\tcase '<':\n\t\t\t  {\n\t\t\t      int flags = FSK_KEYCODE | FSK_IN_STRING;\n\n\t\t\t      if (p[1] != '*')\n\t\t\t\t  flags |= FSK_SIMPLIFY;\n\t\t\t      extra = trans_special(&p, end, flags, FALSE, NULL);\n\t\t\t      if (extra != 0)\n\t\t\t      {\n\t\t\t\t  end += extra;\n\t\t\t\t  if (end >= rettv->vval.v_string + len)\n\t\t\t\t      iemsg(\"eval_string() used more space than allocated\");\n\t\t\t\t  break;\n\t\t\t      }\n\t\t\t  }\n\t\t\t  \/\/ FALLTHROUGH\n\n\t\tdefault: MB_COPY_CHAR(p, end);\n\t\t\t  break;\n\t    }\n\t}\n\telse\n\t{\n\t    if (interpolate && (*p == '{' || *p == '}'))\n\t    {\n\t\tif (*p == '{' && p[1] != '{') \/\/ start of expression\n\t\t    break;\n\t\t++p;  \/\/ reduce \"{{\" to \"{\" and \"}}\" to \"}\"\n\t    }\n\t    MB_COPY_CHAR(p, end);\n\t}\n    }\n    *end = NUL;\n    if (*p == '\"' && !interpolate)\n\t++p;\n    *arg = p;\n\n    return OK;\n}","target":1,"code_token_length":1198,"total_token_length":1434,"max_tokens_setting":2048}
+{"idx":513248,"func":"static bool check_simple_equality(THD *thd, const Item::Context &ctx,\n                                  Item *left_item, Item *right_item,\n                                  COND_EQUAL *cond_equal)\n{\n  Item *orig_left_item= left_item;\n  Item *orig_right_item= right_item;\n  if (left_item->type() == Item::REF_ITEM &&\n      ((Item_ref*)left_item)->ref_type() == Item_ref::VIEW_REF)\n  {\n    if (((Item_ref*)left_item)->get_depended_from())\n      return FALSE;\n    if (((Item_direct_view_ref*)left_item)->get_null_ref_table() !=\n        NO_NULL_TABLE && !left_item->real_item()->used_tables())\n      return FALSE;\n    left_item= left_item->real_item();\n  }\n  if (right_item->type() == Item::REF_ITEM &&\n      ((Item_ref*)right_item)->ref_type() == Item_ref::VIEW_REF)\n  {\n    if (((Item_ref*)right_item)->get_depended_from())\n      return FALSE;\n    if (((Item_direct_view_ref*)right_item)->get_null_ref_table() !=\n        NO_NULL_TABLE && !right_item->real_item()->used_tables())\n      return FALSE;\n    right_item= right_item->real_item();\n  }\n  if (left_item->type() == Item::FIELD_ITEM &&\n      right_item->type() == Item::FIELD_ITEM &&\n      !((Item_field*)left_item)->get_depended_from() &&\n      !((Item_field*)right_item)->get_depended_from())\n  {\n    \/* The predicate the form field1=field2 is processed *\/\n\n    Field *left_field= ((Item_field*) left_item)->field;\n    Field *right_field= ((Item_field*) right_item)->field;\n\n    if (!left_field->eq_def(right_field))\n      return FALSE;\n\n    \/* Search for multiple equalities containing field1 and\/or field2 *\/\n    bool left_copyfl, right_copyfl;\n    Item_equal *left_item_equal=\n               find_item_equal(cond_equal, left_field, &left_copyfl);\n    Item_equal *right_item_equal= \n               find_item_equal(cond_equal, right_field, &right_copyfl);\n\n    \/* As (NULL=NULL) != TRUE we can't just remove the predicate f=f *\/\n    if (left_field->eq(right_field)) \/* f = f *\/\n      return (!(left_field->maybe_null() && !left_item_equal)); \n\n    if (left_item_equal && left_item_equal == right_item_equal)\n    {\n      \/* \n        The equality predicate is inference of one of the existing\n        multiple equalities, i.e the condition is already covered\n        by upper level equalities\n      *\/\n       return TRUE;\n    }\n      \n    \/* Copy the found multiple equalities at the current level if needed *\/\n    if (left_copyfl)\n    {\n      \/* left_item_equal of an upper level contains left_item *\/\n      left_item_equal= new (thd->mem_root) Item_equal(thd, left_item_equal);\n      left_item_equal->set_context_field(((Item_field*) left_item));\n      cond_equal->current_level.push_back(left_item_equal, thd->mem_root);\n    }\n    if (right_copyfl)\n    {\n      \/* right_item_equal of an upper level contains right_item *\/\n      right_item_equal= new (thd->mem_root) Item_equal(thd, right_item_equal);\n      right_item_equal->set_context_field(((Item_field*) right_item));\n      cond_equal->current_level.push_back(right_item_equal, thd->mem_root);\n    }\n\n    if (left_item_equal)\n    { \n      \/* left item was found in the current or one of the upper levels *\/\n      if (! right_item_equal)\n        left_item_equal->add(orig_right_item, thd->mem_root);\n      else\n      {\n        \/* Merge two multiple equalities forming a new one *\/\n        left_item_equal->merge(thd, right_item_equal);\n        \/* Remove the merged multiple equality from the list *\/\n        List_iterator<Item_equal> li(cond_equal->current_level);\n        while ((li++) != right_item_equal) ;\n        li.remove();\n      }\n    }\n    else\n    { \n      \/* left item was not found neither the current nor in upper levels  *\/\n      if (right_item_equal)\n        right_item_equal->add(orig_left_item, thd->mem_root);\n      else \n      {\n        \/* None of the fields was found in multiple equalities *\/\n        Item_equal *item_equal= new (thd->mem_root) Item_equal(thd,\n                                                               orig_left_item,\n                                                               orig_right_item,\n                                                               FALSE);\n        item_equal->set_context_field((Item_field*)left_item);\n        cond_equal->current_level.push_back(item_equal, thd->mem_root);\n      }\n    }\n    return TRUE;\n  }\n\n  {\n    \/* The predicate of the form field=const\/const=field is processed *\/\n    Item *const_item= 0;\n    Item_field *field_item= 0;\n    Item *orig_field_item= 0;\n    if (left_item->type() == Item::FIELD_ITEM &&\n        !((Item_field*)left_item)->get_depended_from() &&\n        right_item->const_item() && !right_item->is_expensive())\n    {\n      orig_field_item= orig_left_item;\n      field_item= (Item_field *) left_item;\n      const_item= right_item;\n    }\n    else if (right_item->type() == Item::FIELD_ITEM &&\n             !((Item_field*)right_item)->get_depended_from() &&\n             left_item->const_item() && !left_item->is_expensive())\n    {\n      orig_field_item= orig_right_item;\n      field_item= (Item_field *) right_item;\n      const_item= left_item;\n    }\n\n    if (const_item &&\n        field_item->field->test_if_equality_guarantees_uniqueness(const_item))\n    {\n      \/*\n        field_item and const_item are arguments of a scalar or a row\n        comparison function:\n          WHERE column=constant\n          WHERE (column, ...) = (constant, ...)\n\n        The owner comparison function has previously called fix_fields(),\n        so field_item and const_item should be directly comparable items,\n        field_item->cmp_context and const_item->cmp_context should be set.\n        In case of string comparison, charsets and collations of\n        field_item and const_item should have already be aggregated\n        for comparison, all necessary character set converters installed\n        and fixed.\n\n        In case of string comparison, const_item can be either:\n        - a weaker constant that does not need to be converted to field_item:\n            WHERE latin1_field = 'latin1_const'\n            WHERE varbinary_field = 'latin1_const'\n            WHERE latin1_bin_field = 'latin1_general_ci_const'\n        - a stronger constant that does not need to be converted to field_item:\n            WHERE latin1_field = binary 0xDF\n            WHERE latin1_field = 'a' COLLATE latin1_bin\n        - a result of conversion (e.g. from the session character set)\n          to the character set of field_item:\n            WHERE latin1_field = 'utf8_string_with_latin1_repertoire'\n      *\/\n      bool copyfl;\n\n      Item_equal *item_equal = find_item_equal(cond_equal,\n                                               field_item->field, ©fl);\n      if (copyfl)\n      {\n        item_equal= new (thd->mem_root) Item_equal(thd, item_equal);\n        cond_equal->current_level.push_back(item_equal, thd->mem_root);\n        item_equal->set_context_field(field_item);\n      }\n      Item *const_item2= field_item->field->get_equal_const_item(thd, ctx,\n                                                                 const_item);\n      if (!const_item2)\n        return false;\n\n      if (item_equal)\n      {\n        \/* \n          The flag cond_false will be set to 1 after this, if item_equal\n          already contains a constant and its value is  not equal to\n          the value of const_item.\n        *\/\n        item_equal->add_const(thd, const_item2);\n      }\n      else\n      {\n        item_equal= new (thd->mem_root) Item_equal(thd, const_item2,\n                                                   orig_field_item, TRUE);\n        item_equal->set_context_field(field_item);\n        cond_equal->current_level.push_back(item_equal, thd->mem_root);\n      }\n      return TRUE;\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":1754,"total_token_length":1990,"max_tokens_setting":2048}
+{"idx":448552,"func":"static int bgp_notify_receive(struct peer *peer, bgp_size_t size)\n{\n\tstruct bgp_notify outer = {};\n\tstruct bgp_notify inner = {};\n\tbool hard_reset = false;\n\n\tif (peer->notify.data) {\n\t\tXFREE(MTYPE_BGP_NOTIFICATION, peer->notify.data);\n\t\tpeer->notify.length = 0;\n\t\tpeer->notify.hard_reset = false;\n\t}\n\n\touter.code = stream_getc(peer->curr);\n\touter.subcode = stream_getc(peer->curr);\n\touter.length = size - 2;\n\touter.data = NULL;\n\touter.raw_data = NULL;\n\tif (outer.length) {\n\t\touter.raw_data = XMALLOC(MTYPE_BGP_NOTIFICATION, outer.length);\n\t\tmemcpy(outer.raw_data, stream_pnt(peer->curr), outer.length);\n\t}\n\n\thard_reset =\n\t\tbgp_notify_received_hard_reset(peer, outer.code, outer.subcode);\n\tif (hard_reset && outer.length) {\n\t\tinner = bgp_notify_decapsulate_hard_reset(&outer);\n\t\tpeer->notify.hard_reset = true;\n\t} else {\n\t\tinner = outer;\n\t}\n\n\t\/* Preserv notify code and sub code. *\/\n\tpeer->notify.code = inner.code;\n\tpeer->notify.subcode = inner.subcode;\n\t\/* For further diagnostic record returned Data. *\/\n\tif (inner.length) {\n\t\tpeer->notify.length = inner.length;\n\t\tpeer->notify.data =\n\t\t\tXMALLOC(MTYPE_BGP_NOTIFICATION, inner.length);\n\t\tmemcpy(peer->notify.data, inner.raw_data, inner.length);\n\t}\n\n\t\/* For debug *\/\n\t{\n\t\tint i;\n\t\tint first = 0;\n\t\tchar c[4];\n\n\t\tif (inner.length) {\n\t\t\tinner.data = XMALLOC(MTYPE_BGP_NOTIFICATION,\n\t\t\t\t\t     inner.length * 3);\n\t\t\tfor (i = 0; i < inner.length; i++)\n\t\t\t\tif (first) {\n\t\t\t\t\tsnprintf(c, sizeof(c), \" %02x\",\n\t\t\t\t\t\tstream_getc(peer->curr));\n\n\t\t\t\t\tstrlcat(inner.data, c,\n\t\t\t\t\t\tinner.length * 3);\n\n\t\t\t\t} else {\n\t\t\t\t\tfirst = 1;\n\t\t\t\t\tsnprintf(c, sizeof(c), \"%02x\",\n\t\t\t\t\t\t stream_getc(peer->curr));\n\n\t\t\t\t\tstrlcpy(inner.data, c,\n\t\t\t\t\t\tinner.length * 3);\n\t\t\t\t}\n\t\t}\n\n\t\tbgp_notify_print(peer, &inner, \"received\", hard_reset);\n\t\tif (inner.length) {\n\t\t\tXFREE(MTYPE_BGP_NOTIFICATION, inner.data);\n\t\t\tinner.length = 0;\n\t\t}\n\t\tif (outer.length) {\n\t\t\tXFREE(MTYPE_BGP_NOTIFICATION, outer.data);\n\t\t\tXFREE(MTYPE_BGP_NOTIFICATION, outer.raw_data);\n\n\t\t\t\/* If this is a Hard Reset notification, we MUST free\n\t\t\t * the inner (encapsulated) notification too.\n\t\t\t *\/\n\t\t\tif (hard_reset)\n\t\t\t\tXFREE(MTYPE_BGP_NOTIFICATION, inner.raw_data);\n\t\t\touter.length = 0;\n\t\t}\n\t}\n\n\t\/* peer count update *\/\n\tatomic_fetch_add_explicit(&peer->notify_in, 1, memory_order_relaxed);\n\n\tpeer->last_reset = PEER_DOWN_NOTIFY_RECEIVED;\n\n\t\/* We have to check for Notify with Unsupported Optional Parameter.\n\t   in that case we fallback to open without the capability option.\n\t   But this done in bgp_stop. We just mark it here to avoid changing\n\t   the fsm tables.  *\/\n\tif (inner.code == BGP_NOTIFY_OPEN_ERR &&\n\t    inner.subcode == BGP_NOTIFY_OPEN_UNSUP_PARAM)\n\t\tUNSET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);\n\n\t\/* If Graceful-Restart N-bit (Notification) is exchanged,\n\t * and it's not a Hard Reset, let's retain the routes.\n\t *\/\n\tif (bgp_has_graceful_restart_notification(peer) && !hard_reset &&\n\t    CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_MODE))\n\t\tSET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT);\n\n\tbgp_peer_gr_flags_update(peer);\n\tBGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(peer->bgp,\n\t\t\t\t\t\t\t  peer->bgp->peer);\n\n\treturn Receive_NOTIFICATION_message;\n}","target":0,"code_token_length":883,"total_token_length":1119,"max_tokens_setting":2048}
+{"idx":176404,"func":"void AddQuickEnableWorkItems(const InstallerState& installer_state,\n                             const InstallationState& machine_state,\n                             const FilePath* setup_path,\n                             const Version* new_version,\n                             WorkItemList* work_item_list) {\n  DCHECK(setup_path ||\n         installer_state.operation() == InstallerState::UNINSTALL);\n  DCHECK(new_version ||\n         installer_state.operation() == InstallerState::UNINSTALL);\n  DCHECK(work_item_list);\n\n  const bool system_install = installer_state.system_install();\n  bool have_multi_chrome = false;\n  bool have_chrome_frame = false;\n\n  const ProductState* product_state = NULL;\n\n  product_state =\n      machine_state.GetProductState(system_install,\n                                    BrowserDistribution::CHROME_BROWSER);\n  if (product_state != NULL && product_state->is_multi_install())\n    have_multi_chrome = true;\n\n  product_state =\n      machine_state.GetProductState(system_install,\n                                    BrowserDistribution::CHROME_FRAME);\n  if (product_state != NULL &&\n      !product_state->uninstall_command().HasSwitch(\n          switches::kChromeFrameReadyMode))\n    have_chrome_frame = true;\n\n  const Product* product = NULL;\n\n  if (installer_state.operation() == InstallerState::UNINSTALL) {\n    product =\n        installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);\n    if (product != NULL && installer_state.is_multi_install())\n      have_multi_chrome = false;\n\n    if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL)\n      have_chrome_frame = false;\n  } else {\n    product =\n        installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);\n    if (product != NULL && installer_state.is_multi_install())\n      have_multi_chrome = true;\n\n    product = installer_state.FindProduct(BrowserDistribution::CHROME_FRAME);\n    if (product != NULL && !product->HasOption(kOptionReadyMode))\n      have_chrome_frame = true;\n  }\n\n  enum QuickEnableOperation {\n    DO_NOTHING,\n    ADD_COMMAND,\n    REMOVE_COMMAND\n  } operation = DO_NOTHING;\n  FilePath binaries_setup_path;\n\n  if (have_chrome_frame) {\n    operation = REMOVE_COMMAND;\n  } else if (have_multi_chrome) {\n    operation = ADD_COMMAND;\n    if (installer_state.operation() == InstallerState::UNINSTALL) {\n      product_state =\n          machine_state.GetProductState(system_install,\n                                        BrowserDistribution::CHROME_BROWSER);\n      DCHECK(product_state);\n      binaries_setup_path = product_state->uninstall_command().GetProgram();\n    } else {\n      DCHECK(installer_state.is_multi_install());\n      binaries_setup_path =\n          installer_state.GetInstallerDirectory(*new_version).Append(\n              setup_path->BaseName());\n    }\n  }\n\n  if (operation != DO_NOTHING) {\n    BrowserDistribution* binaries =\n        BrowserDistribution::GetSpecificDistribution(\n            BrowserDistribution::CHROME_BINARIES);\n    std::wstring cmd_key(binaries->GetVersionKey());\n    cmd_key.append(1, L'\\\\').append(google_update::kRegCommandsKey)\n        .append(1, L'\\\\').append(kCmdQuickEnableCf);\n\n    if (operation == ADD_COMMAND) {\n      DCHECK(!binaries_setup_path.empty());\n      CommandLine cmd_line(binaries_setup_path);\n      cmd_line.AppendSwitch(switches::kMultiInstall);\n      if (installer_state.system_install())\n        cmd_line.AppendSwitch(switches::kSystemLevel);\n      if (installer_state.verbose_logging())\n        cmd_line.AppendSwitch(switches::kVerboseLogging);\n      cmd_line.AppendSwitch(switches::kChromeFrameQuickEnable);\n      AppCommand cmd(cmd_line.command_line_string(), true, true);\n      cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);\n    } else {\n      DCHECK(operation == REMOVE_COMMAND);\n      work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),\n                                              cmd_key)->set_log_message(\n          \"removing quick-enable-cf command\");\n    }\n  }\n}\n","target":0,"code_token_length":823,"total_token_length":1059,"max_tokens_setting":2048}
+{"idx":259200,"func":"static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    int64_t stream_size = avio_size(pb);\n    int64_t offset = av_sat_add64(avio_tell(pb), atom.size), pts, timestamp;\n    uint8_t version, is_complete;\n    int64_t offadd;\n    unsigned i, j, track_id, item_count;\n    AVStream *st = NULL;\n    AVStream *ref_st = NULL;\n    MOVStreamContext *sc, *ref_sc = NULL;\n    AVRational timescale;\n\n    version = avio_r8(pb);\n    if (version > 1) {\n        avpriv_request_sample(c->fc, \"sidx version %u\", version);\n        return 0;\n    }\n\n    avio_rb24(pb); \/\/ flags\n\n    track_id = avio_rb32(pb); \/\/ Reference ID\n    for (i = 0; i < c->fc->nb_streams; i++) {\n        if (c->fc->streams[i]->id == track_id) {\n            st = c->fc->streams[i];\n            break;\n        }\n    }\n    if (!st) {\n        av_log(c->fc, AV_LOG_WARNING, \"could not find corresponding track id %d\\n\", track_id);\n        return 0;\n    }\n\n    sc = st->priv_data;\n\n    timescale = av_make_q(1, avio_rb32(pb));\n\n    if (timescale.den <= 0) {\n        av_log(c->fc, AV_LOG_ERROR, \"Invalid sidx timescale 1\/%d\\n\", timescale.den);\n        return AVERROR_INVALIDDATA;\n    }\n\n    if (version == 0) {\n        pts = avio_rb32(pb);\n        offadd= avio_rb32(pb);\n    } else {\n        pts = avio_rb64(pb);\n        offadd= avio_rb64(pb);\n    }\n    if (av_sat_add64(offset, offadd) != offset + (uint64_t)offadd)\n        return AVERROR_INVALIDDATA;\n\n    offset += (uint64_t)offadd;\n\n    avio_rb16(pb); \/\/ reserved\n\n    item_count = avio_rb16(pb);\n    if (item_count == 0)\n        return AVERROR_INVALIDDATA;\n\n    for (i = 0; i < item_count; i++) {\n        int index;\n        MOVFragmentStreamInfo * frag_stream_info;\n        uint32_t size = avio_rb32(pb);\n        uint32_t duration = avio_rb32(pb);\n        if (size & 0x80000000) {\n            avpriv_request_sample(c->fc, \"sidx reference_type 1\");\n            return AVERROR_PATCHWELCOME;\n        }\n        avio_rb32(pb); \/\/ sap_flags\n        timestamp = av_rescale_q(pts, timescale, st->time_base);\n\n        index = update_frag_index(c, offset);\n        frag_stream_info = get_frag_stream_info(&c->frag_index, index, track_id);\n        if (frag_stream_info)\n            frag_stream_info->sidx_pts = timestamp;\n\n        if (av_sat_add64(offset, size) != offset + (uint64_t)size ||\n            av_sat_add64(pts, duration) != pts + (uint64_t)duration\n        )\n            return AVERROR_INVALIDDATA;\n        offset += size;\n        pts += duration;\n    }\n\n    st->duration = sc->track_end = pts;\n\n    sc->has_sidx = 1;\n\n    \/\/ See if the remaining bytes are just an mfra which we can ignore.\n    is_complete = offset == stream_size;\n    if (!is_complete && (pb->seekable & AVIO_SEEKABLE_NORMAL) && stream_size > 0 ) {\n        int64_t ret;\n        int64_t original_pos = avio_tell(pb);\n        if (!c->have_read_mfra_size) {\n            if ((ret = avio_seek(pb, stream_size - 4, SEEK_SET)) < 0)\n                return ret;\n            c->mfra_size = avio_rb32(pb);\n            c->have_read_mfra_size = 1;\n            if ((ret = avio_seek(pb, original_pos, SEEK_SET)) < 0)\n                return ret;\n        }\n        if (offset == stream_size - c->mfra_size)\n            is_complete = 1;\n    }\n\n    if (is_complete) {\n        \/\/ Find first entry in fragment index that came from an sidx.\n        \/\/ This will pretty much always be the first entry.\n        for (i = 0; i < c->frag_index.nb_items; i++) {\n            MOVFragmentIndexItem * item = &c->frag_index.item[i];\n            for (j = 0; ref_st == NULL && j < item->nb_stream_info; j++) {\n                MOVFragmentStreamInfo * si;\n                si = &item->stream_info[j];\n                if (si->sidx_pts != AV_NOPTS_VALUE) {\n                    ref_st = c->fc->streams[j];\n                    ref_sc = ref_st->priv_data;\n                    break;\n                }\n            }\n        }\n        if (ref_st) for (i = 0; i < c->fc->nb_streams; i++) {\n            st = c->fc->streams[i];\n            sc = st->priv_data;\n            if (!sc->has_sidx) {\n                st->duration = sc->track_end = av_rescale(ref_st->duration, sc->time_scale, ref_sc->time_scale);\n            }\n        }\n\n        c->frag_index.complete = 1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":1212,"total_token_length":1448,"max_tokens_setting":2048}
+{"idx":273405,"func":"void LSTMBlockCellBpropWithEigen(\n    const LSTMBlockCell& cell, OpKernelContext* ctx, const Device& d,\n    bool use_peephole, typename TTypes<T>::ConstMatrix x,\n    typename TTypes<T>::ConstMatrix cs_prev,\n    typename TTypes<T>::ConstMatrix h_prev, typename TTypes<T>::ConstMatrix w,\n    typename TTypes<T>::ConstVec wci, typename TTypes<T>::ConstVec wcf,\n    typename TTypes<T>::ConstVec wco, typename TTypes<T>::ConstVec b,\n    typename TTypes<T>::ConstMatrix i, typename TTypes<T>::ConstMatrix cs,\n    typename TTypes<T>::ConstMatrix f, typename TTypes<T>::ConstMatrix o,\n    typename TTypes<T>::ConstMatrix ci, typename TTypes<T>::ConstMatrix co,\n    typename TTypes<T>::ConstMatrix cs_grad,\n    typename TTypes<T>::ConstMatrix h_grad, typename TTypes<T>::Matrix do_,\n    typename TTypes<T>::Matrix dcs, typename TTypes<T>::Matrix dci,\n    typename TTypes<T>::Matrix df, typename TTypes<T>::Matrix di,\n    typename TTypes<T>::Matrix dgates, typename TTypes<T>::Matrix cs_prev_grad,\n    typename TTypes<T>::Vec wci_grad, typename TTypes<T>::Vec wcf_grad,\n    typename TTypes<T>::Vec wco_grad) {\n  \/\/ do[t] = sigm'(o[t]) .* dh[t] .* co[t]\n  do_.device(d) = o * (o.constant(T(1)) - o) * h_grad * co;\n\n  \/\/ dcs[t] += tanh'(cs[t]) .* dh[t] .* o[t] + dcs[t + 1] .* f[t + 1]\n  dcs.device(d) = (co.constant(T(1)) - co * co) * h_grad * o + cs_grad;\n\n  Eigen::array<Eigen::DenseIndex, 2> p_shape({1, cell.cell_size()});\n  Eigen::array<Eigen::DenseIndex, 2> p_broadcast_shape({cell.batch_size(), 1});\n  if (use_peephole) {\n    dcs.device(d) =\n        dcs + do_ * wco.reshape(p_shape).broadcast(p_broadcast_shape);\n  }\n\n  \/\/ dci[t] = tanh'(ci[t]) dcs[t] i[t]\n  dci.device(d) = (ci.constant(T(1)) - ci * ci) * dcs * i;\n\n  \/\/ df[t] = sigm'(f[t]) dcs[t] cs[t - 1]\n  df.device(d) = f * (f.constant(T(1)) - f) * dcs * cs_prev;\n\n  \/\/ di[t] = sigm'(i[t]) dcs[t] ci[t]\n  di.device(d) = i * (i.constant(T(1)) - i) * dcs * ci;\n\n  dgates.slice(cell.gates_i_offsets(), cell.cell_extents()).device(d) = di;\n  dgates.slice(cell.gates_c_offsets(gate_layout), cell.cell_extents())\n      .device(d) = dci;\n  dgates.slice(cell.gates_f_offsets(gate_layout), cell.cell_extents())\n      .device(d) = df;\n  dgates.slice(cell.gates_o_offsets(), cell.cell_extents()).device(d) = do_;\n\n  cs_prev_grad.device(d) = dcs * f;\n  if (use_peephole) {\n    cs_prev_grad.device(d) =\n        cs_prev_grad + di * wci.reshape(p_shape).broadcast(p_broadcast_shape) +\n        df * wcf.reshape(p_shape).broadcast(p_broadcast_shape);\n    wci_grad.device(d) = (di * cs_prev).sum(Eigen::array<int, 1>({0}));\n    wcf_grad.device(d) = (df * cs_prev).sum(Eigen::array<int, 1>({0}));\n    wco_grad.device(d) = (do_ * cs).sum(Eigen::array<int, 1>({0}));\n  }\n}","target":0,"code_token_length":859,"total_token_length":1095,"max_tokens_setting":2048}
+{"idx":259164,"func":"int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n    int pseudo_stream_id;\n\n    av_assert0 (c->fc->nb_streams >= 1);\n    st = c->fc->streams[c->fc->nb_streams-1];\n    sc = st->priv_data;\n\n    for (pseudo_stream_id = 0;\n         pseudo_stream_id < entries && !pb->eof_reached;\n         pseudo_stream_id++) {\n        \/\/Parsing Sample description table\n        enum AVCodecID id;\n        int ret, dref_id = 1;\n        MOVAtom a = { AV_RL32(\"stsd\") };\n        int64_t start_pos = avio_tell(pb);\n        int64_t size    = avio_rb32(pb); \/* size *\/\n        uint32_t format = avio_rl32(pb); \/* data format *\/\n\n        if (size >= 16) {\n            avio_rb32(pb); \/* reserved *\/\n            avio_rb16(pb); \/* reserved *\/\n            dref_id = avio_rb16(pb);\n        } else if (size <= 7) {\n            av_log(c->fc, AV_LOG_ERROR,\n                   \"invalid size %\"PRId64\" in stsd\\n\", size);\n            return AVERROR_INVALIDDATA;\n        }\n\n        if (mov_skip_multiple_stsd(c, pb, st->codecpar->codec_tag, format,\n                                   size - (avio_tell(pb) - start_pos))) {\n            sc->stsd_count++;\n            continue;\n        }\n\n        sc->pseudo_stream_id = st->codecpar->codec_tag ? -1 : pseudo_stream_id;\n        sc->dref_id= dref_id;\n        sc->format = format;\n\n        id = mov_codec_id(st, format);\n\n        av_log(c->fc, AV_LOG_TRACE,\n               \"size=%\"PRId64\" 4CC=%s codec_type=%d\\n\", size,\n               av_fourcc2str(format), st->codecpar->codec_type);\n\n        st->codecpar->codec_id = id;\n        if (st->codecpar->codec_type==AVMEDIA_TYPE_VIDEO) {\n            mov_parse_stsd_video(c, pb, st, sc);\n        } else if (st->codecpar->codec_type==AVMEDIA_TYPE_AUDIO) {\n            mov_parse_stsd_audio(c, pb, st, sc);\n            if (st->codecpar->sample_rate < 0) {\n                av_log(c->fc, AV_LOG_ERROR, \"Invalid sample rate %d\\n\", st->codecpar->sample_rate);\n                return AVERROR_INVALIDDATA;\n            }\n            if (st->codecpar->ch_layout.nb_channels < 0) {\n                av_log(c->fc, AV_LOG_ERROR, \"Invalid channels %d\\n\", st->codecpar->ch_layout.nb_channels);\n                return AVERROR_INVALIDDATA;\n            }\n        } else if (st->codecpar->codec_type==AVMEDIA_TYPE_SUBTITLE){\n            mov_parse_stsd_subtitle(c, pb, st, sc,\n                                    size - (avio_tell(pb) - start_pos));\n        } else {\n            ret = mov_parse_stsd_data(c, pb, st, sc,\n                                      size - (avio_tell(pb) - start_pos));\n            if (ret < 0)\n                return ret;\n        }\n        \/* this will read extra atoms at the end (wave, alac, damr, avcC, hvcC, SMI ...) *\/\n        a.size = size - (avio_tell(pb) - start_pos);\n        if (a.size > 8) {\n            if ((ret = mov_read_default(c, pb, a)) < 0)\n                return ret;\n        } else if (a.size > 0)\n            avio_skip(pb, a.size);\n\n        if (sc->extradata && st->codecpar->extradata) {\n            int extra_size = st->codecpar->extradata_size;\n\n            \/* Move the current stream extradata to the stream context one. *\/\n            sc->extradata_size[pseudo_stream_id] = extra_size;\n            sc->extradata[pseudo_stream_id] = st->codecpar->extradata;\n            st->codecpar->extradata      = NULL;\n            st->codecpar->extradata_size = 0;\n        }\n        sc->stsd_count++;\n    }\n\n    if (pb->eof_reached) {\n        av_log(c->fc, AV_LOG_WARNING, \"reached eof, corrupted STSD atom\\n\");\n        return AVERROR_EOF;\n    }\n\n    return 0;\n}","target":0,"code_token_length":981,"total_token_length":1217,"max_tokens_setting":2048}
+{"idx":312413,"func":"qf_init_ext(\n    qf_info_T\t    *qi,\n    int\t\t    qf_idx,\n    char_u\t    *efile,\n    buf_T\t    *buf,\n    typval_T\t    *tv,\n    char_u\t    *errorformat,\n    int\t\t    newlist,\t\t\/\/ TRUE: start a new error list\n    linenr_T\t    lnumfirst,\t\t\/\/ first line number to use\n    linenr_T\t    lnumlast,\t\t\/\/ last line number to use\n    char_u\t    *qf_title,\n    char_u\t    *enc)\n{\n    qf_list_T\t    *qfl;\n    qfstate_T\t    state;\n    qffields_T\t    fields;\n    qfline_T\t    *old_last = NULL;\n    int\t\t    adding = FALSE;\n    static efm_T    *fmt_first = NULL;\n    char_u\t    *efm;\n    static char_u   *last_efm = NULL;\n    int\t\t    retval = -1;\t\/\/ default: return error flag\n    int\t\t    status;\n\n    \/\/ Do not used the cached buffer, it may have been wiped out.\n    VIM_CLEAR(qf_last_bufname);\n\n    CLEAR_FIELD(state);\n    CLEAR_FIELD(fields);\n    if ((qf_alloc_fields(&fields) == FAIL) ||\n\t\t(qf_setup_state(&state, enc, efile, tv, buf,\n\t\t\t\t\tlnumfirst, lnumlast) == FAIL))\n\tgoto qf_init_end;\n\n    if (newlist || qf_idx == qi->qf_listcount)\n    {\n\t\/\/ make place for a new list\n\tqf_new_list(qi, qf_title);\n\tqf_idx = qi->qf_curlist;\n\tqfl = qf_get_list(qi, qf_idx);\n    }\n    else\n    {\n\t\/\/ Adding to existing list, use last entry.\n\tadding = TRUE;\n\tqfl = qf_get_list(qi, qf_idx);\n\tif (!qf_list_empty(qfl))\n\t    old_last = qfl->qf_last;\n    }\n\n    \/\/ Use the local value of 'errorformat' if it's set.\n    if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)\n\tefm = buf->b_p_efm;\n    else\n\tefm = errorformat;\n\n    \/\/ If the errorformat didn't change between calls, then reuse the\n    \/\/ previously parsed values.\n    if (last_efm == NULL || (STRCMP(last_efm, efm) != 0))\n    {\n\t\/\/ free the previously parsed data\n\tVIM_CLEAR(last_efm);\n\tfree_efm_list(&fmt_first);\n\n\t\/\/ parse the current 'efm'\n\tfmt_first = parse_efm_option(efm);\n\tif (fmt_first != NULL)\n\t    last_efm = vim_strsave(efm);\n    }\n\n    if (fmt_first == NULL)\t\/\/ nothing found\n\tgoto error2;\n\n    \/\/ got_int is reset here, because it was probably set when killing the\n    \/\/ \":make\" command, but we still want to read the errorfile then.\n    got_int = FALSE;\n\n    \/\/ Read the lines in the error file one by one.\n    \/\/ Try to recognize one of the error formats in each line.\n    while (!got_int)\n    {\n\tstatus = qf_init_process_nextline(qfl, fmt_first, &state, &fields);\n\tif (status == QF_NOMEM)\t\t\/\/ memory alloc failure\n\t    goto qf_init_end;\n\tif (status == QF_END_OF_INPUT)\t\/\/ end of input\n\t    break;\n\tif (status == QF_FAIL)\n\t    goto error2;\n\n\tline_breakcheck();\n    }\n    if (state.fd == NULL || !ferror(state.fd))\n    {\n\tif (qfl->qf_index == 0)\n\t{\n\t    \/\/ no valid entry found\n\t    qfl->qf_ptr = qfl->qf_start;\n\t    qfl->qf_index = 1;\n\t    qfl->qf_nonevalid = TRUE;\n\t}\n\telse\n\t{\n\t    qfl->qf_nonevalid = FALSE;\n\t    if (qfl->qf_ptr == NULL)\n\t\tqfl->qf_ptr = qfl->qf_start;\n\t}\n\t\/\/ return number of matches\n\tretval = qfl->qf_count;\n\tgoto qf_init_end;\n    }\n    emsg(_(e_error_while_reading_errorfile));\nerror2:\n    if (!adding)\n    {\n\t\/\/ Error when creating a new list. Free the new list\n\tqf_free(qfl);\n\tqi->qf_listcount--;\n\tif (qi->qf_curlist > 0)\n\t    --qi->qf_curlist;\n    }\nqf_init_end:\n    if (qf_idx == qi->qf_curlist)\n\tqf_update_buffer(qi, old_last);\n    qf_cleanup_state(&state);\n    qf_free_fields(&fields);\n\n    return retval;\n}","target":0,"code_token_length":1048,"total_token_length":1284,"max_tokens_setting":2048}
+{"idx":246492,"func":"RList *r_bin_wasm_get_sections(RBinWasmObj *bin) {\n\tRList *ret = NULL;\n\tRBinWasmSection *ptr = NULL;\n\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\tif (bin->g_sections) {\n\t\treturn bin->g_sections;\n\t}\n\tif (!(ret = r_list_newf ((RListFree)wasm_sec_free))) {\n\t\treturn NULL;\n\t}\n\tRBuffer *b = bin->buf;\n\tut64 bound = r_buf_size (b) - 1;\n\tr_buf_seek (b, 8, R_BUF_SET);\n\twhile (r_buf_tell (b) <= bound) {\n\t\tif (!(ptr = R_NEW0 (RBinWasmSection))) {\n\t\t\treturn ret;\n\t\t}\n\t\tif (!consume_u7_r (b, bound, &ptr->id)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (!consume_u32_r (b, bound, &ptr->size)) {\n\t\t\tgoto beach;\n\t\t}\n\t\t\/\/ against spec. TODO: choose criteria for parsing\n\t\tif (ptr->size < 1) {\n\t\t\tgoto beach;\n\t\t\t\/\/ free (ptr);\n\t\t\t\/\/ continue;\n\t\t}\n\t\tptr->offset = r_buf_tell (b);\n\t\tswitch (ptr->id) {\n\t\tcase R_BIN_WASM_SECTION_CUSTOM:\n\t\t\t\/\/ eprintf(\"custom section: 0x%x, \", (ut32)b->cur);\n\t\t\tif (!consume_encoded_name_new (b, bound, &ptr->name_len, &ptr->name)) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_TYPE:\n\t\t\t\/\/ eprintf(\"section type: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"type\");\n\t\t\tptr->name_len = 4;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_IMPORT:\n\t\t\t\/\/ eprintf(\"section import: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"import\");\n\t\t\tptr->name_len = 6;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_FUNCTION:\n\t\t\t\/\/ eprintf(\"section function: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"function\");\n\t\t\tptr->name_len = 8;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_TABLE:\n\t\t\t\/\/ eprintf(\"section table: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"table\");\n\t\t\tptr->name_len = 5;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_MEMORY:\n\t\t\t\/\/ eprintf(\"section memory: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"memory\");\n\t\t\tptr->name_len = 6;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_GLOBAL:\n\t\t\t\/\/ eprintf(\"section global: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"global\");\n\t\t\tptr->name_len = 6;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_EXPORT:\n\t\t\t\/\/ eprintf(\"section export: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"export\");\n\t\t\tptr->name_len = 6;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_START:\n\t\t\t\/\/ eprintf(\"section start: 0x%x\\n\", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"start\");\n\t\t\tptr->name_len = 5;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_ELEMENT:\n\t\t\t\/\/ eprintf(\"section element: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"element\");\n\t\t\tptr->name_len = 7;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_CODE:\n\t\t\t\/\/ eprintf(\"section code: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"code\");\n\t\t\tptr->name_len = 4;\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_SECTION_DATA:\n\t\t\t\/\/ eprintf(\"section data: 0x%x, \", (ut32)b->cur);\n\t\t\tptr->name = strdup (\"data\");\n\t\t\tptr->name_len = 4;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\teprintf (\"[wasm] error: unkown section id: %d\\n\", ptr->id);\n\t\t\tr_buf_seek (b, ptr->size - 1, R_BUF_CUR);\n\t\t\tcontinue;\n\t\t}\n\t\tif (ptr->offset + (ut64)ptr->size - 1 > bound) {\n\t\t\t\/\/ TODO: Better error handling here\n\t\t\tut32 diff = ptr->size - (bound + 1 - ptr->offset);\n\t\t\teprintf (\"[wasm] Artificially reducing size of section %s by 0x%x bytes so it fits in the file\\n\", ptr->name, diff);\n\t\t\tptr->size -= diff;\n\t\t}\n\t\tptr->payload_data = r_buf_tell (b);\n\t\tptr->payload_len = ptr->size - (ptr->payload_data - ptr->offset);\n\t\tif (ptr->payload_len > ptr->size) {\n\t\t\tgoto beach;\n\t\t}\n\t\tr_buf_seek (b, ptr->payload_len, R_BUF_CUR);\n\t\tif (!r_list_append (ret, ptr)) {\n\t\t\tfree (ptr);\n\t\t\t\/\/ should it jump to beach?\n\t\t}\n\t\tptr = NULL;\n\t}\n\tbin->g_sections = ret;\n\treturn ret;\nbeach:\n\teprintf (\"[wasm] error: beach sections\\n\");\n\tfree (ptr);\n\treturn ret;\n}","target":0,"code_token_length":1214,"total_token_length":1450,"max_tokens_setting":2048}
+{"idx":197128,"func":"gen_assignment(codegen_scope *s, node *tree, node *rhs, int sp, int val)\n{\n  int idx;\n  int type = nint(tree->car);\n\n  switch (type) {\n  case NODE_GVAR:\n  case NODE_ARG:\n  case NODE_LVAR:\n  case NODE_IVAR:\n  case NODE_CVAR:\n  case NODE_CONST:\n  case NODE_NIL:\n  case NODE_MASGN:\n    if (rhs) {\n      codegen(s, rhs, VAL);\n      pop();\n      sp = cursp();\n    }\n    break;\n\n  case NODE_COLON2:\n  case NODE_CALL:\n  case NODE_SCALL:\n    \/* keep evaluation order *\/\n    break;\n\n  case NODE_NVAR:\n    codegen_error(s, \"Can't assign to numbered parameter\");\n    break;\n\n  default:\n    codegen_error(s, \"unknown lhs\");\n    break;\n  }\n\n  tree = tree->cdr;\n  switch (type) {\n  case NODE_GVAR:\n    gen_setxv(s, OP_SETGV, sp, nsym(tree), val);\n    break;\n  case NODE_ARG:\n  case NODE_LVAR:\n    idx = lv_idx(s, nsym(tree));\n    if (idx > 0) {\n      if (idx != sp) {\n        gen_move(s, idx, sp, val);\n      }\n      break;\n    }\n    else {                      \/* upvar *\/\n      gen_setupvar(s, sp, nsym(tree));\n    }\n    break;\n  case NODE_IVAR:\n    gen_setxv(s, OP_SETIV, sp, nsym(tree), val);\n    break;\n  case NODE_CVAR:\n    gen_setxv(s, OP_SETCV, sp, nsym(tree), val);\n    break;\n  case NODE_CONST:\n    gen_setxv(s, OP_SETCONST, sp, nsym(tree), val);\n    break;\n  case NODE_COLON2:\n    if (sp) {\n      gen_move(s, cursp(), sp, 0);\n    }\n    sp = cursp();\n    push();\n    codegen(s, tree->car, VAL);\n    if (rhs) {\n      codegen(s, rhs, VAL); pop();\n      gen_move(s, sp, cursp(), 0);\n    }\n    pop_n(2);\n    idx = new_sym(s, nsym(tree->cdr));\n    genop_2(s, OP_SETMCNST, sp, idx);\n    break;\n\n  case NODE_CALL:\n  case NODE_SCALL:\n    {\n      int noself = 0, safe = (type == NODE_SCALL), skip = 0, top, call, n = 0;\n      mrb_sym mid = nsym(tree->cdr->car);\n\n      top = cursp();\n      if (val || sp == cursp()) {\n        push();                   \/* room for retval *\/\n      }\n      call = cursp();\n      if (!tree->car) {\n        noself = 1;\n        push();\n      }\n      else {\n        codegen(s, tree->car, VAL); \/* receiver *\/\n      }\n      if (safe) {\n        int recv = cursp()-1;\n        gen_move(s, cursp(), recv, 1);\n        skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n      }\n      tree = tree->cdr->cdr->car;\n      if (tree) {\n        if (tree->car) {            \/* positional arguments *\/\n          n = gen_values(s, tree->car, VAL, (tree->cdr->car)?13:14);\n          if (n < 0) {              \/* variable length *\/\n            n = 15;\n            push();\n          }\n        }\n        if (tree->cdr->car) {       \/* keyword arguments *\/\n          if (n == 14) {\n            pop_n(n);\n            genop_2(s, OP_ARRAY, cursp(), n);\n            push();\n            n = 15;\n          }\n          gen_hash(s, tree->cdr->car->cdr, VAL, 0);\n          if (n < 14) {\n            n++;\n          }\n          else {\n            pop_n(2);\n            genop_2(s, OP_ARYPUSH, cursp(), 1);\n          }\n          push();\n        }\n      }\n      if (rhs) {\n        codegen(s, rhs, VAL);\n        pop();\n      }\n      else {\n        gen_move(s, cursp(), sp, 0);\n      }\n      if (val) {\n        gen_move(s, top, cursp(), 1);\n      }\n      if (n < 14) {\n        n++;\n      }\n      else {\n        pop();\n        genop_2(s, OP_ARYPUSH, cursp(), 1);\n      }\n      s->sp = call;\n      if (mid == MRB_OPSYM_2(s->mrb, aref) && n == 2) {\n        genop_1(s, OP_SETIDX, cursp());\n      }\n      else {\n        genop_3(s, noself ? OP_SSEND : OP_SEND, cursp(), new_sym(s, attrsym(s, mid)), n);\n      }\n      if (safe) {\n        dispatch(s, skip);\n      }\n      s->sp = top;\n    }\n    break;\n\n  case NODE_MASGN:\n    gen_vmassignment(s, tree->car, sp, val);\n    break;\n\n  \/* splat without assignment *\/\n  case NODE_NIL:\n    break;\n\n  default:\n    codegen_error(s, \"unknown lhs\");\n    break;\n  }\n  if (val) push();\n}","target":1,"code_token_length":1184,"total_token_length":1420,"max_tokens_setting":2048}
+{"idx":513358,"func":"do_select(JOIN *join, Procedure *procedure)\n{\n  int rc= 0;\n  enum_nested_loop_state error= NESTED_LOOP_OK;\n  DBUG_ENTER(\"do_select\");\n\n  if (join->pushdown_query)\n  {\n    \/* Select fields are in the temporary table *\/\n    join->fields= &join->tmp_fields_list1;\n    \/* Setup HAVING to work with fields in temporary table *\/\n    join->set_items_ref_array(join->items1);\n    \/* The storage engine will take care of the group by query result *\/\n    int res= join->pushdown_query->execute(join);\n\n    if (res)\n      DBUG_RETURN(res);\n\n    if (join->pushdown_query->store_data_in_temp_table)\n    {\n      JOIN_TAB *last_tab= join->join_tab + join->table_count -\n                          join->exec_join_tab_cnt();      \n      last_tab->next_select= end_send;\n\n      enum_nested_loop_state state= last_tab->aggr->end_send();\n      if (state >= NESTED_LOOP_OK)\n        state= sub_select(join, last_tab, true);\n\n      if (state < NESTED_LOOP_OK)\n        res= 1;\n\n      if (join->result->send_eof())\n        res= 1;\n    }\n    DBUG_RETURN(res);\n  }\n  \n  join->procedure= procedure;\n  join->duplicate_rows= join->send_records=0;\n  if (join->only_const_tables() && !join->need_tmp)\n  {\n    Next_select_func end_select= setup_end_select_func(join, NULL);\n    \/*\n      HAVING will be checked after processing aggregate functions,\n      But WHERE should checked here (we alredy have read tables).\n      Notice that make_join_select() splits all conditions in this case\n      into two groups exec_const_cond and outer_ref_cond.\n      If join->table_count == join->const_tables then it is\n      sufficient to check only the condition pseudo_bits_cond.\n    *\/\n    DBUG_ASSERT(join->outer_ref_cond == NULL);\n    if (!join->pseudo_bits_cond || join->pseudo_bits_cond->val_int())\n    {\n      \/\/ HAVING will be checked by end_select\n      error= (*end_select)(join, 0, 0);\n      if (error >= NESTED_LOOP_OK)\n\terror= (*end_select)(join, 0, 1);\n\n      \/*\n        If we don't go through evaluate_join_record(), do the counting\n        here.  join->send_records is increased on success in end_send(),\n        so we don't touch it here.\n      *\/\n      join->join_examined_rows++;\n      DBUG_ASSERT(join->join_examined_rows <= 1);\n    }\n    else if (join->send_row_on_empty_set())\n    {\n      if (!join->having || join->having->val_int())\n      {\n        List<Item> *columns_list= (procedure ? &join->procedure_fields_list :\n                                   join->fields);\n        rc= join->result->send_data(*columns_list) > 0;\n      }\n    }\n    \/*\n      An error can happen when evaluating the conds \n      (the join condition and piece of where clause \n      relevant to this join table).\n    *\/\n    if (join->thd->is_error())\n      error= NESTED_LOOP_ERROR;\n  }\n  else\n  {\n    DBUG_EXECUTE_IF(\"show_explain_probe_do_select\", \n                    if (dbug_user_var_equals_int(join->thd, \n                                                 \"show_explain_probe_select_id\", \n                                                 join->select_lex->select_number))\n                          dbug_serve_apcs(join->thd, 1);\n                   );\n\n    JOIN_TAB *join_tab= join->join_tab +\n                        (join->tables_list ? join->const_tables : 0);\n    if (join->outer_ref_cond && !join->outer_ref_cond->val_int())\n      error= NESTED_LOOP_NO_MORE_ROWS;\n    else\n      error= join->first_select(join,join_tab,0);\n    if (error >= NESTED_LOOP_OK && join->thd->killed != ABORT_QUERY)\n      error= join->first_select(join,join_tab,1);\n  }\n\n  join->thd->limit_found_rows= join->send_records - join->duplicate_rows;\n\n  if (error == NESTED_LOOP_NO_MORE_ROWS || join->thd->killed == ABORT_QUERY)\n    error= NESTED_LOOP_OK;\n\n  \/*\n    For \"order by with limit\", we cannot rely on send_records, but need\n    to use the rowcount read originally into the join_tab applying the\n    filesort. There cannot be any post-filtering conditions, nor any\n    following join_tabs in this case, so this rowcount properly represents\n    the correct number of qualifying rows.\n  *\/\n  if (join->order)\n  {\n    \/\/ Save # of found records prior to cleanup\n    JOIN_TAB *sort_tab;\n    JOIN_TAB *join_tab= join->join_tab;\n    uint const_tables= join->const_tables;\n\n    \/\/ Take record count from first non constant table or from last tmp table\n    if (join->aggr_tables > 0)\n      sort_tab= join_tab + join->top_join_tab_count + join->aggr_tables - 1;\n    else\n    {\n      DBUG_ASSERT(!join->only_const_tables());\n      sort_tab= join_tab + const_tables;\n    }\n    if (sort_tab->filesort &&\n        join->select_options & OPTION_FOUND_ROWS &&\n        sort_tab->filesort->sortorder &&\n        sort_tab->filesort->limit != HA_POS_ERROR)\n    {\n      join->thd->limit_found_rows= sort_tab->records;\n    }\n  }\n\n  {\n    \/*\n      The following will unlock all cursors if the command wasn't an\n      update command\n    *\/\n    join->join_free();\t\t\t\/\/ Unlock all cursors\n  }\n  if (error == NESTED_LOOP_OK)\n  {\n    \/*\n      Sic: this branch works even if rc != 0, e.g. when\n      send_data above returns an error.\n    *\/\n    if (join->result->send_eof())\n      rc= 1;                                  \/\/ Don't send error\n    DBUG_PRINT(\"info\",(\"%ld records output\", (long) join->send_records));\n  }\n  else\n    rc= -1;\n#ifndef DBUG_OFF\n  if (rc)\n  {\n    DBUG_PRINT(\"error\",(\"Error: do_select() failed\"));\n  }\n#endif\n  rc= join->thd->is_error() ? -1 : rc;\n  DBUG_RETURN(rc);\n}","target":0,"code_token_length":1387,"total_token_length":1623,"max_tokens_setting":2048}
+{"idx":245714,"func":"process_client_headers (struct conn_s *connptr, orderedmap hashofheaders)\n{\n        static const char *skipheaders[] = {\n                \"host\",\n                \"keep-alive\",\n                \"proxy-connection\",\n                \"te\",\n                \"trailers\",\n                \"upgrade\"\n        };\n        int i;\n        size_t iter;\n        int ret = 0;\n\n        char *data, *header;\n\n        \/*\n         * Don't send headers if there's already an error, if the request was\n         * a stats request, or if this was a CONNECT method (unless upstream\n         * http proxy is in use.)\n         *\/\n        if (connptr->server_fd == -1 || connptr->show_stats\n            || (connptr->connect_method && ! UPSTREAM_IS_HTTP(connptr))) {\n                log_message (LOG_INFO,\n                             \"Not sending client headers to remote machine\");\n                return 0;\n        }\n\n        \/*\n         * See if there is a \"Content-Length\" header.  If so, again we need\n         * to do a bit of processing.\n         *\/\n        connptr->content_length.client = get_content_length (hashofheaders);\n\n        \/* Check whether client sends chunked data. *\/\n        if (connptr->content_length.client == -1 && is_chunked_transfer (hashofheaders))\n                connptr->content_length.client = -2;\n\n        \/*\n         * See if there is a \"Connection\" header.  If so, we need to do a bit\n         * of processing. :)\n         *\/\n        remove_connection_headers (hashofheaders);\n\n        \/*\n         * Delete the headers listed in the skipheaders list\n         *\/\n        for (i = 0; i != (sizeof (skipheaders) \/ sizeof (char *)); i++) {\n                orderedmap_remove (hashofheaders, skipheaders[i]);\n        }\n\n        \/* Send, or add the Via header *\/\n        ret = write_via_header (connptr->server_fd, hashofheaders,\n                                connptr->protocol.major,\n                                connptr->protocol.minor);\n        if (ret < 0) {\n                indicate_http_error (connptr, 503,\n                                     \"Could not send data to remote server\",\n                                     \"detail\",\n                                     \"A network error occurred while \"\n                                     \"trying to write data to the remote web server.\",\n                                     NULL);\n                goto PULL_CLIENT_DATA;\n        }\n\n        \/*\n         * Output all the remaining headers to the remote machine.\n         *\/\n        iter = 0;\n        while((iter = orderedmap_next(hashofheaders, iter, &data, &header))) {\n                if (!is_anonymous_enabled (config)\n                    || anonymous_search (config, data) > 0) {\n                        ret =\n                            write_message (connptr->server_fd,\n                                           \"%s: %s\\r\\n\", data, header);\n                        if (ret < 0) {\n                                indicate_http_error (connptr, 503,\n                                                     \"Could not send data to remote server\",\n                                                     \"detail\",\n                                                     \"A network error occurred while \"\n                                                     \"trying to write data to the \"\n                                                     \"remote web server.\",\n                                                     NULL);\n                                goto PULL_CLIENT_DATA;\n                        }\n                }\n        }\n#if defined(XTINYPROXY_ENABLE)\n        if (config->add_xtinyproxy)\n                add_xtinyproxy_header (connptr);\n#endif\n\n        \/* Write the final \"blank\" line to signify the end of the headers *\/\n        if (safe_write (connptr->server_fd, \"\\r\\n\", 2) < 0)\n                return -1;\n\n        \/*\n         * Spin here pulling the data from the client.\n         *\/\nPULL_CLIENT_DATA:\n        if (connptr->content_length.client > 0) {\n                ret = pull_client_data (connptr,\n                                        connptr->content_length.client, 1);\n        } else if (connptr->content_length.client == -2)\n                ret = pull_client_data_chunked (connptr);\n\n        return ret;\n}","target":0,"code_token_length":823,"total_token_length":1059,"max_tokens_setting":2048}
+{"idx":389710,"func":"typval_compare(\n    typval_T\t*tv1,\t\/\/ first operand\n    typval_T\t*tv2,\t\/\/ second operand\n    exprtype_T\ttype,   \/\/ operator\n    int\t\tic)     \/\/ ignore case\n{\n    varnumber_T\tn1, n2;\n    int\t\tres = 0;\n    int\t\ttype_is = type == EXPR_IS || type == EXPR_ISNOT;\n\n    if (type_is && tv1->v_type != tv2->v_type)\n    {\n\t\/\/ For \"is\" a different type always means FALSE, for \"notis\"\n\t\/\/ it means TRUE.\n\tn1 = (type == EXPR_ISNOT);\n    }\n    else if (((tv1->v_type == VAR_SPECIAL && tv1->vval.v_number == VVAL_NULL)\n\t\t|| (tv2->v_type == VAR_SPECIAL\n\t\t\t\t\t   && tv2->vval.v_number == VVAL_NULL))\n\t    && tv1->v_type != tv2->v_type\n\t    && (type == EXPR_EQUAL || type == EXPR_NEQUAL))\n    {\n\tn1 = typval_compare_null(tv1, tv2);\n\tif (n1 == MAYBE)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tif (type == EXPR_NEQUAL)\n\t    n1 = !n1;\n    }\n    else if (tv1->v_type == VAR_BLOB || tv2->v_type == VAR_BLOB)\n    {\n\tif (typval_compare_blob(tv1, tv2, type, &res) == FAIL)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = res;\n    }\n    else if (tv1->v_type == VAR_LIST || tv2->v_type == VAR_LIST)\n    {\n\tif (typval_compare_list(tv1, tv2, type, ic, &res) == FAIL)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = res;\n    }\n    else if (tv1->v_type == VAR_DICT || tv2->v_type == VAR_DICT)\n    {\n\tif (typval_compare_dict(tv1, tv2, type, ic, &res) == FAIL)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = res;\n    }\n    else if (tv1->v_type == VAR_FUNC || tv2->v_type == VAR_FUNC\n\t|| tv1->v_type == VAR_PARTIAL || tv2->v_type == VAR_PARTIAL)\n    {\n\tif (typval_compare_func(tv1, tv2, type, ic, &res) == FAIL)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = res;\n    }\n\n#ifdef FEAT_FLOAT\n    \/\/ If one of the two variables is a float, compare as a float.\n    \/\/ When using \"=~\" or \"!~\", always compare as string.\n    else if ((tv1->v_type == VAR_FLOAT || tv2->v_type == VAR_FLOAT)\n\t    && type != EXPR_MATCH && type != EXPR_NOMATCH)\n    {\n\tfloat_T f1, f2;\n\tint\terror = FALSE;\n\n\tf1 = tv_get_float_chk(tv1, &error);\n\tif (!error)\n\t    f2 = tv_get_float_chk(tv2, &error);\n\tif (error)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = FALSE;\n\tswitch (type)\n\t{\n\t    case EXPR_IS:\n\t    case EXPR_EQUAL:    n1 = (f1 == f2); break;\n\t    case EXPR_ISNOT:\n\t    case EXPR_NEQUAL:   n1 = (f1 != f2); break;\n\t    case EXPR_GREATER:  n1 = (f1 > f2); break;\n\t    case EXPR_GEQUAL:   n1 = (f1 >= f2); break;\n\t    case EXPR_SMALLER:  n1 = (f1 < f2); break;\n\t    case EXPR_SEQUAL:   n1 = (f1 <= f2); break;\n\t    case EXPR_UNKNOWN:\n\t    case EXPR_MATCH:\n\t    default:  break;  \/\/ avoid gcc warning\n\t}\n    }\n#endif\n\n    \/\/ If one of the two variables is a number, compare as a number.\n    \/\/ When using \"=~\" or \"!~\", always compare as string.\n    else if ((tv1->v_type == VAR_NUMBER || tv2->v_type == VAR_NUMBER)\n\t    && type != EXPR_MATCH && type != EXPR_NOMATCH)\n    {\n\tint error = FALSE;\n\n\tn1 = tv_get_number_chk(tv1, &error);\n\tif (!error)\n\t    n2 = tv_get_number_chk(tv2, &error);\n\tif (error)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tswitch (type)\n\t{\n\t    case EXPR_IS:\n\t    case EXPR_EQUAL:    n1 = (n1 == n2); break;\n\t    case EXPR_ISNOT:\n\t    case EXPR_NEQUAL:   n1 = (n1 != n2); break;\n\t    case EXPR_GREATER:  n1 = (n1 > n2); break;\n\t    case EXPR_GEQUAL:   n1 = (n1 >= n2); break;\n\t    case EXPR_SMALLER:  n1 = (n1 < n2); break;\n\t    case EXPR_SEQUAL:   n1 = (n1 <= n2); break;\n\t    case EXPR_UNKNOWN:\n\t    case EXPR_MATCH:\n\t    default:  break;  \/\/ avoid gcc warning\n\t}\n    }\n    else if (in_vim9script() && (tv1->v_type == VAR_BOOL\n\t\t\t\t    || tv2->v_type == VAR_BOOL\n\t\t\t\t    || (tv1->v_type == VAR_SPECIAL\n\t\t\t\t\t      && tv2->v_type == VAR_SPECIAL)))\n    {\n\tif (tv1->v_type != tv2->v_type)\n\t{\n\t    semsg(_(e_cannot_compare_str_with_str),\n\t\t       vartype_name(tv1->v_type), vartype_name(tv2->v_type));\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = tv1->vval.v_number;\n\tn2 = tv2->vval.v_number;\n\tswitch (type)\n\t{\n\t    case EXPR_IS:\n\t    case EXPR_EQUAL:    n1 = (n1 == n2); break;\n\t    case EXPR_ISNOT:\n\t    case EXPR_NEQUAL:   n1 = (n1 != n2); break;\n\t    default:\n\t\tsemsg(_(e_invalid_operation_for_str),\n\t\t\t\t\t\t   vartype_name(tv1->v_type));\n\t\tclear_tv(tv1);\n\t\treturn FAIL;\n\t}\n    }\n#ifdef FEAT_JOB_CHANNEL\n    else if (tv1->v_type == tv2->v_type\n\t    && (tv1->v_type == VAR_CHANNEL || tv1->v_type == VAR_JOB)\n\t    && (type == EXPR_NEQUAL || type == EXPR_EQUAL))\n    {\n\tif (tv1->v_type == VAR_CHANNEL)\n\t    n1 = tv1->vval.v_channel == tv2->vval.v_channel;\n\telse\n\t    n1 = tv1->vval.v_job == tv2->vval.v_job;\n\tif (type == EXPR_NEQUAL)\n\t    n1 = !n1;\n    }\n#endif\n    else\n    {\n\tif (typval_compare_string(tv1, tv2, type, ic, &res) == FAIL)\n\t{\n\t    clear_tv(tv1);\n\t    return FAIL;\n\t}\n\tn1 = res;\n    }\n    clear_tv(tv1);\n    if (in_vim9script())\n    {\n\ttv1->v_type = VAR_BOOL;\n\ttv1->vval.v_number = n1 ? VVAL_TRUE : VVAL_FALSE;\n    }\n    else\n    {\n\ttv1->v_type = VAR_NUMBER;\n\ttv1->vval.v_number = n1;\n    }\n\n    return OK;\n}","target":0,"code_token_length":1682,"total_token_length":1918,"max_tokens_setting":2048}
+{"idx":195289,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& indices = context->input(0);\n    const Tensor& values = context->input(1);\n    const Tensor& shape = context->input(2);\n    const Tensor& weights = context->input(3);\n    bool use_weights = weights.NumElements() > 0;\n\n    OP_REQUIRES(context, TensorShapeUtils::IsMatrix(indices.shape()),\n                errors::InvalidArgument(\n                    \"Input indices must be a 2-dimensional tensor. Got: \",\n                    indices.shape().DebugString()));\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(values.shape()),\n                errors::InvalidArgument(\"Input values must be a vector. Got: \",\n                                        values.shape().DebugString()));\n    OP_REQUIRES(context, TensorShapeUtils::IsVector(shape.shape()),\n                errors::InvalidArgument(\"Input shape must be a vector. Got: \",\n                                        shape.shape().DebugString()));\n    OP_REQUIRES(context,\n                values.shape().dim_size(0) == indices.shape().dim_size(0),\n                errors::InvalidArgument(\n                    \"Number of values must match first dimension of indices.\",\n                    \"Got \", values.shape().dim_size(0),\n                    \" values, indices shape: \", indices.shape().DebugString()));\n    OP_REQUIRES(\n        context, shape.shape().dim_size(0) == indices.shape().dim_size(1),\n        errors::InvalidArgument(\n            \"Number of dimensions must match second dimension of indices.\",\n            \"Got \", shape.shape().dim_size(0),\n            \" dimensions, indices shape: \", indices.shape().DebugString()));\n    OP_REQUIRES(context, shape.NumElements() > 0,\n                errors::InvalidArgument(\n                    \"The shape argument requires at least one element.\"));\n\n    if (use_weights) {\n      OP_REQUIRES(\n          context, weights.shape() == values.shape(),\n          errors::InvalidArgument(\n              \"Weights and values must have the same shape. Weight shape: \",\n              weights.shape().DebugString(),\n              \"; values shape: \", values.shape().DebugString()));\n    }\n\n    bool is_1d = shape.NumElements() == 1;\n    auto shape_vector = shape.flat<int64_t>();\n    int num_batches = is_1d ? 1 : shape_vector(0);\n    int num_values = values.NumElements();\n\n    const auto indices_values = indices.matrix<int64_t>();\n    const auto values_values = values.flat<T>();\n    const auto weight_values = weights.flat<W>();\n\n    auto per_batch_counts = BatchedMap<W>(num_batches);\n\n    T max_value = 0;\n\n    for (int idx = 0; idx < num_values; ++idx) {\n      int batch = is_1d ? 0 : indices_values(idx, 0);\n      if (batch >= num_batches) {\n        OP_REQUIRES(context, batch < num_batches,\n                    errors::InvalidArgument(\n                        \"Indices value along the first dimension must be \",\n                        \"lower than the first index of the shape.\", \"Got \",\n                        batch, \" as batch and \", num_batches,\n                        \" as the first dimension of the shape.\"));\n      }\n      const auto& value = values_values(idx);\n      if (value >= 0 && (maxlength_ <= 0 || value < maxlength_)) {\n        if (binary_output_) {\n          per_batch_counts[batch][value] = 1;\n        } else if (use_weights) {\n          per_batch_counts[batch][value] += weight_values(idx);\n        } else {\n          per_batch_counts[batch][value]++;\n        }\n        if (value > max_value) {\n          max_value = value;\n        }\n      }\n    }\n\n    int num_output_values = GetOutputSize(max_value, maxlength_, minlength_);\n    OP_REQUIRES_OK(context, OutputSparse<W>(per_batch_counts, num_output_values,\n                                            is_1d, context));\n  }","target":1,"code_token_length":799,"total_token_length":1035,"max_tokens_setting":2048}
+{"idx":256138,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& a = ctx->input(0);\n    const Tensor& b = ctx->input(1);\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(a.shape()),\n                errors::InvalidArgument(\"a is not a matrix\"));\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(b.shape()),\n                errors::InvalidArgument(\"b is not a matrix\"));\n\n    const int m = transpose_a_ ? a.dim_size(1) : a.dim_size(0);\n    const int k = transpose_a_ ? a.dim_size(0) : a.dim_size(1);\n    const int n = transpose_b_ ? b.dim_size(0) : b.dim_size(1);\n    const int k2 = transpose_b_ ? b.dim_size(1) : b.dim_size(0);\n\n    OP_REQUIRES(ctx, k == k2,\n                errors::InvalidArgument(\n                    \"Matrix size incompatible: a: \", a.shape().DebugString(),\n                    \", b: \", b.shape().DebugString()));\n    OP_REQUIRES(ctx, m >= 0 && n >= 0 && k >= 0,\n                errors::InvalidArgument(\n                    \"Matrix dimensions cannot be negative: a: \",\n                    a.shape().DebugString(), \", b: \", b.shape().DebugString()));\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({m, n}), &output));\n\n    \/\/ Return early if at least one of the output dimension size is 0.\n    if (m == 0 || n == 0) {\n      return;\n    }\n\n    if (k == 0) {\n      \/\/ If the inner dimension k in the matrix multiplication is zero, we fill\n      \/\/ the output with zeros.\n      functor::SetZeroFunctor<CPUDevice, float> f;\n      f(ctx->eigen_device<CPUDevice>(), output->flat<float>());\n      return;\n    }\n\n    auto out = output->matrix<float>();\n\n    std::unique_ptr<Tensor> a_float;\n    std::unique_ptr<Tensor> b_float;\n    if (!a_is_sparse_ && !b_is_sparse_) {\n      auto left = &a;\n      auto right = &b;\n      \/\/ TODO(agarwal): multi-thread the conversions from bfloat16 to float.\n      if (std::is_same<TL, bfloat16>::value) {\n        a_float.reset(new Tensor(DT_FLOAT, a.shape()));\n        BFloat16ToFloat(a.flat<bfloat16>().data(),\n                        a_float->flat<float>().data(), a.NumElements());\n        left = a_float.get();\n      }\n      if (std::is_same<TR, bfloat16>::value) {\n        b_float.reset(new Tensor(DT_FLOAT, b.shape()));\n        BFloat16ToFloat(b.flat<bfloat16>().data(),\n                        b_float->flat<float>().data(), b.NumElements());\n        right = b_float.get();\n      }\n      Eigen::array<Eigen::IndexPair<Eigen::DenseIndex>, 1> dim_pair;\n      dim_pair[0].first = transpose_a_ ? 0 : 1;\n      dim_pair[0].second = transpose_b_ ? 1 : 0;\n\n      out.device(ctx->template eigen_device<CPUDevice>()) =\n          left->matrix<float>().contract(right->matrix<float>(), dim_pair);\n      return;\n    }\n\n    auto left = &a;\n    auto right = &b;\n    bool transpose_output = false;\n    bool transpose_a = transpose_a_;\n    bool transpose_b = transpose_b_;\n    if (!a_is_sparse_) {\n      \/\/ Swap the order of multiplications using the identity:\n      \/\/ A * B = (B' *  A')'.\n      std::swap(left, right);\n      std::swap(transpose_a, transpose_b);\n      transpose_a = !transpose_a;\n      transpose_b = !transpose_b;\n      transpose_output = !transpose_output;\n    }\n\n    std::unique_ptr<Tensor> right_tr;\n    if (transpose_b) {\n      \/\/ TODO(agarwal): avoid transposing the matrix here and directly handle\n      \/\/ transpose in CreateDenseSlices.\n      OP_REQUIRES(ctx, right->dim_size(0) != 0,\n                  errors::InvalidArgument(\"b has an entry 0 in it's shape.\"));\n      OP_REQUIRES(ctx, right->dim_size(1) != 0,\n                  errors::InvalidArgument(\"b has an entry 0 in it's shape.\"));\n      right_tr.reset(\n          new Tensor(right->dtype(),\n                     TensorShape({right->dim_size(1), right->dim_size(0)})));\n\n      const auto perm = dsizes_10();\n      if (transpose_output) {\n        right_tr->matrix<TL>().device(ctx->template eigen_device<CPUDevice>()) =\n            right->matrix<TL>().shuffle(perm);\n      } else {\n        right_tr->matrix<TR>().device(ctx->template eigen_device<CPUDevice>()) =\n            right->matrix<TR>().shuffle(perm);\n      }\n      right = right_tr.get();\n    }\n\n    if (transpose_output) {\n      DoMatMul<TR, TL>::Compute(&this->cache_tr_, left->matrix<TR>(),\n                                right->matrix<TL>(), transpose_a,\n                                ctx->device()->tensorflow_cpu_worker_threads(),\n                                transpose_output, &out);\n    } else {\n      DoMatMul<TL, TR>::Compute(&this->cache_nt_, left->matrix<TL>(),\n                                right->matrix<TR>(), transpose_a,\n                                ctx->device()->tensorflow_cpu_worker_threads(),\n                                transpose_output, &out);\n    }\n  }","target":0,"code_token_length":1185,"total_token_length":1421,"max_tokens_setting":2048}
+{"idx":318766,"func":"drill_parse_header_is_metric(gerb_file_t *fd, drill_state_t *state,\n\t\t\tgerbv_image_t *image, ssize_t file_line)\n{\n    gerbv_drill_stats_t *stats = image->drill_stats;\n    char c, op[3];\n\n    dprintf(\"    %s(): entering\\n\", __FUNCTION__);\n\n    \/* METRIC is not an actual M code but a command that is only\n     * acceptable within the header.\n     *\n     * The syntax is\n     * METRIC[,{TZ|LZ}][,{000.000|000.00|0000.00}]\n     *\/\n\n    if (DRILL_HEADER != state->curr_section)\n\treturn 0;\n\n    switch (file_check_str(fd, \"METRIC\")) {\n    case -1:\n\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t_(\"Unexpected EOF found while parsing \\\"%s\\\" string \"\n\t\t    \"in file \\\"%s\\\"\"), \"METRIC\", fd->filename);\n\treturn 0;\n\n    case 0:\n\treturn 0;\n    }\n\nheader_again:\n\n    if (',' != gerb_fgetc(fd)) {\n\tgerb_ungetc(fd);\n\teat_line(fd);\n    } else {\n\t\/* Is it TZ, LZ, or zerofmt? *\/\n\tswitch (c = gerb_fgetc(fd)) {\n\tcase 'T':\n\tcase 'L':\n\t    if ('Z' != gerb_fgetc(fd))\n\t\tgoto header_junk;\n\n\t    if (c == 'L') {\n\t\tdprintf (\"    %s(): Detected a file that probably has \"\n\t\t\t\"trailing zero suppression\\n\", __FUNCTION__);\n\t\tif (state->autod)\n\t\t    image->format->omit_zeros = GERBV_OMIT_ZEROS_TRAILING;\n\t    } else {\n\t\tdprintf (\"    %s(): Detected a file that probably has \"\n\t\t\t\"leading zero suppression\\n\", __FUNCTION__);\n\t\tif (state->autod)\n\t\t    image->format->omit_zeros = GERBV_OMIT_ZEROS_LEADING;\n\t    }\n\n\t    if (state->autod) {\n\t\t\/* Default metric number format is 6-digit, 1 um\n\t\t * resolution.  The header number format (for T#C#\n\t\t * definitions) is fixed to that, while the number\n\t\t * format within the file can differ. *\/\n\t\tstate->header_number_format =\n\t\t    state->number_format = FMT_000_000;\n\t\tstate->decimals = 3;\n\t    }\n\n\t    if (',' == gerb_fgetc(fd))\n\t\t\/* Anticipate number format will follow *\/\n\t\tgoto header_again;\n\n\t    gerb_ungetc(fd);\n\n\t    break;\n\n\tcase '0':\n\t    if ('0' != gerb_fgetc(fd)\n\t    ||  '0' != gerb_fgetc(fd))\n\t\tgoto header_junk;\n\n\t    \/* We just parsed three 0s, the remainder options\n\t       so far are: .000 | .00 | 0.00 *\/\n\t    op[0] = gerb_fgetc(fd);\n\t    op[1] = gerb_fgetc(fd);\n\t    op[2] = '\\0';\n\t    if (EOF == op[0]\n\t    ||  EOF == op[1])\n\t\tgoto header_junk;\n\n\t    if (0 == strcmp(op, \"0.\")) {\n\t\t\/* expecting FMT_0000_00,\n\t\t   two trailing 0s must follow *\/\n\t\tif ('0' != gerb_fgetc(fd)\n\t\t||  '0' != gerb_fgetc(fd))\n\t\t    goto header_junk;\n\n\t\teat_line(fd);\n\n\t\tif (state->autod) {\n\t\t    state->number_format = FMT_0000_00;\n\t\t    state->decimals = 2;\n\t\t}\n\t\tbreak;\n\t    }\n\n\t    if (0 != strcmp(op, \".0\"))\n\t\tgoto header_junk;\n\n\t    \/* Must be either FMT_000_000 or FMT_000_00, depending\n\t     * on whether one or two 0s are following *\/\n\t    if ('0' != gerb_fgetc(fd))\n\t\tgoto header_junk;\n\n\t    if ('0' == gerb_fgetc(fd)\n\t    &&  state->autod) {\n\t\tstate->number_format = FMT_000_000;\n\t\tstate->decimals = 3;\n\t    } else {\n\t\tgerb_ungetc(fd);\n\n\t\tif (state->autod) {\n\t\t    state->number_format = FMT_000_00;\n\t\t    state->decimals = 2;\n\t\t}\n\t    }\n\n\t    eat_line(fd);\n\t    break;\n\n\tdefault:\nheader_junk:\n\t    gerb_ungetc(fd);\n\t    eat_line(fd);\n\n\t    gerbv_stats_printf(stats->error_list,\n\t\t    GERBV_MESSAGE_WARNING, -1,\n\t\t    _(\"Found junk after METRIC command \"\n\t\t\t\"at line %ld in file \\\"%s\\\"\"),\n\t\t    file_line, fd->filename);\n\t    break;\n\t}\n    }\n\n    state->unit = GERBV_UNIT_MM;\n\n    return 1;\n} \/* drill_parse_header_is_metric() *\/","target":0,"code_token_length":1100,"total_token_length":1336,"max_tokens_setting":2048}
+{"idx":489137,"func":"static sctp_disposition_t sctp_sf_do_unexpected_init(\n\tconst struct sctp_endpoint *ep,\n\tconst struct sctp_association *asoc,\n\tconst sctp_subtype_t type,\n\tvoid *arg, sctp_cmd_seq_t *commands)\n{\n\tsctp_disposition_t retval;\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sctp_chunk *repl;\n\tstruct sctp_association *new_asoc;\n\tstruct sctp_chunk *err_chunk;\n\tstruct sctp_packet *packet;\n\tsctp_unrecognized_param_t *unk_param;\n\tint len;\n\n\t\/* 6.10 Bundling\n\t * An endpoint MUST NOT bundle INIT, INIT ACK or\n\t * SHUTDOWN COMPLETE with any other chunks.\n\t *\n\t * IG Section 2.11.2\n\t * Furthermore, we require that the receiver of an INIT chunk MUST\n\t * enforce these rules by silently discarding an arriving packet\n\t * with an INIT chunk that is bundled with other chunks.\n\t *\/\n\tif (!chunk->singleton)\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* 3.1 A packet containing an INIT chunk MUST have a zero Verification\n\t * Tag.\n\t *\/\n\tif (chunk->sctp_hdr->vtag != 0)\n\t\treturn sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the INIT chunk has a valid length.\n\t * In this case, we generate a protocol violation since we have\n\t * an association established.\n\t *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\t\/* Grab the INIT header.  *\/\n\tchunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data;\n\n\t\/* Tag the variable length parameters.  *\/\n\tchunk->param_hdr.v = skb_pull(chunk->skb, sizeof(sctp_inithdr_t));\n\n\t\/* Verify the INIT chunk before processing it. *\/\n\terr_chunk = NULL;\n\tif (!sctp_verify_init(asoc, chunk->chunk_hdr->type,\n\t\t\t      (sctp_init_chunk_t *)chunk->chunk_hdr, chunk,\n\t\t\t      &err_chunk)) {\n\t\t\/* This chunk contains fatal error. It is to be discarded.\n\t\t * Send an ABORT, with causes if there is any.\n\t\t *\/\n\t\tif (err_chunk) {\n\t\t\tpacket = sctp_abort_pkt_new(ep, asoc, arg,\n\t\t\t\t\t(__u8 *)(err_chunk->chunk_hdr) +\n\t\t\t\t\tsizeof(sctp_chunkhdr_t),\n\t\t\t\t\tntohs(err_chunk->chunk_hdr->length) -\n\t\t\t\t\tsizeof(sctp_chunkhdr_t));\n\n\t\t\tif (packet) {\n\t\t\t\tsctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,\n\t\t\t\t\t\tSCTP_PACKET(packet));\n\t\t\t\tSCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);\n\t\t\t\tretval = SCTP_DISPOSITION_CONSUME;\n\t\t\t} else {\n\t\t\t\tretval = SCTP_DISPOSITION_NOMEM;\n\t\t\t}\n\t\t\tgoto cleanup;\n\t\t} else {\n\t\t\treturn sctp_sf_tabort_8_4_8(ep, asoc, type, arg,\n\t\t\t\t\t\t    commands);\n\t\t}\n\t}\n\n\t\/*\n\t * Other parameters for the endpoint SHOULD be copied from the\n\t * existing parameters of the association (e.g. number of\n\t * outbound streams) into the INIT ACK and cookie.\n\t * FIXME:  We are copying parameters from the endpoint not the\n\t * association.\n\t *\/\n\tnew_asoc = sctp_make_temp_asoc(ep, chunk, GFP_ATOMIC);\n\tif (!new_asoc)\n\t\tgoto nomem;\n\n\t\/* In the outbound INIT ACK the endpoint MUST copy its current\n\t * Verification Tag and Peers Verification tag into a reserved\n\t * place (local tie-tag and per tie-tag) within the state cookie.\n\t *\/\n\tif (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,\n\t\t\t       sctp_source(chunk),\n\t\t\t       (sctp_init_chunk_t *)chunk->chunk_hdr,\n\t\t\t       GFP_ATOMIC))\n\t\tgoto nomem;\n\n\t\/* Make sure no new addresses are being added during the\n\t * restart.   Do not do this check for COOKIE-WAIT state,\n\t * since there are no peer addresses to check against.\n\t * Upon return an ABORT will have been sent if needed.\n\t *\/\n\tif (!sctp_state(asoc, COOKIE_WAIT)) {\n\t\tif (!sctp_sf_check_restart_addrs(new_asoc, asoc, chunk,\n\t\t\t\t\t\t commands)) {\n\t\t\tretval = SCTP_DISPOSITION_CONSUME;\n\t\t\tgoto nomem_retval;\n\t\t}\n\t}\n\n\tsctp_tietags_populate(new_asoc, asoc);\n\n\t\/* B) \"Z\" shall respond immediately with an INIT ACK chunk.  *\/\n\n\t\/* If there are errors need to be reported for unknown parameters,\n\t * make sure to reserve enough room in the INIT ACK for them.\n\t *\/\n\tlen = 0;\n\tif (err_chunk) {\n\t\tlen = ntohs(err_chunk->chunk_hdr->length) -\n\t\t\tsizeof(sctp_chunkhdr_t);\n\t}\n\n\tif (sctp_assoc_set_bind_addr_from_ep(new_asoc, GFP_ATOMIC) < 0)\n\t\tgoto nomem;\n\n\trepl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len);\n\tif (!repl)\n\t\tgoto nomem;\n\n\t\/* If there are errors need to be reported for unknown parameters,\n\t * include them in the outgoing INIT ACK as \"Unrecognized parameter\"\n\t * parameter.\n\t *\/\n\tif (err_chunk) {\n\t\t\/* Get the \"Unrecognized parameter\" parameter(s) out of the\n\t\t * ERROR chunk generated by sctp_verify_init(). Since the\n\t\t * error cause code for \"unknown parameter\" and the\n\t\t * \"Unrecognized parameter\" type is the same, we can\n\t\t * construct the parameters in INIT ACK by copying the\n\t\t * ERROR causes over.\n\t\t *\/\n\t\tunk_param = (sctp_unrecognized_param_t *)\n\t\t\t    ((__u8 *)(err_chunk->chunk_hdr) +\n\t\t\t    sizeof(sctp_chunkhdr_t));\n\t\t\/* Replace the cause code with the \"Unrecognized parameter\"\n\t\t * parameter type.\n\t\t *\/\n\t\tsctp_addto_chunk(repl, len, unk_param);\n\t}\n\n\tsctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc));\n\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));\n\n\t\/*\n\t * Note: After sending out INIT ACK with the State Cookie parameter,\n\t * \"Z\" MUST NOT allocate any resources for this new association.\n\t * Otherwise, \"Z\" will be vulnerable to resource attacks.\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());\n\tretval = SCTP_DISPOSITION_CONSUME;\n\n\treturn retval;\n\nnomem:\n\tretval = SCTP_DISPOSITION_NOMEM;\nnomem_retval:\n\tif (new_asoc)\n\t\tsctp_association_free(new_asoc);\ncleanup:\n\tif (err_chunk)\n\t\tsctp_chunk_free(err_chunk);\n\treturn retval;\n}","target":0,"code_token_length":1496,"total_token_length":1732,"max_tokens_setting":2048}
+{"idx":379322,"func":"parse_cmd_address(exarg_T *eap, char **errormsg, int silent)\n{\n    int\t\taddress_count = 1;\n    linenr_T\tlnum;\n    int\t\tneed_check_cursor = FALSE;\n    int\t\tret = FAIL;\n\n    \/\/ Repeat for all ',' or ';' separated addresses.\n    for (;;)\n    {\n\teap->line1 = eap->line2;\n\teap->line2 = default_address(eap);\n\teap->cmd = skipwhite(eap->cmd);\n\tlnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,\n\t\t\t\t\teap->addr_count == 0, address_count++);\n\tif (eap->cmd == NULL)\t\/\/ error detected\n\t    goto theend;\n\tif (lnum == MAXLNUM)\n\t{\n\t    if (*eap->cmd == '%')   \/\/ '%' - all lines\n\t    {\n\t\t++eap->cmd;\n\t\tswitch (eap->addr_type)\n\t\t{\n\t\t    case ADDR_LINES:\n\t\t    case ADDR_OTHER:\n\t\t\teap->line1 = 1;\n\t\t\teap->line2 = curbuf->b_ml.ml_line_count;\n\t\t\tbreak;\n\t\t    case ADDR_LOADED_BUFFERS:\n\t\t\t{\n\t\t\t    buf_T\t*buf = firstbuf;\n\n\t\t\t    while (buf->b_next != NULL\n\t\t\t\t\t\t  && buf->b_ml.ml_mfp == NULL)\n\t\t\t\tbuf = buf->b_next;\n\t\t\t    eap->line1 = buf->b_fnum;\n\t\t\t    buf = lastbuf;\n\t\t\t    while (buf->b_prev != NULL\n\t\t\t\t\t\t  && buf->b_ml.ml_mfp == NULL)\n\t\t\t\tbuf = buf->b_prev;\n\t\t\t    eap->line2 = buf->b_fnum;\n\t\t\t    break;\n\t\t\t}\n\t\t    case ADDR_BUFFERS:\n\t\t\teap->line1 = firstbuf->b_fnum;\n\t\t\teap->line2 = lastbuf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_WINDOWS:\n\t\t    case ADDR_TABS:\n\t\t\tif (IS_USER_CMDIDX(eap->cmdidx))\n\t\t\t{\n\t\t\t    eap->line1 = 1;\n\t\t\t    eap->line2 = eap->addr_type == ADDR_WINDOWS\n\t\t\t\t\t\t  ? LAST_WIN_NR : LAST_TAB_NR;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ there is no Vim command which uses '%' and\n\t\t\t    \/\/ ADDR_WINDOWS or ADDR_TABS\n\t\t\t    *errormsg = _(e_invalid_range);\n\t\t\t    goto theend;\n\t\t\t}\n\t\t\tbreak;\n\t\t    case ADDR_TABS_RELATIVE:\n\t\t    case ADDR_UNSIGNED:\n\t\t    case ADDR_QUICKFIX:\n\t\t\t*errormsg = _(e_invalid_range);\n\t\t\tgoto theend;\n\t\t    case ADDR_ARGUMENTS:\n\t\t\tif (ARGCOUNT == 0)\n\t\t\t    eap->line1 = eap->line2 = 0;\n\t\t\telse\n\t\t\t{\n\t\t\t    eap->line1 = 1;\n\t\t\t    eap->line2 = ARGCOUNT;\n\t\t\t}\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX_VALID:\n#ifdef FEAT_QUICKFIX\n\t\t\teap->line1 = 1;\n\t\t\teap->line2 = qf_get_valid_size(eap);\n\t\t\tif (eap->line2 == 0)\n\t\t\t    eap->line2 = 1;\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_NONE:\n\t\t\t\/\/ Will give an error later if a range is found.\n\t\t\tbreak;\n\t\t}\n\t\t++eap->addr_count;\n\t    }\n\t    else if (*eap->cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)\n\t    {\n\t\tpos_T\t    *fp;\n\n\t\t\/\/ '*' - visual area\n\t\tif (eap->addr_type != ADDR_LINES)\n\t\t{\n\t\t    *errormsg = _(e_invalid_range);\n\t\t    goto theend;\n\t\t}\n\n\t\t++eap->cmd;\n\t\tif (!eap->skip)\n\t\t{\n\t\t    fp = getmark('<', FALSE);\n\t\t    if (check_mark(fp) == FAIL)\n\t\t\tgoto theend;\n\t\t    eap->line1 = fp->lnum;\n\t\t    fp = getmark('>', FALSE);\n\t\t    if (check_mark(fp) == FAIL)\n\t\t\tgoto theend;\n\t\t    eap->line2 = fp->lnum;\n\t\t    ++eap->addr_count;\n\t\t}\n\t    }\n\t}\n\telse\n\t    eap->line2 = lnum;\n\teap->addr_count++;\n\n\tif (*eap->cmd == ';')\n\t{\n\t    if (!eap->skip)\n\t    {\n\t\tcurwin->w_cursor.lnum = eap->line2;\n\n\t\t\/\/ Don't leave the cursor on an illegal line or column, but do\n\t\t\/\/ accept zero as address, so 0;\/PATTERN\/ works correctly\n\t\t\/\/ (where zero usually means to use the first line).\n\t\t\/\/ Check the cursor position before returning.\n\t\tif (eap->line2 > 0)\n\t\t    check_cursor();\n\t\telse\n\t\t    check_cursor_col();\n\t\tneed_check_cursor = TRUE;\n\t    }\n\t}\n\telse if (*eap->cmd != ',')\n\t    break;\n\t++eap->cmd;\n    }\n\n    \/\/ One address given: set start and end lines.\n    if (eap->addr_count == 1)\n    {\n\teap->line1 = eap->line2;\n\t\/\/ ... but only implicit: really no address given\n\tif (lnum == MAXLNUM)\n\t    eap->addr_count = 0;\n    }\n    ret = OK;\n\ntheend:\n    if (need_check_cursor)\n\tcheck_cursor();\n    return ret;\n}","target":0,"code_token_length":1173,"total_token_length":1409,"max_tokens_setting":2048}
+{"idx":437407,"func":"translate_ring_addresses(struct virtio_net *dev, int vq_index)\n{\n\tstruct vhost_virtqueue *vq = dev->virtqueue[vq_index];\n\tstruct vhost_vring_addr *addr = &vq->ring_addrs;\n\tuint64_t len, expected_len;\n\n\tif (vq_is_packed(dev)) {\n\t\tlen = sizeof(struct vring_packed_desc) * vq->size;\n\t\tvq->desc_packed = (struct vring_packed_desc *)(uintptr_t)\n\t\t\tring_addr_to_vva(dev, vq, addr->desc_user_addr, &len);\n\t\tvq->log_guest_addr = 0;\n\t\tif (vq->desc_packed == NULL ||\n\t\t\t\tlen != sizeof(struct vring_packed_desc) *\n\t\t\t\tvq->size) {\n\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\t\"(%d) failed to map desc_packed ring.\\n\",\n\t\t\t\tdev->vid);\n\t\t\treturn dev;\n\t\t}\n\n\t\tdev = numa_realloc(dev, vq_index);\n\t\tvq = dev->virtqueue[vq_index];\n\t\taddr = &vq->ring_addrs;\n\n\t\tlen = sizeof(struct vring_packed_desc_event);\n\t\tvq->driver_event = (struct vring_packed_desc_event *)\n\t\t\t\t\t(uintptr_t)ring_addr_to_vva(dev,\n\t\t\t\t\tvq, addr->avail_user_addr, &len);\n\t\tif (vq->driver_event == NULL ||\n\t\t\t\tlen != sizeof(struct vring_packed_desc_event)) {\n\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\t\"(%d) failed to find driver area address.\\n\",\n\t\t\t\tdev->vid);\n\t\t\treturn dev;\n\t\t}\n\n\t\tlen = sizeof(struct vring_packed_desc_event);\n\t\tvq->device_event = (struct vring_packed_desc_event *)\n\t\t\t\t\t(uintptr_t)ring_addr_to_vva(dev,\n\t\t\t\t\tvq, addr->used_user_addr, &len);\n\t\tif (vq->device_event == NULL ||\n\t\t\t\tlen != sizeof(struct vring_packed_desc_event)) {\n\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\t\"(%d) failed to find device area address.\\n\",\n\t\t\t\tdev->vid);\n\t\t\treturn dev;\n\t\t}\n\n\t\tvq->access_ok = 1;\n\t\treturn dev;\n\t}\n\n\t\/* The addresses are converted from QEMU virtual to Vhost virtual. *\/\n\tif (vq->desc && vq->avail && vq->used)\n\t\treturn dev;\n\n\tlen = sizeof(struct vring_desc) * vq->size;\n\tvq->desc = (struct vring_desc *)(uintptr_t)ring_addr_to_vva(dev,\n\t\t\tvq, addr->desc_user_addr, &len);\n\tif (vq->desc == 0 || len != sizeof(struct vring_desc) * vq->size) {\n\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\"(%d) failed to map desc ring.\\n\",\n\t\t\tdev->vid);\n\t\treturn dev;\n\t}\n\n\tdev = numa_realloc(dev, vq_index);\n\tvq = dev->virtqueue[vq_index];\n\taddr = &vq->ring_addrs;\n\n\tlen = sizeof(struct vring_avail) + sizeof(uint16_t) * vq->size;\n\tif (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))\n\t\tlen += sizeof(uint16_t);\n\texpected_len = len;\n\tvq->avail = (struct vring_avail *)(uintptr_t)ring_addr_to_vva(dev,\n\t\t\tvq, addr->avail_user_addr, &len);\n\tif (vq->avail == 0 || len != expected_len) {\n\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\"(%d) failed to map avail ring.\\n\",\n\t\t\tdev->vid);\n\t\treturn dev;\n\t}\n\n\tlen = sizeof(struct vring_used) +\n\t\tsizeof(struct vring_used_elem) * vq->size;\n\tif (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))\n\t\tlen += sizeof(uint16_t);\n\texpected_len = len;\n\tvq->used = (struct vring_used *)(uintptr_t)ring_addr_to_vva(dev,\n\t\t\tvq, addr->used_user_addr, &len);\n\tif (vq->used == 0 || len != expected_len) {\n\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\"(%d) failed to map used ring.\\n\",\n\t\t\tdev->vid);\n\t\treturn dev;\n\t}\n\n\tif (vq->last_used_idx != vq->used->idx) {\n\t\tRTE_LOG(WARNING, VHOST_CONFIG,\n\t\t\t\"last_used_idx (%u) and vq->used->idx (%u) mismatches; \"\n\t\t\t\"some packets maybe resent for Tx and dropped for Rx\\n\",\n\t\t\tvq->last_used_idx, vq->used->idx);\n\t\tvq->last_used_idx  = vq->used->idx;\n\t\tvq->last_avail_idx = vq->used->idx;\n\t}\n\n\tvq->log_guest_addr =\n\t\ttranslate_log_addr(dev, vq, addr->log_guest_addr);\n\tif (vq->log_guest_addr == 0) {\n\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n\t\t\t\"(%d) failed to map log_guest_addr .\\n\",\n\t\t\tdev->vid);\n\t\treturn dev;\n\t}\n\tvq->access_ok = 1;\n\n\tVHOST_LOG_DEBUG(VHOST_CONFIG, \"(%d) mapped address desc: %p\\n\",\n\t\t\tdev->vid, vq->desc);\n\tVHOST_LOG_DEBUG(VHOST_CONFIG, \"(%d) mapped address avail: %p\\n\",\n\t\t\tdev->vid, vq->avail);\n\tVHOST_LOG_DEBUG(VHOST_CONFIG, \"(%d) mapped address used: %p\\n\",\n\t\t\tdev->vid, vq->used);\n\tVHOST_LOG_DEBUG(VHOST_CONFIG, \"(%d) log_guest_addr: %\" PRIx64 \"\\n\",\n\t\t\tdev->vid, vq->log_guest_addr);\n\n\treturn dev;\n}","target":0,"code_token_length":1261,"total_token_length":1497,"max_tokens_setting":2048}
+{"idx":270920,"func":"  ::tensorflow::Status MakeSplits(\n      const Tensor& indices_in, const OpInputList& params_nested_splits_in,\n      SPLITS_TYPE num_params_dense_values,\n      std::vector<std::vector<SPLITS_TYPE>>* out_splits,\n      std::vector<std::pair<SPLITS_TYPE, SPLITS_TYPE>>* value_slices,\n      SPLITS_TYPE* num_values) {\n    *num_values = 0;\n    value_slices->clear();\n\n    int num_splits = indices_in.dims() - 1 + params_nested_splits_in.size();\n    out_splits->assign(num_splits, {0});\n\n    \/\/ Get Eigen tensors.\n    const auto& indices = indices_in.flat<INDEX_TYPE>();\n    std::vector<ConstFlatType> params_nested_splits;\n    params_nested_splits.reserve(params_nested_splits_in.size());\n    for (const auto& splits_in : params_nested_splits_in) {\n      params_nested_splits.push_back(splits_in.flat<SPLITS_TYPE>());\n    }\n\n    TF_RETURN_IF_ERROR(\n        ValidateSplits(params_nested_splits, num_params_dense_values));\n\n    \/\/ Add `splits` that come from all but the last dimension of the dense\n    \/\/ Tensor `indices`.  In particular, for each dimension D, we add a\n    \/\/ splits tensor whose values are:\n    \/\/   range(reduce_prod(splits.shape[:D]) + 1) * splits.shape[D+1]\n    \/\/ E.g., if indices.shape=[2, 3, 4] then we will add splits tensors:\n    \/\/   [0, 3, 6]                    # length=2+1, stride=3\n    \/\/   [0, 4, 8, 12, 16, 20, 24]    # length=2*3+1, stride=4\n    int nrows = 1;\n    for (int dim = 0; dim < indices_in.dims() - 1; ++dim) {\n      nrows *= indices_in.dim_size(dim);\n      int row_length = indices_in.dim_size(dim + 1);\n      for (int i = 1; i < nrows + 1; ++i) {\n        out_splits->at(dim).push_back(i * row_length);\n      }\n    }\n\n    \/\/ Add `splits` that come from `params_nested_splits`.  Starting with the\n    \/\/ outermost ragged dimension (i.e., the first `splits` tensor), we work\n    \/\/ our way in, finding the range of values that should be copied.  As we\n    \/\/ go, we update the output `splits` for each dimension with the appropriate\n    \/\/ values.  In particular, the *lengths* of the slices from `param_splits`\n    \/\/ should be copied to generate corresponding slice lengths in the output\n    \/\/ splits.  E.g., if we are copying a ragged row with length 4, then we\n    \/\/ should add a new split point to out_splits that is 4 greater than the\n    \/\/ previous split point in out_splits.\n    for (int i = 0; i < indices.size(); ++i) {\n      int start = indices(i);\n      int limit = indices(i) + 1;\n\n      \/\/ Copy splits.\n      for (int dim = 0; dim < params_nested_splits.size(); ++dim) {\n        const auto& splits = params_nested_splits[dim];\n        int out_dim = dim + indices_in.dims() - 1;\n        if (out_dim >= 0) {\n          SPLITS_TYPE delta = out_splits->at(out_dim).back() - splits(start);\n          for (int j = start; j < limit; ++j) {\n            out_splits->at(out_dim).push_back(splits(j + 1) + delta);\n          }\n        }\n        start = splits(start);\n        limit = splits(limit);\n      }\n      if (limit != start) {\n        value_slices->emplace_back(start, limit);\n        *num_values += limit - start;\n      }\n    }\n    return ::tensorflow::Status::OK();\n  }","target":0,"code_token_length":852,"total_token_length":1088,"max_tokens_setting":2048}
+{"idx":383304,"func":"gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)\n{\n\tint dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;\n\tint wid;\n\tint w, wstart;\n\tint thick = im->thick;\n\n\t\/* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn *\/\n\tif (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) {\n\t\treturn;\n\t}\n\t\n\tdx = abs(x2 - x1);\n\tdy = abs(y2 - y1);\n\tif (dy <= dx) {\n\t\t\/* More-or-less horizontal. use wid for vertical stroke *\/\n\t\t\/* Doug Claar: watch out for NaN in atan2 (2.0.5) *\/\n\t\tif ((dx == 0) && (dy == 0)) {\n\t\t\twid = 1;\n\t\t} else {\n\t\t\twid = (int)(thick * cos (atan2 (dy, dx)));\n\t\t\tif (wid == 0) {\n\t\t\t\twid = 1;\n\t\t\t}\n\t\t}\n\t\td = 2 * dy - dx;\n\t\tincr1 = 2 * dy;\n\t\tincr2 = 2 * (dy - dx);\n\t\tif (x1 > x2) {\n\t\t\tx = x2;\n\t\t\ty = y2;\n\t\t\tydirflag = (-1);\n\t\t\txend = x1;\n\t\t} else {\n\t\t\tx = x1;\n\t\t\ty = y1;\n\t\t\tydirflag = 1;\n\t\t\txend = x2;\n\t\t}\n\n\t\t\/* Set up line thickness *\/\n\t\twstart = y - wid \/ 2;\n\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\tgdImageSetPixel(im, x, w, color);\n\t\t}\n\n\t\tif (((y2 - y1) * ydirflag) > 0) {\n\t\t\twhile (x < xend) {\n\t\t\t\tx++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\ty++;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = y - wid \/ 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, x, w, color);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (x < xend) {\n\t\t\t\tx++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\ty--;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = y - wid \/ 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, x, w, color);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t\/* More-or-less vertical. use wid for horizontal stroke *\/\n\t\twid = (int)(thick * sin (atan2 (dy, dx)));\n\t\tif (wid == 0) {\n\t\t\twid = 1;\n\t\t}\n\n\t\td = 2 * dx - dy;\n\t\tincr1 = 2 * dx;\n\t\tincr2 = 2 * (dx - dy);\n\t\tif (y1 > y2) {\n\t\t\ty = y2;\n\t\t\tx = x2;\n\t\t\tyend = y1;\n\t\t\txdirflag = (-1);\n\t\t} else {\n\t\t\ty = y1;\n\t\t\tx = x1;\n\t\t\tyend = y2;\n\t\t\txdirflag = 1;\n\t\t}\n\n\t\t\/* Set up line thickness *\/\n\t\twstart = x - wid \/ 2;\n\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t}\n\n\t\tif (((x2 - x1) * xdirflag) > 0) {\n\t\t\twhile (y < yend) {\n\t\t\t\ty++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\tx++;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = x - wid \/ 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (y < yend) {\n\t\t\t\ty++;\n\t\t\t\tif (d < 0) {\n\t\t\t\t\td += incr1;\n\t\t\t\t} else {\n\t\t\t\t\tx--;\n\t\t\t\t\td += incr2;\n\t\t\t\t}\n\t\t\t\twstart = x - wid \/ 2;\n\t\t\t\tfor (w = wstart; w < wstart + wid; w++) {\n\t\t\t\t\tgdImageSetPixel (im, w, y, color);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":1101,"total_token_length":1337,"max_tokens_setting":2048}
+{"idx":211136,"func":"static RzDyldRebaseInfos *get_rebase_infos(RzDyldCache *cache) {\n\tRzDyldRebaseInfos *result = RZ_NEW0(RzDyldRebaseInfos);\n\tif (!result) {\n\t\treturn NULL;\n\t}\n\n\tif (!cache->hdr->slideInfoOffset || !cache->hdr->slideInfoSize) {\n\t\tut32 total_slide_infos = 0;\n\t\tut32 n_slide_infos[MAX_N_HDR];\n\n\t\tut32 i;\n\t\tfor (i = 0; i < cache->n_hdr && i < MAX_N_HDR; i++) {\n\t\t\tut64 hdr_offset = cache->hdr_offset[i];\n\t\t\tif (!rz_buf_read_le32_at(cache->buf, 0x13c + hdr_offset, &n_slide_infos[i])) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t\ttotal_slide_infos += n_slide_infos[i];\n\t\t}\n\n\t\tif (!total_slide_infos) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tRzDyldRebaseInfosEntry *infos = RZ_NEWS0(RzDyldRebaseInfosEntry, total_slide_infos);\n\t\tif (!infos) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tut32 k = 0;\n\t\tfor (i = 0; i < cache->n_hdr && i < MAX_N_HDR; i++) {\n\t\t\tut64 hdr_offset = cache->hdr_offset[i];\n\t\t\tif (!n_slide_infos[i]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tut32 sio;\n\t\t\tif (!rz_buf_read_le32_at(cache->buf, 0x138 + hdr_offset, &sio)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tut64 slide_infos_offset = sio;\n\t\t\tif (!slide_infos_offset) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tslide_infos_offset += hdr_offset;\n\n\t\t\tut32 j;\n\t\t\tRzDyldRebaseInfo *prev_info = NULL;\n\t\t\tfor (j = 0; j < n_slide_infos[i]; j++) {\n\t\t\t\tut64 offset = slide_infos_offset + j * sizeof(cache_mapping_slide);\n\t\t\t\tcache_mapping_slide entry;\n\t\t\t\tif (rz_buf_fread_at(cache->buf, offset, (ut8 *)&entry, \"6lii\", 1) != sizeof(cache_mapping_slide)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (entry.slideInfoOffset && entry.slideInfoSize) {\n\t\t\t\t\tinfos[k].start = entry.fileOffset + hdr_offset;\n\t\t\t\t\tinfos[k].end = infos[k].start + entry.size;\n\t\t\t\t\tut64 slide = prev_info ? prev_info->slide : UT64_MAX;\n\t\t\t\t\tinfos[k].info = get_rebase_info(cache, entry.slideInfoOffset + hdr_offset, entry.slideInfoSize, entry.fileOffset + hdr_offset, slide);\n\t\t\t\t\tprev_info = infos[k].info;\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!k) {\n\t\t\tfree(infos);\n\t\t\tgoto beach;\n\t\t}\n\n\t\tif (k < total_slide_infos) {\n\t\t\tRzDyldRebaseInfosEntry *pruned_infos = RZ_NEWS0(RzDyldRebaseInfosEntry, k);\n\t\t\tif (!pruned_infos) {\n\t\t\t\tfree(infos);\n\t\t\t\tgoto beach;\n\t\t\t}\n\n\t\t\tmemcpy(pruned_infos, infos, sizeof(RzDyldRebaseInfosEntry) * k);\n\t\t\tfree(infos);\n\t\t\tinfos = pruned_infos;\n\t\t}\n\n\t\tresult->entries = infos;\n\t\tresult->length = k;\n\t\treturn result;\n\t}\n\n\tif (cache->hdr->mappingCount > 1) {\n\t\tRzDyldRebaseInfosEntry *infos = RZ_NEWS0(RzDyldRebaseInfosEntry, 1);\n\t\tif (!infos) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tinfos[0].start = cache->maps[1].fileOffset;\n\t\tinfos[0].end = infos[0].start + cache->maps[1].size;\n\t\tinfos[0].info = get_rebase_info(cache, cache->hdr->slideInfoOffset, cache->hdr->slideInfoSize, infos[0].start, UT64_MAX);\n\n\t\tresult->entries = infos;\n\t\tresult->length = 1;\n\t\treturn result;\n\t}\n\nbeach:\n\tfree(result);\n\treturn NULL;\n}","target":1,"code_token_length":930,"total_token_length":1166,"max_tokens_setting":2048}
+{"idx":413617,"func":"static int fcn_print_json(RCore *core, RAnalFunction *fcn, PJ *pj) {\n\tRListIter *iter;\n\tRAnalRef *refi;\n\tRList *refs, *xrefs;\n\tif (!pj) {\n\t\treturn -1;\n\t}\n\tint ebbs = 0;\n\tpj_o (pj);\n\tpj_kn (pj, \"offset\", fcn->addr);\n\tchar *name = r_core_anal_fcn_name (core, fcn);\n\tif (name) {\n\t\tpj_ks (pj, \"name\", name);\n\t}\n\tpj_kn (pj, \"size\", r_anal_function_linear_size (fcn));\n\tpj_ks (pj, \"is-pure\", r_str_bool (r_anal_function_purity (fcn)));\n\tpj_kn (pj, \"realsz\", r_anal_function_realsize (fcn));\n\tpj_kb (pj, \"noreturn\", fcn->is_noreturn);\n\tpj_ki (pj, \"stackframe\", fcn->maxstack);\n\tif (fcn->cc) {\n\t\tpj_ks (pj, \"calltype\", fcn->cc); \/\/ calling conventions\n\t}\n\tpj_ki (pj, \"cost\", r_anal_function_cost (fcn)); \/\/ execution cost\n\tpj_ki (pj, \"cc\", r_anal_function_complexity (fcn)); \/\/ cyclic cost\n\tpj_ki (pj, \"bits\", fcn->bits);\n\tpj_ks (pj, \"type\", r_anal_functiontype_tostring (fcn->type));\n\tpj_ki (pj, \"nbbs\", r_list_length (fcn->bbs));\n\tpj_ki (pj, \"edges\", r_anal_function_count_edges (fcn, &ebbs));\n\tpj_ki (pj, \"ebbs\", ebbs);\n\t{\n\t\tchar *sig = r_core_cmd_strf (core, \"afcf @ 0x%\"PFMT64x, fcn->addr);\n\t\tif (sig) {\n\t\t\tr_str_trim (sig);\n\t\t\tpj_ks (pj, \"signature\", sig);\n\t\t\tfree (sig);\n\t\t}\n\n\t}\n\tpj_kn (pj, \"minbound\", r_anal_function_min_addr (fcn));\n\tpj_kn (pj, \"maxbound\", r_anal_function_max_addr (fcn));\n\n\tint outdegree = 0;\n\trefs = r_anal_function_get_refs (fcn);\n\tif (!r_list_empty (refs)) {\n\t\tpj_k (pj, \"callrefs\");\n\t\tpj_a (pj);\n\t\tr_list_foreach (refs, iter, refi) {\n\t\t\tif (refi->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\t\toutdegree++;\n\t\t\t}\n\t\t\tif (refi->type == R_ANAL_REF_TYPE_CODE ||\n\t\t\t\trefi->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\t\tpj_o (pj);\n\t\t\t\tpj_kn (pj, \"addr\", refi->addr);\n\t\t\t\tpj_ks (pj, \"type\", r_anal_xrefs_type_tostring (refi->type));\n\t\t\t\tpj_kn (pj, \"at\", refi->at);\n\t\t\t\tpj_end (pj);\n\t\t\t}\n\t\t}\n\t\tpj_end (pj);\n\n\t\tpj_k (pj, \"datarefs\");\n\t\tpj_a (pj);\n\t\tr_list_foreach (refs, iter, refi) {\n\t\t\tif (refi->type == R_ANAL_REF_TYPE_DATA) {\n\t\t\t\tpj_n (pj, refi->addr);\n\t\t\t}\n\t\t}\n\t\tpj_end (pj);\n\t}\n\tr_list_free (refs);\n\n\tint indegree = 0;\n\txrefs = r_anal_function_get_xrefs (fcn);\n\tif (!r_list_empty (xrefs)) {\n\t\tpj_k (pj, \"codexrefs\");\n\t\tpj_a (pj);\n\t\tr_list_foreach (xrefs, iter, refi) {\n\t\t\tif (refi->type == R_ANAL_REF_TYPE_CODE ||\n\t\t\t\trefi->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\t\tindegree++;\n\t\t\t\tpj_o (pj);\n\t\t\t\tpj_kn (pj, \"addr\", refi->addr);\n\t\t\t\tpj_ks (pj, \"type\", r_anal_xrefs_type_tostring (refi->type));\n\t\t\t\tpj_kn (pj, \"at\", refi->at);\n\t\t\t\tpj_end (pj);\n\t\t\t}\n\t\t}\n\n\t\tpj_end (pj);\n\t\tpj_k (pj, \"dataxrefs\");\n\t\tpj_a (pj);\n\n\t\tr_list_foreach (xrefs, iter, refi) {\n\t\t\tif (refi->type == R_ANAL_REF_TYPE_DATA) {\n\t\t\t\tpj_n (pj, refi->addr);\n\t\t\t}\n\t\t}\n\t\tpj_end (pj);\n\t}\n\tr_list_free (xrefs);\n\n\tpj_ki (pj, \"indegree\", indegree);\n\tpj_ki (pj, \"outdegree\", outdegree);\n\n\tif (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) {\n\t\tpj_ki (pj, \"nlocals\", r_anal_var_count_locals (fcn));\n\t\tpj_ki (pj, \"nargs\", r_anal_var_count_args (fcn));\n\t\tpj_k (pj, \"bpvars\");\n\t\tr_anal_var_list_show (core->anal, fcn, 'b', 'j', pj);\n\t\tpj_k (pj, \"spvars\");\n\t\tr_anal_var_list_show (core->anal, fcn, 's', 'j', pj);\n\t\tpj_k (pj, \"regvars\");\n\t\tr_anal_var_list_show (core->anal, fcn, 'r', 'j', pj);\n\n\t\tpj_ks (pj, \"difftype\", fcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?\"match\":\n\t\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?\"unmatch\":\"new\");\n\t\tif (fcn->diff->addr != -1) {\n\t\t\tpj_kn (pj, \"diffaddr\", fcn->diff->addr);\n\t\t}\n\t\tif (fcn->diff->name) {\n\t\t\tpj_ks (pj, \"diffname\", fcn->diff->name);\n\t\t}\n\t}\n\tpj_end (pj);\n\tfree (name);\n\treturn 0;\n}","target":0,"code_token_length":1366,"total_token_length":1602,"max_tokens_setting":2048}
+{"idx":224191,"func":"gen_call(codegen_scope *s, node *tree, int val, int safe)\n{\n  mrb_sym sym = nsym(tree->cdr->car);\n  int skip = 0, n = 0, nk = 0, noop = no_optimize(s), noself = 0, blk = 0, sp_save = cursp();\n\n  if (!tree->car) {\n    noself = noop = 1;\n    push();\n  }\n  else {\n    codegen(s, tree->car, VAL); \/* receiver *\/\n  }\n  if (safe) {\n    int recv = cursp()-1;\n    gen_move(s, cursp(), recv, 1);\n    skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n  }\n  tree = tree->cdr->cdr->car;\n  if (tree) {\n    if (tree->car) {            \/* positional arguments *\/\n      n = gen_values(s, tree->car, VAL, 14);\n      if (n < 0) {              \/* variable length *\/\n        noop = 1;               \/* not operator *\/\n        n = 15;\n        push();\n      }\n    }\n    if (tree->cdr->car) {       \/* keyword arguments *\/\n      noop = 1;\n      nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14);\n      if (nk < 0) nk = 15;\n    }\n  }\n  if (tree && tree->cdr && tree->cdr->cdr) {\n    codegen(s, tree->cdr->cdr, VAL);\n    pop();\n    noop = 1;\n    blk = 1;\n  }\n  push();pop();\n  s->sp = sp_save;\n  if (!noop && sym == MRB_OPSYM_2(s->mrb, add) && n == 1)  {\n    gen_addsub(s, OP_ADD, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, sub) && n == 1)  {\n    gen_addsub(s, OP_SUB, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, mul) && n == 1)  {\n    gen_muldiv(s, OP_MUL, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, div) && n == 1)  {\n    gen_muldiv(s, OP_DIV, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, lt) && n == 1)  {\n    genop_1(s, OP_LT, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, le) && n == 1)  {\n    genop_1(s, OP_LE, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, gt) && n == 1)  {\n    genop_1(s, OP_GT, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, ge) && n == 1)  {\n    genop_1(s, OP_GE, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, eq) && n == 1)  {\n    genop_1(s, OP_EQ, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, aset) && n == 2)  {\n    genop_1(s, OP_SETIDX, cursp());\n  }\n  else if (!noop && n == 0 && gen_uniop(s, sym, cursp())) {\n    \/* constant folding succeeded *\/\n  }\n  else if (!noop && n == 1 && gen_binop(s, sym, cursp())) {\n    \/* constant folding succeeded *\/\n  }\n  else if (noself){\n    genop_3(s, blk ? OP_SSENDB : OP_SSEND, cursp(), new_sym(s, sym), n|(nk<<4));\n  }\n  else {\n    genop_3(s, blk ? OP_SENDB : OP_SEND, cursp(), new_sym(s, sym), n|(nk<<4));\n  }\n  if (safe) {\n    dispatch(s, skip);\n  }\n  if (val) {\n    push();\n  }\n}","target":0,"code_token_length":982,"total_token_length":1218,"max_tokens_setting":2048}
+{"idx":249978,"func":"static GF_Err ShiftOffset(GF_ISOFile *file, GF_List *writers, u64 offset)\n{\n\tu32 i, j, k, l, last;\n\tTrackWriter *writer;\n\tGF_StscEntry *ent;\n\n\tif (file->meta) ShiftMetaOffset(file->meta, offset);\n\tif (file->moov && file->moov->meta) ShiftMetaOffset(file->moov->meta, offset);\n\n\ti=0;\n\twhile ((writer = (TrackWriter *)gf_list_enum(writers, &i))) {\n\t\tif (writer->mdia->mediaTrack->meta) ShiftMetaOffset(writer->mdia->mediaTrack->meta, offset);\n\n\t\t\/\/we have to proceed entry by entry in case a part of the media is not self-contained...\n\t\tfor (j=0; j<writer->stsc->nb_entries; j++) {\n\t\t\tent = &writer->stsc->entries[j];\n\t\t\tif ((writer->all_dref_mode==ISOM_DREF_EXT) || !Media_IsSelfContained(writer->mdia, ent->sampleDescriptionIndex))\n\t\t\t\tcontinue;\n\n\t\t\t\/\/OK, get the chunk(s) number(s) and \"shift\" its (their) offset(s).\n\t\t\tif (writer->stco->type == GF_ISOM_BOX_TYPE_STCO) {\n\t\t\t\tGF_ChunkLargeOffsetBox *new_stco64 = NULL;\n\t\t\t\tGF_ChunkOffsetBox *stco = (GF_ChunkOffsetBox *) writer->stco;\n\n\t\t\t\t\/\/be carefull for the last entry, nextChunk is set to 0 in edit mode...\n\t\t\t\tlast = ent->nextChunk ? ent->nextChunk : stco->nb_entries + 1;\n\t\t\t\tfor (k = ent->firstChunk; k < last; k++) {\n\n\t\t\t\t\t\/\/we need to rewrite the table: only allocate co64 if not done previously and convert all offsets\n\t\t\t\t\t\/\/to co64. Then (whether co64 was created or not) adjust the offset\n\t\t\t\t\t\/\/Do not reassign table until we are done with the current sampleToChunk processing\n\t\t\t\t\t\/\/since we have a test on stco->offsets[k-1], we need to keep stco untouched\n\t\t\t\t\tif (new_stco64 || file->force_co64 || (stco->offsets[k-1] + offset > 0xFFFFFFFF)) {\n\t\t\t\t\t\tif (!new_stco64) {\n\t\t\t\t\t\t\tnew_stco64 = (GF_ChunkLargeOffsetBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_CO64);\n\t\t\t\t\t\t\tif (!new_stco64) return GF_OUT_OF_MEM;\n\t\t\t\t\t\t\tnew_stco64->nb_entries = stco->nb_entries;\n\t\t\t\t\t\t\tnew_stco64->offsets = (u64 *) gf_malloc(new_stco64->nb_entries * sizeof(u64));\n\t\t\t\t\t\t\tif (!new_stco64->offsets) return GF_OUT_OF_MEM;\n\t\t\t\t\t\t\t\/\/copy over the stco table\n\t\t\t\t\t\t\tfor (l = 0; l < new_stco64->nb_entries; l++) {\n\t\t\t\t\t\t\t\tnew_stco64->offsets[l] = (u64) stco->offsets[l];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnew_stco64->offsets[k-1] += offset;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstco->offsets[k-1] += (u32) offset;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (new_stco64) {\n\t\t\t\t\t\/\/done with this sampleToChunk entry, replace the box if we moved to co64\n\t\t\t\t\tgf_isom_box_del(writer->stco);\n\t\t\t\t\twriter->stco = (GF_Box *)new_stco64;\n\t\t\t\t\tnew_stco64 = NULL;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tGF_ChunkLargeOffsetBox *stco64 = (GF_ChunkLargeOffsetBox *) writer->stco;\n\t\t\t\t\/\/be carefull for the last entry ...\n\t\t\t\tlast = ent->nextChunk ? ent->nextChunk : stco64->nb_entries + 1;\n\t\t\t\tfor (k = ent->firstChunk; k < last; k++) {\n\t\t\t\t\tstco64->offsets[k-1] += offset;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn GF_OK;\n\n}","target":0,"code_token_length":916,"total_token_length":1152,"max_tokens_setting":2048}
+{"idx":272365,"func":"find_certificate(cms_context *cms, int needs_private_key)\n{\n\tchar *tokenname = resolve_token_name(cms->tokenname);\n\n\tstruct validity_cbdata cbd;\n\tif (!cms->certname || !*cms->certname) {\n\t\tcms->log(cms, LOG_ERR, \"no certificate name specified\");\n\t\treturn -1;\n\t}\n\n\tdprintf(\"setting password function to %s\", cms->func ? \"cms->func\" : \"SECU_GetModulePassword\");\n\tPK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);\n\n\tPK11SlotList *slots = NULL;\n\tslots = PK11_GetAllTokens(CKM_RSA_PKCS, PR_FALSE, PR_TRUE, cms);\n\tif (!slots)\n\t\tcnreterr(-1, cms, \"could not get pk11 token list\");\n\n\tPK11SlotListElement *psle = NULL;\n\tpsle = PK11_GetFirstSafe(slots);\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tcnreterr(-1, cms, \"could not get pk11 safe\");\n\t}\n\n\twhile (psle) {\n\t\tdprintf(\"looking for token \\\"%s\\\", got \\\"%s\\\"\",\n\t\t\ttokenname, PK11_GetTokenName(psle->slot));\n\t\tif (!strcmp(tokenname, PK11_GetTokenName(psle->slot))) {\n\t\t\tdprintf(\"found token \\\"%s\\\"\", tokenname);\n\t\t\tbreak;\n\t\t}\n\n\t\tpsle = PK11_GetNextSafe(slots, psle, PR_FALSE);\n\t}\n\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tnssreterr(-1, \"Could not find token \\\"%s\\\"\", tokenname);\n\t}\n\n\tint errnum;\n\tSECStatus status;\n\tif (PK11_NeedLogin(psle->slot) && !PK11_IsLoggedIn(psle->slot, cms)) {\n\t\tstatus = PK11_Authenticate(psle->slot, PR_TRUE, cms);\n\t\tif (status != SECSuccess) {\n\t\t\tsave_port_err() {\n\t\t\t\terrnum = PORT_GetError();\n\t\t\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\t\t\tPK11_FreeSlotList(slots);\n\t\t\t\tcms->log(cms, LOG_ERR,\n\t\t\t\t\t \"authentication failed for token \\\"%s\\\": %s\",\n\t\t\t\t\t tokenname, PORT_ErrorToString(errnum));\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tCERTCertList *certlist = NULL;\n\tcertlist = PK11_ListCertsInSlot(psle->slot);\n\tif (!certlist) {\n\t\tsave_port_err() {\n\t\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tcnreterr(-1, cms, \"could not get certificate list\");\n\t}\n\n\tSECItem nickname = {\n\t\t.data = (void *)cms->certname,\n\t\t.len = strlen(cms->certname) + 1,\n\t\t.type = siUTF8String,\n\t};\n\n\tcms->psle = psle;\n\n\tcbd.cms = cms;\n\tcbd.psle = psle;\n\tcbd.slot = psle->slot;\n\tcbd.cert = NULL;\n\n\tPORT_SetError(SEC_ERROR_UNKNOWN_CERT);\n\tif (needs_private_key) {\n\t\tstatus = PK11_TraverseCertsForNicknameInSlot(&nickname,\n\t\t\t\t\tpsle->slot, is_valid_cert, &cbd);\n\t\terrnum = PORT_GetError();\n\t\tif (errnum)\n\t\t\tdprintf(\"PK11_TraverseCertsForNicknameInSlot():%s:%s\",\n\t\t\t\tPORT_ErrorToName(errnum), PORT_ErrorToString(errnum));\n\t} else {\n\t\tstatus = PK11_TraverseCertsForNicknameInSlot(&nickname,\n\t\t\t\t\tpsle->slot,\n\t\t\t\t\tis_valid_cert_without_private_key,\n\t\t\t\t\t&cbd);\n\t\terrnum = PORT_GetError();\n\t\tif (errnum)\n\t\t\tdprintf(\"PK11_TraverseCertsForNicknameInSlot():%s:%s\",\n\t\t\t\tPORT_ErrorToName(errnum), PORT_ErrorToString(errnum));\n\t}\n\tdprintf(\"status:%d cbd.cert:%p\", status, cbd.cert);\n\tif (status == SECSuccess && cbd.cert != NULL) {\n\t\tif (cms->cert)\n\t\t\tCERT_DestroyCertificate(cms->cert);\n\t\tcms->cert = CERT_DupCertificate(cbd.cert);\n\t} else {\n\t\terrnum = PORT_GetError();\n\t\tdprintf(\"token traversal %s; cert %sfound:%s:%s\",\n\t\t\tstatus == SECSuccess ? \"succeeded\" : \"failed\",\n\t\t\tcbd.cert == NULL ? \"not\" : \"\",\n\t\t\tPORT_ErrorToName(errnum), PORT_ErrorToString(errnum));\n\t}\n\n\tsave_port_err() {\n\t\tdprintf(\"Destroying cert list\");\n\t\tCERT_DestroyCertList(certlist);\n\t\tdprintf(\"Destroying slot list element\");\n\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\tdprintf(\"Destroying slot list\");\n\t\tPK11_FreeSlotList(slots);\n\t\tcms->psle = NULL;\n\t}\n\tif (status != SECSuccess || cms->cert == NULL)\n\t\tcnreterr(-1, cms, \"could not find certificate\");\n\n\treturn 0;\n}","target":0,"code_token_length":1151,"total_token_length":1387,"max_tokens_setting":2048}
+{"idx":222597,"func":"gen_call(codegen_scope *s, node *tree, int val, int safe)\n{\n  mrb_sym sym = nsym(tree->cdr->car);\n  int skip = 0, n = 0, nk = 0, noop = 0, noself = 0, blk = 0, sp_save = cursp();\n\n  if (!tree->car) {\n    noself = noop = 1;\n    push();\n  }\n  else {\n    codegen(s, tree->car, VAL); \/* receiver *\/\n  }\n  if (safe) {\n    int recv = cursp()-1;\n    gen_move(s, cursp(), recv, 1);\n    skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n  }\n  tree = tree->cdr->cdr->car;\n  if (tree) {\n    if (tree->car) {            \/* positional arguments *\/\n      n = gen_values(s, tree->car, VAL, 14);\n      if (n < 0) {              \/* variable length *\/\n        noop = 1;               \/* not operator *\/\n        n = 15;\n        push();\n      }\n    }\n    if (tree->cdr->car) {       \/* keyword arguments *\/\n      noop = 1;\n      nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14);\n      if (nk < 0) nk = 15;\n    }\n  }\n  if (tree && tree->cdr && tree->cdr->cdr) {\n    codegen(s, tree->cdr->cdr, VAL);\n    pop();\n    noop = 1;\n    blk = 1;\n  }\n  push();pop();\n  s->sp = sp_save;\n  if (!noop && sym == MRB_OPSYM_2(s->mrb, add) && n == 1)  {\n    gen_addsub(s, OP_ADD, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, sub) && n == 1)  {\n    gen_addsub(s, OP_SUB, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, mul) && n == 1)  {\n    gen_muldiv(s, OP_MUL, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, div) && n == 1)  {\n    gen_muldiv(s, OP_DIV, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, lt) && n == 1)  {\n    genop_1(s, OP_LT, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, le) && n == 1)  {\n    genop_1(s, OP_LE, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, gt) && n == 1)  {\n    genop_1(s, OP_GT, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, ge) && n == 1)  {\n    genop_1(s, OP_GE, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, eq) && n == 1)  {\n    genop_1(s, OP_EQ, cursp());\n  }\n  else if (!noop && sym == MRB_OPSYM_2(s->mrb, aset) && n == 2)  {\n    genop_1(s, OP_SETIDX, cursp());\n  }\n  else if (!noop && n == 0 && gen_uniop(s, sym, cursp())) {\n    \/* constant folding succeeded *\/\n  }\n  else if (!noop && n == 1 && gen_binop(s, sym, cursp())) {\n    \/* constant folding succeeded *\/\n  }\n  else if (noself){\n    genop_3(s, blk ? OP_SSENDB : OP_SSEND, cursp(), new_sym(s, sym), n|(nk<<4));\n  }\n  else {\n    genop_3(s, blk ? OP_SENDB : OP_SEND, cursp(), new_sym(s, sym), n|(nk<<4));\n  }\n  if (safe) {\n    dispatch(s, skip);\n  }\n  if (val) {\n    push();\n  }\n}","target":0,"code_token_length":980,"total_token_length":1216,"max_tokens_setting":2048}
+{"idx":353015,"func":"issuerAndThisUpdateCheck(\n\tstruct berval *in,\n\tstruct berval *is,\n\tstruct berval *tu,\n\tvoid *ctx )\n{\n\tint numdquotes = 0;\n\tstruct berval x = *in;\n\tstruct berval ni = BER_BVNULL;\n\t\/* Parse GSER format *\/ \n\tenum {\n\t\tHAVE_NONE = 0x0,\n\t\tHAVE_ISSUER = 0x1,\n\t\tHAVE_THISUPDATE = 0x2,\n\t\tHAVE_ALL = ( HAVE_ISSUER | HAVE_THISUPDATE )\n\t} have = HAVE_NONE;\n\n\n\tif ( in->bv_len < STRLENOF( \"{issuer \\\"\\\",thisUpdate \\\"YYMMDDhhmmssZ\\\"}\" ) ) return LDAP_INVALID_SYNTAX;\n\n\tif ( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tx.bv_val++;\n\tx.bv_len -= STRLENOF(\"{}\");\n\n\tdo {\n\t\t\/* eat leading spaces *\/\n\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\/* empty *\/;\n\t\t}\n\n\t\t\/* should be at issuer or thisUpdate *\/\n\t\tif ( strncasecmp( x.bv_val, \"issuer\", STRLENOF(\"issuer\") ) == 0 ) {\n\t\t\tif ( have & HAVE_ISSUER ) return LDAP_INVALID_SYNTAX;\n\n\t\t\t\/* parse issuer *\/\n\t\t\tx.bv_val += STRLENOF(\"issuer\");\n\t\t\tx.bv_len -= STRLENOF(\"issuer\");\n\n\t\t\tif ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\t\/* For backward compatibility, this part is optional *\/\n\t\t\tif ( strncasecmp( x.bv_val, \"rdnSequence:\", STRLENOF(\"rdnSequence:\") ) != 0 ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\t\t\tx.bv_val += STRLENOF(\"rdnSequence:\");\n\t\t\tx.bv_len -= STRLENOF(\"rdnSequence:\");\n\n\t\t\tif ( x.bv_val[0] != '\"' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\tis->bv_val = x.bv_val;\n\t\t\tis->bv_len = 0;\n\n\t\t\tfor ( ; is->bv_len < x.bv_len; ) {\n\t\t\t\tif ( is->bv_val[is->bv_len] != '\"' ) {\n\t\t\t\t\tis->bv_len++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif ( is->bv_val[is->bv_len+1] == '\"' ) {\n\t\t\t\t\t\/* double dquote *\/\n\t\t\t\t\tnumdquotes++;\n\t\t\t\t\tis->bv_len += 2;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tx.bv_val += is->bv_len + 1;\n\t\t\tx.bv_len -= is->bv_len + 1;\n\n\t\t\thave |= HAVE_ISSUER;\n\n\t\t} else if ( strncasecmp( x.bv_val, \"thisUpdate\", STRLENOF(\"thisUpdate\") ) == 0 )\n\t\t{\n\t\t\tif ( have & HAVE_THISUPDATE ) return LDAP_INVALID_SYNTAX;\n\n\t\t\t\/* parse thisUpdate *\/\n\t\t\tx.bv_val += STRLENOF(\"thisUpdate\");\n\t\t\tx.bv_len -= STRLENOF(\"thisUpdate\");\n\n\t\t\tif ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\tif ( !x.bv_len || x.bv_val[0] != '\"' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\ttu->bv_val = x.bv_val;\n\t\t\ttu->bv_len = 0;\n\n\t\t\tfor ( ; tu->bv_len < x.bv_len; tu->bv_len++ ) {\n\t\t\t\tif ( tu->bv_val[tu->bv_len] == '\"' ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( tu->bv_len < STRLENOF(\"YYYYmmddHHmmssZ\") ) return LDAP_INVALID_SYNTAX;\n\n\t\t\tx.bv_val += tu->bv_len + 1;\n\t\t\tx.bv_len -= tu->bv_len + 1;\n\n\t\t\thave |= HAVE_THISUPDATE;\n\n\t\t} else {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\t\/* eat leading spaces *\/\n\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\/* empty *\/;\n\t\t}\n\n\t\tif ( have == HAVE_ALL ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( x.bv_val[0] != ',' ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\tx.bv_val++;\n\t\tx.bv_len--;\n\t} while ( 1 );\n\n\t\/* should have no characters left... *\/\n\tif ( x.bv_len ) return LDAP_INVALID_SYNTAX;\n\n\tif ( numdquotes == 0 ) {\n\t\tber_dupbv_x( &ni, is, ctx );\n\n\t} else {\n\t\tber_len_t src, dst;\n\n\t\tni.bv_len = is->bv_len - numdquotes;\n\t\tni.bv_val = slap_sl_malloc( ni.bv_len + 1, ctx );\n\t\tfor ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) {\n\t\t\tif ( is->bv_val[src] == '\"' ) {\n\t\t\t\tsrc++;\n\t\t\t}\n\t\t\tni.bv_val[dst] = is->bv_val[src];\n\t\t}\n\t\tni.bv_val[dst] = '\\0';\n\t}\n\t\t\n\t*is = ni;\n\n\treturn 0;\n}","target":0,"code_token_length":1342,"total_token_length":1578,"max_tokens_setting":2048}
+{"idx":218801,"func":"static void XDrawMatteText(Display *display,const XWindowInfo *window_info,\n  XWidgetInfo *text_info)\n{\n  const char\n    *text;\n\n  int\n    n,\n    x,\n    y;\n\n  int\n    i;\n\n  unsigned int\n    height,\n    width;\n\n  XFontStruct\n    *font_info;\n\n  XRectangle\n    crop_info;\n\n  \/*\n    Clear the text area.\n  *\/\n  XSetMatteColor(display,window_info,MagickFalse);\n  (void) XFillRectangle(display,window_info->id,window_info->widget_context,\n    text_info->x,text_info->y,text_info->width,text_info->height);\n  if (text_info->text == (char *) NULL)\n    return;\n  XSetTextColor(display,window_info,text_info->highlight);\n  font_info=window_info->font_info;\n  x=text_info->x+(QuantumMargin >> 2);\n  y=text_info->y+font_info->ascent+(text_info->height >> 2);\n  width=text_info->width-(QuantumMargin >> 1);\n  height=(unsigned int) (font_info->ascent+font_info->descent);\n  if (*text_info->text == '\\0')\n    {\n      \/*\n        No text-- just draw cursor.\n      *\/\n      (void) XDrawLine(display,window_info->id,window_info->annotate_context,\n        x,y+3,x,y-height+3);\n      return;\n    }\n  \/*\n    Set cropping region.\n  *\/\n  crop_info.width=(unsigned short) text_info->width;\n  crop_info.height=(unsigned short) text_info->height;\n  crop_info.x=text_info->x;\n  crop_info.y=text_info->y;\n  \/*\n    Determine beginning of the visible text.\n  *\/\n  if (text_info->cursor < text_info->marker)\n    text_info->marker=text_info->cursor;\n  else\n    {\n      text=text_info->marker;\n      if (XTextWidth(font_info,(char *) text,(int) (text_info->cursor-text)) >\n          (int) width)\n        {\n          text=text_info->text;\n          for (i=0; i < Extent(text); i++)\n          {\n            n=XTextWidth(font_info,(char *) text+i,(int)\n              (text_info->cursor-text-i));\n            if (n <= (int) width)\n              break;\n          }\n          text_info->marker=(char *) text+i;\n        }\n    }\n  \/*\n    Draw text and cursor.\n  *\/\n  if (text_info->highlight == MagickFalse)\n    {\n      (void) XSetClipRectangles(display,window_info->widget_context,0,0,\n        &crop_info,1,Unsorted);\n      (void) XDrawString(display,window_info->id,window_info->widget_context,\n        x,y,text_info->marker,Extent(text_info->marker));\n      (void) XSetClipMask(display,window_info->widget_context,None);\n    }\n  else\n    {\n      (void) XSetClipRectangles(display,window_info->annotate_context,0,0,\n        &crop_info,1,Unsorted);\n      width=WidgetTextWidth(font_info,text_info->marker);\n      (void) XFillRectangle(display,window_info->id,\n        window_info->annotate_context,x,y-font_info->ascent,width,height);\n      (void) XSetClipMask(display,window_info->annotate_context,None);\n      (void) XSetClipRectangles(display,window_info->highlight_context,0,0,\n        &crop_info,1,Unsorted);\n      (void) XDrawString(display,window_info->id,\n        window_info->highlight_context,x,y,text_info->marker,\n        Extent(text_info->marker));\n      (void) XSetClipMask(display,window_info->highlight_context,None);\n    }\n  x+=XTextWidth(font_info,text_info->marker,(int)\n    (text_info->cursor-text_info->marker));\n  (void) XDrawLine(display,window_info->id,window_info->annotate_context,x,y+3,\n    x,y-height+3);\n}","target":0,"code_token_length":867,"total_token_length":1103,"max_tokens_setting":2048}
+{"idx":269314,"func":"static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, IDWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){\n    const int b_width = s->b_width  << s->block_max_depth;\n    const int b_height= s->b_height << s->block_max_depth;\n    const int b_stride= b_width;\n    BlockNode *lt= &s->block[b_x + b_y*b_stride];\n    BlockNode *rt= lt+1;\n    BlockNode *lb= lt+b_stride;\n    BlockNode *rb= lb+1;\n    uint8_t *block[4];\n    int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;\n    uint8_t *tmp = s->scratchbuf;\n    uint8_t *ptmp;\n    int x,y;\n\n    if(b_x<0){\n        lt= rt;\n        lb= rb;\n    }else if(b_x + 1 >= b_width){\n        rt= lt;\n        rb= lb;\n    }\n    if(b_y<0){\n        lt= lb;\n        rt= rb;\n    }else if(b_y + 1 >= b_height){\n        lb= lt;\n        rb= rt;\n    }\n\n    if(src_x<0){ \/\/FIXME merge with prev & always round internal width up to *16\n        obmc -= src_x;\n        b_w += src_x;\n        if(!sliced && !offset_dst)\n            dst -= src_x;\n        src_x=0;\n    }\n    if(src_x + b_w > w){\n        b_w = w - src_x;\n    }\n    if(src_y<0){\n        obmc -= src_y*obmc_stride;\n        b_h += src_y;\n        if(!sliced && !offset_dst)\n            dst -= src_y*dst_stride;\n        src_y=0;\n    }\n    if(src_y + b_h> h){\n        b_h = h - src_y;\n    }\n\n    if(b_w<=0 || b_h<=0) return;\n\n    av_assert2(src_stride > 2*MB_SIZE + 5);\n\n    if(!sliced && offset_dst)\n        dst += src_x + src_y*dst_stride;\n    dst8+= src_x + src_y*src_stride;\n\/\/    src += src_x + src_y*src_stride;\n\n    ptmp= tmp + 3*tmp_step;\n    block[0]= ptmp;\n    ptmp+=tmp_step;\n    ff_snow_pred_block(s, block[0], tmp, src_stride, src_x, src_y, b_w, b_h, lt, plane_index, w, h);\n\n    if(same_block(lt, rt)){\n        block[1]= block[0];\n    }else{\n        block[1]= ptmp;\n        ptmp+=tmp_step;\n        ff_snow_pred_block(s, block[1], tmp, src_stride, src_x, src_y, b_w, b_h, rt, plane_index, w, h);\n    }\n\n    if(same_block(lt, lb)){\n        block[2]= block[0];\n    }else if(same_block(rt, lb)){\n        block[2]= block[1];\n    }else{\n        block[2]= ptmp;\n        ptmp+=tmp_step;\n        ff_snow_pred_block(s, block[2], tmp, src_stride, src_x, src_y, b_w, b_h, lb, plane_index, w, h);\n    }\n\n    if(same_block(lt, rb) ){\n        block[3]= block[0];\n    }else if(same_block(rt, rb)){\n        block[3]= block[1];\n    }else if(same_block(lb, rb)){\n        block[3]= block[2];\n    }else{\n        block[3]= ptmp;\n        ff_snow_pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h);\n    }\n    if(sliced){\n        s->dwt.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);\n    }else{\n        for(y=0; y<b_h; y++){\n            \/\/FIXME ugly misuse of obmc_stride\n            const uint8_t *obmc1= obmc + y*obmc_stride;\n            const uint8_t *obmc2= obmc1+ (obmc_stride>>1);\n            const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);\n            const uint8_t *obmc4= obmc3+ (obmc_stride>>1);\n            for(x=0; x<b_w; x++){\n                int v=   obmc1[x] * block[3][x + y*src_stride]\n                        +obmc2[x] * block[2][x + y*src_stride]\n                        +obmc3[x] * block[1][x + y*src_stride]\n                        +obmc4[x] * block[0][x + y*src_stride];\n\n                v <<= 8 - LOG2_OBMC_MAX;\n                if(FRAC_BITS != 8){\n                    v >>= 8 - FRAC_BITS;\n                }\n                if(add){\n                    v += dst[x + y*dst_stride];\n                    v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS;\n                    if(v&(~255)) v= ~(v>>31);\n                    dst8[x + y*src_stride] = v;\n                }else{\n                    dst[x + y*dst_stride] -= v;\n                }\n            }\n        }\n    }\n}","target":0,"code_token_length":1290,"total_token_length":1526,"max_tokens_setting":2048}
+{"idx":204017,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tsquashfs_dir_header_3 dirh;\n\tchar buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tsquashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;\n\tlong long start;\n\tint bytes = 0;\n\tint dir_count, size, res;\n\tstruct dir_ent *ent, *cur_ent = NULL;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tMEM_ERROR();\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = NULL;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 3)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\toffset = (*i)->offset;\n\tsize = (*i)->data + bytes - 3;\n\n\twhile(bytes < size) {\t\t\t\n\t\tif(swap) {\n\t\t\tsquashfs_dir_header_3 sdirh;\n\t\t\tres = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));\n\t\t\tif(res)\n\t\t\t\tSQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);\n\t\t} else\n\t\t\tres = read_directory_data(&dirh, &start, &offset, sizeof(dirh));\n\t\n\t\tif(res == FALSE)\n\t\t\tgoto corrupted;\n\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_entry_3 sdire;\n\t\t\t\tres = read_directory_data(&sdire, &start,\n\t\t\t\t\t&offset, sizeof(sdire));\n\t\t\t\tif(res)\n\t\t\t\t\tSQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);\n\t\t\t} else\n\t\t\t\tres = read_directory_data(dire, &start,\n\t\t\t\t\t&offset, sizeof(*dire));\n\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tres = read_directory_data(dire->name, &start, &offset,\n\t\t\t\t\t\t\t\tdire->size + 1);\n\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\n\t\t\t\/* check name for invalid characters (i.e \/, ., ..) *\/\n\t\t\tif(check_name(dire->name, dire->size + 1) == FALSE) {\n\t\t\t\tERROR(\"File system corrupted: invalid characters in name\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\n\t\t\tent = malloc(sizeof(struct dir_ent));\n\t\t\tif(ent == NULL)\n\t\t\t\tMEM_ERROR();\n\n\t\t\tent->name = strdup(dire->name);\n\t\t\tent->start_block = dirh.start_block;\n\t\t\tent->offset = dire->offset;\n\t\t\tent->type = dire->type;\n\t\t\tent->next = NULL;\n\t\t\tif(cur_ent == NULL)\n\t\t\t\tdir->dirs = ent;\n\t\t\telse\n\t\t\t\tcur_ent->next = ent;\n\t\t\tcur_ent = ent;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tsquashfs_closedir(dir);\n\treturn NULL;\n}","target":1,"code_token_length":1003,"total_token_length":1239,"max_tokens_setting":2048}
+{"idx":221143,"func":"GF_Err gf_odf_hevc_cfg_write_bs(GF_HEVCConfig *cfg, GF_BitStream *bs)\n{\n\tu32 i, count;\n\n\tcount = gf_list_count(cfg->param_array);\n\n\tif (!cfg->write_annex_b) {\n\t\tgf_bs_write_int(bs, cfg->configurationVersion, 8);\n\n\t\tif (!cfg->is_lhvc) {\n\t\t\tgf_bs_write_int(bs, cfg->profile_space, 2);\n\t\t\tgf_bs_write_int(bs, cfg->tier_flag, 1);\n\t\t\tgf_bs_write_int(bs, cfg->profile_idc, 5);\n\t\t\tgf_bs_write_int(bs, cfg->general_profile_compatibility_flags, 32);\n\t\t\tgf_bs_write_int(bs, cfg->progressive_source_flag, 1);\n\t\t\tgf_bs_write_int(bs, cfg->interlaced_source_flag, 1);\n\t\t\tgf_bs_write_int(bs, cfg->non_packed_constraint_flag, 1);\n\t\t\tgf_bs_write_int(bs, cfg->frame_only_constraint_flag, 1);\n\t\t\t\/*only lowest 44 bits used*\/\n\t\t\tgf_bs_write_long_int(bs, cfg->constraint_indicator_flags, 44);\n\t\t\tgf_bs_write_int(bs, cfg->level_idc, 8);\n\t\t}\n\n\t\tgf_bs_write_int(bs, 0xFF, 4);\n\t\tgf_bs_write_int(bs, cfg->min_spatial_segmentation_idc, 12);\n\n\t\tgf_bs_write_int(bs, 0xFF, 6);\n\t\tgf_bs_write_int(bs, cfg->parallelismType, 2);\n\n\t\tif (!cfg->is_lhvc) {\n\t\t\tgf_bs_write_int(bs, 0xFF, 6);\n\t\t\tgf_bs_write_int(bs, cfg->chromaFormat, 2);\n\t\t\tgf_bs_write_int(bs, 0xFF, 5);\n\t\t\tgf_bs_write_int(bs, cfg->luma_bit_depth-8, 3);\n\t\t\tgf_bs_write_int(bs, 0xFF, 5);\n\t\t\tgf_bs_write_int(bs, cfg->chroma_bit_depth-8, 3);\n\t\t\tgf_bs_write_int(bs, cfg->avgFrameRate, 16);\n\n\t\t\tgf_bs_write_int(bs, cfg->constantFrameRate, 2);\n\t\t} else {\n\t\t\tgf_bs_write_int(bs, 0xFF, 2);\n\t\t}\n\n\t\tgf_bs_write_int(bs, cfg->numTemporalLayers, 3);\n\t\tgf_bs_write_int(bs, cfg->temporalIdNested, 1);\n\t\tgf_bs_write_int(bs, cfg->nal_unit_size - 1, 2);\n\n\t\tgf_bs_write_int(bs, count, 8);\n\t}\n\n\tfor (i=0; i<count; i++) {\n\t\tu32 nalucount, j;\n\t\tGF_NALUFFParamArray *ar = (GF_NALUFFParamArray*)gf_list_get(cfg->param_array, i);\n\n\t\tnalucount = gf_list_count(ar->nalus);\n\t\tif (!cfg->write_annex_b) {\n\t\t\tgf_bs_write_int(bs, ar->array_completeness, 1);\n\t\t\tgf_bs_write_int(bs, 0, 1);\n\t\t\tgf_bs_write_int(bs, ar->type, 6);\n\t\t\tgf_bs_write_int(bs, nalucount, 16);\n\t\t}\n\n\t\tfor (j=0; j<nalucount; j++) {\n\t\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(ar->nalus, j);\n\t\t\tif (!cfg->write_annex_b) {\n\t\t\t\tgf_bs_write_int(bs, sl->size, 16);\n\t\t\t} else {\n\t\t\t\tgf_bs_write_u32(bs, 1);\n\t\t\t}\n\t\t\tgf_bs_write_data(bs, sl->data, sl->size);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":842,"total_token_length":1078,"max_tokens_setting":2048}
+{"idx":234152,"func":"display_formatted_table (unsigned char *data,\n\t\t\t unsigned char *start,\n\t\t\t unsigned char *end,\n\t\t\t const DWARF2_Internal_LineInfo *linfo,\n\t\t\t struct dwarf_section *section,\n\t\t\t bool is_dir)\n{\n  unsigned char *format_start, format_count, *format, formati;\n  dwarf_vma data_count, datai;\n  unsigned int namepass, last_entry = 0;\n  const char * table_name = is_dir ? N_(\"Directory Table\") : N_(\"File Name Table\");\n\n  SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);\n  if (do_checks && format_count > 5)\n    warn (_(\"Unexpectedly large number of columns in the %s (%u)\\n\"),\n\t  table_name, format_count);\n\n  format_start = data;\n  for (formati = 0; formati < format_count; formati++)\n    {\n      SKIP_ULEB (data, end);\n      SKIP_ULEB (data, end);\n      if (data >= end)\n\t{\n\t  warn (_(\"%s: Corrupt format description entry\\n\"), table_name);\n\t  return data;\n\t}\n    }\n\n  READ_ULEB (data_count, data, end);\n  if (data_count == 0)\n    {\n      printf (_(\"\\n The %s is empty.\\n\"), table_name);\n      return data;\n    }\n  else if (data >= end)\n    {\n      warn (_(\"%s: Corrupt entry count - expected %s but none found\\n\"),\n\t    table_name, dwarf_vmatoa (\"x\", data_count));\n      return data;\n    }\n\n  else if (format_count == 0)\n    {\n      warn (_(\"%s: format count is zero, but the table is not empty\\n\"),\n\t    table_name);\n      return end;\n    }\n\n  printf (_(\"\\n The %s (offset 0x%lx, lines %s, columns %u):\\n\"),\n\t  table_name, (long) (data - start), dwarf_vmatoa (\"u\", data_count),\n\t  format_count);\n\n  printf (_(\"  Entry\"));\n  \/* Delay displaying name as the last entry for better screen layout.  *\/\n  for (namepass = 0; namepass < 2; namepass++)\n    {\n      format = format_start;\n      for (formati = 0; formati < format_count; formati++)\n\t{\n\t  dwarf_vma content_type;\n\n\t  READ_ULEB (content_type, format, end);\n\t  if ((content_type == DW_LNCT_path) == (namepass == 1))\n\t    switch (content_type)\n\t      {\n\t      case DW_LNCT_path:\n\t\tprintf (_(\"\\tName\"));\n\t\tbreak;\n\t      case DW_LNCT_directory_index:\n\t\tprintf (_(\"\\tDir\"));\n\t\tbreak;\n\t      case DW_LNCT_timestamp:\n\t\tprintf (_(\"\\tTime\"));\n\t\tbreak;\n\t      case DW_LNCT_size:\n\t\tprintf (_(\"\\tSize\"));\n\t\tbreak;\n\t      case DW_LNCT_MD5:\n\t\tprintf (_(\"\\tMD5\\t\\t\\t\"));\n\t\tbreak;\n\t      default:\n\t\tprintf (_(\"\\t(Unknown format content type %s)\"),\n\t\t\tdwarf_vmatoa (\"u\", content_type));\n\t      }\n\t  SKIP_ULEB (format, end);\n\t}\n    }\n  putchar ('\\n');\n\n  for (datai = 0; datai < data_count; datai++)\n    {\n      unsigned char *datapass = data;\n\n      printf (\"  %d\", last_entry++);\n      \/* Delay displaying name as the last entry for better screen layout.  *\/\n      for (namepass = 0; namepass < 2; namepass++)\n\t{\n\t  format = format_start;\n\t  data = datapass;\n\t  for (formati = 0; formati < format_count; formati++)\n\t    {\n\t      dwarf_vma content_type, form;\n\n\t      READ_ULEB (content_type, format, end);\n\t      READ_ULEB (form, format, end);\n\t      data = read_and_display_attr_value (0, form, 0, start, data, end,\n\t\t\t\t\t\t  0, 0, linfo->li_offset_size,\n\t\t\t\t\t\t  linfo->li_version, NULL,\n\t\t\t    ((content_type == DW_LNCT_path) != (namepass == 1)),\n\t\t\t\t\t\t  section, NULL, '\\t', -1);\n\t    }\n\t}\n\n      if (data >= end && (datai < data_count - 1))\n\t{\n\t  warn (_(\"\\n%s: Corrupt entries list\\n\"), table_name);\n\t  return data;\n\t}\n      putchar ('\\n');\n    }\n  return data;\n}","target":0,"code_token_length":964,"total_token_length":1200,"max_tokens_setting":2048}
+{"idx":343276,"func":"void dodele(char *name)\n{\n#ifndef ANON_CAN_DELETE\n    if (guest != 0) {\n        addreply_noformat(550, MSG_ANON_CANT_DELETE);\n        return;\n    }\n#endif\n    if (name == NULL || *name == 0) {\n        addreply_noformat(501, MSG_NO_FILE_NAME);\n        return;\n    }\n    if (checknamesanity(name, dot_write_ok) != 0) {\n        addreply(553, MSG_SANITY_FILE_FAILURE, name);\n        return;\n    }\n    if (keepallfiles != 0) {\n#ifdef EPERM\n        errno = EPERM;\n#else\n        errno = 1;\n#endif\n        goto denied;\n    }\n\n    \/*\n     * What we do here may look a bit strange. It's to defend against\n     * change-after-stat attacks. If we simply do lstat(name), then unlink(name)\n     * there's a race. An attacker can rename the file between these two\n     * system calls, so that a big file is lstat()ed, but a dummy tiny file is\n     * unlinked. That way, an attacker could easily get extra quota.\n     * To defend against this attack, we rename the file to an unique dot-file\n     * (an atomic operation) . People subject to quotas can't access dot-files.\n     * So we can securely stat it and unlink it. Having the pid in the file\n     * name should be enough to avoid that two concurrent sessions create the\n     * same temporary file. But to be paranoid to the extreme, we add some\n     * random number to that.\n     *\/\n\n#ifdef QUOTAS\n    {\n        char *p;\n        struct stat st;\n        struct stat st2;\n        size_t dirlen = (size_t) 0U;\n        char qtfile[PATH_MAX + 1];\n\n        if ((p = strrchr(name, '\/')) != NULL) {\n            if ((dirlen = p - name + (size_t) 1U) >= sizeof qtfile) {\n                goto denied;       \/* should never happen *\/\n            }\n            memcpy(qtfile, name, dirlen);   \/* safe, dirlen < sizeof qtfile *\/\n        }\n        if (SNCHECK(snprintf(qtfile + dirlen, sizeof qtfile - dirlen,\n                             PUREFTPD_TMPFILE_PREFIX \"rename.%lu.%x\",\n                             (unsigned long) getpid(), zrand()),\n                    sizeof qtfile)) {\n            goto denied;\n        }\n        if (lstat(name, &st) != 0) {\n            goto denied;\n        }\n        if (!S_ISREG(st.st_mode)\n# ifndef NEVER_DELETE_SYMLINKS\n            && !S_ISLNK(st.st_mode)\n# endif\n            ) {\n# ifdef EINVAL\n            errno = EINVAL;\n# endif\n            goto denied;\n        }\n        if (rename(name, qtfile) != 0) {\n            goto denied;\n        }\n        if (lstat(qtfile, &st2) != 0 ||\n            st.st_dev != st2.st_dev ||\n            st.st_ino != st2.st_ino ||\n            st.st_size != st2.st_size) {\n# ifdef EINVAL\n            errno = EINVAL;\n# endif\n            goto denied;\n        }\n        if (unlink(qtfile) < 0) {\n            \/*\n             * Race if rename() goes to an existing file.\n             * seems very difficult to exploit, though.\n             * Does a perfect userland answer exist, after all?\n             *\/\n            (void) rename(qtfile, name);\n            goto denied;\n        }\n        {\n            Quota quota;\n\n            if (quota_update("a, -1LL,\n                             -((long long) st.st_size), NULL) == 0) {\n                displayquota("a);\n            }\n        }\n    }\n#else\n    if (unlink(name) < 0) {\n        goto denied;\n    }\n#endif\n    addreply(250, MSG_DELE_SUCCESS, \"\", \"\", \"\", name);\n    logfile(LOG_NOTICE, MSG_DELE_SUCCESS, root_directory,\n            *name == '\/' ? \"\" : wd,\n            (*name != '\/' && (!*wd || wd[strlen(wd) - 1] != '\/'))\n            ? \"\/\" : \"\", name);\n    return;\n\n    denied:\n    addreply(550, MSG_DELE_FAILED \": %s\", name, strerror(errno));\n}","target":0,"code_token_length":937,"total_token_length":1173,"max_tokens_setting":2048}
+{"idx":274726,"func":"callbacks_handle_log_messages(const gchar *log_domain, GLogLevelFlags log_level,\n\t\t      const gchar *message, gpointer user_data)\n{\n\tGtkTextBuffer *textbuffer = NULL;\n\tGtkTextIter iter;\n\tGtkTextTag *tag;\n\tGtkTextMark *StartMark = NULL, *StopMark = NULL;\n\tGtkTextIter StartIter, StopIter;\n\tGtkWidget *dialog, *label;\n\n\tif (!screen.win.messageTextView)\n\t\treturn;\n\t\t\n\ttextbuffer = gtk_text_view_get_buffer((GtkTextView*)screen.win.messageTextView);\n\n\t\/* create a mark for the end of the text. *\/\n\tgtk_text_buffer_get_end_iter(textbuffer, &iter);\n\n\t\/* get the current end position of the text (it will be the\n\t      start of the new text. *\/\n\tStartMark = gtk_text_buffer_create_mark(textbuffer,\n\t\t\t\t\t    \"NewTextStart\", &iter, TRUE);\n\n\ttag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t                              \"blue_foreground\");\n\t\/* the tag does not exist: create it and let them exist in the tag table.*\/\n\tif (tag == NULL)    {\n\t\ttag = gtk_text_buffer_create_tag(textbuffer, \"black_foreground\",\n\t\t                              \"foreground\", \"black\", NULL);\n\t\ttag = gtk_text_buffer_create_tag(textbuffer, \"blue_foreground\",\n\t\t                              \"foreground\", \"blue\", NULL);\n\t\ttag = gtk_text_buffer_create_tag(textbuffer, \"red_foreground\",\n\t\t                              \"foreground\", \"red\", NULL);\n\t\ttag = gtk_text_buffer_create_tag(textbuffer, \"darkred_foreground\",\n\t\t                              \"foreground\", \"darkred\", NULL);\n\t\ttag = gtk_text_buffer_create_tag(textbuffer, \"darkblue_foreground\",\n\t\t                              \"foreground\", \"darkblue\", NULL);\n\t\ttag = gtk_text_buffer_create_tag (textbuffer, \"darkgreen_foreground\",\n\t\t                              \"foreground\", \"darkgreen\", NULL);\n\t\ttag = gtk_text_buffer_create_tag (textbuffer,\n\t\t                              \"saddlebrown_foreground\",\n\t\t                              \"foreground\", \"saddlebrown\", NULL);\n\t}\n\n\t\/* \n\t* See rgb.txt for the color names definition \n\t* (on my PC it is on \/usr\/X11R6\/lib\/X11\/rgb.txt)\n\t*\/\n\tswitch (log_level & G_LOG_LEVEL_MASK) {\n\tcase G_LOG_LEVEL_ERROR:\n\t\/* a message of this kind aborts the application calling abort() *\/\n\t      tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t                                    \"red_foreground\");\n\t      gtk_notebook_set_current_page(GTK_NOTEBOOK(screen.win.sidepane_notebook), 1);\n\t      gtk_widget_show(screen.win.sidepane_notebook);\n\t\tbreak;\n\tcase G_LOG_LEVEL_CRITICAL:\n\t      tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t                                    \"red_foreground\");\n\t      gtk_notebook_set_current_page(GTK_NOTEBOOK(screen.win.sidepane_notebook), 1);\n\t      gtk_widget_show(screen.win.sidepane_notebook);\n\t\tbreak;\n\tcase G_LOG_LEVEL_WARNING:\n\t      tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t                                    \"darkred_foreground\");\n\t      gtk_notebook_set_current_page(GTK_NOTEBOOK(screen.win.sidepane_notebook), 1);\n\t      gtk_widget_show(screen.win.sidepane_notebook);\n\t\tbreak;\n\tcase G_LOG_LEVEL_MESSAGE:\n\t      tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t                                    \"darkblue_foreground\");\n\t      gtk_notebook_set_current_page(GTK_NOTEBOOK(screen.win.sidepane_notebook), 1);\n\t      gtk_widget_show(screen.win.sidepane_notebook);\n\t\tbreak;\n\tcase G_LOG_LEVEL_INFO:\n\t      tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t                                    \"darkgreen_foreground\");\n\t\tbreak;\n\tcase G_LOG_LEVEL_DEBUG:\n\t\ttag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(textbuffer),\n\t\t\t\t\t\"saddlebrown_foreground\");\n\t\tbreak;\n\tdefault:\n\t      tag = gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table(textbuffer),\n\t                                    \"black_foreground\");\n\t\tbreak;\n\t}\n\n\t\/*\n\t* Fatal aborts application. We will try to get the message out anyhow.\n\t*\/\n\tif (log_level & G_LOG_FLAG_FATAL) {\n\t\tfprintf(stderr, _(\"Fatal error: %s\\n\"), message);\n\n\t\t\/* Try to show dialog box with error message *\/\n\t\tdialog = gtk_dialog_new_with_buttons(_(\"Fatal Error\"),\n\t\t\tNULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,\n\t\t\tGTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);\n\n\t\tlabel = gtk_label_new(g_strdup_printf(_(\"Fatal error: %s\"), message));\n\t\tgtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),\n\t\t\t\tlabel);\n\t\tgtk_label_set_selectable(GTK_LABEL(label), TRUE);\n\t\tgtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),\n\t\t\t\tgtk_label_new(_(\"\\nGerbv will be closed now!\")));\n\n\t\tgtk_container_set_border_width(GTK_CONTAINER(dialog), 5);\n\n\t\tgtk_widget_show_all(dialog);\n\t\tgtk_dialog_run(GTK_DIALOG(dialog));\n\t}\n\n\tgtk_text_buffer_insert(textbuffer, &iter, message, -1);\n\tgtk_text_buffer_insert(textbuffer, &iter, \"\\n\", -1);\n\n\t\/* Scroll view to inserted text *\/\n\tg_signal_emit_by_name(textbuffer, \"paste-done\", NULL);\n\n\tgtk_text_buffer_get_end_iter(textbuffer, &iter);\n\n\tStopMark = gtk_text_buffer_create_mark(textbuffer,\n\t\t\t\t\t   \"NewTextStop\", &iter, TRUE);\n\n\tgtk_text_buffer_get_iter_at_mark(textbuffer, &StartIter, StartMark);\n\tgtk_text_buffer_get_iter_at_mark(textbuffer, &StopIter, StopMark);\n\n\tgtk_text_buffer_apply_tag(textbuffer, tag, &StartIter, &StopIter);\n}","target":0,"code_token_length":1198,"total_token_length":1434,"max_tokens_setting":2048}
+{"idx":195908,"func":"int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,\n\t\t    u64 devid)\n{\n\tstruct btrfs_device *device;\n\tstruct btrfs_fs_devices *cur_devices;\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tu64 num_devices;\n\tint ret = 0;\n\n\tmutex_lock(&uuid_mutex);\n\n\tnum_devices = btrfs_num_devices(fs_info);\n\n\tret = btrfs_check_raid_min_devices(fs_info, num_devices - 1);\n\tif (ret)\n\t\tgoto out;\n\n\tdevice = btrfs_find_device_by_devspec(fs_info, devid, device_path);\n\n\tif (IS_ERR(device)) {\n\t\tif (PTR_ERR(device) == -ENOENT &&\n\t\t    strcmp(device_path, \"missing\") == 0)\n\t\t\tret = BTRFS_ERROR_DEV_MISSING_NOT_FOUND;\n\t\telse\n\t\t\tret = PTR_ERR(device);\n\t\tgoto out;\n\t}\n\n\tif (btrfs_pinned_by_swapfile(fs_info, device)) {\n\t\tbtrfs_warn_in_rcu(fs_info,\n\t\t  \"cannot remove device %s (devid %llu) due to active swapfile\",\n\t\t\t\t  rcu_str_deref(device->name), device->devid);\n\t\tret = -ETXTBSY;\n\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) {\n\t\tret = BTRFS_ERROR_DEV_TGT_REPLACE;\n\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&\n\t    fs_info->fs_devices->rw_devices == 1) {\n\t\tret = BTRFS_ERROR_DEV_ONLY_WRITABLE;\n\t\tgoto out;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {\n\t\tmutex_lock(&fs_info->chunk_mutex);\n\t\tlist_del_init(&device->dev_alloc_list);\n\t\tdevice->fs_devices->rw_devices--;\n\t\tmutex_unlock(&fs_info->chunk_mutex);\n\t}\n\n\tmutex_unlock(&uuid_mutex);\n\tret = btrfs_shrink_device(device, 0);\n\tif (!ret)\n\t\tbtrfs_reada_remove_dev(device);\n\tmutex_lock(&uuid_mutex);\n\tif (ret)\n\t\tgoto error_undo;\n\n\t\/*\n\t * TODO: the superblock still includes this device in its num_devices\n\t * counter although write_all_supers() is not locked out. This\n\t * could give a filesystem state which requires a degraded mount.\n\t *\/\n\tret = btrfs_rm_dev_item(device);\n\tif (ret)\n\t\tgoto error_undo;\n\n\tclear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);\n\tbtrfs_scrub_cancel_dev(device);\n\n\t\/*\n\t * the device list mutex makes sure that we don't change\n\t * the device list while someone else is writing out all\n\t * the device supers. Whoever is writing all supers, should\n\t * lock the device list mutex before getting the number of\n\t * devices in the super block (super_copy). Conversely,\n\t * whoever updates the number of devices in the super block\n\t * (super_copy) should hold the device list mutex.\n\t *\/\n\n\t\/*\n\t * In normal cases the cur_devices == fs_devices. But in case\n\t * of deleting a seed device, the cur_devices should point to\n\t * its own fs_devices listed under the fs_devices->seed.\n\t *\/\n\tcur_devices = device->fs_devices;\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tlist_del_rcu(&device->dev_list);\n\n\tcur_devices->num_devices--;\n\tcur_devices->total_devices--;\n\t\/* Update total_devices of the parent fs_devices if it's seed *\/\n\tif (cur_devices != fs_devices)\n\t\tfs_devices->total_devices--;\n\n\tif (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))\n\t\tcur_devices->missing_devices--;\n\n\tbtrfs_assign_next_active_device(device, NULL);\n\n\tif (device->bdev) {\n\t\tcur_devices->open_devices--;\n\t\t\/* remove sysfs entry *\/\n\t\tbtrfs_sysfs_remove_device(device);\n\t}\n\n\tnum_devices = btrfs_super_num_devices(fs_info->super_copy) - 1;\n\tbtrfs_set_super_num_devices(fs_info->super_copy, num_devices);\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\t\/*\n\t * at this point, the device is zero sized and detached from\n\t * the devices list.  All that's left is to zero out the old\n\t * supers and free the device.\n\t *\/\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state))\n\t\tbtrfs_scratch_superblocks(fs_info, device->bdev,\n\t\t\t\t\t  device->name->str);\n\n\tbtrfs_close_bdev(device);\n\tsynchronize_rcu();\n\tbtrfs_free_device(device);\n\n\tif (cur_devices->open_devices == 0) {\n\t\tlist_del_init(&cur_devices->seed_list);\n\t\tclose_fs_devices(cur_devices);\n\t\tfree_fs_devices(cur_devices);\n\t}\n\nout:\n\tmutex_unlock(&uuid_mutex);\n\treturn ret;\n\nerror_undo:\n\tbtrfs_reada_undo_remove_dev(device);\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {\n\t\tmutex_lock(&fs_info->chunk_mutex);\n\t\tlist_add(&device->dev_alloc_list,\n\t\t\t &fs_devices->alloc_list);\n\t\tdevice->fs_devices->rw_devices++;\n\t\tmutex_unlock(&fs_info->chunk_mutex);\n\t}\n\tgoto out;\n}","target":1,"code_token_length":1117,"total_token_length":1353,"max_tokens_setting":2048}
+{"idx":221678,"func":"int Socket::startSslClient(const std::string &certificate_path, String hostname)\n{\n    if (isssl) {\n        stopSsl();\n    }\n\n    ERR_clear_error();\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n    ctx = SSL_CTX_new(SSLv23_client_method());\n#else\n    ctx = SSL_CTX_new(TLS_client_method());\n#endif\n\n    if (ctx == NULL) {\n#ifdef NETDEBUG\n        std::cout << thread_id << \"Error ssl context is null (check that openssl has been inited)\" << std::endl;\n#endif\n        log_ssl_errors(\"Error ssl context is null for %s\", hostname.c_str());\n        return -1;\n    }\n\n    \/\/set the timeout for the ssl session\n    if (SSL_CTX_set_timeout(ctx, 130l) < 1) {\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -1;\n    }\n\n    \/\/load certs\n    ERR_clear_error();\n    if (certificate_path.length()) {\n        if (!SSL_CTX_load_verify_locations(ctx, NULL, certificate_path.c_str())) {\n#ifdef NETDEBUG\n            std::cout << thread_id << \"couldnt load certificates\" << std::endl;\n#endif\n            log_ssl_errors(\"couldnt load certificates from %s\", certificate_path.c_str());\n            \/\/tidy up\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n            return -2;\n        }\n    } else if (!SSL_CTX_set_default_verify_paths(ctx)) \/\/use default if no certPpath given\n    {\n#ifdef NETDEBUG\n        std::cout << thread_id << \"couldnt load certificates\" << std::endl;\n#endif\n            log_ssl_errors(\"couldnt load default certificates for %s\", hostname.c_str());\n        \/\/tidy up\n        SSL_CTX_free(ctx);\n        ctx = NULL;\n        return -2;\n    }\n\n    \/\/ add validation params\n    ERR_clear_error();\n    X509_VERIFY_PARAM *x509_param = X509_VERIFY_PARAM_new();\n    if (!x509_param) {\n        log_ssl_errors(\"couldnt add validation params for %s\", hostname.c_str());\n        \/\/X509_VERIFY_PARAM_free(x509_param);\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -2;\n    }\n\n    ERR_clear_error();\n    if (!X509_VERIFY_PARAM_set_flags(x509_param, X509_V_FLAG_TRUSTED_FIRST)) {\n        log_ssl_errors(\"couldnt add validation params for %s\", hostname.c_str());\n        X509_VERIFY_PARAM_free(x509_param);\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -2;\n    }\n\n    ERR_clear_error();\n    if (!SSL_CTX_set1_param(ctx, x509_param)) {\n        log_ssl_errors(\"couldnt add validation params for %s\", hostname.c_str());\n        X509_VERIFY_PARAM_free(x509_param);\n            SSL_CTX_free(ctx);\n            ctx = NULL;\n        return -2;\n    }\n\n    X509_VERIFY_PARAM_free(x509_param);     \/\/ try not freeing this as SSL_CTX_free seems to be ring to free it\n\n    \/\/hand socket over to ssl lib\n    ERR_clear_error();\n    ssl = SSL_new(ctx);\n    SSL_set_options(ssl, SSL_OP_ALL);\n    SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);\n    SSL_set_connect_state(ssl);\n\n    \/\/fcntl(this->getFD() ,F_SETFL, O_NONBLOCK); \/\/ blocking mode used currently\n    SSL_set_fd(ssl, this->getFD());\n    SSL_set_tlsext_host_name(ssl, hostname.c_str());\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n#else\n  X509_VERIFY_PARAM_set1_host(SSL_get0_param(ssl),hostname.c_str(),0);\n#endif\n\n    \/\/make io non blocking as select wont tell us if we can do a read without blocking\n    \/\/BIO_set_nbio(SSL_get_rbio(ssl),1l);  \/\/ blocking mode used currently\n    \/\/BIO_set_nbio(SSL_get_wbio(ssl),1l); \/\/ blocking mode used currently\n    ERR_clear_error();\n    int rc = SSL_connect(ssl);\n    if (rc < 0) {\n        log_ssl_errors(\"ssl_connect failed to %s\", hostname.c_str());\n#ifdef NETDEBUG\n        std::cout << thread_id << \"ssl_connect failed with error \" << SSL_get_error(ssl, rc) << std::endl;\n#endif\n        \/\/ tidy up\n        SSL_free(ssl);\n        ssl = NULL;\n        SSL_CTX_free(ctx);\n        ctx = NULL;\n        return -3;\n    }\n\n    \/\/should be safer to do this last as nothing will ever try to use a ssl socket that isnt fully setup\n    isssl = true;\n    issslserver = false;\n    return 0;\n}","target":0,"code_token_length":1047,"total_token_length":1283,"max_tokens_setting":2048}
+{"idx":355637,"func":"eval6(\n    char_u\t**arg,\n    typval_T\t*rettv,\n    evalarg_T\t*evalarg,\n    int\t\twant_string)  \/\/ after \".\" operator\n{\n#ifdef FEAT_FLOAT\n    int\t    use_float = FALSE;\n#endif\n\n    \/*\n     * Get the first variable.\n     *\/\n    if (eval7t(arg, rettv, evalarg, want_string) == FAIL)\n\treturn FAIL;\n\n    \/*\n     * Repeat computing, until no '*', '\/' or '%' is following.\n     *\/\n    for (;;)\n    {\n\tint\t    evaluate;\n\tint\t    getnext;\n\ttypval_T    var2;\n\tchar_u\t    *p;\n\tint\t    op;\n\tvarnumber_T n1, n2;\n#ifdef FEAT_FLOAT\n\tfloat_T\t    f1, f2;\n#endif\n\tint\t    error;\n\n\t\/\/ \"*=\", \"\/=\" and \"%=\" are assignments\n\tp = eval_next_non_blank(*arg, evalarg, &getnext);\n\top = *p;\n\tif ((op != '*' && op != '\/' && op != '%') || p[1] == '=')\n\t    break;\n\n\tevaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);\n\tif (getnext)\n\t    *arg = eval_next_line(evalarg);\n\telse\n\t{\n\t    if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))\n\t    {\n\t\terror_white_both(*arg, 1);\n\t\tclear_tv(rettv);\n\t\treturn FAIL;\n\t    }\n\t    *arg = p;\n\t}\n\n#ifdef FEAT_FLOAT\n\tf1 = 0;\n\tf2 = 0;\n#endif\n\terror = FALSE;\n\tif (evaluate)\n\t{\n#ifdef FEAT_FLOAT\n\t    if (rettv->v_type == VAR_FLOAT)\n\t    {\n\t\tf1 = rettv->vval.v_float;\n\t\tuse_float = TRUE;\n\t\tn1 = 0;\n\t    }\n\t    else\n#endif\n\t\tn1 = tv_get_number_chk(rettv, &error);\n\t    clear_tv(rettv);\n\t    if (error)\n\t\treturn FAIL;\n\t}\n\telse\n\t    n1 = 0;\n\n\t\/*\n\t * Get the second variable.\n\t *\/\n\tif (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))\n\t{\n\t    error_white_both(*arg, 1);\n\t    clear_tv(rettv);\n\t    return FAIL;\n\t}\n\t*arg = skipwhite_and_linebreak(*arg + 1, evalarg);\n\tif (eval7t(arg, &var2, evalarg, FALSE) == FAIL)\n\t    return FAIL;\n\n\tif (evaluate)\n\t{\n#ifdef FEAT_FLOAT\n\t    if (var2.v_type == VAR_FLOAT)\n\t    {\n\t\tif (!use_float)\n\t\t{\n\t\t    f1 = n1;\n\t\t    use_float = TRUE;\n\t\t}\n\t\tf2 = var2.vval.v_float;\n\t\tn2 = 0;\n\t    }\n\t    else\n#endif\n\t    {\n\t\tn2 = tv_get_number_chk(&var2, &error);\n\t\tclear_tv(&var2);\n\t\tif (error)\n\t\t    return FAIL;\n#ifdef FEAT_FLOAT\n\t\tif (use_float)\n\t\t    f2 = n2;\n#endif\n\t    }\n\n\t    \/*\n\t     * Compute the result.\n\t     * When either side is a float the result is a float.\n\t     *\/\n#ifdef FEAT_FLOAT\n\t    if (use_float)\n\t    {\n\t\tif (op == '*')\n\t\t    f1 = f1 * f2;\n\t\telse if (op == '\/')\n\t\t{\n# ifdef VMS\n\t\t    \/\/ VMS crashes on divide by zero, work around it\n\t\t    if (f2 == 0.0)\n\t\t    {\n\t\t\tif (f1 == 0)\n\t\t\t    f1 = -1 * __F_FLT_MAX - 1L;   \/\/ similar to NaN\n\t\t\telse if (f1 < 0)\n\t\t\t    f1 = -1 * __F_FLT_MAX;\n\t\t\telse\n\t\t\t    f1 = __F_FLT_MAX;\n\t\t    }\n\t\t    else\n\t\t\tf1 = f1 \/ f2;\n# else\n\t\t    \/\/ We rely on the floating point library to handle divide\n\t\t    \/\/ by zero to result in \"inf\" and not a crash.\n\t\t    f1 = f1 \/ f2;\n# endif\n\t\t}\n\t\telse\n\t\t{\n\t\t    emsg(_(e_cannot_use_percent_with_float));\n\t\t    return FAIL;\n\t\t}\n\t\trettv->v_type = VAR_FLOAT;\n\t\trettv->vval.v_float = f1;\n\t    }\n\t    else\n#endif\n\t    {\n\t\tint\t    failed = FALSE;\n\n\t\tif (op == '*')\n\t\t    n1 = n1 * n2;\n\t\telse if (op == '\/')\n\t\t    n1 = num_divide(n1, n2, &failed);\n\t\telse\n\t\t    n1 = num_modulus(n1, n2, &failed);\n\t\tif (failed)\n\t\t    return FAIL;\n\n\t\trettv->v_type = VAR_NUMBER;\n\t\trettv->vval.v_number = n1;\n\t    }\n\t}\n    }\n\n    return OK;\n}","target":0,"code_token_length":1059,"total_token_length":1295,"max_tokens_setting":2048}
+{"idx":229166,"func":"static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)\n{\n    VirtIODevice *vdev = VIRTIO_DEVICE(vser);\n    struct VirtIOSerialPort *port;\n    VirtIOSerialPortClass *vsc;\n    struct virtio_console_control cpkt, *gcpkt;\n    uint8_t *buffer;\n    size_t buffer_len;\n\n    gcpkt = buf;\n\n    if (len < sizeof(cpkt)) {\n        \/* The guest sent an invalid control packet *\/\n        return;\n    }\n\n    cpkt.event = virtio_lduw_p(vdev, &gcpkt->event);\n    cpkt.value = virtio_lduw_p(vdev, &gcpkt->value);\n\n    trace_virtio_serial_handle_control_message(cpkt.event, cpkt.value);\n\n    if (cpkt.event == VIRTIO_CONSOLE_DEVICE_READY) {\n        if (!cpkt.value) {\n            error_report(\"virtio-serial-bus: Guest failure in adding device %s\",\n                         vser->bus.qbus.name);\n            return;\n        }\n        \/*\n         * The device is up, we can now tell the device about all the\n         * ports we have here.\n         *\/\n        QTAILQ_FOREACH(port, &vser->ports, next) {\n            send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_ADD, 1);\n        }\n        return;\n    }\n\n    port = find_port_by_id(vser, virtio_ldl_p(vdev, &gcpkt->id));\n    if (!port) {\n        error_report(\"virtio-serial-bus: Unexpected port id %u for device %s\",\n                     virtio_ldl_p(vdev, &gcpkt->id), vser->bus.qbus.name);\n        return;\n    }\n\n    trace_virtio_serial_handle_control_message_port(port->id);\n\n    vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n\n    switch(cpkt.event) {\n    case VIRTIO_CONSOLE_PORT_READY:\n        if (!cpkt.value) {\n            error_report(\"virtio-serial-bus: Guest failure in adding port %u for device %s\",\n                         port->id, vser->bus.qbus.name);\n            break;\n        }\n        \/*\n         * Now that we know the guest asked for the port name, we're\n         * sure the guest has initialised whatever state is necessary\n         * for this port. Now's a good time to let the guest know if\n         * this port is a console port so that the guest can hook it\n         * up to hvc.\n         *\/\n        if (vsc->is_console) {\n            send_control_event(vser, port->id, VIRTIO_CONSOLE_CONSOLE_PORT, 1);\n        }\n\n        if (port->name) {\n            virtio_stl_p(vdev, &cpkt.id, port->id);\n            virtio_stw_p(vdev, &cpkt.event, VIRTIO_CONSOLE_PORT_NAME);\n            virtio_stw_p(vdev, &cpkt.value, 1);\n\n            buffer_len = sizeof(cpkt) + strlen(port->name) + 1;\n            buffer = g_malloc(buffer_len);\n\n            memcpy(buffer, &cpkt, sizeof(cpkt));\n            memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));\n            buffer[buffer_len - 1] = 0;\n\n            send_control_msg(vser, buffer, buffer_len);\n            g_free(buffer);\n        }\n\n        if (port->host_connected) {\n            send_control_event(vser, port->id, VIRTIO_CONSOLE_PORT_OPEN, 1);\n        }\n\n        \/*\n         * When the guest has asked us for this information it means\n         * the guest is all setup and has its virtqueues\n         * initialised. If some app is interested in knowing about\n         * this event, let it know.\n         *\/\n        if (vsc->guest_ready) {\n            vsc->guest_ready(port);\n        }\n        break;\n\n    case VIRTIO_CONSOLE_PORT_OPEN:\n        port->guest_connected = cpkt.value;\n        if (vsc->set_guest_connected) {\n            \/* Send the guest opened notification if an app is interested *\/\n            vsc->set_guest_connected(port, cpkt.value);\n        }\n        break;\n    }\n}","target":0,"code_token_length":902,"total_token_length":1138,"max_tokens_setting":2048}
+{"idx":445929,"func":"fr_window_populate_file_list (FrWindow  *window,\n\t\t\t      GPtrArray *files)\n{\n\tint         sort_column_id;\n\tGtkSortType order;\n\tint         i;\n\n\tif (! gtk_widget_get_realized (GTK_WIDGET (window))) {\n\t\t_fr_window_stop_activity_mode (window);\n\t\treturn;\n\t}\n\n\twindow->priv->populating_file_list = TRUE;\n\tgtk_list_store_clear (window->priv->list_store);\n\n\tgtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t      &sort_column_id,\n\t\t\t\t\t      &order);\n\tgtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store),\n\t \t\t\t\t      GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,\n\t \t\t\t\t      0);\n\n\tfor (i = 0; i < files->len; i++) {\n\t\tFileData    *fdata = g_ptr_array_index (files, i);\n\t\tGtkTreeIter  iter;\n\t\tGdkPixbuf   *icon, *emblem;\n\t\tchar        *utf8_name;\n\n\t\tif (fdata->list_name == NULL)\n\t\t\tcontinue;\n\n\t\tgtk_list_store_append (window->priv->list_store, &iter);\n\n\t\ticon = get_icon (window, fdata);\n\t\temblem = get_emblem (window, fdata);\n\t\tutf8_name = g_filename_display_name (fdata->list_name);\n\n\t\tif (file_data_is_dir (fdata)) {\n\t\t\tchar *utf8_path;\n\t\t\tchar *tmp;\n\t\t\tchar *s_size;\n\t\t\tchar *s_time;\n\n\t\t\tif (fdata->list_dir)\n\t\t\t\ttmp = _g_path_remove_ending_separator (fr_window_get_current_location (window));\n\n\t\t\telse\n\t\t\t\ttmp = _g_path_remove_level (fdata->path);\n\t\t\tutf8_path = g_filename_display_name (tmp);\n\t\t\tg_free (tmp);\n\n\t\t\ts_size = g_format_size (fdata->dir_size);\n\n\t\t\tif (fdata->list_dir)\n\t\t\t\ts_time = g_strdup (\"\");\n\t\t\telse\n\t\t\t\ts_time = _g_time_to_string (fdata->modified);\n\n\t\t\tgtk_list_store_set (window->priv->list_store, &iter,\n\t\t\t\t\t    COLUMN_FILE_DATA, fdata,\n\t\t\t\t\t    COLUMN_ICON, icon,\n\t\t\t\t\t    COLUMN_NAME, utf8_name,\n\t\t\t\t\t    COLUMN_EMBLEM, emblem,\n\t\t\t\t\t    COLUMN_TYPE, _(\"Folder\"),\n\t\t\t\t\t    COLUMN_SIZE, s_size,\n\t\t\t\t\t    COLUMN_TIME, s_time,\n\t\t\t\t\t    COLUMN_PATH, utf8_path,\n\t\t\t\t\t    -1);\n\t\t\tg_free (utf8_path);\n\t\t\tg_free (s_size);\n\t\t\tg_free (s_time);\n\t\t}\n\t\telse {\n\t\t\tchar       *utf8_path;\n\t\t\tchar       *s_size;\n\t\t\tchar       *s_time;\n\t\t\tconst char *desc;\n\n\t\t\tutf8_path = g_filename_display_name (fdata->path);\n\n\t\t\ts_size = g_format_size (fdata->size);\n\t\t\ts_time = _g_time_to_string (fdata->modified);\n\t\t\tdesc = g_content_type_get_description (fdata->content_type);\n\n\t\t\tgtk_list_store_set (window->priv->list_store, &iter,\n\t\t\t\t\t    COLUMN_FILE_DATA, fdata,\n\t\t\t\t\t    COLUMN_ICON, icon,\n\t\t\t\t\t    COLUMN_NAME, utf8_name,\n\t\t\t\t\t    COLUMN_EMBLEM, emblem,\n\t\t\t\t\t    COLUMN_TYPE, desc,\n\t\t\t\t\t    COLUMN_SIZE, s_size,\n\t\t\t\t\t    COLUMN_TIME, s_time,\n\t\t\t\t\t    COLUMN_PATH, utf8_path,\n\t\t\t\t\t    -1);\n\t\t\tg_free (utf8_path);\n\t\t\tg_free (s_size);\n\t\t\tg_free (s_time);\n\t\t}\n\n\t\tg_free (utf8_name);\n\t\t_g_object_unref (icon);\n\t\t_g_object_unref (emblem);\n\t}\n\n\tgtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t      sort_column_id,\n\t\t\t\t\t      order);\n\n\twindow->priv->populating_file_list = FALSE;\n\n\t_fr_window_stop_activity_mode (window);\n}","target":0,"code_token_length":813,"total_token_length":1049,"max_tokens_setting":2048}
+{"idx":238517,"func":"static int check_map_prog_compatibility(struct bpf_verifier_env *env,\n\t\t\t\t\tstruct bpf_map *map,\n\t\t\t\t\tstruct bpf_prog *prog)\n\n{\n\tenum bpf_prog_type prog_type = resolve_prog_type(prog);\n\t\/*\n\t * Validate that trace type programs use preallocated hash maps.\n\t *\n\t * For programs attached to PERF events this is mandatory as the\n\t * perf NMI can hit any arbitrary code sequence.\n\t *\n\t * All other trace types using preallocated hash maps are unsafe as\n\t * well because tracepoint or kprobes can be inside locked regions\n\t * of the memory allocator or at a place where a recursion into the\n\t * memory allocator would see inconsistent state.\n\t *\n\t * On RT enabled kernels run-time allocation of all trace type\n\t * programs is strictly prohibited due to lock type constraints. On\n\t * !RT kernels it is allowed for backwards compatibility reasons for\n\t * now, but warnings are emitted so developers are made aware of\n\t * the unsafety and can fix their programs before this is enforced.\n\t *\/\n\tif (is_tracing_prog_type(prog_type) && !is_preallocated_map(map)) {\n\t\tif (prog_type == BPF_PROG_TYPE_PERF_EVENT) {\n\t\t\tverbose(env, \"perf_event programs can only use preallocated hash map\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (IS_ENABLED(CONFIG_PREEMPT_RT)) {\n\t\t\tverbose(env, \"trace type programs can only use preallocated hash map\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tWARN_ONCE(1, \"trace type BPF program uses run-time allocation\\n\");\n\t\tverbose(env, \"trace type programs with run-time allocated hash maps are unsafe. Switch to preallocated hash maps.\\n\");\n\t}\n\n\tif (map_value_has_spin_lock(map)) {\n\t\tif (prog_type == BPF_PROG_TYPE_SOCKET_FILTER) {\n\t\t\tverbose(env, \"socket filter progs cannot use bpf_spin_lock yet\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (is_tracing_prog_type(prog_type)) {\n\t\t\tverbose(env, \"tracing progs cannot use bpf_spin_lock yet\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (prog->aux->sleepable) {\n\t\t\tverbose(env, \"sleepable progs cannot use bpf_spin_lock yet\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\tif (map_value_has_timer(map)) {\n\t\tif (is_tracing_prog_type(prog_type)) {\n\t\t\tverbose(env, \"tracing progs cannot use bpf_timer yet\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\tif ((bpf_prog_is_dev_bound(prog->aux) || bpf_map_is_dev_bound(map)) &&\n\t    !bpf_offload_prog_map_match(prog, map)) {\n\t\tverbose(env, \"offload device mismatch between prog and map\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (map->map_type == BPF_MAP_TYPE_STRUCT_OPS) {\n\t\tverbose(env, \"bpf_struct_ops map cannot be used in prog\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (prog->aux->sleepable)\n\t\tswitch (map->map_type) {\n\t\tcase BPF_MAP_TYPE_HASH:\n\t\tcase BPF_MAP_TYPE_LRU_HASH:\n\t\tcase BPF_MAP_TYPE_ARRAY:\n\t\tcase BPF_MAP_TYPE_PERCPU_HASH:\n\t\tcase BPF_MAP_TYPE_PERCPU_ARRAY:\n\t\tcase BPF_MAP_TYPE_LRU_PERCPU_HASH:\n\t\tcase BPF_MAP_TYPE_ARRAY_OF_MAPS:\n\t\tcase BPF_MAP_TYPE_HASH_OF_MAPS:\n\t\t\tif (!is_preallocated_map(map)) {\n\t\t\t\tverbose(env,\n\t\t\t\t\t\"Sleepable programs can only use preallocated maps\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BPF_MAP_TYPE_RINGBUF:\n\t\tcase BPF_MAP_TYPE_INODE_STORAGE:\n\t\tcase BPF_MAP_TYPE_SK_STORAGE:\n\t\tcase BPF_MAP_TYPE_TASK_STORAGE:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tverbose(env,\n\t\t\t\t\"Sleepable programs can only use array, hash, and ringbuf maps\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\treturn 0;\n}","target":0,"code_token_length":868,"total_token_length":1104,"max_tokens_setting":2048}
+{"idx":249975,"func":"GF_Err DoWrite(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emulation, u64 StartOffset)\n{\n\tu32 i;\n\tGF_Err e;\n\tTrackWriter *writer;\n\tu64 offset, sampOffset, predOffset;\n\tu32 chunkNumber, descIndex, sampSize;\n\tBool force;\n\tGF_StscEntry *stsc_ent;\n\tu64 size, mdatSize = 0;\n\tGF_ISOFile *movie = mw->movie;\n\n\t\/*write meta content first - WE DON'T support fragmentation of resources in ISOM atm*\/\n\tif (movie->openMode != GF_ISOM_OPEN_WRITE) {\n\t\tif (movie->meta) {\n\t\t\te = DoWriteMeta(movie, movie->meta, bs, Emulation, StartOffset, &size);\n\t\t\tif (e) return e;\n\t\t\tmdatSize += size;\n\t\t\tStartOffset += size;\n\t\t}\n\t\tif (movie->moov && movie->moov->meta) {\n\t\t\te = DoWriteMeta(movie, movie->meta, bs, Emulation, StartOffset, &size);\n\t\t\tif (e) return e;\n\t\t\tmdatSize += size;\n\t\t\tStartOffset += size;\n\t\t}\n\t\ti=0;\n\t\twhile ((writer = (TrackWriter*)gf_list_enum(writers, &i))) {\n\t\t\tif (writer->mdia->mediaTrack->meta) {\n\t\t\t\te = DoWriteMeta(movie, movie->meta, bs, Emulation, StartOffset, &size);\n\t\t\t\tif (e) return e;\n\t\t\t\tmdatSize += size;\n\t\t\t\tStartOffset += size;\n\t\t\t}\n\t\t}\n\t}\n\n\toffset = StartOffset;\n\tpredOffset = 0;\n\ti=0;\n\twhile ((writer = (TrackWriter*)gf_list_enum(writers, &i))) {\n\t\twhile (!writer->isDone) {\n\t\t\tBool self_contained;\n\t\t\tu32 nb_samp=1;\n\t\t\t\/\/To Check: are empty sample tables allowed ???\n\t\t\tif (writer->sampleNumber > writer->stbl->SampleSize->sampleCount) {\n\t\t\t\twriter->isDone = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\te = stbl_GetSampleInfos(writer->stbl, writer->sampleNumber, &sampOffset, &chunkNumber, &descIndex, &stsc_ent);\n\t\t\tif (e) return e;\n\t\t\te = stbl_GetSampleSize(writer->stbl->SampleSize, writer->sampleNumber, &sampSize);\n\t\t\tif (e) return e;\n\n\t\t\tupdate_writer_constant_dur(movie, writer, stsc_ent, &nb_samp, &sampSize, GF_TRUE);\n\n\t\t\t\/\/update our chunks.\n\t\t\tforce = 0;\n\t\t\tif (movie->openMode == GF_ISOM_OPEN_WRITE) {\n\t\t\t\toffset = sampOffset;\n\t\t\t\tif (predOffset != offset)\n\t\t\t\t\tforce = 1;\n\t\t\t}\n\n\t\t\tif (writer->stbl->MaxChunkSize && (writer->chunkSize + sampSize > writer->stbl->MaxChunkSize)) {\n\t\t\t\twriter->chunkSize = 0;\n\t\t\t\tforce = 1;\n\t\t\t}\n\t\t\twriter->chunkSize += sampSize;\n\n\t\t\tself_contained = ((writer->all_dref_mode==ISOM_DREF_SELF) || Media_IsSelfContained(writer->mdia, descIndex) ) ? GF_TRUE : GF_FALSE;\n\n\t\t\t\/\/update our global offset...\n\t\t\tif (self_contained) {\n\t\t\t\te = stbl_SetChunkAndOffset(writer->stbl, writer->sampleNumber, descIndex, writer->stsc, &writer->stco, offset, force, nb_samp);\n\t\t\t\tif (e) return e;\n\t\t\t\tif (movie->openMode == GF_ISOM_OPEN_WRITE) {\n\t\t\t\t\tpredOffset = sampOffset + sampSize;\n\t\t\t\t} else {\n\t\t\t\t\toffset += sampSize;\n\t\t\t\t\tmdatSize += sampSize;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (predOffset != offset) force = 1;\n\t\t\t\tpredOffset = sampOffset + sampSize;\n\t\t\t\t\/\/we have a DataRef, so use the offset idicated in sampleToChunk and ChunkOffset tables...\n\t\t\t\te = stbl_SetChunkAndOffset(writer->stbl, writer->sampleNumber, descIndex, writer->stsc, &writer->stco, sampOffset, force, nb_samp);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\t\t\t\/\/we write the sample if not emulation\n\t\t\tif (!Emulation) {\n\t\t\t\tif (self_contained) {\n\t\t\t\t\te = WriteSample(mw, sampSize, sampOffset, stsc_ent->isEdited, bs, 1);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/\/ok, the track is done\n\t\t\tif (writer->sampleNumber >= writer->stbl->SampleSize->sampleCount) {\n\t\t\t\twriter->isDone = 1;\n\t\t\t} else {\n\t\t\t\twriter->sampleNumber += nb_samp;\n\t\t\t}\n\t\t}\n\t}\n\t\/\/set the mdatSize...\n\tmovie->mdat->dataSize = mdatSize;\n\treturn GF_OK;\n}","target":0,"code_token_length":1084,"total_token_length":1320,"max_tokens_setting":2048}
+{"idx":247160,"func":"static void gf_fs_print_jsf_connection(GF_FilterSession *session, char *filter_name, GF_Filter *js_filter, void (*print_fn)(FILE *output, GF_SysPrintArgFlags flags, const char *fmt, ...) )\n{\n\tGF_CapsBundleStore capstore;\n\tconst char *js_name = NULL;\n\tGF_Err e=GF_OK;\n\tu32 i, j, count, nb_js_caps;\n\tGF_List *sources, *sinks;\n\tGF_FilterRegister loaded_freg;\n\tBool has_output, has_input;\n\n\tif (!js_filter) {\n\t\tjs_filter = gf_fs_load_filter(session, filter_name, &e);\n\t\tif (!js_filter) return;\n\t}\n\n\tjs_name = strrchr(filter_name, '\/');\n\tif (!js_name) js_name = strrchr(filter_name, '\\\\');\n\tif (js_name) js_name++;\n\telse js_name = filter_name;\n\n\tnb_js_caps = gf_filter_caps_bundle_count(js_filter->forced_caps, js_filter->nb_forced_caps);\n\n\t\/\/fake a new register with only the caps set\n\tmemset(&loaded_freg, 0, sizeof(GF_FilterRegister));\n\tloaded_freg.caps = js_filter->forced_caps;\n\tloaded_freg.nb_caps = js_filter->nb_forced_caps;\n\n\thas_output = gf_filter_has_out_caps(js_filter->forced_caps, js_filter->nb_forced_caps);\n\thas_input = gf_filter_has_in_caps(js_filter->forced_caps, js_filter->nb_forced_caps);\n\n\tmemset(&capstore, 0, sizeof(GF_CapsBundleStore));\n\tsources = gf_list_new();\n\tsinks = gf_list_new();\n\t\/\/edges for JS are for the unloaded JSF (eg accept anything, output anything).\n\t\/\/we need to do a manual check\n\tcount = gf_list_count(session->links);\n\tfor (i=0; i<count; i++) {\n\t\tu32 nb_src_caps, k, l;\n\t\tBool src_match = GF_FALSE;\n\t\tBool sink_match = GF_FALSE;\n\t\tGF_FilterRegDesc *a_reg = gf_list_get(session->links, i);\n\t\tif (a_reg->freg == js_filter->freg) continue;\n\n\t\t\/\/check which cap of this filter matches our destination\n\t\tnb_src_caps = gf_filter_caps_bundle_count(a_reg->freg->caps, a_reg->freg->nb_caps);\n\t\tfor (k=0; k<nb_src_caps; k++) {\n\t\t\tfor (l=0; l<nb_js_caps; l++) {\n\t\t\t\ts32 bundle_idx;\n\t\t\t\tu32 loaded_filter_only_flags = 0;\n\t\t\t\tu32 path_weight;\n\t\t\t\tif (has_input && !src_match) {\n\t\t\t\t\tpath_weight = gf_filter_caps_to_caps_match(a_reg->freg, k, (const GF_FilterRegister *) &loaded_freg, NULL, &bundle_idx, l, &loaded_filter_only_flags, &capstore);\n\t\t\t\t\tif (path_weight && (bundle_idx == l))\n\t\t\t\t\t\tsrc_match = GF_TRUE;\n\t\t\t\t}\n\t\t\t\tif (has_output && !sink_match) {\n\t\t\t\t\tloaded_filter_only_flags = 0;\n\t\t\t\t\tpath_weight = gf_filter_caps_to_caps_match(&loaded_freg, l, a_reg->freg, NULL, &bundle_idx, k, &loaded_filter_only_flags, &capstore);\n\n\t\t\t\t\tif (path_weight && (bundle_idx == k))\n\t\t\t\t\t\tsink_match = GF_TRUE;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (src_match && sink_match)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (src_match) gf_list_add(sources, (void *) a_reg->freg);\n\t\tif (sink_match) gf_list_add(sinks, (void *) a_reg->freg);\n\t}\n\n\tfor (i=0; i<2; i++) {\n\t\tGF_List *from = i ? sinks : sources;\n\t\tchar *type = i ? \"sinks\" : \"sources\";\n\n\t\tcount = gf_list_count(from);\n\t\tif (!count) {\n\t\t\tif (print_fn)\n\t\t\t\tprint_fn(stderr, 1, \"%s: no %s\\n\", js_name, type);\n\t\t\telse {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s: no %s\\n\", type));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s %s:\", js_name, type);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s %s:\", js_name, type));\n\t\t}\n\t\tfor (j=0; j<count; j++) {\n\t\t\tGF_FilterRegister *a_reg = gf_list_get(from, j);\n\t\t\tif (print_fn)\n\t\t\t\tprint_fn(stderr, 0, \" %s\", a_reg->name);\n\t\t\telse {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" %s\", a_reg->name));\n\t\t\t}\n\t\t}\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 0, \"\\n\");\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\n\"));\n\t\t}\n\t}\n\n\tif (capstore.bundles_cap_found) gf_free(capstore.bundles_cap_found);\n\tif (capstore.bundles_in_ok) gf_free(capstore.bundles_in_ok);\n\tif (capstore.bundles_in_scores) gf_free(capstore.bundles_in_scores);\n\tgf_list_del(sources);\n\tgf_list_del(sinks);\n}","target":0,"code_token_length":1144,"total_token_length":1380,"max_tokens_setting":2048}
+{"idx":436054,"func":"\nstatic int io_uring_create(unsigned entries, struct io_uring_params *p,\n\t\t\t   struct io_uring_params __user *params)\n{\n\tstruct io_ring_ctx *ctx;\n\tstruct file *file;\n\tint ret;\n\n\tif (!entries)\n\t\treturn -EINVAL;\n\tif (entries > IORING_MAX_ENTRIES) {\n\t\tif (!(p->flags & IORING_SETUP_CLAMP))\n\t\t\treturn -EINVAL;\n\t\tentries = IORING_MAX_ENTRIES;\n\t}\n\n\t\/*\n\t * Use twice as many entries for the CQ ring. It's possible for the\n\t * application to drive a higher depth than the size of the SQ ring,\n\t * since the sqes are only used at submission time. This allows for\n\t * some flexibility in overcommitting a bit. If the application has\n\t * set IORING_SETUP_CQSIZE, it will have passed in the desired number\n\t * of CQ ring entries manually.\n\t *\/\n\tp->sq_entries = roundup_pow_of_two(entries);\n\tif (p->flags & IORING_SETUP_CQSIZE) {\n\t\t\/*\n\t\t * If IORING_SETUP_CQSIZE is set, we do the same roundup\n\t\t * to a power-of-two, if it isn't already. We do NOT impose\n\t\t * any cq vs sq ring sizing.\n\t\t *\/\n\t\tif (!p->cq_entries)\n\t\t\treturn -EINVAL;\n\t\tif (p->cq_entries > IORING_MAX_CQ_ENTRIES) {\n\t\t\tif (!(p->flags & IORING_SETUP_CLAMP))\n\t\t\t\treturn -EINVAL;\n\t\t\tp->cq_entries = IORING_MAX_CQ_ENTRIES;\n\t\t}\n\t\tp->cq_entries = roundup_pow_of_two(p->cq_entries);\n\t\tif (p->cq_entries < p->sq_entries)\n\t\t\treturn -EINVAL;\n\t} else {\n\t\tp->cq_entries = 2 * p->sq_entries;\n\t}\n\n\tctx = io_ring_ctx_alloc(p);\n\tif (!ctx)\n\t\treturn -ENOMEM;\n\tctx->compat = in_compat_syscall();\n\tif (!capable(CAP_IPC_LOCK))\n\t\tctx->user = get_uid(current_user());\n\n\t\/*\n\t * This is just grabbed for accounting purposes. When a process exits,\n\t * the mm is exited and dropped before the files, hence we need to hang\n\t * on to this mm purely for the purposes of being able to unaccount\n\t * memory (locked\/pinned vm). It's not used for anything else.\n\t *\/\n\tmmgrab(current->mm);\n\tctx->mm_account = current->mm;\n\n\tret = io_allocate_scq_urings(ctx, p);\n\tif (ret)\n\t\tgoto err;\n\n\tret = io_sq_offload_create(ctx, p);\n\tif (ret)\n\t\tgoto err;\n\t\/* always set a rsrc node *\/\n\tret = io_rsrc_node_switch_start(ctx);\n\tif (ret)\n\t\tgoto err;\n\tio_rsrc_node_switch(ctx, NULL);\n\n\tmemset(&p->sq_off, 0, sizeof(p->sq_off));\n\tp->sq_off.head = offsetof(struct io_rings, sq.head);\n\tp->sq_off.tail = offsetof(struct io_rings, sq.tail);\n\tp->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask);\n\tp->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries);\n\tp->sq_off.flags = offsetof(struct io_rings, sq_flags);\n\tp->sq_off.dropped = offsetof(struct io_rings, sq_dropped);\n\tp->sq_off.array = (char *)ctx->sq_array - (char *)ctx->rings;\n\n\tmemset(&p->cq_off, 0, sizeof(p->cq_off));\n\tp->cq_off.head = offsetof(struct io_rings, cq.head);\n\tp->cq_off.tail = offsetof(struct io_rings, cq.tail);\n\tp->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask);\n\tp->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries);\n\tp->cq_off.overflow = offsetof(struct io_rings, cq_overflow);\n\tp->cq_off.cqes = offsetof(struct io_rings, cqes);\n\tp->cq_off.flags = offsetof(struct io_rings, cq_flags);\n\n\tp->features = IORING_FEAT_SINGLE_MMAP | IORING_FEAT_NODROP |\n\t\t\tIORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS |\n\t\t\tIORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL |\n\t\t\tIORING_FEAT_POLL_32BITS | IORING_FEAT_SQPOLL_NONFIXED |\n\t\t\tIORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS |\n\t\t\tIORING_FEAT_RSRC_TAGS;\n\n\tif (copy_to_user(params, p, sizeof(*p))) {\n\t\tret = -EFAULT;\n\t\tgoto err;\n\t}\n\n\tfile = io_uring_get_file(ctx);\n\tif (IS_ERR(file)) {\n\t\tret = PTR_ERR(file);\n\t\tgoto err;\n\t}\n\n\t\/*\n\t * Install ring fd as the very last thing, so we don't risk someone\n\t * having closed it before we finish setup\n\t *\/\n\tret = io_uring_install_fd(ctx, file);\n\tif (ret < 0) {\n\t\t\/* fput will clean it up *\/\n\t\tfput(file);\n\t\treturn ret;\n\t}\n\n\ttrace_io_uring_create(ret, ctx, p->sq_entries, p->cq_entries, p->flags);\n\treturn ret;\nerr:\n\tio_ring_ctx_wait_and_kill(ctx);\n\treturn ret;","target":0,"code_token_length":1144,"total_token_length":1380,"max_tokens_setting":2048}
+{"idx":223479,"func":"static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common)\n{\nDEFINE_COMPILER;\nconst sljit_u8 *start_bits = common->re->start_bitmap;\nstruct sljit_label *start;\nstruct sljit_jump *partial_quit;\n#if PCRE2_CODE_UNIT_WIDTH != 8\nstruct sljit_jump *found = NULL;\n#endif\njump_list *matches = NULL;\n\nif (common->match_end_ptr != 0)\n  {\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);\n  OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);\n  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));\n  OP2U(SLJIT_SUB | SLJIT_SET_GREATER, STR_END, 0, TMP1, 0);\n  CMOV(SLJIT_GREATER, STR_END, TMP1, 0);\n  }\n\nstart = LABEL();\n\npartial_quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);\nif (common->mode == PCRE2_JIT_COMPLETE)\n  add_jump(compiler, &common->failed_match, partial_quit);\n\nOP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\nif (!optimize_class(common, start_bits, (start_bits[31] & 0x80) != 0, FALSE, &matches))\n  {\n#if PCRE2_CODE_UNIT_WIDTH != 8\n  if ((start_bits[31] & 0x80) != 0)\n    found = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 255);\n  else\n    CMPTO(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 255, start);\n#elif defined SUPPORT_UNICODE\n  if (common->utf && is_char7_bitset(start_bits, FALSE))\n    CMPTO(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 127, start);\n#endif\n  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);\n  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);\n  OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits);\n  if (!HAS_VIRTUAL_REGISTERS)\n    {\n    OP2(SLJIT_SHL, TMP3, 0, SLJIT_IMM, 1, TMP2, 0);\n    OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP3, 0);\n    }\n  else\n    {\n    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);\n    OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);\n    }\n  JUMPTO(SLJIT_ZERO, start);\n  }\nelse\n  set_jumps(matches, start);\n\n#if PCRE2_CODE_UNIT_WIDTH != 8\nif (found != NULL)\n  JUMPHERE(found);\n#endif\n\nOP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\nif (common->mode != PCRE2_JIT_COMPLETE)\n  JUMPHERE(partial_quit);\n\nif (common->match_end_ptr != 0)\n  OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);\n}","target":0,"code_token_length":889,"total_token_length":1125,"max_tokens_setting":2048}
+{"idx":242661,"func":"dissect_sysdig_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,\n        void *data _U_)\n{\n    proto_item *ti;\n    proto_tree *se_tree, *syscall_tree;\n    guint       event_type = pinfo->rec->rec_header.syscall_header.event_type;\n    int         encoding = pinfo->rec->rec_header.syscall_header.byte_order == G_BIG_ENDIAN ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN;\n    const struct _event_col_info *cur_col_info;\n    const struct _event_tree_info *cur_tree_info;\n\n    \/*** HEURISTICS ***\/\n\n    \/* Check that the packet is long enough for it to belong to us. *\/\n    if (tvb_reported_length(tvb) < SYSDIG_EVENT_MIN_LENGTH)\n        return 0;\n\n    \/*** COLUMN DATA ***\/\n\n    \/*\n     * Sysdig uses the term \"event\" internally. So far every event has been\n     * a syscall.\n     *\/\n    col_set_str(pinfo->cinfo, COL_PROTOCOL, \"System Call\");\n\n    col_clear(pinfo->cinfo, COL_INFO);\n    col_add_str(pinfo->cinfo, COL_INFO, val_to_str(event_type, event_type_vals, \"Unknown syscall %u\"));\n    \/*\n     * XXX We can ditch this in favor of a simple index when event_col_info\n     * is contiguous and in the correct order.\n     *\/\n    for (cur_col_info = event_col_info; cur_col_info->params; cur_col_info++) {\n        if (cur_col_info->event_type == event_type) {\n            const struct _event_col_info_param *cur_param = cur_col_info->params;\n            int param_offset = cur_col_info->num_len_fields * 2;\n\n            \/* Find the data offset *\/\n            int cur_len_field;\n            for (cur_len_field = 0;\n                 cur_len_field < cur_col_info->num_len_fields && cur_param->param_name;\n                 cur_len_field++) {\n                unsigned param_len = tvb_get_guint16(tvb, cur_len_field * 2, encoding);\n                if (cur_param->param_num == cur_len_field) {\n                    col_append_fstr(pinfo->cinfo, COL_INFO, \", %s=\", cur_param->param_name);\n                    switch (cur_param->param_ftype) {\n                    case FT_STRING:\n                        col_append_str(pinfo->cinfo, COL_INFO, format_param_str(tvb, param_offset, param_len));\n                        break;\n                    case FT_UINT64:\n                        col_append_fstr(pinfo->cinfo, COL_INFO, \"%\" G_GUINT64_FORMAT, tvb_get_guint64(tvb, param_offset, encoding));\n                    default:\n                        break;\n                    }\n                    cur_param++;\n                }\n                param_offset += param_len;\n            }\n        }\n    }\n\n    \/*** PROTOCOL TREE ***\/\n\n    \/* create display subtree for the protocol *\/\n    ti = proto_tree_add_item(tree, proto_sysdig_event, tvb, 0, -1, ENC_NA);\n\n    se_tree = proto_item_add_subtree(ti, ett_sysdig_event);\n\n    proto_tree_add_uint(se_tree, hf_se_cpu_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.cpu_id);\n    proto_tree_add_uint64(se_tree, hf_se_thread_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.thread_id);\n    proto_tree_add_uint(se_tree, hf_se_event_length, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.event_len);\n    if (pinfo->rec->rec_header.syscall_header.nparams != 0) {\n        proto_tree_add_uint(se_tree, hf_se_nparams, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.nparams);\n    }\n    ti = proto_tree_add_uint(se_tree, hf_se_event_type, tvb, 0, 0, event_type);\n\n    syscall_tree = proto_item_add_subtree(ti, ett_sysdig_syscall);\n\n    for (cur_tree_info = event_tree_info; cur_tree_info->hf_indexes; cur_tree_info++) {\n        if (cur_tree_info->event_type == event_type) {\n            dissect_event_params(tvb, &pinfo->rec->rec_header.syscall_header, 0, syscall_tree, encoding, cur_tree_info->hf_indexes);\n            break;\n        }\n    }\n\n    \/* XXX *\/\n    \/* return offset; *\/\n    return pinfo->rec->rec_header.syscall_header.event_len;\n}","target":0,"code_token_length":955,"total_token_length":1191,"max_tokens_setting":2048}
+{"idx":214358,"func":"int qtm_decompress(struct qtm_stream *qtm, off_t out_bytes) {\n  unsigned int frame_start, frame_end, window_posn, match_offset, range;\n  unsigned char *window, *i_ptr, *i_end, *runsrc, *rundest;\n  int i, j, selector, extra, sym, match_length, ret;\n  unsigned short H, L, C, symf;\n\n  register unsigned int bit_buffer;\n  register unsigned char bits_left;\n  unsigned char bits_needed, bit_run;\n\n  \/* easy answers *\/\n  if (!qtm || (out_bytes < 0)) return CL_ENULLARG;\n  if (qtm->error) return qtm->error;\n\n  \/* flush out any stored-up bytes before we begin *\/\n  i = qtm->o_end - qtm->o_ptr;\n  if ((off_t) i > out_bytes) i = (int) out_bytes;\n  if (i) {\n    if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {\n      return qtm->error = ret;\n    }\n    qtm->o_ptr  += i;\n    out_bytes   -= i;\n  }\n  if (out_bytes == 0) return CL_SUCCESS;\n\n  \/* restore local state *\/\n  QTM_RESTORE_BITS;\n  window = qtm->window;\n  window_posn = qtm->window_posn;\n  frame_start = qtm->frame_start;\n  H = qtm->H;\n  L = qtm->L;\n  C = qtm->C;\n\n  \/* while we do not have enough decoded bytes in reserve: *\/\n  while ((qtm->o_end - qtm->o_ptr) < out_bytes) {\n\n    \/* read header if necessary. Initialises H, L and C *\/\n    if (!qtm->header_read) {\n      H = 0xFFFF; L = 0; QTM_READ_BITS(C, 16);\n      qtm->header_read = 1;\n    }\n\n    \/* decode more, at most up to to frame boundary *\/\n    frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr));\n    if ((frame_start + QTM_FRAME_SIZE) < frame_end) {\n      frame_end = frame_start + QTM_FRAME_SIZE;\n    }\n\n    while (window_posn < frame_end) {\n      QTM_GET_SYMBOL(qtm->model7, selector);\n      if (selector < 4) {\n\tstruct qtm_model *mdl = (selector == 0) ? &qtm->model0 :\n\t                        ((selector == 1) ? &qtm->model1 :\n\t\t\t\t((selector == 2) ? &qtm->model2 :\n                                                   &qtm->model3));\n\tQTM_GET_SYMBOL((*mdl), sym);\n\twindow[window_posn++] = sym;\n      }\n      else {\n\tswitch (selector) {\n\tcase 4: \/* selector 4 = fixed length match (3 bytes) *\/\n\t  QTM_GET_SYMBOL(qtm->model4, sym);\n\t  QTM_READ_BITS(extra, qtm->extra_bits[sym]);\n\t  match_offset = qtm->position_base[sym] + extra + 1;\n\t  match_length = 3;\n\t  break;\n\n\tcase 5: \/* selector 5 = fixed length match (4 bytes) *\/\n\t  QTM_GET_SYMBOL(qtm->model5, sym);\n\t  QTM_READ_BITS(extra, qtm->extra_bits[sym]);\n\t  match_offset = qtm->position_base[sym] + extra + 1;\n\t  match_length = 4;\n\t  break;\n\n\tcase 6: \/* selector 6 = variable length match *\/\n\t  QTM_GET_SYMBOL(qtm->model6len, sym);\n\t  QTM_READ_BITS(extra, qtm->length_extra[sym]);\n\t  match_length = qtm->length_base[sym] + extra + 5;\n\n\t  QTM_GET_SYMBOL(qtm->model6, sym);\n\t  QTM_READ_BITS(extra, qtm->extra_bits[sym]);\n\t  match_offset = qtm->position_base[sym] + extra + 1;\n\t  break;\n\n\tdefault:\n\t  \/* should be impossible, model7 can only return 0-6 *\/\n\t  return qtm->error = CL_EFORMAT;\n\t}\n\n\trundest = &window[window_posn];\n\ti = match_length;\n\t\/* does match offset wrap the window? *\/\n\tif (match_offset > window_posn) {\n\t  \/* j = length from match offset to end of window *\/\n\t  j = match_offset - window_posn;\n\t  if (j > (int) qtm->window_size) {\n\t    cli_dbgmsg(\"qtm_decompress: match offset beyond window boundaries\\n\");\n\t    return qtm->error = CL_EFORMAT;\n\t  }\n\t  runsrc = &window[qtm->window_size - j];\n\t  if (j < i) {\n\t    \/* if match goes over the window edge, do two copy runs *\/\n\t    i -= j; while (j-- > 0) *rundest++ = *runsrc++;\n\t    runsrc = window;\n\t  }\n\t  while (i-- > 0) *rundest++ = *runsrc++;\n\t}\n\telse {\n\t  runsrc = rundest - match_offset;\n\t  if(i > (int) (qtm->window_size - window_posn))\n\t    i = qtm->window_size - window_posn;\n\t  while (i-- > 0) *rundest++ = *runsrc++;\n\t}\n\twindow_posn += match_length;\n      }\n    } \/* while (window_posn < frame_end) *\/\n\n    qtm->o_end = &window[window_posn];\n\n    \/* another frame completed? *\/\n    if ((window_posn - frame_start) >= QTM_FRAME_SIZE) {\n      if ((window_posn - frame_start) != QTM_FRAME_SIZE) {\n\tcli_dbgmsg(\"qtm_decompress: overshot frame alignment\\n\");\n\treturn qtm->error = CL_EFORMAT;\n      }\n\n      \/* re-align input *\/\n      if (bits_left & 7) QTM_REMOVE_BITS(bits_left & 7);\n      do { QTM_READ_BITS(i, 8); } while (i != 0xFF);\n      qtm->header_read = 0;\n\n      \/* window wrap? *\/\n      if (window_posn == qtm->window_size) {\n\t\/* flush all currently stored data *\/\n\ti = (qtm->o_end - qtm->o_ptr);\n\tif (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {\n\t  return qtm->error = ret;\n\t}\n\tout_bytes -= i;\n\tqtm->o_ptr = &window[0];\n\tqtm->o_end = &window[0];\n\twindow_posn = 0;\n      }\n\n      frame_start = window_posn;\n    }\n\n  } \/* while (more bytes needed) *\/\n\n  if (out_bytes) {\n    i = (int) out_bytes;\n    if (qtm->wflag && (ret = mspack_write(qtm->ofd, qtm->o_ptr, i, qtm->file)) != CL_SUCCESS) {\n      return qtm->error = ret;\n    }\n    qtm->o_ptr += i;\n  }\n\n  \/* store local state *\/\n  QTM_STORE_BITS;\n  qtm->window_posn = window_posn;\n  qtm->frame_start = frame_start;\n  qtm->H = H;\n  qtm->L = L;\n  qtm->C = C;\n\n  return CL_SUCCESS;\n}","target":1,"code_token_length":1628,"total_token_length":1864,"max_tokens_setting":2048}
+{"idx":206989,"func":"apply_extra_data (FlatpakDir   *self,\n                  GFile        *checkoutdir,\n                  GCancellable *cancellable,\n                  GError      **error)\n{\n  g_autoptr(GFile) metadata = NULL;\n  g_autofree char *metadata_contents = NULL;\n  gsize metadata_size;\n  g_autoptr(GKeyFile) metakey = NULL;\n  g_autofree char *id = NULL;\n  g_autofree char *runtime_pref = NULL;\n  g_autoptr(FlatpakDecomposed) runtime_ref = NULL;\n  g_autoptr(FlatpakDeploy) runtime_deploy = NULL;\n  g_autoptr(FlatpakBwrap) bwrap = NULL;\n  g_autoptr(GFile) app_files = NULL;\n  g_autoptr(GFile) apply_extra_file = NULL;\n  g_autoptr(GFile) app_export_file = NULL;\n  g_autoptr(GFile) extra_export_file = NULL;\n  g_autoptr(GFile) extra_files = NULL;\n  g_autoptr(GFile) runtime_files = NULL;\n  g_autoptr(FlatpakContext) app_context = NULL;\n  g_auto(GStrv) minimal_envp = NULL;\n  g_autofree char *runtime_arch = NULL;\n  int exit_status;\n  const char *group = FLATPAK_METADATA_GROUP_APPLICATION;\n  g_autoptr(GError) local_error = NULL;\n\n  apply_extra_file = g_file_resolve_relative_path (checkoutdir, \"files\/bin\/apply_extra\");\n  if (!g_file_query_exists (apply_extra_file, cancellable))\n    return TRUE;\n\n  metadata = g_file_get_child (checkoutdir, \"metadata\");\n\n  if (!g_file_load_contents (metadata, cancellable, &metadata_contents, &metadata_size, NULL, error))\n    return FALSE;\n\n  metakey = g_key_file_new ();\n  if (!g_key_file_load_from_data (metakey, metadata_contents, metadata_size, 0, error))\n    return FALSE;\n\n  id = g_key_file_get_string (metakey, group, FLATPAK_METADATA_KEY_NAME,\n                              &local_error);\n  if (id == NULL)\n    {\n      group = FLATPAK_METADATA_GROUP_RUNTIME;\n      id = g_key_file_get_string (metakey, group, FLATPAK_METADATA_KEY_NAME,\n                                  NULL);\n      if (id == NULL)\n        {\n          g_propagate_error (error, g_steal_pointer (&local_error));\n          return FALSE;\n        }\n      g_clear_error (&local_error);\n    }\n\n  runtime_pref = g_key_file_get_string (metakey, group,\n                                        FLATPAK_METADATA_KEY_RUNTIME, error);\n  if (runtime_pref == NULL)\n    runtime_pref = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_EXTENSION_OF,\n                                          FLATPAK_METADATA_KEY_RUNTIME, NULL);\n  if (runtime_pref == NULL)\n    return FALSE;\n\n  runtime_ref = flatpak_decomposed_new_from_pref (FLATPAK_KINDS_RUNTIME, runtime_pref, error);\n  if (runtime_ref == NULL)\n    return FALSE;\n  runtime_arch = flatpak_decomposed_dup_arch (runtime_ref);\n\n  if (!g_key_file_get_boolean (metakey, FLATPAK_METADATA_GROUP_EXTRA_DATA,\n                               FLATPAK_METADATA_KEY_NO_RUNTIME, NULL))\n    {\n      \/* We pass in self here so that we ensure that we find the runtime in case it only\n         exists in this installation (which might be custom) *\/\n      runtime_deploy = flatpak_find_deploy_for_ref (flatpak_decomposed_get_ref (runtime_ref), NULL, self, cancellable, error);\n      if (runtime_deploy == NULL)\n        return FALSE;\n      runtime_files = flatpak_deploy_get_files (runtime_deploy);\n    }\n\n  app_files = g_file_get_child (checkoutdir, \"files\");\n  app_export_file = g_file_get_child (checkoutdir, \"export\");\n  extra_files = g_file_get_child (app_files, \"extra\");\n  extra_export_file = g_file_get_child (extra_files, \"export\");\n\n  minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE);\n  bwrap = flatpak_bwrap_new (minimal_envp);\n  flatpak_bwrap_add_args (bwrap, flatpak_get_bwrap (), NULL);\n\n  if (runtime_files)\n    flatpak_bwrap_add_args (bwrap,\n                            \"--ro-bind\", flatpak_file_get_path_cached (runtime_files), \"\/usr\",\n                            \"--lock-file\", \"\/usr\/.ref\",\n                            NULL);\n\n  flatpak_bwrap_add_args (bwrap,\n                          \"--ro-bind\", flatpak_file_get_path_cached (app_files), \"\/app\",\n                          \"--bind\", flatpak_file_get_path_cached (extra_files), \"\/app\/extra\",\n                          \"--chdir\", \"\/app\/extra\",\n                          \/* We run as root in the system-helper case, so drop all caps *\/\n                          \"--cap-drop\", \"ALL\",\n                          NULL);\n\n  if (!flatpak_run_setup_base_argv (bwrap, runtime_files, NULL, runtime_arch,\n                                    \/* Might need multiarch in apply_extra (see e.g. #3742). Should be pretty safe in this limited context *\/\n                                    FLATPAK_RUN_FLAG_MULTIARCH |\n                                    FLATPAK_RUN_FLAG_NO_SESSION_HELPER | FLATPAK_RUN_FLAG_NO_PROC,\n                                    error))\n    return FALSE;\n\n  app_context = flatpak_context_new ();\n\n  if (!flatpak_run_add_environment_args (bwrap, NULL,\n                                         FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY |\n                                         FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY |\n                                         FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY,\n                                         id,\n                                         app_context, NULL, NULL, NULL, cancellable, error))\n    return FALSE;\n\n  flatpak_bwrap_add_arg (bwrap, \"\/app\/bin\/apply_extra\");\n\n  flatpak_bwrap_finish (bwrap);\n\n  g_debug (\"Running \/app\/bin\/apply_extra \");\n\n  \/* We run the sandbox without caps, but it can still create files owned by itself with\n   * arbitrary permissions, including setuid myself. This is extra risky in the case where\n   * this runs as root in the system helper case. We canonicalize the permissions at the\n   * end, but to avoid non-canonical permissions leaking out before then we make the\n   * toplevel dir only accessible to the user *\/\n  if (chmod (flatpak_file_get_path_cached (extra_files), 0700) != 0)\n    {\n      glnx_set_error_from_errno (error);\n      return FALSE;\n    }\n\n  if (!g_spawn_sync (NULL,\n                     (char **) bwrap->argv->pdata,\n                     bwrap->envp,\n                     G_SPAWN_SEARCH_PATH,\n                     child_setup, bwrap->fds,\n                     NULL, NULL,\n                     &exit_status,\n                     error))\n    return FALSE;\n\n  if (!flatpak_canonicalize_permissions (AT_FDCWD, flatpak_file_get_path_cached (extra_files),\n                                         getuid () == 0 ? 0 : -1,\n                                         getuid () == 0 ? 0 : -1,\n                                         error))\n    return FALSE;\n\n  if (exit_status != 0)\n    {\n      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,\n                   _(\"apply_extra script failed, exit status %d\"), exit_status);\n      return FALSE;\n    }\n\n  if (g_file_query_exists (extra_export_file, cancellable))\n    {\n      if (!flatpak_mkdir_p (app_export_file, cancellable, error))\n        return FALSE;\n      if (!flatpak_cp_a (extra_export_file,\n                         app_export_file,\n                         FLATPAK_CP_FLAGS_MERGE,\n                         cancellable, error))\n        return FALSE;\n    }\n\n  return TRUE;\n}","target":1,"code_token_length":1641,"total_token_length":1877,"max_tokens_setting":2048}
+{"idx":413339,"func":"PHP_MINIT_FUNCTION(snmp)\n{\n\tnetsnmp_log_handler *logh;\n\tzend_class_entry ce, cex;\n\n\tle_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);\n\n\tinit_snmp(\"snmpapp\");\n\n#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE\n\t\/* Prevent update of the snmpapp.conf file *\/\n\tnetsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);\n#endif\n\n\t\/* Disable logging, use exit status'es and related variabled to detect errors *\/\n\tshutdown_snmp_logging();\n\tlogh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);\n\tif (logh) {\n\t\tlogh->pri_max = LOG_ERR;\n\t}\n\n\tmemcpy(&php_snmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));\n\tphp_snmp_object_handlers.read_property = php_snmp_read_property;\n\tphp_snmp_object_handlers.write_property = php_snmp_write_property;\n\tphp_snmp_object_handlers.has_property = php_snmp_has_property;\n\tphp_snmp_object_handlers.get_properties = php_snmp_get_properties;\n\tphp_snmp_object_handlers.get_gc = php_snmp_get_gc;\n\n\t\/* Register SNMP Class *\/\n\tINIT_CLASS_ENTRY(ce, \"SNMP\", php_snmp_class_methods);\n\tce.create_object = php_snmp_object_new;\n\tphp_snmp_object_handlers.clone_obj = NULL;\n\tphp_snmp_ce = zend_register_internal_class(&ce TSRMLS_CC);\n\n\t\/* Register SNMP Class properties *\/\n\tzend_hash_init(&php_snmp_properties, 0, NULL, NULL, 1);\n\tPHP_SNMP_ADD_PROPERTIES(&php_snmp_properties, php_snmp_property_entries);\n\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_SUFFIX\",\tNETSNMP_OID_OUTPUT_SUFFIX,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_MODULE\",\tNETSNMP_OID_OUTPUT_MODULE,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_FULL\",\t\tNETSNMP_OID_OUTPUT_FULL,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_NUMERIC\",\tNETSNMP_OID_OUTPUT_NUMERIC,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_UCD\",\t\tNETSNMP_OID_OUTPUT_UCD,\t\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_NONE\",\t\tNETSNMP_OID_OUTPUT_NONE,\tCONST_CS | CONST_PERSISTENT);\n\n\tREGISTER_LONG_CONSTANT(\"SNMP_VALUE_LIBRARY\",\tSNMP_VALUE_LIBRARY,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_VALUE_PLAIN\",\tSNMP_VALUE_PLAIN,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_VALUE_OBJECT\",\tSNMP_VALUE_OBJECT,\tCONST_CS | CONST_PERSISTENT);\n\n\tREGISTER_LONG_CONSTANT(\"SNMP_BIT_STR\",\t\tASN_BIT_STR,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OCTET_STR\",\tASN_OCTET_STR,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OPAQUE\",\t\tASN_OPAQUE,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_NULL\",\t\tASN_NULL,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OBJECT_ID\",\tASN_OBJECT_ID,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_IPADDRESS\",\tASN_IPADDRESS,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_COUNTER\",\t\tASN_GAUGE,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_UNSIGNED\",\t\tASN_UNSIGNED,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_TIMETICKS\",\tASN_TIMETICKS,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_UINTEGER\",\t\tASN_UINTEGER,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_INTEGER\",\t\tASN_INTEGER,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_COUNTER64\",\tASN_COUNTER64,\tCONST_CS | CONST_PERSISTENT);\n\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_1\",\t\t\tSNMP_VERSION_1);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_2c\",\t\t\tSNMP_VERSION_2c);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_2C\",\t\t\tSNMP_VERSION_2c);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_3\",\t\t\tSNMP_VERSION_3);\n\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_NOERROR\",\t\t\tPHP_SNMP_ERRNO_NOERROR);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_ANY\",\t\t\tPHP_SNMP_ERRNO_ANY);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_GENERIC\",\t\t\tPHP_SNMP_ERRNO_GENERIC);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_TIMEOUT\",\t\t\tPHP_SNMP_ERRNO_TIMEOUT);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_ERROR_IN_REPLY\",\t\tPHP_SNMP_ERRNO_ERROR_IN_REPLY);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_OID_NOT_INCREASING\",\tPHP_SNMP_ERRNO_OID_NOT_INCREASING);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_OID_PARSING_ERROR\",\tPHP_SNMP_ERRNO_OID_PARSING_ERROR);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_MULTIPLE_SET_QUERIES\",\tPHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES);\n\n\t\/* Register SNMPException class *\/\n\tINIT_CLASS_ENTRY(cex, \"SNMPException\", NULL);\n#ifdef HAVE_SPL\n\tphp_snmp_exception_ce = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException, NULL TSRMLS_CC);\n#else\n\tphp_snmp_exception_ce = zend_register_internal_class_ex(&cex, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);\n#endif\n\n\treturn SUCCESS;\n}","target":0,"code_token_length":1307,"total_token_length":1543,"max_tokens_setting":2048}
+{"idx":204115,"func":"issuerAndThisUpdateCheck(\n\tstruct berval *in,\n\tstruct berval *is,\n\tstruct berval *tu,\n\tvoid *ctx )\n{\n\tint numdquotes = 0;\n\tstruct berval x = *in;\n\tstruct berval ni = BER_BVNULL;\n\t\/* Parse GSER format *\/ \n\tenum {\n\t\tHAVE_NONE = 0x0,\n\t\tHAVE_ISSUER = 0x1,\n\t\tHAVE_THISUPDATE = 0x2,\n\t\tHAVE_ALL = ( HAVE_ISSUER | HAVE_THISUPDATE )\n\t} have = HAVE_NONE;\n\n\n\tif ( in->bv_len < STRLENOF( \"{issuer \\\"\\\",thisUpdate \\\"YYMMDDhhmmssZ\\\"}\" ) ) return LDAP_INVALID_SYNTAX;\n\n\tif ( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tx.bv_val++;\n\tx.bv_len -= STRLENOF(\"{}\");\n\n\tdo {\n\t\t\/* eat leading spaces *\/\n\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\/* empty *\/;\n\t\t}\n\n\t\t\/* should be at issuer or thisUpdate *\/\n\t\tif ( strncasecmp( x.bv_val, \"issuer\", STRLENOF(\"issuer\") ) == 0 ) {\n\t\t\tif ( have & HAVE_ISSUER ) return LDAP_INVALID_SYNTAX;\n\n\t\t\t\/* parse issuer *\/\n\t\t\tx.bv_val += STRLENOF(\"issuer\");\n\t\t\tx.bv_len -= STRLENOF(\"issuer\");\n\n\t\t\tif ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\t\/* For backward compatibility, this part is optional *\/\n\t\t\tif ( strncasecmp( x.bv_val, \"rdnSequence:\", STRLENOF(\"rdnSequence:\") ) != 0 ) {\n\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t}\n\t\t\tx.bv_val += STRLENOF(\"rdnSequence:\");\n\t\t\tx.bv_len -= STRLENOF(\"rdnSequence:\");\n\n\t\t\tif ( x.bv_val[0] != '\"' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\tis->bv_val = x.bv_val;\n\t\t\tis->bv_len = 0;\n\n\t\t\tfor ( ; is->bv_len < x.bv_len; ) {\n\t\t\t\tif ( is->bv_val[is->bv_len] != '\"' ) {\n\t\t\t\t\tis->bv_len++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif ( is->bv_val[is->bv_len+1] == '\"' ) {\n\t\t\t\t\t\/* double dquote *\/\n\t\t\t\t\tnumdquotes++;\n\t\t\t\t\tis->bv_len += 2;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tx.bv_val += is->bv_len + 1;\n\t\t\tx.bv_len -= is->bv_len + 1;\n\n\t\t\thave |= HAVE_ISSUER;\n\n\t\t} else if ( strncasecmp( x.bv_val, \"thisUpdate\", STRLENOF(\"thisUpdate\") ) == 0 )\n\t\t{\n\t\t\tif ( have & HAVE_THISUPDATE ) return LDAP_INVALID_SYNTAX;\n\n\t\t\t\/* parse thisUpdate *\/\n\t\t\tx.bv_val += STRLENOF(\"thisUpdate\");\n\t\t\tx.bv_len -= STRLENOF(\"thisUpdate\");\n\n\t\t\tif ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\t\/* eat leading spaces *\/\n\t\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\t\/* empty *\/;\n\t\t\t}\n\n\t\t\tif ( !x.bv_len || x.bv_val[0] != '\"' ) return LDAP_INVALID_SYNTAX;\n\t\t\tx.bv_val++;\n\t\t\tx.bv_len--;\n\n\t\t\ttu->bv_val = x.bv_val;\n\t\t\ttu->bv_len = 0;\n\n\t\t\tfor ( ; tu->bv_len < x.bv_len; tu->bv_len++ ) {\n\t\t\t\tif ( tu->bv_val[tu->bv_len] == '\"' ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tx.bv_val += tu->bv_len + 1;\n\t\t\tx.bv_len -= tu->bv_len + 1;\n\n\t\t\thave |= HAVE_THISUPDATE;\n\n\t\t} else {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\t\/* eat leading spaces *\/\n\t\tfor ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {\n\t\t\t\/* empty *\/;\n\t\t}\n\n\t\tif ( have == HAVE_ALL ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( x.bv_val[0] != ',' ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\n\t\tx.bv_val++;\n\t\tx.bv_len--;\n\t} while ( 1 );\n\n\t\/* should have no characters left... *\/\n\tif ( x.bv_len ) return LDAP_INVALID_SYNTAX;\n\n\tif ( numdquotes == 0 ) {\n\t\tber_dupbv_x( &ni, is, ctx );\n\n\t} else {\n\t\tber_len_t src, dst;\n\n\t\tni.bv_len = is->bv_len - numdquotes;\n\t\tni.bv_val = slap_sl_malloc( ni.bv_len + 1, ctx );\n\t\tfor ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) {\n\t\t\tif ( is->bv_val[src] == '\"' ) {\n\t\t\t\tsrc++;\n\t\t\t}\n\t\t\tni.bv_val[dst] = is->bv_val[src];\n\t\t}\n\t\tni.bv_val[dst] = '\\0';\n\t}\n\t\t\n\t*is = ni;\n\n\treturn 0;\n}","target":1,"code_token_length":1314,"total_token_length":1550,"max_tokens_setting":2048}
+{"idx":282884,"func":"static int rsi_load_radio_caps(struct rsi_common *common)\n{\n\tstruct rsi_radio_caps *radio_caps;\n\tstruct rsi_hw *adapter = common->priv;\n\tu16 inx = 0;\n\tu8 ii;\n\tu8 radio_id = 0;\n\tu16 gc[20] = {0xf0, 0xf0, 0xf0, 0xf0,\n\t\t      0xf0, 0xf0, 0xf0, 0xf0,\n\t\t      0xf0, 0xf0, 0xf0, 0xf0,\n\t\t      0xf0, 0xf0, 0xf0, 0xf0,\n\t\t      0xf0, 0xf0, 0xf0, 0xf0};\n\tstruct sk_buff *skb;\n\tu16 frame_len = sizeof(struct rsi_radio_caps);\n\n\trsi_dbg(INFO_ZONE, \"%s: Sending rate symbol req frame\\n\", __func__);\n\n\tskb = dev_alloc_skb(frame_len);\n\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, frame_len);\n\tradio_caps = (struct rsi_radio_caps *)skb->data;\n\n\tradio_caps->desc_dword0.frame_type = RADIO_CAPABILITIES;\n\tradio_caps->channel_num = common->channel;\n\tradio_caps->rf_model = RSI_RF_TYPE;\n\n\tradio_caps->radio_cfg_info = RSI_LMAC_CLOCK_80MHZ;\n\tif (common->channel_width == BW_40MHZ) {\n\t\tradio_caps->radio_cfg_info |= RSI_ENABLE_40MHZ;\n\n\t\tif (common->fsm_state == FSM_MAC_INIT_DONE) {\n\t\t\tstruct ieee80211_hw *hw = adapter->hw;\n\t\t\tstruct ieee80211_conf *conf = &hw->conf;\n\n\t\t\tif (conf_is_ht40_plus(conf)) {\n\t\t\t\tradio_caps->ppe_ack_rate =\n\t\t\t\t\tcpu_to_le16(LOWER_20_ENABLE |\n\t\t\t\t\t\t    (LOWER_20_ENABLE >> 12));\n\t\t\t} else if (conf_is_ht40_minus(conf)) {\n\t\t\t\tradio_caps->ppe_ack_rate =\n\t\t\t\t\tcpu_to_le16(UPPER_20_ENABLE |\n\t\t\t\t\t\t    (UPPER_20_ENABLE >> 12));\n\t\t\t} else {\n\t\t\t\tradio_caps->ppe_ack_rate =\n\t\t\t\t\tcpu_to_le16((BW_40MHZ << 12) |\n\t\t\t\t\t\t    FULL40M_ENABLE);\n\t\t\t}\n\t\t}\n\t}\n\tradio_caps->radio_info |= radio_id;\n\n\tif (adapter->device_model == RSI_DEV_9116 &&\n\t    common->channel_width == BW_20MHZ)\n\t\tradio_caps->radio_cfg_info &= ~0x3;\n\n\tradio_caps->sifs_tx_11n = cpu_to_le16(SIFS_TX_11N_VALUE);\n\tradio_caps->sifs_tx_11b = cpu_to_le16(SIFS_TX_11B_VALUE);\n\tradio_caps->slot_rx_11n = cpu_to_le16(SHORT_SLOT_VALUE);\n\tradio_caps->ofdm_ack_tout = cpu_to_le16(OFDM_ACK_TOUT_VALUE);\n\tradio_caps->cck_ack_tout = cpu_to_le16(CCK_ACK_TOUT_VALUE);\n\tradio_caps->preamble_type = cpu_to_le16(LONG_PREAMBLE);\n\n\tfor (ii = 0; ii < MAX_HW_QUEUES; ii++) {\n\t\tradio_caps->qos_params[ii].cont_win_min_q = cpu_to_le16(3);\n\t\tradio_caps->qos_params[ii].cont_win_max_q = cpu_to_le16(0x3f);\n\t\tradio_caps->qos_params[ii].aifsn_val_q = cpu_to_le16(2);\n\t\tradio_caps->qos_params[ii].txop_q = 0;\n\t}\n\n\tfor (ii = 0; ii < NUM_EDCA_QUEUES; ii++) {\n\t\tif (common->edca_params[ii].cw_max > 0) {\n\t\t\tradio_caps->qos_params[ii].cont_win_min_q =\n\t\t\t\tcpu_to_le16(common->edca_params[ii].cw_min);\n\t\t\tradio_caps->qos_params[ii].cont_win_max_q =\n\t\t\t\tcpu_to_le16(common->edca_params[ii].cw_max);\n\t\t\tradio_caps->qos_params[ii].aifsn_val_q =\n\t\t\t\tcpu_to_le16(common->edca_params[ii].aifs << 8);\n\t\t\tradio_caps->qos_params[ii].txop_q =\n\t\t\t\tcpu_to_le16(common->edca_params[ii].txop);\n\t\t}\n\t}\n\n\tradio_caps->qos_params[BROADCAST_HW_Q].txop_q = cpu_to_le16(0xffff);\n\tradio_caps->qos_params[MGMT_HW_Q].txop_q = 0;\n\tradio_caps->qos_params[BEACON_HW_Q].txop_q = cpu_to_le16(0xffff);\n\n\tmemcpy(&common->rate_pwr[0], &gc[0], 40);\n\tfor (ii = 0; ii < 20; ii++)\n\t\tradio_caps->gcpd_per_rate[inx++] =\n\t\t\tcpu_to_le16(common->rate_pwr[ii]  & 0x00FF);\n\n\trsi_set_len_qno(&radio_caps->desc_dword0.len_qno,\n\t\t\t(frame_len - FRAME_DESC_SZ), RSI_WIFI_MGMT_Q);\n\n\tskb_put(skb, frame_len);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":1224,"total_token_length":1460,"max_tokens_setting":2048}
+{"idx":238553,"func":"static int check_stack_range_initialized(\n\t\tstruct bpf_verifier_env *env, int regno, int off,\n\t\tint access_size, bool zero_size_allowed,\n\t\tenum stack_access_src type, struct bpf_call_arg_meta *meta)\n{\n\tstruct bpf_reg_state *reg = reg_state(env, regno);\n\tstruct bpf_func_state *state = func(env, reg);\n\tint err, min_off, max_off, i, j, slot, spi;\n\tchar *err_extra = type == ACCESS_HELPER ? \" indirect\" : \"\";\n\tenum bpf_access_type bounds_check_type;\n\t\/* Some accesses can write anything into the stack, others are\n\t * read-only.\n\t *\/\n\tbool clobber = false;\n\n\tif (access_size == 0 && !zero_size_allowed) {\n\t\tverbose(env, \"invalid zero-sized read\\n\");\n\t\treturn -EACCES;\n\t}\n\n\tif (type == ACCESS_HELPER) {\n\t\t\/* The bounds checks for writes are more permissive than for\n\t\t * reads. However, if raw_mode is not set, we'll do extra\n\t\t * checks below.\n\t\t *\/\n\t\tbounds_check_type = BPF_WRITE;\n\t\tclobber = true;\n\t} else {\n\t\tbounds_check_type = BPF_READ;\n\t}\n\terr = check_stack_access_within_bounds(env, regno, off, access_size,\n\t\t\t\t\t       type, bounds_check_type);\n\tif (err)\n\t\treturn err;\n\n\n\tif (tnum_is_const(reg->var_off)) {\n\t\tmin_off = max_off = reg->var_off.value + off;\n\t} else {\n\t\t\/* Variable offset is prohibited for unprivileged mode for\n\t\t * simplicity since it requires corresponding support in\n\t\t * Spectre masking for stack ALU.\n\t\t * See also retrieve_ptr_limit().\n\t\t *\/\n\t\tif (!env->bypass_spec_v1) {\n\t\t\tchar tn_buf[48];\n\n\t\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\t\tverbose(env, \"R%d%s variable offset stack access prohibited for !root, var_off=%s\\n\",\n\t\t\t\tregno, err_extra, tn_buf);\n\t\t\treturn -EACCES;\n\t\t}\n\t\t\/* Only initialized buffer on stack is allowed to be accessed\n\t\t * with variable offset. With uninitialized buffer it's hard to\n\t\t * guarantee that whole memory is marked as initialized on\n\t\t * helper return since specific bounds are unknown what may\n\t\t * cause uninitialized stack leaking.\n\t\t *\/\n\t\tif (meta && meta->raw_mode)\n\t\t\tmeta = NULL;\n\n\t\tmin_off = reg->smin_value + off;\n\t\tmax_off = reg->smax_value + off;\n\t}\n\n\tif (meta && meta->raw_mode) {\n\t\tmeta->access_size = access_size;\n\t\tmeta->regno = regno;\n\t\treturn 0;\n\t}\n\n\tfor (i = min_off; i < max_off + access_size; i++) {\n\t\tu8 *stype;\n\n\t\tslot = -i - 1;\n\t\tspi = slot \/ BPF_REG_SIZE;\n\t\tif (state->allocated_stack <= slot)\n\t\t\tgoto err;\n\t\tstype = &state->stack[spi].slot_type[slot % BPF_REG_SIZE];\n\t\tif (*stype == STACK_MISC)\n\t\t\tgoto mark;\n\t\tif (*stype == STACK_ZERO) {\n\t\t\tif (clobber) {\n\t\t\t\t\/* helper can write anything into the stack *\/\n\t\t\t\t*stype = STACK_MISC;\n\t\t\t}\n\t\t\tgoto mark;\n\t\t}\n\n\t\tif (is_spilled_reg(&state->stack[spi]) &&\n\t\t    state->stack[spi].spilled_ptr.type == PTR_TO_BTF_ID)\n\t\t\tgoto mark;\n\n\t\tif (is_spilled_reg(&state->stack[spi]) &&\n\t\t    (state->stack[spi].spilled_ptr.type == SCALAR_VALUE ||\n\t\t     env->allow_ptr_leaks)) {\n\t\t\tif (clobber) {\n\t\t\t\t__mark_reg_unknown(env, &state->stack[spi].spilled_ptr);\n\t\t\t\tfor (j = 0; j < BPF_REG_SIZE; j++)\n\t\t\t\t\tscrub_spilled_slot(&state->stack[spi].slot_type[j]);\n\t\t\t}\n\t\t\tgoto mark;\n\t\t}\n\nerr:\n\t\tif (tnum_is_const(reg->var_off)) {\n\t\t\tverbose(env, \"invalid%s read from stack R%d off %d+%d size %d\\n\",\n\t\t\t\terr_extra, regno, min_off, i - min_off, access_size);\n\t\t} else {\n\t\t\tchar tn_buf[48];\n\n\t\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\t\tverbose(env, \"invalid%s read from stack R%d var_off %s+%d size %d\\n\",\n\t\t\t\terr_extra, regno, tn_buf, i - min_off, access_size);\n\t\t}\n\t\treturn -EACCES;\nmark:\n\t\t\/* reading any byte out of 8-byte 'spill_slot' will cause\n\t\t * the whole slot to be marked as 'read'\n\t\t *\/\n\t\tmark_reg_read(env, &state->stack[spi].spilled_ptr,\n\t\t\t      state->stack[spi].spilled_ptr.parent,\n\t\t\t      REG_LIVE_READ64);\n\t}\n\treturn update_stack_depth(env, state, min_off);\n}","target":0,"code_token_length":1101,"total_token_length":1337,"max_tokens_setting":2048}
+{"idx":211773,"func":"cookedprint(\n\tint datatype,\n\tint length,\n\tconst char *data,\n\tint status,\n\tint quiet,\n\tFILE *fp\n\t)\n{\n\tchar *name;\n\tchar *value;\n\tchar output_raw;\n\tint fmt;\n\tl_fp lfp;\n\tsockaddr_u hval;\n\tu_long uval;\n\tint narr;\n\tsize_t len;\n\tl_fp lfparr[8];\n\tchar b[12];\n\tchar bn[2 * MAXVARLEN];\n\tchar bv[2 * MAXVALLEN];\n\n\tUNUSED_ARG(datatype);\n\n\tif (!quiet)\n\t\tfprintf(fp, \"status=%04x %s,\\n\", status,\n\t\t\tstatustoa(datatype, status));\n\n\tstartoutput();\n\twhile (nextvar(&length, &data, &name, &value)) {\n\t\tfmt = varfmt(name);\n\t\toutput_raw = 0;\n\t\tswitch (fmt) {\n\n\t\tcase PADDING:\n\t\t\toutput_raw = '*';\n\t\t\tbreak;\n\n\t\tcase TS:\n\t\t\tif (!decodets(value, &lfp))\n\t\t\t\toutput_raw = '?';\n\t\t\telse\n\t\t\t\toutput(fp, name, prettydate(&lfp));\n\t\t\tbreak;\n\n\t\tcase HA:\t\/* fallthru *\/\n\t\tcase NA:\n\t\t\tif (!decodenetnum(value, &hval)) {\n\t\t\t\toutput_raw = '?';\n\t\t\t} else if (fmt == HA){\n\t\t\t\toutput(fp, name, nntohost(&hval));\n\t\t\t} else {\n\t\t\t\toutput(fp, name, stoa(&hval));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase RF:\n\t\t\tif (decodenetnum(value, &hval)) {\n\t\t\t\tif (ISREFCLOCKADR(&hval))\n\t\t\t\t\toutput(fp, name,\n\t\t\t\t\t       refnumtoa(&hval));\n\t\t\t\telse\n\t\t\t\t\toutput(fp, name, stoa(&hval));\n\t\t\t} else if (strlen(value) <= 4) {\n\t\t\t\toutput(fp, name, value);\n\t\t\t} else {\n\t\t\t\toutput_raw = '?';\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase LP:\n\t\t\tif (!decodeuint(value, &uval) || uval > 3) {\n\t\t\t\toutput_raw = '?';\n\t\t\t} else {\n\t\t\t\tb[0] = (0x2 & uval)\n\t\t\t\t\t   ? '1'\n\t\t\t\t\t   : '0';\n\t\t\t\tb[1] = (0x1 & uval)\n\t\t\t\t\t   ? '1'\n\t\t\t\t\t   : '0';\n\t\t\t\tb[2] = '\\0';\n\t\t\t\toutput(fp, name, b);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OC:\n\t\t\tif (!decodeuint(value, &uval)) {\n\t\t\t\toutput_raw = '?';\n\t\t\t} else {\n\t\t\t\tsnprintf(b, sizeof(b), \"%03lo\", uval);\n\t\t\t\toutput(fp, name, b);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase AR:\n\t\t\tif (!decodearr(value, &narr, lfparr))\n\t\t\t\toutput_raw = '?';\n\t\t\telse\n\t\t\t\toutputarr(fp, name, narr, lfparr);\n\t\t\tbreak;\n\n\t\tcase FX:\n\t\t\tif (!decodeuint(value, &uval))\n\t\t\t\toutput_raw = '?';\n\t\t\telse\n\t\t\t\toutput(fp, name, tstflags(uval));\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tfprintf(stderr, \"Internal error in cookedprint, %s=%s, fmt %d\\n\",\n\t\t\t\tname, value, fmt);\n\t\t\toutput_raw = '?';\n\t\t\tbreak;\n\t\t}\n\n\t\tif (output_raw != 0) {\n\t\t\tatoascii(name, MAXVARLEN, bn, sizeof(bn));\n\t\t\tatoascii(value, MAXVALLEN, bv, sizeof(bv));\n\t\t\tif (output_raw != '*') {\n\t\t\t\tlen = strlen(bv);\n\t\t\t\tbv[len] = output_raw;\n\t\t\t\tbv[len+1] = '\\0';\n\t\t\t}\n\t\t\toutput(fp, bn, bv);\n\t\t}\n\t}\n\tendoutput(fp);\n}","target":1,"code_token_length":791,"total_token_length":1027,"max_tokens_setting":2048}
+{"idx":293943,"func":"get_breakindent_win(\n    win_T\t*wp,\n    char_u\t*line) \/\/ start of the line\n{\n    static int\t    prev_indent = 0;\t\/\/ cached indent value\n    static long\t    prev_ts     = 0L;\t\/\/ cached tabstop value\n    static char_u   *prev_line = NULL;\t\/\/ cached pointer to line\n    static varnumber_T prev_tick = 0;   \/\/ changedtick of cached value\n# ifdef FEAT_VARTABS\n    static int      *prev_vts = NULL;   \/\/ cached vartabs values\n# endif\n    static int      prev_list = 0;\t\/\/ cached list value\n    static int      prev_listopt = 0;\t\/\/ cached w_p_briopt_list value\n    \/\/ cached formatlistpat value\n    static char_u   *prev_flp = NULL;\n    int\t\t    bri = 0;\n    \/\/ window width minus window margin space, i.e. what rests for text\n    const int\t    eff_wwidth = wp->w_width\n\t\t\t    - ((wp->w_p_nu || wp->w_p_rnu)\n\t\t\t\t&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)\n\t\t\t\t\t\t? number_width(wp) + 1 : 0);\n\n    \/\/ used cached indent, unless\n    \/\/ - line pointer changed\n    \/\/ - 'tabstop' changed\n    \/\/ - 'briopt_list changed' changed or\n    \/\/ - 'formatlistpattern' changed\n    if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts\n\t    || prev_tick != CHANGEDTICK(wp->w_buffer)\n\t    || prev_listopt != wp->w_briopt_list\n\t    || (prev_flp == NULL\n\t\t|| (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))\n# ifdef FEAT_VARTABS\n\t    || prev_vts != wp->w_buffer->b_p_vts_array\n# endif\n\t)\n    {\n\tprev_line = line;\n\tprev_ts = wp->w_buffer->b_p_ts;\n\tprev_tick = CHANGEDTICK(wp->w_buffer);\n# ifdef FEAT_VARTABS\n\tprev_vts = wp->w_buffer->b_p_vts_array;\n\tprev_indent = get_indent_str_vtab(line,\n\t\t\t\t     (int)wp->w_buffer->b_p_ts,\n\t\t\t\t    wp->w_buffer->b_p_vts_array, wp->w_p_list);\n# else\n\tprev_indent = get_indent_str(line,\n\t\t\t\t     (int)wp->w_buffer->b_p_ts, wp->w_p_list);\n# endif\n\tprev_listopt = wp->w_briopt_list;\n\tprev_list = 0;\n\tvim_free(prev_flp);\n\tprev_flp = vim_strsave(get_flp_value(wp->w_buffer));\n\t\/\/ add additional indent for numbered lists\n\tif (wp->w_briopt_list != 0)\n\t{\n\t    regmatch_T\t    regmatch;\n\n\t    regmatch.regprog = vim_regcomp(prev_flp,\n\t\t\t\t   RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT);\n\n\t    if (regmatch.regprog != NULL)\n\t    {\n\t\tregmatch.rm_ic = FALSE;\n\t\tif (vim_regexec(®match, line, 0))\n\t\t{\n\t\t    if (wp->w_briopt_list > 0)\n\t\t\tprev_list = wp->w_briopt_list;\n\t\t    else\n\t\t\tprev_list = (*regmatch.endp - *regmatch.startp);\n\t\t}\n\t\tvim_regfree(regmatch.regprog);\n\t    }\n\t}\n    }\n    bri = prev_indent + wp->w_briopt_shift;\n\n    \/\/ Add offset for number column, if 'n' is in 'cpoptions'\n    bri += win_col_off2(wp);\n\n    \/\/ add additional indent for numbered lists\n    if (wp->w_briopt_list != 0)\n    {\n\tif (wp->w_briopt_list > 0)\n\t    bri += prev_list;\n\telse\n\t    bri = prev_list;\n    }\n\n    \/\/ indent minus the length of the showbreak string\n    if (wp->w_briopt_sbr)\n\tbri -= vim_strsize(get_showbreak_value(wp));\n\n\n    \/\/ never indent past left window margin\n    if (bri < 0)\n\tbri = 0;\n\n    \/\/ always leave at least bri_min characters on the left,\n    \/\/ if text width is sufficient\n    else if (bri > eff_wwidth - wp->w_briopt_min)\n\tbri = (eff_wwidth - wp->w_briopt_min < 0)\n\t\t\t\t\t   ? 0 : eff_wwidth - wp->w_briopt_min;\n\n    return bri;\n}","target":0,"code_token_length":1001,"total_token_length":1237,"max_tokens_setting":2048}
+{"idx":395066,"func":"redraw_asap(int type)\n{\n    int\t\trows;\n    int\t\tcols = screen_Columns;\n    int\t\tr;\n    int\t\tret = 0;\n    schar_T\t*screenline;\t\/\/ copy from ScreenLines[]\n    sattr_T\t*screenattr;\t\/\/ copy from ScreenAttrs[]\n    int\t\ti;\n    u8char_T\t*screenlineUC = NULL;\t\/\/ copy from ScreenLinesUC[]\n    u8char_T\t*screenlineC[MAX_MCO];\t\/\/ copy from ScreenLinesC[][]\n    schar_T\t*screenline2 = NULL;\t\/\/ copy from ScreenLines2[]\n\n    redraw_later(type);\n    if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting)\n\treturn ret;\n\n    \/\/ Allocate space to save the text displayed in the command line area.\n    rows = screen_Rows - cmdline_row;\n    screenline = LALLOC_MULT(schar_T, rows * cols);\n    screenattr = LALLOC_MULT(sattr_T, rows * cols);\n    if (screenline == NULL || screenattr == NULL)\n\tret = 2;\n    if (enc_utf8)\n    {\n\tscreenlineUC = LALLOC_MULT(u8char_T, rows * cols);\n\tif (screenlineUC == NULL)\n\t    ret = 2;\n\tfor (i = 0; i < p_mco; ++i)\n\t{\n\t    screenlineC[i] = LALLOC_MULT(u8char_T, rows * cols);\n\t    if (screenlineC[i] == NULL)\n\t\tret = 2;\n\t}\n    }\n    if (enc_dbcs == DBCS_JPNU)\n    {\n\tscreenline2 = LALLOC_MULT(schar_T, rows * cols);\n\tif (screenline2 == NULL)\n\t    ret = 2;\n    }\n\n    if (ret != 2)\n    {\n\t\/\/ Save the text displayed in the command line area.\n\tfor (r = 0; r < rows; ++r)\n\t{\n\t    mch_memmove(screenline + r * cols,\n\t\t\tScreenLines + LineOffset[cmdline_row + r],\n\t\t\t(size_t)cols * sizeof(schar_T));\n\t    mch_memmove(screenattr + r * cols,\n\t\t\tScreenAttrs + LineOffset[cmdline_row + r],\n\t\t\t(size_t)cols * sizeof(sattr_T));\n\t    if (enc_utf8)\n\t    {\n\t\tmch_memmove(screenlineUC + r * cols,\n\t\t\t    ScreenLinesUC + LineOffset[cmdline_row + r],\n\t\t\t    (size_t)cols * sizeof(u8char_T));\n\t\tfor (i = 0; i < p_mco; ++i)\n\t\t    mch_memmove(screenlineC[i] + r * cols,\n\t\t\t\tScreenLinesC[i] + LineOffset[cmdline_row + r],\n\t\t\t\t(size_t)cols * sizeof(u8char_T));\n\t    }\n\t    if (enc_dbcs == DBCS_JPNU)\n\t\tmch_memmove(screenline2 + r * cols,\n\t\t\t    ScreenLines2 + LineOffset[cmdline_row + r],\n\t\t\t    (size_t)cols * sizeof(schar_T));\n\t}\n\n\tupdate_screen(0);\n\tret = 3;\n\n\tif (must_redraw == 0)\n\t{\n\t    int\toff = (int)(current_ScreenLine - ScreenLines);\n\n\t    \/\/ Restore the text displayed in the command line area.\n\t    for (r = 0; r < rows; ++r)\n\t    {\n\t\tmch_memmove(current_ScreenLine,\n\t\t\t    screenline + r * cols,\n\t\t\t    (size_t)cols * sizeof(schar_T));\n\t\tmch_memmove(ScreenAttrs + off,\n\t\t\t    screenattr + r * cols,\n\t\t\t    (size_t)cols * sizeof(sattr_T));\n\t\tif (enc_utf8)\n\t\t{\n\t\t    mch_memmove(ScreenLinesUC + off,\n\t\t\t\tscreenlineUC + r * cols,\n\t\t\t\t(size_t)cols * sizeof(u8char_T));\n\t\t    for (i = 0; i < p_mco; ++i)\n\t\t\tmch_memmove(ScreenLinesC[i] + off,\n\t\t\t\t    screenlineC[i] + r * cols,\n\t\t\t\t    (size_t)cols * sizeof(u8char_T));\n\t\t}\n\t\tif (enc_dbcs == DBCS_JPNU)\n\t\t    mch_memmove(ScreenLines2 + off,\n\t\t\t\tscreenline2 + r * cols,\n\t\t\t\t(size_t)cols * sizeof(schar_T));\n\t\tscreen_line(cmdline_row + r, 0, cols, cols, 0);\n\t    }\n\t    ret = 4;\n\t}\n    }\n\n    vim_free(screenline);\n    vim_free(screenattr);\n    if (enc_utf8)\n    {\n\tvim_free(screenlineUC);\n\tfor (i = 0; i < p_mco; ++i)\n\t    vim_free(screenlineC[i]);\n    }\n    if (enc_dbcs == DBCS_JPNU)\n\tvim_free(screenline2);\n\n    \/\/ Show the intro message when appropriate.\n    maybe_intro_message();\n\n    setcursor();\n\n    return ret;\n}","target":0,"code_token_length":1067,"total_token_length":1303,"max_tokens_setting":2048}
+{"idx":509540,"func":"int ha_maria::enable_indexes(uint mode)\n{\n  int error;\n  ha_rows start_rows= file->state->records;\n  DBUG_PRINT(\"info\", (\"ha_maria::enable_indexes mode: %d\", mode));\n  if (maria_is_all_keys_active(file->s->state.key_map, file->s->base.keys))\n  {\n    \/* All indexes are enabled already. *\/\n    return 0;\n  }\n\n  if (mode == HA_KEY_SWITCH_ALL)\n  {\n    error= maria_enable_indexes(file);\n    \/*\n       Do not try to repair on error,\n       as this could make the enabled state persistent,\n       but mode==HA_KEY_SWITCH_ALL forbids it.\n    *\/\n  }\n  else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE)\n  {\n    THD *thd= table->in_use;\n    HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);\n    if (!param)\n      return HA_ADMIN_INTERNAL_ERROR;\n\n    const char *save_proc_info= thd_proc_info(thd, \"Creating index\");\n\n    maria_chk_init(param);\n    param->op_name= \"recreating_index\";\n    param->testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |\n                     T_CREATE_MISSING_KEYS | T_SAFE_REPAIR);\n    \/*\n      Don't lock and unlock table if it's locked.\n      Normally table should be locked.  This test is mostly for safety.\n    *\/\n    if (likely(file->lock_type != F_UNLCK))\n      param->testflag|= T_NO_LOCKS;\n\n    if (file->create_unique_index_by_sort)\n      param->testflag|= T_CREATE_UNIQUE_BY_SORT;\n\n    if (bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR)\n    {\n      bulk_insert_single_undo= BULK_INSERT_SINGLE_UNDO_AND_REPAIR;\n      \/*\n        Don't bump create_rename_lsn, because UNDO_BULK_INSERT\n        should not be skipped in case of crash during repair.\n      *\/\n      param->testflag|= T_NO_CREATE_RENAME_LSN;\n    }\n\n    param->myf_rw &= ~MY_WAIT_IF_FULL;\n    param->orig_sort_buffer_length= THDVAR(thd,sort_buffer_size);\n    param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);\n    param->tmpdir= &mysql_tmpdir_list;\n    if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair)\n    {\n      sql_print_warning(\"Warning: Enabling keys got errno %d on %s.%s, \"\n                        \"retrying\",\n                        my_errno, param->db_name, param->table_name);\n      \/* This should never fail normally *\/\n      DBUG_ASSERT(thd->killed != 0);\n      \/* Repairing by sort failed. Now try standard repair method. *\/\n      param->testflag &= ~T_REP_BY_SORT;\n      file->state->records= start_rows;\n      error= (repair(thd, param, 0) != HA_ADMIN_OK);\n      \/*\n        If the standard repair succeeded, clear all error messages which\n        might have been set by the first repair. They can still be seen\n        with SHOW WARNINGS then.\n      *\/\n      if (!error)\n        thd->clear_error();\n    }\n    info(HA_STATUS_CONST);\n    thd_proc_info(thd, save_proc_info);\n  }\n  else\n  {\n    \/* mode not implemented *\/\n    error= HA_ERR_WRONG_COMMAND;\n  }\n  DBUG_EXECUTE_IF(\"maria_flush_whole_log\",\n                  {\n                    DBUG_PRINT(\"maria_flush_whole_log\", (\"now\"));\n                    translog_flush(translog_get_horizon());\n                  });\n  DBUG_EXECUTE_IF(\"maria_crash_enable_index\",\n                  {\n                    DBUG_PRINT(\"maria_crash_enable_index\", (\"now\"));\n                    DBUG_SUICIDE();\n                  });\n  return error;\n}","target":0,"code_token_length":832,"total_token_length":1068,"max_tokens_setting":2048}
+{"idx":198552,"func":"static int pkey_GOST_ECcp_encrypt(EVP_PKEY_CTX *pctx, unsigned char *out,\n                           size_t *out_len, const unsigned char *key,\n                           size_t key_len)\n{\n    GOST_KEY_TRANSPORT *gkt = NULL;\n    EVP_PKEY *pubk = EVP_PKEY_CTX_get0_pkey(pctx);\n    struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(pctx);\n    int pkey_nid = EVP_PKEY_base_id(pubk);\n    ASN1_OBJECT *crypt_params_obj = (pkey_nid == NID_id_GostR3410_2001 || pkey_nid == NID_id_GostR3410_2001DH) ?\n        OBJ_nid2obj(NID_id_Gost28147_89_CryptoPro_A_ParamSet) :\n        OBJ_nid2obj(NID_id_tc26_gost_28147_param_Z);\n    const struct gost_cipher_info *param =\n        get_encryption_params(crypt_params_obj);\n    unsigned char ukm[8], shared_key[32], crypted_key[44];\n    int ret = 0;\n    int key_is_ephemeral = 1;\n    gost_ctx cctx;\n    EVP_PKEY *sec_key = EVP_PKEY_CTX_get0_peerkey(pctx);\n    if (data->shared_ukm_size) {\n        memcpy(ukm, data->shared_ukm, 8);\n    } else {\n        if (RAND_bytes(ukm, 8) <= 0) {\n            GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_RNG_ERROR);\n            return 0;\n        }\n    }\n    if (!param)\n        goto err;\n    \/* Check for private key in the peer_key of context *\/\n    if (sec_key) {\n        key_is_ephemeral = 0;\n        if (!gost_get0_priv_key(sec_key)) {\n            GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT,\n                    GOST_R_NO_PRIVATE_PART_OF_NON_EPHEMERAL_KEYPAIR);\n            goto err;\n        }\n    } else {\n        key_is_ephemeral = 1;\n        if (out) {\n            sec_key = EVP_PKEY_new();\n            if (!EVP_PKEY_assign(sec_key, EVP_PKEY_base_id(pubk), EC_KEY_new())\n                || !EVP_PKEY_copy_parameters(sec_key, pubk)\n                || !gost_ec_keygen(EVP_PKEY_get0(sec_key))) {\n                GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT,\n                        GOST_R_ERROR_COMPUTING_SHARED_KEY);\n                goto err;\n            }\n        }\n    }\n    if (out) {\n        int dgst_nid = NID_undef;\n        EVP_PKEY_get_default_digest_nid(pubk, &dgst_nid);\n        if (dgst_nid == NID_id_GostR3411_2012_512)\n            dgst_nid = NID_id_GostR3411_2012_256;\n\n        if (!VKO_compute_key(shared_key,\n                             EC_KEY_get0_public_key(EVP_PKEY_get0(pubk)),\n                             EVP_PKEY_get0(sec_key), ukm, 8, dgst_nid)) {\n            GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT,\n                    GOST_R_ERROR_COMPUTING_SHARED_KEY);\n            goto err;\n        }\n        gost_init(&cctx, param->sblock);\n        keyWrapCryptoPro(&cctx, shared_key, ukm, key, crypted_key);\n    }\n    gkt = GOST_KEY_TRANSPORT_new();\n    if (!gkt) {\n        goto err;\n    }\n    if (!ASN1_OCTET_STRING_set(gkt->key_agreement_info->eph_iv, ukm, 8)) {\n        goto err;\n    }\n    if (!ASN1_OCTET_STRING_set(gkt->key_info->imit, crypted_key + 40, 4)) {\n        goto err;\n    }\n    if (!ASN1_OCTET_STRING_set\n        (gkt->key_info->encrypted_key, crypted_key + 8, 32)) {\n        goto err;\n    }\n    if (key_is_ephemeral) {\n        if (!X509_PUBKEY_set\n            (&gkt->key_agreement_info->ephem_key, out ? sec_key : pubk)) {\n            GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT,\n                    GOST_R_CANNOT_PACK_EPHEMERAL_KEY);\n            goto err;\n        }\n    }\n    ASN1_OBJECT_free(gkt->key_agreement_info->cipher);\n    gkt->key_agreement_info->cipher = OBJ_nid2obj(param->nid);\n    if (key_is_ephemeral)\n        EVP_PKEY_free(sec_key);\n    if (!key_is_ephemeral) {\n        \/* Set control \"public key from client certificate used\" *\/\n        if (EVP_PKEY_CTX_ctrl(pctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 3, NULL)\n            <= 0) {\n            GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_CTRL_CALL_FAILED);\n            goto err;\n        }\n    }\n    if ((*out_len = i2d_GOST_KEY_TRANSPORT(gkt, out ? &out : NULL)) > 0)\n        ret = 1;\n    OPENSSL_cleanse(shared_key, sizeof(shared_key));\n    GOST_KEY_TRANSPORT_free(gkt);\n    return ret;\n err:\n    OPENSSL_cleanse(shared_key, sizeof(shared_key));\n    if (key_is_ephemeral)\n        EVP_PKEY_free(sec_key);\n    GOST_KEY_TRANSPORT_free(gkt);\n    return -1;\n}","target":1,"code_token_length":1262,"total_token_length":1498,"max_tokens_setting":2048}
+{"idx":230394,"func":"static pj_xml_node *xml_parse_node( pj_pool_t *pool, pj_scanner *scanner)\n{\n    pj_xml_node *node;\n    pj_str_t end_name;\n\n    PJ_CHECK_STACK();\n\n    if (*scanner->curptr != '<')\n\ton_syntax_error(scanner);\n\n    \/* Handle Processing Instructino (PI) construct (i.e. \"<?\") *\/\n    if (*scanner->curptr == '<' && *(scanner->curptr+1) == '?') {\n\tpj_scan_advance_n(scanner, 2, PJ_FALSE);\n\tfor (;;) {\n\t    pj_str_t dummy;\n\t    pj_scan_get_until_ch(scanner, '?', &dummy);\n\t    if (*scanner->curptr=='?' && *(scanner->curptr+1)=='>') {\n\t\tpj_scan_advance_n(scanner, 2, PJ_TRUE);\n\t\tbreak;\n\t    } else {\n\t\tpj_scan_advance_n(scanner, 1, PJ_FALSE);\n\t    }\n\t}\n\treturn xml_parse_node(pool, scanner);\n    }\n\n    \/* Handle comments construct (i.e. \"<!\") *\/\n    if (pj_scan_strcmp(scanner, \"<!\", 2) == 0) {\n\tpj_scan_advance_n(scanner, 2, PJ_FALSE);\n\tfor (;;) {\n\t    pj_str_t dummy;\n\t    pj_scan_get_until_ch(scanner, '>', &dummy);\n\t    if (pj_scan_strcmp(scanner, \">\", 1) == 0) {\n\t\tpj_scan_advance_n(scanner, 1, PJ_TRUE);\n\t\tbreak;\n\t    } else {\n\t\tpj_scan_advance_n(scanner, 1, PJ_FALSE);\n\t    }\n\t}\n\treturn xml_parse_node(pool, scanner);\n    }\n\n    \/* Alloc node. *\/\n    node = alloc_node(pool);\n\n    \/* Get '<' *\/\n    pj_scan_get_char(scanner);\n\n    \/* Get node name. *\/\n    pj_scan_get_until_chr( scanner, \" \/>\\t\\r\\n\", &node->name);\n\n    \/* Get attributes. *\/\n    while (*scanner->curptr != '>' && *scanner->curptr != '\/') {\n\tpj_xml_attr *attr = alloc_attr(pool);\n\t\n\tpj_scan_get_until_chr( scanner, \"=> \\t\\r\\n\", &attr->name);\n\tif (*scanner->curptr == '=') {\n\t    pj_scan_get_char( scanner );\n            pj_scan_get_quotes(scanner, \"\\\"'\", \"\\\"'\", 2, &attr->value);\n\t    \/* remove quote characters *\/\n\t    ++attr->value.ptr;\n\t    attr->value.slen -= 2;\n\t}\n\t\n\tpj_list_push_back( &node->attr_head, attr );\n    }\n\n    if (*scanner->curptr == '\/') {\n\tpj_scan_get_char(scanner);\n\tif (pj_scan_get_char(scanner) != '>')\n\t    on_syntax_error(scanner);\n\treturn node;\n    }\n\n    \/* Enclosing bracket. *\/\n    if (pj_scan_get_char(scanner) != '>')\n\ton_syntax_error(scanner);\n\n    \/* Sub nodes. *\/\n    while (*scanner->curptr == '<' && *(scanner->curptr+1) != '\/'\n\t\t\t\t   && *(scanner->curptr+1) != '!')\n    {\n\tpj_xml_node *sub_node = xml_parse_node(pool, scanner);\n\tpj_list_push_back( &node->node_head, sub_node );\n    }\n\n    \/* Content. *\/\n    if (!pj_scan_is_eof(scanner) && *scanner->curptr != '<') {\n\tpj_scan_get_until_ch(scanner, '<', &node->content);\n    }\n\n    \/* CDATA content. *\/\n    if (*scanner->curptr == '<' && *(scanner->curptr+1) == '!' &&\n\tpj_scan_strcmp(scanner, \"<![CDATA[\", 9) == 0)\n    {\n\tpj_scan_advance_n(scanner, 9, PJ_FALSE);\n\tpj_scan_get_until_ch(scanner, ']', &node->content);\n\twhile (pj_scan_strcmp(scanner, \"]]>\", 3)) {\n\t    pj_str_t dummy;\n\n\t    pj_scan_advance_n(scanner, 1, PJ_FALSE);\n\t    pj_scan_get_until_ch(scanner, ']', &dummy);\n\t}\n\tnode->content.slen = scanner->curptr - node->content.ptr;\n\tpj_scan_advance_n(scanner, 3, PJ_TRUE);\n    }\n\n    \/* Enclosing node. *\/\n    if (pj_scan_get_char(scanner) != '<' || pj_scan_get_char(scanner) != '\/')\n\ton_syntax_error(scanner);\n\n    pj_scan_get_until_chr(scanner, \" \\t>\", &end_name);\n\n    \/* Compare name. *\/\n    if (pj_stricmp(&node->name, &end_name) != 0)\n\ton_syntax_error(scanner);\n\n    \/* Enclosing '>' *\/\n    if (pj_scan_get_char(scanner) != '>')\n\ton_syntax_error(scanner);\n\n    return node;\n}","target":0,"code_token_length":965,"total_token_length":1201,"max_tokens_setting":2048}
+{"idx":317328,"func":"static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_security_struct *sksec = sk->sk_security;\n\tu16 family;\n\tint err;\n\n\terr = sock_has_perm(sk, SOCKET__BIND);\n\tif (err)\n\t\tgoto out;\n\n\t\/* If PF_INET or PF_INET6, check name_bind permission for the port. *\/\n\tfamily = sk->sk_family;\n\tif (family == PF_INET || family == PF_INET6) {\n\t\tchar *addrp;\n\t\tstruct common_audit_data ad;\n\t\tstruct lsm_network_audit net = {0,};\n\t\tstruct sockaddr_in *addr4 = NULL;\n\t\tstruct sockaddr_in6 *addr6 = NULL;\n\t\tu16 family_sa;\n\t\tunsigned short snum;\n\t\tu32 sid, node_perm;\n\n\t\t\/*\n\t\t * sctp_bindx(3) calls via selinux_sctp_bind_connect()\n\t\t * that validates multiple binding addresses. Because of this\n\t\t * need to check address->sa_family as it is possible to have\n\t\t * sk->sk_family = PF_INET6 with addr->sa_family = AF_INET.\n\t\t *\/\n\t\tif (addrlen < offsetofend(struct sockaddr, sa_family))\n\t\t\treturn -EINVAL;\n\t\tfamily_sa = address->sa_family;\n\t\tswitch (family_sa) {\n\t\tcase AF_UNSPEC:\n\t\tcase AF_INET:\n\t\t\tif (addrlen < sizeof(struct sockaddr_in))\n\t\t\t\treturn -EINVAL;\n\t\t\taddr4 = (struct sockaddr_in *)address;\n\t\t\tif (family_sa == AF_UNSPEC) {\n\t\t\t\t\/* see __inet_bind(), we only want to allow\n\t\t\t\t * AF_UNSPEC if the address is INADDR_ANY\n\t\t\t\t *\/\n\t\t\t\tif (addr4->sin_addr.s_addr != htonl(INADDR_ANY))\n\t\t\t\t\tgoto err_af;\n\t\t\t\tfamily_sa = AF_INET;\n\t\t\t}\n\t\t\tsnum = ntohs(addr4->sin_port);\n\t\t\taddrp = (char *)&addr4->sin_addr.s_addr;\n\t\t\tbreak;\n\t\tcase AF_INET6:\n\t\t\tif (addrlen < SIN6_LEN_RFC2133)\n\t\t\t\treturn -EINVAL;\n\t\t\taddr6 = (struct sockaddr_in6 *)address;\n\t\t\tsnum = ntohs(addr6->sin6_port);\n\t\t\taddrp = (char *)&addr6->sin6_addr.s6_addr;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tgoto err_af;\n\t\t}\n\n\t\tad.type = LSM_AUDIT_DATA_NET;\n\t\tad.u.net = &net;\n\t\tad.u.net->sport = htons(snum);\n\t\tad.u.net->family = family_sa;\n\n\t\tif (snum) {\n\t\t\tint low, high;\n\n\t\t\tinet_get_local_port_range(sock_net(sk), &low, &high);\n\n\t\t\tif (inet_port_requires_bind_service(sock_net(sk), snum) ||\n\t\t\t    snum < low || snum > high) {\n\t\t\t\terr = sel_netport_sid(sk->sk_protocol,\n\t\t\t\t\t\t      snum, &sid);\n\t\t\t\tif (err)\n\t\t\t\t\tgoto out;\n\t\t\t\terr = avc_has_perm(&selinux_state,\n\t\t\t\t\t\t   sksec->sid, sid,\n\t\t\t\t\t\t   sksec->sclass,\n\t\t\t\t\t\t   SOCKET__NAME_BIND, &ad);\n\t\t\t\tif (err)\n\t\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\n\t\tswitch (sksec->sclass) {\n\t\tcase SECCLASS_TCP_SOCKET:\n\t\t\tnode_perm = TCP_SOCKET__NODE_BIND;\n\t\t\tbreak;\n\n\t\tcase SECCLASS_UDP_SOCKET:\n\t\t\tnode_perm = UDP_SOCKET__NODE_BIND;\n\t\t\tbreak;\n\n\t\tcase SECCLASS_DCCP_SOCKET:\n\t\t\tnode_perm = DCCP_SOCKET__NODE_BIND;\n\t\t\tbreak;\n\n\t\tcase SECCLASS_SCTP_SOCKET:\n\t\t\tnode_perm = SCTP_SOCKET__NODE_BIND;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tnode_perm = RAWIP_SOCKET__NODE_BIND;\n\t\t\tbreak;\n\t\t}\n\n\t\terr = sel_netnode_sid(addrp, family_sa, &sid);\n\t\tif (err)\n\t\t\tgoto out;\n\n\t\tif (family_sa == AF_INET)\n\t\t\tad.u.net->v4info.saddr = addr4->sin_addr.s_addr;\n\t\telse\n\t\t\tad.u.net->v6info.saddr = addr6->sin6_addr;\n\n\t\terr = avc_has_perm(&selinux_state,\n\t\t\t\t   sksec->sid, sid,\n\t\t\t\t   sksec->sclass, node_perm, &ad);\n\t\tif (err)\n\t\t\tgoto out;\n\t}\nout:\n\treturn err;\nerr_af:\n\t\/* Note that SCTP services expect -EINVAL, others -EAFNOSUPPORT. *\/\n\tif (sksec->sclass == SECCLASS_SCTP_SOCKET)\n\t\treturn -EINVAL;\n\treturn -EAFNOSUPPORT;\n}","target":0,"code_token_length":975,"total_token_length":1211,"max_tokens_setting":2048}
+{"idx":252300,"func":"static void hufBuildEncTable(\n    long long *frq,  \/\/ io: input frequencies [HUF_ENCSIZE], output table\n    int *im,         \/\/  o: min frq index\n    int *iM)         \/\/  o: max frq index\n{\n  \/\/\n  \/\/ This function assumes that when it is called, array frq\n  \/\/ indicates the frequency of all possible symbols in the data\n  \/\/ that are to be Huffman-encoded.  (frq[i] contains the number\n  \/\/ of occurrences of symbol i in the data.)\n  \/\/\n  \/\/ The loop below does three things:\n  \/\/\n  \/\/ 1) Finds the minimum and maximum indices that point\n  \/\/    to non-zero entries in frq:\n  \/\/\n  \/\/     frq[im] != 0, and frq[i] == 0 for all i < im\n  \/\/     frq[iM] != 0, and frq[i] == 0 for all i > iM\n  \/\/\n  \/\/ 2) Fills array fHeap with pointers to all non-zero\n  \/\/    entries in frq.\n  \/\/\n  \/\/ 3) Initializes array hlink such that hlink[i] == i\n  \/\/    for all array entries.\n  \/\/\n\n  std::vector<int> hlink(HUF_ENCSIZE);\n  std::vector<long long *> fHeap(HUF_ENCSIZE);\n\n  *im = 0;\n\n  while (!frq[*im]) (*im)++;\n\n  int nf = 0;\n\n  for (int i = *im; i < HUF_ENCSIZE; i++) {\n    hlink[i] = i;\n\n    if (frq[i]) {\n      fHeap[nf] = &frq[i];\n      nf++;\n      *iM = i;\n    }\n  }\n\n  \/\/\n  \/\/ Add a pseudo-symbol, with a frequency count of 1, to frq;\n  \/\/ adjust the fHeap and hlink array accordingly.  Function\n  \/\/ hufEncode() uses the pseudo-symbol for run-length encoding.\n  \/\/\n\n  (*iM)++;\n  frq[*iM] = 1;\n  fHeap[nf] = &frq[*iM];\n  nf++;\n\n  \/\/\n  \/\/ Build an array, scode, such that scode[i] contains the number\n  \/\/ of bits assigned to symbol i.  Conceptually this is done by\n  \/\/ constructing a tree whose leaves are the symbols with non-zero\n  \/\/ frequency:\n  \/\/\n  \/\/     Make a heap that contains all symbols with a non-zero frequency,\n  \/\/     with the least frequent symbol on top.\n  \/\/\n  \/\/     Repeat until only one symbol is left on the heap:\n  \/\/\n  \/\/         Take the two least frequent symbols off the top of the heap.\n  \/\/         Create a new node that has first two nodes as children, and\n  \/\/         whose frequency is the sum of the frequencies of the first\n  \/\/         two nodes.  Put the new node back into the heap.\n  \/\/\n  \/\/ The last node left on the heap is the root of the tree.  For each\n  \/\/ leaf node, the distance between the root and the leaf is the length\n  \/\/ of the code for the corresponding symbol.\n  \/\/\n  \/\/ The loop below doesn't actually build the tree; instead we compute\n  \/\/ the distances of the leaves from the root on the fly.  When a new\n  \/\/ node is added to the heap, then that node's descendants are linked\n  \/\/ into a single linear list that starts at the new node, and the code\n  \/\/ lengths of the descendants (that is, their distance from the root\n  \/\/ of the tree) are incremented by one.\n  \/\/\n\n  std::make_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n\n  std::vector<long long> scode(HUF_ENCSIZE);\n  memset(scode.data(), 0, sizeof(long long) * HUF_ENCSIZE);\n\n  while (nf > 1) {\n    \/\/\n    \/\/ Find the indices, mm and m, of the two smallest non-zero frq\n    \/\/ values in fHeap, add the smallest frq to the second-smallest\n    \/\/ frq, and remove the smallest frq value from fHeap.\n    \/\/\n\n    int mm = fHeap[0] - frq;\n    std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n    --nf;\n\n    int m = fHeap[0] - frq;\n    std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n\n    frq[m] += frq[mm];\n    std::push_heap(&fHeap[0], &fHeap[nf], FHeapCompare());\n\n    \/\/\n    \/\/ The entries in scode are linked into lists with the\n    \/\/ entries in hlink serving as \"next\" pointers and with\n    \/\/ the end of a list marked by hlink[j] == j.\n    \/\/\n    \/\/ Traverse the lists that start at scode[m] and scode[mm].\n    \/\/ For each element visited, increment the length of the\n    \/\/ corresponding code by one bit. (If we visit scode[j]\n    \/\/ during the traversal, then the code for symbol j becomes\n    \/\/ one bit longer.)\n    \/\/\n    \/\/ Merge the lists that start at scode[m] and scode[mm]\n    \/\/ into a single list that starts at scode[m].\n    \/\/\n\n    \/\/\n    \/\/ Add a bit to all codes in the first list.\n    \/\/\n\n    for (int j = m;; j = hlink[j]) {\n      scode[j]++;\n\n      assert(scode[j] <= 58);\n\n      if (hlink[j] == j) {\n        \/\/\n        \/\/ Merge the two lists.\n        \/\/\n\n        hlink[j] = mm;\n        break;\n      }\n    }\n\n    \/\/\n    \/\/ Add a bit to all codes in the second list\n    \/\/\n\n    for (int j = mm;; j = hlink[j]) {\n      scode[j]++;\n\n      assert(scode[j] <= 58);\n\n      if (hlink[j] == j) break;\n    }\n  }\n\n  \/\/\n  \/\/ Build a canonical Huffman code table, replacing the code\n  \/\/ lengths in scode with (code, code length) pairs.  Copy the\n  \/\/ code table from scode into frq.\n  \/\/\n\n  hufCanonicalCodeTable(scode.data());\n  memcpy(frq, scode.data(), sizeof(long long) * HUF_ENCSIZE);\n}","target":0,"code_token_length":1399,"total_token_length":1635,"max_tokens_setting":2048}
+{"idx":310291,"func":"dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)\n{\n  was_router_added_t r;\n  routerinfo_t *ri_old;\n  char *desc, *nickname;\n  size_t desclen = 0;\n  *msg = NULL;\n\n  \/* If it's too big, refuse it now. Otherwise we'll cache it all over the\n   * network and it'll clog everything up. *\/\n  if (ri->cache_info.signed_descriptor_len > MAX_DESCRIPTOR_UPLOAD_SIZE) {\n    log_notice(LD_DIR, \"Somebody attempted to publish a router descriptor '%s'\"\n               \" (source: %s) with size %d. Either this is an attack, or the \"\n               \"MAX_DESCRIPTOR_UPLOAD_SIZE (%d) constant is too low.\",\n               ri->nickname, source, (int)ri->cache_info.signed_descriptor_len,\n               MAX_DESCRIPTOR_UPLOAD_SIZE);\n    *msg = \"Router descriptor was too large\";\n    control_event_or_authdir_new_descriptor(\"REJECTED\",\n               ri->cache_info.signed_descriptor_body,\n               ri->cache_info.signed_descriptor_len, *msg);\n    routerinfo_free(ri);\n    return ROUTER_AUTHDIR_REJECTS;\n  }\n\n  \/* Check whether this descriptor is semantically identical to the last one\n   * from this server.  (We do this here and not in router_add_to_routerlist\n   * because we want to be able to accept the newest router descriptor that\n   * another authority has, so we all converge on the same one.) *\/\n  ri_old = router_get_by_digest(ri->cache_info.identity_digest);\n  if (ri_old && ri_old->cache_info.published_on < ri->cache_info.published_on\n      && router_differences_are_cosmetic(ri_old, ri)\n      && !router_is_me(ri)) {\n    log_info(LD_DIRSERV,\n             \"Not replacing descriptor from %s (source: %s); \"\n             \"differences are cosmetic.\",\n             router_describe(ri), source);\n    *msg = \"Not replacing router descriptor; no information has changed since \"\n      \"the last one with this identity.\";\n    control_event_or_authdir_new_descriptor(\"DROPPED\",\n                         ri->cache_info.signed_descriptor_body,\n                         ri->cache_info.signed_descriptor_len, *msg);\n    routerinfo_free(ri);\n    return ROUTER_WAS_NOT_NEW;\n  }\n\n  \/* Make a copy of desc, since router_add_to_routerlist might free\n   * ri and its associated signed_descriptor_t. *\/\n  desclen = ri->cache_info.signed_descriptor_len;\n  desc = tor_strndup(ri->cache_info.signed_descriptor_body, desclen);\n  nickname = tor_strdup(ri->nickname);\n\n  \/* Tell if we're about to need to launch a test if we add this. *\/\n  ri->needs_retest_if_added =\n    dirserv_should_launch_reachability_test(ri, ri_old);\n\n  r = router_add_to_routerlist(ri, msg, 0, 0);\n  if (!WRA_WAS_ADDED(r)) {\n    \/* unless the routerinfo was fine, just out-of-date *\/\n    if (WRA_WAS_REJECTED(r))\n      control_event_or_authdir_new_descriptor(\"REJECTED\", desc, desclen, *msg);\n    log_info(LD_DIRSERV,\n             \"Did not add descriptor from '%s' (source: %s): %s.\",\n             nickname, source, *msg ? *msg : \"(no message)\");\n  } else {\n    smartlist_t *changed;\n    control_event_or_authdir_new_descriptor(\"ACCEPTED\", desc, desclen, *msg);\n\n    changed = smartlist_create();\n    smartlist_add(changed, ri);\n    routerlist_descriptors_added(changed, 0);\n    smartlist_free(changed);\n    if (!*msg) {\n      *msg =  ri->is_valid ? \"Descriptor for valid server accepted\" :\n        \"Descriptor for invalid server accepted\";\n    }\n    log_info(LD_DIRSERV,\n             \"Added descriptor from '%s' (source: %s): %s.\",\n             nickname, source, *msg);\n  }\n  tor_free(desc);\n  tor_free(nickname);\n  return r;\n}","target":0,"code_token_length":895,"total_token_length":1131,"max_tokens_setting":2048}
+{"idx":476099,"func":"int config_ep_by_speed_and_alt(struct usb_gadget *g,\n\t\t\t\tstruct usb_function *f,\n\t\t\t\tstruct usb_ep *_ep,\n\t\t\t\tu8 alt)\n{\n\tstruct usb_endpoint_descriptor *chosen_desc = NULL;\n\tstruct usb_interface_descriptor *int_desc = NULL;\n\tstruct usb_descriptor_header **speed_desc = NULL;\n\n\tstruct usb_ss_ep_comp_descriptor *comp_desc = NULL;\n\tint want_comp_desc = 0;\n\n\tstruct usb_descriptor_header **d_spd; \/* cursor for speed desc *\/\n\tstruct usb_composite_dev *cdev;\n\tbool incomplete_desc = false;\n\n\tif (!g || !f || !_ep)\n\t\treturn -EIO;\n\n\t\/* select desired speed *\/\n\tswitch (g->speed) {\n\tcase USB_SPEED_SUPER_PLUS:\n\t\tif (gadget_is_superspeed_plus(g)) {\n\t\t\tif (f->ssp_descriptors) {\n\t\t\t\tspeed_desc = f->ssp_descriptors;\n\t\t\t\twant_comp_desc = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tincomplete_desc = true;\n\t\t}\n\t\tfallthrough;\n\tcase USB_SPEED_SUPER:\n\t\tif (gadget_is_superspeed(g)) {\n\t\t\tif (f->ss_descriptors) {\n\t\t\t\tspeed_desc = f->ss_descriptors;\n\t\t\t\twant_comp_desc = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tincomplete_desc = true;\n\t\t}\n\t\tfallthrough;\n\tcase USB_SPEED_HIGH:\n\t\tif (gadget_is_dualspeed(g)) {\n\t\t\tif (f->hs_descriptors) {\n\t\t\t\tspeed_desc = f->hs_descriptors;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tincomplete_desc = true;\n\t\t}\n\t\tfallthrough;\n\tdefault:\n\t\tspeed_desc = f->fs_descriptors;\n\t}\n\n\tcdev = get_gadget_data(g);\n\tif (incomplete_desc)\n\t\tWARNING(cdev,\n\t\t\t\"%s doesn't hold the descriptors for current speed\\n\",\n\t\t\tf->name);\n\n\t\/* find correct alternate setting descriptor *\/\n\tfor_each_desc(speed_desc, d_spd, USB_DT_INTERFACE) {\n\t\tint_desc = (struct usb_interface_descriptor *)*d_spd;\n\n\t\tif (int_desc->bAlternateSetting == alt) {\n\t\t\tspeed_desc = d_spd;\n\t\t\tgoto intf_found;\n\t\t}\n\t}\n\treturn -EIO;\n\nintf_found:\n\t\/* find descriptors *\/\n\tfor_each_desc(speed_desc, d_spd, USB_DT_ENDPOINT) {\n\t\tchosen_desc = (struct usb_endpoint_descriptor *)*d_spd;\n\t\tif (chosen_desc->bEndpointAddress == _ep->address)\n\t\t\tgoto ep_found;\n\t}\n\treturn -EIO;\n\nep_found:\n\t\/* commit results *\/\n\t_ep->maxpacket = usb_endpoint_maxp(chosen_desc);\n\t_ep->desc = chosen_desc;\n\t_ep->comp_desc = NULL;\n\t_ep->maxburst = 0;\n\t_ep->mult = 1;\n\n\tif (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) ||\n\t\t\t\tusb_endpoint_xfer_int(_ep->desc)))\n\t\t_ep->mult = usb_endpoint_maxp_mult(_ep->desc);\n\n\tif (!want_comp_desc)\n\t\treturn 0;\n\n\t\/*\n\t * Companion descriptor should follow EP descriptor\n\t * USB 3.0 spec, #9.6.7\n\t *\/\n\tcomp_desc = (struct usb_ss_ep_comp_descriptor *)*(++d_spd);\n\tif (!comp_desc ||\n\t    (comp_desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP))\n\t\treturn -EIO;\n\t_ep->comp_desc = comp_desc;\n\tif (g->speed >= USB_SPEED_SUPER) {\n\t\tswitch (usb_endpoint_type(_ep->desc)) {\n\t\tcase USB_ENDPOINT_XFER_ISOC:\n\t\t\t\/* mult: bits 1:0 of bmAttributes *\/\n\t\t\t_ep->mult = (comp_desc->bmAttributes & 0x3) + 1;\n\t\t\tfallthrough;\n\t\tcase USB_ENDPOINT_XFER_BULK:\n\t\tcase USB_ENDPOINT_XFER_INT:\n\t\t\t_ep->maxburst = comp_desc->bMaxBurst + 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (comp_desc->bMaxBurst != 0)\n\t\t\t\tERROR(cdev, \"ep0 bMaxBurst must be 0\\n\");\n\t\t\t_ep->maxburst = 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":897,"total_token_length":1133,"max_tokens_setting":2048}
+{"idx":238544,"func":"static int check_stack_write_fixed_off(struct bpf_verifier_env *env,\n\t\t\t\t       \/* stack frame we're writing to *\/\n\t\t\t\t       struct bpf_func_state *state,\n\t\t\t\t       int off, int size, int value_regno,\n\t\t\t\t       int insn_idx)\n{\n\tstruct bpf_func_state *cur; \/* state of the current function *\/\n\tint i, slot = -off - 1, spi = slot \/ BPF_REG_SIZE, err;\n\tu32 dst_reg = env->prog->insnsi[insn_idx].dst_reg;\n\tstruct bpf_reg_state *reg = NULL;\n\n\terr = grow_stack_state(state, round_up(slot + 1, BPF_REG_SIZE));\n\tif (err)\n\t\treturn err;\n\t\/* caller checked that off % size == 0 and -MAX_BPF_STACK <= off < 0,\n\t * so it's aligned access and [off, off + size) are within stack limits\n\t *\/\n\tif (!env->allow_ptr_leaks &&\n\t    state->stack[spi].slot_type[0] == STACK_SPILL &&\n\t    size != BPF_REG_SIZE) {\n\t\tverbose(env, \"attempt to corrupt spilled pointer on stack\\n\");\n\t\treturn -EACCES;\n\t}\n\n\tcur = env->cur_state->frame[env->cur_state->curframe];\n\tif (value_regno >= 0)\n\t\treg = &cur->regs[value_regno];\n\tif (!env->bypass_spec_v4) {\n\t\tbool sanitize = reg && is_spillable_regtype(reg->type);\n\n\t\tfor (i = 0; i < size; i++) {\n\t\t\tif (state->stack[spi].slot_type[i] == STACK_INVALID) {\n\t\t\t\tsanitize = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sanitize)\n\t\t\tenv->insn_aux_data[insn_idx].sanitize_stack_spill = true;\n\t}\n\n\tmark_stack_slot_scratched(env, spi);\n\tif (reg && !(off % BPF_REG_SIZE) && register_is_bounded(reg) &&\n\t    !register_is_null(reg) && env->bpf_capable) {\n\t\tif (dst_reg != BPF_REG_FP) {\n\t\t\t\/* The backtracking logic can only recognize explicit\n\t\t\t * stack slot address like [fp - 8]. Other spill of\n\t\t\t * scalar via different register has to be conservative.\n\t\t\t * Backtrack from here and mark all registers as precise\n\t\t\t * that contributed into 'reg' being a constant.\n\t\t\t *\/\n\t\t\terr = mark_chain_precision(env, value_regno);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t}\n\t\tsave_register_state(state, spi, reg, size);\n\t} else if (reg && is_spillable_regtype(reg->type)) {\n\t\t\/* register containing pointer is being spilled into stack *\/\n\t\tif (size != BPF_REG_SIZE) {\n\t\t\tverbose_linfo(env, insn_idx, \"; \");\n\t\t\tverbose(env, \"invalid size of register spill\\n\");\n\t\t\treturn -EACCES;\n\t\t}\n\t\tif (state != cur && reg->type == PTR_TO_STACK) {\n\t\t\tverbose(env, \"cannot spill pointers to stack into stack frame of the caller\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tsave_register_state(state, spi, reg, size);\n\t} else {\n\t\tu8 type = STACK_MISC;\n\n\t\t\/* regular write of data into stack destroys any spilled ptr *\/\n\t\tstate->stack[spi].spilled_ptr.type = NOT_INIT;\n\t\t\/* Mark slots as STACK_MISC if they belonged to spilled ptr. *\/\n\t\tif (is_spilled_reg(&state->stack[spi]))\n\t\t\tfor (i = 0; i < BPF_REG_SIZE; i++)\n\t\t\t\tscrub_spilled_slot(&state->stack[spi].slot_type[i]);\n\n\t\t\/* only mark the slot as written if all 8 bytes were written\n\t\t * otherwise read propagation may incorrectly stop too soon\n\t\t * when stack slots are partially written.\n\t\t * This heuristic means that read propagation will be\n\t\t * conservative, since it will add reg_live_read marks\n\t\t * to stack slots all the way to first state when programs\n\t\t * writes+reads less than 8 bytes\n\t\t *\/\n\t\tif (size == BPF_REG_SIZE)\n\t\t\tstate->stack[spi].spilled_ptr.live |= REG_LIVE_WRITTEN;\n\n\t\t\/* when we zero initialize stack slots mark them as such *\/\n\t\tif (reg && register_is_null(reg)) {\n\t\t\t\/* backtracking doesn't work for STACK_ZERO yet. *\/\n\t\t\terr = mark_chain_precision(env, value_regno);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\ttype = STACK_ZERO;\n\t\t}\n\n\t\t\/* Mark slots affected by this stack write. *\/\n\t\tfor (i = 0; i < size; i++)\n\t\t\tstate->stack[spi].slot_type[(slot - i) % BPF_REG_SIZE] =\n\t\t\t\ttype;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":1026,"total_token_length":1262,"max_tokens_setting":2048}
+{"idx":218974,"func":"Status ConstantFolding::FoldNode(NodeDef* node, GraphDef* output_graph,\n                                 bool* result_too_large) {\n  *result_too_large = false;\n  if (IsMerge(*node)) {\n    return FoldMergeNode(node, output_graph);\n  }\n\n  std::vector<NodeDef> const_nodes;\n  TF_RETURN_IF_ERROR(\n      EvaluateOneFoldable(*node, &const_nodes, result_too_large));\n  VLOG(2) << \"Folded node: \" << SummarizeNodeDef(*node);\n\n  NodeDef* constant_output = nullptr;\n  for (int i = 0, end = const_nodes.size(); i < end; i++) {\n    NodeDef* const_node = &const_nodes[i];\n    VLOG(3) << \"Generated constant node: \" << SummarizeNodeDef(*const_node);\n    if (const_node->name().empty()) {\n      \/\/ Dead output: we can't create a constant to encode its value, so we'll\n      \/\/ just skip it. We'll preserve the edges that originate from that\n      \/\/ output below to preserve the overall behavior of the graph wrt dead\n      \/\/ edges.\n      continue;\n    }\n\n    \/\/ Returns `true` iff `const_node` already has control input named `input`.\n    const auto is_duplicate_control_input = [&](const string& input) -> bool {\n      auto it = absl::c_find(const_node->input(), input);\n      return it != const_node->input().end();\n    };\n\n    \/\/ Forward control dependencies.\n    for (const string& input : node->input()) {\n      \/\/ Forward control dependencies from folded node.\n      if (IsControlInput(input)) {\n        if (!is_duplicate_control_input(input)) {\n          *const_node->add_input() = input;\n        }\n      }\n\n      \/\/ Forward control dependencies from constant inputs to folded node.\n      if (!IsControlInput(input)) {\n        NodeDef* input_node = node_map_->GetNode(input);\n        for (const string& fanin_of_input : input_node->input()) {\n          if (!is_duplicate_control_input(fanin_of_input)) {\n            *const_node->add_input() = fanin_of_input;\n          }\n        }\n      }\n    }\n\n    \/\/ We rewrite the existing node if it only has a single output, and\n    \/\/ create new nodes otherwise.\n    if (const_nodes.size() == 1) {\n      node->set_op(\"Const\");\n      \/\/ Note we need to clear the inputs in NodeMap before we clear the inputs\n      \/\/ in the node, otherwise NodeMap would see empty inputs and effectively\n      \/\/ does nothing.\n      node_map_->RemoveInputs(node->name());\n      node->clear_input();\n      *node->mutable_input() = const_node->input();\n      for (const auto& input : node->input()) {\n        node_map_->AddOutput(NodeName(input), node->name());\n      }\n      *node->mutable_attr() = const_node->attr();\n      break;\n    } else {\n      if (node_map_->GetNode(const_node->name())) {\n        \/\/ Intended name already exists.\n        return errors::AlreadyExists(strings::StrCat(\n            const_node->name(), \" already present in the graph\"));\n      }\n      NodeDef* added_node = output_graph->add_node();\n      *added_node = *const_node;\n      added_node->set_device(node->device());\n      node_map_->AddNode(added_node->name(), added_node);\n      for (const auto& input : added_node->input()) {\n        node_map_->AddOutput(NodeName(input), added_node->name());\n      }\n      \/\/ All the constant nodes encoding output values have the same control\n      \/\/ dependencies (since these are the control dependencies of the node\n      \/\/ we're trying to fold). Record one such constant node.\n      constant_output = added_node;\n    }\n  }\n\n  if (const_nodes.size() > 1) {\n    \/\/ We make a copy because we mutate the nodes.\n    auto outputs = node_map_->GetOutputs(node->name());\n    for (NodeDef* output : outputs) {\n      for (int i = 0; i < output->input_size(); i++) {\n        int port;\n        string node_name = ParseNodeName(output->input(i), &port);\n        if (node_name == node->name()) {\n          if (port < 0) {\n            \/\/ Propagate control dependencies if possible. If not, we'll just\n            \/\/ preserve the existing control dependencies.\n            if (constant_output != nullptr) {\n              node_map_->UpdateInput(node_name, NodeName(output->input(i)),\n                                     constant_output->name());\n              *output->mutable_input(i) = AsControlDependency(*constant_output);\n            }\n          } else if (port < static_cast<int>(const_nodes.size()) &&\n                     !const_nodes[port].name().empty()) {\n            \/\/ Replace alive outputs with the corresponding constant.\n            node_map_->UpdateInput(output->name(), NodeName(output->input(i)),\n                                   const_nodes[port].name());\n            *output->mutable_input(i) = const_nodes[port].name();\n          } else {\n            \/\/ Leave this edge alone.\n            VLOG(3) << \"Preserving edge from \" << node->name() << \":\" << port\n                    << \"[\" << node->op() << \"] to \" << output->name() << \":\"\n                    << i << \"[\" << output->op() << \"]\";\n          }\n        }\n      }\n    }\n    outputs = node_map_->GetOutputs(node->name());\n    if (outputs.empty() && has_fetch_ &&\n        nodes_to_preserve_.find(node->name()) == nodes_to_preserve_.end()) {\n      node_map_->RemoveInputs(node->name());\n      node->clear_input();\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":1204,"total_token_length":1440,"max_tokens_setting":2048}
+{"idx":310008,"func":"drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret)\n{\n    bool result = FALSE;\n    int status;\n    TERMINAL *termp;\n    SCREEN *sp;\n\n    START_TRACE();\n    T((T_CALLED(\"tinfo::drv_CanHandle(%p)\"), (void *) TCB));\n\n    assert(TCB != 0 && tname != 0);\n    termp = (TERMINAL *) TCB;\n    sp = TCB->csp;\n    TCB->magic = TCBMAGIC;\n\n#if (NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP)\n    status = _nc_setup_tinfo(tname, &TerminalType(termp));\n    T((\"_nc_setup_tinfo returns %d\", status));\n#else\n    T((\"no database available\"));\n    status = TGETENT_NO;\n#endif\n\n    \/* try fallback list if entry on disk *\/\n    if (status != TGETENT_YES) {\n\tconst TERMTYPE2 *fallback = _nc_fallback2(tname);\n\n\tif (fallback) {\n\t    T((\"found fallback entry\"));\n\t    TerminalType(termp) = *fallback;\n\t    status = TGETENT_YES;\n\t}\n    }\n\n    if (status != TGETENT_YES) {\n\tNCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx termp);\n\tif (status == TGETENT_ERR) {\n\t    ret_error0(status, \"terminals database is inaccessible\\n\");\n\t} else if (status == TGETENT_NO) {\n\t    ret_error1(status, \"unknown terminal type.\\n\",\n\t\t       tname, NO_COPY);\n\t} else {\n\t    ret_error0(status, \"unexpected return-code\\n\");\n\t}\n    }\n    result = TRUE;\n#if NCURSES_EXT_NUMBERS\n    _nc_export_termtype2(&termp->type, &TerminalType(termp));\n#endif\n#if !USE_REENTRANT\n    save_ttytype(termp);\n#endif\n\n    if (command_character)\n\t_nc_tinfo_cmdch(termp, *command_character);\n\n    \/*\n     * If an application calls setupterm() rather than initscr() or\n     * newterm(), we will not have the def_prog_mode() call in\n     * _nc_setupscreen().  Do it now anyway, so we can initialize the\n     * baudrate.\n     *\/\n    if (sp == 0 && NC_ISATTY(termp->Filedes)) {\n\tget_baudrate(termp);\n    }\n#if NCURSES_EXT_NUMBERS\n#define cleanup_termtype() \\\n    _nc_free_termtype2(&TerminalType(termp)); \\\n    _nc_free_termtype(&termp->type)\n#else\n#define cleanup_termtype() \\\n    _nc_free_termtype2(&TerminalType(termp))\n#endif\n\n    if (generic_type) {\n\t\/*\n\t * BSD 4.3's termcap contains mis-typed \"gn\" for wy99.  Do a sanity\n\t * check before giving up.\n\t *\/\n\tif ((VALID_STRING(cursor_address)\n\t     || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home)))\n\t    && VALID_STRING(clear_screen)) {\n\t    cleanup_termtype();\n\t    ret_error1(TGETENT_YES, \"terminal is not really generic.\\n\",\n\t\t       tname, NO_COPY);\n\t} else {\n\t    cleanup_termtype();\n\t    ret_error1(TGETENT_NO, \"I need something more specific.\\n\",\n\t\t       tname, NO_COPY);\n\t}\n    }\n    if (hard_copy) {\n\tcleanup_termtype();\n\tret_error1(TGETENT_YES, \"I can't handle hardcopy terminals.\\n\",\n\t\t   tname, NO_COPY);\n    }\n\n    returnBool(result);\n}","target":0,"code_token_length":790,"total_token_length":1026,"max_tokens_setting":2048}
+{"idx":464942,"func":"mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter)\n{\n\tint k;\n\tint c1, w, c2;\n\n\tswitch (filter->status) {\n\tcase 0:\n\t\tif (filter->from->no_encoding == mbfl_no_encoding_cp950) {\n\t\t\tc1 = 0x80;\n\t\t} else {\n\t\t\tc1 = 0xa0;\n\t\t}\n\n\t\tif (c >= 0 && c <= 0x80) {\t\/* latin *\/\n\t\t\tCK((*filter->output_function)(c, filter->data));\n\t\t} else if (c == 0xff) {\n\t\t\tCK((*filter->output_function)(0xf8f8, filter->data));\n\t\t} else if (c > c1 && c < 0xff) {\t\/* dbcs lead byte *\/\n\t\t\tfilter->status = 1;\n\t\t\tfilter->cache = c;\n\t\t} else {\n\t\t\tw = c & MBFL_WCSGROUP_MASK;\n\t\t\tw |= MBFL_WCSGROUP_THROUGH;\n\t\t\tCK((*filter->output_function)(w, filter->data));\n\t\t}\n\t\tbreak;\n\n\tcase 1:\t\t\/* dbcs second byte *\/\n\t\tfilter->status = 0;\n\t\tc1 = filter->cache;\n\t\tif ((c > 0x39 && c < 0x7f) | (c > 0xa0 && c < 0xff)) {\n\t\t\tif (c < 0x7f){\n\t\t\t\tw = (c1 - 0xa1)*157 + (c - 0x40);\n\t\t\t} else {\n\t\t\t\tw = (c1 - 0xa1)*157 + (c - 0xa1) + 0x3f;\n\t\t\t}\n\t\t\tif (w >= 0 && w < big5_ucs_table_size) {\n\t\t\t\tw = big5_ucs_table[w];\n\t\t\t} else {\n\t\t\t\tw = 0;\n\t\t\t}\n\n\t\t\tif (filter->from->no_encoding == mbfl_no_encoding_cp950) {\n\t\t\t\t\/* PUA for CP950 *\/\n\t\t\t\tif (w <= 0 && is_in_cp950_pua(c1, c)) {\n\t\t\t\t\tc2 = c1 << 8 | c;\n\t\t\t\t\tfor (k = 0; k < sizeof(cp950_pua_tbl)\/(sizeof(unsigned short)*4); k++) {\n\t\t\t\t\t\tif (c2 >= cp950_pua_tbl[k][2] && c2 <= cp950_pua_tbl[k][3]) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((cp950_pua_tbl[k][2] & 0xff) == 0x40) {\n\t\t\t\t\t\tw = 157*(c1 - (cp950_pua_tbl[k][2]>>8)) + c - (c >= 0xa1 ? 0x62 : 0x40)\n\t\t\t\t\t\t\t+ cp950_pua_tbl[k][0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tw = c2 - cp950_pua_tbl[k][2] + cp950_pua_tbl[k][0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (w <= 0) {\n\t\t\t\tw = (c1 << 8) | c;\n\t\t\t\tw &= MBFL_WCSPLANE_MASK;\n\t\t\t\tw |= MBFL_WCSPLANE_BIG5;\n\t\t\t}\n\t\t\tCK((*filter->output_function)(w, filter->data));\n\t\t} else if ((c >= 0 && c < 0x21) || c == 0x7f) {\t\t\/* CTLs *\/\n\t\t\tCK((*filter->output_function)(c, filter->data));\n\t\t} else {\n\t\t\tw = (c1 << 8) | c;\n\t\t\tw &= MBFL_WCSGROUP_MASK;\n\t\t\tw |= MBFL_WCSGROUP_THROUGH;\n\t\t\tCK((*filter->output_function)(w, filter->data));\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tfilter->status = 0;\n\t\tbreak;\n\t}\n\n\treturn c;\n}","target":0,"code_token_length":886,"total_token_length":1122,"max_tokens_setting":2048}
+{"idx":234133,"func":"get_line_filename_and_dirname (dwarf_vma line_offset,\n\t\t\t       dwarf_vma fileidx,\n\t\t\t       unsigned char **dir_name)\n{\n  struct dwarf_section *section = &debug_displays [line].section;\n  unsigned char *hdrptr, *dirtable, *file_name;\n  unsigned int offset_size;\n  unsigned int version, opcode_base;\n  dwarf_vma length, diridx;\n  const unsigned char * end;\n\n  *dir_name = NULL;\n  if (section->start == NULL\n      || line_offset >= section->size\n      || fileidx == 0)\n    return NULL;\n\n  hdrptr = section->start + line_offset;\n  end = section->start + section->size;\n\n  SAFE_BYTE_GET_AND_INC (length, hdrptr, 4, end);\n  if (length == 0xffffffff)\n    {\n      \/* This section is 64-bit DWARF 3.  *\/\n      SAFE_BYTE_GET_AND_INC (length, hdrptr, 8, end);\n      offset_size = 8;\n    }\n  else\n    offset_size = 4;\n\n  if (length > (size_t) (end - hdrptr)\n      || length < 2 + offset_size + 1 + 3 + 1)\n    return NULL;\n  end = hdrptr + length;\n\n  SAFE_BYTE_GET_AND_INC (version, hdrptr, 2, end);\n  if (version != 2 && version != 3 && version != 4)\n    return NULL;\n  hdrptr += offset_size + 1;\/* Skip prologue_length and min_insn_length.  *\/\n  if (version >= 4)\n    hdrptr++;\t\t    \/* Skip max_ops_per_insn.  *\/\n  hdrptr += 3;\t\t    \/* Skip default_is_stmt, line_base, line_range.  *\/\n\n  SAFE_BYTE_GET_AND_INC (opcode_base, hdrptr, 1, end);\n  if (opcode_base == 0\n      || opcode_base - 1 >= (size_t) (end - hdrptr))\n    return NULL;\n\n  hdrptr += opcode_base - 1;\n\n  dirtable = hdrptr;\n  \/* Skip over dirname table.  *\/\n  while (*hdrptr != '\\0')\n    {\n      hdrptr += strnlen ((char *) hdrptr, end - hdrptr);\n      if (hdrptr < end)\n\thdrptr++;\n      if (hdrptr >= end)\n\treturn NULL;\n    }\n  hdrptr++;\t\t    \/* Skip the NUL at the end of the table.  *\/\n\n  \/* Now skip over preceding filename table entries.  *\/\n  for (; hdrptr < end && *hdrptr != '\\0' && fileidx > 1; fileidx--)\n    {\n      hdrptr += strnlen ((char *) hdrptr, end - hdrptr);\n      if (hdrptr < end)\n\thdrptr++;\n      SKIP_ULEB (hdrptr, end);\n      SKIP_ULEB (hdrptr, end);\n      SKIP_ULEB (hdrptr, end);\n    }\n  if (hdrptr >= end || *hdrptr == '\\0')\n    return NULL;\n\n  file_name = hdrptr;\n  hdrptr += strnlen ((char *) hdrptr, end - hdrptr);\n  if (hdrptr < end)\n    hdrptr++;\n  if (hdrptr >= end)\n    return NULL;\n  READ_ULEB (diridx, hdrptr, end);\n  if (diridx == 0)\n    return file_name;\n  for (; dirtable < end && *dirtable != '\\0' && diridx > 1; diridx--)\n    {\n      dirtable += strnlen ((char *) dirtable, end - dirtable);\n      if (dirtable < end)\n\tdirtable++;\n    }\n  if (dirtable >= end || *dirtable == '\\0')\n    return NULL;\n  *dir_name = dirtable;\n  return file_name;\n}","target":0,"code_token_length":819,"total_token_length":1055,"max_tokens_setting":2048}
+{"idx":447047,"func":"    byte* FileIo::mmap(bool isWriteable)\n    {\n        assert(p_->fp_ != 0);\n        if (munmap() != 0) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), strError().c_str(), \"munmap\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), strError(), \"munmap\");\n            }\n        }\n        p_->mappedLength_ = size();\n        p_->isWriteable_ = isWriteable;\n        if (p_->isWriteable_ && p_->switchMode(Impl::opWrite) != 0) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(16, wpath(), strError().c_str());\n            }\n            else\n#endif\n            {\n                throw Error(16, path(), strError());\n            }\n        }\n#if defined EXV_HAVE_MMAP && defined EXV_HAVE_MUNMAP\n        int prot = PROT_READ;\n        if (p_->isWriteable_) {\n            prot |= PROT_WRITE;\n        }\n        void* rc = ::mmap(0, p_->mappedLength_, prot, MAP_SHARED, fileno(p_->fp_), 0);\n        if (MAP_FAILED == rc) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), strError().c_str(), \"mmap\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), strError(), \"mmap\");\n            }\n        }\n        p_->pMappedArea_ = static_cast<byte*>(rc);\n\n#elif defined WIN32 && !defined __CYGWIN__\n        \/\/ Windows implementation\n\n        \/\/ TODO: An attempt to map a file with a length of 0 (zero) fails with\n        \/\/ an error code of ERROR_FILE_INVALID.\n        \/\/ Applications should test for files with a length of 0 (zero) and\n        \/\/ reject those files.\n\n        DWORD dwAccess = FILE_MAP_READ;\n        DWORD flProtect = PAGE_READONLY;\n        if (isWriteable) {\n            dwAccess = FILE_MAP_WRITE;\n            flProtect = PAGE_READWRITE;\n        }\n        HANDLE hPh = GetCurrentProcess();\n        HANDLE hFd = (HANDLE)_get_osfhandle(fileno(p_->fp_));\n        if (hFd == INVALID_HANDLE_VALUE) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), \"MSG1\", \"_get_osfhandle\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), \"MSG1\", \"_get_osfhandle\");\n            }\n        }\n        if (!DuplicateHandle(hPh, hFd, hPh, &p_->hFile_, 0, false, DUPLICATE_SAME_ACCESS)) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), \"MSG2\", \"DuplicateHandle\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), \"MSG2\", \"DuplicateHandle\");\n            }\n        }\n        p_->hMap_ = CreateFileMapping(p_->hFile_, 0, flProtect, 0, (DWORD) p_->mappedLength_, 0);\n        if (p_->hMap_ == 0 ) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), \"MSG3\", \"CreateFileMapping\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), \"MSG3\", \"CreateFileMapping\");\n            }\n        }\n        void* rc = MapViewOfFile(p_->hMap_, dwAccess, 0, 0, 0);\n        if (rc == 0) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), \"MSG4\", \"CreateFileMapping\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), \"MSG4\", \"CreateFileMapping\");\n            }\n        }\n        p_->pMappedArea_ = static_cast<byte*>(rc);\n#else\n        \/\/ Workaround for platforms without mmap: Read the file into memory\n        DataBuf buf(static_cast<long>(p_->mappedLength_));\n        if (read(buf.pData_, buf.size_) != buf.size_) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), strError().c_str(), \"FileIo::read\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), strError(), \"FileIo::read\");\n            }\n        }\n        if (error()) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(2, wpath(), strError().c_str(), \"FileIo::mmap\");\n            }\n            else\n#endif\n            {\n                throw Error(2, path(), strError(), \"FileIo::mmap\");\n            }\n        }\n        p_->pMappedArea_ = buf.release().first;\n        p_->isMalloced_ = true;\n#endif\n        return p_->pMappedArea_;\n    }","target":0,"code_token_length":1174,"total_token_length":1410,"max_tokens_setting":2048}
+{"idx":199159,"func":"static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)\n{\n\tint err = 0;\n\tunsigned int saved_f_flags;\n\tstruct snd_pcm_substream *substream;\n\tstruct snd_pcm_runtime *runtime;\n\tsnd_pcm_format_t format;\n\tunsigned long width;\n\tsize_t size;\n\n\tsubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];\n\tif (substream != NULL) {\n\t\truntime = substream->runtime;\n\t\tif (atomic_read(&substream->mmap_count))\n\t\t\tgoto __direct;\n\t\terr = snd_pcm_oss_make_ready(substream);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\tatomic_inc(&runtime->oss.rw_ref);\n\t\tif (mutex_lock_interruptible(&runtime->oss.params_lock)) {\n\t\t\tatomic_dec(&runtime->oss.rw_ref);\n\t\t\treturn -ERESTARTSYS;\n\t\t}\n\t\tformat = snd_pcm_oss_format_from(runtime->oss.format);\n\t\twidth = snd_pcm_format_physical_width(format);\n\t\tif (runtime->oss.buffer_used > 0) {\n#ifdef OSS_DEBUG\n\t\t\tpcm_dbg(substream->pcm, \"sync: buffer_used\\n\");\n#endif\n\t\t\tsize = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) \/ width;\n\t\t\tsnd_pcm_format_set_silence(format,\n\t\t\t\t\t\t   runtime->oss.buffer + runtime->oss.buffer_used,\n\t\t\t\t\t\t   size);\n\t\t\terr = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);\n\t\t\tif (err < 0)\n\t\t\t\tgoto unlock;\n\t\t} else if (runtime->oss.period_ptr > 0) {\n#ifdef OSS_DEBUG\n\t\t\tpcm_dbg(substream->pcm, \"sync: period_ptr\\n\");\n#endif\n\t\t\tsize = runtime->oss.period_bytes - runtime->oss.period_ptr;\n\t\t\tsnd_pcm_format_set_silence(format,\n\t\t\t\t\t\t   runtime->oss.buffer,\n\t\t\t\t\t\t   size * 8 \/ width);\n\t\t\terr = snd_pcm_oss_sync1(substream, size);\n\t\t\tif (err < 0)\n\t\t\t\tgoto unlock;\n\t\t}\n\t\t\/*\n\t\t * The ALSA's period might be a bit large than OSS one.\n\t\t * Fill the remain portion of ALSA period with zeros.\n\t\t *\/\n\t\tsize = runtime->control->appl_ptr % runtime->period_size;\n\t\tif (size > 0) {\n\t\t\tsize = runtime->period_size - size;\n\t\t\tif (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED)\n\t\t\t\tsnd_pcm_lib_write(substream, NULL, size);\n\t\t\telse if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)\n\t\t\t\tsnd_pcm_lib_writev(substream, NULL, size);\n\t\t}\nunlock:\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t\tatomic_dec(&runtime->oss.rw_ref);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\t\/*\n\t\t * finish sync: drain the buffer\n\t\t *\/\n\t      __direct:\n\t\tsaved_f_flags = substream->f_flags;\n\t\tsubstream->f_flags &= ~O_NONBLOCK;\n\t\terr = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);\n\t\tsubstream->f_flags = saved_f_flags;\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\tmutex_lock(&runtime->oss.params_lock);\n\t\truntime->oss.prepare = 1;\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t}\n\n\tsubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];\n\tif (substream != NULL) {\n\t\terr = snd_pcm_oss_make_ready(substream);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\truntime = substream->runtime;\n\t\terr = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\tmutex_lock(&runtime->oss.params_lock);\n\t\truntime->oss.buffer_used = 0;\n\t\truntime->oss.prepare = 1;\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t}\n\treturn 0;\n}","target":1,"code_token_length":853,"total_token_length":1089,"max_tokens_setting":2048}
+{"idx":291831,"func":"static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_path *clt_path)\n{\n\tstruct rtrs_clt_sess *clt = clt_path->clt;\n\tstruct rtrs_clt_path *next;\n\tbool wait_for_grace = false;\n\tint cpu;\n\n\tmutex_lock(&clt->paths_mutex);\n\tlist_del_rcu(&clt_path->s.entry);\n\n\t\/* Make sure everybody observes path removal. *\/\n\tsynchronize_rcu();\n\n\t\/*\n\t * At this point nobody sees @sess in the list, but still we have\n\t * dangling pointer @pcpu_path which _can_ point to @sess.  Since\n\t * nobody can observe @sess in the list, we guarantee that IO path\n\t * will not assign @sess to @pcpu_path, i.e. @pcpu_path can be equal\n\t * to @sess, but can never again become @sess.\n\t *\/\n\n\t\/*\n\t * Decrement paths number only after grace period, because\n\t * caller of do_each_path() must firstly observe list without\n\t * path and only then decremented paths number.\n\t *\n\t * Otherwise there can be the following situation:\n\t *    o Two paths exist and IO is coming.\n\t *    o One path is removed:\n\t *      CPU#0                          CPU#1\n\t *      do_each_path():                rtrs_clt_remove_path_from_arr():\n\t *          path = get_next_path()\n\t *          ^^^                            list_del_rcu(path)\n\t *          [!CONNECTED path]              clt->paths_num--\n\t *                                              ^^^^^^^^^\n\t *          load clt->paths_num                 from 2 to 1\n\t *                    ^^^^^^^^^\n\t *                    sees 1\n\t *\n\t *      path is observed as !CONNECTED, but do_each_path() loop\n\t *      ends, because expression i < clt->paths_num is false.\n\t *\/\n\tclt->paths_num--;\n\n\t\/*\n\t * Get @next connection from current @sess which is going to be\n\t * removed.  If @sess is the last element, then @next is NULL.\n\t *\/\n\trcu_read_lock();\n\tnext = list_next_or_null_rr_rcu(&clt->paths_list, &clt_path->s.entry,\n\t\t\t\t\ttypeof(*next), s.entry);\n\trcu_read_unlock();\n\n\t\/*\n\t * @pcpu paths can still point to the path which is going to be\n\t * removed, so change the pointer manually.\n\t *\/\n\tfor_each_possible_cpu(cpu) {\n\t\tstruct rtrs_clt_path __rcu **ppcpu_path;\n\n\t\tppcpu_path = per_cpu_ptr(clt->pcpu_path, cpu);\n\t\tif (rcu_dereference_protected(*ppcpu_path,\n\t\t\tlockdep_is_held(&clt->paths_mutex)) != clt_path)\n\t\t\t\/*\n\t\t\t * synchronize_rcu() was called just after deleting\n\t\t\t * entry from the list, thus IO code path cannot\n\t\t\t * change pointer back to the pointer which is going\n\t\t\t * to be removed, we are safe here.\n\t\t\t *\/\n\t\t\tcontinue;\n\n\t\t\/*\n\t\t * We race with IO code path, which also changes pointer,\n\t\t * thus we have to be careful not to overwrite it.\n\t\t *\/\n\t\tif (xchg_paths(ppcpu_path, clt_path, next))\n\t\t\t\/*\n\t\t\t * @ppcpu_path was successfully replaced with @next,\n\t\t\t * that means that someone could also pick up the\n\t\t\t * @sess and dereferencing it right now, so wait for\n\t\t\t * a grace period is required.\n\t\t\t *\/\n\t\t\twait_for_grace = true;\n\t}\n\tif (wait_for_grace)\n\t\tsynchronize_rcu();\n\n\tmutex_unlock(&clt->paths_mutex);\n}","target":0,"code_token_length":790,"total_token_length":1026,"max_tokens_setting":2048}
+{"idx":231062,"func":"BaseType_t xQueueReceive( QueueHandle_t xQueue,\r\n                          void * const pvBuffer,\r\n                          TickType_t xTicksToWait )\r\n{\r\n    BaseType_t xEntryTimeSet = pdFALSE;\r\n    TimeOut_t xTimeOut;\r\n    Queue_t * const pxQueue = xQueue;\r\n\r\n    \/* Check the pointer is not NULL. *\/\r\n    configASSERT( ( pxQueue ) );\r\n\r\n    \/* The buffer into which data is received can only be NULL if the data size\r\n     * is zero (so no data is copied into the buffer). *\/\r\n    configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) );\r\n\r\n    \/* Cannot block if the scheduler is suspended. *\/\r\n    #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r\n        {\r\n            configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r\n        }\r\n    #endif\r\n\r\n    \/*lint -save -e904  This function relaxes the coding standard somewhat to\r\n     * allow return statements within the function itself.  This is done in the\r\n     * interest of execution time efficiency. *\/\r\n    for( ; ; )\r\n    {\r\n        taskENTER_CRITICAL();\r\n        {\r\n            const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;\r\n\r\n            \/* Is there data in the queue now?  To be running the calling task\r\n             * must be the highest priority task wanting to access the queue. *\/\r\n            if( uxMessagesWaiting > ( UBaseType_t ) 0 )\r\n            {\r\n                \/* Data available, remove one item. *\/\r\n                prvCopyDataFromQueue( pxQueue, pvBuffer );\r\n                traceQUEUE_RECEIVE( pxQueue );\r\n                pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1;\r\n\r\n                \/* There is now space in the queue, were any tasks waiting to\r\n                 * post to the queue?  If so, unblock the highest priority waiting\r\n                 * task. *\/\r\n                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r\n                {\r\n                    if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r\n                    {\r\n                        queueYIELD_IF_USING_PREEMPTION();\r\n                    }\r\n                    else\r\n                    {\r\n                        mtCOVERAGE_TEST_MARKER();\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n\r\n                taskEXIT_CRITICAL();\r\n                return pdPASS;\r\n            }\r\n            else\r\n            {\r\n                if( xTicksToWait == ( TickType_t ) 0 )\r\n                {\r\n                    \/* The queue was empty and no block time is specified (or\r\n                     * the block time has expired) so leave now. *\/\r\n                    taskEXIT_CRITICAL();\r\n                    traceQUEUE_RECEIVE_FAILED( pxQueue );\r\n                    return errQUEUE_EMPTY;\r\n                }\r\n                else if( xEntryTimeSet == pdFALSE )\r\n                {\r\n                    \/* The queue was empty and a block time was specified so\r\n                     * configure the timeout structure. *\/\r\n                    vTaskInternalSetTimeOutState( &xTimeOut );\r\n                    xEntryTimeSet = pdTRUE;\r\n                }\r\n                else\r\n                {\r\n                    \/* Entry time was already set. *\/\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n            }\r\n        }\r\n        taskEXIT_CRITICAL();\r\n\r\n        \/* Interrupts and other tasks can send to and receive from the queue\r\n         * now the critical section has been exited. *\/\r\n\r\n        vTaskSuspendAll();\r\n        prvLockQueue( pxQueue );\r\n\r\n        \/* Update the timeout state to see if it has expired yet. *\/\r\n        if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r\n        {\r\n            \/* The timeout has not expired.  If the queue is still empty place\r\n             * the task on the list of tasks waiting to receive from the queue. *\/\r\n            if( prvIsQueueEmpty( pxQueue ) != pdFALSE )\r\n            {\r\n                traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r\n                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r\n                prvUnlockQueue( pxQueue );\r\n\r\n                if( xTaskResumeAll() == pdFALSE )\r\n                {\r\n                    portYIELD_WITHIN_API();\r\n                }\r\n                else\r\n                {\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n            }\r\n            else\r\n            {\r\n                \/* The queue contains data again.  Loop back to try and read the\r\n                 * data. *\/\r\n                prvUnlockQueue( pxQueue );\r\n                ( void ) xTaskResumeAll();\r\n            }\r\n        }\r\n        else\r\n        {\r\n            \/* Timed out.  If there is no data in the queue exit, otherwise loop\r\n             * back and attempt to read the data. *\/\r\n            prvUnlockQueue( pxQueue );\r\n            ( void ) xTaskResumeAll();\r\n\r\n            if( prvIsQueueEmpty( pxQueue ) != pdFALSE )\r\n            {\r\n                traceQUEUE_RECEIVE_FAILED( pxQueue );\r\n                return errQUEUE_EMPTY;\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n        }\r\n    } \/*lint -restore *\/\r\n}\r","target":0,"code_token_length":1098,"total_token_length":1334,"max_tokens_setting":2048}
+{"idx":259714,"func":"static int validate_certificate_from_root(json_t * j_params, gnutls_x509_crt_t cert_leaf, cbor_item_t * x5c_array) {\n  int ret = G_ERROR_NOT_FOUND, res;\n  unsigned int result;\n  gnutls_datum_t cert_dat = {NULL, 0}, issuer_dat = {NULL, 0};\n  gnutls_x509_trust_list_t tlist = NULL;\n  gnutls_x509_crt_t cert_x509[cbor_array_size(x5c_array)+1], root_x509 = NULL;\n  json_t * j_cert = NULL;\n  cbor_item_t * cbor_cert = NULL;\n  size_t index = 0, i = 0, x5c_array_size = cbor_array_size(x5c_array);\n  char * issuer;\n  \n  for (i=0; i<x5c_array_size+1; i++) {\n    cert_x509[i] = NULL;\n  }\n  if ((res = gnutls_x509_crt_get_issuer_dn2(cert_leaf, &issuer_dat)) >= 0) {\n    issuer = o_strndup((const char *)issuer_dat.data, issuer_dat.size);\n    json_array_foreach(json_object_get(j_params, \"root-ca-array\"), index, j_cert) {\n      if (0 == o_strcmp(issuer, json_string_value(json_object_get(j_cert, \"dn\")))) {\n        cert_dat.data = (unsigned char *)json_string_value(json_object_get(j_cert, \"x509\"));\n        cert_dat.size = json_string_length(json_object_get(j_cert, \"x509\"));\n        if (!gnutls_x509_crt_init(&root_x509) && !gnutls_x509_crt_import(root_x509, &cert_dat, GNUTLS_X509_FMT_PEM)) {\n          cert_x509[0] = cert_leaf;\n          for (i=1; i<x5c_array_size; i++) {\n            cbor_cert = cbor_array_get(x5c_array, i);\n            cert_dat.data = cbor_bytestring_handle(cbor_cert);\n            cert_dat.size = cbor_bytestring_length(cbor_cert);\n            if (gnutls_x509_crt_init(&cert_x509[i]) < 0 || gnutls_x509_crt_import(cert_x509[i], &cert_dat, GNUTLS_X509_FMT_DER) < 0) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"validate_certificate_from_root - Error import chain cert at index %zu\", i);\n              ret = G_ERROR;\n            }\n            cbor_decref(&cbor_cert);\n          }\n          cert_x509[x5c_array_size] = root_x509;\n          ret = G_OK;\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"validate_certificate_from_root - Error import root cert\");\n          ret = G_ERROR;\n        }\n      }\n    }\n    o_free(issuer);\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"validate_certificate_from_root - Error gnutls_x509_crt_get_issuer_dn2: %d\", res);\n    ret = G_ERROR;\n  }\n  gnutls_free(issuer_dat.data);\n  \n  if (ret == G_OK) {\n    if (!gnutls_x509_trust_list_init(&tlist, 0)) {\n      if (gnutls_x509_trust_list_add_cas(tlist, &root_x509, 1, 0) >= 0) {\n        if (gnutls_x509_trust_list_verify_crt(tlist, cert_x509, 2, 0, &result, NULL) >= 0) {\n          if (result) {\n            y_log_message(Y_LOG_LEVEL_DEBUG, \"validate_certificate_from_root - certificate chain invalid\");\n            ret = G_ERROR;\n          }\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"validate_certificate_from_root - Error gnutls_x509_trust_list_verify_crt\");\n          ret = G_ERROR;\n        }\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"validate_certificate_from_root - Error gnutls_x509_trust_list_add_cas\");\n        ret = G_ERROR;\n      }\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"validate_certificate_from_root - Error gnutls_x509_trust_list_init\");\n      ret = G_ERROR;\n    }\n  }\n  gnutls_x509_crt_deinit(root_x509);\n  for (i=1; i<x5c_array_size; i++) {\n    gnutls_x509_crt_deinit(cert_x509[i]);\n  }\n  gnutls_x509_trust_list_deinit(tlist, 0);\n  return ret;\n}","target":0,"code_token_length":1066,"total_token_length":1302,"max_tokens_setting":2048}
+{"idx":352937,"func":"deliveryMethodValidate(\n\tSyntax *syntax,\n\tstruct berval *val )\n{\n#undef LENOF\n#define LENOF(s) (sizeof(s)-1)\n\tstruct berval tmp = *val;\n\t\/*\n     *\tDeliveryMethod = pdm *( WSP DOLLAR WSP DeliveryMethod )\n\t *\tpdm = \"any\" \/ \"mhs\" \/ \"physical\" \/ \"telex\" \/ \"teletex\" \/\n\t *\t\t\"g3fax\" \/ \"g4fax\" \/ \"ia5\" \/ \"videotex\" \/ \"telephone\"\n\t *\/\nagain:\n\tif( tmp.bv_len < 3 ) return LDAP_INVALID_SYNTAX;\n\n\tswitch( tmp.bv_val[0] ) {\n\tcase 'a':\n\tcase 'A':\n\t\tif(( tmp.bv_len >= LENOF(\"any\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"any\", LENOF(\"any\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"any\");\n\t\t\ttmp.bv_val += LENOF(\"any\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tcase 'm':\n\tcase 'M':\n\t\tif(( tmp.bv_len >= LENOF(\"mhs\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"mhs\", LENOF(\"mhs\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"mhs\");\n\t\t\ttmp.bv_val += LENOF(\"mhs\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tcase 'p':\n\tcase 'P':\n\t\tif(( tmp.bv_len >= LENOF(\"physical\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"physical\", LENOF(\"physical\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"physical\");\n\t\t\ttmp.bv_val += LENOF(\"physical\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tcase 't':\n\tcase 'T': \/* telex or teletex or telephone *\/\n\t\tif(( tmp.bv_len >= LENOF(\"telex\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"telex\", LENOF(\"telex\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"telex\");\n\t\t\ttmp.bv_val += LENOF(\"telex\");\n\t\t\tbreak;\n\t\t}\n\t\tif(( tmp.bv_len >= LENOF(\"teletex\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"teletex\", LENOF(\"teletex\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"teletex\");\n\t\t\ttmp.bv_val += LENOF(\"teletex\");\n\t\t\tbreak;\n\t\t}\n\t\tif(( tmp.bv_len >= LENOF(\"telephone\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"telephone\", LENOF(\"telephone\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"telephone\");\n\t\t\ttmp.bv_val += LENOF(\"telephone\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tcase 'g':\n\tcase 'G': \/* g3fax or g4fax *\/\n\t\tif(( tmp.bv_len >= LENOF(\"g3fax\") ) && (\n\t\t\t( strncasecmp(tmp.bv_val, \"g3fax\", LENOF(\"g3fax\")) == 0 ) ||\n\t\t\t( strncasecmp(tmp.bv_val, \"g4fax\", LENOF(\"g4fax\")) == 0 )))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"g3fax\");\n\t\t\ttmp.bv_val += LENOF(\"g3fax\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tcase 'i':\n\tcase 'I':\n\t\tif(( tmp.bv_len >= LENOF(\"ia5\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"ia5\", LENOF(\"ia5\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"ia5\");\n\t\t\ttmp.bv_val += LENOF(\"ia5\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tcase 'v':\n\tcase 'V':\n\t\tif(( tmp.bv_len >= LENOF(\"videotex\") ) &&\n\t\t\t( strncasecmp(tmp.bv_val, \"videotex\", LENOF(\"videotex\")) == 0 ))\n\t\t{\n\t\t\ttmp.bv_len -= LENOF(\"videotex\");\n\t\t\ttmp.bv_val += LENOF(\"videotex\");\n\t\t\tbreak;\n\t\t}\n\t\treturn LDAP_INVALID_SYNTAX;\n\n\tdefault:\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif( BER_BVISEMPTY( &tmp ) ) return LDAP_SUCCESS;\n\n\twhile( !BER_BVISEMPTY( &tmp ) && ( tmp.bv_val[0] == ' ' ) ) {\n\t\ttmp.bv_len--;\n\t\ttmp.bv_val++;\n\t}\n\tif( !BER_BVISEMPTY( &tmp ) && ( tmp.bv_val[0] == '$' ) ) {\n\t\ttmp.bv_len--;\n\t\ttmp.bv_val++;\n\t} else {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\twhile( !BER_BVISEMPTY( &tmp ) && ( tmp.bv_val[0] == ' ' ) ) {\n\t\ttmp.bv_len--;\n\t\ttmp.bv_val++;\n\t}\n\n\tgoto again;\n}","target":0,"code_token_length":1148,"total_token_length":1384,"max_tokens_setting":2048}
+{"idx":220934,"func":"static void mpgviddmx_check_dur(GF_Filter *filter, GF_MPGVidDmxCtx *ctx)\n{\n\n\tFILE *stream;\n\tGF_BitStream *bs;\n\tGF_M4VParser *vparser;\n\tGF_M4VDecSpecInfo dsi;\n\tGF_Err e;\n\tu64 duration, cur_dur, rate;\n\tconst GF_PropertyValue *p;\n\tif (!ctx->opid || ctx->timescale || ctx->file_loaded) return;\n\n\tif (ctx->index<=0) {\n\t\tctx->file_loaded = GF_TRUE;\n\t\treturn;\n\t}\n\n\tp = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_FILEPATH);\n\tif (!p || !p->value.string || !strncmp(p->value.string, \"gmem:\/\/\", 7)) {\n\t\tctx->is_file = GF_FALSE;\n\t\tctx->file_loaded = GF_TRUE;\n\t\treturn;\n\t}\n\tctx->is_file = GF_TRUE;\n\n\tstream = gf_fopen(p->value.string, \"rb\");\n\tif (!stream) return;\n\n\tctx->index_size = 0;\n\n\tbs = gf_bs_from_file(stream, GF_BITSTREAM_READ);\n\n\tvparser = gf_m4v_parser_bs_new(bs, ctx->is_mpg12);\n\te = gf_m4v_parse_config(vparser, &dsi);\n\tif (e) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (\"[MPGVid] Could not parse video header - duration  not estimated\\n\"));\n\t\tctx->file_loaded = GF_TRUE;\n\t\treturn;\n\t}\n\n\tduration = 0;\n\tcur_dur = 0;\n\twhile (gf_bs_available(bs)) {\n\t\tu8 ftype;\n\t\tu32 tinc;\n\t\tu64 fsize, start;\n\t\tBool is_coded;\n\t\tu64 pos;\n\t\tpos = gf_m4v_get_object_start(vparser);\n\t\te = gf_m4v_parse_frame(vparser, &dsi, &ftype, &tinc, &fsize, &start, &is_coded);\n\t\tif (e<0) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (\"[MPGVid] Could not parse video frame\\n\"));\n\t\t\tcontinue;\n\t\t}\n\n\t\tduration += ctx->cur_fps.den;\n\t\tcur_dur += ctx->cur_fps.den;\n\t\t\/\/only index at I-frame start\n\t\tif (pos && (ftype==0) && (cur_dur >= ctx->index * ctx->cur_fps.num) ) {\n\t\t\tif (!ctx->index_alloc_size) ctx->index_alloc_size = 10;\n\t\t\telse if (ctx->index_alloc_size == ctx->index_size) ctx->index_alloc_size *= 2;\n\t\t\tctx->indexes = gf_realloc(ctx->indexes, sizeof(MPGVidIdx)*ctx->index_alloc_size);\n\t\t\tctx->indexes[ctx->index_size].pos = pos;\n\t\t\tctx->indexes[ctx->index_size].start_time = (Double) (duration-ctx->cur_fps.den);\n\t\t\tctx->indexes[ctx->index_size].start_time \/= ctx->cur_fps.num;\n\t\t\tctx->index_size ++;\n\t\t\tcur_dur = 0;\n\t\t}\n\t}\n\trate = gf_bs_get_position(bs);\n\tgf_m4v_parser_del(vparser);\n\tgf_fclose(stream);\n\n\tif (!ctx->duration.num || (ctx->duration.num  * ctx->cur_fps.num != duration * ctx->duration.den)) {\n\t\tctx->duration.num = (s32) duration;\n\t\tctx->duration.den = ctx->cur_fps.num;\n\n\t\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DURATION, & PROP_FRAC64(ctx->duration));\n\n\t\tif (duration && !gf_sys_is_test_mode() ) {\n\t\t\trate *= 8 * ctx->duration.den;\n\t\t\trate \/= ctx->duration.num;\n\t\t\tctx->bitrate = (u32) rate;\n\t\t}\n\t}\n\n\tp = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_FILE_CACHED);\n\tif (p && p->value.boolean) ctx->file_loaded = GF_TRUE;\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CAN_DATAREF, & PROP_BOOL(GF_TRUE ) );\n}","target":0,"code_token_length":888,"total_token_length":1124,"max_tokens_setting":2048}
+{"idx":224535,"func":"Status MaxPoolV2Shape(shape_inference::InferenceContext* c, int num_inputs) {\n  string data_format_str;\n  TensorFormat data_format;\n  Status s = c->GetAttr(\"data_format\", &data_format_str);\n  if (s.ok()) {\n    FormatFromString(data_format_str, &data_format);\n  } else {\n    data_format = FORMAT_NHWC;\n  }\n\n  const int rank = (data_format == FORMAT_NCHW_VECT_C) ? 5 : 4;\n  ShapeHandle input_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(0), rank, &input_shape));\n\n  TF_RETURN_IF_ERROR(\n      CheckFormatConstraintsOnShape(data_format, input_shape, \"input\", c));\n\n  std::vector<int32> kernel_sizes;\n  std::vector<int32> strides;\n\n  if (c->num_inputs() + 2 == num_inputs) {\n    TF_RETURN_IF_ERROR(c->GetAttr(\"ksize\", &kernel_sizes));\n\n    TF_RETURN_IF_ERROR(c->GetAttr(\"strides\", &strides));\n  } else {\n    \/\/ Verify shape of ksize and strides input.\n    ShapeHandle size;\n    DimensionHandle unused;\n    TF_RETURN_IF_ERROR(c->WithRank(c->input(c->num_inputs() - 2), 1, &size));\n    TF_RETURN_IF_ERROR(c->WithValue(c->Dim(size, 0), 4, &unused));\n    TF_RETURN_IF_ERROR(c->WithRank(c->input(c->num_inputs() - 1), 1, &size));\n    TF_RETURN_IF_ERROR(c->WithValue(c->Dim(size, 0), 4, &unused));\n\n    const Tensor* kernel_sizes_tensor = c->input_tensor(c->num_inputs() - 2);\n    if (kernel_sizes_tensor == nullptr) {\n      c->set_output(0, c->UnknownShape());\n      return Status::OK();\n    }\n    kernel_sizes.resize(kernel_sizes_tensor->shape().num_elements());\n    auto kernel_sizes_vec = kernel_sizes_tensor->flat<int32>();\n    std::copy_n(&kernel_sizes_vec(0), kernel_sizes.size(),\n                kernel_sizes.begin());\n\n    const Tensor* strides_tensor = c->input_tensor(c->num_inputs() - 1);\n    if (strides_tensor == nullptr) {\n      c->set_output(0, c->UnknownShape());\n      return Status::OK();\n    }\n    strides.resize(strides_tensor->shape().num_elements());\n    auto strides_vec = strides_tensor->flat<int32>();\n    std::copy_n(&strides_vec(0), strides.size(), strides.begin());\n  }\n\n  if (strides.size() != 4) {\n    return errors::InvalidArgument(\n        \"MaxPool requires the stride attribute to contain 4 values, but \"\n        \"got: \",\n        strides.size());\n  }\n  if (kernel_sizes.size() != 4) {\n    return errors::InvalidArgument(\n        \"MaxPool requires the ksize attribute to contain 4 values, but got: \",\n        kernel_sizes.size());\n  }\n\n  int32_t stride_depth = GetTensorDim(strides, data_format, 'C');\n  int32_t stride_rows = GetTensorDim(strides, data_format, 'H');\n  int32_t stride_cols = GetTensorDim(strides, data_format, 'W');\n  int32_t kernel_depth = GetTensorDim(kernel_sizes, data_format, 'C');\n  int32_t kernel_rows = GetTensorDim(kernel_sizes, data_format, 'H');\n  int32_t kernel_cols = GetTensorDim(kernel_sizes, data_format, 'W');\n\n  constexpr int num_spatial_dims = 2;\n  DimensionHandle batch_size_dim = c->Dim(\n      input_shape, GetTensorDimIndex<num_spatial_dims>(data_format, 'N'));\n  DimensionHandle in_rows_dim = c->Dim(\n      input_shape, GetTensorDimIndex<num_spatial_dims>(data_format, 'H'));\n  DimensionHandle in_cols_dim = c->Dim(\n      input_shape, GetTensorDimIndex<num_spatial_dims>(data_format, 'W'));\n  DimensionHandle in_depth_dim = c->Dim(\n      input_shape, GetTensorDimIndex<num_spatial_dims>(data_format, 'C'));\n\n  Padding padding;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"padding\", &padding));\n\n  ShapeHandle output_shape;\n  DimensionHandle output_rows, output_cols, output_depth;\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDims(\n      c, in_rows_dim, kernel_rows, stride_rows, padding, &output_rows));\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDims(\n      c, in_cols_dim, kernel_cols, stride_cols, padding, &output_cols));\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeFromDims(\n      c, in_depth_dim, kernel_depth, stride_depth, padding, &output_depth));\n\n  TF_RETURN_IF_ERROR(MakeShapeFromFormat(data_format, batch_size_dim,\n                                         {output_rows, output_cols},\n                                         output_depth, &output_shape, c));\n\n  c->set_output(0, output_shape);\n  return Status::OK();\n}","target":0,"code_token_length":1076,"total_token_length":1312,"max_tokens_setting":2048}
+{"idx":200287,"func":"static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct net *net = sock_net(sk);\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;\n\tlong timeout = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);\n\tstruct list_head *clinks = &tsk->cong_links;\n\tbool syn = !tipc_sk_type_connectionless(sk);\n\tstruct tipc_group *grp = tsk->group;\n\tstruct tipc_msg *hdr = &tsk->phdr;\n\tstruct tipc_socket_addr skaddr;\n\tstruct sk_buff_head pkts;\n\tint atype, mtu, rc;\n\n\tif (unlikely(dlen > TIPC_MAX_USER_MSG_SIZE))\n\t\treturn -EMSGSIZE;\n\n\tif (ua) {\n\t\tif (!tipc_uaddr_valid(ua, m->msg_namelen))\n\t\t\treturn -EINVAL;\n\t\tatype = ua->addrtype;\n\t}\n\n\t\/* If socket belongs to a communication group follow other paths *\/\n\tif (grp) {\n\t\tif (!ua)\n\t\t\treturn tipc_send_group_bcast(sock, m, dlen, timeout);\n\t\tif (atype == TIPC_SERVICE_ADDR)\n\t\t\treturn tipc_send_group_anycast(sock, m, dlen, timeout);\n\t\tif (atype == TIPC_SOCKET_ADDR)\n\t\t\treturn tipc_send_group_unicast(sock, m, dlen, timeout);\n\t\tif (atype == TIPC_SERVICE_RANGE)\n\t\t\treturn tipc_send_group_mcast(sock, m, dlen, timeout);\n\t\treturn -EINVAL;\n\t}\n\n\tif (!ua) {\n\t\tua = (struct tipc_uaddr *)&tsk->peer;\n\t\tif (!syn && ua->family != AF_TIPC)\n\t\t\treturn -EDESTADDRREQ;\n\t\tatype = ua->addrtype;\n\t}\n\n\tif (unlikely(syn)) {\n\t\tif (sk->sk_state == TIPC_LISTEN)\n\t\t\treturn -EPIPE;\n\t\tif (sk->sk_state != TIPC_OPEN)\n\t\t\treturn -EISCONN;\n\t\tif (tsk->published)\n\t\t\treturn -EOPNOTSUPP;\n\t\tif (atype == TIPC_SERVICE_ADDR)\n\t\t\ttsk->conn_addrtype = atype;\n\t\tmsg_set_syn(hdr, 1);\n\t}\n\n\t\/* Determine destination *\/\n\tif (atype == TIPC_SERVICE_RANGE) {\n\t\treturn tipc_sendmcast(sock, ua, m, dlen, timeout);\n\t} else if (atype == TIPC_SERVICE_ADDR) {\n\t\tskaddr.node = ua->lookup_node;\n\t\tua->scope = tipc_node2scope(skaddr.node);\n\t\tif (!tipc_nametbl_lookup_anycast(net, ua, &skaddr))\n\t\t\treturn -EHOSTUNREACH;\n\t} else if (atype == TIPC_SOCKET_ADDR) {\n\t\tskaddr = ua->sk;\n\t} else {\n\t\treturn -EINVAL;\n\t}\n\n\t\/* Block or return if destination link is congested *\/\n\trc = tipc_wait_for_cond(sock, &timeout,\n\t\t\t\t!tipc_dest_find(clinks, skaddr.node, 0));\n\tif (unlikely(rc))\n\t\treturn rc;\n\n\t\/* Finally build message header *\/\n\tmsg_set_destnode(hdr, skaddr.node);\n\tmsg_set_destport(hdr, skaddr.ref);\n\tif (atype == TIPC_SERVICE_ADDR) {\n\t\tmsg_set_type(hdr, TIPC_NAMED_MSG);\n\t\tmsg_set_hdr_sz(hdr, NAMED_H_SIZE);\n\t\tmsg_set_nametype(hdr, ua->sa.type);\n\t\tmsg_set_nameinst(hdr, ua->sa.instance);\n\t\tmsg_set_lookup_scope(hdr, ua->scope);\n\t} else { \/* TIPC_SOCKET_ADDR *\/\n\t\tmsg_set_type(hdr, TIPC_DIRECT_MSG);\n\t\tmsg_set_lookup_scope(hdr, 0);\n\t\tmsg_set_hdr_sz(hdr, BASIC_H_SIZE);\n\t}\n\n\t\/* Add message body *\/\n\t__skb_queue_head_init(&pkts);\n\tmtu = tipc_node_get_mtu(net, skaddr.node, tsk->portid, true);\n\trc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts);\n\tif (unlikely(rc != dlen))\n\t\treturn rc;\n\tif (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue))) {\n\t\t__skb_queue_purge(&pkts);\n\t\treturn -ENOMEM;\n\t}\n\n\t\/* Send message *\/\n\ttrace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, \" \");\n\trc = tipc_node_xmit(net, &pkts, skaddr.node, tsk->portid);\n\tif (unlikely(rc == -ELINKCONG)) {\n\t\ttipc_dest_push(clinks, skaddr.node, 0);\n\t\ttsk->cong_link_cnt++;\n\t\trc = 0;\n\t}\n\n\tif (unlikely(syn && !rc)) {\n\t\ttipc_set_sk_state(sk, TIPC_CONNECTING);\n\t\tif (dlen && timeout) {\n\t\t\ttimeout = msecs_to_jiffies(timeout);\n\t\t\ttipc_wait_for_connect(sock, &timeout);\n\t\t}\n\t}\n\n\treturn rc ? rc : dlen;\n}","target":1,"code_token_length":1114,"total_token_length":1350,"max_tokens_setting":2048}
+{"idx":195274,"func":"bool ConstantFolding::MulConvPushDown(GraphDef* optimized_graph, NodeDef* node,\n                                      const GraphProperties& properties) {\n  \/\/ Push down multiplication on ConvND.\n  \/\/                       *                  ConvND\n  \/\/                     \/   \\                \/    \\\n  \/\/                 ConvND  C2    -- >      X      *\n  \/\/                  \/ \\                          \/ \\\n  \/\/                 X  C1                       C1  C2\n  \/\/\n  \/\/ where C1 and C2 are constants and X is non-constant.\n  \/\/\n  \/\/ TODO(rmlarsen): Use PrepareConstantPushDown() to simplify this code.\n\n  if (!IsAnyMul(*node) || NumNonControlInputs(*node) != 2) return false;\n\n  NodeDef* mul_left_child = node_map_->GetNode(node->input(0));\n  NodeDef* mul_right_child = node_map_->GetNode(node->input(1));\n  \/\/ One child must be constant, and the second must be Conv op.\n  const bool left_child_is_constant = IsReallyConstant(*mul_left_child);\n  const bool right_child_is_constant = IsReallyConstant(*mul_right_child);\n  if (!left_child_is_constant && !right_child_is_constant) {\n    return false;\n  }\n  NodeDef* conv_node =\n      left_child_is_constant ? mul_right_child : mul_left_child;\n  if (!IsConv2D(*conv_node) && !IsConv3D(*conv_node)) {\n    return false;\n  }\n  if (node->device() != mul_left_child->device() ||\n      node->device() != mul_right_child->device()) {\n    return false;\n  }\n\n  \/\/ Make sure that it is safe to change the value of the convolution\n  \/\/ output.\n  if (conv_node->input_size() < 2 ||\n      NumNonControlOutputs(*conv_node, *node_map_) > 1 ||\n      nodes_to_preserve_.find(conv_node->name()) != nodes_to_preserve_.end()) {\n    return false;\n  }\n\n  \/\/ Identify the nodes to swap.\n  NodeDef* conv_left_child = node_map_->GetNode(conv_node->input(0));\n  NodeDef* conv_right_child = node_map_->GetNode(conv_node->input(1));\n  const bool conv_left_is_constant = IsReallyConstant(*conv_left_child);\n  const bool conv_right_is_constant = IsReallyConstant(*conv_right_child);\n  if (!conv_left_is_constant && !conv_right_is_constant) {\n    \/\/ At least one of the convolution inputs should be constant.\n    return false;\n  }\n  if (conv_left_is_constant && conv_right_is_constant) {\n    \/\/ Leverage regular constant folding to handle this.\n    return false;\n  }\n  const auto& mul_props = properties.GetOutputProperties(node->name());\n  const auto& conv_props = properties.GetOutputProperties(conv_node->name());\n  if (mul_props.empty() || conv_props.empty()) {\n    return false;\n  }\n  const auto& mul_shape = mul_props[0].shape();\n  const auto& conv_shape = conv_props[0].shape();\n  if (!ShapesSymbolicallyEqual(mul_shape, conv_shape)) {\n    return false;\n  }\n\n  const auto& input_props = properties.GetInputProperties(conv_node->name());\n  if (input_props.size() < 2) {\n    return false;\n  }\n  const auto& filter_shape = input_props[1].shape();\n\n  NodeDef* const_node =\n      left_child_is_constant ? mul_left_child : mul_right_child;\n  const auto& const_props = properties.GetOutputProperties(const_node->name());\n  if (const_props.empty()) {\n    return false;\n  }\n  const auto& const_shape = const_props[0].shape();\n  if (!IsValidConstShapeForMulConvPushDown(\n          conv_node->attr().at(\"data_format\").s(), filter_shape, const_shape)) {\n    return false;\n  }\n\n  string mul_new_name = AddPrefixToNodeName(\"merged_input\", conv_node->name());\n  if (node_map_->NodeExists(mul_new_name)) {\n    return false;\n  }\n  \/\/ Make sure we don't introduce loops in the graph by removing control\n  \/\/ dependencies from the conv2d node to c2.\n  string conv_const_input =\n      conv_left_is_constant ? conv_node->input(0) : conv_node->input(1);\n  if (MaybeRemoveControlInput(conv_node->name(), const_node, optimized_graph,\n                              node_map_.get())) {\n    \/\/ Add a control dep from c1 to c2 to ensure c2 is in the right frame\n    MaybeAddControlInput(conv_const_input, const_node, optimized_graph,\n                         node_map_.get());\n  }\n\n  conv_node->set_name(node->name());\n  node->set_name(mul_new_name);\n  if (conv_left_is_constant) {\n    node_map_->UpdateInput(conv_node->name(), node->input(0), mul_new_name);\n    conv_node->set_input(0, mul_new_name);\n  } else {\n    node_map_->UpdateInput(conv_node->name(), node->input(1), mul_new_name);\n    conv_node->set_input(1, mul_new_name);\n  }\n  NodeDef* conv_const_node =\n      conv_left_is_constant ? conv_left_child : conv_right_child;\n  if (left_child_is_constant) {\n    node->set_input(1, conv_const_node->name());\n  } else {\n    node->set_input(0, conv_const_node->name());\n  }\n  node_map_->AddNode(mul_new_name, node);\n\n  return true;\n}","target":1,"code_token_length":1170,"total_token_length":1406,"max_tokens_setting":2048}
+{"idx":194994,"func":"Status ImmutableExecutorState::Initialize(const Graph& graph) {\n  TF_RETURN_IF_ERROR(gview_.Initialize(&graph));\n\n  \/\/ Build the information about frames in this subgraph.\n  ControlFlowInfo cf_info;\n  TF_RETURN_IF_ERROR(BuildControlFlowInfo(&graph, &cf_info));\n\n  for (auto& it : cf_info.unique_frame_names) {\n    EnsureFrameInfo(it)->nodes =\n        absl::make_unique<std::vector<const NodeItem*>>();\n  }\n  root_frame_info_ = frame_info_[\"\"].get();\n\n  pending_ids_.resize(gview_.num_nodes());\n\n  \/\/ Preprocess every node in the graph to create an instance of op\n  \/\/ kernel for each node.\n  requires_control_flow_ = false;\n  for (const Node* n : graph.nodes()) {\n    if (IsSink(n)) continue;\n    if (IsSwitch(n) || IsMerge(n) || IsEnter(n) || IsExit(n)) {\n      requires_control_flow_ = true;\n    } else if (IsRecv(n)) {\n      \/\/ A Recv node from a different device may produce dead tensors from\n      \/\/ non-local control-flow nodes.\n      \/\/\n      \/\/ TODO(mrry): Track whether control flow was present in the\n      \/\/ pre-partitioned graph, and enable the caller (e.g.\n      \/\/ `DirectSession`) to relax this constraint.\n      string send_device;\n      string recv_device;\n      TF_RETURN_IF_ERROR(GetNodeAttr(n->attrs(), \"send_device\", &send_device));\n      TF_RETURN_IF_ERROR(GetNodeAttr(n->attrs(), \"recv_device\", &recv_device));\n      if (send_device != recv_device) {\n        requires_control_flow_ = true;\n      }\n    }\n\n    const int id = n->id();\n    const string& frame_name = cf_info.frame_names[id];\n    FrameInfo* frame_info = EnsureFrameInfo(frame_name);\n\n    NodeItem* item = gview_.node(id);\n    item->node_id = id;\n\n    item->input_start = frame_info->total_inputs;\n    frame_info->total_inputs += n->num_inputs();\n\n    Status s = params_.create_kernel(n->properties(), &item->kernel);\n    if (!s.ok()) {\n      item->kernel = nullptr;\n      s = AttachDef(s, *n);\n      return s;\n    }\n    CHECK(item->kernel);\n    item->kernel_is_async = (item->kernel->AsAsync() != nullptr);\n    item->is_merge = IsMerge(n);\n    item->is_any_consumer_merge_or_control_trigger = false;\n    for (const Node* consumer : n->out_nodes()) {\n      if (IsMerge(consumer) || IsControlTrigger(consumer)) {\n        item->is_any_consumer_merge_or_control_trigger = true;\n        break;\n      }\n    }\n    const Tensor* const_tensor = item->kernel->const_tensor();\n    if (const_tensor) {\n      \/\/ Hold onto a shallow copy of the constant tensor in `*this` so that the\n      \/\/ reference count does not drop to 1. This prevents the constant tensor\n      \/\/ from being forwarded, and its buffer reused.\n      const_tensors_.emplace_back(*const_tensor);\n    }\n    item->const_tensor = const_tensor;\n    item->is_noop = (item->kernel->type_string_view() == \"NoOp\");\n    item->is_enter = IsEnter(n);\n    if (item->is_enter) {\n      bool is_constant_enter;\n      TF_RETURN_IF_ERROR(\n          GetNodeAttr(n->attrs(), \"is_constant\", &is_constant_enter));\n      item->is_constant_enter = is_constant_enter;\n\n      string frame_name;\n      TF_RETURN_IF_ERROR(GetNodeAttr(n->attrs(), \"frame_name\", &frame_name));\n      FrameInfo* frame_info = frame_info_[frame_name].get();\n\n      int parallel_iterations;\n      TF_RETURN_IF_ERROR(\n          GetNodeAttr(n->attrs(), \"parallel_iterations\", ¶llel_iterations));\n\n      if (frame_info->parallel_iterations == -1) {\n        frame_info->parallel_iterations = parallel_iterations;\n      } else if (frame_info->parallel_iterations != parallel_iterations) {\n        LOG(WARNING) << \"Loop frame \\\"\" << frame_name\n                     << \"\\\" had two different values for parallel_iterations: \"\n                     << frame_info->parallel_iterations << \" vs. \"\n                     << parallel_iterations << \".\";\n      }\n\n      if (enter_frame_info_.size() <= id) {\n        enter_frame_info_.resize(id + 1);\n      }\n      enter_frame_info_[id] = frame_info;\n    } else {\n      item->is_constant_enter = false;\n    }\n    item->is_exit = IsExit(n);\n    item->is_control_trigger = IsControlTrigger(n);\n    item->is_source = IsSource(n);\n    item->is_enter_exit_or_next_iter =\n        (IsEnter(n) || IsExit(n) || IsNextIteration(n));\n    item->is_transfer_node = IsTransferNode(n);\n    item->is_initialization_op = IsInitializationOp(n);\n    item->is_recv_or_switch = IsRecv(n) || IsSwitch(n);\n    item->is_next_iteration = IsNextIteration(n);\n    item->is_distributed_communication = IsDistributedCommunication(n);\n\n    \/\/ Compute the maximum values we'll store for this node in the\n    \/\/ pending counts data structure, and allocate a handle in\n    \/\/ that frame's pending counts data structure that has enough\n    \/\/ space to store these maximal count values.\n    size_t max_pending, max_dead;\n    GetMaxPendingCounts(n, &max_pending, &max_dead);\n    pending_ids_[id] =\n        frame_info->pending_counts_layout.CreateHandle(max_pending, max_dead);\n\n    \/\/ See if this node is a root node, and if so, add item to root_nodes_.\n    if (n->in_edges().empty()) {\n      root_nodes_.push_back(item);\n    }\n\n    \/\/ Initialize static information about the frames in the graph.\n    frame_info->nodes->push_back(item);\n    if (item->is_enter) {\n      string enter_name;\n      TF_RETURN_IF_ERROR(GetNodeAttr(n->attrs(), \"frame_name\", &enter_name));\n      EnsureFrameInfo(enter_name)->input_count++;\n    }\n\n    \/\/ Record information about whether each output of the op is used.\n    std::unique_ptr<bool[]> outputs_required(new bool[n->num_outputs()]);\n    std::fill(&outputs_required[0], &outputs_required[n->num_outputs()], false);\n    int32_t unused_outputs = n->num_outputs();\n    for (const Edge* e : n->out_edges()) {\n      if (IsSink(e->dst())) continue;\n      if (e->src_output() >= 0) {\n        if (!outputs_required[e->src_output()]) {\n          --unused_outputs;\n          outputs_required[e->src_output()] = true;\n        }\n      }\n    }\n    if (unused_outputs > 0) {\n      for (int i = 0; i < n->num_outputs(); ++i) {\n        if (!outputs_required[i]) {\n          metrics::RecordUnusedOutput(n->type_string());\n        }\n      }\n      item->outputs_required = std::move(outputs_required);\n    }\n  }\n\n  \/\/ Rewrite each `EdgeInfo::input_slot` member to refer directly to the input\n  \/\/ location.\n  for (const Node* n : graph.nodes()) {\n    if (IsSink(n)) continue;\n    const int id = n->id();\n    NodeItem* item = gview_.node(id);\n\n    for (EdgeInfo& e : item->mutable_output_edges()) {\n      const int dst_id = e.dst_id;\n      NodeItem* dst_item = gview_.node(dst_id);\n      e.input_slot += dst_item->input_start;\n    }\n  }\n\n  \/\/ Initialize PendingCounts only after pending_ids_[node.id] is initialized\n  \/\/ for all nodes.\n  InitializePending(&graph, cf_info);\n  return gview_.SetAllocAttrs(&graph, params_.device);\n}","target":1,"code_token_length":1657,"total_token_length":1893,"max_tokens_setting":2048}
+{"idx":517455,"func":"static void do_head(HttpResponse res, const char *path, const char *name, int refresh) {\n        StringBuffer_append(res->outputbuffer,\n                            \"<!DOCTYPE html>\"\\\n                            \"<html>\"\\\n                            \"<head>\"\\\n                            \"<title>Monit: %s<\/title> \"\\\n                            \"<style type=\\\"text\/css\\\"> \"\\\n                            \" html, body {height: 100%%;margin: 0;} \"\\\n                            \" body {background-color: white;font: normal normal normal 16px\/20px 'HelveticaNeue', Helvetica, Arial, sans-serif; color:#222;} \"\\\n                            \" h1 {padding:30px 0 10px 0; text-align:center;color:#222;font-size:28px;} \"\\\n                            \" h2 {padding:20px 0 10px 0; text-align:center;color:#555;font-size:22px;} \"\\\n                            \" a:hover {text-decoration: none;} \"\\\n                            \" a {text-decoration: underline;color:#222} \"\\\n                            \" table {border-collapse:collapse; border:0;} \"\\\n                            \" .stripe {background:#EDF5FF} \"\\\n                            \" .rule {background:#ddd} \"\\\n                            \" .red-text {color:#ff0000;} \"\\\n                            \" .green-text {color:#00ff00;} \"\\\n                            \" .gray-text {color:#999999;} \"\\\n                            \" .blue-text {color:#0000ff;} \"\\\n                            \" .yellow-text {color:#ffff00;} \"\\\n                            \" .orange-text {color:#ff8800;} \"\\\n                            \" .short {overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 350px;}\"\\\n                            \" .column {min-width: 80px;} \"\\\n                            \" .left {text-align:left} \"\\\n                            \" .right {text-align:right} \"\\\n                            \" .center {text-align:center} \"\\\n                            \" #wrap {min-height: 100%%;} \"\\\n                            \" #main {overflow:auto; padding-bottom:50px;} \"\\\n                            \" \/*Opera Fix*\/body:before {content:\\\"\\\";height:100%%;float:left;width:0;margin-top:-32767px;} \"\\\n                            \" #footer {position: relative;margin-top: -50px; height: 50px; clear:both; font-size:11px;color:#777;text-align:center;} \"\\\n                            \" #footer a {color:#333;} #footer a:hover {text-decoration: none;} \"\\\n                            \" #nav {background:#ddd;font:normal normal normal 14px\/0px 'HelveticaNeue', Helvetica;} \"\\\n                            \" #nav td {padding:5px 10px;} \"\\\n                            \" #header {margin-bottom:30px;background:#EFF7FF} \"\\\n                            \" #nav, #header {border-bottom:1px solid #ccc;} \"\\\n                            \" #header-row {width:95%%;} \"\\\n                            \" #header-row th {padding:30px 10px 10px 10px;font-size:120%%;} \"\\\n                            \" #header-row td {padding:3px 10px;} \"\\\n                            \" #header-row .first {min-width:200px;width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} \"\\\n                            \" #status-table {width:95%%;} \"\\\n                            \" #status-table th {text-align:left;background:#edf5ff;font-weight:normal;} \"\\\n                            \" #status-table th, #status-table td, #status-table tr {border:1px solid #ccc;padding:5px;} \"\\\n                            \" #buttons {font-size:20px; margin:40px 0 20px 0;} \"\\\n                            \" #buttons td {padding-right:50px;} \"\\\n                            \" #buttons input {font-size:18px;padding:5px;} \"\\\n                            \"<\/style>\"\\\n                            \"<meta HTTP-EQUIV='REFRESH' CONTENT=%d> \"\\\n                            \"<meta HTTP-EQUIV='Expires' Content=0> \"\\\n                            \"<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'> \"\\\n                            \"<meta charset='UTF-8'>\" \\\n                            \"<link rel='shortcut icon' href='favicon.ico'>\"\\\n                            \"<\/head>\"\\\n                            \"<body><div id='wrap'><div id='main'>\" \\\n                            \"<table id='nav' width='100%%'>\"\\\n                            \"  <tr>\"\\\n                            \"    <td width='20%%'><a href='.'>Home<\/a> > <a href='%s'>%s<\/a><\/td>\"\\\n                            \"    <td width='60%%' style='text-align:center;'>Use <a href='https:\/\/mmonit.com\/'>M\/Monit<\/a> to manage all your Monit instances<\/td>\"\\\n                            \"    <td width='20%%'><p class='right'><a href='_about'>Monit %s<\/a><\/td>\"\\\n                            \"  <\/tr>\"\\\n                            \"<\/table>\"\\\n                            \"<center>\",\n                            Run.system->name, refresh, path, name, VERSION);\n}","target":0,"code_token_length":1127,"total_token_length":1363,"max_tokens_setting":2048}
+{"idx":238391,"func":"njs_function_constructor(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t async)\n{\n    njs_chb_t               chain;\n    njs_int_t               ret;\n    njs_str_t               str, file;\n    njs_uint_t              i;\n    njs_lexer_t             lexer;\n    njs_parser_t            parser;\n    njs_vm_code_t           *code;\n    njs_function_t          *function;\n    njs_generator_t         generator;\n    njs_parser_node_t       *node;\n    njs_parser_scope_t      *scope;\n    njs_function_lambda_t   *lambda;\n    const njs_token_type_t  *type;\n\n    static const njs_token_type_t  safe_ast[] = {\n        NJS_TOKEN_END,\n        NJS_TOKEN_FUNCTION_EXPRESSION,\n        NJS_TOKEN_STATEMENT,\n        NJS_TOKEN_RETURN,\n        NJS_TOKEN_THIS,\n        NJS_TOKEN_ILLEGAL\n    };\n\n    static const njs_token_type_t  safe_ast_async[] = {\n        NJS_TOKEN_END,\n        NJS_TOKEN_ASYNC_FUNCTION_EXPRESSION,\n        NJS_TOKEN_STATEMENT,\n        NJS_TOKEN_RETURN,\n        NJS_TOKEN_THIS,\n        NJS_TOKEN_ILLEGAL\n    };\n\n    if (!vm->options.unsafe && nargs != 2) {\n        goto fail;\n    }\n\n    njs_chb_init(&chain, vm->mem_pool);\n\n    if (async) {\n        njs_chb_append_literal(&chain, \"(async function(\");\n\n    } else {\n        njs_chb_append_literal(&chain, \"(function(\");\n    }\n\n    for (i = 1; i < nargs - 1; i++) {\n        ret = njs_value_to_chain(vm, &chain, njs_argument(args, i));\n        if (njs_slow_path(ret < NJS_OK)) {\n            return ret;\n        }\n\n        if (i != (nargs - 2)) {\n            njs_chb_append_literal(&chain, \",\");\n        }\n    }\n\n    njs_chb_append_literal(&chain, \"){\");\n\n    ret = njs_value_to_chain(vm, &chain, njs_argument(args, nargs - 1));\n    if (njs_slow_path(ret < NJS_OK)) {\n        return ret;\n    }\n\n    njs_chb_append_literal(&chain, \"})\");\n\n    ret = njs_chb_join(&chain, &str);\n    if (njs_slow_path(ret != NJS_OK)) {\n        njs_memory_error(vm);\n        return NJS_ERROR;\n    }\n\n    file = njs_str_value(\"runtime\");\n\n    ret = njs_lexer_init(vm, &lexer, &file, str.start, str.start + str.length,\n                         1);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    njs_memzero(&parser, sizeof(njs_parser_t));\n\n    parser.lexer = &lexer;\n\n    ret = njs_parser(vm, &parser);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (!vm->options.unsafe) {\n        \/*\n         * Safe mode exception:\n         * \"(new Function('return this'))\" is often used to get\n         * the global object in a portable way.\n         *\/\n\n        node = parser.node;\n        type = (async) ? &safe_ast_async[0] : &safe_ast[0];\n\n        for (; *type != NJS_TOKEN_ILLEGAL; type++, node = node->right) {\n            if (node == NULL) {\n                goto fail;\n            }\n\n            if (node->left != NULL\n                && node->token_type != NJS_TOKEN_FUNCTION_EXPRESSION\n                && node->left->token_type != NJS_TOKEN_NAME)\n            {\n                goto fail;\n            }\n\n            if (node->token_type != *type) {\n                goto fail;\n            }\n        }\n    }\n\n    scope = parser.scope;\n\n    ret = njs_variables_copy(vm, &scope->variables, vm->variables_hash);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_generator_init(&generator, 0, 1);\n    if (njs_slow_path(ret != NJS_OK)) {\n        njs_internal_error(vm, \"njs_generator_init() failed\");\n        return NJS_ERROR;\n    }\n\n    code = njs_generate_scope(vm, &generator, scope, &njs_entry_anonymous);\n    if (njs_slow_path(code == NULL)) {\n        if (!njs_is_error(&vm->retval)) {\n            njs_internal_error(vm, \"njs_generate_scope() failed\");\n        }\n\n        return NJS_ERROR;\n    }\n\n    njs_chb_destroy(&chain);\n\n    lambda = ((njs_vmcode_function_t *) generator.code_start)->lambda;\n\n    function = njs_function_alloc(vm, lambda, (njs_bool_t) async);\n    if (njs_slow_path(function == NULL)) {\n        return NJS_ERROR;\n    }\n\n    function->global = 1;\n    function->global_this = 1;\n    function->args_count = lambda->nargs - lambda->rest_parameters;\n\n    njs_set_function(&vm->retval, function);\n\n    return NJS_OK;\n\nfail:\n\n    njs_type_error(vm, \"function constructor is disabled in \\\"safe\\\" mode\");\n    return NJS_ERROR;\n}","target":0,"code_token_length":1136,"total_token_length":1372,"max_tokens_setting":2048}
+{"idx":455412,"func":"xfs_reclaim_inode(\n\tstruct xfs_inode\t*ip,\n\tstruct xfs_perag\t*pag,\n\tint\t\t\tsync_mode)\n{\n\tstruct xfs_buf\t\t*bp = NULL;\n\txfs_ino_t\t\tino = ip->i_ino; \/* for radix_tree_delete *\/\n\tint\t\t\terror;\n\nrestart:\n\terror = 0;\n\txfs_ilock(ip, XFS_ILOCK_EXCL);\n\tif (!xfs_iflock_nowait(ip)) {\n\t\tif (!(sync_mode & SYNC_WAIT))\n\t\t\tgoto out;\n\t\txfs_iflock(ip);\n\t}\n\n\tif (XFS_FORCED_SHUTDOWN(ip->i_mount)) {\n\t\txfs_iunpin_wait(ip);\n\t\t\/* xfs_iflush_abort() drops the flush lock *\/\n\t\txfs_iflush_abort(ip, false);\n\t\tgoto reclaim;\n\t}\n\tif (xfs_ipincount(ip)) {\n\t\tif (!(sync_mode & SYNC_WAIT))\n\t\t\tgoto out_ifunlock;\n\t\txfs_iunpin_wait(ip);\n\t}\n\tif (xfs_iflags_test(ip, XFS_ISTALE) || xfs_inode_clean(ip)) {\n\t\txfs_ifunlock(ip);\n\t\tgoto reclaim;\n\t}\n\n\t\/*\n\t * Never flush out dirty data during non-blocking reclaim, as it would\n\t * just contend with AIL pushing trying to do the same job.\n\t *\/\n\tif (!(sync_mode & SYNC_WAIT))\n\t\tgoto out_ifunlock;\n\n\t\/*\n\t * Now we have an inode that needs flushing.\n\t *\n\t * Note that xfs_iflush will never block on the inode buffer lock, as\n\t * xfs_ifree_cluster() can lock the inode buffer before it locks the\n\t * ip->i_lock, and we are doing the exact opposite here.  As a result,\n\t * doing a blocking xfs_imap_to_bp() to get the cluster buffer would\n\t * result in an ABBA deadlock with xfs_ifree_cluster().\n\t *\n\t * As xfs_ifree_cluser() must gather all inodes that are active in the\n\t * cache to mark them stale, if we hit this case we don't actually want\n\t * to do IO here - we want the inode marked stale so we can simply\n\t * reclaim it.  Hence if we get an EAGAIN error here,  just unlock the\n\t * inode, back off and try again.  Hopefully the next pass through will\n\t * see the stale flag set on the inode.\n\t *\/\n\terror = xfs_iflush(ip, &bp);\n\tif (error == -EAGAIN) {\n\t\txfs_iunlock(ip, XFS_ILOCK_EXCL);\n\t\t\/* backoff longer than in xfs_ifree_cluster *\/\n\t\tdelay(2);\n\t\tgoto restart;\n\t}\n\n\tif (!error) {\n\t\terror = xfs_bwrite(bp);\n\t\txfs_buf_relse(bp);\n\t}\n\nreclaim:\n\tASSERT(!xfs_isiflocked(ip));\n\n\t\/*\n\t * Because we use RCU freeing we need to ensure the inode always appears\n\t * to be reclaimed with an invalid inode number when in the free state.\n\t * We do this as early as possible under the ILOCK so that\n\t * xfs_iflush_cluster() and xfs_ifree_cluster() can be guaranteed to\n\t * detect races with us here. By doing this, we guarantee that once\n\t * xfs_iflush_cluster() or xfs_ifree_cluster() has locked XFS_ILOCK that\n\t * it will see either a valid inode that will serialise correctly, or it\n\t * will see an invalid inode that it can skip.\n\t *\/\n\tspin_lock(&ip->i_flags_lock);\n\tip->i_flags = XFS_IRECLAIM;\n\tip->i_ino = 0;\n\tspin_unlock(&ip->i_flags_lock);\n\n\txfs_iunlock(ip, XFS_ILOCK_EXCL);\n\n\tXFS_STATS_INC(ip->i_mount, xs_ig_reclaims);\n\t\/*\n\t * Remove the inode from the per-AG radix tree.\n\t *\n\t * Because radix_tree_delete won't complain even if the item was never\n\t * added to the tree assert that it's been there before to catch\n\t * problems with the inode life time early on.\n\t *\/\n\tspin_lock(&pag->pag_ici_lock);\n\tif (!radix_tree_delete(&pag->pag_ici_root,\n\t\t\t\tXFS_INO_TO_AGINO(ip->i_mount, ino)))\n\t\tASSERT(0);\n\txfs_perag_clear_reclaim_tag(pag);\n\tspin_unlock(&pag->pag_ici_lock);\n\n\t\/*\n\t * Here we do an (almost) spurious inode lock in order to coordinate\n\t * with inode cache radix tree lookups.  This is because the lookup\n\t * can reference the inodes in the cache without taking references.\n\t *\n\t * We make that OK here by ensuring that we wait until the inode is\n\t * unlocked after the lookup before we go ahead and free it.\n\t *\/\n\txfs_ilock(ip, XFS_ILOCK_EXCL);\n\txfs_qm_dqdetach(ip);\n\txfs_iunlock(ip, XFS_ILOCK_EXCL);\n\n\t__xfs_inode_free(ip);\n\treturn error;\n\nout_ifunlock:\n\txfs_ifunlock(ip);\nout:\n\txfs_iflags_clear(ip, XFS_IRECLAIM);\n\txfs_iunlock(ip, XFS_ILOCK_EXCL);\n\t\/*\n\t * We could return -EAGAIN here to make reclaim rescan the inode tree in\n\t * a short while. However, this just burns CPU time scanning the tree\n\t * waiting for IO to complete and the reclaim work never goes back to\n\t * the idle state. Instead, return 0 to let the next scheduled\n\t * background reclaim attempt to reclaim the inode again.\n\t *\/\n\treturn 0;\n}","target":0,"code_token_length":1204,"total_token_length":1440,"max_tokens_setting":2048}
+{"idx":222515,"func":"  Status InstantiateNode(const NodeDef& fnode, AttrSlice attrs) {\n    const OpDef* fnode_sig = nullptr;\n    TF_CHECK_OK(get_function_(fnode.op(), &fnode_sig));\n    NodeDef* gnode = AddNode(fnode.name());\n    gnode->set_op(fnode.op());\n    gnode->set_device(fnode.device());\n    int gnode_idx = nodes_.size() - 1;\n\n    \/\/ Input\n    const int num_args = fnode_sig->input_arg_size();\n    bool is_type_list;  \/\/ ignored\n    DataTypeVector dtypes;\n    int fnode_arg_index = 0;\n    for (int i = 0; i < num_args; ++i) {\n      TF_RETURN_IF_ERROR(\n          ArgNumType(attrs, fnode_sig->input_arg(i), &is_type_list, &dtypes));\n      \/\/ Consume inputs (indexed by fnode_arg_index) until we have\n      \/\/ matched each element of dtypes (indexed by j).\n      for (size_t j = 0; j < dtypes.size(); ++fnode_arg_index) {\n        if (fnode_arg_index >= fnode.input_size()) {\n          \/\/ Should never happen if we computed dtypes correctly.\n          return errors::InvalidArgument(\n              \"Attempt to access beyond input size: \", fnode_arg_index,\n              \" >= \", fnode.input_size());\n        }\n        \/\/ Look up the next input.\n        const string& input_name = fnode.input(fnode_arg_index);\n        const auto* item = GetItemOrNull(input_name);\n        if (item == nullptr) {\n          return errors::InvalidArgument(\n              \"input \", input_name,\n              \" is not found: \", FormatNodeDefForError(fnode));\n        }\n        if (item->dtypes.size() > dtypes.size() - j) {\n          return errors::InvalidArgument(\"Input \", input_name, \" too long for \",\n                                         fnode_sig->input_arg(i).name());\n        }\n        \/\/ Match up all the elements of this input (indexed by k) with\n        \/\/ elements of dtypes (advancing j).\n        for (int k = 0; k < item->dtypes.size(); ++k, ++j) {\n          if (item->dtypes[k] != dtypes[j]) {\n            return errors::InvalidArgument(\n                \"input \", fnode_sig->input_arg(i).name(), \"[\", j,\n                \"] expected type \", DataTypeString(dtypes[j]),\n                \" != \", DataTypeString(item->dtypes[k]), \", the type of \",\n                input_name, \"[\", k, \"]\");\n          }\n          if (item->is_func_arg) {\n            AddInput(gnode_idx, item->nid + k, 0);\n          } else {\n            AddInput(gnode_idx, item->nid, item->idx + k);\n          }\n        }\n      }\n    }\n\n    \/\/ Control deps.\n    for (int i = fnode_arg_index; i < fnode.input_size(); ++i) {\n      const string& input = fnode.input(i);\n      if (input.empty() || input[0] != '^') {\n        return errors::InvalidArgument(\"Expected input[\", i, \"] == '\", input,\n                                       \"' to be a control input.\");\n      }\n      int nid = -1;\n      const string node_name = input.substr(1);\n      const string node_colon = node_name + \":\";\n      const string node_colon_bound = node_name + \";\";\n      \/\/ index_ is a map sorted lexicographically, so the key we are looking for\n      \/\/ must lie in the range [node_name, node_colon_bound).\n      auto it = index_.lower_bound(node_name);\n      while (it != index_.end() && it->first <= node_colon_bound) {\n        if (it->first == node_name || absl::StartsWith(it->first, node_colon)) {\n          nid = it->second.nid;\n          break;\n        }\n        ++it;\n      }\n      if (nid == -1) {\n        return errors::InvalidArgument(\"input[\", i, \"] == '\", input,\n                                       \"', is not found.\");\n      }\n      AddDep(gnode_idx, nid);\n    }\n\n    \/\/ Attrs.\n    for (const auto& p : attrs) {\n      (*gnode->mutable_attr())[p.first] = p.second;\n    }\n\n    \/\/ Experimental_debug_info.\n    if (fnode.has_experimental_debug_info()) {\n      gnode->mutable_experimental_debug_info()->MergeFrom(\n          fnode.experimental_debug_info());\n    }\n\n    \/\/ Tye info.\n    \/\/ TODO(mdan): Might this need adjustment at instantiation?\n    if (fnode.has_experimental_type()) {\n      *gnode->mutable_experimental_type() = fnode.experimental_type();\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":1009,"total_token_length":1245,"max_tokens_setting":2048}
+{"idx":233823,"func":"void fmtutil_read_atari_palette(deark *c, dbuf *f, i64 pos,\n\tde_color *dstpal, i64 ncolors_to_read, i64 ncolors_used, unsigned int flags)\n{\n\ti64 i;\n\tunsigned int n;\n\tint pal_bits = 0; \/\/ 9, 12, or 15. 0 = not yet determined\n\tu8 cr, cg, cb;\n\tu8 cr1, cg1, cb1;\n\tchar cbuf[32];\n\tchar tmps[64];\n\tconst char *s;\n\n\ts = de_get_ext_option(c, \"atari:palbits\");\n\tif(s) {\n\t\tpal_bits = de_atoi(s);\n\t}\n\n\tif(pal_bits==0 && (flags&DE_FLAG_ATARI_15BIT_PAL)) {\n\t\tpal_bits = 15;\n\t}\n\n\tif(pal_bits==0) {\n\t\t\/\/ Pre-scan the palette, and try to guess whether Atari STE-style 12-bit\n\t\t\/\/ colors are used, instead of the usual 9-bit colors.\n\t\t\/\/ I don't know the best way to do this. Sometimes the 4th bit in each\n\t\t\/\/ nibble is used for extra color detail, and sometimes it just seems to\n\t\t\/\/ contain garbage. Maybe the logic should also depend on the file\n\t\t\/\/ format, or the number of colors.\n\t\tint bit_3_used = 0;\n\t\tint nibble_3_used = 0;\n\n\t\tfor(i=0; i<ncolors_to_read; i++) {\n\t\t\tn = (unsigned int)dbuf_getu16be(f, pos + i*2);\n\t\t\tif(n&0xf000) {\n\t\t\t\tnibble_3_used = 1;\n\t\t\t}\n\t\t\tif(n&0x0888) {\n\t\t\t\tbit_3_used = 1;\n\t\t\t}\n\t\t}\n\n\t\tif(bit_3_used && !nibble_3_used) {\n\t\t\tde_dbg(c, \"12-bit palette colors detected\");\n\t\t\tpal_bits = 12;\n\t\t}\n\t}\n\n\tif(pal_bits<12) { \/\/ Default to 9 if <12\n\t\tpal_bits = 9;\n\t}\n\telse if(pal_bits<15) {\n\t\tpal_bits = 12;\n\t}\n\telse {\n\t\tpal_bits = 15;\n\t}\n\n\tfor(i=0; i<ncolors_to_read; i++) {\n\t\tn = (unsigned int)dbuf_getu16be(f, pos + 2*i);\n\n\t\tif(pal_bits==15) {\n\t\t\tcr1 = (u8)((n>>6)&0x1c);\n\t\t\tif(n&0x0800) cr1+=2;\n\t\t\tif(n&0x8000) cr1++;\n\t\t\tcg1 = (u8)((n>>2)&0x1c);\n\t\t\tif(n&0x0080) cg1+=2;\n\t\t\tif(n&0x4000) cg1++;\n\t\t\tcb1 = (u8)((n<<2)&0x1c);\n\t\t\tif(n&0x0008) cb1+=2;\n\t\t\tif(n&0x2000) cb1++;\n\t\t\tcr = de_scale_n_to_255(31, cr1);\n\t\t\tcg = de_scale_n_to_255(31, cg1);\n\t\t\tcb = de_scale_n_to_255(31, cb1);\n\t\t\tde_snprintf(cbuf, sizeof(cbuf), \"%2d,%2d,%2d\",\n\t\t\t\t(int)cr1, (int)cg1, (int)cb1);\n\t\t}\n\t\telse if(pal_bits==12) {\n\t\t\tcr1 = (u8)((n>>7)&0x0e);\n\t\t\tif(n&0x800) cr1++;\n\t\t\tcg1 = (u8)((n>>3)&0x0e);\n\t\t\tif(n&0x080) cg1++;\n\t\t\tcb1 = (u8)((n<<1)&0x0e);\n\t\t\tif(n&0x008) cb1++;\n\t\t\tcr = scale_15_to_255(cr1);\n\t\t\tcg = scale_15_to_255(cg1);\n\t\t\tcb = scale_15_to_255(cb1);\n\t\t\tde_snprintf(cbuf, sizeof(cbuf), \"%2d,%2d,%2d\",\n\t\t\t\t(int)cr1, (int)cg1, (int)cb1);\n\t\t}\n\t\telse {\n\t\t\tcr1 = (u8)((n>>8)&0x07);\n\t\t\tcg1 = (u8)((n>>4)&0x07);\n\t\t\tcb1 = (u8)(n&0x07);\n\t\t\tcr = scale_7_to_255(cr1);\n\t\t\tcg = scale_7_to_255(cg1);\n\t\t\tcb = scale_7_to_255(cb1);\n\t\t\tde_snprintf(cbuf, sizeof(cbuf), \"%d,%d,%d\",\n\t\t\t\t(int)cr1, (int)cg1, (int)cb1);\n\t\t}\n\n\t\tdstpal[i] = DE_MAKE_RGB(cr, cg, cb);\n\t\tde_snprintf(tmps, sizeof(tmps), \"0x%04x (%s) \"DE_CHAR_RIGHTARROW\" \", n, cbuf);\n\t\tde_dbg_pal_entry2(c, i, dstpal[i], tmps, NULL,\n\t\t\t(i>=ncolors_used)?\" [unused]\":\"\");\n\t}\n}","target":0,"code_token_length":1218,"total_token_length":1454,"max_tokens_setting":2048}
+{"idx":254735,"func":"njs_typed_array_prototype_set(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    double              num;\n    int64_t             i, length, src_length, offset;\n    njs_int_t           ret;\n    njs_value_t         *this, *src, *value, prop;\n    njs_array_t         *array;\n    njs_typed_array_t   *self, *src_tarray;\n    njs_array_buffer_t  *buffer;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_typed_array(this))) {\n        njs_type_error(vm, \"this is not a typed array\");\n        return NJS_ERROR;\n    }\n\n    self = njs_typed_array(this);\n    src = njs_arg(args, nargs, 1);\n    value = njs_arg(args, nargs, 2);\n\n    ret = njs_value_to_integer(vm, value, &offset);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    if (njs_slow_path(offset < 0)) {\n        njs_range_error(vm, \"offset is out of bounds\");\n        return NJS_ERROR;\n    }\n\n    buffer = njs_typed_array_writable(vm, self);\n    if (njs_slow_path(buffer == NULL)) {\n        return NJS_ERROR;\n    }\n\n    length = njs_typed_array_length(self);\n\n    if (njs_is_typed_array(src)) {\n        src_tarray = njs_typed_array(src);\n        if (njs_slow_path(njs_is_detached_buffer(src_tarray->buffer))) {\n            njs_type_error(vm, \"detached buffer\");\n            return NJS_ERROR;\n        }\n\n        src_length = njs_typed_array_length(src_tarray);\n\n        if (njs_slow_path((src_length > length)\n                          || (offset > length - src_length)))\n        {\n            njs_range_error(vm, \"source is too large\");\n            return NJS_ERROR;\n        }\n\n        length = njs_min(njs_typed_array_length(src_tarray), length - offset);\n\n        for (i = 0; i < length; i++) {\n            njs_typed_array_prop_set(vm, self, offset + i,\n                                     njs_typed_array_prop(src_tarray, i));\n        }\n\n    } else {\n        if (njs_is_fast_array(src)) {\n            array = njs_array(src);\n            src_length = array->length;\n\n            if (njs_slow_path((src_length > length)\n                              || (offset > length - src_length)))\n            {\n                njs_range_error(vm, \"source is too large\");\n                return NJS_ERROR;\n            }\n\n            length = njs_min(array->length, length - offset);\n\n            for (i = 0; i < length; i++) {\n                ret = njs_value_to_number(vm, &array->start[i], &num);\n                if (ret == NJS_OK) {\n                    njs_typed_array_prop_set(vm, self, offset + i, num);\n                }\n            }\n\n            goto done;\n        }\n\n        ret = njs_value_to_object(vm, src);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        ret = njs_object_length(vm, src, &src_length);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n\n        if (njs_slow_path((src_length > length)\n                          || (offset > length - src_length)))\n        {\n            njs_range_error(vm, \"source is too large\");\n            return NJS_ERROR;\n        }\n\n        length = njs_min(src_length, length - offset);\n\n        for (i = 0; i < length; i++) {\n            ret = njs_value_property_i64(vm, src, i, &prop);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return NJS_ERROR;\n            }\n\n            num = NAN;\n\n            if (ret == NJS_OK) {\n                ret = njs_value_to_number(vm, &prop, &num);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    return NJS_ERROR;\n                }\n            }\n\n            if (njs_slow_path(njs_is_detached_buffer(buffer))) {\n                njs_type_error(vm, \"detached buffer\");\n                return NJS_ERROR;\n            }\n\n            njs_typed_array_prop_set(vm, self, offset + i, num);\n        }\n    }\n\ndone:\n\n    njs_set_undefined(&vm->retval);\n\n    return NJS_OK;\n}","target":0,"code_token_length":988,"total_token_length":1224,"max_tokens_setting":2048}
+{"idx":355645,"func":"handle_subscript(\n    char_u\t**arg,\n    char_u\t*name_start,\n    typval_T\t*rettv,\n    evalarg_T\t*evalarg,\n    int\t\tverbose)\t\/\/ give error messages\n{\n    int\t\tevaluate = evalarg != NULL\n\t\t\t\t      && (evalarg->eval_flags & EVAL_EVALUATE);\n    int\t\tret = OK;\n    dict_T\t*selfdict = NULL;\n    int\t\tcheck_white = TRUE;\n    int\t\tgetnext;\n    char_u\t*p;\n\n    while (ret == OK)\n    {\n\t\/\/ When at the end of the line and \".name\" or \"->{\" or \"->X\" follows in\n\t\/\/ the next line then consume the line break.\n\tp = eval_next_non_blank(*arg, evalarg, &getnext);\n\tif (getnext\n\t    && ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))\n\t\t|| (p[0] == '-' && p[1] == '>' && (p[2] == '{'\n\t\t\t|| ASCII_ISALPHA(in_vim9script() ? *skipwhite(p + 2)\n\t\t\t\t\t\t\t\t    : p[2])))))\n\t{\n\t    *arg = eval_next_line(evalarg);\n\t    p = *arg;\n\t    check_white = FALSE;\n\t}\n\n\tif (rettv->v_type == VAR_ANY)\n\t{\n\t    char_u\t*exp_name;\n\t    int\t\tcc;\n\t    int\t\tidx;\n\t    ufunc_T\t*ufunc;\n\t    type_T\t*type;\n\n\t    \/\/ Found script from \"import {name} as name\", script item name must\n\t    \/\/ follow.  \"rettv->vval.v_number\" has the script ID.\n\t    if (**arg != '.')\n\t    {\n\t\tif (verbose)\n\t\t    semsg(_(e_expected_dot_after_name_str),\n\t\t\t\t\tname_start != NULL ? name_start: *arg);\n\t\tret = FAIL;\n\t\tbreak;\n\t    }\n\t    ++*arg;\n\t    if (IS_WHITE_OR_NUL(**arg))\n\t    {\n\t\tif (verbose)\n\t\t    emsg(_(e_no_white_space_allowed_after_dot));\n\t\tret = FAIL;\n\t\tbreak;\n\t    }\n\n\t    \/\/ isolate the name\n\t    exp_name = *arg;\n\t    while (eval_isnamec(**arg))\n\t\t++*arg;\n\t    cc = **arg;\n\t    **arg = NUL;\n\n\t    idx = find_exported(rettv->vval.v_number, exp_name, &ufunc, &type,\n\t\t\t\t\t\t  evalarg->eval_cctx, verbose);\n\t    **arg = cc;\n\n\t    if (idx < 0 && ufunc == NULL)\n\t    {\n\t\tret = FAIL;\n\t\tbreak;\n\t    }\n\t    if (idx >= 0)\n\t    {\n\t\tscriptitem_T    *si = SCRIPT_ITEM(rettv->vval.v_number);\n\t\tsvar_T\t\t*sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;\n\n\t\tcopy_tv(sv->sv_tv, rettv);\n\t    }\n\t    else\n\t    {\n\t\trettv->v_type = VAR_FUNC;\n\t\trettv->vval.v_string = vim_strsave(ufunc->uf_name);\n\t    }\n\t    continue;\n\t}\n\n\tif ((**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC\n\t\t\t    || rettv->v_type == VAR_PARTIAL))\n\t\t    && (!check_white || !VIM_ISWHITE(*(*arg - 1))))\n\t{\n\t    ret = call_func_rettv(arg, evalarg, rettv, evaluate,\n\t\t\t\t\t\t\t       selfdict, NULL);\n\n\t    \/\/ Stop the expression evaluation when immediately aborting on\n\t    \/\/ error, or when an interrupt occurred or an exception was thrown\n\t    \/\/ but not caught.\n\t    if (aborting())\n\t    {\n\t\tif (ret == OK)\n\t\t    clear_tv(rettv);\n\t\tret = FAIL;\n\t    }\n\t    dict_unref(selfdict);\n\t    selfdict = NULL;\n\t}\n\telse if (p[0] == '-' && p[1] == '>')\n\t{\n\t    if (in_vim9script())\n\t\t*arg = skipwhite(p + 2);\n\t    else\n\t\t*arg = p + 2;\n\t    if (ret == OK)\n\t    {\n\t\tif (VIM_ISWHITE(**arg))\n\t\t{\n\t\t    emsg(_(e_no_white_space_allowed_before_parenthesis));\n\t\t    ret = FAIL;\n\t\t}\n\t\telse if ((**arg == '{' && !in_vim9script()) || **arg == '(')\n\t\t    \/\/ expr->{lambda}() or expr->(lambda)()\n\t\t    ret = eval_lambda(arg, rettv, evalarg, verbose);\n\t\telse\n\t\t    \/\/ expr->name()\n\t\t    ret = eval_method(arg, rettv, evalarg, verbose);\n\t    }\n\t}\n\t\/\/ \".\" is \".name\" lookup when we found a dict or when evaluating and\n\t\/\/ scriptversion is at least 2, where string concatenation is \"..\".\n\telse if (**arg == '['\n\t\t|| (**arg == '.' && (rettv->v_type == VAR_DICT\n\t\t\t|| (!evaluate\n\t\t\t    && (*arg)[1] != '.'\n\t\t\t    && !in_old_script(2)))))\n\t{\n\t    dict_unref(selfdict);\n\t    if (rettv->v_type == VAR_DICT)\n\t    {\n\t\tselfdict = rettv->vval.v_dict;\n\t\tif (selfdict != NULL)\n\t\t    ++selfdict->dv_refcount;\n\t    }\n\t    else\n\t\tselfdict = NULL;\n\t    if (eval_index(arg, rettv, evalarg, verbose) == FAIL)\n\t    {\n\t\tclear_tv(rettv);\n\t\tret = FAIL;\n\t    }\n\t}\n\telse\n\t    break;\n    }\n\n    \/\/ Turn \"dict.Func\" into a partial for \"Func\" bound to \"dict\".\n    \/\/ Don't do this when \"Func\" is already a partial that was bound\n    \/\/ explicitly (pt_auto is FALSE).\n    if (selfdict != NULL\n\t    && (rettv->v_type == VAR_FUNC\n\t\t|| (rettv->v_type == VAR_PARTIAL\n\t\t    && (rettv->vval.v_partial->pt_auto\n\t\t\t|| rettv->vval.v_partial->pt_dict == NULL))))\n\tselfdict = make_partial(selfdict, rettv);\n\n    dict_unref(selfdict);\n    return ret;\n}","target":0,"code_token_length":1324,"total_token_length":1560,"max_tokens_setting":2048}
+{"idx":313736,"func":"find_ident_at_pos(\n    win_T\t*wp,\n    linenr_T\tlnum,\n    colnr_T\tstartcol,\n    char_u\t**text,\n    int\t\t*textcol,\t\/\/ column where \"text\" starts, can be NULL\n    int\t\tfind_type)\n{\n    char_u\t*ptr;\n    int\t\tcol = 0;\t\/\/ init to shut up GCC\n    int\t\ti;\n    int\t\tthis_class = 0;\n    int\t\tprev_class;\n    int\t\tprevcol;\n    int\t\tbn = 0;\t\t\/\/ bracket nesting\n\n    \/\/ if i == 0: try to find an identifier\n    \/\/ if i == 1: try to find any non-white text\n    ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);\n    for (i = (find_type & FIND_IDENT) ? 0 : 1;\ti < 2; ++i)\n    {\n\t\/*\n\t * 1. skip to start of identifier\/text\n\t *\/\n\tcol = startcol;\n\tif (has_mbyte)\n\t{\n\t    while (ptr[col] != NUL)\n\t    {\n\t\t\/\/ Stop at a ']' to evaluate \"a[x]\".\n\t\tif ((find_type & FIND_EVAL) && ptr[col] == ']')\n\t\t    break;\n\t\tthis_class = mb_get_class(ptr + col);\n\t\tif (this_class != 0 && (i == 1 || this_class != 1))\n\t\t    break;\n\t\tcol += (*mb_ptr2len)(ptr + col);\n\t    }\n\t}\n\telse\n\t    while (ptr[col] != NUL\n\t\t    && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col]))\n\t\t    && (!(find_type & FIND_EVAL) || ptr[col] != ']')\n\t\t    )\n\t\t++col;\n\n\t\/\/ When starting on a ']' count it, so that we include the '['.\n\tbn = ptr[col] == ']';\n\n\t\/*\n\t * 2. Back up to start of identifier\/text.\n\t *\/\n\tif (has_mbyte)\n\t{\n\t    \/\/ Remember class of character under cursor.\n\t    if ((find_type & FIND_EVAL) && ptr[col] == ']')\n\t\tthis_class = mb_get_class((char_u *)\"a\");\n\t    else\n\t\tthis_class = mb_get_class(ptr + col);\n\t    while (col > 0 && this_class != 0)\n\t    {\n\t\tprevcol = col - 1 - (*mb_head_off)(ptr, ptr + col - 1);\n\t\tprev_class = mb_get_class(ptr + prevcol);\n\t\tif (this_class != prev_class\n\t\t\t&& (i == 0\n\t\t\t    || prev_class == 0\n\t\t\t    || (find_type & FIND_IDENT))\n\t\t\t&& (!(find_type & FIND_EVAL)\n\t\t\t    || prevcol == 0\n\t\t\t    || !find_is_eval_item(ptr + prevcol, &prevcol,\n\t\t\t\t\t\t\t       &bn, BACKWARD))\n\t\t\t)\n\t\t    break;\n\t\tcol = prevcol;\n\t    }\n\n\t    \/\/ If we don't want just any old text, or we've found an\n\t    \/\/ identifier, stop searching.\n\t    if (this_class > 2)\n\t\tthis_class = 2;\n\t    if (!(find_type & FIND_STRING) || this_class == 2)\n\t\tbreak;\n\t}\n\telse\n\t{\n\t    while (col > 0\n\t\t    && ((i == 0\n\t\t\t    ? vim_iswordc(ptr[col - 1])\n\t\t\t    : (!VIM_ISWHITE(ptr[col - 1])\n\t\t\t\t&& (!(find_type & FIND_IDENT)\n\t\t\t\t    || !vim_iswordc(ptr[col - 1]))))\n\t\t\t|| ((find_type & FIND_EVAL)\n\t\t\t    && col > 1\n\t\t\t    && find_is_eval_item(ptr + col - 1, &col,\n\t\t\t\t\t\t\t       &bn, BACKWARD))\n\t\t\t))\n\t\t--col;\n\n\t    \/\/ If we don't want just any old text, or we've found an\n\t    \/\/ identifier, stop searching.\n\t    if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col]))\n\t\tbreak;\n\t}\n    }\n\n    if (ptr[col] == NUL || (i == 0\n\t\t&& (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col]))))\n    {\n\t\/\/ didn't find an identifier or text\n\tif ((find_type & FIND_NOERROR) == 0)\n\t{\n\t    if (find_type & FIND_STRING)\n\t\temsg(_(e_no_string_under_cursor));\n\t    else\n\t\temsg(_(e_no_identifier_under_cursor));\n\t}\n\treturn 0;\n    }\n    ptr += col;\n    *text = ptr;\n    if (textcol != NULL)\n\t*textcol = col;\n\n    \/*\n     * 3. Find the end if the identifier\/text.\n     *\/\n    bn = 0;\n    startcol -= col;\n    col = 0;\n    if (has_mbyte)\n    {\n\t\/\/ Search for point of changing multibyte character class.\n\tthis_class = mb_get_class(ptr);\n\twhile (ptr[col] != NUL\n\t\t&& ((i == 0 ? mb_get_class(ptr + col) == this_class\n\t\t\t    : mb_get_class(ptr + col) != 0)\n\t\t    || ((find_type & FIND_EVAL)\n\t\t\t&& col <= (int)startcol\n\t\t\t&& find_is_eval_item(ptr + col, &col, &bn, FORWARD))\n\t\t))\n\t    col += (*mb_ptr2len)(ptr + col);\n    }\n    else\n\twhile ((i == 0 ? vim_iswordc(ptr[col])\n\t\t       : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col])))\n\t\t    || ((find_type & FIND_EVAL)\n\t\t\t&& col <= (int)startcol\n\t\t\t&& find_is_eval_item(ptr + col, &col, &bn, FORWARD))\n\t\t)\n\t    ++col;\n\n    return col;\n}","target":0,"code_token_length":1246,"total_token_length":1482,"max_tokens_setting":2048}
+{"idx":201872,"func":"_gnutls_server_select_suite(gnutls_session_t session, uint8_t * data,\n\t\t\t    unsigned int datalen)\n{\n\tint ret;\n\tunsigned int i, j, cipher_suites_size;\n\tsize_t pk_algos_size;\n\tuint8_t cipher_suites[MAX_CIPHERSUITE_SIZE];\n\tint retval;\n\tgnutls_pk_algorithm_t pk_algos[MAX_ALGOS];\t\/* will hold the pk algorithms\n\t\t\t\t\t\t\t * supported by the peer.\n\t\t\t\t\t\t\t *\/\n\n\tfor (i = 0; i < datalen; i += 2) {\n\t\t\/* TLS_RENEGO_PROTECTION_REQUEST = { 0x00, 0xff } *\/\n\t\tif (session->internals.priorities.sr != SR_DISABLED &&\n\t\t    data[i] == GNUTLS_RENEGO_PROTECTION_REQUEST_MAJOR &&\n\t\t    data[i + 1] == GNUTLS_RENEGO_PROTECTION_REQUEST_MINOR) {\n\t\t\t_gnutls_handshake_log\n\t\t\t    (\"HSK[%p]: Received safe renegotiation CS\\n\",\n\t\t\t     session);\n\t\t\tretval = _gnutls_ext_sr_recv_cs(session);\n\t\t\tif (retval < 0) {\n\t\t\t\tgnutls_assert();\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t}\n\n\t\t\/* TLS_FALLBACK_SCSV *\/\n\t\tif (data[i] == GNUTLS_FALLBACK_SCSV_MAJOR &&\n\t\t    data[i + 1] == GNUTLS_FALLBACK_SCSV_MINOR) {\n\t\t\t_gnutls_handshake_log\n\t\t\t    (\"HSK[%p]: Received fallback CS\\n\",\n\t\t\t     session);\n\n\t\t\tif (gnutls_protocol_get_version(session) !=\n\t\t\t    GNUTLS_TLS_VERSION_MAX)\n\t\t\t\treturn GNUTLS_E_INAPPROPRIATE_FALLBACK;\n\t\t}\n\t}\n\n\tpk_algos_size = MAX_ALGOS;\n\tret =\n\t    server_find_pk_algos_in_ciphersuites(data, datalen, pk_algos,\n\t\t\t\t\t\t &pk_algos_size);\n\tif (ret < 0)\n\t\treturn gnutls_assert_val(ret);\n\n\tret =\n\t    _gnutls_supported_ciphersuites(session, cipher_suites,\n\t\t\t\t\t   sizeof(cipher_suites));\n\tif (ret < 0)\n\t\treturn gnutls_assert_val(ret);\n\n\tcipher_suites_size = ret;\n\n\t\/* Here we remove any ciphersuite that does not conform\n\t * the certificate requested, or to the\n\t * authentication requested (e.g. SRP).\n\t *\/\n\tret =\n\t    _gnutls_remove_unwanted_ciphersuites(session, cipher_suites,\n\t\t\t\t\t\t cipher_suites_size,\n\t\t\t\t\t\t pk_algos, pk_algos_size);\n\tif (ret <= 0) {\n\t\tgnutls_assert();\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\telse\n\t\t\treturn GNUTLS_E_UNKNOWN_CIPHER_SUITE;\n\t}\n\n\tcipher_suites_size = ret;\n\n\t\/* Data length should be zero mod 2 since\n\t * every ciphersuite is 2 bytes. (this check is needed\n\t * see below).\n\t *\/\n\tif (datalen % 2 != 0) {\n\t\tgnutls_assert();\n\t\treturn GNUTLS_E_UNEXPECTED_PACKET_LENGTH;\n\t}\n\n\tmemset(session->security_parameters.cipher_suite, 0, 2);\n\n\tretval = GNUTLS_E_UNKNOWN_CIPHER_SUITE;\n\n\t_gnutls_handshake_log\n\t    (\"HSK[%p]: Requested cipher suites[size: %d]: \\n\", session,\n\t     (int) datalen);\n\n\tif (session->internals.priorities.server_precedence == 0) {\n\t\tfor (j = 0; j < datalen; j += 2) {\n\t\t\t_gnutls_handshake_log(\"\\t0x%.2x, 0x%.2x %s\\n\",\n\t\t\t\t\t      data[j], data[j + 1],\n\t\t\t\t\t      _gnutls_cipher_suite_get_name\n\t\t\t\t\t      (&data[j]));\n\t\t\tfor (i = 0; i < cipher_suites_size; i += 2) {\n\t\t\t\tif (memcmp(&cipher_suites[i], &data[j], 2)\n\t\t\t\t    == 0) {\n\t\t\t\t\t_gnutls_handshake_log\n\t\t\t\t\t    (\"HSK[%p]: Selected cipher suite: %s\\n\",\n\t\t\t\t\t     session,\n\t\t\t\t\t     _gnutls_cipher_suite_get_name\n\t\t\t\t\t     (&data[j]));\n\t\t\t\t\tmemcpy(session->\n\t\t\t\t\t       security_parameters.\n\t\t\t\t\t       cipher_suite,\n\t\t\t\t\t       &cipher_suites[i], 2);\n\t\t\t\t\t_gnutls_epoch_set_cipher_suite\n\t\t\t\t\t    (session, EPOCH_NEXT,\n\t\t\t\t\t     session->security_parameters.\n\t\t\t\t\t     cipher_suite);\n\n\n\t\t\t\t\tretval = 0;\n\t\t\t\t\tgoto finish;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\t\t\/* server selects *\/\n\n\t\tfor (i = 0; i < cipher_suites_size; i += 2) {\n\t\t\tfor (j = 0; j < datalen; j += 2) {\n\t\t\t\tif (memcmp(&cipher_suites[i], &data[j], 2)\n\t\t\t\t    == 0) {\n\t\t\t\t\t_gnutls_handshake_log\n\t\t\t\t\t    (\"HSK[%p]: Selected cipher suite: %s\\n\",\n\t\t\t\t\t     session,\n\t\t\t\t\t     _gnutls_cipher_suite_get_name\n\t\t\t\t\t     (&data[j]));\n\t\t\t\t\tmemcpy(session->\n\t\t\t\t\t       security_parameters.\n\t\t\t\t\t       cipher_suite,\n\t\t\t\t\t       &cipher_suites[i], 2);\n\t\t\t\t\t_gnutls_epoch_set_cipher_suite\n\t\t\t\t\t    (session, EPOCH_NEXT,\n\t\t\t\t\t     session->security_parameters.\n\t\t\t\t\t     cipher_suite);\n\n\n\t\t\t\t\tretval = 0;\n\t\t\t\t\tgoto finish;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n      finish:\n\n\tif (retval != 0) {\n\t\tgnutls_assert();\n\t\treturn retval;\n\t}\n\n\t\/* check if the credentials (username, public key etc.) are ok\n\t *\/\n\tif (_gnutls_get_kx_cred\n\t    (session,\n\t     _gnutls_cipher_suite_get_kx_algo(session->security_parameters.\n\t\t\t\t\t      cipher_suite)) == NULL) {\n\t\tgnutls_assert();\n\t\treturn GNUTLS_E_INSUFFICIENT_CREDENTIALS;\n\t}\n\n\n\t\/* set the mod_auth_st to the appropriate struct\n\t * according to the KX algorithm. This is needed since all the\n\t * handshake functions are read from there;\n\t *\/\n\tsession->internals.auth_struct =\n\t    _gnutls_kx_auth_struct(_gnutls_cipher_suite_get_kx_algo\n\t\t\t\t   (session->security_parameters.\n\t\t\t\t    cipher_suite));\n\tif (session->internals.auth_struct == NULL) {\n\n\t\t_gnutls_handshake_log\n\t\t    (\"HSK[%p]: Cannot find the appropriate handler for the KX algorithm\\n\",\n\t\t     session);\n\t\tgnutls_assert();\n\t\treturn GNUTLS_E_INTERNAL_ERROR;\n\t}\n\n\treturn 0;\n\n}","target":1,"code_token_length":1396,"total_token_length":1632,"max_tokens_setting":2048}
+{"idx":223390,"func":"static void do_caselesscmp(compiler_common *common)\n{\nDEFINE_COMPILER;\nstruct sljit_jump *jump;\nstruct sljit_label *label;\nint char1_reg = STR_END;\nint char2_reg;\nint lcc_table;\nint opt_type = 0;\n\nif (HAS_VIRTUAL_REGISTERS)\n  {\n  char2_reg = STACK_TOP;\n  lcc_table = STACK_LIMIT;\n  }\nelse\n  {\n  char2_reg = RETURN_ADDR;\n  lcc_table = TMP3;\n  }\n\nif (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_POST, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)) == SLJIT_SUCCESS)\n  opt_type = 1;\nelse if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_PRE, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)) == SLJIT_SUCCESS)\n  opt_type = 2;\n\nsljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0);\nOP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);\n\nOP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, char1_reg, 0);\n\nif (char2_reg == STACK_TOP)\n  {\n  OP1(SLJIT_MOV, TMP3, 0, char2_reg, 0);\n  OP1(SLJIT_MOV, RETURN_ADDR, 0, lcc_table, 0);\n  }\n\nOP1(SLJIT_MOV, lcc_table, 0, SLJIT_IMM, common->lcc);\n\nif (opt_type == 1)\n  {\n  label = LABEL();\n  sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1));\n  sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, char2_reg, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));\n  }\nelse if (opt_type == 2)\n  {\n  OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));\n  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n  label = LABEL();\n  sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_PRE, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1));\n  sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_PRE, char2_reg, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));\n  }\nelse\n  {\n  label = LABEL();\n  OP1(MOV_UCHAR, char1_reg, 0, SLJIT_MEM1(TMP1), 0);\n  OP1(MOV_UCHAR, char2_reg, 0, SLJIT_MEM1(STR_PTR), 0);\n  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));\n  }\n\n#if PCRE2_CODE_UNIT_WIDTH != 8\njump = CMP(SLJIT_GREATER, char1_reg, 0, SLJIT_IMM, 255);\n#endif\nOP1(SLJIT_MOV_U8, char1_reg, 0, SLJIT_MEM2(lcc_table, char1_reg), 0);\n#if PCRE2_CODE_UNIT_WIDTH != 8\nJUMPHERE(jump);\njump = CMP(SLJIT_GREATER, char2_reg, 0, SLJIT_IMM, 255);\n#endif\nOP1(SLJIT_MOV_U8, char2_reg, 0, SLJIT_MEM2(lcc_table, char2_reg), 0);\n#if PCRE2_CODE_UNIT_WIDTH != 8\nJUMPHERE(jump);\n#endif\n\nif (opt_type == 0)\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\njump = CMP(SLJIT_NOT_EQUAL, char1_reg, 0, char2_reg, 0);\nOP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));\nJUMPTO(SLJIT_NOT_ZERO, label);\n\nJUMPHERE(jump);\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);\n\nif (opt_type == 2)\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\nif (char2_reg == STACK_TOP)\n  {\n  OP1(SLJIT_MOV, char2_reg, 0, TMP3, 0);\n  OP1(SLJIT_MOV, lcc_table, 0, RETURN_ADDR, 0);\n  }\n\nOP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1);\nOP_SRC(SLJIT_FAST_RETURN, TMP1, 0);\n}","target":0,"code_token_length":1202,"total_token_length":1438,"max_tokens_setting":2048}
+{"idx":376337,"func":"gpg_verify_sync (CamelCipherContext *context,\n                 CamelMimePart *ipart,\n                 GCancellable *cancellable,\n                 GError **error)\n{\n\tCamelCipherContextClass *class;\n\tCamelCipherValidity *validity;\n\tconst gchar *diagnostics = NULL;\n\tstruct _GpgCtx *gpg = NULL;\n\tgchar *sigfile = NULL;\n\tCamelContentType *ct;\n\tCamelMimePart *sigpart;\n\tCamelStream *istream = NULL, *canon_stream;\n\tCamelMultipart *mps;\n\tCamelStream *filter;\n\tCamelMimeFilter *canon;\n\n\tclass = CAMEL_CIPHER_CONTEXT_GET_CLASS (context);\n\n\tmps = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) ipart);\n\tct = ((CamelDataWrapper *) mps)->mime_type;\n\n\t\/* Inline signature (using our fake mime type) or PGP\/Mime signature *\/\n\tif (camel_content_type_is (ct, \"multipart\", \"signed\")) {\n\t\t\/* PGP\/Mime Signature *\/\n\t\tconst gchar *tmp;\n\n\t\ttmp = camel_content_type_param (ct, \"protocol\");\n\t\tif (!CAMEL_IS_MULTIPART_SIGNED (mps)\n\t\t    || tmp == NULL\n\t\t    || g_ascii_strcasecmp (tmp, class->sign_protocol) != 0) {\n\t\t\tg_set_error (\n\t\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t\t_(\"Cannot verify message signature: \"\n\t\t\t\t\"Incorrect message format\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (!(istream = camel_multipart_signed_get_content_stream ((CamelMultipartSigned *) mps, NULL))) {\n\t\t\tg_set_error (\n\t\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t\t_(\"Cannot verify message signature: \"\n\t\t\t\t\"Incorrect message format\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (!(sigpart = camel_multipart_get_part (mps, CAMEL_MULTIPART_SIGNED_SIGNATURE))) {\n\t\t\tg_set_error (\n\t\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t\t_(\"Cannot verify message signature: \"\n\t\t\t\t\"Incorrect message format\"));\n\t\t\tg_object_unref (istream);\n\t\t\treturn NULL;\n\t\t}\n\t} else if (camel_content_type_is (ct, \"application\", \"x-inlinepgp-signed\")) {\n\t\t\/* Inline Signed *\/\n\t\tCamelDataWrapper *content;\n\t\tcontent = camel_medium_get_content ((CamelMedium *) ipart);\n\t\tistream = camel_stream_mem_new ();\n\t\tif (!camel_data_wrapper_decode_to_stream_sync (\n\t\t\tcontent, istream, cancellable, error))\n\t\t\tgoto exception;\n\t\tg_seekable_seek (\n\t\t\tG_SEEKABLE (istream), 0, G_SEEK_SET, NULL, NULL);\n\t\tsigpart = NULL;\n\t} else {\n\t\t\/* Invalid Mimetype *\/\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC,\n\t\t\t_(\"Cannot verify message signature: \"\n\t\t\t\"Incorrect message format\"));\n\t\treturn NULL;\n\t}\n\n\t\/* Now start the real work of verifying the message *\/\n#ifdef GPG_LOG\n\tif (camel_debug_start (\"gpg:sign\")) {\n\t\tgchar *name;\n\t\tCamelStream *out;\n\n\t\tname = g_strdup_printf (\"camel-gpg.%d.verify.data\", logid);\n\t\tout = camel_stream_fs_new_with_name (name, O_CREAT | O_TRUNC | O_WRONLY, 0666);\n\t\tif (out) {\n\t\t\tprintf (\"Writing gpg verify data to '%s'\\n\", name);\n\t\t\tcamel_stream_write_to_stream (istream, out);\n\t\t\tg_seekable_seek (\n\t\t\t\tG_SEEKABLE (istream),\n\t\t\t\t0, G_SEEK_SET, NULL, NULL);\n\t\t\tg_object_unref (out);\n\t\t}\n\n\t\tg_free (name);\n\n\t\tif (sigpart) {\n\t\t\tname = g_strdup_printf (\"camel-gpg.%d.verify.signature\", logid++);\n\t\t\tout = camel_stream_fs_new_with_name (name, O_CREAT | O_TRUNC | O_WRONLY, 0666);\n\t\t\tif (out) {\n\t\t\t\tprintf (\"Writing gpg verify signature to '%s'\\n\", name);\n\t\t\t\tcamel_data_wrapper_write_to_stream ((CamelDataWrapper *) sigpart, out);\n\t\t\t\tg_object_unref (out);\n\t\t\t}\n\t\t\tg_free (name);\n\t\t}\n\t\tcamel_debug_end ();\n\t}\n#endif\n\n\tif (sigpart) {\n\t\tsigfile = swrite (sigpart, cancellable, error);\n\t\tif (sigfile == NULL) {\n\t\t\tg_prefix_error (\n\t\t\t\terror, _(\"Cannot verify message signature: \"));\n\t\t\tgoto exception;\n\t\t}\n\t}\n\n\tg_seekable_seek (G_SEEKABLE (istream), 0, G_SEEK_SET, NULL, NULL);\n\n\tcanon_stream = camel_stream_mem_new ();\n\n\t\/* strip trailing white-spaces *\/\n\tfilter = camel_stream_filter_new (canon_stream);\n\tcanon = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF | CAMEL_MIME_FILTER_CANON_STRIP);\n\tcamel_stream_filter_add (CAMEL_STREAM_FILTER (filter), canon);\n\tg_object_unref (canon);\n\n\tcamel_stream_write_to_stream (istream, filter, NULL, NULL);\n\n\tg_object_unref (filter);\n\n\tg_seekable_seek (G_SEEKABLE (istream), 0, G_SEEK_SET, NULL, NULL);\n\n\tg_seekable_seek (G_SEEKABLE (canon_stream), 0, G_SEEK_SET, NULL, NULL);\n\n\tgpg = gpg_ctx_new (context);\n\tgpg_ctx_set_mode (gpg, GPG_CTX_MODE_VERIFY);\n\tif (sigfile)\n\t\tgpg_ctx_set_sigfile (gpg, sigfile);\n\tgpg_ctx_set_istream (gpg, canon_stream);\n\n\tif (!gpg_ctx_op_start (gpg, error))\n\t\tgoto exception;\n\n\twhile (!gpg_ctx_op_complete (gpg)) {\n\t\tif (gpg_ctx_op_step (gpg, cancellable, error) == -1) {\n\t\t\tgpg_ctx_op_cancel (gpg);\n\t\t\tgoto exception;\n\t\t}\n\t}\n\n\t\/* report error only when no data or didn't found signature *\/\n\tif (gpg_ctx_op_wait (gpg) != 0 && (gpg->nodata || !gpg->hadsig)) {\n\t\tconst gchar *diagnostics;\n\n\t\tdiagnostics = gpg_ctx_get_diagnostics (gpg);\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC, \"%s\",\n\t\t\t(diagnostics != NULL && *diagnostics != '\\0') ?\n\t\t\tdiagnostics : _(\"Failed to execute gpg.\"));\n\t\tgoto exception;\n\t}\n\n\tvalidity = camel_cipher_validity_new ();\n\tdiagnostics = gpg_ctx_get_diagnostics (gpg);\n\tcamel_cipher_validity_set_description (validity, diagnostics);\n\tif (gpg->validsig) {\n\t\tif (gpg->trust == GPG_TRUST_UNDEFINED || gpg->trust == GPG_TRUST_NONE)\n\t\t\tvalidity->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_UNKNOWN;\n\t\telse if (gpg->trust != GPG_TRUST_NEVER)\n\t\t\tvalidity->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_GOOD;\n\t\telse\n\t\t\tvalidity->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;\n\t} else if (gpg->nopubkey) {\n\t\tvalidity->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_NEED_PUBLIC_KEY;\n\t} else {\n\t\tvalidity->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;\n\t}\n\n\tadd_signers (validity, gpg->signers);\n\n\tgpg_ctx_free (gpg);\n\n\tif (sigfile) {\n\t\tg_unlink (sigfile);\n\t\tg_free (sigfile);\n\t}\n\tg_object_unref (istream);\n\tg_object_unref (canon_stream);\n\n\treturn validity;\n\n exception:\n\n\tif (gpg != NULL)\n\t\tgpg_ctx_free (gpg);\n\n\tif (istream)\n\t\tg_object_unref (istream);\n\n\tif (sigfile) {\n\t\tg_unlink (sigfile);\n\t\tg_free (sigfile);\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":1701,"total_token_length":1937,"max_tokens_setting":2048}
+{"idx":353238,"func":"bool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine,\n\t\t\t\t      unsigned char *alphaLine) {\n  SplashOutMaskedImageData *imgData = (SplashOutMaskedImageData *)data;\n  unsigned char *p, *aq;\n  SplashColorPtr q, col;\n  GfxRGB rgb;\n  GfxGray gray;\n#ifdef SPLASH_CMYK\n  GfxCMYK cmyk;\n  GfxColor deviceN;\n#endif\n  unsigned char alpha;\n  unsigned char *maskPtr;\n  int maskBit;\n  int nComps, x;\n\n  if (imgData->y == imgData->height) {\n    return false;\n  }\n  if (!(p = imgData->imgStr->getLine())) {\n    return false;\n  }\n\n  nComps = imgData->colorMap->getNumPixelComps();\n\n  maskPtr = imgData->mask->getDataPtr() +\n              imgData->y * imgData->mask->getRowSize();\n  maskBit = 0x80;\n  for (x = 0, q = colorLine, aq = alphaLine;\n       x < imgData->width;\n       ++x, p += nComps) {\n    alpha = (*maskPtr & maskBit) ? 0xff : 0x00;\n    if (!(maskBit >>= 1)) {\n      ++maskPtr;\n      maskBit = 0x80;\n    }\n    if (imgData->lookup) {\n      switch (imgData->colorMode) {\n      case splashModeMono1:\n      case splashModeMono8:\n\t*q++ = imgData->lookup[*p];\n\tbreak;\n      case splashModeRGB8:\n      case splashModeBGR8:\n\tcol = &imgData->lookup[3 * *p];\n\t*q++ = col[0];\n\t*q++ = col[1];\n\t*q++ = col[2];\n\tbreak;\n      case splashModeXBGR8:\n\tcol = &imgData->lookup[4 * *p];\n\t*q++ = col[0];\n\t*q++ = col[1];\n\t*q++ = col[2];\n\t*q++ = 255;\n\tbreak;\n#ifdef SPLASH_CMYK\n      case splashModeCMYK8:\n\tcol = &imgData->lookup[4 * *p];\n\t*q++ = col[0];\n\t*q++ = col[1];\n\t*q++ = col[2];\n\t*q++ = col[3];\n\tbreak;\n      case splashModeDeviceN8:\n\tcol = &imgData->lookup[(SPOT_NCOMPS+4) * *p];\n  for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)\n    *q++ = col[cp];\n\tbreak;\n#endif\n      }\n      *aq++ = alpha;\n    } else {\n      switch (imgData->colorMode) {\n      case splashModeMono1:\n      case splashModeMono8:\n\timgData->colorMap->getGray(p, &gray);\n\t*q++ = colToByte(gray);\n\tbreak;\n      case splashModeXBGR8:\n      case splashModeRGB8:\n      case splashModeBGR8:\n\timgData->colorMap->getRGB(p, &rgb);\n\t*q++ = colToByte(rgb.r);\n\t*q++ = colToByte(rgb.g);\n\t*q++ = colToByte(rgb.b);\n\tif (imgData->colorMode == splashModeXBGR8) *q++ = 255;\n\tbreak;\n#ifdef SPLASH_CMYK\n      case splashModeCMYK8:\n\timgData->colorMap->getCMYK(p, &cmyk);\n\t*q++ = colToByte(cmyk.c);\n\t*q++ = colToByte(cmyk.m);\n\t*q++ = colToByte(cmyk.y);\n\t*q++ = colToByte(cmyk.k);\n\tbreak;\n      case splashModeDeviceN8:\n\timgData->colorMap->getDeviceN(p, &deviceN);\n  for (int cp = 0; cp < SPOT_NCOMPS+4; cp++)\n    *q++ = colToByte(deviceN.c[cp]);\n\tbreak;\n#endif\n      }\n      *aq++ = alpha;\n    }\n  }\n\n  ++imgData->y;\n  return true;\n}","target":0,"code_token_length":908,"total_token_length":1144,"max_tokens_setting":2048}
+{"idx":277673,"func":"start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n{\n  ppm_source_ptr source = (ppm_source_ptr) sinfo;\n  int c;\n  unsigned int w, h, maxval;\n  boolean need_iobuffer, use_raw_buffer, need_rescale;\n\n  if (getc(source->pub.input_file) != 'P')\n    ERREXIT(cinfo, JERR_PPM_NOT);\n\n  c = getc(source->pub.input_file); \/* subformat discriminator character *\/\n\n  \/* detect unsupported variants (ie, PBM) before trying to read header *\/\n  switch (c) {\n  case '2':                     \/* it's a text-format PGM file *\/\n  case '3':                     \/* it's a text-format PPM file *\/\n  case '5':                     \/* it's a raw-format PGM file *\/\n  case '6':                     \/* it's a raw-format PPM file *\/\n    break;\n  default:\n    ERREXIT(cinfo, JERR_PPM_NOT);\n    break;\n  }\n\n  \/* fetch the remaining header info *\/\n  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n\n  if (w <= 0 || h <= 0 || maxval <= 0) \/* error check *\/\n    ERREXIT(cinfo, JERR_PPM_NOT);\n\n  cinfo->data_precision = BITS_IN_JSAMPLE; \/* we always rescale data to this *\/\n  cinfo->image_width = (JDIMENSION) w;\n  cinfo->image_height = (JDIMENSION) h;\n  source->maxval = maxval;\n\n  \/* initialize flags to most common settings *\/\n  need_iobuffer = TRUE;         \/* do we need an I\/O buffer? *\/\n  use_raw_buffer = FALSE;       \/* do we map input buffer onto I\/O buffer? *\/\n  need_rescale = TRUE;          \/* do we need a rescale array? *\/\n\n  switch (c) {\n  case '2':                     \/* it's a text-format PGM file *\/\n    cinfo->input_components = 1;\n    cinfo->in_color_space = JCS_GRAYSCALE;\n    TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h);\n    source->pub.get_pixel_rows = get_text_gray_row;\n    need_iobuffer = FALSE;\n    break;\n\n  case '3':                     \/* it's a text-format PPM file *\/\n    cinfo->input_components = 3;\n    cinfo->in_color_space = JCS_RGB;\n    TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h);\n    source->pub.get_pixel_rows = get_text_rgb_row;\n    need_iobuffer = FALSE;\n    break;\n\n  case '5':                     \/* it's a raw-format PGM file *\/\n    cinfo->input_components = 1;\n    cinfo->in_color_space = JCS_GRAYSCALE;\n    TRACEMS2(cinfo, 1, JTRC_PGM, w, h);\n    if (maxval > 255) {\n      source->pub.get_pixel_rows = get_word_gray_row;\n    } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR)) {\n      source->pub.get_pixel_rows = get_raw_row;\n      use_raw_buffer = TRUE;\n      need_rescale = FALSE;\n    } else {\n      source->pub.get_pixel_rows = get_scaled_gray_row;\n    }\n    break;\n\n  case '6':                     \/* it's a raw-format PPM file *\/\n    cinfo->input_components = 3;\n    cinfo->in_color_space = JCS_RGB;\n    TRACEMS2(cinfo, 1, JTRC_PPM, w, h);\n    if (maxval > 255) {\n      source->pub.get_pixel_rows = get_word_rgb_row;\n    } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR)) {\n      source->pub.get_pixel_rows = get_raw_row;\n      use_raw_buffer = TRUE;\n      need_rescale = FALSE;\n    } else {\n      source->pub.get_pixel_rows = get_scaled_rgb_row;\n    }\n    break;\n  }\n\n  \/* Allocate space for I\/O buffer: 1 or 3 bytes or words\/pixel. *\/\n  if (need_iobuffer) {\n    source->buffer_width = (size_t) w * cinfo->input_components *\n      ((maxval<=255) ? sizeof(U_CHAR) : (2*sizeof(U_CHAR)));\n    source->iobuffer = (U_CHAR *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n                                  source->buffer_width);\n  }\n\n  \/* Create compressor input buffer. *\/\n  if (use_raw_buffer) {\n    \/* For unscaled raw-input case, we can just map it onto the I\/O buffer. *\/\n    \/* Synthesize a JSAMPARRAY pointer structure *\/\n    source->pixrow = (JSAMPROW) source->iobuffer;\n    source->pub.buffer = & source->pixrow;\n    source->pub.buffer_height = 1;\n  } else {\n    \/* Need to translate anyway, so make a separate sample buffer. *\/\n    source->pub.buffer = (*cinfo->mem->alloc_sarray)\n      ((j_common_ptr) cinfo, JPOOL_IMAGE,\n       (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1);\n    source->pub.buffer_height = 1;\n  }\n\n  \/* Compute the rescaling array if required. *\/\n  if (need_rescale) {\n    INT32 val, half_maxval;\n\n    \/* On 16-bit-int machines we have to be careful of maxval = 65535 *\/\n    source->rescale = (JSAMPLE *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n                                  (size_t) (((long) maxval + 1L) * sizeof(JSAMPLE)));\n    half_maxval = maxval \/ 2;\n    for (val = 0; val <= (INT32) maxval; val++) {\n      \/* The multiplication here must be done in 32 bits to avoid overflow *\/\n      source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)\/maxval);\n    }\n  }\n}","target":0,"code_token_length":1411,"total_token_length":1647,"max_tokens_setting":2048}
+{"idx":402657,"func":"handle_unlock_token(context *ctx, struct pollfd *pollfd, socklen_t size)\n{\n\tstruct msghdr msg;\n\tstruct iovec iov;\n\tssize_t n;\n\n\tint rc = cms_context_alloc(&ctx->cms);\n\tif (rc < 0) {\n\t\tsend_response(ctx, ctx->backup_cms, pollfd, rc);\n\t\treturn;\n\t}\n\n\tsteal_from_cms(ctx->backup_cms, ctx->cms);\n\n\tchar *buffer = malloc(size);\n\tif (!buffer) {\noom:\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unable to allocate memory: %m\");\n\t\texit(1);\n\t}\n\n\tmemset(&msg, '\\0', sizeof(msg));\n\n\tiov.iov_base = buffer;\n\tiov.iov_len = size;\n\tmsg.msg_iov = &iov;\n\tmsg.msg_iovlen = 1;\n\n\tn = recvmsg(pollfd->fd, &msg, MSG_WAITALL);\n\n\tpesignd_string *tn = (pesignd_string *)buffer;\n\tif (n < (long long)sizeof(tn->size)) {\nmalformed:\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unlock-token: invalid data\");\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"possible exploit attempt. closing.\");\n\t\tclose(pollfd->fd);\n\t\treturn;\n\t}\n\tn -= sizeof(tn->size);\n\tif ((size_t)n < tn->size)\n\t\tgoto malformed;\n\tn -= tn->size;\n\n\tif (tn->value[tn->size - 1] != '\\0')\n\t\tgoto malformed;\n\n\tpesignd_string *tp = pesignd_string_next(tn);\n\tif ((size_t)n < sizeof(tp->size))\n\t\tgoto malformed;\n\tn -= sizeof(tp->size);\n\tif ((size_t)n < tp->size)\n\t\tgoto malformed;\n\tn -= tp->size;\n\n\tif (tn->value[tn->size - 1] != '\\0')\n\t\tgoto malformed;\n\n\tif (n != 0)\n\t\tgoto malformed;\n\n\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\"unlocking token \\\"%s\\\"\", tn->value);\n\n\t\/* authenticating with nss frees this ... best API ever. *\/\n\tctx->cms->tokenname = PORT_ArenaStrdup(ctx->cms->arena,\n\t\t\t\t\t\t(char *)tn->value);\n\tif (!ctx->cms->tokenname)\n\t\tgoto oom;\n\n\tchar *pin = (char *)tp->value;\n\tif (!pin)\n\t\tgoto oom;\n\n\tsecuPWData pwdata;\n\n\tmemset(&pwdata, 0, sizeof(pwdata));\n\tpwdata.source = pwdata.orig_source = PW_PLAINTEXT;\n\tpwdata.data = pin;\n\n\tcms_set_pw_callback(ctx->cms, get_password_passthrough);\n\tcms_set_pw_data(ctx->cms, &pwdata);\n\n\trc = unlock_nss_token(ctx->cms);\n\n\tcms_set_pw_callback(ctx->cms, get_password_fail);\n\tcms_set_pw_data(ctx->cms, NULL);\n\n\tif (rc == -1)\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not find token \\\"%s\\\"\", tn->value);\n\telse if (rc == 0) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\t\"authentication succeeded for token \\\"%s\\\"\",\n\t\t\ttn->value);\n\t\trc = add_token_to_authenticated_list(ctx, tn->value);\n\t\tif (rc < 0)\n\t\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\t\"couldn't add token to internal list: %m\");\n\t}\n\n\tsend_response(ctx, ctx->cms, pollfd, rc);\n\tfree(buffer);\n\n\thide_stolen_goods_from_cms(ctx->cms, ctx->backup_cms);\n\tcms_context_fini(ctx->cms);\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048}
+{"idx":449299,"func":"nv_screengo(oparg_T *oap, int dir, long dist)\n{\n    int\t\tlinelen = linetabsize(ml_get_curline());\n    int\t\tretval = OK;\n    int\t\tatend = FALSE;\n    int\t\tn;\n    int\t\tcol_off1;\t\/\/ margin offset for first screen line\n    int\t\tcol_off2;\t\/\/ margin offset for wrapped screen line\n    int\t\twidth1;\t\t\/\/ text width for first screen line\n    int\t\twidth2;\t\t\/\/ text width for wrapped screen line\n\n    oap->motion_type = MCHAR;\n    oap->inclusive = (curwin->w_curswant == MAXCOL);\n\n    col_off1 = curwin_col_off();\n    col_off2 = col_off1 - curwin_col_off2();\n    width1 = curwin->w_width - col_off1;\n    width2 = curwin->w_width - col_off2;\n    if (width2 == 0)\n\twidth2 = 1; \/\/ avoid divide by zero\n\n    if (curwin->w_width != 0)\n    {\n      \/*\n       * Instead of sticking at the last character of the buffer line we\n       * try to stick in the last column of the screen.\n       *\/\n      if (curwin->w_curswant == MAXCOL)\n      {\n\tatend = TRUE;\n\tvalidate_virtcol();\n\tif (width1 <= 0)\n\t    curwin->w_curswant = 0;\n\telse\n\t{\n\t    curwin->w_curswant = width1 - 1;\n\t    if (curwin->w_virtcol > curwin->w_curswant)\n\t\tcurwin->w_curswant += ((curwin->w_virtcol\n\t\t\t     - curwin->w_curswant - 1) \/ width2 + 1) * width2;\n\t}\n      }\n      else\n      {\n\tif (linelen > width1)\n\t    n = ((linelen - width1 - 1) \/ width2 + 1) * width2 + width1;\n\telse\n\t    n = width1;\n\tif (curwin->w_curswant >= (colnr_T)n)\n\t    curwin->w_curswant = n - 1;\n      }\n\n      while (dist--)\n      {\n\tif (dir == BACKWARD)\n\t{\n\t    if ((long)curwin->w_curswant >= width1\n#ifdef FEAT_FOLDING\n\t\t    && !hasFolding(curwin->w_cursor.lnum, NULL, NULL)\n#endif\n\t       )\n\t\t\/\/ Move back within the line. This can give a negative value\n\t\t\/\/ for w_curswant if width1 < width2 (with cpoptions+=n),\n\t\t\/\/ which will get clipped to column 0.\n\t\tcurwin->w_curswant -= width2;\n\t    else\n\t    {\n\t\t\/\/ to previous line\n#ifdef FEAT_FOLDING\n\t\t\/\/ Move to the start of a closed fold.  Don't do that when\n\t\t\/\/ 'foldopen' contains \"all\": it will open in a moment.\n\t\tif (!(fdo_flags & FDO_ALL))\n\t\t    (void)hasFolding(curwin->w_cursor.lnum,\n\t\t\t\t\t\t&curwin->w_cursor.lnum, NULL);\n#endif\n\t\tif (curwin->w_cursor.lnum == 1)\n\t\t{\n\t\t    retval = FAIL;\n\t\t    break;\n\t\t}\n\t\t--curwin->w_cursor.lnum;\n\n\t\tlinelen = linetabsize(ml_get_curline());\n\t\tif (linelen > width1)\n\t\t    curwin->w_curswant += (((linelen - width1 - 1) \/ width2)\n\t\t\t\t\t\t\t\t+ 1) * width2;\n\t    }\n\t}\n\telse \/\/ dir == FORWARD\n\t{\n\t    if (linelen > width1)\n\t\tn = ((linelen - width1 - 1) \/ width2 + 1) * width2 + width1;\n\t    else\n\t\tn = width1;\n\t    if (curwin->w_curswant + width2 < (colnr_T)n\n#ifdef FEAT_FOLDING\n\t\t    && !hasFolding(curwin->w_cursor.lnum, NULL, NULL)\n#endif\n\t\t    )\n\t\t\/\/ move forward within line\n\t\tcurwin->w_curswant += width2;\n\t    else\n\t    {\n\t\t\/\/ to next line\n#ifdef FEAT_FOLDING\n\t\t\/\/ Move to the end of a closed fold.\n\t\t(void)hasFolding(curwin->w_cursor.lnum, NULL,\n\t\t\t\t\t\t      &curwin->w_cursor.lnum);\n#endif\n\t\tif (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)\n\t\t{\n\t\t    retval = FAIL;\n\t\t    break;\n\t\t}\n\t\tcurwin->w_cursor.lnum++;\n\t\tcurwin->w_curswant %= width2;\n\t\t\/\/ Check if the cursor has moved below the number display\n\t\t\/\/ when width1 < width2 (with cpoptions+=n). Subtract width2\n\t\t\/\/ to get a negative value for w_curswant, which will get\n\t\t\/\/ clipped to column 0.\n\t\tif (curwin->w_curswant >= width1)\n\t\t    curwin->w_curswant -= width2;\n\t\tlinelen = linetabsize(ml_get_curline());\n\t    }\n\t}\n      }\n    }\n\n    if (virtual_active() && atend)\n\tcoladvance(MAXCOL);\n    else\n\tcoladvance(curwin->w_curswant);\n\n    if (curwin->w_cursor.col > 0 && curwin->w_p_wrap)\n    {\n\tcolnr_T virtcol;\n\tint\tc;\n\n\t\/*\n\t * Check for landing on a character that got split at the end of the\n\t * last line.  We want to advance a screenline, not end up in the same\n\t * screenline or move two screenlines.\n\t *\/\n\tvalidate_virtcol();\n\tvirtcol = curwin->w_virtcol;\n#if defined(FEAT_LINEBREAK)\n\tif (virtcol > (colnr_T)width1 && *get_showbreak_value(curwin) != NUL)\n\t    virtcol -= vim_strsize(get_showbreak_value(curwin));\n#endif\n\n\tc = (*mb_ptr2char)(ml_get_cursor());\n\tif (dir == FORWARD && virtcol < curwin->w_curswant\n\t\t&& (curwin->w_curswant <= (colnr_T)width1)\n\t\t&& !vim_isprintc(c) && c > 255)\n\t    oneright();\n\n\tif (virtcol > curwin->w_curswant\n\t\t&& (curwin->w_curswant < (colnr_T)width1\n\t\t    ? (curwin->w_curswant > (colnr_T)width1 \/ 2)\n\t\t    : ((curwin->w_curswant - width1) % width2\n\t\t\t\t\t\t      > (colnr_T)width2 \/ 2)))\n\t    --curwin->w_cursor.col;\n    }\n\n    if (atend)\n\tcurwin->w_curswant = MAXCOL;\t    \/\/ stick in the last column\n\n    return retval;\n}","target":0,"code_token_length":1520,"total_token_length":1756,"max_tokens_setting":2048}
+{"idx":326095,"func":"regpiece(int *flagp)\n{\n    char_u\t    *ret;\n    int\t\t    op;\n    char_u\t    *next;\n    int\t\t    flags;\n    long\t    minval;\n    long\t    maxval;\n\n    ret = regatom(&flags);\n    if (ret == NULL)\n\treturn NULL;\n\n    op = peekchr();\n    if (re_multi_type(op) == NOT_MULTI)\n    {\n\t*flagp = flags;\n\treturn ret;\n    }\n    \/\/ default flags\n    *flagp = (WORST | SPSTART | (flags & (HASNL | HASLOOKBH)));\n\n    skipchr();\n    switch (op)\n    {\n\tcase Magic('*'):\n\t    if (flags & SIMPLE)\n\t\treginsert(STAR, ret);\n\t    else\n\t    {\n\t\t\/\/ Emit x* as (x&|), where & means \"self\".\n\t\treginsert(BRANCH, ret); \/\/ Either x\n\t\tregoptail(ret, regnode(BACK));\t\/\/ and loop\n\t\tregoptail(ret, ret);\t\/\/ back\n\t\tregtail(ret, regnode(BRANCH));\t\/\/ or\n\t\tregtail(ret, regnode(NOTHING)); \/\/ null.\n\t    }\n\t    break;\n\n\tcase Magic('+'):\n\t    if (flags & SIMPLE)\n\t\treginsert(PLUS, ret);\n\t    else\n\t    {\n\t\t\/\/ Emit x+ as x(&|), where & means \"self\".\n\t\tnext = regnode(BRANCH); \/\/ Either\n\t\tregtail(ret, next);\n\t\tregtail(regnode(BACK), ret);\t\/\/ loop back\n\t\tregtail(next, regnode(BRANCH)); \/\/ or\n\t\tregtail(ret, regnode(NOTHING)); \/\/ null.\n\t    }\n\t    *flagp = (WORST | HASWIDTH | (flags & (HASNL | HASLOOKBH)));\n\t    break;\n\n\tcase Magic('@'):\n\t    {\n\t\tint\tlop = END;\n\t\tlong\tnr;\n\n\t\tnr = getdecchrs();\n\t\tswitch (no_Magic(getchr()))\n\t\t{\n\t\t    case '=': lop = MATCH; break;\t\t  \/\/ \\@=\n\t\t    case '!': lop = NOMATCH; break;\t\t  \/\/ \\@!\n\t\t    case '>': lop = SUBPAT; break;\t\t  \/\/ \\@>\n\t\t    case '<': switch (no_Magic(getchr()))\n\t\t\t      {\n\t\t\t\t  case '=': lop = BEHIND; break;   \/\/ \\@<=\n\t\t\t\t  case '!': lop = NOBEHIND; break; \/\/ \\@<!\n\t\t\t      }\n\t\t}\n\t\tif (lop == END)\n\t\t    EMSG2_RET_NULL(_(e_invalid_character_after_str_at),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t\t\/\/ Look behind must match with behind_pos.\n\t\tif (lop == BEHIND || lop == NOBEHIND)\n\t\t{\n\t\t    regtail(ret, regnode(BHPOS));\n\t\t    *flagp |= HASLOOKBH;\n\t\t}\n\t\tregtail(ret, regnode(END)); \/\/ operand ends\n\t\tif (lop == BEHIND || lop == NOBEHIND)\n\t\t{\n\t\t    if (nr < 0)\n\t\t\tnr = 0; \/\/ no limit is same as zero limit\n\t\t    reginsert_nr(lop, nr, ret);\n\t\t}\n\t\telse\n\t\t    reginsert(lop, ret);\n\t\tbreak;\n\t    }\n\n\tcase Magic('?'):\n\tcase Magic('='):\n\t    \/\/ Emit x= as (x|)\n\t    reginsert(BRANCH, ret);\t\t\/\/ Either x\n\t    regtail(ret, regnode(BRANCH));\t\/\/ or\n\t    next = regnode(NOTHING);\t\t\/\/ null.\n\t    regtail(ret, next);\n\t    regoptail(ret, next);\n\t    break;\n\n\tcase Magic('{'):\n\t    if (!read_limits(&minval, &maxval))\n\t\treturn NULL;\n\t    if (flags & SIMPLE)\n\t    {\n\t\treginsert(BRACE_SIMPLE, ret);\n\t\treginsert_limits(BRACE_LIMITS, minval, maxval, ret);\n\t    }\n\t    else\n\t    {\n\t\tif (num_complex_braces >= 10)\n\t\t    EMSG2_RET_NULL(_(e_too_many_complex_str_curly),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t\treginsert(BRACE_COMPLEX + num_complex_braces, ret);\n\t\tregoptail(ret, regnode(BACK));\n\t\tregoptail(ret, ret);\n\t\treginsert_limits(BRACE_LIMITS, minval, maxval, ret);\n\t\t++num_complex_braces;\n\t    }\n\t    if (minval > 0 && maxval > 0)\n\t\t*flagp = (HASWIDTH | (flags & (HASNL | HASLOOKBH)));\n\t    break;\n    }\n    if (re_multi_type(peekchr()) != NOT_MULTI)\n    {\n\t\/\/ Can't have a multi follow a multi.\n\tif (peekchr() == Magic('*'))\n\t    EMSG2_RET_NULL(_(e_nested_str), reg_magic >= MAGIC_ON);\n\tEMSG3_RET_NULL(_(e_nested_str_chr), reg_magic == MAGIC_ALL,\n\t\t\t\t\t\t\t  no_Magic(peekchr()));\n    }\n\n    return ret;\n}","target":0,"code_token_length":1067,"total_token_length":1303,"max_tokens_setting":2048}
+{"idx":294685,"func":"rt_complete_frags(VALUE klass, VALUE hash)\n{\n    static VALUE tab = Qnil;\n    int g;\n    long e;\n    VALUE k, a, d;\n\n    if (NIL_P(tab)) {\n\ttab = f_frozen_ary(11,\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"time\"),\n\t\t\t\t      f_frozen_ary(3,\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      Qnil,\n\t\t\t\t      f_frozen_ary(1,\n\t\t\t\t\t\t  sym(\"jd\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"ordinal\"),\n\t\t\t\t      f_frozen_ary(5,\n\t\t\t\t\t\t  sym(\"year\"),\n\t\t\t\t\t\t  sym(\"yday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"civil\"),\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"year\"),\n\t\t\t\t\t\t  sym(\"mon\"),\n\t\t\t\t\t\t  sym(\"mday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"commercial\"),\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"cwyear\"),\n\t\t\t\t\t\t  sym(\"cweek\"),\n\t\t\t\t\t\t  sym(\"cwday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"wday\"),\n\t\t\t\t      f_frozen_ary(4,\n\t\t\t\t\t\t  sym(\"wday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"wnum0\"),\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"year\"),\n\t\t\t\t\t\t  sym(\"wnum0\"),\n\t\t\t\t\t\t  sym(\"wday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      sym(\"wnum1\"),\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"year\"),\n\t\t\t\t\t\t  sym(\"wnum1\"),\n\t\t\t\t\t\t  sym(\"wday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      Qnil,\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"cwyear\"),\n\t\t\t\t\t\t  sym(\"cweek\"),\n\t\t\t\t\t\t  sym(\"wday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      Qnil,\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"year\"),\n\t\t\t\t\t\t  sym(\"wnum0\"),\n\t\t\t\t\t\t  sym(\"cwday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))),\n\t\t\t  f_frozen_ary(2,\n\t\t\t\t      Qnil,\n\t\t\t\t      f_frozen_ary(6,\n\t\t\t\t\t\t  sym(\"year\"),\n\t\t\t\t\t\t  sym(\"wnum1\"),\n\t\t\t\t\t\t  sym(\"cwday\"),\n\t\t\t\t\t\t  sym(\"hour\"),\n\t\t\t\t\t\t  sym(\"min\"),\n\t\t\t\t\t\t  sym(\"sec\"))));\n\trb_gc_register_mark_object(tab);\n    }\n\n    {\n\tlong i, eno = 0, idx = 0;\n\n\tfor (i = 0; i < RARRAY_LEN(tab); i++) {\n\t    VALUE x, a;\n\n\t    x = RARRAY_AREF(tab, i);\n\t    a = RARRAY_AREF(x, 1);\n\n\t    {\n\t\tlong j, n = 0;\n\n\t\tfor (j = 0; j < RARRAY_LEN(a); j++)\n\t\t    if (!NIL_P(ref_hash0(RARRAY_AREF(a, j))))\n\t\t\tn++;\n\t\tif (n > eno) {\n\t\t    eno = n;\n\t\t    idx = i;\n\t\t}\n\t    }\n\t}\n\tif (eno == 0)\n\t    g = 0;\n\telse {\n\t    g = 1;\n\t    k = RARRAY_AREF(RARRAY_AREF(tab, idx), 0);\n\t    a = RARRAY_AREF(RARRAY_AREF(tab, idx), 1);\n\t    e =\teno;\n\t}\n    }\n\n    d = Qnil;\n\n    if (g && !NIL_P(k) && (RARRAY_LEN(a) - e)) {\n\tif (k == sym(\"ordinal\")) {\n\t    if (NIL_P(ref_hash(\"year\"))) {\n\t\tif (NIL_P(d))\n\t\t    d = date_s_today(0, (VALUE *)0, cDate);\n\t\tset_hash(\"year\", d_lite_year(d));\n\t    }\n\t    if (NIL_P(ref_hash(\"yday\")))\n\t\tset_hash(\"yday\", INT2FIX(1));\n\t}\n\telse if (k == sym(\"civil\")) {\n\t    long i;\n\n\t    for (i = 0; i < RARRAY_LEN(a); i++) {\n\t\tVALUE e = RARRAY_AREF(a, i);\n\n\t\tif (!NIL_P(ref_hash0(e)))\n\t\t    break;\n\t\tif (NIL_P(d))\n\t\t    d = date_s_today(0, (VALUE *)0, cDate);\n\t\tset_hash0(e, rb_funcall(d, SYM2ID(e), 0));\n\t    }\n\t    if (NIL_P(ref_hash(\"mon\")))\n\t\tset_hash(\"mon\", INT2FIX(1));\n\t    if (NIL_P(ref_hash(\"mday\")))\n\t\tset_hash(\"mday\", INT2FIX(1));\n\t}\n\telse if (k == sym(\"commercial\")) {\n\t    long i;\n\n\t    for (i = 0; i < RARRAY_LEN(a); i++) {\n\t\tVALUE e = RARRAY_AREF(a, i);\n\n\t\tif (!NIL_P(ref_hash0(e)))\n\t\t    break;\n\t\tif (NIL_P(d))\n\t\t    d = date_s_today(0, (VALUE *)0, cDate);\n\t\tset_hash0(e, rb_funcall(d, SYM2ID(e), 0));\n\t    }\n\t    if (NIL_P(ref_hash(\"cweek\")))\n\t\tset_hash(\"cweek\", INT2FIX(1));\n\t    if (NIL_P(ref_hash(\"cwday\")))\n\t\tset_hash(\"cwday\", INT2FIX(1));\n\t}\n\telse if (k == sym(\"wday\")) {\n\t    if (NIL_P(d))\n\t\td = date_s_today(0, (VALUE *)0, cDate);\n\t    set_hash(\"jd\", d_lite_jd(f_add(f_sub(d,\n\t\t\t\t\t\t d_lite_wday(d)),\n\t\t\t\t\t   ref_hash(\"wday\"))));\n\t}\n\telse if (k == sym(\"wnum0\")) {\n\t    long i;\n\n\t    for (i = 0; i < RARRAY_LEN(a); i++) {\n\t\tVALUE e = RARRAY_AREF(a, i);\n\n\t\tif (!NIL_P(ref_hash0(e)))\n\t\t    break;\n\t\tif (NIL_P(d))\n\t\t    d = date_s_today(0, (VALUE *)0, cDate);\n\t\tset_hash0(e, rb_funcall(d, SYM2ID(e), 0));\n\t    }\n\t    if (NIL_P(ref_hash(\"wnum0\")))\n\t\tset_hash(\"wnum0\", INT2FIX(0));\n\t    if (NIL_P(ref_hash(\"wday\")))\n\t\tset_hash(\"wday\", INT2FIX(0));\n\t}\n\telse if (k == sym(\"wnum1\")) {\n\t    long i;\n\n\t    for (i = 0; i < RARRAY_LEN(a); i++) {\n\t\tVALUE e = RARRAY_AREF(a, i);\n\n\t\tif (!NIL_P(ref_hash0(e)))\n\t\t    break;\n\t\tif (NIL_P(d))\n\t\t    d = date_s_today(0, (VALUE *)0, cDate);\n\t\tset_hash0(e, rb_funcall(d, SYM2ID(e), 0));\n\t    }\n\t    if (NIL_P(ref_hash(\"wnum1\")))\n\t\tset_hash(\"wnum1\", INT2FIX(0));\n\t    if (NIL_P(ref_hash(\"wday\")))\n\t\tset_hash(\"wday\", INT2FIX(1));\n\t}\n    }\n\n    if (g && k == sym(\"time\")) {\n\tif (f_le_p(klass, cDateTime)) {\n\t    if (NIL_P(d))\n\t\td = date_s_today(0, (VALUE *)0, cDate);\n\t    if (NIL_P(ref_hash(\"jd\")))\n\t\tset_hash(\"jd\", d_lite_jd(d));\n\t}\n    }\n\n    if (NIL_P(ref_hash(\"hour\")))\n\tset_hash(\"hour\", INT2FIX(0));\n    if (NIL_P(ref_hash(\"min\")))\n\tset_hash(\"min\", INT2FIX(0));\n    if (NIL_P(ref_hash(\"sec\")))\n\tset_hash(\"sec\", INT2FIX(0));\n    else if (f_gt_p(ref_hash(\"sec\"), INT2FIX(59)))\n\tset_hash(\"sec\", INT2FIX(59));\n\n    return hash;\n}","target":0,"code_token_length":1778,"total_token_length":2014,"max_tokens_setting":2048}
+{"idx":221123,"func":"  void DecodePngV2(OpKernelContext* context, StringPiece input) {\n    int channel_bits = (data_type_ == DataType::DT_UINT8) ? 8 : 16;\n    png::DecodeContext decode;\n    OP_REQUIRES(\n        context, png::CommonInitDecode(input, channels_, channel_bits, &decode),\n        errors::InvalidArgument(\"Invalid PNG. Failed to initialize decoder.\"));\n\n    \/\/ Verify that width and height are not too large:\n    \/\/ - verify width and height don't overflow int.\n    \/\/ - width can later be multiplied by channels_ and sizeof(uint16), so\n    \/\/   verify single dimension is not too large.\n    \/\/ - verify when width and height are multiplied together, there are a few\n    \/\/   bits to spare as well.\n    const int width = static_cast<int>(decode.width);\n    const int height = static_cast<int>(decode.height);\n    const int64_t total_size =\n        static_cast<int64_t>(width) * static_cast<int64_t>(height);\n    if (width != static_cast<int64_t>(decode.width) || width <= 0 ||\n        width >= (1LL << 27) || height != static_cast<int64_t>(decode.height) ||\n        height <= 0 || height >= (1LL << 27) || total_size >= (1LL << 29)) {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\"PNG size too large for int: \",\n                                          decode.width, \" by \", decode.height));\n    }\n\n    Tensor* output = nullptr;\n    Status status;\n    \/\/ By the existing API, we support decoding PNG with `DecodeGif` op.\n    \/\/ We need to make sure to return 4-D shapes when using `DecodeGif`.\n    if (op_type_ == \"DecodeGif\") {\n      status = context->allocate_output(\n          0, TensorShape({1, height, width, decode.channels}), &output);\n    } else {\n      status = context->allocate_output(\n          0, TensorShape({height, width, decode.channels}), &output);\n    }\n\n    if (op_type_ == \"DecodeBmp\") {\n      \/\/ TODO(b\/171060723): Only DecodeBmp as op_type_ is not acceptable here\n      \/\/ because currently `decode_(jpeg|png|gif)` ops can decode any one of\n      \/\/ jpeg, png or gif but not bmp. Similarly, `decode_bmp` cannot decode\n      \/\/ anything but bmp formats. This behavior needs to be revisited. For more\n      \/\/ details, please refer to the bug.\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"Trying to decode PNG format using DecodeBmp op. Use \"\n                      \"`decode_png` or `decode_image` instead.\"));\n    } else if (op_type_ == \"DecodeAndCropJpeg\") {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"DecodeAndCropJpeg operation can run on JPEG only, but \"\n                      \"detected PNG.\"));\n    }\n\n    if (!status.ok()) png::CommonFreeDecode(&decode);\n    OP_REQUIRES_OK(context, status);\n\n    if (data_type_ == DataType::DT_UINT8) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint8>().data()),\n              decode.channels * width * sizeof(uint8), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_UINT16) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint16>().data()),\n              decode.channels * width * sizeof(uint16), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_FLOAT) {\n      \/\/ `png::CommonFinishDecode` does not support `float`. First allocate\n      \/\/ uint16 buffer for the image and decode in uint16 (lossless). Wrap the\n      \/\/ buffer in `unique_ptr` so that we don't forget to delete the buffer.\n      std::unique_ptr<uint16[]> buffer(\n          new uint16[height * width * decode.channels]);\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(reinterpret_cast<png_bytep>(buffer.get()),\n                                  decode.channels * width * sizeof(uint16),\n                                  &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n\n      \/\/ Convert uint16 image data to desired data type.\n      \/\/ Use eigen threadpooling to speed up the copy operation.\n      const auto& device = context->eigen_device<Eigen::ThreadPoolDevice>();\n      TTypes<uint16, 3>::UnalignedConstTensor buf(buffer.get(), height, width,\n                                                  decode.channels);\n      float scale = 1. \/ std::numeric_limits<uint16>::max();\n      \/\/ Fill output tensor with desired dtype.\n      output->tensor<float, 3>().device(device) = buf.cast<float>() * scale;\n    }\n  }","target":0,"code_token_length":1103,"total_token_length":1339,"max_tokens_setting":2048}
+{"idx":234725,"func":"int btrfs_uuid_scan_kthread(void *data)\n{\n\tstruct btrfs_fs_info *fs_info = data;\n\tstruct btrfs_root *root = fs_info->tree_root;\n\tstruct btrfs_key key;\n\tstruct btrfs_path *path = NULL;\n\tint ret = 0;\n\tstruct extent_buffer *eb;\n\tint slot;\n\tstruct btrfs_root_item root_item;\n\tu32 item_size;\n\tstruct btrfs_trans_handle *trans = NULL;\n\tbool closing = false;\n\n\tpath = btrfs_alloc_path();\n\tif (!path) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tkey.objectid = 0;\n\tkey.type = BTRFS_ROOT_ITEM_KEY;\n\tkey.offset = 0;\n\n\twhile (1) {\n\t\tif (btrfs_fs_closing(fs_info)) {\n\t\t\tclosing = true;\n\t\t\tbreak;\n\t\t}\n\t\tret = btrfs_search_forward(root, &key, path,\n\t\t\t\tBTRFS_OLDEST_GENERATION);\n\t\tif (ret) {\n\t\t\tif (ret > 0)\n\t\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (key.type != BTRFS_ROOT_ITEM_KEY ||\n\t\t    (key.objectid < BTRFS_FIRST_FREE_OBJECTID &&\n\t\t     key.objectid != BTRFS_FS_TREE_OBJECTID) ||\n\t\t    key.objectid > BTRFS_LAST_FREE_OBJECTID)\n\t\t\tgoto skip;\n\n\t\teb = path->nodes[0];\n\t\tslot = path->slots[0];\n\t\titem_size = btrfs_item_size_nr(eb, slot);\n\t\tif (item_size < sizeof(root_item))\n\t\t\tgoto skip;\n\n\t\tread_extent_buffer(eb, &root_item,\n\t\t\t\t   btrfs_item_ptr_offset(eb, slot),\n\t\t\t\t   (int)sizeof(root_item));\n\t\tif (btrfs_root_refs(&root_item) == 0)\n\t\t\tgoto skip;\n\n\t\tif (!btrfs_is_empty_uuid(root_item.uuid) ||\n\t\t    !btrfs_is_empty_uuid(root_item.received_uuid)) {\n\t\t\tif (trans)\n\t\t\t\tgoto update_tree;\n\n\t\t\tbtrfs_release_path(path);\n\t\t\t\/*\n\t\t\t * 1 - subvol uuid item\n\t\t\t * 1 - received_subvol uuid item\n\t\t\t *\/\n\t\t\ttrans = btrfs_start_transaction(fs_info->uuid_root, 2);\n\t\t\tif (IS_ERR(trans)) {\n\t\t\t\tret = PTR_ERR(trans);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tgoto skip;\n\t\t}\nupdate_tree:\n\t\tbtrfs_release_path(path);\n\t\tif (!btrfs_is_empty_uuid(root_item.uuid)) {\n\t\t\tret = btrfs_uuid_tree_add(trans, root_item.uuid,\n\t\t\t\t\t\t  BTRFS_UUID_KEY_SUBVOL,\n\t\t\t\t\t\t  key.objectid);\n\t\t\tif (ret < 0) {\n\t\t\t\tbtrfs_warn(fs_info, \"uuid_tree_add failed %d\",\n\t\t\t\t\tret);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!btrfs_is_empty_uuid(root_item.received_uuid)) {\n\t\t\tret = btrfs_uuid_tree_add(trans,\n\t\t\t\t\t\t  root_item.received_uuid,\n\t\t\t\t\t\t BTRFS_UUID_KEY_RECEIVED_SUBVOL,\n\t\t\t\t\t\t  key.objectid);\n\t\t\tif (ret < 0) {\n\t\t\t\tbtrfs_warn(fs_info, \"uuid_tree_add failed %d\",\n\t\t\t\t\tret);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\nskip:\n\t\tbtrfs_release_path(path);\n\t\tif (trans) {\n\t\t\tret = btrfs_end_transaction(trans);\n\t\t\ttrans = NULL;\n\t\t\tif (ret)\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (key.offset < (u64)-1) {\n\t\t\tkey.offset++;\n\t\t} else if (key.type < BTRFS_ROOT_ITEM_KEY) {\n\t\t\tkey.offset = 0;\n\t\t\tkey.type = BTRFS_ROOT_ITEM_KEY;\n\t\t} else if (key.objectid < (u64)-1) {\n\t\t\tkey.offset = 0;\n\t\t\tkey.type = BTRFS_ROOT_ITEM_KEY;\n\t\t\tkey.objectid++;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t\tcond_resched();\n\t}\n\nout:\n\tbtrfs_free_path(path);\n\tif (trans && !IS_ERR(trans))\n\t\tbtrfs_end_transaction(trans);\n\tif (ret)\n\t\tbtrfs_warn(fs_info, \"btrfs_uuid_scan_kthread failed %d\", ret);\n\telse if (!closing)\n\t\tset_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags);\n\tup(&fs_info->uuid_tree_rescan_sem);\n\treturn 0;\n}","target":0,"code_token_length":909,"total_token_length":1145,"max_tokens_setting":2048}
+{"idx":247150,"func":"void gf_fs_print_all_connections(GF_FilterSession *session, char *filter_name, void (*print_fn)(FILE *output, GF_SysPrintArgFlags flags, const char *fmt, ...) )\n{\n\tBool found = GF_FALSE;\n\tGF_List *done;\n\tu32 i, j, count;\n\tu32 llev = gf_log_get_tool_level(GF_LOG_FILTER);\n\n\tgf_log_set_tool_level(GF_LOG_FILTER, GF_LOG_INFO);\n\t\/\/load JS to inspect its connections\n\tif (filter_name && strstr(filter_name, \".js\")) {\n\t\tgf_fs_print_jsf_connection(session, filter_name, NULL, print_fn);\n\t\tgf_log_set_tool_level(GF_LOG_FILTER, llev);\n\t\treturn;\n\t}\n\tdone = gf_list_new();\n\tcount = gf_list_count(session->links);\n\n\tfor (i=0; i<count; i++) {\n\t\tconst GF_FilterRegDesc *src = gf_list_get(session->links, i);\n\t\tif (filter_name && strcmp(src->freg->name, filter_name))\n\t\t\tcontinue;\n\n\t\tif (!src->nb_edges) {\n\t\t\tif (print_fn)\n\t\t\t\tprint_fn(stderr, 1, \"%s: no sources\\n\", src->freg->name);\n\t\t\telse {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s: no sources\\n\", src->freg->name));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tfound = GF_TRUE;\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s sources:\", src->freg->name);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s sources:\", src->freg->name));\n\t\t}\n\n\t\tfor (j=0; j<src->nb_edges; j++) {\n\t\t\tif (gf_list_find(done, (void *) src->edges[j].src_reg->freg->name)<0) {\n\t\t\t\tif (print_fn)\n\t\t\t\t\tprint_fn(stderr, 0, \" %s\", src->edges[j].src_reg->freg->name);\n\t\t\t\telse {\n\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" %s\", src->edges[j].src_reg->freg->name));\n\t\t\t\t}\n\t\t\t\tgf_list_add(done, (void *) src->edges[j].src_reg->freg->name);\n\t\t\t}\n\t\t}\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 0, \"\\n\");\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"\\n\"));\n\t\t}\n\t\tgf_list_reset(done);\n\t}\n\n\tif (found && filter_name) {\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s sinks:\", filter_name);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"%s sinks:\", filter_name));\n\t\t}\n\t\tcount = gf_list_count(session->links);\n\t\tfor (i=0; i<count; i++) {\n\t\t\tconst GF_FilterRegDesc *src = gf_list_get(session->links, i);\n\t\t\tif (!strcmp(src->freg->name, filter_name)) {\n\t\t\t\tif (!(src->freg->flags & GF_FS_REG_EXPLICIT_ONLY) || !(src->freg->flags & GF_FS_REG_ALLOW_CYCLIC))\n\t\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (j=0; j<src->nb_edges; j++) {\n\t\t\t\tif (strcmp(src->edges[j].src_reg->freg->name, filter_name)) continue;\n\n\t\t\t\tif (gf_list_find(done, (void *) src->freg->name)<0) {\n\t\t\t\t\tif (print_fn)\n\t\t\t\t\t\tprint_fn(stderr, 0, \" %s\", src->freg->name);\n\t\t\t\t\telse {\n\t\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" %s\", src->freg->name));\n\t\t\t\t\t}\n\t\t\t\t\tgf_list_add(done, (void *) src->freg->name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_list_reset(done);\n\t\t}\n\t\tif (print_fn)\n\t\t\tprint_fn(stderr, 1, \" \\n\");\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" \\n\"));\n\t\t}\n\t}\n\n\tif (!found && filter_name) {\n\t\tGF_Err e = GF_OK;\n\t\tGF_Filter *f = gf_fs_load_filter(session, filter_name, &e);\n\t\tif (f) {\n\t\t\tgf_fs_print_jsf_connection(session, filter_name, f, print_fn);\n\t\t}\n\t\telse if (print_fn)\n\t\t\tprint_fn(stderr, 1, \"%s filter not found\\n\", filter_name);\n\t\telse {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_APP, (\"%s filter not found\\n\", filter_name));\n\t\t}\n\t}\n\tgf_list_del(done);\n\tgf_log_set_tool_level(GF_LOG_FILTER, llev);\n}","target":0,"code_token_length":1023,"total_token_length":1259,"max_tokens_setting":2048}
+{"idx":384298,"func":"gs_heap_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)\n{\n    gs_malloc_memory_t *mmem = (gs_malloc_memory_t *) mem;\n    gs_malloc_block_t *bp;\n    gs_memory_type_ptr_t pstype;\n    struct_proc_finalize((*finalize));\n\n    if_debug3m('a', mem, \"[a-]gs_free(%s) 0x%lx(%u)\\n\",\n               client_name_string(cname), (ulong) ptr,\n               (ptr == 0 ? 0 : ((gs_malloc_block_t *) ptr)[-1].size));\n    if (ptr == 0)\n        return;\n    pstype = ((gs_malloc_block_t *) ptr)[-1].type;\n    finalize = pstype->finalize;\n    if (finalize != 0) {\n        if_debug3m('u', mem, \"[u]finalizing %s 0x%lx (%s)\\n\",\n                   struct_type_name_string(pstype),\n                   (ulong) ptr, client_name_string(cname));\n        (*finalize) (mem, ptr);\n    }\n    if (mmem->monitor)\n        gx_monitor_enter(mmem->monitor);\t\/* Exclusive access *\/\n    \/* Previously, we used to search through every allocated block to find\n     * the block we are freeing. This gives us safety in that an attempt to\n     * free an unallocated block will not go wrong. This does radically\n     * slow down frees though, so we replace it with this simpler code; we\n     * now assume that the block is valid, and hence avoid the search.\n     *\/\n#if 1\n    bp = &((gs_malloc_block_t *)ptr)[-1];\n    if (bp->prev)\n        bp->prev->next = bp->next;\n    if (bp->next)\n        bp->next->prev = bp->prev;\n    if (bp == mmem->allocated) {\n        mmem->allocated = bp->next;\n        mmem->allocated->prev = NULL;\n    }\n    mmem->used -= bp->size + sizeof(gs_malloc_block_t);\n    if (mmem->monitor)\n        gx_monitor_leave(mmem->monitor);\t\/* Done with exclusive access *\/\n    gs_alloc_fill(bp, gs_alloc_fill_free,\n                  bp->size + sizeof(gs_malloc_block_t));\n    free(bp);\n#else\n    bp = mmem->allocated; \/* If 'finalize' releases a memory,\n                             this function could be called recursively and\n                             change mmem->allocated. *\/\n    if (ptr == bp + 1) {\n        mmem->allocated = bp->next;\n        mmem->used -= bp->size + sizeof(gs_malloc_block_t);\n\n        if (mmem->allocated)\n            mmem->allocated->prev = 0;\n        if (mmem->monitor)\n            gx_monitor_leave(mmem->monitor);\t\/* Done with exclusive access *\/\n        gs_alloc_fill(bp, gs_alloc_fill_free,\n                      bp->size + sizeof(gs_malloc_block_t));\n        free(bp);\n    } else {\n        gs_malloc_block_t *np;\n\n        \/*\n         * bp == 0 at this point is an error, but we'd rather have an\n         * error message than an invalid access.\n         *\/\n        if (bp) {\n            for (; (np = bp->next) != 0; bp = np) {\n                if (ptr == np + 1) {\n                    bp->next = np->next;\n                    if (np->next)\n                        np->next->prev = bp;\n                    mmem->used -= np->size + sizeof(gs_malloc_block_t);\n                    if (mmem->monitor)\n                        gx_monitor_leave(mmem->monitor);\t\/* Done with exclusive access *\/\n                    gs_alloc_fill(np, gs_alloc_fill_free,\n                                  np->size + sizeof(gs_malloc_block_t));\n                    free(np);\n                    return;\n                }\n            }\n        }\n        if (mmem->monitor)\n            gx_monitor_leave(mmem->monitor);\t\/* Done with exclusive access *\/\n        lprintf2(\"%s: free 0x%lx not found!\\n\",\n                 client_name_string(cname), (ulong) ptr);\n        free((char *)((gs_malloc_block_t *) ptr - 1));\n    }\n#endif\n}","target":0,"code_token_length":883,"total_token_length":1119,"max_tokens_setting":2048}
+{"idx":231061,"func":"BaseType_t xQueueGenericSend( QueueHandle_t xQueue,\r\n                              const void * const pvItemToQueue,\r\n                              TickType_t xTicksToWait,\r\n                              const BaseType_t xCopyPosition )\r\n{\r\n    BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired;\r\n    TimeOut_t xTimeOut;\r\n    Queue_t * const pxQueue = xQueue;\r\n\r\n    configASSERT( pxQueue );\r\n    configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r\n    configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r\n    #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r\n        {\r\n            configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r\n        }\r\n    #endif\r\n\r\n    \/*lint -save -e904 This function relaxes the coding standard somewhat to\r\n     * allow return statements within the function itself.  This is done in the\r\n     * interest of execution time efficiency. *\/\r\n    for( ; ; )\r\n    {\r\n        taskENTER_CRITICAL();\r\n        {\r\n            \/* Is there room on the queue now?  The running task must be the\r\n             * highest priority task wanting to access the queue.  If the head item\r\n             * in the queue is to be overwritten then it does not matter if the\r\n             * queue is full. *\/\r\n            if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r\n            {\r\n                traceQUEUE_SEND( pxQueue );\r\n\r\n                #if ( configUSE_QUEUE_SETS == 1 )\r\n                    {\r\n                        const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;\r\n\r\n                        xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r\n\r\n                        if( pxQueue->pxQueueSetContainer != NULL )\r\n                        {\r\n                            if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )\r\n                            {\r\n                                \/* Do not notify the queue set as an existing item\r\n                                 * was overwritten in the queue so the number of items\r\n                                 * in the queue has not changed. *\/\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                            else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )\r\n                            {\r\n                                \/* The queue is a member of a queue set, and posting\r\n                                 * to the queue set caused a higher priority task to\r\n                                 * unblock. A context switch is required. *\/\r\n                                queueYIELD_IF_USING_PREEMPTION();\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                        else\r\n                        {\r\n                            \/* If there was a task waiting for data to arrive on the\r\n                             * queue then unblock it now. *\/\r\n                            if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                            {\r\n                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                                {\r\n                                    \/* The unblocked task has a priority higher than\r\n                                     * our own so yield immediately.  Yes it is ok to\r\n                                     * do this from within the critical section - the\r\n                                     * kernel takes care of that. *\/\r\n                                    queueYIELD_IF_USING_PREEMPTION();\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else if( xYieldRequired != pdFALSE )\r\n                            {\r\n                                \/* This path is a special case that will only get\r\n                                 * executed if the task was holding multiple mutexes\r\n                                 * and the mutexes were given back in an order that is\r\n                                 * different to that in which they were taken. *\/\r\n                                queueYIELD_IF_USING_PREEMPTION();\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                    }\r\n                #else \/* configUSE_QUEUE_SETS *\/\r\n                    {\r\n                        xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r\n\r\n                        \/* If there was a task waiting for data to arrive on the\r\n                         * queue then unblock it now. *\/\r\n                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                        {\r\n                            if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                            {\r\n                                \/* The unblocked task has a priority higher than\r\n                                 * our own so yield immediately.  Yes it is ok to do\r\n                                 * this from within the critical section - the kernel\r\n                                 * takes care of that. *\/\r\n                                queueYIELD_IF_USING_PREEMPTION();\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                        else if( xYieldRequired != pdFALSE )\r\n                        {\r\n                            \/* This path is a special case that will only get\r\n                             * executed if the task was holding multiple mutexes and\r\n                             * the mutexes were given back in an order that is\r\n                             * different to that in which they were taken. *\/\r\n                            queueYIELD_IF_USING_PREEMPTION();\r\n                        }\r\n                        else\r\n                        {\r\n                            mtCOVERAGE_TEST_MARKER();\r\n                        }\r\n                    }\r\n                #endif \/* configUSE_QUEUE_SETS *\/\r\n\r\n                taskEXIT_CRITICAL();\r\n                return pdPASS;\r\n            }\r\n            else\r\n            {\r\n                if( xTicksToWait == ( TickType_t ) 0 )\r\n                {\r\n                    \/* The queue was full and no block time is specified (or\r\n                     * the block time has expired) so leave now. *\/\r\n                    taskEXIT_CRITICAL();\r\n\r\n                    \/* Return to the original privilege level before exiting\r\n                     * the function. *\/\r\n                    traceQUEUE_SEND_FAILED( pxQueue );\r\n                    return errQUEUE_FULL;\r\n                }\r\n                else if( xEntryTimeSet == pdFALSE )\r\n                {\r\n                    \/* The queue was full and a block time was specified so\r\n                     * configure the timeout structure. *\/\r\n                    vTaskInternalSetTimeOutState( &xTimeOut );\r\n                    xEntryTimeSet = pdTRUE;\r\n                }\r\n                else\r\n                {\r\n                    \/* Entry time was already set. *\/\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n            }\r\n        }\r\n        taskEXIT_CRITICAL();\r\n\r\n        \/* Interrupts and other tasks can send to and receive from the queue\r\n         * now the critical section has been exited. *\/\r\n\r\n        vTaskSuspendAll();\r\n        prvLockQueue( pxQueue );\r\n\r\n        \/* Update the timeout state to see if it has expired yet. *\/\r\n        if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r\n        {\r\n            if( prvIsQueueFull( pxQueue ) != pdFALSE )\r\n            {\r\n                traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r\n                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r\n\r\n                \/* Unlocking the queue means queue events can effect the\r\n                 * event list.  It is possible that interrupts occurring now\r\n                 * remove this task from the event list again - but as the\r\n                 * scheduler is suspended the task will go onto the pending\r\n                 * ready last instead of the actual ready list. *\/\r\n                prvUnlockQueue( pxQueue );\r\n\r\n                \/* Resuming the scheduler will move tasks from the pending\r\n                 * ready list into the ready list - so it is feasible that this\r\n                 * task is already in a ready list before it yields - in which\r\n                 * case the yield will not cause a context switch unless there\r\n                 * is also a higher priority task in the pending ready list. *\/\r\n                if( xTaskResumeAll() == pdFALSE )\r\n                {\r\n                    portYIELD_WITHIN_API();\r\n                }\r\n            }\r\n            else\r\n            {\r\n                \/* Try again. *\/\r\n                prvUnlockQueue( pxQueue );\r\n                ( void ) xTaskResumeAll();\r\n            }\r\n        }\r\n        else\r\n        {\r\n            \/* The timeout has expired. *\/\r\n            prvUnlockQueue( pxQueue );\r\n            ( void ) xTaskResumeAll();\r\n\r\n            traceQUEUE_SEND_FAILED( pxQueue );\r\n            return errQUEUE_FULL;\r\n        }\r\n    } \/*lint -restore *\/\r\n}\r","target":0,"code_token_length":1749,"total_token_length":1985,"max_tokens_setting":2048}
+{"idx":432727,"func":"static void util_set_pen(wmfAPI * API, wmfDC * dc)\n{\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  wmfPen\n    *pen = 0;\n\n  double\n    pen_width,\n    pixel_width;\n\n  unsigned int\n    pen_style;\n\n  pen = WMF_DC_PEN(dc);\n\n  pen_width = (WMF_PEN_WIDTH(pen) + WMF_PEN_HEIGHT(pen)) \/ 2;\n\n  \/* Pixel width is inverse of pixel scale *\/\n  pixel_width = (((double) 1 \/ (ddata->scale_x)) +\n                 ((double) 1 \/ (ddata->scale_y))) \/ 2;\n\n  \/* Don't allow pen_width to be much less than pixel_width in order\n     to avoid dissapearing or spider-web lines *\/\n  pen_width = MagickMax(pen_width, pixel_width*0.8);\n\n  pen_style = (unsigned int) WMF_PEN_STYLE(pen);\n\n  \/* Pen style specified? *\/\n  if (pen_style == PS_NULL)\n    {\n      draw_stroke_color_string(WmfDrawingWand,\"none\");\n      return;\n    }\n\n  DrawSetStrokeAntialias(WmfDrawingWand, MagickTrue );\n  DrawSetStrokeWidth(WmfDrawingWand, (unsigned long) MagickMax(0.0, pen_width));\n\n  {\n    LineCap\n      linecap;\n\n    switch ((unsigned int) WMF_PEN_ENDCAP(pen))\n      {\n      case PS_ENDCAP_SQUARE:\n        linecap = SquareCap;\n        break;\n      case PS_ENDCAP_ROUND:\n        linecap = RoundCap;\n        break;\n      case PS_ENDCAP_FLAT:\n      default:\n        linecap = ButtCap;\n        break;\n      }\n    DrawSetStrokeLineCap(WmfDrawingWand, linecap);\n  }\n\n  {\n    LineJoin\n      linejoin;\n\n    switch ((unsigned int) WMF_PEN_JOIN(pen))\n      {\n      case PS_JOIN_BEVEL:\n        linejoin = BevelJoin;\n        break;\n      case PS_JOIN_ROUND:\n        linejoin = RoundJoin;\n        break;\n      case PS_JOIN_MITER:\n      default:\n        linejoin = MiterJoin;\n        break;\n      }\n    DrawSetStrokeLineJoin(WmfDrawingWand,linejoin);\n  }\n\n  {\n    double\n      dasharray[7];\n\n    switch (pen_style)\n      {\n      case PS_DASH:    \/* -------  *\/\n        {\n          \/* Pattern 18,7 *\/\n          dasharray[0] = pixel_width * 18;\n          dasharray[1] = pixel_width * 7;\n          dasharray[2] = 0;\n\n          DrawSetStrokeAntialias(WmfDrawingWand,MagickFalse);\n          (void) DrawSetStrokeDashArray(WmfDrawingWand,2,dasharray);\n          break;\n        }\n      case PS_ALTERNATE:\n      case PS_DOT:    \/* .......  *\/\n        {\n          \/* Pattern 3,3 *\/\n          dasharray[0] = pixel_width * 3;\n          dasharray[1] = pixel_width * 3;\n          dasharray[2] = 0;\n\n          DrawSetStrokeAntialias(WmfDrawingWand,MagickFalse);\n          (void) DrawSetStrokeDashArray(WmfDrawingWand,2,dasharray);\n          break;\n        }\n      case PS_DASHDOT:    \/* _._._._  *\/\n        {\n          \/* Pattern 9,6,3,6 *\/\n          dasharray[0] = pixel_width * 9;\n          dasharray[1] = pixel_width * 6;\n          dasharray[2] = pixel_width * 3;\n          dasharray[3] = pixel_width * 6;\n          dasharray[4] = 0;\n\n          DrawSetStrokeAntialias(WmfDrawingWand,MagickFalse);\n          (void) DrawSetStrokeDashArray(WmfDrawingWand,4,dasharray);\n          break;\n        }\n      case PS_DASHDOTDOT:  \/* _.._.._  *\/\n        {\n          \/* Pattern 9,3,3,3,3,3 *\/\n          dasharray[0] = pixel_width * 9;\n          dasharray[1] = pixel_width * 3;\n          dasharray[2] = pixel_width * 3;\n          dasharray[3] = pixel_width * 3;\n          dasharray[4] = pixel_width * 3;\n          dasharray[5] = pixel_width * 3;\n          dasharray[6] = 0;\n\n          DrawSetStrokeAntialias(WmfDrawingWand,MagickFalse);\n          (void) DrawSetStrokeDashArray(WmfDrawingWand,6,dasharray);\n          break;\n        }\n      case PS_INSIDEFRAME:  \/* There is nothing to do in this case... *\/\n      case PS_SOLID:\n      default:\n        {\n          (void) DrawSetStrokeDashArray(WmfDrawingWand,0,(double *) NULL);\n          break;\n        }\n      }\n  }\n\n  draw_stroke_color_rgb(API,WMF_PEN_COLOR(pen));\n}","target":0,"code_token_length":1087,"total_token_length":1323,"max_tokens_setting":2048}
+{"idx":275950,"func":"static void XYcZ_addC(uECC_word_t * X1,\n                      uECC_word_t * Y1,\n                      uECC_word_t * X2,\n                      uECC_word_t * Y2,\n                      uECC_Curve curve) {\n    \/* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 *\/\n    uECC_word_t t5[uECC_MAX_WORDS];\n    uECC_word_t t6[uECC_MAX_WORDS];\n    uECC_word_t t7[uECC_MAX_WORDS];\n    wordcount_t num_words = curve->num_words;\n\n    uECC_vli_modSub(t5, X2, X1, curve->p, num_words); \/* t5 = x2 - x1 *\/\n    uECC_vli_modSquare_fast(t5, t5, curve);                  \/* t5 = (x2 - x1)^2 = A *\/\n    uECC_vli_modMult_fast(X1, X1, t5, curve);                \/* t1 = x1*A = B *\/\n    uECC_vli_modMult_fast(X2, X2, t5, curve);                \/* t3 = x2*A = C *\/\n    uECC_vli_modAdd(t5, Y2, Y1, curve->p, num_words); \/* t5 = y2 + y1 *\/\n    uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); \/* t4 = y2 - y1 *\/\n\n    uECC_vli_modSub(t6, X2, X1, curve->p, num_words); \/* t6 = C - B *\/\n    uECC_vli_modMult_fast(Y1, Y1, t6, curve);                \/* t2 = y1 * (C - B) = E *\/\n    uECC_vli_modAdd(t6, X1, X2, curve->p, num_words); \/* t6 = B + C *\/\n    uECC_vli_modSquare_fast(X2, Y2, curve);                  \/* t3 = (y2 - y1)^2 = D *\/\n    uECC_vli_modSub(X2, X2, t6, curve->p, num_words); \/* t3 = D - (B + C) = x3 *\/\n\n    uECC_vli_modSub(t7, X1, X2, curve->p, num_words); \/* t7 = B - x3 *\/\n    uECC_vli_modMult_fast(Y2, Y2, t7, curve);                \/* t4 = (y2 - y1)*(B - x3) *\/\n    uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); \/* t4 = (y2 - y1)*(B - x3) - E = y3 *\/\n\n    uECC_vli_modSquare_fast(t7, t5, curve);                  \/* t7 = (y2 + y1)^2 = F *\/\n    uECC_vli_modSub(t7, t7, t6, curve->p, num_words); \/* t7 = F - (B + C) = x3' *\/\n    uECC_vli_modSub(t6, t7, X1, curve->p, num_words); \/* t6 = x3' - B *\/\n    uECC_vli_modMult_fast(t6, t6, t5, curve);                \/* t6 = (y2+y1)*(x3' - B) *\/\n    uECC_vli_modSub(Y1, t6, Y1, curve->p, num_words); \/* t2 = (y2+y1)*(x3' - B) - E = y3' *\/\n\n    uECC_vli_set(X1, t7, num_words);\n}","target":0,"code_token_length":830,"total_token_length":1066,"max_tokens_setting":2048}
+{"idx":197239,"func":"  void Compute(OpKernelContext* ctx) override {\n    try {\n      const Tensor& input = ctx->input(kInputTensorIndex);\n      const Tensor& input_min_vec = ctx->input(kInputMinVecIndex);\n      float* input_min_vec_data = (float*)const_cast<void*>(\n          static_cast<const void*>(input_min_vec.flat<float>().data()));\n      const Tensor& input_max_vec = ctx->input(kInputMaxVecIndex);\n      float* input_max_vec_data = (float*)const_cast<void*>(\n          static_cast<const void*>(input_max_vec.flat<float>().data()));\n\n      const Tensor& input_requested_min = ctx->input(this->kRequestMinIndex);\n      const float input_requested_min_float =\n          input_requested_min.flat<float>()(0);\n      const Tensor& input_requested_max = ctx->input(this->kRequestMaxIndex);\n      const float input_requested_max_float =\n          input_requested_max.flat<float>()(0);\n\n      size_t depth = input_min_vec.NumElements();\n      OP_REQUIRES(\n          ctx, input.dims() == 4,\n          errors::InvalidArgument(\"Current RequantizePerChannel operator\"\n                                  \"supports 4D tensors only.\"));\n      OP_REQUIRES(\n          ctx, input_min_vec.dim_size(0) == depth,\n          errors::InvalidArgument(\"input_min has incorrect size, expected \",\n                                  depth, \" was \", input_min_vec.dim_size(0)));\n      OP_REQUIRES(\n          ctx, input_max_vec.dim_size(0) == depth,\n          errors::InvalidArgument(\"input_max has incorrect size, expected \",\n                                  depth, \" was \", input_max_vec.dim_size(0)));\n\n      if (out_type_ == DT_QINT8) DCHECK(input_requested_min_float < 0.0f);\n\n      const float factor = (out_type_ == DT_QINT8) ? 127.0f : 255.0f;\n      const float requested_min_max =\n          std::max(std::abs(input_requested_min_float),\n                   std::abs(input_requested_max_float));\n      Tensor* output = nullptr;\n      OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputTensorIndex,\n                                               input.shape(), &output));\n\n      std::vector<float> scales(depth);\n      for (int i = 0; i < depth; ++i) {\n        float min_max_from_vec = std::max(std::abs(input_min_vec_data[i]),\n                                          std::abs(input_max_vec_data[i]));\n        scales[i] = factor * (min_max_from_vec \/ requested_min_max \/\n                              static_cast<float>(1L << 31));\n      }\n\n      mkldnn::primitive_attr reorder_attr;\n      reorder_attr.set_output_scales(2, scales);\n\n      memory::dims dims_mkl_order =\n          TFShapeToMklDnnDimsInNCHW(input.shape(), FORMAT_NHWC);\n      memory::desc input_md = memory::desc(dims_mkl_order, MklDnnType<qint32>(),\n                                           memory::format_tag::nhwc);\n      memory::desc output_md =\n          (out_type_ == DT_QINT8)\n              ? memory::desc(dims_mkl_order, MklDnnType<qint8>(),\n                             memory::format_tag::nhwc)\n              : memory::desc(dims_mkl_order, MklDnnType<quint8>(),\n                             memory::format_tag::nhwc);\n\n      void* input_buf =\n          static_cast<void*>(const_cast<qint32*>(input.flat<qint32>().data()));\n      void* output_buf;\n      if (out_type_ == DT_QINT8) {\n        output_buf = static_cast<void*>(\n            const_cast<qint8*>(output->flat<qint8>().data()));\n      } else {\n        output_buf = static_cast<void*>(\n            const_cast<quint8*>(output->flat<quint8>().data()));\n      }\n\n      std::unique_ptr<memory> input_mem_prim(\n          new memory(input_md, cpu_engine_, input_buf));\n      std::unique_ptr<memory> output_mem_prim(\n          new memory(output_md, cpu_engine_, output_buf));\n\n      mkldnn::reorder::primitive_desc reorder_pd =\n          ReorderPd(cpu_engine_, input_mem_prim->get_desc(), cpu_engine_,\n                    output_mem_prim->get_desc(), reorder_attr);\n      std::shared_ptr<stream> reorder_stream;\n      MklDnnThreadPool eigen_tp(ctx);\n      reorder_stream.reset(CreateStream(&eigen_tp, cpu_engine_));\n      std::unordered_map<int, mkldnn::memory> reorder_args = {\n          {MKLDNN_ARG_FROM, *input_mem_prim},\n          {MKLDNN_ARG_TO, *output_mem_prim}};\n      std::unique_ptr<mkldnn::primitive> reorder_prim(\n          new mkldnn::reorder(reorder_pd));\n      reorder_prim->execute(*reorder_stream, reorder_args);\n\n      Tensor* output_min = nullptr;\n      Tensor* output_max = nullptr;\n      OP_REQUIRES_OK(ctx,\n                     ctx->allocate_output(kOutputMinIndex, {}, &output_min));\n      OP_REQUIRES_OK(ctx,\n                     ctx->allocate_output(kOutputMaxIndex, {}, &output_max));\n\n      output_min->flat<float>()(0) = input_requested_min_float;\n      output_max->flat<float>()(0) = input_requested_max_float;\n    } catch (mkldnn::error& e) {\n      string error_msg = \"Status: \" + std::to_string(e.status) +\n                         \", message: \" + std::string(e.message) + \", in file \" +\n                         std::string(__FILE__) + \":\" + std::to_string(__LINE__);\n      OP_REQUIRES_OK(\n          ctx, errors::Aborted(\"Operation received an exception:\", error_msg));\n    }\n  }","target":1,"code_token_length":1204,"total_token_length":1440,"max_tokens_setting":2048}
+{"idx":219907,"func":"GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, GF_ISOTrackID SourceTrackID, u32 SampleNumber, u16 DataLength, u32 offsetInSample, u8 *extra_data, u8 AtBegin)\n{\n\tGF_TrackBox *trak;\n\tGF_HintSampleEntryBox *entry;\n\tu32 count;\n\tu16 refIndex;\n\tGF_HintPacket *pck;\n\tGF_SampleDTE *dte;\n\tGF_Err e;\n\tGF_TrackReferenceTypeBox *hint;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM;\n\n\n\te = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count);\n\tif (e) return e;\n\tif (!entry->hint_sample) return GF_BAD_PARAM;\n\tcount = gf_list_count(entry->hint_sample->packetTable);\n\tif (!count) return GF_BAD_PARAM;\n\tpck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1);\n\n\tdte = (GF_SampleDTE *) NewDTE(2);\n\n\tdte->dataLength = DataLength;\n\tdte->sampleNumber = SampleNumber;\n\tdte->byteOffset = offsetInSample;\n\n\t\/\/we're getting data from another track\n\tif (SourceTrackID != trak->Header->trackID) {\n\t\t\/\/get (or set) the track reference index\n\t\te = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint);\n\t\tif (e) return e;\n\t\te = reftype_AddRefTrack(hint, SourceTrackID, &refIndex);\n\t\tif (e) return e;\n\t\t\/\/WARNING: IN QT, MUST BE 0-based !!!\n\t\tdte->trackRefIndex = (u8) (refIndex - 1);\n\t} else {\n\t\t\/\/we're in the hint track\n\t\tdte->trackRefIndex = (s8) -1;\n\t\t\/\/basic check...\n\t\tif (SampleNumber > trak->Media->information->sampleTable->SampleSize->sampleCount + 1) {\n\t\t\tDelDTE((GF_GenericDTE *)dte);\n\t\t\treturn GF_BAD_PARAM;\n\t\t}\n\n\t\t\/\/are we in the current sample ??\n\t\tif (!SampleNumber || (SampleNumber == trak->Media->information->sampleTable->SampleSize->sampleCount + 1)) {\n\t\t\t\/\/we adding some stuff in the current sample ...\n\t\t\tdte->byteOffset += entry->hint_sample->dataLength;\n\t\t\tentry->hint_sample->AdditionalData = (char*)gf_realloc(entry->hint_sample->AdditionalData, sizeof(char) * (entry->hint_sample->dataLength + DataLength));\n\t\t\tif (AtBegin) {\n\t\t\t\tif (entry->hint_sample->dataLength)\n\t\t\t\t\tmemmove(entry->hint_sample->AdditionalData + DataLength, entry->hint_sample->AdditionalData, entry->hint_sample->dataLength);\n\t\t\t\tmemcpy(entry->hint_sample->AdditionalData, extra_data, DataLength);\n\t\t\t\t\/*offset existing DTE*\/\n\t\t\t\tgf_isom_hint_pck_offset(pck, DataLength, SampleNumber);\n\t\t\t} else {\n\t\t\t\tmemcpy(entry->hint_sample->AdditionalData + entry->hint_sample->dataLength, extra_data, DataLength);\n\t\t\t}\n\t\t\tentry->hint_sample->dataLength += DataLength;\n\t\t\t\/\/and set the sample number ...\n\t\t\tdte->sampleNumber = trak->Media->information->sampleTable->SampleSize->sampleCount + 1;\n\t\t}\n\t}\n\t\/\/OK, add the entry\n\treturn gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin);\n}","target":0,"code_token_length":828,"total_token_length":1064,"max_tokens_setting":2048}
+{"idx":416364,"func":"may_adjust_incsearch_highlighting(\n\tint\t\t\tfirstc,\n\tlong\t\t\tcount,\n\tincsearch_state_T\t*is_state,\n\tint\t\t\tc)\n{\n    int\t    skiplen, patlen;\n    pos_T   t;\n    char_u  *pat;\n    int\t    search_flags = SEARCH_NOOF;\n    int\t    i;\n    int\t    save;\n    int\t    search_delim;\n\n    \/\/ Parsing range may already set the last search pattern.\n    \/\/ NOTE: must call restore_last_search_pattern() before returning!\n    save_last_search_pattern();\n\n    if (!do_incsearch_highlighting(firstc, &search_delim, is_state,\n\t\t\t\t\t\t\t    &skiplen, &patlen))\n    {\n\trestore_last_search_pattern();\n\treturn OK;\n    }\n    if (patlen == 0 && ccline.cmdbuff[skiplen] == NUL)\n    {\n\trestore_last_search_pattern();\n\treturn FAIL;\n    }\n\n    if (search_delim == ccline.cmdbuff[skiplen])\n    {\n\tpat = last_search_pattern();\n\tif (pat == NULL)\n\t{\n\t    restore_last_search_pattern();\n\t    return FAIL;\n\t}\n\tskiplen = 0;\n\tpatlen = (int)STRLEN(pat);\n    }\n    else\n\tpat = ccline.cmdbuff + skiplen;\n\n    cursor_off();\n    out_flush();\n    if (c == Ctrl_G)\n    {\n\tt = is_state->match_end;\n\tif (LT_POS(is_state->match_start, is_state->match_end))\n\t    \/\/ Start searching at the end of the match not at the beginning of\n\t    \/\/ the next column.\n\t    (void)decl(&t);\n\tsearch_flags += SEARCH_COL;\n    }\n    else\n\tt = is_state->match_start;\n    if (!p_hls)\n\tsearch_flags += SEARCH_KEEP;\n    ++emsg_off;\n    save = pat[patlen];\n    pat[patlen] = NUL;\n    i = searchit(curwin, curbuf, &t, NULL,\n\t\t c == Ctrl_G ? FORWARD : BACKWARD,\n\t\t pat, count, search_flags, RE_SEARCH, NULL);\n    --emsg_off;\n    pat[patlen] = save;\n    if (i)\n    {\n\tis_state->search_start = is_state->match_start;\n\tis_state->match_end = t;\n\tis_state->match_start = t;\n\tif (c == Ctrl_T && firstc != '?')\n\t{\n\t    \/\/ Move just before the current match, so that when nv_search\n\t    \/\/ finishes the cursor will be put back on the match.\n\t    is_state->search_start = t;\n\t    (void)decl(&is_state->search_start);\n\t}\n\telse if (c == Ctrl_G && firstc == '?')\n\t{\n\t    \/\/ Move just after the current match, so that when nv_search\n\t    \/\/ finishes the cursor will be put back on the match.\n\t    is_state->search_start = t;\n\t    (void)incl(&is_state->search_start);\n\t}\n\tif (LT_POS(t, is_state->search_start) && c == Ctrl_G)\n\t{\n\t    \/\/ wrap around\n\t    is_state->search_start = t;\n\t    if (firstc == '?')\n\t\t(void)incl(&is_state->search_start);\n\t    else\n\t\t(void)decl(&is_state->search_start);\n\t}\n\n\tset_search_match(&is_state->match_end);\n\tcurwin->w_cursor = is_state->match_start;\n\tchanged_cline_bef_curs();\n\tupdate_topline();\n\tvalidate_cursor();\n\thighlight_match = TRUE;\n\tsave_viewstate(&is_state->old_viewstate);\n\tupdate_screen(UPD_NOT_VALID);\n\thighlight_match = FALSE;\n\tredrawcmdline();\n\tcurwin->w_cursor = is_state->match_end;\n    }\n    else\n\tvim_beep(BO_ERROR);\n    restore_last_search_pattern();\n    return FAIL;\n}","target":0,"code_token_length":805,"total_token_length":1041,"max_tokens_setting":2048}
+{"idx":473864,"func":"uniname2ctype_hash (str, len)\n     register const char *str;\n     register unsigned int len;\n{\n#ifndef USE_UNICODE_PROPERTIES\n  static const unsigned char asso_values[] =\n#else \/* USE_UNICODE_PROPERTIES *\/\n  static const unsigned short asso_values[] =\n#endif \/* USE_UNICODE_PROPERTIES *\/\n    {\n#ifndef USE_UNICODE_PROPERTIES\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n      22, 22, 22, 22, 22, 22, 22,  3, 13,  6,\n       4, 22, 22, 11, 22,  1, 22, 22, 10, 22,\n       2, 22,  1, 22, 10,  8,  4,  7, 22,  3,\n       4, 22, 22, 22, 22, 22, 22, 22\n#else \/* USE_UNICODE_PROPERTIES *\/\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742,    2, 1742,    9,    1,\n         2,   18,    5,    3,    4, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742,\n      1742, 1742, 1742, 1742, 1742, 1742, 1742,    8,  280,    6,\n        96,   67,  362,  294,   38,    9,   63,  517,    2,  213,\n         1,    4,  192,    3,   10,   57,   31,  316,    1,  549,\n       330,  567,   36, 1742, 1742, 1742, 1742, 1742\n#endif \/* USE_UNICODE_PROPERTIES *\/\n    };\n#ifndef USE_UNICODE_PROPERTIES\n  return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]];\n#else \/* USE_UNICODE_PROPERTIES *\/\n  register int hval = len;\n\n  switch (hval)\n    {\n      default:\n        hval += asso_values[(unsigned char)str[15]];\n      \/*FALLTHROUGH*\/\n      case 15:\n      case 14:\n      case 13:\n      case 12:\n        hval += asso_values[(unsigned char)str[11]];\n      \/*FALLTHROUGH*\/\n      case 11:\n      case 10:\n      case 9:\n      case 8:\n      case 7:\n      case 6:\n        hval += asso_values[(unsigned char)str[5]];\n      \/*FALLTHROUGH*\/\n      case 5:\n        hval += asso_values[(unsigned char)str[4]];\n      \/*FALLTHROUGH*\/\n      case 4:\n      case 3:\n        hval += asso_values[(unsigned char)str[2]];\n      \/*FALLTHROUGH*\/\n      case 2:\n        hval += asso_values[(unsigned char)str[1]];\n      \/*FALLTHROUGH*\/\n      case 1:\n        hval += asso_values[(unsigned char)str[0]];\n        break;\n    }\n  return hval + asso_values[(unsigned char)str[len - 1]];\n#endif \/* USE_UNICODE_PROPERTIES *\/\n}","target":0,"code_token_length":1659,"total_token_length":1895,"max_tokens_setting":2048}
+{"idx":415195,"func":"update_reader_status_file (int set_card_removed_flag)\n{\n  int idx;\n  unsigned int status, changed;\n\n  \/* Note, that we only try to get the status, because it does not\n     make sense to wait here for a operation to complete.  If we are\n     busy working with a card, delays in the status file update should\n     be acceptable. *\/\n  for (idx=0; idx < DIM(vreader_table); idx++)\n    {\n      struct vreader_s *vr = vreader_table + idx;\n      struct server_local_s *sl;\n      int sw_apdu;\n\n      if (!vr->valid || vr->slot == -1)\n        continue; \/* Not valid or reader not yet open. *\/\n\n      sw_apdu = apdu_get_status (vr->slot, 0, &status, &changed);\n      if (sw_apdu == SW_HOST_NO_READER)\n        {\n          \/* Most likely the _reader_ has been unplugged.  *\/\n          application_notify_card_reset (vr->slot);\n\t  apdu_close_reader (vr->slot);\n          vr->slot = -1;\n          status = 0;\n          changed = vr->changed;\n        }\n      else if (sw_apdu)\n        {\n          \/* Get status failed.  Ignore that.  *\/\n          continue;\n        }\n\n      if (!vr->any || vr->status != status || vr->changed != changed )\n        {\n          char *fname;\n          char templ[50];\n          FILE *fp;\n\n          log_info (\"updating reader %d (%d) status: 0x%04X->0x%04X (%u->%u)\\n\",\n                    idx, vr->slot, vr->status, status, vr->changed, changed);\n          vr->status = status;\n          vr->changed = changed;\n\n\t  \/* FIXME: Should this be IDX instead of vr->slot?  This\n\t     depends on how client sessions will associate the reader\n\t     status with their session.  *\/\n          snprintf (templ, sizeof templ, \"reader_%d.status\", vr->slot);\n          fname = make_filename (opt.homedir, templ, NULL );\n          fp = fopen (fname, \"w\");\n          if (fp)\n            {\n              fprintf (fp, \"%s\\n\",\n                       (status & 1)? \"USABLE\":\n                       (status & 4)? \"ACTIVE\":\n                       (status & 2)? \"PRESENT\": \"NOCARD\");\n              fclose (fp);\n            }\n          xfree (fname);\n\n          \/* If a status script is executable, run it. *\/\n          {\n            const char *args[9], *envs[2];\n            char numbuf1[30], numbuf2[30], numbuf3[30];\n            char *homestr, *envstr;\n            gpg_error_t err;\n\n            homestr = make_filename (opt.homedir, NULL);\n            if (gpgrt_asprintf (&envstr, \"GNUPGHOME=%s\", homestr) < 0)\n              log_error (\"out of core while building environment\\n\");\n            else\n              {\n                envs[0] = envstr;\n                envs[1] = NULL;\n\n                sprintf (numbuf1, \"%d\", vr->slot);\n                sprintf (numbuf2, \"0x%04X\", vr->status);\n                sprintf (numbuf3, \"0x%04X\", status);\n                args[0] = \"--reader-port\";\n                args[1] = numbuf1;\n                args[2] = \"--old-code\";\n                args[3] = numbuf2;\n                args[4] = \"--new-code\";\n                args[5] = numbuf3;\n                args[6] = \"--status\";\n                args[7] = ((status & 1)? \"USABLE\":\n                           (status & 4)? \"ACTIVE\":\n                           (status & 2)? \"PRESENT\": \"NOCARD\");\n                args[8] = NULL;\n\n                fname = make_filename (opt.homedir, \"scd-event\", NULL);\n                err = gnupg_spawn_process_detached (fname, args, envs);\n                if (err && gpg_err_code (err) != GPG_ERR_ENOENT)\n                  log_error (\"failed to run event handler '%s': %s\\n\",\n                             fname, gpg_strerror (err));\n                xfree (fname);\n                xfree (envstr);\n              }\n            xfree (homestr);\n          }\n\n          \/* Set the card removed flag for all current sessions.  *\/\n          if (vr->any && vr->status == 0 && set_card_removed_flag)\n            update_card_removed (idx, 1);\n\n          vr->any = 1;\n\n          \/* Send a signal to all clients who applied for it.  *\/\n          send_client_notifications ();\n        }\n\n      \/* Check whether a disconnect is pending.  *\/\n      if (opt.card_timeout)\n        {\n          for (sl=session_list; sl; sl = sl->next_session)\n            if (!sl->disconnect_allowed)\n              break;\n          if (session_list && !sl)\n            {\n              \/* FIXME: Use a real timeout.  *\/\n              \/* At least one connection and all allow a disconnect.  *\/\n              log_info (\"disconnecting card in reader %d (%d)\\n\",\n                        idx, vr->slot);\n              apdu_disconnect (vr->slot);\n            }\n        }\n\n    }\n}","target":0,"code_token_length":1138,"total_token_length":1374,"max_tokens_setting":2048}
+{"idx":198170,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  auto* params = reinterpret_cast<TfLiteSVDFParams*>(node->builtin_data);\n  OpData* op_data = reinterpret_cast<OpData*>(node->user_data);\n\n  const TfLiteTensor* input;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n  const TfLiteTensor* weights_feature;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kWeightsFeatureTensor,\n                                          &weights_feature));\n  const TfLiteTensor* weights_time;\n  TF_LITE_ENSURE_OK(\n      context, GetInputSafe(context, node, kWeightsTimeTensor, &weights_time));\n  const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);\n\n  TfLiteTensor* scratch;\n  TF_LITE_ENSURE_OK(context,\n                    GetTemporarySafe(context, node, \/*index=*\/0, &scratch));\n\n  TfLiteTensor* state = GetVariableInput(context, node, kStateTensor);\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context,\n                    GetOutputSafe(context, node, kOutputTensor, &output));\n\n  switch (weights_feature->type) {\n    case kTfLiteFloat32: {\n      reference_ops::EvalFloatSVDF(\n          params, GetTensorShape(input), GetTensorData<float>(input),\n          GetTensorShape(weights_feature),\n          GetTensorData<float>(weights_feature), GetTensorShape(weights_time),\n          GetTensorData<float>(weights_time), GetTensorShape(bias),\n          GetTensorData<float>(bias), GetTensorData<float>(scratch),\n          GetTensorData<float>(state), GetTensorShape(output),\n          GetTensorData<float>(output));\n      return kTfLiteOk;\n    }\n    case kTfLiteUInt8:\n    case kTfLiteInt8: {\n      if (input->type == kTfLiteFloat32) {\n        TfLiteTensor* input_quantized;\n        TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/1,\n                                                    &input_quantized));\n        TfLiteTensor* scaling_factors;\n        TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/2,\n                                                    &scaling_factors));\n        TfLiteTensor* float_weights_time;\n        TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/3,\n                                                    &float_weights_time));\n        TfLiteTensor* zero_points;\n        TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/4,\n                                                    &zero_points));\n        TfLiteTensor* row_sums;\n        TF_LITE_ENSURE_OK(\n            context, GetTemporarySafe(context, node, \/*index=*\/5, &row_sums));\n        \/\/ Dequantize weights time.\n        \/\/ TODO(alanchiao): this dequantization initialization only needs to\n        \/\/ happen once per model and should theoretically be placed in either\n        \/\/ Init or Prepare. However, TFLite doesn't allocate float_weights_time\n        \/\/ until the Eval function.\n        \/\/ TODO(alanchiao): refactor logic out into dequantize function.\n        if (!op_data->float_weights_time_initialized) {\n          const float dequantization_scale = weights_time->params.scale;\n          const int8_t* weights_time_ptr = GetTensorData<int8_t>(weights_time);\n          float* float_weights_time_ptr =\n              GetTensorData<float>(float_weights_time);\n          for (int i = 0; i < NumElements(float_weights_time); ++i) {\n            float_weights_time_ptr[i] =\n                weights_time_ptr[i] * dequantization_scale;\n          }\n          op_data->float_weights_time_initialized = true;\n        }\n\n        int32_t* zero_points_ptr = nullptr;\n        int32_t* row_sums_ptr = nullptr;\n        if (params->asymmetric_quantize_inputs && row_sums != nullptr) {\n          zero_points_ptr = GetTensorData<int32_t>(zero_points);\n          row_sums_ptr = GetTensorData<int32_t>(row_sums);\n        }\n\n        reference_ops::EvalHybridSVDF(\n            params, GetTensorShape(input), GetTensorData<float>(input),\n            GetTensorShape(weights_feature),\n            GetTensorData<int8_t>(weights_feature),\n            weights_feature->params.scale, GetTensorShape(float_weights_time),\n            GetTensorData<float>(float_weights_time), GetTensorShape(bias),\n            GetTensorData<float>(bias), GetTensorData<float>(scratch),\n            GetTensorData<float>(scaling_factors),\n            GetTensorData<int8_t>(input_quantized), GetTensorData<float>(state),\n            GetTensorShape(output), GetTensorData<float>(output),\n            zero_points_ptr, row_sums_ptr, &op_data->compute_row_sums);\n        return kTfLiteOk;\n      }\n      auto* input_params = reinterpret_cast<TfLiteAffineQuantization*>(\n          input->quantization.params);\n      auto* output_params = reinterpret_cast<TfLiteAffineQuantization*>(\n          output->quantization.params);\n      TfLiteTensor* output_temp;\n      TF_LITE_ENSURE_OK(\n          context, GetTemporarySafe(context, node, \/*index=*\/1, &output_temp));\n\n      \/\/ Currently supports only ReLU.\n      \/\/ TODO(jianlijianli): support other activations.\n      TF_LITE_ENSURE_EQ(context, params->activation, kTfLiteActRelu);\n\n      reference_ops::EvalIntegerSVDF(\n          params, GetTensorShape(input), GetTensorData<int8_t>(input),\n          GetTensorShape(weights_feature),\n          GetTensorData<int8_t>(weights_feature), GetTensorShape(weights_time),\n          GetTensorData<int16_t>(weights_time), GetTensorShape(bias),\n          GetTensorData<int32_t>(bias), GetTensorData<int16_t>(state),\n          GetTensorShape(output), GetTensorData<int8_t>(output),\n          GetTensorData<int32_t>(scratch), GetTensorData<int32_t>(output_temp),\n          op_data->effective_scale_1_a, op_data->effective_scale_1_b,\n          op_data->effective_scale_2_a, op_data->effective_scale_2_b,\n          input_params->zero_point->data[0],\n          output_params->zero_point->data[0]);\n      return kTfLiteOk;\n    }\n    default:\n      context->ReportError(context, \"Type %s not currently supported.\",\n                           TfLiteTypeGetName(weights_feature->type));\n      return kTfLiteError;\n  }\n}","target":1,"code_token_length":1382,"total_token_length":1618,"max_tokens_setting":2048}
+{"idx":481788,"func":"static int qh_input(int sd, int events, void *ioc_)\n{\n\tiocache * ioc = (iocache *) ioc_;\n\tint result    = 0;\n\n\t\/* \n\t\tinput on main socket, so accept one \n\t\tthis is when a worker initially connects\n\t\twe create the iocache and then register\n\t\tthat to a new socket descriptor and this function\n\t\tso that ioc_ != NULL next time\n\t*\/\n\tif (sd == qh_listen_sock) {\n\n\t\tstruct sockaddr sa;\n\t\tsocklen_t slen = 0;\n\t\tint nsd        = 0;\n\n\t\t\/* shut valgrind up *\/\n\t\tmemset(&sa, 0, sizeof(sa));\n\t\tnsd = accept(sd, &sa, &slen);\n\t\tif (qh_max_running && qh_running >= qh_max_running) {\n\t\t\tnsock_printf(nsd, \"503: Server full\");\n\t\t\tclose(nsd);\n\t\t\treturn 0;\n\t\t}\n\n\t\tioc = iocache_create(16384);\n\t\tif (ioc == NULL) {\n\t\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE, \"qh: Failed to create iocache for inbound request\\n\");\n\t\t\tnsock_printf(nsd, \"500: Internal server error\");\n\t\t\tclose(nsd);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/*\n\t\t * @todo: Stash the iocache and the socket in some\n\t\t * addressable list so we can release them on deinit\n\t\t *\/\n\t\tresult = iobroker_register(nagios_iobs, nsd, ioc, qh_input);\n\t\tif (result < 0) {\n\t\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE, \"qh: Failed to register input socket %d with I\/O broker: %s\\n\", nsd, strerror(errno));\n\t\t\tiocache_destroy(ioc);\n\t\t\tclose(nsd);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* make it non-blocking, but leave kernel buffers unchanged *\/\n\t\tworker_set_sockopts(nsd, 0);\n\t\tqh_running++;\n\t\treturn 0;\n\t}\n\n\t\/*\n\t\tthis is when an existing connection\n\t\tsends more data after they've already made\n\t\tthe connection\n\t*\/\n\telse {\n\n\t\tunsigned long len         = 0;\n\t\tunsigned int query_len    = 0;\n\t\tstruct query_handler * qh = NULL;\n\t\tchar * buf                = NULL;\n\t\tchar * space              = NULL;\n\t\tchar * handler            = NULL;\n\t\tchar * query              = NULL;\n\n\t\tresult = iocache_read(ioc, sd);\n\n\t\t\/* disconnect? *\/\n\t\tif (result == 0 || (result < 0 && errno == EPIPE)) {\n\t\t\tiocache_destroy(ioc);\n\t\t\tiobroker_close(nagios_iobs, sd);\n\t\t\tqh_running--;\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/*\n\t\t * A request looks like this: '[@|#]<qh>[<SP>][<query>]\\0'.\n\t\t * That is, optional '#' (oneshot) or '@' (keepalive),\n\t\t * followed by the name of a registered handler, followed by\n\t\t * an optional space and an optional query. If the handler\n\t\t * has no \"default\" handler, a query is required or an error\n\t\t * will be thrown.\n\t\t *\/\n\n\t\t\/* Use data up to the first nul byte *\/\n\t\tbuf = iocache_use_delim(ioc, \"\\0\", 1, &len);\n\t\tif (buf == NULL) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* Identify handler part and any magic query bytes *\/\n\t\tif (*buf == '@' || *buf == '#') {\n\t\t\thandler = buf + 1;\n\t\t}\n\n\t\t\/* Locate query (if any) *\/\n\t\tspace = strchr(buf, ' ');\n\t\tif (space != NULL) {\n\t\t\t*space = 0;\n\t\t\tquery = space + 1;\n\t\t\tquery_len = len - (unsigned long)(query - buf);\n\t\t}\n\n\t\t\/* locate the handler *\/\n\t\tqh = qh_find_handler(handler);\n\n\t\t\/* not found. that's a 404 *\/\n\t\tif (qh == NULL) {\n\t\t\tnsock_printf(sd, \"404: %s: No such handler\", handler);\n\t\t\tiobroker_close(nagios_iobs, sd);\n\t\t\tiocache_destroy(ioc);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* strip trailing newlines *\/\n\t\twhile (query_len > 0\n\t\t       && (query[query_len - 1] == 0 || query[query_len - 1] == '\\n')) {\n\n\t\t\tquery[--query_len] = 0;\t\n\t\t}\n\n\t\t\/* now pass the query to the handler *\/\n\t\tresult = qh->handler(sd, query, query_len);\n\t\tif (result >= 100) {\n\t\t\tnsock_printf_nul(sd, \"%d: %s\", result, qh_strerror(result));\n\t\t}\n\n\t\t\/* error code or one-shot query *\/\n\t\tif (result >= 300 || *buf == '#') {\n\t\t\tiobroker_close(nagios_iobs, sd);\n\t\t\tiocache_destroy(ioc);\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/* check for magic handler codes *\/\n\t\tswitch (result) {\n\n\t\t\/* oneshot handler *\/\n\t\tcase QH_CLOSE:\n\n\t\t\/* general error *\/\n\t\tcase -1:\n\t\t\tiobroker_close(nagios_iobs, sd);\n\n\t\t\/* fallthrough *\/\n\n\t\t\/* handler takes over *\/\n\t\tcase QH_TAKEOVER:\n\n\t\t\/* switch protocol (takeover + message) *\/\n\t\tcase 101:\n\t\t\tiocache_destroy(ioc);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":1218,"total_token_length":1454,"max_tokens_setting":2048}
+{"idx":238604,"func":"static int check_pseudo_btf_id(struct bpf_verifier_env *env,\n\t\t\t       struct bpf_insn *insn,\n\t\t\t       struct bpf_insn_aux_data *aux)\n{\n\tconst struct btf_var_secinfo *vsi;\n\tconst struct btf_type *datasec;\n\tstruct btf_mod_pair *btf_mod;\n\tconst struct btf_type *t;\n\tconst char *sym_name;\n\tbool percpu = false;\n\tu32 type, id = insn->imm;\n\tstruct btf *btf;\n\ts32 datasec_id;\n\tu64 addr;\n\tint i, btf_fd, err;\n\n\tbtf_fd = insn[1].imm;\n\tif (btf_fd) {\n\t\tbtf = btf_get_by_fd(btf_fd);\n\t\tif (IS_ERR(btf)) {\n\t\t\tverbose(env, \"invalid module BTF object FD specified.\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t} else {\n\t\tif (!btf_vmlinux) {\n\t\t\tverbose(env, \"kernel is missing BTF, make sure CONFIG_DEBUG_INFO_BTF=y is specified in Kconfig.\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbtf = btf_vmlinux;\n\t\tbtf_get(btf);\n\t}\n\n\tt = btf_type_by_id(btf, id);\n\tif (!t) {\n\t\tverbose(env, \"ldimm64 insn specifies invalid btf_id %d.\\n\", id);\n\t\terr = -ENOENT;\n\t\tgoto err_put;\n\t}\n\n\tif (!btf_type_is_var(t)) {\n\t\tverbose(env, \"pseudo btf_id %d in ldimm64 isn't KIND_VAR.\\n\", id);\n\t\terr = -EINVAL;\n\t\tgoto err_put;\n\t}\n\n\tsym_name = btf_name_by_offset(btf, t->name_off);\n\taddr = kallsyms_lookup_name(sym_name);\n\tif (!addr) {\n\t\tverbose(env, \"ldimm64 failed to find the address for kernel symbol '%s'.\\n\",\n\t\t\tsym_name);\n\t\terr = -ENOENT;\n\t\tgoto err_put;\n\t}\n\n\tdatasec_id = find_btf_percpu_datasec(btf);\n\tif (datasec_id > 0) {\n\t\tdatasec = btf_type_by_id(btf, datasec_id);\n\t\tfor_each_vsi(i, datasec, vsi) {\n\t\t\tif (vsi->type == id) {\n\t\t\t\tpercpu = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tinsn[0].imm = (u32)addr;\n\tinsn[1].imm = addr >> 32;\n\n\ttype = t->type;\n\tt = btf_type_skip_modifiers(btf, type, NULL);\n\tif (percpu) {\n\t\taux->btf_var.reg_type = PTR_TO_PERCPU_BTF_ID;\n\t\taux->btf_var.btf = btf;\n\t\taux->btf_var.btf_id = type;\n\t} else if (!btf_type_is_struct(t)) {\n\t\tconst struct btf_type *ret;\n\t\tconst char *tname;\n\t\tu32 tsize;\n\n\t\t\/* resolve the type size of ksym. *\/\n\t\tret = btf_resolve_size(btf, t, &tsize);\n\t\tif (IS_ERR(ret)) {\n\t\t\ttname = btf_name_by_offset(btf, t->name_off);\n\t\t\tverbose(env, \"ldimm64 unable to resolve the size of type '%s': %ld\\n\",\n\t\t\t\ttname, PTR_ERR(ret));\n\t\t\terr = -EINVAL;\n\t\t\tgoto err_put;\n\t\t}\n\t\taux->btf_var.reg_type = PTR_TO_MEM | MEM_RDONLY;\n\t\taux->btf_var.mem_size = tsize;\n\t} else {\n\t\taux->btf_var.reg_type = PTR_TO_BTF_ID;\n\t\taux->btf_var.btf = btf;\n\t\taux->btf_var.btf_id = type;\n\t}\n\n\t\/* check whether we recorded this BTF (and maybe module) already *\/\n\tfor (i = 0; i < env->used_btf_cnt; i++) {\n\t\tif (env->used_btfs[i].btf == btf) {\n\t\t\tbtf_put(btf);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif (env->used_btf_cnt >= MAX_USED_BTFS) {\n\t\terr = -E2BIG;\n\t\tgoto err_put;\n\t}\n\n\tbtf_mod = &env->used_btfs[env->used_btf_cnt];\n\tbtf_mod->btf = btf;\n\tbtf_mod->module = NULL;\n\n\t\/* if we reference variables from kernel module, bump its refcount *\/\n\tif (btf_is_module(btf)) {\n\t\tbtf_mod->module = btf_try_get_module(btf);\n\t\tif (!btf_mod->module) {\n\t\t\terr = -ENXIO;\n\t\t\tgoto err_put;\n\t\t}\n\t}\n\n\tenv->used_btf_cnt++;\n\n\treturn 0;\nerr_put:\n\tbtf_put(btf);\n\treturn err;\n}","target":0,"code_token_length":1058,"total_token_length":1294,"max_tokens_setting":2048}
+{"idx":195720,"func":"void updateHandshakeState(QuicServerConnectionState& conn) {\n  \/\/ Zero RTT read cipher is available after chlo is processed with the\n  \/\/ condition that early data attempt is accepted.\n  auto handshakeLayer = conn.serverHandshakeLayer;\n  auto zeroRttReadCipher = handshakeLayer->getZeroRttReadCipher();\n  auto zeroRttHeaderCipher = handshakeLayer->getZeroRttReadHeaderCipher();\n  \/\/ One RTT write cipher is available at Fizz layer after chlo is processed.\n  \/\/ However, the cipher is only exported to QUIC if early data attempt is\n  \/\/ accepted. Otherwise, the cipher will be available after cfin is\n  \/\/ processed.\n  auto oneRttWriteCipher = handshakeLayer->getOneRttWriteCipher();\n  \/\/ One RTT read cipher is available after cfin is processed.\n  auto oneRttReadCipher = handshakeLayer->getOneRttReadCipher();\n\n  auto oneRttWriteHeaderCipher = handshakeLayer->getOneRttWriteHeaderCipher();\n  auto oneRttReadHeaderCipher = handshakeLayer->getOneRttReadHeaderCipher();\n\n  if (zeroRttReadCipher) {\n    if (conn.qLogger) {\n      conn.qLogger->addTransportStateUpdate(kDerivedZeroRttReadCipher);\n    }\n    QUIC_TRACE(fst_trace, conn, \"derived 0-rtt read cipher\");\n    conn.readCodec->setZeroRttReadCipher(std::move(zeroRttReadCipher));\n  }\n  if (zeroRttHeaderCipher) {\n    conn.readCodec->setZeroRttHeaderCipher(std::move(zeroRttHeaderCipher));\n  }\n  if (oneRttWriteHeaderCipher) {\n    conn.oneRttWriteHeaderCipher = std::move(oneRttWriteHeaderCipher);\n  }\n  if (oneRttReadHeaderCipher) {\n    conn.readCodec->setOneRttHeaderCipher(std::move(oneRttReadHeaderCipher));\n  }\n\n  if (oneRttWriteCipher) {\n    if (conn.qLogger) {\n      conn.qLogger->addTransportStateUpdate(kDerivedOneRttWriteCipher);\n    }\n    QUIC_TRACE(fst_trace, conn, \"derived 1-rtt write cipher\");\n    CHECK(!conn.oneRttWriteCipher.get());\n    conn.oneRttWriteCipher = std::move(oneRttWriteCipher);\n\n    updatePacingOnKeyEstablished(conn);\n\n    \/\/ We negotiate the transport parameters whenever we have the 1-RTT write\n    \/\/ keys available.\n    auto clientParams = handshakeLayer->getClientTransportParams();\n    if (!clientParams) {\n      throw QuicTransportException(\n          \"No client transport params\",\n          TransportErrorCode::TRANSPORT_PARAMETER_ERROR);\n    }\n    processClientInitialParams(conn, std::move(*clientParams));\n  }\n  if (oneRttReadCipher) {\n    if (conn.qLogger) {\n      conn.qLogger->addTransportStateUpdate(kDerivedOneRttReadCipher);\n    }\n    QUIC_TRACE(fst_trace, conn, \"derived 1-rtt read cipher\");\n    \/\/ Clear limit because CFIN is received at this point\n    conn.writableBytesLimit = folly::none;\n    conn.readCodec->setOneRttReadCipher(std::move(oneRttReadCipher));\n  }\n  auto handshakeReadCipher = handshakeLayer->getHandshakeReadCipher();\n  auto handshakeReadHeaderCipher =\n      handshakeLayer->getHandshakeReadHeaderCipher();\n  if (handshakeReadCipher) {\n    CHECK(handshakeReadHeaderCipher);\n    conn.readCodec->setHandshakeReadCipher(std::move(handshakeReadCipher));\n    conn.readCodec->setHandshakeHeaderCipher(\n        std::move(handshakeReadHeaderCipher));\n  }\n  if (handshakeLayer->isHandshakeDone()) {\n    CHECK(conn.oneRttWriteCipher);\n    if (conn.version != QuicVersion::MVFST_D24 && !conn.sentHandshakeDone) {\n      sendSimpleFrame(conn, HandshakeDoneFrame());\n      conn.sentHandshakeDone = true;\n    }\n  }\n}","target":1,"code_token_length":861,"total_token_length":1097,"max_tokens_setting":2048}
+{"idx":455327,"func":"bash_default_completion (text, start, end, qc, compflags)\n     const char *text;\n     int start, end, qc, compflags;\n{\n  char **matches, *t;\n\n  matches = (char **)NULL;\n\n  \/* New posix-style command substitution or variable name? *\/\n  if (*text == '$')\n    {\n      if (qc != '\\'' && text[1] == '(') \/* ) *\/\n\tmatches = rl_completion_matches (text, command_subst_completion_function);\n      else\n\t{\n\t  matches = rl_completion_matches (text, variable_completion_function);\n\t  \/* If a single match, see if it expands to a directory name and append\n\t     a slash if it does.  This requires us to expand the variable name,\n\t     so we don't want to display errors if the variable is unset.  This\n\t     can happen with dynamic variables whose value has never been\n\t     requested. *\/\n\t  if (matches && matches[0] && matches[1] == 0)\n\t    {\n\t      t = savestring (matches[0]);\n\t      bash_filename_stat_hook (&t);\n\t      \/* doesn't use test_for_directory because that performs tilde\n\t\t expansion *\/\n\t      if (file_isdir (t))\n\t\trl_completion_append_character = '\/';\n\t      free (t);\n\t    }\n\t}\n    }\n\n  \/* If the word starts in `~', and there is no slash in the word, then\n     try completing this word as a username. *\/\n  if (matches == 0 && *text == '~' && mbschr (text, '\/') == 0)\n    matches = rl_completion_matches (text, rl_username_completion_function);\n\n  \/* Another one.  Why not?  If the word starts in '@', then look through\n     the world of known hostnames for completion first. *\/\n  if (matches == 0 && perform_hostname_completion && *text == '@')\n    matches = rl_completion_matches (text, hostname_completion_function);\n\n  \/* And last, (but not least) if this word is in a command position, then\n     complete over possible command names, including aliases, functions,\n     and command names. *\/\n  if (matches == 0 && (compflags & DEFCOMP_CMDPOS))\n    {\n      \/* If END == START and text[0] == 0, we are trying to complete an empty\n\t command word. *\/\n      if (no_empty_command_completion && end == start && text[0] == '\\0')\n\t{\n\t  matches = (char **)NULL;\n\t  rl_ignore_some_completions_function = bash_ignore_everything;\n\t}\n      else\n\t{\n#define CMD_IS_DIR(x)\t(absolute_pathname(x) == 0 && absolute_program(x) == 0 && *(x) != '~' && test_for_directory (x))\n\n\t  dot_in_path = 0;\n\t  matches = rl_completion_matches (text, command_word_completion_function);\n\n\t  \/* If we are attempting command completion and nothing matches, we\n\t     do not want readline to perform filename completion for us.  We\n\t     still want to be able to complete partial pathnames, so set the\n\t     completion ignore function to something which will remove\n\t     filenames and leave directories in the match list. *\/\n\t  if (matches == (char **)NULL)\n\t    rl_ignore_some_completions_function = bash_ignore_filenames;\n\t  else if (matches[1] == 0 && CMD_IS_DIR(matches[0]) && dot_in_path == 0)\n\t    \/* If we found a single match, without looking in the current\n\t       directory (because it's not in $PATH), but the found name is\n\t       also a command in the current directory, suppress appending any\n\t       terminating character, since it's ambiguous. *\/\n\t    {\n\t      rl_completion_suppress_append = 1;\n\t      rl_filename_completion_desired = 0;\n\t    }\n\t  else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && CMD_IS_DIR (matches[0]))\n\t    \/* There are multiple instances of the same match (duplicate\n\t       completions haven't yet been removed).  In this case, all of\n\t       the matches will be the same, and the duplicate removal code\n\t       will distill them all down to one.  We turn on\n\t       rl_completion_suppress_append for the same reason as above.\n\t       Remember: we only care if there's eventually a single unique\n\t       completion.  If there are multiple completions this won't\n\t       make a difference and the problem won't occur. *\/\n\t    {\n\t      rl_completion_suppress_append = 1;\n\t      rl_filename_completion_desired = 0;\n\t    }\n\t}\n    }\n\n  \/* This could be a globbing pattern, so try to expand it using pathname\n     expansion. *\/\n  if (!matches && completion_glob_pattern ((char *)text))\n    {\n      matches = rl_completion_matches (text, glob_complete_word);\n      \/* A glob expression that matches more than one filename is problematic.\n\t If we match more than one filename, punt. *\/\n      if (matches && matches[1] && rl_completion_type == TAB)\n\t{\n\t  strvec_dispose (matches);\n\t  matches = (char **)0;\n\t}\n      else if (matches && matches[1] && rl_completion_type == '!')\n\t{\n\t  rl_completion_suppress_append = 1;\n\t  rl_filename_completion_desired = 0;\n\t}\n    }\n\n  return (matches);\n}","target":0,"code_token_length":1133,"total_token_length":1369,"max_tokens_setting":2048}
+{"idx":204425,"func":"bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)\n{\n  u_char *end;\n  struct capability cap;\n  u_char action;\n  struct bgp *bgp;\n  afi_t afi;\n  safi_t safi;\n\n  bgp = peer->bgp;\n  end = pnt + length;\n\n  while (pnt < end)\n    {\n      \/* We need at least action, capability code and capability length. *\/\n      if (pnt + 3 > end)\n        {\n          zlog_info (\"%s Capability length error\", peer->host);\n          bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);\n          return -1;\n        }\n\n      action = *pnt;\n\n      \/* Fetch structure to the byte stream. *\/\n      memcpy (&cap, pnt + 1, sizeof (struct capability));\n\n      \/* Action value check.  *\/\n      if (action != CAPABILITY_ACTION_SET\n\t  && action != CAPABILITY_ACTION_UNSET)\n        {\n          zlog_info (\"%s Capability Action Value error %d\",\n\t\t     peer->host, action);\n          bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);\n          return -1;\n        }\n\n      if (BGP_DEBUG (normal, NORMAL))\n\tzlog_debug (\"%s CAPABILITY has action: %d, code: %u, length %u\",\n\t\t   peer->host, action, cap.code, cap.length);\n\n      \/* Capability length check. *\/\n      if (pnt + (cap.length + 3) > end)\n        {\n          zlog_info (\"%s Capability length error\", peer->host);\n          bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);\n          return -1;\n        }\n\n      \/* We know MP Capability Code. *\/\n      if (cap.code == CAPABILITY_CODE_MP)\n        {\n\t  afi = ntohs (cap.mpc.afi);\n\t  safi = cap.mpc.safi;\n\n          \/* Ignore capability when override-capability is set. *\/\n          if (CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))\n\t    continue;\n\n\t  \/* Address family check.  *\/\n\t  if ((afi == AFI_IP \n\t       || afi == AFI_IP6)\n\t      && (safi == SAFI_UNICAST \n\t\t  || safi == SAFI_MULTICAST \n\t\t  || safi == BGP_SAFI_VPNV4))\n\t    {\n\t      if (BGP_DEBUG (normal, NORMAL))\n\t\tzlog_debug (\"%s CAPABILITY has %s MP_EXT CAP for afi\/safi: %u\/%u\",\n\t\t\t   peer->host,\n\t\t\t   action == CAPABILITY_ACTION_SET \n\t\t\t   ? \"Advertising\" : \"Removing\",\n\t\t\t   ntohs(cap.mpc.afi) , cap.mpc.safi);\n\t\t  \n\t      \/* Adjust safi code. *\/\n\t      if (safi == BGP_SAFI_VPNV4)\n\t\tsafi = SAFI_MPLS_VPN;\n\t      \n\t      if (action == CAPABILITY_ACTION_SET)\n\t\t{\n\t\t  peer->afc_recv[afi][safi] = 1;\n\t\t  if (peer->afc[afi][safi])\n\t\t    {\n\t\t      peer->afc_nego[afi][safi] = 1;\n\t\t      bgp_announce_route (peer, afi, safi);\n\t\t    }\n\t\t}\n\t      else\n\t\t{\n\t\t  peer->afc_recv[afi][safi] = 0;\n\t\t  peer->afc_nego[afi][safi] = 0;\n\n\t\t  if (peer_active_nego (peer))\n\t\t    bgp_clear_route (peer, afi, safi);\n\t\t  else\n\t\t    BGP_EVENT_ADD (peer, BGP_Stop);\n\t\t} \n\t    }\n        }\n      else\n        {\n          zlog_warn (\"%s unrecognized capability code: %d - ignored\",\n                     peer->host, cap.code);\n        }\n      pnt += cap.length + 3;\n    }\n  return 0;\n}","target":1,"code_token_length":834,"total_token_length":1070,"max_tokens_setting":2048}
+{"idx":474035,"func":"onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,\n\t\t\t\t    OnigApplyAllCaseFoldFunc f, void* arg,\n\t\t\t\t    OnigEncoding enc ARG_UNUSED)\n{\n  const CaseUnfold_11_Type* p11;\n  OnigCodePoint code;\n  int i, j, k, r;\n\n  \/* if (CaseFoldInited == 0) init_case_fold_table(); *\/\n\n  for (i = 0; i < numberof(CaseUnfold_11); i++) {\n    p11 = &CaseUnfold_11[i];\n    for (j = 0; j < p11->to.n; j++) {\n      code = p11->from;\n      r = (*f)(p11->to.code[j], &code, 1, arg);\n      if (r != 0) return r;\n\n      code = p11->to.code[j];\n      r = (*f)(p11->from, &code, 1, arg);\n      if (r != 0) return r;\n\n      for (k = 0; k < j; k++) {\n\tr = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]), 1, arg);\n\tif (r != 0) return r;\n\n\tr = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]), 1, arg);\n\tif (r != 0) return r;\n      }\n    }\n  }\n\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n  if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {\n    code = 0x0131;\n    r = (*f)(0x0049, &code, 1, arg);\n    if (r != 0) return r;\n    code = 0x0049;\n    r = (*f)(0x0131, &code, 1, arg);\n    if (r != 0) return r;\n\n    code = 0x0130;\n    r = (*f)(0x0069, &code, 1, arg);\n    if (r != 0) return r;\n    code = 0x0069;\n    r = (*f)(0x0130, &code, 1, arg);\n    if (r != 0) return r;\n  }\n  else {\n#endif\n    for (i = 0; i < numberof(CaseUnfold_11_Locale); i++) {\n      p11 = &CaseUnfold_11_Locale[i];\n      for (j = 0; j < p11->to.n; j++) {\n\tcode = p11->from;\n\tr = (*f)(p11->to.code[j], &code, 1, arg);\n\tif (r != 0) return r;\n\n\tcode = p11->to.code[j];\n\tr = (*f)(p11->from, &code, 1, arg);\n\tif (r != 0) return r;\n\n\tfor (k = 0; k < j; k++) {\n\t  r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]),\n\t\t   1, arg);\n\t  if (r != 0) return r;\n\n\t  r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]),\n\t\t   1, arg);\n\t  if (r != 0) return r;\n\t}\n      }\n    }\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n  }\n#endif\n\n  if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    for (i = 0; i < numberof(CaseUnfold_12); i++) {\n      for (j = 0; j < CaseUnfold_12[i].to.n; j++) {\n\tr = (*f)(CaseUnfold_12[i].to.code[j],\n\t\t (OnigCodePoint* )CaseUnfold_12[i].from, 2, arg);\n\tif (r != 0) return r;\n\n\tfor (k = 0; k < CaseUnfold_12[i].to.n; k++) {\n\t  if (k == j) continue;\n\n\t  r = (*f)(CaseUnfold_12[i].to.code[j],\n\t\t   (OnigCodePoint* )(&CaseUnfold_12[i].to.code[k]), 1, arg);\n\t  if (r != 0) return r;\n\t}\n      }\n    }\n\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n    if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) {\n#endif\n      for (i = 0; i < numberof(CaseUnfold_12_Locale); i++) {\n\tfor (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) {\n\t  r = (*f)(CaseUnfold_12_Locale[i].to.code[j],\n\t\t   (OnigCodePoint* )CaseUnfold_12_Locale[i].from, 2, arg);\n\t  if (r != 0) return r;\n\n\t  for (k = 0; k < CaseUnfold_12_Locale[i].to.n; k++) {\n\t    if (k == j) continue;\n\n\t    r = (*f)(CaseUnfold_12_Locale[i].to.code[j],\n\t\t     (OnigCodePoint* )(&CaseUnfold_12_Locale[i].to.code[k]),\n\t\t     1, arg);\n\t    if (r != 0) return r;\n\t  }\n\t}\n      }\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n    }\n#endif\n\n    for (i = 0; i < numberof(CaseUnfold_13); i++) {\n      for (j = 0; j < CaseUnfold_13[i].to.n; j++) {\n\tr = (*f)(CaseUnfold_13[i].to.code[j],\n\t\t (OnigCodePoint* )CaseUnfold_13[i].from, 3, arg);\n\tif (r != 0) return r;\n\n\tfor (k = 0; k < CaseUnfold_13[i].to.n; k++) {\n\t  if (k == j) continue;\n\n\t  r = (*f)(CaseUnfold_13[i].to.code[j],\n\t\t   (OnigCodePoint* )(&CaseUnfold_13[i].to.code[k]), 1, arg);\n\t  if (r != 0) return r;\n\t}\n      }\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":1505,"total_token_length":1741,"max_tokens_setting":2048}
+{"idx":310174,"func":"main(int argc, char *argv[])\n{\n    int n;\n    int r_run, t_run, n_run;\n    char *old_term = getenv(\"TERM\");\n    int r_opt = 1;\n    char *t_opt = 0;\n    int len_names = 0;\t\t\/* cur # of items in all_names[] *\/\n    int use_names = 10;\t\t\/* max # of items in all_names[] *\/\n    char **all_names = typeCalloc(char *, use_names);\n    int all_parms[10];\t\t\/* workspace for \"-a\" option *\/\n    int len_terms = 0;\t\t\/* cur # of items in all_terms[] *\/\n    int use_terms = 10;\t\t\/* max # of items in all_terms[] *\/\n    char **all_terms = typeCalloc(char *, use_terms);\n    int len_parms = 0;\t\t\/* cur # of items in num_parms[], str_parms[] *\/\n    int use_parms = argc + 10;\t\/* max # of items in num_parms[], str_parms[] *\/\n    int *num_parms = typeCalloc(int, use_parms);\n    char **str_parms = typeCalloc(char *, use_parms);\n\n    if (all_names == 0 || all_terms == 0 || num_parms == 0 || str_parms == 0)\n\tfailed(\"no memory\");\n\n    while ((n = getopt(argc, argv, \"T:ar:v\")) != -1) {\n\tswitch (n) {\n\tcase 'T':\n\t    t_opt = optarg;\n\t    break;\n\tcase 'a':\n\t    ++a_opt;\n\t    break;\n\tcase 'r':\n\t    r_opt = atoi(optarg);\n\t    break;\n\tcase 'v':\n\t    ++v_opt;\n\t    break;\n\tdefault:\n\t    usage();\n\t    break;\n\t}\n    }\n\n    \/*\n     * If there is a nonnumeric parameter after the options, use that as the\n     * capability name.\n     *\/\n    if (optind < argc) {\n\tif (!isNumeric(argv[optind])) {\n\t    all_names[len_names++] = strdup(argv[optind++]);\n\t}\n    }\n\n    \/*\n     * Any remaining arguments must be possible parameter values.  If numeric,\n     * and \"-a\" is not set, use those as the maximum values within which the\n     * test parameters should vary.\n     *\/\n    while (optind < argc) {\n\tif (isNumeric(argv[optind])) {\n\t    char *dummy = 0;\n\t    long value = strtol(argv[optind], &dummy, 0);\n\t    num_parms[len_parms] = (int) value;\n\t}\n\tstr_parms[len_parms] = argv[optind];\n\t++optind;\n\t++len_parms;\n    }\n    for (n = len_parms; n < use_parms; ++n) {\n\tstatic char dummy[1];\n\tstr_parms[n] = dummy;\n    }\n    if (v_opt) {\n\tprintf(\"%d parameter%s%s\\n\", PLURAL(len_parms), COLONS(len_parms));\n\tfor (n = 0; n < len_parms; ++n) {\n\t    printf(\" %d: %d (%s)\\n\", n + 1, num_parms[n], str_parms[n]);\n\t}\n    }\n\n    \/*\n     * Make a list of values for $TERM.  Accept \"-\" for standard input to\n     * simplify scripting a check of the whole database.\n     *\/\n    old_term = strdup((old_term == 0) ? \"unknown\" : old_term);\n    if (t_opt != 0) {\n\tif (!strcmp(t_opt, \"-\")) {\n\t    char buffer[BUFSIZ];\n\t    while (fgets(buffer, sizeof(buffer) - 1, stdin) != 0) {\n\t\tchar *s = buffer;\n\t\tchar *t;\n\t\twhile (isspace(UChar(s[0])))\n\t\t    ++s;\n\t\tt = s + strlen(s);\n\t\twhile (t != s && isspace(UChar(t[-1])))\n\t\t    *--t = '\\0';\n\t\ts = strdup(s);\n\t\tif (len_terms + 2 >= use_terms) {\n\t\t    use_terms *= 2;\n\t\t    all_terms = typeRealloc(char *, use_terms, all_terms);\n\t\t    if (all_terms == 0)\n\t\t\tfailed(\"no memory: all_terms\");\n\t\t}\n\t\tall_terms[len_terms++] = s;\n\t    }\n\t} else {\n\t    char *s = t_opt;\n\t    char *t;\n\t    while ((t = strtok(s, \",\")) != 0) {\n\t\ts = 0;\n\t\tif (len_terms + 2 >= use_terms) {\n\t\t    use_terms *= 2;\n\t\t    all_terms = typeRealloc(char *, use_terms, all_terms);\n\t\t    if (all_terms == 0)\n\t\t\tfailed(\"no memory: all_terms\");\n\t\t}\n\t\tall_terms[len_terms++] = strdup(t);\n\t    }\n\t}\n    } else {\n\tall_terms[len_terms++] = strdup(old_term);\n    }\n    all_terms[len_terms] = 0;\n    if (v_opt) {\n\tprintf(\"%d term%s:\\n\", PLURAL(len_terms));\n\tfor (n = 0; n < len_terms; ++n) {\n\t    printf(\" %d: %s\\n\", n + 1, all_terms[n]);\n\t}\n    }\n\n    \/*\n     * If no capability name was selected, use the predefined list of string\n     * capabilities.\n     *\n     * TODO: To address the \"other\" systems which do not follow SVr4,\n     * just use the output from infocmp on $TERM.\n     *\/\n    if (len_names == 0) {\n#if defined(HAVE_CURSES_DATA_BOOLNAMES) || defined(DECL_CURSES_DATA_BOOLNAMES)\n\tfor (n = 0; strnames[n] != 0; ++n) {\n\t    if (len_names + 2 >= use_names) {\n\t\tuse_names *= 2;\n\t\tall_names = typeRealloc(char *, use_names, all_names);\n\t\tif (all_names == 0) {\n\t\t    failed(\"no memory: all_names\");\n\t\t}\n\t    }\n\t    all_names[len_names++] = strdup(strnames[n]);\n\t}\n#else\n\tall_names[len_names++] = strdup(\"cup\");\n\tall_names[len_names++] = strdup(\"sgr\");\n#endif\n    }\n    all_names[len_names] = 0;\n    if (v_opt) {\n\tprintf(\"%d name%s%s\\n\", PLURAL(len_names), COLONS(len_names));\n\tfor (n = 0; n < len_names; ++n) {\n\t    printf(\" %d: %s\\n\", n + 1, all_names[n]);\n\t}\n    }\n\n    if (r_opt <= 0)\n\tr_opt = 1;\n\n    for (r_run = 0; r_run < r_opt; ++r_run) {\n\tfor (t_run = 0; t_run < len_terms; ++t_run) {\n\t    int errs;\n\n\t    if (setupterm(all_terms[t_run], fileno(stdout), &errs) != OK) {\n\t\tprintf(\"** skipping %s (errs:%d)\\n\", all_terms[t_run], errs);\n\t    }\n\n\t    if (v_opt)\n\t\tprintf(\"** testing %s\\n\", all_terms[t_run]);\n\t    if (len_names == 1) {\n\t\tif (a_opt) {\n\t\t    \/* for each combination of values *\/\n\t\t    memset(all_parms, 0, sizeof(all_parms));\n\t\t    do {\n\t\t\ttest_tparm(all_names[0], all_parms);\n\t\t    }\n\t\t    while (increment(all_parms, num_parms, len_parms, 0));\n\t\t} else {\n\t\t    \/* for the given values *\/\n\t\t    test_tparm(all_names[0], num_parms);\n\t\t}\n\t    } else {\n\t\tfor (n_run = 0; n_run < len_names; ++n_run) {\n\t\t    test_tparm(all_names[n_run], num_parms);\n\t\t}\n\t    }\n\t    if (cur_term != 0) {\n\t\tdel_curterm(cur_term);\n\t    } else {\n\t\tprintf(\"? no cur_term\\n\");\n\t    }\n\t}\n    }\n#if NO_LEAKS\n    for (n = 0; n < len_names; ++n) {\n\tfree(all_names[n]);\n    }\n    free(all_names);\n    free(old_term);\n    for (n = 0; n < len_terms; ++n) {\n\tfree(all_terms[n]);\n    }\n    free(all_terms);\n    free(num_parms);\n    free(str_parms);\n#endif\n\n    ExitProgram(EXIT_SUCCESS);\n}","target":0,"code_token_length":1757,"total_token_length":1993,"max_tokens_setting":2048}
+{"idx":247290,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& input = ctx->input(kInputTensorIndex);\n    const Tensor& input_min = ctx->input(kInputMinIndex);\n    const Tensor& input_max = ctx->input(kInputMaxIndex);\n\n    const size_t depth = input_max.NumElements();\n    OP_REQUIRES(\n        ctx, input_min.dim_size(0) == depth,\n        errors::InvalidArgument(\"input_min has incorrect size, expected \",\n                                depth, \" was \", input_min.dim_size(0)));\n    OP_REQUIRES(\n        ctx, input_max.dim_size(0) == depth,\n        errors::InvalidArgument(\"input_max has incorrect size, expected \",\n                                depth, \" was \", input_max.dim_size(0)));\n    OP_REQUIRES(\n        ctx, input_min.NumElements() == depth,\n        errors::InvalidArgument(\"input_min must have the same number of \"\n                                \"elements as input_max, got \",\n                                input_min.NumElements(), \" and \", depth));\n    OP_REQUIRES(ctx, input.NumElements() > 0,\n                errors::InvalidArgument(\"input must not be empty\"));\n    OP_REQUIRES(ctx, input.dims() == 4,\n                errors::InvalidArgument(\"input must be in NHWC format\"));\n    OP_REQUIRES(\n        ctx, input.dim_size(3) == depth,\n        errors::InvalidArgument(\n            \"input must have same number of channels as length of input_min: \",\n            input.dim_size(3), \" vs \", depth));\n\n    const float* input_min_data = input_min.flat<float>().data();\n    const float* input_max_data = input_max.flat<float>().data();\n    std::vector<float> ranges(depth);\n    bool is_non_negative = true;\n    Eigen::array<int, 2> shuffling({1, 0});\n    auto input_matrix = input.flat_inner_dims<qint32>();\n\n    \/\/ TODO: verify performance of not transposing and finding the min max\n    \/\/ directly from input_matrix vs the one presented below of transposing and\n    \/\/ using the transposed matrix as the transposing operation in itself might\n    \/\/ be more costly.\n    \/\/ Note that this operation is a calibration step for quantization and will\n    \/\/ cease to exist in the final inference graph(will exist as a const node).\n    auto transposed_input = input_matrix.shuffle(shuffling);\n\n    \/\/ Find the ranges of each channel in parallel.\n    float out_min_max = std::numeric_limits<float>::min();\n\n#ifdef ENABLE_ONEDNN_OPENMP\n#ifdef _MSC_VER\n#pragma omp parallel for\n#else\n#pragma omp parallel for reduction(max : out_min_max)\n#endif\n#endif  \/\/ ENABLE_ONEDNN_OPENMP\n    \/\/ TODO: Add eigen parallel_for\n    for (int64_t i = 0; i < depth; ++i) {\n      Eigen::Tensor<qint32, 0, Eigen::RowMajor> min =\n          transposed_input.chip<0>(i).minimum();\n      Eigen::Tensor<qint32, 0, Eigen::RowMajor> max =\n          transposed_input.chip<0>(i).maximum();\n      const int32_t min_per_channel = min();\n      const int32_t max_per_channel = max();\n      const int32_t abs_max =\n          std::max(std::abs(min_per_channel), std::abs(max_per_channel));\n      float scale =\n          std::max(std::abs(input_min_data[i]), std::abs(input_max_data[i]));\n      ranges[i] =\n          scale * static_cast<float>(abs_max) \/ static_cast<float>(1L << 31);\n      if (min_per_channel < 0) is_non_negative = false;\n\n      \/\/ Thread-local out_min_max.\n      out_min_max = std::max(out_min_max, ranges[i]);\n    }\n\n    \/\/ All local out_min_max gets max-reduced into one global out_min_max at\n    \/\/ the end of the loop by specifying reduction(max:out_min_max) along with\n    \/\/ omp parallel for.\n\n    \/\/ Fixing max to clip_value_max_ (example 6.0 to support relu6)\n    if (out_min_max > clip_value_max_) out_min_max = clip_value_max_;\n\n    Tensor* output_min = nullptr;\n    Tensor* output_max = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputMinIndex, {}, &output_min));\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputMaxIndex, {}, &output_max));\n    output_min->flat<float>()(0) = is_non_negative ? 0.0f : -out_min_max;\n    output_max->flat<float>()(0) = out_min_max;\n  }","target":0,"code_token_length":982,"total_token_length":1218,"max_tokens_setting":2048}
+{"idx":390541,"func":"CheckKeySyms(\tClientPtr\t\tclient,\n\t\tXkbDescPtr\t\txkb,\n\t\txkbSetMapReq *\t\treq,\n\t\tint\t\t\tnTypes,\n\t\tCARD8 *\t \t\tmapWidths,\n\t\tCARD16 *\t \tsymsPerKey,\n\t\txkbSymMapWireDesc **\twireRtrn,\n\t\tint *\t\t\terrorRtrn)\n{\nregister unsigned\ti;\nXkbSymMapPtr\t\tmap;\nxkbSymMapWireDesc*\twire = *wireRtrn;\n\n    if (!(XkbKeySymsMask&req->present))\n\treturn 1;\n    CHK_REQ_KEY_RANGE2(0x11,req->firstKeySym,req->nKeySyms,req,(*errorRtrn),0);\n    map = &xkb->map->key_sym_map[xkb->min_key_code];\n    for (i=xkb->min_key_code;i<(unsigned)req->firstKeySym;i++,map++) {\n\tregister int g,ng,w;\n\tng= XkbNumGroups(map->group_info);\n\tfor (w=g=0;g<ng;g++) {\n\t    if (map->kt_index[g]>=(unsigned)nTypes) {\n\t\t*errorRtrn = _XkbErrCode4(0x13,i,g,map->kt_index[g]);\n\t\treturn 0;\n\t    }\n\t    if (mapWidths[map->kt_index[g]]>w)\n\t\tw= mapWidths[map->kt_index[g]];\n\t}\n\tsymsPerKey[i] = w*ng;\n    }\n    for (i=0;i<req->nKeySyms;i++) {\n\tKeySym *pSyms;\n\tregister unsigned nG;\n\tif (client->swapped) {\n\t    swaps(&wire->nSyms,nG);\n\t}\n\tnG = XkbNumGroups(wire->groupInfo);\n\tif (nG>XkbNumKbdGroups) {\n\t    *errorRtrn = _XkbErrCode3(0x14,i+req->firstKeySym,nG);\n\t    return 0;\n\t}\n\tif (nG>0) {\n\t    register int g,w;\n\t    for (g=w=0;g<nG;g++) {\n\t\tif (wire->ktIndex[g]>=(unsigned)nTypes) {\n\t\t    *errorRtrn= _XkbErrCode4(0x15,i+req->firstKeySym,g,\n\t\t    \t\t\t\t\t   wire->ktIndex[g]);\n\t\t    return 0;\n\t\t}\n\t\tif (mapWidths[wire->ktIndex[g]]>w)\n\t\t    w= mapWidths[wire->ktIndex[g]];\n\t    }\n\t    if (wire->width!=w) {\n\t\t*errorRtrn= _XkbErrCode3(0x16,i+req->firstKeySym,wire->width);\n\t\treturn 0;\n\t    }\n\t    w*= nG;\n\t    symsPerKey[i+req->firstKeySym] = w;\n\t    if (w!=wire->nSyms) {\n\t\t*errorRtrn=_XkbErrCode4(0x16,i+req->firstKeySym,wire->nSyms,w);\n\t\treturn 0;\n\t    }\n\t}\n\telse if (wire->nSyms!=0) {\n\t    *errorRtrn = _XkbErrCode3(0x17,i+req->firstKeySym,wire->nSyms);\n\t    return 0;\n\t}\n\tpSyms = (KeySym *)&wire[1];\n\twire = (xkbSymMapWireDesc *)&pSyms[wire->nSyms];\n    }\n\n    map = &xkb->map->key_sym_map[i];\n    for (;i<=(unsigned)xkb->max_key_code;i++,map++) {\n\tregister int g,nG,w;\n\tnG= XkbKeyNumGroups(xkb,i);\n\tfor (w=g=0;g<nG;g++)  {\n\t    if (map->kt_index[g]>=(unsigned)nTypes) {\n\t\t*errorRtrn = _XkbErrCode4(0x18,i,g,map->kt_index[g]);\n\t\treturn 0;\n\t    }\n\t    if (mapWidths[map->kt_index[g]]>w)\n\t\t    w= mapWidths[map->kt_index[g]];\n\t}\n\tsymsPerKey[i] = w*nG;\n    }\n    *wireRtrn = wire;\n    return 1;\n}","target":0,"code_token_length":942,"total_token_length":1178,"max_tokens_setting":2048}
+{"idx":352982,"func":"octetStringSubstringsMatch(\n\tint *matchp,\n\tslap_mask_t flags,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *value,\n\tvoid *assertedValue )\n{\n\tint match = 0;\n\tSubstringsAssertion *sub = assertedValue;\n\tstruct berval left = *value;\n\tint i;\n\tber_len_t inlen = 0;\n\n\t\/* Add up asserted input length *\/\n\tif ( !BER_BVISNULL( &sub->sa_initial ) ) {\n\t\tinlen += sub->sa_initial.bv_len;\n\t}\n\tif ( sub->sa_any ) {\n\t\tfor ( i = 0; !BER_BVISNULL( &sub->sa_any[i] ); i++ ) {\n\t\t\tinlen += sub->sa_any[i].bv_len;\n\t\t}\n\t}\n\tif ( !BER_BVISNULL( &sub->sa_final ) ) {\n\t\tinlen += sub->sa_final.bv_len;\n\t}\n\n\tif ( !BER_BVISNULL( &sub->sa_initial ) ) {\n\t\tif ( inlen > left.bv_len ) {\n\t\t\tmatch = 1;\n\t\t\tgoto done;\n\t\t}\n\n\t\tmatch = memcmp( sub->sa_initial.bv_val, left.bv_val,\n\t\t\tsub->sa_initial.bv_len );\n\n\t\tif ( match != 0 ) {\n\t\t\tgoto done;\n\t\t}\n\n\t\tleft.bv_val += sub->sa_initial.bv_len;\n\t\tleft.bv_len -= sub->sa_initial.bv_len;\n\t\tinlen -= sub->sa_initial.bv_len;\n\t}\n\n\tif ( !BER_BVISNULL( &sub->sa_final ) ) {\n\t\tif ( inlen > left.bv_len ) {\n\t\t\tmatch = 1;\n\t\t\tgoto done;\n\t\t}\n\n\t\tmatch = memcmp( sub->sa_final.bv_val,\n\t\t\t&left.bv_val[left.bv_len - sub->sa_final.bv_len],\n\t\t\tsub->sa_final.bv_len );\n\n\t\tif ( match != 0 ) {\n\t\t\tgoto done;\n\t\t}\n\n\t\tleft.bv_len -= sub->sa_final.bv_len;\n\t\tinlen -= sub->sa_final.bv_len;\n\t}\n\n\tif ( sub->sa_any ) {\n\t\tfor ( i = 0; !BER_BVISNULL( &sub->sa_any[i] ); i++ ) {\n\t\t\tber_len_t idx;\n\t\t\tchar *p;\n\nretry:\n\t\t\tif ( inlen > left.bv_len ) {\n\t\t\t\t\/* not enough length *\/\n\t\t\t\tmatch = 1;\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\tif ( BER_BVISEMPTY( &sub->sa_any[i] ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tp = memchr( left.bv_val, *sub->sa_any[i].bv_val, left.bv_len );\n\n\t\t\tif( p == NULL ) {\n\t\t\t\tmatch = 1;\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\tidx = p - left.bv_val;\n\n\t\t\tif ( idx >= left.bv_len ) {\n\t\t\t\t\/* this shouldn't happen *\/\n\t\t\t\treturn LDAP_OTHER;\n\t\t\t}\n\n\t\t\tleft.bv_val = p;\n\t\t\tleft.bv_len -= idx;\n\n\t\t\tif ( sub->sa_any[i].bv_len > left.bv_len ) {\n\t\t\t\t\/* not enough left *\/\n\t\t\t\tmatch = 1;\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\tmatch = memcmp( left.bv_val,\n\t\t\t\tsub->sa_any[i].bv_val,\n\t\t\t\tsub->sa_any[i].bv_len );\n\n\t\t\tif ( match != 0 ) {\n\t\t\t\tleft.bv_val++;\n\t\t\t\tleft.bv_len--;\n\t\t\t\tgoto retry;\n\t\t\t}\n\n\t\t\tleft.bv_val += sub->sa_any[i].bv_len;\n\t\t\tleft.bv_len -= sub->sa_any[i].bv_len;\n\t\t\tinlen -= sub->sa_any[i].bv_len;\n\t\t}\n\t}\n\ndone:\n\t*matchp = match;\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":816,"total_token_length":1052,"max_tokens_setting":2048}
+{"idx":254753,"func":"njs_typed_array_prototype_sort(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    u_char                      *base, *orig;\n    int64_t                     length;\n    uint32_t                    element_size;\n    njs_value_t                 *this, *comparefn;\n    njs_typed_array_t           *array;\n    njs_array_buffer_t          *buffer;\n    njs_typed_array_cmp_t       cmp;\n    njs_typed_array_sort_ctx_t  ctx;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_typed_array(this))) {\n        njs_type_error(vm, \"this is not a typed array\");\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(this);\n    if (njs_slow_path(njs_is_detached_buffer(array->buffer))) {\n        njs_type_error(vm, \"detached buffer\");\n        return NJS_ERROR;\n    }\n\n    ctx.vm = vm;\n    ctx.buffer = array->buffer;\n    ctx.exception = 0;\n\n    comparefn = njs_arg(args, nargs, 1);\n\n    if (njs_is_defined(comparefn)) {\n        if (njs_slow_path(!njs_is_function(comparefn))) {\n            njs_type_error(vm, \"comparefn must be callable or undefined\");\n            return NJS_ERROR;\n        }\n\n        ctx.function = njs_function(comparefn);\n\n    } else {\n        ctx.function = NULL;\n    }\n\n    switch (array->type) {\n    case NJS_OBJ_TYPE_UINT8_ARRAY:\n    case NJS_OBJ_TYPE_UINT8_CLAMPED_ARRAY:\n        cmp = njs_typed_array_compare_u8;\n        ctx.get = njs_typed_array_get_u8;\n        break;\n\n    case NJS_OBJ_TYPE_INT8_ARRAY:\n        cmp = njs_typed_array_compare_i8;\n        ctx.get = njs_typed_array_get_i8;\n        break;\n\n    case NJS_OBJ_TYPE_UINT16_ARRAY:\n        cmp = njs_typed_array_compare_u16;\n        ctx.get = njs_typed_array_get_u16;\n        break;\n\n    case NJS_OBJ_TYPE_INT16_ARRAY:\n        cmp = njs_typed_array_compare_i16;\n        ctx.get = njs_typed_array_get_i16;\n        break;\n\n    case NJS_OBJ_TYPE_UINT32_ARRAY:\n        cmp = njs_typed_array_compare_u32;\n        ctx.get = njs_typed_array_get_u32;\n        break;\n\n    case NJS_OBJ_TYPE_INT32_ARRAY:\n        cmp = njs_typed_array_compare_i32;\n        ctx.get = njs_typed_array_get_i32;\n        break;\n\n    case NJS_OBJ_TYPE_FLOAT32_ARRAY:\n        cmp = njs_typed_array_compare_f32;\n        ctx.get = njs_typed_array_get_f32;\n        break;\n\n    default:\n\n        \/* NJS_OBJ_TYPE_FLOAT64_ARRAY. *\/\n\n        cmp = njs_typed_array_compare_f64;\n        ctx.get = njs_typed_array_get_f64;\n        break;\n    }\n\n    buffer = njs_typed_array_writable(vm, array);\n    if (njs_slow_path(buffer == NULL)) {\n        return NJS_ERROR;\n    }\n\n    length = njs_typed_array_length(array);\n    element_size = njs_typed_array_element_size(array->type);\n    base = &buffer->u.u8[array->offset * element_size];\n    orig = base;\n\n    if (ctx.function != NULL) {\n        cmp = njs_typed_array_generic_compare;\n        base = njs_mp_alloc(vm->mem_pool, length * element_size);\n        if (njs_slow_path(base == NULL)) {\n            njs_memory_error(vm);\n            return NJS_ERROR;\n        }\n\n        memcpy(base, &buffer->u.u8[array->offset * element_size],\n               length * element_size);\n    }\n\n    njs_qsort(base, length, element_size, cmp, &ctx);\n    if (ctx.function != NULL) {\n        if (&buffer->u.u8[array->offset * element_size] == orig) {\n            memcpy(orig, base, length * element_size);\n        }\n\n        njs_mp_free(vm->mem_pool, base);\n    }\n\n    if (njs_slow_path(ctx.exception)) {\n        return NJS_ERROR;\n    }\n\n    njs_set_typed_array(&vm->retval, array);\n\n    return NJS_OK;\n}","target":0,"code_token_length":957,"total_token_length":1193,"max_tokens_setting":2048}
+{"idx":218789,"func":"static MagickBooleanType ReadPSDLayer(Image *image,const ImageInfo *image_info,\n  const PSDInfo *psd_info,LayerInfo* layer_info,ExceptionInfo *exception)\n{\n  char\n    message[MaxTextExtent];\n\n  MagickBooleanType\n    status;\n\n  PSDCompressionType\n    compression;\n\n  ssize_t\n    j;\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"    setting up new layer image\");\n  if (psd_info->mode != IndexedMode)\n    (void) SetImageBackgroundColor(layer_info->image);\n  layer_info->image->compose=PSDBlendModeToCompositeOperator(\n    layer_info->blendkey);\n  if (layer_info->visible == MagickFalse)\n    {\n      layer_info->image->compose=NoCompositeOp;\n      (void) SetImageArtifact(layer_info->image,\"psd:layer.invisible\",\"true\");\n    }\n  if (psd_info->mode == CMYKMode)\n    (void) SetImageColorspace(layer_info->image,CMYKColorspace);\n  else if ((psd_info->mode == BitmapMode) || (psd_info->mode == DuotoneMode) ||\n           (psd_info->mode == GrayscaleMode))\n    (void) SetImageColorspace(layer_info->image,GRAYColorspace);\n  \/*\n    Set up some hidden attributes for folks that need them.\n  *\/\n  (void) FormatLocaleString(message,MaxTextExtent,\"%.20g\",\n    (double) layer_info->page.x);\n  (void) SetImageArtifact(layer_info->image,\"psd:layer.x\",message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"%.20g\",\n    (double) layer_info->page.y);\n  (void) SetImageArtifact(layer_info->image,\"psd:layer.y\",message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"%.20g\",(double)\n    layer_info->opacity);\n  (void) SetImageArtifact(layer_info->image,\"psd:layer.opacity\",message);\n  (void) SetImageProperty(layer_info->image,\"label\",(char *) layer_info->name);\n\n  status=MagickTrue;\n  for (j=0; j < (ssize_t) layer_info->channels; j++)\n  {\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"    reading data for channel %.20g\",(double) j);\n\n    compression=(PSDCompressionType) ReadBlobShort(layer_info->image);\n    if ((compression == ZipWithPrediction) && (image->depth == 32))\n      {\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          TypeError,\"CompressionNotSupported\",\"ZipWithPrediction(32 bit)\");\n        return(MagickFalse);\n      }\n\n    layer_info->image->compression=ConvertPSDCompression(compression);\n    if (layer_info->channel_info[j].type == -1)\n      layer_info->image->matte=MagickTrue;\n\n    status=ReadPSDChannel(layer_info->image,image_info,psd_info,layer_info,\n      (size_t) j,compression,exception);\n    InheritException(exception,&layer_info->image->exception);\n\n    if (status == MagickFalse)\n      break;\n  }\n\n  if (status != MagickFalse)\n    status=ApplyPSDLayerOpacity(layer_info->image,layer_info->opacity,\n      MagickFalse,exception);\n\n  if ((status != MagickFalse) &&\n      (layer_info->image->colorspace == CMYKColorspace))\n    status=NegateImage(layer_info->image,MagickFalse);\n\n  if ((status != MagickFalse) && (layer_info->mask.image != (Image *) NULL))\n    {\n      const char\n        *option;\n      \n      layer_info->mask.image->page.x=layer_info->mask.page.x;\n      layer_info->mask.image->page.y=layer_info->mask.page.y;\n      \/* Do not composite the mask when it is disabled *\/\n      if ((layer_info->mask.flags & 0x02) == 0x02)\n        layer_info->mask.image->compose=NoCompositeOp;\n      else\n        status=ApplyPSDOpacityMask(layer_info->image,layer_info->mask.image,\n          layer_info->mask.background == 0 ? 0 : QuantumRange,MagickFalse,\n          exception);\n      option=GetImageOption(image_info,\"psd:preserve-opacity-mask\");\n      if (IsStringTrue(option) != MagickFalse)\n        PreservePSDOpacityMask(image,layer_info,exception);\n      layer_info->mask.image=DestroyImage(layer_info->mask.image);\n    }\n\n  return(status);\n}","target":0,"code_token_length":1016,"total_token_length":1252,"max_tokens_setting":2048}
+{"idx":473880,"func":"is_not_included(Node* x, Node* y, regex_t* reg)\n{\n  int i;\n  OnigDistance len;\n  OnigCodePoint code;\n  UChar *p, c;\n  int ytype;\n\n retry:\n  ytype = NTYPE(y);\n  switch (NTYPE(x)) {\n  case NT_CTYPE:\n    {\n      switch (ytype) {\n      case NT_CTYPE:\n\tif (NCTYPE(y)->ctype == NCTYPE(x)->ctype &&\n\t    NCTYPE(y)->not   != NCTYPE(x)->not)\n\t  return 1;\n\telse\n\t  return 0;\n\tbreak;\n\n      case NT_CCLASS:\n      swap:\n\t{\n\t  Node* tmp;\n\t  tmp = x; x = y; y = tmp;\n\t  goto retry;\n\t}\n\tbreak;\n\n      case NT_STR:\n\tgoto swap;\n\tbreak;\n\n      default:\n\tbreak;\n      }\n    }\n    break;\n\n  case NT_CCLASS:\n    {\n      CClassNode* xc = NCCLASS(x);\n      switch (ytype) {\n      case NT_CTYPE:\n\tswitch (NCTYPE(y)->ctype) {\n\tcase ONIGENC_CTYPE_WORD:\n\t  if (NCTYPE(y)->not == 0) {\n\t    if (IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) {\n\t      for (i = 0; i < SINGLE_BYTE_SIZE; i++) {\n\t\tif (BITSET_AT(xc->bs, i)) {\n\t\t  if (IS_CODE_SB_WORD(reg->enc, i)) return 0;\n\t\t}\n\t      }\n\t      return 1;\n\t    }\n\t    return 0;\n\t  }\n\t  else {\n\t    for (i = 0; i < SINGLE_BYTE_SIZE; i++) {\n\t      if (! IS_CODE_SB_WORD(reg->enc, i)) {\n\t\tif (!IS_NCCLASS_NOT(xc)) {\n\t\t  if (BITSET_AT(xc->bs, i))\n\t\t    return 0;\n\t\t}\n\t\telse {\n\t\t  if (! BITSET_AT(xc->bs, i))\n\t\t    return 0;\n\t\t}\n\t      }\n\t    }\n\t    return 1;\n\t  }\n\t  break;\n\n\tdefault:\n\t  break;\n\t}\n\tbreak;\n\n      case NT_CCLASS:\n\t{\n\t  int v;\n\t  CClassNode* yc = NCCLASS(y);\n\n\t  for (i = 0; i < SINGLE_BYTE_SIZE; i++) {\n\t    v = BITSET_AT(xc->bs, i);\n\t    if ((v != 0 && !IS_NCCLASS_NOT(xc)) ||\n                (v == 0 && IS_NCCLASS_NOT(xc))) {\n\t      v = BITSET_AT(yc->bs, i);\n\t      if ((v != 0 && !IS_NCCLASS_NOT(yc)) ||\n                  (v == 0 && IS_NCCLASS_NOT(yc)))\n\t\treturn 0;\n\t    }\n\t  }\n\t  if ((IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) ||\n\t      (IS_NULL(yc->mbuf) && !IS_NCCLASS_NOT(yc)))\n\t    return 1;\n\t  return 0;\n\t}\n\tbreak;\n\n      case NT_STR:\n\tgoto swap;\n\tbreak;\n\n      default:\n\tbreak;\n      }\n    }\n    break;\n\n  case NT_STR:\n    {\n      StrNode* xs = NSTR(x);\n      if (NSTRING_LEN(x) == 0)\n\tbreak;\n\n      c = *(xs->s);\n      switch (ytype) {\n      case NT_CTYPE:\n\tswitch (NCTYPE(y)->ctype) {\n\tcase ONIGENC_CTYPE_WORD:\n\t  if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end))\n\t    return NCTYPE(y)->not;\n\t  else\n\t    return !(NCTYPE(y)->not);\n\t  break;\n\tdefault:\n\t  break;\n\t}\n\tbreak;\n\n      case NT_CCLASS:\n\t{\n\t  CClassNode* cc = NCCLASS(y);\n\n\t  code = ONIGENC_MBC_TO_CODE(reg->enc, xs->s,\n\t\t\t\t     xs->s + ONIGENC_MBC_MAXLEN(reg->enc));\n\t  return (onig_is_code_in_cc(reg->enc, code, cc) != 0 ? 0 : 1);\n\t}\n\tbreak;\n\n      case NT_STR:\n\t{\n\t  UChar *q;\n\t  StrNode* ys = NSTR(y);\n\t  len = NSTRING_LEN(x);\n\t  if (len > NSTRING_LEN(y)) len = NSTRING_LEN(y);\n\t  if (NSTRING_IS_AMBIG(x) || NSTRING_IS_AMBIG(y)) {\n            \/* tiny version *\/\n            return 0;\n\t  }\n\t  else {\n\t    for (i = 0, p = ys->s, q = xs->s; (OnigDistance)i < len; i++, p++, q++) {\n\t      if (*p != *q) return 1;\n\t    }\n\t  }\n\t}\n\tbreak;\n\n      default:\n\tbreak;\n      }\n    }\n    break;\n\n  default:\n    break;\n  }\n\n  return 0;\n}","target":0,"code_token_length":1035,"total_token_length":1271,"max_tokens_setting":2048}
+{"idx":215549,"func":"int unlzw(in, out)\n    int in, out;    \/* input and output file descriptors *\/\n{\n    REG2   char_type  *stackp;\n    REG3   code_int   code;\n    REG4   int        finchar;\n    REG5   code_int   oldcode;\n    REG6   code_int   incode;\n    REG7   long       inbits;\n    REG8   long       posbits;\n    REG9   int        outpos;\n\/*  REG10  int        insize; (global) *\/\n    REG11  unsigned   bitmask;\n    REG12  code_int   free_ent;\n    REG13  code_int   maxcode;\n    REG14  code_int   maxmaxcode;\n    REG15  int        n_bits;\n    REG16  int        rsize;\n\n#ifdef MAXSEG_64K\n    tab_prefix[0] = tab_prefix0;\n    tab_prefix[1] = tab_prefix1;\n#endif\n    maxbits = get_byte();\n    block_mode = maxbits & BLOCK_MODE;\n    if ((maxbits & LZW_RESERVED) != 0) {\n\tWARN((stderr, \"\\n%s: %s: warning, unknown flags 0x%x\\n\",\n\t      program_name, ifname, maxbits & LZW_RESERVED));\n    }\n    maxbits &= BIT_MASK;\n    maxmaxcode = MAXCODE(maxbits);\n\n    if (maxbits > BITS) {\n\tfprintf(stderr,\n\t\t\"\\n%s: %s: compressed with %d bits, can only handle %d bits\\n\",\n\t\tprogram_name, ifname, maxbits, BITS);\n\texit_code = ERROR;\n\treturn ERROR;\n    }\n    rsize = insize;\n    maxcode = MAXCODE(n_bits = INIT_BITS)-1;\n    bitmask = (1<<n_bits)-1;\n    oldcode = -1;\n    finchar = 0;\n    outpos = 0;\n    posbits = inptr<<3;\n\n    free_ent = ((block_mode) ? FIRST : 256);\n\n    clear_tab_prefixof(); \/* Initialize the first 256 entries in the table. *\/\n\n    for (code = 255 ; code >= 0 ; --code) {\n\ttab_suffixof(code) = (char_type)code;\n    }\n    do {\n\tREG1 int i;\n\tint  e;\n\tint  o;\n\n    resetbuf:\n\te = insize-(o = (posbits>>3));\n\n\tfor (i = 0 ; i < e ; ++i) {\n\t    inbuf[i] = inbuf[i+o];\n\t}\n\tinsize = e;\n\tposbits = 0;\n\n\tif (insize < INBUF_EXTRA) {\n\t    rsize = read_buffer (in, (char *) inbuf + insize, INBUFSIZ);\n\t    if (rsize == -1) {\n\t\tread_error();\n\t    }\n\t    insize += rsize;\n\t    bytes_in += (off_t)rsize;\n\t}\n\tinbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 :\n\t\t  ((long)insize<<3)-(n_bits-1));\n\n\twhile (inbits > posbits) {\n\t    if (free_ent > maxcode) {\n\t\tposbits = ((posbits-1) +\n\t\t\t   ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3)));\n\t\t++n_bits;\n\t\tif (n_bits == maxbits) {\n\t\t    maxcode = maxmaxcode;\n\t\t} else {\n\t\t    maxcode = MAXCODE(n_bits)-1;\n\t\t}\n\t\tbitmask = (1<<n_bits)-1;\n\t\tgoto resetbuf;\n\t    }\n\t    input(inbuf,posbits,code,n_bits,bitmask);\n\t    Tracev((stderr, \"%d \", code));\n\n\t    if (oldcode == -1) {\n\t\tif (256 <= code)\n\t\t  gzip_error (\"corrupt input.\");\n\t\toutbuf[outpos++] = (char_type)(finchar = (int)(oldcode=code));\n\t\tcontinue;\n\t    }\n\t    if (code == CLEAR && block_mode) {\n\t\tclear_tab_prefixof();\n\t\tfree_ent = FIRST - 1;\n\t\tposbits = ((posbits-1) +\n\t\t\t   ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3)));\n\t\tmaxcode = MAXCODE(n_bits = INIT_BITS)-1;\n\t\tbitmask = (1<<n_bits)-1;\n\t\tgoto resetbuf;\n\t    }\n\t    incode = code;\n\t    stackp = de_stack;\n\n\t    if (code >= free_ent) { \/* Special case for KwKwK string. *\/\n\t\tif (code > free_ent) {\n#ifdef DEBUG\n\t\t    char_type *p;\n\n\t\t    posbits -= n_bits;\n\t\t    p = &inbuf[posbits>>3];\n\t\t    fprintf(stderr,\n\t\t\t    \"code:%ld free_ent:%ld n_bits:%d insize:%u\\n\",\n\t\t\t    code, free_ent, n_bits, insize);\n\t\t    fprintf(stderr,\n\t\t\t    \"posbits:%ld inbuf:%02X %02X %02X %02X %02X\\n\",\n\t\t\t    posbits, p[-1],p[0],p[1],p[2],p[3]);\n#endif\n\t\t    if (!test && outpos > 0) {\n\t\t\twrite_buf(out, (char*)outbuf, outpos);\n\t\t\tbytes_out += (off_t)outpos;\n\t\t    }\n\t\t    gzip_error (to_stdout\n\t\t\t\t? \"corrupt input.\"\n\t\t\t\t: \"corrupt input. Use zcat to recover some data.\");\n\t\t}\n\t\t*--stackp = (char_type)finchar;\n\t\tcode = oldcode;\n\t    }\n\n\t    while ((cmp_code_int)code >= (cmp_code_int)256) {\n\t\t\/* Generate output characters in reverse order *\/\n\t\t*--stackp = tab_suffixof(code);\n\t\tcode = tab_prefixof(code);\n\t    }\n\t    *--stackp =\t(char_type)(finchar = tab_suffixof(code));\n\n\t    \/* And put them out in forward order *\/\n\t    {\n\t\tREG1 int\ti;\n\n\t\tif (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) {\n\t\t    do {\n\t\t\tif (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos;\n\n\t\t\tif (i > 0) {\n\t\t\t    memcpy(outbuf+outpos, stackp, i);\n\t\t\t    outpos += i;\n\t\t\t}\n\t\t\tif (outpos >= OUTBUFSIZ) {\n\t\t\t    if (!test) {\n\t\t\t\twrite_buf(out, (char*)outbuf, outpos);\n\t\t\t\tbytes_out += (off_t)outpos;\n\t\t\t    }\n\t\t\t    outpos = 0;\n\t\t\t}\n\t\t\tstackp+= i;\n\t\t    } while ((i = (de_stack-stackp)) > 0);\n\t\t} else {\n\t\t    memcpy(outbuf+outpos, stackp, i);\n\t\t    outpos += i;\n\t\t}\n\t    }\n\n\t    if ((code = free_ent) < maxmaxcode) { \/* Generate the new entry. *\/\n\n\t\ttab_prefixof(code) = (unsigned short)oldcode;\n\t\ttab_suffixof(code) = (char_type)finchar;\n\t\tfree_ent = code+1;\n\t    }\n\t    oldcode = incode;\t\/* Remember previous code.\t*\/\n\t}\n    } while (rsize != 0);\n\n    if (!test && outpos > 0) {\n\twrite_buf(out, (char*)outbuf, outpos);\n\tbytes_out += (off_t)outpos;\n    }\n    return OK;\n}","target":1,"code_token_length":1607,"total_token_length":1843,"max_tokens_setting":2048}
+{"idx":197110,"func":"  void Compute(OpKernelContext* c) override {\n    core::RefCountPtr<Var> v;\n    OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n    OP_REQUIRES_OK(c, EnsureSparseVariableAccess<Device, T>(c, v.get()));\n    \/\/ NOTE: We hold the lock for the whole gather operation instead\n    \/\/ of increasing the reference count of v->tensor() to avoid a\n    \/\/ situation where a write to the same variable will see a\n    \/\/ reference count greater than one and make a copy of the\n    \/\/ (potentially very large) tensor buffer.\n    tf_shared_lock ml(*v->mu());\n    const Tensor& params = *v->tensor();\n    const Tensor& indices = c->input(1);\n    OP_REQUIRES(\n        c, TensorShapeUtils::IsVectorOrHigher(params.shape()),\n        errors::InvalidArgument(\"params must be at least 1 dimensional\"));\n\n    \/\/ Check that we have enough index space\n    const int64_t N = indices.NumElements();\n    OP_REQUIRES(\n        c, params.dim_size(0) <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"params.shape[0] too large for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", params.dim_size(0), \" > \",\n                                std::numeric_limits<Index>::max()));\n\n    \/\/ The result shape is params.shape[:batch_dims] +\n    \/\/ indices.shape[batch_dims:] + params.shape[batch_dims+1:].\n    TensorShape result_shape;\n    for (int i = 0; i < batch_dims_; ++i) {\n      result_shape.AddDim(params.dim_size(i));\n    }\n    for (int i = batch_dims_; i < indices.dims(); ++i) {\n      result_shape.AddDim(indices.dim_size(i));\n    }\n    for (int i = batch_dims_ + 1; i < params.dims(); ++i) {\n      result_shape.AddDim(params.dim_size(i));\n    }\n\n    Tensor* out = nullptr;\n    Tensor tmp;\n    if (params.dtype() == DT_VARIANT) {\n      tmp = Tensor(DT_VARIANT, result_shape);\n      c->set_output(0, tmp);\n      out = &tmp;\n    } else {\n      OP_REQUIRES_OK(c, c->allocate_output(0, result_shape, &out));\n    }\n\n    if (N > 0) {\n      Tensor tmp_indices;\n\n      \/\/ Points to the original or updated (if batch_dims is set) indices.\n      const Tensor* op_indices = &indices;\n      if (batch_dims_ > 0) {\n        OP_REQUIRES_OK(c, c->allocate_temp(indices.dtype(), indices.shape(),\n                                           &tmp_indices));\n        functor::DenseUpdate<Device, Index, ASSIGN> copy_functor;\n        copy_functor(c->eigen_device<Device>(), tmp_indices.flat<Index>(),\n                     indices.flat<Index>());\n\n        AddBatchOffsets(&tmp_indices, params);\n        op_indices = &tmp_indices;\n      }\n\n      int64_t gather_dim_size = 1;\n      for (int idx = 0; idx <= batch_dims_; ++idx) {\n        gather_dim_size *= params.dim_size(idx);\n      }\n      int64_t inner_size = 1;\n      for (int i = batch_dims_ + 1; i < params.dims(); ++i) {\n        inner_size *= params.dim_size(i);\n      }\n      auto params_flat = params.shaped<T, 3>({1, gather_dim_size, inner_size});\n      const auto indices_flat = op_indices->flat<Index>();\n      auto out_flat = out->shaped<T, 3>({1, N, out->NumElements() \/ N});\n\n      functor::GatherFunctor<Device, T, Index> functor;\n      int64_t bad_i = functor(c, params_flat, indices_flat, out_flat);\n\n      OP_REQUIRES(\n          c, bad_i < 0,\n          errors::InvalidArgument(\n              \"indices\", SliceDebugString(indices.shape(), bad_i), \" = \",\n              indices_flat(bad_i), \" is not in [0, \", params.dim_size(0), \")\"));\n    }\n  }","target":1,"code_token_length":889,"total_token_length":1125,"max_tokens_setting":2048}
+{"idx":458301,"func":"static int writeState(const char *stateFilename)\n{\n    struct logState *p;\n    FILE *f;\n    char *chptr;\n    unsigned int i = 0;\n    int error = 0;\n    int bytes = 0;\n    int fdcurr;\n    int fdsave;\n    struct stat sb;\n    char *tmpFilename = NULL;\n    struct tm now;\n    time_t now_time, last_time;\n    char *prevCtx;\n    int force_mode = 0;\n\n    if (!strcmp(stateFilename, \"\/dev\/null\"))\n        \/* explicitly asked not to write the state file *\/\n        return 0;\n\n    localtime_r(&nowSecs, &now);\n\n    tmpFilename = malloc(strlen(stateFilename) + 5 );\n    if (tmpFilename == NULL) {\n        message_OOM();\n        return 1;\n    }\n    strcpy(tmpFilename, stateFilename);\n    strcat(tmpFilename, \".tmp\");\n    \/* Remove possible tmp state file from previous run *\/\n    error = unlink(tmpFilename);\n    if (error == -1 && errno != ENOENT) {\n        message(MESS_ERROR, \"error removing old temporary state file %s: %s\\n\",\n                tmpFilename, strerror(errno));\n        free(tmpFilename);\n        return 1;\n    }\n    error = 0;\n\n    fdcurr = open(stateFilename, O_RDONLY);\n    if (fdcurr == -1) {\n        \/* the statefile should exist, lockState() already created an empty\n         * state file in case it did not exist initially *\/\n        message(MESS_ERROR, \"error opening state file %s: %s\\n\",\n                stateFilename, strerror(errno));\n        free(tmpFilename);\n        return 1;\n    }\n\n    \/* get attributes, to assign them to the new state file *\/\n\n    if (setSecCtx(fdcurr, stateFilename, &prevCtx) != 0) {\n        \/* error msg already printed *\/\n        free(tmpFilename);\n        close(fdcurr);\n        return 1;\n    }\n\n#ifdef WITH_ACL\n    if ((prev_acl = acl_get_fd(fdcurr)) == NULL) {\n        if (is_acl_well_supported(errno)) {\n            message(MESS_ERROR, \"getting file ACL %s: %s\\n\",\n                    stateFilename, strerror(errno));\n            restoreSecCtx(&prevCtx);\n            free(tmpFilename);\n            close(fdcurr);\n            return 1;\n        }\n    }\n#endif\n\n    if (fstat(fdcurr, &sb) == -1) {\n        message(MESS_ERROR, \"error stating %s: %s\\n\", stateFilename, strerror(errno));\n        restoreSecCtx(&prevCtx);\n        free(tmpFilename);\n#ifdef WITH_ACL\n        if (prev_acl) {\n            acl_free(prev_acl);\n            prev_acl = NULL;\n        }\n#endif\n        return 1;\n    }\n\n    close(fdcurr);\n\n    if (sb.st_mode & (mode_t)S_IROTH) {\n        \/* drop world-readable flag to prevent others from locking *\/\n        sb.st_mode &= ~(mode_t)S_IROTH;\n        force_mode = 1;\n    }\n\n    fdsave = createOutputFile(tmpFilename, O_RDWR, &sb, prev_acl, force_mode);\n#ifdef WITH_ACL\n    if (prev_acl) {\n        acl_free(prev_acl);\n        prev_acl = NULL;\n    }\n#endif\n    restoreSecCtx(&prevCtx);\n\n    if (fdsave < 0) {\n        free(tmpFilename);\n        return 1;\n    }\n\n    f = fdopen(fdsave, \"w\");\n    if (!f) {\n        message(MESS_ERROR, \"error creating temp state file %s: %s\\n\",\n                tmpFilename, strerror(errno));\n        free(tmpFilename);\n        return 1;\n    }\n\n    bytes =  fprintf(f, \"logrotate state -- version 2\\n\");\n    if (bytes < 0)\n        error = bytes;\n\n    \/*\n     * Time in seconds it takes earth to go around sun.  The value is\n     * astronomical measurement (solar year) rather than something derived from\n     * a convention (calendar year).\n     *\/\n#define SECONDS_IN_YEAR 31556926\n\n    for (i = 0; i < hashSize && error == 0; i++) {\n        for (p = states[i]->head.lh_first; p != NULL && error == 0;\n                p = p->list.le_next) {\n\n            \/* Skip states which are not used for more than a year. *\/\n            now_time = mktime(&now);\n            last_time = mktime(&p->lastRotated);\n            if (!p->isUsed && difftime(now_time, last_time) > SECONDS_IN_YEAR) {\n                message(MESS_DEBUG, \"Removing %s from state file, \"\n                        \"because it does not exist and has not been rotated for one year\\n\",\n                        p->fn);\n                continue;\n            }\n\n            error = fputc('\"', f) == EOF;\n            for (chptr = p->fn; *chptr && error == 0; chptr++) {\n                switch (*chptr) {\n                    case '\"':\n                    case '\\\\':\n                        error = fputc('\\\\', f) == EOF;\n                        break;\n                    case '\\n':\n                        error = fputc('\\\\', f) == EOF;\n                        if (error == 0) {\n                            error = fputc('n', f) == EOF;\n                        }\n                        continue;\n                    default:\n                        break;\n                }\n                if (error == 0 && fputc(*chptr, f) == EOF) {\n                    error = 1;\n                }\n            }\n\n            if (error == 0 && fputc('\"', f) == EOF)\n                error = 1;\n\n            if (error == 0) {\n                bytes = fprintf(f, \" %d-%d-%d-%d:%d:%d\\n\",\n                                p->lastRotated.tm_year + 1900,\n                                p->lastRotated.tm_mon + 1,\n                                p->lastRotated.tm_mday,\n                                p->lastRotated.tm_hour,\n                                p->lastRotated.tm_min,\n                                p->lastRotated.tm_sec);\n                if (bytes < 0)\n                    error = bytes;\n            }\n        }\n    }\n\n    if (error == 0)\n        error = fflush(f);\n\n    if (error == 0)\n        error = fsync(fdsave);\n\n    if (error == 0)\n        error = fclose(f);\n    else\n        fclose(f);\n\n    if (error == 0) {\n        if (rename(tmpFilename, stateFilename)) {\n            message(MESS_ERROR, \"error renaming temp state file %s to %s: %s\\n\",\n                    tmpFilename, stateFilename, strerror(errno));\n            unlink(tmpFilename);\n            error = 1;\n        }\n    }\n    else {\n        if (errno)\n            message(MESS_ERROR, \"error creating temp state file %s: %s\\n\",\n                    tmpFilename, strerror(errno));\n        else\n            message(MESS_ERROR, \"error creating temp state file %s%s\\n\",\n                    tmpFilename, error == ENOMEM ?\n                    \": Insufficient storage space is available.\" : \"\" );\n        unlink(tmpFilename);\n    }\n    free(tmpFilename);\n    return error;\n}","target":0,"code_token_length":1511,"total_token_length":1747,"max_tokens_setting":2048}
+{"idx":227025,"func":"IRC_PROTOCOL_CALLBACK(topic)\n{\n    char *pos_topic, *old_topic_color, *topic_color;\n    struct t_irc_channel *ptr_channel;\n    struct t_irc_nick *ptr_nick;\n    struct t_gui_buffer *ptr_buffer;\n\n    IRC_PROTOCOL_MIN_ARGS(3);\n\n    if (!irc_channel_is_channel (server, argv[2]))\n    {\n        weechat_printf (server->buffer,\n                        _(\"%s%s: \\\"%s\\\" command received without channel\"),\n                        weechat_prefix (\"error\"), IRC_PLUGIN_NAME, \"topic\");\n        return WEECHAT_RC_OK;\n    }\n\n    pos_topic = (argc > 3) ?\n        ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;\n\n    ptr_channel = irc_channel_search (server, argv[2]);\n    ptr_nick = irc_nick_search (server, ptr_channel, nick);\n    ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;\n\n    \/*\n     * unmask a smart filtered join if it is in hashtable\n     * \"join_smart_filtered\" of channel\n     *\/\n    if (ptr_channel)\n        irc_channel_join_smart_filtered_unmask (ptr_channel, nick);\n\n    if (pos_topic && pos_topic[0])\n    {\n        topic_color = irc_color_decode (\n            pos_topic,\n            weechat_config_boolean (irc_config_network_colors_receive));\n        if (weechat_config_boolean (irc_config_look_display_old_topic)\n            && ptr_channel && ptr_channel->topic && ptr_channel->topic[0])\n        {\n            old_topic_color = irc_color_decode (\n                ptr_channel->topic,\n                weechat_config_boolean (irc_config_network_colors_receive));\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, NULL, ptr_buffer),\n                date,\n                irc_protocol_tags (command, NULL, NULL, address),\n                _(\"%s%s%s%s has changed topic for %s%s%s from \\\"%s%s%s\\\" to \"\n                  \"\\\"%s%s%s\\\"\"),\n                weechat_prefix (\"network\"),\n                irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n                nick,\n                IRC_COLOR_RESET,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[2],\n                IRC_COLOR_RESET,\n                IRC_COLOR_TOPIC_OLD,\n                (old_topic_color) ? old_topic_color : ptr_channel->topic,\n                IRC_COLOR_RESET,\n                IRC_COLOR_TOPIC_NEW,\n                (topic_color) ? topic_color : pos_topic,\n                IRC_COLOR_RESET);\n            if (old_topic_color)\n                free (old_topic_color);\n        }\n        else\n        {\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, NULL, ptr_buffer),\n                date,\n                irc_protocol_tags (command, NULL, NULL, address),\n                _(\"%s%s%s%s has changed topic for %s%s%s to \\\"%s%s%s\\\"\"),\n                weechat_prefix (\"network\"),\n                irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n                nick,\n                IRC_COLOR_RESET,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[2],\n                IRC_COLOR_RESET,\n                IRC_COLOR_TOPIC_NEW,\n                (topic_color) ? topic_color : pos_topic,\n                IRC_COLOR_RESET);\n        }\n        if (topic_color)\n            free (topic_color);\n    }\n    else\n    {\n        if (weechat_config_boolean (irc_config_look_display_old_topic)\n            && ptr_channel && ptr_channel->topic && ptr_channel->topic[0])\n        {\n            old_topic_color = irc_color_decode (\n                ptr_channel->topic,\n                weechat_config_boolean (irc_config_network_colors_receive));\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, NULL, ptr_buffer),\n                date,\n                irc_protocol_tags (command, NULL, NULL, address),\n                _(\"%s%s%s%s has unset topic for %s%s%s (old topic: \"\n                  \"\\\"%s%s%s\\\")\"),\n                weechat_prefix (\"network\"),\n                irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n                nick,\n                IRC_COLOR_RESET,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[2],\n                IRC_COLOR_RESET,\n                IRC_COLOR_TOPIC_OLD,\n                (old_topic_color) ? old_topic_color : ptr_channel->topic,\n                IRC_COLOR_RESET);\n            if (old_topic_color)\n                free (old_topic_color);\n        }\n        else\n        {\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, NULL, ptr_buffer),\n                date,\n                irc_protocol_tags (command, NULL, NULL, address),\n                _(\"%s%s%s%s has unset topic for %s%s%s\"),\n                weechat_prefix (\"network\"),\n                irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n                nick,\n                IRC_COLOR_RESET,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[2],\n                IRC_COLOR_RESET);\n        }\n    }\n\n    if (ptr_channel)\n        irc_channel_set_topic (ptr_channel, pos_topic);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":1089,"total_token_length":1325,"max_tokens_setting":2048}
+{"idx":215400,"func":"int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max)\n{\n\tstruct page *page;\n\tstruct address_space *mapping;\n\t__be32 *pptr, *curr, *end;\n\tu32 mask, start, len, n;\n\t__be32 val;\n\tint i;\n\n\tlen = *max;\n\tif (!len)\n\t\treturn size;\n\n\tdprint(DBG_BITMAP, \"block_allocate: %u,%u,%u\\n\", size, offset, len);\n\tmutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);\n\tmapping = HFSPLUS_SB(sb).alloc_file->i_mapping;\n\tpage = read_mapping_page(mapping, offset \/ PAGE_CACHE_BITS, NULL);\n\tpptr = kmap(page);\n\tcurr = pptr + (offset & (PAGE_CACHE_BITS - 1)) \/ 32;\n\ti = offset % 32;\n\toffset &= ~(PAGE_CACHE_BITS - 1);\n\tif ((size ^ offset) \/ PAGE_CACHE_BITS)\n\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\telse\n\t\tend = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) \/ 32;\n\n\t\/* scan the first partial u32 for zero bits *\/\n\tval = *curr;\n\tif (~val) {\n\t\tn = be32_to_cpu(val);\n\t\tmask = (1U << 31) >> i;\n\t\tfor (; i < 32; mask >>= 1, i++) {\n\t\t\tif (!(n & mask))\n\t\t\t\tgoto found;\n\t\t}\n\t}\n\tcurr++;\n\n\t\/* scan complete u32s for the first zero bit *\/\n\twhile (1) {\n\t\twhile (curr < end) {\n\t\t\tval = *curr;\n\t\t\tif (~val) {\n\t\t\t\tn = be32_to_cpu(val);\n\t\t\t\tmask = 1 << 31;\n\t\t\t\tfor (i = 0; i < 32; mask >>= 1, i++) {\n\t\t\t\t\tif (!(n & mask))\n\t\t\t\t\t\tgoto found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurr++;\n\t\t}\n\t\tkunmap(page);\n\t\toffset += PAGE_CACHE_BITS;\n\t\tif (offset >= size)\n\t\t\tbreak;\n\t\tpage = read_mapping_page(mapping, offset \/ PAGE_CACHE_BITS,\n\t\t\t\t\t NULL);\n\t\tcurr = pptr = kmap(page);\n\t\tif ((size ^ offset) \/ PAGE_CACHE_BITS)\n\t\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\t\telse\n\t\t\tend = pptr + ((size + 31) & (PAGE_CACHE_BITS - 1)) \/ 32;\n\t}\n\tdprint(DBG_BITMAP, \"bitmap full\\n\");\n\tstart = size;\n\tgoto out;\n\nfound:\n\tstart = offset + (curr - pptr) * 32 + i;\n\tif (start >= size) {\n\t\tdprint(DBG_BITMAP, \"bitmap full\\n\");\n\t\tgoto out;\n\t}\n\t\/* do any partial u32 at the start *\/\n\tlen = min(size - start, len);\n\twhile (1) {\n\t\tn |= mask;\n\t\tif (++i >= 32)\n\t\t\tbreak;\n\t\tmask >>= 1;\n\t\tif (!--len || n & mask)\n\t\t\tgoto done;\n\t}\n\tif (!--len)\n\t\tgoto done;\n\t*curr++ = cpu_to_be32(n);\n\t\/* do full u32s *\/\n\twhile (1) {\n\t\twhile (curr < end) {\n\t\t\tn = be32_to_cpu(*curr);\n\t\t\tif (len < 32)\n\t\t\t\tgoto last;\n\t\t\tif (n) {\n\t\t\t\tlen = 32;\n\t\t\t\tgoto last;\n\t\t\t}\n\t\t\t*curr++ = cpu_to_be32(0xffffffff);\n\t\t\tlen -= 32;\n\t\t}\n\t\tset_page_dirty(page);\n\t\tkunmap(page);\n\t\toffset += PAGE_CACHE_BITS;\n\t\tpage = read_mapping_page(mapping, offset \/ PAGE_CACHE_BITS,\n\t\t\t\t\t NULL);\n\t\tpptr = kmap(page);\n\t\tcurr = pptr;\n\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\t}\nlast:\n\t\/* do any partial u32 at end *\/\n\tmask = 1U << 31;\n\tfor (i = 0; i < len; i++) {\n\t\tif (n & mask)\n\t\t\tbreak;\n\t\tn |= mask;\n\t\tmask >>= 1;\n\t}\ndone:\n\t*curr = cpu_to_be32(n);\n\tset_page_dirty(page);\n\tkunmap(page);\n\t*max = offset + (curr - pptr) * 32 + i - start;\n\tHFSPLUS_SB(sb).free_blocks -= *max;\n\tsb->s_dirt = 1;\n\tdprint(DBG_BITMAP, \"-> %u,%u\\n\", start, *max);\nout:\n\tmutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);\n\treturn start;\n}","target":1,"code_token_length":1017,"total_token_length":1253,"max_tokens_setting":2048}
+{"idx":400122,"func":"TerminalClient::TerminalClient(shared_ptr<SocketHandler> _socketHandler,\n                               shared_ptr<SocketHandler> _pipeSocketHandler,\n                               const SocketEndpoint& _socketEndpoint,\n                               const string& id, const string& passkey,\n                               shared_ptr<Console> _console, bool jumphost,\n                               const string& tunnels,\n                               const string& reverseTunnels,\n                               bool forwardSshAgent,\n                               const string& identityAgent)\n    : console(_console), shuttingDown(false) {\n  portForwardHandler = shared_ptr<PortForwardHandler>(\n      new PortForwardHandler(_socketHandler, _pipeSocketHandler));\n  InitialPayload payload;\n  payload.set_jumphost(jumphost);\n\n  try {\n    if (tunnels.length()) {\n      auto pfsrs = parseRangesToRequests(tunnels);\n      for (auto& pfsr : pfsrs) {\n#ifdef WIN32\n        STFATAL << \"Source tunnel not supported on windows yet\";\n#else\n        auto pfsresponse =\n            portForwardHandler->createSource(pfsr, nullptr, -1, -1);\n        if (pfsresponse.has_error()) {\n          throw std::runtime_error(pfsresponse.error());\n        }\n#endif\n      }\n    }\n    if (reverseTunnels.length()) {\n      auto pfsrs = parseRangesToRequests(reverseTunnels);\n      for (auto& pfsr : pfsrs) {\n        *(payload.add_reversetunnels()) = pfsr;\n      }\n    }\n    if (forwardSshAgent) {\n      PortForwardSourceRequest pfsr;\n      string authSock = \"\";\n      if (identityAgent.length()) {\n        authSock.assign(identityAgent);\n      } else {\n        auto authSockEnv = getenv(\"SSH_AUTH_SOCK\");\n        if (!authSockEnv) {\n          CLOG(INFO, \"stdout\")\n              << \"Missing environment variable SSH_AUTH_SOCK.  Are you sure \"\n                 \"you \"\n                 \"ran ssh-agent first?\"\n              << endl;\n          exit(1);\n        }\n        authSock.assign(authSockEnv);\n      }\n      if (authSock.length()) {\n        pfsr.mutable_destination()->set_name(authSock);\n        pfsr.set_environmentvariable(\"SSH_AUTH_SOCK\");\n        *(payload.add_reversetunnels()) = pfsr;\n      }\n    }\n  } catch (const std::runtime_error& ex) {\n    CLOG(INFO, \"stdout\") << \"Error establishing port forward: \" << ex.what()\n                         << endl;\n    exit(1);\n  }\n\n  connection = shared_ptr<ClientConnection>(\n      new ClientConnection(_socketHandler, _socketEndpoint, id, passkey));\n\n  int connectFailCount = 0;\n  while (true) {\n    try {\n      bool fail = true;\n      if (connection->connect()) {\n        connection->writePacket(\n            Packet(EtPacketType::INITIAL_PAYLOAD, protoToString(payload)));\n        fd_set rfd;\n        timeval tv;\n        for (int a = 0; a < 3; a++) {\n          FD_ZERO(&rfd);\n          int clientFd = connection->getSocketFd();\n          if (clientFd < 0) {\n            std::this_thread::sleep_for(std::chrono::seconds(1));\n            continue;\n          }\n          FD_SET(clientFd, &rfd);\n          tv.tv_sec = 1;\n          tv.tv_usec = 0;\n          select(clientFd + 1, &rfd, NULL, NULL, &tv);\n          if (FD_ISSET(clientFd, &rfd)) {\n            Packet initialResponsePacket;\n            if (connection->readPacket(&initialResponsePacket)) {\n              if (initialResponsePacket.getHeader() !=\n                  EtPacketType::INITIAL_RESPONSE) {\n                CLOG(INFO, \"stdout\") << \"Error: Missing initial response\\n\";\n                STFATAL << \"Missing initial response!\";\n              }\n              auto initialResponse = stringToProto<InitialResponse>(\n                  initialResponsePacket.getPayload());\n              if (initialResponse.has_error()) {\n                CLOG(INFO, \"stdout\") << \"Error initializing connection: \"\n                                     << initialResponse.error() << endl;\n                exit(1);\n              }\n              fail = false;\n              break;\n            }\n          }\n        }\n      }\n      if (fail) {\n        LOG(WARNING) << \"Connecting to server failed: Connect timeout\";\n        connectFailCount++;\n        if (connectFailCount == 3) {\n          throw std::runtime_error(\"Connect Timeout\");\n        }\n      }\n    } catch (const runtime_error& err) {\n      LOG(INFO) << \"Could not make initial connection to server\";\n      CLOG(INFO, \"stdout\") << \"Could not make initial connection to \"\n                           << _socketEndpoint << \": \" << err.what() << endl;\n      exit(1);\n    }\n\n    TelemetryService::get()->logToDatadog(\"Connection Established\",\n                                          el::Level::Info, __FILE__, __LINE__);\n    break;\n  }\n  VLOG(1) << \"Client created with id: \" << connection->getId();\n};","target":0,"code_token_length":1056,"total_token_length":1292,"max_tokens_setting":2048}
+{"idx":249985,"func":"GF_Err DoFullInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emulation, u64 StartOffset)\n{\n\n\tu32 i, tracksDone;\n\tTrackWriter *tmp, *curWriter, *prevWriter;\n\tGF_Err e;\n\tu64 DTS, DTStmp, TStmp;\n\ts64 res;\n\tu32 descIndex, sampSize, chunkNumber;\n\tu16 curGroupID, curTrackPriority;\n\tBool forceNewChunk, writeGroup;\n\tGF_StscEntry *stsc_ent;\n\t\/\/this is used to emulate the write ...\n\tu64 offset, totSize, sampOffset;\n\tGF_ISOFile *movie = mw->movie;\n\n\ttotSize = 0;\n\tcurGroupID = 1;\n\n\tprevWriter = NULL;\n\t\/\/we emulate a write from this offset...\n\toffset = StartOffset;\n\ttracksDone = 0;\n\n\t\/\/browse each groups\n\twhile (1) {\n\t\twriteGroup = 1;\n\n\t\t\/\/proceed a group\n\t\twhile (writeGroup) {\n\t\t\tu32 nb_samp = 1;\n\t\t\tBool self_contained, chunked_forced=GF_FALSE;\n\t\t\t\/\/first get the appropriated sample for the min time in this group\n\t\t\tcurWriter = NULL;\n\t\t\tDTStmp = (u64) -1;\n\t\t\tTStmp = 0;\n\t\t\tcurTrackPriority = (u16) -1;\n\n\t\t\ti=0;\n\t\t\twhile ((tmp = (TrackWriter*)gf_list_enum(writers, &i))) {\n\n\t\t\t\t\/\/is it done writing ?\n\t\t\t\t\/\/is it in our group ??\n\t\t\t\tif (tmp->isDone || tmp->stbl->groupID != curGroupID) continue;\n\n\t\t\t\t\/\/OK, get the current sample in this track\n\t\t\t\tstbl_GetSampleDTS(tmp->stbl->TimeToSample, tmp->sampleNumber, &DTS);\n\t\t\t\tres = TStmp ? DTStmp * tmp->timeScale - DTS * TStmp : 0;\n\t\t\t\tif (res < 0) continue;\n\t\t\t\tif ((!res) && curTrackPriority <= tmp->stbl->trackPriority) continue;\n\t\t\t\tcurWriter = tmp;\n\t\t\t\tcurTrackPriority = tmp->stbl->trackPriority;\n\t\t\t\tDTStmp = DTS;\n\t\t\t\tTStmp = tmp->timeScale;\n\t\t\t}\n\t\t\t\/\/no sample found, we're done with this group\n\t\t\tif (!curWriter) {\n\t\t\t\t\/\/we're done with the group\n\t\t\t\twriteGroup = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/\/To Check: are empty sample tables allowed ???\n\t\t\tif (curWriter->sampleNumber > curWriter->stbl->SampleSize->sampleCount) {\n\t\t\t\tcurWriter->isDone = 1;\n\t\t\t\ttracksDone ++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\te = stbl_GetSampleInfos(curWriter->stbl, curWriter->sampleNumber, &sampOffset, &chunkNumber, &descIndex, &stsc_ent);\n\t\t\tif (e) return e;\n\t\t\te = stbl_GetSampleSize(curWriter->stbl->SampleSize, curWriter->sampleNumber, &sampSize);\n\t\t\tif (e) return e;\n\n\t\t\tupdate_writer_constant_dur(movie, curWriter, stsc_ent, &nb_samp, &sampSize, GF_FALSE);\n\n\t\t\tif (curWriter->stbl->MaxChunkSize && (curWriter->chunkSize + sampSize > curWriter->stbl->MaxChunkSize)) {\n\t\t\t\tcurWriter->chunkSize = 0;\n\t\t\t\tchunked_forced = forceNewChunk = 1;\n\t\t\t}\n\t\t\tcurWriter->chunkSize += sampSize;\n\n\t\t\tself_contained = ((curWriter->all_dref_mode==ISOM_DREF_SELF) || Media_IsSelfContained(curWriter->mdia, descIndex) ) ? GF_TRUE : GF_FALSE;\n\n\t\t\t\/\/do we actually write, or do we emulate ?\n\t\t\tif (Emulation) {\n\t\t\t\t\/\/are we in the same track ??? If not, force a new chunk when adding this sample\n\t\t\t\tif (!chunked_forced) {\n\t\t\t\t\tif (curWriter != prevWriter) {\n\t\t\t\t\t\tforceNewChunk = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tforceNewChunk = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\/\/update our offsets...\n\t\t\t\tif (self_contained) {\n\t\t\t\t\te = stbl_SetChunkAndOffset(curWriter->stbl, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, offset, forceNewChunk, nb_samp);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\toffset += sampSize;\n\t\t\t\t\ttotSize += sampSize;\n\t\t\t\t} else {\n\/\/\t\t\t\t\tif (curWriter->prev_offset != sampOffset) forceNewChunk = 1;\n\t\t\t\t\tcurWriter->prev_offset = sampOffset + sampSize;\n\n\t\t\t\t\t\/\/we have a DataRef, so use the offset idicated in sampleToChunk\n\t\t\t\t\t\/\/and ChunkOffset tables...\n\t\t\t\t\te = stbl_SetChunkAndOffset(curWriter->stbl, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, sampOffset, chunked_forced, nb_samp);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t\/\/this is no game, we're writing ....\n\t\t\t\tif (self_contained) {\n\t\t\t\t\te = WriteSample(mw, sampSize, sampOffset, stsc_ent->isEdited, bs, 1);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/\/ok, the sample is done\n\t\t\tif (curWriter->sampleNumber == curWriter->stbl->SampleSize->sampleCount) {\n\t\t\t\tcurWriter->isDone = 1;\n\t\t\t\t\/\/one more track done...\n\t\t\t\ttracksDone ++;\n\t\t\t} else {\n\t\t\t\tcurWriter->sampleNumber += nb_samp;\n\t\t\t}\n\t\t\tprevWriter = curWriter;\n\t\t}\n\t\t\/\/if all our track are done, break\n\t\tif (tracksDone == gf_list_count(writers)) break;\n\t\t\/\/go to next group\n\t\tcurGroupID ++;\n\t}\n\tif (movie->mdat)\n\t\tmovie->mdat->dataSize = totSize;\n\treturn GF_OK;\n}","target":0,"code_token_length":1345,"total_token_length":1581,"max_tokens_setting":2048}
+{"idx":299318,"func":"static MagickBooleanType WriteMATImage(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  char\n    MATLAB_HDR[0x80];\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  size_t\n    imageListLength;\n\n  struct tm\n    local_time;\n\n  time_t\n    current_time;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"enter MAT\");\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(MagickFalse);\n  image->depth=8;\n\n  current_time=time((time_t *) NULL);\n#if defined(MAGICKCORE_HAVE_LOCALTIME_R)\n  (void) localtime_r(¤t_time,&local_time);\n#else\n  (void) memcpy(&local_time,localtime(¤t_time),sizeof(local_time));\n#endif\n  (void) memset(MATLAB_HDR,' ',MagickMin(sizeof(MATLAB_HDR),124));\n  FormatLocaleString(MATLAB_HDR,sizeof(MATLAB_HDR),\n    \"MATLAB 5.0 MAT-file, Platform: %s, Created on: %s %s %2d %2d:%2d:%2d %d\",\n    OsDesc,DayOfWTab[local_time.tm_wday],MonthsTab[local_time.tm_mon],\n    local_time.tm_mday,local_time.tm_hour,local_time.tm_min,\n    local_time.tm_sec,local_time.tm_year+1900);\n  MATLAB_HDR[0x7C]=0;\n  MATLAB_HDR[0x7D]=1;\n  MATLAB_HDR[0x7E]='I';\n  MATLAB_HDR[0x7F]='M';\n  (void) WriteBlob(image,sizeof(MATLAB_HDR),(unsigned char *) MATLAB_HDR);\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    char\n      padding;\n\n    MagickBooleanType\n      is_gray;\n\n    QuantumInfo\n      *quantum_info;\n\n    size_t\n      data_size;\n\n    unsigned char\n      *pixels;\n\n    unsigned int\n      z;\n\n    (void) TransformImageColorspace(image,sRGBColorspace,exception);\n    is_gray=SetImageGray(image,exception);\n    z=(is_gray != MagickFalse) ? 0 : 3;\n\n    \/*\n      Store MAT header.\n    *\/\n    data_size = image->rows * image->columns;\n    if (is_gray == MagickFalse)\n      data_size*=3;\n    padding=((unsigned char)(data_size-1) & 0x7) ^ 0x7;\n\n    (void) WriteBlobLSBLong(image,miMATRIX);\n    (void) WriteBlobLSBLong(image,(unsigned int) data_size+padding+\n      ((is_gray != MagickFalse) ? 48 : 56));\n    (void) WriteBlobLSBLong(image,0x6); \/* 0x88 *\/\n    (void) WriteBlobLSBLong(image,0x8); \/* 0x8C *\/\n    (void) WriteBlobLSBLong(image,0x6); \/* 0x90 *\/\n    (void) WriteBlobLSBLong(image,0);\n    (void) WriteBlobLSBLong(image,0x5); \/* 0x98 *\/\n    (void) WriteBlobLSBLong(image,(is_gray != MagickFalse) ? 0x8 : 0xC); \/* 0x9C - DimFlag *\/\n    (void) WriteBlobLSBLong(image,(unsigned int) image->rows);    \/* x: 0xA0 *\/\n    (void) WriteBlobLSBLong(image,(unsigned int) image->columns); \/* y: 0xA4 *\/\n    if (is_gray == MagickFalse)\n      {\n        (void) WriteBlobLSBLong(image,3); \/* z: 0xA8 *\/\n        (void) WriteBlobLSBLong(image,0);\n      }\n    (void) WriteBlobLSBShort(image,1);  \/* 0xB0 *\/\n    (void) WriteBlobLSBShort(image,1);  \/* 0xB2 *\/\n    (void) WriteBlobLSBLong(image,'M'); \/* 0xB4 *\/\n    (void) WriteBlobLSBLong(image,0x2); \/* 0xB8 *\/\n    (void) WriteBlobLSBLong(image,(unsigned int) data_size); \/* 0xBC *\/\n\n    \/*\n      Store image data.\n    *\/\n    quantum_info=AcquireQuantumInfo(image_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetQuantumPixels(quantum_info);\n    do\n    {\n      const Quantum\n        *p;\n\n      ssize_t\n        y;\n\n      for (y=0; y < (ssize_t)image->columns; y++)\n      {\n        p=GetVirtualPixels(image,y,0,1,image->rows,exception);\n        if (p == (const Quantum *) NULL)\n          break;\n        (void) ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n          z2qtype[z],pixels,exception);\n        (void) WriteBlob(image,image->rows,pixels);\n      }\n      if (SyncAuthenticPixels(image,exception) == MagickFalse)\n        break;\n    } while (z-- >= 2);\n    while (padding-- > 0)\n      (void) WriteBlobByte(image,0);\n    quantum_info=DestroyQuantumInfo(quantum_info);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  (void) CloseBlob(image);\n  return(status);\n}","target":0,"code_token_length":1347,"total_token_length":1583,"max_tokens_setting":2048}
+{"idx":343225,"func":"static void displayrate(const char *word, off_t size,\n                        const double started,\n                        const char * const name, int up)\n{\n    double ended;\n    double t;\n    double speed;\n    char speedstring[64];\n\n    ended = get_usec_time();\n\n    t = ended - started;\n    if (t > 0.0 && size > (off_t) 0) {\n        speed = size \/ t;\n    } else {\n        speed = 0.0;\n    }\n    if (speed > 524288.0) {\n        addreply(0, MSG_TRANSFER_RATE_M, t, speed \/ 1048576.0);\n    } else if (speed > 512.0) {\n        addreply(0, MSG_TRANSFER_RATE_K, t, speed \/ 1024.0);\n    } else if (speed > 0.1) {\n        addreply(0, MSG_TRANSFER_RATE_B, t, speed);\n    }\n    if (!SNCHECK(snprintf(speedstring, sizeof speedstring,\n                          \" (%llu bytes, %.2fKB\/sec)\",\n                          (unsigned long long) size, speed \/ 1024.0),\n                 sizeof speedstring)) {\n        logfile(LOG_NOTICE, \"%s%s%s%s %s %s\", root_directory,\n                *name == '\/' ? \"\" : wd,\n                (*name != '\/' && (!*wd || wd[strlen(wd) - 1] != '\/'))\n                ? \"\/\" : \"\", name, word, speedstring);\n    }\n    \/* Tons of #ifdef here, but it avoids a pointless call to realpath() *\/\n#if defined(WITH_UPLOAD_SCRIPT) || defined(WITH_ALTLOG)\n    if (\n# ifdef WITH_ALTLOG\n        altlog_format != ALTLOG_NONE\n# endif\n# if defined(WITH_UPLOAD_SCRIPT) && defined(WITH_ALTLOG)\n        ||\n# endif\n# if (defined(WITH_UPLOAD_SCRIPT))\n        (do_upload_script != 0 && up != 0)\n# endif\n        )\n    {\n        char *alloca_filename_real;\n        const size_t sizeof_filename_real = PATH_MAX + VHOST_PREFIX_MAX_LEN;\n        char *resolved_path;\n        const size_t sizeof_resolved_path = PATH_MAX + 1U;\n\n        if ((resolved_path = malloc(sizeof_resolved_path)) == NULL) {\n            return;\n        }\n        resolved_path[sizeof_resolved_path - 1U] = 0;\n        if (realpath(name, resolved_path) == NULL) {\n            if (up != 0) {\n                (void) unlink(name);\n            }\n            free(resolved_path);\n            logfile(LOG_ERR, \"realpath() failure : [%s] => [%s]\",\n                    name, strerror(errno));\n            return;\n        }\n        if (resolved_path[sizeof_resolved_path - 1U] != 0) {\n            for (;;) {\n                *resolved_path++ = 0;\n            }\n        }\n        if ((alloca_filename_real = ALLOCA(sizeof_filename_real)) == NULL) {\n            free(resolved_path);\n            return;\n        }\n# ifdef WITH_VIRTUAL_CHROOT\n        if (SNCHECK(snprintf(alloca_filename_real, sizeof_filename_real,\n                             \"\\001%s\", resolved_path), sizeof_filename_real)) {\n            goto rp_failure;\n        }\n# else\n        if (SNCHECK(snprintf(alloca_filename_real, sizeof_filename_real,\n                             \"\\001%s%s\", root_directory,\n                             (*resolved_path == '\/' ? resolved_path + 1 :\n                              resolved_path)), sizeof_filename_real)) {\n            goto rp_failure;\n        }\n# endif\n# ifdef WITH_ALTLOG\n        (void) altlog_writexfer(up, alloca_filename_real + 1, size, t);\n# endif\n# if defined(WITH_UPLOAD_SCRIPT)\n        if (do_upload_script != 0 && up != 0) {\n            upload_pipe_push(account, alloca_filename_real);\n        }\n# endif\n        rp_failure:\n        free(resolved_path);\n        ALLOCA_FREE(alloca_filename_real);\n    }\n#else\n    (void) up;\n#endif\n}","target":0,"code_token_length":866,"total_token_length":1102,"max_tokens_setting":2048}
+{"idx":477299,"func":"static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead,\n\t\t\t\t     struct tipc_bearer *b,\n\t\t\t\t     struct sk_buff **skb, int err)\n{\n\tstruct tipc_skb_cb *skb_cb = TIPC_SKB_CB(*skb);\n\tstruct tipc_crypto *rx = aead->crypto;\n\tstruct tipc_aead *tmp = NULL;\n\tstruct tipc_ehdr *ehdr;\n\tstruct tipc_node *n;\n\n\t\/* Is this completed by TX? *\/\n\tif (unlikely(is_tx(aead->crypto))) {\n\t\trx = skb_cb->tx_clone_ctx.rx;\n\t\tpr_debug(\"TX->RX(%s): err %d, aead %p, skb->next %p, flags %x\\n\",\n\t\t\t (rx) ? tipc_node_get_id_str(rx->node) : \"-\", err, aead,\n\t\t\t (*skb)->next, skb_cb->flags);\n\t\tpr_debug(\"skb_cb [recurs %d, last %p], tx->aead [%p %p %p]\\n\",\n\t\t\t skb_cb->tx_clone_ctx.recurs, skb_cb->tx_clone_ctx.last,\n\t\t\t aead->crypto->aead[1], aead->crypto->aead[2],\n\t\t\t aead->crypto->aead[3]);\n\t\tif (unlikely(err)) {\n\t\t\tif (err == -EBADMSG && (*skb)->next)\n\t\t\t\ttipc_rcv(net, (*skb)->next, b);\n\t\t\tgoto free_skb;\n\t\t}\n\n\t\tif (likely((*skb)->next)) {\n\t\t\tkfree_skb((*skb)->next);\n\t\t\t(*skb)->next = NULL;\n\t\t}\n\t\tehdr = (struct tipc_ehdr *)(*skb)->data;\n\t\tif (!rx) {\n\t\t\tWARN_ON(ehdr->user != LINK_CONFIG);\n\t\t\tn = tipc_node_create(net, 0, ehdr->id, 0xffffu, 0,\n\t\t\t\t\t     true);\n\t\t\trx = tipc_node_crypto_rx(n);\n\t\t\tif (unlikely(!rx))\n\t\t\t\tgoto free_skb;\n\t\t}\n\n\t\t\/* Ignore cloning if it was TX master key *\/\n\t\tif (ehdr->tx_key == KEY_MASTER)\n\t\t\tgoto rcv;\n\t\tif (tipc_aead_clone(&tmp, aead) < 0)\n\t\t\tgoto rcv;\n\t\tWARN_ON(!refcount_inc_not_zero(&tmp->refcnt));\n\t\tif (tipc_crypto_key_attach(rx, tmp, ehdr->tx_key, false) < 0) {\n\t\t\ttipc_aead_free(&tmp->rcu);\n\t\t\tgoto rcv;\n\t\t}\n\t\ttipc_aead_put(aead);\n\t\taead = tmp;\n\t}\n\n\tif (unlikely(err)) {\n\t\ttipc_aead_users_dec((struct tipc_aead __force __rcu *)aead, INT_MIN);\n\t\tgoto free_skb;\n\t}\n\n\t\/* Set the RX key's user *\/\n\ttipc_aead_users_set((struct tipc_aead __force __rcu *)aead, 1);\n\n\t\/* Mark this point, RX works *\/\n\trx->timer1 = jiffies;\n\nrcv:\n\t\/* Remove ehdr & auth. tag prior to tipc_rcv() *\/\n\tehdr = (struct tipc_ehdr *)(*skb)->data;\n\n\t\/* Mark this point, RX passive still works *\/\n\tif (rx->key.passive && ehdr->tx_key == rx->key.passive)\n\t\trx->timer2 = jiffies;\n\n\tskb_reset_network_header(*skb);\n\tskb_pull(*skb, tipc_ehdr_size(ehdr));\n\tpskb_trim(*skb, (*skb)->len - aead->authsize);\n\n\t\/* Validate TIPCv2 message *\/\n\tif (unlikely(!tipc_msg_validate(skb))) {\n\t\tpr_err_ratelimited(\"Packet dropped after decryption!\\n\");\n\t\tgoto free_skb;\n\t}\n\n\t\/* Ok, everything's fine, try to synch own keys according to peers' *\/\n\ttipc_crypto_key_synch(rx, *skb);\n\n\t\/* Mark skb decrypted *\/\n\tskb_cb->decrypted = 1;\n\n\t\/* Clear clone cxt if any *\/\n\tif (likely(!skb_cb->tx_clone_deferred))\n\t\tgoto exit;\n\tskb_cb->tx_clone_deferred = 0;\n\tmemset(&skb_cb->tx_clone_ctx, 0, sizeof(skb_cb->tx_clone_ctx));\n\tgoto exit;\n\nfree_skb:\n\tkfree_skb(*skb);\n\t*skb = NULL;\n\nexit:\n\ttipc_aead_put(aead);\n\tif (rx)\n\t\ttipc_node_put(rx->node);\n}","target":0,"code_token_length":956,"total_token_length":1192,"max_tokens_setting":2048}
+{"idx":358127,"func":"sonmp_decode(struct lldpd *cfg, char *frame, int s,\n    struct lldpd_hardware *hardware,\n    struct lldpd_chassis **newchassis, struct lldpd_port **newport)\n{\n\tconst u_int8_t mcastaddr[] = SONMP_MULTICAST_ADDR;\n\tstruct lldpd_chassis *chassis;\n\tstruct lldpd_port *port;\n\tstruct lldpd_mgmt *mgmt;\n\tint length, i;\n\tu_int8_t *pos;\n\tu_int8_t seg[3], rchassis;\n\tstruct in_addr address;\n\n\tlog_debug(\"sonmp\", \"decode SONMP PDU from %s\",\n\t    hardware->h_ifname);\n\n\tif ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {\n\t\tlog_warn(\"sonmp\", \"failed to allocate remote chassis\");\n\t\treturn -1;\n\t}\n\tTAILQ_INIT(&chassis->c_mgmt);\n\tif ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) {\n\t\tlog_warn(\"sonmp\", \"failed to allocate remote port\");\n\t\tfree(chassis);\n\t\treturn -1;\n\t}\n#ifdef ENABLE_DOT1\n\tTAILQ_INIT(&port->p_vlans);\n#endif\n\n\tlength = s;\n\tpos = (u_int8_t*)frame;\n\tif (length < SONMP_SIZE + 2*ETHER_ADDR_LEN + sizeof(u_int16_t)) {\n\t\tlog_warnx(\"sonmp\", \"too short SONMP frame received on %s\", hardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\tif (PEEK_CMP(mcastaddr, sizeof(mcastaddr)) != 0)\n\t\t\/* There is two multicast address. We just handle only one of\n\t\t * them. *\/\n\t\tgoto malformed;\n\t\/* We skip to LLC PID *\/\n\tPEEK_DISCARD(ETHER_ADDR_LEN); PEEK_DISCARD_UINT16;\n\tPEEK_DISCARD(6);\n\tif (PEEK_UINT16 != LLC_PID_SONMP_HELLO) {\n\t\tlog_debug(\"sonmp\", \"incorrect LLC protocol ID received for SONMP on %s\",\n\t\t    hardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\n\tchassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_ADDR;\n\tif ((chassis->c_id = calloc(1, sizeof(struct in_addr) + 1)) == NULL) {\n\t\tlog_warn(\"sonmp\", \"unable to allocate memory for chassis id on %s\",\n\t\t\thardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\tchassis->c_id_len = sizeof(struct in_addr) + 1;\n\tchassis->c_id[0] = 1;\n\tPEEK_BYTES(&address, sizeof(struct in_addr));\n\tmemcpy(chassis->c_id + 1, &address, sizeof(struct in_addr));\n\tif (asprintf(&chassis->c_name, \"%s\", inet_ntoa(address)) == -1) {\n\t\tlog_warnx(\"sonmp\", \"unable to write chassis name for %s\",\n\t\t    hardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\tPEEK_BYTES(seg, sizeof(seg));\n\trchassis = PEEK_UINT8;\n\tfor (i=0; sonmp_chassis_types[i].type != 0; i++) {\n\t\tif (sonmp_chassis_types[i].type == rchassis)\n\t\t\tbreak;\n\t}\n\tif (asprintf(&chassis->c_descr, \"%s\",\n\t\tsonmp_chassis_types[i].description) == -1) {\n\t\tlog_warnx(\"sonmp\", \"unable to write chassis description for %s\",\n\t\t    hardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\tmgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4, &address, sizeof(struct in_addr), 0);\n\tif (mgmt == NULL) {\n\t\tif (errno == ENOMEM)\n\t\t\tlog_warn(\"sonmp\", \"unable to allocate memory for management address\");\n\t\telse\n\t\t\tlog_warn(\"sonmp\", \"too large management address received on %s\",\n\t\t\t    hardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\tTAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);\n\tport->p_ttl = cfg?(cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold):\n\t    LLDPD_TTL;\n\tport->p_ttl = (port->p_ttl + 999) \/ 1000;\n\n\tport->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL;\n\tif (asprintf(&port->p_id, \"%02x-%02x-%02x\",\n\t\tseg[0], seg[1], seg[2]) == -1) {\n\t\tlog_warn(\"sonmp\", \"unable to allocate memory for port id on %s\",\n\t\t    hardware->h_ifname);\n\t\tgoto malformed;\n\t}\n\tport->p_id_len = strlen(port->p_id);\n\n\t\/* Port description depend on the number of segments *\/\n\tif ((seg[0] == 0) && (seg[1] == 0)) {\n\t\tif (asprintf(&port->p_descr, \"port %d\",\n\t\t\tseg[2]) == -1) {\n\t\t\tlog_warnx(\"sonmp\", \"unable to write port description for %s\",\n\t\t\t    hardware->h_ifname);\n\t\t\tgoto malformed;\n\t\t}\n\t} else if (seg[0] == 0) {\n\t\tif (asprintf(&port->p_descr, \"port %d\/%d\",\n\t\t\tseg[1], seg[2]) == -1) {\n\t\t\tlog_warnx(\"sonmp\", \"unable to write port description for %s\",\n\t\t\t    hardware->h_ifname);\n\t\t\tgoto malformed;\n\t\t}\n\t} else {\n\t\tif (asprintf(&port->p_descr, \"port %x:%x:%x\",\n\t\t\tseg[0], seg[1], seg[2]) == -1) {\n\t\t\tlog_warnx(\"sonmp\", \"unable to write port description for %s\",\n\t\t\t    hardware->h_ifname);\n\t\t\tgoto malformed;\n\t\t}\n\t}\n\t*newchassis = chassis;\n\t*newport = port;\n\treturn 1;\n\nmalformed:\n\tlldpd_chassis_cleanup(chassis, 1);\n\tlldpd_port_cleanup(port, 1);\n\tfree(port);\n\treturn -1;\n}","target":0,"code_token_length":1327,"total_token_length":1563,"max_tokens_setting":2048}
+{"idx":237828,"func":"static int acurite_986_decode(r_device *decoder, bitbuffer_t *bitbuffer)\n{\n    int const browlen = 5;\n    uint8_t *bb, sensor_num, status, crc, crcc;\n    uint8_t br[8];\n    int8_t tempf; \/\/ Raw Temp is 8 bit signed Fahrenheit\n    uint16_t sensor_id, valid_cnt = 0;\n    char sensor_type;\n    char *channel_str;\n    int battery_low;\n    data_t *data;\n\n    int result = 0;\n\n    for (uint16_t brow = 0; brow < bitbuffer->num_rows; ++brow) {\n\n        decoder_logf(decoder, 2, __func__, \"row %u bits %u, bytes %d\", brow, bitbuffer->bits_per_row[brow], browlen);\n\n        if (bitbuffer->bits_per_row[brow] < 39 ||\n            bitbuffer->bits_per_row[brow] > 43 ) {\n            if (bitbuffer->bits_per_row[brow] > 16)\n                decoder_log(decoder, 2, __func__,\"skipping wrong len\");\n            result = DECODE_ABORT_LENGTH;\n            continue; \/\/ DECODE_ABORT_LENGTH\n        }\n        bb = bitbuffer->bb[brow];\n\n        \/\/ Reduce false positives\n        \/\/ may eliminate these with a better PPM (precise?) demod.\n        if ((bb[0] == 0xff && bb[1] == 0xff && bb[2] == 0xff) ||\n                (bb[0] == 0x00 && bb[1] == 0x00 && bb[2] == 0x00)) {\n            result = DECODE_ABORT_EARLY;\n            continue; \/\/ DECODE_ABORT_EARLY\n        }\n\n        \/\/ Reverse the bits, msg sent LSB first\n        for (int i = 0; i < browlen; i++)\n            br[i] = reverse8(bb[i]);\n\n        decoder_log_bitrow(decoder, 1, __func__, br, browlen * 8, \"reversed\");\n\n        tempf = br[0];\n        sensor_id = (br[1] << 8) + br[2];\n        status = br[3];\n        sensor_num = (status & 0x01) + 1;\n        status = status >> 1;\n        battery_low = ((status & 1) == 1);\n\n        \/\/ By default Sensor 1 is the Freezer, 2 Refrigerator\n        sensor_type = sensor_num == 2 ? 'F' : 'R';\n        channel_str = sensor_num == 2 ? \"2F\" : \"1R\";\n\n        crc = br[4];\n        crcc = crc8le(br, 4, 0x07, 0);\n\n        if (crcc != crc) {\n            decoder_logf_bitrow(decoder, 2, __func__, br, browlen * 8, \"bad CRC: %02x -\", crc8le(br, 4, 0x07, 0));\n            \/\/ HACK: rct 2018-04-22\n            \/\/ the message is often missing the last 1 bit either due to a\n            \/\/ problem with the device or demodulator\n            \/\/ Add 1 (0x80 because message is LSB) and retry CRC.\n            if (crcc == (crc | 0x80)) {\n                decoder_logf(decoder, 2, __func__, \"CRC fix %02x - %02x\", crc, crcc);\n            }\n            else {\n                continue; \/\/ DECODE_FAIL_MIC\n            }\n        }\n\n        if (tempf & 0x80) {\n            tempf = (tempf & 0x7f) * -1;\n        }\n\n        decoder_logf(decoder, 1, __func__, \"sensor 0x%04x - %d%c: %d F\", sensor_id, sensor_num, sensor_type, tempf);\n\n        \/* clang-format off *\/\n        data = data_make(\n                \"model\",            \"\",             DATA_STRING, \"Acurite-986\",\n                \"id\",               NULL,           DATA_INT,    sensor_id,\n                \"channel\",          NULL,           DATA_STRING, channel_str,\n                \"battery_ok\",       \"Battery\",      DATA_INT,    !battery_low,\n                \"temperature_F\",    \"temperature\",  DATA_FORMAT, \"%f F\", DATA_DOUBLE,    (float)tempf,\n                \"status\",           \"status\",       DATA_INT,    status,\n                \"mic\",              \"Integrity\",    DATA_STRING, \"CRC\",\n                NULL);\n        \/* clang-format on *\/\n\n        decoder_output_data(decoder, data);\n\n        valid_cnt++;\n    }\n\n    if (valid_cnt)\n        return 1;\n\n    return result;\n}","target":0,"code_token_length":1048,"total_token_length":1284,"max_tokens_setting":2048}
+{"idx":333074,"func":"nfa_regtry(\n    nfa_regprog_T   *prog,\n    colnr_T\t    col,\n    proftime_T\t    *tm UNUSED,\t\/\/ timeout limit or NULL\n    int\t\t    *timed_out UNUSED)\t\/\/ flag set on timeout or NULL\n{\n    int\t\ti;\n    regsubs_T\tsubs, m;\n    nfa_state_T\t*start = prog->start;\n    int\t\tresult;\n#ifdef ENABLE_LOG\n    FILE\t*f;\n#endif\n\n    rex.input = rex.line + col;\n#ifdef FEAT_RELTIME\n    nfa_time_limit = tm;\n    nfa_timed_out = timed_out;\n    nfa_time_count = 0;\n#endif\n\n#ifdef ENABLE_LOG\n    f = fopen(NFA_REGEXP_RUN_LOG, \"a\");\n    if (f != NULL)\n    {\n\tfprintf(f, \"\\n\\n\\t=======================================================\\n\");\n#ifdef DEBUG\n\tfprintf(f, \"\\tRegexp is \\\"%s\\\"\\n\", nfa_regengine.expr);\n#endif\n\tfprintf(f, \"\\tInput text is \\\"%s\\\" \\n\", rex.input);\n\tfprintf(f, \"\\t=======================================================\\n\\n\");\n\tnfa_print_state(f, start);\n\tfprintf(f, \"\\n\\n\");\n\tfclose(f);\n    }\n    else\n\temsg(\"Could not open temporary log file for writing\");\n#endif\n\n    clear_sub(&subs.norm);\n    clear_sub(&m.norm);\n#ifdef FEAT_SYN_HL\n    clear_sub(&subs.synt);\n    clear_sub(&m.synt);\n#endif\n\n    result = nfa_regmatch(prog, start, &subs, &m);\n    if (result == FALSE)\n\treturn 0;\n    else if (result == NFA_TOO_EXPENSIVE)\n\treturn result;\n\n    cleanup_subexpr();\n    if (REG_MULTI)\n    {\n\tfor (i = 0; i < subs.norm.in_use; i++)\n\t{\n\t    rex.reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum;\n\t    rex.reg_startpos[i].col = subs.norm.list.multi[i].start_col;\n\n\t    rex.reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum;\n\t    rex.reg_endpos[i].col = subs.norm.list.multi[i].end_col;\n\t}\n\n\tif (rex.reg_startpos[0].lnum < 0)\n\t{\n\t    rex.reg_startpos[0].lnum = 0;\n\t    rex.reg_startpos[0].col = col;\n\t}\n\tif (rex.reg_endpos[0].lnum < 0)\n\t{\n\t    \/\/ pattern has a \\ze but it didn't match, use current end\n\t    rex.reg_endpos[0].lnum = rex.lnum;\n\t    rex.reg_endpos[0].col = (int)(rex.input - rex.line);\n\t}\n\telse\n\t    \/\/ Use line number of \"\\ze\".\n\t    rex.lnum = rex.reg_endpos[0].lnum;\n    }\n    else\n    {\n\tfor (i = 0; i < subs.norm.in_use; i++)\n\t{\n\t    rex.reg_startp[i] = subs.norm.list.line[i].start;\n\t    rex.reg_endp[i] = subs.norm.list.line[i].end;\n\t}\n\n\tif (rex.reg_startp[0] == NULL)\n\t    rex.reg_startp[0] = rex.line + col;\n\tif (rex.reg_endp[0] == NULL)\n\t    rex.reg_endp[0] = rex.input;\n    }\n\n#ifdef FEAT_SYN_HL\n    \/\/ Package any found \\z(...\\) matches for export. Default is none.\n    unref_extmatch(re_extmatch_out);\n    re_extmatch_out = NULL;\n\n    if (prog->reghasz == REX_SET)\n    {\n\tcleanup_zsubexpr();\n\tre_extmatch_out = make_extmatch();\n\tif (re_extmatch_out == NULL)\n\t    return 0;\n\t\/\/ Loop over \\z1, \\z2, etc.  There is no \\z0.\n\tfor (i = 1; i < subs.synt.in_use; i++)\n\t{\n\t    if (REG_MULTI)\n\t    {\n\t\tstruct multipos *mpos = &subs.synt.list.multi[i];\n\n\t\t\/\/ Only accept single line matches that are valid.\n\t\tif (mpos->start_lnum >= 0\n\t\t\t&& mpos->start_lnum == mpos->end_lnum\n\t\t\t&& mpos->end_col >= mpos->start_col)\n\t\t    re_extmatch_out->matches[i] =\n\t\t\tvim_strnsave(reg_getline(mpos->start_lnum)\n\t\t\t\t\t\t\t    + mpos->start_col,\n\t\t\t\t\t     mpos->end_col - mpos->start_col);\n\t    }\n\t    else\n\t    {\n\t\tstruct linepos *lpos = &subs.synt.list.line[i];\n\n\t\tif (lpos->start != NULL && lpos->end != NULL)\n\t\t    re_extmatch_out->matches[i] =\n\t\t\t    vim_strnsave(lpos->start, lpos->end - lpos->start);\n\t    }\n\t}\n    }\n#endif\n\n    return 1 + rex.lnum;\n}","target":0,"code_token_length":1059,"total_token_length":1295,"max_tokens_setting":2048}
+{"idx":253565,"func":"int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,\n\t\tconst char *path,\n\t\tstruct cifs_sb_info *cifs_sb,\n\t\tstruct cached_fid **cfid)\n{\n\tstruct cifs_ses *ses = tcon->ses;\n\tstruct TCP_Server_Info *server = ses->server;\n\tstruct cifs_open_parms oparms;\n\tstruct smb2_create_rsp *o_rsp = NULL;\n\tstruct smb2_query_info_rsp *qi_rsp = NULL;\n\tint resp_buftype[2];\n\tstruct smb_rqst rqst[2];\n\tstruct kvec rsp_iov[2];\n\tstruct kvec open_iov[SMB2_CREATE_IOV_SIZE];\n\tstruct kvec qi_iov[1];\n\tint rc, flags = 0;\n\t__le16 utf16_path = 0; \/* Null - since an open of top of share *\/\n\tu8 oplock = SMB2_OPLOCK_LEVEL_II;\n\tstruct cifs_fid *pfid;\n\tstruct dentry *dentry;\n\n\tif (tcon->nohandlecache)\n\t\treturn -ENOTSUPP;\n\n\tif (cifs_sb->root == NULL)\n\t\treturn -ENOENT;\n\n\tif (strlen(path))\n\t\treturn -ENOENT;\n\n\tdentry = cifs_sb->root;\n\n\tmutex_lock(&tcon->crfid.fid_mutex);\n\tif (tcon->crfid.is_valid) {\n\t\tcifs_dbg(FYI, \"found a cached root file handle\\n\");\n\t\t*cfid = &tcon->crfid;\n\t\tkref_get(&tcon->crfid.refcount);\n\t\tmutex_unlock(&tcon->crfid.fid_mutex);\n\t\treturn 0;\n\t}\n\n\t\/*\n\t * We do not hold the lock for the open because in case\n\t * SMB2_open needs to reconnect, it will end up calling\n\t * cifs_mark_open_files_invalid() which takes the lock again\n\t * thus causing a deadlock\n\t *\/\n\n\tmutex_unlock(&tcon->crfid.fid_mutex);\n\n\tif (smb3_encryption_required(tcon))\n\t\tflags |= CIFS_TRANSFORM_REQ;\n\n\tif (!server->ops->new_lease_key)\n\t\treturn -EIO;\n\n\tpfid = tcon->crfid.fid;\n\tserver->ops->new_lease_key(pfid);\n\n\tmemset(rqst, 0, sizeof(rqst));\n\tresp_buftype[0] = resp_buftype[1] = CIFS_NO_BUFFER;\n\tmemset(rsp_iov, 0, sizeof(rsp_iov));\n\n\t\/* Open *\/\n\tmemset(&open_iov, 0, sizeof(open_iov));\n\trqst[0].rq_iov = open_iov;\n\trqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE;\n\n\toparms.tcon = tcon;\n\toparms.create_options = cifs_create_options(cifs_sb, 0);\n\toparms.desired_access = FILE_READ_ATTRIBUTES;\n\toparms.disposition = FILE_OPEN;\n\toparms.fid = pfid;\n\toparms.reconnect = false;\n\n\trc = SMB2_open_init(tcon, server,\n\t\t\t    &rqst[0], &oplock, &oparms, &utf16_path);\n\tif (rc)\n\t\tgoto oshr_free;\n\tsmb2_set_next_command(tcon, &rqst[0]);\n\n\tmemset(&qi_iov, 0, sizeof(qi_iov));\n\trqst[1].rq_iov = qi_iov;\n\trqst[1].rq_nvec = 1;\n\n\trc = SMB2_query_info_init(tcon, server,\n\t\t\t\t  &rqst[1], COMPOUND_FID,\n\t\t\t\t  COMPOUND_FID, FILE_ALL_INFORMATION,\n\t\t\t\t  SMB2_O_INFO_FILE, 0,\n\t\t\t\t  sizeof(struct smb2_file_all_info) +\n\t\t\t\t  PATH_MAX * 2, 0, NULL);\n\tif (rc)\n\t\tgoto oshr_free;\n\n\tsmb2_set_related(&rqst[1]);\n\n\trc = compound_send_recv(xid, ses, server,\n\t\t\t\tflags, 2, rqst,\n\t\t\t\tresp_buftype, rsp_iov);\n\tmutex_lock(&tcon->crfid.fid_mutex);\n\n\t\/*\n\t * Now we need to check again as the cached root might have\n\t * been successfully re-opened from a concurrent process\n\t *\/\n\n\tif (tcon->crfid.is_valid) {\n\t\t\/* work was already done *\/\n\n\t\t\/* stash fids for close() later *\/\n\t\tstruct cifs_fid fid = {\n\t\t\t.persistent_fid = pfid->persistent_fid,\n\t\t\t.volatile_fid = pfid->volatile_fid,\n\t\t};\n\n\t\t\/*\n\t\t * caller expects this func to set the fid in crfid to valid\n\t\t * cached root, so increment the refcount.\n\t\t *\/\n\t\tkref_get(&tcon->crfid.refcount);\n\n\t\tmutex_unlock(&tcon->crfid.fid_mutex);\n\n\t\tif (rc == 0) {\n\t\t\t\/* close extra handle outside of crit sec *\/\n\t\t\tSMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);\n\t\t}\n\t\trc = 0;\n\t\tgoto oshr_free;\n\t}\n\n\t\/* Cached root is still invalid, continue normaly *\/\n\n\tif (rc) {\n\t\tif (rc == -EREMCHG) {\n\t\t\ttcon->need_reconnect = true;\n\t\t\tpr_warn_once(\"server share %s deleted\\n\",\n\t\t\t\t     tcon->treeName);\n\t\t}\n\t\tgoto oshr_exit;\n\t}\n\n\tatomic_inc(&tcon->num_remote_opens);\n\n\to_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base;\n\toparms.fid->persistent_fid = o_rsp->PersistentFileId;\n\toparms.fid->volatile_fid = o_rsp->VolatileFileId;\n#ifdef CONFIG_CIFS_DEBUG2\n\toparms.fid->mid = le64_to_cpu(o_rsp->hdr.MessageId);\n#endif \/* CIFS_DEBUG2 *\/\n\n\ttcon->crfid.tcon = tcon;\n\ttcon->crfid.is_valid = true;\n\ttcon->crfid.dentry = dentry;\n\tdget(dentry);\n\tkref_init(&tcon->crfid.refcount);\n\n\t\/* BB TBD check to see if oplock level check can be removed below *\/\n\tif (o_rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) {\n\t\t\/*\n\t\t * See commit 2f94a3125b87. Increment the refcount when we\n\t\t * get a lease for root, release it if lease break occurs\n\t\t *\/\n\t\tkref_get(&tcon->crfid.refcount);\n\t\ttcon->crfid.has_lease = true;\n\t\tsmb2_parse_contexts(server, o_rsp,\n\t\t\t\t&oparms.fid->epoch,\n\t\t\t\t    oparms.fid->lease_key, &oplock,\n\t\t\t\t    NULL, NULL);\n\t} else\n\t\tgoto oshr_exit;\n\n\tqi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;\n\tif (le32_to_cpu(qi_rsp->OutputBufferLength) < sizeof(struct smb2_file_all_info))\n\t\tgoto oshr_exit;\n\tif (!smb2_validate_and_copy_iov(\n\t\t\t\tle16_to_cpu(qi_rsp->OutputBufferOffset),\n\t\t\t\tsizeof(struct smb2_file_all_info),\n\t\t\t\t&rsp_iov[1], sizeof(struct smb2_file_all_info),\n\t\t\t\t(char *)&tcon->crfid.file_all_info))\n\t\ttcon->crfid.file_all_info_is_valid = true;\n\ttcon->crfid.time = jiffies;\n\n\noshr_exit:\n\tmutex_unlock(&tcon->crfid.fid_mutex);\noshr_free:\n\tSMB2_open_free(&rqst[0]);\n\tSMB2_query_info_free(&rqst[1]);\n\tfree_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);\n\tfree_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);\n\tif (rc == 0)\n\t\t*cfid = &tcon->crfid;\n\treturn rc;\n}","target":0,"code_token_length":1681,"total_token_length":1917,"max_tokens_setting":2048}
+{"idx":337845,"func":"static int sctp_process_param(struct sctp_association *asoc,\n\t\t\t      union sctp_params param,\n\t\t\t      const union sctp_addr *peer_addr,\n\t\t\t      gfp_t gfp)\n{\n\tstruct sctp_endpoint *ep = asoc->ep;\n\tunion sctp_addr_param *addr_param;\n\tstruct net *net = asoc->base.net;\n\tstruct sctp_transport *t;\n\tenum sctp_scope scope;\n\tunion sctp_addr addr;\n\tstruct sctp_af *af;\n\tint retval = 1, i;\n\tu32 stale;\n\t__u16 sat;\n\n\t\/* We maintain all INIT parameters in network byte order all the\n\t * time.  This allows us to not worry about whether the parameters\n\t * came from a fresh INIT, and INIT ACK, or were stored in a cookie.\n\t *\/\n\tswitch (param.p->type) {\n\tcase SCTP_PARAM_IPV6_ADDRESS:\n\t\tif (PF_INET6 != asoc->base.sk->sk_family)\n\t\t\tbreak;\n\t\tgoto do_addr_param;\n\n\tcase SCTP_PARAM_IPV4_ADDRESS:\n\t\t\/* v4 addresses are not allowed on v6-only socket *\/\n\t\tif (ipv6_only_sock(asoc->base.sk))\n\t\t\tbreak;\ndo_addr_param:\n\t\taf = sctp_get_af_specific(param_type2af(param.p->type));\n\t\tif (!af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0))\n\t\t\tbreak;\n\t\tscope = sctp_scope(peer_addr);\n\t\tif (sctp_in_scope(net, &addr, scope))\n\t\t\tif (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))\n\t\t\t\treturn 0;\n\t\tbreak;\n\n\tcase SCTP_PARAM_COOKIE_PRESERVATIVE:\n\t\tif (!net->sctp.cookie_preserve_enable)\n\t\t\tbreak;\n\n\t\tstale = ntohl(param.life->lifespan_increment);\n\n\t\t\/* Suggested Cookie Life span increment's unit is msec,\n\t\t * (1\/1000sec).\n\t\t *\/\n\t\tasoc->cookie_life = ktime_add_ms(asoc->cookie_life, stale);\n\t\tbreak;\n\n\tcase SCTP_PARAM_HOST_NAME_ADDRESS:\n\t\tpr_debug(\"%s: unimplemented SCTP_HOST_NAME_ADDRESS\\n\", __func__);\n\t\tbreak;\n\n\tcase SCTP_PARAM_SUPPORTED_ADDRESS_TYPES:\n\t\t\/* Turn off the default values first so we'll know which\n\t\t * ones are really set by the peer.\n\t\t *\/\n\t\tasoc->peer.ipv4_address = 0;\n\t\tasoc->peer.ipv6_address = 0;\n\n\t\t\/* Assume that peer supports the address family\n\t\t * by which it sends a packet.\n\t\t *\/\n\t\tif (peer_addr->sa.sa_family == AF_INET6)\n\t\t\tasoc->peer.ipv6_address = 1;\n\t\telse if (peer_addr->sa.sa_family == AF_INET)\n\t\t\tasoc->peer.ipv4_address = 1;\n\n\t\t\/* Cycle through address types; avoid divide by 0. *\/\n\t\tsat = ntohs(param.p->length) - sizeof(struct sctp_paramhdr);\n\t\tif (sat)\n\t\t\tsat \/= sizeof(__u16);\n\n\t\tfor (i = 0; i < sat; ++i) {\n\t\t\tswitch (param.sat->types[i]) {\n\t\t\tcase SCTP_PARAM_IPV4_ADDRESS:\n\t\t\t\tasoc->peer.ipv4_address = 1;\n\t\t\t\tbreak;\n\n\t\t\tcase SCTP_PARAM_IPV6_ADDRESS:\n\t\t\t\tif (PF_INET6 == asoc->base.sk->sk_family)\n\t\t\t\t\tasoc->peer.ipv6_address = 1;\n\t\t\t\tbreak;\n\n\t\t\tcase SCTP_PARAM_HOST_NAME_ADDRESS:\n\t\t\t\tasoc->peer.hostname_address = 1;\n\t\t\t\tbreak;\n\n\t\t\tdefault: \/* Just ignore anything else.  *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase SCTP_PARAM_STATE_COOKIE:\n\t\tasoc->peer.cookie_len =\n\t\t\tntohs(param.p->length) - sizeof(struct sctp_paramhdr);\n\t\tkfree(asoc->peer.cookie);\n\t\tasoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp);\n\t\tif (!asoc->peer.cookie)\n\t\t\tretval = 0;\n\t\tbreak;\n\n\tcase SCTP_PARAM_HEARTBEAT_INFO:\n\t\t\/* Would be odd to receive, but it causes no problems. *\/\n\t\tbreak;\n\n\tcase SCTP_PARAM_UNRECOGNIZED_PARAMETERS:\n\t\t\/* Rejected during verify stage. *\/\n\t\tbreak;\n\n\tcase SCTP_PARAM_ECN_CAPABLE:\n\t\tif (asoc->ep->ecn_enable) {\n\t\t\tasoc->peer.ecn_capable = 1;\n\t\t\tbreak;\n\t\t}\n\t\t\/* Fall Through *\/\n\t\tgoto fall_through;\n\n\n\tcase SCTP_PARAM_ADAPTATION_LAYER_IND:\n\t\tasoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind);\n\t\tbreak;\n\n\tcase SCTP_PARAM_SET_PRIMARY:\n\t\tif (!ep->asconf_enable)\n\t\t\tgoto fall_through;\n\n\t\taddr_param = param.v + sizeof(struct sctp_addip_param);\n\n\t\taf = sctp_get_af_specific(param_type2af(addr_param->p.type));\n\t\tif (!af)\n\t\t\tbreak;\n\n\t\tif (!af->from_addr_param(&addr, addr_param,\n\t\t\t\t\t htons(asoc->peer.port), 0))\n\t\t\tbreak;\n\n\t\tif (!af->addr_valid(&addr, NULL, NULL))\n\t\t\tbreak;\n\n\t\tt = sctp_assoc_lookup_paddr(asoc, &addr);\n\t\tif (!t)\n\t\t\tbreak;\n\n\t\tsctp_assoc_set_primary(asoc, t);\n\t\tbreak;\n\n\tcase SCTP_PARAM_SUPPORTED_EXT:\n\t\tsctp_process_ext_param(asoc, param);\n\t\tbreak;\n\n\tcase SCTP_PARAM_FWD_TSN_SUPPORT:\n\t\tif (asoc->ep->prsctp_enable) {\n\t\t\tasoc->peer.prsctp_capable = 1;\n\t\t\tbreak;\n\t\t}\n\t\t\/* Fall Through *\/\n\t\tgoto fall_through;\n\n\tcase SCTP_PARAM_RANDOM:\n\t\tif (!ep->auth_enable)\n\t\t\tgoto fall_through;\n\n\t\t\/* Save peer's random parameter *\/\n\t\tkfree(asoc->peer.peer_random);\n\t\tasoc->peer.peer_random = kmemdup(param.p,\n\t\t\t\t\t    ntohs(param.p->length), gfp);\n\t\tif (!asoc->peer.peer_random) {\n\t\t\tretval = 0;\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\tcase SCTP_PARAM_HMAC_ALGO:\n\t\tif (!ep->auth_enable)\n\t\t\tgoto fall_through;\n\n\t\t\/* Save peer's HMAC list *\/\n\t\tkfree(asoc->peer.peer_hmacs);\n\t\tasoc->peer.peer_hmacs = kmemdup(param.p,\n\t\t\t\t\t    ntohs(param.p->length), gfp);\n\t\tif (!asoc->peer.peer_hmacs) {\n\t\t\tretval = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Set the default HMAC the peer requested*\/\n\t\tsctp_auth_asoc_set_default_hmac(asoc, param.hmac_algo);\n\t\tbreak;\n\n\tcase SCTP_PARAM_CHUNKS:\n\t\tif (!ep->auth_enable)\n\t\t\tgoto fall_through;\n\n\t\tkfree(asoc->peer.peer_chunks);\n\t\tasoc->peer.peer_chunks = kmemdup(param.p,\n\t\t\t\t\t    ntohs(param.p->length), gfp);\n\t\tif (!asoc->peer.peer_chunks)\n\t\t\tretval = 0;\n\t\tbreak;\nfall_through:\n\tdefault:\n\t\t\/* Any unrecognized parameters should have been caught\n\t\t * and handled by sctp_verify_param() which should be\n\t\t * called prior to this routine.  Simply log the error\n\t\t * here.\n\t\t *\/\n\t\tpr_debug(\"%s: ignoring param:%d for association:%p.\\n\",\n\t\t\t __func__, ntohs(param.p->type), asoc);\n\t\tbreak;\n\t}\n\n\treturn retval;\n}","target":0,"code_token_length":1601,"total_token_length":1837,"max_tokens_setting":2048}
+{"idx":346415,"func":"get_one_sourceline(source_cookie_T *sp)\n{\n    garray_T\t\tga;\n    int\t\t\tlen;\n    int\t\t\tc;\n    char_u\t\t*buf;\n#ifdef USE_CRNL\n    int\t\t\thas_cr;\t\t\/\/ CR-LF found\n#endif\n    int\t\t\thave_read = FALSE;\n\n    \/\/ use a growarray to store the sourced line\n    ga_init2(&ga, 1, 250);\n\n    \/\/ Loop until there is a finished line (or end-of-file).\n    ++sp->sourcing_lnum;\n    for (;;)\n    {\n\t\/\/ make room to read at least 120 (more) characters\n\tif (ga_grow(&ga, 120) == FAIL)\n\t    break;\n\tif (sp->source_from_buf)\n\t{\n\t    if (sp->buf_lnum >= sp->buflines.ga_len)\n\t\tbreak;\t\t    \/\/ all the lines are processed\n\t    ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);\n\t    sp->buf_lnum++;\n\t    if (ga_grow(&ga, 1) == FAIL)\n\t\tbreak;\n\t    buf = (char_u *)ga.ga_data;\n\t    buf[ga.ga_len++] = NUL;\n\t    len = ga.ga_len;\n\t}\n\telse\n\t{\n\t    buf = (char_u *)ga.ga_data;\n\t    if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,\n\t\t\tsp->fp) == NULL)\n\t\tbreak;\n\t    len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);\n\t}\n#ifdef USE_CRNL\n\t\/\/ Ignore a trailing CTRL-Z, when in Dos mode.\tOnly recognize the\n\t\/\/ CTRL-Z by its own, or after a NL.\n\tif (\t   (len == 1 || (len >= 2 && buf[len - 2] == '\\n'))\n\t\t&& sp->fileformat == EOL_DOS\n\t\t&& buf[len - 1] == Ctrl_Z)\n\t{\n\t    buf[len - 1] = NUL;\n\t    break;\n\t}\n#endif\n\n\thave_read = TRUE;\n\tga.ga_len = len;\n\n\t\/\/ If the line was longer than the buffer, read more.\n\tif (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\\n')\n\t    continue;\n\n\tif (len >= 1 && buf[len - 1] == '\\n')\t\/\/ remove trailing NL\n\t{\n#ifdef USE_CRNL\n\t    has_cr = (len >= 2 && buf[len - 2] == '\\r');\n\t    if (sp->fileformat == EOL_UNKNOWN)\n\t    {\n\t\tif (has_cr)\n\t\t    sp->fileformat = EOL_DOS;\n\t\telse\n\t\t    sp->fileformat = EOL_UNIX;\n\t    }\n\n\t    if (sp->fileformat == EOL_DOS)\n\t    {\n\t\tif (has_cr)\t    \/\/ replace trailing CR\n\t\t{\n\t\t    buf[len - 2] = '\\n';\n\t\t    --len;\n\t\t    --ga.ga_len;\n\t\t}\n\t\telse\t    \/\/ lines like \":map xx yy^M\" will have failed\n\t\t{\n\t\t    if (!sp->error)\n\t\t    {\n\t\t\tmsg_source(HL_ATTR(HLF_W));\n\t\t\temsg(_(\"W15: Warning: Wrong line separator, ^M may be missing\"));\n\t\t    }\n\t\t    sp->error = TRUE;\n\t\t    sp->fileformat = EOL_UNIX;\n\t\t}\n\t    }\n#endif\n\t    \/\/ The '\\n' is escaped if there is an odd number of ^V's just\n\t    \/\/ before it, first set \"c\" just before the 'V's and then check\n\t    \/\/ len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo\n\t    for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--)\n\t\t;\n\t    if ((len & 1) != (c & 1))\t\/\/ escaped NL, read more\n\t    {\n\t\t++sp->sourcing_lnum;\n\t\tcontinue;\n\t    }\n\n\t    buf[len - 1] = NUL;\t\t\/\/ remove the NL\n\t}\n\n\t\/\/ Check for ^C here now and then, so recursive :so can be broken.\n\tline_breakcheck();\n\tbreak;\n    }\n\n    if (have_read)\n\treturn (char_u *)ga.ga_data;\n\n    vim_free(ga.ga_data);\n    return NULL;\n}","target":0,"code_token_length":951,"total_token_length":1187,"max_tokens_setting":2048}
+{"idx":301504,"func":"score_combine(suginfo_T *su)\n{\n    int\t\ti;\n    int\t\tj;\n    garray_T\tga;\n    garray_T\t*gap;\n    langp_T\t*lp;\n    suggest_T\t*stp;\n    char_u\t*p;\n    char_u\tbadsound[MAXWLEN];\n    int\t\tround;\n    int\t\tlpi;\n    slang_T\t*slang = NULL;\n\n    \/\/ Add the alternate score to su_ga.\n    for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)\n    {\n\tlp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);\n\tif (lp->lp_slang->sl_sal.ga_len > 0)\n\t{\n\t    \/\/ soundfold the bad word\n\t    slang = lp->lp_slang;\n\t    spell_soundfold(slang, su->su_fbadword, TRUE, badsound);\n\n\t    for (i = 0; i < su->su_ga.ga_len; ++i)\n\t    {\n\t\tstp = &SUG(su->su_ga, i);\n\t\tstp->st_altscore = stp_sal_score(stp, su, slang, badsound);\n\t\tif (stp->st_altscore == SCORE_MAXMAX)\n\t\t    stp->st_score = (stp->st_score * 3 + SCORE_BIG) \/ 4;\n\t\telse\n\t\t    stp->st_score = (stp->st_score * 3\n\t\t\t\t\t\t  + stp->st_altscore) \/ 4;\n\t\tstp->st_salscore = FALSE;\n\t    }\n\t    break;\n\t}\n    }\n\n    if (slang == NULL)\t\/\/ Using \"double\" without sound folding.\n    {\n\t(void)cleanup_suggestions(&su->su_ga, su->su_maxscore,\n\t\t\t\t\t\t\t     su->su_maxcount);\n\treturn;\n    }\n\n    \/\/ Add the alternate score to su_sga.\n    for (i = 0; i < su->su_sga.ga_len; ++i)\n    {\n\tstp = &SUG(su->su_sga, i);\n\tstp->st_altscore = spell_edit_score(slang,\n\t\t\t\t\t\tsu->su_badword, stp->st_word);\n\tif (stp->st_score == SCORE_MAXMAX)\n\t    stp->st_score = (SCORE_BIG * 7 + stp->st_altscore) \/ 8;\n\telse\n\t    stp->st_score = (stp->st_score * 7 + stp->st_altscore) \/ 8;\n\tstp->st_salscore = TRUE;\n    }\n\n    \/\/ Remove bad suggestions, sort the suggestions and truncate at \"maxcount\"\n    \/\/ for both lists.\n    check_suggestions(su, &su->su_ga);\n    (void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);\n    check_suggestions(su, &su->su_sga);\n    (void)cleanup_suggestions(&su->su_sga, su->su_maxscore, su->su_maxcount);\n\n    ga_init2(&ga, sizeof(suginfo_T), 1);\n    if (ga_grow(&ga, su->su_ga.ga_len + su->su_sga.ga_len) == FAIL)\n\treturn;\n\n    stp = &SUG(ga, 0);\n    for (i = 0; i < su->su_ga.ga_len || i < su->su_sga.ga_len; ++i)\n    {\n\t\/\/ round 1: get a suggestion from su_ga\n\t\/\/ round 2: get a suggestion from su_sga\n\tfor (round = 1; round <= 2; ++round)\n\t{\n\t    gap = round == 1 ? &su->su_ga : &su->su_sga;\n\t    if (i < gap->ga_len)\n\t    {\n\t\t\/\/ Don't add a word if it's already there.\n\t\tp = SUG(*gap, i).st_word;\n\t\tfor (j = 0; j < ga.ga_len; ++j)\n\t\t    if (STRCMP(stp[j].st_word, p) == 0)\n\t\t\tbreak;\n\t\tif (j == ga.ga_len)\n\t\t    stp[ga.ga_len++] = SUG(*gap, i);\n\t\telse\n\t\t    vim_free(p);\n\t    }\n\t}\n    }\n\n    ga_clear(&su->su_ga);\n    ga_clear(&su->su_sga);\n\n    \/\/ Truncate the list to the number of suggestions that will be displayed.\n    if (ga.ga_len > su->su_maxcount)\n    {\n\tfor (i = su->su_maxcount; i < ga.ga_len; ++i)\n\t    vim_free(stp[i].st_word);\n\tga.ga_len = su->su_maxcount;\n    }\n\n    su->su_ga = ga;\n}","target":0,"code_token_length":1040,"total_token_length":1276,"max_tokens_setting":2048}
+{"idx":215976,"func":"extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang,\n                                   int *ressize, bool is_icon)\n{\n\tWin32CursorIconDir *icondir;\n\tWin32CursorIconFileDir *fileicondir;\n\tchar *memory;\n\tint c, size, offset, skipped;\n\n\t\/* get resource data and size *\/\n\ticondir = (Win32CursorIconDir *) get_resource_entry(fi, wr, &size);\n\tif (icondir == NULL) {\n\t\t\/* get_resource_entry will print error *\/\n\t\treturn NULL;\n\t}\n\n\t\/* calculate total size of output file *\/\n\tRETURN_IF_BAD_POINTER(NULL, icondir->count);\n\tskipped = 0;\n\tfor (c = 0 ; c < icondir->count ; c++) {\n\t\tint level;\n\t    \tint iconsize;\n\t\tchar name[14];\n\t\tWinResource *fwr;\n\n\t\tRETURN_IF_BAD_POINTER(NULL, icondir->entries[c]);\n\t\t\/*printf(\"%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d\\n\", c,\n\t\t\ticondir->entries[c].bytes_in_res,\n\t\t\t(is_icon ? icondir->entries[c].res_info.icon.width : icondir->entries[c].res_info.cursor.width),\n\t\t\t(is_icon ? icondir->entries[c].res_info.icon.height : icondir->entries[c].res_info.cursor.height),\n\t\t\ticondir->entries[c].plane_count,\n\t\t\ticondir->entries[c].bit_count);*\/\n\n\t\t\/* find the corresponding icon resource *\/\n\t\tsnprintf(name, sizeof(name)\/sizeof(char), \"-%d\", icondir->entries[c].res_id);\n\t\tfwr = find_resource(fi, (is_icon ? \"-3\" : \"-1\"), name, lang, &level);\n\t\tif (fwr == NULL) {\n\t\t\twarn(_(\"%s: could not find `%s' in `%s' resource.\"),\n\t\t\t \tfi->name, &name[1], (is_icon ? \"group_icon\" : \"group_cursor\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (get_resource_entry(fi, fwr, &iconsize) != NULL) {\n\t\t    if (iconsize == 0) {\n\t\t\twarn(_(\"%s: icon resource `%s' is empty, skipping\"), fi->name, name);\n\t\t\tskipped++;\n\t\t\tcontinue;\n\t\t    }\n\t\t    if (iconsize != icondir->entries[c].bytes_in_res) {\n\t\t\twarn(_(\"%s: mismatch of size in icon resource `%s' and group (%d vs %d)\"), fi->name, name, iconsize, icondir->entries[c].bytes_in_res);\n\t\t    }\n\t\t    size += iconsize < icondir->entries[c].bytes_in_res ? icondir->entries[c].bytes_in_res : iconsize;\n\n\t\t    \/* cursor resources have two additional WORDs that contain\n\t\t     * hotspot info *\/\n\t\t    if (!is_icon)\n\t\t\tsize -= sizeof(uint16_t)*2;\n\t\t}\n\t}\n\toffset = sizeof(Win32CursorIconFileDir) + (icondir->count-skipped) * sizeof(Win32CursorIconFileDirEntry);\n\tsize += offset;\n\t*ressize = size;\n\n\t\/* allocate that much memory *\/\n\tmemory = xmalloc(size);\n\tfileicondir = (Win32CursorIconFileDir *) memory;\n\n\t\/* transfer Win32CursorIconDir structure members *\/\n\tfileicondir->reserved = icondir->reserved;\n\tfileicondir->type = icondir->type;\n\tfileicondir->count = icondir->count - skipped;\n\n\t\/* transfer each cursor\/icon: Win32CursorIconDirEntry and data *\/\n\tskipped = 0;\n\tfor (c = 0 ; c < icondir->count ; c++) {\n\t\tint level;\n\t\tchar name[14];\n\t\tWinResource *fwr;\n\t\tchar *data;\n\t\n\t\t\/* find the corresponding icon resource *\/\n\t\tsnprintf(name, sizeof(name)\/sizeof(char), \"-%d\", icondir->entries[c].res_id);\n\t\tfwr = find_resource(fi, (is_icon ? \"-3\" : \"-1\"), name, lang, &level);\n\t\tif (fwr == NULL) {\n\t\t\twarn(_(\"%s: could not find `%s' in `%s' resource.\"),\n\t\t\t \tfi->name, &name[1], (is_icon ? \"group_icon\" : \"group_cursor\"));\n\t\t\treturn NULL;\n\t\t}\n\n\t\t\/* get data and size of that resource *\/\n\t\tdata = get_resource_entry(fi, fwr, &size);\n\t\tif (data == NULL) {\n\t\t\t\/* get_resource_entry has printed error *\/\n\t\t\treturn NULL;\n\t\t}\n    \t    \tif (size == 0) {\n\t\t    skipped++;\n\t\t    continue;\n\t\t}\n\n\t\t\/* copy ICONDIRENTRY (not including last dwImageOffset) *\/\n\t\tmemcpy(&fileicondir->entries[c-skipped], &icondir->entries[c],\n\t\t\tsizeof(Win32CursorIconFileDirEntry)-sizeof(uint32_t));\n\n\t\t\/* special treatment for cursors *\/\n\t\tif (!is_icon) {\n\t\t\tfileicondir->entries[c-skipped].width = icondir->entries[c].res_info.cursor.width;\n\t\t\tfileicondir->entries[c-skipped].height = icondir->entries[c].res_info.cursor.height \/ 2;\n\t\t\tfileicondir->entries[c-skipped].color_count = 0;\n\t\t\tfileicondir->entries[c-skipped].reserved = 0;\n\t\t}\n\n\t\t\/* set image offset and increase it *\/\n\t\tfileicondir->entries[c-skipped].dib_offset = offset;\n\n\t\t\/* transfer resource into file memory *\/\n\t\tif (is_icon) {\n\t\t\tmemcpy(&memory[offset], data, icondir->entries[c].bytes_in_res);\n\t\t} else {\n\t\t\tfileicondir->entries[c-skipped].hotspot_x = ((uint16_t *) data)[0];\n\t\t\tfileicondir->entries[c-skipped].hotspot_y = ((uint16_t *) data)[1];\n\t\t\tmemcpy(&memory[offset], data+sizeof(uint16_t)*2,\n\t\t\t\t   icondir->entries[c].bytes_in_res-sizeof(uint16_t)*2);\n\t\t\toffset -= sizeof(uint16_t)*2;\n\t\t}\n\n\t\t\/* increase the offset pointer *\/\n\t\toffset += icondir->entries[c].bytes_in_res;\n\t}\n\n\treturn (void *) memory;\n}","target":1,"code_token_length":1343,"total_token_length":1579,"max_tokens_setting":2048}
+{"idx":514309,"func":"int multi_update::prepare(List<Item> ¬_used_values,\n\t\t\t  SELECT_LEX_UNIT *lex_unit)\n\n{\n  TABLE_LIST *table_ref;\n  SQL_I_List<TABLE_LIST> update;\n  table_map tables_to_update;\n  Item_field *item;\n  List_iterator_fast<Item> field_it(*fields);\n  List_iterator_fast<Item> value_it(*values);\n  uint i, max_fields;\n  uint leaf_table_count= 0;\n  List_iterator<TABLE_LIST> ti(updated_leaves);\n  DBUG_ENTER(\"multi_update::prepare\");\n\n  if (prepared)\n    DBUG_RETURN(0);\n  prepared= true;\n\n  thd->count_cuted_fields= CHECK_FIELD_WARN;\n  thd->cuted_fields=0L;\n  THD_STAGE_INFO(thd, stage_updating_main_table);\n\n  tables_to_update= get_table_map(fields);\n\n  if (!tables_to_update)\n  {\n    my_message(ER_NO_TABLES_USED, ER_THD(thd, ER_NO_TABLES_USED), MYF(0));\n    DBUG_RETURN(1);\n  }\n\n  \/*\n    We gather the set of columns read during evaluation of SET expression in\n    TABLE::tmp_set by pointing TABLE::read_set to it and then restore it after\n    setup_fields().\n  *\/\n  while ((table_ref= ti++))\n  {\n    if (table_ref->is_jtbm())\n      continue;\n\n    TABLE *table= table_ref->table;\n    if (tables_to_update & table->map)\n    {\n      DBUG_ASSERT(table->read_set == &table->def_read_set);\n      table->read_set= &table->tmp_set;\n      bitmap_clear_all(table->read_set);\n    }\n  }\n\n  \/*\n    We have to check values after setup_tables to get covering_keys right in\n    reference tables\n  *\/\n\n  int error= setup_fields(thd, Ref_ptr_array(),\n                          *values, MARK_COLUMNS_READ, 0, NULL, 0);\n\n  ti.rewind();\n  while ((table_ref= ti++))\n  {\n    if (table_ref->is_jtbm())\n      continue;\n\n    TABLE *table= table_ref->table;\n    if (tables_to_update & table->map)\n    {\n      table->read_set= &table->def_read_set;\n      bitmap_union(table->read_set, &table->tmp_set);\n    }\n  }\n  if (unlikely(error))\n    DBUG_RETURN(1);    \n\n  \/*\n    Save tables beeing updated in update_tables\n    update_table->shared is position for table\n    Don't use key read on tables that are updated\n  *\/\n\n  update.empty();\n  ti.rewind();\n  while ((table_ref= ti++))\n  {\n    \/* TODO: add support of view of join support *\/\n    if (table_ref->is_jtbm())\n      continue;\n    TABLE *table=table_ref->table;\n    leaf_table_count++;\n    if (tables_to_update & table->map)\n    {\n      TABLE_LIST *tl= (TABLE_LIST*) thd->memdup(table_ref,\n\t\t\t\t\t\tsizeof(*tl));\n      if (!tl)\n\tDBUG_RETURN(1);\n      update.link_in_list(tl, &tl->next_local);\n      tl->shared= table_count++;\n      table->no_keyread=1;\n      table->covering_keys.clear_all();\n      table->pos_in_table_list= tl;\n      table->prepare_triggers_for_update_stmt_or_event();\n      table->reset_default_fields();\n    }\n  }\n\n  table_count=  update.elements;\n  update_tables= update.first;\n\n  tmp_tables = (TABLE**) thd->calloc(sizeof(TABLE *) * table_count);\n  tmp_table_param = (TMP_TABLE_PARAM*) thd->calloc(sizeof(TMP_TABLE_PARAM) *\n\t\t\t\t\t\t   table_count);\n  fields_for_table= (List_item **) thd->alloc(sizeof(List_item *) *\n\t\t\t\t\t      table_count);\n  values_for_table= (List_item **) thd->alloc(sizeof(List_item *) *\n\t\t\t\t\t      table_count);\n  if (unlikely(thd->is_fatal_error))\n    DBUG_RETURN(1);\n  for (i=0 ; i < table_count ; i++)\n  {\n    fields_for_table[i]= new List_item;\n    values_for_table[i]= new List_item;\n  }\n  if (unlikely(thd->is_fatal_error))\n    DBUG_RETURN(1);\n\n  \/* Split fields into fields_for_table[] and values_by_table[] *\/\n\n  while ((item= (Item_field *) field_it++))\n  {\n    Item *value= value_it++;\n    uint offset= item->field->table->pos_in_table_list->shared;\n    fields_for_table[offset]->push_back(item, thd->mem_root);\n    values_for_table[offset]->push_back(value, thd->mem_root);\n  }\n  if (unlikely(thd->is_fatal_error))\n    DBUG_RETURN(1);\n\n  \/* Allocate copy fields *\/\n  max_fields=0;\n  for (i=0 ; i < table_count ; i++)\n  {\n    set_if_bigger(max_fields, fields_for_table[i]->elements + leaf_table_count);\n    if (fields_for_table[i]->elements)\n    {\n      TABLE *table= ((Item_field*)(fields_for_table[i]->head()))->field->table;\n      switch_to_nullable_trigger_fields(*fields_for_table[i], table);\n      switch_to_nullable_trigger_fields(*values_for_table[i], table);\n    }\n  }\n  copy_field= new (thd->mem_root) Copy_field[max_fields];\n  DBUG_RETURN(thd->is_fatal_error != 0);\n}","target":0,"code_token_length":1148,"total_token_length":1384,"max_tokens_setting":2048}
+{"idx":227022,"func":"IRC_PROTOCOL_CALLBACK(352)\n{\n    char *pos_attr, *pos_hopcount, *pos_realname, *str_host;\n    int arg_start, length;\n    struct t_irc_channel *ptr_channel;\n    struct t_irc_nick *ptr_nick;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    \/* silently ignore malformed 352 message (missing infos) *\/\n    if (argc < 8)\n        return WEECHAT_RC_OK;\n\n    pos_attr = NULL;\n    pos_hopcount = NULL;\n    pos_realname = NULL;\n\n    if (argc > 8)\n    {\n        arg_start = ((argc > 9) && (strcmp (argv[8], \"*\") == 0)) ? 9 : 8;\n        if (argv[arg_start][0] == ':')\n        {\n            pos_attr = NULL;\n            pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL;\n            pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL;\n        }\n        else\n        {\n            pos_attr = argv[arg_start];\n            pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL;\n            pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL;\n        }\n    }\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n    ptr_nick = (ptr_channel) ?\n        irc_nick_search (server, ptr_channel, argv[7]) : NULL;\n\n    \/* update host in nick *\/\n    if (ptr_nick)\n    {\n        length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;\n        str_host = malloc (length);\n        if (str_host)\n        {\n            snprintf (str_host, length, \"%s@%s\", argv[4], argv[5]);\n            irc_nick_set_host (ptr_nick, str_host);\n            free (str_host);\n        }\n    }\n\n    \/* update away flag in nick *\/\n    if (ptr_channel && ptr_nick && pos_attr)\n    {\n        irc_nick_set_away (server, ptr_channel, ptr_nick,\n                           (pos_attr[0] == 'G') ? 1 : 0);\n    }\n\n    \/* update realname in nick *\/\n    if (ptr_channel && ptr_nick && pos_realname)\n    {\n        if (ptr_nick->realname)\n            free (ptr_nick->realname);\n        if (pos_realname &&\n            weechat_hashtable_has_key (server->cap_list, \"extended-join\"))\n        {\n            ptr_nick->realname = strdup (pos_realname);\n        }\n        else\n        {\n            ptr_nick->realname = NULL;\n        }\n    }\n\n    \/* display output of who (manual who from user) *\/\n    if (!ptr_channel || (ptr_channel->checking_whox <= 0))\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, NULL, command, \"who\", NULL),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s %s%s%s%s(%s)\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_CHANNEL,\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[7]),\n            argv[7],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_HOST,\n            argv[4],\n            argv[5],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            (pos_attr) ? pos_attr : \"\",\n            (pos_attr) ? \" \" : \"\",\n            (pos_hopcount) ? pos_hopcount : \"\",\n            (pos_hopcount) ? \" \" : \"\",\n            (pos_realname) ? pos_realname : \"\");\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":866,"total_token_length":1102,"max_tokens_setting":2048}
+{"idx":359399,"func":"bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)\n{\n  struct peer *peer;\n  struct listnode *node, *nnode;\n  unsigned int count = 0;\n  char timebuf[BGP_UPTIME_LEN];\n  int len;\n\n  \/* Header string for each address family. *\/\n  static char header[] = \"Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up\/Down  State\/PfxRcd\";\n  \n  for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))\n    {\n      if (peer->afc[afi][safi])\n\t{\n          if (!count)\n            {\n              unsigned long ents;\n              char memstrbuf[MTYPE_MEMSTR_LEN];\n              \n              \/* Usage summary and header *\/\n              vty_out (vty,\n                       \"BGP router identifier %s, local AS number %d%s\",\n                       inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);\n\n              ents = bgp_table_count (bgp->rib[afi][safi]);\n              vty_out (vty, \"RIB entries %ld, using %s of memory%s\", ents,\n                       mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                                     ents * sizeof (struct bgp_node)),\n                       VTY_NEWLINE);\n              \n              \/* Peer related usage *\/\n              ents = listcount (bgp->peer);\n              vty_out (vty, \"Peers %ld, using %s of memory%s\",\n                       ents,\n                       mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                                     ents * sizeof (struct peer)),\n                       VTY_NEWLINE);\n              \n              if ((ents = listcount (bgp->rsclient)))\n                vty_out (vty, \"RS-Client peers %ld, using %s of memory%s\",\n                         ents,\n                         mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                                       ents * sizeof (struct peer)),\n                         VTY_NEWLINE);\n              \n              if ((ents = listcount (bgp->group)))\n                vty_out (vty, \"Peer groups %ld, using %s of memory%s\", ents,\n                         mtype_memstr (memstrbuf, sizeof (memstrbuf),\n                                       ents * sizeof (struct peer_group)),\n                         VTY_NEWLINE);\n\n              if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))\n                vty_out (vty, \"Dampening enabled.%s\", VTY_NEWLINE);\n              vty_out (vty, \"%s\", VTY_NEWLINE);\n              vty_out (vty, \"%s%s\", header, VTY_NEWLINE);\n            }\n          \n\t  count++;\n\n\t  len = vty_out (vty, \"%s\", peer->host);\n\t  len = 16 - len;\n\t  if (len < 1)\n\t    vty_out (vty, \"%s%*s\", VTY_NEWLINE, 16, \" \");\n\t  else\n\t    vty_out (vty, \"%*s\", len, \" \");\n\n\t  vty_out (vty, \"4 \");\n\n\t  vty_out (vty, \"%5d %7d %7d %8d %4d %4lu \",\n\t\t   peer->as,\n\t\t   peer->open_in + peer->update_in + peer->keepalive_in\n\t\t   + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,\n\t\t   peer->open_out + peer->update_out + peer->keepalive_out\n\t\t   + peer->notify_out + peer->refresh_out\n\t\t   + peer->dynamic_cap_out,\n\t\t   0, 0, (unsigned long)peer->obuf->count);\n\n\t  vty_out (vty, \"%8s\", \n\t\t   peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));\n\n\t  if (peer->status == Established)\n\t    {\n\t      vty_out (vty, \" %8ld\", peer->pcount[afi][safi]);\n\t    }\n\t  else\n\t    {\n\t      if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))\n\t\tvty_out (vty, \" Idle (Admin)\");\n\t      else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))\n\t\tvty_out (vty, \" Idle (PfxCt)\");\n\t      else\n\t\tvty_out (vty, \" %-11s\", LOOKUP(bgp_status_msg, peer->status));\n\t    }\n\n\t  vty_out (vty, \"%s\", VTY_NEWLINE);\n\t}\n    }\n\n  if (count)\n    vty_out (vty, \"%sTotal number of neighbors %d%s\", VTY_NEWLINE,\n\t     count, VTY_NEWLINE);\n  else\n    vty_out (vty, \"No %s neighbor is configured%s\",\n\t     afi == AFI_IP ? \"IPv4\" : \"IPv6\", VTY_NEWLINE);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":1080,"total_token_length":1316,"max_tokens_setting":2048}
+{"idx":384798,"func":"buf_init_chartab(\n    buf_T\t*buf,\n    int\t\tglobal)\t\t\/\/ FALSE: only set buf->b_chartab[]\n{\n    int\t\tc;\n    int\t\tc2;\n    char_u\t*p;\n    int\t\ti;\n    int\t\ttilde;\n    int\t\tdo_isalpha;\n\n    if (global)\n    {\n\t\/*\n\t * Set the default size for printable characters:\n\t * From <Space> to '~' is 1 (printable), others are 2 (not printable).\n\t * This also inits all 'isident' and 'isfname' flags to FALSE.\n\t *\/\n\tc = 0;\n\twhile (c < ' ')\n\t    g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;\n\twhile (c <= '~')\n\t    g_chartab[c++] = 1 + CT_PRINT_CHAR;\n\twhile (c < 256)\n\t{\n\t    \/\/ UTF-8: bytes 0xa0 - 0xff are printable (latin1)\n\t    if (enc_utf8 && c >= 0xa0)\n\t\tg_chartab[c++] = CT_PRINT_CHAR + 1;\n\t    \/\/ euc-jp characters starting with 0x8e are single width\n\t    else if (enc_dbcs == DBCS_JPNU && c == 0x8e)\n\t\tg_chartab[c++] = CT_PRINT_CHAR + 1;\n\t    \/\/ other double-byte chars can be printable AND double-width\n\t    else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2)\n\t\tg_chartab[c++] = CT_PRINT_CHAR + 2;\n\t    else\n\t\t\/\/ the rest is unprintable by default\n\t\tg_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;\n\t}\n\n\t\/\/ Assume that every multi-byte char is a filename character.\n\tfor (c = 1; c < 256; ++c)\n\t    if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1)\n\t\t    || (enc_dbcs == DBCS_JPNU && c == 0x8e)\n\t\t    || (enc_utf8 && c >= 0xa0))\n\t\tg_chartab[c] |= CT_FNAME_CHAR;\n    }\n\n    \/*\n     * Init word char flags all to FALSE\n     *\/\n    CLEAR_FIELD(buf->b_chartab);\n    if (enc_dbcs != 0)\n\tfor (c = 0; c < 256; ++c)\n\t{\n\t    \/\/ double-byte characters are probably word characters\n\t    if (MB_BYTE2LEN(c) == 2)\n\t\tSET_CHARTAB(buf, c);\n\t}\n\n#ifdef FEAT_LISP\n    \/*\n     * In lisp mode the '-' character is included in keywords.\n     *\/\n    if (buf->b_p_lisp)\n\tSET_CHARTAB(buf, '-');\n#endif\n\n    \/\/ Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'\n    \/\/ options Each option is a list of characters, character numbers or\n    \/\/ ranges, separated by commas, e.g.: \"200-210,x,#-178,-\"\n    for (i = global ? 0 : 3; i <= 3; ++i)\n    {\n\tif (i == 0)\n\t    p = p_isi;\t\t\/\/ first round: 'isident'\n\telse if (i == 1)\n\t    p = p_isp;\t\t\/\/ second round: 'isprint'\n\telse if (i == 2)\n\t    p = p_isf;\t\t\/\/ third round: 'isfname'\n\telse\t\/\/ i == 3\n\t    p = buf->b_p_isk;\t\/\/ fourth round: 'iskeyword'\n\n\twhile (*p)\n\t{\n\t    tilde = FALSE;\n\t    do_isalpha = FALSE;\n\t    if (*p == '^' && p[1] != NUL)\n\t    {\n\t\ttilde = TRUE;\n\t\t++p;\n\t    }\n\t    if (VIM_ISDIGIT(*p))\n\t\tc = getdigits(&p);\n\t    else if (has_mbyte)\n\t\tc = mb_ptr2char_adv(&p);\n\t    else\n\t\tc = *p++;\n\t    c2 = -1;\n\t    if (*p == '-' && p[1] != NUL)\n\t    {\n\t\t++p;\n\t\tif (VIM_ISDIGIT(*p))\n\t\t    c2 = getdigits(&p);\n\t\telse if (has_mbyte)\n\t\t    c2 = mb_ptr2char_adv(&p);\n\t\telse\n\t\t    c2 = *p++;\n\t    }\n\t    if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256\n\t\t\t\t\t\t || !(*p == NUL || *p == ','))\n\t\treturn FAIL;\n\n\t    if (c2 == -1)\t\/\/ not a range\n\t    {\n\t\t\/*\n\t\t * A single '@' (not \"@-@\"):\n\t\t * Decide on letters being ID\/printable\/keyword chars with\n\t\t * standard function isalpha(). This takes care of locale for\n\t\t * single-byte characters).\n\t\t *\/\n\t\tif (c == '@')\n\t\t{\n\t\t    do_isalpha = TRUE;\n\t\t    c = 1;\n\t\t    c2 = 255;\n\t\t}\n\t\telse\n\t\t    c2 = c;\n\t    }\n\t    while (c <= c2)\n\t    {\n\t\t\/\/ Use the MB_ functions here, because isalpha() doesn't\n\t\t\/\/ work properly when 'encoding' is \"latin1\" and the locale is\n\t\t\/\/ \"C\".\n\t\tif (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c))\n\t\t{\n\t\t    if (i == 0)\t\t\t\/\/ (re)set ID flag\n\t\t    {\n\t\t\tif (tilde)\n\t\t\t    g_chartab[c] &= ~CT_ID_CHAR;\n\t\t\telse\n\t\t\t    g_chartab[c] |= CT_ID_CHAR;\n\t\t    }\n\t\t    else if (i == 1)\t\t\/\/ (re)set printable\n\t\t    {\n\t\t\tif ((c < ' ' || c > '~'\n\t\t\t\t\/\/ For double-byte we keep the cell width, so\n\t\t\t\t\/\/ that we can detect it from the first byte.\n\t\t\t    ) && !(enc_dbcs && MB_BYTE2LEN(c) == 2))\n\t\t\t{\n\t\t\t    if (tilde)\n\t\t\t    {\n\t\t\t\tg_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK)\n\t\t\t\t\t     + ((dy_flags & DY_UHEX) ? 4 : 2);\n\t\t\t\tg_chartab[c] &= ~CT_PRINT_CHAR;\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\tg_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + 1;\n\t\t\t\tg_chartab[c] |= CT_PRINT_CHAR;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t    else if (i == 2)\t\t\/\/ (re)set fname flag\n\t\t    {\n\t\t\tif (tilde)\n\t\t\t    g_chartab[c] &= ~CT_FNAME_CHAR;\n\t\t\telse\n\t\t\t    g_chartab[c] |= CT_FNAME_CHAR;\n\t\t    }\n\t\t    else \/\/ i == 3\t\t (re)set keyword flag\n\t\t    {\n\t\t\tif (tilde)\n\t\t\t    RESET_CHARTAB(buf, c);\n\t\t\telse\n\t\t\t    SET_CHARTAB(buf, c);\n\t\t    }\n\t\t}\n\t\t++c;\n\t    }\n\n\t    c = *p;\n\t    p = skip_to_option_part(p);\n\t    if (c == ',' && *p == NUL)\n\t\t\/\/ Trailing comma is not allowed.\n\t\treturn FAIL;\n\t}\n    }\n    chartab_initialized = TRUE;\n    return OK;\n}","target":0,"code_token_length":1634,"total_token_length":1870,"max_tokens_setting":2048}
+{"idx":254745,"func":"njs_typed_array_alloc(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_bool_t zeroing, njs_object_type_t type)\n{\n    double              num;\n    int64_t             i, length;\n    uint32_t            element_size;\n    uint64_t            size, offset;\n    njs_int_t           ret;\n    njs_value_t         *value, prop;\n    njs_typed_array_t   *array, *src_tarray;\n    njs_array_buffer_t  *buffer;\n\n    size = 0;\n    length = 0;\n    offset = 0;\n\n    buffer = NULL;\n    src_tarray = NULL;\n\n    element_size = njs_typed_array_element_size(type);\n\n    value = njs_arg(args, nargs, 0);\n\n    if (njs_is_array_buffer(value)) {\n        buffer = njs_array_buffer(value);\n\n        ret = njs_value_to_index(vm, njs_arg(args, nargs, 1), &offset);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NULL;\n        }\n\n        if (njs_slow_path((offset % element_size) != 0)) {\n            njs_range_error(vm, \"start offset must be multiple of %uD\",\n                            element_size);\n            return NULL;\n        }\n\n        if (njs_is_defined(njs_arg(args, nargs, 2))) {\n            ret = njs_value_to_index(vm, njs_argument(args, 2), &size);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return NULL;\n            }\n        }\n\n        if (njs_slow_path(njs_is_detached_buffer(buffer))) {\n            njs_type_error(vm, \"detached buffer\");\n            return NULL;\n        }\n\n        if (njs_is_defined(njs_arg(args, nargs, 2))) {\n            ret = njs_value_to_index(vm, njs_argument(args, 2), &size);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return NULL;\n            }\n\n            size *= element_size;\n\n            if (njs_slow_path((offset + size) > buffer->size)) {\n                njs_range_error(vm, \"Invalid typed array length: %uL\", size);\n                return NULL;\n            }\n\n        } else {\n            if (njs_slow_path((buffer->size % element_size) != 0)) {\n                njs_range_error(vm, \"byteLength of buffer must be \"\n                                \"multiple of %uD\", element_size);\n                return NULL;\n            }\n\n            if (offset > buffer->size) {\n                njs_range_error(vm, \"byteOffset %uL is outside the bound of \"\n                                \"the buffer\", offset);\n                return NULL;\n            }\n\n            size = buffer->size - offset;\n        }\n\n    } else if (njs_is_typed_array(value)) {\n        src_tarray = njs_typed_array(value);\n        if (njs_slow_path(njs_is_detached_buffer(src_tarray->buffer))) {\n            njs_type_error(vm, \"detached buffer\");\n            return NULL;\n        }\n\n        size = (uint64_t) njs_typed_array_length(src_tarray) * element_size;\n\n    } else if (njs_is_object(value)) {\n        ret = njs_object_length(vm, value, &length);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return NULL;\n        }\n\n        size = length * element_size;\n\n    } else {\n        ret = njs_value_to_index(vm, value, &size);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NULL;\n        }\n\n        size *= element_size;\n    }\n\n    if (buffer == NULL) {\n        buffer = njs_array_buffer_alloc(vm, size, zeroing);\n        if (njs_slow_path(buffer == NULL)) {\n            return NULL;\n        }\n    }\n\n    array = njs_mp_zalloc(vm->mem_pool, sizeof(njs_typed_array_t));\n    if (njs_slow_path(array == NULL)) {\n        goto memory_error;\n    }\n\n    array->buffer = buffer;\n    array->offset = offset \/ element_size;\n    array->byte_length = size;\n    array->type = type;\n\n    if (src_tarray != NULL) {\n        if (type != src_tarray->type) {\n            length = njs_typed_array_length(src_tarray);\n            for (i = 0; i < length; i++) {\n                njs_typed_array_prop_set(vm, array, i,\n                                         njs_typed_array_prop(src_tarray, i));\n            }\n\n        } else {\n            memcpy(&buffer->u.u8[0], &src_tarray->buffer->u.u8[0], size);\n        }\n\n    } else if (!njs_is_array_buffer(value) && njs_is_object(value)) {\n        for (i = 0; i < length; i++) {\n            ret = njs_value_property_i64(vm, value, i, &prop);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return NULL;\n            }\n\n            num = NAN;\n\n            if (ret == NJS_OK) {\n                ret = njs_value_to_number(vm, &prop, &num);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    return NULL;\n                }\n            }\n\n            njs_typed_array_prop_set(vm, array, i, num);\n        }\n    }\n\n    njs_lvlhsh_init(&array->object.hash);\n    njs_lvlhsh_init(&array->object.shared_hash);\n    array->object.__proto__ = &vm->prototypes[type].object;\n    array->object.type = NJS_TYPED_ARRAY;\n    array->object.extensible = 1;\n    array->object.fast_array = 1;\n\n    return array;\n\nmemory_error:\n\n    njs_memory_error(vm);\n\n    return NULL;\n}","target":0,"code_token_length":1251,"total_token_length":1487,"max_tokens_setting":2048}
+{"idx":204711,"func":"static int ldb_wildcard_compare(struct ldb_context *ldb,\n\t\t\t\tconst struct ldb_parse_tree *tree,\n\t\t\t\tconst struct ldb_val value, bool *matched)\n{\n\tconst struct ldb_schema_attribute *a;\n\tstruct ldb_val val;\n\tstruct ldb_val cnk;\n\tstruct ldb_val *chunk;\n\tuint8_t *save_p = NULL;\n\tunsigned int c = 0;\n\n\ta = ldb_schema_attribute_by_name(ldb, tree->u.substring.attr);\n\tif (!a) {\n\t\treturn LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;\n\t}\n\n\tif (tree->u.substring.chunks == NULL) {\n\t\t*matched = false;\n\t\treturn LDB_SUCCESS;\n\t}\n\n\tif (a->syntax->canonicalise_fn(ldb, ldb, &value, &val) != 0) {\n\t\treturn LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;\n\t}\n\n\tsave_p = val.data;\n\tcnk.data = NULL;\n\n\tif ( ! tree->u.substring.start_with_wildcard ) {\n\n\t\tchunk = tree->u.substring.chunks[c];\n\t\tif (a->syntax->canonicalise_fn(ldb, ldb, chunk, &cnk) != 0) goto mismatch;\n\n\t\t\/* This deals with wildcard prefix searches on binary attributes (eg objectGUID) *\/\n\t\tif (cnk.length > val.length) {\n\t\t\tgoto mismatch;\n\t\t}\n\t\t\/*\n\t\t * Empty strings are returned as length 0. Ensure\n\t\t * we can cope with this.\n\t\t *\/\n\t\tif (cnk.length == 0) {\n\t\t\tgoto mismatch;\n\t\t}\n\n\t\tif (memcmp((char *)val.data, (char *)cnk.data, cnk.length) != 0) goto mismatch;\n\t\tval.length -= cnk.length;\n\t\tval.data += cnk.length;\n\t\tc++;\n\t\ttalloc_free(cnk.data);\n\t\tcnk.data = NULL;\n\t}\n\n\twhile (tree->u.substring.chunks[c]) {\n\t\tuint8_t *p;\n\n\t\tchunk = tree->u.substring.chunks[c];\n\t\tif(a->syntax->canonicalise_fn(ldb, ldb, chunk, &cnk) != 0) goto mismatch;\n\n\t\t\/*\n\t\t * Empty strings are returned as length 0. Ensure\n\t\t * we can cope with this.\n\t\t *\/\n\t\tif (cnk.length == 0) {\n\t\t\tgoto mismatch;\n\t\t}\n\t\t\/*\n\t\t * Values might be binary blobs. Don't use string\n\t\t * search, but memory search instead.\n\t\t *\/\n\t\tp = memmem((const void *)val.data,val.length,\n\t\t\t   (const void *)cnk.data, cnk.length);\n\t\tif (p == NULL) goto mismatch;\n\n\t\t\/*\n\t\t * At this point we know cnk.length <= val.length as\n\t\t * otherwise there could be no match\n\t\t *\/\n\n\t\tif ( (! tree->u.substring.chunks[c + 1]) && (! tree->u.substring.end_with_wildcard) ) {\n\t\t\tuint8_t *g;\n\t\t\tuint8_t *end = val.data + val.length;\n\t\t\tdo { \/* greedy *\/\n\n\t\t\t\t\/*\n\t\t\t\t * haystack is a valid pointer in val\n\t\t\t\t * because the memmem() can only\n\t\t\t\t * succeed if the needle (cnk.length)\n\t\t\t\t * is <= haystacklen\n\t\t\t\t *\n\t\t\t\t * p will be a pointer at least\n\t\t\t\t * cnk.length from the end of haystack\n\t\t\t\t *\/\n\t\t\t\tuint8_t *haystack\n\t\t\t\t\t= p + cnk.length;\n\t\t\t\tsize_t haystacklen\n\t\t\t\t\t= end - (haystack);\n\n\t\t\t\tg = memmem(haystack,\n\t\t\t\t\t   haystacklen,\n\t\t\t\t\t   (const uint8_t *)cnk.data,\n\t\t\t\t\t   cnk.length);\n\t\t\t\tif (g) {\n\t\t\t\t\tp = g;\n\t\t\t\t}\n\t\t\t} while(g);\n\t\t}\n\t\tval.length = val.length - (p - (uint8_t *)(val.data)) - cnk.length;\n\t\tval.data = (uint8_t *)(p + cnk.length);\n\t\tc++;\n\t\ttalloc_free(cnk.data);\n\t\tcnk.data = NULL;\n\t}\n\n\t\/* last chunk may not have reached end of string *\/\n\tif ( (! tree->u.substring.end_with_wildcard) && (*(val.data) != 0) ) goto mismatch;\n\ttalloc_free(save_p);\n\t*matched = true;\n\treturn LDB_SUCCESS;\n\nmismatch:\n\t*matched = false;\n\ttalloc_free(save_p);\n\ttalloc_free(cnk.data);\n\treturn LDB_SUCCESS;\n}","target":1,"code_token_length":922,"total_token_length":1158,"max_tokens_setting":2048}
+{"idx":261415,"func":"void read_sao(thread_context* tctx, int xCtb,int yCtb,\n              int CtbAddrInSliceSeg)\n{\n  slice_segment_header* shdr = tctx->shdr;\n  de265_image* img = tctx->img;\n  const seq_parameter_set& sps = img->get_sps();\n  const pic_parameter_set& pps = img->get_pps();\n\n  logtrace(LogSlice,\"# read_sao(%d,%d)\\n\",xCtb,yCtb);\n\n  sao_info saoinfo;\n  memset(&saoinfo,0,sizeof(sao_info));\n  logtrace(LogSlice,\"sizeof saoinfo: %d\\n\",sizeof(sao_info));\n\n\n  char sao_merge_left_flag = 0;\n  char sao_merge_up_flag = 0;\n\n  if (xCtb>0) {\n    \/\/char leftCtbInSliceSeg = (CtbAddrInSliceSeg>0);\n    char leftCtbInSliceSeg = (tctx->CtbAddrInRS > shdr->SliceAddrRS);\n    char leftCtbInTile = (pps.TileIdRS[xCtb   + yCtb * sps.PicWidthInCtbsY] ==\n                          pps.TileIdRS[xCtb-1 + yCtb * sps.PicWidthInCtbsY]);\n\n    if (leftCtbInSliceSeg && leftCtbInTile) {\n      sao_merge_left_flag = decode_sao_merge_flag(tctx);\n      logtrace(LogSlice,\"sao_merge_left_flag: %d\\n\",sao_merge_left_flag);\n    }\n  }\n\n  if (yCtb>0 && sao_merge_left_flag==0) {\n    logtrace(LogSlice,\"CtbAddrInRS:%d PicWidthInCtbsY:%d slice_segment_address:%d\\n\",\n             tctx->CtbAddrInRS,\n             sps.PicWidthInCtbsY,\n             shdr->slice_segment_address);\n    char upCtbInSliceSeg = (tctx->CtbAddrInRS - sps.PicWidthInCtbsY) >= shdr->SliceAddrRS;\n    char upCtbInTile = (pps.TileIdRS[xCtb +  yCtb    * sps.PicWidthInCtbsY] ==\n                        pps.TileIdRS[xCtb + (yCtb-1) * sps.PicWidthInCtbsY]);\n\n    if (upCtbInSliceSeg && upCtbInTile) {\n      sao_merge_up_flag = decode_sao_merge_flag(tctx);\n      logtrace(LogSlice,\"sao_merge_up_flag: %d\\n\",sao_merge_up_flag);\n    }\n  }\n\n  if (!sao_merge_up_flag && !sao_merge_left_flag) {\n    int nChroma = 3;\n    if (sps.ChromaArrayType == CHROMA_MONO) nChroma=1;\n\n    for (int cIdx=0; cIdx<nChroma; cIdx++) {\n      if ((shdr->slice_sao_luma_flag && cIdx==0) ||\n          (shdr->slice_sao_chroma_flag && cIdx>0)) {\n\n        uint8_t SaoTypeIdx = 0;\n\n        if (cIdx==0) {\n          char sao_type_idx_luma = decode_sao_type_idx(tctx);\n          logtrace(LogSlice,\"sao_type_idx_luma: %d\\n\", sao_type_idx_luma);\n          saoinfo.SaoTypeIdx = SaoTypeIdx = sao_type_idx_luma;\n        }\n        else if (cIdx==1) {\n          char sao_type_idx_chroma = decode_sao_type_idx(tctx);\n          logtrace(LogSlice,\"sao_type_idx_chroma: %d\\n\", sao_type_idx_chroma);\n          SaoTypeIdx = sao_type_idx_chroma;\n          saoinfo.SaoTypeIdx |= SaoTypeIdx<<(2*1);\n          saoinfo.SaoTypeIdx |= SaoTypeIdx<<(2*2);  \/\/ set for both chroma components\n        }\n        else {\n          \/\/ SaoTypeIdx = 0\n\n          SaoTypeIdx = (saoinfo.SaoTypeIdx >> (2*cIdx)) & 0x3;\n        }\n\n        if (SaoTypeIdx != 0) {\n          for (int i=0;i<4;i++) {\n            saoinfo.saoOffsetVal[cIdx][i] = decode_sao_offset_abs(tctx, img->get_bit_depth(cIdx));\n            logtrace(LogSlice,\"saoOffsetVal[%d][%d] = %d\\n\",cIdx,i, saoinfo.saoOffsetVal[cIdx][i]);\n          }\n\n          int sign[4];\n          if (SaoTypeIdx==1) {\n            for (int i=0;i<4;i++) {\n              if (saoinfo.saoOffsetVal[cIdx][i] != 0) {\n                sign[i] = decode_sao_offset_sign(tctx) ? -1 : 1;\n              }\n              else {\n                sign[i] = 0; \/\/ not really required, but compiler warns about uninitialized values\n              }\n            }\n\n            saoinfo.sao_band_position[cIdx] = decode_sao_band_position(tctx);\n          }\n          else {\n            uint8_t SaoEoClass = 0;\n\n            sign[0] = sign[1] =  1;\n            sign[2] = sign[3] = -1;\n\n            if (cIdx==0) {\n              saoinfo.SaoEoClass = SaoEoClass = decode_sao_class(tctx);\n            }\n            else if (cIdx==1) {\n              SaoEoClass = decode_sao_class(tctx);\n              saoinfo.SaoEoClass |= SaoEoClass << (2*1);\n              saoinfo.SaoEoClass |= SaoEoClass << (2*2);\n            }\n\n            logtrace(LogSlice,\"SaoEoClass[%d] = %d\\n\",cIdx,SaoEoClass);\n          }\n\n          int log2OffsetScale;\n\n          if (cIdx==0) {\n            log2OffsetScale = pps.range_extension.log2_sao_offset_scale_luma;\n          }\n          else {\n            log2OffsetScale = pps.range_extension.log2_sao_offset_scale_chroma;\n          }\n\n          for (int i=0;i<4;i++) {\n            saoinfo.saoOffsetVal[cIdx][i] = sign[i]*(saoinfo.saoOffsetVal[cIdx][i] << log2OffsetScale);\n          }\n        }\n      }\n    }\n\n    img->set_sao_info(xCtb,yCtb,  &saoinfo);\n  }\n\n\n  if (sao_merge_left_flag) {\n    img->set_sao_info(xCtb,yCtb,  img->get_sao_info(xCtb-1,yCtb));\n  }\n\n  if (sao_merge_up_flag) {\n    img->set_sao_info(xCtb,yCtb,  img->get_sao_info(xCtb,yCtb-1));\n  }\n}","target":0,"code_token_length":1527,"total_token_length":1763,"max_tokens_setting":2048}
+{"idx":513255,"func":"add_key_field(JOIN *join,\n              KEY_FIELD **key_fields,uint and_level, Item_bool_func *cond,\n              Field *field, bool eq_func, Item **value, uint num_values,\n              table_map usable_tables, SARGABLE_PARAM **sargables,\n              uint row_col_no= 0)\n{\n  uint optimize= 0;  \n  if (eq_func &&\n      ((join->is_allowed_hash_join_access() &&\n        field->hash_join_is_possible() && \n        !(field->table->pos_in_table_list->is_materialized_derived() &&\n          field->table->is_created())) ||\n       (field->table->pos_in_table_list->is_materialized_derived() &&\n        !field->table->is_created() && !(field->flags & BLOB_FLAG))))\n  {\n    optimize= KEY_OPTIMIZE_EQ;\n  }   \n  else if (!(field->flags & PART_KEY_FLAG))\n  {\n    \/\/ Don't remove column IS NULL on a LEFT JOIN table\n    if (eq_func && (*value)->type() == Item::NULL_ITEM &&\n        field->table->maybe_null && !field->null_ptr)\n    {\n      optimize= KEY_OPTIMIZE_EXISTS;\n      DBUG_ASSERT(num_values == 1);\n    }\n  }\n  if (optimize != KEY_OPTIMIZE_EXISTS)\n  {\n    table_map used_tables=0;\n    bool optimizable=0;\n    for (uint i=0; i<num_values; i++)\n    {\n      Item *curr_val; \n      if (row_col_no && value[i]->real_item()->type() == Item::ROW_ITEM)\n      {\n        Item_row *value_tuple= (Item_row *) (value[i]->real_item());\n        curr_val= value_tuple->element_index(row_col_no - 1);\n      }\n      else\n        curr_val= value[i];\n      table_map value_used_tables= curr_val->used_tables();\n      used_tables|= value_used_tables;\n      if (!(value_used_tables & (field->table->map | RAND_TABLE_BIT)))\n        optimizable=1;\n    }\n    if (!optimizable)\n      return;\n    if (!(usable_tables & field->table->map))\n    {\n      if (!eq_func || (*value)->type() != Item::NULL_ITEM ||\n          !field->table->maybe_null || field->null_ptr)\n\treturn;\t\t\t\t\t\/\/ Can't use left join optimize\n      optimize= KEY_OPTIMIZE_EXISTS;\n    }\n    else\n    {\n      JOIN_TAB *stat=field->table->reginfo.join_tab;\n      key_map possible_keys=field->get_possible_keys();\n      possible_keys.intersect(field->table->keys_in_use_for_query);\n      stat[0].keys.merge(possible_keys);             \/\/ Add possible keys\n\n      \/*\n\tSave the following cases:\n\tField op constant\n\tField LIKE constant where constant doesn't start with a wildcard\n\tField = field2 where field2 is in a different table\n\tField op formula\n\tField IS NULL\n\tField IS NOT NULL\n         Field BETWEEN ...\n         Field IN ...\n      *\/\n      if (field->flags & PART_KEY_FLAG)\n        stat[0].key_dependent|=used_tables;\n\n      bool is_const=1;\n      for (uint i=0; i<num_values; i++)\n      {\n        Item *curr_val;\n        if (row_col_no && value[i]->real_item()->type() == Item::ROW_ITEM)\n\t{\n          Item_row *value_tuple= (Item_row *) (value[i]->real_item());\n          curr_val= value_tuple->element_index(row_col_no - 1);\n        }\n        else\n          curr_val= value[i];\n        if (!(is_const&= curr_val->const_item()))\n          break;\n      }\n      if (is_const)\n      {\n        stat[0].const_keys.merge(possible_keys);\n        bitmap_set_bit(&field->table->cond_set, field->field_index);\n      }\n      else if (!eq_func)\n      {\n        \/* \n          Save info to be able check whether this predicate can be \n          considered as sargable for range analisis after reading const tables.\n          We do not save info about equalities as update_const_equal_items\n          will take care of updating info on keys from sargable equalities. \n        *\/\n        (*sargables)--;\n        (*sargables)->field= field;\n        (*sargables)->arg_value= value;\n        (*sargables)->num_values= num_values;\n      }\n      if (!eq_func) \/\/ eq_func is NEVER true when num_values > 1\n        return;\n    }\n  }\n  \/*\n    For the moment eq_func is always true. This slot is reserved for future\n    extensions where we want to remembers other things than just eq comparisons\n  *\/\n  DBUG_ASSERT(eq_func);\n  \/* Store possible eq field *\/\n  (*key_fields)->field=\t\tfield;\n  (*key_fields)->eq_func=\teq_func;\n  (*key_fields)->val=\t\t*value;\n  (*key_fields)->cond=          cond;\n  (*key_fields)->level=         and_level;\n  (*key_fields)->optimize=      optimize;\n  \/*\n    If the condition has form \"tbl.keypart = othertbl.field\" and \n    othertbl.field can be NULL, there will be no matches if othertbl.field \n    has NULL value.\n    We use null_rejecting in add_not_null_conds() to add\n    'othertbl.field IS NOT NULL' to tab->select_cond.\n  *\/\n  {\n    Item *real= (*value)->real_item();\n    if (((cond->functype() == Item_func::EQ_FUNC) ||\n         (cond->functype() == Item_func::MULT_EQUAL_FUNC)) &&\n        (real->type() == Item::FIELD_ITEM) &&\n        ((Item_field*)real)->field->maybe_null())\n      (*key_fields)->null_rejecting= true;\n    else\n      (*key_fields)->null_rejecting= false;\n  }\n  (*key_fields)->cond_guard= NULL;\n\n  (*key_fields)->sj_pred_no= get_semi_join_select_list_index(field);\n  (*key_fields)++;\n}","target":0,"code_token_length":1278,"total_token_length":1514,"max_tokens_setting":2048}
+{"idx":195740,"func":"bool SampleInterleavedLSScan::ParseMCU(void)\n{\n#if ACCUSOFT_CODE\n  int lines             = m_ulRemaining[0]; \/\/ total number of MCU lines processed.\n  UBYTE preshift        = m_ucLowBit + FractionalColorBitsOf();\n  struct Line *line[4];\n  UBYTE cx;\n\n  \/\/\n  \/\/ If a DNL marker is present, the number of remaining lines is zero. Fix it.\n  if (m_pFrame->HeightOf() == 0) {\n    assert(lines == 0);\n    lines = 8;\n  }\n  \/\/\n  \/\/ A \"MCU\" in respect to the code organization is eight lines.\n  if (lines > 8) {\n    lines = 8;\n  }\n  if (m_pFrame->HeightOf() > 0)\n    m_ulRemaining[0] -= lines;\n  assert(lines > 0);\n  assert(m_ucCount < 4);\n\n  \/\/\n  \/\/ Fill the line pointers.\n  for(cx = 0;cx < m_ucCount;cx++) {\n    line[cx] = CurrentLine(cx);\n  }\n\n  \/\/ Loop over lines and columns\n  do {\n    LONG length = m_ulWidth[0];\n    LONG *lp[4];\n\n    \/\/ Get the line pointers and initialize the internal backup lines.\n    for(cx = 0;cx < m_ucCount;cx++) {\n      lp[cx] = line[cx]->m_pData;\n      StartLine(cx);\n    }\n\n    if (BeginReadMCU(m_Stream.ByteStreamOf())) { \n      \/\/ No error handling strategy. No RST in scans. Bummer!\n      do {\n        LONG a[4],b[4],c[4],d[4]; \/\/ neighbouring values.\n        LONG d1[4],d2[4],d3[4];   \/\/ local gradients.\n        bool isrun = true;\n      \n        for(cx = 0;cx < m_ucCount;cx++) {\n          GetContext(cx,a[cx],b[cx],c[cx],d[cx]);\n\n          d1[cx]  = d[cx] - b[cx];    \/\/ compute local gradients\n          d2[cx]  = b[cx] - c[cx];\n          d3[cx]  = c[cx] - a[cx];\n\n          \/\/\n          \/\/ Run mode only if the run condition is met for all components\n          if (isrun && !isRunMode(d1[cx],d2[cx],d3[cx]))\n            isrun = false;\n        }\n        \n        if (isrun) {\n          LONG run = DecodeRun(length,m_lRunIndex[0]);\n          \/\/\n          \/\/ Now fill the data.\n          while(run) {\n            \/\/ Update so that the next process gets the correct value.\n            \/\/ There is one sample per component.\n            for(cx = 0;cx < m_ucCount;cx++) {\n              UpdateContext(cx,a[cx]);\n              \/\/ And insert the value into the target line as well.\n              *lp[cx]++ = a[cx] << preshift;\n            }\n            run--,length--;\n            \/\/ As long as there are pixels on the line.\n          }\n          \/\/\n          \/\/ More data on the line? I.e. the run did not cover the full m_lJ samples?\n          \/\/ Now decode the run interruption sample. The rtype is here always zero.\n          if (length) {\n            bool negative; \/\/ the sign variable\n            LONG errval;   \/\/ the prediction error\n            LONG merr;     \/\/ the mapped error (symbol)\n            LONG rx;       \/\/ the reconstructed value\n            UBYTE k;       \/\/ golomb parameter\n            \/\/\n            \/\/ Decode the interrupting pixels.\n            for(cx = 0;cx < m_ucCount;cx++) {\n              \/\/ Get the neighbourhood.\n              GetContext(cx,a[cx],b[cx],c[cx],d[cx]);\n              \/\/ The prediction mode is always false, but the sign information\n              \/\/ is required.\n              negative = a[cx] > b[cx];\n              \/\/ Get the golomb parameter for run interruption coding.\n              k       = GolombParameter(false);\n              \/\/ Golomb-decode the error symbol. It is always using the common\n              \/\/ run index.\n              merr    = GolombDecode(k,m_lLimit - m_lJ[m_lRunIndex[0]] - 1);\n              \/\/ Inverse the error mapping procedure.\n              errval  = InverseErrorMapping(merr,ErrorMappingOffset(false,merr != 0,k));\n              \/\/ Compute the reconstructed value.\n              rx      = Reconstruct(negative,b[cx],errval);\n              \/\/ Update so that the next process gets the correct value.\n              UpdateContext(cx,rx);\n              \/\/ Fill in the value into the line\n              *lp[cx]++ = rx << preshift;\n              \/\/ Update the variables of the run mode.\n              UpdateState(false,errval);\n            }\n            \/\/ Update the run index now. This is not part of\n            \/\/ EncodeRun because the non-reduced run-index is\n            \/\/ required for the golomb coder length limit. \n            if (m_lRunIndex[0] > 0)\n              m_lRunIndex[0]--;\n          } else break; \/\/ end of line.\n        } else {\n          UWORD ctxt;\n          bool  negative; \/\/ the sign variable.\n          LONG  px;       \/\/ the predicted variable.\n          LONG  rx;       \/\/ the reconstructed value.\n          LONG  errval;   \/\/ the error value.\n          LONG  merr;     \/\/ the mapped error value.\n          UBYTE k;        \/\/ the Golomb parameter.\n          \/\/\n          for(cx = 0;cx < m_ucCount;cx++) {\n            \/\/ Quantize the gradients.\n            d1[cx]  = QuantizedGradient(d1[cx]);\n            d2[cx]  = QuantizedGradient(d2[cx]);\n            d3[cx]  = QuantizedGradient(d3[cx]);\n            \/\/ Compute the context.\n            ctxt    = Context(negative,d1[cx],d2[cx],d3[cx]); \n            \/\/ Compute the predicted value.\n            px      = Predict(a[cx],b[cx],c[cx]);\n            \/\/ Correct the prediction.\n            px      = CorrectPrediction(ctxt,negative,px);\n            \/\/ Compute the golomb parameter k from the context.\n            k       = GolombParameter(ctxt);\n            \/\/ Decode the error symbol.\n            merr    = GolombDecode(k,m_lLimit);\n            \/\/ Inverse the error symbol into an error value.\n            errval  = InverseErrorMapping(merr,ErrorMappingOffset(ctxt,k));\n            \/\/ Update the variables.\n            UpdateState(ctxt,errval);\n            \/\/ Compute the reconstructed value.\n            rx      = Reconstruct(negative,px,errval);\n            \/\/ Update so that the next process gets the correct value.\n            UpdateContext(cx,rx);\n            \/\/ And insert the value into the target line as well.\n            *lp[cx]++ = rx << preshift;\n          }\n        }\n      } while(--length);\n    } \/\/ No error handling here.\n    \/\/\n    \/\/ Advance the line pointers.\n    for(cx = 0;cx < m_ucCount;cx++) {\n      EndLine(cx);\n      line[cx] = line[cx]->m_pNext;\n    }\n    \/\/\n  } while(--lines);\n  \/\/\n  \/\/ If this is the last line, gobble up all the\n  \/\/ bits from bitstuffing the last byte may have left.\n  \/\/ As SkipStuffing is idempotent, we can also do that\n  \/\/ all the time.\n  m_Stream.SkipStuffing();\n#endif  \n  return false;\n}","target":1,"code_token_length":1635,"total_token_length":1871,"max_tokens_setting":2048}
+{"idx":333047,"func":"nfa_regexec_both(\n    char_u\t*line,\n    colnr_T\tstartcol,\t\/\/ column to start looking for match\n    proftime_T\t*tm,\t\t\/\/ timeout limit or NULL\n    int\t\t*timed_out)\t\/\/ flag set on timeout or NULL\n{\n    nfa_regprog_T   *prog;\n    long\t    retval = 0L;\n    int\t\t    i;\n    colnr_T\t    col = startcol;\n\n    if (REG_MULTI)\n    {\n\tprog = (nfa_regprog_T *)rex.reg_mmatch->regprog;\n\tline = reg_getline((linenr_T)0);    \/\/ relative to the cursor\n\trex.reg_startpos = rex.reg_mmatch->startpos;\n\trex.reg_endpos = rex.reg_mmatch->endpos;\n    }\n    else\n    {\n\tprog = (nfa_regprog_T *)rex.reg_match->regprog;\n\trex.reg_startp = rex.reg_match->startp;\n\trex.reg_endp = rex.reg_match->endp;\n    }\n\n    \/\/ Be paranoid...\n    if (prog == NULL || line == NULL)\n    {\n\tiemsg(_(e_null_argument));\n\tgoto theend;\n    }\n\n    \/\/ If pattern contains \"\\c\" or \"\\C\": overrule value of rex.reg_ic\n    if (prog->regflags & RF_ICASE)\n\trex.reg_ic = TRUE;\n    else if (prog->regflags & RF_NOICASE)\n\trex.reg_ic = FALSE;\n\n    \/\/ If pattern contains \"\\Z\" overrule value of rex.reg_icombine\n    if (prog->regflags & RF_ICOMBINE)\n\trex.reg_icombine = TRUE;\n\n    rex.line = line;\n    rex.lnum = 0;    \/\/ relative to line\n\n    rex.nfa_has_zend = prog->has_zend;\n    rex.nfa_has_backref = prog->has_backref;\n    rex.nfa_nsubexpr = prog->nsubexp;\n    rex.nfa_listid = 1;\n    rex.nfa_alt_listid = 2;\n#ifdef DEBUG\n    nfa_regengine.expr = prog->pattern;\n#endif\n\n    if (prog->reganch && col > 0)\n\treturn 0L;\n\n    rex.need_clear_subexpr = TRUE;\n#ifdef FEAT_SYN_HL\n    \/\/ Clear the external match subpointers if necessary.\n    if (prog->reghasz == REX_SET)\n    {\n\trex.nfa_has_zsubexpr = TRUE;\n\trex.need_clear_zsubexpr = TRUE;\n    }\n    else\n    {\n\trex.nfa_has_zsubexpr = FALSE;\n\trex.need_clear_zsubexpr = FALSE;\n    }\n#endif\n\n    if (prog->regstart != NUL)\n    {\n\t\/\/ Skip ahead until a character we know the match must start with.\n\t\/\/ When there is none there is no match.\n\tif (skip_to_start(prog->regstart, &col) == FAIL)\n\t    return 0L;\n\n\t\/\/ If match_text is set it contains the full text that must match.\n\t\/\/ Nothing else to try. Doesn't handle combining chars well.\n\tif (prog->match_text != NULL && !rex.reg_icombine)\n\t    return find_match_text(col, prog->regstart, prog->match_text);\n    }\n\n    \/\/ If the start column is past the maximum column: no need to try.\n    if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol)\n\tgoto theend;\n\n    \/\/ Set the \"nstate\" used by nfa_regcomp() to zero to trigger an error when\n    \/\/ it's accidentally used during execution.\n    nstate = 0;\n    for (i = 0; i < prog->nstate; ++i)\n    {\n\tprog->state[i].id = i;\n\tprog->state[i].lastlist[0] = 0;\n\tprog->state[i].lastlist[1] = 0;\n    }\n\n    retval = nfa_regtry(prog, col, tm, timed_out);\n\n#ifdef DEBUG\n    nfa_regengine.expr = NULL;\n#endif\n\ntheend:\n    if (retval > 0)\n    {\n\t\/\/ Make sure the end is never before the start.  Can happen when \\zs and\n\t\/\/ \\ze are used.\n\tif (REG_MULTI)\n\t{\n\t    lpos_T *start = &rex.reg_mmatch->startpos[0];\n\t    lpos_T *end = &rex.reg_mmatch->endpos[0];\n\n\t    if (end->lnum < start->lnum\n\t\t\t|| (end->lnum == start->lnum && end->col < start->col))\n\t\trex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];\n\t}\n\telse\n\t{\n\t    if (rex.reg_match->endp[0] < rex.reg_match->startp[0])\n\t\trex.reg_match->endp[0] = rex.reg_match->startp[0];\n\t}\n    }\n\n    return retval;\n}","target":0,"code_token_length":1064,"total_token_length":1300,"max_tokens_setting":2048}
+{"idx":513251,"func":"change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,\n\t\t\t List<Item> &res_selected_fields,\n\t\t\t List<Item> &res_all_fields,\n\t\t\t uint elements, List<Item> &all_fields)\n{\n  List_iterator_fast<Item> it(all_fields);\n  Item *item_field,*item;\n  DBUG_ENTER(\"change_to_use_tmp_fields\");\n\n  res_selected_fields.empty();\n  res_all_fields.empty();\n\n  uint border= all_fields.elements - elements;\n  for (uint i= 0; (item= it++); i++)\n  {\n    Field *field;\n    if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||\n       item->with_window_func)\n      item_field= item;\n    else if (item->type() == Item::FIELD_ITEM)\n      item_field= item->get_tmp_table_item(thd);\n    else if (item->type() == Item::FUNC_ITEM &&\n             ((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC)\n    {\n      field= item->get_tmp_table_field();\n      if (field != NULL)\n      {\n        \/*\n          Replace \"@:=<expression>\" with \"@:=<tmp table\n          column>\". Otherwise, we would re-evaluate <expression>, and\n          if expression were a subquery, this would access\n          already-unlocked tables.\n         *\/\n        Item_func_set_user_var* suv=\n          new (thd->mem_root) Item_func_set_user_var(thd, (Item_func_set_user_var*) item);\n        Item_field *new_field= new (thd->mem_root) Item_temptable_field(thd, field);\n        if (!suv || !new_field)\n          DBUG_RETURN(true);                  \/\/ Fatal error\n        List<Item> list;\n        list.push_back(new_field, thd->mem_root);\n        suv->set_arguments(thd, list);\n        item_field= suv;\n      }\n      else\n        item_field= item;\n    }\n    else if ((field= item->get_tmp_table_field()))\n    {\n      if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)\n        item_field= ((Item_sum*) item)->result_item(thd, field);\n      else\n        item_field= (Item *) new (thd->mem_root) Item_temptable_field(thd, field);\n      if (!item_field)\n        DBUG_RETURN(true);                    \/\/ Fatal error\n\n      if (item->real_item()->type() != Item::FIELD_ITEM)\n        field->orig_table= 0;\n      item_field->name= item->name;\n      if (item->type() == Item::REF_ITEM)\n      {\n        Item_field *ifield= (Item_field *) item_field;\n        Item_ref *iref= (Item_ref *) item;\n        ifield->table_name= iref->table_name;\n        ifield->db_name= iref->db_name;\n      }\n#ifndef DBUG_OFF\n      if (!item_field->name)\n      {\n        char buff[256];\n        String str(buff,sizeof(buff),&my_charset_bin);\n        str.length(0);\n        str.extra_allocation(1024);\n        item->print(&str, QT_ORDINARY);\n        item_field->name= thd->strmake(str.ptr(),str.length());\n      }\n#endif\n    }\n    else\n      item_field= item;\n\n    res_all_fields.push_back(item_field, thd->mem_root);\n    ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]=\n      item_field;\n  }\n\n  List_iterator_fast<Item> itr(res_all_fields);\n  for (uint i= 0; i < border; i++)\n    itr++;\n  itr.sublist(res_selected_fields, elements);\n  DBUG_RETURN(false);\n}","target":0,"code_token_length":806,"total_token_length":1042,"max_tokens_setting":2048}
+{"idx":310277,"func":"routerstatus_format_entry(char *buf, size_t buf_len,\n                          routerstatus_t *rs, const char *version,\n                          routerstatus_format_type_t format)\n{\n  int r;\n  struct in_addr in;\n  char *cp;\n  char *summary;\n\n  char published[ISO_TIME_LEN+1];\n  char ipaddr[INET_NTOA_BUF_LEN];\n  char identity64[BASE64_DIGEST_LEN+1];\n  char digest64[BASE64_DIGEST_LEN+1];\n\n  format_iso_time(published, rs->published_on);\n  digest_to_base64(identity64, rs->identity_digest);\n  digest_to_base64(digest64, rs->descriptor_digest);\n  in.s_addr = htonl(rs->addr);\n  tor_inet_ntoa(&in, ipaddr, sizeof(ipaddr));\n\n  r = tor_snprintf(buf, buf_len,\n                   \"r %s %s %s%s%s %s %d %d\\n\",\n                   rs->nickname,\n                   identity64,\n                   (format==NS_V3_CONSENSUS_MICRODESC)?\"\":digest64,\n                   (format==NS_V3_CONSENSUS_MICRODESC)?\"\":\" \",\n                   published,\n                   ipaddr,\n                   (int)rs->or_port,\n                   (int)rs->dir_port);\n  if (r<0) {\n    log_warn(LD_BUG, \"Not enough space in buffer.\");\n    return -1;\n  }\n\n  \/* TODO: Maybe we want to pass in what we need to build the rest of\n   * this here, instead of in the caller. Then we could use the\n   * networkstatus_type_t values, with an additional control port value\n   * added -MP *\/\n  if (format == NS_V3_CONSENSUS || format == NS_V3_CONSENSUS_MICRODESC)\n    return 0;\n\n  cp = buf + strlen(buf);\n  \/* NOTE: Whenever this list expands, be sure to increase MAX_FLAG_LINE_LEN*\/\n  r = tor_snprintf(cp, buf_len - (cp-buf),\n                   \"s%s%s%s%s%s%s%s%s%s%s%s%s%s\\n\",\n                  \/* These must stay in alphabetical order. *\/\n                   rs->is_authority?\" Authority\":\"\",\n                   rs->is_bad_directory?\" BadDirectory\":\"\",\n                   rs->is_bad_exit?\" BadExit\":\"\",\n                   rs->is_exit?\" Exit\":\"\",\n                   rs->is_fast?\" Fast\":\"\",\n                   rs->is_possible_guard?\" Guard\":\"\",\n                   rs->is_hs_dir?\" HSDir\":\"\",\n                   rs->is_named?\" Named\":\"\",\n                   rs->is_running?\" Running\":\"\",\n                   rs->is_stable?\" Stable\":\"\",\n                   rs->is_unnamed?\" Unnamed\":\"\",\n                   rs->is_v2_dir?\" V2Dir\":\"\",\n                   rs->is_valid?\" Valid\":\"\");\n  if (r<0) {\n    log_warn(LD_BUG, \"Not enough space in buffer.\");\n    return -1;\n  }\n  cp += strlen(cp);\n\n  \/* length of \"opt v \\n\" *\/\n#define V_LINE_OVERHEAD 7\n  if (version && strlen(version) < MAX_V_LINE_LEN - V_LINE_OVERHEAD) {\n    if (tor_snprintf(cp, buf_len - (cp-buf), \"opt v %s\\n\", version)<0) {\n      log_warn(LD_BUG, \"Unable to print router version.\");\n      return -1;\n    }\n    cp += strlen(cp);\n  }\n\n  if (format != NS_V2) {\n    routerinfo_t* desc = router_get_by_digest(rs->identity_digest);\n    uint32_t bw;\n\n    if (format != NS_CONTROL_PORT) {\n      \/* Blow up more or less nicely if we didn't get anything or not the\n       * thing we expected.\n       *\/\n      if (!desc) {\n        char id[HEX_DIGEST_LEN+1];\n        char dd[HEX_DIGEST_LEN+1];\n\n        base16_encode(id, sizeof(id), rs->identity_digest, DIGEST_LEN);\n        base16_encode(dd, sizeof(dd), rs->descriptor_digest, DIGEST_LEN);\n        log_warn(LD_BUG, \"Cannot get any descriptor for %s \"\n            \"(wanted descriptor %s).\",\n            id, dd);\n        return -1;\n      };\n\n      \/* This assert can fire for the control port, because\n       * it can request NS documents before all descriptors\n       * have been fetched. *\/\n      if (tor_memneq(desc->cache_info.signed_descriptor_digest,\n            rs->descriptor_digest,\n            DIGEST_LEN)) {\n        char rl_d[HEX_DIGEST_LEN+1];\n        char rs_d[HEX_DIGEST_LEN+1];\n        char id[HEX_DIGEST_LEN+1];\n\n        base16_encode(rl_d, sizeof(rl_d),\n            desc->cache_info.signed_descriptor_digest, DIGEST_LEN);\n        base16_encode(rs_d, sizeof(rs_d), rs->descriptor_digest, DIGEST_LEN);\n        base16_encode(id, sizeof(id), rs->identity_digest, DIGEST_LEN);\n        log_err(LD_BUG, \"descriptor digest in routerlist does not match \"\n            \"the one in routerstatus: %s vs %s \"\n            \"(router %s)\\n\",\n            rl_d, rs_d, id);\n\n        tor_assert(tor_memeq(desc->cache_info.signed_descriptor_digest,\n              rs->descriptor_digest,\n              DIGEST_LEN));\n      };\n    }\n\n    if (format == NS_CONTROL_PORT && rs->has_bandwidth) {\n      bw = rs->bandwidth;\n    } else {\n      tor_assert(desc);\n      bw = router_get_advertised_bandwidth_capped(desc) \/ 1000;\n    }\n    r = tor_snprintf(cp, buf_len - (cp-buf),\n                     \"w Bandwidth=%d\\n\", bw);\n\n    if (r<0) {\n      log_warn(LD_BUG, \"Not enough space in buffer.\");\n      return -1;\n    }\n    cp += strlen(cp);\n    if (format == NS_V3_VOTE && rs->has_measured_bw) {\n      *--cp = '\\0'; \/* Kill \"\\n\" *\/\n      r = tor_snprintf(cp, buf_len - (cp-buf),\n                       \" Measured=%d\\n\", rs->measured_bw);\n      if (r<0) {\n        log_warn(LD_BUG, \"Not enough space in buffer for weight line.\");\n        return -1;\n      }\n      cp += strlen(cp);\n    }\n\n    if (desc) {\n      summary = policy_summarize(desc->exit_policy);\n      r = tor_snprintf(cp, buf_len - (cp-buf), \"p %s\\n\", summary);\n      if (r<0) {\n        log_warn(LD_BUG, \"Not enough space in buffer.\");\n        tor_free(summary);\n        return -1;\n      }\n      cp += strlen(cp);\n      tor_free(summary);\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":1451,"total_token_length":1687,"max_tokens_setting":2048}
+{"idx":409488,"func":"add_termcode(char_u *name, char_u *string, int flags)\n{\n    struct termcode *new_tc;\n    int\t\t    i, j;\n    char_u\t    *s;\n    int\t\t    len;\n\n    if (string == NULL || *string == NUL)\n    {\n\tdel_termcode(name);\n\treturn;\n    }\n\n#if defined(MSWIN) && !defined(FEAT_GUI)\n    s = vim_strnsave(string, STRLEN(string) + 1);\n#else\n# ifdef VIMDLL\n    if (!gui.in_use)\n\ts = vim_strnsave(string, STRLEN(string) + 1);\n    else\n# endif\n\ts = vim_strsave(string);\n#endif\n    if (s == NULL)\n\treturn;\n\n    \/\/ Change leading <Esc>[ to CSI, change <Esc>O to <M-O>.\n    if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0)\n    {\n\tSTRMOVE(s, s + 1);\n\ts[0] = term_7to8bit(string);\n    }\n\n#if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))\n# ifdef VIMDLL\n    if (!gui.in_use)\n# endif\n    {\n\tif (s[0] == K_NUL)\n\t{\n\t    STRMOVE(s + 1, s);\n\t    s[1] = 3;\n\t}\n    }\n#endif\n\n    len = (int)STRLEN(s);\n\n    need_gather = TRUE;\t\t\/\/ need to fill termleader[]\n\n    \/*\n     * need to make space for more entries\n     *\/\n    if (tc_len == tc_max_len)\n    {\n\ttc_max_len += 20;\n\tnew_tc = ALLOC_MULT(struct termcode, tc_max_len);\n\tif (new_tc == NULL)\n\t{\n\t    tc_max_len -= 20;\n\t    vim_free(s);\n\t    return;\n\t}\n\tfor (i = 0; i < tc_len; ++i)\n\t    new_tc[i] = termcodes[i];\n\tvim_free(termcodes);\n\ttermcodes = new_tc;\n    }\n\n    \/*\n     * Look for existing entry with the same name, it is replaced.\n     * Look for an existing entry that is alphabetical higher, the new entry\n     * is inserted in front of it.\n     *\/\n    for (i = 0; i < tc_len; ++i)\n    {\n\tif (termcodes[i].name[0] < name[0])\n\t    continue;\n\tif (termcodes[i].name[0] == name[0])\n\t{\n\t    if (termcodes[i].name[1] < name[1])\n\t\tcontinue;\n\t    \/*\n\t     * Exact match: May replace old code.\n\t     *\/\n\t    if (termcodes[i].name[1] == name[1])\n\t    {\n\t\tif (flags == ATC_FROM_TERM && (j = termcode_star(\n\t\t\t\t    termcodes[i].code, termcodes[i].len)) > 0)\n\t\t{\n\t\t    \/\/ Don't replace ESC[123;*X or ESC O*X with another when\n\t\t    \/\/ invoked from got_code_from_term().\n\t\t    if (len == termcodes[i].len - j\n\t\t\t    && STRNCMP(s, termcodes[i].code, len - 1) == 0\n\t\t\t    && s[len - 1]\n\t\t\t\t   == termcodes[i].code[termcodes[i].len - 1])\n\t\t    {\n\t\t\t\/\/ They are equal but for the \";*\": don't add it.\n\t\t\tvim_free(s);\n\t\t\treturn;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Replace old code.\n\t\t    vim_free(termcodes[i].code);\n\t\t    --tc_len;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n\t\/*\n\t * Found alphabetical larger entry, move rest to insert new entry\n\t *\/\n\tfor (j = tc_len; j > i; --j)\n\t    termcodes[j] = termcodes[j - 1];\n\tbreak;\n    }\n\n    termcodes[i].name[0] = name[0];\n    termcodes[i].name[1] = name[1];\n    termcodes[i].code = s;\n    termcodes[i].len = len;\n\n    \/\/ For xterm we recognize special codes like \"ESC[42;*X\" and \"ESC O*X\" that\n    \/\/ accept modifiers.\n    termcodes[i].modlen = 0;\n    j = termcode_star(s, len);\n    if (j > 0)\n    {\n\ttermcodes[i].modlen = len - 1 - j;\n\t\/\/ For \"CSI[@;X\" the \"@\" is not included in \"modlen\".\n\tif (termcodes[i].code[termcodes[i].modlen - 1] == '@')\n\t    --termcodes[i].modlen;\n    }\n    ++tc_len;\n}","target":0,"code_token_length":1020,"total_token_length":1256,"max_tokens_setting":2048}
+{"idx":202125,"func":"_inplace_src_spans (void *abstract_renderer, int y, int h,\n\t\t    const cairo_half_open_span_t *spans,\n\t\t    unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n    uint8_t *m;\n    int x0;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    x0 = spans[0].x;\n    m = r->_buf;\n    do {\n\tint len = spans[1].x - spans[0].x;\n\tif (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {\n\t    if (spans[0].x != x0) {\n#if PIXMAN_HAS_OP_LERP\n\t\tpixman_image_composite32 (PIXMAN_OP_LERP_SRC,\n\t\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n#else\n\t\tpixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,\n\t\t\t\t\t  r->mask, NULL, r->u.composite.dst,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n\t\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n#endif\n\t    }\n\n\t    pixman_image_composite32 (PIXMAN_OP_SRC,\n\t\t\t\t      r->src, NULL, r->u.composite.dst,\n\t\t\t\t      spans[0].x + r->u.composite.src_x,\n\t\t\t\t      y + r->u.composite.src_y,\n\t\t\t\t      0, 0,\n\t\t\t\t      spans[0].x, y,\n\t\t\t\t      spans[1].x - spans[0].x, h);\n\n\t    m = r->_buf;\n\t    x0 = spans[1].x;\n\t} else if (spans[0].coverage == 0x0) {\n\t    if (spans[0].x != x0) {\n#if PIXMAN_HAS_OP_LERP\n\t\tpixman_image_composite32 (PIXMAN_OP_LERP_SRC,\n\t\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n#else\n\t\tpixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,\n\t\t\t\t\t  r->mask, NULL, r->u.composite.dst,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n\t\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n#endif\n\t    }\n\n\t    m = r->_buf;\n\t    x0 = spans[1].x;\n\t} else {\n\t    *m++ = spans[0].coverage;\n\t    if (len > 1) {\n\t\tmemset (m, spans[0].coverage, --len);\n\t\tm += len;\n\t    }\n\t}\n\tspans++;\n    } while (--num_spans > 1);\n\n    if (spans[0].x != x0) {\n#if PIXMAN_HAS_OP_LERP\n\tpixman_image_composite32 (PIXMAN_OP_LERP_SRC,\n\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  spans[0].x - x0, h);\n#else\n\tpixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,\n\t\t\t\t  r->mask, NULL, r->u.composite.dst,\n\t\t\t\t  0, 0,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  spans[0].x - x0, h);\n\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  spans[0].x - x0, h);\n#endif\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":1,"code_token_length":1089,"total_token_length":1325,"max_tokens_setting":2048}
+{"idx":274739,"func":"static void parea_report (gerbv_net_t *net,\n\t\tgerbv_image_t *img, gerbv_project_t *prj)\n{\n\tgerbv_net_t *n;\n\tunsigned int c = 0;\n\tgerbv_interpolation_t inter_prev;\n\tdouble x, y;\n\n\tif (net->interpolation != GERBV_INTERPOLATION_PAREA_START)\n\t\treturn;\n\n\t\/* Count vertices *\/\n\tfor (gerbv_net_t *n = net->next; n != NULL; n = n->next) {\n\t\tif (n->interpolation == GERBV_INTERPOLATION_PAREA_END)\n\t\t\tbreak;\n\t\tc++;\n\t}\n\n\tg_message (_(\"    Number of vertices: %u\"), c - 1);\n\n\tfor (n = net->next, inter_prev = net->interpolation;\n\t\t\tn != NULL\n\t\t\t&& n->interpolation != GERBV_INTERPOLATION_PAREA_END;\n\t\t\tn = n->next) {\n\n\t\tswitch (n->interpolation) {\n\n\t\tcase GERBV_INTERPOLATION_LINEARx1:\n\n\t\t\tif (inter_prev != n->interpolation) {\n\t\t\t\tx = n->start_x;\n\t\t\t\ty = n->start_y;\n\t\t\t\tgerbv_transform_coord_for_image(&x, &y,\n\t\t\t\t\t\timg, prj);\n\t\t\t\tg_message (_(\"    Line from: (%g, %g) %s\"),\n\t\t\t\t\t\tscreen_units(x),\n\t\t\t\t\t\tscreen_units(y),\n\t\t\t\t\t\tscreen_units_str());\n\t\t\t}\n\n\t\t\tx = n->stop_x;\n\t\t\ty = n->stop_y;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"        Line to: (%g, %g) %s\"),\n\t\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\t\tscreen_units_str());\n\t\t\tbreak;\n\n\t\tcase GERBV_INTERPOLATION_CW_CIRCULAR:\n\t\tcase GERBV_INTERPOLATION_CCW_CIRCULAR:\n\n\t\t\tx = n->start_x;\n\t\t\ty = n->start_y;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Arc from: (%g, %g) %s\"),\n\t\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\t\tscreen_units_str());\n\n\t\t\tx = n->stop_x;\n\t\t\ty = n->stop_y;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"        Arc to: (%g, %g) %s\"),\n\t\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\t\tscreen_units_str());\n\n\t\t\tx = n->cirseg->cp_x;\n\t\t\ty = n->cirseg->cp_y;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"        Center: (%g, %g) %s\"),\n\t\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\t\tscreen_units_str());\n\n\t\t\tx = n->cirseg->width;\n\t\t\ty = n->cirseg->height;\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"        Radius: %g %s\"),\n\t\t\t\t\tscreen_units(x)\/2, screen_units_str());\n\n\t\t\tg_message (_(\"        Angle: %g deg\"),\n\t\t\t\tfabs(n->cirseg->angle1 - n->cirseg->angle2));\n\t\t\tg_message (_(\"        Angles: (%g, %g) deg\"),\n\t\t\t\t\tn->cirseg->angle1, n->cirseg->angle2);\n\t\t\tg_message (_(\"        Direction: %s\"),\n\t\t\t\t\t(n->interpolation ==\n\t\t\t\t\t GERBV_INTERPOLATION_CW_CIRCULAR)?\n\t\t\t\t\t\t_(\"CW\"): _(\"CCW\"));\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tg_message(\"       Skipping interpolation: %s\",\n\t\t\t\t_(gerbv_interpolation_name(n->interpolation)));\n\t\t}\n\n\t\tinter_prev = n->interpolation;\n\t}\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048}
+{"idx":242583,"func":"read_header(void *data, unsigned int datasize,\n\t    PE_COFF_LOADER_IMAGE_CONTEXT *context)\n{\n\tEFI_IMAGE_DOS_HEADER *DosHdr = data;\n\tEFI_IMAGE_OPTIONAL_HEADER_UNION *PEHdr = data;\n\tunsigned long HeaderWithoutDataDir, SectionHeaderOffset, OptHeaderSize;\n\tunsigned long FileAlignment = 0;\n\tUINT16 DllFlags;\n\n\tif (datasize < sizeof (PEHdr->Pe32)) {\n\t\tperror(L\"Invalid image\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE)\n\t\tPEHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((char *)data + DosHdr->e_lfanew);\n\n\tif (!image_is_loadable(PEHdr)) {\n\t\tperror(L\"Platform does not support this image\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif (image_is_64_bit(PEHdr)) {\n\t\tcontext->NumberOfRvaAndSizes = PEHdr->Pe32Plus.OptionalHeader.NumberOfRvaAndSizes;\n\t\tcontext->SizeOfHeaders = PEHdr->Pe32Plus.OptionalHeader.SizeOfHeaders;\n\t\tcontext->ImageSize = PEHdr->Pe32Plus.OptionalHeader.SizeOfImage;\n\t\tcontext->SectionAlignment = PEHdr->Pe32Plus.OptionalHeader.SectionAlignment;\n\t\tFileAlignment = PEHdr->Pe32Plus.OptionalHeader.FileAlignment;\n\t\tOptHeaderSize = sizeof(EFI_IMAGE_OPTIONAL_HEADER64);\n\t} else {\n\t\tcontext->NumberOfRvaAndSizes = PEHdr->Pe32.OptionalHeader.NumberOfRvaAndSizes;\n\t\tcontext->SizeOfHeaders = PEHdr->Pe32.OptionalHeader.SizeOfHeaders;\n\t\tcontext->ImageSize = (UINT64)PEHdr->Pe32.OptionalHeader.SizeOfImage;\n\t\tcontext->SectionAlignment = PEHdr->Pe32.OptionalHeader.SectionAlignment;\n\t\tFileAlignment = PEHdr->Pe32.OptionalHeader.FileAlignment;\n\t\tOptHeaderSize = sizeof(EFI_IMAGE_OPTIONAL_HEADER32);\n\t}\n\n\tif (FileAlignment % 2 != 0) {\n\t\tperror(L\"File Alignment is invalid (%d)\\n\", FileAlignment);\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\tif (FileAlignment == 0)\n\t\tFileAlignment = 0x200;\n\tif (context->SectionAlignment == 0)\n\t\tcontext->SectionAlignment = PAGE_SIZE;\n\tif (context->SectionAlignment < FileAlignment)\n\t\tcontext->SectionAlignment = FileAlignment;\n\n\tcontext->NumberOfSections = PEHdr->Pe32.FileHeader.NumberOfSections;\n\n\tif (EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES < context->NumberOfRvaAndSizes) {\n\t\tperror(L\"Image header too small\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tHeaderWithoutDataDir = OptHeaderSize\n\t\t\t- sizeof (EFI_IMAGE_DATA_DIRECTORY) * EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES;\n\tif (((UINT32)PEHdr->Pe32.FileHeader.SizeOfOptionalHeader - HeaderWithoutDataDir) !=\n\t\t\tcontext->NumberOfRvaAndSizes * sizeof (EFI_IMAGE_DATA_DIRECTORY)) {\n\t\tperror(L\"Image header overflows data directory\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tSectionHeaderOffset = DosHdr->e_lfanew\n\t\t\t\t+ sizeof (UINT32)\n\t\t\t\t+ sizeof (EFI_IMAGE_FILE_HEADER)\n\t\t\t\t+ PEHdr->Pe32.FileHeader.SizeOfOptionalHeader;\n\tif (((UINT32)context->ImageSize - SectionHeaderOffset) \/ EFI_IMAGE_SIZEOF_SECTION_HEADER\n\t\t\t<= context->NumberOfSections) {\n\t\tperror(L\"Image sections overflow image size\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif ((context->SizeOfHeaders - SectionHeaderOffset) \/ EFI_IMAGE_SIZEOF_SECTION_HEADER\n\t\t\t< (UINT32)context->NumberOfSections) {\n\t\tperror(L\"Image sections overflow section headers\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif ((((UINT8 *)PEHdr - (UINT8 *)data) + sizeof(EFI_IMAGE_OPTIONAL_HEADER_UNION)) > datasize) {\n\t\tperror(L\"Invalid image\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif (PEHdr->Te.Signature != EFI_IMAGE_NT_SIGNATURE) {\n\t\tperror(L\"Unsupported image type\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif (PEHdr->Pe32.FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) {\n\t\tperror(L\"Unsupported image - Relocations have been stripped\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tcontext->PEHdr = PEHdr;\n\n\tif (image_is_64_bit(PEHdr)) {\n\t\tcontext->ImageAddress = PEHdr->Pe32Plus.OptionalHeader.ImageBase;\n\t\tcontext->EntryPoint = PEHdr->Pe32Plus.OptionalHeader.AddressOfEntryPoint;\n\t\tcontext->RelocDir = &PEHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\n\t\tcontext->SecDir = &PEHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY];\n\t\tDllFlags = PEHdr->Pe32Plus.OptionalHeader.DllCharacteristics;\n\t} else {\n\t\tcontext->ImageAddress = PEHdr->Pe32.OptionalHeader.ImageBase;\n\t\tcontext->EntryPoint = PEHdr->Pe32.OptionalHeader.AddressOfEntryPoint;\n\t\tcontext->RelocDir = &PEHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\n\t\tcontext->SecDir = &PEHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY];\n\t\tDllFlags = PEHdr->Pe32.OptionalHeader.DllCharacteristics;\n\t}\n\n\tif ((mok_policy & MOK_POLICY_REQUIRE_NX) &&\n\t    !(DllFlags & EFI_IMAGE_DLLCHARACTERISTICS_NX_COMPAT)) {\n\t\tperror(L\"Policy requires NX, but image does not support NX\\n\");\n\t\treturn EFI_UNSUPPORTED;\n        }\n\n\tcontext->FirstSection = (EFI_IMAGE_SECTION_HEADER *)((char *)PEHdr + PEHdr->Pe32.FileHeader.SizeOfOptionalHeader + sizeof(UINT32) + sizeof(EFI_IMAGE_FILE_HEADER));\n\n\tif (context->ImageSize < context->SizeOfHeaders) {\n\t\tperror(L\"Invalid image\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif ((unsigned long)((UINT8 *)context->SecDir - (UINT8 *)data) >\n\t    (datasize - sizeof(EFI_IMAGE_DATA_DIRECTORY))) {\n\t\tperror(L\"Invalid image\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif (context->SecDir->VirtualAddress > datasize ||\n\t    (context->SecDir->VirtualAddress == datasize &&\n\t     context->SecDir->Size > 0)) {\n\t\tperror(L\"Malformed security header\\n\");\n\t\treturn EFI_INVALID_PARAMETER;\n\t}\n\treturn EFI_SUCCESS;\n}","target":0,"code_token_length":1403,"total_token_length":1639,"max_tokens_setting":2048}
+{"idx":254741,"func":"njs_typed_array_prototype_index_of(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t type)\n{\n    double              v;\n    int64_t             i, i64, from, to, index, increment, offset, length;\n    njs_int_t           ret, integer;\n    njs_value_t         *this;\n    const float         *f32;\n    const double        *f64;\n    const uint8_t       *u8;\n    const uint16_t      *u16;\n    const uint32_t      *u32;\n    njs_typed_array_t   *array;\n    njs_array_buffer_t  *buffer;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_typed_array(this))) {\n        njs_type_error(vm, \"this is not a typed array\");\n        return NJS_ERROR;\n    }\n\n    index = -1;\n    array = njs_typed_array(this);\n    length = njs_typed_array_length(array);\n\n    if (!njs_is_number(njs_arg(args, nargs, 1)) || length == 0) {\n        goto done;\n    }\n\n    if (type & 2) {\n        \/* lastIndexOf(). *\/\n\n        if (nargs > 2) {\n            ret = njs_value_to_integer(vm, njs_arg(args, nargs, 2), &from);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n        } else {\n            from = length - 1;\n        }\n\n        if (from >= 0) {\n            from = njs_min(from, length - 1);\n\n        } else if (from < 0) {\n            from += length;\n        }\n\n        to = -1;\n        increment = -1;\n\n        if (from <= to) {\n            goto done;\n        }\n\n    } else {\n        \/* indexOf(), includes(). *\/\n\n        ret = njs_value_to_integer(vm, njs_arg(args, nargs, 2), &from);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (from < 0) {\n            from += length;\n\n            if (from < 0) {\n                from = 0;\n            }\n        }\n\n        to = length;\n        increment = 1;\n\n        if (from >= to) {\n            goto done;\n        }\n    }\n\n    if (njs_slow_path(njs_is_detached_buffer(array->buffer))) {\n        njs_type_error(vm, \"detached buffer\");\n        return NJS_ERROR;\n    }\n\n    v = njs_number(njs_argument(args, 1));\n\n    i64 = v;\n    integer = (v == i64);\n\n    buffer = array->buffer;\n    offset = array->offset;\n\n    switch (array->type) {\n    case NJS_OBJ_TYPE_INT8_ARRAY:\n        if (integer && ((int8_t) i64 == i64)) {\n            goto search8;\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_UINT8_CLAMPED_ARRAY:\n    case NJS_OBJ_TYPE_UINT8_ARRAY:\n        if (integer && ((uint8_t) i64 == i64)) {\nsearch8:\n            u8 = &buffer->u.u8[0];\n            for (i = from; i != to; i += increment) {\n                if (u8[offset + i] == (uint8_t) i64) {\n                    index = i;\n                    break;\n                }\n            }\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_INT16_ARRAY:\n        if (integer && ((int16_t) i64 == i64)) {\n            goto search16;\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_UINT16_ARRAY:\n        if (integer && ((uint16_t) i64 == i64)) {\nsearch16:\n            u16 = &buffer->u.u16[0];\n            for (i = from; i != to; i += increment) {\n                if (u16[offset + i] == (uint16_t) i64) {\n                    index = i;\n                    break;\n                }\n            }\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_INT32_ARRAY:\n        if (integer && ((int32_t) i64 == i64)) {\n            goto search32;\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_UINT32_ARRAY:\n        if (integer && ((uint32_t) i64 == i64)) {\nsearch32:\n            u32 = &buffer->u.u32[0];\n            for (i = from; i != to; i += increment) {\n                if (u32[offset + i] == (uint32_t) i64) {\n                    index = i;\n                    break;\n                }\n            }\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_FLOAT32_ARRAY:\n        f32 = &buffer->u.f32[0];\n\n        if (((float) v == v)) {\n            for (i = from; i != to; i += increment) {\n                if (f32[offset + i] == (float) v) {\n                    index = i;\n                    break;\n                }\n            }\n\n        } else if ((type & 1) && isnan(v)) {\n            \/* includes() handles NaN. *\/\n\n            for (i = from; i != to; i += increment) {\n                if (isnan(f32[offset + i])) {\n                    index = i;\n                    break;\n                }\n            }\n        }\n\n        break;\n\n    default:\n\n        \/* NJS_OBJ_TYPE_FLOAT64_ARRAY. *\/\n\n        f64 = &buffer->u.f64[0];\n\n        if ((type & 1) && isnan(v)) {\n            \/* includes() handles NaN. *\/\n\n            for (i = from; i != to; i += increment) {\n                if (isnan(f64[offset + i])) {\n                    index = i;\n                    break;\n                }\n            }\n\n        } else {\n            for (i = from; i != to; i += increment) {\n                if (f64[offset + i] == v) {\n                    index = i;\n                    break;\n                }\n            }\n        }\n    }\n\ndone:\n\n    \/* Default values. *\/\n\n    if (type & 1) {\n        njs_set_boolean(&vm->retval, index != -1);\n\n    } else {\n        njs_set_number(&vm->retval, index);\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":1411,"total_token_length":1647,"max_tokens_setting":2048}
+{"idx":328944,"func":"R_API RBinJavaField *r_bin_java_read_next_method(RBinJavaObj *bin, const ut64 offset, const ut8 *buf, const ut64 len) {\n\tut32 i, idx;\n\tconst ut8 *f_buf = buf + offset;\n\tut64 adv = 0;\n\tRBinJavaCPTypeObj *item = NULL;\n\tif (!bin || offset + 8 >= len) {\n\t\treturn NULL;\n\t}\n\tRBinJavaField *method = (RBinJavaField *) R_NEW0 (RBinJavaField);\n\tif (!method) {\n\t\teprintf (\"Unable to allocate memory for method information\\n\");\n\t\treturn NULL;\n\t}\n\tmethod->metas = (RBinJavaMetaInfo *) R_NEW0 (RBinJavaMetaInfo);\n\tif (!method->metas) {\n\t\teprintf (\"Unable to allocate memory for meta information\\n\");\n\t\tfree (method);\n\t\treturn NULL;\n\t}\n\tmethod->file_offset = offset;\n\tmethod->flags = R_BIN_JAVA_USHORT (f_buf, 0);\n\tmethod->flags_str = retrieve_method_access_string (method->flags);\n\t\/\/ need to subtract 1 for the idx\n\tmethod->name_idx = R_BIN_JAVA_USHORT (f_buf, 2);\n\tmethod->descriptor_idx = R_BIN_JAVA_USHORT (f_buf, 4);\n\tmethod->attr_count = R_BIN_JAVA_USHORT (f_buf, 6);\n\tmethod->attributes = r_list_newf (r_bin_java_attribute_free);\n\tmethod->type = R_BIN_JAVA_FIELD_TYPE_METHOD;\n\tmethod->metas->ord = bin->method_idx;\n\tadv += 8;\n\tidx = method->name_idx;\n\titem = r_bin_java_get_item_from_bin_cp_list (bin, idx);\n\tmethod->name = r_bin_java_get_utf8_from_bin_cp_list (bin, (ut32) (method->name_idx));\n\tIFDBG eprintf (\"Method name_idx: %d, which is: ord: %d, name: %s, value: %s\\n\", idx, item->metas->ord, ((RBinJavaCPTypeMetas *)item->metas->type_info)->name, method->name);\n\tif (!method->name) {\n\t\tmethod->name = (char *) malloc (21);\n\t\tsnprintf ((char *) method->name, 20, \"sym.method_%08x\", method->metas->ord);\n\t\tIFDBG eprintf (\"r_bin_java_read_next_method: Unable to find the name for 0x%02x index.\\n\", method->name_idx);\n\t}\n\tidx = method->descriptor_idx;\n\titem = r_bin_java_get_item_from_bin_cp_list (bin, idx);\n\tmethod->descriptor = r_bin_java_get_utf8_from_bin_cp_list (bin, (ut32) method->descriptor_idx);\n\tIFDBG eprintf (\"Method descriptor_idx: %d, which is: ord: %d, name: %s, value: %s\\n\", idx, item->metas->ord, ((RBinJavaCPTypeMetas *)item->metas->type_info)->name, method->descriptor);\n\tif (!method->descriptor) {\n\t\tmethod->descriptor = r_str_dup (NULL, \"NULL\");\n\t\tIFDBG eprintf (\"r_bin_java_read_next_method: Unable to find the descriptor for 0x%02x index.\\n\", method->descriptor_idx);\n\t}\n\tIFDBG eprintf (\"Looking for a NameAndType CP with name_idx: %d descriptor_idx: %d\\n\", method->name_idx, method->descriptor_idx);\n\tmethod->field_ref_cp_obj = r_bin_java_find_cp_ref_info_from_name_and_type (bin, method->name_idx, method->descriptor_idx);\n\tif (method->field_ref_cp_obj) {\n\t\tIFDBG eprintf (\"Found the obj.\\n\");\n\t\titem = r_bin_java_get_item_from_bin_cp_list (bin, method->field_ref_cp_obj->info.cp_method.class_idx);\n\t\tIFDBG eprintf (\"Method class reference value: %d, which is: ord: %d, name: %s\\n\", method->field_ref_cp_obj->info.cp_method.class_idx, item->metas->ord, ((RBinJavaCPTypeMetas *)item->metas->type_info)->name);\n\t\tmethod->class_name = r_bin_java_get_item_name_from_bin_cp_list (bin, item);\n\t\tIFDBG eprintf (\"Method requesting ref_cp_obj the following which is: ord: %d, name: %s\\n\", method->field_ref_cp_obj->metas->ord, ((RBinJavaCPTypeMetas *)method->field_ref_cp_obj->metas->type_info)->name);\n\t\tIFDBG eprintf (\"MethodRef class name resolves to: %s\\n\", method->class_name);\n\t\tif (!method->class_name) {\n\t\t\tmethod->class_name = r_str_dup (NULL, \"NULL\");\n\t\t}\n\t} else {\n\t\t\/\/ XXX - default to this class?\n\t\tmethod->field_ref_cp_obj = r_bin_java_get_item_from_bin_cp_list (bin, bin->cf2.this_class);\n\t\tmethod->class_name = r_bin_java_get_item_name_from_bin_cp_list (bin, method->field_ref_cp_obj);\n\t}\n\tIFDBG eprintf (\"Parsing %s(%s)\\n\", method->name, method->descriptor);\n\tif (method->attr_count > 0) {\n\t\tmethod->attr_offset = adv + offset;\n\t\tRBinJavaAttrInfo *attr = NULL;\n\t\tfor (i = 0; i < method->attr_count; i++) {\n\t\t\tattr = r_bin_java_read_next_attr (bin, adv + offset, buf, len);\n\t\t\tif (!attr) {\n\t\t\t\teprintf (\"[X] r_bin_java: Error unable to parse remainder of classfile after Method Attribute: %d.\\n\", i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ((r_bin_java_get_attr_type_by_name (attr->name))->type == R_BIN_JAVA_ATTR_TYPE_CODE_ATTR) {\n\t\t\t\t\/\/ This is necessary for determing the appropriate number of bytes when readin\n\t\t\t\t\/\/ uoffset, ustack, ulocalvar values\n\t\t\t\tbin->cur_method_code_length = attr->info.code_attr.code_length;\n\t\t\t\tbin->offset_sz = 2;\/\/ (attr->info.code_attr.code_length > 65535) ? 4 : 2;\n\t\t\t\tbin->ustack_sz = 2;\/\/ (attr->info.code_attr.max_stack > 65535) ? 4 : 2;\n\t\t\t\tbin->ulocalvar_sz = 2;\/\/ (attr->info.code_attr.max_locals > 65535) ? 4 : 2;\n\t\t\t}\n\t\t\tIFDBG eprintf (\"Parsing @ 0x%\"PFMT64x \" (%s) = 0x%\"PFMT64x \" bytes\\n\", attr->file_offset, attr->name, attr->size);\n\t\t\tr_list_append (method->attributes, attr);\n\t\t\tadv += attr->size;\n\t\t\tif (adv + offset >= len) {\n\t\t\t\teprintf (\"[X] r_bin_java: Error unable to parse remainder of classfile after Method Attribute: %d.\\n\", i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tmethod->size = adv;\n\t\/\/ reset after parsing the method attributes\n\tIFDBG eprintf (\"Parsing @ 0x%\"PFMT64x \" %s(%s) = 0x%\"PFMT64x \" bytes\\n\", method->file_offset, method->name, method->descriptor, method->size);\n\treturn method;\n}","target":0,"code_token_length":1616,"total_token_length":1852,"max_tokens_setting":2048}
+{"idx":369428,"func":"\nSYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,\n\t\tu32, min_complete, u32, flags, const void __user *, argp,\n\t\tsize_t, argsz)\n{\n\tstruct io_ring_ctx *ctx;\n\tint submitted = 0;\n\tstruct fd f;\n\tlong ret;\n\n\tio_run_task_work();\n\n\tif (unlikely(flags & ~(IORING_ENTER_GETEVENTS | IORING_ENTER_SQ_WAKEUP |\n\t\t\t       IORING_ENTER_SQ_WAIT | IORING_ENTER_EXT_ARG |\n\t\t\t       IORING_ENTER_REGISTERED_RING)))\n\t\treturn -EINVAL;\n\n\t\/*\n\t * Ring fd has been registered via IORING_REGISTER_RING_FDS, we\n\t * need only dereference our task private array to find it.\n\t *\/\n\tif (flags & IORING_ENTER_REGISTERED_RING) {\n\t\tstruct io_uring_task *tctx = current->io_uring;\n\n\t\tif (!tctx || fd >= IO_RINGFD_REG_MAX)\n\t\t\treturn -EINVAL;\n\t\tfd = array_index_nospec(fd, IO_RINGFD_REG_MAX);\n\t\tf.file = tctx->registered_rings[fd];\n\t\tif (unlikely(!f.file))\n\t\t\treturn -EBADF;\n\t} else {\n\t\tf = fdget(fd);\n\t\tif (unlikely(!f.file))\n\t\t\treturn -EBADF;\n\t}\n\n\tret = -EOPNOTSUPP;\n\tif (unlikely(f.file->f_op != &io_uring_fops))\n\t\tgoto out_fput;\n\n\tret = -ENXIO;\n\tctx = f.file->private_data;\n\tif (unlikely(!percpu_ref_tryget(&ctx->refs)))\n\t\tgoto out_fput;\n\n\tret = -EBADFD;\n\tif (unlikely(ctx->flags & IORING_SETUP_R_DISABLED))\n\t\tgoto out;\n\n\t\/*\n\t * For SQ polling, the thread will do all submissions and completions.\n\t * Just return the requested submit count, and wake the thread if\n\t * we were asked to.\n\t *\/\n\tret = 0;\n\tif (ctx->flags & IORING_SETUP_SQPOLL) {\n\t\tio_cqring_overflow_flush(ctx);\n\n\t\tif (unlikely(ctx->sq_data->thread == NULL)) {\n\t\t\tret = -EOWNERDEAD;\n\t\t\tgoto out;\n\t\t}\n\t\tif (flags & IORING_ENTER_SQ_WAKEUP)\n\t\t\twake_up(&ctx->sq_data->wait);\n\t\tif (flags & IORING_ENTER_SQ_WAIT) {\n\t\t\tret = io_sqpoll_wait_sq(ctx);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t}\n\t\tsubmitted = to_submit;\n\t} else if (to_submit) {\n\t\tret = io_uring_add_tctx_node(ctx);\n\t\tif (unlikely(ret))\n\t\t\tgoto out;\n\t\tmutex_lock(&ctx->uring_lock);\n\t\tsubmitted = io_submit_sqes(ctx, to_submit);\n\t\tmutex_unlock(&ctx->uring_lock);\n\n\t\tif (submitted != to_submit)\n\t\t\tgoto out;\n\t}\n\tif (flags & IORING_ENTER_GETEVENTS) {\n\t\tconst sigset_t __user *sig;\n\t\tstruct __kernel_timespec __user *ts;\n\n\t\tret = io_get_ext_arg(flags, argp, &argsz, &ts, &sig);\n\t\tif (unlikely(ret))\n\t\t\tgoto out;\n\n\t\tmin_complete = min(min_complete, ctx->cq_entries);\n\n\t\t\/*\n\t\t * When SETUP_IOPOLL and SETUP_SQPOLL are both enabled, user\n\t\t * space applications don't need to do io completion events\n\t\t * polling again, they can rely on io_sq_thread to do polling\n\t\t * work, which can reduce cpu usage and uring_lock contention.\n\t\t *\/\n\t\tif (ctx->flags & IORING_SETUP_IOPOLL &&\n\t\t    !(ctx->flags & IORING_SETUP_SQPOLL)) {\n\t\t\tret = io_iopoll_check(ctx, min_complete);\n\t\t} else {\n\t\t\tret = io_cqring_wait(ctx, min_complete, sig, argsz, ts);\n\t\t}\n\t}\n\nout:\n\tpercpu_ref_put(&ctx->refs);\nout_fput:\n\tif (!(flags & IORING_ENTER_REGISTERED_RING))\n\t\tfdput(f);\n\treturn submitted ? submitted : ret;","target":0,"code_token_length":879,"total_token_length":1115,"max_tokens_setting":2048}
+{"idx":198588,"func":"get_lisp_indent(void)\n{\n    pos_T\t*pos, realpos, paren;\n    int\t\tamount;\n    char_u\t*that;\n    colnr_T\tcol;\n    colnr_T\tfirsttry;\n    int\t\tparencount, quotecount;\n    int\t\tvi_lisp;\n\n    \/\/ Set vi_lisp to use the vi-compatible method\n    vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);\n\n    realpos = curwin->w_cursor;\n    curwin->w_cursor.col = 0;\n\n    if ((pos = findmatch(NULL, '(')) == NULL)\n\tpos = findmatch(NULL, '[');\n    else\n    {\n\tparen = *pos;\n\tpos = findmatch(NULL, '[');\n\tif (pos == NULL || LT_POSP(pos, &paren))\n\t    pos = &paren;\n    }\n    if (pos != NULL)\n    {\n\t\/\/ Extra trick: Take the indent of the first previous non-white\n\t\/\/ line that is at the same () level.\n\tamount = -1;\n\tparencount = 0;\n\n\twhile (--curwin->w_cursor.lnum >= pos->lnum)\n\t{\n\t    if (linewhite(curwin->w_cursor.lnum))\n\t\tcontinue;\n\t    for (that = ml_get_curline(); *that != NUL; ++that)\n\t    {\n\t\tif (*that == ';')\n\t\t{\n\t\t    while (*(that + 1) != NUL)\n\t\t\t++that;\n\t\t    continue;\n\t\t}\n\t\tif (*that == '\\\\')\n\t\t{\n\t\t    if (*(that + 1) != NUL)\n\t\t\t++that;\n\t\t    continue;\n\t\t}\n\t\tif (*that == '\"' && *(that + 1) != NUL)\n\t\t{\n\t\t    while (*++that && *that != '\"')\n\t\t    {\n\t\t\t\/\/ skipping escaped characters in the string\n\t\t\tif (*that == '\\\\')\n\t\t\t{\n\t\t\t    if (*++that == NUL)\n\t\t\t\tbreak;\n\t\t\t    if (that[1] == NUL)\n\t\t\t    {\n\t\t\t\t++that;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (*that == '(' || *that == '[')\n\t\t    ++parencount;\n\t\telse if (*that == ')' || *that == ']')\n\t\t    --parencount;\n\t    }\n\t    if (parencount == 0)\n\t    {\n\t\tamount = get_indent();\n\t\tbreak;\n\t    }\n\t}\n\n\tif (amount == -1)\n\t{\n\t    curwin->w_cursor.lnum = pos->lnum;\n\t    curwin->w_cursor.col = pos->col;\n\t    col = pos->col;\n\n\t    that = ml_get_curline();\n\n\t    if (vi_lisp && get_indent() == 0)\n\t\tamount = 2;\n\t    else\n\t    {\n\t\tchar_u *line = that;\n\n\t\tamount = 0;\n\t\twhile (*that && col)\n\t\t{\n\t\t    amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);\n\t\t    col--;\n\t\t}\n\n\t\t\/\/ Some keywords require \"body\" indenting rules (the\n\t\t\/\/ non-standard-lisp ones are Scheme special forms):\n\t\t\/\/\n\t\t\/\/ (let ((a 1))    instead    (let ((a 1))\n\t\t\/\/   (...))\t      of\t   (...))\n\n\t\tif (!vi_lisp && (*that == '(' || *that == '[')\n\t\t\t\t\t\t      && lisp_match(that + 1))\n\t\t    amount += 2;\n\t\telse\n\t\t{\n\t\t    that++;\n\t\t    amount++;\n\t\t    firsttry = amount;\n\n\t\t    while (VIM_ISWHITE(*that))\n\t\t    {\n\t\t\tamount += lbr_chartabsize(line, that, (colnr_T)amount);\n\t\t\t++that;\n\t\t    }\n\n\t\t    if (*that && *that != ';') \/\/ not a comment line\n\t\t    {\n\t\t\t\/\/ test *that != '(' to accommodate first let\/do\n\t\t\t\/\/ argument if it is more than one line\n\t\t\tif (!vi_lisp && *that != '(' && *that != '[')\n\t\t\t    firsttry++;\n\n\t\t\tparencount = 0;\n\t\t\tquotecount = 0;\n\n\t\t\tif (vi_lisp\n\t\t\t\t|| (*that != '\"'\n\t\t\t\t    && *that != '\\''\n\t\t\t\t    && *that != '#'\n\t\t\t\t    && (*that < '0' || *that > '9')))\n\t\t\t{\n\t\t\t    while (*that\n\t\t\t\t    && (!VIM_ISWHITE(*that)\n\t\t\t\t\t|| quotecount\n\t\t\t\t\t|| parencount)\n\t\t\t\t    && (!((*that == '(' || *that == '[')\n\t\t\t\t\t    && !quotecount\n\t\t\t\t\t    && !parencount\n\t\t\t\t\t    && vi_lisp)))\n\t\t\t    {\n\t\t\t\tif (*that == '\"')\n\t\t\t\t    quotecount = !quotecount;\n\t\t\t\tif ((*that == '(' || *that == '[')\n\t\t\t\t\t\t\t       && !quotecount)\n\t\t\t\t    ++parencount;\n\t\t\t\tif ((*that == ')' || *that == ']')\n\t\t\t\t\t\t\t       && !quotecount)\n\t\t\t\t    --parencount;\n\t\t\t\tif (*that == '\\\\' && *(that+1) != NUL)\n\t\t\t\t    amount += lbr_chartabsize_adv(\n\t\t\t\t\t\tline, &that, (colnr_T)amount);\n\t\t\t\tamount += lbr_chartabsize_adv(\n\t\t\t\t\t\tline, &that, (colnr_T)amount);\n\t\t\t    }\n\t\t\t}\n\t\t\twhile (VIM_ISWHITE(*that))\n\t\t\t{\n\t\t\t    amount += lbr_chartabsize(\n\t\t\t\t\t\t line, that, (colnr_T)amount);\n\t\t\t    that++;\n\t\t\t}\n\t\t\tif (!*that || *that == ';')\n\t\t\t    amount = firsttry;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n    else\n\tamount = 0;\t\/\/ no matching '(' or '[' found, use zero indent\n\n    curwin->w_cursor = realpos;\n\n    return amount;\n}","target":1,"code_token_length":1232,"total_token_length":1468,"max_tokens_setting":2048}
+{"idx":274736,"func":"callbacks_about_activate                     (GtkMenuItem     *menuitem,\n                                        gpointer         user_data)\n{\n\tGtkWidget *aboutdialog1;\n\t\/* TRANSLATORS: Replace this string with your names, one name per line. *\/\n\tgchar *translators = _(\"translator-credits\");\n\n\tgchar *string = g_strdup_printf(_(\n\t\t\"Gerbv \u2014 a Gerber (RS-274\/X) viewer\\n\"\n\t\t\"\\n\"\n\t\t\"Version %s\\n\"\n\t\t\"Compiled on %s at %s\\n\"\n\t\t\"\\n\"\n\t\t\"Gerbv was originally developed as part of the gEDA Project \"\n\t\t\"but is now separately maintained.\\n\"\n\t\t\"\\n\"\n\t\t\"For more information see:\\n\"\n\t\t\"  gerbv homepage: https:\/\/gerbv.github.io\/\\n\"\n\t\t\"  gerbv repository: https:\/\/github.com\/gerbv\/gerbv\"),\n\t\tVERSION, __DATE__, __TIME__);\n\n#if GTK_CHECK_VERSION(2,6,0)\n\tgchar *license = g_strdup_printf(_(\n\t\t\"Gerbv \u2014 a Gerber (RS-274\/X) viewer\\n\"\n\t\t\"\\n\"\n\t\t\"Copyright (C) 2000\u20142007 Stefan Petersen\\n\"\n\t\t\"\\n\"\n\t\t\"This program is free software: you can redistribute it and\/or modify\\n\"\n\t\t\"it under the terms of the GNU General Public License as published by\\n\"\n\t\t\"the Free Software Foundation, either version 2 of the License, or\\n\"\n\t\t\"(at your option) any later version.\\n\"\n\t\t\"\\n\"\n\t\t\"This program is distributed in the hope that it will be useful,\\n\"\n\t\t\"but WITHOUT ANY WARRANTY; without even the implied warranty of\\n\"\n\t\t\"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\\n\"\n\t\t\"GNU General Public License for more details.\\n\\n\"\n\t\t\"You should have received a copy of the GNU General Public License\\n\"\n\t\t\"along with this program.  If not, see <http:\/\/www.gnu.org\/licenses\/>.\"));\n\n\t#include \"authors.c\"\n\n\tint a_size, i;\n\tgchar **a;\n\n\taboutdialog1 = gtk_about_dialog_new ();\n\tgtk_container_set_border_width (GTK_CONTAINER (aboutdialog1), 5);\n\tgtk_about_dialog_set_version (GTK_ABOUT_DIALOG (aboutdialog1), VERSION);\n\tgtk_about_dialog_set_name (GTK_ABOUT_DIALOG (aboutdialog1), _(\"Gerbv\"));\n\n\tgtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (aboutdialog1), translators);\n\tgtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (aboutdialog1), string);\n\tgtk_about_dialog_set_license(GTK_ABOUT_DIALOG (aboutdialog1), license);\n\n\t\/* The authors.c file is autogenerated at build time *\/\n\ta_size = sizeof(authors_string_array)\/sizeof(authors_string_array[0]);\n\ta = g_new(gchar *, a_size);\n\tfor (i = 0; i < a_size; i++)\n\t\ta[i] = _(authors_string_array[i]);\n\n\tgtk_about_dialog_set_authors(GTK_ABOUT_DIALOG (aboutdialog1), (const gchar **)a);\n\tgtk_about_dialog_set_website(GTK_ABOUT_DIALOG (aboutdialog1), \"https:\/\/gerbv.github.io\/\");\n\tg_free(a);\n\n\tg_signal_connect (G_OBJECT(aboutdialog1),\"response\",\n\t\t      G_CALLBACK (gtk_widget_destroy), GTK_WIDGET(aboutdialog1));\n\n\tg_free (string);\n\tg_free (license);\n#else\n\taboutdialog1 = gtk_message_dialog_new (\tGTK_WINDOW (screen.win.topLevelWindow),\n\t\t\t\t\t       GTK_DIALOG_DESTROY_WITH_PARENT,\n\t\t\t\t\t       GTK_MESSAGE_INFO,\n\t\t\t\t\t       GTK_BUTTONS_CLOSE,\n\t\t\t\t\t       string\n\t\t\t\t\t       );\n\n\tgtk_window_set_title ( GTK_WINDOW (aboutdialog1), _(\"About Gerbv\"));\n\n\t\/* Destroy the dialog when the user responds to it (e.g. clicks a button) *\/\n\tg_signal_connect_swapped (aboutdialog1, \"response\",\n\t\t\t\t  G_CALLBACK (gtk_widget_destroy),\n\t\t\t\t  aboutdialog1);\n\tg_free (string);\n#endif\n\n\tgtk_widget_show_all(GTK_WIDGET(aboutdialog1));\n\n}","target":0,"code_token_length":860,"total_token_length":1096,"max_tokens_setting":2048}
+{"idx":437700,"func":"static int cx23888_ir_irq_handler(struct v4l2_subdev *sd, u32 status,\n\t\t\t\t  bool *handled)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tstruct cx23885_dev *dev = state->dev;\n\tunsigned long flags;\n\n\tu32 cntrl = cx23888_ir_read4(dev, CX23888_IR_CNTRL_REG);\n\tu32 irqen = cx23888_ir_read4(dev, CX23888_IR_IRQEN_REG);\n\tu32 stats = cx23888_ir_read4(dev, CX23888_IR_STATS_REG);\n\n\tunion cx23888_ir_fifo_rec rx_data[FIFO_RX_DEPTH];\n\tunsigned int i, j, k;\n\tu32 events, v;\n\tint tsr, rsr, rto, ror, tse, rse, rte, roe, kror;\n\n\ttsr = stats & STATS_TSR; \/* Tx FIFO Service Request *\/\n\trsr = stats & STATS_RSR; \/* Rx FIFO Service Request *\/\n\trto = stats & STATS_RTO; \/* Rx Pulse Width Timer Time Out *\/\n\tror = stats & STATS_ROR; \/* Rx FIFO Over Run *\/\n\n\ttse = irqen & IRQEN_TSE; \/* Tx FIFO Service Request IRQ Enable *\/\n\trse = irqen & IRQEN_RSE; \/* Rx FIFO Service Request IRQ Enable *\/\n\trte = irqen & IRQEN_RTE; \/* Rx Pulse Width Timer Time Out IRQ Enable *\/\n\troe = irqen & IRQEN_ROE; \/* Rx FIFO Over Run IRQ Enable *\/\n\n\t*handled = false;\n\tv4l2_dbg(2, ir_888_debug, sd, \"IRQ Status:  %s %s %s %s %s %s\\n\",\n\t\t tsr ? \"tsr\" : \"   \", rsr ? \"rsr\" : \"   \",\n\t\t rto ? \"rto\" : \"   \", ror ? \"ror\" : \"   \",\n\t\t stats & STATS_TBY ? \"tby\" : \"   \",\n\t\t stats & STATS_RBY ? \"rby\" : \"   \");\n\n\tv4l2_dbg(2, ir_888_debug, sd, \"IRQ Enables: %s %s %s %s\\n\",\n\t\t tse ? \"tse\" : \"   \", rse ? \"rse\" : \"   \",\n\t\t rte ? \"rte\" : \"   \", roe ? \"roe\" : \"   \");\n\n\t\/*\n\t * Transmitter interrupt service\n\t *\/\n\tif (tse && tsr) {\n\t\t\/*\n\t\t * TODO:\n\t\t * Check the watermark threshold setting\n\t\t * Pull FIFO_TX_DEPTH or FIFO_TX_DEPTH\/2 entries from tx_kfifo\n\t\t * Push the data to the hardware FIFO.\n\t\t * If there was nothing more to send in the tx_kfifo, disable\n\t\t *\tthe TSR IRQ and notify the v4l2_device.\n\t\t * If there was something in the tx_kfifo, check the tx_kfifo\n\t\t *      level and notify the v4l2_device, if it is low.\n\t\t *\/\n\t\t\/* For now, inhibit TSR interrupt until Tx is implemented *\/\n\t\tirqenable_tx(dev, 0);\n\t\tevents = V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ;\n\t\tv4l2_subdev_notify(sd, V4L2_SUBDEV_IR_TX_NOTIFY, &events);\n\t\t*handled = true;\n\t}\n\n\t\/*\n\t * Receiver interrupt service\n\t *\/\n\tkror = 0;\n\tif ((rse && rsr) || (rte && rto)) {\n\t\t\/*\n\t\t * Receive data on RSR to clear the STATS_RSR.\n\t\t * Receive data on RTO, since we may not have yet hit the RSR\n\t\t * watermark when we receive the RTO.\n\t\t *\/\n\t\tfor (i = 0, v = FIFO_RX_NDV;\n\t\t     (v & FIFO_RX_NDV) && !kror; i = 0) {\n\t\t\tfor (j = 0;\n\t\t\t     (v & FIFO_RX_NDV) && j < FIFO_RX_DEPTH; j++) {\n\t\t\t\tv = cx23888_ir_read4(dev, CX23888_IR_FIFO_REG);\n\t\t\t\trx_data[i].hw_fifo_data = v & ~FIFO_RX_NDV;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (i == 0)\n\t\t\t\tbreak;\n\t\t\tj = i * sizeof(union cx23888_ir_fifo_rec);\n\t\t\tk = kfifo_in_locked(&state->rx_kfifo,\n\t\t\t\t      (unsigned char *) rx_data, j,\n\t\t\t\t      &state->rx_kfifo_lock);\n\t\t\tif (k != j)\n\t\t\t\tkror++; \/* rx_kfifo over run *\/\n\t\t}\n\t\t*handled = true;\n\t}\n\n\tevents = 0;\n\tv = 0;\n\tif (kror) {\n\t\tevents |= V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN;\n\t\tv4l2_err(sd, \"IR receiver software FIFO overrun\\n\");\n\t}\n\tif (roe && ror) {\n\t\t\/*\n\t\t * The RX FIFO Enable (CNTRL_RFE) must be toggled to clear\n\t\t * the Rx FIFO Over Run status (STATS_ROR)\n\t\t *\/\n\t\tv |= CNTRL_RFE;\n\t\tevents |= V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN;\n\t\tv4l2_err(sd, \"IR receiver hardware FIFO overrun\\n\");\n\t}\n\tif (rte && rto) {\n\t\t\/*\n\t\t * The IR Receiver Enable (CNTRL_RXE) must be toggled to clear\n\t\t * the Rx Pulse Width Timer Time Out (STATS_RTO)\n\t\t *\/\n\t\tv |= CNTRL_RXE;\n\t\tevents |= V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED;\n\t}\n\tif (v) {\n\t\t\/* Clear STATS_ROR & STATS_RTO as needed by resetting hardware *\/\n\t\tcx23888_ir_write4(dev, CX23888_IR_CNTRL_REG, cntrl & ~v);\n\t\tcx23888_ir_write4(dev, CX23888_IR_CNTRL_REG, cntrl);\n\t\t*handled = true;\n\t}\n\n\tspin_lock_irqsave(&state->rx_kfifo_lock, flags);\n\tif (kfifo_len(&state->rx_kfifo) >= CX23888_IR_RX_KFIFO_SIZE \/ 2)\n\t\tevents |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;\n\tspin_unlock_irqrestore(&state->rx_kfifo_lock, flags);\n\n\tif (events)\n\t\tv4l2_subdev_notify(sd, V4L2_SUBDEV_IR_RX_NOTIFY, &events);\n\treturn 0;\n}","target":0,"code_token_length":1434,"total_token_length":1670,"max_tokens_setting":2048}
+{"idx":221518,"func":"flatpak_run_add_x11_args (FlatpakBwrap *bwrap,\n                          gboolean      allowed)\n{\n  g_autofree char *x11_socket = NULL;\n  const char *display;\n\n  \/* Always cover \/tmp\/.X11-unix, that way we never see the host one in case\n   * we have access to the host \/tmp. If you request X access we'll put the right\n   * thing in this anyway.\n   *\n   * We need to be a bit careful here, because there are two situations in\n   * which potentially hostile processes have access to \/tmp and could\n   * create symlinks, which in principle could cause us to create the\n   * directory and mount the tmpfs at the target of the symlink instead\n   * of in the intended place:\n   *\n   * - With --filesystem=\/tmp, it's the host \/tmp - but because of the\n   *   special historical status of \/tmp\/.X11-unix, we can assume that\n   *   it is pre-created by the host system before user code gets to run.\n   *\n   * - When \/tmp is shared between all instances of the same app ID,\n   *   in principle the app has control over what's in \/tmp, but in\n   *   practice it can't interfere with \/tmp\/.X11-unix, because we do\n   *   this unconditionally - therefore by the time app code runs,\n   *   \/tmp\/.X11-unix is already a mount point, meaning the app cannot\n   *   rename or delete it.\n   *\/\n  flatpak_bwrap_add_args (bwrap,\n                          \"--tmpfs\", \"\/tmp\/.X11-unix\",\n                          NULL);\n\n  if (!allowed)\n    {\n      flatpak_bwrap_unset_env (bwrap, \"DISPLAY\");\n      return;\n    }\n\n  g_debug (\"Allowing x11 access\");\n\n  display = g_getenv (\"DISPLAY\");\n  if (display && display[0] == ':' && g_ascii_isdigit (display[1]))\n    {\n      const char *display_nr = &display[1];\n      const char *display_nr_end = display_nr;\n      g_autofree char *d = NULL;\n\n      while (g_ascii_isdigit (*display_nr_end))\n        display_nr_end++;\n\n      d = g_strndup (display_nr, display_nr_end - display_nr);\n      x11_socket = g_strdup_printf (\"\/tmp\/.X11-unix\/X%s\", d);\n\n      flatpak_bwrap_add_args (bwrap,\n                              \"--ro-bind\", x11_socket, \"\/tmp\/.X11-unix\/X99\",\n                              NULL);\n      flatpak_bwrap_set_env (bwrap, \"DISPLAY\", \":99.0\", TRUE);\n\n#ifdef ENABLE_XAUTH\n      g_auto(GLnxTmpfile) xauth_tmpf  = { 0, };\n\n      if (glnx_open_anonymous_tmpfile_full (O_RDWR | O_CLOEXEC, \"\/tmp\", &xauth_tmpf, NULL))\n        {\n          FILE *output = fdopen (xauth_tmpf.fd, \"wb\");\n          if (output != NULL)\n            {\n              \/* fd is now owned by output, steal it from the tmpfile *\/\n              int tmp_fd = dup (glnx_steal_fd (&xauth_tmpf.fd));\n              if (tmp_fd != -1)\n                {\n                  static const char dest[] = \"\/run\/flatpak\/Xauthority\";\n\n                  write_xauth (d, output);\n                  flatpak_bwrap_add_args_data_fd (bwrap, \"--ro-bind-data\", tmp_fd, dest);\n\n                  flatpak_bwrap_set_env (bwrap, \"XAUTHORITY\", dest, TRUE);\n                }\n\n              fclose (output);\n\n              if (tmp_fd != -1)\n                lseek (tmp_fd, 0, SEEK_SET);\n            }\n        }\n#endif\n    }\n  else\n    {\n      flatpak_bwrap_unset_env (bwrap, \"DISPLAY\");\n    }\n}","target":0,"code_token_length":843,"total_token_length":1079,"max_tokens_setting":2048}
+{"idx":208464,"func":"static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,\n\t\tint closing, int tx_ring)\n{\n\tstruct pgv *pg_vec = NULL;\n\tstruct packet_sock *po = pkt_sk(sk);\n\tunsigned long *rx_owner_map = NULL;\n\tint was_running, order = 0;\n\tstruct packet_ring_buffer *rb;\n\tstruct sk_buff_head *rb_queue;\n\t__be16 num;\n\tint err;\n\t\/* Added to avoid minimal code churn *\/\n\tstruct tpacket_req *req = &req_u->req;\n\n\trb = tx_ring ? &po->tx_ring : &po->rx_ring;\n\trb_queue = tx_ring ? &sk->sk_write_queue : &sk->sk_receive_queue;\n\n\terr = -EBUSY;\n\tif (!closing) {\n\t\tif (atomic_read(&po->mapped))\n\t\t\tgoto out;\n\t\tif (packet_read_pending(rb))\n\t\t\tgoto out;\n\t}\n\n\tif (req->tp_block_nr) {\n\t\tunsigned int min_frame_size;\n\n\t\t\/* Sanity tests and some calculations *\/\n\t\terr = -EBUSY;\n\t\tif (unlikely(rb->pg_vec))\n\t\t\tgoto out;\n\n\t\tswitch (po->tp_version) {\n\t\tcase TPACKET_V1:\n\t\t\tpo->tp_hdrlen = TPACKET_HDRLEN;\n\t\t\tbreak;\n\t\tcase TPACKET_V2:\n\t\t\tpo->tp_hdrlen = TPACKET2_HDRLEN;\n\t\t\tbreak;\n\t\tcase TPACKET_V3:\n\t\t\tpo->tp_hdrlen = TPACKET3_HDRLEN;\n\t\t\tbreak;\n\t\t}\n\n\t\terr = -EINVAL;\n\t\tif (unlikely((int)req->tp_block_size <= 0))\n\t\t\tgoto out;\n\t\tif (unlikely(!PAGE_ALIGNED(req->tp_block_size)))\n\t\t\tgoto out;\n\t\tmin_frame_size = po->tp_hdrlen + po->tp_reserve;\n\t\tif (po->tp_version >= TPACKET_V3 &&\n\t\t    req->tp_block_size <\n\t\t    BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + min_frame_size)\n\t\t\tgoto out;\n\t\tif (unlikely(req->tp_frame_size < min_frame_size))\n\t\t\tgoto out;\n\t\tif (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))\n\t\t\tgoto out;\n\n\t\trb->frames_per_block = req->tp_block_size \/ req->tp_frame_size;\n\t\tif (unlikely(rb->frames_per_block == 0))\n\t\t\tgoto out;\n\t\tif (unlikely(rb->frames_per_block > UINT_MAX \/ req->tp_block_nr))\n\t\t\tgoto out;\n\t\tif (unlikely((rb->frames_per_block * req->tp_block_nr) !=\n\t\t\t\t\treq->tp_frame_nr))\n\t\t\tgoto out;\n\n\t\terr = -ENOMEM;\n\t\torder = get_order(req->tp_block_size);\n\t\tpg_vec = alloc_pg_vec(req, order);\n\t\tif (unlikely(!pg_vec))\n\t\t\tgoto out;\n\t\tswitch (po->tp_version) {\n\t\tcase TPACKET_V3:\n\t\t\t\/* Block transmit is not supported yet *\/\n\t\t\tif (!tx_ring) {\n\t\t\t\tinit_prb_bdqc(po, rb, pg_vec, req_u);\n\t\t\t} else {\n\t\t\t\tstruct tpacket_req3 *req3 = &req_u->req3;\n\n\t\t\t\tif (req3->tp_retire_blk_tov ||\n\t\t\t\t    req3->tp_sizeof_priv ||\n\t\t\t\t    req3->tp_feature_req_word) {\n\t\t\t\t\terr = -EINVAL;\n\t\t\t\t\tgoto out_free_pg_vec;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (!tx_ring) {\n\t\t\t\trx_owner_map = bitmap_alloc(req->tp_frame_nr,\n\t\t\t\t\tGFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);\n\t\t\t\tif (!rx_owner_map)\n\t\t\t\t\tgoto out_free_pg_vec;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\t\/* Done *\/\n\telse {\n\t\terr = -EINVAL;\n\t\tif (unlikely(req->tp_frame_nr))\n\t\t\tgoto out;\n\t}\n\n\n\t\/* Detach socket from network *\/\n\tspin_lock(&po->bind_lock);\n\twas_running = po->running;\n\tnum = po->num;\n\tif (was_running) {\n\t\tWRITE_ONCE(po->num, 0);\n\t\t__unregister_prot_hook(sk, false);\n\t}\n\tspin_unlock(&po->bind_lock);\n\n\tsynchronize_net();\n\n\terr = -EBUSY;\n\tmutex_lock(&po->pg_vec_lock);\n\tif (closing || atomic_read(&po->mapped) == 0) {\n\t\terr = 0;\n\t\tspin_lock_bh(&rb_queue->lock);\n\t\tswap(rb->pg_vec, pg_vec);\n\t\tif (po->tp_version <= TPACKET_V2)\n\t\t\tswap(rb->rx_owner_map, rx_owner_map);\n\t\trb->frame_max = (req->tp_frame_nr - 1);\n\t\trb->head = 0;\n\t\trb->frame_size = req->tp_frame_size;\n\t\tspin_unlock_bh(&rb_queue->lock);\n\n\t\tswap(rb->pg_vec_order, order);\n\t\tswap(rb->pg_vec_len, req->tp_block_nr);\n\n\t\trb->pg_vec_pages = req->tp_block_size\/PAGE_SIZE;\n\t\tpo->prot_hook.func = (po->rx_ring.pg_vec) ?\n\t\t\t\t\t\ttpacket_rcv : packet_rcv;\n\t\tskb_queue_purge(rb_queue);\n\t\tif (atomic_read(&po->mapped))\n\t\t\tpr_err(\"packet_mmap: vma is busy: %d\\n\",\n\t\t\t       atomic_read(&po->mapped));\n\t}\n\tmutex_unlock(&po->pg_vec_lock);\n\n\tspin_lock(&po->bind_lock);\n\tif (was_running) {\n\t\tWRITE_ONCE(po->num, num);\n\t\tregister_prot_hook(sk);\n\t}\n\tspin_unlock(&po->bind_lock);\n\tif (pg_vec && (po->tp_version > TPACKET_V2)) {\n\t\t\/* Because we don't support block-based V3 on tx-ring *\/\n\t\tif (!tx_ring)\n\t\t\tprb_shutdown_retire_blk_timer(po, rb_queue);\n\t}\n\nout_free_pg_vec:\n\tbitmap_free(rx_owner_map);\n\tif (pg_vec)\n\t\tfree_pg_vec(pg_vec, order, req->tp_block_nr);\nout:\n\treturn err;\n}","target":1,"code_token_length":1279,"total_token_length":1515,"max_tokens_setting":2048}
+{"idx":238509,"func":"static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)\n{\n\tconst struct btf_type *func, *func_proto;\n\tstruct bpf_kfunc_btf_tab *btf_tab;\n\tstruct bpf_kfunc_desc_tab *tab;\n\tstruct bpf_prog_aux *prog_aux;\n\tstruct bpf_kfunc_desc *desc;\n\tconst char *func_name;\n\tstruct btf *desc_btf;\n\tunsigned long addr;\n\tint err;\n\n\tprog_aux = env->prog->aux;\n\ttab = prog_aux->kfunc_tab;\n\tbtf_tab = prog_aux->kfunc_btf_tab;\n\tif (!tab) {\n\t\tif (!btf_vmlinux) {\n\t\t\tverbose(env, \"calling kernel function is not supported without CONFIG_DEBUG_INFO_BTF\\n\");\n\t\t\treturn -ENOTSUPP;\n\t\t}\n\n\t\tif (!env->prog->jit_requested) {\n\t\t\tverbose(env, \"JIT is required for calling kernel function\\n\");\n\t\t\treturn -ENOTSUPP;\n\t\t}\n\n\t\tif (!bpf_jit_supports_kfunc_call()) {\n\t\t\tverbose(env, \"JIT does not support calling kernel function\\n\");\n\t\t\treturn -ENOTSUPP;\n\t\t}\n\n\t\tif (!env->prog->gpl_compatible) {\n\t\t\tverbose(env, \"cannot call kernel function from non-GPL compatible program\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\ttab = kzalloc(sizeof(*tab), GFP_KERNEL);\n\t\tif (!tab)\n\t\t\treturn -ENOMEM;\n\t\tprog_aux->kfunc_tab = tab;\n\t}\n\n\t\/* func_id == 0 is always invalid, but instead of returning an error, be\n\t * conservative and wait until the code elimination pass before returning\n\t * error, so that invalid calls that get pruned out can be in BPF programs\n\t * loaded from userspace.  It is also required that offset be untouched\n\t * for such calls.\n\t *\/\n\tif (!func_id && !offset)\n\t\treturn 0;\n\n\tif (!btf_tab && offset) {\n\t\tbtf_tab = kzalloc(sizeof(*btf_tab), GFP_KERNEL);\n\t\tif (!btf_tab)\n\t\t\treturn -ENOMEM;\n\t\tprog_aux->kfunc_btf_tab = btf_tab;\n\t}\n\n\tdesc_btf = find_kfunc_desc_btf(env, func_id, offset, NULL);\n\tif (IS_ERR(desc_btf)) {\n\t\tverbose(env, \"failed to find BTF for kernel function\\n\");\n\t\treturn PTR_ERR(desc_btf);\n\t}\n\n\tif (find_kfunc_desc(env->prog, func_id, offset))\n\t\treturn 0;\n\n\tif (tab->nr_descs == MAX_KFUNC_DESCS) {\n\t\tverbose(env, \"too many different kernel function calls\\n\");\n\t\treturn -E2BIG;\n\t}\n\n\tfunc = btf_type_by_id(desc_btf, func_id);\n\tif (!func || !btf_type_is_func(func)) {\n\t\tverbose(env, \"kernel btf_id %u is not a function\\n\",\n\t\t\tfunc_id);\n\t\treturn -EINVAL;\n\t}\n\tfunc_proto = btf_type_by_id(desc_btf, func->type);\n\tif (!func_proto || !btf_type_is_func_proto(func_proto)) {\n\t\tverbose(env, \"kernel function btf_id %u does not have a valid func_proto\\n\",\n\t\t\tfunc_id);\n\t\treturn -EINVAL;\n\t}\n\n\tfunc_name = btf_name_by_offset(desc_btf, func->name_off);\n\taddr = kallsyms_lookup_name(func_name);\n\tif (!addr) {\n\t\tverbose(env, \"cannot find address for kernel function %s\\n\",\n\t\t\tfunc_name);\n\t\treturn -EINVAL;\n\t}\n\n\tdesc = &tab->descs[tab->nr_descs++];\n\tdesc->func_id = func_id;\n\tdesc->imm = BPF_CALL_IMM(addr);\n\tdesc->offset = offset;\n\terr = btf_distill_func_proto(&env->log, desc_btf,\n\t\t\t\t     func_proto, func_name,\n\t\t\t\t     &desc->func_model);\n\tif (!err)\n\t\tsort(tab->descs, tab->nr_descs, sizeof(tab->descs[0]),\n\t\t     kfunc_desc_cmp_by_id_off, NULL);\n\treturn err;\n}","target":0,"code_token_length":878,"total_token_length":1114,"max_tokens_setting":2048}
+{"idx":477351,"func":"R_API RBinJavaAttrInfo *r_bin_java_code_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaAttrInfo *attr = NULL, *_attr = NULL;\n\tut32 k = 0, curpos;\n\tut64 offset = 0;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tif (sz < 16 || sz > buf_offset) {\/\/ sz > buf_offset) {\n\t\tfree (attr);\n\t\treturn NULL;\n\t}\n\toffset += 6;\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_CODE_ATTR;\n\tattr->info.code_attr.max_stack = attr->is_attr_in_old_format ? buffer[offset] : R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += attr->is_attr_in_old_format ? 1 : 2;\n\tattr->info.code_attr.max_locals = attr->is_attr_in_old_format ? buffer[offset] : R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += attr->is_attr_in_old_format ? 1 : 2;\n\tattr->info.code_attr.code_length = attr->is_attr_in_old_format ? R_BIN_JAVA_USHORT(buffer, offset) : R_BIN_JAVA_UINT (buffer, offset);\n\toffset += attr->is_attr_in_old_format ? 2 : 4;\n\t\/\/ BUG: possible unsigned integer overflow here\n\tattr->info.code_attr.code_offset = buf_offset + offset;\n\tattr->info.code_attr.code = (ut8 *) malloc (attr->info.code_attr.code_length);\n\tif (!attr->info.code_attr.code) {\n\t\teprintf (\"Handling Code Attributes: Unable to allocate memory \"\n\t\t\t\"(%u bytes) for a code.\\n\", attr->info.code_attr.code_length);\n\t\treturn attr;\n\t}\n\tR_BIN_JAVA_GLOBAL_BIN->current_code_attr = attr;\n\t{\n\t\tint len = attr->info.code_attr.code_length;\n\t\tmemset (attr->info.code_attr.code, 0, len);\n\t\tif (offset + len >= sz) {\n\t\t\treturn attr;\n\t\t}\n\t\tmemcpy (attr->info.code_attr.code, buffer + offset, len);\n\t\toffset += len;\n\t}\n\tattr->info.code_attr.exception_table_length = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.code_attr.exception_table = r_list_newf (free);\n\tfor (k = 0; k < attr->info.code_attr.exception_table_length; k++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (curpos + 8 > sz) {\n\t\t\treturn attr;\n\t\t}\n\t\tRBinJavaExceptionEntry *e = R_NEW0 (RBinJavaExceptionEntry);\n\t\tif (!e) {\n\t\t\tfree (attr);\n\t\t\treturn NULL;\n\t\t}\n\t\te->file_offset = curpos;\n\t\te->start_pc = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\te->end_pc = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\te->handler_pc = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\te->catch_type = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tr_list_append (attr->info.code_attr.exception_table, e);\n\t\te->size = 8;\n\t}\n\tattr->info.code_attr.attributes_count = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\t\/\/ IFDBG eprintf (\"\tcode Attributes_count: %d\\n\", attr->info.code_attr.attributes_count);\n\t\/\/ XXX - attr->info.code_attr.attributes is not freed because one of the code attributes is improperly parsed.\n\tattr->info.code_attr.attributes = r_list_newf (r_bin_java_attribute_free);\n\tif (attr->info.code_attr.attributes_count > 0) {\n\t\tfor (k = 0; k < attr->info.code_attr.attributes_count; k++) {\n\t\t\tint size = (offset < sz) ? sz - offset : 0;\n\t\t\tif (size > sz || size <= 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t_attr = r_bin_java_read_next_attr_from_buffer (bin, buffer + offset, size, buf_offset + offset);\n\t\t\tif (!_attr) {\n\t\t\t\teprintf (\"[X] r_bin_java_code_attr_new: Error unable to parse remainder of classfile after Method's Code Attribute: %d.\\n\", k);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tIFDBG eprintf(\"Parsing @ 0x%\"PFMT64x \" (%s) = 0x%\"PFMT64x \" bytes, %p\\n\", _attr->file_offset, _attr->name, _attr->size, _attr);\n\t\t\toffset += _attr->size;\n\t\t\tr_list_append (attr->info.code_attr.attributes, _attr);\n\t\t\tif (_attr->type == R_BIN_JAVA_ATTR_TYPE_LOCAL_VARIABLE_TABLE_ATTR) {\n\t\t\t\tIFDBG eprintf(\"Parsed the LocalVariableTable, preparing the implicit mthod frame.\\n\");\n\t\t\t\t\/\/ r_bin_java_print_attr_summary(_attr);\n\t\t\t\tattr->info.code_attr.implicit_frame = r_bin_java_build_stack_frame_from_local_variable_table (R_BIN_JAVA_GLOBAL_BIN, _attr);\n\t\t\t\tattr->info.code_attr.implicit_frame->file_offset = buf_offset;\n\t\t\t\tIFDBG r_bin_java_print_stack_map_frame_summary(attr->info.code_attr.implicit_frame);\n\t\t\t\t\/\/ r_list_append (attr->info.code_attr.attributes, attr->info.code_attr.implicit_frame);\n\t\t\t}\n\t\t\t\/\/ if (offset > sz) {\n\t\t\t\/\/ eprintf (\"[X] r_bin_java: Error unable to parse remainder of classfile after Attribute: %d.\\n\", k);\n\t\t\t\/\/ break;\n\t\t\t\/\/ }\n\n\t\t}\n\t}\n\tif (attr->info.code_attr.implicit_frame == NULL) {\n\t\t\/\/ build a default implicit_frame\n\t\tattr->info.code_attr.implicit_frame = r_bin_java_default_stack_frame ();\n\t\t\/\/ r_list_append (attr->info.code_attr.attributes, attr->info.code_attr.implicit_frame);\n\t}\n\tattr->size = offset;\n\treturn attr;\n}","target":0,"code_token_length":1318,"total_token_length":1554,"max_tokens_setting":2048}
+{"idx":489153,"func":"int sctp_process_asconf_ack(struct sctp_association *asoc,\n\t\t\t    struct sctp_chunk *asconf_ack)\n{\n\tstruct sctp_chunk\t*asconf = asoc->addip_last_asconf;\n\tunion sctp_addr_param\t*addr_param;\n\tsctp_addip_param_t\t*asconf_param;\n\tint\tlength = 0;\n\tint\tasconf_len = asconf->skb->len;\n\tint\tall_param_pass = 0;\n\tint\tno_err = 1;\n\tint\tretval = 0;\n\t__be16\terr_code = SCTP_ERROR_NO_ERROR;\n\n\t\/* Skip the chunkhdr and addiphdr from the last asconf sent and store\n\t * a pointer to address parameter.\n\t *\/\n\tlength = sizeof(sctp_addip_chunk_t);\n\taddr_param = (union sctp_addr_param *)(asconf->skb->data + length);\n\tasconf_len -= length;\n\n\t\/* Skip the address parameter in the last asconf sent and store a\n\t * pointer to the first asconf parameter.\n\t *\/\n\tlength = ntohs(addr_param->v4.param_hdr.length);\n\tasconf_param = (sctp_addip_param_t *)((void *)addr_param + length);\n\tasconf_len -= length;\n\n\t\/* ADDIP 4.1\n\t * A8) If there is no response(s) to specific TLV parameter(s), and no\n\t * failures are indicated, then all request(s) are considered\n\t * successful.\n\t *\/\n\tif (asconf_ack->skb->len == sizeof(sctp_addiphdr_t))\n\t\tall_param_pass = 1;\n\n\t\/* Process the TLVs contained in the last sent ASCONF chunk. *\/\n\twhile (asconf_len > 0) {\n\t\tif (all_param_pass)\n\t\t\terr_code = SCTP_ERROR_NO_ERROR;\n\t\telse {\n\t\t\terr_code = sctp_get_asconf_response(asconf_ack,\n\t\t\t\t\t\t\t    asconf_param,\n\t\t\t\t\t\t\t    no_err);\n\t\t\tif (no_err && (SCTP_ERROR_NO_ERROR != err_code))\n\t\t\t\tno_err = 0;\n\t\t}\n\n\t\tswitch (err_code) {\n\t\tcase SCTP_ERROR_NO_ERROR:\n\t\t\tretval = sctp_asconf_param_success(asoc, asconf_param);\n\t\t\tbreak;\n\n\t\tcase SCTP_ERROR_RSRC_LOW:\n\t\t\tretval = 1;\n\t\t\tbreak;\n\n\t\tcase SCTP_ERROR_INV_PARAM:\n\t\t\t\/* Disable sending this type of asconf parameter in\n\t\t\t * future.\n\t\t\t *\/\n\t\t\tasoc->peer.addip_disabled_mask |=\n\t\t\t\tasconf_param->param_hdr.type;\n\t\t\tbreak;\n\n\t\tcase SCTP_ERROR_REQ_REFUSED:\n\t\tcase SCTP_ERROR_DEL_LAST_IP:\n\t\tcase SCTP_ERROR_DEL_SRC_IP:\n\t\tdefault:\n\t\t\t break;\n\t\t}\n\n\t\t\/* Skip the processed asconf parameter and move to the next\n\t\t * one.\n\t\t *\/\n\t\tlength = ntohs(asconf_param->param_hdr.length);\n\t\tasconf_param = (sctp_addip_param_t *)((void *)asconf_param +\n\t\t\t\t\t\t      length);\n\t\tasconf_len -= length;\n\t}\n\n\t\/* Free the cached last sent asconf chunk. *\/\n\tlist_del_init(&asconf->transmitted_list);\n\tsctp_chunk_free(asconf);\n\tasoc->addip_last_asconf = NULL;\n\n\t\/* Send the next asconf chunk from the addip chunk queue. *\/\n\tif (!list_empty(&asoc->addip_chunk_list)) {\n\t\tstruct list_head *entry = asoc->addip_chunk_list.next;\n\t\tasconf = list_entry(entry, struct sctp_chunk, list);\n\n\t\tlist_del_init(entry);\n\n\t\t\/* Hold the chunk until an ASCONF_ACK is received. *\/\n\t\tsctp_chunk_hold(asconf);\n\t\tif (sctp_primitive_ASCONF(asoc, asconf))\n\t\t\tsctp_chunk_free(asconf);\n\t\telse\n\t\t\tasoc->addip_last_asconf = asconf;\n\t}\n\n\treturn retval;\n}","target":0,"code_token_length":803,"total_token_length":1039,"max_tokens_setting":2048}
+{"idx":369232,"func":"\nstatic __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx,\n\t\t\t\t\t  struct seq_file *m)\n{\n\tstruct io_sq_data *sq = NULL;\n\tstruct io_overflow_cqe *ocqe;\n\tstruct io_rings *r = ctx->rings;\n\tunsigned int sq_mask = ctx->sq_entries - 1, cq_mask = ctx->cq_entries - 1;\n\tunsigned int sq_head = READ_ONCE(r->sq.head);\n\tunsigned int sq_tail = READ_ONCE(r->sq.tail);\n\tunsigned int cq_head = READ_ONCE(r->cq.head);\n\tunsigned int cq_tail = READ_ONCE(r->cq.tail);\n\tunsigned int sq_entries, cq_entries;\n\tbool has_lock;\n\tunsigned int i;\n\n\t\/*\n\t * we may get imprecise sqe and cqe info if uring is actively running\n\t * since we get cached_sq_head and cached_cq_tail without uring_lock\n\t * and sq_tail and cq_head are changed by userspace. But it's ok since\n\t * we usually use these info when it is stuck.\n\t *\/\n\tseq_printf(m, \"SqMask:\\t0x%x\\n\", sq_mask);\n\tseq_printf(m, \"SqHead:\\t%u\\n\", sq_head);\n\tseq_printf(m, \"SqTail:\\t%u\\n\", sq_tail);\n\tseq_printf(m, \"CachedSqHead:\\t%u\\n\", ctx->cached_sq_head);\n\tseq_printf(m, \"CqMask:\\t0x%x\\n\", cq_mask);\n\tseq_printf(m, \"CqHead:\\t%u\\n\", cq_head);\n\tseq_printf(m, \"CqTail:\\t%u\\n\", cq_tail);\n\tseq_printf(m, \"CachedCqTail:\\t%u\\n\", ctx->cached_cq_tail);\n\tseq_printf(m, \"SQEs:\\t%u\\n\", sq_tail - ctx->cached_sq_head);\n\tsq_entries = min(sq_tail - sq_head, ctx->sq_entries);\n\tfor (i = 0; i < sq_entries; i++) {\n\t\tunsigned int entry = i + sq_head;\n\t\tunsigned int sq_idx = READ_ONCE(ctx->sq_array[entry & sq_mask]);\n\t\tstruct io_uring_sqe *sqe;\n\n\t\tif (sq_idx > sq_mask)\n\t\t\tcontinue;\n\t\tsqe = &ctx->sq_sqes[sq_idx];\n\t\tseq_printf(m, \"%5u: opcode:%d, fd:%d, flags:%x, user_data:%llu\\n\",\n\t\t\t   sq_idx, sqe->opcode, sqe->fd, sqe->flags,\n\t\t\t   sqe->user_data);\n\t}\n\tseq_printf(m, \"CQEs:\\t%u\\n\", cq_tail - cq_head);\n\tcq_entries = min(cq_tail - cq_head, ctx->cq_entries);\n\tfor (i = 0; i < cq_entries; i++) {\n\t\tunsigned int entry = i + cq_head;\n\t\tstruct io_uring_cqe *cqe = &r->cqes[entry & cq_mask];\n\n\t\tseq_printf(m, \"%5u: user_data:%llu, res:%d, flag:%x\\n\",\n\t\t\t   entry & cq_mask, cqe->user_data, cqe->res,\n\t\t\t   cqe->flags);\n\t}\n\n\t\/*\n\t * Avoid ABBA deadlock between the seq lock and the io_uring mutex,\n\t * since fdinfo case grabs it in the opposite direction of normal use\n\t * cases. If we fail to get the lock, we just don't iterate any\n\t * structures that could be going away outside the io_uring mutex.\n\t *\/\n\thas_lock = mutex_trylock(&ctx->uring_lock);\n\n\tif (has_lock && (ctx->flags & IORING_SETUP_SQPOLL)) {\n\t\tsq = ctx->sq_data;\n\t\tif (!sq->thread)\n\t\t\tsq = NULL;\n\t}\n\n\tseq_printf(m, \"SqThread:\\t%d\\n\", sq ? task_pid_nr(sq->thread) : -1);\n\tseq_printf(m, \"SqThreadCpu:\\t%d\\n\", sq ? task_cpu(sq->thread) : -1);\n\tseq_printf(m, \"UserFiles:\\t%u\\n\", ctx->nr_user_files);\n\tfor (i = 0; has_lock && i < ctx->nr_user_files; i++) {\n\t\tstruct file *f = io_file_from_index(ctx, i);\n\n\t\tif (f)\n\t\t\tseq_printf(m, \"%5u: %s\\n\", i, file_dentry(f)->d_iname);\n\t\telse\n\t\t\tseq_printf(m, \"%5u: <none>\\n\", i);\n\t}\n\tseq_printf(m, \"UserBufs:\\t%u\\n\", ctx->nr_user_bufs);\n\tfor (i = 0; has_lock && i < ctx->nr_user_bufs; i++) {\n\t\tstruct io_mapped_ubuf *buf = ctx->user_bufs[i];\n\t\tunsigned int len = buf->ubuf_end - buf->ubuf;\n\n\t\tseq_printf(m, \"%5u: 0x%llx\/%u\\n\", i, buf->ubuf, len);\n\t}\n\tif (has_lock && !xa_empty(&ctx->personalities)) {\n\t\tunsigned long index;\n\t\tconst struct cred *cred;\n\n\t\tseq_printf(m, \"Personalities:\\n\");\n\t\txa_for_each(&ctx->personalities, index, cred)\n\t\t\tio_uring_show_cred(m, index, cred);\n\t}\n\tif (has_lock)\n\t\tmutex_unlock(&ctx->uring_lock);\n\n\tseq_puts(m, \"PollList:\\n\");\n\tspin_lock(&ctx->completion_lock);\n\tfor (i = 0; i < (1U << ctx->cancel_hash_bits); i++) {\n\t\tstruct hlist_head *list = &ctx->cancel_hash[i];\n\t\tstruct io_kiocb *req;\n\n\t\thlist_for_each_entry(req, list, hash_node)\n\t\t\tseq_printf(m, \"  op=%d, task_works=%d\\n\", req->opcode,\n\t\t\t\t\ttask_work_pending(req->task));\n\t}\n\n\tseq_puts(m, \"CqOverflowList:\\n\");\n\tlist_for_each_entry(ocqe, &ctx->cq_overflow_list, list) {\n\t\tstruct io_uring_cqe *cqe = &ocqe->cqe;\n\n\t\tseq_printf(m, \"  user_data=%llu, res=%d, flags=%x\\n\",\n\t\t\t   cqe->user_data, cqe->res, cqe->flags);\n\n\t}\n\n\tspin_unlock(&ctx->completion_lock);","target":0,"code_token_length":1339,"total_token_length":1575,"max_tokens_setting":2048}
+{"idx":484061,"func":"START_TEST(SecureChannel_sendAsymmetricOPNMessage_sentDataIsValid) {\n    UA_OpenSecureChannelResponse dummyResponse;\n    createDummyResponse(&dummyResponse);\n\n    \/* Enable encryption for the SecureChannel *\/\n#ifdef UA_ENABLE_ENCRYPTION\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;\n#else\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_NONE;\n#endif\n\n    UA_UInt32 requestId = UA_UInt32_random();\n\n    UA_StatusCode retval =\n        UA_SecureChannel_sendAsymmetricOPNMessage(&testChannel, requestId, &dummyResponse,\n                                                  &UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);\n    ck_assert_msg(retval == UA_STATUSCODE_GOOD, \"Expected function to succeed\");\n\n    size_t offset = 0;\n    UA_TcpMessageHeader header;\n    UA_TcpMessageHeader_decodeBinary(&sentData, &offset, &header);\n    UA_UInt32 secureChannelId;\n    UA_UInt32_decodeBinary(&sentData, &offset, &secureChannelId);\n\n    UA_AsymmetricAlgorithmSecurityHeader asymSecurityHeader;\n    UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(&sentData, &offset, &asymSecurityHeader);\n\n    ck_assert_msg(UA_ByteString_equal(&testChannel.securityPolicy->policyUri,\n                                      &asymSecurityHeader.securityPolicyUri),\n                  \"Expected securityPolicyUri to be equal to the one used by the secureChannel\");\n\n#ifdef UA_ENABLE_ENCRYPTION\n    ck_assert_msg(UA_ByteString_equal(&dummyCertificate, &asymSecurityHeader.senderCertificate),\n                  \"Expected the certificate to be equal to the one used  by the secureChannel\");\n\n    UA_ByteString thumbPrint = {20, testChannel.remoteCertificateThumbprint};\n    ck_assert_msg(UA_ByteString_equal(&thumbPrint,\n                                      &asymSecurityHeader.receiverCertificateThumbprint),\n                  \"Expected receiverCertificateThumbprint to be equal to the one set \"\n                  \"in the secureChannel\");\n\n    \/* Dummy encryption *\/\n    for(size_t i = offset; i < header.messageSize; ++i) {\n        sentData.data[i] = (UA_Byte)((sentData.data[i] - 1) % (UA_BYTE_MAX + 1));\n    }\n#endif\n\n    UA_SequenceHeader sequenceHeader;\n    UA_SequenceHeader_decodeBinary(&sentData, &offset, &sequenceHeader);\n    ck_assert_msg(sequenceHeader.requestId == requestId, \"Expected requestId to be %i but was %i\",\n                  requestId,\n                  sequenceHeader.requestId);\n\n    UA_NodeId requestTypeId;\n    UA_NodeId_decodeBinary(&sentData, &offset, &requestTypeId);\n    ck_assert_msg(UA_NodeId_equal(&UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE].binaryEncodingId, &requestTypeId), \"Expected nodeIds to be equal\");\n\n    UA_OpenSecureChannelResponse sentResponse;\n    UA_OpenSecureChannelResponse_decodeBinary(&sentData, &offset, &sentResponse);\n\n    ck_assert_msg(memcmp(&sentResponse, &dummyResponse, sizeof(UA_OpenSecureChannelResponse)) == 0,\n                  \"Expected the sent response to be equal to the one supplied to the send function\");\n\n#ifdef UA_ENABLE_ENCRYPTION\n    UA_Byte paddingByte = sentData.data[offset];\n    size_t paddingSize = (size_t)paddingByte;\n\n    for(size_t i = 0; i <= paddingSize; ++i) {\n        ck_assert_msg(sentData.data[offset + i] == paddingByte,\n                      \"Expected padding byte %i to be %i but got value %i\",\n                      (int)i, paddingByte, sentData.data[offset + i]);\n    }\n\n    ck_assert_msg(sentData.data[offset + paddingSize + 1] == '*', \"Expected first byte of signature\");\n#endif\n\n    UA_AsymmetricAlgorithmSecurityHeader_clear(&asymSecurityHeader);\n    UA_SequenceHeader_clear(&sequenceHeader);\n    UA_OpenSecureChannelResponse_clear(&sentResponse);\n} END_TEST","target":0,"code_token_length":829,"total_token_length":1065,"max_tokens_setting":2048}
+{"idx":472374,"func":"ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,\n                                          int index, Bytecodes::Code bc,\n                                          ciInstanceKlass* accessor) {\n  assert(cpool.not_null(), \"need constant pool\");\n  assert(accessor != NULL, \"need origin of access\");\n  if (bc == Bytecodes::_invokedynamic) {\n    ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index);\n    bool is_resolved = !cpce->is_f1_null();\n    \/\/ FIXME: code generation could allow for null (unlinked) call site\n    \/\/ The call site could be made patchable as follows:\n    \/\/ Load the appendix argument from the constant pool.\n    \/\/ Test the appendix argument and jump to a known deopt routine if it is null.\n    \/\/ Jump through a patchable call site, which is initially a deopt routine.\n    \/\/ Patch the call site to the nmethod entry point of the static compiled lambda form.\n    \/\/ As with other two-component call sites, both values must be independently verified.\n\n    if (is_resolved) {\n      \/\/ Get the invoker Method* from the constant pool.\n      \/\/ (The appendix argument, if any, will be noted in the method's signature.)\n      Method* adapter = cpce->f1_as_method();\n      return get_method(adapter);\n    }\n\n    \/\/ Fake a method that is equivalent to a declared method.\n    ciInstanceKlass* holder    = get_instance_klass(vmClasses::MethodHandle_klass());\n    ciSymbol*        name      = ciSymbols::invokeBasic_name();\n    ciSymbol*        signature = get_symbol(cpool->signature_ref_at(index));\n    return get_unloaded_method(holder, name, signature, accessor);\n  } else {\n    const int holder_index = cpool->klass_ref_index_at(index);\n    bool holder_is_accessible;\n    ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);\n\n    \/\/ Get the method's name and signature.\n    Symbol* name_sym = cpool->name_ref_at(index);\n    Symbol* sig_sym  = cpool->signature_ref_at(index);\n\n    if (cpool->has_preresolution()\n        || ((holder == ciEnv::MethodHandle_klass() || holder == ciEnv::VarHandle_klass()) &&\n            MethodHandles::is_signature_polymorphic_name(holder->get_Klass(), name_sym))) {\n      \/\/ Short-circuit lookups for JSR 292-related call sites.\n      \/\/ That is, do not rely only on name-based lookups, because they may fail\n      \/\/ if the names are not resolvable in the boot class loader (7056328).\n      switch (bc) {\n      case Bytecodes::_invokevirtual:\n      case Bytecodes::_invokeinterface:\n      case Bytecodes::_invokespecial:\n      case Bytecodes::_invokestatic:\n        {\n          Method* m = ConstantPool::method_at_if_loaded(cpool, index);\n          if (m != NULL) {\n            return get_method(m);\n          }\n        }\n        break;\n      default:\n        break;\n      }\n    }\n\n    if (holder_is_accessible) {  \/\/ Our declared holder is loaded.\n      constantTag tag = cpool->tag_ref_at(index);\n      assert(accessor->get_instanceKlass() == cpool->pool_holder(), \"not the pool holder?\");\n      Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag);\n      if (m != NULL &&\n          (bc == Bytecodes::_invokestatic\n           ?  m->method_holder()->is_not_initialized()\n           : !m->method_holder()->is_loaded())) {\n        m = NULL;\n      }\n#ifdef ASSERT\n      if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {\n        m = NULL;\n      }\n#endif\n      if (m != NULL) {\n        \/\/ We found the method.\n        return get_method(m);\n      }\n    }\n\n    \/\/ Either the declared holder was not loaded, or the method could\n    \/\/ not be found.  Create a dummy ciMethod to represent the failed\n    \/\/ lookup.\n    ciSymbol* name      = get_symbol(name_sym);\n    ciSymbol* signature = get_symbol(sig_sym);\n    return get_unloaded_method(holder, name, signature, accessor);\n  }\n}","target":0,"code_token_length":918,"total_token_length":1154,"max_tokens_setting":2048}
+{"idx":211473,"func":"read_bitmap_file_data (FILE    *fstream,\n\t\t       guint   *width, \n\t\t       guint   *height,\n\t\t       guchar **data,\n\t\t       int     *x_hot, \n\t\t       int     *y_hot)\n{\n\tguchar *bits = NULL;\t\t\/* working variable *\/\n\tchar line[MAX_SIZE];\t\t\/* input line from file *\/\n\tint size;\t\t\t\/* number of bytes of data *\/\n\tchar name_and_type[MAX_SIZE];\t\/* an input line *\/\n\tchar *type;\t\t\t\/* for parsing *\/\n\tint value;\t\t\t\/* from an input line *\/\n\tint version10p;\t\t\t\/* boolean, old format *\/\n\tint padding;\t\t\t\/* to handle alignment *\/\n\tint bytes_per_line;\t\t\/* per scanline of data *\/\n\tguint ww = 0;\t\t\t\/* width *\/\n\tguint hh = 0;\t\t\t\/* height *\/\n\tint hx = -1;\t\t\t\/* x hotspot *\/\n\tint hy = -1;\t\t\t\/* y hotspot *\/\n\n\t\/* first time initialization *\/\n\tif (!initialized) {\n\t\tinit_hex_table ();\n\t}\n\n\t\/* error cleanup and return macro *\/\n#define\tRETURN(code) { g_free (bits); return code; }\n\n\twhile (fgets (line, MAX_SIZE, fstream)) {\n\t\tif (strlen (line) == MAX_SIZE-1)\n\t\t\tRETURN (FALSE);\n\t\tif (sscanf (line,\"#define %s %d\",name_and_type,&value) == 2) {\n\t\t\tif (!(type = strrchr (name_and_type, '_')))\n\t\t\t\ttype = name_and_type;\n\t\t\telse {\n\t\t\t\ttype++;\n\t\t\t}\n\n\t\t\tif (!strcmp (\"width\", type))\n\t\t\t\tww = (unsigned int) value;\n\t\t\tif (!strcmp (\"height\", type))\n\t\t\t\thh = (unsigned int) value;\n\t\t\tif (!strcmp (\"hot\", type)) {\n\t\t\t\tif (type-- == name_and_type\n\t\t\t\t    || type-- == name_and_type)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (!strcmp (\"x_hot\", type))\n\t\t\t\t\thx = value;\n\t\t\t\tif (!strcmp (\"y_hot\", type))\n\t\t\t\t\thy = value;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n    \n\t\tif (sscanf (line, \"static short %s = {\", name_and_type) == 1)\n\t\t\tversion10p = 1;\n\t\telse if (sscanf (line,\"static const unsigned char %s = {\",name_and_type) == 1)\n\t\t\tversion10p = 0;\n\t\telse if (sscanf (line,\"static unsigned char %s = {\",name_and_type) == 1)\n\t\t\tversion10p = 0;\n\t\telse if (sscanf (line, \"static const char %s = {\", name_and_type) == 1)\n\t\t\tversion10p = 0;\n\t\telse if (sscanf (line, \"static char %s = {\", name_and_type) == 1)\n\t\t\tversion10p = 0;\n\t\telse\n\t\t\tcontinue;\n\n\t\tif (!(type = strrchr (name_and_type, '_')))\n\t\t\ttype = name_and_type;\n\t\telse\n\t\t\ttype++;\n\n\t\tif (strcmp (\"bits[]\", type))\n\t\t\tcontinue;\n    \n\t\tif (!ww || !hh)\n\t\t\tRETURN (FALSE);\n\n\t\tif ((ww % 16) && ((ww % 16) < 9) && version10p)\n\t\t\tpadding = 1;\n\t\telse\n\t\t\tpadding = 0;\n\n\t\tbytes_per_line = (ww+7)\/8 + padding;\n\n\t\tsize = bytes_per_line * hh;\n\t\tbits = g_malloc (size);\n\n\t\tif (version10p) {\n\t\t\tunsigned char *ptr;\n\t\t\tint bytes;\n\n\t\t\tfor (bytes = 0, ptr = bits; bytes < size; (bytes += 2)) {\n\t\t\t\tif ((value = next_int (fstream)) < 0)\n\t\t\t\t\tRETURN (FALSE);\n\t\t\t\t*(ptr++) = value;\n\t\t\t\tif (!padding || ((bytes+2) % bytes_per_line))\n\t\t\t\t\t*(ptr++) = value >> 8;\n\t\t\t}\n\t\t} else {\n\t\t\tunsigned char *ptr;\n\t\t\tint bytes;\n\n\t\t\tfor (bytes = 0, ptr = bits; bytes < size; bytes++, ptr++) {\n\t\t\t\tif ((value = next_int (fstream)) < 0) \n\t\t\t\t\tRETURN (FALSE);\n\t\t\t\t*ptr=value;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\t}\n\n\tif (!bits)\n\t\tRETURN (FALSE);\n\n\t*data = bits;\n\t*width = ww;\n\t*height = hh;\n\tif (x_hot)\n\t\t*x_hot = hx;\n\tif (y_hot)\n\t\t*y_hot = hy;\n\n\treturn TRUE;\n}","target":1,"code_token_length":972,"total_token_length":1208,"max_tokens_setting":2048}
+{"idx":238816,"func":"f_searchcount(typval_T *argvars, typval_T *rettv)\n{\n    pos_T\t\tpos = curwin->w_cursor;\n    char_u\t\t*pattern = NULL;\n    int\t\t\tmaxcount = SEARCH_STAT_DEF_MAX_COUNT;\n    long\t\ttimeout = SEARCH_STAT_DEF_TIMEOUT;\n    int\t\t\trecompute = TRUE;\n    searchstat_T\tstat;\n\n    if (rettv_dict_alloc(rettv) == FAIL)\n\treturn;\n\n    if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL)\n\treturn;\n\n    if (shortmess(SHM_SEARCHCOUNT))\t\/\/ 'shortmess' contains 'S' flag\n\trecompute = TRUE;\n\n    if (argvars[0].v_type != VAR_UNKNOWN)\n    {\n\tdict_T\t\t*dict;\n\tdictitem_T\t*di;\n\tlistitem_T\t*li;\n\tint\t\terror = FALSE;\n\n\tif (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)\n\t{\n\t    emsg(_(e_dictionary_required));\n\t    return;\n\t}\n\tdict = argvars[0].vval.v_dict;\n\tdi = dict_find(dict, (char_u *)\"timeout\", -1);\n\tif (di != NULL)\n\t{\n\t    timeout = (long)tv_get_number_chk(&di->di_tv, &error);\n\t    if (error)\n\t\treturn;\n\t}\n\tdi = dict_find(dict, (char_u *)\"maxcount\", -1);\n\tif (di != NULL)\n\t{\n\t    maxcount = (int)tv_get_number_chk(&di->di_tv, &error);\n\t    if (error)\n\t\treturn;\n\t}\n\trecompute = dict_get_bool(dict, (char_u *)\"recompute\", recompute);\n\tdi = dict_find(dict, (char_u *)\"pattern\", -1);\n\tif (di != NULL)\n\t{\n\t    pattern = tv_get_string_chk(&di->di_tv);\n\t    if (pattern == NULL)\n\t\treturn;\n\t}\n\tdi = dict_find(dict, (char_u *)\"pos\", -1);\n\tif (di != NULL)\n\t{\n\t    if (di->di_tv.v_type != VAR_LIST)\n\t    {\n\t\tsemsg(_(e_invalid_argument_str), \"pos\");\n\t\treturn;\n\t    }\n\t    if (list_len(di->di_tv.vval.v_list) != 3)\n\t    {\n\t\tsemsg(_(e_invalid_argument_str), \"List format should be [lnum, col, off]\");\n\t\treturn;\n\t    }\n\t    li = list_find(di->di_tv.vval.v_list, 0L);\n\t    if (li != NULL)\n\t    {\n\t\tpos.lnum = tv_get_number_chk(&li->li_tv, &error);\n\t\tif (error)\n\t\t    return;\n\t    }\n\t    li = list_find(di->di_tv.vval.v_list, 1L);\n\t    if (li != NULL)\n\t    {\n\t\tpos.col = tv_get_number_chk(&li->li_tv, &error) - 1;\n\t\tif (error)\n\t\t    return;\n\t    }\n\t    li = list_find(di->di_tv.vval.v_list, 2L);\n\t    if (li != NULL)\n\t    {\n\t\tpos.coladd = tv_get_number_chk(&li->li_tv, &error);\n\t\tif (error)\n\t\t    return;\n\t    }\n\t}\n    }\n\n    save_last_search_pattern();\n#ifdef FEAT_SEARCH_EXTRA\n    save_incsearch_state();\n#endif\n    if (pattern != NULL)\n    {\n\tif (*pattern == NUL)\n\t    goto the_end;\n\tvim_free(spats[last_idx].pat);\n\tspats[last_idx].pat = vim_strsave(pattern);\n    }\n    if (spats[last_idx].pat == NULL || *spats[last_idx].pat == NUL)\n\tgoto the_end;\t\/\/ the previous pattern was never defined\n\n    update_search_stat(0, &pos, &pos, &stat, recompute, maxcount, timeout);\n\n    dict_add_number(rettv->vval.v_dict, \"current\", stat.cur);\n    dict_add_number(rettv->vval.v_dict, \"total\", stat.cnt);\n    dict_add_number(rettv->vval.v_dict, \"exact_match\", stat.exact_match);\n    dict_add_number(rettv->vval.v_dict, \"incomplete\", stat.incomplete);\n    dict_add_number(rettv->vval.v_dict, \"maxcount\", stat.last_maxcount);\n\nthe_end:\n    restore_last_search_pattern();\n#ifdef FEAT_SEARCH_EXTRA\n    restore_incsearch_state();\n#endif\n}","target":0,"code_token_length":943,"total_token_length":1179,"max_tokens_setting":2048}
+{"idx":413595,"func":"R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref, int mode) {\n\tut8 *buf = (ut8 *)malloc (core->blocksize);\n\tif (!buf) {\n\t\treturn -1;\n\t}\n\tint ptrdepth = r_config_get_i (core->config, \"anal.ptrdepth\");\n\tint i, count = 0;\n\tRAnalOp op = R_EMPTY;\n\tut64 at;\n\tchar bckwrds, do_bckwrd_srch;\n\tint arch = -1;\n\tif (core->rasm->bits == 64) {\n\t\t\/\/ speedup search\n\t\tif (!strncmp (core->rasm->cur->name, \"arm\", 3)) {\n\t\t\tarch = R2_ARCH_ARM64;\n\t\t}\n\t}\n\t\/\/ TODO: get current section range here or gtfo\n\t\/\/ ???\n\t\/\/ XXX must read bytes correctly\n\tdo_bckwrd_srch = bckwrds = core->search->bckwrds;\n\tif (!ref) {\n\t\teprintf (\"Null reference search is not supported\\n\");\n\t\tfree (buf);\n\t\treturn -1;\n\t}\n\tr_cons_break_push (NULL, NULL);\n\tif (core->blocksize > OPSZ) {\n\t\tif (bckwrds) {\n\t\t\tif (from + core->blocksize > to) {\n\t\t\t\tat = from;\n\t\t\t\tdo_bckwrd_srch = false;\n\t\t\t} else {\n\t\t\t\tat = to - core->blocksize;\n\t\t\t}\n\t\t} else {\n\t\t\tat = from;\n\t\t}\n\t\twhile ((!bckwrds && at < to) || bckwrds) {\n\t\t\teprintf (\"\\r[0x%08\"PFMT64x\"-0x%08\"PFMT64x\"] \", at, to);\n\t\t\tif (r_cons_is_breaked ()) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\/\/ TODO: this can be probably enhanced\n\t\t\tif (!r_io_read_at (core->io, at, buf, core->blocksize)) {\n\t\t\t\teprintf (\"Failed to read at 0x%08\" PFMT64x \"\\n\", at);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (i = bckwrds ? (core->blocksize - OPSZ - 1) : 0;\n\t\t\t\t (!bckwrds && i < core->blocksize - OPSZ) ||\n\t\t\t\t (bckwrds && i > 0);\n\t\t\t\t bckwrds ? i-- : i++) {\n\t\t\t\t\/\/ TODO: honor anal.align\n\t\t\t\tif (r_cons_is_breaked ()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tswitch (mode) {\n\t\t\t\tcase 'c':\n\t\t\t\t\t(void)opiscall (core, &op, at + i, buf + i, core->blocksize - i, arch);\n\t\t\t\t\tif (op.size < 1) {\n\t\t\t\t\t\top.size = 1;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'r':\n\t\t\t\tcase 'w':\n\t\t\t\tcase 'x':\n\t\t\t\t\t{\n\t\t\t\t\t\tr_anal_op (core->anal, &op, at + i, buf + i, core->blocksize - i, R_ANAL_OP_MASK_BASIC);\n\t\t\t\t\t\tint mask = mode=='r' ? 1 : mode == 'w' ? 2: mode == 'x' ? 4: 0;\n\t\t\t\t\t\tif (op.direction == mask) {\n\t\t\t\t\t\t\ti += op.size;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr_anal_op_fini (&op);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tif (!r_anal_op (core->anal, &op, at + i, buf + i, core->blocksize - i, R_ANAL_OP_MASK_BASIC)) {\n\t\t\t\t\t\tr_anal_op_fini (&op);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tswitch (op.type) {\n\t\t\t\tcase R_ANAL_OP_TYPE_JMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_CJMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_CALL:\n\t\t\t\tcase R_ANAL_OP_TYPE_CCALL:\n\t\t\t\t\tif (op.jump != UT64_MAX &&\n\t\t\t\t\t\tcore_anal_followptr (core, 'C', at + i, op.jump, ref, true, 0)) {\n\t\t\t\t\t\tcount ++;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_OP_TYPE_UCJMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_UJMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_IJMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_RJMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_IRJMP:\n\t\t\t\tcase R_ANAL_OP_TYPE_MJMP:\n\t\t\t\t\tif (op.ptr != UT64_MAX &&\n\t\t\t\t\t\tcore_anal_followptr (core, 'c', at + i, op.ptr, ref, true ,1)) {\n\t\t\t\t\t\tcount ++;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase R_ANAL_OP_TYPE_UCALL:\n\t\t\t\tcase R_ANAL_OP_TYPE_ICALL:\n\t\t\t\tcase R_ANAL_OP_TYPE_RCALL:\n\t\t\t\tcase R_ANAL_OP_TYPE_IRCALL:\n\t\t\t\tcase R_ANAL_OP_TYPE_UCCALL:\n\t\t\t\t\tif (op.ptr != UT64_MAX &&\n\t\t\t\t\t\tcore_anal_followptr (core, 'C', at + i, op.ptr, ref, true ,1)) {\n\t\t\t\t\t\tcount ++;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!r_anal_op (core->anal, &op, at + i, buf + i, core->blocksize - i, R_ANAL_OP_MASK_BASIC)) {\n\t\t\t\t\t\t\tr_anal_op_fini (&op);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (op.ptr != UT64_MAX &&\n\t\t\t\t\t\tcore_anal_followptr (core, 'd', at + i, op.ptr, ref, false, ptrdepth)) {\n\t\t\t\t\t\tcount ++;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (op.size < 1) {\n\t\t\t\t\top.size = 1;\n\t\t\t\t}\n\t\t\t\ti += op.size - 1;\n\t\t\t\tr_anal_op_fini (&op);\n\t\t\t}\n\t\t\tif (bckwrds) {\n\t\t\t\tif (!do_bckwrd_srch) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (at > from + core->blocksize - OPSZ) {\n\t\t\t\t\tat -= core->blocksize;\n\t\t\t\t} else {\n\t\t\t\t\tdo_bckwrd_srch = false;\n\t\t\t\t\tat = from;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tat += core->blocksize - OPSZ;\n\t\t\t}\n\t\t}\n\t} else {\n\t\teprintf (\"error: block size too small\\n\");\n\t}\n\tr_cons_break_pop ();\n\tfree (buf);\n\tr_anal_op_fini (&op);\n\treturn count;\n}","target":0,"code_token_length":1395,"total_token_length":1631,"max_tokens_setting":2048}
+{"idx":198499,"func":"static int uECC_sign_with_k(const uint8_t *private_key,\n                            const uint8_t *message_hash,\n                            unsigned hash_size,\n                            uECC_word_t *k,\n                            uint8_t *signature,\n                            uECC_Curve curve) {\n\n    uECC_word_t tmp[uECC_MAX_WORDS];\n    uECC_word_t s[uECC_MAX_WORDS];\n    uECC_word_t *k2[2] = {tmp, s};\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    uECC_word_t *p = (uECC_word_t *)signature;\n#else\n    uECC_word_t p[uECC_MAX_WORDS * 2];\n#endif\n    uECC_word_t carry;\n    wordcount_t num_words = curve->num_words;\n    wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits);\n    bitcount_t num_n_bits = curve->num_n_bits;\n\n    \/* Make sure 0 < k < curve_n *\/\n    if (uECC_vli_isZero(k, num_words) || uECC_vli_cmp(curve->n, k, num_n_words) != 1) {\n        return 0;\n    }\n\n    carry = regularize_k(k, tmp, s, curve);\n    EccPoint_mult(p, curve->G, k2[!carry], 0, num_n_bits + 1, curve);\n    if (uECC_vli_isZero(p, num_words)) {\n        return 0;\n    }\n\n    \/* If an RNG function was specified, get a random number\n       to prevent side channel analysis of k. *\/\n    if (!g_rng_function) {\n        uECC_vli_clear(tmp, num_n_words);\n        tmp[0] = 1;\n    } else if (!uECC_generate_random_int(tmp, curve->n, num_n_words)) {\n        return 0;\n    }\n\n    \/* Prevent side channel analysis of uECC_vli_modInv() to determine\n       bits of k \/ the private key by premultiplying by a random number *\/\n    uECC_vli_modMult(k, k, tmp, curve->n, num_n_words); \/* k' = rand * k *\/\n    uECC_vli_modInv(k, k, curve->n, num_n_words);       \/* k = 1 \/ k' *\/\n    uECC_vli_modMult(k, k, tmp, curve->n, num_n_words); \/* k = 1 \/ k *\/\n\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0\n    uECC_vli_nativeToBytes(signature, curve->num_bytes, p); \/* store r *\/\n#endif\n\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    bcopy((uint8_t *) tmp, private_key, BITS_TO_BYTES(curve->num_n_bits));\n#else\n    uECC_vli_bytesToNative(tmp, private_key, BITS_TO_BYTES(curve->num_n_bits)); \/* tmp = d *\/\n#endif\n\n    s[num_n_words - 1] = 0;\n    uECC_vli_set(s, p, num_words);\n    uECC_vli_modMult(s, tmp, s, curve->n, num_n_words); \/* s = r*d *\/\n\n    bits2int(tmp, message_hash, hash_size, curve);\n    uECC_vli_modAdd(s, tmp, s, curve->n, num_n_words); \/* s = e + r*d *\/\n    uECC_vli_modMult(s, s, k, curve->n, num_n_words);  \/* s = (e + r*d) \/ k *\/\n    if (uECC_vli_numBits(s, num_n_words) > (bitcount_t)curve->num_bytes * 8) {\n        return 0;\n    }\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    bcopy((uint8_t *) signature + curve->num_bytes, (uint8_t *) s, curve->num_bytes);\n#else\n    uECC_vli_nativeToBytes(signature + curve->num_bytes, curve->num_bytes, s);\n#endif    \n    return 1;\n}","target":1,"code_token_length":878,"total_token_length":1114,"max_tokens_setting":2048}
+{"idx":398495,"func":"RZ_API bool rz_bin_dwarf_line_op_run(const RzBinDwarfLineHeader *hdr, RzBinDwarfSMRegisters *regs, RzBinDwarfLineOp *op,\n\tRZ_NULLABLE RzBinSourceLineInfoBuilder *bob, RZ_NULLABLE RzBinDwarfDebugInfo *info, RZ_NULLABLE RzBinDwarfLineFileCache fnc) {\n\trz_return_val_if_fail(hdr && regs && op, false);\n\tswitch (op->type) {\n\tcase RZ_BIN_DWARF_LINE_OP_TYPE_STD:\n\t\tswitch (op->opcode) {\n\t\tcase DW_LNS_copy:\n\t\t\tif (bob) {\n\t\t\t\tstore_line_sample(bob, hdr, regs, info, fnc);\n\t\t\t}\n\t\t\tregs->basic_block = DWARF_FALSE;\n\t\t\tbreak;\n\t\tcase DW_LNS_advance_pc:\n\t\t\tregs->address += op->args.advance_pc * hdr->min_inst_len;\n\t\t\tbreak;\n\t\tcase DW_LNS_advance_line:\n\t\t\tregs->line += op->args.advance_line;\n\t\t\tbreak;\n\t\tcase DW_LNS_set_file:\n\t\t\tregs->file = op->args.set_file;\n\t\t\tbreak;\n\t\tcase DW_LNS_set_column:\n\t\t\tregs->column = op->args.set_column;\n\t\t\tbreak;\n\t\tcase DW_LNS_negate_stmt:\n\t\t\tregs->is_stmt = regs->is_stmt ? DWARF_FALSE : DWARF_TRUE;\n\t\t\tbreak;\n\t\tcase DW_LNS_set_basic_block:\n\t\t\tregs->basic_block = DWARF_TRUE;\n\t\t\tbreak;\n\t\tcase DW_LNS_const_add_pc:\n\t\t\tregs->address += rz_bin_dwarf_line_header_get_spec_op_advance_pc(hdr, 255);\n\t\t\tbreak;\n\t\tcase DW_LNS_fixed_advance_pc:\n\t\t\tregs->address += op->args.fixed_advance_pc;\n\t\t\tbreak;\n\t\tcase DW_LNS_set_prologue_end:\n\t\t\tregs->prologue_end = ~0;\n\t\t\tbreak;\n\t\tcase DW_LNS_set_epilogue_begin:\n\t\t\tregs->epilogue_begin = ~0;\n\t\t\tbreak;\n\t\tcase DW_LNS_set_isa:\n\t\t\tregs->isa = op->args.set_isa;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn false;\n\t\t}\n\t\tbreak;\n\tcase RZ_BIN_DWARF_LINE_OP_TYPE_EXT:\n\t\tswitch (op->opcode) {\n\t\tcase DW_LNE_end_sequence:\n\t\t\tregs->end_sequence = DWARF_TRUE;\n\t\t\tif (bob) {\n\t\t\t\t\/\/ closing entry\n\t\t\t\trz_bin_source_line_info_builder_push_sample(bob, regs->address, 0, 0, NULL);\n\t\t\t}\n\t\t\trz_bin_dwarf_line_header_reset_regs(hdr, regs);\n\t\t\tbreak;\n\t\tcase DW_LNE_set_address:\n\t\t\tregs->address = op->args.set_address;\n\t\t\tbreak;\n\t\tcase DW_LNE_define_file:\n\t\t\tbreak;\n\t\tcase DW_LNE_set_discriminator:\n\t\t\tregs->discriminator = op->args.set_discriminator;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn false;\n\t\t}\n\t\tbreak;\n\tcase RZ_BIN_DWARF_LINE_OP_TYPE_SPEC:\n\t\tregs->address += rz_bin_dwarf_line_header_get_spec_op_advance_pc(hdr, op->opcode);\n\t\tregs->line += rz_bin_dwarf_line_header_get_spec_op_advance_line(hdr, op->opcode);\n\t\tif (bob) {\n\t\t\tstore_line_sample(bob, hdr, regs, info, fnc);\n\t\t}\n\t\tregs->basic_block = DWARF_FALSE;\n\t\tregs->prologue_end = DWARF_FALSE;\n\t\tregs->epilogue_begin = DWARF_FALSE;\n\t\tregs->discriminator = 0;\n\t\tbreak;\n\tdefault:\n\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048}
+{"idx":491919,"func":"long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,\n\t\t   unsigned int flags)\n{\n\tstruct fuse_file *ff = file->private_data;\n\tstruct fuse_conn *fc = ff->fc;\n\tstruct fuse_ioctl_in inarg = {\n\t\t.fh = ff->fh,\n\t\t.cmd = cmd,\n\t\t.arg = arg,\n\t\t.flags = flags\n\t};\n\tstruct fuse_ioctl_out outarg;\n\tstruct fuse_req *req = NULL;\n\tstruct page **pages = NULL;\n\tstruct page *iov_page = NULL;\n\tstruct iovec *in_iov = NULL, *out_iov = NULL;\n\tunsigned int in_iovs = 0, out_iovs = 0, num_pages = 0, max_pages;\n\tsize_t in_size, out_size, transferred;\n\tint err;\n\n\t\/* assume all the iovs returned by client always fits in a page *\/\n\tBUILD_BUG_ON(sizeof(struct iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE);\n\n\terr = -ENOMEM;\n\tpages = kzalloc(sizeof(pages[0]) * FUSE_MAX_PAGES_PER_REQ, GFP_KERNEL);\n\tiov_page = alloc_page(GFP_KERNEL);\n\tif (!pages || !iov_page)\n\t\tgoto out;\n\n\t\/*\n\t * If restricted, initialize IO parameters as encoded in @cmd.\n\t * RETRY from server is not allowed.\n\t *\/\n\tif (!(flags & FUSE_IOCTL_UNRESTRICTED)) {\n\t\tstruct iovec *iov = page_address(iov_page);\n\n\t\tiov->iov_base = (void __user *)arg;\n\t\tiov->iov_len = _IOC_SIZE(cmd);\n\n\t\tif (_IOC_DIR(cmd) & _IOC_WRITE) {\n\t\t\tin_iov = iov;\n\t\t\tin_iovs = 1;\n\t\t}\n\n\t\tif (_IOC_DIR(cmd) & _IOC_READ) {\n\t\t\tout_iov = iov;\n\t\t\tout_iovs = 1;\n\t\t}\n\t}\n\n retry:\n\tinarg.in_size = in_size = iov_length(in_iov, in_iovs);\n\tinarg.out_size = out_size = iov_length(out_iov, out_iovs);\n\n\t\/*\n\t * Out data can be used either for actual out data or iovs,\n\t * make sure there always is at least one page.\n\t *\/\n\tout_size = max_t(size_t, out_size, PAGE_SIZE);\n\tmax_pages = DIV_ROUND_UP(max(in_size, out_size), PAGE_SIZE);\n\n\t\/* make sure there are enough buffer pages and init request with them *\/\n\terr = -ENOMEM;\n\tif (max_pages > FUSE_MAX_PAGES_PER_REQ)\n\t\tgoto out;\n\twhile (num_pages < max_pages) {\n\t\tpages[num_pages] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM);\n\t\tif (!pages[num_pages])\n\t\t\tgoto out;\n\t\tnum_pages++;\n\t}\n\n\treq = fuse_get_req(fc);\n\tif (IS_ERR(req)) {\n\t\terr = PTR_ERR(req);\n\t\treq = NULL;\n\t\tgoto out;\n\t}\n\tmemcpy(req->pages, pages, sizeof(req->pages[0]) * num_pages);\n\treq->num_pages = num_pages;\n\n\t\/* okay, let's send it to the client *\/\n\treq->in.h.opcode = FUSE_IOCTL;\n\treq->in.h.nodeid = ff->nodeid;\n\treq->in.numargs = 1;\n\treq->in.args[0].size = sizeof(inarg);\n\treq->in.args[0].value = &inarg;\n\tif (in_size) {\n\t\treq->in.numargs++;\n\t\treq->in.args[1].size = in_size;\n\t\treq->in.argpages = 1;\n\n\t\terr = fuse_ioctl_copy_user(pages, in_iov, in_iovs, in_size,\n\t\t\t\t\t   false);\n\t\tif (err)\n\t\t\tgoto out;\n\t}\n\n\treq->out.numargs = 2;\n\treq->out.args[0].size = sizeof(outarg);\n\treq->out.args[0].value = &outarg;\n\treq->out.args[1].size = out_size;\n\treq->out.argpages = 1;\n\treq->out.argvar = 1;\n\n\tfuse_request_send(fc, req);\n\terr = req->out.h.error;\n\ttransferred = req->out.args[1].size;\n\tfuse_put_request(fc, req);\n\treq = NULL;\n\tif (err)\n\t\tgoto out;\n\n\t\/* did it ask for retry? *\/\n\tif (outarg.flags & FUSE_IOCTL_RETRY) {\n\t\tchar *vaddr;\n\n\t\t\/* no retry if in restricted mode *\/\n\t\terr = -EIO;\n\t\tif (!(flags & FUSE_IOCTL_UNRESTRICTED))\n\t\t\tgoto out;\n\n\t\tin_iovs = outarg.in_iovs;\n\t\tout_iovs = outarg.out_iovs;\n\n\t\t\/*\n\t\t * Make sure things are in boundary, separate checks\n\t\t * are to protect against overflow.\n\t\t *\/\n\t\terr = -ENOMEM;\n\t\tif (in_iovs > FUSE_IOCTL_MAX_IOV ||\n\t\t    out_iovs > FUSE_IOCTL_MAX_IOV ||\n\t\t    in_iovs + out_iovs > FUSE_IOCTL_MAX_IOV)\n\t\t\tgoto out;\n\n\t\terr = -EIO;\n\t\tif ((in_iovs + out_iovs) * sizeof(struct iovec) != transferred)\n\t\t\tgoto out;\n\n\t\t\/* okay, copy in iovs and retry *\/\n\t\tvaddr = kmap_atomic(pages[0], KM_USER0);\n\t\tmemcpy(page_address(iov_page), vaddr, transferred);\n\t\tkunmap_atomic(vaddr, KM_USER0);\n\n\t\tin_iov = page_address(iov_page);\n\t\tout_iov = in_iov + in_iovs;\n\n\t\tgoto retry;\n\t}\n\n\terr = -EIO;\n\tif (transferred > inarg.out_size)\n\t\tgoto out;\n\n\terr = fuse_ioctl_copy_user(pages, out_iov, out_iovs, transferred, true);\n out:\n\tif (req)\n\t\tfuse_put_request(fc, req);\n\tif (iov_page)\n\t\t__free_page(iov_page);\n\twhile (num_pages)\n\t\t__free_page(pages[--num_pages]);\n\tkfree(pages);\n\n\treturn err ? err : outarg.result;\n}","target":0,"code_token_length":1261,"total_token_length":1497,"max_tokens_setting":2048}
+{"idx":210702,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tstruct squashfs_dir_header dirh;\n\tchar buffer[sizeof(struct squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tstruct squashfs_dir_entry *dire = (struct squashfs_dir_entry *) buffer;\n\tlong long start;\n\tlong long bytes;\n\tint dir_count, size;\n\tstruct dir_ent *new_dir;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: malloc failed!\\n\");\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = 0;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 3)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\tbytes = lookup_entry(directory_table_hash, start);\n\n\tif(bytes == -1)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: directory block %lld not \"\n\t\t\t\"found!\\n\", start);\n\n\tbytes += (*i)->offset;\n\tsize = (*i)->data + bytes - 3;\n\n\twhile(bytes < size) {\t\t\t\n\t\tSQUASHFS_SWAP_DIR_HEADER(directory_table + bytes, &dirh);\n\t\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tSQUASHFS_SWAP_DIR_ENTRY(directory_table + bytes, dire);\n\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tmemcpy(dire->name, directory_table + bytes,\n\t\t\t\tdire->size + 1);\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\t\t\tif((dir->dir_count % DIR_ENT_SIZE) == 0) {\n\t\t\t\tnew_dir = realloc(dir->dirs, (dir->dir_count +\n\t\t\t\t\tDIR_ENT_SIZE) * sizeof(struct dir_ent));\n\t\t\t\tif(new_dir == NULL)\n\t\t\t\t\tEXIT_UNSQUASH(\"squashfs_opendir: \"\n\t\t\t\t\t\t\"realloc failed!\\n\");\n\t\t\t\tdir->dirs = new_dir;\n\t\t\t}\n\t\t\tstrcpy(dir->dirs[dir->dir_count].name, dire->name);\n\t\t\tdir->dirs[dir->dir_count].start_block =\n\t\t\t\tdirh.start_block;\n\t\t\tdir->dirs[dir->dir_count].offset = dire->offset;\n\t\t\tdir->dirs[dir->dir_count].type = dire->type;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tfree(dir->dirs);\n\tfree(dir);\n\treturn NULL;\n}","target":1,"code_token_length":854,"total_token_length":1090,"max_tokens_setting":2048}
+{"idx":355657,"func":"do_string_sub(\n    char_u\t*str,\n    char_u\t*pat,\n    char_u\t*sub,\n    typval_T\t*expr,\n    char_u\t*flags)\n{\n    int\t\tsublen;\n    regmatch_T\tregmatch;\n    int\t\ti;\n    int\t\tdo_all;\n    char_u\t*tail;\n    char_u\t*end;\n    garray_T\tga;\n    char_u\t*ret;\n    char_u\t*save_cpo;\n    char_u\t*zero_width = NULL;\n\n    \/\/ Make 'cpoptions' empty, so that the 'l' flag doesn't work here\n    save_cpo = p_cpo;\n    p_cpo = empty_option;\n\n    ga_init2(&ga, 1, 200);\n\n    do_all = (flags[0] == 'g');\n\n    regmatch.rm_ic = p_ic;\n    regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);\n    if (regmatch.regprog != NULL)\n    {\n\ttail = str;\n\tend = str + STRLEN(str);\n\twhile (vim_regexec_nl(®match, str, (colnr_T)(tail - str)))\n\t{\n\t    \/\/ Skip empty match except for first match.\n\t    if (regmatch.startp[0] == regmatch.endp[0])\n\t    {\n\t\tif (zero_width == regmatch.startp[0])\n\t\t{\n\t\t    \/\/ avoid getting stuck on a match with an empty string\n\t\t    i = mb_ptr2len(tail);\n\t\t    mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail,\n\t\t\t\t\t\t\t\t   (size_t)i);\n\t\t    ga.ga_len += i;\n\t\t    tail += i;\n\t\t    continue;\n\t\t}\n\t\tzero_width = regmatch.startp[0];\n\t    }\n\n\t    \/*\n\t     * Get some space for a temporary buffer to do the substitution\n\t     * into.  It will contain:\n\t     * - The text up to where the match is.\n\t     * - The substituted text.\n\t     * - The text after the match.\n\t     *\/\n\t    sublen = vim_regsub(®match, sub, expr, tail, FALSE, TRUE, FALSE);\n\t    if (ga_grow(&ga, (int)((end - tail) + sublen -\n\t\t\t    (regmatch.endp[0] - regmatch.startp[0]))) == FAIL)\n\t    {\n\t\tga_clear(&ga);\n\t\tbreak;\n\t    }\n\n\t    \/\/ copy the text up to where the match is\n\t    i = (int)(regmatch.startp[0] - tail);\n\t    mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i);\n\t    \/\/ add the substituted text\n\t    (void)vim_regsub(®match, sub, expr, (char_u *)ga.ga_data\n\t\t\t\t\t  + ga.ga_len + i, TRUE, TRUE, FALSE);\n\t    ga.ga_len += i + sublen - 1;\n\t    tail = regmatch.endp[0];\n\t    if (*tail == NUL)\n\t\tbreak;\n\t    if (!do_all)\n\t\tbreak;\n\t}\n\n\tif (ga.ga_data != NULL)\n\t    STRCPY((char *)ga.ga_data + ga.ga_len, tail);\n\n\tvim_regfree(regmatch.regprog);\n    }\n\n    ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data);\n    ga_clear(&ga);\n    if (p_cpo == empty_option)\n\tp_cpo = save_cpo;\n    else\n    {\n\t\/\/ Darn, evaluating {sub} expression or {expr} changed the value.\n\t\/\/ If it's still empty it was changed and restored, need to restore in\n\t\/\/ the complicated way.\n\tif (*p_cpo == NUL)\n\t    set_option_value((char_u *)\"cpo\", 0L, save_cpo, 0);\n\tfree_string_option(save_cpo);\n    }\n\n    return ret;\n}","target":0,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048}
+{"idx":468370,"func":"g_socket_client_connect (GSocketClient       *client,\n\t\t\t GSocketConnectable  *connectable,\n\t\t\t GCancellable        *cancellable,\n\t\t\t GError             **error)\n{\n  GIOStream *connection = NULL;\n  GSocketAddressEnumerator *enumerator = NULL;\n  GError *last_error, *tmp_error;\n\n  last_error = NULL;\n\n  if (can_use_proxy (client))\n    {\n      enumerator = g_socket_connectable_proxy_enumerate (connectable);\n      if (client->priv->proxy_resolver &&\n          G_IS_PROXY_ADDRESS_ENUMERATOR (enumerator))\n        {\n          g_object_set (G_OBJECT (enumerator),\n                        \"proxy-resolver\", client->priv->proxy_resolver,\n                        NULL);\n        }\n    }\n  else\n    enumerator = g_socket_connectable_enumerate (connectable);\n\n  while (connection == NULL)\n    {\n      GSocketAddress *address = NULL;\n      gboolean application_proxy = FALSE;\n      GSocket *socket;\n      gboolean using_proxy;\n\n      if (g_cancellable_is_cancelled (cancellable))\n\t{\n\t  g_clear_error (error);\n\t  g_cancellable_set_error_if_cancelled (cancellable, error);\n\t  break;\n\t}\n\n      tmp_error = NULL;\n      g_socket_client_emit_event (client, G_SOCKET_CLIENT_RESOLVING,\n\t\t\t\t  connectable, NULL);\n      address = g_socket_address_enumerator_next (enumerator, cancellable,\n\t      \t\t\t\t\t  &tmp_error);\n\n      if (address == NULL)\n\t{\n\t  if (tmp_error)\n\t    {\n\t      g_clear_error (&last_error);\n\t      g_propagate_error (error, tmp_error);\n\t    }\n\t  else if (last_error)\n\t    {\n\t      g_propagate_error (error, last_error);\n\t    }\n\t  else\n            g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,\n                                 _(\"Unknown error on connect\"));\n\t  break;\n\t}\n      g_socket_client_emit_event (client, G_SOCKET_CLIENT_RESOLVED,\n\t\t\t\t  connectable, NULL);\n\n      using_proxy = (G_IS_PROXY_ADDRESS (address) &&\n\t\t     client->priv->enable_proxy);\n\n      \/* clear error from previous attempt *\/\n      g_clear_error (&last_error);\n\n      socket = create_socket (client, address, &last_error);\n      if (socket == NULL)\n\t{\n\t  g_object_unref (address);\n\t  continue;\n\t}\n\n      connection = (GIOStream *)g_socket_connection_factory_create_connection (socket);\n      g_socket_connection_set_cached_remote_address ((GSocketConnection*)connection, address);\n      g_socket_client_emit_event (client, G_SOCKET_CLIENT_CONNECTING, connectable, connection);\n\n      if (g_socket_connection_connect (G_SOCKET_CONNECTION (connection),\n\t\t\t\t       address, cancellable, &last_error))\n\t{\n          g_socket_connection_set_cached_remote_address ((GSocketConnection*)connection, NULL);\n\t  g_socket_client_emit_event (client, G_SOCKET_CLIENT_CONNECTED, connectable, connection);\n\t}\n      else\n\t{\n\t  clarify_connect_error (last_error, connectable, address);\n\t  g_object_unref (connection);\n\t  connection = NULL;\n\t}\n\n      if (connection && using_proxy)\n\t{\n\t  GProxyAddress *proxy_addr = G_PROXY_ADDRESS (address);\n\t  const gchar *protocol;\n\t  GProxy *proxy;\n\n\t  protocol = g_proxy_address_get_protocol (proxy_addr);\n\n          \/* The connection should not be anything else then TCP Connection,\n           * but let's put a safety guard in case\n\t   *\/\n          if (!G_IS_TCP_CONNECTION (connection))\n            {\n              g_critical (\"Trying to proxy over non-TCP connection, this is \"\n                          \"most likely a bug in GLib IO library.\");\n\n              g_set_error_literal (&last_error,\n                  G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,\n                  _(\"Proxying over a non-TCP connection is not supported.\"));\n\n\t      g_object_unref (connection);\n\t      connection = NULL;\n            }\n\t  else if (g_hash_table_contains (client->priv->app_proxies, protocol))\n\t    {\n\t      application_proxy = TRUE;\n\t    }\n          else if ((proxy = g_proxy_get_default_for_protocol (protocol)))\n\t    {\n\t      GIOStream *proxy_connection;\n\n\t      g_socket_client_emit_event (client, G_SOCKET_CLIENT_PROXY_NEGOTIATING, connectable, connection);\n\t      proxy_connection = g_proxy_connect (proxy,\n\t\t\t\t\t\t  connection,\n\t\t\t\t\t\t  proxy_addr,\n\t\t\t\t\t\t  cancellable,\n\t\t\t\t\t\t  &last_error);\n\t      g_object_unref (connection);\n\t      connection = proxy_connection;\n\t      g_object_unref (proxy);\n\n\t      if (connection)\n\t\tg_socket_client_emit_event (client, G_SOCKET_CLIENT_PROXY_NEGOTIATED, connectable, connection);\n\t    }\n\t  else\n\t    {\n\t      g_set_error (&last_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,\n\t\t\t   _(\"Proxy protocol \u201c%s\u201d is not supported.\"),\n\t\t\t   protocol);\n\t      g_object_unref (connection);\n\t      connection = NULL;\n\t    }\n\t}\n\n      if (!application_proxy && connection && client->priv->tls)\n\t{\n\t  GIOStream *tlsconn;\n\n\t  tlsconn = g_tls_client_connection_new (connection, connectable, &last_error);\n\t  g_object_unref (connection);\n\t  connection = tlsconn;\n\n\t  if (tlsconn)\n\t    {\n\t      g_tls_client_connection_set_validation_flags (G_TLS_CLIENT_CONNECTION (tlsconn),\n                                                            client->priv->tls_validation_flags);\n\t      g_socket_client_emit_event (client, G_SOCKET_CLIENT_TLS_HANDSHAKING, connectable, connection);\n\t      if (g_tls_connection_handshake (G_TLS_CONNECTION (tlsconn),\n\t\t\t\t\t      cancellable, &last_error))\n\t\t{\n\t\t  g_socket_client_emit_event (client, G_SOCKET_CLIENT_TLS_HANDSHAKED, connectable, connection);\n\t\t}\n\t      else\n\t\t{\n\t\t  g_object_unref (tlsconn);\n\t\t  connection = NULL;\n\t\t}\n\t    }\n\t}\n\n      if (connection && !G_IS_SOCKET_CONNECTION (connection))\n\t{\n\t  GSocketConnection *wrapper_connection;\n\n\t  wrapper_connection = g_tcp_wrapper_connection_new (connection, socket);\n\t  g_object_unref (connection);\n\t  connection = (GIOStream *)wrapper_connection;\n\t}\n\n      g_object_unref (socket);\n      g_object_unref (address);\n    }\n  g_object_unref (enumerator);\n\n  g_socket_client_emit_event (client, G_SOCKET_CLIENT_COMPLETE, connectable, connection);\n  return G_SOCKET_CONNECTION (connection);\n}","target":0,"code_token_length":1303,"total_token_length":1539,"max_tokens_setting":2048}
+{"idx":317337,"func":"static inline u16 socket_type_to_security_class(int family, int type, int protocol)\n{\n\tint extsockclass = selinux_policycap_extsockclass();\n\n\tswitch (family) {\n\tcase PF_UNIX:\n\t\tswitch (type) {\n\t\tcase SOCK_STREAM:\n\t\tcase SOCK_SEQPACKET:\n\t\t\treturn SECCLASS_UNIX_STREAM_SOCKET;\n\t\tcase SOCK_DGRAM:\n\t\tcase SOCK_RAW:\n\t\t\treturn SECCLASS_UNIX_DGRAM_SOCKET;\n\t\t}\n\t\tbreak;\n\tcase PF_INET:\n\tcase PF_INET6:\n\t\tswitch (type) {\n\t\tcase SOCK_STREAM:\n\t\tcase SOCK_SEQPACKET:\n\t\t\tif (default_protocol_stream(protocol))\n\t\t\t\treturn SECCLASS_TCP_SOCKET;\n\t\t\telse if (extsockclass && protocol == IPPROTO_SCTP)\n\t\t\t\treturn SECCLASS_SCTP_SOCKET;\n\t\t\telse\n\t\t\t\treturn SECCLASS_RAWIP_SOCKET;\n\t\tcase SOCK_DGRAM:\n\t\t\tif (default_protocol_dgram(protocol))\n\t\t\t\treturn SECCLASS_UDP_SOCKET;\n\t\t\telse if (extsockclass && (protocol == IPPROTO_ICMP ||\n\t\t\t\t\t\t  protocol == IPPROTO_ICMPV6))\n\t\t\t\treturn SECCLASS_ICMP_SOCKET;\n\t\t\telse\n\t\t\t\treturn SECCLASS_RAWIP_SOCKET;\n\t\tcase SOCK_DCCP:\n\t\t\treturn SECCLASS_DCCP_SOCKET;\n\t\tdefault:\n\t\t\treturn SECCLASS_RAWIP_SOCKET;\n\t\t}\n\t\tbreak;\n\tcase PF_NETLINK:\n\t\tswitch (protocol) {\n\t\tcase NETLINK_ROUTE:\n\t\t\treturn SECCLASS_NETLINK_ROUTE_SOCKET;\n\t\tcase NETLINK_SOCK_DIAG:\n\t\t\treturn SECCLASS_NETLINK_TCPDIAG_SOCKET;\n\t\tcase NETLINK_NFLOG:\n\t\t\treturn SECCLASS_NETLINK_NFLOG_SOCKET;\n\t\tcase NETLINK_XFRM:\n\t\t\treturn SECCLASS_NETLINK_XFRM_SOCKET;\n\t\tcase NETLINK_SELINUX:\n\t\t\treturn SECCLASS_NETLINK_SELINUX_SOCKET;\n\t\tcase NETLINK_ISCSI:\n\t\t\treturn SECCLASS_NETLINK_ISCSI_SOCKET;\n\t\tcase NETLINK_AUDIT:\n\t\t\treturn SECCLASS_NETLINK_AUDIT_SOCKET;\n\t\tcase NETLINK_FIB_LOOKUP:\n\t\t\treturn SECCLASS_NETLINK_FIB_LOOKUP_SOCKET;\n\t\tcase NETLINK_CONNECTOR:\n\t\t\treturn SECCLASS_NETLINK_CONNECTOR_SOCKET;\n\t\tcase NETLINK_NETFILTER:\n\t\t\treturn SECCLASS_NETLINK_NETFILTER_SOCKET;\n\t\tcase NETLINK_DNRTMSG:\n\t\t\treturn SECCLASS_NETLINK_DNRT_SOCKET;\n\t\tcase NETLINK_KOBJECT_UEVENT:\n\t\t\treturn SECCLASS_NETLINK_KOBJECT_UEVENT_SOCKET;\n\t\tcase NETLINK_GENERIC:\n\t\t\treturn SECCLASS_NETLINK_GENERIC_SOCKET;\n\t\tcase NETLINK_SCSITRANSPORT:\n\t\t\treturn SECCLASS_NETLINK_SCSITRANSPORT_SOCKET;\n\t\tcase NETLINK_RDMA:\n\t\t\treturn SECCLASS_NETLINK_RDMA_SOCKET;\n\t\tcase NETLINK_CRYPTO:\n\t\t\treturn SECCLASS_NETLINK_CRYPTO_SOCKET;\n\t\tdefault:\n\t\t\treturn SECCLASS_NETLINK_SOCKET;\n\t\t}\n\tcase PF_PACKET:\n\t\treturn SECCLASS_PACKET_SOCKET;\n\tcase PF_KEY:\n\t\treturn SECCLASS_KEY_SOCKET;\n\tcase PF_APPLETALK:\n\t\treturn SECCLASS_APPLETALK_SOCKET;\n\t}\n\n\tif (extsockclass) {\n\t\tswitch (family) {\n\t\tcase PF_AX25:\n\t\t\treturn SECCLASS_AX25_SOCKET;\n\t\tcase PF_IPX:\n\t\t\treturn SECCLASS_IPX_SOCKET;\n\t\tcase PF_NETROM:\n\t\t\treturn SECCLASS_NETROM_SOCKET;\n\t\tcase PF_ATMPVC:\n\t\t\treturn SECCLASS_ATMPVC_SOCKET;\n\t\tcase PF_X25:\n\t\t\treturn SECCLASS_X25_SOCKET;\n\t\tcase PF_ROSE:\n\t\t\treturn SECCLASS_ROSE_SOCKET;\n\t\tcase PF_DECnet:\n\t\t\treturn SECCLASS_DECNET_SOCKET;\n\t\tcase PF_ATMSVC:\n\t\t\treturn SECCLASS_ATMSVC_SOCKET;\n\t\tcase PF_RDS:\n\t\t\treturn SECCLASS_RDS_SOCKET;\n\t\tcase PF_IRDA:\n\t\t\treturn SECCLASS_IRDA_SOCKET;\n\t\tcase PF_PPPOX:\n\t\t\treturn SECCLASS_PPPOX_SOCKET;\n\t\tcase PF_LLC:\n\t\t\treturn SECCLASS_LLC_SOCKET;\n\t\tcase PF_CAN:\n\t\t\treturn SECCLASS_CAN_SOCKET;\n\t\tcase PF_TIPC:\n\t\t\treturn SECCLASS_TIPC_SOCKET;\n\t\tcase PF_BLUETOOTH:\n\t\t\treturn SECCLASS_BLUETOOTH_SOCKET;\n\t\tcase PF_IUCV:\n\t\t\treturn SECCLASS_IUCV_SOCKET;\n\t\tcase PF_RXRPC:\n\t\t\treturn SECCLASS_RXRPC_SOCKET;\n\t\tcase PF_ISDN:\n\t\t\treturn SECCLASS_ISDN_SOCKET;\n\t\tcase PF_PHONET:\n\t\t\treturn SECCLASS_PHONET_SOCKET;\n\t\tcase PF_IEEE802154:\n\t\t\treturn SECCLASS_IEEE802154_SOCKET;\n\t\tcase PF_CAIF:\n\t\t\treturn SECCLASS_CAIF_SOCKET;\n\t\tcase PF_ALG:\n\t\t\treturn SECCLASS_ALG_SOCKET;\n\t\tcase PF_NFC:\n\t\t\treturn SECCLASS_NFC_SOCKET;\n\t\tcase PF_VSOCK:\n\t\t\treturn SECCLASS_VSOCK_SOCKET;\n\t\tcase PF_KCM:\n\t\t\treturn SECCLASS_KCM_SOCKET;\n\t\tcase PF_QIPCRTR:\n\t\t\treturn SECCLASS_QIPCRTR_SOCKET;\n\t\tcase PF_SMC:\n\t\t\treturn SECCLASS_SMC_SOCKET;\n\t\tcase PF_XDP:\n\t\t\treturn SECCLASS_XDP_SOCKET;\n\t\tcase PF_MCTP:\n\t\t\treturn SECCLASS_MCTP_SOCKET;\n#if PF_MAX > 46\n#error New address family defined, please update this function.\n#endif\n\t\t}\n\t}\n\n\treturn SECCLASS_SOCKET;\n}","target":0,"code_token_length":1108,"total_token_length":1344,"max_tokens_setting":2048}
+{"idx":474075,"func":"onig_error_code_to_format(int code)\n{\n  const char *p;\n\n  if (code >= 0) return (UChar* )0;\n\n  switch (code) {\n  case ONIG_MISMATCH:\n    p = \"mismatch\"; break;\n  case ONIG_NO_SUPPORT_CONFIG:\n    p = \"no support in this configuration\"; break;\n  case ONIGERR_MEMORY:\n    p = \"failed to allocate memory\"; break;\n  case ONIGERR_MATCH_STACK_LIMIT_OVER:\n    p = \"match-stack limit over\"; break;\n  case ONIGERR_TYPE_BUG:\n    p = \"undefined type (bug)\"; break;\n  case ONIGERR_PARSER_BUG:\n    p = \"internal parser error (bug)\"; break;\n  case ONIGERR_STACK_BUG:\n    p = \"stack error (bug)\"; break;\n  case ONIGERR_UNDEFINED_BYTECODE:\n    p = \"undefined bytecode (bug)\"; break;\n  case ONIGERR_UNEXPECTED_BYTECODE:\n    p = \"unexpected bytecode (bug)\"; break;\n  case ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED:\n    p = \"default multibyte-encoding is not setted\"; break;\n  case ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR:\n    p = \"can't convert to wide-char on specified multibyte-encoding\"; break;\n  case ONIGERR_INVALID_ARGUMENT:\n    p = \"invalid argument\"; break;\n  case ONIGERR_END_PATTERN_AT_LEFT_BRACE:\n    p = \"end pattern at left brace\"; break;\n  case ONIGERR_END_PATTERN_AT_LEFT_BRACKET:\n    p = \"end pattern at left bracket\"; break;\n  case ONIGERR_EMPTY_CHAR_CLASS:\n    p = \"empty char-class\"; break;\n  case ONIGERR_PREMATURE_END_OF_CHAR_CLASS:\n    p = \"premature end of char-class\"; break;\n  case ONIGERR_END_PATTERN_AT_ESCAPE:\n    p = \"end pattern at escape\"; break;\n  case ONIGERR_END_PATTERN_AT_META:\n    p = \"end pattern at meta\"; break;\n  case ONIGERR_END_PATTERN_AT_CONTROL:\n    p = \"end pattern at control\"; break;\n  case ONIGERR_META_CODE_SYNTAX:\n    p = \"invalid meta-code syntax\"; break;\n  case ONIGERR_CONTROL_CODE_SYNTAX:\n    p = \"invalid control-code syntax\"; break;\n  case ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE:\n    p = \"char-class value at end of range\"; break;\n  case ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE:\n    p = \"char-class value at start of range\"; break;\n  case ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS:\n    p = \"unmatched range specifier in char-class\"; break;\n  case ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED:\n    p = \"target of repeat operator is not specified\"; break;\n  case ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID:\n    p = \"target of repeat operator is invalid\"; break;\n  case ONIGERR_NESTED_REPEAT_OPERATOR:\n    p = \"nested repeat operator\"; break;\n  case ONIGERR_UNMATCHED_CLOSE_PARENTHESIS:\n    p = \"unmatched close parenthesis\"; break;\n  case ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS:\n    p = \"end pattern with unmatched parenthesis\"; break;\n  case ONIGERR_END_PATTERN_IN_GROUP:\n    p = \"end pattern in group\"; break;\n  case ONIGERR_UNDEFINED_GROUP_OPTION:\n    p = \"undefined group option\"; break;\n  case ONIGERR_INVALID_POSIX_BRACKET_TYPE:\n    p = \"invalid POSIX bracket type\"; break;\n  case ONIGERR_INVALID_LOOK_BEHIND_PATTERN:\n    p = \"invalid pattern in look-behind\"; break;\n  case ONIGERR_INVALID_REPEAT_RANGE_PATTERN:\n    p = \"invalid repeat range {lower,upper}\"; break;\n  case ONIGERR_TOO_BIG_NUMBER:\n    p = \"too big number\"; break;\n  case ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE:\n    p = \"too big number for repeat range\"; break;\n  case ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE:\n    p = \"upper is smaller than lower in repeat range\"; break;\n  case ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS:\n    p = \"empty range in char class\"; break;\n  case ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE:\n    p = \"mismatch multibyte code length in char-class range\"; break;\n  case ONIGERR_TOO_MANY_MULTI_BYTE_RANGES:\n    p = \"too many multibyte code ranges are specified\"; break;\n  case ONIGERR_TOO_SHORT_MULTI_BYTE_STRING:\n    p = \"too short multibyte code string\"; break;\n  case ONIGERR_TOO_BIG_BACKREF_NUMBER:\n    p = \"too big backref number\"; break;\n  case ONIGERR_INVALID_BACKREF:\n#ifdef USE_NAMED_GROUP\n    p = \"invalid backref number\/name\"; break;\n#else\n    p = \"invalid backref number\"; break;\n#endif\n  case ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED:\n    p = \"numbered backref\/call is not allowed. (use name)\"; break;\n  case ONIGERR_TOO_BIG_WIDE_CHAR_VALUE:\n    p = \"too big wide-char value\"; break;\n  case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:\n    p = \"too long wide-char value\"; break;\n  case ONIGERR_INVALID_CODE_POINT_VALUE:\n    p = \"invalid code point value\"; break;\n  case ONIGERR_EMPTY_GROUP_NAME:\n    p = \"group name is empty\"; break;\n  case ONIGERR_INVALID_GROUP_NAME:\n    p = \"invalid group name <%n>\"; break;\n  case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:\n#ifdef USE_NAMED_GROUP\n    p = \"invalid char in group name <%n>\"; break;\n#else\n    p = \"invalid char in group number <%n>\"; break;\n#endif\n  case ONIGERR_UNDEFINED_NAME_REFERENCE:\n    p = \"undefined name <%n> reference\"; break;\n  case ONIGERR_UNDEFINED_GROUP_REFERENCE:\n    p = \"undefined group <%n> reference\"; break;\n  case ONIGERR_MULTIPLEX_DEFINED_NAME:\n    p = \"multiplex defined name <%n>\"; break;\n  case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:\n    p = \"multiplex definition name <%n> call\"; break;\n  case ONIGERR_NEVER_ENDING_RECURSION:\n    p = \"never ending recursion\"; break;\n  case ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY:\n    p = \"group number is too big for capture history\"; break;\n  case ONIGERR_INVALID_CHAR_PROPERTY_NAME:\n    p = \"invalid character property name {%n}\"; break;\n  case ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION:\n    p = \"not supported encoding combination\"; break;\n  case ONIGERR_INVALID_COMBINATION_OF_OPTIONS:\n    p = \"invalid combination of options\"; break;\n  case ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT:\n    p = \"over thread pass limit count\"; break;\n\n  default:\n    p = \"undefined error code\"; break;\n  }\n\n  return (UChar* )p;\n}","target":0,"code_token_length":1524,"total_token_length":1760,"max_tokens_setting":2048}
+{"idx":352956,"func":"csnNormalize21(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tstruct berval\tgt, cnt, sid, mod;\n\tstruct berval\tbv;\n\tchar\t\tbuf[ STRLENOF( \"YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss\" ) + 1 ];\n\tchar\t\t*ptr;\n\tber_len_t\ti;\n\n\tassert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) != 0 );\n\tassert( !BER_BVISEMPTY( val ) );\n\n\tgt = *val;\n\n\tptr = ber_bvchr( >, '#' );\n\tif ( ptr == NULL || ptr == >.bv_val[gt.bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tgt.bv_len = ptr - gt.bv_val;\n\tif ( gt.bv_len != STRLENOF( \"YYYYmmddHH:MM:SSZ\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( gt.bv_val[ 10 ] != ':' || gt.bv_val[ 13 ] != ':' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tcnt.bv_val = ptr + 1;\n\tcnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val );\n\n\tptr = ber_bvchr( &cnt, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tcnt.bv_len = ptr - cnt.bv_val;\n\tif ( cnt.bv_len != STRLENOF( \"0x0000\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( strncmp( cnt.bv_val, \"0x\", STRLENOF( \"0x\" ) ) != 0 ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tcnt.bv_val += STRLENOF( \"0x\" );\n\tcnt.bv_len -= STRLENOF( \"0x\" );\n\n\tsid.bv_val = ptr + 1;\n\tsid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val );\n\t\t\n\tptr = ber_bvchr( &sid, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tsid.bv_len = ptr - sid.bv_val;\n\tif ( sid.bv_len != STRLENOF( \"0\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tmod.bv_val = ptr + 1;\n\tmod.bv_len = val->bv_len - ( mod.bv_val - val->bv_val );\n\tif ( mod.bv_len != STRLENOF( \"0000\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_len = STRLENOF( \"YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss\" );\n\tbv.bv_val = buf;\n\n\tptr = bv.bv_val;\n\tptr = lutil_strncopy( ptr, gt.bv_val, STRLENOF( \"YYYYmmddHH\" ) );\n\tptr = lutil_strncopy( ptr, >.bv_val[ STRLENOF( \"YYYYmmddHH:\" ) ],\n\t\tSTRLENOF( \"MM\" ) );\n\tptr = lutil_strncopy( ptr, >.bv_val[ STRLENOF( \"YYYYmmddHH:MM:\" ) ],\n\t\tSTRLENOF( \"SS\" ) );\n\tptr = lutil_strcopy( ptr, \".000000Z#00\" );\n\tptr = lutil_strbvcopy( ptr, &cnt );\n\t*ptr++ = '#';\n\t*ptr++ = '0';\n\t*ptr++ = '0';\n\t*ptr++ = sid.bv_val[ 0 ];\n\t*ptr++ = '#';\n\t*ptr++ = '0';\n\t*ptr++ = '0';\n\tfor ( i = 0; i < mod.bv_len; i++ ) {\n\t\t*ptr++ = TOLOWER( mod.bv_val[ i ] );\n\t}\n\t*ptr = '\\0';\n\n\tassert( ptr == &bv.bv_val[bv.bv_len] );\n\n\tif ( csnValidate( syntax, &bv ) != LDAP_SUCCESS ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tber_dupbv_x( normalized, &bv, ctx );\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":989,"total_token_length":1225,"max_tokens_setting":2048}
+{"idx":261892,"func":"njs_string_prototype_pad(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t pad_start)\n{\n    u_char             *p, *start;\n    size_t             padding, trunc, new_size;\n    int64_t            length, new_length;\n    uint32_t           n, pad_length;\n    njs_int_t          ret;\n    njs_value_t        *value, *pad;\n    const u_char       *end;\n    njs_string_prop_t  string, pad_string;\n\n    static const njs_value_t  string_space = njs_string(\" \");\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = njs_string_prop(&string, njs_argument(args, 0));\n\n    new_length = 0;\n\n    if (nargs > 1) {\n        value = njs_argument(args, 1);\n\n        if (njs_slow_path(!njs_is_number(value))) {\n            ret = njs_value_to_integer(vm, value, &new_length);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n        } else {\n            new_length = njs_number_to_integer(njs_number(value));\n        }\n    }\n\n    if (new_length <= length) {\n        vm->retval = args[0];\n        return NJS_OK;\n    }\n\n    if (njs_slow_path(new_length >= NJS_STRING_MAX_LENGTH)) {\n        njs_range_error(vm, NULL);\n        return NJS_ERROR;\n    }\n\n    padding = new_length - length;\n\n    \/* GCC and Clang complain about uninitialized n and trunc. *\/\n    n = 0;\n    trunc = 0;\n\n    pad = njs_arg(args, nargs, 2);\n\n    if (njs_slow_path(!njs_is_string(pad))) {\n        if (njs_is_undefined(pad)) {\n            pad = njs_value_arg(&string_space);\n\n        } else {\n            ret = njs_value_to_string(vm, pad, pad);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return NJS_ERROR;\n            }\n        }\n    }\n\n    pad_length = njs_string_prop(&pad_string, pad);\n\n    if (pad_string.size == 0) {\n        vm->retval = args[0];\n        return NJS_OK;\n    }\n\n    if (pad_string.size > 1) {\n        n = padding \/ pad_length;\n        trunc = padding % pad_length;\n\n        if (pad_string.size != (size_t) pad_length) {\n            \/* UTF-8 string. *\/\n            end = pad_string.start + pad_string.size;\n            end = njs_string_offset(pad_string.start, end, trunc);\n\n            trunc = end - pad_string.start;\n            padding = pad_string.size * n + trunc;\n        }\n    }\n\n    new_size = string.size + padding;\n\n    start = njs_string_alloc(vm, &vm->retval, new_size, new_length);\n    if (njs_slow_path(start == NULL)) {\n        return NJS_ERROR;\n    }\n\n    p = start;\n\n    if (pad_start) {\n        start += padding;\n\n    } else {\n        p += string.size;\n    }\n\n    memcpy(start, string.start, string.size);\n\n    if (pad_string.size == 1) {\n        njs_memset(p, pad_string.start[0], padding);\n\n    } else {\n        while (n != 0) {\n            memcpy(p, pad_string.start, pad_string.size);\n            p += pad_string.size;\n            n--;\n        }\n\n        memcpy(p, pad_string.start, trunc);\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":791,"total_token_length":1027,"max_tokens_setting":2048}
+{"idx":391666,"func":"NTSTATUS smbd_check_access_rights(struct connection_struct *conn,\n\t\t\t\tconst struct smb_filename *smb_fname,\n\t\t\t\tbool use_privs,\n\t\t\t\tuint32_t access_mask)\n{\n\t\/* Check if we have rights to open. *\/\n\tNTSTATUS status;\n\tstruct security_descriptor *sd = NULL;\n\tuint32_t rejected_share_access;\n\tuint32_t rejected_mask = access_mask;\n\tuint32_t do_not_check_mask = 0;\n\n\trejected_share_access = access_mask & ~(conn->share_access);\n\n\tif (rejected_share_access) {\n\t\tDEBUG(10, (\"smbd_check_access_rights: rejected share access 0x%x \"\n\t\t\t\"on %s (0x%x)\\n\",\n\t\t\t(unsigned int)access_mask,\n\t\t\tsmb_fname_str_dbg(smb_fname),\n\t\t\t(unsigned int)rejected_share_access ));\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\n\tif (!use_privs && get_current_uid(conn) == (uid_t)0) {\n\t\t\/* I'm sorry sir, I didn't know you were root... *\/\n\t\tDEBUG(10,(\"smbd_check_access_rights: root override \"\n\t\t\t\"on %s. Granting 0x%x\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname),\n\t\t\t(unsigned int)access_mask ));\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tif ((access_mask & DELETE_ACCESS) && !lp_acl_check_permissions(SNUM(conn))) {\n\t\tDEBUG(10,(\"smbd_check_access_rights: not checking ACL \"\n\t\t\t\"on DELETE_ACCESS on file %s. Granting 0x%x\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname),\n\t\t\t(unsigned int)access_mask ));\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tif (access_mask == DELETE_ACCESS &&\n\t\t\tVALID_STAT(smb_fname->st) &&\n\t\t\tS_ISLNK(smb_fname->st.st_ex_mode)) {\n\t\t\/* We can always delete a symlink. *\/\n\t\tDEBUG(10,(\"smbd_check_access_rights: not checking ACL \"\n\t\t\t\"on DELETE_ACCESS on symlink %s.\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname) ));\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tstatus = SMB_VFS_GET_NT_ACL(conn, smb_fname->base_name,\n\t\t\t(SECINFO_OWNER |\n\t\t\tSECINFO_GROUP |\n\t\t\t SECINFO_DACL), talloc_tos(), &sd);\n\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\tDEBUG(10, (\"smbd_check_access_rights: Could not get acl \"\n\t\t\t\"on %s: %s\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname),\n\t\t\tnt_errstr(status)));\n\n\t\tif (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {\n\t\t\tgoto access_denied;\n\t\t}\n\n\t\treturn status;\n\t}\n\n \t\/*\n\t * If we can access the path to this file, by\n\t * default we have FILE_READ_ATTRIBUTES from the\n\t * containing directory. See the section:\n\t * \"Algorithm to Check Access to an Existing File\"\n\t * in MS-FSA.pdf.\n\t *\n\t * se_file_access_check() also takes care of\n\t * owner WRITE_DAC and READ_CONTROL.\n\t *\/\n\tdo_not_check_mask = FILE_READ_ATTRIBUTES;\n\n\t\/*\n\t * Samba 3.6 and earlier granted execute access even\n\t * if the ACL did not contain execute rights.\n\t * Samba 4.0 is more correct and checks it.\n\t * The compatibilty mode allows to skip this check\n\t * to smoothen upgrades.\n\t *\/\n\tif (lp_acl_allow_execute_always(SNUM(conn))) {\n\t\tdo_not_check_mask |= FILE_EXECUTE;\n\t}\n\n\tstatus = se_file_access_check(sd,\n\t\t\t\tget_current_nttok(conn),\n\t\t\t\tuse_privs,\n\t\t\t\t(access_mask & ~do_not_check_mask),\n\t\t\t\t&rejected_mask);\n\n\tDEBUG(10,(\"smbd_check_access_rights: file %s requesting \"\n\t\t\"0x%x returning 0x%x (%s)\\n\",\n\t\tsmb_fname_str_dbg(smb_fname),\n\t\t(unsigned int)access_mask,\n\t\t(unsigned int)rejected_mask,\n\t\tnt_errstr(status) ));\n\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\tif (DEBUGLEVEL >= 10) {\n\t\t\tDEBUG(10,(\"smbd_check_access_rights: acl for %s is:\\n\",\n\t\t\t\tsmb_fname_str_dbg(smb_fname) ));\n\t\t\tNDR_PRINT_DEBUG(security_descriptor, sd);\n\t\t}\n\t}\n\n\tTALLOC_FREE(sd);\n\n\tif (NT_STATUS_IS_OK(status) ||\n\t\t\t!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {\n\t\treturn status;\n\t}\n\n\t\/* Here we know status == NT_STATUS_ACCESS_DENIED. *\/\n\n  access_denied:\n\n\tif ((access_mask & FILE_WRITE_ATTRIBUTES) &&\n\t\t\t(rejected_mask & FILE_WRITE_ATTRIBUTES) &&\n\t\t\t!lp_store_dos_attributes(SNUM(conn)) &&\n\t\t\t(lp_map_readonly(SNUM(conn)) ||\n\t\t\tlp_map_archive(SNUM(conn)) ||\n\t\t\tlp_map_hidden(SNUM(conn)) ||\n\t\t\tlp_map_system(SNUM(conn)))) {\n\t\trejected_mask &= ~FILE_WRITE_ATTRIBUTES;\n\n\t\tDEBUG(10,(\"smbd_check_access_rights: \"\n\t\t\t\"overrode \"\n\t\t\t\"FILE_WRITE_ATTRIBUTES \"\n\t\t\t\"on file %s\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname)));\n\t}\n\n\tif (parent_override_delete(conn,\n\t\t\t\tsmb_fname,\n\t\t\t\taccess_mask,\n\t\t\t\trejected_mask)) {\n\t\t\/* Were we trying to do an open\n\t\t * for delete and didn't get DELETE\n\t\t * access (only) ? Check if the\n\t\t * directory allows DELETE_CHILD.\n\t\t * See here:\n\t\t * http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2004\/06\/04\/148426.aspx\n\t\t * for details. *\/\n\n\t\trejected_mask &= ~DELETE_ACCESS;\n\n\t\tDEBUG(10,(\"smbd_check_access_rights: \"\n\t\t\t\"overrode \"\n\t\t\t\"DELETE_ACCESS on \"\n\t\t\t\"file %s\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname)));\n\t}\n\n\tif (rejected_mask != 0) {\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":1309,"total_token_length":1545,"max_tokens_setting":2048}
+{"idx":462395,"func":" *\/\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t**pce;\n\tzval\t\t\t\t*obj;\n\tzval\t\t\t\t*tmp;\n\tTSRMLS_FETCH();\n\n\/* OBJECTS_FIXME *\/\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||\n\t\t!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||\n\t  \t!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||\n\t\t!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||\n\t\t!strcmp(name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (!ent1->data) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp(name, EL_BINARY)) {\n\t\t\tint new_len=0;\n\t\t\tunsigned char *new_str;\n\n\t\t\tnew_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);\n\t\t\tSTR_FREE(Z_STRVAL_P(ent1->data));\n\t\t\tif (new_str) {\n\t\t\t\tZ_STRVAL_P(ent1->data) = new_str;\n\t\t\t\tZ_STRLEN_P(ent1->data) = new_len;\n\t\t\t} else {\n\t\t\t\tZVAL_EMPTY_STRING(ent1->data);\n\t\t\t}\n\t\t}\n\n\t\t\/* Call __wakeup() method on the object. *\/\n\t\tif (Z_TYPE_P(ent1->data) == IS_OBJECT) {\n\t\t\tzval *fname, *retval = NULL;\n\n\t\t\tMAKE_STD_ZVAL(fname);\n\t\t\tZVAL_STRING(fname, \"__wakeup\", 1);\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);\n\n\t\t\tzval_dtor(fname);\n\t\t\tFREE_ZVAL(fname);\n\t\t\tif (retval) {\n\t\t\t\tzval_ptr_dtor(&retval);\n\t\t\t}\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t\/* if non-existent field *\/\n\t\t\tif (ent2->type == ST_FIELD && ent2->data == NULL) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\tif (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),\n\t\t\t\t\t\t\t\t\t\t   Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = &PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\/* Initialize target object *\/\n\t\t\t\t\t\tMAKE_STD_ZVAL(obj);\n\t\t\t\t\t\tobject_init_ex(obj, *pce);\n\n\t\t\t\t\t\t\/* Merge current hashtable with object's default properties *\/\n\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP_P(obj),\n\t\t\t\t\t\t\t\t\t\tZ_ARRVAL_P(ent2->data),\n\t\t\t\t\t\t\t\t\t\t(void (*)(void *)) zval_add_ref,\n\t\t\t\t\t\t\t\t\t\t(void *) &tmp, sizeof(zval *), 0);\n\n\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\tphp_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\/* Clean up old array entry *\/\n\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t\/* Set stack entry to point to the newly created object *\/\n\t\t\t\t\t\tent2->data = obj;\n\n\t\t\t\t\t\t\/* Clean up class name var entry *\/\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE_P(ent2->data);\n\t\t\t\t\t\tZ_DELREF_P(ent1->data);\n\t\t\t\t\t\tadd_property_zval(ent2->data, ent1->varname, ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp(name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}","target":0,"code_token_length":1266,"total_token_length":1502,"max_tokens_setting":2048}
+{"idx":274725,"func":"callbacks_change_tool (GtkButton *button, gpointer   user_data) {\n\tgint toolNumber = GPOINTER_TO_INT (user_data);\n\t\n\t\/* make sure se don't get caught in endless recursion here *\/\n\tif (screen.win.updatingTools)\n\t\treturn;\n\tscreen.win.updatingTools = TRUE;\n\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonPointer), FALSE);\n\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonPan), FALSE);\n\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonZoom), FALSE);\n\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonMeasure), FALSE);\n\tswitch (toolNumber) {\n\t\tcase POINTER:\n\t\t\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonPointer), TRUE);\n\t\t\tscreen.tool = POINTER;\n\t\t\tscreen.state = NORMAL;\n\t\t\tutf8_strncpy(screen.statusbar.diststr,\n\t\t\t\t_(\"Click to select objects in the active layer. \"\n\t\t\t\t\t\"Middle click and drag to pan.\"),\n\t\t\t\tMAX_DISTLEN);\n\t\t\tbreak;\n\t\tcase PAN:\n\t\t\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonPan), TRUE);\n\t\t\tscreen.tool = PAN;\n\t\t\tscreen.state = NORMAL;\n\t\t\tutf8_strncpy(screen.statusbar.diststr,\n\t\t\t\t_(\"Click and drag to pan. Right click and drag to zoom.\"),\n\t\t\t\tMAX_DISTLEN);\n\t\t\tbreak;\n\t\tcase ZOOM:\n\t\t\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonZoom), TRUE);\n\t\t\tscreen.tool = ZOOM;\n\t\t\tscreen.state = NORMAL;\n\t\t\tutf8_strncpy(screen.statusbar.diststr,\n\t\t\t\t_(\"Click and drag to zoom in. Shift+click to zoom out.\"),\n\t\t\t\tMAX_DISTLEN);\n\t\t\tbreak;\n\n\t\tcase MEASURE:\n\t\t\tgtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (screen.win.toolButtonMeasure), TRUE);\n\t\t\tscreen.tool = MEASURE;\n\t\t\tscreen.state = NORMAL;\n\t\t\tutf8_strncpy(screen.statusbar.diststr,\n\t\t\t\t_(\"Click and drag to measure a distance or select two apertures.\"),\n\t\t\t\tMAX_DISTLEN);\n\n\t\t\t\/* To not show previous measure drag-line *\/\n\t\t\tscreen.measure_start_x = 0;\n\t\t\tscreen.measure_start_y = 0;\n\t\t\tscreen.measure_stop_x =  0;\n\t\t\tscreen.measure_stop_y =  0;\n\n\t\t\t\/* If two items are selected, measure they distance *\/\n\t\t\tif (selection_length (&screen.selectionInfo) == 2) {\n\t\t\t\tgerbv_selection_item_t item[2];\n\t\t\t\tgerbv_net_t *net[2];\n\n\t\t\t\titem[0] = selection_get_item_by_index(\n\t\t\t\t\t\t&screen.selectionInfo, 0);\n\t\t\t\titem[1] = selection_get_item_by_index(\n\t\t\t\t\t\t&screen.selectionInfo, 1);\n\t\t\t\tnet[0] = item[0].net;\n\t\t\t\tnet[1] = item[1].net;\n\n\t\t\t\tif ((net[0]->aperture_state ==\n\t\t\t\t\t\tnet[1]->aperture_state)\n\t\t\t\t && (net[0]->aperture_state ==\n\t\t\t\t\t\tGERBV_APERTURE_STATE_FLASH)) {\n\t\t\t\t\tscreen.measure_start_x = net[0]->stop_x;\n\t\t\t\t\tscreen.measure_start_y = net[0]->stop_y;\n\t\t\t\t\tgerbv_transform_coord_for_image(\n\t\t\t\t\t\t\t&screen.measure_start_x,\n\t\t\t\t\t\t\t&screen.measure_start_y,\n\t\t\t\t\t\t\titem[0].image,\n\t\t\t\t\t\t\tmainProject);\n\n\t\t\t\t\tscreen.measure_stop_x = net[1]->stop_x;\n\t\t\t\t\tscreen.measure_stop_y = net[1]->stop_y;\n\t\t\t\t\tgerbv_transform_coord_for_image(\n\t\t\t\t\t\t\t&screen.measure_stop_x,\n\t\t\t\t\t\t\t&screen.measure_stop_y,\n\t\t\t\t\t\t\titem[1].image,\n\t\t\t\t\t\t\tmainProject);\n\n\t\t\t\t\trender_draw_measure_distance();\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\tcallbacks_switch_to_normal_tool_cursor (toolNumber);\n\tcallbacks_update_statusbar();\n\tscreen.win.updatingTools = FALSE;\n\tcallbacks_force_expose_event_for_screen();\n}","target":0,"code_token_length":846,"total_token_length":1082,"max_tokens_setting":2048}
+{"idx":451883,"func":"static jpc_enc_prc_t *prc_create(jpc_enc_prc_t *prc, jpc_enc_band_t *band)\n{\n\tuint_fast32_t prcno;\n\tuint_fast32_t prcxind;\n\tuint_fast32_t prcyind;\n\tuint_fast32_t cbgtlx;\n\tuint_fast32_t cbgtly;\n\tuint_fast32_t tlprctlx;\n\tuint_fast32_t tlprctly;\n\tuint_fast32_t tlcbgtlx;\n\tuint_fast32_t tlcbgtly;\n\tuint_fast16_t rlvlno;\n\tjpc_enc_rlvl_t *rlvl;\n\tuint_fast32_t tlcblktlx;\n\tuint_fast32_t tlcblktly;\n\tuint_fast32_t brcblkbrx;\n\tuint_fast32_t brcblkbry;\n\tuint_fast32_t cblkno;\n\tjpc_enc_cblk_t *cblk;\n\tjpc_enc_tcmpt_t *tcmpt;\n\n\tprc->cblks = 0;\n\tprc->incltree = 0;\n\tprc->savincltree = 0;\n\tprc->nlibtree = 0;\n\tprc->savnlibtree = 0;\n\n\trlvl = band->rlvl;\n\ttcmpt = rlvl->tcmpt;\n\trlvlno = rlvl - tcmpt->rlvls;\n\tprcno = prc - band->prcs;\n\tprcxind = prcno % rlvl->numhprcs;\n\tprcyind = prcno \/ rlvl->numhprcs;\n\tprc->band = band;\n\n\ttlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn);\n\ttlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn);\n\tif (!rlvlno) {\n\t\ttlcbgtlx = tlprctlx;\n\t\ttlcbgtly = tlprctly;\n\t} else {\n\t\ttlcbgtlx = JPC_CEILDIVPOW2(tlprctlx, 1);\n\t\ttlcbgtly = JPC_CEILDIVPOW2(tlprctly, 1);\n\t}\n\n\t\/* Compute the coordinates of the top-left and bottom-right\n\t  corners of the precinct. *\/\n\tcbgtlx = tlcbgtlx + (prcxind << rlvl->cbgwidthexpn);\n\tcbgtly = tlcbgtly + (prcyind << rlvl->cbgheightexpn);\n\tprc->tlx = JAS_MAX(jas_seq2d_xstart(band->data), (jas_matind_t)cbgtlx);\n\tprc->tly = JAS_MAX(jas_seq2d_ystart(band->data), (jas_matind_t)cbgtly);\n\tprc->brx = JAS_MIN(jas_seq2d_xend(band->data), (jas_matind_t)(cbgtlx +\n\t  (1 << rlvl->cbgwidthexpn)));\n\tprc->bry = JAS_MIN(jas_seq2d_yend(band->data), (jas_matind_t)(cbgtly +\n\t  (1 << rlvl->cbgheightexpn)));\n\n\tif (prc->tlx < prc->brx && prc->tly < prc->bry) {\n\t\t\/* The precinct contains at least one code block. *\/\n\n\t\ttlcblktlx = JPC_FLOORTOMULTPOW2(prc->tlx, rlvl->cblkwidthexpn);\n\t\ttlcblktly = JPC_FLOORTOMULTPOW2(prc->tly, rlvl->cblkheightexpn);\n\t\tbrcblkbrx = JPC_CEILTOMULTPOW2(prc->brx, rlvl->cblkwidthexpn);\n\t\tbrcblkbry = JPC_CEILTOMULTPOW2(prc->bry, rlvl->cblkheightexpn);\n\t\tprc->numhcblks = JPC_FLOORDIVPOW2(brcblkbrx - tlcblktlx,\n\t\t  rlvl->cblkwidthexpn);\n\t\tprc->numvcblks = JPC_FLOORDIVPOW2(brcblkbry - tlcblktly,\n\t\t  rlvl->cblkheightexpn);\n\t\tprc->numcblks = prc->numhcblks * prc->numvcblks;\n\n\t\tif (!(prc->incltree = jpc_tagtree_create(prc->numhcblks,\n\t\t  prc->numvcblks))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (!(prc->nlibtree = jpc_tagtree_create(prc->numhcblks,\n\t\t  prc->numvcblks))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (!(prc->savincltree = jpc_tagtree_create(prc->numhcblks,\n\t\t  prc->numvcblks))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (!(prc->savnlibtree = jpc_tagtree_create(prc->numhcblks,\n\t\t  prc->numvcblks))) {\n\t\t\tgoto error;\n\t\t}\n\n\t\tif (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_enc_cblk_t)))) {\n\t\t\tgoto error;\n\t\t}\n\t\tfor (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;\n\t\t  ++cblkno, ++cblk) {\n\t\t\tcblk->passes = 0;\n\t\t\tcblk->stream = 0;\n\t\t\tcblk->mqenc = 0;\n\t\t\tcblk->data = 0;\n\t\t\tcblk->flags = 0;\n\t\t\tcblk->prc = prc;\n\t\t}\n\t\tfor (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;\n\t\t  ++cblkno, ++cblk) {\n\t\t\tif (!cblk_create(cblk, prc)) {\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t\/* The precinct does not contain any code blocks. *\/\n\t\tprc->tlx = prc->brx;\n\t\tprc->tly = prc->bry;\n\t\tprc->numcblks = 0;\n\t\tprc->numhcblks = 0;\n\t\tprc->numvcblks = 0;\n\t\tprc->cblks = 0;\n\t\tprc->incltree = 0;\n\t\tprc->nlibtree = 0;\n\t\tprc->savincltree = 0;\n\t\tprc->savnlibtree = 0;\n\t}\n\n\treturn prc;\n\nerror:\n\tprc_destroy(prc);\n\treturn 0;\n}","target":0,"code_token_length":1505,"total_token_length":1741,"max_tokens_setting":2048}
+{"idx":486804,"func":"static void gem_write(void *opaque, hwaddr offset, uint64_t val,\n        unsigned size)\n{\n    CadenceGEMState *s = (CadenceGEMState *)opaque;\n    uint32_t readonly;\n    int i;\n\n    DB_PRINT(\"offset: 0x%04x write: 0x%08x \", (unsigned)offset, (unsigned)val);\n    offset >>= 2;\n\n    \/* Squash bits which are read only in write value *\/\n    val &= ~(s->regs_ro[offset]);\n    \/* Preserve (only) bits which are read only and wtc in register *\/\n    readonly = s->regs[offset] & (s->regs_ro[offset] | s->regs_w1c[offset]);\n\n    \/* Copy register write to backing store *\/\n    s->regs[offset] = (val & ~s->regs_w1c[offset]) | readonly;\n\n    \/* do w1c *\/\n    s->regs[offset] &= ~(s->regs_w1c[offset] & val);\n\n    \/* Handle register write side effects *\/\n    switch (offset) {\n    case GEM_NWCTRL:\n        if (val & GEM_NWCTRL_RXENA) {\n            for (i = 0; i < s->num_priority_queues; ++i) {\n                gem_get_rx_desc(s, i);\n            }\n        }\n        if (val & GEM_NWCTRL_TXSTART) {\n            gem_transmit(s);\n        }\n        if (!(val & GEM_NWCTRL_TXENA)) {\n            \/* Reset to start of Q when transmit disabled. *\/\n            for (i = 0; i < s->num_priority_queues; i++) {\n                s->tx_desc_addr[i] = gem_get_tx_queue_base_addr(s, i);\n            }\n        }\n        if (gem_can_receive(qemu_get_queue(s->nic))) {\n            qemu_flush_queued_packets(qemu_get_queue(s->nic));\n        }\n        break;\n\n    case GEM_TXSTATUS:\n        gem_update_int_status(s);\n        break;\n    case GEM_RXQBASE:\n        s->rx_desc_addr[0] = val;\n        break;\n    case GEM_RECEIVE_Q1_PTR ... GEM_RECEIVE_Q7_PTR:\n        s->rx_desc_addr[offset - GEM_RECEIVE_Q1_PTR + 1] = val;\n        break;\n    case GEM_TXQBASE:\n        s->tx_desc_addr[0] = val;\n        break;\n    case GEM_TRANSMIT_Q1_PTR ... GEM_TRANSMIT_Q7_PTR:\n        s->tx_desc_addr[offset - GEM_TRANSMIT_Q1_PTR + 1] = val;\n        break;\n    case GEM_RXSTATUS:\n        gem_update_int_status(s);\n        break;\n    case GEM_IER:\n        s->regs[GEM_IMR] &= ~val;\n        gem_update_int_status(s);\n        break;\n    case GEM_JUMBO_MAX_LEN:\n        s->regs[GEM_JUMBO_MAX_LEN] = val & MAX_JUMBO_FRAME_SIZE_MASK;\n        break;\n    case GEM_INT_Q1_ENABLE ... GEM_INT_Q7_ENABLE:\n        s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_ENABLE] &= ~val;\n        gem_update_int_status(s);\n        break;\n    case GEM_IDR:\n        s->regs[GEM_IMR] |= val;\n        gem_update_int_status(s);\n        break;\n    case GEM_INT_Q1_DISABLE ... GEM_INT_Q7_DISABLE:\n        s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_DISABLE] |= val;\n        gem_update_int_status(s);\n        break;\n    case GEM_SPADDR1LO:\n    case GEM_SPADDR2LO:\n    case GEM_SPADDR3LO:\n    case GEM_SPADDR4LO:\n        s->sar_active[(offset - GEM_SPADDR1LO) \/ 2] = false;\n        break;\n    case GEM_SPADDR1HI:\n    case GEM_SPADDR2HI:\n    case GEM_SPADDR3HI:\n    case GEM_SPADDR4HI:\n        s->sar_active[(offset - GEM_SPADDR1HI) \/ 2] = true;\n        break;\n    case GEM_PHYMNTNC:\n        if (val & GEM_PHYMNTNC_OP_W) {\n            uint32_t phy_addr, reg_num;\n\n            phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;\n            if (phy_addr == s->phy_addr) {\n                reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;\n                gem_phy_write(s, reg_num, val);\n            }\n        }\n        break;\n    }\n\n    DB_PRINT(\"newval: 0x%08x\\n\", s->regs[offset]);\n}","target":0,"code_token_length":1031,"total_token_length":1267,"max_tokens_setting":2048}
+{"idx":313838,"func":"nv_screengo(oparg_T *oap, int dir, long dist)\n{\n    int\t\tlinelen = linetabsize(ml_get_curline());\n    int\t\tretval = OK;\n    int\t\tatend = FALSE;\n    int\t\tn;\n    int\t\tcol_off1;\t\/\/ margin offset for first screen line\n    int\t\tcol_off2;\t\/\/ margin offset for wrapped screen line\n    int\t\twidth1;\t\t\/\/ text width for first screen line\n    int\t\twidth2;\t\t\/\/ text width for wrapped screen line\n\n    oap->motion_type = MCHAR;\n    oap->inclusive = (curwin->w_curswant == MAXCOL);\n\n    col_off1 = curwin_col_off();\n    col_off2 = col_off1 - curwin_col_off2();\n    width1 = curwin->w_width - col_off1;\n    width2 = curwin->w_width - col_off2;\n    if (width2 == 0)\n\twidth2 = 1; \/\/ avoid divide by zero\n\n    if (curwin->w_width != 0)\n    {\n      \/\/ Instead of sticking at the last character of the buffer line we\n      \/\/ try to stick in the last column of the screen.\n      if (curwin->w_curswant == MAXCOL)\n      {\n\tatend = TRUE;\n\tvalidate_virtcol();\n\tif (width1 <= 0)\n\t    curwin->w_curswant = 0;\n\telse\n\t{\n\t    curwin->w_curswant = width1 - 1;\n\t    if (curwin->w_virtcol > curwin->w_curswant)\n\t\tcurwin->w_curswant += ((curwin->w_virtcol\n\t\t\t     - curwin->w_curswant - 1) \/ width2 + 1) * width2;\n\t}\n      }\n      else\n      {\n\tif (linelen > width1)\n\t    n = ((linelen - width1 - 1) \/ width2 + 1) * width2 + width1;\n\telse\n\t    n = width1;\n\tif (curwin->w_curswant >= (colnr_T)n)\n\t    curwin->w_curswant = n - 1;\n      }\n\n      while (dist--)\n      {\n\tif (dir == BACKWARD)\n\t{\n\t    if ((long)curwin->w_curswant >= width1\n#ifdef FEAT_FOLDING\n\t\t    && !hasFolding(curwin->w_cursor.lnum, NULL, NULL)\n#endif\n\t       )\n\t\t\/\/ Move back within the line. This can give a negative value\n\t\t\/\/ for w_curswant if width1 < width2 (with cpoptions+=n),\n\t\t\/\/ which will get clipped to column 0.\n\t\tcurwin->w_curswant -= width2;\n\t    else\n\t    {\n\t\t\/\/ to previous line\n#ifdef FEAT_FOLDING\n\t\t\/\/ Move to the start of a closed fold.  Don't do that when\n\t\t\/\/ 'foldopen' contains \"all\": it will open in a moment.\n\t\tif (!(fdo_flags & FDO_ALL))\n\t\t    (void)hasFolding(curwin->w_cursor.lnum,\n\t\t\t\t\t\t&curwin->w_cursor.lnum, NULL);\n#endif\n\t\tif (curwin->w_cursor.lnum == 1)\n\t\t{\n\t\t    retval = FAIL;\n\t\t    break;\n\t\t}\n\t\t--curwin->w_cursor.lnum;\n\n\t\tlinelen = linetabsize(ml_get_curline());\n\t\tif (linelen > width1)\n\t\t    curwin->w_curswant += (((linelen - width1 - 1) \/ width2)\n\t\t\t\t\t\t\t\t+ 1) * width2;\n\t    }\n\t}\n\telse \/\/ dir == FORWARD\n\t{\n\t    if (linelen > width1)\n\t\tn = ((linelen - width1 - 1) \/ width2 + 1) * width2 + width1;\n\t    else\n\t\tn = width1;\n\t    if (curwin->w_curswant + width2 < (colnr_T)n\n#ifdef FEAT_FOLDING\n\t\t    && !hasFolding(curwin->w_cursor.lnum, NULL, NULL)\n#endif\n\t\t    )\n\t\t\/\/ move forward within line\n\t\tcurwin->w_curswant += width2;\n\t    else\n\t    {\n\t\t\/\/ to next line\n#ifdef FEAT_FOLDING\n\t\t\/\/ Move to the end of a closed fold.\n\t\t(void)hasFolding(curwin->w_cursor.lnum, NULL,\n\t\t\t\t\t\t      &curwin->w_cursor.lnum);\n#endif\n\t\tif (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)\n\t\t{\n\t\t    retval = FAIL;\n\t\t    break;\n\t\t}\n\t\tcurwin->w_cursor.lnum++;\n\t\tcurwin->w_curswant %= width2;\n\t\t\/\/ Check if the cursor has moved below the number display\n\t\t\/\/ when width1 < width2 (with cpoptions+=n). Subtract width2\n\t\t\/\/ to get a negative value for w_curswant, which will get\n\t\t\/\/ clipped to column 0.\n\t\tif (curwin->w_curswant >= width1)\n\t\t    curwin->w_curswant -= width2;\n\t\tlinelen = linetabsize(ml_get_curline());\n\t    }\n\t}\n      }\n    }\n\n    if (virtual_active() && atend)\n\tcoladvance(MAXCOL);\n    else\n\tcoladvance(curwin->w_curswant);\n\n    if (curwin->w_cursor.col > 0 && curwin->w_p_wrap)\n    {\n\tcolnr_T virtcol;\n\tint\tc;\n\n\t\/\/ Check for landing on a character that got split at the end of the\n\t\/\/ last line.  We want to advance a screenline, not end up in the same\n\t\/\/ screenline or move two screenlines.\n\tvalidate_virtcol();\n\tvirtcol = curwin->w_virtcol;\n#if defined(FEAT_LINEBREAK)\n\tif (virtcol > (colnr_T)width1 && *get_showbreak_value(curwin) != NUL)\n\t    virtcol -= vim_strsize(get_showbreak_value(curwin));\n#endif\n\n\tc = (*mb_ptr2char)(ml_get_cursor());\n\tif (dir == FORWARD && virtcol < curwin->w_curswant\n\t\t&& (curwin->w_curswant <= (colnr_T)width1)\n\t\t&& !vim_isprintc(c) && c > 255)\n\t    oneright();\n\n\tif (virtcol > curwin->w_curswant\n\t\t&& (curwin->w_curswant < (colnr_T)width1\n\t\t    ? (curwin->w_curswant > (colnr_T)width1 \/ 2)\n\t\t    : ((curwin->w_curswant - width1) % width2\n\t\t\t\t\t\t      > (colnr_T)width2 \/ 2)))\n\t    --curwin->w_cursor.col;\n    }\n\n    if (atend)\n\tcurwin->w_curswant = MAXCOL;\t    \/\/ stick in the last column\n\n    return retval;\n}","target":0,"code_token_length":1512,"total_token_length":1748,"max_tokens_setting":2048}
+{"idx":384878,"func":"dos_expandpath(\n    garray_T\t*gap,\n    char_u\t*path,\n    int\t\twildoff,\n    int\t\tflags,\t\t\/\/ EW_* flags\n    int\t\tdidstar)\t\/\/ expanded \"**\" once already\n{\n    char_u\t*buf;\n    char_u\t*path_end;\n    char_u\t*p, *s, *e;\n    int\t\tstart_len = gap->ga_len;\n    char_u\t*pat;\n    regmatch_T\tregmatch;\n    int\t\tstarts_with_dot;\n    int\t\tmatches;\n    int\t\tlen;\n    int\t\tstarstar = FALSE;\n    static int\tstardepth = 0;\t    \/\/ depth for \"**\" expansion\n    HANDLE\t\thFind = INVALID_HANDLE_VALUE;\n    WIN32_FIND_DATAW    wfb;\n    WCHAR\t\t*wn = NULL;\t\/\/ UCS-2 name, NULL when not used.\n    char_u\t\t*matchname;\n    int\t\t\tok;\n    char_u\t\t*p_alt;\n\n    \/\/ Expanding \"**\" may take a long time, check for CTRL-C.\n    if (stardepth > 0)\n    {\n\tui_breakcheck();\n\tif (got_int)\n\t    return 0;\n    }\n\n    \/\/ Make room for file name.  When doing encoding conversion the actual\n    \/\/ length may be quite a bit longer, thus use the maximum possible length.\n    buf = alloc(MAXPATHL);\n    if (buf == NULL)\n\treturn 0;\n\n    \/*\n     * Find the first part in the path name that contains a wildcard or a ~1.\n     * Copy it into buf, including the preceding characters.\n     *\/\n    p = buf;\n    s = buf;\n    e = NULL;\n    path_end = path;\n    while (*path_end != NUL)\n    {\n\t\/\/ May ignore a wildcard that has a backslash before it; it will\n\t\/\/ be removed by rem_backslash() or file_pat_to_reg_pat() below.\n\tif (path_end >= path + wildoff && rem_backslash(path_end))\n\t    *p++ = *path_end++;\n\telse if (*path_end == '\\\\' || *path_end == ':' || *path_end == '\/')\n\t{\n\t    if (e != NULL)\n\t\tbreak;\n\t    s = p + 1;\n\t}\n\telse if (path_end >= path + wildoff\n\t\t\t && vim_strchr((char_u *)\"*?[~\", *path_end) != NULL)\n\t    e = p;\n\tif (has_mbyte)\n\t{\n\t    len = (*mb_ptr2len)(path_end);\n\t    STRNCPY(p, path_end, len);\n\t    p += len;\n\t    path_end += len;\n\t}\n\telse\n\t    *p++ = *path_end++;\n    }\n    e = p;\n    *e = NUL;\n\n    \/\/ now we have one wildcard component between s and e\n    \/\/ Remove backslashes between \"wildoff\" and the start of the wildcard\n    \/\/ component.\n    for (p = buf + wildoff; p < s; ++p)\n\tif (rem_backslash(p))\n\t{\n\t    STRMOVE(p, p + 1);\n\t    --e;\n\t    --s;\n\t}\n\n    \/\/ Check for \"**\" between \"s\" and \"e\".\n    for (p = s; p < e; ++p)\n\tif (p[0] == '*' && p[1] == '*')\n\t    starstar = TRUE;\n\n    starts_with_dot = *s == '.';\n    pat = file_pat_to_reg_pat(s, e, NULL, FALSE);\n    if (pat == NULL)\n    {\n\tvim_free(buf);\n\treturn 0;\n    }\n\n    \/\/ compile the regexp into a program\n    if (flags & (EW_NOERROR | EW_NOTWILD))\n\t++emsg_silent;\n    regmatch.rm_ic = TRUE;\t\t\/\/ Always ignore case\n    regmatch.regprog = vim_regcomp(pat, RE_MAGIC);\n    if (flags & (EW_NOERROR | EW_NOTWILD))\n\t--emsg_silent;\n    vim_free(pat);\n\n    if (regmatch.regprog == NULL && (flags & EW_NOTWILD) == 0)\n    {\n\tvim_free(buf);\n\treturn 0;\n    }\n\n    \/\/ remember the pattern or file name being looked for\n    matchname = vim_strsave(s);\n\n    \/\/ If \"**\" is by itself, this is the first time we encounter it and more\n    \/\/ is following then find matches without any directory.\n    if (!didstar && stardepth < 100 && starstar && e - s == 2\n\t\t\t\t\t\t\t  && *path_end == '\/')\n    {\n\tSTRCPY(s, path_end + 1);\n\t++stardepth;\n\t(void)dos_expandpath(gap, buf, (int)(s - buf), flags, TRUE);\n\t--stardepth;\n    }\n\n    \/\/ Scan all files in the directory with \"dir\/ *.*\"\n    STRCPY(s, \"*.*\");\n    wn = enc_to_utf16(buf, NULL);\n    if (wn != NULL)\n\thFind = FindFirstFileW(wn, &wfb);\n    ok = (hFind != INVALID_HANDLE_VALUE);\n\n    while (ok)\n    {\n\tp = utf16_to_enc(wfb.cFileName, NULL);   \/\/ p is allocated here\n\n\tif (p == NULL)\n\t    break;  \/\/ out of memory\n\n\t\/\/ Do not use the alternate filename when the file name ends in '~',\n\t\/\/ because it picks up backup files: short name for \"foo.vim~\" is\n\t\/\/ \"foo~1.vim\", which matches \"*.vim\".\n\tif (*wfb.cAlternateFileName == NUL || p[STRLEN(p) - 1] == '~')\n\t    p_alt = NULL;\n\telse\n\t    p_alt = utf16_to_enc(wfb.cAlternateFileName, NULL);\n\n\t\/\/ Ignore entries starting with a dot, unless when asked for.  Accept\n\t\/\/ all entries found with \"matchname\".\n\tif ((p[0] != '.' || starts_with_dot\n\t\t\t || ((flags & EW_DODOT)\n\t\t\t     && p[1] != NUL && (p[1] != '.' || p[2] != NUL)))\n\t\t&& (matchname == NULL\n\t\t  || (regmatch.regprog != NULL\n\t\t      && (vim_regexec(®match, p, (colnr_T)0)\n\t\t\t || (p_alt != NULL\n\t\t\t\t&& vim_regexec(®match, p_alt, (colnr_T)0))))\n\t\t  || ((flags & EW_NOTWILD)\n\t\t     && fnamencmp(path + (s - buf), p, e - s) == 0)))\n\t{\n\t    STRCPY(s, p);\n\t    len = (int)STRLEN(buf);\n\n\t    if (starstar && stardepth < 100\n\t\t\t  && (wfb.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))\n\t    {\n\t\t\/\/ For \"**\" in the pattern first go deeper in the tree to\n\t\t\/\/ find matches.\n\t\tSTRCPY(buf + len, \"\/**\");\n\t\tSTRCPY(buf + len + 3, path_end);\n\t\t++stardepth;\n\t\t(void)dos_expandpath(gap, buf, len + 1, flags, TRUE);\n\t\t--stardepth;\n\t    }\n\n\t    STRCPY(buf + len, path_end);\n\t    if (mch_has_exp_wildcard(path_end))\n\t    {\n\t\t\/\/ need to expand another component of the path\n\t\t\/\/ remove backslashes for the remaining components only\n\t\t(void)dos_expandpath(gap, buf, len + 1, flags, FALSE);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ no more wildcards, check if there is a match\n\t\t\/\/ remove backslashes for the remaining components only\n\t\tif (*path_end != 0)\n\t\t    backslash_halve(buf + len + 1);\n\t\tif (mch_getperm(buf) >= 0)\t\/\/ add existing file\n\t\t    addfile(gap, buf, flags);\n\t    }\n\t}\n\n\tvim_free(p_alt);\n\tvim_free(p);\n\tok = FindNextFileW(hFind, &wfb);\n    }\n\n    FindClose(hFind);\n    vim_free(wn);\n    vim_free(buf);\n    vim_regfree(regmatch.regprog);\n    vim_free(matchname);\n\n    matches = gap->ga_len - start_len;\n    if (matches > 0)\n\tqsort(((char_u **)gap->ga_data) + start_len, (size_t)matches,\n\t\t\t\t\t\t   sizeof(char_u *), pstrcmp);\n    return matches;\n}","target":0,"code_token_length":1804,"total_token_length":2040,"max_tokens_setting":2048}
+{"idx":218979,"func":"Status ConstantFolding::MaterializeReductionIndices(\n    NodeDef* node, const GraphProperties& properties) {\n  if (node->input_size() < 2) {\n    return Status::OK();\n  }\n  const NodeDef* indices = node_map_->GetNode(node->input(1));\n  if (!indices || IsReallyConstant(*indices)) {\n    \/\/ The reduction indices are already constant, there's nothing to do.\n    return Status::OK();\n  }\n\n  const std::vector<OpInfo::TensorProperties>& input_props =\n      properties.GetInputProperties(node->name());\n  if (input_props.size() != 2) {\n    return Status::OK();\n  }\n  const OpInfo::TensorProperties& input_prop = input_props[0];\n  if (input_prop.shape().unknown_rank()) {\n    \/\/ We can't do anything if we don't know the rank of the input.\n    return Status::OK();\n  }\n  const int input_rank = input_prop.shape().dim_size();\n  if (input_rank < 1) {\n    \/\/ Unexpected graph, don't try to change it.\n    return Status::OK();\n  }\n  const OpInfo::TensorProperties& reduction_indices_prop = input_props[1];\n  DataType dtype = reduction_indices_prop.dtype();\n  if (dtype != DT_INT32 && dtype != DT_INT64) {\n    return Status::OK();\n  }\n  PartialTensorShape reduction_indices_shape(reduction_indices_prop.shape());\n  const int num_reduction_indices = reduction_indices_shape.num_elements();\n\n  const std::vector<OpInfo::TensorProperties>& output_props =\n      properties.GetOutputProperties(node->name());\n  if (output_props.size() != 1) {\n    return Status::OK();\n  }\n  const OpInfo::TensorProperties& output_prop = output_props[0];\n  const int output_rank =\n      output_prop.shape().unknown_rank() ? -1 : output_prop.shape().dim_size();\n\n  bool full_reduction = output_rank == 0 || num_reduction_indices == input_rank;\n  if (!full_reduction) {\n    \/\/ A full reduction will generate a tensor of one of the shapes\n    \/\/ [], [1], [1, 1], [1, 1, ...]. Even if we do not know the number of\n    \/\/ elements in the output of the reduction, we may deduce it from reshape\n    \/\/ nodes following it.\n    for (const NodeDef* fanout : node_map_->GetOutputs(node->name())) {\n      full_reduction = false;\n      if (!IsReshape(*fanout)) {\n        return Status::OK();\n      }\n      const std::vector<OpInfo::TensorProperties>& reshape_props =\n          properties.GetOutputProperties(fanout->name());\n      if (reshape_props.size() != 1) {\n        return Status::OK();\n      }\n      const OpInfo::TensorProperties& reshape_prop = reshape_props[0];\n      PartialTensorShape shape(reshape_prop.shape());\n      if (shape.num_elements() != 1) {\n        return Status::OK();\n      } else {\n        full_reduction = true;\n      }\n    }\n    if (!full_reduction) {\n      return Status::OK();\n    }\n  }\n\n  \/\/ We know it's a full reduction. We can generate the full set of indices to\n  \/\/ reduce as a constant node.\n  string const_name = OptimizedNodeName(*node, \"-reduction_indices\");\n  if (node_map_->GetNode(const_name)) {\n    return Status::OK();\n  }\n  NodeDef* reduction_indices = graph_->add_node();\n  Tensor value(dtype, TensorShape({input_rank}));\n  for (int i = 0; i < input_rank; ++i) {\n    if (dtype == DT_INT32) {\n      value.vec<int32>()(i) = i;\n    } else {\n      value.vec<int64_t>()(i) = i;\n    }\n  }\n  TF_RETURN_IF_ERROR(\n      CreateNodeDef(const_name, TensorValue(&value), reduction_indices));\n\n  reduction_indices->set_device(node->device());\n  string ctrl_dep =\n      AddControlDependency(node->input(1), graph_, node_map_.get());\n  *reduction_indices->add_input() = ctrl_dep;\n  node_map_->AddNode(const_name, reduction_indices);\n  node_map_->AddOutput(NodeName(ctrl_dep), const_name);\n\n  node->set_input(1, reduction_indices->name());\n  node_map_->UpdateInput(node->name(), indices->name(),\n                         reduction_indices->name());\n\n  return Status::OK();\n}","target":0,"code_token_length":945,"total_token_length":1181,"max_tokens_setting":2048}
+{"idx":369257,"func":"\nstatic int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tconst struct cred *creds = NULL;\n\tint ret;\n\n\tif (unlikely(!io_assign_file(req, issue_flags)))\n\t\treturn -EBADF;\n\n\tif (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred()))\n\t\tcreds = override_creds(req->creds);\n\n\tif (!io_op_defs[req->opcode].audit_skip)\n\t\taudit_uring_entry(req->opcode);\n\n\tswitch (req->opcode) {\n\tcase IORING_OP_NOP:\n\t\tret = io_nop(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_READV:\n\tcase IORING_OP_READ_FIXED:\n\tcase IORING_OP_READ:\n\t\tret = io_read(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_WRITEV:\n\tcase IORING_OP_WRITE_FIXED:\n\tcase IORING_OP_WRITE:\n\t\tret = io_write(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_FSYNC:\n\t\tret = io_fsync(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_POLL_ADD:\n\t\tret = io_poll_add(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_POLL_REMOVE:\n\t\tret = io_poll_update(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_SYNC_FILE_RANGE:\n\t\tret = io_sync_file_range(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_SENDMSG:\n\t\tret = io_sendmsg(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_SEND:\n\t\tret = io_send(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_RECVMSG:\n\t\tret = io_recvmsg(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_RECV:\n\t\tret = io_recv(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_TIMEOUT:\n\t\tret = io_timeout(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_TIMEOUT_REMOVE:\n\t\tret = io_timeout_remove(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_ACCEPT:\n\t\tret = io_accept(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_CONNECT:\n\t\tret = io_connect(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_ASYNC_CANCEL:\n\t\tret = io_async_cancel(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_FALLOCATE:\n\t\tret = io_fallocate(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_OPENAT:\n\t\tret = io_openat(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_CLOSE:\n\t\tret = io_close(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_FILES_UPDATE:\n\t\tret = io_files_update(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_STATX:\n\t\tret = io_statx(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_FADVISE:\n\t\tret = io_fadvise(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_MADVISE:\n\t\tret = io_madvise(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_OPENAT2:\n\t\tret = io_openat2(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_EPOLL_CTL:\n\t\tret = io_epoll_ctl(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_SPLICE:\n\t\tret = io_splice(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_PROVIDE_BUFFERS:\n\t\tret = io_provide_buffers(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_REMOVE_BUFFERS:\n\t\tret = io_remove_buffers(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_TEE:\n\t\tret = io_tee(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_SHUTDOWN:\n\t\tret = io_shutdown(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_RENAMEAT:\n\t\tret = io_renameat(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_UNLINKAT:\n\t\tret = io_unlinkat(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_MKDIRAT:\n\t\tret = io_mkdirat(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_SYMLINKAT:\n\t\tret = io_symlinkat(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_LINKAT:\n\t\tret = io_linkat(req, issue_flags);\n\t\tbreak;\n\tcase IORING_OP_MSG_RING:\n\t\tret = io_msg_ring(req, issue_flags);\n\t\tbreak;\n\tdefault:\n\t\tret = -EINVAL;\n\t\tbreak;\n\t}\n\n\tif (!io_op_defs[req->opcode].audit_skip)\n\t\taudit_uring_exit(!ret, ret);\n\n\tif (creds)\n\t\trevert_creds(creds);\n\tif (ret)\n\t\treturn ret;\n\t\/* If the op doesn't have a file, we're not polling for it *\/\n\tif ((req->ctx->flags & IORING_SETUP_IOPOLL) && req->file)\n\t\tio_iopoll_req_issued(req, issue_flags);\n\n\treturn 0;","target":0,"code_token_length":1056,"total_token_length":1292,"max_tokens_setting":2048}
+{"idx":402606,"func":"daemonize(cms_context *cms_ctx, char *certdir, int do_fork)\n{\n\tint rc = 0;\n\tcontext ctx = {\n\t\t.backup_cms = cms_ctx,\n\t\t.priority = do_fork ? LOG_PID\n\t\t\t\t    : LOG_PID|LOG_PERROR,\n\t};\n\n\tctx.backup_cms = cms_ctx;\n\tctx.backup_cms->log_priv = &ctx;\n\tctx.sd = -1;\n\n\tif (getuid() != 0) {\n\t\tfprintf(stderr, \"pesignd must be started as root\");\n\t\texit(1);\n\t}\n\n\tcheck_socket(&ctx);\n\n\topenlog(\"pesignd\", LOG_PID, LOG_DAEMON);\n\n\tif (do_fork) {\n\t\tpid_t pid;\n\n\t\tif ((pid = fork())) {\n\t\t\tsleep(2);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tctx.pid = getpid();\n\twrite_pid_file(ctx.pid);\n\tctx.backup_cms->log(ctx.backup_cms, ctx.priority|LOG_NOTICE,\n\t\t\"pesignd starting (pid %d)\", ctx.pid);\n\tdaemon_logger(ctx.backup_cms, ctx.priority|LOG_NOTICE,\n\t\t\"pesignd starting (pid %d)\", ctx.pid);\n\n\tSECStatus status = NSS_Init(certdir);\n\tint error = errno;\n\tif (status != SECSuccess) {\n\t\tchar *globpattern = NULL;\n\t\trc = asprintf(&globpattern, \"%s\/cert*.db\",\n\t\t\t      certdir);\n\t\tif (rc > 0) {\n\t\t\tglob_t globbuf;\n\t\t\tmemset(&globbuf, 0, sizeof(globbuf));\n\t\t\trc = glob(globpattern, GLOB_ERR, NULL,\n\t\t\t\t  &globbuf);\n\t\t\tif (rc != 0) {\n\t\t\t\terrno = error;\n\t\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\t\tctx.priority|LOG_NOTICE,\n\t\t\t\t\t\"Could not open NSS database (\\\"%s\\\"): %m\",\n\t\t\t\t\tPORT_ErrorToString(PORT_GetError()));\n\t\t\t\texit(1);\n\t\t\t}\n\t\t}\n\t}\n\tif (status != SECSuccess) {\n\t\terrno = error;\n\t\tctx.backup_cms->log(ctx.backup_cms, ctx.priority|LOG_NOTICE,\n\t\t\t\t    \"Could not initialize nss.\\n\"\n\t\t\t\t    \"NSS says \\\"%s\\\" errno says \\\"%m\\\"\\n\",\n\t\t\t\t    PORT_ErrorToString(PORT_GetError()));\n\t\texit(1);\n\t}\n\n\tstatus = register_oids(ctx.backup_cms);\n\tif (status != SECSuccess) {\n\t\tctx.backup_cms->log(ctx.backup_cms, ctx.priority|LOG_NOTICE,\n\t\t\t\"Could not register OIDs\\n\");\n\t\texit(1);\n\t}\n\n\tif (do_fork) {\n\t\tint fd = open(\"\/dev\/zero\", O_RDONLY);\n\t\tif (fd < 0) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\t\"could not open \/dev\/zero: %m\");\n\t\t\texit(1);\n\t\t}\n\t\tclose(STDIN_FILENO);\n\t\trc = dup2(fd, STDIN_FILENO);\n\t\tif (rc < 0) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\"could not set up standard input: %m\");\n\t\t\texit(1);\n\t\t}\n\t\tclose(fd);\n\n\t\tfd = open(\"\/dev\/null\", O_WRONLY);\n\t\tif (fd < 0) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\t\"could not open \/dev\/null: %m\");\n\t\t\texit(1);\n\t\t}\n\t\tclose(STDOUT_FILENO);\n\t\trc = dup2(fd, STDOUT_FILENO);\n\t\tif (rc < 0) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\"could not set up standard output: %m\");\n\t\t\texit(1);\n\t\t}\n\n\t\tclose(STDERR_FILENO);\n\t\trc = dup2(fd, STDERR_FILENO);\n\t\tif (rc < 0) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\"could not set up standard error: %m\");\n\t\t\texit(1);\n\t\t}\n\t\tclose(fd);\n\t}\n\n\tprctl(PR_SET_NAME, \"pesignd\", 0, 0, 0);\n\n\tsetsid();\n\n\tif (do_fork) {\n\t\tstruct sigaction sa = {\n\t\t\t.sa_handler = quit_handler,\n\t\t};\n\t\tsigaction(SIGQUIT, &sa, NULL);\n\t\tsigaction(SIGINT, &sa, NULL);\n\t\tsigaction(SIGTERM, &sa, NULL);\n\t}\n\n\tchar *homedir = NULL;\n\n\trc = get_uid_and_gid(&ctx, &homedir);\n\tif (rc < 0) {\n\t\tctx.backup_cms->log(ctx.backup_cms, ctx.priority|LOG_ERR,\n\t\t\t\"could not get group and user information \"\n\t\t\t\"for pesign: %m\");\n\t\texit(1);\n\t}\n\n\tchdir(homedir ? homedir : \"\/\");\n\n\tif (getuid() == 0) {\n\t\t\/* process is running as root, drop privileges *\/\n\t\tif (setgid(ctx.gid) != 0 || setgroups(0, NULL)) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\"unable to drop group privileges: %m\");\n\t\t\texit(1);\n\t\t}\n\t\tif (setuid(ctx.uid) != 0) {\n\t\t\tctx.backup_cms->log(ctx.backup_cms,\n\t\t\t\tctx.priority|LOG_ERR,\n\t\t\t\t\"unable to drop user privileges: %m\");\n\t\t\texit(1);\n\t\t}\n\t}\n\n\tset_up_socket(&ctx);\n\n\tcms_set_pw_callback(ctx.backup_cms, get_password_fail);\n\tcms_set_pw_data(ctx.backup_cms, NULL);\n\tif (do_fork)\n\t\tctx.backup_cms->log = daemon_logger;\n\n\trc = handle_events(&ctx);\n\n\tstatus = NSS_Shutdown();\n\tif (status != SECSuccess) {\n\t\tctx.backup_cms->log(ctx.backup_cms, ctx.priority|LOG_ERR,\n\t\t\t\"NSS_Shutdown failed: %s\\n\",\n\t\t\tPORT_ErrorToString(PORT_GetError()));\n\t\texit(1);\n\t}\n\treturn rc;\n}","target":0,"code_token_length":1307,"total_token_length":1543,"max_tokens_setting":2048}
+{"idx":197015,"func":"GF_Err SetupWriters(MovieWriter *mw, GF_List *writers, u8 interleaving)\n{\n\tu32 i, trackCount;\n\tTrackWriter *writer;\n\tGF_TrackBox *trak;\n\tGF_ISOFile *movie = mw->movie;\n\n\tmw->total_samples = mw->nb_done = 0;\n\tif (!movie->moov) return GF_OK;\n\n\ttrackCount = gf_list_count(movie->moov->trackList);\n\tfor (i = 0; i < trackCount; i++) {\n\t\ttrak = gf_isom_get_track(movie->moov, i+1);\n\n\t\tGF_SAFEALLOC(writer, TrackWriter);\n\t\tif (!writer) goto exit;\n\t\twriter->sampleNumber = 1;\n\t\twriter->mdia = trak->Media;\n\t\twriter->stbl = trak->Media->information->sampleTable;\n\t\twriter->timeScale = trak->Media->mediaHeader->timeScale;\n\t\twriter->all_dref_mode = Media_SelfContainedType(writer->mdia);\n\n\t\tif (trak->sample_encryption)\n\t\t\twriter->prevent_dispatch = GF_TRUE;\n\n\t\twriter->isDone = 0;\n\t\twriter->DTSprev = 0;\n\t\twriter->chunkDur = 0;\n\t\twriter->chunkSize = 0;\n\t\twriter->constant_size = writer->constant_dur = 0;\n\t\tif (writer->stbl->SampleSize->sampleSize)\n\t\t\twriter->constant_size = writer->stbl->SampleSize->sampleSize;\n\t\tif (writer->stbl->TimeToSample->nb_entries==1) {\n\t\t\twriter->constant_dur = writer->stbl->TimeToSample->entries[0].sampleDelta;\n\t\t\tif (writer->constant_dur>1) writer->constant_dur = 0;\n\t\t}\n\t\tif (!writer->constant_dur || !writer->constant_size || (writer->constant_size>=10))\n\t\t\twriter->constant_size = writer->constant_dur = 0;\n\n\t\twriter->stsc = (GF_SampleToChunkBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STSC);\n\t\tif (!writer->stsc) return GF_OUT_OF_MEM;\n\t\tif (writer->stbl->ChunkOffset->type == GF_ISOM_BOX_TYPE_STCO) {\n\t\t\twriter->stco = gf_isom_box_new(GF_ISOM_BOX_TYPE_STCO);\n\t\t} else {\n\t\t\twriter->stco = gf_isom_box_new(GF_ISOM_BOX_TYPE_CO64);\n\t\t}\n\t\tif (!writer->stco) return GF_OUT_OF_MEM;\n\t\t\/*stops from chunk escape*\/\n\t\tif (interleaving) writer->stbl->MaxSamplePerChunk = 0;\n\t\t\/*for progress, assume only one descIndex*\/\n\t\tif (Media_IsSelfContained(writer->mdia, 1))\n\t\t\tmw->total_samples += writer->stbl->SampleSize->sampleCount;\n\t\t\/*optimization for interleaving: put audio last (this can be overridden by priorities)*\/\n\t\tif (movie->storageMode != GF_ISOM_STORE_INTERLEAVED) {\n\t\t\tgf_list_add(writers, writer);\n\t\t} else {\n\t\t\tif (writer->mdia->information->InfoHeader && writer->mdia->information->InfoHeader->type == GF_ISOM_BOX_TYPE_SMHD) {\n\t\t\t\tgf_list_add(writers, writer);\n\t\t\t} else {\n\t\t\t\tgf_list_insert(writers, writer, 0);\n\t\t\t}\n\t\t}\n\t\tif (movie->sample_groups_in_traf && trak->Media->information->sampleTable) {\n\t\t\tgf_isom_box_array_del_parent(&trak->Media->information->sampleTable->child_boxes, trak->Media->information->sampleTable->sampleGroupsDescription);\n\t\t\ttrak->Media->information->sampleTable->sampleGroupsDescription = NULL;\n\t\t}\n\t}\n\treturn GF_OK;\n\nexit:\n\tCleanWriters(writers);\n\treturn GF_OUT_OF_MEM;\n}","target":1,"code_token_length":835,"total_token_length":1071,"max_tokens_setting":2048}
+{"idx":211650,"func":"dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)\n{\n\tstruct dev_data\t\t*dev = fd->private_data;\n\tssize_t\t\t\tvalue, length = len;\n\tunsigned\t\ttotal;\n\tu32\t\t\ttag;\n\tchar\t\t\t*kbuf;\n\n\tspin_lock_irq(&dev->lock);\n\tif (dev->state > STATE_DEV_OPENED) {\n\t\tvalue = ep0_write(fd, buf, len, ptr);\n\t\tspin_unlock_irq(&dev->lock);\n\t\treturn value;\n\t}\n\tspin_unlock_irq(&dev->lock);\n\n\tif ((len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) ||\n\t    (len > PAGE_SIZE * 4))\n\t\treturn -EINVAL;\n\n\t\/* we might need to change message format someday *\/\n\tif (copy_from_user (&tag, buf, 4))\n\t\treturn -EFAULT;\n\tif (tag != 0)\n\t\treturn -EINVAL;\n\tbuf += 4;\n\tlength -= 4;\n\n\tkbuf = memdup_user(buf, length);\n\tif (IS_ERR(kbuf))\n\t\treturn PTR_ERR(kbuf);\n\n\tspin_lock_irq (&dev->lock);\n\tvalue = -EINVAL;\n\tif (dev->buf) {\n\t\tkfree(kbuf);\n\t\tgoto fail;\n\t}\n\tdev->buf = kbuf;\n\n\t\/* full or low speed config *\/\n\tdev->config = (void *) kbuf;\n\ttotal = le16_to_cpu(dev->config->wTotalLength);\n\tif (!is_valid_config(dev->config, total) ||\n\t\t\ttotal > length - USB_DT_DEVICE_SIZE)\n\t\tgoto fail;\n\tkbuf += total;\n\tlength -= total;\n\n\t\/* optional high speed config *\/\n\tif (kbuf [1] == USB_DT_CONFIG) {\n\t\tdev->hs_config = (void *) kbuf;\n\t\ttotal = le16_to_cpu(dev->hs_config->wTotalLength);\n\t\tif (!is_valid_config(dev->hs_config, total) ||\n\t\t\t\ttotal > length - USB_DT_DEVICE_SIZE)\n\t\t\tgoto fail;\n\t\tkbuf += total;\n\t\tlength -= total;\n\t} else {\n\t\tdev->hs_config = NULL;\n\t}\n\n\t\/* could support multiple configs, using another encoding! *\/\n\n\t\/* device descriptor (tweaked for paranoia) *\/\n\tif (length != USB_DT_DEVICE_SIZE)\n\t\tgoto fail;\n\tdev->dev = (void *)kbuf;\n\tif (dev->dev->bLength != USB_DT_DEVICE_SIZE\n\t\t\t|| dev->dev->bDescriptorType != USB_DT_DEVICE\n\t\t\t|| dev->dev->bNumConfigurations != 1)\n\t\tgoto fail;\n\tdev->dev->bcdUSB = cpu_to_le16 (0x0200);\n\n\t\/* triggers gadgetfs_bind(); then we can enumerate. *\/\n\tspin_unlock_irq (&dev->lock);\n\tif (dev->hs_config)\n\t\tgadgetfs_driver.max_speed = USB_SPEED_HIGH;\n\telse\n\t\tgadgetfs_driver.max_speed = USB_SPEED_FULL;\n\n\tvalue = usb_gadget_probe_driver(&gadgetfs_driver);\n\tif (value != 0) {\n\t\tkfree (dev->buf);\n\t\tdev->buf = NULL;\n\t} else {\n\t\t\/* at this point \"good\" hardware has for the first time\n\t\t * let the USB the host see us.  alternatively, if users\n\t\t * unplug\/replug that will clear all the error state.\n\t\t *\n\t\t * note:  everything running before here was guaranteed\n\t\t * to choke driver model style diagnostics.  from here\n\t\t * on, they can work ... except in cleanup paths that\n\t\t * kick in after the ep0 descriptor is closed.\n\t\t *\/\n\t\tvalue = len;\n\t\tdev->gadget_registered = true;\n\t}\n\treturn value;\n\nfail:\n\tspin_unlock_irq (&dev->lock);\n\tpr_debug (\"%s: %s fail %zd, %p\\n\", shortname, __func__, value, dev);\n\tkfree (dev->buf);\n\tdev->buf = NULL;\n\treturn value;\n}","target":1,"code_token_length":818,"total_token_length":1054,"max_tokens_setting":2048}
+{"idx":283752,"func":"static void zynq_slcr_reset_init(Object *obj, ResetType type)\n{\n    ZynqSLCRState *s = ZYNQ_SLCR(obj);\n    int i;\n\n    DB_PRINT(\"RESET\\n\");\n\n    s->regs[R_LOCKSTA] = 1;\n    \/* 0x100 - 0x11C *\/\n    s->regs[R_ARM_PLL_CTRL]   = 0x0001A008;\n    s->regs[R_DDR_PLL_CTRL]   = 0x0001A008;\n    s->regs[R_IO_PLL_CTRL]    = 0x0001A008;\n    s->regs[R_PLL_STATUS]     = 0x0000003F;\n    s->regs[R_ARM_PLL_CFG]    = 0x00014000;\n    s->regs[R_DDR_PLL_CFG]    = 0x00014000;\n    s->regs[R_IO_PLL_CFG]     = 0x00014000;\n\n    \/* 0x120 - 0x16C *\/\n    s->regs[R_ARM_CLK_CTRL]   = 0x1F000400;\n    s->regs[R_DDR_CLK_CTRL]   = 0x18400003;\n    s->regs[R_DCI_CLK_CTRL]   = 0x01E03201;\n    s->regs[R_APER_CLK_CTRL]  = 0x01FFCCCD;\n    s->regs[R_USB0_CLK_CTRL]  = s->regs[R_USB1_CLK_CTRL]  = 0x00101941;\n    s->regs[R_GEM0_RCLK_CTRL] = s->regs[R_GEM1_RCLK_CTRL] = 0x00000001;\n    s->regs[R_GEM0_CLK_CTRL]  = s->regs[R_GEM1_CLK_CTRL]  = 0x00003C01;\n    s->regs[R_SMC_CLK_CTRL]   = 0x00003C01;\n    s->regs[R_LQSPI_CLK_CTRL] = 0x00002821;\n    s->regs[R_SDIO_CLK_CTRL]  = 0x00001E03;\n    s->regs[R_UART_CLK_CTRL]  = 0x00003F03;\n    s->regs[R_SPI_CLK_CTRL]   = 0x00003F03;\n    s->regs[R_CAN_CLK_CTRL]   = 0x00501903;\n    s->regs[R_DBG_CLK_CTRL]   = 0x00000F03;\n    s->regs[R_PCAP_CLK_CTRL]  = 0x00000F01;\n\n    \/* 0x170 - 0x1AC *\/\n    s->regs[R_FPGA0_CLK_CTRL] = s->regs[R_FPGA1_CLK_CTRL]\n                              = s->regs[R_FPGA2_CLK_CTRL]\n                              = s->regs[R_FPGA3_CLK_CTRL] = 0x00101800;\n    s->regs[R_FPGA0_THR_STA] = s->regs[R_FPGA1_THR_STA]\n                             = s->regs[R_FPGA2_THR_STA]\n                             = s->regs[R_FPGA3_THR_STA] = 0x00010000;\n\n    \/* 0x1B0 - 0x1D8 *\/\n    s->regs[R_BANDGAP_TRIP]   = 0x0000001F;\n    s->regs[R_PLL_PREDIVISOR] = 0x00000001;\n    s->regs[R_CLK_621_TRUE]   = 0x00000001;\n\n    \/* 0x200 - 0x25C *\/\n    s->regs[R_FPGA_RST_CTRL]  = 0x01F33F0F;\n    s->regs[R_RST_REASON]     = 0x00000040;\n\n    s->regs[R_BOOT_MODE]      = 0x00000001;\n\n    \/* 0x700 - 0x7D4 *\/\n    for (i = 0; i < 54; i++) {\n        s->regs[R_MIO + i] = 0x00001601;\n    }\n    for (i = 2; i <= 8; i++) {\n        s->regs[R_MIO + i] = 0x00000601;\n    }\n\n    s->regs[R_MIO_MST_TRI0] = s->regs[R_MIO_MST_TRI1] = 0xFFFFFFFF;\n\n    s->regs[R_CPU_RAM + 0] = s->regs[R_CPU_RAM + 1] = s->regs[R_CPU_RAM + 3]\n                           = s->regs[R_CPU_RAM + 4] = s->regs[R_CPU_RAM + 7]\n                           = 0x00010101;\n    s->regs[R_CPU_RAM + 2] = s->regs[R_CPU_RAM + 5] = 0x01010101;\n    s->regs[R_CPU_RAM + 6] = 0x00000001;\n\n    s->regs[R_IOU + 0] = s->regs[R_IOU + 1] = s->regs[R_IOU + 2]\n                       = s->regs[R_IOU + 3] = 0x09090909;\n    s->regs[R_IOU + 4] = s->regs[R_IOU + 5] = 0x00090909;\n    s->regs[R_IOU + 6] = 0x00000909;\n\n    s->regs[R_DMAC_RAM] = 0x00000009;\n\n    s->regs[R_AFI0 + 0] = s->regs[R_AFI0 + 1] = 0x09090909;\n    s->regs[R_AFI1 + 0] = s->regs[R_AFI1 + 1] = 0x09090909;\n    s->regs[R_AFI2 + 0] = s->regs[R_AFI2 + 1] = 0x09090909;\n    s->regs[R_AFI3 + 0] = s->regs[R_AFI3 + 1] = 0x09090909;\n    s->regs[R_AFI0 + 2] = s->regs[R_AFI1 + 2] = s->regs[R_AFI2 + 2]\n                        = s->regs[R_AFI3 + 2] = 0x00000909;\n\n    s->regs[R_OCM + 0] = 0x01010101;\n    s->regs[R_OCM + 1] = s->regs[R_OCM + 2] = 0x09090909;\n\n    s->regs[R_DEVCI_RAM] = 0x00000909;\n    s->regs[R_CSG_RAM]   = 0x00000001;\n\n    s->regs[R_DDRIOB + 0] = s->regs[R_DDRIOB + 1] = s->regs[R_DDRIOB + 2]\n                          = s->regs[R_DDRIOB + 3] = 0x00000e00;\n    s->regs[R_DDRIOB + 4] = s->regs[R_DDRIOB + 5] = s->regs[R_DDRIOB + 6]\n                          = 0x00000e00;\n    s->regs[R_DDRIOB + 12] = 0x00000021;\n}","target":0,"code_token_length":1800,"total_token_length":2036,"max_tokens_setting":2048}
+{"idx":318957,"func":"assert_equalfile(typval_T *argvars)\n{\n    char_u\tbuf1[NUMBUFLEN];\n    char_u\tbuf2[NUMBUFLEN];\n    int\t\tcalled_emsg_before = called_emsg;\n    char_u\t*fname1 = tv_get_string_buf_chk(&argvars[0], buf1);\n    char_u\t*fname2 = tv_get_string_buf_chk(&argvars[1], buf2);\n    garray_T\tga;\n    FILE\t*fd1;\n    FILE\t*fd2;\n    char\tline1[200];\n    char\tline2[200];\n    int\t\tlineidx = 0;\n\n    if (called_emsg > called_emsg_before)\n\treturn 0;\n\n    IObuff[0] = NUL;\n    fd1 = mch_fopen((char *)fname1, READBIN);\n    if (fd1 == NULL)\n    {\n\tvim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str, fname1);\n    }\n    else\n    {\n\tfd2 = mch_fopen((char *)fname2, READBIN);\n\tif (fd2 == NULL)\n\t{\n\t    fclose(fd1);\n\t    vim_snprintf((char *)IObuff, IOSIZE, (char *)e_cant_read_file_str, fname2);\n\t}\n\telse\n\t{\n\t    int\t    c1, c2;\n\t    long    count = 0;\n\t    long    linecount = 1;\n\n\t    for (;;)\n\t    {\n\t\tc1 = fgetc(fd1);\n\t\tc2 = fgetc(fd2);\n\t\tif (c1 == EOF)\n\t\t{\n\t\t    if (c2 != EOF)\n\t\t\tSTRCPY(IObuff, \"first file is shorter\");\n\t\t    break;\n\t\t}\n\t\telse if (c2 == EOF)\n\t\t{\n\t\t    STRCPY(IObuff, \"second file is shorter\");\n\t\t    break;\n\t\t}\n\t\telse\n\t\t{\n\t\t    line1[lineidx] = c1;\n\t\t    line2[lineidx] = c2;\n\t\t    ++lineidx;\n\t\t    if (c1 != c2)\n\t\t    {\n\t\t\tvim_snprintf((char *)IObuff, IOSIZE,\n\t\t\t\t\t    \"difference at byte %ld, line %ld\",\n\t\t\t\t\t\t\t     count, linecount);\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t\t++count;\n\t\tif (c1 == NL)\n\t\t{\n\t\t    ++linecount;\n\t\t    lineidx = 0;\n\t\t}\n\t\telse if (lineidx + 2 == (int)sizeof(line1))\n\t\t{\n\t\t    mch_memmove(line1, line1 + 100, lineidx - 100);\n\t\t    mch_memmove(line2, line2 + 100, lineidx - 100);\n\t\t    lineidx -= 100;\n\t\t}\n\t    }\n\t    fclose(fd1);\n\t    fclose(fd2);\n\t}\n    }\n    if (IObuff[0] != NUL)\n    {\n\tprepare_assert_error(&ga);\n\tif (argvars[2].v_type != VAR_UNKNOWN)\n\t{\n\t    char_u\tnumbuf[NUMBUFLEN];\n\t    char_u\t*tofree;\n\n\t    ga_concat(&ga, echo_string(&argvars[2], &tofree, numbuf, 0));\n\t    vim_free(tofree);\n\t    ga_concat(&ga, (char_u *)\": \");\n\t}\n\tga_concat(&ga, IObuff);\n\tif (lineidx > 0)\n\t{\n\t    line1[lineidx] = NUL;\n\t    line2[lineidx] = NUL;\n\t    ga_concat(&ga, (char_u *)\" after \\\"\");\n\t    ga_concat(&ga, (char_u *)line1);\n\t    if (STRCMP(line1, line2) != 0)\n\t    {\n\t\tga_concat(&ga, (char_u *)\"\\\" vs \\\"\");\n\t\tga_concat(&ga, (char_u *)line2);\n\t    }\n\t    ga_concat(&ga, (char_u *)\"\\\"\");\n\t}\n\tassert_error(&ga);\n\tga_clear(&ga);\n\treturn 1;\n    }\n    return 0;\n}","target":0,"code_token_length":860,"total_token_length":1096,"max_tokens_setting":2048}
+{"idx":225994,"func":"\nstatic GF_Err ctrn_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i, count, flags, first_idx=0;\n\tBool inherit_dur, inherit_size, inherit_flags, inherit_ctso;\n\tGF_TrunEntry *ent;\n\tGF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s;\n\tflags = ptr->flags;\n\tptr->ctrn_flags = flags;\n\tptr->flags = 0;\n\n\tptr->sample_count = gf_bs_read_u16(bs);\n\tISOM_DECREASE_SIZE(ptr, 2);\n\n\tif (flags & GF_ISOM_TRUN_DATA_OFFSET) {\n\t\tif (flags & GF_ISOM_CTRN_DATAOFFSET_16) {\n\t\t\tptr->data_offset = gf_bs_read_u16(bs);\n\t\t\tISOM_DECREASE_SIZE(ptr, 2);\n\t\t} else {\n\t\t\tptr->data_offset = gf_bs_read_u32(bs);\n\t\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\t}\n\t\tptr->flags |= GF_ISOM_TRUN_DATA_OFFSET;\n\t}\n\tif (flags & GF_ISOM_CTRN_CTSO_MULTIPLIER) {\n\t\tptr->ctso_multiplier = gf_bs_read_u16(bs);\n\t\tISOM_DECREASE_SIZE(ptr, 2);\n\t}\n\t\/*no sample dur\/sample_flag\/size\/ctso for first or following, create a pack sample *\/\n\tif (! (flags & 0x00FFFF00)) {\n\t\tGF_SAFEALLOC(ent, GF_TrunEntry);\n\t\tif (!ent) return GF_OUT_OF_MEM;\n\t\tent->nb_pack = ptr->sample_count;\n\t\tgf_list_add(ptr->entries, ent);\n\t\treturn GF_OK;\n\t}\n\t\/*allocate all entries*\/\n\tfor (i=0; i<ptr->sample_count; i++) {\n\t\tGF_SAFEALLOC(ent, GF_TrunEntry);\n\t\tif (!ent) return GF_OUT_OF_MEM;\n\t\tgf_list_add(ptr->entries, ent);\n\t}\n\t\/\/unpack flags\n\tptr->ctrn_first_dur = (flags>>22) & 0x3;\n\tptr->ctrn_first_size = (flags>>20) & 0x3;\n\tptr->ctrn_first_sample_flags = (flags>>18) & 0x3;\n\tptr->ctrn_first_ctts = (flags>>16) & 0x3;\n\tptr->ctrn_dur = (flags>>14) & 0x3;\n\tptr->ctrn_size = (flags>>12) & 0x3;\n\tptr->ctrn_sample_flags = (flags>>10) & 0x3;\n\tptr->ctrn_ctts = (flags>>8) & 0x3;\n\n\tinherit_dur = flags & GF_ISOM_CTRN_INHERIT_DUR;\n\tinherit_size = flags & GF_ISOM_CTRN_INHERIT_SIZE;\n\tinherit_flags = flags & GF_ISOM_CTRN_INHERIT_FLAGS;\n\tinherit_ctso = flags & GF_ISOM_CTRN_INHERIT_CTSO;\n\n\tif (flags & GF_ISOM_CTRN_FIRST_SAMPLE) {\n\t\tent = gf_list_get(ptr->entries, 0);\n\t\tfirst_idx = 1;\n\t\tif (!inherit_dur && ptr->ctrn_first_dur) {\n\t\t\tent->Duration = gf_bs_read_int(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_dur) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_dur) );\n\t\t}\n\t\tif (!inherit_size && ptr->ctrn_first_size) {\n\t\t\tent->size = gf_bs_read_int(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_size) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_size) );\n\t\t}\n\t\tif (!inherit_flags && ptr->ctrn_first_sample_flags) {\n\t\t\tent->flags = ctrn_read_flags(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_sample_flags) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_sample_flags) );\n\t\t}\n\t\tif (!inherit_ctso && ptr->ctrn_first_ctts) {\n\t\t\tent->CTS_Offset = gf_bs_read_int(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_ctts) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_ctts) );\n\t\t\tif (ptr->ctso_multiplier)\n\t\t\t\tent->CTS_Offset *= (s32) ptr->ctso_multiplier;\n\t\t}\n\t}\n\tcount = ptr->sample_count - first_idx;\n\tif (!inherit_dur && ptr->ctrn_dur) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_dur);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->Duration = gf_bs_read_int(bs, nbbits);\n\t\t}\n\t}\n\tif (!inherit_size && ptr->ctrn_size) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_size);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->size = gf_bs_read_int(bs, nbbits);\n\t\t}\n\t}\n\tif (!inherit_flags && ptr->ctrn_sample_flags) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_sample_flags);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->flags = ctrn_read_flags(bs, nbbits);\n\t\t}\n\t}\n\tif (!inherit_ctso && ptr->ctrn_ctts) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_ctts);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->CTS_Offset = gf_bs_read_int(bs, nbbits);\n\t\t\tif (ptr->ctso_multiplier)\n\t\t\t\tent->CTS_Offset *= (s32) ptr->ctso_multiplier;\n\t\t}\n\t}\n\n\treturn GF_OK;","target":0,"code_token_length":1435,"total_token_length":1671,"max_tokens_setting":2048}
+{"idx":522353,"func":"static void CalF77Prc(  int64_t BegIdx, int64_t EndIdx,\n                        void *prc, int NmbArg, void **ArgTab )\n{\n   switch(NmbArg)\n   {\n      case 1 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 1)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 1)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 1));\n      }break;\n\n      case 2 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 2)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 2)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 2));\n      }break;\n\n      case 3 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 3)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 3)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 3));\n      }break;\n\n      case 4 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 4)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 4)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 4));\n      }break;\n\n      case 5 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 5)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 5)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 5));\n      }break;\n\n      case 6 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 6)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 6)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 6));\n      }break;\n\n      case 7 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 7)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 7)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 7));\n      }break;\n\n      case 8 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 8)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 8)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 8));\n      }break;\n\n      case 9 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 9)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 9)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 9));\n      }break;\n\n      case 10 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 10)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 10)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 10));\n      }break;\n\n      case 11 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 11)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 11)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 11));\n      }break;\n\n      case 12 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 12)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 12)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 12));\n      }break;\n\n      case 13 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 13)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 13)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 13));\n      }break;\n\n      case 14 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 14)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 14)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 14));\n      }break;\n\n      case 15 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 15)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 15)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 15));\n      }break;\n\n      case 16 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 16)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 16)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 16));\n      }break;\n\n      case 17 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 17)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 17)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 17));\n      }break;\n\n      case 18 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 18)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 18)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 18));\n      }break;\n\n      case 19 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 19)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 19)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 19));\n      }break;\n\n      case 20 :\n      {\n         void (*prc1)(int64_t *, int64_t *, DUP(void *, 20)) =\n            (void (*)(int64_t *, int64_t *, DUP(void *, 20)))prc;\n         prc1(&BegIdx, &EndIdx, ARG(ArgTab, 20));\n      }break;\n   }\n}","target":0,"code_token_length":1656,"total_token_length":1892,"max_tokens_setting":2048}
+{"idx":488423,"func":"static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,\n\t\tunsigned long address, pmd_t *pmd,\n\t\tpgoff_t pgoff, unsigned int flags, pte_t orig_pte)\n{\n\tpte_t *page_table;\n\tspinlock_t *ptl;\n\tstruct page *page;\n\tpte_t entry;\n\tint anon = 0;\n\tstruct page *dirty_page = NULL;\n\tstruct vm_fault vmf;\n\tint ret;\n\tint page_mkwrite = 0;\n\n\tvmf.virtual_address = (void __user *)(address & PAGE_MASK);\n\tvmf.pgoff = pgoff;\n\tvmf.flags = flags;\n\tvmf.page = NULL;\n\n\tret = vma->vm_ops->fault(vma, &vmf);\n\tif (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))\n\t\treturn ret;\n\n\t\/*\n\t * For consistency in subsequent calls, make the faulted page always\n\t * locked.\n\t *\/\n\tif (unlikely(!(ret & VM_FAULT_LOCKED)))\n\t\tlock_page(vmf.page);\n\telse\n\t\tVM_BUG_ON(!PageLocked(vmf.page));\n\n\t\/*\n\t * Should we do an early C-O-W break?\n\t *\/\n\tpage = vmf.page;\n\tif (flags & FAULT_FLAG_WRITE) {\n\t\tif (!(vma->vm_flags & VM_SHARED)) {\n\t\t\tanon = 1;\n\t\t\tif (unlikely(anon_vma_prepare(vma))) {\n\t\t\t\tret = VM_FAULT_OOM;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tpage = alloc_page_vma(GFP_HIGHUSER_MOVABLE,\n\t\t\t\t\t\tvma, address);\n\t\t\tif (!page) {\n\t\t\t\tret = VM_FAULT_OOM;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tcopy_user_highpage(page, vmf.page, address, vma);\n\t\t\t__SetPageUptodate(page);\n\t\t} else {\n\t\t\t\/*\n\t\t\t * If the page will be shareable, see if the backing\n\t\t\t * address space wants to know that the page is about\n\t\t\t * to become writable\n\t\t\t *\/\n\t\t\tif (vma->vm_ops->page_mkwrite) {\n\t\t\t\tunlock_page(page);\n\t\t\t\tif (vma->vm_ops->page_mkwrite(vma, page) < 0) {\n\t\t\t\t\tret = VM_FAULT_SIGBUS;\n\t\t\t\t\tanon = 1; \/* no anon but release vmf.page *\/\n\t\t\t\t\tgoto out_unlocked;\n\t\t\t\t}\n\t\t\t\tlock_page(page);\n\t\t\t\t\/*\n\t\t\t\t * XXX: this is not quite right (racy vs\n\t\t\t\t * invalidate) to unlock and relock the page\n\t\t\t\t * like this, however a better fix requires\n\t\t\t\t * reworking page_mkwrite locking API, which\n\t\t\t\t * is better done later.\n\t\t\t\t *\/\n\t\t\t\tif (!page->mapping) {\n\t\t\t\t\tret = 0;\n\t\t\t\t\tanon = 1; \/* no anon but release vmf.page *\/\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t\tpage_mkwrite = 1;\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif (mem_cgroup_charge(page, mm, GFP_KERNEL)) {\n\t\tret = VM_FAULT_OOM;\n\t\tgoto out;\n\t}\n\n\tpage_table = pte_offset_map_lock(mm, pmd, address, &ptl);\n\n\t\/*\n\t * This silly early PAGE_DIRTY setting removes a race\n\t * due to the bad i386 page protection. But it's valid\n\t * for other architectures too.\n\t *\n\t * Note that if write_access is true, we either now have\n\t * an exclusive copy of the page, or this is a shared mapping,\n\t * so we can make it writable and dirty to avoid having to\n\t * handle that later.\n\t *\/\n\t\/* Only go through if we didn't race with anybody else... *\/\n\tif (likely(pte_same(*page_table, orig_pte))) {\n\t\tflush_icache_page(vma, page);\n\t\tentry = mk_pte(page, vma->vm_page_prot);\n\t\tif (flags & FAULT_FLAG_WRITE)\n\t\t\tentry = maybe_mkwrite(pte_mkdirty(entry), vma);\n\t\tset_pte_at(mm, address, page_table, entry);\n\t\tif (anon) {\n                        inc_mm_counter(mm, anon_rss);\n                        lru_cache_add_active(page);\n                        page_add_new_anon_rmap(page, vma, address);\n\t\t} else {\n\t\t\tinc_mm_counter(mm, file_rss);\n\t\t\tpage_add_file_rmap(page);\n\t\t\tif (flags & FAULT_FLAG_WRITE) {\n\t\t\t\tdirty_page = page;\n\t\t\t\tget_page(dirty_page);\n\t\t\t}\n\t\t}\n\n\t\t\/* no need to invalidate: a not-present page won't be cached *\/\n\t\tupdate_mmu_cache(vma, address, entry);\n\t} else {\n\t\tmem_cgroup_uncharge_page(page);\n\t\tif (anon)\n\t\t\tpage_cache_release(page);\n\t\telse\n\t\t\tanon = 1; \/* no anon but release faulted_page *\/\n\t}\n\n\tpte_unmap_unlock(page_table, ptl);\n\nout:\n\tunlock_page(vmf.page);\nout_unlocked:\n\tif (anon)\n\t\tpage_cache_release(vmf.page);\n\telse if (dirty_page) {\n\t\tif (vma->vm_file)\n\t\t\tfile_update_time(vma->vm_file);\n\n\t\tset_page_dirty_balance(dirty_page, page_mkwrite);\n\t\tput_page(dirty_page);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":1112,"total_token_length":1348,"max_tokens_setting":2048}
+{"idx":299894,"func":"readconf_driver_init(\n  uschar *class,\n  driver_instance **anchor,\n  driver_info *drivers_available,\n  int size_of_info,\n  void *instance_default,\n  int  instance_size,\n  optionlist *driver_optionlist,\n  int  driver_optionlist_count)\n{\ndriver_instance **p = anchor;\ndriver_instance *d = NULL;\nuschar *buffer;\n\nwhile ((buffer = get_config_line()) != NULL)\n  {\n  uschar name[64];\n  uschar *s;\n\n  \/* Read the first name on the line and test for the start of a new driver. A\n  macro definition indicates the end of the previous driver. If this isn't the\n  start of a new driver, the line will be re-read. *\/\n\n  s = readconf_readname(name, sizeof(name), buffer);\n\n  \/* Handle macro definition, first finishing off the initialization of the\n  previous driver, if any. *\/\n\n  if (isupper(*name) && *s == '=')\n    {\n    if (d != NULL)\n      {\n      if (d->driver_name == NULL)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n          \"no driver defined for %s \\\"%s\\\"\", class, d->name);\n      (d->info->init)(d);\n      d = NULL;\n      }\n    read_macro_assignment(buffer);\n    continue;\n    }\n\n  \/* If the line starts with a name terminated by a colon, we are at the\n  start of the definition of a new driver. The rest of the line must be\n  blank. *\/\n\n  if (*s++ == ':')\n    {\n    int i;\n\n    \/* Finish off initializing the previous driver. *\/\n\n    if (d != NULL)\n      {\n      if (d->driver_name == NULL)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n          \"no driver defined for %s \\\"%s\\\"\", class, d->name);\n      (d->info->init)(d);\n      }\n\n    \/* Check that we haven't already got a driver of this name *\/\n\n    for (d = *anchor; d != NULL; d = d->next)\n      if (Ustrcmp(name, d->name) == 0)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n          \"there are two %ss called \\\"%s\\\"\", class, name);\n\n    \/* Set up a new driver instance data block on the chain, with\n    its default values installed. *\/\n\n    d = store_get(instance_size);\n    memcpy(d, instance_default, instance_size);\n    *p = d;\n    p = &(d->next);\n    d->name = string_copy(name);\n\n    \/* Clear out the \"set\" bits in the generic options *\/\n\n    for (i = 0; i < driver_optionlist_count; i++)\n      driver_optionlist[i].type &= ~opt_set;\n\n    \/* Check nothing more on this line, then do the next loop iteration. *\/\n\n    while (isspace(*s)) s++;\n    if (*s != 0) extra_chars_error(s, US\"driver name \", name, US\"\");\n    continue;\n    }\n\n  \/* Not the start of a new driver. Give an error if we have not set up a\n  current driver yet. *\/\n\n  if (d == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"%s name missing\", class);\n\n  \/* First look to see if this is a generic option; if it is \"driver\",\n  initialize the driver. If is it not a generic option, we can look for a\n  private option provided that the driver has been previously set up. *\/\n\n  if (readconf_handle_option(buffer, driver_optionlist,\n        driver_optionlist_count, d, NULL))\n    {\n    if (d->info == NULL && d->driver_name != NULL)\n      init_driver(d, drivers_available, size_of_info, class);\n    }\n\n  \/* Handle private options - pass the generic block because some may\n  live therein. A flag with each option indicates if it is in the public\n  block. *\/\n\n  else if (d->info != NULL)\n    {\n    readconf_handle_option(buffer, d->info->options,\n      *(d->info->options_count), d, US\"option \\\"%s\\\" unknown\");\n    }\n\n  \/* The option is not generic and the driver name has not yet been given. *\/\n\n  else log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"option \\\"%s\\\" unknown \"\n    \"(\\\"driver\\\" must be specified before any private options)\", name);\n  }\n\n\/* Run the initialization function for the final driver. *\/\n\nif (d != NULL)\n  {\n  if (d->driver_name == NULL)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"no driver defined for %s \\\"%s\\\"\", class, d->name);\n  (d->info->init)(d);\n  }\n}","target":0,"code_token_length":1042,"total_token_length":1278,"max_tokens_setting":2048}
+{"idx":413655,"func":"R_API int r_core_search_value_in_range(RCore *core, RInterval search_itv, ut64 vmin,\n\t\t\t\t\t ut64 vmax, int vsize, inRangeCb cb, void *cb_user) {\n\tint i, align = core->search->align, hitctr = 0;\n\tbool vinfun = r_config_get_i (core->config, \"anal.vinfun\");\n\tbool vinfunr = r_config_get_i (core->config, \"anal.vinfunrange\");\n\tbool analStrings = r_config_get_i (core->config, \"anal.strings\");\n\tmycore = core;\n\tut8 buf[4096];\n\tut64 v64, value = 0, size;\n\tut64 from = search_itv.addr, to = r_itv_end (search_itv);\n\tut32 v32;\n\tut16 v16;\n\tif (from >= to) {\n\t\teprintf (\"Error: from must be lower than to\\n\");\n\t\treturn -1;\n\t}\n\tbool maybeThumb = false;\n\tif (align && core->anal->cur && core->anal->cur->arch) {\n\t\tif (!strcmp (core->anal->cur->arch, \"arm\") && core->anal->bits != 64) {\n\t\t\tmaybeThumb = true;\n\t\t}\n\t}\n\n\tif (vmin >= vmax) {\n\t\teprintf (\"Error: vmin must be lower than vmax\\n\");\n\t\treturn -1;\n\t}\n\tif (to == UT64_MAX) {\n\t\teprintf (\"Error: Invalid destination boundary\\n\");\n\t\treturn -1;\n\t}\n\tr_cons_break_push (NULL, NULL);\n\n\tif (!r_io_is_valid_offset (core->io, from, 0)) {\n\t\treturn -1;\n\t}\n\twhile (from < to) {\n\t\tsize = R_MIN (to - from, sizeof (buf));\n\t\tmemset (buf, 0xff, sizeof (buf)); \/\/ probably unnecessary\n\t\tif (r_cons_is_breaked ()) {\n\t\t\tgoto beach;\n\t\t}\n\t\tbool res = r_io_read_at_mapped (core->io, from, buf, size);\n\t\tif (!res || !memcmp (buf, \"\\xff\\xff\\xff\\xff\", 4) || !memcmp (buf, \"\\x00\\x00\\x00\\x00\", 4)) {\n\t\t\tif (!isValidAddress (core, from)) {\n\t\t\t\tut64 next = from;\n\t\t\t\tif (!r_io_map_locate (core->io, &next, 1, 0)) {\n\t\t\t\t\tfrom += sizeof (buf);\n\t\t\t\t} else {\n\t\t\t\t\tfrom += (next - from);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tfor (i = 0; i <= (size - vsize); i++) {\n\t\t\tvoid *v = (buf + i);\n\t\t\tut64 addr = from + i;\n\t\t\tif (r_cons_is_breaked ()) {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t\tif (align && (addr) % align) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint match = false;\n\t\t\tint left = size - i;\n\t\t\tif (vsize > left) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tswitch (vsize) {\n\t\t\tcase 1: value = *(ut8 *)v; match = (buf[i] >= vmin && buf[i] <= vmax); break;\n\t\t\tcase 2: v16 = *(uut16 *)v; match = (v16 >= vmin && v16 <= vmax); value = v16; break;\n\t\t\tcase 4: v32 = *(uut32 *)v; match = (v32 >= vmin && v32 <= vmax); value = v32; break;\n\t\t\tcase 8: v64 = *(uut64 *)v; match = (v64 >= vmin && v64 <= vmax); value = v64; break;\n\t\t\tdefault: eprintf (\"Unknown vsize %d\\n\", vsize); return -1;\n\t\t\t}\n\t\t\tif (match && !vinfun) {\n\t\t\t\tif (vinfunr) {\n\t\t\t\t\tif (r_anal_get_fcn_in_bounds (core->anal, addr, R_ANAL_FCN_TYPE_NULL)) {\n\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL)) {\n\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (match && value) {\n\t\t\t\tbool isValidMatch = true;\n\t\t\t\tif (align && (value % align)) {\n\t\t\t\t\t\/\/ ignored .. unless we are analyzing arm\/thumb and lower bit is 1\n\t\t\t\t\tisValidMatch = false;\n\t\t\t\t\tif (maybeThumb && (value & 1)) {\n\t\t\t\t\t\tisValidMatch = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isValidMatch) {\n\t\t\t\t\tcb (core, addr, value, vsize, cb_user);\n\t\t\t\t\tif (analStrings && stringAt (core, addr)) {\n\t\t\t\t\t\tadd_string_ref (mycore, addr, value);\n\t\t\t\t\t}\n\t\t\t\t\thitctr++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (size == to-from) {\n\t\t\tbreak;\n\t\t}\n\t\tfrom += size-vsize+1;\n\t}\nbeach:\n\tr_cons_break_pop ();\n\treturn hitctr;\n}","target":0,"code_token_length":1125,"total_token_length":1361,"max_tokens_setting":2048}
+{"idx":293760,"func":"static RList *carve_kexts(RKernelCacheObj *obj, RBinFile *bf) {\n\tstruct section_t *sections = NULL;\n\tif (!(sections = MACH0_(get_sections) (obj->mach0))) {\n\t\treturn NULL;\n\t}\n\n\tut64 pa2va_exec = 0;\n\tut64 pa2va_data = 0;\n\tut64 kmod_start = 0, kmod_end = 0;\n\tut64 kmod_info = 0, kmod_info_end = 0;\n\tint incomplete = 4;\n\tRKmodInfo *all_infos = NULL;\n\n\tint i = 0;\n\tfor (; !sections[i].last && incomplete > 0; i++) {\n\t\tif (strstr (sections[i].name, \"__TEXT_EXEC.__text\")) {\n\t\t\tpa2va_exec = sections[i].addr - sections[i].offset;\n\t\t\tincomplete--;\n\t\t}\n\t\tif (strstr (sections[i].name, \"__DATA.__data\")) {\n\t\t\tpa2va_data = sections[i].addr - sections[i].offset;\n\t\t\tincomplete--;\n\t\t}\n\t\tif (strstr (sections[i].name, \"__PRELINK_INFO.__kmod_start\")) {\n\t\t\tkmod_start = sections[i].offset;\n\t\t\tkmod_end = kmod_start + sections[i].size;\n\t\t\tincomplete--;\n\t\t}\n\t\tif (strstr (sections[i].name, \"__PRELINK_INFO.__kmod_info\")) {\n\t\t\tkmod_info = sections[i].offset;\n\t\t\tkmod_info_end = kmod_info + sections[i].size;\n\t\t\tincomplete--;\n\t\t}\n\t}\n\n\tR_FREE (sections);\n\n\tif (incomplete) {\n\t\treturn NULL;\n\t}\n\n\tRList *kexts = r_list_newf ((RListFree) &r_kext_free);\n\tif (!kexts) {\n\t\treturn NULL;\n\t}\n\n\tint n_kmod_info = (kmod_info_end - kmod_info) \/ 8;\n\tif (n_kmod_info == 0) {\n\t\tgoto beach;\n\t}\n\n\tall_infos = R_NEWS0 (RKmodInfo, n_kmod_info);\n\tif (!all_infos) {\n\t\tgoto beach;\n\t}\n\n\tut8 bytes[8];\n\tint j = 0;\n\tfor (; j < n_kmod_info; j++) {\n\t\tut64 entry_offset = j * 8 + kmod_info;\n\n\t\tif (r_buf_read_at (obj->cache_buf, entry_offset, bytes, 8) < 8) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tut64 kmod_info_paddr = K_RPTR (bytes) - pa2va_data;\n\n\t\tut64 field_name = kmod_info_paddr + 0x10;\n\t\tut64 field_start = kmod_info_paddr + 0xb4;\n\n\t\tif (r_buf_read_at (obj->cache_buf, field_start, bytes, 8) < 8) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tall_infos[j].start = K_RPTR (bytes);\n\n\t\tif (r_buf_read_at (obj->cache_buf, field_name, (ut8 *) all_infos[j].name, 0x40) < 0x40) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tall_infos[j].name[0x40] = 0;\n\t}\n\n\tut64 cursor = kmod_start;\n\tfor(; cursor < kmod_end; cursor += 8) {\n\t\tut8 bytes[8];\n\t\tif (r_buf_read_at (obj->cache_buf, cursor, bytes, 8) < 8) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tRKext *kext = R_NEW0 (RKext);\n\t\tif (!kext) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tkext->vaddr = K_RPTR (bytes);\n\t\tkext->range.offset = kext->vaddr - pa2va_exec;\n\n\t\tkext->mach0 = create_kext_mach0 (obj, kext, bf);\n\t\tif (!kext->mach0) {\n\t\t\tr_kext_free (kext);\n\t\t\tcontinue;\n\t\t}\n\n\t\tr_kext_fill_text_range (kext);\n\t\tkext->vaddr = K_PPTR (kext->vaddr);\n\t\tkext->pa2va_exec = pa2va_exec;\n\t\tkext->pa2va_data = pa2va_data;\n\n\t\tut64 text_start = kext->vaddr;\n\t\tut64 text_end = text_start + kext->text_range.size;\n\n\t\tif (text_start == text_end) {\n\t\t\tr_kext_free (kext);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (j = 0; j < n_kmod_info; j++) {\n\t\t\tif (text_start > all_infos[j].start || all_infos[j].start >= text_end) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tkext->name = strdup (all_infos[j].name);\n\t\t\tkext->own_name = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!kext->name) {\n\t\t\tr_kext_free (kext);\n\t\t\tcontinue;\n\t\t}\n\n\t\tr_list_push (kexts, kext);\n\t}\n\n\tR_FREE (all_infos);\n\treturn kexts;\n\nbeach:\n\tr_list_free (kexts);\n\tR_FREE (all_infos);\n\treturn NULL;\n}","target":0,"code_token_length":1134,"total_token_length":1370,"max_tokens_setting":2048}
+{"idx":369405,"func":"static int io_write(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_rw_state __s, *s = &__s;\n\tstruct iovec *iovec;\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\tssize_t ret, ret2;\n\tloff_t *ppos;\n\n\tif (!req_has_async_data(req)) {\n\t\tret = io_import_iovec(WRITE, req, &iovec, s, issue_flags);\n\t\tif (unlikely(ret < 0))\n\t\t\treturn ret;\n\t} else {\n\t\tstruct io_async_rw *rw = req->async_data;\n\n\t\ts = &rw->s;\n\t\tiov_iter_restore(&s->iter, &s->iter_state);\n\t\tiovec = NULL;\n\t}\n\tret = io_rw_init_file(req, FMODE_WRITE);\n\tif (unlikely(ret)) {\n\t\tkfree(iovec);\n\t\treturn ret;\n\t}\n\treq->result = iov_iter_count(&s->iter);\n\n\tif (force_nonblock) {\n\t\t\/* If the file doesn't support async, just async punt *\/\n\t\tif (unlikely(!io_file_supports_nowait(req)))\n\t\t\tgoto copy_iov;\n\n\t\t\/* file path doesn't support NOWAIT for non-direct_IO *\/\n\t\tif (force_nonblock && !(kiocb->ki_flags & IOCB_DIRECT) &&\n\t\t    (req->flags & REQ_F_ISREG))\n\t\t\tgoto copy_iov;\n\n\t\tkiocb->ki_flags |= IOCB_NOWAIT;\n\t} else {\n\t\t\/* Ensure we clear previously set non-block flag *\/\n\t\tkiocb->ki_flags &= ~IOCB_NOWAIT;\n\t}\n\n\tppos = io_kiocb_update_pos(req);\n\n\tret = rw_verify_area(WRITE, req->file, ppos, req->result);\n\tif (unlikely(ret))\n\t\tgoto out_free;\n\n\t\/*\n\t * Open-code file_start_write here to grab freeze protection,\n\t * which will be released by another thread in\n\t * io_complete_rw().  Fool lockdep by telling it the lock got\n\t * released so that it doesn't complain about the held lock when\n\t * we return to userspace.\n\t *\/\n\tif (req->flags & REQ_F_ISREG) {\n\t\tsb_start_write(file_inode(req->file)->i_sb);\n\t\t__sb_writers_release(file_inode(req->file)->i_sb,\n\t\t\t\t\tSB_FREEZE_WRITE);\n\t}\n\tkiocb->ki_flags |= IOCB_WRITE;\n\n\tif (likely(req->file->f_op->write_iter))\n\t\tret2 = call_write_iter(req->file, kiocb, &s->iter);\n\telse if (req->file->f_op->write)\n\t\tret2 = loop_rw_iter(WRITE, req, &s->iter);\n\telse\n\t\tret2 = -EINVAL;\n\n\tif (req->flags & REQ_F_REISSUE) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\tret2 = -EAGAIN;\n\t}\n\n\t\/*\n\t * Raw bdev writes will return -EOPNOTSUPP for IOCB_NOWAIT. Just\n\t * retry them without IOCB_NOWAIT.\n\t *\/\n\tif (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))\n\t\tret2 = -EAGAIN;\n\t\/* no retry on NONBLOCK nor RWF_NOWAIT *\/\n\tif (ret2 == -EAGAIN && (req->flags & REQ_F_NOWAIT))\n\t\tgoto done;\n\tif (!force_nonblock || ret2 != -EAGAIN) {\n\t\t\/* IOPOLL retry should happen for io-wq threads *\/\n\t\tif (ret2 == -EAGAIN && (req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\t\tgoto copy_iov;\ndone:\n\t\tkiocb_done(req, ret2, issue_flags);\n\t} else {\ncopy_iov:\n\t\tiov_iter_restore(&s->iter, &s->iter_state);\n\t\tret = io_setup_async_rw(req, iovec, s, false);\n\t\treturn ret ?: -EAGAIN;\n\t}\nout_free:\n\t\/* it's reportedly faster than delegating the null check to kfree() *\/\n\tif (iovec)\n\t\tkfree(iovec);\n\treturn ret;\n}","target":0,"code_token_length":902,"total_token_length":1138,"max_tokens_setting":2048}
+{"idx":223375,"func":"static void read_char8_type(compiler_common *common, jump_list **backtracks, BOOL negated)\n{\n\/* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. *\/\nDEFINE_COMPILER;\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8\nstruct sljit_jump *jump;\n#endif\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\nstruct sljit_jump *jump2;\n#endif\n\nSLJIT_UNUSED_ARG(backtracks);\nSLJIT_UNUSED_ARG(negated);\n\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\nif (common->utf)\n  {\n  \/* The result of this read may be unused, but saves an \"else\" part. *\/\n  OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);\n  jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x80);\n\n  if (!negated)\n    {\n    if (common->invalid_utf)\n      add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n    OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2);\n    if (common->invalid_utf)\n      add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0xe0 - 0xc2));\n\n    OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);\n    OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);\n    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x80);\n    if (common->invalid_utf)\n      add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40));\n\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);\n    jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255);\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);\n    JUMPHERE(jump2);\n    }\n  else if (common->invalid_utf)\n    {\n    add_jump(compiler, &common->utfreadchar_invalid, JUMP(SLJIT_FAST_CALL));\n    OP1(SLJIT_MOV, TMP2, 0, TMP1, 0);\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR));\n\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);\n    jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255);\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);\n    JUMPHERE(jump2);\n    }\n  else\n    add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL));\n\n  JUMPHERE(jump);\n  return;\n  }\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 *\/\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 32\nif (common->invalid_utf && negated)\n  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x110000));\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 32 *\/\n\n#if PCRE2_CODE_UNIT_WIDTH != 8\n\/* The ctypes array contains only 256 values. *\/\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);\njump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255);\n#endif \/* PCRE2_CODE_UNIT_WIDTH != 8 *\/\nOP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);\n#if PCRE2_CODE_UNIT_WIDTH != 8\nJUMPHERE(jump);\n#endif \/* PCRE2_CODE_UNIT_WIDTH != 8 *\/\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 16\nif (common->utf && negated)\n  {\n  \/* Skip low surrogate if necessary. *\/\n  if (!common->invalid_utf)\n    {\n    OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);\n\n    if (sljit_has_cpu_feature(SLJIT_HAS_CMOV) && !HAS_VIRTUAL_REGISTERS)\n      {\n      OP2(SLJIT_ADD, RETURN_ADDR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP2, 0, SLJIT_IMM, 0x400);\n      CMOV(SLJIT_LESS, STR_PTR, RETURN_ADDR, 0);\n      }\n    else\n      {\n      jump = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x400);\n      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n      JUMPHERE(jump);\n      }\n    return;\n    }\n\n  OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);\n  jump = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800);\n  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x400));\n  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n\n  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xdc00);\n  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x400));\n\n  JUMPHERE(jump);\n  return;\n  }\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 16 *\/\n}","target":0,"code_token_length":1706,"total_token_length":1942,"max_tokens_setting":2048}
+{"idx":463206,"func":"EXPORTED int annotate_state_fetch(annotate_state_t *state,\n                         const strarray_t *entries, const strarray_t *attribs,\n                         annotate_fetch_cb_t callback, void *rock)\n{\n    int i;\n    struct glob *g;\n    const ptrarray_t *non_db_entries;\n    const annotate_entrydesc_t *db_entry;\n    int r = 0;\n\n    init_internal();\n\n    annotate_state_start(state);\n    state->callback = callback;\n    state->callback_rock = rock;\n\n    \/* Build list of attributes to fetch *\/\n    for (i = 0 ; i < attribs->count ; i++)\n    {\n        const char *s = attribs->data[i];\n        int attribcount;\n\n        \/*\n         * TODO: this is bogus.  The * and % wildcard characters applied\n         * to attributes in the early drafts of the ANNOTATEMORE\n         * extension, but not in later drafts where those characters are\n         * actually illegal in attribute names.\n         *\/\n        g = glob_init(s, '.');\n\n        for (attribcount = 0;\n             annotation_attributes[attribcount].name;\n             attribcount++) {\n            if (GLOB_MATCH(g, annotation_attributes[attribcount].name)) {\n                if (annotation_attributes[attribcount].entry & ATTRIB_DEPRECATED) {\n                    if (strcmp(s, \"*\"))\n                        syslog(LOG_WARNING, \"annotatemore_fetch: client used \"\n                                            \"deprecated attribute \\\"%s\\\", ignoring\",\n                                            annotation_attributes[attribcount].name);\n                }\n                else\n                    state->attribs |= annotation_attributes[attribcount].entry;\n            }\n        }\n\n        glob_free(&g);\n    }\n\n    if (!state->attribs)\n        goto out;\n\n    if (state->which == ANNOTATION_SCOPE_SERVER) {\n        non_db_entries = &server_entries;\n        db_entry = &server_db_entry;\n    }\n    else if (state->which == ANNOTATION_SCOPE_MAILBOX) {\n        non_db_entries = &mailbox_entries;\n        db_entry = &mailbox_db_entry;\n    }\n    else if (state->which == ANNOTATION_SCOPE_MESSAGE) {\n        non_db_entries = &message_entries;\n        db_entry = &message_db_entry;\n    }\n    else {\n        syslog(LOG_ERR, \"IOERROR: unknown annotation scope %d\", state->which);\n        r = IMAP_INTERNAL;\n        goto out;\n    }\n\n    \/* Build a list of callbacks for fetching the annotations *\/\n    for (i = 0 ; i < entries->count ; i++)\n    {\n        const char *s = entries->data[i];\n        int j;\n        int check_db = 0; \/* should we check the db for this entry? *\/\n\n        g = glob_init(s, '\/');\n\n        for (j = 0 ; j < non_db_entries->count ; j++) {\n            const annotate_entrydesc_t *desc = non_db_entries->data[j];\n\n            if (!desc->get)\n                continue;\n\n            if (GLOB_MATCH(g, desc->name)) {\n                \/* Add this entry to our list only if it\n                   applies to our particular server type *\/\n                if ((desc->proxytype != PROXY_ONLY)\n                    || proxy_fetch_func)\n                    _annotate_state_add_entry(state, desc, desc->name);\n            }\n\n            if (!strcmp(s, desc->name)) {\n                \/* exact match *\/\n                if (desc->proxytype != PROXY_ONLY) {\n                    state->orig_entry = entries;  \/* proxy it *\/\n                }\n                break;\n            }\n        }\n\n        if (j == non_db_entries->count) {\n            \/* no [exact] match *\/\n            state->orig_entry = entries;  \/* proxy it *\/\n            check_db = 1;\n        }\n\n        \/* Add the db entry to our list if only if it\n           applies to our particular server type *\/\n        if (check_db &&\n            ((db_entry->proxytype != PROXY_ONLY) || proxy_fetch_func)) {\n            \/* Add the db entry to our list *\/\n            _annotate_state_add_entry(state, db_entry, s);\n        }\n\n        glob_free(&g);\n    }\n\n    if (state->which == ANNOTATION_SCOPE_SERVER) {\n        _annotate_fetch_entries(state, \/*proxy_check*\/1);\n    }\n    else if (state->which == ANNOTATION_SCOPE_MAILBOX) {\n\n        if (state->entry_list || proxy_fetch_func) {\n            if (proxy_fetch_func) {\n                r = annotate_state_need_mbentry(state);\n                if (r)\n                    goto out;\n                assert(state->mbentry);\n            }\n\n            if (proxy_fetch_func && state->orig_entry) {\n                state->orig_mailbox = state->mbentry->name;\n                state->orig_attribute = attribs;\n            }\n\n            _annotate_fetch_entries(state, \/*proxy_check*\/1);\n\n            if (proxy_fetch_func && state->orig_entry && state->mbentry->server &&\n                !hash_lookup(state->mbentry->server, &state->server_table)) {\n                \/* xxx ignoring result *\/\n                proxy_fetch_func(state->mbentry->server, state->mbentry->ext_name,\n                                 state->orig_entry, state->orig_attribute);\n                hash_insert(state->mbentry->server, (void *)0xDEADBEEF, &state->server_table);\n            }\n        }\n    }\n    else if (state->which == ANNOTATION_SCOPE_MESSAGE) {\n        _annotate_fetch_entries(state, \/*proxy_check*\/0);\n    }\n\n    \/* Flush last cached entry in output_entryatt() *\/\n    flush_entryatt(state);\n\nout:\n    annotate_state_finish(state);\n    return r;\n}","target":0,"code_token_length":1162,"total_token_length":1398,"max_tokens_setting":2048}
+{"idx":226966,"func":"IRC_PROTOCOL_CALLBACK(353)\n{\n    char *pos_channel, *pos_nick, *pos_nick_orig, *pos_host, *nickname;\n    char *prefixes, *str_nicks, *color;\n    int args, i, length;\n    struct t_irc_channel *ptr_channel;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    if (irc_channel_is_channel (server, argv[3]))\n    {\n        pos_channel = argv[3];\n        args = 4;\n    }\n    else\n    {\n        pos_channel = argv[4];\n        args = 5;\n    }\n\n    IRC_PROTOCOL_MIN_ARGS(args + 1);\n\n    ptr_channel = irc_channel_search (server, pos_channel);\n    str_nicks = NULL;\n\n    \/*\n     * for a channel without buffer, prepare a string that will be built\n     * with nicks and colors (argc - args is the number of nicks)\n     *\/\n    if (!ptr_channel)\n    {\n        \/*\n         * prefix color (16) + nick color (16) + reset color (16) = 48 bytes\n         * added for each nick\n         *\/\n        length = strlen (argv_eol[args]) + ((argc - args) * (16 + 16 + 16)) + 1;\n        str_nicks = malloc (length);\n        if (str_nicks)\n            str_nicks[0] = '\\0';\n    }\n\n    for (i = args; i < argc; i++)\n    {\n        pos_nick = (argv[i][0] == ':') ? argv[i] + 1 : argv[i];\n        pos_nick_orig = pos_nick;\n\n        \/* skip and save prefix(es) *\/\n        while (pos_nick[0]\n               && (irc_server_get_prefix_char_index (server, pos_nick[0]) >= 0))\n        {\n            pos_nick++;\n        }\n        prefixes = (pos_nick > pos_nick_orig) ?\n            weechat_strndup (pos_nick_orig, pos_nick - pos_nick_orig) : NULL;\n\n        \/* extract nick from host *\/\n        pos_host = strchr (pos_nick, '!');\n        if (pos_host)\n        {\n            nickname = weechat_strndup (pos_nick, pos_host - pos_nick);\n            pos_host++;\n        }\n        else\n            nickname = strdup (pos_nick);\n\n        \/* add or update nick on channel *\/\n        if (nickname)\n        {\n            if (ptr_channel && ptr_channel->nicks)\n            {\n                if (!irc_nick_new (server, ptr_channel, nickname, pos_host,\n                                   prefixes, 0, NULL, NULL))\n                {\n                    weechat_printf (\n                        server->buffer,\n                        _(\"%s%s: cannot create nick \\\"%s\\\" for channel \\\"%s\\\"\"),\n                        weechat_prefix (\"error\"), IRC_PLUGIN_NAME, nickname,\n                        ptr_channel->name);\n                }\n            }\n            else if (!ptr_channel && str_nicks)\n            {\n                if (str_nicks[0])\n                {\n                    strcat (str_nicks, IRC_COLOR_RESET);\n                    strcat (str_nicks, \" \");\n                }\n                if (prefixes)\n                {\n                    strcat (str_nicks,\n                            weechat_color (\n                                irc_nick_get_prefix_color_name (server,\n                                                                prefixes[0])));\n                    strcat (str_nicks, prefixes);\n                }\n                if (weechat_config_boolean (irc_config_look_color_nicks_in_names))\n                {\n                    if (irc_server_strcasecmp (server, nickname, server->nick) == 0)\n                        strcat (str_nicks, IRC_COLOR_CHAT_NICK_SELF);\n                    else\n                    {\n                        color = irc_nick_find_color (nickname);\n                        strcat (str_nicks, color);\n                        if (color)\n                            free (color);\n                    }\n                }\n                else\n                    strcat (str_nicks, IRC_COLOR_RESET);\n                strcat (str_nicks, nickname);\n            }\n            free (nickname);\n        }\n        if (prefixes)\n            free (prefixes);\n    }\n\n    if (!ptr_channel)\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, NULL, command, \"names\", NULL),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            _(\"%sNicks %s%s%s: %s[%s%s%s]\"),\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_CHANNEL,\n            pos_channel,\n            IRC_COLOR_RESET,\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            (str_nicks) ? str_nicks : \"\",\n            IRC_COLOR_CHAT_DELIMITERS);\n    }\n\n    if (str_nicks)\n        free (str_nicks);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":987,"total_token_length":1223,"max_tokens_setting":2048}
+{"idx":373637,"func":"add_pack_dir_to_rtp(char_u *fname)\n{\n    char_u  *p4, *p3, *p2, *p1, *p;\n    char_u  *entry;\n    char_u  *insp = NULL;\n    int\t    c;\n    char_u  *new_rtp;\n    int\t    keep;\n    size_t  oldlen;\n    size_t  addlen;\n    size_t  new_rtp_len;\n    char_u  *afterdir = NULL;\n    size_t  afterlen = 0;\n    char_u  *after_insp = NULL;\n    char_u  *ffname = NULL;\n    size_t  fname_len;\n    char_u  *buf = NULL;\n    char_u  *rtp_ffname;\n    int\t    match;\n    int\t    retval = FAIL;\n\n    p4 = p3 = p2 = p1 = get_past_head(fname);\n    for (p = p1; *p; MB_PTR_ADV(p))\n\tif (vim_ispathsep_nocolon(*p))\n\t{\n\t    p4 = p3; p3 = p2; p2 = p1; p1 = p;\n\t}\n\n    \/\/ now we have:\n    \/\/ rtp\/pack\/name\/start\/name\n    \/\/    p4   p3   p2    p1\n    \/\/\n    \/\/ find the part up to \"pack\" in 'runtimepath'\n    c = *++p4; \/\/ append pathsep in order to expand symlink\n    *p4 = NUL;\n    ffname = fix_fname(fname);\n    *p4 = c;\n    if (ffname == NULL)\n\treturn FAIL;\n\n    \/\/ Find \"ffname\" in \"p_rtp\", ignoring '\/' vs '\\' differences.\n    \/\/ Also stop at the first \"after\" directory.\n    fname_len = STRLEN(ffname);\n    buf = alloc(MAXPATHL);\n    if (buf == NULL)\n\tgoto theend;\n    for (entry = p_rtp; *entry != NUL; )\n    {\n\tchar_u *cur_entry = entry;\n\n\tcopy_option_part(&entry, buf, MAXPATHL, \",\");\n\tif (insp == NULL)\n\t{\n\t    add_pathsep(buf);\n\t    rtp_ffname = fix_fname(buf);\n\t    if (rtp_ffname == NULL)\n\t\tgoto theend;\n\t    match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;\n\t    vim_free(rtp_ffname);\n\t    if (match)\n\t\t\/\/ Insert \"ffname\" after this entry (and comma).\n\t\tinsp = entry;\n\t}\n\n\tif ((p = (char_u *)strstr((char *)buf, \"after\")) != NULL\n\t\t&& p > buf\n\t\t&& vim_ispathsep(p[-1])\n\t\t&& (vim_ispathsep(p[5]) || p[5] == NUL || p[5] == ','))\n\t{\n\t    if (insp == NULL)\n\t\t\/\/ Did not find \"ffname\" before the first \"after\" directory,\n\t\t\/\/ insert it before this entry.\n\t\tinsp = cur_entry;\n\t    after_insp = cur_entry;\n\t    break;\n\t}\n    }\n\n    if (insp == NULL)\n\t\/\/ Both \"fname\" and \"after\" not found, append at the end.\n\tinsp = p_rtp + STRLEN(p_rtp);\n\n    \/\/ check if rtp\/pack\/name\/start\/name\/after exists\n    afterdir = concat_fnames(fname, (char_u *)\"after\", TRUE);\n    if (afterdir != NULL && mch_isdir(afterdir))\n\tafterlen = STRLEN(afterdir) + 1; \/\/ add one for comma\n\n    oldlen = STRLEN(p_rtp);\n    addlen = STRLEN(fname) + 1; \/\/ add one for comma\n    new_rtp = alloc(oldlen + addlen + afterlen + 1); \/\/ add one for NUL\n    if (new_rtp == NULL)\n\tgoto theend;\n\n    \/\/ We now have 'rtp' parts: {keep}{keep_after}{rest}.\n    \/\/ Create new_rtp, first: {keep},{fname}\n    keep = (int)(insp - p_rtp);\n    mch_memmove(new_rtp, p_rtp, keep);\n    new_rtp_len = keep;\n    if (*insp == NUL)\n\tnew_rtp[new_rtp_len++] = ',';  \/\/ add comma before\n    mch_memmove(new_rtp + new_rtp_len, fname, addlen - 1);\n    new_rtp_len += addlen - 1;\n    if (*insp != NUL)\n\tnew_rtp[new_rtp_len++] = ',';  \/\/ add comma after\n\n    if (afterlen > 0 && after_insp != NULL)\n    {\n\tint keep_after = (int)(after_insp - p_rtp);\n\n\t\/\/ Add to new_rtp: {keep},{fname}{keep_after},{afterdir}\n\tmch_memmove(new_rtp + new_rtp_len, p_rtp + keep,\n\t\t\t\t\t\t\tkeep_after - keep);\n\tnew_rtp_len += keep_after - keep;\n\tmch_memmove(new_rtp + new_rtp_len, afterdir, afterlen - 1);\n\tnew_rtp_len += afterlen - 1;\n\tnew_rtp[new_rtp_len++] = ',';\n\tkeep = keep_after;\n    }\n\n    if (p_rtp[keep] != NUL)\n\t\/\/ Append rest: {keep},{fname}{keep_after},{afterdir}{rest}\n\tmch_memmove(new_rtp + new_rtp_len, p_rtp + keep, oldlen - keep + 1);\n    else\n\tnew_rtp[new_rtp_len] = NUL;\n\n    if (afterlen > 0 && after_insp == NULL)\n    {\n\t\/\/ Append afterdir when \"after\" was not found:\n\t\/\/ {keep},{fname}{rest},{afterdir}\n\tSTRCAT(new_rtp, \",\");\n\tSTRCAT(new_rtp, afterdir);\n    }\n\n    set_option_value((char_u *)\"rtp\", 0L, new_rtp, 0);\n    vim_free(new_rtp);\n    retval = OK;\n\ntheend:\n    vim_free(buf);\n    vim_free(ffname);\n    vim_free(afterdir);\n    return retval;\n}","target":0,"code_token_length":1331,"total_token_length":1567,"max_tokens_setting":2048}
+{"idx":225455,"func":"Status MutableGraphView::UpdateFanin(absl::string_view node_name,\n                                     const TensorId& from_fanin,\n                                     const TensorId& to_fanin) {\n  auto error_status = [node_name, from_fanin, to_fanin](absl::string_view msg) {\n    string params =\n        absl::Substitute(\"node_name='$0', from_fanin='$1', to_fanin='$2'\",\n                         node_name, from_fanin.ToString(), to_fanin.ToString());\n    return MutationError(\"UpdateFanin\", params, msg);\n  };\n\n  TF_RETURN_IF_ERROR(CheckFaninIsValid(from_fanin, error_status));\n  TF_RETURN_IF_ERROR(CheckFaninIsValid(to_fanin, error_status));\n  NodeDef* node = GetNode(node_name);\n  TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));\n  NodeDef* from_fanin_node = GetNode(from_fanin.node());\n  TF_RETURN_IF_ERROR(\n      CheckNodeExists(from_fanin.node(), from_fanin_node, error_status));\n  NodeDef* to_fanin_node = GetNode(to_fanin.node());\n  TF_RETURN_IF_ERROR(\n      CheckNodeExists(to_fanin.node(), to_fanin_node, error_status));\n\n  \/\/ When replacing a non control dependency fanin with a control dependency, or\n  \/\/ vice versa, remove and add, so ports can be updated properly in fanout(s).\n  bool to_fanin_is_control = IsTensorIdControlling(to_fanin);\n  if (to_fanin_is_control && IsSwitch(*to_fanin_node)) {\n    \/\/ Can't add Switch node as a control dependency.\n    return error_status(\n        absl::Substitute(\"can't update to fanin '$0' as it will become a \"\n                         \"Switch control dependency\",\n                         to_fanin.ToString()));\n  }\n  if (node_name == from_fanin.node() || node_name == to_fanin.node()) {\n    return error_status(\"can't update fanin to or from self\");\n  }\n\n  if (from_fanin == to_fanin) {\n    return Status::OK();\n  }\n\n  bool from_fanin_is_control = IsTensorIdControlling(from_fanin);\n  if (from_fanin_is_control || to_fanin_is_control) {\n    bool modified = false;\n    if (from_fanin_is_control) {\n      modified |= RemoveControllingFaninInternal(node, from_fanin_node);\n    } else {\n      modified |= RemoveRegularFaninInternal(\n          node, {from_fanin_node, from_fanin.index()});\n    }\n    if (modified) {\n      AddFaninInternal(node, {to_fanin_node, to_fanin.index()});\n    }\n    return Status::OK();\n  }\n\n  \/\/ In place mutation of regular fanins, requires no shifting of ports.\n  string to_fanin_string = TensorIdToString(to_fanin);\n  const int num_regular_fanins =\n      NumFanins(*node, \/*include_controlling_nodes=*\/false);\n  bool modified = false;\n  for (int i = 0; i < num_regular_fanins; ++i) {\n    if (ParseTensorName(node->input(i)) == from_fanin) {\n      InputPort input(node, i);\n\n      OutputPort from_fanin_port(from_fanin_node, from_fanin.index());\n      fanouts()[from_fanin_port].erase(input);\n\n      OutputPort to_fanin_port(to_fanin_node, to_fanin.index());\n      fanouts()[to_fanin_port].insert(input);\n\n      node->set_input(i, to_fanin_string);\n      modified = true;\n    }\n  }\n\n  \/\/ Dedup control dependencies and update max regular output ports.\n  if (modified) {\n    OutputPort from_fanin_port(from_fanin_node, from_fanin.index());\n    UpdateMaxRegularOutputPortForRemovedFanin(\n        {from_fanin_node, from_fanin.index()}, fanouts()[from_fanin_port]);\n    if (max_regular_output_port()[to_fanin_node] < to_fanin.index()) {\n      max_regular_output_port()[to_fanin_node] = to_fanin.index();\n    }\n    if (CanDedupControlWithRegularInput(*this, *to_fanin_node)) {\n      RemoveControllingFaninInternal(node, to_fanin_node);\n    }\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":964,"total_token_length":1200,"max_tokens_setting":2048}
+{"idx":301497,"func":"spell_edit_score_limit_w(\n    slang_T\t*slang,\n    char_u\t*badword,\n    char_u\t*goodword,\n    int\t\tlimit)\n{\n    limitscore_T    stack[10];\t\t\/\/ allow for over 3 * 2 edits\n    int\t\t    stackidx;\n    int\t\t    bi, gi;\n    int\t\t    bi2, gi2;\n    int\t\t    bc, gc;\n    int\t\t    score;\n    int\t\t    score_off;\n    int\t\t    minscore;\n    int\t\t    round;\n    char_u\t    *p;\n    int\t\t    wbadword[MAXWLEN];\n    int\t\t    wgoodword[MAXWLEN];\n\n    \/\/ Get the characters from the multi-byte strings and put them in an\n    \/\/ int array for easy access.\n    bi = 0;\n    for (p = badword; *p != NUL; )\n\twbadword[bi++] = mb_cptr2char_adv(&p);\n    wbadword[bi++] = 0;\n    gi = 0;\n    for (p = goodword; *p != NUL; )\n\twgoodword[gi++] = mb_cptr2char_adv(&p);\n    wgoodword[gi++] = 0;\n\n    \/\/ The idea is to go from start to end over the words.  So long as\n    \/\/ characters are equal just continue, this always gives the lowest score.\n    \/\/ When there is a difference try several alternatives.  Each alternative\n    \/\/ increases \"score\" for the edit distance.  Some of the alternatives are\n    \/\/ pushed unto a stack and tried later, some are tried right away.  At the\n    \/\/ end of the word the score for one alternative is known.  The lowest\n    \/\/ possible score is stored in \"minscore\".\n    stackidx = 0;\n    bi = 0;\n    gi = 0;\n    score = 0;\n    minscore = limit + 1;\n\n    for (;;)\n    {\n\t\/\/ Skip over an equal part, score remains the same.\n\tfor (;;)\n\t{\n\t    bc = wbadword[bi];\n\t    gc = wgoodword[gi];\n\n\t    if (bc != gc)\t\/\/ stop at a char that's different\n\t\tbreak;\n\t    if (bc == NUL)\t\/\/ both words end\n\t    {\n\t\tif (score < minscore)\n\t\t    minscore = score;\n\t\tgoto pop;\t\/\/ do next alternative\n\t    }\n\t    ++bi;\n\t    ++gi;\n\t}\n\n\tif (gc == NUL)    \/\/ goodword ends, delete badword chars\n\t{\n\t    do\n\t    {\n\t\tif ((score += SCORE_DEL) >= minscore)\n\t\t    goto pop;\t    \/\/ do next alternative\n\t    } while (wbadword[++bi] != NUL);\n\t    minscore = score;\n\t}\n\telse if (bc == NUL) \/\/ badword ends, insert badword chars\n\t{\n\t    do\n\t    {\n\t\tif ((score += SCORE_INS) >= minscore)\n\t\t    goto pop;\t    \/\/ do next alternative\n\t    } while (wgoodword[++gi] != NUL);\n\t    minscore = score;\n\t}\n\telse\t\t\t\/\/ both words continue\n\t{\n\t    \/\/ If not close to the limit, perform a change.  Only try changes\n\t    \/\/ that may lead to a lower score than \"minscore\".\n\t    \/\/ round 0: try deleting a char from badword\n\t    \/\/ round 1: try inserting a char in badword\n\t    for (round = 0; round <= 1; ++round)\n\t    {\n\t\tscore_off = score + (round == 0 ? SCORE_DEL : SCORE_INS);\n\t\tif (score_off < minscore)\n\t\t{\n\t\t    if (score_off + SCORE_EDIT_MIN >= minscore)\n\t\t    {\n\t\t\t\/\/ Near the limit, rest of the words must match.  We\n\t\t\t\/\/ can check that right now, no need to push an item\n\t\t\t\/\/ onto the stack.\n\t\t\tbi2 = bi + 1 - round;\n\t\t\tgi2 = gi + round;\n\t\t\twhile (wgoodword[gi2] == wbadword[bi2])\n\t\t\t{\n\t\t\t    if (wgoodword[gi2] == NUL)\n\t\t\t    {\n\t\t\t\tminscore = score_off;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t    ++bi2;\n\t\t\t    ++gi2;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ try deleting a character from badword later\n\t\t\tstack[stackidx].badi = bi + 1 - round;\n\t\t\tstack[stackidx].goodi = gi + round;\n\t\t\tstack[stackidx].score = score_off;\n\t\t\t++stackidx;\n\t\t    }\n\t\t}\n\t    }\n\n\t    if (score + SCORE_SWAP < minscore)\n\t    {\n\t\t\/\/ If swapping two characters makes a match then the\n\t\t\/\/ substitution is more expensive, thus there is no need to\n\t\t\/\/ try both.\n\t\tif (gc == wbadword[bi + 1] && bc == wgoodword[gi + 1])\n\t\t{\n\t\t    \/\/ Swap two characters, that is: skip them.\n\t\t    gi += 2;\n\t\t    bi += 2;\n\t\t    score += SCORE_SWAP;\n\t\t    continue;\n\t\t}\n\t    }\n\n\t    \/\/ Substitute one character for another which is the same\n\t    \/\/ thing as deleting a character from both goodword and badword.\n\t    \/\/ Use a better score when there is only a case difference.\n\t    if (SPELL_TOFOLD(bc) == SPELL_TOFOLD(gc))\n\t\tscore += SCORE_ICASE;\n\t    else\n\t    {\n\t\t\/\/ For a similar character use SCORE_SIMILAR.\n\t\tif (slang != NULL\n\t\t\t&& slang->sl_has_map\n\t\t\t&& similar_chars(slang, gc, bc))\n\t\t    score += SCORE_SIMILAR;\n\t\telse\n\t\t    score += SCORE_SUBST;\n\t    }\n\n\t    if (score < minscore)\n\t    {\n\t\t\/\/ Do the substitution.\n\t\t++gi;\n\t\t++bi;\n\t\tcontinue;\n\t    }\n\t}\npop:\n\t\/\/ Get here to try the next alternative, pop it from the stack.\n\tif (stackidx == 0)\t\t\/\/ stack is empty, finished\n\t    break;\n\n\t\/\/ pop an item from the stack\n\t--stackidx;\n\tgi = stack[stackidx].goodi;\n\tbi = stack[stackidx].badi;\n\tscore = stack[stackidx].score;\n    }\n\n    \/\/ When the score goes over \"limit\" it may actually be much higher.\n    \/\/ Return a very large number to avoid going below the limit when giving a\n    \/\/ bonus.\n    if (minscore > limit)\n\treturn SCORE_MAXMAX;\n    return minscore;\n}","target":0,"code_token_length":1410,"total_token_length":1646,"max_tokens_setting":2048}
+{"idx":259313,"func":"static int find_prev_closest_index(AVStream *st,\n                                   AVIndexEntry *e_old,\n                                   int nb_old,\n                                   MOVCtts* ctts_data,\n                                   int64_t ctts_count,\n                                   int64_t timestamp_pts,\n                                   int flag,\n                                   int64_t* index,\n                                   int64_t* ctts_index,\n                                   int64_t* ctts_sample)\n{\n    MOVStreamContext *msc = st->priv_data;\n    FFStream *const sti = ffstream(st);\n    AVIndexEntry *e_keep = sti->index_entries;\n    int nb_keep = sti->nb_index_entries;\n    int64_t i = 0;\n    int64_t index_ctts_count;\n\n    av_assert0(index);\n\n    \/\/ If dts_shift > 0, then all the index timestamps will have to be offset by\n    \/\/ at least dts_shift amount to obtain PTS.\n    \/\/ Hence we decrement the searched timestamp_pts by dts_shift to find the closest index element.\n    if (msc->dts_shift > 0) {\n        timestamp_pts -= msc->dts_shift;\n    }\n\n    sti->index_entries    = e_old;\n    sti->nb_index_entries = nb_old;\n    *index = av_index_search_timestamp(st, timestamp_pts, flag | AVSEEK_FLAG_BACKWARD);\n\n    \/\/ Keep going backwards in the index entries until the timestamp is the same.\n    if (*index >= 0) {\n        for (i = *index; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp;\n             i--) {\n            if ((flag & AVSEEK_FLAG_ANY) ||\n                (e_old[i - 1].flags & AVINDEX_KEYFRAME)) {\n                *index = i - 1;\n            }\n        }\n    }\n\n    \/\/ If we have CTTS then refine the search, by searching backwards over PTS\n    \/\/ computed by adding corresponding CTTS durations to index timestamps.\n    if (ctts_data && *index >= 0) {\n        av_assert0(ctts_index);\n        av_assert0(ctts_sample);\n        \/\/ Find out the ctts_index for the found frame.\n        *ctts_index = 0;\n        *ctts_sample = 0;\n        for (index_ctts_count = 0; index_ctts_count < *index; index_ctts_count++) {\n            if (*ctts_index < ctts_count) {\n                (*ctts_sample)++;\n                if (ctts_data[*ctts_index].count == *ctts_sample) {\n                    (*ctts_index)++;\n                    *ctts_sample = 0;\n                }\n            }\n        }\n\n        while (*index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < ctts_count) {\n            \/\/ Find a \"key frame\" with PTS <= timestamp_pts (So that we can decode B-frames correctly).\n            \/\/ No need to add dts_shift to the timestamp here becase timestamp_pts has already been\n            \/\/ compensated by dts_shift above.\n            if ((e_old[*index].timestamp + ctts_data[*ctts_index].duration) <= timestamp_pts &&\n                (e_old[*index].flags & AVINDEX_KEYFRAME)) {\n                break;\n            }\n\n            (*index)--;\n            if (*ctts_sample == 0) {\n                (*ctts_index)--;\n                if (*ctts_index >= 0)\n                  *ctts_sample = ctts_data[*ctts_index].count - 1;\n            } else {\n                (*ctts_sample)--;\n            }\n        }\n    }\n\n    \/* restore AVStream state*\/\n    sti->index_entries    = e_keep;\n    sti->nb_index_entries = nb_keep;\n    return *index >= 0 ? 0 : -1;\n}","target":0,"code_token_length":803,"total_token_length":1039,"max_tokens_setting":2048}
+{"idx":292134,"func":"void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {\n  Symbol* method_name       = pool->name_ref_at(index);\n  Symbol* method_signature  = pool->signature_ref_at(index);\n  Klass* current_klass = pool->pool_holder();\n\n  \/\/ Resolve the bootstrap specifier (BSM + optional arguments).\n  Handle bootstrap_specifier;\n  \/\/ Check if CallSite has been bound already:\n  ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index);\n  int pool_index = cpce->constant_pool_index();\n\n  if (cpce->is_f1_null()) {\n    if (cpce->indy_resolution_failed()) {\n      ConstantPool::throw_resolution_error(pool,\n                                           ResolutionErrorTable::encode_cpcache_index(index),\n                                           CHECK);\n    }\n\n    \/\/ The initial step in Call Site Specifier Resolution is to resolve the symbolic\n    \/\/ reference to a method handle which will be the bootstrap method for a dynamic\n    \/\/ call site.  If resolution for the java.lang.invoke.MethodHandle for the bootstrap\n    \/\/ method fails, then a MethodHandleInError is stored at the corresponding bootstrap\n    \/\/ method's CP index for the CONSTANT_MethodHandle_info.  So, there is no need to\n    \/\/ set the indy_rf flag since any subsequent invokedynamic instruction which shares\n    \/\/ this bootstrap method will encounter the resolution of MethodHandleInError.\n    oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD);\n    Exceptions::wrap_dynamic_exception(CHECK);\n    assert(bsm_info != NULL, \"\");\n    \/\/ FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic.\n    bootstrap_specifier = Handle(THREAD, bsm_info);\n  }\n  if (!cpce->is_f1_null()) {\n    methodHandle method(     THREAD, cpce->f1_as_method());\n    Handle       appendix(   THREAD, cpce->appendix_if_resolved(pool));\n    Handle       method_type(THREAD, cpce->method_type_if_resolved(pool));\n    result.set_handle(method, appendix, method_type, THREAD);\n    Exceptions::wrap_dynamic_exception(CHECK);\n    return;\n  }\n\n  if (TraceMethodHandles) {\n    ResourceMark rm(THREAD);\n    tty->print_cr(\"resolve_invokedynamic #%d %s %s in %s\",\n                  ConstantPool::decode_invokedynamic_index(index),\n                  method_name->as_C_string(), method_signature->as_C_string(),\n                  current_klass->name()->as_C_string());\n    tty->print(\"  BSM info: \"); bootstrap_specifier->print();\n  }\n\n  resolve_dynamic_call(result, pool_index, bootstrap_specifier, method_name,\n                       method_signature, current_klass, THREAD);\n  if (HAS_PENDING_EXCEPTION && PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {\n    int encoded_index = ResolutionErrorTable::encode_cpcache_index(index);\n    bool recorded_res_status = cpce->save_and_throw_indy_exc(pool, pool_index,\n                                                             encoded_index,\n                                                             pool()->tag_at(pool_index),\n                                                             CHECK);\n    if (!recorded_res_status) {\n      \/\/ Another thread got here just before we did.  So, either use the method\n      \/\/ that it resolved or throw the LinkageError exception that it threw.\n      if (!cpce->is_f1_null()) {\n        methodHandle method(     THREAD, cpce->f1_as_method());\n        Handle       appendix(   THREAD, cpce->appendix_if_resolved(pool));\n        Handle       method_type(THREAD, cpce->method_type_if_resolved(pool));\n        result.set_handle(method, appendix, method_type, THREAD);\n        Exceptions::wrap_dynamic_exception(CHECK);\n      } else {\n        assert(cpce->indy_resolution_failed(), \"Resolution failure flag not set\");\n        ConstantPool::throw_resolution_error(pool, encoded_index, CHECK);\n      }\n      return;\n    }\n    assert(cpce->indy_resolution_failed(), \"Resolution failure flag wasn't set\");\n  }\n}","target":0,"code_token_length":848,"total_token_length":1084,"max_tokens_setting":2048}
+{"idx":486822,"func":"static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)\n{\n    CadenceGEMState *s = qemu_get_nic_opaque(nc);\n    unsigned   rxbufsize, bytes_to_copy;\n    unsigned   rxbuf_offset;\n    uint8_t   *rxbuf_ptr;\n    bool first_desc = true;\n    int maf;\n    int q = 0;\n\n    \/* Is this destination MAC address \"for us\" ? *\/\n    maf = gem_mac_address_filter(s, buf);\n    if (maf == GEM_RX_REJECT) {\n        return size;  \/* no, drop siliently b\/c it's not an error *\/\n    }\n\n    \/* Discard packets with receive length error enabled ? *\/\n    if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) {\n        unsigned type_len;\n\n        \/* Fish the ethertype \/ length field out of the RX packet *\/\n        type_len = buf[12] << 8 | buf[13];\n        \/* It is a length field, not an ethertype *\/\n        if (type_len < 0x600) {\n            if (size < type_len) {\n                \/* discard *\/\n                return -1;\n            }\n        }\n    }\n\n    \/*\n     * Determine configured receive buffer offset (probably 0)\n     *\/\n    rxbuf_offset = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >>\n                   GEM_NWCFG_BUFF_OFST_S;\n\n    \/* The configure size of each receive buffer.  Determines how many\n     * buffers needed to hold this packet.\n     *\/\n    rxbufsize = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >>\n                 GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL;\n    bytes_to_copy = size;\n\n    \/* Hardware allows a zero value here but warns against it. To avoid QEMU\n     * indefinite loops we enforce a minimum value here\n     *\/\n    if (rxbufsize < GEM_DMACFG_RBUFSZ_MUL) {\n        rxbufsize = GEM_DMACFG_RBUFSZ_MUL;\n    }\n\n    \/* Pad to minimum length. Assume FCS field is stripped, logic\n     * below will increment it to the real minimum of 64 when\n     * not FCS stripping\n     *\/\n    if (size < 60) {\n        size = 60;\n    }\n\n    \/* Strip of FCS field ? (usually yes) *\/\n    if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) {\n        rxbuf_ptr = (void *)buf;\n    } else {\n        unsigned crc_val;\n\n        if (size > MAX_FRAME_SIZE - sizeof(crc_val)) {\n            size = MAX_FRAME_SIZE - sizeof(crc_val);\n        }\n        bytes_to_copy = size;\n        \/* The application wants the FCS field, which QEMU does not provide.\n         * We must try and calculate one.\n         *\/\n\n        memcpy(s->rx_packet, buf, size);\n        memset(s->rx_packet + size, 0, MAX_FRAME_SIZE - size);\n        rxbuf_ptr = s->rx_packet;\n        crc_val = cpu_to_le32(crc32(0, s->rx_packet, MAX(size, 60)));\n        memcpy(s->rx_packet + size, &crc_val, sizeof(crc_val));\n\n        bytes_to_copy += 4;\n        size += 4;\n    }\n\n    DB_PRINT(\"config bufsize: %u packet size: %zd\\n\", rxbufsize, size);\n\n    \/* Find which queue we are targeting *\/\n    q = get_queue_from_screen(s, rxbuf_ptr, rxbufsize);\n\n    if (size > gem_get_max_buf_len(s, false)) {\n        qemu_log_mask(LOG_GUEST_ERROR, \"rx frame too long\\n\");\n        gem_set_isr(s, q, GEM_INT_AMBA_ERR);\n        return -1;\n    }\n\n    while (bytes_to_copy) {\n        hwaddr desc_addr;\n\n        \/* Do nothing if receive is not enabled. *\/\n        if (!gem_can_receive(nc)) {\n            return -1;\n        }\n\n        DB_PRINT(\"copy %\" PRIu32 \" bytes to 0x%\" PRIx64 \"\\n\",\n                MIN(bytes_to_copy, rxbufsize),\n                rx_desc_get_buffer(s, s->rx_desc[q]));\n\n        \/* Copy packet data to emulated DMA buffer *\/\n        address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +\n                                                                  rxbuf_offset,\n                            MEMTXATTRS_UNSPECIFIED, rxbuf_ptr,\n                            MIN(bytes_to_copy, rxbufsize));\n        rxbuf_ptr += MIN(bytes_to_copy, rxbufsize);\n        bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);\n\n        rx_desc_clear_control(s->rx_desc[q]);\n\n        \/* Update the descriptor.  *\/\n        if (first_desc) {\n            rx_desc_set_sof(s->rx_desc[q]);\n            first_desc = false;\n        }\n        if (bytes_to_copy == 0) {\n            rx_desc_set_eof(s->rx_desc[q]);\n            rx_desc_set_length(s->rx_desc[q], size);\n        }\n        rx_desc_set_ownership(s->rx_desc[q]);\n\n        switch (maf) {\n        case GEM_RX_PROMISCUOUS_ACCEPT:\n            break;\n        case GEM_RX_BROADCAST_ACCEPT:\n            rx_desc_set_broadcast(s->rx_desc[q]);\n            break;\n        case GEM_RX_UNICAST_HASH_ACCEPT:\n            rx_desc_set_unicast_hash(s->rx_desc[q]);\n            break;\n        case GEM_RX_MULTICAST_HASH_ACCEPT:\n            rx_desc_set_multicast_hash(s->rx_desc[q]);\n            break;\n        case GEM_RX_REJECT:\n            abort();\n        default: \/* SAR *\/\n            rx_desc_set_sar(s->rx_desc[q], maf);\n        }\n\n        \/* Descriptor write-back.  *\/\n        desc_addr = gem_get_rx_desc_addr(s, q);\n        address_space_write(&s->dma_as, desc_addr, MEMTXATTRS_UNSPECIFIED,\n                            s->rx_desc[q],\n                            sizeof(uint32_t) * gem_get_desc_len(s, true));\n\n        \/* Next descriptor *\/\n        if (rx_desc_get_wrap(s->rx_desc[q])) {\n            DB_PRINT(\"wrapping RX descriptor list\\n\");\n            s->rx_desc_addr[q] = gem_get_rx_queue_base_addr(s, q);\n        } else {\n            DB_PRINT(\"incrementing RX descriptor list\\n\");\n            s->rx_desc_addr[q] += 4 * gem_get_desc_len(s, true);\n        }\n\n        gem_get_rx_desc(s, q);\n    }\n\n    \/* Count it *\/\n    gem_receive_updatestats(s, buf, size);\n\n    s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD;\n    gem_set_isr(s, q, GEM_INT_RXCMPL);\n\n    \/* Handle interrupt consequences *\/\n    gem_update_int_status(s);\n\n    return size;\n}","target":0,"code_token_length":1495,"total_token_length":1731,"max_tokens_setting":2048}
+{"idx":219003,"func":"bool ConstantFolding::MergeConcat(bool use_shape_info,\n                                  GraphProperties* properties,\n                                  GraphDef* optimized_graph, NodeDef* node) {\n  \/\/ We only optimize for ConcatV2.\n  int axis;\n  if (!use_shape_info || !GetConcatAxis(*node, &axis) ||\n      nodes_to_preserve_.find(node->name()) != nodes_to_preserve_.end() ||\n      node_map_->GetOutputs(node->name()).size() != 1) {\n    return false;\n  }\n\n  \/\/ If all inputs are constant, don't merge and let folding take case of it.\n  const int num_regular_inputs = NumNonControlInputs(*node);\n  bool all_inputs_are_const = true;\n  for (int i = 0; i < num_regular_inputs - 1; ++i) {\n    const NodeDef* input_node = node_map_->GetNode(node->input(i));\n    if (!IsReallyConstant(*input_node)) {\n      all_inputs_are_const = false;\n      break;\n    }\n  }\n  if (all_inputs_are_const) return false;\n\n  NodeDef* parent = *node_map_->GetOutputs(node->name()).begin();\n  int parent_axis;\n  if (!GetConcatAxis(*parent, &parent_axis) || axis != parent_axis) {\n    return false;\n  }\n\n  \/\/ Make a pass over the parent inputs to see if any of them have explicit\n  \/\/ device() fields set, and if different inputs are on different tasks.  If\n  \/\/ so, this concat of concats may have been carefully constructed to be a\n  \/\/ two-stage concat, and we don't want to undo that here.\n  string task, device;\n  absl::flat_hash_set<string> unique_input_tasks;\n  const int n_parent_inputs = NumNonControlInputs(*parent);\n  \/\/ Iterate over the real inputs to concatenate [0..n_parent_inputs - 1).  The\n  \/\/ input at n_parent_inputs - 1 is the concat axis argument for a ConcatV2\n  \/\/ node, which we don't want to consider here.\n  for (int i = 0; i < n_parent_inputs - 1; ++i) {\n    const NodeDef* input_node = node_map_->GetNode(parent->input(i));\n    if (!input_node->device().empty() &&\n        tensorflow::DeviceNameUtils::SplitDeviceName(input_node->device(),\n                                                     &task, &device)) {\n      unique_input_tasks.insert(task);\n      if (unique_input_tasks.size() >= 2) {\n        \/\/ More than one input task represented in the device specifications\n        \/\/ of the parent's input nodes.  Don't mess with this.\n        return false;\n      }\n    }\n  }\n\n  protobuf::RepeatedPtrField<string> parent_inputs;\n  parent_inputs.Swap(parent->mutable_input());\n  \/\/ TODO(rmlarsen): IF the child occurs more than once, is it beneficial to\n  \/\/ collapse it into the parent multiple times? Probably not.\n  for (const auto& input : parent_inputs) {\n    if (IsSameInput(input, node->name())) {\n      for (int j = 0; j < num_regular_inputs - 1; ++j) {\n        \/\/ Add tensor inputs to first child concat tensors (except the final\n        \/\/ axis input) to the parent's inputs.\n        parent->add_input(node->input(j));\n        node_map_->UpdateInput(parent->name(), node->name(), node->input(j));\n      }\n    } else {\n      parent->add_input(input);\n    }\n  }\n  \/\/ Forward Add control inputs\n  const int num_inputs = node->input_size();\n  for (int i = num_inputs - 1; i >= num_regular_inputs; --i) {\n    parent->add_input(node->input(i));\n    node_map_->UpdateInput(parent->name(), node->name(), node->input(i));\n    node->mutable_input()->RemoveLast();\n  }\n  (*parent->mutable_attr())[\"N\"].set_i(NumNonControlInputs(*parent) - 1);\n  DedupControlInputs(parent);\n  ReplaceOperationWithNoOp(node, properties, optimized_graph);\n\n  return true;\n}","target":0,"code_token_length":869,"total_token_length":1105,"max_tokens_setting":2048}
+{"idx":207780,"func":"static RList *create_cache_bins(RBinFile *bf, RDyldCache *cache) {\n\tRList *bins = r_list_newf ((RListFree)free_bin);\n\tut16 *depArray = NULL;\n\tcache_imgxtr_t *extras = NULL;\n\tif (!bins) {\n\t\treturn NULL;\n\t}\n\n\tchar *target_libs = NULL;\n\tRList *target_lib_names = NULL;\n\tint *deps = NULL;\n\ttarget_libs = r_sys_getenv (\"R_DYLDCACHE_FILTER\");\n\tif (target_libs) {\n\t\ttarget_lib_names = r_str_split_list (target_libs, \":\", 0);\n\t\tif (!target_lib_names) {\n\t\t\tr_list_free (bins);\n\t\t\treturn NULL;\n\t\t}\n\t\tdeps = R_NEWS0 (int, cache->hdr->imagesCount);\n\t\tif (!deps) {\n\t\t\tr_list_free (bins);\n\t\t\tr_list_free (target_lib_names);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tut32 i;\n\tfor (i = 0; i < cache->n_hdr; i++) {\n\t\tcache_hdr_t *hdr = &cache->hdr[i];\n\t\tut64 hdr_offset = cache->hdr_offset[i];\n\t\tut32 maps_index = cache->maps_index[i];\n\t\tcache_img_t *img = read_cache_images (cache->buf, hdr, hdr_offset);\n\t\tif (!img) {\n\t\t\tgoto next;\n\t\t}\n\n\t\tut32 j;\n\t\tif (target_libs) {\n\t\t\tHtPU *path_to_idx = NULL;\n\t\t\tif (cache->accel) {\n\t\t\t\tdepArray = R_NEWS0 (ut16, cache->accel->depListCount);\n\t\t\t\tif (!depArray) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\n\t\t\t\tif (r_buf_fread_at (cache->buf, cache->accel->depListOffset, (ut8*) depArray, \"s\", cache->accel->depListCount) != cache->accel->depListCount * 2) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\n\t\t\t\textras = read_cache_imgextra (cache->buf, hdr, cache->accel);\n\t\t\t\tif (!extras) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpath_to_idx = create_path_to_index (cache->buf, img, hdr);\n\t\t\t}\n\n\t\t\tfor (j = 0; j < hdr->imagesCount; j++) {\n\t\t\t\tbool printing = !deps[j];\n\t\t\t\tchar *lib_name = get_lib_name (cache->buf, &img[j]);\n\t\t\t\tif (!lib_name) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (strstr (lib_name, \"libobjc.A.dylib\")) {\n\t\t\t\t\tdeps[j]++;\n\t\t\t\t}\n\t\t\t\tif (!r_list_find (target_lib_names, lib_name, string_contains)) {\n\t\t\t\t\tR_FREE (lib_name);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (printing) {\n\t\t\t\t\teprintf (\"FILTER: %s\\n\", lib_name);\n\t\t\t\t}\n\t\t\t\tR_FREE (lib_name);\n\t\t\t\tdeps[j]++;\n\n\t\t\t\tif (extras && depArray) {\n\t\t\t\t\tut32 k;\n\t\t\t\t\tfor (k = extras[j].dependentsStartArrayIndex; depArray[k] != 0xffff; k++) {\n\t\t\t\t\t\tut16 dep_index = depArray[k] & 0x7fff;\n\t\t\t\t\t\tdeps[dep_index]++;\n\n\t\t\t\t\t\tchar *dep_name = get_lib_name (cache->buf, &img[dep_index]);\n\t\t\t\t\t\tif (!dep_name) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (printing) {\n\t\t\t\t\t\t\teprintf (\"-> %s\\n\", dep_name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfree (dep_name);\n\t\t\t\t\t}\n\t\t\t\t} else if (path_to_idx) {\n\t\t\t\t\tcarve_deps_at_address (cache, img, path_to_idx, img[j].address, deps, printing);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tht_pu_free (path_to_idx);\n\t\t\tR_FREE (depArray);\n\t\t\tR_FREE (extras);\n\t\t}\n\n\t\tfor (j = 0; j < hdr->imagesCount; j++) {\n\t\t\tif (deps && !deps[j]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tut64 pa = va2pa (img[j].address, hdr->mappingCount, &cache->maps[maps_index], cache->buf, 0, NULL, NULL);\n\t\t\tif (pa == UT64_MAX) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tut8 magicbytes[4];\n\t\t\tr_buf_read_at (cache->buf, pa, magicbytes, 4);\n\t\t\tint magic = r_read_le32 (magicbytes);\n\t\t\tswitch (magic) {\n\t\t\tcase MH_MAGIC_64:\n\t\t\t{\n\t\t\t\tchar file[256];\n\t\t\t\tRDyldBinImage *bin = R_NEW0 (RDyldBinImage);\n\t\t\t\tif (!bin) {\n\t\t\t\t\tgoto next;\n\t\t\t\t}\n\t\t\t\tbin->header_at = pa;\n\t\t\t\tbin->hdr_offset = hdr_offset;\n\t\t\t\tbin->symbols_off = resolve_symbols_off (cache, pa);\n\t\t\t\tbin->va = img[j].address;\n\t\t\t\tif (r_buf_read_at (cache->buf, img[j].pathFileOffset, (ut8*) &file, sizeof (file)) == sizeof (file)) {\n\t\t\t\t\tfile[255] = 0;\n\t\t\t\t\tchar *last_slash = strrchr (file, '\/');\n\t\t\t\t\tif (last_slash && *last_slash) {\n\t\t\t\t\t\tif (last_slash > file) {\n\t\t\t\t\t\t\tchar *scan = last_slash - 1;\n\t\t\t\t\t\t\twhile (scan > file && *scan != '\/') {\n\t\t\t\t\t\t\t\tscan--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (*scan == '\/') {\n\t\t\t\t\t\t\t\tbin->file = strdup (scan + 1);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tbin->file = strdup (last_slash + 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbin->file = strdup (last_slash + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbin->file = strdup (file);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tr_list_append (bins, bin);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\teprintf (\"Unknown sub-bin\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\nnext:\n\t\tR_FREE (depArray);\n\t\tR_FREE (extras);\n\t\tR_FREE (img);\n\t}\n\tif (r_list_empty (bins)) {\n\t\tr_list_free (bins);\n\t\tbins = NULL;\n\t}\n\tR_FREE (deps);\n\tR_FREE (target_libs);\n\tr_list_free (target_lib_names);\n\treturn bins;\n}","target":1,"code_token_length":1378,"total_token_length":1614,"max_tokens_setting":2048}
+{"idx":308183,"func":"static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)\n{\n\tstruct device *dev = ctx->fl->sctx->dev;\n\tstruct fastrpc_remote_arg *rpra;\n\tstruct fastrpc_invoke_buf *list;\n\tstruct fastrpc_phy_page *pages;\n\tint inbufs, i, oix, err = 0;\n\tu64 len, rlen, pkt_size;\n\tu64 pg_start, pg_end;\n\tuintptr_t args;\n\tint metalen;\n\n\tinbufs = REMOTE_SCALARS_INBUFS(ctx->sc);\n\tmetalen = fastrpc_get_meta_size(ctx);\n\tpkt_size = fastrpc_get_payload_size(ctx, metalen);\n\n\terr = fastrpc_create_maps(ctx);\n\tif (err)\n\t\treturn err;\n\n\tctx->msg_sz = pkt_size;\n\n\terr = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);\n\tif (err)\n\t\treturn err;\n\n\trpra = ctx->buf->virt;\n\tlist = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);\n\tpages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +\n\t\tsizeof(*rpra));\n\targs = (uintptr_t)ctx->buf->virt + metalen;\n\trlen = pkt_size - metalen;\n\tctx->rpra = rpra;\n\n\tfor (oix = 0; oix < ctx->nbufs; ++oix) {\n\t\tint mlen;\n\n\t\ti = ctx->olaps[oix].raix;\n\t\tlen = ctx->args[i].length;\n\n\t\trpra[i].pv = 0;\n\t\trpra[i].len = len;\n\t\tlist[i].num = len ? 1 : 0;\n\t\tlist[i].pgidx = i;\n\n\t\tif (!len)\n\t\t\tcontinue;\n\n\t\tif (ctx->maps[i]) {\n\t\t\tstruct vm_area_struct *vma = NULL;\n\n\t\t\trpra[i].pv = (u64) ctx->args[i].ptr;\n\t\t\tpages[i].addr = ctx->maps[i]->phys;\n\n\t\t\tvma = find_vma(current->mm, ctx->args[i].ptr);\n\t\t\tif (vma)\n\t\t\t\tpages[i].addr += ctx->args[i].ptr -\n\t\t\t\t\t\t vma->vm_start;\n\n\t\t\tpg_start = (ctx->args[i].ptr & PAGE_MASK) >> PAGE_SHIFT;\n\t\t\tpg_end = ((ctx->args[i].ptr + len - 1) & PAGE_MASK) >>\n\t\t\t\t  PAGE_SHIFT;\n\t\t\tpages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE;\n\n\t\t} else {\n\n\t\t\tif (ctx->olaps[oix].offset == 0) {\n\t\t\t\trlen -= ALIGN(args, FASTRPC_ALIGN) - args;\n\t\t\t\targs = ALIGN(args, FASTRPC_ALIGN);\n\t\t\t}\n\n\t\t\tmlen = ctx->olaps[oix].mend - ctx->olaps[oix].mstart;\n\n\t\t\tif (rlen < mlen)\n\t\t\t\tgoto bail;\n\n\t\t\trpra[i].pv = args - ctx->olaps[oix].offset;\n\t\t\tpages[i].addr = ctx->buf->phys -\n\t\t\t\t\tctx->olaps[oix].offset +\n\t\t\t\t\t(pkt_size - rlen);\n\t\t\tpages[i].addr = pages[i].addr &\tPAGE_MASK;\n\n\t\t\tpg_start = (args & PAGE_MASK) >> PAGE_SHIFT;\n\t\t\tpg_end = ((args + len - 1) & PAGE_MASK) >> PAGE_SHIFT;\n\t\t\tpages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE;\n\t\t\targs = args + mlen;\n\t\t\trlen -= mlen;\n\t\t}\n\n\t\tif (i < inbufs && !ctx->maps[i]) {\n\t\t\tvoid *dst = (void *)(uintptr_t)rpra[i].pv;\n\t\t\tvoid *src = (void *)(uintptr_t)ctx->args[i].ptr;\n\n\t\t\tif (!kernel) {\n\t\t\t\tif (copy_from_user(dst, (void __user *)src,\n\t\t\t\t\t\t   len)) {\n\t\t\t\t\terr = -EFAULT;\n\t\t\t\t\tgoto bail;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmemcpy(dst, src, len);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (i = ctx->nbufs; i < ctx->nscalars; ++i) {\n\t\trpra[i].pv = (u64) ctx->args[i].ptr;\n\t\trpra[i].len = ctx->args[i].length;\n\t\tlist[i].num = ctx->args[i].length ? 1 : 0;\n\t\tlist[i].pgidx = i;\n\t\tpages[i].addr = ctx->maps[i]->phys;\n\t\tpages[i].size = ctx->maps[i]->size;\n\t}\n\nbail:\n\tif (err)\n\t\tdev_err(dev, \"Error: get invoke args failed:%d\\n\", err);\n\n\treturn err;\n}","target":0,"code_token_length":1035,"total_token_length":1271,"max_tokens_setting":2048}
+{"idx":195246,"func":"static s32 avc_parse_slice(GF_BitStream *bs, AVCState *avc, Bool svc_idr_flag, AVCSliceInfo *si)\n{\n\ts32 pps_id, num_ref_idx_l0_active_minus1 = 0, num_ref_idx_l1_active_minus1 = 0;\n\n\t\/*s->current_picture.reference= h->nal_ref_idc != 0;*\/\n\tgf_bs_read_ue_log(bs, \"first_mb_in_slice\");\n\tsi->slice_type = gf_bs_read_ue_log(bs, \"slice_type\");\n\tif (si->slice_type > 9) return -1;\n\n\tpps_id = gf_bs_read_ue_log(bs, \"pps_id\");\n\tif (pps_id > 255) return -1;\n\tsi->pps = &avc->pps[pps_id];\n\tif (!si->pps->slice_group_count) return -2;\n\tsi->sps = &avc->sps[si->pps->sps_id];\n\tif (!si->sps->log2_max_frame_num) return -2;\n\tavc->sps_active_idx = si->pps->sps_id;\n\tavc->pps_active_idx = pps_id;\n\n\tsi->frame_num = gf_bs_read_int_log(bs, si->sps->log2_max_frame_num, \"frame_num\");\n\n\tsi->field_pic_flag = 0;\n\tsi->bottom_field_flag = 0;\n\tif (!si->sps->frame_mbs_only_flag) {\n\t\tsi->field_pic_flag = gf_bs_read_int_log(bs, 1, \"field_pic_flag\");\n\t\tif (si->field_pic_flag)\n\t\t\tsi->bottom_field_flag = gf_bs_read_int_log(bs, 1, \"bottom_field_flag\");\n\t}\n\n\tif ((si->nal_unit_type == GF_AVC_NALU_IDR_SLICE) || svc_idr_flag)\n\t\tsi->idr_pic_id = gf_bs_read_ue_log(bs, \"idr_pic_id\");\n\n\tif (si->sps->poc_type == 0) {\n\t\tsi->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, \"poc_lsb\");\n\t\tif (si->pps->pic_order_present && !si->field_pic_flag) {\n\t\t\tsi->delta_poc_bottom = gf_bs_read_se_log(bs, \"poc_lsb\");\n\t\t}\n\t}\n\telse if ((si->sps->poc_type == 1) && !si->sps->delta_pic_order_always_zero_flag) {\n\t\tsi->delta_poc[0] = gf_bs_read_se_log(bs, \"delta_poc0\");\n\t\tif ((si->pps->pic_order_present == 1) && !si->field_pic_flag)\n\t\t\tsi->delta_poc[1] = gf_bs_read_se_log(bs, \"delta_poc1\");\n\t}\n\n\tif (si->pps->redundant_pic_cnt_present) {\n\t\tsi->redundant_pic_cnt = gf_bs_read_ue_log(bs, \"redundant_pic_cnt\");\n\t}\n\n\tif (si->slice_type % 5 == GF_AVC_TYPE_B) {\n\t\tgf_bs_read_int_log(bs, 1, \"direct_spatial_mv_pred_flag\");\n\t}\n\n\tnum_ref_idx_l0_active_minus1 = si->pps->num_ref_idx_l0_default_active_minus1;\n\tnum_ref_idx_l1_active_minus1 = si->pps->num_ref_idx_l1_default_active_minus1;\n\n\tif (si->slice_type % 5 == GF_AVC_TYPE_P || si->slice_type % 5 == GF_AVC_TYPE_SP || si->slice_type % 5 == GF_AVC_TYPE_B) {\n\t\tBool num_ref_idx_active_override_flag = gf_bs_read_int_log(bs, 1, \"num_ref_idx_active_override_flag\");\n\t\tif (num_ref_idx_active_override_flag) {\n\t\t\tnum_ref_idx_l0_active_minus1 = gf_bs_read_ue_log(bs, \"num_ref_idx_l0_active_minus1\");\n\t\t\tif (si->slice_type % 5 == GF_AVC_TYPE_B) {\n\t\t\t\tnum_ref_idx_l1_active_minus1 = gf_bs_read_ue_log(bs, \"num_ref_idx_l1_active_minus1\");\n\t\t\t}\n\t\t}\n\t}\n\n\tif (si->nal_unit_type == 20 || si->nal_unit_type == 21) {\n\t\t\/\/ref_pic_list_mvc_modification(); \/* specified in Annex H *\/\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[avc-h264] unimplemented ref_pic_list_mvc_modification() in slide header\\n\"));\n\t\tassert(0);\n\t\treturn -1;\n\t}\n\telse {\n\t\tref_pic_list_modification(bs, si->slice_type);\n\t}\n\n\tif ((si->pps->weighted_pred_flag && (si->slice_type % 5 == GF_AVC_TYPE_P || si->slice_type % 5 == GF_AVC_TYPE_SP))\n\t\t|| (si->pps->weighted_bipred_idc == 1 && si->slice_type % 5 == GF_AVC_TYPE_B)) {\n\t\tpred_weight_table(bs, si->slice_type, si->sps->ChromaArrayType, num_ref_idx_l0_active_minus1, num_ref_idx_l1_active_minus1);\n\t}\n\n\tif (si->nal_ref_idc != 0) {\n\t\tdec_ref_pic_marking(bs, (si->nal_unit_type == GF_AVC_NALU_IDR_SLICE));\n\t}\n\n\tif (si->pps->entropy_coding_mode_flag && si->slice_type % 5 != GF_AVC_TYPE_I && si->slice_type % 5 != GF_AVC_TYPE_SI) {\n\t\tgf_bs_read_ue_log(bs, \"cabac_init_idc\");\n\t}\n\n\t\/*slice_qp_delta = *\/gf_bs_read_se(bs);\n\tif (si->slice_type % 5 == GF_AVC_TYPE_SP || si->slice_type % 5 == GF_AVC_TYPE_SI) {\n\t\tif (si->slice_type % 5 == GF_AVC_TYPE_SP) {\n\t\t\tgf_bs_read_int_log(bs, 1, \"sp_for_switch_flag\");\n\t\t}\n\t\tgf_bs_read_se_log(bs, \"slice_qs_delta\");\n\t}\n\n\tif (si->pps->deblocking_filter_control_present_flag) {\n\t\tif (gf_bs_read_ue_log(bs, \"disable_deblocking_filter_idc\") != 1) {\n\t\t\tgf_bs_read_se_log(bs, \"slice_alpha_c0_offset_div2\");\n\t\t\tgf_bs_read_se_log(bs, \"slice_beta_offset_div2\");\n\t\t}\n\t}\n\n\tif (si->pps->slice_group_count > 1 && si->pps->mb_slice_group_map_type >= 3 && si->pps->mb_slice_group_map_type <= 5) {\n\t\tgf_bs_read_int_log(bs, (u32)ceil(log1p((si->pps->pic_size_in_map_units_minus1 + 1) \/ (si->pps->slice_group_change_rate_minus1 + 1) ) \/ log(2)), \"slice_group_change_cycle\");\n\t}\n\treturn 0;\n}","target":1,"code_token_length":1516,"total_token_length":1752,"max_tokens_setting":2048}
+{"idx":508783,"func":"bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,\n\t\t      SQL_SELECT *select,\n                      SORT_INFO *filesort,\n\t\t      int use_record_cache, bool print_error, \n                      bool disable_rr_cache)\n{\n  IO_CACHE *tempfile;\n  SORT_ADDON_FIELD *addon_field= filesort ? filesort->addon_field : 0;\n  DBUG_ENTER(\"init_read_record\");\n\n  bzero((char*) info,sizeof(*info));\n  info->thd=thd;\n  info->table=table;\n  info->forms= &info->table;\t\t\/* Only one table *\/\n  info->addon_field= addon_field;\n  \n  if ((table->s->tmp_table == INTERNAL_TMP_TABLE) &&\n      !addon_field)\n    (void) table->file->extra(HA_EXTRA_MMAP);\n  \n  if (addon_field)\n  {\n    info->rec_buf=    (uchar*) filesort->addon_buf.str;\n    info->ref_length= filesort->addon_buf.length;\n    info->unpack=     filesort->unpack;\n  }\n  else\n  {\n    empty_record(table);\n    info->record= table->record[0];\n    info->ref_length= table->file->ref_length;\n  }\n  info->select=select;\n  info->print_error=print_error;\n  info->unlock_row= rr_unlock_row;\n  info->ignore_not_found_rows= 0;\n  table->status= 0;\t\t\t\/* Rows are always found *\/\n\n  tempfile= 0;\n  if (select && my_b_inited(&select->file))\n    tempfile= &select->file;\n  else if (filesort && my_b_inited(&filesort->io_cache))\n    tempfile= &filesort->io_cache;\n\n  if (tempfile && !(select && select->quick))\n  {\n    DBUG_PRINT(\"info\",(\"using rr_from_tempfile\"));\n    info->read_record= (addon_field ?\n                        rr_unpack_from_tempfile : rr_from_tempfile);\n    info->io_cache= tempfile;\n    reinit_io_cache(info->io_cache,READ_CACHE,0L,0,0);\n    info->ref_pos=table->file->ref;\n    if (!table->file->inited)\n      if (table->file->ha_rnd_init_with_error(0))\n        DBUG_RETURN(1);\n\n    \/*\n      addon_field is checked because if we use addon fields,\n      it doesn't make sense to use cache - we don't read from the table\n      and filesort->io_cache is read sequentially\n    *\/\n    if (!disable_rr_cache &&\n        !addon_field &&\n\tthd->variables.read_rnd_buff_size &&\n\t!(table->file->ha_table_flags() & HA_FAST_KEY_READ) &&\n\t(table->db_stat & HA_READ_ONLY ||\n\t table->reginfo.lock_type <= TL_READ_NO_INSERT) &&\n\t(ulonglong) table->s->reclength* (table->file->stats.records+\n                                          table->file->stats.deleted) >\n\t(ulonglong) MIN_FILE_LENGTH_TO_USE_ROW_CACHE &&\n\tinfo->io_cache->end_of_file\/info->ref_length * table->s->reclength >\n\t(my_off_t) MIN_ROWS_TO_USE_TABLE_CACHE &&\n\t!table->s->blob_fields &&\n        info->ref_length <= MAX_REFLENGTH)\n    {\n      if (! init_rr_cache(thd, info))\n      {\n\tDBUG_PRINT(\"info\",(\"using rr_from_cache\"));\n\tinfo->read_record=rr_from_cache;\n      }\n    }\n  }\n  else if (select && select->quick)\n  {\n    DBUG_PRINT(\"info\",(\"using rr_quick\"));\n    info->read_record=rr_quick;\n  }\n  else if (filesort && filesort->record_pointers)\n  {\n    DBUG_PRINT(\"info\",(\"using record_pointers\"));\n    if (table->file->ha_rnd_init_with_error(0))\n      DBUG_RETURN(1);\n    info->cache_pos= filesort->record_pointers;\n    info->cache_end= (info->cache_pos+ \n                      filesort->return_rows * info->ref_length);\n    info->read_record= (addon_field ?\n                        rr_unpack_from_buffer : rr_from_pointers);\n  }\n  else if (table->file->keyread_enabled())\n  {\n    int error;\n    info->read_record= rr_index_first;\n    if (!table->file->inited &&\n        (error= table->file->ha_index_init(table->file->keyread, 1)))\n    {\n      if (print_error)\n        table->file->print_error(error, MYF(0));\n      DBUG_RETURN(1);\n    }\n  }\n  else\n  {\n    DBUG_PRINT(\"info\",(\"using rr_sequential\"));\n    info->read_record=rr_sequential;\n    if (table->file->ha_rnd_init_with_error(1))\n      DBUG_RETURN(1);\n    \/* We can use record cache if we don't update dynamic length tables *\/\n    if (!table->no_cache &&\n\t(use_record_cache > 0 ||\n\t (int) table->reginfo.lock_type <= (int) TL_READ_HIGH_PRIORITY ||\n\t !(table->s->db_options_in_use & HA_OPTION_PACK_RECORD) ||\n\t (use_record_cache < 0 &&\n\t  !(table->file->ha_table_flags() & HA_NOT_DELETE_WITH_CACHE))))\n      (void) table->file->extra_opt(HA_EXTRA_CACHE,\n                                    thd->variables.read_buff_size);\n  }\n  \/* Condition pushdown to storage engine *\/\n  if ((table->file->ha_table_flags() & HA_CAN_TABLE_CONDITION_PUSHDOWN) &&\n      select && select->cond && \n      (select->cond->used_tables() & table->map) &&\n      !table->file->pushed_cond)\n    table->file->cond_push(select->cond);\n\n  DBUG_RETURN(0);\n} \/* init_read_record *\/","target":0,"code_token_length":1242,"total_token_length":1478,"max_tokens_setting":2048}
+{"idx":328916,"func":"R_API ConstJavaValue *U(r_bin_java_resolve_to_const_value)(RBinJavaObj * BIN_OBJ, int idx) {\n\t\/\/ TODO XXX FIXME add a size parameter to the str when it is passed in\n\tRBinJavaCPTypeObj *item = NULL, *item2 = NULL;\n\tConstJavaValue *result = R_NEW0 (ConstJavaValue);\n\tif (!result) {\n\t\treturn NULL;\n\t}\n\tchar *class_str = NULL,\n\t*name_str = NULL,\n\t*desc_str = NULL,\n\t*string_str = NULL,\n\t*empty = \"\",\n\t*cp_name = NULL;\n\tresult->type = \"unknown\";\n\tif (BIN_OBJ && BIN_OBJ->cp_count < 1) {\n\t\t\/\/ r_bin_java_new_bin(BIN_OBJ);\n\t\treturn result;\n\t}\n\titem = (RBinJavaCPTypeObj *) r_bin_java_get_item_from_bin_cp_list (BIN_OBJ, idx);\n\tif (!item) {\n\t\treturn result;\n\t}\n\tcp_name = ((RBinJavaCPTypeMetas *) item->metas->type_info)->name;\n\tIFDBG eprintf (\"java_resolve Resolved: (%d) %s\\n\", idx, cp_name);\n\tif (strcmp (cp_name, \"Class\") == 0) {\n\t\titem2 = (RBinJavaCPTypeObj *) r_bin_java_get_item_from_bin_cp_list (BIN_OBJ, idx);\n\t\t\/\/ str = r_bin_java_get_name_from_bin_cp_list (BIN_OBJ, idx-1);\n\t\tclass_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!class_str) {\n\t\t\tclass_str = empty;\n\t\t}\n\t\tname_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item2);\n\t\tif (!name_str) {\n\t\t\tname_str = empty;\n\t\t}\n\t\tdesc_str = r_bin_java_get_item_desc_from_bin_cp_list (BIN_OBJ, item2);\n\t\tif (!desc_str) {\n\t\t\tdesc_str = empty;\n\t\t}\n\t\tresult->value._ref = R_NEW0 (_JavaRef);\n\t\tresult->type = \"ref\";\n\t\tresult->value._ref->class_name = strdup (class_str);\n\t\tresult->value._ref->name = strdup (name_str);\n\t\tresult->value._ref->desc = strdup (desc_str);\n\t\tif (class_str != empty) {\n\t\t\tfree (class_str);\n\t\t}\n\t\tif (name_str != empty) {\n\t\t\tfree (name_str);\n\t\t}\n\t\tif (desc_str != empty) {\n\t\t\tfree (desc_str);\n\t\t}\n\t} else if (strcmp (cp_name, \"MethodRef\") == 0 ||\n\tstrcmp (cp_name, \"FieldRef\") == 0 ||\n\tstrcmp (cp_name, \"InterfaceMethodRef\") == 0) {\n\t\t\/*\n\t\t*  The MethodRef, FieldRef, and InterfaceMethodRef structures\n\t\t*\/\n\t\tclass_str = r_bin_java_get_name_from_bin_cp_list (BIN_OBJ, item->info.cp_method.class_idx);\n\t\tif (!class_str) {\n\t\t\tclass_str = empty;\n\t\t}\n\t\tname_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!name_str) {\n\t\t\tname_str = empty;\n\t\t}\n\t\tdesc_str = r_bin_java_get_item_desc_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!desc_str) {\n\t\t\tdesc_str = empty;\n\t\t}\n\t\tresult->value._ref = R_NEW0 (_JavaRef);\n\t\tresult->type = \"ref\";\n\t\tresult->value._ref->class_name = strdup (class_str);\n\t\tresult->value._ref->name = strdup (name_str);\n\t\tresult->value._ref->desc = strdup (desc_str);\n\t\tif (class_str != empty) {\n\t\t\tfree (class_str);\n\t\t}\n\t\tif (name_str != empty) {\n\t\t\tfree (name_str);\n\t\t}\n\t\tif (desc_str != empty) {\n\t\t\tfree (desc_str);\n\t\t}\n\t} else if (strcmp (cp_name, \"String\") == 0) {\n\t\tut32 length = r_bin_java_get_utf8_len_from_bin_cp_list (BIN_OBJ, item->info.cp_string.string_idx);\n\t\tstring_str = r_bin_java_get_utf8_from_bin_cp_list (BIN_OBJ, item->info.cp_string.string_idx);\n\t\tIFDBG eprintf (\"java_resolve String got: (%d) %s\\n\", item->info.cp_string.string_idx, string_str);\n\t\tif (!string_str) {\n\t\t\tstring_str = empty;\n\t\t\tlength = strlen (empty);\n\t\t}\n\t\tresult->type = \"str\";\n\t\tresult->value._str = R_NEW0 (struct  java_const_value_str_t);\n\t\tresult->value._str->len = length;\n\t\tif (length > 0) {\n\t\t\tresult->value._str->str = r_str_ndup (string_str, length);\n\t\t} else {\n\t\t\tresult->value._str->str = strdup (\"\");\n\t\t}\n\t\tif (string_str != empty) {\n\t\t\tfree (string_str);\n\t\t}\n\t} else if (strcmp (cp_name, \"Utf8\") == 0) {\n\t\tresult->type = \"str\";\n\t\tresult->value._str = R_NEW0 (struct java_const_value_str_t);\n\t\tresult->value._str->str = malloc (item->info.cp_utf8.length);\n\t\tresult->value._str->len = item->info.cp_utf8.length;\n\t\tmemcpy (result->value._str->str, item->info.cp_utf8.bytes, item->info.cp_utf8.length);\n\t} else if (strcmp (cp_name, \"Long\") == 0) {\n\t\tresult->type = \"long\";\n\t\tresult->value._long = r_bin_java_raw_to_long (item->info.cp_long.bytes.raw, 0);\n\t} else if (strcmp (cp_name, \"Double\") == 0) {\n\t\tresult->type = \"double\";\n\t\tresult->value._double = r_bin_java_raw_to_double (item->info.cp_double.bytes.raw, 0);\n\t} else if (strcmp (cp_name, \"Integer\") == 0) {\n\t\tresult->type = \"int\";\n\t\tresult->value._int = R_BIN_JAVA_UINT (item->info.cp_integer.bytes.raw, 0);\n\t} else if (strcmp (cp_name, \"Float\") == 0) {\n\t\tresult->type = \"float\";\n\t\tresult->value._float = R_BIN_JAVA_FLOAT (item->info.cp_float.bytes.raw, 0);\n\t} else if (strcmp (cp_name, \"NameAndType\") == 0) {\n\t\tresult->value._ref = R_NEW0 (struct java_const_value_ref_t);\n\t\tresult->type = \"ref\";\n\t\tname_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!name_str) {\n\t\t\tname_str = empty;\n\t\t}\n\t\tdesc_str = r_bin_java_get_item_desc_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!desc_str) {\n\t\t\tdesc_str = empty;\n\t\t}\n\t\tresult->value._ref->class_name = strdup (empty);\n\t\tresult->value._ref->name = strdup (name_str);\n\t\tresult->value._ref->desc = strdup (desc_str);\n\t\tif (name_str != empty) {\n\t\t\tfree (name_str);\n\t\t}\n\t\tif (desc_str != empty) {\n\t\t\tfree (desc_str);\n\t\t}\n\t\tresult->value._ref->is_method = r_bin_java_does_cp_idx_ref_method (BIN_OBJ, idx);\n\t\tresult->value._ref->is_field = r_bin_java_does_cp_idx_ref_field (BIN_OBJ, idx);\n\t}\n\treturn result;\n}","target":0,"code_token_length":1636,"total_token_length":1872,"max_tokens_setting":2048}
+{"idx":411927,"func":"fix_transited_encoding(krb5_context context,\n\t\t       krb5_kdc_configuration *config,\n\t\t       krb5_boolean check_policy,\n\t\t       const TransitedEncoding *tr,\n\t\t       EncTicketPart *et,\n\t\t       const char *client_realm,\n\t\t       const char *server_realm,\n\t\t       const char *tgt_realm)\n{\n    krb5_error_code ret = 0;\n    char **realms, **tmp;\n    unsigned int num_realms;\n    size_t i;\n\n    switch (tr->tr_type) {\n    case domain_X500_Compress:\n\tbreak;\n    case 0:\n\t\/*\n\t * Allow empty content of type 0 because that is was Microsoft\n\t * generates in their TGT.\n\t *\/\n\tif (tr->contents.length == 0)\n\t    break;\n\tkdc_log(context, config, 4,\n\t\t\"Transited type 0 with non empty content\");\n\treturn KRB5KDC_ERR_TRTYPE_NOSUPP;\n    default:\n\tkdc_log(context, config, 4,\n\t\t\"Unknown transited type: %u\", tr->tr_type);\n\treturn KRB5KDC_ERR_TRTYPE_NOSUPP;\n    }\n\n    ret = krb5_domain_x500_decode(context,\n\t\t\t\t  tr->contents,\n\t\t\t\t  &realms,\n\t\t\t\t  &num_realms,\n\t\t\t\t  client_realm,\n\t\t\t\t  server_realm);\n    if(ret){\n\tkrb5_warn(context, ret,\n\t\t  \"Decoding transited encoding\");\n\treturn ret;\n    }\n\n    \/*\n     * If the realm of the presented tgt is neither the client nor the server\n     * realm, it is a transit realm and must be added to transited set.\n     *\/\n    if(strcmp(client_realm, tgt_realm) && strcmp(server_realm, tgt_realm)) {\n\tif (num_realms + 1 > UINT_MAX\/sizeof(*realms)) {\n\t    ret = ERANGE;\n\t    goto free_realms;\n\t}\n\ttmp = realloc(realms, (num_realms + 1) * sizeof(*realms));\n\tif(tmp == NULL){\n\t    ret = ENOMEM;\n\t    goto free_realms;\n\t}\n\trealms = tmp;\n\trealms[num_realms] = strdup(tgt_realm);\n\tif(realms[num_realms] == NULL){\n\t    ret = ENOMEM;\n\t    goto free_realms;\n\t}\n\tnum_realms++;\n    }\n    if(num_realms == 0) {\n\tif(strcmp(client_realm, server_realm))\n\t    kdc_log(context, config, 4,\n\t\t    \"cross-realm %s -> %s\", client_realm, server_realm);\n    } else {\n\tsize_t l = 0;\n\tchar *rs;\n\tfor(i = 0; i < num_realms; i++)\n\t    l += strlen(realms[i]) + 2;\n\trs = malloc(l);\n\tif(rs != NULL) {\n\t    *rs = '\\0';\n\t    for(i = 0; i < num_realms; i++) {\n\t\tif(i > 0)\n\t\t    strlcat(rs, \", \", l);\n\t\tstrlcat(rs, realms[i], l);\n\t    }\n\t    kdc_log(context, config, 4,\n\t\t    \"cross-realm %s -> %s via [%s]\",\n\t\t    client_realm, server_realm, rs);\n\t    free(rs);\n\t}\n    }\n    if(check_policy) {\n\tret = krb5_check_transited(context, client_realm,\n\t\t\t\t   server_realm,\n\t\t\t\t   realms, num_realms, NULL);\n\tif(ret) {\n\t    krb5_warn(context, ret, \"cross-realm %s -> %s\",\n\t\t      client_realm, server_realm);\n\t    goto free_realms;\n\t}\n\tet->flags.transited_policy_checked = 1;\n    }\n    et->transited.tr_type = domain_X500_Compress;\n    ret = krb5_domain_x500_encode(realms, num_realms, &et->transited.contents);\n    if(ret)\n\tkrb5_warn(context, ret, \"Encoding transited encoding\");\n  free_realms:\n    for(i = 0; i < num_realms; i++)\n\tfree(realms[i]);\n    free(realms);\n    return ret;\n}","target":0,"code_token_length":872,"total_token_length":1108,"max_tokens_setting":2048}
+{"idx":197359,"func":"Status AutoParallel::Initialize(const GrapplerItem& item) {\n  num_gpus_ = GetNumAvailableGPUs();\n  LOG(INFO) << \"Number of GPUs: \" << num_gpus_;\n  item_ = &item;\n  graph_ = item.graph;\n  LOG(INFO) << \"Original graph size: \" << graph_.node_size();\n  if (item.fetch.empty()) {\n    return Status(error::INVALID_ARGUMENT, \"No fetch nodes provided.\");\n  }\n\n  if (item.MainVariables().empty()) {\n    return Status(error::INVALID_ARGUMENT, \"No variables provided.\");\n  }\n\n  for (const auto& init : item.init_ops) {\n    VLOG(1) << \"Init node: \" << init;\n  }\n\n  for (const auto& fetch : item.fetch) {\n    VLOG(1) << \"Fetch node: \" << fetch;\n  }\n\n  for (const auto& var : item.MainVariables()) {\n    VLOG(2) << \"Variable: \" << var->name();\n  }\n\n  const std::set<string> apply_gradients_ops = {\"ApplyGradientDescent\",\n                                                \"ApplyProximalGradientDescent\",\n                                                \"ApplyAdadelta\",\n                                                \"ApplyAdagrad\",\n                                                \"ApplyProximalAdagrad\",\n                                                \"ApplyAdagradDA\",\n                                                \"ApplyFtrl\",\n                                                \"ApplyMomentum\",\n                                                \"ApplyAdam\",\n                                                \"ApplyRMSProp\",\n                                                \"ApplyCenteredRMSProp\"};\n  for (int i = 0; i < graph_.node_size(); i++) {\n    all_nodes_.insert(\n        std::make_pair(graph_.node(i).name(), graph_.mutable_node(i)));\n    if (apply_gradients_ops.find(graph_.node(i).op()) !=\n        apply_gradients_ops.end()) {\n      apply_gradients_nodes_.insert(graph_.node(i).name());\n      VLOG(2) << \"Apply gradients node: \" << graph_.node(i).name();\n    }\n  }\n\n  auto div_const_node = AddNodeDivConst();\n  all_nodes_.insert(std::make_pair(div_const_node->name(), div_const_node));\n  std::map<string, int> gradient_pos = {{\"ApplyGradientDescent\", 2},\n                                        {\"ApplyProximalGradientDescent\", 4},\n                                        {\"ApplyAdadelta\", 6},\n                                        {\"ApplyAdagrad\", 3},\n                                        {\"ApplyProximalAdagrad\", 5},\n                                        {\"ApplyAdagradDA\", 3},\n                                        {\"ApplyFtrl\", 3},\n                                        {\"ApplyMomentum\", 3},\n                                        {\"ApplyAdam\", 9},\n                                        {\"ApplyRMSProp\", 7},\n                                        {\"ApplyCenteredRMSProp\", 8}};\n  for (const auto& apply_gradient_node_name : apply_gradients_nodes_) {\n    auto apply_gradients_op = all_nodes_[apply_gradient_node_name]->op();\n    auto apply_gradients_node = all_nodes_[apply_gradient_node_name];\n\n    auto div_node = AddNodeDiv(\n        apply_gradient_node_name,\n        apply_gradients_node->input(gradient_pos[apply_gradients_op]),\n        div_const_node->name());\n    all_nodes_.insert(std::make_pair(div_node->name(), div_node));\n    *apply_gradients_node->mutable_input(gradient_pos[apply_gradients_op]) =\n        div_node->name();\n  }\n  LOG(INFO) << \"Graph size after adding div nodes: \" << all_nodes_.size();\n\n  std::vector<const NodeDef*> train_nodes;\n  TF_RETURN_IF_ERROR(ComputeTransitiveFanin(graph_, item.fetch, &train_nodes));\n  LOG(INFO) << \"Number of training nodes: \" << train_nodes.size();\n\n  const NodeDef* dequeue_node;\n  for (const auto& train_node : train_nodes) {\n    if (IsDequeueOp(*train_node)) {\n      dequeue_node = train_node;\n      break;\n    }\n  }\n\n  std::vector<const NodeDef*> input_nodes;\n  if (dequeue_node) {\n    LOG(INFO) << \"Dequeue node: \" << dequeue_node->name();\n    TF_RETURN_IF_ERROR(ComputeTransitiveFanin(graph_, {dequeue_node->name()},\n                                              {}, &input_nodes));\n  }\n  LOG(INFO) << \"Number of input nodes: \" << input_nodes.size();\n\n  std::set<string> dont_replicate_nodes;\n  for (const auto& variable : item.MainVariables()) {\n    dont_replicate_nodes.insert(variable->name());\n  }\n\n  for (const auto& init : item.init_ops) {\n    dont_replicate_nodes.insert(NodeName(init));\n  }\n\n  \/\/ Don't replicate all input nodes, except the dequeue node.\n  for (const auto& input_node : input_nodes) {\n    if (input_node->name() != dequeue_node->name()) {\n      dont_replicate_nodes.insert(input_node->name());\n    }\n  }\n\n  for (const auto& node : train_nodes) {\n    if (dont_replicate_nodes.find(node->name()) == dont_replicate_nodes.end()) {\n      replica_nodes_.insert(node->name());\n    }\n  }\n  LOG(INFO) << \"Number of replica nodes: \" << replica_nodes_.size();\n\n  for (const auto& node : all_nodes_) {\n    if (replica_nodes_.find(node.first) == replica_nodes_.end()) {\n      shared_nodes_.insert(node.first);\n    }\n  }\n  LOG(INFO) << \"Number of shared nodes: \" << shared_nodes_.size();\n  return Status::OK();\n}","target":1,"code_token_length":1131,"total_token_length":1367,"max_tokens_setting":2048}
+{"idx":391661,"func":"static NTSTATUS mkdir_internal(connection_struct *conn,\n\t\t\t       struct smb_filename *smb_dname,\n\t\t\t       uint32 file_attributes)\n{\n\tmode_t mode;\n\tchar *parent_dir = NULL;\n\tNTSTATUS status;\n\tbool posix_open = false;\n\tbool need_re_stat = false;\n\tuint32_t access_mask = SEC_DIR_ADD_SUBDIR;\n\n\tif (!CAN_WRITE(conn) || (access_mask & ~(conn->share_access))) {\n\t\tDEBUG(5,(\"mkdir_internal: failing share access \"\n\t\t\t \"%s\\n\", lp_servicename(talloc_tos(), SNUM(conn))));\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\n\tif (!parent_dirname(talloc_tos(), smb_dname->base_name, &parent_dir,\n\t\t\t    NULL)) {\n\t\treturn NT_STATUS_NO_MEMORY;\n\t}\n\n\tif (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {\n\t\tposix_open = true;\n\t\tmode = (mode_t)(file_attributes & ~FILE_FLAG_POSIX_SEMANTICS);\n\t} else {\n\t\tmode = unix_mode(conn, FILE_ATTRIBUTE_DIRECTORY, smb_dname, parent_dir);\n\t}\n\n\tstatus = check_parent_access(conn,\n\t\t\t\t\tsmb_dname,\n\t\t\t\t\taccess_mask);\n\tif(!NT_STATUS_IS_OK(status)) {\n\t\tDEBUG(5,(\"mkdir_internal: check_parent_access \"\n\t\t\t\"on directory %s for path %s returned %s\\n\",\n\t\t\tparent_dir,\n\t\t\tsmb_dname->base_name,\n\t\t\tnt_errstr(status) ));\n\t\treturn status;\n\t}\n\n\tif (SMB_VFS_MKDIR(conn, smb_dname->base_name, mode) != 0) {\n\t\treturn map_nt_error_from_unix(errno);\n\t}\n\n\t\/* Ensure we're checking for a symlink here.... *\/\n\t\/* We don't want to get caught by a symlink racer. *\/\n\n\tif (SMB_VFS_LSTAT(conn, smb_dname) == -1) {\n\t\tDEBUG(2, (\"Could not stat directory '%s' just created: %s\\n\",\n\t\t\t  smb_fname_str_dbg(smb_dname), strerror(errno)));\n\t\treturn map_nt_error_from_unix(errno);\n\t}\n\n\tif (!S_ISDIR(smb_dname->st.st_ex_mode)) {\n\t\tDEBUG(0, (\"Directory '%s' just created is not a directory !\\n\",\n\t\t\t  smb_fname_str_dbg(smb_dname)));\n\t\treturn NT_STATUS_NOT_A_DIRECTORY;\n\t}\n\n\tif (lp_store_dos_attributes(SNUM(conn))) {\n\t\tif (!posix_open) {\n\t\t\tfile_set_dosmode(conn, smb_dname,\n\t\t\t\t\t file_attributes | FILE_ATTRIBUTE_DIRECTORY,\n\t\t\t\t\t parent_dir, true);\n\t\t}\n\t}\n\n\tif (lp_inherit_perms(SNUM(conn))) {\n\t\tinherit_access_posix_acl(conn, parent_dir,\n\t\t\t\t\t smb_dname->base_name, mode);\n\t\tneed_re_stat = true;\n\t}\n\n\tif (!posix_open) {\n\t\t\/*\n\t\t * Check if high bits should have been set,\n\t\t * then (if bits are missing): add them.\n\t\t * Consider bits automagically set by UNIX, i.e. SGID bit from parent\n\t\t * dir.\n\t\t *\/\n\t\tif ((mode & ~(S_IRWXU|S_IRWXG|S_IRWXO)) &&\n\t\t    (mode & ~smb_dname->st.st_ex_mode)) {\n\t\t\tSMB_VFS_CHMOD(conn, smb_dname->base_name,\n\t\t\t\t      (smb_dname->st.st_ex_mode |\n\t\t\t\t\t  (mode & ~smb_dname->st.st_ex_mode)));\n\t\t\tneed_re_stat = true;\n\t\t}\n\t}\n\n\t\/* Change the owner if required. *\/\n\tif (lp_inherit_owner(SNUM(conn))) {\n\t\tchange_dir_owner_to_parent(conn, parent_dir,\n\t\t\t\t\t   smb_dname->base_name,\n\t\t\t\t\t   &smb_dname->st);\n\t\tneed_re_stat = true;\n\t}\n\n\tif (need_re_stat) {\n\t\tif (SMB_VFS_LSTAT(conn, smb_dname) == -1) {\n\t\t\tDEBUG(2, (\"Could not stat directory '%s' just created: %s\\n\",\n\t\t\t  smb_fname_str_dbg(smb_dname), strerror(errno)));\n\t\t\treturn map_nt_error_from_unix(errno);\n\t\t}\n\t}\n\n\tnotify_fname(conn, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME,\n\t\t     smb_dname->base_name);\n\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":899,"total_token_length":1135,"max_tokens_setting":2048}
+{"idx":337380,"func":"open_buffer(\n    int\t\tread_stdin,\t    \/\/ read file from stdin\n    exarg_T\t*eap,\t\t    \/\/ for forced 'ff' and 'fenc' or NULL\n    int\t\tflags)\t\t    \/\/ extra flags for readfile()\n{\n    int\t\tretval = OK;\n    bufref_T\told_curbuf;\n#ifdef FEAT_SYN_HL\n    long\told_tw = curbuf->b_p_tw;\n#endif\n    int\t\tread_fifo = FALSE;\n\n    \/\/ The 'readonly' flag is only set when BF_NEVERLOADED is being reset.\n    \/\/ When re-entering the same buffer, it should not change, because the\n    \/\/ user may have reset the flag by hand.\n    if (readonlymode && curbuf->b_ffname != NULL\n\t\t\t\t\t&& (curbuf->b_flags & BF_NEVERLOADED))\n\tcurbuf->b_p_ro = TRUE;\n\n    if (ml_open(curbuf) == FAIL)\n    {\n\t\/\/ There MUST be a memfile, otherwise we can't do anything\n\t\/\/ If we can't create one for the current buffer, take another buffer\n\tclose_buffer(NULL, curbuf, 0, FALSE, FALSE);\n\tFOR_ALL_BUFFERS(curbuf)\n\t    if (curbuf->b_ml.ml_mfp != NULL)\n\t\tbreak;\n\t\/\/ If there is no memfile at all, exit.\n\t\/\/ This is OK, since there are no changes to lose.\n\tif (curbuf == NULL)\n\t{\n\t    emsg(_(e_cannot_allocate_any_buffer_exiting));\n\n\t    \/\/ Don't try to do any saving, with \"curbuf\" NULL almost nothing\n\t    \/\/ will work.\n\t    v_dying = 2;\n\t    getout(2);\n\t}\n\n\temsg(_(e_cannot_allocate_buffer_using_other_one));\n\tenter_buffer(curbuf);\n#ifdef FEAT_SYN_HL\n\tif (old_tw != curbuf->b_p_tw)\n\t    check_colorcolumn(curwin);\n#endif\n\treturn FAIL;\n    }\n\n    \/\/ The autocommands in readfile() may change the buffer, but only AFTER\n    \/\/ reading the file.\n    set_bufref(&old_curbuf, curbuf);\n    modified_was_set = FALSE;\n\n    \/\/ mark cursor position as being invalid\n    curwin->w_valid = 0;\n\n    if (curbuf->b_ffname != NULL\n#ifdef FEAT_NETBEANS_INTG\n\t    && netbeansReadFile\n#endif\n       )\n    {\n\tint old_msg_silent = msg_silent;\n#ifdef UNIX\n\tint save_bin = curbuf->b_p_bin;\n\tint perm;\n#endif\n#ifdef FEAT_NETBEANS_INTG\n\tint oldFire = netbeansFireChanges;\n\n\tnetbeansFireChanges = 0;\n#endif\n#ifdef UNIX\n\tperm = mch_getperm(curbuf->b_ffname);\n\tif (perm >= 0 && (S_ISFIFO(perm)\n\t\t      || S_ISSOCK(perm)\n# ifdef OPEN_CHR_FILES\n\t\t      || (S_ISCHR(perm) && is_dev_fd_file(curbuf->b_ffname))\n# endif\n\t\t    ))\n\t\tread_fifo = TRUE;\n\tif (read_fifo)\n\t    curbuf->b_p_bin = TRUE;\n#endif\n\tif (shortmess(SHM_FILEINFO))\n\t    msg_silent = 1;\n\tretval = readfile(curbuf->b_ffname, curbuf->b_fname,\n\t\t  (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap,\n\t\t  flags | READ_NEW | (read_fifo ? READ_FIFO : 0));\n#ifdef UNIX\n\tif (read_fifo)\n\t{\n\t    curbuf->b_p_bin = save_bin;\n\t    if (retval == OK)\n\t\tretval = read_buffer(FALSE, eap, flags);\n\t}\n#endif\n\tmsg_silent = old_msg_silent;\n#ifdef FEAT_NETBEANS_INTG\n\tnetbeansFireChanges = oldFire;\n#endif\n\t\/\/ Help buffer is filtered.\n\tif (bt_help(curbuf))\n\t    fix_help_buffer();\n    }\n    else if (read_stdin)\n    {\n\tint\tsave_bin = curbuf->b_p_bin;\n\n\t\/\/ First read the text in binary mode into the buffer.\n\t\/\/ Then read from that same buffer and append at the end.  This makes\n\t\/\/ it possible to retry when 'fileformat' or 'fileencoding' was\n\t\/\/ guessed wrong.\n\tcurbuf->b_p_bin = TRUE;\n\tretval = readfile(NULL, NULL, (linenr_T)0,\n\t\t  (linenr_T)0, (linenr_T)MAXLNUM, NULL,\n\t\t  flags | (READ_NEW + READ_STDIN));\n\tcurbuf->b_p_bin = save_bin;\n\tif (retval == OK)\n\t    retval = read_buffer(TRUE, eap, flags);\n    }\n\n    \/\/ if first time loading this buffer, init b_chartab[]\n    if (curbuf->b_flags & BF_NEVERLOADED)\n    {\n\t(void)buf_init_chartab(curbuf, FALSE);\n#ifdef FEAT_CINDENT\n\tparse_cino(curbuf);\n#endif\n    }\n\n    \/\/ Set\/reset the Changed flag first, autocmds may change the buffer.\n    \/\/ Apply the automatic commands, before processing the modelines.\n    \/\/ So the modelines have priority over autocommands.\n    \/\/\n    \/\/ When reading stdin, the buffer contents always needs writing, so set\n    \/\/ the changed flag.  Unless in readonly mode: \"ls | gview -\".\n    \/\/ When interrupted and 'cpoptions' contains 'i' set changed flag.\n    if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)\n\t\t|| modified_was_set\t\/\/ \":set modified\" used in autocmd\n#ifdef FEAT_EVAL\n\t\t|| (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)\n#endif\n       )\n\tchanged();\n    else if (retval == OK && !read_stdin && !read_fifo)\n\tunchanged(curbuf, FALSE, TRUE);\n    save_file_ff(curbuf);\t\t\/\/ keep this fileformat\n\n    \/\/ Set last_changedtick to avoid triggering a TextChanged autocommand right\n    \/\/ after it was added.\n    curbuf->b_last_changedtick = CHANGEDTICK(curbuf);\n    curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);\n    curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf);\n\n    \/\/ require \"!\" to overwrite the file, because it wasn't read completely\n#ifdef FEAT_EVAL\n    if (aborting())\n#else\n    if (got_int)\n#endif\n\tcurbuf->b_flags |= BF_READERR;\n\n#ifdef FEAT_FOLDING\n    \/\/ Need to update automatic folding.  Do this before the autocommands,\n    \/\/ they may use the fold info.\n    foldUpdateAll(curwin);\n#endif\n\n    \/\/ need to set w_topline, unless some autocommand already did that.\n    if (!(curwin->w_valid & VALID_TOPLINE))\n    {\n\tcurwin->w_topline = 1;\n#ifdef FEAT_DIFF\n\tcurwin->w_topfill = 0;\n#endif\n    }\n#ifdef FEAT_EVAL\n    apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf, &retval);\n#else\n    apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);\n#endif\n\n    if (retval == OK)\n    {\n\t\/\/ The autocommands may have changed the current buffer.  Apply the\n\t\/\/ modelines to the correct buffer, if it still exists and is loaded.\n\tif (bufref_valid(&old_curbuf) && old_curbuf.br_buf->b_ml.ml_mfp != NULL)\n\t{\n\t    aco_save_T\taco;\n\n\t    \/\/ Go to the buffer that was opened.\n\t    aucmd_prepbuf(&aco, old_curbuf.br_buf);\n\t    do_modelines(0);\n\t    curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);\n\n\t    if ((flags & READ_NOWINENTER) == 0)\n#ifdef FEAT_EVAL\n\t\tapply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE,\n\t\t\t\t\t\t\t      curbuf, &retval);\n#else\n\t\tapply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf);\n#endif\n\n\t    \/\/ restore curwin\/curbuf and a few other things\n\t    aucmd_restbuf(&aco);\n\t}\n    }\n\n    return retval;\n}","target":0,"code_token_length":1786,"total_token_length":2022,"max_tokens_setting":2048}
+{"idx":476137,"func":"static int bos_desc(struct usb_composite_dev *cdev)\n{\n\tstruct usb_ext_cap_descriptor\t*usb_ext;\n\tstruct usb_dcd_config_params\tdcd_config_params;\n\tstruct usb_bos_descriptor\t*bos = cdev->req->buf;\n\tunsigned int\t\t\tbesl = 0;\n\n\tbos->bLength = USB_DT_BOS_SIZE;\n\tbos->bDescriptorType = USB_DT_BOS;\n\n\tbos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE);\n\tbos->bNumDeviceCaps = 0;\n\n\t\/* Get Controller configuration *\/\n\tif (cdev->gadget->ops->get_config_params) {\n\t\tcdev->gadget->ops->get_config_params(cdev->gadget,\n\t\t\t\t\t\t     &dcd_config_params);\n\t} else {\n\t\tdcd_config_params.besl_baseline =\n\t\t\tUSB_DEFAULT_BESL_UNSPECIFIED;\n\t\tdcd_config_params.besl_deep =\n\t\t\tUSB_DEFAULT_BESL_UNSPECIFIED;\n\t\tdcd_config_params.bU1devExitLat =\n\t\t\tUSB_DEFAULT_U1_DEV_EXIT_LAT;\n\t\tdcd_config_params.bU2DevExitLat =\n\t\t\tcpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT);\n\t}\n\n\tif (dcd_config_params.besl_baseline != USB_DEFAULT_BESL_UNSPECIFIED)\n\t\tbesl = USB_BESL_BASELINE_VALID |\n\t\t\tUSB_SET_BESL_BASELINE(dcd_config_params.besl_baseline);\n\n\tif (dcd_config_params.besl_deep != USB_DEFAULT_BESL_UNSPECIFIED)\n\t\tbesl |= USB_BESL_DEEP_VALID |\n\t\t\tUSB_SET_BESL_DEEP(dcd_config_params.besl_deep);\n\n\t\/*\n\t * A SuperSpeed device shall include the USB2.0 extension descriptor\n\t * and shall support LPM when operating in USB2.0 HS mode.\n\t *\/\n\tusb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength);\n\tbos->bNumDeviceCaps++;\n\tle16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE);\n\tusb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;\n\tusb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;\n\tusb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;\n\tusb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT |\n\t\t\t\t\t    USB_BESL_SUPPORT | besl);\n\n\t\/*\n\t * The Superspeed USB Capability descriptor shall be implemented by all\n\t * SuperSpeed devices.\n\t *\/\n\tif (gadget_is_superspeed(cdev->gadget)) {\n\t\tstruct usb_ss_cap_descriptor *ss_cap;\n\n\t\tss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);\n\t\tbos->bNumDeviceCaps++;\n\t\tle16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);\n\t\tss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;\n\t\tss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;\n\t\tss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;\n\t\tss_cap->bmAttributes = 0; \/* LTM is not supported yet *\/\n\t\tss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION |\n\t\t\t\t\t\t      USB_FULL_SPEED_OPERATION |\n\t\t\t\t\t\t      USB_HIGH_SPEED_OPERATION |\n\t\t\t\t\t\t      USB_5GBPS_OPERATION);\n\t\tss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;\n\t\tss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;\n\t\tss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;\n\t}\n\n\t\/* The SuperSpeedPlus USB Device Capability descriptor *\/\n\tif (gadget_is_superspeed_plus(cdev->gadget)) {\n\t\tstruct usb_ssp_cap_descriptor *ssp_cap;\n\t\tu8 ssac = 1;\n\t\tu8 ssic;\n\t\tint i;\n\n\t\tif (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x2)\n\t\t\tssac = 3;\n\n\t\t\/*\n\t\t * Paired RX and TX sublink speed attributes share\n\t\t * the same SSID.\n\t\t *\/\n\t\tssic = (ssac + 1) \/ 2 - 1;\n\n\t\tssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);\n\t\tbos->bNumDeviceCaps++;\n\n\t\tle16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(ssac));\n\t\tssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(ssac);\n\t\tssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;\n\t\tssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE;\n\t\tssp_cap->bReserved = 0;\n\t\tssp_cap->wReserved = 0;\n\n\t\tssp_cap->bmAttributes =\n\t\t\tcpu_to_le32(FIELD_PREP(USB_SSP_SUBLINK_SPEED_ATTRIBS, ssac) |\n\t\t\t\t    FIELD_PREP(USB_SSP_SUBLINK_SPEED_IDS, ssic));\n\n\t\tssp_cap->wFunctionalitySupport =\n\t\t\tcpu_to_le16(FIELD_PREP(USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID, 0) |\n\t\t\t\t    FIELD_PREP(USB_SSP_MIN_RX_LANE_COUNT, 1) |\n\t\t\t\t    FIELD_PREP(USB_SSP_MIN_TX_LANE_COUNT, 1));\n\n\t\t\/*\n\t\t * Use 1 SSID if the gadget supports up to gen2x1 or not\n\t\t * specified:\n\t\t * - SSID 0 for symmetric RX\/TX sublink speed of 10 Gbps.\n\t\t *\n\t\t * Use 1 SSID if the gadget supports up to gen1x2:\n\t\t * - SSID 0 for symmetric RX\/TX sublink speed of 5 Gbps.\n\t\t *\n\t\t * Use 2 SSIDs if the gadget supports up to gen2x2:\n\t\t * - SSID 0 for symmetric RX\/TX sublink speed of 5 Gbps.\n\t\t * - SSID 1 for symmetric RX\/TX sublink speed of 10 Gbps.\n\t\t *\/\n\t\tfor (i = 0; i < ssac + 1; i++) {\n\t\t\tu8 ssid;\n\t\t\tu8 mantissa;\n\t\t\tu8 type;\n\n\t\t\tssid = i >> 1;\n\n\t\t\tif (cdev->gadget->max_ssp_rate == USB_SSP_GEN_2x1 ||\n\t\t\t    cdev->gadget->max_ssp_rate == USB_SSP_GEN_UNKNOWN)\n\t\t\t\tmantissa = 10;\n\t\t\telse\n\t\t\t\tmantissa = 5 << ssid;\n\n\t\t\tif (i % 2)\n\t\t\t\ttype = USB_SSP_SUBLINK_SPEED_ST_SYM_TX;\n\t\t\telse\n\t\t\t\ttype = USB_SSP_SUBLINK_SPEED_ST_SYM_RX;\n\n\t\t\tssp_cap->bmSublinkSpeedAttr[i] =\n\t\t\t\tcpu_to_le32(FIELD_PREP(USB_SSP_SUBLINK_SPEED_SSID, ssid) |\n\t\t\t\t\t    FIELD_PREP(USB_SSP_SUBLINK_SPEED_LSE,\n\t\t\t\t\t\t       USB_SSP_SUBLINK_SPEED_LSE_GBPS) |\n\t\t\t\t\t    FIELD_PREP(USB_SSP_SUBLINK_SPEED_ST, type) |\n\t\t\t\t\t    FIELD_PREP(USB_SSP_SUBLINK_SPEED_LP,\n\t\t\t\t\t\t       USB_SSP_SUBLINK_SPEED_LP_SSP) |\n\t\t\t\t\t    FIELD_PREP(USB_SSP_SUBLINK_SPEED_LSM, mantissa));\n\t\t}\n\t}\n\n\treturn le16_to_cpu(bos->wTotalLength);\n}","target":0,"code_token_length":1610,"total_token_length":1846,"max_tokens_setting":2048}
+{"idx":450326,"func":"static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,\n                        bool skipauth, bool websocket)\n{\n    VncState *vs = g_new0(VncState, 1);\n    bool first_client = QTAILQ_EMPTY(&vd->clients);\n    int i;\n\n    trace_vnc_client_connect(vs, sioc);\n    vs->zrle = g_new0(VncZrle, 1);\n    vs->tight = g_new0(VncTight, 1);\n    vs->magic = VNC_MAGIC;\n    vs->sioc = sioc;\n    object_ref(OBJECT(vs->sioc));\n    vs->ioc = QIO_CHANNEL(sioc);\n    object_ref(OBJECT(vs->ioc));\n    vs->vd = vd;\n\n    buffer_init(&vs->input,          \"vnc-input\/%p\", sioc);\n    buffer_init(&vs->output,         \"vnc-output\/%p\", sioc);\n    buffer_init(&vs->jobs_buffer,    \"vnc-jobs_buffer\/%p\", sioc);\n\n    buffer_init(&vs->tight->tight,    \"vnc-tight\/%p\", sioc);\n    buffer_init(&vs->tight->zlib,     \"vnc-tight-zlib\/%p\", sioc);\n    buffer_init(&vs->tight->gradient, \"vnc-tight-gradient\/%p\", sioc);\n#ifdef CONFIG_VNC_JPEG\n    buffer_init(&vs->tight->jpeg,     \"vnc-tight-jpeg\/%p\", sioc);\n#endif\n#ifdef CONFIG_VNC_PNG\n    buffer_init(&vs->tight->png,      \"vnc-tight-png\/%p\", sioc);\n#endif\n    buffer_init(&vs->zlib.zlib,      \"vnc-zlib\/%p\", sioc);\n    buffer_init(&vs->zrle->zrle,      \"vnc-zrle\/%p\", sioc);\n    buffer_init(&vs->zrle->fb,        \"vnc-zrle-fb\/%p\", sioc);\n    buffer_init(&vs->zrle->zlib,      \"vnc-zrle-zlib\/%p\", sioc);\n\n    if (skipauth) {\n        vs->auth = VNC_AUTH_NONE;\n        vs->subauth = VNC_AUTH_INVALID;\n    } else {\n        if (websocket) {\n            vs->auth = vd->ws_auth;\n            vs->subauth = VNC_AUTH_INVALID;\n        } else {\n            vs->auth = vd->auth;\n            vs->subauth = vd->subauth;\n        }\n    }\n    VNC_DEBUG(\"Client sioc=%p ws=%d auth=%d subauth=%d\\n\",\n              sioc, websocket, vs->auth, vs->subauth);\n\n    vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));\n    for (i = 0; i < VNC_STAT_ROWS; ++i) {\n        vs->lossy_rect[i] = g_new0(uint8_t, VNC_STAT_COLS);\n    }\n\n    VNC_DEBUG(\"New client on socket %p\\n\", vs->sioc);\n    update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);\n    qio_channel_set_blocking(vs->ioc, false, NULL);\n    if (vs->ioc_tag) {\n        g_source_remove(vs->ioc_tag);\n    }\n    if (websocket) {\n        vs->websocket = 1;\n        if (vd->tlscreds) {\n            vs->ioc_tag = qio_channel_add_watch(\n                vs->ioc, G_IO_IN, vncws_tls_handshake_io, vs, NULL);\n        } else {\n            vs->ioc_tag = qio_channel_add_watch(\n                vs->ioc, G_IO_IN, vncws_handshake_io, vs, NULL);\n        }\n    } else {\n        vs->ioc_tag = qio_channel_add_watch(\n            vs->ioc, G_IO_IN, vnc_client_io, vs, NULL);\n    }\n\n    vnc_client_cache_addr(vs);\n    vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED);\n    vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING);\n\n    vs->last_x = -1;\n    vs->last_y = -1;\n\n    vs->as.freq = 44100;\n    vs->as.nchannels = 2;\n    vs->as.fmt = AUDIO_FORMAT_S16;\n    vs->as.endianness = 0;\n\n    qemu_mutex_init(&vs->output_mutex);\n    vs->bh = qemu_bh_new(vnc_jobs_bh, vs);\n\n    QTAILQ_INSERT_TAIL(&vd->clients, vs, next);\n    if (first_client) {\n        vnc_update_server_surface(vd);\n    }\n\n    graphic_hw_update(vd->dcl.con);\n\n    if (!vs->websocket) {\n        vnc_start_protocol(vs);\n    }\n\n    if (vd->num_connecting > vd->connections_limit) {\n        QTAILQ_FOREACH(vs, &vd->clients, next) {\n            if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) {\n                vnc_disconnect_start(vs);\n                return;\n            }\n        }\n    }\n}","target":0,"code_token_length":1107,"total_token_length":1343,"max_tokens_setting":2048}
+{"idx":437671,"func":"static RCoreSymCacheElement *parseDragons(RBinFile *bf, RBuffer *buf, int off, int bits, R_OWN char *file_name) {\n\tD eprintf (\"Dragons at 0x%x\\n\", off);\n\tst64 size = r_buf_size (buf);\n\tif (off >= size) {\n\t\treturn NULL;\n\t}\n\tsize -= off;\n\tif (!size) {\n\t\treturn NULL;\n\t}\n\tif (size < 32) {\n\t\treturn NULL;\n\t}\n\tut8 *b = malloc (size);\n\tif (!b) {\n\t\treturn NULL;\n\t}\n\tint available = r_buf_read_at (buf, off, b, size);\n\tif (available != size) {\n\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\treturn NULL;\n\t}\n#if 0\n\t\/\/ after the list of sections, there's a bunch of unknown\n\t\/\/ data, brobably dwords, and then the same section list again\n\t\/\/ this function aims to parse it.\n\t0x00000138 |1a2b b2a1 0300 0000 1a2b b2a1 e055 0000| .+.......+...U..\n                         n_segments ----.          .--- how many sections ?\n\t0x00000148 |0100 0000 ca55 0000 0400 0000 1800 0000| .....U..........\n\t             .---- how many symbols? 0xc7\n\t0x00000158 |c700 0000 0000 0000 0000 0000 0104 0000| ................\n\t0x00000168 |250b e803 0000 0100 0000 0000 bd55 0000| %............U..\n\t0x00000178 |91bb e903 e35a b42c 93a4 340a 8746 9489| .....Z.,..4..F..\n\t0x00000188 |0cea 4c40 0c00 0000 0900 0000 0000 0000| ..L@............\n\t0x00000198 |0000 0000 0000 0000 0000 0000 0000 0000| ................\n\t0x000001a8 |0080 0000 0000 0000 5f5f 5445 5854 0000| ........__TEXT..\n\t0x000001b8 |0000 0000 0000 0000 0080 0000 0000 0000| ................\n\t0x000001c8 |0040 0000 0000 0000 5f5f 4441 5441 0000| .@......__DATA..\n\t0x000001d8 |0000 0000 0000 0000 00c0 0000 0000 0000| ................\n\t0x000001e8 |0000 0100 0000 0000 5f5f 4c4c 564d 0000| ........__LLVM..\n\t0x000001f8 |0000 0000 0000 0000 00c0 0100 0000 0000| ................\n\t0x00000208 |00c0 0000 0000 0000 5f5f 4c49 4e4b 4544| ........__LINKED\n\t0x00000218 |4954 0000 0000 0000 0000 0000 d069 0000| IT...........i..\n#endif\n\t\/\/ eprintf (\"Dragon's magic:\\n\");\n\tint magicCombo = 0;\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { \/\/ 0x130  ?\n\t\tmagicCombo++;\n\t}\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b + 8, 4)) {\n\t\tmagicCombo++;\n\t}\n\tif (magicCombo != 2) {\n\t\t\/\/ hack for C22F7494\n\t\tavailable = r_buf_read_at (buf, off - 8, b, size);\n\t\tif (available != size) {\n\t\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { \/\/ 0x130  ?\n\t\t\toff -= 8;\n\t\t} else {\n\t\t\teprintf (\"0x%08x  parsing error: invalid magic retry\\n\", off);\n\t\t}\n\t}\n\tD eprintf (\"0x%08x  magic  OK\\n\", off);\n\tD {\n\t\tconst int e0ss = r_read_le32 (b + 12);\n\t\teprintf (\"0x%08x  eoss   0x%x\\n\", off + 12, e0ss);\n\t}\n\tfree (b);\n\treturn r_coresym_cache_element_new (bf, buf, off + 16, bits, file_name);\n}","target":0,"code_token_length":1394,"total_token_length":1630,"max_tokens_setting":2048}
+{"idx":413625,"func":"static int core_anal_graph_nodes(RCore *core, RAnalFunction *fcn, int opts, PJ *pj) {\n\tint is_json = opts & R_CORE_ANAL_JSON;\n\tint is_keva = opts & R_CORE_ANAL_KEYVALUE;\n\tint nodes = 0;\n\tSdb *DB = NULL;\n\tchar *pal_jump = palColorFor (\"graph.true\");\n\tchar *pal_fail = palColorFor (\"graph.false\");\n\tchar *pal_trfa = palColorFor (\"graph.trufae\");\n\tchar *pal_curr = palColorFor (\"graph.current\");\n\tchar *pal_traced = palColorFor (\"graph.traced\");\n\tchar *pal_box4 = palColorFor (\"graph.box4\");\n\tif (!fcn || !fcn->bbs) {\n\t\teprintf (\"No fcn\\n\");\n\t\tfree (pal_jump);\n\t\tfree (pal_fail);\n\t\tfree (pal_trfa);\n\t\tfree (pal_curr);\n\t\tfree (pal_traced);\n\t\tfree (pal_box4);\n\t\treturn -1;\n\t}\n\n\tif (is_keva) {\n\t\tchar ns[64];\n\t\tDB = sdb_ns (core->anal->sdb, \"graph\", 1);\n\t\tsnprintf (ns, sizeof (ns), \"fcn.0x%08\"PFMT64x, fcn->addr);\n\t\tDB = sdb_ns (DB, ns, 1);\n\t}\n\n\tif (is_keva) {\n\t\tchar *ename = sdb_encode ((const ut8*)fcn->name, -1);\n\t\tsdb_set (DB, \"name\", fcn->name, 0);\n\t\tsdb_set (DB, \"ename\", ename, 0);\n\t\tfree (ename);\n\t\tsdb_num_set (DB, \"size\", r_anal_function_linear_size (fcn), 0);\n\t\tif (fcn->maxstack > 0) {\n\t\t\tsdb_num_set (DB, \"stack\", fcn->maxstack, 0);\n\t\t}\n\t\tsdb_set (DB, \"pos\", \"0,0\", 0); \/\/ needs to run layout\n\t\tsdb_set (DB, \"type\", r_anal_functiontype_tostring (fcn->type), 0);\n\t} else if (is_json) {\n\t\t\/\/ TODO: show vars, refs and xrefs\n\t\tchar *fcn_name_escaped = r_str_escape_utf8_for_json (fcn->name, -1);\n\t\tpj_o (pj);\n\t\tpj_ks (pj, \"name\", r_str_getf (fcn_name_escaped));\n\t\tfree (fcn_name_escaped);\n\t\tpj_kn (pj, \"offset\", fcn->addr);\n\t\tpj_ki (pj, \"ninstr\", fcn->ninstr);\n\t\tpj_ki (pj, \"nargs\", r_anal_var_count_args (fcn));\n\t\tpj_ki (pj, \"nlocals\", r_anal_var_count_locals (fcn));\n\t\tpj_kn (pj, \"size\", r_anal_function_linear_size (fcn));\n\t\tpj_ki (pj, \"stack\", fcn->maxstack);\n\t\tpj_ks (pj, \"type\", r_anal_functiontype_tostring (fcn->type));\n\t\tpj_k (pj, \"blocks\");\n\t\tpj_a (pj);\n\t}\n\tnodes += core_anal_graph_construct_nodes (core, fcn, opts, pj, DB);\n\tnodes += core_anal_graph_construct_edges (core, fcn, opts, pj, DB);\n\tif (is_json) {\n\t\tpj_end (pj);\n\t\tpj_end (pj);\n\t}\n\tfree (pal_jump);\n\tfree (pal_fail);\n\tfree (pal_trfa);\n\tfree (pal_curr);\n\tfree (pal_traced);\n\tfree (pal_box4);\n\treturn nodes;\n}","target":0,"code_token_length":795,"total_token_length":1031,"max_tokens_setting":2048}
+{"idx":522356,"func":"int GmfCpyLin(int64_t InpIdx, int64_t OutIdx, int KwdCod)\n{\n   char        s[ WrdSiz * FilStrSiz ];\n   double      d;\n   float       f;\n   int         i, a, err;\n   int64_t     l;\n   GmfMshSct   *InpMsh = (GmfMshSct *)InpIdx, *OutMsh = (GmfMshSct *)OutIdx;\n   KwdSct      *kwd = &InpMsh->KwdTab[ KwdCod ];\n\n   \/\/ Save the current stack environment for longjmp\n   if( (err = setjmp(InpMsh->err)) != 0)\n   {\n#ifdef GMFDEBUG\n      printf(\"libMeshb : mesh %p : error %d\\n\", InpMsh, err);\n#endif\n      return(0);\n   }\n\n   for(i=0;i<kwd->SolSiz;i++)\n   {\n      if(kwd->fmt[i] == 'r')\n      {\n         if(InpMsh->FltSiz == 32)\n         {\n            if(InpMsh->typ & Asc)\n               safe_fscanf(InpMsh->hdl, \"%f\", &f, InpMsh->err);\n            else\n               ScaWrd(InpMsh, (unsigned char *)&f);\n\n            d = (double)f;\n         }\n         else\n         {\n            if(InpMsh->typ & Asc)\n               safe_fscanf(InpMsh->hdl, \"%lf\", &d, InpMsh->err);\n            else\n               ScaDblWrd(InpMsh, (unsigned char *)&d);\n\n            f = (float)d;\n         }\n\n         if(OutMsh->FltSiz == 32)\n            if(OutMsh->typ & Asc)\n               fprintf(OutMsh->hdl, \"%.9g \", (double)f);\n            else\n               RecWrd(OutMsh, (unsigned char *)&f);\n         else\n            if(OutMsh->typ & Asc)\n               fprintf(OutMsh->hdl, \"%.17g \", d);\n            else\n               RecDblWrd(OutMsh, (unsigned char *)&d);\n      }\n      else if(kwd->fmt[i] == 'i')\n      {\n         if(InpMsh->ver <= 3)\n         {\n            if(InpMsh->typ & Asc)\n               safe_fscanf(InpMsh->hdl, \"%d\", &a, InpMsh->err);\n            else\n               ScaWrd(InpMsh, (unsigned char *)&a);\n\n            l = (int64_t)a;\n         }\n         else\n         {\n            if(InpMsh->typ & Asc)\n               safe_fscanf(InpMsh->hdl, INT64_T_FMT, &l, InpMsh->err);\n            else\n               ScaDblWrd(InpMsh, (unsigned char *)&l);\n\n            a = (int)l;\n         }\n\n         if( (i == kwd->SolSiz-1) && (a > GmfMaxRefTab[ KwdCod ]) )\n            GmfMaxRefTab[ KwdCod ] = a;\n\n         if(OutMsh->ver <= 3)\n         {\n            if(OutMsh->typ & Asc)\n               fprintf(OutMsh->hdl, \"%d \", a);\n            else\n               RecWrd(OutMsh, (unsigned char *)&a);\n         }\n         else\n         {\n            if(OutMsh->typ & Asc)\n               fprintf(OutMsh->hdl, INT64_T_FMT\" \", l);\n            else\n               RecDblWrd(OutMsh, (unsigned char *)&l);\n         }\n      }\n      else if(kwd->fmt[i] == 'c')\n      {\n         memset(s, 0, FilStrSiz * WrdSiz);\n\n         if(InpMsh->typ & Asc)\n            safe_fgets(s, WrdSiz * FilStrSiz, InpMsh->hdl, InpMsh->err);\n         else\n#ifdef WITH_GMF_AIO\n            read(InpMsh->FilDes, s, WrdSiz * FilStrSiz);\n#else\n            safe_fread(s, WrdSiz, FilStrSiz, InpMsh->hdl, InpMsh->err);\n#endif\n         if(OutMsh->typ & Asc)\n            fprintf(OutMsh->hdl, \"%s \", s);\n         else\n#ifdef WITH_GMF_AIO\n            write(OutMsh->FilDes, s, WrdSiz * FilStrSiz);\n#else\n            fwrite(s, WrdSiz, FilStrSiz, OutMsh->hdl);\n#endif\n      }\n   }\n\n   if(OutMsh->typ & Asc)\n      fprintf(OutMsh->hdl, \"\\n\");\n\n   return(1);\n}","target":0,"code_token_length":1082,"total_token_length":1318,"max_tokens_setting":2048}
+{"idx":202276,"func":"block_insert(\n    oparg_T\t\t*oap,\n    char_u\t\t*s,\n    int\t\t\tb_insert,\n    struct block_def\t*bdp)\n{\n    int\t\tts_val;\n    int\t\tcount = 0;\t\/\/ extra spaces to replace a cut TAB\n    int\t\tspaces = 0;\t\/\/ non-zero if cutting a TAB\n    colnr_T\toffset;\t\t\/\/ pointer along new line\n    colnr_T\tstartcol;\t\/\/ column where insert starts\n    unsigned\ts_len;\t\t\/\/ STRLEN(s)\n    char_u\t*newp, *oldp;\t\/\/ new, old lines\n    linenr_T\tlnum;\t\t\/\/ loop var\n    int\t\toldstate = State;\n\n    State = INSERT;\t\t\/\/ don't want REPLACE for State\n    s_len = (unsigned)STRLEN(s);\n\n    for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)\n    {\n\tblock_prep(oap, bdp, lnum, TRUE);\n\tif (bdp->is_short && b_insert)\n\t    continue;\t\/\/ OP_INSERT, line ends before block start\n\n\toldp = ml_get(lnum);\n\n\tif (b_insert)\n\t{\n\t    ts_val = bdp->start_char_vcols;\n\t    spaces = bdp->startspaces;\n\t    if (spaces != 0)\n\t\tcount = ts_val - 1; \/\/ we're cutting a TAB\n\t    offset = bdp->textcol;\n\t}\n\telse \/\/ append\n\t{\n\t    ts_val = bdp->end_char_vcols;\n\t    if (!bdp->is_short) \/\/ spaces = padding after block\n\t    {\n\t\tspaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);\n\t\tif (spaces != 0)\n\t\t    count = ts_val - 1; \/\/ we're cutting a TAB\n\t\toffset = bdp->textcol + bdp->textlen - (spaces != 0);\n\t    }\n\t    else \/\/ spaces = padding to block edge\n\t    {\n\t\t\/\/ if $ used, just append to EOL (ie spaces==0)\n\t\tif (!bdp->is_MAX)\n\t\t    spaces = (oap->end_vcol - bdp->end_vcol) + 1;\n\t\tcount = spaces;\n\t\toffset = bdp->textcol + bdp->textlen;\n\t    }\n\t}\n\n\tif (has_mbyte && spaces > 0)\n\t{\n\t    int off;\n\n\t    \/\/ Avoid starting halfway a multi-byte character.\n\t    if (b_insert)\n\t    {\n\t\toff = (*mb_head_off)(oldp, oldp + offset + spaces);\n\t\tspaces -= off;\n\t\tcount -= off;\n\t    }\n\t    else\n\t    {\n\t\t\/\/ spaces fill the gap, the character that's at the edge moves\n\t\t\/\/ right\n\t\toff = (*mb_head_off)(oldp, oldp + offset);\n\t\toffset -= off;\n\t    }\n\t}\n\tif (spaces < 0)  \/\/ can happen when the cursor was moved\n\t    spaces = 0;\n\n\t\/\/ Make sure the allocated size matches what is actually copied below.\n\tnewp = alloc(STRLEN(oldp) + spaces + s_len\n\t\t    + (spaces > 0 && !bdp->is_short ? ts_val - spaces : 0)\n\t\t\t\t\t\t\t\t  + count + 1);\n\tif (newp == NULL)\n\t    continue;\n\n\t\/\/ copy up to shifted part\n\tmch_memmove(newp, oldp, (size_t)offset);\n\toldp += offset;\n\n\t\/\/ insert pre-padding\n\tvim_memset(newp + offset, ' ', (size_t)spaces);\n\tstartcol = offset + spaces;\n\n\t\/\/ copy the new text\n\tmch_memmove(newp + startcol, s, (size_t)s_len);\n\toffset += s_len;\n\n\tif (spaces > 0 && !bdp->is_short)\n\t{\n\t    if (*oldp == TAB)\n\t    {\n\t\t\/\/ insert post-padding\n\t\tvim_memset(newp + offset + spaces, ' ',\n\t\t\t\t\t\t    (size_t)(ts_val - spaces));\n\t\t\/\/ we're splitting a TAB, don't copy it\n\t\toldp++;\n\t\t\/\/ We allowed for that TAB, remember this now\n\t\tcount++;\n\t    }\n\t    else\n\t\t\/\/ Not a TAB, no extra spaces\n\t\tcount = spaces;\n\t}\n\n\tif (spaces > 0)\n\t    offset += count;\n\tSTRMOVE(newp + offset, oldp);\n\n\tml_replace(lnum, newp, FALSE);\n\n\tif (b_insert)\n\t    \/\/ correct any text properties\n\t    inserted_bytes(lnum, startcol, s_len);\n\n\tif (lnum == oap->end.lnum)\n\t{\n\t    \/\/ Set \"']\" mark to the end of the block instead of the end of\n\t    \/\/ the insert in the first line.\n\t    curbuf->b_op_end.lnum = oap->end.lnum;\n\t    curbuf->b_op_end.col = offset;\n\t}\n    } \/\/ for all lnum\n\n    changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);\n\n    State = oldstate;\n}","target":1,"code_token_length":1107,"total_token_length":1343,"max_tokens_setting":2048}
+{"idx":281646,"func":"void CLASS canon_sraw_load_raw()\n{\n  struct jhead jh;\n  short *rp=0, (*ip)[4];\n  int jwide, slice, scol, ecol, row, col, jrow=0, jcol=0, pix[3], c;\n  int v[3]={0,0,0}, ver, hue;\n  char *cp;\n\n  if (!ljpeg_start (&jh, 0) || jh.clrs < 4) return;\n  jwide = (jh.wide >>= 1) * jh.clrs;\n\n#ifdef LIBRAW_LIBRARY_BUILD\n  try {\n#endif\n  for (ecol=slice=0; slice <= cr2_slice[0]; slice++) {\n    scol = ecol;\n    ecol += cr2_slice[1] * 2 \/ jh.clrs;\n    if (!cr2_slice[0] || ecol > raw_width-1) ecol = raw_width & -2;\n    for (row=0; row < height; row += (jh.clrs >> 1) - 1) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n      ip = (short (*)[4]) image + row*width;\n      for (col=scol; col < ecol; col+=2, jcol+=jh.clrs) {\n\tif ((jcol %= jwide) == 0)\n\t  rp = (short *) ljpeg_row (jrow++, &jh);\n\tif (col >= width) continue;\n#ifdef LIBRAW_LIBRARY_BUILD\n        if(imgdata.params.sraw_ycc>=2)\n          {\n            FORC (jh.clrs-2)\n              {\n                ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c];\n                ip[col + (c >> 1)*width + (c & 1)][1] = ip[col + (c >> 1)*width + (c & 1)][2] = 8192;\n              }\n            ip[col][1] = rp[jcol+jh.clrs-2] - 8192;\n            ip[col][2] = rp[jcol+jh.clrs-1] - 8192;\n          }\n        else if(imgdata.params.sraw_ycc)\n          {\n            FORC (jh.clrs-2)\n                ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c];\n            ip[col][1] = rp[jcol+jh.clrs-2] - 8192;\n            ip[col][2] = rp[jcol+jh.clrs-1] - 8192;\n          }\n        else\n#endif\n          {\n            FORC (jh.clrs-2)\n              ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c];\n            ip[col][1] = rp[jcol+jh.clrs-2] - 16384;\n            ip[col][2] = rp[jcol+jh.clrs-1] - 16384;\n          }\n      }\n    }\n  }\n#ifdef LIBRAW_LIBRARY_BUILD\n  } catch (...) {\n      ljpeg_end (&jh);\n      throw ;\n  }\n#endif\n\n#ifdef LIBRAW_LIBRARY_BUILD\n  if(imgdata.params.sraw_ycc>=2)\n    {\n      ljpeg_end (&jh);\n      maximum = 0x3fff;\n      return;\n    }\n#endif\n\n#ifdef LIBRAW_LIBRARY_BUILD\n  try {\n#endif\n  for (cp=model2; *cp && !isdigit(*cp); cp++);\n  sscanf (cp, \"%d.%d.%d\", v, v+1, v+2);\n  ver = (v[0]*1000 + v[1])*1000 + v[2];\n  hue = (jh.sraw+1) << 2;\n  if (unique_id >= 0x80000281 || (unique_id == 0x80000218 && ver > 1000006))\n    hue = jh.sraw << 1;\n  ip = (short (*)[4]) image;\n  rp = ip[0];\n  for (row=0; row < height; row++, ip+=width) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    if (row & (jh.sraw >> 1))\n      for (col=0; col < width; col+=2)\n\tfor (c=1; c < 3; c++)\n\t  if (row == height-1)\n\t       ip[col][c] =  ip[col-width][c];\n\t  else ip[col][c] = (ip[col-width][c] + ip[col+width][c] + 1) >> 1;\n    for (col=1; col < width; col+=2)\n      for (c=1; c < 3; c++)\n\tif (col == width-1)\n\t     ip[col][c] =  ip[col-1][c];\n\telse ip[col][c] = (ip[col-1][c] + ip[col+1][c] + 1) >> 1;\n  }\n#ifdef LIBRAW_LIBRARY_BUILD\n  if(!imgdata.params.sraw_ycc)\n#endif\n    for ( ; rp < ip[0]; rp+=4) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n      if (unique_id == 0x80000218 ||\n          unique_id == 0x80000250 ||\n          unique_id == 0x80000261 ||\n          unique_id == 0x80000281 ||\n          unique_id == 0x80000287) {\n        rp[1] = (rp[1] << 2) + hue;\n        rp[2] = (rp[2] << 2) + hue;\n        pix[0] = rp[0] + ((   50*rp[1] + 22929*rp[2]) >> 14);\n        pix[1] = rp[0] + ((-5640*rp[1] - 11751*rp[2]) >> 14);\n        pix[2] = rp[0] + ((29040*rp[1] -   101*rp[2]) >> 14);\n      } else {\n        if (unique_id < 0x80000218) rp[0] -= 512;\n        pix[0] = rp[0] + rp[2];\n        pix[2] = rp[0] + rp[1];\n        pix[1] = rp[0] + ((-778*rp[1] - (rp[2] << 11)) >> 12);\n      }\n      FORC3 rp[c] = CLIP(pix[c] * sraw_mul[c] >> 10);\n    }\n#ifdef LIBRAW_LIBRARY_BUILD\n  } catch (...) {\n      ljpeg_end (&jh);\n      throw ;\n  }\n#endif\n  ljpeg_end (&jh);\n  maximum = 0x3fff;\n}","target":0,"code_token_length":1569,"total_token_length":1805,"max_tokens_setting":2048}
+{"idx":489135,"func":"sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep,\n\t\t\t\t     const struct sctp_association *asoc,\n\t\t\t\t     const sctp_subtype_t type, void *arg,\n\t\t\t\t     sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk\t*chunk = arg;\n\tstruct sctp_chunk\t*asconf_ack = NULL;\n\tstruct sctp_paramhdr\t*err_param = NULL;\n\tsctp_addiphdr_t\t\t*hdr;\n\tunion sctp_addr_param\t*addr_param;\n\t__u32\t\t\tserial;\n\tint\t\t\tlength;\n\n\tif (!sctp_vtag_verify(chunk, asoc)) {\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG,\n\t\t\t\tSCTP_NULL());\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\t}\n\n\t\/* ADD-IP: Section 4.1.1\n\t * This chunk MUST be sent in an authenticated way by using\n\t * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk\n\t * is received unauthenticated it MUST be silently discarded as\n\t * described in [I-D.ietf-tsvwg-sctp-auth].\n\t *\/\n\tif (!sctp_addip_noauth && !chunk->auth)\n\t\treturn sctp_sf_discard_chunk(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the ASCONF ADDIP chunk has a valid length.  *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_addip_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\thdr = (sctp_addiphdr_t *)chunk->skb->data;\n\tserial = ntohl(hdr->serial);\n\n\taddr_param = (union sctp_addr_param *)hdr->params;\n\tlength = ntohs(addr_param->p.length);\n\tif (length < sizeof(sctp_paramhdr_t))\n\t\treturn sctp_sf_violation_paramlen(ep, asoc, type, arg,\n\t\t\t   (void *)addr_param, commands);\n\n\t\/* Verify the ASCONF chunk before processing it. *\/\n\tif (!sctp_verify_asconf(asoc,\n\t\t\t    (sctp_paramhdr_t *)((void *)addr_param + length),\n\t\t\t    (void *)chunk->chunk_end,\n\t\t\t    &err_param))\n\t\treturn sctp_sf_violation_paramlen(ep, asoc, type, arg,\n\t\t\t\t\t\t  (void *)err_param, commands);\n\n\t\/* ADDIP 5.2 E1) Compare the value of the serial number to the value\n\t * the endpoint stored in a new association variable\n\t * 'Peer-Serial-Number'.\n\t *\/\n\tif (serial == asoc->peer.addip_serial + 1) {\n\t\t\/* If this is the first instance of ASCONF in the packet,\n\t\t * we can clean our old ASCONF-ACKs.\n\t\t *\/\n\t\tif (!chunk->has_asconf)\n\t\t\tsctp_assoc_clean_asconf_ack_cache(asoc);\n\n\t\t\/* ADDIP 5.2 E4) When the Sequence Number matches the next one\n\t\t * expected, process the ASCONF as described below and after\n\t\t * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to\n\t\t * the response packet and cache a copy of it (in the event it\n\t\t * later needs to be retransmitted).\n\t\t *\n\t\t * Essentially, do V1-V5.\n\t\t *\/\n\t\tasconf_ack = sctp_process_asconf((struct sctp_association *)\n\t\t\t\t\t\t asoc, chunk);\n\t\tif (!asconf_ack)\n\t\t\treturn SCTP_DISPOSITION_NOMEM;\n\t} else if (serial < asoc->peer.addip_serial + 1) {\n\t\t\/* ADDIP 5.2 E2)\n\t\t * If the value found in the Sequence Number is less than the\n\t\t * ('Peer- Sequence-Number' + 1), simply skip to the next\n\t\t * ASCONF, and include in the outbound response packet\n\t\t * any previously cached ASCONF-ACK response that was\n\t\t * sent and saved that matches the Sequence Number of the\n\t\t * ASCONF.  Note: It is possible that no cached ASCONF-ACK\n\t\t * Chunk exists.  This will occur when an older ASCONF\n\t\t * arrives out of order.  In such a case, the receiver\n\t\t * should skip the ASCONF Chunk and not include ASCONF-ACK\n\t\t * Chunk for that chunk.\n\t\t *\/\n\t\tasconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial);\n\t\tif (!asconf_ack)\n\t\t\treturn SCTP_DISPOSITION_DISCARD;\n\t} else {\n\t\t\/* ADDIP 5.2 E5) Otherwise, the ASCONF Chunk is discarded since\n\t\t * it must be either a stale packet or from an attacker.\n\t\t *\/\n\t\treturn SCTP_DISPOSITION_DISCARD;\n\t}\n\n\t\/* ADDIP 5.2 E6)  The destination address of the SCTP packet\n\t * containing the ASCONF-ACK Chunks MUST be the source address of\n\t * the SCTP packet that held the ASCONF Chunks.\n\t *\n\t * To do this properly, we'll set the destination address of the chunk\n\t * and at the transmit time, will try look up the transport to use.\n\t * Since ASCONFs may be bundled, the correct transport may not be\n\t * created untill we process the entire packet, thus this workaround.\n\t *\/\n\tasconf_ack->dest = chunk->source;\n\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(asconf_ack));\n\n\treturn SCTP_DISPOSITION_CONSUME;\n}","target":0,"code_token_length":1201,"total_token_length":1437,"max_tokens_setting":2048}
+{"idx":355629,"func":"eval_index(\n    char_u\t**arg,\n    typval_T\t*rettv,\n    evalarg_T\t*evalarg,\n    int\t\tverbose)\t\/\/ give error messages\n{\n    int\t\tevaluate = evalarg != NULL\n\t\t\t\t      && (evalarg->eval_flags & EVAL_EVALUATE);\n    int\t\tempty1 = FALSE, empty2 = FALSE;\n    typval_T\tvar1, var2;\n    int\t\trange = FALSE;\n    char_u\t*key = NULL;\n    int\t\tkeylen = -1;\n    int\t\tvim9 = in_vim9script();\n\n    if (check_can_index(rettv, evaluate, verbose) == FAIL)\n\treturn FAIL;\n\n    init_tv(&var1);\n    init_tv(&var2);\n    if (**arg == '.')\n    {\n\t\/*\n\t * dict.name\n\t *\/\n\tkey = *arg + 1;\n\tfor (keylen = 0; eval_isdictc(key[keylen]); ++keylen)\n\t    ;\n\tif (keylen == 0)\n\t    return FAIL;\n\t*arg = key + keylen;\n    }\n    else\n    {\n\t\/*\n\t * something[idx]\n\t *\n\t * Get the (first) variable from inside the [].\n\t *\/\n\t*arg = skipwhite_and_linebreak(*arg + 1, evalarg);\n\tif (**arg == ':')\n\t    empty1 = TRUE;\n\telse if (eval1(arg, &var1, evalarg) == FAIL)\t\/\/ recursive!\n\t    return FAIL;\n\telse if (vim9 && **arg == ':')\n\t{\n\t    semsg(_(e_white_space_required_before_and_after_str_at_str),\n\t\t\t\t\t\t\t\t    \":\", *arg);\n\t    clear_tv(&var1);\n\t    return FAIL;\n\t}\n\telse if (evaluate)\n\t{\n\t    int error = FALSE;\n\n#ifdef FEAT_FLOAT\n\t    \/\/ allow for indexing with float\n\t    if (vim9 && rettv->v_type == VAR_DICT\n\t\t\t\t\t\t   && var1.v_type == VAR_FLOAT)\n\t    {\n\t\tvar1.vval.v_string = typval_tostring(&var1, TRUE);\n\t\tvar1.v_type = VAR_STRING;\n\t    }\n#endif\n\t    if (vim9 && rettv->v_type == VAR_LIST)\n\t\ttv_get_number_chk(&var1, &error);\n\t    else\n\t\terror = tv_get_string_chk(&var1) == NULL;\n\t    if (error)\n\t    {\n\t\t\/\/ not a number or string\n\t\tclear_tv(&var1);\n\t\treturn FAIL;\n\t    }\n\t}\n\n\t\/*\n\t * Get the second variable from inside the [:].\n\t *\/\n\t*arg = skipwhite_and_linebreak(*arg, evalarg);\n\tif (**arg == ':')\n\t{\n\t    range = TRUE;\n\t    ++*arg;\n\t    if (vim9 && !IS_WHITE_OR_NUL(**arg) && **arg != ']')\n\t    {\n\t\tsemsg(_(e_white_space_required_before_and_after_str_at_str),\n\t\t\t\t\t\t\t\t\":\", *arg - 1);\n\t\tif (!empty1)\n\t\t    clear_tv(&var1);\n\t\treturn FAIL;\n\t    }\n\t    *arg = skipwhite_and_linebreak(*arg, evalarg);\n\t    if (**arg == ']')\n\t\tempty2 = TRUE;\n\t    else if (eval1(arg, &var2, evalarg) == FAIL)\t\/\/ recursive!\n\t    {\n\t\tif (!empty1)\n\t\t    clear_tv(&var1);\n\t\treturn FAIL;\n\t    }\n\t    else if (evaluate && tv_get_string_chk(&var2) == NULL)\n\t    {\n\t\t\/\/ not a number or string\n\t\tif (!empty1)\n\t\t    clear_tv(&var1);\n\t\tclear_tv(&var2);\n\t\treturn FAIL;\n\t    }\n\t}\n\n\t\/\/ Check for the ']'.\n\t*arg = skipwhite_and_linebreak(*arg, evalarg);\n\tif (**arg != ']')\n\t{\n\t    if (verbose)\n\t\temsg(_(e_missing_closing_square_brace));\n\t    clear_tv(&var1);\n\t    if (range)\n\t\tclear_tv(&var2);\n\t    return FAIL;\n\t}\n\t*arg = *arg + 1;\t\/\/ skip over the ']'\n    }\n\n    if (evaluate)\n    {\n\tint res = eval_index_inner(rettv, range,\n\t\tempty1 ? NULL : &var1, empty2 ? NULL : &var2, FALSE,\n\t\tkey, keylen, verbose);\n\n\tif (!empty1)\n\t    clear_tv(&var1);\n\tif (range)\n\t    clear_tv(&var2);\n\treturn res;\n    }\n    return OK;\n}","target":0,"code_token_length":941,"total_token_length":1177,"max_tokens_setting":2048}
+{"idx":503887,"func":"SCM_DEFINE (scm_stat, \"stat\", 1, 1, 0, \n            (SCM object, SCM exception_on_error),\n\t    \"Return an object containing various information about the file\\n\"\n\t    \"determined by @var{object}.  @var{object} can be a string containing\\n\"\n\t    \"a file name or a port or integer file descriptor which is open\\n\"\n\t    \"on a file (in which case @code{fstat} is used as the underlying\\n\"\n\t    \"system call).\\n\"\n\t    \"\\n\"\n            \"If the optional @var{exception_on_error} argument is true, which\\n\"\n            \"is the default, an exception will be raised if the underlying\\n\"\n            \"system call returns an error, for example if the file is not\\n\"\n            \"found or is not readable. Otherwise, an error will cause\\n\"\n            \"@code{stat} to return @code{#f}.\"\n\t    \"\\n\"\n\t    \"The object returned by a successful call to @code{stat} can be\\n\"\n            \"passed as a single parameter to the following procedures, all of\\n\"\n            \"which return integers:\\n\"\n\t    \"\\n\"\n\t    \"@table @code\\n\"\n\t    \"@item stat:dev\\n\"\n\t    \"The device containing the file.\\n\"\n\t    \"@item stat:ino\\n\"\n\t    \"The file serial number, which distinguishes this file from all\\n\"\n\t    \"other files on the same device.\\n\"\n\t    \"@item stat:mode\\n\"\n\t    \"The mode of the file.  This includes file type information and\\n\"\n\t    \"the file permission bits.  See @code{stat:type} and\\n\"\n\t    \"@code{stat:perms} below.\\n\"\n\t    \"@item stat:nlink\\n\"\n\t    \"The number of hard links to the file.\\n\"\n\t    \"@item stat:uid\\n\"\n\t    \"The user ID of the file's owner.\\n\"\n\t    \"@item stat:gid\\n\"\n\t    \"The group ID of the file.\\n\"\n\t    \"@item stat:rdev\\n\"\n\t    \"Device ID; this entry is defined only for character or block\\n\"\n\t    \"special files.\\n\"\n\t    \"@item stat:size\\n\"\n\t    \"The size of a regular file in bytes.\\n\"\n\t    \"@item stat:atime\\n\"\n\t    \"The last access time for the file.\\n\"\n\t    \"@item stat:mtime\\n\"\n\t    \"The last modification time for the file.\\n\"\n\t    \"@item stat:ctime\\n\"\n\t    \"The last modification time for the attributes of the file.\\n\"\n\t    \"@item stat:blksize\\n\"\n\t    \"The optimal block size for reading or writing the file, in\\n\"\n\t    \"bytes.\\n\"\n\t    \"@item stat:blocks\\n\"\n\t    \"The amount of disk space that the file occupies measured in\\n\"\n\t    \"units of 512 byte blocks.\\n\"\n\t    \"@end table\\n\"\n\t    \"\\n\"\n\t    \"In addition, the following procedures return the information\\n\"\n\t    \"from stat:mode in a more convenient form:\\n\"\n\t    \"\\n\"\n\t    \"@table @code\\n\"\n\t    \"@item stat:type\\n\"\n\t    \"A symbol representing the type of file.  Possible values are\\n\"\n\t    \"regular, directory, symlink, block-special, char-special, fifo,\\n\"\n\t    \"socket and unknown\\n\"\n\t    \"@item stat:perms\\n\"\n\t    \"An integer representing the access permission bits.\\n\"\n\t    \"@end table\")\n#define FUNC_NAME s_scm_stat\n{\n  int rv;\n  int fdes;\n  struct stat_or_stat64 stat_temp;\n\n  if (scm_is_integer (object))\n    {\n      SCM_SYSCALL (rv = fstat_or_fstat64 (scm_to_int (object), &stat_temp));\n    }\n  else if (scm_is_string (object))\n    {\n      char *file = scm_to_locale_string (object);\n      SCM_SYSCALL (rv = stat_or_stat64 (file, &stat_temp));\n      free (file);\n    }\n  else\n    {\n      object = SCM_COERCE_OUTPORT (object);\n      SCM_VALIDATE_OPFPORT (1, object);\n      fdes = SCM_FPORT_FDES (object);\n      SCM_SYSCALL (rv = fstat_or_fstat64 (fdes, &stat_temp));\n    }\n\n  if (rv == -1)\n    {\n      if (SCM_UNBNDP (exception_on_error) || scm_is_true (exception_on_error))\n        {\n          int en = errno;\n          SCM_SYSERROR_MSG (\"~A: ~S\",\n                            scm_list_2 (scm_strerror (scm_from_int (en)),\n                                        object),\n                            en);\n        }\n      else\n        return SCM_BOOL_F;\n    }\n  return scm_stat2scm (&stat_temp);\n}","target":0,"code_token_length":1015,"total_token_length":1251,"max_tokens_setting":2048}
+{"idx":369396,"func":"\nstatic __cold int io_uring_create(unsigned entries, struct io_uring_params *p,\n\t\t\t\t  struct io_uring_params __user *params)\n{\n\tstruct io_ring_ctx *ctx;\n\tstruct file *file;\n\tint ret;\n\n\tif (!entries)\n\t\treturn -EINVAL;\n\tif (entries > IORING_MAX_ENTRIES) {\n\t\tif (!(p->flags & IORING_SETUP_CLAMP))\n\t\t\treturn -EINVAL;\n\t\tentries = IORING_MAX_ENTRIES;\n\t}\n\n\t\/*\n\t * Use twice as many entries for the CQ ring. It's possible for the\n\t * application to drive a higher depth than the size of the SQ ring,\n\t * since the sqes are only used at submission time. This allows for\n\t * some flexibility in overcommitting a bit. If the application has\n\t * set IORING_SETUP_CQSIZE, it will have passed in the desired number\n\t * of CQ ring entries manually.\n\t *\/\n\tp->sq_entries = roundup_pow_of_two(entries);\n\tif (p->flags & IORING_SETUP_CQSIZE) {\n\t\t\/*\n\t\t * If IORING_SETUP_CQSIZE is set, we do the same roundup\n\t\t * to a power-of-two, if it isn't already. We do NOT impose\n\t\t * any cq vs sq ring sizing.\n\t\t *\/\n\t\tif (!p->cq_entries)\n\t\t\treturn -EINVAL;\n\t\tif (p->cq_entries > IORING_MAX_CQ_ENTRIES) {\n\t\t\tif (!(p->flags & IORING_SETUP_CLAMP))\n\t\t\t\treturn -EINVAL;\n\t\t\tp->cq_entries = IORING_MAX_CQ_ENTRIES;\n\t\t}\n\t\tp->cq_entries = roundup_pow_of_two(p->cq_entries);\n\t\tif (p->cq_entries < p->sq_entries)\n\t\t\treturn -EINVAL;\n\t} else {\n\t\tp->cq_entries = 2 * p->sq_entries;\n\t}\n\n\tctx = io_ring_ctx_alloc(p);\n\tif (!ctx)\n\t\treturn -ENOMEM;\n\tctx->compat = in_compat_syscall();\n\tif (!capable(CAP_IPC_LOCK))\n\t\tctx->user = get_uid(current_user());\n\n\t\/*\n\t * This is just grabbed for accounting purposes. When a process exits,\n\t * the mm is exited and dropped before the files, hence we need to hang\n\t * on to this mm purely for the purposes of being able to unaccount\n\t * memory (locked\/pinned vm). It's not used for anything else.\n\t *\/\n\tmmgrab(current->mm);\n\tctx->mm_account = current->mm;\n\n\tret = io_allocate_scq_urings(ctx, p);\n\tif (ret)\n\t\tgoto err;\n\n\tret = io_sq_offload_create(ctx, p);\n\tif (ret)\n\t\tgoto err;\n\t\/* always set a rsrc node *\/\n\tret = io_rsrc_node_switch_start(ctx);\n\tif (ret)\n\t\tgoto err;\n\tio_rsrc_node_switch(ctx, NULL);\n\n\tmemset(&p->sq_off, 0, sizeof(p->sq_off));\n\tp->sq_off.head = offsetof(struct io_rings, sq.head);\n\tp->sq_off.tail = offsetof(struct io_rings, sq.tail);\n\tp->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask);\n\tp->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries);\n\tp->sq_off.flags = offsetof(struct io_rings, sq_flags);\n\tp->sq_off.dropped = offsetof(struct io_rings, sq_dropped);\n\tp->sq_off.array = (char *)ctx->sq_array - (char *)ctx->rings;\n\n\tmemset(&p->cq_off, 0, sizeof(p->cq_off));\n\tp->cq_off.head = offsetof(struct io_rings, cq.head);\n\tp->cq_off.tail = offsetof(struct io_rings, cq.tail);\n\tp->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask);\n\tp->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries);\n\tp->cq_off.overflow = offsetof(struct io_rings, cq_overflow);\n\tp->cq_off.cqes = offsetof(struct io_rings, cqes);\n\tp->cq_off.flags = offsetof(struct io_rings, cq_flags);\n\n\tp->features = IORING_FEAT_SINGLE_MMAP | IORING_FEAT_NODROP |\n\t\t\tIORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS |\n\t\t\tIORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL |\n\t\t\tIORING_FEAT_POLL_32BITS | IORING_FEAT_SQPOLL_NONFIXED |\n\t\t\tIORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS |\n\t\t\tIORING_FEAT_RSRC_TAGS | IORING_FEAT_CQE_SKIP |\n\t\t\tIORING_FEAT_LINKED_FILE;\n\n\tif (copy_to_user(params, p, sizeof(*p))) {\n\t\tret = -EFAULT;\n\t\tgoto err;\n\t}\n\n\tfile = io_uring_get_file(ctx);\n\tif (IS_ERR(file)) {\n\t\tret = PTR_ERR(file);\n\t\tgoto err;\n\t}\n\n\t\/*\n\t * Install ring fd as the very last thing, so we don't risk someone\n\t * having closed it before we finish setup\n\t *\/\n\tret = io_uring_install_fd(ctx, file);\n\tif (ret < 0) {\n\t\t\/* fput will clean it up *\/\n\t\tfput(file);\n\t\treturn ret;\n\t}\n\n\ttrace_io_uring_create(ret, ctx, p->sq_entries, p->cq_entries, p->flags);\n\treturn ret;\nerr:\n\tio_ring_ctx_wait_and_kill(ctx);\n\treturn ret;","target":0,"code_token_length":1165,"total_token_length":1401,"max_tokens_setting":2048}
+{"idx":271526,"func":"void ReshapeSparseTensor(OpKernelContext *context,\n                         const Tensor &input_indices_in,\n                         const Tensor &input_shape_in,\n                         const Tensor &target_shape_in, int output_indices_idx,\n                         int output_shape_idx) {\n  OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices_in.shape()),\n              errors::InvalidArgument(\n                  \"Input indices should be a matrix but received shape \",\n                  input_indices_in.shape().DebugString()));\n  OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape_in.shape()),\n              errors::InvalidArgument(\n                  \"Input shape should be a vector but received shape \",\n                  input_shape_in.shape().DebugString()));\n  OP_REQUIRES(context, TensorShapeUtils::IsVector(target_shape_in.shape()),\n              errors::InvalidArgument(\n                  \"Target shape should be a vector but received shape \",\n                  target_shape_in.shape().DebugString()));\n\n  const int64_t output_rank = target_shape_in.NumElements();\n  const TensorShape input_shape(input_shape_in.vec<int64>());\n  const int64_t dense_size = input_shape.num_elements();\n  const int64_t nnz = input_indices_in.shape().dim_size(0);\n\n  \/\/ Compute the output shape. Determine product of specified dimensions, and\n  \/\/ find the index of the unspecified one.\n  TensorShape output_shape;\n  int64_t product = 1;\n  int unknown_index = -1;\n  auto target_shape = target_shape_in.vec<int64>();\n  for (int d = 0; d < output_rank; ++d) {\n    const int64_t size = target_shape(d);\n    if (size == -1) {\n      OP_REQUIRES(\n          context, unknown_index == -1,\n          errors::InvalidArgument(\"only one output dimension may be -1, \"\n                                  \"not both \",\n                                  unknown_index, \" and \", d));\n      unknown_index = d;\n      output_shape.AddDim(1);\n    } else {\n      OP_REQUIRES(context, size >= 0,\n                  errors::InvalidArgument(\"size \", d,\n                                          \" must be non-negative, not \", size));\n      product *= size;\n      output_shape.AddDim(size);\n    }\n  }\n  if (unknown_index != -1) {\n    OP_REQUIRES(\n        context, product > 0,\n        errors::InvalidArgument(\"reshape cannot infer the missing \"\n                                \"input size for an empty tensor unless all \"\n                                \"specified input sizes are non-zero\"));\n    const int64_t missing = dense_size \/ product;\n    OP_REQUIRES(\n        context, product * missing == dense_size,\n        errors::InvalidArgument(\n            \"Input to reshape is a SparseTensor with \", dense_size,\n            \" dense values, but the requested shape requires a multiple of \",\n            product, \". input_shape=\", input_shape.DebugString(),\n            \" output_shape=\", output_shape.DebugString()));\n    output_shape.set_dim(unknown_index, missing);\n  }\n\n  OP_REQUIRES(\n      context, output_shape.num_elements() == dense_size,\n      errors::InvalidArgument(\"Input to reshape is a tensor with \", dense_size,\n                              \" dense values, but the requested shape has \",\n                              output_shape.num_elements(),\n                              \". input_shape=\", input_shape.DebugString(),\n                              \" output_shape=\", output_shape.DebugString()));\n\n  \/\/ Optimize for reshaping to the same shape.\n  if (input_shape == output_shape) {\n    context->set_output(output_indices_idx, input_indices_in);\n    context->set_output(output_shape_idx, input_shape_in);\n    return;\n  }\n\n  Tensor *result_shape = nullptr;\n  OP_REQUIRES_OK(context, context->allocate_output(output_shape_idx,\n                                                   TensorShape({output_rank}),\n                                                   &result_shape));\n  auto output_shape_vec = result_shape->vec<int64>();\n  for (int j = 0; j < output_shape.dims(); ++j) {\n    output_shape_vec(j) = output_shape.dim_size(j);\n  }\n\n  Tensor *result_indices = nullptr;\n  OP_REQUIRES_OK(context,\n                 context->allocate_output(output_indices_idx,\n                                          TensorShape({nnz, output_rank}),\n                                          &result_indices));\n  if (nnz > 0) {\n    OP_REQUIRES(\n        context, dense_size > 0 && product > 0,\n        errors::InvalidArgument(\n            \"Input tensor has \", nnz, \" non zero elements but input shape (\",\n            input_shape.DebugString(), \") or output shape (\",\n            output_shape.DebugString(), \") is empty\"));\n    OP_REQUIRES_OK(context, functor::ReshapeSparseTensorFunctor<Device>()(\n                                context, input_shape, output_shape,\n                                input_indices_in.matrix<int64>(),\n                                result_indices->matrix<int64>()));\n  }\n}","target":0,"code_token_length":976,"total_token_length":1212,"max_tokens_setting":2048}
+{"idx":416358,"func":"cmdline_wildchar_complete(\n\tint\t\tc,\n\tint\t\tescape,\n\tint\t\t*did_wild_list,\n\tint\t\t*wim_index_p,\n\texpand_T\t*xp,\n\tint\t\t*gotesc)\n{\n    int\t\twim_index = *wim_index_p;\n    int\t\tres;\n    int\t\tj;\n    int\t\toptions = WILD_NO_BEEP;\n\n    if (wim_flags[wim_index] & WIM_BUFLASTUSED)\n\toptions |= WILD_BUFLASTUSED;\n    if (xp->xp_numfiles > 0)   \/\/ typed p_wc at least twice\n    {\n\t\/\/ if 'wildmode' contains \"list\" may still need to list\n\tif (xp->xp_numfiles > 1\n\t\t&& !*did_wild_list\n\t\t&& ((wim_flags[wim_index] & WIM_LIST)\n\t\t    || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)))\n\t{\n\t    (void)showmatches(xp,\n\t\t    p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0));\n\t    redrawcmd();\n\t    *did_wild_list = TRUE;\n\t}\n\tif (wim_flags[wim_index] & WIM_LONGEST)\n\t    res = nextwild(xp, WILD_LONGEST, options, escape);\n\telse if (wim_flags[wim_index] & WIM_FULL)\n\t    res = nextwild(xp, WILD_NEXT, options, escape);\n\telse\n\t    res = OK;\t    \/\/ don't insert 'wildchar' now\n    }\n    else\t\t    \/\/ typed p_wc first time\n    {\n\twim_index = 0;\n\tj = ccline.cmdpos;\n\t\/\/ if 'wildmode' first contains \"longest\", get longest\n\t\/\/ common part\n\tif (wim_flags[0] & WIM_LONGEST)\n\t    res = nextwild(xp, WILD_LONGEST, options, escape);\n\telse\n\t    res = nextwild(xp, WILD_EXPAND_KEEP, options, escape);\n\n\t\/\/ if interrupted while completing, behave like it failed\n\tif (got_int)\n\t{\n\t    (void)vpeekc();\t\/\/ remove <C-C> from input stream\n\t    got_int = FALSE;\t\/\/ don't abandon the command line\n\t    (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);\n\t    xp->xp_context = EXPAND_NOTHING;\n\t    *wim_index_p = wim_index;\n\t    return CMDLINE_CHANGED;\n\t}\n\n\t\/\/ when more than one match, and 'wildmode' first contains\n\t\/\/ \"list\", or no change and 'wildmode' contains \"longest,list\",\n\t\/\/ list all matches\n\tif (res == OK && xp->xp_numfiles > 1)\n\t{\n\t    \/\/ a \"longest\" that didn't do anything is skipped (but not\n\t    \/\/ \"list:longest\")\n\t    if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j)\n\t\twim_index = 1;\n\t    if ((wim_flags[wim_index] & WIM_LIST)\n\t\t    || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0))\n\t    {\n\t\tif (!(wim_flags[0] & WIM_LONGEST))\n\t\t{\n\t\t    int p_wmnu_save = p_wmnu;\n\n\t\t    p_wmnu = 0;\n\n\t\t    \/\/ remove match\n\t\t    nextwild(xp, WILD_PREV, 0, escape);\n\t\t    p_wmnu = p_wmnu_save;\n\t\t}\n\t\t(void)showmatches(xp, p_wmnu\n\t\t\t&& ((wim_flags[wim_index] & WIM_LIST) == 0));\n\t\tredrawcmd();\n\t\t*did_wild_list = TRUE;\n\t\tif (wim_flags[wim_index] & WIM_LONGEST)\n\t\t    nextwild(xp, WILD_LONGEST, options, escape);\n\t\telse if (wim_flags[wim_index] & WIM_FULL)\n\t\t    nextwild(xp, WILD_NEXT, options, escape);\n\t    }\n\t    else\n\t\tvim_beep(BO_WILD);\n\t}\n\telse if (xp->xp_numfiles == -1)\n\t    xp->xp_context = EXPAND_NOTHING;\n    }\n    if (wim_index < 3)\n\t++wim_index;\n    if (c == ESC)\n\t*gotesc = TRUE;\n\n    *wim_index_p = wim_index;\n    return (res == OK) ? CMDLINE_CHANGED : CMDLINE_NOT_CHANGED;\n}","target":0,"code_token_length":987,"total_token_length":1223,"max_tokens_setting":2048}
+{"idx":509480,"func":"int ha_maria::create(const char *name, TABLE *table_arg,\n                     HA_CREATE_INFO *ha_create_info)\n{\n  int error;\n  uint create_flags= 0, record_count= 0, i;\n  char buff[FN_REFLEN];\n  MARIA_KEYDEF *keydef;\n  MARIA_COLUMNDEF *recinfo;\n  MARIA_CREATE_INFO create_info;\n  TABLE_SHARE *share= table_arg->s;\n  uint options= share->db_options_in_use;\n  ha_table_option_struct *table_options= table_arg->s->option_struct;\n  enum data_file_type row_type;\n  THD *thd= current_thd;\n  DBUG_ENTER(\"ha_maria::create\");\n\n  for (i= 0; i < share->keys; i++)\n  {\n    if (table_arg->key_info[i].flags & HA_USES_PARSER)\n    {\n      create_flags|= HA_CREATE_RELIES_ON_SQL_LAYER;\n      break;\n    }\n  }\n  \/* Note: BLOCK_RECORD is used if table is transactional *\/\n  row_type= maria_row_type(ha_create_info);\n  if (ha_create_info->transactional == HA_CHOICE_YES &&\n      ha_create_info->row_type != ROW_TYPE_PAGE &&\n      ha_create_info->row_type != ROW_TYPE_NOT_USED &&\n      ha_create_info->row_type != ROW_TYPE_DEFAULT)\n    push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,\n                 ER_ILLEGAL_HA_CREATE_OPTION,\n                 \"Row format set to PAGE because of TRANSACTIONAL=1 option\");\n\n  if (share->table_type == TABLE_TYPE_SEQUENCE)\n  {\n    \/* For sequences, the simples record type is appropriate *\/\n    row_type= STATIC_RECORD;\n    ha_create_info->transactional= HA_CHOICE_NO;\n  }\n\n  bzero((char*) &create_info, sizeof(create_info));\n  if ((error= table2maria(table_arg, row_type, &keydef, &recinfo,\n                          &record_count, &create_info)))\n    DBUG_RETURN(error); \/* purecov: inspected *\/\n  create_info.max_rows= share->max_rows;\n  create_info.reloc_rows= share->min_rows;\n  create_info.with_auto_increment= share->next_number_key_offset == 0;\n  create_info.auto_increment= (ha_create_info->auto_increment_value ?\n                               ha_create_info->auto_increment_value -1 :\n                               (ulonglong) 0);\n  create_info.data_file_length= ((ulonglong) share->max_rows *\n                                 share->avg_row_length);\n  create_info.data_file_name= ha_create_info->data_file_name;\n  create_info.index_file_name= ha_create_info->index_file_name;\n  create_info.language= share->table_charset->number;\n  if (ht != maria_hton)\n  {\n    \/* S3 engine *\/\n    create_info.s3_block_size= (ulong) table_options->s3_block_size;\n    create_info.compression_algorithm= table_options->compression_algorithm;\n  }\n\n  \/*\n    Table is transactional:\n    - If the user specify that table is transactional (in this case\n      row type is forced to BLOCK_RECORD)\n    - If they specify BLOCK_RECORD without specifying transactional behaviour\n\n    Shouldn't this test be pushed down to maria_create()? Because currently,\n    ma_test1 -T crashes: it creates a table with DYNAMIC_RECORD but has\n    born_transactional==1, which confuses some recovery-related code.\n  *\/\n  create_info.transactional= (row_type == BLOCK_RECORD &&\n                              ha_create_info->transactional != HA_CHOICE_NO);\n\n  if (ha_create_info->tmp_table())\n  {\n    create_flags|= HA_CREATE_TMP_TABLE | HA_CREATE_DELAY_KEY_WRITE;\n    create_info.transactional= 0;\n  }\n  if (ha_create_info->options & HA_CREATE_KEEP_FILES)\n    create_flags|= HA_CREATE_KEEP_FILES;\n  if (options & HA_OPTION_PACK_RECORD)\n    create_flags|= HA_PACK_RECORD;\n  if (options & HA_OPTION_CHECKSUM)\n    create_flags|= HA_CREATE_CHECKSUM;\n  if (options & HA_OPTION_DELAY_KEY_WRITE)\n    create_flags|= HA_CREATE_DELAY_KEY_WRITE;\n  if ((ha_create_info->page_checksum == HA_CHOICE_UNDEF &&\n       maria_page_checksums) ||\n       ha_create_info->page_checksum ==  HA_CHOICE_YES)\n    create_flags|= HA_CREATE_PAGE_CHECKSUM;\n\n  (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY,\n                                 (uchar*) thd->query(), thd->query_length());\n\n  create_info.encrypted= maria_encrypt_tables && ht == maria_hton;\n  \/* TODO: Check that the following fn_format is really needed *\/\n  error=\n    maria_create(fn_format(buff, name, \"\", \"\",\n                           MY_UNPACK_FILENAME | MY_APPEND_EXT),\n                 row_type, share->keys, keydef,\n                 record_count,  recinfo,\n                 0, (MARIA_UNIQUEDEF *) 0,\n                 &create_info, create_flags);\n\n  my_free(recinfo);\n  DBUG_RETURN(error);\n}","target":0,"code_token_length":1052,"total_token_length":1288,"max_tokens_setting":2048}
+{"idx":439169,"func":"static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)\n{\n  char\n    buffer[MaxTextExtent],\n    colorspace[MaxTextExtent],\n    tuple[MaxTextExtent];\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  MagickPixelPacket\n    pixel;\n\n  register const IndexPacket\n    *indexes;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    x;\n\n  size_t\n    imageListLength;\n\n  ssize_t\n    y;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    ComplianceType\n      compliance;\n\n    const char\n      *value;\n\n    (void) CopyMagickString(colorspace,CommandOptionToMnemonic(\n      MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent);\n    LocaleLower(colorspace);\n    image->depth=GetImageQuantumDepth(image,MagickTrue);\n    if (image->matte != MagickFalse)\n      (void) ConcatenateMagickString(colorspace,\"a\",MaxTextExtent);\n    compliance=NoCompliance;\n    value=GetImageOption(image_info,\"txt:compliance\");\n    if (value != (char *) NULL)\n      compliance=(ComplianceType) ParseCommandOption(MagickComplianceOptions,\n        MagickFalse,value);\n    if (LocaleCompare(image_info->magick,\"SPARSE-COLOR\") != 0)\n      {\n        size_t\n          depth;\n\n        depth=compliance == SVGCompliance ? image->depth :\n          MAGICKCORE_QUANTUM_DEPTH;\n        (void) FormatLocaleString(buffer,MaxTextExtent,\n          \"# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\\n\",(double)\n          image->columns,(double) image->rows,(double) ((MagickOffsetType)\n          GetQuantumRange(depth)),colorspace);\n        (void) WriteBlobString(image,buffer);\n      }\n    GetMagickPixelPacket(image,&pixel);\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n      if (p == (const PixelPacket *) NULL)\n        break;\n      indexes=GetVirtualIndexQueue(image);\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        SetMagickPixelPacket(image,p,indexes+x,&pixel);\n        if (pixel.colorspace == LabColorspace)\n          {\n            pixel.green-=(QuantumRange+1)\/2.0;\n            pixel.blue-=(QuantumRange+1)\/2.0;\n          }\n        if (LocaleCompare(image_info->magick,\"SPARSE-COLOR\") == 0)\n          {\n            \/*\n              Sparse-color format.\n            *\/\n            if ((image->matte == MagickFalse) ||\n                (GetPixelOpacity(p) == (Quantum) OpaqueOpacity))\n              {\n                GetColorTuple(&pixel,MagickFalse,tuple);\n                (void) FormatLocaleString(buffer,MaxTextExtent,\"%.20g,%.20g,\",\n                  (double) x,(double) y);\n                (void) WriteBlobString(image,buffer);\n                (void) WriteBlobString(image,tuple);\n                (void) WriteBlobString(image,\" \");\n              }\n            p++;\n            continue;\n          }\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"%.20g,%.20g: \",(double)\n          x,(double) y);\n        (void) WriteBlobString(image,buffer);\n        (void) CopyMagickString(tuple,\"(\",MaxTextExtent);\n        ConcatenateColorComponent(&pixel,RedChannel,compliance,tuple);\n        (void) ConcatenateMagickString(tuple,\",\",MaxTextExtent);\n        ConcatenateColorComponent(&pixel,GreenChannel,compliance,tuple);\n        (void) ConcatenateMagickString(tuple,\",\",MaxTextExtent);\n        ConcatenateColorComponent(&pixel,BlueChannel,compliance,tuple);\n        if (pixel.colorspace == CMYKColorspace)\n          {\n            (void) ConcatenateMagickString(tuple,\",\",MaxTextExtent);\n            ConcatenateColorComponent(&pixel,IndexChannel,compliance,tuple);\n          }\n        if (pixel.matte != MagickFalse)\n          {\n            (void) ConcatenateMagickString(tuple,\",\",MaxTextExtent);\n            ConcatenateColorComponent(&pixel,AlphaChannel,compliance,tuple);\n          }\n        (void) ConcatenateMagickString(tuple,\")\",MaxTextExtent);\n        (void) WriteBlobString(image,tuple);\n        (void) WriteBlobString(image,\"  \");\n        GetColorTuple(&pixel,MagickTrue,tuple);\n        (void) FormatLocaleString(buffer,MaxTextExtent,\"%s\",tuple);\n        (void) WriteBlobString(image,buffer);\n        (void) WriteBlobString(image,\"  \");\n        (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,\n          &image->exception);\n        (void) WriteBlobString(image,tuple);\n        (void) WriteBlobString(image,\"\\n\");\n        p++;\n      }\n      status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n        image->rows);\n      if (status == MagickFalse)\n        break;\n    }\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":1343,"total_token_length":1579,"max_tokens_setting":2048}
+{"idx":450413,"func":"static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)\n{\n    int i;\n    uint16_t limit;\n    uint32_t freq;\n    VncDisplay *vd = vs->vd;\n\n    if (data[0] > 3) {\n        update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);\n    }\n\n    switch (data[0]) {\n    case VNC_MSG_CLIENT_SET_PIXEL_FORMAT:\n        if (len == 1)\n            return 20;\n\n        set_pixel_format(vs, read_u8(data, 4),\n                         read_u8(data, 6), read_u8(data, 7),\n                         read_u16(data, 8), read_u16(data, 10),\n                         read_u16(data, 12), read_u8(data, 14),\n                         read_u8(data, 15), read_u8(data, 16));\n        break;\n    case VNC_MSG_CLIENT_SET_ENCODINGS:\n        if (len == 1)\n            return 4;\n\n        if (len == 4) {\n            limit = read_u16(data, 2);\n            if (limit > 0)\n                return 4 + (limit * 4);\n        } else\n            limit = read_u16(data, 2);\n\n        for (i = 0; i < limit; i++) {\n            int32_t val = read_s32(data, 4 + (i * 4));\n            memcpy(data + 4 + (i * 4), &val, sizeof(val));\n        }\n\n        set_encodings(vs, (int32_t *)(data + 4), limit);\n        break;\n    case VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST:\n        if (len == 1)\n            return 10;\n\n        framebuffer_update_request(vs,\n                                   read_u8(data, 1), read_u16(data, 2), read_u16(data, 4),\n                                   read_u16(data, 6), read_u16(data, 8));\n        break;\n    case VNC_MSG_CLIENT_KEY_EVENT:\n        if (len == 1)\n            return 8;\n\n        key_event(vs, read_u8(data, 1), read_u32(data, 4));\n        break;\n    case VNC_MSG_CLIENT_POINTER_EVENT:\n        if (len == 1)\n            return 6;\n\n        pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4));\n        break;\n    case VNC_MSG_CLIENT_CUT_TEXT:\n        if (len == 1) {\n            return 8;\n        }\n        if (len == 8) {\n            uint32_t dlen = read_u32(data, 4);\n            if (dlen > (1 << 20)) {\n                error_report(\"vnc: client_cut_text msg payload has %u bytes\"\n                             \" which exceeds our limit of 1MB.\", dlen);\n                vnc_client_error(vs);\n                break;\n            }\n            if (dlen > 0) {\n                return 8 + dlen;\n            }\n        }\n\n        client_cut_text(vs, read_u32(data, 4), data + 8);\n        break;\n    case VNC_MSG_CLIENT_QEMU:\n        if (len == 1)\n            return 2;\n\n        switch (read_u8(data, 1)) {\n        case VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT:\n            if (len == 2)\n                return 12;\n\n            ext_key_event(vs, read_u16(data, 2),\n                          read_u32(data, 4), read_u32(data, 8));\n            break;\n        case VNC_MSG_CLIENT_QEMU_AUDIO:\n            if (len == 2)\n                return 4;\n\n            switch (read_u16 (data, 2)) {\n            case VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE:\n                audio_add(vs);\n                break;\n            case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE:\n                audio_del(vs);\n                break;\n            case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT:\n                if (len == 4)\n                    return 10;\n                switch (read_u8(data, 4)) {\n                case 0: vs->as.fmt = AUDIO_FORMAT_U8; break;\n                case 1: vs->as.fmt = AUDIO_FORMAT_S8; break;\n                case 2: vs->as.fmt = AUDIO_FORMAT_U16; break;\n                case 3: vs->as.fmt = AUDIO_FORMAT_S16; break;\n                case 4: vs->as.fmt = AUDIO_FORMAT_U32; break;\n                case 5: vs->as.fmt = AUDIO_FORMAT_S32; break;\n                default:\n                    VNC_DEBUG(\"Invalid audio format %d\\n\", read_u8(data, 4));\n                    vnc_client_error(vs);\n                    break;\n                }\n                vs->as.nchannels = read_u8(data, 5);\n                if (vs->as.nchannels != 1 && vs->as.nchannels != 2) {\n                    VNC_DEBUG(\"Invalid audio channel count %d\\n\",\n                              read_u8(data, 5));\n                    vnc_client_error(vs);\n                    break;\n                }\n                freq = read_u32(data, 6);\n                \/* No official limit for protocol, but 48khz is a sensible\n                 * upper bound for trustworthy clients, and this limit\n                 * protects calculations involving 'vs->as.freq' later.\n                 *\/\n                if (freq > 48000) {\n                    VNC_DEBUG(\"Invalid audio frequency %u > 48000\", freq);\n                    vnc_client_error(vs);\n                    break;\n                }\n                vs->as.freq = freq;\n                break;\n            default:\n                VNC_DEBUG(\"Invalid audio message %d\\n\", read_u8(data, 4));\n                vnc_client_error(vs);\n                break;\n            }\n            break;\n\n        default:\n            VNC_DEBUG(\"Msg: %d\\n\", read_u16(data, 0));\n            vnc_client_error(vs);\n            break;\n        }\n        break;\n    default:\n        VNC_DEBUG(\"Msg: %d\\n\", data[0]);\n        vnc_client_error(vs);\n        break;\n    }\n\n    vnc_update_throttle_offset(vs);\n    vnc_read_when(vs, protocol_client_msg, 1);\n    return 0;\n}","target":0,"code_token_length":1380,"total_token_length":1616,"max_tokens_setting":2048}
+{"idx":458917,"func":"cin_isfuncdecl(\n    char_u\t**sp,\n    linenr_T\tfirst_lnum,\n    linenr_T\tmin_lnum)\n{\n    char_u\t*s;\n    linenr_T\tlnum = first_lnum;\n    linenr_T\tsave_lnum = curwin->w_cursor.lnum;\n    int\t\tretval = FALSE;\n    pos_T\t*trypos;\n    int\t\tjust_started = TRUE;\n\n    if (sp == NULL)\n\ts = ml_get(lnum);\n    else\n\ts = *sp;\n\n    curwin->w_cursor.lnum = lnum;\n    if (find_last_paren(s, '(', ')')\n\t&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)\n    {\n\tlnum = trypos->lnum;\n\tif (lnum < min_lnum)\n\t{\n\t    curwin->w_cursor.lnum = save_lnum;\n\t    return FALSE;\n\t}\n\n\ts = ml_get(lnum);\n    }\n    curwin->w_cursor.lnum = save_lnum;\n\n    \/\/ Ignore line starting with #.\n    if (cin_ispreproc(s))\n\treturn FALSE;\n\n    while (*s && *s != '(' && *s != ';' && *s != '\\'' && *s != '\"')\n    {\n\tif (cin_iscomment(s))\t\/\/ ignore comments\n\t    s = cin_skipcomment(s);\n\telse if (*s == ':')\n\t{\n\t    if (*(s + 1) == ':')\n\t\ts += 2;\n\t    else\n\t\t\/\/ To avoid a mistake in the following situation:\n\t\t\/\/ A::A(int a, int b)\n\t\t\/\/     : a(0)  \/\/ <--not a function decl\n\t\t\/\/     , b(0)\n\t\t\/\/ {...\n\t\treturn FALSE;\n\t}\n\telse\n\t    ++s;\n    }\n    if (*s != '(')\n\treturn FALSE;\t\t\/\/ ';', ' or \"  before any () or no '('\n\n    while (*s && *s != ';' && *s != '\\'' && *s != '\"')\n    {\n\tif (*s == ')' && cin_nocode(s + 1))\n\t{\n\t    \/\/ ')' at the end: may have found a match\n\t    \/\/ Check for he previous line not to end in a backslash:\n\t    \/\/       #if defined(x) && {backslash}\n\t    \/\/\t\t defined(y)\n\t    lnum = first_lnum - 1;\n\t    s = ml_get(lnum);\n\t    if (*s == NUL || s[STRLEN(s) - 1] != '\\\\')\n\t\tretval = TRUE;\n\t    goto done;\n\t}\n\tif ((*s == ',' && cin_nocode(s + 1)) || s[1] == NUL || cin_nocode(s))\n\t{\n\t    int comma = (*s == ',');\n\n\t    \/\/ ',' at the end: continue looking in the next line.\n\t    \/\/ At the end: check for ',' in the next line, for this style:\n\t    \/\/ func(arg1\n\t    \/\/       , arg2)\n\t    for (;;)\n\t    {\n\t\tif (lnum >= curbuf->b_ml.ml_line_count)\n\t\t    break;\n\t\ts = ml_get(++lnum);\n\t\tif (!cin_ispreproc(s))\n\t\t    break;\n\t    }\n\t    if (lnum >= curbuf->b_ml.ml_line_count)\n\t\tbreak;\n\t    \/\/ Require a comma at end of the line or a comma or ')' at the\n\t    \/\/ start of next line.\n\t    s = skipwhite(s);\n\t    if (!just_started && (!comma && *s != ',' && *s != ')'))\n\t\tbreak;\n\t    just_started = FALSE;\n\t}\n\telse if (cin_iscomment(s))\t\/\/ ignore comments\n\t    s = cin_skipcomment(s);\n\telse\n\t{\n\t    ++s;\n\t    just_started = FALSE;\n\t}\n    }\n\ndone:\n    if (lnum != first_lnum && sp != NULL)\n\t*sp = ml_get(first_lnum);\n\n    return retval;\n}","target":0,"code_token_length":826,"total_token_length":1062,"max_tokens_setting":2048}
+{"idx":484057,"func":"START_TEST(Securechannel_sendAsymmetricOPNMessage_extraPaddingPresentWhenKeyLargerThan2048Bits) {\n    keySizes.asym_rmt_enc_key_size = 4096;\n    keySizes.asym_rmt_blocksize = 4096;\n    keySizes.asym_rmt_ptext_blocksize = 4096;\n\n    UA_OpenSecureChannelResponse dummyResponse;\n    createDummyResponse(&dummyResponse);\n\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;\n    UA_UInt32 requestId = UA_UInt32_random();\n\n    UA_StatusCode retval =\n        UA_SecureChannel_sendAsymmetricOPNMessage(&testChannel, requestId, &dummyResponse,\n                                                  &UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);\n    ck_assert_msg(retval == UA_STATUSCODE_GOOD, \"Expected function to succeed\");\n\n    size_t offset = 0;\n    UA_TcpMessageHeader header;\n    UA_TcpMessageHeader_decodeBinary(&sentData, &offset, &header);\n    UA_UInt32 secureChannelId;\n    UA_UInt32_decodeBinary(&sentData, &offset, &secureChannelId);\n\n    UA_AsymmetricAlgorithmSecurityHeader asymSecurityHeader;\n    UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(&sentData, &offset, &asymSecurityHeader);\n    ck_assert_msg(UA_ByteString_equal(&dummyCertificate, &asymSecurityHeader.senderCertificate),\n                  \"Expected the certificate to be equal to the one used  by the secureChannel\");\n    ck_assert_msg(UA_ByteString_equal(&testChannel.securityPolicy->policyUri,\n                                      &asymSecurityHeader.securityPolicyUri),\n                  \"Expected securityPolicyUri to be equal to the one used by the secureChannel\");\n    UA_ByteString thumbPrint = {20, testChannel.remoteCertificateThumbprint};\n    ck_assert_msg(UA_ByteString_equal(&thumbPrint,\n                                      &asymSecurityHeader.receiverCertificateThumbprint),\n                  \"Expected receiverCertificateThumbprint to be equal to the one set \"\n                  \"in the secureChannel\");\n\n    for(size_t i = offset; i < header.messageSize; ++i) {\n        sentData.data[i] = (UA_Byte)((sentData.data[i] - 1) % (UA_BYTE_MAX + 1));\n    }\n\n    UA_SequenceHeader sequenceHeader;\n    UA_SequenceHeader_decodeBinary(&sentData, &offset, &sequenceHeader);\n    ck_assert_msg(sequenceHeader.requestId == requestId, \"Expected requestId to be %i but was %i\",\n                  requestId, sequenceHeader.requestId);\n\n    UA_NodeId requestTypeId;\n    UA_NodeId_decodeBinary(&sentData, &offset, &requestTypeId);\n    ck_assert_msg(UA_NodeId_equal(&UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE].binaryEncodingId, &requestTypeId), \"Expected nodeIds to be equal\");\n\n    UA_OpenSecureChannelResponse sentResponse;\n    UA_OpenSecureChannelResponse_decodeBinary(&sentData, &offset, &sentResponse);\n\n    ck_assert_msg(memcmp(&sentResponse, &dummyResponse, sizeof(UA_OpenSecureChannelResponse)) == 0,\n                  \"Expected the sent response to be equal to the one supplied to the send function\");\n\n    UA_Byte paddingByte = sentData.data[offset];\n    UA_Byte extraPaddingByte = sentData.data[sentData.length - keySizes.asym_lcl_sig_size - 1];\n    size_t paddingSize = (size_t)paddingByte;\n    paddingSize |= extraPaddingByte << 8;\n\n    for(size_t i = 0; i <= paddingSize; ++i) {\n        ck_assert_msg(sentData.data[offset + i] == paddingByte,\n                      \"Expected padding byte %i to be %i but got value %i\",\n                      (int)i, paddingByte, sentData.data[offset + i]);\n    }\n\n    ck_assert_msg(sentData.data[offset + paddingSize + 1] == extraPaddingByte,\n                  \"Expected extra padding byte to be %i but got %i\",\n                  extraPaddingByte, sentData.data[offset + paddingSize + 1]);\n    ck_assert_msg(sentData.data[offset + paddingSize + 2] == '*',\n                  \"Expected first byte 42 of signature but got %i\",\n                  sentData.data[offset + paddingSize + 2]);\n\n    UA_AsymmetricAlgorithmSecurityHeader_clear(&asymSecurityHeader);\n    UA_SequenceHeader_clear(&sequenceHeader);\n    UA_OpenSecureChannelResponse_clear(&sentResponse);\n}END_TEST","target":0,"code_token_length":944,"total_token_length":1180,"max_tokens_setting":2048}
+{"idx":452388,"func":"static MagickBooleanType WriteGROUP4Image(const ImageInfo *image_info,\n  Image *image)\n{\n  char\n    filename[MaxTextExtent];\n\n  FILE\n    *file;\n\n  Image\n    *huffman_image;\n\n  ImageInfo\n    *write_info;\n\n  int\n    unique_file;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    i;\n\n  ssize_t\n    count;\n\n  TIFF\n    *tiff;\n\n  toff_t\n    *byte_count,\n    strip_size;\n\n  unsigned char\n    *buffer;\n\n  \/*\n    Write image as CCITT Group4 TIFF image to a temporary file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (IsEventLogging() != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  huffman_image=CloneImage(image,0,0,MagickTrue,&image->exception);\n  if (huffman_image == (Image *) NULL)\n    {\n      (void) CloseBlob(image);\n      return(MagickFalse);\n    }\n  huffman_image->endian=MSBEndian;\n  file=(FILE *) NULL;\n  unique_file=AcquireUniqueFileResource(filename);\n  if (unique_file != -1)\n    file=fdopen(unique_file,\"wb\");\n  if ((unique_file == -1) || (file == (FILE *) NULL))\n    {\n      ThrowFileException(&image->exception,FileOpenError,\n        \"UnableToCreateTemporaryFile\",filename);\n      return(MagickFalse);\n    }\n  (void) FormatLocaleString(huffman_image->filename,MaxTextExtent,\"tiff:%s\",\n    filename);\n  if (IsMonochromeImage(image,&image->exception) != MagickFalse)\n    (void) SetImageType(huffman_image,BilevelType);\n  write_info=CloneImageInfo((ImageInfo *) NULL);\n  SetImageInfoFile(write_info,file);\n  if (IsMonochromeImage(image,&image->exception) == MagickFalse)\n    (void) SetImageType(image,BilevelType);\n  (void) SetImageDepth(image,1);\n  write_info->compression=Group4Compression;\n  write_info->type=BilevelType;\n  status=WriteTIFFImage(write_info,huffman_image);\n  (void) fflush(file);\n  write_info=DestroyImageInfo(write_info);\n  if (status == MagickFalse)\n    {\n      InheritException(&image->exception,&huffman_image->exception);\n      huffman_image=DestroyImage(huffman_image);\n      (void) fclose(file);\n      (void) RelinquishUniqueFileResource(filename);\n      return(MagickFalse);\n    }\n  tiff=TIFFOpen(filename,\"rb\");\n  if (tiff == (TIFF *) NULL)\n    {\n      huffman_image=DestroyImage(huffman_image);\n      (void) fclose(file);\n      (void) RelinquishUniqueFileResource(filename);\n      ThrowFileException(&image->exception,FileOpenError,\"UnableToOpenFile\",\n        image_info->filename);\n      return(MagickFalse);\n    }\n  \/*\n    Allocate raw strip buffer.\n  *\/\n  if (TIFFGetField(tiff,TIFFTAG_STRIPBYTECOUNTS,&byte_count) != 1)\n    {\n      TIFFClose(tiff);\n      huffman_image=DestroyImage(huffman_image);\n      (void) fclose(file);\n      (void) RelinquishUniqueFileResource(filename);\n      return(MagickFalse);\n    }\n  strip_size=byte_count[0];\n  for (i=1; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)\n    if (byte_count[i] > strip_size)\n      strip_size=byte_count[i];\n  buffer=(unsigned char *) AcquireQuantumMemory((size_t) strip_size,\n    sizeof(*buffer));\n  if (buffer == (unsigned char *) NULL)\n    {\n      TIFFClose(tiff);\n      huffman_image=DestroyImage(huffman_image);\n      (void) fclose(file);\n      (void) RelinquishUniqueFileResource(filename);\n      ThrowBinaryImageException(ResourceLimitError,\"MemoryAllocationFailed\",\n        image_info->filename);\n    }\n  \/*\n    Compress runlength encoded to 2D Huffman pixels.\n  *\/\n  for (i=0; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)\n  {\n    count=(ssize_t) TIFFReadRawStrip(tiff,(uint32) i,buffer,strip_size);\n    if (WriteBlob(image,(size_t) count,buffer) != count)\n      status=MagickFalse;\n  }\n  buffer=(unsigned char *) RelinquishMagickMemory(buffer);\n  TIFFClose(tiff);\n  huffman_image=DestroyImage(huffman_image);\n  (void) fclose(file);\n  (void) RelinquishUniqueFileResource(filename);\n  (void) CloseBlob(image);\n  return(status);\n}","target":0,"code_token_length":1094,"total_token_length":1330,"max_tokens_setting":2048}
+{"idx":326643,"func":"set_mode(struct archive_write_disk *a, int mode)\n{\n\tint r = ARCHIVE_OK;\n\tint r2;\n\tmode &= 07777; \/* Strip off file type bits. *\/\n\n\tif (a->todo & TODO_SGID_CHECK) {\n\t\t\/*\n\t\t * If we don't know the GID is right, we must stat()\n\t\t * to verify it.  We can't just check the GID of this\n\t\t * process, since systems sometimes set GID from\n\t\t * the enclosing dir or based on ACLs.\n\t\t *\/\n\t\tif ((r = lazy_stat(a)) != ARCHIVE_OK)\n\t\t\treturn (r);\n\t\tif (a->pst->st_gid != a->gid) {\n\t\t\tmode &= ~ S_ISGID;\n\t\t\tif (a->flags & ARCHIVE_EXTRACT_OWNER) {\n\t\t\t\t\/*\n\t\t\t\t * This is only an error if you\n\t\t\t\t * requested owner restore.  If you\n\t\t\t\t * didn't, we'll try to restore\n\t\t\t\t * sgid\/suid, but won't consider it a\n\t\t\t\t * problem if we can't.\n\t\t\t\t *\/\n\t\t\t\tarchive_set_error(&a->archive, -1,\n\t\t\t\t    \"Can't restore SGID bit\");\n\t\t\t\tr = ARCHIVE_WARN;\n\t\t\t}\n\t\t}\n\t\t\/* While we're here, double-check the UID. *\/\n\t\tif (a->pst->st_uid != a->uid\n\t\t    && (a->todo & TODO_SUID)) {\n\t\t\tmode &= ~ S_ISUID;\n\t\t\tif (a->flags & ARCHIVE_EXTRACT_OWNER) {\n\t\t\t\tarchive_set_error(&a->archive, -1,\n\t\t\t\t    \"Can't restore SUID bit\");\n\t\t\t\tr = ARCHIVE_WARN;\n\t\t\t}\n\t\t}\n\t\ta->todo &= ~TODO_SGID_CHECK;\n\t\ta->todo &= ~TODO_SUID_CHECK;\n\t} else if (a->todo & TODO_SUID_CHECK) {\n\t\t\/*\n\t\t * If we don't know the UID is right, we can just check\n\t\t * the user, since all systems set the file UID from\n\t\t * the process UID.\n\t\t *\/\n\t\tif (a->user_uid != a->uid) {\n\t\t\tmode &= ~ S_ISUID;\n\t\t\tif (a->flags & ARCHIVE_EXTRACT_OWNER) {\n\t\t\t\tarchive_set_error(&a->archive, -1,\n\t\t\t\t    \"Can't make file SUID\");\n\t\t\t\tr = ARCHIVE_WARN;\n\t\t\t}\n\t\t}\n\t\ta->todo &= ~TODO_SUID_CHECK;\n\t}\n\n\tif (S_ISLNK(a->mode)) {\n#ifdef HAVE_LCHMOD\n\t\t\/*\n\t\t * If this is a symlink, use lchmod().  If the\n\t\t * platform doesn't support lchmod(), just skip it.  A\n\t\t * platform that doesn't provide a way to set\n\t\t * permissions on symlinks probably ignores\n\t\t * permissions on symlinks, so a failure here has no\n\t\t * impact.\n\t\t *\/\n\t\tif (lchmod(a->name, mode) != 0) {\n\t\t\tswitch (errno) {\n\t\t\tcase ENOTSUP:\n\t\t\tcase ENOSYS:\n#if ENOTSUP != EOPNOTSUPP\n\t\t\tcase EOPNOTSUPP:\n#endif\n\t\t\t\t\/*\n\t\t\t\t * if lchmod is defined but the platform\n\t\t\t\t * doesn't support it, silently ignore\n\t\t\t\t * error\n\t\t\t\t *\/\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t    \"Can't set permissions to 0%o\", (int)mode);\n\t\t\t\tr = ARCHIVE_WARN;\n\t\t\t}\n\t\t}\n#endif\n\t} else if (!S_ISDIR(a->mode)) {\n\t\t\/*\n\t\t * If it's not a symlink and not a dir, then use\n\t\t * fchmod() or chmod(), depending on whether we have\n\t\t * an fd.  Dirs get their perms set during the\n\t\t * post-extract fixup, which is handled elsewhere.\n\t\t *\/\n#ifdef HAVE_FCHMOD\n\t\tif (a->fd >= 0)\n\t\t\tr2 = fchmod(a->fd, mode);\n\t\telse\n#endif\n\t\t\/* If this platform lacks fchmod(), then\n\t\t * we'll just use chmod(). *\/\n\t\tr2 = chmod(a->name, mode);\n\n\t\tif (r2 != 0) {\n\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t    \"Can't set permissions to 0%o\", (int)mode);\n\t\t\tr = ARCHIVE_WARN;\n\t\t}\n\t}\n\treturn (r);\n}","target":0,"code_token_length":954,"total_token_length":1190,"max_tokens_setting":2048}
+{"idx":220842,"func":"log_x_for_x_greater_than_or_equal_to_1_impl(\n    gemmlowp::FixedPoint<int32_t, InputIntegerBits> input_val) {\n  \/\/ assert(__builtin_clz(0u) >= std::numeric_limits<uint32_t>::digits - 1);\n  \/\/ assert(__builtin_clz(0u) <= std::numeric_limits<uint32_t>::digits);\n  using FixedPoint0 = gemmlowp::FixedPoint<int32_t, 0>;\n  \/\/ The reason for accumulating the result with an extra bit of headroom is\n  \/\/ that z_pow_2_adj * log_2 might be saturated, and adding num_scaled *\n  \/\/ recip_denom will otherwise introduce an error.\n  static constexpr int kAccumIntegerBits = OutputIntegerBits + 1;\n  using FixedPointAccum = gemmlowp::FixedPoint<int32_t, kAccumIntegerBits>;\n\n  const FixedPoint0 log_2 = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 1488522236, std::log(2.0));\n  const FixedPoint0 sqrt_sqrt_half = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 1805811301, std::sqrt(std::sqrt(0.5)));\n  const FixedPoint0 sqrt_half = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 1518500250, std::sqrt(0.5));\n  const FixedPoint0 one_quarter =\n      GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(FixedPoint0, 536870912, 1.0 \/ 4.0);\n\n  const FixedPoint0 alpha_n = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 117049297, 11.0 \/ 240.0 * std::sqrt(std::sqrt(2.0)));\n  const FixedPoint0 alpha_d = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 127690142, 1.0 \/ 20.0 * std::sqrt(std::sqrt(2.0)));\n  const FixedPoint0 alpha_i = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 1057819769,\n      2.0 \/ std::sqrt(std::sqrt(2.0)) - std::sqrt(std::sqrt(2.0)));\n  const FixedPoint0 alpha_f = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(\n      FixedPoint0, 638450708, 1.0 \/ 4.0 * std::sqrt(std::sqrt(2.0)));\n\n  const FixedPointAccum shifted_quarter =\n      gemmlowp::Rescale<kAccumIntegerBits>(one_quarter);\n\n  \/\/ Reinterpret the input value as Q0.31, because we will figure out the\n  \/\/ required shift \"ourselves\" instead of using, say, Rescale.\n  FixedPoint0 z_a = FixedPoint0::FromRaw(input_val.raw());\n  \/\/ z_a_pow_2 = input_integer_bits - z_a_headroom;\n  int z_a_headroom_plus_1 = CountLeadingZeros(static_cast<uint32_t>(z_a.raw()));\n  FixedPoint0 r_a_tmp =\n      SaturatingRoundingMultiplyByPOTParam(z_a, (z_a_headroom_plus_1 - 1));\n  const int32_t r_a_raw =\n      SaturatingRoundingMultiplyByPOTParam((r_a_tmp * sqrt_half).raw(), 1);\n  \/\/ z_pow_2_adj = max(z_pow_2_a - 0.75, z_pow_2_b - 0.25);\n  \/\/ z_pow_2_adj = max(InputIntegerBits - z_a_headroom_plus_1 + 0.25,\n  \/\/                   InputIntegerBits - z_b_headroom - 0.25);\n  const FixedPointAccum z_a_pow_2_adj = SaturatingAddNonGemmlowp(\n      FixedPointAccum::FromRaw(SaturatingRoundingMultiplyByPOTParam(\n          static_cast<int32_t>(InputIntegerBits - z_a_headroom_plus_1),\n          31 - kAccumIntegerBits)),\n      shifted_quarter);\n\n  \/\/ z_b is treated like z_a, but premultiplying by sqrt(0.5).\n  FixedPoint0 z_b = z_a * sqrt_half;\n  int z_b_headroom = CountLeadingZeros(static_cast<uint32_t>(z_b.raw())) - 1;\n  const int32_t r_b_raw =\n      SaturatingRoundingMultiplyByPOTParam(z_a.raw(), z_b_headroom);\n  const FixedPointAccum z_b_pow_2_adj = SaturatingSub(\n      FixedPointAccum::FromRaw(SaturatingRoundingMultiplyByPOTParam(\n          static_cast<int32_t>(InputIntegerBits - z_b_headroom),\n          31 - kAccumIntegerBits)),\n      shifted_quarter);\n\n  const FixedPoint0 r = FixedPoint0::FromRaw(std::min(r_a_raw, r_b_raw));\n  const FixedPointAccum z_pow_2_adj = FixedPointAccum::FromRaw(\n      std::max(z_a_pow_2_adj.raw(), z_b_pow_2_adj.raw()));\n\n  const FixedPoint0 p = gemmlowp::RoundingHalfSum(r, sqrt_sqrt_half);\n  FixedPoint0 q = r - sqrt_sqrt_half;\n  q = q + q;\n\n  const FixedPoint0 common_sq = q * q;\n  const FixedPoint0 num = q * r + q * common_sq * alpha_n;\n  const FixedPoint0 denom_minus_one_0 =\n      p * (alpha_i + q + alpha_d * common_sq) + alpha_f * q;\n  const FixedPoint0 recip_denom =\n      one_over_one_plus_x_for_x_in_0_1(denom_minus_one_0);\n\n  const FixedPointAccum num_scaled = gemmlowp::Rescale<kAccumIntegerBits>(num);\n  return gemmlowp::Rescale<OutputIntegerBits>(z_pow_2_adj * log_2 +\n                                              num_scaled * recip_denom);\n}","target":0,"code_token_length":1379,"total_token_length":1615,"max_tokens_setting":2048}
+{"idx":473888,"func":"onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,\n\t      OnigErrorInfo* einfo, const char *sourcefile, int sourceline)\n{\n#define COMPILE_INIT_SIZE  20\n\n  int r;\n  OnigDistance init_size;\n  Node*  root;\n  ScanEnv  scan_env = {0};\n#ifdef USE_SUBEXP_CALL\n  UnsetAddrList  uslist;\n#endif\n\n  if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;\n\n  scan_env.sourcefile = sourcefile;\n  scan_env.sourceline = sourceline;\n  reg->state = ONIG_STATE_COMPILING;\n\n#ifdef ONIG_DEBUG\n  if (!onig_is_prelude()) print_enc_string(stderr, reg->enc, pattern, pattern_end);\n#endif\n\n  if (reg->alloc == 0) {\n    init_size = (pattern_end - pattern) * 2;\n    if (init_size <= 0) init_size = COMPILE_INIT_SIZE;\n    r = BBUF_INIT(reg, init_size);\n    if (r != 0) goto end;\n  }\n  else\n    reg->used = 0;\n\n  reg->num_mem            = 0;\n  reg->num_repeat         = 0;\n  reg->num_null_check     = 0;\n  reg->repeat_range_alloc = 0;\n  reg->repeat_range       = (OnigRepeatRange* )NULL;\n#ifdef USE_COMBINATION_EXPLOSION_CHECK\n  reg->num_comb_exp_check = 0;\n#endif\n\n  r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env);\n  if (r != 0) goto err;\n\n#ifdef ONIG_DEBUG_PARSE_TREE\n# if 0\n  fprintf(stderr, \"ORIGINAL PARSE TREE:\\n\");\n  if (!onig_is_prelude()) {\n    print_tree(stderr, root);\n  }\n# endif\n#endif\n\n#ifdef USE_NAMED_GROUP\n  \/* mixed use named group and no-named group *\/\n  if (scan_env.num_named > 0 &&\n      IS_SYNTAX_BV(scan_env.syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&\n      !ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_CAPTURE_GROUP)) {\n    if (scan_env.num_named != scan_env.num_mem)\n      r = disable_noname_group_capture(&root, reg, &scan_env);\n    else\n      r = numbered_ref_check(root);\n\n    if (r != 0) goto err;\n  }\n#endif\n\n#ifdef USE_SUBEXP_CALL\n  if (scan_env.num_call > 0) {\n    r = unset_addr_list_init(&uslist, scan_env.num_call);\n    if (r != 0) goto err;\n    scan_env.unset_addr_list = &uslist;\n    r = setup_subexp_call(root, &scan_env);\n    if (r != 0) goto err_unset;\n    r = subexp_recursive_check_trav(root, &scan_env);\n    if (r  < 0) goto err_unset;\n    r = subexp_inf_recursive_check_trav(root, &scan_env);\n    if (r != 0) goto err_unset;\n\n    reg->num_call = scan_env.num_call;\n  }\n  else\n    reg->num_call = 0;\n#endif\n\n  r = setup_tree(root, reg, 0, &scan_env);\n  if (r != 0) goto err_unset;\n\n#ifdef ONIG_DEBUG_PARSE_TREE\n  if (!onig_is_prelude()) print_tree(stderr, root);\n#endif\n\n  reg->capture_history  = scan_env.capture_history;\n  reg->bt_mem_start     = scan_env.bt_mem_start;\n  reg->bt_mem_start    |= reg->capture_history;\n  if (IS_FIND_CONDITION(reg->options))\n    BIT_STATUS_ON_ALL(reg->bt_mem_end);\n  else {\n    reg->bt_mem_end  = scan_env.bt_mem_end;\n    reg->bt_mem_end |= reg->capture_history;\n  }\n\n#ifdef USE_COMBINATION_EXPLOSION_CHECK\n  if (scan_env.backrefed_mem == 0\n#ifdef USE_SUBEXP_CALL\n      || scan_env.num_call == 0\n#endif\n      ) {\n    setup_comb_exp_check(root, 0, &scan_env);\n#ifdef USE_SUBEXP_CALL\n    if (scan_env.has_recursion != 0) {\n      scan_env.num_comb_exp_check = 0;\n    }\n    else\n#endif\n    if (scan_env.comb_exp_max_regnum > 0) {\n      int i;\n      for (i = 1; i <= scan_env.comb_exp_max_regnum; i++) {\n\tif (BIT_STATUS_AT(scan_env.backrefed_mem, i) != 0) {\n\t  scan_env.num_comb_exp_check = 0;\n\t  break;\n\t}\n      }\n    }\n  }\n\n  reg->num_comb_exp_check = scan_env.num_comb_exp_check;\n#endif\n\n  clear_optimize_info(reg);\n#ifndef ONIG_DONT_OPTIMIZE\n  r = set_optimize_info_from_tree(root, reg, &scan_env);\n  if (r != 0) goto err_unset;\n#endif\n\n  if (IS_NOT_NULL(scan_env.mem_nodes_dynamic)) {\n    xfree(scan_env.mem_nodes_dynamic);\n    scan_env.mem_nodes_dynamic = (Node** )NULL;\n  }\n\n  r = compile_tree(root, reg);\n  if (r == 0) {\n    r = add_opcode(reg, OP_END);\n#ifdef USE_SUBEXP_CALL\n    if (scan_env.num_call > 0) {\n      r = unset_addr_list_fix(&uslist, reg);\n      unset_addr_list_end(&uslist);\n      if (r) goto err;\n    }\n#endif\n\n    if ((reg->num_repeat != 0) || (reg->bt_mem_end != 0))\n      reg->stack_pop_level = STACK_POP_LEVEL_ALL;\n    else {\n      if (reg->bt_mem_start != 0)\n\treg->stack_pop_level = STACK_POP_LEVEL_MEM_START;\n      else\n\treg->stack_pop_level = STACK_POP_LEVEL_FREE;\n    }\n  }\n#ifdef USE_SUBEXP_CALL\n  else if (scan_env.num_call > 0) {\n    unset_addr_list_end(&uslist);\n  }\n#endif\n  onig_node_free(root);\n\n#ifdef ONIG_DEBUG_COMPILE\n#ifdef USE_NAMED_GROUP\n  if (!onig_is_prelude()) onig_print_names(stderr, reg);\n#endif\n  if (!onig_is_prelude()) print_compiled_byte_code_list(stderr, reg);\n#endif\n\n end:\n  reg->state = ONIG_STATE_NORMAL;\n  return r;\n\n err_unset:\n#ifdef USE_SUBEXP_CALL\n  if (scan_env.num_call > 0) {\n    unset_addr_list_end(&uslist);\n  }\n#endif\n err:\n  if (IS_NOT_NULL(scan_env.error)) {\n    if (IS_NOT_NULL(einfo)) {\n      einfo->enc     = scan_env.enc;\n      einfo->par     = scan_env.error;\n      einfo->par_end = scan_env.error_end;\n    }\n  }\n\n  onig_node_free(root);\n  if (IS_NOT_NULL(scan_env.mem_nodes_dynamic))\n      xfree(scan_env.mem_nodes_dynamic);\n  return r;\n}","target":0,"code_token_length":1520,"total_token_length":1756,"max_tokens_setting":2048}
+{"idx":383311,"func":"void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)\n{\n\tint x, y;\n\tif (!dst->trueColor) {\n\t\tgdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);\n\t\treturn;\n\t}\n\tfor (y = dstY; (y < dstY + dstH); y++) {\n\t\tfor (x = dstX; (x < dstX + dstW); x++) {\n\t\t\tfloat sy1, sy2, sx1, sx2;\n\t\t\tfloat sx, sy;\n\t\t\tfloat spixels = 0.0f;\n\t\t\tfloat red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;\n\t\t\tfloat alpha_factor, alpha_sum = 0.0f, contrib_sum = 0.0f;\n\t\t\tsy1 = ((float)(y - dstY)) * (float)srcH \/ (float)dstH;\n\t\t\tsy2 = ((float)(y + 1 - dstY)) * (float) srcH \/ (float) dstH;\n\t\t\tsy = sy1;\n\t\t\tdo {\n\t\t\t\tfloat yportion;\n\t\t\t\tif (floor_cast(sy) == floor_cast(sy1)) {\n\t\t\t\t\typortion = 1.0f - (sy - floor_cast(sy));\n\t\t\t\t\tif (yportion > sy2 - sy1) {\n\t\t\t\t\t\typortion = sy2 - sy1;\n\t\t\t\t\t}\n\t\t\t\t\tsy = floor_cast(sy);\n\t\t\t\t} else if (sy == floorf(sy2)) {\n\t\t\t\t\typortion = sy2 - floor_cast(sy2);\n\t\t\t\t} else {\n\t\t\t\t\typortion = 1.0f;\n\t\t\t\t}\n\t\t\t\tsx1 = ((float)(x - dstX)) * (float) srcW \/ dstW;\n\t\t\t\tsx2 = ((float)(x + 1 - dstX)) * (float) srcW \/ dstW;\n\t\t\t\tsx = sx1;\n\t\t\t\tdo {\n\t\t\t\t\tfloat xportion;\n\t\t\t\t\tfloat pcontribution;\n\t\t\t\t\tint p;\n\t\t\t\t\tif (floorf(sx) == floor_cast(sx1)) {\n\t\t\t\t\t\txportion = 1.0f - (sx - floor_cast(sx));\n\t\t\t\t\t\tif (xportion > sx2 - sx1) {\n\t\t\t\t\t\t\txportion = sx2 - sx1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsx = floor_cast(sx);\n\t\t\t\t\t} else if (sx == floorf(sx2)) {\n\t\t\t\t\t\txportion = sx2 - floor_cast(sx2);\n\t\t\t\t\t} else {\n\t\t\t\t\t\txportion = 1.0f;\n\t\t\t\t\t}\n\t\t\t\t\tpcontribution = xportion * yportion;\n\t\t\t\t\tp = gdImageGetTrueColorPixel(src, (int) sx + srcX, (int) sy + srcY);\n\t\t\t\t\t\n\t\t\t\t\talpha_factor = ((gdAlphaMax - gdTrueColorGetAlpha(p))) * pcontribution;\n\t\t\t\t\tred += gdTrueColorGetRed (p) * alpha_factor;\n\t\t\t\t\tgreen += gdTrueColorGetGreen (p) * alpha_factor;\n\t\t\t\t\tblue += gdTrueColorGetBlue (p) * alpha_factor;\n\t\t\t\t\talpha += gdTrueColorGetAlpha (p) * pcontribution;\n\t\t\t\t\talpha_sum += alpha_factor;\n\t\t\t\t\tcontrib_sum += pcontribution;\n\t\t\t\t\tspixels += xportion * yportion;\n\t\t\t\t\tsx += 1.0f;\n\t\t\t\t}\n\t\t\t\twhile (sx < sx2);\n\t\t\t\n\t\t\t\tsy += 1.0f;\n\t\t\t}\n\t\t\t\n\t\t\twhile (sy < sy2);\n\t\t\t\n\t\t\tif (spixels != 0.0f) {\n\t\t\t\tred \/= spixels;\n\t\t\t\tgreen \/= spixels;\n\t\t\t\tblue \/= spixels;\n\t\t\t\talpha \/= spixels;\n\t\t\t}\n\t\t\tif ( alpha_sum != 0.0f) {\n\t\t\t\tif( contrib_sum != 0.0f) {\n\t\t\t\t\talpha_sum \/= contrib_sum;\n\t\t\t\t}\t\n\t\t\t\tred \/= alpha_sum;\n\t\t\t\tgreen \/= alpha_sum;\n\t\t\t\tblue \/= alpha_sum;\n\t\t\t}\n\t\t\t\/* Clamping to allow for rounding errors above *\/\n\t\t\tif (red > 255.0f) {\n\t\t\t\tred = 255.0f;\n\t\t\t}\n\t\t\tif (green > 255.0f) {\n\t\t\t\tgreen = 255.0f;\n\t\t\t}\n\t\t\tif (blue > 255.0f) {\n\t\t\t\tblue = 255.0f;\n\t\t\t}\n\t\t\tif (alpha > gdAlphaMax) {\n\t\t\t\talpha = gdAlphaMax;\n\t\t\t}\n\t\t\tgdImageSetPixel(dst, x, y, gdTrueColorAlpha ((int) red, (int) green, (int) blue, (int) alpha));\n\t\t}\n\t}\n}","target":0,"code_token_length":1065,"total_token_length":1301,"max_tokens_setting":2048}
+{"idx":225012,"func":"conninfo_parse(const char *conninfo, PQExpBuffer errorMessage,\n\t\t\t   bool use_defaults)\n{\n\tchar\t   *pname;\n\tchar\t   *pval;\n\tchar\t   *buf;\n\tchar\t   *cp;\n\tchar\t   *cp2;\n\tPQconninfoOption *options;\n\n\t\/* Make a working copy of PQconninfoOptions *\/\n\toptions = conninfo_init(errorMessage);\n\tif (options == NULL)\n\t\treturn NULL;\n\n\t\/* Need a modifiable copy of the input string *\/\n\tif ((buf = strdup(conninfo)) == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"out of memory\\n\"));\n\t\tPQconninfoFree(options);\n\t\treturn NULL;\n\t}\n\tcp = buf;\n\n\twhile (*cp)\n\t{\n\t\t\/* Skip blanks before the parameter name *\/\n\t\tif (isspace((unsigned char) *cp))\n\t\t{\n\t\t\tcp++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Get the parameter name *\/\n\t\tpname = cp;\n\t\twhile (*cp)\n\t\t{\n\t\t\tif (*cp == '=')\n\t\t\t\tbreak;\n\t\t\tif (isspace((unsigned char) *cp))\n\t\t\t{\n\t\t\t\t*cp++ = '\\0';\n\t\t\t\twhile (*cp)\n\t\t\t\t{\n\t\t\t\t\tif (!isspace((unsigned char) *cp))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcp++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcp++;\n\t\t}\n\n\t\t\/* Check that there is a following '=' *\/\n\t\tif (*cp != '=')\n\t\t{\n\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"missing \\\"=\\\" after \\\"%s\\\" in connection info string\\n\"),\n\t\t\t\t\t\t\t  pname);\n\t\t\tPQconninfoFree(options);\n\t\t\tfree(buf);\n\t\t\treturn NULL;\n\t\t}\n\t\t*cp++ = '\\0';\n\n\t\t\/* Skip blanks after the '=' *\/\n\t\twhile (*cp)\n\t\t{\n\t\t\tif (!isspace((unsigned char) *cp))\n\t\t\t\tbreak;\n\t\t\tcp++;\n\t\t}\n\n\t\t\/* Get the parameter value *\/\n\t\tpval = cp;\n\n\t\tif (*cp != '\\'')\n\t\t{\n\t\t\tcp2 = pval;\n\t\t\twhile (*cp)\n\t\t\t{\n\t\t\t\tif (isspace((unsigned char) *cp))\n\t\t\t\t{\n\t\t\t\t\t*cp++ = '\\0';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (*cp == '\\\\')\n\t\t\t\t{\n\t\t\t\t\tcp++;\n\t\t\t\t\tif (*cp != '\\0')\n\t\t\t\t\t\t*cp2++ = *cp++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t*cp2++ = *cp++;\n\t\t\t}\n\t\t\t*cp2 = '\\0';\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcp2 = pval;\n\t\t\tcp++;\n\t\t\tfor (;;)\n\t\t\t{\n\t\t\t\tif (*cp == '\\0')\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"unterminated quoted string in connection info string\\n\"));\n\t\t\t\t\tPQconninfoFree(options);\n\t\t\t\t\tfree(buf);\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t\tif (*cp == '\\\\')\n\t\t\t\t{\n\t\t\t\t\tcp++;\n\t\t\t\t\tif (*cp != '\\0')\n\t\t\t\t\t\t*cp2++ = *cp++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (*cp == '\\'')\n\t\t\t\t{\n\t\t\t\t\t*cp2 = '\\0';\n\t\t\t\t\tcp++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t*cp2++ = *cp++;\n\t\t\t}\n\t\t}\n\n\t\t\/*\n\t\t * Now that we have the name and the value, store the record.\n\t\t *\/\n\t\tif (!conninfo_storeval(options, pname, pval, errorMessage, false, false))\n\t\t{\n\t\t\tPQconninfoFree(options);\n\t\t\tfree(buf);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\t\/* Done with the modifiable input string *\/\n\tfree(buf);\n\n\t\/*\n\t * Add in defaults if the caller wants that.\n\t *\/\n\tif (use_defaults)\n\t{\n\t\tif (!conninfo_add_defaults(options, errorMessage))\n\t\t{\n\t\t\tPQconninfoFree(options);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\treturn options;\n}","target":0,"code_token_length":821,"total_token_length":1057,"max_tokens_setting":2048}
+{"idx":199681,"func":"static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,\n\t\t    unsigned long param)\n{\n\tint drive = (long)bdev->bd_disk->private_data;\n\tint type = ITYPE(drive_state[drive].fd_device);\n\tint i;\n\tint ret;\n\tint size;\n\tunion inparam {\n\t\tstruct floppy_struct g;\t\/* geometry *\/\n\t\tstruct format_descr f;\n\t\tstruct floppy_max_errors max_errors;\n\t\tstruct floppy_drive_params dp;\n\t} inparam;\t\t\/* parameters coming from user space *\/\n\tconst void *outparam;\t\/* parameters passed back to user space *\/\n\n\t\/* convert compatibility eject ioctls into floppy eject ioctl.\n\t * We do this in order to provide a means to eject floppy disks before\n\t * installing the new fdutils package *\/\n\tif (cmd == CDROMEJECT ||\t\/* CD-ROM eject *\/\n\t    cmd == 0x6470) {\t\t\/* SunOS floppy eject *\/\n\t\tDPRINT(\"obsolete eject ioctl\\n\");\n\t\tDPRINT(\"please use floppycontrol --eject\\n\");\n\t\tcmd = FDEJECT;\n\t}\n\n\tif (!((cmd & 0xff00) == 0x0200))\n\t\treturn -EINVAL;\n\n\t\/* convert the old style command into a new style command *\/\n\tret = normalize_ioctl(&cmd, &size);\n\tif (ret)\n\t\treturn ret;\n\n\t\/* permission checks *\/\n\tif (((cmd & 0x40) && !(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) ||\n\t    ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))\n\t\treturn -EPERM;\n\n\tif (WARN_ON(size < 0 || size > sizeof(inparam)))\n\t\treturn -EINVAL;\n\n\t\/* copyin *\/\n\tmemset(&inparam, 0, sizeof(inparam));\n\tif (_IOC_DIR(cmd) & _IOC_WRITE) {\n\t\tret = fd_copyin((void __user *)param, &inparam, size);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tswitch (cmd) {\n\tcase FDEJECT:\n\t\tif (drive_state[drive].fd_ref != 1)\n\t\t\t\/* somebody else has this drive open *\/\n\t\t\treturn -EBUSY;\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\n\t\t\/* do the actual eject. Fails on\n\t\t * non-Sparc architectures *\/\n\t\tret = fd_eject(UNIT(drive));\n\n\t\tset_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags);\n\t\tset_bit(FD_VERIFY_BIT, &drive_state[drive].flags);\n\t\tprocess_fd_request();\n\t\treturn ret;\n\tcase FDCLRPRM:\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\tcurrent_type[drive] = NULL;\n\t\tfloppy_sizes[drive] = MAX_DISK_SIZE << 1;\n\t\tdrive_state[drive].keep_data = 0;\n\t\treturn invalidate_drive(bdev);\n\tcase FDSETPRM:\n\tcase FDDEFPRM:\n\t\treturn set_geometry(cmd, &inparam.g, drive, type, bdev);\n\tcase FDGETPRM:\n\t\tret = get_floppy_geometry(drive, type,\n\t\t\t\t\t  (struct floppy_struct **)&outparam);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tmemcpy(&inparam.g, outparam,\n\t\t\t\toffsetof(struct floppy_struct, name));\n\t\toutparam = &inparam.g;\n\t\tbreak;\n\tcase FDMSGON:\n\t\tdrive_params[drive].flags |= FTD_MSG;\n\t\treturn 0;\n\tcase FDMSGOFF:\n\t\tdrive_params[drive].flags &= ~FTD_MSG;\n\t\treturn 0;\n\tcase FDFMTBEG:\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\tif (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)\n\t\t\treturn -EINTR;\n\t\tret = drive_state[drive].flags;\n\t\tprocess_fd_request();\n\t\tif (ret & FD_VERIFY)\n\t\t\treturn -ENODEV;\n\t\tif (!(ret & FD_DISK_WRITABLE))\n\t\t\treturn -EROFS;\n\t\treturn 0;\n\tcase FDFMTTRK:\n\t\tif (drive_state[drive].fd_ref != 1)\n\t\t\treturn -EBUSY;\n\t\treturn do_format(drive, &inparam.f);\n\tcase FDFMTEND:\n\tcase FDFLUSH:\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\treturn invalidate_drive(bdev);\n\tcase FDSETEMSGTRESH:\n\t\tdrive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f);\n\t\treturn 0;\n\tcase FDGETMAXERRS:\n\t\toutparam = &drive_params[drive].max_errors;\n\t\tbreak;\n\tcase FDSETMAXERRS:\n\t\tdrive_params[drive].max_errors = inparam.max_errors;\n\t\tbreak;\n\tcase FDGETDRVTYP:\n\t\toutparam = drive_name(type, drive);\n\t\tSUPBOUND(size, strlen((const char *)outparam) + 1);\n\t\tbreak;\n\tcase FDSETDRVPRM:\n\t\tif (!valid_floppy_drive_params(inparam.dp.autodetect,\n\t\t\t\tinparam.dp.native_format))\n\t\t\treturn -EINVAL;\n\t\tdrive_params[drive] = inparam.dp;\n\t\tbreak;\n\tcase FDGETDRVPRM:\n\t\toutparam = &drive_params[drive];\n\t\tbreak;\n\tcase FDPOLLDRVSTAT:\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\tif (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)\n\t\t\treturn -EINTR;\n\t\tprocess_fd_request();\n\t\tfallthrough;\n\tcase FDGETDRVSTAT:\n\t\toutparam = &drive_state[drive];\n\t\tbreak;\n\tcase FDRESET:\n\t\treturn user_reset_fdc(drive, (int)param, true);\n\tcase FDGETFDCSTAT:\n\t\toutparam = &fdc_state[FDC(drive)];\n\t\tbreak;\n\tcase FDWERRORCLR:\n\t\tmemset(&write_errors[drive], 0, sizeof(write_errors[drive]));\n\t\treturn 0;\n\tcase FDWERRORGET:\n\t\toutparam = &write_errors[drive];\n\t\tbreak;\n\tcase FDRAWCMD:\n\t\tif (type)\n\t\t\treturn -EINVAL;\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\tset_floppy(drive);\n\t\ti = raw_cmd_ioctl(cmd, (void __user *)param);\n\t\tif (i == -EINTR)\n\t\t\treturn -EINTR;\n\t\tprocess_fd_request();\n\t\treturn i;\n\tcase FDTWADDLE:\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\ttwaddle(current_fdc, current_drive);\n\t\tprocess_fd_request();\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tif (_IOC_DIR(cmd) & _IOC_READ)\n\t\treturn fd_copyout((void __user *)param, outparam, size);\n\n\treturn 0;\n}","target":1,"code_token_length":1449,"total_token_length":1685,"max_tokens_setting":2048}
+{"idx":381878,"func":"static void udf_merge_extents(struct inode *inode, struct kernel_long_ad *laarr,\n\t\t\t      int *endnum)\n{\n\tint i;\n\tunsigned long blocksize = inode->i_sb->s_blocksize;\n\tunsigned char blocksize_bits = inode->i_sb->s_blocksize_bits;\n\n\tfor (i = 0; i < (*endnum - 1); i++) {\n\t\tstruct kernel_long_ad *li \/*l[i]*\/ = &laarr[i];\n\t\tstruct kernel_long_ad *lip1 \/*l[i plus 1]*\/ = &laarr[i + 1];\n\n\t\tif (((li->extLength >> 30) == (lip1->extLength >> 30)) &&\n\t\t\t(((li->extLength >> 30) ==\n\t\t\t\t(EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) ||\n\t\t\t((lip1->extLocation.logicalBlockNum -\n\t\t\t  li->extLocation.logicalBlockNum) ==\n\t\t\t(((li->extLength & UDF_EXTENT_LENGTH_MASK) +\n\t\t\tblocksize - 1) >> blocksize_bits)))) {\n\n\t\t\tif (((li->extLength & UDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t(lip1->extLength & UDF_EXTENT_LENGTH_MASK) +\n\t\t\t\tblocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) {\n\t\t\t\tlip1->extLength = (lip1->extLength -\n\t\t\t\t\t\t  (li->extLength &\n\t\t\t\t\t\t   UDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t\t\t   UDF_EXTENT_LENGTH_MASK) &\n\t\t\t\t\t\t\t~(blocksize - 1);\n\t\t\t\tli->extLength = (li->extLength &\n\t\t\t\t\t\t UDF_EXTENT_FLAG_MASK) +\n\t\t\t\t\t\t(UDF_EXTENT_LENGTH_MASK + 1) -\n\t\t\t\t\t\tblocksize;\n\t\t\t\tlip1->extLocation.logicalBlockNum =\n\t\t\t\t\tli->extLocation.logicalBlockNum +\n\t\t\t\t\t((li->extLength &\n\t\t\t\t\t\tUDF_EXTENT_LENGTH_MASK) >>\n\t\t\t\t\t\tblocksize_bits);\n\t\t\t} else {\n\t\t\t\tli->extLength = lip1->extLength +\n\t\t\t\t\t(((li->extLength &\n\t\t\t\t\t\tUDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t\t blocksize - 1) & ~(blocksize - 1));\n\t\t\t\tif (*endnum > (i + 2))\n\t\t\t\t\tmemmove(&laarr[i + 1], &laarr[i + 2],\n\t\t\t\t\t\tsizeof(struct long_ad) *\n\t\t\t\t\t\t(*endnum - (i + 2)));\n\t\t\t\ti--;\n\t\t\t\t(*endnum)--;\n\t\t\t}\n\t\t} else if (((li->extLength >> 30) ==\n\t\t\t\t(EXT_NOT_RECORDED_ALLOCATED >> 30)) &&\n\t\t\t   ((lip1->extLength >> 30) ==\n\t\t\t\t(EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) {\n\t\t\tudf_free_blocks(inode->i_sb, inode, &li->extLocation, 0,\n\t\t\t\t\t((li->extLength &\n\t\t\t\t\t  UDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t\t blocksize - 1) >> blocksize_bits);\n\t\t\tli->extLocation.logicalBlockNum = 0;\n\t\t\tli->extLocation.partitionReferenceNum = 0;\n\n\t\t\tif (((li->extLength & UDF_EXTENT_LENGTH_MASK) +\n\t\t\t     (lip1->extLength & UDF_EXTENT_LENGTH_MASK) +\n\t\t\t     blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) {\n\t\t\t\tlip1->extLength = (lip1->extLength -\n\t\t\t\t\t\t   (li->extLength &\n\t\t\t\t\t\t   UDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t\t\t   UDF_EXTENT_LENGTH_MASK) &\n\t\t\t\t\t\t   ~(blocksize - 1);\n\t\t\t\tli->extLength = (li->extLength &\n\t\t\t\t\t\t UDF_EXTENT_FLAG_MASK) +\n\t\t\t\t\t\t(UDF_EXTENT_LENGTH_MASK + 1) -\n\t\t\t\t\t\tblocksize;\n\t\t\t} else {\n\t\t\t\tli->extLength = lip1->extLength +\n\t\t\t\t\t(((li->extLength &\n\t\t\t\t\t\tUDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t\t  blocksize - 1) & ~(blocksize - 1));\n\t\t\t\tif (*endnum > (i + 2))\n\t\t\t\t\tmemmove(&laarr[i + 1], &laarr[i + 2],\n\t\t\t\t\t\tsizeof(struct long_ad) *\n\t\t\t\t\t\t(*endnum - (i + 2)));\n\t\t\t\ti--;\n\t\t\t\t(*endnum)--;\n\t\t\t}\n\t\t} else if ((li->extLength >> 30) ==\n\t\t\t\t\t(EXT_NOT_RECORDED_ALLOCATED >> 30)) {\n\t\t\tudf_free_blocks(inode->i_sb, inode,\n\t\t\t\t\t&li->extLocation, 0,\n\t\t\t\t\t((li->extLength &\n\t\t\t\t\t\tUDF_EXTENT_LENGTH_MASK) +\n\t\t\t\t\t blocksize - 1) >> blocksize_bits);\n\t\t\tli->extLocation.logicalBlockNum = 0;\n\t\t\tli->extLocation.partitionReferenceNum = 0;\n\t\t\tli->extLength = (li->extLength &\n\t\t\t\t\t\tUDF_EXTENT_LENGTH_MASK) |\n\t\t\t\t\t\tEXT_NOT_RECORDED_NOT_ALLOCATED;\n\t\t}\n\t}\n}","target":0,"code_token_length":1069,"total_token_length":1305,"max_tokens_setting":2048}
+{"idx":466107,"func":"static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,\n\t\t\t\t   u16 selector, int seg)\n{\n\tstruct desc_struct seg_desc;\n\tu8 dpl, rpl, cpl;\n\tunsigned err_vec = GP_VECTOR;\n\tu32 err_code = 0;\n\tbool null_selector = !(selector & ~0x3); \/* 0000-0003 are null *\/\n\tint ret;\n\n\tmemset(&seg_desc, 0, sizeof seg_desc);\n\n\tif ((seg <= VCPU_SREG_GS && ctxt->mode == X86EMUL_MODE_VM86)\n\t    || ctxt->mode == X86EMUL_MODE_REAL) {\n\t\t\/* set real mode segment descriptor *\/\n\t\tset_desc_base(&seg_desc, selector << 4);\n\t\tset_desc_limit(&seg_desc, 0xffff);\n\t\tseg_desc.type = 3;\n\t\tseg_desc.p = 1;\n\t\tseg_desc.s = 1;\n\t\tgoto load;\n\t}\n\n\t\/* NULL selector is not valid for TR, CS and SS *\/\n\tif ((seg == VCPU_SREG_CS || seg == VCPU_SREG_SS || seg == VCPU_SREG_TR)\n\t    && null_selector)\n\t\tgoto exception;\n\n\t\/* TR should be in GDT only *\/\n\tif (seg == VCPU_SREG_TR && (selector & (1 << 2)))\n\t\tgoto exception;\n\n\tif (null_selector) \/* for NULL selector skip all following checks *\/\n\t\tgoto load;\n\n\tret = read_segment_descriptor(ctxt, selector, &seg_desc);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\n\terr_code = selector & 0xfffc;\n\terr_vec = GP_VECTOR;\n\n\t\/* can't load system descriptor into segment selecor *\/\n\tif (seg <= VCPU_SREG_GS && !seg_desc.s)\n\t\tgoto exception;\n\n\tif (!seg_desc.p) {\n\t\terr_vec = (seg == VCPU_SREG_SS) ? SS_VECTOR : NP_VECTOR;\n\t\tgoto exception;\n\t}\n\n\trpl = selector & 3;\n\tdpl = seg_desc.dpl;\n\tcpl = ctxt->ops->cpl(ctxt);\n\n\tswitch (seg) {\n\tcase VCPU_SREG_SS:\n\t\t\/*\n\t\t * segment is not a writable data segment or segment\n\t\t * selector's RPL != CPL or segment selector's RPL != CPL\n\t\t *\/\n\t\tif (rpl != cpl || (seg_desc.type & 0xa) != 0x2 || dpl != cpl)\n\t\t\tgoto exception;\n\t\tbreak;\n\tcase VCPU_SREG_CS:\n\t\tif (!(seg_desc.type & 8))\n\t\t\tgoto exception;\n\n\t\tif (seg_desc.type & 4) {\n\t\t\t\/* conforming *\/\n\t\t\tif (dpl > cpl)\n\t\t\t\tgoto exception;\n\t\t} else {\n\t\t\t\/* nonconforming *\/\n\t\t\tif (rpl > cpl || dpl != cpl)\n\t\t\t\tgoto exception;\n\t\t}\n\t\t\/* CS(RPL) <- CPL *\/\n\t\tselector = (selector & 0xfffc) | cpl;\n\t\tbreak;\n\tcase VCPU_SREG_TR:\n\t\tif (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9))\n\t\t\tgoto exception;\n\t\tbreak;\n\tcase VCPU_SREG_LDTR:\n\t\tif (seg_desc.s || seg_desc.type != 2)\n\t\t\tgoto exception;\n\t\tbreak;\n\tdefault: \/*  DS, ES, FS, or GS *\/\n\t\t\/*\n\t\t * segment is not a data or readable code segment or\n\t\t * ((segment is a data or nonconforming code segment)\n\t\t * and (both RPL and CPL > DPL))\n\t\t *\/\n\t\tif ((seg_desc.type & 0xa) == 0x8 ||\n\t\t    (((seg_desc.type & 0xc) != 0xc) &&\n\t\t     (rpl > dpl && cpl > dpl)))\n\t\t\tgoto exception;\n\t\tbreak;\n\t}\n\n\tif (seg_desc.s) {\n\t\t\/* mark segment as accessed *\/\n\t\tseg_desc.type |= 1;\n\t\tret = write_segment_descriptor(ctxt, selector, &seg_desc);\n\t\tif (ret != X86EMUL_CONTINUE)\n\t\t\treturn ret;\n\t}\nload:\n\tctxt->ops->set_segment(ctxt, selector, &seg_desc, 0, seg);\n\treturn X86EMUL_CONTINUE;\nexception:\n\temulate_exception(ctxt, err_vec, err_code, true);\n\treturn X86EMUL_PROPAGATE_FAULT;\n}","target":0,"code_token_length":936,"total_token_length":1172,"max_tokens_setting":2048}
+{"idx":383320,"func":"gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)\n{\n  int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;\n  int dashStep = 0;\n  int on = 1;\n  int wid;\n  int vert;\n  int thick = im->thick;\n\n  dx = abs (x2 - x1);\n  dy = abs (y2 - y1);\n  if (dy <= dx)\n    {\n      \/* More-or-less horizontal. use wid for vertical stroke *\/\n      wid = (int)(thick * sin (atan2 (dy, dx)));\n      vert = 1;\n\n      d = 2 * dy - dx;\n      incr1 = 2 * dy;\n      incr2 = 2 * (dy - dx);\n      if (x1 > x2)\n\t{\n\t  x = x2;\n\t  y = y2;\n\t  ydirflag = (-1);\n\t  xend = x1;\n\t}\n      else\n\t{\n\t  x = x1;\n\t  y = y1;\n\t  ydirflag = 1;\n\t  xend = x2;\n\t}\n      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);\n      if (((y2 - y1) * ydirflag) > 0)\n\t{\n\t  while (x < xend)\n\t    {\n\t      x++;\n\t      if (d < 0)\n\t\t{\n\t\t  d += incr1;\n\t\t}\n\t      else\n\t\t{\n\t\t  y++;\n\t\t  d += incr2;\n\t\t}\n\t      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);\n\t    }\n\t}\n      else\n\t{\n\t  while (x < xend)\n\t    {\n\t      x++;\n\t      if (d < 0)\n\t\t{\n\t\t  d += incr1;\n\t\t}\n\t      else\n\t\t{\n\t\t  y--;\n\t\t  d += incr2;\n\t\t}\n\t      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);\n\t    }\n\t}\n    }\n  else\n    {\n      \/* More-or-less vertical. use wid for horizontal stroke *\/\n      wid = (int)(thick * sin (atan2 (dy, dx)));\n      vert = 0;\n\n      d = 2 * dx - dy;\n      incr1 = 2 * dx;\n      incr2 = 2 * (dx - dy);\n      if (y1 > y2)\n\t{\n\t  y = y2;\n\t  x = x2;\n\t  yend = y1;\n\t  xdirflag = (-1);\n\t}\n      else\n\t{\n\t  y = y1;\n\t  x = x1;\n\t  yend = y2;\n\t  xdirflag = 1;\n\t}\n      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);\n      if (((x2 - x1) * xdirflag) > 0)\n\t{\n\t  while (y < yend)\n\t    {\n\t      y++;\n\t      if (d < 0)\n\t\t{\n\t\t  d += incr1;\n\t\t}\n\t      else\n\t\t{\n\t\t  x++;\n\t\t  d += incr2;\n\t\t}\n\t      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);\n\t    }\n\t}\n      else\n\t{\n\t  while (y < yend)\n\t    {\n\t      y++;\n\t      if (d < 0)\n\t\t{\n\t\t  d += incr1;\n\t\t}\n\t      else\n\t\t{\n\t\t  x--;\n\t\t  d += incr2;\n\t\t}\n\t      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":828,"total_token_length":1064,"max_tokens_setting":2048}
+{"idx":417477,"func":"virNodeDeviceCapPCIDefFormat(virBufferPtr buf,\n                             const virNodeDevCapData *data)\n{\n    size_t i;\n\n    if (data->pci_dev.klass >= 0)\n        virBufferAsprintf(buf, \"<class>0x%.6x<\/class>\\n\", data->pci_dev.klass);\n    virBufferAsprintf(buf, \"<domain>%d<\/domain>\\n\",\n                      data->pci_dev.domain);\n    virBufferAsprintf(buf, \"<bus>%d<\/bus>\\n\", data->pci_dev.bus);\n    virBufferAsprintf(buf, \"<slot>%d<\/slot>\\n\",\n                      data->pci_dev.slot);\n    virBufferAsprintf(buf, \"<function>%d<\/function>\\n\",\n                      data->pci_dev.function);\n    virBufferAsprintf(buf, \"<product id='0x%04x'\",\n                      data->pci_dev.product);\n    if (data->pci_dev.product_name)\n        virBufferEscapeString(buf, \">%s<\/product>\\n\",\n                              data->pci_dev.product_name);\n    else\n        virBufferAddLit(buf, \"\/>\\n\");\n    virBufferAsprintf(buf, \"<vendor id='0x%04x'\",\n                      data->pci_dev.vendor);\n    if (data->pci_dev.vendor_name)\n        virBufferEscapeString(buf, \">%s<\/vendor>\\n\",\n                              data->pci_dev.vendor_name);\n    else\n        virBufferAddLit(buf, \"\/>\\n\");\n    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) {\n        virBufferAddLit(buf, \"<capability type='phys_function'>\\n\");\n        virBufferAdjustIndent(buf, 2);\n        virBufferAsprintf(buf,\n                          \"<address domain='0x%04x' bus='0x%02x' \"\n                          \"slot='0x%02x' function='0x%d'\/>\\n\",\n                          data->pci_dev.physical_function->domain,\n                          data->pci_dev.physical_function->bus,\n                          data->pci_dev.physical_function->slot,\n                          data->pci_dev.physical_function->function);\n        virBufferAdjustIndent(buf, -2);\n        virBufferAddLit(buf, \"<\/capability>\\n\");\n    }\n    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) {\n        virBufferAddLit(buf, \"<capability type='virt_functions'\");\n        if (data->pci_dev.max_virtual_functions)\n            virBufferAsprintf(buf, \" maxCount='%u'\",\n                              data->pci_dev.max_virtual_functions);\n        if (data->pci_dev.num_virtual_functions == 0) {\n            virBufferAddLit(buf, \"\/>\\n\");\n        } else {\n            virBufferAddLit(buf, \">\\n\");\n            virBufferAdjustIndent(buf, 2);\n            for (i = 0; i < data->pci_dev.num_virtual_functions; i++) {\n                virBufferAsprintf(buf,\n                                  \"<address domain='0x%04x' bus='0x%02x' \"\n                                  \"slot='0x%02x' function='0x%d'\/>\\n\",\n                                  data->pci_dev.virtual_functions[i]->domain,\n                                  data->pci_dev.virtual_functions[i]->bus,\n                                  data->pci_dev.virtual_functions[i]->slot,\n                                  data->pci_dev.virtual_functions[i]->function);\n            }\n            virBufferAdjustIndent(buf, -2);\n            virBufferAddLit(buf, \"<\/capability>\\n\");\n        }\n    }\n    if (data->pci_dev.hdrType) {\n        virBufferAsprintf(buf, \"<capability type='%s'\/>\\n\",\n                          virPCIHeaderTypeToString(data->pci_dev.hdrType));\n    }\n    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {\n        virNodeDeviceCapMdevTypesFormat(buf,\n                                        data->pci_dev.mdev_types,\n                                        data->pci_dev.nmdev_types);\n    }\n    if (data->pci_dev.nIommuGroupDevices) {\n        virBufferAsprintf(buf, \"<iommuGroup number='%d'>\\n\",\n                          data->pci_dev.iommuGroupNumber);\n        virBufferAdjustIndent(buf, 2);\n        for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) {\n            virBufferAsprintf(buf,\n                              \"<address domain='0x%04x' bus='0x%02x' \"\n                              \"slot='0x%02x' function='0x%d'\/>\\n\",\n                              data->pci_dev.iommuGroupDevices[i]->domain,\n                              data->pci_dev.iommuGroupDevices[i]->bus,\n                              data->pci_dev.iommuGroupDevices[i]->slot,\n                              data->pci_dev.iommuGroupDevices[i]->function);\n        }\n        virBufferAdjustIndent(buf, -2);\n        virBufferAddLit(buf, \"<\/iommuGroup>\\n\");\n    }\n    if (data->pci_dev.numa_node >= 0)\n        virBufferAsprintf(buf, \"<numa node='%d'\/>\\n\",\n                          data->pci_dev.numa_node);\n\n    if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE)\n        virPCIEDeviceInfoFormat(buf, data->pci_dev.pci_express);\n}","target":0,"code_token_length":1109,"total_token_length":1345,"max_tokens_setting":2048}
+{"idx":333550,"func":"gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)\n{\n\tfloat _angle = ((float) (-degrees \/ 180.0f) * (float)M_PI);\n\tconst int angle_rounded = (int)floor(degrees * 100);\n\tconst int src_w  = gdImageSX(src);\n\tconst int src_h = gdImageSY(src);\n\tconst unsigned int new_width = (unsigned int)(abs((int)(src_w * cos(_angle))) + abs((int)(src_h * sin(_angle))) + 0.5f);\n\tconst unsigned int new_height = (unsigned int)(abs((int)(src_w * sin(_angle))) + abs((int)(src_h * cos(_angle))) + 0.5f);\n\tconst gdFixed f_0_5 = gd_ftofx(0.5f);\n\tconst gdFixed f_H = gd_itofx(src_h\/2);\n\tconst gdFixed f_W = gd_itofx(src_w\/2);\n\tconst gdFixed f_cos = gd_ftofx(cos(-_angle));\n\tconst gdFixed f_sin = gd_ftofx(sin(-_angle));\n\n\tunsigned int dst_offset_x;\n\tunsigned int dst_offset_y = 0;\n\tunsigned int i;\n\tgdImagePtr dst;\n\n\tconst gdFixed f_slop_y = f_sin;\n\tconst gdFixed f_slop_x = f_cos;\n\tconst gdFixed f_slop = f_slop_x > 0 && f_slop_x > 0 ?\n\t\t\t\t\t\t\tf_slop_x > f_slop_y ? gd_divfx(f_slop_y, f_slop_x) : gd_divfx(f_slop_x, f_slop_y)\n\t\t\t\t\t\t: 0;\n\n\n\tif (bgColor < 0) {\n\t\treturn NULL;\n\t}\n\n\tdst = gdImageCreateTrueColor(new_width, new_height);\n\tif (!dst) {\n\t\treturn NULL;\n\t}\n\tdst->saveAlphaFlag = 1;\n\n\tfor (i = 0; i < new_height; i++) {\n\t\tunsigned int j;\n\t\tdst_offset_x = 0;\n\t\tfor (j = 0; j < new_width; j++) {\n\t\t\tgdFixed f_i = gd_itofx((int)i - (int)new_height\/ 2);\n\t\t\tgdFixed f_j = gd_itofx((int)j - (int)new_width \/ 2);\n\t\t\tgdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;\n\t\t\tgdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;\n\t\t\tlong m = gd_fxtoi(f_m);\n\t\t\tlong n = gd_fxtoi(f_n);\n\n\t\t\tif ((n <= 0) || (m <= 0) || (m >= src_h) || (n >= src_w)) {\n\t\t\t\tdst->tpixels[dst_offset_y][dst_offset_x++] = bgColor;\n\t\t\t} else if ((n <= 1) || (m <= 1) || (m >= src_h - 1) || (n >= src_w - 1)) {\n\t\t\t\tgdFixed f_127 = gd_itofx(127);\n\t\t\t\tregister int c = getPixelInterpolated(src, n, m, bgColor);\n\t\t\t\tc = c | (( gdTrueColorGetAlpha(c) + ((int)(127* gd_fxtof(f_slop)))) << 24);\n\n\t\t\t\tdst->tpixels[dst_offset_y][dst_offset_x++] = _color_blend(bgColor, c);\n\t\t\t} else {\n\t\t\t\tdst->tpixels[dst_offset_y][dst_offset_x++] = getPixelInterpolated(src, n, m, bgColor);\n\t\t\t}\n\t\t}\n\t\tdst_offset_y++;\n\t}\n\treturn dst;\n}","target":0,"code_token_length":816,"total_token_length":1052,"max_tokens_setting":2048}
+{"idx":329877,"func":"span_renderer_init (cairo_abstract_span_renderer_t\t*_r,\n\t\t    const cairo_composite_rectangles_t *composite,\n\t\t    cairo_antialias_t\t\t\t antialias,\n\t\t    cairo_bool_t\t\t\t needs_clip)\n{\n    cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *)_r;\n    cairo_image_surface_t *dst = (cairo_image_surface_t *)composite->surface;\n    const cairo_pattern_t *source = &composite->source_pattern.base;\n    cairo_operator_t op = composite->op;\n    cairo_int_status_t status;\n\n    TRACE ((stderr, \"%s: antialias=%d, needs_clip=%d\\n\", __FUNCTION__,\n\t    antialias, needs_clip));\n\n    if (needs_clip)\n\treturn CAIRO_INT_STATUS_UNSUPPORTED;\n\n    r->composite = composite;\n    r->mask = NULL;\n    r->src = NULL;\n    r->base.finish = NULL;\n\n    status = mono_renderer_init (r, composite, antialias, needs_clip);\n    if (status != CAIRO_INT_STATUS_UNSUPPORTED)\n\treturn status;\n\n    status = inplace_renderer_init (r, composite, antialias, needs_clip);\n    if (status != CAIRO_INT_STATUS_UNSUPPORTED)\n\treturn status;\n\n    r->bpp = 0;\n\n    if (op == CAIRO_OPERATOR_CLEAR) {\n#if PIXMAN_HAS_OP_LERP\n\top = PIXMAN_OP_LERP_CLEAR;\n#else\n\tsource = &_cairo_pattern_white.base;\n\top = PIXMAN_OP_OUT_REVERSE;\n#endif\n    } else if (dst->base.is_clear &&\n\t       (op == CAIRO_OPERATOR_SOURCE ||\n\t\top == CAIRO_OPERATOR_OVER ||\n\t\top == CAIRO_OPERATOR_ADD)) {\n\top = PIXMAN_OP_SRC;\n    } else if (op == CAIRO_OPERATOR_SOURCE) {\n\tif (_cairo_pattern_is_opaque (&composite->source_pattern.base,\n\t\t\t\t      &composite->source_sample_area))\n\t{\n\t    op = PIXMAN_OP_OVER;\n\t}\n\telse\n\t{\n#if PIXMAN_HAS_OP_LERP\n\t    op = PIXMAN_OP_LERP_SRC;\n#else\n\t    return CAIRO_INT_STATUS_UNSUPPORTED;\n#endif\n\t}\n    } else {\n\top = _pixman_operator (op);\n    }\n    r->op = op;\n\n    r->src = _pixman_image_for_pattern (dst, source, FALSE,\n\t\t\t\t\t&composite->unbounded,\n\t\t\t\t\t&composite->source_sample_area,\n\t\t\t\t\t&r->u.mask.src_x, &r->u.mask.src_y);\n    if (unlikely (r->src == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n    r->opacity = 1.0;\n    if (composite->mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID) {\n\tr->opacity = composite->mask_pattern.solid.color.alpha;\n    } else {\n\tpixman_image_t *mask;\n\tint mask_x, mask_y;\n\n\tmask = _pixman_image_for_pattern (dst,\n\t\t\t\t\t  &composite->mask_pattern.base,\n\t\t\t\t\t  TRUE,\n\t\t\t\t\t  &composite->unbounded,\n\t\t\t\t\t  &composite->mask_sample_area,\n\t\t\t\t\t  &mask_x, &mask_y);\n\tif (unlikely (mask == NULL))\n\t    return _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n\t\/* XXX Component-alpha? *\/\n\tif ((dst->base.content & CAIRO_CONTENT_COLOR) == 0 &&\n\t    _cairo_pattern_is_opaque (source, &composite->source_sample_area))\n\t{\n\t    pixman_image_unref (r->src);\n\t    r->src = mask;\n\t    r->u.mask.src_x = mask_x;\n\t    r->u.mask.src_y = mask_y;\n\t    mask = NULL;\n\t}\n\n\tif (mask) {\n\t    pixman_image_unref (mask);\n\t    return CAIRO_INT_STATUS_UNSUPPORTED;\n\t}\n    }\n\n    r->u.mask.extents = composite->unbounded;\n    r->u.mask.stride = (r->u.mask.extents.width + 3) & ~3;\n    if (r->u.mask.extents.height * r->u.mask.stride > SZ_BUF) {\n\tr->mask = pixman_image_create_bits (PIXMAN_a8,\n\t\t\t\t\t    r->u.mask.extents.width,\n\t\t\t\t\t    r->u.mask.extents.height,\n\t\t\t\t\t    NULL, 0);\n\n\tr->base.render_rows = _cairo_image_spans;\n\tr->base.finish = NULL;\n    } else {\n\tr->mask = pixman_image_create_bits (PIXMAN_a8,\n\t\t\t\t\t    r->u.mask.extents.width,\n\t\t\t\t\t    r->u.mask.extents.height,\n\t\t\t\t\t    (uint32_t *)r->_buf, r->u.mask.stride);\n\n\tr->base.render_rows = _cairo_image_spans_and_zero;\n\tr->base.finish = _cairo_image_finish_spans_and_zero;\n    }\n    if (unlikely (r->mask == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n    r->u.mask.data = (uint8_t *) pixman_image_get_data (r->mask);\n    r->u.mask.stride = pixman_image_get_stride (r->mask);\n\n    r->u.mask.extents.height += r->u.mask.extents.y;\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":1048,"total_token_length":1284,"max_tokens_setting":2048}
+{"idx":214909,"func":"static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)\n{\n\tstruct mlx5_fpga_device *fdev = conn->fdev;\n\tstruct mlx5_core_dev *mdev = fdev->mdev;\n\tu32 temp_cqc[MLX5_ST_SZ_DW(cqc)] = {0};\n\tu32 out[MLX5_ST_SZ_DW(create_cq_out)];\n\tstruct mlx5_wq_param wqp;\n\tstruct mlx5_cqe64 *cqe;\n\tint inlen, err, eqn;\n\tunsigned int irqn;\n\tvoid *cqc, *in;\n\t__be64 *pas;\n\tu32 i;\n\n\tcq_size = roundup_pow_of_two(cq_size);\n\tMLX5_SET(cqc, temp_cqc, log_cq_size, ilog2(cq_size));\n\n\twqp.buf_numa_node = mdev->priv.numa_node;\n\twqp.db_numa_node  = mdev->priv.numa_node;\n\n\terr = mlx5_cqwq_create(mdev, &wqp, temp_cqc, &conn->cq.wq,\n\t\t\t       &conn->cq.wq_ctrl);\n\tif (err)\n\t\treturn err;\n\n\tfor (i = 0; i < mlx5_cqwq_get_size(&conn->cq.wq); i++) {\n\t\tcqe = mlx5_cqwq_get_wqe(&conn->cq.wq, i);\n\t\tcqe->op_own = MLX5_CQE_INVALID << 4 | MLX5_CQE_OWNER_MASK;\n\t}\n\n\tinlen = MLX5_ST_SZ_BYTES(create_cq_in) +\n\t\tsizeof(u64) * conn->cq.wq_ctrl.buf.npages;\n\tin = kvzalloc(inlen, GFP_KERNEL);\n\tif (!in) {\n\t\terr = -ENOMEM;\n\t\tgoto err_cqwq;\n\t}\n\n\terr = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn);\n\tif (err)\n\t\tgoto err_cqwq;\n\n\tcqc = MLX5_ADDR_OF(create_cq_in, in, cq_context);\n\tMLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size));\n\tMLX5_SET(cqc, cqc, c_eqn, eqn);\n\tMLX5_SET(cqc, cqc, uar_page, fdev->conn_res.uar->index);\n\tMLX5_SET(cqc, cqc, log_page_size, conn->cq.wq_ctrl.buf.page_shift -\n\t\t\t   MLX5_ADAPTER_PAGE_SHIFT);\n\tMLX5_SET64(cqc, cqc, dbr_addr, conn->cq.wq_ctrl.db.dma);\n\n\tpas = (__be64 *)MLX5_ADDR_OF(create_cq_in, in, pas);\n\tmlx5_fill_page_frag_array(&conn->cq.wq_ctrl.buf, pas);\n\n\terr = mlx5_core_create_cq(mdev, &conn->cq.mcq, in, inlen, out, sizeof(out));\n\tkvfree(in);\n\n\tif (err)\n\t\tgoto err_cqwq;\n\n\tconn->cq.mcq.cqe_sz     = 64;\n\tconn->cq.mcq.set_ci_db  = conn->cq.wq_ctrl.db.db;\n\tconn->cq.mcq.arm_db     = conn->cq.wq_ctrl.db.db + 1;\n\t*conn->cq.mcq.set_ci_db = 0;\n\t*conn->cq.mcq.arm_db    = 0;\n\tconn->cq.mcq.vector     = 0;\n\tconn->cq.mcq.comp       = mlx5_fpga_conn_cq_complete;\n\tconn->cq.mcq.event      = mlx5_fpga_conn_cq_event;\n\tconn->cq.mcq.irqn       = irqn;\n\tconn->cq.mcq.uar        = fdev->conn_res.uar;\n\ttasklet_init(&conn->cq.tasklet, mlx5_fpga_conn_cq_tasklet,\n\t\t     (unsigned long)conn);\n\n\tmlx5_fpga_dbg(fdev, \"Created CQ #0x%x\\n\", conn->cq.mcq.cqn);\n\n\tgoto out;\n\nerr_cqwq:\n\tmlx5_wq_destroy(&conn->cq.wq_ctrl);\nout:\n\treturn err;\n}","target":1,"code_token_length":896,"total_token_length":1132,"max_tokens_setting":2048}
+{"idx":210484,"func":"static int io_read(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tstruct iov_iter __iter, *iter = &__iter;\n\tstruct io_async_rw *rw = req->async_data;\n\tssize_t io_size, ret, ret2;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tif (rw) {\n\t\titer = &rw->iter;\n\t\tiovec = NULL;\n\t} else {\n\t\tret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\tio_size = iov_iter_count(iter);\n\treq->result = io_size;\n\n\t\/* Ensure we clear previously set non-block flag *\/\n\tif (!force_nonblock)\n\t\tkiocb->ki_flags &= ~IOCB_NOWAIT;\n\telse\n\t\tkiocb->ki_flags |= IOCB_NOWAIT;\n\n\t\/* If the file doesn't support async, just async punt *\/\n\tif (force_nonblock && !io_file_supports_async(req, READ)) {\n\t\tret = io_setup_async_rw(req, iovec, inline_vecs, iter, true);\n\t\treturn ret ?: -EAGAIN;\n\t}\n\n\tret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size);\n\tif (unlikely(ret)) {\n\t\tkfree(iovec);\n\t\treturn ret;\n\t}\n\n\tret = io_iter_do_read(req, iter);\n\n\tif (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\t\/* IOPOLL retry should happen for io-wq threads *\/\n\t\tif (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\t\tgoto done;\n\t\t\/* no retry on NONBLOCK nor RWF_NOWAIT *\/\n\t\tif (req->flags & REQ_F_NOWAIT)\n\t\t\tgoto done;\n\t\t\/* some cases will consume bytes even on error returns *\/\n\t\tiov_iter_revert(iter, io_size - iov_iter_count(iter));\n\t\tret = 0;\n\t} else if (ret == -EIOCBQUEUED) {\n\t\tgoto out_free;\n\t} else if (ret <= 0 || ret == io_size || !force_nonblock ||\n\t\t   (req->flags & REQ_F_NOWAIT) || !(req->flags & REQ_F_ISREG)) {\n\t\t\/* read all, failed, already did sync or don't want to retry *\/\n\t\tgoto done;\n\t}\n\n\tret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true);\n\tif (ret2)\n\t\treturn ret2;\n\n\tiovec = NULL;\n\trw = req->async_data;\n\t\/* now use our persistent iterator, if we aren't already *\/\n\titer = &rw->iter;\n\n\tdo {\n\t\tio_size -= ret;\n\t\trw->bytes_done += ret;\n\t\t\/* if we can retry, do so with the callbacks armed *\/\n\t\tif (!io_rw_should_retry(req)) {\n\t\t\tkiocb->ki_flags &= ~IOCB_WAITQ;\n\t\t\treturn -EAGAIN;\n\t\t}\n\n\t\t\/*\n\t\t * Now retry read with the IOCB_WAITQ parts set in the iocb. If\n\t\t * we get -EIOCBQUEUED, then we'll get a notification when the\n\t\t * desired page gets unlocked. We can also get a partial read\n\t\t * here, and if we do, then just retry at the new offset.\n\t\t *\/\n\t\tret = io_iter_do_read(req, iter);\n\t\tif (ret == -EIOCBQUEUED)\n\t\t\treturn 0;\n\t\t\/* we got some bytes, but not all. retry. *\/\n\t\tkiocb->ki_flags &= ~IOCB_WAITQ;\n\t} while (ret > 0 && ret < io_size);\ndone:\n\tkiocb_done(kiocb, ret, issue_flags);\nout_free:\n\t\/* it's faster to check here then delegate to kfree *\/\n\tif (iovec)\n\t\tkfree(iovec);\n\treturn 0;\n}","target":1,"code_token_length":899,"total_token_length":1135,"max_tokens_setting":2048}
+{"idx":216965,"func":"multi_update::initialize_tables(JOIN *join)\n{\n  TABLE_LIST *table_ref;\n  DBUG_ENTER(\"initialize_tables\");\n\n  if (unlikely((thd->variables.option_bits & OPTION_SAFE_UPDATES) &&\n               error_if_full_join(join)))\n    DBUG_RETURN(1);\n  main_table=join->join_tab->table;\n  table_to_update= 0;\n\n  \/* Any update has at least one pair (field, value) *\/\n  DBUG_ASSERT(fields->elements);\n  \/*\n   Only one table may be modified by UPDATE of an updatable view.\n   For an updatable view first_table_for_update indicates this\n   table.\n   For a regular multi-update it refers to some updated table.\n  *\/ \n  TABLE *first_table_for_update= ((Item_field *) fields->head())->field->table;\n\n  \/* Create a temporary table for keys to all tables, except main table *\/\n  for (table_ref= update_tables; table_ref; table_ref= table_ref->next_local)\n  {\n    TABLE *table=table_ref->table;\n    uint cnt= table_ref->shared;\n    List<Item> temp_fields;\n    ORDER     group;\n    TMP_TABLE_PARAM *tmp_param;\n\n    if (ignore)\n      table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);\n    if (table == main_table)\t\t\t\/\/ First table in join\n    {\n      if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables))\n      {\n\ttable_to_update= table;\t\t\t\/\/ Update table on the fly\n        has_vers_fields= table->vers_check_update(*fields);\n\tcontinue;\n      }\n    }\n    table->prepare_for_position();\n    join->map2table[table->tablenr]->keep_current_rowid= true;\n\n    \/*\n      enable uncacheable flag if we update a view with check option\n      and check option has a subselect, otherwise, the check option\n      can be evaluated after the subselect was freed as independent\n      (See full_local in JOIN::join_free()).\n    *\/\n    if (table_ref->check_option && !join->select_lex->uncacheable)\n    {\n      SELECT_LEX_UNIT *tmp_unit;\n      SELECT_LEX *sl;\n      for (tmp_unit= join->select_lex->first_inner_unit();\n           tmp_unit;\n           tmp_unit= tmp_unit->next_unit())\n      {\n        for (sl= tmp_unit->first_select(); sl; sl= sl->next_select())\n        {\n          if (sl->master_unit()->item)\n          {\n            join->select_lex->uncacheable|= UNCACHEABLE_CHECKOPTION;\n            goto loop_end;\n          }\n        }\n      }\n    }\nloop_end:\n\n    if (table == first_table_for_update && table_ref->check_option)\n    {\n      table_map unupdated_tables= table_ref->check_option->used_tables() &\n                                  ~first_table_for_update->map;\n      List_iterator<TABLE_LIST> ti(*leaves);\n      TABLE_LIST *tbl_ref;\n      while ((tbl_ref= ti++) && unupdated_tables)\n      {\n        if (unupdated_tables & tbl_ref->table->map)\n          unupdated_tables&= ~tbl_ref->table->map;\n        else\n          continue;\n        if (unupdated_check_opt_tables.push_back(tbl_ref->table))\n          DBUG_RETURN(1);\n      }\n    }\n\n    tmp_param= tmp_table_param+cnt;\n\n    \/*\n      Create a temporary table to store all fields that are changed for this\n      table. The first field in the temporary table is a pointer to the\n      original row so that we can find and update it. For the updatable\n      VIEW a few following fields are rowids of tables used in the CHECK\n      OPTION condition.\n    *\/\n\n    List_iterator_fast<TABLE> tbl_it(unupdated_check_opt_tables);\n    TABLE *tbl= table;\n    do\n    {\n      LEX_CSTRING field_name;\n      field_name.str= tbl->alias.c_ptr();\n      field_name.length= strlen(field_name.str);\n      \/*\n        Signal each table (including tables referenced by WITH CHECK OPTION\n        clause) for which we will store row position in the temporary table\n        that we need a position to be read first.\n      *\/\n      tbl->prepare_for_position();\n      join->map2table[tbl->tablenr]->keep_current_rowid= true;\n\n      Item_temptable_rowid *item=\n        new (thd->mem_root) Item_temptable_rowid(tbl);\n      if (!item)\n         DBUG_RETURN(1);\n      item->fix_fields(thd, 0);\n      if (temp_fields.push_back(item, thd->mem_root))\n        DBUG_RETURN(1);\n    } while ((tbl= tbl_it++));\n\n    temp_fields.append(fields_for_table[cnt]);\n\n    \/* Make an unique key over the first field to avoid duplicated updates *\/\n    bzero((char*) &group, sizeof(group));\n    group.direction= ORDER::ORDER_ASC;\n    group.item= (Item**) temp_fields.head_ref();\n\n    tmp_param->quick_group= 1;\n    tmp_param->field_count= temp_fields.elements;\n    tmp_param->func_count=  temp_fields.elements - 1;\n    calc_group_buffer(tmp_param, &group);\n    \/* small table, ignore SQL_BIG_TABLES *\/\n    my_bool save_big_tables= thd->variables.big_tables; \n    thd->variables.big_tables= FALSE;\n    tmp_tables[cnt]=create_tmp_table(thd, tmp_param, temp_fields,\n                                     (ORDER*) &group, 0, 0,\n                                     TMP_TABLE_ALL_COLUMNS, HA_POS_ERROR, &empty_clex_str);\n    thd->variables.big_tables= save_big_tables;\n    if (!tmp_tables[cnt])\n      DBUG_RETURN(1);\n    tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE);\n  }\n  join->tmp_table_keep_current_rowid= TRUE;\n  DBUG_RETURN(0);\n}","target":1,"code_token_length":1238,"total_token_length":1474,"max_tokens_setting":2048}
+{"idx":389760,"func":"cmdopts_t *cmdopts_parse(int argc, char **argv)\n{\n\tenum {\n\t\tCMDOPT_HELP = 0,\n\t\tCMDOPT_VERBOSE,\n\t\tCMDOPT_QUIET,\n\t\tCMDOPT_INFILE,\n\t\tCMDOPT_INFMT,\n\t\tCMDOPT_INOPT,\n\t\tCMDOPT_OUTFILE,\n\t\tCMDOPT_OUTFMT,\n\t\tCMDOPT_OUTOPT,\n\t\tCMDOPT_VERSION,\n\t\tCMDOPT_DEBUG,\n\t\tCMDOPT_CMPTNO,\n\t\tCMDOPT_SRGB,\n\t\tCMDOPT_MAXMEM,\n\t\tCMDOPT_LIST_ENABLED_CODECS,\n\t\tCMDOPT_LIST_ALL_CODECS,\n\t\tCMDOPT_ENABLE_FORMAT,\n\t\tCMDOPT_ENABLE_ALL_FORMATS,\n\t};\n\n\tstatic const jas_opt_t cmdoptions[] = {\n\t\t{CMDOPT_HELP, \"help\", 0},\n\t\t{CMDOPT_VERBOSE, \"verbose\", 0},\n\t\t{CMDOPT_QUIET, \"quiet\", 0},\n\t\t{CMDOPT_QUIET, \"q\", 0},\n\t\t{CMDOPT_INFILE, \"input\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INFILE, \"f\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INFMT, \"input-format\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INFMT, \"t\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INOPT, \"input-option\", JAS_OPT_HASARG},\n\t\t{CMDOPT_INOPT, \"o\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFILE, \"output\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFILE, \"F\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFMT, \"output-format\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTFMT, \"T\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTOPT, \"output-option\", JAS_OPT_HASARG},\n\t\t{CMDOPT_OUTOPT, \"O\", JAS_OPT_HASARG},\n\t\t{CMDOPT_VERSION, \"version\", 0},\n\t\t{CMDOPT_DEBUG, \"debug-level\", JAS_OPT_HASARG},\n\t\t{CMDOPT_CMPTNO, \"cmptno\", JAS_OPT_HASARG},\n\t\t{CMDOPT_SRGB, \"force-srgb\", 0},\n\t\t{CMDOPT_SRGB, \"S\", 0},\n\t\t{CMDOPT_MAXMEM, \"memory-limit\", JAS_OPT_HASARG},\n\t\t{CMDOPT_LIST_ENABLED_CODECS, \"list-enabled-formats\", 0},\n\t\t{CMDOPT_LIST_ALL_CODECS, \"list-all-formats\", 0},\n\t\t{CMDOPT_ENABLE_FORMAT, \"enable-format\", JAS_OPT_HASARG},\n\t\t{CMDOPT_ENABLE_ALL_FORMATS, \"enable-all-formats\", 0},\n\t\t{-1, 0, 0}\n\t};\n\n\tcmdopts_t *cmdopts;\n\tint c;\n\n\tif (!(cmdopts = malloc(sizeof(cmdopts_t)))) {\n\t\tfprintf(stderr, \"error: insufficient memory\\n\");\n\t\texit(EXIT_FAILURE);\n\t}\n\n\tcmdopts->infile = 0;\n\tcmdopts->infmt = -1;\n\tcmdopts->infmt_str = 0;\n\tcmdopts->inopts = 0;\n\tcmdopts->inoptsbuf[0] = '\\0';\n\tcmdopts->outfile = 0;\n\tcmdopts->outfmt = -1;\n\tcmdopts->outfmt_str = 0;\n\tcmdopts->outopts = 0;\n\tcmdopts->outoptsbuf[0] = '\\0';\n\tcmdopts->verbose = 0;\n\tcmdopts->version = 0;\n\tcmdopts->cmptno = -1;\n\tcmdopts->debug = 0;\n\tcmdopts->srgb = 0;\n\tcmdopts->list_codecs = 0;\n\tcmdopts->list_codecs_all = 0;\n\tcmdopts->help = 0;\n\tcmdopts->max_mem = get_default_max_mem_usage();\n\tcmdopts->enable_format = 0;\n\tcmdopts->enable_all_formats = 0;\n\n\twhile ((c = jas_getopt(argc, argv, cmdoptions)) != EOF) {\n\t\tswitch (c) {\n\t\tcase CMDOPT_HELP:\n\t\t\tcmdopts->help = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_VERBOSE:\n\t\t\tcmdopts->verbose = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_QUIET:\n\t\t\tcmdopts->verbose = -1;\n\t\t\tbreak;\n\t\tcase CMDOPT_VERSION:\n\t\t\tcmdopts->version = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_LIST_ENABLED_CODECS:\n\t\t\tcmdopts->list_codecs = 1;\n\t\t\tcmdopts->list_codecs_all = 0;\n\t\t\tbreak;\n\t\tcase CMDOPT_LIST_ALL_CODECS:\n\t\t\tcmdopts->list_codecs = 1;\n\t\t\tcmdopts->list_codecs_all = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_DEBUG:\n\t\t\tcmdopts->debug = atoi(jas_optarg);\n\t\t\tbreak;\n\t\tcase CMDOPT_INFILE:\n\t\t\tcmdopts->infile = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_INFMT:\n\t\t\tcmdopts->infmt_str= jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_INOPT:\n\t\t\taddopt(cmdopts->inoptsbuf, OPTSMAX, jas_optarg);\n\t\t\tcmdopts->inopts = cmdopts->inoptsbuf;\n\t\t\tbreak;\n\t\tcase CMDOPT_OUTFILE:\n\t\t\tcmdopts->outfile = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_OUTFMT:\n\t\t\tcmdopts->outfmt_str = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_OUTOPT:\n\t\t\taddopt(cmdopts->outoptsbuf, OPTSMAX, jas_optarg);\n\t\t\tcmdopts->outopts = cmdopts->outoptsbuf;\n\t\t\tbreak;\n\t\tcase CMDOPT_CMPTNO:\n\t\t\tcmdopts->cmptno = atoi(jas_optarg);\n\t\t\tbreak;\n\t\tcase CMDOPT_SRGB:\n\t\t\tcmdopts->srgb = 1;\n\t\t\tbreak;\n\t\tcase CMDOPT_MAXMEM:\n\t\t\tcmdopts->max_mem = strtoull(jas_optarg, 0, 10);\n\t\t\tbreak;\n\t\tcase CMDOPT_ENABLE_FORMAT:\n\t\t\tcmdopts->enable_format = jas_optarg;\n\t\t\tbreak;\n\t\tcase CMDOPT_ENABLE_ALL_FORMATS:\n\t\t\tcmdopts->enable_all_formats = 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tcmdopts_destroy(cmdopts);\n\t\t\tbadusage();\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twhile (jas_optind < argc) {\n\t\tfprintf(stderr,\n\t\t  \"warning: ignoring bogus command line argument %s\\n\",\n\t\t  argv[jas_optind]);\n\t\t++jas_optind;\n\t}\n\n\tif (cmdopts->version || cmdopts->list_codecs || cmdopts->help) {\n\t\tgoto done;\n\t}\n\n\tif (!cmdopts->outfmt_str && !cmdopts->outfile) {\n\t\tfprintf(stderr, \"error: cannot determine output format\\n\");\n\t\tcmdopts_destroy(cmdopts);\n\t\tbadusage();\n\t}\n\ndone:\n\treturn cmdopts;\n}","target":0,"code_token_length":1547,"total_token_length":1783,"max_tokens_setting":2048}
+{"idx":247161,"func":"void gf_fs_post_task_ex(GF_FilterSession *fsess, gf_fs_task_callback task_fun, GF_Filter *filter, GF_FilterPid *pid, const char *log_name, void *udta, Bool is_configure, Bool force_direct_call)\n{\n\tGF_FSTask *task;\n\tBool force_main_thread = GF_FALSE;\n\tBool notified = GF_FALSE;\n\n\tassert(fsess);\n\tassert(task_fun);\n\n\t\/\/only flatten calls if in main thread (we still have some broken filters using threading that could trigger tasks)\n\tif ((force_direct_call || fsess->direct_mode)\n\t\t&& (!filter || !filter->in_process)\n\t\t&& fsess->tasks_in_process\n\t\t&& (gf_th_id()==fsess->main_th.th_id)\n\t) {\n\t\tGF_FSTask atask;\n\t\tu64 task_time = gf_sys_clock_high_res();\n\t\tmemset(&atask, 0, sizeof(GF_FSTask));\n\t\tatask.filter = filter;\n\t\tatask.pid = pid;\n\t\tatask.run_task = task_fun;\n\t\tatask.log_name = log_name;\n\t\tatask.udta = udta;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_SCHEDULER, (\"Thread 0 task#%d %p executing Filter %s::%s (%d tasks pending)\\n\", fsess->main_th.nb_tasks, &atask, filter ? filter->name : \"none\", log_name, fsess->tasks_pending));\n\t\tif (filter)\n\t\t\tfilter->scheduled_for_next_task = GF_TRUE;\n\t\ttask_fun(&atask);\n\t\tfilter = atask.filter;\n\t\tif (filter) {\n\t\t\tfilter->time_process += gf_sys_clock_high_res() - task_time;\n\t\t\tfilter->scheduled_for_next_task = GF_FALSE;\n\t\t\tfilter->nb_tasks_done++;\n\t\t}\n\t\tif (!atask.requeue_request)\n\t\t\treturn;\n\t\t\/\/asked to requeue the task, post it\n\t}\n\n\t\/*this was a gf_filter_process_task request but direct call could not be done or requeue is requested.\n\tprocess_task_queued was incremented by caller without checking for existing process task\n\t\t- If the task was not treated, dec \/ inc will give the same state, undo process_task_queued increment\n\t\t- If the task was requeued, dec will undo the increment done when requeing the task in gf_filter_check_pending_tasks\n\n\tIn both cases, inc will redo the same logic as in gf_filter_post_process_task_internal, not creating task if gf_filter_process_task is\n\talready scheduled for the filter\n\n\tWe must use safe_int_dec\/safe_int_inc here for multi thread cases - cf issue #1778\n\t*\/\n\tif (force_direct_call) {\n\t\tassert(filter);\n\t\tsafe_int_dec(&filter->process_task_queued);\n\t\tif (safe_int_inc(&filter->process_task_queued) > 1) {\n\t\t\treturn;\n\t\t}\n\t}\n\ttask = gf_fq_pop(fsess->tasks_reservoir);\n\n\tif (!task) {\n\t\tGF_SAFEALLOC(task, GF_FSTask);\n\t\tif (!task) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_SCHEDULER, (\"No more memory to post new task\\n\"));\n\t\t\treturn;\n\t\t}\n\t}\n\ttask->filter = filter;\n\ttask->pid = pid;\n\ttask->run_task = task_fun;\n\ttask->log_name = log_name;\n\ttask->udta = udta;\n\n\tif (filter && is_configure) {\n\t\tif (filter->freg->flags & GF_FS_REG_CONFIGURE_MAIN_THREAD)\n\t\t\tforce_main_thread = GF_TRUE;\n\t}\n\n\tif (filter) {\n\t\tgf_mx_p(filter->tasks_mx);\n\n\t\t\/\/no tasks and not scheduled\n\t\tif (! filter->scheduled_for_next_task && !gf_fq_count(filter->tasks)) {\n\t\t\tnotified = task->notified = GF_TRUE;\n\n\t\t\tif (!force_main_thread)\n\t\t\t\tforce_main_thread = (filter->main_thread_forced || (filter->freg->flags & GF_FS_REG_MAIN_THREAD)) ? GF_TRUE : GF_FALSE;\n\t\t} else if (force_main_thread) {\n\t\t\tforce_main_thread = GF_FALSE;\n\t\t\tif (filter->process_th_id && (fsess->main_th.th_id != filter->process_th_id)) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_SCHEDULER, (\"Cannot post task to main thread, filter is already scheduled\\n\"));\n\t\t\t}\n\t\t}\n\t\tif (!force_main_thread)\n\t\t\ttask->blocking = (filter->freg->flags & GF_FS_REG_BLOCKING) ? GF_TRUE : GF_FALSE;\n\n\t\tgf_fq_add(filter->tasks, task);\n\t\tgf_mx_v(filter->tasks_mx);\n\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_SCHEDULER, (\"Thread %u Posted task %p Filter %s::%s (%d (%d) pending, %d process tasks) on %s task list\\n\", gf_th_id(), task, filter->name, task->log_name, fsess->tasks_pending, gf_fq_count(filter->tasks), filter->process_task_queued, task->notified ? (force_main_thread ? \"main\" : \"secondary\") : \"filter\"));\n\t} else {\n\t\ttask->notified = notified = GF_TRUE;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_SCHEDULER, (\"Thread %u Posted filter-less task %s (%d pending) on secondary task list\\n\", gf_th_id(), task->log_name, fsess->tasks_pending));\n\t}\n\n\t\/\/WARNING, do not use task->notified since the task may have been posted to the filter task list and may already have been swapped\n\t\/\/with a different value !\n\tif (notified) {\n#ifdef CHECK_TASK_LIST_INTEGRITY\n\t\tcheck_task_list(fsess->main_thread_tasks, task);\n\t\tcheck_task_list(fsess->tasks, task);\n\t\tcheck_task_list(fsess->tasks_reservoir, task);\n#endif\n\t\tassert(task->run_task);\n\t\tif (filter) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_SCHEDULER, (\"Thread %u posting filter task, scheduled_for_next_task %d\\n\", gf_th_id(), filter->scheduled_for_next_task));\n\t\t\tassert(!filter->scheduled_for_next_task);\n\t\t}\n\n\t\t\/\/notify\/count tasks posted on the main task or regular task lists\n\t\tsafe_int_inc(&fsess->tasks_pending);\n\t\tif (filter && force_main_thread) {\n\t\t\tgf_fq_add(fsess->main_thread_tasks, task);\n\t\t\tgf_fs_sema_io(fsess, GF_TRUE, GF_TRUE);\n\t\t} else {\n\t\t\tassert(task->run_task);\n\t\t\tgf_fq_add(fsess->tasks, task);\n\t\t\tgf_fs_sema_io(fsess, GF_TRUE, GF_FALSE);\n\t\t}\n\t}\n}","target":0,"code_token_length":1432,"total_token_length":1668,"max_tokens_setting":2048}
+{"idx":384813,"func":"do_browse(\n    int\t\tflags,\t\t\/\/ BROWSE_SAVE and BROWSE_DIR\n    char_u\t*title,\t\t\/\/ title for the window\n    char_u\t*dflt,\t\t\/\/ default file name (may include directory)\n    char_u\t*ext,\t\t\/\/ extension added\n    char_u\t*initdir,\t\/\/ initial directory, NULL for current dir or\n\t\t\t\t\/\/ when using path from \"dflt\"\n    char_u\t*filter,\t\/\/ file name filter\n    buf_T\t*buf)\t\t\/\/ buffer to read\/write for\n{\n    char_u\t\t*fname;\n    static char_u\t*last_dir = NULL;    \/\/ last used directory\n    char_u\t\t*tofree = NULL;\n    int\t\t\tsave_cmod_flags = cmdmod.cmod_flags;\n\n    \/\/ Must turn off browse to avoid that autocommands will get the\n    \/\/ flag too!\n    cmdmod.cmod_flags &= ~CMOD_BROWSE;\n\n    if (title == NULL || *title == NUL)\n    {\n\tif (flags & BROWSE_DIR)\n\t    title = (char_u *)_(\"Select Directory dialog\");\n\telse if (flags & BROWSE_SAVE)\n\t    title = (char_u *)_(\"Save File dialog\");\n\telse\n\t    title = (char_u *)_(\"Open File dialog\");\n    }\n\n    \/\/ When no directory specified, use default file name, default dir, buffer\n    \/\/ dir, last dir or current dir\n    if ((initdir == NULL || *initdir == NUL) && dflt != NULL && *dflt != NUL)\n    {\n\tif (mch_isdir(dflt))\t\t\/\/ default file name is a directory\n\t{\n\t    initdir = dflt;\n\t    dflt = NULL;\n\t}\n\telse if (gettail(dflt) != dflt)\t\/\/ default file name includes a path\n\t{\n\t    tofree = vim_strsave(dflt);\n\t    if (tofree != NULL)\n\t    {\n\t\tinitdir = tofree;\n\t\t*gettail(initdir) = NUL;\n\t\tdflt = gettail(dflt);\n\t    }\n\t}\n    }\n\n    if (initdir == NULL || *initdir == NUL)\n    {\n\t\/\/ When 'browsedir' is a directory, use it\n\tif (STRCMP(p_bsdir, \"last\") != 0\n\t\t&& STRCMP(p_bsdir, \"buffer\") != 0\n\t\t&& STRCMP(p_bsdir, \"current\") != 0\n\t\t&& mch_isdir(p_bsdir))\n\t    initdir = p_bsdir;\n\t\/\/ When saving or 'browsedir' is \"buffer\", use buffer fname\n\telse if (((flags & BROWSE_SAVE) || *p_bsdir == 'b')\n\t\t&& buf != NULL && buf->b_ffname != NULL)\n\t{\n\t    if (dflt == NULL || *dflt == NUL)\n\t\tdflt = gettail(curbuf->b_ffname);\n\t    tofree = vim_strsave(curbuf->b_ffname);\n\t    if (tofree != NULL)\n\t    {\n\t\tinitdir = tofree;\n\t\t*gettail(initdir) = NUL;\n\t    }\n\t}\n\t\/\/ When 'browsedir' is \"last\", use dir from last browse\n\telse if (*p_bsdir == 'l')\n\t    initdir = last_dir;\n\t\/\/ When 'browsedir is \"current\", use current directory.  This is the\n\t\/\/ default already, leave initdir empty.\n    }\n\n# ifdef FEAT_GUI\n    if (gui.in_use)\t\t\/\/ when this changes, also adjust f_has()!\n    {\n\tif (filter == NULL\n#  ifdef FEAT_EVAL\n\t\t&& (filter = get_var_value((char_u *)\"b:browsefilter\")) == NULL\n\t\t&& (filter = get_var_value((char_u *)\"g:browsefilter\")) == NULL\n#  endif\n\t)\n\t    filter = BROWSE_FILTER_DEFAULT;\n\tif (flags & BROWSE_DIR)\n\t{\n#  if defined(FEAT_GUI_GTK) || defined(MSWIN)\n\t    \/\/ For systems that have a directory dialog.\n\t    fname = gui_mch_browsedir(title, initdir);\n#  else\n\t    \/\/ Generic solution for selecting a directory: select a file and\n\t    \/\/ remove the file name.\n\t    fname = gui_mch_browse(0, title, dflt, ext, initdir, (char_u *)\"\");\n#  endif\n#  if !defined(FEAT_GUI_GTK)\n\t    \/\/ Win32 adds a dummy file name, others return an arbitrary file\n\t    \/\/ name.  GTK+ 2 returns only the directory,\n\t    if (fname != NULL && *fname != NUL && !mch_isdir(fname))\n\t    {\n\t\t\/\/ Remove the file name.\n\t\tchar_u\t    *tail = gettail_sep(fname);\n\n\t\tif (tail == fname)\n\t\t    *tail++ = '.';\t\/\/ use current dir\n\t\t*tail = NUL;\n\t    }\n#  endif\n\t}\n\telse\n\t    fname = gui_mch_browse(flags & BROWSE_SAVE,\n\t\t\t       title, dflt, ext, initdir, (char_u *)_(filter));\n\n\t\/\/ We hang around in the dialog for a while, the user might do some\n\t\/\/ things to our files.  The Win32 dialog allows deleting or renaming\n\t\/\/ a file, check timestamps.\n\tneed_check_timestamps = TRUE;\n\tdid_check_timestamps = FALSE;\n    }\n    else\n# endif\n    {\n\t\/\/ TODO: non-GUI file selector here\n\temsg(_(e_sorry_no_file_browser_in_console_mode));\n\tfname = NULL;\n    }\n\n    \/\/ keep the directory for next time\n    if (fname != NULL)\n    {\n\tvim_free(last_dir);\n\tlast_dir = vim_strsave(fname);\n\tif (last_dir != NULL && !(flags & BROWSE_DIR))\n\t{\n\t    *gettail(last_dir) = NUL;\n\t    if (*last_dir == NUL)\n\t    {\n\t\t\/\/ filename only returned, must be in current dir\n\t\tvim_free(last_dir);\n\t\tlast_dir = alloc(MAXPATHL);\n\t\tif (last_dir != NULL)\n\t\t    mch_dirname(last_dir, MAXPATHL);\n\t    }\n\t}\n    }\n\n    vim_free(tofree);\n    cmdmod.cmod_flags = save_cmod_flags;\n\n    return fname;\n}","target":0,"code_token_length":1369,"total_token_length":1605,"max_tokens_setting":2048}
+{"idx":231025,"func":"BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,\r\n                              BaseType_t * const pxHigherPriorityTaskWoken )\r\n{\r\n    BaseType_t xReturn;\r\n    UBaseType_t uxSavedInterruptStatus;\r\n    Queue_t * const pxQueue = xQueue;\r\n\r\n    \/* Similar to xQueueGenericSendFromISR() but used with semaphores where the\r\n     * item size is 0.  Don't directly wake a task that was blocked on a queue\r\n     * read, instead return a flag to say whether a context switch is required or\r\n     * not (i.e. has a task with a higher priority than us been woken by this\r\n     * post). *\/\r\n\r\n    configASSERT( pxQueue );\r\n\r\n    \/* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR()\r\n     * if the item size is not 0. *\/\r\n    configASSERT( pxQueue->uxItemSize == 0 );\r\n\r\n    \/* Normally a mutex would not be given from an interrupt, especially if\r\n     * there is a mutex holder, as priority inheritance makes no sense for an\r\n     * interrupts, only tasks. *\/\r\n    configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->u.xSemaphore.xMutexHolder != NULL ) ) );\r\n\r\n    \/* RTOS ports that support interrupt nesting have the concept of a maximum\r\n     * system call (or maximum API call) interrupt priority.  Interrupts that are\r\n     * above the maximum system call priority are kept permanently enabled, even\r\n     * when the RTOS kernel is in a critical section, but cannot make any calls to\r\n     * FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r\n     * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r\n     * failure if a FreeRTOS API function is called from an interrupt that has been\r\n     * assigned a priority above the configured maximum system call priority.\r\n     * Only FreeRTOS functions that end in FromISR can be called from interrupts\r\n     * that have been assigned a priority at or (logically) below the maximum\r\n     * system call interrupt priority.  FreeRTOS maintains a separate interrupt\r\n     * safe API to ensure interrupt entry is as fast and as simple as possible.\r\n     * More information (albeit Cortex-M specific) is provided on the following\r\n     * link: https:\/\/www.FreeRTOS.org\/RTOS-Cortex-M3-M4.html *\/\r\n    portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r\n\r\n    uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r\n    {\r\n        const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;\r\n\r\n        \/* When the queue is used to implement a semaphore no data is ever\r\n         * moved through the queue but it is still valid to see if the queue 'has\r\n         * space'. *\/\r\n        if( uxMessagesWaiting < pxQueue->uxLength )\r\n        {\r\n            const int8_t cTxLock = pxQueue->cTxLock;\r\n\r\n            traceQUEUE_SEND_FROM_ISR( pxQueue );\r\n\r\n            \/* A task can only have an inherited priority if it is a mutex\r\n             * holder - and if there is a mutex holder then the mutex cannot be\r\n             * given from an ISR.  As this is the ISR version of the function it\r\n             * can be assumed there is no mutex holder and no need to determine if\r\n             * priority disinheritance is needed.  Simply increase the count of\r\n             * messages (semaphores) available. *\/\r\n            pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1;\r\n\r\n            \/* The event list is not altered if the queue is locked.  This will\r\n             * be done when the queue is unlocked later. *\/\r\n            if( cTxLock == queueUNLOCKED )\r\n            {\r\n                #if ( configUSE_QUEUE_SETS == 1 )\r\n                    {\r\n                        if( pxQueue->pxQueueSetContainer != NULL )\r\n                        {\r\n                            if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )\r\n                            {\r\n                                \/* The semaphore is a member of a queue set, and\r\n                                 * posting to the queue set caused a higher priority\r\n                                 * task to unblock.  A context switch is required. *\/\r\n                                if( pxHigherPriorityTaskWoken != NULL )\r\n                                {\r\n                                    *pxHigherPriorityTaskWoken = pdTRUE;\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                        else\r\n                        {\r\n                            if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                            {\r\n                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                                {\r\n                                    \/* The task waiting has a higher priority so\r\n                                     *  record that a context switch is required. *\/\r\n                                    if( pxHigherPriorityTaskWoken != NULL )\r\n                                    {\r\n                                        *pxHigherPriorityTaskWoken = pdTRUE;\r\n                                    }\r\n                                    else\r\n                                    {\r\n                                        mtCOVERAGE_TEST_MARKER();\r\n                                    }\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                    }\r\n                #else \/* configUSE_QUEUE_SETS *\/\r\n                    {\r\n                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                        {\r\n                            if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                            {\r\n                                \/* The task waiting has a higher priority so record that a\r\n                                 * context switch is required. *\/\r\n                                if( pxHigherPriorityTaskWoken != NULL )\r\n                                {\r\n                                    *pxHigherPriorityTaskWoken = pdTRUE;\r\n                                }\r\n                                else\r\n                                {\r\n                                    mtCOVERAGE_TEST_MARKER();\r\n                                }\r\n                            }\r\n                            else\r\n                            {\r\n                                mtCOVERAGE_TEST_MARKER();\r\n                            }\r\n                        }\r\n                        else\r\n                        {\r\n                            mtCOVERAGE_TEST_MARKER();\r\n                        }\r\n                    }\r\n                #endif \/* configUSE_QUEUE_SETS *\/\r\n            }\r\n            else\r\n            {\r\n                \/* Increment the lock count so the task that unlocks the queue\r\n                 * knows that data was posted while it was locked. *\/\r\n                configASSERT( cTxLock != queueINT8_MAX );\r\n\r\n                pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 );\r\n            }\r\n\r\n            xReturn = pdPASS;\r\n        }\r\n        else\r\n        {\r\n            traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r\n            xReturn = errQUEUE_FULL;\r\n        }\r\n    }\r\n    portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r\n\r\n    return xReturn;\r\n}\r","target":0,"code_token_length":1399,"total_token_length":1635,"max_tokens_setting":2048}
+{"idx":508388,"func":"bool setup_tables(THD *thd, Name_resolution_context *context,\n                  List<TABLE_LIST> *from_clause, TABLE_LIST *tables,\n                  List<TABLE_LIST> &leaves, bool select_insert,\n                  bool full_table_list)\n{\n  uint tablenr= 0;\n  List_iterator<TABLE_LIST> ti(leaves);\n  TABLE_LIST *table_list;\n\n  DBUG_ENTER(\"setup_tables\");\n\n  DBUG_ASSERT ((select_insert && !tables->next_name_resolution_table) || !tables || \n               (context->table_list && context->first_name_resolution_table));\n  \/*\n    this is used for INSERT ... SELECT.\n    For select we setup tables except first (and its underlying tables)\n  *\/\n  TABLE_LIST *first_select_table= (select_insert ?\n                                   tables->next_local:\n                                   0);\n  SELECT_LEX *select_lex= select_insert ? &thd->lex->select_lex :\n                                          thd->lex->current_select;\n  if (select_lex->first_cond_optimization)\n  {\n    leaves.empty();\n    if (select_lex->prep_leaf_list_state != SELECT_LEX::SAVED)\n    {\n      make_leaves_list(thd, leaves, tables, full_table_list, first_select_table);\n      select_lex->prep_leaf_list_state= SELECT_LEX::READY;\n      select_lex->leaf_tables_exec.empty();\n    }\n    else\n    {\n      List_iterator_fast <TABLE_LIST> ti(select_lex->leaf_tables_prep);\n      while ((table_list= ti++))\n        leaves.push_back(table_list, thd->mem_root);\n    }\n      \n    while ((table_list= ti++))\n    {\n      TABLE *table= table_list->table;\n      if (table)\n        table->pos_in_table_list= table_list;\n      if (first_select_table &&\n          table_list->top_table() == first_select_table)\n      {\n        \/* new counting for SELECT of INSERT ... SELECT command *\/\n        first_select_table= 0;\n        thd->lex->select_lex.insert_tables= tablenr;\n        tablenr= 0;\n      }\n      if(table_list->jtbm_subselect)\n      {\n        table_list->jtbm_table_no= tablenr;\n      }\n      else if (table)\n      {\n        table->pos_in_table_list= table_list;\n        setup_table_map(table, table_list, tablenr);\n\n        if (table_list->process_index_hints(table))\n          DBUG_RETURN(1);\n      }\n      tablenr++;\n    }\n    if (tablenr > MAX_TABLES)\n    {\n      my_error(ER_TOO_MANY_TABLES,MYF(0), static_cast<int>(MAX_TABLES));\n      DBUG_RETURN(1);\n    }\n  }\n  else\n  { \n    List_iterator_fast <TABLE_LIST> ti(select_lex->leaf_tables_exec);\n    select_lex->leaf_tables.empty();\n    while ((table_list= ti++))\n    {\n      if(table_list->jtbm_subselect)\n      {\n        table_list->jtbm_table_no= table_list->tablenr_exec;\n      }\n      else\n      {\n        table_list->table->tablenr= table_list->tablenr_exec;\n        table_list->table->map= table_list->map_exec;\n        table_list->table->maybe_null= table_list->maybe_null_exec;\n        table_list->table->pos_in_table_list= table_list;\n        if (table_list->process_index_hints(table_list->table))\n          DBUG_RETURN(1);\n      }\n      select_lex->leaf_tables.push_back(table_list);\n    }\n  }    \n\n  for (table_list= tables;\n       table_list;\n       table_list= table_list->next_local)\n  {\n    if (table_list->merge_underlying_list)\n    {\n      DBUG_ASSERT(table_list->is_merged_derived());\n      Query_arena *arena, backup;\n      arena= thd->activate_stmt_arena_if_needed(&backup);\n      bool res;\n      res= table_list->setup_underlying(thd);\n      if (arena)\n        thd->restore_active_arena(arena, &backup);\n      if (res)\n        DBUG_RETURN(1);\n    }\n\n    if (table_list->jtbm_subselect)\n    {\n      Item *item= table_list->jtbm_subselect->optimizer;\n      if (!table_list->jtbm_subselect->optimizer->fixed &&\n          table_list->jtbm_subselect->optimizer->fix_fields(thd, &item))\n      {\n        my_error(ER_TOO_MANY_TABLES,MYF(0), static_cast<int>(MAX_TABLES)); \/* psergey-todo: WHY ER_TOO_MANY_TABLES ???*\/\n        DBUG_RETURN(1);\n      }\n      DBUG_ASSERT(item == table_list->jtbm_subselect->optimizer);\n    }\n  }\n\n  \/* Precompute and store the row types of NATURAL\/USING joins. *\/\n  if (setup_natural_join_row_types(thd, from_clause, context))\n    DBUG_RETURN(1);\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":1058,"total_token_length":1294,"max_tokens_setting":2048}
+{"idx":230301,"func":"njs_array_prototype_sort(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    int64_t                i, und, len, nlen, length;\n    njs_int_t              ret, fast_path;\n    njs_array_t            *array;\n    njs_value_t            *this, *comparefn, *start, *strings;\n    njs_array_sort_ctx_t   ctx;\n    njs_array_sort_slot_t  *p, *end, *slots, *nslots;\n\n    comparefn = njs_arg(args, nargs, 1);\n\n    if (njs_is_defined(comparefn)) {\n        if (njs_slow_path(!njs_is_function(comparefn))) {\n            njs_type_error(vm, \"comparefn must be callable or undefined\");\n            return NJS_ERROR;\n        }\n\n        ctx.function = njs_function(comparefn);\n\n    } else {\n        ctx.function = NULL;\n    }\n\n    this = njs_argument(args, 0);\n\n    ret = njs_value_to_object(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_value_length(vm, this, &length);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_slow_path(length < 2)) {\n        vm->retval = *this;\n        return NJS_OK;\n    }\n\n    slots = NULL;\n    ctx.vm = vm;\n    ctx.strings.separate = 0;\n    ctx.strings.pointer = 0;\n    ctx.exception = 0;\n\n    fast_path = njs_is_fast_array(this);\n\n    if (njs_fast_path(fast_path)) {\n        array = njs_array(this);\n        start = array->start;\n\n        slots = njs_mp_alloc(vm->mem_pool,\n                             sizeof(njs_array_sort_slot_t) * length);\n        if (njs_slow_path(slots == NULL)) {\n                return NJS_ERROR;\n        }\n\n        und = 0;\n        p = slots;\n\n        for (i = 0; i < length; i++) {\n            if (njs_slow_path(!njs_is_valid(&start[i]))) {\n                fast_path = 0;\n                njs_mp_free(vm->mem_pool, slots);\n                slots = NULL;\n                goto slow_path;\n            }\n\n            if (njs_slow_path(njs_is_undefined(&start[i]))) {\n                und++;\n                continue;\n            }\n\n            p->value = start[i];\n            p->pos = i;\n            p->str = NULL;\n            p++;\n        }\n\n        len = p - slots;\n\n    } else {\n\nslow_path:\n\n        und = 0;\n        p = NULL;\n        end = NULL;\n\n        for (i = 0; i < length; i++) {\n            if (p >= end) {\n                nlen = njs_min(njs_max((p - slots) * 2, 8), length);\n                nslots = njs_mp_alloc(vm->mem_pool,\n                                      sizeof(njs_array_sort_slot_t) * nlen);\n                if (njs_slow_path(nslots == NULL)) {\n                    njs_memory_error(vm);\n                    return NJS_ERROR;\n                }\n\n                if (slots != NULL) {\n                    p = (void *) njs_cpymem(nslots, slots,\n                                  sizeof(njs_array_sort_slot_t) * (p - slots));\n                    njs_mp_free(vm->mem_pool, slots);\n\n                } else {\n                    p = nslots;\n                }\n\n                slots = nslots;\n                end = slots + nlen;\n            }\n\n            ret = njs_value_property_i64(vm, this, i, &p->value);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                ret = NJS_ERROR;\n                goto exception;\n            }\n\n            if (ret == NJS_DECLINED) {\n                continue;\n            }\n\n            if (njs_is_undefined(&p->value)) {\n                und++;\n                continue;\n            }\n\n            p->pos = i;\n            p->str = NULL;\n            p++;\n        }\n\n        len = p - slots;\n    }\n\n    strings = njs_arr_init(vm->mem_pool, &ctx.strings, NULL, len + 1,\n                           sizeof(njs_value_t));\n    if (njs_slow_path(strings == NULL)) {\n        ret = NJS_ERROR;\n        goto exception;\n    }\n\n    njs_qsort(slots, len, sizeof(njs_array_sort_slot_t), njs_array_compare,\n              &ctx);\n\n    if (ctx.exception) {\n        ret = NJS_ERROR;\n        goto exception;\n    }\n\n    if (njs_fast_path(fast_path && njs_is_fast_array(this))) {\n        array = njs_array(this);\n        start = array->start;\n\n        for (i = 0; i < len; i++) {\n            start[i] = slots[i].value;\n        }\n\n        for (i = len; und-- > 0; i++) {\n            start[i] = njs_value_undefined;\n        }\n\n    } else {\n        for (i = 0; i < len; i++) {\n            if (slots[i].pos != i) {\n                ret = njs_value_property_i64_set(vm, this, i, &slots[i].value);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    goto exception;\n                }\n            }\n        }\n\n        for (i = len; und-- > 0; i++) {\n            ret = njs_value_property_i64_set(vm, this, i,\n                                          njs_value_arg(&njs_value_undefined));\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                goto exception;\n            }\n        }\n\n        for (; i < length; i++) {\n            ret = njs_value_property_i64_delete(vm, this, i, NULL);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                goto exception;\n            }\n        }\n    }\n\n    vm->retval = *this;\n\n    ret = NJS_OK;\n\nexception:\n\n    if (slots != NULL) {\n        njs_mp_free(vm->mem_pool, slots);\n    }\n\n    njs_arr_destroy(&ctx.strings);\n\n    return ret;\n}","target":0,"code_token_length":1324,"total_token_length":1560,"max_tokens_setting":2048}
+{"idx":251946,"func":"inline void BinaryBroadcastFiveFold(const ArithmeticParams& unswitched_params,\n                                    const RuntimeShape& unswitched_input1_shape,\n                                    const T* unswitched_input1_data,\n                                    const RuntimeShape& unswitched_input2_shape,\n                                    const T* unswitched_input2_data,\n                                    const RuntimeShape& output_shape,\n                                    T* output_data, ElementwiseF elementwise_f,\n                                    ScalarBroadcastF scalar_broadcast_f) {\n  ArithmeticParams switched_params = unswitched_params;\n  switched_params.input1_offset = unswitched_params.input2_offset;\n  switched_params.input1_multiplier = unswitched_params.input2_multiplier;\n  switched_params.input1_shift = unswitched_params.input2_shift;\n  switched_params.input2_offset = unswitched_params.input1_offset;\n  switched_params.input2_multiplier = unswitched_params.input1_multiplier;\n  switched_params.input2_shift = unswitched_params.input1_shift;\n\n  const bool use_unswitched =\n      unswitched_params.broadcast_category ==\n      tflite::BroadcastableOpCategory::kFirstInputBroadcastsFast;\n\n  const ArithmeticParams& params =\n      use_unswitched ? unswitched_params : switched_params;\n  const T* input1_data =\n      use_unswitched ? unswitched_input1_data : unswitched_input2_data;\n  const T* input2_data =\n      use_unswitched ? unswitched_input2_data : unswitched_input1_data;\n\n  \/\/ Fivefold nested loops. The second input resets its position for each\n  \/\/ iteration of the second loop. The first input resets its position at the\n  \/\/ beginning of the fourth loop. The innermost loop is an elementwise add of\n  \/\/ sections of the arrays.\n  T* output_data_ptr = output_data;\n  const T* input1_data_ptr = input1_data;\n  const T* input2_data_reset = input2_data;\n  \/\/ In the fivefold pattern, y0, y2 and y4 are not broadcast, and so shared\n  \/\/ between input shapes. y3 for input 1 is always broadcast, and so the\n  \/\/ dimension there is 1, whereas optionally y1 might be broadcast for\n  \/\/ input 2. Put another way, input1.shape.FlatSize = y0 * y1 * y2 * y4,\n  \/\/ input2.shape.FlatSize = y0 * y2 * y3 * y4.\n  int y0 = params.broadcast_shape[0];\n  int y1 = params.broadcast_shape[1];\n  int y2 = params.broadcast_shape[2];\n  int y3 = params.broadcast_shape[3];\n  int y4 = params.broadcast_shape[4];\n  if (y4 > 1) {\n    \/\/ General fivefold pattern, with y4 > 1 so there is a non-broadcast inner\n    \/\/ dimension.\n    for (int i0 = 0; i0 < y0; ++i0) {\n      const T* input2_data_ptr = nullptr;\n      for (int i1 = 0; i1 < y1; ++i1) {\n        input2_data_ptr = input2_data_reset;\n        for (int i2 = 0; i2 < y2; ++i2) {\n          for (int i3 = 0; i3 < y3; ++i3) {\n            elementwise_f(y4, params, input1_data_ptr, input2_data_ptr,\n                          output_data_ptr);\n            input2_data_ptr += y4;\n            output_data_ptr += y4;\n          }\n          \/\/ We have broadcast y4 of input1 data y3 times, and now move on.\n          input1_data_ptr += y4;\n        }\n      }\n      \/\/ We have broadcast y2*y3*y4 of input2 data y1 times, and now move on.\n      input2_data_reset = input2_data_ptr;\n    }\n  } else if (input1_data_ptr != nullptr) {\n    \/\/ Special case of y4 == 1, in which the innermost loop is a single\n    \/\/ element and can be combined with the next (y3) as an inner broadcast.\n    \/\/\n    \/\/ Note that this handles the case of pure scalar broadcast when\n    \/\/ y0 == y1 == y2 == 1. With low overhead it handles cases such as scalar\n    \/\/ broadcast with batch (as y2 > 1).\n    \/\/\n    \/\/ NOTE The process is the same as the above general case except\n    \/\/ simplified for y4 == 1 and the loop over y3 is contained within the\n    \/\/ AddScalarBroadcast function.\n    for (int i0 = 0; i0 < y0; ++i0) {\n      const T* input2_data_ptr = nullptr;\n      for (int i1 = 0; i1 < y1; ++i1) {\n        input2_data_ptr = input2_data_reset;\n        for (int i2 = 0; i2 < y2; ++i2) {\n          scalar_broadcast_f(y3, params, *input1_data_ptr, input2_data_ptr,\n                             output_data_ptr);\n          input2_data_ptr += y3;\n          output_data_ptr += y3;\n          input1_data_ptr += 1;\n        }\n      }\n      input2_data_reset = input2_data_ptr;\n    }\n  }\n}","target":0,"code_token_length":1122,"total_token_length":1358,"max_tokens_setting":2048}
+{"idx":234185,"func":"display_loclists_list (struct dwarf_section *  section,\n\t\t       unsigned char **        start_ptr,\n\t\t       unsigned int            debug_info_entry,\n\t\t       dwarf_vma               offset,\n\t\t       dwarf_vma               base_address,\n\t\t       unsigned char **        vstart_ptr,\n\t\t       int                     has_frame_base)\n{\n  unsigned char *  start = *start_ptr;\n  unsigned char *  vstart = *vstart_ptr;\n  unsigned char *  section_end = section->start + section->size;\n  dwarf_vma        cu_offset;\n  unsigned int     pointer_size;\n  unsigned int     offset_size;\n  unsigned int     dwarf_version;\n\n  \/* Initialize it due to a false compiler warning.  *\/\n  dwarf_vma begin = -1, vbegin = -1;\n  dwarf_vma end = -1, vend = -1;\n  dwarf_vma length;\n  int need_frame_base;\n\n  if (debug_info_entry >= num_debug_info_entries)\n    {\n      warn (_(\"No debug information available for \"\n\t      \"loclists lists of entry: %u\\n\"),\n\t    debug_info_entry);\n      return;\n    }\n\n  cu_offset = debug_information [debug_info_entry].cu_offset;\n  pointer_size = debug_information [debug_info_entry].pointer_size;\n  offset_size = debug_information [debug_info_entry].offset_size;\n  dwarf_version = debug_information [debug_info_entry].dwarf_version;\n\n  if (pointer_size < 2 || pointer_size > 8)\n    {\n      warn (_(\"Invalid pointer size (%d) in debug info for entry %d\\n\"),\n\t    pointer_size, debug_info_entry);\n      return;\n    }\n\n  while (1)\n    {\n      dwarf_vma off = offset + (start - *start_ptr);\n      enum dwarf_location_list_entry_type llet;\n\n      if (start + 1 > section_end)\n\t{\n\t  warn (_(\"Location list starting at offset 0x%lx is not terminated.\\n\"),\n\t\t(unsigned long) offset);\n\t  break;\n\t}\n\n      printf (\"    \");\n      print_dwarf_vma (off, 4);\n\n      SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end);\n\n      if (vstart && (llet == DW_LLE_offset_pair\n\t\t     || llet == DW_LLE_start_end\n\t\t     || llet == DW_LLE_start_length))\n\t{\n\t  off = offset + (vstart - *start_ptr);\n\n\t  READ_ULEB (vbegin, vstart, section_end);\n\t  print_dwarf_view (vbegin, pointer_size, 1);\n\n\t  READ_ULEB (vend, vstart, section_end);\n\t  print_dwarf_view (vend, pointer_size, 1);\n\n\t  printf (_(\"views at %8.8lx for:\\n    %*s \"),\n\t\t  (unsigned long) off, 8, \"\");\n\t}\n\n      switch (llet)\n\t{\n\tcase DW_LLE_end_of_list:\n\t  printf (_(\"<End of list>\\n\"));\n\t  break;\n\n\tcase DW_LLE_base_addressx:\n\t  READ_ULEB (base_address, start, section_end);\n\t  print_dwarf_vma (base_address, pointer_size);\n\t  printf (_(\"(index into .debug_addr) \"));\n\t  base_address = fetch_indexed_addr (base_address, pointer_size);\n\t  print_dwarf_vma (base_address, pointer_size);\n\t  printf (_(\"(base address)\\n\"));\n\t  break;\n\n\tcase DW_LLE_startx_endx:\n\t  READ_ULEB (begin, start, section_end);\n\t  begin = fetch_indexed_addr (begin, pointer_size);\n\t  READ_ULEB (end, start, section_end);\n\t  end = fetch_indexed_addr (end, pointer_size);\n\t  break;\n\n\tcase DW_LLE_startx_length:\n\t  READ_ULEB (begin, start, section_end);\n\t  begin = fetch_indexed_addr (begin, pointer_size);\n\t  READ_ULEB (end, start, section_end);\n\t  end += begin;\n\t  break;\n\n\tcase DW_LLE_default_location:\n\t  begin = end = 0;\n\t  break;\n\t  \n\tcase DW_LLE_offset_pair:\n\t  READ_ULEB (begin, start, section_end);\n\t  begin += base_address;\n\t  READ_ULEB (end, start, section_end);\n\t  end += base_address;\n\t  break;\n\n\tcase DW_LLE_base_address:\n\t  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size,\n\t\t\t\t section_end);\n\t  print_dwarf_vma (base_address, pointer_size);\n\t  printf (_(\"(base address)\\n\"));\n\t  break;\n\n\tcase DW_LLE_start_end:\n\t  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);\n\t  SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end);\n\t  break;\n\n\tcase DW_LLE_start_length:\n\t  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);\n\t  READ_ULEB (end, start, section_end);\n\t  end += begin;\n\t  break;\n\n#ifdef DW_LLE_view_pair\n\tcase DW_LLE_view_pair:\n\t  if (vstart)\n\t    printf (_(\"View pair entry in loclist with locviews attribute\\n\"));\n\t  READ_ULEB (vbegin, start, section_end);\n\t  print_dwarf_view (vbegin, pointer_size, 1);\n\n\t  READ_ULEB (vend, start, section_end);\n\t  print_dwarf_view (vend, pointer_size, 1);\n\n\t  printf (_(\"views for:\\n\"));\n\t  continue;\n#endif\n\n\tdefault:\n\t  error (_(\"Invalid location list entry type %d\\n\"), llet);\n\t  return;\n\t}\n\n      if (llet == DW_LLE_end_of_list)\n\tbreak;\n\n      if (llet == DW_LLE_base_address\n\t  || llet == DW_LLE_base_addressx)\n\tcontinue;\n\n      if (start == section_end)\n\t{\n\t  warn (_(\"Location list starting at offset 0x%lx is not terminated.\\n\"),\n\t\t(unsigned long) offset);\n\t  break;\n\t}\n      READ_ULEB (length, start, section_end);\n\n      if (length > (size_t) (section_end - start))\n\t{\n\t  warn (_(\"Location list starting at offset 0x%lx is not terminated.\\n\"),\n\t\t(unsigned long) offset);\n\t  break;\n\t}\n\n      print_dwarf_vma (begin, pointer_size);\n      print_dwarf_vma (end, pointer_size);\n\n      putchar ('(');\n      need_frame_base = decode_location_expression (start,\n\t\t\t\t\t\t    pointer_size,\n\t\t\t\t\t\t    offset_size,\n\t\t\t\t\t\t    dwarf_version,\n\t\t\t\t\t\t    length,\n\t\t\t\t\t\t    cu_offset, section);\n      putchar (')');\n\n      if (need_frame_base && !has_frame_base)\n\tprintf (_(\" [without DW_AT_frame_base]\"));\n\n      if (begin == end && vbegin == vend)\n\tfputs (_(\" (start == end)\"), stdout);\n      else if (begin > end || (begin == end && vbegin > vend))\n\tfputs (_(\" (start > end)\"), stdout);\n\n      putchar ('\\n');\n\n      start += length;\n      vbegin = vend = -1;\n    }\n\n  if (vbegin != vm1 || vend != vm1)\n    printf (_(\"Trailing view pair not used in a range\"));\n\n  *start_ptr = start;\n  *vstart_ptr = vstart;\n}","target":0,"code_token_length":1520,"total_token_length":1756,"max_tokens_setting":2048}
+{"idx":195073,"func":"  void DecodePngV2(OpKernelContext* context, StringPiece input) {\n    int channel_bits = (data_type_ == DataType::DT_UINT8) ? 8 : 16;\n    png::DecodeContext decode;\n    OP_REQUIRES(\n        context, png::CommonInitDecode(input, channels_, channel_bits, &decode),\n        errors::InvalidArgument(\"Invalid PNG. Failed to initialize decoder.\"));\n\n    \/\/ Verify that width and height are not too large:\n    \/\/ - verify width and height don't overflow int.\n    \/\/ - width can later be multiplied by channels_ and sizeof(uint16), so\n    \/\/   verify single dimension is not too large.\n    \/\/ - verify when width and height are multiplied together, there are a few\n    \/\/   bits to spare as well.\n    const int width = static_cast<int>(decode.width);\n    const int height = static_cast<int>(decode.height);\n    const int64_t total_size =\n        static_cast<int64_t>(width) * static_cast<int64_t>(height);\n    if (width != static_cast<int64_t>(decode.width) || width <= 0 ||\n        width >= (1LL << 27) || height != static_cast<int64_t>(decode.height) ||\n        height <= 0 || height >= (1LL << 27) || total_size >= (1LL << 29)) {\n      png::CommonFreeDecode(&decode);\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\"PNG size too large for int: \",\n                                          decode.width, \" by \", decode.height));\n    }\n\n    Tensor* output = nullptr;\n    Status status;\n    \/\/ By the existing API, we support decoding PNG with `DecodeGif` op.\n    \/\/ We need to make sure to return 4-D shapes when using `DecodeGif`.\n    if (op_type_ == \"DecodeGif\") {\n      status = context->allocate_output(\n          0, TensorShape({1, height, width, decode.channels}), &output);\n    } else {\n      status = context->allocate_output(\n          0, TensorShape({height, width, decode.channels}), &output);\n    }\n\n    if (op_type_ == \"DecodeBmp\") {\n      \/\/ TODO(b\/171060723): Only DecodeBmp as op_type_ is not acceptable here\n      \/\/ because currently `decode_(jpeg|png|gif)` ops can decode any one of\n      \/\/ jpeg, png or gif but not bmp. Similarly, `decode_bmp` cannot decode\n      \/\/ anything but bmp formats. This behavior needs to be revisited. For more\n      \/\/ details, please refer to the bug.\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"Trying to decode PNG format using DecodeBmp op. Use \"\n                      \"`decode_png` or `decode_image` instead.\"));\n    } else if (op_type_ == \"DecodeAndCropJpeg\") {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"DecodeAndCropJpeg operation can run on JPEG only, but \"\n                      \"detected PNG.\"));\n    }\n\n    if (!status.ok()) png::CommonFreeDecode(&decode);\n    OP_REQUIRES_OK(context, status);\n\n    if (data_type_ == DataType::DT_UINT8) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint8>().data()),\n              decode.channels * width * sizeof(uint8), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_UINT16) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint16>().data()),\n              decode.channels * width * sizeof(uint16), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_FLOAT) {\n      \/\/ `png::CommonFinishDecode` does not support `float`. First allocate\n      \/\/ uint16 buffer for the image and decode in uint16 (lossless). Wrap the\n      \/\/ buffer in `unique_ptr` so that we don't forget to delete the buffer.\n      std::unique_ptr<uint16[]> buffer(\n          new uint16[height * width * decode.channels]);\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(reinterpret_cast<png_bytep>(buffer.get()),\n                                  decode.channels * width * sizeof(uint16),\n                                  &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n\n      \/\/ Convert uint16 image data to desired data type.\n      \/\/ Use eigen threadpooling to speed up the copy operation.\n      const auto& device = context->eigen_device<Eigen::ThreadPoolDevice>();\n      TTypes<uint16, 3>::UnalignedConstTensor buf(buffer.get(), height, width,\n                                                  decode.channels);\n      float scale = 1. \/ std::numeric_limits<uint16>::max();\n      \/\/ Fill output tensor with desired dtype.\n      output->tensor<float, 3>().device(device) = buf.cast<float>() * scale;\n    }\n  }","target":1,"code_token_length":1112,"total_token_length":1348,"max_tokens_setting":2048}
+{"idx":309854,"func":"expected_params(const char *name)\n{\n#define DATA(name,count) { { name }, count }\n    \/* *INDENT-OFF* *\/\n    static const struct {\n\tconst char name[9];\n\tint count;\n    } table[] = {\n\tDATA( \"S0\",\t\t1 ),\t\/* 'screen' extension *\/\n\tDATA( \"birep\",\t\t2 ),\n\tDATA( \"chr\",\t\t1 ),\n\tDATA( \"colornm\",\t1 ),\n\tDATA( \"cpi\",\t\t1 ),\n\tDATA( \"csnm\",\t\t1 ),\n\tDATA( \"csr\",\t\t2 ),\n\tDATA( \"cub\",\t\t1 ),\n\tDATA( \"cud\",\t\t1 ),\n\tDATA( \"cuf\",\t\t1 ),\n\tDATA( \"cup\",\t\t2 ),\n\tDATA( \"cuu\",\t\t1 ),\n\tDATA( \"cvr\",\t\t1 ),\n\tDATA( \"cwin\",\t\t5 ),\n\tDATA( \"dch\",\t\t1 ),\n\tDATA( \"defc\",\t\t3 ),\n\tDATA( \"dial\",\t\t1 ),\n\tDATA( \"dispc\",\t\t1 ),\n\tDATA( \"dl\",\t\t1 ),\n\tDATA( \"ech\",\t\t1 ),\n\tDATA( \"getm\",\t\t1 ),\n\tDATA( \"hpa\",\t\t1 ),\n\tDATA( \"ich\",\t\t1 ),\n\tDATA( \"il\",\t\t1 ),\n\tDATA( \"indn\",\t\t1 ),\n\tDATA( \"initc\",\t\t4 ),\n\tDATA( \"initp\",\t\t7 ),\n\tDATA( \"lpi\",\t\t1 ),\n\tDATA( \"mc5p\",\t\t1 ),\n\tDATA( \"mrcup\",\t\t2 ),\n\tDATA( \"mvpa\",\t\t1 ),\n\tDATA( \"pfkey\",\t\t2 ),\n\tDATA( \"pfloc\",\t\t2 ),\n\tDATA( \"pfx\",\t\t2 ),\n\tDATA( \"pfxl\",\t\t3 ),\n\tDATA( \"pln\",\t\t2 ),\n\tDATA( \"qdial\",\t\t1 ),\n\tDATA( \"rcsd\",\t\t1 ),\n\tDATA( \"rep\",\t\t2 ),\n\tDATA( \"rin\",\t\t1 ),\n\tDATA( \"sclk\",\t\t3 ),\n\tDATA( \"scp\",\t\t1 ),\n\tDATA( \"scs\",\t\t1 ),\n\tDATA( \"scsd\",\t\t2 ),\n\tDATA( \"setab\",\t\t1 ),\n\tDATA( \"setaf\",\t\t1 ),\n\tDATA( \"setb\",\t\t1 ),\n\tDATA( \"setcolor\",\t1 ),\n\tDATA( \"setf\",\t\t1 ),\n\tDATA( \"sgr\",\t\t9 ),\n\tDATA( \"sgr1\",\t\t6 ),\n\tDATA( \"slength\",\t1 ),\n\tDATA( \"slines\",\t\t1 ),\n\tDATA( \"smgbp\",\t\t1 ),\t\/* 2 if smgtp is not given *\/\n\tDATA( \"smglp\",\t\t1 ),\n\tDATA( \"smglr\",\t\t2 ),\n\tDATA( \"smgrp\",\t\t1 ),\n\tDATA( \"smgtb\",\t\t2 ),\n\tDATA( \"smgtp\",\t\t1 ),\n\tDATA( \"tsl\",\t\t1 ),\n\tDATA( \"u6\",\t\t-1 ),\n\tDATA( \"vpa\",\t\t1 ),\n\tDATA( \"wind\",\t\t4 ),\n\tDATA( \"wingo\",\t\t1 ),\n    };\n    \/* *INDENT-ON* *\/\n#undef DATA\n\n    unsigned n;\n    int result = 0;\t\t\/* function-keys, etc., use none *\/\n\n    for (n = 0; n < SIZEOF(table); n++) {\n\tif (!strcmp(name, table[n].name)) {\n\t    result = table[n].count;\n\t    break;\n\t}\n    }\n\n    return result;\n}","target":0,"code_token_length":852,"total_token_length":1088,"max_tokens_setting":2048}
+{"idx":500668,"func":"static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf,\n    int expectnames) {\n  sftp_attributes attr;\n  ssh_string owner = NULL;\n  ssh_string group = NULL;\n  uint32_t flags = 0;\n  int ok = 0;\n\n  \/* unused member variable *\/\n  (void) expectnames;\n\n  attr = malloc(sizeof(struct sftp_attributes_struct));\n  if (attr == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return NULL;\n  }\n  ZERO_STRUCTP(attr);\n\n  \/* This isn't really a loop, but it is like a try..catch.. *\/\n  do {\n    if (buffer_get_u32(buf, &flags) != 4) {\n      break;\n    }\n\n    flags = ntohl(flags);\n    attr->flags = flags;\n\n    if (flags & SSH_FILEXFER_ATTR_SIZE) {\n      if (buffer_get_u64(buf, &attr->size) != 8) {\n        break;\n      }\n      attr->size = ntohll(attr->size);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_OWNERGROUP) {\n      if((owner = buffer_get_ssh_string(buf)) == NULL ||\n        (attr->owner = ssh_string_to_char(owner)) == NULL) {\n        break;\n      }\n      if ((group = buffer_get_ssh_string(buf)) == NULL ||\n        (attr->group = ssh_string_to_char(group)) == NULL) {\n        break;\n      }\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_PERMISSIONS) {\n      if (buffer_get_u32(buf, &attr->permissions) != 4) {\n        break;\n      }\n      attr->permissions = ntohl(attr->permissions);\n\n      \/* FIXME on windows! *\/\n      switch (attr->permissions & S_IFMT) {\n        case S_IFSOCK:\n        case S_IFBLK:\n        case S_IFCHR:\n        case S_IFIFO:\n          attr->type = SSH_FILEXFER_TYPE_SPECIAL;\n          break;\n        case S_IFLNK:\n          attr->type = SSH_FILEXFER_TYPE_SYMLINK;\n          break;\n        case S_IFREG:\n          attr->type = SSH_FILEXFER_TYPE_REGULAR;\n          break;\n        case S_IFDIR:\n          attr->type = SSH_FILEXFER_TYPE_DIRECTORY;\n          break;\n        default:\n          attr->type = SSH_FILEXFER_TYPE_UNKNOWN;\n          break;\n      }\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_ACCESSTIME) {\n      if (buffer_get_u64(buf, &attr->atime64) != 8) {\n        break;\n      }\n      attr->atime64 = ntohll(attr->atime64);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {\n      if (buffer_get_u32(buf, &attr->atime_nseconds) != 4) {\n        break;\n      }\n      attr->atime_nseconds = ntohl(attr->atime_nseconds);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_CREATETIME) {\n      if (buffer_get_u64(buf, &attr->createtime) != 8) {\n        break;\n      }\n      attr->createtime = ntohll(attr->createtime);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {\n      if (buffer_get_u32(buf, &attr->createtime_nseconds) != 4) {\n        break;\n      }\n      attr->createtime_nseconds = ntohl(attr->createtime_nseconds);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_MODIFYTIME) {\n      if (buffer_get_u64(buf, &attr->mtime64) != 8) {\n        break;\n      }\n      attr->mtime64 = ntohll(attr->mtime64);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) {\n      if (buffer_get_u32(buf, &attr->mtime_nseconds) != 4) {\n        break;\n      }\n      attr->mtime_nseconds = ntohl(attr->mtime_nseconds);\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_ACL) {\n      if ((attr->acl = buffer_get_ssh_string(buf)) == NULL) {\n        break;\n      }\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_EXTENDED) {\n      if (buffer_get_u32(buf,&attr->extended_count) != 4) {\n        break;\n      }\n      attr->extended_count = ntohl(attr->extended_count);\n\n      while(attr->extended_count &&\n          (attr->extended_type = buffer_get_ssh_string(buf)) &&\n          (attr->extended_data = buffer_get_ssh_string(buf))){\n        attr->extended_count--;\n      }\n\n      if (attr->extended_count) {\n        break;\n      }\n    }\n    ok = 1;\n  } while (0);\n\n  if (ok == 0) {\n    \/* break issued somewhere *\/\n    ssh_string_free(owner);\n    ssh_string_free(group);\n    ssh_string_free(attr->acl);\n    ssh_string_free(attr->extended_type);\n    ssh_string_free(attr->extended_data);\n    SAFE_FREE(attr->owner);\n    SAFE_FREE(attr->group);\n    SAFE_FREE(attr);\n\n    ssh_set_error(sftp->session, SSH_FATAL, \"Invalid ATTR structure\");\n\n    return NULL;\n  }\n\n  return attr;\n}","target":0,"code_token_length":1135,"total_token_length":1371,"max_tokens_setting":2048}
+{"idx":256165,"func":"inline void SparseMatMul<TL, TR>::Compute(\n    typename SparseMatMul<TL, TR>::TensorInfoCache* \/*cache*\/,\n    const typename SparseMatMul<TL, TR>::ConstMatrixMapL& left,\n    const typename SparseMatMul<TL, TR>::ConstMatrixMapR& right,\n    bool transpose_left, const DeviceBase::CpuWorkerThreads* thread_pool,\n    bool transpose_output, MatrixMap* output) {\n  const int num_threads = thread_pool->num_threads;\n  int KR, NR, KL, JB, IB;\n  ComputeBlockSizes(left, right, transpose_left, num_threads, &KR, &NR, &KL,\n                    &JB, &IB);\n  \/\/ Slice the left matrix\n  std::vector<std::vector<SparseSlice<TL>*>> left_slices;\n  std::unique_ptr<BlockingCounter> sparse_slice_counter =\n      CreateSparseSlices(ConstMatrixMapL(left.data(), left.dimensions()),\n                         transpose_left, M, K, KL, &left_slices, thread_pool);\n  const int num_left_slices = left_slices.size();\n\n  const int right_dim0 = right.dimension(0);\n  const int right_dim1 = right.dimension(1);\n  \/\/ Allocate buffer for storing slices of right matrix.\n  \/\/ Note buffer needs enough space to hold at most a KR * NR matrix since that\n  \/\/ is the block size per iteration.\n  const int buffer_num_rows =\n      std::min(KR, right_dim0) * ((std::min(NR, right_dim1) + N - 1) \/ N);\n  MatrixR buffer(buffer_num_rows, N);\n  std::vector<ConstMatrixMapR*> right_slices;\n\n  std::vector<SparseSlice<TL>*> block_left_slices;\n  std::vector<std::function<void(void)>> tasks;\n  \/\/ Number of blocks based on block sizes of KR * NR.\n  const int num_k_blocks = (right_dim0 + KR - 1) \/ KR;\n  const int num_n_blocks = (right_dim1 + NR - 1) \/ NR;\n  std::unique_ptr<BlockingCounter> dense_slice_counter;\n\n  for (int nb = 0; nb < num_n_blocks; ++nb) {\n    const int right_num_cols =\n        std::min(NR, static_cast<int>(right_dim1 - NR * nb));\n    for (int kb = 0; kb < num_k_blocks; ++kb) {\n      const int right_num_rows =\n          std::min(KR, static_cast<int>(right_dim0 - KR * kb));\n      dense_slice_counter = CreateDenseSlices(\n          right, kb * KR, right_num_rows, nb * NR, right_num_cols, thread_pool,\n          &buffer, &right_slices);\n      const int num_right_slices = right_slices.size();\n      tasks.reserve(num_left_slices * num_right_slices);\n      for (int j_outer = 0; j_outer < num_right_slices; j_outer += JB) {\n        for (int i_outer = 0; i_outer < num_left_slices; i_outer += IB) {\n          for (int j_inner = j_outer;\n               j_inner < std::min(num_right_slices, j_outer + JB); ++j_inner) {\n            const int num_cols = std::min(N, right_num_cols - N * j_inner);\n            for (int i_inner = i_outer;\n                 i_inner < std::min(num_left_slices, i_outer + IB); ++i_inner) {\n              block_left_slices.clear();\n              int begin = kb * KR \/ KL;\n              int end = std::min<int>((kb + 1) * KR \/ KL,\n                                      (right.dimension(0) + KL - 1) \/ KL);\n              DCHECK_LT(begin, end);\n              block_left_slices.insert(block_left_slices.begin(),\n                                       left_slices[i_inner].begin() + begin,\n                                       left_slices[i_inner].begin() + end);\n              tasks.push_back(std::bind(\n                  &ComputeOutputBlock, block_left_slices,\n                  std::ref(*right_slices[j_inner]), num_cols, M * i_inner,\n                  N * j_inner + nb * NR, kb == 0, transpose_output, output));\n            }\n          }\n        }\n      }\n      if (sparse_slice_counter) {\n        sparse_slice_counter->Wait();\n        sparse_slice_counter.reset(nullptr);\n      }\n      if (dense_slice_counter) {\n        dense_slice_counter->Wait();\n        dense_slice_counter.reset(nullptr);\n      }\n      BlockingCounter bc(tasks.size());\n      for (const auto& t : tasks) {\n        thread_pool->workers->Schedule([&bc, &t]() {\n          t();\n          bc.DecrementCount();\n        });\n      }\n      bc.Wait();\n      tasks.clear();\n      for (auto& temp : right_slices) {\n        delete temp;\n      }\n      right_slices.clear();\n    }\n  }\n  for (auto& left_slice : left_slices) {\n    for (auto& temp : left_slice) {\n      delete temp;\n    }\n    left_slice.clear();\n  }\n}","target":0,"code_token_length":1045,"total_token_length":1281,"max_tokens_setting":2048}
+{"idx":424533,"func":"static UINT video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA* data)\n{\n\tVideoClientContextPriv* priv = context->priv;\n\tPresentationContext* presentation;\n\tint status;\n\n\tpresentation = priv->currentPresentation;\n\tif (!presentation)\n\t{\n\t\tWLog_ERR(TAG, \"no current presentation\");\n\t\treturn CHANNEL_RC_OK;\n\t}\n\n\tif (presentation->PresentationId != data->PresentationId)\n\t{\n\t\tWLog_ERR(TAG, \"current presentation id=%d doesn't match data id=%d\",\n\t\t         presentation->PresentationId, data->PresentationId);\n\t\treturn CHANNEL_RC_OK;\n\t}\n\n\tif (!Stream_EnsureRemainingCapacity(presentation->currentSample, data->cbSample))\n\t{\n\t\tWLog_ERR(TAG, \"unable to expand the current packet\");\n\t\treturn CHANNEL_RC_NO_MEMORY;\n\t}\n\n\tStream_Write(presentation->currentSample, data->pSample, data->cbSample);\n\n\tif (data->CurrentPacketIndex == data->PacketsInSample)\n\t{\n\t\tH264_CONTEXT* h264 = presentation->h264;\n\t\tUINT64 startTime = GetTickCount64(), timeAfterH264;\n\t\tMAPPED_GEOMETRY* geom = presentation->geometry;\n\n\t\tStream_SealLength(presentation->currentSample);\n\t\tStream_SetPosition(presentation->currentSample, 0);\n\n\t\tstatus = h264->subsystem->Decompress(h264, Stream_Pointer(presentation->currentSample),\n\t\t                                     Stream_Length(presentation->currentSample));\n\t\tif (status == 0)\n\t\t\treturn CHANNEL_RC_OK;\n\n\t\tif (status < 0)\n\t\t\treturn CHANNEL_RC_OK;\n\n\t\ttimeAfterH264 = GetTickCount64();\n\t\tif (data->SampleNumber == 1)\n\t\t{\n\t\t\tpresentation->lastPublishTime = startTime;\n\t\t}\n\n\t\tpresentation->lastPublishTime += (data->hnsDuration \/ 10000);\n\t\tif (presentation->lastPublishTime <= timeAfterH264 + 10)\n\t\t{\n\t\t\tint dropped = 0;\n\n\t\t\t\/* if the frame is to be published in less than 10 ms, let's consider it's now *\/\n\t\t\tyuv_to_rgb(presentation, presentation->surfaceData);\n\n\t\t\tcontext->showSurface(context, presentation->surface);\n\n\t\t\tpriv->publishedFrames++;\n\n\t\t\t\/* cleanup previously scheduled frames *\/\n\t\t\tEnterCriticalSection(&priv->framesLock);\n\t\t\twhile (Queue_Count(priv->frames) > 0)\n\t\t\t{\n\t\t\t\tVideoFrame* frame = Queue_Dequeue(priv->frames);\n\t\t\t\tif (frame)\n\t\t\t\t{\n\t\t\t\t\tpriv->droppedFrames++;\n\t\t\t\t\tVideoFrame_free(&frame);\n\t\t\t\t\tdropped++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tLeaveCriticalSection(&priv->framesLock);\n\n\t\t\tif (dropped)\n\t\t\t\tWLog_DBG(TAG, \"showing frame (%d dropped)\", dropped);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tBOOL enqueueResult;\n\t\t\tVideoFrame* frame = calloc(1, sizeof(*frame));\n\t\t\tif (!frame)\n\t\t\t{\n\t\t\t\tWLog_ERR(TAG, \"unable to create frame\");\n\t\t\t\treturn CHANNEL_RC_NO_MEMORY;\n\t\t\t}\n\t\t\tmappedGeometryRef(geom);\n\n\t\t\tframe->presentation = presentation;\n\t\t\tframe->publishTime = presentation->lastPublishTime;\n\t\t\tframe->geometry = geom;\n\t\t\tframe->w = presentation->SourceWidth;\n\t\t\tframe->h = presentation->SourceHeight;\n\n\t\t\tframe->surfaceData = BufferPool_Take(priv->surfacePool, frame->w * frame->h * 4);\n\t\t\tif (!frame->surfaceData)\n\t\t\t{\n\t\t\t\tWLog_ERR(TAG, \"unable to allocate frame data\");\n\t\t\t\tmappedGeometryUnref(geom);\n\t\t\t\tfree(frame);\n\t\t\t\treturn CHANNEL_RC_NO_MEMORY;\n\t\t\t}\n\n\t\t\tif (!yuv_to_rgb(presentation, frame->surfaceData))\n\t\t\t{\n\t\t\t\tWLog_ERR(TAG, \"error during YUV->RGB conversion\");\n\t\t\t\tBufferPool_Return(priv->surfacePool, frame->surfaceData);\n\t\t\t\tmappedGeometryUnref(geom);\n\t\t\t\tfree(frame);\n\t\t\t\treturn CHANNEL_RC_NO_MEMORY;\n\t\t\t}\n\n\t\t\tInterlockedIncrement(&presentation->refCounter);\n\n\t\t\tEnterCriticalSection(&priv->framesLock);\n\t\t\tenqueueResult = Queue_Enqueue(priv->frames, frame);\n\t\t\tLeaveCriticalSection(&priv->framesLock);\n\n\t\t\tif (!enqueueResult)\n\t\t\t{\n\t\t\t\tWLog_ERR(TAG, \"unable to enqueue frame\");\n\t\t\t\tVideoFrame_free(&frame);\n\t\t\t\treturn CHANNEL_RC_NO_MEMORY;\n\t\t\t}\n\n\t\t\tWLog_DBG(TAG, \"scheduling frame in %\" PRIu32 \" ms\", (frame->publishTime - startTime));\n\t\t}\n\t}\n\n\treturn CHANNEL_RC_OK;\n}","target":0,"code_token_length":987,"total_token_length":1223,"max_tokens_setting":2048}
+{"idx":215992,"func":"load_image (const gchar  *filename,\n            GError      **error)\n{\n  FILE     *fp;\n  tga_info  info;\n  guchar    header[18];\n  guchar    footer[26];\n  guchar    extension[495];\n  long      offset;\n  gint32    image_ID = -1;\n\n  gimp_progress_init_printf (_(\"Opening '%s'\"),\n                             gimp_filename_to_utf8 (filename));\n\n  fp = g_fopen (filename, \"rb\");\n\n  if (! fp)\n    {\n      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),\n                   _(\"Could not open '%s' for reading: %s\"),\n                   gimp_filename_to_utf8 (filename), g_strerror (errno));\n      return -1;\n    }\n\n  \/* Is file big enough for a footer? *\/\n  if (!fseek (fp, -26L, SEEK_END))\n    {\n      if (fread (footer, sizeof (footer), 1, fp) != 1)\n        {\n          g_message (_(\"Cannot read footer from '%s'\"),\n                     gimp_filename_to_utf8 (filename));\n          return -1;\n        }\n      else if (memcmp (footer + 8, magic, sizeof (magic)) == 0)\n        {\n          \/* Check the signature. *\/\n\n          offset = (footer[0]          +\n                    footer[1] * 256L   +\n                    footer[2] * 65536L +\n                    footer[3] * 16777216L);\n\n          if (offset != 0)\n            {\n              if (fseek (fp, offset, SEEK_SET) ||\n                  fread (extension, sizeof (extension), 1, fp) != 1)\n                {\n                  g_message (_(\"Cannot read extension from '%s'\"),\n                             gimp_filename_to_utf8 (filename));\n                  return -1;\n                }\n              \/* Eventually actually handle version 2 TGA here *\/\n            }\n        }\n    }\n\n  if (fseek (fp, 0, SEEK_SET) ||\n      fread (header, sizeof (header), 1, fp) != 1)\n    {\n      g_message (_(\"Cannot read header from '%s'\"),\n                 gimp_filename_to_utf8 (filename));\n      return -1;\n    }\n\n  switch (header[2])\n    {\n    case 1:\n      info.imageType        = TGA_TYPE_MAPPED;\n      info.imageCompression = TGA_COMP_NONE;\n      break;\n    case 2:\n      info.imageType        = TGA_TYPE_COLOR;\n      info.imageCompression = TGA_COMP_NONE;\n      break;\n    case 3:\n      info.imageType        = TGA_TYPE_GRAY;\n      info.imageCompression = TGA_COMP_NONE;\n      break;\n\n    case 9:\n      info.imageType        = TGA_TYPE_MAPPED;\n      info.imageCompression = TGA_COMP_RLE;\n      break;\n    case 10:\n      info.imageType        = TGA_TYPE_COLOR;\n      info.imageCompression = TGA_COMP_RLE;\n      break;\n    case 11:\n      info.imageType        = TGA_TYPE_GRAY;\n      info.imageCompression = TGA_COMP_RLE;\n      break;\n\n    default:\n      info.imageType = 0;\n    }\n\n  info.idLength     = header[0];\n  info.colorMapType = header[1];\n\n  info.colorMapIndex  = header[3] + header[4] * 256;\n  info.colorMapLength = header[5] + header[6] * 256;\n  info.colorMapSize   = header[7];\n\n  info.xOrigin = header[8]  + header[9] * 256;\n  info.yOrigin = header[10] + header[11] * 256;\n  info.width   = header[12] + header[13] * 256;\n  info.height  = header[14] + header[15] * 256;\n\n  info.bpp       = header[16];\n  info.bytes     = (info.bpp + 7) \/ 8;\n  info.alphaBits = header[17] & 0x0f; \/* Just the low 4 bits *\/\n  info.flipHoriz = (header[17] & 0x10) ? 1 : 0;\n  info.flipVert  = (header[17] & 0x20) ? 0 : 1;\n\n  \/* hack to handle some existing files with incorrect headers, see bug #306675 *\/\n  if (info.alphaBits == info.bpp)\n    info.alphaBits = 0;\n\n  \/* hack to handle yet another flavor of incorrect headers, see bug #540969 *\/\n  if (info.alphaBits == 0)\n    {\n      if (info.imageType == TGA_TYPE_COLOR && info.bpp == 32)\n        info.alphaBits = 8;\n\n      if (info.imageType == TGA_TYPE_GRAY && info.bpp == 16)\n        info.alphaBits = 8;\n    }\n\n  switch (info.imageType)\n    {\n      case TGA_TYPE_MAPPED:\n        if (info.bpp != 8)\n          {\n            g_message (\"Unhandled sub-format in '%s' (type = %u, bpp = %u)\",\n                       gimp_filename_to_utf8 (filename),\n                       info.imageType, info.bpp);\n            return -1;\n          }\n        break;\n      case TGA_TYPE_COLOR:\n        if (info.bpp != 15 && info.bpp != 16 &&\n            info.bpp != 24 && info.bpp != 32)\n          {\n            g_message (\"Unhandled sub-format in '%s' (type = %u, bpp = %u)\",\n                       gimp_filename_to_utf8 (filename),\n                       info.imageType, info.bpp);\n            return -1;\n          }\n        break;\n      case TGA_TYPE_GRAY:\n        if (info.bpp != 8 &&\n            (info.alphaBits != 8 || (info.bpp != 16 && info.bpp != 15)))\n          {\n            g_message (\"Unhandled sub-format in '%s' (type = %u, bpp = %u)\",\n                       gimp_filename_to_utf8 (filename),\n                       info.imageType, info.bpp);\n            return -1;\n          }\n        break;\n\n      default:\n        g_message (\"Unknown image type %u for '%s'\",\n                   info.imageType, gimp_filename_to_utf8 (filename));\n        return -1;\n    }\n\n  \/* Plausible but unhandled formats *\/\n  if (info.bytes * 8 != info.bpp && info.bpp != 15)\n    {\n      g_message (\"Unhandled sub-format in '%s' (type = %u, bpp = %u)\",\n                 gimp_filename_to_utf8 (filename),\n                 info.imageType, info.bpp);\n      return -1;\n    }\n\n  \/* Check that we have a color map only when we need it. *\/\n  if (info.imageType == TGA_TYPE_MAPPED && info.colorMapType != 1)\n    {\n      g_message (\"Indexed image has invalid color map type %u\",\n                 info.colorMapType);\n      return -1;\n    }\n  else if (info.imageType != TGA_TYPE_MAPPED && info.colorMapType != 0)\n    {\n      g_message (\"Non-indexed image has invalid color map type %u\",\n                 info.colorMapType);\n      return -1;\n    }\n\n  \/* Skip the image ID field. *\/\n  if (info.idLength && fseek (fp, info.idLength, SEEK_CUR))\n    {\n      g_message (\"File '%s' is truncated or corrupted\",\n                 gimp_filename_to_utf8 (filename));\n      return -1;\n    }\n\n  image_ID = ReadImage (fp, &info, filename);\n\n  fclose (fp);\n\n  return image_ID;\n}","target":1,"code_token_length":1688,"total_token_length":1924,"max_tokens_setting":2048}
+{"idx":383322,"func":"gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)\n{\n\tint c;\n\tint x, y;\n\tint tox, toy;\n\tint ydest;\n\tint i;\n\tint colorMap[gdMaxColors];\n\t\/* Stretch vectors *\/\n\tint *stx, *sty;\n\t\/* We only need to use floating point to determine the correct stretch vector for one line's worth. *\/\n\tdouble accum;\n\tstx = (int *) gdMalloc (sizeof (int) * srcW);\n\tsty = (int *) gdMalloc (sizeof (int) * srcH);\n\taccum = 0;\n\t\n\tfor (i = 0; (i < srcW); i++) {\n\t\tint got;\n\t\taccum += (double) dstW \/ (double) srcW;\n\t\tgot = (int) floor (accum);\n\t\tstx[i] = got;\n\t\taccum -= got;\n\t}\n\taccum = 0;\n\tfor (i = 0; (i < srcH); i++) {\n\t\tint got;\n\t\taccum += (double) dstH \/ (double) srcH;\n\t\tgot = (int) floor (accum);\n\t\tsty[i] = got;\n\t\taccum -= got;\n\t}\n\tfor (i = 0; (i < gdMaxColors); i++) {\n\t\tcolorMap[i] = (-1);\n\t}\n\ttoy = dstY;\n\tfor (y = srcY; (y < (srcY + srcH)); y++) {\n\t\tfor (ydest = 0; (ydest < sty[y - srcY]); ydest++) {\n\t\t\ttox = dstX;\n\t\t\tfor (x = srcX; (x < (srcX + srcW)); x++) {\n\t\t\t\tint nc = 0;\n\t\t\t\tint mapTo;\n\t\t\t\tif (!stx[x - srcX]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (dst->trueColor) {\n\t\t\t\t\t\/* 2.0.9: Thorben Kundinger: Maybe the source image is not a truecolor image *\/\n\t\t\t\t\tif (!src->trueColor) {\n\t\t\t\t\t  \tint tmp = gdImageGetPixel (src, x, y);\n\t\t  \t\t\t\tmapTo = gdImageGetTrueColorPixel (src, x, y);\n\t\t\t\t\t  \tif (gdImageGetTransparent (src) == tmp) {\n\t\t\t\t\t  \t\ttox++;\n\t\t\t\t\t  \t\tcontinue;\n\t\t\t\t\t  \t}\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/* TK: old code follows *\/\n\t\t\t\t\t  \tmapTo = gdImageGetTrueColorPixel (src, x, y);\n\t\t\t\t\t\t\/* Added 7\/24\/95: support transparent copies *\/\n\t\t\t\t\t\tif (gdImageGetTransparent (src) == mapTo) {\n\t\t\t\t\t\t\ttox++;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\t\n\t\t\t\t} else {\n\t\t\t\t\tc = gdImageGetPixel (src, x, y);\n\t\t\t\t\t\/* Added 7\/24\/95: support transparent copies *\/\n\t\t\t\t\tif (gdImageGetTransparent (src) == c) {\n\t\t\t\t\t      tox += stx[x - srcX];\n\t\t\t\t\t      continue;\n\t\t\t\t\t}\n\t\t\t\t\tif (src->trueColor) {\n\t\t\t\t\t      \/* Remap to the palette available in the destination image. This is slow and works badly. *\/\n\t\t\t\t\t      mapTo = gdImageColorResolveAlpha(dst, gdTrueColorGetRed(c),\n\t\t\t\t\t      \t\t\t\t\t    gdTrueColorGetGreen(c),\n\t\t\t\t\t      \t\t\t\t\t    gdTrueColorGetBlue(c),\n\t\t\t\t\t      \t\t\t\t\t    gdTrueColorGetAlpha (c));\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/* Have we established a mapping for this color? *\/\n\t\t\t\t\t\tif (colorMap[c] == (-1)) {\n\t\t\t\t\t\t\t\/* If it's the same image, mapping is trivial *\/\n\t\t\t\t\t\t\tif (dst == src) {\n\t\t\t\t\t\t\t\tnc = c;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\/* Find or create the best match *\/\n\t\t\t\t\t\t\t\t\/* 2.0.5: can't use gdTrueColorGetRed, etc with palette *\/\n\t\t\t\t\t\t\t\tnc = gdImageColorResolveAlpha(dst, gdImageRed(src, c),\n\t\t\t\t\t\t\t\t\t\t\t\t   gdImageGreen(src, c),\n\t\t\t\t\t\t\t\t\t\t\t\t   gdImageBlue(src, c),\n\t\t\t\t\t\t\t\t\t\t\t\t   gdImageAlpha(src, c));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcolorMap[c] = nc;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmapTo = colorMap[c];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (i = 0; (i < stx[x - srcX]); i++) {\n\t\t\t\t\tgdImageSetPixel (dst, tox, toy, mapTo);\n\t\t\t\t\ttox++;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoy++;\n\t\t}\n\t}\n\tgdFree (stx);\n\tgdFree (sty);\n}","target":0,"code_token_length":984,"total_token_length":1220,"max_tokens_setting":2048}
+{"idx":505463,"func":"static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,\n                                  void *ptr)\n{\n    EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);\n\n    switch(type) {\n    case EVP_CTRL_INIT:\n        if (actx == NULL)\n            actx = ctx->cipher_data\n                 = OPENSSL_zalloc(sizeof(*actx) + Poly1305_ctx_size());\n        if (actx == NULL) {\n            EVPerr(EVP_F_CHACHA20_POLY1305_CTRL, EVP_R_INITIALIZATION_ERROR);\n            return 0;\n        }\n        actx->len.aad = 0;\n        actx->len.text = 0;\n        actx->aad = 0;\n        actx->mac_inited = 0;\n        actx->tag_len = 0;\n        actx->nonce_len = 12;\n        actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;\n        memset(actx->tls_aad, 0, POLY1305_BLOCK_SIZE);\n        return 1;\n\n    case EVP_CTRL_COPY:\n        if (actx) {\n            EVP_CIPHER_CTX *dst = (EVP_CIPHER_CTX *)ptr;\n\n            dst->cipher_data =\n                   OPENSSL_memdup(actx, sizeof(*actx) + Poly1305_ctx_size());\n            if (dst->cipher_data == NULL) {\n                EVPerr(EVP_F_CHACHA20_POLY1305_CTRL, EVP_R_COPY_ERROR);\n                return 0;\n            }\n        }\n        return 1;\n\n    case EVP_CTRL_AEAD_SET_IVLEN:\n        if (arg <= 0 || arg > CHACHA20_POLY1305_MAX_IVLEN)\n            return 0;\n        actx->nonce_len = arg;\n        return 1;\n\n    case EVP_CTRL_AEAD_SET_IV_FIXED:\n        if (arg != 12)\n            return 0;\n        actx->nonce[0] = actx->key.counter[1]\n                       = CHACHA_U8TOU32((unsigned char *)ptr);\n        actx->nonce[1] = actx->key.counter[2]\n                       = CHACHA_U8TOU32((unsigned char *)ptr+4);\n        actx->nonce[2] = actx->key.counter[3]\n                       = CHACHA_U8TOU32((unsigned char *)ptr+8);\n        return 1;\n\n    case EVP_CTRL_AEAD_SET_TAG:\n        if (arg <= 0 || arg > POLY1305_BLOCK_SIZE)\n            return 0;\n        if (ptr != NULL) {\n            memcpy(actx->tag, ptr, arg);\n            actx->tag_len = arg;\n        }\n        return 1;\n\n    case EVP_CTRL_AEAD_GET_TAG:\n        if (arg <= 0 || arg > POLY1305_BLOCK_SIZE || !ctx->encrypt)\n            return 0;\n        memcpy(ptr, actx->tag, arg);\n        return 1;\n\n    case EVP_CTRL_AEAD_TLS1_AAD:\n        if (arg != EVP_AEAD_TLS1_AAD_LEN)\n            return 0;\n        {\n            unsigned int len;\n            unsigned char *aad = ptr;\n\n            memcpy(actx->tls_aad, ptr, EVP_AEAD_TLS1_AAD_LEN);\n            len = aad[EVP_AEAD_TLS1_AAD_LEN - 2] << 8 |\n                  aad[EVP_AEAD_TLS1_AAD_LEN - 1];\n            aad = actx->tls_aad;\n            if (!ctx->encrypt) {\n                if (len < POLY1305_BLOCK_SIZE)\n                    return 0;\n                len -= POLY1305_BLOCK_SIZE;     \/* discount attached tag *\/\n                aad[EVP_AEAD_TLS1_AAD_LEN - 2] = (unsigned char)(len >> 8);\n                aad[EVP_AEAD_TLS1_AAD_LEN - 1] = (unsigned char)len;\n            }\n            actx->tls_payload_length = len;\n\n            \/*\n             * merge record sequence number as per RFC7905\n             *\/\n            actx->key.counter[1] = actx->nonce[0];\n            actx->key.counter[2] = actx->nonce[1] ^ CHACHA_U8TOU32(aad);\n            actx->key.counter[3] = actx->nonce[2] ^ CHACHA_U8TOU32(aad+4);\n            actx->mac_inited = 0;\n\n            return POLY1305_BLOCK_SIZE;         \/* tag length *\/\n        }\n\n    case EVP_CTRL_AEAD_SET_MAC_KEY:\n        \/* no-op *\/\n        return 1;\n\n    default:\n        return -1;\n    }\n}","target":0,"code_token_length":1044,"total_token_length":1280,"max_tokens_setting":2048}
+{"idx":508401,"func":"bool close_cached_tables(THD *thd, TABLE_LIST *tables,\n                         bool wait_for_refresh, ulong timeout)\n{\n  bool result= FALSE;\n  struct timespec abstime;\n  tdc_version_t refresh_version;\n  DBUG_ENTER(\"close_cached_tables\");\n  DBUG_ASSERT(thd || (!wait_for_refresh && !tables));\n\n  refresh_version= tdc_increment_refresh_version();\n\n  if (!tables)\n  {\n    \/*\n      Force close of all open tables.\n\n      Note that code in TABLE_SHARE::wait_for_old_version() assumes that\n      incrementing of refresh_version is followed by purge of unused table\n      shares.\n    *\/\n    kill_delayed_threads();\n    \/*\n      Get rid of all unused TABLE and TABLE_SHARE instances. By doing\n      this we automatically close all tables which were marked as \"old\".\n    *\/\n    tc_purge(true);\n    \/* Free table shares which were not freed implicitly by loop above. *\/\n    tdc_purge(true);\n  }\n  else\n  {\n    bool found=0;\n    for (TABLE_LIST *table= tables; table; table= table->next_local)\n    {\n      \/* tdc_remove_table() also sets TABLE_SHARE::version to 0. *\/\n      found|= tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table->db,\n                               table->table_name, TRUE);\n    }\n    if (!found)\n      wait_for_refresh=0;\t\t\t\/\/ Nothing to wait for\n  }\n\n  DBUG_PRINT(\"info\", (\"open table definitions: %d\",\n                      (int) tdc_records()));\n\n  if (!wait_for_refresh)\n    DBUG_RETURN(result);\n\n  if (thd->locked_tables_mode)\n  {\n    \/*\n      If we are under LOCK TABLES, we need to reopen the tables without\n      opening a door for any concurrent threads to sneak in and get\n      lock on our tables. To achieve this we use exclusive metadata\n      locks.\n    *\/\n    TABLE_LIST *tables_to_reopen= (tables ? tables :\n                                  thd->locked_tables_list.locked_tables());\n\n    \/* Close open HANDLER instances to avoid self-deadlock. *\/\n    mysql_ha_flush_tables(thd, tables_to_reopen);\n\n    for (TABLE_LIST *table_list= tables_to_reopen; table_list;\n         table_list= table_list->next_global)\n    {\n      int err;\n      \/* A check that the table was locked for write is done by the caller. *\/\n      TABLE *table= find_table_for_mdl_upgrade(thd, table_list->db,\n                                               table_list->table_name, &err);\n\n      \/* May return NULL if this table has already been closed via an alias. *\/\n      if (! table)\n        continue;\n\n      if (wait_while_table_is_used(thd, table,\n                                   HA_EXTRA_PREPARE_FOR_FORCED_CLOSE))\n      {\n        result= TRUE;\n        goto err_with_reopen;\n      }\n      close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL);\n    }\n  }\n\n  \/* Wait until all threads have closed all the tables we are flushing. *\/\n  DBUG_PRINT(\"info\", (\"Waiting for other threads to close their open tables\"));\n\n  \/*\n    To a self-deadlock or deadlocks with other FLUSH threads\n    waiting on our open HANDLERs, we have to flush them.\n  *\/\n  mysql_ha_flush(thd);\n  DEBUG_SYNC(thd, \"after_flush_unlock\");\n\n  if (!tables)\n  {\n    int r= 0;\n    close_cached_tables_arg argument;\n    argument.refresh_version= refresh_version;\n    set_timespec(abstime, timeout);\n\n    while (!thd->killed &&\n           (r= tdc_iterate(thd,\n                           (my_hash_walk_action) close_cached_tables_callback,\n                           &argument)) == 1 &&\n           !argument.element->share->wait_for_old_version(thd, &abstime,\n                                    MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL))\n      \/* no-op *\/;\n\n    if (r)\n      result= TRUE;\n  }\n  else\n  {\n    for (TABLE_LIST *table= tables; table; table= table->next_local)\n    {\n      if (thd->killed)\n        break;\n      if (tdc_wait_for_old_version(thd, table->db, table->table_name, timeout,\n                                   MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL,\n                                   refresh_version))\n      {\n        result= TRUE;\n        break;\n      }\n    }\n  }\n\nerr_with_reopen:\n  if (thd->locked_tables_mode)\n  {\n    \/*\n      No other thread has the locked tables open; reopen them and get the\n      old locks. This should always succeed (unless some external process\n      has removed the tables)\n    *\/\n    if (thd->locked_tables_list.reopen_tables(thd, false))\n      result= true;\n    \/*\n      Since downgrade_lock() won't do anything with shared\n      metadata lock it is much simpler to go through all open tables rather\n      than picking only those tables that were flushed.\n    *\/\n    for (TABLE *tab= thd->open_tables; tab; tab= tab->next)\n      tab->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);\n  }\n  DBUG_RETURN(result);\n}","target":0,"code_token_length":1105,"total_token_length":1341,"max_tokens_setting":2048}
+{"idx":336517,"func":"void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m)\n{\n    SpiceMigrateDataMain mig_data;\n    RedCharDeviceVDIPort *agent_dev = reds->agent_dev.get();\n    SpiceMarshaller *m2;\n\n    memset(&mig_data, 0, sizeof(mig_data));\n    spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_MAIN_MAGIC);\n    spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_MAIN_VERSION);\n\n    if (!reds->vdagent) {\n        uint8_t *null_agent_mig_data;\n\n        \/* MSG_AGENT_CONNECTED_TOKENS is supported by the client\n           (see spice_server_migrate_connect), so agent_attached\n           is set to FALSE when the agent is disconnected and\n           there is no need to track the client tokens\n           (see reds_reset_vdp) *\/\n        spice_assert(!agent_dev->priv->agent_attached);\n        RedCharDevice::migrate_data_marshall_empty(m);\n        size_t padding_len = sizeof(SpiceMigrateDataMain) - sizeof(SpiceMigrateDataCharDevice);\n        null_agent_mig_data = spice_marshaller_reserve_space(m, padding_len);\n        memset(null_agent_mig_data, 0, padding_len);\n        return;\n    }\n\n    agent_dev->migrate_data_marshall(m);\n    spice_marshaller_add_uint8(m, agent_dev->priv->client_agent_started);\n\n    mig_data.agent2client.chunk_header = agent_dev->priv->vdi_chunk_header;\n\n    \/* agent to client partial msg *\/\n    if (agent_dev->priv->read_state == VDI_PORT_READ_STATE_READ_HEADER) {\n        mig_data.agent2client.chunk_header_size = agent_dev->priv->receive_pos -\n            (uint8_t *)&agent_dev->priv->vdi_chunk_header;\n\n        mig_data.agent2client.msg_header_done = FALSE;\n        mig_data.agent2client.msg_header_partial_len = 0;\n        spice_assert(!agent_dev->priv->read_filter.msg_data_to_read);\n    } else {\n        mig_data.agent2client.chunk_header_size = sizeof(VDIChunkHeader);\n        mig_data.agent2client.chunk_header.size = agent_dev->priv->message_receive_len;\n        if (agent_dev->priv->read_state == VDI_PORT_READ_STATE_READ_DATA) {\n            \/* in the middle of reading the message header (see reds_on_main_channel_migrate) *\/\n            mig_data.agent2client.msg_header_done = FALSE;\n            mig_data.agent2client.msg_header_partial_len =\n                agent_dev->priv->receive_pos - agent_dev->priv->current_read_buf->data;\n            spice_assert(mig_data.agent2client.msg_header_partial_len < sizeof(VDAgentMessage));\n            spice_assert(!agent_dev->priv->read_filter.msg_data_to_read);\n        } else {\n            mig_data.agent2client.msg_header_done =  TRUE;\n            mig_data.agent2client.msg_remaining = agent_dev->priv->read_filter.msg_data_to_read;\n            mig_data.agent2client.msg_filter_result = agent_dev->priv->read_filter.result;\n        }\n    }\n    spice_marshaller_add_uint32(m, mig_data.agent2client.chunk_header_size);\n    spice_marshaller_add(m,\n                         (uint8_t *)&mig_data.agent2client.chunk_header,\n                         sizeof(VDIChunkHeader));\n    spice_marshaller_add_uint8(m, mig_data.agent2client.msg_header_done);\n    spice_marshaller_add_uint32(m, mig_data.agent2client.msg_header_partial_len);\n    m2 = spice_marshaller_get_ptr_submarshaller(m);\n    spice_marshaller_add(m2, agent_dev->priv->current_read_buf->data,\n                         mig_data.agent2client.msg_header_partial_len);\n    spice_marshaller_add_uint32(m, mig_data.agent2client.msg_remaining);\n    spice_marshaller_add_uint8(m, mig_data.agent2client.msg_filter_result);\n\n    mig_data.client2agent.msg_remaining = agent_dev->priv->write_filter.msg_data_to_read;\n    mig_data.client2agent.msg_filter_result = agent_dev->priv->write_filter.result;\n    spice_marshaller_add_uint32(m, mig_data.client2agent.msg_remaining);\n    spice_marshaller_add_uint8(m, mig_data.client2agent.msg_filter_result);\n    spice_debug(\"from agent filter: discard all %d, wait_msg %u, msg_filter_result %d\",\n                agent_dev->priv->read_filter.discard_all,\n                agent_dev->priv->read_filter.msg_data_to_read,\n                agent_dev->priv->read_filter.result);\n    spice_debug(\"to agent filter: discard all %d, wait_msg %u, msg_filter_result %d\",\n                agent_dev->priv->write_filter.discard_all,\n                agent_dev->priv->write_filter.msg_data_to_read,\n                agent_dev->priv->write_filter.result);\n}","target":0,"code_token_length":1018,"total_token_length":1254,"max_tokens_setting":2048}
+{"idx":234876,"func":"static int read_user_chunk_callback(png_struct *ping, png_unknown_chunkp chunk)\n{\n  Image\n    *image;\n\n\n  \/* The unknown chunk structure contains the chunk data:\n     png_byte name[5];\n     png_byte *data;\n     png_size_t size;\n\n     Note that libpng has already taken care of the CRC handling.\n\n     Returns one of the following:\n         return(-n);  chunk had an error\n         return(0);  did not recognize\n         return(n);  success\n  *\/\n\n  (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n     \"    read_user_chunk: found %c%c%c%c chunk\",\n       chunk->name[0],chunk->name[1],chunk->name[2],chunk->name[3]);\n\n  if (chunk->name[0]  == 101 &&\n      (chunk->name[1] ==  88 || chunk->name[1] == 120 ) &&\n      chunk->name[2] ==   73 &&\n      chunk-> name[3] == 102)\n    {\n      \/* process eXIf or exIf chunk *\/\n\n      PNGErrorInfo\n        *error_info;\n\n      StringInfo\n        *profile;\n\n      unsigned char\n        *p;\n\n      png_byte\n        *s;\n\n      size_t\n        i;\n\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \" recognized eXIf|exIf chunk\");\n\n      image=(Image *) png_get_user_chunk_ptr(ping);\n\n      error_info=(PNGErrorInfo *) png_get_error_ptr(ping);\n\n      profile=BlobToStringInfo((const void *) NULL,chunk->size+6);\n\n      if (profile == (StringInfo *) NULL)\n        {\n          (void) ThrowMagickException(error_info->exception,GetMagickModule(),\n            ResourceLimitError,\"MemoryAllocationFailed\",\"`%s'\",\n            image->filename);\n          return(-1);\n        }\n      p=GetStringInfoDatum(profile);\n\n      if (*p != 'E')\n        {\n          \/* Initialize profile with \"Exif\\0\\0\" if it is not\n             already present by accident\n          *\/\n          *p++ ='E';\n          *p++ ='x';\n          *p++ ='i';\n          *p++ ='f';\n          *p++ ='\\0';\n          *p++ ='\\0';\n        }\n      else\n        {\n          if (p[1] != 'x' || p[2] != 'i' || p[3] != 'f' ||\n              p[4] != '\\0' || p[5] != '\\0')\n            {\n              \/* Chunk is malformed *\/\n              profile=DestroyStringInfo(profile);\n              return(-1);\n            }\n         }\n\n      \/* copy chunk->data to profile *\/\n      s=chunk->data;\n      for (i=0; i<chunk->size; i++)\n        *p++ = *s++;\n\n      error_info=(PNGErrorInfo *) png_get_error_ptr(ping);\n      (void) SetImageProfile(image,\"exif\",profile,\n        error_info->exception);\n\n      profile=DestroyStringInfo(profile);\n\n      return(1);\n    }\n\n  \/* vpAg (deprecated, replaced by caNv) *\/\n  if (chunk->name[0] == 118 &&\n      chunk->name[1] == 112 &&\n      chunk->name[2] ==  65 &&\n      chunk->name[3] == 103)\n    {\n      \/* recognized vpAg *\/\n\n      if (chunk->size != 9)\n        return(-1); \/* Error return *\/\n\n      if (chunk->data[8] != 0)\n        return(0);  \/* ImageMagick requires pixel units *\/\n\n      image=(Image *) png_get_user_chunk_ptr(ping);\n\n      image->page.width=(size_t) ((chunk->data[0] << 24) |\n         (chunk->data[1] << 16) | (chunk->data[2] << 8) | chunk->data[3]);\n\n      image->page.height=(size_t) ((chunk->data[4] << 24) |\n         (chunk->data[5] << 16) | (chunk->data[6] << 8) | chunk->data[7]);\n\n      return(1);\n    }\n\n  \/* caNv *\/\n  if (chunk->name[0] ==  99 &&\n      chunk->name[1] ==  97 &&\n      chunk->name[2] ==  78 &&\n      chunk->name[3] == 118)\n    {\n      \/* recognized caNv *\/\n\n      if (chunk->size != 16)\n        return(-1); \/* Error return *\/\n\n      image=(Image *) png_get_user_chunk_ptr(ping);\n\n      image->page.width=(size_t) ((chunk->data[0] << 24) |\n         (chunk->data[1] << 16) | (chunk->data[2] << 8) | chunk->data[3]);\n\n      image->page.height=(size_t) ((chunk->data[4] << 24) |\n         (chunk->data[5] << 16) | (chunk->data[6] << 8) | chunk->data[7]);\n\n      image->page.x=(size_t) ((chunk->data[8] << 24) |\n         (chunk->data[9] << 16) | (chunk->data[10] << 8) | chunk->data[11]);\n\n      image->page.y=(size_t) ((chunk->data[12] << 24) |\n         (chunk->data[13] << 16) | (chunk->data[14] << 8) | chunk->data[15]);\n\n      return(1);\n    }\n\n  return(0); \/* Did not recognize *\/\n}","target":0,"code_token_length":1265,"total_token_length":1501,"max_tokens_setting":2048}
+{"idx":246646,"func":"static void naludmx_finalize_au_flags(GF_NALUDmxCtx *ctx)\n{\n\tu64 ts;\n\tBool is_rap = GF_FALSE;\n\n\tif (!ctx->first_pck_in_au)\n\t\treturn;\n\tif (ctx->au_sap) {\n\t\tgf_filter_pck_set_sap(ctx->first_pck_in_au, ctx->au_sap);\n\t\tif ((ctx->au_sap == GF_FILTER_SAP_1) || ctx->au_sap2_poc_reset) {\n\t\t\tctx->dts_last_IDR = gf_filter_pck_get_dts(ctx->first_pck_in_au);\n\t\t\tif (ctx->is_paff)\n\t\t\t\tctx->dts_last_IDR *= 2;\n\t\t}\n\t\tif (ctx->au_sap <= GF_FILTER_SAP_3) {\n\t\t\tis_rap = GF_TRUE;\n\t\t}\n\t}\n\telse if (ctx->has_islice && ctx->force_sync && (ctx->sei_recovery_frame_count==0)) {\n\t\tgf_filter_pck_set_sap(ctx->first_pck_in_au, GF_FILTER_SAP_1);\n\t\tif (!ctx->use_opengop_gdr) {\n\t\t\tctx->use_opengop_gdr = 1;\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_MEDIA, (\"[%s] Forcing non-IDR samples with I slices to be marked as sync points - resulting file will not be ISOBMFF compliant\\n\", ctx->log_name));\n\t\t}\n\t\tis_rap = GF_TRUE;\n\t}\n\t\/*set roll info sampleGroups info*\/\n\telse if (!ctx->au_sap && ( (ctx->sei_recovery_frame_count >= 0) || ctx->has_islice) ) {\n\t\t\/*generic GDR*\/\n\t\tif (ctx->sei_recovery_frame_count > 0) {\n\t\t\tif (!ctx->use_opengop_gdr) ctx->use_opengop_gdr = 1;\n\t\t\tgf_filter_pck_set_sap(ctx->first_pck_in_au, GF_FILTER_SAP_4);\n\t\t\tgf_filter_pck_set_roll_info(ctx->first_pck_in_au, ctx->sei_recovery_frame_count);\n\t\t}\n\t\t\/*open-GOP*\/\n\t\telse if ((ctx->sei_recovery_frame_count == 0) && ctx->has_islice) {\n\t\t\tif (!ctx->use_opengop_gdr) ctx->use_opengop_gdr = 2;\n\t\t\tgf_filter_pck_set_sap(ctx->first_pck_in_au, GF_FILTER_SAP_3);\n\t\t\tis_rap = GF_TRUE;\n\t\t}\n\t}\n\tif (ctx->is_paff) {\n\t\tgf_filter_pck_set_interlaced(ctx->first_pck_in_au, ctx->bottom_field_flag ? 2 : 1);\n\t}\n\n\t\/\/if TS is set, the packet was the first in AU in the input timed packet (eg PES), we reuse the input timing\n\tts = gf_filter_pck_get_cts(ctx->first_pck_in_au);\n\tif (ts == GF_FILTER_NO_TS) {\n\t\t\/*we store the POC (last POC minus the poc shift) as the CTS offset and re-update the CTS when dispatching*\/\n\t\tassert(ctx->last_poc >= ctx->poc_shift);\n\t\tgf_filter_pck_set_cts(ctx->first_pck_in_au, CTS_POC_OFFSET_SAFETY + ctx->last_poc - ctx->poc_shift);\n\t\t\/\/we use the carousel flag temporarly to indicate the cts must be recomputed\n\t\tgf_filter_pck_set_carousel_version(ctx->first_pck_in_au, 1);\n\t}\n\n\tif (ctx->subsamp_buffer_size) {\n\t\tgf_filter_pck_set_property(ctx->first_pck_in_au, GF_PROP_PCK_SUBS, &PROP_DATA(ctx->subsamp_buffer, ctx->subsamp_buffer_size) );\n\t\tctx->subsamp_buffer_size = 0;\n\t\tctx->subs_mapped_bytes = 0;\n\t}\n\tif (ctx->deps) {\n\t\tu8 flags = 0;\n\t\t\/\/dependsOn\n\t\tflags = (is_rap) ? 2 : 1;\n\t\tflags <<= 2;\n\t\t\/\/dependedOn\n\t \tflags |= ctx->has_ref_slices ? 1 : 2;\n\t\tflags <<= 2;\n\t\t\/\/hasRedundant\n\t \tflags |= ctx->has_redundant ? 1 : 2;\n\t \tgf_filter_pck_set_dependency_flags(ctx->first_pck_in_au, flags);\n\t}\n\tctx->has_ref_slices = GF_FALSE;\n\tctx->has_redundant = GF_FALSE;\n\n\tif ((ctx->hevc_state && ctx->hevc_state->clli_valid)\n\t\t|| (ctx->vvc_state && ctx->vvc_state->clli_valid)\n\t) {\n\t\tu8 *clli = ctx->hevc_state ? ctx->hevc_state->clli_data : ctx->vvc_state->clli_data;\n\t\tu32 crc = gf_crc_32(clli, 4);\n\t\tif (!ctx->clli_crc) {\n\t\t\tnaludmx_update_clli_mdcv(ctx, GF_FALSE);\n\t\t}\n\n\t\tif (crc != ctx->clli_crc) {\n\t\t\tgf_filter_pck_set_property(ctx->first_pck_in_au, GF_PROP_PID_CONTENT_LIGHT_LEVEL, &PROP_DATA(clli, 4));\n\t\t}\n\t}\n\tif ((ctx->hevc_state && ctx->hevc_state->mdcv_valid)\n\t\t|| (ctx->vvc_state && ctx->vvc_state->mdcv_valid)\n\t) {\n\t\tu8 *mdcv = ctx->hevc_state ? ctx->hevc_state->mdcv_data : ctx->vvc_state->mdcv_data;\n\t\tu32 crc = gf_crc_32(mdcv, 24);\n\t\tif (!ctx->mdcv_crc) {\n\t\t\tnaludmx_update_clli_mdcv(ctx, GF_FALSE);\n\t\t}\n\t\tif (crc != ctx->mdcv_crc) {\n\t\t\tgf_filter_pck_set_property(ctx->first_pck_in_au, GF_PROP_PID_MASTER_DISPLAY_COLOUR, &PROP_DATA(mdcv, 24));\n\t\t}\n\t}\n\tif (ctx->hevc_state)\n\t\tctx->hevc_state->clli_valid = ctx->hevc_state->mdcv_valid = 0;\n\tif (ctx->vvc_state)\n\t\tctx->vvc_state->clli_valid = ctx->vvc_state->mdcv_valid = 0;\n\n\n\t\/\/if we reuse input packets timing, we can dispatch asap.\n\t\/\/otherwise if poc probe is done (we know the min_poc_diff between images) and we are not in strict mode, dispatch asap\n\t\/\/otherwise we will need to wait for the next ref frame to make sure we know all pocs ...\n\tif (!ctx->notime || (!ctx->strict_poc && ctx->poc_probe_done) )\n\t\tnaludmx_enqueue_or_dispatch(ctx, NULL, GF_TRUE);\n\n\tctx->first_pck_in_au = NULL;\n}","target":0,"code_token_length":1523,"total_token_length":1759,"max_tokens_setting":2048}
+{"idx":391648,"func":"NTSTATUS change_dir_owner_to_parent(connection_struct *conn,\n\t\t\t\t       const char *inherit_from_dir,\n\t\t\t\t       const char *fname,\n\t\t\t\t       SMB_STRUCT_STAT *psbuf)\n{\n\tstruct smb_filename *smb_fname_parent;\n\tstruct smb_filename *smb_fname_cwd = NULL;\n\tchar *saved_dir = NULL;\n\tTALLOC_CTX *ctx = talloc_tos();\n\tNTSTATUS status = NT_STATUS_OK;\n\tint ret;\n\n\tsmb_fname_parent = synthetic_smb_fname(ctx, inherit_from_dir,\n\t\t\t\t\t       NULL, NULL);\n\tif (smb_fname_parent == NULL) {\n\t\treturn NT_STATUS_NO_MEMORY;\n\t}\n\n\tret = SMB_VFS_STAT(conn, smb_fname_parent);\n\tif (ret == -1) {\n\t\tstatus = map_nt_error_from_unix(errno);\n\t\tDEBUG(0,(\"change_dir_owner_to_parent: failed to stat parent \"\n\t\t\t \"directory %s. Error was %s\\n\",\n\t\t\t smb_fname_str_dbg(smb_fname_parent),\n\t\t\t strerror(errno)));\n\t\tgoto out;\n\t}\n\n\t\/* We've already done an lstat into psbuf, and we know it's a\n\t   directory. If we can cd into the directory and the dev\/ino\n\t   are the same then we can safely chown without races as\n\t   we're locking the directory in place by being in it.  This\n\t   should work on any UNIX (thanks tridge :-). JRA.\n\t*\/\n\n\tsaved_dir = vfs_GetWd(ctx,conn);\n\tif (!saved_dir) {\n\t\tstatus = map_nt_error_from_unix(errno);\n\t\tDEBUG(0,(\"change_dir_owner_to_parent: failed to get \"\n\t\t\t \"current working directory. Error was %s\\n\",\n\t\t\t strerror(errno)));\n\t\tgoto out;\n\t}\n\n\t\/* Chdir into the new path. *\/\n\tif (vfs_ChDir(conn, fname) == -1) {\n\t\tstatus = map_nt_error_from_unix(errno);\n\t\tDEBUG(0,(\"change_dir_owner_to_parent: failed to change \"\n\t\t\t \"current working directory to %s. Error \"\n\t\t\t \"was %s\\n\", fname, strerror(errno) ));\n\t\tgoto chdir;\n\t}\n\n\tsmb_fname_cwd = synthetic_smb_fname(ctx, \".\", NULL, NULL);\n\tif (smb_fname_cwd == NULL) {\n\t\tstatus = NT_STATUS_NO_MEMORY;\n\t\tgoto chdir;\n\t}\n\n\tret = SMB_VFS_STAT(conn, smb_fname_cwd);\n\tif (ret == -1) {\n\t\tstatus = map_nt_error_from_unix(errno);\n\t\tDEBUG(0,(\"change_dir_owner_to_parent: failed to stat \"\n\t\t\t \"directory '.' (%s) Error was %s\\n\",\n\t\t\t fname, strerror(errno)));\n\t\tgoto chdir;\n\t}\n\n\t\/* Ensure we're pointing at the same place. *\/\n\tif (smb_fname_cwd->st.st_ex_dev != psbuf->st_ex_dev ||\n\t    smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino) {\n\t\tDEBUG(0,(\"change_dir_owner_to_parent: \"\n\t\t\t \"device\/inode on directory %s changed. \"\n\t\t\t \"Refusing to chown !\\n\", fname ));\n\t\tstatus = NT_STATUS_ACCESS_DENIED;\n\t\tgoto chdir;\n\t}\n\n\tif (smb_fname_parent->st.st_ex_uid == smb_fname_cwd->st.st_ex_uid) {\n\t\t\/* Already this uid - no need to change. *\/\n\t\tDEBUG(10,(\"change_dir_owner_to_parent: directory %s \"\n\t\t\t\"is already owned by uid %d\\n\",\n\t\t\tfname,\n\t\t\t(int)smb_fname_cwd->st.st_ex_uid ));\n\t\tstatus = NT_STATUS_OK;\n\t\tgoto chdir;\n\t}\n\n\tbecome_root();\n\tret = SMB_VFS_LCHOWN(conn, \".\", smb_fname_parent->st.st_ex_uid,\n\t\t\t    (gid_t)-1);\n\tunbecome_root();\n\tif (ret == -1) {\n\t\tstatus = map_nt_error_from_unix(errno);\n\t\tDEBUG(10,(\"change_dir_owner_to_parent: failed to chown \"\n\t\t\t  \"directory %s to parent directory uid %u. \"\n\t\t\t  \"Error was %s\\n\", fname,\n\t\t\t  (unsigned int)smb_fname_parent->st.st_ex_uid,\n\t\t\t  strerror(errno) ));\n\t} else {\n\t\tDEBUG(10,(\"change_dir_owner_to_parent: changed ownership of new \"\n\t\t\t\"directory %s to parent directory uid %u.\\n\",\n\t\t\tfname, (unsigned int)smb_fname_parent->st.st_ex_uid ));\n\t\t\/* Ensure the uid entry is updated. *\/\n\t\tpsbuf->st_ex_uid = smb_fname_parent->st.st_ex_uid;\n\t}\n\n chdir:\n\tvfs_ChDir(conn,saved_dir);\n out:\n\tTALLOC_FREE(smb_fname_parent);\n\tTALLOC_FREE(smb_fname_cwd);\n\treturn status;\n}","target":0,"code_token_length":983,"total_token_length":1219,"max_tokens_setting":2048}
+{"idx":211090,"func":"add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstype)\n{\n\tint rc = 0;\n\tuid_t uid;\n\tchar *mount_user = NULL;\n\tstruct mntent mountent;\n\tFILE *pmntfile;\n\tsigset_t mask, oldmask;\n\n\tuid = getuid();\n\tif (uid != 0)\n\t\tmount_user = getusername(uid);\n\n\t\/*\n\t * Set the real uid to the effective uid. This prevents unprivileged\n\t * users from sending signals to this process, though ^c on controlling\n\t * terminal should still work.\n\t *\/\n\trc = setreuid(geteuid(), -1);\n\tif (rc != 0) {\n\t\tfprintf(stderr, \"Unable to set real uid to effective uid: %s\\n\",\n\t\t\t\tstrerror(errno));\n\t\treturn EX_FILEIO;\n\t}\n\n\trc = sigfillset(&mask);\n\tif (rc) {\n\t\tfprintf(stderr, \"Unable to set filled signal mask\\n\");\n\t\treturn EX_FILEIO;\n\t}\n\n\trc = sigprocmask(SIG_SETMASK, &mask, &oldmask);\n\tif (rc) {\n\t\tfprintf(stderr, \"Unable to make process ignore signals\\n\");\n\t\treturn EX_FILEIO;\n\t}\n\n\trc = toggle_dac_capability(1, 1);\n\tif (rc)\n\t\treturn EX_FILEIO;\n\n\tatexit(unlock_mtab);\n\trc = lock_mtab();\n\tif (rc) {\n\t\tfprintf(stderr, \"cannot lock mtab\");\n\t\trc = EX_FILEIO;\n\t\tgoto add_mtab_exit;\n\t}\n\n\tpmntfile = setmntent(MOUNTED, \"a+\");\n\tif (!pmntfile) {\n\t\tfprintf(stderr, \"could not update mount table\\n\");\n\t\tunlock_mtab();\n\t\trc = EX_FILEIO;\n\t\tgoto add_mtab_exit;\n\t}\n\n\tmountent.mnt_fsname = devname;\n\tmountent.mnt_dir = mountpoint;\n\tmountent.mnt_type = (char *)(void *)fstype;\n\tmountent.mnt_opts = (char *)calloc(MTAB_OPTIONS_LEN, 1);\n\tif (mountent.mnt_opts) {\n\t\tif (flags & MS_RDONLY)\n\t\t\tstrlcat(mountent.mnt_opts, \"ro\", MTAB_OPTIONS_LEN);\n\t\telse\n\t\t\tstrlcat(mountent.mnt_opts, \"rw\", MTAB_OPTIONS_LEN);\n\n\t\tif (flags & MS_MANDLOCK)\n\t\t\tstrlcat(mountent.mnt_opts, \",mand\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_NOEXEC)\n\t\t\tstrlcat(mountent.mnt_opts, \",noexec\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_NOSUID)\n\t\t\tstrlcat(mountent.mnt_opts, \",nosuid\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_NODEV)\n\t\t\tstrlcat(mountent.mnt_opts, \",nodev\", MTAB_OPTIONS_LEN);\n\t\tif (flags & MS_SYNCHRONOUS)\n\t\t\tstrlcat(mountent.mnt_opts, \",sync\", MTAB_OPTIONS_LEN);\n\t\tif (mount_user) {\n\t\t\tstrlcat(mountent.mnt_opts, \",user=\", MTAB_OPTIONS_LEN);\n\t\t\tstrlcat(mountent.mnt_opts, mount_user,\n\t\t\t\tMTAB_OPTIONS_LEN);\n\t\t}\n\t}\n\tmountent.mnt_freq = 0;\n\tmountent.mnt_passno = 0;\n\trc = addmntent(pmntfile, &mountent);\n\tif (rc) {\n\t\tfprintf(stderr, \"unable to add mount entry to mtab\\n\");\n\t\trc = EX_FILEIO;\n\t}\n\tendmntent(pmntfile);\n\tunlock_mtab();\n\tSAFE_FREE(mountent.mnt_opts);\nadd_mtab_exit:\n\ttoggle_dac_capability(1, 0);\n\tsigprocmask(SIG_SETMASK, &oldmask, NULL);\n\n\treturn rc;\n}","target":1,"code_token_length":808,"total_token_length":1044,"max_tokens_setting":2048}
+{"idx":210284,"func":"vhost_user_get_inflight_fd(struct virtio_net **pdev,\n\t\t\t   struct vhu_msg_context *ctx,\n\t\t\t   int main_fd __rte_unused)\n{\n\tstruct rte_vhost_inflight_info_packed *inflight_packed;\n\tuint64_t pervq_inflight_size, mmap_size;\n\tuint16_t num_queues, queue_size;\n\tstruct virtio_net *dev = *pdev;\n\tint fd, i, j;\n\tint numa_node = SOCKET_ID_ANY;\n\tvoid *addr;\n\n\tif (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) {\n\t\tVHOST_LOG_CONFIG(ERR, \"(%s) invalid get_inflight_fd message size is %d\\n\",\n\t\t\tdev->ifname, ctx->msg.size);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\t\/*\n\t * If VQ 0 has already been allocated, try to allocate on the same\n\t * NUMA node. It can be reallocated later in numa_realloc().\n\t *\/\n\tif (dev->nr_vring > 0)\n\t\tnuma_node = dev->virtqueue[0]->numa_node;\n\n\tif (dev->inflight_info == NULL) {\n\t\tdev->inflight_info = rte_zmalloc_socket(\"inflight_info\",\n\t\t\t\tsizeof(struct inflight_mem_info), 0, numa_node);\n\t\tif (!dev->inflight_info) {\n\t\t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to alloc dev inflight area\\n\",\n\t\t\t\t\tdev->ifname);\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\t\tdev->inflight_info->fd = -1;\n\t}\n\n\tnum_queues = ctx->msg.payload.inflight.num_queues;\n\tqueue_size = ctx->msg.payload.inflight.queue_size;\n\n\tVHOST_LOG_CONFIG(INFO, \"(%s) get_inflight_fd num_queues: %u\\n\",\n\t\tdev->ifname, ctx->msg.payload.inflight.num_queues);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) get_inflight_fd queue_size: %u\\n\",\n\t\tdev->ifname, ctx->msg.payload.inflight.queue_size);\n\n\tif (vq_is_packed(dev))\n\t\tpervq_inflight_size = get_pervq_shm_size_packed(queue_size);\n\telse\n\t\tpervq_inflight_size = get_pervq_shm_size_split(queue_size);\n\n\tmmap_size = num_queues * pervq_inflight_size;\n\taddr = inflight_mem_alloc(dev, \"vhost-inflight\", mmap_size, &fd);\n\tif (!addr) {\n\t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to alloc vhost inflight area\\n\", dev->ifname);\n\t\t\tctx->msg.payload.inflight.mmap_size = 0;\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\tmemset(addr, 0, mmap_size);\n\n\tif (dev->inflight_info->addr) {\n\t\tmunmap(dev->inflight_info->addr, dev->inflight_info->size);\n\t\tdev->inflight_info->addr = NULL;\n\t}\n\n\tif (dev->inflight_info->fd >= 0) {\n\t\tclose(dev->inflight_info->fd);\n\t\tdev->inflight_info->fd = -1;\n\t}\n\n\tdev->inflight_info->addr = addr;\n\tdev->inflight_info->size = ctx->msg.payload.inflight.mmap_size = mmap_size;\n\tdev->inflight_info->fd = ctx->fds[0] = fd;\n\tctx->msg.payload.inflight.mmap_offset = 0;\n\tctx->fd_num = 1;\n\n\tif (vq_is_packed(dev)) {\n\t\tfor (i = 0; i < num_queues; i++) {\n\t\t\tinflight_packed =\n\t\t\t\t(struct rte_vhost_inflight_info_packed *)addr;\n\t\t\tinflight_packed->used_wrap_counter = 1;\n\t\t\tinflight_packed->old_used_wrap_counter = 1;\n\t\t\tfor (j = 0; j < queue_size; j++)\n\t\t\t\tinflight_packed->desc[j].next = j + 1;\n\t\t\taddr = (void *)((char *)addr + pervq_inflight_size);\n\t\t}\n\t}\n\n\tVHOST_LOG_CONFIG(INFO, \"(%s) send inflight mmap_size: %\"PRIu64\"\\n\",\n\t\t\tdev->ifname, ctx->msg.payload.inflight.mmap_size);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) send inflight mmap_offset: %\"PRIu64\"\\n\",\n\t\t\tdev->ifname, ctx->msg.payload.inflight.mmap_offset);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) send inflight fd: %d\\n\", dev->ifname, ctx->fds[0]);\n\n\treturn RTE_VHOST_MSG_RESULT_REPLY;\n}","target":1,"code_token_length":970,"total_token_length":1206,"max_tokens_setting":2048}
+{"idx":195055,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& indices = context->input(0);\n    const Tensor& values = context->input(1);\n    const Tensor& shape = context->input(2);\n    const Tensor& weights = context->input(3);\n    bool use_weights = weights.NumElements() > 0;\n\n    OP_REQUIRES(context, TensorShapeUtils::IsMatrix(indices.shape()),\n                errors::InvalidArgument(\n                    \"Input indices must be a 2-dimensional tensor. Got: \",\n                    indices.shape().DebugString()));\n\n    if (use_weights) {\n      OP_REQUIRES(\n          context, weights.shape() == values.shape(),\n          errors::InvalidArgument(\n              \"Weights and values must have the same shape. Weight shape: \",\n              weights.shape().DebugString(),\n              \"; values shape: \", values.shape().DebugString()));\n    }\n\n    OP_REQUIRES(context, shape.NumElements() != 0,\n                errors::InvalidArgument(\n                    \"The shape argument requires at least one element.\"));\n\n    bool is_1d = shape.NumElements() == 1;\n    auto shape_vector = shape.flat<int64_t>();\n    int num_batches = is_1d ? 1 : shape_vector(0);\n    int num_values = values.NumElements();\n\n    for (int b = 0; b < shape_vector.size(); b++) {\n      OP_REQUIRES(context, shape_vector(b) >= 0,\n                  errors::InvalidArgument(\n                      \"Elements in dense_shape must be >= 0. Instead got:\",\n                      shape.DebugString()));\n    }\n\n    OP_REQUIRES(context, num_values == indices.shape().dim_size(0),\n                errors::InvalidArgument(\n                    \"Number of values must match first dimension of indices.\",\n                    \"Got \", num_values,\n                    \" values, indices shape: \", indices.shape().DebugString()));\n\n    const auto indices_values = indices.matrix<int64_t>();\n    const auto values_values = values.flat<T>();\n    const auto weight_values = weights.flat<W>();\n\n    auto per_batch_counts = BatchedMap<W>(num_batches);\n\n    T max_value = 0;\n\n    OP_REQUIRES(context, num_values <= indices.shape().dim_size(0),\n                errors::InvalidArgument(\n                    \"The first dimension of indices must be equal to or \"\n                    \"greather than number of values. ( \",\n                    indices.shape().dim_size(0), \" vs. \", num_values, \" )\"));\n    OP_REQUIRES(context, indices.shape().dim_size(1) > 0,\n                errors::InvalidArgument(\"The second dimension of indices must \"\n                                        \"be greater than 0. Received: \",\n                                        indices.shape().dim_size(1)));\n\n    for (int idx = 0; idx < num_values; ++idx) {\n      int batch = is_1d ? 0 : indices_values(idx, 0);\n      if (batch >= num_batches) {\n        OP_REQUIRES(context, batch < num_batches,\n                    errors::InvalidArgument(\n                        \"Indices value along the first dimension must be \",\n                        \"lower than the first index of the shape.\", \"Got \",\n                        batch, \" as batch and \", num_batches,\n                        \" as the first dimension of the shape.\"));\n      }\n      const auto& value = values_values(idx);\n      if (value >= 0 && (maxlength_ <= 0 || value < maxlength_)) {\n        if (binary_output_) {\n          per_batch_counts[batch][value] = 1;\n        } else if (use_weights) {\n          per_batch_counts[batch][value] += weight_values(idx);\n        } else {\n          per_batch_counts[batch][value]++;\n        }\n        if (value > max_value) {\n          max_value = value;\n        }\n      }\n    }\n\n    int num_output_values = GetOutputSize(max_value, maxlength_, minlength_);\n    OP_REQUIRES_OK(context, OutputSparse<W>(per_batch_counts, num_output_values,\n                                            is_1d, context));\n  }","target":1,"code_token_length":819,"total_token_length":1055,"max_tokens_setting":2048}
+{"idx":218742,"func":"static HENHMETAFILE ReadEnhMetaFile(const char *path,ssize_t *width,\n  ssize_t *height)\n{\n#pragma pack( push, 2 )\n  typedef struct\n  {\n    DWORD dwKey;\n    WORD hmf;\n    SMALL_RECT bbox;\n    WORD wInch;\n    DWORD dwReserved;\n    WORD wCheckSum;\n  } APMHEADER, *PAPMHEADER;\n#pragma pack( pop )\n\n  DWORD\n    dwSize;\n\n  ENHMETAHEADER\n    emfh;\n\n  HANDLE\n    hFile;\n\n  HDC\n    hDC;\n\n  HENHMETAFILE\n    hTemp;\n\n  LPBYTE\n    pBits;\n\n  METAFILEPICT\n    mp;\n\n  HMETAFILE\n    hOld;\n\n  *width=512;\n  *height=512;\n  hTemp=GetEnhMetaFile(path);\n#if defined(MAGICKCORE_HAVE__WFOPEN)\n  if (hTemp == (HENHMETAFILE) NULL)\n    {\n      wchar_t\n        *unicode_path;\n\n      unicode_path=ConvertUTF8ToUTF16((const unsigned char *) path);\n      if (unicode_path != (wchar_t *) NULL)\n        {\n          hTemp=GetEnhMetaFileW(unicode_path);\n          unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path);\n        }\n    }\n#endif\n  if (hTemp != (HENHMETAFILE) NULL)\n    {\n      \/*\n        Enhanced metafile.\n      *\/\n      GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh);\n      *width=emfh.rclFrame.right-emfh.rclFrame.left;\n      *height=emfh.rclFrame.bottom-emfh.rclFrame.top;\n      return(hTemp);\n    }\n  hOld=GetMetaFile(path);\n  if (hOld != (HMETAFILE) NULL)\n    {\n      \/*\n        16bit windows metafile.\n      *\/\n      dwSize=GetMetaFileBitsEx(hOld,0,NULL);\n      if (dwSize == 0)\n        {\n          DeleteMetaFile(hOld);\n          return((HENHMETAFILE) NULL);\n        }\n      pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits));\n      if (pBits == (LPBYTE) NULL)\n        {\n          DeleteMetaFile(hOld);\n          return((HENHMETAFILE) NULL);\n        }\n      if (GetMetaFileBitsEx(hOld,dwSize,pBits) == 0)\n        {\n          pBits=(BYTE *) DestroyString((char *) pBits);\n          DeleteMetaFile(hOld);\n          return((HENHMETAFILE) NULL);\n        }\n      \/*\n        Make an enhanced metafile from the windows metafile.\n      *\/\n      mp.mm=MM_ANISOTROPIC;\n      mp.xExt=1000;\n      mp.yExt=1000;\n      mp.hMF=NULL;\n      hDC=GetDC(NULL);\n      hTemp=SetWinMetaFileBits(dwSize,pBits,hDC,&mp);\n      ReleaseDC(NULL,hDC);\n      DeleteMetaFile(hOld);\n      pBits=(BYTE *) DestroyString((char *) pBits);\n      GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh);\n      *width=emfh.rclFrame.right-emfh.rclFrame.left;\n      *height=emfh.rclFrame.bottom-emfh.rclFrame.top;\n      return(hTemp);\n    }\n  \/*\n    Aldus Placeable metafile.\n  *\/\n  hFile=CreateFile(path,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,\n    NULL);\n  if (hFile == INVALID_HANDLE_VALUE)\n    return(NULL);\n  dwSize=GetFileSize(hFile,NULL);\n  pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits));\n  if (pBits == (LPBYTE) NULL)\n    {\n      CloseHandle(hFile);\n      return((HENHMETAFILE) NULL);\n    }\n  ReadFile(hFile,pBits,dwSize,&dwSize,NULL);\n  CloseHandle(hFile);\n  if (((PAPMHEADER) pBits)->dwKey != 0x9ac6cdd7l ||\n      (((PAPMHEADER) pBits)->wInch == 0))\n    {\n      pBits=(BYTE *) DestroyString((char *) pBits);\n      return((HENHMETAFILE) NULL);\n    }\n  \/*\n    Make an enhanced metafile from the placable metafile.\n  *\/\n  mp.mm=MM_ANISOTROPIC;\n  mp.xExt=((PAPMHEADER) pBits)->bbox.Right-((PAPMHEADER) pBits)->bbox.Left;\n  *width=mp.xExt;\n  mp.xExt=(mp.xExt*2540l)\/(DWORD) (((PAPMHEADER) pBits)->wInch);\n  mp.yExt=((PAPMHEADER)pBits)->bbox.Bottom-((PAPMHEADER) pBits)->bbox.Top;\n  *height=mp.yExt;\n  mp.yExt=(mp.yExt*2540l)\/(DWORD) (((PAPMHEADER) pBits)->wInch);\n  mp.hMF=NULL;\n  hDC=GetDC(NULL);\n  hTemp=SetWinMetaFileBits(dwSize,&(pBits[sizeof(APMHEADER)]),hDC,&mp);\n  ReleaseDC(NULL,hDC);\n  pBits=(BYTE *) DestroyString((char *) pBits);\n  return(hTemp);\n}","target":0,"code_token_length":1159,"total_token_length":1395,"max_tokens_setting":2048}
+{"idx":279939,"func":"do_bang(\n    int\t\taddr_count,\n    exarg_T\t*eap,\n    int\t\tforceit,\n    int\t\tdo_in,\n    int\t\tdo_out)\n{\n    char_u\t\t*arg = eap->arg;\t\/\/ command\n    linenr_T\t\tline1 = eap->line1;\t\/\/ start of range\n    linenr_T\t\tline2 = eap->line2;\t\/\/ end of range\n    char_u\t\t*newcmd = NULL;\t\t\/\/ the new command\n    int\t\t\tfree_newcmd = FALSE;    \/\/ need to free() newcmd\n    int\t\t\tins_prevcmd;\n    char_u\t\t*t;\n    char_u\t\t*p;\n    char_u\t\t*trailarg;\n    int\t\t\tlen;\n    int\t\t\tscroll_save = msg_scroll;\n\n    \/*\n     * Disallow shell commands for \"rvim\".\n     * Disallow shell commands from .exrc and .vimrc in current directory for\n     * security reasons.\n     *\/\n    if (check_restricted() || check_secure())\n\treturn;\n\n    if (addr_count == 0)\t\t\/\/ :!\n    {\n\tmsg_scroll = FALSE;\t    \/\/ don't scroll here\n\tautowrite_all();\n\tmsg_scroll = scroll_save;\n    }\n\n    \/*\n     * Try to find an embedded bang, like in :!<cmd> ! [args]\n     * (:!! is indicated by the 'forceit' variable)\n     *\/\n    ins_prevcmd = forceit;\n    trailarg = arg;\n    do\n    {\n\tlen = (int)STRLEN(trailarg) + 1;\n\tif (newcmd != NULL)\n\t    len += (int)STRLEN(newcmd);\n\tif (ins_prevcmd)\n\t{\n\t    if (prevcmd == NULL)\n\t    {\n\t\temsg(_(e_no_previous_command));\n\t\tvim_free(newcmd);\n\t\treturn;\n\t    }\n\t    len += (int)STRLEN(prevcmd);\n\t}\n\tif ((t = alloc(len)) == NULL)\n\t{\n\t    vim_free(newcmd);\n\t    return;\n\t}\n\t*t = NUL;\n\tif (newcmd != NULL)\n\t    STRCAT(t, newcmd);\n\tif (ins_prevcmd)\n\t    STRCAT(t, prevcmd);\n\tp = t + STRLEN(t);\n\tSTRCAT(t, trailarg);\n\tvim_free(newcmd);\n\tnewcmd = t;\n\n\t\/*\n\t * Scan the rest of the argument for '!', which is replaced by the\n\t * previous command.  \"\\!\" is replaced by \"!\" (this is vi compatible).\n\t *\/\n\ttrailarg = NULL;\n\twhile (*p)\n\t{\n\t    if (*p == '!')\n\t    {\n\t\tif (p > newcmd && p[-1] == '\\\\')\n\t\t    STRMOVE(p - 1, p);\n\t\telse\n\t\t{\n\t\t    trailarg = p;\n\t\t    *trailarg++ = NUL;\n\t\t    ins_prevcmd = TRUE;\n\t\t    break;\n\t\t}\n\t    }\n\t    ++p;\n\t}\n    } while (trailarg != NULL);\n\n    vim_free(prevcmd);\n    prevcmd = newcmd;\n\n    if (bangredo)\t    \/\/ put cmd in redo buffer for ! command\n    {\n\t\/\/ If % or # appears in the command, it must have been escaped.\n\t\/\/ Reescape them, so that redoing them does not substitute them by the\n\t\/\/ buffername.\n\tchar_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)\"%#\");\n\n\tif (cmd != NULL)\n\t{\n\t    AppendToRedobuffLit(cmd, -1);\n\t    vim_free(cmd);\n\t}\n\telse\n\t    AppendToRedobuffLit(prevcmd, -1);\n\tAppendToRedobuff((char_u *)\"\\n\");\n\tbangredo = FALSE;\n    }\n    \/*\n     * Add quotes around the command, for shells that need them.\n     *\/\n    if (*p_shq != NUL)\n    {\n\tnewcmd = alloc(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1);\n\tif (newcmd == NULL)\n\t    return;\n\tSTRCPY(newcmd, p_shq);\n\tSTRCAT(newcmd, prevcmd);\n\tSTRCAT(newcmd, p_shq);\n\tfree_newcmd = TRUE;\n    }\n    if (addr_count == 0)\t\t\/\/ :!\n    {\n\t\/\/ echo the command\n\tmsg_start();\n\tmsg_putchar(':');\n\tmsg_putchar('!');\n\tmsg_outtrans(newcmd);\n\tmsg_clr_eos();\n\twindgoto(msg_row, msg_col);\n\n\tdo_shell(newcmd, 0);\n    }\n    else\t\t\t\t\/\/ :range!\n    {\n\t\/\/ Careful: This may recursively call do_bang() again! (because of\n\t\/\/ autocommands)\n\tdo_filter(line1, line2, eap, newcmd, do_in, do_out);\n\tapply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, FALSE, curbuf);\n    }\n    if (free_newcmd)\n\tvim_free(newcmd);\n}","target":0,"code_token_length":1051,"total_token_length":1287,"max_tokens_setting":2048}
+{"idx":402601,"func":"find_named_certificate(cms_context *cms, char *name, CERTCertificate **cert)\n{\n\tif (!name) {\n\t\tcms->log(cms, LOG_ERR, \"no certificate name specified\");\n\t\treturn -1;\n\t}\n\n\tPK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);\n\n\tPK11SlotList *slots = NULL;\n\tslots = PK11_GetAllTokens(CKM_RSA_PKCS, PR_FALSE, PR_TRUE, cms);\n\tif (!slots)\n\t\tcmsreterr(-1, cms, \"could not get pk11 token list\");\n\n\tPK11SlotListElement *psle = NULL;\n\tpsle = PK11_GetFirstSafe(slots);\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tcmsreterr(-1, cms, \"could not get pk11 safe\");\n\t}\n\n\twhile (psle) {\n\t\tif (!strcmp(cms->tokenname, PK11_GetTokenName(psle->slot)))\n\t\t\tbreak;\n\n\t\tpsle = PK11_GetNextSafe(slots, psle, PR_FALSE);\n\t}\n\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t\tcms->log(cms, LOG_ERR, \"could not find token \\\"%s\\\"\",\n\t\t\t\t cms->tokenname);\n\t\t}\n\t\treturn -1;\n\t}\n\n\tSECStatus status;\n\tif (PK11_NeedLogin(psle->slot) && !PK11_IsLoggedIn(psle->slot, cms)) {\n\t\tstatus = PK11_Authenticate(psle->slot, PR_TRUE, cms);\n\t\tif (status != SECSuccess) {\n\t\t\tsave_port_err() {\n\t\t\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\t\t\tPK11_FreeSlotList(slots);\n\t\t\t\tcms->log(cms, LOG_ERR,\n\t\t\t\t\t \"authentication failed for token \\\"%s\\\"\",\n\t\t\t\t\t cms->tokenname);\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tCERTCertList *certlist = NULL;\n\tcertlist = PK11_ListCertsInSlot(psle->slot);\n\tif (!certlist) {\n\t\tsave_port_err() {\n\t\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tcmsreterr(-1, cms, \"could not get certificate list\");\n\t}\n\n\tCERTCertListNode *node = NULL;\n\tfor_each_cert(certlist, tmpnode) {\n\t\tif (!strcmp(tmpnode->cert->subjectName, name)) {\n\t\t\tnode = tmpnode;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\/* If we're looking up the issuer of some cert, and the issuer isn't\n\t * in the database, we'll get back what is essentially a template\n\t * that's in NSS's cache waiting to be filled out.  We can't use that,\n\t * it'll just cause CERT_DupCertificate() to segfault. *\/\n\tif (!node || !node->cert || !node->cert->derCert.data\n\t    || !node->cert->derCert.len\n\t    || !node->cert->derIssuer.data\n\t    || !node->cert->derIssuer.len) {\n\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\tPK11_FreeSlotList(slots);\n\t\tCERT_DestroyCertList(certlist);\n\n\t\treturn -1;\n\t}\n\n\t*cert = CERT_DupCertificate(node->cert);\n\n\tPK11_DestroySlotListElement(slots, &psle);\n\tPK11_FreeSlotList(slots);\n\tCERT_DestroyCertList(certlist);\n\n\treturn 0;\n}","target":0,"code_token_length":797,"total_token_length":1033,"max_tokens_setting":2048}
+{"idx":246724,"func":"GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 base_flags, Bool copy_data, Bool interleave, Bool regular_iod, Bool single_group, Bool hint_no_offset)\n{\n\tGF_ESD *esd;\n\tGF_InitialObjectDescriptor *iod;\n\tu32 i, val, res, streamType;\n\tu32 sl_mode, prev_ocr, single_ocr, nb_done, tot_bw, bw, flags, spec_type;\n\tGF_Err e;\n\tchar szPayload[30];\n\tGF_RTPHinter *hinter;\n\tBool copy, has_iod, single_av;\n\tu8 init_payt = BASE_PAYT;\n\tu32 mtype;\n\tGF_SDP_IODProfile iod_mode = GF_SDP_IOD_NONE;\n\tu32 media_group = 0;\n\tu8 media_prio = 0;\n\n\ttot_bw = 0;\n\tprev_ocr = 0;\n\tsingle_ocr = 1;\n\n\thas_iod = 1;\n\tiod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);\n\tif (!iod) has_iod = 0;\n\telse {\n\t\tif (!gf_list_count(iod->ESDescriptors)) has_iod = 0;\n\t\tgf_odf_desc_del((GF_Descriptor *) iod);\n\t}\n\n\tspec_type = gf_isom_guess_specification(file);\n\tsingle_av = single_group ? 1 : gf_isom_is_single_av(file);\n\n\t\/*first make sure we use a systems track as base OCR*\/\n\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\tres = gf_isom_get_media_type(file, i+1);\n\t\tif ((res==GF_ISOM_MEDIA_SCENE) || (res==GF_ISOM_MEDIA_OD)) {\n\t\t\tif (gf_isom_is_track_in_root_od(file, i+1)) {\n\t\t\t\tgf_isom_set_default_sync_track(file, i+1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tnb_done = 0;\n\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\tsl_mode = base_flags;\n\t\tcopy = copy_data;\n\t\t\/*skip emty tracks (mainly MPEG-4 interaction streams...*\/\n\t\tif (!gf_isom_get_sample_count(file, i+1)) continue;\n\t\tif (!gf_isom_is_track_enabled(file, i+1)) {\n\t\t\tM4_LOG(GF_LOG_INFO, (\"Track ID %d disabled - skipping hint\\n\", gf_isom_get_track_id(file, i+1) ));\n\t\t\tcontinue;\n\t\t}\n\n\t\tmtype = gf_isom_get_media_type(file, i+1);\n\t\tswitch (mtype) {\n\t\tcase GF_ISOM_MEDIA_VISUAL:\n\t\t\tif (single_av) {\n\t\t\t\tmedia_group = 2;\n\t\t\t\tmedia_prio = 2;\n\t\t\t}\n\t\t\tbreak;\n        case GF_ISOM_MEDIA_AUXV:\n            if (single_av) {\n                media_group = 2;\n                media_prio = 3;\n            }\n            break;\n        case GF_ISOM_MEDIA_PICT:\n            if (single_av) {\n                media_group = 2;\n                media_prio = 4;\n            }\n            break;\n\t\tcase GF_ISOM_MEDIA_AUDIO:\n\t\t\tif (single_av) {\n\t\t\t\tmedia_group = 2;\n\t\t\t\tmedia_prio = 1;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase GF_ISOM_MEDIA_HINT:\n\t\t\tcontinue;\n\t\tdefault:\n\t\t\t\/*no hinting of systems track on isma*\/\n\t\t\tif (spec_type==GF_ISOM_BRAND_ISMA) continue;\n\t\t}\n\t\tmtype = gf_isom_get_media_subtype(file, i+1, 1);\n\t\tif ((mtype==GF_ISOM_SUBTYPE_MPEG4) || (mtype==GF_ISOM_SUBTYPE_MPEG4_CRYP) ) mtype = gf_isom_get_mpeg4_subtype(file, i+1, 1);\n\n\t\tif (!single_av) {\n\t\t\t\/*one media per group only (we should prompt user for group selection)*\/\n\t\t\tmedia_group ++;\n\t\t\tmedia_prio = 1;\n\t\t}\n\n\t\tstreamType = 0;\n\t\tesd = gf_isom_get_esd(file, i+1, 1);\n\t\tif (esd && esd->decoderConfig) {\n\t\t\tstreamType = esd->decoderConfig->streamType;\n\t\t\tif (!prev_ocr) {\n\t\t\t\tprev_ocr = esd->OCRESID;\n\t\t\t\tif (!esd->OCRESID) prev_ocr = esd->ESID;\n\t\t\t} else if (esd->OCRESID && prev_ocr != esd->OCRESID) {\n\t\t\t\tsingle_ocr = 0;\n\t\t\t}\n\t\t\t\/*OD MUST BE WITHOUT REFERENCES*\/\n\t\t\tif (streamType==1) copy = 1;\n\t\t}\n\t\tgf_odf_desc_del((GF_Descriptor *) esd);\n\n\t\tif (!regular_iod && gf_isom_is_track_in_root_od(file, i+1)) {\n\t\t\t\/*single AU - check if base64 would fit in ESD (consider 33% overhead of base64), otherwise stream*\/\n\t\t\tif (gf_isom_get_sample_count(file, i+1)==1) {\n\t\t\t\tGF_ISOSample *samp = gf_isom_get_sample(file, i+1, 1, &val);\n\t\t\t\tif (streamType && samp) {\n\t\t\t\t\tres = gf_hinter_can_embbed_data(samp->data, samp->dataLength, streamType);\n\t\t\t\t} else {\n\t\t\t\t\t\/*not a system track, we shall hint it*\/\n\t\t\t\t\tres = 0;\n\t\t\t\t}\n\t\t\t\tif (samp) gf_isom_sample_del(&samp);\n\t\t\t\tif (res) continue;\n\t\t\t}\n\t\t}\n\t\tif (interleave) sl_mode |= GP_RTP_PCK_USE_INTERLEAVING;\n\n\t\thinter = gf_hinter_track_new(file, i+1, MTUSize, max_ptime, rtp_rate, sl_mode, init_payt, copy, media_group, media_prio, &e);\n\n\t\tif (!hinter) {\n\t\t\tif (e) {\n\t\t\t\tM4_LOG(nb_done ? GF_LOG_WARNING : GF_LOG_ERROR, (\"Cannot create hinter (%s)\\n\", gf_error_to_string(e) ));\n\t\t\t\tif (!nb_done) return e;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hint_no_offset)\n\t\t\tgf_hinter_track_force_no_offsets(hinter);\n\n\t\tbw = gf_hinter_track_get_bandwidth(hinter);\n\t\ttot_bw += bw;\n\t\tflags = gf_hinter_track_get_flags(hinter);\n\n\t\t\/\/set extraction mode for AVC\/SVC\n\t\tgf_isom_set_nalu_extract_mode(file, i+1, GF_ISOM_NALU_EXTRACT_LAYER_ONLY);\n\n\t\tgf_hinter_track_get_payload_name(hinter, szPayload);\n\t\tM4_LOG(GF_LOG_INFO, (\"Hinting track ID %d - Type \\\"%s:%s\\\" (%s) - BW %d kbps\\n\", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw));\n\t\tif (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) M4_LOG(GF_LOG_INFO, (\"\\tMPEG-4 Systems stream carousel enabled\\n\"));\n\t\te = gf_hinter_track_process(hinter);\n\n\t\tif (!e) e = gf_hinter_track_finalize(hinter, has_iod);\n\t\tgf_hinter_track_del(hinter);\n\n\t\tif (e) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Error while hinting (%s)\\n\", gf_error_to_string(e)));\n\t\t\tif (!nb_done) return e;\n\t\t}\n\t\tinit_payt++;\n\t\tnb_done ++;\n\t}\n\n\tif (has_iod) {\n\t\tiod_mode = GF_SDP_IOD_ISMA;\n\t\tif (regular_iod) iod_mode = GF_SDP_IOD_REGULAR;\n\t} else {\n\t\tiod_mode = GF_SDP_IOD_NONE;\n\t}\n\tgf_hinter_finalize(file, iod_mode, tot_bw);\n\n\tif (!single_ocr)\n\t\tM4_LOG(GF_LOG_WARNING, (\"Warning: at least 2 timelines found in the file\\nThis may not be supported by servers\/players\\n\\n\"));\n\n\treturn GF_OK;\n}","target":0,"code_token_length":1794,"total_token_length":2030,"max_tokens_setting":2048}
+{"idx":212414,"func":"static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,\n\t\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct nlattr *tca[TCA_MAX + 1];\n\tchar name[IFNAMSIZ];\n\tstruct tcmsg *t;\n\tu32 protocol;\n\tu32 prio;\n\tbool prio_allocate;\n\tu32 parent;\n\tu32 chain_index;\n\tstruct Qdisc *q = NULL;\n\tstruct tcf_chain_info chain_info;\n\tstruct tcf_chain *chain = NULL;\n\tstruct tcf_block *block;\n\tstruct tcf_proto *tp;\n\tunsigned long cl;\n\tvoid *fh;\n\tint err;\n\tint tp_created;\n\tbool rtnl_held = false;\n\tu32 flags;\n\n\tif (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))\n\t\treturn -EPERM;\n\nreplay:\n\ttp_created = 0;\n\n\terr = nlmsg_parse_deprecated(n, sizeof(*t), tca, TCA_MAX,\n\t\t\t\t     rtm_tca_policy, extack);\n\tif (err < 0)\n\t\treturn err;\n\n\tt = nlmsg_data(n);\n\tprotocol = TC_H_MIN(t->tcm_info);\n\tprio = TC_H_MAJ(t->tcm_info);\n\tprio_allocate = false;\n\tparent = t->tcm_parent;\n\ttp = NULL;\n\tcl = 0;\n\tblock = NULL;\n\tflags = 0;\n\n\tif (prio == 0) {\n\t\t\/* If no priority is provided by the user,\n\t\t * we allocate one.\n\t\t *\/\n\t\tif (n->nlmsg_flags & NLM_F_CREATE) {\n\t\t\tprio = TC_H_MAKE(0x80000000U, 0U);\n\t\t\tprio_allocate = true;\n\t\t} else {\n\t\t\tNL_SET_ERR_MSG(extack, \"Invalid filter command with priority of zero\");\n\t\t\treturn -ENOENT;\n\t\t}\n\t}\n\n\t\/* Find head of filter chain. *\/\n\n\terr = __tcf_qdisc_find(net, &q, &parent, t->tcm_ifindex, false, extack);\n\tif (err)\n\t\treturn err;\n\n\tif (tcf_proto_check_kind(tca[TCA_KIND], name)) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified TC filter name too long\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\n\t\/* Take rtnl mutex if rtnl_held was set to true on previous iteration,\n\t * block is shared (no qdisc found), qdisc is not unlocked, classifier\n\t * type is not specified, classifier is not unlocked.\n\t *\/\n\tif (rtnl_held ||\n\t    (q && !(q->ops->cl_ops->flags & QDISC_CLASS_OPS_DOIT_UNLOCKED)) ||\n\t    !tcf_proto_is_unlocked(name)) {\n\t\trtnl_held = true;\n\t\trtnl_lock();\n\t}\n\n\terr = __tcf_qdisc_cl_find(q, parent, &cl, t->tcm_ifindex, extack);\n\tif (err)\n\t\tgoto errout;\n\n\tblock = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index,\n\t\t\t\t extack);\n\tif (IS_ERR(block)) {\n\t\terr = PTR_ERR(block);\n\t\tgoto errout;\n\t}\n\tblock->classid = parent;\n\n\tchain_index = tca[TCA_CHAIN] ? nla_get_u32(tca[TCA_CHAIN]) : 0;\n\tif (chain_index > TC_ACT_EXT_VAL_MASK) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified chain index exceeds upper limit\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\tchain = tcf_chain_get(block, chain_index, true);\n\tif (!chain) {\n\t\tNL_SET_ERR_MSG(extack, \"Cannot create specified filter chain\");\n\t\terr = -ENOMEM;\n\t\tgoto errout;\n\t}\n\n\tmutex_lock(&chain->filter_chain_lock);\n\ttp = tcf_chain_tp_find(chain, &chain_info, protocol,\n\t\t\t       prio, prio_allocate);\n\tif (IS_ERR(tp)) {\n\t\tNL_SET_ERR_MSG(extack, \"Filter with specified priority\/protocol not found\");\n\t\terr = PTR_ERR(tp);\n\t\tgoto errout_locked;\n\t}\n\n\tif (tp == NULL) {\n\t\tstruct tcf_proto *tp_new = NULL;\n\n\t\tif (chain->flushing) {\n\t\t\terr = -EAGAIN;\n\t\t\tgoto errout_locked;\n\t\t}\n\n\t\t\/* Proto-tcf does not exist, create new one *\/\n\n\t\tif (tca[TCA_KIND] == NULL || !protocol) {\n\t\t\tNL_SET_ERR_MSG(extack, \"Filter kind and protocol must be specified\");\n\t\t\terr = -EINVAL;\n\t\t\tgoto errout_locked;\n\t\t}\n\n\t\tif (!(n->nlmsg_flags & NLM_F_CREATE)) {\n\t\t\tNL_SET_ERR_MSG(extack, \"Need both RTM_NEWTFILTER and NLM_F_CREATE to create a new filter\");\n\t\t\terr = -ENOENT;\n\t\t\tgoto errout_locked;\n\t\t}\n\n\t\tif (prio_allocate)\n\t\t\tprio = tcf_auto_prio(tcf_chain_tp_prev(chain,\n\t\t\t\t\t\t\t       &chain_info));\n\n\t\tmutex_unlock(&chain->filter_chain_lock);\n\t\ttp_new = tcf_proto_create(name, protocol, prio, chain,\n\t\t\t\t\t  rtnl_held, extack);\n\t\tif (IS_ERR(tp_new)) {\n\t\t\terr = PTR_ERR(tp_new);\n\t\t\tgoto errout_tp;\n\t\t}\n\n\t\ttp_created = 1;\n\t\ttp = tcf_chain_tp_insert_unique(chain, tp_new, protocol, prio,\n\t\t\t\t\t\trtnl_held);\n\t\tif (IS_ERR(tp)) {\n\t\t\terr = PTR_ERR(tp);\n\t\t\tgoto errout_tp;\n\t\t}\n\t} else {\n\t\tmutex_unlock(&chain->filter_chain_lock);\n\t}\n\n\tif (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified filter kind does not match existing one\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\n\tfh = tp->ops->get(tp, t->tcm_handle);\n\n\tif (!fh) {\n\t\tif (!(n->nlmsg_flags & NLM_F_CREATE)) {\n\t\t\tNL_SET_ERR_MSG(extack, \"Need both RTM_NEWTFILTER and NLM_F_CREATE to create a new filter\");\n\t\t\terr = -ENOENT;\n\t\t\tgoto errout;\n\t\t}\n\t} else if (n->nlmsg_flags & NLM_F_EXCL) {\n\t\ttfilter_put(tp, fh);\n\t\tNL_SET_ERR_MSG(extack, \"Filter already exists\");\n\t\terr = -EEXIST;\n\t\tgoto errout;\n\t}\n\n\tif (chain->tmplt_ops && chain->tmplt_ops != tp->ops) {\n\t\tNL_SET_ERR_MSG(extack, \"Chain template is set to a different filter kind\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\n\tif (!(n->nlmsg_flags & NLM_F_CREATE))\n\t\tflags |= TCA_ACT_FLAGS_REPLACE;\n\tif (!rtnl_held)\n\t\tflags |= TCA_ACT_FLAGS_NO_RTNL;\n\terr = tp->ops->change(net, skb, tp, cl, t->tcm_handle, tca, &fh,\n\t\t\t      flags, extack);\n\tif (err == 0) {\n\t\ttfilter_notify(net, skb, n, tp, block, q, parent, fh,\n\t\t\t       RTM_NEWTFILTER, false, rtnl_held);\n\t\ttfilter_put(tp, fh);\n\t\t\/* q pointer is NULL for shared blocks *\/\n\t\tif (q)\n\t\t\tq->flags &= ~TCQ_F_CAN_BYPASS;\n\t}\n\nerrout:\n\tif (err && tp_created)\n\t\ttcf_chain_tp_delete_empty(chain, tp, rtnl_held, NULL);\nerrout_tp:\n\tif (chain) {\n\t\tif (tp && !IS_ERR(tp))\n\t\t\ttcf_proto_put(tp, rtnl_held, NULL);\n\t\tif (!tp_created)\n\t\t\ttcf_chain_put(chain);\n\t}\n\ttcf_block_release(q, block, rtnl_held);\n\n\tif (rtnl_held)\n\t\trtnl_unlock();\n\n\tif (err == -EAGAIN) {\n\t\t\/* Take rtnl lock in case EAGAIN is caused by concurrent flush\n\t\t * of target chain.\n\t\t *\/\n\t\trtnl_held = true;\n\t\t\/* Replay the request. *\/\n\t\tgoto replay;\n\t}\n\treturn err;\n\nerrout_locked:\n\tmutex_unlock(&chain->filter_chain_lock);\n\tgoto errout;\n}","target":1,"code_token_length":1805,"total_token_length":2041,"max_tokens_setting":2048}
+{"idx":223728,"func":"bool ConstantFolding::MulConvPushDown(GraphDef* optimized_graph, NodeDef* node,\n                                      const GraphProperties& properties) {\n  \/\/ Push down multiplication on ConvND.\n  \/\/                       *                  ConvND\n  \/\/                     \/   \\                \/    \\\n  \/\/                 ConvND  C2    -- >      X      *\n  \/\/                  \/ \\                          \/ \\\n  \/\/                 X  C1                       C1  C2\n  \/\/\n  \/\/ where C1 and C2 are constants and X is non-constant.\n  \/\/\n  \/\/ TODO(rmlarsen): Use PrepareConstantPushDown() to simplify this code.\n\n  if (!IsAnyMul(*node) || NumNonControlInputs(*node) != 2) return false;\n\n  NodeDef* mul_left_child = node_map_->GetNode(node->input(0));\n  NodeDef* mul_right_child = node_map_->GetNode(node->input(1));\n  if (mul_left_child == nullptr || mul_right_child == nullptr) {\n    return false;\n  }\n  \/\/ One child must be constant, and the second must be Conv op.\n  const bool left_child_is_constant = IsReallyConstant(*mul_left_child);\n  const bool right_child_is_constant = IsReallyConstant(*mul_right_child);\n  if (!left_child_is_constant && !right_child_is_constant) {\n    return false;\n  }\n  NodeDef* conv_node =\n      left_child_is_constant ? mul_right_child : mul_left_child;\n  if (!IsConv2D(*conv_node) && !IsConv3D(*conv_node)) {\n    return false;\n  }\n  if (node->device() != mul_left_child->device() ||\n      node->device() != mul_right_child->device()) {\n    return false;\n  }\n\n  \/\/ Make sure that it is safe to change the value of the convolution\n  \/\/ output.\n  if (conv_node->input_size() < 2 ||\n      NumNonControlOutputs(*conv_node, *node_map_) > 1 ||\n      nodes_to_preserve_.find(conv_node->name()) != nodes_to_preserve_.end()) {\n    return false;\n  }\n\n  \/\/ Identify the nodes to swap.\n  NodeDef* conv_left_child = node_map_->GetNode(conv_node->input(0));\n  NodeDef* conv_right_child = node_map_->GetNode(conv_node->input(1));\n  const bool conv_left_is_constant = IsReallyConstant(*conv_left_child);\n  const bool conv_right_is_constant = IsReallyConstant(*conv_right_child);\n  if (!conv_left_is_constant && !conv_right_is_constant) {\n    \/\/ At least one of the convolution inputs should be constant.\n    return false;\n  }\n  if (conv_left_is_constant && conv_right_is_constant) {\n    \/\/ Leverage regular constant folding to handle this.\n    return false;\n  }\n  const auto& mul_props = properties.GetOutputProperties(node->name());\n  const auto& conv_props = properties.GetOutputProperties(conv_node->name());\n  if (mul_props.empty() || conv_props.empty()) {\n    return false;\n  }\n  const auto& mul_shape = mul_props[0].shape();\n  const auto& conv_shape = conv_props[0].shape();\n  if (!ShapesSymbolicallyEqual(mul_shape, conv_shape)) {\n    return false;\n  }\n\n  const auto& input_props = properties.GetInputProperties(conv_node->name());\n  if (input_props.size() < 2) {\n    return false;\n  }\n  const auto& filter_shape = input_props[1].shape();\n\n  NodeDef* const_node =\n      left_child_is_constant ? mul_left_child : mul_right_child;\n  const auto& const_props = properties.GetOutputProperties(const_node->name());\n  if (const_props.empty()) {\n    return false;\n  }\n  const auto& const_shape = const_props[0].shape();\n  if (!IsValidConstShapeForMulConvPushDown(\n          conv_node->attr().at(\"data_format\").s(), filter_shape, const_shape)) {\n    return false;\n  }\n\n  string mul_new_name = AddPrefixToNodeName(\"merged_input\", conv_node->name());\n  if (node_map_->NodeExists(mul_new_name)) {\n    return false;\n  }\n  \/\/ Make sure we don't introduce loops in the graph by removing control\n  \/\/ dependencies from the conv2d node to c2.\n  string conv_const_input =\n      conv_left_is_constant ? conv_node->input(0) : conv_node->input(1);\n  if (MaybeRemoveControlInput(conv_node->name(), const_node, optimized_graph,\n                              node_map_.get())) {\n    \/\/ Add a control dep from c1 to c2 to ensure c2 is in the right frame\n    MaybeAddControlInput(conv_const_input, const_node, optimized_graph,\n                         node_map_.get());\n  }\n\n  conv_node->set_name(node->name());\n  node->set_name(mul_new_name);\n  if (conv_left_is_constant) {\n    node_map_->UpdateInput(conv_node->name(), node->input(0), mul_new_name);\n    conv_node->set_input(0, mul_new_name);\n  } else {\n    node_map_->UpdateInput(conv_node->name(), node->input(1), mul_new_name);\n    conv_node->set_input(1, mul_new_name);\n  }\n  NodeDef* conv_const_node =\n      conv_left_is_constant ? conv_left_child : conv_right_child;\n  if (left_child_is_constant) {\n    node->set_input(1, conv_const_node->name());\n  } else {\n    node->set_input(0, conv_const_node->name());\n  }\n  node_map_->AddNode(mul_new_name, node);\n\n  return true;\n}","target":0,"code_token_length":1192,"total_token_length":1428,"max_tokens_setting":2048}
+{"idx":231700,"func":"  virtual void setupConnection() {\n    EXPECT_EQ(server->getConn().readCodec, nullptr);\n    EXPECT_EQ(server->getConn().statsCallback, transportInfoCb_.get());\n    setupClientReadCodec();\n    recvClientHello();\n\n    IOBufEqualTo eq;\n    EXPECT_TRUE(eq(getCryptoStreamData(), IOBuf::copyBuffer(\"SHLO\")));\n    serverWrites.clear();\n\n    EXPECT_NE(server->getConn().readCodec, nullptr);\n    EXPECT_NE(server->getConn().initialWriteCipher, nullptr);\n    EXPECT_NE(server->getConn().initialHeaderCipher, nullptr);\n    EXPECT_NE(server->getConn().handshakeWriteCipher, nullptr);\n    EXPECT_NE(server->getConn().handshakeWriteHeaderCipher, nullptr);\n    EXPECT_NE(server->getConn().readCodec->getHandshakeHeaderCipher(), nullptr);\n\n    EXPECT_FALSE(server->getConn().localConnectionError.has_value());\n    EXPECT_EQ(server->getConn().version, QuicVersion::MVFST);\n    EXPECT_EQ(server->getConn().serverConnIdParams->processId, 0);\n    EXPECT_EQ(server->getConn().serverConnIdParams->workerId, 1);\n    EXPECT_TRUE(server->getConn().serverConnectionId.has_value());\n    EXPECT_EQ(server->getConn().selfConnectionIds.size(), 1);\n    serverConnectionId = *server->getConn().serverConnectionId;\n    EXPECT_EQ(\n        server->getConn().selfConnectionIds[0].connId, serverConnectionId);\n    \/\/ the crypto data should have been written in the previous loop, verify\n    \/\/ that the write loop callback is not scheduled any more since we don't\n    \/\/ have keys to write acks. This assumes that we will schedule crypto data\n    \/\/ as soon as we can.\n    EXPECT_FALSE(server->writeLooper()->isLoopCallbackScheduled());\n    EXPECT_FALSE(server->readLooper()->isLoopCallbackScheduled());\n\n    expectWriteNewSessionTicket();\n    \/\/ Once oneRtt keys are available, ServerTransport must call the\n    \/\/ onConnectionIdBound on its 'routingCallback'\n    EXPECT_CALL(routingCallback, onConnectionIdBound(_))\n        .WillOnce(Invoke([&, clientAddr = clientAddr](auto transport) {\n          EXPECT_EQ(clientAddr, transport->getOriginalPeerAddress());\n        }));\n\n    EXPECT_TRUE(server->getConn().pendingEvents.frames.empty());\n    EXPECT_EQ(server->getConn().nextSelfConnectionIdSequence, 1);\n    recvClientFinished();\n\n    \/\/ We need an extra pump here for some reason.\n    loopForWrites();\n\n    \/\/ Issue (kMinNumAvailableConnIds - 1) more connection ids on handshake\n    \/\/ complete\n    auto numNewConnIdFrames = 0;\n    for (const auto& packet : server->getConn().outstandings.packets) {\n      for (const auto& frame : packet.packet.frames) {\n        switch (frame.type()) {\n          case QuicWriteFrame::Type::QuicSimpleFrame: {\n            const auto writeFrame = frame.asQuicSimpleFrame();\n            if (writeFrame->type() ==\n                QuicSimpleFrame::Type::NewConnectionIdFrame) {\n              ++numNewConnIdFrames;\n            }\n            break;\n          }\n          default:\n            break;\n        }\n      }\n    }\n    uint64_t connIdsToIssue = std::min(\n                                  server->getConn().peerActiveConnectionIdLimit,\n                                  kDefaultActiveConnectionIdLimit) -\n        1;\n\n    if (server->getConn().transportSettings.disableMigration ||\n        (connIdsToIssue == 0)) {\n      EXPECT_EQ(numNewConnIdFrames, 0);\n      EXPECT_EQ(server->getConn().nextSelfConnectionIdSequence, 1);\n    } else {\n      EXPECT_EQ(numNewConnIdFrames, connIdsToIssue);\n      EXPECT_EQ(\n          server->getConn().nextSelfConnectionIdSequence, connIdsToIssue + 1);\n    }\n\n    EXPECT_NE(server->getConn().readCodec, nullptr);\n    EXPECT_NE(server->getConn().oneRttWriteCipher, nullptr);\n    EXPECT_NE(server->getConn().oneRttWriteHeaderCipher, nullptr);\n    EXPECT_NE(server->getConn().readCodec->getOneRttHeaderCipher(), nullptr);\n\n    EXPECT_TRUE(getCryptoStream(\n                    *server->getConn().cryptoState, EncryptionLevel::Initial)\n                    ->readBuffer.empty());\n    EXPECT_FALSE(server->getConn().localConnectionError.has_value());\n    verifyTransportParameters(kDefaultIdleTimeout);\n    serverWrites.clear();\n\n    auto& cryptoState = server->getConn().cryptoState;\n    EXPECT_EQ(cryptoState->handshakeStream.retransmissionBuffer.size(), 0);\n    EXPECT_EQ(cryptoState->oneRttStream.retransmissionBuffer.size(), 0);\n  }","target":0,"code_token_length":990,"total_token_length":1226,"max_tokens_setting":2048}
+{"idx":226951,"func":"IRC_PROTOCOL_CALLBACK(005)\n{\n    char *pos, *pos2, *pos_start, *error, *isupport2;\n    int length_isupport, length, casemapping;\n    long value;\n\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    irc_protocol_cb_numeric (server,\n                             date, nick, address, host, command,\n                             ignored, argc, argv, argv_eol);\n\n    \/* save prefix *\/\n    pos = strstr (argv_eol[3], \"PREFIX=\");\n    if (pos)\n    {\n        pos += 7;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        irc_server_set_prefix_modes_chars (server, pos);\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save max nick length *\/\n    pos = strstr (argv_eol[3], \"NICKLEN=\");\n    if (pos)\n    {\n        pos += 8;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        error = NULL;\n        value = strtol (pos, &error, 10);\n        if (error && !error[0] && (value > 0))\n            server->nick_max_length = (int)value;\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save max user length *\/\n    pos = strstr (argv_eol[3], \"USERLEN=\");\n    if (pos)\n    {\n        pos += 8;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        error = NULL;\n        value = strtol (pos, &error, 10);\n        if (error && !error[0] && (value > 0))\n            server->user_max_length = (int)value;\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save max host length *\/\n    pos = strstr (argv_eol[3], \"HOSTLEN=\");\n    if (pos)\n    {\n        pos += 8;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        error = NULL;\n        value = strtol (pos, &error, 10);\n        if (error && !error[0] && (value > 0))\n            server->host_max_length = (int)value;\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save casemapping *\/\n    pos = strstr (argv_eol[3], \"CASEMAPPING=\");\n    if (pos)\n    {\n        pos += 12;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        casemapping = irc_server_search_casemapping (pos);\n        if (casemapping >= 0)\n            server->casemapping = casemapping;\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save chantypes *\/\n    pos = strstr (argv_eol[3], \"CHANTYPES=\");\n    if (pos)\n    {\n        pos += 10;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        if (server->chantypes)\n            free (server->chantypes);\n        server->chantypes = strdup (pos);\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save chanmodes *\/\n    pos = strstr (argv_eol[3], \"CHANMODES=\");\n    if (pos)\n    {\n        pos += 10;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        if (server->chanmodes)\n            free (server->chanmodes);\n        server->chanmodes = strdup (pos);\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save monitor (limit) *\/\n    pos = strstr (argv_eol[3], \"MONITOR=\");\n    if (pos)\n    {\n        pos += 8;\n        pos2 = strchr (pos, ' ');\n        if (pos2)\n            pos2[0] = '\\0';\n        error = NULL;\n        value = strtol (pos, &error, 10);\n        if (error && !error[0] && (value > 0))\n            server->monitor = (int)value;\n        if (pos2)\n            pos2[0] = ' ';\n    }\n\n    \/* save whole message (concatenate to existing isupport, if any) *\/\n    pos_start = NULL;\n    pos = strstr (argv_eol[3], \" :\");\n    length = (pos) ? pos - argv_eol[3] : (int)strlen (argv_eol[3]);\n    if (server->isupport)\n    {\n        length_isupport = strlen (server->isupport);\n        isupport2 = realloc (server->isupport,\n                             length_isupport + \/* existing *\/\n                             1 + length + 1); \/* new *\/\n        if (isupport2)\n        {\n            server->isupport = isupport2;\n            pos_start = server->isupport + length_isupport;\n        }\n    }\n    else\n    {\n        server->isupport = malloc (1 + length + 1);\n        if (server->isupport)\n            pos_start = server->isupport;\n    }\n\n    if (pos_start)\n    {\n        pos_start[0] = ' ';\n        memcpy (pos_start + 1, argv_eol[3], length);\n        pos_start[length + 1] = '\\0';\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":1246,"total_token_length":1482,"max_tokens_setting":2048}
+{"idx":459116,"func":"static int tc_get_tfilter(struct sk_buff *skb, struct nlmsghdr *n,\n\t\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct nlattr *tca[TCA_MAX + 1];\n\tchar name[IFNAMSIZ];\n\tstruct tcmsg *t;\n\tu32 protocol;\n\tu32 prio;\n\tu32 parent;\n\tu32 chain_index;\n\tstruct Qdisc *q = NULL;\n\tstruct tcf_chain_info chain_info;\n\tstruct tcf_chain *chain = NULL;\n\tstruct tcf_block *block = NULL;\n\tstruct tcf_proto *tp = NULL;\n\tunsigned long cl = 0;\n\tvoid *fh = NULL;\n\tint err;\n\tbool rtnl_held = false;\n\n\terr = nlmsg_parse_deprecated(n, sizeof(*t), tca, TCA_MAX,\n\t\t\t\t     rtm_tca_policy, extack);\n\tif (err < 0)\n\t\treturn err;\n\n\tt = nlmsg_data(n);\n\tprotocol = TC_H_MIN(t->tcm_info);\n\tprio = TC_H_MAJ(t->tcm_info);\n\tparent = t->tcm_parent;\n\n\tif (prio == 0) {\n\t\tNL_SET_ERR_MSG(extack, \"Invalid filter command with priority of zero\");\n\t\treturn -ENOENT;\n\t}\n\n\t\/* Find head of filter chain. *\/\n\n\terr = __tcf_qdisc_find(net, &q, &parent, t->tcm_ifindex, false, extack);\n\tif (err)\n\t\treturn err;\n\n\tif (tcf_proto_check_kind(tca[TCA_KIND], name)) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified TC filter name too long\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\t\/* Take rtnl mutex if block is shared (no qdisc found), qdisc is not\n\t * unlocked, classifier type is not specified, classifier is not\n\t * unlocked.\n\t *\/\n\tif ((q && !(q->ops->cl_ops->flags & QDISC_CLASS_OPS_DOIT_UNLOCKED)) ||\n\t    !tcf_proto_is_unlocked(name)) {\n\t\trtnl_held = true;\n\t\trtnl_lock();\n\t}\n\n\terr = __tcf_qdisc_cl_find(q, parent, &cl, t->tcm_ifindex, extack);\n\tif (err)\n\t\tgoto errout;\n\n\tblock = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index,\n\t\t\t\t extack);\n\tif (IS_ERR(block)) {\n\t\terr = PTR_ERR(block);\n\t\tgoto errout;\n\t}\n\n\tchain_index = tca[TCA_CHAIN] ? nla_get_u32(tca[TCA_CHAIN]) : 0;\n\tif (chain_index > TC_ACT_EXT_VAL_MASK) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified chain index exceeds upper limit\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\tchain = tcf_chain_get(block, chain_index, false);\n\tif (!chain) {\n\t\tNL_SET_ERR_MSG(extack, \"Cannot find specified filter chain\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\n\tmutex_lock(&chain->filter_chain_lock);\n\ttp = tcf_chain_tp_find(chain, &chain_info, protocol,\n\t\t\t       prio, false);\n\tmutex_unlock(&chain->filter_chain_lock);\n\tif (!tp || IS_ERR(tp)) {\n\t\tNL_SET_ERR_MSG(extack, \"Filter with specified priority\/protocol not found\");\n\t\terr = tp ? PTR_ERR(tp) : -ENOENT;\n\t\tgoto errout;\n\t} else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified filter kind does not match existing one\");\n\t\terr = -EINVAL;\n\t\tgoto errout;\n\t}\n\n\tfh = tp->ops->get(tp, t->tcm_handle);\n\n\tif (!fh) {\n\t\tNL_SET_ERR_MSG(extack, \"Specified filter handle not found\");\n\t\terr = -ENOENT;\n\t} else {\n\t\terr = tfilter_notify(net, skb, n, tp, block, q, parent,\n\t\t\t\t     fh, RTM_NEWTFILTER, true, rtnl_held);\n\t\tif (err < 0)\n\t\t\tNL_SET_ERR_MSG(extack, \"Failed to send filter notify message\");\n\t}\n\n\ttfilter_put(tp, fh);\nerrout:\n\tif (chain) {\n\t\tif (tp && !IS_ERR(tp))\n\t\t\ttcf_proto_put(tp, rtnl_held, NULL);\n\t\ttcf_chain_put(chain);\n\t}\n\ttcf_block_release(q, block, rtnl_held);\n\n\tif (rtnl_held)\n\t\trtnl_unlock();\n\n\treturn err;\n}","target":0,"code_token_length":1002,"total_token_length":1238,"max_tokens_setting":2048}
+{"idx":238809,"func":"searchc(cmdarg_T *cap, int t_cmd)\n{\n    int\t\t\tc = cap->nchar;\t\/\/ char to search for\n    int\t\t\tdir = cap->arg;\t\/\/ TRUE for searching forward\n    long\t\tcount = cap->count1;\t\/\/ repeat count\n    int\t\t\tcol;\n    char_u\t\t*p;\n    int\t\t\tlen;\n    int\t\t\tstop = TRUE;\n\n    if (c != NUL)\t\/\/ normal search: remember args for repeat\n    {\n\tif (!KeyStuffed)    \/\/ don't remember when redoing\n\t{\n\t    *lastc = c;\n\t    set_csearch_direction(dir);\n\t    set_csearch_until(t_cmd);\n\t    lastc_bytelen = (*mb_char2bytes)(c, lastc_bytes);\n\t    if (cap->ncharC1 != 0)\n\t    {\n\t\tlastc_bytelen += (*mb_char2bytes)(cap->ncharC1,\n\t\t\tlastc_bytes + lastc_bytelen);\n\t\tif (cap->ncharC2 != 0)\n\t\t    lastc_bytelen += (*mb_char2bytes)(cap->ncharC2,\n\t\t\t    lastc_bytes + lastc_bytelen);\n\t    }\n\t}\n    }\n    else\t\t\/\/ repeat previous search\n    {\n\tif (*lastc == NUL && lastc_bytelen == 1)\n\t    return FAIL;\n\tif (dir)\t\/\/ repeat in opposite direction\n\t    dir = -lastcdir;\n\telse\n\t    dir = lastcdir;\n\tt_cmd = last_t_cmd;\n\tc = *lastc;\n\t\/\/ For multi-byte re-use last lastc_bytes[] and lastc_bytelen.\n\n\t\/\/ Force a move of at least one char, so \";\" and \",\" will move the\n\t\/\/ cursor, even if the cursor is right in front of char we are looking\n\t\/\/ at.\n\tif (vim_strchr(p_cpo, CPO_SCOLON) == NULL && count == 1 && t_cmd)\n\t    stop = FALSE;\n    }\n\n    if (dir == BACKWARD)\n\tcap->oap->inclusive = FALSE;\n    else\n\tcap->oap->inclusive = TRUE;\n\n    p = ml_get_curline();\n    col = curwin->w_cursor.col;\n    len = (int)STRLEN(p);\n\n    while (count--)\n    {\n\tif (has_mbyte)\n\t{\n\t    for (;;)\n\t    {\n\t\tif (dir > 0)\n\t\t{\n\t\t    col += (*mb_ptr2len)(p + col);\n\t\t    if (col >= len)\n\t\t\treturn FAIL;\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (col == 0)\n\t\t\treturn FAIL;\n\t\t    col -= (*mb_head_off)(p, p + col - 1) + 1;\n\t\t}\n\t\tif (lastc_bytelen == 1)\n\t\t{\n\t\t    if (p[col] == c && stop)\n\t\t\tbreak;\n\t\t}\n\t\telse if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0\n\t\t\t\t\t\t\t\t       && stop)\n\t\t    break;\n\t\tstop = TRUE;\n\t    }\n\t}\n\telse\n\t{\n\t    for (;;)\n\t    {\n\t\tif ((col += dir) < 0 || col >= len)\n\t\t    return FAIL;\n\t\tif (p[col] == c && stop)\n\t\t    break;\n\t\tstop = TRUE;\n\t    }\n\t}\n    }\n\n    if (t_cmd)\n    {\n\t\/\/ backup to before the character (possibly double-byte)\n\tcol -= dir;\n\tif (has_mbyte)\n\t{\n\t    if (dir < 0)\n\t\t\/\/ Landed on the search char which is lastc_bytelen long\n\t\tcol += lastc_bytelen - 1;\n\t    else\n\t\t\/\/ To previous char, which may be multi-byte.\n\t\tcol -= (*mb_head_off)(p, p + col);\n\t}\n    }\n    curwin->w_cursor.col = col;\n\n    return OK;\n}","target":0,"code_token_length":831,"total_token_length":1067,"max_tokens_setting":2048}
+{"idx":372861,"func":"static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,\n\t\t\t       struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct irda_sock *self = irda_sk(sk);\n\tint noblock = flags & MSG_DONTWAIT;\n\tsize_t copied = 0;\n\tint target, err;\n\tlong timeo;\n\n\tIRDA_DEBUG(3, \"%s()\\n\", __func__);\n\n\tif ((err = sock_error(sk)) < 0)\n\t\treturn err;\n\n\tif (sock->flags & __SO_ACCEPTCON)\n\t\treturn -EINVAL;\n\n\terr =-EOPNOTSUPP;\n\tif (flags & MSG_OOB)\n\t\treturn -EOPNOTSUPP;\n\n\terr = 0;\n\ttarget = sock_rcvlowat(sk, flags & MSG_WAITALL, size);\n\ttimeo = sock_rcvtimeo(sk, noblock);\n\n\tmsg->msg_namelen = 0;\n\n\tdo {\n\t\tint chunk;\n\t\tstruct sk_buff *skb = skb_dequeue(&sk->sk_receive_queue);\n\n\t\tif (skb == NULL) {\n\t\t\tDEFINE_WAIT(wait);\n\t\t\terr = 0;\n\n\t\t\tif (copied >= target)\n\t\t\t\tbreak;\n\n\t\t\tprepare_to_wait_exclusive(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);\n\n\t\t\t\/*\n\t\t\t *\tPOSIX 1003.1g mandates this order.\n\t\t\t *\/\n\t\t\terr = sock_error(sk);\n\t\t\tif (err)\n\t\t\t\t;\n\t\t\telse if (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\t;\n\t\t\telse if (noblock)\n\t\t\t\terr = -EAGAIN;\n\t\t\telse if (signal_pending(current))\n\t\t\t\terr = sock_intr_errno(timeo);\n\t\t\telse if (sk->sk_state != TCP_ESTABLISHED)\n\t\t\t\terr = -ENOTCONN;\n\t\t\telse if (skb_peek(&sk->sk_receive_queue) == NULL)\n\t\t\t\t\/* Wait process until data arrives *\/\n\t\t\t\tschedule();\n\n\t\t\tfinish_wait(sk_sleep(sk), &wait);\n\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\tbreak;\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tchunk = min_t(unsigned int, skb->len, size);\n\t\tif (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {\n\t\t\tskb_queue_head(&sk->sk_receive_queue, skb);\n\t\t\tif (copied == 0)\n\t\t\t\tcopied = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\tcopied += chunk;\n\t\tsize -= chunk;\n\n\t\t\/* Mark read part of skb as used *\/\n\t\tif (!(flags & MSG_PEEK)) {\n\t\t\tskb_pull(skb, chunk);\n\n\t\t\t\/* put the skb back if we didn't use it up.. *\/\n\t\t\tif (skb->len) {\n\t\t\t\tIRDA_DEBUG(1, \"%s(), back on q!\\n\",\n\t\t\t\t\t   __func__);\n\t\t\t\tskb_queue_head(&sk->sk_receive_queue, skb);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tkfree_skb(skb);\n\t\t} else {\n\t\t\tIRDA_DEBUG(0, \"%s() questionable!?\\n\", __func__);\n\n\t\t\t\/* put message back and return *\/\n\t\t\tskb_queue_head(&sk->sk_receive_queue, skb);\n\t\t\tbreak;\n\t\t}\n\t} while (size);\n\n\t\/*\n\t *  Check if we have previously stopped IrTTP and we know\n\t *  have more free space in our rx_queue. If so tell IrTTP\n\t *  to start delivering frames again before our rx_queue gets\n\t *  empty\n\t *\/\n\tif (self->rx_flow == FLOW_STOP) {\n\t\tif ((atomic_read(&sk->sk_rmem_alloc) << 2) <= sk->sk_rcvbuf) {\n\t\t\tIRDA_DEBUG(2, \"%s(), Starting IrTTP\\n\", __func__);\n\t\t\tself->rx_flow = FLOW_START;\n\t\t\tirttp_flow_request(self->tsap, FLOW_START);\n\t\t}\n\t}\n\n\treturn copied;\n}","target":0,"code_token_length":848,"total_token_length":1084,"max_tokens_setting":2048}
+{"idx":212095,"func":"MOBI_RET mobi_reconstruct_infl(char *outstring, const MOBIIndx *infl, const MOBIIndexEntry *orth_entry) {\n    const char *label = orth_entry->label;\n    uint32_t *infl_groups = NULL;\n    size_t infl_count = mobi_get_indxentry_tagarray(&infl_groups, orth_entry, INDX_TAGARR_ORTH_INFL);\n    \n    if (infl_count == 0 || !infl_groups) {\n        return MOBI_SUCCESS;\n    }    \n    const char *start_tag = \"<idx:infl>\";\n    const char *end_tag = \"<\/idx:infl>\";\n    const char *iform_tag = \"<idx:iform%s value=\\\"%s\\\"\/>\";\n    char name_attr[INDX_INFLBUF_SIZEMAX + 1];\n    char infl_tag[INDX_INFLBUF_SIZEMAX + 1];\n    strcpy(outstring, start_tag);\n    size_t initlen = strlen(start_tag) + strlen(end_tag);\n    size_t outlen = initlen;\n    size_t label_length = strlen(label);\n    if (label_length > INDX_INFLBUF_SIZEMAX) {\n        debug_print(\"Entry label too long (%s)\\n\", label);\n        return MOBI_DATA_CORRUPT;\n    }\n    if (infl->cncx_record == NULL) {\n        debug_print(\"%s\\n\", \"Missing cncx record\");\n        return MOBI_DATA_CORRUPT;\n    }\n    for (size_t i = 0; i < infl_count; i++) {\n        size_t offset = infl_groups[i];\n        if (offset >= infl->entries_count) {\n            debug_print(\"%s\\n\", \"Invalid entry offset\");\n            return MOBI_DATA_CORRUPT;\n        }\n        uint32_t *groups;\n        size_t group_cnt = mobi_get_indxentry_tagarray(&groups, &infl->entries[offset], INDX_TAGARR_INFL_GROUPS);\n        uint32_t *parts;\n        size_t part_cnt = mobi_get_indxentry_tagarray(&parts, &infl->entries[offset], INDX_TAGARR_INFL_PARTS_V2);\n        if (group_cnt != part_cnt) {\n            return MOBI_DATA_CORRUPT;\n        }\n        for (size_t j = 0; j < part_cnt; j++) {\n            name_attr[0] = '\\0';\n            char *group_name = mobi_get_cncx_string(infl->cncx_record, groups[j]);\n            if (group_name == NULL) {\n                debug_print(\"%s\\n\", \"Memory allocation failed\");\n                return MOBI_MALLOC_FAILED;\n            }\n            if (strlen(group_name)) {\n                snprintf(name_attr, INDX_INFLBUF_SIZEMAX, \" name=\\\"%s\\\"\", group_name);\n            }\n            free(group_name);\n            \n            unsigned char decoded[INDX_INFLBUF_SIZEMAX + 1];\n            memset(decoded, 0, INDX_INFLBUF_SIZEMAX + 1);\n            unsigned char *rule = (unsigned char *) infl->entries[parts[j]].label;\n            memcpy(decoded, label, label_length);\n            int decoded_length = (int) label_length;\n            MOBI_RET ret = mobi_decode_infl(decoded, &decoded_length, rule);\n            if (ret != MOBI_SUCCESS) {\n                return ret;\n            }\n            if (decoded_length == 0) {\n                continue;\n            }\n            int n = snprintf(infl_tag, INDX_INFLBUF_SIZEMAX, iform_tag, name_attr, decoded);\n            if (n > INDX_INFLBUF_SIZEMAX) {\n                debug_print(\"Skipping truncated tag: %s\\n\", infl_tag);\n                continue;\n            }\n            outlen += strlen(infl_tag);\n            if (outlen > INDX_INFLTAG_SIZEMAX) {\n                debug_print(\"Inflections text in %s too long (%zu)\\n\", label, outlen);\n                return MOBI_ERROR;\n            }\n            strcat(outstring, infl_tag);\n        }\n    }\n    if (outlen == initlen) {\n        outstring[0] = '\\0';\n    } else {\n        strcat(outstring, end_tag);\n    }\n    return MOBI_SUCCESS;\n}","target":1,"code_token_length":898,"total_token_length":1134,"max_tokens_setting":2048}
+{"idx":253545,"func":"smb2_make_node(unsigned int xid, struct inode *inode,\n\t       struct dentry *dentry, struct cifs_tcon *tcon,\n\t       const char *full_path, umode_t mode, dev_t dev)\n{\n\tstruct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);\n\tint rc = -EPERM;\n\tFILE_ALL_INFO *buf = NULL;\n\tstruct cifs_io_parms io_parms = {0};\n\t__u32 oplock = 0;\n\tstruct cifs_fid fid;\n\tstruct cifs_open_parms oparms;\n\tunsigned int bytes_written;\n\tstruct win_dev *pdev;\n\tstruct kvec iov[2];\n\n\t\/*\n\t * Check if mounted with mount parm 'sfu' mount parm.\n\t * SFU emulation should work with all servers, but only\n\t * supports block and char device (no socket & fifo),\n\t * and was used by default in earlier versions of Windows\n\t *\/\n\tif (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))\n\t\tgoto out;\n\n\t\/*\n\t * TODO: Add ability to create instead via reparse point. Windows (e.g.\n\t * their current NFS server) uses this approach to expose special files\n\t * over SMB2\/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions\n\t *\/\n\n\tif (!S_ISCHR(mode) && !S_ISBLK(mode))\n\t\tgoto out;\n\n\tcifs_dbg(FYI, \"sfu compat create special file\\n\");\n\n\tbuf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);\n\tif (buf == NULL) {\n\t\trc = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\toparms.tcon = tcon;\n\toparms.cifs_sb = cifs_sb;\n\toparms.desired_access = GENERIC_WRITE;\n\toparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR |\n\t\t\t\t\t\t    CREATE_OPTION_SPECIAL);\n\toparms.disposition = FILE_CREATE;\n\toparms.path = full_path;\n\toparms.fid = &fid;\n\toparms.reconnect = false;\n\n\tif (tcon->ses->server->oplocks)\n\t\toplock = REQ_OPLOCK;\n\telse\n\t\toplock = 0;\n\trc = tcon->ses->server->ops->open(xid, &oparms, &oplock, buf);\n\tif (rc)\n\t\tgoto out;\n\n\t\/*\n\t * BB Do not bother to decode buf since no local inode yet to put\n\t * timestamps in, but we can reuse it safely.\n\t *\/\n\n\tpdev = (struct win_dev *)buf;\n\tio_parms.pid = current->tgid;\n\tio_parms.tcon = tcon;\n\tio_parms.offset = 0;\n\tio_parms.length = sizeof(struct win_dev);\n\tiov[1].iov_base = buf;\n\tiov[1].iov_len = sizeof(struct win_dev);\n\tif (S_ISCHR(mode)) {\n\t\tmemcpy(pdev->type, \"IntxCHR\", 8);\n\t\tpdev->major = cpu_to_le64(MAJOR(dev));\n\t\tpdev->minor = cpu_to_le64(MINOR(dev));\n\t\trc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,\n\t\t\t\t\t\t\t&bytes_written, iov, 1);\n\t} else if (S_ISBLK(mode)) {\n\t\tmemcpy(pdev->type, \"IntxBLK\", 8);\n\t\tpdev->major = cpu_to_le64(MAJOR(dev));\n\t\tpdev->minor = cpu_to_le64(MINOR(dev));\n\t\trc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,\n\t\t\t\t\t\t\t&bytes_written, iov, 1);\n\t}\n\ttcon->ses->server->ops->close(xid, tcon, &fid);\n\td_drop(dentry);\n\n\t\/* FIXME: add code here to set EAs *\/\nout:\n\tkfree(buf);\n\treturn rc;\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048}
+{"idx":259081,"func":"void RestoreTensor(OpKernelContext* context,\n                   checkpoint::TensorSliceReader::OpenTableFunction open_func,\n                   int preferred_shard, bool restore_slice, int restore_index) {\n  const Tensor& file_pattern_t = context->input(0);\n  {\n    const int64_t size = file_pattern_t.NumElements();\n    OP_REQUIRES(\n        context, size == 1,\n        errors::InvalidArgument(\n            \"Input 0 (file_pattern) must be a string scalar; got a tensor of \",\n            size, \" elements\"));\n  }\n  const string& file_pattern = file_pattern_t.flat<tstring>()(0);\n\n  const Tensor& tensor_name_t = context->input(1);\n  {\n    const int64_t size = tensor_name_t.NumElements();\n    OP_REQUIRES(context, size > restore_index,\n                errors::InvalidArgument(\n                    \"Input 1 (file_pattern) must be a have at least \",\n                    restore_index + 1, \" elements\"));\n  }\n  const string& tensor_name = tensor_name_t.flat<tstring>()(restore_index);\n\n  \/\/ If we cannot find a cached reader we will allocate our own.\n  std::unique_ptr<checkpoint::TensorSliceReader> allocated_reader;\n\n  const checkpoint::TensorSliceReader* reader = nullptr;\n\n  if (context->slice_reader_cache()) {\n    reader = context->slice_reader_cache()->GetReader(file_pattern, open_func,\n                                                      preferred_shard);\n  }\n  if (!reader) {\n    allocated_reader.reset(new checkpoint::TensorSliceReader(\n        file_pattern, open_func, preferred_shard));\n    reader = allocated_reader.get();\n  }\n  OP_REQUIRES_OK(context, CHECK_NOTNULL(reader)->status());\n\n  \/\/ Get the shape and type from the save file.\n  DataType type;\n  TensorShape saved_shape;\n  OP_REQUIRES(\n      context, reader->HasTensor(tensor_name, &saved_shape, &type),\n      errors::NotFound(\"Tensor name \\\"\", tensor_name,\n                       \"\\\" not found in checkpoint files \", file_pattern));\n  OP_REQUIRES(\n      context, type == context->expected_output_dtype(restore_index),\n      errors::InvalidArgument(\"Expected to restore a tensor of type \",\n                              DataTypeString(context->expected_output_dtype(0)),\n                              \", got a tensor of type \", DataTypeString(type),\n                              \" instead: tensor_name = \", tensor_name));\n\n  \/\/ Shape of the output and slice to load.\n  TensorShape output_shape(saved_shape);\n  TensorSlice slice_to_load(saved_shape.dims());\n  if (restore_slice) {\n    const tstring& shape_spec =\n        context->input(2).flat<tstring>()(restore_index);\n    if (!shape_spec.empty()) {\n      TensorShape parsed_shape;\n      OP_REQUIRES_OK(context, checkpoint::ParseShapeAndSlice(\n                                  shape_spec, &parsed_shape, &slice_to_load,\n                                  &output_shape));\n      OP_REQUIRES(\n          context, parsed_shape.IsSameSize(saved_shape),\n          errors::InvalidArgument(\n              \"Shape in shape_and_slice spec does not match the shape in the \"\n              \"save file: \",\n              parsed_shape.DebugString(),\n              \", save file shape: \", saved_shape.DebugString()));\n    }\n  }\n\n  Tensor* t = nullptr;\n  OP_REQUIRES_OK(context,\n                 context->allocate_output(restore_index, output_shape, &t));\n\n  if (output_shape.num_elements() == 0) return;\n\n#define READER_COPY(T)                                                \\\n  case DataTypeToEnum<T>::value:                                      \\\n    OP_REQUIRES(context,                                              \\\n                reader->CopySliceData(tensor_name, slice_to_load,     \\\n                                      t->flat<T>().data()),           \\\n                errors::InvalidArgument(\"Error copying slice data\")); \\\n    break;\n\n  switch (type) {\n    TF_CALL_SAVE_RESTORE_TYPES(READER_COPY)\n    default:\n      context->SetStatus(errors::Unimplemented(\n          \"Restoring data type \", DataTypeString(type), \" not yet supported\"));\n  }\n#undef READER_COPY\n}","target":0,"code_token_length":822,"total_token_length":1058,"max_tokens_setting":2048}
+{"idx":450434,"func":"static int zrle_send_framebuffer_update(VncState *vs, int x, int y,\n                                        int w, int h)\n{\n    bool be = vs->client_be;\n    size_t bytes;\n    int zywrle_level;\n\n    if (vs->zrle->type == VNC_ENCODING_ZYWRLE) {\n        if (!vs->vd->lossy || vs->tight->quality == (uint8_t)-1\n            || vs->tight->quality == 9) {\n            zywrle_level = 0;\n            vs->zrle->type = VNC_ENCODING_ZRLE;\n        } else if (vs->tight->quality < 3) {\n            zywrle_level = 3;\n        } else if (vs->tight->quality < 6) {\n            zywrle_level = 2;\n        } else {\n            zywrle_level = 1;\n        }\n    } else {\n        zywrle_level = 0;\n    }\n\n    vnc_zrle_start(vs);\n\n    switch (vs->client_pf.bytes_per_pixel) {\n    case 1:\n        zrle_encode_8ne(vs, x, y, w, h, zywrle_level);\n        break;\n\n    case 2:\n        if (vs->client_pf.gmax > 0x1F) {\n            if (be) {\n                zrle_encode_16be(vs, x, y, w, h, zywrle_level);\n            } else {\n                zrle_encode_16le(vs, x, y, w, h, zywrle_level);\n            }\n        } else {\n            if (be) {\n                zrle_encode_15be(vs, x, y, w, h, zywrle_level);\n            } else {\n                zrle_encode_15le(vs, x, y, w, h, zywrle_level);\n            }\n        }\n        break;\n\n    case 4:\n    {\n        bool fits_in_ls3bytes;\n        bool fits_in_ms3bytes;\n\n        fits_in_ls3bytes =\n            ((vs->client_pf.rmax << vs->client_pf.rshift) < (1 << 24) &&\n             (vs->client_pf.gmax << vs->client_pf.gshift) < (1 << 24) &&\n             (vs->client_pf.bmax << vs->client_pf.bshift) < (1 << 24));\n\n        fits_in_ms3bytes = (vs->client_pf.rshift > 7 &&\n                            vs->client_pf.gshift > 7 &&\n                            vs->client_pf.bshift > 7);\n\n        if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) {\n            if (be) {\n                zrle_encode_24abe(vs, x, y, w, h, zywrle_level);\n            } else {\n                zrle_encode_24ale(vs, x, y, w, h, zywrle_level);\n          }\n        } else if ((fits_in_ls3bytes && be) || (fits_in_ms3bytes && !be)) {\n            if (be) {\n                zrle_encode_24bbe(vs, x, y, w, h, zywrle_level);\n            } else {\n                zrle_encode_24ble(vs, x, y, w, h, zywrle_level);\n            }\n        } else {\n            if (be) {\n                zrle_encode_32be(vs, x, y, w, h, zywrle_level);\n            } else {\n                zrle_encode_32le(vs, x, y, w, h, zywrle_level);\n            }\n        }\n    }\n    break;\n    }\n\n    vnc_zrle_stop(vs);\n    bytes = zrle_compress_data(vs, Z_DEFAULT_COMPRESSION);\n    vnc_framebuffer_update(vs, x, y, w, h, vs->zrle->type);\n    vnc_write_u32(vs, bytes);\n    vnc_write(vs, vs->zrle->zlib.buffer, vs->zrle->zlib.offset);\n    return 1;\n}","target":0,"code_token_length":904,"total_token_length":1140,"max_tokens_setting":2048}
+{"idx":256414,"func":"PJ_DEF(void) pjmedia_rtcp_rx_rtp2(pjmedia_rtcp_session *sess, \n\t\t\t\t  unsigned seq, \n\t\t\t\t  unsigned rtp_ts,\n\t\t\t\t  unsigned payload,\n\t\t\t\t  pj_bool_t discarded)\n{   \n    pj_timestamp ts;\n    pj_uint32_t arrival;\n    pj_int32_t transit;\n    pjmedia_rtp_status seq_st;\n\n#if !defined(PJMEDIA_HAS_RTCP_XR) || (PJMEDIA_HAS_RTCP_XR == 0)\n    PJ_UNUSED_ARG(discarded);\n#endif\n\n    if (sess->stat.rx.pkt == 0) {\n\t\/* Init sequence for the first time. *\/\n\tpjmedia_rtp_seq_init(&sess->seq_ctrl, (pj_uint16_t)seq);\n    } \n\n    sess->stat.rx.pkt++;\n    sess->stat.rx.bytes += payload;\n\n    \/* Process the RTP packet. *\/\n    pjmedia_rtp_seq_update(&sess->seq_ctrl, (pj_uint16_t)seq, &seq_st);\n\n    if (seq_st.status.flag.restart) {\n\trtcp_init_seq(sess);\n    }\n    \n    if (seq_st.status.flag.dup) {\n\tsess->stat.rx.dup++;\n\tTRACE_((sess->name, \"Duplicate packet detected\"));\n    }\n\n    if (seq_st.status.flag.outorder && !seq_st.status.flag.probation) {\n\tsess->stat.rx.reorder++;\n\tTRACE_((sess->name, \"Out-of-order packet detected\"));\n    }\n\n    if (seq_st.status.flag.bad) {\n\tsess->stat.rx.discard++;\n\n#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)\n\tpjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq, \n\t\t\t       -1,\t\t\t\t \/* lost    *\/\n\t\t\t       (seq_st.status.flag.dup? 1:0),\t \/* dup     *\/\n\t\t\t       (!seq_st.status.flag.dup? 1:-1),  \/* discard *\/\n\t\t\t       -1,\t\t\t\t \/* jitter  *\/\n\t\t\t       -1, 0);\t\t\t\t \/* toh\t    *\/\n#endif\n\n\tTRACE_((sess->name, \"Bad packet discarded\"));\n\treturn;\n    }\n\n    \/* Only mark \"good\" packets *\/\n    ++sess->received;\n\n    \/* Calculate loss periods. *\/\n    if (seq_st.diff > 1) {\n\tunsigned count = seq_st.diff - 1;\n\tunsigned period;\n\n\tperiod = count * sess->pkt_size * 1000 \/ sess->clock_rate;\n\tperiod *= 1000;\n\n\t\/* Update packet lost. \n\t * The packet lost number will also be updated when we're sending\n\t * outbound RTCP RR.\n\t *\/\n\tsess->stat.rx.loss += (seq_st.diff - 1);\n\tTRACE_((sess->name, \"%d packet(s) lost\", seq_st.diff - 1));\n\n\t\/* Update loss period stat *\/\n\tpj_math_stat_update(&sess->stat.rx.loss_period, period);\n    }\n\n\n    \/*\n     * Calculate jitter only when sequence is good (see RFC 3550 section A.8),\n     * AND only when the timestamp is different than the last packet\n     * (see RTP FAQ).\n     *\/\n    if (seq_st.diff == 1 && rtp_ts != sess->rtp_last_ts) {\n\t\/* Get arrival time and convert timestamp to samples *\/\n\tpj_get_timestamp(&ts);\n\tts.u64 = ts.u64 * sess->clock_rate \/ sess->ts_freq.u64;\n\tarrival = ts.u32.lo;\n\n\ttransit = arrival - rtp_ts;\n    \n\t\/* Ignore the first N packets as they normally have bad jitter\n\t * due to other threads working to establish the call\n\t *\/\n\tif (sess->transit == 0 || \n\t    sess->received < PJMEDIA_RTCP_IGNORE_FIRST_PACKETS) \n\t{\n\t    sess->transit = transit;\n\t    sess->stat.rx.jitter.min = (unsigned)-1;\n\t} else {\n\t    pj_int32_t d;\n\t    pj_uint32_t jitter;\n\n\t    d = transit - sess->transit;\n\t    if (d < 0) \n\t\td = -d;\n\t    \n\t    sess->jitter += d - ((sess->jitter + 8) >> 4);\n\n\t    \/* Update jitter stat *\/\n\t    jitter = sess->jitter >> 4;\n\t    \n\t    \/* Convert jitter unit from samples to usec *\/\n\t    if (jitter < 4294)\n\t\tjitter = jitter * 1000000 \/ sess->clock_rate;\n\t    else {\n\t\tjitter = jitter * 1000 \/ sess->clock_rate;\n\t\tjitter *= 1000;\n\t    }\n\t    pj_math_stat_update(&sess->stat.rx.jitter, jitter);\n\n\n#if defined(PJMEDIA_RTCP_STAT_HAS_RAW_JITTER) && PJMEDIA_RTCP_STAT_HAS_RAW_JITTER!=0\n\t    {\n\t\tpj_uint32_t raw_jitter;\n\n\t\t\/* Convert raw jitter unit from samples to usec *\/\n\t\tif (d < 4294)\n\t\t    raw_jitter = d * 1000000 \/ sess->clock_rate;\n\t\telse {\n\t\t    raw_jitter = d * 1000 \/ sess->clock_rate;\n\t\t    raw_jitter *= 1000;\n\t\t}\n\t\t\n\t\t\/* Update jitter stat *\/\n\t\tpj_math_stat_update(&sess->stat.rx_raw_jitter, raw_jitter);\n\t    }\n#endif\n\n\n#if defined(PJMEDIA_RTCP_STAT_HAS_IPDV) && PJMEDIA_RTCP_STAT_HAS_IPDV!=0\n\t    {\n\t\tpj_int32_t ipdv;\n\n\t\tipdv = transit - sess->transit;\n\t\t\/* Convert IPDV unit from samples to usec *\/\n\t\tif (ipdv > -2147 && ipdv < 2147)\n\t\t    ipdv = ipdv * 1000000 \/ (int)sess->clock_rate;\n\t\telse {\n\t\t    ipdv = ipdv * 1000 \/ (int)sess->clock_rate;\n\t\t    ipdv *= 1000;\n\t\t}\n\t\t\n\t\t\/* Update jitter stat *\/\n\t\tpj_math_stat_update(&sess->stat.rx_ipdv, ipdv);\n\t    }\n#endif\n\n#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)\n\t    pjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq, \n\t\t\t\t   0,\t\t\t    \/* lost    *\/\n\t\t\t\t   0,\t\t\t    \/* dup     *\/\n\t\t\t\t   discarded,\t\t    \/* discard *\/\n\t\t\t\t   (sess->jitter >> 4),\t    \/* jitter  *\/\n\t\t\t\t   -1, 0);\t\t    \/* toh     *\/\n#endif\n\n\t    \/* Update session transit *\/\n\t    sess->transit = transit;\n\t}\n#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)\n    } else if (seq_st.diff > 1) {\n\tint i;\n\n\t\/* Report RTCP XR about packet losses *\/\n\tfor (i=seq_st.diff-1; i>0; --i) {\n\t    pjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq - i, \n\t\t\t\t   1,\t\t\t    \/* lost    *\/\n\t\t\t\t   0,\t\t\t    \/* dup     *\/\n\t\t\t\t   0,\t\t\t    \/* discard *\/\n\t\t\t\t   -1,\t\t\t    \/* jitter  *\/\n\t\t\t\t   -1, 0);\t\t    \/* toh     *\/\n\t}\n\n\t\/* Report RTCP XR this packet *\/\n\tpjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq, \n\t\t\t       0,\t\t\t    \/* lost    *\/\n\t\t\t       0,\t\t\t    \/* dup     *\/\n\t\t\t       discarded,\t\t    \/* discard *\/\n\t\t\t       -1,\t\t\t    \/* jitter  *\/\n\t\t\t       -1, 0);\t\t\t    \/* toh     *\/\n#endif\n    }\n\n    \/* Update timestamp of last RX RTP packet *\/\n    sess->rtp_last_ts = rtp_ts;\n}","target":0,"code_token_length":1673,"total_token_length":1909,"max_tokens_setting":2048}
+{"idx":376355,"func":"gpg_ctx_op_step (struct _GpgCtx *gpg,\n                 GCancellable *cancellable,\n                 GError **error)\n{\n#ifndef G_OS_WIN32\n\tGPollFD polls[6];\n\tgint status, i;\n\tgboolean read_data = FALSE, wrote_data = FALSE;\n\n\tfor (i = 0; i < 6; i++) {\n\t\tpolls[i].fd = -1;\n\t\tpolls[i].events = 0;\n\t}\n\n\tif (!gpg->seen_eof1) {\n\t\tpolls[0].fd = gpg->stdout_fd;\n\t\tpolls[0].events = G_IO_IN;\n\t}\n\n\tif (!gpg->seen_eof2) {\n\t\tpolls[1].fd = gpg->stderr_fd;\n\t\tpolls[1].events = G_IO_IN;\n\t}\n\n\tif (!gpg->complete) {\n\t\tpolls[2].fd = gpg->status_fd;\n\t\tpolls[2].events = G_IO_IN;\n\t}\n\n\tpolls[3].fd = gpg->stdin_fd;\n\tpolls[3].events = G_IO_OUT;\n\tpolls[4].fd = gpg->passwd_fd;\n\tpolls[4].events = G_IO_OUT;\n\tpolls[5].fd = g_cancellable_get_fd (cancellable);\n\tpolls[5].events = G_IO_IN;\n\n\tdo {\n\t\tfor (i = 0; i < 6; i++)\n\t\t\tpolls[i].revents = 0;\n\t\tstatus = g_poll (polls, 6, 30 * 1000);\n\t} while (status == -1 && errno == EINTR);\n\n\tif (status == 0)\n\t\treturn 0;\t\/* timed out *\/\n\telse if (status == -1)\n\t\tgoto exception;\n\n\tif ((polls[5].revents & G_IO_IN) &&\n\t\tg_cancellable_set_error_if_cancelled (cancellable, error)) {\n\n\t\tgpg_ctx_op_cancel (gpg);\n\t\treturn -1;\n\t}\n\n\t\/* Test each and every file descriptor to see if it's 'ready',\n\t * and if so - do what we can with it and then drop through to\n\t * the next file descriptor and so on until we've done what we\n\t * can to all of them. If one fails along the way, return\n\t * -1. *\/\n\n\tif (polls[2].revents & (G_IO_IN | G_IO_HUP)) {\n\t\t\/* read the status message and decide what to do... *\/\n\t\tgchar buffer[4096];\n\t\tgssize nread;\n\n\t\td (printf (\"reading from gpg's status-fd...\\n\"));\n\n\t\tdo {\n\t\t\tnread = read (gpg->status_fd, buffer, sizeof (buffer));\n\t\t} while (nread == -1 && (errno == EINTR || errno == EAGAIN));\n\t\tif (nread == -1)\n\t\t\tgoto exception;\n\n\t\tif (nread > 0) {\n\t\t\tstatus_backup (gpg, buffer, nread);\n\n\t\t\tif (gpg_ctx_parse_status (gpg, error) == -1)\n\t\t\t\treturn -1;\n\t\t} else {\n\t\t\tgpg->complete = TRUE;\n\t\t}\n\t}\n\n\tif ((polls[0].revents & (G_IO_IN | G_IO_HUP)) && gpg->ostream) {\n\t\tgchar buffer[4096];\n\t\tgssize nread;\n\n\t\td (printf (\"reading gpg's stdout...\\n\"));\n\n\t\tdo {\n\t\t\tnread = read (gpg->stdout_fd, buffer, sizeof (buffer));\n\t\t} while (nread == -1 && (errno == EINTR || errno == EAGAIN));\n\t\tif (nread == -1)\n\t\t\tgoto exception;\n\n\t\tif (nread > 0) {\n\t\t\tgsize written = camel_stream_write (\n\t\t\t\tgpg->ostream, buffer, (gsize)\n\t\t\t\tnread, cancellable, error);\n\t\t\tif (written != nread)\n\t\t\t\treturn -1;\n\t\t} else {\n\t\t\tgpg->seen_eof1 = TRUE;\n\t\t}\n\n\t\tread_data = TRUE;\n\t}\n\n\tif (polls[1].revents & (G_IO_IN | G_IO_HUP)) {\n\t\tgchar buffer[4096];\n\t\tgssize nread;\n\n\t\td (printf (\"reading gpg's stderr...\\n\"));\n\n\t\tdo {\n\t\t\tnread = read (gpg->stderr_fd, buffer, sizeof (buffer));\n\t\t} while (nread == -1 && (errno == EINTR || errno == EAGAIN));\n\t\tif (nread == -1)\n\t\t\tgoto exception;\n\n\t\tif (nread > 0) {\n\t\t\tcamel_stream_write (\n\t\t\t\tgpg->diagnostics, buffer,\n\t\t\t\tnread, cancellable, error);\n\t\t} else {\n\t\t\tgpg->seen_eof2 = TRUE;\n\t\t}\n\t}\n\n\tif ((polls[4].revents & (G_IO_OUT | G_IO_HUP)) && gpg->need_passwd && gpg->send_passwd) {\n\t\tgssize w, nwritten = 0;\n\t\tgsize n;\n\n\t\td (printf (\"sending gpg our passphrase...\\n\"));\n\n\t\t\/* send the passphrase to gpg *\/\n\t\tn = strlen (gpg->passwd);\n\t\tdo {\n\t\t\tdo {\n\t\t\t\tw = write (gpg->passwd_fd, gpg->passwd + nwritten, n - nwritten);\n\t\t\t} while (w == -1 && (errno == EINTR || errno == EAGAIN));\n\n\t\t\tif (w > 0)\n\t\t\t\tnwritten += w;\n\t\t} while (nwritten < n && w != -1);\n\n\t\t\/* zero and free our passwd buffer *\/\n\t\tmemset (gpg->passwd, 0, n);\n\t\tg_free (gpg->passwd);\n\t\tgpg->passwd = NULL;\n\n\t\tif (w == -1)\n\t\t\tgoto exception;\n\n\t\tgpg->send_passwd = FALSE;\n\t}\n\n\tif ((polls[3].revents & (G_IO_OUT | G_IO_HUP)) && gpg->istream) {\n\t\tgchar buffer[4096];\n\t\tgssize nread;\n\n\t\td (printf (\"writing to gpg's stdin...\\n\"));\n\n\t\t\/* write our stream to gpg's stdin *\/\n\t\tnread = camel_stream_read (\n\t\t\tgpg->istream, buffer,\n\t\t\tsizeof (buffer), cancellable, NULL);\n\t\tif (nread > 0) {\n\t\t\tgssize w, nwritten = 0;\n\n\t\t\tdo {\n\t\t\t\tdo {\n\t\t\t\t\tw = write (gpg->stdin_fd, buffer + nwritten, nread - nwritten);\n\t\t\t\t} while (w == -1 && (errno == EINTR || errno == EAGAIN));\n\n\t\t\t\tif (w > 0)\n\t\t\t\t\tnwritten += w;\n\t\t\t} while (nwritten < nread && w != -1);\n\n\t\t\tif (w == -1)\n\t\t\t\tgoto exception;\n\n\t\t\td (printf (\"wrote %d (out of %d) bytes to gpg's stdin\\n\", nwritten, nread));\n\t\t\twrote_data = TRUE;\n\t\t}\n\n\t\tif (camel_stream_eos (gpg->istream)) {\n\t\t\td (printf (\"closing gpg's stdin\\n\"));\n\t\t\tclose (gpg->stdin_fd);\n\t\t\tgpg->stdin_fd = -1;\n\t\t}\n\t}\n\n\tif (gpg->need_id && !gpg->processing && !read_data && !wrote_data) {\n\t\t\/* do not ask more than hundred times per second when looking for a pass phrase,\n\t\t * in case user has the use-agent set, it'll not use the all CPU when\n\t\t * agent is asking for a pass phrase, instead of us *\/\n\t\tg_usleep (G_USEC_PER_SEC \/ 100);\n\t}\n\n\treturn 0;\n\n exception:\n\t\/* always called on an i\/o error *\/\n\tg_set_error (\n\t\terror, G_IO_ERROR,\n\t\tg_io_error_from_errno (errno),\n\t\t_(\"Failed to execute gpg: %s\"), g_strerror (errno));\n\tgpg_ctx_op_cancel (gpg);\n#endif\n\treturn -1;\n}","target":0,"code_token_length":1722,"total_token_length":1958,"max_tokens_setting":2048}
+{"idx":512868,"func":"Item_cond::fix_fields(THD *thd, Item **ref)\n{\n  DBUG_ASSERT(fixed == 0);\n  List_iterator<Item> li(list);\n  Item *item;\n  uchar buff[sizeof(char*)];\t\t\t\/\/ Max local vars in function\n  bool is_and_cond= functype() == Item_func::COND_AND_FUNC;\n  not_null_tables_cache= 0;\n  used_tables_and_const_cache_init();\n\n  \/*\n    and_table_cache is the value that Item_cond_or() returns for\n    not_null_tables()\n  *\/\n  and_tables_cache= ~(table_map) 0;\n\n  if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))\n    return TRUE;\t\t\t\t\/\/ Fatal error flag is set!\n  \/*\n    The following optimization reduces the depth of an AND-OR tree.\n    E.g. a WHERE clause like\n      F1 AND (F2 AND (F2 AND F4))\n    is parsed into a tree with the same nested structure as defined\n    by braces. This optimization will transform such tree into\n      AND (F1, F2, F3, F4).\n    Trees of OR items are flattened as well:\n      ((F1 OR F2) OR (F3 OR F4))   =>   OR (F1, F2, F3, F4)\n    Items for removed AND\/OR levels will dangle until the death of the\n    entire statement.\n    The optimization is currently prepared statements and stored procedures\n    friendly as it doesn't allocate any memory and its effects are durable\n    (i.e. do not depend on PS\/SP arguments).\n  *\/\n  while ((item=li++))\n  {\n    while (item->type() == Item::COND_ITEM &&\n\t   ((Item_cond*) item)->functype() == functype() &&\n           !((Item_cond*) item)->list.is_empty())\n    {\t\t\t\t\t\t\/\/ Identical function\n      li.replace(((Item_cond*) item)->list);\n      ((Item_cond*) item)->list.empty();\n      item= *li.ref();\t\t\t\t\/\/ new current item\n    }\n    if (abort_on_null)\n      item->top_level_item();\n\n    \/*\n      replace degraded condition:\n        was:    <field>\n        become: <field> = 1\n    *\/\n    Item::Type type= item->type();\n    if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)\n    {\n      Query_arena backup, *arena;\n      Item *new_item;\n      arena= thd->activate_stmt_arena_if_needed(&backup);\n      if ((new_item= new (thd->mem_root) Item_func_ne(thd, item, new (thd->mem_root) Item_int(thd, 0, 1))))\n        li.replace(item= new_item);\n      if (arena)\n        thd->restore_active_arena(arena, &backup);\n    }\n\n    if (item->fix_fields_if_needed_for_bool(thd, li.ref()))\n      return TRUE; \/* purecov: inspected *\/\n    item= *li.ref(); \/\/ item can be substituted in fix_fields\n    used_tables_cache|=     item->used_tables();\n    if (item->const_item() && !item->with_param &&\n        !item->is_expensive() && !cond_has_datetime_is_null(item))\n    {\n      if (item->eval_const_cond() == is_and_cond && top_level())\n      {\n        \/* \n          a. This is \"... AND true_cond AND ...\"\n          In this case, true_cond  has no effect on cond_and->not_null_tables()\n          b. This is \"... OR false_cond\/null cond OR ...\" \n          In this case, false_cond has no effect on cond_or->not_null_tables()\n        *\/\n      }\n      else\n      {\n        \/* \n          a. This is \"... AND false_cond\/null_cond AND ...\"\n          The whole condition is FALSE\/UNKNOWN.\n          b. This is  \"... OR const_cond OR ...\"\n          In this case, cond_or->not_null_tables()=0, because the condition\n          const_cond might evaluate to true (regardless of whether some tables\n          were NULL-complemented).\n        *\/\n        not_null_tables_cache= (table_map) 0;\n        and_tables_cache= (table_map) 0;\n      }\n      if (thd->is_error())\n        return TRUE;\n    }\n    else\n    {\n      table_map tmp_table_map= item->not_null_tables();\n      not_null_tables_cache|= tmp_table_map;\n      and_tables_cache&= tmp_table_map;\n\n      const_item_cache= FALSE;\n    } \n  \n    join_with_sum_func(item);\n    with_param|=       item->with_param;\n    with_field|=       item->with_field;\n    m_with_subquery|=  item->with_subquery();\n    with_window_func|= item->with_window_func;\n    maybe_null|=       item->maybe_null;\n  }\n  if (fix_length_and_dec())\n    return TRUE;\n  fixed= 1;\n  return FALSE;\n}","target":0,"code_token_length":1042,"total_token_length":1278,"max_tokens_setting":2048}
+{"idx":387829,"func":"InstanceKlass* InstanceKlass::nest_host(Symbol* validationException, TRAPS) {\n  InstanceKlass* nest_host_k = _nest_host;\n  if (nest_host_k == NULL) {\n    \/\/ need to resolve and save our nest-host class. This could be attempted\n    \/\/ concurrently but as the result is idempotent and we don't use the class\n    \/\/ then we do not need any synchronization beyond what is implicitly used\n    \/\/ during class loading.\n    if (_nest_host_index != 0) { \/\/ we have a real nest_host\n      \/\/ Before trying to resolve check if we're in a suitable context\n      if (!THREAD->can_call_java() && !_constants->tag_at(_nest_host_index).is_klass()) {\n        if (log_is_enabled(Trace, class, nestmates)) {\n          ResourceMark rm(THREAD);\n          log_trace(class, nestmates)(\"Rejected resolution of nest-host of %s in unsuitable thread\",\n                                      this->external_name());\n        }\n        return NULL;\n      }\n\n      if (log_is_enabled(Trace, class, nestmates)) {\n        ResourceMark rm(THREAD);\n        log_trace(class, nestmates)(\"Resolving nest-host of %s using cp entry for %s\",\n                                    this->external_name(),\n                                    _constants->klass_name_at(_nest_host_index)->as_C_string());\n      }\n\n      Klass* k = _constants->klass_at(_nest_host_index, THREAD);\n      if (HAS_PENDING_EXCEPTION) {\n        Handle exc_h = Handle(THREAD, PENDING_EXCEPTION);\n        if (exc_h->is_a(SystemDictionary::NoClassDefFoundError_klass())) {\n          \/\/ throw a new CDNFE with the original as its cause, and a clear msg\n          ResourceMark rm(THREAD);\n          char buf[200];\n          CLEAR_PENDING_EXCEPTION;\n          jio_snprintf(buf, sizeof(buf),\n                       \"Unable to load nest-host class (%s) of %s\",\n                       _constants->klass_name_at(_nest_host_index)->as_C_string(),\n                       this->external_name());\n          log_trace(class, nestmates)(\"%s - NoClassDefFoundError\", buf);\n          THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), buf, exc_h);\n        }\n        \/\/ All other exceptions pass through (OOME, StackOverflowError, LinkageErrors etc).\n        return NULL;\n      }\n\n      \/\/ A valid nest-host is an instance class in the current package that lists this\n      \/\/ class as a nest member. If any of these conditions are not met we post the\n      \/\/ requested exception type (if any) and return NULL\n\n      const char* error = NULL;\n\n      \/\/ JVMS 5.4.4 indicates package check comes first\n      if (is_same_class_package(k)) {\n\n        \/\/ Now check actual membership. We can't be a member if our \"host\" is\n        \/\/ not an instance class.\n        if (k->is_instance_klass()) {\n          nest_host_k = InstanceKlass::cast(k);\n\n          bool is_member = nest_host_k->has_nest_member(this, CHECK_NULL);\n          if (is_member) {\n            \/\/ save resolved nest-host value\n            _nest_host = nest_host_k;\n\n            if (log_is_enabled(Trace, class, nestmates)) {\n              ResourceMark rm(THREAD);\n              log_trace(class, nestmates)(\"Resolved nest-host of %s to %s\",\n                                          this->external_name(), k->external_name());\n            }\n            return nest_host_k;\n          }\n        }\n        error = \"current type is not listed as a nest member\";\n      } else {\n        error = \"types are in different packages\";\n      }\n\n      if (log_is_enabled(Trace, class, nestmates)) {\n        ResourceMark rm(THREAD);\n        log_trace(class, nestmates)(\"Type %s is not a nest member of resolved type %s: %s\",\n                                    this->external_name(),\n                                    k->external_name(),\n                                    error);\n      }\n\n      if (validationException != NULL && THREAD->can_call_java()) {\n        ResourceMark rm(THREAD);\n        Exceptions::fthrow(THREAD_AND_LOCATION,\n                           validationException,\n                           \"Type %s is not a nest member of %s: %s\",\n                           this->external_name(),\n                           k->external_name(),\n                           error\n                           );\n      }\n      return NULL;\n    } else {\n      if (log_is_enabled(Trace, class, nestmates)) {\n        ResourceMark rm(THREAD);\n        log_trace(class, nestmates)(\"Type %s is not part of a nest: setting nest-host to self\",\n                                    this->external_name());\n      }\n      \/\/ save resolved nest-host value\n      return (_nest_host = this);\n    }\n  }\n  return nest_host_k;\n}","target":0,"code_token_length":992,"total_token_length":1228,"max_tokens_setting":2048}
+{"idx":224578,"func":"Status EinsumShape(shape_inference::InferenceContext* c) {\n  \/\/ We assume that the equation has a valid format. Either (x),(y)->(z)\n  \/\/ or (x)->(z), where each of (x), (y) and (z) are concatenation of zero or\n  \/\/ more latin alphabets and contains at most one ellipsis ('...').\n  string equation;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"equation\", &equation));\n  gtl::InlinedVector<string, 2> input_labels;\n  string output_labels;\n  TF_RETURN_IF_ERROR(\n      ParseEinsumEquation(equation, &input_labels, &output_labels));\n\n  if (c->num_inputs() == 0 || c->num_inputs() > 2) {\n    return errors::InvalidArgument(\"Expected either 1 or 2 inputs but got: \",\n                                   c->num_inputs());\n  }\n  const int input_labels_size = input_labels.size();\n  if (c->num_inputs() != input_labels_size) {\n    return errors::InvalidArgument(\"Expected \", input_labels.size(),\n                                   \" inputs for equation \", equation,\n                                   \" but got: \", c->num_inputs());\n  }\n\n  \/\/ Validate input subscripts, build the label to dimension mapping and obtain\n  \/\/ the broadcast shapes that map to ellipsis.\n  absl::flat_hash_map<char, DimensionHandle> label_to_dimension;\n  gtl::InlinedVector<ShapeHandle, 2> input_bcast_shapes(c->num_inputs());\n  for (int i = 0, end = c->num_inputs(); i < end; ++i) {\n    bool has_ellipsis = false;\n    TF_RETURN_IF_ERROR(ValidateEinsumEllipsis(input_labels[i], &has_ellipsis));\n    ShapeHandle input_shape = c->input(i);\n    \/\/ Validate that the input rank is sufficient for the given number of named\n    \/\/ labels.\n    if (c->RankKnown(input_shape)) {\n      if (has_ellipsis) {\n        const int num_named_labels =\n            static_cast<int>(input_labels[i].size()) - 3;\n        TF_RETURN_WITH_CONTEXT_IF_ERROR(\n            c->WithRankAtLeast(input_shape, num_named_labels, &input_shape),\n            \" for \", i, \"th input and equation: \", equation);\n      } else {\n        const int num_named_labels = static_cast<int>(input_labels[i].size());\n        TF_RETURN_WITH_CONTEXT_IF_ERROR(\n            c->WithRank(input_shape, num_named_labels, &input_shape), \" for \",\n            i, \"th input and equation: \", equation);\n      }\n    }\n\n    bool seen_ellipsis = false;\n    input_bcast_shapes[i] = c->Scalar();\n    \/\/ Run through the input labels; populate label_to_dimension mapping and\n    \/\/ compute the broadcast shapes corresponding to the ellipsis (if present).\n    for (int label_idx = 0, end = input_labels[i].size(); label_idx < end;\n         ++label_idx) {\n      const char label = input_labels[i][label_idx];\n      \/\/ Calculate the input axis that the current label is referring to. After\n      \/\/ the ellipsis, the axis may be found by using negative indices; i.e the\n      \/\/ (rank - k)th dimension corresponds to the (num_labels - k)th label.\n      const int64_t axis_before_ellipsis = label_idx;\n      const int64_t axis_after_ellipsis =\n          c->RankKnown(input_shape)\n              ? label_idx + c->Rank(input_shape) - input_labels[i].size()\n              : -1;\n\n      \/\/ Populate the input broadcast shape when we encounter an ellipsis (...).\n      if (label == '.') {\n        if (!c->RankKnown(input_shape)) {\n          input_bcast_shapes[i] = c->UnknownShape();\n        } else {\n          \/\/ The broadcast shape runs till the named label right after the\n          \/\/ ellipsis, the label with index (label_idx + 3).\n          TF_RETURN_IF_ERROR(c->Subshape(input_shape, axis_before_ellipsis,\n                                         axis_after_ellipsis + 3,\n                                         &input_bcast_shapes[i]));\n        }\n        label_idx += 2;  \/\/ Skip the rest of the ellipsis.\n        seen_ellipsis = true;\n        continue;\n      }\n      \/\/ Obtain the dimension that the current label corresponds to.\n      int64_t axis = seen_ellipsis ? axis_after_ellipsis : axis_before_ellipsis;\n      DimensionHandle new_dim = c->RankKnown(input_shape)\n                                    ? c->Dim(input_shape, axis)\n                                    : c->UnknownDim();\n      \/\/ If we've seen this label before, make sure previous and current\n      \/\/ dimensions are compatible.\n      if (label_to_dimension.contains(label)) {\n        DimensionHandle merged;\n        TF_RETURN_IF_ERROR(\n            c->Merge(label_to_dimension[label], new_dim, &merged));\n        label_to_dimension[label] = merged;\n      } else {\n        label_to_dimension[label] = new_dim;\n      }\n    }\n  }\n\n  \/\/ For two inputs, broadcast the two input broadcast shapes to create the\n  \/\/ output broadcast shape. For one input, just copy the single broadcast\n  \/\/ shape.\n  ShapeHandle output_bcast_shape;\n  if (input_bcast_shapes.size() == 1) {\n    output_bcast_shape = input_bcast_shapes[0];\n  } else if (input_bcast_shapes.size() == 2) {\n    TF_RETURN_IF_ERROR(BroadcastBinaryOpOutputShapeFnHelper(\n        c, input_bcast_shapes[0], input_bcast_shapes[1], true,\n        &output_bcast_shape));\n  }\n\n  bool output_has_ellipsis = false;\n  TF_RETURN_IF_ERROR(\n      ValidateEinsumEllipsis(output_labels, &output_has_ellipsis));\n  if (output_has_ellipsis) {\n    \/\/ If the output subscript has ellipsis and the output broadcast rank is\n    \/\/ unknown, then the output shape should have unknown rank.\n    if (!c->RankKnown(output_bcast_shape)) {\n      c->set_output(0, c->UnknownShape());\n      return Status::OK();\n    }\n  } else {\n    \/\/ If the output subscripts don't have ellipsis then make sure the output\n    \/\/ broadcasting shape is empty.\n    TF_RETURN_WITH_CONTEXT_IF_ERROR(\n        c->WithRankAtMost(output_bcast_shape, 0, &output_bcast_shape),\n        \" for einsum equation '\", equation,\n        \"' without ellipsis (...) in the output subscripts where input(s) have \"\n        \"non-empty broadcasting shape\");\n    output_bcast_shape = c->Scalar();\n  }\n\n  \/\/ Create the output shape from output labels and label_to_dimension mapping.\n  std::vector<DimensionHandle> output_dims;\n  for (int label_idx = 0, end = output_labels.size(); label_idx < end;\n       ++label_idx) {\n    const char label = output_labels[label_idx];\n    \/\/ Append the output_bcast_shape when the ellipsis is encountered.\n    if (label == '.') {\n      for (int k = 0; k < c->Rank(output_bcast_shape); ++k) {\n        output_dims.push_back(c->Dim(output_bcast_shape, k));\n      }\n      label_idx += 2;  \/\/ Skip the rest of the ellipsis.\n      continue;\n    }\n    auto dimension_it = label_to_dimension.find(label);\n    if (dimension_it == label_to_dimension.end()) {\n      return errors::InvalidArgument(\n          \"Einsum output subscripts for equation '\", equation, \"' has label '\",\n          label, \"' which is not present in the input subscripts\");\n    }\n    output_dims.push_back(dimension_it->second);\n  }\n  c->set_output(0, c->MakeShape(output_dims));\n  return Status::OK();\n}","target":0,"code_token_length":1627,"total_token_length":1863,"max_tokens_setting":2048}
+{"idx":197565,"func":"static int MqttClient_WaitType(MqttClient *client, void *packet_obj,\n    byte wait_type, word16 wait_packet_id, int timeout_ms)\n{\n    int rc;\n    word16 packet_id;\n    MqttPacketType packet_type;\n#ifdef WOLFMQTT_MULTITHREAD\n    MqttPendResp *pendResp;\n    int readLocked;\n#endif\n    MqttMsgStat* mms_stat;\n    int waitMatchFound;\n\n    if (client == NULL || packet_obj == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    \/* all packet type structures must have MqttMsgStat at top *\/\n    mms_stat = (MqttMsgStat*)packet_obj;\n\nwait_again:\n\n    \/* initialize variables *\/\n    packet_id = 0;\n    packet_type = MQTT_PACKET_TYPE_RESERVED;\n#ifdef WOLFMQTT_MULTITHREAD\n    pendResp = NULL;\n    readLocked = 0;\n#endif\n    waitMatchFound = 0;\n\n#ifdef WOLFMQTT_DEBUG_CLIENT\n    PRINTF(\"MqttClient_WaitType: Type %s (%d), ID %d\",\n        MqttPacket_TypeDesc((MqttPacketType)wait_type),\n            wait_type, wait_packet_id);\n#endif\n\n    switch ((int)*mms_stat)\n    {\n        case MQTT_MSG_BEGIN:\n        {\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Lock recv socket mutex *\/\n            rc = wm_SemLock(&client->lockRecv);\n            if (rc != 0) {\n                PRINTF(\"MqttClient_WaitType: recv lock error!\");\n                return rc;\n            }\n            readLocked = 1;\n        #endif\n\n            \/* reset the packet state *\/\n            client->packet.stat = MQTT_PK_BEGIN;\n        }\n        FALL_THROUGH;\n\n    #ifdef WOLFMQTT_V5\n        case MQTT_MSG_AUTH:\n    #endif\n        case MQTT_MSG_WAIT:\n        {\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Check to see if packet type and id have already completed *\/\n            pendResp = NULL;\n            rc = wm_SemLock(&client->lockClient);\n            if (rc == 0) {\n                if (MqttClient_RespList_Find(client, (MqttPacketType)wait_type, \n                    wait_packet_id, &pendResp)) {\n                    if (pendResp->packetDone) {\n                        \/* pending response is already done, so return *\/\n                        rc = pendResp->packet_ret;\n                    #ifdef WOLFMQTT_DEBUG_CLIENT\n                        PRINTF(\"PendResp already Done %p: Rc %d\", pendResp, rc);\n                    #endif\n                        MqttClient_RespList_Remove(client, pendResp);\n                        wm_SemUnlock(&client->lockClient);\n                        wm_SemUnlock(&client->lockRecv);\n                        return rc;\n                    }\n                }\n                wm_SemUnlock(&client->lockClient);\n            }\n            else {\n                break; \/* error *\/\n            }\n        #endif \/* WOLFMQTT_MULTITHREAD *\/\n\n            *mms_stat = MQTT_MSG_WAIT;\n\n            \/* Wait for packet *\/\n            rc = MqttPacket_Read(client, client->rx_buf, client->rx_buf_len,\n                    timeout_ms);\n            \/* handle failure *\/\n            if (rc <= 0) {\n                break;\n            }\n\n            \/* capture length read *\/\n            client->packet.buf_len = rc;\n\n            \/* Decode Packet - get type and id *\/\n            rc = MqttClient_DecodePacket(client, client->rx_buf,\n                client->packet.buf_len, NULL, &packet_type, NULL, &packet_id);\n            if (rc < 0) {\n                break;\n            }\n\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"Read Packet: Len %d, Type %d, ID %d\",\n                client->packet.buf_len, packet_type, packet_id);\n        #endif\n\n            *mms_stat = MQTT_MSG_READ;\n        }\n        FALL_THROUGH;\n\n        case MQTT_MSG_READ:\n        case MQTT_MSG_READ_PAYLOAD:\n        {\n            MqttPacketType use_packet_type;\n            void* use_packet_obj;\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            readLocked = 1; \/* if in this state read is locked *\/\n        #endif\n\n            \/* read payload state only happens for publish messages *\/\n            if (*mms_stat == MQTT_MSG_READ_PAYLOAD) {\n                packet_type = MQTT_PACKET_TYPE_PUBLISH;\n            }\n\n            \/* Determine if we received data for this request *\/\n            if ((wait_type == MQTT_PACKET_TYPE_ANY ||\n                 wait_type == packet_type ||\n                 MqttIsPubRespPacket(packet_type) == MqttIsPubRespPacket(wait_type)) &&\n               (wait_packet_id == 0 || wait_packet_id == packet_id))\n            {\n                use_packet_obj = packet_obj;\n                waitMatchFound = 1;\n            }\n            else {\n                \/* use generic packet object *\/\n                use_packet_obj = &client->msg;\n            }\n            use_packet_type = packet_type;\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Check to see if we have a pending response for this packet *\/\n            pendResp = NULL;\n            rc = wm_SemLock(&client->lockClient);\n            if (rc == 0) {\n                if (MqttClient_RespList_Find(client, packet_type, packet_id,\n                                                               &pendResp)) {\n                    \/* we found packet match this incoming read packet *\/\n                    pendResp->packetProcessing = 1;\n                    use_packet_obj = pendResp->packet_obj;\n                    use_packet_type = pendResp->packet_type;\n                    \/* req from another thread... not a match *\/\n                    waitMatchFound = 0;\n                }\n                wm_SemUnlock(&client->lockClient);\n            }\n            else {\n                break; \/* error *\/\n            }\n        #endif \/* WOLFMQTT_MULTITHREAD *\/\n\n            \/* Perform packet handling for publish callback and QoS *\/\n            rc = MqttClient_HandlePacket(client, use_packet_type,\n                use_packet_obj, timeout_ms);\n\n        #ifdef WOLFMQTT_NONBLOCK\n            if (rc == MQTT_CODE_CONTINUE) {\n                \/* we have received some data, so keep the recv\n                    mutex lock active and return *\/\n                return rc;\n            }\n        #endif\n\n            \/* handle success case *\/\n            if (rc >= 0) {\n                rc = MQTT_CODE_SUCCESS;\n            }\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (pendResp) {\n                \/* Mark pending response entry done *\/\n                if (wm_SemLock(&client->lockClient) == 0) {\n                    pendResp->packetDone = 1;\n                    pendResp->packet_ret = rc;\n                #ifdef WOLFMQTT_DEBUG_CLIENT\n                    PRINTF(\"PendResp Done %p\", pendResp);\n                #endif\n                    pendResp = NULL;\n                    wm_SemUnlock(&client->lockClient);\n                }\n            }\n        #endif \/* WOLFMQTT_MULTITHREAD *\/\n            break;\n        }\n\n        case MQTT_MSG_WRITE:\n        case MQTT_MSG_WRITE_PAYLOAD:\n        default:\n        {\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"MqttClient_WaitType: Invalid state %d!\", *mms_stat);\n        #endif\n            rc = MQTT_CODE_ERROR_STAT;\n            break;\n        }\n    } \/* switch (*mms_stat) *\/\n\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc != MQTT_CODE_CONTINUE)\n#endif\n    {\n        \/* reset state *\/\n        *mms_stat = MQTT_MSG_BEGIN;\n    }\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (readLocked) {\n        wm_SemUnlock(&client->lockRecv);\n    }\n#endif\n    if (rc < 0) {\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"MqttClient_WaitType: Failure: %s (%d)\",\n            MqttClient_ReturnCodeToString(rc), rc);\n    #endif\n        return rc;\n    }\n\n    if (!waitMatchFound) {\n        \/* if we get here, then the we are still waiting for a packet *\/\n        goto wait_again;\n    }\n\n    return rc;\n}","target":1,"code_token_length":1716,"total_token_length":1952,"max_tokens_setting":2048}
+{"idx":463134,"func":"static int write_entry(struct mailbox *mailbox,\n                       unsigned int uid,\n                       const char *entry,\n                       const char *userid,\n                       const struct buf *value,\n                       int ignorequota,\n                       int silent,\n                       const struct annotate_metadata *mdata,\n                       int maywrite)\n\n{\n    char key[MAX_MAILBOX_PATH+1];\n    int keylen, r;\n    annotate_db_t *d = NULL;\n    struct buf oldval = BUF_INITIALIZER;\n    const char *mboxname = mailbox ? mailbox->name : \"\";\n    modseq_t modseq = mdata ? mdata->modseq : 0;\n\n    r = _annotate_getdb(mboxname, uid, CYRUSDB_CREATE, &d);\n    if (r)\n        return r;\n\n    \/* must be in a transaction to modify the db *\/\n    annotate_begin(d);\n\n    keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key));\n\n    struct annotate_metadata oldmdata;\n    r = read_old_value(d, key, keylen, &oldval, &oldmdata);\n    if (r) goto out;\n\n    \/* if the value is identical, don't touch the mailbox *\/\n    if (oldval.len == value->len && (!value->len || !memcmp(oldval.s, value->s, value->len)))\n        goto out;\n\n    if (!maywrite) {\n        r = IMAP_PERMISSION_DENIED;\n        if (r) goto out;\n    }\n\n    if (mailbox) {\n        if (!ignorequota) {\n            quota_t qdiffs[QUOTA_NUMRESOURCES] = QUOTA_DIFFS_DONTCARE_INITIALIZER;\n            qdiffs[QUOTA_ANNOTSTORAGE] = value->len - (quota_t)oldval.len;\n            r = mailbox_quota_check(mailbox, qdiffs);\n            if (r) goto out;\n        }\n\n        \/* do the annot-changed here before altering the DB *\/\n        mailbox_annot_changed(mailbox, uid, entry, userid, &oldval, value, silent);\n\n        \/* grab the message annotation modseq, if not overridden *\/\n        if (uid && !mdata) {\n            modseq = mailbox->i.highestmodseq;\n        }\n    }\n\n    \/* zero length annotation is deletion.\n     * keep tombstones for message annotations *\/\n    if (!value->len && !uid) {\n\n#if DEBUG\n        syslog(LOG_ERR, \"write_entry: deleting key %s from %s\",\n                key_as_string(d, key, keylen), d->filename);\n#endif\n\n        do {\n            r = cyrusdb_delete(d->db, key, keylen, tid(d), \/*force*\/1);\n        } while (r == CYRUSDB_AGAIN);\n    }\n    else {\n        struct buf data = BUF_INITIALIZER;\n        unsigned char flags = 0;\n        if (!value->len || value->s == NULL) {\n            flags |= ANNOTATE_FLAG_DELETED;\n        }\n        else {\n            \/\/ this is only here to allow cleanup of invalid values in the past...\n            \/\/ the calling of this API with a NULL \"userid\" is bogus, because that's\n            \/\/ supposed to be reserved for the make_key of prefixes - but there has\n            \/\/ been API abuse in the past, so some of these are in the wild.  *sigh*.\n            \/\/ Don't allow new ones to be written\n            if (!userid) goto out;\n        }\n        make_entry(&data, value, modseq, flags);\n\n#if DEBUG\n        syslog(LOG_ERR, \"write_entry: storing key %s (value: %s) to %s (modseq=\" MODSEQ_FMT \")\",\n                key_as_string(d, key, keylen), value->s, d->filename, modseq);\n#endif\n\n        do {\n            r = cyrusdb_store(d->db, key, keylen, data.s, data.len, tid(d));\n        } while (r == CYRUSDB_AGAIN);\n        buf_free(&data);\n    }\n\n    if (!mailbox)\n        sync_log_annotation(\"\");\n\nout:\n    annotate_putdb(&d);\n    buf_free(&oldval);\n\n    return r;\n}","target":0,"code_token_length":868,"total_token_length":1104,"max_tokens_setting":2048}
+{"idx":309817,"func":"initialize_mousetype(SCREEN *sp)\n{\n    T((T_CALLED(\"initialize_mousetype()\")));\n\n    \/* Try gpm first, because gpm may be configured to run in xterm *\/\n#if USE_GPM_SUPPORT\n    if (allow_gpm_mouse(sp)) {\n\tif (!sp->_mouse_gpm_loaded) {\n#ifdef HAVE_LIBDL\n\t    load_gpm_library(sp);\n#else \/* !HAVE_LIBDL *\/\n\t    sp->_mouse_gpm_found = TRUE;\n\t    sp->_mouse_gpm_loaded = TRUE;\n#endif\n\t}\n\n\t\/*\n\t * The gpm_fd file-descriptor may be negative (xterm).  So we have to\n\t * maintain our notion of whether the mouse connection is active\n\t * without testing the file-descriptor.\n\t *\/\n\tif (sp->_mouse_gpm_found && enable_gpm_mouse(sp, TRUE)) {\n\t    sp->_mouse_type = M_GPM;\n\t    sp->_mouse_fd = *(my_gpm_fd);\n\t    T((\"GPM mouse_fd %d\", sp->_mouse_fd));\n\t    returnVoid;\n\t}\n    }\n#endif \/* USE_GPM_SUPPORT *\/\n\n    \/* OS\/2 VIO *\/\n#if USE_EMX_MOUSE\n    if (!sp->_emxmouse_thread\n\t&& strstr(SP_TERMTYPE term_names, \"xterm\") == 0\n\t&& NonEmpty(key_mouse)) {\n\tint handles[2];\n\n\tif (pipe(handles) < 0) {\n\t    perror(\"mouse pipe error\");\n\t    returnVoid;\n\t} else {\n\t    int rc;\n\n\t    if (!sp->_emxmouse_buttons[0]) {\n\t\tconst char *s = getenv(\"MOUSE_BUTTONS_123\");\n\n\t\tsp->_emxmouse_buttons[0] = 1;\n\t\tif (s && strlen(s) >= 3) {\n\t\t    sp->_emxmouse_buttons[1] = s[0] - '0';\n\t\t    sp->_emxmouse_buttons[2] = s[1] - '0';\n\t\t    sp->_emxmouse_buttons[3] = s[2] - '0';\n\t\t} else {\n\t\t    sp->_emxmouse_buttons[1] = 1;\n\t\t    sp->_emxmouse_buttons[2] = 3;\n\t\t    sp->_emxmouse_buttons[3] = 2;\n\t\t}\n\t    }\n\t    sp->_emxmouse_wfd = handles[1];\n\t    M_FD(sp) = handles[0];\n\t    \/* Needed? *\/\n\t    setmode(handles[0], O_BINARY);\n\t    setmode(handles[1], O_BINARY);\n\t    \/* Do not use CRT functions, we may single-threaded. *\/\n\t    rc = DosCreateThread((unsigned long *) &sp->_emxmouse_thread,\n\t\t\t\t mouse_server, (long) sp, 0, 8192);\n\t    if (rc) {\n\t\tprintf(\"mouse thread error %d=%#x\", rc, rc);\n\t    } else {\n\t\tsp->_mouse_type = M_XTERM;\n\t    }\n\t    returnVoid;\n\t}\n    }\n#endif \/* USE_EMX_MOUSE *\/\n\n#if USE_SYSMOUSE\n    {\n\tstatic char dev_tty[] = \"\/dev\/tty\";\n\tstruct mouse_info the_mouse;\n\tchar *the_device = 0;\n\n\tif (NC_ISATTY(sp->_ifd))\n\t    the_device = ttyname(sp->_ifd);\n\tif (the_device == 0)\n\t    the_device = dev_tty;\n\n\tsp->_mouse_fd = open(the_device, O_RDWR);\n\n\tif (sp->_mouse_fd >= 0) {\n\t    \/*\n\t     * sysmouse does not have a usable user interface for obtaining\n\t     * mouse events.  The logical way to proceed (reading data on a\n\t     * stream) only works if one opens the device as root.  Even in\n\t     * that mode, careful examination shows we lose events\n\t     * occasionally.  The interface provided for user programs is to\n\t     * establish a signal handler.  really.\n\t     *\n\t     * Take over SIGUSR2 for this purpose since SIGUSR1 is more\n\t     * likely to be used by an application.  getch() will have to\n\t     * handle the misleading EINTR's.\n\t     *\/\n\t    signal(SIGUSR2, SIG_IGN);\n\t    the_mouse.operation = MOUSE_MODE;\n\t    the_mouse.u.mode.mode = 0;\n\t    the_mouse.u.mode.signal = SIGUSR2;\n\t    if (ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {\n\t\tsignal(SIGUSR2, handle_sysmouse);\n\t\tthe_mouse.operation = MOUSE_SHOW;\n\t\tioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);\n\n#if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO)\t\/* FreeBSD > 2.x *\/\n\t\t{\n#ifndef FBIO_GETMODE\t\t\/* FreeBSD 3.x *\/\n#define FBIO_GETMODE    CONS_GET\n#define FBIO_MODEINFO   CONS_MODEINFO\n#endif \/* FBIO_GETMODE *\/\n\t\t    video_info_t the_video;\n\n\t\t    if (ioctl(sp->_mouse_fd,\n\t\t\t      FBIO_GETMODE,\n\t\t\t      &the_video.vi_mode) != -1\n\t\t\t&& ioctl(sp->_mouse_fd,\n\t\t\t\t FBIO_MODEINFO,\n\t\t\t\t &the_video) != -1) {\n\t\t\tsp->_sysmouse_char_width = the_video.vi_cwidth;\n\t\t\tsp->_sysmouse_char_height = the_video.vi_cheight;\n\t\t    }\n\t\t}\n#endif \/* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) *\/\n\n\t\tif (sp->_sysmouse_char_width <= 0)\n\t\t    sp->_sysmouse_char_width = 8;\n\t\tif (sp->_sysmouse_char_height <= 0)\n\t\t    sp->_sysmouse_char_height = 16;\n\t\tsp->_mouse_type = M_SYSMOUSE;\n\t\treturnVoid;\n\t    }\n\t}\n    }\n#endif \/* USE_SYSMOUSE *\/\n\n#ifdef USE_TERM_DRIVER\n    CallDriver(sp, td_initmouse);\n#else\n    \/* we know how to recognize mouse events under \"xterm\" *\/\n    if (NonEmpty(key_mouse)) {\n\tinit_xterm_mouse(sp);\n    } else if (strstr(SP_TERMTYPE term_names, \"xterm\") != 0) {\n\tif (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)\n\t    init_xterm_mouse(sp);\n    }\n#endif\n\n    returnVoid;\n}","target":0,"code_token_length":1316,"total_token_length":1552,"max_tokens_setting":2048}
+{"idx":376316,"func":"gpg_ctx_get_argv (struct _GpgCtx *gpg,\n                  gint status_fd,\n                  gchar **sfd,\n                  gint passwd_fd,\n                  gchar **pfd)\n{\n\tconst gchar *hash_str;\n\tGPtrArray *argv;\n\tgchar *buf;\n\tgint i;\n\n\targv = g_ptr_array_new ();\n\tg_ptr_array_add (argv, (guint8 *) gpg_ctx_get_executable_name ());\n\n\tg_ptr_array_add (argv, (guint8 *) \"--verbose\");\n\tg_ptr_array_add (argv, (guint8 *) \"--no-secmem-warning\");\n\tg_ptr_array_add (argv, (guint8 *) \"--no-greeting\");\n\tg_ptr_array_add (argv, (guint8 *) \"--no-tty\");\n\n\tif (passwd_fd == -1) {\n\t\t\/* only use batch mode if we don't intend on using the\n\t\t * interactive --command-fd option *\/\n\t\tg_ptr_array_add (argv, (guint8 *) \"--batch\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"--yes\");\n\t}\n\n\t*sfd = buf = g_strdup_printf (\"--status-fd=%d\", status_fd);\n\tg_ptr_array_add (argv, buf);\n\n\tif (passwd_fd != -1) {\n\t\t*pfd = buf = g_strdup_printf (\"--command-fd=%d\", passwd_fd);\n\t\tg_ptr_array_add (argv, buf);\n\t}\n\n\tswitch (gpg->mode) {\n\tcase GPG_CTX_MODE_SIGN:\n\t\tg_ptr_array_add (argv, (guint8 *) \"--sign\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"--detach\");\n\t\tif (gpg->armor)\n\t\t\tg_ptr_array_add (argv, (guint8 *) \"--armor\");\n\t\thash_str = gpg_hash_str (gpg->hash);\n\t\tif (hash_str)\n\t\t\tg_ptr_array_add (argv, (guint8 *) hash_str);\n\t\tif (gpg->userids) {\n\t\t\tGSList *uiter;\n\n\t\t\tfor (uiter = gpg->userids; uiter; uiter = uiter->next) {\n\t\t\t\tg_ptr_array_add (argv, (guint8 *) \"-u\");\n\t\t\t\tg_ptr_array_add (argv, (guint8 *) uiter->data);\n\t\t\t}\n\t\t}\n\t\tg_ptr_array_add (argv, (guint8 *) \"--output\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"-\");\n\t\tbreak;\n\tcase GPG_CTX_MODE_VERIFY:\n\t\tif (!camel_session_get_online (gpg->session)) {\n\t\t\t\/* this is a deprecated flag to gpg since 1.0.7 *\/\n\t\t\t\/*g_ptr_array_add (argv, \"--no-auto-key-retrieve\");*\/\n\t\t\tg_ptr_array_add (argv, (guint8 *) \"--keyserver-options\");\n\t\t\tg_ptr_array_add (argv, (guint8 *) \"no-auto-key-retrieve\");\n\t\t}\n\t\tg_ptr_array_add (argv, (guint8 *) \"--verify\");\n\t\tif (gpg->sigfile)\n\t\t\tg_ptr_array_add (argv, gpg->sigfile);\n\t\tg_ptr_array_add (argv, (guint8 *) \"-\");\n\t\tbreak;\n\tcase GPG_CTX_MODE_ENCRYPT:\n\t\tg_ptr_array_add (argv, (guint8 *) \"--encrypt\");\n\t\tif (gpg->armor)\n\t\t\tg_ptr_array_add (argv, (guint8 *) \"--armor\");\n\t\tif (gpg->always_trust)\n\t\t\tg_ptr_array_add (argv, (guint8 *) \"--always-trust\");\n\t\tif (gpg->userids) {\n\t\t\tGSList *uiter;\n\n\t\t\tfor (uiter = gpg->userids; uiter; uiter = uiter->next) {\n\t\t\t\tg_ptr_array_add (argv, (guint8 *) \"-u\");\n\t\t\t\tg_ptr_array_add (argv, (guint8 *) uiter->data);\n\t\t\t}\n\t\t}\n\t\tif (gpg->recipients) {\n\t\t\tfor (i = 0; i < gpg->recipients->len; i++) {\n\t\t\t\tg_ptr_array_add (argv, (guint8 *) \"-r\");\n\t\t\t\tg_ptr_array_add (argv, gpg->recipients->pdata[i]);\n\t\t\t}\n\t\t}\n\t\tg_ptr_array_add (argv, (guint8 *) \"--output\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"-\");\n\t\tbreak;\n\tcase GPG_CTX_MODE_DECRYPT:\n\t\tg_ptr_array_add (argv, (guint8 *) \"--decrypt\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"--output\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"-\");\n\t\tbreak;\n\tcase GPG_CTX_MODE_IMPORT:\n\t\tg_ptr_array_add (argv, (guint8 *) \"--import\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"-\");\n\t\tbreak;\n\tcase GPG_CTX_MODE_EXPORT:\n\t\tif (gpg->armor)\n\t\t\tg_ptr_array_add (argv, (guint8 *) \"--armor\");\n\t\tg_ptr_array_add (argv, (guint8 *) \"--export\");\n\t\tfor (i = 0; i < gpg->recipients->len; i++)\n\t\t\tg_ptr_array_add (argv, gpg->recipients->pdata[i]);\n\t\tbreak;\n\t}\n\n\tg_ptr_array_add (argv, NULL);\n\n\treturn argv;\n}","target":0,"code_token_length":1136,"total_token_length":1372,"max_tokens_setting":2048}
+{"idx":513241,"func":"static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab,\n                                    KEYUSE *org_keyuse, table_map used_tables)\n{\n  KEY *keyinfo;\n  KEY_PART_INFO *key_part_info;\n  KEYUSE *keyuse= org_keyuse;\n  uint key_parts= 0;\n  THD  *thd= join->thd;\n  TABLE *table= join_tab->table;\n  bool first_keyuse= TRUE;\n  DBUG_ENTER(\"create_hj_key_for_table\");\n\n  do\n  {\n    if (!(~used_tables & keyuse->used_tables) &&\n        join_tab->keyuse_is_valid_for_access_in_chosen_plan(join, keyuse) &&\n        are_tables_local(join_tab, keyuse->used_tables))    \n    {\n      if (first_keyuse)\n      {\n        key_parts++;\n      }\n      else\n      {\n        KEYUSE *curr= org_keyuse;\n        for( ; curr < keyuse; curr++)\n        {\n          if (curr->keypart == keyuse->keypart &&\n              !(~used_tables & curr->used_tables) &&\n              join_tab->keyuse_is_valid_for_access_in_chosen_plan(join,\n                                                                  curr) &&\n              are_tables_local(join_tab, curr->used_tables))\n            break;\n        }\n        if (curr == keyuse)\n           key_parts++;\n      }\n    }\n    first_keyuse= FALSE;\n    keyuse++;\n  } while (keyuse->table == table && keyuse->is_for_hash_join());\n  if (!key_parts)\n    DBUG_RETURN(TRUE);\n  \/* This memory is allocated only once for the joined table join_tab *\/\n  if (!(keyinfo= (KEY *) thd->alloc(sizeof(KEY))) ||\n      !(key_part_info = (KEY_PART_INFO *) thd->alloc(sizeof(KEY_PART_INFO)*\n                                                     key_parts)))\n    DBUG_RETURN(TRUE);\n  keyinfo->usable_key_parts= keyinfo->user_defined_key_parts = key_parts;\n  keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;\n  keyinfo->key_part= key_part_info;\n  keyinfo->key_length=0;\n  keyinfo->algorithm= HA_KEY_ALG_UNDEF;\n  keyinfo->flags= HA_GENERATED_KEY;\n  keyinfo->is_statistics_from_stat_tables= FALSE;\n  keyinfo->name= (char *) \"$hj\";\n  keyinfo->rec_per_key= (ulong*) thd->calloc(sizeof(ulong)*key_parts);\n  if (!keyinfo->rec_per_key)\n    DBUG_RETURN(TRUE);\n  keyinfo->key_part= key_part_info;\n\n  first_keyuse= TRUE;\n  keyuse= org_keyuse;\n  do\n  {\n    if (!(~used_tables & keyuse->used_tables) &&\n        join_tab->keyuse_is_valid_for_access_in_chosen_plan(join, keyuse) &&\n        are_tables_local(join_tab, keyuse->used_tables))\n    { \n      bool add_key_part= TRUE;\n      if (!first_keyuse)\n      {\n        for(KEYUSE *curr= org_keyuse; curr < keyuse; curr++)\n        {\n          if (curr->keypart == keyuse->keypart &&\n              !(~used_tables & curr->used_tables) &&\n              join_tab->keyuse_is_valid_for_access_in_chosen_plan(join,\n                                                                  curr) &&\n              are_tables_local(join_tab, curr->used_tables))\n\t  {\n            keyuse->keypart= NO_KEYPART;\n            add_key_part= FALSE;\n            break;\n          }\n        }\n      }\n      if (add_key_part)\n      {\n        Field *field= table->field[keyuse->keypart];\n        uint fieldnr= keyuse->keypart+1;\n        table->create_key_part_by_field(key_part_info, field, fieldnr);\n        keyinfo->key_length += key_part_info->store_length;\n        key_part_info++;\n      }\n    }\n    first_keyuse= FALSE;\n    keyuse++;\n  } while (keyuse->table == table && keyuse->is_for_hash_join());\n\n  keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;\n  keyinfo->ext_key_flags= keyinfo->flags;\n  keyinfo->ext_key_part_map= 0;\n\n  join_tab->hj_key= keyinfo;\n\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":904,"total_token_length":1140,"max_tokens_setting":2048}
+{"idx":220168,"func":"  void DecodePngV2(OpKernelContext* context, StringPiece input) {\n    int channel_bits = (data_type_ == DataType::DT_UINT8) ? 8 : 16;\n    png::DecodeContext decode;\n    OP_REQUIRES(\n        context, png::CommonInitDecode(input, channels_, channel_bits, &decode),\n        errors::InvalidArgument(\"Invalid PNG. Failed to initialize decoder.\"));\n\n    \/\/ If we reach this point, then there is data in `decode` which must be\n    \/\/ freed by the time we end execution in this function. We cannot call\n    \/\/ `png::CommonFreeDecode()` before an `OP_REQUIRES` because if\n    \/\/ `OP_REQUIRES` constraint is satisfied then the data would be freed\n    \/\/ prematurely. Instead, let's use a `Cleanup` object.\n    auto cleanup = gtl::MakeCleanup([&decode]() {\n      std::cerr << \"Cleanup called...\\n\";\n      png::CommonFreeDecode(&decode);\n    });\n\n    \/\/ Verify that width and height are not too large:\n    \/\/ - verify width and height don't overflow int.\n    \/\/ - width can later be multiplied by channels_ and sizeof(uint16), so\n    \/\/   verify single dimension is not too large.\n    \/\/ - verify when width and height are multiplied together, there are a few\n    \/\/   bits to spare as well.\n    const int width = static_cast<int>(decode.width);\n    const int height = static_cast<int>(decode.height);\n    const int64_t total_size =\n        static_cast<int64_t>(width) * static_cast<int64_t>(height);\n    if (width != static_cast<int64_t>(decode.width) || width <= 0 ||\n        width >= (1LL << 27) || height != static_cast<int64_t>(decode.height) ||\n        height <= 0 || height >= (1LL << 27) || total_size >= (1LL << 29)) {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\"PNG size too large for int: \",\n                                          decode.width, \" by \", decode.height));\n    }\n\n    Tensor* output = nullptr;\n    \/\/ By the existing API, we support decoding PNG with `DecodeGif` op.\n    \/\/ We need to make sure to return 4-D shapes when using `DecodeGif`.\n    if (op_type_ == \"DecodeGif\") {\n      OP_REQUIRES_OK(\n          context,\n          context->allocate_output(\n              0, TensorShape({1, height, width, decode.channels}), &output));\n    } else {\n      OP_REQUIRES_OK(\n          context,\n          context->allocate_output(\n              0, TensorShape({height, width, decode.channels}), &output));\n    }\n\n    if (op_type_ == \"DecodeBmp\") {\n      \/\/ TODO(b\/171060723): Only DecodeBmp as op_type_ is not acceptable here\n      \/\/ because currently `decode_(jpeg|png|gif)` ops can decode any one of\n      \/\/ jpeg, png or gif but not bmp. Similarly, `decode_bmp` cannot decode\n      \/\/ anything but bmp formats. This behavior needs to be revisited. For more\n      \/\/ details, please refer to the bug.\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"Trying to decode PNG format using DecodeBmp op. Use \"\n                      \"`decode_png` or `decode_image` instead.\"));\n    } else if (op_type_ == \"DecodeAndCropJpeg\") {\n      OP_REQUIRES(context, false,\n                  errors::InvalidArgument(\n                      \"DecodeAndCropJpeg operation can run on JPEG only, but \"\n                      \"detected PNG.\"));\n    }\n\n    if (data_type_ == DataType::DT_UINT8) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint8>().data()),\n              decode.channels * width * sizeof(uint8), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_UINT16) {\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(\n              reinterpret_cast<png_bytep>(output->flat<uint16>().data()),\n              decode.channels * width * sizeof(uint16), &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n    } else if (data_type_ == DataType::DT_FLOAT) {\n      \/\/ `png::CommonFinishDecode` does not support `float`. First allocate\n      \/\/ uint16 buffer for the image and decode in uint16 (lossless). Wrap the\n      \/\/ buffer in `unique_ptr` so that we don't forget to delete the buffer.\n      std::unique_ptr<uint16[]> buffer(\n          new uint16[height * width * decode.channels]);\n      OP_REQUIRES(\n          context,\n          png::CommonFinishDecode(reinterpret_cast<png_bytep>(buffer.get()),\n                                  decode.channels * width * sizeof(uint16),\n                                  &decode),\n          errors::InvalidArgument(\"Invalid PNG data, size \", input.size()));\n\n      \/\/ Convert uint16 image data to desired data type.\n      \/\/ Use eigen threadpooling to speed up the copy operation.\n      const auto& device = context->eigen_device<Eigen::ThreadPoolDevice>();\n      TTypes<uint16, 3>::UnalignedConstTensor buf(buffer.get(), height, width,\n                                                  decode.channels);\n      float scale = 1. \/ std::numeric_limits<uint16>::max();\n      \/\/ Fill output tensor with desired dtype.\n      output->tensor<float, 3>().device(device) = buf.cast<float>() * scale;\n    }\n  }","target":0,"code_token_length":1213,"total_token_length":1449,"max_tokens_setting":2048}
+{"idx":411889,"func":"router_parse_directory(const char *str)\n{\n  directory_token_t *tok;\n  char digest[DIGEST_LEN];\n  time_t published_on;\n  int r;\n  const char *end, *cp, *str_dup = str;\n  smartlist_t *tokens = NULL;\n  crypto_pk_env_t *declared_key = NULL;\n  memarea_t *area = memarea_new();\n\n  \/* XXXX This could be simplified a lot, but it will all go away\n   * once pre-0.1.1.8 is obsolete, and for now it's better not to\n   * touch it. *\/\n\n  if (router_get_dir_hash(str, digest)) {\n    log_warn(LD_DIR, \"Unable to compute digest of directory\");\n    goto err;\n  }\n  log_debug(LD_DIR,\"Received directory hashes to %s\",hex_str(digest,4));\n\n  \/* Check signature first, before we try to tokenize. *\/\n  cp = str;\n  while (cp && (end = strstr(cp+1, \"\\ndirectory-signature\")))\n    cp = end;\n  if (cp == str || !cp) {\n    log_warn(LD_DIR, \"No signature found on directory.\"); goto err;\n  }\n  ++cp;\n  tokens = smartlist_create();\n  if (tokenize_string(area,cp,strchr(cp,'\\0'),tokens,dir_token_table,0)) {\n    log_warn(LD_DIR, \"Error tokenizing directory signature\"); goto err;\n  }\n  if (smartlist_len(tokens) != 1) {\n    log_warn(LD_DIR, \"Unexpected number of tokens in signature\"); goto err;\n  }\n  tok=smartlist_get(tokens,0);\n  if (tok->tp != K_DIRECTORY_SIGNATURE) {\n    log_warn(LD_DIR,\"Expected a single directory signature\"); goto err;\n  }\n  declared_key = find_dir_signing_key(str, str+strlen(str));\n  note_crypto_pk_op(VERIFY_DIR);\n  if (check_signature_token(digest, DIGEST_LEN, tok, declared_key,\n                            CST_CHECK_AUTHORITY, \"directory\")<0)\n    goto err;\n\n  SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));\n  smartlist_clear(tokens);\n  memarea_clear(area);\n\n  \/* Now try to parse the first part of the directory. *\/\n  if ((end = strstr(str,\"\\nrouter \"))) {\n    ++end;\n  } else if ((end = strstr(str, \"\\ndirectory-signature\"))) {\n    ++end;\n  } else {\n    end = str + strlen(str);\n  }\n\n  if (tokenize_string(area,str,end,tokens,dir_token_table,0)) {\n    log_warn(LD_DIR, \"Error tokenizing directory\"); goto err;\n  }\n\n  tok = find_by_keyword(tokens, K_PUBLISHED);\n  tor_assert(tok->n_args == 1);\n\n  if (parse_iso_time(tok->args[0], &published_on) < 0) {\n     goto err;\n  }\n\n  \/* Now that we know the signature is okay, and we have a\n   * publication time, cache the directory. *\/\n  if (directory_caches_v1_dir_info(get_options()) &&\n      !authdir_mode_v1(get_options()))\n    dirserv_set_cached_directory(str, published_on, 0);\n\n  r = 0;\n  goto done;\n err:\n  dump_desc(str_dup, \"v1 directory\");\n  r = -1;\n done:\n  if (declared_key) crypto_free_pk_env(declared_key);\n  if (tokens) {\n    SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));\n    smartlist_free(tokens);\n  }\n  if (area) {\n    DUMP_AREA(area, \"v1 directory\");\n    memarea_drop_all(area);\n  }\n  return r;\n}","target":0,"code_token_length":794,"total_token_length":1030,"max_tokens_setting":2048}
+{"idx":195471,"func":"IRC_PROTOCOL_CALLBACK(352)\n{\n    char *pos_attr, *pos_hopcount, *pos_realname, *str_host;\n    int arg_start, length;\n    struct t_irc_channel *ptr_channel;\n    struct t_irc_nick *ptr_nick;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    \/* silently ignore malformed 352 message (missing infos) *\/\n    if (argc < 8)\n        return WEECHAT_RC_OK;\n\n    pos_attr = NULL;\n    pos_hopcount = NULL;\n    pos_realname = NULL;\n\n    if (argc > 8)\n    {\n        arg_start = (strcmp (argv[8], \"*\") == 0) ? 9 : 8;\n        if (argv[arg_start][0] == ':')\n        {\n            pos_attr = NULL;\n            pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL;\n            pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL;\n        }\n        else\n        {\n            pos_attr = argv[arg_start];\n            pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL;\n            pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL;\n        }\n    }\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n    ptr_nick = (ptr_channel) ?\n        irc_nick_search (server, ptr_channel, argv[7]) : NULL;\n\n    \/* update host in nick *\/\n    if (ptr_nick)\n    {\n        length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;\n        str_host = malloc (length);\n        if (str_host)\n        {\n            snprintf (str_host, length, \"%s@%s\", argv[4], argv[5]);\n            irc_nick_set_host (ptr_nick, str_host);\n            free (str_host);\n        }\n    }\n\n    \/* update away flag in nick *\/\n    if (ptr_channel && ptr_nick && pos_attr)\n    {\n        irc_nick_set_away (server, ptr_channel, ptr_nick,\n                           (pos_attr[0] == 'G') ? 1 : 0);\n    }\n\n    \/* update realname in nick *\/\n    if (ptr_channel && ptr_nick && pos_realname)\n    {\n        if (ptr_nick->realname)\n            free (ptr_nick->realname);\n        if (pos_realname &&\n            weechat_hashtable_has_key (server->cap_list, \"extended-join\"))\n        {\n            ptr_nick->realname = strdup (pos_realname);\n        }\n        else\n        {\n            ptr_nick->realname = NULL;\n        }\n    }\n\n    \/* display output of who (manual who from user) *\/\n    if (!ptr_channel || (ptr_channel->checking_whox <= 0))\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, NULL, command, \"who\", NULL),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s %s%s%s%s(%s)\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_CHANNEL,\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[7]),\n            argv[7],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_HOST,\n            argv[4],\n            argv[5],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            (pos_attr) ? pos_attr : \"\",\n            (pos_attr) ? \" \" : \"\",\n            (pos_hopcount) ? pos_hopcount : \"\",\n            (pos_hopcount) ? \" \" : \"\",\n            (pos_realname) ? pos_realname : \"\");\n    }\n\n    return WEECHAT_RC_OK;\n}","target":1,"code_token_length":859,"total_token_length":1095,"max_tokens_setting":2048}
+{"idx":338230,"func":"bool WasmBinaryBuilder::maybeVisitStore(Expression*& out,\n                                        uint8_t code,\n                                        bool isAtomic) {\n  Store* curr;\n  if (!isAtomic) {\n    switch (code) {\n      case BinaryConsts::I32StoreMem8:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 1;\n        curr->valueType = Type::i32;\n        break;\n      case BinaryConsts::I32StoreMem16:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 2;\n        curr->valueType = Type::i32;\n        break;\n      case BinaryConsts::I32StoreMem:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 4;\n        curr->valueType = Type::i32;\n        break;\n      case BinaryConsts::I64StoreMem8:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 1;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::I64StoreMem16:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 2;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::I64StoreMem32:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 4;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::I64StoreMem:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 8;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::F32StoreMem:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 4;\n        curr->valueType = Type::f32;\n        break;\n      case BinaryConsts::F64StoreMem:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 8;\n        curr->valueType = Type::f64;\n        break;\n      default:\n        return false;\n    }\n  } else {\n    switch (code) {\n      case BinaryConsts::I32AtomicStore8:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 1;\n        curr->valueType = Type::i32;\n        break;\n      case BinaryConsts::I32AtomicStore16:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 2;\n        curr->valueType = Type::i32;\n        break;\n      case BinaryConsts::I32AtomicStore:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 4;\n        curr->valueType = Type::i32;\n        break;\n      case BinaryConsts::I64AtomicStore8:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 1;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::I64AtomicStore16:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 2;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::I64AtomicStore32:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 4;\n        curr->valueType = Type::i64;\n        break;\n      case BinaryConsts::I64AtomicStore:\n        curr = allocator.alloc<Store>();\n        curr->bytes = 8;\n        curr->valueType = Type::i64;\n        break;\n      default:\n        return false;\n    }\n  }\n\n  curr->isAtomic = isAtomic;\n  BYN_TRACE(\"zz node: Store\\n\");\n  readMemoryAccess(curr->align, curr->offset);\n  curr->value = popNonVoidExpression();\n  curr->ptr = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":844,"total_token_length":1080,"max_tokens_setting":2048}
+{"idx":238815,"func":"update_search_stat(\n    int\t\t\tdirc,\n    pos_T\t\t*pos,\n    pos_T\t\t*cursor_pos,\n    searchstat_T\t*stat,\n    int\t\t\trecompute,\n    int\t\t\tmaxcount,\n    long\t\ttimeout UNUSED)\n{\n    int\t\t    save_ws = p_ws;\n    int\t\t    wraparound = FALSE;\n    pos_T\t    p = (*pos);\n    static pos_T    lastpos = {0, 0, 0};\n    static int\t    cur = 0;\n    static int\t    cnt = 0;\n    static int\t    exact_match = FALSE;\n    static int\t    incomplete = 0;\n    static int\t    last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;\n    static int\t    chgtick = 0;\n    static char_u   *lastpat = NULL;\n    static buf_T    *lbuf = NULL;\n#ifdef FEAT_RELTIME\n    proftime_T  start;\n#endif\n\n    vim_memset(stat, 0, sizeof(searchstat_T));\n\n    if (dirc == 0 && !recompute && !EMPTY_POS(lastpos))\n    {\n\tstat->cur = cur;\n\tstat->cnt = cnt;\n\tstat->exact_match = exact_match;\n\tstat->incomplete = incomplete;\n\tstat->last_maxcount = last_maxcount;\n\treturn;\n    }\n    last_maxcount = maxcount;\n\n    wraparound = ((dirc == '?' && LT_POS(lastpos, p))\n\t       || (dirc == '\/' && LT_POS(p, lastpos)));\n\n    \/\/ If anything relevant changed the count has to be recomputed.\n    \/\/ MB_STRNICMP ignores case, but we should not ignore case.\n    \/\/ Unfortunately, there is no MB_STRNICMP function.\n    \/\/ XXX: above comment should be \"no MB_STRCMP function\" ?\n    if (!(chgtick == CHANGEDTICK(curbuf)\n\t&& MB_STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0\n\t&& STRLEN(lastpat) == STRLEN(spats[last_idx].pat)\n\t&& EQUAL_POS(lastpos, *cursor_pos)\n\t&& lbuf == curbuf) || wraparound || cur < 0\n\t    || (maxcount > 0 && cur > maxcount) || recompute)\n    {\n\tcur = 0;\n\tcnt = 0;\n\texact_match = FALSE;\n\tincomplete = 0;\n\tCLEAR_POS(&lastpos);\n\tlbuf = curbuf;\n    }\n\n    if (EQUAL_POS(lastpos, *cursor_pos) && !wraparound\n\t\t&& (dirc == 0 || dirc == '\/' ? cur < cnt : cur > 0))\n\tcur += dirc == 0 ? 0 : dirc == '\/' ? 1 : -1;\n    else\n    {\n\tint\tdone_search = FALSE;\n\tpos_T\tendpos = {0, 0, 0};\n\n\tp_ws = FALSE;\n#ifdef FEAT_RELTIME\n\tif (timeout > 0)\n\t    profile_setlimit(timeout, &start);\n#endif\n\twhile (!got_int && searchit(curwin, curbuf, &lastpos, &endpos,\n\t\t\t FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST, NULL) != FAIL)\n\t{\n\t    done_search = TRUE;\n#ifdef FEAT_RELTIME\n\t    \/\/ Stop after passing the time limit.\n\t    if (timeout > 0 && profile_passed_limit(&start))\n\t    {\n\t\tincomplete = 1;\n\t\tbreak;\n\t    }\n#endif\n\t    cnt++;\n\t    if (LTOREQ_POS(lastpos, p))\n\t    {\n\t\tcur = cnt;\n\t\tif (LT_POS(p, endpos))\n\t\t    exact_match = TRUE;\n\t    }\n\t    fast_breakcheck();\n\t    if (maxcount > 0 && cnt > maxcount)\n\t    {\n\t\tincomplete = 2;    \/\/ max count exceeded\n\t\tbreak;\n\t    }\n\t}\n\tif (got_int)\n\t    cur = -1; \/\/ abort\n\tif (done_search)\n\t{\n\t    vim_free(lastpat);\n\t    lastpat = vim_strsave(spats[last_idx].pat);\n\t    chgtick = CHANGEDTICK(curbuf);\n\t    lbuf = curbuf;\n\t    lastpos = p;\n\t}\n    }\n    stat->cur = cur;\n    stat->cnt = cnt;\n    stat->exact_match = exact_match;\n    stat->incomplete = incomplete;\n    stat->last_maxcount = last_maxcount;\n    p_ws = save_ws;\n}","target":0,"code_token_length":922,"total_token_length":1158,"max_tokens_setting":2048}
+{"idx":213482,"func":"nbd_internal_command_common (struct nbd_handle *h,\n                             uint16_t flags, uint16_t type,\n                             uint64_t offset, uint64_t count, int count_err,\n                             void *data, struct command_cb *cb)\n{\n  struct command *cmd;\n\n  if (h->disconnect_request) {\n      set_error (EINVAL, \"cannot request more commands after NBD_CMD_DISC\");\n      goto err;\n  }\n  if (h->in_flight == INT_MAX) {\n      set_error (ENOMEM, \"too many commands already in flight\");\n      goto err;\n  }\n\n  if (count_err) {\n    if ((h->strict & LIBNBD_STRICT_ZERO_SIZE) && count == 0) {\n      set_error (EINVAL, \"count cannot be 0\");\n      goto err;\n    }\n\n    if ((h->strict & LIBNBD_STRICT_BOUNDS) &&\n        (offset > h->exportsize || count > h->exportsize - offset)) {\n      set_error (count_err, \"request out of bounds\");\n      goto err;\n    }\n\n    if (h->block_minimum && (h->strict & LIBNBD_STRICT_ALIGN) &&\n        (offset | count) & (h->block_minimum - 1)) {\n      set_error (EINVAL, \"request is unaligned\");\n      goto err;\n    }\n  }\n\n  switch (type) {\n    \/* Commands which send or receive data are limited to MAX_REQUEST_SIZE. *\/\n  case NBD_CMD_READ:\n  case NBD_CMD_WRITE:\n    if (count > MAX_REQUEST_SIZE) {\n      set_error (ERANGE, \"request too large: maximum request size is %d\",\n                 MAX_REQUEST_SIZE);\n      goto err;\n    }\n    break;\n\n    \/* Other commands are currently limited by the 32 bit field in the\n     * command structure on the wire, but in future we hope to support\n     * 64 bit values here with a change to the NBD protocol which is\n     * being discussed upstream.\n     *\/\n  default:\n    if (count > UINT32_MAX) {\n      set_error (ERANGE, \"request too large: maximum request size is %\" PRIu32,\n                 UINT32_MAX);\n      goto err;\n    }\n    break;\n  }\n\n  cmd = calloc (1, sizeof *cmd);\n  if (cmd == NULL) {\n    set_error (errno, \"calloc\");\n    goto err;\n  }\n  cmd->flags = flags;\n  cmd->type = type;\n  cmd->cookie = h->unique++;\n  cmd->offset = offset;\n  cmd->count = count;\n  cmd->data = data;\n  if (cb)\n    cmd->cb = *cb;\n\n  \/* If structured replies were negotiated then we trust the server to\n   * send back sufficient data to cover the whole buffer.  It's tricky\n   * to check this, so an easier thing is simply to zero the buffer\n   * ahead of time which avoids any security problems.  I measured the\n   * overhead of this and for non-TLS there is no measurable overhead\n   * in the highly intensive loopback case.  For TLS we get a\n   * performance gain, go figure.\n   *\/\n  if (h->structured_replies && cmd->data && type == NBD_CMD_READ)\n    memset (cmd->data, 0, cmd->count);\n\n  \/* Add the command to the end of the queue. Kick the state machine\n   * if there is no other command being processed, otherwise, it will\n   * be handled automatically on a future cycle around to READY.\n   * Beyond this point, we have to return a cookie to the user, since\n   * we are queuing the command, even if kicking the state machine\n   * detects a failure.  Not reporting a state machine failure here is\n   * okay - any caller of an async command will be calling more API to\n   * await results, and will eventually learn that the machine has\n   * moved on to DEAD at that time.\n   *\/\n  h->in_flight++;\n  if (h->cmds_to_issue != NULL) {\n    assert (nbd_internal_is_state_processing (get_next_state (h)));\n    h->cmds_to_issue_tail = h->cmds_to_issue_tail->next = cmd;\n  }\n  else {\n    assert (h->cmds_to_issue_tail == NULL);\n    h->cmds_to_issue = h->cmds_to_issue_tail = cmd;\n    if (nbd_internal_is_state_ready (get_next_state (h)) &&\n        nbd_internal_run (h, cmd_issue) == -1)\n      debug (h, \"command queued, ignoring state machine failure\");\n  }\n\n  return cmd->cookie;\n\n err:\n  \/* Since we did not queue the command, we must free the callbacks. *\/\n  if (cb) {\n    if (type == NBD_CMD_BLOCK_STATUS)\n      FREE_CALLBACK (cb->fn.extent);\n    if (type == NBD_CMD_READ)\n      FREE_CALLBACK (cb->fn.chunk);\n    FREE_CALLBACK (cb->completion);\n  }\n  return -1;\n}","target":1,"code_token_length":1068,"total_token_length":1304,"max_tokens_setting":2048}
+{"idx":436990,"func":"get_lisp_indent(void)\n{\n    pos_T\t*pos, realpos, paren;\n    int\t\tamount;\n    char_u\t*that;\n    colnr_T\tcol;\n    colnr_T\tfirsttry;\n    int\t\tparencount, quotecount;\n    int\t\tvi_lisp;\n\n    \/\/ Set vi_lisp to use the vi-compatible method\n    vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);\n\n    realpos = curwin->w_cursor;\n    curwin->w_cursor.col = 0;\n\n    if ((pos = findmatch(NULL, '(')) == NULL)\n\tpos = findmatch(NULL, '[');\n    else\n    {\n\tparen = *pos;\n\tpos = findmatch(NULL, '[');\n\tif (pos == NULL || LT_POSP(pos, &paren))\n\t    pos = &paren;\n    }\n    if (pos != NULL)\n    {\n\t\/\/ Extra trick: Take the indent of the first previous non-white\n\t\/\/ line that is at the same () level.\n\tamount = -1;\n\tparencount = 0;\n\n\twhile (--curwin->w_cursor.lnum >= pos->lnum)\n\t{\n\t    if (linewhite(curwin->w_cursor.lnum))\n\t\tcontinue;\n\t    for (that = ml_get_curline(); *that != NUL; ++that)\n\t    {\n\t\tif (*that == ';')\n\t\t{\n\t\t    while (*(that + 1) != NUL)\n\t\t\t++that;\n\t\t    continue;\n\t\t}\n\t\tif (*that == '\\\\')\n\t\t{\n\t\t    if (*(that + 1) != NUL)\n\t\t\t++that;\n\t\t    continue;\n\t\t}\n\t\tif (*that == '\"' && *(that + 1) != NUL)\n\t\t{\n\t\t    while (*++that && *that != '\"')\n\t\t    {\n\t\t\t\/\/ skipping escaped characters in the string\n\t\t\tif (*that == '\\\\')\n\t\t\t{\n\t\t\t    if (*++that == NUL)\n\t\t\t\tbreak;\n\t\t\t    if (that[1] == NUL)\n\t\t\t    {\n\t\t\t\t++that;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t    if (*that == NUL)\n\t\t\tbreak;\n\t\t}\n\t\tif (*that == '(' || *that == '[')\n\t\t    ++parencount;\n\t\telse if (*that == ')' || *that == ']')\n\t\t    --parencount;\n\t    }\n\t    if (parencount == 0)\n\t    {\n\t\tamount = get_indent();\n\t\tbreak;\n\t    }\n\t}\n\n\tif (amount == -1)\n\t{\n\t    curwin->w_cursor.lnum = pos->lnum;\n\t    curwin->w_cursor.col = pos->col;\n\t    col = pos->col;\n\n\t    that = ml_get_curline();\n\n\t    if (vi_lisp && get_indent() == 0)\n\t\tamount = 2;\n\t    else\n\t    {\n\t\tchar_u *line = that;\n\n\t\tamount = 0;\n\t\twhile (*that && col)\n\t\t{\n\t\t    amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);\n\t\t    col--;\n\t\t}\n\n\t\t\/\/ Some keywords require \"body\" indenting rules (the\n\t\t\/\/ non-standard-lisp ones are Scheme special forms):\n\t\t\/\/\n\t\t\/\/ (let ((a 1))    instead    (let ((a 1))\n\t\t\/\/   (...))\t      of\t   (...))\n\n\t\tif (!vi_lisp && (*that == '(' || *that == '[')\n\t\t\t\t\t\t      && lisp_match(that + 1))\n\t\t    amount += 2;\n\t\telse\n\t\t{\n\t\t    if (*that != NUL)\n\t\t    {\n\t\t\tthat++;\n\t\t\tamount++;\n\t\t    }\n\t\t    firsttry = amount;\n\n\t\t    while (VIM_ISWHITE(*that))\n\t\t    {\n\t\t\tamount += lbr_chartabsize(line, that, (colnr_T)amount);\n\t\t\t++that;\n\t\t    }\n\n\t\t    if (*that && *that != ';') \/\/ not a comment line\n\t\t    {\n\t\t\t\/\/ test *that != '(' to accommodate first let\/do\n\t\t\t\/\/ argument if it is more than one line\n\t\t\tif (!vi_lisp && *that != '(' && *that != '[')\n\t\t\t    firsttry++;\n\n\t\t\tparencount = 0;\n\t\t\tquotecount = 0;\n\n\t\t\tif (vi_lisp\n\t\t\t\t|| (*that != '\"'\n\t\t\t\t    && *that != '\\''\n\t\t\t\t    && *that != '#'\n\t\t\t\t    && (*that < '0' || *that > '9')))\n\t\t\t{\n\t\t\t    while (*that\n\t\t\t\t    && (!VIM_ISWHITE(*that)\n\t\t\t\t\t|| quotecount\n\t\t\t\t\t|| parencount)\n\t\t\t\t    && (!((*that == '(' || *that == '[')\n\t\t\t\t\t    && !quotecount\n\t\t\t\t\t    && !parencount\n\t\t\t\t\t    && vi_lisp)))\n\t\t\t    {\n\t\t\t\tif (*that == '\"')\n\t\t\t\t    quotecount = !quotecount;\n\t\t\t\tif ((*that == '(' || *that == '[')\n\t\t\t\t\t\t\t       && !quotecount)\n\t\t\t\t    ++parencount;\n\t\t\t\tif ((*that == ')' || *that == ']')\n\t\t\t\t\t\t\t       && !quotecount)\n\t\t\t\t    --parencount;\n\t\t\t\tif (*that == '\\\\' && *(that+1) != NUL)\n\t\t\t\t    amount += lbr_chartabsize_adv(\n\t\t\t\t\t\tline, &that, (colnr_T)amount);\n\t\t\t\tamount += lbr_chartabsize_adv(\n\t\t\t\t\t\tline, &that, (colnr_T)amount);\n\t\t\t    }\n\t\t\t}\n\t\t\twhile (VIM_ISWHITE(*that))\n\t\t\t{\n\t\t\t    amount += lbr_chartabsize(\n\t\t\t\t\t\t line, that, (colnr_T)amount);\n\t\t\t    that++;\n\t\t\t}\n\t\t\tif (!*that || *that == ';')\n\t\t\t    amount = firsttry;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n    else\n\tamount = 0;\t\/\/ no matching '(' or '[' found, use zero indent\n\n    curwin->w_cursor = realpos;\n\n    return amount;\n}","target":0,"code_token_length":1256,"total_token_length":1492,"max_tokens_setting":2048}
+{"idx":384768,"func":"halfpage(int flag, linenr_T Prenum)\n{\n    long\tscrolled = 0;\n    int\t\ti;\n    int\t\tn;\n    int\t\troom;\n\n    if (Prenum)\n\tcurwin->w_p_scr = (Prenum > curwin->w_height) ?\n\t\t\t\t\t\tcurwin->w_height : Prenum;\n    n = (curwin->w_p_scr <= curwin->w_height) ?\n\t\t\t\t    curwin->w_p_scr : curwin->w_height;\n\n    update_topline();\n    validate_botline();\n    room = curwin->w_empty_rows;\n#ifdef FEAT_DIFF\n    room += curwin->w_filler_rows;\n#endif\n    if (flag)\n    {\n\t\/*\n\t * scroll the text up\n\t *\/\n\twhile (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count)\n\t{\n#ifdef FEAT_DIFF\n\t    if (curwin->w_topfill > 0)\n\t    {\n\t\ti = 1;\n\t\t--n;\n\t\t--curwin->w_topfill;\n\t    }\n\t    else\n#endif\n\t    {\n\t\ti = PLINES_NOFILL(curwin->w_topline);\n\t\tn -= i;\n\t\tif (n < 0 && scrolled > 0)\n\t\t    break;\n#ifdef FEAT_FOLDING\n\t\t(void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline);\n#endif\n\t\t++curwin->w_topline;\n#ifdef FEAT_DIFF\n\t\tcurwin->w_topfill = diff_check_fill(curwin, curwin->w_topline);\n#endif\n\n\t\tif (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)\n\t\t{\n\t\t    ++curwin->w_cursor.lnum;\n\t\t    curwin->w_valid &=\n\t\t\t\t    ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL);\n\t\t}\n\t    }\n\t    curwin->w_valid &= ~(VALID_CROW|VALID_WROW);\n\t    scrolled += i;\n\n\t    \/*\n\t     * Correct w_botline for changed w_topline.\n\t     * Won't work when there are filler lines.\n\t     *\/\n#ifdef FEAT_DIFF\n\t    if (curwin->w_p_diff)\n\t\tcurwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP);\n\t    else\n#endif\n\t    {\n\t\troom += i;\n\t\tdo\n\t\t{\n\t\t    i = plines(curwin->w_botline);\n\t\t    if (i > room)\n\t\t\tbreak;\n#ifdef FEAT_FOLDING\n\t\t    (void)hasFolding(curwin->w_botline, NULL,\n\t\t\t\t\t\t\t  &curwin->w_botline);\n#endif\n\t\t    ++curwin->w_botline;\n\t\t    room -= i;\n\t\t} while (curwin->w_botline <= curbuf->b_ml.ml_line_count);\n\t    }\n\t}\n\n\t\/*\n\t * When hit bottom of the file: move cursor down.\n\t *\/\n\tif (n > 0)\n\t{\n# ifdef FEAT_FOLDING\n\t    if (hasAnyFolding(curwin))\n\t    {\n\t\twhile (--n >= 0\n\t\t\t&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)\n\t\t{\n\t\t    (void)hasFolding(curwin->w_cursor.lnum, NULL,\n\t\t\t\t\t\t      &curwin->w_cursor.lnum);\n\t\t    ++curwin->w_cursor.lnum;\n\t\t}\n\t    }\n\t    else\n# endif\n\t\tcurwin->w_cursor.lnum += n;\n\t    check_cursor_lnum();\n\t}\n    }\n    else\n    {\n\t\/*\n\t * scroll the text down\n\t *\/\n\twhile (n > 0 && curwin->w_topline > 1)\n\t{\n#ifdef FEAT_DIFF\n\t    if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline))\n\t    {\n\t\ti = 1;\n\t\t--n;\n\t\t++curwin->w_topfill;\n\t    }\n\t    else\n#endif\n\t    {\n\t\ti = PLINES_NOFILL(curwin->w_topline - 1);\n\t\tn -= i;\n\t\tif (n < 0 && scrolled > 0)\n\t\t    break;\n\t\t--curwin->w_topline;\n#ifdef FEAT_FOLDING\n\t\t(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);\n#endif\n#ifdef FEAT_DIFF\n\t\tcurwin->w_topfill = 0;\n#endif\n\t    }\n\t    curwin->w_valid &= ~(VALID_CROW|VALID_WROW|\n\t\t\t\t\t      VALID_BOTLINE|VALID_BOTLINE_AP);\n\t    scrolled += i;\n\t    if (curwin->w_cursor.lnum > 1)\n\t    {\n\t\t--curwin->w_cursor.lnum;\n\t\tcurwin->w_valid &= ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL);\n\t    }\n\t}\n\n\t\/*\n\t * When hit top of the file: move cursor up.\n\t *\/\n\tif (n > 0)\n\t{\n\t    if (curwin->w_cursor.lnum <= (linenr_T)n)\n\t\tcurwin->w_cursor.lnum = 1;\n\t    else\n# ifdef FEAT_FOLDING\n\t    if (hasAnyFolding(curwin))\n\t    {\n\t\twhile (--n >= 0 && curwin->w_cursor.lnum > 1)\n\t\t{\n\t\t    --curwin->w_cursor.lnum;\n\t\t    (void)hasFolding(curwin->w_cursor.lnum,\n\t\t\t\t\t\t&curwin->w_cursor.lnum, NULL);\n\t\t}\n\t    }\n\t    else\n# endif\n\t\tcurwin->w_cursor.lnum -= n;\n\t}\n    }\n# ifdef FEAT_FOLDING\n    \/\/ Move cursor to first line of closed fold.\n    foldAdjustCursor();\n# endif\n#ifdef FEAT_DIFF\n    check_topfill(curwin, !flag);\n#endif\n    cursor_correct();\n    beginline(BL_SOL | BL_FIX);\n    redraw_later(VALID);\n}","target":0,"code_token_length":1263,"total_token_length":1499,"max_tokens_setting":2048}
+{"idx":244004,"func":"static GF_Err ctrn_box_size(GF_TrackFragmentRunBox *ctrn)\n{\n\tBool use_ctso_multi = GF_TRUE;\n\tu32 i, count;\n\tGF_TrunEntry *ent;\n\n\tctrn->ctrn_flags = 0;\n\tctrn->ctrn_first_dur = ctrn->ctrn_first_size = ctrn->ctrn_first_sample_flags = ctrn->ctrn_first_ctts = 0;\n\tctrn->ctrn_dur = ctrn->ctrn_size = ctrn->ctrn_sample_flags = ctrn->ctrn_ctts = 0;\n\n\tctrn->size += 2; \/\/16 bits for sample count\n\tif (ctrn->flags & GF_ISOM_TRUN_DATA_OFFSET) {\n\t\tctrn->ctrn_flags |= GF_ISOM_TRUN_DATA_OFFSET;\n\t\tif (ABS(ctrn->data_offset) < 32767) {\n\t\t\tctrn->size += 2;\n\t\t\tctrn->ctrn_flags |= GF_ISOM_CTRN_DATAOFFSET_16;\n\t\t} else\n\t\t\tctrn->size += 4;\n\t}\n\n\tcount = gf_list_count(ctrn->entries);\n\tif (ctrn->ctso_multiplier && (ctrn->flags & GF_ISOM_TRUN_CTS_OFFSET) && (ctrn->ctso_multiplier<=0xFFFF) ) {\n\t\tfor (i=0; i<count; i++) {\n\t\t\tGF_TrunEntry *a_ent = gf_list_get(ctrn->entries, i);\n\t\t\tif (a_ent->CTS_Offset % ctrn->ctso_multiplier) {\n\t\t\t\tuse_ctso_multi = GF_FALSE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tuse_ctso_multi = GF_FALSE;\n\t}\n\tif (ctrn->use_inherit) {\n\t\tuse_ctso_multi = GF_FALSE;\n\t\tctrn->ctrn_flags |= 0xB0; \/\/duration=1,size=0,flags=1,cts=1 << 4\n\t}\n\n\tif (use_ctso_multi) {\n\t\tctrn->size += 2;\n\t\tctrn->ctrn_flags |= GF_ISOM_CTRN_CTSO_MULTIPLIER;\n\t} else {\n\t\tctrn->ctso_multiplier = 0;\n\t}\n\n\t\/*we always write first sample using first flags*\/\n\tent = gf_list_get(ctrn->entries, 0);\n\tctrn->ctrn_flags |= GF_ISOM_CTRN_FIRST_SAMPLE;\n\n\tif (!ctrn->use_inherit && (ctrn->flags & GF_ISOM_TRUN_DURATION)) {\n\t\tctrn->ctrn_first_dur = ctrn_u32_to_index(ent->Duration);\n\t\tif (ctrn->ctrn_first_dur) {\n\t\t\tctrn->size += ctrn_field_size(ctrn->ctrn_first_dur);\n\t\t\tctrn->ctrn_flags |= ctrn->ctrn_first_dur<<22;\n\t\t}\n\t}\n\n\tif (ctrn->flags & GF_ISOM_TRUN_SIZE) {\n\t\tctrn->ctrn_first_size = ctrn_u32_to_index(ent->size);\n\t\tif (ctrn->ctrn_first_size) {\n\t\t\tctrn->size += ctrn_field_size(ctrn->ctrn_first_size);\n\t\t\tctrn->ctrn_flags |= ctrn->ctrn_first_size<<20;\n\t\t}\n\t}\n\n\tif (!ctrn->use_inherit && (ctrn->flags & GF_ISOM_TRUN_FLAGS)) {\n\t\tctrn->ctrn_first_sample_flags = ctrn_sample_flags_to_index(ent->flags);\n\t\tif (ctrn->ctrn_first_sample_flags) {\n\t\t\tctrn->size += ctrn_field_size(ctrn->ctrn_first_sample_flags);\n\t\t\tctrn->ctrn_flags |= ctrn->ctrn_first_sample_flags<<18;\n\t\t}\n\t}\n\tif (!ctrn->use_inherit && (ctrn->flags & GF_ISOM_TRUN_CTS_OFFSET)) {\n\t\tctrn->ctrn_first_ctts = ctrn_ctts_to_index(ctrn, ent->CTS_Offset);\n\t\tif (ctrn->ctrn_first_ctts) {\n\t\t\tctrn->size += ctrn_field_size(ctrn->ctrn_first_ctts);\n\t\t\tctrn->ctrn_flags |= ctrn->ctrn_first_ctts<<16;\n\t\t}\n\t}\n\n\tfor (i=1; i<count; i++) {\n\t\tu8 field_idx;\n\t\tGF_TrunEntry *a_ent = gf_list_get(ctrn->entries, i);\n\n\t\tif (!ctrn->use_inherit && (ctrn->flags & GF_ISOM_TRUN_DURATION)) {\n\t\t\tfield_idx = ctrn_u32_to_index(a_ent->Duration);\n\t\t\tif (ctrn->ctrn_dur < field_idx)\n\t\t\t\tctrn->ctrn_dur = field_idx;\n\t\t}\n\t\tif (ctrn->flags & GF_ISOM_TRUN_SIZE) {\n\t\t\tfield_idx = ctrn_u32_to_index(a_ent->size);\n\t\t\tif (ctrn->ctrn_size < field_idx)\n\t\t\t\tctrn->ctrn_size = field_idx;\n\t\t}\n\t\tif (!ctrn->use_inherit && (ctrn->flags & GF_ISOM_TRUN_FLAGS)) {\n\t\t\tfield_idx = ctrn_sample_flags_to_index(a_ent->flags);\n\t\t\tif (ctrn->ctrn_sample_flags < field_idx)\n\t\t\t\tctrn->ctrn_sample_flags = field_idx;\n\t\t}\n\t\tif (!ctrn->use_inherit) {\n\t\t\tfield_idx = ctrn_ctts_to_index(ctrn, a_ent->CTS_Offset);\n\t\t\tif (ctrn->ctrn_ctts < field_idx)\n\t\t\t\tctrn->ctrn_ctts = field_idx;\n\t\t}\n\t}\n\tcount-=1;\n\tif (ctrn->ctrn_dur) {\n\t\tctrn->size += count * ctrn_field_size(ctrn->ctrn_dur);\n\t\tctrn->ctrn_flags |= ctrn->ctrn_dur<<14;\n\t}\n\tif (ctrn->ctrn_size) {\n\t\tctrn->size += count * ctrn_field_size(ctrn->ctrn_size);\n\t\tctrn->ctrn_flags |= ctrn->ctrn_size<<12;\n\t}\n\tif (ctrn->ctrn_sample_flags) {\n\t\tctrn->size += count * ctrn_field_size(ctrn->ctrn_sample_flags);\n\t\tctrn->ctrn_flags |= ctrn->ctrn_sample_flags<<10;\n\t}\n\tif (ctrn->ctrn_ctts) {\n\t\tctrn->size += count * ctrn_field_size(ctrn->ctrn_ctts);\n\t\tctrn->ctrn_flags |= ctrn->ctrn_ctts<<8;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":1461,"total_token_length":1697,"max_tokens_setting":2048}
+{"idx":312576,"func":"qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)\n{\n    char_u\t*fname;\n    buf_T\t*buf;\n    int\t\tfilter_entry;\n\n    fname = NULL;\n    if (qfp->qf_module != NULL && *qfp->qf_module != NUL)\n\tvim_snprintf((char *)IObuff, IOSIZE, \"%2d %s\", qf_idx,\n\t\t\t\t\t\t(char *)qfp->qf_module);\n    else {\n\tif (qfp->qf_fnum != 0\n\t\t&& (buf = buflist_findnr(qfp->qf_fnum)) != NULL)\n\t{\n\t    fname = buf->b_fname;\n\t    if (qfp->qf_type == 1)\t\/\/ :helpgrep\n\t\tfname = gettail(fname);\n\t}\n\tif (fname == NULL)\n\t    sprintf((char *)IObuff, \"%2d\", qf_idx);\n\telse\n\t    vim_snprintf((char *)IObuff, IOSIZE, \"%2d %s\",\n\t\t    qf_idx, (char *)fname);\n    }\n\n    \/\/ Support for filtering entries using :filter \/pat\/ clist\n    \/\/ Match against the module name, file name, search pattern and\n    \/\/ text of the entry.\n    filter_entry = TRUE;\n    if (qfp->qf_module != NULL && *qfp->qf_module != NUL)\n\tfilter_entry &= message_filtered(qfp->qf_module);\n    if (filter_entry && fname != NULL)\n\tfilter_entry &= message_filtered(fname);\n    if (filter_entry && qfp->qf_pattern != NULL)\n\tfilter_entry &= message_filtered(qfp->qf_pattern);\n    if (filter_entry)\n\tfilter_entry &= message_filtered(qfp->qf_text);\n    if (filter_entry)\n\treturn;\n\n    msg_putchar('\\n');\n    msg_outtrans_attr(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr);\n\n    if (qfp->qf_lnum != 0)\n\tmsg_puts_attr(\":\", qfSepAttr);\n    if (qfp->qf_lnum == 0)\n\tIObuff[0] = NUL;\n    else\n\tqf_range_text(qfp, IObuff, IOSIZE);\n    sprintf((char *)IObuff + STRLEN(IObuff), \"%s\",\n\t    (char *)qf_types(qfp->qf_type, qfp->qf_nr));\n    msg_puts_attr((char *)IObuff, qfLineAttr);\n    msg_puts_attr(\":\", qfSepAttr);\n    if (qfp->qf_pattern != NULL)\n    {\n\tqf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);\n\tmsg_puts((char *)IObuff);\n\tmsg_puts_attr(\":\", qfSepAttr);\n    }\n    msg_puts(\" \");\n\n    {\n\tchar_u *tbuf = IObuff;\n\tsize_t\ttbuflen = IOSIZE;\n\tsize_t\tlen = STRLEN(qfp->qf_text) + 3;\n\n\tif (len > IOSIZE)\n\t{\n\t    tbuf = alloc(len);\n\t    if (tbuf != NULL)\n\t\ttbuflen = len;\n\t    else\n\t\ttbuf = IObuff;\n\t}\n\n\t\/\/ Remove newlines and leading whitespace from the text.  For an\n\t\/\/ unrecognized line keep the indent, the compiler may mark a word\n\t\/\/ with ^^^^.\n\tqf_fmt_text((fname != NULL || qfp->qf_lnum != 0)\n\t\t\t\t    ? skipwhite(qfp->qf_text) : qfp->qf_text,\n\t\t\t\t    tbuf, (int)tbuflen);\n\tmsg_prt_line(tbuf, FALSE);\n\n\tif (tbuf != IObuff)\n\t    vim_free(tbuf);\n    }\n    out_flush();\t\t\/\/ show one line at a time\n}","target":0,"code_token_length":810,"total_token_length":1046,"max_tokens_setting":2048}
+{"idx":246694,"func":"static Bool PrintHelpArg(char *arg_name, u32 search_type, GF_FilterSession *fs)\n{\n\tBool first=GF_TRUE;\n\tGF_GPACArg an_arg;\n\tu32 i, count;\n\tu32 res = 0;\n\tu32 alen = (u32) strlen(arg_name);\n\tres += PrintHelpForArgs(arg_name, m4b_gen_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_split_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_dash_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_imp_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_imp_fileopt_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_senc_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_crypt_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_hint_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_extr_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_dump_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_meta_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_swf_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_liveenc_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, m4b_usage_args, NULL, search_type);\n\tres += PrintHelpForArgs(arg_name, NULL, (GF_GPACArg *) gf_sys_get_options(), search_type);\n\n\tif (!fs) return res;\n\n\tmemset(&an_arg, 0, sizeof(GF_GPACArg));\n\tcount = gf_fs_filters_registers_count(fs);\n\tfor (i=0; i<count; i++) {\n\t\tu32 j=0;\n\t\tconst GF_FilterRegister *reg = gf_fs_get_filter_register(fs, i);\n\n\t\twhile (reg->args) {\n\t\t\tu32 len;\n\t\t\tconst GF_FilterArgs *arg = ®->args[j];\n\t\t\tif (!arg || !arg->arg_name) break;\n\t\t\tj++;\n\t\t\tif ((search_type==SEARCH_ARG_EXACT) && strcmp(arg->arg_name, arg_name)) continue;\n\n\t\t\tif ((search_type==SEARCH_ARG_CLOSE) && !gf_sys_word_match(arg->arg_name, arg_name)) continue;\n\n\t\t\tif (search_type==SEARCH_DESC) {\n\t\t\t\tif (!strstr_nocase(arg->arg_desc, arg_name, alen)) continue;\n\t\t\t}\n\n\t\t\tan_arg.name = arg->arg_name;\n\t\t\tif (search_type==SEARCH_ARG_EXACT) {\n\t\t\t\tan_arg.description = arg->arg_desc;\n\t\t\t\tswitch (arg->arg_type) {\n\t\t\t\tcase GF_PROP_BOOL:\n\t\t\t\t\tan_arg.type = GF_ARG_BOOL;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_PROP_UINT:\n\t\t\t\tcase GF_PROP_SINT:\n\t\t\t\t\tan_arg.type = GF_ARG_INT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_PROP_DOUBLE:\n\t\t\t\t\tan_arg.type = GF_ARG_DOUBLE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_PROP_STRING_LIST:\n\t\t\t\tcase GF_PROP_UINT_LIST:\n\t\t\t\tcase GF_PROP_SINT_LIST:\n\t\t\t\tcase GF_PROP_VEC2I_LIST:\n\t\t\t\t\tan_arg.type = GF_ARG_STRINGS;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_PROP_4CC:\n\t\t\t\t\tan_arg.type = GF_ARG_4CC;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_PROP_4CC_LIST:\n\t\t\t\t\tan_arg.type = GF_ARG_4CCS;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tan_arg.type = GF_ARG_STRING;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (first) {\n\t\t\t\t\tfirst = GF_FALSE;\n\t\t\t\t\tgf_sys_format_help(helpout, 0, \"\\nGlobal filter session arguments. Syntax is `--arg` or `--arg=VAL`. `[F]` indicates filter name. See `gpac -h` and `gpac -h F` for more info.\\n\");\n\t\t\t\t}\n\t\t\t\tfprintf(helpout, \"[%s]\", reg->name);\n\t\t\t\tlen = (u32)strlen(reg->name);\n\t\t\t\twhile (len<10) {\n\t\t\t\t\tlen++;\n\t\t\t\t\tfprintf(helpout, \" \");\n\t\t\t\t}\n\t\t\t\tfprintf(helpout, \" \");\n\t\t\t}\n\n\t\t\tgf_sys_print_arg(helpout, GF_PRINTARG_ADD_DASH, &an_arg, \"TEST\");\n\t\t\tres++;\n\t\t}\n\t}\n\tif (res) return GF_TRUE;\n\treturn GF_FALSE;\n}","target":0,"code_token_length":961,"total_token_length":1197,"max_tokens_setting":2048}
+{"idx":232957,"func":"static CURLcode inflate_stream(struct Curl_easy *data,\n                               struct contenc_writer *writer,\n                               zlibInitState started)\n{\n  struct zlib_params *zp = (struct zlib_params *) &writer->params;\n  z_stream *z = &zp->z;         \/* zlib state structure *\/\n  uInt nread = z->avail_in;\n  Bytef *orig_in = z->next_in;\n  bool done = FALSE;\n  CURLcode result = CURLE_OK;   \/* Curl_client_write status *\/\n  char *decomp;                 \/* Put the decompressed data here. *\/\n\n  \/* Check state. *\/\n  if(zp->zlib_init != ZLIB_INIT &&\n     zp->zlib_init != ZLIB_INFLATING &&\n     zp->zlib_init != ZLIB_INIT_GZIP &&\n     zp->zlib_init != ZLIB_GZIP_INFLATING)\n    return exit_zlib(data, z, &zp->zlib_init, CURLE_WRITE_ERROR);\n\n  \/* Dynamically allocate a buffer for decompression because it's uncommonly\n     large to hold on the stack *\/\n  decomp = malloc(DSIZ);\n  if(!decomp)\n    return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);\n\n  \/* because the buffer size is fixed, iteratively decompress and transfer to\n     the client via downstream_write function. *\/\n  while(!done) {\n    int status;                   \/* zlib status *\/\n    done = TRUE;\n\n    \/* (re)set buffer for decompressed output for every iteration *\/\n    z->next_out = (Bytef *) decomp;\n    z->avail_out = DSIZ;\n\n#ifdef Z_BLOCK\n    \/* Z_BLOCK is only available in zlib ver. >= 1.2.0.5 *\/\n    status = inflate(z, Z_BLOCK);\n#else\n    \/* fallback for zlib ver. < 1.2.0.5 *\/\n    status = inflate(z, Z_SYNC_FLUSH);\n#endif\n\n    \/* Flush output data if some. *\/\n    if(z->avail_out != DSIZ) {\n      if(status == Z_OK || status == Z_STREAM_END) {\n        zp->zlib_init = started;      \/* Data started. *\/\n        result = Curl_unencode_write(data, writer->downstream, decomp,\n                                     DSIZ - z->avail_out);\n        if(result) {\n          exit_zlib(data, z, &zp->zlib_init, result);\n          break;\n        }\n      }\n    }\n\n    \/* Dispatch by inflate() status. *\/\n    switch(status) {\n    case Z_OK:\n      \/* Always loop: there may be unflushed latched data in zlib state. *\/\n      done = FALSE;\n      break;\n    case Z_BUF_ERROR:\n      \/* No more data to flush: just exit loop. *\/\n      break;\n    case Z_STREAM_END:\n      result = process_trailer(data, zp);\n      break;\n    case Z_DATA_ERROR:\n      \/* some servers seem to not generate zlib headers, so this is an attempt\n         to fix and continue anyway *\/\n      if(zp->zlib_init == ZLIB_INIT) {\n        \/* Do not use inflateReset2(): only available since zlib 1.2.3.4. *\/\n        (void) inflateEnd(z);     \/* don't care about the return code *\/\n        if(inflateInit2(z, -MAX_WBITS) == Z_OK) {\n          z->next_in = orig_in;\n          z->avail_in = nread;\n          zp->zlib_init = ZLIB_INFLATING;\n          zp->trailerlen = 4; \/* Tolerate up to 4 unknown trailer bytes. *\/\n          done = FALSE;\n          break;\n        }\n        zp->zlib_init = ZLIB_UNINIT;    \/* inflateEnd() already called. *\/\n      }\n      result = exit_zlib(data, z, &zp->zlib_init, process_zlib_error(data, z));\n      break;\n    default:\n      result = exit_zlib(data, z, &zp->zlib_init, process_zlib_error(data, z));\n      break;\n    }\n  }\n  free(decomp);\n\n  \/* We're about to leave this call so the `nread' data bytes won't be seen\n     again. If we are in a state that would wrongly allow restart in raw mode\n     at the next call, assume output has already started. *\/\n  if(nread && zp->zlib_init == ZLIB_INIT)\n    zp->zlib_init = started;      \/* Cannot restart anymore. *\/\n\n  return result;\n}","target":0,"code_token_length":960,"total_token_length":1196,"max_tokens_setting":2048}
+{"idx":204019,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tstruct squashfs_dir_header dirh;\n\tchar buffer[sizeof(struct squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tstruct squashfs_dir_entry *dire = (struct squashfs_dir_entry *) buffer;\n\tlong long start;\n\tint bytes = 0, dir_count, size, res;\n\tstruct dir_ent *ent, *cur_ent = NULL;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tMEM_ERROR();\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = NULL;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 3)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\toffset = (*i)->offset;\n\tsize = (*i)->data + bytes - 3;\n\n\twhile(bytes < size) {\t\t\t\n\t\tres = read_directory_data(&dirh, &start, &offset, sizeof(dirh));\n\t\tif(res == FALSE)\n\t\t\tgoto corrupted;\n\n\t\tSQUASHFS_INSWAP_DIR_HEADER(&dirh);\n\t\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tres = read_directory_data(dire, &start, &offset, sizeof(*dire));\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tSQUASHFS_INSWAP_DIR_ENTRY(dire);\n\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tres = read_directory_data(dire->name, &start, &offset,\n\t\t\t\t\t\t\t\tdire->size + 1);\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\n\t\t\t\/* check name for invalid characters (i.e \/, ., ..) *\/\n\t\t\tif(check_name(dire->name, dire->size + 1) == FALSE) {\n\t\t\t\tERROR(\"File system corrupted: invalid characters in name\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\n\t\t\tent = malloc(sizeof(struct dir_ent));\n\t\t\tif(ent == NULL)\n\t\t\t\tMEM_ERROR();\n\n\t\t\tent->name = strdup(dire->name);\n\t\t\tent->start_block = dirh.start_block;\n\t\t\tent->offset = dire->offset;\n\t\t\tent->type = dire->type;\n\t\t\tent->next = NULL;\n\t\t\tif(cur_ent == NULL)\n\t\t\t\tdir->dirs = ent;\n\t\t\telse\n\t\t\t\tcur_ent->next = ent;\n\t\t\tcur_ent = ent;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tsquashfs_closedir(dir);\n\treturn NULL;\n}","target":1,"code_token_length":881,"total_token_length":1117,"max_tokens_setting":2048}
+{"idx":252309,"func":"static void wav2Encode(\n    unsigned short *in,  \/\/ io: values are transformed in place\n    int nx,              \/\/ i : x size\n    int ox,              \/\/ i : x offset\n    int ny,              \/\/ i : y size\n    int oy,              \/\/ i : y offset\n    unsigned short mx)   \/\/ i : maximum in[x][y] value\n{\n  bool w14 = (mx < (1 << 14));\n  int n = (nx > ny) ? ny : nx;\n  int p = 1;   \/\/ == 1 <<  level\n  int p2 = 2;  \/\/ == 1 << (level+1)\n\n  \/\/\n  \/\/ Hierachical loop on smaller dimension n\n  \/\/\n\n  while (p2 <= n) {\n    unsigned short *py = in;\n    unsigned short *ey = in + oy * (ny - p2);\n    int oy1 = oy * p;\n    int oy2 = oy * p2;\n    int ox1 = ox * p;\n    int ox2 = ox * p2;\n    unsigned short i00, i01, i10, i11;\n\n    \/\/\n    \/\/ Y loop\n    \/\/\n\n    for (; py <= ey; py += oy2) {\n      unsigned short *px = py;\n      unsigned short *ex = py + ox * (nx - p2);\n\n      \/\/\n      \/\/ X loop\n      \/\/\n\n      for (; px <= ex; px += ox2) {\n        unsigned short *p01 = px + ox1;\n        unsigned short *p10 = px + oy1;\n        unsigned short *p11 = p10 + ox1;\n\n        \/\/\n        \/\/ 2D wavelet encoding\n        \/\/\n\n        if (w14) {\n          wenc14(*px, *p01, i00, i01);\n          wenc14(*p10, *p11, i10, i11);\n          wenc14(i00, i10, *px, *p10);\n          wenc14(i01, i11, *p01, *p11);\n        } else {\n          wenc16(*px, *p01, i00, i01);\n          wenc16(*p10, *p11, i10, i11);\n          wenc16(i00, i10, *px, *p10);\n          wenc16(i01, i11, *p01, *p11);\n        }\n      }\n\n      \/\/\n      \/\/ Encode (1D) odd column (still in Y loop)\n      \/\/\n\n      if (nx & p) {\n        unsigned short *p10 = px + oy1;\n\n        if (w14)\n          wenc14(*px, *p10, i00, *p10);\n        else\n          wenc16(*px, *p10, i00, *p10);\n\n        *px = i00;\n      }\n    }\n\n    \/\/\n    \/\/ Encode (1D) odd line (must loop in X)\n    \/\/\n\n    if (ny & p) {\n      unsigned short *px = py;\n      unsigned short *ex = py + ox * (nx - p2);\n\n      for (; px <= ex; px += ox2) {\n        unsigned short *p01 = px + ox1;\n\n        if (w14)\n          wenc14(*px, *p01, i00, *p01);\n        else\n          wenc16(*px, *p01, i00, *p01);\n\n        *px = i00;\n      }\n    }\n\n    \/\/\n    \/\/ Next level\n    \/\/\n\n    p = p2;\n    p2 <<= 1;\n  }\n}","target":0,"code_token_length":842,"total_token_length":1078,"max_tokens_setting":2048}
+{"idx":269330,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Here's the basic idea:\n    \/\/ Batch and depth dimension are independent from row and col dimension. And\n    \/\/ because FractionalAvgPool currently only support pooling along row and\n    \/\/ col, we can basically think of this 4D tensor backpropagation as\n    \/\/ operation of a series of 2D planes.\n    \/\/\n    \/\/ For each element of a 'slice' (2D plane) of output_backprop, we need to\n    \/\/ figure out its contributors when doing FractionalAvgPool operation. This\n    \/\/ can be done based on row_pooling_sequence, col_pooling_seq and\n    \/\/ overlapping.\n    \/\/ Once we figure out the original contributors, we just need to evenly\n    \/\/ divide the value of this element among these contributors.\n    \/\/\n    \/\/ Internally, we divide the out_backprop tensor and store it in a temporary\n    \/\/ tensor of double type. And cast it to the corresponding type.\n    typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        ConstEigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenDoubleMatrixMap;\n\n    \/\/ Grab the inputs.\n    const Tensor& orig_input_tensor_shape = context->input(0);\n    OP_REQUIRES(context,\n                orig_input_tensor_shape.dims() == 1 &&\n                    orig_input_tensor_shape.NumElements() == 4,\n                errors::InvalidArgument(\"original input tensor shape must be\"\n                                        \"1-dimensional and 4 elements\"));\n    const Tensor& out_backprop = context->input(1);\n    const Tensor& row_seq_tensor = context->input(2);\n    const Tensor& col_seq_tensor = context->input(3);\n\n    const int64_t out_batch = out_backprop.dim_size(0);\n    const int64_t out_rows = out_backprop.dim_size(1);\n    const int64_t out_cols = out_backprop.dim_size(2);\n    const int64_t out_depth = out_backprop.dim_size(3);\n\n    OP_REQUIRES(context, row_seq_tensor.NumElements() > out_rows,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", row_seq_tensor must have at least \",\n                                        out_rows + 1, \" elements, but got \",\n                                        row_seq_tensor.NumElements()));\n    OP_REQUIRES(context, col_seq_tensor.NumElements() > out_cols,\n                errors::InvalidArgument(\"Given out_backprop shape \",\n                                        out_backprop.shape().DebugString(),\n                                        \", col_seq_tensor must have at least \",\n                                        out_cols + 1, \" elements, but got \",\n                                        col_seq_tensor.NumElements()));\n\n    auto row_seq_tensor_flat = row_seq_tensor.flat<int64>();\n    auto col_seq_tensor_flat = col_seq_tensor.flat<int64>();\n    auto orig_input_tensor_shape_flat = orig_input_tensor_shape.flat<int64>();\n\n    const int64_t in_batch = orig_input_tensor_shape_flat(0);\n    const int64_t in_rows = orig_input_tensor_shape_flat(1);\n    const int64_t in_cols = orig_input_tensor_shape_flat(2);\n    const int64_t in_depth = orig_input_tensor_shape_flat(3);\n    OP_REQUIRES(\n        context, in_batch != 0,\n        errors::InvalidArgument(\"Batch dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_rows != 0,\n        errors::InvalidArgument(\"Rows dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_cols != 0,\n        errors::InvalidArgument(\"Columns dimension of input must not be 0\"));\n    OP_REQUIRES(\n        context, in_depth != 0,\n        errors::InvalidArgument(\"Depth dimension of input must not be 0\"));\n\n    constexpr int tensor_in_and_out_dims = 4;\n    \/\/ Transform orig_input_tensor_shape into TensorShape\n    TensorShape in_shape;\n    for (auto i = 0; i < tensor_in_and_out_dims; ++i) {\n      in_shape.AddDim(orig_input_tensor_shape_flat(i));\n    }\n\n    \/\/ Create intermediate in_backprop.\n    Tensor in_backprop_tensor_temp;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(\n                                {0}, DataTypeToEnum<double>::v(), in_shape,\n                                &in_backprop_tensor_temp));\n    in_backprop_tensor_temp.flat<double>().setZero();\n    \/\/ Transform 4D tensor to 2D matrix.\n    EigenDoubleMatrixMap in_backprop_tensor_temp_mat(\n        in_backprop_tensor_temp.flat<double>().data(), in_depth,\n        in_cols * in_rows * in_batch);\n    ConstEigenMatrixMap out_backprop_mat(out_backprop.flat<T>().data(),\n                                         out_depth,\n                                         out_cols * out_rows * out_batch);\n    \/\/ Loop through each element of out_backprop and evenly distribute the\n    \/\/ element to the corresponding pooling cell.\n    const int64_t in_max_row_index = in_rows - 1;\n    const int64_t in_max_col_index = in_cols - 1;\n    for (int64_t b = 0; b < out_batch; ++b) {\n      for (int64_t r = 0; r < out_rows; ++r) {\n        const int64_t in_row_start = row_seq_tensor_flat(r);\n        int64_t in_row_end = overlapping_ ? row_seq_tensor_flat(r + 1)\n                                          : row_seq_tensor_flat(r + 1) - 1;\n        in_row_end = std::min(in_row_end, in_max_row_index);\n        for (int64_t c = 0; c < out_cols; ++c) {\n          const int64_t in_col_start = col_seq_tensor_flat(c);\n          int64_t in_col_end = overlapping_ ? col_seq_tensor_flat(c + 1)\n                                            : col_seq_tensor_flat(c + 1) - 1;\n          in_col_end = std::min(in_col_end, in_max_col_index);\n\n          const int64_t num_elements_in_pooling_cell =\n              (in_row_end - in_row_start + 1) * (in_col_end - in_col_start + 1);\n          const int64_t out_index = (b * out_rows + r) * out_cols + c;\n          \/\/ Now we can evenly distribute out_backprop(b, h, w, *) to\n          \/\/ in_backprop(b, hs:he, ws:we, *).\n          for (int64_t in_r = in_row_start; in_r <= in_row_end; ++in_r) {\n            for (int64_t in_c = in_col_start; in_c <= in_col_end; ++in_c) {\n              const int64_t in_index = (b * in_rows + in_r) * in_cols + in_c;\n              \/\/ Walk through each channel (depth).\n              for (int64_t d = 0; d < out_depth; ++d) {\n                const double out_backprop_element = static_cast<double>(\n                    out_backprop_mat.coeffRef(d, out_index));\n                double& in_backprop_ref =\n                    in_backprop_tensor_temp_mat.coeffRef(d, in_index);\n                in_backprop_ref +=\n                    out_backprop_element \/ num_elements_in_pooling_cell;\n              }\n            }\n          }\n        }\n      }\n    }\n\n    \/\/ Depending on the type, cast double to type T.\n    Tensor* in_backprop_tensor = nullptr;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(\n                                {0}, 0, in_shape, &in_backprop_tensor));\n    auto in_backprop_tensor_flat = in_backprop_tensor->flat<T>();\n    auto in_backprop_tensor_temp_flat = in_backprop_tensor_temp.flat<double>();\n    for (int64_t i = 0; i < in_backprop_tensor_flat.size(); ++i) {\n      in_backprop_tensor_flat(i) =\n          static_cast<T>(in_backprop_tensor_temp_flat(i));\n    }\n  }","target":0,"code_token_length":1699,"total_token_length":1935,"max_tokens_setting":2048}
+{"idx":261190,"func":"int MqttClient_Connect(MqttClient *client, MqttConnect *mc_connect)\n{\n    int rc, len = 0;\n\n    \/* Validate required arguments *\/\n    if (client == NULL || mc_connect == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    if (mc_connect->stat == MQTT_MSG_BEGIN) {\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n\n    #ifdef WOLFMQTT_V5\n        \/* Use specified protocol version if set *\/\n        mc_connect->protocol_level = client->protocol_level;\n    #endif\n\n        \/* Encode the connect packet *\/\n        rc = MqttEncode_Connect(client->tx_buf, client->tx_buf_len, mc_connect);\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d\",\n            rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_CONNECT),\n            MQTT_PACKET_TYPE_CONNECT, 0, 0);\n    #endif\n        if (rc <= 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n            return rc;\n        }\n        len = rc;\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        rc = wm_SemLock(&client->lockClient);\n        if (rc == 0) {\n            \/* inform other threads of expected response *\/\n            rc = MqttClient_RespList_Add(client, MQTT_PACKET_TYPE_CONNECT_ACK,\n                    0, &mc_connect->pendResp, &mc_connect->ack);\n            wm_SemUnlock(&client->lockClient);\n        }\n        if (rc != 0) {\n            wm_SemUnlock(&client->lockSend);\n            return rc; \/* Error locking client *\/\n        }\n    #endif\n\n        \/* Send connect packet *\/\n        rc = MqttPacket_Write(client, client->tx_buf, len);\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n        if (rc != len) {\n    #ifdef WOLFMQTT_MULTITHREAD\n            if ((rc != MQTT_CODE_CONTINUE) &&\n                (wm_SemLock(&client->lockClient)) == 0) {\n                MqttClient_RespList_Remove(client, &mc_connect->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n    #endif\n            return rc;\n        }\n    #ifdef WOLFMQTT_V5\n        \/* Enhanced authentication *\/\n        if (client->enable_eauth == 1) {\n            mc_connect->stat = MQTT_MSG_AUTH;\n        }\n        else\n    #endif\n        {\n            mc_connect->stat = MQTT_MSG_WAIT;\n        }\n    }\n\n#ifdef WOLFMQTT_V5\n    \/* Enhanced authentication *\/\n    if (mc_connect->protocol_level > MQTT_CONNECT_PROTOCOL_LEVEL_4 && \n            mc_connect->stat == MQTT_MSG_AUTH)\n    {\n        MqttAuth auth, *p_auth = &auth;\n        MqttProp* prop, *conn_prop;\n\n        \/* Find the AUTH property in the connect structure *\/\n        for (conn_prop = mc_connect->props;\n             (conn_prop != NULL) && (conn_prop->type != MQTT_PROP_AUTH_METHOD);\n             conn_prop = conn_prop->next) {\n        }\n        if (conn_prop == NULL) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (wm_SemLock(&client->lockClient) == 0) {\n                MqttClient_RespList_Remove(client, &mc_connect->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n        #endif\n            \/* AUTH property was not set in connect structure *\/\n            return MQTT_CODE_ERROR_BAD_ARG;\n        }\n\n        XMEMSET((void*)p_auth, 0, sizeof(MqttAuth));\n\n        \/* Set the authentication reason *\/\n        p_auth->reason_code = MQTT_REASON_CONT_AUTH;\n\n        \/* Use the same authentication method property from connect *\/\n        prop = MqttProps_Add(&p_auth->props);\n        prop->type = MQTT_PROP_AUTH_METHOD;\n        prop->data_str.str = conn_prop->data_str.str;\n        prop->data_str.len = conn_prop->data_str.len;\n\n        \/* Send the AUTH packet *\/\n        rc = MqttClient_Auth(client, p_auth);\n        MqttClient_PropsFree(p_auth->props);\n    #ifdef WOLFMQTT_NONBLOCK\n        if (rc == MQTT_CODE_CONTINUE)\n            return rc;\n    #endif\n        if (rc != len) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (wm_SemLock(&client->lockClient) == 0) {\n                MqttClient_RespList_Remove(client, &mc_connect->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n        #endif\n            return rc;\n        }\n    }\n#endif \/* WOLFMQTT_V5 *\/\n\n    \/* Wait for connect ack packet *\/\n    rc = MqttClient_WaitType(client, &mc_connect->ack,\n        MQTT_PACKET_TYPE_CONNECT_ACK, 0, client->cmd_timeout_ms);\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &mc_connect->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n    \/* reset state *\/\n    mc_connect->stat = MQTT_MSG_BEGIN;\n\n    return rc;\n}","target":0,"code_token_length":1240,"total_token_length":1476,"max_tokens_setting":2048}
+{"idx":262023,"func":"ServiceProtoValidateSamlBearerToken(ServiceConnection *conn,\n                                    ProtoRequest *req)\n{\n   VGAuthError err;\n   gchar *packet;\n   gchar *sPacket;\n   char *userName = NULL;\n   char *subjectName = NULL;\n   char *comment = NULL;\n   char *tokenStr = NULL;\n   ServiceAliasInfo *ai = NULL;\n\n   \/*\n    * The validate code will do argument validation.\n    *\/\n   err = SAML_VerifyBearerTokenAndChain(req->reqData.validateSamlBToken.samlToken,\n                                        req->reqData.validateSamlBToken.userName,\n                                        &userName,\n                                        &subjectName,\n                                        &ai);\n#ifdef _WIN32\n   \/*\n    * Only create a token in the non-info-only mode\n    *\/\n   if ((err == VGAUTH_E_OK) &&\n       !req->reqData.validateSamlBToken.validateOnly) {\n      HANDLE userToken = NULL;\n\n      err = WinToken_GenerateTokenForUser(userName, &userToken);\n      if (err == VGAUTH_E_OK) {\n         tokenStr = ServiceDupHandleTo(conn->hProc, userToken);\n         if (!tokenStr) {\n            VGAUTH_LOG_WARNING(\"ServiceDupHandleTo() failed, user = %s\",\n                               userName);\n            err = VGAUTH_E_FAIL;\n         } else {\n            \/\/ close our copy after duping into client process\n            CloseHandle(userToken);\n         }\n      } else {\n         VGAUTH_LOG_WARNING(\"WinToken_GenerateTokenForUser() failed, user = %s\",\n                            userName);\n      }\n   } else {\n      Debug(\"%s: skipping token creation\\n\", __FUNCTION__);\n   }\n#endif\n   if (err != VGAUTH_E_OK) {\n      Audit_Event(FALSE,\n                  SU_(validate.samlBearer.fail,\n                      \"Validation of SAML bearer token failed: %d\"),\n                  (int) err);    \/\/ localization code can't deal with\n                                 \/\/ differing types of uint64\n\n\n      \/*\n       * Rewrite some errors to hide any data that could be useful to an\n       * attacker.  Do this at this stage so that we still have\n       * useful debug and possibly auditing reasons.\n       *\/\n      if (err ==  VGAUTH_E_INVALID_CERTIFICATE) {\n         err = VGAUTH_E_AUTHENTICATION_DENIED;\n      }\n      packet = Proto_MakeErrorReply(conn, req, err,\n                                    \"validateSamlToken failed\");\n   } else {\n      Audit_Event(FALSE,\n                  SU_(validate.samlBearer.success,\n                      \"Validated SAML bearer token for user '%s'\"),\n                  userName);\n      \/* Value of tokenStr is always NULL on non-Windows platforms *\/\n      \/* coverity[dead_error_line] *\/\n      packet = g_markup_printf_escaped(VGAUTH_VALIDATESAMLBEARERTOKEN_REPLY_FORMAT_START,\n                                       req->sequenceNumber,\n                                       userName ? userName : \"\",\n                                       tokenStr ? tokenStr : \"\",\n                                       subjectName ? subjectName : \"\");\n\n      if (SUBJECT_TYPE_NAMED == ai->type) {\n            sPacket = g_markup_printf_escaped(VGAUTH_NAMEDALIASINFO_FORMAT,\n                                               ai->name,\n                                               ai->comment);\n      } else {\n            sPacket = g_markup_printf_escaped(VGAUTH_ANYALIASINFO_FORMAT,\n                                              ai->comment);\n      }\n      packet = Proto_ConcatXMLStrings(packet, sPacket);\n      packet = Proto_ConcatXMLStrings(packet,\n                                      g_strdup(VGAUTH_VALIDATESAMLBEARERTOKEN_REPLY_FORMAT_END));\n   }\n\n   err = ServiceNetworkWriteData(conn, strlen(packet), packet);\n   if (err != VGAUTH_E_OK) {\n      VGAUTH_LOG_WARNING(\"ServiceNetWorkWriteData() failed, pipe = %s\", conn->pipeName);\n      goto done;\n   }\n\ndone:\n   g_free(userName);\n   g_free(subjectName);\n   g_free(packet);\n   g_free(comment);\n   g_free(tokenStr);\n   ServiceAliasFreeAliasInfo(ai);\n\n   return err;\n}","target":0,"code_token_length":825,"total_token_length":1061,"max_tokens_setting":2048}
+{"idx":216726,"func":"static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,\n                                  void *ptr)\n{\n    EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);\n\n    switch(type) {\n    case EVP_CTRL_INIT:\n        if (actx == NULL)\n            actx = ctx->cipher_data\n                 = OPENSSL_zalloc(sizeof(*actx) + Poly1305_ctx_size());\n        if (actx == NULL) {\n            EVPerr(EVP_F_CHACHA20_POLY1305_CTRL, EVP_R_INITIALIZATION_ERROR);\n            return 0;\n        }\n        actx->len.aad = 0;\n        actx->len.text = 0;\n        actx->aad = 0;\n        actx->mac_inited = 0;\n        actx->tag_len = 0;\n        actx->nonce_len = 12;\n        actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;\n        memset(actx->tls_aad, 0, POLY1305_BLOCK_SIZE);\n        return 1;\n\n    case EVP_CTRL_COPY:\n        if (actx) {\n            EVP_CIPHER_CTX *dst = (EVP_CIPHER_CTX *)ptr;\n\n            dst->cipher_data =\n                   OPENSSL_memdup(actx, sizeof(*actx) + Poly1305_ctx_size());\n            if (dst->cipher_data == NULL) {\n                EVPerr(EVP_F_CHACHA20_POLY1305_CTRL, EVP_R_COPY_ERROR);\n                return 0;\n            }\n        }\n        return 1;\n\n    case EVP_CTRL_AEAD_SET_IVLEN:\n        if (arg <= 0 || arg > CHACHA_CTR_SIZE)\n            return 0;\n        actx->nonce_len = arg;\n        return 1;\n\n    case EVP_CTRL_AEAD_SET_IV_FIXED:\n        if (arg != 12)\n            return 0;\n        actx->nonce[0] = actx->key.counter[1]\n                       = CHACHA_U8TOU32((unsigned char *)ptr);\n        actx->nonce[1] = actx->key.counter[2]\n                       = CHACHA_U8TOU32((unsigned char *)ptr+4);\n        actx->nonce[2] = actx->key.counter[3]\n                       = CHACHA_U8TOU32((unsigned char *)ptr+8);\n        return 1;\n\n    case EVP_CTRL_AEAD_SET_TAG:\n        if (arg <= 0 || arg > POLY1305_BLOCK_SIZE)\n            return 0;\n        if (ptr != NULL) {\n            memcpy(actx->tag, ptr, arg);\n            actx->tag_len = arg;\n        }\n        return 1;\n\n    case EVP_CTRL_AEAD_GET_TAG:\n        if (arg <= 0 || arg > POLY1305_BLOCK_SIZE || !ctx->encrypt)\n            return 0;\n        memcpy(ptr, actx->tag, arg);\n        return 1;\n\n    case EVP_CTRL_AEAD_TLS1_AAD:\n        if (arg != EVP_AEAD_TLS1_AAD_LEN)\n            return 0;\n        {\n            unsigned int len;\n            unsigned char *aad = ptr;\n\n            memcpy(actx->tls_aad, ptr, EVP_AEAD_TLS1_AAD_LEN);\n            len = aad[EVP_AEAD_TLS1_AAD_LEN - 2] << 8 |\n                  aad[EVP_AEAD_TLS1_AAD_LEN - 1];\n            aad = actx->tls_aad;\n            if (!ctx->encrypt) {\n                if (len < POLY1305_BLOCK_SIZE)\n                    return 0;\n                len -= POLY1305_BLOCK_SIZE;     \/* discount attached tag *\/\n                aad[EVP_AEAD_TLS1_AAD_LEN - 2] = (unsigned char)(len >> 8);\n                aad[EVP_AEAD_TLS1_AAD_LEN - 1] = (unsigned char)len;\n            }\n            actx->tls_payload_length = len;\n\n            \/*\n             * merge record sequence number as per RFC7905\n             *\/\n            actx->key.counter[1] = actx->nonce[0];\n            actx->key.counter[2] = actx->nonce[1] ^ CHACHA_U8TOU32(aad);\n            actx->key.counter[3] = actx->nonce[2] ^ CHACHA_U8TOU32(aad+4);\n            actx->mac_inited = 0;\n\n            return POLY1305_BLOCK_SIZE;         \/* tag length *\/\n        }\n\n    case EVP_CTRL_AEAD_SET_MAC_KEY:\n        \/* no-op *\/\n        return 1;\n\n    default:\n        return -1;\n    }\n}","target":1,"code_token_length":1036,"total_token_length":1272,"max_tokens_setting":2048}
+{"idx":254736,"func":"njs_data_view_prototype_get(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t type)\n{\n    double              v;\n    uint32_t            u32;\n    uint64_t            index;\n    njs_int_t           ret;\n    njs_bool_t          swap;\n    njs_value_t         *this;\n    const uint8_t       *u8;\n    njs_conv_f32_t      conv_f32;\n    njs_conv_f64_t      conv_f64;\n    njs_data_view_t     *view;\n    njs_array_buffer_t  *buffer;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_data_view(this))) {\n        njs_type_error(vm, \"this is not a DataView\");\n        return NJS_ERROR;\n    }\n\n    ret = njs_value_to_index(vm, njs_arg(args, nargs, 1), &index);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    swap = njs_bool(njs_arg(args, nargs, 2));\n\n#if NJS_HAVE_LITTLE_ENDIAN\n    swap = !swap;\n#endif\n\n    view = njs_data_view(this);\n    if (njs_slow_path(njs_is_detached_buffer(view->buffer))) {\n        njs_type_error(vm, \"detached buffer\");\n        return NJS_ERROR;\n    }\n\n    if (njs_typed_array_element_size(type) + index > view->byte_length) {\n        njs_range_error(vm, \"index %uL is outside the bound of the buffer\",\n                        index);\n        return NJS_ERROR;\n    }\n\n    buffer = view->buffer;\n    u8 = &buffer->u.u8[index + view->offset];\n\n    switch (type) {\n    case NJS_OBJ_TYPE_UINT8_ARRAY:\n        v = *u8;\n        break;\n\n    case NJS_OBJ_TYPE_INT8_ARRAY:\n        v = (int8_t) *u8;\n        break;\n\n    case NJS_OBJ_TYPE_UINT16_ARRAY:\n        u32 = njs_get_u16(u8);\n\n        if (swap) {\n            u32 = njs_bswap_u16(u32);\n        }\n\n        v = u32;\n        break;\n\n    case NJS_OBJ_TYPE_INT16_ARRAY:\n        u32 = njs_get_u16(u8);\n\n        if (swap) {\n            u32 = njs_bswap_u16(u32);\n        }\n\n        v = (int16_t) u32;\n        break;\n\n    case NJS_OBJ_TYPE_UINT32_ARRAY:\n    case NJS_OBJ_TYPE_INT32_ARRAY:\n    case NJS_OBJ_TYPE_FLOAT32_ARRAY:\n        u32 = njs_get_u32(u8);\n\n        if (swap) {\n            u32 = njs_bswap_u32(u32);\n        }\n\n        switch (type) {\n        case NJS_OBJ_TYPE_UINT32_ARRAY:\n            v = u32;\n            break;\n\n        case NJS_OBJ_TYPE_INT32_ARRAY:\n            v = (int32_t) u32;\n            break;\n\n        default:\n            conv_f32.u = u32;\n            v = conv_f32.f;\n        }\n\n        break;\n\n    default:\n        \/* NJS_OBJ_TYPE_FLOAT64_ARRAY. *\/\n\n        conv_f64.u = njs_get_u64(u8);\n\n        if (swap) {\n            conv_f64.u = njs_bswap_u64(conv_f64.u);\n        }\n\n        v = conv_f64.f;\n    }\n\n    njs_set_number(&vm->retval, v);\n\n    return NJS_OK;\n}","target":0,"code_token_length":806,"total_token_length":1042,"max_tokens_setting":2048}
+{"idx":265452,"func":"static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,\n\t\t\t   int token_count, u32 *m_list, int m_count)\n{\n\tstruct squashfs_super_block *sblk = ctxt.sblk;\n\tchar *path, *target, **sym_tokens, *res, *rem;\n\tint j, ret = 0, new_inode_number, offset;\n\tstruct squashfs_symlink_inode *sym;\n\tstruct squashfs_ldir_inode *ldir;\n\tstruct squashfs_dir_inode *dir;\n\tstruct fs_dir_stream *dirsp;\n\tstruct fs_dirent *dent;\n\tunsigned char *table;\n\n\tres = NULL;\n\trem = NULL;\n\tpath = NULL;\n\ttarget = NULL;\n\tsym_tokens = NULL;\n\n\tdirsp = (struct fs_dir_stream *)dirs;\n\n\t\/* Start by root inode *\/\n\ttable = sqfs_find_inode(dirs->inode_table, le32_to_cpu(sblk->inodes),\n\t\t\t\tsblk->inodes, sblk->block_size);\n\n\tdir = (struct squashfs_dir_inode *)table;\n\tldir = (struct squashfs_ldir_inode *)table;\n\n\t\/* get directory offset in directory table *\/\n\toffset = sqfs_dir_offset(table, m_list, m_count);\n\tdirs->table = &dirs->dir_table[offset];\n\n\t\/* Setup directory header *\/\n\tdirs->dir_header = malloc(SQFS_DIR_HEADER_SIZE);\n\tif (!dirs->dir_header)\n\t\treturn -ENOMEM;\n\n\tmemcpy(dirs->dir_header, dirs->table, SQFS_DIR_HEADER_SIZE);\n\n\t\/* Initialize squashfs_dir_stream members *\/\n\tdirs->table += SQFS_DIR_HEADER_SIZE;\n\tdirs->size = get_unaligned_le16(&dir->file_size) - SQFS_DIR_HEADER_SIZE;\n\tdirs->entry_count = dirs->dir_header->count + 1;\n\n\t\/* No path given -> root directory *\/\n\tif (!strcmp(token_list[0], \"\/\")) {\n\t\tdirs->table = &dirs->dir_table[offset];\n\t\tmemcpy(&dirs->i_dir, dir, sizeof(*dir));\n\t\treturn 0;\n\t}\n\n\tfor (j = 0; j < token_count; j++) {\n\t\tif (!sqfs_is_dir(get_unaligned_le16(&dir->inode_type))) {\n\t\t\tprintf(\"** Cannot find directory. **\\n\");\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\twhile (!sqfs_readdir(dirsp, &dent)) {\n\t\t\tret = strcmp(dent->name, token_list[j]);\n\t\t\tif (!ret)\n\t\t\t\tbreak;\n\t\t\tfree(dirs->entry);\n\t\t\tdirs->entry = NULL;\n\t\t}\n\n\t\tif (ret) {\n\t\t\tprintf(\"** Cannot find directory. **\\n\");\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Redefine inode as the found token *\/\n\t\tnew_inode_number = dirs->entry->inode_offset +\n\t\t\tdirs->dir_header->inode_number;\n\n\t\t\/* Get reference to inode in the inode table *\/\n\t\ttable = sqfs_find_inode(dirs->inode_table, new_inode_number,\n\t\t\t\t\tsblk->inodes, sblk->block_size);\n\t\tdir = (struct squashfs_dir_inode *)table;\n\n\t\t\/* Check for symbolic link and inode type sanity *\/\n\t\tif (get_unaligned_le16(&dir->inode_type) == SQFS_SYMLINK_TYPE) {\n\t\t\tsym = (struct squashfs_symlink_inode *)table;\n\t\t\t\/* Get first j + 1 tokens *\/\n\t\t\tpath = sqfs_concat_tokens(token_list, j + 1);\n\t\t\tif (!path) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\t\/* Resolve for these tokens *\/\n\t\t\ttarget = sqfs_resolve_symlink(sym, path);\n\t\t\tif (!target) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\t\/* Join remaining tokens *\/\n\t\t\trem = sqfs_concat_tokens(token_list + j + 1, token_count -\n\t\t\t\t\t\t j - 1);\n\t\t\tif (!rem) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\t\/* Concatenate remaining tokens and symlink's target *\/\n\t\t\tres = malloc(strlen(rem) + strlen(target) + 1);\n\t\t\tif (!res) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tstrcpy(res, target);\n\t\t\tres[strlen(target)] = '\/';\n\t\t\tstrcpy(res + strlen(target) + 1, rem);\n\t\t\ttoken_count = sqfs_count_tokens(res);\n\n\t\t\tif (token_count < 0) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\tsym_tokens = malloc(token_count * sizeof(char *));\n\t\t\tif (!sym_tokens) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\t\/* Fill tokens list *\/\n\t\t\tret = sqfs_tokenize(sym_tokens, token_count, res);\n\t\t\tif (ret) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tfree(dirs->entry);\n\t\t\tdirs->entry = NULL;\n\n\t\t\tret = sqfs_search_dir(dirs, sym_tokens, token_count,\n\t\t\t\t\t      m_list, m_count);\n\t\t\tgoto out;\n\t\t} else if (!sqfs_is_dir(get_unaligned_le16(&dir->inode_type))) {\n\t\t\tprintf(\"** Cannot find directory. **\\n\");\n\t\t\tfree(dirs->entry);\n\t\t\tdirs->entry = NULL;\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/* Check if it is an extended dir. *\/\n\t\tif (get_unaligned_le16(&dir->inode_type) == SQFS_LDIR_TYPE)\n\t\t\tldir = (struct squashfs_ldir_inode *)table;\n\n\t\t\/* Get dir. offset into the directory table *\/\n\t\toffset = sqfs_dir_offset(table, m_list, m_count);\n\t\tdirs->table = &dirs->dir_table[offset];\n\n\t\t\/* Copy directory header *\/\n\t\tmemcpy(dirs->dir_header, &dirs->dir_table[offset],\n\t\t       SQFS_DIR_HEADER_SIZE);\n\n\t\t\/* Check for empty directory *\/\n\t\tif (sqfs_is_empty_dir(table)) {\n\t\t\tprintf(\"Empty directory.\\n\");\n\t\t\tfree(dirs->entry);\n\t\t\tdirs->entry = NULL;\n\t\t\tret = SQFS_EMPTY_DIR;\n\t\t\tgoto out;\n\t\t}\n\n\t\tdirs->table += SQFS_DIR_HEADER_SIZE;\n\t\tdirs->size = get_unaligned_le16(&dir->file_size);\n\t\tdirs->entry_count = dirs->dir_header->count + 1;\n\t\tdirs->size -= SQFS_DIR_HEADER_SIZE;\n\t\tfree(dirs->entry);\n\t\tdirs->entry = NULL;\n\t}\n\n\toffset = sqfs_dir_offset(table, m_list, m_count);\n\tdirs->table = &dirs->dir_table[offset];\n\n\tif (get_unaligned_le16(&dir->inode_type) == SQFS_DIR_TYPE)\n\t\tmemcpy(&dirs->i_dir, dir, sizeof(*dir));\n\telse\n\t\tmemcpy(&dirs->i_ldir, ldir, sizeof(*ldir));\n\nout:\n\tfree(res);\n\tfree(rem);\n\tfree(path);\n\tfree(target);\n\tfree(sym_tokens);\n\treturn ret;\n}","target":0,"code_token_length":1478,"total_token_length":1714,"max_tokens_setting":2048}
+{"idx":432703,"func":"static void ipa_device_begin(wmfAPI * API)\n{\n  char\n    comment[MagickPathExtent],\n    *url;\n\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  \/* Make SVG output happy *\/\n  (void) PushDrawingWand(WmfDrawingWand);\n\n  DrawSetViewbox(WmfDrawingWand,0,0,ddata->image->columns,ddata->image->rows);\n\n  url=GetMagickHomeURL();\n  (void) FormatLocaleString(comment,MagickPathExtent,\n    \"Created by ImageMagick %s\",url);\n  url=DestroyString(url);\n  DrawComment(WmfDrawingWand,comment);\n\n  \/* Scale width and height to image *\/\n  DrawScale(WmfDrawingWand, ddata->scale_x, ddata->scale_y);\n\n  \/* Translate to TL corner of bounding box *\/\n  DrawTranslate(WmfDrawingWand, ddata->translate_x, ddata->translate_y);\n\n  \/* Apply rotation *\/\n  DrawRotate(WmfDrawingWand, ddata->rotate);\n\n  if (ddata->image_info->texture == NULL)\n    {\n      PixelWand\n        *background_color;\n\n      \/* Draw rectangle in background color *\/\n      background_color=NewPixelWand();\n      PixelSetPixelColor(background_color,&ddata->image->background_color);\n      DrawSetFillColor(WmfDrawingWand,background_color);\n      background_color=DestroyPixelWand(background_color);\n      DrawRectangle(WmfDrawingWand,\n                     XC(ddata->bbox.TL.x),YC(ddata->bbox.TL.y),\n                     XC(ddata->bbox.BR.x),YC(ddata->bbox.BR.y));\n    }\n  else\n    {\n      \/* Draw rectangle with texture image the SVG way *\/\n      Image\n        *image;\n\n      ImageInfo\n        *image_info;\n\n      ExceptionInfo\n        *exception;\n\n      exception=AcquireExceptionInfo();\n\n      image_info = CloneImageInfo((ImageInfo *) 0);\n      (void) CopyMagickString(image_info->filename,ddata->image_info->texture,\n        MagickPathExtent);\n      if ( ddata->image_info->size )\n        CloneString(&image_info->size,ddata->image_info->size);\n\n      image = ReadImage(image_info,exception);\n      (void) DestroyExceptionInfo(exception);\n      image_info=DestroyImageInfo(image_info);\n      if (image)\n        {\n          char\n            pattern_id[MagickPathExtent];\n\n          MagickWand\n            *magick_wand;\n\n          (void) CopyMagickString(image->magick,\"MIFF\",MagickPathExtent);\n          DrawPushDefs(WmfDrawingWand);\n          draw_pattern_push(API,ddata->pattern_id,image->columns,image->rows);\n          magick_wand=NewMagickWandFromImage(image);\n          (void) DrawComposite(WmfDrawingWand,CopyCompositeOp,0,0,\n            image->columns,image->rows,magick_wand);\n          magick_wand=DestroyMagickWand(magick_wand);\n          (void) DrawPopPattern(WmfDrawingWand);\n          DrawPopDefs(WmfDrawingWand);\n          (void) FormatLocaleString(pattern_id,MagickPathExtent,\"#brush_%lu\",\n            ddata->pattern_id);\n          (void) DrawSetFillPatternURL(WmfDrawingWand,pattern_id);\n          ++ddata->pattern_id;\n          DrawRectangle(WmfDrawingWand,\n            XC(ddata->bbox.TL.x),YC(ddata->bbox.TL.y),\n            XC(ddata->bbox.BR.x),YC(ddata->bbox.BR.y));\n          image=DestroyImageList(image);\n        }\n      else\n        {\n          LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"reading texture image failed!\");\n        }\n    }\n\n  DrawSetClipRule(WmfDrawingWand,EvenOddRule); \/* Default for WMF is ALTERNATE polygon fill mode *\/\n  draw_fill_color_string(WmfDrawingWand,\"none\"); \/* Default brush is WHITE_BRUSH *\/\n  draw_stroke_color_string(WmfDrawingWand,\"none\"); \/* Default pen is BLACK_PEN *\/\n  DrawSetStrokeLineCap(WmfDrawingWand,ButtCap); \/* Default linecap is PS_ENDCAP_FLAT *\/\n  DrawSetStrokeLineJoin(WmfDrawingWand,MiterJoin); \/* Default linejoin is PS_JOIN_MITER *\/\n  draw_under_color_string(WmfDrawingWand,\"white\"); \/* Default text box is white *\/\n}","target":0,"code_token_length":959,"total_token_length":1195,"max_tokens_setting":2048}
+{"idx":195801,"func":" *\/\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t*pce;\n\tzval\t\t\t\tobj;\n\n\/* OBJECTS_FIXME *\/\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp((char *)name, EL_STRING) || !strcmp((char *)name, EL_NUMBER) ||\n\t\t!strcmp((char *)name, EL_BOOLEAN) || !strcmp((char *)name, EL_NULL) ||\n\t  \t!strcmp((char *)name, EL_ARRAY) || !strcmp((char *)name, EL_STRUCT) ||\n\t\t!strcmp((char *)name, EL_RECORDSET) || !strcmp((char *)name, EL_BINARY) ||\n\t\t!strcmp((char *)name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (Z_TYPE(ent1->data) == IS_UNDEF) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp((char *)name, EL_BINARY)) {\n\t\t\tzend_string *new_str = php_base64_decode(\n\t\t\t\t(unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));\n\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\tZVAL_STR(&ent1->data, new_str);\n\t\t}\n\n\t\t\/* Call __wakeup() method on the object. *\/\n\t\tif (Z_TYPE(ent1->data) == IS_OBJECT) {\n\t\t\tzval fname, retval;\n\n\t\t\tZVAL_STRING(&fname, \"__wakeup\");\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, &fname, &retval, 0, 0, 0, NULL);\n\n\t\t\tzval_ptr_dtor(&fname);\n\t\t\tzval_ptr_dtor(&retval);\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t\/* if non-existent field *\/\n\t\t\tif (ent2->type == ST_FIELD && Z_ISUNDEF(ent2->data)) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE(ent2->data) == IS_ARRAY || Z_TYPE(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(&ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE(ent1->data) == IS_STRING && Z_STRLEN(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));\n\t\t\t\t\t\tzend_string_forget_hash_val(Z_STR(ent1->data));\n\t\t\t\t\t\tif ((pce = zend_hash_find_ptr(EG(class_table), Z_STR(ent1->data))) == NULL) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\/* Initialize target object *\/\n\t\t\t\t\t\tobject_init_ex(&obj, pce);\n\n\t\t\t\t\t\t\/* Merge current hashtable with object's default properties *\/\n\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP(obj),\n\t\t\t\t\t\t\t\t\t\tZ_ARRVAL(ent2->data),\n\t\t\t\t\t\t\t\t\t\tzval_add_ref, 0);\n\n\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\tphp_store_class_name(&obj, Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\/* Clean up old array entry *\/\n\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t\/* Set stack entry to point to the newly created object *\/\n\t\t\t\t\t\tZVAL_COPY_VALUE(&ent2->data, &obj);\n\n\t\t\t\t\t\t\/* Clean up class name var entry *\/\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE(ent2->data);\n\t\t\t\t\t\tadd_property_zval(&ent2->data, ent1->varname, &ent1->data);\n\t\t\t\t\t\tif Z_REFCOUNTED(ent1->data) Z_DELREF(ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_str_update(target_hash, ent1->varname, strlen(ent1->varname), &ent1->data);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp((char *)name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp((char *)name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}","target":1,"code_token_length":1177,"total_token_length":1413,"max_tokens_setting":2048}
+{"idx":199918,"func":"spell_move_to(\n    win_T\t*wp,\n    int\t\tdir,\t\t\/\/ FORWARD or BACKWARD\n    int\t\tallwords,\t\/\/ TRUE for \"[s\"\/\"]s\", FALSE for \"[S\"\/\"]S\"\n    int\t\tcurline,\n    hlf_T\t*attrp)\t\t\/\/ return: attributes of bad word or NULL\n\t\t\t\t\/\/ (only when \"dir\" is FORWARD)\n{\n    linenr_T\tlnum;\n    pos_T\tfound_pos;\n    int\t\tfound_len = 0;\n    char_u\t*line;\n    char_u\t*p;\n    char_u\t*endp;\n    hlf_T\tattr;\n    int\t\tlen;\n#ifdef FEAT_SYN_HL\n    int\t\thas_syntax = syntax_present(wp);\n#endif\n    int\t\tcol;\n    int\t\tcan_spell;\n    char_u\t*buf = NULL;\n    int\t\tbuflen = 0;\n    int\t\tskip = 0;\n    int\t\tcapcol = -1;\n    int\t\tfound_one = FALSE;\n    int\t\twrapped = FALSE;\n\n    if (no_spell_checking(wp))\n\treturn 0;\n\n    \/*\n     * Start looking for bad word at the start of the line, because we can't\n     * start halfway a word, we don't know where it starts or ends.\n     *\n     * When searching backwards, we continue in the line to find the last\n     * bad word (in the cursor line: before the cursor).\n     *\n     * We concatenate the start of the next line, so that wrapped words work\n     * (e.g. \"et<line-break>cetera\").  Doesn't work when searching backwards\n     * though...\n     *\/\n    lnum = wp->w_cursor.lnum;\n    CLEAR_POS(&found_pos);\n\n    while (!got_int)\n    {\n\tline = ml_get_buf(wp->w_buffer, lnum, FALSE);\n\n\tlen = (int)STRLEN(line);\n\tif (buflen < len + MAXWLEN + 2)\n\t{\n\t    vim_free(buf);\n\t    buflen = len + MAXWLEN + 2;\n\t    buf = alloc(buflen);\n\t    if (buf == NULL)\n\t\tbreak;\n\t}\n\n\t\/\/ In first line check first word for Capital.\n\tif (lnum == 1)\n\t    capcol = 0;\n\n\t\/\/ For checking first word with a capital skip white space.\n\tif (capcol == 0)\n\t    capcol = getwhitecols(line);\n\telse if (curline && wp == curwin)\n\t{\n\t    \/\/ For spellbadword(): check if first word needs a capital.\n\t    col = getwhitecols(line);\n\t    if (check_need_cap(lnum, col))\n\t\tcapcol = col;\n\n\t    \/\/ Need to get the line again, may have looked at the previous\n\t    \/\/ one.\n\t    line = ml_get_buf(wp->w_buffer, lnum, FALSE);\n\t}\n\n\t\/\/ Copy the line into \"buf\" and append the start of the next line if\n\t\/\/ possible.\n\tSTRCPY(buf, line);\n\tif (lnum < wp->w_buffer->b_ml.ml_line_count)\n\t    spell_cat_line(buf + STRLEN(buf),\n\t\t\t  ml_get_buf(wp->w_buffer, lnum + 1, FALSE), MAXWLEN);\n\n\tp = buf + skip;\n\tendp = buf + len;\n\twhile (p < endp)\n\t{\n\t    \/\/ When searching backward don't search after the cursor.  Unless\n\t    \/\/ we wrapped around the end of the buffer.\n\t    if (dir == BACKWARD\n\t\t    && lnum == wp->w_cursor.lnum\n\t\t    && !wrapped\n\t\t    && (colnr_T)(p - buf) >= wp->w_cursor.col)\n\t\tbreak;\n\n\t    \/\/ start of word\n\t    attr = HLF_COUNT;\n\t    len = spell_check(wp, p, &attr, &capcol, FALSE);\n\n\t    if (attr != HLF_COUNT)\n\t    {\n\t\t\/\/ We found a bad word.  Check the attribute.\n\t\tif (allwords || attr == HLF_SPB)\n\t\t{\n\t\t    \/\/ When searching forward only accept a bad word after\n\t\t    \/\/ the cursor.\n\t\t    if (dir == BACKWARD\n\t\t\t    || lnum != wp->w_cursor.lnum\n\t\t\t    || (wrapped\n\t\t\t\t|| (colnr_T)(curline ? p - buf + len\n\t\t\t\t\t\t     : p - buf)\n\t\t\t\t\t\t  > wp->w_cursor.col))\n\t\t    {\n#ifdef FEAT_SYN_HL\n\t\t\tif (has_syntax)\n\t\t\t{\n\t\t\t    col = (int)(p - buf);\n\t\t\t    (void)syn_get_id(wp, lnum, (colnr_T)col,\n\t\t\t\t\t\t    FALSE, &can_spell, FALSE);\n\t\t\t    if (!can_spell)\n\t\t\t\tattr = HLF_COUNT;\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\t    can_spell = TRUE;\n\n\t\t\tif (can_spell)\n\t\t\t{\n\t\t\t    found_one = TRUE;\n\t\t\t    found_pos.lnum = lnum;\n\t\t\t    found_pos.col = (int)(p - buf);\n\t\t\t    found_pos.coladd = 0;\n\t\t\t    if (dir == FORWARD)\n\t\t\t    {\n\t\t\t\t\/\/ No need to search further.\n\t\t\t\twp->w_cursor = found_pos;\n\t\t\t\tvim_free(buf);\n\t\t\t\tif (attrp != NULL)\n\t\t\t\t    *attrp = attr;\n\t\t\t\treturn len;\n\t\t\t    }\n\t\t\t    else if (curline)\n\t\t\t\t\/\/ Insert mode completion: put cursor after\n\t\t\t\t\/\/ the bad word.\n\t\t\t\tfound_pos.col += len;\n\t\t\t    found_len = len;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t\tfound_one = TRUE;\n\t\t}\n\t    }\n\n\t    \/\/ advance to character after the word\n\t    p += len;\n\t    capcol -= len;\n\t}\n\n\tif (dir == BACKWARD && found_pos.lnum != 0)\n\t{\n\t    \/\/ Use the last match in the line (before the cursor).\n\t    wp->w_cursor = found_pos;\n\t    vim_free(buf);\n\t    return found_len;\n\t}\n\n\tif (curline)\n\t    break;\t\/\/ only check cursor line\n\n\t\/\/ If we are back at the starting line and searched it again there\n\t\/\/ is no match, give up.\n\tif (lnum == wp->w_cursor.lnum && wrapped)\n\t    break;\n\n\t\/\/ Advance to next line.\n\tif (dir == BACKWARD)\n\t{\n\t    if (lnum > 1)\n\t\t--lnum;\n\t    else if (!p_ws)\n\t\tbreak;\t    \/\/ at first line and 'nowrapscan'\n\t    else\n\t    {\n\t\t\/\/ Wrap around to the end of the buffer.  May search the\n\t\t\/\/ starting line again and accept the last match.\n\t\tlnum = wp->w_buffer->b_ml.ml_line_count;\n\t\twrapped = TRUE;\n\t\tif (!shortmess(SHM_SEARCH))\n\t\t    give_warning((char_u *)_(top_bot_msg), TRUE);\n\t    }\n\t    capcol = -1;\n\t}\n\telse\n\t{\n\t    if (lnum < wp->w_buffer->b_ml.ml_line_count)\n\t\t++lnum;\n\t    else if (!p_ws)\n\t\tbreak;\t    \/\/ at first line and 'nowrapscan'\n\t    else\n\t    {\n\t\t\/\/ Wrap around to the start of the buffer.  May search the\n\t\t\/\/ starting line again and accept the first match.\n\t\tlnum = 1;\n\t\twrapped = TRUE;\n\t\tif (!shortmess(SHM_SEARCH))\n\t\t    give_warning((char_u *)_(bot_top_msg), TRUE);\n\t    }\n\n\t    \/\/ If we are back at the starting line and there is no match then\n\t    \/\/ give up.\n\t    if (lnum == wp->w_cursor.lnum && !found_one)\n\t\tbreak;\n\n\t    \/\/ Skip the characters at the start of the next line that were\n\t    \/\/ included in a match crossing line boundaries.\n\t    if (attr == HLF_COUNT)\n\t\tskip = (int)(p - endp);\n\t    else\n\t\tskip = 0;\n\n\t    \/\/ Capcol skips over the inserted space.\n\t    --capcol;\n\n\t    \/\/ But after empty line check first word in next line\n\t    if (*skipwhite(line) == NUL)\n\t\tcapcol = 0;\n\t}\n\n\tline_breakcheck();\n    }\n\n    vim_free(buf);\n    return 0;\n}","target":1,"code_token_length":1721,"total_token_length":1957,"max_tokens_setting":2048}
+{"idx":384771,"func":"cursor_correct(void)\n{\n    int\t\tabove = 0;\t    \/\/ screen lines above topline\n    linenr_T\ttopline;\n    int\t\tbelow = 0;\t    \/\/ screen lines below botline\n    linenr_T\tbotline;\n    int\t\tabove_wanted, below_wanted;\n    linenr_T\tcln;\t\t    \/\/ Cursor Line Number\n    int\t\tmax_off;\n    long        so = get_scrolloff_value();\n\n    \/*\n     * How many lines we would like to have above\/below the cursor depends on\n     * whether the first\/last line of the file is on screen.\n     *\/\n    above_wanted = so;\n    below_wanted = so;\n    if (mouse_dragging > 0)\n    {\n\tabove_wanted = mouse_dragging - 1;\n\tbelow_wanted = mouse_dragging - 1;\n    }\n    if (curwin->w_topline == 1)\n    {\n\tabove_wanted = 0;\n\tmax_off = curwin->w_height \/ 2;\n\tif (below_wanted > max_off)\n\t    below_wanted = max_off;\n    }\n    validate_botline();\n    if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1\n\t    && mouse_dragging == 0)\n    {\n\tbelow_wanted = 0;\n\tmax_off = (curwin->w_height - 1) \/ 2;\n\tif (above_wanted > max_off)\n\t    above_wanted = max_off;\n    }\n\n    \/*\n     * If there are sufficient file-lines above and below the cursor, we can\n     * return now.\n     *\/\n    cln = curwin->w_cursor.lnum;\n    if (cln >= curwin->w_topline + above_wanted\n\t    && cln < curwin->w_botline - below_wanted\n#ifdef FEAT_FOLDING\n\t    && !hasAnyFolding(curwin)\n#endif\n\t    )\n\treturn;\n\n    \/*\n     * Narrow down the area where the cursor can be put by taking lines from\n     * the top and the bottom until:\n     * - the desired context lines are found\n     * - the lines from the top is past the lines from the bottom\n     *\/\n    topline = curwin->w_topline;\n    botline = curwin->w_botline - 1;\n#ifdef FEAT_DIFF\n    \/\/ count filler lines as context\n    above = curwin->w_topfill;\n    below = curwin->w_filler_rows;\n#endif\n    while ((above < above_wanted || below < below_wanted) && topline < botline)\n    {\n\tif (below < below_wanted && (below <= above || above >= above_wanted))\n\t{\n#ifdef FEAT_FOLDING\n\t    if (hasFolding(botline, &botline, NULL))\n\t\t++below;\n\t    else\n#endif\n\t\tbelow += plines(botline);\n\t    --botline;\n\t}\n\tif (above < above_wanted && (above < below || below >= below_wanted))\n\t{\n#ifdef FEAT_FOLDING\n\t    if (hasFolding(topline, NULL, &topline))\n\t\t++above;\n\t    else\n#endif\n\t\tabove += PLINES_NOFILL(topline);\n#ifdef FEAT_DIFF\n\t    \/\/ Count filler lines below this line as context.\n\t    if (topline < botline)\n\t\tabove += diff_check_fill(curwin, topline + 1);\n#endif\n\t    ++topline;\n\t}\n    }\n    if (topline == botline || botline == 0)\n\tcurwin->w_cursor.lnum = topline;\n    else if (topline > botline)\n\tcurwin->w_cursor.lnum = botline;\n    else\n    {\n\tif (cln < topline && curwin->w_topline > 1)\n\t{\n\t    curwin->w_cursor.lnum = topline;\n\t    curwin->w_valid &=\n\t\t\t    ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW);\n\t}\n\tif (cln > botline && curwin->w_botline <= curbuf->b_ml.ml_line_count)\n\t{\n\t    curwin->w_cursor.lnum = botline;\n\t    curwin->w_valid &=\n\t\t\t    ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW);\n\t}\n    }\n    curwin->w_valid |= VALID_TOPLINE;\n}","target":0,"code_token_length":935,"total_token_length":1171,"max_tokens_setting":2048}
+{"idx":235252,"func":"static bool test_writeunlock(struct torture_context *tctx,\n\t\t\t     struct smbcli_state *cli)\n{\n\tunion smb_write io;\n\tNTSTATUS status;\n\tbool ret = true;\n\tint fnum;\n\tuint8_t *buf;\n\tconst int maxsize = 90000;\n\tconst char *fname = BASEDIR \"\\\\test.txt\";\n\tunsigned int seed = time(NULL);\n\tunion smb_fileinfo finfo;\n\n\tbuf = talloc_zero_array(tctx, uint8_t, maxsize);\n\n\tif (!cli->transport->negotiate.lockread_supported) {\n\t\ttorture_skip(tctx, \"Server does not support writeunlock - skipping\\n\");\n\t}\n\n\tif (!torture_setup_dir(cli, BASEDIR)) {\n\t\ttorture_fail(tctx, \"failed to setup basedir\");\n\t}\n\n\ttorture_comment(tctx, \"Testing RAW_WRITE_WRITEUNLOCK\\n\");\n\tio.generic.level = RAW_WRITE_WRITEUNLOCK;\n\n\tfnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);\n\tif (fnum == -1) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"Failed to create %s - %s\\n\", fname, smbcli_errstr(cli->tree)));\n\t}\n\n\ttorture_comment(tctx, \"Trying zero write\\n\");\n\tio.writeunlock.in.file.fnum = fnum;\n\tio.writeunlock.in.count = 0;\n\tio.writeunlock.in.offset = 0;\n\tio.writeunlock.in.remaining = 0;\n\tio.writeunlock.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.writeunlock.out.nwritten, io.writeunlock.in.count);\n\n\tsetup_buffer(buf, seed, maxsize);\n\n\ttorture_comment(tctx, \"Trying small write\\n\");\n\tio.writeunlock.in.count = 9;\n\tio.writeunlock.in.offset = 4;\n\tio.writeunlock.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);\n\tif (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf+4, seed, 9);\n\tCHECK_VALUE(IVAL(buf,0), 0);\n\n\tsetup_buffer(buf, seed, maxsize);\n\tsmbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,\n\t\t 0, WRITE_LOCK);\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.writeunlock.out.nwritten, io.writeunlock.in.count);\n\n\tmemset(buf, 0, maxsize);\n\tif (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf+4, seed, 9);\n\tCHECK_VALUE(IVAL(buf,0), 0);\n\n\tsetup_buffer(buf, seed, maxsize);\n\n\ttorture_comment(tctx, \"Trying large write\\n\");\n\tio.writeunlock.in.count = 4000;\n\tio.writeunlock.in.offset = 0;\n\tio.writeunlock.in.data = buf;\n\tsmbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,\n\t\t 0, WRITE_LOCK);\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.writeunlock.out.nwritten, 4000);\n\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);\n\n\tmemset(buf, 0, maxsize);\n\tif (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf, seed, 4000);\n\n\ttorture_comment(tctx, \"Trying bad fnum\\n\");\n\tio.writeunlock.in.file.fnum = fnum+1;\n\tio.writeunlock.in.count = 4000;\n\tio.writeunlock.in.offset = 0;\n\tio.writeunlock.in.data = buf;\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);\n\n\ttorture_comment(tctx, \"Setting file as sparse\\n\");\n\tstatus = torture_set_sparse(cli->tree, fnum);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\n\tif (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {\n\t\ttorture_skip(tctx, \"skipping large file tests - CAP_LARGE_FILES not set\\n\");\n\t}\n\n\ttorture_comment(tctx, \"Trying 2^32 offset\\n\");\n\tsetup_buffer(buf, seed, maxsize);\n\tio.writeunlock.in.file.fnum = fnum;\n\tio.writeunlock.in.count = 4000;\n\tio.writeunlock.in.offset = 0xFFFFFFFF - 2000;\n\tio.writeunlock.in.data = buf;\n\tsmbcli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,\n\t\t 0, WRITE_LOCK);\n\tstatus = smb_raw_write(cli->tree, &io);\n\tCHECK_STATUS(status, NT_STATUS_OK);\n\tCHECK_VALUE(io.writeunlock.out.nwritten, 4000);\n\tCHECK_ALL_INFO(io.writeunlock.in.count + (uint64_t)io.writeunlock.in.offset, size);\n\n\tmemset(buf, 0, maxsize);\n\tif (smbcli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {\n\t\tret = false;\n\t\ttorture_fail_goto(tctx, done, talloc_asprintf(tctx, \"read failed at %s\\n\", __location__));\n\t}\n\tCHECK_BUFFER(buf, seed, 4000);\n\ndone:\n\tsmbcli_close(cli->tree, fnum);\n\tsmb_raw_exit(cli->session);\n\tsmbcli_deltree(cli->tree, BASEDIR);\n\treturn ret;\n}","target":0,"code_token_length":1357,"total_token_length":1593,"max_tokens_setting":2048}
+{"idx":225913,"func":"GF_Err audio_sample_entry_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_MPEGAudioSampleEntryBox *ptr;\n\tchar *data;\n\tu8 a, b, c, d;\n\tu32 i, size, v, nb_alnum;\n\tGF_Err e;\n\tu64 pos, start;\n\n\tptr = (GF_MPEGAudioSampleEntryBox *)s;\n\n\tstart = gf_bs_get_position(bs);\n\tgf_bs_seek(bs, start + 8);\n\tv = gf_bs_read_u16(bs);\n\tif (v)\n\t\tptr->qtff_mode = GF_ISOM_AUDIO_QTFF_ON_NOEXT;\n\n\t\/\/try to disambiguate QTFF v1 and MP4 v1 audio sample entries ...\n\tif (v==1) {\n\t\t\/\/go to end of ISOM audio sample entry, skip 4 byte (box size field), read 4 bytes (box type) and check if this looks like a box\n\t\tgf_bs_seek(bs, start + 8 + 20  + 4);\n\t\ta = gf_bs_read_u8(bs);\n\t\tb = gf_bs_read_u8(bs);\n\t\tc = gf_bs_read_u8(bs);\n\t\td = gf_bs_read_u8(bs);\n\t\tnb_alnum = 0;\n\t\tif (isalnum(a)) nb_alnum++;\n\t\tif (isalnum(b)) nb_alnum++;\n\t\tif (isalnum(c)) nb_alnum++;\n\t\tif (isalnum(d)) nb_alnum++;\n\t\tif (nb_alnum>2) ptr->qtff_mode = GF_ISOM_AUDIO_QTFF_NONE;\n\t}\n\n\tgf_bs_seek(bs, start);\n\te = gf_isom_audio_sample_entry_read((GF_AudioSampleEntryBox*)s, bs);\n\tif (e) return e;\n\tpos = gf_bs_get_position(bs);\n\tsize = (u32) s->size;\n\n\t\/\/when cookie is set on bs, always convert qtff-style mp4a to isobmff-style\n\t\/\/since the conversion is done in addBox and we don't have the bitstream there (arg...), flag the box\n \tif (gf_bs_get_cookie(bs) & GF_ISOM_BS_COOKIE_QT_CONV) {\n \t\tptr->qtff_mode |= GF_ISOM_AUDIO_QTFF_CONVERT_FLAG;\n \t}\n\n\te = gf_isom_box_array_read(s, bs);\n\tif (!e) {\n\t\tif (s->type==GF_ISOM_BOX_TYPE_ENCA) {\n\t\t\tGF_ProtectionSchemeInfoBox *sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(s->child_boxes, GF_ISOM_BOX_TYPE_SINF);\n\n\t\t\tif (sinf && sinf->original_format) {\n\t\t\t\tu32 type = sinf->original_format->data_format;\n\t\t\t\tswitch (type) {\n\t\t\t\tcase GF_ISOM_SUBTYPE_3GP_AMR:\n\t\t\t\tcase GF_ISOM_SUBTYPE_3GP_AMR_WB:\n\t\t\t\tcase GF_ISOM_SUBTYPE_3GP_EVRC:\n\t\t\t\tcase GF_ISOM_SUBTYPE_3GP_QCELP:\n\t\t\t\tcase GF_ISOM_SUBTYPE_3GP_SMV:\n\t\t\t\t\tif (ptr->cfg_3gpp) ptr->cfg_3gpp->cfg.type = type;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn GF_OK;\n\t}\n\tif (size<8) return GF_ISOM_INVALID_FILE;\n\n\n\t\/*hack for some weird files (possibly recorded with live.com tools, needs further investigations)*\/\n\tgf_bs_seek(bs, pos);\n\tdata = (char*)gf_malloc(sizeof(char) * size);\n\tif (!data) return GF_OUT_OF_MEM;\n\n\tgf_bs_read_data(bs, data, size);\n\tfor (i=0; i<size-8; i++) {\n\t\tif (GF_4CC((u32)data[i+4], (u8)data[i+5], (u8)data[i+6], (u8)data[i+7]) == GF_ISOM_BOX_TYPE_ESDS) {\n\t\t\tGF_BitStream *mybs = gf_bs_new(data + i, size - i, GF_BITSTREAM_READ);\n\t\t\tif (ptr->esd) gf_isom_box_del_parent(&ptr->child_boxes, (GF_Box *)ptr->esd);\n\t\t\tptr->esd = NULL;\n\t\t\te = gf_isom_box_parse((GF_Box **)&ptr->esd, mybs);\n\t\t\tgf_bs_del(mybs);\n\n\t\t\tif ((e==GF_OK) && (ptr->esd->type == GF_ISOM_BOX_TYPE_ESDS)) {\n\t\t\t\tif (!ptr->child_boxes) ptr->child_boxes = gf_list_new();\n\t\t\t\tgf_list_add(ptr->child_boxes, ptr->esd);\n\t\t\t} else if (ptr->esd) {\n\t\t\t\tgf_isom_box_del((GF_Box *)ptr->esd);\n\t\t\t\tptr->esd = NULL;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tgf_free(data);\n\treturn e;\n}","target":0,"code_token_length":1049,"total_token_length":1285,"max_tokens_setting":2048}
+{"idx":484740,"func":"static int xennet_get_responses(struct netfront_queue *queue,\n\t\t\t\tstruct netfront_rx_info *rinfo, RING_IDX rp,\n\t\t\t\tstruct sk_buff_head *list,\n\t\t\t\tbool *need_xdp_flush)\n{\n\tstruct xen_netif_rx_response *rx = &rinfo->rx, rx_local;\n\tint max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD);\n\tRING_IDX cons = queue->rx.rsp_cons;\n\tstruct sk_buff *skb = xennet_get_rx_skb(queue, cons);\n\tstruct xen_netif_extra_info *extras = rinfo->extras;\n\tgrant_ref_t ref = xennet_get_rx_ref(queue, cons);\n\tstruct device *dev = &queue->info->netdev->dev;\n\tstruct bpf_prog *xdp_prog;\n\tstruct xdp_buff xdp;\n\tint slots = 1;\n\tint err = 0;\n\tu32 verdict;\n\n\tif (rx->flags & XEN_NETRXF_extra_info) {\n\t\terr = xennet_get_extras(queue, extras, rp);\n\t\tif (!err) {\n\t\t\tif (extras[XEN_NETIF_EXTRA_TYPE_XDP - 1].type) {\n\t\t\t\tstruct xen_netif_extra_info *xdp;\n\n\t\t\t\txdp = &extras[XEN_NETIF_EXTRA_TYPE_XDP - 1];\n\t\t\t\trx->offset = xdp->u.xdp.headroom;\n\t\t\t}\n\t\t}\n\t\tcons = queue->rx.rsp_cons;\n\t}\n\n\tfor (;;) {\n\t\tif (unlikely(rx->status < 0 ||\n\t\t\t     rx->offset + rx->status > XEN_PAGE_SIZE)) {\n\t\t\tif (net_ratelimit())\n\t\t\t\tdev_warn(dev, \"rx->offset: %u, size: %d\\n\",\n\t\t\t\t\t rx->offset, rx->status);\n\t\t\txennet_move_rx_slot(queue, skb, ref);\n\t\t\terr = -EINVAL;\n\t\t\tgoto next;\n\t\t}\n\n\t\t\/*\n\t\t * This definitely indicates a bug, either in this driver or in\n\t\t * the backend driver. In future this should flag the bad\n\t\t * situation to the system controller to reboot the backend.\n\t\t *\/\n\t\tif (ref == INVALID_GRANT_REF) {\n\t\t\tif (net_ratelimit())\n\t\t\t\tdev_warn(dev, \"Bad rx response id %d.\\n\",\n\t\t\t\t\t rx->id);\n\t\t\terr = -EINVAL;\n\t\t\tgoto next;\n\t\t}\n\n\t\tif (!gnttab_end_foreign_access_ref(ref)) {\n\t\t\tdev_alert(dev,\n\t\t\t\t  \"Grant still in use by backend domain\\n\");\n\t\t\tqueue->info->broken = true;\n\t\t\tdev_alert(dev, \"Disabled for further use\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tgnttab_release_grant_reference(&queue->gref_rx_head, ref);\n\n\t\trcu_read_lock();\n\t\txdp_prog = rcu_dereference(queue->xdp_prog);\n\t\tif (xdp_prog) {\n\t\t\tif (!(rx->flags & XEN_NETRXF_more_data)) {\n\t\t\t\t\/* currently only a single page contains data *\/\n\t\t\t\tverdict = xennet_run_xdp(queue,\n\t\t\t\t\t\t\t skb_frag_page(&skb_shinfo(skb)->frags[0]),\n\t\t\t\t\t\t\t rx, xdp_prog, &xdp, need_xdp_flush);\n\t\t\t\tif (verdict != XDP_PASS)\n\t\t\t\t\terr = -EINVAL;\n\t\t\t} else {\n\t\t\t\t\/* drop the frame *\/\n\t\t\t\terr = -EINVAL;\n\t\t\t}\n\t\t}\n\t\trcu_read_unlock();\n\n\t\t__skb_queue_tail(list, skb);\n\nnext:\n\t\tif (!(rx->flags & XEN_NETRXF_more_data))\n\t\t\tbreak;\n\n\t\tif (cons + slots == rp) {\n\t\t\tif (net_ratelimit())\n\t\t\t\tdev_warn(dev, \"Need more slots\\n\");\n\t\t\terr = -ENOENT;\n\t\t\tbreak;\n\t\t}\n\n\t\tRING_COPY_RESPONSE(&queue->rx, cons + slots, &rx_local);\n\t\trx = &rx_local;\n\t\tskb = xennet_get_rx_skb(queue, cons + slots);\n\t\tref = xennet_get_rx_ref(queue, cons + slots);\n\t\tslots++;\n\t}\n\n\tif (unlikely(slots > max)) {\n\t\tif (net_ratelimit())\n\t\t\tdev_warn(dev, \"Too many slots\\n\");\n\t\terr = -E2BIG;\n\t}\n\n\tif (unlikely(err))\n\t\txennet_set_rx_rsp_cons(queue, cons + slots);\n\n\treturn err;\n}","target":0,"code_token_length":919,"total_token_length":1155,"max_tokens_setting":2048}
+{"idx":261445,"func":"static enum PartMode decode_part_mode(thread_context* tctx,\n\t\t\t\t      enum PredMode pred_mode, int cLog2CbSize)\n{\n  de265_image* img = tctx->img;\n\n  if (pred_mode == MODE_INTRA) {\n    logtrace(LogSlice,\"# part_mode (INTRA)\\n\");\n\n    int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE]);\n\n    logtrace(LogSlice,\"> %s\\n\",bit ? \"2Nx2N\" : \"NxN\");\n\n    logtrace(LogSymbols,\"$1 part_mode=%d\\n\",bit ? PART_2Nx2N : PART_NxN);\n\n    return bit ? PART_2Nx2N : PART_NxN;\n  }\n  else {\n    const seq_parameter_set& sps = img->get_sps();\n\n    int bit0 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+0]);\n    if (bit0) { logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2Nx2N); return PART_2Nx2N; }\n\n    \/\/ CHECK_ME: I optimize code and fix bug here, need more VERIFY!\n    int bit1 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+1]);\n    if (cLog2CbSize > sps.Log2MinCbSizeY) {\n      if (!sps.amp_enabled_flag) {\n        logtrace(LogSymbols,\"$1 part_mode=%d\\n\",bit1 ? PART_2NxN : PART_Nx2N);\n        return bit1 ? PART_2NxN : PART_Nx2N;\n      }\n      else {\n        int bit3 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+3]);\n        if (bit3) {\n          logtrace(LogSymbols,\"$1 part_mode=%d\\n\",bit1 ? PART_2NxN : PART_Nx2N);\n          return bit1 ? PART_2NxN : PART_Nx2N;\n        }\n\n        int bit4 = decode_CABAC_bypass(&tctx->cabac_decoder);\n        if ( bit1 &&  bit4) {\n          logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2NxnD);\n          return PART_2NxnD;\n        }\n        if ( bit1 && !bit4) {\n          logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2NxnU);\n          return PART_2NxnU;\n        }\n        if (!bit1 && !bit4) {\n          logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_nLx2N);\n          return PART_nLx2N;\n        }\n        if (!bit1 &&  bit4) {\n          logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_nRx2N);\n          return PART_nRx2N;\n        }\n      }\n    }\n    else {\n      \/\/ TODO, we could save one if here when first decoding the next bin and then\n      \/\/ checkcLog2CbSize==3 when it is '0'\n\n      if (bit1) {\n        logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_2NxN);\n        return PART_2NxN;\n      }\n\n      if (cLog2CbSize==3) {\n        logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_Nx2N);\n        return PART_Nx2N;\n      }\n      else {\n        int bit2 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_PART_MODE+2]);\n        logtrace(LogSymbols,\"$1 part_mode=%d\\n\",PART_NxN-bit2);\n        return (enum PartMode)((int)PART_NxN - bit2)\/*bit2 ? PART_Nx2N : PART_NxN*\/;\n      }\n    }\n  }\n\n  assert(false); \/\/ should never be reached\n  return PART_2Nx2N;\n}","target":0,"code_token_length":895,"total_token_length":1131,"max_tokens_setting":2048}
+{"idx":261438,"func":"static int decode_significant_coeff_flag(thread_context* tctx,\n\t\t\t\t\t int xC,int yC,\n\t\t\t\t\t const uint8_t* coded_sub_block_flag,\n\t\t\t\t\t int sbWidth,\n\t\t\t\t\t int cIdx,\n\t\t\t\t\t int scanIdx)\n{\n  logtrace(LogSlice,\"# significant_coeff_flag (xC:%d yC:%d sbWidth:%d cIdx:%d scanIdx:%d)\\n\",\n           xC,yC,sbWidth,cIdx,scanIdx);\n\n  int sigCtx;\n\n  \/\/ if log2TrafoSize==2\n  if (sbWidth==1) {\n    sigCtx = ctxIdxMap[(yC<<2) + xC];\n  }\n  else if (xC+yC==0) {\n    sigCtx = 0;\n  }\n  else {\n    int xS = xC>>2;\n    int yS = yC>>2;\n    int prevCsbf = 0;\n    if (xS < sbWidth-1) { prevCsbf += coded_sub_block_flag[xS+1  +yS*sbWidth];    }\n    if (yS < sbWidth-1) { prevCsbf += coded_sub_block_flag[xS+(1+yS)*sbWidth]<<1; }\n\n    int xP = xC & 3;\n    int yP = yC & 3;\n\n    logtrace(LogSlice,\"posInSubset: %d,%d\\n\",xP,yP);\n    logtrace(LogSlice,\"prevCsbf: %d\\n\",prevCsbf);\n\n    \/\/printf(\"%d | %d %d\\n\",prevCsbf,xP,yP);\n\n    switch (prevCsbf) {\n    case 0:\n      \/\/sigCtx = (xP+yP==0) ? 2 : (xP+yP<3) ? 1 : 0;\n      sigCtx = (xP+yP>=3) ? 0 : (xP+yP>0) ? 1 : 2;\n      break;\n    case 1:\n      sigCtx = (yP==0) ? 2 : (yP==1) ? 1 : 0;\n      break;\n    case 2:\n      sigCtx = (xP==0) ? 2 : (xP==1) ? 1 : 0;\n      break;\n    default:\n      sigCtx = 2;\n      break;\n    }\n\n    logtrace(LogSlice,\"a) sigCtx=%d\\n\",sigCtx);\n\n    if (cIdx==0) {\n      if (xS+yS > 0) sigCtx+=3;\n\n      logtrace(LogSlice,\"b) sigCtx=%d\\n\",sigCtx);\n\n      \/\/ if log2TrafoSize==3\n      if (sbWidth==2) {\n        sigCtx += (scanIdx==0) ? 9 : 15;\n      } else {\n        sigCtx += 21;\n      }\n\n      logtrace(LogSlice,\"c) sigCtx=%d\\n\",sigCtx);\n    }\n    else {\n      \/\/ if log2TrafoSize==3\n      if (sbWidth==2) {\n        sigCtx+=9;\n      }\n      else {\n        sigCtx+=12;\n      }\n    }\n  }\n\n  int ctxIdxInc;\n  if (cIdx==0) { ctxIdxInc=sigCtx; }\n  else         { ctxIdxInc=27+sigCtx; }\n\n  int context = tctx->shdr->initType*42 + ctxIdxInc;\n  logtrace(LogSlice,\"context: %d\\n\",context);\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &tctx->ctx_model[CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG + context]);\n  return bit;\n}","target":0,"code_token_length":793,"total_token_length":1029,"max_tokens_setting":2048}
+{"idx":313865,"func":"nv_ident(cmdarg_T *cap)\n{\n    char_u\t*ptr = NULL;\n    char_u\t*buf;\n    unsigned\tbuflen;\n    char_u\t*newbuf;\n    char_u\t*p;\n    char_u\t*kp;\t\t\/\/ value of 'keywordprg'\n    int\t\tkp_help;\t\/\/ 'keywordprg' is \":he\"\n    int\t\tkp_ex;\t\t\/\/ 'keywordprg' starts with \":\"\n    int\t\tn = 0;\t\t\/\/ init for GCC\n    int\t\tcmdchar;\n    int\t\tg_cmd;\t\t\/\/ \"g\" command\n    int\t\ttag_cmd = FALSE;\n    char_u\t*aux_ptr;\n\n    if (cap->cmdchar == 'g')\t\/\/ \"g*\", \"g#\", \"g]\" and \"gCTRL-]\"\n    {\n\tcmdchar = cap->nchar;\n\tg_cmd = TRUE;\n    }\n    else\n    {\n\tcmdchar = cap->cmdchar;\n\tg_cmd = FALSE;\n    }\n\n    if (cmdchar == POUND)\t\/\/ the pound sign, '#' for English keyboards\n\tcmdchar = '#';\n\n    \/\/ The \"]\", \"CTRL-]\" and \"K\" commands accept an argument in Visual mode.\n    if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K')\n    {\n\tif (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL)\n\t    return;\n\tif (checkclearopq(cap->oap))\n\t    return;\n    }\n\n    if (ptr == NULL && (n = find_ident_under_cursor(&ptr,\n\t\t    (cmdchar == '*' || cmdchar == '#')\n\t\t\t\t ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0)\n    {\n\tclearop(cap->oap);\n\treturn;\n    }\n\n    \/\/ Allocate buffer to put the command in.  Inserting backslashes can\n    \/\/ double the length of the word.  p_kp \/ curbuf->b_p_kp could be added\n    \/\/ and some numbers.\n    kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp);\n    kp_help = (*kp == NUL || STRCMP(kp, \":he\") == 0\n\t\t\t\t\t\t || STRCMP(kp, \":help\") == 0);\n    if (kp_help && *skipwhite(ptr) == NUL)\n    {\n\temsg(_(e_no_identifier_under_cursor));\t \/\/ found white space only\n\treturn;\n    }\n    kp_ex = (*kp == ':');\n    buflen = (unsigned)(n * 2 + 30 + STRLEN(kp));\n    buf = alloc(buflen);\n    if (buf == NULL)\n\treturn;\n    buf[0] = NUL;\n\n    switch (cmdchar)\n    {\n\tcase '*':\n\tcase '#':\n\t    \/\/ Put cursor at start of word, makes search skip the word\n\t    \/\/ under the cursor.\n\t    \/\/ Call setpcmark() first, so \"*``\" puts the cursor back where\n\t    \/\/ it was.\n\t    setpcmark();\n\t    curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline());\n\n\t    if (!g_cmd && vim_iswordp(ptr))\n\t\tSTRCPY(buf, \"\\\\<\");\n\t    no_smartcase = TRUE;\t\/\/ don't use 'smartcase' now\n\t    break;\n\n\tcase 'K':\n\t    n = nv_K_getcmd(cap, kp, kp_help, kp_ex, &ptr, n, buf, buflen);\n\t    if (n == 0)\n\t\treturn;\n\t    break;\n\n\tcase ']':\n\t    tag_cmd = TRUE;\n#ifdef FEAT_CSCOPE\n\t    if (p_cst)\n\t\tSTRCPY(buf, \"cstag \");\n\t    else\n#endif\n\t\tSTRCPY(buf, \"ts \");\n\t    break;\n\n\tdefault:\n\t    tag_cmd = TRUE;\n\t    if (curbuf->b_help)\n\t\tSTRCPY(buf, \"he! \");\n\t    else\n\t    {\n\t\tif (g_cmd)\n\t\t    STRCPY(buf, \"tj \");\n\t\telse if (cap->count0 == 0)\n\t\t    STRCPY(buf, \"ta \");\n\t\telse\n\t\t    sprintf((char *)buf, \":%ldta \", cap->count0);\n\t    }\n    }\n\n    \/\/ Now grab the chars in the identifier\n    if (cmdchar == 'K' && !kp_help)\n    {\n\tptr = vim_strnsave(ptr, n);\n\tif (kp_ex)\n\t    \/\/ Escape the argument properly for an Ex command\n\t    p = vim_strsave_fnameescape(ptr, VSE_NONE);\n\telse\n\t    \/\/ Escape the argument properly for a shell command\n\t    p = vim_strsave_shellescape(ptr, TRUE, TRUE);\n\tvim_free(ptr);\n\tif (p == NULL)\n\t{\n\t    vim_free(buf);\n\t    return;\n\t}\n\tnewbuf = vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);\n\tif (newbuf == NULL)\n\t{\n\t    vim_free(buf);\n\t    vim_free(p);\n\t    return;\n\t}\n\tbuf = newbuf;\n\tSTRCAT(buf, p);\n\tvim_free(p);\n    }\n    else\n    {\n\tif (cmdchar == '*')\n\t    aux_ptr = (char_u *)(magic_isset() ? \"\/.*~[^$\\\\\" : \"\/^$\\\\\");\n\telse if (cmdchar == '#')\n\t    aux_ptr = (char_u *)(magic_isset() ? \"\/?.*~[^$\\\\\" : \"\/?^$\\\\\");\n\telse if (tag_cmd)\n\t{\n\t    if (curbuf->b_help)\n\t\t\/\/ \":help\" handles unescaped argument\n\t\taux_ptr = (char_u *)\"\";\n\t    else\n\t\taux_ptr = (char_u *)\"\\\\|\\\"\\n[\";\n\t}\n\telse\n\t    aux_ptr = (char_u *)\"\\\\|\\\"\\n*?[\";\n\n\tp = buf + STRLEN(buf);\n\twhile (n-- > 0)\n\t{\n\t    \/\/ put a backslash before \\ and some others\n\t    if (vim_strchr(aux_ptr, *ptr) != NULL)\n\t\t*p++ = '\\\\';\n\t    \/\/ When current byte is a part of multibyte character, copy all\n\t    \/\/ bytes of that character.\n\t    if (has_mbyte)\n\t    {\n\t\tint i;\n\t\tint len = (*mb_ptr2len)(ptr) - 1;\n\n\t\tfor (i = 0; i < len && n >= 1; ++i, --n)\n\t\t    *p++ = *ptr++;\n\t    }\n\t    *p++ = *ptr++;\n\t}\n\t*p = NUL;\n    }\n\n    \/\/ Execute the command.\n    if (cmdchar == '*' || cmdchar == '#')\n    {\n\tif (!g_cmd && (has_mbyte\n\t\t    ? vim_iswordp(mb_prevptr(ml_get_curline(), ptr))\n\t\t    : vim_iswordc(ptr[-1])))\n\t    STRCAT(buf, \"\\\\>\");\n\n\t\/\/ put pattern in search history\n\tinit_history();\n\tadd_to_history(HIST_SEARCH, buf, TRUE, NUL);\n\n\t(void)normal_search(cap, cmdchar == '*' ? '\/' : '?', buf, 0, NULL);\n    }\n    else\n    {\n\tg_tag_at_cursor = TRUE;\n\tdo_cmdline_cmd(buf);\n\tg_tag_at_cursor = FALSE;\n    }\n\n    vim_free(buf);\n}","target":0,"code_token_length":1535,"total_token_length":1771,"max_tokens_setting":2048}
+{"idx":321739,"func":"static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,\n\t\tunsigned long param)\n{\n\tstruct aspeed_lpc_ctrl *lpc_ctrl = file_aspeed_lpc_ctrl(file);\n\tstruct device *dev = file->private_data;\n\tvoid __user *p = (void __user *)param;\n\tstruct aspeed_lpc_ctrl_mapping map;\n\tu32 addr;\n\tu32 size;\n\tlong rc;\n\n\tif (copy_from_user(&map, p, sizeof(map)))\n\t\treturn -EFAULT;\n\n\tif (map.flags != 0)\n\t\treturn -EINVAL;\n\n\tswitch (cmd) {\n\tcase ASPEED_LPC_CTRL_IOCTL_GET_SIZE:\n\t\t\/* The flash windows don't report their size *\/\n\t\tif (map.window_type != ASPEED_LPC_CTRL_WINDOW_MEMORY)\n\t\t\treturn -EINVAL;\n\n\t\t\/* Support more than one window id in the future *\/\n\t\tif (map.window_id != 0)\n\t\t\treturn -EINVAL;\n\n\t\t\/* If memory-region is not described in device tree *\/\n\t\tif (!lpc_ctrl->mem_size) {\n\t\t\tdev_dbg(dev, \"Didn't find reserved memory\\n\");\n\t\t\treturn -ENXIO;\n\t\t}\n\n\t\tmap.size = lpc_ctrl->mem_size;\n\n\t\treturn copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0;\n\tcase ASPEED_LPC_CTRL_IOCTL_MAP:\n\n\t\t\/*\n\t\t * The top half of HICR7 is the MSB of the BMC address of the\n\t\t * mapping.\n\t\t * The bottom half of HICR7 is the MSB of the HOST LPC\n\t\t * firmware space address of the mapping.\n\t\t *\n\t\t * The 1 bits in the top of half of HICR8 represent the bits\n\t\t * (in the requested address) that should be ignored and\n\t\t * replaced with those from the top half of HICR7.\n\t\t * The 1 bits in the bottom half of HICR8 represent the bits\n\t\t * (in the requested address) that should be kept and pass\n\t\t * into the BMC address space.\n\t\t *\/\n\n\t\t\/*\n\t\t * It doesn't make sense to talk about a size or offset with\n\t\t * low 16 bits set. Both HICR7 and HICR8 talk about the top 16\n\t\t * bits of addresses and sizes.\n\t\t *\/\n\n\t\tif ((map.size & 0x0000ffff) || (map.offset & 0x0000ffff))\n\t\t\treturn -EINVAL;\n\n\t\t\/*\n\t\t * Because of the way the masks work in HICR8 offset has to\n\t\t * be a multiple of size.\n\t\t *\/\n\t\tif (map.offset & (map.size - 1))\n\t\t\treturn -EINVAL;\n\n\t\tif (map.window_type == ASPEED_LPC_CTRL_WINDOW_FLASH) {\n\t\t\tif (!lpc_ctrl->pnor_size) {\n\t\t\t\tdev_dbg(dev, \"Didn't find host pnor flash\\n\");\n\t\t\t\treturn -ENXIO;\n\t\t\t}\n\t\t\taddr = lpc_ctrl->pnor_base;\n\t\t\tsize = lpc_ctrl->pnor_size;\n\t\t} else if (map.window_type == ASPEED_LPC_CTRL_WINDOW_MEMORY) {\n\t\t\t\/* If memory-region is not described in device tree *\/\n\t\t\tif (!lpc_ctrl->mem_size) {\n\t\t\t\tdev_dbg(dev, \"Didn't find reserved memory\\n\");\n\t\t\t\treturn -ENXIO;\n\t\t\t}\n\t\t\taddr = lpc_ctrl->mem_base;\n\t\t\tsize = lpc_ctrl->mem_size;\n\t\t} else {\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\t\/* Check overflow first! *\/\n\t\tif (map.offset + map.size < map.offset ||\n\t\t\tmap.offset + map.size > size)\n\t\t\treturn -EINVAL;\n\n\t\tif (map.size == 0 || map.size > size)\n\t\t\treturn -EINVAL;\n\n\t\taddr += map.offset;\n\n\t\t\/*\n\t\t * addr (host lpc address) is safe regardless of values. This\n\t\t * simply changes the address the host has to request on its\n\t\t * side of the LPC bus. This cannot impact the hosts own\n\t\t * memory space by surprise as LPC specific accessors are\n\t\t * required. The only strange thing that could be done is\n\t\t * setting the lower 16 bits but the shift takes care of that.\n\t\t *\/\n\n\t\trc = regmap_write(lpc_ctrl->regmap, HICR7,\n\t\t\t\t(addr | (map.addr >> 16)));\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\trc = regmap_write(lpc_ctrl->regmap, HICR8,\n\t\t\t\t(~(map.size - 1)) | ((map.size >> 16) - 1));\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\t\/*\n\t\t * Switch to FWH2AHB mode, AST2600 only.\n\t\t *\n\t\t * The other bits in this register are interrupt status bits\n\t\t * that are cleared by writing 1. As we don't want to clear\n\t\t * them, set only the bit of interest.\n\t\t *\/\n\t\tif (lpc_ctrl->fwh2ahb)\n\t\t\tregmap_write(lpc_ctrl->regmap, HICR6, SW_FWH2AHB);\n\n\t\t\/*\n\t\t * Enable LPC FHW cycles. This is required for the host to\n\t\t * access the regions specified.\n\t\t *\/\n\t\treturn regmap_update_bits(lpc_ctrl->regmap, HICR5,\n\t\t\t\tHICR5_ENFWH | HICR5_ENL2H,\n\t\t\t\tHICR5_ENFWH | HICR5_ENL2H);\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":1179,"total_token_length":1415,"max_tokens_setting":2048}
+{"idx":253619,"func":"smb2_copychunk_range(const unsigned int xid,\n\t\t\tstruct cifsFileInfo *srcfile,\n\t\t\tstruct cifsFileInfo *trgtfile, u64 src_off,\n\t\t\tu64 len, u64 dest_off)\n{\n\tint rc;\n\tunsigned int ret_data_len;\n\tstruct copychunk_ioctl *pcchunk;\n\tstruct copychunk_ioctl_rsp *retbuf = NULL;\n\tstruct cifs_tcon *tcon;\n\tint chunks_copied = 0;\n\tbool chunk_sizes_updated = false;\n\tssize_t bytes_written, total_bytes_written = 0;\n\n\tpcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);\n\n\tif (pcchunk == NULL)\n\t\treturn -ENOMEM;\n\n\tcifs_dbg(FYI, \"%s: about to call request res key\\n\", __func__);\n\t\/* Request a key from the server to identify the source of the copy *\/\n\trc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink),\n\t\t\t\tsrcfile->fid.persistent_fid,\n\t\t\t\tsrcfile->fid.volatile_fid, pcchunk);\n\n\t\/* Note: request_res_key sets res_key null only if rc !=0 *\/\n\tif (rc)\n\t\tgoto cchunk_out;\n\n\t\/* For now array only one chunk long, will make more flexible later *\/\n\tpcchunk->ChunkCount = cpu_to_le32(1);\n\tpcchunk->Reserved = 0;\n\tpcchunk->Reserved2 = 0;\n\n\ttcon = tlink_tcon(trgtfile->tlink);\n\n\twhile (len > 0) {\n\t\tpcchunk->SourceOffset = cpu_to_le64(src_off);\n\t\tpcchunk->TargetOffset = cpu_to_le64(dest_off);\n\t\tpcchunk->Length =\n\t\t\tcpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));\n\n\t\t\/* Request server copy to target from src identified by key *\/\n\t\tkfree(retbuf);\n\t\tretbuf = NULL;\n\t\trc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,\n\t\t\ttrgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,\n\t\t\ttrue \/* is_fsctl *\/, (char *)pcchunk,\n\t\t\tsizeof(struct copychunk_ioctl),\tCIFSMaxBufSize,\n\t\t\t(char **)&retbuf, &ret_data_len);\n\t\tif (rc == 0) {\n\t\t\tif (ret_data_len !=\n\t\t\t\t\tsizeof(struct copychunk_ioctl_rsp)) {\n\t\t\t\tcifs_tcon_dbg(VFS, \"Invalid cchunk response size\\n\");\n\t\t\t\trc = -EIO;\n\t\t\t\tgoto cchunk_out;\n\t\t\t}\n\t\t\tif (retbuf->TotalBytesWritten == 0) {\n\t\t\t\tcifs_dbg(FYI, \"no bytes copied\\n\");\n\t\t\t\trc = -EIO;\n\t\t\t\tgoto cchunk_out;\n\t\t\t}\n\t\t\t\/*\n\t\t\t * Check if server claimed to write more than we asked\n\t\t\t *\/\n\t\t\tif (le32_to_cpu(retbuf->TotalBytesWritten) >\n\t\t\t    le32_to_cpu(pcchunk->Length)) {\n\t\t\t\tcifs_tcon_dbg(VFS, \"Invalid copy chunk response\\n\");\n\t\t\t\trc = -EIO;\n\t\t\t\tgoto cchunk_out;\n\t\t\t}\n\t\t\tif (le32_to_cpu(retbuf->ChunksWritten) != 1) {\n\t\t\t\tcifs_tcon_dbg(VFS, \"Invalid num chunks written\\n\");\n\t\t\t\trc = -EIO;\n\t\t\t\tgoto cchunk_out;\n\t\t\t}\n\t\t\tchunks_copied++;\n\n\t\t\tbytes_written = le32_to_cpu(retbuf->TotalBytesWritten);\n\t\t\tsrc_off += bytes_written;\n\t\t\tdest_off += bytes_written;\n\t\t\tlen -= bytes_written;\n\t\t\ttotal_bytes_written += bytes_written;\n\n\t\t\tcifs_dbg(FYI, \"Chunks %d PartialChunk %d Total %zu\\n\",\n\t\t\t\tle32_to_cpu(retbuf->ChunksWritten),\n\t\t\t\tle32_to_cpu(retbuf->ChunkBytesWritten),\n\t\t\t\tbytes_written);\n\t\t} else if (rc == -EINVAL) {\n\t\t\tif (ret_data_len != sizeof(struct copychunk_ioctl_rsp))\n\t\t\t\tgoto cchunk_out;\n\n\t\t\tcifs_dbg(FYI, \"MaxChunks %d BytesChunk %d MaxCopy %d\\n\",\n\t\t\t\tle32_to_cpu(retbuf->ChunksWritten),\n\t\t\t\tle32_to_cpu(retbuf->ChunkBytesWritten),\n\t\t\t\tle32_to_cpu(retbuf->TotalBytesWritten));\n\n\t\t\t\/*\n\t\t\t * Check if this is the first request using these sizes,\n\t\t\t * (ie check if copy succeed once with original sizes\n\t\t\t * and check if the server gave us different sizes after\n\t\t\t * we already updated max sizes on previous request).\n\t\t\t * if not then why is the server returning an error now\n\t\t\t *\/\n\t\t\tif ((chunks_copied != 0) || chunk_sizes_updated)\n\t\t\t\tgoto cchunk_out;\n\n\t\t\t\/* Check that server is not asking us to grow size *\/\n\t\t\tif (le32_to_cpu(retbuf->ChunkBytesWritten) <\n\t\t\t\t\ttcon->max_bytes_chunk)\n\t\t\t\ttcon->max_bytes_chunk =\n\t\t\t\t\tle32_to_cpu(retbuf->ChunkBytesWritten);\n\t\t\telse\n\t\t\t\tgoto cchunk_out; \/* server gave us bogus size *\/\n\n\t\t\t\/* No need to change MaxChunks since already set to 1 *\/\n\t\t\tchunk_sizes_updated = true;\n\t\t} else\n\t\t\tgoto cchunk_out;\n\t}\n\ncchunk_out:\n\tkfree(pcchunk);\n\tkfree(retbuf);\n\tif (rc)\n\t\treturn rc;\n\telse\n\t\treturn total_bytes_written;\n}","target":0,"code_token_length":1136,"total_token_length":1372,"max_tokens_setting":2048}
+{"idx":208654,"func":"PHP_MINIT_FUNCTION(snmp)\n{\n\tnetsnmp_log_handler *logh;\n\tzend_class_entry ce, cex;\n\n\tle_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);\n\n\tinit_snmp(\"snmpapp\");\n\n#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE\n\t\/* Prevent update of the snmpapp.conf file *\/\n\tnetsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);\n#endif\n\n\t\/* Disable logging, use exit status'es and related variabled to detect errors *\/\n\tshutdown_snmp_logging();\n\tlogh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);\n\tif (logh) {\n\t\tlogh->pri_max = LOG_ERR;\n\t}\n\n\tmemcpy(&php_snmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));\n\tphp_snmp_object_handlers.read_property = php_snmp_read_property;\n\tphp_snmp_object_handlers.write_property = php_snmp_write_property;\n\tphp_snmp_object_handlers.has_property = php_snmp_has_property;\n\tphp_snmp_object_handlers.get_properties = php_snmp_get_properties;\n\n\t\/* Register SNMP Class *\/\n\tINIT_CLASS_ENTRY(ce, \"SNMP\", php_snmp_class_methods);\n\tce.create_object = php_snmp_object_new;\n\tphp_snmp_object_handlers.clone_obj = NULL;\n\tphp_snmp_ce = zend_register_internal_class(&ce TSRMLS_CC);\n\n\t\/* Register SNMP Class properties *\/\n\tzend_hash_init(&php_snmp_properties, 0, NULL, NULL, 1);\n\tPHP_SNMP_ADD_PROPERTIES(&php_snmp_properties, php_snmp_property_entries);\n\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_SUFFIX\",\tNETSNMP_OID_OUTPUT_SUFFIX,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_MODULE\",\tNETSNMP_OID_OUTPUT_MODULE,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_FULL\",\t\tNETSNMP_OID_OUTPUT_FULL,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_NUMERIC\",\tNETSNMP_OID_OUTPUT_NUMERIC,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_UCD\",\t\tNETSNMP_OID_OUTPUT_UCD,\t\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OID_OUTPUT_NONE\",\t\tNETSNMP_OID_OUTPUT_NONE,\tCONST_CS | CONST_PERSISTENT);\n\n\tREGISTER_LONG_CONSTANT(\"SNMP_VALUE_LIBRARY\",\tSNMP_VALUE_LIBRARY,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_VALUE_PLAIN\",\tSNMP_VALUE_PLAIN,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_VALUE_OBJECT\",\tSNMP_VALUE_OBJECT,\tCONST_CS | CONST_PERSISTENT);\n\n\tREGISTER_LONG_CONSTANT(\"SNMP_BIT_STR\",\t\tASN_BIT_STR,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OCTET_STR\",\tASN_OCTET_STR,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OPAQUE\",\t\tASN_OPAQUE,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_NULL\",\t\tASN_NULL,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_OBJECT_ID\",\tASN_OBJECT_ID,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_IPADDRESS\",\tASN_IPADDRESS,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_COUNTER\",\t\tASN_GAUGE,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_UNSIGNED\",\t\tASN_UNSIGNED,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_TIMETICKS\",\tASN_TIMETICKS,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_UINTEGER\",\t\tASN_UINTEGER,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_INTEGER\",\t\tASN_INTEGER,\tCONST_CS | CONST_PERSISTENT);\n\tREGISTER_LONG_CONSTANT(\"SNMP_COUNTER64\",\tASN_COUNTER64,\tCONST_CS | CONST_PERSISTENT);\n\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_1\",\t\t\tSNMP_VERSION_1);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_2c\",\t\t\tSNMP_VERSION_2c);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_2C\",\t\t\tSNMP_VERSION_2c);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"VERSION_3\",\t\t\tSNMP_VERSION_3);\n\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_NOERROR\",\t\t\tPHP_SNMP_ERRNO_NOERROR);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_ANY\",\t\t\tPHP_SNMP_ERRNO_ANY);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_GENERIC\",\t\t\tPHP_SNMP_ERRNO_GENERIC);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_TIMEOUT\",\t\t\tPHP_SNMP_ERRNO_TIMEOUT);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_ERROR_IN_REPLY\",\t\tPHP_SNMP_ERRNO_ERROR_IN_REPLY);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_OID_NOT_INCREASING\",\tPHP_SNMP_ERRNO_OID_NOT_INCREASING);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_OID_PARSING_ERROR\",\tPHP_SNMP_ERRNO_OID_PARSING_ERROR);\n\tREGISTER_SNMP_CLASS_CONST_LONG(\"ERRNO_MULTIPLE_SET_QUERIES\",\tPHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES);\n\n\t\/* Register SNMPException class *\/\n\tINIT_CLASS_ENTRY(cex, \"SNMPException\", NULL);\n#ifdef HAVE_SPL\n\tphp_snmp_exception_ce = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException, NULL TSRMLS_CC);\n#else\n\tphp_snmp_exception_ce = zend_register_internal_class_ex(&cex, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);\n#endif\n\n\treturn SUCCESS;\n}","target":1,"code_token_length":1292,"total_token_length":1528,"max_tokens_setting":2048}
+{"idx":517432,"func":"static void print_alerts(HttpResponse res, Mail_T s) {\n        for (Mail_T r = s; r; r = r->next) {\n                StringBuffer_append(res->outputbuffer,\n                                    \"<tr class='stripe'><td>Alert mail to<\/td>\"\n                                    \"<td>%s<\/td><\/tr>\", r->to ? r->to : \"\");\n                StringBuffer_append(res->outputbuffer, \"<tr><td>Alert on<\/td><td>\");\n                if (r->events == Event_Null) {\n                        StringBuffer_append(res->outputbuffer, \"No events\");\n                } else if (r->events == Event_All) {\n                        StringBuffer_append(res->outputbuffer, \"All events\");\n                } else {\n                        if (IS_EVENT_SET(r->events, Event_Action))\n                                StringBuffer_append(res->outputbuffer, \"Action \");\n                        if (IS_EVENT_SET(r->events, Event_ByteIn))\n                                StringBuffer_append(res->outputbuffer, \"ByteIn \");\n                        if (IS_EVENT_SET(r->events, Event_ByteOut))\n                                StringBuffer_append(res->outputbuffer, \"ByteOut \");\n                        if (IS_EVENT_SET(r->events, Event_Checksum))\n                                StringBuffer_append(res->outputbuffer, \"Checksum \");\n                        if (IS_EVENT_SET(r->events, Event_Connection))\n                                StringBuffer_append(res->outputbuffer, \"Connection \");\n                        if (IS_EVENT_SET(r->events, Event_Content))\n                                StringBuffer_append(res->outputbuffer, \"Content \");\n                        if (IS_EVENT_SET(r->events, Event_Data))\n                                StringBuffer_append(res->outputbuffer, \"Data \");\n                        if (IS_EVENT_SET(r->events, Event_Exec))\n                                StringBuffer_append(res->outputbuffer, \"Exec \");\n                        if (IS_EVENT_SET(r->events, Event_Exist))\n                                StringBuffer_append(res->outputbuffer, \"Exist \");\n                        if (IS_EVENT_SET(r->events, Event_FsFlag))\n                                StringBuffer_append(res->outputbuffer, \"Fsflags \");\n                        if (IS_EVENT_SET(r->events, Event_Gid))\n                                StringBuffer_append(res->outputbuffer, \"Gid \");\n                        if (IS_EVENT_SET(r->events, Event_Instance))\n                                StringBuffer_append(res->outputbuffer, \"Instance \");\n                        if (IS_EVENT_SET(r->events, Event_Invalid))\n                                StringBuffer_append(res->outputbuffer, \"Invalid \");\n                        if (IS_EVENT_SET(r->events, Event_Link))\n                                StringBuffer_append(res->outputbuffer, \"Link \");\n                        if (IS_EVENT_SET(r->events, Event_NonExist))\n                                StringBuffer_append(res->outputbuffer, \"Nonexist \");\n                        if (IS_EVENT_SET(r->events, Event_Permission))\n                                StringBuffer_append(res->outputbuffer, \"Permission \");\n                        if (IS_EVENT_SET(r->events, Event_PacketIn))\n                                StringBuffer_append(res->outputbuffer, \"PacketIn \");\n                        if (IS_EVENT_SET(r->events, Event_PacketOut))\n                                StringBuffer_append(res->outputbuffer, \"PacketOut \");\n                        if (IS_EVENT_SET(r->events, Event_Pid))\n                                StringBuffer_append(res->outputbuffer, \"PID \");\n                        if (IS_EVENT_SET(r->events, Event_Icmp))\n                                StringBuffer_append(res->outputbuffer, \"Ping \");\n                        if (IS_EVENT_SET(r->events, Event_PPid))\n                                StringBuffer_append(res->outputbuffer, \"PPID \");\n                        if (IS_EVENT_SET(r->events, Event_Resource))\n                                StringBuffer_append(res->outputbuffer, \"Resource \");\n                        if (IS_EVENT_SET(r->events, Event_Saturation))\n                                StringBuffer_append(res->outputbuffer, \"Saturation \");\n                        if (IS_EVENT_SET(r->events, Event_Size))\n                                StringBuffer_append(res->outputbuffer, \"Size \");\n                        if (IS_EVENT_SET(r->events, Event_Speed))\n                                StringBuffer_append(res->outputbuffer, \"Speed \");\n                        if (IS_EVENT_SET(r->events, Event_Status))\n                                StringBuffer_append(res->outputbuffer, \"Status \");\n                        if (IS_EVENT_SET(r->events, Event_Timeout))\n                                StringBuffer_append(res->outputbuffer, \"Timeout \");\n                        if (IS_EVENT_SET(r->events, Event_Timestamp))\n                                StringBuffer_append(res->outputbuffer, \"Timestamp \");\n                        if (IS_EVENT_SET(r->events, Event_Uid))\n                                StringBuffer_append(res->outputbuffer, \"Uid \");\n                        if (IS_EVENT_SET(r->events, Event_Uptime))\n                                StringBuffer_append(res->outputbuffer, \"Uptime \");\n                }\n                StringBuffer_append(res->outputbuffer, \"<\/td><\/tr>\");\n                if (r->reminder) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<tr><td>Alert reminder<\/td><td>%u cycles<\/td><\/tr>\",\n                                            r->reminder);\n                }\n        }\n}","target":0,"code_token_length":964,"total_token_length":1200,"max_tokens_setting":2048}
+{"idx":427707,"func":"cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,\n    uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)\n{\n\tconst cdf_section_header_t *shp;\n\tcdf_section_header_t sh;\n\tconst uint8_t *p, *q, *e;\n\tsize_t i, o4, nelements, j, slen, left;\n\tcdf_property_info_t *inp;\n\n\tif (offs > UINT32_MAX \/ 4) {\n\t\terrno = EFTYPE;\n\t\tgoto out;\n\t}\n\tshp = CAST(const cdf_section_header_t *,\n\t    cdf_offset(sst->sst_tab, offs));\n\tif (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1)\n\t\tgoto out;\n\tsh.sh_len = CDF_TOLE4(shp->sh_len);\n\tif (sh.sh_len > CDF_SHLEN_LIMIT) {\n\t\terrno = EFTYPE;\n\t\tgoto out;\n\t}\n\n\tif (cdf_check_stream_offset(sst, h, shp, sh.sh_len, __LINE__) == -1)\n\t\tgoto out;\n\n\tsh.sh_properties = CDF_TOLE4(shp->sh_properties);\n\tDPRINTF((\"section len: %u properties %u\\n\", sh.sh_len,\n\t    sh.sh_properties));\n\tif (sh.sh_properties > CDF_PROP_LIMIT)\n\t\tgoto out;\n\tinp = cdf_grow_info(info, maxcount, sh.sh_properties);\n\tif (inp == NULL)\n\t\tgoto out;\n\tinp += *count;\n\t*count += sh.sh_properties;\n\tp = CAST(const uint8_t *, cdf_offset(sst->sst_tab, offs + sizeof(sh)));\n\te = CAST(const uint8_t *, cdf_offset(shp, sh.sh_len));\n\tif (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)\n\t\tgoto out;\n\n\tfor (i = 0; i < sh.sh_properties; i++) {\n\t\tif ((q = cdf_get_property_info_pos(sst, h, p, e, i)) == NULL)\n\t\t\tgoto out;\n\t\tinp[i].pi_id = CDF_GETUINT32(p, i << 1);\n\t\tleft = CAST(size_t, e - q);\n\t\tif (left < sizeof(uint32_t)) {\n\t\t\tDPRINTF((\"short info (no type)_\\n\"));\n\t\t\tgoto out;\n\t\t}\n\t\tinp[i].pi_type = CDF_GETUINT32(q, 0);\n\t\tDPRINTF((\"%\" SIZE_T_FORMAT \"u) id=%#x type=%#x offs=%#tx,%#x\\n\",\n\t\t    i, inp[i].pi_id, inp[i].pi_type, q - p, offs));\n\t\tif (inp[i].pi_type & CDF_VECTOR) {\n\t\t\tif (left < sizeof(uint32_t) * 2) {\n\t\t\t\tDPRINTF((\"missing CDF_VECTOR length\\n\"));\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tnelements = CDF_GETUINT32(q, 1);\n\t\t\tif (nelements > CDF_ELEMENT_LIMIT || nelements == 0) {\n\t\t\t\tDPRINTF((\"CDF_VECTOR with nelements == %\"\n\t\t\t\t    SIZE_T_FORMAT \"u\\n\", nelements));\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tslen = 2;\n\t\t} else {\n\t\t\tnelements = 1;\n\t\t\tslen = 1;\n\t\t}\n\t\to4 = slen * sizeof(uint32_t);\n\t\tif (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED))\n\t\t\tgoto unknown;\n\t\tswitch (inp[i].pi_type & CDF_TYPEMASK) {\n\t\tcase CDF_NULL:\n\t\tcase CDF_EMPTY:\n\t\t\tbreak;\n\t\tcase CDF_SIGNED16:\n\t\t\tif (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int16_t)))\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tcase CDF_SIGNED32:\n\t\tcase CDF_BOOL:\n\t\tcase CDF_UNSIGNED32:\n\t\tcase CDF_FLOAT:\n\t\t\tif (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int32_t)))\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tcase CDF_SIGNED64:\n\t\tcase CDF_UNSIGNED64:\n\t\tcase CDF_DOUBLE:\n\t\tcase CDF_FILETIME:\n\t\t\tif (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int64_t)))\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tcase CDF_LENGTH32_STRING:\n\t\tcase CDF_LENGTH32_WSTRING:\n\t\t\tif (nelements > 1) {\n\t\t\t\tsize_t nelem = inp - *info;\n\t\t\t\tinp = cdf_grow_info(info, maxcount, nelements);\n\t\t\t\tif (inp == NULL)\n\t\t\t\t\tgoto out;\n\t\t\t\tinp += nelem;\n\t\t\t}\n\t\t\tfor (j = 0; j < nelements && i < sh.sh_properties;\n\t\t\t    j++, i++)\n\t\t\t{\n\t\t\t\tuint32_t l;\n\n\t\t\t\tif (o4 + sizeof(uint32_t) > left)\n\t\t\t\t\tgoto out;\n\n\t\t\t\tl = CDF_GETUINT32(q, slen);\n\t\t\t\to4 += sizeof(uint32_t);\n\t\t\t\tif (o4 + l > left)\n\t\t\t\t\tgoto out;\n\n\t\t\t\tinp[i].pi_str.s_len = l;\n\t\t\t\tinp[i].pi_str.s_buf = CAST(const char *,\n\t\t\t\t    CAST(const void *, &q[o4]));\n\n\t\t\t\tDPRINTF((\"o=%\" SIZE_T_FORMAT \"u l=%d(%\"\n\t\t\t\t    SIZE_T_FORMAT \"u), t=%\" SIZE_T_FORMAT\n\t\t\t\t    \"u s=%s\\n\", o4, l, CDF_ROUND(l, sizeof(l)),\n\t\t\t\t    left, inp[i].pi_str.s_buf));\n\n\t\t\t\tif (l & 1)\n\t\t\t\t\tl++;\n\n\t\t\t\tslen += l >> 1;\n\t\t\t\to4 = slen * sizeof(uint32_t);\n\t\t\t}\n\t\t\ti--;\n\t\t\tbreak;\n\t\tcase CDF_CLIPBOARD:\n\t\t\tif (inp[i].pi_type & CDF_VECTOR)\n\t\t\t\tgoto unknown;\n\t\t\tbreak;\n\t\tdefault:\n\t\tunknown:\n\t\t\tmemset(&inp[i].pi_val, 0, sizeof(inp[i].pi_val));\n\t\t\tDPRINTF((\"Don't know how to deal with %#x\\n\",\n\t\t\t    inp[i].pi_type));\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\nout:\n\tfree(*info);\n\t*info = NULL;\n\t*count = 0;\n\t*maxcount = 0;\n\terrno = EFTYPE;\n\treturn -1;\n}","target":0,"code_token_length":1399,"total_token_length":1635,"max_tokens_setting":2048}
+{"idx":508413,"func":"open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx,\n                         Sroutine_hash_entry *rt,\n                         Prelocking_strategy *prelocking_strategy,\n                         bool has_prelocking_list,\n                         Open_table_context *ot_ctx,\n                         bool *need_prelocking, bool *routine_modifies_data)\n{\n  MDL_key::enum_mdl_namespace mdl_type= rt->mdl_request.key.mdl_namespace();\n  DBUG_ENTER(\"open_and_process_routine\");\n\n  *routine_modifies_data= false;\n\n  switch (mdl_type)\n  {\n  case MDL_key::FUNCTION:\n  case MDL_key::PROCEDURE:\n    {\n      sp_head *sp;\n      \/*\n        Try to get MDL lock on the routine.\n        Note that we do not take locks on top-level CALLs as this can\n        lead to a deadlock. Not locking top-level CALLs does not break\n        the binlog as only the statements in the called procedure show\n        up there, not the CALL itself.\n      *\/\n      if (rt != (Sroutine_hash_entry*)prelocking_ctx->sroutines_list.first ||\n          mdl_type != MDL_key::PROCEDURE)\n      {\n        \/*\n          Since we acquire only shared lock on routines we don't\n          need to care about global intention exclusive locks.\n        *\/\n        DBUG_ASSERT(rt->mdl_request.type == MDL_SHARED);\n\n        \/*\n          Waiting for a conflicting metadata lock to go away may\n          lead to a deadlock, detected by MDL subsystem.\n          If possible, we try to resolve such deadlocks by releasing all\n          metadata locks and restarting the pre-locking process.\n          To prevent the error from polluting the diagnostics area\n          in case of successful resolution, install a special error\n          handler for ER_LOCK_DEADLOCK error.\n        *\/\n        MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);\n\n        thd->push_internal_handler(&mdl_deadlock_handler);\n        bool result= thd->mdl_context.acquire_lock(&rt->mdl_request,\n                                                   ot_ctx->get_timeout());\n        thd->pop_internal_handler();\n\n        if (result)\n          DBUG_RETURN(TRUE);\n\n        DEBUG_SYNC(thd, \"after_shared_lock_pname\");\n\n        \/* Ensures the routine is up-to-date and cached, if exists. *\/\n        if (sp_cache_routine(thd, rt, has_prelocking_list, &sp))\n          DBUG_RETURN(TRUE);\n\n        \/* Remember the version of the routine in the parse tree. *\/\n        if (check_and_update_routine_version(thd, rt, sp))\n          DBUG_RETURN(TRUE);\n\n        \/* 'sp' is NULL when there is no such routine. *\/\n        if (sp)\n        {\n          *routine_modifies_data= sp->modifies_data();\n\n          if (!has_prelocking_list)\n            prelocking_strategy->handle_routine(thd, prelocking_ctx, rt, sp,\n                                                need_prelocking);\n        }\n      }\n      else\n      {\n        \/*\n          If it's a top level call, just make sure we have a recent\n          version of the routine, if it exists.\n          Validating routine version is unnecessary, since CALL\n          does not affect the prepared statement prelocked list.\n        *\/\n        if (sp_cache_routine(thd, rt, FALSE, &sp))\n          DBUG_RETURN(TRUE);\n      }\n    }\n    break;\n  case MDL_key::TRIGGER:\n    \/**\n      We add trigger entries to lex->sroutines_list, but we don't\n      load them here. The trigger entry is only used when building\n      a transitive closure of objects used in a statement, to avoid\n      adding to this closure objects that are used in the trigger more\n      than once.\n      E.g. if a trigger trg refers to table t2, and the trigger table t1\n      is used multiple times in the statement (say, because it's used in\n      function f1() twice), we will only add t2 once to the list of\n      tables to prelock.\n\n      We don't take metadata locks on triggers either: they are protected\n      by a respective lock on the table, on which the trigger is defined.\n\n      The only two cases which give \"trouble\" are SHOW CREATE TRIGGER\n      and DROP TRIGGER statements. For these, statement syntax doesn't\n      specify the table on which this trigger is defined, so we have\n      to make a \"dirty\" read in the data dictionary to find out the\n      table name. Once we discover the table name, we take a metadata\n      lock on it, and this protects all trigger operations.\n      Of course the table, in theory, may disappear between the dirty\n      read and metadata lock acquisition, but in that case we just return\n      a run-time error.\n\n      Grammar of other trigger DDL statements (CREATE, DROP) requires\n      the table to be specified explicitly, so we use the table metadata\n      lock to protect trigger metadata in these statements. Similarly, in\n      DML we always use triggers together with their tables, and thus don't\n      need to take separate metadata locks on them.\n    *\/\n    break;\n  default:\n    \/* Impossible type value. *\/\n    DBUG_ASSERT(0);\n  }\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":1092,"total_token_length":1328,"max_tokens_setting":2048}
+{"idx":445884,"func":"fr_window_archive_extract (FrWindow    *window,\n\t\t\t   GList       *file_list,\n\t\t\t   GFile       *destination,\n\t\t\t   const char  *base_dir,\n\t\t\t   gboolean     skip_older,\n\t\t\t   FrOverwrite  overwrite,\n\t\t\t   gboolean     junk_paths,\n\t\t\t   gboolean     ask_to_open_destination)\n{\n\tExtractData *edata;\n\tgboolean     do_not_extract = FALSE;\n\tGError      *error = NULL;\n\n\tedata = extract_data_new (window,\n\t\t\t\t  file_list,\n\t\t\t\t  destination,\n\t\t\t\t  base_dir,\n\t\t\t\t  skip_older,\n\t\t\t\t  overwrite,\n\t\t\t\t  junk_paths,\n\t\t\t\t  FALSE,\n\t\t\t\t  ask_to_open_destination);\n\n\tfr_window_set_current_batch_action (window,\n\t\t\t\t\t    FR_BATCH_ACTION_EXTRACT,\n\t\t\t\t\t    edata,\n\t\t\t\t\t    (GFreeFunc) extract_data_free);\n\n\tif (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL)) {\n\t\tdlg_ask_password (window);\n\t\treturn;\n\t}\n\n\tif (! _g_file_query_is_dir (edata->destination)) {\n\n\t\t\/* There is nothing to ask if the destination doesn't exist. *\/\n\t\tif (edata->overwrite == FR_OVERWRITE_ASK)\n\t\t\tedata->overwrite = FR_OVERWRITE_YES;\n\n\t\tif (! ForceDirectoryCreation) {\n\t\t\tGtkWidget *d;\n\t\t\tint        r;\n\t\t\tchar      *folder_name;\n\t\t\tchar      *msg;\n\n\t\t\tfolder_name = _g_file_get_display_basename (edata->destination);\n\t\t\tmsg = g_strdup_printf (_(\"Destination folder \\\"%s\\\" does not exist.\\n\\nDo you want to create it?\"), folder_name);\n\t\t\tg_free (folder_name);\n\n\t\t\td = _gtk_message_dialog_new (GTK_WINDOW (window),\n\t\t\t\t\t\t     GTK_DIALOG_MODAL,\n\t\t\t\t\t\t     GTK_STOCK_DIALOG_QUESTION,\n\t\t\t\t\t\t     msg,\n\t\t\t\t\t\t     NULL,\n\t\t\t\t\t\t     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,\n\t\t\t\t\t\t     _(\"Create _Folder\"), GTK_RESPONSE_YES,\n\t\t\t\t\t\t     NULL);\n\n\t\t\tgtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES);\n\t\t\tr = gtk_dialog_run (GTK_DIALOG (d));\n\t\t\tgtk_widget_destroy (GTK_WIDGET (d));\n\n\t\t\tg_free (msg);\n\n\t\t\tif (r != GTK_RESPONSE_YES)\n\t\t\t\tdo_not_extract = TRUE;\n\t\t}\n\n\t\tif (! do_not_extract && ! _g_file_make_directory_tree (edata->destination, 0755, &error)) {\n\t\t\tGtkWidget *d;\n\t\t\tchar      *details;\n\n\t\t\tdetails = g_strdup_printf (_(\"Could not create the destination folder: %s.\"), error->message);\n\t\t\td = _gtk_error_dialog_new (GTK_WINDOW (window),\n\t\t\t\t\t\t   0,\n\t\t\t\t\t\t   NULL,\n\t\t\t\t\t\t   _(\"Extraction not performed\"),\n\t\t\t\t\t\t   \"%s\",\n\t\t\t\t\t\t   details);\n\t\t\tg_clear_error (&error);\n\t\t\tfr_window_show_error_dialog (window, d, GTK_WINDOW (window), details);\n\t\t\tfr_window_stop_batch (window);\n\n\t\t\tg_free (details);\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (do_not_extract) {\n\t\tGtkWidget *d;\n\n\t\td = _gtk_message_dialog_new (GTK_WINDOW (window),\n\t\t\t\t\t     0,\n\t\t\t\t\t     GTK_STOCK_DIALOG_WARNING,\n\t\t\t\t\t     _(\"Extraction not performed\"),\n\t\t\t\t\t     NULL,\n\t\t\t\t\t     GTK_STOCK_OK, GTK_RESPONSE_OK,\n\t\t\t\t\t     NULL);\n\t\tgtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK);\n\t\tfr_window_show_error_dialog (window, d, GTK_WINDOW (window), _(\"Extraction not performed\"));\n\t\tfr_window_stop_batch (window);\n\n\t\treturn;\n\t}\n\n\tif (edata->overwrite == FR_OVERWRITE_ASK) {\n\t\tOverwriteData *odata;\n\n\t\todata = g_new0 (OverwriteData, 1);\n\t\todata->window = window;\n\t\todata->edata = edata;\n\t\todata->extract_all = (edata->file_list == NULL) || (g_list_length (edata->file_list) == window->archive->files->len);\n\t\tif (edata->file_list == NULL)\n\t\t\tedata->file_list = fr_window_get_file_list (window);\n\t\todata->current_file = odata->edata->file_list;\n\n\t\t_fr_window_ask_overwrite_dialog (odata);\n\t}\n\telse\n\t\t_fr_window_archive_extract_from_edata (window, edata);\n}","target":0,"code_token_length":866,"total_token_length":1102,"max_tokens_setting":2048}
+{"idx":508311,"func":"find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,\n                        const char *name, uint length,\n                        const char *item_name, const char *db_name,\n                        const char *table_name, Item **ref,\n                        bool check_privileges, bool allow_rowid,\n                        uint *cached_field_index_ptr,\n                        bool register_tree_change, TABLE_LIST **actual_table)\n{\n  Field *fld;\n  DBUG_ENTER(\"find_field_in_table_ref\");\n  DBUG_ASSERT(table_list->alias);\n  DBUG_ASSERT(name);\n  DBUG_ASSERT(item_name);\n  DBUG_PRINT(\"enter\",\n             (\"table: '%s'  field name: '%s'  item name: '%s'  ref %p\",\n              table_list->alias, name, item_name, ref));\n\n  \/*\n    Check that the table and database that qualify the current field name\n    are the same as the table reference we are going to search for the field.\n\n    Exclude from the test below nested joins because the columns in a\n    nested join generally originate from different tables. Nested joins\n    also have no table name, except when a nested join is a merge view\n    or an information schema table.\n\n    We include explicitly table references with a 'field_translation' table,\n    because if there are views over natural joins we don't want to search\n    inside the view, but we want to search directly in the view columns\n    which are represented as a 'field_translation'.\n\n    TODO: Ensure that table_name, db_name and tables->db always points to\n          something !\n  *\/\n  if (\/* Exclude nested joins. *\/\n      (!table_list->nested_join ||\n       \/* Include merge views and information schema tables. *\/\n       table_list->field_translation) &&\n      \/*\n        Test if the field qualifiers match the table reference we plan\n        to search.\n      *\/\n      table_name && table_name[0] &&\n      (my_strcasecmp(table_alias_charset, table_list->alias, table_name) ||\n       (db_name && db_name[0] && (!table_list->db || !table_list->db[0])) ||\n       (db_name && db_name[0] && table_list->db && table_list->db[0] &&\n        (table_list->schema_table ?\n         my_strcasecmp(system_charset_info, db_name, table_list->db) :\n         strcmp(db_name, table_list->db)))))\n    DBUG_RETURN(0);\n\n  *actual_table= NULL;\n\n  if (table_list->field_translation)\n  {\n    \/* 'table_list' is a view or an information schema table. *\/\n    if ((fld= find_field_in_view(thd, table_list, name, length, item_name, ref,\n                                 register_tree_change)))\n      *actual_table= table_list;\n  }\n  else if (!table_list->nested_join)\n  {\n    \/* 'table_list' is a stored table. *\/\n    DBUG_ASSERT(table_list->table);\n    if ((fld= find_field_in_table(thd, table_list->table, name, length,\n                                  allow_rowid,\n                                  cached_field_index_ptr)))\n      *actual_table= table_list;\n  }\n  else\n  {\n    \/*\n      'table_list' is a NATURAL\/USING join, or an operand of such join that\n      is a nested join itself.\n\n      If the field name we search for is qualified, then search for the field\n      in the table references used by NATURAL\/USING the join.\n    *\/\n    if (table_name && table_name[0])\n    {\n      List_iterator<TABLE_LIST> it(table_list->nested_join->join_list);\n      TABLE_LIST *table;\n      while ((table= it++))\n      {\n        if ((fld= find_field_in_table_ref(thd, table, name, length, item_name,\n                                          db_name, table_name, ref,\n                                          check_privileges, allow_rowid,\n                                          cached_field_index_ptr,\n                                          register_tree_change, actual_table)))\n          DBUG_RETURN(fld);\n      }\n      DBUG_RETURN(0);\n    }\n    \/*\n      Non-qualified field, search directly in the result columns of the\n      natural join. The condition of the outer IF is true for the top-most\n      natural join, thus if the field is not qualified, we will search\n      directly the top-most NATURAL\/USING join.\n    *\/\n    fld= find_field_in_natural_join(thd, table_list, name, length, ref,\n                                    register_tree_change, actual_table);\n  }\n\n  if (fld)\n  {\n#ifndef NO_EMBEDDED_ACCESS_CHECKS\n    \/* Check if there are sufficient access rights to the found field. *\/\n    if (check_privileges &&\n        !table_list->is_derived() &&\n        check_column_grant_in_table_ref(thd, *actual_table, name, length))\n      fld= WRONG_GRANT;\n    else\n#endif\n      if (thd->mark_used_columns != MARK_COLUMNS_NONE)\n      {\n        \/*\n          Get rw_set correct for this field so that the handler\n          knows that this field is involved in the query and gets\n          retrieved\/updated\n         *\/\n        Field *field_to_set= NULL;\n        if (fld == view_ref_found)\n        {\n          if (!ref)\n            DBUG_RETURN(fld);\n          Item *it= (*ref)->real_item();\n          if (it->type() == Item::FIELD_ITEM)\n            field_to_set= ((Item_field*)it)->field;\n          else\n          {\n            if (thd->mark_used_columns == MARK_COLUMNS_READ)\n              it->walk(&Item::register_field_in_read_map, 0, 0);\n            else\n              it->walk(&Item::register_field_in_write_map, 0, 0);\n          }\n        }\n        else\n          field_to_set= fld;\n        if (field_to_set)\n        {\n          TABLE *table= field_to_set->table;\n          if (thd->mark_used_columns == MARK_COLUMNS_READ)\n            field_to_set->register_field_in_read_map();\n          else\n            bitmap_set_bit(table->write_set, field_to_set->field_index);\n        }\n      }\n  }\n  DBUG_RETURN(fld);\n}","target":0,"code_token_length":1288,"total_token_length":1524,"max_tokens_setting":2048}
+{"idx":374035,"func":"static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadaddr, Sdb *sdb) {\n#if 0\n\tSYMBOLS HEADER\n\n 0\tMAGIC\t02ff01ff\n 4\tVERSION 1 (little endian)\n 8      ffffffff\n16      002b0000 01000000 { 0x2b00, 0x0000 }\n24\tUUID    16 bytes\n40\t2621 d85b 2100 2000 0000 0000 0000 0000\n56\tffff ffff ffff ff7f 0c00 0000 0900 0000\n72\t0400 0000 6800 0000 2f76 6172 2f66 6f6c .... 4, 104 \/\/\/ 104 length string\n184\n0x000000b8  5f5f 5445 5854 0000 0000 0000 0000 0000 0000 0000 0000 0000 0080 0000 0000 0000  __TEXT..........................\n0x000000d8  5f5f 4441 5441 0000 0000 0000 0000 0000 0080 0000 0000 0000 0040 0000 0000 0000  __DATA...................@......\n0x000000f8  5f5f 4c4c 564d 0000 0000 0000 0000 0000 00c0 0000 0000 0000 0000 0100 0000 0000  __LLVM..........................\n0x00000118  5f5f 4c49 4e4b 4544 4954 0000 0000 0000 00c0 0100 0000 0000 00c0 0000 0000 0000  __LINKEDIT......................\n\n#endif\n\t\/\/ 0 - magic check, version ...\n\tSymbolsHeader sh = parseHeader (buf);\n\tif (!sh.valid) {\n\t\teprintf (\"Invalid headers\\n\");\n\t\treturn false;\n\t}\n\tSymbolsMetadata sm = parseMetadata (buf, 0x40);\n\tchar * file_name = NULL;\n\tif (sm.namelen) {\n\t\tfile_name = calloc (sm.namelen + 1, 1);\n\t\tif (!file_name) {\n\t\t\treturn false;\n\t\t}\n\t\tif (r_buf_read_at (buf, 0x50, (ut8*)file_name, sm.namelen) != sm.namelen) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tRCoreSymCacheElement *element = parseDragons (bf, buf, sm.addr + sm.size, sm.bits, file_name);\n\tif (element) {\n\t\t*bin_obj = element;\n\t\treturn true;\n\t}\n\tfree (file_name);\n\treturn false;\n}","target":0,"code_token_length":848,"total_token_length":1084,"max_tokens_setting":2048}
+{"idx":230460,"func":"na_input(void)\n{\n  uint8_t is_llchange;\n  uint8_t is_router;\n  uint8_t is_solicited;\n  uint8_t is_override;\n  uip_lladdr_t lladdr_aligned;\n\n  LOG_INFO(\"Received NA from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\" to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\" with target address \");\n  LOG_INFO_6ADDR((uip_ipaddr_t *) (&UIP_ND6_NA_BUF->tgtipaddr));\n  LOG_INFO_(\"\\n\");\n  UIP_STAT(++uip_stat.nd6.recv);\n\n  \/*\n   * booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20\n   * but it works. Be careful though, do not use tests such as is_router == 1\n   *\/\n  is_llchange = 0;\n  is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));\n  is_solicited =\n    ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_SOLICITED));\n  is_override =\n    ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_OVERRIDE));\n\n#if UIP_CONF_IPV6_CHECKS\n  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||\n     (UIP_ICMP_BUF->icode != 0) ||\n     (uip_is_addr_mcast(&UIP_ND6_NA_BUF->tgtipaddr)) ||\n     (is_solicited && uip_is_addr_mcast(&UIP_IP_BUF->destipaddr))) {\n    LOG_ERR(\"NA received is bad\\n\");\n    goto discard;\n  }\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n\n  \/* Options processing: we handle TLLAO, and must ignore others *\/\n  nd6_opt_offset = UIP_ND6_NA_LEN;\n  nd6_opt_llao = NULL;\n  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {\n#if UIP_CONF_IPV6_CHECKS\n    if(ND6_OPT_HDR_BUF(nd6_opt_offset)->len == 0) {\n      LOG_ERR(\"NA received is bad\\n\");\n      goto discard;\n    }\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n    switch (ND6_OPT_HDR_BUF(nd6_opt_offset)->type) {\n    case UIP_ND6_OPT_TLLAO:\n      nd6_opt_llao = (uint8_t *)ND6_OPT_HDR_BUF(nd6_opt_offset);\n      break;\n    default:\n      LOG_WARN(\"ND option not supported in NA\\n\");\n      break;\n    }\n    nd6_opt_offset += (ND6_OPT_HDR_BUF(nd6_opt_offset)->len << 3);\n  }\n  addr = uip_ds6_addr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);\n  \/* Message processing, including TLLAO if any *\/\n  if(addr != NULL) {\n#if UIP_ND6_DEF_MAXDADNS > 0\n    if(addr->state == ADDR_TENTATIVE) {\n      uip_ds6_dad_failed(addr);\n    }\n#endif \/*UIP_ND6_DEF_MAXDADNS > 0 *\/\n    LOG_ERR(\"NA received is bad\\n\");\n    goto discard;\n  } else {\n    const uip_lladdr_t *lladdr;\n    nbr = uip_ds6_nbr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);\n    if(nbr == NULL) {\n      goto discard;\n    }\n    lladdr = uip_ds6_nbr_get_ll(nbr);\n    if(lladdr == NULL) {\n      goto discard;\n    }\n    if(nd6_opt_llao != NULL) {\n      is_llchange =\n        memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], lladdr,\n               UIP_LLADDR_LEN) == 0 ? 0 : 1;\n    }\n    if(nbr->state == NBR_INCOMPLETE) {\n      if(nd6_opt_llao == NULL || !extract_lladdr_from_llao_aligned(&lladdr_aligned)) {\n        goto discard;\n      }\n      if(uip_ds6_nbr_update_ll(&nbr,\n                               (const uip_lladdr_t *)&lladdr_aligned) < 0) {\n        \/* failed to update the lladdr *\/\n        goto discard;\n      }\n\n      \/* Note: No need to refresh the state of the nbr here.\n       * It has already been refreshed upon receiving the unicast IPv6 ND packet.\n       * See: uip_ds6_nbr_refresh_reachable_state()\n       *\/\n      if(!is_solicited) {\n        nbr->state = NBR_STALE;\n      }\n      nbr->isrouter = is_router;\n    } else { \/* NBR is not INCOMPLETE *\/\n      if(!is_override && is_llchange) {\n        if(nbr->state == NBR_REACHABLE) {\n          nbr->state = NBR_STALE;\n        }\n        goto discard;\n      } else {\n        \/**\n         *  If this is an cache override, or same lladdr, or no llao -\n         *  do updates of nbr states.\n         *\/\n        if(is_override || !is_llchange || nd6_opt_llao == NULL) {\n          if(nd6_opt_llao != NULL && is_llchange) {\n            if(!extract_lladdr_from_llao_aligned(&lladdr_aligned) ||\n               uip_ds6_nbr_update_ll(&nbr,\n                                     (const uip_lladdr_t *)&lladdr_aligned)\n               < 0) {\n              \/* failed to update the lladdr *\/\n              goto discard;\n            }\n          }\n          \/* Note: No need to refresh the state of the nbr here.\n           * It has already been refreshed upon receiving the unicast IPv6 ND packet.\n           * See: uip_ds6_nbr_refresh_reachable_state()\n           *\/\n        }\n      }\n      if(nbr->isrouter && !is_router) {\n        defrt = uip_ds6_defrt_lookup(&UIP_IP_BUF->srcipaddr);\n        if(defrt != NULL) {\n          uip_ds6_defrt_rm(defrt);\n        }\n      }\n      nbr->isrouter = is_router;\n    }\n  }\n#if UIP_CONF_IPV6_QUEUE_PKT\n  \/* The nbr is now reachable, check if we had buffered a pkt for it *\/\n  \/*if(nbr->queue_buf_len != 0) {\n    uip_len = nbr->queue_buf_len;\n    memcpy(UIP_IP_BUF, nbr->queue_buf, uip_len);\n    nbr->queue_buf_len = 0;\n    return;\n    }*\/\n  if(uip_packetqueue_buflen(&nbr->packethandle) != 0) {\n    uip_len = uip_packetqueue_buflen(&nbr->packethandle);\n    memcpy(UIP_IP_BUF, uip_packetqueue_buf(&nbr->packethandle), uip_len);\n    uip_packetqueue_free(&nbr->packethandle);\n    return;\n  }\n\n#endif \/*UIP_CONF_IPV6_QUEUE_PKT *\/\n\ndiscard:\n  uipbuf_clear();\n  return;\n}","target":0,"code_token_length":1526,"total_token_length":1762,"max_tokens_setting":2048}
+{"idx":328869,"func":"R_API char *r_bin_java_resolve(RBinJavaObj *BIN_OBJ, int idx, ut8 space_bn_name_type) {\n\t\/\/ TODO XXX FIXME add a size parameter to the str when it is passed in\n\tRBinJavaCPTypeObj *item = NULL, *item2 = NULL;\n\tchar *class_str = NULL,\n\t*name_str = NULL,\n\t*desc_str = NULL,\n\t*string_str = NULL,\n\t*empty = \"\",\n\t*cp_name = NULL,\n\t*str = NULL;\n\tif (BIN_OBJ && BIN_OBJ->cp_count < 1) {\n\t\t\/\/ r_bin_java_new_bin(BIN_OBJ);\n\t\treturn NULL;\n\t}\n\titem = (RBinJavaCPTypeObj *) r_bin_java_get_item_from_bin_cp_list (BIN_OBJ, idx);\n\tif (item) {\n\t\tcp_name = ((RBinJavaCPTypeMetas *) item->metas->type_info)->name;\n\t\tIFDBG eprintf (\"java_resolve Resolved: (%d) %s\\n\", idx, cp_name);\n\t} else {\n\t\tstr = malloc (512);\n\t\tif (str) {\n\t\t\tsnprintf (str, 512, \"(%d) INVALID CP_OBJ\", idx);\n\t\t}\n\t\treturn str;\n\t}\n\tif (strcmp (cp_name, \"Class\") == 0) {\n\t\titem2 = (RBinJavaCPTypeObj *) r_bin_java_get_item_from_bin_cp_list (BIN_OBJ, idx);\n\t\t\/\/ str = r_bin_java_get_name_from_bin_cp_list (BIN_OBJ, idx-1);\n\t\tclass_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!class_str) {\n\t\t\tclass_str = empty;\n\t\t}\n\t\tname_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item2);\n\t\tif (!name_str) {\n\t\t\tname_str = empty;\n\t\t}\n\t\tdesc_str = r_bin_java_get_item_desc_from_bin_cp_list (BIN_OBJ, item2);\n\t\tif (!desc_str) {\n\t\t\tdesc_str = empty;\n\t\t}\n\t\tstr = r_str_newf (\"%s%s%s\", name_str,\n\t\t\tspace_bn_name_type ? \" \" : \"\", desc_str);\n\t\tif (class_str != empty) {\n\t\t\tfree (class_str);\n\t\t}\n\t\tif (name_str != empty) {\n\t\t\tfree (name_str);\n\t\t}\n\t\tif (desc_str != empty) {\n\t\t\tfree (desc_str);\n\t\t}\n\t} else if (!strcmp (cp_name, \"MethodRef\") ||\n\t!strcmp (cp_name, \"FieldRef\") ||\n\t!strcmp (cp_name, \"InterfaceMethodRef\")) {\n\t\t\/*\n\t\t*  The MethodRef, FieldRef, and InterfaceMethodRef structures\n\t\t*\/\n\t\tclass_str = r_bin_java_get_name_from_bin_cp_list (BIN_OBJ, item->info.cp_method.class_idx);\n\t\tif (!class_str) {\n\t\t\tclass_str = empty;\n\t\t}\n\t\tname_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!name_str) {\n\t\t\tname_str = empty;\n\t\t}\n\t\tdesc_str = r_bin_java_get_item_desc_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!desc_str) {\n\t\t\tdesc_str = empty;\n\t\t}\n\t\tstr = r_str_newf (\"%s\/%s%s%s\", class_str, name_str,\n\t\t\tspace_bn_name_type ? \" \" : \"\", desc_str);\n\t\tif (class_str != empty) {\n\t\t\tfree (class_str);\n\t\t}\n\t\tif (name_str != empty) {\n\t\t\tfree (name_str);\n\t\t}\n\t\tif (desc_str != empty) {\n\t\t\tfree (desc_str);\n\t\t}\n\t} else if (!strcmp (cp_name, \"String\")) {\n\t\tstring_str = r_bin_java_get_utf8_from_bin_cp_list (BIN_OBJ, item->info.cp_string.string_idx);\n\t\tstr = NULL;\n\t\tIFDBG eprintf (\"java_resolve String got: (%d) %s\\n\", item->info.cp_string.string_idx, string_str);\n\t\tif (!string_str) {\n\t\t\tstring_str = empty;\n\t\t}\n\t\tstr = r_str_newf (\"\\\"%s\\\"\", string_str);\n\t\tIFDBG eprintf (\"java_resolve String return: %s\\n\", str);\n\t\tif (string_str != empty) {\n\t\t\tfree (string_str);\n\t\t}\n\n\t} else if (!strcmp (cp_name, \"Utf8\")) {\n\t\tchar *tmp_str = convert_string ((const char *) item->info.cp_utf8.bytes, item->info.cp_utf8.length);\n\t\tut32 tmp_str_len = tmp_str ? strlen (tmp_str) + 4 : 0;\n\t\tif (tmp_str) {\n\t\t\tstr = malloc (tmp_str_len + 4);\n\t\t\tsnprintf (str, tmp_str_len + 4, \"\\\"%s\\\"\", tmp_str);\n\t\t}\n\t\tfree (tmp_str);\n\t} else if (!strcmp (cp_name, \"Long\")) {\n\t\tstr = r_str_newf (\"0x%\"PFMT64x, r_bin_java_raw_to_long (item->info.cp_long.bytes.raw, 0));\n\t} else if (!strcmp (cp_name, \"Double\")) {\n\t\tstr = r_str_newf (\"%f\", r_bin_java_raw_to_double (item->info.cp_double.bytes.raw, 0));\n\t} else if (!strcmp (cp_name, \"Integer\")) {\n\t\tstr = r_str_newf (\"0x%08x\", R_BIN_JAVA_UINT (item->info.cp_integer.bytes.raw, 0));\n\t} else if (!strcmp (cp_name, \"Float\")) {\n\t\tstr = r_str_newf (\"%f\", R_BIN_JAVA_FLOAT (item->info.cp_float.bytes.raw, 0));\n\t} else if (!strcmp (cp_name, \"NameAndType\")) {\n\t\tname_str = r_bin_java_get_item_name_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!name_str) {\n\t\t\tname_str = empty;\n\t\t}\n\t\tdesc_str = r_bin_java_get_item_desc_from_bin_cp_list (BIN_OBJ, item);\n\t\tif (!desc_str) {\n\t\t\tdesc_str = empty;\n\t\t}\n\t\tstr = r_str_newf (\"%s%s%s\", name_str, space_bn_name_type ? \" \" : \"\", desc_str);\n\t\tif (name_str != empty) {\n\t\t\tfree (name_str);\n\t\t}\n\t\tif (desc_str != empty) {\n\t\t\tfree (desc_str);\n\t\t}\n\t} else {\n\t\tstr = strdup (\"(null)\");\n\t}\n\treturn str;\n}","target":0,"code_token_length":1390,"total_token_length":1626,"max_tokens_setting":2048}
+{"idx":197666,"func":"njs_object_iterate_reverse(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_iterator_handler_t handler)\n{\n    double              idx;\n    int64_t             i, from, to, length;\n    njs_int_t           ret;\n    njs_array_t         *array, *keys;\n    njs_value_t         *entry, *value, prop, character, string_obj;\n    const u_char        *p, *end, *pos;\n    njs_string_prop_t   string_prop;\n    njs_object_value_t  *object;\n\n    value = args->value;\n    from = args->from;\n    to = args->to;\n\n    if (njs_is_array(value)) {\n        array = njs_array(value);\n\n        from += 1;\n\n        while (from-- > to) {\n            if (njs_slow_path(!array->object.fast_array)) {\n                goto process_object;\n            }\n\n            if (njs_fast_path(from < array->length\n                              && njs_is_valid(&array->start[from])))\n            {\n                ret = handler(vm, args, &array->start[from], from);\n\n            } else {\n                entry = njs_value_arg(&njs_value_invalid);\n                ret = njs_value_property_i64(vm, value, from, &prop);\n                if (njs_slow_path(ret != NJS_DECLINED)) {\n                    if (ret == NJS_ERROR) {\n                        return NJS_ERROR;\n                    }\n\n                    entry = ∝\n                }\n\n                ret = handler(vm, args, entry, from);\n            }\n\n            if (njs_slow_path(ret != NJS_OK)) {\n                if (ret == NJS_DONE) {\n                    return NJS_DONE;\n                }\n\n                return NJS_ERROR;\n            }\n        }\n\n        return NJS_OK;\n    }\n\n    if (njs_is_string(value) || njs_is_object_string(value)) {\n\n        if (njs_is_string(value)) {\n            object = njs_object_value_alloc(vm, NJS_OBJ_TYPE_STRING, 0, value);\n            if (njs_slow_path(object == NULL)) {\n                return NJS_ERROR;\n            }\n\n            njs_set_object_value(&string_obj, object);\n\n            args->value = &string_obj;\n        }\n        else {\n            value = njs_object_value(value);\n        }\n\n        length = njs_string_prop(&string_prop, value);\n        end = string_prop.start + string_prop.size;\n\n        if ((size_t) length == string_prop.size) {\n            \/* Byte or ASCII string. *\/\n\n            p = string_prop.start + from;\n\n            i = from + 1;\n\n            while (i-- > to) {\n                \/* This cannot fail. *\/\n                (void) njs_string_new(vm, &character, p, 1, 1);\n\n                ret = handler(vm, args, &character, i);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    if (ret == NJS_DONE) {\n                        return NJS_DONE;\n                    }\n\n                    return NJS_ERROR;\n                }\n\n                p--;\n            }\n\n        } else {\n            \/* UTF-8 string. *\/\n\n            p = njs_string_offset(string_prop.start, end, from);\n            p = njs_utf8_next(p, end);\n\n            i = from + 1;\n\n            while (i-- > to) {\n                pos = njs_utf8_prev(p);\n\n                \/* This cannot fail. *\/\n                (void) njs_string_new(vm, &character, pos, p - pos , 1);\n\n                ret = handler(vm, args, &character, i);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    if (ret == NJS_DONE) {\n                        return NJS_DONE;\n                    }\n\n                    return NJS_ERROR;\n                }\n\n                p = pos;\n            }\n        }\n\n        return NJS_OK;\n    }\n\n    if (!njs_is_object(value)) {\n        return NJS_OK;\n    }\n\nprocess_object:\n\n    if (!njs_fast_object(from - to)) {\n        keys = njs_array_indices(vm, value);\n        if (njs_slow_path(keys == NULL)) {\n            return NJS_ERROR;\n        }\n\n        i = keys->length;\n\n        while (i > 0) {\n            idx = njs_string_to_index(&keys->start[--i]);\n\n            if (idx < to || idx > from) {\n                continue;\n            }\n\n            ret = njs_iterator_object_handler(vm, handler, args,\n                                              &keys->start[i], idx);\n            if (njs_slow_path(ret != NJS_OK)) {\n                njs_array_destroy(vm, keys);\n                return ret;\n            }\n        }\n\n        njs_array_destroy(vm, keys);\n\n        return NJS_OK;\n    }\n\n    i = from + 1;\n\n    while (i-- > to) {\n        ret = njs_iterator_object_handler(vm, handler, args, NULL, i);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n    }\n\n    return NJS_OK;\n}","target":1,"code_token_length":1057,"total_token_length":1293,"max_tokens_setting":2048}
+{"idx":213370,"func":"g_socket_client_connected_callback (GObject      *source,\n\t\t\t\t    GAsyncResult *result,\n\t\t\t\t    gpointer      user_data)\n{\n  ConnectionAttempt *attempt = user_data;\n  GSocketClientAsyncConnectData *data = attempt->data;\n  GSList *l;\n  GError *error = NULL;\n  GProxy *proxy;\n  const gchar *protocol;\n\n  \/* data is NULL once the task is completed *\/\n  if (data && g_task_return_error_if_cancelled (data->task))\n    {\n      g_object_unref (data->task);\n      connection_attempt_unref (attempt);\n      return;\n    }\n\n  if (attempt->timeout_source)\n    {\n      g_source_destroy (attempt->timeout_source);\n      g_clear_pointer (&attempt->timeout_source, g_source_unref);\n    }\n\n  if (!g_socket_connection_connect_finish (G_SOCKET_CONNECTION (source),\n\t\t\t\t\t   result, &error))\n    {\n      if (!g_cancellable_is_cancelled (attempt->cancellable))\n        {\n          clarify_connect_error (error, data->connectable, attempt->address);\n          set_last_error (data, error);\n        }\n      else\n        g_clear_error (&error);\n\n      if (data)\n        {\n          connection_attempt_remove (attempt);\n          enumerator_next_async (data);\n        }\n      else\n        connection_attempt_unref (attempt);\n\n      return;\n    }\n\n  data->socket = g_steal_pointer (&attempt->socket);\n  data->connection = g_steal_pointer (&attempt->connection);\n\n  for (l = data->connection_attempts; l; l = g_slist_next (l))\n    {\n      ConnectionAttempt *attempt_entry = l->data;\n      g_cancellable_cancel (attempt_entry->cancellable);\n      attempt_entry->data = NULL;\n      connection_attempt_unref (attempt_entry);\n    }\n  g_slist_free (data->connection_attempts);\n  data->connection_attempts = NULL;\n  connection_attempt_unref (attempt);\n\n  g_socket_connection_set_cached_remote_address ((GSocketConnection*)data->connection, NULL);\n  g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_CONNECTED, data->connectable, data->connection);\n\n  \/* wrong, but backward compatible *\/\n  g_socket_set_blocking (data->socket, TRUE);\n\n  if (!data->proxy_addr)\n    {\n      g_socket_client_tls_handshake (data);\n      return;\n    }\n\n  protocol = g_proxy_address_get_protocol (data->proxy_addr);\n\n  \/* The connection should not be anything other than TCP,\n   * but let's put a safety guard in case\n   *\/\n  if (!G_IS_TCP_CONNECTION (data->connection))\n    {\n      g_critical (\"Trying to proxy over non-TCP connection, this is \"\n          \"most likely a bug in GLib IO library.\");\n\n      g_set_error_literal (&data->last_error,\n          G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,\n          _(\"Proxying over a non-TCP connection is not supported.\"));\n\n      enumerator_next_async (data);\n    }\n  else if (g_hash_table_contains (data->client->priv->app_proxies, protocol))\n    {\n      \/* Simply complete the connection, we don't want to do TLS handshake\n       * as the application proxy handling may need proxy handshake first *\/\n      g_socket_client_async_connect_complete (data);\n    }\n  else if ((proxy = g_proxy_get_default_for_protocol (protocol)))\n    {\n      g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_PROXY_NEGOTIATING, data->connectable, data->connection);\n      g_proxy_connect_async (proxy,\n                             data->connection,\n                             data->proxy_addr,\n                             g_task_get_cancellable (data->task),\n                             g_socket_client_proxy_connect_callback,\n                             data);\n      g_object_unref (proxy);\n    }\n  else\n    {\n      g_clear_error (&data->last_error);\n\n      g_set_error (&data->last_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,\n          _(\"Proxy protocol \u201c%s\u201d is not supported.\"),\n          protocol);\n\n      enumerator_next_async (data);\n    }\n}","target":1,"code_token_length":831,"total_token_length":1067,"max_tokens_setting":2048}
+{"idx":236202,"func":"GF_Err text_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu16 pSize;\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\tISOM_DECREASE_SIZE(ptr, 8);\n\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);\n\tif (e) return e;\n\n\tptr->textJustification = 1;\n\n\t\/\/some weird text entries are not QT text nor 3gpp, cf issue #1030\n\tif (!ptr->size) {\n\t\treturn GF_OK;\n\t}\n\tif (ptr->size < 43) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Broken text box (%d bytes but min 43 required), skiping parsing.\\n\", ptr->size));\n\t\treturn GF_OK;\n\t}\n\tISOM_DECREASE_SIZE(ptr, 43);\n\n\tptr->displayFlags = gf_bs_read_u32(bs);\t\t\t\/*Display flags*\/\n\tptr->textJustification = gf_bs_read_u32(bs);\t\/*Text justification*\/\n\tgf_bs_read_data(bs, ptr->background_color, 6);\t\/*Background color*\/\n\tgpp_read_box(bs, &ptr->default_box);\t\t\t\/*Default text box*\/\n\tgf_bs_read_data(bs, ptr->reserved1, 8);\t\t\t\/*Reserved*\/\n\tptr->fontNumber = gf_bs_read_u16(bs);\t\t\t\/*Font number*\/\n\tptr->fontFace   = gf_bs_read_u16(bs);\t\t\t\/*Font face*\/\n\tptr->reserved2  = gf_bs_read_u8(bs);\t\t\t\/*Reserved*\/\n\tptr->reserved3  = gf_bs_read_u16(bs);\t\t\t\/*Reserved*\/\n\tgf_bs_read_data(bs, ptr->foreground_color, 6);\t\/*Foreground color*\/\n\n\t\/*ffmpeg compatibility with iPod streams: no pascal string*\/\n\tif (!ptr->size)\n\t\treturn GF_OK;\n\n\tISOM_DECREASE_SIZE(ptr, 1);\n\tpSize = gf_bs_read_u8(bs); \/*a Pascal string begins with its size: get textName size*\/\n\n\tif (ptr->size < pSize) {\n\t\tu32 b_size = pSize;\n\t\tsize_t i = 0;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string: trying to decode anyway.\\n\"));\n\t\tptr->textName = (char*)gf_malloc((size_t)ptr->size + 1 + 1);\n\t\tif (!ptr->textName) return GF_OUT_OF_MEM;\n\n\t\tdo {\n\t\t\tchar c = (char)b_size;\n\t\t\tif (c == '\\0') {\n\t\t\t\tbreak;\n\t\t\t} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {\n\t\t\t\tptr->textName[i] = c;\n\t\t\t} else {\n\t\t\t\tgf_free(ptr->textName);\n\t\t\t\tptr->textName = NULL;\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string and contains non-chars. Abort.\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\ti++;\n\t\t\tif (!ptr->size)\n\t\t\t\tbreak;\n\t\t\tptr->size--;\n\t\t\tb_size = gf_bs_read_u8(bs);\n\t\t} while (b_size);\n\n\t\tptr->textName[i] = '\\0';\t\t\t\t\/*Font name*\/\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string: \\\"%s\\\" detected.\\n\", ptr->textName));\n\t\treturn GF_OK;\n\t}\n\tif (pSize) {\n\t\tptr->textName = (char*) gf_malloc(pSize+1 * sizeof(char));\n\t\tif (!ptr->textName) return GF_OUT_OF_MEM;\n\n\t\tif (gf_bs_read_data(bs, ptr->textName, pSize) != pSize) {\n\t\t\tgf_free(ptr->textName);\n\t\t\tptr->textName = NULL;\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tptr->textName[pSize] = '\\0';\t\t\t\t\/*Font name*\/\n\t}\n\tISOM_DECREASE_SIZE(ptr, pSize);\n\n\tu32 next_size = gf_bs_peek_bits(bs, 32, 0);\n\tif (next_size > ptr->size) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Broken text box detected, skiping parsing.\\n\"));\n\t\tptr->textJustification = 1;\n\t\treturn GF_OK;\n\t}\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":999,"total_token_length":1235,"max_tokens_setting":2048}
+{"idx":513176,"func":"void plugin_opt_set_limits(struct my_option *options,\n                           const struct st_mysql_sys_var *opt)\n{\n  options->sub_size= 0;\n\n  switch (opt->flags & (PLUGIN_VAR_TYPEMASK |\n                        PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL)) {\n  \/* global system variables *\/\n  case PLUGIN_VAR_INT:\n    OPTION_SET_LIMITS(GET_INT, options, (sysvar_int_t*) opt);\n    break;\n  case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED:\n    OPTION_SET_LIMITS(GET_UINT, options, (sysvar_uint_t*) opt);\n    break;\n  case PLUGIN_VAR_LONG:\n    OPTION_SET_LIMITS(GET_LONG, options, (sysvar_long_t*) opt);\n    break;\n  case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED:\n    OPTION_SET_LIMITS(GET_ULONG, options, (sysvar_ulong_t*) opt);\n    break;\n  case PLUGIN_VAR_LONGLONG:\n    OPTION_SET_LIMITS(GET_LL, options, (sysvar_longlong_t*) opt);\n    break;\n  case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED:\n    OPTION_SET_LIMITS(GET_ULL, options, (sysvar_ulonglong_t*) opt);\n    break;\n  case PLUGIN_VAR_ENUM:\n    options->var_type= GET_ENUM;\n    options->typelib= ((sysvar_enum_t*) opt)->typelib;\n    options->def_value= ((sysvar_enum_t*) opt)->def_val;\n    options->min_value= options->block_size= 0;\n    options->max_value= options->typelib->count - 1;\n    break;\n  case PLUGIN_VAR_SET:\n    options->var_type= GET_SET;\n    options->typelib= ((sysvar_set_t*) opt)->typelib;\n    options->def_value= ((sysvar_set_t*) opt)->def_val;\n    options->min_value= options->block_size= 0;\n    options->max_value= (1ULL << options->typelib->count) - 1;\n    break;\n  case PLUGIN_VAR_BOOL:\n    options->var_type= GET_BOOL;\n    options->def_value= ((sysvar_bool_t*) opt)->def_val;\n    options->typelib= &bool_typelib;\n    break;\n  case PLUGIN_VAR_STR:\n    options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?\n                        GET_STR_ALLOC : GET_STR);\n    options->def_value= (intptr) ((sysvar_str_t*) opt)->def_val;\n    break;\n  case PLUGIN_VAR_DOUBLE:\n    OPTION_SET_LIMITS_DOUBLE(options, (sysvar_double_t*) opt);\n    break;\n  \/* threadlocal variables *\/\n  case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS(GET_INT, options, (thdvar_int_t*) opt);\n    break;\n  case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS(GET_UINT, options, (thdvar_uint_t*) opt);\n    break;\n  case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS(GET_LONG, options, (thdvar_long_t*) opt);\n    break;\n  case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS(GET_ULONG, options, (thdvar_ulong_t*) opt);\n    break;\n  case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS(GET_LL, options, (thdvar_longlong_t*) opt);\n    break;\n  case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS(GET_ULL, options, (thdvar_ulonglong_t*) opt);\n    break;\n  case PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL:\n    OPTION_SET_LIMITS_DOUBLE(options, (thdvar_double_t*) opt);\n    break;\n  case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:\n    options->var_type= GET_ENUM;\n    options->typelib= ((thdvar_enum_t*) opt)->typelib;\n    options->def_value= ((thdvar_enum_t*) opt)->def_val;\n    options->min_value= options->block_size= 0;\n    options->max_value= options->typelib->count - 1;\n    break;\n  case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:\n    options->var_type= GET_SET;\n    options->typelib= ((thdvar_set_t*) opt)->typelib;\n    options->def_value= ((thdvar_set_t*) opt)->def_val;\n    options->min_value= options->block_size= 0;\n    options->max_value= (1ULL << options->typelib->count) - 1;\n    break;\n  case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:\n    options->var_type= GET_BOOL;\n    options->def_value= ((thdvar_bool_t*) opt)->def_val;\n    options->typelib= &bool_typelib;\n    break;\n  case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:\n    options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?\n                        GET_STR_ALLOC : GET_STR);\n    options->def_value= (intptr) ((thdvar_str_t*) opt)->def_val;\n    break;\n  default:\n    DBUG_ASSERT(0);\n  }\n  options->arg_type= REQUIRED_ARG;\n  if (opt->flags & PLUGIN_VAR_NOCMDARG)\n    options->arg_type= NO_ARG;\n  if (opt->flags & PLUGIN_VAR_OPCMDARG)\n    options->arg_type= OPT_ARG;\n}","target":0,"code_token_length":1163,"total_token_length":1399,"max_tokens_setting":2048}
+{"idx":195565,"func":"String string_number_format(double d, int dec,\n                            const String& dec_point,\n                            const String& thousand_sep) {\n  char *tmpbuf = nullptr, *resbuf;\n  char *s, *t;  \/* source, target *\/\n  char *dp;\n  int integral;\n  int tmplen, reslen=0;\n  int count=0;\n  int is_negative=0;\n\n  if (d < 0) {\n    is_negative = 1;\n    d = -d;\n  }\n\n  if (dec < 0) dec = 0;\n  d = php_math_round(d, dec);\n\n  \/\/ departure from PHP: we got rid of dependencies on spprintf() here.\n  String tmpstr(63, ReserveString);\n  tmpbuf = tmpstr.mutableData();\n  tmplen = snprintf(tmpbuf, 64, \"%.*F\", dec, d);\n  if (tmplen < 0) return empty_string();\n  if (tmpbuf == nullptr || !isdigit((int)tmpbuf[0])) {\n    tmpstr.setSize(tmplen);\n    return tmpstr;\n  }\n  if (tmplen >= 64) {\n    \/\/ Uncommon, asked for more than 64 chars worth of precision\n    tmpstr = String(tmplen, ReserveString);\n    tmpbuf = tmpstr.mutableData();\n    tmplen = snprintf(tmpbuf, tmplen + 1, \"%.*F\", dec, d);\n    if (tmplen < 0) return empty_string();\n    if (tmpbuf == nullptr || !isdigit((int)tmpbuf[0])) {\n      tmpstr.setSize(tmplen);\n      return tmpstr;\n    }\n  }\n\n  \/* find decimal point, if expected *\/\n  if (dec) {\n    dp = strpbrk(tmpbuf, \".,\");\n  } else {\n    dp = nullptr;\n  }\n\n  \/* calculate the length of the return buffer *\/\n  if (dp) {\n    integral = dp - tmpbuf;\n  } else {\n    \/* no decimal point was found *\/\n    integral = tmplen;\n  }\n\n  \/* allow for thousand separators *\/\n  if (!thousand_sep.empty()) {\n    if (integral + thousand_sep.size() * ((integral-1) \/ 3) < integral) {\n      \/* overflow *\/\n      raise_error(\"String overflow\");\n    }\n\n    integral += ((integral-1) \/ 3) * thousand_sep.size();\n  }\n\n  reslen = integral;\n\n  if (dec) {\n    reslen += dec;\n\n    if (!dec_point.empty()) {\n      if (reslen + dec_point.size() < dec_point.size()) {\n        \/* overflow *\/\n        raise_error(\"String overflow\");\n      }\n      reslen += dec_point.size();\n    }\n  }\n\n  \/* add a byte for minus sign *\/\n  if (is_negative) {\n    reslen++;\n  }\n  String resstr(reslen, ReserveString);\n  resbuf = resstr.mutableData();\n\n  s = tmpbuf+tmplen-1;\n  t = resbuf+reslen-1;\n\n  \/* copy the decimal places.\n   * Take care, as the sprintf implementation may return less places than\n   * we requested due to internal buffer limitations *\/\n  if (dec) {\n    int declen = dp ? s - dp : 0;\n    int topad = dec > declen ? dec - declen : 0;\n\n    \/* pad with '0's *\/\n    while (topad--) {\n      *t-- = '0';\n    }\n\n    if (dp) {\n      s -= declen + 1; \/* +1 to skip the point *\/\n      t -= declen;\n\n      \/* now copy the chars after the point *\/\n      memcpy(t + 1, dp + 1, declen);\n    }\n\n    \/* add decimal point *\/\n    if (!dec_point.empty()) {\n      memcpy(t + (1 - dec_point.size()), dec_point.data(), dec_point.size());\n      t -= dec_point.size();\n    }\n  }\n\n  \/* copy the numbers before the decimal point, adding thousand\n   * separator every three digits *\/\n  while(s >= tmpbuf) {\n    *t-- = *s--;\n    if (thousand_sep && (++count%3)==0 && s>=tmpbuf) {\n      memcpy(t + (1 - thousand_sep.size()),\n             thousand_sep.data(),\n             thousand_sep.size());\n      t -= thousand_sep.size();\n    }\n  }\n\n  \/* and a minus sign, if needed *\/\n  if (is_negative) {\n    *t-- = '-';\n  }\n\n  resstr.setSize(reslen);\n  return resstr;\n}","target":1,"code_token_length":960,"total_token_length":1196,"max_tokens_setting":2048}
+{"idx":413820,"func":"void LinkResolver::runtime_resolve_interface_method(CallInfo& result,\n                                                    const methodHandle& resolved_method,\n                                                    Klass* resolved_klass,\n                                                    Handle recv,\n                                                    Klass* recv_klass,\n                                                    bool check_null_and_abstract, TRAPS) {\n\n  \/\/ check if receiver exists\n  if (check_null_and_abstract && recv.is_null()) {\n    THROW(vmSymbols::java_lang_NullPointerException());\n  }\n\n  \/\/ check if receiver klass implements the resolved interface\n  if (!recv_klass->is_subtype_of(resolved_klass)) {\n    ResourceMark rm(THREAD);\n    char buf[200];\n    jio_snprintf(buf, sizeof(buf), \"Class %s does not implement the requested interface %s\",\n                 recv_klass->external_name(),\n                 resolved_klass->external_name());\n    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);\n  }\n\n  methodHandle selected_method = resolved_method;\n\n  \/\/ resolve the method in the receiver class, unless it is private\n  if (!resolved_method()->is_private()) {\n    \/\/ do lookup based on receiver klass\n    \/\/ This search must match the linktime preparation search for itable initialization\n    \/\/ to correctly enforce loader constraints for interface method inheritance.\n    \/\/ Private methods are skipped as the resolved method was not private.\n    Method* method = lookup_instance_method_in_klasses(recv_klass,\n                                                       resolved_method->name(),\n                                                       resolved_method->signature(),\n                                                       Klass::PrivateLookupMode::skip);\n    selected_method = methodHandle(THREAD, method);\n\n    if (selected_method.is_null() && !check_null_and_abstract) {\n      \/\/ In theory this is a harmless placeholder value, but\n      \/\/ in practice leaving in null affects the nsk default method tests.\n      \/\/ This needs further study.\n      selected_method = resolved_method;\n    }\n    \/\/ check if method exists\n    if (selected_method.is_null()) {\n      \/\/ Pass arguments for generating a verbose error message.\n      throw_abstract_method_error(resolved_method, recv_klass, CHECK);\n    }\n    \/\/ check access\n    \/\/ Throw Illegal Access Error if selected_method is not public.\n    if (!selected_method->is_public()) {\n      ResourceMark rm(THREAD);\n      stringStream ss;\n      ss.print(\"'\");\n      Method::print_external_name(&ss, recv_klass, selected_method->name(), selected_method->signature());\n      ss.print(\"'\");\n      THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());\n    }\n    \/\/ check if abstract\n    if (check_null_and_abstract && selected_method->is_abstract()) {\n      throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK);\n    }\n  }\n\n  if (log_develop_is_enabled(Trace, itables)) {\n    trace_method_resolution(\"invokeinterface selected method: receiver-class:\",\n                            recv_klass, resolved_klass, selected_method(), true);\n  }\n  \/\/ setup result\n  if (resolved_method->has_vtable_index()) {\n    int vtable_index = resolved_method->vtable_index();\n    log_develop_trace(itables)(\"  -- vtable index: %d\", vtable_index);\n    assert(vtable_index == selected_method->vtable_index(), \"sanity check\");\n    result.set_virtual(resolved_klass, resolved_method, selected_method, vtable_index, CHECK);\n  } else if (resolved_method->has_itable_index()) {\n    int itable_index = resolved_method()->itable_index();\n    log_develop_trace(itables)(\"  -- itable index: %d\", itable_index);\n    result.set_interface(resolved_klass, resolved_method, selected_method, itable_index, CHECK);\n  } else {\n    int index = resolved_method->vtable_index();\n    log_develop_trace(itables)(\"  -- non itable\/vtable index: %d\", index);\n    assert(index == Method::nonvirtual_vtable_index, \"Oops hit another case!\");\n    assert(resolved_method()->is_private() ||\n           (resolved_method()->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()),\n           \"Should only have non-virtual invokeinterface for private or final-Object methods!\");\n    assert(resolved_method()->can_be_statically_bound(), \"Should only have non-virtual invokeinterface for statically bound methods!\");\n    \/\/ This sets up the nonvirtual form of \"virtual\" call (as needed for final and private methods)\n    result.set_virtual(resolved_klass, resolved_method, resolved_method, index, CHECK);\n  }\n}","target":0,"code_token_length":934,"total_token_length":1170,"max_tokens_setting":2048}
+{"idx":301015,"func":"pcx_write_page(gx_device_printer * pdev, gp_file * file, pcx_header * phdr,\n               bool planar)\n{\n    int raster = gdev_prn_raster(pdev);\n    uint rsize = ROUND_UP((pdev->width * phdr->bpp + 7) >> 3, 2);\t\/* PCX format requires even *\/\n    int height = pdev->height;\n    int depth = pdev->color_info.depth;\n    uint lsize = raster + rsize;\n    byte *line = gs_alloc_bytes(pdev->memory, lsize, \"pcx file buffer\");\n    byte *plane = line + raster;\n    int y;\n    int code = 0;\t\t\/* return code *\/\n\n    if (line == 0)\t\t\/* can't allocate line buffer *\/\n        return_error(gs_error_VMerror);\n\n    \/* Fill in the other variable entries in the header struct. *\/\n\n    assign_ushort(phdr->x2, pdev->width - 1);\n    assign_ushort(phdr->y2, height - 1);\n    assign_ushort(phdr->hres, (int)pdev->x_pixels_per_inch);\n    assign_ushort(phdr->vres, (int)pdev->y_pixels_per_inch);\n    assign_ushort(phdr->bpl, (planar || depth == 1 ? rsize :\n                              raster + (raster & 1)));\n\n    \/* Write the header. *\/\n\n    if (gp_fwrite((const char *)phdr, 1, 128, file) < 128) {\n        code = gs_error_ioerror;\n        goto pcx_done;\n    }\n    \/* Write the contents of the image. *\/\n    for (y = 0; y < height; y++) {\n        byte *row;\n        byte *end;\n\n        code = gdev_prn_get_bits(pdev, y, line, &row);\n        if (code < 0)\n            break;\n        end = row + raster;\n        if (!planar) {\t\t\/* Just write the bits. *\/\n            if (raster & 1) {\t\/* Round to even, with predictable padding. *\/\n                *end = end[-1];\n                ++end;\n            }\n            pcx_write_rle(row, end, 1, file);\n        } else\n            switch (depth) {\n\n                case 4:\n                    {\n                        byte *pend = plane + rsize;\n                        int shift;\n\n                        for (shift = 0; shift < 4; shift++) {\n                            register byte *from, *to;\n                            register int bright = 1 << shift;\n                            register int bleft = bright << 4;\n\n                            for (from = row, to = plane;\n                                 from < end; from += 4\n                                ) {\n                                *to++ =\n                                    (from[0] & bleft ? 0x80 : 0) |\n                                    (from[0] & bright ? 0x40 : 0) |\n                                    (from[1] & bleft ? 0x20 : 0) |\n                                    (from[1] & bright ? 0x10 : 0) |\n                                    (from[2] & bleft ? 0x08 : 0) |\n                                    (from[2] & bright ? 0x04 : 0) |\n                                    (from[3] & bleft ? 0x02 : 0) |\n                                    (from[3] & bright ? 0x01 : 0);\n                            }\n                            \/* We might be one byte short of rsize. *\/\n                            if (to < pend)\n                                *to = to[-1];\n                            pcx_write_rle(plane, pend, 1, file);\n                        }\n                    }\n                    break;\n\n                case 24:\n                    {\n                        int pnum;\n\n                        for (pnum = 0; pnum < 3; ++pnum) {\n                            pcx_write_rle(row + pnum, row + raster, 3, file);\n                            if (pdev->width & 1)\n                                gp_fputc(0, file);\t\t\/* pad to even *\/\n                        }\n                    }\n                    break;\n\n                default:\n                    code = gs_note_error(gs_error_rangecheck);\n                    goto pcx_done;\n\n            }\n    }\n\n  pcx_done:\n    gs_free_object(pdev->memory, line, \"pcx file buffer\");\n\n    return code;\n}","target":0,"code_token_length":939,"total_token_length":1175,"max_tokens_setting":2048}
+{"idx":241067,"func":"static int do_command(cmd_request_t cmd)\n{\n\tstruct booth_site *site;\n\tstruct boothc_ticket_msg reply;\n\tstruct booth_transport const *tpt;\n\tuint32_t leader_id;\n\tint rv;\n\tint reply_cnt = 0, msg_logged = 0;\n\tconst char *op_str = \"\";\n\n\tif (cmd == CMD_GRANT)\n\t\top_str = \"grant\";\n\telse if (cmd == CMD_REVOKE)\n\t\top_str = \"revoke\";\n\n\trv = 0;\n\tsite = NULL;\n\n\t\/* Always use TCP for client - at least for now. *\/\n\ttpt = booth_transport + TCP;\n\n\tif (!*cl.site)\n\t\tsite = local;\n\telse {\n\t\tif (!find_site_by_name(cl.site, &site, 1)) {\n\t\t\tlog_error(\"Site \\\"%s\\\" not configured.\", cl.site);\n\t\t\tgoto out_close;\n\t\t}\n\t}\n\n\tif (site->type == ARBITRATOR) {\n\t\tif (site == local) {\n\t\t\tlog_error(\"We're just an arbitrator, cannot grant\/revoke tickets here.\");\n\t\t} else {\n\t\t\tlog_error(\"%s is just an arbitrator, cannot grant\/revoke tickets there.\", cl.site);\n\t\t}\n\t\tgoto out_close;\n\t}\n\n\tassert(site->type == SITE);\n\n\t\/* We don't check for existence of ticket, so that asking can be\n\t * done without local configuration, too.\n\t * Although, that means that the UDP port has to be specified, too. *\/\n\tif (!cl.msg.ticket.id[0]) {\n\t\t\/* If the loaded configuration has only a single ticket defined, use that. *\/\n\t\tif (booth_conf->ticket_count == 1) {\n\t\t\tstrncpy(cl.msg.ticket.id, booth_conf->ticket[0].name,\n\t\t\t\tsizeof(cl.msg.ticket.id));\n\t\t} else {\n\t\t\tlog_error(\"No ticket given.\");\n\t\t\tgoto out_close;\n\t\t}\n\t}\n\nredirect:\n\tinit_header(&cl.msg.header, cmd, 0, cl.options, 0, 0, sizeof(cl.msg));\n\n\trv = tpt->open(site);\n\tif (rv < 0)\n\t\tgoto out_close;\n\n\trv = tpt->send(site, &cl.msg, sendmsglen(&cl.msg));\n\tif (rv < 0)\n\t\tgoto out_close;\n\nread_more:\n\trv = tpt->recv_auth(site, &reply, sizeof(reply));\n\tif (rv < 0) {\n\t\t\/* print any errors depending on the code sent by the\n\t\t * server *\/\n\t\t(void)test_reply(ntohl(reply.header.result), cmd);\n\t\tgoto out_close;\n\t}\n\n\trv = test_reply(ntohl(reply.header.result), cmd);\n\tif (rv == 1) {\n\t\ttpt->close(site);\n\t\tleader_id = ntohl(reply.ticket.leader);\n\t\tif (!find_site_by_id(leader_id, &site)) {\n\t\t\tlog_error(\"Message with unknown redirect site %x received\", leader_id);\n\t\t\trv = -1;\n\t\t\tgoto out_close;\n\t\t}\n\t\tgoto redirect;\n\t} else if (rv == 2 || rv == 3) {\n\t\t\/* the server has more to say *\/\n\t\t\/* don't wait too long *\/\n\t\tif (reply_cnt > 1 && !(cl.options & OPT_WAIT)) {\n\t\t\trv = 0;\n\t\t\tlog_info(\"Giving up on waiting for the definite result. \"\n\t\t\t\t \"Please use \\\"booth list\\\" later to \"\n\t\t\t\t \"see the outcome.\");\n\t\t\tgoto out_close;\n\t\t}\n\t\tif (reply_cnt == 0) {\n\t\t\tlog_info(\"%s request sent, \"\n\t\t\t\t\"waiting for the result ...\", op_str);\n\t\t\tmsg_logged++;\n\t\t} else if (rv == 3 && msg_logged < 2) {\n\t\t\tlog_info(\"waiting for the CIB commit ...\");\n\t\t\tmsg_logged++;\n\t\t}\n\t\treply_cnt++;\n\t\tgoto read_more;\n\t}\n\nout_close:\n\tif (site)\n\t\ttpt->close(site);\n\treturn rv;\n}","target":0,"code_token_length":822,"total_token_length":1058,"max_tokens_setting":2048}
+{"idx":195331,"func":"Status ConcatShapeHelper(InferenceContext* c, int start_value_index,\n                         int end_value_index, int dim_index) {\n  ShapeHandle unused;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(dim_index), 0, &unused));\n  const Tensor* concat_dim_t = c->input_tensor(dim_index);\n  if (concat_dim_t == nullptr) {\n    \/\/ Return an unknown shape with same rank as inputs, or an unknown rank\n    \/\/ if no input's rank is known.\n\n    \/\/ Find rank.\n    int32_t rank = InferenceContext::kUnknownRank;\n    for (int i = start_value_index; i < end_value_index; ++i) {\n      if (rank == InferenceContext::kUnknownRank) rank = c->Rank(c->input(i));\n      if (rank != InferenceContext::kUnknownRank) {\n        break;\n      }\n    }\n    if (rank == InferenceContext::kUnknownRank) {\n      c->set_output(0, c->UnknownShape());\n      return Status::OK();\n    } else if (rank == 0) {\n      return errors::InvalidArgument(\n          \"Can't concatenate scalars (use tf.stack instead)\");\n    } else {\n      for (int i = start_value_index; i < end_value_index; ++i) {\n        \/\/ Check that all the inputs are of the correct rank.\n        TF_RETURN_IF_ERROR(c->WithRank(c->input(i), rank, &unused));\n      }\n    }\n    \/\/ Build result of <rank> different unknown dims.\n    std::vector<DimensionHandle> dims;\n    dims.reserve(rank);\n    for (int i = 0; i < rank; ++i) dims.push_back(c->UnknownDim());\n    c->set_output(0, c->MakeShape(dims));\n    return Status::OK();\n  }\n\n  \/\/ Merge all the non-concat dims, and sum the concat dim to make an output\n  \/\/ shape.\n  int64_t concat_dim;\n  if (concat_dim_t->dtype() == DT_INT32) {\n    concat_dim = static_cast<int64_t>(concat_dim_t->flat<int32>()(0));\n  } else {\n    concat_dim = concat_dim_t->flat<int64_t>()(0);\n  }\n\n  \/\/ Minimum required number of dimensions.\n  const int min_rank = concat_dim < 0 ? -concat_dim : concat_dim + 1;\n\n  ShapeHandle output_before;\n  ShapeHandle output_after;\n\n  ShapeHandle input = c->input(end_value_index - 1);\n  TF_RETURN_IF_ERROR(c->WithRankAtLeast(input, min_rank, &input));\n  TF_RETURN_IF_ERROR(c->Subshape(input, 0, concat_dim, &output_before));\n  DimensionHandle output_middle = c->Dim(input, concat_dim);\n  if (concat_dim == -1) {\n    output_after = c->Scalar();  \/\/ no dimensions.\n  } else {\n    TF_RETURN_IF_ERROR(c->Subshape(input, concat_dim + 1, &output_after));\n  }\n\n  for (int i = end_value_index - 2; i >= start_value_index; --i) {\n    ShapeHandle before;\n    ShapeHandle after;\n    input = c->input(i);\n    TF_RETURN_IF_ERROR(c->WithRankAtLeast(input, min_rank, &input));\n    TF_RETURN_IF_ERROR(c->Subshape(input, 0, concat_dim, &before));\n    DimensionHandle middle = c->Dim(input, concat_dim);\n    if (concat_dim == -1) {\n      after = c->Scalar();\n    } else {\n      TF_RETURN_IF_ERROR(c->Subshape(input, concat_dim + 1, &after));\n    }\n\n    TF_RETURN_IF_ERROR(c->Merge(before, output_before, &output_before));\n    TF_RETURN_IF_ERROR(c->Add(output_middle, middle, &output_middle));\n    TF_RETURN_IF_ERROR(c->Merge(after, output_after, &output_after));\n  }\n\n  ShapeHandle s;\n  TF_RETURN_IF_ERROR(\n      c->Concatenate(output_before, c->Vector(output_middle), &s));\n  TF_RETURN_IF_ERROR(c->Concatenate(s, output_after, &s));\n  c->set_output(0, s);\n  return Status::OK();\n}","target":1,"code_token_length":892,"total_token_length":1128,"max_tokens_setting":2048}
+{"idx":244070,"func":"static GF_Err ctrn_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i, count, flags, first_idx=0;\n\tBool inherit_dur, inherit_size, inherit_flags, inherit_ctso;\n\tGF_TrunEntry *ent;\n\tGF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s;\n\tflags = ptr->flags;\n\tptr->ctrn_flags = flags;\n\tptr->flags = 0;\n\n\tptr->sample_count = gf_bs_read_u16(bs);\n\tISOM_DECREASE_SIZE(ptr, 2);\n\n\tif (flags & GF_ISOM_TRUN_DATA_OFFSET) {\n\t\tif (flags & GF_ISOM_CTRN_DATAOFFSET_16) {\n\t\t\tptr->data_offset = gf_bs_read_u16(bs);\n\t\t\tISOM_DECREASE_SIZE(ptr, 2);\n\t\t} else {\n\t\t\tptr->data_offset = gf_bs_read_u32(bs);\n\t\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\t}\n\t\tptr->flags |= GF_ISOM_TRUN_DATA_OFFSET;\n\t}\n\tif (flags & GF_ISOM_CTRN_CTSO_MULTIPLIER) {\n\t\tptr->ctso_multiplier = gf_bs_read_u16(bs);\n\t\tISOM_DECREASE_SIZE(ptr, 2);\n\t}\n\t\/*no sample dur\/sample_flag\/size\/ctso for first or following, create a pack sample *\/\n\tif (! (flags & 0x00FFFF00)) {\n\t\tGF_SAFEALLOC(ent, GF_TrunEntry);\n\t\tif (!ent) return GF_OUT_OF_MEM;\n\t\tent->nb_pack = ptr->sample_count;\n\t\tgf_list_add(ptr->entries, ent);\n\t\treturn GF_OK;\n\t}\n\t\/*allocate all entries*\/\n\tfor (i=0; i<ptr->sample_count; i++) {\n\t\tGF_SAFEALLOC(ent, GF_TrunEntry);\n\t\tif (!ent) return GF_OUT_OF_MEM;\n\t\tgf_list_add(ptr->entries, ent);\n\t}\n\t\/\/unpack flags\n\tptr->ctrn_first_dur = (flags>>22) & 0x3;\n\tptr->ctrn_first_size = (flags>>20) & 0x3;\n\tptr->ctrn_first_sample_flags = (flags>>18) & 0x3;\n\tptr->ctrn_first_ctts = (flags>>16) & 0x3;\n\tptr->ctrn_dur = (flags>>14) & 0x3;\n\tptr->ctrn_size = (flags>>12) & 0x3;\n\tptr->ctrn_sample_flags = (flags>>10) & 0x3;\n\tptr->ctrn_ctts = (flags>>8) & 0x3;\n\n\tinherit_dur = flags & GF_ISOM_CTRN_INHERIT_DUR;\n\tinherit_size = flags & GF_ISOM_CTRN_INHERIT_SIZE;\n\tinherit_flags = flags & GF_ISOM_CTRN_INHERIT_FLAGS;\n\tinherit_ctso = flags & GF_ISOM_CTRN_INHERIT_CTSO;\n\n\tif (flags & GF_ISOM_CTRN_FIRST_SAMPLE) {\n\t\tent = gf_list_get(ptr->entries, 0);\n\t\tfirst_idx = 1;\n\t\tif (!inherit_dur && ptr->ctrn_first_dur) {\n\t\t\tent->Duration = gf_bs_read_int(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_dur) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_dur) );\n\t\t}\n\t\tif (!inherit_size && ptr->ctrn_first_size) {\n\t\t\tent->size = gf_bs_read_int(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_size) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_size) );\n\t\t}\n\t\tif (!inherit_flags && ptr->ctrn_first_sample_flags) {\n\t\t\tent->flags = ctrn_read_flags(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_sample_flags) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_sample_flags) );\n\t\t}\n\t\tif (!inherit_ctso && ptr->ctrn_first_ctts) {\n\t\t\tent->CTS_Offset = gf_bs_read_int(bs, gf_isom_ctrn_field_size_bits(ptr->ctrn_first_ctts) );\n\t\t\tISOM_DECREASE_SIZE(ptr, ctrn_field_size(ptr->ctrn_first_ctts) );\n\t\t\tif (ptr->ctso_multiplier)\n\t\t\t\tent->CTS_Offset *= (s32) ptr->ctso_multiplier;\n\t\t}\n\t}\n\tcount = ptr->sample_count - first_idx;\n\tif (!inherit_dur && ptr->ctrn_dur) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_dur);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->Duration = gf_bs_read_int(bs, nbbits);\n\t\t}\n\t}\n\tif (!inherit_size && ptr->ctrn_size) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_size);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->size = gf_bs_read_int(bs, nbbits);\n\t\t}\n\t}\n\tif (!inherit_flags && ptr->ctrn_sample_flags) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_sample_flags);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->flags = ctrn_read_flags(bs, nbbits);\n\t\t}\n\t}\n\tif (!inherit_ctso && ptr->ctrn_ctts) {\n\t\tu32 nbbits = gf_isom_ctrn_field_size_bits(ptr->ctrn_ctts);\n\t\tISOM_DECREASE_SIZE(ptr, count * nbbits \/ 8);\n\t\tfor (i=first_idx; i<ptr->sample_count; i++) {\n\t\t\tent = gf_list_get(ptr->entries, i);\n\t\t\tent->CTS_Offset = gf_bs_read_int(bs, nbbits);\n\t\t\tif (ptr->ctso_multiplier)\n\t\t\t\tent->CTS_Offset *= (s32) ptr->ctso_multiplier;\n\t\t}\n\t}\n\n\treturn GF_OK;\n}","target":0,"code_token_length":1435,"total_token_length":1671,"max_tokens_setting":2048}
+{"idx":446058,"func":"LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)\n{\n\tstatic const char module[] = \"LZWDecodeCompat\";\n\tLZWCodecState *sp = DecoderState(tif);\n\tchar *op = (char*) op0;\n\tlong occ = (long) occ0;\n\tchar *tp;\n\tunsigned char *bp;\n\tint code, nbits;\n\tint len;\n\tlong nextbits, nextdata, nbitsmask;\n\tcode_t *codep, *free_entp, *maxcodep, *oldcodep;\n\n\t(void) s;\n\tassert(sp != NULL);\n\n\t\/*\n\t  Fail if value does not fit in long.\n\t*\/\n\tif ((tmsize_t) occ != occ0)\n\t        return (0);\n\n\t\/*\n\t * Restart interrupted output operation.\n\t *\/\n\tif (sp->dec_restart) {\n\t\tlong residue;\n\n\t\tcodep = sp->dec_codep;\n\t\tresidue = codep->length - sp->dec_restart;\n\t\tif (residue > occ) {\n\t\t\t\/*\n\t\t\t * Residue from previous decode is sufficient\n\t\t\t * to satisfy decode request.  Skip to the\n\t\t\t * start of the decoded string, place decoded\n\t\t\t * values in the output buffer, and return.\n\t\t\t *\/\n\t\t\tsp->dec_restart += occ;\n\t\t\tdo {\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--residue > occ);\n\t\t\ttp = op + occ;\n\t\t\tdo {\n\t\t\t\t*--tp = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--occ);\n\t\t\treturn (1);\n\t\t}\n\t\t\/*\n\t\t * Residue satisfies only part of the decode request.\n\t\t *\/\n\t\top += residue;\n\t\tocc -= residue;\n\t\ttp = op;\n\t\tdo {\n\t\t\t*--tp = codep->value;\n\t\t\tcodep = codep->next;\n\t\t} while (--residue);\n\t\tsp->dec_restart = 0;\n\t}\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n#ifdef LZW_CHECKEOS\n\tsp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);\n#endif\n\tnbits = sp->lzw_nbits;\n\tnextdata = sp->lzw_nextdata;\n\tnextbits = sp->lzw_nextbits;\n\tnbitsmask = sp->dec_nbitsmask;\n\toldcodep = sp->dec_oldcodep;\n\tfree_entp = sp->dec_free_entp;\n\tmaxcodep = sp->dec_maxcodep;\n\n\twhile (occ > 0) {\n\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\tif (code == CODE_EOI)\n\t\t\tbreak;\n\t\tif (code == CODE_CLEAR) {\n\t\t\tdo {\n\t\t\t\tfree_entp = sp->dec_codetab + CODE_FIRST;\n\t\t\t\t_TIFFmemset(free_entp, 0,\n\t\t\t\t\t    (CSIZE - CODE_FIRST) * sizeof (code_t));\n\t\t\t\tnbits = BITS_MIN;\n\t\t\t\tnbitsmask = MAXCODE(BITS_MIN);\n\t\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\t\t} while (code == CODE_CLEAR);\t\/* consecutive CODE_CLEAR codes *\/\n\t\t\tif (code == CODE_EOI)\n\t\t\t\tbreak;\n\t\t\tif (code > CODE_CLEAR) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, tif->tif_name,\n\t\t\t\t\"LZWDecode: Corrupted LZW table at scanline %d\",\n\t\t\t\t\t     tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t\toldcodep = sp->dec_codetab + code;\n\t\t\tcontinue;\n\t\t}\n\t\tcodep = sp->dec_codetab + code;\n\n\t\t\/*\n\t\t * Add the new entry to the code table.\n\t\t *\/\n\t\tif (free_entp < &sp->dec_codetab[0] ||\n\t\t    free_entp >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\n\t\tfree_entp->next = oldcodep;\n\t\tif (free_entp->next < &sp->dec_codetab[0] ||\n\t\t    free_entp->next >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\t\tfree_entp->firstchar = free_entp->next->firstchar;\n\t\tfree_entp->length = free_entp->next->length+1;\n\t\tfree_entp->value = (codep < free_entp) ?\n\t\t    codep->firstchar : free_entp->firstchar;\n\t\tif (++free_entp > maxcodep) {\n\t\t\tif (++nbits > BITS_MAX)\t\t\/* should not happen *\/\n\t\t\t\tnbits = BITS_MAX;\n\t\t\tnbitsmask = MAXCODE(nbits);\n\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t}\n\t\toldcodep = codep;\n\t\tif (code >= 256) {\n\t\t\t\/*\n\t\t\t * Code maps to a string, copy string\n\t\t\t * value to output (written in reverse).\n\t\t\t *\/\n\t\t\tif(codep->length == 0) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\t    \"Wrong length of decoded \"\n\t\t\t\t    \"string: data probably corrupted at scanline %d\",\n\t\t\t\t    tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\tif (codep->length > occ) {\n\t\t\t\t\/*\n\t\t\t\t * String is too long for decode buffer,\n\t\t\t\t * locate portion that will fit, copy to\n\t\t\t\t * the decode buffer, and setup restart\n\t\t\t\t * logic for the next decoding call.\n\t\t\t\t *\/\n\t\t\t\tsp->dec_codep = codep;\n\t\t\t\tdo {\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (codep->length > occ);\n\t\t\t\tsp->dec_restart = occ;\n\t\t\t\ttp = op + occ;\n\t\t\t\tdo  {\n\t\t\t\t\t*--tp = codep->value;\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t}  while (--occ);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlen = codep->length;\n\t\t\ttp = op + len;\n\t\t\tdo {\n\t\t\t\tint t;\n\t\t\t\t--tp;\n\t\t\t\tt = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t\t*tp = (char)t;\n\t\t\t} while (codep && tp > op);\n\t\t\tassert(occ >= len);\n\t\t\top += len;\n\t\t\tocc -= len;\n\t\t} else {\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t}\n\t}\n\n\ttif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );\n\ttif->tif_rawcp = (uint8*) bp;\n\tsp->lzw_nbits = (unsigned short)nbits;\n\tsp->lzw_nextdata = nextdata;\n\tsp->lzw_nextbits = nextbits;\n\tsp->dec_nbitsmask = nbitsmask;\n\tsp->dec_oldcodep = oldcodep;\n\tsp->dec_free_entp = free_entp;\n\tsp->dec_maxcodep = maxcodep;\n\n\tif (occ > 0) {\n#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %I64d bytes)\",\n\t\t\t     tif->tif_row, (unsigned __int64) occ);\n#else\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %llu bytes)\",\n\t\t\t     tif->tif_row, (unsigned long long) occ);\n#endif\n\t\treturn (0);\n\t}\n\treturn (1);\n}","target":0,"code_token_length":1736,"total_token_length":1972,"max_tokens_setting":2048}
+{"idx":473980,"func":"expand_case_fold_string(Node* node, regex_t* reg)\n{\n#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION  8\n\n  int r, n, len, alt_num;\n  UChar *start, *end, *p;\n  Node *top_root, *root, *snode, *prev_node;\n  OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];\n  StrNode* sn = NSTR(node);\n\n  if (NSTRING_IS_AMBIG(node)) return 0;\n\n  start = sn->s;\n  end   = sn->end;\n  if (start >= end) return 0;\n\n  r = 0;\n  top_root = root = prev_node = snode = NULL_NODE;\n  alt_num = 1;\n  p = start;\n  while (p < end) {\n    n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(reg->enc, reg->case_fold_flag,\n\t\t\t\t\t   p, end, items);\n    if (n < 0) {\n      r = n;\n      goto err;\n    }\n\n    len = enclen(reg->enc, p, end);\n\n    if (n == 0) {\n      if (IS_NULL(snode)) {\n\tif (IS_NULL(root) && IS_NOT_NULL(prev_node)) {\n\t  top_root = root = onig_node_list_add(NULL_NODE, prev_node);\n\t  if (IS_NULL(root)) {\n\t    onig_node_free(prev_node);\n\t    goto mem_err;\n\t  }\n\t}\n\n\tprev_node = snode = onig_node_new_str(NULL, NULL);\n\tif (IS_NULL(snode)) goto mem_err;\n\tif (IS_NOT_NULL(root)) {\n\t  if (IS_NULL(onig_node_list_add(root, snode))) {\n\t    onig_node_free(snode);\n\t    goto mem_err;\n\t  }\n\t}\n      }\n\n      r = onig_node_str_cat(snode, p, p + len);\n      if (r != 0) goto err;\n    }\n    else {\n      alt_num *= (n + 1);\n      if (alt_num > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break;\n\n      if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {\n\ttop_root = root = onig_node_list_add(NULL_NODE, prev_node);\n\tif (IS_NULL(root)) {\n\t  onig_node_free(prev_node);\n\t  goto mem_err;\n\t}\n      }\n\n      r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node);\n      if (r < 0) goto mem_err;\n      if (r == 1) {\n\tif (IS_NULL(root)) {\n\t  top_root = prev_node;\n\t}\n\telse {\n\t  if (IS_NULL(onig_node_list_add(root, prev_node))) {\n\t    onig_node_free(prev_node);\n\t    goto mem_err;\n\t  }\n\t}\n\n\troot = NCAR(prev_node);\n      }\n      else { \/* r == 0 *\/\n\tif (IS_NOT_NULL(root)) {\n\t  if (IS_NULL(onig_node_list_add(root, prev_node))) {\n\t    onig_node_free(prev_node);\n\t    goto mem_err;\n\t  }\n\t}\n      }\n\n      snode = NULL_NODE;\n    }\n\n    p += len;\n  }\n\n  if (p < end) {\n    Node *srem;\n\n    r = expand_case_fold_make_rem_string(&srem, p, end, reg);\n    if (r != 0) goto mem_err;\n\n    if (IS_NOT_NULL(prev_node) && IS_NULL(root)) {\n      top_root = root = onig_node_list_add(NULL_NODE, prev_node);\n      if (IS_NULL(root)) {\n\tonig_node_free(srem);\n\tonig_node_free(prev_node);\n\tgoto mem_err;\n      }\n    }\n\n    if (IS_NULL(root)) {\n      prev_node = srem;\n    }\n    else {\n      if (IS_NULL(onig_node_list_add(root, srem))) {\n\tonig_node_free(srem);\n\tgoto mem_err;\n      }\n    }\n  }\n\n  \/* ending *\/\n  top_root = (IS_NOT_NULL(top_root) ? top_root : prev_node);\n  swap_node(node, top_root);\n  onig_node_free(top_root);\n  return 0;\n\n mem_err:\n  r = ONIGERR_MEMORY;\n\n err:\n  onig_node_free(top_root);\n  return r;\n}","target":0,"code_token_length":908,"total_token_length":1144,"max_tokens_setting":2048}
+{"idx":406215,"func":"static void __attribute__((__noreturn__)) usage(FILE *out)\n{\n\tfputs(USAGE_HEADER, out);\n\tfprintf(out, _(\n\t\t\" %1$s [-lhV]\\n\"\n\t\t\" %1$s -a [options]\\n\"\n\t\t\" %1$s [options] [--source] <source> | [--target] <directory>\\n\"\n\t\t\" %1$s [options] <source> <directory>\\n\"\n\t\t\" %1$s <operation> <mountpoint> [<target>]\\n\"),\n\t\tprogram_invocation_short_name);\n\n\tfputs(USAGE_OPTIONS, out);\n\tfprintf(out, _(\n\t\" -a, --all               mount all filesystems mentioned in fstab\\n\"\n\t\" -c, --no-canonicalize   don't canonicalize paths\\n\"\n\t\" -f, --fake              dry run; skip the mount(2) syscall\\n\"\n\t\" -F, --fork              fork off for each device (use with -a)\\n\"\n\t\" -T, --fstab <path>      alternative file to \/etc\/fstab\\n\"));\n\tfprintf(out, _(\n\t\" -h, --help              display this help text and exit\\n\"\n\t\" -i, --internal-only     don't call the mount.<type> helpers\\n\"\n\t\" -l, --show-labels       lists all mounts with LABELs\\n\"\n\t\" -n, --no-mtab           don't write to \/etc\/mtab\\n\"));\n\tfprintf(out, _(\n\t\" -o, --options <list>    comma-separated list of mount options\\n\"\n\t\" -O, --test-opts <list>  limit the set of filesystems (use with -a)\\n\"\n\t\" -r, --read-only         mount the filesystem read-only (same as -o ro)\\n\"\n\t\" -t, --types <list>      limit the set of filesystem types\\n\"));\n\tfprintf(out, _(\n\t\"     --source <src>      explicitly specifies source (path, label, uuid)\\n\"\n\t\"     --target <target>   explicitly specifies mountpoint\\n\"));\n\tfprintf(out, _(\n\t\" -v, --verbose           say what is being done\\n\"\n\t\" -V, --version           display version information and exit\\n\"\n\t\" -w, --read-write        mount the filesystem read-write (default)\\n\"));\n\n\tfputs(USAGE_SEPARATOR, out);\n\tfputs(USAGE_HELP, out);\n\tfputs(USAGE_VERSION, out);\n\n\tfprintf(out, _(\n\t\"\\nSource:\\n\"\n\t\" -L, --label <label>     synonym for LABEL=<label>\\n\"\n\t\" -U, --uuid <uuid>       synonym for UUID=<uuid>\\n\"\n\t\" LABEL=<label>           specifies device by filesystem label\\n\"\n\t\" UUID=<uuid>             specifies device by filesystem UUID\\n\"\n\t\" PARTLABEL=<label>       specifies device by partition label\\n\"\n\t\" PARTUUID=<uuid>         specifies device by partition UUID\\n\"));\n\n\tfprintf(out, _(\n\t\" <device>                specifies device by path\\n\"\n\t\" <directory>             mountpoint for bind mounts (see --bind\/rbind)\\n\"\n\t\" <file>                  regular file for loopdev setup\\n\"));\n\n\tfprintf(out, _(\n\t\"\\nOperations:\\n\"\n\t\" -B, --bind              mount a subtree somewhere else (same as -o bind)\\n\"\n\t\" -M, --move              move a subtree to some other place\\n\"\n\t\" -R, --rbind             mount a subtree and all submounts somewhere else\\n\"));\n\tfprintf(out, _(\n\t\" --make-shared           mark a subtree as shared\\n\"\n\t\" --make-slave            mark a subtree as slave\\n\"\n\t\" --make-private          mark a subtree as private\\n\"\n\t\" --make-unbindable       mark a subtree as unbindable\\n\"));\n\tfprintf(out, _(\n\t\" --make-rshared          recursively mark a whole subtree as shared\\n\"\n\t\" --make-rslave           recursively mark a whole subtree as slave\\n\"\n\t\" --make-rprivate         recursively mark a whole subtree as private\\n\"\n\t\" --make-runbindable      recursively mark a whole subtree as unbindable\\n\"));\n\n\tfprintf(out, USAGE_MAN_TAIL(\"mount(8)\"));\n\n\texit(out == stderr ? MOUNT_EX_USAGE : MOUNT_EX_SUCCESS);\n}","target":0,"code_token_length":918,"total_token_length":1154,"max_tokens_setting":2048}
+{"idx":247123,"func":"static void gf_fs_print_filter_outputs(GF_Filter *f, GF_List *filters_done, u32 indent, GF_FilterPid *pid, GF_Filter *alias_for, u32 src_num_tiled_pids, Bool skip_print)\n{\n\tu32 i=0;\n\tu32 num_tile_pids = 0;\n\n\tif (!skip_print) {\n\t\twhile (i<indent) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"-\"));\n\t\t\ti++;\n\t\t}\n\n\t\tif (src_num_tiled_pids>1) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"(tilePID[%d]) \", src_num_tiled_pids));\n\t\t}\n\t\telse if (pid) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"(PID %s) \", pid->name));\n\t\t}\n\n\t\tprint_filter_name(f, GF_TRUE, GF_FALSE);\n\t\tif (f->id) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" (ID=%s)\\n\", f->id));\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" (ptr=%p)\\n\", f));\n\t\t}\n\t}\n\n\tif (filters_done && (gf_list_find(filters_done, f)>=0))\n\t\treturn;\n\n\tif (filters_done)\n\t\tgf_list_add(filters_done, f);\n\tif (alias_for && !skip_print) {\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" (<=> \"));\n\t\tprint_filter_name(alias_for, GF_TRUE, GF_TRUE);\n\t\tif (alias_for->id) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" ID=%s\", alias_for->id));\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\" ptr=%p\", alias_for));\n\t\t}\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\")\\n\"));\n\t}\n\n\tfor (i=0; i<f->num_output_pids; i++) {\n\t\tu32 j, k;\n\t\tBool is_tiled = GF_FALSE;\n\t\tBool skip_tiled = skip_print;\n\n\t\tGF_FilterPid *pidout = gf_list_get(f->output_pids, i);\n\t\tconst GF_PropertyValue *p = gf_filter_pid_get_property(pidout, GF_PROP_PID_CODECID);\n\t\tif (p && (p->value.uint==GF_CODECID_HEVC_TILES)) {\n\t\t\tis_tiled = GF_TRUE;\n\t\t\t\/\/only print the first tile pid\n\t\t\tif (num_tile_pids) {\n\t\t\t\tskip_tiled = GF_TRUE;\n\t\t\t} else {\n\t\t\t\tfor (j=i; j<f->num_output_pids; j++) {\n\t\t\t\t\tGF_FilterPid *apid = gf_list_get(f->output_pids, j);\n\t\t\t\t\tconst GF_PropertyValue *p = gf_filter_pid_get_property(apid, GF_PROP_PID_CODECID);\n\t\t\t\t\tif (p && (p->value.uint==GF_CODECID_HEVC_TILES)) {\n\t\t\t\t\t\tnum_tile_pids++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (j=0; j<pidout->num_destinations; j++) {\n\t\t\tGF_FilterPidInst *pidi = gf_list_get(pidout->destinations, j);\n\t\t\tGF_Filter *alias = NULL;\n\t\t\tfor (k=0; k<gf_list_count(f->destination_filters); k++) {\n\t\t\t\talias = gf_list_get(f->destination_filters, k);\n\t\t\t\tif (alias->multi_sink_target == pidi->filter)\n\t\t\t\t\tbreak;\n\t\t\t\talias = NULL;\n\t\t\t}\n\t\t\tif (alias) {\n\t\t\t\tgf_fs_print_filter_outputs(alias, filters_done, indent+1, pidout, pidi->filter, is_tiled ? num_tile_pids : src_num_tiled_pids, skip_tiled);\n\t\t\t} else {\n\t\t\t\tgf_fs_print_filter_outputs(pidi->filter, filters_done, indent+1, pidout, NULL, is_tiled ? num_tile_pids : src_num_tiled_pids, skip_tiled);\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":876,"total_token_length":1112,"max_tokens_setting":2048}
+{"idx":232291,"func":"bool SampleInterleavedLSScan::WriteMCU(void)\n{\n#if ACCUSOFT_CODE\n  int lines             = m_ulRemaining[0]; \/\/ total number of MCU lines processed.\n  UBYTE preshift        = m_ucLowBit + FractionalColorBitsOf();\n  struct Line *line[4];\n  UBYTE cx;\n  \n  \/\/\n  \/\/ A \"MCU\" in respect to the code organization is eight lines.\n  if (lines > 8) {\n    lines = 8;\n  }\n  m_ulRemaining[0] -= lines;\n  assert(lines > 0);\n  assert(m_ucCount < 4);\n\n  \/\/\n  \/\/ Fill the line pointers.\n  for(cx = 0;cx < m_ucCount;cx++) {\n    line[cx] = CurrentLine(cx);\n  }\n\n  \/\/ Loop over lines and columns\n  do {\n    LONG length = m_ulWidth[0];\n    LONG *lp[4];\n\n    \/\/ Get the line pointers and initialize the internal backup lines.\n    for(cx = 0;cx < m_ucCount;cx++) {\n      lp[cx] = line[cx]->m_pData;\n      StartLine(cx);\n    }\n    \/\/\n    BeginWriteMCU(m_Stream.ByteStreamOf()); \n    do {\n        LONG a[4],b[4],c[4],d[4]; \/\/ neighbouring values.\n        LONG d1[4],d2[4],d3[4];   \/\/ local gradients.\n        bool isrun = true;\n      \n        for(cx = 0;cx < m_ucCount;cx++) {\n          GetContext(cx,a[cx],b[cx],c[cx],d[cx]);\n\n          d1[cx]  = d[cx] - b[cx];    \/\/ compute local gradients\n          d2[cx]  = b[cx] - c[cx];\n          d3[cx]  = c[cx] - a[cx];\n\n          \/\/\n          \/\/ Run mode only if the run condition is met for all components\n          if (isrun && !isRunMode(d1[cx],d2[cx],d3[cx]))\n            isrun = false;\n        }\n        \n        if (isrun) {\n          LONG runcnt = 0;\n          do {\n            \/\/\n            \/\/ Check whether the pixel is close enough to continue the run.\n            for(cx = 0;cx < m_ucCount;cx++) {\n              LONG x  = *lp[cx] >> preshift;\n              if (x - a[cx] < -m_lNear || x - a[cx] > m_lNear)\n                break;\n            }\n            if (cx < m_ucCount)\n              break; \/\/ run ends.\n            \/\/\n            \/\/ Update so that the next process gets the correct value.\n            \/\/ Also updates the line pointers.\n            for(cx = 0;cx < m_ucCount;cx++) {\n              UpdateContext(cx,a[cx]);\n              lp[cx]++;\n            }\n          } while(runcnt++,--length);\n          \/\/\n          \/\/ Encode the run. Note that only a single run index is used here.\n          EncodeRun(runcnt,length == 0,m_lRunIndex[0]);\n          \/\/ Continue the encoding of the end of the run if there are more\n          \/\/ samples to encode.\n          if (length) {       \n            bool negative; \/\/ the sign variable\n            LONG errval;   \/\/ the prediction error\n            LONG merr;     \/\/ the mapped error (symbol)\n            LONG rx;       \/\/ the reconstructed value\n            UBYTE k;       \/\/ golomb parameter\n            \/\/\n            \/\/ The complete pixel in all components is now to be encoded.\n            for(cx = 0;cx < m_ucCount;cx++) {\n              \/\/ Get the neighbourhood.\n              GetContext(cx,a[cx],b[cx],c[cx],d[cx]);\n              \/\/ The prediction mode is always fixed, but the sign\n              \/\/ has to be found.\n              negative = a[cx] > b[cx];\n              \/\/ Compute the error value.\n              errval   = (*lp[cx]++ >> preshift) - b[cx];\n              if (negative)\n                errval = -errval;\n              \/\/ Quantize the error.\n              errval = QuantizePredictionError(errval);\n              \/\/ Compute the reconstructed value.\n              rx     = Reconstruct(negative,b[cx],errval);\n              \/\/ Update so that the next process gets the correct value.\n              UpdateContext(cx,rx);\n              \/\/ Get the golomb parameter for run interruption coding.\n              k      = GolombParameter(false);\n              \/\/ Map the error into a symbol.\n              merr   = ErrorMapping(errval,ErrorMappingOffset(false,errval != 0,k));\n              \/\/ Golomb-coding of the error.\n              GolombCode(k,merr,m_lLimit - m_lJ[m_lRunIndex[0]] - 1);\n              \/\/ Update the variables of the run mode.\n              UpdateState(false,errval);\n            }\n            \/\/ Update the run index now. This is not part of\n            \/\/ EncodeRun because the non-reduced run-index is\n            \/\/ required for the golomb coder length limit.\n            if (m_lRunIndex[0] > 0)\n                m_lRunIndex[0]--;\n          } else break; \/\/ Line ended, abort the loop over the line.  \n        } else { \n          UWORD ctxt;\n          bool  negative; \/\/ the sign variable.\n          LONG  px;       \/\/ the predicted variable.\n          LONG  rx;       \/\/ the reconstructed value.\n          LONG  errval;   \/\/ the error value.\n          LONG  merr;     \/\/ the mapped error value.\n          UBYTE k;        \/\/ the Golomb parameter.\n          \/\/\n          for(cx = 0;cx < m_ucCount;cx++) {\n            \/\/ Quantize the gradients.\n            d1[cx]     = QuantizedGradient(d1[cx]);\n            d2[cx]     = QuantizedGradient(d2[cx]);\n            d3[cx]     = QuantizedGradient(d3[cx]);\n            \/\/ Compute the context.\n            ctxt   = Context(negative,d1[cx],d2[cx],d3[cx]); \n            \/\/ Compute the predicted value.\n            px     = Predict(a[cx],b[cx],c[cx]);\n            \/\/ Correct the prediction.\n            px     = CorrectPrediction(ctxt,negative,px);\n            \/\/ Compute the error value.\n            errval = (*lp[cx]++ >> preshift) - px;\n            if (negative)\n              errval = -errval;\n            \/\/ Quantize the prediction error if NEAR > 0\n            errval = QuantizePredictionError(errval);\n            \/\/ Compute the reconstructed value.\n            rx     = Reconstruct(negative,px,errval);\n            \/\/ Update so that the next process gets the correct value.\n            UpdateContext(cx,rx);\n            \/\/ Compute the golomb parameter k from the context.\n            k      = GolombParameter(ctxt);\n            \/\/ Map the error into a symbol\n            merr   = ErrorMapping(errval,ErrorMappingOffset(ctxt,k));\n            \/\/ Golomb-coding of the error.\n            GolombCode(k,merr,m_lLimit);\n            \/\/ Update the variables.\n            UpdateState(ctxt,errval);\n          }\n        }\n    } while(--length);\n    \/\/\n    \/\/ Advance the line pointers.\n    for(cx = 0;cx < m_ucCount;cx++) {\n      EndLine(cx);\n      line[cx] = line[cx]->m_pNext;\n    }\n    \/\/\n  } while(--lines);\n#endif  \n  return false;\n}","target":0,"code_token_length":1610,"total_token_length":1846,"max_tokens_setting":2048}
+{"idx":336136,"func":"static int ip6gre_tunnel_ioctl(struct net_device *dev,\n\tstruct ifreq *ifr, int cmd)\n{\n\tint err = 0;\n\tstruct ip6_tnl_parm2 p;\n\tstruct __ip6_tnl_parm p1;\n\tstruct ip6_tnl *t = netdev_priv(dev);\n\tstruct net *net = t->net;\n\tstruct ip6gre_net *ign = net_generic(net, ip6gre_net_id);\n\n\tmemset(&p1, 0, sizeof(p1));\n\n\tswitch (cmd) {\n\tcase SIOCGETTUNNEL:\n\t\tif (dev == ign->fb_tunnel_dev) {\n\t\t\tif (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) {\n\t\t\t\terr = -EFAULT;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tip6gre_tnl_parm_from_user(&p1, &p);\n\t\t\tt = ip6gre_tunnel_locate(net, &p1, 0);\n\t\t\tif (!t)\n\t\t\t\tt = netdev_priv(dev);\n\t\t}\n\t\tmemset(&p, 0, sizeof(p));\n\t\tip6gre_tnl_parm_to_user(&p, &t->parms);\n\t\tif (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\n\tcase SIOCADDTUNNEL:\n\tcase SIOCCHGTUNNEL:\n\t\terr = -EPERM;\n\t\tif (!ns_capable(net->user_ns, CAP_NET_ADMIN))\n\t\t\tgoto done;\n\n\t\terr = -EFAULT;\n\t\tif (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))\n\t\t\tgoto done;\n\n\t\terr = -EINVAL;\n\t\tif ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING))\n\t\t\tgoto done;\n\n\t\tif (!(p.i_flags&GRE_KEY))\n\t\t\tp.i_key = 0;\n\t\tif (!(p.o_flags&GRE_KEY))\n\t\t\tp.o_key = 0;\n\n\t\tip6gre_tnl_parm_from_user(&p1, &p);\n\t\tt = ip6gre_tunnel_locate(net, &p1, cmd == SIOCADDTUNNEL);\n\n\t\tif (dev != ign->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {\n\t\t\tif (t) {\n\t\t\t\tif (t->dev != dev) {\n\t\t\t\t\terr = -EEXIST;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tt = netdev_priv(dev);\n\n\t\t\t\tip6gre_tunnel_unlink(ign, t);\n\t\t\t\tsynchronize_net();\n\t\t\t\tip6gre_tnl_change(t, &p1, 1);\n\t\t\t\tip6gre_tunnel_link(ign, t);\n\t\t\t\tnetdev_state_change(dev);\n\t\t\t}\n\t\t}\n\n\t\tif (t) {\n\t\t\terr = 0;\n\n\t\t\tmemset(&p, 0, sizeof(p));\n\t\t\tip6gre_tnl_parm_to_user(&p, &t->parms);\n\t\t\tif (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))\n\t\t\t\terr = -EFAULT;\n\t\t} else\n\t\t\terr = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT);\n\t\tbreak;\n\n\tcase SIOCDELTUNNEL:\n\t\terr = -EPERM;\n\t\tif (!ns_capable(net->user_ns, CAP_NET_ADMIN))\n\t\t\tgoto done;\n\n\t\tif (dev == ign->fb_tunnel_dev) {\n\t\t\terr = -EFAULT;\n\t\t\tif (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))\n\t\t\t\tgoto done;\n\t\t\terr = -ENOENT;\n\t\t\tip6gre_tnl_parm_from_user(&p1, &p);\n\t\t\tt = ip6gre_tunnel_locate(net, &p1, 0);\n\t\t\tif (!t)\n\t\t\t\tgoto done;\n\t\t\terr = -EPERM;\n\t\t\tif (t == netdev_priv(ign->fb_tunnel_dev))\n\t\t\t\tgoto done;\n\t\t\tdev = t->dev;\n\t\t}\n\t\tunregister_netdevice(dev);\n\t\terr = 0;\n\t\tbreak;\n\n\tdefault:\n\t\terr = -EINVAL;\n\t}\n\ndone:\n\treturn err;\n}","target":0,"code_token_length":862,"total_token_length":1098,"max_tokens_setting":2048}
+{"idx":197095,"func":"inline void BinaryBroadcastFiveFold(const ArithmeticParams& unswitched_params,\n                                    const RuntimeShape& unswitched_input1_shape,\n                                    const T* unswitched_input1_data,\n                                    const RuntimeShape& unswitched_input2_shape,\n                                    const T* unswitched_input2_data,\n                                    const RuntimeShape& output_shape,\n                                    T* output_data, ElementwiseF elementwise_f,\n                                    ScalarBroadcastF scalar_broadcast_f) {\n  ArithmeticParams switched_params = unswitched_params;\n  switched_params.input1_offset = unswitched_params.input2_offset;\n  switched_params.input1_multiplier = unswitched_params.input2_multiplier;\n  switched_params.input1_shift = unswitched_params.input2_shift;\n  switched_params.input2_offset = unswitched_params.input1_offset;\n  switched_params.input2_multiplier = unswitched_params.input1_multiplier;\n  switched_params.input2_shift = unswitched_params.input1_shift;\n\n  const bool use_unswitched =\n      unswitched_params.broadcast_category ==\n      tflite::BroadcastableOpCategory::kFirstInputBroadcastsFast;\n\n  const ArithmeticParams& params =\n      use_unswitched ? unswitched_params : switched_params;\n  const T* input1_data =\n      use_unswitched ? unswitched_input1_data : unswitched_input2_data;\n  const T* input2_data =\n      use_unswitched ? unswitched_input2_data : unswitched_input1_data;\n\n  \/\/ Fivefold nested loops. The second input resets its position for each\n  \/\/ iteration of the second loop. The first input resets its position at the\n  \/\/ beginning of the fourth loop. The innermost loop is an elementwise add of\n  \/\/ sections of the arrays.\n  T* output_data_ptr = output_data;\n  const T* input1_data_ptr = input1_data;\n  const T* input2_data_reset = input2_data;\n  \/\/ In the fivefold pattern, y0, y2 and y4 are not broadcast, and so shared\n  \/\/ between input shapes. y3 for input 1 is always broadcast, and so the\n  \/\/ dimension there is 1, whereas optionally y1 might be broadcast for\n  \/\/ input 2. Put another way, input1.shape.FlatSize = y0 * y1 * y2 * y4,\n  \/\/ input2.shape.FlatSize = y0 * y2 * y3 * y4.\n  int y0 = params.broadcast_shape[0];\n  int y1 = params.broadcast_shape[1];\n  int y2 = params.broadcast_shape[2];\n  int y3 = params.broadcast_shape[3];\n  int y4 = params.broadcast_shape[4];\n  if (y4 > 1) {\n    \/\/ General fivefold pattern, with y4 > 1 so there is a non-broadcast inner\n    \/\/ dimension.\n    for (int i0 = 0; i0 < y0; ++i0) {\n      const T* input2_data_ptr = nullptr;\n      for (int i1 = 0; i1 < y1; ++i1) {\n        input2_data_ptr = input2_data_reset;\n        for (int i2 = 0; i2 < y2; ++i2) {\n          for (int i3 = 0; i3 < y3; ++i3) {\n            elementwise_f(y4, params, input1_data_ptr, input2_data_ptr,\n                          output_data_ptr);\n            input2_data_ptr += y4;\n            output_data_ptr += y4;\n          }\n          \/\/ We have broadcast y4 of input1 data y3 times, and now move on.\n          input1_data_ptr += y4;\n        }\n      }\n      \/\/ We have broadcast y2*y3*y4 of input2 data y1 times, and now move on.\n      input2_data_reset = input2_data_ptr;\n    }\n  } else {\n    \/\/ Special case of y4 == 1, in which the innermost loop is a single\n    \/\/ element and can be combined with the next (y3) as an inner broadcast.\n    \/\/\n    \/\/ Note that this handles the case of pure scalar broadcast when\n    \/\/ y0 == y1 == y2 == 1. With low overhead it handles cases such as scalar\n    \/\/ broadcast with batch (as y2 > 1).\n    \/\/\n    \/\/ NOTE The process is the same as the above general case except\n    \/\/ simplified for y4 == 1 and the loop over y3 is contained within the\n    \/\/ AddScalarBroadcast function.\n    for (int i0 = 0; i0 < y0; ++i0) {\n      const T* input2_data_ptr = nullptr;\n      for (int i1 = 0; i1 < y1; ++i1) {\n        input2_data_ptr = input2_data_reset;\n        for (int i2 = 0; i2 < y2; ++i2) {\n          scalar_broadcast_f(y3, params, *input1_data_ptr, input2_data_ptr,\n                             output_data_ptr);\n          input2_data_ptr += y3;\n          output_data_ptr += y3;\n          input1_data_ptr += 1;\n        }\n      }\n      input2_data_reset = input2_data_ptr;\n    }\n  }\n}","target":1,"code_token_length":1113,"total_token_length":1349,"max_tokens_setting":2048}
+{"idx":261378,"func":"bool alloc_and_init_significant_coeff_ctxIdx_lookupTable_OLD()\n{\n  int tableSize = 2*2*4*(4*4 + 8*8 + 16*16 + 32*32);\n  uint8_t* p = (uint8_t*)malloc(tableSize);\n  if (p==NULL) {\n    return false;\n  }\n\n  for (int log2w=2; log2w<=5 ; log2w++)\n    for (int cIdx=0;cIdx<2;cIdx++)\n      for (int scanIdx=0;scanIdx<2;scanIdx++)\n        for (int prevCsbf=0;prevCsbf<4;prevCsbf++)\n          {\n            \/\/ assign pointer into reserved memory area\n\n            ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf] = p;\n            p += (1<<log2w)*(1<<log2w);\n\n            const position* ScanOrderSub = get_scan_order(log2w-2, scanIdx);\n            const position* ScanOrderPos = get_scan_order(2, scanIdx);\n\n            \/\/for (int yC=0;yC<(1<<log2w);yC++)\n            \/\/ for (int xC=0;xC<(1<<log2w);xC++)\n            for (int s=0;s<(1<<log2w)*(1<<log2w);s++)\n              {\n                position S = ScanOrderSub[s>>4];\n                int x0 = S.x<<2;\n                int y0 = S.y<<2;\n\n                int subX = ScanOrderPos[s & 0xF].x;\n                int subY = ScanOrderPos[s & 0xF].y;\n                int xC = x0 + subX;\n                int yC = y0 + subY;\n\n\n                int w = 1<<log2w;\n                int sbWidth = w>>2;\n\n                int sigCtx;\n\n                \/\/ if log2TrafoSize==2\n                if (sbWidth==1) {\n                  sigCtx = ctxIdxMap[(yC<<2) + xC];\n                }\n                else if (xC+yC==0) {\n                  sigCtx = 0;\n                }\n                else {\n                  int xS = xC>>2;\n                  int yS = yC>>2;\n                  \/*\n                    int prevCsbf = 0;\n\n                    if (xS < sbWidth-1) { prevCsbf += coded_sub_block_flag[xS+1  +yS*sbWidth];    }\n                    if (yS < sbWidth-1) { prevCsbf += coded_sub_block_flag[xS+(1+yS)*sbWidth]<<1; }\n                  *\/\n                  int xP = xC & 3;\n                  int yP = yC & 3;\n\n                  logtrace(LogSlice,\"posInSubset: %d,%d\\n\",xP,yP);\n                  logtrace(LogSlice,\"prevCsbf: %d\\n\",prevCsbf);\n\n                  \/\/printf(\"%d | %d %d\\n\",prevCsbf,xP,yP);\n\n                  switch (prevCsbf) {\n                  case 0:\n                    \/\/sigCtx = (xP+yP==0) ? 2 : (xP+yP<3) ? 1 : 0;\n                    sigCtx = (xP+yP>=3) ? 0 : (xP+yP>0) ? 1 : 2;\n                    break;\n                  case 1:\n                    sigCtx = (yP==0) ? 2 : (yP==1) ? 1 : 0;\n                    break;\n                  case 2:\n                    sigCtx = (xP==0) ? 2 : (xP==1) ? 1 : 0;\n                    break;\n                  default:\n                    sigCtx = 2;\n                    break;\n                  }\n\n                  logtrace(LogSlice,\"a) sigCtx=%d\\n\",sigCtx);\n\n                  if (cIdx==0) {\n                    if (xS+yS > 0) sigCtx+=3;\n\n                    logtrace(LogSlice,\"b) sigCtx=%d\\n\",sigCtx);\n\n                    \/\/ if log2TrafoSize==3\n                    if (sbWidth==2) { \/\/ 8x8 block\n                      sigCtx += (scanIdx==0) ? 9 : 15;\n                    } else {\n                      sigCtx += 21;\n                    }\n\n                    logtrace(LogSlice,\"c) sigCtx=%d\\n\",sigCtx);\n                  }\n                  else {\n                    \/\/ if log2TrafoSize==3\n                    if (sbWidth==2) { \/\/ 8x8 block\n                      sigCtx+=9;\n                    }\n                    else {\n                      sigCtx+=12;\n                    }\n                  }\n                }\n\n                int ctxIdxInc;\n                if (cIdx==0) { ctxIdxInc=sigCtx; }\n                else         { ctxIdxInc=27+sigCtx; }\n\n\n                ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf][xC+(yC<<log2w)] = ctxIdxInc;\n\n                \/\/NOTE: when using this option, we have to include all three scanIdx in the table\n                \/\/ctxIdxLookup[log2w-2][cIdx][scanIdx][prevCsbf][s] = ctxIdxInc;\n              }\n          }\n\n  return true;\n}","target":0,"code_token_length":1145,"total_token_length":1381,"max_tokens_setting":2048}
+{"idx":376333,"func":"gpg_encrypt_sync (CamelCipherContext *context,\n                  const gchar *userid,\n                  GPtrArray *recipients,\n                  CamelMimePart *ipart,\n                  CamelMimePart *opart,\n                  GCancellable *cancellable,\n                  GError **error)\n{\n\tCamelCipherContextClass *class;\n\tCamelGpgContext *ctx = (CamelGpgContext *) context;\n\tstruct _GpgCtx *gpg;\n\tCamelStream *istream, *ostream, *vstream;\n\tCamelMimePart *encpart, *verpart;\n\tCamelDataWrapper *dw;\n\tCamelContentType *ct;\n\tCamelMultipartEncrypted *mpe;\n\tgboolean success = FALSE;\n\tgint i;\n\n\tclass = CAMEL_CIPHER_CONTEXT_GET_CLASS (context);\n\n\tostream = camel_stream_mem_new ();\n\tistream = camel_stream_mem_new ();\n\tif (camel_cipher_canonical_to_stream (\n\t\tipart, CAMEL_MIME_FILTER_CANON_CRLF, istream, NULL, error) == -1) {\n\t\tg_prefix_error (\n\t\t\terror, _(\"Could not generate encrypting data: \"));\n\t\tgoto fail1;\n\t}\n\n\tgpg = gpg_ctx_new (context);\n\tgpg_ctx_set_mode (gpg, GPG_CTX_MODE_ENCRYPT);\n\tgpg_ctx_set_armor (gpg, TRUE);\n\tgpg_ctx_set_userid (gpg, userid);\n\tgpg_ctx_set_istream (gpg, istream);\n\tgpg_ctx_set_ostream (gpg, ostream);\n\tgpg_ctx_set_always_trust (gpg, ctx->priv->always_trust);\n\n\tfor (i = 0; i < recipients->len; i++) {\n\t\tgpg_ctx_add_recipient (gpg, recipients->pdata[i]);\n\t}\n\n\tif (!gpg_ctx_op_start (gpg, error))\n\t\tgoto fail;\n\n\t\/* FIXME: move this to a common routine *\/\n\twhile (!gpg_ctx_op_complete (gpg)) {\n\t\tif (gpg_ctx_op_step (gpg, cancellable, error) == -1) {\n\t\t\tgpg_ctx_op_cancel (gpg);\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tif (gpg_ctx_op_wait (gpg) != 0) {\n\t\tconst gchar *diagnostics;\n\n\t\tdiagnostics = gpg_ctx_get_diagnostics (gpg);\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC, \"%s\",\n\t\t\t(diagnostics != NULL && *diagnostics != '\\0') ?\n\t\t\tdiagnostics : _(\"Failed to execute gpg.\"));\n\t\tgoto fail;\n\t}\n\n\tsuccess = TRUE;\n\n\tdw = camel_data_wrapper_new ();\n\tcamel_data_wrapper_construct_from_stream_sync (\n\t\tdw, ostream, NULL, NULL);\n\n\tencpart = camel_mime_part_new ();\n\tct = camel_content_type_new (\"application\", \"octet-stream\");\n\tcamel_content_type_set_param (ct, \"name\", \"encrypted.asc\");\n\tcamel_data_wrapper_set_mime_type_field (dw, ct);\n\tcamel_content_type_unref (ct);\n\n\tcamel_medium_set_content ((CamelMedium *) encpart, dw);\n\tg_object_unref (dw);\n\n\tcamel_mime_part_set_description (encpart, _(\"This is a digitally encrypted message part\"));\n\n\tvstream = camel_stream_mem_new ();\n\tcamel_stream_write_string (vstream, \"Version: 1\\n\", NULL, NULL);\n\tg_seekable_seek (G_SEEKABLE (vstream), 0, G_SEEK_SET, NULL, NULL);\n\n\tverpart = camel_mime_part_new ();\n\tdw = camel_data_wrapper_new ();\n\tcamel_data_wrapper_set_mime_type (dw, class->encrypt_protocol);\n\tcamel_data_wrapper_construct_from_stream_sync (\n\t\tdw, vstream, NULL, NULL);\n\tg_object_unref (vstream);\n\tcamel_medium_set_content ((CamelMedium *) verpart, dw);\n\tg_object_unref (dw);\n\n\tmpe = camel_multipart_encrypted_new ();\n\tct = camel_content_type_new (\"multipart\", \"encrypted\");\n\tcamel_content_type_set_param (ct, \"protocol\", class->encrypt_protocol);\n\tcamel_data_wrapper_set_mime_type_field ((CamelDataWrapper *) mpe, ct);\n\tcamel_content_type_unref (ct);\n\tcamel_multipart_set_boundary ((CamelMultipart *) mpe, NULL);\n\n\tmpe->decrypted = g_object_ref (ipart);\n\n\tcamel_multipart_add_part ((CamelMultipart *) mpe, verpart);\n\tg_object_unref (verpart);\n\tcamel_multipart_add_part ((CamelMultipart *) mpe, encpart);\n\tg_object_unref (encpart);\n\n\tcamel_medium_set_content ((CamelMedium *) opart, (CamelDataWrapper *) mpe);\nfail:\n\tgpg_ctx_free (gpg);\nfail1:\n\tg_object_unref (istream);\n\tg_object_unref (ostream);\n\n\treturn success;\n}","target":0,"code_token_length":999,"total_token_length":1235,"max_tokens_setting":2048}
+{"idx":223452,"func":"static void peek_char_back(compiler_common *common, sljit_u32 max, jump_list **backtracks)\n{\n\/* Reads one character back without moving STR_PTR. TMP2 must\ncontain the start of the subject buffer. Affects TMP1, TMP2, and RETURN_ADDR. *\/\nDEFINE_COMPILER;\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\nstruct sljit_jump *jump;\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 *\/\n\nSLJIT_UNUSED_ARG(max);\nSLJIT_UNUSED_ARG(backtracks);\n\nOP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));\n\n#ifdef SUPPORT_UNICODE\n#if PCRE2_CODE_UNIT_WIDTH == 8\nif (common->utf)\n  {\n  if (max < 128) return;\n\n  jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0x80);\n  if (common->invalid_utf)\n    {\n    add_jump(compiler, &common->utfpeakcharback_invalid, JUMP(SLJIT_FAST_CALL));\n    if (backtracks != NULL)\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR));\n    }\n  else\n    add_jump(compiler, &common->utfpeakcharback, JUMP(SLJIT_FAST_CALL));\n  JUMPHERE(jump);\n  }\n#elif PCRE2_CODE_UNIT_WIDTH == 16\nif (common->utf)\n  {\n  if (max < 0xd800) return;\n\n  if (common->invalid_utf)\n    {\n    jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800);\n    add_jump(compiler, &common->utfpeakcharback_invalid, JUMP(SLJIT_FAST_CALL));\n    if (backtracks != NULL)\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR));\n    }\n  else\n    {\n    OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xdc00);\n    jump = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0xe000 - 0xdc00);\n    \/* TMP2 contains the low surrogate. *\/\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));\n    OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x10000);\n    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xd800);\n    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 10);\n    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\n    }\n    JUMPHERE(jump);\n  }\n#elif PCRE2_CODE_UNIT_WIDTH == 32\nif (common->invalid_utf)\n  {\n  OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);\n  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x110000));\n  add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800));\n  }\n#endif \/* PCRE2_CODE_UNIT_WIDTH == [8|16|32] *\/\n#endif \/* SUPPORT_UNICODE *\/\n}","target":0,"code_token_length":866,"total_token_length":1102,"max_tokens_setting":2048}
+{"idx":308176,"func":"static int fastrpc_init_create_process(struct fastrpc_user *fl,\n\t\t\t\t\tchar __user *argp)\n{\n\tstruct fastrpc_init_create init;\n\tstruct fastrpc_invoke_args *args;\n\tstruct fastrpc_phy_page pages[1];\n\tstruct fastrpc_map *map = NULL;\n\tstruct fastrpc_buf *imem = NULL;\n\tint memlen;\n\tint err;\n\tstruct {\n\t\tint pgid;\n\t\tu32 namelen;\n\t\tu32 filelen;\n\t\tu32 pageslen;\n\t\tu32 attrs;\n\t\tu32 siglen;\n\t} inbuf;\n\tu32 sc;\n\n\targs = kcalloc(FASTRPC_CREATE_PROCESS_NARGS, sizeof(*args), GFP_KERNEL);\n\tif (!args)\n\t\treturn -ENOMEM;\n\n\tif (copy_from_user(&init, argp, sizeof(init))) {\n\t\terr = -EFAULT;\n\t\tgoto err;\n\t}\n\n\tif (init.filelen > INIT_FILELEN_MAX) {\n\t\terr = -EINVAL;\n\t\tgoto err;\n\t}\n\n\tinbuf.pgid = fl->tgid;\n\tinbuf.namelen = strlen(current->comm) + 1;\n\tinbuf.filelen = init.filelen;\n\tinbuf.pageslen = 1;\n\tinbuf.attrs = init.attrs;\n\tinbuf.siglen = init.siglen;\n\tfl->pd = 1;\n\n\tif (init.filelen && init.filefd) {\n\t\terr = fastrpc_map_create(fl, init.filefd, init.filelen, &map);\n\t\tif (err)\n\t\t\tgoto err;\n\t}\n\n\tmemlen = ALIGN(max(INIT_FILELEN_MAX, (int)init.filelen * 4),\n\t\t       1024 * 1024);\n\terr = fastrpc_buf_alloc(fl, fl->sctx->dev, memlen,\n\t\t\t\t&imem);\n\tif (err)\n\t\tgoto err_alloc;\n\n\tfl->init_mem = imem;\n\targs[0].ptr = (u64)(uintptr_t)&inbuf;\n\targs[0].length = sizeof(inbuf);\n\targs[0].fd = -1;\n\n\targs[1].ptr = (u64)(uintptr_t)current->comm;\n\targs[1].length = inbuf.namelen;\n\targs[1].fd = -1;\n\n\targs[2].ptr = (u64) init.file;\n\targs[2].length = inbuf.filelen;\n\targs[2].fd = init.filefd;\n\n\tpages[0].addr = imem->phys;\n\tpages[0].size = imem->size;\n\n\targs[3].ptr = (u64)(uintptr_t) pages;\n\targs[3].length = 1 * sizeof(*pages);\n\targs[3].fd = -1;\n\n\targs[4].ptr = (u64)(uintptr_t)&inbuf.attrs;\n\targs[4].length = sizeof(inbuf.attrs);\n\targs[4].fd = -1;\n\n\targs[5].ptr = (u64)(uintptr_t) &inbuf.siglen;\n\targs[5].length = sizeof(inbuf.siglen);\n\targs[5].fd = -1;\n\n\tsc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE, 4, 0);\n\tif (init.attrs)\n\t\tsc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_ATTR, 6, 0);\n\n\terr = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,\n\t\t\t\t      sc, args);\n\tif (err)\n\t\tgoto err_invoke;\n\n\tkfree(args);\n\n\treturn 0;\n\nerr_invoke:\n\tfl->init_mem = NULL;\n\tfastrpc_buf_free(imem);\nerr_alloc:\n\tif (map) {\n\t\tspin_lock(&fl->lock);\n\t\tlist_del(&map->node);\n\t\tspin_unlock(&fl->lock);\n\t\tfastrpc_map_put(map);\n\t}\nerr:\n\tkfree(args);\n\n\treturn err;\n}","target":0,"code_token_length":805,"total_token_length":1041,"max_tokens_setting":2048}
+{"idx":310191,"func":"_nc_real_mvcur(NCURSES_SP_DCLx\n\t       int yold, int xold,\n\t       int ynew, int xnew,\n\t       NCURSES_SP_OUTC myOutCh,\n\t       int ovw)\n{\n    NCURSES_CH_T oldattr;\n    int code;\n\n    TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED(\"_nc_tinfo_mvcur(%p,%d,%d,%d,%d)\"),\n\t\t\t\t  (void *) SP_PARM, yold, xold, ynew, xnew));\n\n    if (SP_PARM == 0) {\n\tcode = ERR;\n    } else if (yold == ynew && xold == xnew) {\n\tcode = OK;\n    } else {\n\n\t\/*\n\t * Most work here is rounding for terminal boundaries getting the\n\t * column position implied by wraparound or the lack thereof and\n\t * rolling up the screen to get ynew on the screen.\n\t *\/\n\tif (xnew >= screen_columns(SP_PARM)) {\n\t    ynew += xnew \/ screen_columns(SP_PARM);\n\t    xnew %= screen_columns(SP_PARM);\n\t}\n\n\t\/*\n\t * Force restore even if msgr is on when we're in an alternate\n\t * character set -- these have a strong tendency to screw up the CR &\n\t * LF used for local character motions!\n\t *\/\n\toldattr = SCREEN_ATTRS(SP_PARM);\n\tif ((AttrOf(oldattr) & A_ALTCHARSET)\n\t    || (AttrOf(oldattr) && !move_standout_mode)) {\n\t    TR(TRACE_CHARPUT, (\"turning off (%#lx) %s before move\",\n\t\t\t       (unsigned long) AttrOf(oldattr),\n\t\t\t       _traceattr(AttrOf(oldattr))));\n\t    VIDPUTS(SP_PARM, A_NORMAL, 0);\n\t}\n\n\tif (xold >= screen_columns(SP_PARM)) {\n\n\t    if (SP_PARM->_nl) {\n\t\tint l = (xold + 1) \/ screen_columns(SP_PARM);\n\n\t\tyold += l;\n\t\tif (yold >= screen_lines(SP_PARM))\n\t\t    l -= (yold - screen_lines(SP_PARM) - 1);\n\n\t\tif (l > 0) {\n\t\t    if (carriage_return) {\n\t\t\tNCURSES_PUTP2(\"carriage_return\", carriage_return);\n\t\t    } else {\n\t\t\tmyOutCh(NCURSES_SP_ARGx '\\r');\n\t\t    }\n\t\t    xold = 0;\n\n\t\t    while (l > 0) {\n\t\t\tif (newline) {\n\t\t\t    NCURSES_PUTP2(\"newline\", newline);\n\t\t\t} else {\n\t\t\t    myOutCh(NCURSES_SP_ARGx '\\n');\n\t\t\t}\n\t\t\tl--;\n\t\t    }\n\t\t}\n\t    } else {\n\t\t\/*\n\t\t * If caller set nonl(), we cannot really use newlines to\n\t\t * position to the next row.\n\t\t *\/\n\t\txold = -1;\n\t\tyold = -1;\n\t    }\n\t}\n\n\tif (yold > screen_lines(SP_PARM) - 1)\n\t    yold = screen_lines(SP_PARM) - 1;\n\tif (ynew > screen_lines(SP_PARM) - 1)\n\t    ynew = screen_lines(SP_PARM) - 1;\n\n\t\/* destination location is on screen now *\/\n\tcode = onscreen_mvcur(NCURSES_SP_ARGx yold, xold, ynew, xnew, ovw, myOutCh);\n\n\t\/*\n\t * Restore attributes if we disabled them before moving.\n\t *\/\n\tif (!SameAttrOf(oldattr, SCREEN_ATTRS(SP_PARM))) {\n\t    TR(TRACE_CHARPUT, (\"turning on (%#lx) %s after move\",\n\t\t\t       (unsigned long) AttrOf(oldattr),\n\t\t\t       _traceattr(AttrOf(oldattr))));\n\t    VIDPUTS(SP_PARM, AttrOf(oldattr), GetPair(oldattr));\n\t}\n    }\n    returnCode(code);\n}","target":0,"code_token_length":814,"total_token_length":1050,"max_tokens_setting":2048}
+{"idx":387756,"func":"void InstanceKlass::purge_previous_version_list() {\n  assert(SafepointSynchronize::is_at_safepoint(), \"only called at safepoint\");\n  assert(has_been_redefined(), \"Should only be called for main class\");\n\n  \/\/ Quick exit.\n  if (previous_versions() == NULL) {\n    return;\n  }\n\n  \/\/ This klass has previous versions so see what we can cleanup\n  \/\/ while it is safe to do so.\n\n  int deleted_count = 0;    \/\/ leave debugging breadcrumbs\n  int live_count = 0;\n  ClassLoaderData* loader_data = class_loader_data();\n  assert(loader_data != NULL, \"should never be null\");\n\n  ResourceMark rm;\n  log_trace(redefine, class, iklass, purge)(\"%s: previous versions\", external_name());\n\n  \/\/ previous versions are linked together through the InstanceKlass\n  InstanceKlass* pv_node = previous_versions();\n  InstanceKlass* last = this;\n  int version = 0;\n\n  \/\/ check the previous versions list\n  for (; pv_node != NULL; ) {\n\n    ConstantPool* pvcp = pv_node->constants();\n    assert(pvcp != NULL, \"cp ref was unexpectedly cleared\");\n\n    if (!pvcp->on_stack()) {\n      \/\/ If the constant pool isn't on stack, none of the methods\n      \/\/ are executing.  Unlink this previous_version.\n      \/\/ The previous version InstanceKlass is on the ClassLoaderData deallocate list\n      \/\/ so will be deallocated during the next phase of class unloading.\n      log_trace(redefine, class, iklass, purge)\n        (\"previous version \" INTPTR_FORMAT \" is dead.\", p2i(pv_node));\n      \/\/ For debugging purposes.\n      pv_node->set_is_scratch_class();\n      \/\/ Unlink from previous version list.\n      assert(pv_node->class_loader_data() == loader_data, \"wrong loader_data\");\n      InstanceKlass* next = pv_node->previous_versions();\n      pv_node->link_previous_versions(NULL);   \/\/ point next to NULL\n      last->link_previous_versions(next);\n      \/\/ Add to the deallocate list after unlinking\n      loader_data->add_to_deallocate_list(pv_node);\n      pv_node = next;\n      deleted_count++;\n      version++;\n      continue;\n    } else {\n      log_trace(redefine, class, iklass, purge)(\"previous version \" INTPTR_FORMAT \" is alive\", p2i(pv_node));\n      assert(pvcp->pool_holder() != NULL, \"Constant pool with no holder\");\n      guarantee (!loader_data->is_unloading(), \"unloaded classes can't be on the stack\");\n      live_count++;\n      \/\/ found a previous version for next time we do class unloading\n      _has_previous_versions = true;\n    }\n\n    \/\/ At least one method is live in this previous version.\n    \/\/ Reset dead EMCP methods not to get breakpoints.\n    \/\/ All methods are deallocated when all of the methods for this class are no\n    \/\/ longer running.\n    Array<Method*>* method_refs = pv_node->methods();\n    if (method_refs != NULL) {\n      log_trace(redefine, class, iklass, purge)(\"previous methods length=%d\", method_refs->length());\n      for (int j = 0; j < method_refs->length(); j++) {\n        Method* method = method_refs->at(j);\n\n        if (!method->on_stack()) {\n          \/\/ no breakpoints for non-running methods\n          if (method->is_running_emcp()) {\n            method->set_running_emcp(false);\n          }\n        } else {\n          assert (method->is_obsolete() || method->is_running_emcp(),\n                  \"emcp method cannot run after emcp bit is cleared\");\n          log_trace(redefine, class, iklass, purge)\n            (\"purge: %s(%s): prev method @%d in version @%d is alive\",\n             method->name()->as_C_string(), method->signature()->as_C_string(), j, version);\n        }\n      }\n    }\n    \/\/ next previous version\n    last = pv_node;\n    pv_node = pv_node->previous_versions();\n    version++;\n  }\n  log_trace(redefine, class, iklass, purge)\n    (\"previous version stats: live=%d, deleted=%d\", live_count, deleted_count);\n}","target":0,"code_token_length":910,"total_token_length":1146,"max_tokens_setting":2048}
+{"idx":195665,"func":"njs_array_prototype_splice(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    int64_t      i, n, start, length, items, delta, delete;\n    njs_int_t    ret;\n    njs_value_t  *this, value, del_object;\n    njs_array_t  *array, *deleted;\n\n    this = njs_argument(args, 0);\n\n    ret = njs_value_to_object(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_object_length(vm, this, &length);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &start);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    start = (start < 0) ? njs_max(length + start, 0) : njs_min(start, length);\n\n    items = 0;\n    delete = 0;\n\n    if (nargs == 2) {\n        delete = length - start;\n\n    } else if (nargs > 2) {\n        items = nargs - 3;\n\n        ret = njs_value_to_integer(vm, njs_arg(args, nargs, 2), &delete);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        delete = njs_min(njs_max(delete, 0), length - start);\n    }\n\n    delta = items - delete;\n\n    if (njs_slow_path((length + delta) > NJS_MAX_LENGTH)) {\n        njs_type_error(vm, \"Invalid length\");\n        return NJS_ERROR;\n    }\n\n    \/* TODO: ArraySpeciesCreate(). *\/\n\n    deleted = njs_array_alloc(vm, 0, delete, 0);\n    if (njs_slow_path(deleted == NULL)) {\n        return NJS_ERROR;\n    }\n\n    if (njs_fast_path(njs_is_fast_array(this) && deleted->object.fast_array)) {\n        array = njs_array(this);\n        for (i = 0, n = start; i < delete; i++, n++) {\n            deleted->start[i] = array->start[n];\n        }\n\n    } else {\n        njs_set_array(&del_object, deleted);\n\n        for (i = 0, n = start; i < delete; i++, n++) {\n            ret = njs_value_property_i64(vm, this, n, &value);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return NJS_ERROR;\n            }\n\n            if (ret == NJS_OK) {\n                \/* TODO:  CreateDataPropertyOrThrow(). *\/\n                ret = njs_value_property_i64_set(vm, &del_object, i, &value);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    return ret;\n                }\n            }\n        }\n\n        ret = njs_object_length_set(vm, &del_object, delete);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NJS_ERROR;\n        }\n    }\n\n    if (njs_fast_path(njs_is_fast_array(this))) {\n        array = njs_array(this);\n\n        if (delta != 0) {\n            \/*\n             * Relocate the rest of items.\n             * Index of the first item is in \"n\".\n             *\/\n            if (delta > 0) {\n                ret = njs_array_expand(vm, array, 0, delta);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    return ret;\n                }\n            }\n\n            ret = njs_array_copy_within(vm, this, start + items, start + delete,\n                                        array->length - (start + delete), 0);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            array->length += delta;\n        }\n\n        \/* Copy new items. *\/\n\n        if (items > 0) {\n            memcpy(&array->start[start], &args[3],\n                   items * sizeof(njs_value_t));\n        }\n\n    } else {\n\n       if (delta != 0) {\n           ret = njs_array_copy_within(vm, this, start + items, start + delete,\n                                       length - (start + delete), delta < 0);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            for (i = length - 1; i >= length + delta; i--) {\n                ret = njs_value_property_i64_delete(vm, this, i, NULL);\n                if (njs_slow_path(ret == NJS_ERROR)) {\n                    return NJS_ERROR;\n                }\n            }\n       }\n\n        \/* Copy new items. *\/\n\n        for (i = 3, n = start; items-- > 0; i++, n++) {\n            ret = njs_value_property_i64_set(vm, this, n, &args[i]);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return NJS_ERROR;\n            }\n        }\n\n        ret = njs_object_length_set(vm, this, length + delta);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NJS_ERROR;\n        }\n    }\n\n    njs_set_array(&vm->retval, deleted);\n\n    return NJS_OK;\n}","target":1,"code_token_length":1161,"total_token_length":1397,"max_tokens_setting":2048}
+{"idx":253559,"func":"smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t   struct cifs_sb_info *cifs_sb, const char *full_path,\n\t\t   char **target_path, bool is_reparse_point)\n{\n\tint rc;\n\t__le16 *utf16_path = NULL;\n\t__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;\n\tstruct cifs_open_parms oparms;\n\tstruct cifs_fid fid;\n\tstruct kvec err_iov = {NULL, 0};\n\tstruct smb2_err_rsp *err_buf = NULL;\n\tstruct smb2_symlink_err_rsp *symlink;\n\tstruct TCP_Server_Info *server = cifs_pick_channel(tcon->ses);\n\tunsigned int sub_len;\n\tunsigned int sub_offset;\n\tunsigned int print_len;\n\tunsigned int print_offset;\n\tint flags = CIFS_CP_CREATE_CLOSE_OP;\n\tstruct smb_rqst rqst[3];\n\tint resp_buftype[3];\n\tstruct kvec rsp_iov[3];\n\tstruct kvec open_iov[SMB2_CREATE_IOV_SIZE];\n\tstruct kvec io_iov[SMB2_IOCTL_IOV_SIZE];\n\tstruct kvec close_iov[1];\n\tstruct smb2_create_rsp *create_rsp;\n\tstruct smb2_ioctl_rsp *ioctl_rsp;\n\tstruct reparse_data_buffer *reparse_buf;\n\tint create_options = is_reparse_point ? OPEN_REPARSE_POINT : 0;\n\tu32 plen;\n\n\tcifs_dbg(FYI, \"%s: path: %s\\n\", __func__, full_path);\n\n\t*target_path = NULL;\n\n\tif (smb3_encryption_required(tcon))\n\t\tflags |= CIFS_TRANSFORM_REQ;\n\n\tmemset(rqst, 0, sizeof(rqst));\n\tresp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;\n\tmemset(rsp_iov, 0, sizeof(rsp_iov));\n\n\tutf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);\n\tif (!utf16_path)\n\t\treturn -ENOMEM;\n\n\t\/* Open *\/\n\tmemset(&open_iov, 0, sizeof(open_iov));\n\trqst[0].rq_iov = open_iov;\n\trqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE;\n\n\tmemset(&oparms, 0, sizeof(oparms));\n\toparms.tcon = tcon;\n\toparms.desired_access = FILE_READ_ATTRIBUTES;\n\toparms.disposition = FILE_OPEN;\n\toparms.create_options = cifs_create_options(cifs_sb, create_options);\n\toparms.fid = &fid;\n\toparms.reconnect = false;\n\n\trc = SMB2_open_init(tcon, server,\n\t\t\t    &rqst[0], &oplock, &oparms, utf16_path);\n\tif (rc)\n\t\tgoto querty_exit;\n\tsmb2_set_next_command(tcon, &rqst[0]);\n\n\n\t\/* IOCTL *\/\n\tmemset(&io_iov, 0, sizeof(io_iov));\n\trqst[1].rq_iov = io_iov;\n\trqst[1].rq_nvec = SMB2_IOCTL_IOV_SIZE;\n\n\trc = SMB2_ioctl_init(tcon, server,\n\t\t\t     &rqst[1], fid.persistent_fid,\n\t\t\t     fid.volatile_fid, FSCTL_GET_REPARSE_POINT,\n\t\t\t     true \/* is_fctl *\/, NULL, 0,\n\t\t\t     CIFSMaxBufSize -\n\t\t\t     MAX_SMB2_CREATE_RESPONSE_SIZE -\n\t\t\t     MAX_SMB2_CLOSE_RESPONSE_SIZE);\n\tif (rc)\n\t\tgoto querty_exit;\n\n\tsmb2_set_next_command(tcon, &rqst[1]);\n\tsmb2_set_related(&rqst[1]);\n\n\n\t\/* Close *\/\n\tmemset(&close_iov, 0, sizeof(close_iov));\n\trqst[2].rq_iov = close_iov;\n\trqst[2].rq_nvec = 1;\n\n\trc = SMB2_close_init(tcon, server,\n\t\t\t     &rqst[2], COMPOUND_FID, COMPOUND_FID, false);\n\tif (rc)\n\t\tgoto querty_exit;\n\n\tsmb2_set_related(&rqst[2]);\n\n\trc = compound_send_recv(xid, tcon->ses, server,\n\t\t\t\tflags, 3, rqst,\n\t\t\t\tresp_buftype, rsp_iov);\n\n\tcreate_rsp = rsp_iov[0].iov_base;\n\tif (create_rsp && create_rsp->hdr.Status)\n\t\terr_iov = rsp_iov[0];\n\tioctl_rsp = rsp_iov[1].iov_base;\n\n\t\/*\n\t * Open was successful and we got an ioctl response.\n\t *\/\n\tif ((rc == 0) && (is_reparse_point)) {\n\t\t\/* See MS-FSCC 2.3.23 *\/\n\n\t\treparse_buf = (struct reparse_data_buffer *)\n\t\t\t((char *)ioctl_rsp +\n\t\t\t le32_to_cpu(ioctl_rsp->OutputOffset));\n\t\tplen = le32_to_cpu(ioctl_rsp->OutputCount);\n\n\t\tif (plen + le32_to_cpu(ioctl_rsp->OutputOffset) >\n\t\t    rsp_iov[1].iov_len) {\n\t\t\tcifs_tcon_dbg(VFS, \"srv returned invalid ioctl len: %d\\n\",\n\t\t\t\t plen);\n\t\t\trc = -EIO;\n\t\t\tgoto querty_exit;\n\t\t}\n\n\t\trc = parse_reparse_point(reparse_buf, plen, target_path,\n\t\t\t\t\t cifs_sb);\n\t\tgoto querty_exit;\n\t}\n\n\tif (!rc || !err_iov.iov_base) {\n\t\trc = -ENOENT;\n\t\tgoto querty_exit;\n\t}\n\n\terr_buf = err_iov.iov_base;\n\tif (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) ||\n\t    err_iov.iov_len < SMB2_SYMLINK_STRUCT_SIZE) {\n\t\trc = -EINVAL;\n\t\tgoto querty_exit;\n\t}\n\n\tsymlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;\n\tif (le32_to_cpu(symlink->SymLinkErrorTag) != SYMLINK_ERROR_TAG ||\n\t    le32_to_cpu(symlink->ReparseTag) != IO_REPARSE_TAG_SYMLINK) {\n\t\trc = -EINVAL;\n\t\tgoto querty_exit;\n\t}\n\n\t\/* open must fail on symlink - reset rc *\/\n\trc = 0;\n\tsub_len = le16_to_cpu(symlink->SubstituteNameLength);\n\tsub_offset = le16_to_cpu(symlink->SubstituteNameOffset);\n\tprint_len = le16_to_cpu(symlink->PrintNameLength);\n\tprint_offset = le16_to_cpu(symlink->PrintNameOffset);\n\n\tif (err_iov.iov_len < SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) {\n\t\trc = -EINVAL;\n\t\tgoto querty_exit;\n\t}\n\n\tif (err_iov.iov_len <\n\t    SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) {\n\t\trc = -EINVAL;\n\t\tgoto querty_exit;\n\t}\n\n\t*target_path = cifs_strndup_from_utf16(\n\t\t\t\t(char *)symlink->PathBuffer + sub_offset,\n\t\t\t\tsub_len, true, cifs_sb->local_nls);\n\tif (!(*target_path)) {\n\t\trc = -ENOMEM;\n\t\tgoto querty_exit;\n\t}\n\tconvert_delimiter(*target_path, '\/');\n\tcifs_dbg(FYI, \"%s: target path: %s\\n\", __func__, *target_path);\n\n querty_exit:\n\tcifs_dbg(FYI, \"query symlink rc %d\\n\", rc);\n\tkfree(utf16_path);\n\tSMB2_open_free(&rqst[0]);\n\tSMB2_ioctl_free(&rqst[1]);\n\tSMB2_close_free(&rqst[2]);\n\tfree_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);\n\tfree_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);\n\tfree_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);\n\treturn rc;\n}","target":0,"code_token_length":1684,"total_token_length":1920,"max_tokens_setting":2048}
+{"idx":301502,"func":"find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword)\n{\n    char_u\tuword[MAXWLEN];\t\t\/\/ \"fword\" in upper-case\n    int\t\tdepth;\n    idx_T\ttryidx;\n\n    \/\/ The following arrays are used at each depth in the tree.\n    idx_T\tarridx[MAXWLEN];\n    int\t\tround[MAXWLEN];\n    int\t\tfwordidx[MAXWLEN];\n    int\t\tuwordidx[MAXWLEN];\n    int\t\tkwordlen[MAXWLEN];\n\n    int\t\tflen, ulen;\n    int\t\tl;\n    int\t\tlen;\n    int\t\tc;\n    idx_T\tlo, hi, m;\n    char_u\t*p;\n    char_u\t*byts = slang->sl_kbyts;    \/\/ array with bytes of the words\n    idx_T\t*idxs = slang->sl_kidxs;    \/\/ array with indexes\n\n    if (byts == NULL)\n    {\n\t\/\/ array is empty: \"cannot happen\"\n\t*kword = NUL;\n\treturn;\n    }\n\n    \/\/ Make an all-cap version of \"fword\".\n    allcap_copy(fword, uword);\n\n    \/\/ Each character needs to be tried both case-folded and upper-case.\n    \/\/ All this gets very complicated if we keep in mind that changing case\n    \/\/ may change the byte length of a multi-byte character...\n    depth = 0;\n    arridx[0] = 0;\n    round[0] = 0;\n    fwordidx[0] = 0;\n    uwordidx[0] = 0;\n    kwordlen[0] = 0;\n    while (depth >= 0)\n    {\n\tif (fword[fwordidx[depth]] == NUL)\n\t{\n\t    \/\/ We are at the end of \"fword\".  If the tree allows a word to end\n\t    \/\/ here we have found a match.\n\t    if (byts[arridx[depth] + 1] == 0)\n\t    {\n\t\tkword[kwordlen[depth]] = NUL;\n\t\treturn;\n\t    }\n\n\t    \/\/ kword is getting too long, continue one level up\n\t    --depth;\n\t}\n\telse if (++round[depth] > 2)\n\t{\n\t    \/\/ tried both fold-case and upper-case character, continue one\n\t    \/\/ level up\n\t    --depth;\n\t}\n\telse\n\t{\n\t    \/\/ round[depth] == 1: Try using the folded-case character.\n\t    \/\/ round[depth] == 2: Try using the upper-case character.\n\t    if (has_mbyte)\n\t    {\n\t\tflen = MB_CPTR2LEN(fword + fwordidx[depth]);\n\t\tulen = MB_CPTR2LEN(uword + uwordidx[depth]);\n\t    }\n\t    else\n\t\tulen = flen = 1;\n\t    if (round[depth] == 1)\n\t    {\n\t\tp = fword + fwordidx[depth];\n\t\tl = flen;\n\t    }\n\t    else\n\t    {\n\t\tp = uword + uwordidx[depth];\n\t\tl = ulen;\n\t    }\n\n\t    for (tryidx = arridx[depth]; l > 0; --l)\n\t    {\n\t\t\/\/ Perform a binary search in the list of accepted bytes.\n\t\tlen = byts[tryidx++];\n\t\tc = *p++;\n\t\tlo = tryidx;\n\t\thi = tryidx + len - 1;\n\t\twhile (lo < hi)\n\t\t{\n\t\t    m = (lo + hi) \/ 2;\n\t\t    if (byts[m] > c)\n\t\t\thi = m - 1;\n\t\t    else if (byts[m] < c)\n\t\t\tlo = m + 1;\n\t\t    else\n\t\t    {\n\t\t\tlo = hi = m;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\n\t\t\/\/ Stop if there is no matching byte.\n\t\tif (hi < lo || byts[lo] != c)\n\t\t    break;\n\n\t\t\/\/ Continue at the child (if there is one).\n\t\ttryidx = idxs[lo];\n\t    }\n\n\t    if (l == 0)\n\t    {\n\t\t\/\/ Found the matching char.  Copy it to \"kword\" and go a\n\t\t\/\/ level deeper.\n\t\tif (round[depth] == 1)\n\t\t{\n\t\t    STRNCPY(kword + kwordlen[depth], fword + fwordidx[depth],\n\t\t\t\t\t\t\t\t\tflen);\n\t\t    kwordlen[depth + 1] = kwordlen[depth] + flen;\n\t\t}\n\t\telse\n\t\t{\n\t\t    STRNCPY(kword + kwordlen[depth], uword + uwordidx[depth],\n\t\t\t\t\t\t\t\t\tulen);\n\t\t    kwordlen[depth + 1] = kwordlen[depth] + ulen;\n\t\t}\n\t\tfwordidx[depth + 1] = fwordidx[depth] + flen;\n\t\tuwordidx[depth + 1] = uwordidx[depth] + ulen;\n\n\t\t++depth;\n\t\tarridx[depth] = tryidx;\n\t\tround[depth] = 0;\n\t    }\n\t}\n    }\n\n    \/\/ Didn't find it: \"cannot happen\".\n    *kword = NUL;\n}","target":0,"code_token_length":1123,"total_token_length":1359,"max_tokens_setting":2048}
+{"idx":463219,"func":"static void init_annotation_definitions(void)\n{\n    char *p;\n    char aline[ANNOT_DEF_MAXLINELEN];\n    annotate_entrydesc_t *ae;\n    int i;\n    FILE* f;\n    struct parse_state state;\n    ptrarray_t *entries = NULL;\n\n    \/* copy static entries into list *\/\n    for (i = 0 ; server_builtin_entries[i].name ; i++)\n        ptrarray_append(&server_entries, (void *)&server_builtin_entries[i]);\n\n    \/* copy static entries into list *\/\n    for (i = 0 ; mailbox_builtin_entries[i].name ; i++)\n        ptrarray_append(&mailbox_entries, (void *)&mailbox_builtin_entries[i]);\n\n    \/* copy static entries into list *\/\n    for (i = 0 ; message_builtin_entries[i].name ; i++)\n        ptrarray_append(&message_entries, (void *)&message_builtin_entries[i]);\n\n    memset(&state, 0, sizeof(state));\n\n    \/* parse config file *\/\n    state.filename = config_getstring(IMAPOPT_ANNOTATION_DEFINITIONS);\n\n    if (!state.filename)\n        return;\n\n    f = fopen(state.filename,\"r\");\n    if (!f) {\n        syslog(LOG_ERR, \"%s: could not open annotation definition file: %m\",\n               state.filename);\n        return;\n    }\n\n    while (fgets(aline, sizeof(aline), f)) {\n        \/* remove leading space, skip blank lines and comments *\/\n        state.lineno++;\n        for (p = aline; *p && isspace(*p); p++);\n        if (!*p || *p == '#') continue;\n        tok_initm(&state.tok, aline, \",\", TOK_TRIMLEFT|TOK_TRIMRIGHT|TOK_EMPTY);\n\n        \/* note, we only do the most basic validity checking and may\n           be more restrictive than necessary *\/\n\n        ae = xzmalloc(sizeof(*ae));\n\n        if (!(p = get_token(&state, \".-_\/:\"))) goto bad;\n        \/* TV-TODO: should test for empty *\/\n\n        if (!strncmp(p, IMAP_ANNOT_NS, strlen(IMAP_ANNOT_NS))) {\n            parse_error(&state, \"annotation under \" IMAP_ANNOT_NS);\n            goto bad;\n        }\n        ae->name = xstrdup(p);\n\n        if (!(p = get_token(&state, \".-_\/\"))) goto bad;\n        switch (table_lookup(annotation_scope_names, p)) {\n        case ANNOTATION_SCOPE_SERVER:\n            entries = &server_entries;\n            break;\n        case ANNOTATION_SCOPE_MAILBOX:\n            entries = &mailbox_entries;\n            break;\n        case ANNOTATION_SCOPE_MESSAGE:\n            if (!strncmp(ae->name, \"\/flags\/\", 7)) {\n                \/* RFC5257 reserves the \/flags\/ hierarchy for future use *\/\n                state.context = ae->name;\n                parse_error(&state, \"message entry under \/flags\/\");\n                goto bad;\n            }\n            entries = &message_entries;\n            break;\n        case -1:\n            parse_error(&state, \"invalid annotation scope\");\n            goto bad;\n        }\n\n        if (!(p = get_token(&state, NULL))) goto bad;\n        i = table_lookup(attribute_type_names, p);\n        if (i < 0) {\n            parse_error(&state, \"invalid annotation type\");\n            goto bad;\n        }\n        ae->type = i;\n\n        i = parse_table_lookup_bitmask(annotation_proxy_type_names, &state);\n        if (i < 0) {\n            parse_error(&state, \"invalid annotation proxy type\");\n            goto bad;\n        }\n        ae->proxytype = i;\n\n        i = parse_table_lookup_bitmask(annotation_attributes, &state);\n        if (i < 0) {\n            parse_error(&state, \"invalid annotation attributes\");\n            goto bad;\n        }\n        ae->attribs = normalise_attribs(&state, i);\n\n        if (!(p = get_token(&state, NULL))) goto bad;\n        cyrus_acl_strtomask(p, &ae->extra_rights);\n        \/* XXX and if strtomask fails? *\/\n\n        p = tok_next(&state.tok);\n        if (p) {\n            parse_error(&state, \"junk at end of line\");\n            goto bad;\n        }\n\n        ae->get = annotation_get_fromdb;\n        ae->set = annotation_set_todb;\n        ae->rock = NULL;\n        ptrarray_append(entries, ae);\n        continue;\n\nbad:\n        free((char *)ae->name);\n        free(ae);\n        tok_fini(&state.tok);\n        continue;\n    }\n\n\n#if 0\n\/* Suppress the syslog message to fix the unit tests, but have the\n * syslog message to aid the admin ...\n *\/\n    if (state.nerrors)\n        syslog(LOG_ERR, \"%s: encountered %u errors.  Struggling on, but \"\n                        \"some of your annotation definitions may be \"\n                        \"ignored.  Please fix this file!\",\n                        state.filename, state.nerrors);\n#endif\n\n    fclose(f);\n}","target":0,"code_token_length":1031,"total_token_length":1267,"max_tokens_setting":2048}
+{"idx":447231,"func":"apprentice_load(struct magic_set *ms, const char *fn, int action)\n{\n\tint errs = 0;\n\tuint32_t i, j;\n\tsize_t files = 0, maxfiles = 0;\n\tchar **filearr = NULL;\n\tstruct stat st;\n\tstruct magic_map *map;\n\tstruct magic_entry_set mset[MAGIC_SETS];\n\tphp_stream *dir;\n\tphp_stream_dirent d;\n \n\tTSRMLS_FETCH();\n\n\tmemset(mset, 0, sizeof(mset));\n\tms->flags |= MAGIC_CHECK;\t\/* Enable checks for parsed files *\/\n\n\n\tif ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL)\n\t{\n\t\tfile_oomem(ms, sizeof(*map));\n\t\treturn NULL;\n\t}\n\n\t\/* print silly verbose header for USG compat. *\/\n\tif (action == FILE_CHECK)\n\t\t(void)fprintf(stderr, \"%s\\n\", usg_hdr);\n\n\t\/* load directory or file *\/\n\t\/* FIXME: Read file names and sort them to prevent\n\t   non-determinism. See Debian bug #488562. *\/\n\tif (php_sys_stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {\n\t\tint mflen;\n\t\tchar mfn[MAXPATHLEN];\n\n\t\tdir = php_stream_opendir((char *)fn, REPORT_ERRORS, NULL);\n\t\tif (!dir) {\n\t\t\terrs++;\n\t\t\tgoto out;\n\t\t}\n\t\twhile (php_stream_readdir(dir, &d)) {\n\t\t\tif ((mflen = snprintf(mfn, sizeof(mfn), \"%s\/%s\", fn, d.d_name)) < 0) {\n\t\t\t\tfile_oomem(ms,\n\t\t\t\tstrlen(fn) + strlen(d.d_name) + 2);\n\t\t\t\terrs++;\n\t\t\t\tphp_stream_closedir(dir);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tif (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (files >= maxfiles) {\n\t\t\t\tsize_t mlen;\n\t\t\t\tmaxfiles = (maxfiles + 1) * 2;\n\t\t\t\tmlen = maxfiles * sizeof(*filearr);\n\t\t\t\tif ((filearr = CAST(char **,\n\t\t\t\t    erealloc(filearr, mlen))) == NULL) {\n\t\t\t\t\tfile_oomem(ms, mlen);\n\t\t\t\t\tphp_stream_closedir(dir);\n\t\t\t\t\terrs++;\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfilearr[files++] = estrndup(mfn, (mflen > sizeof(mfn) - 1)? sizeof(mfn) - 1: mflen);\n\t\t}\n\t\tphp_stream_closedir(dir);\n\t\tqsort(filearr, files, sizeof(*filearr), cmpstrp);\n\t\tfor (i = 0; i < files; i++) {\n\t\t\tload_1(ms, action, filearr[i], &errs, mset);\n\t\t\tefree(filearr[i]);\n\t\t}\n\t\tefree(filearr);\n\t} else\n\t\tload_1(ms, action, fn, &errs, mset);\n\tif (errs)\n\t\tgoto out;\n\n\tfor (j = 0; j < MAGIC_SETS; j++) {\n\t\t\/* Set types of tests *\/\n\t\tfor (i = 0; i < mset[j].count; ) {\n\t\t\tif (mset[j].me[i].mp->cont_level != 0) {\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ti = set_text_binary(ms, mset[j].me, mset[j].count, i);\n\t\t}\n\t\tqsort(mset[j].me, mset[j].count, sizeof(*mset[j].me),\n\t\t    apprentice_sort);\n\n\t\t\/*\n\t\t * Make sure that any level 0 \"default\" line is last\n\t\t * (if one exists).\n\t\t *\/\n\t\tset_last_default(ms, mset[j].me, mset[j].count);\n\n\t\t\/* coalesce per file arrays into a single one *\/\n\t\tif (coalesce_entries(ms, mset[j].me, mset[j].count,\n\t\t    &map->magic[j], &map->nmagic[j]) == -1) {\n\t\t\terrs++;\n\t\t\tgoto out;\n\t\t}\n\t}\n\nout:\n\tfor (j = 0; j < MAGIC_SETS; j++)\n\t\tmagic_entry_free(mset[j].me, mset[j].count);\n\n\tif (errs) {\n\t\tfor (j = 0; j < MAGIC_SETS; j++) {\n\t\t\tif (map->magic[j])\n\t\t\t\tefree(map->magic[j]);\n\t\t}\n\t\tefree(map);\n\t\treturn NULL;\n\t}\n\treturn map;\n}","target":0,"code_token_length":981,"total_token_length":1217,"max_tokens_setting":2048}
+{"idx":513333,"func":"static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,\n                                             COND *cond,\n                                             COND_EQUAL *cond_equal,\n                                             void *table_join_idx)\n{\n  Item_equal *item_equal;\n  COND *org_cond= cond;                 \/\/ Return this in case of fatal error\n\n  if (cond->type() == Item::COND_ITEM)\n  {\n    List<Item> *cond_list= ((Item_cond*) cond)->argument_list();\n\n    bool and_level= ((Item_cond*) cond)->functype() ==\n                      Item_func::COND_AND_FUNC;\n    if (and_level)\n    {\n      cond_equal= &((Item_cond_and *) cond)->m_cond_equal;\n      cond_list->disjoin((List<Item> *) &cond_equal->current_level);\/* remove Item_equal objects from the AND. *\/\n\n      List_iterator_fast<Item_equal> it(cond_equal->current_level);      \n      while ((item_equal= it++))\n      {\n        item_equal->sort(&compare_fields_by_table_order, table_join_idx);\n      }\n    }\n    \n    List_iterator<Item> li(*cond_list);\n    Item *item;\n    while ((item= li++))\n    {\n      Item *new_item= substitute_for_best_equal_field(thd, context_tab,\n                                                      item, cond_equal,\n                                                      table_join_idx);\n      \/*\n        This works OK with PS\/SP re-execution as changes are made to\n        the arguments of AND\/OR items only\n      *\/\n      if (new_item != item)\n        li.replace(new_item);\n    }\n\n    if (and_level)\n    {\n      COND *eq_cond= 0;\n      List_iterator_fast<Item_equal> it(cond_equal->current_level);\n      bool false_eq_cond= FALSE;\n      while ((item_equal= it++))\n      {\n        eq_cond= eliminate_item_equal(thd, eq_cond, cond_equal->upper_levels,\n                                      item_equal);\n        if (!eq_cond)\n\t{\n          eq_cond= 0;\n          break;\n        }\n        else if (eq_cond->type() == Item::INT_ITEM && !eq_cond->val_bool()) \n\t{\n          \/*\n            This occurs when eliminate_item_equal() founds that cond is\n            always false and substitutes it with Item_int 0.\n            Due to this, value of item_equal will be 0, so just return it.\n\t  *\/\n          cond= eq_cond;\n          false_eq_cond= TRUE;\n          break;\n        }\n      }\n      if (eq_cond && !false_eq_cond)\n      {\n        \/* Insert the generated equalities before all other conditions *\/\n        if (eq_cond->type() == Item::COND_ITEM)\n          ((Item_cond *) cond)->add_at_head(\n                                  ((Item_cond *) eq_cond)->argument_list());\n        else\n\t{\n          if (cond_list->is_empty())\n            cond= eq_cond;\n          else\n\t  {\n             \/* Do not add an equality condition if it's always true *\/ \n             if (eq_cond->type() != Item::INT_ITEM &&\n                 cond_list->push_front(eq_cond, thd->mem_root))\n               eq_cond= 0;\n          }\n\t}\n      }\n      if (!eq_cond)\n      {\n        \/* \n          We are out of memory doing the transformation.\n          This is a fatal error now. However we bail out by returning the\n          original condition that we had before we started the transformation. \n\t*\/\n\tcond_list->append((List<Item> *) &cond_equal->current_level);\n      }\n    }\t \n  }\n  else if (cond->type() == Item::FUNC_ITEM && \n           ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)\n  {\n    item_equal= (Item_equal *) cond;\n    item_equal->sort(&compare_fields_by_table_order, table_join_idx);\n    cond_equal= item_equal->upper_levels;\n    if (cond_equal && cond_equal->current_level.head() == item_equal)\n      cond_equal= cond_equal->upper_levels;\n    cond= eliminate_item_equal(thd, 0, cond_equal, item_equal);\n    return cond ? cond : org_cond;\n  }\n  else \n  {\n    while (cond_equal)\n    {\n      List_iterator_fast<Item_equal> it(cond_equal->current_level);\n      while((item_equal= it++))\n      {\n        REPLACE_EQUAL_FIELD_ARG arg= {item_equal, context_tab};\n        cond= cond->transform(thd, &Item::replace_equal_field, (uchar *) &arg);\n      }\n      cond_equal= cond_equal->upper_levels;\n    }\n  }\n  return cond;\n}","target":0,"code_token_length":952,"total_token_length":1188,"max_tokens_setting":2048}
+{"idx":395071,"func":"text_to_screenline(win_T *wp, char_u *text, int col)\n{\n    int\t\toff = (int)(current_ScreenLine - ScreenLines);\n\n    if (has_mbyte)\n    {\n\tint\tcells;\n\tint\tu8c, u8cc[MAX_MCO];\n\tint\ti;\n\tint\tidx;\n\tint\tc_len;\n\tchar_u\t*p;\n# ifdef FEAT_ARABIC\n\tint\tprev_c = 0;\t\t\/\/ previous Arabic character\n\tint\tprev_c1 = 0;\t\t\/\/ first composing char for prev_c\n# endif\n\n# ifdef FEAT_RIGHTLEFT\n\tif (wp->w_p_rl)\n\t    idx = off;\n\telse\n# endif\n\t    idx = off + col;\n\n\t\/\/ Store multibyte characters in ScreenLines[] et al. correctly.\n\tfor (p = text; *p != NUL; )\n\t{\n\t    cells = (*mb_ptr2cells)(p);\n\t    c_len = (*mb_ptr2len)(p);\n\t    if (col + cells > wp->w_width\n# ifdef FEAT_RIGHTLEFT\n\t\t    - (wp->w_p_rl ? col : 0)\n# endif\n\t\t    )\n\t\tbreak;\n\t    ScreenLines[idx] = *p;\n\t    if (enc_utf8)\n\t    {\n\t\tu8c = utfc_ptr2char(p, u8cc);\n\t\tif (*p < 0x80 && u8cc[0] == 0)\n\t\t{\n\t\t    ScreenLinesUC[idx] = 0;\n#ifdef FEAT_ARABIC\n\t\t    prev_c = u8c;\n#endif\n\t\t}\n\t\telse\n\t\t{\n#ifdef FEAT_ARABIC\n\t\t    if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))\n\t\t    {\n\t\t\t\/\/ Do Arabic shaping.\n\t\t\tint\tpc, pc1, nc;\n\t\t\tint\tpcc[MAX_MCO];\n\t\t\tint\tfirstbyte = *p;\n\n\t\t\t\/\/ The idea of what is the previous and next\n\t\t\t\/\/ character depends on 'rightleft'.\n\t\t\tif (wp->w_p_rl)\n\t\t\t{\n\t\t\t    pc = prev_c;\n\t\t\t    pc1 = prev_c1;\n\t\t\t    nc = utf_ptr2char(p + c_len);\n\t\t\t    prev_c1 = u8cc[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    pc = utfc_ptr2char(p + c_len, pcc);\n\t\t\t    nc = prev_c;\n\t\t\t    pc1 = pcc[0];\n\t\t\t}\n\t\t\tprev_c = u8c;\n\n\t\t\tu8c = arabic_shape(u8c, &firstbyte, &u8cc[0],\n\t\t\t\t\t\t\t\t pc, pc1, nc);\n\t\t\tScreenLines[idx] = firstbyte;\n\t\t    }\n\t\t    else\n\t\t\tprev_c = u8c;\n#endif\n\t\t    \/\/ Non-BMP character: display as ? or fullwidth ?.\n\t\t    ScreenLinesUC[idx] = u8c;\n\t\t    for (i = 0; i < Screen_mco; ++i)\n\t\t    {\n\t\t\tScreenLinesC[i][idx] = u8cc[i];\n\t\t\tif (u8cc[i] == 0)\n\t\t\t    break;\n\t\t    }\n\t\t}\n\t\tif (cells > 1)\n\t\t    ScreenLines[idx + 1] = 0;\n\t    }\n\t    else if (enc_dbcs == DBCS_JPNU && *p == 0x8e)\n\t\t\/\/ double-byte single width character\n\t\tScreenLines2[idx] = p[1];\n\t    else if (cells > 1)\n\t\t\/\/ double-width character\n\t\tScreenLines[idx + 1] = p[1];\n\t    col += cells;\n\t    idx += cells;\n\t    p += c_len;\n\t}\n    }\n    else\n    {\n\tint len = (int)STRLEN(text);\n\n\tif (len > wp->w_width - col)\n\t    len = wp->w_width - col;\n\tif (len > 0)\n\t{\n#ifdef FEAT_RIGHTLEFT\n\t    if (wp->w_p_rl)\n\t\tmch_memmove(current_ScreenLine, text, len);\n\t    else\n#endif\n\t\tmch_memmove(current_ScreenLine + col, text, len);\n\t    col += len;\n\t}\n    }\n    return col;\n}","target":0,"code_token_length":885,"total_token_length":1121,"max_tokens_setting":2048}
+{"idx":200672,"func":"static void sdhci_do_adma(SDHCIState *s)\n{\n    unsigned int begin, length;\n    const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK;\n    ADMADescr dscr = {};\n    int i;\n\n    if (s->trnmod & SDHC_TRNS_BLK_CNT_EN && !s->blkcnt) {\n        \/* Stop Multiple Transfer *\/\n        sdhci_end_transfer(s);\n        return;\n    }\n\n    for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) {\n        s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH;\n\n        get_adma_description(s, &dscr);\n        trace_sdhci_adma_loop(dscr.addr, dscr.length, dscr.attr);\n\n        if ((dscr.attr & SDHC_ADMA_ATTR_VALID) == 0) {\n            \/* Indicate that error occurred in ST_FDS state *\/\n            s->admaerr &= ~SDHC_ADMAERR_STATE_MASK;\n            s->admaerr |= SDHC_ADMAERR_STATE_ST_FDS;\n\n            \/* Generate ADMA error interrupt *\/\n            if (s->errintstsen & SDHC_EISEN_ADMAERR) {\n                s->errintsts |= SDHC_EIS_ADMAERR;\n                s->norintsts |= SDHC_NIS_ERR;\n            }\n\n            sdhci_update_irq(s);\n            return;\n        }\n\n        length = dscr.length ? dscr.length : 64 * KiB;\n\n        switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) {\n        case SDHC_ADMA_ATTR_ACT_TRAN:  \/* data transfer *\/\n            if (s->trnmod & SDHC_TRNS_READ) {\n                while (length) {\n                    if (s->data_count == 0) {\n                        sdbus_read_data(&s->sdbus, s->fifo_buffer, block_size);\n                    }\n                    begin = s->data_count;\n                    if ((length + begin) < block_size) {\n                        s->data_count = length + begin;\n                        length = 0;\n                     } else {\n                        s->data_count = block_size;\n                        length -= block_size - begin;\n                    }\n                    dma_memory_write(s->dma_as, dscr.addr,\n                                     &s->fifo_buffer[begin],\n                                     s->data_count - begin);\n                    dscr.addr += s->data_count - begin;\n                    if (s->data_count == block_size) {\n                        s->data_count = 0;\n                        if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {\n                            s->blkcnt--;\n                            if (s->blkcnt == 0) {\n                                break;\n                            }\n                        }\n                    }\n                }\n            } else {\n                while (length) {\n                    begin = s->data_count;\n                    if ((length + begin) < block_size) {\n                        s->data_count = length + begin;\n                        length = 0;\n                     } else {\n                        s->data_count = block_size;\n                        length -= block_size - begin;\n                    }\n                    dma_memory_read(s->dma_as, dscr.addr,\n                                    &s->fifo_buffer[begin],\n                                    s->data_count - begin);\n                    dscr.addr += s->data_count - begin;\n                    if (s->data_count == block_size) {\n                        sdbus_write_data(&s->sdbus, s->fifo_buffer, block_size);\n                        s->data_count = 0;\n                        if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {\n                            s->blkcnt--;\n                            if (s->blkcnt == 0) {\n                                break;\n                            }\n                        }\n                    }\n                }\n            }\n            s->admasysaddr += dscr.incr;\n            break;\n        case SDHC_ADMA_ATTR_ACT_LINK:   \/* link to next descriptor table *\/\n            s->admasysaddr = dscr.addr;\n            trace_sdhci_adma(\"link\", s->admasysaddr);\n            break;\n        default:\n            s->admasysaddr += dscr.incr;\n            break;\n        }\n\n        if (dscr.attr & SDHC_ADMA_ATTR_INT) {\n            trace_sdhci_adma(\"interrupt\", s->admasysaddr);\n            if (s->norintstsen & SDHC_NISEN_DMA) {\n                s->norintsts |= SDHC_NIS_DMA;\n            }\n\n            if (sdhci_update_irq(s) && !(dscr.attr & SDHC_ADMA_ATTR_END)) {\n                \/* IRQ delivered, reschedule current transfer *\/\n                break;\n            }\n        }\n\n        \/* ADMA transfer terminates if blkcnt == 0 or by END attribute *\/\n        if (((s->trnmod & SDHC_TRNS_BLK_CNT_EN) &&\n                    (s->blkcnt == 0)) || (dscr.attr & SDHC_ADMA_ATTR_END)) {\n            trace_sdhci_adma_transfer_completed();\n            if (length || ((dscr.attr & SDHC_ADMA_ATTR_END) &&\n                (s->trnmod & SDHC_TRNS_BLK_CNT_EN) &&\n                s->blkcnt != 0)) {\n                trace_sdhci_error(\"SD\/MMC host ADMA length mismatch\");\n                s->admaerr |= SDHC_ADMAERR_LENGTH_MISMATCH |\n                        SDHC_ADMAERR_STATE_ST_TFR;\n                if (s->errintstsen & SDHC_EISEN_ADMAERR) {\n                    trace_sdhci_error(\"Set ADMA error flag\");\n                    s->errintsts |= SDHC_EIS_ADMAERR;\n                    s->norintsts |= SDHC_NIS_ERR;\n                }\n\n                sdhci_update_irq(s);\n            }\n            sdhci_end_transfer(s);\n            return;\n        }\n\n    }\n\n    \/* we have unfinished business - reschedule to continue ADMA *\/\n    timer_mod(s->transfer_timer,\n                   qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + SDHC_TRANSFER_DELAY);\n}","target":1,"code_token_length":1242,"total_token_length":1478,"max_tokens_setting":2048}
+{"idx":234241,"func":"display_debug_pubnames_worker (struct dwarf_section *section,\n\t\t\t       void *file ATTRIBUTE_UNUSED,\n\t\t\t       int is_gnu)\n{\n  DWARF2_Internal_PubNames names;\n  unsigned char *start = section->start;\n  unsigned char *end = start + section->size;\n\n  \/* It does not matter if this load fails,\n     we test for that later on.  *\/\n  load_debug_info (file);\n\n  introduce (section, false);\n\n  while (start < end)\n    {\n      unsigned char *data;\n      unsigned long sec_off = start - section->start;\n      unsigned int offset_size;\n\n      SAFE_BYTE_GET_AND_INC (names.pn_length, start, 4, end);\n      if (names.pn_length == 0xffffffff)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (names.pn_length, start, 8, end);\n\t  offset_size = 8;\n\t}\n      else\n\toffset_size = 4;\n\n      if (names.pn_length > (size_t) (end - start))\n\t{\n\t  warn (_(\"Debug info is corrupted, %s header at %#lx has length %s\\n\"),\n\t\tsection->name,\n\t\tsec_off,\n\t\tdwarf_vmatoa (\"x\", names.pn_length));\n\t  break;\n\t}\n\n      data = start;\n      start += names.pn_length;\n\n      SAFE_BYTE_GET_AND_INC (names.pn_version, data, 2, start);\n      SAFE_BYTE_GET_AND_INC (names.pn_offset, data, offset_size, start);\n\n      if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE\n\t  && num_debug_info_entries > 0\n\t  && find_debug_info_for_offset (names.pn_offset) == NULL)\n\twarn (_(\".debug_info offset of 0x%lx in %s section does not point to a CU header.\\n\"),\n\t      (unsigned long) names.pn_offset, section->name);\n\n      SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, start);\n\n      printf (_(\"  Length:                              %ld\\n\"),\n\t      (long) names.pn_length);\n      printf (_(\"  Version:                             %d\\n\"),\n\t      names.pn_version);\n      printf (_(\"  Offset into .debug_info section:     0x%lx\\n\"),\n\t      (unsigned long) names.pn_offset);\n      printf (_(\"  Size of area in .debug_info section: %ld\\n\"),\n\t      (long) names.pn_size);\n\n      if (names.pn_version != 2 && names.pn_version != 3)\n\t{\n\t  static int warned = 0;\n\n\t  if (! warned)\n\t    {\n\t      warn (_(\"Only DWARF 2 and 3 pubnames are currently supported\\n\"));\n\t      warned = 1;\n\t    }\n\n\t  continue;\n\t}\n\n      if (is_gnu)\n\tprintf (_(\"\\n    Offset  Kind          Name\\n\"));\n      else\n\tprintf (_(\"\\n    Offset\\tName\\n\"));\n\n      while (1)\n\t{\n\t  bfd_size_type maxprint;\n\t  dwarf_vma offset;\n\n\t  SAFE_BYTE_GET_AND_INC (offset, data, offset_size, start);\n\n\t  if (offset == 0)\n\t    break;\n\n\t  if (data >= start)\n\t    break;\n\t  maxprint = (start - data) - 1;\n\n\t  if (is_gnu)\n\t    {\n\t      unsigned int kind_data;\n\t      gdb_index_symbol_kind kind;\n\t      const char *kind_name;\n\t      int is_static;\n\n\t      SAFE_BYTE_GET_AND_INC (kind_data, data, 1, start);\n\t      maxprint --;\n\t      \/* GCC computes the kind as the upper byte in the CU index\n\t\t word, and then right shifts it by the CU index size.\n\t\t Left shift KIND to where the gdb-index.h accessor macros\n\t\t can use it.  *\/\n\t      kind_data <<= GDB_INDEX_CU_BITSIZE;\n\t      kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data);\n\t      kind_name = get_gdb_index_symbol_kind_name (kind);\n\t      is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data);\n\t      printf (\"    %-6lx  %s,%-10s  %.*s\\n\",\n\t\t      (unsigned long) offset, is_static ? _(\"s\") : _(\"g\"),\n\t\t      kind_name, (int) maxprint, data);\n\t    }\n\t  else\n\t    printf (\"    %-6lx\\t%.*s\\n\",\n\t\t    (unsigned long) offset, (int) maxprint, data);\n\n\t  data += strnlen ((char *) data, maxprint);\n\t  if (data < start)\n\t    data++;\n\t  if (data >= start)\n\t    break;\n\t}\n    }\n\n  printf (\"\\n\");\n  return 1;\n}","target":0,"code_token_length":974,"total_token_length":1210,"max_tokens_setting":2048}
+{"idx":349278,"func":"static void squashfs_stat(char *source)\n{\n\ttime_t mkfs_time = (time_t) sBlk.s.mkfs_time;\n\tstruct tm *t = use_localtime ? localtime(&mkfs_time) :\n\t\t\t\t\tgmtime(&mkfs_time);\n\tchar *mkfs_str = asctime(t);\n\tlong long xattr_ids = read_xattr_ids();\n\n\tif(xattr_ids == -1)\n\t\tEXIT_UNSQUASH(\"File system corruption detected\\n\");\n\n\tprintf(\"Found a valid SQUASHFS 4:0 superblock on %s.\\n\", source);\n\tprintf(\"Creation or last append time %s\", mkfs_str ? mkfs_str :\n\t\t\"failed to get time\\n\");\n\tprintf(\"Filesystem size %llu bytes (%.2f Kbytes \/ %.2f Mbytes)\\n\",\n\t\tsBlk.s.bytes_used, sBlk.s.bytes_used \/ 1024.0,\n\t\tsBlk.s.bytes_used \/ (1024.0 * 1024.0));\n\tprintf(\"Compression %s\\n\", comp->name);\n\n\tif(SQUASHFS_COMP_OPTS(sBlk.s.flags)) {\n\t\tchar buffer[SQUASHFS_METADATA_SIZE] __attribute__ ((aligned));\n\t\tint bytes;\n\n\t\tif(!comp->supported)\n\t\t\tprintf(\"\\tCould not display compressor options, because\"\n\t\t\t\t\" %s compression is not supported\\n\",\n\t\t\t\tcomp->name);\n\t\telse {\n\t\t\tbytes = read_block(fd, sizeof(sBlk.s), NULL, 0, buffer);\n\t\t\tif(bytes == 0) {\n\t\t\t\tERROR(\"Failed to read compressor options\\n\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcompressor_display_options(comp, buffer, bytes);\n\t\t}\n\t}\n\n\tprintf(\"Block size %d\\n\", sBlk.s.block_size);\n\tprintf(\"Filesystem is %sexportable via NFS\\n\",\n\t\tSQUASHFS_EXPORTABLE(sBlk.s.flags) ? \"\" : \"not \");\n\tprintf(\"Inodes are %scompressed\\n\",\n\t\tSQUASHFS_UNCOMPRESSED_INODES(sBlk.s.flags) ? \"un\" : \"\");\n\tprintf(\"Data is %scompressed\\n\",\n\t\tSQUASHFS_UNCOMPRESSED_DATA(sBlk.s.flags) ? \"un\" : \"\");\n\tprintf(\"Uids\/Gids (Id table) are %scompressed\\n\",\n\t\tSQUASHFS_UNCOMPRESSED_INODES(sBlk.s.flags) ||\n\t\tSQUASHFS_UNCOMPRESSED_IDS(sBlk.s.flags) ? \"un\" : \"\");\n\n\tif(SQUASHFS_NO_FRAGMENTS(sBlk.s.flags))\n\t\tprintf(\"Fragments are not stored\\n\");\n\telse {\n\t\tprintf(\"Fragments are %scompressed\\n\",\n\t\t\tSQUASHFS_UNCOMPRESSED_FRAGMENTS(sBlk.s.flags) ?\n\t\t\t\"un\" : \"\");\n\t\tprintf(\"Always-use-fragments option is %sspecified\\n\",\n\t\t\tSQUASHFS_ALWAYS_FRAGMENTS(sBlk.s.flags) ? \"\" : \"not \");\n\t}\n\n\tif(SQUASHFS_NO_XATTRS(sBlk.s.flags))\n\t\tprintf(\"Xattrs are not stored\\n\");\n\telse\n\t\tprintf(\"Xattrs are %scompressed\\n\",\n\t\t\tSQUASHFS_UNCOMPRESSED_XATTRS(sBlk.s.flags) ?  \"un\" : \"\");\n\n\tprintf(\"Duplicates are %sremoved\\n\", SQUASHFS_DUPLICATES(sBlk.s.flags)\n\t\t\t? \"\" : \"not \");\n\tprintf(\"Number of fragments %u\\n\", sBlk.s.fragments);\n\tprintf(\"Number of inodes %u\\n\", sBlk.s.inodes);\n\tprintf(\"Number of ids %d\\n\", sBlk.s.no_ids);\n\n\tif(!SQUASHFS_NO_XATTRS(sBlk.s.flags))\n\t\tprintf(\"Number of xattr ids %lld\\n\", xattr_ids);\n\n\tTRACE(\"sBlk.s.inode_table_start 0x%llx\\n\", sBlk.s.inode_table_start);\n\tTRACE(\"sBlk.s.directory_table_start 0x%llx\\n\", sBlk.s.directory_table_start);\n\tTRACE(\"sBlk.s.fragment_table_start 0x%llx\\n\", sBlk.s.fragment_table_start);\n\tTRACE(\"sBlk.s.lookup_table_start 0x%llx\\n\", sBlk.s.lookup_table_start);\n\tTRACE(\"sBlk.s.id_table_start 0x%llx\\n\", sBlk.s.id_table_start);\n\tTRACE(\"sBlk.s.xattr_id_table_start 0x%llx\\n\", sBlk.s.xattr_id_table_start);\n}","target":0,"code_token_length":947,"total_token_length":1183,"max_tokens_setting":2048}
+{"idx":291770,"func":"static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc)\n{\n\tstruct rtrs_clt_con *con = to_clt_con(wc->qp->qp_context);\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\tu32 imm_type, imm_payload;\n\tbool w_inval = false;\n\tint err;\n\n\tif (wc->status != IB_WC_SUCCESS) {\n\t\tif (wc->status != IB_WC_WR_FLUSH_ERR) {\n\t\t\trtrs_err(clt_path->clt, \"RDMA failed: %s\\n\",\n\t\t\t\t  ib_wc_status_msg(wc->status));\n\t\t\trtrs_rdma_error_recovery(con);\n\t\t}\n\t\treturn;\n\t}\n\trtrs_clt_update_wc_stats(con);\n\n\tswitch (wc->opcode) {\n\tcase IB_WC_RECV_RDMA_WITH_IMM:\n\t\t\/*\n\t\t * post_recv() RDMA write completions of IO reqs (read\/write)\n\t\t * and hb\n\t\t *\/\n\t\tif (WARN_ON(wc->wr_cqe->done != rtrs_clt_rdma_done))\n\t\t\treturn;\n\t\trtrs_from_imm(be32_to_cpu(wc->ex.imm_data),\n\t\t\t       &imm_type, &imm_payload);\n\t\tif (imm_type == RTRS_IO_RSP_IMM ||\n\t\t    imm_type == RTRS_IO_RSP_W_INV_IMM) {\n\t\t\tu32 msg_id;\n\n\t\t\tw_inval = (imm_type == RTRS_IO_RSP_W_INV_IMM);\n\t\t\trtrs_from_io_rsp_imm(imm_payload, &msg_id, &err);\n\n\t\t\tprocess_io_rsp(clt_path, msg_id, err, w_inval);\n\t\t} else if (imm_type == RTRS_HB_MSG_IMM) {\n\t\t\tWARN_ON(con->c.cid);\n\t\t\trtrs_send_hb_ack(&clt_path->s);\n\t\t\tif (clt_path->flags & RTRS_MSG_NEW_RKEY_F)\n\t\t\t\treturn  rtrs_clt_recv_done(con, wc);\n\t\t} else if (imm_type == RTRS_HB_ACK_IMM) {\n\t\t\tWARN_ON(con->c.cid);\n\t\t\tclt_path->s.hb_missed_cnt = 0;\n\t\t\tclt_path->s.hb_cur_latency =\n\t\t\t\tktime_sub(ktime_get(), clt_path->s.hb_last_sent);\n\t\t\tif (clt_path->flags & RTRS_MSG_NEW_RKEY_F)\n\t\t\t\treturn  rtrs_clt_recv_done(con, wc);\n\t\t} else {\n\t\t\trtrs_wrn(con->c.path, \"Unknown IMM type %u\\n\",\n\t\t\t\t  imm_type);\n\t\t}\n\t\tif (w_inval)\n\t\t\t\/*\n\t\t\t * Post x2 empty WRs: first is for this RDMA with IMM,\n\t\t\t * second is for RECV with INV, which happened earlier.\n\t\t\t *\/\n\t\t\terr = rtrs_post_recv_empty_x2(&con->c, &io_comp_cqe);\n\t\telse\n\t\t\terr = rtrs_post_recv_empty(&con->c, &io_comp_cqe);\n\t\tif (err) {\n\t\t\trtrs_err(con->c.path, \"rtrs_post_recv_empty(): %d\\n\",\n\t\t\t\t  err);\n\t\t\trtrs_rdma_error_recovery(con);\n\t\t}\n\t\tbreak;\n\tcase IB_WC_RECV:\n\t\t\/*\n\t\t * Key invalidations from server side\n\t\t *\/\n\t\tWARN_ON(!(wc->wc_flags & IB_WC_WITH_INVALIDATE ||\n\t\t\t  wc->wc_flags & IB_WC_WITH_IMM));\n\t\tWARN_ON(wc->wr_cqe->done != rtrs_clt_rdma_done);\n\t\tif (clt_path->flags & RTRS_MSG_NEW_RKEY_F) {\n\t\t\tif (wc->wc_flags & IB_WC_WITH_INVALIDATE)\n\t\t\t\treturn  rtrs_clt_recv_done(con, wc);\n\n\t\t\treturn  rtrs_clt_rkey_rsp_done(con, wc);\n\t\t}\n\t\tbreak;\n\tcase IB_WC_RDMA_WRITE:\n\t\t\/*\n\t\t * post_send() RDMA write completions of IO reqs (read\/write)\n\t\t * and hb.\n\t\t *\/\n\t\tbreak;\n\n\tdefault:\n\t\trtrs_wrn(clt_path->clt, \"Unexpected WC type: %d\\n\", wc->opcode);\n\t\treturn;\n\t}\n}","target":0,"code_token_length":887,"total_token_length":1123,"max_tokens_setting":2048}
+{"idx":197262,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& a = ctx->input(0);\n    const Tensor& b = ctx->input(1);\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(a.shape()),\n                errors::InvalidArgument(\"a is not a matrix\"));\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(b.shape()),\n                errors::InvalidArgument(\"b is not a matrix\"));\n\n    const int m = transpose_a_ ? a.dim_size(1) : a.dim_size(0);\n    const int k = transpose_a_ ? a.dim_size(0) : a.dim_size(1);\n    const int n = transpose_b_ ? b.dim_size(0) : b.dim_size(1);\n    const int k2 = transpose_b_ ? b.dim_size(1) : b.dim_size(0);\n\n    OP_REQUIRES(ctx, k == k2,\n                errors::InvalidArgument(\n                    \"Matrix size incompatible: a: \", a.shape().DebugString(),\n                    \", b: \", b.shape().DebugString()));\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({m, n}), &output));\n\n    if (k == 0) {\n      \/\/ If the inner dimension k in the matrix multiplication is zero, we fill\n      \/\/ the output with zeros.\n      functor::SetZeroFunctor<CPUDevice, float> f;\n      f(ctx->eigen_device<CPUDevice>(), output->flat<float>());\n      return;\n    }\n\n    auto out = output->matrix<float>();\n\n    std::unique_ptr<Tensor> a_float;\n    std::unique_ptr<Tensor> b_float;\n    if (!a_is_sparse_ && !b_is_sparse_) {\n      auto left = &a;\n      auto right = &b;\n      \/\/ TODO(agarwal): multi-thread the conversions from bfloat16 to float.\n      if (std::is_same<TL, bfloat16>::value) {\n        a_float.reset(new Tensor(DT_FLOAT, a.shape()));\n        BFloat16ToFloat(a.flat<bfloat16>().data(),\n                        a_float->flat<float>().data(), a.NumElements());\n        left = a_float.get();\n      }\n      if (std::is_same<TR, bfloat16>::value) {\n        b_float.reset(new Tensor(DT_FLOAT, b.shape()));\n        BFloat16ToFloat(b.flat<bfloat16>().data(),\n                        b_float->flat<float>().data(), b.NumElements());\n        right = b_float.get();\n      }\n      Eigen::array<Eigen::IndexPair<Eigen::DenseIndex>, 1> dim_pair;\n      dim_pair[0].first = transpose_a_ ? 0 : 1;\n      dim_pair[0].second = transpose_b_ ? 1 : 0;\n\n      out.device(ctx->template eigen_device<CPUDevice>()) =\n          left->matrix<float>().contract(right->matrix<float>(), dim_pair);\n      return;\n    }\n\n    auto left = &a;\n    auto right = &b;\n    bool transpose_output = false;\n    bool transpose_a = transpose_a_;\n    bool transpose_b = transpose_b_;\n    if (!a_is_sparse_) {\n      \/\/ Swap the order of multiplications using the identity:\n      \/\/ A * B = (B' *  A')'.\n      std::swap(left, right);\n      std::swap(transpose_a, transpose_b);\n      transpose_a = !transpose_a;\n      transpose_b = !transpose_b;\n      transpose_output = !transpose_output;\n    }\n\n    std::unique_ptr<Tensor> right_tr;\n    if (transpose_b) {\n      \/\/ TODO(agarwal): avoid transposing the matrix here and directly handle\n      \/\/ transpose in CreateDenseSlices.\n      OP_REQUIRES(ctx, right->dim_size(0) != 0,\n                  errors::InvalidArgument(\"b has an entry 0 in it's shape.\"));\n      OP_REQUIRES(ctx, right->dim_size(1) != 0,\n                  errors::InvalidArgument(\"b has an entry 0 in it's shape.\"));\n      right_tr.reset(\n          new Tensor(right->dtype(),\n                     TensorShape({right->dim_size(1), right->dim_size(0)})));\n\n      const auto perm = dsizes_10();\n      if (transpose_output) {\n        right_tr->matrix<TL>().device(ctx->template eigen_device<CPUDevice>()) =\n            right->matrix<TL>().shuffle(perm);\n      } else {\n        right_tr->matrix<TR>().device(ctx->template eigen_device<CPUDevice>()) =\n            right->matrix<TR>().shuffle(perm);\n      }\n      right = right_tr.get();\n    }\n\n    if (transpose_output) {\n      DoMatMul<TR, TL>::Compute(&this->cache_tr_, left->matrix<TR>(),\n                                right->matrix<TL>(), transpose_a,\n                                ctx->device()->tensorflow_cpu_worker_threads(),\n                                transpose_output, &out);\n    } else {\n      DoMatMul<TL, TR>::Compute(&this->cache_nt_, left->matrix<TL>(),\n                                right->matrix<TR>(), transpose_a,\n                                ctx->device()->tensorflow_cpu_worker_threads(),\n                                transpose_output, &out);\n    }\n  }","target":1,"code_token_length":1094,"total_token_length":1330,"max_tokens_setting":2048}
+{"idx":345215,"func":"int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)\n{\n\tint err = 0, err1, i;\n\tstruct uni_pagedir *p, *q;\n\tstruct unipair *unilist, *plist;\n\n\tif (!ct)\n\t\treturn 0;\n\n\tunilist = vmemdup_user(list, ct * sizeof(struct unipair));\n\tif (IS_ERR(unilist))\n\t\treturn PTR_ERR(unilist);\n\n\tconsole_lock();\n\n\t\/* Save original vc_unipagdir_loc in case we allocate a new one *\/\n\tp = *vc->vc_uni_pagedir_loc;\n\n\tif (!p) {\n\t\terr = -EINVAL;\n\n\t\tgoto out_unlock;\n\t}\n\t\n\tif (p->refcount > 1) {\n\t\tint j, k;\n\t\tu16 **p1, *p2, l;\n\t\t\n\t\terr1 = con_do_clear_unimap(vc);\n\t\tif (err1) {\n\t\t\terr = err1;\n\t\t\tgoto out_unlock;\n\t\t}\n\t\t\n\t\t\/*\n\t\t * Since refcount was > 1, con_clear_unimap() allocated a\n\t\t * a new uni_pagedir for this vc.  Re: p != q\n\t\t *\/\n\t\tq = *vc->vc_uni_pagedir_loc;\n\n\t\t\/*\n\t\t * uni_pgdir is a 32*32*64 table with rows allocated\n\t\t * when its first entry is added.  The unicode value must\n\t\t * still be incremented for empty rows.  We are copying\n\t\t * entries from \"p\" (old) to \"q\" (new).\n\t\t *\/\n\t\tl = 0;\t\t\/* unicode value *\/\n\t\tfor (i = 0; i < 32; i++) {\n\t\tp1 = p->uni_pgdir[i];\n\t\tif (p1)\n\t\t\tfor (j = 0; j < 32; j++) {\n\t\t\tp2 = p1[j];\n\t\t\tif (p2) {\n\t\t\t\tfor (k = 0; k < 64; k++, l++)\n\t\t\t\tif (p2[k] != 0xffff) {\n\t\t\t\t\t\/*\n\t\t\t\t\t * Found one, copy entry for unicode\n\t\t\t\t\t * l with fontpos value p2[k].\n\t\t\t\t\t *\/\n\t\t\t\t\terr1 = con_insert_unipair(q, l, p2[k]);\n\t\t\t\t\tif (err1) {\n\t\t\t\t\t\tp->refcount++;\n\t\t\t\t\t\t*vc->vc_uni_pagedir_loc = p;\n\t\t\t\t\t\tcon_release_unimap(q);\n\t\t\t\t\t\tkfree(q);\n\t\t\t\t\t\terr = err1;\n\t\t\t\t\t\tgoto out_unlock;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t\/* Account for row of 64 empty entries *\/\n\t\t\t\tl += 64;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\t\/* Account for empty table *\/\n\t\t\tl += 32 * 64;\n\t\t}\n\n\t\t\/*\n\t\t * Finished copying font table, set vc_uni_pagedir to new table\n\t\t *\/\n\t\tp = q;\n\t} else if (p == dflt) {\n\t\tdflt = NULL;\n\t}\n\n\t\/*\n\t * Insert user specified unicode pairs into new table.\n\t *\/\n\tfor (plist = unilist; ct; ct--, plist++) {\n\t\terr1 = con_insert_unipair(p, plist->unicode, plist->fontpos);\n\t\tif (err1)\n\t\t\terr = err1;\n\t}\n\t\n\t\/*\n\t * Merge with fontmaps of any other virtual consoles.\n\t *\/\n\tif (con_unify_unimap(vc, p))\n\t\tgoto out_unlock;\n\n\tfor (i = 0; i <= 3; i++)\n\t\tset_inverse_transl(vc, p, i); \/* Update inverse translations *\/\n\tset_inverse_trans_unicode(vc, p);\n\nout_unlock:\n\tconsole_unlock();\n\tkvfree(unilist);\n\treturn err;\n}","target":0,"code_token_length":810,"total_token_length":1046,"max_tokens_setting":2048}
+{"idx":230628,"func":"void get_merge_candidate_list_without_step_9(base_context* ctx,\n                                             const slice_segment_header* shdr,\n                                             const MotionVectorAccess& mvaccess,\n                                             de265_image* img,\n                                             int xC,int yC, int xP,int yP,\n                                             int nCS, int nPbW,int nPbH, int partIdx,\n                                             int max_merge_idx,\n                                             PBMotion* mergeCandList)\n{\n\n  \/\/int xOrigP = xP;\n  \/\/int yOrigP = yP;\n  int nOrigPbW = nPbW;\n  int nOrigPbH = nPbH;\n\n  int singleMCLFlag; \/\/ single merge-candidate-list (MCL) flag\n\n  \/* Use single MCL for CBs of size 8x8, except when parallel-merge-level is at 4x4.\n     Without this flag, PBs smaller than 8x8 would not receive as much merging candidates.\n     Having additional candidates might have these advantages:\n     - coding MVs for these small PBs is expensive, and\n     - since the PBs are not far away from a proper (neighboring) merging candidate,\n     the quality of the candidates will still be good.\n  *\/\n  singleMCLFlag = (img->get_pps().log2_parallel_merge_level > 2 && nCS==8);\n\n  if (singleMCLFlag) {\n    xP=xC;\n    yP=yC;\n    nPbW=nCS;\n    nPbH=nCS;\n    partIdx=0;\n  }\n\n  int maxCandidates = max_merge_idx+1;\n  \/\/MotionVectorSpec mergeCandList[5];\n  int numMergeCand=0;\n\n  \/\/ --- spatial merge candidates\n\n  numMergeCand = derive_spatial_merging_candidates(mvaccess,\n                                                   img, xC,yC, nCS, xP,yP, singleMCLFlag,\n                                                   nPbW,nPbH,partIdx, mergeCandList,\n                                                   maxCandidates);\n\n  \/\/ --- collocated merge candidate\n  if (numMergeCand < maxCandidates) {\n    int refIdxCol[2] = { 0,0 };\n\n    MotionVector mvCol[2];\n    uint8_t predFlagLCol[2];\n    derive_temporal_luma_vector_prediction(ctx,img,shdr, xP,yP,nPbW,nPbH,\n                                           refIdxCol[0],0, &mvCol[0],\n                                           &predFlagLCol[0]);\n\n    uint8_t availableFlagCol = predFlagLCol[0];\n    predFlagLCol[1] = 0;\n\n    if (shdr->slice_type == SLICE_TYPE_B) {\n      derive_temporal_luma_vector_prediction(ctx,img,shdr,\n                                             xP,yP,nPbW,nPbH, refIdxCol[1],1, &mvCol[1],\n                                             &predFlagLCol[1]);\n      availableFlagCol |= predFlagLCol[1];\n    }\n\n\n    if (availableFlagCol) {\n      PBMotion* colVec = &mergeCandList[numMergeCand++];\n\n      colVec->mv[0] = mvCol[0];\n      colVec->mv[1] = mvCol[1];\n      colVec->predFlag[0] = predFlagLCol[0];\n      colVec->predFlag[1] = predFlagLCol[1];\n      colVec->refIdx[0] = refIdxCol[0];\n      colVec->refIdx[1] = refIdxCol[1];\n    }\n  }\n\n\n  \/\/ --- bipredictive merge candidates ---\n\n  if (shdr->slice_type == SLICE_TYPE_B) {\n    derive_combined_bipredictive_merging_candidates(ctx, shdr,\n                                                    mergeCandList, &numMergeCand, maxCandidates);\n  }\n\n\n  \/\/ --- zero-vector merge candidates ---\n\n  derive_zero_motion_vector_candidates(shdr, mergeCandList, &numMergeCand, maxCandidates);\n\n\n  logtrace(LogMotion,\"mergeCandList:\\n\");\n  for (int i=0;i<shdr->MaxNumMergeCand;i++)\n    {\n      \/\/logtrace(LogMotion, \" %d:%s\\n\", i, i==merge_idx ? \" SELECTED\":\"\");\n      logmvcand(mergeCandList[i]);\n    }\n}","target":0,"code_token_length":936,"total_token_length":1172,"max_tokens_setting":2048}
+{"idx":210570,"func":"static RCoreSymCacheElement *parseDragons(RBinFile *bf, RBuffer *buf, int off, int bits, R_OWN char *file_name) {\n\tD eprintf (\"Dragons at 0x%x\\n\", off);\n\tut64 size = r_buf_size (buf);\n\tif (off >= size) {\n\t\treturn NULL;\n\t}\n\tsize -= off;\n\tif (!size) {\n\t\treturn NULL;\n\t}\n\tut8 *b = malloc (size);\n\tif (!b) {\n\t\treturn NULL;\n\t}\n\tint available = r_buf_read_at (buf, off, b, size);\n\tif (available != size) {\n\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\treturn NULL;\n\t}\n#if 0\n\t\/\/ after the list of sections, there's a bunch of unknown\n\t\/\/ data, brobably dwords, and then the same section list again\n\t\/\/ this function aims to parse it.\n\t0x00000138 |1a2b b2a1 0300 0000 1a2b b2a1 e055 0000| .+.......+...U..\n                         n_segments ----.          .--- how many sections ?\n\t0x00000148 |0100 0000 ca55 0000 0400 0000 1800 0000| .....U..........\n\t             .---- how many symbols? 0xc7\n\t0x00000158 |c700 0000 0000 0000 0000 0000 0104 0000| ................\n\t0x00000168 |250b e803 0000 0100 0000 0000 bd55 0000| %............U..\n\t0x00000178 |91bb e903 e35a b42c 93a4 340a 8746 9489| .....Z.,..4..F..\n\t0x00000188 |0cea 4c40 0c00 0000 0900 0000 0000 0000| ..L@............\n\t0x00000198 |0000 0000 0000 0000 0000 0000 0000 0000| ................\n\t0x000001a8 |0080 0000 0000 0000 5f5f 5445 5854 0000| ........__TEXT..\n\t0x000001b8 |0000 0000 0000 0000 0080 0000 0000 0000| ................\n\t0x000001c8 |0040 0000 0000 0000 5f5f 4441 5441 0000| .@......__DATA..\n\t0x000001d8 |0000 0000 0000 0000 00c0 0000 0000 0000| ................\n\t0x000001e8 |0000 0100 0000 0000 5f5f 4c4c 564d 0000| ........__LLVM..\n\t0x000001f8 |0000 0000 0000 0000 00c0 0100 0000 0000| ................\n\t0x00000208 |00c0 0000 0000 0000 5f5f 4c49 4e4b 4544| ........__LINKED\n\t0x00000218 |4954 0000 0000 0000 0000 0000 d069 0000| IT...........i..\n#endif\n\t\/\/ eprintf (\"Dragon's magic:\\n\");\n\tint magicCombo = 0;\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { \/\/ 0x130  ?\n\t\tmagicCombo++;\n\t}\n\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b + 8, 4)) {\n\t\tmagicCombo++;\n\t}\n\tif (magicCombo != 2) {\n\t\t\/\/ hack for C22F7494\n\t\tavailable = r_buf_read_at (buf, off - 8, b, size);\n\t\tif (available != size) {\n\t\t\teprintf (\"Warning: r_buf_read_at failed\\n\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (!memcmp (\"\\x1a\\x2b\\xb2\\xa1\", b, 4)) { \/\/ 0x130  ?\n\t\t\toff -= 8;\n\t\t} else {\n\t\t\teprintf (\"0x%08x  parsing error: invalid magic retry\\n\", off);\n\t\t}\n\t}\n\tD eprintf (\"0x%08x  magic  OK\\n\", off);\n\tD {\n\t\tconst int e0ss = r_read_le32 (b + 12);\n\t\teprintf (\"0x%08x  eoss   0x%x\\n\", off + 12, e0ss);\n\t}\n\tfree (b);\n\treturn r_coresym_cache_element_new (bf, buf, off + 16, bits, file_name);\n}","target":1,"code_token_length":1380,"total_token_length":1616,"max_tokens_setting":2048}
+{"idx":477249,"func":"current_block(\n    oparg_T\t*oap,\n    long\tcount,\n    int\t\tinclude,\t\/\/ TRUE == include white space\n    int\t\twhat,\t\t\/\/ '(', '{', etc.\n    int\t\tother)\t\t\/\/ ')', '}', etc.\n{\n    pos_T\told_pos;\n    pos_T\t*pos = NULL;\n    pos_T\tstart_pos;\n    pos_T\t*end_pos;\n    pos_T\told_start, old_end;\n    char_u\t*save_cpo;\n    int\t\tsol = FALSE;\t\t\/\/ '{' at start of line\n\n    old_pos = curwin->w_cursor;\n    old_end = curwin->w_cursor;\t\t\/\/ remember where we started\n    old_start = old_end;\n\n    \/*\n     * If we start on '(', '{', ')', '}', etc., use the whole block inclusive.\n     *\/\n    if (!VIsual_active || EQUAL_POS(VIsual, curwin->w_cursor))\n    {\n\tsetpcmark();\n\tif (what == '{')\t\t\/\/ ignore indent\n\t    while (inindent(1))\n\t\tif (inc_cursor() != 0)\n\t\t    break;\n\tif (gchar_cursor() == what)\n\t    \/\/ cursor on '(' or '{', move cursor just after it\n\t    ++curwin->w_cursor.col;\n    }\n    else if (LT_POS(VIsual, curwin->w_cursor))\n    {\n\told_start = VIsual;\n\tcurwin->w_cursor = VIsual;\t    \/\/ cursor at low end of Visual\n    }\n    else\n\told_end = VIsual;\n\n    \/*\n     * Search backwards for unclosed '(', '{', etc..\n     * Put this position in start_pos.\n     * Ignore quotes here.  Keep the \"M\" flag in 'cpo', as that is what the\n     * user wants.\n     *\/\n    save_cpo = p_cpo;\n    p_cpo = (char_u *)(vim_strchr(p_cpo, CPO_MATCHBSL) != NULL ? \"%M\" : \"%\");\n    if ((pos = findmatch(NULL, what)) != NULL)\n    {\n\twhile (count-- > 0)\n\t{\n\t    if ((pos = findmatch(NULL, what)) == NULL)\n\t\tbreak;\n\t    curwin->w_cursor = *pos;\n\t    start_pos = *pos;   \/\/ the findmatch for end_pos will overwrite *pos\n\t}\n    }\n    else\n    {\n\twhile (count-- > 0)\n\t{\n\t    if ((pos = findmatchlimit(NULL, what, FM_FORWARD, 0)) == NULL)\n\t\tbreak;\n\t    curwin->w_cursor = *pos;\n\t    start_pos = *pos;   \/\/ the findmatch for end_pos will overwrite *pos\n\t}\n    }\n    p_cpo = save_cpo;\n\n    \/*\n     * Search for matching ')', '}', etc.\n     * Put this position in curwin->w_cursor.\n     *\/\n    if (pos == NULL || (end_pos = findmatch(NULL, other)) == NULL)\n    {\n\tcurwin->w_cursor = old_pos;\n\treturn FAIL;\n    }\n    curwin->w_cursor = *end_pos;\n\n    \/*\n     * Try to exclude the '(', '{', ')', '}', etc. when \"include\" is FALSE.\n     * If the ending '}', ')' or ']' is only preceded by indent, skip that\n     * indent.  But only if the resulting area is not smaller than what we\n     * started with.\n     *\/\n    while (!include)\n    {\n\tincl(&start_pos);\n\tsol = (curwin->w_cursor.col == 0);\n\tdecl(&curwin->w_cursor);\n\twhile (inindent(1))\n\t{\n\t    sol = TRUE;\n\t    if (decl(&curwin->w_cursor) != 0)\n\t\tbreak;\n\t}\n\n\t\/*\n\t * In Visual mode, when the resulting area is not bigger than what we\n\t * started with, extend it to the next block, and then exclude again.\n\t *\/\n\tif (!LT_POS(start_pos, old_start) && !LT_POS(old_end, curwin->w_cursor)\n\t\t&& VIsual_active)\n\t{\n\t    curwin->w_cursor = old_start;\n\t    decl(&curwin->w_cursor);\n\t    if ((pos = findmatch(NULL, what)) == NULL)\n\t    {\n\t\tcurwin->w_cursor = old_pos;\n\t\treturn FAIL;\n\t    }\n\t    start_pos = *pos;\n\t    curwin->w_cursor = *pos;\n\t    if ((end_pos = findmatch(NULL, other)) == NULL)\n\t    {\n\t\tcurwin->w_cursor = old_pos;\n\t\treturn FAIL;\n\t    }\n\t    curwin->w_cursor = *end_pos;\n\t}\n\telse\n\t    break;\n    }\n\n    if (VIsual_active)\n    {\n\tif (*p_sel == 'e')\n\t    inc(&curwin->w_cursor);\n\tif (sol && gchar_cursor() != NUL)\n\t    inc(&curwin->w_cursor);\t\/\/ include the line break\n\tVIsual = start_pos;\n\tVIsual_mode = 'v';\n\tredraw_curbuf_later(INVERTED);\t\/\/ update the inversion\n\tshowmode();\n    }\n    else\n    {\n\toap->start = start_pos;\n\toap->motion_type = MCHAR;\n\toap->inclusive = FALSE;\n\tif (sol)\n\t    incl(&curwin->w_cursor);\n\telse if (LTOREQ_POS(start_pos, curwin->w_cursor))\n\t    \/\/ Include the character under the cursor.\n\t    oap->inclusive = TRUE;\n\telse\n\t    \/\/ End is before the start (no text in between <>, [], etc.): don't\n\t    \/\/ operate on any text.\n\t    curwin->w_cursor = start_pos;\n    }\n\n    return OK;\n}","target":0,"code_token_length":1208,"total_token_length":1444,"max_tokens_setting":2048}
+{"idx":301493,"func":"add_sound_suggest(\n    suginfo_T\t*su,\n    char_u\t*goodword,\n    int\t\tscore,\t\t\/\/ soundfold score\n    langp_T\t*lp)\n{\n    slang_T\t*slang = lp->lp_slang;\t\/\/ language for sound folding\n    int\t\tsfwordnr;\n    char_u\t*nrline;\n    int\t\torgnr;\n    char_u\ttheword[MAXWLEN];\n    int\t\ti;\n    int\t\twlen;\n    char_u\t*byts;\n    idx_T\t*idxs;\n    int\t\tn;\n    int\t\twordcount;\n    int\t\twc;\n    int\t\tgoodscore;\n    hash_T\thash;\n    hashitem_T  *hi;\n    sftword_T\t*sft;\n    int\t\tbc, gc;\n    int\t\tlimit;\n\n    \/\/ It's very well possible that the same soundfold word is found several\n    \/\/ times with different scores.  Since the following is quite slow only do\n    \/\/ the words that have a better score than before.  Use a hashtable to\n    \/\/ remember the words that have been done.\n    hash = hash_hash(goodword);\n    hi = hash_lookup(&slang->sl_sounddone, goodword, hash);\n    if (HASHITEM_EMPTY(hi))\n    {\n\tsft = alloc(sizeof(sftword_T) + STRLEN(goodword));\n\tif (sft != NULL)\n\t{\n\t    sft->sft_score = score;\n\t    STRCPY(sft->sft_word, goodword);\n\t    hash_add_item(&slang->sl_sounddone, hi, sft->sft_word, hash);\n\t}\n    }\n    else\n    {\n\tsft = HI2SFT(hi);\n\tif (score >= sft->sft_score)\n\t    return;\n\tsft->sft_score = score;\n    }\n\n    \/\/ Find the word nr in the soundfold tree.\n    sfwordnr = soundfold_find(slang, goodword);\n    if (sfwordnr < 0)\n    {\n\tinternal_error(\"add_sound_suggest()\");\n\treturn;\n    }\n\n    \/\/ go over the list of good words that produce this soundfold word\n    nrline = ml_get_buf(slang->sl_sugbuf, (linenr_T)(sfwordnr + 1), FALSE);\n    orgnr = 0;\n    while (*nrline != NUL)\n    {\n\t\/\/ The wordnr was stored in a minimal nr of bytes as an offset to the\n\t\/\/ previous wordnr.\n\torgnr += bytes2offset(&nrline);\n\n\tbyts = slang->sl_fbyts;\n\tidxs = slang->sl_fidxs;\n\n\t\/\/ Lookup the word \"orgnr\" one of the two tries.\n\tn = 0;\n\twordcount = 0;\n\tfor (wlen = 0; wlen < MAXWLEN - 3; ++wlen)\n\t{\n\t    i = 1;\n\t    if (wordcount == orgnr && byts[n + 1] == NUL)\n\t\tbreak;\t\/\/ found end of word\n\n\t    if (byts[n + 1] == NUL)\n\t\t++wordcount;\n\n\t    \/\/ skip over the NUL bytes\n\t    for ( ; byts[n + i] == NUL; ++i)\n\t\tif (i > byts[n])\t\/\/ safety check\n\t\t{\n\t\t    STRCPY(theword + wlen, \"BAD\");\n\t\t    wlen += 3;\n\t\t    goto badword;\n\t\t}\n\n\t    \/\/ One of the siblings must have the word.\n\t    for ( ; i < byts[n]; ++i)\n\t    {\n\t\twc = idxs[idxs[n + i]];\t\/\/ nr of words under this byte\n\t\tif (wordcount + wc > orgnr)\n\t\t    break;\n\t\twordcount += wc;\n\t    }\n\n\t    theword[wlen] = byts[n + i];\n\t    n = idxs[n + i];\n\t}\nbadword:\n\ttheword[wlen] = NUL;\n\n\t\/\/ Go over the possible flags and regions.\n\tfor (; i <= byts[n] && byts[n + i] == NUL; ++i)\n\t{\n\t    char_u\tcword[MAXWLEN];\n\t    char_u\t*p;\n\t    int\t\tflags = (int)idxs[n + i];\n\n\t    \/\/ Skip words with the NOSUGGEST flag\n\t    if (flags & WF_NOSUGGEST)\n\t\tcontinue;\n\n\t    if (flags & WF_KEEPCAP)\n\t    {\n\t\t\/\/ Must find the word in the keep-case tree.\n\t\tfind_keepcap_word(slang, theword, cword);\n\t\tp = cword;\n\t    }\n\t    else\n\t    {\n\t\tflags |= su->su_badflags;\n\t\tif ((flags & WF_CAPMASK) != 0)\n\t\t{\n\t\t    \/\/ Need to fix case according to \"flags\".\n\t\t    make_case_word(theword, cword, flags);\n\t\t    p = cword;\n\t\t}\n\t\telse\n\t\t    p = theword;\n\t    }\n\n\t    \/\/ Add the suggestion.\n\t    if (sps_flags & SPS_DOUBLE)\n\t    {\n\t\t\/\/ Add the suggestion if the score isn't too bad.\n\t\tif (score <= su->su_maxscore)\n\t\t    add_suggestion(su, &su->su_sga, p, su->su_badlen,\n\t\t\t\t\t       score, 0, FALSE, slang, FALSE);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Add a penalty for words in another region.\n\t\tif ((flags & WF_REGION)\n\t\t\t    && (((unsigned)flags >> 16) & lp->lp_region) == 0)\n\t\t    goodscore = SCORE_REGION;\n\t\telse\n\t\t    goodscore = 0;\n\n\t\t\/\/ Add a small penalty for changing the first letter from\n\t\t\/\/ lower to upper case.  Helps for \"tath\" -> \"Kath\", which is\n\t\t\/\/ less common than \"tath\" -> \"path\".  Don't do it when the\n\t\t\/\/ letter is the same, that has already been counted.\n\t\tgc = PTR2CHAR(p);\n\t\tif (SPELL_ISUPPER(gc))\n\t\t{\n\t\t    bc = PTR2CHAR(su->su_badword);\n\t\t    if (!SPELL_ISUPPER(bc)\n\t\t\t\t      && SPELL_TOFOLD(bc) != SPELL_TOFOLD(gc))\n\t\t\tgoodscore += SCORE_ICASE \/ 2;\n\t\t}\n\n\t\t\/\/ Compute the score for the good word.  This only does letter\n\t\t\/\/ insert\/delete\/swap\/replace.  REP items are not considered,\n\t\t\/\/ which may make the score a bit higher.\n\t\t\/\/ Use a limit for the score to make it work faster.  Use\n\t\t\/\/ MAXSCORE(), because RESCORE() will change the score.\n\t\t\/\/ If the limit is very high then the iterative method is\n\t\t\/\/ inefficient, using an array is quicker.\n\t\tlimit = MAXSCORE(su->su_sfmaxscore - goodscore, score);\n\t\tif (limit > SCORE_LIMITMAX)\n\t\t    goodscore += spell_edit_score(slang, su->su_badword, p);\n\t\telse\n\t\t    goodscore += spell_edit_score_limit(slang, su->su_badword,\n\t\t\t\t\t\t\t\t    p, limit);\n\n\t\t\/\/ When going over the limit don't bother to do the rest.\n\t\tif (goodscore < SCORE_MAXMAX)\n\t\t{\n\t\t    \/\/ Give a bonus to words seen before.\n\t\t    goodscore = score_wordcount_adj(slang, goodscore, p, FALSE);\n\n\t\t    \/\/ Add the suggestion if the score isn't too bad.\n\t\t    goodscore = RESCORE(goodscore, score);\n\t\t    if (goodscore <= su->su_sfmaxscore)\n\t\t\tadd_suggestion(su, &su->su_ga, p, su->su_badlen,\n\t\t\t\t\t goodscore, score, TRUE, slang, TRUE);\n\t\t}\n\t    }\n\t}\n\t\/\/ smsg(\"word %s (%d): %s (%d)\", sftword, sftnr, theword, orgnr);\n    }\n}","target":0,"code_token_length":1697,"total_token_length":1933,"max_tokens_setting":2048}
+{"idx":247619,"func":"void testSupportForStatelessSessionResumption(const std::string& server_ctx_yaml,\n                                              const std::string& client_ctx_yaml,\n                                              bool expect_support,\n                                              const Network::Address::IpVersion ip_version) {\n  Event::SimulatedTimeSystem time_system;\n  ContextManagerImpl manager(*time_system);\n\n  Stats::IsolatedStoreImpl server_stats_store;\n  Api::ApiPtr server_api = Api::createApiForTest(server_stats_store, time_system);\n  NiceMock<Runtime::MockLoader> runtime;\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>\n      server_factory_context;\n  ON_CALL(server_factory_context, api()).WillByDefault(ReturnRef(*server_api));\n\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext server_tls_context;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(server_ctx_yaml), server_tls_context);\n  auto server_cfg =\n      std::make_unique<ServerContextConfigImpl>(server_tls_context, server_factory_context);\n\n  ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager,\n                                                   server_stats_store, {});\n  auto tcp_socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(\n      Network::Test::getCanonicalLoopbackAddress(ip_version));\n  NiceMock<Network::MockTcpListenerCallbacks> callbacks;\n  Event::DispatcherPtr dispatcher(server_api->allocateDispatcher(\"test_thread\"));\n  Network::ListenerPtr listener =\n      dispatcher->createListener(tcp_socket, callbacks, runtime, true, false);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client_tls_context;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(client_ctx_yaml), client_tls_context);\n\n  Stats::IsolatedStoreImpl client_stats_store;\n  Api::ApiPtr client_api = Api::createApiForTest(client_stats_store, time_system);\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>\n      client_factory_context;\n  ON_CALL(client_factory_context, api()).WillByDefault(ReturnRef(*client_api));\n\n  auto client_cfg =\n      std::make_unique<ClientContextConfigImpl>(client_tls_context, client_factory_context);\n  ClientSslSocketFactory ssl_socket_factory(std::move(client_cfg), manager, client_stats_store);\n  Network::ClientConnectionPtr client_connection = dispatcher->createClientConnection(\n      tcp_socket->connectionInfoProvider().localAddress(),\n      Network::Address::InstanceConstSharedPtr(), ssl_socket_factory.createTransportSocket(nullptr),\n      nullptr);\n\n  Network::MockConnectionCallbacks client_connection_callbacks;\n  client_connection->addConnectionCallbacks(client_connection_callbacks);\n  client_connection->connect();\n\n  StreamInfo::StreamInfoImpl stream_info(time_system, nullptr);\n  Network::ConnectionPtr server_connection;\n  EXPECT_CALL(callbacks, onAccept_(_))\n      .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {\n        server_connection = dispatcher->createServerConnection(\n            std::move(socket), server_ssl_socket_factory.createTransportSocket(nullptr),\n            stream_info);\n\n        const SslHandshakerImpl* ssl_socket =\n            dynamic_cast<const SslHandshakerImpl*>(server_connection->ssl().get());\n        SSL* server_ssl_socket = ssl_socket->ssl();\n        SSL_CTX* server_ssl_context = SSL_get_SSL_CTX(server_ssl_socket);\n        if (expect_support) {\n          EXPECT_EQ(0, (SSL_CTX_get_options(server_ssl_context) & SSL_OP_NO_TICKET));\n        } else {\n          EXPECT_EQ(SSL_OP_NO_TICKET, (SSL_CTX_get_options(server_ssl_context) & SSL_OP_NO_TICKET));\n        }\n      }));\n\n  EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))\n      .WillOnce(Invoke([&](Network::ConnectionEvent) -> void {\n        client_connection->close(Network::ConnectionCloseType::NoFlush);\n        server_connection->close(Network::ConnectionCloseType::NoFlush);\n        dispatcher->exit();\n      }));\n\n  EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));\n  dispatcher->run(Event::Dispatcher::RunType::Block);\n}","target":0,"code_token_length":854,"total_token_length":1090,"max_tokens_setting":2048}
+{"idx":261200,"func":"int MqttClient_Publish_ex(MqttClient *client, MqttPublish *publish,\n                            MqttPublishCb pubCb)\n{\n    int rc = MQTT_CODE_SUCCESS;\n    MqttPacketType resp_type;\n\n    \/* Validate required arguments *\/\n    if (client == NULL || publish == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n#ifdef WOLFMQTT_V5\n    \/* Use specified protocol version if set *\/\n    publish->protocol_level = client->protocol_level;\n\n    \/* Validate publish request against server properties *\/\n    if ((publish->qos > client->max_qos) ||\n        ((publish->retain == 1) && (client->retain_avail == 0)))\n    {\n        return MQTT_CODE_ERROR_SERVER_PROP;\n    }\n#endif\n\n    switch (publish->stat)\n    {\n        case MQTT_MSG_BEGIN:\n        {\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Lock send socket mutex *\/\n            rc = wm_SemLock(&client->lockSend);\n            if (rc != 0) {\n                return rc;\n            }\n        #endif\n\n            \/* Encode the publish packet *\/\n            rc = MqttEncode_Publish(client->tx_buf, client->tx_buf_len,\n                    publish, pubCb ? 1 : 0);\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d,\"\n                    \" QoS %d\",\n                rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_PUBLISH),\n                MQTT_PACKET_TYPE_PUBLISH, publish->packet_id,\n                publish->qos);\n        #endif\n            if (rc <= 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n                return rc;\n            }\n            client->write.len = rc;\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (publish->qos > MQTT_QOS_0) {\n                resp_type = (publish->qos == MQTT_QOS_1) ?\n                        MQTT_PACKET_TYPE_PUBLISH_ACK :\n                        MQTT_PACKET_TYPE_PUBLISH_COMP;\n\n                rc = wm_SemLock(&client->lockClient);\n                if (rc == 0) {\n                    \/* inform other threads of expected response *\/\n                    rc = MqttClient_RespList_Add(client, resp_type,\n                        publish->packet_id, &publish->pendResp, &publish->resp);\n                    wm_SemUnlock(&client->lockClient);\n                }\n                if (rc != 0) {\n                    wm_SemUnlock(&client->lockSend);\n                    return rc; \/* Error locking client *\/\n                }\n            }\n        #endif\n\n            publish->stat = MQTT_MSG_WRITE;\n        }\n        FALL_THROUGH;\n\n        case MQTT_MSG_WRITE:\n        {\n            \/* Send packet *\/\n            rc = MqttPacket_Write(client, client->tx_buf, client->write.len);\n        #ifdef WOLFMQTT_NONBLOCK\n            if (rc == MQTT_CODE_CONTINUE)\n                return rc;\n        #endif\n            if (rc < 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n            #ifdef WOLFMQTT_MULTITHREAD\n                if (wm_SemLock(&client->lockClient) == 0) {\n                    MqttClient_RespList_Remove(client, &publish->pendResp);\n                    wm_SemUnlock(&client->lockClient);\n                }\n            #endif\n                return rc;\n            }\n\n            \/* advance state *\/\n            publish->stat = MQTT_MSG_WRITE_PAYLOAD;\n        }\n        FALL_THROUGH;\n\n        case MQTT_MSG_WRITE_PAYLOAD:\n        {\n            rc = MqttClient_Publish_WritePayload(client, publish, pubCb);\n        #ifdef WOLFMQTT_NONBLOCK\n            if (rc == MQTT_CODE_CONTINUE)\n                return rc;\n        #endif\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n\n            if (rc < 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                if (wm_SemLock(&client->lockClient) == 0) {\n                    MqttClient_RespList_Remove(client, &publish->pendResp);\n                    wm_SemUnlock(&client->lockClient);\n                }\n            #endif\n                break;\n            }\n\n            \/* if not expecting a reply then we are done *\/\n            if (publish->qos == MQTT_QOS_0) {\n                break;\n            }\n            publish->stat = MQTT_MSG_WAIT;\n        }\n        FALL_THROUGH;\n\n        case MQTT_MSG_WAIT:\n        {\n            \/* Handle QoS *\/\n            if (publish->qos > MQTT_QOS_0) {\n                \/* Determine packet type to wait for *\/\n                resp_type = (publish->qos == MQTT_QOS_1) ?\n                    MQTT_PACKET_TYPE_PUBLISH_ACK :\n                    MQTT_PACKET_TYPE_PUBLISH_COMP;\n\n                \/* Wait for publish response packet *\/\n                rc = MqttClient_WaitType(client, &publish->resp, resp_type,\n                    publish->packet_id, client->cmd_timeout_ms);\n            #ifdef WOLFMQTT_NONBLOCK\n                if (rc == MQTT_CODE_CONTINUE)\n                    break;\n            #endif\n            #ifdef WOLFMQTT_MULTITHREAD\n                if (wm_SemLock(&client->lockClient) == 0) {\n                    MqttClient_RespList_Remove(client, &publish->pendResp);\n                    wm_SemUnlock(&client->lockClient);\n                }\n            #endif\n            }\n            break;\n        }\n\n    #ifdef WOLFMQTT_V5\n        case MQTT_MSG_AUTH:\n    #endif\n        case MQTT_MSG_READ:\n        case MQTT_MSG_READ_PAYLOAD:\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"MqttClient_Publish: Invalid state %d!\",\n                publish->stat);\n        #endif\n            rc = MQTT_CODE_ERROR_STAT;\n            break;\n    } \/* switch (publish->stat) *\/\n\n    \/* reset state *\/\n    if ((rc != MQTT_CODE_PUB_CONTINUE)\n#ifdef WOLFMQTT_NONBLOCK\n         && (rc != MQTT_CODE_CONTINUE)\n#endif\n        )\n    {\n        publish->stat = MQTT_MSG_BEGIN;\n    }\n    if (rc > 0) {\n        rc = MQTT_CODE_SUCCESS;\n    }\n\n    return rc;\n}","target":0,"code_token_length":1347,"total_token_length":1583,"max_tokens_setting":2048}
+{"idx":500046,"func":"krb5_error_code  kssl_check_authent(\n\t\t\t\/* IN     *\/\tKSSL_CTX\t*kssl_ctx,\n                        \/* IN     *\/   \tkrb5_data\t*authentp,\n\t\t\t\/* OUT    *\/\tkrb5_timestamp\t*atimep,\n\t\t\t\/* OUT    *\/    KSSL_ERR\t*kssl_err  )\n\t{\n        krb5_error_code\t\tkrb5rc = 0;\n\tKRB5_ENCDATA\t\t*dec_authent = NULL;\n\tKRB5_AUTHENTBODY\t*auth = NULL;\n\tkrb5_enctype\t\tenctype;\n\tEVP_CIPHER_CTX\t\tciph_ctx;\n\tconst EVP_CIPHER\t*enc = NULL;\n\tunsigned char\t\tiv[EVP_MAX_IV_LENGTH];\n\tconst unsigned char\t*p;\n\tunsigned char\t\t*unenc_authent;\n\tint \t\t\toutl, unencbufsize;\n\tstruct tm\t\ttm_time, *tm_l, *tm_g;\n\ttime_t\t\t\tnow, tl, tg, tr, tz_offset;\n\n\tEVP_CIPHER_CTX_init(&ciph_ctx);\n\t*atimep = 0;\n\tkssl_err_set(kssl_err, 0, \"\");\n\n#ifndef KRB5CHECKAUTH\n\tauthentp = NULL;\n#else\n#if\tKRB5CHECKAUTH == 0\n\tauthentp = NULL;\n#endif\n#endif\t\/* KRB5CHECKAUTH *\/\n\n\tif (authentp == NULL  ||  authentp->length == 0)  return 0;\n\n#ifdef KSSL_DEBUG\n        {\n        unsigned int ui;\n\tprintf(\"kssl_check_authent: authenticator[%d]:\\n\",authentp->length);\n\tp = authentp->data; \n\tfor (ui=0; ui < authentp->length; ui++)  printf(\"%02x \",p[ui]);\n\tprintf(\"\\n\");\n        }\n#endif\t\/* KSSL_DEBUG *\/\n\n\tunencbufsize = 2 * authentp->length;\n\tif ((unenc_authent = calloc(1, unencbufsize)) == NULL)\n\t\t{\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n\t\t\t\"Unable to allocate authenticator buffer.\\n\");\n\t\tkrb5rc = KRB5KRB_ERR_GENERIC;\n\t\tgoto err;\n\t\t}\n\n\tp = (unsigned char *)authentp->data;\n\tif ((dec_authent = d2i_KRB5_ENCDATA(NULL, &p,\n\t\t\t\t\t(long) authentp->length)) == NULL) \n\t\t{\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"Error decoding authenticator.\\n\");\n\t\tkrb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;\n\t\tgoto err;\n\t\t}\n\n\tenctype = dec_authent->etype->data[0];\t\/* should = kssl_ctx->enctype *\/\n#if !defined(KRB5_MIT_OLD11)\n            switch ( enctype ) {\n            case ENCTYPE_DES3_CBC_SHA1:\t\t\/*    EVP_des_ede3_cbc();  *\/\n            case ENCTYPE_DES3_CBC_SHA:\n            case ENCTYPE_DES3_CBC_RAW:\n                krb5rc = 0;                     \/* Skip, can't handle derived keys *\/\n                goto err;\n            }\n#endif\n\tenc = kssl_map_enc(enctype);\n\tmemset(iv, 0, sizeof iv);       \/* per RFC 1510 *\/\n\n\tif (enc == NULL)\n\t\t{\n\t\t\/*  Disable kssl_check_authent for ENCTYPE_DES3_CBC_SHA1.\n\t\t**  This enctype indicates the authenticator was encrypted\n\t\t**  using key-usage derived keys which openssl cannot decrypt.\n\t\t*\/\n\t\tgoto err;\n\t\t}\n\n        if (!EVP_CipherInit(&ciph_ctx,enc,kssl_ctx->key,iv,0))\n                {\n                kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"EVP_CipherInit error decrypting authenticator.\\n\");\n                krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;\n                goto err;\n                }\n        outl = dec_authent->cipher->length;\n        if (!EVP_Cipher(&ciph_ctx,unenc_authent,dec_authent->cipher->data,outl))\n                {\n                kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"EVP_Cipher error decrypting authenticator.\\n\");\n                krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;\n                goto err;\n                }\n        EVP_CIPHER_CTX_cleanup(&ciph_ctx);\n\n#ifdef KSSL_DEBUG\n\tprintf(\"kssl_check_authent: decrypted authenticator[%d] =\\n\", outl);\n\tfor (padl=0; padl < outl; padl++) printf(\"%02x \",unenc_authent[padl]);\n\tprintf(\"\\n\");\n#endif\t\/* KSSL_DEBUG *\/\n\n\tif ((p = kssl_skip_confound(enctype, unenc_authent)) == NULL)\n\t\t{\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"confounded by authenticator.\\n\");\n\t\tkrb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;\n\t\tgoto err;\n\t\t}\n\toutl -= p - unenc_authent;\n\n\tif ((auth = (KRB5_AUTHENTBODY *) d2i_KRB5_AUTHENT(NULL, &p,\n\t\t\t\t\t\t\t  (long) outl))==NULL)\n\t\t{\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"Error decoding authenticator body.\\n\");\n\t\tkrb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;\n\t\tgoto err;\n\t\t}\n\n\tmemset(&tm_time,0,sizeof(struct tm));\n\tif (k_gmtime(auth->ctime, &tm_time)  &&\n\t\t((tr = mktime(&tm_time)) != (time_t)(-1)))\n \t\t{\n \t\tnow  = time(&now);\n \t\ttm_l = localtime(&now); \ttl = mktime(tm_l);\n \t\ttm_g = gmtime(&now);\t\ttg = mktime(tm_g);\n \t\ttz_offset = tg - tl;\n\n\t\t*atimep = (krb5_timestamp)(tr - tz_offset);\n \t\t}\n\n#ifdef KSSL_DEBUG\n\tprintf(\"kssl_check_authent: returns %d for client time \", *atimep);\n\tif (auth && auth->ctime && auth->ctime->length && auth->ctime->data)\n\t\tprintf(\"%.*s\\n\", auth->ctime->length, auth->ctime->data);\n\telse\tprintf(\"NULL\\n\");\n#endif\t\/* KSSL_DEBUG *\/\n\n err:\n\tif (auth)\t\tKRB5_AUTHENT_free((KRB5_AUTHENT *) auth);\n\tif (dec_authent)\tKRB5_ENCDATA_free(dec_authent);\n\tif (unenc_authent)\tfree(unenc_authent);\n\tEVP_CIPHER_CTX_cleanup(&ciph_ctx);\n\treturn krb5rc;\n\t}","target":0,"code_token_length":1482,"total_token_length":1718,"max_tokens_setting":2048}
+{"idx":230272,"func":"njs_array_prototype_iterator(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t magic)\n{\n    int64_t                 i, length;\n    njs_int_t               ret;\n    njs_array_t             *array;\n    njs_value_t             accumulator;\n    njs_iterator_args_t     iargs;\n    njs_iterator_handler_t  handler;\n\n    iargs.value = njs_argument(args, 0);\n\n    ret = njs_value_to_object(vm, iargs.value);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_value_length(vm, iargs.value, &iargs.to);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    iargs.from = 0;\n\n    if (njs_array_arg1(magic) == NJS_ARRAY_FUNC) {\n        if (njs_slow_path(!njs_is_function(njs_arg(args, nargs, 1)))) {\n            njs_type_error(vm, \"callback argument is not callable\");\n            return NJS_ERROR;\n        }\n\n        iargs.function = njs_function(njs_argument(args, 1));\n        iargs.argument = njs_arg(args, nargs, 2);\n\n    } else {\n        iargs.argument = njs_arg(args, nargs, 1);\n    }\n\n    switch (njs_array_type(magic)) {\n    case NJS_ARRAY_EVERY:\n        handler = njs_array_handler_every;\n        break;\n\n    case NJS_ARRAY_SOME:\n        handler = njs_array_handler_some;\n        break;\n\n    case NJS_ARRAY_INCLUDES:\n    case NJS_ARRAY_INDEX_OF:\n        switch (njs_array_type(magic)) {\n        case NJS_ARRAY_INCLUDES:\n            handler = njs_array_handler_includes;\n\n            if (iargs.to == 0) {\n                goto done;\n            }\n\n            break;\n\n        default:\n            handler = njs_array_handler_index_of;\n        }\n\n        ret = njs_value_to_integer(vm, njs_arg(args, nargs, 2), &iargs.from);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (iargs.from < 0) {\n            iargs.from += iargs.to;\n\n            if (iargs.from < 0) {\n                iargs.from = 0;\n            }\n        }\n\n        break;\n\n    case NJS_ARRAY_FOR_EACH:\n        handler = njs_array_handler_for_each;\n        break;\n\n    case NJS_ARRAY_FIND:\n        handler = njs_array_handler_find;\n        break;\n\n    case NJS_ARRAY_FIND_INDEX:\n        handler = njs_array_handler_find_index;\n        break;\n\n    case NJS_ARRAY_REDUCE:\n        handler = njs_array_handler_reduce;\n\n        njs_set_invalid(&accumulator);\n\n        if (nargs > 2) {\n            accumulator = *iargs.argument;\n        }\n\n        iargs.argument = &accumulator;\n        break;\n\n    case NJS_ARRAY_FILTER:\n    case NJS_ARRAY_MAP:\n    default:\n        if (njs_array_type(magic) == NJS_ARRAY_FILTER) {\n            length = 0;\n            handler = njs_array_handler_filter;\n\n        } else {\n            length = iargs.to;\n            handler = njs_array_handler_map;\n        }\n\n        array = njs_array_alloc(vm, 0, length, NJS_ARRAY_SPARE);\n        if (njs_slow_path(array == NULL)) {\n            return NJS_ERROR;\n        }\n\n        if (array->object.fast_array) {\n            for (i = 0; i < length; i++) {\n                njs_set_invalid(&array->start[i]);\n            }\n        }\n\n        iargs.data = array;\n\n        break;\n    }\n\n    ret = njs_object_iterate(vm, &iargs, handler);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    if (ret == NJS_DONE) {\n        return NJS_OK;\n    }\n\ndone:\n\n    \/* Default values. *\/\n\n    switch (njs_array_type(magic)) {\n    case NJS_ARRAY_EVERY:\n        vm->retval = njs_value_true;\n        break;\n\n    case NJS_ARRAY_SOME:\n    case NJS_ARRAY_INCLUDES:\n        vm->retval = njs_value_false;\n        break;\n\n    case NJS_ARRAY_INDEX_OF:\n    case NJS_ARRAY_FIND_INDEX:\n        njs_set_number(&vm->retval, -1);\n        break;\n\n    case NJS_ARRAY_FOR_EACH:\n    case NJS_ARRAY_FIND:\n        njs_set_undefined(&vm->retval);\n        break;\n\n    case NJS_ARRAY_REDUCE:\n        if (!njs_is_valid(&accumulator)) {\n            njs_type_error(vm, \"Reduce of empty object with no initial value\");\n            return NJS_ERROR;\n        }\n\n        vm->retval = accumulator;\n        break;\n\n    case NJS_ARRAY_FILTER:\n    case NJS_ARRAY_MAP:\n    default:\n        njs_set_array(&vm->retval, iargs.data);\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":1080,"total_token_length":1316,"max_tokens_setting":2048}
+{"idx":508384,"func":"lock_table_names(THD *thd, const DDL_options_st &options,\n                 TABLE_LIST *tables_start, TABLE_LIST *tables_end,\n                 ulong lock_wait_timeout, uint flags)\n{\n  MDL_request_list mdl_requests;\n  TABLE_LIST *table;\n  MDL_request global_request;\n  ulong org_lock_wait_timeout= lock_wait_timeout;\n  \/* Check if we are using CREATE TABLE ... IF NOT EXISTS *\/\n  bool create_table;\n  Dummy_error_handler error_handler;\n  DBUG_ENTER(\"lock_table_names\");\n\n  DBUG_ASSERT(!thd->locked_tables_mode);\n\n  for (table= tables_start; table && table != tables_end;\n       table= table->next_global)\n  {\n    if (table->mdl_request.type < MDL_SHARED_UPGRADABLE ||\n        table->mdl_request.type == MDL_SHARED_READ_ONLY ||\n        table->open_type == OT_TEMPORARY_ONLY ||\n        (table->open_type == OT_TEMPORARY_OR_BASE && is_temporary_table(table)))\n    {\n      continue;\n    }\n\n    \/* Write lock on normal tables is not allowed in a read only transaction. *\/\n    if (thd->tx_read_only)\n    {\n      my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0));\n      DBUG_RETURN(true);\n    }\n\n    \/* Scoped locks: Take intention exclusive locks on all involved schemas. *\/\n    if (!(flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK))\n    {\n      MDL_request *schema_request= new (thd->mem_root) MDL_request;\n      if (schema_request == NULL)\n        DBUG_RETURN(TRUE);\n      schema_request->init(MDL_key::SCHEMA, table->db, \"\",\n                           MDL_INTENTION_EXCLUSIVE,\n                           MDL_TRANSACTION);\n      mdl_requests.push_front(schema_request);\n    }\n\n    mdl_requests.push_front(&table->mdl_request);\n  }\n\n  if (mdl_requests.is_empty())\n    DBUG_RETURN(FALSE);\n\n  \/* Check if CREATE TABLE without REPLACE was used *\/\n  create_table= thd->lex->sql_command == SQLCOM_CREATE_TABLE &&\n                !options.or_replace();\n\n  if (!(flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK))\n  {\n    \/*\n      Protect this statement against concurrent global read lock\n      by acquiring global intention exclusive lock with statement\n      duration.\n    *\/\n    if (thd->global_read_lock.can_acquire_protection())\n      DBUG_RETURN(TRUE);\n    global_request.init(MDL_key::GLOBAL, \"\", \"\", MDL_INTENTION_EXCLUSIVE,\n                        MDL_STATEMENT);\n    mdl_requests.push_front(&global_request);\n\n    if (create_table)\n#ifdef WITH_WSREP\n      if (!(thd->lex->sql_command == SQLCOM_CREATE_TABLE &&\n\t    thd->wsrep_exec_mode == REPL_RECV))\n#endif\n      lock_wait_timeout= 0;                     \/\/ Don't wait for timeout\n  }\n\n  for (;;)\n  {\n    if (create_table)\n      thd->push_internal_handler(&error_handler);  \/\/ Avoid warnings & errors\n    bool res= thd->mdl_context.acquire_locks(&mdl_requests, lock_wait_timeout);\n    if (create_table)\n      thd->pop_internal_handler();\n\n    if (!res)\n      DBUG_RETURN(FALSE);                       \/\/ Got locks\n\n    if (!create_table)\n      DBUG_RETURN(TRUE);                        \/\/ Return original error\n\n    \/*\n      We come here in the case of lock timeout when executing CREATE TABLE.\n      Verify that table does exist (it usually does, as we got a lock conflict)\n    *\/\n    if (ha_table_exists(thd, tables_start->db, tables_start->table_name))\n    {\n      if (options.if_not_exists())\n      {\n        push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,\n                            ER_TABLE_EXISTS_ERROR,\n                            ER_THD(thd, ER_TABLE_EXISTS_ERROR),\n                            tables_start->table_name);\n      }\n      else\n        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tables_start->table_name);\n      DBUG_RETURN(TRUE);\n    }\n    \/*\n      We got error from acquire_locks, but the table didn't exists.\n      This could happen if another connection runs a statement\n      involving this non-existent table, and this statement took the mdl,\n      but didn't error out with ER_NO_SUCH_TABLE yet (yes, a race condition).\n      We play safe and restart the original acquire_locks with the\n      original timeout.\n    *\/\n    create_table= 0;\n    lock_wait_timeout= org_lock_wait_timeout;\n  }\n}","target":0,"code_token_length":935,"total_token_length":1171,"max_tokens_setting":2048}
+{"idx":409450,"func":"handle_csi(\n\tchar_u\t*tp,\n\tint\tlen,\n\tchar_u\t*argp,\n\tint\toffset,\n\tchar_u  *buf,\n\tint\tbufsize,\n\tint\t*buflen,\n\tchar_u\t*key_name,\n\tint\t*slen)\n{\n    int\t\tfirst = -1;  \/\/ optional char right after {lead}\n    int\t\ttrail;\t     \/\/ char that ends CSI sequence\n    int\t\targ[3] = {-1, -1, -1};\t\/\/ argument numbers\n    int\t\targc;\t\t\t\/\/ number of arguments\n    char_u\t*ap = argp;\n    int\t\tcsi_len;\n\n    \/\/ Check for non-digit after CSI.\n    if (!VIM_ISDIGIT(*ap))\n\tfirst = *ap++;\n\n    \/\/ Find up to three argument numbers.\n    for (argc = 0; argc < 3; )\n    {\n\tif (ap >= tp + len)\n\t    return -1;\n\tif (*ap == ';')\n\t    arg[argc++] = -1;  \/\/ omitted number\n\telse if (VIM_ISDIGIT(*ap))\n\t{\n\t    arg[argc] = 0;\n\t    for (;;)\n\t    {\n\t\tif (ap >= tp + len)\n\t\t    return -1;\n\t\tif (!VIM_ISDIGIT(*ap))\n\t\t    break;\n\t\targ[argc] = arg[argc] * 10 + (*ap - '0');\n\t\t++ap;\n\t    }\n\t    ++argc;\n\t}\n\tif (*ap == ';')\n\t    ++ap;\n\telse\n\t    break;\n    }\n\n    \/\/ mrxvt has been reported to have \"+\" in the version. Assume\n    \/\/ the escape sequence ends with a letter or one of \"{|}~\".\n    while (ap < tp + len\n\t    && !(*ap >= '{' && *ap <= '~')\n\t    && !ASCII_ISALPHA(*ap))\n\t++ap;\n    if (ap >= tp + len)\n\treturn -1;\n    trail = *ap;\n    csi_len = (int)(ap - tp) + 1;\n\n    \/\/ Cursor position report: Eat it when there are 2 arguments\n    \/\/ and it ends in 'R'. Also when u7_status is not \"sent\", it\n    \/\/ may be from a previous Vim that just exited.  But not for\n    \/\/ <S-F3>, it sends something similar, check for row and column\n    \/\/ to make sense.\n    if (first == -1 && argc == 2 && trail == 'R')\n    {\n\thandle_u7_response(arg, tp, csi_len);\n\n\tkey_name[0] = (int)KS_EXTRA;\n\tkey_name[1] = (int)KE_IGNORE;\n\t*slen = csi_len;\n    }\n\n    \/\/ Version string: Eat it when there is at least one digit and\n    \/\/ it ends in 'c'\n    else if (*T_CRV != NUL && ap > argp + 1 && trail == 'c')\n    {\n\thandle_version_response(first, arg, argc, tp);\n\n\t*slen = csi_len;\n# ifdef FEAT_EVAL\n\tset_vim_var_string(VV_TERMRESPONSE, tp, *slen);\n# endif\n\tapply_autocmds(EVENT_TERMRESPONSE,\n\t\t\t\t\tNULL, NULL, FALSE, curbuf);\n\tkey_name[0] = (int)KS_EXTRA;\n\tkey_name[1] = (int)KE_IGNORE;\n    }\n\n    \/\/ Check blinking cursor from xterm:\n    \/\/ {lead}?12;1$y       set\n    \/\/ {lead}?12;2$y       not set\n    \/\/\n    \/\/ {lead} can be <Esc>[ or CSI\n    else if (rbm_status.tr_progress == STATUS_SENT\n\t    && first == '?'\n\t    && ap == argp + 6\n\t    && arg[0] == 12\n\t    && ap[-1] == '$'\n\t    && trail == 'y')\n    {\n\tinitial_cursor_blink = (arg[1] == '1');\n\trbm_status.tr_progress = STATUS_GOT;\n\tLOG_TR((\"Received cursor blinking mode response: %s\", tp));\n\tkey_name[0] = (int)KS_EXTRA;\n\tkey_name[1] = (int)KE_IGNORE;\n\t*slen = csi_len;\n# ifdef FEAT_EVAL\n\tset_vim_var_string(VV_TERMBLINKRESP, tp, *slen);\n# endif\n    }\n\n    \/\/ Check for a window position response from the terminal:\n    \/\/       {lead}3;{x};{y}t\n    else if (did_request_winpos && argc == 3 && arg[0] == 3\n\t\t\t\t\t\t   && trail == 't')\n    {\n\twinpos_x = arg[1];\n\twinpos_y = arg[2];\n\t\/\/ got finished code: consume it\n\tkey_name[0] = (int)KS_EXTRA;\n\tkey_name[1] = (int)KE_IGNORE;\n\t*slen = csi_len;\n\n\tif (--did_request_winpos <= 0)\n\t    winpos_status.tr_progress = STATUS_GOT;\n    }\n\n    \/\/ Key with modifier:\n    \/\/\t{lead}27;{modifier};{key}~\n    \/\/\t{lead}{key};{modifier}u\n    else if ((arg[0] == 27 && argc == 3 && trail == '~')\n\t    || (argc == 2 && trail == 'u'))\n    {\n\treturn len + handle_key_with_modifier(arg, trail,\n\t\t\t    csi_len, offset, buf, bufsize, buflen);\n    }\n\n    \/\/ else: Unknown CSI sequence.  We could drop it, but then the\n    \/\/ user can't create a map for it.\n    return 0;\n}","target":0,"code_token_length":1198,"total_token_length":1434,"max_tokens_setting":2048}
+{"idx":231683,"func":"TEST_F(\n    QuicServerTransportTest,\n    MigrateToUnvalidatePeerCancelsOutstandingPathChallenge) {\n  server->getNonConstConn().transportSettings.disableMigration = false;\n  auto data = IOBuf::copyBuffer(\"bad data\");\n  auto packetData = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      2,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n\n  auto peerAddress = server->getConn().peerAddress;\n  auto congestionController = server->getConn().congestionController.get();\n  auto srtt = server->getConn().lossState.srtt;\n  auto lrtt = server->getConn().lossState.lrtt;\n  auto rttvar = server->getConn().lossState.rttvar;\n  auto mrtt = server->getConn().lossState.mrtt;\n\n  folly::SocketAddress newPeer(\"100.101.102.103\", 23456);\n  deliverData(std::move(packetData), true, &newPeer);\n  EXPECT_EQ(server->getConn().peerAddress, newPeer);\n  EXPECT_TRUE(server->getConn().outstandingPathValidation);\n  EXPECT_TRUE(server->getConn().pendingEvents.schedulePathValidationTimeout);\n  EXPECT_TRUE(server->pathValidationTimeout().isScheduled());\n\n  EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1);\n  EXPECT_EQ(\n      server->getConn().migrationState.previousPeerAddresses.back(),\n      peerAddress);\n  EXPECT_EQ(server->getConn().lossState.srtt, 0us);\n  EXPECT_EQ(server->getConn().lossState.lrtt, 0us);\n  EXPECT_EQ(server->getConn().lossState.rttvar, 0us);\n  EXPECT_EQ(server->getConn().lossState.mrtt, kDefaultMinRtt);\n  EXPECT_NE(server->getConn().congestionController.get(), nullptr);\n  EXPECT_NE(server->getConn().congestionController.get(), congestionController);\n  EXPECT_EQ(\n      server->getConn().migrationState.lastCongestionAndRtt->peerAddress,\n      clientAddr);\n  EXPECT_EQ(\n      server->getConn()\n          .migrationState.lastCongestionAndRtt->congestionController.get(),\n      congestionController);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->srtt, srtt);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->lrtt, lrtt);\n  EXPECT_EQ(\n      server->getConn().migrationState.lastCongestionAndRtt->rttvar, rttvar);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->mrtt, mrtt);\n\n  auto packetData2 = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      6,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n  folly::SocketAddress newPeer2(\"200.101.102.103\", 23456);\n  deliverData(std::move(packetData2), false, &newPeer2);\n  EXPECT_FALSE(server->getConn().outstandingPathValidation);\n  EXPECT_FALSE(server->getConn().pendingEvents.schedulePathValidationTimeout);\n  EXPECT_FALSE(server->pathValidationTimeout().isScheduled());\n\n  EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1);\n  EXPECT_EQ(\n      server->getConn().migrationState.previousPeerAddresses.back(),\n      peerAddress);\n  EXPECT_EQ(server->getConn().lossState.srtt, 0us);\n  EXPECT_EQ(server->getConn().lossState.lrtt, 0us);\n  EXPECT_EQ(server->getConn().lossState.rttvar, 0us);\n  EXPECT_EQ(server->getConn().lossState.mrtt, kDefaultMinRtt);\n  EXPECT_NE(server->getConn().congestionController.get(), nullptr);\n  EXPECT_NE(server->getConn().congestionController.get(), congestionController);\n  EXPECT_EQ(\n      server->getConn().migrationState.lastCongestionAndRtt->peerAddress,\n      clientAddr);\n  EXPECT_EQ(\n      server->getConn()\n          .migrationState.lastCongestionAndRtt->congestionController.get(),\n      congestionController);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->srtt, srtt);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->lrtt, lrtt);\n  EXPECT_EQ(\n      server->getConn().migrationState.lastCongestionAndRtt->rttvar, rttvar);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->mrtt, mrtt);\n}","target":0,"code_token_length":1074,"total_token_length":1310,"max_tokens_setting":2048}
+{"idx":244193,"func":"GF_Err trun_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s;\n\n#ifdef GF_ENABLE_CTRN\n\tif (ptr->type == GF_ISOM_BOX_TYPE_CTRN) {\n\t\tptr->type = GF_ISOM_BOX_TYPE_TRUN;\n\t\tptr->use_ctrn = GF_TRUE;\n\t\treturn ctrn_box_read(s, bs);\n\t}\n#endif\n\n\t\/\/check this is a good file\n\tif ((ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) && (ptr->flags & GF_ISOM_TRUN_FLAGS))\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->sample_count = gf_bs_read_u32(bs);\n\n\t\/\/The rest depends on the flags\n\tif (ptr->flags & GF_ISOM_TRUN_DATA_OFFSET) {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->data_offset = gf_bs_read_u32(bs);\n\t}\n\tif (ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->first_sample_flags = gf_bs_read_u32(bs);\n\t}\n\tif (! (ptr->flags & (GF_ISOM_TRUN_DURATION | GF_ISOM_TRUN_SIZE | GF_ISOM_TRUN_FLAGS | GF_ISOM_TRUN_CTS_OFFSET) ) ) {\n\t\tptr->samples = gf_malloc(sizeof(GF_TrunEntry));\n\t\tif (!ptr->samples) return GF_OUT_OF_MEM;\n\t\t\/\/memset to 0 !!\n\t\tmemset(ptr->samples, 0, sizeof(GF_TrunEntry));\n\t\tptr->sample_alloc = ptr->nb_samples = 1;\n\t\tptr->samples[0].nb_pack = ptr->sample_count;\n\t} else {\n\t\t\/\/if we get here, at least one flag (so at least 4 bytes) is set, check size\n\t\tif (ptr->sample_count * 4 > ptr->size) {\n\t\t\tISOM_DECREASE_SIZE(ptr, ptr->sample_count*4);\n\t\t}\n\t\tif ((u64)ptr->sample_count > (u64)SIZE_MAX\/sizeof(GF_TrunEntry)) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of samples %d in trun\\n\", ptr->sample_count));\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tptr->samples = gf_malloc(sizeof(GF_TrunEntry) * ptr->sample_count);\n\t\tif (!ptr->samples) return GF_OUT_OF_MEM;\n\t\tptr->sample_alloc = ptr->nb_samples = ptr->sample_count;\n\t\t\/\/memset to 0 upfront\n\t\tmemset(ptr->samples, 0, ptr->sample_count * sizeof(GF_TrunEntry));\n\n\t\t\/\/read each entry (even though nothing may be written)\n\t\tfor (i=0; i<ptr->sample_count; i++) {\n\t\t\tu32 trun_size = 0;\n\t\t\tGF_TrunEntry *p = &ptr->samples[i];\n\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_DURATION) {\n\t\t\t\tp->Duration = gf_bs_read_u32(bs);\n\t\t\t\ttrun_size += 4;\n\t\t\t}\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_SIZE) {\n\t\t\t\tp->size = gf_bs_read_u32(bs);\n\t\t\t\ttrun_size += 4;\n\t\t\t}\n\t\t\t\/\/SHOULDN'T BE USED IF GF_ISOM_TRUN_FIRST_FLAG IS DEFINED\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_FLAGS) {\n\t\t\t\tp->flags = gf_bs_read_u32(bs);\n\t\t\t\ttrun_size += 4;\n\t\t\t}\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) {\n\t\t\t\tif (ptr->version==0) {\n\t\t\t\t\tp->CTS_Offset = (u32) gf_bs_read_u32(bs);\n\t\t\t\t} else {\n\t\t\t\t\tp->CTS_Offset = (s32) gf_bs_read_u32(bs);\n\t\t\t\t}\n\t\t\t\ttrun_size += 4;\n\t\t\t}\n\t\t\tISOM_DECREASE_SIZE(ptr, trun_size);\n\t\t}\n\t}\n\t\/*todo parse sample reorder*\/\n\tif (ptr->size) {\n\t\tgf_bs_skip_bytes(bs, ptr->size);\n\t\tptr->size = 0;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":947,"total_token_length":1183,"max_tokens_setting":2048}
+{"idx":385940,"func":"static int atomic_open(struct nameidata *nd, struct dentry *dentry,\n\t\t\tstruct path *path, struct file *file,\n\t\t\tconst struct open_flags *op,\n\t\t\tbool got_write, bool need_lookup,\n\t\t\tint *opened)\n{\n\tstruct inode *dir =  nd->path.dentry->d_inode;\n\tunsigned open_flag = open_to_namei_flags(op->open_flag);\n\tumode_t mode;\n\tint error;\n\tint acc_mode;\n\tint create_error = 0;\n\tstruct dentry *const DENTRY_NOT_SET = (void *) -1UL;\n\n\tBUG_ON(dentry->d_inode);\n\n\t\/* Don't create child dentry for a dead directory. *\/\n\tif (unlikely(IS_DEADDIR(dir))) {\n\t\terror = -ENOENT;\n\t\tgoto out;\n\t}\n\n\tmode = op->mode;\n\tif ((open_flag & O_CREAT) && !IS_POSIXACL(dir))\n\t\tmode &= ~current_umask();\n\n\tif ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) {\n\t\topen_flag &= ~O_TRUNC;\n\t\t*opened |= FILE_CREATED;\n\t}\n\n\t\/*\n\t * Checking write permission is tricky, bacuse we don't know if we are\n\t * going to actually need it: O_CREAT opens should work as long as the\n\t * file exists.  But checking existence breaks atomicity.  The trick is\n\t * to check access and if not granted clear O_CREAT from the flags.\n\t *\n\t * Another problem is returing the \"right\" error value (e.g. for an\n\t * O_EXCL open we want to return EEXIST not EROFS).\n\t *\/\n\tif (((open_flag & (O_CREAT | O_TRUNC)) ||\n\t    (open_flag & O_ACCMODE) != O_RDONLY) && unlikely(!got_write)) {\n\t\tif (!(open_flag & O_CREAT)) {\n\t\t\t\/*\n\t\t\t * No O_CREATE -> atomicity not a requirement -> fall\n\t\t\t * back to lookup + open\n\t\t\t *\/\n\t\t\tgoto no_open;\n\t\t} else if (open_flag & (O_EXCL | O_TRUNC)) {\n\t\t\t\/* Fall back and fail with the right error *\/\n\t\t\tcreate_error = -EROFS;\n\t\t\tgoto no_open;\n\t\t} else {\n\t\t\t\/* No side effects, safe to clear O_CREAT *\/\n\t\t\tcreate_error = -EROFS;\n\t\t\topen_flag &= ~O_CREAT;\n\t\t}\n\t}\n\n\tif (open_flag & O_CREAT) {\n\t\terror = may_o_create(&nd->path, dentry, mode);\n\t\tif (error) {\n\t\t\tcreate_error = error;\n\t\t\tif (open_flag & O_EXCL)\n\t\t\t\tgoto no_open;\n\t\t\topen_flag &= ~O_CREAT;\n\t\t}\n\t}\n\n\tif (nd->flags & LOOKUP_DIRECTORY)\n\t\topen_flag |= O_DIRECTORY;\n\n\tfile->f_path.dentry = DENTRY_NOT_SET;\n\tfile->f_path.mnt = nd->path.mnt;\n\terror = dir->i_op->atomic_open(dir, dentry, file, open_flag, mode,\n\t\t\t\t      opened);\n\tif (error < 0) {\n\t\tif (create_error && error == -ENOENT)\n\t\t\terror = create_error;\n\t\tgoto out;\n\t}\n\n\tacc_mode = op->acc_mode;\n\tif (*opened & FILE_CREATED) {\n\t\tfsnotify_create(dir, dentry);\n\t\tacc_mode = MAY_OPEN;\n\t}\n\n\tif (error) {\t\/* returned 1, that is *\/\n\t\tif (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {\n\t\t\terror = -EIO;\n\t\t\tgoto out;\n\t\t}\n\t\tif (file->f_path.dentry) {\n\t\t\tdput(dentry);\n\t\t\tdentry = file->f_path.dentry;\n\t\t}\n\t\tif (create_error && dentry->d_inode == NULL) {\n\t\t\terror = create_error;\n\t\t\tgoto out;\n\t\t}\n\t\tgoto looked_up;\n\t}\n\n\t\/*\n\t * We didn't have the inode before the open, so check open permission\n\t * here.\n\t *\/\n\terror = may_open(&file->f_path, acc_mode, open_flag);\n\tif (error)\n\t\tfput(file);\n\nout:\n\tdput(dentry);\n\treturn error;\n\nno_open:\n\tif (need_lookup) {\n\t\tdentry = lookup_real(dir, dentry, nd->flags);\n\t\tif (IS_ERR(dentry))\n\t\t\treturn PTR_ERR(dentry);\n\n\t\tif (create_error) {\n\t\t\tint open_flag = op->open_flag;\n\n\t\t\terror = create_error;\n\t\t\tif ((open_flag & O_EXCL)) {\n\t\t\t\tif (!dentry->d_inode)\n\t\t\t\t\tgoto out;\n\t\t\t} else if (!dentry->d_inode) {\n\t\t\t\tgoto out;\n\t\t\t} else if ((open_flag & O_TRUNC) &&\n\t\t\t\t   S_ISREG(dentry->d_inode->i_mode)) {\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\t\/* will fail later, go on to get the right error *\/\n\t\t}\n\t}\nlooked_up:\n\tpath->dentry = dentry;\n\tpath->mnt = nd->path.mnt;\n\treturn 1;\n}","target":0,"code_token_length":1058,"total_token_length":1294,"max_tokens_setting":2048}
+{"idx":240606,"func":"  void Compute(OpKernelContext* c) override {\n    core::RefCountPtr<Var> v;\n    OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n    OP_REQUIRES_OK(c, EnsureSparseVariableAccess<Device, T>(c, v.get()));\n    \/\/ NOTE: We hold the lock for the whole gather operation instead\n    \/\/ of increasing the reference count of v->tensor() to avoid a\n    \/\/ situation where a write to the same variable will see a\n    \/\/ reference count greater than one and make a copy of the\n    \/\/ (potentially very large) tensor buffer.\n    tf_shared_lock ml(*v->mu());\n    const Tensor& params = *v->tensor();\n    const Tensor& indices = c->input(1);\n    OP_REQUIRES(\n        c, TensorShapeUtils::IsVectorOrHigher(params.shape()),\n        errors::InvalidArgument(\"params must be at least 1 dimensional\"));\n    OP_REQUIRES(\n        c, params.shape().dims() >= batch_dims_,\n        errors::InvalidArgument(\"params must have at least \", batch_dims_,\n                                \" (batch_dims) dimensions but it has shape \",\n                                params.shape().DebugString()));\n\n    \/\/ Check that we have enough index space\n    const int64_t N = indices.NumElements();\n    OP_REQUIRES(\n        c, params.dim_size(0) <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"params.shape[0] too large for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", params.dim_size(0), \" > \",\n                                std::numeric_limits<Index>::max()));\n\n    \/\/ The result shape is params.shape[:batch_dims] +\n    \/\/ indices.shape[batch_dims:] + params.shape[batch_dims+1:].\n    TensorShape result_shape;\n    for (int i = 0; i < batch_dims_; ++i) {\n      result_shape.AddDim(params.dim_size(i));\n    }\n    for (int i = batch_dims_; i < indices.dims(); ++i) {\n      result_shape.AddDim(indices.dim_size(i));\n    }\n    for (int i = batch_dims_ + 1; i < params.dims(); ++i) {\n      result_shape.AddDim(params.dim_size(i));\n    }\n\n    Tensor* out = nullptr;\n    Tensor tmp;\n    if (params.dtype() == DT_VARIANT) {\n      tmp = Tensor(DT_VARIANT, result_shape);\n      c->set_output(0, tmp);\n      out = &tmp;\n    } else {\n      OP_REQUIRES_OK(c, c->allocate_output(0, result_shape, &out));\n    }\n\n    if (N > 0) {\n      Tensor tmp_indices;\n\n      \/\/ Points to the original or updated (if batch_dims is set) indices.\n      const Tensor* op_indices = &indices;\n      if (batch_dims_ > 0) {\n        OP_REQUIRES_OK(c, c->allocate_temp(indices.dtype(), indices.shape(),\n                                           &tmp_indices));\n        functor::DenseUpdate<Device, Index, ASSIGN> copy_functor;\n        copy_functor(c->eigen_device<Device>(), tmp_indices.flat<Index>(),\n                     indices.flat<Index>());\n\n        AddBatchOffsets(c, &tmp_indices, params);\n        if (!c->status().ok()) return;\n        op_indices = &tmp_indices;\n      }\n\n      int64_t gather_dim_size = 1;\n      for (int idx = 0; idx <= batch_dims_; ++idx) {\n        gather_dim_size *= params.dim_size(idx);\n      }\n      int64_t inner_size = 1;\n      for (int i = batch_dims_ + 1; i < params.dims(); ++i) {\n        inner_size *= params.dim_size(i);\n      }\n      auto params_flat = params.shaped<T, 3>({1, gather_dim_size, inner_size});\n      const auto indices_flat = op_indices->flat<Index>();\n      auto out_flat = out->shaped<T, 3>({1, N, out->NumElements() \/ N});\n\n      functor::GatherFunctor<Device, T, Index> functor;\n      int64_t bad_i = functor(c, params_flat, indices_flat, out_flat);\n\n      OP_REQUIRES(\n          c, bad_i < 0,\n          errors::InvalidArgument(\n              \"indices\", SliceDebugString(indices.shape(), bad_i), \" = \",\n              indices_flat(bad_i), \" is not in [0, \", params.dim_size(0), \")\"));\n    }\n  }","target":0,"code_token_length":953,"total_token_length":1189,"max_tokens_setting":2048}
+{"idx":247618,"func":"TEST_P(SslSocketTest, RevokedIntermediateCertificate) {\n\n  \/\/ This should succeed, since the crl chain is complete.\n  \/\/\n  \/\/ Trust chain contains:\n  \/\/  - Root authority certificate (i.e., ca_cert.pem)\n  \/\/  - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n  \/\/\n  \/\/ Certificate revocation list contains:\n  \/\/  - Root authority certificate revocation list (i.e., ca_cert.crl)\n  \/\/  - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl)\n  const std::string complete_server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain.pem\"\n      crl:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain.crl\"\n)EOF\";\n\n  \/\/ This should fail, since the crl chain is incomplete.\n  \/\/\n  \/\/ Trust chain contains:\n  \/\/  - Root authority certificate (i.e., ca_cert.pem)\n  \/\/  - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n  \/\/\n  \/\/ Certificate revocation list contains:\n  \/\/  - Root authority certificate revocation list (i.e., ca_cert.crl)\n  \/\/\n  \/\/ Certificate revocation list omits:\n  \/\/  - Root authority certificate revocation list (i.e., ca_cert.crl)\n  const std::string incomplete_server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain.pem\"\n      crl:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert.crl\"\n)EOF\";\n\n  \/\/ This should fail, since the certificate has been revoked.\n  const std::string revoked_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_key.pem\"\n)EOF\";\n\n  \/\/ This should succeed, since the certificate has not been revoked.\n  const std::string unrevoked_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns4_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns4_key.pem\"\n)EOF\";\n\n  \/\/ Ensure that incomplete crl chains fail with revoked certificates.\n  TestUtilOptions incomplete_revoked_test_options(revoked_client_ctx_yaml,\n                                                  incomplete_server_ctx_yaml, false, GetParam());\n  testUtil(incomplete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n  \/\/ Ensure that incomplete crl chains fail with unrevoked certificates.\n  TestUtilOptions incomplete_unrevoked_test_options(unrevoked_client_ctx_yaml,\n                                                    incomplete_server_ctx_yaml, false, GetParam());\n  testUtil(incomplete_unrevoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_CRL));\n\n  \/\/ Ensure that complete crl chains fail with revoked certificates.\n  TestUtilOptions complete_revoked_test_options(revoked_client_ctx_yaml, complete_server_ctx_yaml,\n                                                false, GetParam());\n  testUtil(complete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n  \/\/ Ensure that complete crl chains succeed with unrevoked certificates.\n  TestUtilOptions complete_unrevoked_test_options(unrevoked_client_ctx_yaml,\n                                                  complete_server_ctx_yaml, true, GetParam());\n  testUtil(complete_unrevoked_test_options.setExpectedSerialNumber(TEST_SAN_DNS4_CERT_SERIAL));\n}","target":0,"code_token_length":1029,"total_token_length":1265,"max_tokens_setting":2048}
+{"idx":413604,"func":"R_API int r_core_anal_fcn_list(RCore *core, const char *input, const char *rad) {\n\tchar temp[64];\n\tr_return_val_if_fail (core && core->anal, 0);\n\tif (r_list_empty (core->anal->fcns)) {\n\t\tif (*rad == 'j') {\n\t\t\tr_cons_println (\"[]\");\n\t\t}\n\t\treturn 0;\n\t}\n\tif (*rad == '.') {\n\t\tRList *fcns = r_anal_get_functions_in (core->anal, core->offset);\n\t\tif (!fcns || r_list_empty (fcns)) {\n\t\t\teprintf (\"No functions at current address.\\n\");\n\t\t\tr_list_free (fcns);\n\t\t\treturn -1;\n\t\t}\n\t\tfcn_list_default (core, fcns, false);\n\t\tr_list_free (fcns);\n\t\treturn 0;\n\t}\n\n\tif (rad && (*rad == 'l' || *rad == 'j')) {\n\t\tfcnlist_gather_metadata (core->anal, core->anal->fcns);\n\t}\n\n\tconst char *name = input;\n\tut64 addr = core->offset;\n\tif (input && *input) {\n\t\tname = input + 1;\n\t\taddr = r_num_math (core->num, name);\n\t}\n\n\tRList *fcns = r_list_newf (NULL);\n\tif (!fcns) {\n\t\treturn -1;\n\t}\n\tRListIter *iter;\n\tRAnalFunction *fcn;\n\tr_list_foreach (core->anal->fcns, iter, fcn) {\n\t\tif (!input || r_anal_function_contains (fcn, addr) || (!strcmp (name, fcn->name))) {\n\t\t\tr_list_append (fcns, fcn);\n\t\t}\n\t}\n\n\t\/\/ Use afls[asn] to sort by address, size or name, dont sort it here .. r_list_sort (fcns, &cmpfcn);\n\tif (!rad) {\n\t\tfcn_list_default (core, fcns, false);\n\t\tr_list_free (fcns);\n\t\treturn 0;\n\t}\n\tswitch (*rad) {\n\tcase '+':\n\t\tr_core_anal_fcn_list_size (core);\n\t\tbreak;\n\tcase '=': { \/\/ afl=\n\t\tr_list_sort (fcns, cmpaddr);\n\t\tRList *flist = r_list_newf ((RListFree) r_listinfo_free);\n\t\tif (!flist) {\n\t\t\tr_list_free (fcns);\n\t\t\treturn -1;\n\t\t}\n\t\tls_foreach (fcns, iter, fcn) {\n\t\t\tRInterval inter = {r_anal_function_min_addr (fcn), r_anal_function_linear_size (fcn) };\n\t\t\tRListInfo *info = r_listinfo_new (r_core_anal_fcn_name (core, fcn), inter, inter, -1, sdb_itoa (fcn->bits, temp, 10));\n\t\t\tif (!info) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tr_list_append (flist, info);\n\t\t}\n\t\tRTable *table = r_core_table (core, \"functions\");\n\t\tr_table_visual_list (table, flist, core->offset, core->blocksize,\n\t\t\tr_cons_get_size (NULL), r_config_get_i (core->config, \"scr.color\"));\n\t\tr_cons_printf (\"\\n%s\\n\", r_table_tostring (table));\n\t\tr_table_free (table);\n\t\tr_list_free (flist);\n\t\tbreak;\n\t\t}\n\tcase ',': \/\/ \"afl,\" \"afl,j\"\n\tcase 't': \/\/ \"aflt\" \"afltj\"\n\t\tif (rad[1] == 'j') {\n\t\t\tfcn_list_table (core, r_str_trim_head_ro (rad + 2), 'j');\n\t\t} else {\n\t\t\tfcn_list_table (core, r_str_trim_head_ro (rad + 1), rad[1]);\n\t\t}\n\t\tbreak;\n\tcase 'l': \/\/ \"afll\" \"afllj\"\n\t\tif (rad[1] == 'j') {\n\t\t\tfcn_list_verbose_json (core, fcns);\n\t\t} else {\n\t\t\tchar *sp = strchr (rad, ' ');\n\t\t\tfcn_list_verbose (core, fcns, sp?sp+1: NULL);\n\t\t}\n\t\tbreak;\n\tcase 'q':\n\t\tif (rad[1] == 'j') {\n\t\t\tfcn_list_json (core, fcns, true);\n\t\t} else {\n\t\t\tfcn_list_default (core, fcns, true);\n\t\t}\n\t\tbreak;\n\tcase 'j':\n\t\tfcn_list_json (core, fcns, false);\n\t\tbreak;\n\tcase '*':\n\t\tfcn_list_detail (core, fcns);\n\t\tbreak;\n\tcase 'm': \/\/ \"aflm\"\n\t\t{\n\t\t\tchar mode = 'm';\n\t\t\tif (rad[1] != 0) {\n\t\t\t\tif (rad[1] == 'j') { \/\/ \"aflmj\"\n\t\t\t\t\tmode = 'j';\n\t\t\t\t} else if (rad[1] == 'q') { \/\/ \"aflmq\"\n\t\t\t\t\tmode = 'q';\n\t\t\t\t}\n\t\t\t}\n\t\t\tfcn_print_makestyle (core, fcns, mode);\n\t\t\tbreak;\n\t\t}\n\tcase 1:\n\t\tfcn_list_legacy (core, fcns);\n\t\tbreak;\n\tdefault:\n\t\tfcn_list_default (core, fcns, false);\n\t\tbreak;\n\t}\n\tr_list_free (fcns);\n\treturn 0;\n}","target":0,"code_token_length":1152,"total_token_length":1388,"max_tokens_setting":2048}
+{"idx":509526,"func":"int maria_check_definition(MARIA_KEYDEF *t1_keyinfo,\n                           MARIA_COLUMNDEF *t1_recinfo,\n                           uint t1_keys, uint t1_recs,\n                           MARIA_KEYDEF *t2_keyinfo,\n                           MARIA_COLUMNDEF *t2_recinfo,\n                           uint t2_keys, uint t2_recs, bool strict)\n{\n  uint i, j;\n  DBUG_ENTER(\"maria_check_definition\");\n  if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys))\n  {\n    DBUG_PRINT(\"error\", (\"Number of keys differs: t1_keys=%u, t2_keys=%u\",\n                         t1_keys, t2_keys));\n    DBUG_RETURN(1);\n  }\n  if (t1_recs != t2_recs)\n  {\n    DBUG_PRINT(\"error\", (\"Number of recs differs: t1_recs=%u, t2_recs=%u\",\n                         t1_recs, t2_recs));\n    DBUG_RETURN(1);\n  }\n  for (i= 0; i < t1_keys; i++)\n  {\n    HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg;\n    HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg;\n    if (t1_keyinfo[i].flag & HA_FULLTEXT && t2_keyinfo[i].flag & HA_FULLTEXT)\n      continue;\n    else if (t1_keyinfo[i].flag & HA_FULLTEXT ||\n             t2_keyinfo[i].flag & HA_FULLTEXT)\n    {\n       DBUG_PRINT(\"error\", (\"Key %d has different definition\", i));\n       DBUG_PRINT(\"error\", (\"t1_fulltext= %d, t2_fulltext=%d\",\n                            MY_TEST(t1_keyinfo[i].flag & HA_FULLTEXT),\n                            MY_TEST(t2_keyinfo[i].flag & HA_FULLTEXT)));\n       DBUG_RETURN(1);\n    }\n    if (t1_keyinfo[i].flag & HA_SPATIAL && t2_keyinfo[i].flag & HA_SPATIAL)\n      continue;\n    else if (t1_keyinfo[i].flag & HA_SPATIAL ||\n             t2_keyinfo[i].flag & HA_SPATIAL)\n    {\n       DBUG_PRINT(\"error\", (\"Key %d has different definition\", i));\n       DBUG_PRINT(\"error\", (\"t1_spatial= %d, t2_spatial=%d\",\n                            MY_TEST(t1_keyinfo[i].flag & HA_SPATIAL),\n                            MY_TEST(t2_keyinfo[i].flag & HA_SPATIAL)));\n       DBUG_RETURN(1);\n    }\n    if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs ||\n        t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg)\n    {\n      DBUG_PRINT(\"error\", (\"Key %d has different definition\", i));\n      DBUG_PRINT(\"error\", (\"t1_keysegs=%d, t1_key_alg=%d\",\n                           t1_keyinfo[i].keysegs, t1_keyinfo[i].key_alg));\n      DBUG_PRINT(\"error\", (\"t2_keysegs=%d, t2_key_alg=%d\",\n                           t2_keyinfo[i].keysegs, t2_keyinfo[i].key_alg));\n      DBUG_RETURN(1);\n    }\n    for (j=  t1_keyinfo[i].keysegs; j--;)\n    {\n      uint8 t1_keysegs_j__type= t1_keysegs[j].type;\n      \/*\n        Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is\n        always HA_KEYTYPE_VARTEXT2. In 4.1 we had only the equivalent of\n        HA_KEYTYPE_VARTEXT1. Since we treat both the same on MyISAM\n        level, we can ignore a mismatch between these types.\n      *\/\n      if ((t1_keysegs[j].flag & HA_BLOB_PART) &&\n          (t2_keysegs[j].flag & HA_BLOB_PART))\n      {\n        if ((t1_keysegs_j__type == HA_KEYTYPE_VARTEXT2) &&\n            (t2_keysegs[j].type == HA_KEYTYPE_VARTEXT1))\n          t1_keysegs_j__type= HA_KEYTYPE_VARTEXT1; \/* purecov: tested *\/\n        else if ((t1_keysegs_j__type == HA_KEYTYPE_VARBINARY2) &&\n                 (t2_keysegs[j].type == HA_KEYTYPE_VARBINARY1))\n          t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; \/* purecov: inspected *\/\n      }\n\n      if (t1_keysegs_j__type != t2_keysegs[j].type ||\n          t1_keysegs[j].language != t2_keysegs[j].language ||\n          t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||\n          t1_keysegs[j].length != t2_keysegs[j].length)\n      {\n        DBUG_PRINT(\"error\", (\"Key segment %d (key %d) has different \"\n                             \"definition\", j, i));\n        DBUG_PRINT(\"error\", (\"t1_type=%d, t1_language=%d, t1_null_bit=%d, \"\n                             \"t1_length=%d\",\n                             t1_keysegs[j].type, t1_keysegs[j].language,\n                             t1_keysegs[j].null_bit, t1_keysegs[j].length));\n        DBUG_PRINT(\"error\", (\"t2_type=%d, t2_language=%d, t2_null_bit=%d, \"\n                             \"t2_length=%d\",\n                             t2_keysegs[j].type, t2_keysegs[j].language,\n                             t2_keysegs[j].null_bit, t2_keysegs[j].length));\n\n        DBUG_RETURN(1);\n      }\n    }\n  }\n\n  for (i= 0; i < t1_recs; i++)\n  {\n    MARIA_COLUMNDEF *t1_rec= &t1_recinfo[i];\n    MARIA_COLUMNDEF *t2_rec= &t2_recinfo[i];\n    \/*\n      FIELD_SKIP_ZERO can be changed to FIELD_NORMAL in maria_create,\n      see NOTE1 in ma_create.c\n    *\/\n    if ((t1_rec->type != t2_rec->type &&\n         !(t1_rec->type == (int) FIELD_SKIP_ZERO &&\n           t1_rec->length == 1 &&\n           t2_rec->type == (int) FIELD_NORMAL)) ||\n        t1_rec->length != t2_rec->length ||\n        t1_rec->null_bit != t2_rec->null_bit)\n    {\n      DBUG_PRINT(\"error\", (\"Field %d has different definition\", i));\n      DBUG_PRINT(\"error\", (\"t1_type=%d, t1_length=%d, t1_null_bit=%d\",\n                           t1_rec->type, t1_rec->length, t1_rec->null_bit));\n      DBUG_PRINT(\"error\", (\"t2_type=%d, t2_length=%d, t2_null_bit=%d\",\n                           t2_rec->type, t2_rec->length, t2_rec->null_bit));\n      DBUG_RETURN(1);\n    }\n  }\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":1576,"total_token_length":1812,"max_tokens_setting":2048}
+{"idx":279951,"func":"check_overwrite(\n    exarg_T\t*eap,\n    buf_T\t*buf,\n    char_u\t*fname,\t    \/\/ file name to be used (can differ from\n\t\t\t    \/\/ buf->ffname)\n    char_u\t*ffname,    \/\/ full path version of fname\n    int\t\tother)\t    \/\/ writing under other name\n{\n    \/*\n     * Write to another file or b_flags set or not writing the whole file:\n     * overwriting only allowed with '!'.\n     *\/\n    if (       (other\n\t\t|| (buf->b_flags & BF_NOTEDITED)\n\t\t|| ((buf->b_flags & BF_NEW)\n\t\t    && vim_strchr(p_cpo, CPO_OVERNEW) == NULL)\n\t\t|| (buf->b_flags & BF_READERR))\n\t    && !p_wa\n\t    && vim_fexists(ffname))\n    {\n\tif (!eap->forceit && !eap->append)\n\t{\n#ifdef UNIX\n\t    \/\/ with UNIX it is possible to open a directory\n\t    if (mch_isdir(ffname))\n\t    {\n\t\tsemsg(_(e_src_is_directory), ffname);\n\t\treturn FAIL;\n\t    }\n#endif\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\t    if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))\n\t    {\n\t\tchar_u\tbuff[DIALOG_MSG_SIZE];\n\n\t\tdialog_msg(buff, _(\"Overwrite existing file \\\"%s\\\"?\"), fname);\n\t\tif (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES)\n\t\t    return FAIL;\n\t\teap->forceit = TRUE;\n\t    }\n\t    else\n#endif\n\t    {\n\t\temsg(_(e_file_exists));\n\t\treturn FAIL;\n\t    }\n\t}\n\n\t\/\/ For \":w! filename\" check that no swap file exists for \"filename\".\n\tif (other && !emsg_silent)\n\t{\n\t    char_u\t*dir;\n\t    char_u\t*p;\n\t    int\t\tr;\n\t    char_u\t*swapname;\n\n\t    \/\/ We only try the first entry in 'directory', without checking if\n\t    \/\/ it's writable.  If the \".\" directory is not writable the write\n\t    \/\/ will probably fail anyway.\n\t    \/\/ Use 'shortname' of the current buffer, since there is no buffer\n\t    \/\/ for the written file.\n\t    if (*p_dir == NUL)\n\t    {\n\t\tdir = alloc(5);\n\t\tif (dir == NULL)\n\t\t    return FAIL;\n\t\tSTRCPY(dir, \".\");\n\t    }\n\t    else\n\t    {\n\t\tdir = alloc(MAXPATHL);\n\t\tif (dir == NULL)\n\t\t    return FAIL;\n\t\tp = p_dir;\n\t\tcopy_option_part(&p, dir, MAXPATHL, \",\");\n\t    }\n\t    swapname = makeswapname(fname, ffname, curbuf, dir);\n\t    vim_free(dir);\n\t    r = vim_fexists(swapname);\n\t    if (r)\n\t    {\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\t\tif (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))\n\t\t{\n\t\t    char_u\tbuff[DIALOG_MSG_SIZE];\n\n\t\t    dialog_msg(buff,\n\t\t\t    _(\"Swap file \\\"%s\\\" exists, overwrite anyway?\"),\n\t\t\t\t\t\t\t\t    swapname);\n\t\t    if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)\n\t\t\t\t\t\t\t\t   != VIM_YES)\n\t\t    {\n\t\t\tvim_free(swapname);\n\t\t\treturn FAIL;\n\t\t    }\n\t\t    eap->forceit = TRUE;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    semsg(_(e_swap_file_exists_str_silent_overrides), swapname);\n\t\t    vim_free(swapname);\n\t\t    return FAIL;\n\t\t}\n\t    }\n\t    vim_free(swapname);\n\t}\n    }\n    return OK;\n}","target":0,"code_token_length":795,"total_token_length":1031,"max_tokens_setting":2048}
+{"idx":220450,"func":"Status ComputeConv2DDimension(const Conv2DParameters& params,\n                              const Tensor& input, const Tensor& filter,\n                              Conv2DDimensions* dimensions) {\n  \/\/ Check that 2D convolution input and filter have exactly 4 dimensions.\n  TF_REQUIRES(input.dims() == 4,\n              errors::InvalidArgument(\"input must be 4-dimensional\",\n                                      input.shape().DebugString()));\n  TF_REQUIRES(filter.dims() == 4,\n              errors::InvalidArgument(\"filter must be 4-dimensional: \",\n                                      filter.shape().DebugString()));\n  for (int i = 0; i < 3; i++) {\n    TF_REQUIRES(\n        FastBoundsCheck(filter.dim_size(i), std::numeric_limits<int>::max()),\n        errors::InvalidArgument(\"filter too large\"));\n  }\n\n  \/\/ The last dimension for input is in_depth. Check that it is the same as the\n  \/\/ filter's in_depth or it is evenly divisible by filter's in_depth.\n  const int64_t in_depth_raw = GetTensorDim(input, params.data_format, 'C');\n  const int64_t patch_depth_raw = filter.dim_size(2);\n  TF_REQUIRES(FastBoundsCheck(in_depth_raw, std::numeric_limits<int>::max()),\n              errors::InvalidArgument(\"Input depth too large\"));\n  TF_REQUIRES(FastBoundsCheck(patch_depth_raw, std::numeric_limits<int>::max()),\n              errors::InvalidArgument(\"Patch depth too large\"));\n  const int in_depth = static_cast<int>(in_depth_raw);\n  const int patch_depth = static_cast<int>(patch_depth_raw);\n  TF_REQUIRES(patch_depth > 0,\n              errors::InvalidArgument(\n                  \"filter depth must be stricly positive, got \", patch_depth));\n  TF_REQUIRES(in_depth % patch_depth == 0,\n              errors::InvalidArgument(\n                  \"input depth must be evenly divisible by filter depth: \",\n                  in_depth, \" vs \", patch_depth));\n\n  \/\/ The last dimension for filter is out_depth.\n  const int out_depth = static_cast<int>(filter.dim_size(3));\n\n  \/\/ The second dimension for input is rows\/height.\n  \/\/ The first dimension for filter is rows\/height.\n  const int64_t input_rows_raw = GetTensorDim(input, params.data_format, 'H');\n  TF_REQUIRES(FastBoundsCheck(input_rows_raw, std::numeric_limits<int>::max()),\n              errors::InvalidArgument(\"Input rows too large\"));\n  const int input_rows = static_cast<int>(input_rows_raw);\n  const int filter_rows = static_cast<int>(filter.dim_size(0));\n\n  \/\/ The third dimension for input is columns\/width.\n  \/\/ The second dimension for filter is columns\/width.\n  const int64_t input_cols_raw = GetTensorDim(input, params.data_format, 'W');\n  TF_REQUIRES(FastBoundsCheck(input_cols_raw, std::numeric_limits<int>::max()),\n              errors::InvalidArgument(\"Input cols too large\"));\n  const int input_cols = static_cast<int>(input_cols_raw);\n  const int filter_cols = static_cast<int>(filter.dim_size(1));\n\n  \/\/ The first dimension for input is batch.\n  const int64_t batch_raw = GetTensorDim(input, params.data_format, 'N');\n  TF_REQUIRES(FastBoundsCheck(batch_raw, std::numeric_limits<int>::max()),\n              errors::InvalidArgument(\"batch is too large\"));\n  const int batch = static_cast<int>(batch_raw);\n\n  \/\/ Take the stride and dilation from the second and third dimensions only (we\n  \/\/ do not support striding or dilation on the batch or depth dimension).\n  const int stride_rows = GetTensorDim(params.strides, params.data_format, 'H');\n  const int stride_cols = GetTensorDim(params.strides, params.data_format, 'W');\n  const int dilation_rows =\n      GetTensorDim(params.dilations, params.data_format, 'H');\n  const int dilation_cols =\n      GetTensorDim(params.dilations, params.data_format, 'W');\n\n  int64_t pad_rows_before, pad_rows_after, pad_cols_before, pad_cols_after;\n  if (params.padding == Padding::EXPLICIT) {\n    GetExplicitPaddingForDim(params.explicit_paddings, params.data_format, 'H',\n                             &pad_rows_before, &pad_rows_after);\n    GetExplicitPaddingForDim(params.explicit_paddings, params.data_format, 'W',\n                             &pad_cols_before, &pad_cols_after);\n  }\n\n  \/\/ Compute windowed output sizes for rows and columns.\n  int64_t out_rows = 0, out_cols = 0;\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeVerboseV2(\n      input_rows, filter_rows, dilation_rows, stride_rows, params.padding,\n      &out_rows, &pad_rows_before, &pad_rows_after));\n  TF_RETURN_IF_ERROR(GetWindowedOutputSizeVerboseV2(\n      input_cols, filter_cols, dilation_cols, stride_cols, params.padding,\n      &out_cols, &pad_cols_before, &pad_cols_after));\n\n  dimensions->batch = batch;\n  dimensions->input_rows = input_rows;\n  dimensions->input_cols = input_cols;\n  dimensions->in_depth = in_depth;\n  dimensions->filter_rows = filter_rows;\n  dimensions->filter_cols = filter_cols;\n  dimensions->patch_depth = patch_depth;\n  dimensions->out_depth = out_depth;\n  dimensions->stride_rows = stride_rows;\n  dimensions->stride_cols = stride_cols;\n  dimensions->dilation_rows = dilation_rows;\n  dimensions->dilation_cols = dilation_cols;\n  dimensions->out_rows = out_rows;\n  dimensions->out_cols = out_cols;\n  dimensions->pad_rows_before = pad_rows_before;\n  dimensions->pad_rows_after = pad_rows_after;\n  dimensions->pad_cols_before = pad_cols_before;\n  dimensions->pad_cols_after = pad_cols_after;\n\n  return Status::OK();\n}","target":0,"code_token_length":1231,"total_token_length":1467,"max_tokens_setting":2048}
+{"idx":210701,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tsquashfs_dir_header_3 dirh;\n\tchar buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tsquashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;\n\tlong long start;\n\tint bytes;\n\tint dir_count, size;\n\tstruct dir_ent *new_dir;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: malloc failed!\\n\");\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = 0;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 3)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\tbytes = lookup_entry(directory_table_hash, start);\n\n\tif(bytes == -1)\n\t\tEXIT_UNSQUASH(\"squashfs_opendir: directory block %d not \"\n\t\t\t\"found!\\n\", block_start);\n\n\tbytes += (*i)->offset;\n\tsize = (*i)->data + bytes - 3;\n\n\twhile(bytes < size) {\t\t\t\n\t\tif(swap) {\n\t\t\tsquashfs_dir_header_3 sdirh;\n\t\t\tmemcpy(&sdirh, directory_table + bytes, sizeof(sdirh));\n\t\t\tSQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);\n\t\t} else\n\t\t\tmemcpy(&dirh, directory_table + bytes, sizeof(dirh));\n\t\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_entry_3 sdire;\n\t\t\t\tmemcpy(&sdire, directory_table + bytes,\n\t\t\t\t\tsizeof(sdire));\n\t\t\t\tSQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);\n\t\t\t} else\n\t\t\t\tmemcpy(dire, directory_table + bytes,\n\t\t\t\t\tsizeof(*dire));\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tmemcpy(dire->name, directory_table + bytes,\n\t\t\t\tdire->size + 1);\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\t\t\tif((dir->dir_count % DIR_ENT_SIZE) == 0) {\n\t\t\t\tnew_dir = realloc(dir->dirs, (dir->dir_count +\n\t\t\t\t\tDIR_ENT_SIZE) * sizeof(struct dir_ent));\n\t\t\t\tif(new_dir == NULL)\n\t\t\t\t\tEXIT_UNSQUASH(\"squashfs_opendir: \"\n\t\t\t\t\t\t\"realloc failed!\\n\");\n\t\t\t\tdir->dirs = new_dir;\n\t\t\t}\n\t\t\tstrcpy(dir->dirs[dir->dir_count].name, dire->name);\n\t\t\tdir->dirs[dir->dir_count].start_block =\n\t\t\t\tdirh.start_block;\n\t\t\tdir->dirs[dir->dir_count].offset = dire->offset;\n\t\t\tdir->dirs[dir->dir_count].type = dire->type;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tfree(dir->dirs);\n\tfree(dir);\n\treturn NULL;\n}","target":1,"code_token_length":979,"total_token_length":1215,"max_tokens_setting":2048}
+{"idx":383337,"func":"int gdImageSelectiveBlur( gdImagePtr src)\n{\n\tint         x, y, i, j;\n\tfloat       new_r, new_g, new_b;\n\tint         new_pxl, cpxl, pxl, new_a=0;\n\tfloat flt_r [3][3];\n\tfloat flt_g [3][3];\n\tfloat flt_b [3][3];\n\tfloat flt_r_sum, flt_g_sum, flt_b_sum;\n\n\tgdImagePtr srcback;\n\ttypedef int (*FuncPtr)(gdImagePtr, int, int);\n\tFuncPtr f;\n\n\tif (src==NULL) {\n\t\treturn 0;\n\t}\n\t\n\t\/* We need the orinal image with each safe neoghb. pixel *\/\n\tsrcback = gdImageCreateTrueColor (src->sx, src->sy);\n\tgdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);\n  \n\tif (srcback==NULL) {\n\t\treturn 0;\n\t}\n\n\tf = GET_PIXEL_FUNCTION(src);\n\n\tfor(y = 0; y<src->sy; y++) {\n\t\tfor (x=0; x<src->sx; x++) {\n\t\t      flt_r_sum = flt_g_sum = flt_b_sum = 0.0;\n\t\t\tcpxl = f(src, x, y); \n\n\t\t\tfor (j=0; j<3; j++) {\n\t\t\t\tfor (i=0; i<3; i++) {\n\t\t\t\t\tif ((j == 1) && (i == 1)) {\n\t\t\t\t\t\tflt_r[1][1] = flt_g[1][1] = flt_b[1][1] = 0.5;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpxl = f(src, x-(3>>1)+i, y-(3>>1)+j); \n\t\t\t\t\t\tnew_a = gdImageAlpha(srcback, pxl);\n\n\t\t\t\t\t\tnew_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl));\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (new_r < 0.0f) {\n\t\t\t\t\t\t\tnew_r = -new_r;\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tif (new_r != 0) {\n\t\t\t\t\t\t\tflt_r[j][i] = 1.0f\/new_r;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tflt_r[j][i] = 1.0f;\n\t\t\t\t\t\t}\t\n\n\t\t\t\t\t\tnew_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl));\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (new_g < 0.0f) {\n\t\t\t\t\t\t\tnew_g = -new_g;\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tif (new_g != 0) {\n\t\t\t\t\t\t\tflt_g[j][i] = 1.0f\/new_g;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tflt_g[j][i] = 1.0f;\n\t\t\t\t\t\t}\t\n\n\t\t\t\t\t\tnew_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl));\n\n\t\t\t\t\t\tif (new_b < 0.0f) {\n\t\t\t\t\t\t\tnew_b = -new_b;\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tif (new_b != 0) {\n\t\t\t\t\t\t\tflt_b[j][i] = 1.0f\/new_b;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tflt_b[j][i] = 1.0f;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\tflt_r_sum += flt_r[j][i];\n\t\t\t\t\tflt_g_sum += flt_g[j][i];\n\t\t\t\t\tflt_b_sum += flt_b [j][i];\n\t\t\t\t}\n\t\t\t}\n      \n\t\t\tfor (j=0; j<3; j++) {\n\t\t\t\tfor (i=0; i<3; i++) {\n\t\t\t\t\tif (flt_r_sum != 0.0) {\n\t\t\t\t\t\tflt_r[j][i] \/= flt_r_sum;\n\t\t\t\t\t}\t\n\t\t\t\t\tif (flt_g_sum != 0.0) {\n\t\t\t\t\t\tflt_g[j][i] \/= flt_g_sum;\n\t\t\t\t\t}\t\n\t\t\t\t\tif (flt_b_sum != 0.0) {\n\t\t\t\t\t\tflt_b [j][i] \/= flt_b_sum;\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnew_r = new_g = new_b = 0.0;\n\t\t\t\n\t\t\tfor (j=0; j<3; j++) {\n\t\t\t\tfor (i=0; i<3; i++) {\n\t\t\t\t\tpxl = f(src, x-(3>>1)+i, y-(3>>1)+j);\n\t\t\t\t\tnew_r += (float)gdImageRed(srcback, pxl) * flt_r[j][i];\n\t\t\t\t\tnew_g += (float)gdImageGreen(srcback, pxl) * flt_g[j][i];\n\t\t\t\t\tnew_b += (float)gdImageBlue(srcback, pxl) * flt_b[j][i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnew_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);\n\t\t\tnew_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);\n\t\t\tnew_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);\n\t\t\tnew_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);\n\t\t\tif (new_pxl == -1) {\n\t\t\t\tnew_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);\n\t\t\t}\n\t\t\tif ((y >= 0) && (y < src->sy)) {\n\t\t\t\tgdImageSetPixel (src, x, y, new_pxl);\n\t\t\t}      \n\t\t}\n\t}\n\tgdImageDestroy(srcback);\n\treturn 1;\n}","target":0,"code_token_length":1301,"total_token_length":1537,"max_tokens_setting":2048}
+{"idx":95897,"func":"void AddChromeFrameWorkItems(const InstallationState& original_state,\n                             const InstallerState& installer_state,\n                             const FilePath& setup_path,\n                             const Version& new_version,\n                             const Product& product,\n                             WorkItemList* list) {\n  DCHECK(product.is_chrome_frame());\n  if (!installer_state.is_multi_install()) {\n    VLOG(1) << \"Not adding GCF specific work items for single install.\";\n    return;\n  }\n\n  std::wstring version_key(product.distribution()->GetVersionKey());\n  bool ready_mode = product.HasOption(kOptionReadyMode);\n  HKEY root = installer_state.root_key();\n  const bool is_install =\n      (installer_state.operation() != InstallerState::UNINSTALL);\n  bool update_chrome_uninstall_command = false;\n  BrowserDistribution* dist =\n      installer_state.multi_package_binaries_distribution();\n  if (ready_mode) {\n    list->AddCreateRegKeyWorkItem(root, dist->GetStateKey());\n    list->AddSetRegValueWorkItem(root, dist->GetStateKey(),\n        kChromeFrameReadyModeField,\n        static_cast<int64>(is_install ? 1 : 0),  \/\/ The value we want to set.\n        is_install ? false : true);  \/\/ Overwrite existing value.\n    if (is_install) {\n      FilePath installer_path(installer_state\n          .GetInstallerDirectory(new_version).Append(setup_path.BaseName()));\n\n      CommandLine basic_cl(installer_path);\n      basic_cl.AppendSwitch(switches::kChromeFrame);\n      basic_cl.AppendSwitch(switches::kMultiInstall);\n\n      if (installer_state.system_install())\n        basic_cl.AppendSwitch(switches::kSystemLevel);\n\n      CommandLine temp_opt_out(basic_cl);\n      temp_opt_out.AppendSwitch(switches::kChromeFrameReadyModeTempOptOut);\n\n      CommandLine end_temp_opt_out(basic_cl);\n      end_temp_opt_out.AppendSwitch(\n          switches::kChromeFrameReadyModeEndTempOptOut);\n\n      CommandLine opt_out(installer_path);\n      AppendUninstallCommandLineFlags(installer_state, product, &opt_out);\n      opt_out.AppendSwitch(switches::kForceUninstall);\n\n      CommandLine opt_in(basic_cl);\n      opt_in.AppendSwitch(switches::kChromeFrameReadyModeOptIn);\n\n      list->AddSetRegValueWorkItem(root, version_key,\n                                   google_update::kRegCFTempOptOutCmdField,\n                                   temp_opt_out.command_line_string(), true);\n      list->AddSetRegValueWorkItem(root, version_key,\n                                   google_update::kRegCFEndTempOptOutCmdField,\n                                   end_temp_opt_out.command_line_string(),\n                                   true);\n      list->AddSetRegValueWorkItem(root, version_key,\n                                   google_update::kRegCFOptOutCmdField,\n                                   opt_out.command_line_string(), true);\n      list->AddSetRegValueWorkItem(root, version_key,\n                                   google_update::kRegCFOptInCmdField,\n                                   opt_in.command_line_string(), true);\n    } else {\n      update_chrome_uninstall_command =\n          (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) ==\n           NULL);\n    }\n  } else {\n\n    list->AddDeleteRegValueWorkItem(root, dist->GetStateKey(),\n        kChromeFrameReadyModeField);\n\n    const Product* chrome =\n        installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);\n    if (chrome) {\n    } else {\n      const ProductState* chrome_state = original_state.GetProductState(\n          installer_state.system_install(),\n          BrowserDistribution::CHROME_BROWSER);\n      update_chrome_uninstall_command =\n          (chrome_state != NULL) && chrome_state->is_multi_install();\n    }\n  }\n\n  if (!ready_mode || !is_install) {\n    list->AddDeleteRegValueWorkItem(root, version_key,\n                                    google_update::kRegCFTempOptOutCmdField);\n    list->AddDeleteRegValueWorkItem(root, version_key,\n                                    google_update::kRegCFEndTempOptOutCmdField);\n    list->AddDeleteRegValueWorkItem(root, version_key,\n                                    google_update::kRegCFOptOutCmdField);\n    list->AddDeleteRegValueWorkItem(root, version_key,\n                                    google_update::kRegCFOptInCmdField);\n  }\n\n  if (update_chrome_uninstall_command) {\n    const ProductState* chrome_state = original_state.GetProductState(\n        installer_state.system_install(),\n        BrowserDistribution::CHROME_BROWSER);\n    if (chrome_state != NULL) {\n      DCHECK(chrome_state->is_multi_install());\n      Product chrome(BrowserDistribution::GetSpecificDistribution(\n                         BrowserDistribution::CHROME_BROWSER));\n      chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command());\n      AddUninstallShortcutWorkItems(installer_state, setup_path,\n                                    chrome_state->version(), list, chrome);\n    } else {\n      NOTREACHED() << \"What happened to Chrome?\";\n    }\n  }\n}\n","target":0,"code_token_length":1023,"total_token_length":1259,"max_tokens_setting":2048}
+{"idx":238606,"func":"static int check_stack_read_fixed_off(struct bpf_verifier_env *env,\n\t\t\t\t      \/* func where src register points to *\/\n\t\t\t\t      struct bpf_func_state *reg_state,\n\t\t\t\t      int off, int size, int dst_regno)\n{\n\tstruct bpf_verifier_state *vstate = env->cur_state;\n\tstruct bpf_func_state *state = vstate->frame[vstate->curframe];\n\tint i, slot = -off - 1, spi = slot \/ BPF_REG_SIZE;\n\tstruct bpf_reg_state *reg;\n\tu8 *stype, type;\n\n\tstype = reg_state->stack[spi].slot_type;\n\treg = ®_state->stack[spi].spilled_ptr;\n\n\tif (is_spilled_reg(®_state->stack[spi])) {\n\t\tu8 spill_size = 1;\n\n\t\tfor (i = BPF_REG_SIZE - 1; i > 0 && stype[i - 1] == STACK_SPILL; i--)\n\t\t\tspill_size++;\n\n\t\tif (size != BPF_REG_SIZE || spill_size != BPF_REG_SIZE) {\n\t\t\tif (reg->type != SCALAR_VALUE) {\n\t\t\t\tverbose_linfo(env, env->insn_idx, \"; \");\n\t\t\t\tverbose(env, \"invalid size of register fill\\n\");\n\t\t\t\treturn -EACCES;\n\t\t\t}\n\n\t\t\tmark_reg_read(env, reg, reg->parent, REG_LIVE_READ64);\n\t\t\tif (dst_regno < 0)\n\t\t\t\treturn 0;\n\n\t\t\tif (!(off % BPF_REG_SIZE) && size == spill_size) {\n\t\t\t\t\/* The earlier check_reg_arg() has decided the\n\t\t\t\t * subreg_def for this insn.  Save it first.\n\t\t\t\t *\/\n\t\t\t\ts32 subreg_def = state->regs[dst_regno].subreg_def;\n\n\t\t\t\tstate->regs[dst_regno] = *reg;\n\t\t\t\tstate->regs[dst_regno].subreg_def = subreg_def;\n\t\t\t} else {\n\t\t\t\tfor (i = 0; i < size; i++) {\n\t\t\t\t\ttype = stype[(slot - i) % BPF_REG_SIZE];\n\t\t\t\t\tif (type == STACK_SPILL)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (type == STACK_MISC)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tverbose(env, \"invalid read from stack off %d+%d size %d\\n\",\n\t\t\t\t\t\toff, i, size);\n\t\t\t\t\treturn -EACCES;\n\t\t\t\t}\n\t\t\t\tmark_reg_unknown(env, state->regs, dst_regno);\n\t\t\t}\n\t\t\tstate->regs[dst_regno].live |= REG_LIVE_WRITTEN;\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (dst_regno >= 0) {\n\t\t\t\/* restore register state from stack *\/\n\t\t\tstate->regs[dst_regno] = *reg;\n\t\t\t\/* mark reg as written since spilled pointer state likely\n\t\t\t * has its liveness marks cleared by is_state_visited()\n\t\t\t * which resets stack\/reg liveness for state transitions\n\t\t\t *\/\n\t\t\tstate->regs[dst_regno].live |= REG_LIVE_WRITTEN;\n\t\t} else if (__is_pointer_value(env->allow_ptr_leaks, reg)) {\n\t\t\t\/* If dst_regno==-1, the caller is asking us whether\n\t\t\t * it is acceptable to use this value as a SCALAR_VALUE\n\t\t\t * (e.g. for XADD).\n\t\t\t * We must not allow unprivileged callers to do that\n\t\t\t * with spilled pointers.\n\t\t\t *\/\n\t\t\tverbose(env, \"leaking pointer from stack off %d\\n\",\n\t\t\t\toff);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tmark_reg_read(env, reg, reg->parent, REG_LIVE_READ64);\n\t} else {\n\t\tfor (i = 0; i < size; i++) {\n\t\t\ttype = stype[(slot - i) % BPF_REG_SIZE];\n\t\t\tif (type == STACK_MISC)\n\t\t\t\tcontinue;\n\t\t\tif (type == STACK_ZERO)\n\t\t\t\tcontinue;\n\t\t\tverbose(env, \"invalid read from stack off %d+%d size %d\\n\",\n\t\t\t\toff, i, size);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tmark_reg_read(env, reg, reg->parent, REG_LIVE_READ64);\n\t\tif (dst_regno >= 0)\n\t\t\tmark_reg_stack_read(env, reg_state, off, off + size, dst_regno);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":920,"total_token_length":1156,"max_tokens_setting":2048}
+{"idx":336808,"func":"lprn_put_params(gx_device * dev, gs_param_list * plist)\n{\n    gx_device_lprn *const lprn = (gx_device_lprn *) dev;\n    int ecode = 0;\n    int code;\n    gs_param_name param_name;\n    bool ManualFeed = lprn->ManualFeed;\n    bool NegativePrint = lprn->NegativePrint;\n    bool Tumble = lprn->Tumble;\n    bool RITOff = lprn->RITOff;\n    int BlockLine = lprn->BlockLine;\n    int BlockWidth = lprn->nBw;\n    int BlockHeight = lprn->nBh;\n    bool ShowBubble = lprn->ShowBubble;\n\n    if ((code = param_read_bool(plist,\n                                (param_name = \"ManualFeed\"),\n                                &ManualFeed)) < 0) {\n        param_signal_error(plist, param_name, ecode = code);\n    }\n\n    if ((code = param_read_bool(plist,\n                                (param_name = \"NegativePrint\"),\n                                &NegativePrint)) < 0) {\n        param_signal_error(plist, param_name, ecode = code);\n    }\n    if ((code = param_read_bool(plist,\n                                (param_name = \"Tumble\"),\n                                &Tumble)) < 0) {\n        param_signal_error(plist, param_name, ecode = code);\n    }\n    if ((code = param_read_bool(plist,\n                                (param_name = \"RITOff\"),\n                                &RITOff)) < 0) {\n        param_signal_error(plist, param_name, ecode = code);\n    }\n    switch (code = param_read_int(plist,\n                                  (param_name = \"BlockWidth\"),\n                                  &BlockWidth)) {\n        case 0:\n            if (BlockWidth < 0)\n                ecode = gs_error_rangecheck;\n            else\n                break;\n            goto bwidthe;\n        default:\n            ecode = code;\n          bwidthe:param_signal_error(plist, param_name, ecode = code);\n        case 1:\n            break;\n    }\n\n    switch (code = param_read_int(plist,\n                                  (param_name = \"BlockLine\"),\n                                  &BlockLine)) {\n        case 0:\n            if (BlockLine < 0)\n                ecode = gs_error_rangecheck;\n            else\n                break;\n            goto crowe;\n        default:\n            ecode = code;\n          crowe:param_signal_error(plist, param_name, ecode = code);\n        case 1:\n            break;\n    }\n\n    switch (code = param_read_int(plist,\n                                  (param_name = \"BlockHeight\"),\n                                  &BlockHeight)) {\n        case 0:\n            if (BlockHeight < 0)\n                ecode = gs_error_rangecheck;\n            else\n                break;\n            goto bheighte;\n        default:\n            ecode = code;\n          bheighte:param_signal_error(plist, param_name, ecode = code);\n        case 1:\n            break;\n    }\n\n    if ((code = param_read_bool(plist,\n                                (param_name = \"ShowBubble\"),\n                                &ShowBubble)) < 0) {\n        param_signal_error(plist, param_name, ecode = code);\n    }\n    if (ecode < 0)\n        return ecode;\n    code = gdev_prn_put_params(dev, plist);\n    if (code < 0)\n        return code;\n\n    lprn->ManualFeed = ManualFeed;\n    lprn->NegativePrint = NegativePrint;\n    lprn->Tumble = Tumble;\n    lprn->RITOff = RITOff;\n    lprn->BlockLine = BlockLine;\n    lprn->nBw = BlockWidth;\n    lprn->nBh = BlockHeight;\n    lprn->ShowBubble = ShowBubble;\n\n    return 0;\n}","target":0,"code_token_length":824,"total_token_length":1060,"max_tokens_setting":2048}
+{"idx":349259,"func":"static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,\n\tstruct inode **i)\n{\n\tsquashfs_dir_header_3 dirh;\n\tchar buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]\n\t\t__attribute__((aligned));\n\tsquashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;\n\tlong long start;\n\tint bytes = 0;\n\tint dir_count, size, res;\n\tstruct dir_ent *ent, *cur_ent = NULL;\n\tstruct dir *dir;\n\n\tTRACE(\"squashfs_opendir: inode start block %d, offset %d\\n\",\n\t\tblock_start, offset);\n\n\t*i = read_inode(block_start, offset);\n\n\tdir = malloc(sizeof(struct dir));\n\tif(dir == NULL)\n\t\tMEM_ERROR();\n\n\tdir->dir_count = 0;\n\tdir->cur_entry = NULL;\n\tdir->mode = (*i)->mode;\n\tdir->uid = (*i)->uid;\n\tdir->guid = (*i)->gid;\n\tdir->mtime = (*i)->time;\n\tdir->xattr = (*i)->xattr;\n\tdir->dirs = NULL;\n\n\tif ((*i)->data == 3)\n\t\t\/*\n\t\t * if the directory is empty, skip the unnecessary\n\t\t * lookup_entry, this fixes the corner case with\n\t\t * completely empty filesystems where lookup_entry correctly\n\t\t * returning -1 is incorrectly treated as an error\n\t\t *\/\n\t\treturn dir;\n\n\tstart = sBlk.s.directory_table_start + (*i)->start;\n\toffset = (*i)->offset;\n\tsize = (*i)->data + bytes - 3;\n\n\twhile(bytes < size) {\t\t\t\n\t\tif(swap) {\n\t\t\tsquashfs_dir_header_3 sdirh;\n\t\t\tres = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));\n\t\t\tif(res)\n\t\t\t\tSQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);\n\t\t} else\n\t\t\tres = read_directory_data(&dirh, &start, &offset, sizeof(dirh));\n\t\n\t\tif(res == FALSE)\n\t\t\tgoto corrupted;\n\n\t\tdir_count = dirh.count + 1;\n\t\tTRACE(\"squashfs_opendir: Read directory header @ byte position \"\n\t\t\t\"%d, %d directory entries\\n\", bytes, dir_count);\n\t\tbytes += sizeof(dirh);\n\n\t\t\/* dir_count should never be larger than SQUASHFS_DIR_COUNT *\/\n\t\tif(dir_count > SQUASHFS_DIR_COUNT) {\n\t\t\tERROR(\"File system corrupted: too many entries in directory\\n\");\n\t\t\tgoto corrupted;\n\t\t}\n\n\t\twhile(dir_count--) {\n\t\t\tif(swap) {\n\t\t\t\tsquashfs_dir_entry_3 sdire;\n\t\t\t\tres = read_directory_data(&sdire, &start,\n\t\t\t\t\t&offset, sizeof(sdire));\n\t\t\t\tif(res)\n\t\t\t\t\tSQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);\n\t\t\t} else\n\t\t\t\tres = read_directory_data(dire, &start,\n\t\t\t\t\t&offset, sizeof(*dire));\n\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tbytes += sizeof(*dire);\n\n\t\t\t\/* size should never be SQUASHFS_NAME_LEN or larger *\/\n\t\t\tif(dire->size >= SQUASHFS_NAME_LEN) {\n\t\t\t\tERROR(\"File system corrupted: filename too long\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tres = read_directory_data(dire->name, &start, &offset,\n\t\t\t\t\t\t\t\tdire->size + 1);\n\n\t\t\tif(res == FALSE)\n\t\t\t\tgoto corrupted;\n\n\t\t\tdire->name[dire->size + 1] = '\\0';\n\n\t\t\t\/* check name for invalid characters (i.e \/, ., ..) *\/\n\t\t\tif(check_name(dire->name, dire->size + 1) == FALSE) {\n\t\t\t\tERROR(\"File system corrupted: invalid characters in name\\n\");\n\t\t\t\tgoto corrupted;\n\t\t\t}\n\n\t\t\tTRACE(\"squashfs_opendir: directory entry %s, inode \"\n\t\t\t\t\"%d:%d, type %d\\n\", dire->name,\n\t\t\t\tdirh.start_block, dire->offset, dire->type);\n\n\t\t\tent = malloc(sizeof(struct dir_ent));\n\t\t\tif(ent == NULL)\n\t\t\t\tMEM_ERROR();\n\n\t\t\tent->name = strdup(dire->name);\n\t\t\tent->start_block = dirh.start_block;\n\t\t\tent->offset = dire->offset;\n\t\t\tent->type = dire->type;\n\t\t\tent->next = NULL;\n\t\t\tif(cur_ent == NULL)\n\t\t\t\tdir->dirs = ent;\n\t\t\telse\n\t\t\t\tcur_ent->next = ent;\n\t\t\tcur_ent = ent;\n\t\t\tdir->dir_count ++;\n\t\t\tbytes += dire->size + 1;\n\t\t}\n\t}\n\n\t\/* check directory for duplicate names and sorting *\/\n\tif(check_directory(dir) == FALSE) {\n\t\tERROR(\"File system corrupted: directory has duplicate names or is unsorted\\n\");\n\t\tgoto corrupted;\n\t}\n\n\treturn dir;\n\ncorrupted:\n\tsquashfs_closedir(dir);\n\treturn NULL;\n}","target":0,"code_token_length":1045,"total_token_length":1281,"max_tokens_setting":2048}
+{"idx":313546,"func":"static int __must_check rose_add_node(struct rose_route_struct *rose_route,\n\tstruct net_device *dev)\n{\n\tstruct rose_node  *rose_node, *rose_tmpn, *rose_tmpp;\n\tstruct rose_neigh *rose_neigh;\n\tint i, res = 0;\n\n\tspin_lock_bh(&rose_node_list_lock);\n\tspin_lock_bh(&rose_neigh_list_lock);\n\n\trose_node = rose_node_list;\n\twhile (rose_node != NULL) {\n\t\tif ((rose_node->mask == rose_route->mask) &&\n\t\t    (rosecmpm(&rose_route->address, &rose_node->address,\n\t\t\t      rose_route->mask) == 0))\n\t\t\tbreak;\n\t\trose_node = rose_node->next;\n\t}\n\n\tif (rose_node != NULL && rose_node->loopback) {\n\t\tres = -EINVAL;\n\t\tgoto out;\n\t}\n\n\trose_neigh = rose_neigh_list;\n\twhile (rose_neigh != NULL) {\n\t\tif (ax25cmp(&rose_route->neighbour,\n\t\t\t    &rose_neigh->callsign) == 0 &&\n\t\t    rose_neigh->dev == dev)\n\t\t\tbreak;\n\t\trose_neigh = rose_neigh->next;\n\t}\n\n\tif (rose_neigh == NULL) {\n\t\trose_neigh = kmalloc(sizeof(*rose_neigh), GFP_ATOMIC);\n\t\tif (rose_neigh == NULL) {\n\t\t\tres = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\trose_neigh->callsign  = rose_route->neighbour;\n\t\trose_neigh->digipeat  = NULL;\n\t\trose_neigh->ax25      = NULL;\n\t\trose_neigh->dev       = dev;\n\t\trose_neigh->count     = 0;\n\t\trose_neigh->use       = 0;\n\t\trose_neigh->dce_mode  = 0;\n\t\trose_neigh->loopback  = 0;\n\t\trose_neigh->number    = rose_neigh_no++;\n\t\trose_neigh->restarted = 0;\n\n\t\tskb_queue_head_init(&rose_neigh->queue);\n\n\t\ttimer_setup(&rose_neigh->ftimer, NULL, 0);\n\t\ttimer_setup(&rose_neigh->t0timer, NULL, 0);\n\n\t\tif (rose_route->ndigis != 0) {\n\t\t\trose_neigh->digipeat =\n\t\t\t\tkmalloc(sizeof(ax25_digi), GFP_ATOMIC);\n\t\t\tif (rose_neigh->digipeat == NULL) {\n\t\t\t\tkfree(rose_neigh);\n\t\t\t\tres = -ENOMEM;\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\trose_neigh->digipeat->ndigi      = rose_route->ndigis;\n\t\t\trose_neigh->digipeat->lastrepeat = -1;\n\n\t\t\tfor (i = 0; i < rose_route->ndigis; i++) {\n\t\t\t\trose_neigh->digipeat->calls[i]    =\n\t\t\t\t\trose_route->digipeaters[i];\n\t\t\t\trose_neigh->digipeat->repeated[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\trose_neigh->next = rose_neigh_list;\n\t\trose_neigh_list  = rose_neigh;\n\t}\n\n\t\/*\n\t * This is a new node to be inserted into the list. Find where it needs\n\t * to be inserted into the list, and insert it. We want to be sure\n\t * to order the list in descending order of mask size to ensure that\n\t * later when we are searching this list the first match will be the\n\t * best match.\n\t *\/\n\tif (rose_node == NULL) {\n\t\trose_tmpn = rose_node_list;\n\t\trose_tmpp = NULL;\n\n\t\twhile (rose_tmpn != NULL) {\n\t\t\tif (rose_tmpn->mask > rose_route->mask) {\n\t\t\t\trose_tmpp = rose_tmpn;\n\t\t\t\trose_tmpn = rose_tmpn->next;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t\/* create new node *\/\n\t\trose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC);\n\t\tif (rose_node == NULL) {\n\t\t\tres = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\trose_node->address      = rose_route->address;\n\t\trose_node->mask         = rose_route->mask;\n\t\trose_node->count        = 1;\n\t\trose_node->loopback     = 0;\n\t\trose_node->neighbour[0] = rose_neigh;\n\n\t\tif (rose_tmpn == NULL) {\n\t\t\tif (rose_tmpp == NULL) {\t\/* Empty list *\/\n\t\t\t\trose_node_list  = rose_node;\n\t\t\t\trose_node->next = NULL;\n\t\t\t} else {\n\t\t\t\trose_tmpp->next = rose_node;\n\t\t\t\trose_node->next = NULL;\n\t\t\t}\n\t\t} else {\n\t\t\tif (rose_tmpp == NULL) {\t\/* 1st node *\/\n\t\t\t\trose_node->next = rose_node_list;\n\t\t\t\trose_node_list  = rose_node;\n\t\t\t} else {\n\t\t\t\trose_tmpp->next = rose_node;\n\t\t\t\trose_node->next = rose_tmpn;\n\t\t\t}\n\t\t}\n\t\trose_neigh->count++;\n\n\t\tgoto out;\n\t}\n\n\t\/* We have space, slot it in *\/\n\tif (rose_node->count < 3) {\n\t\trose_node->neighbour[rose_node->count] = rose_neigh;\n\t\trose_node->count++;\n\t\trose_neigh->count++;\n\t}\n\nout:\n\tspin_unlock_bh(&rose_neigh_list_lock);\n\tspin_unlock_bh(&rose_node_list_lock);\n\n\treturn res;\n}","target":0,"code_token_length":1195,"total_token_length":1431,"max_tokens_setting":2048}
+{"idx":223404,"func":"static int get_framesize(compiler_common *common, PCRE2_SPTR cc, PCRE2_SPTR ccend, BOOL recursive, BOOL *needs_control_head)\n{\nint length = 0;\nint possessive = 0;\nBOOL stack_restore = FALSE;\nBOOL setsom_found = recursive;\nBOOL setmark_found = recursive;\n\/* The last capture is a local variable even for recursions. *\/\nBOOL capture_last_found = FALSE;\n\n#if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD\nSLJIT_ASSERT(common->control_head_ptr != 0);\n*needs_control_head = TRUE;\n#else\n*needs_control_head = FALSE;\n#endif\n\nif (ccend == NULL)\n  {\n  ccend = bracketend(cc) - (1 + LINK_SIZE);\n  if (!recursive && (*cc == OP_CBRAPOS || *cc == OP_SCBRAPOS))\n    {\n    possessive = length = (common->capture_last_ptr != 0) ? 5 : 3;\n    \/* This is correct regardless of common->capture_last_ptr. *\/\n    capture_last_found = TRUE;\n    }\n  cc = next_opcode(common, cc);\n  }\n\nSLJIT_ASSERT(cc != NULL);\nwhile (cc < ccend)\n  switch(*cc)\n    {\n    case OP_SET_SOM:\n    SLJIT_ASSERT(common->has_set_som);\n    stack_restore = TRUE;\n    if (!setsom_found)\n      {\n      length += 2;\n      setsom_found = TRUE;\n      }\n    cc += 1;\n    break;\n\n    case OP_MARK:\n    case OP_COMMIT_ARG:\n    case OP_PRUNE_ARG:\n    case OP_THEN_ARG:\n    SLJIT_ASSERT(common->mark_ptr != 0);\n    stack_restore = TRUE;\n    if (!setmark_found)\n      {\n      length += 2;\n      setmark_found = TRUE;\n      }\n    if (common->control_head_ptr != 0)\n      *needs_control_head = TRUE;\n    cc += 1 + 2 + cc[1];\n    break;\n\n    case OP_RECURSE:\n    stack_restore = TRUE;\n    if (common->has_set_som && !setsom_found)\n      {\n      length += 2;\n      setsom_found = TRUE;\n      }\n    if (common->mark_ptr != 0 && !setmark_found)\n      {\n      length += 2;\n      setmark_found = TRUE;\n      }\n    if (common->capture_last_ptr != 0 && !capture_last_found)\n      {\n      length += 2;\n      capture_last_found = TRUE;\n      }\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_CBRA:\n    case OP_CBRAPOS:\n    case OP_SCBRA:\n    case OP_SCBRAPOS:\n    stack_restore = TRUE;\n    if (common->capture_last_ptr != 0 && !capture_last_found)\n      {\n      length += 2;\n      capture_last_found = TRUE;\n      }\n    length += 3;\n    cc += 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_THEN:\n    stack_restore = TRUE;\n    if (common->control_head_ptr != 0)\n      *needs_control_head = TRUE;\n    cc ++;\n    break;\n\n    default:\n    stack_restore = TRUE;\n    \/* Fall through. *\/\n\n    case OP_NOT_WORD_BOUNDARY:\n    case OP_WORD_BOUNDARY:\n    case OP_NOT_DIGIT:\n    case OP_DIGIT:\n    case OP_NOT_WHITESPACE:\n    case OP_WHITESPACE:\n    case OP_NOT_WORDCHAR:\n    case OP_WORDCHAR:\n    case OP_ANY:\n    case OP_ALLANY:\n    case OP_ANYBYTE:\n    case OP_NOTPROP:\n    case OP_PROP:\n    case OP_ANYNL:\n    case OP_NOT_HSPACE:\n    case OP_HSPACE:\n    case OP_NOT_VSPACE:\n    case OP_VSPACE:\n    case OP_EXTUNI:\n    case OP_EODN:\n    case OP_EOD:\n    case OP_CIRC:\n    case OP_CIRCM:\n    case OP_DOLL:\n    case OP_DOLLM:\n    case OP_CHAR:\n    case OP_CHARI:\n    case OP_NOT:\n    case OP_NOTI:\n\n    case OP_EXACT:\n    case OP_POSSTAR:\n    case OP_POSPLUS:\n    case OP_POSQUERY:\n    case OP_POSUPTO:\n\n    case OP_EXACTI:\n    case OP_POSSTARI:\n    case OP_POSPLUSI:\n    case OP_POSQUERYI:\n    case OP_POSUPTOI:\n\n    case OP_NOTEXACT:\n    case OP_NOTPOSSTAR:\n    case OP_NOTPOSPLUS:\n    case OP_NOTPOSQUERY:\n    case OP_NOTPOSUPTO:\n\n    case OP_NOTEXACTI:\n    case OP_NOTPOSSTARI:\n    case OP_NOTPOSPLUSI:\n    case OP_NOTPOSQUERYI:\n    case OP_NOTPOSUPTOI:\n\n    case OP_TYPEEXACT:\n    case OP_TYPEPOSSTAR:\n    case OP_TYPEPOSPLUS:\n    case OP_TYPEPOSQUERY:\n    case OP_TYPEPOSUPTO:\n\n    case OP_CLASS:\n    case OP_NCLASS:\n    case OP_XCLASS:\n\n    case OP_CALLOUT:\n    case OP_CALLOUT_STR:\n\n    cc = next_opcode(common, cc);\n    SLJIT_ASSERT(cc != NULL);\n    break;\n    }\n\n\/* Possessive quantifiers can use a special case. *\/\nif (SLJIT_UNLIKELY(possessive == length))\n  return stack_restore ? no_frame : no_stack;\n\nif (length > 0)\n  return length + 1;\nreturn stack_restore ? no_frame : no_stack;\n}","target":0,"code_token_length":1174,"total_token_length":1410,"max_tokens_setting":2048}
+{"idx":508919,"func":"void st_select_lex::set_explain_type(bool on_the_fly)\n{\n  bool is_primary= FALSE;\n  if (next_select())\n    is_primary= TRUE;\n\n  if (!is_primary && first_inner_unit())\n  {\n    \/*\n      If there is at least one materialized derived|view then it's a PRIMARY select.\n      Otherwise, all derived tables\/views were merged and this select is a SIMPLE one.\n    *\/\n    for (SELECT_LEX_UNIT *un= first_inner_unit(); un; un= un->next_unit())\n    {\n      if ((!un->derived || un->derived->is_materialized_derived()))\n      {\n        is_primary= TRUE;\n        break;\n      }\n    }\n  }\n\n  if (on_the_fly && !is_primary && have_merged_subqueries)\n    is_primary= TRUE;\n\n  SELECT_LEX *first= master_unit()->first_select();\n  \/* drop UNCACHEABLE_EXPLAIN, because it is for internal usage only *\/\n  uint8 is_uncacheable= (uncacheable & ~UNCACHEABLE_EXPLAIN);\n  \n  bool using_materialization= FALSE;\n  Item_subselect *parent_item;\n  if ((parent_item= master_unit()->item) &&\n      parent_item->substype() == Item_subselect::IN_SUBS)\n  {\n    Item_in_subselect *in_subs= (Item_in_subselect*)parent_item;\n    \/*\n      Surprisingly, in_subs->is_set_strategy() can return FALSE here,\n      even for the last invocation of this function for the select.\n    *\/\n    if (in_subs->test_strategy(SUBS_MATERIALIZATION))\n      using_materialization= TRUE;\n  }\n\n  if (&master_unit()->thd->lex->select_lex == this)\n  {\n     type= is_primary ? \"PRIMARY\" : \"SIMPLE\";\n  }\n  else\n  {\n    if (this == first)\n    {\n      \/* If we're a direct child of a UNION, we're the first sibling there *\/\n      if (linkage == DERIVED_TABLE_TYPE)\n        type= \"DERIVED\";\n      else if (using_materialization)\n        type= \"MATERIALIZED\";\n      else\n      {\n         if (is_uncacheable & UNCACHEABLE_DEPENDENT)\n           type= \"DEPENDENT SUBQUERY\";\n         else\n         {\n           type= is_uncacheable? \"UNCACHEABLE SUBQUERY\" :\n                                 \"SUBQUERY\";\n         }\n      }\n    }\n    else\n    {\n      \/* This a non-first sibling in UNION *\/\n      if (is_uncacheable & UNCACHEABLE_DEPENDENT)\n        type= \"DEPENDENT UNION\";\n      else if (using_materialization)\n        type= \"MATERIALIZED UNION\";\n      else\n      {\n        type= is_uncacheable ? \"UNCACHEABLE UNION\": \"UNION\";\n        if (this == master_unit()->fake_select_lex)\n          type= \"UNION RESULT\";\n        \/*\n          join below may be =NULL when this functions is called at an early\n          stage. It will be later called again and we will set the correct\n          value.\n        *\/\n        if (join)\n        {\n          bool uses_cte= false;\n          for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_BUSH_ROOTS,\n                                                     WITH_CONST_TABLES);\n               tab;\n               tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))\n          {\n            \/*\n              pos_in_table_list=NULL for e.g. post-join aggregation JOIN_TABs.\n            *\/\n            if (!(tab->table && tab->table->pos_in_table_list))\n\t      continue;\n            TABLE_LIST *tbl= tab->table->pos_in_table_list;\n            if (tbl->with && tbl->with->is_recursive &&\n                tbl->is_with_table_recursive_reference())\n            {\n              uses_cte= true;\n              break;\n            }\n          }\n          if (uses_cte)\n            type= \"RECURSIVE UNION\";\n        }\n      }\n    }\n  }\n\n  if (!on_the_fly)\n    options|= SELECT_DESCRIBE;\n}","target":0,"code_token_length":837,"total_token_length":1073,"max_tokens_setting":2048}
+{"idx":310055,"func":"_nc_trim_sgr0(TERMTYPE2 *tp)\n{\n    char *result = exit_attribute_mode;\n\n    T((T_CALLED(\"_nc_trim_sgr0()\")));\n\n    if (PRESENT(exit_attribute_mode)\n\t&& PRESENT(set_attributes)) {\n\tbool found = FALSE;\n\tchar *on = set_attribute_9(tp, 1);\n\tchar *off = set_attribute_9(tp, 0);\n\tchar *end = strdup(exit_attribute_mode);\n\tchar *tmp;\n\tsize_t i, j, k;\n\n\tTR(TRACE_DATABASE, (\"checking if we can trim sgr0 based on sgr\"));\n\tTR(TRACE_DATABASE, (\"sgr0       %s\", _nc_visbuf(end)));\n\tTR(TRACE_DATABASE, (\"sgr(9:off) %s\", _nc_visbuf(off)));\n\tTR(TRACE_DATABASE, (\"sgr(9:on)  %s\", _nc_visbuf(on)));\n\n\tif (!rewrite_sgr(on, enter_alt_charset_mode)\n\t    || !rewrite_sgr(off, exit_alt_charset_mode)\n\t    || !rewrite_sgr(end, exit_alt_charset_mode)) {\n\t    FreeIfNeeded(off);\n\t} else if (similar_sgr(off, end)\n\t\t   && !similar_sgr(off, on)) {\n\t    TR(TRACE_DATABASE, (\"adjusting sgr(9:off) : %s\", _nc_visbuf(off)));\n\t    result = off;\n\t    \/*\n\t     * If rmacs is a substring of sgr(0), remove that chunk.\n\t     *\/\n\t    if (PRESENT(exit_alt_charset_mode)) {\n\t\tTR(TRACE_DATABASE, (\"scan for rmacs %s\", _nc_visbuf(exit_alt_charset_mode)));\n\t\tj = strlen(off);\n\t\tk = strlen(exit_alt_charset_mode);\n\t\tif (j > k) {\n\t\t    for (i = 0; i <= (j - k); ++i) {\n\t\t\tunsigned k2 = compare_part(exit_alt_charset_mode,\n\t\t\t\t\t\t   off + i);\n\t\t\tif (k2 != 0) {\n\t\t\t    found = TRUE;\n\t\t\t    chop_out(off, (unsigned) i, (unsigned) (i + k2));\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    \/*\n\t     * SGR 10 would reset to normal font.\n\t     *\/\n\t    if (!found) {\n\t\tif ((i = (size_t) is_csi(off)) != 0\n\t\t    && off[strlen(off) - 1] == 'm') {\n\t\t    TR(TRACE_DATABASE, (\"looking for SGR 10 in %s\",\n\t\t\t\t\t_nc_visbuf(off)));\n\t\t    tmp = skip_zero(off + i);\n\t\t    if (tmp[0] == '1'\n\t\t\t&& skip_zero(tmp + 1) != tmp + 1) {\n\t\t\ti = (size_t) (tmp - off);\n\t\t\tif (off[i - 1] == ';')\n\t\t\t    i--;\n\t\t\tj = (size_t) (skip_zero(tmp + 1) - off);\n\t\t\t(void) chop_out(off, (unsigned) i, (unsigned) j);\n\t\t\tfound = TRUE;\n\t\t    }\n\t\t}\n\t    }\n\t    if (!found\n\t\t&& (tmp = strstr(end, off)) != 0\n\t\t&& strcmp(end, off) != 0) {\n\t\ti = (size_t) (tmp - end);\n\t\tj = strlen(off);\n\t\ttmp = strdup(end);\n\t\tchop_out(tmp, (unsigned) i, (unsigned) j);\n\t\tfree(off);\n\t\tresult = tmp;\n\t    }\n\t    TR(TRACE_DATABASE, (\"...adjusted sgr0 : %s\", _nc_visbuf(result)));\n\t    if (!strcmp(result, exit_attribute_mode)) {\n\t\tTR(TRACE_DATABASE, (\"...same result, discard\"));\n\t\tfree(result);\n\t\tresult = exit_attribute_mode;\n\t    }\n\t} else {\n\t    \/*\n\t     * Either the sgr does not reference alternate character set,\n\t     * or it is incorrect.  That's too hard to decide right now.\n\t     *\/\n\t    free(off);\n\t}\n\tFreeIfNeeded(end);\n\tFreeIfNeeded(on);\n    } else {\n\t\/*\n\t * Possibly some applications are confused if sgr0 contains rmacs,\n\t * but that would be a different bug report -TD\n\t *\/\n    }\n\n    returnPtr(result);\n}","target":0,"code_token_length":883,"total_token_length":1119,"max_tokens_setting":2048}
+{"idx":215342,"func":"int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,\n\t\tunsigned long start, int len, int write, int force,\n\t\tstruct page **pages, struct vm_area_struct **vmas)\n{\n\tint i;\n\tunsigned int vm_flags;\n\n\tif (len <= 0)\n\t\treturn 0;\n\t\/* \n\t * Require read or write permissions.\n\t * If 'force' is set, we only require the \"MAY\" flags.\n\t *\/\n\tvm_flags  = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);\n\tvm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);\n\ti = 0;\n\n\tdo {\n\t\tstruct vm_area_struct *vma;\n\t\tunsigned int foll_flags;\n\n\t\tvma = find_extend_vma(mm, start);\n\t\tif (!vma && in_gate_area(tsk, start)) {\n\t\t\tunsigned long pg = start & PAGE_MASK;\n\t\t\tstruct vm_area_struct *gate_vma = get_gate_vma(tsk);\n\t\t\tpgd_t *pgd;\n\t\t\tpud_t *pud;\n\t\t\tpmd_t *pmd;\n\t\t\tpte_t *pte;\n\t\t\tif (write) \/* user gate pages are read-only *\/\n\t\t\t\treturn i ? : -EFAULT;\n\t\t\tif (pg > TASK_SIZE)\n\t\t\t\tpgd = pgd_offset_k(pg);\n\t\t\telse\n\t\t\t\tpgd = pgd_offset_gate(mm, pg);\n\t\t\tBUG_ON(pgd_none(*pgd));\n\t\t\tpud = pud_offset(pgd, pg);\n\t\t\tBUG_ON(pud_none(*pud));\n\t\t\tpmd = pmd_offset(pud, pg);\n\t\t\tif (pmd_none(*pmd))\n\t\t\t\treturn i ? : -EFAULT;\n\t\t\tpte = pte_offset_map(pmd, pg);\n\t\t\tif (pte_none(*pte)) {\n\t\t\t\tpte_unmap(pte);\n\t\t\t\treturn i ? : -EFAULT;\n\t\t\t}\n\t\t\tif (pages) {\n\t\t\t\tstruct page *page = vm_normal_page(gate_vma, start, *pte);\n\t\t\t\tpages[i] = page;\n\t\t\t\tif (page)\n\t\t\t\t\tget_page(page);\n\t\t\t}\n\t\t\tpte_unmap(pte);\n\t\t\tif (vmas)\n\t\t\t\tvmas[i] = gate_vma;\n\t\t\ti++;\n\t\t\tstart += PAGE_SIZE;\n\t\t\tlen--;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP))\n\t\t\t\t|| !(vm_flags & vma->vm_flags))\n\t\t\treturn i ? : -EFAULT;\n\n\t\tif (is_vm_hugetlb_page(vma)) {\n\t\t\ti = follow_hugetlb_page(mm, vma, pages, vmas,\n\t\t\t\t\t\t&start, &len, i, write);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfoll_flags = FOLL_TOUCH;\n\t\tif (pages)\n\t\t\tfoll_flags |= FOLL_GET;\n\t\tif (!write && !(vma->vm_flags & VM_LOCKED) &&\n\t\t    (!vma->vm_ops || !vma->vm_ops->fault))\n\t\t\tfoll_flags |= FOLL_ANON;\n\n\t\tdo {\n\t\t\tstruct page *page;\n\n\t\t\t\/*\n\t\t\t * If tsk is ooming, cut off its access to large memory\n\t\t\t * allocations. It has a pending SIGKILL, but it can't\n\t\t\t * be processed until returning to user space.\n\t\t\t *\/\n\t\t\tif (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE)))\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tif (write)\n\t\t\t\tfoll_flags |= FOLL_WRITE;\n\n\t\t\tcond_resched();\n\t\t\twhile (!(page = follow_page(vma, start, foll_flags))) {\n\t\t\t\tint ret;\n\t\t\t\tret = handle_mm_fault(mm, vma, start,\n\t\t\t\t\t\tfoll_flags & FOLL_WRITE);\n\t\t\t\tif (ret & VM_FAULT_ERROR) {\n\t\t\t\t\tif (ret & VM_FAULT_OOM)\n\t\t\t\t\t\treturn i ? i : -ENOMEM;\n\t\t\t\t\telse if (ret & VM_FAULT_SIGBUS)\n\t\t\t\t\t\treturn i ? i : -EFAULT;\n\t\t\t\t\tBUG();\n\t\t\t\t}\n\t\t\t\tif (ret & VM_FAULT_MAJOR)\n\t\t\t\t\ttsk->maj_flt++;\n\t\t\t\telse\n\t\t\t\t\ttsk->min_flt++;\n\n\t\t\t\t\/*\n\t\t\t\t * The VM_FAULT_WRITE bit tells us that\n\t\t\t\t * do_wp_page has broken COW when necessary,\n\t\t\t\t * even if maybe_mkwrite decided not to set\n\t\t\t\t * pte_write. We can thus safely do subsequent\n\t\t\t\t * page lookups as if they were reads.\n\t\t\t\t *\/\n\t\t\t\tif (ret & VM_FAULT_WRITE)\n\t\t\t\t\tfoll_flags &= ~FOLL_WRITE;\n\n\t\t\t\tcond_resched();\n\t\t\t}\n\t\t\tif (pages) {\n\t\t\t\tpages[i] = page;\n\n\t\t\t\tflush_anon_page(vma, page, start);\n\t\t\t\tflush_dcache_page(page);\n\t\t\t}\n\t\t\tif (vmas)\n\t\t\t\tvmas[i] = vma;\n\t\t\ti++;\n\t\t\tstart += PAGE_SIZE;\n\t\t\tlen--;\n\t\t} while (len && start < vma->vm_end);\n\t} while (len);\n\treturn i;\n}","target":1,"code_token_length":1066,"total_token_length":1302,"max_tokens_setting":2048}
+{"idx":254751,"func":"njs_typed_array_prototype_slice(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t copy)\n{\n    int64_t             start, end, count, offset;\n    uint32_t            i, element_size, length;\n    njs_int_t           ret;\n    njs_value_t         arguments[3], *this, *value;\n    njs_typed_array_t   *array, *new_array;\n    njs_array_buffer_t  *buffer, *new_buffer;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_typed_array(this))) {\n        njs_type_error(vm, \"this is not a typed array\");\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(this);\n    length = njs_typed_array_length(array);\n    buffer = njs_typed_array_buffer(array);\n    if (njs_slow_path(copy && njs_is_detached_buffer(buffer))) {\n        njs_type_error(vm, \"detached buffer\");\n        return NJS_ERROR;\n    }\n\n    ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &start);\n    if (njs_slow_path(ret != NJS_OK)) {\n        njs_range_error(vm, \"invalid start\");\n        return NJS_ERROR;\n    }\n\n    start = (start < 0) ? njs_max(length + start, 0) : njs_min(start, length);\n\n    value = njs_arg(args, nargs, 2);\n\n    if (njs_is_undefined(value)) {\n        end = length;\n\n    } else {\n        ret = njs_value_to_integer(vm, value, &end);\n        if (njs_slow_path(ret != NJS_OK)) {\n            njs_range_error(vm, \"invalid end\");\n            return NJS_ERROR;\n        }\n    }\n\n    end = (end < 0) ? njs_max(length + end, 0) : njs_min(end, length);\n\n    element_size = njs_typed_array_element_size(array->type);\n\n    if (copy) {\n        count = njs_max(end - start, 0);\n        njs_set_number(&arguments[0], count);\n\n        ret = njs_typed_array_species_create(vm, this,\n                                             njs_value_arg(arguments), 1,\n                                             &vm->retval);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (count == 0) {\n            return NJS_OK;\n        }\n\n        if (njs_slow_path(njs_is_detached_buffer(buffer))) {\n            njs_type_error(vm, \"detached buffer\");\n            return NJS_ERROR;\n        }\n\n        new_array = njs_typed_array(&vm->retval);\n        new_buffer = njs_typed_array_buffer(new_array);\n        element_size = njs_typed_array_element_size(array->type);\n\n        if (njs_fast_path(array->type == new_array->type)) {\n            start = start * element_size;\n            count = count * element_size;\n\n            memcpy(&new_buffer->u.u8[0], &buffer->u.u8[start], count);\n\n        } else {\n            for (i = 0; i < count; i++) {\n                njs_typed_array_prop_set(vm, new_array, i,\n                                        njs_typed_array_prop(array, i + start));\n            }\n        }\n\n        return NJS_OK;\n    }\n\n    offset = array->offset * element_size;\n    offset += start * element_size;\n\n    njs_set_array_buffer(&arguments[0], buffer);\n    njs_set_number(&arguments[1], offset);\n    njs_set_number(&arguments[2], njs_max(end - start, 0));\n\n    return njs_typed_array_species_create(vm, this, njs_value_arg(arguments), 3,\n                                          &vm->retval);\n}","target":0,"code_token_length":829,"total_token_length":1065,"max_tokens_setting":2048}
+{"idx":231753,"func":"TEST_P(\n    QuicServerTransportAllowMigrationTest,\n    MigrateToUnvalidatedPeerOverwritesCachedRttState) {\n  folly::SocketAddress newPeer(\"100.101.102.103\", 23456);\n  server->getNonConstConn().migrationState.previousPeerAddresses.push_back(\n      newPeer);\n  CongestionAndRttState state;\n  state.peerAddress = newPeer;\n  state.recordTime = Clock::now();\n  state.congestionController = ccFactory_->makeCongestionController(\n      server->getNonConstConn(),\n      server->getNonConstConn().transportSettings.defaultCongestionController);\n  state.srtt = 1000us;\n  state.lrtt = 2000us;\n  state.rttvar = 3000us;\n  state.mrtt = 800us;\n  server->getNonConstConn().migrationState.lastCongestionAndRtt =\n      std::move(state);\n\n  auto data = IOBuf::copyBuffer(\"bad data\");\n  auto packetData = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      2,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n\n  EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1);\n\n  auto peerAddress = server->getConn().peerAddress;\n  auto congestionController = server->getConn().congestionController.get();\n  auto srtt = server->getConn().lossState.srtt;\n  auto lrtt = server->getConn().lossState.lrtt;\n  auto rttvar = server->getConn().lossState.rttvar;\n  auto mrtt = server->getConn().lossState.mrtt;\n\n  folly::SocketAddress newPeer2(\"200.101.102.103\", 2345);\n  deliverData(std::move(packetData), false, &newPeer2);\n\n  EXPECT_TRUE(server->getConn().pendingEvents.pathChallenge);\n\n  EXPECT_EQ(server->getConn().peerAddress, newPeer2);\n  EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 2);\n  EXPECT_EQ(\n      server->getConn().migrationState.previousPeerAddresses.front(), newPeer);\n  EXPECT_EQ(\n      server->getConn().migrationState.previousPeerAddresses.back(),\n      peerAddress);\n  EXPECT_EQ(server->getConn().lossState.srtt, 0us);\n  EXPECT_EQ(server->getConn().lossState.lrtt, 0us);\n  EXPECT_EQ(server->getConn().lossState.rttvar, 0us);\n  EXPECT_EQ(server->getConn().lossState.mrtt, kDefaultMinRtt);\n  EXPECT_NE(server->getConn().congestionController.get(), nullptr);\n  EXPECT_NE(server->getConn().congestionController.get(), congestionController);\n  EXPECT_EQ(\n      server->getConn().migrationState.lastCongestionAndRtt->peerAddress,\n      clientAddr);\n  EXPECT_EQ(\n      server->getConn()\n          .migrationState.lastCongestionAndRtt->congestionController.get(),\n      congestionController);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->srtt, srtt);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->lrtt, lrtt);\n  EXPECT_EQ(\n      server->getConn().migrationState.lastCongestionAndRtt->rttvar, rttvar);\n  EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->mrtt, mrtt);\n}","target":0,"code_token_length":805,"total_token_length":1041,"max_tokens_setting":2048}
+{"idx":226985,"func":"IRC_PROTOCOL_CALLBACK(354)\n{\n    char *pos_attr, *pos_hopcount, *pos_account, *pos_realname, *str_host;\n    int length;\n    struct t_irc_channel *ptr_channel;\n    struct t_irc_nick *ptr_nick;\n\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n\n    \/*\n     * if there are less than 11 arguments, we are unable to parse the message,\n     * some infos are missing but we don't know which ones; in this case we\n     * just display the message as-is\n     *\/\n    if (argc < 11)\n    {\n        if (!ptr_channel || (ptr_channel->checking_whox <= 0))\n        {\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, \"who\", NULL),\n                date,\n                irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n                \"%s%s[%s%s%s]%s%s%s\",\n                weechat_prefix (\"network\"),\n                IRC_COLOR_CHAT_DELIMITERS,\n                IRC_COLOR_CHAT_CHANNEL,\n                argv[3],\n                IRC_COLOR_CHAT_DELIMITERS,\n                IRC_COLOR_RESET,\n                (argc > 4) ? \" \" : \"\",\n                (argc > 4) ? argv_eol[4] : \"\");\n        }\n        return WEECHAT_RC_OK;\n    }\n\n    ptr_nick = (ptr_channel) ?\n        irc_nick_search (server, ptr_channel, argv[7]) : NULL;\n    pos_attr = argv[8];\n    pos_hopcount = argv[9];\n    pos_account = (strcmp (argv[10], \"0\") != 0) ? argv[10] : NULL;\n    pos_realname = (argc > 11) ?\n        ((argv_eol[11][0] == ':') ? argv_eol[11] + 1 : argv_eol[11]) : NULL;\n\n    \/* update host in nick *\/\n    if (ptr_nick)\n    {\n        length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;\n        str_host = malloc (length);\n        if (str_host)\n        {\n            snprintf (str_host, length, \"%s@%s\", argv[4], argv[5]);\n            irc_nick_set_host (ptr_nick, str_host);\n            free (str_host);\n        }\n    }\n\n    \/* update away flag in nick *\/\n    if (ptr_channel && ptr_nick)\n    {\n        irc_nick_set_away (server, ptr_channel, ptr_nick,\n                           (pos_attr && (pos_attr[0] == 'G')) ? 1 : 0);\n    }\n\n    \/* update account flag in nick *\/\n    if (ptr_nick)\n    {\n        if (ptr_nick->account)\n            free (ptr_nick->account);\n        if (ptr_channel && pos_account\n            && weechat_hashtable_has_key (server->cap_list, \"account-notify\"))\n        {\n            ptr_nick->account = strdup (pos_account);\n        }\n        else\n        {\n            ptr_nick->account = NULL;\n        }\n    }\n\n    \/* update realname in nick *\/\n    if (ptr_nick)\n    {\n        if (ptr_nick->realname)\n            free (ptr_nick->realname);\n        if (ptr_channel && pos_realname\n            && weechat_hashtable_has_key (server->cap_list, \"extended-join\"))\n        {\n            ptr_nick->realname = strdup (pos_realname);\n        }\n        else\n        {\n            ptr_nick->realname = NULL;\n        }\n    }\n\n    \/* display output of who (manual who from user) *\/\n    if (!ptr_channel || (ptr_channel->checking_whox <= 0))\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, NULL, command, \"who\", NULL),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s %s%s%s%s%s%s(%s%s@%s%s)%s %s%s%s%s(%s)\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_CHANNEL,\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[7]),\n            argv[7],\n            IRC_COLOR_CHAT_DELIMITERS,\n            (pos_account) ? \"[\" : \"\",\n            (pos_account) ? IRC_COLOR_CHAT_HOST : \"\",\n            (pos_account) ? pos_account : \"\",\n            (pos_account) ? IRC_COLOR_CHAT_DELIMITERS : \"\",\n            (pos_account) ? \"] \" : \"\",\n            IRC_COLOR_CHAT_HOST,\n            argv[4],\n            argv[5],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            (pos_attr) ? pos_attr : \"\",\n            (pos_attr) ? \" \" : \"\",\n            (pos_hopcount) ? pos_hopcount : \"\",\n            (pos_hopcount) ? \" \" : \"\",\n            (pos_realname) ? pos_realname : \"\");\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":1098,"total_token_length":1334,"max_tokens_setting":2048}
+{"idx":338168,"func":"void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {\n  BYN_TRACE(\"zz node: Try\\n\");\n  auto* curr = allocator.alloc<Try>();\n  startControlFlow(curr);\n  \/\/ For simplicity of implementation, like if scopes, we create a hidden block\n  \/\/ within each try-body and catch-body, and let branches target those inner\n  \/\/ blocks instead.\n  curr->type = getType();\n  curr->body = getBlockOrSingleton(curr->type);\n\n  Builder builder(wasm);\n  \/\/ A nameless label shared by all catch body blocks\n  Name catchLabel = getNextLabel();\n  breakStack.push_back({catchLabel, curr->type});\n\n  auto readCatchBody = [&](Type tagType) {\n    auto start = expressionStack.size();\n    if (tagType != Type::none) {\n      pushExpression(builder.makePop(tagType));\n    }\n    processExpressions();\n    size_t end = expressionStack.size();\n    if (start > end) {\n      throwError(\"block cannot pop from outside\");\n    }\n    if (end - start == 1) {\n      curr->catchBodies.push_back(popExpression());\n    } else {\n      auto* block = allocator.alloc<Block>();\n      pushBlockElements(block, curr->type, start);\n      block->finalize(curr->type);\n      curr->catchBodies.push_back(block);\n    }\n  };\n\n  while (lastSeparator == BinaryConsts::Catch ||\n         lastSeparator == BinaryConsts::CatchAll) {\n    if (lastSeparator == BinaryConsts::Catch) {\n      auto index = getU32LEB();\n      if (index >= wasm.tags.size()) {\n        throwError(\"bad tag index\");\n      }\n      auto* tag = wasm.tags[index].get();\n      curr->catchTags.push_back(tag->name);\n      readCatchBody(tag->sig.params);\n\n    } else { \/\/ catch_all\n      if (curr->hasCatchAll()) {\n        throwError(\"there should be at most one 'catch_all' clause per try\");\n      }\n      readCatchBody(Type::none);\n    }\n  }\n  breakStack.pop_back();\n\n  if (lastSeparator == BinaryConsts::Delegate) {\n    curr->delegateTarget = getExceptionTargetName(getU32LEB());\n  }\n\n  \/\/ For simplicity, we ensure that try's labels can only be targeted by\n  \/\/ delegates and rethrows, and delegates\/rethrows can only target try's\n  \/\/ labels. (If they target blocks or loops, it is a validation failure.)\n  \/\/ Because we create an inner block within each try and catch body, if any\n  \/\/ delegate\/rethrow targets those inner blocks, we should make them target the\n  \/\/ try's label instead.\n  curr->name = getNextLabel();\n  if (auto* block = curr->body->dynCast<Block>()) {\n    if (block->name.is()) {\n      if (exceptionTargetNames.find(block->name) !=\n          exceptionTargetNames.end()) {\n        BranchUtils::replaceExceptionTargets(block, block->name, curr->name);\n        exceptionTargetNames.erase(block->name);\n      }\n    }\n  }\n  if (exceptionTargetNames.find(catchLabel) != exceptionTargetNames.end()) {\n    for (auto* catchBody : curr->catchBodies) {\n      BranchUtils::replaceExceptionTargets(catchBody, catchLabel, curr->name);\n    }\n    exceptionTargetNames.erase(catchLabel);\n  }\n\n  \/\/ If catch bodies contained stacky code, 'pop's can be nested within a block.\n  \/\/ Fix that up.\n  EHUtils::handleBlockNestedPop(curr, currFunction, wasm);\n  curr->finalize(curr->type);\n\n  \/\/ For simplicity, we create an inner block within the catch body too, but the\n  \/\/ one within the 'catch' *must* be omitted when we write out the binary back\n  \/\/ later, because the 'catch' instruction pushes a value onto the stack and\n  \/\/ the inner block does not support block input parameters without multivalue\n  \/\/ support.\n  \/\/ try\n  \/\/   ...\n  \/\/ catch $e   ;; Pushes value(s) onto the stack\n  \/\/   block  ;; Inner block. Should be deleted when writing binary!\n  \/\/     use the pushed value\n  \/\/   end\n  \/\/ end\n  \/\/\n  \/\/ But when input binary code is like\n  \/\/ try\n  \/\/   ...\n  \/\/ catch $e\n  \/\/   br 0\n  \/\/ end\n  \/\/\n  \/\/ 'br 0' accidentally happens to target the inner block, creating code like\n  \/\/ this in Binaryen IR, making the inner block not deletable, resulting in a\n  \/\/ validation error:\n  \/\/ (try\n  \/\/   ...\n  \/\/   (catch $e\n  \/\/     (block $label0 ;; Cannot be deleted, because there's a branch to this\n  \/\/       ...\n  \/\/       (br $label0)\n  \/\/     )\n  \/\/   )\n  \/\/ )\n  \/\/\n  \/\/ When this happens, we fix this by creating a block that wraps the whole\n  \/\/ try-catch, and making the branches target that block instead, like this:\n  \/\/ (block $label  ;; New enclosing block, new target for the branch\n  \/\/   (try\n  \/\/     ...\n  \/\/     (catch $e\n  \/\/       (block   ;; Now this can be deleted when writing binary\n  \/\/         ...\n  \/\/         (br $label)\n  \/\/       )\n  \/\/     )\n  \/\/   )\n  \/\/ )\n  if (breakTargetNames.find(catchLabel) == breakTargetNames.end()) {\n    out = curr;\n  } else {\n    \/\/ Create a new block that encloses the whole try-catch\n    auto* block = builder.makeBlock(catchLabel, curr);\n    out = block;\n  }\n  breakTargetNames.erase(catchLabel);\n}","target":0,"code_token_length":1232,"total_token_length":1468,"max_tokens_setting":2048}
+{"idx":472366,"func":"ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,\n                                             int pool_index, int cache_index,\n                                             ciInstanceKlass* accessor) {\n  int index = pool_index;\n  if (cache_index >= 0) {\n    assert(index < 0, \"only one kind of index at a time\");\n    index = cpool->object_to_cp_index(cache_index);\n    oop obj = cpool->resolved_references()->obj_at(cache_index);\n    if (obj != NULL) {\n      if (obj == Universe::the_null_sentinel()) {\n        return ciConstant(T_OBJECT, get_object(NULL));\n      }\n      BasicType bt = T_OBJECT;\n      if (cpool->tag_at(index).is_dynamic_constant()) {\n        bt = Signature::basic_type(cpool->uncached_signature_ref_at(index));\n      }\n      if (!is_reference_type(bt)) {\n        \/\/ we have to unbox the primitive value\n        if (!is_java_primitive(bt)) {\n          return ciConstant();\n        }\n        jvalue value;\n        BasicType bt2 = java_lang_boxing_object::get_value(obj, &value);\n        assert(bt2 == bt, \"\");\n        switch (bt2) {\n        case T_DOUBLE:  return ciConstant(value.d);\n        case T_FLOAT:   return ciConstant(value.f);\n        case T_LONG:    return ciConstant(value.j);\n        case T_INT:     return ciConstant(bt2, value.i);\n        case T_SHORT:   return ciConstant(bt2, value.s);\n        case T_BYTE:    return ciConstant(bt2, value.b);\n        case T_CHAR:    return ciConstant(bt2, value.c);\n        case T_BOOLEAN: return ciConstant(bt2, value.z);\n        default:  return ciConstant();\n        }\n      }\n      ciObject* ciobj = get_object(obj);\n      if (ciobj->is_array()) {\n        return ciConstant(T_ARRAY, ciobj);\n      } else {\n        assert(ciobj->is_instance(), \"should be an instance\");\n        return ciConstant(T_OBJECT, ciobj);\n      }\n    }\n  }\n  constantTag tag = cpool->tag_at(index);\n  if (tag.is_int()) {\n    return ciConstant(T_INT, (jint)cpool->int_at(index));\n  } else if (tag.is_long()) {\n    return ciConstant((jlong)cpool->long_at(index));\n  } else if (tag.is_float()) {\n    return ciConstant((jfloat)cpool->float_at(index));\n  } else if (tag.is_double()) {\n    return ciConstant((jdouble)cpool->double_at(index));\n  } else if (tag.is_string()) {\n    EXCEPTION_CONTEXT;\n    oop string = NULL;\n    assert(cache_index >= 0, \"should have a cache index\");\n    string = cpool->string_at(index, cache_index, THREAD);\n    if (HAS_PENDING_EXCEPTION) {\n      CLEAR_PENDING_EXCEPTION;\n      record_out_of_memory_failure();\n      return ciConstant();\n    }\n    ciObject* constant = get_object(string);\n    if (constant->is_array()) {\n      return ciConstant(T_ARRAY, constant);\n    } else {\n      assert (constant->is_instance(), \"must be an instance, or not? \");\n      return ciConstant(T_OBJECT, constant);\n    }\n  } else if (tag.is_unresolved_klass_in_error()) {\n    return ciConstant(T_OBJECT, get_unloaded_klass_mirror(NULL));\n  } else if (tag.is_klass() || tag.is_unresolved_klass()) {\n    bool will_link;\n    ciKlass* klass = get_klass_by_index_impl(cpool, index, will_link, accessor);\n    assert (klass->is_instance_klass() || klass->is_array_klass(),\n            \"must be an instance or array klass \");\n    ciInstance* mirror = (will_link ? klass->java_mirror() : get_unloaded_klass_mirror(klass));\n    return ciConstant(T_OBJECT, mirror);\n  } else if (tag.is_method_type() || tag.is_method_type_in_error()) {\n    \/\/ must execute Java code to link this CP entry into cache[i].f1\n    ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));\n    ciObject* ciobj = get_unloaded_method_type_constant(signature);\n    return ciConstant(T_OBJECT, ciobj);\n  } else if (tag.is_method_handle() || tag.is_method_handle_in_error()) {\n    \/\/ must execute Java code to link this CP entry into cache[i].f1\n    bool ignore_will_link;\n    int ref_kind        = cpool->method_handle_ref_kind_at(index);\n    int callee_index    = cpool->method_handle_klass_index_at(index);\n    ciKlass* callee     = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor);\n    ciSymbol* name      = get_symbol(cpool->method_handle_name_ref_at(index));\n    ciSymbol* signature = get_symbol(cpool->method_handle_signature_ref_at(index));\n    ciObject* ciobj     = get_unloaded_method_handle_constant(callee, name, signature, ref_kind);\n    return ciConstant(T_OBJECT, ciobj);\n  } else if (tag.is_dynamic_constant() || tag.is_dynamic_constant_in_error()) {\n    return ciConstant(); \/\/ not supported\n  } else {\n    assert(false, \"unknown tag: %d (%s)\", tag.value(), tag.internal_name());\n    return ciConstant();\n  }\n}","target":0,"code_token_length":1141,"total_token_length":1377,"max_tokens_setting":2048}
+{"idx":413674,"func":"static int fcn_print_detail(RCore *core, RAnalFunction *fcn) {\n\tconst char *defaultCC = r_anal_cc_default (core->anal);\n\tchar *name = r_core_anal_fcn_name (core, fcn);\n\tchar *paren = strchr (name, '(');\n\tif (paren) {\n\t\t*paren = '\\0';\n\t}\n\tr_cons_printf (\"\\\"f %s %\"PFMT64u\" 0x%08\"PFMT64x\"\\\"\\n\", name, r_anal_function_linear_size (fcn), fcn->addr);\n\tr_cons_printf (\"\\\"af+ 0x%08\"PFMT64x\" %s %c %c\\\"\\n\",\n\t\t\tfcn->addr, name, \/\/r_anal_function_size (fcn), name,\n\t\t\tfcn->type == R_ANAL_FCN_TYPE_LOC?'l':\n\t\t\tfcn->type == R_ANAL_FCN_TYPE_SYM?'s':\n\t\t\tfcn->type == R_ANAL_FCN_TYPE_IMP?'i':'f',\n\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?'m':\n\t\t\tfcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?'u':'n');\n\t\/\/ FIXME: this command prints something annoying. Does it have important side-effects?\n\tfcn_list_bbs (fcn);\n\tif (fcn->bits != 0) {\n\t\tr_cons_printf (\"afB %d @ 0x%08\"PFMT64x\"\\n\", fcn->bits, fcn->addr);\n\t}\n\t\/\/ FIXME command injection vuln here\n\tif (fcn->cc || defaultCC) {\n\t\tr_cons_printf (\"s 0x%\"PFMT64x\"\\n\", fcn->addr);\n\t\tr_cons_printf (\"\\\"afc %s\\\"\\n\", fcn->cc? fcn->cc: defaultCC);\n\t\tr_cons_println (\"s-\");\n\t}\n\tif (fcn->folded) {\n\t\tr_cons_printf (\"afF @ 0x%08\"PFMT64x\"\\n\", fcn->addr);\n\t}\n\tif (fcn) {\n\t\t\/* show variables  and arguments *\/\n\t\tr_core_cmdf (core, \"afvb* @ 0x%\"PFMT64x\"\\n\", fcn->addr);\n\t\tr_core_cmdf (core, \"afvr* @ 0x%\"PFMT64x\"\\n\", fcn->addr);\n\t\tr_core_cmdf (core, \"afvs* @ 0x%\"PFMT64x\"\\n\", fcn->addr);\n\t}\n\t\/* Show references *\/\n\tRListIter *refiter;\n\tRAnalRef *refi;\n\tRList *refs = r_anal_function_get_refs (fcn);\n\tr_list_foreach (refs, refiter, refi) {\n\t\tswitch (refi->type) {\n\t\tcase R_ANAL_REF_TYPE_CALL:\n\t\t\tr_cons_printf (\"axC 0x%\"PFMT64x\" 0x%\"PFMT64x\"\\n\", refi->addr, refi->at);\n\t\t\tbreak;\n\t\tcase R_ANAL_REF_TYPE_DATA:\n\t\t\tr_cons_printf (\"axd 0x%\"PFMT64x\" 0x%\"PFMT64x\"\\n\", refi->addr, refi->at);\n\t\t\tbreak;\n\t\tcase R_ANAL_REF_TYPE_CODE:\n\t\t\tr_cons_printf (\"axc 0x%\"PFMT64x\" 0x%\"PFMT64x\"\\n\", refi->addr, refi->at);\n\t\t\tbreak;\n\t\tcase R_ANAL_REF_TYPE_STRING:\n\t\t\tr_cons_printf (\"axs 0x%\"PFMT64x\" 0x%\"PFMT64x\"\\n\", refi->addr, refi->at);\n\t\t\tbreak;\n\t\tcase R_ANAL_REF_TYPE_NULL:\n\t\tdefault:\n\t\t\tr_cons_printf (\"ax 0x%\"PFMT64x\" 0x%\"PFMT64x\"\\n\", refi->addr, refi->at);\n\t\t\tbreak;\n\t\t}\n\t}\n\tr_list_free (refs);\n\t\/*Saving Function stack frame*\/\n\tr_cons_printf (\"afS %d @ 0x%\"PFMT64x\"\\n\", fcn->maxstack, fcn->addr);\n\tfree (name);\n\treturn 0;\n}","target":0,"code_token_length":914,"total_token_length":1150,"max_tokens_setting":2048}
+{"idx":220906,"func":"void DependencyOptimizer::GroupCrossDeviceControlEdges(bool host_granularity) {\n  VLOG(1)\n      << \"DependencyOptimizer::GroupCrossDeviceControlEdges host_granularity=\"\n      << host_granularity;\n  const int num_nodes = optimized_graph_->node_size();\n  for (int i = 0; i < num_nodes; ++i) {\n    NodeDef* node = optimized_graph_->mutable_node(i);\n    if (node->device().empty()) continue;\n    string rest, node_device = node->device();\n    if (host_granularity) {\n      DeviceNameUtils::SplitDeviceName(node->device(), &node_device, &rest);\n    }\n\n    \/\/ Creates new noop nodes for devices on which multiple control inputs are\n    \/\/ located.\n\n    \/\/ Map keyed by device name to the newly introduced Noop node for that\n    \/\/ device. A nullptr value means that we have only seen a single node on\n    \/\/ that device.\n    std::map<string, NodeDef*> noops;\n    int num_noops = 0;\n    for (int j = 0; j < node->input_size(); ++j) {\n      if (IsControlInput(node->input(j))) {\n        const NodeDef* input = node_map_->GetNode(node->input(j));\n        if (input == nullptr || input->device().empty()) continue;\n        string input_device = input->device();\n        if (host_granularity) {\n          DeviceNameUtils::SplitDeviceName(input->device(), &input_device,\n                                           &rest);\n        }\n        if (input_device != node_device) {\n          VLOG(2) << \"Cross-device \" << node->name() << \" \" << input->device()\n                  << \" -> \" << node->device();\n          auto emplace_result = noops.emplace(input_device, nullptr);\n          if (!emplace_result.second &&\n              emplace_result.first->second == nullptr) {\n            VLOG(2) << \"Duplicate input device from \" << node->name();\n            \/\/ This is the second cross-device control input from the same\n            \/\/ device. Creates an intermediate noop node on that device.\n            string group_name;\n            NodeDef* noop;\n            \/\/ Creates a fresh node name; there may be conflicting names from\n            \/\/ a previous iteration of the optimizer.\n            do {\n              group_name = AddPrefixToNodeName(\n                  node->name(),\n                  strings::StrCat(\"GroupCrossDeviceControlEdges_\", num_noops));\n              noop = node_map_->GetNode(group_name);\n              ++num_noops;\n            } while (noop != nullptr);\n            noop = optimized_graph_->add_node();\n            noop->set_name(group_name);\n            noop->set_device(input->device());\n            noop->set_op(\"NoOp\");\n            node_map_->AddNode(noop->name(), noop);\n            emplace_result.first->second = noop;\n            VLOG(1) << \"GroupCrossDeviceControlEdges: Added \"\n                    << SummarizeNodeDef(*noop);\n          }\n        }\n      }\n    }\n\n    \/\/ Reroute existing control edges to go via the newly introduced NoOp nodes.\n    int pos = 0;\n    while (pos < node->input_size()) {\n      const string& input_name = node->input(pos);\n      if (IsControlInput(input_name)) {\n        NodeDef* input = node_map_->GetNode(input_name);\n        if (input == nullptr) {\n          ++pos;\n        } else {\n          string input_device = input->device();\n          if (host_granularity) {\n            DeviceNameUtils::SplitDeviceName(input->device(), &input_device,\n                                             &rest);\n          }\n          auto it = noops.find(input_device);\n          if (it == noops.end() || it->second == nullptr) {\n            ++pos;\n          } else {\n            VLOG(2) << \"Rewriting input from \" << input_name;\n            node->mutable_input()->SwapElements(pos, node->input_size() - 1);\n            node->mutable_input()->RemoveLast();\n            it->second->add_input(AsControlDependency(*input));\n            node_map_->UpdateOutput(input_name, node->name(),\n                                    it->second->name());\n          }\n        }\n      } else {\n        ++pos;\n      }\n    }\n    for (const auto& entry : noops) {\n      if (entry.second) {\n        node->add_input(AsControlDependency(*entry.second));\n        node_map_->AddOutput(entry.second->name(), node->name());\n      }\n    }\n  }\n}","target":0,"code_token_length":943,"total_token_length":1179,"max_tokens_setting":2048}
+{"idx":230119,"func":"static json_t * get_assertion_from_session(struct config_module * config, json_t * j_params, const char * username, const char * session, int mock) {\n  json_t * j_query, * j_result, * j_return;\n  char * username_escaped, * mod_name_escaped, * username_clause, * expiration_clause;\n  char * session_hash;\n  int res;\n  time_t now;\n\n  if (o_strlen(session)) {\n    session_hash = generate_hash(config->hash_algorithm, session);\n    if (session_hash != NULL) {\n      time(&now);\n      username_escaped = h_escape_string_with_quotes(config->conn, username);\n      mod_name_escaped = h_escape_string_with_quotes(config->conn, json_string_value(json_object_get(j_params, \"mod_name\")));\n      username_clause = msprintf(\" = (SELECT gswu_id FROM \"G_TABLE_WEBAUTHN_USER\" WHERE UPPER(gswu_username) = UPPER(%s) AND gswu_mod_name = %s)\", username_escaped, mod_name_escaped);\n      if (config->conn->type==HOEL_DB_TYPE_MARIADB) {\n        expiration_clause = msprintf(\"> FROM_UNIXTIME(%u)\", (now - (unsigned int)json_integer_value(json_object_get(j_params, \"credential-assertion\"))));\n      } else if (config->conn->type==HOEL_DB_TYPE_PGSQL) {\n        expiration_clause = msprintf(\"> TO_TIMESTAMP(%u)\", (now - (unsigned int)json_integer_value(json_object_get(j_params, \"credential-assertion\"))));\n      } else { \/\/ HOEL_DB_TYPE_SQLITE\n        expiration_clause = msprintf(\"> %u\", (now - (unsigned int)json_integer_value(json_object_get(j_params, \"credential-assertion\"))));\n      }\n      j_query = json_pack(\"{sss[ssss]s{sss{ssss}sis{ssss}si}}\",\n                          \"table\",\n                          G_TABLE_WEBAUTHN_ASSERTION,\n                          \"columns\",\n                            \"gswa_id\",\n                            \"gswu_id\",\n                            \"gswa_session_hash AS session_hash\",\n                            \"gswa_challenge_hash AS challenge_hash\",\n                          \"where\",\n                            \"gswa_session_hash\",\n                            session_hash,\n                            \"gswu_id\",\n                              \"operator\",\n                              \"raw\",\n                              \"value\",\n                              username_clause,\n                            \"gswa_status\",\n                            0,\n                            \"gswa_issued_at\",\n                              \"operator\",\n                              \"raw\",\n                              \"value\",\n                              expiration_clause,\n                            \"gswa_mock\",\n                            mock);\n      o_free(username_clause);\n      o_free(username_escaped);\n      o_free(mod_name_escaped);\n      o_free(expiration_clause);\n      res = h_select(config->conn, j_query, &j_result, NULL);\n      json_decref(j_query);\n      if (res == H_OK) {\n        if (json_array_size(j_result)) {\n          j_return = json_pack(\"{sisO}\", \"result\", G_OK, \"assertion\", json_array_get(j_result, 0));\n        } else {\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR_NOT_FOUND);\n        }\n        json_decref(j_result);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"get_assertion_from_session - Error executing j_query\");\n        config->glewlwyd_module_callback_metrics_increment_counter(config, GLWD_METRICS_DATABSE_ERROR, 1, NULL);\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_DB);\n      }\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"get_assertion_from_session - Error generate_hash\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    o_free(session_hash);\n  } else {\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n  }\n  return j_return;\n}","target":0,"code_token_length":820,"total_token_length":1056,"max_tokens_setting":2048}
+{"idx":255934,"func":"Status ShapeRefiner::ConstantPartialShape(\n    InferenceContext* target_context, const Node* node, int dst_idx,\n    ShapeHandle* result, shape_inference::InferenceContext* outer_context) {\n  const Edge* input_edge;\n  TF_RETURN_IF_ERROR(node->input_edge(dst_idx, &input_edge));\n\n  InferenceContext* src_context = GetContext(input_edge->src());\n  if (src_context == nullptr) return errors::Internal(\"Missing src context\");\n  ShapeHandle src_shape = src_context->output(input_edge->src_output());\n\n  if (src_context->Value(src_context->Rank(src_shape)) == 0) {\n    Tensor t;\n    bool evaluated = false;\n    TF_RETURN_IF_ERROR(EvaluateConstantTensorForEdge(node, dst_idx, &evaluated,\n                                                     &t, outer_context));\n    if (!evaluated) {\n      return errors::InvalidArgument(\n          \"Received a shape scalar with unknown static value.  A static value \"\n          \"of '-1' is required to represent an unknown shape.\");\n    }\n    if (t.dims() == 0) {\n      if (t.dtype() == DT_INT32 && t.scalar<int32>()() == -1) {\n        *result = target_context->UnknownShape();\n        return Status::OK();\n      } else if (t.dtype() == DT_INT64 && t.scalar<int64>()() == -1) {\n        *result = target_context->UnknownShape();\n        return Status::OK();\n      }\n    }\n    return errors::InvalidArgument(\n        \"Received an invalid shape scalar with a static value that is not \"\n        \"'-1': \",\n        t.DebugString());\n  }\n\n  TF_RETURN_IF_ERROR(src_context->WithRank(src_shape, 1, &src_shape));\n\n  const string& src_op = input_edge->src()->type_string();\n  if (src_context->Value(src_context->Dim(src_shape, 0)) == 0) {\n    \/\/ Source tensor is a vector of length 0, so the shape it\n    \/\/ represents is as scalar.\n    *result = target_context->Scalar();\n  } else if (src_op == \"Cast\") {\n    \/\/ First try to evaluate the current tensor, as it might be a valid cast of\n    \/\/ a float.\n    Tensor t;\n    bool evaluated = false;\n    if (EvaluateConstantTensorForEdge(node, dst_idx, &evaluated, &t,\n                                      outer_context)\n            .ok()) {\n      if (evaluated &&\n          target_context->MakeShapeFromTensor(&t, src_shape, result).ok()) {\n        return Status::OK();\n      }\n    }\n\n    \/\/ Then try to infer partial shape from the input to the cast tensor.\n    ShapeHandle pre_cast_shape;\n    if (!ConstantPartialShape(target_context, input_edge->src(), 0,\n                              &pre_cast_shape, outer_context)\n             .ok()) {\n      TF_RETURN_IF_ERROR(\n          target_context->MakeShapeFromTensor(nullptr, src_shape, result));\n    }\n    if (!target_context->RankKnown(pre_cast_shape)) {\n      \/\/ Failed to evaluate. Treat the output as completely unknown.\n      *result = target_context->UnknownShape();\n      return Status::OK();\n    }\n    auto* dest_type = input_edge->src()->attrs().Find(\"DstT\");\n    if (dest_type == nullptr || dest_type->value_case() != AttrValue::kType ||\n        (dest_type->type() != DT_INT32 && dest_type->type() != DT_INT64)) {\n      \/\/ Casting to a weird type. Do not attempt to infer across it.\n      *result = target_context->MakeShape(std::vector<DimensionHandle>(\n          target_context->Rank(pre_cast_shape), target_context->UnknownDim()));\n      return Status::OK();\n    }\n    *result = pre_cast_shape;\n  } else if (src_op == \"Shape\") {\n    *result = src_context->input(0);\n  } else if (src_op == \"ShapeN\") {\n    *result = src_context->input(input_edge->src_output());\n  } else if (src_op == \"Pack\") {\n    std::vector<DimensionHandle> dims;\n    \/\/ Pack is concatenating its input scalars to form the shape tensor vector.\n    for (int i = 0; i < src_context->num_inputs(); ++i) {\n      int64 size;\n      bool evaluated;\n      TF_RETURN_IF_ERROR(EvaluateConstantIntScalarEdge(\n          input_edge->src(), i, &evaluated, &size, outer_context));\n      if (evaluated) {\n        dims.push_back(size < 0 ? target_context->UnknownDim()\n                                : target_context->MakeDim(size));\n      } else {\n        dims.push_back(target_context->UnknownDim());\n      }\n    }\n    *result = target_context->MakeShape(dims);\n  } else if (src_op == \"Concat\" || src_op == \"ConcatV2\") {\n    *result = target_context->Scalar();\n    \/\/ For Concat, input 0 is concat dim; for V2 it is the last input.\n    const int concat_dim =\n        src_op == \"Concat\" ? 0 : src_context->num_inputs() - 1;\n    \/\/ Concat is concatenating its input shape vectors.\n    for (int i = 0; i < src_context->num_inputs(); ++i) {\n      \/\/ Concat dim is ignored (and will always be a scalar).\n      if (i == concat_dim) continue;\n      ShapeHandle sub_result;\n      TF_RETURN_IF_ERROR(ConstantPartialShape(target_context, input_edge->src(),\n                                              i, &sub_result, outer_context));\n      if (!target_context->RankKnown(sub_result)) {\n        \/\/ Failed to evaluate. Treat the output as completely unknown.\n        \/\/ TODO(cwhipkey): we could rely on all inputs being the same rank, so\n        \/\/ figure that rank out and append the right number of unknown dims.\n        *result = target_context->UnknownShape();\n        return Status::OK();\n      }\n      TF_RETURN_IF_ERROR(\n          target_context->Concatenate(*result, sub_result, result));\n    }\n  } else if (src_op == \"StridedSlice\") {\n    TF_RETURN_IF_ERROR(PartialStridedSliceShape(input_edge->src(), src_context,\n                                                result, outer_context));\n  } else if (src_op == \"VariableShape\") {\n    auto* handle_data = src_context->input_handle_shapes_and_types(0);\n    if (handle_data != nullptr && !handle_data->empty()) {\n      *result = handle_data->at(0).shape;\n    } else {\n      *result = target_context->UnknownShape();\n    }\n  } else {\n    Tensor t;\n    bool evaluated = false;\n    TF_RETURN_IF_ERROR(EvaluateConstantTensorForEdge(node, dst_idx, &evaluated,\n                                                     &t, outer_context));\n    TF_RETURN_IF_ERROR(target_context->MakeShapeFromTensor(\n        evaluated ? &t : nullptr, src_shape, result));\n  }\n  return Status::OK();\n}","target":0,"code_token_length":1465,"total_token_length":1701,"max_tokens_setting":2048}
+{"idx":300833,"func":"int tipc_sk_dump(struct sock *sk, u16 dqueues, char *buf)\n{\n\tint i = 0;\n\tsize_t sz = (dqueues) ? SK_LMAX : SK_LMIN;\n\tu32 conn_type, conn_instance;\n\tstruct tipc_sock *tsk;\n\tstruct publication *p;\n\tbool tsk_connected;\n\n\tif (!sk) {\n\t\ti += scnprintf(buf, sz, \"sk data: (null)\\n\");\n\t\treturn i;\n\t}\n\n\ttsk = tipc_sk(sk);\n\ttsk_connected = !tipc_sk_type_connectionless(sk);\n\n\ti += scnprintf(buf, sz, \"sk data: %u\", sk->sk_type);\n\ti += scnprintf(buf + i, sz - i, \" %d\", sk->sk_state);\n\ti += scnprintf(buf + i, sz - i, \" %x\", tsk_own_node(tsk));\n\ti += scnprintf(buf + i, sz - i, \" %u\", tsk->portid);\n\ti += scnprintf(buf + i, sz - i, \" | %u\", tsk_connected);\n\tif (tsk_connected) {\n\t\ti += scnprintf(buf + i, sz - i, \" %x\", tsk_peer_node(tsk));\n\t\ti += scnprintf(buf + i, sz - i, \" %u\", tsk_peer_port(tsk));\n\t\tconn_type = msg_nametype(&tsk->phdr);\n\t\tconn_instance = msg_nameinst(&tsk->phdr);\n\t\ti += scnprintf(buf + i, sz - i, \" %u\", conn_type);\n\t\ti += scnprintf(buf + i, sz - i, \" %u\", conn_instance);\n\t}\n\ti += scnprintf(buf + i, sz - i, \" | %u\", tsk->published);\n\tif (tsk->published) {\n\t\tp = list_first_entry_or_null(&tsk->publications,\n\t\t\t\t\t     struct publication, binding_sock);\n\t\ti += scnprintf(buf + i, sz - i, \" %u\", (p) ? p->sr.type : 0);\n\t\ti += scnprintf(buf + i, sz - i, \" %u\", (p) ? p->sr.lower : 0);\n\t\ti += scnprintf(buf + i, sz - i, \" %u\", (p) ? p->sr.upper : 0);\n\t}\n\ti += scnprintf(buf + i, sz - i, \" | %u\", tsk->snd_win);\n\ti += scnprintf(buf + i, sz - i, \" %u\", tsk->rcv_win);\n\ti += scnprintf(buf + i, sz - i, \" %u\", tsk->max_pkt);\n\ti += scnprintf(buf + i, sz - i, \" %x\", tsk->peer_caps);\n\ti += scnprintf(buf + i, sz - i, \" %u\", tsk->cong_link_cnt);\n\ti += scnprintf(buf + i, sz - i, \" %u\", tsk->snt_unacked);\n\ti += scnprintf(buf + i, sz - i, \" %u\", tsk->rcv_unacked);\n\ti += scnprintf(buf + i, sz - i, \" %u\", atomic_read(&tsk->dupl_rcvcnt));\n\ti += scnprintf(buf + i, sz - i, \" %u\", sk->sk_shutdown);\n\ti += scnprintf(buf + i, sz - i, \" | %d\", sk_wmem_alloc_get(sk));\n\ti += scnprintf(buf + i, sz - i, \" %d\", sk->sk_sndbuf);\n\ti += scnprintf(buf + i, sz - i, \" | %d\", sk_rmem_alloc_get(sk));\n\ti += scnprintf(buf + i, sz - i, \" %d\", sk->sk_rcvbuf);\n\ti += scnprintf(buf + i, sz - i, \" | %d\\n\", READ_ONCE(sk->sk_backlog.len));\n\n\tif (dqueues & TIPC_DUMP_SK_SNDQ) {\n\t\ti += scnprintf(buf + i, sz - i, \"sk_write_queue: \");\n\t\ti += tipc_list_dump(&sk->sk_write_queue, false, buf + i);\n\t}\n\n\tif (dqueues & TIPC_DUMP_SK_RCVQ) {\n\t\ti += scnprintf(buf + i, sz - i, \"sk_receive_queue: \");\n\t\ti += tipc_list_dump(&sk->sk_receive_queue, false, buf + i);\n\t}\n\n\tif (dqueues & TIPC_DUMP_SK_BKLGQ) {\n\t\ti += scnprintf(buf + i, sz - i, \"sk_backlog:\\n  head \");\n\t\ti += tipc_skb_dump(sk->sk_backlog.head, false, buf + i);\n\t\tif (sk->sk_backlog.tail != sk->sk_backlog.head) {\n\t\t\ti += scnprintf(buf + i, sz - i, \"  tail \");\n\t\t\ti += tipc_skb_dump(sk->sk_backlog.tail, false,\n\t\t\t\t\t   buf + i);\n\t\t}\n\t}\n\n\treturn i;\n}","target":0,"code_token_length":1058,"total_token_length":1294,"max_tokens_setting":2048}
+{"idx":432154,"func":"StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> PipelineD::prepareExecutor(\n    const intrusive_ptr<ExpressionContext>& expCtx,\n    const CollectionPtr& collection,\n    const NamespaceString& nss,\n    Pipeline* pipeline,\n    const boost::intrusive_ptr<DocumentSourceSort>& sortStage,\n    std::unique_ptr<GroupFromFirstDocumentTransformation> rewrittenGroupStage,\n    QueryMetadataBitSet unavailableMetadata,\n    const BSONObj& queryObj,\n    SkipThenLimit skipThenLimit,\n    const AggregateCommandRequest* aggRequest,\n    const MatchExpressionParser::AllowedFeatureSet& matcherFeatures,\n    bool* hasNoRequirements) {\n    invariant(hasNoRequirements);\n\n    \/\/ Any data returned from the inner executor must be owned.\n    size_t plannerOpts = QueryPlannerParams::DEFAULT;\n\n    if (pipeline->peekFront() && pipeline->peekFront()->constraints().isChangeStreamStage()) {\n        invariant(expCtx->tailableMode == TailableModeEnum::kTailableAndAwaitData);\n        plannerOpts |= (QueryPlannerParams::TRACK_LATEST_OPLOG_TS |\n                        QueryPlannerParams::ASSERT_MIN_TS_HAS_NOT_FALLEN_OFF_OPLOG);\n    }\n\n    \/\/ The $_requestReshardingResumeToken parameter is only valid for an oplog scan.\n    if (aggRequest && aggRequest->getRequestReshardingResumeToken()) {\n        plannerOpts |= (QueryPlannerParams::TRACK_LATEST_OPLOG_TS |\n                        QueryPlannerParams::ASSERT_MIN_TS_HAS_NOT_FALLEN_OFF_OPLOG);\n    }\n\n    \/\/ If there is a sort stage eligible for pushdown, serialize its SortPattern to a BSONObj. The\n    \/\/ BSONObj format is currently necessary to request that the sort is computed by the query layer\n    \/\/ inside the inner PlanExecutor. We also remove the $sort stage from the Pipeline, since it\n    \/\/ will be handled instead by PlanStage execution.\n    BSONObj sortObj;\n    if (sortStage) {\n        sortObj = sortStage->getSortKeyPattern()\n                      .serialize(SortPattern::SortKeySerialization::kForPipelineSerialization)\n                      .toBson();\n\n        pipeline->popFrontWithName(DocumentSourceSort::kStageName);\n\n        \/\/ Now that we've pushed down the sort, see if there is a $limit and $skip to push down\n        \/\/ also. We should not already have a limit or skip here, otherwise it would be incorrect\n        \/\/ for the caller to pass us a sort stage to push down, since the order matters.\n        invariant(!skipThenLimit.getLimit());\n        invariant(!skipThenLimit.getSkip());\n\n        \/\/ Since all $limit stages were already pushdowned to the sort stage, we are only looking\n        \/\/ for $skip stages.\n        auto skip = extractSkipForPushdown(pipeline);\n\n        \/\/ Since the limit from $sort is going before the extracted $skip stages, we construct\n        \/\/ 'LimitThenSkip' object and then convert it 'SkipThenLimit'.\n        skipThenLimit = LimitThenSkip(sortStage->getLimit(), skip).flip();\n    }\n\n    \/\/ Perform dependency analysis. In order to minimize the dependency set, we only analyze the\n    \/\/ stages that remain in the pipeline after pushdown. In particular, any dependencies for a\n    \/\/ $match or $sort pushed down into the query layer will not be reflected here.\n    auto deps = pipeline->getDependencies(unavailableMetadata);\n    *hasNoRequirements = deps.hasNoRequirements();\n\n    BSONObj projObj;\n    if (*hasNoRequirements) {\n        \/\/ This query might be eligible for count optimizations, since the remaining stages in the\n        \/\/ pipeline don't actually need to read any data produced by the query execution layer.\n        plannerOpts |= QueryPlannerParams::IS_COUNT;\n    } else {\n        \/\/ Build a BSONObj representing a projection eligible for pushdown. If there is an inclusion\n        \/\/ projection at the front of the pipeline, it will be removed and handled by the PlanStage\n        \/\/ layer. If a projection cannot be pushed down, an empty BSONObj will be returned.\n\n        \/\/ In most cases .find() behaves as if it evaluates in a predictable order:\n        \/\/     predicate, sort, skip, limit, projection.\n        \/\/ But there is at least one case where it runs the projection before the sort\/skip\/limit:\n        \/\/ when the predicate has a rooted $or.  (In that case we plan each branch of the $or\n        \/\/ separately, using Subplan, and include the projection on each branch.)\n\n        \/\/ To work around this behavior, don't allow pushing down expressions if we are also going\n        \/\/ to push down a sort, skip or limit. We don't want the expressions to be evaluated on any\n        \/\/ documents that the sort\/skip\/limit would have filtered out. (The sort stage can be a\n        \/\/ top-k sort, which both sorts and limits.)\n        bool allowExpressions = !sortStage && !skipThenLimit.getSkip() && !skipThenLimit.getLimit();\n        projObj = buildProjectionForPushdown(deps, pipeline, allowExpressions);\n        plannerOpts |= QueryPlannerParams::RETURN_OWNED_DATA;\n    }\n\n    if (rewrittenGroupStage) {\n        \/\/ See if the query system can handle the $group and $sort stage using a DISTINCT_SCAN\n        \/\/ (SERVER-9507).\n        auto swExecutorGrouped = attemptToGetExecutor(expCtx,\n                                                      collection,\n                                                      nss,\n                                                      queryObj,\n                                                      projObj,\n                                                      deps.metadataDeps(),\n                                                      sortObj,\n                                                      SkipThenLimit{boost::none, boost::none},\n                                                      rewrittenGroupStage->groupId(),\n                                                      aggRequest,\n                                                      plannerOpts,\n                                                      matcherFeatures);\n\n        if (swExecutorGrouped.isOK()) {\n            \/\/ Any $limit stage before the $group stage should make the pipeline ineligible for this\n            \/\/ optimization.\n            invariant(!sortStage || !sortStage->hasLimit());\n\n            \/\/ We remove the $sort and $group stages that begin the pipeline, because the executor\n            \/\/ will handle the sort, and the groupTransform (added below) will handle the $group\n            \/\/ stage.\n            pipeline->popFrontWithName(DocumentSourceSort::kStageName);\n            pipeline->popFrontWithName(DocumentSourceGroup::kStageName);\n\n            boost::intrusive_ptr<DocumentSource> groupTransform(\n                new DocumentSourceSingleDocumentTransformation(\n                    expCtx,\n                    std::move(rewrittenGroupStage),\n                    \"$groupByDistinctScan\",\n                    false \/* independentOfAnyCollection *\/));\n            pipeline->addInitialSource(groupTransform);\n\n            return swExecutorGrouped;\n        } else if (swExecutorGrouped != ErrorCodes::NoQueryExecutionPlans) {\n            return swExecutorGrouped.getStatus().withContext(\n                \"Failed to determine whether query system can provide a \"\n                \"DISTINCT_SCAN grouping\");\n        }\n    }\n\n    return attemptToGetExecutor(expCtx,\n                                collection,\n                                nss,\n                                queryObj,\n                                projObj,\n                                deps.metadataDeps(),\n                                sortObj,\n                                skipThenLimit,\n                                boost::none, \/* groupIdForDistinctScan *\/\n                                aggRequest,\n                                plannerOpts,\n                                matcherFeatures);\n}","target":0,"code_token_length":1493,"total_token_length":1729,"max_tokens_setting":2048}
+{"idx":238631,"func":"static int check_map_func_compatibility(struct bpf_verifier_env *env,\n\t\t\t\t\tstruct bpf_map *map, int func_id)\n{\n\tif (!map)\n\t\treturn 0;\n\n\t\/* We need a two way check, first is from map perspective ... *\/\n\tswitch (map->map_type) {\n\tcase BPF_MAP_TYPE_PROG_ARRAY:\n\t\tif (func_id != BPF_FUNC_tail_call)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_PERF_EVENT_ARRAY:\n\t\tif (func_id != BPF_FUNC_perf_event_read &&\n\t\t    func_id != BPF_FUNC_perf_event_output &&\n\t\t    func_id != BPF_FUNC_skb_output &&\n\t\t    func_id != BPF_FUNC_perf_event_read_value &&\n\t\t    func_id != BPF_FUNC_xdp_output)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_RINGBUF:\n\t\tif (func_id != BPF_FUNC_ringbuf_output &&\n\t\t    func_id != BPF_FUNC_ringbuf_reserve &&\n\t\t    func_id != BPF_FUNC_ringbuf_query)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_STACK_TRACE:\n\t\tif (func_id != BPF_FUNC_get_stackid)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_CGROUP_ARRAY:\n\t\tif (func_id != BPF_FUNC_skb_under_cgroup &&\n\t\t    func_id != BPF_FUNC_current_task_under_cgroup)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_CGROUP_STORAGE:\n\tcase BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE:\n\t\tif (func_id != BPF_FUNC_get_local_storage)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_DEVMAP:\n\tcase BPF_MAP_TYPE_DEVMAP_HASH:\n\t\tif (func_id != BPF_FUNC_redirect_map &&\n\t\t    func_id != BPF_FUNC_map_lookup_elem)\n\t\t\tgoto error;\n\t\tbreak;\n\t\/* Restrict bpf side of cpumap and xskmap, open when use-cases\n\t * appear.\n\t *\/\n\tcase BPF_MAP_TYPE_CPUMAP:\n\t\tif (func_id != BPF_FUNC_redirect_map)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_XSKMAP:\n\t\tif (func_id != BPF_FUNC_redirect_map &&\n\t\t    func_id != BPF_FUNC_map_lookup_elem)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_ARRAY_OF_MAPS:\n\tcase BPF_MAP_TYPE_HASH_OF_MAPS:\n\t\tif (func_id != BPF_FUNC_map_lookup_elem)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_SOCKMAP:\n\t\tif (func_id != BPF_FUNC_sk_redirect_map &&\n\t\t    func_id != BPF_FUNC_sock_map_update &&\n\t\t    func_id != BPF_FUNC_map_delete_elem &&\n\t\t    func_id != BPF_FUNC_msg_redirect_map &&\n\t\t    func_id != BPF_FUNC_sk_select_reuseport &&\n\t\t    func_id != BPF_FUNC_map_lookup_elem &&\n\t\t    !may_update_sockmap(env, func_id))\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_SOCKHASH:\n\t\tif (func_id != BPF_FUNC_sk_redirect_hash &&\n\t\t    func_id != BPF_FUNC_sock_hash_update &&\n\t\t    func_id != BPF_FUNC_map_delete_elem &&\n\t\t    func_id != BPF_FUNC_msg_redirect_hash &&\n\t\t    func_id != BPF_FUNC_sk_select_reuseport &&\n\t\t    func_id != BPF_FUNC_map_lookup_elem &&\n\t\t    !may_update_sockmap(env, func_id))\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_REUSEPORT_SOCKARRAY:\n\t\tif (func_id != BPF_FUNC_sk_select_reuseport)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_QUEUE:\n\tcase BPF_MAP_TYPE_STACK:\n\t\tif (func_id != BPF_FUNC_map_peek_elem &&\n\t\t    func_id != BPF_FUNC_map_pop_elem &&\n\t\t    func_id != BPF_FUNC_map_push_elem)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_SK_STORAGE:\n\t\tif (func_id != BPF_FUNC_sk_storage_get &&\n\t\t    func_id != BPF_FUNC_sk_storage_delete)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_INODE_STORAGE:\n\t\tif (func_id != BPF_FUNC_inode_storage_get &&\n\t\t    func_id != BPF_FUNC_inode_storage_delete)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_TASK_STORAGE:\n\t\tif (func_id != BPF_FUNC_task_storage_get &&\n\t\t    func_id != BPF_FUNC_task_storage_delete)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_MAP_TYPE_BLOOM_FILTER:\n\t\tif (func_id != BPF_FUNC_map_peek_elem &&\n\t\t    func_id != BPF_FUNC_map_push_elem)\n\t\t\tgoto error;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\t\/* ... and second from the function itself. *\/\n\tswitch (func_id) {\n\tcase BPF_FUNC_tail_call:\n\t\tif (map->map_type != BPF_MAP_TYPE_PROG_ARRAY)\n\t\t\tgoto error;\n\t\tif (env->subprog_cnt > 1 && !allow_tail_call_in_subprogs(env)) {\n\t\t\tverbose(env, \"tail_calls are not allowed in non-JITed programs with bpf-to-bpf calls\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbreak;\n\tcase BPF_FUNC_perf_event_read:\n\tcase BPF_FUNC_perf_event_output:\n\tcase BPF_FUNC_perf_event_read_value:\n\tcase BPF_FUNC_skb_output:\n\tcase BPF_FUNC_xdp_output:\n\t\tif (map->map_type != BPF_MAP_TYPE_PERF_EVENT_ARRAY)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_ringbuf_output:\n\tcase BPF_FUNC_ringbuf_reserve:\n\tcase BPF_FUNC_ringbuf_query:\n\t\tif (map->map_type != BPF_MAP_TYPE_RINGBUF)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_get_stackid:\n\t\tif (map->map_type != BPF_MAP_TYPE_STACK_TRACE)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_current_task_under_cgroup:\n\tcase BPF_FUNC_skb_under_cgroup:\n\t\tif (map->map_type != BPF_MAP_TYPE_CGROUP_ARRAY)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_redirect_map:\n\t\tif (map->map_type != BPF_MAP_TYPE_DEVMAP &&\n\t\t    map->map_type != BPF_MAP_TYPE_DEVMAP_HASH &&\n\t\t    map->map_type != BPF_MAP_TYPE_CPUMAP &&\n\t\t    map->map_type != BPF_MAP_TYPE_XSKMAP)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_sk_redirect_map:\n\tcase BPF_FUNC_msg_redirect_map:\n\tcase BPF_FUNC_sock_map_update:\n\t\tif (map->map_type != BPF_MAP_TYPE_SOCKMAP)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_sk_redirect_hash:\n\tcase BPF_FUNC_msg_redirect_hash:\n\tcase BPF_FUNC_sock_hash_update:\n\t\tif (map->map_type != BPF_MAP_TYPE_SOCKHASH)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_get_local_storage:\n\t\tif (map->map_type != BPF_MAP_TYPE_CGROUP_STORAGE &&\n\t\t    map->map_type != BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_sk_select_reuseport:\n\t\tif (map->map_type != BPF_MAP_TYPE_REUSEPORT_SOCKARRAY &&\n\t\t    map->map_type != BPF_MAP_TYPE_SOCKMAP &&\n\t\t    map->map_type != BPF_MAP_TYPE_SOCKHASH)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_map_pop_elem:\n\t\tif (map->map_type != BPF_MAP_TYPE_QUEUE &&\n\t\t    map->map_type != BPF_MAP_TYPE_STACK)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_map_peek_elem:\n\tcase BPF_FUNC_map_push_elem:\n\t\tif (map->map_type != BPF_MAP_TYPE_QUEUE &&\n\t\t    map->map_type != BPF_MAP_TYPE_STACK &&\n\t\t    map->map_type != BPF_MAP_TYPE_BLOOM_FILTER)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_sk_storage_get:\n\tcase BPF_FUNC_sk_storage_delete:\n\t\tif (map->map_type != BPF_MAP_TYPE_SK_STORAGE)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_inode_storage_get:\n\tcase BPF_FUNC_inode_storage_delete:\n\t\tif (map->map_type != BPF_MAP_TYPE_INODE_STORAGE)\n\t\t\tgoto error;\n\t\tbreak;\n\tcase BPF_FUNC_task_storage_get:\n\tcase BPF_FUNC_task_storage_delete:\n\t\tif (map->map_type != BPF_MAP_TYPE_TASK_STORAGE)\n\t\t\tgoto error;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn 0;\nerror:\n\tverbose(env, \"cannot pass map_type %d into func %s#%d\\n\",\n\t\tmap->map_type, func_id_name(func_id), func_id);\n\treturn -EINVAL;\n}","target":0,"code_token_length":1797,"total_token_length":2033,"max_tokens_setting":2048}
+{"idx":386526,"func":"bool DL_Dxf::handleSplineData(DL_CreationInterface* \/*creationInterface*\/) {\n    \/\/ Allocate Spline knots (group code 72):\n    if (groupCode==72) {\n        maxKnots = toInt(groupValue);\n        if (maxKnots>0) {\n            if (knots!=NULL) {\n                delete[] knots;\n            }\n            knots = new double[maxKnots];\n            for (int i=0; i<maxKnots; ++i) {\n                knots[i] = 0.0;\n            }\n        }\n        knotIndex=-1;\n        return true;\n    }\n\n    \/\/ Allocate Spline control points \/ weights (group code 73):\n    else if (groupCode==73) {\n        maxControlPoints = toInt(groupValue);\n        if (maxControlPoints>0) {\n            if (controlPoints!=NULL) {\n                delete[] controlPoints;\n            }\n            if (weights!=NULL) {\n                delete[] weights;\n            }\n            controlPoints = new double[3*maxControlPoints];\n            weights = new double[maxControlPoints];\n            for (int i=0; i<maxControlPoints; ++i) {\n                controlPoints[i*3] = 0.0;\n                controlPoints[i*3+1] = 0.0;\n                controlPoints[i*3+2] = 0.0;\n                weights[i] = 1.0;\n            }\n        }\n        controlPointIndex=-1;\n        weightIndex=-1;\n        return true;\n    }\n\n    \/\/ Allocate Spline fit points (group code 74):\n    else if (groupCode==74) {\n        maxFitPoints = toInt(groupValue);\n        if (maxFitPoints>0) {\n            if (fitPoints!=NULL) {\n                delete[] fitPoints;\n            }\n            fitPoints = new double[3*maxFitPoints];\n            for (int i=0; i<maxFitPoints; ++i) {\n                fitPoints[i*3] = 0.0;\n                fitPoints[i*3+1] = 0.0;\n                fitPoints[i*3+2] = 0.0;\n            }\n        }\n        fitPointIndex=-1;\n        return true;\n    }\n\n    \/\/ Process spline knot vertices (group code 40):\n    else if (groupCode==40) {\n        if (knotIndex<maxKnots-1) {\n            knotIndex++;\n            knots[knotIndex] = toReal(groupValue);\n        }\n        return true;\n    }\n\n    \/\/ Process spline control points (group codes 10\/20\/30):\n    else if (groupCode==10 || groupCode==20 ||\n             groupCode==30) {\n\n        if (controlPointIndex<maxControlPoints-1 && groupCode==10) {\n            controlPointIndex++;\n        }\n\n        if (controlPointIndex>=0 && controlPointIndex<maxControlPoints) {\n            controlPoints[3*controlPointIndex + (groupCode\/10-1)] = toReal(groupValue);\n        }\n        return true;\n    }\n\n    \/\/ Process spline fit points (group codes 11\/21\/31):\n    else if (groupCode==11 || groupCode==21 || groupCode==31) {\n        if (fitPointIndex<maxFitPoints-1 && groupCode==11) {\n            fitPointIndex++;\n        }\n\n        if (fitPointIndex>=0 && fitPointIndex<maxFitPoints) {\n            fitPoints[3*fitPointIndex + ((groupCode-1)\/10-1)] = toReal(groupValue);\n        }\n        return true;\n    }\n\n    \/\/ Process spline weights (group code 41)\n    else if (groupCode==41) {\n\n        if (weightIndex<maxControlPoints-1) {\n            weightIndex++;\n        }\n\n        if (weightIndex>=0 && weightIndex<maxControlPoints) {\n            weights[weightIndex] = toReal(groupValue);\n        }\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":874,"total_token_length":1110,"max_tokens_setting":2048}
+{"idx":344800,"func":"vdollar_percent_expand(int *parseerror, int dollar, int percent,\n    const char *string, va_list ap)\n{\n#define EXPAND_MAX_KEYS\t16\n\tu_int num_keys = 0, i;\n\tstruct {\n\t\tconst char *key;\n\t\tconst char *repl;\n\t} keys[EXPAND_MAX_KEYS];\n\tstruct sshbuf *buf;\n\tint r, missingvar = 0;\n\tchar *ret = NULL, *var, *varend, *val;\n\tsize_t len;\n\n\tif ((buf = sshbuf_new()) == NULL)\n\t\tfatal_f(\"sshbuf_new failed\");\n\tif (parseerror == NULL)\n\t\tfatal_f(\"null parseerror arg\");\n\t*parseerror = 1;\n\n\t\/* Gather keys if we're doing percent expansion. *\/\n\tif (percent) {\n\t\tfor (num_keys = 0; num_keys < EXPAND_MAX_KEYS; num_keys++) {\n\t\t\tkeys[num_keys].key = va_arg(ap, char *);\n\t\t\tif (keys[num_keys].key == NULL)\n\t\t\t\tbreak;\n\t\t\tkeys[num_keys].repl = va_arg(ap, char *);\n\t\t\tif (keys[num_keys].repl == NULL) {\n\t\t\t\tfatal_f(\"NULL replacement for token %s\",\n\t\t\t\t    keys[num_keys].key);\n\t\t\t}\n\t\t}\n\t\tif (num_keys == EXPAND_MAX_KEYS && va_arg(ap, char *) != NULL)\n\t\t\tfatal_f(\"too many keys\");\n\t\tif (num_keys == 0)\n\t\t\tfatal_f(\"percent expansion without token list\");\n\t}\n\n\t\/* Expand string *\/\n\tfor (i = 0; *string != '\\0'; string++) {\n\t\t\/* Optionally process ${ENVIRONMENT} expansions. *\/\n\t\tif (dollar && string[0] == '$' && string[1] == '{') {\n\t\t\tstring += 2;  \/* skip over '${' *\/\n\t\t\tif ((varend = strchr(string, '}')) == NULL) {\n\t\t\t\terror_f(\"environment variable '%s' missing \"\n\t\t\t\t    \"closing '}'\", string);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tlen = varend - string;\n\t\t\tif (len == 0) {\n\t\t\t\terror_f(\"zero-length environment variable\");\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tvar = xmalloc(len + 1);\n\t\t\t(void)strlcpy(var, string, len + 1);\n\t\t\tif ((val = getenv(var)) == NULL) {\n\t\t\t\terror_f(\"env var ${%s} has no value\", var);\n\t\t\t\tmissingvar = 1;\n\t\t\t} else {\n\t\t\t\tdebug3_f(\"expand ${%s} -> '%s'\", var, val);\n\t\t\t\tif ((r = sshbuf_put(buf, val, strlen(val))) !=0)\n\t\t\t\t\tfatal_fr(r, \"sshbuf_put ${}\");\n\t\t\t}\n\t\t\tfree(var);\n\t\t\tstring += len;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/*\n\t\t * Process percent expansions if we have a list of TOKENs.\n\t\t * If we're not doing percent expansion everything just gets\n\t\t * appended here.\n\t\t *\/\n\t\tif (*string != '%' || !percent) {\n append:\n\t\t\tif ((r = sshbuf_put_u8(buf, *string)) != 0)\n\t\t\t\tfatal_fr(r, \"sshbuf_put_u8 %%\");\n\t\t\tcontinue;\n\t\t}\n\t\tstring++;\n\t\t\/* %% case *\/\n\t\tif (*string == '%')\n\t\t\tgoto append;\n\t\tif (*string == '\\0') {\n\t\t\terror_f(\"invalid format\");\n\t\t\tgoto out;\n\t\t}\n\t\tfor (i = 0; i < num_keys; i++) {\n\t\t\tif (strchr(keys[i].key, *string) != NULL) {\n\t\t\t\tif ((r = sshbuf_put(buf, keys[i].repl,\n\t\t\t\t    strlen(keys[i].repl))) != 0)\n\t\t\t\t\tfatal_fr(r, \"sshbuf_put %%-repl\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i >= num_keys) {\n\t\t\terror_f(\"unknown key %%%c\", *string);\n\t\t\tgoto out;\n\t\t}\n\t}\n\tif (!missingvar && (ret = sshbuf_dup_string(buf)) == NULL)\n\t\tfatal_f(\"sshbuf_dup_string failed\");\n\t*parseerror = 0;\n out:\n\tsshbuf_free(buf);\n\treturn *parseerror ? NULL : ret;\n#undef EXPAND_MAX_KEYS\n}","target":0,"code_token_length":900,"total_token_length":1136,"max_tokens_setting":2048}
+{"idx":450362,"func":"static int vnc_refresh_server_surface(VncDisplay *vd)\n{\n    int width = MIN(pixman_image_get_width(vd->guest.fb),\n                    pixman_image_get_width(vd->server));\n    int height = MIN(pixman_image_get_height(vd->guest.fb),\n                     pixman_image_get_height(vd->server));\n    int cmp_bytes, server_stride, line_bytes, guest_ll, guest_stride, y = 0;\n    uint8_t *guest_row0 = NULL, *server_row0;\n    VncState *vs;\n    int has_dirty = 0;\n    pixman_image_t *tmpbuf = NULL;\n\n    struct timeval tv = { 0, 0 };\n\n    if (!vd->non_adaptive) {\n        gettimeofday(&tv, NULL);\n        has_dirty = vnc_update_stats(vd, &tv);\n    }\n\n    \/*\n     * Walk through the guest dirty map.\n     * Check and copy modified bits from guest to server surface.\n     * Update server dirty map.\n     *\/\n    server_row0 = (uint8_t *)pixman_image_get_data(vd->server);\n    server_stride = guest_stride = guest_ll =\n        pixman_image_get_stride(vd->server);\n    cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,\n                    server_stride);\n    if (vd->guest.format != VNC_SERVER_FB_FORMAT) {\n        int width = pixman_image_get_width(vd->server);\n        tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width);\n    } else {\n        int guest_bpp =\n            PIXMAN_FORMAT_BPP(pixman_image_get_format(vd->guest.fb));\n        guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb);\n        guest_stride = pixman_image_get_stride(vd->guest.fb);\n        guest_ll = pixman_image_get_width(vd->guest.fb)\n                   * DIV_ROUND_UP(guest_bpp, 8);\n    }\n    line_bytes = MIN(server_stride, guest_ll);\n\n    for (;;) {\n        int x;\n        uint8_t *guest_ptr, *server_ptr;\n        unsigned long offset = find_next_bit((unsigned long *) &vd->guest.dirty,\n                                             height * VNC_DIRTY_BPL(&vd->guest),\n                                             y * VNC_DIRTY_BPL(&vd->guest));\n        if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {\n            \/* no more dirty bits *\/\n            break;\n        }\n        y = offset \/ VNC_DIRTY_BPL(&vd->guest);\n        x = offset % VNC_DIRTY_BPL(&vd->guest);\n\n        server_ptr = server_row0 + y * server_stride + x * cmp_bytes;\n\n        if (vd->guest.format != VNC_SERVER_FB_FORMAT) {\n            qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, 0, y);\n            guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);\n        } else {\n            guest_ptr = guest_row0 + y * guest_stride;\n        }\n        guest_ptr += x * cmp_bytes;\n\n        for (; x < DIV_ROUND_UP(width, VNC_DIRTY_PIXELS_PER_BIT);\n             x++, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {\n            int _cmp_bytes = cmp_bytes;\n            if (!test_and_clear_bit(x, vd->guest.dirty[y])) {\n                continue;\n            }\n            if ((x + 1) * cmp_bytes > line_bytes) {\n                _cmp_bytes = line_bytes - x * cmp_bytes;\n            }\n            assert(_cmp_bytes >= 0);\n            if (memcmp(server_ptr, guest_ptr, _cmp_bytes) == 0) {\n                continue;\n            }\n            memcpy(server_ptr, guest_ptr, _cmp_bytes);\n            if (!vd->non_adaptive) {\n                vnc_rect_updated(vd, x * VNC_DIRTY_PIXELS_PER_BIT,\n                                 y, &tv);\n            }\n            QTAILQ_FOREACH(vs, &vd->clients, next) {\n                set_bit(x, vs->dirty[y]);\n            }\n            has_dirty++;\n        }\n\n        y++;\n    }\n    qemu_pixman_image_unref(tmpbuf);\n    return has_dirty;\n}","target":0,"code_token_length":889,"total_token_length":1125,"max_tokens_setting":2048}
+{"idx":291811,"func":"static int rtrs_clt_read_req(struct rtrs_clt_io_req *req)\n{\n\tstruct rtrs_clt_con *con = req->con;\n\tstruct rtrs_path *s = con->c.path;\n\tstruct rtrs_clt_path *clt_path = to_clt_path(s);\n\tstruct rtrs_msg_rdma_read *msg;\n\tstruct rtrs_ib_dev *dev = clt_path->s.dev;\n\n\tstruct ib_reg_wr rwr;\n\tstruct ib_send_wr *wr = NULL;\n\n\tint ret, count = 0;\n\tu32 imm, buf_id;\n\n\tconst size_t tsize = sizeof(*msg) + req->data_len + req->usr_len;\n\n\tif (tsize > clt_path->chunk_size) {\n\t\trtrs_wrn(s,\n\t\t\t  \"Read request failed, message size is %zu, bigger than CHUNK_SIZE %d\\n\",\n\t\t\t  tsize, clt_path->chunk_size);\n\t\treturn -EMSGSIZE;\n\t}\n\n\tif (req->sg_cnt) {\n\t\tcount = ib_dma_map_sg(dev->ib_dev, req->sglist, req->sg_cnt,\n\t\t\t\t      req->dir);\n\t\tif (!count) {\n\t\t\trtrs_wrn(s,\n\t\t\t\t  \"Read request failed, dma map failed\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\t\/* put our message into req->buf after user message*\/\n\tmsg = req->iu->buf + req->usr_len;\n\tmsg->type = cpu_to_le16(RTRS_MSG_READ);\n\tmsg->usr_len = cpu_to_le16(req->usr_len);\n\n\tif (count) {\n\t\tret = rtrs_map_sg_fr(req, count);\n\t\tif (ret < 0) {\n\t\t\trtrs_err_rl(s,\n\t\t\t\t     \"Read request failed, failed to map  fast reg. data, err: %d\\n\",\n\t\t\t\t     ret);\n\t\t\tib_dma_unmap_sg(dev->ib_dev, req->sglist, req->sg_cnt,\n\t\t\t\t\treq->dir);\n\t\t\treturn ret;\n\t\t}\n\t\trwr = (struct ib_reg_wr) {\n\t\t\t.wr.opcode = IB_WR_REG_MR,\n\t\t\t.wr.wr_cqe = &fast_reg_cqe,\n\t\t\t.mr = req->mr,\n\t\t\t.key = req->mr->rkey,\n\t\t\t.access = (IB_ACCESS_LOCAL_WRITE |\n\t\t\t\t   IB_ACCESS_REMOTE_WRITE),\n\t\t};\n\t\twr = &rwr.wr;\n\n\t\tmsg->sg_cnt = cpu_to_le16(1);\n\t\tmsg->flags = cpu_to_le16(RTRS_MSG_NEED_INVAL_F);\n\n\t\tmsg->desc[0].addr = cpu_to_le64(req->mr->iova);\n\t\tmsg->desc[0].key = cpu_to_le32(req->mr->rkey);\n\t\tmsg->desc[0].len = cpu_to_le32(req->mr->length);\n\n\t\t\/* Further invalidation is required *\/\n\t\treq->need_inv = !!RTRS_MSG_NEED_INVAL_F;\n\n\t} else {\n\t\tmsg->sg_cnt = 0;\n\t\tmsg->flags = 0;\n\t}\n\t\/*\n\t * rtrs message will be after the space reserved for disk data and\n\t * user message\n\t *\/\n\timm = req->permit->mem_off + req->data_len + req->usr_len;\n\timm = rtrs_to_io_req_imm(imm);\n\tbuf_id = req->permit->mem_id;\n\n\treq->sg_size  = sizeof(*msg);\n\treq->sg_size += le16_to_cpu(msg->sg_cnt) * sizeof(struct rtrs_sg_desc);\n\treq->sg_size += req->usr_len;\n\n\t\/*\n\t * Update stats now, after request is successfully sent it is not\n\t * safe anymore to touch it.\n\t *\/\n\trtrs_clt_update_all_stats(req, READ);\n\n\tret = rtrs_post_send_rdma(req->con, req, &clt_path->rbufs[buf_id],\n\t\t\t\t   req->data_len, imm, wr);\n\tif (ret) {\n\t\trtrs_err_rl(s,\n\t\t\t    \"Read request failed: error=%d path=%s [%s:%u]\\n\",\n\t\t\t    ret, kobject_name(&clt_path->kobj), clt_path->hca_name,\n\t\t\t    clt_path->hca_port);\n\t\tif (req->mp_policy == MP_POLICY_MIN_INFLIGHT)\n\t\t\tatomic_dec(&clt_path->stats->inflight);\n\t\treq->need_inv = false;\n\t\tif (req->sg_cnt)\n\t\t\tib_dma_unmap_sg(dev->ib_dev, req->sglist,\n\t\t\t\t\treq->sg_cnt, req->dir);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":961,"total_token_length":1197,"max_tokens_setting":2048}
+{"idx":199767,"func":"inbound_cap_ls (server *serv, char *nick, char *extensions_str,\n\t\t\t\t\t const message_tags_data *tags_data)\n{\n\tchar buffer[256];\t\/* buffer for requesting capabilities and emitting the signal *\/\n\tguint32 want_cap; \/* format the CAP REQ string based on previous capabilities being requested or not *\/\n\tguint32 want_sasl; \/* CAP END shouldn't be sent when SASL is requested, it needs further responses *\/\n\tchar **extensions;\n\tint i;\n\n\tEMIT_SIGNAL_TIMESTAMP (XP_TE_CAPLIST, serv->server_session, nick,\n\t\t\t\t\t\t\t\t  extensions_str, NULL, NULL, 0, tags_data->timestamp);\n\twant_cap = 0;\n\twant_sasl = 0;\n\n\textensions = g_strsplit (extensions_str, \" \", 0);\n\n\tstrcpy (buffer, \"CAP REQ :\");\n\n\tfor (i=0; extensions[i]; i++)\n\t{\n\t\tconst char *extension = extensions[i];\n\n\t\tif (!strcmp (extension, \"identify-msg\"))\n\t\t{\n\t\t\tstrcat (buffer, \"identify-msg \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (!strcmp (extension, \"multi-prefix\"))\n\t\t{\n\t\t\tstrcat (buffer, \"multi-prefix \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (!strcmp (extension, \"away-notify\"))\n\t\t{\n\t\t\tstrcat (buffer, \"away-notify \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (!strcmp (extension, \"account-notify\"))\n\t\t{\n\t\t\tstrcat (buffer, \"account-notify \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (!strcmp (extension, \"extended-join\"))\n\t\t{\n\t\t\tstrcat (buffer, \"extended-join \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (!strcmp (extension, \"userhost-in-names\"))\n\t\t{\n\t\t\tstrcat (buffer, \"userhost-in-names \");\n\t\t\twant_cap = 1;\n\t\t}\n\n\t\t\/* bouncers can prefix a name space to the extension so we should use.\n\t\t * znc <= 1.0 uses \"znc.in\/server-time\" and newer use \"znc.in\/server-time-iso\".\n\t\t *\/\n\t\tif (!strcmp (extension, \"znc.in\/server-time-iso\"))\n\t\t{\n\t\t\tstrcat (buffer, \"znc.in\/server-time-iso \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (!strcmp (extension, \"znc.in\/server-time\"))\n\t\t{\n\t\t\tstrcat (buffer, \"znc.in\/server-time \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\tif (prefs.hex_irc_cap_server_time\n\t\t\t && !strcmp (extension, \"server-time\"))\n\t\t{\n\t\t\tstrcat (buffer, \"server-time \");\n\t\t\twant_cap = 1;\n\t\t}\n\t\t\n\t\t\/* if the SASL password is set AND auth mode is set to SASL, request SASL auth *\/\n\t\tif (!strcmp (extension, \"sasl\")\n\t\t\t&& ((serv->loginmethod == LOGIN_SASL && strlen (serv->password) != 0)\n\t\t\t|| (serv->loginmethod == LOGIN_SASLEXTERNAL && serv->have_cert)))\n\t\t{\n\t\t\tstrcat (buffer, \"sasl \");\n\t\t\twant_cap = 1;\n\t\t\twant_sasl = 1;\n\t\t}\n\t}\n\n\tg_strfreev (extensions);\n\n\tif (want_cap)\n\t{\n\t\t\/* buffer + 9 = emit buffer without \"CAP REQ :\" *\/\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_CAPREQ, serv->server_session,\n\t\t\t\t\t\t\t\t\t  buffer + 9, NULL, NULL, NULL, 0,\n\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\t\ttcp_sendf (serv, \"%s\\r\\n\", g_strchomp (buffer));\n\t}\n\tif (!want_sasl)\n\t{\n\t\t\/* if we use SASL, CAP END is dealt via raw numerics *\/\n\t\tserv->sent_capend = TRUE;\n\t\ttcp_send_len (serv, \"CAP END\\r\\n\", 9);\n\t}\n}","target":1,"code_token_length":836,"total_token_length":1072,"max_tokens_setting":2048}
+{"idx":215038,"func":"gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)\n{\n  GstCaps *caps;\n  guint avail;\n  GstFlowReturn res = GST_FLOW_OK;\n\n  GstFlxDec *flxdec;\n  FlxHeader *flxh;\n\n  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);\n  flxdec = (GstFlxDec *) parent;\n  g_return_val_if_fail (flxdec != NULL, GST_FLOW_ERROR);\n\n  gst_adapter_push (flxdec->adapter, buf);\n  avail = gst_adapter_available (flxdec->adapter);\n\n  if (flxdec->state == GST_FLXDEC_READ_HEADER) {\n    if (avail >= FlxHeaderSize) {\n      const guint8 *data = gst_adapter_map (flxdec->adapter, FlxHeaderSize);\n      GstCaps *templ;\n\n      memcpy ((gchar *) & flxdec->hdr, data, FlxHeaderSize);\n      FLX_HDR_FIX_ENDIANNESS (&(flxdec->hdr));\n      gst_adapter_unmap (flxdec->adapter);\n      gst_adapter_flush (flxdec->adapter, FlxHeaderSize);\n\n      flxh = &flxdec->hdr;\n\n      \/* check header *\/\n      if (flxh->type != FLX_MAGICHDR_FLI &&\n          flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX)\n        goto wrong_type;\n\n      GST_LOG (\"size      :  %d\", flxh->size);\n      GST_LOG (\"frames    :  %d\", flxh->frames);\n      GST_LOG (\"width     :  %d\", flxh->width);\n      GST_LOG (\"height    :  %d\", flxh->height);\n      GST_LOG (\"depth     :  %d\", flxh->depth);\n      GST_LOG (\"speed     :  %d\", flxh->speed);\n\n      flxdec->next_time = 0;\n\n      if (flxh->type == FLX_MAGICHDR_FLI) {\n        flxdec->frame_time = JIFFIE * flxh->speed;\n      } else if (flxh->speed == 0) {\n        flxdec->frame_time = GST_SECOND \/ 70;\n      } else {\n        flxdec->frame_time = flxh->speed * GST_MSECOND;\n      }\n\n      flxdec->duration = flxh->frames * flxdec->frame_time;\n      GST_LOG (\"duration   :  %\" GST_TIME_FORMAT,\n          GST_TIME_ARGS (flxdec->duration));\n\n      templ = gst_pad_get_pad_template_caps (flxdec->srcpad);\n      caps = gst_caps_copy (templ);\n      gst_caps_unref (templ);\n      gst_caps_set_simple (caps,\n          \"width\", G_TYPE_INT, flxh->width,\n          \"height\", G_TYPE_INT, flxh->height,\n          \"framerate\", GST_TYPE_FRACTION, (gint) GST_MSECOND,\n          (gint) flxdec->frame_time \/ 1000, NULL);\n\n      gst_pad_set_caps (flxdec->srcpad, caps);\n      gst_caps_unref (caps);\n\n      if (flxh->depth <= 8)\n        flxdec->converter =\n            flx_colorspace_converter_new (flxh->width, flxh->height);\n\n      if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) {\n        GST_LOG (\"(FLC) aspect_dx :  %d\", flxh->aspect_dx);\n        GST_LOG (\"(FLC) aspect_dy :  %d\", flxh->aspect_dy);\n        GST_LOG (\"(FLC) oframe1   :  0x%08x\", flxh->oframe1);\n        GST_LOG (\"(FLC) oframe2   :  0x%08x\", flxh->oframe2);\n      }\n\n      flxdec->size = ((guint) flxh->width * (guint) flxh->height);\n\n      \/* create delta and output frame *\/\n      flxdec->frame_data = g_malloc (flxdec->size);\n      flxdec->delta_data = g_malloc (flxdec->size);\n\n      flxdec->state = GST_FLXDEC_PLAYING;\n    }\n  } else if (flxdec->state == GST_FLXDEC_PLAYING) {\n    GstBuffer *out;\n\n    \/* while we have enough data in the adapter *\/\n    while (avail >= FlxFrameChunkSize && res == GST_FLOW_OK) {\n      FlxFrameChunk flxfh;\n      guchar *chunk;\n      const guint8 *data;\n      GstMapInfo map;\n\n      chunk = NULL;\n      data = gst_adapter_map (flxdec->adapter, FlxFrameChunkSize);\n      memcpy (&flxfh, data, FlxFrameChunkSize);\n      FLX_FRAME_CHUNK_FIX_ENDIANNESS (&flxfh);\n      gst_adapter_unmap (flxdec->adapter);\n\n      switch (flxfh.id) {\n        case FLX_FRAME_TYPE:\n          \/* check if we have the complete frame *\/\n          if (avail < flxfh.size)\n            goto need_more_data;\n\n          \/* flush header *\/\n          gst_adapter_flush (flxdec->adapter, FlxFrameChunkSize);\n\n          chunk = gst_adapter_take (flxdec->adapter,\n              flxfh.size - FlxFrameChunkSize);\n          FLX_FRAME_TYPE_FIX_ENDIANNESS ((FlxFrameType *) chunk);\n          if (((FlxFrameType *) chunk)->chunks == 0)\n            break;\n\n          \/* create 32 bits output frame *\/\n\/\/          res = gst_pad_alloc_buffer_and_set_caps (flxdec->srcpad,\n\/\/              GST_BUFFER_OFFSET_NONE,\n\/\/              flxdec->size * 4, GST_PAD_CAPS (flxdec->srcpad), &out);\n\/\/          if (res != GST_FLOW_OK)\n\/\/            break;\n\n          out = gst_buffer_new_and_alloc (flxdec->size * 4);\n\n          \/* decode chunks *\/\n          if (!flx_decode_chunks (flxdec,\n                  ((FlxFrameType *) chunk)->chunks,\n                  chunk + FlxFrameTypeSize, flxdec->frame_data)) {\n            GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,\n                (\"%s\", \"Could not decode chunk\"), NULL);\n            return GST_FLOW_ERROR;\n          }\n\n          \/* save copy of the current frame for possible delta. *\/\n          memcpy (flxdec->delta_data, flxdec->frame_data, flxdec->size);\n\n          gst_buffer_map (out, &map, GST_MAP_WRITE);\n          \/* convert current frame. *\/\n          flx_colorspace_convert (flxdec->converter, flxdec->frame_data,\n              map.data);\n          gst_buffer_unmap (out, &map);\n\n          GST_BUFFER_TIMESTAMP (out) = flxdec->next_time;\n          flxdec->next_time += flxdec->frame_time;\n\n          res = gst_pad_push (flxdec->srcpad, out);\n          break;\n        default:\n          \/* check if we have the complete frame *\/\n          if (avail < flxfh.size)\n            goto need_more_data;\n\n          gst_adapter_flush (flxdec->adapter, flxfh.size);\n          break;\n      }\n\n      g_free (chunk);\n\n      avail = gst_adapter_available (flxdec->adapter);\n    }\n  }\nneed_more_data:\n  return res;\n\n  \/* ERRORS *\/\nwrong_type:\n  {\n    GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL),\n        (\"not a flx file (type %x)\", flxh->type));\n    gst_object_unref (flxdec);\n    return GST_FLOW_ERROR;\n  }\n}","target":1,"code_token_length":1681,"total_token_length":1917,"max_tokens_setting":2048}
+{"idx":432155,"func":"PipelineD::buildInnerQueryExecutorGeneric(const CollectionPtr& collection,\n                                          const NamespaceString& nss,\n                                          const AggregateCommandRequest* aggRequest,\n                                          Pipeline* pipeline) {\n    \/\/ Make a last effort to optimize pipeline stages before potentially detaching them to be pushed\n    \/\/ down into the query executor.\n    pipeline->optimizePipeline();\n\n    Pipeline::SourceContainer& sources = pipeline->_sources;\n    auto expCtx = pipeline->getContext();\n\n    \/\/ Look for an initial match. This works whether we got an initial query or not. If not, it\n    \/\/ results in a \"{}\" query, which will be what we want in that case.\n    const BSONObj queryObj = pipeline->getInitialQuery();\n    if (!queryObj.isEmpty()) {\n        auto matchStage = dynamic_cast<DocumentSourceMatch*>(sources.front().get());\n        if (matchStage) {\n            \/\/ If a $match query is pulled into the cursor, the $match is redundant, and can be\n            \/\/ removed from the pipeline.\n            sources.pop_front();\n        } else {\n            \/\/ A $geoNear stage, the only other stage that can produce an initial query, is also\n            \/\/ a valid initial stage. However, we should be in prepareGeoNearCursorSource() instead.\n            MONGO_UNREACHABLE;\n        }\n    }\n\n    auto&& [sortStage, groupStage] = getSortAndGroupStagesFromPipeline(pipeline->_sources);\n    std::unique_ptr<GroupFromFirstDocumentTransformation> rewrittenGroupStage;\n    if (groupStage) {\n        rewrittenGroupStage = groupStage->rewriteGroupAsTransformOnFirstDocument();\n    }\n\n    \/\/ If there is a $limit or $skip stage (or multiple of them) that could be pushed down into the\n    \/\/ PlanStage layer, obtain the value of the limit and skip and remove the $limit and $skip\n    \/\/ stages from the pipeline.\n    \/\/\n    \/\/ This analysis is done here rather than in 'optimizePipeline()' because swapping $limit before\n    \/\/ stages such as $project is not always useful, and can sometimes defeat other optimizations.\n    \/\/ In particular, in a sharded scenario a pipeline such as [$project, $limit] is preferable to\n    \/\/ [$limit, $project]. The former permits the execution of the projection operation to be\n    \/\/ parallelized across all targeted shards, whereas the latter would bring all of the data to a\n    \/\/ merging shard first, and then apply the projection serially. See SERVER-24981 for a more\n    \/\/ detailed discussion.\n    \/\/\n    \/\/ This only handles the case in which the the $limit or $skip can logically be swapped to the\n    \/\/ front of the pipeline. We can also push down a $limit which comes after a $sort into the\n    \/\/ PlanStage layer, but that is handled elsewhere.\n    const auto skipThenLimit = extractSkipAndLimitForPushdown(pipeline);\n\n    auto unavailableMetadata = DocumentSourceMatch::isTextQuery(queryObj)\n        ? DepsTracker::kDefaultUnavailableMetadata & ~DepsTracker::kOnlyTextScore\n        : DepsTracker::kDefaultUnavailableMetadata;\n\n    \/\/ Create the PlanExecutor.\n    bool shouldProduceEmptyDocs = false;\n    auto exec = uassertStatusOK(prepareExecutor(expCtx,\n                                                collection,\n                                                nss,\n                                                pipeline,\n                                                sortStage,\n                                                std::move(rewrittenGroupStage),\n                                                unavailableMetadata,\n                                                queryObj,\n                                                skipThenLimit,\n                                                aggRequest,\n                                                Pipeline::kAllowedMatcherFeatures,\n                                                &shouldProduceEmptyDocs));\n\n    const auto cursorType = shouldProduceEmptyDocs\n        ? DocumentSourceCursor::CursorType::kEmptyDocuments\n        : DocumentSourceCursor::CursorType::kRegular;\n\n    \/\/ If this is a change stream pipeline or a resharding resume token has been requested, make\n    \/\/ sure that we tell DSCursor to track the oplog time.\n    const bool trackOplogTS =\n        (pipeline->peekFront() && pipeline->peekFront()->constraints().isChangeStreamStage()) ||\n        (aggRequest && aggRequest->getRequestReshardingResumeToken());\n\n    auto attachExecutorCallback =\n        [cursorType, trackOplogTS](const CollectionPtr& collection,\n                                   std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> exec,\n                                   Pipeline* pipeline) {\n            auto cursor = DocumentSourceCursor::create(\n                collection, std::move(exec), pipeline->getContext(), cursorType, trackOplogTS);\n            pipeline->addInitialSource(std::move(cursor));\n        };\n    return std::make_pair(std::move(attachExecutorCallback), std::move(exec));\n}","target":0,"code_token_length":970,"total_token_length":1206,"max_tokens_setting":2048}
+{"idx":210283,"func":"vhost_user_set_inflight_fd(struct virtio_net **pdev,\n\t\t\t   struct vhu_msg_context *ctx,\n\t\t\t   int main_fd __rte_unused)\n{\n\tuint64_t mmap_size, mmap_offset;\n\tuint16_t num_queues, queue_size;\n\tstruct virtio_net *dev = *pdev;\n\tuint32_t pervq_inflight_size;\n\tstruct vhost_virtqueue *vq;\n\tvoid *addr;\n\tint fd, i;\n\tint numa_node = SOCKET_ID_ANY;\n\n\tfd = ctx->fds[0];\n\tif (ctx->msg.size != sizeof(ctx->msg.payload.inflight) || fd < 0) {\n\t\tVHOST_LOG_CONFIG(ERR, \"(%s) invalid set_inflight_fd message size is %d,fd is %d\\n\",\n\t\t\tdev->ifname, ctx->msg.size, fd);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tmmap_size = ctx->msg.payload.inflight.mmap_size;\n\tmmap_offset = ctx->msg.payload.inflight.mmap_offset;\n\tnum_queues = ctx->msg.payload.inflight.num_queues;\n\tqueue_size = ctx->msg.payload.inflight.queue_size;\n\n\tif (vq_is_packed(dev))\n\t\tpervq_inflight_size = get_pervq_shm_size_packed(queue_size);\n\telse\n\t\tpervq_inflight_size = get_pervq_shm_size_split(queue_size);\n\n\tVHOST_LOG_CONFIG(INFO, \"(%s) set_inflight_fd mmap_size: %\"PRIu64\"\\n\",\n\t\t\tdev->ifname, mmap_size);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) set_inflight_fd mmap_offset: %\"PRIu64\"\\n\",\n\t\t\tdev->ifname, mmap_offset);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) set_inflight_fd num_queues: %u\\n\", dev->ifname, num_queues);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) set_inflight_fd queue_size: %u\\n\", dev->ifname, queue_size);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) set_inflight_fd fd: %d\\n\", dev->ifname, fd);\n\tVHOST_LOG_CONFIG(INFO, \"(%s) set_inflight_fd pervq_inflight_size: %d\\n\",\n\t\t\tdev->ifname, pervq_inflight_size);\n\n\t\/*\n\t * If VQ 0 has already been allocated, try to allocate on the same\n\t * NUMA node. It can be reallocated later in numa_realloc().\n\t *\/\n\tif (dev->nr_vring > 0)\n\t\tnuma_node = dev->virtqueue[0]->numa_node;\n\n\tif (!dev->inflight_info) {\n\t\tdev->inflight_info = rte_zmalloc_socket(\"inflight_info\",\n\t\t\t\tsizeof(struct inflight_mem_info), 0, numa_node);\n\t\tif (dev->inflight_info == NULL) {\n\t\t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to alloc dev inflight area\\n\",\n\t\t\t\t\tdev->ifname);\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\t\tdev->inflight_info->fd = -1;\n\t}\n\n\tif (dev->inflight_info->addr) {\n\t\tmunmap(dev->inflight_info->addr, dev->inflight_info->size);\n\t\tdev->inflight_info->addr = NULL;\n\t}\n\n\taddr = mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,\n\t\t    fd, mmap_offset);\n\tif (addr == MAP_FAILED) {\n\t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to mmap share memory.\\n\", dev->ifname);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tif (dev->inflight_info->fd >= 0) {\n\t\tclose(dev->inflight_info->fd);\n\t\tdev->inflight_info->fd = -1;\n\t}\n\n\tdev->inflight_info->fd = fd;\n\tdev->inflight_info->addr = addr;\n\tdev->inflight_info->size = mmap_size;\n\n\tfor (i = 0; i < num_queues; i++) {\n\t\tvq = dev->virtqueue[i];\n\t\tif (!vq)\n\t\t\tcontinue;\n\n\t\tif (vq_is_packed(dev)) {\n\t\t\tvq->inflight_packed = addr;\n\t\t\tvq->inflight_packed->desc_num = queue_size;\n\t\t} else {\n\t\t\tvq->inflight_split = addr;\n\t\t\tvq->inflight_split->desc_num = queue_size;\n\t\t}\n\t\taddr = (void *)((char *)addr + pervq_inflight_size);\n\t}\n\n\treturn RTE_VHOST_MSG_RESULT_OK;\n}","target":1,"code_token_length":953,"total_token_length":1189,"max_tokens_setting":2048}
+{"idx":261738,"func":"const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {\n    auto ptr = data;\n    while (len) {\n        size_t offset = 0;\n        auto header = (RtmpHeader *) ptr;\n        auto header_len = HEADER_LENGTH[header->fmt];\n        _now_chunk_id = header->chunk_id;\n        switch (_now_chunk_id) {\n            case 0: {\n                \/\/0 \u503c\u8868\u793a\u4e8c\u5b57\u8282\u5f62\u5f0f\uff0c\u5e76\u4e14 ID \u8303\u56f4 64 - 319\n                \/\/(\u7b2c\u4e8c\u4e2a\u5b57\u8282 + 64)\u3002\n                if (len < 2) {\n                    \/\/need more data\n                    return ptr;\n                }\n                _now_chunk_id = 64 + (uint8_t) (ptr[1]);\n                offset = 1;\n                break;\n            }\n\n            case 1: {\n                \/\/1 \u503c\u8868\u793a\u4e09\u5b57\u8282\u5f62\u5f0f\uff0c\u5e76\u4e14 ID \u8303\u56f4\u4e3a 64 - 65599\n                \/\/((\u7b2c\u4e09\u4e2a\u5b57\u8282) * 256 + \u7b2c\u4e8c\u4e2a\u5b57\u8282 + 64)\u3002\n                if (len < 3) {\n                    \/\/need more data\n                    return ptr;\n                }\n                _now_chunk_id = 64 + ((uint8_t) (ptr[2]) << 8) + (uint8_t) (ptr[1]);\n                offset = 2;\n                break;\n            }\n\n            \/\/\u5e26\u6709 2 \u503c\u7684\u5757\u6d41 ID \u88ab\u4fdd\u7559\uff0c\u7528\u4e8e\u4e0b\u5c42\u534f\u8bae\u63a7\u5236\u6d88\u606f\u548c\u547d\u4ee4\u3002\n            default : break;\n        }\n\n        if (len < header_len + offset) {\n            \/\/need more data\n            return ptr;\n        }\n        header = (RtmpHeader *) (ptr + offset);\n        auto &pr = _map_chunk_data[_now_chunk_id];\n        auto &now_packet = pr.first;\n        auto &last_packet = pr.second;\n        if (!now_packet) {\n            now_packet = RtmpPacket::create();\n            if (last_packet) {\n                \/\/\u6062\u590dchunk\u4e0a\u4e0b\u6587\n                *now_packet = *last_packet;\n            }\n            \/\/\u7edd\u5bf9\u65f6\u95f4\u6233\u6807\u8bb0\u590d\u4f4d\n            now_packet->is_abs_stamp = false;\n        }\n        auto &chunk_data = *now_packet;\n        chunk_data.chunk_id = _now_chunk_id;\n        switch (header_len) {\n            case 12:\n                chunk_data.is_abs_stamp = true;\n                chunk_data.stream_index = load_le32(header->stream_index);\n            case 8:\n                chunk_data.body_size = load_be24(header->body_size);\n                chunk_data.type_id = header->type_id;\n            case 4:\n                chunk_data.ts_field = load_be24(header->time_stamp);\n        }\n\n        auto time_stamp = chunk_data.ts_field;\n        if (chunk_data.ts_field == 0xFFFFFF) {\n            if (len < header_len + offset + 4) {\n                \/\/need more data\n                return ptr;\n            }\n            time_stamp = load_be32(ptr + offset + header_len);\n            offset += 4;\n        }\n\n        if (chunk_data.body_size < chunk_data.buffer.size()) {\n            throw std::runtime_error(\"\u975e\u6cd5\u7684bodySize\");\n        }\n\n        auto more = min(_chunk_size_in, (size_t) (chunk_data.body_size - chunk_data.buffer.size()));\n        if (len < header_len + offset + more) {\n            \/\/need more data\n            return ptr;\n        }\n        if (more) {\n            chunk_data.buffer.append(ptr + header_len + offset, more);\n        }\n        ptr += header_len + offset + more;\n        len -= header_len + offset + more;\n        if (chunk_data.buffer.size() == chunk_data.body_size) {\n            \/\/frame is ready\n            _now_stream_index = chunk_data.stream_index;\n            chunk_data.time_stamp = time_stamp + (chunk_data.is_abs_stamp ? 0 : chunk_data.time_stamp);\n            \/\/\u4fdd\u5b58chunk\u4e0a\u4e0b\u6587\n            last_packet = now_packet;\n            if (chunk_data.body_size) {\n                handle_chunk(std::move(now_packet));\n            } else {\n                now_packet = nullptr;\n            }\n        }\n    }\n    return ptr;\n}","target":0,"code_token_length":880,"total_token_length":1116,"max_tokens_setting":2048}
+{"idx":256952,"func":"  static Status ProcessDimensions(\n      const OpInputList& inputs,\n      const gtl::InlinedVector<bool, 2>& input_has_ellipsis,\n      const bool output_has_ellipsis, OperandLabels* input_labels,\n      Labels* output_labels, std::vector<DimensionType>* label_types,\n      OperandLabelCounts* input_label_counts, LabelCounts* output_label_counts,\n      LabelToDimSizes* label_to_dim_sizes) {\n    if (inputs.size() != input_labels->size()) {\n      return errors::InvalidArgument(\"Expected \", input_labels->size(),\n                                     \" inputs but got: \", inputs.size());\n    }\n    const int num_inputs = inputs.size();\n\n    \/\/ We infer the number of broadcasting dimensions by taking the maximum rank\n    \/\/ among the broadcasting subshapes of the input.\n    int max_bcast_dims = 0;\n    const int num_named_labels = label_types->size();\n    label_to_dim_sizes->resize(num_named_labels);\n    for (int i = 0; i < num_inputs; ++i) {\n      Labels* labels = &(*input_labels)[i];\n\n      if (!input_has_ellipsis[i]) {\n        if (inputs[i].dims() != labels->size()) {\n          return errors::InvalidArgument(\"Expected input \", i, \" to have rank \",\n                                         labels->size(),\n                                         \" but got: \", inputs[i].dims());\n        }\n        for (int label_idx = 0; label_idx < labels->size(); ++label_idx) {\n          const int label = (*labels)[label_idx];\n          TF_RETURN_IF_ERROR(RecordLabelToDimension(label, label_idx, inputs[i],\n                                                    label_to_dim_sizes));\n        }\n        continue;\n      }\n\n      \/\/ Input has an ellipsis.\n      if (inputs[i].dims() + 1 < labels->size()) {\n        return errors::InvalidArgument(\n            \"Expected input \", i, \" to have rank at least \", labels->size() - 1,\n            \" but got: \", inputs[i].dims());\n      }\n      int ellipsis_axis = -1;\n      const int num_bcast_dims = inputs[i].dims() - labels->size() + 1;\n      for (int label_idx = 0; label_idx < labels->size(); ++label_idx) {\n        const int label = (*labels)[label_idx];\n        if (label == kEllipsisLabel) {\n          ellipsis_axis = label_idx;\n          continue;\n        }\n        \/\/ Current label is not an ellipsis.\n        const int axis =\n            label_idx + (ellipsis_axis == -1 ? 0 : num_bcast_dims - 1);\n        TF_RETURN_IF_ERROR(\n            RecordLabelToDimension(label, axis, inputs[i], label_to_dim_sizes));\n      }\n      \/\/ Found an ellipsis. Replace 'kEllipsisLabel' with broadcasting\n      \/\/ dimensions.\n      if (ellipsis_axis != -1) {\n        InsertBroadcastLabels(num_bcast_dims, num_named_labels, ellipsis_axis,\n                              labels, &input_label_counts->at(i));\n        max_bcast_dims = std::max(max_bcast_dims, num_bcast_dims);\n      }\n    }\n    if (!absl::c_linear_search(input_has_ellipsis, true) &&\n        !output_has_ellipsis) {\n      return Status::OK();\n    }\n    \/\/ Insert broadcasting dimensions in the output labels.\n    auto it =\n        std::find(output_labels->begin(), output_labels->end(), kEllipsisLabel);\n    if (it != output_labels->end()) {\n      const int ellipsis_axis = it - output_labels->begin();\n      InsertBroadcastLabels(max_bcast_dims, num_named_labels, ellipsis_axis,\n                            output_labels, output_label_counts);\n    } else if (max_bcast_dims > 0) {\n      return errors::InvalidArgument(\n          \"Output contains \", max_bcast_dims,\n          \" broadcasting dimension(s) but no ellipsis \"\n          \"(...) was found in the output subscripts.\");\n    }\n    \/\/ Populate DimensionType for the new broadcasting labels.\n    label_types->resize(num_named_labels + max_bcast_dims, kBroadcasting);\n    return Status::OK();\n  }","target":0,"code_token_length":857,"total_token_length":1093,"max_tokens_setting":2048}
+{"idx":230135,"func":"static json_t * generate_new_credential(struct config_module * config, json_t * j_params, const char * username) {\n  json_t * j_query, * j_return;\n  char * username_escaped, * mod_name_escaped, * username_clause, * challenge_hash;\n  int res;\n  size_t challenge_b64_len, challenge_len = (size_t)json_integer_value(json_object_get(j_params, \"challenge-length\"));\n  unsigned char challenge_b64[challenge_len*2], challenge[challenge_len+1];\n  char session[SESSION_LENGTH+1] = {0}, * session_hash;\n\n  gnutls_rnd(GNUTLS_RND_NONCE, challenge, challenge_len);\n  if (o_base64_encode(challenge, challenge_len, challenge_b64, &challenge_b64_len)) {\n    challenge_b64[challenge_b64_len] = '\\0';\n    if ((challenge_hash = generate_hash(config->hash_algorithm, (const char *)challenge_b64)) != NULL) {\n      rand_string(session, SESSION_LENGTH);\n      if ((session_hash = generate_hash(config->hash_algorithm, session)) != NULL) {\n        username_escaped = h_escape_string_with_quotes(config->conn, username);\n        mod_name_escaped = h_escape_string_with_quotes(config->conn, json_string_value(json_object_get(j_params, \"mod_name\")));\n        username_clause = msprintf(\" (SELECT gswu_id FROM \"G_TABLE_WEBAUTHN_USER\" WHERE UPPER(gswu_username) = UPPER(%s) AND gswu_mod_name = %s)\", username_escaped, mod_name_escaped);\n        \/\/ Disable all credential with status 0 (new) of the same user\n        j_query = json_pack(\"{sss{si}s{s{ssss+}si}}\",\n                            \"table\",\n                            G_TABLE_WEBAUTHN_CREDENTIAL,\n                            \"set\",\n                              \"gswc_status\",\n                              2,\n                            \"where\",\n                              \"gswu_id\",\n                                \"operator\",\n                                \"raw\",\n                                \"value\",\n                                \" =\",\n                                username_clause,\n                              \"gswc_status\",\n                              0);\n        res = h_update(config->conn, j_query, NULL);\n        json_decref(j_query);\n        if (res == H_OK) {\n          \/\/ Insert new credential\n          j_query = json_pack(\"{sss{s{ss}sssssi}}\",\n                              \"table\",\n                              G_TABLE_WEBAUTHN_CREDENTIAL,\n                              \"values\",\n                                \"gswu_id\",\n                                  \"raw\",\n                                  username_clause,\n                                \"gswc_session_hash\",\n                                session_hash,\n                                \"gswc_challenge_hash\",\n                                challenge_hash,\n                                \"gswc_status\",\n                                0);\n          res = h_insert(config->conn, j_query, NULL);\n          json_decref(j_query);\n          if (res == H_OK) {\n            j_return = json_pack(\"{sis{ssss}}\", \"result\", G_OK, \"credential\", \"session\", session, \"challenge\", challenge_b64);\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"generate_new_credential - Error executing j_query insert\");\n            config->glewlwyd_module_callback_metrics_increment_counter(config, GLWD_METRICS_DATABSE_ERROR, 1, NULL);\n            j_return = json_pack(\"{si}\", \"result\", G_ERROR_DB);\n          }\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"generate_new_credential - Error executing j_query update\");\n          config->glewlwyd_module_callback_metrics_increment_counter(config, GLWD_METRICS_DATABSE_ERROR, 1, NULL);\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR_DB);\n        }\n        o_free(username_clause);\n        o_free(username_escaped);\n        o_free(mod_name_escaped);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"generate_new_credential - Error generate_hash session\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n      o_free(session_hash);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"generate_new_credential - Error generate_hash challenge\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    o_free(challenge_hash);\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"generate_new_credential - Error o_base64_encode challenge\");\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n  }\n  return j_return;\n}","target":0,"code_token_length":946,"total_token_length":1182,"max_tokens_setting":2048}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..643f67b2bb870b549f11ebf7c82791890bebf1c0
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3b59ab95ad981147d35534e9bd80489407fe7e49c19822d9589c928e7022be0d
+size 3079302
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..e074bd8292d0efcb635fdc7d79e05e27a3ca359a
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.jsonl
@@ -0,0 +1,20 @@
+{"idx":395078,"func":"win_update(win_T *wp)\n{\n    buf_T\t*buf = wp->w_buffer;\n    int\t\ttype;\n    int\t\ttop_end = 0;\t\/\/ Below last row of the top area that needs\n\t\t\t\t\/\/ updating.  0 when no top area updating.\n    int\t\tmid_start = 999;\/\/ first row of the mid area that needs\n\t\t\t\t\/\/ updating.  999 when no mid area updating.\n    int\t\tmid_end = 0;\t\/\/ Below last row of the mid area that needs\n\t\t\t\t\/\/ updating.  0 when no mid area updating.\n    int\t\tbot_start = 999;\/\/ first row of the bot area that needs\n\t\t\t\t\/\/ updating.  999 when no bot area updating\n    int\t\tscrolled_down = FALSE;\t\/\/ TRUE when scrolled down when\n\t\t\t\t\t\/\/ w_topline got smaller a bit\n#ifdef FEAT_SEARCH_EXTRA\n    int\t\ttop_to_mod = FALSE;    \/\/ redraw above mod_top\n#endif\n\n    int\t\trow;\t\t\/\/ current window row to display\n    linenr_T\tlnum;\t\t\/\/ current buffer lnum to display\n    int\t\tidx;\t\t\/\/ current index in w_lines[]\n    int\t\tsrow;\t\t\/\/ starting row of the current line\n\n    int\t\teof = FALSE;\t\/\/ if TRUE, we hit the end of the file\n    int\t\tdidline = FALSE; \/\/ if TRUE, we finished the last line\n    int\t\ti;\n    long\tj;\n    static int\trecursive = FALSE;\t\/\/ being called recursively\n    linenr_T\told_botline = wp->w_botline;\n#ifdef FEAT_CONCEAL\n    int\t\told_wrow = wp->w_wrow;\n    int\t\told_wcol = wp->w_wcol;\n#endif\n#ifdef FEAT_FOLDING\n    long\tfold_count;\n#endif\n#ifdef FEAT_SYN_HL\n    \/\/ remember what happened to the previous line, to know if\n    \/\/ check_visual_highlight() can be used\n#define DID_NONE 1\t\/\/ didn't update a line\n#define DID_LINE 2\t\/\/ updated a normal line\n#define DID_FOLD 3\t\/\/ updated a folded line\n    int\t\tdid_update = DID_NONE;\n    linenr_T\tsyntax_last_parsed = 0;\t\t\/\/ last parsed text line\n#endif\n    linenr_T\tmod_top = 0;\n    linenr_T\tmod_bot = 0;\n#if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)\n    int\t\tsave_got_int;\n#endif\n#ifdef SYN_TIME_LIMIT\n    proftime_T\tsyntax_tm;\n#endif\n\n#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)\n    \/\/ This needs to be done only for the first window when update_screen() is\n    \/\/ called.\n    if (!did_update_one_window)\n    {\n\tdid_update_one_window = TRUE;\n# ifdef FEAT_SEARCH_EXTRA\n\tstart_search_hl();\n# endif\n# ifdef FEAT_CLIPBOARD\n\t\/\/ When Visual area changed, may have to update selection.\n\tif (clip_star.available && clip_isautosel_star())\n\t    clip_update_selection(&clip_star);\n\tif (clip_plus.available && clip_isautosel_plus())\n\t    clip_update_selection(&clip_plus);\n# endif\n    }\n#endif\n\n    type = wp->w_redr_type;\n\n    if (type == NOT_VALID)\n    {\n\twp->w_redr_status = TRUE;\n\twp->w_lines_valid = 0;\n    }\n\n    \/\/ Window frame is zero-height: nothing to draw.\n    if (wp->w_height + WINBAR_HEIGHT(wp) == 0\n\t    || (wp->w_frame->fr_height == wp->w_status_height\n#if defined(FEAT_PROP_POPUP)\n\t\t&& !popup_is_popup(wp)\n#endif\n\t       ))\n    {\n\twp->w_redr_type = 0;\n\treturn;\n    }\n\n    \/\/ Window is zero-width: Only need to draw the separator.\n    if (wp->w_width == 0)\n    {\n\t\/\/ draw the vertical separator right of this window\n\tdraw_vsep_win(wp, 0);\n\twp->w_redr_type = 0;\n\treturn;\n    }\n\n#ifdef FEAT_TERMINAL\n    \/\/ If this window contains a terminal, redraw works completely differently.\n    if (term_do_update_window(wp))\n    {\n\tterm_update_window(wp);\n# ifdef FEAT_MENU\n\t\/\/ Draw the window toolbar, if there is one.\n\tif (winbar_height(wp) > 0)\n\t    redraw_win_toolbar(wp);\n# endif\n\twp->w_redr_type = 0;\n\treturn;\n    }\n#endif\n\n#ifdef FEAT_SEARCH_EXTRA\n    init_search_hl(wp, &screen_search_hl);\n#endif\n\n#ifdef FEAT_LINEBREAK\n    \/\/ Force redraw when width of 'number' or 'relativenumber' column\n    \/\/ changes.\n    i = (wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) : 0;\n    if (wp->w_nrwidth != i)\n    {\n\ttype = NOT_VALID;\n\twp->w_nrwidth = i;\n    }\n    else\n#endif\n\n    if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0)\n    {\n\t\/\/ When there are both inserted\/deleted lines and specific lines to be\n\t\/\/ redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw\n\t\/\/ everything (only happens when redrawing is off for while).\n\ttype = NOT_VALID;\n    }\n    else\n    {\n\t\/\/ Set mod_top to the first line that needs displaying because of\n\t\/\/ changes.  Set mod_bot to the first line after the changes.\n\tmod_top = wp->w_redraw_top;\n\tif (wp->w_redraw_bot != 0)\n\t    mod_bot = wp->w_redraw_bot + 1;\n\telse\n\t    mod_bot = 0;\n\tif (buf->b_mod_set)\n\t{\n\t    if (mod_top == 0 || mod_top > buf->b_mod_top)\n\t    {\n\t\tmod_top = buf->b_mod_top;\n#ifdef FEAT_SYN_HL\n\t\t\/\/ Need to redraw lines above the change that may be included\n\t\t\/\/ in a pattern match.\n\t\tif (syntax_present(wp))\n\t\t{\n\t\t    mod_top -= buf->b_s.b_syn_sync_linebreaks;\n\t\t    if (mod_top < 1)\n\t\t\tmod_top = 1;\n\t\t}\n#endif\n\t    }\n\t    if (mod_bot == 0 || mod_bot < buf->b_mod_bot)\n\t\tmod_bot = buf->b_mod_bot;\n\n#ifdef FEAT_SEARCH_EXTRA\n\t    \/\/ When 'hlsearch' is on and using a multi-line search pattern, a\n\t    \/\/ change in one line may make the Search highlighting in a\n\t    \/\/ previous line invalid.  Simple solution: redraw all visible\n\t    \/\/ lines above the change.\n\t    \/\/ Same for a match pattern.\n\t    if (screen_search_hl.rm.regprog != NULL\n\t\t    && re_multiline(screen_search_hl.rm.regprog))\n\t\ttop_to_mod = TRUE;\n\t    else\n\t    {\n\t\tmatchitem_T *cur = wp->w_match_head;\n\n\t\twhile (cur != NULL)\n\t\t{\n\t\t    if (cur->match.regprog != NULL\n\t\t\t\t\t   && re_multiline(cur->match.regprog))\n\t\t    {\n\t\t\ttop_to_mod = TRUE;\n\t\t\tbreak;\n\t\t    }\n\t\t    cur = cur->next;\n\t\t}\n\t    }\n#endif\n\t}\n#ifdef FEAT_FOLDING\n\tif (mod_top != 0 && hasAnyFolding(wp))\n\t{\n\t    linenr_T\tlnumt, lnumb;\n\n\t    \/\/ A change in a line can cause lines above it to become folded or\n\t    \/\/ unfolded.  Find the top most buffer line that may be affected.\n\t    \/\/ If the line was previously folded and displayed, get the first\n\t    \/\/ line of that fold.  If the line is folded now, get the first\n\t    \/\/ folded line.  Use the minimum of these two.\n\n\t    \/\/ Find last valid w_lines[] entry above mod_top.  Set lnumt to\n\t    \/\/ the line below it.  If there is no valid entry, use w_topline.\n\t    \/\/ Find the first valid w_lines[] entry below mod_bot.  Set lnumb\n\t    \/\/ to this line.  If there is no valid entry, use MAXLNUM.\n\t    lnumt = wp->w_topline;\n\t    lnumb = MAXLNUM;\n\t    for (i = 0; i < wp->w_lines_valid; ++i)\n\t\tif (wp->w_lines[i].wl_valid)\n\t\t{\n\t\t    if (wp->w_lines[i].wl_lastlnum < mod_top)\n\t\t\tlnumt = wp->w_lines[i].wl_lastlnum + 1;\n\t\t    if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot)\n\t\t    {\n\t\t\tlnumb = wp->w_lines[i].wl_lnum;\n\t\t\t\/\/ When there is a fold column it might need updating\n\t\t\t\/\/ in the next line (\"J\" just above an open fold).\n\t\t\tif (compute_foldcolumn(wp, 0) > 0)\n\t\t\t    ++lnumb;\n\t\t    }\n\t\t}\n\n\t    (void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL);\n\t    if (mod_top > lnumt)\n\t\tmod_top = lnumt;\n\n\t    \/\/ Now do the same for the bottom line (one above mod_bot).\n\t    --mod_bot;\n\t    (void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL);\n\t    ++mod_bot;\n\t    if (mod_bot < lnumb)\n\t\tmod_bot = lnumb;\n\t}\n#endif\n\n\t\/\/ When a change starts above w_topline and the end is below\n\t\/\/ w_topline, start redrawing at w_topline.\n\t\/\/ If the end of the change is above w_topline: do like no change was\n\t\/\/ made, but redraw the first line to find changes in syntax.\n\tif (mod_top != 0 && mod_top < wp->w_topline)\n\t{\n\t    if (mod_bot > wp->w_topline)\n\t\tmod_top = wp->w_topline;\n#ifdef FEAT_SYN_HL\n\t    else if (syntax_present(wp))\n\t\ttop_end = 1;\n#endif\n\t}\n\n\t\/\/ When line numbers are displayed need to redraw all lines below\n\t\/\/ inserted\/deleted lines.\n\tif (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu)\n\t    mod_bot = MAXLNUM;\n    }\n    wp->w_redraw_top = 0;\t\/\/ reset for next time\n    wp->w_redraw_bot = 0;\n\n    \/\/ When only displaying the lines at the top, set top_end.  Used when\n    \/\/ window has scrolled down for msg_scrolled.\n    if (type == REDRAW_TOP)\n    {\n\tj = 0;\n\tfor (i = 0; i < wp->w_lines_valid; ++i)\n\t{\n\t    j += wp->w_lines[i].wl_size;\n\t    if (j >= wp->w_upd_rows)\n\t    {\n\t\ttop_end = j;\n\t\tbreak;\n\t    }\n\t}\n\tif (top_end == 0)\n\t    \/\/ not found (cannot happen?): redraw everything\n\t    type = NOT_VALID;\n\telse\n\t    \/\/ top area defined, the rest is VALID\n\t    type = VALID;\n    }\n\n    \/\/ Trick: we want to avoid clearing the screen twice.  screenclear() will\n    \/\/ set \"screen_cleared\" to TRUE.  The special value MAYBE (which is still\n    \/\/ non-zero and thus not FALSE) will indicate that screenclear() was not\n    \/\/ called.\n    if (screen_cleared)\n\tscreen_cleared = MAYBE;\n\n    \/\/ If there are no changes on the screen that require a complete redraw,\n    \/\/ handle three cases:\n    \/\/ 1: we are off the top of the screen by a few lines: scroll down\n    \/\/ 2: wp->w_topline is below wp->w_lines[0].wl_lnum: may scroll up\n    \/\/ 3: wp->w_topline is wp->w_lines[0].wl_lnum: find first entry in\n    \/\/    w_lines[] that needs updating.\n    if ((type == VALID || type == SOME_VALID\n\t\t\t\t  || type == INVERTED || type == INVERTED_ALL)\n#ifdef FEAT_DIFF\n\t    && !wp->w_botfill && !wp->w_old_botfill\n#endif\n\t    )\n    {\n\tif (mod_top != 0\n\t\t&& wp->w_topline == mod_top\n\t\t&& (!wp->w_lines[0].wl_valid\n\t\t    || wp->w_topline <= wp->w_lines[0].wl_lnum))\n\t{\n\t    \/\/ w_topline is the first changed line and window is not scrolled,\n\t    \/\/ the scrolling from changed lines will be done further down.\n\t}\n\telse if (wp->w_lines[0].wl_valid\n\t\t&& (wp->w_topline < wp->w_lines[0].wl_lnum\n#ifdef FEAT_DIFF\n\t\t    || (wp->w_topline == wp->w_lines[0].wl_lnum\n\t\t\t&& wp->w_topfill > wp->w_old_topfill)\n#endif\n\t\t   ))\n\t{\n\t    \/\/ New topline is above old topline: May scroll down.\n#ifdef FEAT_FOLDING\n\t    if (hasAnyFolding(wp))\n\t    {\n\t\tlinenr_T ln;\n\n\t\t\/\/ count the number of lines we are off, counting a sequence\n\t\t\/\/ of folded lines as one\n\t\tj = 0;\n\t\tfor (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ++ln)\n\t\t{\n\t\t    ++j;\n\t\t    if (j >= wp->w_height - 2)\n\t\t\tbreak;\n\t\t    (void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL);\n\t\t}\n\t    }\n\t    else\n#endif\n\t\tj = wp->w_lines[0].wl_lnum - wp->w_topline;\n\t    if (j < wp->w_height - 2)\t\t\/\/ not too far off\n\t    {\n\t\ti = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1);\n#ifdef FEAT_DIFF\n\t\t\/\/ insert extra lines for previously invisible filler lines\n\t\tif (wp->w_lines[0].wl_lnum != wp->w_topline)\n\t\t    i += diff_check_fill(wp, wp->w_lines[0].wl_lnum)\n\t\t\t\t\t\t\t  - wp->w_old_topfill;\n#endif\n\t\tif (i < wp->w_height - 2)\t\/\/ less than a screen off\n\t\t{\n\t\t    \/\/ Try to insert the correct number of lines.\n\t\t    \/\/ If not the last window, delete the lines at the bottom.\n\t\t    \/\/ win_ins_lines may fail when the terminal can't do it.\n\t\t    if (i > 0)\n\t\t\tcheck_for_delay(FALSE);\n\t\t    if (win_ins_lines(wp, 0, i, FALSE, wp == firstwin) == OK)\n\t\t    {\n\t\t\tif (wp->w_lines_valid != 0)\n\t\t\t{\n\t\t\t    \/\/ Need to update rows that are new, stop at the\n\t\t\t    \/\/ first one that scrolled down.\n\t\t\t    top_end = i;\n\t\t\t    scrolled_down = TRUE;\n\n\t\t\t    \/\/ Move the entries that were scrolled, disable\n\t\t\t    \/\/ the entries for the lines to be redrawn.\n\t\t\t    if ((wp->w_lines_valid += j) > wp->w_height)\n\t\t\t\twp->w_lines_valid = wp->w_height;\n\t\t\t    for (idx = wp->w_lines_valid; idx - j >= 0; idx--)\n\t\t\t\twp->w_lines[idx] = wp->w_lines[idx - j];\n\t\t\t    while (idx >= 0)\n\t\t\t\twp->w_lines[idx--].wl_valid = FALSE;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t\tmid_start = 0;\t\t\/\/ redraw all lines\n\t\t}\n\t\telse\n\t\t    mid_start = 0;\t\t\/\/ redraw all lines\n\t    }\n\t    else\n\t\tmid_start = 0;\t\t\/\/ redraw all lines\n\t}\n\telse\n\t{\n\t    \/\/ New topline is at or below old topline: May scroll up.\n\t    \/\/ When topline didn't change, find first entry in w_lines[] that\n\t    \/\/ needs updating.\n\n\t    \/\/ try to find wp->w_topline in wp->w_lines[].wl_lnum\n\t    j = -1;\n\t    row = 0;\n\t    for (i = 0; i < wp->w_lines_valid; i++)\n\t    {\n\t\tif (wp->w_lines[i].wl_valid\n\t\t\t&& wp->w_lines[i].wl_lnum == wp->w_topline)\n\t\t{\n\t\t    j = i;\n\t\t    break;\n\t\t}\n\t\trow += wp->w_lines[i].wl_size;\n\t    }\n\t    if (j == -1)\n\t    {\n\t\t\/\/ if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all\n\t\t\/\/ lines\n\t\tmid_start = 0;\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Try to delete the correct number of lines.\n\t\t\/\/ wp->w_topline is at wp->w_lines[i].wl_lnum.\n#ifdef FEAT_DIFF\n\t\t\/\/ If the topline didn't change, delete old filler lines,\n\t\t\/\/ otherwise delete filler lines of the new topline...\n\t\tif (wp->w_lines[0].wl_lnum == wp->w_topline)\n\t\t    row += wp->w_old_topfill;\n\t\telse\n\t\t    row += diff_check_fill(wp, wp->w_topline);\n\t\t\/\/ ... but don't delete new filler lines.\n\t\trow -= wp->w_topfill;\n#endif\n\t\tif (row > 0)\n\t\t{\n\t\t    check_for_delay(FALSE);\n\t\t    if (win_del_lines(wp, 0, row, FALSE, wp == firstwin, 0)\n\t\t\t\t\t\t\t\t\t == OK)\n\t\t\tbot_start = wp->w_height - row;\n\t\t    else\n\t\t\tmid_start = 0;\t\t\/\/ redraw all lines\n\t\t}\n\t\tif ((row == 0 || bot_start < 999) && wp->w_lines_valid != 0)\n\t\t{\n\t\t    \/\/ Skip the lines (below the deleted lines) that are still\n\t\t    \/\/ valid and don't need redrawing.\tCopy their info\n\t\t    \/\/ upwards, to compensate for the deleted lines.  Set\n\t\t    \/\/ bot_start to the first row that needs redrawing.\n\t\t    bot_start = 0;\n\t\t    idx = 0;\n\t\t    for (;;)\n\t\t    {\n\t\t\twp->w_lines[idx] = wp->w_lines[j];\n\t\t\t\/\/ stop at line that didn't fit, unless it is still\n\t\t\t\/\/ valid (no lines deleted)\n\t\t\tif (row > 0 && bot_start + row\n\t\t\t\t + (int)wp->w_lines[j].wl_size > wp->w_height)\n\t\t\t{\n\t\t\t    wp->w_lines_valid = idx + 1;\n\t\t\t    break;\n\t\t\t}\n\t\t\tbot_start += wp->w_lines[idx++].wl_size;\n\n\t\t\t\/\/ stop at the last valid entry in w_lines[].wl_size\n\t\t\tif (++j >= wp->w_lines_valid)\n\t\t\t{\n\t\t\t    wp->w_lines_valid = idx;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n#ifdef FEAT_DIFF\n\t\t    \/\/ Correct the first entry for filler lines at the top\n\t\t    \/\/ when it won't get updated below.\n\t\t    if (wp->w_p_diff && bot_start > 0)\n\t\t\twp->w_lines[0].wl_size =\n\t\t\t    plines_win_nofill(wp, wp->w_topline, TRUE)\n\t\t\t\t\t\t\t      + wp->w_topfill;\n#endif\n\t\t}\n\t    }\n\t}\n\n\t\/\/ When starting redraw in the first line, redraw all lines.  When\n\t\/\/ there is only one window it's probably faster to clear the screen\n\t\/\/ first.\n\tif (mid_start == 0)\n\t{\n\t    mid_end = wp->w_height;\n\t    if (ONE_WINDOW && !WIN_IS_POPUP(wp))\n\t    {\n\t\t\/\/ Clear the screen when it was not done by win_del_lines() or\n\t\t\/\/ win_ins_lines() above, \"screen_cleared\" is FALSE or MAYBE\n\t\t\/\/ then.\n\t\tif (screen_cleared != TRUE)\n\t\t    screenclear();\n\t\t\/\/ The screen was cleared, redraw the tab pages line.\n\t\tif (redraw_tabline)\n\t\t    draw_tabline();\n\t    }\n\t}\n\n\t\/\/ When win_del_lines() or win_ins_lines() caused the screen to be\n\t\/\/ cleared (only happens for the first window) or when screenclear()\n\t\/\/ was called directly above, \"must_redraw\" will have been set to\n\t\/\/ NOT_VALID, need to reset it here to avoid redrawing twice.\n\tif (screen_cleared == TRUE)\n\t    must_redraw = 0;\n    }\n    else\n    {\n\t\/\/ Not VALID or INVERTED: redraw all lines.\n\tmid_start = 0;\n\tmid_end = wp->w_height;\n    }\n\n    if (type == SOME_VALID)\n    {\n\t\/\/ SOME_VALID: redraw all lines.\n\tmid_start = 0;\n\tmid_end = wp->w_height;\n\ttype = NOT_VALID;\n    }\n\n    \/\/ check if we are updating or removing the inverted part\n    if ((VIsual_active && buf == curwin->w_buffer)\n\t    || (wp->w_old_cursor_lnum != 0 && type != NOT_VALID))\n    {\n\tlinenr_T    from, to;\n\n\tif (VIsual_active)\n\t{\n\t    if (VIsual_active\n\t\t    && (VIsual_mode != wp->w_old_visual_mode\n\t\t\t|| type == INVERTED_ALL))\n\t    {\n\t\t\/\/ If the type of Visual selection changed, redraw the whole\n\t\t\/\/ selection.  Also when the ownership of the X selection is\n\t\t\/\/ gained or lost.\n\t\tif (curwin->w_cursor.lnum < VIsual.lnum)\n\t\t{\n\t\t    from = curwin->w_cursor.lnum;\n\t\t    to = VIsual.lnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    from = VIsual.lnum;\n\t\t    to = curwin->w_cursor.lnum;\n\t\t}\n\t\t\/\/ redraw more when the cursor moved as well\n\t\tif (wp->w_old_cursor_lnum < from)\n\t\t    from = wp->w_old_cursor_lnum;\n\t\tif (wp->w_old_cursor_lnum > to)\n\t\t    to = wp->w_old_cursor_lnum;\n\t\tif (wp->w_old_visual_lnum < from)\n\t\t    from = wp->w_old_visual_lnum;\n\t\tif (wp->w_old_visual_lnum > to)\n\t\t    to = wp->w_old_visual_lnum;\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Find the line numbers that need to be updated: The lines\n\t\t\/\/ between the old cursor position and the current cursor\n\t\t\/\/ position.  Also check if the Visual position changed.\n\t\tif (curwin->w_cursor.lnum < wp->w_old_cursor_lnum)\n\t\t{\n\t\t    from = curwin->w_cursor.lnum;\n\t\t    to = wp->w_old_cursor_lnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    from = wp->w_old_cursor_lnum;\n\t\t    to = curwin->w_cursor.lnum;\n\t\t    if (from == 0)\t\/\/ Visual mode just started\n\t\t\tfrom = to;\n\t\t}\n\n\t\tif (VIsual.lnum != wp->w_old_visual_lnum\n\t\t\t\t\t|| VIsual.col != wp->w_old_visual_col)\n\t\t{\n\t\t    if (wp->w_old_visual_lnum < from\n\t\t\t\t\t\t&& wp->w_old_visual_lnum != 0)\n\t\t\tfrom = wp->w_old_visual_lnum;\n\t\t    if (wp->w_old_visual_lnum > to)\n\t\t\tto = wp->w_old_visual_lnum;\n\t\t    if (VIsual.lnum < from)\n\t\t\tfrom = VIsual.lnum;\n\t\t    if (VIsual.lnum > to)\n\t\t\tto = VIsual.lnum;\n\t\t}\n\t    }\n\n\t    \/\/ If in block mode and changed column or curwin->w_curswant:\n\t    \/\/ update all lines.\n\t    \/\/ First compute the actual start and end column.\n\t    if (VIsual_mode == Ctrl_V)\n\t    {\n\t\tcolnr_T\t    fromc, toc;\n#if defined(FEAT_LINEBREAK)\n\t\tint\t    save_ve_flags = curwin->w_ve_flags;\n\n\t\tif (curwin->w_p_lbr)\n\t\t    curwin->w_ve_flags = VE_ALL;\n#endif\n\t\tgetvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);\n\t\t++toc;\n#if defined(FEAT_LINEBREAK)\n\t\tcurwin->w_ve_flags = save_ve_flags;\n#endif\n\t\t\/\/ Highlight to the end of the line, unless 'virtualedit' has\n\t\t\/\/ \"block\".\n\t\tif (curwin->w_curswant == MAXCOL)\n\t\t{\n\t\t    if (get_ve_flags() & VE_BLOCK)\n\t\t    {\n\t\t\tpos_T\t    pos;\n\t\t\tint\t    cursor_above =\n\t\t\t\t\t   curwin->w_cursor.lnum < VIsual.lnum;\n\n\t\t\t\/\/ Need to find the longest line.\n\t\t\ttoc = 0;\n\t\t\tpos.coladd = 0;\n\t\t\tfor (pos.lnum = curwin->w_cursor.lnum; cursor_above\n\t\t\t\t\t? pos.lnum <= VIsual.lnum\n\t\t\t\t\t: pos.lnum >= VIsual.lnum;\n\t\t\t\t\t     pos.lnum += cursor_above ? 1 : -1)\n\t\t\t{\n\t\t\t    colnr_T t;\n\n\t\t\t    pos.col = (int)STRLEN(ml_get_buf(wp->w_buffer,\n\t\t\t\t\t\t\t     pos.lnum, FALSE));\n\t\t\t    getvvcol(wp, &pos, NULL, NULL, &t);\n\t\t\t    if (toc < t)\n\t\t\t\ttoc = t;\n\t\t\t}\n\t\t\t++toc;\n\t\t    }\n\t\t    else\n\t\t\ttoc = MAXCOL;\n\t\t}\n\n\t\tif (fromc != wp->w_old_cursor_fcol\n\t\t\t|| toc != wp->w_old_cursor_lcol)\n\t\t{\n\t\t    if (from > VIsual.lnum)\n\t\t\tfrom = VIsual.lnum;\n\t\t    if (to < VIsual.lnum)\n\t\t\tto = VIsual.lnum;\n\t\t}\n\t\twp->w_old_cursor_fcol = fromc;\n\t\twp->w_old_cursor_lcol = toc;\n\t    }\n\t}\n\telse\n\t{\n\t    \/\/ Use the line numbers of the old Visual area.\n\t    if (wp->w_old_cursor_lnum < wp->w_old_visual_lnum)\n\t    {\n\t\tfrom = wp->w_old_cursor_lnum;\n\t\tto = wp->w_old_visual_lnum;\n\t    }\n\t    else\n\t    {\n\t\tfrom = wp->w_old_visual_lnum;\n\t\tto = wp->w_old_cursor_lnum;\n\t    }\n\t}\n\n\t\/\/ There is no need to update lines above the top of the window.\n\tif (from < wp->w_topline)\n\t    from = wp->w_topline;\n\n\t\/\/ If we know the value of w_botline, use it to restrict the update to\n\t\/\/ the lines that are visible in the window.\n\tif (wp->w_valid & VALID_BOTLINE)\n\t{\n\t    if (from >= wp->w_botline)\n\t\tfrom = wp->w_botline - 1;\n\t    if (to >= wp->w_botline)\n\t\tto = wp->w_botline - 1;\n\t}\n\n\t\/\/ Find the minimal part to be updated.\n\t\/\/ Watch out for scrolling that made entries in w_lines[] invalid.\n\t\/\/ E.g., CTRL-U makes the first half of w_lines[] invalid and sets\n\t\/\/ top_end; need to redraw from top_end to the \"to\" line.\n\t\/\/ A middle mouse click with a Visual selection may change the text\n\t\/\/ above the Visual area and reset wl_valid, do count these for\n\t\/\/ mid_end (in srow).\n\tif (mid_start > 0)\n\t{\n\t    lnum = wp->w_topline;\n\t    idx = 0;\n\t    srow = 0;\n\t    if (scrolled_down)\n\t\tmid_start = top_end;\n\t    else\n\t\tmid_start = 0;\n\t    while (lnum < from && idx < wp->w_lines_valid)\t\/\/ find start\n\t    {\n\t\tif (wp->w_lines[idx].wl_valid)\n\t\t    mid_start += wp->w_lines[idx].wl_size;\n\t\telse if (!scrolled_down)\n\t\t    srow += wp->w_lines[idx].wl_size;\n\t\t++idx;\n# ifdef FEAT_FOLDING\n\t\tif (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid)\n\t\t    lnum = wp->w_lines[idx].wl_lnum;\n\t\telse\n# endif\n\t\t    ++lnum;\n\t    }\n\t    srow += mid_start;\n\t    mid_end = wp->w_height;\n\t    for ( ; idx < wp->w_lines_valid; ++idx)\t\t\/\/ find end\n\t    {\n\t\tif (wp->w_lines[idx].wl_valid\n\t\t\t&& wp->w_lines[idx].wl_lnum >= to + 1)\n\t\t{\n\t\t    \/\/ Only update until first row of this line\n\t\t    mid_end = srow;\n\t\t    break;\n\t\t}\n\t\tsrow += wp->w_lines[idx].wl_size;\n\t    }\n\t}\n    }\n\n    if (VIsual_active && buf == curwin->w_buffer)\n    {\n\twp->w_old_visual_mode = VIsual_mode;\n\twp->w_old_cursor_lnum = curwin->w_cursor.lnum;\n\twp->w_old_visual_lnum = VIsual.lnum;\n\twp->w_old_visual_col = VIsual.col;\n\twp->w_old_curswant = curwin->w_curswant;\n    }\n    else\n    {\n\twp->w_old_visual_mode = 0;\n\twp->w_old_cursor_lnum = 0;\n\twp->w_old_visual_lnum = 0;\n\twp->w_old_visual_col = 0;\n    }\n\n#if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)\n    \/\/ reset got_int, otherwise regexp won't work\n    save_got_int = got_int;\n    got_int = 0;\n#endif\n#ifdef SYN_TIME_LIMIT\n    \/\/ Set the time limit to 'redrawtime'.\n    profile_setlimit(p_rdt, &syntax_tm);\n    syn_set_timeout(&syntax_tm);\n#endif\n#ifdef FEAT_FOLDING\n    win_foldinfo.fi_level = 0;\n#endif\n\n#ifdef FEAT_MENU\n    \/\/ Draw the window toolbar, if there is one.\n    \/\/ TODO: only when needed.\n    if (winbar_height(wp) > 0)\n\tredraw_win_toolbar(wp);\n#endif\n\n    \/\/ Update all the window rows.\n    idx = 0;\t\t\/\/ first entry in w_lines[].wl_size\n    row = 0;\n    srow = 0;\n    lnum = wp->w_topline;\t\/\/ first line shown in window\n    for (;;)\n    {\n\t\/\/ stop updating when reached the end of the window (check for _past_\n\t\/\/ the end of the window is at the end of the loop)\n\tif (row == wp->w_height)\n\t{\n\t    didline = TRUE;\n\t    break;\n\t}\n\n\t\/\/ stop updating when hit the end of the file\n\tif (lnum > buf->b_ml.ml_line_count)\n\t{\n\t    eof = TRUE;\n\t    break;\n\t}\n\n\t\/\/ Remember the starting row of the line that is going to be dealt\n\t\/\/ with.  It is used further down when the line doesn't fit.\n\tsrow = row;\n\n\t\/\/ Update a line when it is in an area that needs updating, when it\n\t\/\/ has changes or w_lines[idx] is invalid.\n\t\/\/ \"bot_start\" may be halfway a wrapped line after using\n\t\/\/ win_del_lines(), check if the current line includes it.\n\t\/\/ When syntax folding is being used, the saved syntax states will\n\t\/\/ already have been updated, we can't see where the syntax state is\n\t\/\/ the same again, just update until the end of the window.\n\tif (row < top_end\n\t\t|| (row >= mid_start && row < mid_end)\n#ifdef FEAT_SEARCH_EXTRA\n\t\t|| top_to_mod\n#endif\n\t\t|| idx >= wp->w_lines_valid\n\t\t|| (row + wp->w_lines[idx].wl_size > bot_start)\n\t\t|| (mod_top != 0\n\t\t    && (lnum == mod_top\n\t\t\t|| (lnum >= mod_top\n\t\t\t    && (lnum < mod_bot\n#ifdef FEAT_SYN_HL\n\t\t\t\t|| did_update == DID_FOLD\n\t\t\t\t|| (did_update == DID_LINE\n\t\t\t\t    && syntax_present(wp)\n\t\t\t\t    && (\n# ifdef FEAT_FOLDING\n\t\t\t\t\t(foldmethodIsSyntax(wp)\n\t\t\t\t\t\t      && hasAnyFolding(wp)) ||\n# endif\n\t\t\t\t\tsyntax_check_changed(lnum)))\n#endif\n#ifdef FEAT_SEARCH_EXTRA\n\t\t\t\t\/\/ match in fixed position might need redraw\n\t\t\t\t\/\/ if lines were inserted or deleted\n\t\t\t\t|| (wp->w_match_head != NULL\n\t\t\t\t\t\t    && buf->b_mod_xlines != 0)\n#endif\n\t\t\t\t))))\n#ifdef FEAT_SYN_HL\n\t\t|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum\n\t\t\t\t\t     || lnum == wp->w_last_cursorline))\n#endif\n\t\t\t\t)\n\t{\n#ifdef FEAT_SEARCH_EXTRA\n\t    if (lnum == mod_top)\n\t\ttop_to_mod = FALSE;\n#endif\n\n\t    \/\/ When at start of changed lines: May scroll following lines\n\t    \/\/ up or down to minimize redrawing.\n\t    \/\/ Don't do this when the change continues until the end.\n\t    \/\/ Don't scroll when dollar_vcol >= 0, keep the \"$\".\n\t    \/\/ Don't scroll when redrawing the top, scrolled already above.\n\t    if (lnum == mod_top\n\t\t    && mod_bot != MAXLNUM\n\t\t    && !(dollar_vcol >= 0 && mod_bot == mod_top + 1)\n\t\t    && row >= top_end)\n\t    {\n\t\tint\t\told_rows = 0;\n\t\tint\t\tnew_rows = 0;\n\t\tint\t\txtra_rows;\n\t\tlinenr_T\tl;\n\n\t\t\/\/ Count the old number of window rows, using w_lines[], which\n\t\t\/\/ should still contain the sizes for the lines as they are\n\t\t\/\/ currently displayed.\n\t\tfor (i = idx; i < wp->w_lines_valid; ++i)\n\t\t{\n\t\t    \/\/ Only valid lines have a meaningful wl_lnum.  Invalid\n\t\t    \/\/ lines are part of the changed area.\n\t\t    if (wp->w_lines[i].wl_valid\n\t\t\t    && wp->w_lines[i].wl_lnum == mod_bot)\n\t\t\tbreak;\n\t\t    old_rows += wp->w_lines[i].wl_size;\n#ifdef FEAT_FOLDING\n\t\t    if (wp->w_lines[i].wl_valid\n\t\t\t    && wp->w_lines[i].wl_lastlnum + 1 == mod_bot)\n\t\t    {\n\t\t\t\/\/ Must have found the last valid entry above mod_bot.\n\t\t\t\/\/ Add following invalid entries.\n\t\t\t++i;\n\t\t\twhile (i < wp->w_lines_valid\n\t\t\t\t\t\t  && !wp->w_lines[i].wl_valid)\n\t\t\t    old_rows += wp->w_lines[i++].wl_size;\n\t\t\tbreak;\n\t\t    }\n#endif\n\t\t}\n\n\t\tif (i >= wp->w_lines_valid)\n\t\t{\n\t\t    \/\/ We can't find a valid line below the changed lines,\n\t\t    \/\/ need to redraw until the end of the window.\n\t\t    \/\/ Inserting\/deleting lines has no use.\n\t\t    bot_start = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Able to count old number of rows: Count new window\n\t\t    \/\/ rows, and may insert\/delete lines\n\t\t    j = idx;\n\t\t    for (l = lnum; l < mod_bot; ++l)\n\t\t    {\n#ifdef FEAT_FOLDING\n\t\t\tif (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))\n\t\t\t    ++new_rows;\n\t\t\telse\n#endif\n#ifdef FEAT_DIFF\n\t\t\t    if (l == wp->w_topline)\n\t\t\t    new_rows += plines_win_nofill(wp, l, TRUE)\n\t\t\t\t\t\t\t      + wp->w_topfill;\n\t\t\telse\n#endif\n\t\t\t    new_rows += plines_win(wp, l, TRUE);\n\t\t\t++j;\n\t\t\tif (new_rows > wp->w_height - row - 2)\n\t\t\t{\n\t\t\t    \/\/ it's getting too much, must redraw the rest\n\t\t\t    new_rows = 9999;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t    xtra_rows = new_rows - old_rows;\n\t\t    if (xtra_rows < 0)\n\t\t    {\n\t\t\t\/\/ May scroll text up.  If there is not enough\n\t\t\t\/\/ remaining text or scrolling fails, must redraw the\n\t\t\t\/\/ rest.  If scrolling works, must redraw the text\n\t\t\t\/\/ below the scrolled text.\n\t\t\tif (row - xtra_rows >= wp->w_height - 2)\n\t\t\t    mod_bot = MAXLNUM;\n\t\t\telse\n\t\t\t{\n\t\t\t    check_for_delay(FALSE);\n\t\t\t    if (win_del_lines(wp, row,\n\t\t\t\t\t  -xtra_rows, FALSE, FALSE, 0) == FAIL)\n\t\t\t\tmod_bot = MAXLNUM;\n\t\t\t    else\n\t\t\t\tbot_start = wp->w_height + xtra_rows;\n\t\t\t}\n\t\t    }\n\t\t    else if (xtra_rows > 0)\n\t\t    {\n\t\t\t\/\/ May scroll text down.  If there is not enough\n\t\t\t\/\/ remaining text of scrolling fails, must redraw the\n\t\t\t\/\/ rest.\n\t\t\tif (row + xtra_rows >= wp->w_height - 2)\n\t\t\t    mod_bot = MAXLNUM;\n\t\t\telse\n\t\t\t{\n\t\t\t    check_for_delay(FALSE);\n\t\t\t    if (win_ins_lines(wp, row + old_rows,\n\t\t\t\t\t     xtra_rows, FALSE, FALSE) == FAIL)\n\t\t\t\tmod_bot = MAXLNUM;\n\t\t\t    else if (top_end > row + old_rows)\n\t\t\t\t\/\/ Scrolled the part at the top that requires\n\t\t\t\t\/\/ updating down.\n\t\t\t\ttop_end += xtra_rows;\n\t\t\t}\n\t\t    }\n\n\t\t    \/\/ When not updating the rest, may need to move w_lines[]\n\t\t    \/\/ entries.\n\t\t    if (mod_bot != MAXLNUM && i != j)\n\t\t    {\n\t\t\tif (j < i)\n\t\t\t{\n\t\t\t    int x = row + new_rows;\n\n\t\t\t    \/\/ move entries in w_lines[] upwards\n\t\t\t    for (;;)\n\t\t\t    {\n\t\t\t\t\/\/ stop at last valid entry in w_lines[]\n\t\t\t\tif (i >= wp->w_lines_valid)\n\t\t\t\t{\n\t\t\t\t    wp->w_lines_valid = j;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t\twp->w_lines[j] = wp->w_lines[i];\n\t\t\t\t\/\/ stop at a line that won't fit\n\t\t\t\tif (x + (int)wp->w_lines[j].wl_size\n\t\t\t\t\t\t\t   > wp->w_height)\n\t\t\t\t{\n\t\t\t\t    wp->w_lines_valid = j + 1;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t\tx += wp->w_lines[j++].wl_size;\n\t\t\t\t++i;\n\t\t\t    }\n\t\t\t    if (bot_start > x)\n\t\t\t\tbot_start = x;\n\t\t\t}\n\t\t\telse \/\/ j > i\n\t\t\t{\n\t\t\t    \/\/ move entries in w_lines[] downwards\n\t\t\t    j -= i;\n\t\t\t    wp->w_lines_valid += j;\n\t\t\t    if (wp->w_lines_valid > wp->w_height)\n\t\t\t\twp->w_lines_valid = wp->w_height;\n\t\t\t    for (i = wp->w_lines_valid; i - j >= idx; --i)\n\t\t\t\twp->w_lines[i] = wp->w_lines[i - j];\n\n\t\t\t    \/\/ The w_lines[] entries for inserted lines are\n\t\t\t    \/\/ now invalid, but wl_size may be used above.\n\t\t\t    \/\/ Reset to zero.\n\t\t\t    while (i >= idx)\n\t\t\t    {\n\t\t\t\twp->w_lines[i].wl_size = 0;\n\t\t\t\twp->w_lines[i--].wl_valid = FALSE;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\n#ifdef FEAT_FOLDING\n\t    \/\/ When lines are folded, display one line for all of them.\n\t    \/\/ Otherwise, display normally (can be several display lines when\n\t    \/\/ 'wrap' is on).\n\t    fold_count = foldedCount(wp, lnum, &win_foldinfo);\n\t    if (fold_count != 0)\n\t    {\n\t\tfold_line(wp, fold_count, &win_foldinfo, lnum, row);\n\t\t++row;\n\t\t--fold_count;\n\t\twp->w_lines[idx].wl_folded = TRUE;\n\t\twp->w_lines[idx].wl_lastlnum = lnum + fold_count;\n# ifdef FEAT_SYN_HL\n\t\tdid_update = DID_FOLD;\n# endif\n\t    }\n\t    else\n#endif\n\t    if (idx < wp->w_lines_valid\n\t\t    && wp->w_lines[idx].wl_valid\n\t\t    && wp->w_lines[idx].wl_lnum == lnum\n\t\t    && lnum > wp->w_topline\n\t\t    && !(dy_flags & (DY_LASTLINE | DY_TRUNCATE))\n\t\t    && !WIN_IS_POPUP(wp)\n\t\t    && srow + wp->w_lines[idx].wl_size > wp->w_height\n#ifdef FEAT_DIFF\n\t\t    && diff_check_fill(wp, lnum) == 0\n#endif\n\t\t    )\n\t    {\n\t\t\/\/ This line is not going to fit.  Don't draw anything here,\n\t\t\/\/ will draw \"@  \" lines below.\n\t\trow = wp->w_height + 1;\n\t    }\n\t    else\n\t    {\n#ifdef FEAT_SEARCH_EXTRA\n\t\tprepare_search_hl(wp, &screen_search_hl, lnum);\n#endif\n#ifdef FEAT_SYN_HL\n\t\t\/\/ Let the syntax stuff know we skipped a few lines.\n\t\tif (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum\n\t\t\t\t\t\t       && syntax_present(wp))\n\t\t    syntax_end_parsing(syntax_last_parsed + 1);\n#endif\n\n\t\t\/\/ Display one line.\n\t\trow = win_line(wp, lnum, srow, wp->w_height,\n\t\t\t\t\t\t\t  mod_top == 0, FALSE);\n\n#ifdef FEAT_FOLDING\n\t\twp->w_lines[idx].wl_folded = FALSE;\n\t\twp->w_lines[idx].wl_lastlnum = lnum;\n#endif\n#ifdef FEAT_SYN_HL\n\t\tdid_update = DID_LINE;\n\t\tsyntax_last_parsed = lnum;\n#endif\n\t    }\n\n\t    wp->w_lines[idx].wl_lnum = lnum;\n\t    wp->w_lines[idx].wl_valid = TRUE;\n\n\t    \/\/ Past end of the window or end of the screen. Note that after\n\t    \/\/ resizing wp->w_height may be end up too big. That's a problem\n\t    \/\/ elsewhere, but prevent a crash here.\n\t    if (row > wp->w_height || row + wp->w_winrow >= Rows)\n\t    {\n\t\t\/\/ we may need the size of that too long line later on\n\t\tif (dollar_vcol == -1)\n\t\t    wp->w_lines[idx].wl_size = plines_win(wp, lnum, TRUE);\n\t\t++idx;\n\t\tbreak;\n\t    }\n\t    if (dollar_vcol == -1)\n\t\twp->w_lines[idx].wl_size = row - srow;\n\t    ++idx;\n#ifdef FEAT_FOLDING\n\t    lnum += fold_count + 1;\n#else\n\t    ++lnum;\n#endif\n\t}\n\telse\n\t{\n\t    if (wp->w_p_rnu)\n\t    {\n#ifdef FEAT_FOLDING\n\t\t\/\/ 'relativenumber' set: The text doesn't need to be drawn, but\n\t\t\/\/ the number column nearly always does.\n\t\tfold_count = foldedCount(wp, lnum, &win_foldinfo);\n\t\tif (fold_count != 0)\n\t\t    fold_line(wp, fold_count, &win_foldinfo, lnum, row);\n\t\telse\n#endif\n\t\t    (void)win_line(wp, lnum, srow, wp->w_height, TRUE, TRUE);\n\t    }\n\n\t    \/\/ This line does not need to be drawn, advance to the next one.\n\t    row += wp->w_lines[idx++].wl_size;\n\t    if (row > wp->w_height)\t\/\/ past end of screen\n\t\tbreak;\n#ifdef FEAT_FOLDING\n\t    lnum = wp->w_lines[idx - 1].wl_lastlnum + 1;\n#else\n\t    ++lnum;\n#endif\n#ifdef FEAT_SYN_HL\n\t    did_update = DID_NONE;\n#endif\n\t}\n\n\tif (lnum > buf->b_ml.ml_line_count)\n\t{\n\t    eof = TRUE;\n\t    break;\n\t}\n    }\n\n    \/\/ End of loop over all window lines.\n\n#ifdef FEAT_VTP\n    \/\/ Rewrite the character at the end of the screen line.\n    \/\/ See the version that was fixed.\n    if (use_vtp() && get_conpty_fix_type() < 1)\n    {\n\tint i;\n\n\tfor (i = 0; i < Rows; ++i)\n\t    if (enc_utf8)\n\t\tif ((*mb_off2cells)(LineOffset[i] + Columns - 2,\n\t\t\t\t\t   LineOffset[i] + screen_Columns) > 1)\n\t\t    screen_draw_rectangle(i, Columns - 2, 1, 2, FALSE);\n\t\telse\n\t\t    screen_draw_rectangle(i, Columns - 1, 1, 1, FALSE);\n\t    else\n\t\tscreen_char(LineOffset[i] + Columns - 1, i, Columns - 1);\n    }\n#endif\n\n    if (idx > wp->w_lines_valid)\n\twp->w_lines_valid = idx;\n\n#ifdef FEAT_SYN_HL\n    \/\/ Let the syntax stuff know we stop parsing here.\n    if (syntax_last_parsed != 0 && syntax_present(wp))\n\tsyntax_end_parsing(syntax_last_parsed + 1);\n#endif\n\n    \/\/ If we didn't hit the end of the file, and we didn't finish the last\n    \/\/ line we were working on, then the line didn't fit.\n    wp->w_empty_rows = 0;\n#ifdef FEAT_DIFF\n    wp->w_filler_rows = 0;\n#endif\n    if (!eof && !didline)\n    {\n\tif (lnum == wp->w_topline)\n\t{\n\t    \/\/ Single line that does not fit!\n\t    \/\/ Don't overwrite it, it can be edited.\n\t    wp->w_botline = lnum + 1;\n\t}\n#ifdef FEAT_DIFF\n\telse if (diff_check_fill(wp, lnum) >= wp->w_height - srow)\n\t{\n\t    \/\/ Window ends in filler lines.\n\t    wp->w_botline = lnum;\n\t    wp->w_filler_rows = wp->w_height - srow;\n\t}\n#endif\n#ifdef FEAT_PROP_POPUP\n\telse if (WIN_IS_POPUP(wp))\n\t{\n\t    \/\/ popup line that doesn't fit is left as-is\n\t    wp->w_botline = lnum;\n\t}\n#endif\n\telse if (dy_flags & DY_TRUNCATE)\t\/\/ 'display' has \"truncate\"\n\t{\n\t    int scr_row = W_WINROW(wp) + wp->w_height - 1;\n\n\t    \/\/ Last line isn't finished: Display \"@@@\" in the last screen line.\n\t    screen_puts_len((char_u *)\"@@\", 2, scr_row, wp->w_wincol,\n\t\t\t\t\t\t\t      HL_ATTR(HLF_AT));\n\t    screen_fill(scr_row, scr_row + 1,\n\t\t    (int)wp->w_wincol + 2, (int)W_ENDCOL(wp),\n\t\t    '@', ' ', HL_ATTR(HLF_AT));\n\t    set_empty_rows(wp, srow);\n\t    wp->w_botline = lnum;\n\t}\n\telse if (dy_flags & DY_LASTLINE)\t\/\/ 'display' has \"lastline\"\n\t{\n\t    \/\/ Last line isn't finished: Display \"@@@\" at the end.\n\t    screen_fill(W_WINROW(wp) + wp->w_height - 1,\n\t\t    W_WINROW(wp) + wp->w_height,\n\t\t    (int)W_ENDCOL(wp) - 3, (int)W_ENDCOL(wp),\n\t\t    '@', '@', HL_ATTR(HLF_AT));\n\t    set_empty_rows(wp, srow);\n\t    wp->w_botline = lnum;\n\t}\n\telse\n\t{\n\t    win_draw_end(wp, '@', ' ', TRUE, srow, wp->w_height, HLF_AT);\n\t    wp->w_botline = lnum;\n\t}\n    }\n    else\n    {\n\tdraw_vsep_win(wp, row);\n\tif (eof)\t\t\/\/ we hit the end of the file\n\t{\n\t    wp->w_botline = buf->b_ml.ml_line_count + 1;\n#ifdef FEAT_DIFF\n\t    j = diff_check_fill(wp, wp->w_botline);\n\t    if (j > 0 && !wp->w_botfill)\n\t    {\n\t\t\/\/ Display filler lines at the end of the file.\n\t\tif (char2cells(fill_diff) > 1)\n\t\t    i = '-';\n\t\telse\n\t\t    i = fill_diff;\n\t\tif (row + j > wp->w_height)\n\t\t    j = wp->w_height - row;\n\t\twin_draw_end(wp, i, i, TRUE, row, row + (int)j, HLF_DED);\n\t\trow += j;\n\t    }\n#endif\n\t}\n\telse if (dollar_vcol == -1)\n\t    wp->w_botline = lnum;\n\n\t\/\/ Make sure the rest of the screen is blank\n\t\/\/ write the 'fill_eob' character to rows that aren't part of the file\n\tif (WIN_IS_POPUP(wp))\n\t    win_draw_end(wp, ' ', ' ', FALSE, row, wp->w_height, HLF_AT);\n\telse\n\t    win_draw_end(wp, fill_eob, ' ', FALSE, row, wp->w_height, HLF_EOB);\n    }\n\n#ifdef SYN_TIME_LIMIT\n    syn_set_timeout(NULL);\n#endif\n\n    \/\/ Reset the type of redrawing required, the window has been updated.\n    wp->w_redr_type = 0;\n#ifdef FEAT_DIFF\n    wp->w_old_topfill = wp->w_topfill;\n    wp->w_old_botfill = wp->w_botfill;\n#endif\n\n    if (dollar_vcol == -1)\n    {\n\t\/\/ There is a trick with w_botline.  If we invalidate it on each\n\t\/\/ change that might modify it, this will cause a lot of expensive\n\t\/\/ calls to plines() in update_topline() each time.  Therefore the\n\t\/\/ value of w_botline is often approximated, and this value is used to\n\t\/\/ compute the value of w_topline.  If the value of w_botline was\n\t\/\/ wrong, check that the value of w_topline is correct (cursor is on\n\t\/\/ the visible part of the text).  If it's not, we need to redraw\n\t\/\/ again.  Mostly this just means scrolling up a few lines, so it\n\t\/\/ doesn't look too bad.  Only do this for the current window (where\n\t\/\/ changes are relevant).\n\twp->w_valid |= VALID_BOTLINE;\n\tif (wp == curwin && wp->w_botline != old_botline && !recursive)\n\t{\n\t    win_T\t*wwp;\n#if defined(FEAT_CONCEAL)\n\t    linenr_T\told_topline = wp->w_topline;\n\t    int\t\tnew_wcol = wp->w_wcol;\n#endif\n\t    recursive = TRUE;\n\t    curwin->w_valid &= ~VALID_TOPLINE;\n\t    update_topline();\t\/\/ may invalidate w_botline again\n\n#if defined(FEAT_CONCEAL)\n\t    if (old_wcol != new_wcol && (wp->w_valid & (VALID_WCOL|VALID_WROW))\n\t\t\t\t\t\t    != (VALID_WCOL|VALID_WROW))\n\t    {\n\t\t\/\/ A win_line() call applied a fix to screen cursor column to\n\t\t\/\/ accommodate concealment of cursor line, but in this call to\n\t\t\/\/ update_topline() the cursor's row or column got invalidated.\n\t\t\/\/ If they are left invalid, setcursor() will recompute them\n\t\t\/\/ but there won't be any further win_line() call to re-fix the\n\t\t\/\/ column and the cursor will end up misplaced.  So we call\n\t\t\/\/ cursor validation now and reapply the fix again (or call\n\t\t\/\/ win_line() to do it for us).\n\t\tvalidate_cursor();\n\t\tif (wp->w_wcol == old_wcol && wp->w_wrow == old_wrow\n\t\t\t\t\t       && old_topline == wp->w_topline)\n\t\t    wp->w_wcol = new_wcol;\n\t\telse\n\t\t    redrawWinline(wp, wp->w_cursor.lnum);\n\t    }\n#endif\n\t    \/\/ New redraw either due to updated topline or due to wcol fix.\n\t    if (wp->w_redr_type != 0)\n\t    {\n\t\t\/\/ Don't update for changes in buffer again.\n\t\ti = curbuf->b_mod_set;\n\t\tcurbuf->b_mod_set = FALSE;\n\t\tj = curbuf->b_mod_xlines;\n\t\tcurbuf->b_mod_xlines = 0;\n\t\twin_update(curwin);\n\t\tcurbuf->b_mod_set = i;\n\t\tcurbuf->b_mod_xlines = j;\n\t    }\n\t    \/\/ Other windows might have w_redr_type raised in update_topline().\n\t    must_redraw = 0;\n\t    FOR_ALL_WINDOWS(wwp)\n\t\tif (wwp->w_redr_type > must_redraw)\n\t\t    must_redraw = wwp->w_redr_type;\n\t    recursive = FALSE;\n\t}\n    }\n\n#if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)\n    \/\/ restore got_int, unless CTRL-C was hit while redrawing\n    if (!got_int)\n\tgot_int = save_got_int;\n#endif\n}","target":0,"code_token_length":11522,"total_token_length":11758,"max_tokens_setting":28000}
+{"idx":195691,"func":"mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)\n{\n  \/* mrb_assert(MRB_PROC_CFUNC_P(proc)) *\/\n  const mrb_irep *irep = proc->body.irep;\n  const mrb_pool_value *pool = irep->pool;\n  const mrb_sym *syms = irep->syms;\n  mrb_code insn;\n  int ai = mrb_gc_arena_save(mrb);\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf c_jmp;\n  uint32_t a;\n  uint16_t b;\n  uint16_t c;\n  mrb_sym mid;\n  const struct mrb_irep_catch_handler *ch;\n\n#ifdef DIRECT_THREADED\n  static const void * const optable[] = {\n#define OPCODE(x,_) &&L_OP_ ## x,\n#include \"mruby\/ops.h\"\n#undef OPCODE\n  };\n#endif\n\n  mrb_bool exc_catched = FALSE;\nRETRY_TRY_BLOCK:\n\n  MRB_TRY(&c_jmp) {\n\n  if (exc_catched) {\n    exc_catched = FALSE;\n    mrb_gc_arena_restore(mrb, ai);\n    if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)\n      goto L_BREAK;\n    goto L_RAISE;\n  }\n  mrb->jmp = &c_jmp;\n  mrb_vm_ci_proc_set(mrb->c->ci, proc);\n\n#define regs (mrb->c->ci->stack)\n  INIT_DISPATCH {\n    CASE(OP_NOP, Z) {\n      \/* do nothing *\/\n      NEXT;\n    }\n\n    CASE(OP_MOVE, BB) {\n      regs[a] = regs[b];\n      NEXT;\n    }\n\n    CASE(OP_LOADL, BB) {\n      switch (pool[b].tt) {   \/* number *\/\n      case IREP_TT_INT32:\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);\n        break;\n      case IREP_TT_INT64:\n#if defined(MRB_INT64)\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n        break;\n#else\n#if defined(MRB_64BIT)\n        if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {\n          regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n          break;\n        }\n#endif\n        goto L_INT_OVERFLOW;\n#endif\n      case IREP_TT_BIGINT:\n#ifdef MRB_USE_BIGINT\n        {\n          const char *s = pool[b].u.str;\n          regs[a] = mrb_bint_new_str(mrb, s+2, (mrb_int)s[0], (mrb_int)s[1]);\n        }\n        break;\n#else\n        goto L_INT_OVERFLOW;\n#endif\n#ifndef MRB_NO_FLOAT\n      case IREP_TT_FLOAT:\n        regs[a] = mrb_float_value(mrb, pool[b].u.f);\n        break;\n#endif\n      default:\n        \/* should not happen (tt:string) *\/\n        regs[a] = mrb_nil_value();\n        break;\n      }\n      NEXT;\n    }\n\n    CASE(OP_LOADI, BB) {\n      SET_FIXNUM_VALUE(regs[a], b);\n      NEXT;\n    }\n\n    CASE(OP_LOADINEG, BB) {\n      SET_FIXNUM_VALUE(regs[a], -b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI__1,B) goto L_LOADI;\n    CASE(OP_LOADI_0,B) goto L_LOADI;\n    CASE(OP_LOADI_1,B) goto L_LOADI;\n    CASE(OP_LOADI_2,B) goto L_LOADI;\n    CASE(OP_LOADI_3,B) goto L_LOADI;\n    CASE(OP_LOADI_4,B) goto L_LOADI;\n    CASE(OP_LOADI_5,B) goto L_LOADI;\n    CASE(OP_LOADI_6,B) goto L_LOADI;\n    CASE(OP_LOADI_7, B) {\n    L_LOADI:\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);\n      NEXT;\n    }\n\n    CASE(OP_LOADI16, BS) {\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI32, BSS) {\n      SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));\n      NEXT;\n    }\n\n    CASE(OP_LOADSYM, BB) {\n      SET_SYM_VALUE(regs[a], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_LOADNIL, B) {\n      SET_NIL_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADSELF, B) {\n      regs[a] = regs[0];\n      NEXT;\n    }\n\n    CASE(OP_LOADT, B) {\n      SET_TRUE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADF, B) {\n      SET_FALSE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETGV, BB) {\n      mrb_value val = mrb_gv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETGV, BB) {\n      mrb_gv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETSV, BB) {\n      mrb_value val = mrb_vm_special_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETSV, BB) {\n      mrb_vm_special_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIV, BB) {\n      regs[a] = mrb_iv_get(mrb, regs[0], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETIV, BB) {\n      mrb_iv_set(mrb, regs[0], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETCV, BB) {\n      mrb_value val;\n      val = mrb_vm_cv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETCV, BB) {\n      mrb_vm_cv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIDX, B) {\n      mrb_value va = regs[a], vb = regs[a+1];\n      switch (mrb_type(va)) {\n      case MRB_TT_ARRAY:\n        if (!mrb_integer_p(vb)) goto getidx_fallback;\n        regs[a] = mrb_ary_entry(va, mrb_integer(vb));\n        break;\n      case MRB_TT_HASH:\n        va = mrb_hash_get(mrb, va, vb);\n        regs[a] = va;\n        break;\n      case MRB_TT_STRING:\n        switch (mrb_type(vb)) {\n        case MRB_TT_INTEGER:\n        case MRB_TT_STRING:\n        case MRB_TT_RANGE:\n          va = mrb_str_aref(mrb, va, vb, mrb_undef_value());\n          regs[a] = va;\n          break;\n        default:\n          goto getidx_fallback;\n        }\n        break;\n      default:\n      getidx_fallback:\n        mid = MRB_OPSYM(aref);\n        goto L_SEND_SYM;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETIDX, B) {\n      c = 2;\n      mid = MRB_OPSYM(aset);\n      SET_NIL_VALUE(regs[a+3]);\n      goto L_SENDB_SYM;\n    }\n\n    CASE(OP_GETCONST, BB) {\n      mrb_value v = mrb_vm_const_get(mrb, syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETCONST, BB) {\n      mrb_vm_const_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETMCNST, BB) {\n      mrb_value v = mrb_const_get(mrb, regs[a], syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETMCNST, BB) {\n      mrb_const_set(mrb, regs[a+1], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETUPVAR, BBB) {\n      mrb_value *regs_a = regs + a;\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e && b < MRB_ENV_LEN(e)) {\n        *regs_a = e->stack[b];\n      }\n      else {\n        *regs_a = mrb_nil_value();\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETUPVAR, BBB) {\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e) {\n        mrb_value *regs_a = regs + a;\n\n        if (b < MRB_ENV_LEN(e)) {\n          e->stack[b] = *regs_a;\n          mrb_write_barrier(mrb, (struct RBasic*)e);\n        }\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMP, S) {\n      pc += (int16_t)a;\n      JUMP;\n    }\n    CASE(OP_JMPIF, BS) {\n      if (mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNOT, BS) {\n      if (!mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNIL, BS) {\n      if (mrb_nil_p(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMPUW, S) {\n      a = (uint32_t)((pc - irep->iseq) + (int16_t)a);\n      CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {\n        struct RBreak *brk = (struct RBreak*)mrb->exc;\n        mrb_value target = mrb_break_value_get(brk);\n        mrb_assert(mrb_integer_p(target));\n        a = (uint32_t)mrb_integer(target);\n        mrb_assert(a >= 0 && a < irep->ilen);\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {\n        ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);\n        if (ch) {\n          \/* avoiding a jump from a catch handler into the same handler *\/\n          if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {\n            THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));\n          }\n        }\n      }\n      CHECKPOINT_END(RBREAK_TAG_JUMP);\n\n      mrb->exc = NULL; \/* clear break object *\/\n      pc = irep->iseq + a;\n      JUMP;\n    }\n\n    CASE(OP_EXCEPT, B) {\n      mrb_value exc;\n\n      if (mrb->exc == NULL) {\n        exc = mrb_nil_value();\n      }\n      else {\n        switch (mrb->exc->tt) {\n        case MRB_TT_BREAK:\n        case MRB_TT_EXCEPTION:\n          exc = mrb_obj_value(mrb->exc);\n          break;\n        default:\n          mrb_assert(!\"bad mrb_type\");\n          exc = mrb_nil_value();\n          break;\n        }\n        mrb->exc = NULL;\n      }\n      regs[a] = exc;\n      NEXT;\n    }\n    CASE(OP_RESCUE, BB) {\n      mrb_value exc = regs[a];  \/* exc on stack *\/\n      mrb_value e = regs[b];\n      struct RClass *ec;\n\n      switch (mrb_type(e)) {\n      case MRB_TT_CLASS:\n      case MRB_TT_MODULE:\n        break;\n      default:\n        {\n          mrb_value exc;\n\n          exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                    \"class or module required for rescue clause\");\n          mrb_exc_set(mrb, exc);\n          goto L_RAISE;\n        }\n      }\n      ec = mrb_class_ptr(e);\n      regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));\n      NEXT;\n    }\n\n    CASE(OP_RAISEIF, B) {\n      mrb_value exc = regs[a];\n      if (mrb_break_p(exc)) {\n        mrb->exc = mrb_obj_ptr(exc);\n        goto L_BREAK;\n      }\n      mrb_exc_set(mrb, exc);\n      if (mrb->exc) {\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SSEND, BBB) {\n      regs[a] = regs[0];\n      insn = OP_SEND;\n    }\n    goto L_SENDB;\n\n    CASE(OP_SSENDB, BBB) {\n      regs[a] = regs[0];\n    }\n    goto L_SENDB;\n\n    CASE(OP_SEND, BBB)\n    goto L_SENDB;\n\n    L_SEND_SYM:\n    c = 1;\n    \/* push nil after arguments *\/\n    SET_NIL_VALUE(regs[a+2]);\n    goto L_SENDB_SYM;\n\n    CASE(OP_SENDB, BBB)\n    L_SENDB:\n    mid = syms[b];\n    L_SENDB_SYM:\n    {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_value recv, blk;\n\n      ARGUMENT_NORMALIZE(a, &c, insn);\n\n      recv = regs[a];\n      cls = mrb_class(mrb, recv);\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, c);\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        if (MRB_METHOD_PROC_P(m)) {\n          struct RProc *p = MRB_METHOD_PROC(m);\n\n          mrb_vm_ci_proc_set(ci, p);\n          recv = p->body.func(mrb, recv);\n        }\n        else {\n          if (MRB_METHOD_NOARG_P(m)) {\n            check_method_noarg(mrb, ci);\n          }\n          recv = MRB_METHOD_FUNC(m)(mrb, recv);\n        }\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n          if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n        if (!ci->u.target_class) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return recv;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        ci->stack[0] = recv;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n    }\n    JUMP;\n\n    CASE(OP_CALL, Z) {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv = ci->stack[0];\n      struct RProc *m = mrb_proc_ptr(recv);\n\n      \/* replace callinfo *\/\n      ci->u.target_class = MRB_PROC_TARGET_CLASS(m);\n      mrb_vm_ci_proc_set(ci, m);\n      if (MRB_PROC_ENV_P(m)) {\n        ci->mid = MRB_PROC_ENV(m)->mid;\n      }\n\n      \/* prepare stack *\/\n      if (MRB_PROC_CFUNC_P(m)) {\n        recv = MRB_PROC_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n        ci[1].stack[0] = recv;\n        irep = mrb->c->ci->proc->body.irep;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        proc = m;\n        irep = m->body.irep;\n        if (!irep) {\n          mrb->c->ci->stack[0] = mrb_nil_value();\n          a = 0;\n          c = OP_R_NORMAL;\n          goto L_OP_RETURN_BODY;\n        }\n        mrb_int nargs = mrb_ci_bidx(ci)+1;\n        if (nargs < irep->nregs) {\n          mrb_stack_extend(mrb, irep->nregs);\n          stack_clear(regs+nargs, irep->nregs-nargs);\n        }\n        if (MRB_PROC_ENV_P(m)) {\n          regs[0] = MRB_PROC_ENV(m)->stack[0];\n        }\n        pc = irep->iseq;\n      }\n      pool = irep->pool;\n      syms = irep->syms;\n      JUMP;\n    }\n\n    CASE(OP_SUPER, BB) {\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv, blk;\n      const struct RProc *p = ci->proc;\n      mrb_sym mid = ci->mid;\n      struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);\n\n      if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { \/* alias support *\/\n        mid = p->e.env->mid;    \/* restore old mid *\/\n      }\n\n      if (mid == 0 || !target_class) {\n        mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {\n        target_class = mrb_vm_ci_target_class(ci);\n      }\n      else if (target_class->tt == MRB_TT_MODULE) {\n        target_class = mrb_vm_ci_target_class(ci);\n        if (!target_class || target_class->tt != MRB_TT_ICLASS) {\n          goto super_typeerror;\n        }\n      }\n      recv = regs[0];\n      if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {\n      super_typeerror: ;\n        mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                            \"self has wrong type to call super in this context\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n\n      ARGUMENT_NORMALIZE(a, &b, OP_SUPER);\n\n      cls = target_class->super;\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, b);\n\n      \/* prepare stack *\/\n      ci->stack[0] = recv;\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        mrb_value v;\n\n        if (MRB_METHOD_PROC_P(m)) {\n          mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n        }\n        v = MRB_METHOD_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_restore(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        mrb_assert(!mrb_break_p(v));\n        if (!mrb_vm_ci_target_class(ci)) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return v;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        mrb->c->ci->stack[0] = v;\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n      JUMP;\n    }\n\n    CASE(OP_ARGARY, BS) {\n      mrb_int m1 = (b>>11)&0x3f;\n      mrb_int r  = (b>>10)&0x1;\n      mrb_int m2 = (b>>5)&0x1f;\n      mrb_int kd = (b>>4)&0x1;\n      mrb_int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {\n        mrb_value exc;\n\n      L_NOSUPER:\n        exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e) goto L_NOSUPER;\n        if (MRB_ENV_LEN(e) <= m1+r+m2+1)\n          goto L_NOSUPER;\n        stack = e->stack + 1;\n      }\n      if (r == 0) {\n        regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack);\n      }\n      else {\n        mrb_value *pp = NULL;\n        struct RArray *rest;\n        mrb_int len = 0;\n\n        if (mrb_array_p(stack[m1])) {\n          struct RArray *ary = mrb_ary_ptr(stack[m1]);\n\n          pp = ARY_PTR(ary);\n          len = ARY_LEN(ary);\n        }\n        regs[a] = mrb_ary_new_capa(mrb, m1+len+m2);\n        rest = mrb_ary_ptr(regs[a]);\n        if (m1 > 0) {\n          stack_copy(ARY_PTR(rest), stack, m1);\n        }\n        if (len > 0) {\n          stack_copy(ARY_PTR(rest)+m1, pp, len);\n        }\n        if (m2 > 0) {\n          stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2);\n        }\n        ARY_SET_LEN(rest, m1+len+m2);\n      }\n      if (kd) {\n        regs[a+1] = stack[m1+r+m2];\n        regs[a+2] = stack[m1+r+m2+1];\n      }\n      else {\n        regs[a+1] = stack[m1+r+m2];\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ENTER, W) {\n      mrb_int m1 = MRB_ASPEC_REQ(a);\n      mrb_int o  = MRB_ASPEC_OPT(a);\n      mrb_int r  = MRB_ASPEC_REST(a);\n      mrb_int m2 = MRB_ASPEC_POST(a);\n      mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;\n      \/* unused\n      int b  = MRB_ASPEC_BLOCK(a);\n      *\/\n      mrb_int const len = m1 + o + r + m2;\n\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_int argc = ci->n;\n      mrb_value *argv = regs+1;\n      mrb_value * const argv0 = argv;\n      mrb_int const kw_pos = len + kd;    \/* where kwhash should be *\/\n      mrb_int const blk_pos = kw_pos + 1; \/* where block should be *\/\n      mrb_value blk = regs[mrb_ci_bidx(ci)];\n      mrb_value kdict = mrb_nil_value();\n\n      \/* keyword arguments *\/\n      if (ci->nk > 0) {\n        mrb_int kidx = mrb_ci_kidx(ci);\n        kdict = regs[kidx];\n        if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) {\n          kdict = mrb_nil_value();\n          ci->nk = 0;\n        }\n      }\n      if (!kd && !mrb_nil_p(kdict)) {\n        if (argc < 14) {\n          ci->n++;\n          argc++;    \/* include kdict in normal arguments *\/\n        }\n        else if (argc == 14) {\n          \/* pack arguments and kdict *\/\n          regs[1] = mrb_ary_new_from_values(mrb, argc+1, ®s[1]);\n          argc = ci->n = 15;\n        }\n        else {\/* argc == 15 *\/\n          \/* push kdict to packed arguments *\/\n          mrb_ary_push(mrb, regs[1], regs[2]);\n        }\n        ci->nk = 0;\n      }\n      if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) {\n        kdict = mrb_hash_dup(mrb, kdict);\n      }\n\n      \/* arguments is passed with Array *\/\n      if (argc == 15) {\n        struct RArray *ary = mrb_ary_ptr(regs[1]);\n        argv = ARY_PTR(ary);\n        argc = (int)ARY_LEN(ary);\n        mrb_gc_protect(mrb, regs[1]);\n      }\n\n      \/* strict argument check *\/\n      if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) {\n        if (argc < m1 + m2 || (r == 0 && argc > len)) {\n          argnum_error(mrb, m1+m2);\n          goto L_RAISE;\n        }\n      }\n      \/* extract first argument array to arguments *\/\n      else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) {\n        mrb_gc_protect(mrb, argv[0]);\n        argc = (int)RARRAY_LEN(argv[0]);\n        argv = RARRAY_PTR(argv[0]);\n      }\n\n      \/* rest arguments *\/\n      mrb_value rest = mrb_nil_value();\n      if (argc < len) {\n        mrb_int mlen = m2;\n        if (argc < m1+m2) {\n          mlen = m1 < argc ? argc - m1 : 0;\n        }\n\n        \/* copy mandatory and optional arguments *\/\n        if (argv0 != argv && argv) {\n          value_move(®s[1], argv, argc-mlen); \/* m1 + o *\/\n        }\n        if (argc < m1) {\n          stack_clear(®s[argc+1], m1-argc);\n        }\n        \/* copy post mandatory arguments *\/\n        if (mlen) {\n          value_move(®s[len-m2+1], &argv[argc-mlen], mlen);\n        }\n        if (mlen < m2) {\n          stack_clear(®s[len-m2+mlen+1], m2-mlen);\n        }\n        \/* initialize rest arguments with empty Array *\/\n        if (r) {\n          rest = mrb_ary_new_capa(mrb, 0);\n          regs[m1+o+1] = rest;\n        }\n        \/* skip initializer of passed arguments *\/\n        if (o > 0 && argc > m1+m2)\n          pc += (argc - m1 - m2)*3;\n      }\n      else {\n        mrb_int rnum = 0;\n        if (argv0 != argv) {\n          value_move(®s[1], argv, m1+o);\n        }\n        if (r) {\n          rnum = argc-m1-o-m2;\n          rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o);\n          regs[m1+o+1] = rest;\n        }\n        if (m2 > 0 && argc-m2 > m1) {\n          value_move(®s[m1+o+r+1], &argv[m1+o+rnum], m2);\n        }\n        pc += o*3;\n      }\n\n      \/* need to be update blk first to protect blk from GC *\/\n      regs[blk_pos] = blk;              \/* move block *\/\n      if (kd) {\n        if (mrb_nil_p(kdict))\n          kdict = mrb_hash_new_capa(mrb, 0);\n        regs[kw_pos] = kdict;           \/* set kwhash *\/\n      }\n\n      \/* format arguments for generated code *\/\n      mrb->c->ci->n = (uint8_t)len;\n\n      \/* clear local (but non-argument) variables *\/\n      if (irep->nlocals-blk_pos-1 > 0) {\n        stack_clear(®s[blk_pos+1], irep->nlocals-blk_pos-1);\n      }\n      JUMP;\n    }\n\n    CASE(OP_KARG, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict, v;\n\n      if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) {\n        mrb_value str = mrb_format(mrb, \"missing keyword: %v\", k);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      v = mrb_hash_get(mrb, kdict, k);\n      regs[a] = v;\n      mrb_hash_delete_key(mrb, kdict, k);\n      NEXT;\n    }\n\n    CASE(OP_KEY_P, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n      mrb_bool key_p = FALSE;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) {\n        key_p = mrb_hash_key_p(mrb, kdict, k);\n      }\n      regs[a] = mrb_bool_value(key_p);\n      NEXT;\n    }\n\n    CASE(OP_KEYEND, Z) {\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) {\n        mrb_value keys = mrb_hash_keys(mrb, kdict);\n        mrb_value key1 = RARRAY_PTR(keys)[0];\n        mrb_value str = mrb_format(mrb, \"unknown keyword: %v\", key1);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_BREAK, B) {\n      c = OP_R_BREAK;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN_BLK, B) {\n      c = OP_R_RETURN;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN, B)\n    c = OP_R_NORMAL;\n    L_RETURN:\n    {\n      mrb_callinfo *ci;\n\n      ci = mrb->c->ci;\n      if (ci->mid) {\n        mrb_value blk = regs[mrb_ci_bidx(ci)];\n\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n\n          if (!MRB_PROC_STRICT_P(p) &&\n              ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n      }\n\n      if (mrb->exc) {\n      L_RAISE:\n        ci = mrb->c->ci;\n        if (ci == mrb->c->cibase) {\n          ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n          if (ch == NULL) goto L_FTOP;\n          goto L_CATCH;\n        }\n        while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {\n          ci = cipop(mrb);\n          if (ci[1].cci == CINFO_SKIP && prev_jmp) {\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          pc = ci[0].pc;\n          if (ci == mrb->c->cibase) {\n            ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n            if (ch == NULL) {\n            L_FTOP:             \/* fiber top *\/\n              if (mrb->c == mrb->root_c) {\n                mrb->c->ci->stack = mrb->c->stbase;\n                goto L_STOP;\n              }\n              else {\n                struct mrb_context *c = mrb->c;\n\n                c->status = MRB_FIBER_TERMINATED;\n                mrb->c = c->prev;\n                c->prev = NULL;\n                goto L_RAISE;\n              }\n            }\n            break;\n          }\n        }\n      L_CATCH:\n        if (ch == NULL) goto L_STOP;\n        if (FALSE) {\n        L_CATCH_TAGGED_BREAK: \/* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() *\/\n          ci = mrb->c->ci;\n        }\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, irep->nregs);\n        pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);\n      }\n      else {\n        mrb_int acc;\n        mrb_value v;\n\n        ci = mrb->c->ci;\n        v = regs[a];\n        mrb_gc_protect(mrb, v);\n        switch (c) {\n        case OP_R_RETURN:\n          \/* Fall through to OP_R_NORMAL otherwise *\/\n          if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {\n            const struct RProc *dst;\n            mrb_callinfo *cibase;\n            cibase = mrb->c->cibase;\n            dst = top_proc(mrb, proc);\n\n            if (MRB_PROC_ENV_P(dst)) {\n              struct REnv *e = MRB_PROC_ENV(dst);\n\n              if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n            }\n            \/* check jump destination *\/\n            while (cibase <= ci && ci->proc != dst) {\n              if (ci->cci > CINFO_NONE) { \/* jump cross C boundary *\/\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n              ci--;\n            }\n            if (ci <= cibase) { \/* no jump destination *\/\n              localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n              goto L_RAISE;\n            }\n            ci = mrb->c->ci;\n            while (cibase <= ci && ci->proc != dst) {\n              CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {\n                cibase = mrb->c->cibase;\n                dst = top_proc(mrb, proc);\n              }\n              CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {\n                UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);\n              }\n              CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);\n              ci = cipop(mrb);\n              pc = ci->pc;\n            }\n            proc = ci->proc;\n            mrb->exc = NULL; \/* clear break object *\/\n            break;\n          }\n          \/* fallthrough *\/\n        case OP_R_NORMAL:\n        NORMAL_RETURN:\n          if (ci == mrb->c->cibase) {\n            struct mrb_context *c;\n            c = mrb->c;\n\n            if (!c->prev) { \/* toplevel return *\/\n              regs[irep->nlocals] = v;\n              goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);\n            }\n            if (!c->vmexec && c->prev->ci == c->prev->cibase) {\n              mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, \"double resume\");\n              mrb_exc_set(mrb, exc);\n              goto L_RAISE;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {\n              c = mrb->c;\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);\n            \/* automatic yield at the end *\/\n            c->status = MRB_FIBER_TERMINATED;\n            mrb->c = c->prev;\n            mrb->c->status = MRB_FIBER_RUNNING;\n            c->prev = NULL;\n            if (c->vmexec) {\n              mrb_gc_arena_restore(mrb, ai);\n              c->vmexec = FALSE;\n              mrb->jmp = prev_jmp;\n              return v;\n            }\n            ci = mrb->c->ci;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_RETURN);\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        case OP_R_BREAK:\n          if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;\n          if (MRB_PROC_ORPHAN_P(proc)) {\n            mrb_value exc;\n\n          L_BREAK_ERROR:\n            exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,\n                                      \"break from proc-closure\");\n            mrb_exc_set(mrb, exc);\n            goto L_RAISE;\n          }\n          if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {\n            goto L_BREAK_ERROR;\n          }\n          else {\n            struct REnv *e = MRB_PROC_ENV(proc);\n\n            if (e->cxt != mrb->c) {\n              goto L_BREAK_ERROR;\n            }\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK);\n          \/* break from fiber block *\/\n          if (ci == mrb->c->cibase && ci->pc) {\n            struct mrb_context *c = mrb->c;\n\n            mrb->c = c->prev;\n            c->prev = NULL;\n            ci = mrb->c->ci;\n          }\n          if (ci->cci > CINFO_NONE) {\n            ci = cipop(mrb);\n            mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);\n            mrb_gc_arena_restore(mrb, ai);\n            mrb->c->vmexec = FALSE;\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          if (FALSE) {\n            struct RBreak *brk;\n\n          L_BREAK:\n            brk = (struct RBreak*)mrb->exc;\n            proc = mrb_break_proc_get(brk);\n            v = mrb_break_value_get(brk);\n            ci = mrb->c->ci;\n\n            switch (mrb_break_tag_get(brk)) {\n#define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);\n              RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)\n#undef DISPATCH_CHECKPOINTS\n              default:\n                mrb_assert(!\"wrong break tag\");\n            }\n          }\n          while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {\n            if (ci[-1].cci == CINFO_SKIP) {\n              goto L_BREAK_ERROR;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {\n              \/* do nothing *\/\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);\n            ci = cipop(mrb);\n            pc = ci->pc;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);\n          if (ci == mrb->c->cibase) {\n            goto L_BREAK_ERROR;\n          }\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        default:\n          \/* cannot happen *\/\n          break;\n        }\n        mrb_assert(ci == mrb->c->ci);\n        mrb_assert(mrb->exc == NULL);\n\n        if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->c->vmexec = FALSE;\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        acc = ci->cci;\n        ci = cipop(mrb);\n        if (acc == CINFO_SKIP || acc == CINFO_DIRECT) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        pc = ci->pc;\n        DEBUG(fprintf(stderr, \"from :%s\\n\", mrb_sym_name(mrb, ci->mid)));\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n\n        ci[1].stack[0] = v;\n        mrb_gc_arena_restore(mrb, ai);\n      }\n      JUMP;\n    }\n\n    CASE(OP_BLKPUSH, BS) {\n      int m1 = (b>>11)&0x3f;\n      int r  = (b>>10)&0x1;\n      int m2 = (b>>5)&0x1f;\n      int kd = (b>>4)&0x1;\n      int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||\n            MRB_ENV_LEN(e) <= m1+r+m2+1) {\n          localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n          goto L_RAISE;\n        }\n        stack = e->stack + 1;\n      }\n      if (mrb_nil_p(stack[m1+r+m2+kd])) {\n        localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n        goto L_RAISE;\n      }\n      regs[a] = stack[m1+r+m2+kd];\n      NEXT;\n    }\n\n#if !defined(MRB_USE_BIGINT) || defined(MRB_INT32)\n  L_INT_OVERFLOW:\n    {\n      mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, \"integer overflow\");\n      mrb_exc_set(mrb, exc);\n    }\n    goto L_RAISE;\n#endif\n\n#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))\n#define OP_MATH(op_name)                                                    \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {                  \\\n    OP_MATH_CASE_INTEGER(op_name);                                          \\\n    OP_MATH_CASE_FLOAT(op_name, integer, float);                            \\\n    OP_MATH_CASE_FLOAT(op_name, float,  integer);                           \\\n    OP_MATH_CASE_FLOAT(op_name, float,  float);                             \\\n    OP_MATH_CASE_STRING_##op_name();                                        \\\n    default:                                                                \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATH_CASE_INTEGER(op_name)                                       \\\n  case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER):                              \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z;      \\\n      if (mrb_int_##op_name##_overflow(x, y, &z)) {                         \\\n        OP_MATH_OVERFLOW_INT(op_name,x,y);                                  \\\n      }                                                                     \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0\n#else\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2)                                     \\\n  case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2):                                \\\n    {                                                                           \\\n      mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                         \\\n    }                                                                           \\\n    break\n#endif\n#ifdef MRB_USE_BIGINT\n#define OP_MATH_OVERFLOW_INT(op,x,y) regs[a] = mrb_bint_##op##_ii(mrb,x,y)\n#else\n#define OP_MATH_OVERFLOW_INT(op,x,y) goto L_INT_OVERFLOW\n#endif\n#define OP_MATH_CASE_STRING_add()                                           \\\n  case TYPES2(MRB_TT_STRING, MRB_TT_STRING):                                \\\n    regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]);                        \\\n    mrb_gc_arena_restore(mrb, ai);                                          \\\n    break\n#define OP_MATH_CASE_STRING_sub() (void)0\n#define OP_MATH_CASE_STRING_mul() (void)0\n#define OP_MATH_OP_add +\n#define OP_MATH_OP_sub -\n#define OP_MATH_OP_mul *\n#define OP_MATH_TT_integer MRB_TT_INTEGER\n#define OP_MATH_TT_float   MRB_TT_FLOAT\n\n    CASE(OP_ADD, B) {\n      OP_MATH(add);\n    }\n\n    CASE(OP_SUB, B) {\n      OP_MATH(sub);\n    }\n\n    CASE(OP_MUL, B) {\n      OP_MATH(mul);\n    }\n\n    CASE(OP_DIV, B) {\n#ifndef MRB_NO_FLOAT\n      mrb_float x, y, f;\n#endif\n\n      \/* need to check if op is overridden *\/\n      switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\n        {\n          mrb_int x = mrb_integer(regs[a]);\n          mrb_int y = mrb_integer(regs[a+1]);\n          mrb_int div = mrb_div_int(mrb, x, y);\n          SET_INT_VALUE(mrb, regs[a], div);\n        }\n        NEXT;\n#ifndef MRB_NO_FLOAT\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\n        x = (mrb_float)mrb_integer(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\n        x = mrb_float(regs[a]);\n        y = (mrb_float)mrb_integer(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\n        x = mrb_float(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n#endif\n      default:\n        mid = MRB_OPSYM(div);\n        goto L_SEND_SYM;\n      }\n\n#ifndef MRB_NO_FLOAT\n      f = mrb_div_float(x, y);\n      SET_FLOAT_VALUE(mrb, regs[a], f);\n#endif\n      NEXT;\n    }\n\n#define OP_MATHI(op_name)                                                   \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (mrb_type(regs[a])) {                                              \\\n    OP_MATHI_CASE_INTEGER(op_name);                                         \\\n    OP_MATHI_CASE_FLOAT(op_name);                                           \\\n    default:                                                                \\\n      SET_INT_VALUE(mrb,regs[a+1], b);                                      \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATHI_CASE_INTEGER(op_name)                                      \\\n  case MRB_TT_INTEGER:                                                      \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z;                  \\\n      if (mrb_int_##op_name##_overflow(x, y, &z)) {                         \\\n        OP_MATH_OVERFLOW_INT(op_name,x,y);                                  \\\n      }                                                                     \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATHI_CASE_FLOAT(op_name) (void)0\n#else\n#define OP_MATHI_CASE_FLOAT(op_name)                                        \\\n  case MRB_TT_FLOAT:                                                        \\\n    {                                                                       \\\n      mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b;              \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                     \\\n    }                                                                       \\\n    break\n#endif\n\n    CASE(OP_ADDI, BB) {\n      OP_MATHI(add);\n    }\n\n    CASE(OP_SUBI, BB) {\n      OP_MATHI(sub);\n    }\n\n#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))\n\n#ifdef MRB_NO_FLOAT\n#define OP_CMP(op,sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#else\n#define OP_CMP(op, sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_float);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#endif\n\n    CASE(OP_EQ, B) {\n      if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {\n        SET_TRUE_VALUE(regs[a]);\n      }\n      else {\n        OP_CMP(==,eq);\n      }\n      NEXT;\n    }\n\n    CASE(OP_LT, B) {\n      OP_CMP(<,lt);\n      NEXT;\n    }\n\n    CASE(OP_LE, B) {\n      OP_CMP(<=,le);\n      NEXT;\n    }\n\n    CASE(OP_GT, B) {\n      OP_CMP(>,gt);\n      NEXT;\n    }\n\n    CASE(OP_GE, B) {\n      OP_CMP(>=,ge);\n      NEXT;\n    }\n\n    CASE(OP_ARRAY, BB) {\n      regs[a] = mrb_ary_new_from_values(mrb, b, ®s[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_ARRAY2, BBB) {\n      regs[a] = mrb_ary_new_from_values(mrb, c, ®s[b]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYCAT, B) {\n      mrb_value splat = mrb_ary_splat(mrb, regs[a+1]);\n      if (mrb_nil_p(regs[a])) {\n        regs[a] = splat;\n      }\n      else {\n        mrb_assert(mrb_array_p(regs[a]));\n        mrb_ary_concat(mrb, regs[a], splat);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYPUSH, BB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      for (mrb_int i=0; i<b; i++) {\n        mrb_ary_push(mrb, regs[a], regs[a+i+1]);\n      }\n      NEXT;\n    }\n\n    CASE(OP_ARYDUP, B) {\n      mrb_value ary = regs[a];\n      if (mrb_array_p(ary)) {\n        ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));\n      }\n      else {\n        ary = mrb_ary_new_from_values(mrb, 1, &ary);\n      }\n      regs[a] = ary;\n      NEXT;\n    }\n\n    CASE(OP_AREF, BBB) {\n      mrb_value v = regs[b];\n\n      if (!mrb_array_p(v)) {\n        if (c == 0) {\n          regs[a] = v;\n        }\n        else {\n          SET_NIL_VALUE(regs[a]);\n        }\n      }\n      else {\n        v = mrb_ary_ref(mrb, v, c);\n        regs[a] = v;\n      }\n      NEXT;\n    }\n\n    CASE(OP_ASET, BBB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      mrb_ary_set(mrb, regs[b], c, regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_APOST, BBB) {\n      mrb_value v = regs[a];\n      int pre  = b;\n      int post = c;\n      struct RArray *ary;\n      int len, idx;\n\n      if (!mrb_array_p(v)) {\n        v = mrb_ary_new_from_values(mrb, 1, ®s[a]);\n      }\n      ary = mrb_ary_ptr(v);\n      len = (int)ARY_LEN(ary);\n      if (len > pre + post) {\n        v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre);\n        regs[a++] = v;\n        while (post--) {\n          regs[a++] = ARY_PTR(ary)[len-post-1];\n        }\n      }\n      else {\n        v = mrb_ary_new_capa(mrb, 0);\n        regs[a++] = v;\n        for (idx=0; idx+pre<len; idx++) {\n          regs[a+idx] = ARY_PTR(ary)[pre+idx];\n        }\n        while (idx < post) {\n          SET_NIL_VALUE(regs[a+idx]);\n          idx++;\n        }\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_INTERN, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_sym sym = mrb_intern_str(mrb, regs[a]);\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_SYMBOL, BB) {\n      size_t len;\n      mrb_sym sym;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        sym = mrb_intern_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        sym  = mrb_intern(mrb, pool[b].u.str, len);\n      }\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_STRING, BB) {\n      mrb_int len;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        regs[a] = mrb_str_new(mrb, pool[b].u.str, len);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_STRCAT, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_str_concat(mrb, regs[a], regs[a+1]);\n      NEXT;\n    }\n\n    CASE(OP_HASH, BB) {\n      mrb_value hash = mrb_hash_new_capa(mrb, b);\n      int i;\n      int lim = a+b*2;\n\n      for (i=a; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      regs[a] = hash;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_HASHADD, BB) {\n      mrb_value hash;\n      int i;\n      int lim = a+b*2+1;\n\n      hash = regs[a];\n      mrb_ensure_hash_type(mrb, hash);\n      for (i=a+1; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_HASHCAT, B) {\n      mrb_value hash = regs[a];\n\n      mrb_assert(mrb_hash_p(hash));\n      mrb_hash_merge(mrb, hash, regs[a+1]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_LAMBDA, BB)\n    c = OP_L_LAMBDA;\n    L_MAKE_LAMBDA:\n    {\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      if (c & OP_L_CAPTURE) {\n        p = mrb_closure_new(mrb, nirep);\n      }\n      else {\n        p = mrb_proc_new(mrb, nirep);\n        p->flags |= MRB_PROC_SCOPE;\n      }\n      if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;\n      regs[a] = mrb_obj_value(p);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_BLOCK, BB) {\n      c = OP_L_BLOCK;\n      goto L_MAKE_LAMBDA;\n    }\n    CASE(OP_METHOD, BB) {\n      c = OP_L_METHOD;\n      goto L_MAKE_LAMBDA;\n    }\n\n    CASE(OP_RANGE_INC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_RANGE_EXC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], TRUE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_OCLASS, B) {\n      regs[a] = mrb_obj_value(mrb->object_class);\n      NEXT;\n    }\n\n    CASE(OP_CLASS, BB) {\n      struct RClass *c = 0, *baseclass;\n      mrb_value base, super;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      super = regs[a+1];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      c = mrb_vm_define_class(mrb, base, super, id);\n      regs[a] = mrb_obj_value(c);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_MODULE, BB) {\n      struct RClass *cls = 0, *baseclass;\n      mrb_value base;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      cls = mrb_vm_define_module(mrb, base, id);\n      regs[a] = mrb_obj_value(cls);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_EXEC, BB)\n    {\n      mrb_value recv = regs[a];\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      \/* prepare closure *\/\n      p = mrb_proc_new(mrb, nirep);\n      p->c = NULL;\n      mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc);\n      MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv));\n      p->flags |= MRB_PROC_SCOPE;\n\n      \/* prepare call stack *\/\n      cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0);\n\n      irep = p->body.irep;\n      pool = irep->pool;\n      syms = irep->syms;\n      mrb_stack_extend(mrb, irep->nregs);\n      stack_clear(regs+1, irep->nregs-1);\n      pc = irep->iseq;\n      JUMP;\n    }\n\n    CASE(OP_DEF, BB) {\n      struct RClass *target = mrb_class_ptr(regs[a]);\n      struct RProc *p = mrb_proc_ptr(regs[a+1]);\n      mrb_method_t m;\n      mrb_sym mid = syms[b];\n\n      MRB_METHOD_FROM_PROC(m, p);\n      mrb_define_method_raw(mrb, target, mid, m);\n      mrb_method_added(mrb, target, mid);\n      mrb_gc_arena_restore(mrb, ai);\n      regs[a] = mrb_symbol_value(mid);\n      NEXT;\n    }\n\n    CASE(OP_SCLASS, B) {\n      regs[a] = mrb_singleton_class(mrb, regs[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_TCLASS, B) {\n      struct RClass *target = check_target_class(mrb);\n      if (!target) goto L_RAISE;\n      regs[a] = mrb_obj_value(target);\n      NEXT;\n    }\n\n    CASE(OP_ALIAS, BB) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_alias_method(mrb, target, syms[a], syms[b]);\n      mrb_method_added(mrb, target, syms[a]);\n      NEXT;\n    }\n    CASE(OP_UNDEF, B) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_undef_method_id(mrb, target, syms[a]);\n      NEXT;\n    }\n\n    CASE(OP_DEBUG, Z) {\n      FETCH_BBB();\n#ifdef MRB_USE_DEBUG_HOOK\n      mrb->debug_op_hook(mrb, irep, pc, regs);\n#else\n#ifndef MRB_NO_STDIO\n      printf(\"OP_DEBUG %d %d %d\\n\", a, b, c);\n#else\n      abort();\n#endif\n#endif\n      NEXT;\n    }\n\n    CASE(OP_ERR, B) {\n      size_t len = pool[a].tt >> 2;\n      mrb_value exc;\n\n      mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);\n      exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);\n      mrb_exc_set(mrb, exc);\n      goto L_RAISE;\n    }\n\n    CASE(OP_EXT1, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT2, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT3, Z) {\n      uint8_t insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n\n    CASE(OP_STOP, Z) {\n      \/*        stop VM *\/\n      CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {\n        \/* do nothing *\/\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_STOP) {\n        UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());\n      }\n      CHECKPOINT_END(RBREAK_TAG_STOP);\n    L_STOP:\n      mrb->jmp = prev_jmp;\n      if (mrb->exc) {\n        mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);\n        return mrb_obj_value(mrb->exc);\n      }\n      return regs[irep->nlocals];\n    }\n  }\n  END_DISPATCH;\n#undef regs\n  }\n  MRB_CATCH(&c_jmp) {\n    mrb_callinfo *ci = mrb->c->ci;\n    while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) {\n      ci = cipop(mrb);\n    }\n    exc_catched = TRUE;\n    pc = ci->pc;\n    goto RETRY_TRY_BLOCK;\n  }\n  MRB_END_EXC(&c_jmp);\n}","target":1,"code_token_length":14672,"total_token_length":14908,"max_tokens_setting":28000}
+{"idx":224195,"func":"codegen(codegen_scope *s, node *tree, int val)\n{\n  int nt;\n  int rlev = s->rlev;\n\n  if (!tree) {\n    if (val) {\n      genop_1(s, OP_LOADNIL, cursp());\n      push();\n    }\n    return;\n  }\n\n  s->rlev++;\n  if (s->rlev > MRB_CODEGEN_LEVEL_MAX) {\n    codegen_error(s, \"too complex expression\");\n  }\n  if (s->irep && s->filename_index != tree->filename_index) {\n    mrb_sym fname = mrb_parser_get_filename(s->parser, s->filename_index);\n    const char *filename = mrb_sym_name_len(s->mrb, fname, NULL);\n\n    mrb_debug_info_append_file(s->mrb, s->irep->debug_info,\n                               filename, s->lines, s->debug_start_pos, s->pc);\n    s->debug_start_pos = s->pc;\n    s->filename_index = tree->filename_index;\n    s->filename_sym = mrb_parser_get_filename(s->parser, tree->filename_index);\n  }\n\n  nt = nint(tree->car);\n  s->lineno = tree->lineno;\n  tree = tree->cdr;\n  switch (nt) {\n  case NODE_BEGIN:\n    if (val && !tree) {\n      genop_1(s, OP_LOADNIL, cursp());\n      push();\n    }\n    while (tree) {\n      codegen(s, tree->car, tree->cdr ? NOVAL : val);\n      tree = tree->cdr;\n    }\n    break;\n\n  case NODE_RESCUE:\n    {\n      int noexc;\n      uint32_t exend, pos1, pos2, tmp;\n      struct loopinfo *lp;\n      int catch_entry, begin, end;\n\n      if (tree->car == NULL) goto exit;\n      lp = loop_push(s, LOOP_BEGIN);\n      lp->pc0 = new_label(s);\n      catch_entry = catch_handler_new(s);\n      begin = s->pc;\n      codegen(s, tree->car, VAL);\n      pop();\n      lp->type = LOOP_RESCUE;\n      end = s->pc;\n      noexc = genjmp_0(s, OP_JMP);\n      catch_handler_set(s, catch_entry, MRB_CATCH_RESCUE, begin, end, s->pc);\n      tree = tree->cdr;\n      exend = JMPLINK_START;\n      pos1 = JMPLINK_START;\n      if (tree->car) {\n        node *n2 = tree->car;\n        int exc = cursp();\n\n        genop_1(s, OP_EXCEPT, exc);\n        push();\n        while (n2) {\n          node *n3 = n2->car;\n          node *n4 = n3->car;\n\n          dispatch(s, pos1);\n          pos2 = JMPLINK_START;\n          do {\n            if (n4 && n4->car && nint(n4->car->car) == NODE_SPLAT) {\n              codegen(s, n4->car, VAL);\n              gen_move(s, cursp(), exc, 0);\n              push_n(2); pop_n(2); \/* space for one arg and a block *\/\n              pop();\n              genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM_2(s->mrb, __case_eqq)), 1);\n            }\n            else {\n              if (n4) {\n                codegen(s, n4->car, VAL);\n              }\n              else {\n                genop_2(s, OP_GETCONST, cursp(), new_sym(s, MRB_SYM_2(s->mrb, StandardError)));\n                push();\n              }\n              pop();\n              genop_2(s, OP_RESCUE, exc, cursp());\n            }\n            tmp = genjmp2(s, OP_JMPIF, cursp(), pos2, val);\n            pos2 = tmp;\n            if (n4) {\n              n4 = n4->cdr;\n            }\n          } while (n4);\n          pos1 = genjmp_0(s, OP_JMP);\n          dispatch_linked(s, pos2);\n\n          pop();\n          if (n3->cdr->car) {\n            gen_assignment(s, n3->cdr->car, NULL, exc, NOVAL);\n          }\n          if (n3->cdr->cdr->car) {\n            codegen(s, n3->cdr->cdr->car, val);\n            if (val) pop();\n          }\n          tmp = genjmp(s, OP_JMP, exend);\n          exend = tmp;\n          n2 = n2->cdr;\n          push();\n        }\n        if (pos1 != JMPLINK_START) {\n          dispatch(s, pos1);\n          genop_1(s, OP_RAISEIF, exc);\n        }\n      }\n      pop();\n      tree = tree->cdr;\n      dispatch(s, noexc);\n      if (tree->car) {\n        codegen(s, tree->car, val);\n      }\n      else if (val) {\n        push();\n      }\n      dispatch_linked(s, exend);\n      loop_pop(s, NOVAL);\n    }\n    break;\n\n  case NODE_ENSURE:\n    if (!tree->cdr || !tree->cdr->cdr ||\n        (nint(tree->cdr->cdr->car) == NODE_BEGIN &&\n         tree->cdr->cdr->cdr)) {\n      int catch_entry, begin, end, target;\n      int idx;\n\n      catch_entry = catch_handler_new(s);\n      begin = s->pc;\n      codegen(s, tree->car, val);\n      end = target = s->pc;\n      push();\n      idx = cursp();\n      genop_1(s, OP_EXCEPT, idx);\n      push();\n      codegen(s, tree->cdr->cdr, NOVAL);\n      pop();\n      genop_1(s, OP_RAISEIF, idx);\n      pop();\n      catch_handler_set(s, catch_entry, MRB_CATCH_ENSURE, begin, end, target);\n    }\n    else {                      \/* empty ensure ignored *\/\n      codegen(s, tree->car, val);\n    }\n    break;\n\n  case NODE_LAMBDA:\n    if (val) {\n      int idx = lambda_body(s, tree, 1);\n\n      genop_2(s, OP_LAMBDA, cursp(), idx);\n      push();\n    }\n    break;\n\n  case NODE_BLOCK:\n    if (val) {\n      int idx = lambda_body(s, tree, 1);\n\n      genop_2(s, OP_BLOCK, cursp(), idx);\n      push();\n    }\n    break;\n\n  case NODE_IF:\n    {\n      uint32_t pos1, pos2;\n      mrb_bool nil_p = FALSE;\n      node *elsepart = tree->cdr->cdr->car;\n\n      if (!tree->car) {\n        codegen(s, elsepart, val);\n        goto exit;\n      }\n      if (true_always(tree->car)) {\n        codegen(s, tree->cdr->car, val);\n        goto exit;\n      }\n      if (false_always(tree->car)) {\n        codegen(s, elsepart, val);\n        goto exit;\n      }\n      if (nint(tree->car->car) == NODE_CALL) {\n        node *n = tree->car->cdr;\n        mrb_sym mid = nsym(n->cdr->car);\n        mrb_sym sym_nil_p = MRB_SYM_Q_2(s->mrb, nil);\n        if (mid == sym_nil_p && n->cdr->cdr->car == NULL) {\n          nil_p = TRUE;\n          codegen(s, n->car, VAL);\n        }\n      }\n      if (!nil_p) {\n        codegen(s, tree->car, VAL);\n      }\n      pop();\n      if (val || tree->cdr->car) {\n        if (nil_p) {\n          pos2 = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n          pos1 = genjmp_0(s, OP_JMP);\n          dispatch(s, pos2);\n        }\n        else {\n          pos1 = genjmp2_0(s, OP_JMPNOT, cursp(), val);\n        }\n        codegen(s, tree->cdr->car, val);\n        if (val) pop();\n        if (elsepart || val) {\n          pos2 = genjmp_0(s, OP_JMP);\n          dispatch(s, pos1);\n          codegen(s, elsepart, val);\n          dispatch(s, pos2);\n        }\n        else {\n          dispatch(s, pos1);\n        }\n      }\n      else {                    \/* empty then-part *\/\n        if (elsepart) {\n          if (nil_p) {\n            pos1 = genjmp2_0(s, OP_JMPNIL, cursp(), val);\n          }\n          else {\n            pos1 = genjmp2_0(s, OP_JMPIF, cursp(), val);\n          }\n          codegen(s, elsepart, val);\n          dispatch(s, pos1);\n        }\n        else if (val && !nil_p) {\n          genop_1(s, OP_LOADNIL, cursp());\n          push();\n        }\n      }\n    }\n    break;\n\n  case NODE_AND:\n    {\n      uint32_t pos;\n\n      if (true_always(tree->car)) {\n        codegen(s, tree->cdr, val);\n        goto exit;\n      }\n      if (false_always(tree->car)) {\n        codegen(s, tree->car, val);\n        goto exit;\n      }\n      codegen(s, tree->car, VAL);\n      pop();\n      pos = genjmp2_0(s, OP_JMPNOT, cursp(), val);\n      codegen(s, tree->cdr, val);\n      dispatch(s, pos);\n    }\n    break;\n\n  case NODE_OR:\n    {\n      uint32_t pos;\n\n      if (true_always(tree->car)) {\n        codegen(s, tree->car, val);\n        goto exit;\n      }\n      if (false_always(tree->car)) {\n        codegen(s, tree->cdr, val);\n        goto exit;\n      }\n      codegen(s, tree->car, VAL);\n      pop();\n      pos = genjmp2_0(s, OP_JMPIF, cursp(), val);\n      codegen(s, tree->cdr, val);\n      dispatch(s, pos);\n    }\n    break;\n\n  case NODE_WHILE:\n  case NODE_UNTIL:\n    {\n      if (true_always(tree->car)) {\n        if (nt == NODE_UNTIL) {\n          if (val) {\n            genop_1(s, OP_LOADNIL, cursp());\n            push();\n          }\n          goto exit;\n        }\n      }\n      else if (false_always(tree->car)) {\n        if (nt == NODE_WHILE) {\n          if (val) {\n            genop_1(s, OP_LOADNIL, cursp());\n            push();\n          }\n          goto exit;\n        }\n      }\n\n      uint32_t pos = JMPLINK_START;\n      struct loopinfo *lp = loop_push(s, LOOP_NORMAL);\n\n      if (!val) lp->reg = -1;\n      lp->pc0 = new_label(s);\n      codegen(s, tree->car, VAL);\n      pop();\n      if (nt == NODE_WHILE) {\n        pos = genjmp2_0(s, OP_JMPNOT, cursp(), NOVAL);\n      }\n      else {\n        pos = genjmp2_0(s, OP_JMPIF, cursp(), NOVAL);\n      }\n      lp->pc1 = new_label(s);\n      codegen(s, tree->cdr, NOVAL);\n      genjmp(s, OP_JMP, lp->pc0);\n      dispatch(s, pos);\n      loop_pop(s, val);\n    }\n    break;\n\n  case NODE_FOR:\n    for_body(s, tree);\n    if (val) push();\n    break;\n\n  case NODE_CASE:\n    {\n      int head = 0;\n      uint32_t pos1, pos2, pos3, tmp;\n      node *n;\n\n      pos3 = JMPLINK_START;\n      if (tree->car) {\n        head = cursp();\n        codegen(s, tree->car, VAL);\n      }\n      tree = tree->cdr;\n      while (tree) {\n        n = tree->car->car;\n        pos1 = pos2 = JMPLINK_START;\n        while (n) {\n          codegen(s, n->car, VAL);\n          if (head) {\n            gen_move(s, cursp(), head, 0);\n            push(); push(); pop(); pop(); pop();\n            if (nint(n->car->car) == NODE_SPLAT) {\n              genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM_2(s->mrb, __case_eqq)), 1);\n            }\n            else {\n              genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_OPSYM_2(s->mrb, eqq)), 1);\n            }\n          }\n          else {\n            pop();\n          }\n          tmp = genjmp2(s, OP_JMPIF, cursp(), pos2, NOVAL);\n          pos2 = tmp;\n          n = n->cdr;\n        }\n        if (tree->car->car) {\n          pos1 = genjmp_0(s, OP_JMP);\n          dispatch_linked(s, pos2);\n        }\n        codegen(s, tree->car->cdr, val);\n        if (val) pop();\n        tmp = genjmp(s, OP_JMP, pos3);\n        pos3 = tmp;\n        dispatch(s, pos1);\n        tree = tree->cdr;\n      }\n      if (val) {\n        uint32_t pos = cursp();\n        genop_1(s, OP_LOADNIL, cursp());\n        if (pos3 != JMPLINK_START) dispatch_linked(s, pos3);\n        if (head) pop();\n        if (cursp() != pos) {\n          gen_move(s, cursp(), pos, 0);\n        }\n        push();\n      }\n      else {\n        if (pos3 != JMPLINK_START) {\n          dispatch_linked(s, pos3);\n        }\n        if (head) {\n          pop();\n        }\n      }\n    }\n    break;\n\n  case NODE_SCOPE:\n    scope_body(s, tree, NOVAL);\n    break;\n\n  case NODE_FCALL:\n  case NODE_CALL:\n    gen_call(s, tree, val, 0);\n    break;\n  case NODE_SCALL:\n    gen_call(s, tree, val, 1);\n    break;\n\n  case NODE_DOT2:\n    codegen(s, tree->car, val);\n    codegen(s, tree->cdr, val);\n    if (val) {\n      pop(); pop();\n      genop_1(s, OP_RANGE_INC, cursp());\n      push();\n    }\n    break;\n\n  case NODE_DOT3:\n    codegen(s, tree->car, val);\n    codegen(s, tree->cdr, val);\n    if (val) {\n      pop(); pop();\n      genop_1(s, OP_RANGE_EXC, cursp());\n      push();\n    }\n    break;\n\n  case NODE_COLON2:\n    {\n      int sym = new_sym(s, nsym(tree->cdr));\n\n      codegen(s, tree->car, VAL);\n      pop();\n      genop_2(s, OP_GETMCNST, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_COLON3:\n    {\n      int sym = new_sym(s, nsym(tree));\n\n      genop_1(s, OP_OCLASS, cursp());\n      genop_2(s, OP_GETMCNST, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_ARRAY:\n    {\n      int n;\n\n      n = gen_values(s, tree, val, 0);\n      if (val) {\n        if (n >= 0) {\n          pop_n(n);\n          genop_2(s, OP_ARRAY, cursp(), n);\n        }\n        push();\n      }\n    }\n    break;\n\n  case NODE_HASH:\n  case NODE_KW_HASH:\n    {\n      int nk = gen_hash(s, tree, val, GEN_LIT_ARY_MAX);\n      if (val && nk >= 0) {\n        pop_n(nk*2);\n        genop_2(s, OP_HASH, cursp(), nk);\n        push();\n      }\n    }\n    break;\n\n  case NODE_SPLAT:\n    codegen(s, tree, val);\n    break;\n\n  case NODE_ASGN:\n    gen_assignment(s, tree->car, tree->cdr, 0, val);\n    break;\n\n  case NODE_MASGN:\n    {\n      int len = 0, n = 0, post = 0;\n      node *t = tree->cdr, *p;\n      int rhs = cursp();\n\n      if (nint(t->car) == NODE_ARRAY && t->cdr && nosplat(t->cdr)) {\n        \/* fixed rhs *\/\n        t = t->cdr;\n        while (t) {\n          codegen(s, t->car, VAL);\n          len++;\n          t = t->cdr;\n        }\n        tree = tree->car;\n        if (tree->car) {                \/* pre *\/\n          t = tree->car;\n          n = 0;\n          while (t) {\n            if (n < len) {\n              gen_assignment(s, t->car, NULL, rhs+n, NOVAL);\n              n++;\n            }\n            else {\n              genop_1(s, OP_LOADNIL, rhs+n);\n              gen_assignment(s, t->car, NULL, rhs+n, NOVAL);\n            }\n            t = t->cdr;\n          }\n        }\n        t = tree->cdr;\n        if (t) {\n          if (t->cdr) {         \/* post count *\/\n            p = t->cdr->car;\n            while (p) {\n              post++;\n              p = p->cdr;\n            }\n          }\n          if (t->car) {         \/* rest (len - pre - post) *\/\n            int rn;\n\n            if (len < post + n) {\n              rn = 0;\n            }\n            else {\n              rn = len - post - n;\n            }\n            if (cursp() == rhs+n) {\n              genop_2(s, OP_ARRAY, cursp(), rn);\n            }\n            else {\n              genop_3(s, OP_ARRAY2, cursp(), rhs+n, rn);\n            }\n            gen_assignment(s, t->car, NULL, cursp(), NOVAL);\n            n += rn;\n          }\n          if (t->cdr && t->cdr->car) {\n            t = t->cdr->car;\n            while (t) {\n              if (n<len) {\n                gen_assignment(s, t->car, NULL, rhs+n, NOVAL);\n              }\n              else {\n                genop_1(s, OP_LOADNIL, cursp());\n                gen_assignment(s, t->car, NULL, cursp(), NOVAL);\n              }\n              t = t->cdr;\n              n++;\n            }\n          }\n        }\n        pop_n(len);\n        if (val) {\n          genop_2(s, OP_ARRAY, rhs, len);\n          push();\n        }\n      }\n      else {\n        \/* variable rhs *\/\n        codegen(s, t, VAL);\n        gen_massignment(s, tree->car, rhs, val);\n        if (!val) {\n          pop();\n        }\n      }\n    }\n    break;\n\n  case NODE_OP_ASGN:\n    {\n      mrb_sym sym = nsym(tree->cdr->car);\n      mrb_int len;\n      const char *name = mrb_sym_name_len(s->mrb, sym, &len);\n      int idx, callargs = -1, vsp = -1;\n\n      if ((len == 2 && name[0] == '|' && name[1] == '|') &&\n          (nint(tree->car->car) == NODE_CONST ||\n           nint(tree->car->car) == NODE_CVAR)) {\n        int catch_entry, begin, end;\n        int noexc, exc;\n        struct loopinfo *lp;\n\n        lp = loop_push(s, LOOP_BEGIN);\n        lp->pc0 = new_label(s);\n        catch_entry = catch_handler_new(s);\n        begin = s->pc;\n        exc = cursp();\n        codegen(s, tree->car, VAL);\n        end = s->pc;\n        noexc = genjmp_0(s, OP_JMP);\n        lp->type = LOOP_RESCUE;\n        catch_handler_set(s, catch_entry, MRB_CATCH_RESCUE, begin, end, s->pc);\n        genop_1(s, OP_EXCEPT, exc);\n        genop_1(s, OP_LOADF, exc);\n        dispatch(s, noexc);\n        loop_pop(s, NOVAL);\n      }\n      else if (nint(tree->car->car) == NODE_CALL) {\n        node *n = tree->car->cdr;\n        int base, i, nargs = 0;\n        callargs = 0;\n\n        if (val) {\n          vsp = cursp();\n          push();\n        }\n        codegen(s, n->car, VAL);   \/* receiver *\/\n        idx = new_sym(s, nsym(n->cdr->car));\n        base = cursp()-1;\n        if (n->cdr->cdr->car) {\n          nargs = gen_values(s, n->cdr->cdr->car->car, VAL, 13);\n          if (nargs >= 0) {\n            callargs = nargs;\n          }\n          else { \/* varargs *\/\n            push();\n            nargs = 1;\n            callargs = CALL_MAXARGS;\n          }\n        }\n        \/* copy receiver and arguments *\/\n        gen_move(s, cursp(), base, 1);\n        for (i=0; i<nargs; i++) {\n          gen_move(s, cursp()+i+1, base+i+1, 1);\n        }\n        push_n(nargs+2);pop_n(nargs+2); \/* space for receiver, arguments and a block *\/\n        genop_3(s, OP_SEND, cursp(), idx, callargs);\n        push();\n      }\n      else {\n        codegen(s, tree->car, VAL);\n      }\n      if (len == 2 &&\n          ((name[0] == '|' && name[1] == '|') ||\n           (name[0] == '&' && name[1] == '&'))) {\n        uint32_t pos;\n\n        pop();\n        if (val) {\n          if (vsp >= 0) {\n            gen_move(s, vsp, cursp(), 1);\n          }\n          pos = genjmp2_0(s, name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), val);\n        }\n        else {\n          pos = genjmp2_0(s, name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), val);\n        }\n        codegen(s, tree->cdr->cdr->car, VAL);\n        pop();\n        if (val && vsp >= 0) {\n          gen_move(s, vsp, cursp(), 1);\n        }\n        if (nint(tree->car->car) == NODE_CALL) {\n          if (callargs == CALL_MAXARGS) {\n            pop();\n            genop_2(s, OP_ARYPUSH, cursp(), 1);\n          }\n          else {\n            pop_n(callargs);\n            callargs++;\n          }\n          pop();\n          idx = new_sym(s, attrsym(s, nsym(tree->car->cdr->cdr->car)));\n          genop_3(s, OP_SEND, cursp(), idx, callargs);\n        }\n        else {\n          gen_assignment(s, tree->car, NULL, cursp(), val);\n        }\n        dispatch(s, pos);\n        goto exit;\n      }\n      codegen(s, tree->cdr->cdr->car, VAL);\n      push(); pop();\n      pop(); pop();\n\n      if (len == 1 && name[0] == '+')  {\n        gen_addsub(s, OP_ADD, cursp());\n      }\n      else if (len == 1 && name[0] == '-')  {\n        gen_addsub(s, OP_SUB, cursp());\n      }\n      else if (len == 1 && name[0] == '*')  {\n        genop_1(s, OP_MUL, cursp());\n      }\n      else if (len == 1 && name[0] == '\/')  {\n        genop_1(s, OP_DIV, cursp());\n      }\n      else if (len == 1 && name[0] == '<')  {\n        genop_1(s, OP_LT, cursp());\n      }\n      else if (len == 2 && name[0] == '<' && name[1] == '=')  {\n        genop_1(s, OP_LE, cursp());\n      }\n      else if (len == 1 && name[0] == '>')  {\n        genop_1(s, OP_GT, cursp());\n      }\n      else if (len == 2 && name[0] == '>' && name[1] == '=')  {\n        genop_1(s, OP_GE, cursp());\n      }\n      else {\n        idx = new_sym(s, sym);\n        genop_3(s, OP_SEND, cursp(), idx, 1);\n      }\n      if (callargs < 0) {\n        gen_assignment(s, tree->car, NULL, cursp(), val);\n      }\n      else {\n        if (val && vsp >= 0) {\n          gen_move(s, vsp, cursp(), 0);\n        }\n        if (callargs == CALL_MAXARGS) {\n          pop();\n          genop_2(s, OP_ARYPUSH, cursp(), 1);\n        }\n        else {\n          pop_n(callargs);\n          callargs++;\n        }\n        pop();\n        idx = new_sym(s, attrsym(s,nsym(tree->car->cdr->cdr->car)));\n        genop_3(s, OP_SEND, cursp(), idx, callargs);\n      }\n    }\n    break;\n\n  case NODE_SUPER:\n    {\n      codegen_scope *s2 = s;\n      int lv = 0;\n      int n = 0, nk = 0, st = 0;\n\n      push();\n      while (!s2->mscope) {\n        lv++;\n        s2 = s2->prev;\n        if (!s2) break;\n      }\n      if (tree) {\n        node *args = tree->car;\n        if (args) {\n          st = n = gen_values(s, args, VAL, 14);\n          if (n < 0) {\n            st = 1; n = 15;\n            push();\n          }\n        }\n        \/* keyword arguments *\/\n        if (tree->cdr->car) {\n          nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14);\n          if (nk < 0) {st++; nk = 15;}\n          else st += nk*2;\n          n |= nk<<4;\n        }\n        \/* block arguments *\/\n        if (tree->cdr->cdr) {\n          codegen(s, tree->cdr->cdr, VAL);\n        }\n        else if (s2) gen_blkmove(s, s2->ainfo, lv);\n        else {\n          genop_1(s, OP_LOADNIL, cursp());\n          push();\n        }\n      }\n      else {\n        if (s2) gen_blkmove(s, s2->ainfo, lv);\n        else {\n          genop_1(s, OP_LOADNIL, cursp());\n          push();\n        }\n      }\n      st++;\n      pop_n(st+1);\n      genop_2(s, OP_SUPER, cursp(), n);\n      if (val) push();\n    }\n    break;\n\n  case NODE_ZSUPER:\n    {\n      codegen_scope *s2 = s;\n      int lv = 0;\n      uint16_t ainfo = 0;\n      int n = CALL_MAXARGS;\n      int sp = cursp();\n\n      push();        \/* room for receiver *\/\n      while (!s2->mscope) {\n        lv++;\n        s2 = s2->prev;\n        if (!s2) break;\n      }\n      if (s2 && s2->ainfo > 0) {\n        ainfo = s2->ainfo;\n      }\n      if (ainfo > 0) {\n        genop_2S(s, OP_ARGARY, cursp(), (ainfo<<4)|(lv & 0xf));\n        push(); push(); push();   \/* ARGARY pushes 3 values at most *\/\n        pop(); pop(); pop();\n        \/* keyword arguments *\/\n        if (ainfo & 0x1) {\n          n |= CALL_MAXARGS<<4;\n          push();\n        }\n        \/* block argument *\/\n        if (tree && tree->cdr && tree->cdr->cdr) {\n          push();\n          codegen(s, tree->cdr->cdr, VAL);\n        }\n      }\n      else {\n        \/* block argument *\/\n        if (tree && tree->cdr && tree->cdr->cdr) {\n          codegen(s, tree->cdr->cdr, VAL);\n        }\n        else {\n          gen_blkmove(s, 0, lv);\n        }\n        n = 0;\n      }\n      s->sp = sp;\n      genop_2(s, OP_SUPER, cursp(), n);\n      if (val) push();\n    }\n    break;\n\n  case NODE_RETURN:\n    if (tree) {\n      gen_retval(s, tree);\n    }\n    else {\n      genop_1(s, OP_LOADNIL, cursp());\n    }\n    if (s->loop) {\n      gen_return(s, OP_RETURN_BLK, cursp());\n    }\n    else {\n      gen_return(s, OP_RETURN, cursp());\n    }\n    if (val) push();\n    break;\n\n  case NODE_YIELD:\n    {\n      codegen_scope *s2 = s;\n      int lv = 0, ainfo = -1;\n      int n = 0, sendv = 0;\n\n      while (!s2->mscope) {\n        lv++;\n        s2 = s2->prev;\n        if (!s2) break;\n      }\n      if (s2) {\n        ainfo = (int)s2->ainfo;\n      }\n      if (ainfo < 0) codegen_error(s, \"invalid yield (SyntaxError)\");\n      push();\n      if (tree) {\n        n = gen_values(s, tree, VAL, 14);\n        if (n < 0) {\n          n = sendv = 1;\n          push();\n        }\n      }\n      push();pop(); \/* space for a block *\/\n      pop_n(n+1);\n      genop_2S(s, OP_BLKPUSH, cursp(), (ainfo<<4)|(lv & 0xf));\n      if (sendv) n = CALL_MAXARGS;\n      genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM_2(s->mrb, call)), n);\n      if (val) push();\n    }\n    break;\n\n  case NODE_BREAK:\n    loop_break(s, tree);\n    if (val) push();\n    break;\n\n  case NODE_NEXT:\n    if (!s->loop) {\n      raise_error(s, \"unexpected next\");\n    }\n    else if (s->loop->type == LOOP_NORMAL) {\n      codegen(s, tree, NOVAL);\n      genjmp(s, OP_JMPUW, s->loop->pc0);\n    }\n    else {\n      if (tree) {\n        codegen(s, tree, VAL);\n        pop();\n      }\n      else {\n        genop_1(s, OP_LOADNIL, cursp());\n      }\n      gen_return(s, OP_RETURN, cursp());\n    }\n    if (val) push();\n    break;\n\n  case NODE_REDO:\n    if (!s->loop || s->loop->type == LOOP_BEGIN || s->loop->type == LOOP_RESCUE) {\n      raise_error(s, \"unexpected redo\");\n    }\n    else {\n      genjmp(s, OP_JMPUW, s->loop->pc1);\n    }\n    if (val) push();\n    break;\n\n  case NODE_RETRY:\n    {\n      const char *msg = \"unexpected retry\";\n      const struct loopinfo *lp = s->loop;\n\n      while (lp && lp->type != LOOP_RESCUE) {\n        lp = lp->prev;\n      }\n      if (!lp) {\n        raise_error(s, msg);\n      }\n      else {\n        genjmp(s, OP_JMPUW, lp->pc0);\n      }\n      if (val) push();\n    }\n    break;\n\n  case NODE_LVAR:\n    if (val) {\n      int idx = lv_idx(s, nsym(tree));\n\n      if (idx > 0) {\n        gen_move(s, cursp(), idx, val);\n      }\n      else {\n        gen_getupvar(s, cursp(), nsym(tree));\n      }\n      push();\n    }\n    break;\n\n  case NODE_NVAR:\n    if (val) {\n      int idx = nint(tree);\n\n      gen_move(s, cursp(), idx, val);\n\n      push();\n    }\n    break;\n\n  case NODE_GVAR:\n    {\n      int sym = new_sym(s, nsym(tree));\n\n      genop_2(s, OP_GETGV, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_IVAR:\n    {\n      int sym = new_sym(s, nsym(tree));\n\n      genop_2(s, OP_GETIV, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_CVAR:\n    {\n      int sym = new_sym(s, nsym(tree));\n\n      genop_2(s, OP_GETCV, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_CONST:\n    {\n      int sym = new_sym(s, nsym(tree));\n\n      genop_2(s, OP_GETCONST, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_BACK_REF:\n    if (val) {\n      char buf[] = {'$', nchar(tree)};\n      int sym = new_sym(s, mrb_intern(s->mrb, buf, sizeof(buf)));\n\n      genop_2(s, OP_GETGV, cursp(), sym);\n      push();\n    }\n    break;\n\n  case NODE_NTH_REF:\n    if (val) {\n      mrb_state *mrb = s->mrb;\n      mrb_value str;\n      int sym;\n\n      str = mrb_format(mrb, \"$%d\", nint(tree));\n      sym = new_sym(s, mrb_intern_str(mrb, str));\n      genop_2(s, OP_GETGV, cursp(), sym);\n      push();\n    }\n    break;\n\n  case NODE_ARG:\n    \/* should not happen *\/\n    break;\n\n  case NODE_BLOCK_ARG:\n    if (!tree) {\n      int idx = lv_idx(s, MRB_OPSYM_2(s->mrb, and));\n\n      if (idx == 0) {\n        codegen_error(s, \"no anonymous block argument\");\n      }\n      gen_move(s, cursp(), idx, val);\n      if (val) push();\n    }\n    else {\n      codegen(s, tree, val);\n    }\n    break;\n\n  case NODE_INT:\n    if (val) {\n      char *p = (char*)tree->car;\n      int base = nint(tree->cdr->car);\n      mrb_int i;\n      mrb_bool overflow;\n\n      i = readint(s, p, base, FALSE, &overflow);\n      if (overflow) {\n        int off = new_litbn(s, p, base, FALSE);\n        genop_2(s, OP_LOADL, cursp(), off);\n      }\n      else {\n        gen_int(s, cursp(), i);\n      }\n      push();\n    }\n    break;\n\n#ifndef MRB_NO_FLOAT\n  case NODE_FLOAT:\n    if (val) {\n      char *p = (char*)tree;\n      mrb_float f = mrb_float_read(p, NULL);\n      int off = new_lit(s, mrb_float_value(s->mrb, f));\n\n      genop_2(s, OP_LOADL, cursp(), off);\n      push();\n    }\n    break;\n#endif\n\n  case NODE_NEGATE:\n    {\n      nt = nint(tree->car);\n      switch (nt) {\n#ifndef MRB_NO_FLOAT\n      case NODE_FLOAT:\n        if (val) {\n          char *p = (char*)tree->cdr;\n          mrb_float f = mrb_float_read(p, NULL);\n          int off = new_lit(s, mrb_float_value(s->mrb, -f));\n\n          genop_2(s, OP_LOADL, cursp(), off);\n          push();\n        }\n        break;\n#endif\n\n      case NODE_INT:\n        if (val) {\n          char *p = (char*)tree->cdr->car;\n          int base = nint(tree->cdr->cdr->car);\n          mrb_int i;\n          mrb_bool overflow;\n\n          i = readint(s, p, base, TRUE, &overflow);\n          if (overflow) {\n            int off = new_litbn(s, p, base, TRUE);\n            genop_2(s, OP_LOADL, cursp(), off);\n          }\n          else {\n            gen_int(s, cursp(), i);\n          }\n          push();\n        }\n        break;\n\n      default:\n        if (val) {\n          codegen(s, tree, VAL);\n          pop();\n          push_n(2);pop_n(2); \/* space for receiver&block *\/\n          mrb_sym minus = MRB_OPSYM_2(s->mrb, minus);\n          if (!gen_uniop(s, minus, cursp())) {\n            genop_3(s, OP_SEND, cursp(), new_sym(s, minus), 0);\n          }\n          push();\n        }\n        else {\n          codegen(s, tree, NOVAL);\n        }\n        break;\n      }\n    }\n    break;\n\n  case NODE_STR:\n    if (val) {\n      char *p = (char*)tree->car;\n      mrb_int len = nint(tree->cdr);\n      int ai = mrb_gc_arena_save(s->mrb);\n      int off = new_lit(s, mrb_str_new(s->mrb, p, len));\n\n      mrb_gc_arena_restore(s->mrb, ai);\n      genop_2(s, OP_STRING, cursp(), off);\n      push();\n    }\n    break;\n\n  case NODE_HEREDOC:\n    tree = ((struct mrb_parser_heredoc_info *)tree)->doc;\n    \/* fall through *\/\n  case NODE_DSTR:\n    if (val) {\n      node *n = tree;\n\n      if (!n) {\n        genop_1(s, OP_LOADNIL, cursp());\n        push();\n        break;\n      }\n      codegen(s, n->car, VAL);\n      n = n->cdr;\n      while (n) {\n        codegen(s, n->car, VAL);\n        pop(); pop();\n        genop_1(s, OP_STRCAT, cursp());\n        push();\n        n = n->cdr;\n      }\n    }\n    else {\n      node *n = tree;\n\n      while (n) {\n        if (nint(n->car->car) != NODE_STR) {\n          codegen(s, n->car, NOVAL);\n        }\n        n = n->cdr;\n      }\n    }\n    break;\n\n  case NODE_WORDS:\n    gen_literal_array(s, tree, FALSE, val);\n    break;\n\n  case NODE_SYMBOLS:\n    gen_literal_array(s, tree, TRUE, val);\n    break;\n\n  case NODE_DXSTR:\n    {\n      node *n;\n      int ai = mrb_gc_arena_save(s->mrb);\n      int sym = new_sym(s, MRB_SYM_2(s->mrb, Kernel));\n\n      genop_1(s, OP_LOADSELF, cursp());\n      push();\n      codegen(s, tree->car, VAL);\n      n = tree->cdr;\n      while (n) {\n        if (nint(n->car->car) == NODE_XSTR) {\n          n->car->car = (struct mrb_ast_node*)(intptr_t)NODE_STR;\n          mrb_assert(!n->cdr); \/* must be the end *\/\n        }\n        codegen(s, n->car, VAL);\n        pop(); pop();\n        genop_1(s, OP_STRCAT, cursp());\n        push();\n        n = n->cdr;\n      }\n      push();                   \/* for block *\/\n      pop_n(3);\n      sym = new_sym(s, MRB_OPSYM_2(s->mrb, tick)); \/* ` *\/\n      genop_3(s, OP_SEND, cursp(), sym, 1);\n      if (val) push();\n      mrb_gc_arena_restore(s->mrb, ai);\n    }\n    break;\n\n  case NODE_XSTR:\n    {\n      char *p = (char*)tree->car;\n      mrb_int len = nint(tree->cdr);\n      int ai = mrb_gc_arena_save(s->mrb);\n      int off = new_lit(s, mrb_str_new(s->mrb, p, len));\n      int sym;\n\n      genop_1(s, OP_LOADSELF, cursp());\n      push();\n      genop_2(s, OP_STRING, cursp(), off);\n      push(); push();\n      pop_n(3);\n      sym = new_sym(s, MRB_OPSYM_2(s->mrb, tick)); \/* ` *\/\n      genop_3(s, OP_SEND, cursp(), sym, 1);\n      if (val) push();\n      mrb_gc_arena_restore(s->mrb, ai);\n    }\n    break;\n\n  case NODE_REGX:\n    if (val) {\n      char *p1 = (char*)tree->car;\n      char *p2 = (char*)tree->cdr->car;\n      char *p3 = (char*)tree->cdr->cdr;\n      int ai = mrb_gc_arena_save(s->mrb);\n      int sym = new_sym(s, mrb_intern_lit(s->mrb, REGEXP_CLASS));\n      int off = new_lit(s, mrb_str_new_cstr(s->mrb, p1));\n      int argc = 1;\n\n      genop_1(s, OP_OCLASS, cursp());\n      genop_2(s, OP_GETMCNST, cursp(), sym);\n      push();\n      genop_2(s, OP_STRING, cursp(), off);\n      push();\n      if (p2 || p3) {\n        if (p2) { \/* opt *\/\n          off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));\n          genop_2(s, OP_STRING, cursp(), off);\n        }\n        else {\n          genop_1(s, OP_LOADNIL, cursp());\n        }\n        push();\n        argc++;\n        if (p3) { \/* enc *\/\n          off = new_lit(s, mrb_str_new(s->mrb, p3, 1));\n          genop_2(s, OP_STRING, cursp(), off);\n          push();\n          argc++;\n        }\n      }\n      push(); \/* space for a block *\/\n      pop_n(argc+2);\n      sym = new_sym(s, MRB_SYM_2(s->mrb, compile));\n      genop_3(s, OP_SEND, cursp(), sym, argc);\n      mrb_gc_arena_restore(s->mrb, ai);\n      push();\n    }\n    break;\n\n  case NODE_DREGX:\n    if (val) {\n      node *n = tree->car;\n      int ai = mrb_gc_arena_save(s->mrb);\n      int sym = new_sym(s, mrb_intern_lit(s->mrb, REGEXP_CLASS));\n      int argc = 1;\n      int off;\n      char *p;\n\n      genop_1(s, OP_OCLASS, cursp());\n      genop_2(s, OP_GETMCNST, cursp(), sym);\n      push();\n      codegen(s, n->car, VAL);\n      n = n->cdr;\n      while (n) {\n        codegen(s, n->car, VAL);\n        pop(); pop();\n        genop_1(s, OP_STRCAT, cursp());\n        push();\n        n = n->cdr;\n      }\n      n = tree->cdr->cdr;\n      if (n->car) { \/* tail *\/\n        p = (char*)n->car;\n        off = new_lit(s, mrb_str_new_cstr(s->mrb, p));\n        codegen(s, tree->car, VAL);\n        genop_2(s, OP_STRING, cursp(), off);\n        pop();\n        genop_1(s, OP_STRCAT, cursp());\n        push();\n      }\n      if (n->cdr->car) { \/* opt *\/\n        char *p2 = (char*)n->cdr->car;\n        off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));\n        genop_2(s, OP_STRING, cursp(), off);\n        push();\n        argc++;\n      }\n      if (n->cdr->cdr) { \/* enc *\/\n        char *p2 = (char*)n->cdr->cdr;\n        off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));\n        genop_2(s, OP_STRING, cursp(), off);\n        push();\n        argc++;\n      }\n      push(); \/* space for a block *\/\n      pop_n(argc+2);\n      sym = new_sym(s, MRB_SYM_2(s->mrb, compile));\n      genop_3(s, OP_SEND, cursp(), sym, argc);\n      mrb_gc_arena_restore(s->mrb, ai);\n      push();\n    }\n    else {\n      node *n = tree->car;\n\n      while (n) {\n        if (nint(n->car->car) != NODE_STR) {\n          codegen(s, n->car, NOVAL);\n        }\n        n = n->cdr;\n      }\n    }\n    break;\n\n  case NODE_SYM:\n    if (val) {\n      int sym = new_sym(s, nsym(tree));\n\n      genop_2(s, OP_LOADSYM, cursp(), sym);\n      push();\n    }\n    break;\n\n  case NODE_DSYM:\n    codegen(s, tree, val);\n    if (val) {\n      gen_intern(s);\n    }\n    break;\n\n  case NODE_SELF:\n    if (val) {\n      genop_1(s, OP_LOADSELF, cursp());\n      push();\n    }\n    break;\n\n  case NODE_NIL:\n    if (val) {\n      genop_1(s, OP_LOADNIL, cursp());\n      push();\n    }\n    break;\n\n  case NODE_TRUE:\n    if (val) {\n      genop_1(s, OP_LOADT, cursp());\n      push();\n    }\n    break;\n\n  case NODE_FALSE:\n    if (val) {\n      genop_1(s, OP_LOADF, cursp());\n      push();\n    }\n    break;\n\n  case NODE_ALIAS:\n    {\n      int a = new_sym(s, nsym(tree->car));\n      int b = new_sym(s, nsym(tree->cdr));\n\n      genop_2(s, OP_ALIAS, a, b);\n      if (val) {\n        genop_1(s, OP_LOADNIL, cursp());\n        push();\n      }\n    }\n   break;\n\n  case NODE_UNDEF:\n    {\n      node *t = tree;\n\n      while (t) {\n        int symbol = new_sym(s, nsym(t->car));\n        genop_1(s, OP_UNDEF, symbol);\n        t = t->cdr;\n      }\n      if (val) {\n        genop_1(s, OP_LOADNIL, cursp());\n        push();\n      }\n    }\n    break;\n\n  case NODE_CLASS:\n    {\n      int idx;\n      node *body;\n\n      if (tree->car->car == (node*)0) {\n        genop_1(s, OP_LOADNIL, cursp());\n        push();\n      }\n      else if (tree->car->car == (node*)1) {\n        genop_1(s, OP_OCLASS, cursp());\n        push();\n      }\n      else {\n        codegen(s, tree->car->car, VAL);\n      }\n      if (tree->cdr->car) {\n        codegen(s, tree->cdr->car, VAL);\n      }\n      else {\n        genop_1(s, OP_LOADNIL, cursp());\n        push();\n      }\n      pop(); pop();\n      idx = new_sym(s, nsym(tree->car->cdr));\n      genop_2(s, OP_CLASS, cursp(), idx);\n      body = tree->cdr->cdr->car;\n      if (nint(body->cdr->car) == NODE_BEGIN && body->cdr->cdr == NULL) {\n        genop_1(s, OP_LOADNIL, cursp());\n      }\n      else {\n        idx = scope_body(s, body, val);\n        genop_2(s, OP_EXEC, cursp(), idx);\n      }\n      if (val) {\n        push();\n      }\n    }\n    break;\n\n  case NODE_MODULE:\n    {\n      int idx;\n\n      if (tree->car->car == (node*)0) {\n        genop_1(s, OP_LOADNIL, cursp());\n        push();\n      }\n      else if (tree->car->car == (node*)1) {\n        genop_1(s, OP_OCLASS, cursp());\n        push();\n      }\n      else {\n        codegen(s, tree->car->car, VAL);\n      }\n      pop();\n      idx = new_sym(s, nsym(tree->car->cdr));\n      genop_2(s, OP_MODULE, cursp(), idx);\n      if (nint(tree->cdr->car->cdr->car) == NODE_BEGIN &&\n          tree->cdr->car->cdr->cdr == NULL) {\n        genop_1(s, OP_LOADNIL, cursp());\n      }\n      else {\n        idx = scope_body(s, tree->cdr->car, val);\n        genop_2(s, OP_EXEC, cursp(), idx);\n      }\n      if (val) {\n        push();\n      }\n    }\n    break;\n\n  case NODE_SCLASS:\n    {\n      int idx;\n\n      codegen(s, tree->car, VAL);\n      pop();\n      genop_1(s, OP_SCLASS, cursp());\n      if (nint(tree->cdr->car->cdr->car) == NODE_BEGIN &&\n          tree->cdr->car->cdr->cdr == NULL) {\n        genop_1(s, OP_LOADNIL, cursp());\n      }\n      else {\n        idx = scope_body(s, tree->cdr->car, val);\n        genop_2(s, OP_EXEC, cursp(), idx);\n      }\n      if (val) {\n        push();\n      }\n    }\n    break;\n\n  case NODE_DEF:\n    {\n      int sym = new_sym(s, nsym(tree->car));\n      int idx = lambda_body(s, tree->cdr, 0);\n\n      genop_1(s, OP_TCLASS, cursp());\n      push();\n      genop_2(s, OP_METHOD, cursp(), idx);\n      push(); pop();\n      pop();\n      genop_2(s, OP_DEF, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_SDEF:\n    {\n      node *recv = tree->car;\n      int sym = new_sym(s, nsym(tree->cdr->car));\n      int idx = lambda_body(s, tree->cdr->cdr, 0);\n\n      codegen(s, recv, VAL);\n      pop();\n      genop_1(s, OP_SCLASS, cursp());\n      push();\n      genop_2(s, OP_METHOD, cursp(), idx);\n      pop();\n      genop_2(s, OP_DEF, cursp(), sym);\n      if (val) push();\n    }\n    break;\n\n  case NODE_POSTEXE:\n    codegen(s, tree, NOVAL);\n    break;\n\n  default:\n    break;\n  }\n exit:\n  s->rlev = rlev;\n}","target":0,"code_token_length":11138,"total_token_length":11374,"max_tokens_setting":28000}
+{"idx":200323,"func":"suggest_trie_walk(\n    suginfo_T\t*su,\n    langp_T\t*lp,\n    char_u\t*fword,\n    int\t\tsoundfold)\n{\n    char_u\ttword[MAXWLEN];\t    \/\/ good word collected so far\n    trystate_T\tstack[MAXWLEN];\n    char_u\tpreword[MAXWLEN * 3]; \/\/ word found with proper case;\n\t\t\t\t      \/\/ concatenation of prefix compound\n\t\t\t\t      \/\/ words and split word.  NUL terminated\n\t\t\t\t      \/\/ when going deeper but not when coming\n\t\t\t\t      \/\/ back.\n    char_u\tcompflags[MAXWLEN];\t\/\/ compound flags, one for each word\n    trystate_T\t*sp;\n    int\t\tnewscore;\n    int\t\tscore;\n    char_u\t*byts, *fbyts, *pbyts;\n    idx_T\t*idxs, *fidxs, *pidxs;\n    int\t\tdepth;\n    int\t\tc, c2, c3;\n    int\t\tn = 0;\n    int\t\tflags;\n    garray_T\t*gap;\n    idx_T\tarridx;\n    int\t\tlen;\n    char_u\t*p;\n    fromto_T\t*ftp;\n    int\t\tfl = 0, tl;\n    int\t\trepextra = 0;\t    \/\/ extra bytes in fword[] from REP item\n    slang_T\t*slang = lp->lp_slang;\n    int\t\tfword_ends;\n    int\t\tgoodword_ends;\n#ifdef DEBUG_TRIEWALK\n    \/\/ Stores the name of the change made at each level.\n    char_u\tchangename[MAXWLEN][80];\n#endif\n    int\t\tbreakcheckcount = 1000;\n#ifdef FEAT_RELTIME\n    proftime_T\ttime_limit;\n#endif\n    int\t\tcompound_ok;\n\n    \/\/ Go through the whole case-fold tree, try changes at each node.\n    \/\/ \"tword[]\" contains the word collected from nodes in the tree.\n    \/\/ \"fword[]\" the word we are trying to match with (initially the bad\n    \/\/ word).\n    depth = 0;\n    sp = &stack[0];\n    CLEAR_POINTER(sp);\n    sp->ts_curi = 1;\n\n    if (soundfold)\n    {\n\t\/\/ Going through the soundfold tree.\n\tbyts = fbyts = slang->sl_sbyts;\n\tidxs = fidxs = slang->sl_sidxs;\n\tpbyts = NULL;\n\tpidxs = NULL;\n\tsp->ts_prefixdepth = PFD_NOPREFIX;\n\tsp->ts_state = STATE_START;\n    }\n    else\n    {\n\t\/\/ When there are postponed prefixes we need to use these first.  At\n\t\/\/ the end of the prefix we continue in the case-fold tree.\n\tfbyts = slang->sl_fbyts;\n\tfidxs = slang->sl_fidxs;\n\tpbyts = slang->sl_pbyts;\n\tpidxs = slang->sl_pidxs;\n\tif (pbyts != NULL)\n\t{\n\t    byts = pbyts;\n\t    idxs = pidxs;\n\t    sp->ts_prefixdepth = PFD_PREFIXTREE;\n\t    sp->ts_state = STATE_NOPREFIX;\t\/\/ try without prefix first\n\t}\n\telse\n\t{\n\t    byts = fbyts;\n\t    idxs = fidxs;\n\t    sp->ts_prefixdepth = PFD_NOPREFIX;\n\t    sp->ts_state = STATE_START;\n\t}\n    }\n#ifdef FEAT_RELTIME\n    \/\/ The loop may take an indefinite amount of time. Break out after some\n    \/\/ time.\n    if (spell_suggest_timeout > 0)\n\tprofile_setlimit(spell_suggest_timeout, &time_limit);\n#endif\n\n    \/\/ Loop to find all suggestions.  At each round we either:\n    \/\/ - For the current state try one operation, advance \"ts_curi\",\n    \/\/   increase \"depth\".\n    \/\/ - When a state is done go to the next, set \"ts_state\".\n    \/\/ - When all states are tried decrease \"depth\".\n    while (depth >= 0 && !got_int)\n    {\n\tsp = &stack[depth];\n\tswitch (sp->ts_state)\n\t{\n\tcase STATE_START:\n\tcase STATE_NOPREFIX:\n\t    \/\/ Start of node: Deal with NUL bytes, which means\n\t    \/\/ tword[] may end here.\n\t    arridx = sp->ts_arridx;\t    \/\/ current node in the tree\n\t    len = byts[arridx];\t\t    \/\/ bytes in this node\n\t    arridx += sp->ts_curi;\t    \/\/ index of current byte\n\n\t    if (sp->ts_prefixdepth == PFD_PREFIXTREE)\n\t    {\n\t\t\/\/ Skip over the NUL bytes, we use them later.\n\t\tfor (n = 0; n < len && byts[arridx + n] == 0; ++n)\n\t\t    ;\n\t\tsp->ts_curi += n;\n\n\t\t\/\/ Always past NUL bytes now.\n\t\tn = (int)sp->ts_state;\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_ENDNUL;\n\t\tsp->ts_save_badflags = su->su_badflags;\n\n\t\t\/\/ At end of a prefix or at start of prefixtree: check for\n\t\t\/\/ following word.\n\t\tif (depth < MAXWLEN - 1\n\t\t\t    && (byts[arridx] == 0 || n == (int)STATE_NOPREFIX))\n\t\t{\n\t\t    \/\/ Set su->su_badflags to the caps type at this position.\n\t\t    \/\/ Use the caps type until here for the prefix itself.\n\t\t    if (has_mbyte)\n\t\t\tn = nofold_len(fword, sp->ts_fidx, su->su_badptr);\n\t\t    else\n\t\t\tn = sp->ts_fidx;\n\t\t    flags = badword_captype(su->su_badptr, su->su_badptr + n);\n\t\t    su->su_badflags = badword_captype(su->su_badptr + n,\n\t\t\t\t\t       su->su_badptr + su->su_badlen);\n#ifdef DEBUG_TRIEWALK\n\t\t    sprintf(changename[depth], \"prefix\");\n#endif\n\t\t    go_deeper(stack, depth, 0);\n\t\t    ++depth;\n\t\t    sp = &stack[depth];\n\t\t    sp->ts_prefixdepth = depth - 1;\n\t\t    byts = fbyts;\n\t\t    idxs = fidxs;\n\t\t    sp->ts_arridx = 0;\n\n\t\t    \/\/ Move the prefix to preword[] with the right case\n\t\t    \/\/ and make find_keepcap_word() works.\n\t\t    tword[sp->ts_twordlen] = NUL;\n\t\t    make_case_word(tword + sp->ts_splitoff,\n\t\t\t\t\t  preword + sp->ts_prewordlen, flags);\n\t\t    sp->ts_prewordlen = (char_u)STRLEN(preword);\n\t\t    sp->ts_splitoff = sp->ts_twordlen;\n\t\t}\n\t\tbreak;\n\t    }\n\n\t    if (sp->ts_curi > len || byts[arridx] != 0)\n\t    {\n\t\t\/\/ Past bytes in node and\/or past NUL bytes.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_ENDNUL;\n\t\tsp->ts_save_badflags = su->su_badflags;\n\t\tbreak;\n\t    }\n\n\t    \/\/ End of word in tree.\n\t    ++sp->ts_curi;\t\t\/\/ eat one NUL byte\n\n\t    flags = (int)idxs[arridx];\n\n\t    \/\/ Skip words with the NOSUGGEST flag.\n\t    if (flags & WF_NOSUGGEST)\n\t\tbreak;\n\n\t    fword_ends = (fword[sp->ts_fidx] == NUL\n\t\t\t   || (soundfold\n\t\t\t       ? VIM_ISWHITE(fword[sp->ts_fidx])\n\t\t\t       : !spell_iswordp(fword + sp->ts_fidx, curwin)));\n\t    tword[sp->ts_twordlen] = NUL;\n\n\t    if (sp->ts_prefixdepth <= PFD_NOTSPECIAL\n\t\t\t\t\t&& (sp->ts_flags & TSF_PREFIXOK) == 0\n\t\t\t\t\t&& pbyts != NULL)\n\t    {\n\t\t\/\/ There was a prefix before the word.  Check that the prefix\n\t\t\/\/ can be used with this word.\n\t\t\/\/ Count the length of the NULs in the prefix.  If there are\n\t\t\/\/ none this must be the first try without a prefix.\n\t\tn = stack[sp->ts_prefixdepth].ts_arridx;\n\t\tlen = pbyts[n++];\n\t\tfor (c = 0; c < len && pbyts[n + c] == 0; ++c)\n\t\t    ;\n\t\tif (c > 0)\n\t\t{\n\t\t    c = valid_word_prefix(c, n, flags,\n\t\t\t\t       tword + sp->ts_splitoff, slang, FALSE);\n\t\t    if (c == 0)\n\t\t\tbreak;\n\n\t\t    \/\/ Use the WF_RARE flag for a rare prefix.\n\t\t    if (c & WF_RAREPFX)\n\t\t\tflags |= WF_RARE;\n\n\t\t    \/\/ Tricky: when checking for both prefix and compounding\n\t\t    \/\/ we run into the prefix flag first.\n\t\t    \/\/ Remember that it's OK, so that we accept the prefix\n\t\t    \/\/ when arriving at a compound flag.\n\t\t    sp->ts_flags |= TSF_PREFIXOK;\n\t\t}\n\t    }\n\n\t    \/\/ Check NEEDCOMPOUND: can't use word without compounding.  Do try\n\t    \/\/ appending another compound word below.\n\t    if (sp->ts_complen == sp->ts_compsplit && fword_ends\n\t\t\t\t\t\t     && (flags & WF_NEEDCOMP))\n\t\tgoodword_ends = FALSE;\n\t    else\n\t\tgoodword_ends = TRUE;\n\n\t    p = NULL;\n\t    compound_ok = TRUE;\n\t    if (sp->ts_complen > sp->ts_compsplit)\n\t    {\n\t\tif (slang->sl_nobreak)\n\t\t{\n\t\t    \/\/ There was a word before this word.  When there was no\n\t\t    \/\/ change in this word (it was correct) add the first word\n\t\t    \/\/ as a suggestion.  If this word was corrected too, we\n\t\t    \/\/ need to check if a correct word follows.\n\t\t    if (sp->ts_fidx - sp->ts_splitfidx\n\t\t\t\t\t  == sp->ts_twordlen - sp->ts_splitoff\n\t\t\t    && STRNCMP(fword + sp->ts_splitfidx,\n\t\t\t\t\ttword + sp->ts_splitoff,\n\t\t\t\t\t sp->ts_fidx - sp->ts_splitfidx) == 0)\n\t\t    {\n\t\t\tpreword[sp->ts_prewordlen] = NUL;\n\t\t\tnewscore = score_wordcount_adj(slang, sp->ts_score,\n\t\t\t\t\t\t preword + sp->ts_prewordlen,\n\t\t\t\t\t\t sp->ts_prewordlen > 0);\n\t\t\t\/\/ Add the suggestion if the score isn't too bad.\n\t\t\tif (newscore <= su->su_maxscore)\n\t\t\t    add_suggestion(su, &su->su_ga, preword,\n\t\t\t\t    sp->ts_splitfidx - repextra,\n\t\t\t\t    newscore, 0, FALSE,\n\t\t\t\t    lp->lp_sallang, FALSE);\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ There was a compound word before this word.  If this\n\t\t    \/\/ word does not support compounding then give up\n\t\t    \/\/ (splitting is tried for the word without compound\n\t\t    \/\/ flag).\n\t\t    if (((unsigned)flags >> 24) == 0\n\t\t\t    || sp->ts_twordlen - sp->ts_splitoff\n\t\t\t\t\t\t       < slang->sl_compminlen)\n\t\t\tbreak;\n\t\t    \/\/ For multi-byte chars check character length against\n\t\t    \/\/ COMPOUNDMIN.\n\t\t    if (has_mbyte\n\t\t\t    && slang->sl_compminlen > 0\n\t\t\t    && mb_charlen(tword + sp->ts_splitoff)\n\t\t\t\t\t\t       < slang->sl_compminlen)\n\t\t\tbreak;\n\n\t\t    compflags[sp->ts_complen] = ((unsigned)flags >> 24);\n\t\t    compflags[sp->ts_complen + 1] = NUL;\n\t\t    vim_strncpy(preword + sp->ts_prewordlen,\n\t\t\t    tword + sp->ts_splitoff,\n\t\t\t    sp->ts_twordlen - sp->ts_splitoff);\n\n\t\t    \/\/ Verify CHECKCOMPOUNDPATTERN  rules.\n\t\t    if (match_checkcompoundpattern(preword,  sp->ts_prewordlen,\n\t\t\t\t\t\t\t  &slang->sl_comppat))\n\t\t\tcompound_ok = FALSE;\n\n\t\t    if (compound_ok)\n\t\t    {\n\t\t\tp = preword;\n\t\t\twhile (*skiptowhite(p) != NUL)\n\t\t\t    p = skipwhite(skiptowhite(p));\n\t\t\tif (fword_ends && !can_compound(slang, p,\n\t\t\t\t\t\tcompflags + sp->ts_compsplit))\n\t\t\t    \/\/ Compound is not allowed.  But it may still be\n\t\t\t    \/\/ possible if we add another (short) word.\n\t\t\t    compound_ok = FALSE;\n\t\t    }\n\n\t\t    \/\/ Get pointer to last char of previous word.\n\t\t    p = preword + sp->ts_prewordlen;\n\t\t    MB_PTR_BACK(preword, p);\n\t\t}\n\t    }\n\n\t    \/\/ Form the word with proper case in preword.\n\t    \/\/ If there is a word from a previous split, append.\n\t    \/\/ For the soundfold tree don't change the case, simply append.\n\t    if (soundfold)\n\t\tSTRCPY(preword + sp->ts_prewordlen, tword + sp->ts_splitoff);\n\t    else if (flags & WF_KEEPCAP)\n\t\t\/\/ Must find the word in the keep-case tree.\n\t\tfind_keepcap_word(slang, tword + sp->ts_splitoff,\n\t\t\t\t\t\t preword + sp->ts_prewordlen);\n\t    else\n\t    {\n\t\t\/\/ Include badflags: If the badword is onecap or allcap\n\t\t\/\/ use that for the goodword too.  But if the badword is\n\t\t\/\/ allcap and it's only one char long use onecap.\n\t\tc = su->su_badflags;\n\t\tif ((c & WF_ALLCAP)\n\t\t\t&& su->su_badlen == (*mb_ptr2len)(su->su_badptr))\n\t\t    c = WF_ONECAP;\n\t\tc |= flags;\n\n\t\t\/\/ When appending a compound word after a word character don't\n\t\t\/\/ use Onecap.\n\t\tif (p != NULL && spell_iswordp_nmw(p, curwin))\n\t\t    c &= ~WF_ONECAP;\n\t\tmake_case_word(tword + sp->ts_splitoff,\n\t\t\t\t\t      preword + sp->ts_prewordlen, c);\n\t    }\n\n\t    if (!soundfold)\n\t    {\n\t\t\/\/ Don't use a banned word.  It may appear again as a good\n\t\t\/\/ word, thus remember it.\n\t\tif (flags & WF_BANNED)\n\t\t{\n\t\t    add_banned(su, preword + sp->ts_prewordlen);\n\t\t    break;\n\t\t}\n\t\tif ((sp->ts_complen == sp->ts_compsplit\n\t\t\t    && WAS_BANNED(su, preword + sp->ts_prewordlen))\n\t\t\t\t\t\t   || WAS_BANNED(su, preword))\n\t\t{\n\t\t    if (slang->sl_compprog == NULL)\n\t\t\tbreak;\n\t\t    \/\/ the word so far was banned but we may try compounding\n\t\t    goodword_ends = FALSE;\n\t\t}\n\t    }\n\n\t    newscore = 0;\n\t    if (!soundfold)\t\/\/ soundfold words don't have flags\n\t    {\n\t\tif ((flags & WF_REGION)\n\t\t\t    && (((unsigned)flags >> 16) & lp->lp_region) == 0)\n\t\t    newscore += SCORE_REGION;\n\t\tif (flags & WF_RARE)\n\t\t    newscore += SCORE_RARE;\n\n\t\tif (!spell_valid_case(su->su_badflags,\n\t\t\t\t  captype(preword + sp->ts_prewordlen, NULL)))\n\t\t    newscore += SCORE_ICASE;\n\t    }\n\n\t    \/\/ TODO: how about splitting in the soundfold tree?\n\t    if (fword_ends\n\t\t    && goodword_ends\n\t\t    && sp->ts_fidx >= sp->ts_fidxtry\n\t\t    && compound_ok)\n\t    {\n\t\t\/\/ The badword also ends: add suggestions.\n#ifdef DEBUG_TRIEWALK\n\t\tif (soundfold && STRCMP(preword, \"smwrd\") == 0)\n\t\t{\n\t\t    int\t    j;\n\n\t\t    \/\/ print the stack of changes that brought us here\n\t\t    smsg(\"------ %s -------\", fword);\n\t\t    for (j = 0; j < depth; ++j)\n\t\t\tsmsg(\"%s\", changename[j]);\n\t\t}\n#endif\n\t\tif (soundfold)\n\t\t{\n\t\t    \/\/ For soundfolded words we need to find the original\n\t\t    \/\/ words, the edit distance and then add them.\n\t\t    add_sound_suggest(su, preword, sp->ts_score, lp);\n\t\t}\n\t\telse if (sp->ts_fidx > 0)\n\t\t{\n\t\t    \/\/ Give a penalty when changing non-word char to word\n\t\t    \/\/ char, e.g., \"thes,\" -> \"these\".\n\t\t    p = fword + sp->ts_fidx;\n\t\t    MB_PTR_BACK(fword, p);\n\t\t    if (!spell_iswordp(p, curwin) && *preword != NUL)\n\t\t    {\n\t\t\tp = preword + STRLEN(preword);\n\t\t\tMB_PTR_BACK(preword, p);\n\t\t\tif (spell_iswordp(p, curwin))\n\t\t\t    newscore += SCORE_NONWORD;\n\t\t    }\n\n\t\t    \/\/ Give a bonus to words seen before.\n\t\t    score = score_wordcount_adj(slang,\n\t\t\t\t\t\tsp->ts_score + newscore,\n\t\t\t\t\t\tpreword + sp->ts_prewordlen,\n\t\t\t\t\t\tsp->ts_prewordlen > 0);\n\n\t\t    \/\/ Add the suggestion if the score isn't too bad.\n\t\t    if (score <= su->su_maxscore)\n\t\t    {\n\t\t\tadd_suggestion(su, &su->su_ga, preword,\n\t\t\t\t    sp->ts_fidx - repextra,\n\t\t\t\t    score, 0, FALSE, lp->lp_sallang, FALSE);\n\n\t\t\tif (su->su_badflags & WF_MIXCAP)\n\t\t\t{\n\t\t\t    \/\/ We really don't know if the word should be\n\t\t\t    \/\/ upper or lower case, add both.\n\t\t\t    c = captype(preword, NULL);\n\t\t\t    if (c == 0 || c == WF_ALLCAP)\n\t\t\t    {\n\t\t\t\tmake_case_word(tword + sp->ts_splitoff,\n\t\t\t\t\t      preword + sp->ts_prewordlen,\n\t\t\t\t\t\t      c == 0 ? WF_ALLCAP : 0);\n\n\t\t\t\tadd_suggestion(su, &su->su_ga, preword,\n\t\t\t\t\tsp->ts_fidx - repextra,\n\t\t\t\t\tscore + SCORE_ICASE, 0, FALSE,\n\t\t\t\t\tlp->lp_sallang, FALSE);\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\n\t    \/\/ Try word split and\/or compounding.\n\t    if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends)\n\t\t    \/\/ Don't split halfway a character.\n\t\t    && (!has_mbyte || sp->ts_tcharlen == 0))\n\t    {\n\t\tint\ttry_compound;\n\t\tint\ttry_split;\n\n\t\t\/\/ If past the end of the bad word don't try a split.\n\t\t\/\/ Otherwise try changing the next word.  E.g., find\n\t\t\/\/ suggestions for \"the the\" where the second \"the\" is\n\t\t\/\/ different.  It's done like a split.\n\t\t\/\/ TODO: word split for soundfold words\n\t\ttry_split = (sp->ts_fidx - repextra < su->su_badlen)\n\t\t\t\t\t\t\t\t&& !soundfold;\n\n\t\t\/\/ Get here in several situations:\n\t\t\/\/ 1. The word in the tree ends:\n\t\t\/\/    If the word allows compounding try that.  Otherwise try\n\t\t\/\/    a split by inserting a space.  For both check that a\n\t\t\/\/    valid words starts at fword[sp->ts_fidx].\n\t\t\/\/    For NOBREAK do like compounding to be able to check if\n\t\t\/\/    the next word is valid.\n\t\t\/\/ 2. The badword does end, but it was due to a change (e.g.,\n\t\t\/\/    a swap).  No need to split, but do check that the\n\t\t\/\/    following word is valid.\n\t\t\/\/ 3. The badword and the word in the tree end.  It may still\n\t\t\/\/    be possible to compound another (short) word.\n\t\ttry_compound = FALSE;\n\t\tif (!soundfold\n\t\t\t&& !slang->sl_nocompoundsugs\n\t\t\t&& slang->sl_compprog != NULL\n\t\t\t&& ((unsigned)flags >> 24) != 0\n\t\t\t&& sp->ts_twordlen - sp->ts_splitoff\n\t\t\t\t\t\t       >= slang->sl_compminlen\n\t\t\t&& (!has_mbyte\n\t\t\t    || slang->sl_compminlen == 0\n\t\t\t    || mb_charlen(tword + sp->ts_splitoff)\n\t\t\t\t\t\t      >= slang->sl_compminlen)\n\t\t\t&& (slang->sl_compsylmax < MAXWLEN\n\t\t\t    || sp->ts_complen + 1 - sp->ts_compsplit\n\t\t\t\t\t\t\t  < slang->sl_compmax)\n\t\t\t&& (can_be_compound(sp, slang,\n\t\t\t\t\t compflags, ((unsigned)flags >> 24))))\n\n\t\t{\n\t\t    try_compound = TRUE;\n\t\t    compflags[sp->ts_complen] = ((unsigned)flags >> 24);\n\t\t    compflags[sp->ts_complen + 1] = NUL;\n\t\t}\n\n\t\t\/\/ For NOBREAK we never try splitting, it won't make any word\n\t\t\/\/ valid.\n\t\tif (slang->sl_nobreak && !slang->sl_nocompoundsugs)\n\t\t    try_compound = TRUE;\n\n\t\t\/\/ If we could add a compound word, and it's also possible to\n\t\t\/\/ split at this point, do the split first and set\n\t\t\/\/ TSF_DIDSPLIT to avoid doing it again.\n\t\telse if (!fword_ends\n\t\t\t&& try_compound\n\t\t\t&& (sp->ts_flags & TSF_DIDSPLIT) == 0)\n\t\t{\n\t\t    try_compound = FALSE;\n\t\t    sp->ts_flags |= TSF_DIDSPLIT;\n\t\t    --sp->ts_curi;\t    \/\/ do the same NUL again\n\t\t    compflags[sp->ts_complen] = NUL;\n\t\t}\n\t\telse\n\t\t    sp->ts_flags &= ~TSF_DIDSPLIT;\n\n\t\tif (try_split || try_compound)\n\t\t{\n\t\t    if (!try_compound && (!fword_ends || !goodword_ends))\n\t\t    {\n\t\t\t\/\/ If we're going to split need to check that the\n\t\t\t\/\/ words so far are valid for compounding.  If there\n\t\t\t\/\/ is only one word it must not have the NEEDCOMPOUND\n\t\t\t\/\/ flag.\n\t\t\tif (sp->ts_complen == sp->ts_compsplit\n\t\t\t\t\t\t     && (flags & WF_NEEDCOMP))\n\t\t\t    break;\n\t\t\tp = preword;\n\t\t\twhile (*skiptowhite(p) != NUL)\n\t\t\t    p = skipwhite(skiptowhite(p));\n\t\t\tif (sp->ts_complen > sp->ts_compsplit\n\t\t\t\t&& !can_compound(slang, p,\n\t\t\t\t\t\tcompflags + sp->ts_compsplit))\n\t\t\t    break;\n\n\t\t\tif (slang->sl_nosplitsugs)\n\t\t\t    newscore += SCORE_SPLIT_NO;\n\t\t\telse\n\t\t\t    newscore += SCORE_SPLIT;\n\n\t\t\t\/\/ Give a bonus to words seen before.\n\t\t\tnewscore = score_wordcount_adj(slang, newscore,\n\t\t\t\t\t   preword + sp->ts_prewordlen, TRUE);\n\t\t    }\n\n\t\t    if (TRY_DEEPER(su, stack, depth, newscore))\n\t\t    {\n\t\t\tgo_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\t\tif (!try_compound && !fword_ends)\n\t\t\t    sprintf(changename[depth], \"%.*s-%s: split\",\n\t\t\t\t sp->ts_twordlen, tword, fword + sp->ts_fidx);\n\t\t\telse\n\t\t\t    sprintf(changename[depth], \"%.*s-%s: compound\",\n\t\t\t\t sp->ts_twordlen, tword, fword + sp->ts_fidx);\n#endif\n\t\t\t\/\/ Save things to be restored at STATE_SPLITUNDO.\n\t\t\tsp->ts_save_badflags = su->su_badflags;\n\t\t\tPROF_STORE(sp->ts_state)\n\t\t\tsp->ts_state = STATE_SPLITUNDO;\n\n\t\t\t++depth;\n\t\t\tsp = &stack[depth];\n\n\t\t\t\/\/ Append a space to preword when splitting.\n\t\t\tif (!try_compound && !fword_ends)\n\t\t\t    STRCAT(preword, \" \");\n\t\t\tsp->ts_prewordlen = (char_u)STRLEN(preword);\n\t\t\tsp->ts_splitoff = sp->ts_twordlen;\n\t\t\tsp->ts_splitfidx = sp->ts_fidx;\n\n\t\t\t\/\/ If the badword has a non-word character at this\n\t\t\t\/\/ position skip it.  That means replacing the\n\t\t\t\/\/ non-word character with a space.  Always skip a\n\t\t\t\/\/ character when the word ends.  But only when the\n\t\t\t\/\/ good word can end.\n\t\t\tif (((!try_compound && !spell_iswordp_nmw(fword\n\t\t\t\t\t\t\t       + sp->ts_fidx,\n\t\t\t\t\t\t\t       curwin))\n\t\t\t\t    || fword_ends)\n\t\t\t\t&& fword[sp->ts_fidx] != NUL\n\t\t\t\t&& goodword_ends)\n\t\t\t{\n\t\t\t    int\t    l;\n\n\t\t\t    l = mb_ptr2len(fword + sp->ts_fidx);\n\t\t\t    if (fword_ends)\n\t\t\t    {\n\t\t\t\t\/\/ Copy the skipped character to preword.\n\t\t\t\tmch_memmove(preword + sp->ts_prewordlen,\n\t\t\t\t\t\t      fword + sp->ts_fidx, l);\n\t\t\t\tsp->ts_prewordlen += l;\n\t\t\t\tpreword[sp->ts_prewordlen] = NUL;\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tsp->ts_score -= SCORE_SPLIT - SCORE_SUBST;\n\t\t\t    sp->ts_fidx += l;\n\t\t\t}\n\n\t\t\t\/\/ When compounding include compound flag in\n\t\t\t\/\/ compflags[] (already set above).  When splitting we\n\t\t\t\/\/ may start compounding over again.\n\t\t\tif (try_compound)\n\t\t\t    ++sp->ts_complen;\n\t\t\telse\n\t\t\t    sp->ts_compsplit = sp->ts_complen;\n\t\t\tsp->ts_prefixdepth = PFD_NOPREFIX;\n\n\t\t\t\/\/ set su->su_badflags to the caps type at this\n\t\t\t\/\/ position\n\t\t\tif (has_mbyte)\n\t\t\t    n = nofold_len(fword, sp->ts_fidx, su->su_badptr);\n\t\t\telse\n\t\t\t    n = sp->ts_fidx;\n\t\t\tsu->su_badflags = badword_captype(su->su_badptr + n,\n\t\t\t\t\t       su->su_badptr + su->su_badlen);\n\n\t\t\t\/\/ Restart at top of the tree.\n\t\t\tsp->ts_arridx = 0;\n\n\t\t\t\/\/ If there are postponed prefixes, try these too.\n\t\t\tif (pbyts != NULL)\n\t\t\t{\n\t\t\t    byts = pbyts;\n\t\t\t    idxs = pidxs;\n\t\t\t    sp->ts_prefixdepth = PFD_PREFIXTREE;\n\t\t\t    PROF_STORE(sp->ts_state)\n\t\t\t    sp->ts_state = STATE_NOPREFIX;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\tcase STATE_SPLITUNDO:\n\t    \/\/ Undo the changes done for word split or compound word.\n\t    su->su_badflags = sp->ts_save_badflags;\n\n\t    \/\/ Continue looking for NUL bytes.\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_START;\n\n\t    \/\/ In case we went into the prefix tree.\n\t    byts = fbyts;\n\t    idxs = fidxs;\n\t    break;\n\n\tcase STATE_ENDNUL:\n\t    \/\/ Past the NUL bytes in the node.\n\t    su->su_badflags = sp->ts_save_badflags;\n\t    if (fword[sp->ts_fidx] == NUL && sp->ts_tcharlen == 0)\n\t    {\n\t\t\/\/ The badword ends, can't use STATE_PLAIN.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_DEL;\n\t\tbreak;\n\t    }\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_PLAIN;\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_PLAIN:\n\t    \/\/ Go over all possible bytes at this node, add each to tword[]\n\t    \/\/ and use child node.  \"ts_curi\" is the index.\n\t    arridx = sp->ts_arridx;\n\t    if (sp->ts_curi > byts[arridx])\n\t    {\n\t\t\/\/ Done all bytes at this node, do next state.  When still at\n\t\t\/\/ already changed bytes skip the other tricks.\n\t\tPROF_STORE(sp->ts_state)\n\t\tif (sp->ts_fidx >= sp->ts_fidxtry)\n\t\t    sp->ts_state = STATE_DEL;\n\t\telse\n\t\t    sp->ts_state = STATE_FINAL;\n\t    }\n\t    else\n\t    {\n\t\tarridx += sp->ts_curi++;\n\t\tc = byts[arridx];\n\n\t\t\/\/ Normal byte, go one level deeper.  If it's not equal to the\n\t\t\/\/ byte in the bad word adjust the score.  But don't even try\n\t\t\/\/ when the byte was already changed.  And don't try when we\n\t\t\/\/ just deleted this byte, accepting it is always cheaper than\n\t\t\/\/ delete + substitute.\n\t\tif (c == fword[sp->ts_fidx]\n\t\t\t|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE))\n\t\t    newscore = 0;\n\t\telse\n\t\t    newscore = SCORE_SUBST;\n\t\tif ((newscore == 0\n\t\t\t    || (sp->ts_fidx >= sp->ts_fidxtry\n\t\t\t\t&& ((sp->ts_flags & TSF_DIDDEL) == 0\n\t\t\t\t    || c != fword[sp->ts_delidx])))\n\t\t\t&& TRY_DEEPER(su, stack, depth, newscore))\n\t\t{\n\t\t    go_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\t    if (newscore > 0)\n\t\t\tsprintf(changename[depth], \"%.*s-%s: subst %c to %c\",\n\t\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\t\tfword[sp->ts_fidx], c);\n\t\t    else\n\t\t\tsprintf(changename[depth], \"%.*s-%s: accept %c\",\n\t\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\t\tfword[sp->ts_fidx]);\n#endif\n\t\t    ++depth;\n\t\t    sp = &stack[depth];\n\t\t    if (fword[sp->ts_fidx] != NUL)\n\t\t\t++sp->ts_fidx;\n\t\t    tword[sp->ts_twordlen++] = c;\n\t\t    sp->ts_arridx = idxs[arridx];\n\t\t    if (newscore == SCORE_SUBST)\n\t\t\tsp->ts_isdiff = DIFF_YES;\n\t\t    if (has_mbyte)\n\t\t    {\n\t\t\t\/\/ Multi-byte characters are a bit complicated to\n\t\t\t\/\/ handle: They differ when any of the bytes differ\n\t\t\t\/\/ and then their length may also differ.\n\t\t\tif (sp->ts_tcharlen == 0)\n\t\t\t{\n\t\t\t    \/\/ First byte.\n\t\t\t    sp->ts_tcharidx = 0;\n\t\t\t    sp->ts_tcharlen = MB_BYTE2LEN(c);\n\t\t\t    sp->ts_fcharstart = sp->ts_fidx - 1;\n\t\t\t    sp->ts_isdiff = (newscore != 0)\n\t\t\t\t\t\t       ? DIFF_YES : DIFF_NONE;\n\t\t\t}\n\t\t\telse if (sp->ts_isdiff == DIFF_INSERT)\n\t\t\t    \/\/ When inserting trail bytes don't advance in the\n\t\t\t    \/\/ bad word.\n\t\t\t    --sp->ts_fidx;\n\t\t\tif (++sp->ts_tcharidx == sp->ts_tcharlen)\n\t\t\t{\n\t\t\t    \/\/ Last byte of character.\n\t\t\t    if (sp->ts_isdiff == DIFF_YES)\n\t\t\t    {\n\t\t\t\t\/\/ Correct ts_fidx for the byte length of the\n\t\t\t\t\/\/ character (we didn't check that before).\n\t\t\t\tsp->ts_fidx = sp->ts_fcharstart\n\t\t\t\t\t    + mb_ptr2len(\n\t\t\t\t\t\t    fword + sp->ts_fcharstart);\n\t\t\t\t\/\/ For changing a composing character adjust\n\t\t\t\t\/\/ the score from SCORE_SUBST to\n\t\t\t\t\/\/ SCORE_SUBCOMP.\n\t\t\t\tif (enc_utf8\n\t\t\t\t\t&& utf_iscomposing(\n\t\t\t\t\t    utf_ptr2char(tword\n\t\t\t\t\t\t+ sp->ts_twordlen\n\t\t\t\t\t\t\t   - sp->ts_tcharlen))\n\t\t\t\t\t&& utf_iscomposing(\n\t\t\t\t\t    utf_ptr2char(fword\n\t\t\t\t\t\t\t+ sp->ts_fcharstart)))\n\t\t\t\t    sp->ts_score -=\n\t\t\t\t\t\t  SCORE_SUBST - SCORE_SUBCOMP;\n\n\t\t\t\t\/\/ For a similar character adjust score from\n\t\t\t\t\/\/ SCORE_SUBST to SCORE_SIMILAR.\n\t\t\t\telse if (!soundfold\n\t\t\t\t\t&& slang->sl_has_map\n\t\t\t\t\t&& similar_chars(slang,\n\t\t\t\t\t    mb_ptr2char(tword\n\t\t\t\t\t\t+ sp->ts_twordlen\n\t\t\t\t\t\t\t   - sp->ts_tcharlen),\n\t\t\t\t\t    mb_ptr2char(fword\n\t\t\t\t\t\t\t+ sp->ts_fcharstart)))\n\t\t\t\t    sp->ts_score -=\n\t\t\t\t\t\t  SCORE_SUBST - SCORE_SIMILAR;\n\t\t\t    }\n\t\t\t    else if (sp->ts_isdiff == DIFF_INSERT\n\t\t\t\t\t && sp->ts_twordlen > sp->ts_tcharlen)\n\t\t\t    {\n\t\t\t\tp = tword + sp->ts_twordlen - sp->ts_tcharlen;\n\t\t\t\tc = mb_ptr2char(p);\n\t\t\t\tif (enc_utf8 && utf_iscomposing(c))\n\t\t\t\t{\n\t\t\t\t    \/\/ Inserting a composing char doesn't\n\t\t\t\t    \/\/ count that much.\n\t\t\t\t    sp->ts_score -= SCORE_INS - SCORE_INSCOMP;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    \/\/ If the previous character was the same,\n\t\t\t\t    \/\/ thus doubling a character, give a bonus\n\t\t\t\t    \/\/ to the score.  Also for the soundfold\n\t\t\t\t    \/\/ tree (might seem illogical but does\n\t\t\t\t    \/\/ give better scores).\n\t\t\t\t    MB_PTR_BACK(tword, p);\n\t\t\t\t    if (c == mb_ptr2char(p))\n\t\t\t\t\tsp->ts_score -= SCORE_INS\n\t\t\t\t\t\t\t       - SCORE_INSDUP;\n\t\t\t\t}\n\t\t\t    }\n\n\t\t\t    \/\/ Starting a new char, reset the length.\n\t\t\t    sp->ts_tcharlen = 0;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ If we found a similar char adjust the score.\n\t\t\t\/\/ We do this after calling go_deeper() because\n\t\t\t\/\/ it's slow.\n\t\t\tif (newscore != 0\n\t\t\t\t&& !soundfold\n\t\t\t\t&& slang->sl_has_map\n\t\t\t\t&& similar_chars(slang,\n\t\t\t\t\t\t   c, fword[sp->ts_fidx - 1]))\n\t\t\t    sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\tcase STATE_DEL:\n\t    \/\/ When past the first byte of a multi-byte char don't try\n\t    \/\/ delete\/insert\/swap a character.\n\t    if (has_mbyte && sp->ts_tcharlen > 0)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\t    \/\/ Try skipping one character in the bad word (delete it).\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_INS_PREP;\n\t    sp->ts_curi = 1;\n\t    if (soundfold && sp->ts_fidx == 0 && fword[sp->ts_fidx] == '*')\n\t\t\/\/ Deleting a vowel at the start of a word counts less, see\n\t\t\/\/ soundalike_score().\n\t\tnewscore = 2 * SCORE_DEL \/ 3;\n\t    else\n\t\tnewscore = SCORE_DEL;\n\t    if (fword[sp->ts_fidx] != NUL\n\t\t\t\t    && TRY_DEEPER(su, stack, depth, newscore))\n\t    {\n\t\tgo_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: delete %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tfword[sp->ts_fidx]);\n#endif\n\t\t++depth;\n\n\t\t\/\/ Remember what character we deleted, so that we can avoid\n\t\t\/\/ inserting it again.\n\t\tstack[depth].ts_flags |= TSF_DIDDEL;\n\t\tstack[depth].ts_delidx = sp->ts_fidx;\n\n\t\t\/\/ Advance over the character in fword[].  Give a bonus to the\n\t\t\/\/ score if the same character is following \"nn\" -> \"n\".  It's\n\t\t\/\/ a bit illogical for soundfold tree but it does give better\n\t\t\/\/ results.\n\t\tif (has_mbyte)\n\t\t{\n\t\t    c = mb_ptr2char(fword + sp->ts_fidx);\n\t\t    stack[depth].ts_fidx += mb_ptr2len(fword + sp->ts_fidx);\n\t\t    if (enc_utf8 && utf_iscomposing(c))\n\t\t\tstack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;\n\t\t    else if (c == mb_ptr2char(fword + stack[depth].ts_fidx))\n\t\t\tstack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;\n\t\t}\n\t\telse\n\t\t{\n\t\t    ++stack[depth].ts_fidx;\n\t\t    if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])\n\t\t\tstack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;\n\t\t}\n\t\tbreak;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_INS_PREP:\n\t    if (sp->ts_flags & TSF_DIDDEL)\n\t    {\n\t\t\/\/ If we just deleted a byte then inserting won't make sense,\n\t\t\/\/ a substitute is always cheaper.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_SWAP;\n\t\tbreak;\n\t    }\n\n\t    \/\/ skip over NUL bytes\n\t    n = sp->ts_arridx;\n\t    for (;;)\n\t    {\n\t\tif (sp->ts_curi > byts[n])\n\t\t{\n\t\t    \/\/ Only NUL bytes at this node, go to next state.\n\t\t    PROF_STORE(sp->ts_state)\n\t\t    sp->ts_state = STATE_SWAP;\n\t\t    break;\n\t\t}\n\t\tif (byts[n + sp->ts_curi] != NUL)\n\t\t{\n\t\t    \/\/ Found a byte to insert.\n\t\t    PROF_STORE(sp->ts_state)\n\t\t    sp->ts_state = STATE_INS;\n\t\t    break;\n\t\t}\n\t\t++sp->ts_curi;\n\t    }\n\t    break;\n\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_INS:\n\t    \/\/ Insert one byte.  Repeat this for each possible byte at this\n\t    \/\/ node.\n\t    n = sp->ts_arridx;\n\t    if (sp->ts_curi > byts[n])\n\t    {\n\t\t\/\/ Done all bytes at this node, go to next state.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_SWAP;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Do one more byte at this node, but:\n\t    \/\/ - Skip NUL bytes.\n\t    \/\/ - Skip the byte if it's equal to the byte in the word,\n\t    \/\/   accepting that byte is always better.\n\t    n += sp->ts_curi++;\n\t    c = byts[n];\n\t    if (soundfold && sp->ts_twordlen == 0 && c == '*')\n\t\t\/\/ Inserting a vowel at the start of a word counts less,\n\t\t\/\/ see soundalike_score().\n\t\tnewscore = 2 * SCORE_INS \/ 3;\n\t    else\n\t\tnewscore = SCORE_INS;\n\t    if (c != fword[sp->ts_fidx]\n\t\t\t\t    && TRY_DEEPER(su, stack, depth, newscore))\n\t    {\n\t\tgo_deeper(stack, depth, newscore);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: insert %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tc);\n#endif\n\t\t++depth;\n\t\tsp = &stack[depth];\n\t\ttword[sp->ts_twordlen++] = c;\n\t\tsp->ts_arridx = idxs[n];\n\t\tif (has_mbyte)\n\t\t{\n\t\t    fl = MB_BYTE2LEN(c);\n\t\t    if (fl > 1)\n\t\t    {\n\t\t\t\/\/ There are following bytes for the same character.\n\t\t\t\/\/ We must find all bytes before trying\n\t\t\t\/\/ delete\/insert\/swap\/etc.\n\t\t\tsp->ts_tcharlen = fl;\n\t\t\tsp->ts_tcharidx = 1;\n\t\t\tsp->ts_isdiff = DIFF_INSERT;\n\t\t    }\n\t\t}\n\t\telse\n\t\t    fl = 1;\n\t\tif (fl == 1)\n\t\t{\n\t\t    \/\/ If the previous character was the same, thus doubling a\n\t\t    \/\/ character, give a bonus to the score.  Also for\n\t\t    \/\/ soundfold words (illogical but does give a better\n\t\t    \/\/ score).\n\t\t    if (sp->ts_twordlen >= 2\n\t\t\t\t\t   && tword[sp->ts_twordlen - 2] == c)\n\t\t\tsp->ts_score -= SCORE_INS - SCORE_INSDUP;\n\t\t}\n\t    }\n\t    break;\n\n\tcase STATE_SWAP:\n\t    \/\/ Swap two bytes in the bad word: \"12\" -> \"21\".\n\t    \/\/ We change \"fword\" here, it's changed back afterwards at\n\t    \/\/ STATE_UNSWAP.\n\t    p = fword + sp->ts_fidx;\n\t    c = *p;\n\t    if (c == NUL)\n\t    {\n\t\t\/\/ End of word, can't swap or replace.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Don't swap if the first character is not a word character.\n\t    \/\/ SWAP3 etc. also don't make sense then.\n\t    if (!soundfold && !spell_iswordp(p, curwin))\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\n\t    if (has_mbyte)\n\t    {\n\t\tn = MB_CPTR2LEN(p);\n\t\tc = mb_ptr2char(p);\n\t\tif (p[n] == NUL)\n\t\t    c2 = NUL;\n\t\telse if (!soundfold && !spell_iswordp(p + n, curwin))\n\t\t    c2 = c; \/\/ don't swap non-word char\n\t\telse\n\t\t    c2 = mb_ptr2char(p + n);\n\t    }\n\t    else\n\t    {\n\t\tif (p[1] == NUL)\n\t\t    c2 = NUL;\n\t\telse if (!soundfold && !spell_iswordp(p + 1, curwin))\n\t\t    c2 = c; \/\/ don't swap non-word char\n\t\telse\n\t\t    c2 = p[1];\n\t    }\n\n\t    \/\/ When the second character is NUL we can't swap.\n\t    if (c2 == NUL)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\n\t    \/\/ When characters are identical, swap won't do anything.\n\t    \/\/ Also get here if the second char is not a word character.\n\t    if (c == c2)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_SWAP3;\n\t\tbreak;\n\t    }\n\t    if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: swap %c and %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tc, c2);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNSWAP;\n\t\t++depth;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    fl = mb_char2len(c2);\n\t\t    mch_memmove(p, p + n, fl);\n\t\t    mb_char2bytes(c, p + fl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    p[0] = c2;\n\t\t    p[1] = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 2;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ If this swap doesn't work then SWAP3 won't either.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNSWAP:\n\t    \/\/ Undo the STATE_SWAP swap: \"21\" -> \"12\".\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = mb_ptr2len(p);\n\t\tc = mb_ptr2char(p + n);\n\t\tmch_memmove(p + mb_ptr2len(p + n), p, n);\n\t\tmb_char2bytes(c, p);\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\t*p = p[1];\n\t\tp[1] = c;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_SWAP3:\n\t    \/\/ Swap two bytes, skipping one: \"123\" -> \"321\".  We change\n\t    \/\/ \"fword\" here, it's changed back afterwards at STATE_UNSWAP3.\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = MB_CPTR2LEN(p);\n\t\tc = mb_ptr2char(p);\n\t\tfl = MB_CPTR2LEN(p + n);\n\t\tc2 = mb_ptr2char(p + n);\n\t\tif (!soundfold && !spell_iswordp(p + n + fl, curwin))\n\t\t    c3 = c;\t\/\/ don't swap non-word char\n\t\telse\n\t\t    c3 = mb_ptr2char(p + n + fl);\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\tc2 = p[1];\n\t\tif (!soundfold && !spell_iswordp(p + 2, curwin))\n\t\t    c3 = c;\t\/\/ don't swap non-word char\n\t\telse\n\t\t    c3 = p[2];\n\t    }\n\n\t    \/\/ When characters are identical: \"121\" then SWAP3 result is\n\t    \/\/ identical, ROT3L result is same as SWAP: \"211\", ROT3L result is\n\t    \/\/ same as SWAP on next char: \"112\".  Thus skip all swapping.\n\t    \/\/ Also skip when c3 is NUL.\n\t    \/\/ Also get here when the third character is not a word character.\n\t    \/\/ Second character may any char: \"a.b\" -> \"b.a\"\n\t    if (c == c3 || c3 == NUL)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\t    if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP3);\n#ifdef DEBUG_TRIEWALK\n\t\tsprintf(changename[depth], \"%.*s-%s: swap3 %c and %c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tc, c3);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNSWAP3;\n\t\t++depth;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    tl = mb_char2len(c3);\n\t\t    mch_memmove(p, p + n + fl, tl);\n\t\t    mb_char2bytes(c2, p + tl);\n\t\t    mb_char2bytes(c, p + fl + tl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    p[0] = p[2];\n\t\t    p[2] = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 3;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNSWAP3:\n\t    \/\/ Undo STATE_SWAP3: \"321\" -> \"123\"\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = mb_ptr2len(p);\n\t\tc2 = mb_ptr2char(p + n);\n\t\tfl = mb_ptr2len(p + n);\n\t\tc = mb_ptr2char(p + n + fl);\n\t\ttl = mb_ptr2len(p + n + fl);\n\t\tmch_memmove(p + fl + tl, p, n);\n\t\tmb_char2bytes(c, p);\n\t\tmb_char2bytes(c2, p + tl);\n\t\tp = p + tl;\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\t*p = p[2];\n\t\tp[2] = c;\n\t\t++p;\n\t    }\n\n\t    if (!soundfold && !spell_iswordp(p, curwin))\n\t    {\n\t\t\/\/ Middle char is not a word char, skip the rotate.  First and\n\t\t\/\/ third char were already checked at swap and swap3.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Rotate three characters left: \"123\" -> \"231\".  We change\n\t    \/\/ \"fword\" here, it's changed back afterwards at STATE_UNROT3L.\n\t    if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP3);\n#ifdef DEBUG_TRIEWALK\n\t\tp = fword + sp->ts_fidx;\n\t\tsprintf(changename[depth], \"%.*s-%s: rotate left %c%c%c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tp[0], p[1], p[2]);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNROT3L;\n\t\t++depth;\n\t\tp = fword + sp->ts_fidx;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    n = MB_CPTR2LEN(p);\n\t\t    c = mb_ptr2char(p);\n\t\t    fl = MB_CPTR2LEN(p + n);\n\t\t    fl += MB_CPTR2LEN(p + n + fl);\n\t\t    mch_memmove(p, p + n, fl);\n\t\t    mb_char2bytes(c, p + fl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    c = *p;\n\t\t    *p = p[1];\n\t\t    p[1] = p[2];\n\t\t    p[2] = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 3;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNROT3L:\n\t    \/\/ Undo ROT3L: \"231\" -> \"123\"\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tn = mb_ptr2len(p);\n\t\tn += mb_ptr2len(p + n);\n\t\tc = mb_ptr2char(p + n);\n\t\ttl = mb_ptr2len(p + n);\n\t\tmch_memmove(p + tl, p, n);\n\t\tmb_char2bytes(c, p);\n\t    }\n\t    else\n\t    {\n\t\tc = p[2];\n\t\tp[2] = p[1];\n\t\tp[1] = *p;\n\t\t*p = c;\n\t    }\n\n\t    \/\/ Rotate three bytes right: \"123\" -> \"312\".  We change \"fword\"\n\t    \/\/ here, it's changed back afterwards at STATE_UNROT3R.\n\t    if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))\n\t    {\n\t\tgo_deeper(stack, depth, SCORE_SWAP3);\n#ifdef DEBUG_TRIEWALK\n\t\tp = fword + sp->ts_fidx;\n\t\tsprintf(changename[depth], \"%.*s-%s: rotate right %c%c%c\",\n\t\t\tsp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\tp[0], p[1], p[2]);\n#endif\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_UNROT3R;\n\t\t++depth;\n\t\tp = fword + sp->ts_fidx;\n\t\tif (has_mbyte)\n\t\t{\n\t\t    n = MB_CPTR2LEN(p);\n\t\t    n += MB_CPTR2LEN(p + n);\n\t\t    c = mb_ptr2char(p + n);\n\t\t    tl = MB_CPTR2LEN(p + n);\n\t\t    mch_memmove(p + tl, p, n);\n\t\t    mb_char2bytes(c, p);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;\n\t\t}\n\t\telse\n\t\t{\n\t\t    c = p[2];\n\t\t    p[2] = p[1];\n\t\t    p[1] = *p;\n\t\t    *p = c;\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + 3;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_REP_INI;\n\t    }\n\t    break;\n\n\tcase STATE_UNROT3R:\n\t    \/\/ Undo ROT3R: \"312\" -> \"123\"\n\t    p = fword + sp->ts_fidx;\n\t    if (has_mbyte)\n\t    {\n\t\tc = mb_ptr2char(p);\n\t\ttl = mb_ptr2len(p);\n\t\tn = mb_ptr2len(p + tl);\n\t\tn += mb_ptr2len(p + tl + n);\n\t\tmch_memmove(p, p + tl, n);\n\t\tmb_char2bytes(c, p + n);\n\t    }\n\t    else\n\t    {\n\t\tc = *p;\n\t\t*p = p[1];\n\t\tp[1] = p[2];\n\t\tp[2] = c;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_REP_INI:\n\t    \/\/ Check if matching with REP items from the .aff file would work.\n\t    \/\/ Quickly skip if:\n\t    \/\/ - there are no REP items and we are not in the soundfold trie\n\t    \/\/ - the score is going to be too high anyway\n\t    \/\/ - already applied a REP item or swapped here\n\t    if ((lp->lp_replang == NULL && !soundfold)\n\t\t    || sp->ts_score + SCORE_REP >= su->su_maxscore\n\t\t    || sp->ts_fidx < sp->ts_fidxtry)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\n\t    \/\/ Use the first byte to quickly find the first entry that may\n\t    \/\/ match.  If the index is -1 there is none.\n\t    if (soundfold)\n\t\tsp->ts_curi = slang->sl_repsal_first[fword[sp->ts_fidx]];\n\t    else\n\t\tsp->ts_curi = lp->lp_replang->sl_rep_first[fword[sp->ts_fidx]];\n\n\t    if (sp->ts_curi < 0)\n\t    {\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t\tbreak;\n\t    }\n\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_REP;\n\t    \/\/ FALLTHROUGH\n\n\tcase STATE_REP:\n\t    \/\/ Try matching with REP items from the .aff file.  For each match\n\t    \/\/ replace the characters and check if the resulting word is\n\t    \/\/ valid.\n\t    p = fword + sp->ts_fidx;\n\n\t    if (soundfold)\n\t\tgap = &slang->sl_repsal;\n\t    else\n\t\tgap = &lp->lp_replang->sl_rep;\n\t    while (sp->ts_curi < gap->ga_len)\n\t    {\n\t\tftp = (fromto_T *)gap->ga_data + sp->ts_curi++;\n\t\tif (*ftp->ft_from != *p)\n\t\t{\n\t\t    \/\/ past possible matching entries\n\t\t    sp->ts_curi = gap->ga_len;\n\t\t    break;\n\t\t}\n\t\tif (STRNCMP(ftp->ft_from, p, STRLEN(ftp->ft_from)) == 0\n\t\t\t&& TRY_DEEPER(su, stack, depth, SCORE_REP))\n\t\t{\n\t\t    go_deeper(stack, depth, SCORE_REP);\n#ifdef DEBUG_TRIEWALK\n\t\t    sprintf(changename[depth], \"%.*s-%s: replace %s with %s\",\n\t\t\t    sp->ts_twordlen, tword, fword + sp->ts_fidx,\n\t\t\t    ftp->ft_from, ftp->ft_to);\n#endif\n\t\t    \/\/ Need to undo this afterwards.\n\t\t    PROF_STORE(sp->ts_state)\n\t\t    sp->ts_state = STATE_REP_UNDO;\n\n\t\t    \/\/ Change the \"from\" to the \"to\" string.\n\t\t    ++depth;\n\t\t    fl = (int)STRLEN(ftp->ft_from);\n\t\t    tl = (int)STRLEN(ftp->ft_to);\n\t\t    if (fl != tl)\n\t\t    {\n\t\t\tSTRMOVE(p + tl, p + fl);\n\t\t\trepextra += tl - fl;\n\t\t    }\n\t\t    mch_memmove(p, ftp->ft_to, tl);\n\t\t    stack[depth].ts_fidxtry = sp->ts_fidx + tl;\n\t\t    stack[depth].ts_tcharlen = 0;\n\t\t    break;\n\t\t}\n\t    }\n\n\t    if (sp->ts_curi >= gap->ga_len && sp->ts_state == STATE_REP)\n\t    {\n\t\t\/\/ No (more) matches.\n\t\tPROF_STORE(sp->ts_state)\n\t\tsp->ts_state = STATE_FINAL;\n\t    }\n\n\t    break;\n\n\tcase STATE_REP_UNDO:\n\t    \/\/ Undo a REP replacement and continue with the next one.\n\t    if (soundfold)\n\t\tgap = &slang->sl_repsal;\n\t    else\n\t\tgap = &lp->lp_replang->sl_rep;\n\t    ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;\n\t    fl = (int)STRLEN(ftp->ft_from);\n\t    tl = (int)STRLEN(ftp->ft_to);\n\t    p = fword + sp->ts_fidx;\n\t    if (fl != tl)\n\t    {\n\t\tSTRMOVE(p + fl, p + tl);\n\t\trepextra -= tl - fl;\n\t    }\n\t    mch_memmove(p, ftp->ft_from, fl);\n\t    PROF_STORE(sp->ts_state)\n\t    sp->ts_state = STATE_REP;\n\t    break;\n\n\tdefault:\n\t    \/\/ Did all possible states at this level, go up one level.\n\t    --depth;\n\n\t    if (depth >= 0 && stack[depth].ts_prefixdepth == PFD_PREFIXTREE)\n\t    {\n\t\t\/\/ Continue in or go back to the prefix tree.\n\t\tbyts = pbyts;\n\t\tidxs = pidxs;\n\t    }\n\n\t    \/\/ Don't check for CTRL-C too often, it takes time.\n\t    if (--breakcheckcount == 0)\n\t    {\n\t\tui_breakcheck();\n\t\tbreakcheckcount = 1000;\n#ifdef FEAT_RELTIME\n\t\tif (spell_suggest_timeout > 0\n\t\t\t\t\t  && profile_passed_limit(&time_limit))\n\t\t    got_int = TRUE;\n#endif\n\t    }\n\t}\n    }\n}","target":1,"code_token_length":12904,"total_token_length":13140,"max_tokens_setting":28000}
+{"idx":201885,"func":"regmatch(\n    char_u\t*scan,\t\t    \/\/ Current node.\n    proftime_T\t*tm UNUSED,\t    \/\/ timeout limit or NULL\n    int\t\t*timed_out UNUSED)  \/\/ flag set on timeout or NULL\n{\n  char_u\t*next;\t\t\/\/ Next node.\n  int\t\top;\n  int\t\tc;\n  regitem_T\t*rp;\n  int\t\tno;\n  int\t\tstatus;\t\t\/\/ one of the RA_ values:\n#ifdef FEAT_RELTIME\n  int\t\ttm_count = 0;\n#endif\n\n  \/\/ Make \"regstack\" and \"backpos\" empty.  They are allocated and freed in\n  \/\/ bt_regexec_both() to reduce malloc()\/free() calls.\n  regstack.ga_len = 0;\n  backpos.ga_len = 0;\n\n  \/\/ Repeat until \"regstack\" is empty.\n  for (;;)\n  {\n    \/\/ Some patterns may take a long time to match, e.g., \"\\([a-z]\\+\\)\\+Q\".\n    \/\/ Allow interrupting them with CTRL-C.\n    fast_breakcheck();\n\n#ifdef DEBUG\n    if (scan != NULL && regnarrate)\n    {\n\tmch_errmsg((char *)regprop(scan));\n\tmch_errmsg(\"(\\n\");\n    }\n#endif\n\n    \/\/ Repeat for items that can be matched sequentially, without using the\n    \/\/ regstack.\n    for (;;)\n    {\n\tif (got_int || scan == NULL)\n\t{\n\t    status = RA_FAIL;\n\t    break;\n\t}\n#ifdef FEAT_RELTIME\n\t\/\/ Check for timeout once in a 100 times to avoid overhead.\n\tif (tm != NULL && ++tm_count == 100)\n\t{\n\t    tm_count = 0;\n\t    if (profile_passed_limit(tm))\n\t    {\n\t\tif (timed_out != NULL)\n\t\t    *timed_out = TRUE;\n\t\tstatus = RA_FAIL;\n\t\tbreak;\n\t    }\n\t}\n#endif\n\tstatus = RA_CONT;\n\n#ifdef DEBUG\n\tif (regnarrate)\n\t{\n\t    mch_errmsg((char *)regprop(scan));\n\t    mch_errmsg(\"...\\n\");\n# ifdef FEAT_SYN_HL\n\t    if (re_extmatch_in != NULL)\n\t    {\n\t\tint i;\n\n\t\tmch_errmsg(_(\"External submatches:\\n\"));\n\t\tfor (i = 0; i < NSUBEXP; i++)\n\t\t{\n\t\t    mch_errmsg(\"    \\\"\");\n\t\t    if (re_extmatch_in->matches[i] != NULL)\n\t\t\tmch_errmsg((char *)re_extmatch_in->matches[i]);\n\t\t    mch_errmsg(\"\\\"\\n\");\n\t\t}\n\t    }\n# endif\n\t}\n#endif\n\tnext = regnext(scan);\n\n\top = OP(scan);\n\t\/\/ Check for character class with NL added.\n\tif (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI\n\t\t\t     && *rex.input == NUL && rex.lnum <= rex.reg_maxline)\n\t{\n\t    reg_nextline();\n\t}\n\telse if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\\n')\n\t{\n\t    ADVANCE_REGINPUT();\n\t}\n\telse\n\t{\n\t  if (WITH_NL(op))\n\t      op -= ADD_NL;\n\t  if (has_mbyte)\n\t      c = (*mb_ptr2char)(rex.input);\n\t  else\n\t      c = *rex.input;\n\t  switch (op)\n\t  {\n\t  case BOL:\n\t    if (rex.input != rex.line)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case EOL:\n\t    if (c != NUL)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_BOF:\n\t    \/\/ We're not at the beginning of the file when below the first\n\t    \/\/ line where we started, not at the start of the line or we\n\t    \/\/ didn't start at the first line of the buffer.\n\t    if (rex.lnum != 0 || rex.input != rex.line\n\t\t\t\t       || (REG_MULTI && rex.reg_firstlnum > 1))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_EOF:\n\t    if (rex.lnum != rex.reg_maxline || c != NUL)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case CURSOR:\n\t    \/\/ Check if the buffer is in a window and compare the\n\t    \/\/ rex.reg_win->w_cursor position to the match position.\n\t    if (rex.reg_win == NULL\n\t\t    || (rex.lnum + rex.reg_firstlnum\n\t\t\t\t\t\t != rex.reg_win->w_cursor.lnum)\n\t\t    || ((colnr_T)(rex.input - rex.line)\n\t\t\t\t\t\t != rex.reg_win->w_cursor.col))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_MARK:\n\t    \/\/ Compare the mark position to the match position.\n\t    {\n\t\tint\tmark = OPERAND(scan)[0];\n\t\tint\tcmp = OPERAND(scan)[1];\n\t\tpos_T\t*pos;\n\n\t\tpos = getmark_buf(rex.reg_buf, mark, FALSE);\n\t\tif (pos == NULL\t\t     \/\/ mark doesn't exist\n\t\t\t|| pos->lnum <= 0)   \/\/ mark isn't set in reg_buf\n\t\t{\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t\telse\n\t\t{\n\t\t    colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum\n\t\t\t\t\t\t\t  && pos->col == MAXCOL\n\t\t\t\t      ? (colnr_T)STRLEN(reg_getline(\n\t\t\t\t\t\tpos->lnum - rex.reg_firstlnum))\n\t\t\t\t      : pos->col;\n\n\t\t    if ((pos->lnum == rex.lnum + rex.reg_firstlnum\n\t\t\t\t? (pos_col == (colnr_T)(rex.input - rex.line)\n\t\t\t\t    ? (cmp == '<' || cmp == '>')\n\t\t\t\t    : (pos_col < (colnr_T)(rex.input - rex.line)\n\t\t\t\t\t? cmp != '>'\n\t\t\t\t\t: cmp != '<'))\n\t\t\t\t: (pos->lnum < rex.lnum + rex.reg_firstlnum\n\t\t\t\t    ? cmp != '>'\n\t\t\t\t    : cmp != '<')))\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t    }\n\t    break;\n\n\t  case RE_VISUAL:\n\t    if (!reg_match_visual())\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_LNUM:\n\t    if (!REG_MULTI || !re_num_cmp((long_u)(rex.lnum + rex.reg_firstlnum),\n\t\t\t\t\t\t\t\t\tscan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_COL:\n\t    if (!re_num_cmp((long_u)(rex.input - rex.line) + 1, scan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_VCOL:\n\t    if (!re_num_cmp((long_u)win_linetabsize(\n\t\t\t    rex.reg_win == NULL ? curwin : rex.reg_win,\n\t\t\t    rex.line, (colnr_T)(rex.input - rex.line)) + 1, scan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case BOW:\t\/\/ \\<word; rex.input points to w\n\t    if (c == NUL)\t\/\/ Can't match at end of line\n\t\tstatus = RA_NOMATCH;\n\t    else if (has_mbyte)\n\t    {\n\t\tint this_class;\n\n\t\t\/\/ Get class of current and previous char (if it exists).\n\t\tthis_class = mb_get_class_buf(rex.input, rex.reg_buf);\n\t\tif (this_class <= 1)\n\t\t    status = RA_NOMATCH;  \/\/ not on a word at all\n\t\telse if (reg_prev_class() == this_class)\n\t\t    status = RA_NOMATCH;  \/\/ previous char is in same word\n\t    }\n\t    else\n\t    {\n\t\tif (!vim_iswordc_buf(c, rex.reg_buf) || (rex.input > rex.line\n\t\t\t\t&& vim_iswordc_buf(rex.input[-1], rex.reg_buf)))\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    break;\n\n\t  case EOW:\t\/\/ word\\>; rex.input points after d\n\t    if (rex.input == rex.line)    \/\/ Can't match at start of line\n\t\tstatus = RA_NOMATCH;\n\t    else if (has_mbyte)\n\t    {\n\t\tint this_class, prev_class;\n\n\t\t\/\/ Get class of current and previous char (if it exists).\n\t\tthis_class = mb_get_class_buf(rex.input, rex.reg_buf);\n\t\tprev_class = reg_prev_class();\n\t\tif (this_class == prev_class\n\t\t\t|| prev_class == 0 || prev_class == 1)\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    else\n\t    {\n\t\tif (!vim_iswordc_buf(rex.input[-1], rex.reg_buf)\n\t\t\t|| (rex.input[0] != NUL\n\t\t\t\t\t   && vim_iswordc_buf(c, rex.reg_buf)))\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    break; \/\/ Matched with EOW\n\n\t  case ANY:\n\t    \/\/ ANY does not match new lines.\n\t    if (c == NUL)\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case IDENT:\n\t    if (!vim_isIDc(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SIDENT:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isIDc(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case KWORD:\n\t    if (!vim_iswordp_buf(rex.input, rex.reg_buf))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SKWORD:\n\t    if (VIM_ISDIGIT(*rex.input)\n\t\t\t\t    || !vim_iswordp_buf(rex.input, rex.reg_buf))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case FNAME:\n\t    if (!vim_isfilec(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SFNAME:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isfilec(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case PRINT:\n\t    if (!vim_isprintc(PTR2CHAR(rex.input)))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SPRINT:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input)))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case WHITE:\n\t    if (!VIM_ISWHITE(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NWHITE:\n\t    if (c == NUL || VIM_ISWHITE(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case DIGIT:\n\t    if (!ri_digit(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NDIGIT:\n\t    if (c == NUL || ri_digit(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case HEX:\n\t    if (!ri_hex(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NHEX:\n\t    if (c == NUL || ri_hex(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case OCTAL:\n\t    if (!ri_octal(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NOCTAL:\n\t    if (c == NUL || ri_octal(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case WORD:\n\t    if (!ri_word(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NWORD:\n\t    if (c == NUL || ri_word(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case HEAD:\n\t    if (!ri_head(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NHEAD:\n\t    if (c == NUL || ri_head(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case ALPHA:\n\t    if (!ri_alpha(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NALPHA:\n\t    if (c == NUL || ri_alpha(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case LOWER:\n\t    if (!ri_lower(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NLOWER:\n\t    if (c == NUL || ri_lower(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case UPPER:\n\t    if (!ri_upper(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NUPPER:\n\t    if (c == NUL || ri_upper(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case EXACTLY:\n\t    {\n\t\tint\tlen;\n\t\tchar_u\t*opnd;\n\n\t\topnd = OPERAND(scan);\n\t\t\/\/ Inline the first byte, for speed.\n\t\tif (*opnd != *rex.input\n\t\t\t&& (!rex.reg_ic\n\t\t\t    || (!enc_utf8\n\t\t\t      && MB_TOLOWER(*opnd) != MB_TOLOWER(*rex.input))))\n\t\t    status = RA_NOMATCH;\n\t\telse if (*opnd == NUL)\n\t\t{\n\t\t    \/\/ match empty string always works; happens when \"~\" is\n\t\t    \/\/ empty.\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic))\n\t\t    {\n\t\t\tlen = 1;\t\/\/ matched a single byte above\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Need to match first byte again for multi-byte.\n\t\t\tlen = (int)STRLEN(opnd);\n\t\t\tif (cstrncmp(opnd, rex.input, &len) != 0)\n\t\t\t    status = RA_NOMATCH;\n\t\t    }\n\t\t    \/\/ Check for following composing character, unless %C\n\t\t    \/\/ follows (skips over all composing chars).\n\t\t    if (status != RA_NOMATCH\n\t\t\t    && enc_utf8\n\t\t\t    && UTF_COMPOSINGLIKE(rex.input, rex.input + len)\n\t\t\t    && !rex.reg_icombine\n\t\t\t    && OP(next) != RE_COMPOSING)\n\t\t    {\n\t\t\t\/\/ raaron: This code makes a composing character get\n\t\t\t\/\/ ignored, which is the correct behavior (sometimes)\n\t\t\t\/\/ for voweled Hebrew texts.\n\t\t\tstatus = RA_NOMATCH;\n\t\t    }\n\t\t    if (status != RA_NOMATCH)\n\t\t\trex.input += len;\n\t\t}\n\t    }\n\t    break;\n\n\t  case ANYOF:\n\t  case ANYBUT:\n\t    if (c == NUL)\n\t\tstatus = RA_NOMATCH;\n\t    else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case MULTIBYTECODE:\n\t    if (has_mbyte)\n\t    {\n\t\tint\ti, len;\n\t\tchar_u\t*opnd;\n\t\tint\topndc = 0, inpc;\n\n\t\topnd = OPERAND(scan);\n\t\t\/\/ Safety check (just in case 'encoding' was changed since\n\t\t\/\/ compiling the program).\n\t\tif ((len = (*mb_ptr2len)(opnd)) < 2)\n\t\t{\n\t\t    status = RA_NOMATCH;\n\t\t    break;\n\t\t}\n\t\tif (enc_utf8)\n\t\t    opndc = utf_ptr2char(opnd);\n\t\tif (enc_utf8 && utf_iscomposing(opndc))\n\t\t{\n\t\t    \/\/ When only a composing char is given match at any\n\t\t    \/\/ position where that composing char appears.\n\t\t    status = RA_NOMATCH;\n\t\t    for (i = 0; rex.input[i] != NUL;\n\t\t\t\t\t\ti += utf_ptr2len(rex.input + i))\n\t\t    {\n\t\t\tinpc = utf_ptr2char(rex.input + i);\n\t\t\tif (!utf_iscomposing(inpc))\n\t\t\t{\n\t\t\t    if (i > 0)\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (opndc == inpc)\n\t\t\t{\n\t\t\t    \/\/ Include all following composing chars.\n\t\t\t    len = i + utfc_ptr2len(rex.input + i);\n\t\t\t    status = RA_MATCH;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    for (i = 0; i < len; ++i)\n\t\t\tif (opnd[i] != rex.input[i])\n\t\t\t{\n\t\t\t    status = RA_NOMATCH;\n\t\t\t    break;\n\t\t\t}\n\t\trex.input += len;\n\t    }\n\t    else\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\t  case RE_COMPOSING:\n\t    if (enc_utf8)\n\t    {\n\t\t\/\/ Skip composing characters.\n\t\twhile (utf_iscomposing(utf_ptr2char(rex.input)))\n\t\t    MB_CPTR_ADV(rex.input);\n\t    }\n\t    break;\n\n\t  case NOTHING:\n\t    break;\n\n\t  case BACK:\n\t    {\n\t\tint\t\ti;\n\t\tbackpos_T\t*bp;\n\n\t\t\/\/ When we run into BACK we need to check if we don't keep\n\t\t\/\/ looping without matching any input.  The second and later\n\t\t\/\/ times a BACK is encountered it fails if the input is still\n\t\t\/\/ at the same position as the previous time.\n\t\t\/\/ The positions are stored in \"backpos\" and found by the\n\t\t\/\/ current value of \"scan\", the position in the RE program.\n\t\tbp = (backpos_T *)backpos.ga_data;\n\t\tfor (i = 0; i < backpos.ga_len; ++i)\n\t\t    if (bp[i].bp_scan == scan)\n\t\t\tbreak;\n\t\tif (i == backpos.ga_len)\n\t\t{\n\t\t    \/\/ First time at this BACK, make room to store the pos.\n\t\t    if (ga_grow(&backpos, 1) == FAIL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\t\/\/ get \"ga_data\" again, it may have changed\n\t\t\tbp = (backpos_T *)backpos.ga_data;\n\t\t\tbp[i].bp_scan = scan;\n\t\t\t++backpos.ga_len;\n\t\t    }\n\t\t}\n\t\telse if (reg_save_equal(&bp[i].bp_pos))\n\t\t    \/\/ Still at same position as last time, fail.\n\t\t    status = RA_NOMATCH;\n\n\t\tif (status != RA_FAIL && status != RA_NOMATCH)\n\t\t    reg_save(&bp[i].bp_pos, &backpos);\n\t    }\n\t    break;\n\n\t  case MOPEN + 0:   \/\/ Match start: \\zs\n\t  case MOPEN + 1:   \/\/ \\(\n\t  case MOPEN + 2:\n\t  case MOPEN + 3:\n\t  case MOPEN + 4:\n\t  case MOPEN + 5:\n\t  case MOPEN + 6:\n\t  case MOPEN + 7:\n\t  case MOPEN + 8:\n\t  case MOPEN + 9:\n\t    {\n\t\tno = op - MOPEN;\n\t\tcleanup_subexpr();\n\t\trp = regstack_push(RS_MOPEN, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, &rex.reg_startpos[no],\n\t\t\t\t\t\t\t  &rex.reg_startp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n\n\t  case NOPEN:\t    \/\/ \\%(\n\t  case NCLOSE:\t    \/\/ \\) after \\%(\n\t\tif (regstack_push(RS_NOPEN, scan) == NULL)\n\t\t    status = RA_FAIL;\n\t\t\/\/ We simply continue and handle the result when done.\n\t\tbreak;\n\n#ifdef FEAT_SYN_HL\n\t  case ZOPEN + 1:\n\t  case ZOPEN + 2:\n\t  case ZOPEN + 3:\n\t  case ZOPEN + 4:\n\t  case ZOPEN + 5:\n\t  case ZOPEN + 6:\n\t  case ZOPEN + 7:\n\t  case ZOPEN + 8:\n\t  case ZOPEN + 9:\n\t    {\n\t\tno = op - ZOPEN;\n\t\tcleanup_zsubexpr();\n\t\trp = regstack_push(RS_ZOPEN, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, ®_startzpos[no],\n\t\t\t\t\t\t\t     ®_startzp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case MCLOSE + 0:  \/\/ Match end: \\ze\n\t  case MCLOSE + 1:  \/\/ \\)\n\t  case MCLOSE + 2:\n\t  case MCLOSE + 3:\n\t  case MCLOSE + 4:\n\t  case MCLOSE + 5:\n\t  case MCLOSE + 6:\n\t  case MCLOSE + 7:\n\t  case MCLOSE + 8:\n\t  case MCLOSE + 9:\n\t    {\n\t\tno = op - MCLOSE;\n\t\tcleanup_subexpr();\n\t\trp = regstack_push(RS_MCLOSE, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, &rex.reg_endpos[no],\n\t\t\t\t\t\t\t    &rex.reg_endp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case ZCLOSE + 1:  \/\/ \\) after \\z(\n\t  case ZCLOSE + 2:\n\t  case ZCLOSE + 3:\n\t  case ZCLOSE + 4:\n\t  case ZCLOSE + 5:\n\t  case ZCLOSE + 6:\n\t  case ZCLOSE + 7:\n\t  case ZCLOSE + 8:\n\t  case ZCLOSE + 9:\n\t    {\n\t\tno = op - ZCLOSE;\n\t\tcleanup_zsubexpr();\n\t\trp = regstack_push(RS_ZCLOSE, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, ®_endzpos[no],\n\t\t\t\t\t\t\t      ®_endzp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case BACKREF + 1:\n\t  case BACKREF + 2:\n\t  case BACKREF + 3:\n\t  case BACKREF + 4:\n\t  case BACKREF + 5:\n\t  case BACKREF + 6:\n\t  case BACKREF + 7:\n\t  case BACKREF + 8:\n\t  case BACKREF + 9:\n\t    {\n\t\tint\t\tlen;\n\n\t\tno = op - BACKREF;\n\t\tcleanup_subexpr();\n\t\tif (!REG_MULTI)\t\t\/\/ Single-line regexp\n\t\t{\n\t\t    if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL)\n\t\t    {\n\t\t\t\/\/ Backref was not set: Match an empty string.\n\t\t\tlen = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Compare current input with back-ref in the same\n\t\t\t\/\/ line.\n\t\t\tlen = (int)(rex.reg_endp[no] - rex.reg_startp[no]);\n\t\t\tif (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0)\n\t\t\t    status = RA_NOMATCH;\n\t\t    }\n\t\t}\n\t\telse\t\t\t\t\/\/ Multi-line regexp\n\t\t{\n\t\t    if (rex.reg_startpos[no].lnum < 0\n\t\t\t\t\t\t|| rex.reg_endpos[no].lnum < 0)\n\t\t    {\n\t\t\t\/\/ Backref was not set: Match an empty string.\n\t\t\tlen = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (rex.reg_startpos[no].lnum == rex.lnum\n\t\t\t\t&& rex.reg_endpos[no].lnum == rex.lnum)\n\t\t\t{\n\t\t\t    \/\/ Compare back-ref within the current line.\n\t\t\t    len = rex.reg_endpos[no].col\n\t\t\t\t\t\t    - rex.reg_startpos[no].col;\n\t\t\t    if (cstrncmp(rex.line + rex.reg_startpos[no].col,\n\t\t\t\t\t\t\t  rex.input, &len) != 0)\n\t\t\t\tstatus = RA_NOMATCH;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Messy situation: Need to compare between two\n\t\t\t    \/\/ lines.\n\t\t\t    int r = match_with_backref(\n\t\t\t\t\t    rex.reg_startpos[no].lnum,\n\t\t\t\t\t    rex.reg_startpos[no].col,\n\t\t\t\t\t    rex.reg_endpos[no].lnum,\n\t\t\t\t\t    rex.reg_endpos[no].col,\n\t\t\t\t\t    &len);\n\n\t\t\t    if (r != RA_MATCH)\n\t\t\t\tstatus = r;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t\t\/\/ Matched the backref, skip over it.\n\t\trex.input += len;\n\t    }\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case ZREF + 1:\n\t  case ZREF + 2:\n\t  case ZREF + 3:\n\t  case ZREF + 4:\n\t  case ZREF + 5:\n\t  case ZREF + 6:\n\t  case ZREF + 7:\n\t  case ZREF + 8:\n\t  case ZREF + 9:\n\t    {\n\t\tint\tlen;\n\n\t\tcleanup_zsubexpr();\n\t\tno = op - ZREF;\n\t\tif (re_extmatch_in != NULL\n\t\t\t&& re_extmatch_in->matches[no] != NULL)\n\t\t{\n\t\t    len = (int)STRLEN(re_extmatch_in->matches[no]);\n\t\t    if (cstrncmp(re_extmatch_in->matches[no],\n\t\t\t\t\t\t\t  rex.input, &len) != 0)\n\t\t\tstatus = RA_NOMATCH;\n\t\t    else\n\t\t\trex.input += len;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Backref was not set: Match an empty string.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case BRANCH:\n\t    {\n\t\tif (OP(next) != BRANCH) \/\/ No choice.\n\t\t    next = OPERAND(scan);\t\/\/ Avoid recursion.\n\t\telse\n\t\t{\n\t\t    rp = regstack_push(RS_BRANCH, scan);\n\t\t    if (rp == NULL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t\tstatus = RA_BREAK;\t\/\/ rest is below\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_LIMITS:\n\t    {\n\t\tif (OP(next) == BRACE_SIMPLE)\n\t\t{\n\t\t    bl_minval = OPERAND_MIN(scan);\n\t\t    bl_maxval = OPERAND_MAX(scan);\n\t\t}\n\t\telse if (OP(next) >= BRACE_COMPLEX\n\t\t\t&& OP(next) < BRACE_COMPLEX + 10)\n\t\t{\n\t\t    no = OP(next) - BRACE_COMPLEX;\n\t\t    brace_min[no] = OPERAND_MIN(scan);\n\t\t    brace_max[no] = OPERAND_MAX(scan);\n\t\t    brace_count[no] = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    internal_error(\"BRACE_LIMITS\");\n\t\t    status = RA_FAIL;\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_COMPLEX + 0:\n\t  case BRACE_COMPLEX + 1:\n\t  case BRACE_COMPLEX + 2:\n\t  case BRACE_COMPLEX + 3:\n\t  case BRACE_COMPLEX + 4:\n\t  case BRACE_COMPLEX + 5:\n\t  case BRACE_COMPLEX + 6:\n\t  case BRACE_COMPLEX + 7:\n\t  case BRACE_COMPLEX + 8:\n\t  case BRACE_COMPLEX + 9:\n\t    {\n\t\tno = op - BRACE_COMPLEX;\n\t\t++brace_count[no];\n\n\t\t\/\/ If not matched enough times yet, try one more\n\t\tif (brace_count[no] <= (brace_min[no] <= brace_max[no]\n\t\t\t\t\t     ? brace_min[no] : brace_max[no]))\n\t\t{\n\t\t    rp = regstack_push(RS_BRCPLX_MORE, scan);\n\t\t    if (rp == NULL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\trp->rs_no = no;\n\t\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\t\tnext = OPERAND(scan);\n\t\t\t\/\/ We continue and handle the result when done.\n\t\t    }\n\t\t    break;\n\t\t}\n\n\t\t\/\/ If matched enough times, may try matching some more\n\t\tif (brace_min[no] <= brace_max[no])\n\t\t{\n\t\t    \/\/ Range is the normal way around, use longest match\n\t\t    if (brace_count[no] <= brace_max[no])\n\t\t    {\n\t\t\trp = regstack_push(RS_BRCPLX_LONG, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    rp->rs_no = no;\n\t\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t\t    next = OPERAND(scan);\n\t\t\t    \/\/ We continue and handle the result when done.\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Range is backwards, use shortest match first\n\t\t    if (brace_count[no] <= brace_min[no])\n\t\t    {\n\t\t\trp = regstack_push(RS_BRCPLX_SHORT, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t\t    \/\/ We continue and handle the result when done.\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_SIMPLE:\n\t  case STAR:\n\t  case PLUS:\n\t    {\n\t\tregstar_T\trst;\n\n\t\t\/\/ Lookahead to avoid useless match attempts when we know\n\t\t\/\/ what character comes next.\n\t\tif (OP(next) == EXACTLY)\n\t\t{\n\t\t    rst.nextb = *OPERAND(next);\n\t\t    if (rex.reg_ic)\n\t\t    {\n\t\t\tif (MB_ISUPPER(rst.nextb))\n\t\t\t    rst.nextb_ic = MB_TOLOWER(rst.nextb);\n\t\t\telse\n\t\t\t    rst.nextb_ic = MB_TOUPPER(rst.nextb);\n\t\t    }\n\t\t    else\n\t\t\trst.nextb_ic = rst.nextb;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rst.nextb = NUL;\n\t\t    rst.nextb_ic = NUL;\n\t\t}\n\t\tif (op != BRACE_SIMPLE)\n\t\t{\n\t\t    rst.minval = (op == STAR) ? 0 : 1;\n\t\t    rst.maxval = MAX_LIMIT;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rst.minval = bl_minval;\n\t\t    rst.maxval = bl_maxval;\n\t\t}\n\n\t\t\/\/ When maxval > minval, try matching as much as possible, up\n\t\t\/\/ to maxval.  When maxval < minval, try matching at least the\n\t\t\/\/ minimal number (since the range is backwards, that's also\n\t\t\/\/ maxval!).\n\t\trst.count = regrepeat(OPERAND(scan), rst.maxval);\n\t\tif (got_int)\n\t\t{\n\t\t    status = RA_FAIL;\n\t\t    break;\n\t\t}\n\t\tif (rst.minval <= rst.maxval\n\t\t\t  ? rst.count >= rst.minval : rst.count >= rst.maxval)\n\t\t{\n\t\t    \/\/ It could match.  Prepare for trying to match what\n\t\t    \/\/ follows.  The code is below.  Parameters are stored in\n\t\t    \/\/ a regstar_T on the regstack.\n\t\t    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n\t\t    {\n\t\t\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\t\t\tstatus = RA_FAIL;\n\t\t    }\n\t\t    else if (ga_grow(®stack, sizeof(regstar_T)) == FAIL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\tregstack.ga_len += sizeof(regstar_T);\n\t\t\trp = regstack_push(rst.minval <= rst.maxval\n\t\t\t\t\t? RS_STAR_LONG : RS_STAR_SHORT, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    *(((regstar_T *)rp) - 1) = rst;\n\t\t\t    status = RA_BREAK;\t    \/\/ skip the restore bits\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    status = RA_NOMATCH;\n\n\t    }\n\t    break;\n\n\t  case NOMATCH:\n\t  case MATCH:\n\t  case SUBPAT:\n\t    rp = regstack_push(RS_NOMATCH, scan);\n\t    if (rp == NULL)\n\t\tstatus = RA_FAIL;\n\t    else\n\t    {\n\t\trp->rs_no = op;\n\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\tnext = OPERAND(scan);\n\t\t\/\/ We continue and handle the result when done.\n\t    }\n\t    break;\n\n\t  case BEHIND:\n\t  case NOBEHIND:\n\t    \/\/ Need a bit of room to store extra positions.\n\t    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n\t    {\n\t\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\t\tstatus = RA_FAIL;\n\t    }\n\t    else if (ga_grow(®stack, sizeof(regbehind_T)) == FAIL)\n\t\tstatus = RA_FAIL;\n\t    else\n\t    {\n\t\tregstack.ga_len += sizeof(regbehind_T);\n\t\trp = regstack_push(RS_BEHIND1, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    \/\/ Need to save the subexpr to be able to restore them\n\t\t    \/\/ when there is a match but we don't use it.\n\t\t    save_subexpr(((regbehind_T *)rp) - 1);\n\n\t\t    rp->rs_no = op;\n\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t    \/\/ First try if what follows matches.  If it does then we\n\t\t    \/\/ check the behind match by looping.\n\t\t}\n\t    }\n\t    break;\n\n\t  case BHPOS:\n\t    if (REG_MULTI)\n\t    {\n\t\tif (behind_pos.rs_u.pos.col != (colnr_T)(rex.input - rex.line)\n\t\t\t|| behind_pos.rs_u.pos.lnum != rex.lnum)\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    else if (behind_pos.rs_u.ptr != rex.input)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case NEWL:\n\t    if ((c != NUL || !REG_MULTI || rex.lnum > rex.reg_maxline\n\t\t\t     || rex.reg_line_lbr)\n\t\t\t\t\t   && (c != '\\n' || !rex.reg_line_lbr))\n\t\tstatus = RA_NOMATCH;\n\t    else if (rex.reg_line_lbr)\n\t\tADVANCE_REGINPUT();\n\t    else\n\t\treg_nextline();\n\t    break;\n\n\t  case END:\n\t    status = RA_MATCH;\t\/\/ Success!\n\t    break;\n\n\t  default:\n\t    iemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\t    printf(\"Illegal op code %d\\n\", op);\n#endif\n\t    status = RA_FAIL;\n\t    break;\n\t  }\n\t}\n\n\t\/\/ If we can't continue sequentially, break the inner loop.\n\tif (status != RA_CONT)\n\t    break;\n\n\t\/\/ Continue in inner loop, advance to next item.\n\tscan = next;\n\n    } \/\/ end of inner loop\n\n    \/\/ If there is something on the regstack execute the code for the state.\n    \/\/ If the state is popped then loop and use the older state.\n    while (regstack.ga_len > 0 && status != RA_FAIL)\n    {\n\trp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;\n\tswitch (rp->rs_state)\n\t{\n\t  case RS_NOPEN:\n\t    \/\/ Result is passed on as-is, simply pop the state.\n\t    regstack_pop(&scan);\n\t    break;\n\n\t  case RS_MOPEN:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no],\n\t\t\t\t\t\t  &rex.reg_startp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case RS_ZOPEN:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, ®_startzpos[rp->rs_no],\n\t\t\t\t\t\t ®_startzp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n#endif\n\n\t  case RS_MCLOSE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no],\n\t\t\t\t\t\t    &rex.reg_endp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case RS_ZCLOSE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, ®_endzpos[rp->rs_no],\n\t\t\t\t\t\t   ®_endzp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n#endif\n\n\t  case RS_BRANCH:\n\t    if (status == RA_MATCH)\n\t\t\/\/ this branch matched, use it\n\t\tregstack_pop(&scan);\n\t    else\n\t    {\n\t\tif (status != RA_BREAK)\n\t\t{\n\t\t    \/\/ After a non-matching branch: try next one.\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t    scan = rp->rs_scan;\n\t\t}\n\t\tif (scan == NULL || OP(scan) != BRANCH)\n\t\t{\n\t\t    \/\/ no more branches, didn't find a match\n\t\t    status = RA_NOMATCH;\n\t\t    regstack_pop(&scan);\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Prepare to try a branch.\n\t\t    rp->rs_scan = regnext(scan);\n\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t    scan = OPERAND(scan);\n\t\t}\n\t    }\n\t    break;\n\n\t  case RS_BRCPLX_MORE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\t--brace_count[rp->rs_no];\t\/\/ decrement match count\n\t    }\n\t    regstack_pop(&scan);\n\t    break;\n\n\t  case RS_BRCPLX_LONG:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\t\/\/ There was no match, but we did find enough matches.\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\t--brace_count[rp->rs_no];\n\t\t\/\/ continue with the items after \"\\{}\"\n\t\tstatus = RA_CONT;\n\t    }\n\t    regstack_pop(&scan);\n\t    if (status == RA_CONT)\n\t\tscan = regnext(scan);\n\t    break;\n\n\t  case RS_BRCPLX_SHORT:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\t\/\/ There was no match, try to match one more item.\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t    regstack_pop(&scan);\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\tscan = OPERAND(scan);\n\t\tstatus = RA_CONT;\n\t    }\n\t    break;\n\n\t  case RS_NOMATCH:\n\t    \/\/ Pop the state.  If the operand matches for NOMATCH or\n\t    \/\/ doesn't match for MATCH\/SUBPAT, we fail.  Otherwise backup,\n\t    \/\/ except for SUBPAT, and continue with the next item.\n\t    if (status == (rp->rs_no == NOMATCH ? RA_MATCH : RA_NOMATCH))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t    {\n\t\tstatus = RA_CONT;\n\t\tif (rp->rs_no != SUBPAT)\t\/\/ zero-width\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t    }\n\t    regstack_pop(&scan);\n\t    if (status == RA_CONT)\n\t\tscan = regnext(scan);\n\t    break;\n\n\t  case RS_BEHIND1:\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\tregstack_pop(&scan);\n\t\tregstack.ga_len -= sizeof(regbehind_T);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ The stuff after BEHIND\/NOBEHIND matches.  Now try if\n\t\t\/\/ the behind part does (not) match before the current\n\t\t\/\/ position in the input.  This must be done at every\n\t\t\/\/ position in the input and checking if the match ends at\n\t\t\/\/ the current position.\n\n\t\t\/\/ save the position after the found match for next\n\t\treg_save(&(((regbehind_T *)rp) - 1)->save_after, &backpos);\n\n\t\t\/\/ Start looking for a match with operand at the current\n\t\t\/\/ position.  Go back one character until we find the\n\t\t\/\/ result, hitting the start of the line or the previous\n\t\t\/\/ line (for multi-line matching).\n\t\t\/\/ Set behind_pos to where the match should end, BHPOS\n\t\t\/\/ will match it.  Save the current value.\n\t\t(((regbehind_T *)rp) - 1)->save_behind = behind_pos;\n\t\tbehind_pos = rp->rs_un.regsave;\n\n\t\trp->rs_state = RS_BEHIND2;\n\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\tscan = OPERAND(rp->rs_scan) + 4;\n\t    }\n\t    break;\n\n\t  case RS_BEHIND2:\n\t    \/\/ Looping for BEHIND \/ NOBEHIND match.\n\t    if (status == RA_MATCH && reg_save_equal(&behind_pos))\n\t    {\n\t\t\/\/ found a match that ends where \"next\" started\n\t\tbehind_pos = (((regbehind_T *)rp) - 1)->save_behind;\n\t\tif (rp->rs_no == BEHIND)\n\t\t    reg_restore(&(((regbehind_T *)rp) - 1)->save_after,\n\t\t\t\t\t\t\t\t    &backpos);\n\t\telse\n\t\t{\n\t\t    \/\/ But we didn't want a match.  Need to restore the\n\t\t    \/\/ subexpr, because what follows matched, so they have\n\t\t    \/\/ been set.\n\t\t    status = RA_NOMATCH;\n\t\t    restore_subexpr(((regbehind_T *)rp) - 1);\n\t\t}\n\t\tregstack_pop(&scan);\n\t\tregstack.ga_len -= sizeof(regbehind_T);\n\t    }\n\t    else\n\t    {\n\t\tlong limit;\n\n\t\t\/\/ No match or a match that doesn't end where we want it: Go\n\t\t\/\/ back one character.  May go to previous line once.\n\t\tno = OK;\n\t\tlimit = OPERAND_MIN(rp->rs_scan);\n\t\tif (REG_MULTI)\n\t\t{\n\t\t    if (limit > 0\n\t\t\t    && ((rp->rs_un.regsave.rs_u.pos.lnum\n\t\t\t\t\t\t    < behind_pos.rs_u.pos.lnum\n\t\t\t\t    ? (colnr_T)STRLEN(rex.line)\n\t\t\t\t    : behind_pos.rs_u.pos.col)\n\t\t\t\t- rp->rs_un.regsave.rs_u.pos.col >= limit))\n\t\t\tno = FAIL;\n\t\t    else if (rp->rs_un.regsave.rs_u.pos.col == 0)\n\t\t    {\n\t\t\tif (rp->rs_un.regsave.rs_u.pos.lnum\n\t\t\t\t\t< behind_pos.rs_u.pos.lnum\n\t\t\t\t|| reg_getline(\n\t\t\t\t\t--rp->rs_un.regsave.rs_u.pos.lnum)\n\t\t\t\t\t\t\t\t  == NULL)\n\t\t\t    no = FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t\t    rp->rs_un.regsave.rs_u.pos.col =\n\t\t\t\t\t\t (colnr_T)STRLEN(rex.line);\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t{\n\t\t\t    char_u *line =\n\t\t\t\t  reg_getline(rp->rs_un.regsave.rs_u.pos.lnum);\n\n\t\t\t    rp->rs_un.regsave.rs_u.pos.col -=\n\t\t\t\t(*mb_head_off)(line, line\n\t\t\t\t    + rp->rs_un.regsave.rs_u.pos.col - 1) + 1;\n\t\t\t}\n\t\t\telse\n\t\t\t    --rp->rs_un.regsave.rs_u.pos.col;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (rp->rs_un.regsave.rs_u.ptr == rex.line)\n\t\t\tno = FAIL;\n\t\t    else\n\t\t    {\n\t\t\tMB_PTR_BACK(rex.line, rp->rs_un.regsave.rs_u.ptr);\n\t\t\tif (limit > 0 && (long)(behind_pos.rs_u.ptr\n\t\t\t\t     - rp->rs_un.regsave.rs_u.ptr) > limit)\n\t\t\t    no = FAIL;\n\t\t    }\n\t\t}\n\t\tif (no == OK)\n\t\t{\n\t\t    \/\/ Advanced, prepare for finding match again.\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t    scan = OPERAND(rp->rs_scan) + 4;\n\t\t    if (status == RA_MATCH)\n\t\t    {\n\t\t\t\/\/ We did match, so subexpr may have been changed,\n\t\t\t\/\/ need to restore them for the next try.\n\t\t\tstatus = RA_NOMATCH;\n\t\t\trestore_subexpr(((regbehind_T *)rp) - 1);\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Can't advance.  For NOBEHIND that's a match.\n\t\t    behind_pos = (((regbehind_T *)rp) - 1)->save_behind;\n\t\t    if (rp->rs_no == NOBEHIND)\n\t\t    {\n\t\t\treg_restore(&(((regbehind_T *)rp) - 1)->save_after,\n\t\t\t\t\t\t\t\t    &backpos);\n\t\t\tstatus = RA_MATCH;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ We do want a proper match.  Need to restore the\n\t\t\t\/\/ subexpr if we had a match, because they may have\n\t\t\t\/\/ been set.\n\t\t\tif (status == RA_MATCH)\n\t\t\t{\n\t\t\t    status = RA_NOMATCH;\n\t\t\t    restore_subexpr(((regbehind_T *)rp) - 1);\n\t\t\t}\n\t\t    }\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regbehind_T);\n\t\t}\n\t    }\n\t    break;\n\n\t  case RS_STAR_LONG:\n\t  case RS_STAR_SHORT:\n\t    {\n\t\tregstar_T\t    *rst = ((regstar_T *)rp) - 1;\n\n\t\tif (status == RA_MATCH)\n\t\t{\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regstar_T);\n\t\t    break;\n\t\t}\n\n\t\t\/\/ Tried once already, restore input pointers.\n\t\tif (status != RA_BREAK)\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\n\t\t\/\/ Repeat until we found a position where it could match.\n\t\tfor (;;)\n\t\t{\n\t\t    if (status != RA_BREAK)\n\t\t    {\n\t\t\t\/\/ Tried first position already, advance.\n\t\t\tif (rp->rs_state == RS_STAR_LONG)\n\t\t\t{\n\t\t\t    \/\/ Trying for longest match, but couldn't or\n\t\t\t    \/\/ didn't match -- back up one char.\n\t\t\t    if (--rst->count < rst->minval)\n\t\t\t\tbreak;\n\t\t\t    if (rex.input == rex.line)\n\t\t\t    {\n\t\t\t\t\/\/ backup to last char of previous line\n\t\t\t\tif (rex.lnum == 0)\n\t\t\t\t{\n\t\t\t\t    status = RA_NOMATCH;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t\t--rex.lnum;\n\t\t\t\trex.line = reg_getline(rex.lnum);\n\t\t\t\t\/\/ Just in case regrepeat() didn't count\n\t\t\t\t\/\/ right.\n\t\t\t\tif (rex.line == NULL)\n\t\t\t\t    break;\n\t\t\t\trex.input = rex.line + STRLEN(rex.line);\n\t\t\t\tfast_breakcheck();\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tMB_PTR_BACK(rex.line, rex.input);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Range is backwards, use shortest match first.\n\t\t\t    \/\/ Careful: maxval and minval are exchanged!\n\t\t\t    \/\/ Couldn't or didn't match: try advancing one\n\t\t\t    \/\/ char.\n\t\t\t    if (rst->count == rst->minval\n\t\t\t\t  || regrepeat(OPERAND(rp->rs_scan), 1L) == 0)\n\t\t\t\tbreak;\n\t\t\t    ++rst->count;\n\t\t\t}\n\t\t\tif (got_int)\n\t\t\t    break;\n\t\t    }\n\t\t    else\n\t\t\tstatus = RA_NOMATCH;\n\n\t\t    \/\/ If it could match, try it.\n\t\t    if (rst->nextb == NUL || *rex.input == rst->nextb\n\t\t\t\t\t     || *rex.input == rst->nextb_ic)\n\t\t    {\n\t\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\t\tscan = regnext(rp->rs_scan);\n\t\t\tstatus = RA_CONT;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t\tif (status != RA_CONT)\n\t\t{\n\t\t    \/\/ Failed.\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regstar_T);\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t    }\n\t    break;\n\t}\n\n\t\/\/ If we want to continue the inner loop or didn't pop a state\n\t\/\/ continue matching loop\n\tif (status == RA_CONT || rp == (regitem_T *)\n\t\t\t     ((char *)regstack.ga_data + regstack.ga_len) - 1)\n\t    break;\n    }\n\n    \/\/ May need to continue with the inner loop, starting at \"scan\".\n    if (status == RA_CONT)\n\tcontinue;\n\n    \/\/ If the regstack is empty or something failed we are done.\n    if (regstack.ga_len == 0 || status == RA_FAIL)\n    {\n\tif (scan == NULL)\n\t{\n\t    \/\/ We get here only if there's trouble -- normally \"case END\" is\n\t    \/\/ the terminating point.\n\t    iemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\t    printf(\"Premature EOL\\n\");\n#endif\n\t}\n\treturn (status == RA_MATCH);\n    }\n\n  } \/\/ End of loop until the regstack is empty.\n\n  \/\/ NOTREACHED\n}","target":1,"code_token_length":10890,"total_token_length":11126,"max_tokens_setting":28000}
+{"idx":196805,"func":"mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)\n{\n  \/* mrb_assert(MRB_PROC_CFUNC_P(proc)) *\/\n  const mrb_irep *irep = proc->body.irep;\n  const mrb_pool_value *pool = irep->pool;\n  const mrb_sym *syms = irep->syms;\n  mrb_code insn;\n  int ai = mrb_gc_arena_save(mrb);\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf c_jmp;\n  uint32_t a;\n  uint16_t b;\n  uint16_t c;\n  mrb_sym mid;\n  const struct mrb_irep_catch_handler *ch;\n\n#ifdef DIRECT_THREADED\n  static const void * const optable[] = {\n#define OPCODE(x,_) &&L_OP_ ## x,\n#include \"mruby\/ops.h\"\n#undef OPCODE\n  };\n#endif\n\n  mrb_bool exc_catched = FALSE;\nRETRY_TRY_BLOCK:\n\n  MRB_TRY(&c_jmp) {\n\n  if (exc_catched) {\n    exc_catched = FALSE;\n    mrb_gc_arena_restore(mrb, ai);\n    if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)\n      goto L_BREAK;\n    goto L_RAISE;\n  }\n  mrb->jmp = &c_jmp;\n  mrb_vm_ci_proc_set(mrb->c->ci, proc);\n\n#define regs (mrb->c->ci->stack)\n  INIT_DISPATCH {\n    CASE(OP_NOP, Z) {\n      \/* do nothing *\/\n      NEXT;\n    }\n\n    CASE(OP_MOVE, BB) {\n      regs[a] = regs[b];\n      NEXT;\n    }\n\n    CASE(OP_LOADL, BB) {\n      switch (pool[b].tt) {   \/* number *\/\n      case IREP_TT_INT32:\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);\n        break;\n      case IREP_TT_INT64:\n#if defined(MRB_INT64)\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n        break;\n#else\n#if defined(MRB_64BIT)\n        if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {\n          regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n          break;\n        }\n#endif\n        goto L_INT_OVERFLOW;\n#endif\n      case IREP_TT_BIGINT:\n        goto L_INT_OVERFLOW;\n#ifndef MRB_NO_FLOAT\n      case IREP_TT_FLOAT:\n        regs[a] = mrb_float_value(mrb, pool[b].u.f);\n        break;\n#endif\n      default:\n        \/* should not happen (tt:string) *\/\n        regs[a] = mrb_nil_value();\n        break;\n      }\n      NEXT;\n    }\n\n    CASE(OP_LOADI, BB) {\n      SET_FIXNUM_VALUE(regs[a], b);\n      NEXT;\n    }\n\n    CASE(OP_LOADINEG, BB) {\n      SET_FIXNUM_VALUE(regs[a], -b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI__1,B) goto L_LOADI;\n    CASE(OP_LOADI_0,B) goto L_LOADI;\n    CASE(OP_LOADI_1,B) goto L_LOADI;\n    CASE(OP_LOADI_2,B) goto L_LOADI;\n    CASE(OP_LOADI_3,B) goto L_LOADI;\n    CASE(OP_LOADI_4,B) goto L_LOADI;\n    CASE(OP_LOADI_5,B) goto L_LOADI;\n    CASE(OP_LOADI_6,B) goto L_LOADI;\n    CASE(OP_LOADI_7, B) {\n    L_LOADI:\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);\n      NEXT;\n    }\n\n    CASE(OP_LOADI16, BS) {\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI32, BSS) {\n      SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));\n      NEXT;\n    }\n\n    CASE(OP_LOADSYM, BB) {\n      SET_SYM_VALUE(regs[a], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_LOADNIL, B) {\n      SET_NIL_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADSELF, B) {\n      regs[a] = regs[0];\n      NEXT;\n    }\n\n    CASE(OP_LOADT, B) {\n      SET_TRUE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADF, B) {\n      SET_FALSE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETGV, BB) {\n      mrb_value val = mrb_gv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETGV, BB) {\n      mrb_gv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETSV, BB) {\n      mrb_value val = mrb_vm_special_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETSV, BB) {\n      mrb_vm_special_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIV, BB) {\n      regs[a] = mrb_iv_get(mrb, regs[0], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETIV, BB) {\n      mrb_iv_set(mrb, regs[0], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETCV, BB) {\n      mrb_value val;\n      val = mrb_vm_cv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETCV, BB) {\n      mrb_vm_cv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIDX, B) {\n      mrb_value va = regs[a], vb = regs[a+1];\n      switch (mrb_type(va)) {\n      case MRB_TT_ARRAY:\n        if (!mrb_integer_p(vb)) goto getidx_fallback;\n        regs[a] = mrb_ary_entry(va, mrb_integer(vb));\n        break;\n      case MRB_TT_HASH:\n        regs[a] = mrb_hash_get(mrb, va, vb);\n        break;\n      case MRB_TT_STRING:\n        switch (mrb_type(vb)) {\n        case MRB_TT_INTEGER:\n        case MRB_TT_STRING:\n        case MRB_TT_RANGE:\n          regs[a] = mrb_str_aref(mrb, va, vb, mrb_undef_value());\n          break;\n        default:\n          goto getidx_fallback;\n        }\n        break;\n      default:\n      getidx_fallback:\n        mid = MRB_OPSYM(aref);\n        goto L_SEND_SYM;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETIDX, B) {\n      c = 2;\n      mid = MRB_OPSYM(aset);\n      SET_NIL_VALUE(regs[a+3]);\n      goto L_SENDB_SYM;\n    }\n\n    CASE(OP_GETCONST, BB) {\n      regs[a] = mrb_vm_const_get(mrb, syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETCONST, BB) {\n      mrb_vm_const_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETMCNST, BB) {\n      regs[a] = mrb_const_get(mrb, regs[a], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETMCNST, BB) {\n      mrb_const_set(mrb, regs[a+1], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETUPVAR, BBB) {\n      mrb_value *regs_a = regs + a;\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e && b < MRB_ENV_LEN(e)) {\n        *regs_a = e->stack[b];\n      }\n      else {\n        *regs_a = mrb_nil_value();\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETUPVAR, BBB) {\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e) {\n        mrb_value *regs_a = regs + a;\n\n        if (b < MRB_ENV_LEN(e)) {\n          e->stack[b] = *regs_a;\n          mrb_write_barrier(mrb, (struct RBasic*)e);\n        }\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMP, S) {\n      pc += (int16_t)a;\n      JUMP;\n    }\n    CASE(OP_JMPIF, BS) {\n      if (mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNOT, BS) {\n      if (!mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNIL, BS) {\n      if (mrb_nil_p(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMPUW, S) {\n      a = (uint32_t)((pc - irep->iseq) + (int16_t)a);\n      CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {\n        struct RBreak *brk = (struct RBreak*)mrb->exc;\n        mrb_value target = mrb_break_value_get(brk);\n        mrb_assert(mrb_integer_p(target));\n        a = (uint32_t)mrb_integer(target);\n        mrb_assert(a >= 0 && a < irep->ilen);\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {\n        ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);\n        if (ch) {\n          \/* avoiding a jump from a catch handler into the same handler *\/\n          if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {\n            THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));\n          }\n        }\n      }\n      CHECKPOINT_END(RBREAK_TAG_JUMP);\n\n      mrb->exc = NULL; \/* clear break object *\/\n      pc = irep->iseq + a;\n      JUMP;\n    }\n\n    CASE(OP_EXCEPT, B) {\n      mrb_value exc;\n\n      if (mrb->exc == NULL) {\n        exc = mrb_nil_value();\n      }\n      else {\n        switch (mrb->exc->tt) {\n        case MRB_TT_BREAK:\n        case MRB_TT_EXCEPTION:\n          exc = mrb_obj_value(mrb->exc);\n          break;\n        default:\n          mrb_assert(!\"bad mrb_type\");\n          exc = mrb_nil_value();\n          break;\n        }\n        mrb->exc = NULL;\n      }\n      regs[a] = exc;\n      NEXT;\n    }\n    CASE(OP_RESCUE, BB) {\n      mrb_value exc = regs[a];  \/* exc on stack *\/\n      mrb_value e = regs[b];\n      struct RClass *ec;\n\n      switch (mrb_type(e)) {\n      case MRB_TT_CLASS:\n      case MRB_TT_MODULE:\n        break;\n      default:\n        {\n          mrb_value exc;\n\n          exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                    \"class or module required for rescue clause\");\n          mrb_exc_set(mrb, exc);\n          goto L_RAISE;\n        }\n      }\n      ec = mrb_class_ptr(e);\n      regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));\n      NEXT;\n    }\n\n    CASE(OP_RAISEIF, B) {\n      mrb_value exc = regs[a];\n      if (mrb_break_p(exc)) {\n        mrb->exc = mrb_obj_ptr(exc);\n        goto L_BREAK;\n      }\n      mrb_exc_set(mrb, exc);\n      if (mrb->exc) {\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SSEND, BBB) {\n      regs[a] = regs[0];\n      insn = OP_SEND;\n    }\n    goto L_SENDB;\n\n    CASE(OP_SSENDB, BBB) {\n      regs[a] = regs[0];\n    }\n    goto L_SENDB;\n\n    CASE(OP_SEND, BBB)\n    goto L_SENDB;\n\n    L_SEND_SYM:\n    c = 1;\n    \/* push nil after arguments *\/\n    SET_NIL_VALUE(regs[a+2]);\n    goto L_SENDB_SYM;\n\n    CASE(OP_SENDB, BBB)\n    L_SENDB:\n    mid = syms[b];\n    L_SENDB_SYM:\n    {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_value recv, blk;\n\n      ARGUMENT_NORMALIZE(a, &c, insn);\n\n      recv = regs[a];\n      cls = mrb_class(mrb, recv);\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, c);\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        if (MRB_METHOD_PROC_P(m)) {\n          struct RProc *p = MRB_METHOD_PROC(m);\n\n          mrb_vm_ci_proc_set(ci, p);\n          recv = p->body.func(mrb, recv);\n        }\n        else {\n          if (MRB_METHOD_NOARG_P(m)) {\n            check_method_noarg(mrb, ci);\n          }\n          recv = MRB_METHOD_FUNC(m)(mrb, recv);\n        }\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n          if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n        if (!ci->u.target_class) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return recv;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        ci->stack[0] = recv;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n    }\n    JUMP;\n\n    CASE(OP_CALL, Z) {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv = ci->stack[0];\n      struct RProc *m = mrb_proc_ptr(recv);\n\n      \/* replace callinfo *\/\n      ci->u.target_class = MRB_PROC_TARGET_CLASS(m);\n      mrb_vm_ci_proc_set(ci, m);\n      if (MRB_PROC_ENV_P(m)) {\n        ci->mid = MRB_PROC_ENV(m)->mid;\n      }\n\n      \/* prepare stack *\/\n      if (MRB_PROC_CFUNC_P(m)) {\n        recv = MRB_PROC_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n        ci[1].stack[0] = recv;\n        irep = mrb->c->ci->proc->body.irep;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        proc = m;\n        irep = m->body.irep;\n        if (!irep) {\n          mrb->c->ci->stack[0] = mrb_nil_value();\n          a = 0;\n          c = OP_R_NORMAL;\n          goto L_OP_RETURN_BODY;\n        }\n        mrb_int nargs = mrb_ci_bidx(ci)+1;\n        if (nargs < irep->nregs) {\n          mrb_stack_extend(mrb, irep->nregs);\n          stack_clear(regs+nargs, irep->nregs-nargs);\n        }\n        if (MRB_PROC_ENV_P(m)) {\n          regs[0] = MRB_PROC_ENV(m)->stack[0];\n        }\n        pc = irep->iseq;\n      }\n      pool = irep->pool;\n      syms = irep->syms;\n      JUMP;\n    }\n\n    CASE(OP_SUPER, BB) {\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv, blk;\n      const struct RProc *p = ci->proc;\n      mrb_sym mid = ci->mid;\n      struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);\n\n      if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { \/* alias support *\/\n        mid = p->e.env->mid;    \/* restore old mid *\/\n      }\n\n      if (mid == 0 || !target_class) {\n        mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {\n        target_class = mrb_vm_ci_target_class(ci);\n      }\n      else if (target_class->tt == MRB_TT_MODULE) {\n        target_class = mrb_vm_ci_target_class(ci);\n        if (target_class->tt != MRB_TT_ICLASS) {\n          goto super_typeerror;\n        }\n      }\n      recv = regs[0];\n      if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {\n      super_typeerror: ;\n        mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                            \"self has wrong type to call super in this context\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n\n      ARGUMENT_NORMALIZE(a, &b, OP_SUPER);\n\n      cls = target_class->super;\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, b);\n\n      \/* prepare stack *\/\n      ci->stack[0] = recv;\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        mrb_value v;\n\n        if (MRB_METHOD_PROC_P(m)) {\n          mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n        }\n        v = MRB_METHOD_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_restore(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        mrb_assert(!mrb_break_p(v));\n        if (!mrb_vm_ci_target_class(ci)) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return v;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        mrb->c->ci->stack[0] = v;\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n      JUMP;\n    }\n\n    CASE(OP_ARGARY, BS) {\n      mrb_int m1 = (b>>11)&0x3f;\n      mrb_int r  = (b>>10)&0x1;\n      mrb_int m2 = (b>>5)&0x1f;\n      mrb_int kd = (b>>4)&0x1;\n      mrb_int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {\n        mrb_value exc;\n\n      L_NOSUPER:\n        exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e) goto L_NOSUPER;\n        if (MRB_ENV_LEN(e) <= m1+r+m2+1)\n          goto L_NOSUPER;\n        stack = e->stack + 1;\n      }\n      if (r == 0) {\n        regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack);\n      }\n      else {\n        mrb_value *pp = NULL;\n        struct RArray *rest;\n        mrb_int len = 0;\n\n        if (mrb_array_p(stack[m1])) {\n          struct RArray *ary = mrb_ary_ptr(stack[m1]);\n\n          pp = ARY_PTR(ary);\n          len = ARY_LEN(ary);\n        }\n        regs[a] = mrb_ary_new_capa(mrb, m1+len+m2);\n        rest = mrb_ary_ptr(regs[a]);\n        if (m1 > 0) {\n          stack_copy(ARY_PTR(rest), stack, m1);\n        }\n        if (len > 0) {\n          stack_copy(ARY_PTR(rest)+m1, pp, len);\n        }\n        if (m2 > 0) {\n          stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2);\n        }\n        ARY_SET_LEN(rest, m1+len+m2);\n      }\n      if (kd) {\n        regs[a+1] = stack[m1+r+m2];\n        regs[a+2] = stack[m1+r+m2+1];\n      }\n      else {\n        regs[a+1] = stack[m1+r+m2];\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ENTER, W) {\n      mrb_int m1 = MRB_ASPEC_REQ(a);\n      mrb_int o  = MRB_ASPEC_OPT(a);\n      mrb_int r  = MRB_ASPEC_REST(a);\n      mrb_int m2 = MRB_ASPEC_POST(a);\n      mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;\n      \/* unused\n      int b  = MRB_ASPEC_BLOCK(a);\n      *\/\n      mrb_int const len = m1 + o + r + m2;\n\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_int argc = ci->n;\n      mrb_value *argv = regs+1;\n      mrb_value * const argv0 = argv;\n      mrb_int const kw_pos = len + kd;    \/* where kwhash should be *\/\n      mrb_int const blk_pos = kw_pos + 1; \/* where block should be *\/\n      mrb_value blk = regs[mrb_ci_bidx(ci)];\n      mrb_value kdict = mrb_nil_value();\n\n      \/* keyword arguments *\/\n      if (ci->nk > 0) {\n        mrb_int kidx = mrb_ci_kidx(ci);\n        kdict = regs[kidx];\n        if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) {\n          kdict = mrb_nil_value();\n          ci->nk = 0;\n        }\n      }\n      if (!kd && !mrb_nil_p(kdict)) {\n        if (argc < 14) {\n          ci->n++;\n          argc++;    \/* include kdict in normal arguments *\/\n        }\n        else if (argc == 14) {\n          \/* pack arguments and kdict *\/\n          regs[1] = mrb_ary_new_from_values(mrb, argc+1, ®s[1]);\n          argc = ci->n = 15;\n        }\n        else {\/* argc == 15 *\/\n          \/* push kdict to packed arguments *\/\n          mrb_ary_push(mrb, regs[1], regs[2]);\n        }\n        ci->nk = 0;\n      }\n      if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) {\n        kdict = mrb_hash_dup(mrb, kdict);\n      }\n\n      \/* arguments is passed with Array *\/\n      if (argc == 15) {\n        struct RArray *ary = mrb_ary_ptr(regs[1]);\n        argv = ARY_PTR(ary);\n        argc = (int)ARY_LEN(ary);\n        mrb_gc_protect(mrb, regs[1]);\n      }\n\n      \/* strict argument check *\/\n      if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) {\n        if (argc < m1 + m2 || (r == 0 && argc > len)) {\n          argnum_error(mrb, m1+m2);\n          goto L_RAISE;\n        }\n      }\n      \/* extract first argument array to arguments *\/\n      else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) {\n        mrb_gc_protect(mrb, argv[0]);\n        argc = (int)RARRAY_LEN(argv[0]);\n        argv = RARRAY_PTR(argv[0]);\n      }\n\n      \/* rest arguments *\/\n      mrb_value rest = mrb_nil_value();\n      if (argc < len) {\n        mrb_int mlen = m2;\n        if (argc < m1+m2) {\n          mlen = m1 < argc ? argc - m1 : 0;\n        }\n\n        \/* copy mandatory and optional arguments *\/\n        if (argv0 != argv && argv) {\n          value_move(®s[1], argv, argc-mlen); \/* m1 + o *\/\n        }\n        if (argc < m1) {\n          stack_clear(®s[argc+1], m1-argc);\n        }\n        \/* copy post mandatory arguments *\/\n        if (mlen) {\n          value_move(®s[len-m2+1], &argv[argc-mlen], mlen);\n        }\n        if (mlen < m2) {\n          stack_clear(®s[len-m2+mlen+1], m2-mlen);\n        }\n        \/* initialize rest arguments with empty Array *\/\n        if (r) {\n          rest = mrb_ary_new_capa(mrb, 0);\n          regs[m1+o+1] = rest;\n        }\n        \/* skip initializer of passed arguments *\/\n        if (o > 0 && argc > m1+m2)\n          pc += (argc - m1 - m2)*3;\n      }\n      else {\n        mrb_int rnum = 0;\n        if (argv0 != argv) {\n          value_move(®s[1], argv, m1+o);\n        }\n        if (r) {\n          rnum = argc-m1-o-m2;\n          rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o);\n          regs[m1+o+1] = rest;\n        }\n        if (m2 > 0 && argc-m2 > m1) {\n          value_move(®s[m1+o+r+1], &argv[m1+o+rnum], m2);\n        }\n        pc += o*3;\n      }\n\n      \/* need to be update blk first to protect blk from GC *\/\n      regs[blk_pos] = blk;              \/* move block *\/\n      if (kd) {\n        if (mrb_nil_p(kdict))\n          kdict = mrb_hash_new_capa(mrb, 0);\n        regs[kw_pos] = kdict;           \/* set kwhash *\/\n      }\n\n      \/* format arguments for generated code *\/\n      mrb->c->ci->n = len;\n\n      \/* clear local (but non-argument) variables *\/\n      if (irep->nlocals-blk_pos-1 > 0) {\n        stack_clear(®s[blk_pos+1], irep->nlocals-blk_pos-1);\n      }\n      JUMP;\n    }\n\n    CASE(OP_KARG, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n\n      if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) {\n        mrb_value str = mrb_format(mrb, \"missing keyword: %v\", k);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      regs[a] = mrb_hash_get(mrb, kdict, k);\n      mrb_hash_delete_key(mrb, kdict, k);\n      NEXT;\n    }\n\n    CASE(OP_KEY_P, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n      mrb_bool key_p = FALSE;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) {\n        key_p = mrb_hash_key_p(mrb, kdict, k);\n      }\n      regs[a] = mrb_bool_value(key_p);\n      NEXT;\n    }\n\n    CASE(OP_KEYEND, Z) {\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) {\n        mrb_value keys = mrb_hash_keys(mrb, kdict);\n        mrb_value key1 = RARRAY_PTR(keys)[0];\n        mrb_value str = mrb_format(mrb, \"unknown keyword: %v\", key1);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_BREAK, B) {\n      c = OP_R_BREAK;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN_BLK, B) {\n      c = OP_R_RETURN;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN, B)\n    c = OP_R_NORMAL;\n    L_RETURN:\n    {\n      mrb_callinfo *ci;\n\n      ci = mrb->c->ci;\n      if (ci->mid) {\n        mrb_value blk = regs[mrb_ci_bidx(ci)];\n\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n\n          if (!MRB_PROC_STRICT_P(p) &&\n              ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n      }\n\n      if (mrb->exc) {\n      L_RAISE:\n        ci = mrb->c->ci;\n        if (ci == mrb->c->cibase) {\n          ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n          if (ch == NULL) goto L_FTOP;\n          goto L_CATCH;\n        }\n        while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {\n          ci = cipop(mrb);\n          if (ci[1].cci == CINFO_SKIP && prev_jmp) {\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          pc = ci[0].pc;\n          if (ci == mrb->c->cibase) {\n            ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n            if (ch == NULL) {\n            L_FTOP:             \/* fiber top *\/\n              if (mrb->c == mrb->root_c) {\n                mrb->c->ci->stack = mrb->c->stbase;\n                goto L_STOP;\n              }\n              else {\n                struct mrb_context *c = mrb->c;\n\n                c->status = MRB_FIBER_TERMINATED;\n                mrb->c = c->prev;\n                c->prev = NULL;\n                goto L_RAISE;\n              }\n            }\n            break;\n          }\n        }\n      L_CATCH:\n        if (ch == NULL) goto L_STOP;\n        if (FALSE) {\n        L_CATCH_TAGGED_BREAK: \/* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() *\/\n          ci = mrb->c->ci;\n        }\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, irep->nregs);\n        pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);\n      }\n      else {\n        mrb_int acc;\n        mrb_value v;\n\n        ci = mrb->c->ci;\n        v = regs[a];\n        mrb_gc_protect(mrb, v);\n        switch (c) {\n        case OP_R_RETURN:\n          \/* Fall through to OP_R_NORMAL otherwise *\/\n          if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {\n            const struct RProc *dst;\n            mrb_callinfo *cibase;\n            cibase = mrb->c->cibase;\n            dst = top_proc(mrb, proc);\n\n            if (MRB_PROC_ENV_P(dst)) {\n              struct REnv *e = MRB_PROC_ENV(dst);\n\n              if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n            }\n            \/* check jump destination *\/\n            while (cibase <= ci && ci->proc != dst) {\n              if (ci->cci > CINFO_NONE) { \/* jump cross C boundary *\/\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n              ci--;\n            }\n            if (ci <= cibase) { \/* no jump destination *\/\n              localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n              goto L_RAISE;\n            }\n            ci = mrb->c->ci;\n            while (cibase <= ci && ci->proc != dst) {\n              CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {\n                cibase = mrb->c->cibase;\n                dst = top_proc(mrb, proc);\n              }\n              CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {\n                UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);\n              }\n              CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);\n              ci = cipop(mrb);\n              pc = ci->pc;\n            }\n            proc = ci->proc;\n            mrb->exc = NULL; \/* clear break object *\/\n            break;\n          }\n          \/* fallthrough *\/\n        case OP_R_NORMAL:\n        NORMAL_RETURN:\n          if (ci == mrb->c->cibase) {\n            struct mrb_context *c;\n            c = mrb->c;\n\n            if (!c->prev) { \/* toplevel return *\/\n              regs[irep->nlocals] = v;\n              goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);\n            }\n            if (!c->vmexec && c->prev->ci == c->prev->cibase) {\n              mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, \"double resume\");\n              mrb_exc_set(mrb, exc);\n              goto L_RAISE;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {\n              c = mrb->c;\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);\n            \/* automatic yield at the end *\/\n            c->status = MRB_FIBER_TERMINATED;\n            mrb->c = c->prev;\n            mrb->c->status = MRB_FIBER_RUNNING;\n            c->prev = NULL;\n            if (c->vmexec) {\n              mrb_gc_arena_restore(mrb, ai);\n              c->vmexec = FALSE;\n              mrb->jmp = prev_jmp;\n              return v;\n            }\n            ci = mrb->c->ci;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_RETURN);\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        case OP_R_BREAK:\n          if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;\n          if (MRB_PROC_ORPHAN_P(proc)) {\n            mrb_value exc;\n\n          L_BREAK_ERROR:\n            exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,\n                                      \"break from proc-closure\");\n            mrb_exc_set(mrb, exc);\n            goto L_RAISE;\n          }\n          if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {\n            goto L_BREAK_ERROR;\n          }\n          else {\n            struct REnv *e = MRB_PROC_ENV(proc);\n\n            if (e->cxt != mrb->c) {\n              goto L_BREAK_ERROR;\n            }\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK);\n          \/* break from fiber block *\/\n          if (ci == mrb->c->cibase && ci->pc) {\n            struct mrb_context *c = mrb->c;\n\n            mrb->c = c->prev;\n            c->prev = NULL;\n            ci = mrb->c->ci;\n          }\n          if (ci->cci > CINFO_NONE) {\n            ci = cipop(mrb);\n            mrb_gc_arena_restore(mrb, ai);\n            mrb->c->vmexec = FALSE;\n            mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          if (FALSE) {\n            struct RBreak *brk;\n\n          L_BREAK:\n            brk = (struct RBreak*)mrb->exc;\n            proc = mrb_break_proc_get(brk);\n            v = mrb_break_value_get(brk);\n            ci = mrb->c->ci;\n\n            switch (mrb_break_tag_get(brk)) {\n#define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);\n              RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)\n#undef DISPATCH_CHECKPOINTS\n              default:\n                mrb_assert(!\"wrong break tag\");\n            }\n          }\n          while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {\n            if (ci[-1].cci == CINFO_SKIP) {\n              goto L_BREAK_ERROR;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {\n              \/* do nothing *\/\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);\n            ci = cipop(mrb);\n            pc = ci->pc;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);\n          if (ci == mrb->c->cibase) {\n            goto L_BREAK_ERROR;\n          }\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        default:\n          \/* cannot happen *\/\n          break;\n        }\n        mrb_assert(ci == mrb->c->ci);\n        mrb_assert(mrb->exc == NULL);\n\n        if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->c->vmexec = FALSE;\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        acc = ci->cci;\n        ci = cipop(mrb);\n        if (acc == CINFO_SKIP || acc == CINFO_DIRECT) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        pc = ci->pc;\n        DEBUG(fprintf(stderr, \"from :%s\\n\", mrb_sym_name(mrb, ci->mid)));\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n\n        ci[1].stack[0] = v;\n        mrb_gc_arena_restore(mrb, ai);\n      }\n      JUMP;\n    }\n\n    CASE(OP_BLKPUSH, BS) {\n      int m1 = (b>>11)&0x3f;\n      int r  = (b>>10)&0x1;\n      int m2 = (b>>5)&0x1f;\n      int kd = (b>>4)&0x1;\n      int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||\n            MRB_ENV_LEN(e) <= m1+r+m2+1) {\n          localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n          goto L_RAISE;\n        }\n        stack = e->stack + 1;\n      }\n      if (mrb_nil_p(stack[m1+r+m2+kd])) {\n        localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n        goto L_RAISE;\n      }\n      regs[a] = stack[m1+r+m2+kd];\n      NEXT;\n    }\n\n  L_INT_OVERFLOW:\n    {\n      mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, \"integer overflow\");\n      mrb_exc_set(mrb, exc);\n    }\n    goto L_RAISE;\n\n#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))\n#define OP_MATH(op_name)                                                    \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {                  \\\n    OP_MATH_CASE_INTEGER(op_name);                                          \\\n    OP_MATH_CASE_FLOAT(op_name, integer, float);                            \\\n    OP_MATH_CASE_FLOAT(op_name, float,  integer);                           \\\n    OP_MATH_CASE_FLOAT(op_name, float,  float);                             \\\n    OP_MATH_CASE_STRING_##op_name();                                        \\\n    default:                                                                \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATH_CASE_INTEGER(op_name)                                       \\\n  case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER):                              \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z;      \\\n      if (mrb_int_##op_name##_overflow(x, y, &z))                           \\\n        OP_MATH_OVERFLOW_INT();                                             \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0\n#else\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2)                                     \\\n  case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2):                                \\\n    {                                                                           \\\n      mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                         \\\n    }                                                                           \\\n    break\n#endif\n#define OP_MATH_OVERFLOW_INT() goto L_INT_OVERFLOW\n#define OP_MATH_CASE_STRING_add()                                           \\\n  case TYPES2(MRB_TT_STRING, MRB_TT_STRING):                                \\\n    regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]);                        \\\n    mrb_gc_arena_restore(mrb, ai);                                          \\\n    break\n#define OP_MATH_CASE_STRING_sub() (void)0\n#define OP_MATH_CASE_STRING_mul() (void)0\n#define OP_MATH_OP_add +\n#define OP_MATH_OP_sub -\n#define OP_MATH_OP_mul *\n#define OP_MATH_TT_integer MRB_TT_INTEGER\n#define OP_MATH_TT_float   MRB_TT_FLOAT\n\n    CASE(OP_ADD, B) {\n      OP_MATH(add);\n    }\n\n    CASE(OP_SUB, B) {\n      OP_MATH(sub);\n    }\n\n    CASE(OP_MUL, B) {\n      OP_MATH(mul);\n    }\n\n    CASE(OP_DIV, B) {\n#ifndef MRB_NO_FLOAT\n      mrb_float x, y, f;\n#endif\n\n      \/* need to check if op is overridden *\/\n      switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\n        {\n          mrb_int x = mrb_integer(regs[a]);\n          mrb_int y = mrb_integer(regs[a+1]);\n          mrb_int div = mrb_div_int(mrb, x, y);\n          SET_INT_VALUE(mrb, regs[a], div);\n        }\n        NEXT;\n#ifndef MRB_NO_FLOAT\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\n        x = (mrb_float)mrb_integer(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\n        x = mrb_float(regs[a]);\n        y = (mrb_float)mrb_integer(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\n        x = mrb_float(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n#endif\n      default:\n        mid = MRB_OPSYM(div);\n        goto L_SEND_SYM;\n      }\n\n#ifndef MRB_NO_FLOAT\n      f = mrb_div_float(x, y);\n      SET_FLOAT_VALUE(mrb, regs[a], f);\n#endif\n      NEXT;\n    }\n\n#define OP_MATHI(op_name)                                                   \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (mrb_type(regs[a])) {                                              \\\n    OP_MATHI_CASE_INTEGER(op_name);                                         \\\n    OP_MATHI_CASE_FLOAT(op_name);                                           \\\n    default:                                                                \\\n      SET_INT_VALUE(mrb,regs[a+1], b);                                      \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATHI_CASE_INTEGER(op_name)                                      \\\n  case MRB_TT_INTEGER:                                                      \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z;                  \\\n      if (mrb_int_##op_name##_overflow(x, y, &z))                           \\\n        OP_MATH_OVERFLOW_INT();                                             \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATHI_CASE_FLOAT(op_name) (void)0\n#else\n#define OP_MATHI_CASE_FLOAT(op_name)                                        \\\n  case MRB_TT_FLOAT:                                                        \\\n    {                                                                       \\\n      mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b;              \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                     \\\n    }                                                                       \\\n    break\n#endif\n\n    CASE(OP_ADDI, BB) {\n      OP_MATHI(add);\n    }\n\n    CASE(OP_SUBI, BB) {\n      OP_MATHI(sub);\n    }\n\n#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))\n\n#ifdef MRB_NO_FLOAT\n#define OP_CMP(op,sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#else\n#define OP_CMP(op, sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_float);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#endif\n\n    CASE(OP_EQ, B) {\n      if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {\n        SET_TRUE_VALUE(regs[a]);\n      }\n      else {\n        OP_CMP(==,eq);\n      }\n      NEXT;\n    }\n\n    CASE(OP_LT, B) {\n      OP_CMP(<,lt);\n      NEXT;\n    }\n\n    CASE(OP_LE, B) {\n      OP_CMP(<=,le);\n      NEXT;\n    }\n\n    CASE(OP_GT, B) {\n      OP_CMP(>,gt);\n      NEXT;\n    }\n\n    CASE(OP_GE, B) {\n      OP_CMP(>=,ge);\n      NEXT;\n    }\n\n    CASE(OP_ARRAY, BB) {\n      regs[a] = mrb_ary_new_from_values(mrb, b, ®s[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_ARRAY2, BBB) {\n      regs[a] = mrb_ary_new_from_values(mrb, c, ®s[b]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYCAT, B) {\n      mrb_value splat = mrb_ary_splat(mrb, regs[a+1]);\n      if (mrb_nil_p(regs[a])) {\n        regs[a] = splat;\n      }\n      else {\n        mrb_assert(mrb_array_p(regs[a]));\n        mrb_ary_concat(mrb, regs[a], splat);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYPUSH, BB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      for (mrb_int i=0; i<b; i++) {\n        mrb_ary_push(mrb, regs[a], regs[a+i+1]);\n      }\n      NEXT;\n    }\n\n    CASE(OP_ARYDUP, B) {\n      mrb_value ary = regs[a];\n      if (mrb_array_p(ary)) {\n        ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));\n      }\n      else {\n        ary = mrb_ary_new_from_values(mrb, 1, &ary);\n      }\n      regs[a] = ary;\n      NEXT;\n    }\n\n    CASE(OP_AREF, BBB) {\n      mrb_value v = regs[b];\n\n      if (!mrb_array_p(v)) {\n        if (c == 0) {\n          regs[a] = v;\n        }\n        else {\n          SET_NIL_VALUE(regs[a]);\n        }\n      }\n      else {\n        v = mrb_ary_ref(mrb, v, c);\n        regs[a] = v;\n      }\n      NEXT;\n    }\n\n    CASE(OP_ASET, BBB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      mrb_ary_set(mrb, regs[b], c, regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_APOST, BBB) {\n      mrb_value v = regs[a];\n      int pre  = b;\n      int post = c;\n      struct RArray *ary;\n      int len, idx;\n\n      if (!mrb_array_p(v)) {\n        v = mrb_ary_new_from_values(mrb, 1, ®s[a]);\n      }\n      ary = mrb_ary_ptr(v);\n      len = (int)ARY_LEN(ary);\n      if (len > pre + post) {\n        v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre);\n        regs[a++] = v;\n        while (post--) {\n          regs[a++] = ARY_PTR(ary)[len-post-1];\n        }\n      }\n      else {\n        v = mrb_ary_new_capa(mrb, 0);\n        regs[a++] = v;\n        for (idx=0; idx+pre<len; idx++) {\n          regs[a+idx] = ARY_PTR(ary)[pre+idx];\n        }\n        while (idx < post) {\n          SET_NIL_VALUE(regs[a+idx]);\n          idx++;\n        }\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_INTERN, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_sym sym = mrb_intern_str(mrb, regs[a]);\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_SYMBOL, BB) {\n      size_t len;\n      mrb_sym sym;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        sym = mrb_intern_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        sym  = mrb_intern(mrb, pool[b].u.str, len);\n      }\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_STRING, BB) {\n      mrb_int len;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        regs[a] = mrb_str_new(mrb, pool[b].u.str, len);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_STRCAT, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_str_concat(mrb, regs[a], regs[a+1]);\n      NEXT;\n    }\n\n    CASE(OP_HASH, BB) {\n      mrb_value hash = mrb_hash_new_capa(mrb, b);\n      int i;\n      int lim = a+b*2;\n\n      for (i=a; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      regs[a] = hash;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_HASHADD, BB) {\n      mrb_value hash;\n      int i;\n      int lim = a+b*2+1;\n\n      hash = regs[a];\n      mrb_ensure_hash_type(mrb, hash);\n      for (i=a+1; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_HASHCAT, B) {\n      mrb_value hash = regs[a];\n\n      mrb_assert(mrb_hash_p(hash));\n      mrb_hash_merge(mrb, hash, regs[a+1]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_LAMBDA, BB)\n    c = OP_L_LAMBDA;\n    L_MAKE_LAMBDA:\n    {\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      if (c & OP_L_CAPTURE) {\n        p = mrb_closure_new(mrb, nirep);\n      }\n      else {\n        p = mrb_proc_new(mrb, nirep);\n        p->flags |= MRB_PROC_SCOPE;\n      }\n      if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;\n      regs[a] = mrb_obj_value(p);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_BLOCK, BB) {\n      c = OP_L_BLOCK;\n      goto L_MAKE_LAMBDA;\n    }\n    CASE(OP_METHOD, BB) {\n      c = OP_L_METHOD;\n      goto L_MAKE_LAMBDA;\n    }\n\n    CASE(OP_RANGE_INC, B) {\n      regs[a] = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_RANGE_EXC, B) {\n      regs[a] = mrb_range_new(mrb, regs[a], regs[a+1], TRUE);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_OCLASS, B) {\n      regs[a] = mrb_obj_value(mrb->object_class);\n      NEXT;\n    }\n\n    CASE(OP_CLASS, BB) {\n      struct RClass *c = 0, *baseclass;\n      mrb_value base, super;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      super = regs[a+1];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      c = mrb_vm_define_class(mrb, base, super, id);\n      regs[a] = mrb_obj_value(c);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_MODULE, BB) {\n      struct RClass *cls = 0, *baseclass;\n      mrb_value base;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      cls = mrb_vm_define_module(mrb, base, id);\n      regs[a] = mrb_obj_value(cls);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_EXEC, BB)\n    {\n      mrb_value recv = regs[a];\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      \/* prepare closure *\/\n      p = mrb_proc_new(mrb, nirep);\n      p->c = NULL;\n      mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc);\n      MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv));\n      p->flags |= MRB_PROC_SCOPE;\n\n      \/* prepare call stack *\/\n      cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0);\n\n      irep = p->body.irep;\n      pool = irep->pool;\n      syms = irep->syms;\n      mrb_stack_extend(mrb, irep->nregs);\n      stack_clear(regs+1, irep->nregs-1);\n      pc = irep->iseq;\n      JUMP;\n    }\n\n    CASE(OP_DEF, BB) {\n      struct RClass *target = mrb_class_ptr(regs[a]);\n      struct RProc *p = mrb_proc_ptr(regs[a+1]);\n      mrb_method_t m;\n      mrb_sym mid = syms[b];\n\n      MRB_METHOD_FROM_PROC(m, p);\n      mrb_define_method_raw(mrb, target, mid, m);\n      mrb_method_added(mrb, target, mid);\n      mrb_gc_arena_restore(mrb, ai);\n      regs[a] = mrb_symbol_value(mid);\n      NEXT;\n    }\n\n    CASE(OP_SCLASS, B) {\n      regs[a] = mrb_singleton_class(mrb, regs[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_TCLASS, B) {\n      struct RClass *target = check_target_class(mrb);\n      if (!target) goto L_RAISE;\n      regs[a] = mrb_obj_value(target);\n      NEXT;\n    }\n\n    CASE(OP_ALIAS, BB) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_alias_method(mrb, target, syms[a], syms[b]);\n      mrb_method_added(mrb, target, syms[a]);\n      NEXT;\n    }\n    CASE(OP_UNDEF, B) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_undef_method_id(mrb, target, syms[a]);\n      NEXT;\n    }\n\n    CASE(OP_DEBUG, Z) {\n      FETCH_BBB();\n#ifdef MRB_USE_DEBUG_HOOK\n      mrb->debug_op_hook(mrb, irep, pc, regs);\n#else\n#ifndef MRB_NO_STDIO\n      printf(\"OP_DEBUG %d %d %d\\n\", a, b, c);\n#else\n      abort();\n#endif\n#endif\n      NEXT;\n    }\n\n    CASE(OP_ERR, B) {\n      size_t len = pool[a].tt >> 2;\n      mrb_value exc;\n\n      mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);\n      exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);\n      mrb_exc_set(mrb, exc);\n      goto L_RAISE;\n    }\n\n    CASE(OP_EXT1, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT2, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT3, Z) {\n      uint8_t insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n\n    CASE(OP_STOP, Z) {\n      \/*        stop VM *\/\n      CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {\n        \/* do nothing *\/\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_STOP) {\n        UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());\n      }\n      CHECKPOINT_END(RBREAK_TAG_STOP);\n    L_STOP:\n      mrb->jmp = prev_jmp;\n      if (mrb->exc) {\n        mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);\n        return mrb_obj_value(mrb->exc);\n      }\n      return regs[irep->nlocals];\n    }\n  }\n  END_DISPATCH;\n#undef regs\n  }\n  MRB_CATCH(&c_jmp) {\n    mrb_callinfo *ci = mrb->c->ci;\n    while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) {\n      ci = cipop(mrb);\n    }\n    exc_catched = TRUE;\n    pc = ci->pc;\n    goto RETRY_TRY_BLOCK;\n  }\n  MRB_END_EXC(&c_jmp);\n}","target":1,"code_token_length":14480,"total_token_length":14716,"max_tokens_setting":28000}
+{"idx":458923,"func":"get_c_indent(void)\n{\n    pos_T\tcur_curpos;\n    int\t\tamount;\n    int\t\tscope_amount;\n    int\t\tcur_amount = MAXCOL;\n    colnr_T\tcol;\n    char_u\t*theline;\n    char_u\t*linecopy;\n    pos_T\t*trypos;\n    pos_T\t*comment_pos;\n    pos_T\t*tryposBrace = NULL;\n    pos_T\ttryposCopy;\n    pos_T\tour_paren_pos;\n    char_u\t*start;\n    int\t\tstart_brace;\n#define BRACE_IN_COL0\t\t1\t    \/\/ '{' is in column 0\n#define BRACE_AT_START\t\t2\t    \/\/ '{' is at start of line\n#define BRACE_AT_END\t\t3\t    \/\/ '{' is at end of line\n    linenr_T\tourscope;\n    char_u\t*l;\n    char_u\t*look;\n    char_u\tterminated;\n    int\t\tlookfor;\n    int\t\twhilelevel;\n    linenr_T\tlnum;\n    int\t\tn;\n    int\t\tiscase;\n    int\t\tlookfor_break;\n    int\t\tlookfor_cpp_namespace = FALSE;\n    int\t\tcont_amount = 0;    \/\/ amount for continuation line\n    int\t\toriginal_line_islabel;\n    int\t\tadded_to_amount = 0;\n    int\t\tjs_cur_has_key = 0;\n    linenr_T\traw_string_start = 0;\n    cpp_baseclass_cache_T cache_cpp_baseclass = { FALSE, { MAXLNUM, 0 } };\n\n    \/\/ make a copy, value is changed below\n    int\t\tind_continuation = curbuf->b_ind_continuation;\n\n    \/\/ remember where the cursor was when we started\n    cur_curpos = curwin->w_cursor;\n\n    \/\/ if we are at line 1 zero indent is fine, right?\n    if (cur_curpos.lnum == 1)\n\treturn 0;\n\n    \/\/ Get a copy of the current contents of the line.\n    \/\/ This is required, because only the most recent line obtained with\n    \/\/ ml_get is valid!\n    linecopy = vim_strsave(ml_get(cur_curpos.lnum));\n    if (linecopy == NULL)\n\treturn 0;\n\n    \/\/ In insert mode and the cursor is on a ')' truncate the line at the\n    \/\/ cursor position.  We don't want to line up with the matching '(' when\n    \/\/ inserting new stuff.\n    \/\/ For unknown reasons the cursor might be past the end of the line, thus\n    \/\/ check for that.\n    if ((State & INSERT)\n\t    && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy)\n\t    && linecopy[curwin->w_cursor.col] == ')')\n\tlinecopy[curwin->w_cursor.col] = NUL;\n\n    theline = skipwhite(linecopy);\n\n    \/\/ move the cursor to the start of the line\n\n    curwin->w_cursor.col = 0;\n\n    original_line_islabel = cin_islabel();  \/\/ XXX\n\n    \/\/ If we are inside a raw string don't change the indent.\n    \/\/ Ignore a raw string inside a comment.\n    comment_pos = ind_find_start_comment();\n    if (comment_pos != NULL)\n    {\n\t\/\/ findmatchlimit() static pos is overwritten, make a copy\n\ttryposCopy = *comment_pos;\n\tcomment_pos = &tryposCopy;\n    }\n    trypos = find_start_rawstring(curbuf->b_ind_maxcomment);\n    if (trypos != NULL && (comment_pos == NULL\n\t\t\t\t\t     || LT_POS(*trypos, *comment_pos)))\n    {\n\tamount = -1;\n\tgoto laterend;\n    }\n\n    \/\/ #defines and so on go at the left when included in 'cinkeys',\n    \/\/ excluding pragmas when customized in 'cinoptions'\n    if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE)))\n    {\n\tchar_u *directive = skipwhite(theline + 1);\n\tif (curbuf->b_ind_pragma == 0 || STRNCMP(directive, \"pragma\", 6) != 0)\n\t{\n\t    amount = curbuf->b_ind_hash_comment;\n\t    goto theend;\n\t}\n    }\n\n    \/\/ Is it a non-case label?\tThen that goes at the left margin too unless:\n    \/\/  - JS flag is set.\n    \/\/  - 'L' item has a positive value.\n    if (original_line_islabel && !curbuf->b_ind_js\n\t\t\t\t\t      && curbuf->b_ind_jump_label < 0)\n    {\n\tamount = 0;\n\tgoto theend;\n    }\n\n    \/\/ If we're inside a \"\/\/\" comment and there is a \"\/\/\" comment in a\n    \/\/ previous line, lineup with that one.\n    if (cin_islinecomment(theline)\n\t    && (trypos = find_line_comment()) != NULL) \/\/ XXX\n    {\n\t\/\/ find how indented the line beginning the comment is\n\tgetvcol(curwin, trypos, &col, NULL, NULL);\n\tamount = col;\n\tgoto theend;\n    }\n\n    \/\/ If we're inside a comment and not looking at the start of the\n    \/\/ comment, try using the 'comments' option.\n    if (!cin_iscomment(theline) && comment_pos != NULL) \/\/ XXX\n    {\n\tint\tlead_start_len = 2;\n\tint\tlead_middle_len = 1;\n\tchar_u\tlead_start[COM_MAX_LEN];\t\/\/ start-comment string\n\tchar_u\tlead_middle[COM_MAX_LEN];\t\/\/ middle-comment string\n\tchar_u\tlead_end[COM_MAX_LEN];\t\t\/\/ end-comment string\n\tchar_u\t*p;\n\tint\tstart_align = 0;\n\tint\tstart_off = 0;\n\tint\tdone = FALSE;\n\n\t\/\/ find how indented the line beginning the comment is\n\tgetvcol(curwin, comment_pos, &col, NULL, NULL);\n\tamount = col;\n\t*lead_start = NUL;\n\t*lead_middle = NUL;\n\n\tp = curbuf->b_p_com;\n\twhile (*p != NUL)\n\t{\n\t    int\talign = 0;\n\t    int\toff = 0;\n\t    int what = 0;\n\n\t    while (*p != NUL && *p != ':')\n\t    {\n\t\tif (*p == COM_START || *p == COM_END || *p == COM_MIDDLE)\n\t\t    what = *p++;\n\t\telse if (*p == COM_LEFT || *p == COM_RIGHT)\n\t\t    align = *p++;\n\t\telse if (VIM_ISDIGIT(*p) || *p == '-')\n\t\t    off = getdigits(&p);\n\t\telse\n\t\t    ++p;\n\t    }\n\n\t    if (*p == ':')\n\t\t++p;\n\t    (void)copy_option_part(&p, lead_end, COM_MAX_LEN, \",\");\n\t    if (what == COM_START)\n\t    {\n\t\tSTRCPY(lead_start, lead_end);\n\t\tlead_start_len = (int)STRLEN(lead_start);\n\t\tstart_off = off;\n\t\tstart_align = align;\n\t    }\n\t    else if (what == COM_MIDDLE)\n\t    {\n\t\tSTRCPY(lead_middle, lead_end);\n\t\tlead_middle_len = (int)STRLEN(lead_middle);\n\t    }\n\t    else if (what == COM_END)\n\t    {\n\t\t\/\/ If our line starts with the middle comment string, line it\n\t\t\/\/ up with the comment opener per the 'comments' option.\n\t\tif (STRNCMP(theline, lead_middle, lead_middle_len) == 0\n\t\t\t&& STRNCMP(theline, lead_end, STRLEN(lead_end)) != 0)\n\t\t{\n\t\t    done = TRUE;\n\t\t    if (curwin->w_cursor.lnum > 1)\n\t\t    {\n\t\t\t\/\/ If the start comment string matches in the previous\n\t\t\t\/\/ line, use the indent of that line plus offset.  If\n\t\t\t\/\/ the middle comment string matches in the previous\n\t\t\t\/\/ line, use the indent of that line.  XXX\n\t\t\tlook = skipwhite(ml_get(curwin->w_cursor.lnum - 1));\n\t\t\tif (STRNCMP(look, lead_start, lead_start_len) == 0)\n\t\t\t    amount = get_indent_lnum(curwin->w_cursor.lnum - 1);\n\t\t\telse if (STRNCMP(look, lead_middle,\n\t\t\t\t\t\t\tlead_middle_len) == 0)\n\t\t\t{\n\t\t\t    amount = get_indent_lnum(curwin->w_cursor.lnum - 1);\n\t\t\t    break;\n\t\t\t}\n\t\t\t\/\/ If the start comment string doesn't match with the\n\t\t\t\/\/ start of the comment, skip this entry.  XXX\n\t\t\telse if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col,\n\t\t\t\t\t     lead_start, lead_start_len) != 0)\n\t\t\t    continue;\n\t\t    }\n\t\t    if (start_off != 0)\n\t\t\tamount += start_off;\n\t\t    else if (start_align == COM_RIGHT)\n\t\t\tamount += vim_strsize(lead_start)\n\t\t\t\t\t\t   - vim_strsize(lead_middle);\n\t\t    break;\n\t\t}\n\n\t\t\/\/ If our line starts with the end comment string, line it up\n\t\t\/\/ with the middle comment\n\t\tif (STRNCMP(theline, lead_middle, lead_middle_len) != 0\n\t\t\t&& STRNCMP(theline, lead_end, STRLEN(lead_end)) == 0)\n\t\t{\n\t\t    amount = get_indent_lnum(curwin->w_cursor.lnum - 1);\n\t\t\t\t\t\t\t\t     \/\/ XXX\n\t\t    if (off != 0)\n\t\t\tamount += off;\n\t\t    else if (align == COM_RIGHT)\n\t\t\tamount += vim_strsize(lead_start)\n\t\t\t\t\t\t   - vim_strsize(lead_middle);\n\t\t    done = TRUE;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n\n\t\/\/ If our line starts with an asterisk, line up with the\n\t\/\/ asterisk in the comment opener; otherwise, line up\n\t\/\/ with the first character of the comment text.\n\tif (done)\n\t    ;\n\telse if (theline[0] == '*')\n\t    amount += 1;\n\telse\n\t{\n\t    \/\/ If we are more than one line away from the comment opener, take\n\t    \/\/ the indent of the previous non-empty line.  If 'cino' has \"CO\"\n\t    \/\/ and we are just below the comment opener and there are any\n\t    \/\/ white characters after it line up with the text after it;\n\t    \/\/ otherwise, add the amount specified by \"c\" in 'cino'\n\t    amount = -1;\n\t    for (lnum = cur_curpos.lnum - 1; lnum > comment_pos->lnum; --lnum)\n\t    {\n\t\tif (linewhite(lnum))\t\t    \/\/ skip blank lines\n\t\t    continue;\n\t\tamount = get_indent_lnum(lnum);\t    \/\/ XXX\n\t\tbreak;\n\t    }\n\t    if (amount == -1)\t\t\t    \/\/ use the comment opener\n\t    {\n\t\tif (!curbuf->b_ind_in_comment2)\n\t\t{\n\t\t    start = ml_get(comment_pos->lnum);\n\t\t    look = start + comment_pos->col + 2; \/\/ skip \/ and *\n\t\t    if (*look != NUL)\t\t    \/\/ if something after it\n\t\t\tcomment_pos->col = (colnr_T)(skipwhite(look) - start);\n\t\t}\n\t\tgetvcol(curwin, comment_pos, &col, NULL, NULL);\n\t\tamount = col;\n\t\tif (curbuf->b_ind_in_comment2 || *look == NUL)\n\t\t    amount += curbuf->b_ind_in_comment;\n\t    }\n\t}\n\tgoto theend;\n    }\n\n    \/\/ Are we looking at a ']' that has a match?\n    if (*skipwhite(theline) == ']'\n\t    && (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL)\n    {\n\t\/\/ align with the line containing the '['.\n\tamount = get_indent_lnum(trypos->lnum);\n\tgoto theend;\n    }\n\n    \/\/ Are we inside parentheses or braces?  XXX\n    if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL\n\t\t&& curbuf->b_ind_java == 0)\n\t    || (tryposBrace = find_start_brace()) != NULL\n\t    || trypos != NULL)\n    {\n      if (trypos != NULL && tryposBrace != NULL)\n      {\n\t  \/\/ Both an unmatched '(' and '{' is found.  Use the one which is\n\t  \/\/ closer to the current cursor position, set the other to NULL.\n\t  if (trypos->lnum != tryposBrace->lnum\n\t\t  ? trypos->lnum < tryposBrace->lnum\n\t\t  : trypos->col < tryposBrace->col)\n\t      trypos = NULL;\n\t  else\n\t      tryposBrace = NULL;\n      }\n\n      if (trypos != NULL)\n      {\n\t\/\/ If the matching paren is more than one line away, use the indent of\n\t\/\/ a previous non-empty line that matches the same paren.\n\tif (theline[0] == ')' && curbuf->b_ind_paren_prev)\n\t{\n\t    \/\/ Line up with the start of the matching paren line.\n\t    amount = get_indent_lnum(curwin->w_cursor.lnum - 1);  \/\/ XXX\n\t}\n\telse\n\t{\n\t    amount = -1;\n\t    our_paren_pos = *trypos;\n\t    for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum)\n\t    {\n\t\tl = skipwhite(ml_get(lnum));\n\t\tif (cin_nocode(l))\t\t\/\/ skip comment lines\n\t\t    continue;\n\t\tif (cin_ispreproc_cont(&l, &lnum, &amount))\n\t\t    continue;\t\t\t\/\/ ignore #define, #if, etc.\n\t\tcurwin->w_cursor.lnum = lnum;\n\n\t\t\/\/ Skip a comment or raw string.  XXX\n\t\tif ((trypos = ind_find_start_CORS(NULL)) != NULL)\n\t\t{\n\t\t    lnum = trypos->lnum + 1;\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ XXX\n\t\tif ((trypos = find_match_paren(\n\t\t\tcorr_ind_maxparen(&cur_curpos))) != NULL\n\t\t\t&& trypos->lnum == our_paren_pos.lnum\n\t\t\t&& trypos->col == our_paren_pos.col)\n\t\t{\n\t\t\tamount = get_indent_lnum(lnum);\t\/\/ XXX\n\n\t\t\tif (theline[0] == ')')\n\t\t\t{\n\t\t\t    if (our_paren_pos.lnum != lnum\n\t\t\t\t\t\t       && cur_amount > amount)\n\t\t\t\tcur_amount = amount;\n\t\t\t    amount = -1;\n\t\t\t}\n\t\t    break;\n\t\t}\n\t    }\n\t}\n\n\t\/\/ Line up with line where the matching paren is. XXX\n\t\/\/ If the line starts with a '(' or the indent for unclosed\n\t\/\/ parentheses is zero, line up with the unclosed parentheses.\n\tif (amount == -1)\n\t{\n\t    int\t    ignore_paren_col = 0;\n\t    int\t    is_if_for_while = 0;\n\n\t    if (curbuf->b_ind_if_for_while)\n\t    {\n\t\t\/\/ Look for the outermost opening parenthesis on this line\n\t\t\/\/ and check whether it belongs to an \"if\", \"for\" or \"while\".\n\n\t\tpos_T\t    cursor_save = curwin->w_cursor;\n\t\tpos_T\t    outermost;\n\t\tchar_u\t    *line;\n\n\t\ttrypos = &our_paren_pos;\n\t\tdo {\n\t\t    outermost = *trypos;\n\t\t    curwin->w_cursor.lnum = outermost.lnum;\n\t\t    curwin->w_cursor.col = outermost.col;\n\n\t\t    trypos = find_match_paren(curbuf->b_ind_maxparen);\n\t\t} while (trypos && trypos->lnum == outermost.lnum);\n\n\t\tcurwin->w_cursor = cursor_save;\n\n\t\tline = ml_get(outermost.lnum);\n\n\t\tis_if_for_while =\n\t\t    cin_is_if_for_while_before_offset(line, &outermost.col);\n\t    }\n\n\t    amount = skip_label(our_paren_pos.lnum, &look);\n\t    look = skipwhite(look);\n\t    if (*look == '(')\n\t    {\n\t\tlinenr_T    save_lnum = curwin->w_cursor.lnum;\n\t\tchar_u\t    *line;\n\t\tint\t    look_col;\n\n\t\t\/\/ Ignore a '(' in front of the line that has a match before\n\t\t\/\/ our matching '('.\n\t\tcurwin->w_cursor.lnum = our_paren_pos.lnum;\n\t\tline = ml_get_curline();\n\t\tlook_col = (int)(look - line);\n\t\tcurwin->w_cursor.col = look_col + 1;\n\t\tif ((trypos = findmatchlimit(NULL, ')', 0,\n\t\t\t\t\t\t      curbuf->b_ind_maxparen))\n\t\t\t\t\t\t\t\t      != NULL\n\t\t\t  && trypos->lnum == our_paren_pos.lnum\n\t\t\t  && trypos->col < our_paren_pos.col)\n\t\t    ignore_paren_col = trypos->col + 1;\n\n\t\tcurwin->w_cursor.lnum = save_lnum;\n\t\tlook = ml_get(our_paren_pos.lnum) + look_col;\n\t    }\n\t    if (theline[0] == ')' || (curbuf->b_ind_unclosed == 0\n\t\t\t\t\t\t      && is_if_for_while == 0)\n\t\t    || (!curbuf->b_ind_unclosed_noignore && *look == '('\n\t\t\t\t\t\t    && ignore_paren_col == 0))\n\t    {\n\t\t\/\/ If we're looking at a close paren, line up right there;\n\t\t\/\/ otherwise, line up with the next (non-white) character.\n\t\t\/\/ When b_ind_unclosed_wrapped is set and the matching paren is\n\t\t\/\/ the last nonwhite character of the line, use either the\n\t\t\/\/ indent of the current line or the indentation of the next\n\t\t\/\/ outer paren and add b_ind_unclosed_wrapped (for very long\n\t\t\/\/ lines).\n\t\tif (theline[0] != ')')\n\t\t{\n\t\t    cur_amount = MAXCOL;\n\t\t    l = ml_get(our_paren_pos.lnum);\n\t\t    if (curbuf->b_ind_unclosed_wrapped\n\t\t\t\t       && cin_ends_in(l, (char_u *)\"(\", NULL))\n\t\t    {\n\t\t\t\/\/ look for opening unmatched paren, indent one level\n\t\t\t\/\/ for each additional level\n\t\t\tn = 1;\n\t\t\tfor (col = 0; col < our_paren_pos.col; ++col)\n\t\t\t{\n\t\t\t    switch (l[col])\n\t\t\t    {\n\t\t\t\tcase '(':\n\t\t\t\tcase '{': ++n;\n\t\t\t\t\t  break;\n\n\t\t\t\tcase ')':\n\t\t\t\tcase '}': if (n > 1)\n\t\t\t\t\t      --n;\n\t\t\t\t\t  break;\n\t\t\t    }\n\t\t\t}\n\n\t\t\tour_paren_pos.col = 0;\n\t\t\tamount += n * curbuf->b_ind_unclosed_wrapped;\n\t\t    }\n\t\t    else if (curbuf->b_ind_unclosed_whiteok)\n\t\t\tour_paren_pos.col++;\n\t\t    else\n\t\t    {\n\t\t\tcol = our_paren_pos.col + 1;\n\t\t\twhile (VIM_ISWHITE(l[col]))\n\t\t\t    col++;\n\t\t\tif (l[col] != NUL)\t\/\/ In case of trailing space\n\t\t\t    our_paren_pos.col = col;\n\t\t\telse\n\t\t\t    our_paren_pos.col++;\n\t\t    }\n\t\t}\n\n\t\t\/\/ Find how indented the paren is, or the character after it\n\t\t\/\/ if we did the above \"if\".\n\t\tif (our_paren_pos.col > 0)\n\t\t{\n\t\t    getvcol(curwin, &our_paren_pos, &col, NULL, NULL);\n\t\t    if (cur_amount > (int)col)\n\t\t\tcur_amount = col;\n\t\t}\n\t    }\n\n\t    if (theline[0] == ')' && curbuf->b_ind_matching_paren)\n\t    {\n\t\t\/\/ Line up with the start of the matching paren line.\n\t    }\n\t    else if ((curbuf->b_ind_unclosed == 0 && is_if_for_while == 0)\n\t\t     || (!curbuf->b_ind_unclosed_noignore\n\t\t\t\t    && *look == '(' && ignore_paren_col == 0))\n\t    {\n\t\tif (cur_amount != MAXCOL)\n\t\t    amount = cur_amount;\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Add b_ind_unclosed2 for each '(' before our matching one,\n\t\t\/\/ but ignore (void) before the line (ignore_paren_col).\n\t\tcol = our_paren_pos.col;\n\t\twhile ((int)our_paren_pos.col > ignore_paren_col)\n\t\t{\n\t\t    --our_paren_pos.col;\n\t\t    switch (*ml_get_pos(&our_paren_pos))\n\t\t    {\n\t\t\tcase '(': amount += curbuf->b_ind_unclosed2;\n\t\t\t\t  col = our_paren_pos.col;\n\t\t\t\t  break;\n\t\t\tcase ')': amount -= curbuf->b_ind_unclosed2;\n\t\t\t\t  col = MAXCOL;\n\t\t\t\t  break;\n\t\t    }\n\t\t}\n\n\t\t\/\/ Use b_ind_unclosed once, when the first '(' is not inside\n\t\t\/\/ braces\n\t\tif (col == MAXCOL)\n\t\t    amount += curbuf->b_ind_unclosed;\n\t\telse\n\t\t{\n\t\t    curwin->w_cursor.lnum = our_paren_pos.lnum;\n\t\t    curwin->w_cursor.col = col;\n\t\t    if (find_match_paren_after_brace(curbuf->b_ind_maxparen)\n\t\t\t\t\t\t\t\t      != NULL)\n\t\t\tamount += curbuf->b_ind_unclosed2;\n\t\t    else\n\t\t    {\n\t\t\tif (is_if_for_while)\n\t\t\t    amount += curbuf->b_ind_if_for_while;\n\t\t\telse\n\t\t\t    amount += curbuf->b_ind_unclosed;\n\t\t    }\n\t\t}\n\t\t\/\/ For a line starting with ')' use the minimum of the two\n\t\t\/\/ positions, to avoid giving it more indent than the previous\n\t\t\/\/ lines:\n\t\t\/\/  func_long_name(\t\t    if (x\n\t\t\/\/\targ\t\t\t\t    && yy\n\t\t\/\/\t)\t  ^ not here\t       )    ^ not here\n\t\tif (cur_amount < amount)\n\t\t    amount = cur_amount;\n\t    }\n\t}\n\n\t\/\/ add extra indent for a comment\n\tif (cin_iscomment(theline))\n\t    amount += curbuf->b_ind_comment;\n      }\n      else\n      {\n\t\/\/ We are inside braces, there is a { before this line at the position\n\t\/\/ stored in tryposBrace.\n\t\/\/ Make a copy of tryposBrace, it may point to pos_copy inside\n\t\/\/ find_start_brace(), which may be changed somewhere.\n\ttryposCopy = *tryposBrace;\n\ttryposBrace = &tryposCopy;\n\ttrypos = tryposBrace;\n\tourscope = trypos->lnum;\n\tstart = ml_get(ourscope);\n\n\t\/\/ Now figure out how indented the line is in general.\n\t\/\/ If the brace was at the start of the line, we use that;\n\t\/\/ otherwise, check out the indentation of the line as\n\t\/\/ a whole and then add the \"imaginary indent\" to that.\n\tlook = skipwhite(start);\n\tif (*look == '{')\n\t{\n\t    getvcol(curwin, trypos, &col, NULL, NULL);\n\t    amount = col;\n\t    if (*start == '{')\n\t\tstart_brace = BRACE_IN_COL0;\n\t    else\n\t\tstart_brace = BRACE_AT_START;\n\t}\n\telse\n\t{\n\t    \/\/ That opening brace might have been on a continuation\n\t    \/\/ line.  if so, find the start of the line.\n\t    curwin->w_cursor.lnum = ourscope;\n\n\t    \/\/ Position the cursor over the rightmost paren, so that\n\t    \/\/ matching it will take us back to the start of the line.\n\t    lnum = ourscope;\n\t    if (find_last_paren(start, '(', ')')\n\t\t\t&& (trypos = find_match_paren(curbuf->b_ind_maxparen))\n\t\t\t\t\t\t\t\t      != NULL)\n\t\tlnum = trypos->lnum;\n\n\t    \/\/ It could have been something like\n\t    \/\/\t   case 1: if (asdf &&\n\t    \/\/\t\t\tldfd) {\n\t    \/\/\t\t    }\n\t    if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)\n\t\t\t   && cin_iscase(skipwhite(ml_get_curline()), FALSE))\n\t\tamount = get_indent();\n\t    else if (curbuf->b_ind_js)\n\t\tamount = get_indent_lnum(lnum);\n\t    else\n\t\tamount = skip_label(lnum, &l);\n\n\t    start_brace = BRACE_AT_END;\n\t}\n\n\t\/\/ For Javascript check if the line starts with \"key:\".\n\tif (curbuf->b_ind_js)\n\t    js_cur_has_key = cin_has_js_key(theline);\n\n\t\/\/ If we're looking at a closing brace, that's where\n\t\/\/ we want to be.  otherwise, add the amount of room\n\t\/\/ that an indent is supposed to be.\n\tif (theline[0] == '}')\n\t{\n\t    \/\/ they may want closing braces to line up with something\n\t    \/\/ other than the open brace.  indulge them, if so.\n\t    amount += curbuf->b_ind_close_extra;\n\t}\n\telse\n\t{\n\t    \/\/ If we're looking at an \"else\", try to find an \"if\"\n\t    \/\/ to match it with.\n\t    \/\/ If we're looking at a \"while\", try to find a \"do\"\n\t    \/\/ to match it with.\n\t    lookfor = LOOKFOR_INITIAL;\n\t    if (cin_iselse(theline))\n\t\tlookfor = LOOKFOR_IF;\n\t    else if (cin_iswhileofdo(theline, cur_curpos.lnum)) \/\/ XXX\n\t\tlookfor = LOOKFOR_DO;\n\t    if (lookfor != LOOKFOR_INITIAL)\n\t    {\n\t\tcurwin->w_cursor.lnum = cur_curpos.lnum;\n\t\tif (find_match(lookfor, ourscope) == OK)\n\t\t{\n\t\t    amount = get_indent();\t\/\/ XXX\n\t\t    goto theend;\n\t\t}\n\t    }\n\n\t    \/\/ We get here if we are not on an \"while-of-do\" or \"else\" (or\n\t    \/\/ failed to find a matching \"if\").\n\t    \/\/ Search backwards for something to line up with.\n\t    \/\/ First set amount for when we don't find anything.\n\n\t    \/\/ if the '{' is  _really_ at the left margin, use the imaginary\n\t    \/\/ location of a left-margin brace.  Otherwise, correct the\n\t    \/\/ location for b_ind_open_extra.\n\n\t    if (start_brace == BRACE_IN_COL0)\t    \/\/ '{' is in column 0\n\t    {\n\t\tamount = curbuf->b_ind_open_left_imag;\n\t\tlookfor_cpp_namespace = TRUE;\n\t    }\n\t    else if (start_brace == BRACE_AT_START &&\n\t\t    lookfor_cpp_namespace)\t  \/\/ '{' is at start\n\t    {\n\n\t\tlookfor_cpp_namespace = TRUE;\n\t    }\n\t    else\n\t    {\n\t\tif (start_brace == BRACE_AT_END)    \/\/ '{' is at end of line\n\t\t{\n\t\t    amount += curbuf->b_ind_open_imag;\n\n\t\t    l = skipwhite(ml_get_curline());\n\t\t    if (cin_is_cpp_namespace(l))\n\t\t\tamount += curbuf->b_ind_cpp_namespace;\n\t\t    else if (cin_is_cpp_extern_c(l))\n\t\t\tamount += curbuf->b_ind_cpp_extern_c;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Compensate for adding b_ind_open_extra later.\n\t\t    amount -= curbuf->b_ind_open_extra;\n\t\t    if (amount < 0)\n\t\t\tamount = 0;\n\t\t}\n\t    }\n\n\t    lookfor_break = FALSE;\n\n\t    if (cin_iscase(theline, FALSE))\t\/\/ it's a switch() label\n\t    {\n\t\tlookfor = LOOKFOR_CASE;\t\/\/ find a previous switch() label\n\t\tamount += curbuf->b_ind_case;\n\t    }\n\t    else if (cin_isscopedecl(theline))\t\/\/ private:, ...\n\t    {\n\t\tlookfor = LOOKFOR_SCOPEDECL;\t\/\/ class decl is this block\n\t\tamount += curbuf->b_ind_scopedecl;\n\t    }\n\t    else\n\t    {\n\t\tif (curbuf->b_ind_case_break && cin_isbreak(theline))\n\t\t    \/\/ break; ...\n\t\t    lookfor_break = TRUE;\n\n\t\tlookfor = LOOKFOR_INITIAL;\n\t\t\/\/ b_ind_level from start of block\n\t\tamount += curbuf->b_ind_level;\n\t    }\n\t    scope_amount = amount;\n\t    whilelevel = 0;\n\n\t    \/\/ Search backwards.  If we find something we recognize, line up\n\t    \/\/ with that.\n\t    \/\/\n\t    \/\/ If we're looking at an open brace, indent\n\t    \/\/ the usual amount relative to the conditional\n\t    \/\/ that opens the block.\n\t    curwin->w_cursor = cur_curpos;\n\t    for (;;)\n\t    {\n\t\tcurwin->w_cursor.lnum--;\n\t\tcurwin->w_cursor.col = 0;\n\n\t\t\/\/ If we went all the way back to the start of our scope, line\n\t\t\/\/ up with it.\n\t\tif (curwin->w_cursor.lnum <= ourscope)\n\t\t{\n\t\t    \/\/ We reached end of scope:\n\t\t    \/\/ If looking for an enum or structure initialization\n\t\t    \/\/ go further back:\n\t\t    \/\/ If it is an initializer (enum xxx or xxx =), then\n\t\t    \/\/ don't add ind_continuation, otherwise it is a variable\n\t\t    \/\/ declaration:\n\t\t    \/\/ int x,\n\t\t    \/\/     here; <-- add ind_continuation\n\t\t    if (lookfor == LOOKFOR_ENUM_OR_INIT)\n\t\t    {\n\t\t\tif (curwin->w_cursor.lnum == 0\n\t\t\t\t|| curwin->w_cursor.lnum\n\t\t\t\t\t  < ourscope - curbuf->b_ind_maxparen)\n\t\t\t{\n\t\t\t    \/\/ nothing found (abuse curbuf->b_ind_maxparen as\n\t\t\t    \/\/ limit) assume terminated line (i.e. a variable\n\t\t\t    \/\/ initialization)\n\t\t\t    if (cont_amount > 0)\n\t\t\t\tamount = cont_amount;\n\t\t\t    else if (!curbuf->b_ind_js)\n\t\t\t\tamount += ind_continuation;\n\t\t\t    break;\n\t\t\t}\n\n\t\t\tl = ml_get_curline();\n\n\t\t\t\/\/ If we're in a comment or raw string now, skip to\n\t\t\t\/\/ the start of it.\n\t\t\ttrypos = ind_find_start_CORS(NULL);\n\t\t\tif (trypos != NULL)\n\t\t\t{\n\t\t\t    curwin->w_cursor.lnum = trypos->lnum + 1;\n\t\t\t    curwin->w_cursor.col = 0;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\t\/\/ Skip preprocessor directives and blank lines.\n\t\t\tif (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum,\n\t\t\t\t\t\t\t\t    &amount))\n\t\t\t    continue;\n\n\t\t\tif (cin_nocode(l))\n\t\t\t    continue;\n\n\t\t\tterminated = cin_isterminated(l, FALSE, TRUE);\n\n\t\t\t\/\/ If we are at top level and the line looks like a\n\t\t\t\/\/ function declaration, we are done\n\t\t\t\/\/ (it's a variable declaration).\n\t\t\tif (start_brace != BRACE_IN_COL0\n\t\t\t     || !cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0))\n\t\t\t{\n\t\t\t    \/\/ if the line is terminated with another ','\n\t\t\t    \/\/ it is a continued variable initialization.\n\t\t\t    \/\/ don't add extra indent.\n\t\t\t    \/\/ TODO: does not work, if  a function\n\t\t\t    \/\/ declaration is split over multiple lines:\n\t\t\t    \/\/ cin_isfuncdecl returns FALSE then.\n\t\t\t    if (terminated == ',')\n\t\t\t\tbreak;\n\n\t\t\t    \/\/ if it is an enum declaration or an assignment,\n\t\t\t    \/\/ we are done.\n\t\t\t    if (terminated != ';' && cin_isinit())\n\t\t\t\tbreak;\n\n\t\t\t    \/\/ nothing useful found\n\t\t\t    if (terminated == 0 || terminated == '{')\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (terminated != ';')\n\t\t\t{\n\t\t\t    \/\/ Skip parens and braces. Position the cursor\n\t\t\t    \/\/ over the rightmost paren, so that matching it\n\t\t\t    \/\/ will take us back to the start of the line.\n\t\t\t    \/\/ XXX\n\t\t\t    trypos = NULL;\n\t\t\t    if (find_last_paren(l, '(', ')'))\n\t\t\t\ttrypos = find_match_paren(\n\t\t\t\t\t\t      curbuf->b_ind_maxparen);\n\n\t\t\t    if (trypos == NULL && find_last_paren(l, '{', '}'))\n\t\t\t\ttrypos = find_start_brace();\n\n\t\t\t    if (trypos != NULL)\n\t\t\t    {\n\t\t\t\tcurwin->w_cursor.lnum = trypos->lnum + 1;\n\t\t\t\tcurwin->w_cursor.col = 0;\n\t\t\t\tcontinue;\n\t\t\t    }\n\t\t\t}\n\n\t\t\t\/\/ it's a variable declaration, add indentation\n\t\t\t\/\/ like in\n\t\t\t\/\/ int a,\n\t\t\t\/\/    b;\n\t\t\tif (cont_amount > 0)\n\t\t\t    amount = cont_amount;\n\t\t\telse\n\t\t\t    amount += ind_continuation;\n\t\t    }\n\t\t    else if (lookfor == LOOKFOR_UNTERM)\n\t\t    {\n\t\t\tif (cont_amount > 0)\n\t\t\t    amount = cont_amount;\n\t\t\telse\n\t\t\t    amount += ind_continuation;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (lookfor != LOOKFOR_TERM\n\t\t\t\t\t&& lookfor != LOOKFOR_CPP_BASECLASS\n\t\t\t\t\t&& lookfor != LOOKFOR_COMMA)\n\t\t\t{\n\t\t\t    amount = scope_amount;\n\t\t\t    if (theline[0] == '{')\n\t\t\t    {\n\t\t\t\tamount += curbuf->b_ind_open_extra;\n\t\t\t\tadded_to_amount = curbuf->b_ind_open_extra;\n\t\t\t    }\n\t\t\t}\n\n\t\t\tif (lookfor_cpp_namespace)\n\t\t\t{\n\t\t\t    \/\/ Looking for C++ namespace, need to look further\n\t\t\t    \/\/ back.\n\t\t\t    if (curwin->w_cursor.lnum == ourscope)\n\t\t\t\tcontinue;\n\n\t\t\t    if (curwin->w_cursor.lnum == 0\n\t\t\t\t    || curwin->w_cursor.lnum\n\t\t\t\t\t      < ourscope - FIND_NAMESPACE_LIM)\n\t\t\t\tbreak;\n\n\t\t\t    l = ml_get_curline();\n\n\t\t\t    \/\/ If we're in a comment or raw string now, skip\n\t\t\t    \/\/ to the start of it.\n\t\t\t    trypos = ind_find_start_CORS(NULL);\n\t\t\t    if (trypos != NULL)\n\t\t\t    {\n\t\t\t\tcurwin->w_cursor.lnum = trypos->lnum + 1;\n\t\t\t\tcurwin->w_cursor.col = 0;\n\t\t\t\tcontinue;\n\t\t\t    }\n\n\t\t\t    \/\/ Skip preprocessor directives and blank lines.\n\t\t\t    if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum,\n\t\t\t\t\t\t\t\t    &amount))\n\t\t\t\tcontinue;\n\n\t\t\t    \/\/ Finally the actual check for \"namespace\".\n\t\t\t    if (cin_is_cpp_namespace(l))\n\t\t\t    {\n\t\t\t\tamount += curbuf->b_ind_cpp_namespace\n\t\t\t\t\t\t\t    - added_to_amount;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t    else if (cin_is_cpp_extern_c(l))\n\t\t\t    {\n\t\t\t\tamount += curbuf->b_ind_cpp_extern_c\n\t\t\t\t\t\t\t    - added_to_amount;\n\t\t\t\tbreak;\n\t\t\t    }\n\n\t\t\t    if (cin_nocode(l))\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t    }\n\t\t    break;\n\t\t}\n\n\t\t\/\/ If we're in a comment or raw string now, skip to the start\n\t\t\/\/ of it.  XXX\n\t\tif ((trypos = ind_find_start_CORS(&raw_string_start)) != NULL)\n\t\t{\n\t\t    curwin->w_cursor.lnum = trypos->lnum + 1;\n\t\t    curwin->w_cursor.col = 0;\n\t\t    continue;\n\t\t}\n\n\t\tl = ml_get_curline();\n\n\t\t\/\/ If this is a switch() label, may line up relative to that.\n\t\t\/\/ If this is a C++ scope declaration, do the same.\n\t\tiscase = cin_iscase(l, FALSE);\n\t\tif (iscase || cin_isscopedecl(l))\n\t\t{\n\t\t    \/\/ we are only looking for cpp base class\n\t\t    \/\/ declaration\/initialization any longer\n\t\t    if (lookfor == LOOKFOR_CPP_BASECLASS)\n\t\t\tbreak;\n\n\t\t    \/\/ When looking for a \"do\" we are not interested in\n\t\t    \/\/ labels.\n\t\t    if (whilelevel > 0)\n\t\t\tcontinue;\n\n\t\t    \/\/\tcase xx:\n\t\t    \/\/\t    c = 99 +\t    <- this indent plus continuation\n\t\t    \/\/->\t   here;\n\t\t    if (lookfor == LOOKFOR_UNTERM\n\t\t\t\t\t   || lookfor == LOOKFOR_ENUM_OR_INIT)\n\t\t    {\n\t\t\tif (cont_amount > 0)\n\t\t\t    amount = cont_amount;\n\t\t\telse\n\t\t\t    amount += ind_continuation;\n\t\t\tbreak;\n\t\t    }\n\n\t\t    \/\/\tcase xx:\t<- line up with this case\n\t\t    \/\/\t    x = 333;\n\t\t    \/\/\tcase yy:\n\t\t    if (       (iscase && lookfor == LOOKFOR_CASE)\n\t\t\t    || (iscase && lookfor_break)\n\t\t\t    || (!iscase && lookfor == LOOKFOR_SCOPEDECL))\n\t\t    {\n\t\t\t\/\/ Check that this case label is not for another\n\t\t\t\/\/ switch()\t\t    XXX\n\t\t\tif ((trypos = find_start_brace()) == NULL\n\t\t\t\t\t\t  || trypos->lnum == ourscope)\n\t\t\t{\n\t\t\t    amount = get_indent();\t\/\/ XXX\n\t\t\t    break;\n\t\t\t}\n\t\t\tcontinue;\n\t\t    }\n\n\t\t    n = get_indent_nolabel(curwin->w_cursor.lnum);  \/\/ XXX\n\n\t\t    \/\/\t case xx: if (cond)\t    <- line up with this if\n\t\t    \/\/\t\t      y = y + 1;\n\t\t    \/\/ ->\t  s = 99;\n\t\t    \/\/\n\t\t    \/\/\t case xx:\n\t\t    \/\/\t     if (cond)\t\t<- line up with this line\n\t\t    \/\/\t\t y = y + 1;\n\t\t    \/\/ ->    s = 99;\n\t\t    if (lookfor == LOOKFOR_TERM)\n\t\t    {\n\t\t\tif (n)\n\t\t\t    amount = n;\n\n\t\t\tif (!lookfor_break)\n\t\t\t    break;\n\t\t    }\n\n\t\t    \/\/\t case xx: x = x + 1;\t    <- line up with this x\n\t\t    \/\/ ->\t  y = y + 1;\n\t\t    \/\/\n\t\t    \/\/\t case xx: if (cond)\t    <- line up with this if\n\t\t    \/\/ ->\t       y = y + 1;\n\t\t    if (n)\n\t\t    {\n\t\t\tamount = n;\n\t\t\tl = after_label(ml_get_curline());\n\t\t\tif (l != NULL && cin_is_cinword(l))\n\t\t\t{\n\t\t\t    if (theline[0] == '{')\n\t\t\t\tamount += curbuf->b_ind_open_extra;\n\t\t\t    else\n\t\t\t\tamount += curbuf->b_ind_level\n\t\t\t\t\t\t     + curbuf->b_ind_no_brace;\n\t\t\t}\n\t\t\tbreak;\n\t\t    }\n\n\t\t    \/\/ Try to get the indent of a statement before the switch\n\t\t    \/\/ label.  If nothing is found, line up relative to the\n\t\t    \/\/ switch label.\n\t\t    \/\/\t    break;\t\t<- may line up with this line\n\t\t    \/\/\t case xx:\n\t\t    \/\/ ->   y = 1;\n\t\t    scope_amount = get_indent() + (iscase    \/\/ XXX\n\t\t\t\t\t? curbuf->b_ind_case_code\n\t\t\t\t\t: curbuf->b_ind_scopedecl_code);\n\t\t    lookfor = curbuf->b_ind_case_break\n\t\t\t\t\t      ? LOOKFOR_NOBREAK : LOOKFOR_ANY;\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ Looking for a switch() label or C++ scope declaration,\n\t\t\/\/ ignore other lines, skip {}-blocks.\n\t\tif (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL)\n\t\t{\n\t\t    if (find_last_paren(l, '{', '}')\n\t\t\t\t     && (trypos = find_start_brace()) != NULL)\n\t\t    {\n\t\t\tcurwin->w_cursor.lnum = trypos->lnum + 1;\n\t\t\tcurwin->w_cursor.col = 0;\n\t\t    }\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ Ignore jump labels with nothing after them.\n\t\tif (!curbuf->b_ind_js && cin_islabel())\n\t\t{\n\t\t    l = after_label(ml_get_curline());\n\t\t    if (l == NULL || cin_nocode(l))\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/\/ Ignore #defines, #if, etc.\n\t\t\/\/ Ignore comment and empty lines.\n\t\t\/\/ (need to get the line again, cin_islabel() may have\n\t\t\/\/ unlocked it)\n\t\tl = ml_get_curline();\n\t\tif (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)\n\t\t\t\t\t\t\t     || cin_nocode(l))\n\t\t    continue;\n\n\t\t\/\/ Are we at the start of a cpp base class declaration or\n\t\t\/\/ constructor initialization?  XXX\n\t\tn = FALSE;\n\t\tif (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0)\n\t\t{\n\t\t    n = cin_is_cpp_baseclass(&cache_cpp_baseclass);\n\t\t    l = ml_get_curline();\n\t\t}\n\t\tif (n)\n\t\t{\n\t\t    if (lookfor == LOOKFOR_UNTERM)\n\t\t    {\n\t\t\tif (cont_amount > 0)\n\t\t\t    amount = cont_amount;\n\t\t\telse\n\t\t\t    amount += ind_continuation;\n\t\t    }\n\t\t    else if (theline[0] == '{')\n\t\t    {\n\t\t\t\/\/ Need to find start of the declaration.\n\t\t\tlookfor = LOOKFOR_UNTERM;\n\t\t\tind_continuation = 0;\n\t\t\tcontinue;\n\t\t    }\n\t\t    else\n\t\t\t\/\/ XXX\n\t\t\tamount = get_baseclass_amount(\n\t\t\t\t\t\tcache_cpp_baseclass.lpos.col);\n\t\t    break;\n\t\t}\n\t\telse if (lookfor == LOOKFOR_CPP_BASECLASS)\n\t\t{\n\t\t    \/\/ only look, whether there is a cpp base class\n\t\t    \/\/ declaration or initialization before the opening brace.\n\t\t    if (cin_isterminated(l, TRUE, FALSE))\n\t\t\tbreak;\n\t\t    else\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/\/ What happens next depends on the line being terminated.\n\t\t\/\/ If terminated with a ',' only consider it terminating if\n\t\t\/\/ there is another unterminated statement behind, eg:\n\t\t\/\/   123,\n\t\t\/\/   sizeof\n\t\t\/\/\t  here\n\t\t\/\/ Otherwise check whether it is an enumeration or structure\n\t\t\/\/ initialisation (not indented) or a variable declaration\n\t\t\/\/ (indented).\n\t\tterminated = cin_isterminated(l, FALSE, TRUE);\n\n\t\tif (js_cur_has_key)\n\t\t{\n\t\t    js_cur_has_key = 0; \/\/ only check the first line\n\t\t    if (curbuf->b_ind_js && terminated == ',')\n\t\t    {\n\t\t\t\/\/ For Javascript we might be inside an object:\n\t\t\t\/\/   key: something,  <- align with this\n\t\t\t\/\/   key: something\n\t\t\t\/\/ or:\n\t\t\t\/\/   key: something +  <- align with this\n\t\t\t\/\/       something,\n\t\t\t\/\/   key: something\n\t\t\tlookfor = LOOKFOR_JS_KEY;\n\t\t    }\n\t\t}\n\t\tif (lookfor == LOOKFOR_JS_KEY && cin_has_js_key(l))\n\t\t{\n\t\t    amount = get_indent();\n\t\t    break;\n\t\t}\n\t\tif (lookfor == LOOKFOR_COMMA)\n\t\t{\n\t\t    if (tryposBrace != NULL && tryposBrace->lnum\n\t\t\t\t\t\t    >= curwin->w_cursor.lnum)\n\t\t\tbreak;\n\t\t    if (terminated == ',')\n\t\t\t\/\/ line below current line is the one that starts a\n\t\t\t\/\/ (possibly broken) line ending in a comma.\n\t\t\tbreak;\n\t\t    else\n\t\t    {\n\t\t\tamount = get_indent();\n\t\t\tif (curwin->w_cursor.lnum - 1 == ourscope)\n\t\t\t    \/\/ line above is start of the scope, thus current\n\t\t\t    \/\/ line is the one that stars a (possibly broken)\n\t\t\t    \/\/ line ending in a comma.\n\t\t\t    break;\n\t\t    }\n\t\t}\n\n\t\tif (terminated == 0 || (lookfor != LOOKFOR_UNTERM\n\t\t\t\t\t\t\t&& terminated == ','))\n\t\t{\n\t\t    if (lookfor != LOOKFOR_ENUM_OR_INIT &&\n\t\t\t    (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '['))\n\t\t\tamount += ind_continuation;\n\t\t    \/\/ if we're in the middle of a paren thing,\n\t\t    \/\/ go back to the line that starts it so\n\t\t    \/\/ we can get the right prevailing indent\n\t\t    \/\/\t   if ( foo &&\n\t\t    \/\/\t\t    bar )\n\n\t\t    \/\/ Position the cursor over the rightmost paren, so that\n\t\t    \/\/ matching it will take us back to the start of the line.\n\t\t    \/\/ Ignore a match before the start of the block.\n\t\t    (void)find_last_paren(l, '(', ')');\n\t\t    trypos = find_match_paren(corr_ind_maxparen(&cur_curpos));\n\t\t    if (trypos != NULL && (trypos->lnum < tryposBrace->lnum\n\t\t\t\t|| (trypos->lnum == tryposBrace->lnum\n\t\t\t\t    && trypos->col < tryposBrace->col)))\n\t\t\ttrypos = NULL;\n\n\t\t    \/\/ If we are looking for ',', we also look for matching\n\t\t    \/\/ braces.\n\t\t    if (trypos == NULL && terminated == ','\n\t\t\t\t\t      && find_last_paren(l, '{', '}'))\n\t\t\ttrypos = find_start_brace();\n\n\t\t    if (trypos != NULL)\n\t\t    {\n\t\t\t\/\/ Check if we are on a case label now.  This is\n\t\t\t\/\/ handled above.\n\t\t\t\/\/     case xx:  if ( asdf &&\n\t\t\t\/\/\t\t\tasdf)\n\t\t\tcurwin->w_cursor = *trypos;\n\t\t\tl = ml_get_curline();\n\t\t\tif (cin_iscase(l, FALSE) || cin_isscopedecl(l))\n\t\t\t{\n\t\t\t    ++curwin->w_cursor.lnum;\n\t\t\t    curwin->w_cursor.col = 0;\n\t\t\t    continue;\n\t\t\t}\n\t\t    }\n\n\t\t    \/\/ Skip over continuation lines to find the one to get the\n\t\t    \/\/ indent from\n\t\t    \/\/ char *usethis = \"bla{backslash}\n\t\t    \/\/\t\t bla\",\n\t\t    \/\/      here;\n\t\t    if (terminated == ',')\n\t\t    {\n\t\t\twhile (curwin->w_cursor.lnum > 1)\n\t\t\t{\n\t\t\t    l = ml_get(curwin->w_cursor.lnum - 1);\n\t\t\t    if (*l == NUL || l[STRLEN(l) - 1] != '\\\\')\n\t\t\t\tbreak;\n\t\t\t    --curwin->w_cursor.lnum;\n\t\t\t    curwin->w_cursor.col = 0;\n\t\t\t}\n\t\t    }\n\n\t\t    \/\/ Get indent and pointer to text for current line,\n\t\t    \/\/ ignoring any jump label.  XXX\n\t\t    if (curbuf->b_ind_js)\n\t\t\tcur_amount = get_indent();\n\t\t    else\n\t\t\tcur_amount = skip_label(curwin->w_cursor.lnum, &l);\n\t\t    \/\/ If this is just above the line we are indenting, and it\n\t\t    \/\/ starts with a '{', line it up with this line.\n\t\t    \/\/\t\twhile (not)\n\t\t    \/\/ ->\t{\n\t\t    \/\/\t\t}\n\t\t    if (terminated != ',' && lookfor != LOOKFOR_TERM\n\t\t\t\t\t\t\t && theline[0] == '{')\n\t\t    {\n\t\t\tamount = cur_amount;\n\t\t\t\/\/ Only add b_ind_open_extra when the current line\n\t\t\t\/\/ doesn't start with a '{', which must have a match\n\t\t\t\/\/ in the same line (scope is the same).  Probably:\n\t\t\t\/\/\t{ 1, 2 },\n\t\t\t\/\/ ->\t{ 3, 4 }\n\t\t\tif (*skipwhite(l) != '{')\n\t\t\t    amount += curbuf->b_ind_open_extra;\n\n\t\t\tif (curbuf->b_ind_cpp_baseclass && !curbuf->b_ind_js)\n\t\t\t{\n\t\t\t    \/\/ have to look back, whether it is a cpp base\n\t\t\t    \/\/ class declaration or initialization\n\t\t\t    lookfor = LOOKFOR_CPP_BASECLASS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tbreak;\n\t\t    }\n\n\t\t    \/\/ Check if we are after an \"if\", \"while\", etc.\n\t\t    \/\/ Also allow \"   } else\".\n\t\t    if (cin_is_cinword(l) || cin_iselse(skipwhite(l)))\n\t\t    {\n\t\t\t\/\/ Found an unterminated line after an if (), line up\n\t\t\t\/\/ with the last one.\n\t\t\t\/\/   if (cond)\n\t\t\t\/\/\t    100 +\n\t\t\t\/\/ ->\t\there;\n\t\t\tif (lookfor == LOOKFOR_UNTERM\n\t\t\t\t\t   || lookfor == LOOKFOR_ENUM_OR_INIT)\n\t\t\t{\n\t\t\t    if (cont_amount > 0)\n\t\t\t\tamount = cont_amount;\n\t\t\t    else\n\t\t\t\tamount += ind_continuation;\n\t\t\t    break;\n\t\t\t}\n\n\t\t\t\/\/ If this is just above the line we are indenting, we\n\t\t\t\/\/ are finished.\n\t\t\t\/\/\t    while (not)\n\t\t\t\/\/ ->\t\there;\n\t\t\t\/\/ Otherwise this indent can be used when the line\n\t\t\t\/\/ before this is terminated.\n\t\t\t\/\/\tyyy;\n\t\t\t\/\/\tif (stat)\n\t\t\t\/\/\t    while (not)\n\t\t\t\/\/\t\txxx;\n\t\t\t\/\/ ->\there;\n\t\t\tamount = cur_amount;\n\t\t\tif (theline[0] == '{')\n\t\t\t    amount += curbuf->b_ind_open_extra;\n\t\t\tif (lookfor != LOOKFOR_TERM)\n\t\t\t{\n\t\t\t    amount += curbuf->b_ind_level\n\t\t\t\t\t\t     + curbuf->b_ind_no_brace;\n\t\t\t    break;\n\t\t\t}\n\n\t\t\t\/\/ Special trick: when expecting the while () after a\n\t\t\t\/\/ do, line up with the while()\n\t\t\t\/\/     do\n\t\t\t\/\/\t    x = 1;\n\t\t\t\/\/ ->  here\n\t\t\tl = skipwhite(ml_get_curline());\n\t\t\tif (cin_isdo(l))\n\t\t\t{\n\t\t\t    if (whilelevel == 0)\n\t\t\t\tbreak;\n\t\t\t    --whilelevel;\n\t\t\t}\n\n\t\t\t\/\/ When searching for a terminated line, don't use the\n\t\t\t\/\/ one between the \"if\" and the matching \"else\".\n\t\t\t\/\/ Need to use the scope of this \"else\".  XXX\n\t\t\t\/\/ If whilelevel != 0 continue looking for a \"do {\".\n\t\t\tif (cin_iselse(l) && whilelevel == 0)\n\t\t\t{\n\t\t\t    \/\/ If we're looking at \"} else\", let's make sure we\n\t\t\t    \/\/ find the opening brace of the enclosing scope,\n\t\t\t    \/\/ not the one from \"if () {\".\n\t\t\t    if (*l == '}')\n\t\t\t\tcurwin->w_cursor.col =\n\t\t\t\t\t  (colnr_T)(l - ml_get_curline()) + 1;\n\n\t\t\t    if ((trypos = find_start_brace()) == NULL\n\t\t\t\t       || find_match(LOOKFOR_IF, trypos->lnum)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t\t\t\tbreak;\n\t\t\t}\n\t\t    }\n\n\t\t    \/\/ If we're below an unterminated line that is not an\n\t\t    \/\/ \"if\" or something, we may line up with this line or\n\t\t    \/\/ add something for a continuation line, depending on\n\t\t    \/\/ the line before this one.\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Found two unterminated lines on a row, line up with\n\t\t\t\/\/ the last one.\n\t\t\t\/\/   c = 99 +\n\t\t\t\/\/\t    100 +\n\t\t\t\/\/ ->\t    here;\n\t\t\tif (lookfor == LOOKFOR_UNTERM)\n\t\t\t{\n\t\t\t    \/\/ When line ends in a comma add extra indent\n\t\t\t    if (terminated == ',')\n\t\t\t\tamount += ind_continuation;\n\t\t\t    break;\n\t\t\t}\n\n\t\t\tif (lookfor == LOOKFOR_ENUM_OR_INIT)\n\t\t\t{\n\t\t\t    \/\/ Found two lines ending in ',', lineup with the\n\t\t\t    \/\/ lowest one, but check for cpp base class\n\t\t\t    \/\/ declaration\/initialization, if it is an\n\t\t\t    \/\/ opening brace or we are looking just for\n\t\t\t    \/\/ enumerations\/initializations.\n\t\t\t    if (terminated == ',')\n\t\t\t    {\n\t\t\t\tif (curbuf->b_ind_cpp_baseclass == 0)\n\t\t\t\t    break;\n\n\t\t\t\tlookfor = LOOKFOR_CPP_BASECLASS;\n\t\t\t\tcontinue;\n\t\t\t    }\n\n\t\t\t    \/\/ Ignore unterminated lines in between, but\n\t\t\t    \/\/ reduce indent.\n\t\t\t    if (amount > cur_amount)\n\t\t\t\tamount = cur_amount;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Found first unterminated line on a row, may\n\t\t\t    \/\/ line up with this line, remember its indent\n\t\t\t    \/\/\t    100 +\n\t\t\t    \/\/ ->\t    here;\n\t\t\t    l = ml_get_curline();\n\t\t\t    amount = cur_amount;\n\n\t\t\t    n = (int)STRLEN(l);\n\t\t\t    if (terminated == ',' && (*skipwhite(l) == ']'\n\t\t\t\t\t|| (n >=2 && l[n - 2] == ']')))\n\t\t\t\tbreak;\n\n\t\t\t    \/\/ If previous line ends in ',', check whether we\n\t\t\t    \/\/ are in an initialization or enum\n\t\t\t    \/\/ struct xxx =\n\t\t\t    \/\/ {\n\t\t\t    \/\/      sizeof a,\n\t\t\t    \/\/      124 };\n\t\t\t    \/\/ or a normal possible continuation line.\n\t\t\t    \/\/ but only, of no other statement has been found\n\t\t\t    \/\/ yet.\n\t\t\t    if (lookfor == LOOKFOR_INITIAL && terminated == ',')\n\t\t\t    {\n\t\t\t\tif (curbuf->b_ind_js)\n\t\t\t\t{\n\t\t\t\t    \/\/ Search for a line ending in a comma\n\t\t\t\t    \/\/ and line up with the line below it\n\t\t\t\t    \/\/ (could be the current line).\n\t\t\t\t    \/\/ some = [\n\t\t\t\t    \/\/     1,     <- line up here\n\t\t\t\t    \/\/     2,\n\t\t\t\t    \/\/ some = [\n\t\t\t\t    \/\/     3 +    <- line up here\n\t\t\t\t    \/\/       4 *\n\t\t\t\t    \/\/        5,\n\t\t\t\t    \/\/     6,\n\t\t\t\t    if (cin_iscomment(skipwhite(l)))\n\t\t\t\t\tbreak;\n\t\t\t\t    lookfor = LOOKFOR_COMMA;\n\t\t\t\t    trypos = find_match_char('[',\n\t\t\t\t\t\t      curbuf->b_ind_maxparen);\n\t\t\t\t    if (trypos != NULL)\n\t\t\t\t    {\n\t\t\t\t\tif (trypos->lnum\n\t\t\t\t\t\t == curwin->w_cursor.lnum - 1)\n\t\t\t\t\t{\n\t\t\t\t\t    \/\/ Current line is first inside\n\t\t\t\t\t    \/\/ [], line up with it.\n\t\t\t\t\t    break;\n\t\t\t\t\t}\n\t\t\t\t\tourscope = trypos->lnum;\n\t\t\t\t    }\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    lookfor = LOOKFOR_ENUM_OR_INIT;\n\t\t\t\t    cont_amount = cin_first_id_amount();\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\tif (lookfor == LOOKFOR_INITIAL\n\t\t\t\t\t&& *l != NUL\n\t\t\t\t\t&& l[STRLEN(l) - 1] == '\\\\')\n\t\t\t\t\t\t\t\t\/\/ XXX\n\t\t\t\t    cont_amount = cin_get_equal_amount(\n\t\t\t\t\t\t       curwin->w_cursor.lnum);\n\t\t\t\tif (lookfor != LOOKFOR_TERM\n\t\t\t\t\t\t&& lookfor != LOOKFOR_JS_KEY\n\t\t\t\t\t\t&& lookfor != LOOKFOR_COMMA\n\t\t\t\t\t\t&& raw_string_start != curwin->w_cursor.lnum)\n\t\t\t\t    lookfor = LOOKFOR_UNTERM;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t\t\/\/ Check if we are after a while (cond);\n\t\t\/\/ If so: Ignore until the matching \"do\".\n\t\telse if (cin_iswhileofdo_end(terminated)) \/\/ XXX\n\t\t{\n\t\t    \/\/ Found an unterminated line after a while ();, line up\n\t\t    \/\/ with the last one.\n\t\t    \/\/\t    while (cond);\n\t\t    \/\/\t    100 +\t\t<- line up with this one\n\t\t    \/\/ ->\t    here;\n\t\t    if (lookfor == LOOKFOR_UNTERM\n\t\t\t\t\t   || lookfor == LOOKFOR_ENUM_OR_INIT)\n\t\t    {\n\t\t\tif (cont_amount > 0)\n\t\t\t    amount = cont_amount;\n\t\t\telse\n\t\t\t    amount += ind_continuation;\n\t\t\tbreak;\n\t\t    }\n\n\t\t    if (whilelevel == 0)\n\t\t    {\n\t\t\tlookfor = LOOKFOR_TERM;\n\t\t\tamount = get_indent();\t    \/\/ XXX\n\t\t\tif (theline[0] == '{')\n\t\t\t    amount += curbuf->b_ind_open_extra;\n\t\t    }\n\t\t    ++whilelevel;\n\t\t}\n\n\t\t\/\/ We are after a \"normal\" statement.\n\t\t\/\/ If we had another statement we can stop now and use the\n\t\t\/\/ indent of that other statement.\n\t\t\/\/ Otherwise the indent of the current statement may be used,\n\t\t\/\/ search backwards for the next \"normal\" statement.\n\t\telse\n\t\t{\n\t\t    \/\/ Skip single break line, if before a switch label. It\n\t\t    \/\/ may be lined up with the case label.\n\t\t    if (lookfor == LOOKFOR_NOBREAK\n\t\t\t\t  && cin_isbreak(skipwhite(ml_get_curline())))\n\t\t    {\n\t\t\tlookfor = LOOKFOR_ANY;\n\t\t\tcontinue;\n\t\t    }\n\n\t\t    \/\/ Handle \"do {\" line.\n\t\t    if (whilelevel > 0)\n\t\t    {\n\t\t\tl = cin_skipcomment(ml_get_curline());\n\t\t\tif (cin_isdo(l))\n\t\t\t{\n\t\t\t    amount = get_indent();\t\/\/ XXX\n\t\t\t    --whilelevel;\n\t\t\t    continue;\n\t\t\t}\n\t\t    }\n\n\t\t    \/\/ Found a terminated line above an unterminated line. Add\n\t\t    \/\/ the amount for a continuation line.\n\t\t    \/\/\t x = 1;\n\t\t    \/\/\t y = foo +\n\t\t    \/\/ ->\there;\n\t\t    \/\/ or\n\t\t    \/\/\t int x = 1;\n\t\t    \/\/\t int foo,\n\t\t    \/\/ ->\there;\n\t\t    if (lookfor == LOOKFOR_UNTERM\n\t\t\t\t\t   || lookfor == LOOKFOR_ENUM_OR_INIT)\n\t\t    {\n\t\t\tif (cont_amount > 0)\n\t\t\t    amount = cont_amount;\n\t\t\telse\n\t\t\t    amount += ind_continuation;\n\t\t\tbreak;\n\t\t    }\n\n\t\t    \/\/ Found a terminated line above a terminated line or \"if\"\n\t\t    \/\/ etc. line. Use the amount of the line below us.\n\t\t    \/\/\t x = 1;\t\t\t\tx = 1;\n\t\t    \/\/\t if (asdf)\t\t    y = 2;\n\t\t    \/\/\t     while (asdf)\t  ->here;\n\t\t    \/\/\t\there;\n\t\t    \/\/ ->foo;\n\t\t    if (lookfor == LOOKFOR_TERM)\n\t\t    {\n\t\t\tif (!lookfor_break && whilelevel == 0)\n\t\t\t    break;\n\t\t    }\n\n\t\t    \/\/ First line above the one we're indenting is terminated.\n\t\t    \/\/ To know what needs to be done look further backward for\n\t\t    \/\/ a terminated line.\n\t\t    else\n\t\t    {\n\t\t\t\/\/ position the cursor over the rightmost paren, so\n\t\t\t\/\/ that matching it will take us back to the start of\n\t\t\t\/\/ the line.  Helps for:\n\t\t\t\/\/     func(asdr,\n\t\t\t\/\/\t      asdfasdf);\n\t\t\t\/\/     here;\nterm_again:\n\t\t\tl = ml_get_curline();\n\t\t\tif (find_last_paren(l, '(', ')')\n\t\t\t\t&& (trypos = find_match_paren(\n\t\t\t\t\t   curbuf->b_ind_maxparen)) != NULL)\n\t\t\t{\n\t\t\t    \/\/ Check if we are on a case label now.  This is\n\t\t\t    \/\/ handled above.\n\t\t\t    \/\/\t   case xx:  if ( asdf &&\n\t\t\t    \/\/\t\t\t    asdf)\n\t\t\t    curwin->w_cursor = *trypos;\n\t\t\t    l = ml_get_curline();\n\t\t\t    if (cin_iscase(l, FALSE) || cin_isscopedecl(l))\n\t\t\t    {\n\t\t\t\t++curwin->w_cursor.lnum;\n\t\t\t\tcurwin->w_cursor.col = 0;\n\t\t\t\tcontinue;\n\t\t\t    }\n\t\t\t}\n\n\t\t\t\/\/ When aligning with the case statement, don't align\n\t\t\t\/\/ with a statement after it.\n\t\t\t\/\/  case 1: {   <-- don't use this { position\n\t\t\t\/\/\tstat;\n\t\t\t\/\/  }\n\t\t\t\/\/  case 2:\n\t\t\t\/\/\tstat;\n\t\t\t\/\/ }\n\t\t\tiscase = (curbuf->b_ind_keep_case_label\n\t\t\t\t\t\t     && cin_iscase(l, FALSE));\n\n\t\t\t\/\/ Get indent and pointer to text for current line,\n\t\t\t\/\/ ignoring any jump label.\n\t\t\tamount = skip_label(curwin->w_cursor.lnum, &l);\n\n\t\t\tif (theline[0] == '{')\n\t\t\t    amount += curbuf->b_ind_open_extra;\n\t\t\t\/\/ See remark above: \"Only add b_ind_open_extra..\"\n\t\t\tl = skipwhite(l);\n\t\t\tif (*l == '{')\n\t\t\t    amount -= curbuf->b_ind_open_extra;\n\t\t\tlookfor = iscase ? LOOKFOR_ANY : LOOKFOR_TERM;\n\n\t\t\t\/\/ When a terminated line starts with \"else\" skip to\n\t\t\t\/\/ the matching \"if\":\n\t\t\t\/\/       else 3;\n\t\t\t\/\/\t     indent this;\n\t\t\t\/\/ Need to use the scope of this \"else\".  XXX\n\t\t\t\/\/ If whilelevel != 0 continue looking for a \"do {\".\n\t\t\tif (lookfor == LOOKFOR_TERM\n\t\t\t\t&& *l != '}'\n\t\t\t\t&& cin_iselse(l)\n\t\t\t\t&& whilelevel == 0)\n\t\t\t{\n\t\t\t    if ((trypos = find_start_brace()) == NULL\n\t\t\t\t       || find_match(LOOKFOR_IF, trypos->lnum)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t\t\t\tbreak;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\t\/\/ If we're at the end of a block, skip to the start of\n\t\t\t\/\/ that block.\n\t\t\tl = ml_get_curline();\n\t\t\tif (find_last_paren(l, '{', '}') \/\/ XXX\n\t\t\t\t     && (trypos = find_start_brace()) != NULL)\n\t\t\t{\n\t\t\t    curwin->w_cursor = *trypos;\n\t\t\t    \/\/ if not \"else {\" check for terminated again\n\t\t\t    \/\/ but skip block for \"} else {\"\n\t\t\t    l = cin_skipcomment(ml_get_curline());\n\t\t\t    if (*l == '}' || !cin_iselse(l))\n\t\t\t\tgoto term_again;\n\t\t\t    ++curwin->w_cursor.lnum;\n\t\t\t    curwin->w_cursor.col = 0;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t}\n      }\n\n      \/\/ add extra indent for a comment\n      if (cin_iscomment(theline))\n\t  amount += curbuf->b_ind_comment;\n\n      \/\/ subtract extra left-shift for jump labels\n      if (curbuf->b_ind_jump_label > 0 && original_line_islabel)\n\t  amount -= curbuf->b_ind_jump_label;\n\n      goto theend;\n    }\n\n    \/\/ ok -- we're not inside any sort of structure at all!\n    \/\/\n    \/\/ This means we're at the top level, and everything should\n    \/\/ basically just match where the previous line is, except\n    \/\/ for the lines immediately following a function declaration,\n    \/\/ which are K&R-style parameters and need to be indented.\n    \/\/\n    \/\/ if our line starts with an open brace, forget about any\n    \/\/ prevailing indent and make sure it looks like the start\n    \/\/ of a function\n\n    if (theline[0] == '{')\n    {\n\tamount = curbuf->b_ind_first_open;\n\tgoto theend;\n    }\n\n    \/\/ If the NEXT line is a function declaration, the current\n    \/\/ line needs to be indented as a function type spec.\n    \/\/ Don't do this if the current line looks like a comment or if the\n    \/\/ current line is terminated, ie. ends in ';', or if the current line\n    \/\/ contains { or }: \"void f() {\\n if (1)\"\n    if (cur_curpos.lnum < curbuf->b_ml.ml_line_count\n\t    && !cin_nocode(theline)\n\t    && vim_strchr(theline, '{') == NULL\n\t    && vim_strchr(theline, '}') == NULL\n\t    && !cin_ends_in(theline, (char_u *)\":\", NULL)\n\t    && !cin_ends_in(theline, (char_u *)\",\", NULL)\n\t    && cin_isfuncdecl(NULL, cur_curpos.lnum + 1,\n\t\t\t      cur_curpos.lnum + 1)\n\t    && !cin_isterminated(theline, FALSE, TRUE))\n    {\n\tamount = curbuf->b_ind_func_type;\n\tgoto theend;\n    }\n\n    \/\/ search backwards until we find something we recognize\n    amount = 0;\n    curwin->w_cursor = cur_curpos;\n    while (curwin->w_cursor.lnum > 1)\n    {\n\tcurwin->w_cursor.lnum--;\n\tcurwin->w_cursor.col = 0;\n\n\tl = ml_get_curline();\n\n\t\/\/ If we're in a comment or raw string now, skip to the start\n\t\/\/ of it.  XXX\n\tif ((trypos = ind_find_start_CORS(NULL)) != NULL)\n\t{\n\t    curwin->w_cursor.lnum = trypos->lnum + 1;\n\t    curwin->w_cursor.col = 0;\n\t    continue;\n\t}\n\n\t\/\/ Are we at the start of a cpp base class declaration or\n\t\/\/ constructor initialization?  XXX\n\tn = FALSE;\n\tif (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{')\n\t{\n\t    n = cin_is_cpp_baseclass(&cache_cpp_baseclass);\n\t    l = ml_get_curline();\n\t}\n\tif (n)\n\t{\n\t\t\t\t\t\t\t     \/\/ XXX\n\t    amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col);\n\t    break;\n\t}\n\n\t\/\/ Skip preprocessor directives and blank lines.\n\tif (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount))\n\t    continue;\n\n\tif (cin_nocode(l))\n\t    continue;\n\n\t\/\/ If the previous line ends in ',', use one level of\n\t\/\/ indentation:\n\t\/\/ int foo,\n\t\/\/     bar;\n\t\/\/ do this before checking for '}' in case of eg.\n\t\/\/ enum foobar\n\t\/\/ {\n\t\/\/   ...\n\t\/\/ } foo,\n\t\/\/   bar;\n\tn = 0;\n\tif (cin_ends_in(l, (char_u *)\",\", NULL)\n\t\t     || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\\\'))\n\t{\n\t    \/\/ take us back to opening paren\n\t    if (find_last_paren(l, '(', ')')\n\t\t    && (trypos = find_match_paren(\n\t\t\t\t     curbuf->b_ind_maxparen)) != NULL)\n\t\tcurwin->w_cursor = *trypos;\n\n\t    \/\/ For a line ending in ',' that is a continuation line go\n\t    \/\/ back to the first line with a backslash:\n\t    \/\/ char *foo = \"bla{backslash}\n\t    \/\/\t\t bla\",\n\t    \/\/      here;\n\t    while (n == 0 && curwin->w_cursor.lnum > 1)\n\t    {\n\t\tl = ml_get(curwin->w_cursor.lnum - 1);\n\t\tif (*l == NUL || l[STRLEN(l) - 1] != '\\\\')\n\t\t    break;\n\t\t--curwin->w_cursor.lnum;\n\t\tcurwin->w_cursor.col = 0;\n\t    }\n\n\t    amount = get_indent();\t    \/\/ XXX\n\n\t    if (amount == 0)\n\t\tamount = cin_first_id_amount();\n\t    if (amount == 0)\n\t\tamount = ind_continuation;\n\t    break;\n\t}\n\n\t\/\/ If the line looks like a function declaration, and we're\n\t\/\/ not in a comment, put it the left margin.\n\tif (cin_isfuncdecl(NULL, cur_curpos.lnum, 0))  \/\/ XXX\n\t    break;\n\tl = ml_get_curline();\n\n\t\/\/ Finding the closing '}' of a previous function.  Put\n\t\/\/ current line at the left margin.  For when 'cino' has \"fs\".\n\tif (*skipwhite(l) == '}')\n\t    break;\n\n\t\/\/\t\t\t    (matching {)\n\t\/\/ If the previous line ends on '};' (maybe followed by\n\t\/\/ comments) align at column 0.  For example:\n\t\/\/ char *string_array[] = { \"foo\",\n\t\/\/     \/ * x * \/ \"b};ar\" }; \/ * foobar * \/\n\tif (cin_ends_in(l, (char_u *)\"};\", NULL))\n\t    break;\n\n\t\/\/ If the previous line ends on '[' we are probably in an\n\t\/\/ array constant:\n\t\/\/ something = [\n\t\/\/     234,  <- extra indent\n\tif (cin_ends_in(l, (char_u *)\"[\", NULL))\n\t{\n\t    amount = get_indent() + ind_continuation;\n\t    break;\n\t}\n\n\t\/\/ Find a line only has a semicolon that belongs to a previous\n\t\/\/ line ending in '}', e.g. before an #endif.  Don't increase\n\t\/\/ indent then.\n\tif (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1))\n\t{\n\t    pos_T curpos_save = curwin->w_cursor;\n\n\t    while (curwin->w_cursor.lnum > 1)\n\t    {\n\t\tlook = ml_get(--curwin->w_cursor.lnum);\n\t\tif (!(cin_nocode(look) || cin_ispreproc_cont(\n\t\t\t\t      &look, &curwin->w_cursor.lnum, &amount)))\n\t\t    break;\n\t    }\n\t    if (curwin->w_cursor.lnum > 0\n\t\t\t    && cin_ends_in(look, (char_u *)\"}\", NULL))\n\t\tbreak;\n\n\t    curwin->w_cursor = curpos_save;\n\t}\n\n\t\/\/ If the PREVIOUS line is a function declaration, the current\n\t\/\/ line (and the ones that follow) needs to be indented as\n\t\/\/ parameters.\n\tif (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0))\n\t{\n\t    amount = curbuf->b_ind_param;\n\t    break;\n\t}\n\n\t\/\/ If the previous line ends in ';' and the line before the\n\t\/\/ previous line ends in ',' or '\\', ident to column zero:\n\t\/\/ int foo,\n\t\/\/     bar;\n\t\/\/ indent_to_0 here;\n\tif (cin_ends_in(l, (char_u *)\";\", NULL))\n\t{\n\t    l = ml_get(curwin->w_cursor.lnum - 1);\n\t    if (cin_ends_in(l, (char_u *)\",\", NULL)\n\t\t    || (*l != NUL && l[STRLEN(l) - 1] == '\\\\'))\n\t\tbreak;\n\t    l = ml_get_curline();\n\t}\n\n\t\/\/ Doesn't look like anything interesting -- so just\n\t\/\/ use the indent of this line.\n\t\/\/\n\t\/\/ Position the cursor over the rightmost paren, so that\n\t\/\/ matching it will take us back to the start of the line.\n\tfind_last_paren(l, '(', ')');\n\n\tif ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)\n\t    curwin->w_cursor = *trypos;\n\tamount = get_indent();\t    \/\/ XXX\n\tbreak;\n    }\n\n    \/\/ add extra indent for a comment\n    if (cin_iscomment(theline))\n\tamount += curbuf->b_ind_comment;\n\n    \/\/ add extra indent if the previous line ended in a backslash:\n    \/\/\t      \"asdfasdf{backslash}\n    \/\/\t\t  here\";\n    \/\/\t    char *foo = \"asdf{backslash}\n    \/\/\t\t\t here\";\n    if (cur_curpos.lnum > 1)\n    {\n\tl = ml_get(cur_curpos.lnum - 1);\n\tif (*l != NUL && l[STRLEN(l) - 1] == '\\\\')\n\t{\n\t    cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);\n\t    if (cur_amount > 0)\n\t\tamount = cur_amount;\n\t    else if (cur_amount == 0)\n\t\tamount += ind_continuation;\n\t}\n    }\n\ntheend:\n    if (amount < 0)\n\tamount = 0;\n\nlaterend:\n    \/\/ put the cursor back where it belongs\n    curwin->w_cursor = cur_curpos;\n\n    vim_free(linecopy);\n\n    return amount;\n}","target":0,"code_token_length":15057,"total_token_length":15293,"max_tokens_setting":28000}
+{"idx":195388,"func":"PQconnectPoll(PGconn *conn)\n{\n\tbool\t\treset_connection_state_machine = false;\n\tbool\t\tneed_new_connection = false;\n\tPGresult   *res;\n\tchar\t\tsebuf[PG_STRERROR_R_BUFLEN];\n\tint\t\t\toptval;\n\n\tif (conn == NULL)\n\t\treturn PGRES_POLLING_FAILED;\n\n\t\/* Get the new data *\/\n\tswitch (conn->status)\n\t{\n\t\t\t\/*\n\t\t\t * We really shouldn't have been polled in these two cases, but we\n\t\t\t * can handle it.\n\t\t\t *\/\n\t\tcase CONNECTION_BAD:\n\t\t\treturn PGRES_POLLING_FAILED;\n\t\tcase CONNECTION_OK:\n\t\t\treturn PGRES_POLLING_OK;\n\n\t\t\t\/* These are reading states *\/\n\t\tcase CONNECTION_AWAITING_RESPONSE:\n\t\tcase CONNECTION_AUTH_OK:\n\t\tcase CONNECTION_CHECK_WRITABLE:\n\t\tcase CONNECTION_CONSUME:\n\t\tcase CONNECTION_CHECK_STANDBY:\n\t\t\t{\n\t\t\t\t\/* Load waiting data *\/\n\t\t\t\tint\t\t\tn = pqReadData(conn);\n\n\t\t\t\tif (n < 0)\n\t\t\t\t\tgoto error_return;\n\t\t\t\tif (n == 0)\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t\/* These are writing states, so we just proceed. *\/\n\t\tcase CONNECTION_STARTED:\n\t\tcase CONNECTION_MADE:\n\t\t\tbreak;\n\n\t\t\t\/* Special cases: proceed without waiting. *\/\n\t\tcase CONNECTION_SSL_STARTUP:\n\t\tcase CONNECTION_NEEDED:\n\t\tcase CONNECTION_GSS_STARTUP:\n\t\tcase CONNECTION_CHECK_TARGET:\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t libpq_gettext(\"invalid connection state, probably indicative of memory corruption\\n\"));\n\t\t\tgoto error_return;\n\t}\n\n\nkeep_going:\t\t\t\t\t\t\/* We will come back to here until there is\n\t\t\t\t\t\t\t\t * nothing left to do. *\/\n\n\t\/* Time to advance to next address, or next host if no more addresses? *\/\n\tif (conn->try_next_addr)\n\t{\n\t\tif (conn->addr_cur && conn->addr_cur->ai_next)\n\t\t{\n\t\t\tconn->addr_cur = conn->addr_cur->ai_next;\n\t\t\treset_connection_state_machine = true;\n\t\t}\n\t\telse\n\t\t\tconn->try_next_host = true;\n\t\tconn->try_next_addr = false;\n\t}\n\n\t\/* Time to advance to next connhost[] entry? *\/\n\tif (conn->try_next_host)\n\t{\n\t\tpg_conn_host *ch;\n\t\tstruct addrinfo hint;\n\t\tint\t\t\tthisport;\n\t\tint\t\t\tret;\n\t\tchar\t\tportstr[MAXPGPATH];\n\n\t\tif (conn->whichhost + 1 < conn->nconnhost)\n\t\t\tconn->whichhost++;\n\t\telse\n\t\t{\n\t\t\t\/*\n\t\t\t * Oops, no more hosts.\n\t\t\t *\n\t\t\t * If we are trying to connect in \"prefer-standby\" mode, then drop\n\t\t\t * the standby requirement and start over.\n\t\t\t *\n\t\t\t * Otherwise, an appropriate error message is already set up, so\n\t\t\t * we just need to set the right status.\n\t\t\t *\/\n\t\t\tif (conn->target_server_type == SERVER_TYPE_PREFER_STANDBY &&\n\t\t\t\tconn->nconnhost > 0)\n\t\t\t{\n\t\t\t\tconn->target_server_type = SERVER_TYPE_PREFER_STANDBY_PASS2;\n\t\t\t\tconn->whichhost = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t\tgoto error_return;\n\t\t}\n\n\t\t\/* Drop any address info for previous host *\/\n\t\trelease_conn_addrinfo(conn);\n\n\t\t\/*\n\t\t * Look up info for the new host.  On failure, log the problem in\n\t\t * conn->errorMessage, then loop around to try the next host.  (Note\n\t\t * we don't clear try_next_host until we've succeeded.)\n\t\t *\/\n\t\tch = &conn->connhost[conn->whichhost];\n\n\t\t\/* Initialize hint structure *\/\n\t\tMemSet(&hint, 0, sizeof(hint));\n\t\thint.ai_socktype = SOCK_STREAM;\n\t\tconn->addrlist_family = hint.ai_family = AF_UNSPEC;\n\n\t\t\/* Figure out the port number we're going to use. *\/\n\t\tif (ch->port == NULL || ch->port[0] == '\\0')\n\t\t\tthisport = DEF_PGPORT;\n\t\telse\n\t\t{\n\t\t\tif (!parse_int_param(ch->port, &thisport, conn, \"port\"))\n\t\t\t\tgoto error_return;\n\n\t\t\tif (thisport < 1 || thisport > 65535)\n\t\t\t{\n\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"invalid port number: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t  ch->port);\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\t\t}\n\t\tsnprintf(portstr, sizeof(portstr), \"%d\", thisport);\n\n\t\t\/* Use pg_getaddrinfo_all() to resolve the address *\/\n\t\tswitch (ch->type)\n\t\t{\n\t\t\tcase CHT_HOST_NAME:\n\t\t\t\tret = pg_getaddrinfo_all(ch->host, portstr, &hint,\n\t\t\t\t\t\t\t\t\t\t &conn->addrlist);\n\t\t\t\tif (ret || !conn->addrlist)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not translate host name \\\"%s\\\" to address: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  ch->host, gai_strerror(ret));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CHT_HOST_ADDRESS:\n\t\t\t\thint.ai_flags = AI_NUMERICHOST;\n\t\t\t\tret = pg_getaddrinfo_all(ch->hostaddr, portstr, &hint,\n\t\t\t\t\t\t\t\t\t\t &conn->addrlist);\n\t\t\t\tif (ret || !conn->addrlist)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not parse network address \\\"%s\\\": %s\\n\"),\n\t\t\t\t\t\t\t\t\t  ch->hostaddr, gai_strerror(ret));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CHT_UNIX_SOCKET:\n#ifdef HAVE_UNIX_SOCKETS\n\t\t\t\tconn->addrlist_family = hint.ai_family = AF_UNIX;\n\t\t\t\tUNIXSOCK_PATH(portstr, thisport, ch->host);\n\t\t\t\tif (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"Unix-domain socket path \\\"%s\\\" is too long (maximum %d bytes)\\n\"),\n\t\t\t\t\t\t\t\t\t  portstr,\n\t\t\t\t\t\t\t\t\t  (int) (UNIXSOCK_PATH_BUFLEN - 1));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * NULL hostname tells pg_getaddrinfo_all to parse the service\n\t\t\t\t * name as a Unix-domain socket path.\n\t\t\t\t *\/\n\t\t\t\tret = pg_getaddrinfo_all(NULL, portstr, &hint,\n\t\t\t\t\t\t\t\t\t\t &conn->addrlist);\n\t\t\t\tif (ret || !conn->addrlist)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not translate Unix-domain socket path \\\"%s\\\" to address: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  portstr, gai_strerror(ret));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n#else\n\t\t\t\tAssert(false);\n#endif\n\t\t\t\tbreak;\n\t\t}\n\n\t\t\/* OK, scan this addrlist for a working server address *\/\n\t\tconn->addr_cur = conn->addrlist;\n\t\treset_connection_state_machine = true;\n\t\tconn->try_next_host = false;\n\t}\n\n\t\/* Reset connection state machine? *\/\n\tif (reset_connection_state_machine)\n\t{\n\t\t\/*\n\t\t * (Re) initialize our connection control variables for a set of\n\t\t * connection attempts to a single server address.  These variables\n\t\t * must persist across individual connection attempts, but we must\n\t\t * reset them when we start to consider a new server.\n\t\t *\/\n\t\tconn->pversion = PG_PROTOCOL(3, 0);\n\t\tconn->send_appname = true;\n#ifdef USE_SSL\n\t\t\/* initialize these values based on SSL mode *\/\n\t\tconn->allow_ssl_try = (conn->sslmode[0] != 'd');\t\/* \"disable\" *\/\n\t\tconn->wait_ssl_try = (conn->sslmode[0] == 'a'); \/* \"allow\" *\/\n#endif\n#ifdef ENABLE_GSS\n\t\tconn->try_gss = (conn->gssencmode[0] != 'd');\t\/* \"disable\" *\/\n#endif\n\n\t\treset_connection_state_machine = false;\n\t\tneed_new_connection = true;\n\t}\n\n\t\/* Force a new connection (perhaps to the same server as before)? *\/\n\tif (need_new_connection)\n\t{\n\t\t\/* Drop any existing connection *\/\n\t\tpqDropConnection(conn, true);\n\n\t\t\/* Reset all state obtained from old server *\/\n\t\tpqDropServerData(conn);\n\n\t\t\/* Drop any PGresult we might have, too *\/\n\t\tconn->asyncStatus = PGASYNC_IDLE;\n\t\tconn->xactStatus = PQTRANS_IDLE;\n\t\tconn->pipelineStatus = PQ_PIPELINE_OFF;\n\t\tpqClearAsyncResult(conn);\n\n\t\t\/* Reset conn->status to put the state machine in the right state *\/\n\t\tconn->status = CONNECTION_NEEDED;\n\n\t\tneed_new_connection = false;\n\t}\n\n\t\/* Now try to advance the state machine for this connection *\/\n\tswitch (conn->status)\n\t{\n\t\tcase CONNECTION_NEEDED:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Try to initiate a connection to one of the addresses\n\t\t\t\t * returned by pg_getaddrinfo_all().  conn->addr_cur is the\n\t\t\t\t * next one to try.\n\t\t\t\t *\n\t\t\t\t * The extra level of braces here is historical.  It's not\n\t\t\t\t * worth reindenting this whole switch case to remove 'em.\n\t\t\t\t *\/\n\t\t\t\t{\n\t\t\t\t\tstruct addrinfo *addr_cur = conn->addr_cur;\n\t\t\t\t\tchar\t\thost_addr[NI_MAXHOST];\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Advance to next possible host, if we've tried all of\n\t\t\t\t\t * the addresses for the current host.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (addr_cur == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* Remember current address for possible use later *\/\n\t\t\t\t\tmemcpy(&conn->raddr.addr, addr_cur->ai_addr,\n\t\t\t\t\t\t   addr_cur->ai_addrlen);\n\t\t\t\t\tconn->raddr.salen = addr_cur->ai_addrlen;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Set connip, too.  Note we purposely ignore strdup\n\t\t\t\t\t * failure; not a big problem if it fails.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->connip != NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tfree(conn->connip);\n\t\t\t\t\t\tconn->connip = NULL;\n\t\t\t\t\t}\n\t\t\t\t\tgetHostaddr(conn, host_addr, NI_MAXHOST);\n\t\t\t\t\tif (host_addr[0])\n\t\t\t\t\t\tconn->connip = strdup(host_addr);\n\n\t\t\t\t\t\/* Try to create the socket *\/\n\t\t\t\t\tconn->sock = socket(addr_cur->ai_family, SOCK_STREAM, 0);\n\t\t\t\t\tif (conn->sock == PGINVALID_SOCKET)\n\t\t\t\t\t{\n\t\t\t\t\t\tint\t\t\terrorno = SOCK_ERRNO;\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Silently ignore socket() failure if we have more\n\t\t\t\t\t\t * addresses to try; this reduces useless chatter in\n\t\t\t\t\t\t * cases where the address list includes both IPv4 and\n\t\t\t\t\t\t * IPv6 but kernel only accepts one family.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (addr_cur->ai_next != NULL ||\n\t\t\t\t\t\t\tconn->whichhost + 1 < conn->nconnhost)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temitHostIdentityInfo(conn, host_addr);\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not create socket: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Once we've identified a target address, all errors\n\t\t\t\t\t * except the preceding socket()-failure case should be\n\t\t\t\t\t * prefixed with host-identity information.  (If the\n\t\t\t\t\t * connection succeeds, the contents of conn->errorMessage\n\t\t\t\t\t * won't matter, so this is harmless.)\n\t\t\t\t\t *\/\n\t\t\t\t\temitHostIdentityInfo(conn, host_addr);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Select socket options: no delay of outgoing data for\n\t\t\t\t\t * TCP sockets, nonblock mode, close-on-exec.  Try the\n\t\t\t\t\t * next address if any of this fails.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (!IS_AF_UNIX(addr_cur->ai_family))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!connectNoDelay(conn))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* error message already created *\/\n\t\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!pg_set_noblock(conn->sock))\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not set socket to nonblocking mode: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n#ifdef F_SETFD\n\t\t\t\t\tif (fcntl(conn->sock, F_SETFD, FD_CLOEXEC) == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not set socket to close-on-exec mode: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n#endif\t\t\t\t\t\t\t\/* F_SETFD *\/\n\n\t\t\t\t\tif (!IS_AF_UNIX(addr_cur->ai_family))\n\t\t\t\t\t{\n#ifndef WIN32\n\t\t\t\t\t\tint\t\t\ton = 1;\n#endif\n\t\t\t\t\t\tint\t\t\tusekeepalives = useKeepalives(conn);\n\t\t\t\t\t\tint\t\t\terr = 0;\n\n\t\t\t\t\t\tif (usekeepalives < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"keepalives parameter must be an integer\\n\"));\n\t\t\t\t\t\t\terr = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (usekeepalives == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* Do nothing *\/\n\t\t\t\t\t\t}\n#ifndef WIN32\n\t\t\t\t\t\telse if (setsockopt(conn->sock,\n\t\t\t\t\t\t\t\t\t\t\tSOL_SOCKET, SO_KEEPALIVE,\n\t\t\t\t\t\t\t\t\t\t\t(char *) &on, sizeof(on)) < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"%s(%s) failed: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  \"setsockopt\",\n\t\t\t\t\t\t\t\t\t\t\t  \"SO_KEEPALIVE\",\n\t\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\t\terr = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (!setKeepalivesIdle(conn)\n\t\t\t\t\t\t\t\t || !setKeepalivesInterval(conn)\n\t\t\t\t\t\t\t\t || !setKeepalivesCount(conn))\n\t\t\t\t\t\t\terr = 1;\n#else\t\t\t\t\t\t\t\/* WIN32 *\/\n#ifdef SIO_KEEPALIVE_VALS\n\t\t\t\t\t\telse if (!setKeepalivesWin32(conn))\n\t\t\t\t\t\t\terr = 1;\n#endif\t\t\t\t\t\t\t\/* SIO_KEEPALIVE_VALS *\/\n#endif\t\t\t\t\t\t\t\/* WIN32 *\/\n\t\t\t\t\t\telse if (!setTCPUserTimeout(conn))\n\t\t\t\t\t\t\terr = 1;\n\n\t\t\t\t\t\tif (err)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*----------\n\t\t\t\t\t * We have three methods of blocking SIGPIPE during\n\t\t\t\t\t * send() calls to this socket:\n\t\t\t\t\t *\n\t\t\t\t\t *\t- setsockopt(sock, SO_NOSIGPIPE)\n\t\t\t\t\t *\t- send(sock, ..., MSG_NOSIGNAL)\n\t\t\t\t\t *\t- setting the signal mask to SIG_IGN during send()\n\t\t\t\t\t *\n\t\t\t\t\t * The third method requires three syscalls per send,\n\t\t\t\t\t * so we prefer either of the first two, but they are\n\t\t\t\t\t * less portable.  The state is tracked in the following\n\t\t\t\t\t * members of PGconn:\n\t\t\t\t\t *\n\t\t\t\t\t * conn->sigpipe_so\t\t- we have set up SO_NOSIGPIPE\n\t\t\t\t\t * conn->sigpipe_flag\t- we're specifying MSG_NOSIGNAL\n\t\t\t\t\t *\n\t\t\t\t\t * If we can use SO_NOSIGPIPE, then set sigpipe_so here\n\t\t\t\t\t * and we're done.  Otherwise, set sigpipe_flag so that\n\t\t\t\t\t * we will try MSG_NOSIGNAL on sends.  If we get an error\n\t\t\t\t\t * with MSG_NOSIGNAL, we'll clear that flag and revert to\n\t\t\t\t\t * signal masking.\n\t\t\t\t\t *----------\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->sigpipe_so = false;\n#ifdef MSG_NOSIGNAL\n\t\t\t\t\tconn->sigpipe_flag = true;\n#else\n\t\t\t\t\tconn->sigpipe_flag = false;\n#endif\t\t\t\t\t\t\t\/* MSG_NOSIGNAL *\/\n\n#ifdef SO_NOSIGPIPE\n\t\t\t\t\toptval = 1;\n\t\t\t\t\tif (setsockopt(conn->sock, SOL_SOCKET, SO_NOSIGPIPE,\n\t\t\t\t\t\t\t\t   (char *) &optval, sizeof(optval)) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->sigpipe_so = true;\n\t\t\t\t\t\tconn->sigpipe_flag = false;\n\t\t\t\t\t}\n#endif\t\t\t\t\t\t\t\/* SO_NOSIGPIPE *\/\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Start\/make connection.  This should not block, since we\n\t\t\t\t\t * are in nonblock mode.  If it does, well, too bad.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (connect(conn->sock, addr_cur->ai_addr,\n\t\t\t\t\t\t\t\taddr_cur->ai_addrlen) < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (SOCK_ERRNO == EINPROGRESS ||\n#ifdef WIN32\n\t\t\t\t\t\t\tSOCK_ERRNO == EWOULDBLOCK ||\n#endif\n\t\t\t\t\t\t\tSOCK_ERRNO == EINTR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/*\n\t\t\t\t\t\t\t * This is fine - we're in non-blocking mode, and\n\t\t\t\t\t\t\t * the connection is in progress.  Tell caller to\n\t\t\t\t\t\t\t * wait for write-ready on socket.\n\t\t\t\t\t\t\t *\/\n\t\t\t\t\t\t\tconn->status = CONNECTION_STARTED;\n\t\t\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/* otherwise, trouble *\/\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Hm, we're connected already --- seems the \"nonblock\n\t\t\t\t\t\t * connection\" wasn't.  Advance the state machine and\n\t\t\t\t\t\t * go do the next stuff.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_STARTED;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * This connection failed.  Add the error report to\n\t\t\t\t\t * conn->errorMessage, then try the next address if any.\n\t\t\t\t\t *\/\n\t\t\t\t\tconnectFailureMessage(conn, SOCK_ERRNO);\n\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase CONNECTION_STARTED:\n\t\t\t{\n\t\t\t\tACCEPT_TYPE_ARG3 optlen = sizeof(optval);\n\n\t\t\t\t\/*\n\t\t\t\t * Write ready, since we've made it here, so the connection\n\t\t\t\t * has been made ... or has failed.\n\t\t\t\t *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Now check (using getsockopt) that there is not an error\n\t\t\t\t * state waiting for us on the socket.\n\t\t\t\t *\/\n\n\t\t\t\tif (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,\n\t\t\t\t\t\t\t   (char *) &optval, &optlen) == -1)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not get socket error status: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\t\t\t\telse if (optval != 0)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * When using a nonblocking connect, we will typically see\n\t\t\t\t\t * connect failures at this point, so provide a friendly\n\t\t\t\t\t * error message.\n\t\t\t\t\t *\/\n\t\t\t\t\tconnectFailureMessage(conn, optval);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Try the next address if any, just as in the case where\n\t\t\t\t\t * connect() returned failure immediately.\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/* Fill in the client address *\/\n\t\t\t\tconn->laddr.salen = sizeof(conn->laddr.addr);\n\t\t\t\tif (getsockname(conn->sock,\n\t\t\t\t\t\t\t\t(struct sockaddr *) &conn->laddr.addr,\n\t\t\t\t\t\t\t\t&conn->laddr.salen) < 0)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not get client address from socket: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Make sure we can write before advancing to next step.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t}\n\n\t\tcase CONNECTION_MADE:\n\t\t\t{\n\t\t\t\tchar\t   *startpacket;\n\t\t\t\tint\t\t\tpacketlen;\n\n\t\t\t\t\/*\n\t\t\t\t * Implement requirepeer check, if requested and it's a\n\t\t\t\t * Unix-domain socket.\n\t\t\t\t *\/\n\t\t\t\tif (conn->requirepeer && conn->requirepeer[0] &&\n\t\t\t\t\tIS_AF_UNIX(conn->raddr.addr.ss_family))\n\t\t\t\t{\n#ifndef WIN32\n\t\t\t\t\tchar\t\tpwdbuf[BUFSIZ];\n\t\t\t\t\tstruct passwd pass_buf;\n\t\t\t\t\tstruct passwd *pass;\n\t\t\t\t\tint\t\t\tpasserr;\n#endif\n\t\t\t\t\tuid_t\t\tuid;\n\t\t\t\t\tgid_t\t\tgid;\n\n\t\t\t\t\terrno = 0;\n\t\t\t\t\tif (getpeereid(conn->sock, &uid, &gid) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Provide special error message if getpeereid is a\n\t\t\t\t\t\t * stub\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (errno == ENOSYS)\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"requirepeer parameter is not supported on this platform\\n\"));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not get peer credentials: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  strerror_r(errno, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n#ifndef WIN32\n\t\t\t\t\tpasserr = pqGetpwuid(uid, &pass_buf, pwdbuf, sizeof(pwdbuf), &pass);\n\t\t\t\t\tif (pass == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (passerr != 0)\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not look up local user ID %d: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  (int) uid,\n\t\t\t\t\t\t\t\t\t\t\t  strerror_r(passerr, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"local user with ID %d does not exist\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  (int) uid);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (strcmp(pass->pw_name, conn->requirepeer) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"requirepeer specifies \\\"%s\\\", but actual peer user name is \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t\t\t  conn->requirepeer, pass->pw_name);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n#else\t\t\t\t\t\t\t\/* WIN32 *\/\n\t\t\t\t\t\/* should have failed with ENOSYS above *\/\n\t\t\t\t\tAssert(false);\n#endif\t\t\t\t\t\t\t\/* WIN32 *\/\n\t\t\t\t}\n\n\t\t\t\tif (IS_AF_UNIX(conn->raddr.addr.ss_family))\n\t\t\t\t{\n\t\t\t\t\t\/* Don't request SSL or GSSAPI over Unix sockets *\/\n#ifdef USE_SSL\n\t\t\t\t\tconn->allow_ssl_try = false;\n#endif\n#ifdef ENABLE_GSS\n\t\t\t\t\tconn->try_gss = false;\n#endif\n\t\t\t\t}\n\n#ifdef ENABLE_GSS\n\n\t\t\t\t\/*\n\t\t\t\t * If GSSAPI encryption is enabled, then call\n\t\t\t\t * pg_GSS_have_cred_cache() which will return true if we can\n\t\t\t\t * acquire credentials (and give us a handle to use in\n\t\t\t\t * conn->gcred), and then send a packet to the server asking\n\t\t\t\t * for GSSAPI Encryption (and skip past SSL negotiation and\n\t\t\t\t * regular startup below).\n\t\t\t\t *\/\n\t\t\t\tif (conn->try_gss && !conn->gctx)\n\t\t\t\t\tconn->try_gss = pg_GSS_have_cred_cache(&conn->gcred);\n\t\t\t\tif (conn->try_gss && !conn->gctx)\n\t\t\t\t{\n\t\t\t\t\tProtocolVersion pv = pg_hton32(NEGOTIATE_GSS_CODE);\n\n\t\t\t\t\tif (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not send GSSAPI negotiation packet: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* Ok, wait for response *\/\n\t\t\t\t\tconn->status = CONNECTION_GSS_STARTUP;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\t\t\t\telse if (!conn->gctx && conn->gssencmode[0] == 'r')\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"GSSAPI encryption required but was impossible (possibly no credential cache, no server support, or using a local socket)\\n\"));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n#endif\n\n#ifdef USE_SSL\n\n\t\t\t\t\/*\n\t\t\t\t * Enable the libcrypto callbacks before checking if SSL needs\n\t\t\t\t * to be done.  This is done before sending the startup packet\n\t\t\t\t * as depending on the type of authentication done, like MD5\n\t\t\t\t * or SCRAM that use cryptohashes, the callbacks would be\n\t\t\t\t * required even without a SSL connection\n\t\t\t\t *\/\n\t\t\t\tif (pqsecure_initialize(conn, false, true) < 0)\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\t\/*\n\t\t\t\t * If SSL is enabled and we haven't already got encryption of\n\t\t\t\t * some sort running, request SSL instead of sending the\n\t\t\t\t * startup message.\n\t\t\t\t *\/\n\t\t\t\tif (conn->allow_ssl_try && !conn->wait_ssl_try &&\n\t\t\t\t\t!conn->ssl_in_use\n#ifdef ENABLE_GSS\n\t\t\t\t\t&& !conn->gssenc\n#endif\n\t\t\t\t\t)\n\t\t\t\t{\n\t\t\t\t\tProtocolVersion pv;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Send the SSL request packet.\n\t\t\t\t\t *\n\t\t\t\t\t * Theoretically, this could block, but it really\n\t\t\t\t\t * shouldn't since we only got here if the socket is\n\t\t\t\t\t * write-ready.\n\t\t\t\t\t *\/\n\t\t\t\t\tpv = pg_hton32(NEGOTIATE_SSL_CODE);\n\t\t\t\t\tif (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not send SSL negotiation packet: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t\t\/* Ok, wait for response *\/\n\t\t\t\t\tconn->status = CONNECTION_SSL_STARTUP;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n#endif\t\t\t\t\t\t\t\/* USE_SSL *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Build the startup packet.\n\t\t\t\t *\/\n\t\t\t\tstartpacket = pqBuildStartupPacket3(conn, &packetlen,\n\t\t\t\t\t\t\t\t\t\t\t\t\tEnvironmentOptions);\n\t\t\t\tif (!startpacket)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"out of memory\\n\"));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Send the startup packet.\n\t\t\t\t *\n\t\t\t\t * Theoretically, this could block, but it really shouldn't\n\t\t\t\t * since we only got here if the socket is write-ready.\n\t\t\t\t *\/\n\t\t\t\tif (pqPacketSend(conn, 0, startpacket, packetlen) != STATUS_OK)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not send startup packet: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\tfree(startpacket);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\tfree(startpacket);\n\n\t\t\t\tconn->status = CONNECTION_AWAITING_RESPONSE;\n\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Handle SSL negotiation: wait for postmaster messages and\n\t\t\t * respond as necessary.\n\t\t\t *\/\n\t\tcase CONNECTION_SSL_STARTUP:\n\t\t\t{\n#ifdef USE_SSL\n\t\t\t\tPostgresPollingStatusType pollres;\n\n\t\t\t\t\/*\n\t\t\t\t * On first time through, get the postmaster's response to our\n\t\t\t\t * SSL negotiation packet.\n\t\t\t\t *\/\n\t\t\t\tif (!conn->ssl_in_use)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * We use pqReadData here since it has the logic to\n\t\t\t\t\t * distinguish no-data-yet from connection closure. Since\n\t\t\t\t\t * conn->ssl isn't set, a plain recv() will occur.\n\t\t\t\t\t *\/\n\t\t\t\t\tchar\t\tSSLok;\n\t\t\t\t\tint\t\t\trdresult;\n\n\t\t\t\t\trdresult = pqReadData(conn);\n\t\t\t\t\tif (rdresult < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* errorMessage is already filled in *\/\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t\tif (rdresult == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* caller failed to wait for data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\tif (pqGetc(&SSLok, conn) < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* should not happen really *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\tif (SSLok == 'S')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* mark byte consumed *\/\n\t\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Set up global SSL state if required.  The crypto\n\t\t\t\t\t\t * state has already been set if libpq took care of\n\t\t\t\t\t\t * doing that, so there is no need to make that happen\n\t\t\t\t\t\t * again.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (pqsecure_initialize(conn, true, false) != 0)\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t\telse if (SSLok == 'N')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* mark byte consumed *\/\n\t\t\t\t\t\tconn->inStart = conn->inCursor;\n\t\t\t\t\t\t\/* OK to do without SSL? *\/\n\t\t\t\t\t\tif (conn->sslmode[0] == 'r' ||\t\/* \"require\" *\/\n\t\t\t\t\t\t\tconn->sslmode[0] == 'v')\t\/* \"verify-ca\" or\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t * \"verify-full\" *\/\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* Require SSL, but server does not want it *\/\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server does not support SSL, but SSL was required\\n\"));\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/* Otherwise, proceed with normal startup *\/\n\t\t\t\t\t\tconn->allow_ssl_try = false;\n\t\t\t\t\t\t\/* We can proceed using this connection *\/\n\t\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t\t}\n\t\t\t\t\telse if (SSLok == 'E')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Server failure of some sort, such as failure to\n\t\t\t\t\t\t * fork a backend process.  We need to process and\n\t\t\t\t\t\t * report the error message, which might be formatted\n\t\t\t\t\t\t * according to either protocol 2 or protocol 3.\n\t\t\t\t\t\t * Rather than duplicate the code for that, we flip\n\t\t\t\t\t\t * into AWAITING_RESPONSE state and let the code there\n\t\t\t\t\t\t * deal with it.  Note we have *not* consumed the \"E\"\n\t\t\t\t\t\t * byte here.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_AWAITING_RESPONSE;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"received invalid response to SSL negotiation: %c\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SSLok);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Begin or continue the SSL negotiation process.\n\t\t\t\t *\/\n\t\t\t\tpollres = pqsecure_open_client(conn);\n\t\t\t\tif (pollres == PGRES_POLLING_OK)\n\t\t\t\t{\n\t\t\t\t\t\/* SSL handshake done, ready to send startup packet *\/\n\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t}\n\t\t\t\tif (pollres == PGRES_POLLING_FAILED)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * Failed ... if sslmode is \"prefer\" then do a non-SSL\n\t\t\t\t\t * retry\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sslmode[0] == 'p' \/* \"prefer\" *\/\n\t\t\t\t\t\t&& conn->allow_ssl_try\t\/* redundant? *\/\n\t\t\t\t\t\t&& !conn->wait_ssl_try) \/* redundant? *\/\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->allow_ssl_try = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t\t\/* Else it's a hard failure *\/\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\t\t\t\t\/* Else, return POLLING_READING or POLLING_WRITING status *\/\n\t\t\t\treturn pollres;\n#else\t\t\t\t\t\t\t\/* !USE_SSL *\/\n\t\t\t\t\/* can't get here *\/\n\t\t\t\tgoto error_return;\n#endif\t\t\t\t\t\t\t\/* USE_SSL *\/\n\t\t\t}\n\n\t\tcase CONNECTION_GSS_STARTUP:\n\t\t\t{\n#ifdef ENABLE_GSS\n\t\t\t\tPostgresPollingStatusType pollres;\n\n\t\t\t\t\/*\n\t\t\t\t * If we haven't yet, get the postmaster's response to our\n\t\t\t\t * negotiation packet\n\t\t\t\t *\/\n\t\t\t\tif (conn->try_gss && !conn->gctx)\n\t\t\t\t{\n\t\t\t\t\tchar\t\tgss_ok;\n\t\t\t\t\tint\t\t\trdresult = pqReadData(conn);\n\n\t\t\t\t\tif (rdresult < 0)\n\t\t\t\t\t\t\/* pqReadData fills in error message *\/\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\telse if (rdresult == 0)\n\t\t\t\t\t\t\/* caller failed to wait for data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\tif (pqGetc(&gss_ok, conn) < 0)\n\t\t\t\t\t\t\/* shouldn't happen... *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\n\t\t\t\t\tif (gss_ok == 'E')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Server failure of some sort.  Assume it's a\n\t\t\t\t\t\t * protocol version support failure, and let's see if\n\t\t\t\t\t\t * we can't recover (if it's not, we'll get a better\n\t\t\t\t\t\t * error message on retry).  Server gets fussy if we\n\t\t\t\t\t\t * don't hang up the socket, though.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* mark byte consumed *\/\n\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\tif (gss_ok == 'N')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Server doesn't want GSSAPI; fall back if we can *\/\n\t\t\t\t\t\tif (conn->gssencmode[0] == 'r')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server doesn't support GSSAPI encryption, but it was required\\n\"));\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\t\t\/* We can proceed using this connection *\/\n\t\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t\t}\n\t\t\t\t\telse if (gss_ok != 'G')\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"received invalid response to GSSAPI negotiation: %c\\n\"),\n\t\t\t\t\t\t\t\t\t\t  gss_ok);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/* Begin or continue GSSAPI negotiation *\/\n\t\t\t\tpollres = pqsecure_open_gss(conn);\n\t\t\t\tif (pollres == PGRES_POLLING_OK)\n\t\t\t\t{\n\t\t\t\t\t\/* All set for startup packet *\/\n\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t}\n\t\t\t\telse if (pollres == PGRES_POLLING_FAILED &&\n\t\t\t\t\t\t conn->gssencmode[0] == 'p')\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * We failed, but we can retry on \"prefer\".  Have to drop\n\t\t\t\t\t * the current connection to do so, though.\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t\treturn pollres;\n#else\t\t\t\t\t\t\t\/* !ENABLE_GSS *\/\n\t\t\t\t\/* unreachable *\/\n\t\t\t\tgoto error_return;\n#endif\t\t\t\t\t\t\t\/* ENABLE_GSS *\/\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Handle authentication exchange: wait for postmaster messages\n\t\t\t * and respond as necessary.\n\t\t\t *\/\n\t\tcase CONNECTION_AWAITING_RESPONSE:\n\t\t\t{\n\t\t\t\tchar\t\tberesp;\n\t\t\t\tint\t\t\tmsgLength;\n\t\t\t\tint\t\t\tavail;\n\t\t\t\tAuthRequest areq;\n\t\t\t\tint\t\t\tres;\n\n\t\t\t\t\/*\n\t\t\t\t * Scan the message from current point (note that if we find\n\t\t\t\t * the message is incomplete, we will return without advancing\n\t\t\t\t * inStart, and resume here next time).\n\t\t\t\t *\/\n\t\t\t\tconn->inCursor = conn->inStart;\n\n\t\t\t\t\/* Read type byte *\/\n\t\t\t\tif (pqGetc(&beresp, conn))\n\t\t\t\t{\n\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Validate message type: we expect only an authentication\n\t\t\t\t * request or an error here.  Anything else probably means\n\t\t\t\t * it's not Postgres on the other end at all.\n\t\t\t\t *\/\n\t\t\t\tif (!(beresp == 'R' || beresp == 'E'))\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"expected authentication request from server, but received %c\\n\"),\n\t\t\t\t\t\t\t\t\t  beresp);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/* Read message length word *\/\n\t\t\t\tif (pqGetInt(&msgLength, 4, conn))\n\t\t\t\t{\n\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Try to validate message length before using it.\n\t\t\t\t * Authentication requests can't be very large, although GSS\n\t\t\t\t * auth requests may not be that small.  Errors can be a\n\t\t\t\t * little larger, but not huge.  If we see a large apparent\n\t\t\t\t * length in an error, it means we're really talking to a\n\t\t\t\t * pre-3.0-protocol server; cope.  (Before version 14, the\n\t\t\t\t * server also used the old protocol for errors that happened\n\t\t\t\t * before processing the startup packet.)\n\t\t\t\t *\/\n\t\t\t\tif (beresp == 'R' && (msgLength < 8 || msgLength > 2000))\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"expected authentication request from server, but received %c\\n\"),\n\t\t\t\t\t\t\t\t\t  beresp);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\tif (beresp == 'E' && (msgLength < 8 || msgLength > 30000))\n\t\t\t\t{\n\t\t\t\t\t\/* Handle error from a pre-3.0 server *\/\n\t\t\t\t\tconn->inCursor = conn->inStart + 1; \/* reread data *\/\n\t\t\t\t\tif (pqGets_append(&conn->errorMessage, conn))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\t\/* OK, we read the message; mark data consumed *\/\n\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Before 7.2, the postmaster didn't always end its\n\t\t\t\t\t * messages with a newline, so add one if needed to\n\t\t\t\t\t * conform to libpq conventions.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->errorMessage.len == 0 ||\n\t\t\t\t\t\tconn->errorMessage.data[conn->errorMessage.len - 1] != '\\n')\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBufferChar(&conn->errorMessage, '\\n');\n\t\t\t\t\t}\n\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Can't process if message body isn't all here yet.\n\t\t\t\t *\/\n\t\t\t\tmsgLength -= 4;\n\t\t\t\tavail = conn->inEnd - conn->inCursor;\n\t\t\t\tif (avail < msgLength)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * Before returning, try to enlarge the input buffer if\n\t\t\t\t\t * needed to hold the whole message; see notes in\n\t\t\t\t\t * pqParseInput3.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength,\n\t\t\t\t\t\t\t\t\t\t\t conn))\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/* Handle errors. *\/\n\t\t\t\tif (beresp == 'E')\n\t\t\t\t{\n\t\t\t\t\tif (pqGetErrorNotice3(conn, true))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\t\/* OK, we read the message; mark data consumed *\/\n\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If error is \"cannot connect now\", try the next host if\n\t\t\t\t\t * any (but we don't want to consider additional addresses\n\t\t\t\t\t * for this host, nor is there much point in changing SSL\n\t\t\t\t\t * or GSS mode).  This is helpful when dealing with\n\t\t\t\t\t * standby servers that might not be in hot-standby state.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (strcmp(conn->last_sqlstate,\n\t\t\t\t\t\t\t   ERRCODE_CANNOT_CONNECT_NOW) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* Check to see if we should mention pgpassfile *\/\n\t\t\t\t\tpgpassfileWarning(conn);\n\n#ifdef ENABLE_GSS\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If gssencmode is \"prefer\" and we're using GSSAPI, retry\n\t\t\t\t\t * without it.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->gssenc && conn->gssencmode[0] == 'p')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n#endif\n\n#ifdef USE_SSL\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if sslmode is \"allow\" and we haven't tried an SSL\n\t\t\t\t\t * connection already, then retry with an SSL connection\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sslmode[0] == 'a' \/* \"allow\" *\/\n\t\t\t\t\t\t&& !conn->ssl_in_use\n\t\t\t\t\t\t&& conn->allow_ssl_try\n\t\t\t\t\t\t&& conn->wait_ssl_try)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->wait_ssl_try = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if sslmode is \"prefer\" and we're in an SSL connection,\n\t\t\t\t\t * then do a non-SSL retry\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sslmode[0] == 'p' \/* \"prefer\" *\/\n\t\t\t\t\t\t&& conn->ssl_in_use\n\t\t\t\t\t\t&& conn->allow_ssl_try\t\/* redundant? *\/\n\t\t\t\t\t\t&& !conn->wait_ssl_try) \/* redundant? *\/\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->allow_ssl_try = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n#endif\n\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/* It is an authentication request. *\/\n\t\t\t\tconn->auth_req_received = true;\n\n\t\t\t\t\/* Get the type of request. *\/\n\t\t\t\tif (pqGetInt((int *) &areq, 4, conn))\n\t\t\t\t{\n\t\t\t\t\t\/* We'll come back when there are more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\t\t\t\tmsgLength -= 4;\n\n\t\t\t\t\/*\n\t\t\t\t * Process the rest of the authentication request message, and\n\t\t\t\t * respond to it if necessary.\n\t\t\t\t *\n\t\t\t\t * Note that conn->pghost must be non-NULL if we are going to\n\t\t\t\t * avoid the Kerberos code doing a hostname look-up.\n\t\t\t\t *\/\n\t\t\t\tres = pg_fe_sendauth(areq, msgLength, conn);\n\n\t\t\t\t\/* OK, we have processed the message; mark data consumed *\/\n\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\tif (res != STATUS_OK)\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\t\/*\n\t\t\t\t * Just make sure that any data sent by pg_fe_sendauth is\n\t\t\t\t * flushed out.  Although this theoretically could block, it\n\t\t\t\t * really shouldn't since we don't send large auth responses.\n\t\t\t\t *\/\n\t\t\t\tif (pqFlush(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (areq == AUTH_REQ_OK)\n\t\t\t\t{\n\t\t\t\t\t\/* We are done with authentication exchange *\/\n\t\t\t\t\tconn->status = CONNECTION_AUTH_OK;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Set asyncStatus so that PQgetResult will think that\n\t\t\t\t\t * what comes back next is the result of a query.  See\n\t\t\t\t\t * below.\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->asyncStatus = PGASYNC_BUSY;\n\t\t\t\t}\n\n\t\t\t\t\/* Look to see if we have more data yet. *\/\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_AUTH_OK:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Now we expect to hear from the backend. A ReadyForQuery\n\t\t\t\t * message indicates that startup is successful, but we might\n\t\t\t\t * also get an Error message indicating failure. (Notice\n\t\t\t\t * messages indicating nonfatal warnings are also allowed by\n\t\t\t\t * the protocol, as are ParameterStatus and BackendKeyData\n\t\t\t\t * messages.) Easiest way to handle this is to let\n\t\t\t\t * PQgetResult() read the messages. We just have to fake it\n\t\t\t\t * out about the state of the connection, by setting\n\t\t\t\t * asyncStatus = PGASYNC_BUSY (done above).\n\t\t\t\t *\/\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\n\t\t\t\tres = PQgetResult(conn);\n\n\t\t\t\t\/*\n\t\t\t\t * NULL return indicating we have gone to IDLE state is\n\t\t\t\t * expected\n\t\t\t\t *\/\n\t\t\t\tif (res)\n\t\t\t\t{\n\t\t\t\t\tif (res->resultStatus != PGRES_FATAL_ERROR)\n\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"unexpected message from server during startup\\n\"));\n\t\t\t\t\telse if (conn->send_appname &&\n\t\t\t\t\t\t\t (conn->appname || conn->fbappname))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * If we tried to send application_name, check to see\n\t\t\t\t\t\t * if the error is about that --- pre-9.0 servers will\n\t\t\t\t\t\t * reject it at this stage of the process.  If so,\n\t\t\t\t\t\t * close the connection and retry without sending\n\t\t\t\t\t\t * application_name.  We could possibly get a false\n\t\t\t\t\t\t * SQLSTATE match here and retry uselessly, but there\n\t\t\t\t\t\t * seems no great harm in that; we'll just get the\n\t\t\t\t\t\t * same error again if it's unrelated.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconst char *sqlstate;\n\n\t\t\t\t\t\tsqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);\n\t\t\t\t\t\tif (sqlstate &&\n\t\t\t\t\t\t\tstrcmp(sqlstate, ERRCODE_APPNAME_UNKNOWN) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tPQclear(res);\n\t\t\t\t\t\t\tconn->send_appname = false;\n\t\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if the resultStatus is FATAL, then conn->errorMessage\n\t\t\t\t\t * already has a copy of the error; needn't copy it back.\n\t\t\t\t\t * But add a newline if it's not there already, since\n\t\t\t\t\t * postmaster error messages may not have one.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->errorMessage.len <= 0 ||\n\t\t\t\t\t\tconn->errorMessage.data[conn->errorMessage.len - 1] != '\\n')\n\t\t\t\t\t\tappendPQExpBufferChar(&conn->errorMessage, '\\n');\n\t\t\t\t\tPQclear(res);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/* Almost there now ... *\/\n\t\t\t\tconn->status = CONNECTION_CHECK_TARGET;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_CHECK_TARGET:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * If a read-write, read-only, primary, or standby connection\n\t\t\t\t * is required, see if we have one.\n\t\t\t\t *\/\n\t\t\t\tif (conn->target_server_type == SERVER_TYPE_READ_WRITE ||\n\t\t\t\t\tconn->target_server_type == SERVER_TYPE_READ_ONLY)\n\t\t\t\t{\n\t\t\t\t\tbool\t\tread_only_server;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If the server didn't report\n\t\t\t\t\t * \"default_transaction_read_only\" or \"in_hot_standby\" at\n\t\t\t\t\t * startup, we must determine its state by sending the\n\t\t\t\t\t * query \"SHOW transaction_read_only\".  This GUC exists in\n\t\t\t\t\t * all server versions that support 3.0 protocol.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->default_transaction_read_only == PG_BOOL_UNKNOWN ||\n\t\t\t\t\t\tconn->in_hot_standby == PG_BOOL_UNKNOWN)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * We use PQsendQueryContinue so that\n\t\t\t\t\t\t * conn->errorMessage does not get cleared.  We need\n\t\t\t\t\t\t * to preserve any error messages related to previous\n\t\t\t\t\t\t * hosts we have tried and failed to connect to.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tif (!PQsendQueryContinue(conn,\n\t\t\t\t\t\t\t\t\t\t\t\t \"SHOW transaction_read_only\"))\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t\/* We'll return to this state when we have the answer *\/\n\t\t\t\t\t\tconn->status = CONNECTION_CHECK_WRITABLE;\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* OK, we can make the test *\/\n\t\t\t\t\tread_only_server =\n\t\t\t\t\t\t(conn->default_transaction_read_only == PG_BOOL_YES ||\n\t\t\t\t\t\t conn->in_hot_standby == PG_BOOL_YES);\n\n\t\t\t\t\tif ((conn->target_server_type == SERVER_TYPE_READ_WRITE) ?\n\t\t\t\t\t\tread_only_server : !read_only_server)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Wrong server state, reject and try the next host *\/\n\t\t\t\t\t\tif (conn->target_server_type == SERVER_TYPE_READ_WRITE)\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"session is read-only\\n\"));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"session is not read-only\\n\"));\n\n\t\t\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Try next host if any, but we don't want to consider\n\t\t\t\t\t\t * additional addresses for this host.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (conn->target_server_type == SERVER_TYPE_PRIMARY ||\n\t\t\t\t\t\t conn->target_server_type == SERVER_TYPE_STANDBY ||\n\t\t\t\t\t\t conn->target_server_type == SERVER_TYPE_PREFER_STANDBY)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * If the server didn't report \"in_hot_standby\" at\n\t\t\t\t\t * startup, we must determine its state by sending the\n\t\t\t\t\t * query \"SELECT pg_catalog.pg_is_in_recovery()\".  Servers\n\t\t\t\t\t * before 9.0 don't have that function, but by the same\n\t\t\t\t\t * token they don't have any standby mode, so we may just\n\t\t\t\t\t * assume the result.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sversion < 90000)\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_NO;\n\n\t\t\t\t\tif (conn->in_hot_standby == PG_BOOL_UNKNOWN)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * We use PQsendQueryContinue so that\n\t\t\t\t\t\t * conn->errorMessage does not get cleared.  We need\n\t\t\t\t\t\t * to preserve any error messages related to previous\n\t\t\t\t\t\t * hosts we have tried and failed to connect to.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tif (!PQsendQueryContinue(conn,\n\t\t\t\t\t\t\t\t\t\t\t\t \"SELECT pg_catalog.pg_is_in_recovery()\"))\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t\/* We'll return to this state when we have the answer *\/\n\t\t\t\t\t\tconn->status = CONNECTION_CHECK_STANDBY;\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* OK, we can make the test *\/\n\t\t\t\t\tif ((conn->target_server_type == SERVER_TYPE_PRIMARY) ?\n\t\t\t\t\t\t(conn->in_hot_standby == PG_BOOL_YES) :\n\t\t\t\t\t\t(conn->in_hot_standby == PG_BOOL_NO))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Wrong server state, reject and try the next host *\/\n\t\t\t\t\t\tif (conn->target_server_type == SERVER_TYPE_PRIMARY)\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server is in hot standby mode\\n\"));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server is not in hot standby mode\\n\"));\n\n\t\t\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Try next host if any, but we don't want to consider\n\t\t\t\t\t\t * additional addresses for this host.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/* We can release the address list now. *\/\n\t\t\t\trelease_conn_addrinfo(conn);\n\n\t\t\t\t\/*\n\t\t\t\t * Contents of conn->errorMessage are no longer interesting\n\t\t\t\t * (and it seems some clients expect it to be empty after a\n\t\t\t\t * successful connection).\n\t\t\t\t *\/\n\t\t\t\tresetPQExpBuffer(&conn->errorMessage);\n\n\t\t\t\t\/* We are open for business! *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\treturn PGRES_POLLING_OK;\n\t\t\t}\n\n\t\tcase CONNECTION_CONSUME:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * This state just makes sure the connection is idle after\n\t\t\t\t * we've obtained the result of a SHOW or SELECT query.  Once\n\t\t\t\t * we're clear, return to CONNECTION_CHECK_TARGET state to\n\t\t\t\t * decide what to do next.  We must transiently set status =\n\t\t\t\t * CONNECTION_OK in order to use the result-consuming\n\t\t\t\t * subroutines.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tif (!PQconsumeInput(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/* Call PQgetResult() again until we get a NULL result *\/\n\t\t\t\tres = PQgetResult(conn);\n\t\t\t\tif (res != NULL)\n\t\t\t\t{\n\t\t\t\t\tPQclear(res);\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\tconn->status = CONNECTION_CHECK_TARGET;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_CHECK_WRITABLE:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Waiting for result of \"SHOW transaction_read_only\".  We\n\t\t\t\t * must transiently set status = CONNECTION_OK in order to use\n\t\t\t\t * the result-consuming subroutines.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tif (!PQconsumeInput(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_CHECK_WRITABLE;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\tres = PQgetResult(conn);\n\t\t\t\tif (res && PQresultStatus(res) == PGRES_TUPLES_OK &&\n\t\t\t\t\tPQntuples(res) == 1)\n\t\t\t\t{\n\t\t\t\t\tchar\t   *val = PQgetvalue(res, 0, 0);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * \"transaction_read_only = on\" proves that at least one\n\t\t\t\t\t * of default_transaction_read_only and in_hot_standby is\n\t\t\t\t\t * on, but we don't actually know which.  We don't care\n\t\t\t\t\t * though for the purpose of identifying a read-only\n\t\t\t\t\t * session, so satisfy the CONNECTION_CHECK_TARGET code by\n\t\t\t\t\t * claiming they are both on.  On the other hand, if it's\n\t\t\t\t\t * a read-write session, they are certainly both off.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (strncmp(val, \"on\", 2) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->default_transaction_read_only = PG_BOOL_YES;\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_YES;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->default_transaction_read_only = PG_BOOL_NO;\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_NO;\n\t\t\t\t\t}\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\t\/* Finish reading messages before continuing *\/\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/* Something went wrong with \"SHOW transaction_read_only\". *\/\n\t\t\t\tif (res)\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\/* Append error report to conn->errorMessage. *\/\n\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"\\\"%s\\\" failed\\n\"),\n\t\t\t\t\t\t\t\t  \"SHOW transaction_read_only\");\n\n\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\/* Try next host. *\/\n\t\t\t\tconn->try_next_host = true;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_CHECK_STANDBY:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Waiting for result of \"SELECT pg_is_in_recovery()\".  We\n\t\t\t\t * must transiently set status = CONNECTION_OK in order to use\n\t\t\t\t * the result-consuming subroutines.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tif (!PQconsumeInput(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_CHECK_STANDBY;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\tres = PQgetResult(conn);\n\t\t\t\tif (res && PQresultStatus(res) == PGRES_TUPLES_OK &&\n\t\t\t\t\tPQntuples(res) == 1)\n\t\t\t\t{\n\t\t\t\t\tchar\t   *val = PQgetvalue(res, 0, 0);\n\n\t\t\t\t\tif (strncmp(val, \"t\", 1) == 0)\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_YES;\n\t\t\t\t\telse\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_NO;\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\t\/* Finish reading messages before continuing *\/\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/* Something went wrong with \"SELECT pg_is_in_recovery()\". *\/\n\t\t\t\tif (res)\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\/* Append error report to conn->errorMessage. *\/\n\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"\\\"%s\\\" failed\\n\"),\n\t\t\t\t\t\t\t\t  \"SELECT pg_is_in_recovery()\");\n\n\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\/* Try next host. *\/\n\t\t\t\tconn->try_next_host = true;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tdefault:\n\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"invalid connection state %d, \"\n\t\t\t\t\t\t\t\t\t\t\t\"probably indicative of memory corruption\\n\"),\n\t\t\t\t\t\t\t  conn->status);\n\t\t\tgoto error_return;\n\t}\n\n\t\/* Unreachable *\/\n\nerror_return:\n\n\t\/*\n\t * We used to close the socket at this point, but that makes it awkward\n\t * for those above us if they wish to remove this socket from their own\n\t * records (an fd_set for example).  We'll just have this socket closed\n\t * when PQfinish is called (which is compulsory even after an error, since\n\t * the connection structure must be freed).\n\t *\/\n\tconn->status = CONNECTION_BAD;\n\treturn PGRES_POLLING_FAILED;\n}","target":1,"code_token_length":12369,"total_token_length":12605,"max_tokens_setting":28000}
+{"idx":428226,"func":"CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,\n                     va_list param)\n{\n  char *argptr;\n  CURLcode result = CURLE_OK;\n  long arg;\n#ifndef CURL_DISABLE_HTTP\n  curl_off_t bigsize;\n#endif\n\n  switch(option) {\n  case CURLOPT_DNS_CACHE_TIMEOUT:\n    data->set.dns_cache_timeout = va_arg(param, long);\n    break;\n  case CURLOPT_DNS_USE_GLOBAL_CACHE:\n    \/* remember we want this enabled *\/\n    arg = va_arg(param, long);\n    data->set.global_dns_cache = (0 != arg)?TRUE:FALSE;\n    break;\n  case CURLOPT_SSL_CIPHER_LIST:\n    \/* set a list of cipher we want to use in the SSL connection *\/\n    result = setstropt(&data->set.str[STRING_SSL_CIPHER_LIST],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_RANDOM_FILE:\n    \/*\n     * This is the path name to a file that contains random data to seed\n     * the random SSL stuff with. The file is only used for reading.\n     *\/\n    result = setstropt(&data->set.str[STRING_SSL_RANDOM_FILE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_EGDSOCKET:\n    \/*\n     * The Entropy Gathering Daemon socket pathname\n     *\/\n    result = setstropt(&data->set.str[STRING_SSL_EGDSOCKET],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_MAXCONNECTS:\n    \/*\n     * Set the absolute number of maximum simultaneous alive connection that\n     * libcurl is allowed to have.\n     *\/\n    data->set.maxconnects = va_arg(param, long);\n    break;\n  case CURLOPT_FORBID_REUSE:\n    \/*\n     * When this transfer is done, it must not be left to be reused by a\n     * subsequent transfer but shall be closed immediately.\n     *\/\n    data->set.reuse_forbid = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_FRESH_CONNECT:\n    \/*\n     * This transfer shall not use a previously cached connection but\n     * should be made with a fresh new connect!\n     *\/\n    data->set.reuse_fresh = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_VERBOSE:\n    \/*\n     * Verbose means infof() calls that give a lot of information about\n     * the connection and transfer procedures as well as internal choices.\n     *\/\n    data->set.verbose = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_HEADER:\n    \/*\n     * Set to include the header in the general data output stream.\n     *\/\n    data->set.include_header = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_NOPROGRESS:\n    \/*\n     * Shut off the internal supported progress meter\n     *\/\n    data->set.hide_progress = (0 != va_arg(param, long))?TRUE:FALSE;\n    if(data->set.hide_progress)\n      data->progress.flags |= PGRS_HIDE;\n    else\n      data->progress.flags &= ~PGRS_HIDE;\n    break;\n  case CURLOPT_NOBODY:\n    \/*\n     * Do not include the body part in the output data stream.\n     *\/\n    data->set.opt_no_body = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_FAILONERROR:\n    \/*\n     * Don't output the >=400 error code HTML-page, but instead only\n     * return error.\n     *\/\n    data->set.http_fail_on_error = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_UPLOAD:\n  case CURLOPT_PUT:\n    \/*\n     * We want to sent data to the remote host. If this is HTTP, that equals\n     * using the PUT request.\n     *\/\n    data->set.upload = (0 != va_arg(param, long))?TRUE:FALSE;\n    if(data->set.upload) {\n      \/* If this is HTTP, PUT is what's needed to \"upload\" *\/\n      data->set.httpreq = HTTPREQ_PUT;\n      data->set.opt_no_body = FALSE; \/* this is implied *\/\n    }\n    else\n      \/* In HTTP, the opposite of upload is GET (unless NOBODY is true as\n         then this can be changed to HEAD later on) *\/\n      data->set.httpreq = HTTPREQ_GET;\n    break;\n  case CURLOPT_FILETIME:\n    \/*\n     * Try to get the file time of the remote document. The time will\n     * later (possibly) become available using curl_easy_getinfo().\n     *\/\n    data->set.get_filetime = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_FTP_CREATE_MISSING_DIRS:\n    \/*\n     * An FTP option that modifies an upload to create missing directories on\n     * the server.\n     *\/\n    switch(va_arg(param, long)) {\n    case 0:\n      data->set.ftp_create_missing_dirs = 0;\n      break;\n    case 1:\n      data->set.ftp_create_missing_dirs = 1;\n      break;\n    case 2:\n      data->set.ftp_create_missing_dirs = 2;\n      break;\n    default:\n      \/* reserve other values for future use *\/\n      result = CURLE_UNKNOWN_OPTION;\n      break;\n    }\n    break;\n  case CURLOPT_SERVER_RESPONSE_TIMEOUT:\n    \/*\n     * Option that specifies how quickly an server response must be obtained\n     * before it is considered failure. For pingpong protocols.\n     *\/\n    data->set.server_response_timeout = va_arg( param , long ) * 1000;\n    break;\n  case CURLOPT_TFTP_BLKSIZE:\n    \/*\n     * TFTP option that specifies the block size to use for data transmission\n     *\/\n    data->set.tftp_blksize = va_arg(param, long);\n    break;\n  case CURLOPT_DIRLISTONLY:\n    \/*\n     * An option that changes the command to one that asks for a list\n     * only, no file info details.\n     *\/\n    data->set.ftp_list_only = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_APPEND:\n    \/*\n     * We want to upload and append to an existing file.\n     *\/\n    data->set.ftp_append = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_FTP_FILEMETHOD:\n    \/*\n     * How do access files over FTP.\n     *\/\n    data->set.ftp_filemethod = (curl_ftpfile)va_arg(param, long);\n    break;\n  case CURLOPT_NETRC:\n    \/*\n     * Parse the $HOME\/.netrc file\n     *\/\n    data->set.use_netrc = (enum CURL_NETRC_OPTION)va_arg(param, long);\n    break;\n  case CURLOPT_NETRC_FILE:\n    \/*\n     * Use this file instead of the $HOME\/.netrc file\n     *\/\n    result = setstropt(&data->set.str[STRING_NETRC_FILE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_TRANSFERTEXT:\n    \/*\n     * This option was previously named 'FTPASCII'. Renamed to work with\n     * more protocols than merely FTP.\n     *\n     * Transfer using ASCII (instead of BINARY).\n     *\/\n    data->set.prefer_ascii = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_TIMECONDITION:\n    \/*\n     * Set HTTP time condition. This must be one of the defines in the\n     * curl\/curl.h header file.\n     *\/\n    data->set.timecondition = (curl_TimeCond)va_arg(param, long);\n    break;\n  case CURLOPT_TIMEVALUE:\n    \/*\n     * This is the value to compare with the remote document with the\n     * method set with CURLOPT_TIMECONDITION\n     *\/\n    data->set.timevalue = (time_t)va_arg(param, long);\n    break;\n  case CURLOPT_SSLVERSION:\n    \/*\n     * Set explicit SSL version to try to connect with, as some SSL\n     * implementations are lame.\n     *\/\n    data->set.ssl.version = va_arg(param, long);\n    break;\n\n#ifndef CURL_DISABLE_HTTP\n  case CURLOPT_AUTOREFERER:\n    \/*\n     * Switch on automatic referer that gets set if curl follows locations.\n     *\/\n    data->set.http_auto_referer = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_ACCEPT_ENCODING:\n    \/*\n     * String to use at the value of Accept-Encoding header.\n     *\n     * If the encoding is set to \"\" we use an Accept-Encoding header that\n     * encompasses all the encodings we support.\n     * If the encoding is set to NULL we don't send an Accept-Encoding header\n     * and ignore an received Content-Encoding header.\n     *\n     *\/\n    argptr = va_arg(param, char *);\n    result = setstropt(&data->set.str[STRING_ENCODING],\n                       (argptr && !*argptr)?\n                       (char *) ALL_CONTENT_ENCODINGS: argptr);\n    break;\n\n  case CURLOPT_TRANSFER_ENCODING:\n    data->set.http_transfer_encoding = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_FOLLOWLOCATION:\n    \/*\n     * Follow Location: header hints on a HTTP-server.\n     *\/\n    data->set.http_follow_location = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_UNRESTRICTED_AUTH:\n    \/*\n     * Send authentication (user+password) when following locations, even when\n     * hostname changed.\n     *\/\n    data->set.http_disable_hostname_check_before_authentication =\n      (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_MAXREDIRS:\n    \/*\n     * The maximum amount of hops you allow curl to follow Location:\n     * headers. This should mostly be used to detect never-ending loops.\n     *\/\n    data->set.maxredirs = va_arg(param, long);\n    break;\n\n  case CURLOPT_POSTREDIR:\n  {\n    \/*\n     * Set the behaviour of POST when redirecting\n     * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302\n     * CURL_REDIR_POST_301 - POST is kept as POST after 301\n     * CURL_REDIR_POST_302 - POST is kept as POST after 302\n     * CURL_REDIR_POST_303 - POST is kept as POST after 303\n     * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303\n     * other - POST is kept as POST after 301 and 302\n     *\/\n    int postRedir = curlx_sltosi(va_arg(param, long));\n    data->set.keep_post = postRedir & CURL_REDIR_POST_ALL;\n  }\n  break;\n\n  case CURLOPT_POST:\n    \/* Does this option serve a purpose anymore? Yes it does, when\n       CURLOPT_POSTFIELDS isn't used and the POST data is read off the\n       callback! *\/\n    if(va_arg(param, long)) {\n      data->set.httpreq = HTTPREQ_POST;\n      data->set.opt_no_body = FALSE; \/* this is implied *\/\n    }\n    else\n      data->set.httpreq = HTTPREQ_GET;\n    break;\n\n  case CURLOPT_COPYPOSTFIELDS:\n    \/*\n     * A string with POST data. Makes curl HTTP POST. Even if it is NULL.\n     * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to\n     *  CURLOPT_COPYPOSTFIELDS and not altered later.\n     *\/\n    argptr = va_arg(param, char *);\n\n    if(!argptr || data->set.postfieldsize == -1)\n      result = setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);\n    else {\n      \/*\n       *  Check that requested length does not overflow the size_t type.\n       *\/\n\n      if((data->set.postfieldsize < 0) ||\n         ((sizeof(curl_off_t) != sizeof(size_t)) &&\n          (data->set.postfieldsize > (curl_off_t)((size_t)-1))))\n        result = CURLE_OUT_OF_MEMORY;\n      else {\n        char * p;\n\n        (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);\n\n        \/* Allocate even when size == 0. This satisfies the need of possible\n           later address compare to detect the COPYPOSTFIELDS mode, and\n           to mark that postfields is used rather than read function or\n           form data.\n        *\/\n        p = malloc((size_t)(data->set.postfieldsize?\n                            data->set.postfieldsize:1));\n\n        if(!p)\n          result = CURLE_OUT_OF_MEMORY;\n        else {\n          if(data->set.postfieldsize)\n            memcpy(p, argptr, (size_t)data->set.postfieldsize);\n\n          data->set.str[STRING_COPYPOSTFIELDS] = p;\n        }\n      }\n    }\n\n    data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];\n    data->set.httpreq = HTTPREQ_POST;\n    break;\n\n  case CURLOPT_POSTFIELDS:\n    \/*\n     * Like above, but use static data instead of copying it.\n     *\/\n    data->set.postfields = va_arg(param, void *);\n    \/* Release old copied data. *\/\n    (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);\n    data->set.httpreq = HTTPREQ_POST;\n    break;\n\n  case CURLOPT_POSTFIELDSIZE:\n    \/*\n     * The size of the POSTFIELD data to prevent libcurl to do strlen() to\n     * figure it out. Enables binary posts.\n     *\/\n    bigsize = va_arg(param, long);\n\n    if(data->set.postfieldsize < bigsize &&\n       data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {\n      \/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. *\/\n      (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);\n      data->set.postfields = NULL;\n    }\n\n    data->set.postfieldsize = bigsize;\n    break;\n\n  case CURLOPT_POSTFIELDSIZE_LARGE:\n    \/*\n     * The size of the POSTFIELD data to prevent libcurl to do strlen() to\n     * figure it out. Enables binary posts.\n     *\/\n    bigsize = va_arg(param, curl_off_t);\n\n    if(data->set.postfieldsize < bigsize &&\n       data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {\n      \/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. *\/\n      (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);\n      data->set.postfields = NULL;\n    }\n\n    data->set.postfieldsize = bigsize;\n    break;\n\n  case CURLOPT_HTTPPOST:\n    \/*\n     * Set to make us do HTTP POST\n     *\/\n    data->set.httppost = va_arg(param, struct curl_httppost *);\n    data->set.httpreq = HTTPREQ_POST_FORM;\n    data->set.opt_no_body = FALSE; \/* this is implied *\/\n    break;\n\n  case CURLOPT_REFERER:\n    \/*\n     * String to set in the HTTP Referer: field.\n     *\/\n    if(data->change.referer_alloc) {\n      Curl_safefree(data->change.referer);\n      data->change.referer_alloc = FALSE;\n    }\n    result = setstropt(&data->set.str[STRING_SET_REFERER],\n                       va_arg(param, char *));\n    data->change.referer = data->set.str[STRING_SET_REFERER];\n    break;\n\n  case CURLOPT_USERAGENT:\n    \/*\n     * String to use in the HTTP User-Agent field\n     *\/\n    result = setstropt(&data->set.str[STRING_USERAGENT],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_HTTPHEADER:\n    \/*\n     * Set a list with HTTP headers to use (or replace internals with)\n     *\/\n    data->set.headers = va_arg(param, struct curl_slist *);\n    break;\n\n  case CURLOPT_PROXYHEADER:\n    \/*\n     * Set a list with proxy headers to use (or replace internals with)\n     *\n     * Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a\n     * long time we remain doing it this way until CURLOPT_PROXYHEADER is\n     * used. As soon as this option has been used, if set to anything but\n     * NULL, custom headers for proxies are only picked from this list.\n     *\n     * Set this option to NULL to restore the previous behavior.\n     *\/\n    data->set.proxyheaders = va_arg(param, struct curl_slist *);\n    break;\n\n  case CURLOPT_HEADEROPT:\n    \/*\n     * Set header option.\n     *\/\n    arg = va_arg(param, long);\n    data->set.sep_headers = (arg & CURLHEADER_SEPARATE)? TRUE: FALSE;\n    break;\n\n  case CURLOPT_HTTP200ALIASES:\n    \/*\n     * Set a list of aliases for HTTP 200 in response header\n     *\/\n    data->set.http200aliases = va_arg(param, struct curl_slist *);\n    break;\n\n#if !defined(CURL_DISABLE_COOKIES)\n  case CURLOPT_COOKIE:\n    \/*\n     * Cookie string to send to the remote server in the request.\n     *\/\n    result = setstropt(&data->set.str[STRING_COOKIE],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_COOKIEFILE:\n    \/*\n     * Set cookie file to read and parse. Can be used multiple times.\n     *\/\n    argptr = (char *)va_arg(param, void *);\n    if(argptr) {\n      struct curl_slist *cl;\n      \/* append the cookie file name to the list of file names, and deal with\n         them later *\/\n      cl = curl_slist_append(data->change.cookielist, argptr);\n      if(!cl) {\n        curl_slist_free_all(data->change.cookielist);\n        data->change.cookielist = NULL;\n        return CURLE_OUT_OF_MEMORY;\n      }\n      data->change.cookielist = cl; \/* store the list for later use *\/\n    }\n    break;\n\n  case CURLOPT_COOKIEJAR:\n    \/*\n     * Set cookie file name to dump all cookies to when we're done.\n     *\/\n  {\n    struct CookieInfo *newcookies;\n    result = setstropt(&data->set.str[STRING_COOKIEJAR],\n                       va_arg(param, char *));\n\n    \/*\n     * Activate the cookie parser. This may or may not already\n     * have been made.\n     *\/\n    newcookies = Curl_cookie_init(data, NULL, data->cookies,\n                                  data->set.cookiesession);\n    if(!newcookies)\n      result = CURLE_OUT_OF_MEMORY;\n    data->cookies = newcookies;\n  }\n    break;\n\n  case CURLOPT_COOKIESESSION:\n    \/*\n     * Set this option to TRUE to start a new \"cookie session\". It will\n     * prevent the forthcoming read-cookies-from-file actions to accept\n     * cookies that are marked as being session cookies, as they belong to a\n     * previous session.\n     *\n     * In the original Netscape cookie spec, \"session cookies\" are cookies\n     * with no expire date set. RFC2109 describes the same action if no\n     * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds\n     * a 'Discard' action that can enforce the discard even for cookies that\n     * have a Max-Age.\n     *\n     * We run mostly with the original cookie spec, as hardly anyone implements\n     * anything else.\n     *\/\n    data->set.cookiesession = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_COOKIELIST:\n    argptr = va_arg(param, char *);\n\n    if(argptr == NULL)\n      break;\n\n    if(Curl_raw_equal(argptr, \"ALL\")) {\n      \/* clear all cookies *\/\n      Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);\n      Curl_cookie_clearall(data->cookies);\n      Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);\n    }\n    else if(Curl_raw_equal(argptr, \"SESS\")) {\n      \/* clear session cookies *\/\n      Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);\n      Curl_cookie_clearsess(data->cookies);\n      Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);\n    }\n    else if(Curl_raw_equal(argptr, \"FLUSH\")) {\n      \/* flush cookies to file, takes care of the locking *\/\n      Curl_flush_cookies(data, 0);\n    }\n    else if(Curl_raw_equal(argptr, \"RELOAD\")) {\n      \/* reload cookies from file *\/\n      Curl_cookie_loadfiles(data);\n      break;\n    }\n    else {\n      if(!data->cookies)\n        \/* if cookie engine was not running, activate it *\/\n        data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);\n\n      argptr = strdup(argptr);\n      if(!argptr || !data->cookies) {\n        result = CURLE_OUT_OF_MEMORY;\n        Curl_safefree(argptr);\n      }\n      else {\n        Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);\n\n        if(checkprefix(\"Set-Cookie:\", argptr))\n          \/* HTTP Header format line *\/\n          Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);\n\n        else\n          \/* Netscape format line *\/\n          Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);\n\n        Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);\n        free(argptr);\n      }\n    }\n\n    break;\n#endif \/* CURL_DISABLE_COOKIES *\/\n\n  case CURLOPT_HTTPGET:\n    \/*\n     * Set to force us do HTTP GET\n     *\/\n    if(va_arg(param, long)) {\n      data->set.httpreq = HTTPREQ_GET;\n      data->set.upload = FALSE; \/* switch off upload *\/\n      data->set.opt_no_body = FALSE; \/* this is implied *\/\n    }\n    break;\n\n  case CURLOPT_HTTP_VERSION:\n    \/*\n     * This sets a requested HTTP version to be used. The value is one of\n     * the listed enums in curl\/curl.h.\n     *\/\n    arg = va_arg(param, long);\n#ifndef USE_NGHTTP2\n    if(arg == CURL_HTTP_VERSION_2_0)\n      return CURLE_UNSUPPORTED_PROTOCOL;\n#endif\n    data->set.httpversion = arg;\n    break;\n\n  case CURLOPT_HTTPAUTH:\n    \/*\n     * Set HTTP Authentication type BITMASK.\n     *\/\n  {\n    int bitcheck;\n    bool authbits;\n    unsigned long auth = va_arg(param, unsigned long);\n\n    if(auth == CURLAUTH_NONE) {\n      data->set.httpauth = auth;\n      break;\n    }\n\n    \/* the DIGEST_IE bit is only used to set a special marker, for all the\n       rest we need to handle it as normal DIGEST *\/\n    data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE;\n\n    if(auth & CURLAUTH_DIGEST_IE) {\n      auth |= CURLAUTH_DIGEST; \/* set standard digest bit *\/\n      auth &= ~CURLAUTH_DIGEST_IE; \/* unset ie digest bit *\/\n    }\n\n    \/* switch off bits we can't support *\/\n#ifndef USE_NTLM\n    auth &= ~CURLAUTH_NTLM;    \/* no NTLM support *\/\n    auth &= ~CURLAUTH_NTLM_WB; \/* no NTLM_WB support *\/\n#elif !defined(NTLM_WB_ENABLED)\n    auth &= ~CURLAUTH_NTLM_WB; \/* no NTLM_WB support *\/\n#endif\n#ifndef USE_SPNEGO\n    auth &= ~CURLAUTH_NEGOTIATE; \/* no Negotiate (SPNEGO) auth without\n                                    GSS-API or SSPI *\/\n#endif\n\n    \/* check if any auth bit lower than CURLAUTH_ONLY is still set *\/\n    bitcheck = 0;\n    authbits = FALSE;\n    while(bitcheck < 31) {\n      if(auth & (1UL << bitcheck++)) {\n        authbits = TRUE;\n        break;\n      }\n    }\n    if(!authbits)\n      return CURLE_NOT_BUILT_IN; \/* no supported types left! *\/\n\n    data->set.httpauth = auth;\n  }\n  break;\n\n  case CURLOPT_EXPECT_100_TIMEOUT_MS:\n    \/*\n     * Time to wait for a response to a HTTP request containing an\n     * Expect: 100-continue header before sending the data anyway.\n     *\/\n    data->set.expect_100_timeout = va_arg(param, long);\n    break;\n\n#endif   \/* CURL_DISABLE_HTTP *\/\n\n  case CURLOPT_CUSTOMREQUEST:\n    \/*\n     * Set a custom string to use as request\n     *\/\n    result = setstropt(&data->set.str[STRING_CUSTOMREQUEST],\n                       va_arg(param, char *));\n\n    \/* we don't set\n       data->set.httpreq = HTTPREQ_CUSTOM;\n       here, we continue as if we were using the already set type\n       and this just changes the actual request keyword *\/\n    break;\n\n#ifndef CURL_DISABLE_PROXY\n  case CURLOPT_HTTPPROXYTUNNEL:\n    \/*\n     * Tunnel operations through the proxy instead of normal proxy use\n     *\/\n    data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_PROXYPORT:\n    \/*\n     * Explicitly set HTTP proxy port number.\n     *\/\n    data->set.proxyport = va_arg(param, long);\n    break;\n\n  case CURLOPT_PROXYAUTH:\n    \/*\n     * Set HTTP Authentication type BITMASK.\n     *\/\n  {\n    int bitcheck;\n    bool authbits;\n    unsigned long auth = va_arg(param, unsigned long);\n\n    if(auth == CURLAUTH_NONE) {\n      data->set.proxyauth = auth;\n      break;\n    }\n\n    \/* the DIGEST_IE bit is only used to set a special marker, for all the\n       rest we need to handle it as normal DIGEST *\/\n    data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE;\n\n    if(auth & CURLAUTH_DIGEST_IE) {\n      auth |= CURLAUTH_DIGEST; \/* set standard digest bit *\/\n      auth &= ~CURLAUTH_DIGEST_IE; \/* unset ie digest bit *\/\n    }\n    \/* switch off bits we can't support *\/\n#ifndef USE_NTLM\n    auth &= ~CURLAUTH_NTLM;    \/* no NTLM support *\/\n    auth &= ~CURLAUTH_NTLM_WB; \/* no NTLM_WB support *\/\n#elif !defined(NTLM_WB_ENABLED)\n    auth &= ~CURLAUTH_NTLM_WB; \/* no NTLM_WB support *\/\n#endif\n#ifndef USE_SPNEGO\n    auth &= ~CURLAUTH_NEGOTIATE; \/* no Negotiate (SPNEGO) auth without\n                                    GSS-API or SSPI *\/\n#endif\n\n    \/* check if any auth bit lower than CURLAUTH_ONLY is still set *\/\n    bitcheck = 0;\n    authbits = FALSE;\n    while(bitcheck < 31) {\n      if(auth & (1UL << bitcheck++)) {\n        authbits = TRUE;\n        break;\n      }\n    }\n    if(!authbits)\n      return CURLE_NOT_BUILT_IN; \/* no supported types left! *\/\n\n    data->set.proxyauth = auth;\n  }\n  break;\n\n  case CURLOPT_PROXY:\n    \/*\n     * Set proxy server:port to use as HTTP proxy.\n     *\n     * If the proxy is set to \"\" we explicitly say that we don't want to use a\n     * proxy (even though there might be environment variables saying so).\n     *\n     * Setting it to NULL, means no proxy but allows the environment variables\n     * to decide for us.\n     *\/\n    result = setstropt(&data->set.str[STRING_PROXY],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_PROXYTYPE:\n    \/*\n     * Set proxy type. HTTP\/HTTP_1_0\/SOCKS4\/SOCKS4a\/SOCKS5\/SOCKS5_HOSTNAME\n     *\/\n    data->set.proxytype = (curl_proxytype)va_arg(param, long);\n    break;\n\n  case CURLOPT_PROXY_TRANSFER_MODE:\n    \/*\n     * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy\n     *\/\n    switch (va_arg(param, long)) {\n    case 0:\n      data->set.proxy_transfer_mode = FALSE;\n      break;\n    case 1:\n      data->set.proxy_transfer_mode = TRUE;\n      break;\n    default:\n      \/* reserve other values for future use *\/\n      result = CURLE_UNKNOWN_OPTION;\n      break;\n    }\n    break;\n#endif   \/* CURL_DISABLE_PROXY *\/\n\n#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)\n  case CURLOPT_SOCKS5_GSSAPI_SERVICE:\n    \/*\n     * Set GSS-API service name\n     *\/\n    result = setstropt(&data->set.str[STRING_SOCKS5_GSSAPI_SERVICE],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_SOCKS5_GSSAPI_NEC:\n    \/*\n     * set flag for nec socks5 support\n     *\/\n    data->set.socks5_gssapi_nec = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n#endif\n\n  case CURLOPT_HEADERDATA:\n    \/*\n     * Custom pointer to pass the header write callback function\n     *\/\n    data->set.writeheader = (void *)va_arg(param, void *);\n    break;\n  case CURLOPT_ERRORBUFFER:\n    \/*\n     * Error buffer provided by the caller to get the human readable\n     * error string in.\n     *\/\n    data->set.errorbuffer = va_arg(param, char *);\n    break;\n  case CURLOPT_WRITEDATA:\n    \/*\n     * FILE pointer to write to. Or possibly\n     * used as argument to the write callback.\n     *\/\n    data->set.out = va_arg(param, void *);\n    break;\n  case CURLOPT_FTPPORT:\n    \/*\n     * Use FTP PORT, this also specifies which IP address to use\n     *\/\n    result = setstropt(&data->set.str[STRING_FTPPORT],\n                       va_arg(param, char *));\n    data->set.ftp_use_port = (NULL != data->set.str[STRING_FTPPORT]) ?\n                             TRUE:FALSE;\n    break;\n\n  case CURLOPT_FTP_USE_EPRT:\n    data->set.ftp_use_eprt = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_FTP_USE_EPSV:\n    data->set.ftp_use_epsv = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_FTP_USE_PRET:\n    data->set.ftp_use_pret = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_FTP_SSL_CCC:\n    data->set.ftp_ccc = (curl_ftpccc)va_arg(param, long);\n    break;\n\n  case CURLOPT_FTP_SKIP_PASV_IP:\n    \/*\n     * Enable or disable FTP_SKIP_PASV_IP, which will disable\/enable the\n     * bypass of the IP address in PASV responses.\n     *\/\n    data->set.ftp_skip_ip = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_READDATA:\n    \/*\n     * FILE pointer to read the file to be uploaded from. Or possibly\n     * used as argument to the read callback.\n     *\/\n    data->set.in = va_arg(param, void *);\n    break;\n  case CURLOPT_INFILESIZE:\n    \/*\n     * If known, this should inform curl about the file size of the\n     * to-be-uploaded file.\n     *\/\n    data->set.filesize = va_arg(param, long);\n    break;\n  case CURLOPT_INFILESIZE_LARGE:\n    \/*\n     * If known, this should inform curl about the file size of the\n     * to-be-uploaded file.\n     *\/\n    data->set.filesize = va_arg(param, curl_off_t);\n    break;\n  case CURLOPT_LOW_SPEED_LIMIT:\n    \/*\n     * The low speed limit that if transfers are below this for\n     * CURLOPT_LOW_SPEED_TIME, the transfer is aborted.\n     *\/\n    data->set.low_speed_limit=va_arg(param, long);\n    break;\n  case CURLOPT_MAX_SEND_SPEED_LARGE:\n    \/*\n     * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE\n     * bytes per second the transfer is throttled..\n     *\/\n    data->set.max_send_speed=va_arg(param, curl_off_t);\n    break;\n  case CURLOPT_MAX_RECV_SPEED_LARGE:\n    \/*\n     * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per\n     * second the transfer is throttled..\n     *\/\n    data->set.max_recv_speed=va_arg(param, curl_off_t);\n    break;\n  case CURLOPT_LOW_SPEED_TIME:\n    \/*\n     * The low speed time that if transfers are below the set\n     * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.\n     *\/\n    data->set.low_speed_time=va_arg(param, long);\n    break;\n  case CURLOPT_URL:\n    \/*\n     * The URL to fetch.\n     *\/\n    if(data->change.url_alloc) {\n      \/* the already set URL is allocated, free it first! *\/\n      Curl_safefree(data->change.url);\n      data->change.url_alloc = FALSE;\n    }\n    result = setstropt(&data->set.str[STRING_SET_URL],\n                       va_arg(param, char *));\n    data->change.url = data->set.str[STRING_SET_URL];\n    break;\n  case CURLOPT_PORT:\n    \/*\n     * The port number to use when getting the URL\n     *\/\n    data->set.use_port = va_arg(param, long);\n    break;\n  case CURLOPT_TIMEOUT:\n    \/*\n     * The maximum time you allow curl to use for a single transfer\n     * operation.\n     *\/\n    data->set.timeout = va_arg(param, long) * 1000L;\n    break;\n\n  case CURLOPT_TIMEOUT_MS:\n    data->set.timeout = va_arg(param, long);\n    break;\n\n  case CURLOPT_CONNECTTIMEOUT:\n    \/*\n     * The maximum time you allow curl to use to connect.\n     *\/\n    data->set.connecttimeout = va_arg(param, long) * 1000L;\n    break;\n\n  case CURLOPT_CONNECTTIMEOUT_MS:\n    data->set.connecttimeout = va_arg(param, long);\n    break;\n\n  case CURLOPT_ACCEPTTIMEOUT_MS:\n    \/*\n     * The maximum time you allow curl to wait for server connect\n     *\/\n    data->set.accepttimeout = va_arg(param, long);\n    break;\n\n  case CURLOPT_USERPWD:\n    \/*\n     * user:password to use in the operation\n     *\/\n    result = setstropt_userpwd(va_arg(param, char *),\n                               &data->set.str[STRING_USERNAME],\n                               &data->set.str[STRING_PASSWORD]);\n    break;\n\n  case CURLOPT_USERNAME:\n    \/*\n     * authentication user name to use in the operation\n     *\/\n    result = setstropt(&data->set.str[STRING_USERNAME],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_PASSWORD:\n    \/*\n     * authentication password to use in the operation\n     *\/\n    result = setstropt(&data->set.str[STRING_PASSWORD],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_LOGIN_OPTIONS:\n    \/*\n     * authentication options to use in the operation\n     *\/\n    result = setstropt(&data->set.str[STRING_OPTIONS],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_XOAUTH2_BEARER:\n    \/*\n     * XOAUTH2 bearer token to use in the operation\n     *\/\n    result = setstropt(&data->set.str[STRING_BEARER],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_POSTQUOTE:\n    \/*\n     * List of RAW FTP commands to use after a transfer\n     *\/\n    data->set.postquote = va_arg(param, struct curl_slist *);\n    break;\n  case CURLOPT_PREQUOTE:\n    \/*\n     * List of RAW FTP commands to use prior to RETR (Wesley Laxton)\n     *\/\n    data->set.prequote = va_arg(param, struct curl_slist *);\n    break;\n  case CURLOPT_QUOTE:\n    \/*\n     * List of RAW FTP commands to use before a transfer\n     *\/\n    data->set.quote = va_arg(param, struct curl_slist *);\n    break;\n  case CURLOPT_RESOLVE:\n    \/*\n     * List of NAME:[address] names to populate the DNS cache with\n     * Prefix the NAME with dash (-) to _remove_ the name from the cache.\n     *\n     * Names added with this API will remain in the cache until explicitly\n     * removed or the handle is cleaned up.\n     *\n     * This API can remove any name from the DNS cache, but only entries\n     * that aren't actually in use right now will be pruned immediately.\n     *\/\n    data->set.resolve = va_arg(param, struct curl_slist *);\n    data->change.resolve = data->set.resolve;\n    break;\n  case CURLOPT_PROGRESSFUNCTION:\n    \/*\n     * Progress callback function\n     *\/\n    data->set.fprogress = va_arg(param, curl_progress_callback);\n    if(data->set.fprogress)\n      data->progress.callback = TRUE; \/* no longer internal *\/\n    else\n      data->progress.callback = FALSE; \/* NULL enforces internal *\/\n    break;\n\n  case CURLOPT_XFERINFOFUNCTION:\n    \/*\n     * Transfer info callback function\n     *\/\n    data->set.fxferinfo = va_arg(param, curl_xferinfo_callback);\n    if(data->set.fxferinfo)\n      data->progress.callback = TRUE; \/* no longer internal *\/\n    else\n      data->progress.callback = FALSE; \/* NULL enforces internal *\/\n\n    break;\n\n  case CURLOPT_PROGRESSDATA:\n    \/*\n     * Custom client data to pass to the progress callback\n     *\/\n    data->set.progress_client = va_arg(param, void *);\n    break;\n\n#ifndef CURL_DISABLE_PROXY\n  case CURLOPT_PROXYUSERPWD:\n    \/*\n     * user:password needed to use the proxy\n     *\/\n    result = setstropt_userpwd(va_arg(param, char *),\n                               &data->set.str[STRING_PROXYUSERNAME],\n                               &data->set.str[STRING_PROXYPASSWORD]);\n    break;\n  case CURLOPT_PROXYUSERNAME:\n    \/*\n     * authentication user name to use in the operation\n     *\/\n    result = setstropt(&data->set.str[STRING_PROXYUSERNAME],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_PROXYPASSWORD:\n    \/*\n     * authentication password to use in the operation\n     *\/\n    result = setstropt(&data->set.str[STRING_PROXYPASSWORD],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_NOPROXY:\n    \/*\n     * proxy exception list\n     *\/\n    result = setstropt(&data->set.str[STRING_NOPROXY],\n                       va_arg(param, char *));\n    break;\n#endif\n\n  case CURLOPT_RANGE:\n    \/*\n     * What range of the file you want to transfer\n     *\/\n    result = setstropt(&data->set.str[STRING_SET_RANGE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_RESUME_FROM:\n    \/*\n     * Resume transfer at the give file position\n     *\/\n    data->set.set_resume_from = va_arg(param, long);\n    break;\n  case CURLOPT_RESUME_FROM_LARGE:\n    \/*\n     * Resume transfer at the give file position\n     *\/\n    data->set.set_resume_from = va_arg(param, curl_off_t);\n    break;\n  case CURLOPT_DEBUGFUNCTION:\n    \/*\n     * stderr write callback.\n     *\/\n    data->set.fdebug = va_arg(param, curl_debug_callback);\n    \/*\n     * if the callback provided is NULL, it'll use the default callback\n     *\/\n    break;\n  case CURLOPT_DEBUGDATA:\n    \/*\n     * Set to a void * that should receive all error writes. This\n     * defaults to CURLOPT_STDERR for normal operations.\n     *\/\n    data->set.debugdata = va_arg(param, void *);\n    break;\n  case CURLOPT_STDERR:\n    \/*\n     * Set to a FILE * that should receive all error writes. This\n     * defaults to stderr for normal operations.\n     *\/\n    data->set.err = va_arg(param, FILE *);\n    if(!data->set.err)\n      data->set.err = stderr;\n    break;\n  case CURLOPT_HEADERFUNCTION:\n    \/*\n     * Set header write callback\n     *\/\n    data->set.fwrite_header = va_arg(param, curl_write_callback);\n    break;\n  case CURLOPT_WRITEFUNCTION:\n    \/*\n     * Set data write callback\n     *\/\n    data->set.fwrite_func = va_arg(param, curl_write_callback);\n    if(!data->set.fwrite_func) {\n      data->set.is_fwrite_set = 0;\n      \/* When set to NULL, reset to our internal default function *\/\n      data->set.fwrite_func = (curl_write_callback)fwrite;\n    }\n    else\n      data->set.is_fwrite_set = 1;\n    break;\n  case CURLOPT_READFUNCTION:\n    \/*\n     * Read data callback\n     *\/\n    data->set.fread_func = va_arg(param, curl_read_callback);\n    if(!data->set.fread_func) {\n      data->set.is_fread_set = 0;\n      \/* When set to NULL, reset to our internal default function *\/\n      data->set.fread_func = (curl_read_callback)fread;\n    }\n    else\n      data->set.is_fread_set = 1;\n    break;\n  case CURLOPT_SEEKFUNCTION:\n    \/*\n     * Seek callback. Might be NULL.\n     *\/\n    data->set.seek_func = va_arg(param, curl_seek_callback);\n    break;\n  case CURLOPT_SEEKDATA:\n    \/*\n     * Seek control callback. Might be NULL.\n     *\/\n    data->set.seek_client = va_arg(param, void *);\n    break;\n  case CURLOPT_CONV_FROM_NETWORK_FUNCTION:\n    \/*\n     * \"Convert from network encoding\" callback\n     *\/\n    data->set.convfromnetwork = va_arg(param, curl_conv_callback);\n    break;\n  case CURLOPT_CONV_TO_NETWORK_FUNCTION:\n    \/*\n     * \"Convert to network encoding\" callback\n     *\/\n    data->set.convtonetwork = va_arg(param, curl_conv_callback);\n    break;\n  case CURLOPT_CONV_FROM_UTF8_FUNCTION:\n    \/*\n     * \"Convert from UTF-8 encoding\" callback\n     *\/\n    data->set.convfromutf8 = va_arg(param, curl_conv_callback);\n    break;\n  case CURLOPT_IOCTLFUNCTION:\n    \/*\n     * I\/O control callback. Might be NULL.\n     *\/\n    data->set.ioctl_func = va_arg(param, curl_ioctl_callback);\n    break;\n  case CURLOPT_IOCTLDATA:\n    \/*\n     * I\/O control data pointer. Might be NULL.\n     *\/\n    data->set.ioctl_client = va_arg(param, void *);\n    break;\n  case CURLOPT_SSLCERT:\n    \/*\n     * String that holds file name of the SSL certificate to use\n     *\/\n    result = setstropt(&data->set.str[STRING_CERT],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_SSLCERTTYPE:\n    \/*\n     * String that holds file type of the SSL certificate to use\n     *\/\n    result = setstropt(&data->set.str[STRING_CERT_TYPE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_SSLKEY:\n    \/*\n     * String that holds file name of the SSL key to use\n     *\/\n    result = setstropt(&data->set.str[STRING_KEY],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_SSLKEYTYPE:\n    \/*\n     * String that holds file type of the SSL key to use\n     *\/\n    result = setstropt(&data->set.str[STRING_KEY_TYPE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_KEYPASSWD:\n    \/*\n     * String that holds the SSL or SSH private key password.\n     *\/\n    result = setstropt(&data->set.str[STRING_KEY_PASSWD],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_SSLENGINE:\n    \/*\n     * String that holds the SSL crypto engine.\n     *\/\n    argptr = va_arg(param, char *);\n    if(argptr && argptr[0])\n      result = Curl_ssl_set_engine(data, argptr);\n    break;\n\n  case CURLOPT_SSLENGINE_DEFAULT:\n    \/*\n     * flag to set engine as default.\n     *\/\n    result = Curl_ssl_set_engine_default(data);\n    break;\n  case CURLOPT_CRLF:\n    \/*\n     * Kludgy option to enable CRLF conversions. Subject for removal.\n     *\/\n    data->set.crlf = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_INTERFACE:\n    \/*\n     * Set what interface or address\/hostname to bind the socket to when\n     * performing an operation and thus what from-IP your connection will use.\n     *\/\n    result = setstropt(&data->set.str[STRING_DEVICE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_LOCALPORT:\n    \/*\n     * Set what local port to bind the socket to when performing an operation.\n     *\/\n    data->set.localport = curlx_sltous(va_arg(param, long));\n    break;\n  case CURLOPT_LOCALPORTRANGE:\n    \/*\n     * Set number of local ports to try, starting with CURLOPT_LOCALPORT.\n     *\/\n    data->set.localportrange = curlx_sltosi(va_arg(param, long));\n    break;\n  case CURLOPT_KRBLEVEL:\n    \/*\n     * A string that defines the kerberos security level.\n     *\/\n    result = setstropt(&data->set.str[STRING_KRB_LEVEL],\n                       va_arg(param, char *));\n    data->set.krb = (NULL != data->set.str[STRING_KRB_LEVEL])?TRUE:FALSE;\n    break;\n  case CURLOPT_GSSAPI_DELEGATION:\n    \/*\n     * GSS-API credential delegation\n     *\/\n    data->set.gssapi_delegation = va_arg(param, long);\n    break;\n  case CURLOPT_SSL_VERIFYPEER:\n    \/*\n     * Enable peer SSL verifying.\n     *\/\n    data->set.ssl.verifypeer = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_SSL_VERIFYHOST:\n    \/*\n     * Enable verification of the host name in the peer certificate\n     *\/\n    arg = va_arg(param, long);\n\n    \/* Obviously people are not reading documentation and too many thought\n       this argument took a boolean when it wasn't and misused it. We thus ban\n       1 as a sensible input and we warn about its use. Then we only have the\n       2 action internally stored as TRUE. *\/\n\n    if(1 == arg) {\n      failf(data, \"CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!\");\n      return CURLE_BAD_FUNCTION_ARGUMENT;\n    }\n\n    data->set.ssl.verifyhost = (0 != arg)?TRUE:FALSE;\n    break;\n  case CURLOPT_SSL_CTX_FUNCTION:\n#ifdef have_curlssl_ssl_ctx\n    \/*\n     * Set a SSL_CTX callback\n     *\/\n    data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);\n#else\n    result = CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURLOPT_SSL_CTX_DATA:\n#ifdef have_curlssl_ssl_ctx\n    \/*\n     * Set a SSL_CTX callback parameter pointer\n     *\/\n    data->set.ssl.fsslctxp = va_arg(param, void *);\n#else\n    result = CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURLOPT_CERTINFO:\n#ifdef have_curlssl_certinfo\n    data->set.ssl.certinfo = (0 != va_arg(param, long))?TRUE:FALSE;\n#else\n    result = CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURLOPT_PINNEDPUBLICKEY:\n    \/*\n     * Set pinned public key for SSL connection.\n     * Specify file name of the public key in DER format.\n     *\/\n    result = setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_CAINFO:\n    \/*\n     * Set CA info for SSL connection. Specify file name of the CA certificate\n     *\/\n    result = setstropt(&data->set.str[STRING_SSL_CAFILE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_CAPATH:\n#ifdef have_curlssl_ca_path \/* not supported by all backends *\/\n    \/*\n     * Set CA path info for SSL connection. Specify directory name of the CA\n     * certificates which have been prepared using openssl c_rehash utility.\n     *\/\n    \/* This does not work on windows. *\/\n    result = setstropt(&data->set.str[STRING_SSL_CAPATH],\n                       va_arg(param, char *));\n#else\n    result = CURLE_NOT_BUILT_IN;\n#endif\n    break;\n  case CURLOPT_CRLFILE:\n    \/*\n     * Set CRL file info for SSL connection. Specify file name of the CRL\n     * to check certificates revocation\n     *\/\n    result = setstropt(&data->set.str[STRING_SSL_CRLFILE],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_ISSUERCERT:\n    \/*\n     * Set Issuer certificate file\n     * to check certificates issuer\n     *\/\n    result = setstropt(&data->set.str[STRING_SSL_ISSUERCERT],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_TELNETOPTIONS:\n    \/*\n     * Set a linked list of telnet options\n     *\/\n    data->set.telnet_options = va_arg(param, struct curl_slist *);\n    break;\n\n  case CURLOPT_BUFFERSIZE:\n    \/*\n     * The application kindly asks for a differently sized receive buffer.\n     * If it seems reasonable, we'll use it.\n     *\/\n    data->set.buffer_size = va_arg(param, long);\n\n    if((data->set.buffer_size> (BUFSIZE -1 )) ||\n       (data->set.buffer_size < 1))\n      data->set.buffer_size = 0; \/* huge internal default *\/\n\n    break;\n\n  case CURLOPT_NOSIGNAL:\n    \/*\n     * The application asks not to set any signal() or alarm() handlers,\n     * even when using a timeout.\n     *\/\n    data->set.no_signal = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_SHARE:\n  {\n    struct Curl_share *set;\n    set = va_arg(param, struct Curl_share *);\n\n    \/* disconnect from old share, if any *\/\n    if(data->share) {\n      Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);\n\n      if(data->dns.hostcachetype == HCACHE_SHARED) {\n        data->dns.hostcache = NULL;\n        data->dns.hostcachetype = HCACHE_NONE;\n      }\n\n#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)\n      if(data->share->cookies == data->cookies)\n        data->cookies = NULL;\n#endif\n\n      if(data->share->sslsession == data->state.session)\n        data->state.session = NULL;\n\n      data->share->dirty--;\n\n      Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);\n      data->share = NULL;\n    }\n\n    \/* use new share if it set *\/\n    data->share = set;\n    if(data->share) {\n\n      Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);\n\n      data->share->dirty++;\n\n      if(data->share->hostcache) {\n        \/* use shared host cache *\/\n        data->dns.hostcache = data->share->hostcache;\n        data->dns.hostcachetype = HCACHE_SHARED;\n      }\n#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)\n      if(data->share->cookies) {\n        \/* use shared cookie list, first free own one if any *\/\n        if(data->cookies)\n          Curl_cookie_cleanup(data->cookies);\n        \/* enable cookies since we now use a share that uses cookies! *\/\n        data->cookies = data->share->cookies;\n      }\n#endif   \/* CURL_DISABLE_HTTP *\/\n      if(data->share->sslsession) {\n        data->set.ssl.max_ssl_sessions = data->share->max_ssl_sessions;\n        data->state.session = data->share->sslsession;\n      }\n      Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);\n\n    }\n    \/* check for host cache not needed,\n     * it will be done by curl_easy_perform *\/\n  }\n  break;\n\n  case CURLOPT_PRIVATE:\n    \/*\n     * Set private data pointer.\n     *\/\n    data->set.private_data = va_arg(param, void *);\n    break;\n\n  case CURLOPT_MAXFILESIZE:\n    \/*\n     * Set the maximum size of a file to download.\n     *\/\n    data->set.max_filesize = va_arg(param, long);\n    break;\n\n#ifdef USE_SSL\n  case CURLOPT_USE_SSL:\n    \/*\n     * Make transfers attempt to use SSL\/TLS.\n     *\/\n    data->set.use_ssl = (curl_usessl)va_arg(param, long);\n    break;\n\n  case CURLOPT_SSL_OPTIONS:\n    arg = va_arg(param, long);\n    data->set.ssl_enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;\n    break;\n\n#endif\n  case CURLOPT_FTPSSLAUTH:\n    \/*\n     * Set a specific auth for FTP-SSL transfers.\n     *\/\n    data->set.ftpsslauth = (curl_ftpauth)va_arg(param, long);\n    break;\n\n  case CURLOPT_IPRESOLVE:\n    data->set.ipver = va_arg(param, long);\n    break;\n\n  case CURLOPT_MAXFILESIZE_LARGE:\n    \/*\n     * Set the maximum size of a file to download.\n     *\/\n    data->set.max_filesize = va_arg(param, curl_off_t);\n    break;\n\n  case CURLOPT_TCP_NODELAY:\n    \/*\n     * Enable or disable TCP_NODELAY, which will disable\/enable the Nagle\n     * algorithm\n     *\/\n    data->set.tcp_nodelay = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_FTP_ACCOUNT:\n    result = setstropt(&data->set.str[STRING_FTP_ACCOUNT],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_IGNORE_CONTENT_LENGTH:\n    data->set.ignorecl = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_CONNECT_ONLY:\n    \/*\n     * No data transfer, set up connection and let application use the socket\n     *\/\n    data->set.connect_only = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_FTP_ALTERNATIVE_TO_USER:\n    result = setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_SOCKOPTFUNCTION:\n    \/*\n     * socket callback function: called after socket() but before connect()\n     *\/\n    data->set.fsockopt = va_arg(param, curl_sockopt_callback);\n    break;\n\n  case CURLOPT_SOCKOPTDATA:\n    \/*\n     * socket callback data pointer. Might be NULL.\n     *\/\n    data->set.sockopt_client = va_arg(param, void *);\n    break;\n\n  case CURLOPT_OPENSOCKETFUNCTION:\n    \/*\n     * open\/create socket callback function: called instead of socket(),\n     * before connect()\n     *\/\n    data->set.fopensocket = va_arg(param, curl_opensocket_callback);\n    break;\n\n  case CURLOPT_OPENSOCKETDATA:\n    \/*\n     * socket callback data pointer. Might be NULL.\n     *\/\n    data->set.opensocket_client = va_arg(param, void *);\n    break;\n\n  case CURLOPT_CLOSESOCKETFUNCTION:\n    \/*\n     * close socket callback function: called instead of close()\n     * when shutting down a connection\n     *\/\n    data->set.fclosesocket = va_arg(param, curl_closesocket_callback);\n    break;\n\n  case CURLOPT_CLOSESOCKETDATA:\n    \/*\n     * socket callback data pointer. Might be NULL.\n     *\/\n    data->set.closesocket_client = va_arg(param, void *);\n    break;\n\n  case CURLOPT_SSL_SESSIONID_CACHE:\n    data->set.ssl.sessionid = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n#ifdef USE_LIBSSH2\n    \/* we only include SSH options if explicitly built to support SSH *\/\n  case CURLOPT_SSH_AUTH_TYPES:\n    data->set.ssh_auth_types = va_arg(param, long);\n    break;\n\n  case CURLOPT_SSH_PUBLIC_KEYFILE:\n    \/*\n     * Use this file instead of the $HOME\/.ssh\/id_dsa.pub file\n     *\/\n    result = setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_SSH_PRIVATE_KEYFILE:\n    \/*\n     * Use this file instead of the $HOME\/.ssh\/id_dsa file\n     *\/\n    result = setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY],\n                       va_arg(param, char *));\n    break;\n  case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:\n    \/*\n     * Option to allow for the MD5 of the host public key to be checked\n     * for validation purposes.\n     *\/\n    result = setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5],\n                       va_arg(param, char *));\n    break;\n#ifdef HAVE_LIBSSH2_KNOWNHOST_API\n  case CURLOPT_SSH_KNOWNHOSTS:\n    \/*\n     * Store the file name to read known hosts from.\n     *\/\n    result = setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_SSH_KEYFUNCTION:\n    \/* setting to NULL is fine since the ssh.c functions themselves will\n       then rever to use the internal default *\/\n    data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);\n    break;\n\n  case CURLOPT_SSH_KEYDATA:\n    \/*\n     * Custom client data to pass to the SSH keyfunc callback\n     *\/\n    data->set.ssh_keyfunc_userp = va_arg(param, void *);\n    break;\n#endif \/* HAVE_LIBSSH2_KNOWNHOST_API *\/\n\n#endif \/* USE_LIBSSH2 *\/\n\n  case CURLOPT_HTTP_TRANSFER_DECODING:\n    \/*\n     * disable libcurl transfer encoding is used\n     *\/\n    data->set.http_te_skip = (0 == va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_HTTP_CONTENT_DECODING:\n    \/*\n     * raw data passed to the application when content encoding is used\n     *\/\n    data->set.http_ce_skip = (0 == va_arg(param, long))?TRUE:FALSE;\n    break;\n\n  case CURLOPT_NEW_FILE_PERMS:\n    \/*\n     * Uses these permissions instead of 0644\n     *\/\n    data->set.new_file_perms = va_arg(param, long);\n    break;\n\n  case CURLOPT_NEW_DIRECTORY_PERMS:\n    \/*\n     * Uses these permissions instead of 0755\n     *\/\n    data->set.new_directory_perms = va_arg(param, long);\n    break;\n\n  case CURLOPT_ADDRESS_SCOPE:\n    \/*\n     * We always get longs when passed plain numericals, but for this value we\n     * know that an unsigned int will always hold the value so we blindly\n     * typecast to this type\n     *\/\n    data->set.scope_id = curlx_sltoui(va_arg(param, long));\n    break;\n\n  case CURLOPT_PROTOCOLS:\n    \/* set the bitmask for the protocols that are allowed to be used for the\n       transfer, which thus helps the app which takes URLs from users or other\n       external inputs and want to restrict what protocol(s) to deal\n       with. Defaults to CURLPROTO_ALL. *\/\n    data->set.allowed_protocols = va_arg(param, long);\n    break;\n\n  case CURLOPT_REDIR_PROTOCOLS:\n    \/* set the bitmask for the protocols that libcurl is allowed to follow to,\n       as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs\n       to be set in both bitmasks to be allowed to get redirected to. Defaults\n       to all protocols except FILE and SCP. *\/\n    data->set.redir_protocols = va_arg(param, long);\n    break;\n\n  case CURLOPT_MAIL_FROM:\n    \/* Set the SMTP mail originator *\/\n    result = setstropt(&data->set.str[STRING_MAIL_FROM],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_MAIL_AUTH:\n    \/* Set the SMTP auth originator *\/\n    result = setstropt(&data->set.str[STRING_MAIL_AUTH],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_MAIL_RCPT:\n    \/* Set the list of mail recipients *\/\n    data->set.mail_rcpt = va_arg(param, struct curl_slist *);\n    break;\n\n  case CURLOPT_SASL_IR:\n    \/* Enable\/disable SASL initial response *\/\n    data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE;\n    break;\n\n  case CURLOPT_RTSP_REQUEST:\n    {\n      \/*\n       * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)\n       * Would this be better if the RTSPREQ_* were just moved into here?\n       *\/\n      long curl_rtspreq = va_arg(param, long);\n      Curl_RtspReq rtspreq = RTSPREQ_NONE;\n      switch(curl_rtspreq) {\n        case CURL_RTSPREQ_OPTIONS:\n          rtspreq = RTSPREQ_OPTIONS;\n          break;\n\n        case CURL_RTSPREQ_DESCRIBE:\n          rtspreq = RTSPREQ_DESCRIBE;\n          break;\n\n        case CURL_RTSPREQ_ANNOUNCE:\n          rtspreq = RTSPREQ_ANNOUNCE;\n          break;\n\n        case CURL_RTSPREQ_SETUP:\n          rtspreq = RTSPREQ_SETUP;\n          break;\n\n        case CURL_RTSPREQ_PLAY:\n          rtspreq = RTSPREQ_PLAY;\n          break;\n\n        case CURL_RTSPREQ_PAUSE:\n          rtspreq = RTSPREQ_PAUSE;\n          break;\n\n        case CURL_RTSPREQ_TEARDOWN:\n          rtspreq = RTSPREQ_TEARDOWN;\n          break;\n\n        case CURL_RTSPREQ_GET_PARAMETER:\n          rtspreq = RTSPREQ_GET_PARAMETER;\n          break;\n\n        case CURL_RTSPREQ_SET_PARAMETER:\n          rtspreq = RTSPREQ_SET_PARAMETER;\n          break;\n\n        case CURL_RTSPREQ_RECORD:\n          rtspreq = RTSPREQ_RECORD;\n          break;\n\n        case CURL_RTSPREQ_RECEIVE:\n          rtspreq = RTSPREQ_RECEIVE;\n          break;\n        default:\n          rtspreq = RTSPREQ_NONE;\n      }\n\n      data->set.rtspreq = rtspreq;\n    break;\n    }\n\n\n  case CURLOPT_RTSP_SESSION_ID:\n    \/*\n     * Set the RTSP Session ID manually. Useful if the application is\n     * resuming a previously established RTSP session\n     *\/\n    result = setstropt(&data->set.str[STRING_RTSP_SESSION_ID],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_RTSP_STREAM_URI:\n    \/*\n     * Set the Stream URI for the RTSP request. Unless the request is\n     * for generic server options, the application will need to set this.\n     *\/\n    result = setstropt(&data->set.str[STRING_RTSP_STREAM_URI],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_RTSP_TRANSPORT:\n    \/*\n     * The content of the Transport: header for the RTSP request\n     *\/\n    result = setstropt(&data->set.str[STRING_RTSP_TRANSPORT],\n                       va_arg(param, char *));\n    break;\n\n  case CURLOPT_RTSP_CLIENT_CSEQ:\n    \/*\n     * Set the CSEQ number to issue for the next RTSP request. Useful if the\n     * application is resuming a previously broken connection. The CSEQ\n     * will increment from this new number henceforth.\n     *\/\n    data->state.rtsp_next_client_CSeq = va_arg(param, long);\n    break;\n\n  case CURLOPT_RTSP_SERVER_CSEQ:\n    \/* Same as the above, but for server-initiated requests *\/\n    data->state.rtsp_next_client_CSeq = va_arg(param, long);\n    break;\n\n  case CURLOPT_INTERLEAVEDATA:\n    data->set.rtp_out = va_arg(param, void *);\n    break;\n  case CURLOPT_INTERLEAVEFUNCTION:\n    \/* Set the user defined RTP write function *\/\n    data->set.fwrite_rtp = va_arg(param, curl_write_callback);\n    break;\n\n  case CURLOPT_WILDCARDMATCH:\n    data->set.wildcardmatch = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_CHUNK_BGN_FUNCTION:\n    data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);\n    break;\n  case CURLOPT_CHUNK_END_FUNCTION:\n    data->set.chunk_end = va_arg(param, curl_chunk_end_callback);\n    break;\n  case CURLOPT_FNMATCH_FUNCTION:\n    data->set.fnmatch = va_arg(param, curl_fnmatch_callback);\n    break;\n  case CURLOPT_CHUNK_DATA:\n    data->wildcard.customptr = va_arg(param, void *);\n    break;\n  case CURLOPT_FNMATCH_DATA:\n    data->set.fnmatch_data = va_arg(param, void *);\n    break;\n#ifdef USE_TLS_SRP\n  case CURLOPT_TLSAUTH_USERNAME:\n    result = setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],\n                       va_arg(param, char *));\n    if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)\n      data->set.ssl.authtype = CURL_TLSAUTH_SRP; \/* default to SRP *\/\n    break;\n  case CURLOPT_TLSAUTH_PASSWORD:\n    result = setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],\n                       va_arg(param, char *));\n    if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)\n      data->set.ssl.authtype = CURL_TLSAUTH_SRP; \/* default to SRP *\/\n    break;\n  case CURLOPT_TLSAUTH_TYPE:\n    if(strnequal((char *)va_arg(param, char *), \"SRP\", strlen(\"SRP\")))\n      data->set.ssl.authtype = CURL_TLSAUTH_SRP;\n    else\n      data->set.ssl.authtype = CURL_TLSAUTH_NONE;\n    break;\n#endif\n  case CURLOPT_DNS_SERVERS:\n    result = Curl_set_dns_servers(data, va_arg(param, char *));\n    break;\n  case CURLOPT_DNS_INTERFACE:\n    result = Curl_set_dns_interface(data, va_arg(param, char *));\n    break;\n  case CURLOPT_DNS_LOCAL_IP4:\n    result = Curl_set_dns_local_ip4(data, va_arg(param, char *));\n    break;\n  case CURLOPT_DNS_LOCAL_IP6:\n    result = Curl_set_dns_local_ip6(data, va_arg(param, char *));\n    break;\n\n  case CURLOPT_TCP_KEEPALIVE:\n    data->set.tcp_keepalive = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_TCP_KEEPIDLE:\n    data->set.tcp_keepidle = va_arg(param, long);\n    break;\n  case CURLOPT_TCP_KEEPINTVL:\n    data->set.tcp_keepintvl = va_arg(param, long);\n    break;\n  case CURLOPT_SSL_ENABLE_NPN:\n    data->set.ssl_enable_npn = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n  case CURLOPT_SSL_ENABLE_ALPN:\n    data->set.ssl_enable_alpn = (0 != va_arg(param, long))?TRUE:FALSE;\n    break;\n\n#ifdef USE_UNIX_SOCKETS\n  case CURLOPT_UNIX_SOCKET_PATH:\n    result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],\n                       va_arg(param, char *));\n    break;\n#endif\n\n  default:\n    \/* unknown tag and its companion, just ignore: *\/\n    result = CURLE_UNKNOWN_OPTION;\n    break;\n  }\n\n  return result;\n}","target":0,"code_token_length":14401,"total_token_length":14637,"max_tokens_setting":28000}
+{"idx":326119,"func":"regmatch(\n    char_u\t*scan,\t\t    \/\/ Current node.\n    proftime_T\t*tm UNUSED,\t    \/\/ timeout limit or NULL\n    int\t\t*timed_out UNUSED)  \/\/ flag set on timeout or NULL\n{\n  char_u\t*next;\t\t\/\/ Next node.\n  int\t\top;\n  int\t\tc;\n  regitem_T\t*rp;\n  int\t\tno;\n  int\t\tstatus;\t\t\/\/ one of the RA_ values:\n#ifdef FEAT_RELTIME\n  int\t\ttm_count = 0;\n#endif\n\n  \/\/ Make \"regstack\" and \"backpos\" empty.  They are allocated and freed in\n  \/\/ bt_regexec_both() to reduce malloc()\/free() calls.\n  regstack.ga_len = 0;\n  backpos.ga_len = 0;\n\n  \/\/ Repeat until \"regstack\" is empty.\n  for (;;)\n  {\n    \/\/ Some patterns may take a long time to match, e.g., \"\\([a-z]\\+\\)\\+Q\".\n    \/\/ Allow interrupting them with CTRL-C.\n    fast_breakcheck();\n\n#ifdef DEBUG\n    if (scan != NULL && regnarrate)\n    {\n\tmch_errmsg((char *)regprop(scan));\n\tmch_errmsg(\"(\\n\");\n    }\n#endif\n\n    \/\/ Repeat for items that can be matched sequentially, without using the\n    \/\/ regstack.\n    for (;;)\n    {\n\tif (got_int || scan == NULL)\n\t{\n\t    status = RA_FAIL;\n\t    break;\n\t}\n#ifdef FEAT_RELTIME\n\t\/\/ Check for timeout once in a 100 times to avoid overhead.\n\tif (tm != NULL && ++tm_count == 100)\n\t{\n\t    tm_count = 0;\n\t    if (profile_passed_limit(tm))\n\t    {\n\t\tif (timed_out != NULL)\n\t\t    *timed_out = TRUE;\n\t\tstatus = RA_FAIL;\n\t\tbreak;\n\t    }\n\t}\n#endif\n\tstatus = RA_CONT;\n\n#ifdef DEBUG\n\tif (regnarrate)\n\t{\n\t    mch_errmsg((char *)regprop(scan));\n\t    mch_errmsg(\"...\\n\");\n# ifdef FEAT_SYN_HL\n\t    if (re_extmatch_in != NULL)\n\t    {\n\t\tint i;\n\n\t\tmch_errmsg(_(\"External submatches:\\n\"));\n\t\tfor (i = 0; i < NSUBEXP; i++)\n\t\t{\n\t\t    mch_errmsg(\"    \\\"\");\n\t\t    if (re_extmatch_in->matches[i] != NULL)\n\t\t\tmch_errmsg((char *)re_extmatch_in->matches[i]);\n\t\t    mch_errmsg(\"\\\"\\n\");\n\t\t}\n\t    }\n# endif\n\t}\n#endif\n\tnext = regnext(scan);\n\n\top = OP(scan);\n\t\/\/ Check for character class with NL added.\n\tif (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI\n\t\t\t     && *rex.input == NUL && rex.lnum <= rex.reg_maxline)\n\t{\n\t    reg_nextline();\n\t}\n\telse if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\\n')\n\t{\n\t    ADVANCE_REGINPUT();\n\t}\n\telse\n\t{\n\t  if (WITH_NL(op))\n\t      op -= ADD_NL;\n\t  if (has_mbyte)\n\t      c = (*mb_ptr2char)(rex.input);\n\t  else\n\t      c = *rex.input;\n\t  switch (op)\n\t  {\n\t  case BOL:\n\t    if (rex.input != rex.line)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case EOL:\n\t    if (c != NUL)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_BOF:\n\t    \/\/ We're not at the beginning of the file when below the first\n\t    \/\/ line where we started, not at the start of the line or we\n\t    \/\/ didn't start at the first line of the buffer.\n\t    if (rex.lnum != 0 || rex.input != rex.line\n\t\t\t\t       || (REG_MULTI && rex.reg_firstlnum > 1))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_EOF:\n\t    if (rex.lnum != rex.reg_maxline || c != NUL)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case CURSOR:\n\t    \/\/ Check if the buffer is in a window and compare the\n\t    \/\/ rex.reg_win->w_cursor position to the match position.\n\t    if (rex.reg_win == NULL\n\t\t    || (rex.lnum + rex.reg_firstlnum\n\t\t\t\t\t\t != rex.reg_win->w_cursor.lnum)\n\t\t    || ((colnr_T)(rex.input - rex.line)\n\t\t\t\t\t\t != rex.reg_win->w_cursor.col))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_MARK:\n\t    \/\/ Compare the mark position to the match position.\n\t    {\n\t\tint\tmark = OPERAND(scan)[0];\n\t\tint\tcmp = OPERAND(scan)[1];\n\t\tpos_T\t*pos;\n\t\tsize_t\tcol = REG_MULTI ? rex.input - rex.line : 0;\n\n\t\tpos = getmark_buf(rex.reg_buf, mark, FALSE);\n\n\t\t\/\/ Line may have been freed, get it again.\n\t\tif (REG_MULTI)\n\t\t{\n\t\t    rex.line = reg_getline(rex.lnum);\n\t\t    rex.input = rex.line + col;\n\t\t}\n\n\t\tif (pos == NULL\t\t     \/\/ mark doesn't exist\n\t\t\t|| pos->lnum <= 0)   \/\/ mark isn't set in reg_buf\n\t\t{\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t\telse\n\t\t{\n\t\t    colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum\n\t\t\t\t\t\t\t  && pos->col == MAXCOL\n\t\t\t\t      ? (colnr_T)STRLEN(reg_getline(\n\t\t\t\t\t\tpos->lnum - rex.reg_firstlnum))\n\t\t\t\t      : pos->col;\n\n\t\t    if ((pos->lnum == rex.lnum + rex.reg_firstlnum\n\t\t\t\t? (pos_col == (colnr_T)(rex.input - rex.line)\n\t\t\t\t    ? (cmp == '<' || cmp == '>')\n\t\t\t\t    : (pos_col < (colnr_T)(rex.input - rex.line)\n\t\t\t\t\t? cmp != '>'\n\t\t\t\t\t: cmp != '<'))\n\t\t\t\t: (pos->lnum < rex.lnum + rex.reg_firstlnum\n\t\t\t\t    ? cmp != '>'\n\t\t\t\t    : cmp != '<')))\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t    }\n\t    break;\n\n\t  case RE_VISUAL:\n\t    if (!reg_match_visual())\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_LNUM:\n\t    if (!REG_MULTI || !re_num_cmp((long_u)(rex.lnum + rex.reg_firstlnum),\n\t\t\t\t\t\t\t\t\tscan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_COL:\n\t    if (!re_num_cmp((long_u)(rex.input - rex.line) + 1, scan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_VCOL:\n\t    if (!re_num_cmp((long_u)win_linetabsize(\n\t\t\t    rex.reg_win == NULL ? curwin : rex.reg_win,\n\t\t\t    rex.line, (colnr_T)(rex.input - rex.line)) + 1, scan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case BOW:\t\/\/ \\<word; rex.input points to w\n\t    if (c == NUL)\t\/\/ Can't match at end of line\n\t\tstatus = RA_NOMATCH;\n\t    else if (has_mbyte)\n\t    {\n\t\tint this_class;\n\n\t\t\/\/ Get class of current and previous char (if it exists).\n\t\tthis_class = mb_get_class_buf(rex.input, rex.reg_buf);\n\t\tif (this_class <= 1)\n\t\t    status = RA_NOMATCH;  \/\/ not on a word at all\n\t\telse if (reg_prev_class() == this_class)\n\t\t    status = RA_NOMATCH;  \/\/ previous char is in same word\n\t    }\n\t    else\n\t    {\n\t\tif (!vim_iswordc_buf(c, rex.reg_buf) || (rex.input > rex.line\n\t\t\t\t&& vim_iswordc_buf(rex.input[-1], rex.reg_buf)))\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    break;\n\n\t  case EOW:\t\/\/ word\\>; rex.input points after d\n\t    if (rex.input == rex.line)    \/\/ Can't match at start of line\n\t\tstatus = RA_NOMATCH;\n\t    else if (has_mbyte)\n\t    {\n\t\tint this_class, prev_class;\n\n\t\t\/\/ Get class of current and previous char (if it exists).\n\t\tthis_class = mb_get_class_buf(rex.input, rex.reg_buf);\n\t\tprev_class = reg_prev_class();\n\t\tif (this_class == prev_class\n\t\t\t|| prev_class == 0 || prev_class == 1)\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    else\n\t    {\n\t\tif (!vim_iswordc_buf(rex.input[-1], rex.reg_buf)\n\t\t\t|| (rex.input[0] != NUL\n\t\t\t\t\t   && vim_iswordc_buf(c, rex.reg_buf)))\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    break; \/\/ Matched with EOW\n\n\t  case ANY:\n\t    \/\/ ANY does not match new lines.\n\t    if (c == NUL)\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case IDENT:\n\t    if (!vim_isIDc(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SIDENT:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isIDc(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case KWORD:\n\t    if (!vim_iswordp_buf(rex.input, rex.reg_buf))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SKWORD:\n\t    if (VIM_ISDIGIT(*rex.input)\n\t\t\t\t    || !vim_iswordp_buf(rex.input, rex.reg_buf))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case FNAME:\n\t    if (!vim_isfilec(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SFNAME:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isfilec(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case PRINT:\n\t    if (!vim_isprintc(PTR2CHAR(rex.input)))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SPRINT:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input)))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case WHITE:\n\t    if (!VIM_ISWHITE(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NWHITE:\n\t    if (c == NUL || VIM_ISWHITE(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case DIGIT:\n\t    if (!ri_digit(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NDIGIT:\n\t    if (c == NUL || ri_digit(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case HEX:\n\t    if (!ri_hex(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NHEX:\n\t    if (c == NUL || ri_hex(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case OCTAL:\n\t    if (!ri_octal(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NOCTAL:\n\t    if (c == NUL || ri_octal(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case WORD:\n\t    if (!ri_word(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NWORD:\n\t    if (c == NUL || ri_word(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case HEAD:\n\t    if (!ri_head(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NHEAD:\n\t    if (c == NUL || ri_head(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case ALPHA:\n\t    if (!ri_alpha(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NALPHA:\n\t    if (c == NUL || ri_alpha(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case LOWER:\n\t    if (!ri_lower(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NLOWER:\n\t    if (c == NUL || ri_lower(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case UPPER:\n\t    if (!ri_upper(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NUPPER:\n\t    if (c == NUL || ri_upper(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case EXACTLY:\n\t    {\n\t\tint\tlen;\n\t\tchar_u\t*opnd;\n\n\t\topnd = OPERAND(scan);\n\t\t\/\/ Inline the first byte, for speed.\n\t\tif (*opnd != *rex.input\n\t\t\t&& (!rex.reg_ic\n\t\t\t    || (!enc_utf8\n\t\t\t      && MB_TOLOWER(*opnd) != MB_TOLOWER(*rex.input))))\n\t\t    status = RA_NOMATCH;\n\t\telse if (*opnd == NUL)\n\t\t{\n\t\t    \/\/ match empty string always works; happens when \"~\" is\n\t\t    \/\/ empty.\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic))\n\t\t    {\n\t\t\tlen = 1;\t\/\/ matched a single byte above\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Need to match first byte again for multi-byte.\n\t\t\tlen = (int)STRLEN(opnd);\n\t\t\tif (cstrncmp(opnd, rex.input, &len) != 0)\n\t\t\t    status = RA_NOMATCH;\n\t\t    }\n\t\t    \/\/ Check for following composing character, unless %C\n\t\t    \/\/ follows (skips over all composing chars).\n\t\t    if (status != RA_NOMATCH\n\t\t\t    && enc_utf8\n\t\t\t    && UTF_COMPOSINGLIKE(rex.input, rex.input + len)\n\t\t\t    && !rex.reg_icombine\n\t\t\t    && OP(next) != RE_COMPOSING)\n\t\t    {\n\t\t\t\/\/ raaron: This code makes a composing character get\n\t\t\t\/\/ ignored, which is the correct behavior (sometimes)\n\t\t\t\/\/ for voweled Hebrew texts.\n\t\t\tstatus = RA_NOMATCH;\n\t\t    }\n\t\t    if (status != RA_NOMATCH)\n\t\t\trex.input += len;\n\t\t}\n\t    }\n\t    break;\n\n\t  case ANYOF:\n\t  case ANYBUT:\n\t    if (c == NUL)\n\t\tstatus = RA_NOMATCH;\n\t    else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case MULTIBYTECODE:\n\t    if (has_mbyte)\n\t    {\n\t\tint\ti, len;\n\t\tchar_u\t*opnd;\n\t\tint\topndc = 0, inpc;\n\n\t\topnd = OPERAND(scan);\n\t\t\/\/ Safety check (just in case 'encoding' was changed since\n\t\t\/\/ compiling the program).\n\t\tif ((len = (*mb_ptr2len)(opnd)) < 2)\n\t\t{\n\t\t    status = RA_NOMATCH;\n\t\t    break;\n\t\t}\n\t\tif (enc_utf8)\n\t\t    opndc = utf_ptr2char(opnd);\n\t\tif (enc_utf8 && utf_iscomposing(opndc))\n\t\t{\n\t\t    \/\/ When only a composing char is given match at any\n\t\t    \/\/ position where that composing char appears.\n\t\t    status = RA_NOMATCH;\n\t\t    for (i = 0; rex.input[i] != NUL;\n\t\t\t\t\t\ti += utf_ptr2len(rex.input + i))\n\t\t    {\n\t\t\tinpc = utf_ptr2char(rex.input + i);\n\t\t\tif (!utf_iscomposing(inpc))\n\t\t\t{\n\t\t\t    if (i > 0)\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (opndc == inpc)\n\t\t\t{\n\t\t\t    \/\/ Include all following composing chars.\n\t\t\t    len = i + utfc_ptr2len(rex.input + i);\n\t\t\t    status = RA_MATCH;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    for (i = 0; i < len; ++i)\n\t\t\tif (opnd[i] != rex.input[i])\n\t\t\t{\n\t\t\t    status = RA_NOMATCH;\n\t\t\t    break;\n\t\t\t}\n\t\trex.input += len;\n\t    }\n\t    else\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\t  case RE_COMPOSING:\n\t    if (enc_utf8)\n\t    {\n\t\t\/\/ Skip composing characters.\n\t\twhile (utf_iscomposing(utf_ptr2char(rex.input)))\n\t\t    MB_CPTR_ADV(rex.input);\n\t    }\n\t    break;\n\n\t  case NOTHING:\n\t    break;\n\n\t  case BACK:\n\t    {\n\t\tint\t\ti;\n\t\tbackpos_T\t*bp;\n\n\t\t\/\/ When we run into BACK we need to check if we don't keep\n\t\t\/\/ looping without matching any input.  The second and later\n\t\t\/\/ times a BACK is encountered it fails if the input is still\n\t\t\/\/ at the same position as the previous time.\n\t\t\/\/ The positions are stored in \"backpos\" and found by the\n\t\t\/\/ current value of \"scan\", the position in the RE program.\n\t\tbp = (backpos_T *)backpos.ga_data;\n\t\tfor (i = 0; i < backpos.ga_len; ++i)\n\t\t    if (bp[i].bp_scan == scan)\n\t\t\tbreak;\n\t\tif (i == backpos.ga_len)\n\t\t{\n\t\t    \/\/ First time at this BACK, make room to store the pos.\n\t\t    if (ga_grow(&backpos, 1) == FAIL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\t\/\/ get \"ga_data\" again, it may have changed\n\t\t\tbp = (backpos_T *)backpos.ga_data;\n\t\t\tbp[i].bp_scan = scan;\n\t\t\t++backpos.ga_len;\n\t\t    }\n\t\t}\n\t\telse if (reg_save_equal(&bp[i].bp_pos))\n\t\t    \/\/ Still at same position as last time, fail.\n\t\t    status = RA_NOMATCH;\n\n\t\tif (status != RA_FAIL && status != RA_NOMATCH)\n\t\t    reg_save(&bp[i].bp_pos, &backpos);\n\t    }\n\t    break;\n\n\t  case MOPEN + 0:   \/\/ Match start: \\zs\n\t  case MOPEN + 1:   \/\/ \\(\n\t  case MOPEN + 2:\n\t  case MOPEN + 3:\n\t  case MOPEN + 4:\n\t  case MOPEN + 5:\n\t  case MOPEN + 6:\n\t  case MOPEN + 7:\n\t  case MOPEN + 8:\n\t  case MOPEN + 9:\n\t    {\n\t\tno = op - MOPEN;\n\t\tcleanup_subexpr();\n\t\trp = regstack_push(RS_MOPEN, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, &rex.reg_startpos[no],\n\t\t\t\t\t\t\t  &rex.reg_startp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n\n\t  case NOPEN:\t    \/\/ \\%(\n\t  case NCLOSE:\t    \/\/ \\) after \\%(\n\t\tif (regstack_push(RS_NOPEN, scan) == NULL)\n\t\t    status = RA_FAIL;\n\t\t\/\/ We simply continue and handle the result when done.\n\t\tbreak;\n\n#ifdef FEAT_SYN_HL\n\t  case ZOPEN + 1:\n\t  case ZOPEN + 2:\n\t  case ZOPEN + 3:\n\t  case ZOPEN + 4:\n\t  case ZOPEN + 5:\n\t  case ZOPEN + 6:\n\t  case ZOPEN + 7:\n\t  case ZOPEN + 8:\n\t  case ZOPEN + 9:\n\t    {\n\t\tno = op - ZOPEN;\n\t\tcleanup_zsubexpr();\n\t\trp = regstack_push(RS_ZOPEN, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, ®_startzpos[no],\n\t\t\t\t\t\t\t     ®_startzp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case MCLOSE + 0:  \/\/ Match end: \\ze\n\t  case MCLOSE + 1:  \/\/ \\)\n\t  case MCLOSE + 2:\n\t  case MCLOSE + 3:\n\t  case MCLOSE + 4:\n\t  case MCLOSE + 5:\n\t  case MCLOSE + 6:\n\t  case MCLOSE + 7:\n\t  case MCLOSE + 8:\n\t  case MCLOSE + 9:\n\t    {\n\t\tno = op - MCLOSE;\n\t\tcleanup_subexpr();\n\t\trp = regstack_push(RS_MCLOSE, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, &rex.reg_endpos[no],\n\t\t\t\t\t\t\t    &rex.reg_endp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case ZCLOSE + 1:  \/\/ \\) after \\z(\n\t  case ZCLOSE + 2:\n\t  case ZCLOSE + 3:\n\t  case ZCLOSE + 4:\n\t  case ZCLOSE + 5:\n\t  case ZCLOSE + 6:\n\t  case ZCLOSE + 7:\n\t  case ZCLOSE + 8:\n\t  case ZCLOSE + 9:\n\t    {\n\t\tno = op - ZCLOSE;\n\t\tcleanup_zsubexpr();\n\t\trp = regstack_push(RS_ZCLOSE, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, ®_endzpos[no],\n\t\t\t\t\t\t\t      ®_endzp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case BACKREF + 1:\n\t  case BACKREF + 2:\n\t  case BACKREF + 3:\n\t  case BACKREF + 4:\n\t  case BACKREF + 5:\n\t  case BACKREF + 6:\n\t  case BACKREF + 7:\n\t  case BACKREF + 8:\n\t  case BACKREF + 9:\n\t    {\n\t\tint\t\tlen;\n\n\t\tno = op - BACKREF;\n\t\tcleanup_subexpr();\n\t\tif (!REG_MULTI)\t\t\/\/ Single-line regexp\n\t\t{\n\t\t    if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL)\n\t\t    {\n\t\t\t\/\/ Backref was not set: Match an empty string.\n\t\t\tlen = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Compare current input with back-ref in the same\n\t\t\t\/\/ line.\n\t\t\tlen = (int)(rex.reg_endp[no] - rex.reg_startp[no]);\n\t\t\tif (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0)\n\t\t\t    status = RA_NOMATCH;\n\t\t    }\n\t\t}\n\t\telse\t\t\t\t\/\/ Multi-line regexp\n\t\t{\n\t\t    if (rex.reg_startpos[no].lnum < 0\n\t\t\t\t\t\t|| rex.reg_endpos[no].lnum < 0)\n\t\t    {\n\t\t\t\/\/ Backref was not set: Match an empty string.\n\t\t\tlen = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (rex.reg_startpos[no].lnum == rex.lnum\n\t\t\t\t&& rex.reg_endpos[no].lnum == rex.lnum)\n\t\t\t{\n\t\t\t    \/\/ Compare back-ref within the current line.\n\t\t\t    len = rex.reg_endpos[no].col\n\t\t\t\t\t\t    - rex.reg_startpos[no].col;\n\t\t\t    if (cstrncmp(rex.line + rex.reg_startpos[no].col,\n\t\t\t\t\t\t\t  rex.input, &len) != 0)\n\t\t\t\tstatus = RA_NOMATCH;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Messy situation: Need to compare between two\n\t\t\t    \/\/ lines.\n\t\t\t    int r = match_with_backref(\n\t\t\t\t\t    rex.reg_startpos[no].lnum,\n\t\t\t\t\t    rex.reg_startpos[no].col,\n\t\t\t\t\t    rex.reg_endpos[no].lnum,\n\t\t\t\t\t    rex.reg_endpos[no].col,\n\t\t\t\t\t    &len);\n\n\t\t\t    if (r != RA_MATCH)\n\t\t\t\tstatus = r;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t\t\/\/ Matched the backref, skip over it.\n\t\trex.input += len;\n\t    }\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case ZREF + 1:\n\t  case ZREF + 2:\n\t  case ZREF + 3:\n\t  case ZREF + 4:\n\t  case ZREF + 5:\n\t  case ZREF + 6:\n\t  case ZREF + 7:\n\t  case ZREF + 8:\n\t  case ZREF + 9:\n\t    {\n\t\tint\tlen;\n\n\t\tcleanup_zsubexpr();\n\t\tno = op - ZREF;\n\t\tif (re_extmatch_in != NULL\n\t\t\t&& re_extmatch_in->matches[no] != NULL)\n\t\t{\n\t\t    len = (int)STRLEN(re_extmatch_in->matches[no]);\n\t\t    if (cstrncmp(re_extmatch_in->matches[no],\n\t\t\t\t\t\t\t  rex.input, &len) != 0)\n\t\t\tstatus = RA_NOMATCH;\n\t\t    else\n\t\t\trex.input += len;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Backref was not set: Match an empty string.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case BRANCH:\n\t    {\n\t\tif (OP(next) != BRANCH) \/\/ No choice.\n\t\t    next = OPERAND(scan);\t\/\/ Avoid recursion.\n\t\telse\n\t\t{\n\t\t    rp = regstack_push(RS_BRANCH, scan);\n\t\t    if (rp == NULL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t\tstatus = RA_BREAK;\t\/\/ rest is below\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_LIMITS:\n\t    {\n\t\tif (OP(next) == BRACE_SIMPLE)\n\t\t{\n\t\t    bl_minval = OPERAND_MIN(scan);\n\t\t    bl_maxval = OPERAND_MAX(scan);\n\t\t}\n\t\telse if (OP(next) >= BRACE_COMPLEX\n\t\t\t&& OP(next) < BRACE_COMPLEX + 10)\n\t\t{\n\t\t    no = OP(next) - BRACE_COMPLEX;\n\t\t    brace_min[no] = OPERAND_MIN(scan);\n\t\t    brace_max[no] = OPERAND_MAX(scan);\n\t\t    brace_count[no] = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    internal_error(\"BRACE_LIMITS\");\n\t\t    status = RA_FAIL;\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_COMPLEX + 0:\n\t  case BRACE_COMPLEX + 1:\n\t  case BRACE_COMPLEX + 2:\n\t  case BRACE_COMPLEX + 3:\n\t  case BRACE_COMPLEX + 4:\n\t  case BRACE_COMPLEX + 5:\n\t  case BRACE_COMPLEX + 6:\n\t  case BRACE_COMPLEX + 7:\n\t  case BRACE_COMPLEX + 8:\n\t  case BRACE_COMPLEX + 9:\n\t    {\n\t\tno = op - BRACE_COMPLEX;\n\t\t++brace_count[no];\n\n\t\t\/\/ If not matched enough times yet, try one more\n\t\tif (brace_count[no] <= (brace_min[no] <= brace_max[no]\n\t\t\t\t\t     ? brace_min[no] : brace_max[no]))\n\t\t{\n\t\t    rp = regstack_push(RS_BRCPLX_MORE, scan);\n\t\t    if (rp == NULL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\trp->rs_no = no;\n\t\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\t\tnext = OPERAND(scan);\n\t\t\t\/\/ We continue and handle the result when done.\n\t\t    }\n\t\t    break;\n\t\t}\n\n\t\t\/\/ If matched enough times, may try matching some more\n\t\tif (brace_min[no] <= brace_max[no])\n\t\t{\n\t\t    \/\/ Range is the normal way around, use longest match\n\t\t    if (brace_count[no] <= brace_max[no])\n\t\t    {\n\t\t\trp = regstack_push(RS_BRCPLX_LONG, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    rp->rs_no = no;\n\t\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t\t    next = OPERAND(scan);\n\t\t\t    \/\/ We continue and handle the result when done.\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Range is backwards, use shortest match first\n\t\t    if (brace_count[no] <= brace_min[no])\n\t\t    {\n\t\t\trp = regstack_push(RS_BRCPLX_SHORT, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t\t    \/\/ We continue and handle the result when done.\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_SIMPLE:\n\t  case STAR:\n\t  case PLUS:\n\t    {\n\t\tregstar_T\trst;\n\n\t\t\/\/ Lookahead to avoid useless match attempts when we know\n\t\t\/\/ what character comes next.\n\t\tif (OP(next) == EXACTLY)\n\t\t{\n\t\t    rst.nextb = *OPERAND(next);\n\t\t    if (rex.reg_ic)\n\t\t    {\n\t\t\tif (MB_ISUPPER(rst.nextb))\n\t\t\t    rst.nextb_ic = MB_TOLOWER(rst.nextb);\n\t\t\telse\n\t\t\t    rst.nextb_ic = MB_TOUPPER(rst.nextb);\n\t\t    }\n\t\t    else\n\t\t\trst.nextb_ic = rst.nextb;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rst.nextb = NUL;\n\t\t    rst.nextb_ic = NUL;\n\t\t}\n\t\tif (op != BRACE_SIMPLE)\n\t\t{\n\t\t    rst.minval = (op == STAR) ? 0 : 1;\n\t\t    rst.maxval = MAX_LIMIT;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rst.minval = bl_minval;\n\t\t    rst.maxval = bl_maxval;\n\t\t}\n\n\t\t\/\/ When maxval > minval, try matching as much as possible, up\n\t\t\/\/ to maxval.  When maxval < minval, try matching at least the\n\t\t\/\/ minimal number (since the range is backwards, that's also\n\t\t\/\/ maxval!).\n\t\trst.count = regrepeat(OPERAND(scan), rst.maxval);\n\t\tif (got_int)\n\t\t{\n\t\t    status = RA_FAIL;\n\t\t    break;\n\t\t}\n\t\tif (rst.minval <= rst.maxval\n\t\t\t  ? rst.count >= rst.minval : rst.count >= rst.maxval)\n\t\t{\n\t\t    \/\/ It could match.  Prepare for trying to match what\n\t\t    \/\/ follows.  The code is below.  Parameters are stored in\n\t\t    \/\/ a regstar_T on the regstack.\n\t\t    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n\t\t    {\n\t\t\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\t\t\tstatus = RA_FAIL;\n\t\t    }\n\t\t    else if (ga_grow(®stack, sizeof(regstar_T)) == FAIL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\tregstack.ga_len += sizeof(regstar_T);\n\t\t\trp = regstack_push(rst.minval <= rst.maxval\n\t\t\t\t\t? RS_STAR_LONG : RS_STAR_SHORT, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    *(((regstar_T *)rp) - 1) = rst;\n\t\t\t    status = RA_BREAK;\t    \/\/ skip the restore bits\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    status = RA_NOMATCH;\n\n\t    }\n\t    break;\n\n\t  case NOMATCH:\n\t  case MATCH:\n\t  case SUBPAT:\n\t    rp = regstack_push(RS_NOMATCH, scan);\n\t    if (rp == NULL)\n\t\tstatus = RA_FAIL;\n\t    else\n\t    {\n\t\trp->rs_no = op;\n\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\tnext = OPERAND(scan);\n\t\t\/\/ We continue and handle the result when done.\n\t    }\n\t    break;\n\n\t  case BEHIND:\n\t  case NOBEHIND:\n\t    \/\/ Need a bit of room to store extra positions.\n\t    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n\t    {\n\t\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\t\tstatus = RA_FAIL;\n\t    }\n\t    else if (ga_grow(®stack, sizeof(regbehind_T)) == FAIL)\n\t\tstatus = RA_FAIL;\n\t    else\n\t    {\n\t\tregstack.ga_len += sizeof(regbehind_T);\n\t\trp = regstack_push(RS_BEHIND1, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    \/\/ Need to save the subexpr to be able to restore them\n\t\t    \/\/ when there is a match but we don't use it.\n\t\t    save_subexpr(((regbehind_T *)rp) - 1);\n\n\t\t    rp->rs_no = op;\n\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t    \/\/ First try if what follows matches.  If it does then we\n\t\t    \/\/ check the behind match by looping.\n\t\t}\n\t    }\n\t    break;\n\n\t  case BHPOS:\n\t    if (REG_MULTI)\n\t    {\n\t\tif (behind_pos.rs_u.pos.col != (colnr_T)(rex.input - rex.line)\n\t\t\t|| behind_pos.rs_u.pos.lnum != rex.lnum)\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    else if (behind_pos.rs_u.ptr != rex.input)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case NEWL:\n\t    if ((c != NUL || !REG_MULTI || rex.lnum > rex.reg_maxline\n\t\t\t     || rex.reg_line_lbr)\n\t\t\t\t\t   && (c != '\\n' || !rex.reg_line_lbr))\n\t\tstatus = RA_NOMATCH;\n\t    else if (rex.reg_line_lbr)\n\t\tADVANCE_REGINPUT();\n\t    else\n\t\treg_nextline();\n\t    break;\n\n\t  case END:\n\t    status = RA_MATCH;\t\/\/ Success!\n\t    break;\n\n\t  default:\n\t    iemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\t    printf(\"Illegal op code %d\\n\", op);\n#endif\n\t    status = RA_FAIL;\n\t    break;\n\t  }\n\t}\n\n\t\/\/ If we can't continue sequentially, break the inner loop.\n\tif (status != RA_CONT)\n\t    break;\n\n\t\/\/ Continue in inner loop, advance to next item.\n\tscan = next;\n\n    } \/\/ end of inner loop\n\n    \/\/ If there is something on the regstack execute the code for the state.\n    \/\/ If the state is popped then loop and use the older state.\n    while (regstack.ga_len > 0 && status != RA_FAIL)\n    {\n\trp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;\n\tswitch (rp->rs_state)\n\t{\n\t  case RS_NOPEN:\n\t    \/\/ Result is passed on as-is, simply pop the state.\n\t    regstack_pop(&scan);\n\t    break;\n\n\t  case RS_MOPEN:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no],\n\t\t\t\t\t\t  &rex.reg_startp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case RS_ZOPEN:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, ®_startzpos[rp->rs_no],\n\t\t\t\t\t\t ®_startzp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n#endif\n\n\t  case RS_MCLOSE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no],\n\t\t\t\t\t\t    &rex.reg_endp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case RS_ZCLOSE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, ®_endzpos[rp->rs_no],\n\t\t\t\t\t\t   ®_endzp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n#endif\n\n\t  case RS_BRANCH:\n\t    if (status == RA_MATCH)\n\t\t\/\/ this branch matched, use it\n\t\tregstack_pop(&scan);\n\t    else\n\t    {\n\t\tif (status != RA_BREAK)\n\t\t{\n\t\t    \/\/ After a non-matching branch: try next one.\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t    scan = rp->rs_scan;\n\t\t}\n\t\tif (scan == NULL || OP(scan) != BRANCH)\n\t\t{\n\t\t    \/\/ no more branches, didn't find a match\n\t\t    status = RA_NOMATCH;\n\t\t    regstack_pop(&scan);\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Prepare to try a branch.\n\t\t    rp->rs_scan = regnext(scan);\n\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t    scan = OPERAND(scan);\n\t\t}\n\t    }\n\t    break;\n\n\t  case RS_BRCPLX_MORE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\t--brace_count[rp->rs_no];\t\/\/ decrement match count\n\t    }\n\t    regstack_pop(&scan);\n\t    break;\n\n\t  case RS_BRCPLX_LONG:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\t\/\/ There was no match, but we did find enough matches.\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\t--brace_count[rp->rs_no];\n\t\t\/\/ continue with the items after \"\\{}\"\n\t\tstatus = RA_CONT;\n\t    }\n\t    regstack_pop(&scan);\n\t    if (status == RA_CONT)\n\t\tscan = regnext(scan);\n\t    break;\n\n\t  case RS_BRCPLX_SHORT:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\t\/\/ There was no match, try to match one more item.\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t    regstack_pop(&scan);\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\tscan = OPERAND(scan);\n\t\tstatus = RA_CONT;\n\t    }\n\t    break;\n\n\t  case RS_NOMATCH:\n\t    \/\/ Pop the state.  If the operand matches for NOMATCH or\n\t    \/\/ doesn't match for MATCH\/SUBPAT, we fail.  Otherwise backup,\n\t    \/\/ except for SUBPAT, and continue with the next item.\n\t    if (status == (rp->rs_no == NOMATCH ? RA_MATCH : RA_NOMATCH))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t    {\n\t\tstatus = RA_CONT;\n\t\tif (rp->rs_no != SUBPAT)\t\/\/ zero-width\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t    }\n\t    regstack_pop(&scan);\n\t    if (status == RA_CONT)\n\t\tscan = regnext(scan);\n\t    break;\n\n\t  case RS_BEHIND1:\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\tregstack_pop(&scan);\n\t\tregstack.ga_len -= sizeof(regbehind_T);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ The stuff after BEHIND\/NOBEHIND matches.  Now try if\n\t\t\/\/ the behind part does (not) match before the current\n\t\t\/\/ position in the input.  This must be done at every\n\t\t\/\/ position in the input and checking if the match ends at\n\t\t\/\/ the current position.\n\n\t\t\/\/ save the position after the found match for next\n\t\treg_save(&(((regbehind_T *)rp) - 1)->save_after, &backpos);\n\n\t\t\/\/ Start looking for a match with operand at the current\n\t\t\/\/ position.  Go back one character until we find the\n\t\t\/\/ result, hitting the start of the line or the previous\n\t\t\/\/ line (for multi-line matching).\n\t\t\/\/ Set behind_pos to where the match should end, BHPOS\n\t\t\/\/ will match it.  Save the current value.\n\t\t(((regbehind_T *)rp) - 1)->save_behind = behind_pos;\n\t\tbehind_pos = rp->rs_un.regsave;\n\n\t\trp->rs_state = RS_BEHIND2;\n\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\tscan = OPERAND(rp->rs_scan) + 4;\n\t    }\n\t    break;\n\n\t  case RS_BEHIND2:\n\t    \/\/ Looping for BEHIND \/ NOBEHIND match.\n\t    if (status == RA_MATCH && reg_save_equal(&behind_pos))\n\t    {\n\t\t\/\/ found a match that ends where \"next\" started\n\t\tbehind_pos = (((regbehind_T *)rp) - 1)->save_behind;\n\t\tif (rp->rs_no == BEHIND)\n\t\t    reg_restore(&(((regbehind_T *)rp) - 1)->save_after,\n\t\t\t\t\t\t\t\t    &backpos);\n\t\telse\n\t\t{\n\t\t    \/\/ But we didn't want a match.  Need to restore the\n\t\t    \/\/ subexpr, because what follows matched, so they have\n\t\t    \/\/ been set.\n\t\t    status = RA_NOMATCH;\n\t\t    restore_subexpr(((regbehind_T *)rp) - 1);\n\t\t}\n\t\tregstack_pop(&scan);\n\t\tregstack.ga_len -= sizeof(regbehind_T);\n\t    }\n\t    else\n\t    {\n\t\tlong limit;\n\n\t\t\/\/ No match or a match that doesn't end where we want it: Go\n\t\t\/\/ back one character.  May go to previous line once.\n\t\tno = OK;\n\t\tlimit = OPERAND_MIN(rp->rs_scan);\n\t\tif (REG_MULTI)\n\t\t{\n\t\t    if (limit > 0\n\t\t\t    && ((rp->rs_un.regsave.rs_u.pos.lnum\n\t\t\t\t\t\t    < behind_pos.rs_u.pos.lnum\n\t\t\t\t    ? (colnr_T)STRLEN(rex.line)\n\t\t\t\t    : behind_pos.rs_u.pos.col)\n\t\t\t\t- rp->rs_un.regsave.rs_u.pos.col >= limit))\n\t\t\tno = FAIL;\n\t\t    else if (rp->rs_un.regsave.rs_u.pos.col == 0)\n\t\t    {\n\t\t\tif (rp->rs_un.regsave.rs_u.pos.lnum\n\t\t\t\t\t< behind_pos.rs_u.pos.lnum\n\t\t\t\t|| reg_getline(\n\t\t\t\t\t--rp->rs_un.regsave.rs_u.pos.lnum)\n\t\t\t\t\t\t\t\t  == NULL)\n\t\t\t    no = FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t\t    rp->rs_un.regsave.rs_u.pos.col =\n\t\t\t\t\t\t (colnr_T)STRLEN(rex.line);\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t{\n\t\t\t    char_u *line =\n\t\t\t\t  reg_getline(rp->rs_un.regsave.rs_u.pos.lnum);\n\n\t\t\t    rp->rs_un.regsave.rs_u.pos.col -=\n\t\t\t\t(*mb_head_off)(line, line\n\t\t\t\t    + rp->rs_un.regsave.rs_u.pos.col - 1) + 1;\n\t\t\t}\n\t\t\telse\n\t\t\t    --rp->rs_un.regsave.rs_u.pos.col;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (rp->rs_un.regsave.rs_u.ptr == rex.line)\n\t\t\tno = FAIL;\n\t\t    else\n\t\t    {\n\t\t\tMB_PTR_BACK(rex.line, rp->rs_un.regsave.rs_u.ptr);\n\t\t\tif (limit > 0 && (long)(behind_pos.rs_u.ptr\n\t\t\t\t     - rp->rs_un.regsave.rs_u.ptr) > limit)\n\t\t\t    no = FAIL;\n\t\t    }\n\t\t}\n\t\tif (no == OK)\n\t\t{\n\t\t    \/\/ Advanced, prepare for finding match again.\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t    scan = OPERAND(rp->rs_scan) + 4;\n\t\t    if (status == RA_MATCH)\n\t\t    {\n\t\t\t\/\/ We did match, so subexpr may have been changed,\n\t\t\t\/\/ need to restore them for the next try.\n\t\t\tstatus = RA_NOMATCH;\n\t\t\trestore_subexpr(((regbehind_T *)rp) - 1);\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Can't advance.  For NOBEHIND that's a match.\n\t\t    behind_pos = (((regbehind_T *)rp) - 1)->save_behind;\n\t\t    if (rp->rs_no == NOBEHIND)\n\t\t    {\n\t\t\treg_restore(&(((regbehind_T *)rp) - 1)->save_after,\n\t\t\t\t\t\t\t\t    &backpos);\n\t\t\tstatus = RA_MATCH;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ We do want a proper match.  Need to restore the\n\t\t\t\/\/ subexpr if we had a match, because they may have\n\t\t\t\/\/ been set.\n\t\t\tif (status == RA_MATCH)\n\t\t\t{\n\t\t\t    status = RA_NOMATCH;\n\t\t\t    restore_subexpr(((regbehind_T *)rp) - 1);\n\t\t\t}\n\t\t    }\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regbehind_T);\n\t\t}\n\t    }\n\t    break;\n\n\t  case RS_STAR_LONG:\n\t  case RS_STAR_SHORT:\n\t    {\n\t\tregstar_T\t    *rst = ((regstar_T *)rp) - 1;\n\n\t\tif (status == RA_MATCH)\n\t\t{\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regstar_T);\n\t\t    break;\n\t\t}\n\n\t\t\/\/ Tried once already, restore input pointers.\n\t\tif (status != RA_BREAK)\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\n\t\t\/\/ Repeat until we found a position where it could match.\n\t\tfor (;;)\n\t\t{\n\t\t    if (status != RA_BREAK)\n\t\t    {\n\t\t\t\/\/ Tried first position already, advance.\n\t\t\tif (rp->rs_state == RS_STAR_LONG)\n\t\t\t{\n\t\t\t    \/\/ Trying for longest match, but couldn't or\n\t\t\t    \/\/ didn't match -- back up one char.\n\t\t\t    if (--rst->count < rst->minval)\n\t\t\t\tbreak;\n\t\t\t    if (rex.input == rex.line)\n\t\t\t    {\n\t\t\t\t\/\/ backup to last char of previous line\n\t\t\t\tif (rex.lnum == 0)\n\t\t\t\t{\n\t\t\t\t    status = RA_NOMATCH;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t\t--rex.lnum;\n\t\t\t\trex.line = reg_getline(rex.lnum);\n\t\t\t\t\/\/ Just in case regrepeat() didn't count\n\t\t\t\t\/\/ right.\n\t\t\t\tif (rex.line == NULL)\n\t\t\t\t    break;\n\t\t\t\trex.input = rex.line + STRLEN(rex.line);\n\t\t\t\tfast_breakcheck();\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tMB_PTR_BACK(rex.line, rex.input);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Range is backwards, use shortest match first.\n\t\t\t    \/\/ Careful: maxval and minval are exchanged!\n\t\t\t    \/\/ Couldn't or didn't match: try advancing one\n\t\t\t    \/\/ char.\n\t\t\t    if (rst->count == rst->minval\n\t\t\t\t  || regrepeat(OPERAND(rp->rs_scan), 1L) == 0)\n\t\t\t\tbreak;\n\t\t\t    ++rst->count;\n\t\t\t}\n\t\t\tif (got_int)\n\t\t\t    break;\n\t\t    }\n\t\t    else\n\t\t\tstatus = RA_NOMATCH;\n\n\t\t    \/\/ If it could match, try it.\n\t\t    if (rst->nextb == NUL || *rex.input == rst->nextb\n\t\t\t\t\t     || *rex.input == rst->nextb_ic)\n\t\t    {\n\t\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\t\tscan = regnext(rp->rs_scan);\n\t\t\tstatus = RA_CONT;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t\tif (status != RA_CONT)\n\t\t{\n\t\t    \/\/ Failed.\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regstar_T);\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t    }\n\t    break;\n\t}\n\n\t\/\/ If we want to continue the inner loop or didn't pop a state\n\t\/\/ continue matching loop\n\tif (status == RA_CONT || rp == (regitem_T *)\n\t\t\t     ((char *)regstack.ga_data + regstack.ga_len) - 1)\n\t    break;\n    }\n\n    \/\/ May need to continue with the inner loop, starting at \"scan\".\n    if (status == RA_CONT)\n\tcontinue;\n\n    \/\/ If the regstack is empty or something failed we are done.\n    if (regstack.ga_len == 0 || status == RA_FAIL)\n    {\n\tif (scan == NULL)\n\t{\n\t    \/\/ We get here only if there's trouble -- normally \"case END\" is\n\t    \/\/ the terminating point.\n\t    iemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\t    printf(\"Premature EOL\\n\");\n#endif\n\t}\n\treturn (status == RA_MATCH);\n    }\n\n  } \/\/ End of loop until the regstack is empty.\n\n  \/\/ NOTREACHED\n}","target":0,"code_token_length":10953,"total_token_length":11189,"max_tokens_setting":28000}
+{"idx":333060,"func":"nfa_emit_equi_class(int c)\n{\n#define EMIT2(c)    EMIT(c); EMIT(NFA_CONCAT);\n\n    if (enc_utf8 || STRCMP(p_enc, \"latin1\") == 0\n\t\t\t\t\t || STRCMP(p_enc, \"iso-8859-15\") == 0)\n    {\n#ifdef EBCDIC\n# define A_circumflex 0x62\n# define A_diaeresis 0x63\n# define A_grave 0x64\n# define A_acute 0x65\n# define A_virguilla 0x66\n# define A_ring 0x67\n# define C_cedilla 0x68\n# define E_acute 0x71\n# define E_circumflex 0x72\n# define E_diaeresis 0x73\n# define E_grave 0x74\n# define I_acute 0x75\n# define I_circumflex 0x76\n# define I_diaeresis 0x77\n# define I_grave 0x78\n# define N_virguilla 0x69\n# define O_circumflex 0xeb\n# define O_diaeresis 0xec\n# define O_grave 0xed\n# define O_acute 0xee\n# define O_virguilla 0xef\n# define O_slash 0x80\n# define U_circumflex 0xfb\n# define U_diaeresis 0xfc\n# define U_grave 0xfd\n# define U_acute 0xfe\n# define Y_acute 0xba\n# define a_grave 0x42\n# define a_acute 0x43\n# define a_circumflex 0x44\n# define a_virguilla 0x45\n# define a_diaeresis 0x46\n# define a_ring 0x47\n# define c_cedilla 0x48\n# define e_grave 0x51\n# define e_acute 0x52\n# define e_circumflex 0x53\n# define e_diaeresis 0x54\n# define i_grave 0x55\n# define i_acute 0x56\n# define i_circumflex 0x57\n# define i_diaeresis 0x58\n# define n_virguilla 0x49\n# define o_grave 0xcb\n# define o_acute 0xcc\n# define o_circumflex 0xcd\n# define o_virguilla 0xce\n# define o_diaeresis 0xcf\n# define o_slash 0x70\n# define u_grave 0xdb\n# define u_acute 0xdc\n# define u_circumflex 0xdd\n# define u_diaeresis 0xde\n# define y_acute 0x8d\n# define y_diaeresis 0xdf\n#else\n# define A_grave 0xc0\n# define A_acute 0xc1\n# define A_circumflex 0xc2\n# define A_virguilla 0xc3\n# define A_diaeresis 0xc4\n# define A_ring 0xc5\n# define C_cedilla 0xc7\n# define E_grave 0xc8\n# define E_acute 0xc9\n# define E_circumflex 0xca\n# define E_diaeresis 0xcb\n# define I_grave 0xcc\n# define I_acute 0xcd\n# define I_circumflex 0xce\n# define I_diaeresis 0xcf\n# define N_virguilla 0xd1\n# define O_grave 0xd2\n# define O_acute 0xd3\n# define O_circumflex 0xd4\n# define O_virguilla 0xd5\n# define O_diaeresis 0xd6\n# define O_slash 0xd8\n# define U_grave 0xd9\n# define U_acute 0xda\n# define U_circumflex 0xdb\n# define U_diaeresis 0xdc\n# define Y_acute 0xdd\n# define a_grave 0xe0\n# define a_acute 0xe1\n# define a_circumflex 0xe2\n# define a_virguilla 0xe3\n# define a_diaeresis 0xe4\n# define a_ring 0xe5\n# define c_cedilla 0xe7\n# define e_grave 0xe8\n# define e_acute 0xe9\n# define e_circumflex 0xea\n# define e_diaeresis 0xeb\n# define i_grave 0xec\n# define i_acute 0xed\n# define i_circumflex 0xee\n# define i_diaeresis 0xef\n# define n_virguilla 0xf1\n# define o_grave 0xf2\n# define o_acute 0xf3\n# define o_circumflex 0xf4\n# define o_virguilla 0xf5\n# define o_diaeresis 0xf6\n# define o_slash 0xf8\n# define u_grave 0xf9\n# define u_acute 0xfa\n# define u_circumflex 0xfb\n# define u_diaeresis 0xfc\n# define y_acute 0xfd\n# define y_diaeresis 0xff\n#endif\n\tswitch (c)\n\t{\n\t    case 'A': case A_grave: case A_acute: case A_circumflex:\n\t    case A_virguilla: case A_diaeresis: case A_ring:\n\t    case 0x100: case 0x102: case 0x104: case 0x1cd:\n\t    case 0x1de: case 0x1e0: case 0x1fa: case 0x200:\n\t    case 0x202: case 0x226: case 0x23a: case 0x1e00:\n\t    case 0x1ea0: case 0x1ea2: case 0x1ea4: case 0x1ea6:\n\t    case 0x1ea8: case 0x1eaa: case 0x1eac: case 0x1eae:\n\t    case 0x1eb0: case 0x1eb2: case 0x1eb4: case 0x1eb6:\n\t\t    EMIT2('A') EMIT2(A_grave) EMIT2(A_acute)\n\t\t    EMIT2(A_circumflex) EMIT2(A_virguilla)\n\t\t    EMIT2(A_diaeresis) EMIT2(A_ring)\n\t\t    EMIT2(0x100) EMIT2(0x102) EMIT2(0x104)\n\t\t    EMIT2(0x1cd) EMIT2(0x1de) EMIT2(0x1e0)\n\t\t    EMIT2(0x1fa) EMIT2(0x200) EMIT2(0x202)\n\t\t    EMIT2(0x226) EMIT2(0x23a) EMIT2(0x1e00)\n\t\t    EMIT2(0x1ea0) EMIT2(0x1ea2) EMIT2(0x1ea4)\n\t\t    EMIT2(0x1ea6) EMIT2(0x1ea8) EMIT2(0x1eaa)\n\t\t    EMIT2(0x1eac) EMIT2(0x1eae) EMIT2(0x1eb0)\n\t\t    EMIT2(0x1eb2) EMIT2(0x1eb6) EMIT2(0x1eb4)\n\t\t    return OK;\n\n\t    case 'B': case 0x181: case 0x243: case 0x1e02:\n\t    case 0x1e04: case 0x1e06:\n\t\t    EMIT2('B')\n\t\t    EMIT2(0x181) EMIT2(0x243) EMIT2(0x1e02)\n\t\t    EMIT2(0x1e04) EMIT2(0x1e06)\n\t\t    return OK;\n\n\t    case 'C': case C_cedilla: case 0x106: case 0x108:\n\t    case 0x10a: case 0x10c: case 0x187: case 0x23b:\n\t    case 0x1e08: case 0xa792:\n\t\t    EMIT2('C') EMIT2(C_cedilla)\n\t\t    EMIT2(0x106) EMIT2(0x108) EMIT2(0x10a)\n\t\t    EMIT2(0x10c) EMIT2(0x187) EMIT2(0x23b)\n\t\t    EMIT2(0x1e08) EMIT2(0xa792)\n\t\t    return OK;\n\n\t    case 'D': case 0x10e: case 0x110: case 0x18a:\n\t    case 0x1e0a: case 0x1e0c: case 0x1e0e: case 0x1e10:\n\t    case 0x1e12:\n\t\t    EMIT2('D') EMIT2(0x10e) EMIT2(0x110) EMIT2(0x18a)\n\t\t    EMIT2(0x1e0a) EMIT2(0x1e0c) EMIT2(0x1e0e)\n\t\t    EMIT2(0x1e10) EMIT2(0x1e12)\n\t\t    return OK;\n\n\t    case 'E': case E_grave: case E_acute: case E_circumflex:\n\t    case E_diaeresis: case 0x112: case 0x114: case 0x116:\n\t    case 0x118: case 0x11a: case 0x204: case 0x206:\n\t    case 0x228: case 0x246: case 0x1e14: case 0x1e16:\n\t    case 0x1e18: case 0x1e1a: case 0x1e1c: case 0x1eb8:\n\t    case 0x1eba: case 0x1ebc: case 0x1ebe: case 0x1ec0:\n\t    case 0x1ec2: case 0x1ec4: case 0x1ec6:\n\t\t    EMIT2('E') EMIT2(E_grave) EMIT2(E_acute)\n\t\t    EMIT2(E_circumflex) EMIT2(E_diaeresis)\n\t\t    EMIT2(0x112) EMIT2(0x114) EMIT2(0x116)\n\t\t    EMIT2(0x118) EMIT2(0x11a) EMIT2(0x204)\n\t\t    EMIT2(0x206) EMIT2(0x228) EMIT2(0x246)\n\t\t    EMIT2(0x1e14) EMIT2(0x1e16) EMIT2(0x1e18)\n\t\t    EMIT2(0x1e1a) EMIT2(0x1e1c) EMIT2(0x1eb8)\n\t\t    EMIT2(0x1eba) EMIT2(0x1ebc) EMIT2(0x1ebe)\n\t\t    EMIT2(0x1ec0) EMIT2(0x1ec2) EMIT2(0x1ec4)\n\t\t    EMIT2(0x1ec6)\n\t\t    return OK;\n\n\t    case 'F': case 0x191: case 0x1e1e: case 0xa798:\n\t\t    EMIT2('F') EMIT2(0x191) EMIT2(0x1e1e) EMIT2(0xa798)\n\t\t    return OK;\n\n\t    case 'G': case 0x11c: case 0x11e: case 0x120:\n\t    case 0x122: case 0x193: case 0x1e4: case 0x1e6:\n\t    case 0x1f4: case 0x1e20: case 0xa7a0:\n\t\t    EMIT2('G') EMIT2(0x11c) EMIT2(0x11e) EMIT2(0x120)\n\t\t    EMIT2(0x122) EMIT2(0x193) EMIT2(0x1e4)\n\t\t    EMIT2(0x1e6) EMIT2(0x1f4) EMIT2(0x1e20)\n\t\t    EMIT2(0xa7a0)\n\t\t    return OK;\n\n\t    case 'H': case 0x124: case 0x126: case 0x21e:\n\t    case 0x1e22: case 0x1e24: case 0x1e26: case 0x1e28:\n\t    case 0x1e2a: case 0x2c67:\n\t\t    EMIT2('H') EMIT2(0x124) EMIT2(0x126) EMIT2(0x21e)\n\t\t    EMIT2(0x1e22) EMIT2(0x1e24) EMIT2(0x1e26)\n\t\t    EMIT2(0x1e28) EMIT2(0x1e2a) EMIT2(0x2c67)\n\t\t    return OK;\n\n\t    case 'I': case I_grave: case I_acute: case I_circumflex:\n\t    case I_diaeresis: case 0x128: case 0x12a: case 0x12c:\n\t    case 0x12e: case 0x130: case 0x197: case 0x1cf:\n\t    case 0x208: case 0x20a: case 0x1e2c: case 0x1e2e:\n\t    case 0x1ec8: case 0x1eca:\n\t\t    EMIT2('I') EMIT2(I_grave) EMIT2(I_acute)\n\t\t    EMIT2(I_circumflex) EMIT2(I_diaeresis)\n\t\t    EMIT2(0x128) EMIT2(0x12a) EMIT2(0x12c)\n\t\t    EMIT2(0x12e) EMIT2(0x130) EMIT2(0x197)\n\t\t    EMIT2(0x1cf) EMIT2(0x208) EMIT2(0x20a)\n\t\t    EMIT2(0x1e2c) EMIT2(0x1e2e) EMIT2(0x1ec8)\n\t\t    EMIT2(0x1eca)\n\t\t    return OK;\n\n\t    case 'J': case 0x134: case 0x248:\n\t\t    EMIT2('J') EMIT2(0x134) EMIT2(0x248)\n\t\t    return OK;\n\n\t    case 'K': case 0x136: case 0x198: case 0x1e8: case 0x1e30:\n\t    case 0x1e32: case 0x1e34: case 0x2c69: case 0xa740:\n\t\t    EMIT2('K') EMIT2(0x136) EMIT2(0x198) EMIT2(0x1e8)\n\t\t    EMIT2(0x1e30) EMIT2(0x1e32) EMIT2(0x1e34)\n\t\t    EMIT2(0x2c69) EMIT2(0xa740)\n\t\t    return OK;\n\n\t    case 'L': case 0x139: case 0x13b: case 0x13d:\n\t    case 0x13f: case 0x141: case 0x23d: case 0x1e36:\n\t    case 0x1e38: case 0x1e3a: case 0x1e3c: case 0x2c60:\n\t\t    EMIT2('L') EMIT2(0x139) EMIT2(0x13b)\n\t\t    EMIT2(0x13d) EMIT2(0x13f) EMIT2(0x141)\n\t\t    EMIT2(0x23d) EMIT2(0x1e36) EMIT2(0x1e38)\n\t\t    EMIT2(0x1e3a) EMIT2(0x1e3c) EMIT2(0x2c60)\n\t\t    return OK;\n\n\t    case 'M': case 0x1e3e: case 0x1e40: case 0x1e42:\n\t\t    EMIT2('M') EMIT2(0x1e3e) EMIT2(0x1e40)\n\t\t    EMIT2(0x1e42)\n\t\t    return OK;\n\n\t    case 'N': case N_virguilla:\n\t    case 0x143: case 0x145: case 0x147: case 0x1f8:\n\t    case 0x1e44: case 0x1e46: case 0x1e48: case 0x1e4a:\n\t    case 0xa7a4:\n\t\t    EMIT2('N') EMIT2(N_virguilla)\n\t\t    EMIT2(0x143) EMIT2(0x145) EMIT2(0x147)\n\t\t    EMIT2(0x1f8) EMIT2(0x1e44) EMIT2(0x1e46)\n\t\t    EMIT2(0x1e48) EMIT2(0x1e4a) EMIT2(0xa7a4)\n\t\t    return OK;\n\n\t    case 'O': case O_grave: case O_acute: case O_circumflex:\n\t    case O_virguilla: case O_diaeresis: case O_slash:\n\t    case 0x14c: case 0x14e: case 0x150: case 0x19f:\n\t    case 0x1a0: case 0x1d1: case 0x1ea: case 0x1ec:\n\t    case 0x1fe: case 0x20c: case 0x20e: case 0x22a:\n\t    case 0x22c: case 0x22e: case 0x230: case 0x1e4c:\n\t    case 0x1e4e: case 0x1e50: case 0x1e52: case 0x1ecc:\n\t    case 0x1ece: case 0x1ed0: case 0x1ed2: case 0x1ed4:\n\t    case 0x1ed6: case 0x1ed8: case 0x1eda: case 0x1edc:\n\t    case 0x1ede: case 0x1ee0: case 0x1ee2:\n\t\t    EMIT2('O') EMIT2(O_grave) EMIT2(O_acute)\n\t\t    EMIT2(O_circumflex) EMIT2(O_virguilla)\n\t\t    EMIT2(O_diaeresis) EMIT2(O_slash)\n\t\t    EMIT2(0x14c) EMIT2(0x14e) EMIT2(0x150)\n\t\t    EMIT2(0x19f) EMIT2(0x1a0) EMIT2(0x1d1)\n\t\t    EMIT2(0x1ea) EMIT2(0x1ec) EMIT2(0x1fe)\n\t\t    EMIT2(0x20c) EMIT2(0x20e) EMIT2(0x22a)\n\t\t    EMIT2(0x22c) EMIT2(0x22e) EMIT2(0x230)\n\t\t    EMIT2(0x1e4c) EMIT2(0x1e4e) EMIT2(0x1e50)\n\t\t    EMIT2(0x1e52) EMIT2(0x1ecc) EMIT2(0x1ece)\n\t\t    EMIT2(0x1ed0) EMIT2(0x1ed2) EMIT2(0x1ed4)\n\t\t    EMIT2(0x1ed6) EMIT2(0x1ed8) EMIT2(0x1eda)\n\t\t    EMIT2(0x1edc) EMIT2(0x1ede) EMIT2(0x1ee0)\n\t\t    EMIT2(0x1ee2)\n\t\t    return OK;\n\n\t    case 'P': case 0x1a4: case 0x1e54: case 0x1e56: case 0x2c63:\n\t\t    EMIT2('P') EMIT2(0x1a4) EMIT2(0x1e54) EMIT2(0x1e56)\n\t\t    EMIT2(0x2c63)\n\t\t    return OK;\n\n\t    case 'Q': case 0x24a:\n\t\t    EMIT2('Q') EMIT2(0x24a)\n\t\t    return OK;\n\n\t    case 'R': case 0x154: case 0x156: case 0x158: case 0x210:\n\t    case 0x212: case 0x24c: case 0x1e58: case 0x1e5a:\n\t    case 0x1e5c: case 0x1e5e: case 0x2c64: case 0xa7a6:\n\t\t    EMIT2('R') EMIT2(0x154) EMIT2(0x156) EMIT2(0x158)\n\t\t    EMIT2(0x210) EMIT2(0x212) EMIT2(0x24c) EMIT2(0x1e58)\n\t\t    EMIT2(0x1e5a) EMIT2(0x1e5c) EMIT2(0x1e5e) EMIT2(0x2c64)\n\t\t    EMIT2(0xa7a6)\n\t\t    return OK;\n\n\t    case 'S': case 0x15a: case 0x15c: case 0x15e: case 0x160:\n\t    case 0x218: case 0x1e60: case 0x1e62: case 0x1e64:\n\t    case 0x1e66: case 0x1e68: case 0x2c7e: case 0xa7a8:\n\t\t    EMIT2('S') EMIT2(0x15a) EMIT2(0x15c) EMIT2(0x15e)\n\t\t    EMIT2(0x160) EMIT2(0x218) EMIT2(0x1e60) EMIT2(0x1e62)\n\t\t    EMIT2(0x1e64) EMIT2(0x1e66) EMIT2(0x1e68) EMIT2(0x2c7e)\n\t\t    EMIT2(0xa7a8)\n\t\t    return OK;\n\n\t    case 'T': case 0x162: case 0x164: case 0x166: case 0x1ac:\n\t    case 0x1ae: case 0x21a: case 0x23e: case 0x1e6a: case 0x1e6c:\n\t    case 0x1e6e: case 0x1e70:\n\t\t    EMIT2('T') EMIT2(0x162) EMIT2(0x164) EMIT2(0x166)\n\t\t    EMIT2(0x1ac) EMIT2(0x1ae) EMIT2(0x23e) EMIT2(0x21a)\n\t\t    EMIT2(0x1e6a) EMIT2(0x1e6c) EMIT2(0x1e6e) EMIT2(0x1e70)\n\t\t    return OK;\n\n\t    case 'U': case U_grave: case U_acute: case U_diaeresis:\n\t    case U_circumflex: case 0x168: case 0x16a: case 0x16c:\n\t    case 0x16e: case 0x170: case 0x172: case 0x1af:\n\t    case 0x1d3: case 0x1d5: case 0x1d7: case 0x1d9:\n\t    case 0x1db: case 0x214: case 0x216: case 0x244:\n\t    case 0x1e72: case 0x1e74: case 0x1e76: case 0x1e78:\n\t    case 0x1e7a: case 0x1ee4: case 0x1ee6: case 0x1ee8:\n\t    case 0x1eea: case 0x1eec: case 0x1eee: case 0x1ef0:\n\t\t    EMIT2('U') EMIT2(U_grave) EMIT2(U_acute)\n\t\t    EMIT2(U_diaeresis) EMIT2(U_circumflex)\n\t\t    EMIT2(0x168) EMIT2(0x16a)\n\t\t    EMIT2(0x16c) EMIT2(0x16e) EMIT2(0x170)\n\t\t    EMIT2(0x172) EMIT2(0x1af) EMIT2(0x1d3)\n\t\t    EMIT2(0x1d5) EMIT2(0x1d7) EMIT2(0x1d9)\n\t\t    EMIT2(0x1db) EMIT2(0x214) EMIT2(0x216)\n\t\t    EMIT2(0x244) EMIT2(0x1e72) EMIT2(0x1e74)\n\t\t    EMIT2(0x1e76) EMIT2(0x1e78) EMIT2(0x1e7a)\n\t\t    EMIT2(0x1ee4) EMIT2(0x1ee6) EMIT2(0x1ee8)\n\t\t    EMIT2(0x1eea) EMIT2(0x1eec) EMIT2(0x1eee)\n\t\t    EMIT2(0x1ef0)\n\t\t    return OK;\n\n\t    case 'V': case 0x1b2: case 0x1e7c: case 0x1e7e:\n\t\t    EMIT2('V') EMIT2(0x1b2) EMIT2(0x1e7c) EMIT2(0x1e7e)\n\t\t    return OK;\n\n\t    case 'W': case 0x174: case 0x1e80: case 0x1e82: case 0x1e84:\n\t    case 0x1e86: case 0x1e88:\n\t\t    EMIT2('W') EMIT2(0x174) EMIT2(0x1e80) EMIT2(0x1e82)\n\t\t    EMIT2(0x1e84) EMIT2(0x1e86) EMIT2(0x1e88)\n\t\t    return OK;\n\n\t    case 'X': case 0x1e8a: case 0x1e8c:\n\t\t    EMIT2('X') EMIT2(0x1e8a) EMIT2(0x1e8c)\n\t\t    return OK;\n\n\t    case 'Y': case Y_acute: case 0x176: case 0x178:\n\t    case 0x1b3: case 0x232: case 0x24e: case 0x1e8e:\n\t    case 0x1ef2: case 0x1ef4: case 0x1ef6: case 0x1ef8:\n\t\t    EMIT2('Y') EMIT2(Y_acute)\n\t\t    EMIT2(0x176) EMIT2(0x178) EMIT2(0x1b3)\n\t\t    EMIT2(0x232) EMIT2(0x24e) EMIT2(0x1e8e)\n\t\t    EMIT2(0x1ef2) EMIT2(0x1ef4) EMIT2(0x1ef6)\n\t\t    EMIT2(0x1ef8)\n\t\t    return OK;\n\n\t    case 'Z': case 0x179: case 0x17b: case 0x17d:\n\t    case 0x1b5: case 0x1e90: case 0x1e92: case 0x1e94:\n\t    case 0x2c6b:\n\t\t    EMIT2('Z') EMIT2(0x179) EMIT2(0x17b) EMIT2(0x17d)\n\t\t    EMIT2(0x1b5) EMIT2(0x1e90) EMIT2(0x1e92)\n\t\t    EMIT2(0x1e94) EMIT2(0x2c6b)\n\t\t    return OK;\n\n\t    case 'a': case a_grave: case a_acute: case a_circumflex:\n\t    case a_virguilla: case a_diaeresis: case a_ring:\n\t    case 0x101: case 0x103: case 0x105: case 0x1ce:\n\t    case 0x1df: case 0x1e1: case 0x1fb: case 0x201:\n\t    case 0x203: case 0x227: case 0x1d8f: case 0x1e01:\n\t    case 0x1e9a: case 0x1ea1: case 0x1ea3: case 0x1ea5:\n\t    case 0x1ea7: case 0x1ea9: case 0x1eab: case 0x1ead:\n\t    case 0x1eaf: case 0x1eb1: case 0x1eb3: case 0x1eb5:\n\t    case 0x1eb7: case 0x2c65:\n\t\t    EMIT2('a') EMIT2(a_grave) EMIT2(a_acute)\n\t\t    EMIT2(a_circumflex) EMIT2(a_virguilla)\n\t\t    EMIT2(a_diaeresis) EMIT2(a_ring)\n\t\t    EMIT2(0x101) EMIT2(0x103) EMIT2(0x105)\n\t\t    EMIT2(0x1ce) EMIT2(0x1df) EMIT2(0x1e1)\n\t\t    EMIT2(0x1fb) EMIT2(0x201) EMIT2(0x203)\n\t\t    EMIT2(0x227) EMIT2(0x1d8f) EMIT2(0x1e01)\n\t\t    EMIT2(0x1e9a) EMIT2(0x1ea1) EMIT2(0x1ea3)\n\t\t    EMIT2(0x1ea5) EMIT2(0x1ea7) EMIT2(0x1ea9)\n\t\t    EMIT2(0x1eab) EMIT2(0x1ead) EMIT2(0x1eaf)\n\t\t    EMIT2(0x1eb1) EMIT2(0x1eb3) EMIT2(0x1eb5)\n\t\t    EMIT2(0x1eb7) EMIT2(0x2c65)\n\t\t    return OK;\n\n\t    case 'b': case 0x180: case 0x253: case 0x1d6c: case 0x1d80:\n\t    case 0x1e03: case 0x1e05: case 0x1e07:\n\t\t    EMIT2('b') EMIT2(0x180) EMIT2(0x253) EMIT2(0x1d6c)\n\t\t    EMIT2(0x1d80) EMIT2(0x1e03) EMIT2(0x1e05) EMIT2(0x1e07)\n\t\t    return OK;\n\n\t    case 'c': case c_cedilla: case 0x107: case 0x109: case 0x10b:\n\t    case 0x10d: case 0x188: case 0x23c: case 0x1e09: case 0xa793:\n\t    case 0xa794:\n\t\t    EMIT2('c') EMIT2(c_cedilla)\n\t\t    EMIT2(0x107) EMIT2(0x109) EMIT2(0x10b)\n\t\t    EMIT2(0x10d) EMIT2(0x188) EMIT2(0x23c)\n\t\t    EMIT2(0x1e09) EMIT2(0xa793) EMIT2(0xa794)\n\t\t    return OK;\n\n\t    case 'd': case 0x10f: case 0x111: case 0x257: case 0x1d6d:\n\t    case 0x1d81: case 0x1d91: case 0x1e0b: case 0x1e0d: case 0x1e0f:\n\t    case 0x1e11: case 0x1e13:\n\t\t    EMIT2('d') EMIT2(0x10f) EMIT2(0x111)\n\t\t    EMIT2(0x257) EMIT2(0x1d6d) EMIT2(0x1d81)\n\t\t    EMIT2(0x1d91) EMIT2(0x1e0b) EMIT2(0x1e0d)\n\t\t    EMIT2(0x1e0f) EMIT2(0x1e11) EMIT2(0x1e13)\n\t\t    return OK;\n\n\t    case 'e': case e_grave: case e_acute: case e_circumflex:\n\t    case e_diaeresis: case 0x113: case 0x115: case 0x117:\n\t    case 0x119: case 0x11b: case 0x205: case 0x207:\n\t    case 0x229: case 0x247: case 0x1d92: case 0x1e15:\n\t    case 0x1e17: case 0x1e19: case 0x1e1b: case 0x1e1d:\n\t    case 0x1eb9: case 0x1ebb: case 0x1ebd: case 0x1ebf:\n\t    case 0x1ec1: case 0x1ec3: case 0x1ec5: case 0x1ec7:\n\t\t    EMIT2('e') EMIT2(e_grave) EMIT2(e_acute)\n\t\t    EMIT2(e_circumflex) EMIT2(e_diaeresis)\n\t\t    EMIT2(0x113) EMIT2(0x115)\n\t\t    EMIT2(0x117) EMIT2(0x119) EMIT2(0x11b)\n\t\t    EMIT2(0x205) EMIT2(0x207) EMIT2(0x229)\n\t\t    EMIT2(0x247) EMIT2(0x1d92) EMIT2(0x1e15)\n\t\t    EMIT2(0x1e17) EMIT2(0x1e19) EMIT2(0x1e1b)\n\t\t    EMIT2(0x1e1d) EMIT2(0x1eb9) EMIT2(0x1ebb)\n\t\t    EMIT2(0x1ebd) EMIT2(0x1ebf) EMIT2(0x1ec1)\n\t\t    EMIT2(0x1ec3) EMIT2(0x1ec5) EMIT2(0x1ec7)\n\t\t    return OK;\n\n\t    case 'f': case 0x192: case 0x1d6e: case 0x1d82:\n\t    case 0x1e1f: case 0xa799:\n\t\t    EMIT2('f') EMIT2(0x192) EMIT2(0x1d6e) EMIT2(0x1d82)\n\t\t    EMIT2(0x1e1f) EMIT2(0xa799)\n\t\t    return OK;\n\n\t    case 'g': case 0x11d: case 0x11f: case 0x121: case 0x123:\n\t    case 0x1e5: case 0x1e7: case 0x1f5: case 0x260: case 0x1d83:\n\t    case 0x1e21: case 0xa7a1:\n\t\t    EMIT2('g') EMIT2(0x11d) EMIT2(0x11f) EMIT2(0x121)\n\t\t    EMIT2(0x123) EMIT2(0x1e5) EMIT2(0x1e7)\n\t\t    EMIT2(0x1f5) EMIT2(0x260) EMIT2(0x1d83)\n\t\t    EMIT2(0x1e21) EMIT2(0xa7a1)\n\t\t    return OK;\n\n\t    case 'h': case 0x125: case 0x127: case 0x21f: case 0x1e23:\n\t    case 0x1e25: case 0x1e27: case 0x1e29: case 0x1e2b:\n\t    case 0x1e96: case 0x2c68: case 0xa795:\n\t\t    EMIT2('h') EMIT2(0x125) EMIT2(0x127) EMIT2(0x21f)\n\t\t    EMIT2(0x1e23) EMIT2(0x1e25) EMIT2(0x1e27)\n\t\t    EMIT2(0x1e29) EMIT2(0x1e2b) EMIT2(0x1e96)\n\t\t    EMIT2(0x2c68) EMIT2(0xa795)\n\t\t    return OK;\n\n\t    case 'i': case i_grave: case i_acute: case i_circumflex:\n\t    case i_diaeresis: case 0x129: case 0x12b: case 0x12d:\n\t    case 0x12f: case 0x1d0: case 0x209: case 0x20b:\n\t    case 0x268: case 0x1d96: case 0x1e2d: case 0x1e2f:\n\t    case 0x1ec9: case 0x1ecb:\n\t\t    EMIT2('i') EMIT2(i_grave) EMIT2(i_acute)\n\t\t    EMIT2(i_circumflex) EMIT2(i_diaeresis)\n\t\t    EMIT2(0x129) EMIT2(0x12b) EMIT2(0x12d)\n\t\t    EMIT2(0x12f) EMIT2(0x1d0) EMIT2(0x209)\n\t\t    EMIT2(0x20b) EMIT2(0x268) EMIT2(0x1d96)\n\t\t    EMIT2(0x1e2d) EMIT2(0x1e2f) EMIT2(0x1ec9)\n\t\t    EMIT2(0x1ecb) EMIT2(0x1ecb)\n\t\t    return OK;\n\n\t    case 'j': case 0x135: case 0x1f0: case 0x249:\n\t\t    EMIT2('j') EMIT2(0x135) EMIT2(0x1f0) EMIT2(0x249)\n\t\t    return OK;\n\n\t    case 'k': case 0x137: case 0x199: case 0x1e9: case 0x1d84:\n\t    case 0x1e31: case 0x1e33: case 0x1e35: case 0x2c6a: case 0xa741:\n\t\t    EMIT2('k') EMIT2(0x137) EMIT2(0x199) EMIT2(0x1e9)\n\t\t    EMIT2(0x1d84) EMIT2(0x1e31) EMIT2(0x1e33)\n\t\t    EMIT2(0x1e35) EMIT2(0x2c6a) EMIT2(0xa741)\n\t\t    return OK;\n\n\t    case 'l': case 0x13a: case 0x13c: case 0x13e: case 0x140:\n\t    case 0x142: case 0x19a: case 0x1e37: case 0x1e39: case 0x1e3b:\n\t    case 0x1e3d: case 0x2c61:\n\t\t    EMIT2('l') EMIT2(0x13a) EMIT2(0x13c)\n\t\t    EMIT2(0x13e) EMIT2(0x140) EMIT2(0x142)\n\t\t    EMIT2(0x19a) EMIT2(0x1e37) EMIT2(0x1e39)\n\t\t    EMIT2(0x1e3b) EMIT2(0x1e3d) EMIT2(0x2c61)\n\t\t    return OK;\n\n\t    case 'm': case 0x1d6f: case 0x1e3f: case 0x1e41: case 0x1e43:\n\t\t    EMIT2('m') EMIT2(0x1d6f) EMIT2(0x1e3f)\n\t\t    EMIT2(0x1e41) EMIT2(0x1e43)\n\t\t    return OK;\n\n\t    case 'n': case n_virguilla: case 0x144: case 0x146: case 0x148:\n\t    case 0x149: case 0x1f9: case 0x1d70: case 0x1d87: case 0x1e45:\n\t    case 0x1e47: case 0x1e49: case 0x1e4b: case 0xa7a5:\n\t\t    EMIT2('n') EMIT2(n_virguilla)\n\t\t    EMIT2(0x144) EMIT2(0x146) EMIT2(0x148)\n\t\t    EMIT2(0x149) EMIT2(0x1f9) EMIT2(0x1d70)\n\t\t    EMIT2(0x1d87) EMIT2(0x1e45) EMIT2(0x1e47)\n\t\t    EMIT2(0x1e49) EMIT2(0x1e4b) EMIT2(0xa7a5)\n\t\t    return OK;\n\n\t    case 'o': case o_grave: case o_acute: case o_circumflex:\n\t    case o_virguilla: case o_diaeresis: case o_slash:\n\t    case 0x14d: case 0x14f: case 0x151: case 0x1a1:\n\t    case 0x1d2: case 0x1eb: case 0x1ed: case 0x1ff:\n\t    case 0x20d: case 0x20f: case 0x22b: case 0x22d:\n\t    case 0x22f: case 0x231: case 0x275: case 0x1e4d:\n\t    case 0x1e4f: case 0x1e51: case 0x1e53: case 0x1ecd:\n\t    case 0x1ecf: case 0x1ed1: case 0x1ed3: case 0x1ed5:\n\t    case 0x1ed7: case 0x1ed9: case 0x1edb: case 0x1edd:\n\t    case 0x1edf: case 0x1ee1: case 0x1ee3:\n\t\t    EMIT2('o') EMIT2(o_grave) EMIT2(o_acute)\n\t\t    EMIT2(o_circumflex) EMIT2(o_virguilla)\n\t\t    EMIT2(o_diaeresis) EMIT2(o_slash)\n\t\t    EMIT2(0x14d) EMIT2(0x14f) EMIT2(0x151)\n\t\t    EMIT2(0x1a1) EMIT2(0x1d2) EMIT2(0x1eb)\n\t\t    EMIT2(0x1ed) EMIT2(0x1ff) EMIT2(0x20d)\n\t\t    EMIT2(0x20f) EMIT2(0x22b) EMIT2(0x22d)\n\t\t    EMIT2(0x22f) EMIT2(0x231) EMIT2(0x275)\n\t\t    EMIT2(0x1e4d) EMIT2(0x1e4f) EMIT2(0x1e51)\n\t\t    EMIT2(0x1e53) EMIT2(0x1ecd) EMIT2(0x1ecf)\n\t\t    EMIT2(0x1ed1) EMIT2(0x1ed3) EMIT2(0x1ed5)\n\t\t    EMIT2(0x1ed7) EMIT2(0x1ed9) EMIT2(0x1edb)\n\t\t    EMIT2(0x1edd) EMIT2(0x1edf) EMIT2(0x1ee1)\n\t\t    EMIT2(0x1ee3)\n\t\t    return OK;\n\n\t    case 'p': case 0x1a5: case 0x1d71: case 0x1d7d: case 0x1d88:\n\t    case 0x1e55: case 0x1e57:\n\t\t    EMIT2('p') EMIT2(0x1a5) EMIT2(0x1d71) EMIT2(0x1d7d)\n\t\t    EMIT2(0x1d88) EMIT2(0x1e55) EMIT2(0x1e57)\n\t\t    return OK;\n\n\t    case 'q': case 0x24b: case 0x2a0:\n\t\t    EMIT2('q') EMIT2(0x24b) EMIT2(0x2a0)\n\t\t    return OK;\n\n\t    case 'r': case 0x155: case 0x157: case 0x159: case 0x211:\n\t    case 0x213: case 0x24d: case 0x27d: case 0x1d72: case 0x1d73:\n\t    case 0x1d89: case 0x1e59: case 0x1e5b: case 0x1e5d: case 0x1e5f:\n\t    case 0xa7a7:\n\t\t    EMIT2('r') EMIT2(0x155) EMIT2(0x157) EMIT2(0x159)\n\t\t    EMIT2(0x211) EMIT2(0x213) EMIT2(0x24d) EMIT2(0x27d)\n\t\t    EMIT2(0x1d72) EMIT2(0x1d73) EMIT2(0x1d89) EMIT2(0x1e59)\n\t\t    EMIT2(0x1e5b) EMIT2(0x1e5d) EMIT2(0x1e5f) EMIT2(0xa7a7)\n\t\t    return OK;\n\n\t    case 's': case 0x15b: case 0x15d: case 0x15f: case 0x161:\n\t    case 0x219: case 0x23f: case 0x1d74: case 0x1d8a: case 0x1e61:\n\t    case 0x1e63: case 0x1e65: case 0x1e67: case 0x1e69: case 0xa7a9:\n\t\t    EMIT2('s') EMIT2(0x15b) EMIT2(0x15d) EMIT2(0x15f)\n\t\t    EMIT2(0x161) EMIT2(0x219) EMIT2(0x23f) EMIT2(0x1d74)\n\t\t    EMIT2(0x1d8a) EMIT2(0x1e61) EMIT2(0x1e63) EMIT2(0x1e65)\n\t\t    EMIT2(0x1e67) EMIT2(0x1e69) EMIT2(0xa7a9)\n\t\t    return OK;\n\n\t    case 't': case 0x163: case 0x165: case 0x167: case 0x1ab:\n\t    case 0x1ad: case 0x21b: case 0x288: case 0x1d75: case 0x1e6b:\n\t    case 0x1e6d: case 0x1e6f: case 0x1e71: case 0x1e97: case 0x2c66:\n\t\t    EMIT2('t') EMIT2(0x163) EMIT2(0x165) EMIT2(0x167)\n\t\t    EMIT2(0x1ab) EMIT2(0x1ad) EMIT2(0x21b) EMIT2(0x288)\n\t\t    EMIT2(0x1d75) EMIT2(0x1e6b) EMIT2(0x1e6d) EMIT2(0x1e6f)\n\t\t    EMIT2(0x1e71) EMIT2(0x1e97) EMIT2(0x2c66)\n\t\t    return OK;\n\n\t    case 'u': case u_grave: case u_acute: case u_circumflex:\n\t    case u_diaeresis: case 0x169: case 0x16b: case 0x16d:\n\t    case 0x16f: case 0x171: case 0x173: case 0x1b0: case 0x1d4:\n\t    case 0x1d6: case 0x1d8: case 0x1da: case 0x1dc: case 0x215:\n\t    case 0x217: case 0x289: case 0x1d7e: case 0x1d99: case 0x1e73:\n\t    case 0x1e75: case 0x1e77: case 0x1e79: case 0x1e7b:\n\t    case 0x1ee5: case 0x1ee7: case 0x1ee9: case 0x1eeb:\n\t    case 0x1eed: case 0x1eef: case 0x1ef1:\n\t\t    EMIT2('u') EMIT2(u_grave) EMIT2(u_acute)\n\t\t    EMIT2(u_circumflex) EMIT2(u_diaeresis)\n\t\t    EMIT2(0x169) EMIT2(0x16b)\n\t\t    EMIT2(0x16d) EMIT2(0x16f) EMIT2(0x171)\n\t\t    EMIT2(0x173) EMIT2(0x1d6) EMIT2(0x1d8)\n\t\t    EMIT2(0x215) EMIT2(0x217) EMIT2(0x1b0)\n\t\t    EMIT2(0x1d4) EMIT2(0x1da) EMIT2(0x1dc)\n\t\t    EMIT2(0x289) EMIT2(0x1e73) EMIT2(0x1d7e)\n\t\t    EMIT2(0x1d99) EMIT2(0x1e75) EMIT2(0x1e77)\n\t\t    EMIT2(0x1e79) EMIT2(0x1e7b) EMIT2(0x1ee5)\n\t\t    EMIT2(0x1ee7) EMIT2(0x1ee9) EMIT2(0x1eeb)\n\t\t    EMIT2(0x1eed) EMIT2(0x1eef) EMIT2(0x1ef1)\n\t\t    return OK;\n\n\t    case 'v': case 0x28b: case 0x1d8c: case 0x1e7d: case 0x1e7f:\n\t\t    EMIT2('v') EMIT2(0x28b) EMIT2(0x1d8c) EMIT2(0x1e7d)\n\t\t    EMIT2(0x1e7f)\n\t\t    return OK;\n\n\t    case 'w': case 0x175: case 0x1e81: case 0x1e83: case 0x1e85:\n\t    case 0x1e87: case 0x1e89: case 0x1e98:\n\t\t    EMIT2('w') EMIT2(0x175) EMIT2(0x1e81) EMIT2(0x1e83)\n\t\t    EMIT2(0x1e85) EMIT2(0x1e87) EMIT2(0x1e89) EMIT2(0x1e98)\n\t\t    return OK;\n\n\t    case 'x': case 0x1e8b: case 0x1e8d:\n\t\t    EMIT2('x') EMIT2(0x1e8b) EMIT2(0x1e8d)\n\t\t    return OK;\n\n\t    case 'y': case y_acute: case y_diaeresis: case 0x177:\n\t    case 0x1b4: case 0x233: case 0x24f: case 0x1e8f:\n\t    case 0x1e99: case 0x1ef3: case 0x1ef5: case 0x1ef7:\n\t    case 0x1ef9:\n\t\t    EMIT2('y') EMIT2(y_acute) EMIT2(y_diaeresis)\n\t\t    EMIT2(0x177) EMIT2(0x1b4) EMIT2(0x233) EMIT2(0x24f)\n\t\t    EMIT2(0x1e8f) EMIT2(0x1e99) EMIT2(0x1ef3)\n\t\t    EMIT2(0x1ef5) EMIT2(0x1ef7) EMIT2(0x1ef9)\n\t\t    return OK;\n\n\t    case 'z': case 0x17a: case 0x17c: case 0x17e: case 0x1b6:\n\t    case 0x1d76: case 0x1d8e: case 0x1e91: case 0x1e93:\n\t    case 0x1e95: case 0x2c6c:\n\t\t    EMIT2('z') EMIT2(0x17a) EMIT2(0x17c) EMIT2(0x17e)\n\t\t    EMIT2(0x1b6) EMIT2(0x1d76) EMIT2(0x1d8e) EMIT2(0x1e91)\n\t\t    EMIT2(0x1e93) EMIT2(0x1e95) EMIT2(0x2c6c)\n\t\t    return OK;\n\n\t    \/\/ default: character itself\n\t}\n    }\n\n    EMIT2(c);\n    return OK;\n#undef EMIT2\n#undef EMIT2\n}","target":0,"code_token_length":13650,"total_token_length":13886,"max_tokens_setting":28000}
+{"idx":198512,"func":"mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)\n{\n  \/* mrb_assert(MRB_PROC_CFUNC_P(proc)) *\/\n  const mrb_irep *irep = proc->body.irep;\n  const mrb_pool_value *pool = irep->pool;\n  const mrb_sym *syms = irep->syms;\n  mrb_code insn;\n  int ai = mrb_gc_arena_save(mrb);\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf c_jmp;\n  uint32_t a;\n  uint16_t b;\n  uint16_t c;\n  mrb_sym mid;\n  const struct mrb_irep_catch_handler *ch;\n\n#ifdef DIRECT_THREADED\n  static const void * const optable[] = {\n#define OPCODE(x,_) &&L_OP_ ## x,\n#include \"mruby\/ops.h\"\n#undef OPCODE\n  };\n#endif\n\n  mrb_bool exc_catched = FALSE;\nRETRY_TRY_BLOCK:\n\n  MRB_TRY(&c_jmp) {\n\n  if (exc_catched) {\n    exc_catched = FALSE;\n    mrb_gc_arena_restore(mrb, ai);\n    if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)\n      goto L_BREAK;\n    goto L_RAISE;\n  }\n  mrb->jmp = &c_jmp;\n  mrb_vm_ci_proc_set(mrb->c->ci, proc);\n\n#define regs (mrb->c->ci->stack)\n  INIT_DISPATCH {\n    CASE(OP_NOP, Z) {\n      \/* do nothing *\/\n      NEXT;\n    }\n\n    CASE(OP_MOVE, BB) {\n      regs[a] = regs[b];\n      NEXT;\n    }\n\n    CASE(OP_LOADL, BB) {\n      switch (pool[b].tt) {   \/* number *\/\n      case IREP_TT_INT32:\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);\n        break;\n      case IREP_TT_INT64:\n#if defined(MRB_INT64)\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n        break;\n#else\n#if defined(MRB_64BIT)\n        if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {\n          regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n          break;\n        }\n#endif\n        goto L_INT_OVERFLOW;\n#endif\n      case IREP_TT_BIGINT:\n        goto L_INT_OVERFLOW;\n#ifndef MRB_NO_FLOAT\n      case IREP_TT_FLOAT:\n        regs[a] = mrb_float_value(mrb, pool[b].u.f);\n        break;\n#endif\n      default:\n        \/* should not happen (tt:string) *\/\n        regs[a] = mrb_nil_value();\n        break;\n      }\n      NEXT;\n    }\n\n    CASE(OP_LOADI, BB) {\n      SET_FIXNUM_VALUE(regs[a], b);\n      NEXT;\n    }\n\n    CASE(OP_LOADINEG, BB) {\n      SET_FIXNUM_VALUE(regs[a], -b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI__1,B) goto L_LOADI;\n    CASE(OP_LOADI_0,B) goto L_LOADI;\n    CASE(OP_LOADI_1,B) goto L_LOADI;\n    CASE(OP_LOADI_2,B) goto L_LOADI;\n    CASE(OP_LOADI_3,B) goto L_LOADI;\n    CASE(OP_LOADI_4,B) goto L_LOADI;\n    CASE(OP_LOADI_5,B) goto L_LOADI;\n    CASE(OP_LOADI_6,B) goto L_LOADI;\n    CASE(OP_LOADI_7, B) {\n    L_LOADI:\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);\n      NEXT;\n    }\n\n    CASE(OP_LOADI16, BS) {\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI32, BSS) {\n      SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));\n      NEXT;\n    }\n\n    CASE(OP_LOADSYM, BB) {\n      SET_SYM_VALUE(regs[a], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_LOADNIL, B) {\n      SET_NIL_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADSELF, B) {\n      regs[a] = regs[0];\n      NEXT;\n    }\n\n    CASE(OP_LOADT, B) {\n      SET_TRUE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADF, B) {\n      SET_FALSE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETGV, BB) {\n      mrb_value val = mrb_gv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETGV, BB) {\n      mrb_gv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETSV, BB) {\n      mrb_value val = mrb_vm_special_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETSV, BB) {\n      mrb_vm_special_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIV, BB) {\n      regs[a] = mrb_iv_get(mrb, regs[0], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETIV, BB) {\n      mrb_iv_set(mrb, regs[0], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETCV, BB) {\n      mrb_value val;\n      val = mrb_vm_cv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETCV, BB) {\n      mrb_vm_cv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIDX, B) {\n      mrb_value va = regs[a], vb = regs[a+1];\n      switch (mrb_type(va)) {\n      case MRB_TT_ARRAY:\n        if (!mrb_integer_p(vb)) goto getidx_fallback;\n        regs[a] = mrb_ary_entry(va, mrb_integer(vb));\n        break;\n      case MRB_TT_HASH:\n        va = mrb_hash_get(mrb, va, vb);\n        regs[a] = va;\n        break;\n      case MRB_TT_STRING:\n        switch (mrb_type(vb)) {\n        case MRB_TT_INTEGER:\n        case MRB_TT_STRING:\n        case MRB_TT_RANGE:\n          va = mrb_str_aref(mrb, va, vb, mrb_undef_value());\n          regs[a] = va;\n          break;\n        default:\n          goto getidx_fallback;\n        }\n        break;\n      default:\n      getidx_fallback:\n        mid = MRB_OPSYM(aref);\n        goto L_SEND_SYM;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETIDX, B) {\n      c = 2;\n      mid = MRB_OPSYM(aset);\n      SET_NIL_VALUE(regs[a+3]);\n      goto L_SENDB_SYM;\n    }\n\n    CASE(OP_GETCONST, BB) {\n      mrb_value v = mrb_vm_const_get(mrb, syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETCONST, BB) {\n      mrb_vm_const_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETMCNST, BB) {\n      mrb_value v = mrb_const_get(mrb, regs[a], syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETMCNST, BB) {\n      mrb_const_set(mrb, regs[a+1], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETUPVAR, BBB) {\n      mrb_value *regs_a = regs + a;\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e && b < MRB_ENV_LEN(e)) {\n        *regs_a = e->stack[b];\n      }\n      else {\n        *regs_a = mrb_nil_value();\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETUPVAR, BBB) {\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e) {\n        mrb_value *regs_a = regs + a;\n\n        if (b < MRB_ENV_LEN(e)) {\n          e->stack[b] = *regs_a;\n          mrb_write_barrier(mrb, (struct RBasic*)e);\n        }\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMP, S) {\n      pc += (int16_t)a;\n      JUMP;\n    }\n    CASE(OP_JMPIF, BS) {\n      if (mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNOT, BS) {\n      if (!mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNIL, BS) {\n      if (mrb_nil_p(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMPUW, S) {\n      a = (uint32_t)((pc - irep->iseq) + (int16_t)a);\n      CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {\n        struct RBreak *brk = (struct RBreak*)mrb->exc;\n        mrb_value target = mrb_break_value_get(brk);\n        mrb_assert(mrb_integer_p(target));\n        a = (uint32_t)mrb_integer(target);\n        mrb_assert(a >= 0 && a < irep->ilen);\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {\n        ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);\n        if (ch) {\n          \/* avoiding a jump from a catch handler into the same handler *\/\n          if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {\n            THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));\n          }\n        }\n      }\n      CHECKPOINT_END(RBREAK_TAG_JUMP);\n\n      mrb->exc = NULL; \/* clear break object *\/\n      pc = irep->iseq + a;\n      JUMP;\n    }\n\n    CASE(OP_EXCEPT, B) {\n      mrb_value exc;\n\n      if (mrb->exc == NULL) {\n        exc = mrb_nil_value();\n      }\n      else {\n        switch (mrb->exc->tt) {\n        case MRB_TT_BREAK:\n        case MRB_TT_EXCEPTION:\n          exc = mrb_obj_value(mrb->exc);\n          break;\n        default:\n          mrb_assert(!\"bad mrb_type\");\n          exc = mrb_nil_value();\n          break;\n        }\n        mrb->exc = NULL;\n      }\n      regs[a] = exc;\n      NEXT;\n    }\n    CASE(OP_RESCUE, BB) {\n      mrb_value exc = regs[a];  \/* exc on stack *\/\n      mrb_value e = regs[b];\n      struct RClass *ec;\n\n      switch (mrb_type(e)) {\n      case MRB_TT_CLASS:\n      case MRB_TT_MODULE:\n        break;\n      default:\n        {\n          mrb_value exc;\n\n          exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                    \"class or module required for rescue clause\");\n          mrb_exc_set(mrb, exc);\n          goto L_RAISE;\n        }\n      }\n      ec = mrb_class_ptr(e);\n      regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));\n      NEXT;\n    }\n\n    CASE(OP_RAISEIF, B) {\n      mrb_value exc = regs[a];\n      if (mrb_break_p(exc)) {\n        mrb->exc = mrb_obj_ptr(exc);\n        goto L_BREAK;\n      }\n      mrb_exc_set(mrb, exc);\n      if (mrb->exc) {\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SSEND, BBB) {\n      regs[a] = regs[0];\n      insn = OP_SEND;\n    }\n    goto L_SENDB;\n\n    CASE(OP_SSENDB, BBB) {\n      regs[a] = regs[0];\n    }\n    goto L_SENDB;\n\n    CASE(OP_SEND, BBB)\n    goto L_SENDB;\n\n    L_SEND_SYM:\n    c = 1;\n    \/* push nil after arguments *\/\n    SET_NIL_VALUE(regs[a+2]);\n    goto L_SENDB_SYM;\n\n    CASE(OP_SENDB, BBB)\n    L_SENDB:\n    mid = syms[b];\n    L_SENDB_SYM:\n    {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_value recv, blk;\n\n      ARGUMENT_NORMALIZE(a, &c, insn);\n\n      recv = regs[a];\n      cls = mrb_class(mrb, recv);\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, c);\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        if (MRB_METHOD_PROC_P(m)) {\n          struct RProc *p = MRB_METHOD_PROC(m);\n\n          mrb_vm_ci_proc_set(ci, p);\n          recv = p->body.func(mrb, recv);\n        }\n        else {\n          if (MRB_METHOD_NOARG_P(m)) {\n            check_method_noarg(mrb, ci);\n          }\n          recv = MRB_METHOD_FUNC(m)(mrb, recv);\n        }\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n          if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n        if (!ci->u.target_class) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return recv;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        ci->stack[0] = recv;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n    }\n    JUMP;\n\n    CASE(OP_CALL, Z) {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv = ci->stack[0];\n      struct RProc *m = mrb_proc_ptr(recv);\n\n      \/* replace callinfo *\/\n      ci->u.target_class = MRB_PROC_TARGET_CLASS(m);\n      mrb_vm_ci_proc_set(ci, m);\n      if (MRB_PROC_ENV_P(m)) {\n        ci->mid = MRB_PROC_ENV(m)->mid;\n      }\n\n      \/* prepare stack *\/\n      if (MRB_PROC_CFUNC_P(m)) {\n        recv = MRB_PROC_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n        ci[1].stack[0] = recv;\n        irep = mrb->c->ci->proc->body.irep;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        proc = m;\n        irep = m->body.irep;\n        if (!irep) {\n          mrb->c->ci->stack[0] = mrb_nil_value();\n          a = 0;\n          c = OP_R_NORMAL;\n          goto L_OP_RETURN_BODY;\n        }\n        mrb_int nargs = mrb_ci_bidx(ci)+1;\n        if (nargs < irep->nregs) {\n          mrb_stack_extend(mrb, irep->nregs);\n          stack_clear(regs+nargs, irep->nregs-nargs);\n        }\n        if (MRB_PROC_ENV_P(m)) {\n          regs[0] = MRB_PROC_ENV(m)->stack[0];\n        }\n        pc = irep->iseq;\n      }\n      pool = irep->pool;\n      syms = irep->syms;\n      JUMP;\n    }\n\n    CASE(OP_SUPER, BB) {\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv, blk;\n      const struct RProc *p = ci->proc;\n      mrb_sym mid = ci->mid;\n      struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);\n\n      if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { \/* alias support *\/\n        mid = p->e.env->mid;    \/* restore old mid *\/\n      }\n\n      if (mid == 0 || !target_class) {\n        mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {\n        target_class = mrb_vm_ci_target_class(ci);\n      }\n      else if (target_class->tt == MRB_TT_MODULE) {\n        target_class = mrb_vm_ci_target_class(ci);\n        if (target_class->tt != MRB_TT_ICLASS) {\n          goto super_typeerror;\n        }\n      }\n      recv = regs[0];\n      if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {\n      super_typeerror: ;\n        mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                            \"self has wrong type to call super in this context\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n\n      ARGUMENT_NORMALIZE(a, &b, OP_SUPER);\n\n      cls = target_class->super;\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, b);\n\n      \/* prepare stack *\/\n      ci->stack[0] = recv;\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        mrb_value v;\n\n        if (MRB_METHOD_PROC_P(m)) {\n          mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n        }\n        v = MRB_METHOD_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_restore(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        mrb_assert(!mrb_break_p(v));\n        if (!mrb_vm_ci_target_class(ci)) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return v;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        mrb->c->ci->stack[0] = v;\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n      JUMP;\n    }\n\n    CASE(OP_ARGARY, BS) {\n      mrb_int m1 = (b>>11)&0x3f;\n      mrb_int r  = (b>>10)&0x1;\n      mrb_int m2 = (b>>5)&0x1f;\n      mrb_int kd = (b>>4)&0x1;\n      mrb_int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {\n        mrb_value exc;\n\n      L_NOSUPER:\n        exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e) goto L_NOSUPER;\n        if (MRB_ENV_LEN(e) <= m1+r+m2+1)\n          goto L_NOSUPER;\n        stack = e->stack + 1;\n      }\n      if (r == 0) {\n        regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack);\n      }\n      else {\n        mrb_value *pp = NULL;\n        struct RArray *rest;\n        mrb_int len = 0;\n\n        if (mrb_array_p(stack[m1])) {\n          struct RArray *ary = mrb_ary_ptr(stack[m1]);\n\n          pp = ARY_PTR(ary);\n          len = ARY_LEN(ary);\n        }\n        regs[a] = mrb_ary_new_capa(mrb, m1+len+m2);\n        rest = mrb_ary_ptr(regs[a]);\n        if (m1 > 0) {\n          stack_copy(ARY_PTR(rest), stack, m1);\n        }\n        if (len > 0) {\n          stack_copy(ARY_PTR(rest)+m1, pp, len);\n        }\n        if (m2 > 0) {\n          stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2);\n        }\n        ARY_SET_LEN(rest, m1+len+m2);\n      }\n      if (kd) {\n        regs[a+1] = stack[m1+r+m2];\n        regs[a+2] = stack[m1+r+m2+1];\n      }\n      else {\n        regs[a+1] = stack[m1+r+m2];\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ENTER, W) {\n      mrb_int m1 = MRB_ASPEC_REQ(a);\n      mrb_int o  = MRB_ASPEC_OPT(a);\n      mrb_int r  = MRB_ASPEC_REST(a);\n      mrb_int m2 = MRB_ASPEC_POST(a);\n      mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;\n      \/* unused\n      int b  = MRB_ASPEC_BLOCK(a);\n      *\/\n      mrb_int const len = m1 + o + r + m2;\n\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_int argc = ci->n;\n      mrb_value *argv = regs+1;\n      mrb_value * const argv0 = argv;\n      mrb_int const kw_pos = len + kd;    \/* where kwhash should be *\/\n      mrb_int const blk_pos = kw_pos + 1; \/* where block should be *\/\n      mrb_value blk = regs[mrb_ci_bidx(ci)];\n      mrb_value kdict = mrb_nil_value();\n\n      \/* keyword arguments *\/\n      if (ci->nk > 0) {\n        mrb_int kidx = mrb_ci_kidx(ci);\n        kdict = regs[kidx];\n        if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) {\n          kdict = mrb_nil_value();\n          ci->nk = 0;\n        }\n      }\n      if (!kd && !mrb_nil_p(kdict)) {\n        if (argc < 14) {\n          ci->n++;\n          argc++;    \/* include kdict in normal arguments *\/\n        }\n        else if (argc == 14) {\n          \/* pack arguments and kdict *\/\n          regs[1] = mrb_ary_new_from_values(mrb, argc+1, ®s[1]);\n          argc = ci->n = 15;\n        }\n        else {\/* argc == 15 *\/\n          \/* push kdict to packed arguments *\/\n          mrb_ary_push(mrb, regs[1], regs[2]);\n        }\n        ci->nk = 0;\n      }\n      if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) {\n        kdict = mrb_hash_dup(mrb, kdict);\n      }\n\n      \/* arguments is passed with Array *\/\n      if (argc == 15) {\n        struct RArray *ary = mrb_ary_ptr(regs[1]);\n        argv = ARY_PTR(ary);\n        argc = (int)ARY_LEN(ary);\n        mrb_gc_protect(mrb, regs[1]);\n      }\n\n      \/* strict argument check *\/\n      if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) {\n        if (argc < m1 + m2 || (r == 0 && argc > len)) {\n          argnum_error(mrb, m1+m2);\n          goto L_RAISE;\n        }\n      }\n      \/* extract first argument array to arguments *\/\n      else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) {\n        mrb_gc_protect(mrb, argv[0]);\n        argc = (int)RARRAY_LEN(argv[0]);\n        argv = RARRAY_PTR(argv[0]);\n      }\n\n      \/* rest arguments *\/\n      mrb_value rest = mrb_nil_value();\n      if (argc < len) {\n        mrb_int mlen = m2;\n        if (argc < m1+m2) {\n          mlen = m1 < argc ? argc - m1 : 0;\n        }\n\n        \/* copy mandatory and optional arguments *\/\n        if (argv0 != argv && argv) {\n          value_move(®s[1], argv, argc-mlen); \/* m1 + o *\/\n        }\n        if (argc < m1) {\n          stack_clear(®s[argc+1], m1-argc);\n        }\n        \/* copy post mandatory arguments *\/\n        if (mlen) {\n          value_move(®s[len-m2+1], &argv[argc-mlen], mlen);\n        }\n        if (mlen < m2) {\n          stack_clear(®s[len-m2+mlen+1], m2-mlen);\n        }\n        \/* initialize rest arguments with empty Array *\/\n        if (r) {\n          rest = mrb_ary_new_capa(mrb, 0);\n          regs[m1+o+1] = rest;\n        }\n        \/* skip initializer of passed arguments *\/\n        if (o > 0 && argc > m1+m2)\n          pc += (argc - m1 - m2)*3;\n      }\n      else {\n        mrb_int rnum = 0;\n        if (argv0 != argv) {\n          value_move(®s[1], argv, m1+o);\n        }\n        if (r) {\n          rnum = argc-m1-o-m2;\n          rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o);\n          regs[m1+o+1] = rest;\n        }\n        if (m2 > 0 && argc-m2 > m1) {\n          value_move(®s[m1+o+r+1], &argv[m1+o+rnum], m2);\n        }\n        pc += o*3;\n      }\n\n      \/* need to be update blk first to protect blk from GC *\/\n      regs[blk_pos] = blk;              \/* move block *\/\n      if (kd) {\n        if (mrb_nil_p(kdict))\n          kdict = mrb_hash_new_capa(mrb, 0);\n        regs[kw_pos] = kdict;           \/* set kwhash *\/\n      }\n\n      \/* format arguments for generated code *\/\n      mrb->c->ci->n = len;\n\n      \/* clear local (but non-argument) variables *\/\n      if (irep->nlocals-blk_pos-1 > 0) {\n        stack_clear(®s[blk_pos+1], irep->nlocals-blk_pos-1);\n      }\n      JUMP;\n    }\n\n    CASE(OP_KARG, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict, v;\n\n      if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) {\n        mrb_value str = mrb_format(mrb, \"missing keyword: %v\", k);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      v = mrb_hash_get(mrb, kdict, k);\n      regs[a] = v;\n      mrb_hash_delete_key(mrb, kdict, k);\n      NEXT;\n    }\n\n    CASE(OP_KEY_P, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n      mrb_bool key_p = FALSE;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) {\n        key_p = mrb_hash_key_p(mrb, kdict, k);\n      }\n      regs[a] = mrb_bool_value(key_p);\n      NEXT;\n    }\n\n    CASE(OP_KEYEND, Z) {\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) {\n        mrb_value keys = mrb_hash_keys(mrb, kdict);\n        mrb_value key1 = RARRAY_PTR(keys)[0];\n        mrb_value str = mrb_format(mrb, \"unknown keyword: %v\", key1);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_BREAK, B) {\n      c = OP_R_BREAK;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN_BLK, B) {\n      c = OP_R_RETURN;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN, B)\n    c = OP_R_NORMAL;\n    L_RETURN:\n    {\n      mrb_callinfo *ci;\n\n      ci = mrb->c->ci;\n      if (ci->mid) {\n        mrb_value blk = regs[mrb_ci_bidx(ci)];\n\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n\n          if (!MRB_PROC_STRICT_P(p) &&\n              ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n      }\n\n      if (mrb->exc) {\n      L_RAISE:\n        ci = mrb->c->ci;\n        if (ci == mrb->c->cibase) {\n          ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n          if (ch == NULL) goto L_FTOP;\n          goto L_CATCH;\n        }\n        while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {\n          ci = cipop(mrb);\n          if (ci[1].cci == CINFO_SKIP && prev_jmp) {\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          pc = ci[0].pc;\n          if (ci == mrb->c->cibase) {\n            ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n            if (ch == NULL) {\n            L_FTOP:             \/* fiber top *\/\n              if (mrb->c == mrb->root_c) {\n                mrb->c->ci->stack = mrb->c->stbase;\n                goto L_STOP;\n              }\n              else {\n                struct mrb_context *c = mrb->c;\n\n                c->status = MRB_FIBER_TERMINATED;\n                mrb->c = c->prev;\n                c->prev = NULL;\n                goto L_RAISE;\n              }\n            }\n            break;\n          }\n        }\n      L_CATCH:\n        if (ch == NULL) goto L_STOP;\n        if (FALSE) {\n        L_CATCH_TAGGED_BREAK: \/* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() *\/\n          ci = mrb->c->ci;\n        }\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, irep->nregs);\n        pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);\n      }\n      else {\n        mrb_int acc;\n        mrb_value v;\n\n        ci = mrb->c->ci;\n        v = regs[a];\n        mrb_gc_protect(mrb, v);\n        switch (c) {\n        case OP_R_RETURN:\n          \/* Fall through to OP_R_NORMAL otherwise *\/\n          if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {\n            const struct RProc *dst;\n            mrb_callinfo *cibase;\n            cibase = mrb->c->cibase;\n            dst = top_proc(mrb, proc);\n\n            if (MRB_PROC_ENV_P(dst)) {\n              struct REnv *e = MRB_PROC_ENV(dst);\n\n              if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n            }\n            \/* check jump destination *\/\n            while (cibase <= ci && ci->proc != dst) {\n              if (ci->cci > CINFO_NONE) { \/* jump cross C boundary *\/\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n              ci--;\n            }\n            if (ci <= cibase) { \/* no jump destination *\/\n              localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n              goto L_RAISE;\n            }\n            ci = mrb->c->ci;\n            while (cibase <= ci && ci->proc != dst) {\n              CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {\n                cibase = mrb->c->cibase;\n                dst = top_proc(mrb, proc);\n              }\n              CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {\n                UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);\n              }\n              CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);\n              ci = cipop(mrb);\n              pc = ci->pc;\n            }\n            proc = ci->proc;\n            mrb->exc = NULL; \/* clear break object *\/\n            break;\n          }\n          \/* fallthrough *\/\n        case OP_R_NORMAL:\n        NORMAL_RETURN:\n          if (ci == mrb->c->cibase) {\n            struct mrb_context *c;\n            c = mrb->c;\n\n            if (!c->prev) { \/* toplevel return *\/\n              regs[irep->nlocals] = v;\n              goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);\n            }\n            if (!c->vmexec && c->prev->ci == c->prev->cibase) {\n              mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, \"double resume\");\n              mrb_exc_set(mrb, exc);\n              goto L_RAISE;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {\n              c = mrb->c;\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);\n            \/* automatic yield at the end *\/\n            c->status = MRB_FIBER_TERMINATED;\n            mrb->c = c->prev;\n            mrb->c->status = MRB_FIBER_RUNNING;\n            c->prev = NULL;\n            if (c->vmexec) {\n              mrb_gc_arena_restore(mrb, ai);\n              c->vmexec = FALSE;\n              mrb->jmp = prev_jmp;\n              return v;\n            }\n            ci = mrb->c->ci;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_RETURN);\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        case OP_R_BREAK:\n          if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;\n          if (MRB_PROC_ORPHAN_P(proc)) {\n            mrb_value exc;\n\n          L_BREAK_ERROR:\n            exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,\n                                      \"break from proc-closure\");\n            mrb_exc_set(mrb, exc);\n            goto L_RAISE;\n          }\n          if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {\n            goto L_BREAK_ERROR;\n          }\n          else {\n            struct REnv *e = MRB_PROC_ENV(proc);\n\n            if (e->cxt != mrb->c) {\n              goto L_BREAK_ERROR;\n            }\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK);\n          \/* break from fiber block *\/\n          if (ci == mrb->c->cibase && ci->pc) {\n            struct mrb_context *c = mrb->c;\n\n            mrb->c = c->prev;\n            c->prev = NULL;\n            ci = mrb->c->ci;\n          }\n          if (ci->cci > CINFO_NONE) {\n            ci = cipop(mrb);\n            mrb_gc_arena_restore(mrb, ai);\n            mrb->c->vmexec = FALSE;\n            mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          if (FALSE) {\n            struct RBreak *brk;\n\n          L_BREAK:\n            brk = (struct RBreak*)mrb->exc;\n            proc = mrb_break_proc_get(brk);\n            v = mrb_break_value_get(brk);\n            ci = mrb->c->ci;\n\n            switch (mrb_break_tag_get(brk)) {\n#define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);\n              RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)\n#undef DISPATCH_CHECKPOINTS\n              default:\n                mrb_assert(!\"wrong break tag\");\n            }\n          }\n          while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {\n            if (ci[-1].cci == CINFO_SKIP) {\n              goto L_BREAK_ERROR;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {\n              \/* do nothing *\/\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);\n            ci = cipop(mrb);\n            pc = ci->pc;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);\n          if (ci == mrb->c->cibase) {\n            goto L_BREAK_ERROR;\n          }\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        default:\n          \/* cannot happen *\/\n          break;\n        }\n        mrb_assert(ci == mrb->c->ci);\n        mrb_assert(mrb->exc == NULL);\n\n        if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->c->vmexec = FALSE;\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        acc = ci->cci;\n        ci = cipop(mrb);\n        if (acc == CINFO_SKIP || acc == CINFO_DIRECT) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        pc = ci->pc;\n        DEBUG(fprintf(stderr, \"from :%s\\n\", mrb_sym_name(mrb, ci->mid)));\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n\n        ci[1].stack[0] = v;\n        mrb_gc_arena_restore(mrb, ai);\n      }\n      JUMP;\n    }\n\n    CASE(OP_BLKPUSH, BS) {\n      int m1 = (b>>11)&0x3f;\n      int r  = (b>>10)&0x1;\n      int m2 = (b>>5)&0x1f;\n      int kd = (b>>4)&0x1;\n      int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||\n            MRB_ENV_LEN(e) <= m1+r+m2+1) {\n          localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n          goto L_RAISE;\n        }\n        stack = e->stack + 1;\n      }\n      if (mrb_nil_p(stack[m1+r+m2+kd])) {\n        localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n        goto L_RAISE;\n      }\n      regs[a] = stack[m1+r+m2+kd];\n      NEXT;\n    }\n\n  L_INT_OVERFLOW:\n    {\n      mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, \"integer overflow\");\n      mrb_exc_set(mrb, exc);\n    }\n    goto L_RAISE;\n\n#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))\n#define OP_MATH(op_name)                                                    \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {                  \\\n    OP_MATH_CASE_INTEGER(op_name);                                          \\\n    OP_MATH_CASE_FLOAT(op_name, integer, float);                            \\\n    OP_MATH_CASE_FLOAT(op_name, float,  integer);                           \\\n    OP_MATH_CASE_FLOAT(op_name, float,  float);                             \\\n    OP_MATH_CASE_STRING_##op_name();                                        \\\n    default:                                                                \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATH_CASE_INTEGER(op_name)                                       \\\n  case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER):                              \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z;      \\\n      if (mrb_int_##op_name##_overflow(x, y, &z))                           \\\n        OP_MATH_OVERFLOW_INT();                                             \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0\n#else\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2)                                     \\\n  case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2):                                \\\n    {                                                                           \\\n      mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                         \\\n    }                                                                           \\\n    break\n#endif\n#define OP_MATH_OVERFLOW_INT() goto L_INT_OVERFLOW\n#define OP_MATH_CASE_STRING_add()                                           \\\n  case TYPES2(MRB_TT_STRING, MRB_TT_STRING):                                \\\n    regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]);                        \\\n    mrb_gc_arena_restore(mrb, ai);                                          \\\n    break\n#define OP_MATH_CASE_STRING_sub() (void)0\n#define OP_MATH_CASE_STRING_mul() (void)0\n#define OP_MATH_OP_add +\n#define OP_MATH_OP_sub -\n#define OP_MATH_OP_mul *\n#define OP_MATH_TT_integer MRB_TT_INTEGER\n#define OP_MATH_TT_float   MRB_TT_FLOAT\n\n    CASE(OP_ADD, B) {\n      OP_MATH(add);\n    }\n\n    CASE(OP_SUB, B) {\n      OP_MATH(sub);\n    }\n\n    CASE(OP_MUL, B) {\n      OP_MATH(mul);\n    }\n\n    CASE(OP_DIV, B) {\n#ifndef MRB_NO_FLOAT\n      mrb_float x, y, f;\n#endif\n\n      \/* need to check if op is overridden *\/\n      switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\n        {\n          mrb_int x = mrb_integer(regs[a]);\n          mrb_int y = mrb_integer(regs[a+1]);\n          mrb_int div = mrb_div_int(mrb, x, y);\n          SET_INT_VALUE(mrb, regs[a], div);\n        }\n        NEXT;\n#ifndef MRB_NO_FLOAT\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\n        x = (mrb_float)mrb_integer(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\n        x = mrb_float(regs[a]);\n        y = (mrb_float)mrb_integer(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\n        x = mrb_float(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n#endif\n      default:\n        mid = MRB_OPSYM(div);\n        goto L_SEND_SYM;\n      }\n\n#ifndef MRB_NO_FLOAT\n      f = mrb_div_float(x, y);\n      SET_FLOAT_VALUE(mrb, regs[a], f);\n#endif\n      NEXT;\n    }\n\n#define OP_MATHI(op_name)                                                   \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (mrb_type(regs[a])) {                                              \\\n    OP_MATHI_CASE_INTEGER(op_name);                                         \\\n    OP_MATHI_CASE_FLOAT(op_name);                                           \\\n    default:                                                                \\\n      SET_INT_VALUE(mrb,regs[a+1], b);                                      \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATHI_CASE_INTEGER(op_name)                                      \\\n  case MRB_TT_INTEGER:                                                      \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z;                  \\\n      if (mrb_int_##op_name##_overflow(x, y, &z))                           \\\n        OP_MATH_OVERFLOW_INT();                                             \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATHI_CASE_FLOAT(op_name) (void)0\n#else\n#define OP_MATHI_CASE_FLOAT(op_name)                                        \\\n  case MRB_TT_FLOAT:                                                        \\\n    {                                                                       \\\n      mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b;              \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                     \\\n    }                                                                       \\\n    break\n#endif\n\n    CASE(OP_ADDI, BB) {\n      OP_MATHI(add);\n    }\n\n    CASE(OP_SUBI, BB) {\n      OP_MATHI(sub);\n    }\n\n#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))\n\n#ifdef MRB_NO_FLOAT\n#define OP_CMP(op,sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#else\n#define OP_CMP(op, sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_float);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#endif\n\n    CASE(OP_EQ, B) {\n      if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {\n        SET_TRUE_VALUE(regs[a]);\n      }\n      else {\n        OP_CMP(==,eq);\n      }\n      NEXT;\n    }\n\n    CASE(OP_LT, B) {\n      OP_CMP(<,lt);\n      NEXT;\n    }\n\n    CASE(OP_LE, B) {\n      OP_CMP(<=,le);\n      NEXT;\n    }\n\n    CASE(OP_GT, B) {\n      OP_CMP(>,gt);\n      NEXT;\n    }\n\n    CASE(OP_GE, B) {\n      OP_CMP(>=,ge);\n      NEXT;\n    }\n\n    CASE(OP_ARRAY, BB) {\n      regs[a] = mrb_ary_new_from_values(mrb, b, ®s[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_ARRAY2, BBB) {\n      regs[a] = mrb_ary_new_from_values(mrb, c, ®s[b]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYCAT, B) {\n      mrb_value splat = mrb_ary_splat(mrb, regs[a+1]);\n      if (mrb_nil_p(regs[a])) {\n        regs[a] = splat;\n      }\n      else {\n        mrb_assert(mrb_array_p(regs[a]));\n        mrb_ary_concat(mrb, regs[a], splat);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYPUSH, BB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      for (mrb_int i=0; i<b; i++) {\n        mrb_ary_push(mrb, regs[a], regs[a+i+1]);\n      }\n      NEXT;\n    }\n\n    CASE(OP_ARYDUP, B) {\n      mrb_value ary = regs[a];\n      if (mrb_array_p(ary)) {\n        ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));\n      }\n      else {\n        ary = mrb_ary_new_from_values(mrb, 1, &ary);\n      }\n      regs[a] = ary;\n      NEXT;\n    }\n\n    CASE(OP_AREF, BBB) {\n      mrb_value v = regs[b];\n\n      if (!mrb_array_p(v)) {\n        if (c == 0) {\n          regs[a] = v;\n        }\n        else {\n          SET_NIL_VALUE(regs[a]);\n        }\n      }\n      else {\n        v = mrb_ary_ref(mrb, v, c);\n        regs[a] = v;\n      }\n      NEXT;\n    }\n\n    CASE(OP_ASET, BBB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      mrb_ary_set(mrb, regs[b], c, regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_APOST, BBB) {\n      mrb_value v = regs[a];\n      int pre  = b;\n      int post = c;\n      struct RArray *ary;\n      int len, idx;\n\n      if (!mrb_array_p(v)) {\n        v = mrb_ary_new_from_values(mrb, 1, ®s[a]);\n      }\n      ary = mrb_ary_ptr(v);\n      len = (int)ARY_LEN(ary);\n      if (len > pre + post) {\n        v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre);\n        regs[a++] = v;\n        while (post--) {\n          regs[a++] = ARY_PTR(ary)[len-post-1];\n        }\n      }\n      else {\n        v = mrb_ary_new_capa(mrb, 0);\n        regs[a++] = v;\n        for (idx=0; idx+pre<len; idx++) {\n          regs[a+idx] = ARY_PTR(ary)[pre+idx];\n        }\n        while (idx < post) {\n          SET_NIL_VALUE(regs[a+idx]);\n          idx++;\n        }\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_INTERN, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_sym sym = mrb_intern_str(mrb, regs[a]);\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_SYMBOL, BB) {\n      size_t len;\n      mrb_sym sym;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        sym = mrb_intern_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        sym  = mrb_intern(mrb, pool[b].u.str, len);\n      }\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_STRING, BB) {\n      mrb_int len;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        regs[a] = mrb_str_new(mrb, pool[b].u.str, len);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_STRCAT, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_str_concat(mrb, regs[a], regs[a+1]);\n      NEXT;\n    }\n\n    CASE(OP_HASH, BB) {\n      mrb_value hash = mrb_hash_new_capa(mrb, b);\n      int i;\n      int lim = a+b*2;\n\n      for (i=a; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      regs[a] = hash;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_HASHADD, BB) {\n      mrb_value hash;\n      int i;\n      int lim = a+b*2+1;\n\n      hash = regs[a];\n      mrb_ensure_hash_type(mrb, hash);\n      for (i=a+1; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_HASHCAT, B) {\n      mrb_value hash = regs[a];\n\n      mrb_assert(mrb_hash_p(hash));\n      mrb_hash_merge(mrb, hash, regs[a+1]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_LAMBDA, BB)\n    c = OP_L_LAMBDA;\n    L_MAKE_LAMBDA:\n    {\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      if (c & OP_L_CAPTURE) {\n        p = mrb_closure_new(mrb, nirep);\n      }\n      else {\n        p = mrb_proc_new(mrb, nirep);\n        p->flags |= MRB_PROC_SCOPE;\n      }\n      if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;\n      regs[a] = mrb_obj_value(p);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_BLOCK, BB) {\n      c = OP_L_BLOCK;\n      goto L_MAKE_LAMBDA;\n    }\n    CASE(OP_METHOD, BB) {\n      c = OP_L_METHOD;\n      goto L_MAKE_LAMBDA;\n    }\n\n    CASE(OP_RANGE_INC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_RANGE_EXC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], TRUE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_OCLASS, B) {\n      regs[a] = mrb_obj_value(mrb->object_class);\n      NEXT;\n    }\n\n    CASE(OP_CLASS, BB) {\n      struct RClass *c = 0, *baseclass;\n      mrb_value base, super;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      super = regs[a+1];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      c = mrb_vm_define_class(mrb, base, super, id);\n      regs[a] = mrb_obj_value(c);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_MODULE, BB) {\n      struct RClass *cls = 0, *baseclass;\n      mrb_value base;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      cls = mrb_vm_define_module(mrb, base, id);\n      regs[a] = mrb_obj_value(cls);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_EXEC, BB)\n    {\n      mrb_value recv = regs[a];\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      \/* prepare closure *\/\n      p = mrb_proc_new(mrb, nirep);\n      p->c = NULL;\n      mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc);\n      MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv));\n      p->flags |= MRB_PROC_SCOPE;\n\n      \/* prepare call stack *\/\n      cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0);\n\n      irep = p->body.irep;\n      pool = irep->pool;\n      syms = irep->syms;\n      mrb_stack_extend(mrb, irep->nregs);\n      stack_clear(regs+1, irep->nregs-1);\n      pc = irep->iseq;\n      JUMP;\n    }\n\n    CASE(OP_DEF, BB) {\n      struct RClass *target = mrb_class_ptr(regs[a]);\n      struct RProc *p = mrb_proc_ptr(regs[a+1]);\n      mrb_method_t m;\n      mrb_sym mid = syms[b];\n\n      MRB_METHOD_FROM_PROC(m, p);\n      mrb_define_method_raw(mrb, target, mid, m);\n      mrb_method_added(mrb, target, mid);\n      mrb_gc_arena_restore(mrb, ai);\n      regs[a] = mrb_symbol_value(mid);\n      NEXT;\n    }\n\n    CASE(OP_SCLASS, B) {\n      regs[a] = mrb_singleton_class(mrb, regs[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_TCLASS, B) {\n      struct RClass *target = check_target_class(mrb);\n      if (!target) goto L_RAISE;\n      regs[a] = mrb_obj_value(target);\n      NEXT;\n    }\n\n    CASE(OP_ALIAS, BB) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_alias_method(mrb, target, syms[a], syms[b]);\n      mrb_method_added(mrb, target, syms[a]);\n      NEXT;\n    }\n    CASE(OP_UNDEF, B) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_undef_method_id(mrb, target, syms[a]);\n      NEXT;\n    }\n\n    CASE(OP_DEBUG, Z) {\n      FETCH_BBB();\n#ifdef MRB_USE_DEBUG_HOOK\n      mrb->debug_op_hook(mrb, irep, pc, regs);\n#else\n#ifndef MRB_NO_STDIO\n      printf(\"OP_DEBUG %d %d %d\\n\", a, b, c);\n#else\n      abort();\n#endif\n#endif\n      NEXT;\n    }\n\n    CASE(OP_ERR, B) {\n      size_t len = pool[a].tt >> 2;\n      mrb_value exc;\n\n      mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);\n      exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);\n      mrb_exc_set(mrb, exc);\n      goto L_RAISE;\n    }\n\n    CASE(OP_EXT1, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT2, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT3, Z) {\n      uint8_t insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n\n    CASE(OP_STOP, Z) {\n      \/*        stop VM *\/\n      CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {\n        \/* do nothing *\/\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_STOP) {\n        UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());\n      }\n      CHECKPOINT_END(RBREAK_TAG_STOP);\n    L_STOP:\n      mrb->jmp = prev_jmp;\n      if (mrb->exc) {\n        mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);\n        return mrb_obj_value(mrb->exc);\n      }\n      return regs[irep->nlocals];\n    }\n  }\n  END_DISPATCH;\n#undef regs\n  }\n  MRB_CATCH(&c_jmp) {\n    mrb_callinfo *ci = mrb->c->ci;\n    while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) {\n      ci = cipop(mrb);\n    }\n    exc_catched = TRUE;\n    pc = ci->pc;\n    goto RETRY_TRY_BLOCK;\n  }\n  MRB_END_EXC(&c_jmp);\n}","target":1,"code_token_length":14525,"total_token_length":14761,"max_tokens_setting":28000}
+{"idx":206921,"func":"regmatch(\n    char_u\t*scan,\t\t    \/\/ Current node.\n    proftime_T\t*tm UNUSED,\t    \/\/ timeout limit or NULL\n    int\t\t*timed_out UNUSED)  \/\/ flag set on timeout or NULL\n{\n  char_u\t*next;\t\t\/\/ Next node.\n  int\t\top;\n  int\t\tc;\n  regitem_T\t*rp;\n  int\t\tno;\n  int\t\tstatus;\t\t\/\/ one of the RA_ values:\n#ifdef FEAT_RELTIME\n  int\t\ttm_count = 0;\n#endif\n\n  \/\/ Make \"regstack\" and \"backpos\" empty.  They are allocated and freed in\n  \/\/ bt_regexec_both() to reduce malloc()\/free() calls.\n  regstack.ga_len = 0;\n  backpos.ga_len = 0;\n\n  \/\/ Repeat until \"regstack\" is empty.\n  for (;;)\n  {\n    \/\/ Some patterns may take a long time to match, e.g., \"\\([a-z]\\+\\)\\+Q\".\n    \/\/ Allow interrupting them with CTRL-C.\n    fast_breakcheck();\n\n#ifdef DEBUG\n    if (scan != NULL && regnarrate)\n    {\n\tmch_errmsg((char *)regprop(scan));\n\tmch_errmsg(\"(\\n\");\n    }\n#endif\n\n    \/\/ Repeat for items that can be matched sequentially, without using the\n    \/\/ regstack.\n    for (;;)\n    {\n\tif (got_int || scan == NULL)\n\t{\n\t    status = RA_FAIL;\n\t    break;\n\t}\n#ifdef FEAT_RELTIME\n\t\/\/ Check for timeout once in a 100 times to avoid overhead.\n\tif (tm != NULL && ++tm_count == 100)\n\t{\n\t    tm_count = 0;\n\t    if (profile_passed_limit(tm))\n\t    {\n\t\tif (timed_out != NULL)\n\t\t    *timed_out = TRUE;\n\t\tstatus = RA_FAIL;\n\t\tbreak;\n\t    }\n\t}\n#endif\n\tstatus = RA_CONT;\n\n#ifdef DEBUG\n\tif (regnarrate)\n\t{\n\t    mch_errmsg((char *)regprop(scan));\n\t    mch_errmsg(\"...\\n\");\n# ifdef FEAT_SYN_HL\n\t    if (re_extmatch_in != NULL)\n\t    {\n\t\tint i;\n\n\t\tmch_errmsg(_(\"External submatches:\\n\"));\n\t\tfor (i = 0; i < NSUBEXP; i++)\n\t\t{\n\t\t    mch_errmsg(\"    \\\"\");\n\t\t    if (re_extmatch_in->matches[i] != NULL)\n\t\t\tmch_errmsg((char *)re_extmatch_in->matches[i]);\n\t\t    mch_errmsg(\"\\\"\\n\");\n\t\t}\n\t    }\n# endif\n\t}\n#endif\n\tnext = regnext(scan);\n\n\top = OP(scan);\n\t\/\/ Check for character class with NL added.\n\tif (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI\n\t\t\t     && *rex.input == NUL && rex.lnum <= rex.reg_maxline)\n\t{\n\t    reg_nextline();\n\t}\n\telse if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\\n')\n\t{\n\t    ADVANCE_REGINPUT();\n\t}\n\telse\n\t{\n\t  if (WITH_NL(op))\n\t      op -= ADD_NL;\n\t  if (has_mbyte)\n\t      c = (*mb_ptr2char)(rex.input);\n\t  else\n\t      c = *rex.input;\n\t  switch (op)\n\t  {\n\t  case BOL:\n\t    if (rex.input != rex.line)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case EOL:\n\t    if (c != NUL)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_BOF:\n\t    \/\/ We're not at the beginning of the file when below the first\n\t    \/\/ line where we started, not at the start of the line or we\n\t    \/\/ didn't start at the first line of the buffer.\n\t    if (rex.lnum != 0 || rex.input != rex.line\n\t\t\t\t       || (REG_MULTI && rex.reg_firstlnum > 1))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_EOF:\n\t    if (rex.lnum != rex.reg_maxline || c != NUL)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case CURSOR:\n\t    \/\/ Check if the buffer is in a window and compare the\n\t    \/\/ rex.reg_win->w_cursor position to the match position.\n\t    if (rex.reg_win == NULL\n\t\t    || (rex.lnum + rex.reg_firstlnum\n\t\t\t\t\t\t != rex.reg_win->w_cursor.lnum)\n\t\t    || ((colnr_T)(rex.input - rex.line)\n\t\t\t\t\t\t != rex.reg_win->w_cursor.col))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_MARK:\n\t    \/\/ Compare the mark position to the match position.\n\t    {\n\t\tint\tmark = OPERAND(scan)[0];\n\t\tint\tcmp = OPERAND(scan)[1];\n\t\tpos_T\t*pos;\n\n\t\tpos = getmark_buf(rex.reg_buf, mark, FALSE);\n\t\tif (pos == NULL\t\t     \/\/ mark doesn't exist\n\t\t\t|| pos->lnum <= 0)   \/\/ mark isn't set in reg_buf\n\t\t{\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t\telse\n\t\t{\n\t\t    colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum\n\t\t\t\t\t\t\t  && pos->col == MAXCOL\n\t\t\t\t      ? (colnr_T)STRLEN(reg_getline(\n\t\t\t\t\t\tpos->lnum - rex.reg_firstlnum))\n\t\t\t\t      : pos->col;\n\n\t\t    if ((pos->lnum == rex.lnum + rex.reg_firstlnum\n\t\t\t\t? (pos_col == (colnr_T)(rex.input - rex.line)\n\t\t\t\t    ? (cmp == '<' || cmp == '>')\n\t\t\t\t    : (pos_col < (colnr_T)(rex.input - rex.line)\n\t\t\t\t\t? cmp != '>'\n\t\t\t\t\t: cmp != '<'))\n\t\t\t\t: (pos->lnum < rex.lnum + rex.reg_firstlnum\n\t\t\t\t    ? cmp != '>'\n\t\t\t\t    : cmp != '<')))\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t    }\n\t    break;\n\n\t  case RE_VISUAL:\n\t    if (!reg_match_visual())\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_LNUM:\n\t    if (!REG_MULTI || !re_num_cmp((long_u)(rex.lnum + rex.reg_firstlnum),\n\t\t\t\t\t\t\t\t\tscan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_COL:\n\t    if (!re_num_cmp((long_u)(rex.input - rex.line) + 1, scan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case RE_VCOL:\n\t    if (!re_num_cmp((long_u)win_linetabsize(\n\t\t\t    rex.reg_win == NULL ? curwin : rex.reg_win,\n\t\t\t    rex.line, (colnr_T)(rex.input - rex.line)) + 1, scan))\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case BOW:\t\/\/ \\<word; rex.input points to w\n\t    if (c == NUL)\t\/\/ Can't match at end of line\n\t\tstatus = RA_NOMATCH;\n\t    else if (has_mbyte)\n\t    {\n\t\tint this_class;\n\n\t\t\/\/ Get class of current and previous char (if it exists).\n\t\tthis_class = mb_get_class_buf(rex.input, rex.reg_buf);\n\t\tif (this_class <= 1)\n\t\t    status = RA_NOMATCH;  \/\/ not on a word at all\n\t\telse if (reg_prev_class() == this_class)\n\t\t    status = RA_NOMATCH;  \/\/ previous char is in same word\n\t    }\n\t    else\n\t    {\n\t\tif (!vim_iswordc_buf(c, rex.reg_buf) || (rex.input > rex.line\n\t\t\t\t&& vim_iswordc_buf(rex.input[-1], rex.reg_buf)))\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    break;\n\n\t  case EOW:\t\/\/ word\\>; rex.input points after d\n\t    if (rex.input == rex.line)    \/\/ Can't match at start of line\n\t\tstatus = RA_NOMATCH;\n\t    else if (has_mbyte)\n\t    {\n\t\tint this_class, prev_class;\n\n\t\t\/\/ Get class of current and previous char (if it exists).\n\t\tthis_class = mb_get_class_buf(rex.input, rex.reg_buf);\n\t\tprev_class = reg_prev_class();\n\t\tif (this_class == prev_class\n\t\t\t|| prev_class == 0 || prev_class == 1)\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    else\n\t    {\n\t\tif (!vim_iswordc_buf(rex.input[-1], rex.reg_buf)\n\t\t\t|| (rex.input[0] != NUL\n\t\t\t\t\t   && vim_iswordc_buf(c, rex.reg_buf)))\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    break; \/\/ Matched with EOW\n\n\t  case ANY:\n\t    \/\/ ANY does not match new lines.\n\t    if (c == NUL)\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case IDENT:\n\t    if (!vim_isIDc(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SIDENT:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isIDc(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case KWORD:\n\t    if (!vim_iswordp_buf(rex.input, rex.reg_buf))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SKWORD:\n\t    if (VIM_ISDIGIT(*rex.input)\n\t\t\t\t    || !vim_iswordp_buf(rex.input, rex.reg_buf))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case FNAME:\n\t    if (!vim_isfilec(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SFNAME:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isfilec(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case PRINT:\n\t    if (!vim_isprintc(PTR2CHAR(rex.input)))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case SPRINT:\n\t    if (VIM_ISDIGIT(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input)))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case WHITE:\n\t    if (!VIM_ISWHITE(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NWHITE:\n\t    if (c == NUL || VIM_ISWHITE(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case DIGIT:\n\t    if (!ri_digit(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NDIGIT:\n\t    if (c == NUL || ri_digit(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case HEX:\n\t    if (!ri_hex(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NHEX:\n\t    if (c == NUL || ri_hex(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case OCTAL:\n\t    if (!ri_octal(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NOCTAL:\n\t    if (c == NUL || ri_octal(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case WORD:\n\t    if (!ri_word(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NWORD:\n\t    if (c == NUL || ri_word(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case HEAD:\n\t    if (!ri_head(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NHEAD:\n\t    if (c == NUL || ri_head(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case ALPHA:\n\t    if (!ri_alpha(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NALPHA:\n\t    if (c == NUL || ri_alpha(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case LOWER:\n\t    if (!ri_lower(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NLOWER:\n\t    if (c == NUL || ri_lower(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case UPPER:\n\t    if (!ri_upper(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case NUPPER:\n\t    if (c == NUL || ri_upper(c))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case EXACTLY:\n\t    {\n\t\tint\tlen;\n\t\tchar_u\t*opnd;\n\n\t\topnd = OPERAND(scan);\n\t\t\/\/ Inline the first byte, for speed.\n\t\tif (*opnd != *rex.input\n\t\t\t&& (!rex.reg_ic\n\t\t\t    || (!enc_utf8\n\t\t\t      && MB_TOLOWER(*opnd) != MB_TOLOWER(*rex.input))))\n\t\t    status = RA_NOMATCH;\n\t\telse if (*opnd == NUL)\n\t\t{\n\t\t    \/\/ match empty string always works; happens when \"~\" is\n\t\t    \/\/ empty.\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic))\n\t\t    {\n\t\t\tlen = 1;\t\/\/ matched a single byte above\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Need to match first byte again for multi-byte.\n\t\t\tlen = (int)STRLEN(opnd);\n\t\t\tif (cstrncmp(opnd, rex.input, &len) != 0)\n\t\t\t    status = RA_NOMATCH;\n\t\t    }\n\t\t    \/\/ Check for following composing character, unless %C\n\t\t    \/\/ follows (skips over all composing chars).\n\t\t    if (status != RA_NOMATCH\n\t\t\t    && enc_utf8\n\t\t\t    && UTF_COMPOSINGLIKE(rex.input, rex.input + len)\n\t\t\t    && !rex.reg_icombine\n\t\t\t    && OP(next) != RE_COMPOSING)\n\t\t    {\n\t\t\t\/\/ raaron: This code makes a composing character get\n\t\t\t\/\/ ignored, which is the correct behavior (sometimes)\n\t\t\t\/\/ for voweled Hebrew texts.\n\t\t\tstatus = RA_NOMATCH;\n\t\t    }\n\t\t    if (status != RA_NOMATCH)\n\t\t\trex.input += len;\n\t\t}\n\t    }\n\t    break;\n\n\t  case ANYOF:\n\t  case ANYBUT:\n\t    if (c == NUL)\n\t\tstatus = RA_NOMATCH;\n\t    else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t\tADVANCE_REGINPUT();\n\t    break;\n\n\t  case MULTIBYTECODE:\n\t    if (has_mbyte)\n\t    {\n\t\tint\ti, len;\n\t\tchar_u\t*opnd;\n\t\tint\topndc = 0, inpc;\n\n\t\topnd = OPERAND(scan);\n\t\t\/\/ Safety check (just in case 'encoding' was changed since\n\t\t\/\/ compiling the program).\n\t\tif ((len = (*mb_ptr2len)(opnd)) < 2)\n\t\t{\n\t\t    status = RA_NOMATCH;\n\t\t    break;\n\t\t}\n\t\tif (enc_utf8)\n\t\t    opndc = utf_ptr2char(opnd);\n\t\tif (enc_utf8 && utf_iscomposing(opndc))\n\t\t{\n\t\t    \/\/ When only a composing char is given match at any\n\t\t    \/\/ position where that composing char appears.\n\t\t    status = RA_NOMATCH;\n\t\t    for (i = 0; rex.input[i] != NUL;\n\t\t\t\t\t\ti += utf_ptr2len(rex.input + i))\n\t\t    {\n\t\t\tinpc = utf_ptr2char(rex.input + i);\n\t\t\tif (!utf_iscomposing(inpc))\n\t\t\t{\n\t\t\t    if (i > 0)\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (opndc == inpc)\n\t\t\t{\n\t\t\t    \/\/ Include all following composing chars.\n\t\t\t    len = i + utfc_ptr2len(rex.input + i);\n\t\t\t    status = RA_MATCH;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    for (i = 0; i < len; ++i)\n\t\t\tif (opnd[i] != rex.input[i])\n\t\t\t{\n\t\t\t    status = RA_NOMATCH;\n\t\t\t    break;\n\t\t\t}\n\t\trex.input += len;\n\t    }\n\t    else\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\t  case RE_COMPOSING:\n\t    if (enc_utf8)\n\t    {\n\t\t\/\/ Skip composing characters.\n\t\twhile (utf_iscomposing(utf_ptr2char(rex.input)))\n\t\t    MB_CPTR_ADV(rex.input);\n\t    }\n\t    break;\n\n\t  case NOTHING:\n\t    break;\n\n\t  case BACK:\n\t    {\n\t\tint\t\ti;\n\t\tbackpos_T\t*bp;\n\n\t\t\/\/ When we run into BACK we need to check if we don't keep\n\t\t\/\/ looping without matching any input.  The second and later\n\t\t\/\/ times a BACK is encountered it fails if the input is still\n\t\t\/\/ at the same position as the previous time.\n\t\t\/\/ The positions are stored in \"backpos\" and found by the\n\t\t\/\/ current value of \"scan\", the position in the RE program.\n\t\tbp = (backpos_T *)backpos.ga_data;\n\t\tfor (i = 0; i < backpos.ga_len; ++i)\n\t\t    if (bp[i].bp_scan == scan)\n\t\t\tbreak;\n\t\tif (i == backpos.ga_len)\n\t\t{\n\t\t    \/\/ First time at this BACK, make room to store the pos.\n\t\t    if (ga_grow(&backpos, 1) == FAIL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\t\/\/ get \"ga_data\" again, it may have changed\n\t\t\tbp = (backpos_T *)backpos.ga_data;\n\t\t\tbp[i].bp_scan = scan;\n\t\t\t++backpos.ga_len;\n\t\t    }\n\t\t}\n\t\telse if (reg_save_equal(&bp[i].bp_pos))\n\t\t    \/\/ Still at same position as last time, fail.\n\t\t    status = RA_NOMATCH;\n\n\t\tif (status != RA_FAIL && status != RA_NOMATCH)\n\t\t    reg_save(&bp[i].bp_pos, &backpos);\n\t    }\n\t    break;\n\n\t  case MOPEN + 0:   \/\/ Match start: \\zs\n\t  case MOPEN + 1:   \/\/ \\(\n\t  case MOPEN + 2:\n\t  case MOPEN + 3:\n\t  case MOPEN + 4:\n\t  case MOPEN + 5:\n\t  case MOPEN + 6:\n\t  case MOPEN + 7:\n\t  case MOPEN + 8:\n\t  case MOPEN + 9:\n\t    {\n\t\tno = op - MOPEN;\n\t\tcleanup_subexpr();\n\t\trp = regstack_push(RS_MOPEN, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, &rex.reg_startpos[no],\n\t\t\t\t\t\t\t  &rex.reg_startp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n\n\t  case NOPEN:\t    \/\/ \\%(\n\t  case NCLOSE:\t    \/\/ \\) after \\%(\n\t\tif (regstack_push(RS_NOPEN, scan) == NULL)\n\t\t    status = RA_FAIL;\n\t\t\/\/ We simply continue and handle the result when done.\n\t\tbreak;\n\n#ifdef FEAT_SYN_HL\n\t  case ZOPEN + 1:\n\t  case ZOPEN + 2:\n\t  case ZOPEN + 3:\n\t  case ZOPEN + 4:\n\t  case ZOPEN + 5:\n\t  case ZOPEN + 6:\n\t  case ZOPEN + 7:\n\t  case ZOPEN + 8:\n\t  case ZOPEN + 9:\n\t    {\n\t\tno = op - ZOPEN;\n\t\tcleanup_zsubexpr();\n\t\trp = regstack_push(RS_ZOPEN, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, ®_startzpos[no],\n\t\t\t\t\t\t\t     ®_startzp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case MCLOSE + 0:  \/\/ Match end: \\ze\n\t  case MCLOSE + 1:  \/\/ \\)\n\t  case MCLOSE + 2:\n\t  case MCLOSE + 3:\n\t  case MCLOSE + 4:\n\t  case MCLOSE + 5:\n\t  case MCLOSE + 6:\n\t  case MCLOSE + 7:\n\t  case MCLOSE + 8:\n\t  case MCLOSE + 9:\n\t    {\n\t\tno = op - MCLOSE;\n\t\tcleanup_subexpr();\n\t\trp = regstack_push(RS_MCLOSE, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, &rex.reg_endpos[no],\n\t\t\t\t\t\t\t    &rex.reg_endp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case ZCLOSE + 1:  \/\/ \\) after \\z(\n\t  case ZCLOSE + 2:\n\t  case ZCLOSE + 3:\n\t  case ZCLOSE + 4:\n\t  case ZCLOSE + 5:\n\t  case ZCLOSE + 6:\n\t  case ZCLOSE + 7:\n\t  case ZCLOSE + 8:\n\t  case ZCLOSE + 9:\n\t    {\n\t\tno = op - ZCLOSE;\n\t\tcleanup_zsubexpr();\n\t\trp = regstack_push(RS_ZCLOSE, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    rp->rs_no = no;\n\t\t    save_se(&rp->rs_un.sesave, ®_endzpos[no],\n\t\t\t\t\t\t\t      ®_endzp[no]);\n\t\t    \/\/ We simply continue and handle the result when done.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case BACKREF + 1:\n\t  case BACKREF + 2:\n\t  case BACKREF + 3:\n\t  case BACKREF + 4:\n\t  case BACKREF + 5:\n\t  case BACKREF + 6:\n\t  case BACKREF + 7:\n\t  case BACKREF + 8:\n\t  case BACKREF + 9:\n\t    {\n\t\tint\t\tlen;\n\n\t\tno = op - BACKREF;\n\t\tcleanup_subexpr();\n\t\tif (!REG_MULTI)\t\t\/\/ Single-line regexp\n\t\t{\n\t\t    if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL)\n\t\t    {\n\t\t\t\/\/ Backref was not set: Match an empty string.\n\t\t\tlen = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Compare current input with back-ref in the same\n\t\t\t\/\/ line.\n\t\t\tlen = (int)(rex.reg_endp[no] - rex.reg_startp[no]);\n\t\t\tif (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0)\n\t\t\t    status = RA_NOMATCH;\n\t\t    }\n\t\t}\n\t\telse\t\t\t\t\/\/ Multi-line regexp\n\t\t{\n\t\t    if (rex.reg_startpos[no].lnum < 0\n\t\t\t\t\t\t|| rex.reg_endpos[no].lnum < 0)\n\t\t    {\n\t\t\t\/\/ Backref was not set: Match an empty string.\n\t\t\tlen = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (rex.reg_startpos[no].lnum == rex.lnum\n\t\t\t\t&& rex.reg_endpos[no].lnum == rex.lnum)\n\t\t\t{\n\t\t\t    \/\/ Compare back-ref within the current line.\n\t\t\t    len = rex.reg_endpos[no].col\n\t\t\t\t\t\t    - rex.reg_startpos[no].col;\n\t\t\t    if (cstrncmp(rex.line + rex.reg_startpos[no].col,\n\t\t\t\t\t\t\t  rex.input, &len) != 0)\n\t\t\t\tstatus = RA_NOMATCH;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Messy situation: Need to compare between two\n\t\t\t    \/\/ lines.\n\t\t\t    int r = match_with_backref(\n\t\t\t\t\t    rex.reg_startpos[no].lnum,\n\t\t\t\t\t    rex.reg_startpos[no].col,\n\t\t\t\t\t    rex.reg_endpos[no].lnum,\n\t\t\t\t\t    rex.reg_endpos[no].col,\n\t\t\t\t\t    &len);\n\n\t\t\t    if (r != RA_MATCH)\n\t\t\t\tstatus = r;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t\t\/\/ Matched the backref, skip over it.\n\t\trex.input += len;\n\t    }\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case ZREF + 1:\n\t  case ZREF + 2:\n\t  case ZREF + 3:\n\t  case ZREF + 4:\n\t  case ZREF + 5:\n\t  case ZREF + 6:\n\t  case ZREF + 7:\n\t  case ZREF + 8:\n\t  case ZREF + 9:\n\t    {\n\t\tint\tlen;\n\n\t\tcleanup_zsubexpr();\n\t\tno = op - ZREF;\n\t\tif (re_extmatch_in != NULL\n\t\t\t&& re_extmatch_in->matches[no] != NULL)\n\t\t{\n\t\t    len = (int)STRLEN(re_extmatch_in->matches[no]);\n\t\t    if (cstrncmp(re_extmatch_in->matches[no],\n\t\t\t\t\t\t\t  rex.input, &len) != 0)\n\t\t\tstatus = RA_NOMATCH;\n\t\t    else\n\t\t\trex.input += len;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Backref was not set: Match an empty string.\n\t\t}\n\t    }\n\t    break;\n#endif\n\n\t  case BRANCH:\n\t    {\n\t\tif (OP(next) != BRANCH) \/\/ No choice.\n\t\t    next = OPERAND(scan);\t\/\/ Avoid recursion.\n\t\telse\n\t\t{\n\t\t    rp = regstack_push(RS_BRANCH, scan);\n\t\t    if (rp == NULL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t\tstatus = RA_BREAK;\t\/\/ rest is below\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_LIMITS:\n\t    {\n\t\tif (OP(next) == BRACE_SIMPLE)\n\t\t{\n\t\t    bl_minval = OPERAND_MIN(scan);\n\t\t    bl_maxval = OPERAND_MAX(scan);\n\t\t}\n\t\telse if (OP(next) >= BRACE_COMPLEX\n\t\t\t&& OP(next) < BRACE_COMPLEX + 10)\n\t\t{\n\t\t    no = OP(next) - BRACE_COMPLEX;\n\t\t    brace_min[no] = OPERAND_MIN(scan);\n\t\t    brace_max[no] = OPERAND_MAX(scan);\n\t\t    brace_count[no] = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    internal_error(\"BRACE_LIMITS\");\n\t\t    status = RA_FAIL;\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_COMPLEX + 0:\n\t  case BRACE_COMPLEX + 1:\n\t  case BRACE_COMPLEX + 2:\n\t  case BRACE_COMPLEX + 3:\n\t  case BRACE_COMPLEX + 4:\n\t  case BRACE_COMPLEX + 5:\n\t  case BRACE_COMPLEX + 6:\n\t  case BRACE_COMPLEX + 7:\n\t  case BRACE_COMPLEX + 8:\n\t  case BRACE_COMPLEX + 9:\n\t    {\n\t\tno = op - BRACE_COMPLEX;\n\t\t++brace_count[no];\n\n\t\t\/\/ If not matched enough times yet, try one more\n\t\tif (brace_count[no] <= (brace_min[no] <= brace_max[no]\n\t\t\t\t\t     ? brace_min[no] : brace_max[no]))\n\t\t{\n\t\t    rp = regstack_push(RS_BRCPLX_MORE, scan);\n\t\t    if (rp == NULL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\trp->rs_no = no;\n\t\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\t\tnext = OPERAND(scan);\n\t\t\t\/\/ We continue and handle the result when done.\n\t\t    }\n\t\t    break;\n\t\t}\n\n\t\t\/\/ If matched enough times, may try matching some more\n\t\tif (brace_min[no] <= brace_max[no])\n\t\t{\n\t\t    \/\/ Range is the normal way around, use longest match\n\t\t    if (brace_count[no] <= brace_max[no])\n\t\t    {\n\t\t\trp = regstack_push(RS_BRCPLX_LONG, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    rp->rs_no = no;\n\t\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t\t    next = OPERAND(scan);\n\t\t\t    \/\/ We continue and handle the result when done.\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Range is backwards, use shortest match first\n\t\t    if (brace_count[no] <= brace_min[no])\n\t\t    {\n\t\t\trp = regstack_push(RS_BRCPLX_SHORT, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t\t    \/\/ We continue and handle the result when done.\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\n\t  case BRACE_SIMPLE:\n\t  case STAR:\n\t  case PLUS:\n\t    {\n\t\tregstar_T\trst;\n\n\t\t\/\/ Lookahead to avoid useless match attempts when we know\n\t\t\/\/ what character comes next.\n\t\tif (OP(next) == EXACTLY)\n\t\t{\n\t\t    rst.nextb = *OPERAND(next);\n\t\t    if (rex.reg_ic)\n\t\t    {\n\t\t\tif (MB_ISUPPER(rst.nextb))\n\t\t\t    rst.nextb_ic = MB_TOLOWER(rst.nextb);\n\t\t\telse\n\t\t\t    rst.nextb_ic = MB_TOUPPER(rst.nextb);\n\t\t    }\n\t\t    else\n\t\t\trst.nextb_ic = rst.nextb;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rst.nextb = NUL;\n\t\t    rst.nextb_ic = NUL;\n\t\t}\n\t\tif (op != BRACE_SIMPLE)\n\t\t{\n\t\t    rst.minval = (op == STAR) ? 0 : 1;\n\t\t    rst.maxval = MAX_LIMIT;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rst.minval = bl_minval;\n\t\t    rst.maxval = bl_maxval;\n\t\t}\n\n\t\t\/\/ When maxval > minval, try matching as much as possible, up\n\t\t\/\/ to maxval.  When maxval < minval, try matching at least the\n\t\t\/\/ minimal number (since the range is backwards, that's also\n\t\t\/\/ maxval!).\n\t\trst.count = regrepeat(OPERAND(scan), rst.maxval);\n\t\tif (got_int)\n\t\t{\n\t\t    status = RA_FAIL;\n\t\t    break;\n\t\t}\n\t\tif (rst.minval <= rst.maxval\n\t\t\t  ? rst.count >= rst.minval : rst.count >= rst.maxval)\n\t\t{\n\t\t    \/\/ It could match.  Prepare for trying to match what\n\t\t    \/\/ follows.  The code is below.  Parameters are stored in\n\t\t    \/\/ a regstar_T on the regstack.\n\t\t    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n\t\t    {\n\t\t\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\t\t\tstatus = RA_FAIL;\n\t\t    }\n\t\t    else if (ga_grow(®stack, sizeof(regstar_T)) == FAIL)\n\t\t\tstatus = RA_FAIL;\n\t\t    else\n\t\t    {\n\t\t\tregstack.ga_len += sizeof(regstar_T);\n\t\t\trp = regstack_push(rst.minval <= rst.maxval\n\t\t\t\t\t? RS_STAR_LONG : RS_STAR_SHORT, scan);\n\t\t\tif (rp == NULL)\n\t\t\t    status = RA_FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    *(((regstar_T *)rp) - 1) = rst;\n\t\t\t    status = RA_BREAK;\t    \/\/ skip the restore bits\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    status = RA_NOMATCH;\n\n\t    }\n\t    break;\n\n\t  case NOMATCH:\n\t  case MATCH:\n\t  case SUBPAT:\n\t    rp = regstack_push(RS_NOMATCH, scan);\n\t    if (rp == NULL)\n\t\tstatus = RA_FAIL;\n\t    else\n\t    {\n\t\trp->rs_no = op;\n\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\tnext = OPERAND(scan);\n\t\t\/\/ We continue and handle the result when done.\n\t    }\n\t    break;\n\n\t  case BEHIND:\n\t  case NOBEHIND:\n\t    \/\/ Need a bit of room to store extra positions.\n\t    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n\t    {\n\t\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\t\tstatus = RA_FAIL;\n\t    }\n\t    else if (ga_grow(®stack, sizeof(regbehind_T)) == FAIL)\n\t\tstatus = RA_FAIL;\n\t    else\n\t    {\n\t\tregstack.ga_len += sizeof(regbehind_T);\n\t\trp = regstack_push(RS_BEHIND1, scan);\n\t\tif (rp == NULL)\n\t\t    status = RA_FAIL;\n\t\telse\n\t\t{\n\t\t    \/\/ Need to save the subexpr to be able to restore them\n\t\t    \/\/ when there is a match but we don't use it.\n\t\t    save_subexpr(((regbehind_T *)rp) - 1);\n\n\t\t    rp->rs_no = op;\n\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t    \/\/ First try if what follows matches.  If it does then we\n\t\t    \/\/ check the behind match by looping.\n\t\t}\n\t    }\n\t    break;\n\n\t  case BHPOS:\n\t    if (REG_MULTI)\n\t    {\n\t\tif (behind_pos.rs_u.pos.col != (colnr_T)(rex.input - rex.line)\n\t\t\t|| behind_pos.rs_u.pos.lnum != rex.lnum)\n\t\t    status = RA_NOMATCH;\n\t    }\n\t    else if (behind_pos.rs_u.ptr != rex.input)\n\t\tstatus = RA_NOMATCH;\n\t    break;\n\n\t  case NEWL:\n\t    if ((c != NUL || !REG_MULTI || rex.lnum > rex.reg_maxline\n\t\t\t     || rex.reg_line_lbr)\n\t\t\t\t\t   && (c != '\\n' || !rex.reg_line_lbr))\n\t\tstatus = RA_NOMATCH;\n\t    else if (rex.reg_line_lbr)\n\t\tADVANCE_REGINPUT();\n\t    else\n\t\treg_nextline();\n\t    break;\n\n\t  case END:\n\t    status = RA_MATCH;\t\/\/ Success!\n\t    break;\n\n\t  default:\n\t    iemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\t    printf(\"Illegal op code %d\\n\", op);\n#endif\n\t    status = RA_FAIL;\n\t    break;\n\t  }\n\t}\n\n\t\/\/ If we can't continue sequentially, break the inner loop.\n\tif (status != RA_CONT)\n\t    break;\n\n\t\/\/ Continue in inner loop, advance to next item.\n\tscan = next;\n\n    } \/\/ end of inner loop\n\n    \/\/ If there is something on the regstack execute the code for the state.\n    \/\/ If the state is popped then loop and use the older state.\n    while (regstack.ga_len > 0 && status != RA_FAIL)\n    {\n\trp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;\n\tswitch (rp->rs_state)\n\t{\n\t  case RS_NOPEN:\n\t    \/\/ Result is passed on as-is, simply pop the state.\n\t    regstack_pop(&scan);\n\t    break;\n\n\t  case RS_MOPEN:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no],\n\t\t\t\t\t\t  &rex.reg_startp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case RS_ZOPEN:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, ®_startzpos[rp->rs_no],\n\t\t\t\t\t\t ®_startzp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n#endif\n\n\t  case RS_MCLOSE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no],\n\t\t\t\t\t\t    &rex.reg_endp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n\n#ifdef FEAT_SYN_HL\n\t  case RS_ZCLOSE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\trestore_se(&rp->rs_un.sesave, ®_endzpos[rp->rs_no],\n\t\t\t\t\t\t   ®_endzp[rp->rs_no]);\n\t    regstack_pop(&scan);\n\t    break;\n#endif\n\n\t  case RS_BRANCH:\n\t    if (status == RA_MATCH)\n\t\t\/\/ this branch matched, use it\n\t\tregstack_pop(&scan);\n\t    else\n\t    {\n\t\tif (status != RA_BREAK)\n\t\t{\n\t\t    \/\/ After a non-matching branch: try next one.\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t    scan = rp->rs_scan;\n\t\t}\n\t\tif (scan == NULL || OP(scan) != BRANCH)\n\t\t{\n\t\t    \/\/ no more branches, didn't find a match\n\t\t    status = RA_NOMATCH;\n\t\t    regstack_pop(&scan);\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Prepare to try a branch.\n\t\t    rp->rs_scan = regnext(scan);\n\t\t    reg_save(&rp->rs_un.regsave, &backpos);\n\t\t    scan = OPERAND(scan);\n\t\t}\n\t    }\n\t    break;\n\n\t  case RS_BRCPLX_MORE:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\t--brace_count[rp->rs_no];\t\/\/ decrement match count\n\t    }\n\t    regstack_pop(&scan);\n\t    break;\n\n\t  case RS_BRCPLX_LONG:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\t\/\/ There was no match, but we did find enough matches.\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\t--brace_count[rp->rs_no];\n\t\t\/\/ continue with the items after \"\\{}\"\n\t\tstatus = RA_CONT;\n\t    }\n\t    regstack_pop(&scan);\n\t    if (status == RA_CONT)\n\t\tscan = regnext(scan);\n\t    break;\n\n\t  case RS_BRCPLX_SHORT:\n\t    \/\/ Pop the state.  Restore pointers when there is no match.\n\t    if (status == RA_NOMATCH)\n\t\t\/\/ There was no match, try to match one more item.\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t    regstack_pop(&scan);\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\tscan = OPERAND(scan);\n\t\tstatus = RA_CONT;\n\t    }\n\t    break;\n\n\t  case RS_NOMATCH:\n\t    \/\/ Pop the state.  If the operand matches for NOMATCH or\n\t    \/\/ doesn't match for MATCH\/SUBPAT, we fail.  Otherwise backup,\n\t    \/\/ except for SUBPAT, and continue with the next item.\n\t    if (status == (rp->rs_no == NOMATCH ? RA_MATCH : RA_NOMATCH))\n\t\tstatus = RA_NOMATCH;\n\t    else\n\t    {\n\t\tstatus = RA_CONT;\n\t\tif (rp->rs_no != SUBPAT)\t\/\/ zero-width\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t    }\n\t    regstack_pop(&scan);\n\t    if (status == RA_CONT)\n\t\tscan = regnext(scan);\n\t    break;\n\n\t  case RS_BEHIND1:\n\t    if (status == RA_NOMATCH)\n\t    {\n\t\tregstack_pop(&scan);\n\t\tregstack.ga_len -= sizeof(regbehind_T);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ The stuff after BEHIND\/NOBEHIND matches.  Now try if\n\t\t\/\/ the behind part does (not) match before the current\n\t\t\/\/ position in the input.  This must be done at every\n\t\t\/\/ position in the input and checking if the match ends at\n\t\t\/\/ the current position.\n\n\t\t\/\/ save the position after the found match for next\n\t\treg_save(&(((regbehind_T *)rp) - 1)->save_after, &backpos);\n\n\t\t\/\/ Start looking for a match with operand at the current\n\t\t\/\/ position.  Go back one character until we find the\n\t\t\/\/ result, hitting the start of the line or the previous\n\t\t\/\/ line (for multi-line matching).\n\t\t\/\/ Set behind_pos to where the match should end, BHPOS\n\t\t\/\/ will match it.  Save the current value.\n\t\t(((regbehind_T *)rp) - 1)->save_behind = behind_pos;\n\t\tbehind_pos = rp->rs_un.regsave;\n\n\t\trp->rs_state = RS_BEHIND2;\n\n\t\treg_restore(&rp->rs_un.regsave, &backpos);\n\t\tscan = OPERAND(rp->rs_scan) + 4;\n\t    }\n\t    break;\n\n\t  case RS_BEHIND2:\n\t    \/\/ Looping for BEHIND \/ NOBEHIND match.\n\t    if (status == RA_MATCH && reg_save_equal(&behind_pos))\n\t    {\n\t\t\/\/ found a match that ends where \"next\" started\n\t\tbehind_pos = (((regbehind_T *)rp) - 1)->save_behind;\n\t\tif (rp->rs_no == BEHIND)\n\t\t    reg_restore(&(((regbehind_T *)rp) - 1)->save_after,\n\t\t\t\t\t\t\t\t    &backpos);\n\t\telse\n\t\t{\n\t\t    \/\/ But we didn't want a match.  Need to restore the\n\t\t    \/\/ subexpr, because what follows matched, so they have\n\t\t    \/\/ been set.\n\t\t    status = RA_NOMATCH;\n\t\t    restore_subexpr(((regbehind_T *)rp) - 1);\n\t\t}\n\t\tregstack_pop(&scan);\n\t\tregstack.ga_len -= sizeof(regbehind_T);\n\t    }\n\t    else\n\t    {\n\t\tlong limit;\n\n\t\t\/\/ No match or a match that doesn't end where we want it: Go\n\t\t\/\/ back one character.  May go to previous line once.\n\t\tno = OK;\n\t\tlimit = OPERAND_MIN(rp->rs_scan);\n\t\tif (REG_MULTI)\n\t\t{\n\t\t    if (limit > 0\n\t\t\t    && ((rp->rs_un.regsave.rs_u.pos.lnum\n\t\t\t\t\t\t    < behind_pos.rs_u.pos.lnum\n\t\t\t\t    ? (colnr_T)STRLEN(rex.line)\n\t\t\t\t    : behind_pos.rs_u.pos.col)\n\t\t\t\t- rp->rs_un.regsave.rs_u.pos.col >= limit))\n\t\t\tno = FAIL;\n\t\t    else if (rp->rs_un.regsave.rs_u.pos.col == 0)\n\t\t    {\n\t\t\tif (rp->rs_un.regsave.rs_u.pos.lnum\n\t\t\t\t\t< behind_pos.rs_u.pos.lnum\n\t\t\t\t|| reg_getline(\n\t\t\t\t\t--rp->rs_un.regsave.rs_u.pos.lnum)\n\t\t\t\t\t\t\t\t  == NULL)\n\t\t\t    no = FAIL;\n\t\t\telse\n\t\t\t{\n\t\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t\t    rp->rs_un.regsave.rs_u.pos.col =\n\t\t\t\t\t\t (colnr_T)STRLEN(rex.line);\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t{\n\t\t\t    char_u *line =\n\t\t\t\t  reg_getline(rp->rs_un.regsave.rs_u.pos.lnum);\n\n\t\t\t    rp->rs_un.regsave.rs_u.pos.col -=\n\t\t\t\t(*mb_head_off)(line, line\n\t\t\t\t    + rp->rs_un.regsave.rs_u.pos.col - 1) + 1;\n\t\t\t}\n\t\t\telse\n\t\t\t    --rp->rs_un.regsave.rs_u.pos.col;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (rp->rs_un.regsave.rs_u.ptr == rex.line)\n\t\t\tno = FAIL;\n\t\t    else\n\t\t    {\n\t\t\tMB_PTR_BACK(rex.line, rp->rs_un.regsave.rs_u.ptr);\n\t\t\tif (limit > 0 && (long)(behind_pos.rs_u.ptr\n\t\t\t\t     - rp->rs_un.regsave.rs_u.ptr) > limit)\n\t\t\t    no = FAIL;\n\t\t    }\n\t\t}\n\t\tif (no == OK)\n\t\t{\n\t\t    \/\/ Advanced, prepare for finding match again.\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\t\t    scan = OPERAND(rp->rs_scan) + 4;\n\t\t    if (status == RA_MATCH)\n\t\t    {\n\t\t\t\/\/ We did match, so subexpr may have been changed,\n\t\t\t\/\/ need to restore them for the next try.\n\t\t\tstatus = RA_NOMATCH;\n\t\t\trestore_subexpr(((regbehind_T *)rp) - 1);\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Can't advance.  For NOBEHIND that's a match.\n\t\t    behind_pos = (((regbehind_T *)rp) - 1)->save_behind;\n\t\t    if (rp->rs_no == NOBEHIND)\n\t\t    {\n\t\t\treg_restore(&(((regbehind_T *)rp) - 1)->save_after,\n\t\t\t\t\t\t\t\t    &backpos);\n\t\t\tstatus = RA_MATCH;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ We do want a proper match.  Need to restore the\n\t\t\t\/\/ subexpr if we had a match, because they may have\n\t\t\t\/\/ been set.\n\t\t\tif (status == RA_MATCH)\n\t\t\t{\n\t\t\t    status = RA_NOMATCH;\n\t\t\t    restore_subexpr(((regbehind_T *)rp) - 1);\n\t\t\t}\n\t\t    }\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regbehind_T);\n\t\t}\n\t    }\n\t    break;\n\n\t  case RS_STAR_LONG:\n\t  case RS_STAR_SHORT:\n\t    {\n\t\tregstar_T\t    *rst = ((regstar_T *)rp) - 1;\n\n\t\tif (status == RA_MATCH)\n\t\t{\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regstar_T);\n\t\t    break;\n\t\t}\n\n\t\t\/\/ Tried once already, restore input pointers.\n\t\tif (status != RA_BREAK)\n\t\t    reg_restore(&rp->rs_un.regsave, &backpos);\n\n\t\t\/\/ Repeat until we found a position where it could match.\n\t\tfor (;;)\n\t\t{\n\t\t    if (status != RA_BREAK)\n\t\t    {\n\t\t\t\/\/ Tried first position already, advance.\n\t\t\tif (rp->rs_state == RS_STAR_LONG)\n\t\t\t{\n\t\t\t    \/\/ Trying for longest match, but couldn't or\n\t\t\t    \/\/ didn't match -- back up one char.\n\t\t\t    if (--rst->count < rst->minval)\n\t\t\t\tbreak;\n\t\t\t    if (rex.input == rex.line)\n\t\t\t    {\n\t\t\t\t\/\/ backup to last char of previous line\n\t\t\t\t--rex.lnum;\n\t\t\t\trex.line = reg_getline(rex.lnum);\n\t\t\t\t\/\/ Just in case regrepeat() didn't count\n\t\t\t\t\/\/ right.\n\t\t\t\tif (rex.line == NULL)\n\t\t\t\t    break;\n\t\t\t\trex.input = rex.line + STRLEN(rex.line);\n\t\t\t\tfast_breakcheck();\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tMB_PTR_BACK(rex.line, rex.input);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Range is backwards, use shortest match first.\n\t\t\t    \/\/ Careful: maxval and minval are exchanged!\n\t\t\t    \/\/ Couldn't or didn't match: try advancing one\n\t\t\t    \/\/ char.\n\t\t\t    if (rst->count == rst->minval\n\t\t\t\t  || regrepeat(OPERAND(rp->rs_scan), 1L) == 0)\n\t\t\t\tbreak;\n\t\t\t    ++rst->count;\n\t\t\t}\n\t\t\tif (got_int)\n\t\t\t    break;\n\t\t    }\n\t\t    else\n\t\t\tstatus = RA_NOMATCH;\n\n\t\t    \/\/ If it could match, try it.\n\t\t    if (rst->nextb == NUL || *rex.input == rst->nextb\n\t\t\t\t\t     || *rex.input == rst->nextb_ic)\n\t\t    {\n\t\t\treg_save(&rp->rs_un.regsave, &backpos);\n\t\t\tscan = regnext(rp->rs_scan);\n\t\t\tstatus = RA_CONT;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t\tif (status != RA_CONT)\n\t\t{\n\t\t    \/\/ Failed.\n\t\t    regstack_pop(&scan);\n\t\t    regstack.ga_len -= sizeof(regstar_T);\n\t\t    status = RA_NOMATCH;\n\t\t}\n\t    }\n\t    break;\n\t}\n\n\t\/\/ If we want to continue the inner loop or didn't pop a state\n\t\/\/ continue matching loop\n\tif (status == RA_CONT || rp == (regitem_T *)\n\t\t\t     ((char *)regstack.ga_data + regstack.ga_len) - 1)\n\t    break;\n    }\n\n    \/\/ May need to continue with the inner loop, starting at \"scan\".\n    if (status == RA_CONT)\n\tcontinue;\n\n    \/\/ If the regstack is empty or something failed we are done.\n    if (regstack.ga_len == 0 || status == RA_FAIL)\n    {\n\tif (scan == NULL)\n\t{\n\t    \/\/ We get here only if there's trouble -- normally \"case END\" is\n\t    \/\/ the terminating point.\n\t    iemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\t    printf(\"Premature EOL\\n\");\n#endif\n\t}\n\treturn (status == RA_MATCH);\n    }\n\n  } \/\/ End of loop until the regstack is empty.\n\n  \/\/ NOTREACHED\n}","target":1,"code_token_length":10863,"total_token_length":11099,"max_tokens_setting":28000}
+{"idx":214997,"func":"compileRule(FileInfo *file, TranslationTableHeader **table,\n\t\tDisplayTableHeader **displayTable, const MacroList **inScopeMacros) {\n\tCharsString token;\n\tTranslationTableOpcode opcode;\n\tCharsString ruleChars;\n\tCharsString ruleDots;\n\tCharsString cells;\n\tCharsString scratchPad;\n\tCharsString emphClass;\n\tTranslationTableCharacterAttributes after = 0;\n\tTranslationTableCharacterAttributes before = 0;\n\tint noback, nofor, nocross;\n\tnoback = nofor = nocross = 0;\ndoOpcode:\n\tif (!getToken(file, &token, NULL)) return 1;\t\t\t\t  \/* blank line *\/\n\tif (token.chars[0] == '#' || token.chars[0] == '<') return 1; \/* comment *\/\n\tif (file->lineNumber == 1 &&\n\t\t\t(eqasc2uni((unsigned char *)\"ISO\", token.chars, 3) ||\n\t\t\t\t\teqasc2uni((unsigned char *)\"UTF-8\", token.chars, 5))) {\n\t\tif (table)\n\t\t\tcompileHyphenation(file, &token, table);\n\t\telse\n\t\t\t\/* ignore the whole file *\/\n\t\t\twhile (_lou_getALine(file))\n\t\t\t\t;\n\t\treturn 1;\n\t}\n\topcode = getOpcode(file, &token);\n\tswitch (opcode) {\n\tcase CTO_Macro: {\n\t\tconst Macro *macro;\n#ifdef ENABLE_MACROS\n\t\tif (!inScopeMacros) {\n\t\t\tcompileError(file, \"Defining macros only allowed in table files.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (compileMacro(file, ¯o)) {\n\t\t\t*inScopeMacros = cons_macro(macro, *inScopeMacros);\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n#else\n\t\tcompileError(file, \"Macro feature is disabled.\");\n\t\treturn 0;\n#endif\n\t}\n\tcase CTO_IncludeFile: {\n\t\tCharsString includedFile;\n\t\tif (!getToken(file, &token, \"include file name\")) return 0;\n\t\tif (!parseChars(file, &includedFile, &token)) return 0;\n\t\treturn includeFile(file, &includedFile, table, displayTable);\n\t}\n\tcase CTO_NoBack:\n\t\tif (nofor) {\n\t\t\tcompileError(file, \"%s already specified.\", _lou_findOpcodeName(CTO_NoFor));\n\t\t\treturn 0;\n\t\t}\n\t\tnoback = 1;\n\t\tgoto doOpcode;\n\tcase CTO_NoFor:\n\t\tif (noback) {\n\t\t\tcompileError(file, \"%s already specified.\", _lou_findOpcodeName(CTO_NoBack));\n\t\t\treturn 0;\n\t\t}\n\t\tnofor = 1;\n\t\tgoto doOpcode;\n\tcase CTO_Space:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Space, noback, nofor, table, displayTable);\n\tcase CTO_Digit:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Digit, noback, nofor, table, displayTable);\n\tcase CTO_LitDigit:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_LitDigit, noback, nofor, table, displayTable);\n\tcase CTO_Punctuation:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Punctuation, noback, nofor, table, displayTable);\n\tcase CTO_Math:\n\t\treturn compileCharDef(file, opcode, CTC_Math, noback, nofor, table, displayTable);\n\tcase CTO_Sign:\n\t\treturn compileCharDef(file, opcode, CTC_Sign, noback, nofor, table, displayTable);\n\tcase CTO_Letter:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Letter, noback, nofor, table, displayTable);\n\tcase CTO_UpperCase:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_UpperCase, noback, nofor, table, displayTable);\n\tcase CTO_LowerCase:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_LowerCase, noback, nofor, table, displayTable);\n\tcase CTO_Grouping:\n\t\treturn compileGrouping(file, noback, nofor, table, displayTable);\n\tcase CTO_Display:\n\t\tif (!displayTable) return 1;  \/\/ ignore\n\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\tif (ruleChars.length != 1 || ruleDots.length != 1) {\n\t\t\tcompileError(file, \"Exactly one character and one cell are required.\");\n\t\t\treturn 0;\n\t\t}\n\t\treturn putCharDotsMapping(\n\t\t\t\tfile, ruleChars.chars[0], ruleDots.chars[0], displayTable);\n\tcase CTO_UpLow:\n\tcase CTO_None: {\n\t\t\/\/ check if token is a macro name\n\t\tif (inScopeMacros) {\n\t\t\tconst MacroList *macros = *inScopeMacros;\n\t\t\twhile (macros) {\n\t\t\t\tconst Macro *m = macros->head;\n\t\t\t\tif (token.length == strlen(m->name) &&\n\t\t\t\t\t\teqasc2uni((unsigned char *)m->name, token.chars, token.length)) {\n\t\t\t\t\tif (!inScopeMacros) {\n\t\t\t\t\t\tcompileError(file, \"Calling macros only allowed in table files.\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tFileInfo tmpFile;\n\t\t\t\t\tmemset(&tmpFile, 0, sizeof(tmpFile));\n\t\t\t\t\ttmpFile.fileName = file->fileName;\n\t\t\t\t\ttmpFile.sourceFile = file->sourceFile;\n\t\t\t\t\ttmpFile.lineNumber = file->lineNumber;\n\t\t\t\t\ttmpFile.encoding = noEncoding;\n\t\t\t\t\ttmpFile.status = 0;\n\t\t\t\t\ttmpFile.linepos = 0;\n\t\t\t\t\ttmpFile.linelen = 0;\n\t\t\t\t\tint argument_count = 0;\n\t\t\t\t\tCharsString *arguments =\n\t\t\t\t\t\t\tmalloc(m->argument_count * sizeof(CharsString));\n\t\t\t\t\twhile (argument_count < m->argument_count) {\n\t\t\t\t\t\tif (getToken(file, &token, \"macro argument\"))\n\t\t\t\t\t\t\targuments[argument_count++] = token;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (argument_count < m->argument_count) {\n\t\t\t\t\t\tcompileError(file, \"Expected %d arguments\", m->argument_count);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tint i = 0;\n\t\t\t\t\tint subst = 0;\n\t\t\t\t\tint next = subst < m->substitution_count ? m->substitutions[2 * subst]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t : m->definition_length;\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\twhile (i < next) {\n\t\t\t\t\t\t\twidechar c = m->definition[i++];\n\t\t\t\t\t\t\tif (c == '\\n') {\n\t\t\t\t\t\t\t\tif (!compileRule(&tmpFile, table, displayTable,\n\t\t\t\t\t\t\t\t\t\t\tinScopeMacros)) {\n\t\t\t\t\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\t\t\t\t\"result of macro expansion was: %s\",\n\t\t\t\t\t\t\t\t\t\t\t_lou_showString(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttmpFile.line, tmpFile.linelen, 0));\n\t\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttmpFile.linepos = 0;\n\t\t\t\t\t\t\t\ttmpFile.linelen = 0;\n\t\t\t\t\t\t\t} else if (tmpFile.linelen >= MAXSTRING) {\n\t\t\t\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\t\t\t\"Line exceeds %d characters (post macro \"\n\t\t\t\t\t\t\t\t\t\t\"expansion)\",\n\t\t\t\t\t\t\t\t\t\tMAXSTRING);\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\ttmpFile.line[tmpFile.linelen++] = c;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (subst < m->substitution_count) {\n\t\t\t\t\t\t\tCharsString arg =\n\t\t\t\t\t\t\t\t\targuments[m->substitutions[2 * subst + 1] - 1];\n\t\t\t\t\t\t\tfor (int j = 0; j < arg.length; j++)\n\t\t\t\t\t\t\t\ttmpFile.line[tmpFile.linelen++] = arg.chars[j];\n\t\t\t\t\t\t\tsubst++;\n\t\t\t\t\t\t\tnext = subst < m->substitution_count\n\t\t\t\t\t\t\t\t\t? m->substitutions[2 * subst]\n\t\t\t\t\t\t\t\t\t: m->definition_length;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!compileRule(\n\t\t\t\t\t\t\t\t\t\t&tmpFile, table, displayTable, inScopeMacros)) {\n\t\t\t\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\t\t\t\"result of macro expansion was: %s\",\n\t\t\t\t\t\t\t\t\t\t_lou_showString(\n\t\t\t\t\t\t\t\t\t\t\t\ttmpFile.line, tmpFile.linelen, 0));\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tmacros = macros->tail;\n\t\t\t}\n\t\t}\n\t\tif (opcode == CTO_UpLow) {\n\t\t\tcompileError(file, \"The uplow opcode is deprecated.\");\n\t\t\treturn 0;\n\t\t}\n\t\tcompileError(file, \"opcode %s not defined.\",\n\t\t\t\t_lou_showString(token.chars, token.length, 0));\n\t\treturn 0;\n\t}\n\n\t\/* now only opcodes follow that don't modify the display table *\/\n\tdefault:\n\t\tif (!table) return 1;\n\t\tswitch (opcode) {\n\t\tcase CTO_Locale:\n\t\t\tcompileWarning(file,\n\t\t\t\t\t\"The locale opcode is not implemented. Use the locale meta data \"\n\t\t\t\t\t\"instead.\");\n\t\t\treturn 1;\n\t\tcase CTO_Undefined: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->undefined;\n\t\t\tif (!compileBrailleIndicator(file, \"undefined character opcode\",\n\t\t\t\t\t\tCTO_Undefined, &ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->undefined = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_Match: {\n\t\t\tint ok = 0;\n\t\t\twidechar *patterns = NULL;\n\t\t\tTranslationTableRule *rule;\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\tCharsString ptn_before, ptn_after;\n\t\t\tTranslationTableOffset patternsOffset;\n\t\t\tint len, mrk;\n\t\t\tsize_t patternsByteSize = sizeof(*patterns) * 27720;\n\t\t\tpatterns = (widechar *)malloc(patternsByteSize);\n\t\t\tif (!patterns) _lou_outOfMemory();\n\t\t\tmemset(patterns, 0xffff, patternsByteSize);\n\t\t\tnoback = 1;\n\t\t\tgetCharacters(file, &ptn_before);\n\t\t\tgetRuleCharsText(file, &ruleChars);\n\t\t\tgetCharacters(file, &ptn_after);\n\t\t\tgetRuleDotsPattern(file, &ruleDots);\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset,\n\t\t\t\t\t\t&rule, noback, nofor, table))\n\t\t\t\tgoto CTO_Match_cleanup;\n\t\t\tif (ptn_before.chars[0] == '-' && ptn_before.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_before.chars[0], 0, &patterns[1], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length,\n\t\t\t\t\t\t&patterns[1], 13841, *table, file);\n\t\t\tif (!len) goto CTO_Match_cleanup;\n\t\t\tmrk = patterns[0] = len + 1;\n\t\t\t_lou_pattern_reverse(&patterns[1]);\n\t\t\tif (ptn_after.chars[0] == '-' && ptn_after.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length,\n\t\t\t\t\t\t&patterns[mrk], 13841, *table, file);\n\t\t\tif (!len) goto CTO_Match_cleanup;\n\t\t\tlen += mrk;\n\t\t\tif (!allocateSpaceInTranslationTable(\n\t\t\t\t\t\tfile, &patternsOffset, len * sizeof(widechar), table))\n\t\t\t\tgoto CTO_Match_cleanup;\n\t\t\t\/\/ allocateSpaceInTranslationTable may have moved table, so make sure rule is\n\t\t\t\/\/ still valid\n\t\t\trule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];\n\t\t\tmemcpy(&(*table)->ruleArea[patternsOffset], patterns, len * sizeof(widechar));\n\t\t\trule->patterns = patternsOffset;\n\t\t\tok = 1;\n\t\tCTO_Match_cleanup:\n\t\t\tfree(patterns);\n\t\t\treturn ok;\n\t\t}\n\n\t\tcase CTO_BackMatch: {\n\t\t\tint ok = 0;\n\t\t\twidechar *patterns = NULL;\n\t\t\tTranslationTableRule *rule;\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\tCharsString ptn_before, ptn_after;\n\t\t\tTranslationTableOffset patternOffset;\n\t\t\tint len, mrk;\n\t\t\tsize_t patternsByteSize = sizeof(*patterns) * 27720;\n\t\t\tpatterns = (widechar *)malloc(patternsByteSize);\n\t\t\tif (!patterns) _lou_outOfMemory();\n\t\t\tmemset(patterns, 0xffff, patternsByteSize);\n\t\t\tnofor = 1;\n\t\t\tgetCharacters(file, &ptn_before);\n\t\t\tgetRuleCharsText(file, &ruleChars);\n\t\t\tgetCharacters(file, &ptn_after);\n\t\t\tgetRuleDotsPattern(file, &ruleDots);\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, 0, 0, &ruleOffset, &rule,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\tgoto CTO_BackMatch_cleanup;\n\t\t\tif (ptn_before.chars[0] == '-' && ptn_before.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_before.chars[0], 0, &patterns[1], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length,\n\t\t\t\t\t\t&patterns[1], 13841, *table, file);\n\t\t\tif (!len) goto CTO_BackMatch_cleanup;\n\t\t\tmrk = patterns[0] = len + 1;\n\t\t\t_lou_pattern_reverse(&patterns[1]);\n\t\t\tif (ptn_after.chars[0] == '-' && ptn_after.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length,\n\t\t\t\t\t\t&patterns[mrk], 13841, *table, file);\n\t\t\tif (!len) goto CTO_BackMatch_cleanup;\n\t\t\tlen += mrk;\n\t\t\tif (!allocateSpaceInTranslationTable(\n\t\t\t\t\t\tfile, &patternOffset, len * sizeof(widechar), table))\n\t\t\t\tgoto CTO_BackMatch_cleanup;\n\t\t\t\/\/ allocateSpaceInTranslationTable may have moved table, so make sure rule is\n\t\t\t\/\/ still valid\n\t\t\trule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];\n\t\t\tmemcpy(&(*table)->ruleArea[patternOffset], patterns, len * sizeof(widechar));\n\t\t\trule->patterns = patternOffset;\n\t\t\tok = 1;\n\t\tCTO_BackMatch_cleanup:\n\t\t\tfree(patterns);\n\t\t\treturn ok;\n\t\t}\n\n\t\tcase CTO_CapsLetter:\n\t\tcase CTO_BegCapsWord:\n\t\tcase CTO_EndCapsWord:\n\t\tcase CTO_BegCaps:\n\t\tcase CTO_EndCaps:\n\t\tcase CTO_BegCapsPhrase:\n\t\tcase CTO_EndCapsPhrase:\n\t\tcase CTO_LenCapsPhrase:\n\t\t\/* these 8 general purpose opcodes are compiled further down to more specific\n\t\t * internal opcodes:\n\t\t * - modeletter\n\t\t * - begmodeword\n\t\t * - endmodeword\n\t\t * - begmode\n\t\t * - endmode\n\t\t * - begmodephrase\n\t\t * - endmodephrase\n\t\t * - lenmodephrase\n\t\t *\/\n\t\tcase CTO_ModeLetter:\n\t\tcase CTO_BegModeWord:\n\t\tcase CTO_EndModeWord:\n\t\tcase CTO_BegMode:\n\t\tcase CTO_EndMode:\n\t\tcase CTO_BegModePhrase:\n\t\tcase CTO_EndModePhrase:\n\t\tcase CTO_LenModePhrase: {\n\t\t\tTranslationTableCharacterAttributes mode;\n\t\t\tint i;\n\t\t\tswitch (opcode) {\n\t\t\tcase CTO_CapsLetter:\n\t\t\tcase CTO_BegCapsWord:\n\t\t\tcase CTO_EndCapsWord:\n\t\t\tcase CTO_BegCaps:\n\t\t\tcase CTO_EndCaps:\n\t\t\tcase CTO_BegCapsPhrase:\n\t\t\tcase CTO_EndCapsPhrase:\n\t\t\tcase CTO_LenCapsPhrase:\n\t\t\t\tmode = CTC_UpperCase;\n\t\t\t\ti = 0;\n\t\t\t\topcode += (CTO_ModeLetter - CTO_CapsLetter);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (!getToken(file, &token, \"attribute name\")) return 0;\n\t\t\t\tif (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tconst CharacterClass *characterClass = findCharacterClass(&token, *table);\n\t\t\t\tif (!characterClass) {\n\t\t\t\t\tcharacterClass =\n\t\t\t\t\t\t\taddCharacterClass(file, token.chars, token.length, *table, 1);\n\t\t\t\t\tif (!characterClass) return 0;\n\t\t\t\t}\n\t\t\t\tmode = characterClass->attribute;\n\t\t\t\tif (!(mode == CTC_UpperCase || mode == CTC_Digit) && mode >= CTC_Space &&\n\t\t\t\t\t\tmode <= CTC_LitDigit) {\n\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\"mode must be \\\"uppercase\\\", \\\"digit\\\", or a custom \"\n\t\t\t\t\t\t\t\"attribute name.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\t\/* check if this mode is already defined and if the number of modes does\n\t\t\t\t * not exceed the maximal number *\/\n\t\t\t\tif (mode == CTC_UpperCase)\n\t\t\t\t\ti = 0;\n\t\t\t\telse {\n\t\t\t\t\tfor (i = 1; i < MAX_MODES && (*table)->modes[i].value; i++) {\n\t\t\t\t\t\tif ((*table)->modes[i].mode == mode) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (i == MAX_MODES) {\n\t\t\t\t\t\tcompileError(file, \"Max number of modes (%i) reached\", MAX_MODES);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(*table)->modes[i].value)\n\t\t\t\t(*table)->modes[i] = (EmphasisClass){ plain_text, mode,\n\t\t\t\t\t0x1 << (MAX_EMPH_CLASSES + i), MAX_EMPH_CLASSES + i };\n\t\t\tswitch (opcode) {\n\t\t\tcase CTO_BegModePhrase: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first word capital sign\",\n\t\t\t\t\t\t\tCTO_BegCapsPhraseRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_EndModePhrase: {\n\t\t\t\tTranslationTableOffset ruleOffset;\n\t\t\t\tswitch (compileBeforeAfter(file)) {\n\t\t\t\tcase 1:\t \/\/ before\n\t\t\t\t\tif ((*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset]) {\n\t\t\t\t\t\tcompileError(\n\t\t\t\t\t\t\t\tfile, \"Capital sign after last word already defined.\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\truleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i]\n\t\t\t\t\t\t\t\t\t\t\t\t\t[endPhraseBeforeOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"capital sign before last word\",\n\t\t\t\t\t\t\t\tCTO_EndCapsPhraseBeforeRule + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseBeforeOffset] =\n\t\t\t\t\t\t\truleOffset;\n\t\t\t\t\treturn 1;\n\t\t\t\tcase 2:\t \/\/ after\n\t\t\t\t\tif ((*table)->emphRules[MAX_EMPH_CLASSES + i]\n\t\t\t\t\t\t\t\t\t\t   [endPhraseBeforeOffset]) {\n\t\t\t\t\t\tcompileError(\n\t\t\t\t\t\t\t\tfile, \"Capital sign before last word already defined.\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\truleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i]\n\t\t\t\t\t\t\t\t\t\t\t\t\t[endPhraseAfterOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"capital sign after last word\",\n\t\t\t\t\t\t\t\tCTO_EndCapsPhraseAfterRule + (8 * i), &ruleOffset, noback,\n\t\t\t\t\t\t\t\tnofor, table))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset] =\n\t\t\t\t\t\t\truleOffset;\n\t\t\t\t\treturn 1;\n\t\t\t\tdefault:  \/\/ error\n\t\t\t\t\tcompileError(file, \"Invalid lastword indicator location.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tcase CTO_BegMode: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first letter capital sign\",\n\t\t\t\t\t\t\tCTO_BegCapsRule + (8 * i), &ruleOffset, noback, nofor, table))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_EndMode: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"last letter capital sign\",\n\t\t\t\t\t\t\tCTO_EndCapsRule + (8 * i), &ruleOffset, noback, nofor, table))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_ModeLetter: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"single letter capital sign\",\n\t\t\t\t\t\t\tCTO_CapsLetterRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_BegModeWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"capital word\",\n\t\t\t\t\t\t\tCTO_BegCapsWordRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_EndModeWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"capital word stop\",\n\t\t\t\t\t\t\tCTO_EndCapsWordRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_LenModePhrase:\n\t\t\t\treturn (*table)->emphRules[MAX_EMPH_CLASSES + i][lenPhraseOffset] =\n\t\t\t\t\t\t\t   compileNumber(file);\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* these 8 general purpose emphasis opcodes are compiled further down to more\n\t\t * specific internal opcodes:\n\t\t * - emphletter\n\t\t * - begemphword\n\t\t * - endemphword\n\t\t * - begemph\n\t\t * - endemph\n\t\t * - begemphphrase\n\t\t * - endemphphrase\n\t\t * - lenemphphrase\n\t\t *\/\n\t\tcase CTO_EmphClass:\n\t\t\tif (!getToken(file, &emphClass, \"emphasis class\")) {\n\t\t\t\tcompileError(file, \"emphclass must be followed by a valid class name.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tint k, i;\n\t\t\tchar *s = malloc(sizeof(char) * (emphClass.length + 1));\n\t\t\tfor (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k];\n\t\t\ts[k++] = '\\0';\n\t\t\tfor (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++)\n\t\t\t\tif (strcmp(s, (*table)->emphClassNames[i]) == 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_WARN, \"Duplicate emphasis class: %s\", s);\n\t\t\t\t\twarningCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\tif (i == MAX_EMPH_CLASSES) {\n\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\"Max number of emphasis classes (%i) reached\", MAX_EMPH_CLASSES);\n\t\t\t\terrorCount++;\n\t\t\t\tfree(s);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tswitch (i) {\n\t\t\t\/* For backwards compatibility (i.e. because programs will assume\n\t\t\t * the first 3 typeform bits are `italic', `underline' and `bold')\n\t\t\t * we require that the first 3 emphclass definitions are (in that\n\t\t\t * order):\n\t\t\t *\n\t\t\t *   emphclass italic\n\t\t\t *   emphclass underline\n\t\t\t *   emphclass bold\n\t\t\t *\n\t\t\t * While it would be possible to use the emphclass opcode only for\n\t\t\t * defining _additional_ classes (not allowing for them to be called\n\t\t\t * italic, underline or bold), thereby reducing the amount of\n\t\t\t * boilerplate, we deliberately choose not to do that in order to\n\t\t\t * not give italic, underline and bold any special status. The\n\t\t\t * hope is that eventually all programs will use liblouis for\n\t\t\t * emphasis the recommended way (i.e. by looking up the supported\n\t\t\t * typeforms in the documentation or API) so that we can drop this\n\t\t\t * restriction.\n\t\t\t *\/\n\t\t\tcase 0:\n\t\t\t\tif (strcmp(s, \"italic\") != 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\"First emphasis class must be \\\"italic\\\" but got \"\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\ts);\n\t\t\t\t\terrorCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tif (strcmp(s, \"underline\") != 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\"Second emphasis class must be \\\"underline\\\" but \"\n\t\t\t\t\t\t\t\"got \"\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\ts);\n\t\t\t\t\terrorCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tif (strcmp(s, \"bold\") != 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\"Third emphasis class must be \\\"bold\\\" but got \"\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\ts);\n\t\t\t\t\terrorCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t(*table)->emphClassNames[i] = s;\n\t\t\t(*table)->emphClasses[i] = (EmphasisClass){ emph_1\n\t\t\t\t\t\t<< i, \/* relies on the order of typeforms emph_1..emph_10 *\/\n\t\t\t\t0, 0x1 << i, i };\n\t\t\treturn 1;\n\t\tcase CTO_EmphLetter:\n\t\tcase CTO_BegEmphWord:\n\t\tcase CTO_EndEmphWord:\n\t\tcase CTO_BegEmph:\n\t\tcase CTO_EndEmph:\n\t\tcase CTO_BegEmphPhrase:\n\t\tcase CTO_EndEmphPhrase:\n\t\tcase CTO_LenEmphPhrase:\n\t\tcase CTO_EmphModeChars:\n\t\tcase CTO_NoEmphChars: {\n\t\t\tif (!getToken(file, &token, \"emphasis class\")) return 0;\n\t\t\tif (!parseChars(file, &emphClass, &token)) return 0;\n\t\t\tchar *s = malloc(sizeof(char) * (emphClass.length + 1));\n\t\t\tint k, i;\n\t\t\tfor (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k];\n\t\t\ts[k++] = '\\0';\n\t\t\tfor (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++)\n\t\t\t\tif (strcmp(s, (*table)->emphClassNames[i]) == 0) break;\n\t\t\tif (i == MAX_EMPH_CLASSES || !(*table)->emphClassNames[i]) {\n\t\t\t\t_lou_logMessage(LOU_LOG_ERROR, \"Emphasis class %s not declared\", s);\n\t\t\t\terrorCount++;\n\t\t\t\tfree(s);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tint ok = 0;\n\t\t\tswitch (opcode) {\n\t\t\tcase CTO_EmphLetter: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][letterOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"single letter\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + letterOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][letterOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_BegEmphWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][begWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"word\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + begWordOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][begWordOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_EndEmphWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][endWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"word stop\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + endWordOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][endWordOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_BegEmph: {\n\t\t\t\t\/* fail if both begemph and any of begemphphrase or begemphword are\n\t\t\t\t * defined *\/\n\t\t\t\tif ((*table)->emphRules[i][begWordOffset] ||\n\t\t\t\t\t\t(*table)->emphRules[i][begPhraseOffset]) {\n\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\"Cannot define emphasis for both no context and word or \"\n\t\t\t\t\t\t\t\"phrase context, i.e. cannot have both begemph and \"\n\t\t\t\t\t\t\t\"begemphword or begemphphrase.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][begOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first letter\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + begOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][begOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_EndEmph: {\n\t\t\t\tif ((*table)->emphRules[i][endWordOffset] ||\n\t\t\t\t\t\t(*table)->emphRules[i][endPhraseBeforeOffset] ||\n\t\t\t\t\t\t(*table)->emphRules[i][endPhraseAfterOffset]) {\n\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\"Cannot define emphasis for both no context and word or \"\n\t\t\t\t\t\t\t\"phrase context, i.e. cannot have both endemph and \"\n\t\t\t\t\t\t\t\"endemphword or endemphphrase.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][endOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"last letter\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + endOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][endOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_BegEmphPhrase: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[i][begPhraseOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first word\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + begPhraseOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][begPhraseOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_EndEmphPhrase:\n\t\t\t\tswitch (compileBeforeAfter(file)) {\n\t\t\t\tcase 1: {  \/\/ before\n\t\t\t\t\tif ((*table)->emphRules[i][endPhraseAfterOffset]) {\n\t\t\t\t\t\tcompileError(file, \"last word after already defined.\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t\t(*table)->emphRules[i][endPhraseBeforeOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"last word before\",\n\t\t\t\t\t\t\t\tCTO_Emph1LetterRule + endPhraseBeforeOffset + (8 * i),\n\t\t\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t(*table)->emphRules[i][endPhraseBeforeOffset] = ruleOffset;\n\t\t\t\t\tok = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 2: {  \/\/ after\n\t\t\t\t\tif ((*table)->emphRules[i][endPhraseBeforeOffset]) {\n\t\t\t\t\t\tcompileError(file, \"last word before already defined.\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t\t(*table)->emphRules[i][endPhraseAfterOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"last word after\",\n\t\t\t\t\t\t\t\tCTO_Emph1LetterRule + endPhraseAfterOffset + (8 * i),\n\t\t\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t(*table)->emphRules[i][endPhraseAfterOffset] = ruleOffset;\n\t\t\t\t\tok = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:  \/\/ error\n\t\t\t\t\tcompileError(file, \"Invalid lastword indicator location.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CTO_LenEmphPhrase:\n\t\t\t\tif (((*table)->emphRules[i][lenPhraseOffset] = compileNumber(file)))\n\t\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\tcase CTO_EmphModeChars: {\n\t\t\t\tif (!getRuleCharsText(file, &ruleChars)) break;\n\t\t\t\twidechar *emphmodechars = (*table)->emphModeChars[i];\n\t\t\t\tint len;\n\t\t\t\tfor (len = 0; len < EMPHMODECHARSSIZE && emphmodechars[len]; len++)\n\t\t\t\t\t;\n\t\t\t\tif (len + ruleChars.length > EMPHMODECHARSSIZE) {\n\t\t\t\t\tcompileError(file, \"More than %d characters\", EMPHMODECHARSSIZE);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tok = 1;\n\t\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\t\tif (!getChar(ruleChars.chars[k], *table, NULL)) {\n\t\t\t\t\t\tcompileError(file, \"Emphasis mode character undefined\");\n\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\temphmodechars[len++] = ruleChars.chars[k];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_NoEmphChars: {\n\t\t\t\tif (!getRuleCharsText(file, &ruleChars)) break;\n\t\t\t\twidechar *noemphchars = (*table)->noEmphChars[i];\n\t\t\t\tint len;\n\t\t\t\tfor (len = 0; len < NOEMPHCHARSSIZE && noemphchars[len]; len++)\n\t\t\t\t\t;\n\t\t\t\tif (len + ruleChars.length > NOEMPHCHARSSIZE) {\n\t\t\t\t\tcompileError(file, \"More than %d characters\", NOEMPHCHARSSIZE);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tok = 1;\n\t\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\t\tif (!getChar(ruleChars.chars[k], *table, NULL)) {\n\t\t\t\t\t\tcompileError(file, \"Character undefined\");\n\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tnoemphchars[len++] = ruleChars.chars[k];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfree(s);\n\t\t\treturn ok;\n\t\t}\n\t\tcase CTO_LetterSign: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->letterSign;\n\t\t\tif (!compileBrailleIndicator(file, \"letter sign\", CTO_LetterRule, &ruleOffset,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->letterSign = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_NoLetsignBefore:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->noLetsignBeforeCount + ruleChars.length) > LETSIGNBEFORESIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", LETSIGNBEFORESIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->noLetsignBefore[(*table)->noLetsignBeforeCount++] =\n\t\t\t\t\t\truleChars.chars[k];\n\t\t\treturn 1;\n\t\tcase CTO_NoLetsign:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->noLetsignCount + ruleChars.length) > LETSIGNSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", LETSIGNSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->noLetsign[(*table)->noLetsignCount++] = ruleChars.chars[k];\n\t\t\treturn 1;\n\t\tcase CTO_NoLetsignAfter:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->noLetsignAfterCount + ruleChars.length) > LETSIGNAFTERSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", LETSIGNAFTERSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->noLetsignAfter[(*table)->noLetsignAfterCount++] =\n\t\t\t\t\t\truleChars.chars[k];\n\t\t\treturn 1;\n\t\tcase CTO_NumberSign: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->numberSign;\n\t\t\tif (!compileBrailleIndicator(file, \"number sign\", CTO_NumberRule, &ruleOffset,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->numberSign = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\n\t\tcase CTO_NumericModeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Numeric mode character undefined: %s\",\n\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[k], 1, 0));\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_NumericMode;\n\t\t\t\t(*table)->usesNumericMode = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_MidEndNumericModeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Midendnumeric mode character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_MidEndNumericMode;\n\t\t\t\t(*table)->usesNumericMode = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_NumericNoContractChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Numeric no contraction character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_NumericNoContract;\n\t\t\t\t(*table)->usesNumericMode = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_NoContractSign: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->noContractSign;\n\t\t\tif (!compileBrailleIndicator(file, \"no contractions sign\", CTO_NoContractRule,\n\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->noContractSign = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_SeqDelimiter:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Sequence delimiter character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_SeqDelimiter;\n\t\t\t\t(*table)->usesSequences = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqBeforeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Sequence before character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_SeqBefore;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqAfterChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Sequence after character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_SeqAfter;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqAfterPattern:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->seqPatternsCount + ruleChars.length + 1) > SEQPATTERNSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", SEQPATTERNSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->seqPatterns[(*table)->seqPatternsCount++] = ruleChars.chars[k];\n\t\t\t(*table)->seqPatterns[(*table)->seqPatternsCount++] = 0;\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqAfterExpression:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor ((*table)->seqAfterExpressionLength = 0;\n\t\t\t\t\t(*table)->seqAfterExpressionLength < ruleChars.length;\n\t\t\t\t\t(*table)->seqAfterExpressionLength++)\n\t\t\t\t(*table)->seqAfterExpression[(*table)->seqAfterExpressionLength] =\n\t\t\t\t\t\truleChars.chars[(*table)->seqAfterExpressionLength];\n\t\t\t(*table)->seqAfterExpression[(*table)->seqAfterExpressionLength] = 0;\n\t\t\treturn 1;\n\n\t\tcase CTO_CapsModeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Capital mode character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_CapsMode;\n\t\t\t\t(*table)->hasCapsModeChars = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_BegComp: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->begComp;\n\t\t\tif (!compileBrailleIndicator(file, \"begin computer braille\", CTO_BegCompRule,\n\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->begComp = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_EndComp: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->endComp;\n\t\t\tif (!compileBrailleIndicator(file, \"end computer braslle\", CTO_EndCompRule,\n\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->endComp = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_NoCross:\n\t\t\tif (nocross) {\n\t\t\t\tcompileError(\n\t\t\t\t\t\tfile, \"%s already specified.\", _lou_findOpcodeName(CTO_NoCross));\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tnocross = 1;\n\t\t\tgoto doOpcode;\n\t\tcase CTO_Syllable:\n\t\t\t(*table)->syllables = 1;\n\t\tcase CTO_Always:\n\t\tcase CTO_LargeSign:\n\t\tcase CTO_WholeWord:\n\t\tcase CTO_PartWord:\n\t\tcase CTO_JoinNum:\n\t\tcase CTO_JoinableWord:\n\t\tcase CTO_LowWord:\n\t\tcase CTO_SuffixableWord:\n\t\tcase CTO_PrefixableWord:\n\t\tcase CTO_BegWord:\n\t\tcase CTO_BegMidWord:\n\t\tcase CTO_MidWord:\n\t\tcase CTO_MidEndWord:\n\t\tcase CTO_EndWord:\n\t\tcase CTO_PrePunc:\n\t\tcase CTO_PostPunc:\n\t\tcase CTO_BegNum:\n\t\tcase CTO_MidNum:\n\t\tcase CTO_EndNum:\n\t\tcase CTO_Repeated:\n\t\tcase CTO_RepWord:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\t\tif (ruleDots.length == 0)\n\t\t\t\t\/\/ check that all characters in a rule with `=` as second operand are\n\t\t\t\t\/\/ defined (or based on another character)\n\t\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\t\tTranslationTableCharacter *c =\n\t\t\t\t\t\t\tgetChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\t\tif (!(c && (c->definitionRule || c->basechar))) {\n\t\t\t\t\t\tcompileError(file, \"Character %s is not defined\",\n\t\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[k], 1, 0));\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tTranslationTableRule *r;\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, &r,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\tif (nocross) r->nocross = 1;\n\t\t\treturn 1;\n\t\t\t\/\/ if (opcode == CTO_MidNum)\n\t\t\t\/\/ {\n\t\t\t\/\/   TranslationTableCharacter *c = getChar(ruleChars.chars[0]);\n\t\t\t\/\/   if(c)\n\t\t\t\/\/     c->attributes |= CTC_NumericMode;\n\t\t\t\/\/ }\n\t\tcase CTO_RepEndWord:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tCharsString dots;\n\t\t\tif (!getToken(file, &dots, \"dots,dots operand\")) return 0;\n\t\t\tint len = dots.length;\n\t\t\tfor (int k = 0; k < len - 1; k++) {\n\t\t\t\tif (dots.chars[k] == ',') {\n\t\t\t\t\tdots.length = k;\n\t\t\t\t\tif (!parseDots(file, &ruleDots, &dots)) return 0;\n\t\t\t\t\truleDots.chars[ruleDots.length++] = ',';\n\t\t\t\t\tk++;\n\t\t\t\t\tif (k == len - 1 && dots.chars[k] == '=') {\n\t\t\t\t\t\t\/\/ check that all characters are defined (or based on another\n\t\t\t\t\t\t\/\/ character)\n\t\t\t\t\t\tfor (int l = 0; l < ruleChars.length; l++) {\n\t\t\t\t\t\t\tTranslationTableCharacter *c =\n\t\t\t\t\t\t\t\t\tgetChar(ruleChars.chars[l], *table, NULL);\n\t\t\t\t\t\t\tif (!(c && (c->definitionRule || c->basechar))) {\n\t\t\t\t\t\t\t\tcompileError(file, \"Character %s is not defined\",\n\t\t\t\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[l], 1, 0));\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tCharsString x, y;\n\t\t\t\t\t\tx.length = 0;\n\t\t\t\t\t\twhile (k < len) x.chars[x.length++] = dots.chars[k++];\n\t\t\t\t\t\tif (parseDots(file, &y, &x))\n\t\t\t\t\t\t\tfor (int l = 0; l < y.length; l++)\n\t\t\t\t\t\t\t\truleDots.chars[ruleDots.length++] = y.chars[l];\n\t\t\t\t\t}\n\t\t\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, after, before,\n\t\t\t\t\t\t\tNULL, NULL, noback, nofor, table);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\tcase CTO_CompDots:\n\t\tcase CTO_Comp6: {\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (ruleChars.length != 1) {\n\t\t\t\tcompileError(file, \"first operand must be 1 character\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (nofor || noback) {\n\t\t\t\tcompileWarning(file, \"nofor and noback not allowed on comp6 rules\");\n\t\t\t}\n\t\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset,\n\t\t\t\t\t\tNULL, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_ExactDots:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (ruleChars.chars[0] != '@') {\n\t\t\t\tcompileError(file, \"The operand must begin with an at sign (@)\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 1; k < ruleChars.length; k++)\n\t\t\t\tscratchPad.chars[k - 1] = ruleChars.chars[k];\n\t\t\tscratchPad.length = ruleChars.length - 1;\n\t\t\tif (!parseDots(file, &ruleDots, &scratchPad)) return 0;\n\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, before, after, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\tcase CTO_CapsNoCont: {\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\truleChars.length = 1;\n\t\t\truleChars.chars[0] = 'a';\n\t\t\tif (!addRule(file, CTO_CapsNoContRule, &ruleChars, NULL, after, before,\n\t\t\t\t\t\t&ruleOffset, NULL, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->capsNoCont = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_Replace:\n\t\t\tif (getRuleCharsText(file, &ruleChars)) {\n\t\t\t\tif (atEndOfLine(file))\n\t\t\t\t\truleDots.length = ruleDots.chars[0] = 0;\n\t\t\t\telse {\n\t\t\t\t\tgetRuleDotsText(file, &ruleDots);\n\t\t\t\t\tif (ruleDots.chars[0] == '#')\n\t\t\t\t\t\truleDots.length = ruleDots.chars[0] = 0;\n\t\t\t\t\telse if (ruleDots.chars[0] == '\\\\' && ruleDots.chars[1] == '#')\n\t\t\t\t\t\tmemmove(&ruleDots.chars[0], &ruleDots.chars[1],\n\t\t\t\t\t\t\t\truleDots.length-- * CHARSIZE);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\tputChar(file, ruleChars.chars[k], table, NULL);\n\t\t\tfor (int k = 0; k < ruleDots.length; k++)\n\t\t\t\tputChar(file, ruleDots.chars[k], table, NULL);\n\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\tcase CTO_Correct:\n\t\t\t(*table)->corrections = 1;\n\t\t\tgoto doPass;\n\t\tcase CTO_Pass2:\n\t\t\tif ((*table)->numPasses < 2) (*table)->numPasses = 2;\n\t\t\tgoto doPass;\n\t\tcase CTO_Pass3:\n\t\t\tif ((*table)->numPasses < 3) (*table)->numPasses = 3;\n\t\t\tgoto doPass;\n\t\tcase CTO_Pass4:\n\t\t\tif ((*table)->numPasses < 4) (*table)->numPasses = 4;\n\t\tdoPass:\n\t\tcase CTO_Context:\n\t\t\tif (!(nofor || noback)) {\n\t\t\t\tcompileError(file, \"%s or %s must be specified.\",\n\t\t\t\t\t\t_lou_findOpcodeName(CTO_NoFor), _lou_findOpcodeName(CTO_NoBack));\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn compilePassOpcode(file, opcode, noback, nofor, table);\n\t\tcase CTO_Contraction:\n\t\tcase CTO_NoCont:\n\t\tcase CTO_CompBrl:\n\t\tcase CTO_Literal:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\t\/\/ check that all characters in a compbrl, contraction,\n\t\t\t\/\/ nocont or literal rule are defined (or based on another\n\t\t\t\/\/ character)\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!(c && (c->definitionRule || c->basechar))) {\n\t\t\t\t\tcompileError(file, \"Character %s is not defined\",\n\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[k], 1, 0));\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn addRule(file, opcode, &ruleChars, NULL, after, before, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\tcase CTO_MultInd: {\n\t\t\truleChars.length = 0;\n\t\t\tif (!getToken(file, &token, \"multiple braille indicators\") ||\n\t\t\t\t\t!parseDots(file, &cells, &token))\n\t\t\t\treturn 0;\n\t\t\twhile (getToken(file, &token, \"multind opcodes\")) {\n\t\t\t\topcode = getOpcode(file, &token);\n\t\t\t\tif (opcode == CTO_None) {\n\t\t\t\t\tcompileError(file, \"opcode %s not defined.\",\n\t\t\t\t\t\t\t_lou_showString(token.chars, token.length, 0));\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (!(opcode >= CTO_CapsLetter && opcode < CTO_MultInd)) {\n\t\t\t\t\tcompileError(file, \"Not a braille indicator opcode.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\truleChars.chars[ruleChars.length++] = (widechar)opcode;\n\t\t\t\tif (atEndOfLine(file)) break;\n\t\t\t}\n\t\t\treturn addRule(file, CTO_MultInd, &ruleChars, &cells, after, before, NULL,\n\t\t\t\t\tNULL, noback, nofor, table);\n\t\t}\n\n\t\tcase CTO_Class:\n\t\t\tcompileWarning(file, \"class is deprecated, use attribute instead\");\n\t\tcase CTO_Attribute: {\n\t\t\tif (nofor || noback) {\n\t\t\t\tcompileWarning(\n\t\t\t\t\t\tfile, \"nofor and noback not allowed before class\/attribute\");\n\t\t\t}\n\t\t\tif ((opcode == CTO_Class && (*table)->usesAttributeOrClass == 1) ||\n\t\t\t\t\t(opcode == CTO_Attribute && (*table)->usesAttributeOrClass == 2)) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"attribute and class rules must not be both present in a table\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (opcode == CTO_Class)\n\t\t\t\t(*table)->usesAttributeOrClass = 2;\n\t\t\telse\n\t\t\t\t(*table)->usesAttributeOrClass = 1;\n\t\t\tif (!getToken(file, &token, \"attribute name\")) {\n\t\t\t\tcompileError(file, \"Expected %s\", \"attribute name\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tTranslationTableCharacterAttributes attribute = 0;\n\t\t\t{\n\t\t\t\tint attrNumber = -1;\n\t\t\t\tswitch (token.chars[0]) {\n\t\t\t\tcase '0':\n\t\t\t\tcase '1':\n\t\t\t\tcase '2':\n\t\t\t\tcase '3':\n\t\t\t\tcase '4':\n\t\t\t\tcase '5':\n\t\t\t\tcase '6':\n\t\t\t\tcase '7':\n\t\t\t\tcase '8':\n\t\t\t\tcase '9':\n\t\t\t\t\tattrNumber = token.chars[0] - '0';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (attrNumber >= 0) {\n\t\t\t\t\tif (opcode == CTO_Class) {\n\t\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\t\"Invalid class name: may not contain digits, use \"\n\t\t\t\t\t\t\t\t\"attribute instead of class\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (token.length > 1 || attrNumber > 7) {\n\t\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\t\"Invalid attribute name: must be a digit between 0 and 7 \"\n\t\t\t\t\t\t\t\t\"or a word containing only letters\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (!(*table)->numberedAttributes[attrNumber])\n\t\t\t\t\t\t\/\/ attribute not used before yet: assign it a value\n\t\t\t\t\t\t(*table)->numberedAttributes[attrNumber] =\n\t\t\t\t\t\t\t\tgetNextNumberedAttribute(*table);\n\t\t\t\t\tattribute = (*table)->numberedAttributes[attrNumber];\n\t\t\t\t} else {\n\t\t\t\t\tconst CharacterClass *namedAttr = findCharacterClass(&token, *table);\n\t\t\t\t\tif (!namedAttr) {\n\t\t\t\t\t\t\/\/ no class with that name: create one\n\t\t\t\t\t\tnamedAttr = addCharacterClass(\n\t\t\t\t\t\t\t\tfile, &token.chars[0], token.length, *table, 1);\n\t\t\t\t\t\tif (!namedAttr) return 0;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ there is a class with that name or a new class was successfully\n\t\t\t\t\t\/\/ created\n\t\t\t\t\tattribute = namedAttr->attribute;\n\t\t\t\t\tif (attribute == CTC_UpperCase || attribute == CTC_LowerCase)\n\t\t\t\t\t\tattribute |= CTC_Letter;\n\t\t\t\t}\n\t\t\t}\n\t\t\tCharsString characters;\n\t\t\tif (!getCharacters(file, &characters)) return 0;\n\t\t\tfor (int i = 0; i < characters.length; i++) {\n\t\t\t\t\/\/ get the character from the table, or if it is not defined yet,\n\t\t\t\t\/\/ define it\n\t\t\t\tTranslationTableCharacter *character =\n\t\t\t\t\t\tputChar(file, characters.chars[i], table, NULL);\n\t\t\t\t\/\/ set the attribute\n\t\t\t\tcharacter->attributes |= attribute;\n\t\t\t\t\/\/ also set the attribute on the associated dots (if any)\n\t\t\t\tif (character->basechar)\n\t\t\t\t\tcharacter = (TranslationTableCharacter *)&(*table)\n\t\t\t\t\t\t\t\t\t\t->ruleArea[character->basechar];\n\t\t\t\tif (character->definitionRule) {\n\t\t\t\t\tTranslationTableRule *defRule =\n\t\t\t\t\t\t\t(TranslationTableRule *)&(*table)\n\t\t\t\t\t\t\t\t\t->ruleArea[character->definitionRule];\n\t\t\t\t\tif (defRule->dotslen == 1) {\n\t\t\t\t\t\tTranslationTableCharacter *dots =\n\t\t\t\t\t\t\t\tgetDots(defRule->charsdots[defRule->charslen], *table);\n\t\t\t\t\t\tif (dots) dots->attributes |= attribute;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 1;\n\t\t}\n\n\t\t\t{\n\t\t\t\tTranslationTableCharacterAttributes *attributes;\n\t\t\t\tconst CharacterClass *class;\n\t\t\tcase CTO_After:\n\t\t\t\tattributes = &after;\n\t\t\t\tgoto doBeforeAfter;\n\t\t\tcase CTO_Before:\n\t\t\t\tattributes = &before;\n\t\t\tdoBeforeAfter:\n\t\t\t\tif (!(*table)->characterClasses) {\n\t\t\t\t\tif (!allocateCharacterClasses(*table)) return 0;\n\t\t\t\t}\n\t\t\t\tif (!getToken(file, &token, \"attribute name\")) return 0;\n\t\t\t\tif (!(class = findCharacterClass(&token, *table))) {\n\t\t\t\t\tcompileError(file, \"attribute not defined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\t*attributes |= class->attribute;\n\t\t\t\tgoto doOpcode;\n\t\t\t}\n\t\tcase CTO_Base:\n\t\t\tif (nofor || noback) {\n\t\t\t\tcompileWarning(file, \"nofor and noback not allowed before base\");\n\t\t\t}\n\t\t\tif (!getToken(file, &token, \"attribute name\")) {\n\t\t\t\tcompileError(\n\t\t\t\t\t\tfile, \"base opcode must be followed by a valid attribute name.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tconst CharacterClass *mode = findCharacterClass(&token, *table);\n\t\t\tif (!mode) {\n\t\t\t\tmode = addCharacterClass(file, token.chars, token.length, *table, 1);\n\t\t\t\tif (!mode) return 0;\n\t\t\t}\n\t\t\tif (!(mode->attribute == CTC_UpperCase || mode->attribute == CTC_Digit) &&\n\t\t\t\t\tmode->attribute >= CTC_Space && mode->attribute <= CTC_LitDigit) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"base opcode must be followed by \\\"uppercase\\\", \\\"digit\\\", or a \"\n\t\t\t\t\t\t\"custom attribute name.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!getRuleCharsText(file, &token)) return 0;\n\t\t\tif (token.length != 1) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"Exactly one character followed by one base character is \"\n\t\t\t\t\t\t\"required.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tTranslationTableOffset characterOffset;\n\t\t\tTranslationTableCharacter *character =\n\t\t\t\t\tputChar(file, token.chars[0], table, &characterOffset);\n\t\t\tif (!getRuleCharsText(file, &token)) return 0;\n\t\t\tif (token.length != 1) {\n\t\t\t\tcompileError(file, \"Exactly one base character is required.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (character->definitionRule) {\n\t\t\t\tTranslationTableRule *prevRule =\n\t\t\t\t\t\t(TranslationTableRule *)&(*table)\n\t\t\t\t\t\t\t\t->ruleArea[character->definitionRule];\n\t\t\t\t_lou_logMessage(LOU_LOG_DEBUG,\n\t\t\t\t\t\t\"%s:%d: Character already defined (%s). The base rule will take \"\n\t\t\t\t\t\t\"precedence.\",\n\t\t\t\t\t\tfile->fileName, file->lineNumber,\n\t\t\t\t\t\tprintSource(file, prevRule->sourceFile, prevRule->sourceLine));\n\t\t\t\tcharacter->definitionRule = 0;\n\t\t\t}\n\t\t\tTranslationTableOffset basechar;\n\t\t\tputChar(file, token.chars[0], table, &basechar);\n\t\t\t\/\/ putChar may have moved table, so make sure character is still valid\n\t\t\tcharacter = (TranslationTableCharacter *)&(*table)->ruleArea[characterOffset];\n\t\t\tif (character->basechar) {\n\t\t\t\tif (character->basechar == basechar &&\n\t\t\t\t\t\tcharacter->mode == mode->attribute) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_DEBUG, \"%s:%d: Duplicate base rule.\",\n\t\t\t\t\t\t\tfile->fileName, file->lineNumber);\n\t\t\t\t} else {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_DEBUG,\n\t\t\t\t\t\t\t\"%s:%d: A different base rule already exists for this \"\n\t\t\t\t\t\t\t\"character (%s). The new rule will take precedence.\",\n\t\t\t\t\t\t\tfile->fileName, file->lineNumber,\n\t\t\t\t\t\t\tprintSource(\n\t\t\t\t\t\t\t\t\tfile, character->sourceFile, character->sourceLine));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcharacter->basechar = basechar;\n\t\t\tcharacter->mode = mode->attribute;\n\t\t\tcharacter->sourceFile = file->sourceFile;\n\t\t\tcharacter->sourceLine = file->lineNumber;\n\t\t\t\/* some other processing is done at the end of the compilation, in\n\t\t\t * finalizeTable() *\/\n\t\t\treturn 1;\n\t\tcase CTO_EmpMatchBefore:\n\t\t\tbefore |= CTC_EmpMatch;\n\t\t\tgoto doOpcode;\n\t\tcase CTO_EmpMatchAfter:\n\t\t\tafter |= CTC_EmpMatch;\n\t\t\tgoto doOpcode;\n\n\t\tcase CTO_SwapCc:\n\t\tcase CTO_SwapCd:\n\t\tcase CTO_SwapDd:\n\t\t\treturn compileSwap(file, opcode, noback, nofor, table);\n\t\tcase CTO_Hyphen:\n\t\tcase CTO_DecPoint:\n\t\t\t\/\/\tcase CTO_Apostrophe:\n\t\t\t\/\/\tcase CTO_Initial:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\t\tif (ruleChars.length != 1 || ruleDots.length < 1) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"One Unicode character and at least one cell are \"\n\t\t\t\t\t\t\"required.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\t\t\/\/ if (opcode == CTO_DecPoint)\n\t\t\t\/\/ {\n\t\t\t\/\/   TranslationTableCharacter *c =\n\t\t\t\/\/   getChar(ruleChars.chars[0]);\n\t\t\t\/\/   if(c)\n\t\t\t\/\/     c->attributes |= CTC_NumericMode;\n\t\t\t\/\/ }\n\t\tdefault:\n\t\t\tcompileError(file, \"unimplemented opcode.\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 0;\n}","target":1,"code_token_length":14694,"total_token_length":14930,"max_tokens_setting":28000}
+{"idx":225062,"func":"PQconnectPoll(PGconn *conn)\n{\n\tbool\t\treset_connection_state_machine = false;\n\tbool\t\tneed_new_connection = false;\n\tPGresult   *res;\n\tchar\t\tsebuf[PG_STRERROR_R_BUFLEN];\n\tint\t\t\toptval;\n\n\tif (conn == NULL)\n\t\treturn PGRES_POLLING_FAILED;\n\n\t\/* Get the new data *\/\n\tswitch (conn->status)\n\t{\n\t\t\t\/*\n\t\t\t * We really shouldn't have been polled in these two cases, but we\n\t\t\t * can handle it.\n\t\t\t *\/\n\t\tcase CONNECTION_BAD:\n\t\t\treturn PGRES_POLLING_FAILED;\n\t\tcase CONNECTION_OK:\n\t\t\treturn PGRES_POLLING_OK;\n\n\t\t\t\/* These are reading states *\/\n\t\tcase CONNECTION_AWAITING_RESPONSE:\n\t\tcase CONNECTION_AUTH_OK:\n\t\tcase CONNECTION_CHECK_WRITABLE:\n\t\tcase CONNECTION_CONSUME:\n\t\tcase CONNECTION_CHECK_STANDBY:\n\t\t\t{\n\t\t\t\t\/* Load waiting data *\/\n\t\t\t\tint\t\t\tn = pqReadData(conn);\n\n\t\t\t\tif (n < 0)\n\t\t\t\t\tgoto error_return;\n\t\t\t\tif (n == 0)\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t\/* These are writing states, so we just proceed. *\/\n\t\tcase CONNECTION_STARTED:\n\t\tcase CONNECTION_MADE:\n\t\t\tbreak;\n\n\t\t\t\/* Special cases: proceed without waiting. *\/\n\t\tcase CONNECTION_SSL_STARTUP:\n\t\tcase CONNECTION_NEEDED:\n\t\tcase CONNECTION_GSS_STARTUP:\n\t\tcase CONNECTION_CHECK_TARGET:\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t libpq_gettext(\"invalid connection state, probably indicative of memory corruption\\n\"));\n\t\t\tgoto error_return;\n\t}\n\n\nkeep_going:\t\t\t\t\t\t\/* We will come back to here until there is\n\t\t\t\t\t\t\t\t * nothing left to do. *\/\n\n\t\/* Time to advance to next address, or next host if no more addresses? *\/\n\tif (conn->try_next_addr)\n\t{\n\t\tif (conn->addr_cur && conn->addr_cur->ai_next)\n\t\t{\n\t\t\tconn->addr_cur = conn->addr_cur->ai_next;\n\t\t\treset_connection_state_machine = true;\n\t\t}\n\t\telse\n\t\t\tconn->try_next_host = true;\n\t\tconn->try_next_addr = false;\n\t}\n\n\t\/* Time to advance to next connhost[] entry? *\/\n\tif (conn->try_next_host)\n\t{\n\t\tpg_conn_host *ch;\n\t\tstruct addrinfo hint;\n\t\tint\t\t\tthisport;\n\t\tint\t\t\tret;\n\t\tchar\t\tportstr[MAXPGPATH];\n\n\t\tif (conn->whichhost + 1 < conn->nconnhost)\n\t\t\tconn->whichhost++;\n\t\telse\n\t\t{\n\t\t\t\/*\n\t\t\t * Oops, no more hosts.\n\t\t\t *\n\t\t\t * If we are trying to connect in \"prefer-standby\" mode, then drop\n\t\t\t * the standby requirement and start over.\n\t\t\t *\n\t\t\t * Otherwise, an appropriate error message is already set up, so\n\t\t\t * we just need to set the right status.\n\t\t\t *\/\n\t\t\tif (conn->target_server_type == SERVER_TYPE_PREFER_STANDBY &&\n\t\t\t\tconn->nconnhost > 0)\n\t\t\t{\n\t\t\t\tconn->target_server_type = SERVER_TYPE_PREFER_STANDBY_PASS2;\n\t\t\t\tconn->whichhost = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t\tgoto error_return;\n\t\t}\n\n\t\t\/* Drop any address info for previous host *\/\n\t\trelease_conn_addrinfo(conn);\n\n\t\t\/*\n\t\t * Look up info for the new host.  On failure, log the problem in\n\t\t * conn->errorMessage, then loop around to try the next host.  (Note\n\t\t * we don't clear try_next_host until we've succeeded.)\n\t\t *\/\n\t\tch = &conn->connhost[conn->whichhost];\n\n\t\t\/* Initialize hint structure *\/\n\t\tMemSet(&hint, 0, sizeof(hint));\n\t\thint.ai_socktype = SOCK_STREAM;\n\t\tconn->addrlist_family = hint.ai_family = AF_UNSPEC;\n\n\t\t\/* Figure out the port number we're going to use. *\/\n\t\tif (ch->port == NULL || ch->port[0] == '\\0')\n\t\t\tthisport = DEF_PGPORT;\n\t\telse\n\t\t{\n\t\t\tif (!parse_int_param(ch->port, &thisport, conn, \"port\"))\n\t\t\t\tgoto error_return;\n\n\t\t\tif (thisport < 1 || thisport > 65535)\n\t\t\t{\n\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"invalid port number: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t  ch->port);\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\t\t}\n\t\tsnprintf(portstr, sizeof(portstr), \"%d\", thisport);\n\n\t\t\/* Use pg_getaddrinfo_all() to resolve the address *\/\n\t\tswitch (ch->type)\n\t\t{\n\t\t\tcase CHT_HOST_NAME:\n\t\t\t\tret = pg_getaddrinfo_all(ch->host, portstr, &hint,\n\t\t\t\t\t\t\t\t\t\t &conn->addrlist);\n\t\t\t\tif (ret || !conn->addrlist)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not translate host name \\\"%s\\\" to address: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  ch->host, gai_strerror(ret));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CHT_HOST_ADDRESS:\n\t\t\t\thint.ai_flags = AI_NUMERICHOST;\n\t\t\t\tret = pg_getaddrinfo_all(ch->hostaddr, portstr, &hint,\n\t\t\t\t\t\t\t\t\t\t &conn->addrlist);\n\t\t\t\tif (ret || !conn->addrlist)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not parse network address \\\"%s\\\": %s\\n\"),\n\t\t\t\t\t\t\t\t\t  ch->hostaddr, gai_strerror(ret));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase CHT_UNIX_SOCKET:\n#ifdef HAVE_UNIX_SOCKETS\n\t\t\t\tconn->addrlist_family = hint.ai_family = AF_UNIX;\n\t\t\t\tUNIXSOCK_PATH(portstr, thisport, ch->host);\n\t\t\t\tif (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"Unix-domain socket path \\\"%s\\\" is too long (maximum %d bytes)\\n\"),\n\t\t\t\t\t\t\t\t\t  portstr,\n\t\t\t\t\t\t\t\t\t  (int) (UNIXSOCK_PATH_BUFLEN - 1));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * NULL hostname tells pg_getaddrinfo_all to parse the service\n\t\t\t\t * name as a Unix-domain socket path.\n\t\t\t\t *\/\n\t\t\t\tret = pg_getaddrinfo_all(NULL, portstr, &hint,\n\t\t\t\t\t\t\t\t\t\t &conn->addrlist);\n\t\t\t\tif (ret || !conn->addrlist)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not translate Unix-domain socket path \\\"%s\\\" to address: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  portstr, gai_strerror(ret));\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n#else\n\t\t\t\tAssert(false);\n#endif\n\t\t\t\tbreak;\n\t\t}\n\n\t\t\/* OK, scan this addrlist for a working server address *\/\n\t\tconn->addr_cur = conn->addrlist;\n\t\treset_connection_state_machine = true;\n\t\tconn->try_next_host = false;\n\t}\n\n\t\/* Reset connection state machine? *\/\n\tif (reset_connection_state_machine)\n\t{\n\t\t\/*\n\t\t * (Re) initialize our connection control variables for a set of\n\t\t * connection attempts to a single server address.  These variables\n\t\t * must persist across individual connection attempts, but we must\n\t\t * reset them when we start to consider a new server.\n\t\t *\/\n\t\tconn->pversion = PG_PROTOCOL(3, 0);\n\t\tconn->send_appname = true;\n#ifdef USE_SSL\n\t\t\/* initialize these values based on SSL mode *\/\n\t\tconn->allow_ssl_try = (conn->sslmode[0] != 'd');\t\/* \"disable\" *\/\n\t\tconn->wait_ssl_try = (conn->sslmode[0] == 'a'); \/* \"allow\" *\/\n#endif\n#ifdef ENABLE_GSS\n\t\tconn->try_gss = (conn->gssencmode[0] != 'd');\t\/* \"disable\" *\/\n#endif\n\n\t\treset_connection_state_machine = false;\n\t\tneed_new_connection = true;\n\t}\n\n\t\/* Force a new connection (perhaps to the same server as before)? *\/\n\tif (need_new_connection)\n\t{\n\t\t\/* Drop any existing connection *\/\n\t\tpqDropConnection(conn, true);\n\n\t\t\/* Reset all state obtained from old server *\/\n\t\tpqDropServerData(conn);\n\n\t\t\/* Drop any PGresult we might have, too *\/\n\t\tconn->asyncStatus = PGASYNC_IDLE;\n\t\tconn->xactStatus = PQTRANS_IDLE;\n\t\tconn->pipelineStatus = PQ_PIPELINE_OFF;\n\t\tpqClearAsyncResult(conn);\n\n\t\t\/* Reset conn->status to put the state machine in the right state *\/\n\t\tconn->status = CONNECTION_NEEDED;\n\n\t\tneed_new_connection = false;\n\t}\n\n\t\/* Now try to advance the state machine for this connection *\/\n\tswitch (conn->status)\n\t{\n\t\tcase CONNECTION_NEEDED:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Try to initiate a connection to one of the addresses\n\t\t\t\t * returned by pg_getaddrinfo_all().  conn->addr_cur is the\n\t\t\t\t * next one to try.\n\t\t\t\t *\n\t\t\t\t * The extra level of braces here is historical.  It's not\n\t\t\t\t * worth reindenting this whole switch case to remove 'em.\n\t\t\t\t *\/\n\t\t\t\t{\n\t\t\t\t\tstruct addrinfo *addr_cur = conn->addr_cur;\n\t\t\t\t\tchar\t\thost_addr[NI_MAXHOST];\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Advance to next possible host, if we've tried all of\n\t\t\t\t\t * the addresses for the current host.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (addr_cur == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* Remember current address for possible use later *\/\n\t\t\t\t\tmemcpy(&conn->raddr.addr, addr_cur->ai_addr,\n\t\t\t\t\t\t   addr_cur->ai_addrlen);\n\t\t\t\t\tconn->raddr.salen = addr_cur->ai_addrlen;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Set connip, too.  Note we purposely ignore strdup\n\t\t\t\t\t * failure; not a big problem if it fails.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->connip != NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tfree(conn->connip);\n\t\t\t\t\t\tconn->connip = NULL;\n\t\t\t\t\t}\n\t\t\t\t\tgetHostaddr(conn, host_addr, NI_MAXHOST);\n\t\t\t\t\tif (host_addr[0])\n\t\t\t\t\t\tconn->connip = strdup(host_addr);\n\n\t\t\t\t\t\/* Try to create the socket *\/\n\t\t\t\t\tconn->sock = socket(addr_cur->ai_family, SOCK_STREAM, 0);\n\t\t\t\t\tif (conn->sock == PGINVALID_SOCKET)\n\t\t\t\t\t{\n\t\t\t\t\t\tint\t\t\terrorno = SOCK_ERRNO;\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Silently ignore socket() failure if we have more\n\t\t\t\t\t\t * addresses to try; this reduces useless chatter in\n\t\t\t\t\t\t * cases where the address list includes both IPv4 and\n\t\t\t\t\t\t * IPv6 but kernel only accepts one family.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (addr_cur->ai_next != NULL ||\n\t\t\t\t\t\t\tconn->whichhost + 1 < conn->nconnhost)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temitHostIdentityInfo(conn, host_addr);\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not create socket: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Once we've identified a target address, all errors\n\t\t\t\t\t * except the preceding socket()-failure case should be\n\t\t\t\t\t * prefixed with host-identity information.  (If the\n\t\t\t\t\t * connection succeeds, the contents of conn->errorMessage\n\t\t\t\t\t * won't matter, so this is harmless.)\n\t\t\t\t\t *\/\n\t\t\t\t\temitHostIdentityInfo(conn, host_addr);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Select socket options: no delay of outgoing data for\n\t\t\t\t\t * TCP sockets, nonblock mode, close-on-exec.  Try the\n\t\t\t\t\t * next address if any of this fails.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (!IS_AF_UNIX(addr_cur->ai_family))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!connectNoDelay(conn))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* error message already created *\/\n\t\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!pg_set_noblock(conn->sock))\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not set socket to nonblocking mode: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n#ifdef F_SETFD\n\t\t\t\t\tif (fcntl(conn->sock, F_SETFD, FD_CLOEXEC) == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not set socket to close-on-exec mode: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n#endif\t\t\t\t\t\t\t\/* F_SETFD *\/\n\n\t\t\t\t\tif (!IS_AF_UNIX(addr_cur->ai_family))\n\t\t\t\t\t{\n#ifndef WIN32\n\t\t\t\t\t\tint\t\t\ton = 1;\n#endif\n\t\t\t\t\t\tint\t\t\tusekeepalives = useKeepalives(conn);\n\t\t\t\t\t\tint\t\t\terr = 0;\n\n\t\t\t\t\t\tif (usekeepalives < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"keepalives parameter must be an integer\\n\"));\n\t\t\t\t\t\t\terr = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (usekeepalives == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* Do nothing *\/\n\t\t\t\t\t\t}\n#ifndef WIN32\n\t\t\t\t\t\telse if (setsockopt(conn->sock,\n\t\t\t\t\t\t\t\t\t\t\tSOL_SOCKET, SO_KEEPALIVE,\n\t\t\t\t\t\t\t\t\t\t\t(char *) &on, sizeof(on)) < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"%s(%s) failed: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  \"setsockopt\",\n\t\t\t\t\t\t\t\t\t\t\t  \"SO_KEEPALIVE\",\n\t\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\t\terr = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (!setKeepalivesIdle(conn)\n\t\t\t\t\t\t\t\t || !setKeepalivesInterval(conn)\n\t\t\t\t\t\t\t\t || !setKeepalivesCount(conn))\n\t\t\t\t\t\t\terr = 1;\n#else\t\t\t\t\t\t\t\/* WIN32 *\/\n#ifdef SIO_KEEPALIVE_VALS\n\t\t\t\t\t\telse if (!setKeepalivesWin32(conn))\n\t\t\t\t\t\t\terr = 1;\n#endif\t\t\t\t\t\t\t\/* SIO_KEEPALIVE_VALS *\/\n#endif\t\t\t\t\t\t\t\/* WIN32 *\/\n\t\t\t\t\t\telse if (!setTCPUserTimeout(conn))\n\t\t\t\t\t\t\terr = 1;\n\n\t\t\t\t\t\tif (err)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*----------\n\t\t\t\t\t * We have three methods of blocking SIGPIPE during\n\t\t\t\t\t * send() calls to this socket:\n\t\t\t\t\t *\n\t\t\t\t\t *\t- setsockopt(sock, SO_NOSIGPIPE)\n\t\t\t\t\t *\t- send(sock, ..., MSG_NOSIGNAL)\n\t\t\t\t\t *\t- setting the signal mask to SIG_IGN during send()\n\t\t\t\t\t *\n\t\t\t\t\t * The third method requires three syscalls per send,\n\t\t\t\t\t * so we prefer either of the first two, but they are\n\t\t\t\t\t * less portable.  The state is tracked in the following\n\t\t\t\t\t * members of PGconn:\n\t\t\t\t\t *\n\t\t\t\t\t * conn->sigpipe_so\t\t- we have set up SO_NOSIGPIPE\n\t\t\t\t\t * conn->sigpipe_flag\t- we're specifying MSG_NOSIGNAL\n\t\t\t\t\t *\n\t\t\t\t\t * If we can use SO_NOSIGPIPE, then set sigpipe_so here\n\t\t\t\t\t * and we're done.  Otherwise, set sigpipe_flag so that\n\t\t\t\t\t * we will try MSG_NOSIGNAL on sends.  If we get an error\n\t\t\t\t\t * with MSG_NOSIGNAL, we'll clear that flag and revert to\n\t\t\t\t\t * signal masking.\n\t\t\t\t\t *----------\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->sigpipe_so = false;\n#ifdef MSG_NOSIGNAL\n\t\t\t\t\tconn->sigpipe_flag = true;\n#else\n\t\t\t\t\tconn->sigpipe_flag = false;\n#endif\t\t\t\t\t\t\t\/* MSG_NOSIGNAL *\/\n\n#ifdef SO_NOSIGPIPE\n\t\t\t\t\toptval = 1;\n\t\t\t\t\tif (setsockopt(conn->sock, SOL_SOCKET, SO_NOSIGPIPE,\n\t\t\t\t\t\t\t\t   (char *) &optval, sizeof(optval)) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->sigpipe_so = true;\n\t\t\t\t\t\tconn->sigpipe_flag = false;\n\t\t\t\t\t}\n#endif\t\t\t\t\t\t\t\/* SO_NOSIGPIPE *\/\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Start\/make connection.  This should not block, since we\n\t\t\t\t\t * are in nonblock mode.  If it does, well, too bad.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (connect(conn->sock, addr_cur->ai_addr,\n\t\t\t\t\t\t\t\taddr_cur->ai_addrlen) < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (SOCK_ERRNO == EINPROGRESS ||\n#ifdef WIN32\n\t\t\t\t\t\t\tSOCK_ERRNO == EWOULDBLOCK ||\n#endif\n\t\t\t\t\t\t\tSOCK_ERRNO == EINTR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/*\n\t\t\t\t\t\t\t * This is fine - we're in non-blocking mode, and\n\t\t\t\t\t\t\t * the connection is in progress.  Tell caller to\n\t\t\t\t\t\t\t * wait for write-ready on socket.\n\t\t\t\t\t\t\t *\/\n\t\t\t\t\t\t\tconn->status = CONNECTION_STARTED;\n\t\t\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/* otherwise, trouble *\/\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Hm, we're connected already --- seems the \"nonblock\n\t\t\t\t\t\t * connection\" wasn't.  Advance the state machine and\n\t\t\t\t\t\t * go do the next stuff.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_STARTED;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * This connection failed.  Add the error report to\n\t\t\t\t\t * conn->errorMessage, then try the next address if any.\n\t\t\t\t\t *\/\n\t\t\t\t\tconnectFailureMessage(conn, SOCK_ERRNO);\n\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase CONNECTION_STARTED:\n\t\t\t{\n\t\t\t\tACCEPT_TYPE_ARG3 optlen = sizeof(optval);\n\n\t\t\t\t\/*\n\t\t\t\t * Write ready, since we've made it here, so the connection\n\t\t\t\t * has been made ... or has failed.\n\t\t\t\t *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Now check (using getsockopt) that there is not an error\n\t\t\t\t * state waiting for us on the socket.\n\t\t\t\t *\/\n\n\t\t\t\tif (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,\n\t\t\t\t\t\t\t   (char *) &optval, &optlen) == -1)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not get socket error status: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\t\t\t\telse if (optval != 0)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * When using a nonblocking connect, we will typically see\n\t\t\t\t\t * connect failures at this point, so provide a friendly\n\t\t\t\t\t * error message.\n\t\t\t\t\t *\/\n\t\t\t\t\tconnectFailureMessage(conn, optval);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Try the next address if any, just as in the case where\n\t\t\t\t\t * connect() returned failure immediately.\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->try_next_addr = true;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/* Fill in the client address *\/\n\t\t\t\tconn->laddr.salen = sizeof(conn->laddr.addr);\n\t\t\t\tif (getsockname(conn->sock,\n\t\t\t\t\t\t\t\t(struct sockaddr *) &conn->laddr.addr,\n\t\t\t\t\t\t\t\t&conn->laddr.salen) < 0)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not get client address from socket: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Make sure we can write before advancing to next step.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t}\n\n\t\tcase CONNECTION_MADE:\n\t\t\t{\n\t\t\t\tchar\t   *startpacket;\n\t\t\t\tint\t\t\tpacketlen;\n\n\t\t\t\t\/*\n\t\t\t\t * Implement requirepeer check, if requested and it's a\n\t\t\t\t * Unix-domain socket.\n\t\t\t\t *\/\n\t\t\t\tif (conn->requirepeer && conn->requirepeer[0] &&\n\t\t\t\t\tIS_AF_UNIX(conn->raddr.addr.ss_family))\n\t\t\t\t{\n#ifndef WIN32\n\t\t\t\t\tchar\t\tpwdbuf[BUFSIZ];\n\t\t\t\t\tstruct passwd pass_buf;\n\t\t\t\t\tstruct passwd *pass;\n\t\t\t\t\tint\t\t\tpasserr;\n#endif\n\t\t\t\t\tuid_t\t\tuid;\n\t\t\t\t\tgid_t\t\tgid;\n\n\t\t\t\t\terrno = 0;\n\t\t\t\t\tif (getpeereid(conn->sock, &uid, &gid) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Provide special error message if getpeereid is a\n\t\t\t\t\t\t * stub\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (errno == ENOSYS)\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"requirepeer parameter is not supported on this platform\\n\"));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not get peer credentials: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  strerror_r(errno, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n#ifndef WIN32\n\t\t\t\t\tpasserr = pqGetpwuid(uid, &pass_buf, pwdbuf, sizeof(pwdbuf), &pass);\n\t\t\t\t\tif (pass == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (passerr != 0)\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not look up local user ID %d: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  (int) uid,\n\t\t\t\t\t\t\t\t\t\t\t  strerror_r(passerr, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"local user with ID %d does not exist\\n\"),\n\t\t\t\t\t\t\t\t\t\t\t  (int) uid);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (strcmp(pass->pw_name, conn->requirepeer) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"requirepeer specifies \\\"%s\\\", but actual peer user name is \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t\t\t  conn->requirepeer, pass->pw_name);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n#else\t\t\t\t\t\t\t\/* WIN32 *\/\n\t\t\t\t\t\/* should have failed with ENOSYS above *\/\n\t\t\t\t\tAssert(false);\n#endif\t\t\t\t\t\t\t\/* WIN32 *\/\n\t\t\t\t}\n\n\t\t\t\tif (IS_AF_UNIX(conn->raddr.addr.ss_family))\n\t\t\t\t{\n\t\t\t\t\t\/* Don't request SSL or GSSAPI over Unix sockets *\/\n#ifdef USE_SSL\n\t\t\t\t\tconn->allow_ssl_try = false;\n#endif\n#ifdef ENABLE_GSS\n\t\t\t\t\tconn->try_gss = false;\n#endif\n\t\t\t\t}\n\n#ifdef ENABLE_GSS\n\n\t\t\t\t\/*\n\t\t\t\t * If GSSAPI encryption is enabled, then call\n\t\t\t\t * pg_GSS_have_cred_cache() which will return true if we can\n\t\t\t\t * acquire credentials (and give us a handle to use in\n\t\t\t\t * conn->gcred), and then send a packet to the server asking\n\t\t\t\t * for GSSAPI Encryption (and skip past SSL negotiation and\n\t\t\t\t * regular startup below).\n\t\t\t\t *\/\n\t\t\t\tif (conn->try_gss && !conn->gctx)\n\t\t\t\t\tconn->try_gss = pg_GSS_have_cred_cache(&conn->gcred);\n\t\t\t\tif (conn->try_gss && !conn->gctx)\n\t\t\t\t{\n\t\t\t\t\tProtocolVersion pv = pg_hton32(NEGOTIATE_GSS_CODE);\n\n\t\t\t\t\tif (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not send GSSAPI negotiation packet: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* Ok, wait for response *\/\n\t\t\t\t\tconn->status = CONNECTION_GSS_STARTUP;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\t\t\t\telse if (!conn->gctx && conn->gssencmode[0] == 'r')\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"GSSAPI encryption required but was impossible (possibly no credential cache, no server support, or using a local socket)\\n\"));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n#endif\n\n#ifdef USE_SSL\n\n\t\t\t\t\/*\n\t\t\t\t * Enable the libcrypto callbacks before checking if SSL needs\n\t\t\t\t * to be done.  This is done before sending the startup packet\n\t\t\t\t * as depending on the type of authentication done, like MD5\n\t\t\t\t * or SCRAM that use cryptohashes, the callbacks would be\n\t\t\t\t * required even without a SSL connection\n\t\t\t\t *\/\n\t\t\t\tif (pqsecure_initialize(conn, false, true) < 0)\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\t\/*\n\t\t\t\t * If SSL is enabled and we haven't already got encryption of\n\t\t\t\t * some sort running, request SSL instead of sending the\n\t\t\t\t * startup message.\n\t\t\t\t *\/\n\t\t\t\tif (conn->allow_ssl_try && !conn->wait_ssl_try &&\n\t\t\t\t\t!conn->ssl_in_use\n#ifdef ENABLE_GSS\n\t\t\t\t\t&& !conn->gssenc\n#endif\n\t\t\t\t\t)\n\t\t\t\t{\n\t\t\t\t\tProtocolVersion pv;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Send the SSL request packet.\n\t\t\t\t\t *\n\t\t\t\t\t * Theoretically, this could block, but it really\n\t\t\t\t\t * shouldn't since we only got here if the socket is\n\t\t\t\t\t * write-ready.\n\t\t\t\t\t *\/\n\t\t\t\t\tpv = pg_hton32(NEGOTIATE_SSL_CODE);\n\t\t\t\t\tif (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not send SSL negotiation packet: %s\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t\t\/* Ok, wait for response *\/\n\t\t\t\t\tconn->status = CONNECTION_SSL_STARTUP;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n#endif\t\t\t\t\t\t\t\/* USE_SSL *\/\n\n\t\t\t\t\/*\n\t\t\t\t * Build the startup packet.\n\t\t\t\t *\/\n\t\t\t\tstartpacket = pqBuildStartupPacket3(conn, &packetlen,\n\t\t\t\t\t\t\t\t\t\t\t\t\tEnvironmentOptions);\n\t\t\t\tif (!startpacket)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"out of memory\\n\"));\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Send the startup packet.\n\t\t\t\t *\n\t\t\t\t * Theoretically, this could block, but it really shouldn't\n\t\t\t\t * since we only got here if the socket is write-ready.\n\t\t\t\t *\/\n\t\t\t\tif (pqPacketSend(conn, 0, startpacket, packetlen) != STATUS_OK)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"could not send startup packet: %s\\n\"),\n\t\t\t\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\t\t\t\tfree(startpacket);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\tfree(startpacket);\n\n\t\t\t\tconn->status = CONNECTION_AWAITING_RESPONSE;\n\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Handle SSL negotiation: wait for postmaster messages and\n\t\t\t * respond as necessary.\n\t\t\t *\/\n\t\tcase CONNECTION_SSL_STARTUP:\n\t\t\t{\n#ifdef USE_SSL\n\t\t\t\tPostgresPollingStatusType pollres;\n\n\t\t\t\t\/*\n\t\t\t\t * On first time through, get the postmaster's response to our\n\t\t\t\t * SSL negotiation packet.\n\t\t\t\t *\/\n\t\t\t\tif (!conn->ssl_in_use)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * We use pqReadData here since it has the logic to\n\t\t\t\t\t * distinguish no-data-yet from connection closure. Since\n\t\t\t\t\t * conn->ssl isn't set, a plain recv() will occur.\n\t\t\t\t\t *\/\n\t\t\t\t\tchar\t\tSSLok;\n\t\t\t\t\tint\t\t\trdresult;\n\n\t\t\t\t\trdresult = pqReadData(conn);\n\t\t\t\t\tif (rdresult < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* errorMessage is already filled in *\/\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t\tif (rdresult == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* caller failed to wait for data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\tif (pqGetc(&SSLok, conn) < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* should not happen really *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\tif (SSLok == 'S')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* mark byte consumed *\/\n\t\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Set up global SSL state if required.  The crypto\n\t\t\t\t\t\t * state has already been set if libpq took care of\n\t\t\t\t\t\t * doing that, so there is no need to make that happen\n\t\t\t\t\t\t * again.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tif (pqsecure_initialize(conn, true, false) != 0)\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t\telse if (SSLok == 'N')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* mark byte consumed *\/\n\t\t\t\t\t\tconn->inStart = conn->inCursor;\n\t\t\t\t\t\t\/* OK to do without SSL? *\/\n\t\t\t\t\t\tif (conn->sslmode[0] == 'r' ||\t\/* \"require\" *\/\n\t\t\t\t\t\t\tconn->sslmode[0] == 'v')\t\/* \"verify-ca\" or\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t * \"verify-full\" *\/\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\/* Require SSL, but server does not want it *\/\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server does not support SSL, but SSL was required\\n\"));\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/* Otherwise, proceed with normal startup *\/\n\t\t\t\t\t\tconn->allow_ssl_try = false;\n\t\t\t\t\t\t\/* We can proceed using this connection *\/\n\t\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t\t}\n\t\t\t\t\telse if (SSLok == 'E')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Server failure of some sort, such as failure to\n\t\t\t\t\t\t * fork a backend process.  We need to process and\n\t\t\t\t\t\t * report the error message, which might be formatted\n\t\t\t\t\t\t * according to either protocol 2 or protocol 3.\n\t\t\t\t\t\t * Rather than duplicate the code for that, we flip\n\t\t\t\t\t\t * into AWAITING_RESPONSE state and let the code there\n\t\t\t\t\t\t * deal with it.  Note we have *not* consumed the \"E\"\n\t\t\t\t\t\t * byte here.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_AWAITING_RESPONSE;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"received invalid response to SSL negotiation: %c\\n\"),\n\t\t\t\t\t\t\t\t\t\t  SSLok);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Begin or continue the SSL negotiation process.\n\t\t\t\t *\/\n\t\t\t\tpollres = pqsecure_open_client(conn);\n\t\t\t\tif (pollres == PGRES_POLLING_OK)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * At this point we should have no data already buffered.\n\t\t\t\t\t * If we do, it was received before we performed the SSL\n\t\t\t\t\t * handshake, so it wasn't encrypted and indeed may have\n\t\t\t\t\t * been injected by a man-in-the-middle.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->inCursor != conn->inEnd)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"received unencrypted data after SSL response\\n\"));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* SSL handshake done, ready to send startup packet *\/\n\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t}\n\t\t\t\tif (pollres == PGRES_POLLING_FAILED)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * Failed ... if sslmode is \"prefer\" then do a non-SSL\n\t\t\t\t\t * retry\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sslmode[0] == 'p' \/* \"prefer\" *\/\n\t\t\t\t\t\t&& conn->allow_ssl_try\t\/* redundant? *\/\n\t\t\t\t\t\t&& !conn->wait_ssl_try) \/* redundant? *\/\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->allow_ssl_try = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t\t\/* Else it's a hard failure *\/\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\t\t\t\t\/* Else, return POLLING_READING or POLLING_WRITING status *\/\n\t\t\t\treturn pollres;\n#else\t\t\t\t\t\t\t\/* !USE_SSL *\/\n\t\t\t\t\/* can't get here *\/\n\t\t\t\tgoto error_return;\n#endif\t\t\t\t\t\t\t\/* USE_SSL *\/\n\t\t\t}\n\n\t\tcase CONNECTION_GSS_STARTUP:\n\t\t\t{\n#ifdef ENABLE_GSS\n\t\t\t\tPostgresPollingStatusType pollres;\n\n\t\t\t\t\/*\n\t\t\t\t * If we haven't yet, get the postmaster's response to our\n\t\t\t\t * negotiation packet\n\t\t\t\t *\/\n\t\t\t\tif (conn->try_gss && !conn->gctx)\n\t\t\t\t{\n\t\t\t\t\tchar\t\tgss_ok;\n\t\t\t\t\tint\t\t\trdresult = pqReadData(conn);\n\n\t\t\t\t\tif (rdresult < 0)\n\t\t\t\t\t\t\/* pqReadData fills in error message *\/\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\telse if (rdresult == 0)\n\t\t\t\t\t\t\/* caller failed to wait for data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\tif (pqGetc(&gss_ok, conn) < 0)\n\t\t\t\t\t\t\/* shouldn't happen... *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\n\t\t\t\t\tif (gss_ok == 'E')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Server failure of some sort.  Assume it's a\n\t\t\t\t\t\t * protocol version support failure, and let's see if\n\t\t\t\t\t\t * we can't recover (if it's not, we'll get a better\n\t\t\t\t\t\t * error message on retry).  Server gets fussy if we\n\t\t\t\t\t\t * don't hang up the socket, though.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* mark byte consumed *\/\n\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\tif (gss_ok == 'N')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Server doesn't want GSSAPI; fall back if we can *\/\n\t\t\t\t\t\tif (conn->gssencmode[0] == 'r')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server doesn't support GSSAPI encryption, but it was required\\n\"));\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\t\t\/* We can proceed using this connection *\/\n\t\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t\t}\n\t\t\t\t\telse if (gss_ok != 'G')\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t  libpq_gettext(\"received invalid response to GSSAPI negotiation: %c\\n\"),\n\t\t\t\t\t\t\t\t\t\t  gss_ok);\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/* Begin or continue GSSAPI negotiation *\/\n\t\t\t\tpollres = pqsecure_open_gss(conn);\n\t\t\t\tif (pollres == PGRES_POLLING_OK)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * At this point we should have no data already buffered.\n\t\t\t\t\t * If we do, it was received before we performed the GSS\n\t\t\t\t\t * handshake, so it wasn't encrypted and indeed may have\n\t\t\t\t\t * been injected by a man-in-the-middle.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->inCursor != conn->inEnd)\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"received unencrypted data after GSSAPI encryption response\\n\"));\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* All set for startup packet *\/\n\t\t\t\t\tconn->status = CONNECTION_MADE;\n\t\t\t\t\treturn PGRES_POLLING_WRITING;\n\t\t\t\t}\n\t\t\t\telse if (pollres == PGRES_POLLING_FAILED &&\n\t\t\t\t\t\t conn->gssencmode[0] == 'p')\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * We failed, but we can retry on \"prefer\".  Have to drop\n\t\t\t\t\t * the current connection to do so, though.\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\t\t\t\treturn pollres;\n#else\t\t\t\t\t\t\t\/* !ENABLE_GSS *\/\n\t\t\t\t\/* unreachable *\/\n\t\t\t\tgoto error_return;\n#endif\t\t\t\t\t\t\t\/* ENABLE_GSS *\/\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Handle authentication exchange: wait for postmaster messages\n\t\t\t * and respond as necessary.\n\t\t\t *\/\n\t\tcase CONNECTION_AWAITING_RESPONSE:\n\t\t\t{\n\t\t\t\tchar\t\tberesp;\n\t\t\t\tint\t\t\tmsgLength;\n\t\t\t\tint\t\t\tavail;\n\t\t\t\tAuthRequest areq;\n\t\t\t\tint\t\t\tres;\n\n\t\t\t\t\/*\n\t\t\t\t * Scan the message from current point (note that if we find\n\t\t\t\t * the message is incomplete, we will return without advancing\n\t\t\t\t * inStart, and resume here next time).\n\t\t\t\t *\/\n\t\t\t\tconn->inCursor = conn->inStart;\n\n\t\t\t\t\/* Read type byte *\/\n\t\t\t\tif (pqGetc(&beresp, conn))\n\t\t\t\t{\n\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Validate message type: we expect only an authentication\n\t\t\t\t * request or an error here.  Anything else probably means\n\t\t\t\t * it's not Postgres on the other end at all.\n\t\t\t\t *\/\n\t\t\t\tif (!(beresp == 'R' || beresp == 'E'))\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"expected authentication request from server, but received %c\\n\"),\n\t\t\t\t\t\t\t\t\t  beresp);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/* Read message length word *\/\n\t\t\t\tif (pqGetInt(&msgLength, 4, conn))\n\t\t\t\t{\n\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Try to validate message length before using it.\n\t\t\t\t * Authentication requests can't be very large, although GSS\n\t\t\t\t * auth requests may not be that small.  Errors can be a\n\t\t\t\t * little larger, but not huge.  If we see a large apparent\n\t\t\t\t * length in an error, it means we're really talking to a\n\t\t\t\t * pre-3.0-protocol server; cope.  (Before version 14, the\n\t\t\t\t * server also used the old protocol for errors that happened\n\t\t\t\t * before processing the startup packet.)\n\t\t\t\t *\/\n\t\t\t\tif (beresp == 'R' && (msgLength < 8 || msgLength > 2000))\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"expected authentication request from server, but received %c\\n\"),\n\t\t\t\t\t\t\t\t\t  beresp);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\tif (beresp == 'E' && (msgLength < 8 || msgLength > 30000))\n\t\t\t\t{\n\t\t\t\t\t\/* Handle error from a pre-3.0 server *\/\n\t\t\t\t\tconn->inCursor = conn->inStart + 1; \/* reread data *\/\n\t\t\t\t\tif (pqGets_append(&conn->errorMessage, conn))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\t\/* OK, we read the message; mark data consumed *\/\n\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Before 7.2, the postmaster didn't always end its\n\t\t\t\t\t * messages with a newline, so add one if needed to\n\t\t\t\t\t * conform to libpq conventions.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->errorMessage.len == 0 ||\n\t\t\t\t\t\tconn->errorMessage.data[conn->errorMessage.len - 1] != '\\n')\n\t\t\t\t\t{\n\t\t\t\t\t\tappendPQExpBufferChar(&conn->errorMessage, '\\n');\n\t\t\t\t\t}\n\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/*\n\t\t\t\t * Can't process if message body isn't all here yet.\n\t\t\t\t *\/\n\t\t\t\tmsgLength -= 4;\n\t\t\t\tavail = conn->inEnd - conn->inCursor;\n\t\t\t\tif (avail < msgLength)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * Before returning, try to enlarge the input buffer if\n\t\t\t\t\t * needed to hold the whole message; see notes in\n\t\t\t\t\t * pqParseInput3.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength,\n\t\t\t\t\t\t\t\t\t\t\t conn))\n\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/* Handle errors. *\/\n\t\t\t\tif (beresp == 'E')\n\t\t\t\t{\n\t\t\t\t\tif (pqGetErrorNotice3(conn, true))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* We'll come back when there is more data *\/\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\t\t\t\t\t\/* OK, we read the message; mark data consumed *\/\n\t\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If error is \"cannot connect now\", try the next host if\n\t\t\t\t\t * any (but we don't want to consider additional addresses\n\t\t\t\t\t * for this host, nor is there much point in changing SSL\n\t\t\t\t\t * or GSS mode).  This is helpful when dealing with\n\t\t\t\t\t * standby servers that might not be in hot-standby state.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (strcmp(conn->last_sqlstate,\n\t\t\t\t\t\t\t   ERRCODE_CANNOT_CONNECT_NOW) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* Check to see if we should mention pgpassfile *\/\n\t\t\t\t\tpgpassfileWarning(conn);\n\n#ifdef ENABLE_GSS\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If gssencmode is \"prefer\" and we're using GSSAPI, retry\n\t\t\t\t\t * without it.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->gssenc && conn->gssencmode[0] == 'p')\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->try_gss = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n#endif\n\n#ifdef USE_SSL\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if sslmode is \"allow\" and we haven't tried an SSL\n\t\t\t\t\t * connection already, then retry with an SSL connection\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sslmode[0] == 'a' \/* \"allow\" *\/\n\t\t\t\t\t\t&& !conn->ssl_in_use\n\t\t\t\t\t\t&& conn->allow_ssl_try\n\t\t\t\t\t\t&& conn->wait_ssl_try)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->wait_ssl_try = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if sslmode is \"prefer\" and we're in an SSL connection,\n\t\t\t\t\t * then do a non-SSL retry\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sslmode[0] == 'p' \/* \"prefer\" *\/\n\t\t\t\t\t\t&& conn->ssl_in_use\n\t\t\t\t\t\t&& conn->allow_ssl_try\t\/* redundant? *\/\n\t\t\t\t\t\t&& !conn->wait_ssl_try) \/* redundant? *\/\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* only retry once *\/\n\t\t\t\t\t\tconn->allow_ssl_try = false;\n\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n#endif\n\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/* It is an authentication request. *\/\n\t\t\t\tconn->auth_req_received = true;\n\n\t\t\t\t\/* Get the type of request. *\/\n\t\t\t\tif (pqGetInt((int *) &areq, 4, conn))\n\t\t\t\t{\n\t\t\t\t\t\/* We'll come back when there are more data *\/\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\t\t\t\tmsgLength -= 4;\n\n\t\t\t\t\/*\n\t\t\t\t * Process the rest of the authentication request message, and\n\t\t\t\t * respond to it if necessary.\n\t\t\t\t *\n\t\t\t\t * Note that conn->pghost must be non-NULL if we are going to\n\t\t\t\t * avoid the Kerberos code doing a hostname look-up.\n\t\t\t\t *\/\n\t\t\t\tres = pg_fe_sendauth(areq, msgLength, conn);\n\n\t\t\t\t\/* OK, we have processed the message; mark data consumed *\/\n\t\t\t\tconn->inStart = conn->inCursor;\n\n\t\t\t\tif (res != STATUS_OK)\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\t\/*\n\t\t\t\t * Just make sure that any data sent by pg_fe_sendauth is\n\t\t\t\t * flushed out.  Although this theoretically could block, it\n\t\t\t\t * really shouldn't since we don't send large auth responses.\n\t\t\t\t *\/\n\t\t\t\tif (pqFlush(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (areq == AUTH_REQ_OK)\n\t\t\t\t{\n\t\t\t\t\t\/* We are done with authentication exchange *\/\n\t\t\t\t\tconn->status = CONNECTION_AUTH_OK;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * Set asyncStatus so that PQgetResult will think that\n\t\t\t\t\t * what comes back next is the result of a query.  See\n\t\t\t\t\t * below.\n\t\t\t\t\t *\/\n\t\t\t\t\tconn->asyncStatus = PGASYNC_BUSY;\n\t\t\t\t}\n\n\t\t\t\t\/* Look to see if we have more data yet. *\/\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_AUTH_OK:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Now we expect to hear from the backend. A ReadyForQuery\n\t\t\t\t * message indicates that startup is successful, but we might\n\t\t\t\t * also get an Error message indicating failure. (Notice\n\t\t\t\t * messages indicating nonfatal warnings are also allowed by\n\t\t\t\t * the protocol, as are ParameterStatus and BackendKeyData\n\t\t\t\t * messages.) Easiest way to handle this is to let\n\t\t\t\t * PQgetResult() read the messages. We just have to fake it\n\t\t\t\t * out about the state of the connection, by setting\n\t\t\t\t * asyncStatus = PGASYNC_BUSY (done above).\n\t\t\t\t *\/\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\n\t\t\t\tres = PQgetResult(conn);\n\n\t\t\t\t\/*\n\t\t\t\t * NULL return indicating we have gone to IDLE state is\n\t\t\t\t * expected\n\t\t\t\t *\/\n\t\t\t\tif (res)\n\t\t\t\t{\n\t\t\t\t\tif (res->resultStatus != PGRES_FATAL_ERROR)\n\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"unexpected message from server during startup\\n\"));\n\t\t\t\t\telse if (conn->send_appname &&\n\t\t\t\t\t\t\t (conn->appname || conn->fbappname))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * If we tried to send application_name, check to see\n\t\t\t\t\t\t * if the error is about that --- pre-9.0 servers will\n\t\t\t\t\t\t * reject it at this stage of the process.  If so,\n\t\t\t\t\t\t * close the connection and retry without sending\n\t\t\t\t\t\t * application_name.  We could possibly get a false\n\t\t\t\t\t\t * SQLSTATE match here and retry uselessly, but there\n\t\t\t\t\t\t * seems no great harm in that; we'll just get the\n\t\t\t\t\t\t * same error again if it's unrelated.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconst char *sqlstate;\n\n\t\t\t\t\t\tsqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);\n\t\t\t\t\t\tif (sqlstate &&\n\t\t\t\t\t\t\tstrcmp(sqlstate, ERRCODE_APPNAME_UNKNOWN) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tPQclear(res);\n\t\t\t\t\t\t\tconn->send_appname = false;\n\t\t\t\t\t\t\tneed_new_connection = true;\n\t\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * if the resultStatus is FATAL, then conn->errorMessage\n\t\t\t\t\t * already has a copy of the error; needn't copy it back.\n\t\t\t\t\t * But add a newline if it's not there already, since\n\t\t\t\t\t * postmaster error messages may not have one.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->errorMessage.len <= 0 ||\n\t\t\t\t\t\tconn->errorMessage.data[conn->errorMessage.len - 1] != '\\n')\n\t\t\t\t\t\tappendPQExpBufferChar(&conn->errorMessage, '\\n');\n\t\t\t\t\tPQclear(res);\n\t\t\t\t\tgoto error_return;\n\t\t\t\t}\n\n\t\t\t\t\/* Almost there now ... *\/\n\t\t\t\tconn->status = CONNECTION_CHECK_TARGET;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_CHECK_TARGET:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * If a read-write, read-only, primary, or standby connection\n\t\t\t\t * is required, see if we have one.\n\t\t\t\t *\/\n\t\t\t\tif (conn->target_server_type == SERVER_TYPE_READ_WRITE ||\n\t\t\t\t\tconn->target_server_type == SERVER_TYPE_READ_ONLY)\n\t\t\t\t{\n\t\t\t\t\tbool\t\tread_only_server;\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * If the server didn't report\n\t\t\t\t\t * \"default_transaction_read_only\" or \"in_hot_standby\" at\n\t\t\t\t\t * startup, we must determine its state by sending the\n\t\t\t\t\t * query \"SHOW transaction_read_only\".  This GUC exists in\n\t\t\t\t\t * all server versions that support 3.0 protocol.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->default_transaction_read_only == PG_BOOL_UNKNOWN ||\n\t\t\t\t\t\tconn->in_hot_standby == PG_BOOL_UNKNOWN)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * We use PQsendQueryContinue so that\n\t\t\t\t\t\t * conn->errorMessage does not get cleared.  We need\n\t\t\t\t\t\t * to preserve any error messages related to previous\n\t\t\t\t\t\t * hosts we have tried and failed to connect to.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tif (!PQsendQueryContinue(conn,\n\t\t\t\t\t\t\t\t\t\t\t\t \"SHOW transaction_read_only\"))\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t\/* We'll return to this state when we have the answer *\/\n\t\t\t\t\t\tconn->status = CONNECTION_CHECK_WRITABLE;\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* OK, we can make the test *\/\n\t\t\t\t\tread_only_server =\n\t\t\t\t\t\t(conn->default_transaction_read_only == PG_BOOL_YES ||\n\t\t\t\t\t\t conn->in_hot_standby == PG_BOOL_YES);\n\n\t\t\t\t\tif ((conn->target_server_type == SERVER_TYPE_READ_WRITE) ?\n\t\t\t\t\t\tread_only_server : !read_only_server)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Wrong server state, reject and try the next host *\/\n\t\t\t\t\t\tif (conn->target_server_type == SERVER_TYPE_READ_WRITE)\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"session is read-only\\n\"));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"session is not read-only\\n\"));\n\n\t\t\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Try next host if any, but we don't want to consider\n\t\t\t\t\t\t * additional addresses for this host.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (conn->target_server_type == SERVER_TYPE_PRIMARY ||\n\t\t\t\t\t\t conn->target_server_type == SERVER_TYPE_STANDBY ||\n\t\t\t\t\t\t conn->target_server_type == SERVER_TYPE_PREFER_STANDBY)\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * If the server didn't report \"in_hot_standby\" at\n\t\t\t\t\t * startup, we must determine its state by sending the\n\t\t\t\t\t * query \"SELECT pg_catalog.pg_is_in_recovery()\".  Servers\n\t\t\t\t\t * before 9.0 don't have that function, but by the same\n\t\t\t\t\t * token they don't have any standby mode, so we may just\n\t\t\t\t\t * assume the result.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (conn->sversion < 90000)\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_NO;\n\n\t\t\t\t\tif (conn->in_hot_standby == PG_BOOL_UNKNOWN)\n\t\t\t\t\t{\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * We use PQsendQueryContinue so that\n\t\t\t\t\t\t * conn->errorMessage does not get cleared.  We need\n\t\t\t\t\t\t * to preserve any error messages related to previous\n\t\t\t\t\t\t * hosts we have tried and failed to connect to.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tif (!PQsendQueryContinue(conn,\n\t\t\t\t\t\t\t\t\t\t\t\t \"SELECT pg_catalog.pg_is_in_recovery()\"))\n\t\t\t\t\t\t\tgoto error_return;\n\t\t\t\t\t\t\/* We'll return to this state when we have the answer *\/\n\t\t\t\t\t\tconn->status = CONNECTION_CHECK_STANDBY;\n\t\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/* OK, we can make the test *\/\n\t\t\t\t\tif ((conn->target_server_type == SERVER_TYPE_PRIMARY) ?\n\t\t\t\t\t\t(conn->in_hot_standby == PG_BOOL_YES) :\n\t\t\t\t\t\t(conn->in_hot_standby == PG_BOOL_NO))\n\t\t\t\t\t{\n\t\t\t\t\t\t\/* Wrong server state, reject and try the next host *\/\n\t\t\t\t\t\tif (conn->target_server_type == SERVER_TYPE_PRIMARY)\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server is in hot standby mode\\n\"));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tappendPQExpBufferStr(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"server is not in hot standby mode\\n\"));\n\n\t\t\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\t\t\/*\n\t\t\t\t\t\t * Try next host if any, but we don't want to consider\n\t\t\t\t\t\t * additional addresses for this host.\n\t\t\t\t\t\t *\/\n\t\t\t\t\t\tconn->try_next_host = true;\n\t\t\t\t\t\tgoto keep_going;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/* We can release the address list now. *\/\n\t\t\t\trelease_conn_addrinfo(conn);\n\n\t\t\t\t\/*\n\t\t\t\t * Contents of conn->errorMessage are no longer interesting\n\t\t\t\t * (and it seems some clients expect it to be empty after a\n\t\t\t\t * successful connection).\n\t\t\t\t *\/\n\t\t\t\tresetPQExpBuffer(&conn->errorMessage);\n\n\t\t\t\t\/* We are open for business! *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\treturn PGRES_POLLING_OK;\n\t\t\t}\n\n\t\tcase CONNECTION_CONSUME:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * This state just makes sure the connection is idle after\n\t\t\t\t * we've obtained the result of a SHOW or SELECT query.  Once\n\t\t\t\t * we're clear, return to CONNECTION_CHECK_TARGET state to\n\t\t\t\t * decide what to do next.  We must transiently set status =\n\t\t\t\t * CONNECTION_OK in order to use the result-consuming\n\t\t\t\t * subroutines.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tif (!PQconsumeInput(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\t\/* Call PQgetResult() again until we get a NULL result *\/\n\t\t\t\tres = PQgetResult(conn);\n\t\t\t\tif (res != NULL)\n\t\t\t\t{\n\t\t\t\t\tPQclear(res);\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\tconn->status = CONNECTION_CHECK_TARGET;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_CHECK_WRITABLE:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Waiting for result of \"SHOW transaction_read_only\".  We\n\t\t\t\t * must transiently set status = CONNECTION_OK in order to use\n\t\t\t\t * the result-consuming subroutines.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tif (!PQconsumeInput(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_CHECK_WRITABLE;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\tres = PQgetResult(conn);\n\t\t\t\tif (res && PQresultStatus(res) == PGRES_TUPLES_OK &&\n\t\t\t\t\tPQntuples(res) == 1)\n\t\t\t\t{\n\t\t\t\t\tchar\t   *val = PQgetvalue(res, 0, 0);\n\n\t\t\t\t\t\/*\n\t\t\t\t\t * \"transaction_read_only = on\" proves that at least one\n\t\t\t\t\t * of default_transaction_read_only and in_hot_standby is\n\t\t\t\t\t * on, but we don't actually know which.  We don't care\n\t\t\t\t\t * though for the purpose of identifying a read-only\n\t\t\t\t\t * session, so satisfy the CONNECTION_CHECK_TARGET code by\n\t\t\t\t\t * claiming they are both on.  On the other hand, if it's\n\t\t\t\t\t * a read-write session, they are certainly both off.\n\t\t\t\t\t *\/\n\t\t\t\t\tif (strncmp(val, \"on\", 2) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->default_transaction_read_only = PG_BOOL_YES;\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_YES;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tconn->default_transaction_read_only = PG_BOOL_NO;\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_NO;\n\t\t\t\t\t}\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\t\/* Finish reading messages before continuing *\/\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/* Something went wrong with \"SHOW transaction_read_only\". *\/\n\t\t\t\tif (res)\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\/* Append error report to conn->errorMessage. *\/\n\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"\\\"%s\\\" failed\\n\"),\n\t\t\t\t\t\t\t\t  \"SHOW transaction_read_only\");\n\n\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\/* Try next host. *\/\n\t\t\t\tconn->try_next_host = true;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tcase CONNECTION_CHECK_STANDBY:\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * Waiting for result of \"SELECT pg_is_in_recovery()\".  We\n\t\t\t\t * must transiently set status = CONNECTION_OK in order to use\n\t\t\t\t * the result-consuming subroutines.\n\t\t\t\t *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tif (!PQconsumeInput(conn))\n\t\t\t\t\tgoto error_return;\n\n\t\t\t\tif (PQisBusy(conn))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_CHECK_STANDBY;\n\t\t\t\t\treturn PGRES_POLLING_READING;\n\t\t\t\t}\n\n\t\t\t\tres = PQgetResult(conn);\n\t\t\t\tif (res && PQresultStatus(res) == PGRES_TUPLES_OK &&\n\t\t\t\t\tPQntuples(res) == 1)\n\t\t\t\t{\n\t\t\t\t\tchar\t   *val = PQgetvalue(res, 0, 0);\n\n\t\t\t\t\tif (strncmp(val, \"t\", 1) == 0)\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_YES;\n\t\t\t\t\telse\n\t\t\t\t\t\tconn->in_hot_standby = PG_BOOL_NO;\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\t\/* Finish reading messages before continuing *\/\n\t\t\t\t\tconn->status = CONNECTION_CONSUME;\n\t\t\t\t\tgoto keep_going;\n\t\t\t\t}\n\n\t\t\t\t\/* Something went wrong with \"SELECT pg_is_in_recovery()\". *\/\n\t\t\t\tif (res)\n\t\t\t\t\tPQclear(res);\n\n\t\t\t\t\/* Append error report to conn->errorMessage. *\/\n\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"\\\"%s\\\" failed\\n\"),\n\t\t\t\t\t\t\t\t  \"SELECT pg_is_in_recovery()\");\n\n\t\t\t\t\/* Close connection politely. *\/\n\t\t\t\tconn->status = CONNECTION_OK;\n\t\t\t\tsendTerminateConn(conn);\n\n\t\t\t\t\/* Try next host. *\/\n\t\t\t\tconn->try_next_host = true;\n\t\t\t\tgoto keep_going;\n\t\t\t}\n\n\t\tdefault:\n\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"invalid connection state %d, \"\n\t\t\t\t\t\t\t\t\t\t\t\"probably indicative of memory corruption\\n\"),\n\t\t\t\t\t\t\t  conn->status);\n\t\t\tgoto error_return;\n\t}\n\n\t\/* Unreachable *\/\n\nerror_return:\n\n\t\/*\n\t * We used to close the socket at this point, but that makes it awkward\n\t * for those above us if they wish to remove this socket from their own\n\t * records (an fd_set for example).  We'll just have this socket closed\n\t * when PQfinish is called (which is compulsory even after an error, since\n\t * the connection structure must be freed).\n\t *\/\n\tconn->status = CONNECTION_BAD;\n\treturn PGRES_POLLING_FAILED;\n}","target":0,"code_token_length":12591,"total_token_length":12827,"max_tokens_setting":28000}
+{"idx":326117,"func":"reg_equi_class(int c)\n{\n    if (enc_utf8 || STRCMP(p_enc, \"latin1\") == 0\n\t\t\t\t\t || STRCMP(p_enc, \"iso-8859-15\") == 0)\n    {\n\tswitch (c)\n\t{\n\t    \/\/ Do not use '\\300' style, it results in a negative number.\n\t    case 'A': case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4:\n\t    case 0xc5: case 0x100: case 0x102: case 0x104: case 0x1cd:\n\t    case 0x1de: case 0x1e0: case 0x1fa: case 0x202: case 0x226:\n\t    case 0x23a: case 0x1e00: case 0x1ea0: case 0x1ea2: case 0x1ea4:\n\t    case 0x1ea6: case 0x1ea8: case 0x1eaa: case 0x1eac: case 0x1eae:\n\t    case 0x1eb0: case 0x1eb2: case 0x1eb4: case 0x1eb6:\n\t\t      regmbc('A'); regmbc(0xc0); regmbc(0xc1); regmbc(0xc2);\n\t\t      regmbc(0xc3); regmbc(0xc4); regmbc(0xc5);\n\t\t      regmbc(0x100); regmbc(0x102); regmbc(0x104);\n\t\t      regmbc(0x1cd); regmbc(0x1de); regmbc(0x1e0);\n\t\t      regmbc(0x1fa); regmbc(0x202); regmbc(0x226);\n\t\t      regmbc(0x23a); regmbc(0x1e00); regmbc(0x1ea0);\n\t\t      regmbc(0x1ea2); regmbc(0x1ea4); regmbc(0x1ea6);\n\t\t      regmbc(0x1ea8); regmbc(0x1eaa); regmbc(0x1eac);\n\t\t      regmbc(0x1eae); regmbc(0x1eb0); regmbc(0x1eb2);\n\t\t      regmbc(0x1eb4); regmbc(0x1eb6);\n\t\t      return;\n\t    case 'B': case 0x181: case 0x243: case 0x1e02:\n\t    case 0x1e04: case 0x1e06:\n\t\t      regmbc('B');\n\t\t      regmbc(0x181); regmbc(0x243); regmbc(0x1e02);\n\t\t      regmbc(0x1e04); regmbc(0x1e06);\n\t\t      return;\n\t    case 'C': case 0xc7:\n\t    case 0x106: case 0x108: case 0x10a: case 0x10c: case 0x187:\n\t    case 0x23b: case 0x1e08: case 0xa792:\n\t\t      regmbc('C'); regmbc(0xc7);\n\t\t      regmbc(0x106); regmbc(0x108); regmbc(0x10a);\n\t\t      regmbc(0x10c); regmbc(0x187); regmbc(0x23b);\n\t\t      regmbc(0x1e08); regmbc(0xa792);\n\t\t      return;\n\t    case 'D': case 0x10e: case 0x110: case 0x18a:\n\t    case 0x1e0a: case 0x1e0c: case 0x1e0e: case 0x1e10:\n\t    case 0x1e12:\n\t\t      regmbc('D'); regmbc(0x10e); regmbc(0x110);\n\t\t      regmbc(0x18a); regmbc(0x1e0a); regmbc(0x1e0c);\n\t\t      regmbc(0x1e0e); regmbc(0x1e10); regmbc(0x1e12);\n\t\t      return;\n\t    case 'E': case 0xc8: case 0xc9: case 0xca: case 0xcb:\n\t    case 0x112: case 0x114: case 0x116: case 0x118: case 0x11a:\n\t    case 0x204: case 0x206: case 0x228: case 0x246: case 0x1e14:\n\t    case 0x1e16: case 0x1e18: case 0x1e1a: case 0x1e1c:\n\t    case 0x1eb8: case 0x1eba: case 0x1ebc: case 0x1ebe:\n\t    case 0x1ec0: case 0x1ec2: case 0x1ec4: case 0x1ec6:\n\t\t      regmbc('E'); regmbc(0xc8); regmbc(0xc9);\n\t\t      regmbc(0xca); regmbc(0xcb); regmbc(0x112);\n\t\t      regmbc(0x114); regmbc(0x116); regmbc(0x118);\n\t\t      regmbc(0x11a); regmbc(0x204); regmbc(0x206);\n\t\t      regmbc(0x228); regmbc(0x246); regmbc(0x1e14);\n\t\t      regmbc(0x1e16); regmbc(0x1e18); regmbc(0x1e1a);\n\t\t      regmbc(0x1e1c); regmbc(0x1eb8); regmbc(0x1eba);\n\t\t      regmbc(0x1ebc); regmbc(0x1ebe); regmbc(0x1ec0);\n\t\t      regmbc(0x1ec2); regmbc(0x1ec4); regmbc(0x1ec6);\n\t\t      return;\n\t    case 'F': case 0x191: case 0x1e1e: case 0xa798:\n\t\t      regmbc('F'); regmbc(0x191); regmbc(0x1e1e);\n\t\t      regmbc(0xa798);\n\t\t      return;\n\t    case 'G': case 0x11c: case 0x11e: case 0x120:\n\t    case 0x122: case 0x193: case 0x1e4: case 0x1e6:\n\t    case 0x1f4: case 0x1e20: case 0xa7a0:\n\t\t      regmbc('G'); regmbc(0x11c); regmbc(0x11e);\n\t\t      regmbc(0x120); regmbc(0x122); regmbc(0x193);\n\t\t      regmbc(0x1e4); regmbc(0x1e6); regmbc(0x1f4);\n\t\t      regmbc(0x1e20); regmbc(0xa7a0);\n\t\t      return;\n\t    case 'H': case 0x124: case 0x126: case 0x21e:\n\t    case 0x1e22: case 0x1e24: case 0x1e26:\n\t    case 0x1e28: case 0x1e2a: case 0x2c67:\n\t\t      regmbc('H'); regmbc(0x124); regmbc(0x126);\n\t\t      regmbc(0x21e); regmbc(0x1e22); regmbc(0x1e24);\n\t\t      regmbc(0x1e26); regmbc(0x1e28); regmbc(0x1e2a);\n\t\t      regmbc(0x2c67);\n\t\t      return;\n\t    case 'I': case 0xcc: case 0xcd: case 0xce: case 0xcf:\n\t    case 0x128: case 0x12a: case 0x12c: case 0x12e:\n\t    case 0x130: case 0x197: case 0x1cf: case 0x208:\n\t    case 0x20a: case 0x1e2c: case 0x1e2e: case 0x1ec8:\n\t    case 0x1eca:\n\t\t      regmbc('I'); regmbc(0xcc); regmbc(0xcd);\n\t\t      regmbc(0xce); regmbc(0xcf); regmbc(0x128);\n\t\t      regmbc(0x12a); regmbc(0x12c); regmbc(0x12e);\n\t\t      regmbc(0x130); regmbc(0x197); regmbc(0x1cf);\n\t\t      regmbc(0x208); regmbc(0x20a); regmbc(0x1e2c);\n\t\t      regmbc(0x1e2e); regmbc(0x1ec8); regmbc(0x1eca);\n\t\t      return;\n\t    case 'J': case 0x134: case 0x248:\n\t\t      regmbc('J'); regmbc(0x134); regmbc(0x248);\n\t\t      return;\n\t    case 'K': case 0x136: case 0x198: case 0x1e8: case 0x1e30:\n\t    case 0x1e32: case 0x1e34: case 0x2c69: case 0xa740:\n\t\t      regmbc('K'); regmbc(0x136); regmbc(0x198);\n\t\t      regmbc(0x1e8); regmbc(0x1e30); regmbc(0x1e32);\n\t\t      regmbc(0x1e34); regmbc(0x2c69); regmbc(0xa740);\n\t\t      return;\n\t    case 'L': case 0x139: case 0x13b: case 0x13d: case 0x13f:\n\t    case 0x141: case 0x23d: case 0x1e36: case 0x1e38:\n\t    case 0x1e3a: case 0x1e3c: case 0x2c60:\n\t\t      regmbc('L'); regmbc(0x139); regmbc(0x13b);\n\t\t      regmbc(0x13d); regmbc(0x13f); regmbc(0x141);\n\t\t      regmbc(0x23d); regmbc(0x1e36); regmbc(0x1e38);\n\t\t      regmbc(0x1e3a); regmbc(0x1e3c); regmbc(0x2c60);\n\t\t      return;\n\t    case 'M': case 0x1e3e: case 0x1e40: case 0x1e42:\n\t\t      regmbc('M'); regmbc(0x1e3e); regmbc(0x1e40);\n\t\t      regmbc(0x1e42);\n\t\t      return;\n\t    case 'N': case 0xd1:\n\t    case 0x143: case 0x145: case 0x147: case 0x1f8:\n\t    case 0x1e44: case 0x1e46: case 0x1e48: case 0x1e4a:\n\t    case 0xa7a4:\n\t\t      regmbc('N'); regmbc(0xd1);\n\t\t      regmbc(0x143); regmbc(0x145); regmbc(0x147);\n\t\t      regmbc(0x1f8); regmbc(0x1e44); regmbc(0x1e46);\n\t\t      regmbc(0x1e48); regmbc(0x1e4a); regmbc(0xa7a4);\n\t\t      return;\n\t    case 'O': case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6:\n\t    case 0xd8: case 0x14c: case 0x14e: case 0x150: case 0x19f:\n\t    case 0x1a0: case 0x1d1: case 0x1ea: case 0x1ec: case 0x1fe:\n\t    case 0x20c: case 0x20e: case 0x22a: case 0x22c: case 0x22e:\n\t    case 0x230: case 0x1e4c: case 0x1e4e: case 0x1e50: case 0x1e52:\n\t    case 0x1ecc: case 0x1ece: case 0x1ed0: case 0x1ed2: case 0x1ed4:\n\t    case 0x1ed6: case 0x1ed8: case 0x1eda: case 0x1edc: case 0x1ede:\n\t    case 0x1ee0: case 0x1ee2:\n\t\t      regmbc('O'); regmbc(0xd2); regmbc(0xd3); regmbc(0xd4);\n\t\t      regmbc(0xd5); regmbc(0xd6); regmbc(0xd8);\n\t\t      regmbc(0x14c); regmbc(0x14e); regmbc(0x150);\n\t\t      regmbc(0x19f); regmbc(0x1a0); regmbc(0x1d1);\n\t\t      regmbc(0x1ea); regmbc(0x1ec); regmbc(0x1fe);\n\t\t      regmbc(0x20c); regmbc(0x20e); regmbc(0x22a);\n\t\t      regmbc(0x22c); regmbc(0x22e); regmbc(0x230);\n\t\t      regmbc(0x1e4c); regmbc(0x1e4e); regmbc(0x1e50);\n\t\t      regmbc(0x1e52); regmbc(0x1ecc); regmbc(0x1ece);\n\t\t      regmbc(0x1ed0); regmbc(0x1ed2); regmbc(0x1ed4);\n\t\t      regmbc(0x1ed6); regmbc(0x1ed8); regmbc(0x1eda);\n\t\t      regmbc(0x1edc); regmbc(0x1ede); regmbc(0x1ee0);\n\t\t      regmbc(0x1ee2);\n\t\t      return;\n\t    case 'P': case 0x1a4: case 0x1e54: case 0x1e56: case 0x2c63:\n\t\t      regmbc('P'); regmbc(0x1a4); regmbc(0x1e54);\n\t\t      regmbc(0x1e56); regmbc(0x2c63);\n\t\t      return;\n\t    case 'Q': case 0x24a:\n\t\t      regmbc('Q'); regmbc(0x24a);\n\t\t      return;\n\t    case 'R': case 0x154: case 0x156: case 0x158: case 0x210:\n\t    case 0x212: case 0x24c: case 0x1e58: case 0x1e5a:\n\t    case 0x1e5c: case 0x1e5e: case 0x2c64: case 0xa7a6:\n\t\t      regmbc('R'); regmbc(0x154); regmbc(0x156);\n\t\t      regmbc(0x210); regmbc(0x212); regmbc(0x158);\n\t\t      regmbc(0x24c); regmbc(0x1e58); regmbc(0x1e5a);\n\t\t      regmbc(0x1e5c); regmbc(0x1e5e); regmbc(0x2c64);\n\t\t      regmbc(0xa7a6);\n\t\t      return;\n\t    case 'S': case 0x15a: case 0x15c: case 0x15e: case 0x160:\n\t    case 0x218: case 0x1e60: case 0x1e62: case 0x1e64:\n\t    case 0x1e66: case 0x1e68: case 0x2c7e: case 0xa7a8:\n\t\t      regmbc('S'); regmbc(0x15a); regmbc(0x15c);\n\t\t      regmbc(0x15e); regmbc(0x160); regmbc(0x218);\n\t\t      regmbc(0x1e60); regmbc(0x1e62); regmbc(0x1e64);\n\t\t      regmbc(0x1e66); regmbc(0x1e68); regmbc(0x2c7e);\n\t\t\t  regmbc(0xa7a8);\n\t\t      return;\n\t    case 'T': case 0x162: case 0x164: case 0x166: case 0x1ac:\n\t    case 0x1ae: case 0x21a: case 0x23e: case 0x1e6a: case 0x1e6c:\n\t    case 0x1e6e: case 0x1e70:\n\t\t      regmbc('T'); regmbc(0x162); regmbc(0x164);\n\t\t      regmbc(0x166); regmbc(0x1ac); regmbc(0x23e);\n\t\t      regmbc(0x1ae); regmbc(0x21a); regmbc(0x1e6a);\n\t\t      regmbc(0x1e6c); regmbc(0x1e6e); regmbc(0x1e70);\n\t\t      return;\n\t    case 'U': case 0xd9: case 0xda: case 0xdb: case 0xdc:\n\t    case 0x168: case 0x16a: case 0x16c: case 0x16e:\n\t    case 0x170: case 0x172: case 0x1af: case 0x1d3:\n\t    case 0x1d5: case 0x1d7: case 0x1d9: case 0x1db:\n\t    case 0x214: case 0x216: case 0x244: case 0x1e72:\n\t    case 0x1e74: case 0x1e76: case 0x1e78: case 0x1e7a:\n\t    case 0x1ee4: case 0x1ee6: case 0x1ee8: case 0x1eea:\n\t    case 0x1eec: case 0x1eee: case 0x1ef0:\n\t\t      regmbc('U'); regmbc(0xd9); regmbc(0xda);\n\t\t      regmbc(0xdb); regmbc(0xdc); regmbc(0x168);\n\t\t      regmbc(0x16a); regmbc(0x16c); regmbc(0x16e);\n\t\t      regmbc(0x170); regmbc(0x172); regmbc(0x1af);\n\t\t      regmbc(0x1d3); regmbc(0x1d5); regmbc(0x1d7);\n\t\t      regmbc(0x1d9); regmbc(0x1db); regmbc(0x214);\n\t\t      regmbc(0x216); regmbc(0x244); regmbc(0x1e72);\n\t\t      regmbc(0x1e74); regmbc(0x1e76); regmbc(0x1e78);\n\t\t      regmbc(0x1e7a); regmbc(0x1ee4); regmbc(0x1ee6);\n\t\t      regmbc(0x1ee8); regmbc(0x1eea); regmbc(0x1eec);\n\t\t      regmbc(0x1eee); regmbc(0x1ef0);\n\t\t      return;\n\t    case 'V': case 0x1b2: case 0x1e7c: case 0x1e7e:\n\t\t      regmbc('V'); regmbc(0x1b2); regmbc(0x1e7c);\n\t\t      regmbc(0x1e7e);\n\t\t      return;\n\t    case 'W': case 0x174: case 0x1e80: case 0x1e82:\n\t    case 0x1e84: case 0x1e86: case 0x1e88:\n\t\t      regmbc('W'); regmbc(0x174); regmbc(0x1e80);\n\t\t      regmbc(0x1e82); regmbc(0x1e84); regmbc(0x1e86);\n\t\t      regmbc(0x1e88);\n\t\t      return;\n\t    case 'X': case 0x1e8a: case 0x1e8c:\n\t\t      regmbc('X'); regmbc(0x1e8a); regmbc(0x1e8c);\n\t\t      return;\n\t    case 'Y': case 0xdd:\n\t    case 0x176: case 0x178: case 0x1b3: case 0x232: case 0x24e:\n\t    case 0x1e8e: case 0x1ef2: case 0x1ef6: case 0x1ef4: case 0x1ef8:\n\t\t      regmbc('Y'); regmbc(0xdd); regmbc(0x176);\n\t\t      regmbc(0x178); regmbc(0x1b3); regmbc(0x232);\n\t\t      regmbc(0x24e); regmbc(0x1e8e); regmbc(0x1ef2);\n\t\t      regmbc(0x1ef4); regmbc(0x1ef6); regmbc(0x1ef8);\n\t\t      return;\n\t    case 'Z': case 0x179: case 0x17b: case 0x17d: case 0x1b5:\n\t    case 0x1e90: case 0x1e92: case 0x1e94: case 0x2c6b:\n\t\t      regmbc('Z'); regmbc(0x179); regmbc(0x17b);\n\t\t      regmbc(0x17d); regmbc(0x1b5); regmbc(0x1e90);\n\t\t      regmbc(0x1e92); regmbc(0x1e94); regmbc(0x2c6b);\n\t\t      return;\n\t    case 'a': case 0xe0: case 0xe1: case 0xe2:\n\t    case 0xe3: case 0xe4: case 0xe5: case 0x101: case 0x103:\n\t    case 0x105: case 0x1ce: case 0x1df: case 0x1e1: case 0x1fb:\n\t    case 0x201: case 0x203: case 0x227: case 0x1d8f: case 0x1e01:\n\t    case 0x1e9a: case 0x1ea1: case 0x1ea3: case 0x1ea5:\n\t    case 0x1ea7: case 0x1ea9: case 0x1eab: case 0x1ead:\n\t    case 0x1eaf: case 0x1eb1: case 0x1eb3: case 0x1eb5:\n\t    case 0x1eb7: case 0x2c65:\n\t\t      regmbc('a'); regmbc(0xe0); regmbc(0xe1);\n\t\t      regmbc(0xe2); regmbc(0xe3); regmbc(0xe4);\n\t\t      regmbc(0xe5); regmbc(0x101); regmbc(0x103);\n\t\t      regmbc(0x105); regmbc(0x1ce); regmbc(0x1df);\n\t\t      regmbc(0x1e1); regmbc(0x1fb); regmbc(0x201);\n\t\t      regmbc(0x203); regmbc(0x227); regmbc(0x1d8f);\n\t\t      regmbc(0x1e01); regmbc(0x1e9a); regmbc(0x1ea1);\n\t\t      regmbc(0x1ea3); regmbc(0x1ea5); regmbc(0x1ea7);\n\t\t      regmbc(0x1ea9); regmbc(0x1eab); regmbc(0x1ead);\n\t\t      regmbc(0x1eaf); regmbc(0x1eb1); regmbc(0x1eb3);\n\t\t      regmbc(0x1eb5); regmbc(0x1eb7); regmbc(0x2c65);\n\t\t      return;\n\t    case 'b': case 0x180: case 0x253: case 0x1d6c: case 0x1d80:\n\t    case 0x1e03: case 0x1e05: case 0x1e07:\n\t\t      regmbc('b');\n\t\t      regmbc(0x180); regmbc(0x253); regmbc(0x1d6c);\n\t\t      regmbc(0x1d80); regmbc(0x1e03); regmbc(0x1e05);\n\t\t      regmbc(0x1e07);\n\t\t      return;\n\t    case 'c': case 0xe7:\n\t    case 0x107: case 0x109: case 0x10b: case 0x10d: case 0x188:\n\t    case 0x23c: case 0x1e09: case 0xa793: case 0xa794:\n\t\t      regmbc('c'); regmbc(0xe7); regmbc(0x107);\n\t\t      regmbc(0x109); regmbc(0x10b); regmbc(0x10d);\n\t\t      regmbc(0x188); regmbc(0x23c); regmbc(0x1e09);\n\t\t      regmbc(0xa793); regmbc(0xa794);\n\t\t      return;\n\t    case 'd': case 0x10f: case 0x111: case 0x257: case 0x1d6d:\n\t    case 0x1d81: case 0x1d91: case 0x1e0b: case 0x1e0d:\n\t    case 0x1e0f: case 0x1e11: case 0x1e13:\n\t\t      regmbc('d'); regmbc(0x10f); regmbc(0x111);\n\t\t      regmbc(0x257); regmbc(0x1d6d); regmbc(0x1d81);\n\t\t      regmbc(0x1d91); regmbc(0x1e0b); regmbc(0x1e0d);\n\t\t      regmbc(0x1e0f); regmbc(0x1e11); regmbc(0x1e13);\n\t\t      return;\n\t    case 'e': case 0xe8: case 0xe9: case 0xea: case 0xeb:\n\t    case 0x113: case 0x115: case 0x117: case 0x119:\n\t    case 0x11b: case 0x205: case 0x207: case 0x229:\n\t    case 0x247: case 0x1d92: case 0x1e15: case 0x1e17:\n\t    case 0x1e19: case 0x1e1b: case 0x1eb9: case 0x1ebb:\n\t    case 0x1e1d: case 0x1ebd: case 0x1ebf: case 0x1ec1:\n\t    case 0x1ec3: case 0x1ec5: case 0x1ec7:\n\t\t      regmbc('e'); regmbc(0xe8); regmbc(0xe9);\n\t\t      regmbc(0xea); regmbc(0xeb); regmbc(0x113);\n\t\t      regmbc(0x115); regmbc(0x117); regmbc(0x119);\n\t\t      regmbc(0x11b); regmbc(0x205); regmbc(0x207);\n\t\t      regmbc(0x229); regmbc(0x247); regmbc(0x1d92);\n\t\t      regmbc(0x1e15); regmbc(0x1e17); regmbc(0x1e19);\n\t\t      regmbc(0x1e1b); regmbc(0x1e1d); regmbc(0x1eb9);\n\t\t      regmbc(0x1ebb); regmbc(0x1ebd); regmbc(0x1ebf);\n\t\t      regmbc(0x1ec1); regmbc(0x1ec3); regmbc(0x1ec5);\n\t\t      regmbc(0x1ec7);\n\t\t      return;\n\t    case 'f': case 0x192: case 0x1d6e: case 0x1d82:\n\t    case 0x1e1f: case 0xa799:\n\t\t     regmbc('f'); regmbc(0x192); regmbc(0x1d6e);\n\t\t     regmbc(0x1d82); regmbc(0x1e1f); regmbc(0xa799);\n\t\t     return;\n\t    case 'g': case 0x11d: case 0x11f: case 0x121: case 0x123:\n\t    case 0x1e5: case 0x1e7: case 0x260: case 0x1f5: case 0x1d83:\n\t    case 0x1e21: case 0xa7a1:\n\t\t      regmbc('g'); regmbc(0x11d); regmbc(0x11f);\n\t\t      regmbc(0x121); regmbc(0x123); regmbc(0x1e5);\n\t\t      regmbc(0x1e7); regmbc(0x1f5); regmbc(0x260);\n\t\t      regmbc(0x1d83); regmbc(0x1e21); regmbc(0xa7a1);\n\t\t      return;\n\t    case 'h': case 0x125: case 0x127: case 0x21f: case 0x1e23:\n\t    case 0x1e25: case 0x1e27: case 0x1e29: case 0x1e2b:\n\t    case 0x1e96: case 0x2c68: case 0xa795:\n\t\t      regmbc('h'); regmbc(0x125); regmbc(0x127);\n\t\t      regmbc(0x21f); regmbc(0x1e23); regmbc(0x1e25);\n\t\t      regmbc(0x1e27); regmbc(0x1e29); regmbc(0x1e2b);\n\t\t      regmbc(0x1e96); regmbc(0x2c68); regmbc(0xa795);\n\t\t      return;\n\t    case 'i': case 0xec: case 0xed: case 0xee: case 0xef:\n\t    case 0x129: case 0x12b: case 0x12d: case 0x12f:\n\t    case 0x1d0: case 0x209: case 0x20b: case 0x268:\n\t    case 0x1d96: case 0x1e2d: case 0x1e2f: case 0x1ec9:\n\t    case 0x1ecb:\n\t\t      regmbc('i'); regmbc(0xec); regmbc(0xed);\n\t\t      regmbc(0xee); regmbc(0xef); regmbc(0x129);\n\t\t      regmbc(0x12b); regmbc(0x12d); regmbc(0x12f);\n\t\t      regmbc(0x1d0); regmbc(0x209); regmbc(0x20b);\n\t\t      regmbc(0x268); regmbc(0x1d96); regmbc(0x1e2d);\n\t\t      regmbc(0x1e2f); regmbc(0x1ec9); regmbc(0x1ecb);\n\t\t      return;\n\t    case 'j': case 0x135: case 0x1f0: case 0x249:\n\t\t      regmbc('j'); regmbc(0x135); regmbc(0x1f0);\n\t\t      regmbc(0x249);\n\t\t      return;\n\t    case 'k': case 0x137: case 0x199: case 0x1e9:\n\t    case 0x1d84: case 0x1e31: case 0x1e33: case 0x1e35:\n\t    case 0x2c6a: case 0xa741:\n\t\t      regmbc('k'); regmbc(0x137); regmbc(0x199);\n\t\t      regmbc(0x1e9); regmbc(0x1d84); regmbc(0x1e31);\n\t\t      regmbc(0x1e33); regmbc(0x1e35); regmbc(0x2c6a);\n\t\t      regmbc(0xa741);\n\t\t      return;\n\t    case 'l': case 0x13a: case 0x13c: case 0x13e:\n\t    case 0x140: case 0x142: case 0x19a: case 0x1e37:\n\t    case 0x1e39: case 0x1e3b: case 0x1e3d: case 0x2c61:\n\t\t      regmbc('l'); regmbc(0x13a); regmbc(0x13c);\n\t\t      regmbc(0x13e); regmbc(0x140); regmbc(0x142);\n\t\t      regmbc(0x19a); regmbc(0x1e37); regmbc(0x1e39);\n\t\t      regmbc(0x1e3b); regmbc(0x1e3d); regmbc(0x2c61);\n\t\t      return;\n\t    case 'm': case 0x1d6f: case 0x1e3f: case 0x1e41: case 0x1e43:\n\t\t      regmbc('m'); regmbc(0x1d6f); regmbc(0x1e3f);\n\t\t      regmbc(0x1e41); regmbc(0x1e43);\n\t\t      return;\n\t    case 'n': case 0xf1: case 0x144: case 0x146: case 0x148:\n\t    case 0x149: case 0x1f9: case 0x1d70: case 0x1d87:\n\t    case 0x1e45: case 0x1e47: case 0x1e49: case 0x1e4b:\n\t    case 0xa7a5:\n\t\t      regmbc('n'); regmbc(0xf1); regmbc(0x144);\n\t\t      regmbc(0x146); regmbc(0x148); regmbc(0x149);\n\t\t      regmbc(0x1f9); regmbc(0x1d70); regmbc(0x1d87);\n\t\t      regmbc(0x1e45); regmbc(0x1e47); regmbc(0x1e49);\n\t\t      regmbc(0x1e4b); regmbc(0xa7a5);\n\t\t      return;\n\t    case 'o': case 0xf2: case 0xf3: case 0xf4: case 0xf5:\n\t    case 0xf6: case 0xf8: case 0x14d: case 0x14f: case 0x151:\n\t    case 0x1a1: case 0x1d2: case 0x1eb: case 0x1ed: case 0x1ff:\n\t    case 0x20d: case 0x20f: case 0x22b: case 0x22d: case 0x22f:\n\t    case 0x231: case 0x275: case 0x1e4d: case 0x1e4f:\n\t    case 0x1e51: case 0x1e53: case 0x1ecd: case 0x1ecf:\n\t    case 0x1ed1: case 0x1ed3: case 0x1ed5: case 0x1ed7:\n\t    case 0x1ed9: case 0x1edb: case 0x1edd: case 0x1edf:\n\t    case 0x1ee1: case 0x1ee3:\n\t\t      regmbc('o'); regmbc(0xf2); regmbc(0xf3);\n\t\t      regmbc(0xf4); regmbc(0xf5); regmbc(0xf6);\n\t\t      regmbc(0xf8); regmbc(0x14d); regmbc(0x14f);\n\t\t      regmbc(0x151); regmbc(0x1a1); regmbc(0x1d2);\n\t\t      regmbc(0x1eb); regmbc(0x1ed); regmbc(0x1ff);\n\t\t      regmbc(0x20d); regmbc(0x20f); regmbc(0x22b);\n\t\t      regmbc(0x22d); regmbc(0x22f); regmbc(0x231);\n\t\t      regmbc(0x275); regmbc(0x1e4d); regmbc(0x1e4f);\n\t\t      regmbc(0x1e51); regmbc(0x1e53); regmbc(0x1ecd);\n\t\t      regmbc(0x1ecf); regmbc(0x1ed1); regmbc(0x1ed3);\n\t\t      regmbc(0x1ed5); regmbc(0x1ed7); regmbc(0x1ed9);\n\t\t      regmbc(0x1edb); regmbc(0x1edd); regmbc(0x1edf);\n\t\t      regmbc(0x1ee1); regmbc(0x1ee3);\n\t\t      return;\n\t    case 'p': case 0x1a5: case 0x1d71: case 0x1d88: case 0x1d7d:\n\t    case 0x1e55: case 0x1e57:\n\t\t      regmbc('p'); regmbc(0x1a5); regmbc(0x1d71);\n\t\t      regmbc(0x1d7d); regmbc(0x1d88); regmbc(0x1e55);\n\t\t      regmbc(0x1e57);\n\t\t      return;\n\t    case 'q': case 0x24b: case 0x2a0:\n\t\t      regmbc('q'); regmbc(0x24b); regmbc(0x2a0);\n\t\t      return;\n\t    case 'r': case 0x155: case 0x157: case 0x159: case 0x211:\n\t    case 0x213: case 0x24d: case 0x27d: case 0x1d72: case 0x1d73:\n\t    case 0x1d89: case 0x1e59: case 0x1e5b: case 0x1e5d: case 0x1e5f:\n\t    case 0xa7a7:\n\t\t      regmbc('r'); regmbc(0x155); regmbc(0x157);\n\t\t      regmbc(0x159); regmbc(0x211); regmbc(0x213);\n\t\t      regmbc(0x24d); regmbc(0x1d72); regmbc(0x1d73);\n\t\t      regmbc(0x1d89); regmbc(0x1e59); regmbc(0x27d);\n\t\t      regmbc(0x1e5b); regmbc(0x1e5d); regmbc(0x1e5f);\n\t\t      regmbc(0xa7a7);\n\t\t      return;\n\t    case 's': case 0x15b: case 0x15d: case 0x15f: case 0x161:\n\t    case 0x1e61: case 0x219: case 0x23f: case 0x1d74: case 0x1d8a:\n\t    case 0x1e63: case 0x1e65: case 0x1e67: case 0x1e69: case 0xa7a9:\n\t\t      regmbc('s'); regmbc(0x15b); regmbc(0x15d);\n\t\t      regmbc(0x15f); regmbc(0x161); regmbc(0x23f);\n\t\t      regmbc(0x219); regmbc(0x1d74); regmbc(0x1d8a);\n\t\t      regmbc(0x1e61); regmbc(0x1e63); regmbc(0x1e65);\n\t\t      regmbc(0x1e67); regmbc(0x1e69); regmbc(0xa7a9);\n\t\t      return;\n\t    case 't': case 0x163: case 0x165: case 0x167: case 0x1ab:\n\t    case 0x1ad: case 0x21b: case 0x288: case 0x1d75: case 0x1e6b:\n\t    case 0x1e6d: case 0x1e6f: case 0x1e71: case 0x1e97: case 0x2c66:\n\t\t      regmbc('t'); regmbc(0x163); regmbc(0x165);\n\t\t      regmbc(0x167); regmbc(0x1ab); regmbc(0x21b);\n\t\t      regmbc(0x1ad); regmbc(0x288); regmbc(0x1d75);\n\t\t      regmbc(0x1e6b); regmbc(0x1e6d); regmbc(0x1e6f);\n\t\t      regmbc(0x1e71); regmbc(0x1e97); regmbc(0x2c66);\n\t\t      return;\n\t    case 'u': case 0xf9: case 0xfa: case 0xfb: case 0xfc:\n\t    case 0x169: case 0x16b: case 0x16d: case 0x16f:\n\t    case 0x171: case 0x173: case 0x1b0: case 0x1d4:\n\t    case 0x1d6: case 0x1d8: case 0x1da: case 0x1dc:\n\t    case 0x215: case 0x217: case 0x289: case 0x1e73:\n\t    case 0x1d7e: case 0x1d99: case 0x1e75: case 0x1e77:\n\t    case 0x1e79: case 0x1e7b: case 0x1ee5: case 0x1ee7:\n\t    case 0x1ee9: case 0x1eeb: case 0x1eed: case 0x1eef:\n\t    case 0x1ef1:\n\t\t      regmbc('u'); regmbc(0xf9); regmbc(0xfa);\n\t\t      regmbc(0xfb); regmbc(0xfc); regmbc(0x169);\n\t\t      regmbc(0x16b); regmbc(0x16d); regmbc(0x16f);\n\t\t      regmbc(0x171); regmbc(0x173); regmbc(0x1d6);\n\t\t      regmbc(0x1d8); regmbc(0x1da); regmbc(0x1dc);\n\t\t      regmbc(0x215); regmbc(0x217); regmbc(0x1b0);\n\t\t      regmbc(0x1d4); regmbc(0x289); regmbc(0x1d7e);\n\t\t      regmbc(0x1d99); regmbc(0x1e73); regmbc(0x1e75);\n\t\t      regmbc(0x1e77); regmbc(0x1e79); regmbc(0x1e7b);\n\t\t      regmbc(0x1ee5); regmbc(0x1ee7); regmbc(0x1ee9);\n\t\t      regmbc(0x1eeb); regmbc(0x1eed); regmbc(0x1eef);\n\t\t      regmbc(0x1ef1);\n\t\t      return;\n\t    case 'v': case 0x28b: case 0x1d8c: case 0x1e7d: case 0x1e7f:\n\t\t      regmbc('v'); regmbc(0x28b); regmbc(0x1d8c);\n\t\t      regmbc(0x1e7d); regmbc(0x1e7f);\n\t\t      return;\n\t    case 'w': case 0x175: case 0x1e81: case 0x1e83:\n\t    case 0x1e85: case 0x1e87: case 0x1e89: case 0x1e98:\n\t\t      regmbc('w'); regmbc(0x175); regmbc(0x1e81);\n\t\t      regmbc(0x1e83); regmbc(0x1e85); regmbc(0x1e87);\n\t\t      regmbc(0x1e89); regmbc(0x1e98);\n\t\t      return;\n\t    case 'x': case 0x1e8b: case 0x1e8d:\n\t\t      regmbc('x'); regmbc(0x1e8b); regmbc(0x1e8d);\n\t\t      return;\n\t    case 'y': case 0xfd: case 0xff: case 0x177: case 0x1b4:\n\t    case 0x233: case 0x24f: case 0x1e8f: case 0x1e99: case 0x1ef3:\n\t    case 0x1ef5: case 0x1ef7: case 0x1ef9:\n\t\t      regmbc('y'); regmbc(0xfd); regmbc(0xff);\n\t\t      regmbc(0x177); regmbc(0x1b4); regmbc(0x233);\n\t\t      regmbc(0x24f); regmbc(0x1e8f); regmbc(0x1e99);\n\t\t      regmbc(0x1ef3); regmbc(0x1ef5); regmbc(0x1ef7);\n\t\t      regmbc(0x1ef9);\n\t\t      return;\n\t    case 'z': case 0x17a: case 0x17c: case 0x17e: case 0x1b6:\n\t    case 0x1d76: case 0x1d8e: case 0x1e91: case 0x1e93:\n\t    case 0x1e95: case 0x2c6c:\n\t\t      regmbc('z'); regmbc(0x17a); regmbc(0x17c);\n\t\t      regmbc(0x17e); regmbc(0x1b6); regmbc(0x1d76);\n\t\t      regmbc(0x1d8e); regmbc(0x1e91); regmbc(0x1e93);\n\t\t      regmbc(0x1e95); regmbc(0x2c6c);\n\t\t      return;\n\t}\n    }\n    regmbc(c);\n}","target":0,"code_token_length":12301,"total_token_length":12537,"max_tokens_setting":28000}
+{"idx":198439,"func":"mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)\n{\n  \/* mrb_assert(MRB_PROC_CFUNC_P(proc)) *\/\n  const mrb_irep *irep = proc->body.irep;\n  const mrb_pool_value *pool = irep->pool;\n  const mrb_sym *syms = irep->syms;\n  mrb_code insn;\n  int ai = mrb_gc_arena_save(mrb);\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf c_jmp;\n  uint32_t a;\n  uint16_t b;\n  uint16_t c;\n  mrb_sym mid;\n  const struct mrb_irep_catch_handler *ch;\n\n#ifdef DIRECT_THREADED\n  static const void * const optable[] = {\n#define OPCODE(x,_) &&L_OP_ ## x,\n#include \"mruby\/ops.h\"\n#undef OPCODE\n  };\n#endif\n\n  mrb_bool exc_catched = FALSE;\nRETRY_TRY_BLOCK:\n\n  MRB_TRY(&c_jmp) {\n\n  if (exc_catched) {\n    exc_catched = FALSE;\n    mrb_gc_arena_restore(mrb, ai);\n    if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)\n      goto L_BREAK;\n    goto L_RAISE;\n  }\n  mrb->jmp = &c_jmp;\n  mrb_vm_ci_proc_set(mrb->c->ci, proc);\n\n#define regs (mrb->c->ci->stack)\n  INIT_DISPATCH {\n    CASE(OP_NOP, Z) {\n      \/* do nothing *\/\n      NEXT;\n    }\n\n    CASE(OP_MOVE, BB) {\n      regs[a] = regs[b];\n      NEXT;\n    }\n\n    CASE(OP_LOADL, BB) {\n      switch (pool[b].tt) {   \/* number *\/\n      case IREP_TT_INT32:\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);\n        break;\n      case IREP_TT_INT64:\n#if defined(MRB_INT64)\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n        break;\n#else\n#if defined(MRB_64BIT)\n        if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {\n          regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n          break;\n        }\n#endif\n        goto L_INT_OVERFLOW;\n#endif\n      case IREP_TT_BIGINT:\n        goto L_INT_OVERFLOW;\n#ifndef MRB_NO_FLOAT\n      case IREP_TT_FLOAT:\n        regs[a] = mrb_float_value(mrb, pool[b].u.f);\n        break;\n#endif\n      default:\n        \/* should not happen (tt:string) *\/\n        regs[a] = mrb_nil_value();\n        break;\n      }\n      NEXT;\n    }\n\n    CASE(OP_LOADI, BB) {\n      SET_FIXNUM_VALUE(regs[a], b);\n      NEXT;\n    }\n\n    CASE(OP_LOADINEG, BB) {\n      SET_FIXNUM_VALUE(regs[a], -b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI__1,B) goto L_LOADI;\n    CASE(OP_LOADI_0,B) goto L_LOADI;\n    CASE(OP_LOADI_1,B) goto L_LOADI;\n    CASE(OP_LOADI_2,B) goto L_LOADI;\n    CASE(OP_LOADI_3,B) goto L_LOADI;\n    CASE(OP_LOADI_4,B) goto L_LOADI;\n    CASE(OP_LOADI_5,B) goto L_LOADI;\n    CASE(OP_LOADI_6,B) goto L_LOADI;\n    CASE(OP_LOADI_7, B) {\n    L_LOADI:\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);\n      NEXT;\n    }\n\n    CASE(OP_LOADI16, BS) {\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI32, BSS) {\n      SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));\n      NEXT;\n    }\n\n    CASE(OP_LOADSYM, BB) {\n      SET_SYM_VALUE(regs[a], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_LOADNIL, B) {\n      SET_NIL_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADSELF, B) {\n      regs[a] = regs[0];\n      NEXT;\n    }\n\n    CASE(OP_LOADT, B) {\n      SET_TRUE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADF, B) {\n      SET_FALSE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETGV, BB) {\n      mrb_value val = mrb_gv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETGV, BB) {\n      mrb_gv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETSV, BB) {\n      mrb_value val = mrb_vm_special_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETSV, BB) {\n      mrb_vm_special_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIV, BB) {\n      regs[a] = mrb_iv_get(mrb, regs[0], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETIV, BB) {\n      mrb_iv_set(mrb, regs[0], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETCV, BB) {\n      mrb_value val;\n      val = mrb_vm_cv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETCV, BB) {\n      mrb_vm_cv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIDX, B) {\n      mrb_value va = regs[a], vb = regs[a+1];\n      switch (mrb_type(va)) {\n      case MRB_TT_ARRAY:\n        if (!mrb_integer_p(vb)) goto getidx_fallback;\n        regs[a] = mrb_ary_entry(va, mrb_integer(vb));\n        break;\n      case MRB_TT_HASH:\n        va = mrb_hash_get(mrb, va, vb);\n        regs[a] = va;\n        break;\n      case MRB_TT_STRING:\n        switch (mrb_type(vb)) {\n        case MRB_TT_INTEGER:\n        case MRB_TT_STRING:\n        case MRB_TT_RANGE:\n          va = mrb_str_aref(mrb, va, vb, mrb_undef_value());\n          regs[a] = va;\n          break;\n        default:\n          goto getidx_fallback;\n        }\n        break;\n      default:\n      getidx_fallback:\n        mid = MRB_OPSYM(aref);\n        goto L_SEND_SYM;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETIDX, B) {\n      c = 2;\n      mid = MRB_OPSYM(aset);\n      SET_NIL_VALUE(regs[a+3]);\n      goto L_SENDB_SYM;\n    }\n\n    CASE(OP_GETCONST, BB) {\n      mrb_value v = mrb_vm_const_get(mrb, syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETCONST, BB) {\n      mrb_vm_const_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETMCNST, BB) {\n      mrb_value v = mrb_const_get(mrb, regs[a], syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETMCNST, BB) {\n      mrb_const_set(mrb, regs[a+1], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETUPVAR, BBB) {\n      mrb_value *regs_a = regs + a;\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e && b < MRB_ENV_LEN(e)) {\n        *regs_a = e->stack[b];\n      }\n      else {\n        *regs_a = mrb_nil_value();\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETUPVAR, BBB) {\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e) {\n        mrb_value *regs_a = regs + a;\n\n        if (b < MRB_ENV_LEN(e)) {\n          e->stack[b] = *regs_a;\n          mrb_write_barrier(mrb, (struct RBasic*)e);\n        }\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMP, S) {\n      pc += (int16_t)a;\n      JUMP;\n    }\n    CASE(OP_JMPIF, BS) {\n      if (mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNOT, BS) {\n      if (!mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNIL, BS) {\n      if (mrb_nil_p(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMPUW, S) {\n      a = (uint32_t)((pc - irep->iseq) + (int16_t)a);\n      CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {\n        struct RBreak *brk = (struct RBreak*)mrb->exc;\n        mrb_value target = mrb_break_value_get(brk);\n        mrb_assert(mrb_integer_p(target));\n        a = (uint32_t)mrb_integer(target);\n        mrb_assert(a >= 0 && a < irep->ilen);\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {\n        ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);\n        if (ch) {\n          \/* avoiding a jump from a catch handler into the same handler *\/\n          if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {\n            THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));\n          }\n        }\n      }\n      CHECKPOINT_END(RBREAK_TAG_JUMP);\n\n      mrb->exc = NULL; \/* clear break object *\/\n      pc = irep->iseq + a;\n      JUMP;\n    }\n\n    CASE(OP_EXCEPT, B) {\n      mrb_value exc;\n\n      if (mrb->exc == NULL) {\n        exc = mrb_nil_value();\n      }\n      else {\n        switch (mrb->exc->tt) {\n        case MRB_TT_BREAK:\n        case MRB_TT_EXCEPTION:\n          exc = mrb_obj_value(mrb->exc);\n          break;\n        default:\n          mrb_assert(!\"bad mrb_type\");\n          exc = mrb_nil_value();\n          break;\n        }\n        mrb->exc = NULL;\n      }\n      regs[a] = exc;\n      NEXT;\n    }\n    CASE(OP_RESCUE, BB) {\n      mrb_value exc = regs[a];  \/* exc on stack *\/\n      mrb_value e = regs[b];\n      struct RClass *ec;\n\n      switch (mrb_type(e)) {\n      case MRB_TT_CLASS:\n      case MRB_TT_MODULE:\n        break;\n      default:\n        {\n          mrb_value exc;\n\n          exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                    \"class or module required for rescue clause\");\n          mrb_exc_set(mrb, exc);\n          goto L_RAISE;\n        }\n      }\n      ec = mrb_class_ptr(e);\n      regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));\n      NEXT;\n    }\n\n    CASE(OP_RAISEIF, B) {\n      mrb_value exc = regs[a];\n      if (mrb_break_p(exc)) {\n        mrb->exc = mrb_obj_ptr(exc);\n        goto L_BREAK;\n      }\n      mrb_exc_set(mrb, exc);\n      if (mrb->exc) {\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SSEND, BBB) {\n      regs[a] = regs[0];\n      insn = OP_SEND;\n    }\n    goto L_SENDB;\n\n    CASE(OP_SSENDB, BBB) {\n      regs[a] = regs[0];\n    }\n    goto L_SENDB;\n\n    CASE(OP_SEND, BBB)\n    goto L_SENDB;\n\n    L_SEND_SYM:\n    c = 1;\n    \/* push nil after arguments *\/\n    SET_NIL_VALUE(regs[a+2]);\n    goto L_SENDB_SYM;\n\n    CASE(OP_SENDB, BBB)\n    L_SENDB:\n    mid = syms[b];\n    L_SENDB_SYM:\n    {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_value recv, blk;\n\n      ARGUMENT_NORMALIZE(a, &c, insn);\n\n      recv = regs[a];\n      cls = mrb_class(mrb, recv);\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, c);\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        if (MRB_METHOD_PROC_P(m)) {\n          struct RProc *p = MRB_METHOD_PROC(m);\n\n          mrb_vm_ci_proc_set(ci, p);\n          recv = p->body.func(mrb, recv);\n        }\n        else {\n          if (MRB_METHOD_NOARG_P(m)) {\n            check_method_noarg(mrb, ci);\n          }\n          recv = MRB_METHOD_FUNC(m)(mrb, recv);\n        }\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n          if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n        if (!ci->u.target_class) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return recv;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        ci->stack[0] = recv;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n    }\n    JUMP;\n\n    CASE(OP_CALL, Z) {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv = ci->stack[0];\n      struct RProc *m = mrb_proc_ptr(recv);\n\n      \/* replace callinfo *\/\n      ci->u.target_class = MRB_PROC_TARGET_CLASS(m);\n      mrb_vm_ci_proc_set(ci, m);\n      if (MRB_PROC_ENV_P(m)) {\n        ci->mid = MRB_PROC_ENV(m)->mid;\n      }\n\n      \/* prepare stack *\/\n      if (MRB_PROC_CFUNC_P(m)) {\n        recv = MRB_PROC_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n        ci[1].stack[0] = recv;\n        irep = mrb->c->ci->proc->body.irep;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        proc = m;\n        irep = m->body.irep;\n        if (!irep) {\n          mrb->c->ci->stack[0] = mrb_nil_value();\n          a = 0;\n          c = OP_R_NORMAL;\n          goto L_OP_RETURN_BODY;\n        }\n        mrb_int nargs = mrb_ci_bidx(ci)+1;\n        if (nargs < irep->nregs) {\n          mrb_stack_extend(mrb, irep->nregs);\n          stack_clear(regs+nargs, irep->nregs-nargs);\n        }\n        if (MRB_PROC_ENV_P(m)) {\n          regs[0] = MRB_PROC_ENV(m)->stack[0];\n        }\n        pc = irep->iseq;\n      }\n      pool = irep->pool;\n      syms = irep->syms;\n      JUMP;\n    }\n\n    CASE(OP_SUPER, BB) {\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv, blk;\n      const struct RProc *p = ci->proc;\n      mrb_sym mid = ci->mid;\n      struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);\n\n      if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { \/* alias support *\/\n        mid = p->e.env->mid;    \/* restore old mid *\/\n      }\n\n      if (mid == 0 || !target_class) {\n        mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {\n        target_class = mrb_vm_ci_target_class(ci);\n      }\n      else if (target_class->tt == MRB_TT_MODULE) {\n        target_class = mrb_vm_ci_target_class(ci);\n        if (!target_class || target_class->tt != MRB_TT_ICLASS) {\n          goto super_typeerror;\n        }\n      }\n      recv = regs[0];\n      if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {\n      super_typeerror: ;\n        mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                            \"self has wrong type to call super in this context\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n\n      ARGUMENT_NORMALIZE(a, &b, OP_SUPER);\n\n      cls = target_class->super;\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, b);\n\n      \/* prepare stack *\/\n      ci->stack[0] = recv;\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        mrb_value v;\n\n        if (MRB_METHOD_PROC_P(m)) {\n          mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n        }\n        v = MRB_METHOD_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_restore(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        mrb_assert(!mrb_break_p(v));\n        if (!mrb_vm_ci_target_class(ci)) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return v;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        mrb->c->ci->stack[0] = v;\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n      JUMP;\n    }\n\n    CASE(OP_ARGARY, BS) {\n      mrb_int m1 = (b>>11)&0x3f;\n      mrb_int r  = (b>>10)&0x1;\n      mrb_int m2 = (b>>5)&0x1f;\n      mrb_int kd = (b>>4)&0x1;\n      mrb_int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {\n        mrb_value exc;\n\n      L_NOSUPER:\n        exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e) goto L_NOSUPER;\n        if (MRB_ENV_LEN(e) <= m1+r+m2+1)\n          goto L_NOSUPER;\n        stack = e->stack + 1;\n      }\n      if (r == 0) {\n        regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack);\n      }\n      else {\n        mrb_value *pp = NULL;\n        struct RArray *rest;\n        mrb_int len = 0;\n\n        if (mrb_array_p(stack[m1])) {\n          struct RArray *ary = mrb_ary_ptr(stack[m1]);\n\n          pp = ARY_PTR(ary);\n          len = ARY_LEN(ary);\n        }\n        regs[a] = mrb_ary_new_capa(mrb, m1+len+m2);\n        rest = mrb_ary_ptr(regs[a]);\n        if (m1 > 0) {\n          stack_copy(ARY_PTR(rest), stack, m1);\n        }\n        if (len > 0) {\n          stack_copy(ARY_PTR(rest)+m1, pp, len);\n        }\n        if (m2 > 0) {\n          stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2);\n        }\n        ARY_SET_LEN(rest, m1+len+m2);\n      }\n      if (kd) {\n        regs[a+1] = stack[m1+r+m2];\n        regs[a+2] = stack[m1+r+m2+1];\n      }\n      else {\n        regs[a+1] = stack[m1+r+m2];\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ENTER, W) {\n      mrb_int m1 = MRB_ASPEC_REQ(a);\n      mrb_int o  = MRB_ASPEC_OPT(a);\n      mrb_int r  = MRB_ASPEC_REST(a);\n      mrb_int m2 = MRB_ASPEC_POST(a);\n      mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;\n      \/* unused\n      int b  = MRB_ASPEC_BLOCK(a);\n      *\/\n      mrb_int const len = m1 + o + r + m2;\n\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_int argc = ci->n;\n      mrb_value *argv = regs+1;\n      mrb_value * const argv0 = argv;\n      mrb_int const kw_pos = len + kd;    \/* where kwhash should be *\/\n      mrb_int const blk_pos = kw_pos + 1; \/* where block should be *\/\n      mrb_value blk = regs[mrb_ci_bidx(ci)];\n      mrb_value kdict = mrb_nil_value();\n\n      \/* keyword arguments *\/\n      if (ci->nk > 0) {\n        mrb_int kidx = mrb_ci_kidx(ci);\n        kdict = regs[kidx];\n        if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) {\n          kdict = mrb_nil_value();\n          ci->nk = 0;\n        }\n      }\n      if (!kd && !mrb_nil_p(kdict)) {\n        if (argc < 14) {\n          ci->n++;\n          argc++;    \/* include kdict in normal arguments *\/\n        }\n        else if (argc == 14) {\n          \/* pack arguments and kdict *\/\n          regs[1] = mrb_ary_new_from_values(mrb, argc+1, ®s[1]);\n          argc = ci->n = 15;\n        }\n        else {\/* argc == 15 *\/\n          \/* push kdict to packed arguments *\/\n          mrb_ary_push(mrb, regs[1], regs[2]);\n        }\n        ci->nk = 0;\n      }\n      if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) {\n        kdict = mrb_hash_dup(mrb, kdict);\n      }\n\n      \/* arguments is passed with Array *\/\n      if (argc == 15) {\n        struct RArray *ary = mrb_ary_ptr(regs[1]);\n        argv = ARY_PTR(ary);\n        argc = (int)ARY_LEN(ary);\n        mrb_gc_protect(mrb, regs[1]);\n      }\n\n      \/* strict argument check *\/\n      if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) {\n        if (argc < m1 + m2 || (r == 0 && argc > len)) {\n          argnum_error(mrb, m1+m2);\n          goto L_RAISE;\n        }\n      }\n      \/* extract first argument array to arguments *\/\n      else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) {\n        mrb_gc_protect(mrb, argv[0]);\n        argc = (int)RARRAY_LEN(argv[0]);\n        argv = RARRAY_PTR(argv[0]);\n      }\n\n      \/* rest arguments *\/\n      mrb_value rest = mrb_nil_value();\n      if (argc < len) {\n        mrb_int mlen = m2;\n        if (argc < m1+m2) {\n          mlen = m1 < argc ? argc - m1 : 0;\n        }\n\n        \/* copy mandatory and optional arguments *\/\n        if (argv0 != argv && argv) {\n          value_move(®s[1], argv, argc-mlen); \/* m1 + o *\/\n        }\n        if (argc < m1) {\n          stack_clear(®s[argc+1], m1-argc);\n        }\n        \/* copy post mandatory arguments *\/\n        if (mlen) {\n          value_move(®s[len-m2+1], &argv[argc-mlen], mlen);\n        }\n        if (mlen < m2) {\n          stack_clear(®s[len-m2+mlen+1], m2-mlen);\n        }\n        \/* initialize rest arguments with empty Array *\/\n        if (r) {\n          rest = mrb_ary_new_capa(mrb, 0);\n          regs[m1+o+1] = rest;\n        }\n        \/* skip initializer of passed arguments *\/\n        if (o > 0 && argc > m1+m2)\n          pc += (argc - m1 - m2)*3;\n      }\n      else {\n        mrb_int rnum = 0;\n        if (argv0 != argv) {\n          value_move(®s[1], argv, m1+o);\n        }\n        if (r) {\n          rnum = argc-m1-o-m2;\n          rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o);\n          regs[m1+o+1] = rest;\n        }\n        if (m2 > 0 && argc-m2 > m1) {\n          value_move(®s[m1+o+r+1], &argv[m1+o+rnum], m2);\n        }\n        pc += o*3;\n      }\n\n      \/* need to be update blk first to protect blk from GC *\/\n      regs[blk_pos] = blk;              \/* move block *\/\n      if (kd) {\n        if (mrb_nil_p(kdict))\n          kdict = mrb_hash_new_capa(mrb, 0);\n        regs[kw_pos] = kdict;           \/* set kwhash *\/\n      }\n\n      \/* format arguments for generated code *\/\n      mrb->c->ci->n = len;\n\n      \/* clear local (but non-argument) variables *\/\n      if (irep->nlocals-blk_pos-1 > 0) {\n        stack_clear(®s[blk_pos+1], irep->nlocals-blk_pos-1);\n      }\n      JUMP;\n    }\n\n    CASE(OP_KARG, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict, v;\n\n      if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) {\n        mrb_value str = mrb_format(mrb, \"missing keyword: %v\", k);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      v = mrb_hash_get(mrb, kdict, k);\n      regs[a] = v;\n      mrb_hash_delete_key(mrb, kdict, k);\n      NEXT;\n    }\n\n    CASE(OP_KEY_P, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n      mrb_bool key_p = FALSE;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) {\n        key_p = mrb_hash_key_p(mrb, kdict, k);\n      }\n      regs[a] = mrb_bool_value(key_p);\n      NEXT;\n    }\n\n    CASE(OP_KEYEND, Z) {\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) {\n        mrb_value keys = mrb_hash_keys(mrb, kdict);\n        mrb_value key1 = RARRAY_PTR(keys)[0];\n        mrb_value str = mrb_format(mrb, \"unknown keyword: %v\", key1);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_BREAK, B) {\n      c = OP_R_BREAK;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN_BLK, B) {\n      c = OP_R_RETURN;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN, B)\n    c = OP_R_NORMAL;\n    L_RETURN:\n    {\n      mrb_callinfo *ci;\n\n      ci = mrb->c->ci;\n      if (ci->mid) {\n        mrb_value blk = regs[mrb_ci_bidx(ci)];\n\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n\n          if (!MRB_PROC_STRICT_P(p) &&\n              ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n      }\n\n      if (mrb->exc) {\n      L_RAISE:\n        ci = mrb->c->ci;\n        if (ci == mrb->c->cibase) {\n          ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n          if (ch == NULL) goto L_FTOP;\n          goto L_CATCH;\n        }\n        while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {\n          ci = cipop(mrb);\n          if (ci[1].cci == CINFO_SKIP && prev_jmp) {\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          pc = ci[0].pc;\n          if (ci == mrb->c->cibase) {\n            ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n            if (ch == NULL) {\n            L_FTOP:             \/* fiber top *\/\n              if (mrb->c == mrb->root_c) {\n                mrb->c->ci->stack = mrb->c->stbase;\n                goto L_STOP;\n              }\n              else {\n                struct mrb_context *c = mrb->c;\n\n                c->status = MRB_FIBER_TERMINATED;\n                mrb->c = c->prev;\n                c->prev = NULL;\n                goto L_RAISE;\n              }\n            }\n            break;\n          }\n        }\n      L_CATCH:\n        if (ch == NULL) goto L_STOP;\n        if (FALSE) {\n        L_CATCH_TAGGED_BREAK: \/* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() *\/\n          ci = mrb->c->ci;\n        }\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, irep->nregs);\n        pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);\n      }\n      else {\n        mrb_int acc;\n        mrb_value v;\n\n        ci = mrb->c->ci;\n        v = regs[a];\n        mrb_gc_protect(mrb, v);\n        switch (c) {\n        case OP_R_RETURN:\n          \/* Fall through to OP_R_NORMAL otherwise *\/\n          if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {\n            const struct RProc *dst;\n            mrb_callinfo *cibase;\n            cibase = mrb->c->cibase;\n            dst = top_proc(mrb, proc);\n\n            if (MRB_PROC_ENV_P(dst)) {\n              struct REnv *e = MRB_PROC_ENV(dst);\n\n              if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n            }\n            \/* check jump destination *\/\n            while (cibase <= ci && ci->proc != dst) {\n              if (ci->cci > CINFO_NONE) { \/* jump cross C boundary *\/\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n              ci--;\n            }\n            if (ci <= cibase) { \/* no jump destination *\/\n              localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n              goto L_RAISE;\n            }\n            ci = mrb->c->ci;\n            while (cibase <= ci && ci->proc != dst) {\n              CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {\n                cibase = mrb->c->cibase;\n                dst = top_proc(mrb, proc);\n              }\n              CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {\n                UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);\n              }\n              CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);\n              ci = cipop(mrb);\n              pc = ci->pc;\n            }\n            proc = ci->proc;\n            mrb->exc = NULL; \/* clear break object *\/\n            break;\n          }\n          \/* fallthrough *\/\n        case OP_R_NORMAL:\n        NORMAL_RETURN:\n          if (ci == mrb->c->cibase) {\n            struct mrb_context *c;\n            c = mrb->c;\n\n            if (!c->prev) { \/* toplevel return *\/\n              regs[irep->nlocals] = v;\n              goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);\n            }\n            if (!c->vmexec && c->prev->ci == c->prev->cibase) {\n              mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, \"double resume\");\n              mrb_exc_set(mrb, exc);\n              goto L_RAISE;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {\n              c = mrb->c;\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);\n            \/* automatic yield at the end *\/\n            c->status = MRB_FIBER_TERMINATED;\n            mrb->c = c->prev;\n            mrb->c->status = MRB_FIBER_RUNNING;\n            c->prev = NULL;\n            if (c->vmexec) {\n              mrb_gc_arena_restore(mrb, ai);\n              c->vmexec = FALSE;\n              mrb->jmp = prev_jmp;\n              return v;\n            }\n            ci = mrb->c->ci;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_RETURN);\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        case OP_R_BREAK:\n          if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;\n          if (MRB_PROC_ORPHAN_P(proc)) {\n            mrb_value exc;\n\n          L_BREAK_ERROR:\n            exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,\n                                      \"break from proc-closure\");\n            mrb_exc_set(mrb, exc);\n            goto L_RAISE;\n          }\n          if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {\n            goto L_BREAK_ERROR;\n          }\n          else {\n            struct REnv *e = MRB_PROC_ENV(proc);\n\n            if (e->cxt != mrb->c) {\n              goto L_BREAK_ERROR;\n            }\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK);\n          \/* break from fiber block *\/\n          if (ci == mrb->c->cibase && ci->pc) {\n            struct mrb_context *c = mrb->c;\n\n            mrb->c = c->prev;\n            c->prev = NULL;\n            ci = mrb->c->ci;\n          }\n          if (ci->cci > CINFO_NONE) {\n            ci = cipop(mrb);\n            mrb_gc_arena_restore(mrb, ai);\n            mrb->c->vmexec = FALSE;\n            mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          if (FALSE) {\n            struct RBreak *brk;\n\n          L_BREAK:\n            brk = (struct RBreak*)mrb->exc;\n            proc = mrb_break_proc_get(brk);\n            v = mrb_break_value_get(brk);\n            ci = mrb->c->ci;\n\n            switch (mrb_break_tag_get(brk)) {\n#define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);\n              RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)\n#undef DISPATCH_CHECKPOINTS\n              default:\n                mrb_assert(!\"wrong break tag\");\n            }\n          }\n          while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {\n            if (ci[-1].cci == CINFO_SKIP) {\n              goto L_BREAK_ERROR;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {\n              \/* do nothing *\/\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);\n            ci = cipop(mrb);\n            pc = ci->pc;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);\n          if (ci == mrb->c->cibase) {\n            goto L_BREAK_ERROR;\n          }\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        default:\n          \/* cannot happen *\/\n          break;\n        }\n        mrb_assert(ci == mrb->c->ci);\n        mrb_assert(mrb->exc == NULL);\n\n        if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->c->vmexec = FALSE;\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        acc = ci->cci;\n        ci = cipop(mrb);\n        if (acc == CINFO_SKIP || acc == CINFO_DIRECT) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        pc = ci->pc;\n        DEBUG(fprintf(stderr, \"from :%s\\n\", mrb_sym_name(mrb, ci->mid)));\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n\n        ci[1].stack[0] = v;\n        mrb_gc_arena_restore(mrb, ai);\n      }\n      JUMP;\n    }\n\n    CASE(OP_BLKPUSH, BS) {\n      int m1 = (b>>11)&0x3f;\n      int r  = (b>>10)&0x1;\n      int m2 = (b>>5)&0x1f;\n      int kd = (b>>4)&0x1;\n      int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||\n            MRB_ENV_LEN(e) <= m1+r+m2+1) {\n          localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n          goto L_RAISE;\n        }\n        stack = e->stack + 1;\n      }\n      if (mrb_nil_p(stack[m1+r+m2+kd])) {\n        localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n        goto L_RAISE;\n      }\n      regs[a] = stack[m1+r+m2+kd];\n      NEXT;\n    }\n\n  L_INT_OVERFLOW:\n    {\n      mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, \"integer overflow\");\n      mrb_exc_set(mrb, exc);\n    }\n    goto L_RAISE;\n\n#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))\n#define OP_MATH(op_name)                                                    \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {                  \\\n    OP_MATH_CASE_INTEGER(op_name);                                          \\\n    OP_MATH_CASE_FLOAT(op_name, integer, float);                            \\\n    OP_MATH_CASE_FLOAT(op_name, float,  integer);                           \\\n    OP_MATH_CASE_FLOAT(op_name, float,  float);                             \\\n    OP_MATH_CASE_STRING_##op_name();                                        \\\n    default:                                                                \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATH_CASE_INTEGER(op_name)                                       \\\n  case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER):                              \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z;      \\\n      if (mrb_int_##op_name##_overflow(x, y, &z))                           \\\n        OP_MATH_OVERFLOW_INT();                                             \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0\n#else\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2)                                     \\\n  case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2):                                \\\n    {                                                                           \\\n      mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                         \\\n    }                                                                           \\\n    break\n#endif\n#define OP_MATH_OVERFLOW_INT() goto L_INT_OVERFLOW\n#define OP_MATH_CASE_STRING_add()                                           \\\n  case TYPES2(MRB_TT_STRING, MRB_TT_STRING):                                \\\n    regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]);                        \\\n    mrb_gc_arena_restore(mrb, ai);                                          \\\n    break\n#define OP_MATH_CASE_STRING_sub() (void)0\n#define OP_MATH_CASE_STRING_mul() (void)0\n#define OP_MATH_OP_add +\n#define OP_MATH_OP_sub -\n#define OP_MATH_OP_mul *\n#define OP_MATH_TT_integer MRB_TT_INTEGER\n#define OP_MATH_TT_float   MRB_TT_FLOAT\n\n    CASE(OP_ADD, B) {\n      OP_MATH(add);\n    }\n\n    CASE(OP_SUB, B) {\n      OP_MATH(sub);\n    }\n\n    CASE(OP_MUL, B) {\n      OP_MATH(mul);\n    }\n\n    CASE(OP_DIV, B) {\n#ifndef MRB_NO_FLOAT\n      mrb_float x, y, f;\n#endif\n\n      \/* need to check if op is overridden *\/\n      switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\n        {\n          mrb_int x = mrb_integer(regs[a]);\n          mrb_int y = mrb_integer(regs[a+1]);\n          mrb_int div = mrb_div_int(mrb, x, y);\n          SET_INT_VALUE(mrb, regs[a], div);\n        }\n        NEXT;\n#ifndef MRB_NO_FLOAT\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\n        x = (mrb_float)mrb_integer(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\n        x = mrb_float(regs[a]);\n        y = (mrb_float)mrb_integer(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\n        x = mrb_float(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n#endif\n      default:\n        mid = MRB_OPSYM(div);\n        goto L_SEND_SYM;\n      }\n\n#ifndef MRB_NO_FLOAT\n      f = mrb_div_float(x, y);\n      SET_FLOAT_VALUE(mrb, regs[a], f);\n#endif\n      NEXT;\n    }\n\n#define OP_MATHI(op_name)                                                   \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (mrb_type(regs[a])) {                                              \\\n    OP_MATHI_CASE_INTEGER(op_name);                                         \\\n    OP_MATHI_CASE_FLOAT(op_name);                                           \\\n    default:                                                                \\\n      SET_INT_VALUE(mrb,regs[a+1], b);                                      \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATHI_CASE_INTEGER(op_name)                                      \\\n  case MRB_TT_INTEGER:                                                      \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z;                  \\\n      if (mrb_int_##op_name##_overflow(x, y, &z))                           \\\n        OP_MATH_OVERFLOW_INT();                                             \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATHI_CASE_FLOAT(op_name) (void)0\n#else\n#define OP_MATHI_CASE_FLOAT(op_name)                                        \\\n  case MRB_TT_FLOAT:                                                        \\\n    {                                                                       \\\n      mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b;              \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                     \\\n    }                                                                       \\\n    break\n#endif\n\n    CASE(OP_ADDI, BB) {\n      OP_MATHI(add);\n    }\n\n    CASE(OP_SUBI, BB) {\n      OP_MATHI(sub);\n    }\n\n#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))\n\n#ifdef MRB_NO_FLOAT\n#define OP_CMP(op,sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#else\n#define OP_CMP(op, sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_float);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#endif\n\n    CASE(OP_EQ, B) {\n      if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {\n        SET_TRUE_VALUE(regs[a]);\n      }\n      else {\n        OP_CMP(==,eq);\n      }\n      NEXT;\n    }\n\n    CASE(OP_LT, B) {\n      OP_CMP(<,lt);\n      NEXT;\n    }\n\n    CASE(OP_LE, B) {\n      OP_CMP(<=,le);\n      NEXT;\n    }\n\n    CASE(OP_GT, B) {\n      OP_CMP(>,gt);\n      NEXT;\n    }\n\n    CASE(OP_GE, B) {\n      OP_CMP(>=,ge);\n      NEXT;\n    }\n\n    CASE(OP_ARRAY, BB) {\n      regs[a] = mrb_ary_new_from_values(mrb, b, ®s[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_ARRAY2, BBB) {\n      regs[a] = mrb_ary_new_from_values(mrb, c, ®s[b]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYCAT, B) {\n      mrb_value splat = mrb_ary_splat(mrb, regs[a+1]);\n      if (mrb_nil_p(regs[a])) {\n        regs[a] = splat;\n      }\n      else {\n        mrb_assert(mrb_array_p(regs[a]));\n        mrb_ary_concat(mrb, regs[a], splat);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYPUSH, BB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      for (mrb_int i=0; i<b; i++) {\n        mrb_ary_push(mrb, regs[a], regs[a+i+1]);\n      }\n      NEXT;\n    }\n\n    CASE(OP_ARYDUP, B) {\n      mrb_value ary = regs[a];\n      if (mrb_array_p(ary)) {\n        ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));\n      }\n      else {\n        ary = mrb_ary_new_from_values(mrb, 1, &ary);\n      }\n      regs[a] = ary;\n      NEXT;\n    }\n\n    CASE(OP_AREF, BBB) {\n      mrb_value v = regs[b];\n\n      if (!mrb_array_p(v)) {\n        if (c == 0) {\n          regs[a] = v;\n        }\n        else {\n          SET_NIL_VALUE(regs[a]);\n        }\n      }\n      else {\n        v = mrb_ary_ref(mrb, v, c);\n        regs[a] = v;\n      }\n      NEXT;\n    }\n\n    CASE(OP_ASET, BBB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      mrb_ary_set(mrb, regs[b], c, regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_APOST, BBB) {\n      mrb_value v = regs[a];\n      int pre  = b;\n      int post = c;\n      struct RArray *ary;\n      int len, idx;\n\n      if (!mrb_array_p(v)) {\n        v = mrb_ary_new_from_values(mrb, 1, ®s[a]);\n      }\n      ary = mrb_ary_ptr(v);\n      len = (int)ARY_LEN(ary);\n      if (len > pre + post) {\n        v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre);\n        regs[a++] = v;\n        while (post--) {\n          regs[a++] = ARY_PTR(ary)[len-post-1];\n        }\n      }\n      else {\n        v = mrb_ary_new_capa(mrb, 0);\n        regs[a++] = v;\n        for (idx=0; idx+pre<len; idx++) {\n          regs[a+idx] = ARY_PTR(ary)[pre+idx];\n        }\n        while (idx < post) {\n          SET_NIL_VALUE(regs[a+idx]);\n          idx++;\n        }\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_INTERN, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_sym sym = mrb_intern_str(mrb, regs[a]);\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_SYMBOL, BB) {\n      size_t len;\n      mrb_sym sym;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        sym = mrb_intern_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        sym  = mrb_intern(mrb, pool[b].u.str, len);\n      }\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_STRING, BB) {\n      mrb_int len;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        regs[a] = mrb_str_new(mrb, pool[b].u.str, len);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_STRCAT, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_str_concat(mrb, regs[a], regs[a+1]);\n      NEXT;\n    }\n\n    CASE(OP_HASH, BB) {\n      mrb_value hash = mrb_hash_new_capa(mrb, b);\n      int i;\n      int lim = a+b*2;\n\n      for (i=a; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      regs[a] = hash;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_HASHADD, BB) {\n      mrb_value hash;\n      int i;\n      int lim = a+b*2+1;\n\n      hash = regs[a];\n      mrb_ensure_hash_type(mrb, hash);\n      for (i=a+1; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_HASHCAT, B) {\n      mrb_value hash = regs[a];\n\n      mrb_assert(mrb_hash_p(hash));\n      mrb_hash_merge(mrb, hash, regs[a+1]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_LAMBDA, BB)\n    c = OP_L_LAMBDA;\n    L_MAKE_LAMBDA:\n    {\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      if (c & OP_L_CAPTURE) {\n        p = mrb_closure_new(mrb, nirep);\n      }\n      else {\n        p = mrb_proc_new(mrb, nirep);\n        p->flags |= MRB_PROC_SCOPE;\n      }\n      if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;\n      regs[a] = mrb_obj_value(p);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_BLOCK, BB) {\n      c = OP_L_BLOCK;\n      goto L_MAKE_LAMBDA;\n    }\n    CASE(OP_METHOD, BB) {\n      c = OP_L_METHOD;\n      goto L_MAKE_LAMBDA;\n    }\n\n    CASE(OP_RANGE_INC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_RANGE_EXC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], TRUE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_OCLASS, B) {\n      regs[a] = mrb_obj_value(mrb->object_class);\n      NEXT;\n    }\n\n    CASE(OP_CLASS, BB) {\n      struct RClass *c = 0, *baseclass;\n      mrb_value base, super;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      super = regs[a+1];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      c = mrb_vm_define_class(mrb, base, super, id);\n      regs[a] = mrb_obj_value(c);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_MODULE, BB) {\n      struct RClass *cls = 0, *baseclass;\n      mrb_value base;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      cls = mrb_vm_define_module(mrb, base, id);\n      regs[a] = mrb_obj_value(cls);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_EXEC, BB)\n    {\n      mrb_value recv = regs[a];\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      \/* prepare closure *\/\n      p = mrb_proc_new(mrb, nirep);\n      p->c = NULL;\n      mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc);\n      MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv));\n      p->flags |= MRB_PROC_SCOPE;\n\n      \/* prepare call stack *\/\n      cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0);\n\n      irep = p->body.irep;\n      pool = irep->pool;\n      syms = irep->syms;\n      mrb_stack_extend(mrb, irep->nregs);\n      stack_clear(regs+1, irep->nregs-1);\n      pc = irep->iseq;\n      JUMP;\n    }\n\n    CASE(OP_DEF, BB) {\n      struct RClass *target = mrb_class_ptr(regs[a]);\n      struct RProc *p = mrb_proc_ptr(regs[a+1]);\n      mrb_method_t m;\n      mrb_sym mid = syms[b];\n\n      MRB_METHOD_FROM_PROC(m, p);\n      mrb_define_method_raw(mrb, target, mid, m);\n      mrb_method_added(mrb, target, mid);\n      mrb_gc_arena_restore(mrb, ai);\n      regs[a] = mrb_symbol_value(mid);\n      NEXT;\n    }\n\n    CASE(OP_SCLASS, B) {\n      regs[a] = mrb_singleton_class(mrb, regs[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_TCLASS, B) {\n      struct RClass *target = check_target_class(mrb);\n      if (!target) goto L_RAISE;\n      regs[a] = mrb_obj_value(target);\n      NEXT;\n    }\n\n    CASE(OP_ALIAS, BB) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_alias_method(mrb, target, syms[a], syms[b]);\n      mrb_method_added(mrb, target, syms[a]);\n      NEXT;\n    }\n    CASE(OP_UNDEF, B) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_undef_method_id(mrb, target, syms[a]);\n      NEXT;\n    }\n\n    CASE(OP_DEBUG, Z) {\n      FETCH_BBB();\n#ifdef MRB_USE_DEBUG_HOOK\n      mrb->debug_op_hook(mrb, irep, pc, regs);\n#else\n#ifndef MRB_NO_STDIO\n      printf(\"OP_DEBUG %d %d %d\\n\", a, b, c);\n#else\n      abort();\n#endif\n#endif\n      NEXT;\n    }\n\n    CASE(OP_ERR, B) {\n      size_t len = pool[a].tt >> 2;\n      mrb_value exc;\n\n      mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);\n      exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);\n      mrb_exc_set(mrb, exc);\n      goto L_RAISE;\n    }\n\n    CASE(OP_EXT1, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT2, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT3, Z) {\n      uint8_t insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n\n    CASE(OP_STOP, Z) {\n      \/*        stop VM *\/\n      CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {\n        \/* do nothing *\/\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_STOP) {\n        UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());\n      }\n      CHECKPOINT_END(RBREAK_TAG_STOP);\n    L_STOP:\n      mrb->jmp = prev_jmp;\n      if (mrb->exc) {\n        mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);\n        return mrb_obj_value(mrb->exc);\n      }\n      return regs[irep->nlocals];\n    }\n  }\n  END_DISPATCH;\n#undef regs\n  }\n  MRB_CATCH(&c_jmp) {\n    mrb_callinfo *ci = mrb->c->ci;\n    while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) {\n      ci = cipop(mrb);\n    }\n    exc_catched = TRUE;\n    pc = ci->pc;\n    goto RETRY_TRY_BLOCK;\n  }\n  MRB_END_EXC(&c_jmp);\n}","target":1,"code_token_length":14528,"total_token_length":14764,"max_tokens_setting":28000}
+{"idx":482533,"func":"compileRule(FileInfo *file, TranslationTableHeader **table,\n\t\tDisplayTableHeader **displayTable, const MacroList **inScopeMacros) {\n\tCharsString token;\n\tTranslationTableOpcode opcode;\n\tCharsString ruleChars;\n\tCharsString ruleDots;\n\tCharsString cells;\n\tCharsString scratchPad;\n\tCharsString emphClass;\n\tTranslationTableCharacterAttributes after = 0;\n\tTranslationTableCharacterAttributes before = 0;\n\tint noback, nofor, nocross;\n\tnoback = nofor = nocross = 0;\ndoOpcode:\n\tif (!getToken(file, &token, NULL)) return 1;\t\t\t\t  \/* blank line *\/\n\tif (token.chars[0] == '#' || token.chars[0] == '<') return 1; \/* comment *\/\n\tif (file->lineNumber == 1 &&\n\t\t\t(eqasc2uni((unsigned char *)\"ISO\", token.chars, 3) ||\n\t\t\t\t\teqasc2uni((unsigned char *)\"UTF-8\", token.chars, 5))) {\n\t\tif (table)\n\t\t\tcompileHyphenation(file, &token, table);\n\t\telse\n\t\t\t\/* ignore the whole file *\/\n\t\t\twhile (_lou_getALine(file))\n\t\t\t\t;\n\t\treturn 1;\n\t}\n\topcode = getOpcode(file, &token);\n\tswitch (opcode) {\n\tcase CTO_Macro: {\n\t\tconst Macro *macro;\n#ifdef ENABLE_MACROS\n\t\tif (!inScopeMacros) {\n\t\t\tcompileError(file, \"Defining macros only allowed in table files.\");\n\t\t\treturn 0;\n\t\t}\n\t\tif (compileMacro(file, ¯o)) {\n\t\t\t*inScopeMacros = cons_macro(macro, *inScopeMacros);\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n#else\n\t\tcompileError(file, \"Macro feature is disabled.\");\n\t\treturn 0;\n#endif\n\t}\n\tcase CTO_IncludeFile: {\n\t\tCharsString includedFile;\n\t\tif (!getToken(file, &token, \"include file name\")) return 0;\n\t\tif (!parseChars(file, &includedFile, &token)) return 0;\n\t\treturn includeFile(file, &includedFile, table, displayTable);\n\t}\n\tcase CTO_NoBack:\n\t\tif (nofor) {\n\t\t\tcompileError(file, \"%s already specified.\", _lou_findOpcodeName(CTO_NoFor));\n\t\t\treturn 0;\n\t\t}\n\t\tnoback = 1;\n\t\tgoto doOpcode;\n\tcase CTO_NoFor:\n\t\tif (noback) {\n\t\t\tcompileError(file, \"%s already specified.\", _lou_findOpcodeName(CTO_NoBack));\n\t\t\treturn 0;\n\t\t}\n\t\tnofor = 1;\n\t\tgoto doOpcode;\n\tcase CTO_Space:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Space, noback, nofor, table, displayTable);\n\tcase CTO_Digit:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Digit, noback, nofor, table, displayTable);\n\tcase CTO_LitDigit:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_LitDigit, noback, nofor, table, displayTable);\n\tcase CTO_Punctuation:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Punctuation, noback, nofor, table, displayTable);\n\tcase CTO_Math:\n\t\treturn compileCharDef(file, opcode, CTC_Math, noback, nofor, table, displayTable);\n\tcase CTO_Sign:\n\t\treturn compileCharDef(file, opcode, CTC_Sign, noback, nofor, table, displayTable);\n\tcase CTO_Letter:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_Letter, noback, nofor, table, displayTable);\n\tcase CTO_UpperCase:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_UpperCase, noback, nofor, table, displayTable);\n\tcase CTO_LowerCase:\n\t\treturn compileCharDef(\n\t\t\t\tfile, opcode, CTC_LowerCase, noback, nofor, table, displayTable);\n\tcase CTO_Grouping:\n\t\treturn compileGrouping(file, noback, nofor, table, displayTable);\n\tcase CTO_Display:\n\t\tif (!displayTable) return 1;  \/\/ ignore\n\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\tif (ruleChars.length != 1 || ruleDots.length != 1) {\n\t\t\tcompileError(file, \"Exactly one character and one cell are required.\");\n\t\t\treturn 0;\n\t\t}\n\t\treturn putCharDotsMapping(\n\t\t\t\tfile, ruleChars.chars[0], ruleDots.chars[0], displayTable);\n\tcase CTO_UpLow:\n\tcase CTO_None: {\n\t\t\/\/ check if token is a macro name\n\t\tif (inScopeMacros) {\n\t\t\tconst MacroList *macros = *inScopeMacros;\n\t\t\twhile (macros) {\n\t\t\t\tconst Macro *m = macros->head;\n\t\t\t\tif (token.length == strlen(m->name) &&\n\t\t\t\t\t\teqasc2uni((unsigned char *)m->name, token.chars, token.length)) {\n\t\t\t\t\tif (!inScopeMacros) {\n\t\t\t\t\t\tcompileError(file, \"Calling macros only allowed in table files.\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tFileInfo tmpFile;\n\t\t\t\t\tmemset(&tmpFile, 0, sizeof(tmpFile));\n\t\t\t\t\ttmpFile.fileName = file->fileName;\n\t\t\t\t\ttmpFile.sourceFile = file->sourceFile;\n\t\t\t\t\ttmpFile.lineNumber = file->lineNumber;\n\t\t\t\t\ttmpFile.encoding = noEncoding;\n\t\t\t\t\ttmpFile.status = 0;\n\t\t\t\t\ttmpFile.linepos = 0;\n\t\t\t\t\ttmpFile.linelen = 0;\n\t\t\t\t\tint argument_count = 0;\n\t\t\t\t\tCharsString *arguments =\n\t\t\t\t\t\t\tmalloc(m->argument_count * sizeof(CharsString));\n\t\t\t\t\twhile (argument_count < m->argument_count) {\n\t\t\t\t\t\tif (getToken(file, &token, \"macro argument\"))\n\t\t\t\t\t\t\targuments[argument_count++] = token;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (argument_count < m->argument_count) {\n\t\t\t\t\t\tcompileError(file, \"Expected %d arguments\", m->argument_count);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tint i = 0;\n\t\t\t\t\tint subst = 0;\n\t\t\t\t\tint next = subst < m->substitution_count ? m->substitutions[2 * subst]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t : m->definition_length;\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\twhile (i < next) {\n\t\t\t\t\t\t\twidechar c = m->definition[i++];\n\t\t\t\t\t\t\tif (c == '\\n') {\n\t\t\t\t\t\t\t\tif (!compileRule(&tmpFile, table, displayTable,\n\t\t\t\t\t\t\t\t\t\t\tinScopeMacros)) {\n\t\t\t\t\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\t\t\t\t\"result of macro expansion was: %s\",\n\t\t\t\t\t\t\t\t\t\t\t_lou_showString(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttmpFile.line, tmpFile.linelen, 0));\n\t\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttmpFile.linepos = 0;\n\t\t\t\t\t\t\t\ttmpFile.linelen = 0;\n\t\t\t\t\t\t\t} else if (tmpFile.linelen >= MAXSTRING) {\n\t\t\t\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\t\t\t\"Line exceeds %d characters (post macro \"\n\t\t\t\t\t\t\t\t\t\t\"expansion)\",\n\t\t\t\t\t\t\t\t\t\tMAXSTRING);\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t} else\n\t\t\t\t\t\t\t\ttmpFile.line[tmpFile.linelen++] = c;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (subst < m->substitution_count) {\n\t\t\t\t\t\t\tCharsString arg =\n\t\t\t\t\t\t\t\t\targuments[m->substitutions[2 * subst + 1] - 1];\n\t\t\t\t\t\t\tfor (int j = 0; j < arg.length; j++)\n\t\t\t\t\t\t\t\ttmpFile.line[tmpFile.linelen++] = arg.chars[j];\n\t\t\t\t\t\t\tsubst++;\n\t\t\t\t\t\t\tnext = subst < m->substitution_count\n\t\t\t\t\t\t\t\t\t? m->substitutions[2 * subst]\n\t\t\t\t\t\t\t\t\t: m->definition_length;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!compileRule(\n\t\t\t\t\t\t\t\t\t\t&tmpFile, table, displayTable, inScopeMacros)) {\n\t\t\t\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\t\t\t\"result of macro expansion was: %s\",\n\t\t\t\t\t\t\t\t\t\t_lou_showString(\n\t\t\t\t\t\t\t\t\t\t\t\ttmpFile.line, tmpFile.linelen, 0));\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tmacros = macros->tail;\n\t\t\t}\n\t\t}\n\t\tif (opcode == CTO_UpLow) {\n\t\t\tcompileError(file, \"The uplow opcode is deprecated.\");\n\t\t\treturn 0;\n\t\t}\n\t\tcompileError(file, \"opcode %s not defined.\",\n\t\t\t\t_lou_showString(token.chars, token.length, 0));\n\t\treturn 0;\n\t}\n\n\t\/* now only opcodes follow that don't modify the display table *\/\n\tdefault:\n\t\tif (!table) return 1;\n\t\tswitch (opcode) {\n\t\tcase CTO_Locale:\n\t\t\tcompileWarning(file,\n\t\t\t\t\t\"The locale opcode is not implemented. Use the locale meta data \"\n\t\t\t\t\t\"instead.\");\n\t\t\treturn 1;\n\t\tcase CTO_Undefined: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->undefined;\n\t\t\tif (!compileBrailleIndicator(file, \"undefined character opcode\",\n\t\t\t\t\t\tCTO_Undefined, &ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->undefined = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_Match: {\n\t\t\tint ok = 0;\n\t\t\twidechar *patterns = NULL;\n\t\t\tTranslationTableRule *rule;\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\tCharsString ptn_before, ptn_after;\n\t\t\tTranslationTableOffset patternsOffset;\n\t\t\tint len, mrk;\n\t\t\tsize_t patternsByteSize = sizeof(*patterns) * 27720;\n\t\t\tpatterns = (widechar *)malloc(patternsByteSize);\n\t\t\tif (!patterns) _lou_outOfMemory();\n\t\t\tmemset(patterns, 0xffff, patternsByteSize);\n\t\t\tnoback = 1;\n\t\t\tgetCharacters(file, &ptn_before);\n\t\t\tgetRuleCharsText(file, &ruleChars);\n\t\t\tgetCharacters(file, &ptn_after);\n\t\t\tgetRuleDotsPattern(file, &ruleDots);\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset,\n\t\t\t\t\t\t&rule, noback, nofor, table))\n\t\t\t\tgoto CTO_Match_cleanup;\n\t\t\tif (ptn_before.chars[0] == '-' && ptn_before.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_before.chars[0], 0, &patterns[1], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length,\n\t\t\t\t\t\t&patterns[1], 13841, *table, file);\n\t\t\tif (!len) goto CTO_Match_cleanup;\n\t\t\tmrk = patterns[0] = len + 1;\n\t\t\t_lou_pattern_reverse(&patterns[1]);\n\t\t\tif (ptn_after.chars[0] == '-' && ptn_after.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length,\n\t\t\t\t\t\t&patterns[mrk], 13841, *table, file);\n\t\t\tif (!len) goto CTO_Match_cleanup;\n\t\t\tlen += mrk;\n\t\t\tif (!allocateSpaceInTranslationTable(\n\t\t\t\t\t\tfile, &patternsOffset, len * sizeof(widechar), table))\n\t\t\t\tgoto CTO_Match_cleanup;\n\t\t\t\/\/ allocateSpaceInTranslationTable may have moved table, so make sure rule is\n\t\t\t\/\/ still valid\n\t\t\trule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];\n\t\t\tmemcpy(&(*table)->ruleArea[patternsOffset], patterns, len * sizeof(widechar));\n\t\t\trule->patterns = patternsOffset;\n\t\t\tok = 1;\n\t\tCTO_Match_cleanup:\n\t\t\tfree(patterns);\n\t\t\treturn ok;\n\t\t}\n\n\t\tcase CTO_BackMatch: {\n\t\t\tint ok = 0;\n\t\t\twidechar *patterns = NULL;\n\t\t\tTranslationTableRule *rule;\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\tCharsString ptn_before, ptn_after;\n\t\t\tTranslationTableOffset patternOffset;\n\t\t\tint len, mrk;\n\t\t\tsize_t patternsByteSize = sizeof(*patterns) * 27720;\n\t\t\tpatterns = (widechar *)malloc(patternsByteSize);\n\t\t\tif (!patterns) _lou_outOfMemory();\n\t\t\tmemset(patterns, 0xffff, patternsByteSize);\n\t\t\tnofor = 1;\n\t\t\tgetCharacters(file, &ptn_before);\n\t\t\tgetRuleCharsText(file, &ruleChars);\n\t\t\tgetCharacters(file, &ptn_after);\n\t\t\tgetRuleDotsPattern(file, &ruleDots);\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, 0, 0, &ruleOffset, &rule,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\tgoto CTO_BackMatch_cleanup;\n\t\t\tif (ptn_before.chars[0] == '-' && ptn_before.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_before.chars[0], 0, &patterns[1], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length,\n\t\t\t\t\t\t&patterns[1], 13841, *table, file);\n\t\t\tif (!len) goto CTO_BackMatch_cleanup;\n\t\t\tmrk = patterns[0] = len + 1;\n\t\t\t_lou_pattern_reverse(&patterns[1]);\n\t\t\tif (ptn_after.chars[0] == '-' && ptn_after.length == 1)\n\t\t\t\tlen = _lou_pattern_compile(\n\t\t\t\t\t\t&ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file);\n\t\t\telse\n\t\t\t\tlen = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length,\n\t\t\t\t\t\t&patterns[mrk], 13841, *table, file);\n\t\t\tif (!len) goto CTO_BackMatch_cleanup;\n\t\t\tlen += mrk;\n\t\t\tif (!allocateSpaceInTranslationTable(\n\t\t\t\t\t\tfile, &patternOffset, len * sizeof(widechar), table))\n\t\t\t\tgoto CTO_BackMatch_cleanup;\n\t\t\t\/\/ allocateSpaceInTranslationTable may have moved table, so make sure rule is\n\t\t\t\/\/ still valid\n\t\t\trule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];\n\t\t\tmemcpy(&(*table)->ruleArea[patternOffset], patterns, len * sizeof(widechar));\n\t\t\trule->patterns = patternOffset;\n\t\t\tok = 1;\n\t\tCTO_BackMatch_cleanup:\n\t\t\tfree(patterns);\n\t\t\treturn ok;\n\t\t}\n\n\t\tcase CTO_CapsLetter:\n\t\tcase CTO_BegCapsWord:\n\t\tcase CTO_EndCapsWord:\n\t\tcase CTO_BegCaps:\n\t\tcase CTO_EndCaps:\n\t\tcase CTO_BegCapsPhrase:\n\t\tcase CTO_EndCapsPhrase:\n\t\tcase CTO_LenCapsPhrase:\n\t\t\/* these 8 general purpose opcodes are compiled further down to more specific\n\t\t * internal opcodes:\n\t\t * - modeletter\n\t\t * - begmodeword\n\t\t * - endmodeword\n\t\t * - begmode\n\t\t * - endmode\n\t\t * - begmodephrase\n\t\t * - endmodephrase\n\t\t * - lenmodephrase\n\t\t *\/\n\t\tcase CTO_ModeLetter:\n\t\tcase CTO_BegModeWord:\n\t\tcase CTO_EndModeWord:\n\t\tcase CTO_BegMode:\n\t\tcase CTO_EndMode:\n\t\tcase CTO_BegModePhrase:\n\t\tcase CTO_EndModePhrase:\n\t\tcase CTO_LenModePhrase: {\n\t\t\tTranslationTableCharacterAttributes mode;\n\t\t\tint i;\n\t\t\tswitch (opcode) {\n\t\t\tcase CTO_CapsLetter:\n\t\t\tcase CTO_BegCapsWord:\n\t\t\tcase CTO_EndCapsWord:\n\t\t\tcase CTO_BegCaps:\n\t\t\tcase CTO_EndCaps:\n\t\t\tcase CTO_BegCapsPhrase:\n\t\t\tcase CTO_EndCapsPhrase:\n\t\t\tcase CTO_LenCapsPhrase:\n\t\t\t\tmode = CTC_UpperCase;\n\t\t\t\ti = 0;\n\t\t\t\topcode += (CTO_ModeLetter - CTO_CapsLetter);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (!getToken(file, &token, \"attribute name\")) return 0;\n\t\t\t\tif (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tconst CharacterClass *characterClass = findCharacterClass(&token, *table);\n\t\t\t\tif (!characterClass) {\n\t\t\t\t\tcharacterClass =\n\t\t\t\t\t\t\taddCharacterClass(file, token.chars, token.length, *table, 1);\n\t\t\t\t\tif (!characterClass) return 0;\n\t\t\t\t}\n\t\t\t\tmode = characterClass->attribute;\n\t\t\t\tif (!(mode == CTC_UpperCase || mode == CTC_Digit) && mode >= CTC_Space &&\n\t\t\t\t\t\tmode <= CTC_LitDigit) {\n\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\"mode must be \\\"uppercase\\\", \\\"digit\\\", or a custom \"\n\t\t\t\t\t\t\t\"attribute name.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\t\/* check if this mode is already defined and if the number of modes does\n\t\t\t\t * not exceed the maximal number *\/\n\t\t\t\tif (mode == CTC_UpperCase)\n\t\t\t\t\ti = 0;\n\t\t\t\telse {\n\t\t\t\t\tfor (i = 1; i < MAX_MODES && (*table)->modes[i].value; i++) {\n\t\t\t\t\t\tif ((*table)->modes[i].mode == mode) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (i == MAX_MODES) {\n\t\t\t\t\t\tcompileError(file, \"Max number of modes (%i) reached\", MAX_MODES);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(*table)->modes[i].value)\n\t\t\t\t(*table)->modes[i] = (EmphasisClass){ plain_text, mode,\n\t\t\t\t\t0x1 << (MAX_EMPH_CLASSES + i), MAX_EMPH_CLASSES + i };\n\t\t\tswitch (opcode) {\n\t\t\tcase CTO_BegModePhrase: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first word capital sign\",\n\t\t\t\t\t\t\tCTO_BegCapsPhraseRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_EndModePhrase: {\n\t\t\t\tTranslationTableOffset ruleOffset;\n\t\t\t\tswitch (compileBeforeAfter(file)) {\n\t\t\t\tcase 1:\t \/\/ before\n\t\t\t\t\tif ((*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset]) {\n\t\t\t\t\t\tcompileError(\n\t\t\t\t\t\t\t\tfile, \"Capital sign after last word already defined.\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\truleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i]\n\t\t\t\t\t\t\t\t\t\t\t\t\t[endPhraseBeforeOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"capital sign before last word\",\n\t\t\t\t\t\t\t\tCTO_EndCapsPhraseBeforeRule + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseBeforeOffset] =\n\t\t\t\t\t\t\truleOffset;\n\t\t\t\t\treturn 1;\n\t\t\t\tcase 2:\t \/\/ after\n\t\t\t\t\tif ((*table)->emphRules[MAX_EMPH_CLASSES + i]\n\t\t\t\t\t\t\t\t\t\t   [endPhraseBeforeOffset]) {\n\t\t\t\t\t\tcompileError(\n\t\t\t\t\t\t\t\tfile, \"Capital sign before last word already defined.\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\truleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i]\n\t\t\t\t\t\t\t\t\t\t\t\t\t[endPhraseAfterOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"capital sign after last word\",\n\t\t\t\t\t\t\t\tCTO_EndCapsPhraseAfterRule + (8 * i), &ruleOffset, noback,\n\t\t\t\t\t\t\t\tnofor, table))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset] =\n\t\t\t\t\t\t\truleOffset;\n\t\t\t\t\treturn 1;\n\t\t\t\tdefault:  \/\/ error\n\t\t\t\t\tcompileError(file, \"Invalid lastword indicator location.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tcase CTO_BegMode: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first letter capital sign\",\n\t\t\t\t\t\t\tCTO_BegCapsRule + (8 * i), &ruleOffset, noback, nofor, table))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_EndMode: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"last letter capital sign\",\n\t\t\t\t\t\t\tCTO_EndCapsRule + (8 * i), &ruleOffset, noback, nofor, table))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_ModeLetter: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"single letter capital sign\",\n\t\t\t\t\t\t\tCTO_CapsLetterRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_BegModeWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"capital word\",\n\t\t\t\t\t\t\tCTO_BegCapsWordRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_EndModeWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"capital word stop\",\n\t\t\t\t\t\t\tCTO_EndCapsWordRule + (8 * i), &ruleOffset, noback, nofor,\n\t\t\t\t\t\t\ttable))\n\t\t\t\t\treturn 0;\n\t\t\t\t(*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset] = ruleOffset;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tcase CTO_LenModePhrase:\n\t\t\t\treturn (*table)->emphRules[MAX_EMPH_CLASSES + i][lenPhraseOffset] =\n\t\t\t\t\t\t\t   compileNumber(file);\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* these 8 general purpose emphasis opcodes are compiled further down to more\n\t\t * specific internal opcodes:\n\t\t * - emphletter\n\t\t * - begemphword\n\t\t * - endemphword\n\t\t * - begemph\n\t\t * - endemph\n\t\t * - begemphphrase\n\t\t * - endemphphrase\n\t\t * - lenemphphrase\n\t\t *\/\n\t\tcase CTO_EmphClass:\n\t\t\tif (!getToken(file, &emphClass, \"emphasis class\")) {\n\t\t\t\tcompileError(file, \"emphclass must be followed by a valid class name.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tint k, i;\n\t\t\tchar *s = malloc(sizeof(char) * (emphClass.length + 1));\n\t\t\tfor (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k];\n\t\t\ts[k++] = '\\0';\n\t\t\tfor (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++)\n\t\t\t\tif (strcmp(s, (*table)->emphClassNames[i]) == 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_WARN, \"Duplicate emphasis class: %s\", s);\n\t\t\t\t\twarningCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\tif (i == MAX_EMPH_CLASSES) {\n\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\"Max number of emphasis classes (%i) reached\", MAX_EMPH_CLASSES);\n\t\t\t\terrorCount++;\n\t\t\t\tfree(s);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tswitch (i) {\n\t\t\t\/* For backwards compatibility (i.e. because programs will assume\n\t\t\t * the first 3 typeform bits are `italic', `underline' and `bold')\n\t\t\t * we require that the first 3 emphclass definitions are (in that\n\t\t\t * order):\n\t\t\t *\n\t\t\t *   emphclass italic\n\t\t\t *   emphclass underline\n\t\t\t *   emphclass bold\n\t\t\t *\n\t\t\t * While it would be possible to use the emphclass opcode only for\n\t\t\t * defining _additional_ classes (not allowing for them to be called\n\t\t\t * italic, underline or bold), thereby reducing the amount of\n\t\t\t * boilerplate, we deliberately choose not to do that in order to\n\t\t\t * not give italic, underline and bold any special status. The\n\t\t\t * hope is that eventually all programs will use liblouis for\n\t\t\t * emphasis the recommended way (i.e. by looking up the supported\n\t\t\t * typeforms in the documentation or API) so that we can drop this\n\t\t\t * restriction.\n\t\t\t *\/\n\t\t\tcase 0:\n\t\t\t\tif (strcmp(s, \"italic\") != 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\"First emphasis class must be \\\"italic\\\" but got \"\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\ts);\n\t\t\t\t\terrorCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tif (strcmp(s, \"underline\") != 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\"Second emphasis class must be \\\"underline\\\" but \"\n\t\t\t\t\t\t\t\"got \"\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\ts);\n\t\t\t\t\terrorCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tif (strcmp(s, \"bold\") != 0) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_ERROR,\n\t\t\t\t\t\t\t\"Third emphasis class must be \\\"bold\\\" but got \"\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\ts);\n\t\t\t\t\terrorCount++;\n\t\t\t\t\tfree(s);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t(*table)->emphClassNames[i] = s;\n\t\t\t(*table)->emphClasses[i] = (EmphasisClass){ emph_1\n\t\t\t\t\t\t<< i, \/* relies on the order of typeforms emph_1..emph_10 *\/\n\t\t\t\t0, 0x1 << i, i };\n\t\t\treturn 1;\n\t\tcase CTO_EmphLetter:\n\t\tcase CTO_BegEmphWord:\n\t\tcase CTO_EndEmphWord:\n\t\tcase CTO_BegEmph:\n\t\tcase CTO_EndEmph:\n\t\tcase CTO_BegEmphPhrase:\n\t\tcase CTO_EndEmphPhrase:\n\t\tcase CTO_LenEmphPhrase:\n\t\tcase CTO_EmphModeChars:\n\t\tcase CTO_NoEmphChars: {\n\t\t\tif (!getToken(file, &token, \"emphasis class\")) return 0;\n\t\t\tif (!parseChars(file, &emphClass, &token)) return 0;\n\t\t\tchar *s = malloc(sizeof(char) * (emphClass.length + 1));\n\t\t\tint k, i;\n\t\t\tfor (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k];\n\t\t\ts[k++] = '\\0';\n\t\t\tfor (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++)\n\t\t\t\tif (strcmp(s, (*table)->emphClassNames[i]) == 0) break;\n\t\t\tif (i == MAX_EMPH_CLASSES || !(*table)->emphClassNames[i]) {\n\t\t\t\t_lou_logMessage(LOU_LOG_ERROR, \"Emphasis class %s not declared\", s);\n\t\t\t\terrorCount++;\n\t\t\t\tfree(s);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tint ok = 0;\n\t\t\tswitch (opcode) {\n\t\t\tcase CTO_EmphLetter: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][letterOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"single letter\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + letterOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][letterOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_BegEmphWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][begWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"word\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + begWordOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][begWordOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_EndEmphWord: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][endWordOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"word stop\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + endWordOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][endWordOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_BegEmph: {\n\t\t\t\t\/* fail if both begemph and any of begemphphrase or begemphword are\n\t\t\t\t * defined *\/\n\t\t\t\tif ((*table)->emphRules[i][begWordOffset] ||\n\t\t\t\t\t\t(*table)->emphRules[i][begPhraseOffset]) {\n\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\"Cannot define emphasis for both no context and word or \"\n\t\t\t\t\t\t\t\"phrase context, i.e. cannot have both begemph and \"\n\t\t\t\t\t\t\t\"begemphword or begemphphrase.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][begOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first letter\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + begOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][begOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_EndEmph: {\n\t\t\t\tif ((*table)->emphRules[i][endWordOffset] ||\n\t\t\t\t\t\t(*table)->emphRules[i][endPhraseBeforeOffset] ||\n\t\t\t\t\t\t(*table)->emphRules[i][endPhraseAfterOffset]) {\n\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\"Cannot define emphasis for both no context and word or \"\n\t\t\t\t\t\t\t\"phrase context, i.e. cannot have both endemph and \"\n\t\t\t\t\t\t\t\"endemphword or endemphphrase.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset = (*table)->emphRules[i][endOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"last letter\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + endOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][endOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_BegEmphPhrase: {\n\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\/\/ table\n\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t(*table)->emphRules[i][begPhraseOffset];\n\t\t\t\tif (!compileBrailleIndicator(file, \"first word\",\n\t\t\t\t\t\t\tCTO_Emph1LetterRule + begPhraseOffset + (8 * i), &ruleOffset,\n\t\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\t\tbreak;\n\t\t\t\t(*table)->emphRules[i][begPhraseOffset] = ruleOffset;\n\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_EndEmphPhrase:\n\t\t\t\tswitch (compileBeforeAfter(file)) {\n\t\t\t\tcase 1: {  \/\/ before\n\t\t\t\t\tif ((*table)->emphRules[i][endPhraseAfterOffset]) {\n\t\t\t\t\t\tcompileError(file, \"last word after already defined.\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t\t(*table)->emphRules[i][endPhraseBeforeOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"last word before\",\n\t\t\t\t\t\t\t\tCTO_Emph1LetterRule + endPhraseBeforeOffset + (8 * i),\n\t\t\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t(*table)->emphRules[i][endPhraseBeforeOffset] = ruleOffset;\n\t\t\t\t\tok = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 2: {  \/\/ after\n\t\t\t\t\tif ((*table)->emphRules[i][endPhraseBeforeOffset]) {\n\t\t\t\t\t\tcompileError(file, \"last word before already defined.\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate\n\t\t\t\t\t\/\/ table\n\t\t\t\t\tTranslationTableOffset ruleOffset =\n\t\t\t\t\t\t\t(*table)->emphRules[i][endPhraseAfterOffset];\n\t\t\t\t\tif (!compileBrailleIndicator(file, \"last word after\",\n\t\t\t\t\t\t\t\tCTO_Emph1LetterRule + endPhraseAfterOffset + (8 * i),\n\t\t\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t(*table)->emphRules[i][endPhraseAfterOffset] = ruleOffset;\n\t\t\t\t\tok = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:  \/\/ error\n\t\t\t\t\tcompileError(file, \"Invalid lastword indicator location.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CTO_LenEmphPhrase:\n\t\t\t\tif (((*table)->emphRules[i][lenPhraseOffset] = compileNumber(file)))\n\t\t\t\t\tok = 1;\n\t\t\t\tbreak;\n\t\t\tcase CTO_EmphModeChars: {\n\t\t\t\tif (!getRuleCharsText(file, &ruleChars)) break;\n\t\t\t\twidechar *emphmodechars = (*table)->emphModeChars[i];\n\t\t\t\tint len;\n\t\t\t\tfor (len = 0; len < EMPHMODECHARSSIZE && emphmodechars[len]; len++)\n\t\t\t\t\t;\n\t\t\t\tif (len + ruleChars.length > EMPHMODECHARSSIZE) {\n\t\t\t\t\tcompileError(file, \"More than %d characters\", EMPHMODECHARSSIZE);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tok = 1;\n\t\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\t\tif (!getChar(ruleChars.chars[k], *table, NULL)) {\n\t\t\t\t\t\tcompileError(file, \"Emphasis mode character undefined\");\n\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\temphmodechars[len++] = ruleChars.chars[k];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CTO_NoEmphChars: {\n\t\t\t\tif (!getRuleCharsText(file, &ruleChars)) break;\n\t\t\t\twidechar *noemphchars = (*table)->noEmphChars[i];\n\t\t\t\tint len;\n\t\t\t\tfor (len = 0; len < NOEMPHCHARSSIZE && noemphchars[len]; len++)\n\t\t\t\t\t;\n\t\t\t\tif (len + ruleChars.length > NOEMPHCHARSSIZE) {\n\t\t\t\t\tcompileError(file, \"More than %d characters\", NOEMPHCHARSSIZE);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tok = 1;\n\t\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\t\tif (!getChar(ruleChars.chars[k], *table, NULL)) {\n\t\t\t\t\t\tcompileError(file, \"Character undefined\");\n\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tnoemphchars[len++] = ruleChars.chars[k];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfree(s);\n\t\t\treturn ok;\n\t\t}\n\t\tcase CTO_LetterSign: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->letterSign;\n\t\t\tif (!compileBrailleIndicator(file, \"letter sign\", CTO_LetterRule, &ruleOffset,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->letterSign = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_NoLetsignBefore:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->noLetsignBeforeCount + ruleChars.length) > LETSIGNBEFORESIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", LETSIGNBEFORESIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->noLetsignBefore[(*table)->noLetsignBeforeCount++] =\n\t\t\t\t\t\truleChars.chars[k];\n\t\t\treturn 1;\n\t\tcase CTO_NoLetsign:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->noLetsignCount + ruleChars.length) > LETSIGNSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", LETSIGNSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->noLetsign[(*table)->noLetsignCount++] = ruleChars.chars[k];\n\t\t\treturn 1;\n\t\tcase CTO_NoLetsignAfter:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->noLetsignAfterCount + ruleChars.length) > LETSIGNAFTERSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", LETSIGNAFTERSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->noLetsignAfter[(*table)->noLetsignAfterCount++] =\n\t\t\t\t\t\truleChars.chars[k];\n\t\t\treturn 1;\n\t\tcase CTO_NumberSign: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->numberSign;\n\t\t\tif (!compileBrailleIndicator(file, \"number sign\", CTO_NumberRule, &ruleOffset,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->numberSign = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\n\t\tcase CTO_NumericModeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Numeric mode character undefined: %s\",\n\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[k], 1, 0));\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_NumericMode;\n\t\t\t\t(*table)->usesNumericMode = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_MidEndNumericModeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Midendnumeric mode character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_MidEndNumericMode;\n\t\t\t\t(*table)->usesNumericMode = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_NumericNoContractChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Numeric no contraction character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_NumericNoContract;\n\t\t\t\t(*table)->usesNumericMode = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_NoContractSign: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->noContractSign;\n\t\t\tif (!compileBrailleIndicator(file, \"no contractions sign\", CTO_NoContractRule,\n\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->noContractSign = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_SeqDelimiter:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Sequence delimiter character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_SeqDelimiter;\n\t\t\t\t(*table)->usesSequences = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqBeforeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Sequence before character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_SeqBefore;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqAfterChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Sequence after character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_SeqAfter;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqAfterPattern:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (((*table)->seqPatternsCount + ruleChars.length + 1) > SEQPATTERNSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", SEQPATTERNSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->seqPatterns[(*table)->seqPatternsCount++] = ruleChars.chars[k];\n\t\t\t(*table)->seqPatterns[(*table)->seqPatternsCount++] = 0;\n\t\t\treturn 1;\n\n\t\tcase CTO_SeqAfterExpression:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif ((ruleChars.length + 1) > SEQPATTERNSIZE) {\n\t\t\t\tcompileError(file, \"More than %d characters\", SEQPATTERNSIZE);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\t(*table)->seqAfterExpression[k] = ruleChars.chars[k];\n\t\t\t(*table)->seqAfterExpression[ruleChars.length] = 0;\n\t\t\t(*table)->seqAfterExpressionLength = ruleChars.length;\n\t\t\treturn 1;\n\n\t\tcase CTO_CapsModeChars:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!c) {\n\t\t\t\t\tcompileError(file, \"Capital mode character undefined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tc->attributes |= CTC_CapsMode;\n\t\t\t\t(*table)->hasCapsModeChars = 1;\n\t\t\t}\n\t\t\treturn 1;\n\n\t\tcase CTO_BegComp: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->begComp;\n\t\t\tif (!compileBrailleIndicator(file, \"begin computer braille\", CTO_BegCompRule,\n\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->begComp = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_EndComp: {\n\t\t\t\/\/ not passing pointer because compileBrailleIndicator may reallocate table\n\t\t\tTranslationTableOffset ruleOffset = (*table)->endComp;\n\t\t\tif (!compileBrailleIndicator(file, \"end computer braslle\", CTO_EndCompRule,\n\t\t\t\t\t\t&ruleOffset, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->endComp = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_NoCross:\n\t\t\tif (nocross) {\n\t\t\t\tcompileError(\n\t\t\t\t\t\tfile, \"%s already specified.\", _lou_findOpcodeName(CTO_NoCross));\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tnocross = 1;\n\t\t\tgoto doOpcode;\n\t\tcase CTO_Syllable:\n\t\t\t(*table)->syllables = 1;\n\t\tcase CTO_Always:\n\t\tcase CTO_LargeSign:\n\t\tcase CTO_WholeWord:\n\t\tcase CTO_PartWord:\n\t\tcase CTO_JoinNum:\n\t\tcase CTO_JoinableWord:\n\t\tcase CTO_LowWord:\n\t\tcase CTO_SuffixableWord:\n\t\tcase CTO_PrefixableWord:\n\t\tcase CTO_BegWord:\n\t\tcase CTO_BegMidWord:\n\t\tcase CTO_MidWord:\n\t\tcase CTO_MidEndWord:\n\t\tcase CTO_EndWord:\n\t\tcase CTO_PrePunc:\n\t\tcase CTO_PostPunc:\n\t\tcase CTO_BegNum:\n\t\tcase CTO_MidNum:\n\t\tcase CTO_EndNum:\n\t\tcase CTO_Repeated:\n\t\tcase CTO_RepWord:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\t\tif (ruleDots.length == 0)\n\t\t\t\t\/\/ check that all characters in a rule with `=` as second operand are\n\t\t\t\t\/\/ defined (or based on another character)\n\t\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\t\tTranslationTableCharacter *c =\n\t\t\t\t\t\t\tgetChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\t\tif (!(c && (c->definitionRule || c->basechar))) {\n\t\t\t\t\t\tcompileError(file, \"Character %s is not defined\",\n\t\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[k], 1, 0));\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tTranslationTableRule *r;\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, &r,\n\t\t\t\t\t\tnoback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\tif (nocross) r->nocross = 1;\n\t\t\treturn 1;\n\t\t\t\/\/ if (opcode == CTO_MidNum)\n\t\t\t\/\/ {\n\t\t\t\/\/   TranslationTableCharacter *c = getChar(ruleChars.chars[0]);\n\t\t\t\/\/   if(c)\n\t\t\t\/\/     c->attributes |= CTC_NumericMode;\n\t\t\t\/\/ }\n\t\tcase CTO_RepEndWord:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tCharsString dots;\n\t\t\tif (!getToken(file, &dots, \"dots,dots operand\")) return 0;\n\t\t\tint len = dots.length;\n\t\t\tfor (int k = 0; k < len - 1; k++) {\n\t\t\t\tif (dots.chars[k] == ',') {\n\t\t\t\t\tdots.length = k;\n\t\t\t\t\tif (!parseDots(file, &ruleDots, &dots)) return 0;\n\t\t\t\t\truleDots.chars[ruleDots.length++] = ',';\n\t\t\t\t\tk++;\n\t\t\t\t\tif (k == len - 1 && dots.chars[k] == '=') {\n\t\t\t\t\t\t\/\/ check that all characters are defined (or based on another\n\t\t\t\t\t\t\/\/ character)\n\t\t\t\t\t\tfor (int l = 0; l < ruleChars.length; l++) {\n\t\t\t\t\t\t\tTranslationTableCharacter *c =\n\t\t\t\t\t\t\t\t\tgetChar(ruleChars.chars[l], *table, NULL);\n\t\t\t\t\t\t\tif (!(c && (c->definitionRule || c->basechar))) {\n\t\t\t\t\t\t\t\tcompileError(file, \"Character %s is not defined\",\n\t\t\t\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[l], 1, 0));\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tCharsString x, y;\n\t\t\t\t\t\tx.length = 0;\n\t\t\t\t\t\twhile (k < len) x.chars[x.length++] = dots.chars[k++];\n\t\t\t\t\t\tif (parseDots(file, &y, &x))\n\t\t\t\t\t\t\tfor (int l = 0; l < y.length; l++)\n\t\t\t\t\t\t\t\truleDots.chars[ruleDots.length++] = y.chars[l];\n\t\t\t\t\t}\n\t\t\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, after, before,\n\t\t\t\t\t\t\tNULL, NULL, noback, nofor, table);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\tcase CTO_CompDots:\n\t\tcase CTO_Comp6: {\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (ruleChars.length != 1) {\n\t\t\t\tcompileError(file, \"first operand must be 1 character\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (nofor || noback) {\n\t\t\t\tcompileWarning(file, \"nofor and noback not allowed on comp6 rules\");\n\t\t\t}\n\t\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\t\tif (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset,\n\t\t\t\t\t\tNULL, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_ExactDots:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (ruleChars.chars[0] != '@') {\n\t\t\t\tcompileError(file, \"The operand must begin with an at sign (@)\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tfor (int k = 1; k < ruleChars.length; k++)\n\t\t\t\tscratchPad.chars[k - 1] = ruleChars.chars[k];\n\t\t\tscratchPad.length = ruleChars.length - 1;\n\t\t\tif (!parseDots(file, &ruleDots, &scratchPad)) return 0;\n\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, before, after, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\tcase CTO_CapsNoCont: {\n\t\t\tTranslationTableOffset ruleOffset;\n\t\t\truleChars.length = 1;\n\t\t\truleChars.chars[0] = 'a';\n\t\t\tif (!addRule(file, CTO_CapsNoContRule, &ruleChars, NULL, after, before,\n\t\t\t\t\t\t&ruleOffset, NULL, noback, nofor, table))\n\t\t\t\treturn 0;\n\t\t\t(*table)->capsNoCont = ruleOffset;\n\t\t\treturn 1;\n\t\t}\n\t\tcase CTO_Replace:\n\t\t\tif (getRuleCharsText(file, &ruleChars)) {\n\t\t\t\tif (atEndOfLine(file))\n\t\t\t\t\truleDots.length = ruleDots.chars[0] = 0;\n\t\t\t\telse {\n\t\t\t\t\tgetRuleDotsText(file, &ruleDots);\n\t\t\t\t\tif (ruleDots.chars[0] == '#')\n\t\t\t\t\t\truleDots.length = ruleDots.chars[0] = 0;\n\t\t\t\t\telse if (ruleDots.chars[0] == '\\\\' && ruleDots.chars[1] == '#')\n\t\t\t\t\t\tmemmove(&ruleDots.chars[0], &ruleDots.chars[1],\n\t\t\t\t\t\t\t\truleDots.length-- * CHARSIZE);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int k = 0; k < ruleChars.length; k++)\n\t\t\t\tputChar(file, ruleChars.chars[k], table, NULL);\n\t\t\tfor (int k = 0; k < ruleDots.length; k++)\n\t\t\t\tputChar(file, ruleDots.chars[k], table, NULL);\n\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\tcase CTO_Correct:\n\t\t\t(*table)->corrections = 1;\n\t\t\tgoto doPass;\n\t\tcase CTO_Pass2:\n\t\t\tif ((*table)->numPasses < 2) (*table)->numPasses = 2;\n\t\t\tgoto doPass;\n\t\tcase CTO_Pass3:\n\t\t\tif ((*table)->numPasses < 3) (*table)->numPasses = 3;\n\t\t\tgoto doPass;\n\t\tcase CTO_Pass4:\n\t\t\tif ((*table)->numPasses < 4) (*table)->numPasses = 4;\n\t\tdoPass:\n\t\tcase CTO_Context:\n\t\t\tif (!(nofor || noback)) {\n\t\t\t\tcompileError(file, \"%s or %s must be specified.\",\n\t\t\t\t\t\t_lou_findOpcodeName(CTO_NoFor), _lou_findOpcodeName(CTO_NoBack));\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn compilePassOpcode(file, opcode, noback, nofor, table);\n\t\tcase CTO_Contraction:\n\t\tcase CTO_NoCont:\n\t\tcase CTO_CompBrl:\n\t\tcase CTO_Literal:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\t\/\/ check that all characters in a compbrl, contraction,\n\t\t\t\/\/ nocont or literal rule are defined (or based on another\n\t\t\t\/\/ character)\n\t\t\tfor (int k = 0; k < ruleChars.length; k++) {\n\t\t\t\tTranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);\n\t\t\t\tif (!(c && (c->definitionRule || c->basechar))) {\n\t\t\t\t\tcompileError(file, \"Character %s is not defined\",\n\t\t\t\t\t\t\t_lou_showString(&ruleChars.chars[k], 1, 0));\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn addRule(file, opcode, &ruleChars, NULL, after, before, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\tcase CTO_MultInd: {\n\t\t\truleChars.length = 0;\n\t\t\tif (!getToken(file, &token, \"multiple braille indicators\") ||\n\t\t\t\t\t!parseDots(file, &cells, &token))\n\t\t\t\treturn 0;\n\t\t\twhile (getToken(file, &token, \"multind opcodes\")) {\n\t\t\t\topcode = getOpcode(file, &token);\n\t\t\t\tif (opcode == CTO_None) {\n\t\t\t\t\tcompileError(file, \"opcode %s not defined.\",\n\t\t\t\t\t\t\t_lou_showString(token.chars, token.length, 0));\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (!(opcode >= CTO_CapsLetter && opcode < CTO_MultInd)) {\n\t\t\t\t\tcompileError(file, \"Not a braille indicator opcode.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\truleChars.chars[ruleChars.length++] = (widechar)opcode;\n\t\t\t\tif (atEndOfLine(file)) break;\n\t\t\t}\n\t\t\treturn addRule(file, CTO_MultInd, &ruleChars, &cells, after, before, NULL,\n\t\t\t\t\tNULL, noback, nofor, table);\n\t\t}\n\n\t\tcase CTO_Class:\n\t\t\tcompileWarning(file, \"class is deprecated, use attribute instead\");\n\t\tcase CTO_Attribute: {\n\t\t\tif (nofor || noback) {\n\t\t\t\tcompileWarning(\n\t\t\t\t\t\tfile, \"nofor and noback not allowed before class\/attribute\");\n\t\t\t}\n\t\t\tif ((opcode == CTO_Class && (*table)->usesAttributeOrClass == 1) ||\n\t\t\t\t\t(opcode == CTO_Attribute && (*table)->usesAttributeOrClass == 2)) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"attribute and class rules must not be both present in a table\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (opcode == CTO_Class)\n\t\t\t\t(*table)->usesAttributeOrClass = 2;\n\t\t\telse\n\t\t\t\t(*table)->usesAttributeOrClass = 1;\n\t\t\tif (!getToken(file, &token, \"attribute name\")) {\n\t\t\t\tcompileError(file, \"Expected %s\", \"attribute name\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tTranslationTableCharacterAttributes attribute = 0;\n\t\t\t{\n\t\t\t\tint attrNumber = -1;\n\t\t\t\tswitch (token.chars[0]) {\n\t\t\t\tcase '0':\n\t\t\t\tcase '1':\n\t\t\t\tcase '2':\n\t\t\t\tcase '3':\n\t\t\t\tcase '4':\n\t\t\t\tcase '5':\n\t\t\t\tcase '6':\n\t\t\t\tcase '7':\n\t\t\t\tcase '8':\n\t\t\t\tcase '9':\n\t\t\t\t\tattrNumber = token.chars[0] - '0';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (attrNumber >= 0) {\n\t\t\t\t\tif (opcode == CTO_Class) {\n\t\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\t\"Invalid class name: may not contain digits, use \"\n\t\t\t\t\t\t\t\t\"attribute instead of class\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (token.length > 1 || attrNumber > 7) {\n\t\t\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\t\t\"Invalid attribute name: must be a digit between 0 and 7 \"\n\t\t\t\t\t\t\t\t\"or a word containing only letters\");\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (!(*table)->numberedAttributes[attrNumber])\n\t\t\t\t\t\t\/\/ attribute not used before yet: assign it a value\n\t\t\t\t\t\t(*table)->numberedAttributes[attrNumber] =\n\t\t\t\t\t\t\t\tgetNextNumberedAttribute(*table);\n\t\t\t\t\tattribute = (*table)->numberedAttributes[attrNumber];\n\t\t\t\t} else {\n\t\t\t\t\tconst CharacterClass *namedAttr = findCharacterClass(&token, *table);\n\t\t\t\t\tif (!namedAttr) {\n\t\t\t\t\t\t\/\/ no class with that name: create one\n\t\t\t\t\t\tnamedAttr = addCharacterClass(\n\t\t\t\t\t\t\t\tfile, &token.chars[0], token.length, *table, 1);\n\t\t\t\t\t\tif (!namedAttr) return 0;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ there is a class with that name or a new class was successfully\n\t\t\t\t\t\/\/ created\n\t\t\t\t\tattribute = namedAttr->attribute;\n\t\t\t\t\tif (attribute == CTC_UpperCase || attribute == CTC_LowerCase)\n\t\t\t\t\t\tattribute |= CTC_Letter;\n\t\t\t\t}\n\t\t\t}\n\t\t\tCharsString characters;\n\t\t\tif (!getCharacters(file, &characters)) return 0;\n\t\t\tfor (int i = 0; i < characters.length; i++) {\n\t\t\t\t\/\/ get the character from the table, or if it is not defined yet,\n\t\t\t\t\/\/ define it\n\t\t\t\tTranslationTableCharacter *character =\n\t\t\t\t\t\tputChar(file, characters.chars[i], table, NULL);\n\t\t\t\t\/\/ set the attribute\n\t\t\t\tcharacter->attributes |= attribute;\n\t\t\t\t\/\/ also set the attribute on the associated dots (if any)\n\t\t\t\tif (character->basechar)\n\t\t\t\t\tcharacter = (TranslationTableCharacter *)&(*table)\n\t\t\t\t\t\t\t\t\t\t->ruleArea[character->basechar];\n\t\t\t\tif (character->definitionRule) {\n\t\t\t\t\tTranslationTableRule *defRule =\n\t\t\t\t\t\t\t(TranslationTableRule *)&(*table)\n\t\t\t\t\t\t\t\t\t->ruleArea[character->definitionRule];\n\t\t\t\t\tif (defRule->dotslen == 1) {\n\t\t\t\t\t\tTranslationTableCharacter *dots =\n\t\t\t\t\t\t\t\tgetDots(defRule->charsdots[defRule->charslen], *table);\n\t\t\t\t\t\tif (dots) dots->attributes |= attribute;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 1;\n\t\t}\n\n\t\t\t{\n\t\t\t\tTranslationTableCharacterAttributes *attributes;\n\t\t\t\tconst CharacterClass *class;\n\t\t\tcase CTO_After:\n\t\t\t\tattributes = &after;\n\t\t\t\tgoto doBeforeAfter;\n\t\t\tcase CTO_Before:\n\t\t\t\tattributes = &before;\n\t\t\tdoBeforeAfter:\n\t\t\t\tif (!(*table)->characterClasses) {\n\t\t\t\t\tif (!allocateCharacterClasses(*table)) return 0;\n\t\t\t\t}\n\t\t\t\tif (!getToken(file, &token, \"attribute name\")) return 0;\n\t\t\t\tif (!(class = findCharacterClass(&token, *table))) {\n\t\t\t\t\tcompileError(file, \"attribute not defined\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\t*attributes |= class->attribute;\n\t\t\t\tgoto doOpcode;\n\t\t\t}\n\t\tcase CTO_Base:\n\t\t\tif (nofor || noback) {\n\t\t\t\tcompileWarning(file, \"nofor and noback not allowed before base\");\n\t\t\t}\n\t\t\tif (!getToken(file, &token, \"attribute name\")) {\n\t\t\t\tcompileError(\n\t\t\t\t\t\tfile, \"base opcode must be followed by a valid attribute name.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tconst CharacterClass *mode = findCharacterClass(&token, *table);\n\t\t\tif (!mode) {\n\t\t\t\tmode = addCharacterClass(file, token.chars, token.length, *table, 1);\n\t\t\t\tif (!mode) return 0;\n\t\t\t}\n\t\t\tif (!(mode->attribute == CTC_UpperCase || mode->attribute == CTC_Digit) &&\n\t\t\t\t\tmode->attribute >= CTC_Space && mode->attribute <= CTC_LitDigit) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"base opcode must be followed by \\\"uppercase\\\", \\\"digit\\\", or a \"\n\t\t\t\t\t\t\"custom attribute name.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (!getRuleCharsText(file, &token)) return 0;\n\t\t\tif (token.length != 1) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"Exactly one character followed by one base character is \"\n\t\t\t\t\t\t\"required.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tTranslationTableOffset characterOffset;\n\t\t\tTranslationTableCharacter *character =\n\t\t\t\t\tputChar(file, token.chars[0], table, &characterOffset);\n\t\t\tif (!getRuleCharsText(file, &token)) return 0;\n\t\t\tif (token.length != 1) {\n\t\t\t\tcompileError(file, \"Exactly one base character is required.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (character->definitionRule) {\n\t\t\t\tTranslationTableRule *prevRule =\n\t\t\t\t\t\t(TranslationTableRule *)&(*table)\n\t\t\t\t\t\t\t\t->ruleArea[character->definitionRule];\n\t\t\t\t_lou_logMessage(LOU_LOG_DEBUG,\n\t\t\t\t\t\t\"%s:%d: Character already defined (%s). The base rule will take \"\n\t\t\t\t\t\t\"precedence.\",\n\t\t\t\t\t\tfile->fileName, file->lineNumber,\n\t\t\t\t\t\tprintSource(file, prevRule->sourceFile, prevRule->sourceLine));\n\t\t\t\tcharacter->definitionRule = 0;\n\t\t\t}\n\t\t\tTranslationTableOffset basechar;\n\t\t\tputChar(file, token.chars[0], table, &basechar);\n\t\t\t\/\/ putChar may have moved table, so make sure character is still valid\n\t\t\tcharacter = (TranslationTableCharacter *)&(*table)->ruleArea[characterOffset];\n\t\t\tif (character->basechar) {\n\t\t\t\tif (character->basechar == basechar &&\n\t\t\t\t\t\tcharacter->mode == mode->attribute) {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_DEBUG, \"%s:%d: Duplicate base rule.\",\n\t\t\t\t\t\t\tfile->fileName, file->lineNumber);\n\t\t\t\t} else {\n\t\t\t\t\t_lou_logMessage(LOU_LOG_DEBUG,\n\t\t\t\t\t\t\t\"%s:%d: A different base rule already exists for this \"\n\t\t\t\t\t\t\t\"character (%s). The new rule will take precedence.\",\n\t\t\t\t\t\t\tfile->fileName, file->lineNumber,\n\t\t\t\t\t\t\tprintSource(\n\t\t\t\t\t\t\t\t\tfile, character->sourceFile, character->sourceLine));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcharacter->basechar = basechar;\n\t\t\tcharacter->mode = mode->attribute;\n\t\t\tcharacter->sourceFile = file->sourceFile;\n\t\t\tcharacter->sourceLine = file->lineNumber;\n\t\t\t\/* some other processing is done at the end of the compilation, in\n\t\t\t * finalizeTable() *\/\n\t\t\treturn 1;\n\t\tcase CTO_EmpMatchBefore:\n\t\t\tbefore |= CTC_EmpMatch;\n\t\t\tgoto doOpcode;\n\t\tcase CTO_EmpMatchAfter:\n\t\t\tafter |= CTC_EmpMatch;\n\t\t\tgoto doOpcode;\n\n\t\tcase CTO_SwapCc:\n\t\tcase CTO_SwapCd:\n\t\tcase CTO_SwapDd:\n\t\t\treturn compileSwap(file, opcode, noback, nofor, table);\n\t\tcase CTO_Hyphen:\n\t\tcase CTO_DecPoint:\n\t\t\t\/\/\tcase CTO_Apostrophe:\n\t\t\t\/\/\tcase CTO_Initial:\n\t\t\tif (!getRuleCharsText(file, &ruleChars)) return 0;\n\t\t\tif (!getRuleDotsPattern(file, &ruleDots)) return 0;\n\t\t\tif (ruleChars.length != 1 || ruleDots.length < 1) {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"One Unicode character and at least one cell are \"\n\t\t\t\t\t\t\"required.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL,\n\t\t\t\t\tnoback, nofor, table);\n\t\t\t\/\/ if (opcode == CTO_DecPoint)\n\t\t\t\/\/ {\n\t\t\t\/\/   TranslationTableCharacter *c =\n\t\t\t\/\/   getChar(ruleChars.chars[0]);\n\t\t\t\/\/   if(c)\n\t\t\t\/\/     c->attributes |= CTC_NumericMode;\n\t\t\t\/\/ }\n\t\tdefault:\n\t\t\tcompileError(file, \"unimplemented opcode.\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":14713,"total_token_length":14949,"max_tokens_setting":28000}
+{"idx":231012,"func":"mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)\n{\n  \/* mrb_assert(MRB_PROC_CFUNC_P(proc)) *\/\n  const mrb_irep *irep = proc->body.irep;\n  const mrb_pool_value *pool = irep->pool;\n  const mrb_sym *syms = irep->syms;\n  mrb_code insn;\n  int ai = mrb_gc_arena_save(mrb);\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf c_jmp;\n  uint32_t a;\n  uint16_t b;\n  uint16_t c;\n  mrb_sym mid;\n  const struct mrb_irep_catch_handler *ch;\n\n#ifdef DIRECT_THREADED\n  static const void * const optable[] = {\n#define OPCODE(x,_) &&L_OP_ ## x,\n#include \"mruby\/ops.h\"\n#undef OPCODE\n  };\n#endif\n\n  mrb_bool exc_catched = FALSE;\nRETRY_TRY_BLOCK:\n\n  MRB_TRY(&c_jmp) {\n\n  if (exc_catched) {\n    exc_catched = FALSE;\n    mrb_gc_arena_restore(mrb, ai);\n    if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)\n      goto L_BREAK;\n    goto L_RAISE;\n  }\n  mrb->jmp = &c_jmp;\n  mrb_vm_ci_proc_set(mrb->c->ci, proc);\n\n#define regs (mrb->c->ci->stack)\n  INIT_DISPATCH {\n    CASE(OP_NOP, Z) {\n      \/* do nothing *\/\n      NEXT;\n    }\n\n    CASE(OP_MOVE, BB) {\n      regs[a] = regs[b];\n      NEXT;\n    }\n\n    CASE(OP_LOADL, BB) {\n      switch (pool[b].tt) {   \/* number *\/\n      case IREP_TT_INT32:\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);\n        break;\n      case IREP_TT_INT64:\n#if defined(MRB_INT64)\n        regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n        break;\n#else\n#if defined(MRB_64BIT)\n        if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {\n          regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);\n          break;\n        }\n#endif\n        goto L_INT_OVERFLOW;\n#endif\n      case IREP_TT_BIGINT:\n#ifdef MRB_USE_BIGINT\n        {\n          const char *s = pool[b].u.str;\n          regs[a] = mrb_bint_new_str(mrb, s+2, (mrb_int)s[0], (mrb_int)s[1]);\n        }\n        break;\n#else\n        goto L_INT_OVERFLOW;\n#endif\n#ifndef MRB_NO_FLOAT\n      case IREP_TT_FLOAT:\n        regs[a] = mrb_float_value(mrb, pool[b].u.f);\n        break;\n#endif\n      default:\n        \/* should not happen (tt:string) *\/\n        regs[a] = mrb_nil_value();\n        break;\n      }\n      NEXT;\n    }\n\n    CASE(OP_LOADI, BB) {\n      SET_FIXNUM_VALUE(regs[a], b);\n      NEXT;\n    }\n\n    CASE(OP_LOADINEG, BB) {\n      SET_FIXNUM_VALUE(regs[a], -b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI__1,B) goto L_LOADI;\n    CASE(OP_LOADI_0,B) goto L_LOADI;\n    CASE(OP_LOADI_1,B) goto L_LOADI;\n    CASE(OP_LOADI_2,B) goto L_LOADI;\n    CASE(OP_LOADI_3,B) goto L_LOADI;\n    CASE(OP_LOADI_4,B) goto L_LOADI;\n    CASE(OP_LOADI_5,B) goto L_LOADI;\n    CASE(OP_LOADI_6,B) goto L_LOADI;\n    CASE(OP_LOADI_7, B) {\n    L_LOADI:\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);\n      NEXT;\n    }\n\n    CASE(OP_LOADI16, BS) {\n      SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);\n      NEXT;\n    }\n\n    CASE(OP_LOADI32, BSS) {\n      SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));\n      NEXT;\n    }\n\n    CASE(OP_LOADSYM, BB) {\n      SET_SYM_VALUE(regs[a], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_LOADNIL, B) {\n      SET_NIL_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADSELF, B) {\n      regs[a] = regs[0];\n      NEXT;\n    }\n\n    CASE(OP_LOADT, B) {\n      SET_TRUE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_LOADF, B) {\n      SET_FALSE_VALUE(regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETGV, BB) {\n      mrb_value val = mrb_gv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETGV, BB) {\n      mrb_gv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETSV, BB) {\n      mrb_value val = mrb_vm_special_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETSV, BB) {\n      mrb_vm_special_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIV, BB) {\n      regs[a] = mrb_iv_get(mrb, regs[0], syms[b]);\n      NEXT;\n    }\n\n    CASE(OP_SETIV, BB) {\n      mrb_iv_set(mrb, regs[0], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETCV, BB) {\n      mrb_value val;\n      val = mrb_vm_cv_get(mrb, syms[b]);\n      regs[a] = val;\n      NEXT;\n    }\n\n    CASE(OP_SETCV, BB) {\n      mrb_vm_cv_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETIDX, B) {\n      mrb_value va = regs[a], vb = regs[a+1];\n      switch (mrb_type(va)) {\n      case MRB_TT_ARRAY:\n        if (!mrb_integer_p(vb)) goto getidx_fallback;\n        regs[a] = mrb_ary_entry(va, mrb_integer(vb));\n        break;\n      case MRB_TT_HASH:\n        va = mrb_hash_get(mrb, va, vb);\n        regs[a] = va;\n        break;\n      case MRB_TT_STRING:\n        switch (mrb_type(vb)) {\n        case MRB_TT_INTEGER:\n        case MRB_TT_STRING:\n        case MRB_TT_RANGE:\n          va = mrb_str_aref(mrb, va, vb, mrb_undef_value());\n          regs[a] = va;\n          break;\n        default:\n          goto getidx_fallback;\n        }\n        break;\n      default:\n      getidx_fallback:\n        mid = MRB_OPSYM(aref);\n        goto L_SEND_SYM;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETIDX, B) {\n      c = 2;\n      mid = MRB_OPSYM(aset);\n      SET_NIL_VALUE(regs[a+3]);\n      goto L_SENDB_SYM;\n    }\n\n    CASE(OP_GETCONST, BB) {\n      mrb_value v = mrb_vm_const_get(mrb, syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETCONST, BB) {\n      mrb_vm_const_set(mrb, syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETMCNST, BB) {\n      mrb_value v = mrb_const_get(mrb, regs[a], syms[b]);\n      regs[a] = v;\n      NEXT;\n    }\n\n    CASE(OP_SETMCNST, BB) {\n      mrb_const_set(mrb, regs[a+1], syms[b], regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_GETUPVAR, BBB) {\n      mrb_value *regs_a = regs + a;\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e && b < MRB_ENV_LEN(e)) {\n        *regs_a = e->stack[b];\n      }\n      else {\n        *regs_a = mrb_nil_value();\n      }\n      NEXT;\n    }\n\n    CASE(OP_SETUPVAR, BBB) {\n      struct REnv *e = uvenv(mrb, c);\n\n      if (e) {\n        mrb_value *regs_a = regs + a;\n\n        if (b < MRB_ENV_LEN(e)) {\n          e->stack[b] = *regs_a;\n          mrb_write_barrier(mrb, (struct RBasic*)e);\n        }\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMP, S) {\n      pc += (int16_t)a;\n      JUMP;\n    }\n    CASE(OP_JMPIF, BS) {\n      if (mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNOT, BS) {\n      if (!mrb_test(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n    CASE(OP_JMPNIL, BS) {\n      if (mrb_nil_p(regs[a])) {\n        pc += (int16_t)b;\n        JUMP;\n      }\n      NEXT;\n    }\n\n    CASE(OP_JMPUW, S) {\n      a = (uint32_t)((pc - irep->iseq) + (int16_t)a);\n      CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {\n        struct RBreak *brk = (struct RBreak*)mrb->exc;\n        mrb_value target = mrb_break_value_get(brk);\n        mrb_assert(mrb_integer_p(target));\n        a = (uint32_t)mrb_integer(target);\n        mrb_assert(a >= 0 && a < irep->ilen);\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {\n        ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);\n        if (ch) {\n          \/* avoiding a jump from a catch handler into the same handler *\/\n          if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {\n            THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));\n          }\n        }\n      }\n      CHECKPOINT_END(RBREAK_TAG_JUMP);\n\n      mrb->exc = NULL; \/* clear break object *\/\n      pc = irep->iseq + a;\n      JUMP;\n    }\n\n    CASE(OP_EXCEPT, B) {\n      mrb_value exc;\n\n      if (mrb->exc == NULL) {\n        exc = mrb_nil_value();\n      }\n      else {\n        switch (mrb->exc->tt) {\n        case MRB_TT_BREAK:\n        case MRB_TT_EXCEPTION:\n          exc = mrb_obj_value(mrb->exc);\n          break;\n        default:\n          mrb_assert(!\"bad mrb_type\");\n          exc = mrb_nil_value();\n          break;\n        }\n        mrb->exc = NULL;\n      }\n      regs[a] = exc;\n      NEXT;\n    }\n    CASE(OP_RESCUE, BB) {\n      mrb_value exc = regs[a];  \/* exc on stack *\/\n      mrb_value e = regs[b];\n      struct RClass *ec;\n\n      switch (mrb_type(e)) {\n      case MRB_TT_CLASS:\n      case MRB_TT_MODULE:\n        break;\n      default:\n        {\n          mrb_value exc;\n\n          exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                    \"class or module required for rescue clause\");\n          mrb_exc_set(mrb, exc);\n          goto L_RAISE;\n        }\n      }\n      ec = mrb_class_ptr(e);\n      regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));\n      NEXT;\n    }\n\n    CASE(OP_RAISEIF, B) {\n      mrb_value exc = regs[a];\n      if (mrb_break_p(exc)) {\n        mrb->exc = mrb_obj_ptr(exc);\n        goto L_BREAK;\n      }\n      mrb_exc_set(mrb, exc);\n      if (mrb->exc) {\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_SSEND, BBB) {\n      regs[a] = regs[0];\n      insn = OP_SEND;\n    }\n    goto L_SENDB;\n\n    CASE(OP_SSENDB, BBB) {\n      regs[a] = regs[0];\n    }\n    goto L_SENDB;\n\n    CASE(OP_SEND, BBB)\n    goto L_SENDB;\n\n    L_SEND_SYM:\n    c = 1;\n    \/* push nil after arguments *\/\n    SET_NIL_VALUE(regs[a+2]);\n    goto L_SENDB_SYM;\n\n    CASE(OP_SENDB, BBB)\n    L_SENDB:\n    mid = syms[b];\n    L_SENDB_SYM:\n    {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_value recv, blk;\n\n      ARGUMENT_NORMALIZE(a, &c, insn);\n\n      recv = regs[a];\n      cls = mrb_class(mrb, recv);\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, c);\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        if (MRB_METHOD_PROC_P(m)) {\n          struct RProc *p = MRB_METHOD_PROC(m);\n\n          mrb_vm_ci_proc_set(ci, p);\n          recv = p->body.func(mrb, recv);\n        }\n        else {\n          if (MRB_METHOD_NOARG_P(m)) {\n            check_method_noarg(mrb, ci);\n          }\n          recv = MRB_METHOD_FUNC(m)(mrb, recv);\n        }\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n          if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n        if (!ci->u.target_class) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return recv;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        ci->stack[0] = recv;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n    }\n    JUMP;\n\n    CASE(OP_CALL, Z) {\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv = ci->stack[0];\n      struct RProc *m = mrb_proc_ptr(recv);\n\n      \/* replace callinfo *\/\n      ci->u.target_class = MRB_PROC_TARGET_CLASS(m);\n      mrb_vm_ci_proc_set(ci, m);\n      if (MRB_PROC_ENV_P(m)) {\n        ci->mid = MRB_PROC_ENV(m)->mid;\n      }\n\n      \/* prepare stack *\/\n      if (MRB_PROC_CFUNC_P(m)) {\n        recv = MRB_PROC_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_shrink(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        \/* pop stackpos *\/\n        ci = cipop(mrb);\n        pc = ci->pc;\n        ci[1].stack[0] = recv;\n        irep = mrb->c->ci->proc->body.irep;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        proc = m;\n        irep = m->body.irep;\n        if (!irep) {\n          mrb->c->ci->stack[0] = mrb_nil_value();\n          a = 0;\n          c = OP_R_NORMAL;\n          goto L_OP_RETURN_BODY;\n        }\n        mrb_int nargs = mrb_ci_bidx(ci)+1;\n        if (nargs < irep->nregs) {\n          mrb_stack_extend(mrb, irep->nregs);\n          stack_clear(regs+nargs, irep->nregs-nargs);\n        }\n        if (MRB_PROC_ENV_P(m)) {\n          regs[0] = MRB_PROC_ENV(m)->stack[0];\n        }\n        pc = irep->iseq;\n      }\n      pool = irep->pool;\n      syms = irep->syms;\n      JUMP;\n    }\n\n    CASE(OP_SUPER, BB) {\n      mrb_method_t m;\n      struct RClass *cls;\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_value recv, blk;\n      const struct RProc *p = ci->proc;\n      mrb_sym mid = ci->mid;\n      struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);\n\n      if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { \/* alias support *\/\n        mid = p->e.env->mid;    \/* restore old mid *\/\n      }\n\n      if (mid == 0 || !target_class) {\n        mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if ((target_class->flags & MRB_FL_CLASS_IS_PREPENDED) || target_class->tt == MRB_TT_MODULE) {\n        target_class = mrb_vm_ci_target_class(ci);\n        if (!target_class || target_class->tt != MRB_TT_ICLASS) {\n          goto super_typeerror;\n        }\n      }\n      recv = regs[0];\n      if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {\n      super_typeerror: ;\n        mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,\n                                            \"self has wrong type to call super in this context\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n\n      ARGUMENT_NORMALIZE(a, &b, OP_SUPER);\n\n      cls = target_class->super;\n      m = mrb_method_search_vm(mrb, &cls, mid);\n      if (MRB_METHOD_UNDEF_P(m)) {\n        m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1);\n        mid = MRB_SYM(method_missing);\n      }\n\n      \/* push callinfo *\/\n      ci = cipush(mrb, a, 0, cls, NULL, mid, b);\n\n      \/* prepare stack *\/\n      ci->stack[0] = recv;\n\n      if (MRB_METHOD_CFUNC_P(m)) {\n        mrb_value v;\n\n        if (MRB_METHOD_PROC_P(m)) {\n          mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n        }\n        v = MRB_METHOD_CFUNC(m)(mrb, recv);\n        mrb_gc_arena_restore(mrb, ai);\n        if (mrb->exc) goto L_RAISE;\n        ci = mrb->c->ci;\n        mrb_assert(!mrb_break_p(v));\n        if (!mrb_vm_ci_target_class(ci)) { \/* return from context modifying method (resume\/yield) *\/\n          if (ci->cci == CINFO_RESUMED) {\n            mrb->jmp = prev_jmp;\n            return v;\n          }\n          else {\n            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));\n            proc = ci[-1].proc;\n            irep = proc->body.irep;\n            pool = irep->pool;\n            syms = irep->syms;\n          }\n        }\n        mrb->c->ci->stack[0] = v;\n        ci = cipop(mrb);\n        pc = ci->pc;\n      }\n      else {\n        \/* setup environment for calling method *\/\n        mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);\n        pc = irep->iseq;\n      }\n      JUMP;\n    }\n\n    CASE(OP_ARGARY, BS) {\n      mrb_int m1 = (b>>11)&0x3f;\n      mrb_int r  = (b>>10)&0x1;\n      mrb_int m2 = (b>>5)&0x1f;\n      mrb_int kd = (b>>4)&0x1;\n      mrb_int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {\n        mrb_value exc;\n\n      L_NOSUPER:\n        exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, \"super called outside of method\");\n        mrb_exc_set(mrb, exc);\n        goto L_RAISE;\n      }\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e) goto L_NOSUPER;\n        if (MRB_ENV_LEN(e) <= m1+r+m2+1)\n          goto L_NOSUPER;\n        stack = e->stack + 1;\n      }\n      if (r == 0) {\n        regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack);\n      }\n      else {\n        mrb_value *pp = NULL;\n        struct RArray *rest;\n        mrb_int len = 0;\n\n        if (mrb_array_p(stack[m1])) {\n          struct RArray *ary = mrb_ary_ptr(stack[m1]);\n\n          pp = ARY_PTR(ary);\n          len = ARY_LEN(ary);\n        }\n        regs[a] = mrb_ary_new_capa(mrb, m1+len+m2);\n        rest = mrb_ary_ptr(regs[a]);\n        if (m1 > 0) {\n          stack_copy(ARY_PTR(rest), stack, m1);\n        }\n        if (len > 0) {\n          stack_copy(ARY_PTR(rest)+m1, pp, len);\n        }\n        if (m2 > 0) {\n          stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2);\n        }\n        ARY_SET_LEN(rest, m1+len+m2);\n      }\n      if (kd) {\n        regs[a+1] = stack[m1+r+m2];\n        regs[a+2] = stack[m1+r+m2+1];\n      }\n      else {\n        regs[a+1] = stack[m1+r+m2];\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ENTER, W) {\n      mrb_int m1 = MRB_ASPEC_REQ(a);\n      mrb_int o  = MRB_ASPEC_OPT(a);\n      mrb_int r  = MRB_ASPEC_REST(a);\n      mrb_int m2 = MRB_ASPEC_POST(a);\n      mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;\n      \/* unused\n      int b  = MRB_ASPEC_BLOCK(a);\n      *\/\n      mrb_int const len = m1 + o + r + m2;\n\n      mrb_callinfo *ci = mrb->c->ci;\n      mrb_int argc = ci->n;\n      mrb_value *argv = regs+1;\n      mrb_value * const argv0 = argv;\n      mrb_int const kw_pos = len + kd;    \/* where kwhash should be *\/\n      mrb_int const blk_pos = kw_pos + 1; \/* where block should be *\/\n      mrb_value blk = regs[mrb_ci_bidx(ci)];\n      mrb_value kdict = mrb_nil_value();\n\n      \/* keyword arguments *\/\n      if (ci->nk > 0) {\n        mrb_int kidx = mrb_ci_kidx(ci);\n        kdict = regs[kidx];\n        if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) {\n          kdict = mrb_nil_value();\n          ci->nk = 0;\n        }\n      }\n      if (!kd && !mrb_nil_p(kdict)) {\n        if (argc < 14) {\n          ci->n++;\n          argc++;    \/* include kdict in normal arguments *\/\n        }\n        else if (argc == 14) {\n          \/* pack arguments and kdict *\/\n          regs[1] = mrb_ary_new_from_values(mrb, argc+1, ®s[1]);\n          argc = ci->n = 15;\n        }\n        else {\/* argc == 15 *\/\n          \/* push kdict to packed arguments *\/\n          mrb_ary_push(mrb, regs[1], regs[2]);\n        }\n        ci->nk = 0;\n      }\n      if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) {\n        kdict = mrb_hash_dup(mrb, kdict);\n      }\n\n      \/* arguments is passed with Array *\/\n      if (argc == 15) {\n        struct RArray *ary = mrb_ary_ptr(regs[1]);\n        argv = ARY_PTR(ary);\n        argc = (int)ARY_LEN(ary);\n        mrb_gc_protect(mrb, regs[1]);\n      }\n\n      \/* strict argument check *\/\n      if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) {\n        if (argc < m1 + m2 || (r == 0 && argc > len)) {\n          argnum_error(mrb, m1+m2);\n          goto L_RAISE;\n        }\n      }\n      \/* extract first argument array to arguments *\/\n      else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) {\n        mrb_gc_protect(mrb, argv[0]);\n        argc = (int)RARRAY_LEN(argv[0]);\n        argv = RARRAY_PTR(argv[0]);\n      }\n\n      \/* rest arguments *\/\n      mrb_value rest = mrb_nil_value();\n      if (argc < len) {\n        mrb_int mlen = m2;\n        if (argc < m1+m2) {\n          mlen = m1 < argc ? argc - m1 : 0;\n        }\n\n        \/* copy mandatory and optional arguments *\/\n        if (argv0 != argv && argv) {\n          value_move(®s[1], argv, argc-mlen); \/* m1 + o *\/\n        }\n        if (argc < m1) {\n          stack_clear(®s[argc+1], m1-argc);\n        }\n        \/* copy post mandatory arguments *\/\n        if (mlen) {\n          value_move(®s[len-m2+1], &argv[argc-mlen], mlen);\n        }\n        if (mlen < m2) {\n          stack_clear(®s[len-m2+mlen+1], m2-mlen);\n        }\n        \/* initialize rest arguments with empty Array *\/\n        if (r) {\n          rest = mrb_ary_new_capa(mrb, 0);\n          regs[m1+o+1] = rest;\n        }\n        \/* skip initializer of passed arguments *\/\n        if (o > 0 && argc > m1+m2)\n          pc += (argc - m1 - m2)*3;\n      }\n      else {\n        mrb_int rnum = 0;\n        if (argv0 != argv) {\n          value_move(®s[1], argv, m1+o);\n        }\n        if (r) {\n          rnum = argc-m1-o-m2;\n          rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o);\n          regs[m1+o+1] = rest;\n        }\n        if (m2 > 0 && argc-m2 > m1) {\n          value_move(®s[m1+o+r+1], &argv[m1+o+rnum], m2);\n        }\n        pc += o*3;\n      }\n\n      \/* need to be update blk first to protect blk from GC *\/\n      regs[blk_pos] = blk;              \/* move block *\/\n      if (kd) {\n        if (mrb_nil_p(kdict))\n          kdict = mrb_hash_new_capa(mrb, 0);\n        regs[kw_pos] = kdict;           \/* set kwhash *\/\n      }\n\n      \/* format arguments for generated code *\/\n      mrb->c->ci->n = (uint8_t)len;\n\n      \/* clear local (but non-argument) variables *\/\n      if (irep->nlocals-blk_pos-1 > 0) {\n        stack_clear(®s[blk_pos+1], irep->nlocals-blk_pos-1);\n      }\n      JUMP;\n    }\n\n    CASE(OP_KARG, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict, v;\n\n      if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) {\n        mrb_value str = mrb_format(mrb, \"missing keyword: %v\", k);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      v = mrb_hash_get(mrb, kdict, k);\n      regs[a] = v;\n      mrb_hash_delete_key(mrb, kdict, k);\n      NEXT;\n    }\n\n    CASE(OP_KEY_P, BB) {\n      mrb_value k = mrb_symbol_value(syms[b]);\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n      mrb_bool key_p = FALSE;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) {\n        key_p = mrb_hash_key_p(mrb, kdict, k);\n      }\n      regs[a] = mrb_bool_value(key_p);\n      NEXT;\n    }\n\n    CASE(OP_KEYEND, Z) {\n      mrb_int kidx = mrb_ci_kidx(mrb->c->ci);\n      mrb_value kdict;\n\n      if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) {\n        mrb_value keys = mrb_hash_keys(mrb, kdict);\n        mrb_value key1 = RARRAY_PTR(keys)[0];\n        mrb_value str = mrb_format(mrb, \"unknown keyword: %v\", key1);\n        mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));\n        goto L_RAISE;\n      }\n      NEXT;\n    }\n\n    CASE(OP_BREAK, B) {\n      c = OP_R_BREAK;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN_BLK, B) {\n      c = OP_R_RETURN;\n      goto L_RETURN;\n    }\n    CASE(OP_RETURN, B)\n    c = OP_R_NORMAL;\n    L_RETURN:\n    {\n      mrb_callinfo *ci;\n\n      ci = mrb->c->ci;\n      if (ci->mid) {\n        mrb_value blk = regs[mrb_ci_bidx(ci)];\n\n        if (mrb_proc_p(blk)) {\n          struct RProc *p = mrb_proc_ptr(blk);\n\n          if (!MRB_PROC_STRICT_P(p) &&\n              ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {\n            p->flags |= MRB_PROC_ORPHAN;\n          }\n        }\n      }\n\n      if (mrb->exc) {\n      L_RAISE:\n        ci = mrb->c->ci;\n        if (ci == mrb->c->cibase) {\n          ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n          if (ch == NULL) goto L_FTOP;\n          goto L_CATCH;\n        }\n        while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {\n          ci = cipop(mrb);\n          if (ci[1].cci == CINFO_SKIP && prev_jmp) {\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          pc = ci[0].pc;\n          if (ci == mrb->c->cibase) {\n            ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);\n            if (ch == NULL) {\n            L_FTOP:             \/* fiber top *\/\n              if (mrb->c == mrb->root_c) {\n                mrb->c->ci->stack = mrb->c->stbase;\n                goto L_STOP;\n              }\n              else {\n                struct mrb_context *c = mrb->c;\n\n                c->status = MRB_FIBER_TERMINATED;\n                mrb->c = c->prev;\n                c->prev = NULL;\n                goto L_RAISE;\n              }\n            }\n            break;\n          }\n        }\n      L_CATCH:\n        if (ch == NULL) goto L_STOP;\n        if (FALSE) {\n        L_CATCH_TAGGED_BREAK: \/* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() *\/\n          ci = mrb->c->ci;\n        }\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n        mrb_stack_extend(mrb, irep->nregs);\n        pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);\n      }\n      else {\n        mrb_int acc;\n        mrb_value v;\n\n        ci = mrb->c->ci;\n        v = regs[a];\n        mrb_gc_protect(mrb, v);\n        switch (c) {\n        case OP_R_RETURN:\n          \/* Fall through to OP_R_NORMAL otherwise *\/\n          if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {\n            const struct RProc *dst;\n            mrb_callinfo *cibase;\n            cibase = mrb->c->cibase;\n            dst = top_proc(mrb, proc);\n\n            if (MRB_PROC_ENV_P(dst)) {\n              struct REnv *e = MRB_PROC_ENV(dst);\n\n              if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n            }\n            \/* check jump destination *\/\n            while (cibase <= ci && ci->proc != dst) {\n              if (ci->cci > CINFO_NONE) { \/* jump cross C boundary *\/\n                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n                goto L_RAISE;\n              }\n              ci--;\n            }\n            if (ci <= cibase) { \/* no jump destination *\/\n              localjump_error(mrb, LOCALJUMP_ERROR_RETURN);\n              goto L_RAISE;\n            }\n            ci = mrb->c->ci;\n            while (cibase <= ci && ci->proc != dst) {\n              CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {\n                cibase = mrb->c->cibase;\n                dst = top_proc(mrb, proc);\n              }\n              CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {\n                UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);\n              }\n              CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);\n              ci = cipop(mrb);\n              pc = ci->pc;\n            }\n            proc = ci->proc;\n            mrb->exc = NULL; \/* clear break object *\/\n            break;\n          }\n          \/* fallthrough *\/\n        case OP_R_NORMAL:\n        NORMAL_RETURN:\n          if (ci == mrb->c->cibase) {\n            struct mrb_context *c;\n            c = mrb->c;\n\n            if (!c->prev) { \/* toplevel return *\/\n              regs[irep->nlocals] = v;\n              goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);\n            }\n            if (!c->vmexec && c->prev->ci == c->prev->cibase) {\n              mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, \"double resume\");\n              mrb_exc_set(mrb, exc);\n              goto L_RAISE;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {\n              c = mrb->c;\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);\n            \/* automatic yield at the end *\/\n            c->status = MRB_FIBER_TERMINATED;\n            mrb->c = c->prev;\n            mrb->c->status = MRB_FIBER_RUNNING;\n            c->prev = NULL;\n            if (c->vmexec) {\n              mrb_gc_arena_restore(mrb, ai);\n              c->vmexec = FALSE;\n              mrb->jmp = prev_jmp;\n              return v;\n            }\n            ci = mrb->c->ci;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_RETURN);\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        case OP_R_BREAK:\n          if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;\n          if (MRB_PROC_ORPHAN_P(proc)) {\n            mrb_value exc;\n\n          L_BREAK_ERROR:\n            exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,\n                                      \"break from proc-closure\");\n            mrb_exc_set(mrb, exc);\n            goto L_RAISE;\n          }\n          if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {\n            goto L_BREAK_ERROR;\n          }\n          else {\n            struct REnv *e = MRB_PROC_ENV(proc);\n\n            if (e->cxt != mrb->c) {\n              goto L_BREAK_ERROR;\n            }\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK);\n          \/* break from fiber block *\/\n          if (ci == mrb->c->cibase && ci->pc) {\n            struct mrb_context *c = mrb->c;\n\n            mrb->c = c->prev;\n            c->prev = NULL;\n            ci = mrb->c->ci;\n          }\n          if (ci->cci > CINFO_NONE) {\n            ci = cipop(mrb);\n            mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);\n            mrb_gc_arena_restore(mrb, ai);\n            mrb->c->vmexec = FALSE;\n            mrb->jmp = prev_jmp;\n            MRB_THROW(prev_jmp);\n          }\n          if (FALSE) {\n            struct RBreak *brk;\n\n          L_BREAK:\n            brk = (struct RBreak*)mrb->exc;\n            proc = mrb_break_proc_get(brk);\n            v = mrb_break_value_get(brk);\n            ci = mrb->c->ci;\n\n            switch (mrb_break_tag_get(brk)) {\n#define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);\n              RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)\n#undef DISPATCH_CHECKPOINTS\n              default:\n                mrb_assert(!\"wrong break tag\");\n            }\n          }\n          while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {\n            if (ci[-1].cci == CINFO_SKIP) {\n              goto L_BREAK_ERROR;\n            }\n            CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {\n              \/* do nothing *\/\n            }\n            CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {\n              UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);\n            }\n            CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);\n            ci = cipop(mrb);\n            pc = ci->pc;\n          }\n          CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {\n            \/* do nothing *\/\n          }\n          CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {\n            UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);\n          }\n          CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);\n          if (ci == mrb->c->cibase) {\n            goto L_BREAK_ERROR;\n          }\n          mrb->exc = NULL; \/* clear break object *\/\n          break;\n        default:\n          \/* cannot happen *\/\n          break;\n        }\n        mrb_assert(ci == mrb->c->ci);\n        mrb_assert(mrb->exc == NULL);\n\n        if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->c->vmexec = FALSE;\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        acc = ci->cci;\n        ci = cipop(mrb);\n        if (acc == CINFO_SKIP || acc == CINFO_DIRECT) {\n          mrb_gc_arena_restore(mrb, ai);\n          mrb->jmp = prev_jmp;\n          return v;\n        }\n        pc = ci->pc;\n        DEBUG(fprintf(stderr, \"from :%s\\n\", mrb_sym_name(mrb, ci->mid)));\n        proc = ci->proc;\n        irep = proc->body.irep;\n        pool = irep->pool;\n        syms = irep->syms;\n\n        ci[1].stack[0] = v;\n        mrb_gc_arena_restore(mrb, ai);\n      }\n      JUMP;\n    }\n\n    CASE(OP_BLKPUSH, BS) {\n      int m1 = (b>>11)&0x3f;\n      int r  = (b>>10)&0x1;\n      int m2 = (b>>5)&0x1f;\n      int kd = (b>>4)&0x1;\n      int lv = (b>>0)&0xf;\n      mrb_value *stack;\n\n      if (lv == 0) stack = regs + 1;\n      else {\n        struct REnv *e = uvenv(mrb, lv-1);\n        if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||\n            MRB_ENV_LEN(e) <= m1+r+m2+1) {\n          localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n          goto L_RAISE;\n        }\n        stack = e->stack + 1;\n      }\n      if (mrb_nil_p(stack[m1+r+m2+kd])) {\n        localjump_error(mrb, LOCALJUMP_ERROR_YIELD);\n        goto L_RAISE;\n      }\n      regs[a] = stack[m1+r+m2+kd];\n      NEXT;\n    }\n\n#if !defined(MRB_USE_BIGINT) || defined(MRB_INT32)\n  L_INT_OVERFLOW:\n    {\n      mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, \"integer overflow\");\n      mrb_exc_set(mrb, exc);\n    }\n    goto L_RAISE;\n#endif\n\n#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))\n#define OP_MATH(op_name)                                                    \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {                  \\\n    OP_MATH_CASE_INTEGER(op_name);                                          \\\n    OP_MATH_CASE_FLOAT(op_name, integer, float);                            \\\n    OP_MATH_CASE_FLOAT(op_name, float,  integer);                           \\\n    OP_MATH_CASE_FLOAT(op_name, float,  float);                             \\\n    OP_MATH_CASE_STRING_##op_name();                                        \\\n    default:                                                                \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATH_CASE_INTEGER(op_name)                                       \\\n  case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER):                              \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z;      \\\n      if (mrb_int_##op_name##_overflow(x, y, &z)) {                         \\\n        OP_MATH_OVERFLOW_INT(op_name,x,y);                                  \\\n      }                                                                     \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0\n#else\n#define OP_MATH_CASE_FLOAT(op_name, t1, t2)                                     \\\n  case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2):                                \\\n    {                                                                           \\\n      mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                         \\\n    }                                                                           \\\n    break\n#endif\n#ifdef MRB_USE_BIGINT\n#define OP_MATH_OVERFLOW_INT(op,x,y) regs[a] = mrb_bint_##op##_ii(mrb,x,y)\n#else\n#define OP_MATH_OVERFLOW_INT(op,x,y) goto L_INT_OVERFLOW\n#endif\n#define OP_MATH_CASE_STRING_add()                                           \\\n  case TYPES2(MRB_TT_STRING, MRB_TT_STRING):                                \\\n    regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]);                        \\\n    mrb_gc_arena_restore(mrb, ai);                                          \\\n    break\n#define OP_MATH_CASE_STRING_sub() (void)0\n#define OP_MATH_CASE_STRING_mul() (void)0\n#define OP_MATH_OP_add +\n#define OP_MATH_OP_sub -\n#define OP_MATH_OP_mul *\n#define OP_MATH_TT_integer MRB_TT_INTEGER\n#define OP_MATH_TT_float   MRB_TT_FLOAT\n\n    CASE(OP_ADD, B) {\n      OP_MATH(add);\n    }\n\n    CASE(OP_SUB, B) {\n      OP_MATH(sub);\n    }\n\n    CASE(OP_MUL, B) {\n      OP_MATH(mul);\n    }\n\n    CASE(OP_DIV, B) {\n#ifndef MRB_NO_FLOAT\n      mrb_float x, y, f;\n#endif\n\n      \/* need to check if op is overridden *\/\n      switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\n        {\n          mrb_int x = mrb_integer(regs[a]);\n          mrb_int y = mrb_integer(regs[a+1]);\n          mrb_int div = mrb_div_int(mrb, x, y);\n          SET_INT_VALUE(mrb, regs[a], div);\n        }\n        NEXT;\n#ifndef MRB_NO_FLOAT\n      case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\n        x = (mrb_float)mrb_integer(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\n        x = mrb_float(regs[a]);\n        y = (mrb_float)mrb_integer(regs[a+1]);\n        break;\n      case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\n        x = mrb_float(regs[a]);\n        y = mrb_float(regs[a+1]);\n        break;\n#endif\n      default:\n        mid = MRB_OPSYM(div);\n        goto L_SEND_SYM;\n      }\n\n#ifndef MRB_NO_FLOAT\n      f = mrb_div_float(x, y);\n      SET_FLOAT_VALUE(mrb, regs[a], f);\n#endif\n      NEXT;\n    }\n\n#define OP_MATHI(op_name)                                                   \\\n  \/* need to check if op is overridden *\/                                   \\\n  switch (mrb_type(regs[a])) {                                              \\\n    OP_MATHI_CASE_INTEGER(op_name);                                         \\\n    OP_MATHI_CASE_FLOAT(op_name);                                           \\\n    default:                                                                \\\n      SET_INT_VALUE(mrb,regs[a+1], b);                                      \\\n      mid = MRB_OPSYM(op_name);                                             \\\n      goto L_SEND_SYM;                                                      \\\n  }                                                                         \\\n  NEXT;\n#define OP_MATHI_CASE_INTEGER(op_name)                                      \\\n  case MRB_TT_INTEGER:                                                      \\\n    {                                                                       \\\n      mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z;                  \\\n      if (mrb_int_##op_name##_overflow(x, y, &z)) {                         \\\n        OP_MATH_OVERFLOW_INT(op_name,x,y);                                  \\\n      }                                                                     \\\n      else                                                                  \\\n        SET_INT_VALUE(mrb,regs[a], z);                                      \\\n    }                                                                       \\\n    break\n#ifdef MRB_NO_FLOAT\n#define OP_MATHI_CASE_FLOAT(op_name) (void)0\n#else\n#define OP_MATHI_CASE_FLOAT(op_name)                                        \\\n  case MRB_TT_FLOAT:                                                        \\\n    {                                                                       \\\n      mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b;              \\\n      SET_FLOAT_VALUE(mrb, regs[a], z);                                     \\\n    }                                                                       \\\n    break\n#endif\n\n    CASE(OP_ADDI, BB) {\n      OP_MATHI(add);\n    }\n\n    CASE(OP_SUBI, BB) {\n      OP_MATHI(sub);\n    }\n\n#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))\n\n#ifdef MRB_NO_FLOAT\n#define OP_CMP(op,sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#else\n#define OP_CMP(op, sym) do {\\\n  int result;\\\n  \/* need to check if - is overridden *\/\\\n  switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\\\n    break;\\\n  case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\\\n    result = OP_CMP_BODY(op,mrb_float,mrb_float);\\\n    break;\\\n  default:\\\n    mid = MRB_OPSYM(sym);\\\n    goto L_SEND_SYM;\\\n  }\\\n  if (result) {\\\n    SET_TRUE_VALUE(regs[a]);\\\n  }\\\n  else {\\\n    SET_FALSE_VALUE(regs[a]);\\\n  }\\\n} while(0)\n#endif\n\n    CASE(OP_EQ, B) {\n      if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {\n        SET_TRUE_VALUE(regs[a]);\n      }\n      else {\n        OP_CMP(==,eq);\n      }\n      NEXT;\n    }\n\n    CASE(OP_LT, B) {\n      OP_CMP(<,lt);\n      NEXT;\n    }\n\n    CASE(OP_LE, B) {\n      OP_CMP(<=,le);\n      NEXT;\n    }\n\n    CASE(OP_GT, B) {\n      OP_CMP(>,gt);\n      NEXT;\n    }\n\n    CASE(OP_GE, B) {\n      OP_CMP(>=,ge);\n      NEXT;\n    }\n\n    CASE(OP_ARRAY, BB) {\n      regs[a] = mrb_ary_new_from_values(mrb, b, ®s[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_ARRAY2, BBB) {\n      regs[a] = mrb_ary_new_from_values(mrb, c, ®s[b]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYCAT, B) {\n      mrb_value splat = mrb_ary_splat(mrb, regs[a+1]);\n      if (mrb_nil_p(regs[a])) {\n        regs[a] = splat;\n      }\n      else {\n        mrb_assert(mrb_array_p(regs[a]));\n        mrb_ary_concat(mrb, regs[a], splat);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_ARYPUSH, BB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      for (mrb_int i=0; i<b; i++) {\n        mrb_ary_push(mrb, regs[a], regs[a+i+1]);\n      }\n      NEXT;\n    }\n\n    CASE(OP_ARYDUP, B) {\n      mrb_value ary = regs[a];\n      if (mrb_array_p(ary)) {\n        ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));\n      }\n      else {\n        ary = mrb_ary_new_from_values(mrb, 1, &ary);\n      }\n      regs[a] = ary;\n      NEXT;\n    }\n\n    CASE(OP_AREF, BBB) {\n      mrb_value v = regs[b];\n\n      if (!mrb_array_p(v)) {\n        if (c == 0) {\n          regs[a] = v;\n        }\n        else {\n          SET_NIL_VALUE(regs[a]);\n        }\n      }\n      else {\n        v = mrb_ary_ref(mrb, v, c);\n        regs[a] = v;\n      }\n      NEXT;\n    }\n\n    CASE(OP_ASET, BBB) {\n      mrb_assert(mrb_array_p(regs[a]));\n      mrb_ary_set(mrb, regs[b], c, regs[a]);\n      NEXT;\n    }\n\n    CASE(OP_APOST, BBB) {\n      mrb_value v = regs[a];\n      int pre  = b;\n      int post = c;\n      struct RArray *ary;\n      int len, idx;\n\n      if (!mrb_array_p(v)) {\n        v = mrb_ary_new_from_values(mrb, 1, ®s[a]);\n      }\n      ary = mrb_ary_ptr(v);\n      len = (int)ARY_LEN(ary);\n      if (len > pre + post) {\n        v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre);\n        regs[a++] = v;\n        while (post--) {\n          regs[a++] = ARY_PTR(ary)[len-post-1];\n        }\n      }\n      else {\n        v = mrb_ary_new_capa(mrb, 0);\n        regs[a++] = v;\n        for (idx=0; idx+pre<len; idx++) {\n          regs[a+idx] = ARY_PTR(ary)[pre+idx];\n        }\n        while (idx < post) {\n          SET_NIL_VALUE(regs[a+idx]);\n          idx++;\n        }\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_INTERN, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_sym sym = mrb_intern_str(mrb, regs[a]);\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_SYMBOL, BB) {\n      size_t len;\n      mrb_sym sym;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        sym = mrb_intern_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        sym  = mrb_intern(mrb, pool[b].u.str, len);\n      }\n      regs[a] = mrb_symbol_value(sym);\n      NEXT;\n    }\n\n    CASE(OP_STRING, BB) {\n      mrb_int len;\n\n      mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);\n      len = pool[b].tt >> 2;\n      if (pool[b].tt & IREP_TT_SFLAG) {\n        regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);\n      }\n      else {\n        regs[a] = mrb_str_new(mrb, pool[b].u.str, len);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_STRCAT, B) {\n      mrb_assert(mrb_string_p(regs[a]));\n      mrb_str_concat(mrb, regs[a], regs[a+1]);\n      NEXT;\n    }\n\n    CASE(OP_HASH, BB) {\n      mrb_value hash = mrb_hash_new_capa(mrb, b);\n      int i;\n      int lim = a+b*2;\n\n      for (i=a; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      regs[a] = hash;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_HASHADD, BB) {\n      mrb_value hash;\n      int i;\n      int lim = a+b*2+1;\n\n      hash = regs[a];\n      mrb_ensure_hash_type(mrb, hash);\n      for (i=a+1; i<lim; i+=2) {\n        mrb_hash_set(mrb, hash, regs[i], regs[i+1]);\n      }\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_HASHCAT, B) {\n      mrb_value hash = regs[a];\n\n      mrb_assert(mrb_hash_p(hash));\n      mrb_hash_merge(mrb, hash, regs[a+1]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_LAMBDA, BB)\n    c = OP_L_LAMBDA;\n    L_MAKE_LAMBDA:\n    {\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      if (c & OP_L_CAPTURE) {\n        p = mrb_closure_new(mrb, nirep);\n      }\n      else {\n        p = mrb_proc_new(mrb, nirep);\n        p->flags |= MRB_PROC_SCOPE;\n      }\n      if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;\n      regs[a] = mrb_obj_value(p);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n    CASE(OP_BLOCK, BB) {\n      c = OP_L_BLOCK;\n      goto L_MAKE_LAMBDA;\n    }\n    CASE(OP_METHOD, BB) {\n      c = OP_L_METHOD;\n      goto L_MAKE_LAMBDA;\n    }\n\n    CASE(OP_RANGE_INC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_RANGE_EXC, B) {\n      mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], TRUE);\n      regs[a] = v;\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_OCLASS, B) {\n      regs[a] = mrb_obj_value(mrb->object_class);\n      NEXT;\n    }\n\n    CASE(OP_CLASS, BB) {\n      struct RClass *c = 0, *baseclass;\n      mrb_value base, super;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      super = regs[a+1];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      c = mrb_vm_define_class(mrb, base, super, id);\n      regs[a] = mrb_obj_value(c);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_MODULE, BB) {\n      struct RClass *cls = 0, *baseclass;\n      mrb_value base;\n      mrb_sym id = syms[b];\n\n      base = regs[a];\n      if (mrb_nil_p(base)) {\n        baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);\n        if (!baseclass) baseclass = mrb->object_class;\n        base = mrb_obj_value(baseclass);\n      }\n      cls = mrb_vm_define_module(mrb, base, id);\n      regs[a] = mrb_obj_value(cls);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_EXEC, BB)\n    {\n      mrb_value recv = regs[a];\n      struct RProc *p;\n      const mrb_irep *nirep = irep->reps[b];\n\n      \/* prepare closure *\/\n      p = mrb_proc_new(mrb, nirep);\n      p->c = NULL;\n      mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc);\n      MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv));\n      p->flags |= MRB_PROC_SCOPE;\n\n      \/* prepare call stack *\/\n      cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0);\n\n      irep = p->body.irep;\n      pool = irep->pool;\n      syms = irep->syms;\n      mrb_stack_extend(mrb, irep->nregs);\n      stack_clear(regs+1, irep->nregs-1);\n      pc = irep->iseq;\n      JUMP;\n    }\n\n    CASE(OP_DEF, BB) {\n      struct RClass *target = mrb_class_ptr(regs[a]);\n      struct RProc *p = mrb_proc_ptr(regs[a+1]);\n      mrb_method_t m;\n      mrb_sym mid = syms[b];\n\n      MRB_METHOD_FROM_PROC(m, p);\n      mrb_define_method_raw(mrb, target, mid, m);\n      mrb_method_added(mrb, target, mid);\n      mrb_gc_arena_restore(mrb, ai);\n      regs[a] = mrb_symbol_value(mid);\n      NEXT;\n    }\n\n    CASE(OP_SCLASS, B) {\n      regs[a] = mrb_singleton_class(mrb, regs[a]);\n      mrb_gc_arena_restore(mrb, ai);\n      NEXT;\n    }\n\n    CASE(OP_TCLASS, B) {\n      struct RClass *target = check_target_class(mrb);\n      if (!target) goto L_RAISE;\n      regs[a] = mrb_obj_value(target);\n      NEXT;\n    }\n\n    CASE(OP_ALIAS, BB) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_alias_method(mrb, target, syms[a], syms[b]);\n      mrb_method_added(mrb, target, syms[a]);\n      NEXT;\n    }\n    CASE(OP_UNDEF, B) {\n      struct RClass *target = check_target_class(mrb);\n\n      if (!target) goto L_RAISE;\n      mrb_undef_method_id(mrb, target, syms[a]);\n      NEXT;\n    }\n\n    CASE(OP_DEBUG, Z) {\n      FETCH_BBB();\n#ifdef MRB_USE_DEBUG_HOOK\n      mrb->debug_op_hook(mrb, irep, pc, regs);\n#else\n#ifndef MRB_NO_STDIO\n      printf(\"OP_DEBUG %d %d %d\\n\", a, b, c);\n#else\n      abort();\n#endif\n#endif\n      NEXT;\n    }\n\n    CASE(OP_ERR, B) {\n      size_t len = pool[a].tt >> 2;\n      mrb_value exc;\n\n      mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);\n      exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);\n      mrb_exc_set(mrb, exc);\n      goto L_RAISE;\n    }\n\n    CASE(OP_EXT1, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT2, Z) {\n      insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n    CASE(OP_EXT3, Z) {\n      uint8_t insn = READ_B();\n      switch (insn) {\n#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;\n#include \"mruby\/ops.h\"\n#undef OPCODE\n      }\n      pc--;\n      NEXT;\n    }\n\n    CASE(OP_STOP, Z) {\n      \/*        stop VM *\/\n      CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {\n        \/* do nothing *\/\n      }\n      CHECKPOINT_MAIN(RBREAK_TAG_STOP) {\n        UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());\n      }\n      CHECKPOINT_END(RBREAK_TAG_STOP);\n    L_STOP:\n      mrb->jmp = prev_jmp;\n      if (mrb->exc) {\n        mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);\n        return mrb_obj_value(mrb->exc);\n      }\n      return regs[irep->nlocals];\n    }\n  }\n  END_DISPATCH;\n#undef regs\n  }\n  MRB_CATCH(&c_jmp) {\n    mrb_callinfo *ci = mrb->c->ci;\n    while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) {\n      ci = cipop(mrb);\n    }\n    exc_catched = TRUE;\n    pc = ci->pc;\n    goto RETRY_TRY_BLOCK;\n  }\n  MRB_END_EXC(&c_jmp);\n}","target":0,"code_token_length":14655,"total_token_length":14891,"max_tokens_setting":28000}
+{"idx":359846,"func":"WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand,\n     const char *option,const char *arg1n, const char *arg2n)\n{\n  ssize_t\n    parse;     \/* option argument parsing (string to value table lookup) *\/\n\n  const char    \/* percent escaped versions of the args *\/\n    *arg1,\n    *arg2;\n\n#define _image_info       (cli_wand->wand.image_info)\n#define _image            (cli_wand->wand.images)\n#define _exception        (cli_wand->wand.exception)\n#define _draw_info        (cli_wand->draw_info)\n#define _quantize_info    (cli_wand->quantize_info)\n#define IfSetOption       (*option=='-')\n#define ArgBoolean        IfSetOption ? MagickTrue : MagickFalse\n#define ArgBooleanNot     IfSetOption ? MagickFalse : MagickTrue\n#define ArgBooleanString  (IfSetOption?\"true\":\"false\")\n#define ArgOption(def)    (IfSetOption?arg1:(const char *)(def))\n\n  assert(cli_wand != (MagickCLI *) NULL);\n  assert(cli_wand->signature == MagickWandSignature);\n  assert(cli_wand->wand.signature == MagickWandSignature);\n\n  if (cli_wand->wand.debug != MagickFalse)\n    (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),\n         \"- Setting Option: %s \\\"%s\\\" \\\"%s\\\"\", option,arg1n,arg2n);\n\n  arg1 = arg1n,\n  arg2 = arg2n;\n\n#if 1\n#define _process_flags    (cli_wand->process_flags)\n#define _option_type      ((CommandOptionFlags) cli_wand->command->flags)\n  \/* Interpret Percent Escapes in Arguments - using first image *\/\n  if ( (((_process_flags & ProcessInterpretProperities) != 0 )\n        || ((_option_type & AlwaysInterpretArgsFlag) != 0)\n       )  && ((_option_type & NeverInterpretArgsFlag) == 0) ) {\n    \/* Interpret Percent escapes in argument 1 *\/\n    if (arg1n != (char *) NULL) {\n      arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception);\n      if (arg1 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg1=arg1n;  \/* use the given argument as is *\/\n      }\n    }\n    if (arg2n != (char *) NULL) {\n      arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception);\n      if (arg2 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg2=arg2n;  \/* use the given argument as is *\/\n      }\n    }\n  }\n#undef _process_flags\n#undef _option_type\n#endif\n\n  switch (*(option+1))\n  {\n    case 'a':\n    {\n      if (LocaleCompare(\"adjoin\",option+1) == 0)\n        {\n          _image_info->adjoin = ArgBoolean;\n          break;\n        }\n      if (LocaleCompare(\"affine\",option+1) == 0)\n        {\n          CLIWandWarnReplaced(\"-draw 'affine ...'\");\n          if (IfSetOption)\n            (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception);\n          else\n            GetAffineMatrix(&_draw_info->affine);\n          break;\n        }\n      if (LocaleCompare(\"antialias\",option+1) == 0)\n        {\n          _image_info->antialias =\n            _draw_info->stroke_antialias =\n              _draw_info->text_antialias = ArgBoolean;\n          break;\n        }\n      if (LocaleCompare(\"attenuate\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(\"1.0\"));\n          break;\n        }\n      if (LocaleCompare(\"authenticate\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'b':\n    {\n      if (LocaleCompare(\"background\",option+1) == 0)\n        {\n          \/* FUTURE: both _image_info attribute & ImageOption in use!\n             _image_info only used directly for generating new images.\n             SyncImageSettings() used to set per-image attribute.\n\n             FUTURE: if _image_info->background_color is not set then\n             we should fall back to per-image background_color\n\n             At this time -background will 'wipe out' the per-image\n             background color!\n\n             Better error handling of QueryColorCompliance() needed.\n          *\/\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          (void) QueryColorCompliance(ArgOption(MogrifyBackgroundColor),AllCompliance,\n             &_image_info->background_color,_exception);\n          break;\n        }\n      if (LocaleCompare(\"bias\",option+1) == 0)\n        {\n          \/* FUTURE: bias OBSOLETED, replaced by Artifact \"convolve:bias\"\n             as it is actually rarely used except in direct convolve operations\n             Usage outside a direct convolve operation is actally non-sensible!\n\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,\"convolve:bias\",ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"black-point-compensation\",option+1) == 0)\n        {\n          \/* Used as a image chromaticity setting\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          (void) SetImageOption(_image_info,option+1,ArgBooleanString);\n          break;\n        }\n      if (LocaleCompare(\"blue-primary\",option+1) == 0)\n        {\n          \/* Image chromaticity X,Y  NB: Y=X if Y not defined\n             Used by many coders including PNG\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          arg1=ArgOption(\"0.0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"bordercolor\",option+1) == 0)\n        {\n          \/* FUTURE: both _image_info attribute & ImageOption in use!\n             SyncImageSettings() used to set per-image attribute.\n             Better error checking of QueryColorCompliance().\n          *\/\n          if (IfSetOption)\n            {\n              (void) SetImageOption(_image_info,option+1,arg1);\n              (void) QueryColorCompliance(arg1,AllCompliance,\n                  &_image_info->border_color,_exception);\n              (void) QueryColorCompliance(arg1,AllCompliance,\n                  &_draw_info->border_color,_exception);\n              break;\n            }\n          (void) DeleteImageOption(_image_info,option+1);\n          (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,\n            &_image_info->border_color,_exception);\n          (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,\n            &_draw_info->border_color,_exception);\n          break;\n        }\n      if (LocaleCompare(\"box\",option+1) == 0)\n        {\n          CLIWandWarnReplaced(\"-undercolor\");\n          CLISettingOptionInfo(cli_wand,\"-undercolor\",arg1, arg2);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'c':\n    {\n      if (LocaleCompare(\"cache\",option+1) == 0)\n        {\n          MagickSizeType\n            limit;\n\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          limit=MagickResourceInfinity;\n          if (LocaleCompare(\"unlimited\",arg1) != 0)\n            limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0);\n          (void) SetMagickResourceLimit(MemoryResource,limit);\n          (void) SetMagickResourceLimit(MapResource,2*limit);\n          break;\n        }\n      if (LocaleCompare(\"caption\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"colorspace\",option+1) == 0)\n        {\n          \/* Setting used for new images via AquireImage()\n             But also used as a SimpleImageOperator\n             Undefined colorspace means don't modify images on\n             read or as a operation *\/\n          parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,\n             ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedColorspace\",option,\n              arg1);\n          _image_info->colorspace=(ColorspaceType) parse;\n          break;\n        }\n      if (LocaleCompare(\"comment\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"compose\",option+1) == 0)\n        {\n          \/* FUTURE: _image_info should be used,\n             SyncImageSettings() used to set per-image attribute. - REMOVE\n\n             This setting should NOT be used to set image 'compose'\n             \"-layer\" operators shoud use _image_info if defined otherwise\n             they should use a per-image compose setting.\n          *\/\n          parse = ParseCommandOption(MagickComposeOptions,MagickFalse,\n                          ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedComposeOperator\",\n                                      option,arg1);\n          _image_info->compose=(CompositeOperator) parse;\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"compress\",option+1) == 0)\n        {\n          \/* FUTURE: What should be used?  _image_info  or ImageOption ???\n             The former is more efficent, but Crisy prefers the latter!\n             SyncImageSettings() used to set per-image attribute.\n\n             The coders appears to use _image_info, not Image_Option\n             however the image attribute (for save) is set from the\n             ImageOption!\n\n             Note that \"undefined\" is a different setting to \"none\".\n          *\/\n          parse = ParseCommandOption(MagickCompressOptions,MagickFalse,\n                     ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedImageCompression\",\n                                      option,arg1);\n          _image_info->compression=(CompressionType) parse;\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'd':\n    {\n      if (LocaleCompare(\"debug\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          arg1=ArgOption(\"none\");\n          parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedEventType\",\n                                      option,arg1);\n          (void) SetLogEventMask(arg1);\n          _image_info->debug=IsEventLogging();   \/* extract logging*\/\n          cli_wand->wand.debug=IsEventLogging();\n          break;\n        }\n      if (LocaleCompare(\"define\",option+1) == 0)\n        {\n          if (LocaleNCompare(arg1,\"registry:\",9) == 0)\n            {\n              if (IfSetOption)\n                (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception);\n              else\n                (void) DeleteImageRegistry(arg1+9);\n              break;\n            }\n          \/* DefineImageOption() equals SetImageOption() but with '=' *\/\n          if (IfSetOption)\n            (void) DefineImageOption(_image_info,arg1);\n          else if (DeleteImageOption(_image_info,arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"NoSuchOption\",option,arg1);\n          break;\n        }\n      if (LocaleCompare(\"delay\",option+1) == 0)\n        {\n          \/* Only used for new images via AcquireImage()\n             FUTURE: Option should also be used for \"-morph\" (color morphing)\n          *\/\n          arg1=ArgOption(\"0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"density\",option+1) == 0)\n        {\n          \/* FUTURE: strings used in _image_info attr and _draw_info!\n             Basically as density can be in a XxY form!\n\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          (void) CloneString(&_image_info->density,ArgOption(NULL));\n          (void) CloneString(&_draw_info->density,_image_info->density);\n          break;\n        }\n      if (LocaleCompare(\"depth\",option+1) == 0)\n        {\n          \/* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!!\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          _image_info->depth=IfSetOption?StringToUnsignedLong(arg1)\n                                       :MAGICKCORE_QUANTUM_DEPTH;\n          break;\n        }\n      if (LocaleCompare(\"direction\",option+1) == 0)\n        {\n          \/* Image Option is only used to set _draw_info *\/\n          arg1=ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedDirectionType\",\n                                      option,arg1);\n          _draw_info->direction=(DirectionType) parse;\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"display\",option+1) == 0)\n        {\n          (void) CloneString(&_image_info->server_name,ArgOption(NULL));\n          (void) CloneString(&_draw_info->server_name,_image_info->server_name);\n          break;\n        }\n      if (LocaleCompare(\"dispose\",option+1) == 0)\n        {\n          \/* only used in setting new images *\/\n          arg1=ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedDisposeMethod\",\n                                      option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(\"undefined\"));\n          break;\n        }\n      if (LocaleCompare(\"dissimilarity-threshold\",option+1) == 0)\n        {\n          \/* FUTURE: this is only used by CompareImages() which is used\n             only by the \"compare\" CLI program at this time.  *\/\n          arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD);\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"dither\",option+1) == 0)\n        {\n          \/* _image_info attr (on\/off), _quantize_info attr (on\/off)\n             but also ImageInfo and _quantize_info method!\n             FUTURE: merge the duality of the dithering options\n          *\/\n          _image_info->dither = ArgBoolean;\n          (void) SetImageOption(_image_info,option+1,ArgOption(\"none\"));\n          _quantize_info->dither_method=(DitherMethod) ParseCommandOption(\n             MagickDitherOptions,MagickFalse,ArgOption(\"none\"));\n          if (_quantize_info->dither_method == NoDitherMethod)\n            _image_info->dither = MagickFalse;\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'e':\n    {\n      if (LocaleCompare(\"encoding\",option+1) == 0)\n        {\n          (void) CloneString(&_draw_info->encoding,ArgOption(\"undefined\"));\n          (void) SetImageOption(_image_info,option+1,_draw_info->encoding);\n          break;\n        }\n      if (LocaleCompare(\"endian\",option+1) == 0)\n        {\n          \/* Both _image_info attr and ImageInfo *\/\n          arg1 = ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedEndianType\",\n                                      option,arg1);\n          \/* FUTURE: check alloc\/free of endian string!  - remove? *\/\n          _image_info->endian=(EndianType) (*arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"extract\",option+1) == 0)\n        {\n          (void) CloneString(&_image_info->extract,ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'f':\n    {\n      if (LocaleCompare(\"family\",option+1) == 0)\n        {\n          (void) CloneString(&_draw_info->family,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"features\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,\"identify:features\",\n            ArgBooleanString);\n          if (IfSetOption)\n            (void) SetImageArtifact(_image,\"verbose\",\"true\");\n          break;\n        }\n      if (LocaleCompare(\"fill\",option+1) == 0)\n        {\n          \/* Set \"fill\" OR \"fill-pattern\" in _draw_info\n             The original fill color is preserved if a fill-pattern is given.\n             That way it does not effect other operations that directly using\n             the fill color and, can be retored using \"+tile\".\n          *\/\n          MagickBooleanType\n            status;\n\n          ExceptionInfo\n            *sans;\n\n          PixelInfo\n            color;\n\n          arg1 = ArgOption(\"none\");  \/* +fill turns it off! *\/\n          (void) SetImageOption(_image_info,option+1,arg1);\n          if (_draw_info->fill_pattern != (Image *) NULL)\n            _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern);\n\n          \/* is it a color or a image? -- ignore exceptions *\/\n          sans=AcquireExceptionInfo();\n          status=QueryColorCompliance(arg1,AllCompliance,&color,sans);\n          sans=DestroyExceptionInfo(sans);\n\n          if (status == MagickFalse)\n            _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception);\n          else\n            _draw_info->fill=color;\n          break;\n        }\n      if (LocaleCompare(\"filter\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          arg1 = ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedImageFilter\",\n                                      option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"font\",option+1) == 0)\n        {\n          (void) CloneString(&_draw_info->font,ArgOption(NULL));\n          (void) CloneString(&_image_info->font,_draw_info->font);\n          break;\n        }\n      if (LocaleCompare(\"format\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"fuzz\",option+1) == 0)\n        {\n          \/* Option used to set image fuzz! unless blank canvas (from color)\n             Image attribute used for color compare operations\n             SyncImageSettings() used to set per-image attribute.\n\n             FUTURE: Can't find anything else using _image_info->fuzz directly!\n                     convert structure attribute to 'option' string\n          *\/\n          arg1=ArgOption(\"0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          _image_info->fuzz=StringToDoubleInterval(arg1,(double)\n                QuantumRange+1.0);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'g':\n    {\n      if (LocaleCompare(\"gravity\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          arg1 = ArgOption(\"none\");\n          parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedGravityType\",\n                                      option,arg1);\n          _draw_info->gravity=(GravityType) parse;\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"green-primary\",option+1) == 0)\n        {\n          \/* Image chromaticity X,Y  NB: Y=X if Y not defined\n             SyncImageSettings() used to set per-image attribute.\n             Used directly by many coders\n          *\/\n          arg1=ArgOption(\"0.0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'h':\n    {\n      if (LocaleCompare(\"highlight-color\",option+1) == 0)\n        {\n          \/* FUTURE: this is only used by CompareImages() which is used\n             only by the \"compare\" CLI program at this time.  *\/\n          (void) SetImageOption(_image_info,\"compare:highlight-color\",\n            ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'i':\n    {\n      if (LocaleCompare(\"illuminant\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,\"color:illuminant\",\n            ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"intensity\",option+1) == 0)\n        {\n          arg1 = ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,\n            arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedIntensityType\",\n              option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"intent\",option+1) == 0)\n        {\n          \/* Only used by coders: MIFF, MPC, BMP, PNG\n             and for image profile call to AcquireTransformTLS()\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          arg1 = ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedIntentType\",\n                                      option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"interlace\",option+1) == 0)\n        {\n          \/* _image_info is directly used by coders (so why an image setting?)\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          arg1 = ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedInterlaceType\",\n                                      option,arg1);\n          _image_info->interlace=(InterlaceType) parse;\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"interline-spacing\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1, ArgOption(NULL));\n          _draw_info->interline_spacing=StringToDouble(ArgOption(\"0\"),\n               (char **) NULL);\n          break;\n        }\n      if (LocaleCompare(\"interpolate\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          arg1 = ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedInterpolateMethod\",\n                                      option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"interword-spacing\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1, ArgOption(NULL));\n          _draw_info->interword_spacing=StringToDouble(ArgOption(\"0\"),(char **) NULL);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'k':\n    {\n      if (LocaleCompare(\"kerning\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          _draw_info->kerning=StringToDouble(ArgOption(\"0\"),(char **) NULL);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'l':\n    {\n      if (LocaleCompare(\"label\",option+1) == 0)\n        {\n          \/* only used for new images - not in SyncImageOptions() *\/\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"limit\",option+1) == 0)\n        {\n          MagickSizeType\n            limit;\n\n          limit=MagickResourceInfinity;\n          parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1);\n          if ( parse < 0 )\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedResourceType\",\n                option,arg1);\n          if (LocaleCompare(\"unlimited\",arg2) != 0)\n            limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0);\n          (void) SetMagickResourceLimit((ResourceType)parse,limit);\n          break;\n        }\n      if (LocaleCompare(\"log\",option+1) == 0)\n        {\n          if (IfSetOption) {\n            if ((strchr(arg1,'%') == (char *) NULL))\n              CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n            (void) SetLogFormat(arg1);\n          }\n          break;\n        }\n      if (LocaleCompare(\"lowlight-color\",option+1) == 0)\n        {\n          \/* FUTURE: this is only used by CompareImages() which is used\n             only by the \"compare\" CLI program at this time.  *\/\n          (void) SetImageOption(_image_info,\"compare:lowlight-color\",\n            ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"loop\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          arg1=ArgOption(\"0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'm':\n    {\n      if (LocaleCompare(\"mattecolor\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          (void) QueryColorCompliance(ArgOption(MogrifyAlphaColor),\n            AllCompliance,&_image_info->matte_color,_exception);\n          break;\n        }\n      if (LocaleCompare(\"metric\",option+1) == 0)\n        {\n          \/* FUTURE: this is only used by CompareImages() which is used\n             only by the \"compare\" CLI program at this time.  *\/\n          parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1);\n          if ( parse < 0 )\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedMetricType\",\n                option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"moments\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,\"identify:moments\",\n            ArgBooleanString);\n          if (IfSetOption)\n            (void) SetImageArtifact(_image,\"verbose\",\"true\");\n          break;\n        }\n      if (LocaleCompare(\"monitor\",option+1) == 0)\n        {\n          (void) SetImageInfoProgressMonitor(_image_info, IfSetOption?\n                MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL);\n          break;\n        }\n      if (LocaleCompare(\"monochrome\",option+1) == 0)\n        {\n          \/* Setting (used by some input coders!) -- why?\n             Warning: This is also Special '-type' SimpleOperator\n          *\/\n          _image_info->monochrome= ArgBoolean;\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'o':\n    {\n      if (LocaleCompare(\"orient\",option+1) == 0)\n        {\n          \/* Is not used when defining for new images.\n             This makes it more of a 'operation' than a setting\n             FUTURE: make set meta-data operator instead.\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          parse=ParseCommandOption(MagickOrientationOptions,MagickFalse,\n               ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedImageOrientation\",\n                                      option,arg1);\n          _image_info->orientation=(OrientationType)parse;\n          (void) SetImageOption(_image_info,option+1, ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'p':\n    {\n      if (LocaleCompare(\"page\",option+1) == 0)\n        {\n          \/* Only used for new images and image generators.\n             SyncImageSettings() used to set per-image attribute. ?????\n             That last is WRONG!!!!\n             FUTURE: adjust named 'page' sizes according density\n          *\/\n          char\n            *canonical_page,\n            page[MagickPathExtent];\n\n          const char\n            *image_option;\n\n          MagickStatusType\n            flags;\n\n          RectangleInfo\n            geometry;\n\n          if (!IfSetOption)\n            {\n              (void) DeleteImageOption(_image_info,option+1);\n              (void) CloneString(&_image_info->page,(char *) NULL);\n              break;\n            }\n          (void) memset(&geometry,0,sizeof(geometry));\n          image_option=GetImageOption(_image_info,\"page\");\n          if (image_option != (const char *) NULL)\n            flags=ParseAbsoluteGeometry(image_option,&geometry);\n          canonical_page=GetPageGeometry(arg1);\n          flags=ParseAbsoluteGeometry(canonical_page,&geometry);\n          canonical_page=DestroyString(canonical_page);\n          (void) FormatLocaleString(page,MagickPathExtent,\"%lux%lu\",\n            (unsigned long) geometry.width,(unsigned long) geometry.height);\n          if (((flags & XValue) != 0) || ((flags & YValue) != 0))\n            (void) FormatLocaleString(page,MagickPathExtent,\"%lux%lu%+ld%+ld\",\n              (unsigned long) geometry.width,(unsigned long) geometry.height,\n              (long) geometry.x,(long) geometry.y);\n          (void) SetImageOption(_image_info,option+1,page);\n          (void) CloneString(&_image_info->page,page);\n          break;\n        }\n      if (LocaleCompare(\"ping\",option+1) == 0)\n        {\n          _image_info->ping=ArgBoolean;\n          break;\n        }\n      if (LocaleCompare(\"pointsize\",option+1) == 0)\n        {\n          if (IfSetOption) {\n            if (IsGeometry(arg1) == MagickFalse)\n              CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n            _image_info->pointsize =\n            _draw_info->pointsize =\n              StringToDouble(arg1,(char **) NULL);\n          }\n          else {\n            _image_info->pointsize=0.0; \/* unset pointsize *\/\n            _draw_info->pointsize=12.0;\n          }\n          break;\n        }\n      if (LocaleCompare(\"precision\",option+1) == 0)\n        {\n          arg1=ArgOption(\"-1\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetMagickPrecision(StringToInteger(arg1));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'q':\n    {\n      if (LocaleCompare(\"quality\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1)\n                                            : UNDEFINED_COMPRESSION_QUALITY;\n          (void) SetImageOption(_image_info,option+1,ArgOption(\"0\"));\n          break;\n        }\n      if (LocaleCompare(\"quantize\",option+1) == 0)\n        {\n          \/* Just a set direct in _quantize_info *\/\n          arg1=ArgOption(\"undefined\");\n          parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedColorspace\",\n                 option,arg1);\n          _quantize_info->colorspace=(ColorspaceType)parse;\n          break;\n        }\n      if (LocaleCompare(\"quiet\",option+1) == 0)\n        {\n          \/* FUTURE: if two -quiet is performed you can not do +quiet!\n             This needs to be checked over thoughly.\n          *\/\n          static WarningHandler\n            warning_handler = (WarningHandler) NULL;\n\n          WarningHandler\n            tmp = SetWarningHandler((WarningHandler) NULL);\n\n          if ( tmp != (WarningHandler) NULL)\n            warning_handler = tmp; \/* remember the old handler *\/\n          if (!IfSetOption)        \/* set the old handler *\/\n            warning_handler=SetWarningHandler(warning_handler);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'r':\n    {\n      if (LocaleCompare(\"red-primary\",option+1) == 0)\n        {\n          \/* Image chromaticity X,Y  NB: Y=X if Y not defined\n             Used by many coders\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          arg1=ArgOption(\"0.0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"regard-warnings\",option+1) == 0)\n        \/* FUTURE: to be replaced by a 'fatal-level' type setting *\/\n        break;\n      if (LocaleCompare(\"render\",option+1) == 0)\n        {\n          \/* _draw_info only setting *\/\n          _draw_info->render= ArgBooleanNot;\n          break;\n        }\n      if (LocaleCompare(\"respect-parenthesis\",option+1) == 0)\n        {\n          \/* link image and setting stacks - option is itself saved on stack! *\/\n          (void) SetImageOption(_image_info,option+1,ArgBooleanString);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 's':\n    {\n      if (LocaleCompare(\"sampling-factor\",option+1) == 0)\n        {\n          \/* FUTURE: should be converted to jpeg:sampling_factor *\/\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"scene\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set this as a per-image attribute.\n             What ??? Why ????\n          *\/\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          _image_info->scene=StringToUnsignedLong(ArgOption(\"0\"));\n          break;\n        }\n      if (LocaleCompare(\"seed\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          SetRandomSecretKey(\n               IfSetOption ? (unsigned long) StringToUnsignedLong(arg1)\n                           : (unsigned long) time((time_t *) NULL));\n          break;\n        }\n      if (LocaleCompare(\"size\",option+1) == 0)\n        {\n          \/* FUTURE: string in _image_info -- convert to Option ???\n             Look at the special handling for \"size\" in SetImageOption()\n           *\/\n          (void) CloneString(&_image_info->size,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"stretch\",option+1) == 0)\n        {\n          arg1=ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedStretchType\",\n                 option,arg1);\n          _draw_info->stretch=(StretchType) parse;\n          break;\n        }\n      if (LocaleCompare(\"stroke\",option+1) == 0)\n        {\n          \/* set stroke color OR stroke-pattern\n             UPDATE: ensure stroke color is not destroyed is a pattern\n             is given. Just in case the color is also used for other purposes.\n           *\/\n          MagickBooleanType\n            status;\n\n          ExceptionInfo\n            *sans;\n\n          PixelInfo\n            color;\n\n          arg1 = ArgOption(\"none\");  \/* +fill turns it off! *\/\n          (void) SetImageOption(_image_info,option+1,arg1);\n          if (_draw_info->stroke_pattern != (Image *) NULL)\n            _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern);\n\n          \/* is it a color or a image? -- ignore exceptions *\/\n          sans=AcquireExceptionInfo();\n          status=QueryColorCompliance(arg1,AllCompliance,&color,sans);\n          sans=DestroyExceptionInfo(sans);\n\n          if (status == MagickFalse)\n            _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception);\n          else\n            _draw_info->stroke=color;\n          break;\n        }\n      if (LocaleCompare(\"strokewidth\",option+1) == 0)\n        {\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          _draw_info->stroke_width=StringToDouble(ArgOption(\"1.0\"),\n               (char **) NULL);\n          break;\n        }\n      if (LocaleCompare(\"style\",option+1) == 0)\n        {\n          arg1=ArgOption(\"undefined\");\n          parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1);\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedStyleType\",\n                 option,arg1);\n          _draw_info->style=(StyleType) parse;\n          break;\n        }\n#if 0\n      if (LocaleCompare(\"subimage-search\",option+1) == 0)\n        {\n        \/* FUTURE: this is only used by CompareImages() which is used\n            only by the \"compare\" CLI program at this time.  *\/\n          (void) SetImageOption(_image_info,option+1,ArgBooleanString);\n          break;\n        }\n#endif\n      if (LocaleCompare(\"synchronize\",option+1) == 0)\n        {\n          \/* FUTURE: syncronize to storage - but what does that mean? *\/\n          _image_info->synchronize = ArgBoolean;\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 't':\n    {\n      if (LocaleCompare(\"taint\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          (void) SetImageOption(_image_info,option+1,ArgBooleanString);\n          break;\n        }\n      if (LocaleCompare(\"texture\",option+1) == 0)\n        {\n          \/* Note: arguments do not have percent escapes expanded *\/\n          \/* FUTURE: move _image_info string to option splay-tree\n             Other than \"montage\" what uses \"texture\" ????\n          *\/\n          (void) CloneString(&_image_info->texture,ArgOption(NULL));\n          break;\n        }\n      if (LocaleCompare(\"tile\",option+1) == 0)\n        {\n          \/* Note: arguments do not have percent escapes expanded *\/\n          _draw_info->fill_pattern=IfSetOption\n                                 ?GetImageCache(_image_info,arg1,_exception)\n                                 :DestroyImage(_draw_info->fill_pattern);\n          break;\n        }\n      if (LocaleCompare(\"tile-offset\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. ??? *\/\n          arg1=ArgOption(\"0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      if (LocaleCompare(\"transparent-color\",option+1) == 0)\n        {\n          \/* FUTURE: both _image_info attribute & ImageOption in use!\n             _image_info only used for generating new images.\n             SyncImageSettings() used to set per-image attribute.\n\n             Note that +transparent-color, means fall-back to image\n             attribute so ImageOption is deleted, not set to a default.\n          *\/\n          if (IfSetOption && (IsGeometry(arg1) == MagickFalse))\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          (void) QueryColorCompliance(ArgOption(\"none\"),AllCompliance,\n              &_image_info->transparent_color,_exception);\n          break;\n        }\n      if (LocaleCompare(\"treedepth\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          _quantize_info->tree_depth=StringToUnsignedLong(ArgOption(\"0\"));\n          break;\n        }\n      if (LocaleCompare(\"type\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute. *\/\n          parse=ParseCommandOption(MagickTypeOptions,MagickFalse,\n               ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedImageType\",\n                 option,arg1);\n          _image_info->type=(ImageType) parse;\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'u':\n    {\n      if (LocaleCompare(\"undercolor\",option+1) == 0)\n        {\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          (void) QueryColorCompliance(ArgOption(\"none\"),AllCompliance,\n               &_draw_info->undercolor,_exception);\n          break;\n        }\n      if (LocaleCompare(\"units\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute.\n             Should this effect _draw_info X and Y resolution?\n             FUTURE: this probably should be part of the density setting\n          *\/\n          parse=ParseCommandOption(MagickResolutionOptions,MagickFalse,\n               ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedUnitsType\",\n                 option,arg1);\n          _image_info->units=(ResolutionType) parse;\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'v':\n    {\n      if (LocaleCompare(\"verbose\",option+1) == 0)\n        {\n          \/* FUTURE: Remember all options become image artifacts\n             _image_info->verbose is only used by coders.\n          *\/\n          (void) SetImageOption(_image_info,option+1,ArgBooleanString);\n          _image_info->verbose= ArgBoolean;\n          _image_info->ping=MagickFalse; \/* verbose can't be a ping *\/\n          break;\n        }\n      if (LocaleCompare(\"virtual-pixel\",option+1) == 0)\n        {\n          \/* SyncImageSettings() used to set per-image attribute.\n             This is VERY deep in the image caching structure.\n          *\/\n          parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,\n               ArgOption(\"undefined\"));\n          if (parse < 0)\n            CLIWandExceptArgBreak(OptionError,\"UnrecognizedVirtualPixelMethod\",\n                 option,arg1);\n          (void) SetImageOption(_image_info,option+1,ArgOption(NULL));\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    case 'w':\n    {\n      if (LocaleCompare(\"weight\",option+1) == 0)\n        {\n          ssize_t\n            weight;\n\n          weight=ParseCommandOption(MagickWeightOptions,MagickFalse,arg1);\n          if (weight == -1)\n            weight=(ssize_t) StringToUnsignedLong(arg1);\n          _draw_info->weight=(size_t) weight;\n          break;\n        }\n      if (LocaleCompare(\"white-point\",option+1) == 0)\n        {\n          \/* Used as a image chromaticity setting\n             SyncImageSettings() used to set per-image attribute.\n          *\/\n          arg1=ArgOption(\"0.0\");\n          if (IsGeometry(arg1) == MagickFalse)\n            CLIWandExceptArgBreak(OptionError,\"InvalidArgument\",option,arg1);\n          (void) SetImageOption(_image_info,option+1,arg1);\n          break;\n        }\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n    }\n    default:\n      CLIWandExceptionBreak(OptionError,\"UnrecognizedOption\",option);\n  }\n\n  \/* clean up percent escape interpreted strings *\/\n  if ((arg1 && arg1n) && (arg1 != arg1n ))\n    arg1=DestroyString((char *) arg1);\n  if ((arg2 && arg2n) && (arg2 != arg2n ))\n    arg2=DestroyString((char *) arg2);\n\n#undef _image_info\n#undef _exception\n#undef _draw_info\n#undef _quantize_info\n#undef IfSetOption\n#undef ArgBoolean\n#undef ArgBooleanNot\n#undef ArgBooleanString\n#undef ArgOption\n\n  return;\n}","target":0,"code_token_length":11012,"total_token_length":11248,"max_tokens_setting":28000}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..4da4b6ba4690ef6147b060f423338d3eff9de542
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3422c839fc79648d2123c71465ed474ec2bd15a9f34a235a62e0609c20ffa4ad
+size 864409
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..e84aaba90c2f8beb4ba5a6faed684fea3776187c
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.jsonl
@@ -0,0 +1,241 @@
+{"idx":409513,"func":"handle_version_response(int first, int *arg, int argc, char_u *tp)\n{\n    \/\/ The xterm version.  It is set to zero when it can't be an actual xterm\n    \/\/ version.\n    int version = arg[1];\n\n    LOG_TR((\"Received CRV response: %s\", tp));\n    crv_status.tr_progress = STATUS_GOT;\n    did_cursorhold = TRUE;\n\n    \/\/ Reset terminal properties that are set based on the termresponse.\n    \/\/ Mainly useful for tests that send the termresponse multiple times.\n    \/\/ For testing all props can be reset.\n    init_term_props(\n#ifdef FEAT_EVAL\n\t    reset_term_props_on_termresponse\n#else\n\t    FALSE\n#endif\n\t    );\n\n    \/\/ If this code starts with CSI, you can bet that the\n    \/\/ terminal uses 8-bit codes.\n    if (tp[0] == CSI)\n\tswitch_to_8bit();\n\n    \/\/ Screen sends 40500.\n    \/\/ rxvt sends its version number: \"20703\" is 2.7.3.\n    \/\/ Ignore it for when the user has set 'term' to xterm,\n    \/\/ even though it's an rxvt.\n    if (version > 20000)\n\tversion = 0;\n\n    \/\/ Figure out more if the response is CSI > 99 ; 99 ; 99 c\n    if (first == '>' && argc == 3)\n    {\n\tint need_flush = FALSE;\n\n\t\/\/ mintty 2.9.5 sends 77;20905;0c.\n\t\/\/ (77 is ASCII 'M' for mintty.)\n\tif (arg[0] == 77)\n\t{\n\t    \/\/ mintty can do SGR mouse reporting\n\t    term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t}\n\n\t\/\/ If xterm version >= 141 try to get termcap codes.  For other\n\t\/\/ terminals the request should be ignored.\n\tif (version >= 141 && p_xtermcodes)\n\t{\n\t    LOG_TR((\"Enable checking for XT codes\"));\n\t    check_for_codes = TRUE;\n\t    need_gather = TRUE;\n\t    req_codes_from_term();\n\t}\n\n\t\/\/ libvterm sends 0;100;0\n\tif (version == 100 && arg[0] == 0 && arg[2] == 0)\n\t{\n\t    \/\/ If run from Vim $COLORS is set to the number of\n\t    \/\/ colors the terminal supports.  Otherwise assume\n\t    \/\/ 256, libvterm supports even more.\n\t    if (mch_getenv((char_u *)\"COLORS\") == NULL)\n\t\tmay_adjust_color_count(256);\n\t    \/\/ Libvterm can handle SGR mouse reporting.\n\t    term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t}\n\n\tif (version == 95)\n\t{\n\t    \/\/ Mac Terminal.app sends 1;95;0\n\t    if (arg[0] == 1 && arg[2] == 0)\n\t    {\n\t\tterm_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t    }\n\t    \/\/ iTerm2 sends 0;95;0\n\t    else if (arg[0] == 0 && arg[2] == 0)\n\t    {\n\t\t\/\/ iTerm2 can do SGR mouse reporting\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t    }\n\t    \/\/ old iTerm2 sends 0;95;\n\t    else if (arg[0] == 0 && arg[2] == -1)\n\t\tterm_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;\n\t}\n\n\t\/\/ screen sends 83;40500;0 83 is 'S' in ASCII.\n\tif (arg[0] == 83)\n\t{\n\t    \/\/ screen supports SGR mouse codes since 4.7.0\n\t    if (arg[1] >= 40700)\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t    else\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM;\n\t}\n\n\t\/\/ If no recognized terminal has set mouse behavior, assume xterm.\n\tif (term_props[TPR_MOUSE].tpr_status == TPR_UNKNOWN)\n\t{\n\t    \/\/ Xterm version 277 supports SGR.\n\t    \/\/ Xterm version >= 95 supports mouse dragging.\n\t    if (version >= 277)\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t    else if (version >= 95)\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM2;\n\t}\n\n\t\/\/ Detect terminals that set $TERM to something like\n\t\/\/ \"xterm-256color\" but are not fully xterm compatible.\n\t\/\/\n\t\/\/ Gnome terminal sends 1;3801;0, 1;4402;0 or 1;2501;0.\n\t\/\/ Newer Gnome-terminal sends 65;6001;1.\n\t\/\/ xfce4-terminal sends 1;2802;0.\n\t\/\/ screen sends 83;40500;0\n\t\/\/ Assuming any version number over 2500 is not an\n\t\/\/ xterm (without the limit for rxvt and screen).\n\tif (arg[1] >= 2500)\n\t    term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;\n\n\telse if (version == 136 && arg[2] == 0)\n\t{\n\t    term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;\n\n\t    \/\/ PuTTY sends 0;136;0\n\t    if (arg[0] == 0)\n\t    {\n\t\t\/\/ supports sgr-like mouse reporting.\n\t\tterm_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;\n\t    }\n\t    \/\/ vandyke SecureCRT sends 1;136;0\n\t}\n\n\t\/\/ Konsole sends 0;115;0 - but t_u8 does not actually work, therefore\n\t\/\/ commented out.\n\t\/\/ else if (version == 115 && arg[0] == 0 && arg[2] == 0)\n\t\/\/     term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;\n\n\t\/\/ GNU screen sends 83;30600;0, 83;40500;0, etc.\n\t\/\/ 30600\/40500 is a version number of GNU screen. DA2 support is added\n\t\/\/ on 3.6.  DCS string has a special meaning to GNU screen, but xterm\n\t\/\/ compatibility checking does not detect GNU screen.\n\tif (arg[0] == 83 && arg[1] >= 30600)\n\t{\n\t    term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO;\n\t    term_props[TPR_CURSOR_BLINK].tpr_status = TPR_NO;\n\t}\n\n\t\/\/ Xterm first responded to this request at patch level\n\t\/\/ 95, so assume anything below 95 is not xterm and hopefully supports\n\t\/\/ the underline RGB color sequence.\n\tif (version < 95)\n\t    term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES;\n\n\t\/\/ Getting the cursor style is only supported properly by xterm since\n\t\/\/ version 279 (otherwise it returns 0x18).\n\tif (version < 279)\n\t    term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO;\n\n\t\/*\n\t * Take action on the detected properties.\n\t *\/\n\n\t\/\/ Unless the underline RGB color is expected to work, disable \"t_8u\".\n\t\/\/ It does not work for the real Xterm, it resets the background color.\n\t\/\/ This may cause some flicker.  Alternative would be to set \"t_8u\"\n\t\/\/ here if the terminal is expected to support it, but that might\n\t\/\/ conflict with what was set in the .vimrc.\n\tif (term_props[TPR_UNDERLINE_RGB].tpr_status != TPR_YES\n\t\t\t&& *T_8U != NUL\n\t\t\t&& !option_was_set((char_u *)\"t_8u\"))\n\t{\n\t    set_string_option_direct((char_u *)\"t_8u\", -1, (char_u *)\"\",\n\t\t\t\t\t\t\t\t  OPT_FREE, 0);\n\t}\n\tif (*T_8U != NUL && write_t_8u_state == MAYBE)\n\t    \/\/ Did skip writing t_8u, a complete redraw is needed.\n\t    redraw_later_clear();\n\twrite_t_8u_state = OK;  \/\/ can output t_8u now\n\n\t\/\/ Only set 'ttymouse' automatically if it was not set\n\t\/\/ by the user already.\n\tif (!option_was_set((char_u *)\"ttym\")\n\t\t&& (term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_XTERM2\n\t\t    || term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR))\n\t{\n\t    set_option_value_give_err((char_u *)\"ttym\", 0L,\n\t\t    term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR\n\t\t\t\t    ? (char_u *)\"sgr\" : (char_u *)\"xterm2\", 0);\n\t}\n\n\t\/\/ Only request the cursor style if t_SH and t_RS are\n\t\/\/ set. Only supported properly by xterm since version\n\t\/\/ 279 (otherwise it returns 0x18).\n\t\/\/ Only when getting the cursor style was detected to work.\n\t\/\/ Not for Terminal.app, it can't handle t_RS, it\n\t\/\/ echoes the characters to the screen.\n\tif (rcs_status.tr_progress == STATUS_GET\n\t\t&& term_props[TPR_CURSOR_STYLE].tpr_status == TPR_YES\n\t\t&& *T_CSH != NUL\n\t\t&& *T_CRS != NUL)\n\t{\n\t    MAY_WANT_TO_LOG_THIS;\n\t    LOG_TR((\"Sending cursor style request\"));\n\t    out_str(T_CRS);\n\t    termrequest_sent(&rcs_status);\n\t    need_flush = TRUE;\n\t}\n\n\t\/\/ Only request the cursor blink mode if t_RC set. Not\n\t\/\/ for Gnome terminal, it can't handle t_RC, it\n\t\/\/ echoes the characters to the screen.\n\t\/\/ Only when getting the cursor style was detected to work.\n\tif (rbm_status.tr_progress == STATUS_GET\n\t\t&& term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES\n\t\t&& *T_CRC != NUL)\n\t{\n\t    MAY_WANT_TO_LOG_THIS;\n\t    LOG_TR((\"Sending cursor blink mode request\"));\n\t    out_str(T_CRC);\n\t    termrequest_sent(&rbm_status);\n\t    need_flush = TRUE;\n\t}\n\n\tif (need_flush)\n\t    out_flush();\n    }\n}","target":0,"code_token_length":2421,"total_token_length":2657,"max_tokens_setting":4096}
+{"idx":195230,"func":"void pjmedia_rtcp_xr_rx_rtcp_xr( pjmedia_rtcp_xr_session *sess,\n\t\t\t\t const void *pkt,\n\t\t\t\t pj_size_t size)\n{\n    const pjmedia_rtcp_xr_pkt\t      *rtcp_xr = (pjmedia_rtcp_xr_pkt*) pkt;\n    const pjmedia_rtcp_xr_rb_rr_time  *rb_rr_time = NULL;\n    const pjmedia_rtcp_xr_rb_dlrr     *rb_dlrr = NULL;\n    const pjmedia_rtcp_xr_rb_stats    *rb_stats = NULL;\n    const pjmedia_rtcp_xr_rb_voip_mtc *rb_voip_mtc = NULL;\n    const pjmedia_rtcp_xr_rb_header   *rb_hdr = (pjmedia_rtcp_xr_rb_header*) \n\t\t\t\t\t\trtcp_xr->buf;\n    unsigned pkt_len, rb_len;\n\n    if (rtcp_xr->common.pt != RTCP_XR)\n\treturn;\n\n    pkt_len = pj_ntohs((pj_uint16_t)rtcp_xr->common.length);\n\n    if ((pkt_len + 1) > (size \/ 4))\n\treturn;\n\n    \/* Parse report rpt_types *\/\n    while ((pj_int32_t*)rb_hdr < (pj_int32_t*)pkt + pkt_len)\n    {\t\n\trb_len = pj_ntohs((pj_uint16_t)rb_hdr->length);\n\n\t\/* Just skip any block with length == 0 (no report content) *\/\n\tif (rb_len) {\n\t    switch (rb_hdr->bt) {\n\t\tcase BT_RR_TIME:\n\t\t    rb_rr_time = (pjmedia_rtcp_xr_rb_rr_time*) rb_hdr;\n\t\t    break;\n\t\tcase BT_DLRR:\n\t\t    rb_dlrr = (pjmedia_rtcp_xr_rb_dlrr*) rb_hdr;\n\t\t    break;\n\t\tcase BT_STATS:\n\t\t    rb_stats = (pjmedia_rtcp_xr_rb_stats*) rb_hdr;\n\t\t    break;\n\t\tcase BT_VOIP_METRICS:\n\t\t    rb_voip_mtc = (pjmedia_rtcp_xr_rb_voip_mtc*) rb_hdr;\n\t\t    break;\n\t\tdefault:\n\t\t    break;\n\t    }\n\t}\n\trb_hdr = (pjmedia_rtcp_xr_rb_header*)\n\t\t ((pj_int32_t*)rb_hdr + rb_len + 1);\n    }\n\n    \/* Receiving RR Time *\/\n    if (rb_rr_time) {\n\t\/* Save LRR from NTP timestamp of the RR time block report *\/\n\tsess->rx_lrr = ((pj_ntohl(rb_rr_time->ntp_sec) & 0x0000FFFF) << 16) | \n\t\t       ((pj_ntohl(rb_rr_time->ntp_frac) >> 16) & 0xFFFF);\n\n\t\/* Calculate RR arrival time for DLRR *\/\n\tpj_get_timestamp(&sess->rx_lrr_time);\n\n\tTRACE_((sess->name, \"Rx RTCP SR: ntp_ts=%p\", sess->rx_lrr,\n\t       (pj_uint32_t)(sess->rx_lrr_time.u64*65536\/\n\t\t\t     sess->rtcp_session->ts_freq.u64)));\n    }\n\n    \/* Receiving DLRR *\/\n    if (rb_dlrr) {\n\tpj_uint32_t lrr, now, dlrr;\n\tpj_uint64_t eedelay;\n\tpjmedia_rtcp_ntp_rec ntp;\n\n\t\/* LRR is the middle 32bit of NTP. It has 1\/65536 second \n\t * resolution \n\t *\/\n\tlrr = pj_ntohl(rb_dlrr->item.lrr);\n\n\t\/* DLRR is delay since LRR, also in 1\/65536 resolution *\/\n\tdlrr = pj_ntohl(rb_dlrr->item.dlrr);\n\n\t\/* Get current time, and convert to 1\/65536 resolution *\/\n\tpjmedia_rtcp_get_ntp_time(sess->rtcp_session, &ntp);\n\tnow = ((ntp.hi & 0xFFFF) << 16) + (ntp.lo >> 16);\n\n\t\/* End-to-end delay is (now-lrr-dlrr) *\/\n\teedelay = now - lrr - dlrr;\n\n\t\/* Convert end to end delay to usec (keeping the calculation in\n         * 64bit space)::\n\t *   sess->ee_delay = (eedelay * 1000) \/ 65536;\n\t *\/\n\tif (eedelay < 4294) {\n\t    eedelay = (eedelay * 1000000) >> 16;\n\t} else {\n\t    eedelay = (eedelay * 1000) >> 16;\n\t    eedelay *= 1000;\n\t}\n\n\tTRACE_((sess->name, \"Rx RTCP XR DLRR: lrr=%p, dlrr=%p (%d:%03dms), \"\n\t\t\t   \"now=%p, rtt=%p\",\n\t\tlrr, dlrr, dlrr\/65536, (dlrr%65536)*1000\/65536,\n\t\tnow, (pj_uint32_t)eedelay));\n\t\n\t\/* Only save calculation if \"now\" is greater than lrr, or\n\t * otherwise rtt will be invalid \n\t *\/\n\tif (now-dlrr >= lrr) {\n\t    unsigned rtt = (pj_uint32_t)eedelay;\n\t    \n\t    \/* Check that eedelay value really makes sense. \n\t     * We allow up to 30 seconds RTT!\n\t     *\/\n\t    if (eedelay <= 30 * 1000 * 1000UL) {\n\t\t\/* \"Normalize\" rtt value that is exceptionally high.\n\t\t * For such values, \"normalize\" the rtt to be three times\n\t\t * the average value.\n\t\t *\/\n\t\tif (rtt>((unsigned)sess->stat.rtt.mean*3) && sess->stat.rtt.n!=0)\n\t\t{\n\t\t    unsigned orig_rtt = rtt;\n\t\t    rtt = (unsigned)sess->stat.rtt.mean*3;\n\t\t    PJ_LOG(5,(sess->name, \n\t\t\t      \"RTT value %d usec is normalized to %d usec\",\n\t\t\t      orig_rtt, rtt));\n\t\t}\n    \t\n\t\tTRACE_((sess->name, \"RTCP RTT is set to %d usec\", rtt));\n\t\tpj_math_stat_update(&sess->stat.rtt, rtt);\n\t    }\n\t} else {\n\t    PJ_LOG(5, (sess->name, \"Internal RTCP NTP clock skew detected: \"\n\t\t\t\t   \"lrr=%p, now=%p, dlrr=%p (%d:%03dms), \"\n\t\t\t\t   \"diff=%d\",\n\t\t\t\t   lrr, now, dlrr, dlrr\/65536,\n\t\t\t\t   (dlrr%65536)*1000\/65536,\n\t\t\t\t   dlrr-(now-lrr)));\n\t}\n    }\n\n    \/* Receiving Statistics Summary *\/\n    if (rb_stats) {\n\tpj_uint8_t flags = rb_stats->header.specific;\n\n\tpj_bzero(&sess->stat.tx.stat_sum, sizeof(sess->stat.tx.stat_sum));\n\n\t\/* Range of packets sequence reported in this blocks *\/\n\tsess->stat.tx.stat_sum.begin_seq = pj_ntohs(rb_stats->begin_seq);\n\tsess->stat.tx.stat_sum.end_seq   = pj_ntohs(rb_stats->end_seq);\n\n\t\/* Get flags of valid fields *\/\n\tsess->stat.tx.stat_sum.l = (flags & (1 << 7)) != 0;\n\tsess->stat.tx.stat_sum.d = (flags & (1 << 6)) != 0;\n\tsess->stat.tx.stat_sum.j = (flags & (1 << 5)) != 0;\n\tsess->stat.tx.stat_sum.t = (flags & (3 << 3)) != 0;\n\n\t\/* Fetch the reports info *\/\n\tif (sess->stat.tx.stat_sum.l) {\n\t    sess->stat.tx.stat_sum.lost = pj_ntohl(rb_stats->lost);\n\t}\n\n\tif (sess->stat.tx.stat_sum.d) {\n\t    sess->stat.tx.stat_sum.dup = pj_ntohl(rb_stats->dup);\n\t}\n\n\tif (sess->stat.tx.stat_sum.j) {\n\t    sess->stat.tx.stat_sum.jitter.min = pj_ntohl(rb_stats->jitter_min);\n\t    sess->stat.tx.stat_sum.jitter.max = pj_ntohl(rb_stats->jitter_max);\n\t    sess->stat.tx.stat_sum.jitter.mean= pj_ntohl(rb_stats->jitter_mean);\n\t    pj_math_stat_set_stddev(&sess->stat.tx.stat_sum.jitter, \n\t\t\t\t    pj_ntohl(rb_stats->jitter_dev));\n\t}\n\n\tif (sess->stat.tx.stat_sum.t) {\n\t    sess->stat.tx.stat_sum.toh.min = rb_stats->toh_min;\n\t    sess->stat.tx.stat_sum.toh.max = rb_stats->toh_max;\n\t    sess->stat.tx.stat_sum.toh.mean= rb_stats->toh_mean;\n\t    pj_math_stat_set_stddev(&sess->stat.tx.stat_sum.toh, \n\t\t\t\t    pj_ntohl(rb_stats->toh_dev));\n\t}\n\n\tpj_gettimeofday(&sess->stat.tx.stat_sum.update);\n    }\n\n    \/* Receiving VoIP Metrics *\/\n    if (rb_voip_mtc) {\n\tsess->stat.tx.voip_mtc.loss_rate = rb_voip_mtc->loss_rate;\n\tsess->stat.tx.voip_mtc.discard_rate = rb_voip_mtc->discard_rate;\n\tsess->stat.tx.voip_mtc.burst_den = rb_voip_mtc->burst_den;\n\tsess->stat.tx.voip_mtc.gap_den = rb_voip_mtc->gap_den;\n\tsess->stat.tx.voip_mtc.burst_dur = pj_ntohs(rb_voip_mtc->burst_dur);\n\tsess->stat.tx.voip_mtc.gap_dur = pj_ntohs(rb_voip_mtc->gap_dur);\n\tsess->stat.tx.voip_mtc.rnd_trip_delay = \n\t\t\t\t\tpj_ntohs(rb_voip_mtc->rnd_trip_delay);\n\tsess->stat.tx.voip_mtc.end_sys_delay = \n\t\t\t\t\tpj_ntohs(rb_voip_mtc->end_sys_delay);\n\t\/* signal & noise level encoded in two's complement form *\/\n\tsess->stat.tx.voip_mtc.signal_lvl = (pj_int8_t)\n\t\t\t\t    ((rb_voip_mtc->signal_lvl > 127)?\n\t\t\t\t     ((int)rb_voip_mtc->signal_lvl - 256) : \n\t\t\t\t     rb_voip_mtc->signal_lvl);\n\tsess->stat.tx.voip_mtc.noise_lvl  = (pj_int8_t)\n\t\t\t\t    ((rb_voip_mtc->noise_lvl > 127)?\n\t\t\t\t     ((int)rb_voip_mtc->noise_lvl - 256) : \n\t\t\t\t     rb_voip_mtc->noise_lvl);\n\tsess->stat.tx.voip_mtc.rerl = rb_voip_mtc->rerl;\n\tsess->stat.tx.voip_mtc.gmin = rb_voip_mtc->gmin;\n\tsess->stat.tx.voip_mtc.r_factor = rb_voip_mtc->r_factor;\n\tsess->stat.tx.voip_mtc.ext_r_factor = rb_voip_mtc->ext_r_factor;\n\tsess->stat.tx.voip_mtc.mos_lq = rb_voip_mtc->mos_lq;\n\tsess->stat.tx.voip_mtc.mos_cq = rb_voip_mtc->mos_cq;\n\tsess->stat.tx.voip_mtc.rx_config = rb_voip_mtc->rx_config;\n\tsess->stat.tx.voip_mtc.jb_nom = pj_ntohs(rb_voip_mtc->jb_nom);\n\tsess->stat.tx.voip_mtc.jb_max = pj_ntohs(rb_voip_mtc->jb_max);\n\tsess->stat.tx.voip_mtc.jb_abs_max = pj_ntohs(rb_voip_mtc->jb_abs_max);\n\n\tpj_gettimeofday(&sess->stat.tx.voip_mtc.update);\n    }\n}","target":1,"code_token_length":2618,"total_token_length":2854,"max_tokens_setting":4096}
+{"idx":455330,"func":"main (argc, argv, env)\n     int argc;\n     char **argv, **env;\n#endif \/* !NO_MAIN_ENV_ARG *\/\n{\n  register int i;\n  int code, old_errexit_flag;\n#if defined (RESTRICTED_SHELL)\n  int saverst;\n#endif\n  volatile int locally_skip_execution;\n  volatile int arg_index, top_level_arg_index;\n#ifdef __OPENNT\n  char **env;\n\n  env = environ;\n#endif \/* __OPENNT *\/\n\n  USE_VAR(argc);\n  USE_VAR(argv);\n  USE_VAR(env);\n  USE_VAR(code);\n  USE_VAR(old_errexit_flag);\n#if defined (RESTRICTED_SHELL)\n  USE_VAR(saverst);\n#endif\n\n  \/* Catch early SIGINTs. *\/\n  code = setjmp_nosigs (top_level);\n  if (code)\n    exit (2);\n\n  xtrace_init ();\n\n#if defined (USING_BASH_MALLOC) && defined (DEBUG) && !defined (DISABLE_MALLOC_WRAPPERS)\n  malloc_set_register (1);\t\/* XXX - change to 1 for malloc debugging *\/\n#endif\n\n  check_dev_tty ();\n\n#ifdef __CYGWIN__\n  _cygwin32_check_tmp ();\n#endif \/* __CYGWIN__ *\/\n\n  \/* Wait forever if we are debugging a login shell. *\/\n  while (debugging_login_shell) sleep (3);\n\n  set_default_locale ();\n\n  running_setuid = uidget ();\n\n  if (getenv (\"POSIXLY_CORRECT\") || getenv (\"POSIX_PEDANTIC\"))\n    posixly_correct = 1;\n\n#if defined (USE_GNU_MALLOC_LIBRARY)\n  mcheck (programming_error, (void (*) ())0);\n#endif \/* USE_GNU_MALLOC_LIBRARY *\/\n\n  if (setjmp_sigs (subshell_top_level))\n    {\n      argc = subshell_argc;\n      argv = subshell_argv;\n      env = subshell_envp;\n      sourced_env = 0;\n    }\n\n  shell_reinitialized = 0;\n\n  \/* Initialize `local' variables for all `invocations' of main (). *\/\n  arg_index = 1;\n  if (arg_index > argc)\n    arg_index = argc;\n  command_execution_string = shell_script_filename = (char *)NULL;\n  want_pending_command = locally_skip_execution = read_from_stdin = 0;\n  default_input = stdin;\n#if defined (BUFFERED_INPUT)\n  default_buffered_input = -1;\n#endif\n\n  \/* Fix for the `infinite process creation' bug when running shell scripts\n     from startup files on System V. *\/\n  login_shell = make_login_shell = 0;\n\n  \/* If this shell has already been run, then reinitialize it to a\n     vanilla state. *\/\n  if (shell_initialized || shell_name)\n    {\n      \/* Make sure that we do not infinitely recurse as a login shell. *\/\n      if (*shell_name == '-')\n\tshell_name++;\n\n      shell_reinitialize ();\n      if (setjmp_nosigs (top_level))\n\texit (2);\n    }\n\n  shell_environment = env;\n  set_shell_name (argv[0]);\n  shell_start_time = NOW;\t\/* NOW now defined in general.h *\/\n\n  \/* Parse argument flags from the input line. *\/\n\n  \/* Find full word arguments first. *\/\n  arg_index = parse_long_options (argv, arg_index, argc);\n  \n  if (want_initial_help)\n    {\n      show_shell_usage (stdout, 1);\n      exit (EXECUTION_SUCCESS);\n    }\n\n  if (do_version)\n    {\n      show_shell_version (1);\n      exit (EXECUTION_SUCCESS);\n    }\n\n  echo_input_at_read = verbose_flag;\t\/* --verbose given *\/\n\n  \/* All done with full word options; do standard shell option parsing.*\/\n  this_command_name = shell_name;\t\/* for error reporting *\/\n  arg_index = parse_shell_options (argv, arg_index, argc);\n\n  \/* If user supplied the \"--login\" (or -l) flag, then set and invert\n     LOGIN_SHELL. *\/\n  if (make_login_shell)\n    {\n      login_shell++;\n      login_shell = -login_shell;\n    }\n\n  set_login_shell (\"login_shell\", login_shell != 0);\n\n  if (dump_po_strings)\n    dump_translatable_strings = 1;\n\n  if (dump_translatable_strings)\n    read_but_dont_execute = 1;\n\n  if (running_setuid && privileged_mode == 0)\n    disable_priv_mode ();\n\n  \/* Need to get the argument to a -c option processed in the\n     above loop.  The next arg is a command to execute, and the\n     following args are $0...$n respectively. *\/\n  if (want_pending_command)\n    {\n      command_execution_string = argv[arg_index];\n      if (command_execution_string == 0)\n\t{\n\t  report_error (_(\"%s: option requires an argument\"), \"-c\");\n\t  exit (EX_BADUSAGE);\n\t}\n      arg_index++;\n    }\n  this_command_name = (char *)NULL;\n\n  \/* First, let the outside world know about our interactive status.\n     A shell is interactive if the `-i' flag was given, or if all of\n     the following conditions are met:\n\tno -c command\n\tno arguments remaining or the -s flag given\n\tstandard input is a terminal\n\tstandard error is a terminal\n     Refer to Posix.2, the description of the `sh' utility. *\/\n\n  if (forced_interactive ||\t\t\/* -i flag *\/\n      (!command_execution_string &&\t\/* No -c command and ... *\/\n       wordexp_only == 0 &&\t\t\/* No --wordexp and ... *\/\n       ((arg_index == argc) ||\t\t\/*   no remaining args or... *\/\n\tread_from_stdin) &&\t\t\/*   -s flag with args, and *\/\n       isatty (fileno (stdin)) &&\t\/* Input is a terminal and *\/\n       isatty (fileno (stderr))))\t\/* error output is a terminal. *\/\n    init_interactive ();\n  else\n    init_noninteractive ();\n\n  \/*\n   * Some systems have the bad habit of starting login shells with lots of open\n   * file descriptors.  For instance, most systems that have picked up the\n   * pre-4.0 Sun YP code leave a file descriptor open each time you call one\n   * of the getpw* functions, and it's set to be open across execs.  That\n   * means one for login, one for xterm, one for shelltool, etc.  There are\n   * also systems that open persistent FDs to other agents or files as part\n   * of process startup; these need to be set to be close-on-exec.\n   *\/\n  if (login_shell && interactive_shell)\n    {\n      for (i = 3; i < 20; i++)\n\tSET_CLOSE_ON_EXEC (i);\n    }\n\n  \/* If we're in a strict Posix.2 mode, turn on interactive comments,\n     alias expansion in non-interactive shells, and other Posix.2 things. *\/\n  if (posixly_correct)\n    {\n      bind_variable (\"POSIXLY_CORRECT\", \"y\", 0);\n      sv_strict_posix (\"POSIXLY_CORRECT\");\n    }\n\n  \/* Now we run the shopt_alist and process the options. *\/\n  if (shopt_alist)\n    run_shopt_alist ();\n\n  \/* From here on in, the shell must be a normal functioning shell.\n     Variables from the environment are expected to be set, etc. *\/\n  shell_initialize ();\n\n  set_default_lang ();\n  set_default_locale_vars ();\n\n  \/*\n   * M-x term -> TERM=eterm-color INSIDE_EMACS='251,term:0.96' (eterm)\n   * M-x shell -> TERM='dumb' INSIDE_EMACS='25.1,comint' (no line editing)\n   *\n   * Older versions of Emacs may set EMACS to 't' or to something like\n   * '22.1 (term:0.96)' instead of (or in addition to) setting INSIDE_EMACS.\n   * They may set TERM to 'eterm' instead of 'eterm-color'.  They may have\n   * a now-obsolete command that sets neither EMACS nor INSIDE_EMACS:\n   * M-x terminal -> TERM='emacs-em7955' (line editing)\n   *\/\n  if (interactive_shell)\n    {\n      char *term, *emacs, *inside_emacs;\n      int emacs_term, in_emacs;\n\n      term = get_string_value (\"TERM\");\n      emacs = get_string_value (\"EMACS\");\n      inside_emacs = get_string_value (\"INSIDE_EMACS\");\n\n      if (inside_emacs)\n\t{\n\t  emacs_term = strstr (inside_emacs, \",term:\") != 0;\n\t  in_emacs = 1;\n\t}\n      else if (emacs)\n\t{\n\t  \/* Infer whether we are in an older Emacs. *\/\n\t  emacs_term = strstr (emacs, \" (term:\") != 0;\n\t  in_emacs = emacs_term || STREQ (emacs, \"t\");\n\t}\n      else\n\tin_emacs = emacs_term = 0;\n\n      \/* Not sure any emacs terminal emulator sets TERM=emacs any more *\/\n      no_line_editing |= STREQ (term, \"emacs\");\n      no_line_editing |= in_emacs && STREQ (term, \"dumb\");\n\n      \/* running_under_emacs == 2 for `eterm' *\/\n      running_under_emacs = in_emacs || STREQN (term, \"emacs\", 5);\n      running_under_emacs += emacs_term && STREQN (term, \"eterm\", 5);\n\n      if (running_under_emacs)\n\tgnu_error_format = 1;\n    }\n\n  top_level_arg_index = arg_index;\n  old_errexit_flag = exit_immediately_on_error;\n\n  \/* Give this shell a place to longjmp to before executing the\n     startup files.  This allows users to press C-c to abort the\n     lengthy startup. *\/\n  code = setjmp_sigs (top_level);\n  if (code)\n    {\n      if (code == EXITPROG || code == ERREXIT)\n\texit_shell (last_command_exit_value);\n      else\n\t{\n#if defined (JOB_CONTROL)\n\t  \/* Reset job control, since run_startup_files turned it off. *\/\n\t  set_job_control (interactive_shell);\n#endif\n\t  \/* Reset value of `set -e', since it's turned off before running\n\t     the startup files. *\/\n\t  exit_immediately_on_error += old_errexit_flag;\n\t  locally_skip_execution++;\n\t}\n    }\n\n  arg_index = top_level_arg_index;\n\n  \/* Execute the start-up scripts. *\/\n\n  if (interactive_shell == 0)\n    {\n      unbind_variable (\"PS1\");\n      unbind_variable (\"PS2\");\n      interactive = 0;\n#if 0\n      \/* This has already been done by init_noninteractive *\/\n      expand_aliases = posixly_correct;\n#endif\n    }\n  else\n    {\n      change_flag ('i', FLAG_ON);\n      interactive = 1;\n    }\n\n#if defined (RESTRICTED_SHELL)\n  \/* Set restricted_shell based on whether the basename of $0 indicates that\n     the shell should be restricted or if the `-r' option was supplied at\n     startup. *\/\n  restricted_shell = shell_is_restricted (shell_name);\n\n  \/* If the `-r' option is supplied at invocation, make sure that the shell\n     is not in restricted mode when running the startup files. *\/\n  saverst = restricted;\n  restricted = 0;\n#endif\n\n  \/* Set positional parameters before running startup files. top_level_arg_index\n     holds the index of the current argument before setting the positional\n     parameters, so any changes performed in the startup files won't affect\n     later option processing. *\/\n  if (wordexp_only)\n    ;\t\t\t\/* nothing yet *\/\n  else if (command_execution_string)\n    arg_index = bind_args (argv, arg_index, argc, 0);\t\/* $0 ... $n *\/\n  else if (arg_index != argc && read_from_stdin == 0)\n    {\n      shell_script_filename = argv[arg_index++];\n      arg_index = bind_args (argv, arg_index, argc, 1);\t\/* $1 ... $n *\/\n    }\n  else\n    arg_index = bind_args (argv, arg_index, argc, 1);\t\/* $1 ... $n *\/\n\n  \/* The startup files are run with `set -e' temporarily disabled. *\/\n  if (locally_skip_execution == 0 && running_setuid == 0)\n    {\n      old_errexit_flag = exit_immediately_on_error;\n      exit_immediately_on_error = 0;\n\n      run_startup_files ();\n      exit_immediately_on_error += old_errexit_flag;\n    }\n\n  \/* If we are invoked as `sh', turn on Posix mode. *\/\n  if (act_like_sh)\n    {\n      bind_variable (\"POSIXLY_CORRECT\", \"y\", 0);\n      sv_strict_posix (\"POSIXLY_CORRECT\");\n    }\n\n#if defined (RESTRICTED_SHELL)\n  \/* Turn on the restrictions after executing the startup files.  This\n     means that `bash -r' or `set -r' invoked from a startup file will\n     turn on the restrictions after the startup files are executed. *\/\n  restricted = saverst || restricted;\n  if (shell_reinitialized == 0)\n    maybe_make_restricted (shell_name);\n#endif \/* RESTRICTED_SHELL *\/\n\n#if defined (WORDEXP_OPTION)\n  if (wordexp_only)\n    {\n      startup_state = 3;\n      last_command_exit_value = run_wordexp (argv[top_level_arg_index]);\n      exit_shell (last_command_exit_value);\n    }\n#endif\n\n  cmd_init ();\t\t\/* initialize the command object caches *\/\n  uwp_init ();\n\n  if (command_execution_string)\n    {\n      startup_state = 2;\n\n      if (debugging_mode)\n\tstart_debugger ();\n\n#if defined (ONESHOT)\n      executing = 1;\n      run_one_command (command_execution_string);\n      exit_shell (last_command_exit_value);\n#else \/* ONESHOT *\/\n      with_input_from_string (command_execution_string, \"-c\");\n      goto read_and_execute;\n#endif \/* !ONESHOT *\/\n    }\n\n  \/* Get possible input filename and set up default_buffered_input or\n     default_input as appropriate. *\/\n  if (shell_script_filename)\n    open_shell_script (shell_script_filename);\n  else if (interactive == 0)\n    {\n      \/* In this mode, bash is reading a script from stdin, which is a\n\t pipe or redirected file. *\/\n#if defined (BUFFERED_INPUT)\n      default_buffered_input = fileno (stdin);\t\/* == 0 *\/\n#else\n      setbuf (default_input, (char *)NULL);\n#endif \/* !BUFFERED_INPUT *\/\n      read_from_stdin = 1;\n    }\n  else if (top_level_arg_index == argc)\t\t\/* arg index before startup files *\/\n    \/* \"If there are no operands and the -c option is not specified, the -s\n       option shall be assumed.\" *\/\n    read_from_stdin = 1;\n\n  set_bash_input ();\n\n  if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && (reading_shell_script || interactive_shell == 0))\n    start_debugger ();\n\n  \/* Do the things that should be done only for interactive shells. *\/\n  if (interactive_shell)\n    {\n      \/* Set up for checking for presence of mail. *\/\n      reset_mail_timer ();\n      init_mail_dates ();\n\n#if defined (HISTORY)\n      \/* Initialize the interactive history stuff. *\/\n      bash_initialize_history ();\n      \/* Don't load the history from the history file if we've already\n\t saved some lines in this session (e.g., by putting `history -s xx'\n\t into one of the startup files). *\/\n      if (shell_initialized == 0 && history_lines_this_session == 0)\n\tload_history ();\n#endif \/* HISTORY *\/\n\n      \/* Initialize terminal state for interactive shells after the\n\t .bash_profile and .bashrc are interpreted. *\/\n      get_tty_state ();\n    }\n\n#if !defined (ONESHOT)\n read_and_execute:\n#endif \/* !ONESHOT *\/\n\n  shell_initialized = 1;\n\n  if (pretty_print_mode && interactive_shell)\n    {\n      internal_warning (_(\"pretty-printing mode ignored in interactive shells\"));\n      pretty_print_mode = 0;\n    }\n  if (pretty_print_mode)\n    exit_shell (pretty_print_loop ());\n\n  \/* Read commands until exit condition. *\/\n  reader_loop ();\n  exit_shell (last_command_exit_value);\n}","target":0,"code_token_length":3504,"total_token_length":3740,"max_tokens_setting":4096}
+{"idx":335424,"func":"eval_vars(\n    char_u\t*src,\t\t\/\/ pointer into commandline\n    char_u\t*srcstart,\t\/\/ beginning of valid memory for src\n    int\t\t*usedlen,\t\/\/ characters after src that are used\n    linenr_T\t*lnump,\t\t\/\/ line number for :e command, or NULL\n    char\t**errormsg,\t\/\/ pointer to error message\n    int\t\t*escaped,\t\/\/ return value has escaped white space (can\n\t\t\t\t\/\/ be NULL)\n    int\t\tempty_is_error)\t\/\/ empty result is considered an error\n{\n    int\t\ti;\n    char_u\t*s;\n    char_u\t*result;\n    char_u\t*resultbuf = NULL;\n    int\t\tresultlen;\n    buf_T\t*buf;\n    int\t\tvalid = VALID_HEAD + VALID_PATH;    \/\/ assume valid result\n    int\t\tspec_idx;\n    int\t\ttilde_file = FALSE;\n    int\t\tskip_mod = FALSE;\n    char_u\tstrbuf[30];\n\n    *errormsg = NULL;\n    if (escaped != NULL)\n\t*escaped = FALSE;\n\n    \/*\n     * Check if there is something to do.\n     *\/\n    spec_idx = find_cmdline_var(src, usedlen);\n    if (spec_idx < 0)\t\/\/ no match\n    {\n\t*usedlen = 1;\n\treturn NULL;\n    }\n\n    \/*\n     * Skip when preceded with a backslash \"\\%\" and \"\\#\".\n     * Note: In \"\\\\%\" the % is also not recognized!\n     *\/\n    if (src > srcstart && src[-1] == '\\\\')\n    {\n\t*usedlen = 0;\n\tSTRMOVE(src - 1, src);\t\/\/ remove backslash\n\treturn NULL;\n    }\n\n    \/*\n     * word or WORD under cursor\n     *\/\n    if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD\n\t\t\t\t\t\t     || spec_idx == SPEC_CEXPR)\n    {\n\tresultlen = find_ident_under_cursor(&result,\n\t\tspec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING)\n\t      : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL)\n\t      : FIND_STRING);\n\tif (resultlen == 0)\n\t{\n\t    *errormsg = \"\";\n\t    return NULL;\n\t}\n    }\n\n    \/*\n     * '#': Alternate file name\n     * '%': Current file name\n     *\t    File name under the cursor\n     *\t    File name for autocommand\n     *\tand following modifiers\n     *\/\n    else\n    {\n\tint off = 0;\n\n\tswitch (spec_idx)\n\t{\n\tcase SPEC_PERC:\n#ifdef FEAT_EVAL\n\t\tif (!in_vim9script() || src[1] != '%')\n#endif\n\t\t{\n\t\t    \/\/ '%': current file\n\t\t    if (curbuf->b_fname == NULL)\n\t\t    {\n\t\t\tresult = (char_u *)\"\";\n\t\t\tvalid = 0;\t    \/\/ Must have \":p:h\" to be valid\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tresult = curbuf->b_fname;\n\t\t\ttilde_file = STRCMP(result, \"~\") == 0;\n\t\t    }\n\t\t    break;\n\t\t}\n#ifdef FEAT_EVAL\n\t\t\/\/ \"%%\" alternate file\n\t\toff = 1;\n#endif\n\t\t\/\/ FALLTHROUGH\n\tcase SPEC_HASH:\t\t\/\/ '#' or \"#99\": alternate file\n\t\tif (off == 0 ? src[1] == '#' : src[2] == '%')\n\t\t{\n\t\t    \/\/ \"##\" or \"%%%\": the argument list\n\t\t    result = arg_all();\n\t\t    resultbuf = result;\n\t\t    *usedlen = off + 2;\n\t\t    if (escaped != NULL)\n\t\t\t*escaped = TRUE;\n\t\t    skip_mod = TRUE;\n\t\t    break;\n\t\t}\n\t\ts = src + off + 1;\n\t\tif (*s == '<')\t\t\/\/ \"#<99\" uses v:oldfiles\n\t\t    ++s;\n\t\ti = (int)getdigits(&s);\n\t\tif (s == src + off + 2 && src[off + 1] == '-')\n\t\t    \/\/ just a minus sign, don't skip over it\n\t\t    s--;\n\t\t*usedlen = (int)(s - src); \/\/ length of what we expand\n\n\t\tif (src[off + 1] == '<' && i != 0)\n\t\t{\n\t\t    if (*usedlen < off + 2)\n\t\t    {\n\t\t\t\/\/ Should we give an error message for #<text?\n\t\t\t*usedlen = off + 1;\n\t\t\treturn NULL;\n\t\t    }\n#ifdef FEAT_EVAL\n\t\t    result = list_find_str(get_vim_var_list(VV_OLDFILES),\n\t\t\t\t\t\t\t\t     (long)i);\n\t\t    if (result == NULL)\n\t\t    {\n\t\t\t*errormsg = \"\";\n\t\t\treturn NULL;\n\t\t    }\n#else\n\t\t    *errormsg = _(e_hashsmall_is_not_available_without_the_eval_feature);\n\t\t    return NULL;\n#endif\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (i == 0 && src[off + 1] == '<' && *usedlen > off + 1)\n\t\t\t*usedlen = off + 1;\n\t\t    buf = buflist_findnr(i);\n\t\t    if (buf == NULL)\n\t\t    {\n\t\t\t*errormsg = _(e_no_alternate_file_name_to_substitute_for_hash);\n\t\t\treturn NULL;\n\t\t    }\n\t\t    if (lnump != NULL)\n\t\t\t*lnump = ECMD_LAST;\n\t\t    if (buf->b_fname == NULL)\n\t\t    {\n\t\t\tresult = (char_u *)\"\";\n\t\t\tvalid = 0;\t    \/\/ Must have \":p:h\" to be valid\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tresult = buf->b_fname;\n\t\t\ttilde_file = STRCMP(result, \"~\") == 0;\n\t\t    }\n\t\t}\n\t\tbreak;\n\n#ifdef FEAT_SEARCHPATH\n\tcase SPEC_CFILE:\t\/\/ file name under cursor\n\t\tresult = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = \"\";\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n#endif\n\n\tcase SPEC_AFILE:\t\/\/ file name for autocommand\n\t\tresult = autocmd_fname;\n\t\tif (result != NULL && !autocmd_fname_full)\n\t\t{\n\t\t    \/\/ Still need to turn the fname into a full path.  It is\n\t\t    \/\/ postponed to avoid a delay when <afile> is not used.\n\t\t    autocmd_fname_full = TRUE;\n\t\t    result = FullName_save(autocmd_fname, FALSE);\n\t\t    vim_free(autocmd_fname);\n\t\t    autocmd_fname = result;\n\t\t}\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_autocommand_file_name_to_substitute_for_afile);\n\t\t    return NULL;\n\t\t}\n\t\tresult = shorten_fname1(result);\n\t\tbreak;\n\n\tcase SPEC_ABUF:\t\t\/\/ buffer number for autocommand\n\t\tif (autocmd_bufnr <= 0)\n\t\t{\n\t\t    *errormsg = _(e_no_autocommand_buffer_name_to_substitute_for_abuf);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"%d\", autocmd_bufnr);\n\t\tresult = strbuf;\n\t\tbreak;\n\n\tcase SPEC_AMATCH:\t\/\/ match name for autocommand\n\t\tresult = autocmd_match;\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_autocommand_match_name_to_substitute_for_amatch);\n\t\t    return NULL;\n\t\t}\n\t\tbreak;\n\n\tcase SPEC_SFILE:\t\/\/ file name for \":so\" command\n\t\tresult = estack_sfile(ESTACK_SFILE);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_source_file_name_to_substitute_for_sfile);\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\tcase SPEC_STACK:\t\/\/ call stack\n\t\tresult = estack_sfile(ESTACK_STACK);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_call_stack_to_substitute_for_stack);\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\tcase SPEC_SCRIPT:\t\/\/ script file name\n\t\tresult = estack_sfile(ESTACK_SCRIPT);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_script_file_name_to_substitute_for_script);\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\n\tcase SPEC_SLNUM:\t\/\/ line in file for \":so\" command\n\t\tif (SOURCING_NAME == NULL || SOURCING_LNUM == 0)\n\t\t{\n\t\t    *errormsg = _(e_no_line_number_to_use_for_slnum);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"%ld\", SOURCING_LNUM);\n\t\tresult = strbuf;\n\t\tbreak;\n\n#ifdef FEAT_EVAL\n\tcase SPEC_SFLNUM:\t\/\/ line in script file\n\t\tif (current_sctx.sc_lnum + SOURCING_LNUM == 0)\n\t\t{\n\t\t    *errormsg = _(e_no_line_number_to_use_for_sflnum);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"%ld\",\n\t\t\t\t (long)(current_sctx.sc_lnum + SOURCING_LNUM));\n\t\tresult = strbuf;\n\t\tbreak;\n\n\tcase SPEC_SID:\n\t\tif (current_sctx.sc_sid <= 0)\n\t\t{\n\t\t    *errormsg = _(e_using_sid_not_in_script_context);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"<SNR>%d_\", current_sctx.sc_sid);\n\t\tresult = strbuf;\n\t\tbreak;\n#endif\n\n#ifdef FEAT_CLIENTSERVER\n\tcase SPEC_CLIENT:\t\/\/ Source of last submitted input\n\t\tsprintf((char *)strbuf, PRINTF_HEX_LONG_U,\n\t\t\t\t\t\t\t(long_u)clientWindow);\n\t\tresult = strbuf;\n\t\tbreak;\n#endif\n\n\tdefault:\n\t\tresult = (char_u *)\"\"; \/\/ avoid gcc warning\n\t\tbreak;\n\t}\n\n\tresultlen = (int)STRLEN(result);\t\/\/ length of new string\n\tif (src[*usedlen] == '<')\t\/\/ remove the file name extension\n\t{\n\t    ++*usedlen;\n\t    if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))\n\t\tresultlen = (int)(s - result);\n\t}\n\telse if (!skip_mod)\n\t{\n\t    valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf,\n\t\t\t\t\t\t\t\t  &resultlen);\n\t    if (result == NULL)\n\t    {\n\t\t*errormsg = \"\";\n\t\treturn NULL;\n\t    }\n\t}\n    }\n\n    if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)\n    {\n\tif (empty_is_error)\n\t{\n\t    if (valid != VALID_HEAD + VALID_PATH)\n\t\t*errormsg = _(e_empty_file_name_for_percent_or_hash_only_works_with_ph);\n\t    else\n\t\t*errormsg = _(e_evaluates_to_an_empty_string);\n\t}\n\tresult = NULL;\n    }\n    else\n\tresult = vim_strnsave(result, resultlen);\n    vim_free(resultbuf);\n    return result;\n}","target":0,"code_token_length":2418,"total_token_length":2654,"max_tokens_setting":4096}
+{"idx":454759,"func":"static int ismt_access(struct i2c_adapter *adap, u16 addr,\n\t\t       unsigned short flags, char read_write, u8 command,\n\t\t       int size, union i2c_smbus_data *data)\n{\n\tint ret;\n\tunsigned long time_left;\n\tdma_addr_t dma_addr = 0; \/* address of the data buffer *\/\n\tu8 dma_size = 0;\n\tenum dma_data_direction dma_direction = 0;\n\tstruct ismt_desc *desc;\n\tstruct ismt_priv *priv = i2c_get_adapdata(adap);\n\tstruct device *dev = &priv->pci_dev->dev;\n\tu8 *dma_buffer = PTR_ALIGN(&priv->buffer[0], 16);\n\n\tdesc = &priv->hw[priv->head];\n\n\t\/* Initialize the DMA buffer *\/\n\tmemset(priv->buffer, 0, sizeof(priv->buffer));\n\n\t\/* Initialize the descriptor *\/\n\tmemset(desc, 0, sizeof(struct ismt_desc));\n\tdesc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, read_write);\n\n\t\/* Always clear the log entries *\/\n\tmemset(priv->log, 0, ISMT_LOG_ENTRIES * sizeof(u32));\n\n\t\/* Initialize common control bits *\/\n\tif (likely(pci_dev_msi_enabled(priv->pci_dev)))\n\t\tdesc->control = ISMT_DESC_INT | ISMT_DESC_FAIR;\n\telse\n\t\tdesc->control = ISMT_DESC_FAIR;\n\n\tif ((flags & I2C_CLIENT_PEC) && (size != I2C_SMBUS_QUICK)\n\t    && (size != I2C_SMBUS_I2C_BLOCK_DATA))\n\t\tdesc->control |= ISMT_DESC_PEC;\n\n\tswitch (size) {\n\tcase I2C_SMBUS_QUICK:\n\t\tdev_dbg(dev, \"I2C_SMBUS_QUICK\\n\");\n\t\tbreak;\n\n\tcase I2C_SMBUS_BYTE:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/*\n\t\t\t * Send Byte\n\t\t\t * The command field contains the write data\n\t\t\t *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE:  WRITE\\n\");\n\t\t\tdesc->control |= ISMT_DESC_CWRL;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t} else {\n\t\t\t\/* Receive Byte *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE:  READ\\n\");\n\t\t\tdma_size = 1;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t\tdesc->rd_len = 1;\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_BYTE_DATA:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/*\n\t\t\t * Write Byte\n\t\t\t * Command plus 1 data byte\n\t\t\t *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE_DATA:  WRITE\\n\");\n\t\t\tdesc->wr_len_cmd = 2;\n\t\t\tdma_size = 2;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdma_buffer[0] = command;\n\t\t\tdma_buffer[1] = data->byte;\n\t\t} else {\n\t\t\t\/* Read Byte *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE_DATA:  READ\\n\");\n\t\t\tdesc->control |= ISMT_DESC_CWRL;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->rd_len = 1;\n\t\t\tdma_size = 1;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_WORD_DATA:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/* Write Word *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_WORD_DATA:  WRITE\\n\");\n\t\t\tdesc->wr_len_cmd = 3;\n\t\t\tdma_size = 3;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdma_buffer[0] = command;\n\t\t\tdma_buffer[1] = data->word & 0xff;\n\t\t\tdma_buffer[2] = data->word >> 8;\n\t\t} else {\n\t\t\t\/* Read Word *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_WORD_DATA:  READ\\n\");\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->control |= ISMT_DESC_CWRL;\n\t\t\tdesc->rd_len = 2;\n\t\t\tdma_size = 2;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_PROC_CALL:\n\t\tdev_dbg(dev, \"I2C_SMBUS_PROC_CALL\\n\");\n\t\tdesc->wr_len_cmd = 3;\n\t\tdesc->rd_len = 2;\n\t\tdma_size = 3;\n\t\tdma_direction = DMA_BIDIRECTIONAL;\n\t\tdma_buffer[0] = command;\n\t\tdma_buffer[1] = data->word & 0xff;\n\t\tdma_buffer[2] = data->word >> 8;\n\t\tbreak;\n\n\tcase I2C_SMBUS_BLOCK_DATA:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/* Block Write *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BLOCK_DATA:  WRITE\\n\");\n\t\t\tdma_size = data->block[0] + 1;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdesc->wr_len_cmd = dma_size;\n\t\t\tdesc->control |= ISMT_DESC_BLK;\n\t\t\tdma_buffer[0] = command;\n\t\t\tmemcpy(&dma_buffer[1], &data->block[1], dma_size - 1);\n\t\t} else {\n\t\t\t\/* Block Read *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BLOCK_DATA:  READ\\n\");\n\t\t\tdma_size = I2C_SMBUS_BLOCK_MAX;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t\tdesc->rd_len = dma_size;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->control |= (ISMT_DESC_BLK | ISMT_DESC_CWRL);\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_BLOCK_PROC_CALL:\n\t\tdev_dbg(dev, \"I2C_SMBUS_BLOCK_PROC_CALL\\n\");\n\t\tif (data->block[0] > I2C_SMBUS_BLOCK_MAX)\n\t\t\treturn -EINVAL;\n\n\t\tdma_size = I2C_SMBUS_BLOCK_MAX;\n\t\tdesc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, 1);\n\t\tdesc->wr_len_cmd = data->block[0] + 1;\n\t\tdesc->rd_len = dma_size;\n\t\tdesc->control |= ISMT_DESC_BLK;\n\t\tdma_direction = DMA_BIDIRECTIONAL;\n\t\tdma_buffer[0] = command;\n\t\tmemcpy(&dma_buffer[1], &data->block[1], data->block[0]);\n\t\tbreak;\n\n\tcase I2C_SMBUS_I2C_BLOCK_DATA:\n\t\t\/* Make sure the length is valid *\/\n\t\tif (data->block[0] < 1)\n\t\t\tdata->block[0] = 1;\n\n\t\tif (data->block[0] > I2C_SMBUS_BLOCK_MAX)\n\t\t\tdata->block[0] = I2C_SMBUS_BLOCK_MAX;\n\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/* i2c Block Write *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_I2C_BLOCK_DATA:  WRITE\\n\");\n\t\t\tdma_size = data->block[0] + 1;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdesc->wr_len_cmd = dma_size;\n\t\t\tdesc->control |= ISMT_DESC_I2C;\n\t\t\tdma_buffer[0] = command;\n\t\t\tmemcpy(&dma_buffer[1], &data->block[1], dma_size - 1);\n\t\t} else {\n\t\t\t\/* i2c Block Read *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_I2C_BLOCK_DATA:  READ\\n\");\n\t\t\tdma_size = data->block[0];\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t\tdesc->rd_len = dma_size;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->control |= (ISMT_DESC_I2C | ISMT_DESC_CWRL);\n\t\t\t\/*\n\t\t\t * Per the \"Table 15-15. I2C Commands\",\n\t\t\t * in the External Design Specification (EDS),\n\t\t\t * (Document Number: 508084, Revision: 2.0),\n\t\t\t * the _rw bit must be 0\n\t\t\t *\/\n\t\t\tdesc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, 0);\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tdev_err(dev, \"Unsupported transaction %d\\n\",\n\t\t\tsize);\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\t\/* map the data buffer *\/\n\tif (dma_size != 0) {\n\t\tdev_dbg(dev, \" dev=%p\\n\", dev);\n\t\tdev_dbg(dev, \" data=%p\\n\", data);\n\t\tdev_dbg(dev, \" dma_buffer=%p\\n\", dma_buffer);\n\t\tdev_dbg(dev, \" dma_size=%d\\n\", dma_size);\n\t\tdev_dbg(dev, \" dma_direction=%d\\n\", dma_direction);\n\n\t\tdma_addr = dma_map_single(dev,\n\t\t\t\t      dma_buffer,\n\t\t\t\t      dma_size,\n\t\t\t\t      dma_direction);\n\n\t\tif (dma_mapping_error(dev, dma_addr)) {\n\t\t\tdev_err(dev, \"Error in mapping dma buffer %p\\n\",\n\t\t\t\tdma_buffer);\n\t\t\treturn -EIO;\n\t\t}\n\n\t\tdev_dbg(dev, \" dma_addr = %pad\\n\", &dma_addr);\n\n\t\tdesc->dptr_low = lower_32_bits(dma_addr);\n\t\tdesc->dptr_high = upper_32_bits(dma_addr);\n\t}\n\n\treinit_completion(&priv->cmp);\n\n\t\/* Add the descriptor *\/\n\tismt_submit_desc(priv);\n\n\t\/* Now we wait for interrupt completion, 1s *\/\n\ttime_left = wait_for_completion_timeout(&priv->cmp, HZ*1);\n\n\t\/* unmap the data buffer *\/\n\tif (dma_size != 0)\n\t\tdma_unmap_single(dev, dma_addr, dma_size, dma_direction);\n\n\tif (unlikely(!time_left)) {\n\t\tdev_err(dev, \"completion wait timed out\\n\");\n\t\tret = -ETIMEDOUT;\n\t\tgoto out;\n\t}\n\n\t\/* do any post processing of the descriptor here *\/\n\tret = ismt_process_desc(desc, data, priv, size, read_write);\n\nout:\n\t\/* Update the ring pointer *\/\n\tpriv->head++;\n\tpriv->head %= ISMT_DESC_ENTRIES;\n\n\treturn ret;\n}","target":0,"code_token_length":2197,"total_token_length":2433,"max_tokens_setting":4096}
+{"idx":210273,"func":"createRandomCursorExecutor(const CollectionPtr& coll,\n                           const boost::intrusive_ptr<ExpressionContext>& expCtx,\n                           long long sampleSize,\n                           long long numRecords,\n                           boost::optional<BucketUnpacker> bucketUnpacker) {\n    OperationContext* opCtx = expCtx->opCtx;\n\n    \/\/ Verify that we are already under a collection lock. We avoid taking locks ourselves in this\n    \/\/ function because double-locking forces any PlanExecutor we create to adopt a NO_YIELD policy.\n    invariant(opCtx->lockState()->isCollectionLockedForMode(coll->ns(), MODE_IS));\n\n    static const double kMaxSampleRatioForRandCursor = 0.05;\n    if (!expCtx->ns.isTimeseriesBucketsCollection()) {\n        if (sampleSize > numRecords * kMaxSampleRatioForRandCursor || numRecords <= 100) {\n            return std::pair{nullptr, false};\n        }\n    } else {\n        \/\/ Suppose that a time-series bucket collection is observed to contain 200 buckets, and the\n        \/\/ 'gTimeseriesBucketMaxCount' parameter is set to 1000. If all buckets are full, then the\n        \/\/ maximum possible measurment count would be 200 * 1000 = 200,000. While the\n        \/\/ 'SampleFromTimeseriesBucket' plan is more efficient when the sample size is small\n        \/\/ relative to the total number of measurements in the time-series collection, for larger\n        \/\/ sample sizes the top-k sort based sample is faster. Experiments have approximated that\n        \/\/ the tipping point is roughly when the requested sample size is greater than 1% of the\n        \/\/ maximum possible number of measurements in the collection (i.e. numBuckets *\n        \/\/ maxMeasurementsPerBucket).\n        static const double kCoefficient = 0.01;\n        if (sampleSize > kCoefficient * numRecords * gTimeseriesBucketMaxCount) {\n            return std::pair{nullptr, false};\n        }\n    }\n\n    \/\/ Attempt to get a random cursor from the RecordStore.\n    auto rsRandCursor = coll->getRecordStore()->getRandomCursor(opCtx);\n    if (!rsRandCursor) {\n        \/\/ The storage engine has no random cursor support.\n        return std::pair{nullptr, false};\n    }\n\n    \/\/ Build a MultiIteratorStage and pass it the random-sampling RecordCursor.\n    auto ws = std::make_unique<WorkingSet>();\n    std::unique_ptr<PlanStage> root =\n        std::make_unique<MultiIteratorStage>(expCtx.get(), ws.get(), coll);\n    static_cast<MultiIteratorStage*>(root.get())->addIterator(std::move(rsRandCursor));\n\n    \/\/ If the incoming operation is sharded, use the CSS to infer the filtering metadata for the\n    \/\/ collection, otherwise treat it as unsharded\n    auto collectionFilter =\n        CollectionShardingState::get(opCtx, coll->ns())\n            ->getOwnershipFilter(\n                opCtx, CollectionShardingState::OrphanCleanupPolicy::kDisallowOrphanCleanup);\n\n    TrialStage* trialStage = nullptr;\n\n    \/\/ Because 'numRecords' includes orphan documents, our initial decision to optimize the $sample\n    \/\/ cursor may have been mistaken. For sharded collections, build a TRIAL plan that will switch\n    \/\/ to a collection scan if the ratio of orphaned to owned documents encountered over the first\n    \/\/ 100 works() is such that we would have chosen not to optimize.\n    static const size_t kMaxPresampleSize = 100;\n    if (collectionFilter.isSharded() && !expCtx->ns.isTimeseriesBucketsCollection()) {\n        \/\/ The ratio of owned to orphaned documents must be at least equal to the ratio between the\n        \/\/ requested sampleSize and the maximum permitted sampleSize for the original constraints to\n        \/\/ be satisfied. For instance, if there are 200 documents and the sampleSize is 5, then at\n        \/\/ least (5 \/ (200*0.05)) = (5\/10) = 50% of those documents must be owned. If less than 5%\n        \/\/ of the documents in the collection are owned, we default to the backup plan.\n        const auto minAdvancedToWorkRatio = std::max(\n            sampleSize \/ (numRecords * kMaxSampleRatioForRandCursor), kMaxSampleRatioForRandCursor);\n        \/\/ The trial plan is SHARDING_FILTER-MULTI_ITERATOR.\n        auto randomCursorPlan = std::make_unique<ShardFilterStage>(\n            expCtx.get(), collectionFilter, ws.get(), std::move(root));\n        \/\/ The backup plan is SHARDING_FILTER-COLLSCAN.\n        std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>(\n            expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr);\n        collScanPlan = std::make_unique<ShardFilterStage>(\n            expCtx.get(), collectionFilter, ws.get(), std::move(collScanPlan));\n        \/\/ Place a TRIAL stage at the root of the plan tree, and pass it the trial and backup plans.\n        root = std::make_unique<TrialStage>(expCtx.get(),\n                                            ws.get(),\n                                            std::move(randomCursorPlan),\n                                            std::move(collScanPlan),\n                                            kMaxPresampleSize,\n                                            minAdvancedToWorkRatio);\n        trialStage = static_cast<TrialStage*>(root.get());\n    } else if (expCtx->ns.isTimeseriesBucketsCollection()) {\n        \/\/ We can't take ARHASH optimization path for a direct $sample on the system.buckets\n        \/\/ collection because data is in compressed form. If we did have a direct $sample on the\n        \/\/ system.buckets collection, then the 'bucketUnpacker' would not be set up properly. We\n        \/\/ also should bail out early if a $sample is made against a time series collection that is\n        \/\/ empty. If we don't the 'minAdvancedToWorkRatio' can be nan\/-nan depending on the\n        \/\/ architecture.\n        if (!(bucketUnpacker && numRecords)) {\n            return std::pair{nullptr, false};\n        }\n\n        \/\/ Use a 'TrialStage' to run a trial between 'SampleFromTimeseriesBucket' and\n        \/\/ 'UnpackTimeseriesBucket' with $sample left in the pipeline in-place. If the buckets are\n        \/\/ not sufficiently full, or the 'SampleFromTimeseriesBucket' plan draws too many\n        \/\/ duplicates, then we will fall back to the 'TrialStage' backup plan. This backup plan uses\n        \/\/ the top-k sort sampling approach.\n        \/\/\n        \/\/ Suppose the 'gTimeseriesBucketMaxCount' is 1000, but each bucket only contains 500\n        \/\/ documents on average. The observed trial advanced\/work ratio approximates the average\n        \/\/ bucket fullness, noted here as \"abf\". In this example, abf = 500 \/ 1000 = 0.5.\n        \/\/ Experiments have shown that the optimized 'SampleFromTimeseriesBucket' algorithm performs\n        \/\/ better than backup plan when\n        \/\/\n        \/\/     sampleSize < 0.02 * abf * numRecords * gTimeseriesBucketMaxCount\n        \/\/\n        \/\/  This inequality can be rewritten as\n        \/\/\n        \/\/     abf > sampleSize \/ (0.02 * numRecords * gTimeseriesBucketMaxCount)\n        \/\/\n        \/\/ Therefore, if the advanced\/work ratio exceeds this threshold, we will use the\n        \/\/ 'SampleFromTimeseriesBucket' plan. Note that as the sample size requested by the user\n        \/\/ becomes larger with respect to the number of buckets, we require a higher advanced\/work\n        \/\/ ratio in order to justify using 'SampleFromTimeseriesBucket'.\n        \/\/\n        \/\/ Additionally, we require the 'TrialStage' to approximate the abf as at least 0.25. When\n        \/\/ buckets are mostly empty, the 'SampleFromTimeseriesBucket' will be inefficient due to a\n        \/\/ lot of sampling \"misses\".\n        static const auto kCoefficient = 0.02;\n        static const auto kMinBucketFullness = 0.25;\n        const auto minAdvancedToWorkRatio = std::max(\n            std::min(sampleSize \/ (kCoefficient * numRecords * gTimeseriesBucketMaxCount), 1.0),\n            kMinBucketFullness);\n\n        auto arhashPlan = std::make_unique<SampleFromTimeseriesBucket>(\n            expCtx.get(),\n            ws.get(),\n            std::move(root),\n            *bucketUnpacker,\n            \/\/ By using a quantity slightly higher than 'kMaxPresampleSize', we ensure that the\n            \/\/ 'SampleFromTimeseriesBucket' stage won't fail due to too many consecutive sampling\n            \/\/ attempts during the 'TrialStage's trial period.\n            kMaxPresampleSize + 5,\n            sampleSize,\n            gTimeseriesBucketMaxCount);\n\n        std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>(\n            expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr);\n\n        auto topkSortPlan = std::make_unique<UnpackTimeseriesBucket>(\n            expCtx.get(), ws.get(), std::move(collScanPlan), *bucketUnpacker);\n\n        root = std::make_unique<TrialStage>(expCtx.get(),\n                                            ws.get(),\n                                            std::move(arhashPlan),\n                                            std::move(topkSortPlan),\n                                            kMaxPresampleSize,\n                                            minAdvancedToWorkRatio);\n        trialStage = static_cast<TrialStage*>(root.get());\n    }\n\n    auto execStatus = plan_executor_factory::make(expCtx,\n                                                  std::move(ws),\n                                                  std::move(root),\n                                                  &coll,\n                                                  opCtx->inMultiDocumentTransaction()\n                                                      ? PlanYieldPolicy::YieldPolicy::INTERRUPT_ONLY\n                                                      : PlanYieldPolicy::YieldPolicy::YIELD_AUTO,\n                                                  QueryPlannerParams::RETURN_OWNED_DATA);\n    if (!execStatus.isOK()) {\n        return execStatus.getStatus();\n    }\n\n    \/\/ For sharded collections, the root of the plan tree is a TrialStage that may have chosen\n    \/\/ either a random-sampling cursor trial plan or a COLLSCAN backup plan. We can only optimize\n    \/\/ the $sample aggregation stage if the trial plan was chosen.\n    return std::pair{std::move(execStatus.getValue()),\n                     !trialStage || !trialStage->pickedBackupPlan()};\n}","target":1,"code_token_length":2243,"total_token_length":2479,"max_tokens_setting":4096}
+{"idx":326604,"func":"_archive_write_disk_finish_entry(struct archive *_a)\n{\n\tstruct archive_write_disk *a = (struct archive_write_disk *)_a;\n\tint ret = ARCHIVE_OK;\n\n\tarchive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,\n\t    ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,\n\t    \"archive_write_finish_entry\");\n\tif (a->archive.state & ARCHIVE_STATE_HEADER)\n\t\treturn (ARCHIVE_OK);\n\tarchive_clear_error(&a->archive);\n\n\t\/* Pad or truncate file to the right size. *\/\n\tif (a->fd < 0) {\n\t\t\/* There's no file. *\/\n\t} else if (a->filesize < 0) {\n\t\t\/* File size is unknown, so we can't set the size. *\/\n\t} else if (a->fd_offset == a->filesize) {\n\t\t\/* Last write ended at exactly the filesize; we're done. *\/\n\t\t\/* Hopefully, this is the common case. *\/\n#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_ZLIB_H)\n\t} else if (a->todo & TODO_HFS_COMPRESSION) {\n\t\tchar null_d[1024];\n\t\tssize_t r;\n\n\t\tif (a->file_remaining_bytes)\n\t\t\tmemset(null_d, 0, sizeof(null_d));\n\t\twhile (a->file_remaining_bytes) {\n\t\t\tif (a->file_remaining_bytes > sizeof(null_d))\n\t\t\t\tr = hfs_write_data_block(\n\t\t\t\t    a, null_d, sizeof(null_d));\n\t\t\telse\n\t\t\t\tr = hfs_write_data_block(\n\t\t\t\t    a, null_d, a->file_remaining_bytes);\n\t\t\tif (r < 0)\n\t\t\t\treturn ((int)r);\n\t\t}\n#endif\n\t} else {\n#if HAVE_FTRUNCATE\n\t\tif (ftruncate(a->fd, a->filesize) == -1 &&\n\t\t    a->filesize == 0) {\n\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t    \"File size could not be restored\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n#endif\n\t\t\/*\n\t\t * Not all platforms implement the XSI option to\n\t\t * extend files via ftruncate.  Stat() the file again\n\t\t * to see what happened.\n\t\t *\/\n\t\ta->pst = NULL;\n\t\tif ((ret = lazy_stat(a)) != ARCHIVE_OK)\n\t\t\treturn (ret);\n\t\t\/* We can use lseek()\/write() to extend the file if\n\t\t * ftruncate didn't work or isn't available. *\/\n\t\tif (a->st.st_size < a->filesize) {\n\t\t\tconst char nul = '\\0';\n\t\t\tif (lseek(a->fd, a->filesize - 1, SEEK_SET) < 0) {\n\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t    \"Seek failed\");\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\tif (write(a->fd, &nul, 1) < 0) {\n\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t    \"Write to restore size failed\");\n\t\t\t\treturn (ARCHIVE_FATAL);\n\t\t\t}\n\t\t\ta->pst = NULL;\n\t\t}\n\t}\n\n\t\/* Restore metadata. *\/\n\n\t\/*\n\t * This is specific to Mac OS X.\n\t * If the current file is an AppleDouble file, it should be\n\t * linked with the data fork file and remove it.\n\t *\/\n\tif (a->todo & TODO_APPLEDOUBLE) {\n\t\tint r2 = fixup_appledouble(a, a->name);\n\t\tif (r2 == ARCHIVE_EOF) {\n\t\t\t\/* The current file has been successfully linked\n\t\t\t * with the data fork file and removed. So there\n\t\t\t * is nothing to do on the current file.  *\/\n\t\t\tgoto finish_metadata;\n\t\t}\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * Look up the \"real\" UID only if we're going to need it.\n\t * TODO: the TODO_SGID condition can be dropped here, can't it?\n\t *\/\n\tif (a->todo & (TODO_OWNER | TODO_SUID | TODO_SGID)) {\n\t\ta->uid = archive_write_disk_uid(&a->archive,\n\t\t    archive_entry_uname(a->entry),\n\t\t    archive_entry_uid(a->entry));\n\t}\n\t\/* Look up the \"real\" GID only if we're going to need it. *\/\n\t\/* TODO: the TODO_SUID condition can be dropped here, can't it? *\/\n\tif (a->todo & (TODO_OWNER | TODO_SGID | TODO_SUID)) {\n\t\ta->gid = archive_write_disk_gid(&a->archive,\n\t\t    archive_entry_gname(a->entry),\n\t\t    archive_entry_gid(a->entry));\n\t }\n\n\t\/*\n\t * Restore ownership before set_mode tries to restore suid\/sgid\n\t * bits.  If we set the owner, we know what it is and can skip\n\t * a stat() call to examine the ownership of the file on disk.\n\t *\/\n\tif (a->todo & TODO_OWNER) {\n\t\tint r2 = set_ownership(a);\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * HYPOTHESIS:\n\t * If we're not root, we won't be setting any security\n\t * attributes that may be wiped by the set_mode() routine\n\t * below.  We also can't set xattr on non-owner-writable files,\n\t * which may be the state after set_mode(). Perform\n\t * set_xattrs() first based on these constraints.\n\t *\/\n\tif (a->user_uid != 0 &&\n\t    (a->todo & TODO_XATTR)) {\n\t\tint r2 = set_xattrs(a);\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * set_mode must precede ACLs on systems such as Solaris and\n\t * FreeBSD where setting the mode implicitly clears extended ACLs\n\t *\/\n\tif (a->todo & TODO_MODE) {\n\t\tint r2 = set_mode(a, a->mode);\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * Security-related extended attributes (such as\n\t * security.capability on Linux) have to be restored last,\n\t * since they're implicitly removed by other file changes.\n\t * We do this last only when root.\n\t *\/\n\tif (a->user_uid == 0 &&\n\t    (a->todo & TODO_XATTR)) {\n\t\tint r2 = set_xattrs(a);\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * Some flags prevent file modification; they must be restored after\n\t * file contents are written.\n\t *\/\n\tif (a->todo & TODO_FFLAGS) {\n\t\tint r2 = set_fflags(a);\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * Time must follow most other metadata;\n\t * otherwise atime will get changed.\n\t *\/\n\tif (a->todo & TODO_TIMES) {\n\t\tint r2 = set_times_from_entry(a);\n\t\tif (r2 < ret) ret = r2;\n\t}\n\n\t\/*\n\t * Mac extended metadata includes ACLs.\n\t *\/\n\tif (a->todo & TODO_MAC_METADATA) {\n\t\tconst void *metadata;\n\t\tsize_t metadata_size;\n\t\tmetadata = archive_entry_mac_metadata(a->entry, &metadata_size);\n\t\tif (metadata != NULL && metadata_size > 0) {\n\t\t\tint r2 = set_mac_metadata(a, archive_entry_pathname(\n\t\t\t    a->entry), metadata, metadata_size);\n\t\t\tif (r2 < ret) ret = r2;\n\t\t}\n\t}\n\n\t\/*\n\t * ACLs must be restored after timestamps because there are\n\t * ACLs that prevent attribute changes (including time).\n\t *\/\n\tif (a->todo & TODO_ACLS) {\n\t\tint r2;\n\t\tr2 = archive_write_disk_set_acls(&a->archive, a->fd,\n\t\t    archive_entry_pathname(a->entry),\n\t\t    archive_entry_acl(a->entry),\n\t\t    archive_entry_mode(a->entry));\n\t\tif (r2 < ret) ret = r2;\n\t}\n\nfinish_metadata:\n\t\/* If there's an fd, we can close it now. *\/\n\tif (a->fd >= 0) {\n\t\tclose(a->fd);\n\t\ta->fd = -1;\n\t\tif (a->tmpname) {\n\t\t\tif (rename(a->tmpname, a->name) == -1) {\n\t\t\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t    \"Failed to rename temporary file\");\n\t\t\t\tret = ARCHIVE_FAILED;\n\t\t\t\tunlink(a->tmpname);\n\t\t\t}\n\t\t\ta->tmpname = NULL;\n\t\t}\n\t}\n\t\/* If there's an entry, we can release it now. *\/\n\tarchive_entry_free(a->entry);\n\ta->entry = NULL;\n\ta->archive.state = ARCHIVE_STATE_HEADER;\n\treturn (ret);\n}","target":0,"code_token_length":1877,"total_token_length":2113,"max_tokens_setting":4096}
+{"idx":207461,"func":"at_bitmap input_bmp_reader(gchar * filename, at_input_opts_type * opts, at_msg_func msg_func, gpointer msg_data, gpointer user_data)\n{\n  FILE *fd;\n  unsigned char buffer[64];\n  int ColormapSize, rowbytes, Maps;\n  gboolean Grey = FALSE;\n  unsigned char ColorMap[256][3];\n  at_bitmap image = at_bitmap_init(0, 0, 0, 1);\n  unsigned char *image_storage;\n  at_exception_type exp = at_exception_new(msg_func, msg_data);\n  char magick[2];\n  Bitmap_Channel masks[4];\n\n  fd = fopen(filename, \"rb\");\n\n  if (!fd) {\n    LOG(\"Can't open \\\"%s\\\"\\n\", filename);\n    at_exception_fatal(&exp, \"bmp: cannot open input file\");\n    goto cleanup;\n  }\n\n  \/* It is a File. Now is it a Bitmap? Read the shortest possible header. *\/\n\n  if (!ReadOK(fd, magick, 2) ||\n\t  !(!strncmp(magick, \"BA\", 2) ||\n\t\t  !strncmp(magick, \"BM\", 2) ||\n\t\t  !strncmp(magick, \"IC\", 2) ||\n\t\t  !strncmp(magick, \"PT\", 2) ||\n\t\t  !strncmp(magick, \"CI\", 2) ||\n\t\t  !strncmp(magick, \"CP\", 2)))\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  while (!strncmp(magick, \"BA\", 2))\n  {\n\t  if (!ReadOK(fd, buffer, 12))\n\t  {\n\t\t  LOG(\"%s is not a valid BMP file\", filename);\n\t\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t\t  goto cleanup;\n\t  }\n\n\t  if (!ReadOK(fd, magick, 2))\n\t  {\n\t\t  LOG(\"%s is not a valid BMP file\", filename);\n\t\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t\t  goto cleanup;\n\t  }\n  }\n\n  if (!ReadOK(fd, buffer, 12))\/\/\/\/\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  \/* bring them to the right byteorder. Not too nice, but it should work *\/\n\n  Bitmap_File_Head.bfSize = ToL(&buffer[0x00]);\n  Bitmap_File_Head.zzHotX = ToS(&buffer[0x04]);\n  Bitmap_File_Head.zzHotY = ToS(&buffer[0x06]);\n  Bitmap_File_Head.bfOffs = ToL(&buffer[0x08]);\n\n  if (!ReadOK(fd, buffer, 4))\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  Bitmap_File_Head.biSize = ToL(&buffer[0x00]);\n\n  \/* What kind of bitmap is it? *\/\n\n  if (Bitmap_File_Head.biSize == 12) {  \/* OS\/2 1.x ? *\/\n    if (!ReadOK(fd, buffer, 8)) {\n      LOG(\"Error reading BMP file header\\n\");\n      at_exception_fatal(&exp, \"Error reading BMP file header\");\n      goto cleanup;\n    }\n\n    Bitmap_Head.biWidth = ToS(&buffer[0x00]); \/* 12 *\/\n    Bitmap_Head.biHeight = ToS(&buffer[0x02]);  \/* 14 *\/\n    Bitmap_Head.biPlanes = ToS(&buffer[0x04]);  \/* 16 *\/\n    Bitmap_Head.biBitCnt = ToS(&buffer[0x06]);  \/* 18 *\/\n    Bitmap_Head.biCompr = 0;\n    Bitmap_Head.biSizeIm = 0;\n    Bitmap_Head.biXPels = Bitmap_Head.biYPels = 0;\n    Bitmap_Head.biClrUsed = 0;\n    Bitmap_Head.biClrImp = 0;\n    Bitmap_Head.masks[0] = 0;\n    Bitmap_Head.masks[1] = 0;\n    Bitmap_Head.masks[2] = 0;\n    Bitmap_Head.masks[3] = 0;\n\n    memset(masks, 0, sizeof(masks));\n    Maps = 3;\n\n  } else if (Bitmap_File_Head.biSize == 40) { \/* Windows 3.x *\/\n    if (!ReadOK(fd, buffer, 36))\n    {\n      LOG (\"Error reading BMP file header\\n\");\n      at_exception_fatal(&exp, \"Error reading BMP file header\");\n      goto cleanup;\n    }\n          \n\n    Bitmap_Head.biWidth = ToL(&buffer[0x00]); \/* 12 *\/\n    Bitmap_Head.biHeight = ToL(&buffer[0x04]);  \/* 16 *\/\n    Bitmap_Head.biPlanes = ToS(&buffer[0x08]);  \/* 1A *\/\n    Bitmap_Head.biBitCnt = ToS(&buffer[0x0A]);  \/* 1C *\/\n    Bitmap_Head.biCompr = ToL(&buffer[0x0C]); \/* 1E *\/\n    Bitmap_Head.biSizeIm = ToL(&buffer[0x10]);  \/* 22 *\/\n    Bitmap_Head.biXPels = ToL(&buffer[0x14]); \/* 26 *\/\n    Bitmap_Head.biYPels = ToL(&buffer[0x18]); \/* 2A *\/\n    Bitmap_Head.biClrUsed = ToL(&buffer[0x1C]); \/* 2E *\/\n    Bitmap_Head.biClrImp = ToL(&buffer[0x20]);  \/* 32 *\/\n    Bitmap_Head.masks[0] = 0;\n    Bitmap_Head.masks[1] = 0;\n    Bitmap_Head.masks[2] = 0;\n    Bitmap_Head.masks[3] = 0;\n\n    Maps = 4;\n    memset(masks, 0, sizeof(masks));\n\n    if (Bitmap_Head.biCompr == BI_BITFIELDS)\n      {\n\tif (!ReadOK(fd, buffer, 3 * sizeof(unsigned long)))\n\t  {\n\t    LOG(\"Error reading BMP file header\\n\");\n\t    at_exception_fatal(&exp, \"Error reading BMP file header\");\n\t    goto cleanup;\n\t  }\n\n\tBitmap_Head.masks[0] = ToL(&buffer[0x00]);\n\tBitmap_Head.masks[1] = ToL(&buffer[0x04]);\n\tBitmap_Head.masks[2] = ToL(&buffer[0x08]);\n\n\tReadChannelMasks(&Bitmap_Head.masks[0], masks, 3);\n      }\n    else if (Bitmap_Head.biCompr == BI_RGB)\n      {\n\tsetMasksDefault(Bitmap_Head.biBitCnt, masks);\n      }\n    else if ((Bitmap_Head.biCompr != BI_RLE4) &&\n\t     (Bitmap_Head.biCompr != BI_RLE8))\n      {\n\t\/* BI_ALPHABITFIELDS, etc. *\/\n\tLOG(\"Unsupported compression in BMP file\\n\");\n\tat_exception_fatal(&exp, \"Unsupported compression in BMP file\");\n\tgoto cleanup;\n      }\n  }\n  else if (Bitmap_File_Head.biSize >= 56 &&\n\t   Bitmap_File_Head.biSize <= 64)\n  {\n    \/* enhanced Windows format with bit masks *\/\n\n    if (!ReadOK (fd, buffer, Bitmap_File_Head.biSize - 4))\n    {\n\n      LOG(\"Error reading BMP file header\\n\");\n      at_exception_fatal(&exp, \"Error reading BMP file header\");\n      goto cleanup;\n    }\n\n    Bitmap_Head.biWidth = ToL(&buffer[0x00]); \/* 12 *\/\n    Bitmap_Head.biHeight = ToL(&buffer[0x04]);  \/* 16 *\/\n    Bitmap_Head.biPlanes = ToS(&buffer[0x08]);  \/* 1A *\/\n    Bitmap_Head.biBitCnt = ToS(&buffer[0x0A]);  \/* 1C *\/\n    Bitmap_Head.biCompr = ToL(&buffer[0x0C]); \/* 1E *\/\n    Bitmap_Head.biSizeIm = ToL(&buffer[0x10]);  \/* 22 *\/\n    Bitmap_Head.biXPels = ToL(&buffer[0x14]); \/* 26 *\/\n    Bitmap_Head.biYPels = ToL(&buffer[0x18]); \/* 2A *\/\n    Bitmap_Head.biClrUsed = ToL(&buffer[0x1C]); \/* 2E *\/\n    Bitmap_Head.biClrImp = ToL(&buffer[0x20]);  \/* 32 *\/\n    Bitmap_Head.masks[0] = ToL(&buffer[0x24]);       \/* 36 *\/\n    Bitmap_Head.masks[1] = ToL(&buffer[0x28]);       \/* 3A *\/\n    Bitmap_Head.masks[2] = ToL(&buffer[0x2C]);       \/* 3E *\/\n    Bitmap_Head.masks[3] = ToL(&buffer[0x30]);       \/* 42 *\/\n\n    Maps = 4;\n    ReadChannelMasks(&Bitmap_Head.masks[0], masks, 4);\n  }\n  else if (Bitmap_File_Head.biSize == 108 ||\n           Bitmap_File_Head.biSize == 124)\n  {\n    \/* BMP Version 4 or 5 *\/\n\n    if (!ReadOK(fd, buffer, Bitmap_File_Head.biSize - 4))\n    {\n\t    LOG(\"Error reading BMP file header\\n\");\n\t    at_exception_fatal(&exp, \"Error reading BMP file header\");\n\t    goto cleanup;\n    }\n\n    Bitmap_Head.biWidth = ToL(&buffer[0x00]);\n    Bitmap_Head.biHeight = ToL(&buffer[0x04]);\n    Bitmap_Head.biPlanes = ToS(&buffer[0x08]);\n    Bitmap_Head.biBitCnt = ToS(&buffer[0x0A]);\n    Bitmap_Head.biCompr = ToL(&buffer[0x0C]);\n    Bitmap_Head.biSizeIm = ToL(&buffer[0x10]);\n    Bitmap_Head.biXPels = ToL(&buffer[0x14]);\n    Bitmap_Head.biYPels = ToL(&buffer[0x18]);\n    Bitmap_Head.biClrUsed = ToL(&buffer[0x1C]);\n    Bitmap_Head.biClrImp = ToL(&buffer[0x20]);\n    Bitmap_Head.masks[0] = ToL(&buffer[0x24]);\n    Bitmap_Head.masks[1] = ToL(&buffer[0x28]);\n    Bitmap_Head.masks[2] = ToL(&buffer[0x2C]);\n    Bitmap_Head.masks[3] = ToL(&buffer[0x30]);\n\n    Maps = 4;\n\n    if (Bitmap_Head.biCompr == BI_BITFIELDS)\n    {\n\t    ReadChannelMasks(&Bitmap_Head.masks[0], masks, 4);\n    }\n    else if (Bitmap_Head.biCompr == BI_RGB)\n    {\n\t    setMasksDefault(Bitmap_Head.biBitCnt, masks);\n    }\n  } else {\n    LOG(\"Error reading BMP file header\\n\");\n    at_exception_fatal(&exp, \"Error reading BMP file header\");\n    goto cleanup;\n  }\n\n  \/* Valid options 1, 4, 8, 16, 24, 32 *\/\n  \/* 16 is awful, we should probably shoot whoever invented it *\/\n\n  switch (Bitmap_Head.biBitCnt)\n  {\n  case 1:\n  case 2:\n  case 4:\n  case 8:\n  case 16:\n  case 24:\n  case 32:\n\t  break;\n  default:\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  \/* There should be some colors used! *\/\n\n  ColormapSize = (Bitmap_File_Head.bfOffs - Bitmap_File_Head.biSize - 14) \/ Maps;\n\n  if ((Bitmap_Head.biClrUsed == 0) &&\n      (Bitmap_Head.biBitCnt <= 8))\n  {\n\t  ColormapSize = Bitmap_Head.biClrUsed = 1 << Bitmap_Head.biBitCnt;\n  }\n\n  if (ColormapSize > 256)\n    ColormapSize = 256;\n\n  \/* Sanity checks *\/\n\n  if (Bitmap_Head.biHeight == 0 ||\n\t  Bitmap_Head.biWidth == 0)\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  \/* biHeight may be negative, but -2147483648 is dangerous because:\n\t -2147483648 == -(-2147483648) *\/\n  if (Bitmap_Head.biWidth < 0 ||\n\t  Bitmap_Head.biHeight == -2147483648)\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  if (Bitmap_Head.biPlanes != 1)\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  if (Bitmap_Head.biClrUsed > 256 &&\n\t  Bitmap_Head.biBitCnt <= 8)\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  \/* protect against integer overflows caused by malicious BMPs *\/\n  \/* use divisions in comparisons to avoid type overflows *\/\n\n  if (((unsigned long)Bitmap_Head.biWidth) > (unsigned int)0x7fffffff \/ Bitmap_Head.biBitCnt ||\n\t  ((unsigned long)Bitmap_Head.biWidth) > ((unsigned int)0x7fffffff \/abs(Bitmap_Head.biHeight)) \/ 4)\n  {\n\t  LOG(\"%s is not a valid BMP file\", filename);\n\t  at_exception_fatal(&exp, \"bmp: invalid input file\");\n\t  goto cleanup;\n  }\n\n  \/* Windows and OS\/2 declare filler so that rows are a multiple of\n   * word length (32 bits == 4 bytes)\n   *\/\n   \n  unsigned long overflowTest = Bitmap_Head.biWidth * Bitmap_Head.biBitCnt;\n  if (overflowTest \/ Bitmap_Head.biWidth != Bitmap_Head.biBitCnt) {\n    LOG(\"Error reading BMP file header. Width is too large\\n\");\n    at_exception_fatal(&exp, \"Error reading BMP file header. Width is too large\");\n    goto cleanup;\n  }\n\n  rowbytes = ((Bitmap_Head.biWidth * Bitmap_Head.biBitCnt - 1) \/ 32) * 4 + 4;\n\n#ifdef DEBUG\n  printf(\"\\nSize: %u, Colors: %u, Bits: %u, Width: %u, Height: %u, Comp: %u, Zeile: %u\\n\", Bitmap_File_Head.bfSize, Bitmap_Head.biClrUsed, Bitmap_Head.biBitCnt, Bitmap_Head.biWidth, Bitmap_Head.biHeight, Bitmap_Head.biCompr, rowbytes);\n#endif\n\n\n  if (Bitmap_Head.biBitCnt <= 8)\n  {\n#ifdef DEBUG\n    printf(\"Colormap read\\n\");\n#endif\n\t  \/* Get the Colormap *\/\n\t  if (!ReadColorMap(fd, ColorMap, ColormapSize, Maps, &Grey, &exp))\n\t\t  goto cleanup;\n  }\n\n  fseek(fd, Bitmap_File_Head.bfOffs, SEEK_SET);\n\n  \/* Get the Image and return the ID or -1 on error *\/\n  image_storage = ReadImage(fd, \n\tBitmap_Head.biWidth, Bitmap_Head.biHeight,\n\tColorMap,\n        Bitmap_Head.biClrUsed,\n\tBitmap_Head.biBitCnt, Bitmap_Head.biCompr, rowbytes,\n        Grey,\n\tmasks,\n\t&exp);\n\n  image = at_bitmap_init(image_storage, (unsigned short)Bitmap_Head.biWidth, (unsigned short)Bitmap_Head.biHeight, Grey ? 1 : 3);\ncleanup:\n  fclose(fd);\n  return (image);\n}","target":1,"code_token_length":3564,"total_token_length":3800,"max_tokens_setting":4096}
+{"idx":206043,"func":"load_image (const gchar  *filename,\n            GError      **error)\n{\n  gchar             *name;\n  gint               fd;\n  BrushHeader        bh;\n  guchar            *brush_buf = NULL;\n  gint32             image_ID;\n  gint32             layer_ID;\n  GimpParasite      *parasite;\n  GimpDrawable      *drawable;\n  GimpPixelRgn       pixel_rgn;\n  gint               bn_size;\n  GimpImageBaseType  base_type;\n  GimpImageType      image_type;\n  gsize              size;\n\n  fd = g_open (filename, O_RDONLY | _O_BINARY, 0);\n\n  if (fd == -1)\n    {\n      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),\n                   _(\"Could not open '%s' for reading: %s\"),\n                   gimp_filename_to_utf8 (filename), g_strerror (errno));\n      return -1;\n    }\n\n  gimp_progress_init_printf (_(\"Opening '%s'\"),\n                             gimp_filename_to_utf8 (filename));\n\n  if (read (fd, &bh, sizeof (BrushHeader)) != sizeof (BrushHeader))\n    {\n      close (fd);\n      return -1;\n    }\n\n  \/*  rearrange the bytes in each unsigned int  *\/\n  bh.header_size  = g_ntohl (bh.header_size);\n  bh.version      = g_ntohl (bh.version);\n  bh.width        = g_ntohl (bh.width);\n  bh.height       = g_ntohl (bh.height);\n  bh.bytes        = g_ntohl (bh.bytes);\n  bh.magic_number = g_ntohl (bh.magic_number);\n  bh.spacing      = g_ntohl (bh.spacing);\n\n  \/* Sanitize values *\/\n  if ((bh.width == 0) || (bh.width > GIMP_MAX_IMAGE_SIZE) ||\n      (bh.height == 0) || (bh.height > GIMP_MAX_IMAGE_SIZE) ||\n      ((bh.bytes != 1) && (bh.bytes != 2) && (bh.bytes != 4) &&\n       (bh.bytes != 18)) ||\n      (G_MAXSIZE \/ bh.width \/ bh.height \/ bh.bytes < 1))\n    {\n      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,\n                   _(\"Invalid header data in '%s': width=%lu, height=%lu, \"\n                     \"bytes=%lu\"), gimp_filename_to_utf8 (filename),\n                   (unsigned long int)bh.width, (unsigned long int)bh.height,\n                   (unsigned long int)bh.bytes);\n      return -1;\n    }\n\n  switch (bh.version)\n    {\n    case 1:\n      \/* Version 1 didn't have a magic number and had no spacing  *\/\n      bh.spacing = 25;\n      \/* And we need to rewind the handle, 4 due spacing and 4 due magic *\/\n      lseek (fd, -8, SEEK_CUR);\n      bh.header_size += 8;\n      break;\n\n    case 3: \/*  cinepaint brush  *\/\n      if (bh.bytes == 18 \/* FLOAT16_GRAY_GIMAGE *\/)\n        {\n          bh.bytes = 2;\n        }\n      else\n        {\n          g_message (_(\"Unsupported brush format\"));\n          close (fd);\n          return -1;\n        }\n      \/*  fallthrough  *\/\n\n    case 2:\n      if (bh.magic_number == GBRUSH_MAGIC &&\n          bh.header_size  >  sizeof (BrushHeader))\n        break;\n\n    default:\n      g_message (_(\"Unsupported brush format\"));\n      close (fd);\n      return -1;\n    }\n\n  if ((bn_size = (bh.header_size - sizeof (BrushHeader))) > 0)\n    {\n      gchar *temp = g_new (gchar, bn_size);\n\n      if ((read (fd, temp, bn_size)) < bn_size)\n        {\n          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,\n                       _(\"Error in GIMP brush file '%s'\"),\n                       gimp_filename_to_utf8 (filename));\n          close (fd);\n          g_free (temp);\n          return -1;\n        }\n\n      name = gimp_any_to_utf8 (temp, -1,\n                               _(\"Invalid UTF-8 string in brush file '%s'.\"),\n                               gimp_filename_to_utf8 (filename));\n      g_free (temp);\n    }\n  else\n    {\n      name = g_strdup (_(\"Unnamed\"));\n    }\n\n  \/* Now there's just raw data left. *\/\n\n  size = bh.width * bh.height * bh.bytes;\n  brush_buf = g_malloc (size);\n\n  if (read (fd, brush_buf, size) != size)\n    {\n      close (fd);\n      g_free (brush_buf);\n      g_free (name);\n      return -1;\n    }\n\n  switch (bh.bytes)\n    {\n    case 1:\n      {\n        PatternHeader ph;\n\n        \/*  For backwards-compatibility, check if a pattern follows.\n            The obsolete .gpb format did it this way.  *\/\n\n        if (read (fd, &ph, sizeof (PatternHeader)) == sizeof(PatternHeader))\n          {\n            \/*  rearrange the bytes in each unsigned int  *\/\n            ph.header_size  = g_ntohl (ph.header_size);\n            ph.version      = g_ntohl (ph.version);\n            ph.width        = g_ntohl (ph.width);\n            ph.height       = g_ntohl (ph.height);\n            ph.bytes        = g_ntohl (ph.bytes);\n            ph.magic_number = g_ntohl (ph.magic_number);\n\n            if (ph.magic_number == GPATTERN_MAGIC        &&\n                ph.version      == 1                     &&\n                ph.header_size  > sizeof (PatternHeader) &&\n                ph.bytes        == 3                     &&\n                ph.width        == bh.width              &&\n                ph.height       == bh.height             &&\n                lseek (fd, ph.header_size - sizeof (PatternHeader),\n                       SEEK_CUR) > 0)\n              {\n                guchar *plain_brush = brush_buf;\n                gint    i;\n\n                bh.bytes = 4;\n                brush_buf = g_malloc (4 * bh.width * bh.height);\n\n                for (i = 0; i < ph.width * ph.height; i++)\n                  {\n                    if (read (fd, brush_buf + i * 4, 3) != 3)\n                      {\n                        close (fd);\n                        g_free (name);\n                        g_free (plain_brush);\n                        g_free (brush_buf);\n                        return -1;\n                      }\n                    brush_buf[i * 4 + 3] = plain_brush[i];\n                  }\n                g_free (plain_brush);\n              }\n          }\n      }\n      break;\n\n    case 2:\n      {\n        guint16 *buf = (guint16 *) brush_buf;\n        gint     i;\n\n        for (i = 0; i < bh.width * bh.height; i++, buf++)\n          {\n            union\n            {\n              guint16 u[2];\n              gfloat  f;\n            } short_float;\n\n#if G_BYTE_ORDER == G_LITTLE_ENDIAN\n            short_float.u[0] = 0;\n            short_float.u[1] = GUINT16_FROM_BE (*buf);\n#else\n            short_float.u[0] = GUINT16_FROM_BE (*buf);\n            short_float.u[1] = 0;\n#endif\n\n            brush_buf[i] = (guchar) (short_float.f * 255.0 + 0.5);\n          }\n\n        bh.bytes = 1;\n      }\n      break;\n\n    default:\n      break;\n    }\n\n  \/*\n   * Create a new image of the proper size and\n   * associate the filename with it.\n   *\/\n\n  switch (bh.bytes)\n    {\n    case 1:\n      base_type = GIMP_GRAY;\n      image_type = GIMP_GRAY_IMAGE;\n      break;\n\n    case 4:\n      base_type = GIMP_RGB;\n      image_type = GIMP_RGBA_IMAGE;\n      break;\n\n    default:\n      g_message (\"Unsupported brush depth: %d\\n\"\n                 \"GIMP Brushes must be GRAY or RGBA\\n\",\n                 bh.bytes);\n      g_free (name);\n      return -1;\n    }\n\n  image_ID = gimp_image_new (bh.width, bh.height, base_type);\n  gimp_image_set_filename (image_ID, filename);\n\n  parasite = gimp_parasite_new (\"gimp-brush-name\",\n                                GIMP_PARASITE_PERSISTENT,\n                                strlen (name) + 1, name);\n  gimp_image_attach_parasite (image_ID, parasite);\n  gimp_parasite_free (parasite);\n\n  layer_ID = gimp_layer_new (image_ID, name, bh.width, bh.height,\n                             image_type, 100, GIMP_NORMAL_MODE);\n  gimp_image_insert_layer (image_ID, layer_ID, -1, 0);\n\n  g_free (name);\n\n  drawable = gimp_drawable_get (layer_ID);\n  gimp_pixel_rgn_init (&pixel_rgn, drawable,\n                       0, 0, drawable->width, drawable->height,\n                       TRUE, FALSE);\n\n  gimp_pixel_rgn_set_rect (&pixel_rgn, brush_buf,\n                           0, 0, bh.width, bh.height);\n  g_free (brush_buf);\n\n  if (image_type == GIMP_GRAY_IMAGE)\n    gimp_invert (layer_ID);\n\n  close (fd);\n\n  gimp_drawable_flush (drawable);\n  gimp_progress_update (1.0);\n\n  return image_ID;\n}","target":1,"code_token_length":2004,"total_token_length":2240,"max_tokens_setting":4096}
+{"idx":197242,"func":"TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n  const auto* params = reinterpret_cast<TfLiteSVDFParams*>(node->builtin_data);\n  OpData* op_data = reinterpret_cast<OpData*>(node->user_data);\n  int scratch_tensor_index = op_data->scratch_tensor_index;\n\n  \/\/ Check we have all the inputs and outputs we need.\n  TF_LITE_ENSURE_EQ(context, node->outputs->size, 1);\n  TF_LITE_ENSURE_EQ(context, node->inputs->size, 5);\n\n  const TfLiteTensor* input;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n  const TfLiteTensor* weights_feature;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kWeightsFeatureTensor,\n                                          &weights_feature));\n  const TfLiteTensor* weights_time;\n  TF_LITE_ENSURE_OK(\n      context, GetInputSafe(context, node, kWeightsTimeTensor, &weights_time));\n\n  TF_LITE_ENSURE(context,\n                 input->type == kTfLiteFloat32 || input->type == kTfLiteInt8);\n\n  \/\/ Check all the parameters of tensor match within themselves and match the\n  \/\/ input configuration.\n  const int rank = params->rank;\n  const int batch_size = input->dims->data[0];\n  const int num_filters = weights_feature->dims->data[0];\n  TF_LITE_ENSURE(context, rank != 0);\n  TF_LITE_ENSURE_EQ(context, num_filters % rank, 0);\n  const int num_units = num_filters \/ rank;\n  const int memory_size = weights_time->dims->data[1];\n  TF_LITE_ENSURE_EQ(context, input->dims->data[1],\n                    weights_feature->dims->data[1]);\n  TF_LITE_ENSURE_EQ(context, weights_time->dims->data[0], num_filters);\n\n  const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);\n  if (bias) {\n    TF_LITE_ENSURE_EQ(context, bias->dims->data[0], num_units);\n  }\n\n  const TfLiteTensor* state;\n  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kStateTensor, &state));\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context,\n                    GetOutputSafe(context, node, kOutputTensor, &output));\n\n  \/\/ Check the shape of input state tensors.\n  TF_LITE_ENSURE_EQ(context, NumDimensions(state), 2);\n  TF_LITE_ENSURE_EQ(context, SizeOfDimension(state, 0), batch_size);\n  TF_LITE_ENSURE_EQ(context, SizeOfDimension(state, 1),\n                    memory_size * num_filters);\n\n  \/\/ Resize output.\n  TfLiteIntArray* output_size_array = TfLiteIntArrayCreate(2);\n  output_size_array->data[0] = batch_size;\n  output_size_array->data[1] = num_units;\n  TF_LITE_ENSURE_OK(context,\n                    context->ResizeTensor(context, output, output_size_array));\n\n  \/\/ The weights are of consistent type, so it suffices to check one.\n  const bool is_hybrid_op = IsHybridOp(input, weights_feature);\n  const bool is_full_integer = input->type == kTfLiteInt8;\n\n  \/\/ Resize scratch.\n  TfLiteIntArrayFree(node->temporaries);\n  if (is_hybrid_op) {\n    node->temporaries = TfLiteIntArrayCreate(6);\n  } else if (is_full_integer) {\n    node->temporaries = TfLiteIntArrayCreate(2);\n  } else {\n    node->temporaries = TfLiteIntArrayCreate(1);\n  }\n  node->temporaries->data[0] = scratch_tensor_index;\n\n  TfLiteIntArray* scratch_size_array = TfLiteIntArrayCreate(2);\n  scratch_size_array->data[0] = batch_size;\n  scratch_size_array->data[1] = num_filters;\n\n  TfLiteTensor* scratch_tensor;\n  TF_LITE_ENSURE_OK(\n      context, GetTemporarySafe(context, node, \/*index=*\/0, &scratch_tensor));\n\n  \/\/ The scratch buffer is of type int32 for full integer svdf and it's of type\n  \/\/ float32 for hybrid and float case.\n  if (is_full_integer) {\n    scratch_tensor->type = kTfLiteInt32;\n  } else {\n    scratch_tensor->type = kTfLiteFloat32;\n  }\n  scratch_tensor->allocation_type = kTfLiteArenaRw;\n  TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, scratch_tensor,\n                                                   scratch_size_array));\n\n  if (is_hybrid_op) {\n    op_data->compute_row_sums = true;\n    \/\/ Tell interpreter to allocate temporary tensors to store quantized values\n    \/\/ of input tensors.\n    node->temporaries->data[1] = scratch_tensor_index + 1;\n    TfLiteTensor* input_quantized;\n    TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/1,\n                                                &input_quantized));\n    input_quantized->type = weights_feature->type;\n    input_quantized->allocation_type = kTfLiteArenaRw;\n    if (!TfLiteIntArrayEqual(input_quantized->dims, input->dims)) {\n      TfLiteIntArray* input_quantized_size = TfLiteIntArrayCopy(input->dims);\n      TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, input_quantized,\n                                                       input_quantized_size));\n    }\n\n    \/\/ Tell interpreter to allocate temporary tensors to store scaling factors.\n    node->temporaries->data[2] = scratch_tensor_index + 2;\n    TfLiteTensor* scaling_factors;\n    TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/2,\n                                                &scaling_factors));\n    scaling_factors->type = kTfLiteFloat32;\n    scaling_factors->allocation_type = kTfLiteArenaRw;\n    int scaling_dims[1] = {batch_size};\n    if (!TfLiteIntArrayEqualsArray(scaling_factors->dims, 1, scaling_dims)) {\n      TfLiteIntArray* scaling_factors_size = TfLiteIntArrayCreate(1);\n      scaling_factors_size->data[0] = batch_size;\n      TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, scaling_factors,\n                                                       scaling_factors_size));\n    }\n\n    \/\/ Used to store dequantized weights_time matrix for hybrid computation of\n    \/\/ matmul(state, weights_time), which occurs in floating point.\n    node->temporaries->data[3] = scratch_tensor_index + 3;\n    TfLiteTensor* float_weights_time;\n    TF_LITE_ENSURE_OK(context, GetTemporarySafe(context, node, \/*index=*\/3,\n                                                &float_weights_time));\n    float_weights_time->type = kTfLiteFloat32;\n    \/\/ Persistent so that we can compute the dequantized weights only once.\n    float_weights_time->allocation_type = kTfLiteArenaRwPersistent;\n    if (!TfLiteIntArrayEqual(float_weights_time->dims, weights_time->dims)) {\n      TfLiteIntArray* float_weights_time_size =\n          TfLiteIntArrayCopy(weights_time->dims);\n      TF_LITE_ENSURE_OK(context,\n                        context->ResizeTensor(context, float_weights_time,\n                                              float_weights_time_size));\n    }\n\n    node->temporaries->data[4] = scratch_tensor_index + 4;\n    TfLiteTensor* zero_points;\n    TF_LITE_ENSURE_OK(\n        context, GetTemporarySafe(context, node, \/*index=*\/4, &zero_points));\n    zero_points->type = kTfLiteFloat32;\n    zero_points->allocation_type = kTfLiteArenaRw;\n    int zero_points_dims[1] = {batch_size};\n    if (!TfLiteIntArrayEqualsArray(zero_points->dims, 1, zero_points_dims)) {\n      TfLiteIntArray* zero_points_size = TfLiteIntArrayCreate(1);\n      zero_points_size->data[0] = zero_points_dims[0];\n      TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, zero_points,\n                                                       zero_points_size));\n    }\n\n    node->temporaries->data[5] = scratch_tensor_index + 5;\n    TfLiteTensor* row_sums;\n    TF_LITE_ENSURE_OK(context,\n                      GetTemporarySafe(context, node, \/*index=*\/5, &row_sums));\n    row_sums->type = kTfLiteFloat32;\n    row_sums->allocation_type = kTfLiteArenaRwPersistent;\n    int row_sums_dims[1] = {num_filters};\n    if (!TfLiteIntArrayEqualsArray(row_sums->dims, 1, row_sums_dims)) {\n      TfLiteIntArray* row_sums_size = TfLiteIntArrayCreate(1);\n      row_sums_size->data[0] = row_sums_dims[0];\n      TF_LITE_ENSURE_OK(\n          context, context->ResizeTensor(context, row_sums, row_sums_size));\n    }\n  }\n  if (is_full_integer) {\n    \/\/ Allocated one extra tensor.\n    TfLiteIntArray* output_temp_size_array = TfLiteIntArrayCreate(2);\n    output_temp_size_array->data[0] = num_units;\n    output_temp_size_array->data[1] = batch_size;\n    node->temporaries->data[1] = scratch_tensor_index + 1;\n    TfLiteTensor* output_temp;\n    TF_LITE_ENSURE_OK(\n        context, GetTemporarySafe(context, node, \/*index=*\/1, &output_temp));\n    output_temp->type = kTfLiteInt32;\n    output_temp->allocation_type = kTfLiteArenaRw;\n    TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, output_temp,\n                                                     output_temp_size_array));\n\n    \/\/ Calculate effective scales.\n    auto* input_params =\n        reinterpret_cast<TfLiteAffineQuantization*>(input->quantization.params);\n    auto* weights_feature_params = reinterpret_cast<TfLiteAffineQuantization*>(\n        weights_feature->quantization.params);\n    auto* state_params =\n        reinterpret_cast<TfLiteAffineQuantization*>(state->quantization.params);\n    auto* weight_time_params = reinterpret_cast<TfLiteAffineQuantization*>(\n        weights_time->quantization.params);\n    auto* output_params = reinterpret_cast<TfLiteAffineQuantization*>(\n        output->quantization.params);\n    const double effective_scale_1 = input_params->scale->data[0] *\n                                     weights_feature_params->scale->data[0] \/\n                                     state_params->scale->data[0];\n    const double effective_scale_2 = state_params->scale->data[0] *\n                                     weight_time_params->scale->data[0] \/\n                                     output_params->scale->data[0];\n    QuantizeMultiplier(effective_scale_1, &op_data->effective_scale_1_a,\n                       &op_data->effective_scale_1_b);\n    QuantizeMultiplier(effective_scale_2, &op_data->effective_scale_2_a,\n                       &op_data->effective_scale_2_b);\n  }\n  return kTfLiteOk;\n}","target":1,"code_token_length":2361,"total_token_length":2597,"max_tokens_setting":4096}
+{"idx":451884,"func":"static int jpc_enc_encodemainbody(jpc_enc_t *enc)\n{\n\tint tileno;\n\tjpc_sot_t *sot;\n\tjpc_enc_tcmpt_t *comp;\n\tjpc_enc_tcmpt_t *endcomps;\n\tjpc_enc_band_t *band;\n\tjpc_enc_band_t *endbands;\n\tjpc_enc_rlvl_t *lvl;\n\tunsigned rlvlno;\n\tjpc_qcc_t *qcc;\n\tjpc_cod_t *cod;\n\tint adjust;\n\tint absbandno;\n\tlong tilehdrlen;\n\tlong tilelen;\n\tjpc_enc_tile_t *tile;\n\tjpc_enc_cp_t *cp;\n\tdouble rho;\n\tunsigned cmptno;\n\tint samestepsizes;\n\tjpc_enc_ccp_t *ccps;\n\tjpc_enc_tccp_t *tccp;\n\tint bandno;\n\tint mingbits;\n\tint actualnumbps;\n\tjpc_fix_t mxmag;\n\tjpc_fix_t mag;\n\tint numgbits;\n\n\tcp = enc->cp;\n\n\tfor (tileno = 0; tileno < JAS_CAST(int, cp->numtiles); ++tileno) {\n\t\tif (!(enc->curtile = jpc_enc_tile_create(enc->cp, enc->image,\n\t\t  tileno))) {\n\t\t\tjas_eprintf(\"cannot create tile\\n\");\n\t\t\treturn -1;\n\t\t}\n\n\t\ttile = enc->curtile;\n\n\t\tif (jas_getdbglevel() >= 10) {\n\t\t\tjpc_enc_dump(enc);\n\t\t}\n\n\t\tendcomps = &tile->tcmpts[tile->numtcmpts];\n\t\tfor (cmptno = 0, comp = tile->tcmpts; cmptno < tile->numtcmpts; ++cmptno, ++comp) {\n\t\t\tif (!cp->ccps[cmptno].sgnd) {\n\t\t\t\tadjust = 1 << (cp->ccps[cmptno].prec - 1);\n\t\t\t\tfor (jas_matind_t i = 0; i < jas_matrix_numrows(comp->data); ++i) {\n\t\t\t\t\tfor (jas_matind_t j = 0; j < jas_matrix_numcols(comp->data); ++j) {\n\t\t\t\t\t\t*jas_matrix_getref(comp->data, i, j) -= adjust;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!tile->intmode) {\n\t\t\t\tendcomps = &tile->tcmpts[tile->numtcmpts];\n\t\t\t\tfor (comp = tile->tcmpts; comp != endcomps; ++comp) {\n\t\t\t\t\tjas_matrix_asl(comp->data, JPC_FIX_FRACBITS);\n\t\t\t\t}\n\t\t}\n\n\t\tswitch (tile->mctid) {\n\t\tcase JPC_MCT_RCT:\nassert(jas_image_numcmpts(enc->image) == 3);\n\t\t\tjpc_rct(tile->tcmpts[0].data, tile->tcmpts[1].data,\n\t\t\t  tile->tcmpts[2].data);\n\t\t\tbreak;\n\t\tcase JPC_MCT_ICT:\nassert(jas_image_numcmpts(enc->image) == 3);\n\t\t\tjpc_ict(tile->tcmpts[0].data, tile->tcmpts[1].data,\n\t\t\t  tile->tcmpts[2].data);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (unsigned  i = 0; i < jas_image_numcmpts(enc->image); ++i) {\n\t\t\tcomp = &tile->tcmpts[i];\n\t\t\tjpc_tsfb_analyze(comp->tsfb, comp->data);\n\n\t\t}\n\n\n\t\tendcomps = &tile->tcmpts[tile->numtcmpts];\n\t\tfor (cmptno = 0, comp = tile->tcmpts; comp != endcomps; ++cmptno, ++comp) {\n\t\t\tmingbits = 0;\n\t\t\tabsbandno = 0;\n\t\t\t\/* All bands must have a corresponding quantizer step size,\n\t\t\t  even if they contain no samples and are never coded. *\/\n\t\t\t\/* Some bands may not be hit by the loop below, so we must\n\t\t\t  initialize all of the step sizes to a sane value. *\/\n\t\t\tmemset(comp->stepsizes, 0, sizeof(comp->stepsizes));\n\t\t\tfor (rlvlno = 0, lvl = comp->rlvls; rlvlno < comp->numrlvls; ++rlvlno, ++lvl) {\n\t\t\t\tif (!lvl->bands) {\n\t\t\t\t\tabsbandno += rlvlno ? 3 : 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tendbands = &lvl->bands[lvl->numbands];\n\t\t\t\tfor (band = lvl->bands; band != endbands; ++band) {\n\t\t\t\t\tif (!band->data) {\n\t\t\t\t\t\t++absbandno;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tactualnumbps = 0;\n\t\t\t\t\tmxmag = 0;\n\t\t\t\t\tfor (jas_matind_t y = 0; y < jas_matrix_numrows(band->data); ++y) {\n\t\t\t\t\t\tfor (jas_matind_t x = 0; x < jas_matrix_numcols(band->data); ++x) {\n\t\t\t\t\t\t\tmag = JAS_ABS(jas_matrix_get(band->data, y, x));\n\t\t\t\t\t\t\tif (mag > mxmag) {\n\t\t\t\t\t\t\t\tmxmag = mag;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (tile->intmode) {\n\t\t\t\t\t\tactualnumbps = jpc_fix_firstone(mxmag) + 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tactualnumbps = jpc_fix_firstone(mxmag) + 1 - JPC_FIX_FRACBITS;\n\t\t\t\t\t}\n\t\t\t\t\tnumgbits = actualnumbps - (cp->ccps[cmptno].prec - 1 +\n\t\t\t\t\t  band->analgain);\n#if 0\njas_eprintf(\"%d %d mag=%d actual=%d numgbits=%d\\n\", cp->ccps[cmptno].prec, band->analgain, mxmag, actualnumbps, numgbits);\n#endif\n\t\t\t\t\tif (numgbits > mingbits) {\n\t\t\t\t\t\tmingbits = numgbits;\n\t\t\t\t\t}\n\t\t\t\t\tif (!tile->intmode) {\n\t\t\t\t\t\tband->absstepsize = jpc_fix_div(jpc_inttofix(1\n\t\t\t\t\t\t  << (band->analgain + 1)),\n\t\t\t\t\t\t  band->synweight);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tband->absstepsize = jpc_inttofix(1);\n\t\t\t\t\t}\n\t\t\t\t\tconst uint_fast32_t stepsize = jpc_abstorelstepsize(\n\t\t\t\t\t  band->absstepsize, cp->ccps[cmptno].prec +\n\t\t\t\t\t  band->analgain);\n\t\t\t\t\tif (stepsize == UINT_FAST32_MAX)\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\tband->stepsize = stepsize;\n\t\t\t\t\tband->numbps = cp->tccp.numgbits +\n\t\t\t\t\t  JPC_QCX_GETEXPN(band->stepsize) - 1;\n\n\t\t\t\t\tif ((!tile->intmode) && band->data) {\n\t\t\t\t\t\tjpc_quantize(band->data, band->absstepsize);\n\t\t\t\t\t}\n\n\t\t\t\t\tcomp->stepsizes[absbandno] = band->stepsize;\n\t\t\t\t\t++absbandno;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tassert(JPC_FIX_FRACBITS >= JPC_NUMEXTRABITS);\n\t\t\tif (!tile->intmode) {\n\t\t\t\tjas_matrix_divpow2(comp->data, JPC_FIX_FRACBITS - JPC_NUMEXTRABITS);\n\t\t\t} else {\n\t\t\t\tjas_matrix_asl(comp->data, JPC_NUMEXTRABITS);\n\t\t\t}\n\n#if 0\njas_eprintf(\"mingbits %d\\n\", mingbits);\n#endif\n\t\t\tif (mingbits > cp->tccp.numgbits) {\n\t\t\t\tjas_eprintf(\"error: too few guard bits (need at least %d)\\n\",\n\t\t\t\t  mingbits);\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\n\t\tif (!(enc->tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tjas_eprintf(\"cannot open tmp file\\n\");\n\t\t\treturn -1;\n\t\t}\n\n\t\t\/* Write the tile header. *\/\n\t\tif (!(enc->mrk = jpc_ms_create(JPC_MS_SOT))) {\n\t\t\treturn -1;\n\t\t}\n\t\tsot = &enc->mrk->parms.sot;\n\t\tsot->len = 0;\n\t\tsot->tileno = tileno;\n\t\tsot->partno = 0;\n\t\tsot->numparts = 1;\n\t\tif (jpc_putms(enc->tmpstream, enc->cstate, enc->mrk)) {\n\t\t\tjas_eprintf(\"cannot write SOT marker\\n\");\n\t\t\treturn -1;\n\t\t}\n\t\tjpc_ms_destroy(enc->mrk);\n\t\tenc->mrk = 0;\n\n\/************************************************************************\/\n\/************************************************************************\/\n\/************************************************************************\/\n\n\t\ttccp = &cp->tccp;\n\t\tfor (cmptno = 0; cmptno < cp->numcmpts; ++cmptno) {\n\t\t\tcomp = &tile->tcmpts[cmptno];\n\t\t\tif (comp->numrlvls != tccp->maxrlvls) {\n\t\t\t\tif (!(enc->mrk = jpc_ms_create(JPC_MS_COD))) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\/* XXX = this is not really correct. we are using comp #0's precint sizes\nand other characteristics *\/\n\t\t\t\tcomp = &tile->tcmpts[0];\n\t\t\t\tcod = &enc->mrk->parms.cod;\n\t\t\t\tcod->compparms.csty = 0;\n\t\t\t\tcod->compparms.numdlvls = comp->numrlvls - 1;\n\t\t\t\tcod->prg = tile->prg;\n\t\t\t\tcod->numlyrs = tile->numlyrs;\n\t\t\t\tcod->compparms.cblkwidthval = JPC_COX_CBLKSIZEEXPN(comp->cblkwidthexpn);\n\t\t\t\tcod->compparms.cblkheightval = JPC_COX_CBLKSIZEEXPN(comp->cblkheightexpn);\n\t\t\t\tcod->compparms.cblksty = comp->cblksty;\n\t\t\t\tcod->compparms.qmfbid = comp->qmfbid;\n\t\t\t\tcod->mctrans = (tile->mctid != JPC_MCT_NONE);\n\t\t\t\tfor (unsigned i = 0; i < comp->numrlvls; ++i) {\n\t\t\t\t\tcod->compparms.rlvls[i].parwidthval = comp->rlvls[i].prcwidthexpn;\n\t\t\t\t\tcod->compparms.rlvls[i].parheightval = comp->rlvls[i].prcheightexpn;\n\t\t\t\t}\n\t\t\t\tif (jpc_putms(enc->tmpstream, enc->cstate, enc->mrk)) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tjpc_ms_destroy(enc->mrk);\n\t\t\t\tenc->mrk = 0;\n\t\t\t}\n\t\t}\n\n\t\tfor (cmptno = 0, comp = tile->tcmpts; cmptno < cp->numcmpts; ++cmptno, ++comp) {\n\t\t\tccps = &cp->ccps[cmptno];\n\t\t\tif (JAS_CAST(int, ccps->numstepsizes) == comp->numstepsizes) {\n\t\t\t\tsamestepsizes = 1;\n\t\t\t\tfor (bandno = 0; bandno < JAS_CAST(int, ccps->numstepsizes);\n\t\t\t\t  ++bandno) {\n\t\t\t\t\tif (ccps->stepsizes[bandno] != comp->stepsizes[bandno]) {\n\t\t\t\t\t\tsamestepsizes = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsamestepsizes = 0;\n\t\t\t}\n\t\t\tif (!samestepsizes) {\n\t\t\t\tif (!(enc->mrk = jpc_ms_create(JPC_MS_QCC))) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tqcc = &enc->mrk->parms.qcc;\n\t\t\t\tqcc->compno = cmptno;\n\t\t\t\tqcc->compparms.numguard = cp->tccp.numgbits;\n\t\t\t\tqcc->compparms.qntsty = (comp->qmfbid == JPC_COX_INS) ?\n\t\t\t\t  JPC_QCX_SEQNT : JPC_QCX_NOQNT;\n\t\t\t\tqcc->compparms.numstepsizes = comp->numstepsizes;\n\t\t\t\tqcc->compparms.stepsizes = comp->stepsizes;\n\t\t\t\tif (jpc_putms(enc->tmpstream, enc->cstate, enc->mrk)) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tqcc->compparms.stepsizes = 0;\n\t\t\t\tjpc_ms_destroy(enc->mrk);\n\t\t\t\tenc->mrk = 0;\n\t\t\t}\n\t\t}\n\n\t\t\/* Write a SOD marker to indicate the end of the tile header. *\/\n\t\tif (!(enc->mrk = jpc_ms_create(JPC_MS_SOD))) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (jpc_putms(enc->tmpstream, enc->cstate, enc->mrk)) {\n\t\t\tjas_eprintf(\"cannot write SOD marker\\n\");\n\t\t\treturn -1;\n\t\t}\n\t\tjpc_ms_destroy(enc->mrk);\n\t\tenc->mrk = 0;\n\t\ttilehdrlen = jas_stream_getrwcount(enc->tmpstream);\n\t\tassert(tilehdrlen >= 0);\n\n\/************************************************************************\/\n\/************************************************************************\/\n\/************************************************************************\/\n\n\t\tif (jpc_enc_enccblks(enc)) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tcp = enc->cp;\n\t\trho = (double) (tile->brx - tile->tlx) * (tile->bry - tile->tly) \/\n\t\t  ((cp->refgrdwidth - cp->imgareatlx) * (cp->refgrdheight -\n\t\t  cp->imgareatly));\n\t\ttile->rawsize = cp->rawsize * rho;\n\n\t\tfor (unsigned lyrno = 0; lyrno < tile->numlyrs - 1; ++lyrno) {\n\t\t\ttile->lyrsizes[lyrno] = tile->rawsize * jpc_fixtodbl(\n\t\t\t  cp->tcp.ilyrrates[lyrno]);\n\t\t}\n#if !defined(__clang__)\n\t\t\/\/ WARNING:\n\t\t\/\/ Some versions of Clang (e.g., 3.7.1 and 3.8.1) appear to generate\n\t\t\/\/ incorrect code for the following line.\n\t\ttile->lyrsizes[tile->numlyrs - 1] =\n\t\t  (cp->totalsize != UINT_FAST32_MAX) ?\n\t\t  (rho * enc->mainbodysize) : UINT_FAST32_MAX;\n#else\n\t\tif (cp->totalsize != UINT_FAST32_MAX) {\n\t\t\ttile->lyrsizes[tile->numlyrs - 1] = (rho * enc->mainbodysize);\n\t\t} else {\n\t\t\ttile->lyrsizes[tile->numlyrs - 1] = UINT_FAST32_MAX;\n\t\t}\n#endif\n\/\/jas_eprintf(\"TESTING %ld %ld\\n\", cp->totalsize != UINT_FAST32_MAX, tile->lyrsizes[0]);\n\t\tfor (unsigned lyrno = 0; lyrno < tile->numlyrs; ++lyrno) {\n\t\t\tif (tile->lyrsizes[lyrno] != UINT_FAST32_MAX) {\n\t\t\t\tif (JAS_CAST(uint_fast32_t, tilehdrlen) <= tile->lyrsizes[lyrno]) {\n\t\t\t\t\ttile->lyrsizes[lyrno] -= tilehdrlen;\n\t\t\t\t} else {\n\t\t\t\t\ttile->lyrsizes[lyrno] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (rateallocate(enc, tile->numlyrs, tile->lyrsizes)) {\n\t\t\treturn -1;\n\t\t}\n\n#if 0\njas_eprintf(\"ENCODE TILE DATA\\n\");\n#endif\n\t\tif (jpc_enc_encodetiledata(enc)) {\n\t\t\tjas_eprintf(\"dotile failed\\n\");\n\t\t\treturn -1;\n\t\t}\n\n\/************************************************************************\/\n\/************************************************************************\/\n\/************************************************************************\/\n\n\/************************************************************************\/\n\/************************************************************************\/\n\/************************************************************************\/\n\n\t\ttilelen = jas_stream_tell(enc->tmpstream);\n\n\t\tif (jas_stream_seek(enc->tmpstream, 6, SEEK_SET) < 0) {\n\t\t\treturn -1;\n\t\t}\n\t\tjpc_putuint32(enc->tmpstream, tilelen);\n\n\t\tif (jas_stream_seek(enc->tmpstream, 0, SEEK_SET) < 0) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (jpc_putdata(enc->out, enc->tmpstream, -1)) {\n\t\t\treturn -1;\n\t\t}\n\t\tenc->len += tilelen;\n\n\t\tjas_stream_close(enc->tmpstream);\n\t\tenc->tmpstream = 0;\n\n\t\tjpc_enc_tile_destroy(enc->curtile);\n\t\tenc->curtile = 0;\n\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":3655,"total_token_length":3891,"max_tokens_setting":4096}
+{"idx":274767,"func":"static int ntfs_attr_fill_hole(ntfs_attr *na, s64 count, s64 *ofs, \n\t\t\t       runlist_element **rl, VCN *update_from)\n{\n\ts64 to_write;\n\ts64 need;\n\tntfs_volume *vol = na->ni->vol;\n\tint eo, ret = -1;\n\trunlist *rlc;\n\tLCN lcn_seek_from = -1;\n\tVCN cur_vcn, from_vcn;\n\n\tif (na->ni->mft_no == FILE_Bitmap) {\n\t\t\/*\n\t\t * Filling a hole in the main bitmap implies allocating\n\t\t * clusters, which is likely to imply updating the\n\t\t * bitmap in a cluster being allocated.\n\t\t * Not supported now, could lead to endless recursions.\n\t\t *\/\n\t\tntfs_log_error(\"Corrupt $BitMap not fully allocated\\n\");\n\t\terrno = EIO;\n\t\tgoto err_out;\n\t}\n\tto_write = min(count, ((*rl)->length << vol->cluster_size_bits) - *ofs);\n\t\n\tcur_vcn = (*rl)->vcn;\n\tfrom_vcn = (*rl)->vcn + (*ofs >> vol->cluster_size_bits);\n\t\n\tntfs_log_trace(\"count: %lld, cur_vcn: %lld, from: %lld, to: %lld, ofs: \"\n\t\t       \"%lld\\n\", (long long)count, (long long)cur_vcn, \n\t\t       (long long)from_vcn, (long long)to_write, (long long)*ofs);\n\t \n\t\/* Map the runlist to be able to update mapping pairs later. *\/\n#if PARTIAL_RUNLIST_UPDATING\n\tif (!na->rl) {\n\t\tif (ntfs_attr_map_whole_runlist(na))\n\t\t\tgoto err_out;\n\t} else {\n\t\t\/* make sure the run ahead of hole is mapped *\/\n\t\tif ((*rl)->lcn == LCN_HOLE) {\n\t\t\tif (ntfs_attr_map_partial_runlist(na,\n\t\t\t\t(cur_vcn ? cur_vcn - 1 : cur_vcn)))\n\t\t\t\t\tgoto err_out;\n\t\t}\n\t}\n#else\n\tif (ntfs_attr_map_whole_runlist(na))\n\t\tgoto err_out;\n#endif\n\t \n\t\/* Restore @*rl, it probably get lost during runlist mapping. *\/\n\t*rl = ntfs_attr_find_vcn(na, cur_vcn);\n\tif (!*rl) {\n\t\tntfs_log_error(\"Failed to find run after mapping runlist. \"\n\t\t\t       \"Please report to %s.\\n\", NTFS_DEV_LIST);\n\t\terrno = EIO;\n\t\tgoto err_out;\n\t}\n\t\n\t\/* Search backwards to find the best lcn to start seek from. *\/\n\trlc = *rl;\n\twhile (rlc->vcn) {\n\t\trlc--;\n\t\tif (rlc->lcn >= 0) {\n\t\t\t\t\/*\n\t\t\t\t * avoid fragmenting a compressed file\n\t\t\t\t * Windows does not do that, and that may\n\t\t\t\t * not be desirable for files which can\n\t\t\t\t * be updated\n\t\t\t\t *\/\n\t\t\tif (na->data_flags & ATTR_COMPRESSION_MASK)\n\t\t\t\tlcn_seek_from = rlc->lcn + rlc->length;\n\t\t\telse\n\t\t\t\tlcn_seek_from = rlc->lcn + (from_vcn - rlc->vcn);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (lcn_seek_from == -1) {\n\t\t\/* Backwards search failed, search forwards. *\/\n\t\trlc = *rl;\n\t\twhile (rlc->length) {\n\t\t\trlc++;\n\t\t\tif (rlc->lcn >= 0) {\n\t\t\t\tlcn_seek_from = rlc->lcn - (rlc->vcn - from_vcn);\n\t\t\t\tif (lcn_seek_from < -1)\n\t\t\t\t\tlcn_seek_from = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tneed = ((*ofs + to_write - 1) >> vol->cluster_size_bits)\n\t\t\t + 1 + (*rl)->vcn - from_vcn;\n\tif ((na->data_flags & ATTR_COMPRESSION_MASK)\n\t    && (need < na->compression_block_clusters)) {\n\t\t\/*\n\t\t * for a compressed file, be sure to allocate the full\n\t\t * compression block, as we may need space to decompress\n\t\t * existing compressed data.\n\t\t * So allocate the space common to compression block\n\t\t * and existing hole.\n\t\t *\/\n\t\tVCN alloc_vcn;\n\n\t\tif ((from_vcn & -na->compression_block_clusters) <= (*rl)->vcn)\n\t\t\talloc_vcn = (*rl)->vcn;\n\t\telse\n\t\t\talloc_vcn = from_vcn & -na->compression_block_clusters;\n\t\tneed = (alloc_vcn | (na->compression_block_clusters - 1))\n\t\t\t+ 1 - alloc_vcn;\n\t\tif (need > (*rl)->length) {\n\t\t\tntfs_log_error(\"Cannot allocate %lld clusters\"\n\t\t\t\t\t\" within a hole of %lld\\n\",\n\t\t\t\t\t(long long)need,\n\t\t\t\t\t(long long)(*rl)->length);\n\t\t\terrno = EIO;\n\t\t\tgoto err_out;\n\t\t}\n\t\trlc = ntfs_cluster_alloc(vol, alloc_vcn, need,\n\t\t\t\t lcn_seek_from, DATA_ZONE);\n\t} else\n\t\trlc = ntfs_cluster_alloc(vol, from_vcn, need,\n\t\t\t\t lcn_seek_from, DATA_ZONE);\n\tif (!rlc)\n\t\tgoto err_out;\n\tif (na->data_flags & (ATTR_COMPRESSION_MASK | ATTR_IS_SPARSE))\n\t\tna->compressed_size += need << vol->cluster_size_bits;\n\t\n\t*rl = ntfs_runlists_merge(na->rl, rlc);\n\tNAttrSetRunlistDirty(na);\n\t\t\/*\n\t\t * For a compressed attribute, we must be sure there are two\n\t\t * available entries, so reserve them before it gets too late.\n\t\t *\/\n\tif (*rl && (na->data_flags & ATTR_COMPRESSION_MASK)) {\n\t\trunlist_element *oldrl = na->rl;\n\t\tna->rl = *rl;\n\t\t*rl = ntfs_rl_extend(na,*rl,2);\n\t\tif (!*rl) na->rl = oldrl; \/* restore to original if failed *\/\n\t}\n\tif (!*rl) {\n\t\teo = errno;\n\t\tntfs_log_perror(\"Failed to merge runlists\");\n\t\tif (ntfs_cluster_free_from_rl(vol, rlc)) {\n\t\t\tntfs_log_perror(\"Failed to free hot clusters. \"\n\t\t\t\t\t\"Please run chkdsk \/f\");\n\t\t}\n\t\terrno = eo;\n\t\tgoto err_out;\n\t}\n\tna->unused_runs = 2;\n\tna->rl = *rl;\n\tif ((*update_from == -1) || (from_vcn < *update_from))\n\t\t*update_from = from_vcn;\n\t*rl = ntfs_attr_find_vcn(na, cur_vcn);\n\tif (!*rl) {\n\t\t\/*\n\t\t * It's definitely a BUG, if we failed to find @cur_vcn, because\n\t\t * we missed it during instantiating of the hole.\n\t\t *\/\n\t\tntfs_log_error(\"Failed to find run after hole instantiation. \"\n\t\t\t       \"Please report to %s.\\n\", NTFS_DEV_LIST);\n\t\terrno = EIO;\n\t\tgoto err_out;\n\t}\n\t\/* If leaved part of the hole go to the next run. *\/\n\tif ((*rl)->lcn < 0)\n\t\t(*rl)++;\n\t\/* Now LCN shoudn't be less than 0. *\/\n\tif ((*rl)->lcn < 0) {\n\t\tntfs_log_error(\"BUG! LCN is lesser than 0. \"\n\t\t\t       \"Please report to the %s.\\n\", NTFS_DEV_LIST);\n\t\terrno = EIO;\n\t\tgoto err_out;\n\t}\n\tif (*ofs) {\n\t\t\/* Clear non-sparse region from @cur_vcn to @*ofs. *\/\n\t\tif (ntfs_attr_fill_zero(na, cur_vcn << vol->cluster_size_bits,\n\t\t\t\t\t*ofs))\n\t\t\tgoto err_out;\n\t}\n\tif ((*rl)->vcn < cur_vcn) {\n\t\t\/*\n\t\t * Clusters that replaced hole are merged with\n\t\t * previous run, so we need to update offset.\n\t\t *\/\n\t\t*ofs += (cur_vcn - (*rl)->vcn) << vol->cluster_size_bits;\n\t}\n\tif ((*rl)->vcn > cur_vcn) {\n\t\t\/*\n\t\t * We left part of the hole, so we need to update offset\n\t\t *\/\n\t\t*ofs -= ((*rl)->vcn - cur_vcn) << vol->cluster_size_bits;\n\t}\n\t\n\tret = 0;\nerr_out:\n\treturn ret;\n}","target":0,"code_token_length":1860,"total_token_length":2096,"max_tokens_setting":4096}
+{"idx":196629,"func":"  void ComputeAsync(OpKernelContext* context, DoneCallback done) final {\n    const Tensor& input = context->input(0);\n    const Tensor& rhs = context->input(1);\n    const int ndims = input.dims();\n    const int64 n = input.dim_size(ndims - 1);\n    const int64 nrhs = rhs.dim_size(ndims - 1);\n    \/\/ Validate inputs.\n    OP_REQUIRES_ASYNC(\n        context, ndims >= 2,\n        errors::InvalidArgument(\"Input must have rank >= 2, got \", ndims),\n        done);\n    OP_REQUIRES_ASYNC(context, rhs.dims() == ndims,\n                      errors::InvalidArgument(\n                          \"Input and right-hand side must have same rank, got \",\n                          ndims, \" != \", rhs.dims()),\n                      done);\n    OP_REQUIRES_ASYNC(\n        context, input.dim_size(ndims - 2) == n,\n        errors::InvalidArgument(\"Input matrices must be squares, got\",\n                                input.dim_size(ndims - 2), \" != \", n),\n        done);\n    OP_REQUIRES_ASYNC(context, rhs.dim_size(ndims - 2) == n,\n                      errors::InvalidArgument(\n                          \"Input matrix and right-hand side must have the \"\n                          \"same number of rows, got\",\n                          n, \" != \", rhs.dim_size(ndims - 2)),\n                      done);\n\n    \/\/ Allocate output.\n    Tensor* output;\n    OP_REQUIRES_OK_ASYNC(\n        context,\n        context->forward_input_or_allocate_output({1}, 0, rhs.shape(), &output),\n        done);\n\n    \/\/ To be consistent with the MatrixInverse op, we define the solution for\n    \/\/ an empty set of equations as the empty matrix.\n    if (input.NumElements() == 0 || rhs.NumElements() == 0) {\n      done();\n      return;\n    }\n\n    \/\/ TODO(rmlarsen): Convert to std::make_unique when available.\n    std::unique_ptr<CudaSolver> solver(new CudaSolver(context));\n\n    \/\/ Make a copy of the input for the factorization step, or, if adjoint_ is\n    \/\/ false, try to reuse the input buffer if this op owns it exclusively.\n    Tensor input_copy;\n    const GPUDevice& device = context->eigen_device<GPUDevice>();\n    if (adjoint_) {\n      \/\/ For the adjoint case, it is simpler to always make a transposed copy up\n      \/\/ front.\n      OP_REQUIRES_OK_ASYNC(\n          context,\n          solver->allocate_scoped_tensor(DataTypeToEnum<Scalar>::value,\n                                         input.shape(), &input_copy),\n          done);\n      OP_REQUIRES_OK_ASYNC(context,\n                           DoMatrixTranspose(device, input, &input_copy), done);\n    } else {\n      OP_REQUIRES_OK_ASYNC(\n          context,\n          solver->forward_input_or_allocate_scoped_tensor(\n              {0}, DataTypeToEnum<Scalar>::value, input.shape(), &input_copy),\n          done);\n      if (!input.SharesBufferWith(input_copy)) {\n        device.memcpy(input_copy.flat<Scalar>().data(),\n                      input.flat<Scalar>().data(),\n                      input.NumElements() * sizeof(Scalar));\n      }\n    }\n    auto input_copy_reshaped = input_copy.template flat_inner_dims<Scalar, 3>();\n    const int64 batch_size = input_copy_reshaped.dimension(0);\n\n    \/\/ Allocate pivots on the device.\n    Tensor pivots;\n    OP_REQUIRES_OK_ASYNC(\n        context,\n        solver->allocate_scoped_tensor(DataTypeToEnum<int>::value,\n                                       TensorShape{batch_size, n}, &pivots),\n        done);\n    auto pivots_mat = pivots.template matrix<int>();\n\n    \/\/ 1. Compute the partially pivoted LU factorization(s) of the\n    \/\/ matrix\/matrices.\n    std::vector<DeviceLapackInfo> dev_info;\n    auto input_copy_ptrs = solver->GetScratchSpace<uint8>(\n        sizeof(Scalar*) * batch_size, \"input_copt_ptrs\",\n        \/* on_host *\/ true);\n    const int kMaxMatrixSizeToBatchSizeRatio = 128;\n    const bool use_batched_solver =\n        n <= kMaxMatrixSizeToBatchSizeRatio * batch_size;\n    if (use_batched_solver) {\n      \/\/ For small matrices or large batch sizes, we use the batched interface\n      \/\/ from cuBlas.\n      const Scalar** input_copy_ptrs_base =\n          reinterpret_cast<const Scalar**>(input_copy_ptrs.mutable_data());\n      for (int batch = 0; batch < batch_size; ++batch) {\n        input_copy_ptrs_base[batch] = &input_copy_reshaped(batch, 0, 0);\n      }\n      dev_info.push_back(\n          solver->GetDeviceLapackInfo(batch_size, \"getrfBatched\"));\n      OP_REQUIRES_OK_ASYNC(\n          context,\n          solver->GetrfBatched(n, input_copy_ptrs_base, n, pivots_mat.data(),\n                               &dev_info.back(), batch_size),\n          done);\n    } else {\n      \/\/ For small batch sizes or large matrices, we use the non-batched\n      \/\/ interface from cuSolver, which is much faster for large matrices.\n      dev_info.push_back(solver->GetDeviceLapackInfo(batch_size, \"getrf\"));\n      for (int batch = 0; batch < batch_size; ++batch) {\n        OP_REQUIRES_OK_ASYNC(\n            context,\n            solver->Getrf(n, n, &input_copy_reshaped(batch, 0, 0), n,\n                          &pivots_mat(batch, 0), &dev_info.back()(batch)),\n            done);\n      }\n    }\n\n    \/\/ 2. Make a transposed copy of the right-hand sides. This is necessary\n    \/\/ because cuBLAS assumes column-major storage while TensorFlow TF uses\n    \/\/ row-major.\n    TensorShape transposed_rhs_shape(rhs.shape());\n    transposed_rhs_shape.RemoveLastDims(2);\n    transposed_rhs_shape.AddDim(nrhs);\n    transposed_rhs_shape.AddDim(n);\n    Tensor transposed_rhs;\n    OP_REQUIRES_OK_ASYNC(\n        context,\n        solver->allocate_scoped_tensor(DataTypeToEnum<Scalar>::value,\n                                       transposed_rhs_shape, &transposed_rhs),\n        done);\n    if (nrhs > 1) {\n      OP_REQUIRES_OK_ASYNC(\n          context, DoMatrixTranspose(device, rhs, &transposed_rhs), done);\n    } else {\n      device.memcpy(transposed_rhs.flat<Scalar>().data(),\n                    rhs.flat<Scalar>().data(),\n                    rhs.NumElements() * sizeof(Scalar));\n    }\n\n    \/\/ 3. Solve op(A) X = B (in column major form).\n    \/\/ We use a trick here: If adjoint_ is true, we converted A to column major\n    \/\/ form above. If adjoint is false then I leave A in row-major form and use\n    \/\/ trans_a = CUBLAS_OP_T to effectively transform it to column-major on the\n    \/\/ fly. (This means that we actually use the LU-factorization of A^T in that\n    \/\/ case, but that is equally good for solving AX=B). This way we save an\n    \/\/ explicit transpose in the more common case of adjoint_ == false.\n    auto input_copy_ptr_array = solver->GetScratchSpace<uint8>(\n        sizeof(Scalar*) * batch_size, \"input_copy_ptr_array\",\n        \/* on_host *\/ true);\n    auto transposed_rhs_ptr_array = solver->GetScratchSpace<uint8>(\n        sizeof(Scalar*) * batch_size, \"transposed_rhs_ptr_array\",\n        \/* on_host *\/ true);\n    auto transposed_rhs_reshaped =\n        transposed_rhs.template flat_inner_dims<Scalar, 3>();\n    if (use_batched_solver) {\n      const Scalar** input_copy_ptrs_base =\n          reinterpret_cast<const Scalar**>(input_copy_ptr_array.mutable_data());\n      const Scalar** transposed_rhs_ptrs_base =\n          reinterpret_cast<const Scalar**>(\n              transposed_rhs_ptr_array.mutable_data());\n      for (int batch = 0; batch < batch_size; ++batch) {\n        input_copy_ptrs_base[batch] = &input_copy_reshaped(batch, 0, 0);\n        transposed_rhs_ptrs_base[batch] = &transposed_rhs_reshaped(batch, 0, 0);\n      }\n      int host_info = 0;\n      OP_REQUIRES_OK_ASYNC(\n          context,\n          solver->GetrsBatched(adjoint_ ? CUBLAS_OP_C : CUBLAS_OP_T, n, nrhs,\n                               input_copy_ptrs_base, n, pivots_mat.data(),\n                               transposed_rhs_ptrs_base, n, &host_info,\n                               batch_size),\n          done);\n      OP_REQUIRES_ASYNC(\n          context, host_info == 0,\n          errors::InvalidArgument(\"The \", -host_info,\n                                  \"'th argument to cublas*getrsBatched had \"\n                                  \"an illegal value.\"),\n          done);\n    } else {\n      dev_info.push_back(solver->GetDeviceLapackInfo(batch_size, \"getrs\"));\n      for (int batch = 0; batch < batch_size; ++batch) {\n        OP_REQUIRES_OK_ASYNC(\n            context,\n            solver->Getrs(adjoint_ ? CUBLAS_OP_C : CUBLAS_OP_T, n, nrhs,\n                          &input_copy_reshaped(batch, 0, 0), n,\n                          &pivots_mat(batch, 0),\n                          &transposed_rhs_reshaped(batch, 0, 0), n,\n                          &dev_info.back()(batch)),\n            done);\n      }\n    }\n\n    \/\/ 4. Transpose X to get the final result in row-major form.\n    if (nrhs > 1) {\n      OP_REQUIRES_OK_ASYNC(\n          context, DoMatrixTranspose(device, transposed_rhs, output), done);\n    } else {\n      device.memcpy(output->flat<Scalar>().data(),\n                    transposed_rhs.flat<Scalar>().data(),\n                    transposed_rhs.NumElements() * sizeof(Scalar));\n    }\n\n    \/\/ Callback for checking info after kernels finish. Also capture the\n    \/\/ temporary Tensors\/ScratchSpace so they don't get deallocated before the\n    \/\/ kernels run. TODO(rmlarsen): Use move capture once C++14 becomes\n    \/\/ available.\n    auto info_checker = [context, done, dev_info](\n                            const Status& status,\n                            const std::vector<HostLapackInfo>& host_infos) {\n      if (!status.ok() && errors::IsInvalidArgument(status) &&\n          !host_infos.empty()) {\n        for (int i = 0; i < host_infos[0].size(); ++i) {\n          \/\/ Match the CPU error message for singular matrices. Otherwise\n          \/\/ just print the original error message from the status below.\n          OP_REQUIRES_ASYNC(context, host_infos[0].data()[i] <= 0,\n                            errors::InvalidArgument(kErrMsg), done);\n        }\n      }\n      OP_REQUIRES_OK_ASYNC(context, status, done);\n      done();\n    };\n    CudaSolver::CheckLapackInfoAndDeleteSolverAsync(std::move(solver), dev_info,\n                                                    std::move(info_checker));\n  }","target":1,"code_token_length":2343,"total_token_length":2579,"max_tokens_setting":4096}
+{"idx":513289,"func":"test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,\n                         key_map usable_keys,  int ref_key,\n                         ha_rows select_limit_arg,\n                         int *new_key, int *new_key_direction,\n                         ha_rows *new_select_limit, uint *new_used_key_parts,\n                         uint *saved_best_key_parts)\n{\n  DBUG_ENTER(\"test_if_cheaper_ordering\");\n  \/*\n    Check whether there is an index compatible with the given order\n    usage of which is cheaper than usage of the ref_key index (ref_key>=0)\n    or a table scan.\n    It may be the case if ORDER\/GROUP BY is used with LIMIT.\n  *\/\n  ha_rows best_select_limit= HA_POS_ERROR;\n  JOIN *join= tab ? tab->join : NULL;\n  uint nr;\n  key_map keys;\n  uint best_key_parts= 0;\n  int best_key_direction= 0;\n  ha_rows best_records= 0;\n  double read_time;\n  int best_key= -1;\n  bool is_best_covering= FALSE;\n  double fanout= 1;\n  ha_rows table_records= table->stat_records();\n  bool group= join && join->group && order == join->group_list;\n  ha_rows refkey_rows_estimate= table->quick_condition_rows;\n  const bool has_limit= (select_limit_arg != HA_POS_ERROR);\n\n  \/*\n    If not used with LIMIT, only use keys if the whole query can be\n    resolved with a key;  This is because filesort() is usually faster than\n    retrieving all rows through an index.\n  *\/\n  if (select_limit_arg >= table_records)\n  {\n    keys= *table->file->keys_to_use_for_scanning();\n    keys.merge(table->covering_keys);\n\n    \/*\n      We are adding here also the index specified in FORCE INDEX clause, \n      if any.\n      This is to allow users to use index in ORDER BY.\n    *\/\n    if (table->force_index) \n      keys.merge(group ? table->keys_in_use_for_group_by :\n                         table->keys_in_use_for_order_by);\n    keys.intersect(usable_keys);\n  }\n  else\n    keys= usable_keys;\n\n  if (join)\n  {\n    uint tablenr= (uint)(tab - join->join_tab);\n    read_time= join->best_positions[tablenr].read_time;\n    for (uint i= tablenr+1; i < join->table_count; i++)\n      fanout*= join->best_positions[i].records_read; \/\/ fanout is always >= 1\n  }\n  else\n    read_time= table->file->scan_time();\n  \n  \/*\n    TODO: add cost of sorting here.\n  *\/\n  read_time += COST_EPS;\n\n  \/*\n    Calculate the selectivity of the ref_key for REF_ACCESS. For\n    RANGE_ACCESS we use table->quick_condition_rows.\n  *\/\n  if (ref_key >= 0 && ref_key != MAX_KEY && tab->type == JT_REF)\n  {\n    if (table->quick_keys.is_set(ref_key))\n      refkey_rows_estimate= table->quick_rows[ref_key];\n    else\n    {\n      const KEY *ref_keyinfo= table->key_info + ref_key;\n      refkey_rows_estimate= ref_keyinfo->rec_per_key[tab->ref.key_parts - 1];\n    }\n    set_if_bigger(refkey_rows_estimate, 1);\n  }\n\n  for (nr=0; nr < table->s->keys ; nr++)\n  {\n    int direction;\n    ha_rows select_limit= select_limit_arg;\n    uint used_key_parts= 0;\n\n    if (keys.is_set(nr) &&\n        (direction= test_if_order_by_key(join, order, table, nr,\n                                         &used_key_parts)))\n    {\n      \/*\n        At this point we are sure that ref_key is a non-ordering\n        key (where \"ordering key\" is a key that will return rows\n        in the order required by ORDER BY).\n      *\/\n      DBUG_ASSERT (ref_key != (int) nr);\n\n      bool is_covering= (table->covering_keys.is_set(nr) ||\n                         (table->file->index_flags(nr, 0, 1) &\n                          HA_CLUSTERED_INDEX));\n      \/* \n        Don't use an index scan with ORDER BY without limit.\n        For GROUP BY without limit always use index scan\n        if there is a suitable index. \n        Why we hold to this asymmetry hardly can be explained\n        rationally. It's easy to demonstrate that using\n        temporary table + filesort could be cheaper for grouping\n        queries too.\n      *\/ \n      if (is_covering ||\n          select_limit != HA_POS_ERROR || \n          (ref_key < 0 && (group || table->force_index)))\n      { \n        double rec_per_key;\n        double index_scan_time;\n        KEY *keyinfo= table->key_info+nr;\n        if (select_limit == HA_POS_ERROR)\n          select_limit= table_records;\n        if (group)\n        {\n          \/* \n            Used_key_parts can be larger than keyinfo->user_defined_key_parts\n            when using a secondary index clustered with a primary \n            key (e.g. as in Innodb). \n            See Bug #28591 for details.\n          *\/  \n          uint used_index_parts= keyinfo->user_defined_key_parts;\n          uint used_pk_parts= 0;\n          if (used_key_parts > used_index_parts)\n            used_pk_parts= used_key_parts-used_index_parts;\n          rec_per_key= used_key_parts ?\n\t               keyinfo->actual_rec_per_key(used_key_parts-1) : 1;\n          \/* Take into account the selectivity of the used pk prefix *\/\n          if (used_pk_parts)\n\t  {\n            KEY *pkinfo=tab->table->key_info+table->s->primary_key;\n            \/*\n              If the values of of records per key for the prefixes\n              of the primary key are considered unknown we assume\n              they are equal to 1.\n\t    *\/\n            if (used_key_parts == pkinfo->user_defined_key_parts ||\n                pkinfo->rec_per_key[0] == 0)\n              rec_per_key= 1;                 \n            if (rec_per_key > 1)\n\t    {\n              rec_per_key*= pkinfo->actual_rec_per_key(used_pk_parts-1);\n              rec_per_key\/= pkinfo->actual_rec_per_key(0);\n              \/* \n                The value of rec_per_key for the extended key has\n                to be adjusted accordingly if some components of\n                the secondary key are included in the primary key.\n\t      *\/\n               for(uint i= 1; i < used_pk_parts; i++)\n\t      {\n\t        if (pkinfo->key_part[i].field->key_start.is_set(nr))\n\t        {\n                  \/* \n                    We presume here that for any index rec_per_key[i] != 0\n                    if rec_per_key[0] != 0.\n\t          *\/\n                  DBUG_ASSERT(pkinfo->actual_rec_per_key(i));\n                  rec_per_key*= pkinfo->actual_rec_per_key(i-1);\n                  rec_per_key\/= pkinfo->actual_rec_per_key(i);\n                }\n\t      }\n            }    \n          }\n          set_if_bigger(rec_per_key, 1);\n          \/*\n            With a grouping query each group containing on average\n            rec_per_key records produces only one row that will\n            be included into the result set.\n          *\/  \n          if (select_limit > table_records\/rec_per_key)\n            select_limit= table_records;\n          else\n            select_limit= (ha_rows) (select_limit*rec_per_key);\n        } \/* group *\/\n\n        \/* \n          If tab=tk is not the last joined table tn then to get first\n          L records from the result set we can expect to retrieve\n          only L\/fanout(tk,tn) where fanout(tk,tn) says how many\n          rows in the record set on average will match each row tk.\n          Usually our estimates for fanouts are too pessimistic.\n          So the estimate for L\/fanout(tk,tn) will be too optimistic\n          and as result we'll choose an index scan when using ref\/range\n          access + filesort will be cheaper.\n        *\/\n        select_limit= (ha_rows) (select_limit < fanout ?\n                                 1 : select_limit\/fanout);\n        \/*\n          We assume that each of the tested indexes is not correlated\n          with ref_key. Thus, to select first N records we have to scan\n          N\/selectivity(ref_key) index entries. \n          selectivity(ref_key) = #scanned_records\/#table_records =\n          refkey_rows_estimate\/table_records.\n          In any case we can't select more than #table_records.\n          N\/(refkey_rows_estimate\/table_records) > table_records\n          <=> N > refkey_rows_estimate.\n         *\/\n        if (select_limit > refkey_rows_estimate)\n          select_limit= table_records;\n        else\n          select_limit= (ha_rows) (select_limit *\n                                   (double) table_records \/\n                                    refkey_rows_estimate);\n        rec_per_key= keyinfo->actual_rec_per_key(keyinfo->user_defined_key_parts-1);\n        set_if_bigger(rec_per_key, 1);\n        \/*\n          Here we take into account the fact that rows are\n          accessed in sequences rec_per_key records in each.\n          Rows in such a sequence are supposed to be ordered\n          by rowid\/primary key. When reading the data\n          in a sequence we'll touch not more pages than the\n          table file contains.\n          TODO. Use the formula for a disk sweep sequential access\n          to calculate the cost of accessing data rows for one \n          index entry.\n        *\/\n        index_scan_time= select_limit\/rec_per_key *\n                         MY_MIN(rec_per_key, table->file->scan_time());\n        double range_scan_time;\n        if (get_range_limit_read_cost(tab, table, nr, select_limit, \n                                       &range_scan_time))\n        {\n          if (range_scan_time < index_scan_time)\n            index_scan_time= range_scan_time;\n        }\n\n        if ((ref_key < 0 && (group || table->force_index || is_covering)) ||\n            index_scan_time < read_time)\n        {\n          ha_rows quick_records= table_records;\n          ha_rows refkey_select_limit= (ref_key >= 0 &&\n                                        !is_hash_join_key_no(ref_key) &&\n                                        table->covering_keys.is_set(ref_key)) ?\n                                        refkey_rows_estimate :\n                                        HA_POS_ERROR;\n          if ((is_best_covering && !is_covering) ||\n              (is_covering && refkey_select_limit < select_limit))\n            continue;\n          if (table->quick_keys.is_set(nr))\n            quick_records= table->quick_rows[nr];\n          if (best_key < 0 ||\n              (select_limit <= MY_MIN(quick_records,best_records) ?\n               keyinfo->user_defined_key_parts < best_key_parts :\n               quick_records < best_records) ||\n              (!is_best_covering && is_covering))\n          {\n            best_key= nr;\n            best_key_parts= keyinfo->user_defined_key_parts;\n            if (saved_best_key_parts)\n              *saved_best_key_parts= used_key_parts;\n            best_records= quick_records;\n            is_best_covering= is_covering;\n            best_key_direction= direction; \n            best_select_limit= select_limit;\n          }\n        }   \n      }      \n    }\n  }\n\n  if (best_key < 0 || best_key == ref_key)\n    DBUG_RETURN(FALSE);\n  \n  *new_key= best_key;\n  *new_key_direction= best_key_direction;\n  *new_select_limit= has_limit ? best_select_limit : table_records;\n  if (new_used_key_parts != NULL)\n    *new_used_key_parts= best_key_parts;\n\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":2485,"total_token_length":2721,"max_tokens_setting":4096}
+{"idx":359598,"func":"bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)\n{\n  struct bgp_filter *filter;\n  char orf_pfx_name[BUFSIZ];\n  int orf_pfx_count;\n\n  filter = &p->filter[afi][safi];\n\n  vty_out (vty, \" For address family: %s%s\", afi_safi_print (afi, safi),\n\t   VTY_NEWLINE);\n\n  if (p->af_group[afi][safi])\n    vty_out (vty, \"  %s peer-group member%s\", p->group->name, VTY_NEWLINE);\n\n  if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))\n    vty_out (vty, \"  AF-dependant capabilities:%s\", VTY_NEWLINE);\n\n  if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))\n    {\n      vty_out (vty, \"    Outbound Route Filter (ORF) type (%d) Prefix-list:%s\",\n\t       ORF_TYPE_PREFIX, VTY_NEWLINE);\n      bgp_show_peer_afi_orf_cap (vty, p, afi, safi,\n\t\t\t\t PEER_CAP_ORF_PREFIX_SM_ADV,\n\t\t\t\t PEER_CAP_ORF_PREFIX_RM_ADV,\n\t\t\t\t PEER_CAP_ORF_PREFIX_SM_RCV,\n\t\t\t\t PEER_CAP_ORF_PREFIX_RM_RCV);\n    }\n  if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)\n      || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))\n    {\n      vty_out (vty, \"    Outbound Route Filter (ORF) type (%d) Prefix-list:%s\",\n\t       ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);\n      bgp_show_peer_afi_orf_cap (vty, p, afi, safi,\n\t\t\t\t PEER_CAP_ORF_PREFIX_SM_ADV,\n\t\t\t\t PEER_CAP_ORF_PREFIX_RM_ADV,\n\t\t\t\t PEER_CAP_ORF_PREFIX_SM_OLD_RCV,\n\t\t\t\t PEER_CAP_ORF_PREFIX_RM_OLD_RCV);\n    }\n\n  sprintf (orf_pfx_name, \"%s.%d.%d\", p->host, afi, safi);\n  orf_pfx_count =  prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);\n\n  if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)\n      || orf_pfx_count)\n    {\n      vty_out (vty, \"  Outbound Route Filter (ORF):\");\n      if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))\n\t  vty_out (vty, \" sent;\");\n      if (orf_pfx_count)\n\tvty_out (vty, \" received (%d entries)\", orf_pfx_count);\n      vty_out (vty, \"%s\", VTY_NEWLINE);\n    }\n  if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))\n      vty_out (vty, \"  First update is deferred until ORF or ROUTE-REFRESH is received%s\", VTY_NEWLINE);\n\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))\n    vty_out (vty, \"  Route-Reflector Client%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))\n    vty_out (vty, \"  Route-Server Client%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))\n    vty_out (vty, \"  Inbound soft reconfiguration allowed%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))\n    vty_out (vty, \"  Private AS number removed from updates to this neighbor%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))\n    vty_out (vty, \"  NEXT_HOP is always this router%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))\n    vty_out (vty, \"  AS_PATH is propagated unchanged to this neighbor%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))\n    vty_out (vty, \"  NEXT_HOP is propagated unchanged to this neighbor%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))\n    vty_out (vty, \"  MED is propagated unchanged to this neighbor%s\", VTY_NEWLINE);\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)\n      || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))\n    {\n      vty_out (vty, \"  Community attribute sent to this neighbor\");\n      if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)\n\t&& CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))\n\tvty_out (vty, \"(both)%s\", VTY_NEWLINE);\n      else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))\n\tvty_out (vty, \"(extended)%s\", VTY_NEWLINE);\n      else \n\tvty_out (vty, \"(standard)%s\", VTY_NEWLINE);\n    }\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))\n    {\n      vty_out (vty, \"  Default information originate,\");\n\n      if (p->default_rmap[afi][safi].name)\n\tvty_out (vty, \" default route-map %s%s,\",\n\t\t p->default_rmap[afi][safi].map ? \"*\" : \"\",\n\t\t p->default_rmap[afi][safi].name);\n      if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))\n\tvty_out (vty, \" default sent%s\", VTY_NEWLINE);\n      else\n\tvty_out (vty, \" default not sent%s\", VTY_NEWLINE);\n    }\n\n  if (filter->plist[FILTER_IN].name\n      || filter->dlist[FILTER_IN].name\n      || filter->aslist[FILTER_IN].name\n      || filter->map[RMAP_IN].name)\n    vty_out (vty, \"  Inbound path policy configured%s\", VTY_NEWLINE);\n  if (filter->plist[FILTER_OUT].name\n      || filter->dlist[FILTER_OUT].name\n      || filter->aslist[FILTER_OUT].name\n      || filter->map[RMAP_OUT].name\n      || filter->usmap.name)\n    vty_out (vty, \"  Outbound path policy configured%s\", VTY_NEWLINE);\n  if (filter->map[RMAP_IMPORT].name)\n    vty_out (vty, \"  Import policy for this RS-client configured%s\", VTY_NEWLINE);\n  if (filter->map[RMAP_EXPORT].name)\n    vty_out (vty, \"  Export policy for this RS-client configured%s\", VTY_NEWLINE);\n\n  \/* prefix-list *\/\n  if (filter->plist[FILTER_IN].name)\n    vty_out (vty, \"  Incoming update prefix filter list is %s%s%s\",\n\t     filter->plist[FILTER_IN].plist ? \"*\" : \"\",\n\t     filter->plist[FILTER_IN].name,\n\t     VTY_NEWLINE);\n  if (filter->plist[FILTER_OUT].name)\n    vty_out (vty, \"  Outgoing update prefix filter list is %s%s%s\",\n\t     filter->plist[FILTER_OUT].plist ? \"*\" : \"\",\n\t     filter->plist[FILTER_OUT].name,\n\t     VTY_NEWLINE);\n\n  \/* distribute-list *\/\n  if (filter->dlist[FILTER_IN].name)\n    vty_out (vty, \"  Incoming update network filter list is %s%s%s\",\n\t     filter->dlist[FILTER_IN].alist ? \"*\" : \"\",\n\t     filter->dlist[FILTER_IN].name,\n\t     VTY_NEWLINE);\n  if (filter->dlist[FILTER_OUT].name)\n    vty_out (vty, \"  Outgoing update network filter list is %s%s%s\",\n\t     filter->dlist[FILTER_OUT].alist ? \"*\" : \"\",\n\t     filter->dlist[FILTER_OUT].name,\n\t     VTY_NEWLINE);\n\n  \/* filter-list. *\/\n  if (filter->aslist[FILTER_IN].name)\n    vty_out (vty, \"  Incoming update AS path filter list is %s%s%s\",\n\t     filter->aslist[FILTER_IN].aslist ? \"*\" : \"\",\n\t     filter->aslist[FILTER_IN].name,\n\t     VTY_NEWLINE);\n  if (filter->aslist[FILTER_OUT].name)\n    vty_out (vty, \"  Outgoing update AS path filter list is %s%s%s\",\n\t     filter->aslist[FILTER_OUT].aslist ? \"*\" : \"\",\n\t     filter->aslist[FILTER_OUT].name,\n\t     VTY_NEWLINE);\n\n  \/* route-map. *\/\n  if (filter->map[RMAP_IN].name)\n    vty_out (vty, \"  Route map for incoming advertisements is %s%s%s\",\n            filter->map[RMAP_IN].map ? \"*\" : \"\",\n            filter->map[RMAP_IN].name,\n\t     VTY_NEWLINE);\n  if (filter->map[RMAP_OUT].name)\n    vty_out (vty, \"  Route map for outgoing advertisements is %s%s%s\",\n            filter->map[RMAP_OUT].map ? \"*\" : \"\",\n            filter->map[RMAP_OUT].name,\n            VTY_NEWLINE);\n  if (filter->map[RMAP_IMPORT].name)\n    vty_out (vty, \"  Route map for advertisements going into this RS-client's table is %s%s%s\",\n            filter->map[RMAP_IMPORT].map ? \"*\" : \"\",\n            filter->map[RMAP_IMPORT].name,\n            VTY_NEWLINE);\n  if (filter->map[RMAP_EXPORT].name)\n    vty_out (vty, \"  Route map for advertisements coming from this RS-client is %s%s%s\",\n            filter->map[RMAP_EXPORT].map ? \"*\" : \"\",\n            filter->map[RMAP_EXPORT].name,\n\t     VTY_NEWLINE);\n\n  \/* unsuppress-map *\/\n  if (filter->usmap.name)\n    vty_out (vty, \"  Route map for selective unsuppress is %s%s%s\",\n\t     filter->usmap.map ? \"*\" : \"\",\n\t     filter->usmap.name, VTY_NEWLINE);\n\n  \/* Receive prefix count *\/\n  vty_out (vty, \"  %ld accepted prefixes%s\", p->pcount[afi][safi], VTY_NEWLINE);\n\n  \/* Maximum prefix *\/\n  if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))\n    {\n      vty_out (vty, \"  Maximum prefixes allowed %ld%s%s\", p->pmax[afi][safi],\n\t       CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)\n\t       ? \" (warning-only)\" : \"\", VTY_NEWLINE);\n      vty_out (vty, \"  Threshold for warning message %d%%\",\n\t       p->pmax_threshold[afi][safi]);\n      if (p->pmax_restart[afi][safi])\n\tvty_out (vty, \", restart interval %d min\", p->pmax_restart[afi][safi]);\n      vty_out (vty, \"%s\", VTY_NEWLINE);\n    }\n\n  vty_out (vty, \"%s\", VTY_NEWLINE);\n}","target":0,"code_token_length":2906,"total_token_length":3142,"max_tokens_setting":4096}
+{"idx":249510,"func":"Status DecodeImageAPNG(Span<const uint8_t> bytes, ThreadPool* pool,\n                       CodecInOut* io) {\n  Reader r;\n  unsigned int id, i, j, w, h, w0, h0, x0, y0;\n  unsigned int delay_num, delay_den, dop, bop, rowbytes, imagesize;\n  unsigned char sig[8];\n  png_structp png_ptr;\n  png_infop info_ptr;\n  CHUNK chunk;\n  CHUNK chunkIHDR;\n  std::vector<CHUNK> chunksInfo;\n  bool isAnimated = false;\n  bool skipFirst = false;\n  bool hasInfo = false;\n  bool all_dispose_bg = true;\n  APNGFrame frameRaw = {};\n\n  r = {bytes.data(), bytes.data() + bytes.size()};\n  \/\/ Not an aPNG => not an error\n  unsigned char png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n  if (r.Read(sig, 8) || memcmp(sig, png_signature, 8) != 0) {\n    return false;\n  }\n  id = read_chunk(&r, &chunkIHDR);\n\n  io->frames.clear();\n  io->dec_pixels = 0;\n  io->metadata.m.SetUintSamples(8);\n  io->metadata.m.SetAlphaBits(8);\n  io->metadata.m.color_encoding =\n      ColorEncoding::SRGB();  \/\/ todo: get data from png metadata\n  (void)io->dec_hints.Foreach(\n      [](const std::string& key, const std::string& \/*value*\/) {\n        JXL_WARNING(\"APNG decoder ignoring %s hint\", key.c_str());\n        return true;\n      });\n\n  bool errorstate = true;\n  if (id == kId_IHDR && chunkIHDR.size == 25) {\n    w0 = w = png_get_uint_32(chunkIHDR.p + 8);\n    h0 = h = png_get_uint_32(chunkIHDR.p + 12);\n\n    if (w > cMaxPNGSize || h > cMaxPNGSize) {\n      return false;\n    }\n\n    x0 = 0;\n    y0 = 0;\n    delay_num = 1;\n    delay_den = 10;\n    dop = 0;\n    bop = 0;\n    rowbytes = w * 4;\n    imagesize = h * rowbytes;\n\n    frameRaw.p = new unsigned char[imagesize];\n    frameRaw.rows = new png_bytep[h * sizeof(png_bytep)];\n    for (j = 0; j < h; j++) frameRaw.rows[j] = frameRaw.p + j * rowbytes;\n\n    if (!processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo,\n                          chunkIHDR, chunksInfo)) {\n      bool last_base_was_none = true;\n      while (!r.Eof()) {\n        id = read_chunk(&r, &chunk);\n        if (!id) break;\n        JXL_ASSERT(chunk.p != nullptr);\n\n        if (id == kId_acTL && !hasInfo && !isAnimated) {\n          isAnimated = true;\n          skipFirst = true;\n          io->metadata.m.have_animation = true;\n          io->metadata.m.animation.tps_numerator = 1000;\n        } else if (id == kId_IEND ||\n                   (id == kId_fcTL && (!hasInfo || isAnimated))) {\n          if (hasInfo) {\n            if (!processing_finish(png_ptr, info_ptr)) {\n              ImageBundle bundle(&io->metadata.m);\n              bundle.duration = delay_num * 1000 \/ delay_den;\n              bundle.origin.x0 = x0;\n              bundle.origin.y0 = y0;\n              \/\/ TODO(veluca): this could in principle be implemented.\n              if (last_base_was_none && !all_dispose_bg &&\n                  (x0 != 0 || y0 != 0 || w0 != w || h0 != h || bop != 0)) {\n                return JXL_FAILURE(\n                    \"APNG with dispose-to-0 is not supported for non-full or \"\n                    \"blended frames\");\n              }\n              switch (dop) {\n                case 0:\n                  bundle.use_for_next_frame = true;\n                  last_base_was_none = false;\n                  all_dispose_bg = false;\n                  break;\n                case 2:\n                  bundle.use_for_next_frame = false;\n                  all_dispose_bg = false;\n                  break;\n                default:\n                  bundle.use_for_next_frame = false;\n                  last_base_was_none = true;\n              }\n              bundle.blend = bop != 0;\n              io->dec_pixels += w0 * h0;\n\n              Image3F sub_frame(w0, h0);\n              ImageF sub_frame_alpha(w0, h0);\n              for (size_t y = 0; y < h0; ++y) {\n                float* const JXL_RESTRICT row_r = sub_frame.PlaneRow(0, y);\n                float* const JXL_RESTRICT row_g = sub_frame.PlaneRow(1, y);\n                float* const JXL_RESTRICT row_b = sub_frame.PlaneRow(2, y);\n                float* const JXL_RESTRICT row_alpha = sub_frame_alpha.Row(y);\n                uint8_t* const f = frameRaw.rows[y];\n                for (size_t x = 0; x < w0; ++x) {\n                  if (f[4 * x + 3] == 0) {\n                    row_alpha[x] = 0;\n                    row_r[x] = 0;\n                    row_g[x] = 0;\n                    row_b[x] = 0;\n                    continue;\n                  }\n                  row_r[x] = f[4 * x + 0] * (1.f \/ 255);\n                  row_g[x] = f[4 * x + 1] * (1.f \/ 255);\n                  row_b[x] = f[4 * x + 2] * (1.f \/ 255);\n                  row_alpha[x] = f[4 * x + 3] * (1.f \/ 255);\n                }\n              }\n              bundle.SetFromImage(std::move(sub_frame), ColorEncoding::SRGB());\n              bundle.SetAlpha(std::move(sub_frame_alpha),\n                              \/*alpha_is_premultiplied=*\/false);\n              io->frames.push_back(std::move(bundle));\n            } else {\n              delete[] chunk.p;\n              break;\n            }\n          }\n\n          if (id == kId_IEND) {\n            errorstate = false;\n            break;\n          }\n          \/\/ At this point the old frame is done. Let's start a new one.\n          w0 = png_get_uint_32(chunk.p + 12);\n          h0 = png_get_uint_32(chunk.p + 16);\n          x0 = png_get_uint_32(chunk.p + 20);\n          y0 = png_get_uint_32(chunk.p + 24);\n          delay_num = png_get_uint_16(chunk.p + 28);\n          delay_den = png_get_uint_16(chunk.p + 30);\n          dop = chunk.p[32];\n          bop = chunk.p[33];\n\n          if (!delay_den) delay_den = 100;\n\n          if (w0 > cMaxPNGSize || h0 > cMaxPNGSize || x0 > cMaxPNGSize ||\n              y0 > cMaxPNGSize || x0 + w0 > w || y0 + h0 > h || dop > 2 ||\n              bop > 1) {\n            delete[] chunk.p;\n            break;\n          }\n\n          if (hasInfo) {\n            memcpy(chunkIHDR.p + 8, chunk.p + 12, 8);\n            if (processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo,\n                                 chunkIHDR, chunksInfo)) {\n              delete[] chunk.p;\n              break;\n            }\n          } else\n            skipFirst = false;\n\n          if (io->frames.size() == (skipFirst ? 1 : 0)) {\n            bop = 0;\n            if (dop == 2) dop = 1;\n          }\n        } else if (id == kId_IDAT) {\n          hasInfo = true;\n          if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) {\n            delete[] chunk.p;\n            break;\n          }\n        } else if (id == kId_fdAT && isAnimated) {\n          png_save_uint_32(chunk.p + 4, chunk.size - 16);\n          memcpy(chunk.p + 8, \"IDAT\", 4);\n          if (processing_data(png_ptr, info_ptr, chunk.p + 4, chunk.size - 4)) {\n            delete[] chunk.p;\n            break;\n          }\n        } else if (!isAbc(chunk.p[4]) || !isAbc(chunk.p[5]) ||\n                   !isAbc(chunk.p[6]) || !isAbc(chunk.p[7])) {\n          delete[] chunk.p;\n          break;\n        } else if (!hasInfo) {\n          if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) {\n            delete[] chunk.p;\n            break;\n          }\n          chunksInfo.push_back(chunk);\n          continue;\n        }\n        delete[] chunk.p;\n      }\n    }\n    delete[] frameRaw.rows;\n    delete[] frameRaw.p;\n  }\n\n  for (i = 0; i < chunksInfo.size(); i++) delete[] chunksInfo[i].p;\n\n  chunksInfo.clear();\n  delete[] chunkIHDR.p;\n\n  if (errorstate) return false;\n  SetIntensityTarget(io);\n  return true;\n}","target":0,"code_token_length":2089,"total_token_length":2325,"max_tokens_setting":4096}
+{"idx":333551,"func":"gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const int bgColor)\n{\n\tconst float _angle = (float)((- degrees \/ 180.0f) * M_PI);\n\tconst int src_w = gdImageSX(src);\n\tconst int src_h = gdImageSY(src);\n\tconst unsigned int new_width = abs((int)(src_w*cos(_angle))) + abs((int)(src_h*sin(_angle) + 0.5f));\n\tconst unsigned int new_height = abs((int)(src_w*sin(_angle))) + abs((int)(src_h*cos(_angle) + 0.5f));\n\tconst gdFixed f_0_5 = gd_ftofx(0.5f);\n\tconst gdFixed f_H = gd_itofx(src_h\/2);\n\tconst gdFixed f_W = gd_itofx(src_w\/2);\n\tconst gdFixed f_cos = gd_ftofx(cos(-_angle));\n\tconst gdFixed f_sin = gd_ftofx(sin(-_angle));\n\tconst gdFixed f_1 = gd_itofx(1);\n\tconst gdFixed f_2 = gd_itofx(2);\n\tconst gdFixed f_4 = gd_itofx(4);\n\tconst gdFixed f_6 = gd_itofx(6);\n\tconst gdFixed f_gama = gd_ftofx(1.04f);\n\n\tunsigned int dst_offset_x;\n\tunsigned int dst_offset_y = 0;\n\tunsigned int i;\n\tgdImagePtr dst;\n\n\tdst = gdImageCreateTrueColor(new_width, new_height);\n\n\tif (dst == NULL) {\n\t\treturn NULL;\n\t}\n\tdst->saveAlphaFlag = 1;\n\n\tfor (i=0; i < new_height; i++) {\n\t\tunsigned int j;\n\t\tdst_offset_x = 0;\n\n\t\tfor (j=0; j < new_width; j++) {\n\t\t\tconst gdFixed f_i = gd_itofx((int)i - (int)new_height\/2);\n\t\t\tconst gdFixed f_j = gd_itofx((int)j - (int)new_width\/2);\n\t\t\tconst gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;\n\t\t\tconst gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;\n\t\t\tconst int m = gd_fxtoi(f_m);\n\t\t\tconst int n = gd_fxtoi(f_n);\n\n\t\t\tif ((m > 0) && (m < src_h - 1) && (n > 0) && (n < src_w-1)) {\n\t\t\t\tconst gdFixed f_f = f_m - gd_itofx(m);\n\t\t\t\tconst gdFixed f_g = f_n - gd_itofx(n);\n\t\t\t\tunsigned int src_offset_x[16], src_offset_y[16];\n\t\t\t\tunsigned char red, green, blue, alpha;\n\t\t\t\tgdFixed f_red=0, f_green=0, f_blue=0, f_alpha=0;\n\t\t\t\tint k;\n\n\t\t\t\tif ((m < 1) || (n < 1)) {\n\t\t\t\t\tsrc_offset_x[0] = n;\n\t\t\t\t\tsrc_offset_y[0] = m;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[0] = n - 1;\n\t\t\t\t\tsrc_offset_y[0] = m;\n\t\t\t\t}\n\n\t\t\t\tif (m < 1) {\n\t\t\t\t\tsrc_offset_x[1] = n;\n\t\t\t\t\tsrc_offset_y[1] = m;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[1] = n;\n\t\t\t\t\tsrc_offset_y[1] = m ;\n\t\t\t\t}\n\n\t\t\t\tif ((m < 1) || (n >= src_w-1)) {\n\t\t\t\t\tsrc_offset_x[2] = - 1;\n\t\t\t\t\tsrc_offset_y[2] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[2] = n + 1;\n\t\t\t\t\tsrc_offset_y[2] = m ;\n\t\t\t\t}\n\n\t\t\t\tif ((m < 1) || (n >= src_w-2)) {\n\t\t\t\t\tsrc_offset_x[3] = - 1;\n\t\t\t\t\tsrc_offset_y[3] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[3] = n + 1 + 1;\n\t\t\t\t\tsrc_offset_y[3] = m ;\n\t\t\t\t}\n\n\t\t\t\tif (n < 1) {\n\t\t\t\t\tsrc_offset_x[4] = - 1;\n\t\t\t\t\tsrc_offset_y[4] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[4] = n - 1;\n\t\t\t\t\tsrc_offset_y[4] = m;\n\t\t\t\t}\n\n\t\t\t\tsrc_offset_x[5] = n;\n\t\t\t\tsrc_offset_y[5] = m;\n\t\t\t\tif (n >= src_w-1) {\n\t\t\t\t\tsrc_offset_x[6] = - 1;\n\t\t\t\t\tsrc_offset_y[6] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[6] = n + 1;\n\t\t\t\t\tsrc_offset_y[6] = m;\n\t\t\t\t}\n\n\t\t\t\tif (n >= src_w-2) {\n\t\t\t\t\tsrc_offset_x[7] = - 1;\n\t\t\t\t\tsrc_offset_y[7] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[7] = n + 1 + 1;\n\t\t\t\t\tsrc_offset_y[7] = m;\n\t\t\t\t}\n\n\t\t\t\tif ((m >= src_h-1) || (n < 1)) {\n\t\t\t\t\tsrc_offset_x[8] = - 1;\n\t\t\t\t\tsrc_offset_y[8] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[8] = n - 1;\n\t\t\t\t\tsrc_offset_y[8] = m;\n\t\t\t\t}\n\n\t\t\t\tif (m >= src_h-1) {\n\t\t\t\t\tsrc_offset_x[8] = - 1;\n\t\t\t\t\tsrc_offset_y[8] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[9] = n;\n\t\t\t\t\tsrc_offset_y[9] = m;\n\t\t\t\t}\n\n\t\t\t\tif ((m >= src_h-1) || (n >= src_w-1)) {\n\t\t\t\t\tsrc_offset_x[10] = - 1;\n\t\t\t\t\tsrc_offset_y[10] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[10] = n + 1;\n\t\t\t\t\tsrc_offset_y[10] = m;\n\t\t\t\t}\n\n\t\t\t\tif ((m >= src_h-1) || (n >= src_w-2)) {\n\t\t\t\t\tsrc_offset_x[11] = - 1;\n\t\t\t\t\tsrc_offset_y[11] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[11] = n + 1 + 1;\n\t\t\t\t\tsrc_offset_y[11] = m;\n\t\t\t\t}\n\n\t\t\t\tif ((m >= src_h-2) || (n < 1)) {\n\t\t\t\t\tsrc_offset_x[12] = - 1;\n\t\t\t\t\tsrc_offset_y[12] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[12] = n - 1;\n\t\t\t\t\tsrc_offset_y[12] = m;\n\t\t\t\t}\n\n\t\t\t\tif (m >= src_h-2) {\n\t\t\t\t\tsrc_offset_x[13] = - 1;\n\t\t\t\t\tsrc_offset_y[13] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[13] = n;\n\t\t\t\t\tsrc_offset_y[13] = m;\n\t\t\t\t}\n\n\t\t\t\tif ((m >= src_h-2) || (n >= src_w - 1)) {\n\t\t\t\t\tsrc_offset_x[14] = - 1;\n\t\t\t\t\tsrc_offset_y[14] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[14] = n + 1;\n\t\t\t\t\tsrc_offset_y[14] = m;\n\t\t\t\t}\n\n\t\t\t\tif ((m >= src_h-2) || (n >= src_w-2)) {\n\t\t\t\t\tsrc_offset_x[15] = - 1;\n\t\t\t\t\tsrc_offset_y[15] = - 1;\n\t\t\t\t} else {\n\t\t\t\t\tsrc_offset_x[15] = n  + 1 + 1;\n\t\t\t\t\tsrc_offset_y[15] = m;\n\t\t\t\t}\n\n\t\t\t\tfor (k=-1; k<3; k++) {\n\t\t\t\t\tconst gdFixed f = gd_itofx(k)-f_f;\n\t\t\t\t\tconst gdFixed f_fm1 = f - f_1;\n\t\t\t\t\tconst gdFixed f_fp1 = f + f_1;\n\t\t\t\t\tconst gdFixed f_fp2 = f + f_2;\n\t\t\t\t\tgdFixed f_a = 0, f_b = 0,f_c = 0, f_d = 0;\n\t\t\t\t\tgdFixed f_RY;\n\t\t\t\t\tint l;\n\n\t\t\t\t\tif (f_fp2 > 0) {\n\t\t\t\t\t\tf_a = gd_mulfx(f_fp2,gd_mulfx(f_fp2,f_fp2));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (f_fp1 > 0) {\n\t\t\t\t\t\tf_b = gd_mulfx(f_fp1,gd_mulfx(f_fp1,f_fp1));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (f > 0) {\n\t\t\t\t\t\tf_c = gd_mulfx(f,gd_mulfx(f,f));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (f_fm1 > 0) {\n\t\t\t\t\t\tf_d = gd_mulfx(f_fm1,gd_mulfx(f_fm1,f_fm1));\n\t\t\t\t\t}\n\t\t\t\t\tf_RY = gd_divfx((f_a-gd_mulfx(f_4,f_b)+gd_mulfx(f_6,f_c)-gd_mulfx(f_4,f_d)),f_6);\n\n\t\t\t\t\tfor (l=-1;  l< 3; l++) {\n\t\t\t\t\t\tconst gdFixed f = gd_itofx(l) - f_g;\n\t\t\t\t\t\tconst gdFixed f_fm1 = f - f_1;\n\t\t\t\t\t\tconst gdFixed f_fp1 = f + f_1;\n\t\t\t\t\t\tconst gdFixed f_fp2 = f + f_2;\n\t\t\t\t\t\tgdFixed f_a = 0, f_b = 0, f_c = 0, f_d = 0;\n\t\t\t\t\t\tgdFixed f_RX, f_R;\n\t\t\t\t\t\tconst int _k = ((k + 1) * 4) + (l + 1);\n\t\t\t\t\t\tregister gdFixed f_rs, f_gs, f_bs, f_as;\n\t\t\t\t\t\tregister int c;\n\n\t\t\t\t\t\tif (f_fp2 > 0) {\n\t\t\t\t\t\t\tf_a = gd_mulfx(f_fp2,gd_mulfx(f_fp2,f_fp2));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (f_fp1 > 0) {\n\t\t\t\t\t\t\tf_b = gd_mulfx(f_fp1,gd_mulfx(f_fp1,f_fp1));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (f > 0) {\n\t\t\t\t\t\t\tf_c = gd_mulfx(f,gd_mulfx(f,f));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (f_fm1 > 0) {\n\t\t\t\t\t\t\tf_d = gd_mulfx(f_fm1,gd_mulfx(f_fm1,f_fm1));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tf_RX = gd_divfx((f_a - gd_mulfx(f_4, f_b) + gd_mulfx(f_6, f_c) - gd_mulfx(f_4, f_d)), f_6);\n\t\t\t\t\t\tf_R = gd_mulfx(f_RY, f_RX);\n\n\t\t\t\t\t\tif ((src_offset_x[_k] <= 0) || (src_offset_y[_k] <= 0) || (src_offset_y[_k] >= src_h) || (src_offset_x[_k] >= src_w)) {\n\t\t\t\t\t\t\tc = bgColor;\n\t\t\t\t\t\t} else if ((src_offset_x[_k] <= 1) || (src_offset_y[_k] <= 1) || (src_offset_y[_k] >= (int)src_h - 1) || (src_offset_x[_k] >= (int)src_w - 1)) {\n\t\t\t\t\t\t\tgdFixed f_127 = gd_itofx(127);\n\t\t\t\t\t\t\tc = src->tpixels[src_offset_y[_k]][src_offset_x[_k]];\n\t\t\t\t\t\t\tc = c | (( (int) (gd_fxtof(gd_mulfx(f_R, f_127)) + 50.5f)) << 24);\n\t\t\t\t\t\t\tc = _color_blend(bgColor, c);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tc = src->tpixels[src_offset_y[_k]][src_offset_x[_k]];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tf_rs = gd_itofx(gdTrueColorGetRed(c));\n\t\t\t\t\t\tf_gs = gd_itofx(gdTrueColorGetGreen(c));\n\t\t\t\t\t\tf_bs = gd_itofx(gdTrueColorGetBlue(c));\n\t\t\t\t\t\tf_as = gd_itofx(gdTrueColorGetAlpha(c));\n\n\t\t\t\t\t\tf_red   += gd_mulfx(f_rs, f_R);\n\t\t\t\t\t\tf_green += gd_mulfx(f_gs, f_R);\n\t\t\t\t\t\tf_blue  += gd_mulfx(f_bs, f_R);\n\t\t\t\t\t\tf_alpha += gd_mulfx(f_as, f_R);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tred   = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_red, f_gama)),   0, 255);\n\t\t\t\tgreen = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_green, f_gama)), 0, 255);\n\t\t\t\tblue  = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_blue, f_gama)),  0, 255);\n\t\t\t\talpha = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_alpha, f_gama)), 0, 127);\n\n\t\t\t\tdst->tpixels[dst_offset_y][dst_offset_x] =  gdTrueColorAlpha(red, green, blue, alpha);\n\t\t\t} else {\n\t\t\t\tdst->tpixels[dst_offset_y][dst_offset_x] =  bgColor;\n\t\t\t}\n\t\t\tdst_offset_x++;\n\t\t}\n\n\t\tdst_offset_y++;\n\t}\n\treturn dst;\n}","target":0,"code_token_length":2947,"total_token_length":3183,"max_tokens_setting":4096}
+{"idx":198013,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Checks what we're remapping and inverts the relevant remapping Tensors to\n    \/\/ be maps with key = old ID, value = new ID.\n    std::unordered_map<int64_t, int64_t> old_row_to_new_row_map;\n    std::vector<bool> row_id_present;\n    const Tensor* row_remapping_t;\n    OP_REQUIRES_OK(context, context->input(\"row_remapping\", &row_remapping_t));\n    const auto row_remapping = row_remapping_t->vec<int64_t>();\n    OP_REQUIRES(context, row_remapping.size() == num_rows_,\n                errors::InvalidArgument(strings::StrCat(\n                    \"Size of row_remapping is \", row_remapping.size(),\n                    \" instead of being equal to num_rows=\", num_rows_)));\n    OP_REQUIRES_OK(context, RemapVectorToMap(row_remapping, &row_id_present,\n                                             &old_row_to_new_row_map));\n\n    \/\/ Calculates the min\/max old row ID that we need to read, to save us from\n    \/\/ reading some unnecessary slices of the old tensor.\n    int64_t min_old_row = -1;\n    int64_t max_old_row = -1;\n    for (int i = 0; i < row_remapping.size(); ++i) {\n      if (min_old_row < 0 ||\n          (row_remapping(i) >= 0 && row_remapping(i) < min_old_row)) {\n        min_old_row = row_remapping(i);\n      }\n      if (max_old_row < 0 ||\n          (row_remapping(i) >= 0 && row_remapping(i) > max_old_row)) {\n        max_old_row = row_remapping(i);\n      }\n    }\n\n    \/\/ Processes the remapping for columns.\n    std::unordered_map<int64_t, int64_t> old_col_to_new_col_map;\n    std::vector<bool> col_id_present;\n    const Tensor* col_remapping_t;\n    OP_REQUIRES_OK(context, context->input(\"col_remapping\", &col_remapping_t));\n    const auto col_remapping = col_remapping_t->vec<int64_t>();\n    \/\/ Note that we always \"remap rows\", even when the row vocabulary does\n    \/\/ not change, because partitioning requires a mapping from partitioned\n    \/\/ Variables to the full checkpoints we load.\n    const bool remap_cols = col_remapping.size() > 0;\n    if (remap_cols) {\n      OP_REQUIRES(\n          context, col_remapping.size() == num_cols_,\n          errors::InvalidArgument(strings::StrCat(\n              \"Provided col_remapping, but its size is \", col_remapping.size(),\n              \" instead of being equal to num_cols=\", num_cols_)));\n      OP_REQUIRES_OK(context, RemapVectorToMap(col_remapping, &col_id_present,\n                                               &old_col_to_new_col_map));\n    } else {\n      col_id_present.clear();\n      col_id_present.resize(num_cols_, true);\n    }\n\n    \/\/ Processes the checkpoint source and the provided Tensor name.\n    const Tensor* ckpt_path_t;\n    OP_REQUIRES_OK(context, context->input(\"ckpt_path\", &ckpt_path_t));\n    OP_REQUIRES(\n        context, ckpt_path_t->NumElements() == 1,\n        errors::InvalidArgument(\"The `ckpt_path` tensor must have exactly one \"\n                                \"element, got tensor of shape \",\n                                ckpt_path_t->shape().DebugString()));\n    const string& ckpt_path = ckpt_path_t->scalar<tstring>()();\n    const Tensor* old_tensor_name_t;\n    OP_REQUIRES_OK(context,\n                   context->input(\"old_tensor_name\", &old_tensor_name_t));\n    const string& old_tensor_name = old_tensor_name_t->scalar<tstring>()();\n\n    LOG(INFO) << \"Processing checkpoint : \" << ckpt_path;\n    BundleReader reader(context->env(), ckpt_path);\n    OP_REQUIRES_OK(context, reader.status());\n\n    DataType tensor_type;\n    TensorShape tensor_shape;\n    OP_REQUIRES_OK(context, reader.LookupDtypeAndShape(\n                                old_tensor_name, &tensor_type, &tensor_shape));\n    OP_REQUIRES(context, tensor_type == DT_FLOAT,\n                errors::InvalidArgument(strings::StrCat(\n                    \"Tensor \", old_tensor_name, \" has invalid type \",\n                    DataTypeString(tensor_type), \" instead of expected type \",\n                    DataTypeString(DT_FLOAT))));\n    \/\/ This op is limited to loading Tensors of rank 2 (matrices).\n    OP_REQUIRES(\n        context, tensor_shape.dims() == 2,\n        errors::InvalidArgument(strings::StrCat(\n            \"Tensor \", old_tensor_name, \" has shape \",\n            tensor_shape.DebugString(), \" of invalid rank \",\n            tensor_shape.dims(), \" instead of expected shape of rank 2.\")));\n\n    if (!remap_cols) {\n      \/\/ TODO(weiho): Consider relaxing this restriction to allow partial column\n      \/\/ loading (even when no column remapping is specified) if there turns out\n      \/\/ to be a use case for it.\n      OP_REQUIRES(context, num_cols_ == tensor_shape.dim_size(1),\n                  errors::InvalidArgument(strings::StrCat(\n                      \"Tensor \", old_tensor_name, \" has shape \",\n                      tensor_shape.DebugString(),\n                      \", where the size of its 2nd dimension is \",\n                      tensor_shape.dim_size(1),\n                      \" instead of being equal to num_cols=\", num_cols_)));\n    }\n\n    \/\/ Uses TensorSlice to potentially load the old tensor in chunks in case\n    \/\/ memory usage is a concern.\n    std::vector<TensorSlice> tensor_slices;\n    TensorSlice slice(tensor_shape.dims());\n    if (min_old_row >= 0 && max_old_row >= 0) {\n      int64_t row_start = min_old_row;\n      \/\/ TODO(weiho): Given the list of old row IDs of interest (the keys of\n      \/\/ old_row_to_new_row_map), we could also try something smarter to\n      \/\/ find some minimal set of covering ranges for the list of old row IDs\n      \/\/ such that the size of each range is less than max_rows_in_memory_.\n      while (row_start <= max_old_row) {\n        const int64_t slice_length =\n            max_rows_in_memory_ <= 0\n                \/\/ If max_rows_in_memory_ <= 0, we just load the entire chunk.\n                ? max_old_row - row_start + 1\n                : std::min(max_rows_in_memory_, max_old_row - row_start + 1);\n        slice.set_start(0, row_start);\n        slice.set_length(0, slice_length);\n        tensor_slices.push_back(slice);\n        row_start += slice_length;\n      }\n    }\n\n    \/\/ Allocates the output matrix.\n    Tensor* output_matrix_t = nullptr;\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(\"output_matrix\",\n                                            TensorShape({num_rows_, num_cols_}),\n                                            &output_matrix_t));\n    auto output_matrix = output_matrix_t->matrix<float>();\n\n    \/\/ Iterates through tensor slices and copies over values from the old tensor\n    \/\/ to the output matrix.\n    int64_t row_index = min_old_row;\n    int64_t rows_copied = 0;\n    Tensor loaded_tensor_t;\n    for (const TensorSlice& tensor_slice : tensor_slices) {\n      LOG(INFO) << \"Loading slice \" << tensor_slice.DebugString();\n      TensorShape slice_shape;\n      OP_REQUIRES_OK(context,\n                     tensor_slice.SliceTensorShape(tensor_shape, &slice_shape));\n      \/\/ Potentially re-allocates the tensor buffer since the last slice may\n      \/\/ have fewer rows than the other slices.\n      if (loaded_tensor_t.shape() != slice_shape) {\n        loaded_tensor_t = Tensor(DT_FLOAT, slice_shape);\n      }\n      OP_REQUIRES_OK(context, reader.LookupSlice(old_tensor_name, tensor_slice,\n                                                 &loaded_tensor_t));\n\n      \/\/ Iterates through the old loaded tensor slice row-by-row.\n      for (int row = 0; row < loaded_tensor_t.dim_size(0); ++row, ++row_index) {\n        if (row_index % 500000 == min_old_row) {\n          LOG(INFO) << \"Processing old row \" << row_index;\n        }\n\n        \/\/ If the old row ID is not found in old_row_to_new_row_map, continue\n        \/\/ to the next row; otherwise, copy it to the output matrix.\n        const int64_t* new_row_ptr =\n            gtl::FindOrNull(old_row_to_new_row_map, row_index);\n        if (new_row_ptr == nullptr) {\n          continue;\n        }\n        ++rows_copied;\n        const int64_t new_row = *new_row_ptr;\n\n        \/\/ Copies over the row element-by-element, in case remapping is needed\n        \/\/ along the column axis.\n        const auto& loaded_tensor = loaded_tensor_t.matrix<float>();\n        for (int old_col = 0; old_col < loaded_tensor_t.dim_size(1);\n             ++old_col) {\n          int64_t new_col = old_col;\n          if (remap_cols) {\n            const int64_t* new_col_ptr =\n                gtl::FindOrNull(old_col_to_new_col_map, old_col);\n            if (new_col_ptr == nullptr) {\n              \/\/ Column remapping is specified, but this column is not found in\n              \/\/ old_col_to_new_col_map, so we leave it uninitialized, to be\n              \/\/ filled in with initializing_values later.\n              continue;\n            }\n            new_col = *new_col_ptr;\n          }\n\n          OP_REQUIRES(context,\n                      new_row < num_rows_ && new_col < num_cols_ &&\n                          new_row >= 0 && new_col >= 0,\n                      errors::Internal(strings::StrCat(\n                          \"new_row=\", new_row, \" and new_col=\", new_col,\n                          \" should have been less than num_rows_=\", num_rows_,\n                          \" and num_cols_=\", num_cols_,\n                          \" and non-negative. This should never have happened \"\n                          \"if the code were correct. Please file a bug.\")));\n          output_matrix(new_row, new_col) = loaded_tensor(row, old_col);\n        }\n      }\n    }\n    LOG(INFO) << \"Copied \" << rows_copied << \" rows from old matrix (with \"\n              << tensor_shape.dim_size(0) << \" rows) to new matrix (with \"\n              << num_rows_ << \" rows).\";\n\n    \/\/ At this point, there are potentially whole rows\/columns uninitialized\n    \/\/ (corresponding to the indices where row_id_present\/col_id_present are\n    \/\/ false). We fill this in cell-by-cell using row_id_present and\n    \/\/ col_id_present while dequeuing from the initializing_values vector.\n    const Tensor* initializing_values_t;\n    OP_REQUIRES_OK(\n        context, context->input(\"initializing_values\", &initializing_values_t));\n    const auto initializing_values = initializing_values_t->flat<float>();\n    int64_t initializing_values_index = 0;\n    for (int i = 0; i < num_rows_; ++i) {\n      for (int j = 0; j < num_cols_; ++j) {\n        if (row_id_present[i] && col_id_present[j]) continue;\n        OP_REQUIRES(\n            context, initializing_values_index < initializing_values.size(),\n            errors::InvalidArgument(\n                \"initializing_values contained \", initializing_values.size(),\n                \" elements, but more missing values remain.\"));\n        output_matrix(i, j) = initializing_values(initializing_values_index);\n        ++initializing_values_index;\n      }\n    }\n\n    \/\/ Checks that we used all the given initializing values.\n    OP_REQUIRES(\n        context, initializing_values_index == initializing_values.size(),\n        errors::InvalidArgument(\n            \"initializing_values contained \", initializing_values.size(),\n            \" elements, but only \", initializing_values_index,\n            \" elements were used to fill in missing values.\"));\n  }","target":1,"code_token_length":2516,"total_token_length":2752,"max_tokens_setting":4096}
+{"idx":202256,"func":"void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &inPen)\n{\n#ifdef QT_DEBUG_DRAW\n    qDebug() << \"QPaintEngineEx::stroke()\" << pen;\n#endif\n\n    Q_D(QPaintEngineEx);\n\n    if (path.isEmpty())\n        return;\n\n    if (!d->strokeHandler) {\n        d->strokeHandler = new StrokeHandler(path.elementCount()+4);\n        d->stroker.setMoveToHook(qpaintengineex_moveTo);\n        d->stroker.setLineToHook(qpaintengineex_lineTo);\n        d->stroker.setCubicToHook(qpaintengineex_cubicTo);\n    }\n\n    QRectF clipRect;\n    QPen pen = inPen;\n    if (pen.style() > Qt::SolidLine) {\n        QRectF cpRect = path.controlPointRect();\n        const QTransform &xf = state()->matrix;\n        if (pen.isCosmetic()) {\n            clipRect = d->exDeviceRect;\n            cpRect.translate(xf.dx(), xf.dy());\n        } else {\n            clipRect = xf.inverted().mapRect(QRectF(d->exDeviceRect));\n        }\n        \/\/ Check to avoid generating unwieldy amount of dashes that will not be visible anyway\n        QRectF extentRect = cpRect & clipRect;\n        qreal extent = qMax(extentRect.width(), extentRect.height());\n        qreal patternLength = 0;\n        const QList<qreal> pattern = pen.dashPattern();\n        const int patternSize = qMin(pattern.size(), 32);\n        for (int i = 0; i < patternSize; i++)\n            patternLength += qMax(pattern.at(i), qreal(0));\n        if (pen.widthF())\n            patternLength *= pen.widthF();\n        if (qFuzzyIsNull(patternLength)) {\n            pen.setStyle(Qt::NoPen);\n        } else if (extent \/ patternLength > 10000) {\n            \/\/ approximate stream of tiny dashes with semi-transparent solid line\n            pen.setStyle(Qt::SolidLine);\n            QColor color(pen.color());\n            color.setAlpha(color.alpha() \/ 2);\n            pen.setColor(color);\n        }\n    }\n\n    if (!qpen_fast_equals(pen, d->strokerPen)) {\n        d->strokerPen = pen;\n        d->stroker.setJoinStyle(pen.joinStyle());\n        d->stroker.setCapStyle(pen.capStyle());\n        d->stroker.setMiterLimit(pen.miterLimit());\n        qreal penWidth = pen.widthF();\n        if (penWidth == 0)\n            d->stroker.setStrokeWidth(1);\n        else\n            d->stroker.setStrokeWidth(penWidth);\n\n        Qt::PenStyle style = pen.style();\n        if (style == Qt::SolidLine) {\n            d->activeStroker = &d->stroker;\n        } else if (style == Qt::NoPen) {\n            d->activeStroker = nullptr;\n        } else {\n            d->dasher.setDashPattern(pen.dashPattern());\n            d->dasher.setDashOffset(pen.dashOffset());\n            d->activeStroker = &d->dasher;\n        }\n    }\n\n    if (!d->activeStroker) {\n        return;\n    }\n\n    if (!clipRect.isNull())\n        d->activeStroker->setClipRect(clipRect);\n\n    if (d->activeStroker == &d->stroker)\n        d->stroker.setForceOpen(path.hasExplicitOpen());\n\n    const QPainterPath::ElementType *types = path.elements();\n    const qreal *points = path.points();\n    int pointCount = path.elementCount();\n\n    const qreal *lastPoint = points + (pointCount<<1);\n\n    d->strokeHandler->types.reset();\n    d->strokeHandler->pts.reset();\n\n    \/\/ Some engines might decide to optimize for the non-shape hint later on...\n    uint flags = QVectorPath::WindingFill;\n\n    if (path.elementCount() > 2)\n        flags |= QVectorPath::NonConvexShapeMask;\n\n    if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)\n        flags |= QVectorPath::CurvedShapeMask;\n\n    \/\/ ### Perspective Xforms are currently not supported...\n    if (!pen.isCosmetic()) {\n        \/\/ We include cosmetic pens in this case to avoid having to\n        \/\/ change the current transform. Normal transformed,\n        \/\/ non-cosmetic pens will be transformed as part of fill\n        \/\/ later, so they are also covered here..\n        d->activeStroker->setCurveThresholdFromTransform(state()->matrix);\n        d->activeStroker->begin(d->strokeHandler);\n        if (types) {\n            while (points < lastPoint) {\n                switch (*types) {\n                case QPainterPath::MoveToElement:\n                    d->activeStroker->moveTo(points[0], points[1]);\n                    points += 2;\n                    ++types;\n                    break;\n                case QPainterPath::LineToElement:\n                    d->activeStroker->lineTo(points[0], points[1]);\n                    points += 2;\n                    ++types;\n                    break;\n                case QPainterPath::CurveToElement:\n                    d->activeStroker->cubicTo(points[0], points[1],\n                                              points[2], points[3],\n                                              points[4], points[5]);\n                    points += 6;\n                    types += 3;\n                    flags |= QVectorPath::CurvedShapeMask;\n                    break;\n                default:\n                    break;\n                }\n            }\n            if (path.hasImplicitClose())\n                d->activeStroker->lineTo(path.points()[0], path.points()[1]);\n\n        } else {\n            d->activeStroker->moveTo(points[0], points[1]);\n            points += 2;\n            while (points < lastPoint) {\n                d->activeStroker->lineTo(points[0], points[1]);\n                points += 2;\n            }\n            if (path.hasImplicitClose())\n                d->activeStroker->lineTo(path.points()[0], path.points()[1]);\n        }\n        d->activeStroker->end();\n\n        if (!d->strokeHandler->types.size()) \/\/ an empty path...\n            return;\n\n        QVectorPath strokePath(d->strokeHandler->pts.data(),\n                               d->strokeHandler->types.size(),\n                               d->strokeHandler->types.data(),\n                               flags);\n        fill(strokePath, pen.brush());\n    } else {\n        \/\/ For cosmetic pens we need a bit of trickery... We to process xform the input points\n        if (state()->matrix.type() >= QTransform::TxProject) {\n            QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());\n            d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());\n        } else {\n            d->activeStroker->setCurveThresholdFromTransform(QTransform());\n            d->activeStroker->begin(d->strokeHandler);\n            if (types) {\n                while (points < lastPoint) {\n                    switch (*types) {\n                    case QPainterPath::MoveToElement: {\n                        QPointF pt = (*(const QPointF *) points) * state()->matrix;\n                        d->activeStroker->moveTo(pt.x(), pt.y());\n                        points += 2;\n                        ++types;\n                        break;\n                    }\n                    case QPainterPath::LineToElement: {\n                        QPointF pt = (*(const QPointF *) points) * state()->matrix;\n                        d->activeStroker->lineTo(pt.x(), pt.y());\n                        points += 2;\n                        ++types;\n                        break;\n                    }\n                    case QPainterPath::CurveToElement: {\n                        QPointF c1 = ((const QPointF *) points)[0] * state()->matrix;\n                        QPointF c2 = ((const QPointF *) points)[1] * state()->matrix;\n                        QPointF e =  ((const QPointF *) points)[2] * state()->matrix;\n                        d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());\n                        points += 6;\n                        types += 3;\n                        flags |= QVectorPath::CurvedShapeMask;\n                        break;\n                    }\n                    default:\n                        break;\n                    }\n                }\n                if (path.hasImplicitClose()) {\n                    QPointF pt = * ((const QPointF *) path.points()) * state()->matrix;\n                    d->activeStroker->lineTo(pt.x(), pt.y());\n                }\n\n            } else {\n                QPointF p = ((const QPointF *)points)[0] * state()->matrix;\n                d->activeStroker->moveTo(p.x(), p.y());\n                points += 2;\n                while (points < lastPoint) {\n                    QPointF p = ((const QPointF *)points)[0] * state()->matrix;\n                    d->activeStroker->lineTo(p.x(), p.y());\n                    points += 2;\n                }\n                if (path.hasImplicitClose())\n                    d->activeStroker->lineTo(p.x(), p.y());\n            }\n            d->activeStroker->end();\n        }\n\n        QVectorPath strokePath(d->strokeHandler->pts.data(),\n                               d->strokeHandler->types.size(),\n                               d->strokeHandler->types.data(),\n                               flags);\n\n        QTransform xform = state()->matrix;\n        state()->matrix = QTransform();\n        transformChanged();\n\n        QBrush brush = pen.brush();\n        if (qbrush_style(brush) != Qt::SolidPattern)\n            brush.setTransform(brush.transform() * xform);\n\n        fill(strokePath, brush);\n\n        state()->matrix = xform;\n        transformChanged();\n    }\n}","target":1,"code_token_length":2014,"total_token_length":2250,"max_tokens_setting":4096}
+{"idx":267985,"func":"static int string_scan_range(RList *list, RBinFile *bf, int min,\n\t\t\t      const ut64 from, const ut64 to, int type, int raw, RBinSection *section) {\n\tRBin *bin = bf->rbin;\n\tut8 tmp[R_STRING_SCAN_BUFFER_SIZE];\n\tut64 str_start, needle = from;\n\tint count = 0, i, rc, runes;\n\tint str_type = R_STRING_TYPE_DETECT;\n\n\t\/\/ if list is null it means its gonna dump\n\tr_return_val_if_fail (bf, -1);\n\n\tif (type == -1) {\n\t\ttype = R_STRING_TYPE_DETECT;\n\t}\n\tif (from == to) {\n\t\treturn 0;\n\t}\n\tif (from > to) {\n\t\teprintf (\"Invalid range to find strings 0x%\"PFMT64x\" .. 0x%\"PFMT64x\"\\n\", from, to);\n\t\treturn -1;\n\t}\n\tst64 len = (st64)(to - from);\n\tif (len < 1 || len > ST32_MAX) {\n\t\teprintf (\"String scan range is invalid (%\"PFMT64d\" bytes)\\n\", len);\n\t\treturn -1;\n\t}\n\tut8 *buf = calloc (len, 1);\n\tif (!buf || !min) {\n\t\tfree (buf);\n\t\treturn -1;\n\t}\n\tst64 vdelta = 0, pdelta = 0;\n\tRBinSection *s = NULL;\n\tbool ascii_only = false;\n\tPJ *pj = NULL;\n\tif (bf->strmode == R_MODE_JSON && !list) {\n\t\tpj = pj_new ();\n\t\tif (pj) {\n\t\t\tpj_a (pj);\n\t\t}\n\t}\n\tr_buf_read_at (bf->buf, from, buf, len);\n\tchar *charset = r_sys_getenv (\"RABIN2_CHARSET\");\n\tif (!R_STR_ISEMPTY (charset)) {\n\t\tRCharset *ch = r_charset_new ();\n\t\tif (r_charset_use (ch, charset)) {\n\t\t\tint outlen = len * 4;\n\t\t\tut8 *out = calloc (len, 4);\n\t\t\tif (out) {\n\t\t\t\tint res = r_charset_encode_str (ch, out, outlen, buf, len);\n\t\t\t\tint i;\n\t\t\t\t\/\/ TODO unknown chars should be translated to null bytes\n\t\t\t\tfor (i = 0; i < res; i++) {\n\t\t\t\t\tif (out[i] == '?') {\n\t\t\t\t\t\tout[i] = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlen = res;\n\t\t\t\tfree (buf);\n\t\t\t\tbuf = out;\n\t\t\t} else {\n\t\t\t\teprintf (\"Cannot allocate\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"Invalid value for RABIN2_CHARSET.\\n\");\n\t\t}\n\t\tr_charset_free (ch);\n\t}\n\tfree (charset);\n\tRConsIsBreaked is_breaked = (bin && bin->consb.is_breaked)? bin->consb.is_breaked: NULL;\n\t\/\/ may oobread\n\twhile (needle < to && needle < UT64_MAX - 4) {\n\t\tif (is_breaked && is_breaked ()) {\n\t\t\tbreak;\n\t\t}\n\t\t\/\/ smol optimization\n\t\tif (needle < to - 4) {\n\t\t\tut32 n1 = r_read_le32 (buf + (needle - from));\n\t\t\tif (!n1) {\n\t\t\t\tneedle += 4;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\trc = r_utf8_decode (buf + (needle - from), to - needle, NULL);\n\t\tif (!rc) {\n\t\t\tneedle++;\n\t\t\tcontinue;\n\t\t}\n\t\tbool addr_aligned = !(needle % 4);\n\n\t\tif (type == R_STRING_TYPE_DETECT) {\n\t\t\tchar *w = (char *)buf + (needle + rc - from);\n\t\t\tif (((to - needle) > 8 + rc)) {\n\t\t\t\t\/\/ TODO: support le and be\n\t\t\t\tbool is_wide32le = (needle + rc + 2 < to) && (!w[0] && !w[1] && !w[2] && w[3] && !w[4]);\n\t\t\t\t\/\/ reduce false positives\n\t\t\t\tif (is_wide32le) {\n\t\t\t\t\tif (!w[5] && !w[6] && w[7] && w[8]) {\n\t\t\t\t\t\tis_wide32le = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!addr_aligned) {\n\t\t\t\t\tis_wide32le = false;\n\t\t\t\t}\n\t\t\t\t\/\/\/is_wide32be &= (n1 < 0xff && n11 < 0xff); \/\/ false; \/\/ n11 < 0xff;\n\t\t\t\tif (is_wide32le  && addr_aligned) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_WIDE32; \/\/ asume big endian,is there little endian w32?\n\t\t\t\t} else {\n\t\t\t\t\t\/\/ bool is_wide = (n1 && n2 && n1 < 0xff && (!n2 || n2 < 0xff));\n\t\t\t\t\tbool is_wide = needle + rc + 4 < to && !w[0] && w[1] && !w[2] && w[3] && !w[4];\n\t\t\t\t\tstr_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8; \/\/ could be charset if set :?\n\t\t\t\t} else {\n\t\t\t\t\tstr_type = R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (type == R_STRING_TYPE_UTF8) {\n\t\t\tstr_type = R_STRING_TYPE_ASCII; \/\/ initial assumption\n\t\t} else {\n\t\t\tstr_type = type;\n\t\t}\n\t\trunes = 0;\n\t\tstr_start = needle;\n\n\t\t\/* Eat a whole C string *\/\n\t\tfor (i = 0; i < sizeof (tmp) - 4 && needle < to; i += rc) {\n\t\t\tRRune r = {0};\n\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\trc = r_utf32le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc) {\n\t\t\t\t\trc = 4;\n\t\t\t\t}\n\t\t\t} else if (str_type == R_STRING_TYPE_WIDE) {\n\t\t\t\trc = r_utf16le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc == 1) {\n\t\t\t\t\trc = 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trc = r_utf8_decode (buf + (needle - from), to - needle, &r);\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/* Invalid sequence detected *\/\n\t\t\tif (!rc || (ascii_only && r > 0x7f)) {\n\t\t\t\tneedle++;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tneedle += rc;\n\n\t\t\tif (r_isprint (r) && r != '\\\\') {\n\t\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\t\tif (r == 0xff) {\n\t\t\t\t\t\tr = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trc = r_utf8_encode (tmp + i, r);\n\t\t\t\trunes++;\n\t\t\t\t\/* Print the escape code *\/\n\t\t\t} else if (r && r < 0x100 && strchr (\"\\b\\v\\f\\n\\r\\t\\a\\033\\\\\", (char)r)) {\n\t\t\t\tif ((i + 32) < sizeof (tmp) && r < 93) {\n\t\t\t\t\ttmp[i + 0] = '\\\\';\n\t\t\t\t\ttmp[i + 1] = \"       abtnvfr             e  \"\n\t\t\t\t\t             \"                              \"\n\t\t\t\t\t             \"                              \"\n\t\t\t\t\t             \"  \\\\\"[r];\n\t\t\t\t} else {\n\t\t\t\t\t\/\/ string too long\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\trc = 2;\n\t\t\t\trunes++;\n\t\t\t} else {\n\t\t\t\t\/* \\0 marks the end of C-strings *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\ttmp[i++] = '\\0';\n\n\t\tif (runes < min && runes >= 2 && str_type == R_STRING_TYPE_ASCII && needle < to) {\n\t\t\t\/\/ back up past the \\0 to the last char just in case it starts a wide string\n\t\t\tneedle -= 2;\n\t\t}\n\t\tif (runes >= min) {\n\t\t\t\/\/ reduce false positives\n\t\t\tint j, num_blocks, *block_list;\n\t\t\tint *freq_list = NULL, expected_ascii, actual_ascii, num_chars;\n\t\t\tif (str_type == R_STRING_TYPE_ASCII) {\n\t\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\t\tchar ch = tmp[j];\n\t\t\t\t\tif (ch != '\\n' && ch != '\\r' && ch != '\\t') {\n\t\t\t\t\t\tif (!IS_PRINTABLE (tmp[j])) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (str_type) {\n\t\t\tcase R_STRING_TYPE_UTF8:\n\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\tnum_blocks = 0;\n\t\t\t\tblock_list = r_utf_block_list ((const ut8*)tmp, i - 1,\n\t\t\t\t\t\tstr_type == R_STRING_TYPE_WIDE? &freq_list: NULL);\n\t\t\t\tif (block_list) {\n\t\t\t\t\tfor (j = 0; block_list[j] != -1; j++) {\n\t\t\t\t\t\tnum_blocks++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (freq_list) {\n\t\t\t\t\tnum_chars = 0;\n\t\t\t\t\tactual_ascii = 0;\n\t\t\t\t\tfor (j = 0; freq_list[j] != -1; j++) {\n\t\t\t\t\t\tnum_chars += freq_list[j];\n\t\t\t\t\t\tif (!block_list[j]) { \/\/ ASCII\n\t\t\t\t\t\t\tactual_ascii = freq_list[j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfree (freq_list);\n\t\t\t\t\texpected_ascii = num_blocks ? num_chars \/ num_blocks : 0;\n\t\t\t\t\tif (actual_ascii > expected_ascii) {\n\t\t\t\t\t\tascii_only = true;\n\t\t\t\t\t\tneedle = str_start;\n\t\t\t\t\t\tfree (block_list);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfree (block_list);\n\t\t\t\tif (num_blocks > R_STRING_MAX_UNI_BLOCKS) {\n\t\t\t\t\tneedle++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tRBinString *bs = R_NEW0 (RBinString);\n\t\t\tif (!bs) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbs->type = str_type;\n\t\t\tbs->length = runes;\n\t\t\tbs->size = needle - str_start;\n\t\t\tbs->ordinal = count++;\n\t\t\t\/\/ TODO: move into adjust_offset\n\t\t\tswitch (str_type) {\n\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\t\tif (str_start - from > 1) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 2 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 2; \/\/ \\xff\\xfe\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\tif (str_start - from > 3) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 4 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 4; \/\/ \\xff\\xfe\\x00\\x00\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!s) {\n\t\t\t\tif (section) {\n\t\t\t\t\ts = section;\n\t\t\t\t} else if (bf->o) {\n\t\t\t\t\ts = r_bin_get_section_at (bf->o, str_start, false);\n\t\t\t\t}\n\t\t\t\tif (s) {\n\t\t\t\t\tvdelta = s->vaddr;\n\t\t\t\t\tpdelta = s->paddr;\n\t\t\t\t}\n\t\t\t}\n\t\t\tut64 baddr = bf->loadaddr && bf->o? bf->o->baddr: bf->loadaddr;\n\t\t\tbs->paddr = str_start + baddr;\n\t\t\tbs->vaddr = str_start - pdelta + vdelta + baddr;\n\t\t\tbs->string = r_str_ndup ((const char *)tmp, i);\n\t\t\tif (list) {\n\t\t\t\tr_list_append (list, bs);\n\t\t\t\tif (bf->o) {\n\t\t\t\t\tht_up_insert (bf->o->strings_db, bs->vaddr, bs);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint_string (bf, bs, raw, pj);\n\t\t\t\tr_bin_string_free (bs);\n\t\t\t}\n\t\t\tif (from == 0 && to == bf->size) {\n\t\t\t\t\/* force lookup section at the next one *\/\n\t\t\t\ts = NULL;\n\t\t\t}\n\t\t}\n\t\tascii_only = false;\n\t}\n\tfree (buf);\n\tif (pj) {\n\t\tpj_end (pj);\n\t\tif (bin) {\n\t\t\tRIO *io = bin->iob.io;\n\t\t\tif (io) {\n\t\t\t\tio->cb_printf (\"%s\", pj_string (pj));\n\t\t\t}\n\t\t}\n\t\tpj_free (pj);\n\t}\n\treturn count;\n}","target":0,"code_token_length":2806,"total_token_length":3042,"max_tokens_setting":4096}
+{"idx":439141,"func":"static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  char\n    colorspace[MaxTextExtent],\n    text[MaxTextExtent];\n\n  double\n    x_offset,\n    y_offset;\n\n  Image\n    *image;\n\n  IndexPacket\n    *indexes;\n\n  MagickBooleanType\n    status;\n\n  MagickPixelPacket\n    pixel;\n\n  QuantumAny\n    range;\n\n  register ssize_t\n    i,\n    x;\n\n  register PixelPacket\n    *q;\n\n  ssize_t\n    count,\n    type,\n    y;\n\n  unsigned long\n    depth,\n    height,\n    max_value,\n    width;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  (void) memset(text,0,sizeof(text));\n  (void) ReadBlobString(image,text);\n  if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  x_offset=(-1.0);\n  y_offset=(-1.0);\n  do\n  {\n    width=0;\n    height=0;\n    max_value=0;\n    *colorspace='\\0';\n    count=(ssize_t) sscanf(text+32,\"%lu,%lu,%lu,%32s\",&width,&height,&max_value,\n      colorspace);\n    if ((count != 4) || (width == 0) || (height == 0) || (max_value == 0))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    image->columns=width;\n    image->rows=height;\n    if ((max_value == 0) || (max_value > 4294967295U))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;\n    image->depth=depth;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status != MagickFalse)\n      status=ResetImagePixels(image,&image->exception);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    LocaleLower(colorspace);\n    i=(ssize_t) strlen(colorspace)-1;\n    image->matte=MagickFalse;\n    if ((i > 0) && (colorspace[i] == 'a'))\n      {\n        colorspace[i]='\\0';\n        image->matte=MagickTrue;\n      }\n    type=ParseCommandOption(MagickColorspaceOptions,MagickFalse,colorspace);\n    if (type < 0)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    image->colorspace=(ColorspaceType) type;\n    (void) memset(&pixel,0,sizeof(pixel));\n    (void) SetImageBackgroundColor(image);\n    range=GetQuantumRange(image->depth);\n    status=MagickTrue;\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      double\n        blue,\n        green,\n        index,\n        opacity,\n        red;\n\n      if (status == MagickFalse)\n        break;\n      red=0.0;\n      green=0.0;\n      blue=0.0;\n      index=0.0;\n      opacity=0.0;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        if (ReadBlobString(image,text) == (char *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        switch (image->colorspace)\n        {\n          case LinearGRAYColorspace:\n          case GRAYColorspace:\n          {\n            if (image->matte != MagickFalse)\n              {\n                (void) sscanf(text,\"%lf,%lf: (%lf%*[%,]%lf%*[%,]\",&x_offset,\n                  &y_offset,&red,&opacity);\n                green=red;\n                blue=red;\n                break;\n              }\n            (void) sscanf(text,\"%lf,%lf: (%lf%*[%,]\",&x_offset,&y_offset,&red);\n            green=red;\n            blue=red;\n            break;\n          }\n          case CMYKColorspace:\n          {\n            if (image->matte != MagickFalse)\n              {\n                (void) sscanf(text,\n                  \"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\",\n                  &x_offset,&y_offset,&red,&green,&blue,&index,&opacity);\n                break;\n              }\n            (void) sscanf(text,\n              \"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\",&x_offset,\n              &y_offset,&red,&green,&blue,&index);\n            break;\n          }\n          default:\n          {\n            if (image->matte != MagickFalse)\n              {\n                (void) sscanf(text,\n                  \"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]\",\n                  &x_offset,&y_offset,&red,&green,&blue,&opacity);\n                break;\n              }\n            (void) sscanf(text,\"%lf,%lf: (%lf%*[%,]%lf%*[%,]%lf%*[%,]\",\n              &x_offset,&y_offset,&red,&green,&blue);\n            break;\n          }\n        }\n        if (strchr(text,'%') != (char *) NULL)\n          {\n            red*=0.01*range;\n            green*=0.01*range;\n            blue*=0.01*range;\n            index*=0.01*range;\n            opacity*=0.01*range;\n          }\n        if (image->colorspace == LabColorspace)\n          {\n            green+=(range+1)\/2.0;\n            blue+=(range+1)\/2.0;\n          }\n        pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (red+0.5),\n          range);\n        pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (green+0.5),\n          range);\n        pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (blue+0.5),\n          range);\n        pixel.index=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (index+0.5),\n          range);\n        pixel.opacity=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (opacity+\n          0.5),range);\n        q=GetAuthenticPixels(image,(ssize_t) x_offset,(ssize_t) y_offset,1,1,\n          exception);\n        if (q == (PixelPacket *) NULL)\n          continue;\n        SetPixelRed(q,pixel.red);\n        SetPixelGreen(q,pixel.green);\n        SetPixelBlue(q,pixel.blue);\n        if (image->colorspace == CMYKColorspace)\n          {\n            indexes=GetAuthenticIndexQueue(image);\n            SetPixelIndex(indexes,pixel.index);\n          }\n        if (image->matte != MagickFalse)\n          SetPixelAlpha(q,pixel.opacity);\n        if (SyncAuthenticPixels(image,exception) == MagickFalse)\n          {\n            status=MagickFalse;\n            break;\n          }\n      }\n    }\n    if (status == MagickFalse)\n      break;\n    *text='\\0';\n    (void) ReadBlobString(image,text);\n    if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":1914,"total_token_length":2150,"max_tokens_setting":4096}
+{"idx":502659,"func":"BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)\n{\n    int i, j;\n    BIO *out = NULL, *btmp = NULL, *etmp = NULL, *bio = NULL;\n    unsigned char *tmp = NULL;\n    X509_ALGOR *xa;\n    ASN1_OCTET_STRING *data_body = NULL;\n    const EVP_MD *evp_md;\n    const EVP_CIPHER *evp_cipher = NULL;\n    EVP_CIPHER_CTX *evp_ctx = NULL;\n    X509_ALGOR *enc_alg = NULL;\n    STACK_OF(X509_ALGOR) *md_sk = NULL;\n    STACK_OF(PKCS7_RECIP_INFO) *rsk = NULL;\n    PKCS7_RECIP_INFO *ri = NULL;\n\n    if (p7 == NULL) {\n        PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_INVALID_NULL_POINTER);\n        return NULL;\n    }\n\n    if (p7->d.ptr == NULL) {\n        PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_NO_CONTENT);\n        return NULL;\n    }\n\n    i = OBJ_obj2nid(p7->type);\n    p7->state = PKCS7_S_HEADER;\n\n    switch (i) {\n    case NID_pkcs7_signed:\n        \/*\n         * p7->d.sign->contents is a PKCS7 structure consisting of a contentType\n         * field and optional content.\n         * data_body is NULL if that structure has no (=detached) content\n         * or if the contentType is wrong (i.e., not \"data\").\n         *\/\n        data_body = PKCS7_get_octet_string(p7->d.sign->contents);\n        md_sk = p7->d.sign->md_algs;\n        break;\n    case NID_pkcs7_signedAndEnveloped:\n        rsk = p7->d.signed_and_enveloped->recipientinfo;\n        md_sk = p7->d.signed_and_enveloped->md_algs;\n        \/* data_body is NULL if the optional EncryptedContent is missing. *\/\n        data_body = p7->d.signed_and_enveloped->enc_data->enc_data;\n        enc_alg = p7->d.signed_and_enveloped->enc_data->algorithm;\n        evp_cipher = EVP_get_cipherbyobj(enc_alg->algorithm);\n        if (evp_cipher == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                     PKCS7_R_UNSUPPORTED_CIPHER_TYPE);\n            goto err;\n        }\n        break;\n    case NID_pkcs7_enveloped:\n        rsk = p7->d.enveloped->recipientinfo;\n        enc_alg = p7->d.enveloped->enc_data->algorithm;\n        \/* data_body is NULL if the optional EncryptedContent is missing. *\/\n        data_body = p7->d.enveloped->enc_data->enc_data;\n        evp_cipher = EVP_get_cipherbyobj(enc_alg->algorithm);\n        if (evp_cipher == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                     PKCS7_R_UNSUPPORTED_CIPHER_TYPE);\n            goto err;\n        }\n        break;\n    default:\n        PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_UNSUPPORTED_CONTENT_TYPE);\n        goto err;\n    }\n\n    \/* Detached content must be supplied via in_bio instead. *\/\n    if (data_body == NULL && in_bio == NULL) {\n        PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_NO_CONTENT);\n        goto err;\n    }\n\n    \/* We will be checking the signature *\/\n    if (md_sk != NULL) {\n        for (i = 0; i < sk_X509_ALGOR_num(md_sk); i++) {\n            xa = sk_X509_ALGOR_value(md_sk, i);\n            if ((btmp = BIO_new(BIO_f_md())) == NULL) {\n                PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_BIO_LIB);\n                goto err;\n            }\n\n            j = OBJ_obj2nid(xa->algorithm);\n            evp_md = EVP_get_digestbynid(j);\n            if (evp_md == NULL) {\n                PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                         PKCS7_R_UNKNOWN_DIGEST_TYPE);\n                goto err;\n            }\n\n            BIO_set_md(btmp, evp_md);\n            if (out == NULL)\n                out = btmp;\n            else\n                BIO_push(out, btmp);\n            btmp = NULL;\n        }\n    }\n\n    if (evp_cipher != NULL) {\n#if 0\n        unsigned char key[EVP_MAX_KEY_LENGTH];\n        unsigned char iv[EVP_MAX_IV_LENGTH];\n        unsigned char *p;\n        int keylen, ivlen;\n        int max;\n        X509_OBJECT ret;\n#endif\n        unsigned char *tkey = NULL;\n        int tkeylen;\n        int jj;\n\n        if ((etmp = BIO_new(BIO_f_cipher())) == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_BIO_LIB);\n            goto err;\n        }\n\n        \/*\n         * It was encrypted, we need to decrypt the secret key with the\n         * private key\n         *\/\n\n        \/*\n         * Find the recipientInfo which matches the passed certificate (if\n         * any)\n         *\/\n\n        if (pcert) {\n            for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) {\n                ri = sk_PKCS7_RECIP_INFO_value(rsk, i);\n                if (!pkcs7_cmp_ri(ri, pcert))\n                    break;\n                ri = NULL;\n            }\n            if (ri == NULL) {\n                PKCS7err(PKCS7_F_PKCS7_DATADECODE,\n                         PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE);\n                goto err;\n            }\n        }\n\n        jj = EVP_PKEY_size(pkey);\n        tmp = (unsigned char *)OPENSSL_malloc(jj + 10);\n        if (tmp == NULL) {\n            PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n\n        \/* If we haven't got a certificate try each ri in turn *\/\n\n        if (pcert == NULL) {\n            \/*\n             * Temporary storage in case EVP_PKEY_decrypt overwrites output\n             * buffer on error.\n             *\/\n            unsigned char *tmp2;\n            tmp2 = OPENSSL_malloc(jj);\n            if (!tmp2)\n                goto err;\n            jj = -1;\n            \/*\n             * Always attempt to decrypt all cases to avoid leaking timing\n             * information about a successful decrypt.\n             *\/\n            for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) {\n                int tret;\n                ri = sk_PKCS7_RECIP_INFO_value(rsk, i);\n                tret = EVP_PKEY_decrypt(tmp2,\n                                        M_ASN1_STRING_data(ri->enc_key),\n                                        M_ASN1_STRING_length(ri->enc_key),\n                                        pkey);\n                if (tret > 0) {\n                    memcpy(tmp, tmp2, tret);\n                    OPENSSL_cleanse(tmp2, tret);\n                    jj = tret;\n                }\n                ERR_clear_error();\n            }\n            OPENSSL_free(tmp2);\n        } else {\n            jj = EVP_PKEY_decrypt(tmp,\n                                  M_ASN1_STRING_data(ri->enc_key),\n                                  M_ASN1_STRING_length(ri->enc_key), pkey);\n            ERR_clear_error();\n        }\n\n        evp_ctx = NULL;\n        BIO_get_cipher_ctx(etmp, &evp_ctx);\n        if (EVP_CipherInit_ex(evp_ctx, evp_cipher, NULL, NULL, NULL, 0) <= 0)\n            goto err;\n        if (EVP_CIPHER_asn1_to_param(evp_ctx, enc_alg->parameter) < 0)\n            goto err;\n        \/* Generate random key to counter MMA *\/\n        tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx);\n        tkey = OPENSSL_malloc(tkeylen);\n        if (!tkey)\n            goto err;\n        if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0)\n            goto err;\n        \/* If we have no key use random key *\/\n        if (jj <= 0) {\n            OPENSSL_free(tmp);\n            jj = tkeylen;\n            tmp = tkey;\n            tkey = NULL;\n        }\n\n        if (jj != tkeylen) {\n            \/*\n             * Some S\/MIME clients don't use the same key and effective key\n             * length. The key length is determined by the size of the\n             * decrypted RSA key.\n             *\/\n            if (!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) {\n                \/* As MMA defence use random key instead *\/\n                OPENSSL_cleanse(tmp, jj);\n                OPENSSL_free(tmp);\n                jj = tkeylen;\n                tmp = tkey;\n                tkey = NULL;\n            }\n        }\n        ERR_clear_error();\n        if (EVP_CipherInit_ex(evp_ctx, NULL, NULL, tmp, NULL, 0) <= 0)\n            goto err;\n\n        OPENSSL_cleanse(tmp, jj);\n\n        if (tkey) {\n            OPENSSL_cleanse(tkey, tkeylen);\n            OPENSSL_free(tkey);\n        }\n\n        if (out == NULL)\n            out = etmp;\n        else\n            BIO_push(out, etmp);\n        etmp = NULL;\n    }\n#if 1\n    if (in_bio != NULL) {\n        bio = in_bio;\n    } else {\n# if 0\n        bio = BIO_new(BIO_s_mem());\n        \/*\n         * We need to set this so that when we have read all the data, the\n         * encrypt BIO, if present, will read EOF and encode the last few\n         * bytes\n         *\/\n        BIO_set_mem_eof_return(bio, 0);\n\n        if (data_body->length > 0)\n            BIO_write(bio, (char *)data_body->data, data_body->length);\n# else\n        if (data_body->length > 0)\n            bio = BIO_new_mem_buf(data_body->data, data_body->length);\n        else {\n            bio = BIO_new(BIO_s_mem());\n            BIO_set_mem_eof_return(bio, 0);\n        }\n        if (bio == NULL)\n            goto err;\n# endif\n    }\n    BIO_push(out, bio);\n    bio = NULL;\n#endif\n    if (0) {\n err:\n        if (out != NULL)\n            BIO_free_all(out);\n        if (btmp != NULL)\n            BIO_free_all(btmp);\n        if (etmp != NULL)\n            BIO_free_all(etmp);\n        if (bio != NULL)\n            BIO_free_all(bio);\n        out = NULL;\n    }\n    if (tmp != NULL)\n        OPENSSL_free(tmp);\n    return (out);\n}","target":0,"code_token_length":2391,"total_token_length":2627,"max_tokens_setting":4096}
+{"idx":430422,"func":"static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,\n\t\t\t\t  const struct sw_flow_key *key,\n\t\t\t\t  struct sw_flow_actions **sfa,\n\t\t\t\t  __be16 eth_type, __be16 vlan_tci,\n\t\t\t\t  u32 mpls_label_count, bool log)\n{\n\tu8 mac_proto = ovs_key_mac_proto(key);\n\tconst struct nlattr *a;\n\tint rem, err;\n\n\tnla_for_each_nested(a, attr, rem) {\n\t\t\/* Expected argument lengths, (u32)-1 for variable length. *\/\n\t\tstatic const u32 action_lens[OVS_ACTION_ATTR_MAX + 1] = {\n\t\t\t[OVS_ACTION_ATTR_OUTPUT] = sizeof(u32),\n\t\t\t[OVS_ACTION_ATTR_RECIRC] = sizeof(u32),\n\t\t\t[OVS_ACTION_ATTR_USERSPACE] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_PUSH_MPLS] = sizeof(struct ovs_action_push_mpls),\n\t\t\t[OVS_ACTION_ATTR_POP_MPLS] = sizeof(__be16),\n\t\t\t[OVS_ACTION_ATTR_PUSH_VLAN] = sizeof(struct ovs_action_push_vlan),\n\t\t\t[OVS_ACTION_ATTR_POP_VLAN] = 0,\n\t\t\t[OVS_ACTION_ATTR_SET] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_SET_MASKED] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_SAMPLE] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_HASH] = sizeof(struct ovs_action_hash),\n\t\t\t[OVS_ACTION_ATTR_CT] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_CT_CLEAR] = 0,\n\t\t\t[OVS_ACTION_ATTR_TRUNC] = sizeof(struct ovs_action_trunc),\n\t\t\t[OVS_ACTION_ATTR_PUSH_ETH] = sizeof(struct ovs_action_push_eth),\n\t\t\t[OVS_ACTION_ATTR_POP_ETH] = 0,\n\t\t\t[OVS_ACTION_ATTR_PUSH_NSH] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_POP_NSH] = 0,\n\t\t\t[OVS_ACTION_ATTR_METER] = sizeof(u32),\n\t\t\t[OVS_ACTION_ATTR_CLONE] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_CHECK_PKT_LEN] = (u32)-1,\n\t\t\t[OVS_ACTION_ATTR_ADD_MPLS] = sizeof(struct ovs_action_add_mpls),\n\t\t\t[OVS_ACTION_ATTR_DEC_TTL] = (u32)-1,\n\t\t};\n\t\tconst struct ovs_action_push_vlan *vlan;\n\t\tint type = nla_type(a);\n\t\tbool skip_copy;\n\n\t\tif (type > OVS_ACTION_ATTR_MAX ||\n\t\t    (action_lens[type] != nla_len(a) &&\n\t\t     action_lens[type] != (u32)-1))\n\t\t\treturn -EINVAL;\n\n\t\tskip_copy = false;\n\t\tswitch (type) {\n\t\tcase OVS_ACTION_ATTR_UNSPEC:\n\t\t\treturn -EINVAL;\n\n\t\tcase OVS_ACTION_ATTR_USERSPACE:\n\t\t\terr = validate_userspace(a);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_OUTPUT:\n\t\t\tif (nla_get_u32(a) >= DP_MAX_PORTS)\n\t\t\t\treturn -EINVAL;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_TRUNC: {\n\t\t\tconst struct ovs_action_trunc *trunc = nla_data(a);\n\n\t\t\tif (trunc->max_len < ETH_HLEN)\n\t\t\t\treturn -EINVAL;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_HASH: {\n\t\t\tconst struct ovs_action_hash *act_hash = nla_data(a);\n\n\t\t\tswitch (act_hash->hash_alg) {\n\t\t\tcase OVS_HASH_ALG_L4:\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn  -EINVAL;\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_POP_VLAN:\n\t\t\tif (mac_proto != MAC_PROTO_ETHERNET)\n\t\t\t\treturn -EINVAL;\n\t\t\tvlan_tci = htons(0);\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_PUSH_VLAN:\n\t\t\tif (mac_proto != MAC_PROTO_ETHERNET)\n\t\t\t\treturn -EINVAL;\n\t\t\tvlan = nla_data(a);\n\t\t\tif (!eth_type_vlan(vlan->vlan_tpid))\n\t\t\t\treturn -EINVAL;\n\t\t\tif (!(vlan->vlan_tci & htons(VLAN_CFI_MASK)))\n\t\t\t\treturn -EINVAL;\n\t\t\tvlan_tci = vlan->vlan_tci;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_RECIRC:\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_ADD_MPLS: {\n\t\t\tconst struct ovs_action_add_mpls *mpls = nla_data(a);\n\n\t\t\tif (!eth_p_mpls(mpls->mpls_ethertype))\n\t\t\t\treturn -EINVAL;\n\n\t\t\tif (mpls->tun_flags & OVS_MPLS_L3_TUNNEL_FLAG_MASK) {\n\t\t\t\tif (vlan_tci & htons(VLAN_CFI_MASK) ||\n\t\t\t\t    (eth_type != htons(ETH_P_IP) &&\n\t\t\t\t     eth_type != htons(ETH_P_IPV6) &&\n\t\t\t\t     eth_type != htons(ETH_P_ARP) &&\n\t\t\t\t     eth_type != htons(ETH_P_RARP) &&\n\t\t\t\t     !eth_p_mpls(eth_type)))\n\t\t\t\t\treturn -EINVAL;\n\t\t\t\tmpls_label_count++;\n\t\t\t} else {\n\t\t\t\tif (mac_proto == MAC_PROTO_ETHERNET) {\n\t\t\t\t\tmpls_label_count = 1;\n\t\t\t\t\tmac_proto = MAC_PROTO_NONE;\n\t\t\t\t} else {\n\t\t\t\t\tmpls_label_count++;\n\t\t\t\t}\n\t\t\t}\n\t\t\teth_type = mpls->mpls_ethertype;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_PUSH_MPLS: {\n\t\t\tconst struct ovs_action_push_mpls *mpls = nla_data(a);\n\n\t\t\tif (!eth_p_mpls(mpls->mpls_ethertype))\n\t\t\t\treturn -EINVAL;\n\t\t\t\/* Prohibit push MPLS other than to a white list\n\t\t\t * for packets that have a known tag order.\n\t\t\t *\/\n\t\t\tif (vlan_tci & htons(VLAN_CFI_MASK) ||\n\t\t\t    (eth_type != htons(ETH_P_IP) &&\n\t\t\t     eth_type != htons(ETH_P_IPV6) &&\n\t\t\t     eth_type != htons(ETH_P_ARP) &&\n\t\t\t     eth_type != htons(ETH_P_RARP) &&\n\t\t\t     !eth_p_mpls(eth_type)))\n\t\t\t\treturn -EINVAL;\n\t\t\teth_type = mpls->mpls_ethertype;\n\t\t\tmpls_label_count++;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_POP_MPLS: {\n\t\t\t__be16  proto;\n\t\t\tif (vlan_tci & htons(VLAN_CFI_MASK) ||\n\t\t\t    !eth_p_mpls(eth_type))\n\t\t\t\treturn -EINVAL;\n\n\t\t\t\/* Disallow subsequent L2.5+ set actions and mpls_pop\n\t\t\t * actions once the last MPLS label in the packet is\n\t\t\t * is popped as there is no check here to ensure that\n\t\t\t * the new eth type is valid and thus set actions could\n\t\t\t * write off the end of the packet or otherwise corrupt\n\t\t\t * it.\n\t\t\t *\n\t\t\t * Support for these actions is planned using packet\n\t\t\t * recirculation.\n\t\t\t *\/\n\t\t\tproto = nla_get_be16(a);\n\n\t\t\tif (proto == htons(ETH_P_TEB) &&\n\t\t\t    mac_proto != MAC_PROTO_NONE)\n\t\t\t\treturn -EINVAL;\n\n\t\t\tmpls_label_count--;\n\n\t\t\tif (!eth_p_mpls(proto) || !mpls_label_count)\n\t\t\t\teth_type = htons(0);\n\t\t\telse\n\t\t\t\teth_type =  proto;\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_SET:\n\t\t\terr = validate_set(a, key, sfa,\n\t\t\t\t\t   &skip_copy, mac_proto, eth_type,\n\t\t\t\t\t   false, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_SET_MASKED:\n\t\t\terr = validate_set(a, key, sfa,\n\t\t\t\t\t   &skip_copy, mac_proto, eth_type,\n\t\t\t\t\t   true, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_SAMPLE: {\n\t\t\tbool last = nla_is_last(a, rem);\n\n\t\t\terr = validate_and_copy_sample(net, a, key, sfa,\n\t\t\t\t\t\t       eth_type, vlan_tci,\n\t\t\t\t\t\t       mpls_label_count,\n\t\t\t\t\t\t       log, last);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tskip_copy = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_CT:\n\t\t\terr = ovs_ct_copy_action(net, a, key, sfa, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tskip_copy = true;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_CT_CLEAR:\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_PUSH_ETH:\n\t\t\t\/* Disallow pushing an Ethernet header if one\n\t\t\t * is already present *\/\n\t\t\tif (mac_proto != MAC_PROTO_NONE)\n\t\t\t\treturn -EINVAL;\n\t\t\tmac_proto = MAC_PROTO_ETHERNET;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_POP_ETH:\n\t\t\tif (mac_proto != MAC_PROTO_ETHERNET)\n\t\t\t\treturn -EINVAL;\n\t\t\tif (vlan_tci & htons(VLAN_CFI_MASK))\n\t\t\t\treturn -EINVAL;\n\t\t\tmac_proto = MAC_PROTO_NONE;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_PUSH_NSH:\n\t\t\tif (mac_proto != MAC_PROTO_ETHERNET) {\n\t\t\t\tu8 next_proto;\n\n\t\t\t\tnext_proto = tun_p_from_eth_p(eth_type);\n\t\t\t\tif (!next_proto)\n\t\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tmac_proto = MAC_PROTO_NONE;\n\t\t\tif (!validate_nsh(nla_data(a), false, true, true))\n\t\t\t\treturn -EINVAL;\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_POP_NSH: {\n\t\t\t__be16 inner_proto;\n\n\t\t\tif (eth_type != htons(ETH_P_NSH))\n\t\t\t\treturn -EINVAL;\n\t\t\tinner_proto = tun_p_to_eth_p(key->nsh.base.np);\n\t\t\tif (!inner_proto)\n\t\t\t\treturn -EINVAL;\n\t\t\tif (key->nsh.base.np == TUN_P_ETHERNET)\n\t\t\t\tmac_proto = MAC_PROTO_ETHERNET;\n\t\t\telse\n\t\t\t\tmac_proto = MAC_PROTO_NONE;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_METER:\n\t\t\t\/* Non-existent meters are simply ignored.  *\/\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_CLONE: {\n\t\t\tbool last = nla_is_last(a, rem);\n\n\t\t\terr = validate_and_copy_clone(net, a, key, sfa,\n\t\t\t\t\t\t      eth_type, vlan_tci,\n\t\t\t\t\t\t      mpls_label_count,\n\t\t\t\t\t\t      log, last);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tskip_copy = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_CHECK_PKT_LEN: {\n\t\t\tbool last = nla_is_last(a, rem);\n\n\t\t\terr = validate_and_copy_check_pkt_len(net, a, key, sfa,\n\t\t\t\t\t\t\t      eth_type,\n\t\t\t\t\t\t\t      vlan_tci,\n\t\t\t\t\t\t\t      mpls_label_count,\n\t\t\t\t\t\t\t      log, last);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tskip_copy = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase OVS_ACTION_ATTR_DEC_TTL:\n\t\t\terr = validate_and_copy_dec_ttl(net, a, key, sfa,\n\t\t\t\t\t\t\teth_type, vlan_tci,\n\t\t\t\t\t\t\tmpls_label_count, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tskip_copy = true;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tOVS_NLERR(log, \"Unknown Action type %d\", type);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (!skip_copy) {\n\t\t\terr = copy_action(a, sfa, log);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t}\n\t}\n\n\tif (rem > 0)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":2492,"total_token_length":2728,"max_tokens_setting":4096}
+{"idx":210303,"func":"static Image *ReadWMFImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  double\n    bounding_height,\n    bounding_width,\n    image_height,\n    image_height_inch,\n    image_width,\n    image_width_inch,\n    resolution_y,\n    resolution_x,\n    units_per_inch;\n\n  float\n    wmf_width,\n    wmf_height;\n\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  unsigned long\n    wmf_options_flags = 0;\n\n  wmf_error_t\n    wmf_error;\n\n  wmf_magick_t\n    *ddata = 0;\n\n  wmfAPI\n    *API = 0;\n\n  wmfAPI_Options\n    wmf_api_options;\n\n  wmfD_Rect\n    bbox;\n\n  image=AcquireImage(image_info,exception);\n  if (OpenBlob(image_info,image,ReadBinaryBlobMode,exception) == MagickFalse)\n    {\n      if (image->debug != MagickFalse)\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  OpenBlob failed\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"leave ReadWMFImage()\");\n        }\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n\n  \/*\n   * Create WMF API\n   *\n   *\/\n\n  \/* Register callbacks *\/\n  wmf_options_flags |= WMF_OPT_FUNCTION;\n  (void) ResetMagickMemory(&wmf_api_options, 0, sizeof(wmf_api_options));\n  wmf_api_options.function = ipa_functions;\n\n  \/* Ignore non-fatal errors *\/\n  wmf_options_flags |= WMF_OPT_IGNORE_NONFATAL;\n\n  wmf_error = wmf_api_create(&API, wmf_options_flags, &wmf_api_options);\n  if (wmf_error != wmf_E_None)\n    {\n      if (API)\n        wmf_api_destroy(API);\n      if (image->debug != MagickFalse)\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  wmf_api_create failed\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"leave ReadWMFImage()\");\n        }\n      ThrowReaderException(DelegateError,\"UnableToInitializeWMFLibrary\");\n    }\n\n  \/* Register progress monitor *\/\n  wmf_status_function(API,image,magick_progress_callback);\n\n  ddata=WMF_MAGICK_GetData(API);\n  ddata->image=image;\n  ddata->image_info=image_info;\n  ddata->draw_info=CloneDrawInfo(image_info,(const DrawInfo *) NULL);\n  ddata->exception=exception;\n  ddata->draw_info->font=(char *)\n    RelinquishMagickMemory(ddata->draw_info->font);\n  ddata->draw_info->text=(char *)\n    RelinquishMagickMemory(ddata->draw_info->text);\n\n#if defined(MAGICKCORE_WMF_DELEGATE)\n  \/* Must initialize font subystem for WMFlite interface *\/\n  lite_font_init (API,&wmf_api_options); \/* similar to wmf_ipa_font_init in src\/font.c *\/\n  \/* wmf_arg_fontdirs (API,options); *\/ \/* similar to wmf_arg_fontdirs in src\/wmf.c *\/\n\n#endif\n\n  \/*\n   * Open BLOB input via libwmf API\n   *\n   *\/\n  wmf_error = wmf_bbuf_input(API,ipa_blob_read,ipa_blob_seek,\n    ipa_blob_tell,(void*)image);\n  if (wmf_error != wmf_E_None)\n    {\n      wmf_api_destroy(API);\n      if (image->debug != MagickFalse)\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  wmf_bbuf_input failed\");\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"leave ReadWMFImage()\");\n        }\n      ThrowFileException(exception,FileOpenError,\"UnableToOpenFile\",\n        image->filename);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n\n  \/*\n   * Scan WMF file\n   *\n   *\/\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"  Scanning WMF to obtain bounding box\");\n  wmf_error=wmf_scan(API, 0, &bbox);\n  if (wmf_error != wmf_E_None)\n    {\n      wmf_api_destroy(API);\n      if (image->debug != MagickFalse)\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  wmf_scan failed with wmf_error %d\", wmf_error);\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"leave ReadWMFImage()\");\n        }\n      ThrowReaderException(DelegateError,\"FailedToScanFile\");\n    }\n\n  \/*\n   * Compute dimensions and scale factors\n   *\n   *\/\n\n  ddata->bbox=bbox;\n\n  \/* User specified resolution *\/\n  resolution_y=DefaultResolution;\n  if (image->resolution.y != 0.0)\n    {\n      resolution_y = image->resolution.y;\n      if (image->units == PixelsPerCentimeterResolution)\n        resolution_y *= CENTIMETERS_PER_INCH;\n    }\n  resolution_x=DefaultResolution;\n  if (image->resolution.x != 0.0)\n    {\n      resolution_x = image->resolution.x;\n      if (image->units == PixelsPerCentimeterResolution)\n        resolution_x *= CENTIMETERS_PER_INCH;\n    }\n\n  \/* Obtain output size expressed in metafile units *\/\n  wmf_error=wmf_size(API,&wmf_width,&wmf_height);\n  if (wmf_error != wmf_E_None)\n    {\n      wmf_api_destroy(API);\n      if (image->debug != MagickFalse)\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  wmf_size failed with wmf_error %d\", wmf_error);\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"leave ReadWMFImage()\");\n        }\n      ThrowReaderException(DelegateError,\"FailedToComputeOutputSize\");\n    }\n\n  \/* Obtain (or guess) metafile units *\/\n  if ((API)->File->placeable)\n    units_per_inch=(API)->File->pmh->Inch;\n  else if ( (wmf_width*wmf_height) < 1024*1024)\n    units_per_inch=POINTS_PER_INCH;  \/* MM_TEXT *\/\n  else\n    units_per_inch=TWIPS_PER_INCH;  \/* MM_TWIPS *\/\n\n  \/* Calculate image width and height based on specified DPI\n     resolution *\/\n  image_width_inch  = (double) wmf_width \/ units_per_inch;\n  image_height_inch = (double) wmf_height \/ units_per_inch;\n  image_width       = image_width_inch * resolution_x;\n  image_height      = image_height_inch * resolution_y;\n\n  \/* Compute bounding box scale factors and origin translations\n   *\n   * This all just a hack since libwmf does not currently seem to\n   * provide the mapping between LOGICAL coordinates and DEVICE\n   * coordinates. This mapping is necessary in order to know\n   * where to place the logical bounding box within the image.\n   *\n   *\/\n\n  bounding_width  = bbox.BR.x - bbox.TL.x;\n  bounding_height = bbox.BR.y - bbox.TL.y;\n\n  ddata->scale_x = image_width\/bounding_width;\n  ddata->translate_x = 0-bbox.TL.x;\n  ddata->rotate = 0;\n\n  \/* Heuristic: guess that if the vertical coordinates mostly span\n     negative values, then the image must be inverted. *\/\n  if ( fabs(bbox.BR.y) > fabs(bbox.TL.y) )\n    {\n      \/* Normal (Origin at top left of image) *\/\n      ddata->scale_y = (image_height\/bounding_height);\n      ddata->translate_y = 0-bbox.TL.y;\n    }\n  else\n    {\n      \/* Inverted (Origin at bottom left of image) *\/\n      ddata->scale_y = (-image_height\/bounding_height);\n      ddata->translate_y = 0-bbox.BR.y;\n    }\n\n  if (image->debug != MagickFalse)\n    {\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n         \"  Placeable metafile:          %s\",\n         (API)->File->placeable ? \"Yes\" : \"No\");\n\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Size in metafile units:      %gx%g\",wmf_width,wmf_height);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Metafile units\/inch:         %g\",units_per_inch);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Size in inches:              %gx%g\",\n        image_width_inch,image_height_inch);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Bounding Box:                %g,%g %g,%g\",\n        bbox.TL.x, bbox.TL.y, bbox.BR.x, bbox.BR.y);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Bounding width x height:     %gx%g\",bounding_width,\n        bounding_height);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Output resolution:           %gx%g\",resolution_x,resolution_y);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Image size:                  %gx%g\",image_width,image_height);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Bounding box scale factor:   %g,%g\",ddata->scale_x,\n        ddata->scale_y);\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"  Translation:                 %g,%g\",\n        ddata->translate_x, ddata->translate_y);\n    }\n\n#if 0\n#if 0\n  {\n    typedef struct _wmfPlayer_t wmfPlayer_t;\n    struct _wmfPlayer_t\n    {\n      wmfPen   default_pen;\n      wmfBrush default_brush;\n      wmfFont  default_font;\n\n      wmfDC* dc; \/* current dc *\/\n    };\n\n    wmfDC\n      *dc;\n\n#define WMF_ELICIT_DC(API) (((wmfPlayer_t*)((API)->player_data))->dc)\n\n    dc = WMF_ELICIT_DC(API);\n\n    printf(\"dc->Window.Ox     = %d\\n\", dc->Window.Ox);\n    printf(\"dc->Window.Oy     = %d\\n\", dc->Window.Oy);\n    printf(\"dc->Window.width  = %d\\n\", dc->Window.width);\n    printf(\"dc->Window.height = %d\\n\", dc->Window.height);\n    printf(\"dc->pixel_width   = %g\\n\", dc->pixel_width);\n    printf(\"dc->pixel_height  = %g\\n\", dc->pixel_height);\n#if defined(MAGICKCORE_WMF_DELEGATE)  \/* Only in libwmf 0.3 *\/\n    printf(\"dc->Ox            = %.d\\n\", dc->Ox);\n    printf(\"dc->Oy            = %.d\\n\", dc->Oy);\n    printf(\"dc->width         = %.d\\n\", dc->width);\n    printf(\"dc->height        = %.d\\n\", dc->height);\n#endif\n\n  }\n#endif\n\n#endif\n\n  \/*\n   * Create canvas image\n   *\n   *\/\n  image->rows=(unsigned long) ceil(image_height);\n  image->columns=(unsigned long) ceil(image_width);\n\n  if (image_info->ping != MagickFalse)\n    {\n      wmf_api_destroy(API);\n      (void) CloseBlob(image);\n      if (image->debug != MagickFalse)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"leave ReadWMFImage()\");\n      return(GetFirstImageInList(image));\n    }\n  status=SetImageExtent(image,image->columns,image->rows,exception);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n       \"  Creating canvas image with size %lux%lu\",(unsigned long) image->rows,\n       (unsigned long) image->columns);\n\n  \/*\n   * Set solid background color\n   *\/\n  {\n    image->background_color = image_info->background_color;\n    if (image->background_color.alpha != OpaqueAlpha)\n      image->alpha_trait=BlendPixelTrait;\n    (void) SetImageBackgroundColor(image,exception);\n  }\n  \/*\n   * Play file to generate Vector drawing commands\n   *\n   *\/\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"  Playing WMF to prepare vectors\");\n\n  wmf_error = wmf_play(API, 0, &bbox);\n  if (wmf_error != wmf_E_None)\n    {\n      wmf_api_destroy(API);\n      if (image->debug != MagickFalse)\n        {\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Playing WMF failed with wmf_error %d\", wmf_error);\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"leave ReadWMFImage()\");\n        }\n      ThrowReaderException(DelegateError,\"FailedToRenderFile\");\n    }\n\n  \/*\n   * Scribble on canvas image\n   *\n   *\/\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"  Rendering WMF vectors\");\n  DrawRender(ddata->draw_wand);\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"leave ReadWMFImage()\");\n\n  \/* Cleanup allocated data *\/\n  wmf_api_destroy(API);\n  (void) CloseBlob(image);\n\n  \/* Return image *\/\n  return image;\n}","target":1,"code_token_length":3092,"total_token_length":3328,"max_tokens_setting":4096}
+{"idx":274764,"func":"static s64 ntfs_attr_pread_i(ntfs_attr *na, const s64 pos, s64 count, void *b)\n{\n\ts64 br, to_read, ofs, total, total2, max_read, max_init;\n\tntfs_volume *vol;\n\trunlist_element *rl;\n\tu16 efs_padding_length;\n\n\t\/* Sanity checking arguments is done in ntfs_attr_pread(). *\/\n\t\n\tif ((na->data_flags & ATTR_COMPRESSION_MASK) && NAttrNonResident(na)) {\n\t\tif ((na->data_flags & ATTR_COMPRESSION_MASK)\n\t\t    == ATTR_IS_COMPRESSED)\n\t\t\treturn ntfs_compressed_attr_pread(na, pos, count, b);\n\t\telse {\n\t\t\t\t\/* compression mode not supported *\/\n\t\t\terrno = EOPNOTSUPP;\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\/*\n\t * Encrypted non-resident attributes are not supported.  We return\n\t * access denied, which is what Windows NT4 does, too.\n\t * However, allow if mounted with efs_raw option\n\t *\/\n\tvol = na->ni->vol;\n\tif (!vol->efs_raw && NAttrEncrypted(na) && NAttrNonResident(na)) {\n\t\terrno = EACCES;\n\t\treturn -1;\n\t}\n\t\n\tif (!count)\n\t\treturn 0;\n\t\t\/*\n\t\t * Truncate reads beyond end of attribute,\n\t\t * but round to next 512 byte boundary for encrypted\n\t\t * attributes with efs_raw mount option\n\t\t *\/\n\tmax_read = na->data_size;\n\tmax_init = na->initialized_size;\n\tif (na->ni->vol->efs_raw\n\t    && (na->data_flags & ATTR_IS_ENCRYPTED)\n\t    && NAttrNonResident(na)) {\n\t\tif (na->data_size != na->initialized_size) {\n\t\t\tntfs_log_error(\"uninitialized encrypted file not supported\\n\");\n\t\t\terrno = EINVAL;\n\t\t\treturn -1;\n\t\t}\t\n\t\tmax_init = max_read = ((na->data_size + 511) & ~511) + 2;\n\t}\n\tif (pos + count > max_read) {\n\t\tif (pos >= max_read)\n\t\t\treturn 0;\n\t\tcount = max_read - pos;\n\t}\n\t\/* If it is a resident attribute, get the value from the mft record. *\/\n\tif (!NAttrNonResident(na)) {\n\t\tntfs_attr_search_ctx *ctx;\n\t\tchar *val;\n\n\t\tctx = ntfs_attr_get_search_ctx(na->ni, NULL);\n\t\tif (!ctx)\n\t\t\treturn -1;\n\t\tif (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,\n\t\t\t\t0, NULL, 0, ctx)) {\nres_err_out:\n\t\t\tntfs_attr_put_search_ctx(ctx);\n\t\t\treturn -1;\n\t\t}\n\t\tval = (char*)ctx->attr + le16_to_cpu(ctx->attr->value_offset);\n\t\tif (val < (char*)ctx->attr || val +\n\t\t\t\tle32_to_cpu(ctx->attr->value_length) >\n\t\t\t\t(char*)ctx->mrec + vol->mft_record_size) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"%s: Sanity check failed\", __FUNCTION__);\n\t\t\tgoto res_err_out;\n\t\t}\n\t\tmemcpy(b, val + pos, count);\n\t\tntfs_attr_put_search_ctx(ctx);\n\t\treturn count;\n\t}\n\ttotal = total2 = 0;\n\t\/* Zero out reads beyond initialized size. *\/\n\tif (pos + count > max_init) {\n\t\tif (pos >= max_init) {\n\t\t\tmemset(b, 0, count);\n\t\t\treturn count;\n\t\t}\n\t\ttotal2 = pos + count - max_init;\n\t\tcount -= total2;\n\t\tmemset((u8*)b + count, 0, total2);\n\t}\n\t\t\/*\n\t\t * for encrypted non-resident attributes with efs_raw set \n\t\t * the last two bytes aren't read from disk but contain\n\t\t * the number of padding bytes so original size can be \n\t\t * restored\n\t\t *\/\n\tif (na->ni->vol->efs_raw && \n\t\t\t(na->data_flags & ATTR_IS_ENCRYPTED) && \n\t\t\t((pos + count) > max_init-2)) {\n\t\tefs_padding_length = 511 - ((na->data_size - 1) & 511);\n\t\tif (pos+count == max_init) {\n\t\t\tif (count == 1) {\n\t\t\t\t*((u8*)b+count-1) = (u8)(efs_padding_length >> 8);\n\t\t\t\tcount--;\n\t\t\t\ttotal2++;\n\t\t\t} else {\n\t\t\t\t*(le16*)((u8*)b+count-2) = cpu_to_le16(efs_padding_length);\n\t\t\t\tcount -= 2;\n\t\t\t\ttotal2 +=2;\n\t\t\t}\n\t\t} else {\n\t\t\t*((u8*)b+count-1) = (u8)(efs_padding_length & 0xff);\n\t\t\tcount--;\n\t\t\ttotal2++;\n\t\t}\n\t}\n\t\n\t\/* Find the runlist element containing the vcn. *\/\n\trl = ntfs_attr_find_vcn(na, pos >> vol->cluster_size_bits);\n\tif (!rl) {\n\t\t\/*\n\t\t * If the vcn is not present it is an out of bounds read.\n\t\t * However, we already truncated the read to the data_size,\n\t\t * so getting this here is an error.\n\t\t *\/\n\t\tif (errno == ENOENT) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"%s: Failed to find VCN #1\", __FUNCTION__);\n\t\t}\n\t\treturn -1;\n\t}\n\t\/*\n\t * Gather the requested data into the linear destination buffer. Note,\n\t * a partial final vcn is taken care of by the @count capping of read\n\t * length.\n\t *\/\n\tofs = pos - (rl->vcn << vol->cluster_size_bits);\n\tfor (; count; rl++, ofs = 0) {\n\t\tif (rl->lcn == LCN_RL_NOT_MAPPED) {\n\t\t\trl = ntfs_attr_find_vcn(na, rl->vcn);\n\t\t\tif (!rl) {\n\t\t\t\tif (errno == ENOENT) {\n\t\t\t\t\terrno = EIO;\n\t\t\t\t\tntfs_log_perror(\"%s: Failed to find VCN #2\",\n\t\t\t\t\t\t\t__FUNCTION__);\n\t\t\t\t}\n\t\t\t\tgoto rl_err_out;\n\t\t\t}\n\t\t\t\/* Needed for case when runs merged. *\/\n\t\t\tofs = pos + total - (rl->vcn << vol->cluster_size_bits);\n\t\t}\n\t\tif (!rl->length) {\n\t\t\terrno = EIO;\n\t\t\tntfs_log_perror(\"%s: Zero run length\", __FUNCTION__);\n\t\t\tgoto rl_err_out;\n\t\t}\n\t\tif (rl->lcn < (LCN)0) {\n\t\t\tif (rl->lcn != (LCN)LCN_HOLE) {\n\t\t\t\tntfs_log_perror(\"%s: Bad run (%lld)\", \n\t\t\t\t\t\t__FUNCTION__,\n\t\t\t\t\t\t(long long)rl->lcn);\n\t\t\t\tgoto rl_err_out;\n\t\t\t}\n\t\t\t\/* It is a hole, just zero the matching @b range. *\/\n\t\t\tto_read = min(count, (rl->length <<\n\t\t\t\t\tvol->cluster_size_bits) - ofs);\n\t\t\tmemset(b, 0, to_read);\n\t\t\t\/* Update progress counters. *\/\n\t\t\ttotal += to_read;\n\t\t\tcount -= to_read;\n\t\t\tb = (u8*)b + to_read;\n\t\t\tcontinue;\n\t\t}\n\t\t\/* It is a real lcn, read it into @dst. *\/\n\t\tto_read = min(count, (rl->length << vol->cluster_size_bits) -\n\t\t\t\tofs);\nretry:\n\t\tntfs_log_trace(\"Reading %lld bytes from vcn %lld, lcn %lld, ofs\"\n\t\t\t\t\" %lld.\\n\", (long long)to_read, (long long)rl->vcn,\n\t\t\t       (long long )rl->lcn, (long long)ofs);\n\t\tbr = ntfs_pread(vol->dev, (rl->lcn << vol->cluster_size_bits) +\n\t\t\t\tofs, to_read, b);\n\t\t\/* If everything ok, update progress counters and continue. *\/\n\t\tif (br > 0) {\n\t\t\ttotal += br;\n\t\t\tcount -= br;\n\t\t\tb = (u8*)b + br;\n\t\t}\n\t\tif (br == to_read)\n\t\t\tcontinue;\n\t\t\/* If the syscall was interrupted, try again. *\/\n\t\tif (br == (s64)-1 && errno == EINTR)\n\t\t\tgoto retry;\n\t\tif (total)\n\t\t\treturn total;\n\t\tif (!br)\n\t\t\terrno = EIO;\n\t\tntfs_log_perror(\"%s: ntfs_pread failed\", __FUNCTION__);\n\t\treturn -1;\n\t}\n\t\/* Finally, return the number of bytes read. *\/\n\treturn total + total2;\nrl_err_out:\n\tif (total)\n\t\treturn total;\n\terrno = EIO;\n\treturn -1;\n}","target":0,"code_token_length":1940,"total_token_length":2176,"max_tokens_setting":4096}
+{"idx":246700,"func":"static GF_Err do_dash()\n{\n\tGF_Err e;\n\tu32 i;\n\tBool del_file = GF_FALSE;\n\tchar szMPD[GF_MAX_PATH], *sep;\n\tchar szStateFile[GF_MAX_PATH];\n\tBool dyn_state_file = GF_FALSE;\n\tu32 do_abort = 0;\n\tGF_DASHSegmenter *dasher=NULL;\n\n\tif (crypt) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"MP4Box cannot use -crypt and -dash in the same pass. Please encrypt your content first, or specify encryption filters on dash sources.\\n\"));\n\t\treturn GF_BAD_PARAM;\n\t}\n\n\tstrcpy(outfile, outName ? outName : gf_url_get_resource_name(inName) );\n\tsep = strrchr(outfile, '.');\n\tif (sep) sep[0] = 0;\n\tif (!outName) strcat(outfile, \"_dash\");\n\tstrcpy(szMPD, outfile);\n\tif (outName && sep) {\n\t\tsep[0] = '.';\n\t\tstrcat(szMPD, sep);\n\t} else {\n\t\tstrcat(szMPD, \".mpd\");\n\t}\n\n\tif ((dash_subduration>0) && (dash_duration > dash_subduration)) {\n\t\tM4_LOG(GF_LOG_WARNING, (\"Warning: -subdur parameter (%g s) should be greater than segment duration (%g s), using segment duration instead\\n\", dash_subduration, dash_duration));\n\t\tdash_subduration = dash_duration;\n\t}\n\n\tif (dash_mode && dash_live)\n\t\tM4_LOG(GF_LOG_INFO, (\"Live DASH-ing - press 'q' to quit, 's' to save context and quit\\n\"));\n\n\tif (!dash_ctx_file && dash_live) {\n\t\tu32 r1;\n\t\tu64 add = (u64) (intptr_t) &dasher;\n\t\tadd ^= gf_net_get_utc();\n\t\tr1 = (u32) add ^ (u32) (add\/0xFFFFFFFF);\n\t\tr1 ^= gf_rand();\n\t\tsprintf(szStateFile, \"%s\/dasher_%X.xml\", gf_get_default_cache_directory(), r1 );\n\t\tdash_ctx_file = szStateFile;\n\t\tdyn_state_file = GF_TRUE;\n\t} else if (dash_ctx_file) {\n\t\tif (force_new)\n\t\t\tgf_file_delete(dash_ctx_file);\n\t}\n\n\tif (dash_profile==GF_DASH_PROFILE_AUTO)\n\t\tdash_profile = dash_mode ? GF_DASH_PROFILE_LIVE : GF_DASH_PROFILE_FULL;\n\n\tif (!dash_mode) {\n\t\ttime_shift_depth = 0;\n\t\tmpd_update_time = 0;\n\t} else if ((dash_profile>=GF_DASH_PROFILE_MAIN) && !use_url_template && !mpd_update_time) {\n\t\t\/*use a default MPD update of dash_duration sec*\/\n\t\tmpd_update_time = (Double) (dash_subduration ? dash_subduration : dash_duration);\n\t\tM4_LOG(GF_LOG_INFO, (\"Using default MPD refresh of %g seconds\\n\", mpd_update_time));\n\t}\n\n\tif (file && do_save) {\n\t\tgf_isom_close(file);\n\t\tfile = NULL;\n\t\tdel_file = GF_TRUE;\n\t}\n\n\t\/*setup dash*\/\n\tdasher = gf_dasher_new(szMPD, dash_profile, NULL, dash_scale, dash_ctx_file);\n\tif (!dasher) {\n\t\treturn mp4box_cleanup(1);\n\t}\n\te = gf_dasher_set_info(dasher, dash_title, cprt, dash_more_info, dash_source, NULL);\n\tif (e) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"DASH Error: %s\\n\", gf_error_to_string(e)));\n\t\tgf_dasher_del(dasher);\n\t\treturn e;\n\t}\n\n\tgf_dasher_set_start_date(dasher, dash_start_date);\n\tgf_dasher_set_location(dasher, dash_source);\n\tfor (i=0; i < nb_mpd_base_urls; i++) {\n\t\te = gf_dasher_add_base_url(dasher, mpd_base_urls[i]);\n\t\tif (e) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"DASH Error: %s\\n\", gf_error_to_string(e)));\n\t\t\tgf_dasher_del(dasher);\n\t\t\treturn e;\n\t\t}\n\t}\n\n\tif (segment_timeline && !use_url_template) {\n\t\tM4_LOG(GF_LOG_WARNING, (\"DASH Warning: using -segment-timeline with no -url-template. Forcing URL template.\\n\"));\n\t\tuse_url_template = GF_TRUE;\n\t}\n\n\te = gf_dasher_enable_url_template(dasher, (Bool) use_url_template, seg_name, seg_ext, init_seg_ext);\n\tif (!e) e = gf_dasher_enable_segment_timeline(dasher, segment_timeline);\n\tif (!e) e = gf_dasher_enable_single_segment(dasher, single_segment);\n\tif (!e) e = gf_dasher_enable_single_file(dasher, single_file);\n\tif (!e) e = gf_dasher_set_switch_mode(dasher, bitstream_switching_mode);\n\tif (!e) e = gf_dasher_set_durations(dasher, dash_duration, interleaving_time, dash_subduration);\n\tif (!e) e = gf_dasher_enable_rap_splitting(dasher, seg_at_rap, frag_at_rap);\n\tif (!e) e = gf_dasher_set_segment_marker(dasher, segment_marker);\n\tif (!e) e = gf_dasher_enable_sidx(dasher, (subsegs_per_sidx>=0) ? 1 : 0, (u32) subsegs_per_sidx, daisy_chain_sidx, use_ssix);\n\tif (!e) e = gf_dasher_set_dynamic_mode(dasher, dash_mode, mpd_update_time, time_shift_depth, mpd_live_duration);\n\tif (!e) e = gf_dasher_set_min_buffer(dasher, min_buffer);\n\tif (!e) e = gf_dasher_set_ast_offset(dasher, ast_offset_ms);\n\tif (!e) e = gf_dasher_enable_memory_fragmenting(dasher, memory_frags);\n\tif (!e) e = gf_dasher_set_initial_isobmf(dasher, initial_moof_sn, initial_tfdt);\n\tif (!e) e = gf_dasher_configure_isobmf_default(dasher, no_fragments_defaults, pssh_mode, samplegroups_in_traf, single_traf_per_moof, tfdt_per_traf, mvex_after_traks, sdtp_in_traf);\n\tif (!e) e = gf_dasher_enable_utc_ref(dasher, insert_utc);\n\tif (!e) e = gf_dasher_enable_real_time(dasher, frag_real_time);\n\tif (!e) e = gf_dasher_set_content_protection_location_mode(dasher, cp_location_mode);\n\tif (!e) e = gf_dasher_set_profile_extension(dasher, dash_profile_extension);\n\tif (!e) e = gf_dasher_enable_cached_inputs(dasher, no_cache);\n\tif (!e) e = gf_dasher_enable_loop_inputs(dasher, ! no_loop);\n\tif (!e) e = gf_dasher_set_split_mode(dasher, dash_split_mode);\n\tif (!e) e = gf_dasher_set_last_segment_merge(dasher, merge_last_seg);\n\tif (!e) e = gf_dasher_set_hls_clock(dasher, hls_clock);\n\tif (!e && dash_cues) e = gf_dasher_set_cues(dasher, dash_cues, strict_cues);\n\tif (!e) e = gf_dasher_print_session_info(dasher, fs_dump_flags);\n\tif (!e)  e = gf_dasher_keep_source_utc(dasher, keep_utc);\n\n\tfor (i=0; i < nb_dash_inputs; i++) {\n\t\tif (!e) e = gf_dasher_add_input(dasher, &dash_inputs[i]);\n\t}\n\tif (e) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"DASH Setup Error: %s\\n\", gf_error_to_string(e)));\n\t\tgf_dasher_del(dasher);\n\t\treturn e;\n\t}\n\n\tdash_cumulated_time=0;\n\n\twhile (1) {\n\t\tif (run_for && (dash_cumulated_time >= run_for)) {\n\t\t\tM4_LOG(GF_LOG_INFO, (\"Done running, computing static MPD\\n\"));\n\t\t\tdo_abort = 3;\n\t\t}\n\n\t\tdash_prev_time=gf_sys_clock();\n\t\tif (do_abort>=2) {\n\t\t\te = gf_dasher_set_dynamic_mode(dasher, GF_DASH_DYNAMIC_LAST, 0, time_shift_depth, mpd_live_duration);\n\t\t}\n\n\t\tif (!e) e = gf_dasher_process(dasher);\n\t\tif (!dash_live && (e==GF_EOS) ) {\n\t\t\tM4_LOG(GF_LOG_INFO, (\"Nothing to dash, too early ...\\n\"));\n\t\t\te = GF_OK;\n\t\t}\n\n\t\tif (do_abort)\n\t\t\tbreak;\n\n\t\t\/\/this happens when reading file while writing them (local playback of the live session ...)\n\t\tif (dash_live && (e==GF_IO_ERR) ) {\n\t\t\tM4_LOG(GF_LOG_WARNING, (\"Error dashing file (%s) but continuing ...\\n\", gf_error_to_string(e) ));\n\t\t\te = GF_OK;\n\t\t}\n\n\t\tif (e) break;\n\n\t\tif (dash_live) {\n\t\t\tu64 ms_in_session=0;\n\t\t\tu32 slept = gf_sys_clock();\n\t\t\tu32 sleep_for = gf_dasher_next_update_time(dasher, &ms_in_session);\n\t\t\tM4_LOG(GF_LOG_INFO, (\"Next generation scheduled in %u ms (DASH time \"LLU\" ms)\\r\", sleep_for, ms_in_session));\n\t\t\tif (run_for && (ms_in_session>=run_for)) {\n\t\t\t\tdash_cumulated_time = 1+run_for;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\twhile (1) {\n\t\t\t\tif (gf_prompt_has_input()) {\n\t\t\t\t\tchar c = (char) gf_prompt_get_char();\n\t\t\t\t\tif (c=='X') {\n\t\t\t\t\t\tdo_abort = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (c=='q') {\n\t\t\t\t\t\tdo_abort = 2;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (c=='s') {\n\t\t\t\t\t\tdo_abort = 3;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (dash_mode == GF_DASH_DYNAMIC_DEBUG) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!sleep_for) break;\n\n\t\t\t\tgf_sleep(sleep_for\/10);\n\t\t\t\tsleep_for = gf_dasher_next_update_time(dasher, NULL);\n\t\t\t\tif (sleep_for<=1) {\n\t\t\t\t\tdash_now_time=gf_sys_clock();\n\t\t\t\t\tdash_cumulated_time+=(dash_now_time-dash_prev_time);\n\t\t\t\t\tM4_LOG(GF_LOG_INFO, (\"Slept for %d ms before generation, dash cumulated time %d\\n\", dash_now_time - slept, dash_cumulated_time));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tgf_dasher_del(dasher);\n\n\tif (!run_for && dash_ctx_file && (do_abort==3) && (dyn_state_file) && !gf_sys_is_test_mode() ) {\n\t\tchar szName[1024];\n\t\tM4_LOG(GF_LOG_INFO, (\"Enter file name to save dash context:\\n\"));\n\t\tif (scanf(\"%1023s\", szName) == 1) {\n\t\t\tgf_file_move(dash_ctx_file, szName);\n\t\t}\n\t}\n\tif (e) M4_LOG(GF_LOG_ERROR, (\"Error DASHing file: %s\\n\", gf_error_to_string(e)));\n\tif (file) gf_isom_delete(file);\n\tif (del_file)\n\t\tgf_file_delete(inName);\n\n\treturn e;\n}","target":0,"code_token_length":2429,"total_token_length":2665,"max_tokens_setting":4096}
+{"idx":208421,"func":"ex_diffgetput(exarg_T *eap)\n{\n    linenr_T\tlnum;\n    int\t\tcount;\n    linenr_T\toff = 0;\n    diff_T\t*dp;\n    diff_T\t*dprev;\n    diff_T\t*dfree;\n    int\t\tidx_cur;\n    int\t\tidx_other;\n    int\t\tidx_from;\n    int\t\tidx_to;\n    int\t\ti;\n    int\t\tadded;\n    char_u\t*p;\n    aco_save_T\taco;\n    buf_T\t*buf;\n    int\t\tstart_skip, end_skip;\n    int\t\tnew_count;\n    int\t\tbuf_empty;\n    int\t\tfound_not_ma = FALSE;\n\n    \/\/ Find the current buffer in the list of diff buffers.\n    idx_cur = diff_buf_idx(curbuf);\n    if (idx_cur == DB_COUNT)\n    {\n\temsg(_(e_current_buffer_is_not_in_diff_mode));\n\treturn;\n    }\n\n    if (*eap->arg == NUL)\n    {\n\t\/\/ No argument: Find the other buffer in the list of diff buffers.\n\tfor (idx_other = 0; idx_other < DB_COUNT; ++idx_other)\n\t    if (curtab->tp_diffbuf[idx_other] != curbuf\n\t\t    && curtab->tp_diffbuf[idx_other] != NULL)\n\t    {\n\t\tif (eap->cmdidx != CMD_diffput\n\t\t\t\t     || curtab->tp_diffbuf[idx_other]->b_p_ma)\n\t\t    break;\n\t\tfound_not_ma = TRUE;\n\t    }\n\tif (idx_other == DB_COUNT)\n\t{\n\t    if (found_not_ma)\n\t\temsg(_(e_no_other_buffer_in_diff_mode_is_modifiable));\n\t    else\n\t\temsg(_(e_no_other_buffer_in_diff_mode));\n\t    return;\n\t}\n\n\t\/\/ Check that there isn't a third buffer in the list\n\tfor (i = idx_other + 1; i < DB_COUNT; ++i)\n\t    if (curtab->tp_diffbuf[i] != curbuf\n\t\t    && curtab->tp_diffbuf[i] != NULL\n\t\t    && (eap->cmdidx != CMD_diffput || curtab->tp_diffbuf[i]->b_p_ma))\n\t    {\n\t\temsg(_(e_more_than_two_buffers_in_diff_mode_dont_know_which_one_to_use));\n\t\treturn;\n\t    }\n    }\n    else\n    {\n\t\/\/ Buffer number or pattern given.  Ignore trailing white space.\n\tp = eap->arg + STRLEN(eap->arg);\n\twhile (p > eap->arg && VIM_ISWHITE(p[-1]))\n\t    --p;\n\tfor (i = 0; vim_isdigit(eap->arg[i]) && eap->arg + i < p; ++i)\n\t    ;\n\tif (eap->arg + i == p)\t    \/\/ digits only\n\t    i = atol((char *)eap->arg);\n\telse\n\t{\n\t    i = buflist_findpat(eap->arg, p, FALSE, TRUE, FALSE);\n\t    if (i < 0)\n\t\treturn;\t\t\/\/ error message already given\n\t}\n\tbuf = buflist_findnr(i);\n\tif (buf == NULL)\n\t{\n\t    semsg(_(e_cant_find_buffer_str), eap->arg);\n\t    return;\n\t}\n\tif (buf == curbuf)\n\t    return;\t\t\/\/ nothing to do\n\tidx_other = diff_buf_idx(buf);\n\tif (idx_other == DB_COUNT)\n\t{\n\t    semsg(_(e_buffer_str_is_not_in_diff_mode), eap->arg);\n\t    return;\n\t}\n    }\n\n    diff_busy = TRUE;\n\n    \/\/ When no range given include the line above or below the cursor.\n    if (eap->addr_count == 0)\n    {\n\t\/\/ Make it possible that \":diffget\" on the last line gets line below\n\t\/\/ the cursor line when there is no difference above the cursor.\n\tif (eap->cmdidx == CMD_diffget\n\t\t&& eap->line1 == curbuf->b_ml.ml_line_count\n\t\t&& diff_check(curwin, eap->line1) == 0\n\t\t&& (eap->line1 == 1 || diff_check(curwin, eap->line1 - 1) == 0))\n\t    ++eap->line2;\n\telse if (eap->line1 > 0)\n\t    --eap->line1;\n    }\n\n    if (eap->cmdidx == CMD_diffget)\n    {\n\tidx_from = idx_other;\n\tidx_to = idx_cur;\n    }\n    else\n    {\n\tidx_from = idx_cur;\n\tidx_to = idx_other;\n\t\/\/ Need to make the other buffer the current buffer to be able to make\n\t\/\/ changes in it.\n\t\/\/ set curwin\/curbuf to buf and save a few things\n\taucmd_prepbuf(&aco, curtab->tp_diffbuf[idx_other]);\n    }\n\n    \/\/ May give the warning for a changed buffer here, which can trigger the\n    \/\/ FileChangedRO autocommand, which may do nasty things and mess\n    \/\/ everything up.\n    if (!curbuf->b_changed)\n    {\n\tchange_warning(0);\n\tif (diff_buf_idx(curbuf) != idx_to)\n\t{\n\t    emsg(_(e_buffer_changed_unexpectedly));\n\t    goto theend;\n\t}\n    }\n\n    dprev = NULL;\n    for (dp = curtab->tp_first_diff; dp != NULL; )\n    {\n\tif (dp->df_lnum[idx_cur] > eap->line2 + off)\n\t    break;\t\/\/ past the range that was specified\n\n\tdfree = NULL;\n\tlnum = dp->df_lnum[idx_to];\n\tcount = dp->df_count[idx_to];\n\tif (dp->df_lnum[idx_cur] + dp->df_count[idx_cur] > eap->line1 + off\n\t\t&& u_save(lnum - 1, lnum + count) != FAIL)\n\t{\n\t    \/\/ Inside the specified range and saving for undo worked.\n\t    start_skip = 0;\n\t    end_skip = 0;\n\t    if (eap->addr_count > 0)\n\t    {\n\t\t\/\/ A range was specified: check if lines need to be skipped.\n\t\tstart_skip = eap->line1 + off - dp->df_lnum[idx_cur];\n\t\tif (start_skip > 0)\n\t\t{\n\t\t    \/\/ range starts below start of current diff block\n\t\t    if (start_skip > count)\n\t\t    {\n\t\t\tlnum += count;\n\t\t\tcount = 0;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tcount -= start_skip;\n\t\t\tlnum += start_skip;\n\t\t    }\n\t\t}\n\t\telse\n\t\t    start_skip = 0;\n\n\t\tend_skip = dp->df_lnum[idx_cur] + dp->df_count[idx_cur] - 1\n\t\t\t\t\t\t\t - (eap->line2 + off);\n\t\tif (end_skip > 0)\n\t\t{\n\t\t    \/\/ range ends above end of current\/from diff block\n\t\t    if (idx_cur == idx_from)\t\/\/ :diffput\n\t\t    {\n\t\t\ti = dp->df_count[idx_cur] - start_skip - end_skip;\n\t\t\tif (count > i)\n\t\t\t    count = i;\n\t\t    }\n\t\t    else\t\t\t\/\/ :diffget\n\t\t    {\n\t\t\tcount -= end_skip;\n\t\t\tend_skip = dp->df_count[idx_from] - start_skip - count;\n\t\t\tif (end_skip < 0)\n\t\t\t    end_skip = 0;\n\t\t    }\n\t\t}\n\t\telse\n\t\t    end_skip = 0;\n\t    }\n\n\t    buf_empty = BUFEMPTY();\n\t    added = 0;\n\t    for (i = 0; i < count; ++i)\n\t    {\n\t\t\/\/ remember deleting the last line of the buffer\n\t\tbuf_empty = curbuf->b_ml.ml_line_count == 1;\n\t\tml_delete(lnum);\n\t\t--added;\n\t    }\n\t    for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)\n\t    {\n\t\tlinenr_T nr;\n\n\t\tnr = dp->df_lnum[idx_from] + start_skip + i;\n\t\tif (nr > curtab->tp_diffbuf[idx_from]->b_ml.ml_line_count)\n\t\t    break;\n\t\tp = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx_from],\n\t\t\t\t\t\t\t\t  nr, FALSE));\n\t\tif (p != NULL)\n\t\t{\n\t\t    ml_append(lnum + i - 1, p, 0, FALSE);\n\t\t    vim_free(p);\n\t\t    ++added;\n\t\t    if (buf_empty && curbuf->b_ml.ml_line_count == 2)\n\t\t    {\n\t\t\t\/\/ Added the first line into an empty buffer, need to\n\t\t\t\/\/ delete the dummy empty line.\n\t\t\tbuf_empty = FALSE;\n\t\t\tml_delete((linenr_T)2);\n\t\t    }\n\t\t}\n\t    }\n\t    new_count = dp->df_count[idx_to] + added;\n\t    dp->df_count[idx_to] = new_count;\n\n\t    if (start_skip == 0 && end_skip == 0)\n\t    {\n\t\t\/\/ Check if there are any other buffers and if the diff is\n\t\t\/\/ equal in them.\n\t\tfor (i = 0; i < DB_COUNT; ++i)\n\t\t    if (curtab->tp_diffbuf[i] != NULL && i != idx_from\n\t\t\t\t\t\t\t\t&& i != idx_to\n\t\t\t    && !diff_equal_entry(dp, idx_from, i))\n\t\t\tbreak;\n\t\tif (i == DB_COUNT)\n\t\t{\n\t\t    \/\/ delete the diff entry, the buffers are now equal here\n\t\t    dfree = dp;\n\t\t    dp = dp->df_next;\n\t\t    if (dprev == NULL)\n\t\t\tcurtab->tp_first_diff = dp;\n\t\t    else\n\t\t\tdprev->df_next = dp;\n\t\t}\n\t    }\n\n\t    \/\/ Adjust marks.  This will change the following entries!\n\t    if (added != 0)\n\t    {\n\t\tmark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added);\n\t\tif (curwin->w_cursor.lnum >= lnum)\n\t\t{\n\t\t    \/\/ Adjust the cursor position if it's in\/after the changed\n\t\t    \/\/ lines.\n\t\t    if (curwin->w_cursor.lnum >= lnum + count)\n\t\t\tcurwin->w_cursor.lnum += added;\n\t\t    else if (added < 0)\n\t\t\tcurwin->w_cursor.lnum = lnum;\n\t\t}\n\t    }\n\t    changed_lines(lnum, 0, lnum + count, (long)added);\n\n\t    if (dfree != NULL)\n\t    {\n\t\t\/\/ Diff is deleted, update folds in other windows.\n#ifdef FEAT_FOLDING\n\t\tdiff_fold_update(dfree, idx_to);\n#endif\n\t\tvim_free(dfree);\n\t    }\n\t    else\n\t\t\/\/ mark_adjust() may have changed the count in a wrong way\n\t\tdp->df_count[idx_to] = new_count;\n\n\t    \/\/ When changing the current buffer, keep track of line numbers\n\t    if (idx_cur == idx_to)\n\t\toff += added;\n\t}\n\n\t\/\/ If before the range or not deleted, go to next diff.\n\tif (dfree == NULL)\n\t{\n\t    dprev = dp;\n\t    dp = dp->df_next;\n\t}\n    }\n\n    \/\/ restore curwin\/curbuf and a few other things\n    if (eap->cmdidx != CMD_diffget)\n    {\n\t\/\/ Syncing undo only works for the current buffer, but we change\n\t\/\/ another buffer.  Sync undo if the command was typed.  This isn't\n\t\/\/ 100% right when \":diffput\" is used in a function or mapping.\n\tif (KeyTyped)\n\t    u_sync(FALSE);\n\taucmd_restbuf(&aco);\n    }\n\ntheend:\n    diff_busy = FALSE;\n    if (diff_need_update)\n\tex_diffupdate(NULL);\n\n    \/\/ Check that the cursor is on a valid character and update its\n    \/\/ position.  When there were filler lines the topline has become\n    \/\/ invalid.\n    check_cursor();\n    changed_line_abv_curs();\n\n    if (diff_need_update)\n\t\/\/ redraw already done by ex_diffupdate()\n\tdiff_need_update = FALSE;\n    else\n    {\n\t\/\/ Also need to redraw the other buffers.\n\tdiff_redraw(FALSE);\n\tapply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, FALSE, curbuf);\n    }\n}","target":1,"code_token_length":2606,"total_token_length":2842,"max_tokens_setting":4096}
+{"idx":200157,"func":"readconf_main(void)\n{\nint sep = 0;\nstruct stat statbuf;\nuschar *s, *filename;\nuschar *list = config_main_filelist;\n\n\/* Loop through the possible file names *\/\n\nwhile((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size))\n       != NULL)\n  {\n  \/* Cut out all the fancy processing unless specifically wanted *\/\n\n  #if defined(CONFIGURE_FILE_USE_NODE) || defined(CONFIGURE_FILE_USE_EUID)\n  uschar *suffix = filename + Ustrlen(filename);\n\n  \/* Try for the node-specific file if a node name exists *\/\n\n  #ifdef CONFIGURE_FILE_USE_NODE\n  struct utsname uts;\n  if (uname(&uts) >= 0)\n    {\n    #ifdef CONFIGURE_FILE_USE_EUID\n    sprintf(CS suffix, \".%ld.%.256s\", (long int)original_euid, uts.nodename);\n    config_file = Ufopen(filename, \"rb\");\n    if (config_file == NULL)\n    #endif  \/* CONFIGURE_FILE_USE_EUID *\/\n      {\n      sprintf(CS suffix, \".%.256s\", uts.nodename);\n      config_file = Ufopen(filename, \"rb\");\n      }\n    }\n  #endif  \/* CONFIGURE_FILE_USE_NODE *\/\n\n  \/* Otherwise, try the generic name, possibly with the euid added *\/\n\n  #ifdef CONFIGURE_FILE_USE_EUID\n  if (config_file == NULL)\n    {\n    sprintf(CS suffix, \".%ld\", (long int)original_euid);\n    config_file = Ufopen(filename, \"rb\");\n    }\n  #endif  \/* CONFIGURE_FILE_USE_EUID *\/\n\n  \/* Finally, try the unadorned name *\/\n\n  if (config_file == NULL)\n    {\n    *suffix = 0;\n    config_file = Ufopen(filename, \"rb\");\n    }\n  #else  \/* if neither defined *\/\n\n  \/* This is the common case when the fancy processing is not included. *\/\n\n  config_file = Ufopen(filename, \"rb\");\n  #endif\n\n  \/* If the file does not exist, continue to try any others. For any other\n  error, break out (and die). *\/\n\n  if (config_file != NULL || errno != ENOENT) break;\n  }\n\n\/* On success, save the name for verification; config_filename is used when\nlogging configuration errors (it changes for .included files) whereas\nconfig_main_filename is the name shown by -bP. Failure to open a configuration\nfile is a serious disaster. *\/\n\nif (config_file != NULL)\n  {\n  config_filename = config_main_filename = string_copy(filename);\n  }\nelse\n  {\n  if (filename == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"non-existent configuration file(s): \"\n      \"%s\", config_main_filelist);\n  else\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"%s\", string_open_failed(errno,\n      \"configuration file %s\", filename));\n  }\n\n\/* Check the status of the file we have opened, unless it was specified on\nthe command line, in which case privilege was given away at the start. *\/\n\nif (!config_changed)\n  {\n  if (fstat(fileno(config_file), &statbuf) != 0)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to stat configuration file %s\",\n      big_buffer);\n\n  if ((statbuf.st_uid != root_uid                \/* owner not root *\/\n       #ifdef CONFIGURE_OWNER\n       && statbuf.st_uid != config_uid           \/* owner not the special one *\/\n       #endif\n         ) ||                                    \/* or *\/\n      (statbuf.st_gid != root_gid                \/* group not root & *\/\n       #ifdef CONFIGURE_GROUP\n       && statbuf.st_gid != config_gid           \/* group not the special one *\/\n       #endif\n       && (statbuf.st_mode & 020) != 0) ||       \/* group writeable  *\/\n                                                 \/* or *\/\n      ((statbuf.st_mode & 2) != 0))              \/* world writeable  *\/\n\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"Exim configuration file %s has the \"\n      \"wrong owner, group, or mode\", big_buffer);\n  }\n\n\/* Process the main configuration settings. They all begin with a lower case\nletter. If we see something starting with an upper case letter, it is taken as\na macro definition. *\/\n\nwhile ((s = get_config_line()) != NULL)\n  {\n  if (isupper(s[0])) read_macro_assignment(s);\n\n  else if (Ustrncmp(s, \"domainlist\", 10) == 0)\n    read_named_list(&domainlist_anchor, &domainlist_count,\n      MAX_NAMED_LIST, s+10, US\"domain list\");\n\n  else if (Ustrncmp(s, \"hostlist\", 8) == 0)\n    read_named_list(&hostlist_anchor, &hostlist_count,\n      MAX_NAMED_LIST, s+8, US\"host list\");\n\n  else if (Ustrncmp(s, US\"addresslist\", 11) == 0)\n    read_named_list(&addresslist_anchor, &addresslist_count,\n      MAX_NAMED_LIST, s+11, US\"address list\");\n\n  else if (Ustrncmp(s, US\"localpartlist\", 13) == 0)\n    read_named_list(&localpartlist_anchor, &localpartlist_count,\n      MAX_NAMED_LIST, s+13, US\"local part list\");\n\n  else\n    (void) readconf_handle_option(s, optionlist_config, optionlist_config_size,\n      NULL, US\"main option \\\"%s\\\" unknown\");\n  }\n\n\n\/* If local_sender_retain is set, local_from_check must be unset. *\/\n\nif (local_sender_retain && local_from_check)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"both local_from_check and \"\n    \"local_sender_retain are set; this combination is not allowed\");\n\n\/* If the timezone string is empty, set it to NULL, implying no TZ variable\nwanted. *\/\n\nif (timezone_string != NULL && *timezone_string == 0) timezone_string = NULL;\n\n\/* The max retry interval must not be greater than 24 hours. *\/\n\nif (retry_interval_max > 24*60*60) retry_interval_max = 24*60*60;\n\n\/* remote_max_parallel must be > 0 *\/\n\nif (remote_max_parallel <= 0) remote_max_parallel = 1;\n\n\/* Save the configured setting of freeze_tell, so we can re-instate it at the\nstart of a new SMTP message. *\/\n\nfreeze_tell_config = freeze_tell;\n\n\/* The primary host name may be required for expansion of spool_directory\nand log_file_path, so make sure it is set asap. It is obtained from uname(),\nbut if that yields an unqualified value, make a FQDN by using gethostbyname to\ncanonize it. Some people like upper case letters in their host names, so we\ndon't force the case. *\/\n\nif (primary_hostname == NULL)\n  {\n  uschar *hostname;\n  struct utsname uts;\n  if (uname(&uts) < 0)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"uname() failed to yield host name\");\n  hostname = US uts.nodename;\n\n  if (Ustrchr(hostname, '.') == NULL)\n    {\n    int af = AF_INET;\n    struct hostent *hostdata;\n\n    #if HAVE_IPV6\n    if (!disable_ipv6 && (dns_ipv4_lookup == NULL ||\n         match_isinlist(hostname, &dns_ipv4_lookup, 0, NULL, NULL, MCL_DOMAIN,\n           TRUE, NULL) != OK))\n      af = AF_INET6;\n    #else\n    af = AF_INET;\n    #endif\n\n    for (;;)\n      {\n      #if HAVE_IPV6\n        #if HAVE_GETIPNODEBYNAME\n        int error_num;\n        hostdata = getipnodebyname(CS hostname, af, 0, &error_num);\n        #else\n        hostdata = gethostbyname2(CS hostname, af);\n        #endif\n      #else\n      hostdata = gethostbyname(CS hostname);\n      #endif\n\n      if (hostdata != NULL)\n        {\n        hostname = US hostdata->h_name;\n        break;\n        }\n\n      if (af == AF_INET) break;\n      af = AF_INET;\n      }\n    }\n\n  primary_hostname = string_copy(hostname);\n  }\n\n\/* Set up default value for smtp_active_hostname *\/\n\nsmtp_active_hostname = primary_hostname;\n\n\/* If spool_directory wasn't set in the build-time configuration, it must have\ngot set above. Of course, writing to the log may not work if log_file_path is\nnot set, but it will at least get to syslog or somewhere, with any luck. *\/\n\nif (*spool_directory == 0)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"spool_directory undefined: cannot \"\n    \"proceed\");\n\n\/* Expand the spool directory name; it may, for example, contain the primary\nhost name. Same comment about failure. *\/\n\ns = expand_string(spool_directory);\nif (s == NULL)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to expand spool_directory \"\n    \"\\\"%s\\\": %s\", spool_directory, expand_string_message);\nspool_directory = s;\n\n\/* Expand log_file_path, which must contain \"%s\" in any component that isn't\nthe null string or \"syslog\". It is also allowed to contain one instance of %D.\nHowever, it must NOT contain % followed by anything else. *\/\n\nif (*log_file_path != 0)\n  {\n  uschar *ss, *sss;\n  int sep = ':';                       \/* Fixed for log file path *\/\n  s = expand_string(log_file_path);\n  if (s == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to expand log_file_path \"\n      \"\\\"%s\\\": %s\", log_file_path, expand_string_message);\n\n  ss = s;\n  while ((sss = string_nextinlist(&ss,&sep,big_buffer,big_buffer_size)) != NULL)\n    {\n    uschar *t;\n    if (sss[0] == 0 || Ustrcmp(sss, \"syslog\") == 0) continue;\n    t = Ustrstr(sss, \"%s\");\n    if (t == NULL)\n      log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"log_file_path \\\"%s\\\" does not \"\n        \"contain \\\"%%s\\\"\", sss);\n    *t = 'X';\n    t = Ustrchr(sss, '%');\n    if (t != NULL)\n      {\n      if (t[1] != 'D' || Ustrchr(t+2, '%') != NULL)\n        log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"log_file_path \\\"%s\\\" contains \"\n          \"unexpected \\\"%%\\\" character\", s);\n      }\n    }\n\n  log_file_path = s;\n  }\n\n\/* Interpret syslog_facility into an integer argument for 'ident' param to\nopenlog(). Default is LOG_MAIL set in globals.c. Allow the user to omit the\nleading \"log_\". *\/\n\nif (syslog_facility_str != NULL)\n  {\n  int i;\n  uschar *s = syslog_facility_str;\n\n  if ((Ustrlen(syslog_facility_str) >= 4) &&\n        (strncmpic(syslog_facility_str, US\"log_\", 4) == 0))\n    s += 4;\n\n  for (i = 0; i < syslog_list_size; i++)\n    {\n    if (strcmpic(s, syslog_list[i].name) == 0)\n      {\n      syslog_facility = syslog_list[i].value;\n      break;\n      }\n    }\n\n  if (i >= syslog_list_size)\n    {\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"failed to interpret syslog_facility \\\"%s\\\"\", syslog_facility_str);\n    }\n  }\n\n\/* Expand pid_file_path *\/\n\nif (*pid_file_path != 0)\n  {\n  s = expand_string(pid_file_path);\n  if (s == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to expand pid_file_path \"\n      \"\\\"%s\\\": %s\", pid_file_path, expand_string_message);\n  pid_file_path = s;\n  }\n\n\/* Compile the regex for matching a UUCP-style \"From_\" line in an incoming\nmessage. *\/\n\nregex_From = regex_must_compile(uucp_from_pattern, FALSE, TRUE);\n\n\/* Unpick the SMTP rate limiting options, if set *\/\n\nif (smtp_ratelimit_mail != NULL)\n  {\n  unpick_ratelimit(smtp_ratelimit_mail, &smtp_rlm_threshold,\n    &smtp_rlm_base, &smtp_rlm_factor, &smtp_rlm_limit);\n  }\n\nif (smtp_ratelimit_rcpt != NULL)\n  {\n  unpick_ratelimit(smtp_ratelimit_rcpt, &smtp_rlr_threshold,\n    &smtp_rlr_base, &smtp_rlr_factor, &smtp_rlr_limit);\n  }\n\n\/* The qualify domains default to the primary host name *\/\n\nif (qualify_domain_sender == NULL)\n  qualify_domain_sender = primary_hostname;\nif (qualify_domain_recipient == NULL)\n  qualify_domain_recipient = qualify_domain_sender;\n\n\/* Setting system_filter_user in the configuration sets the gid as well if a\nname is given, but a numerical value does not. *\/\n\nif (system_filter_uid_set && !system_filter_gid_set)\n  {\n  struct passwd *pw = getpwuid(system_filter_uid);\n  if (pw == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"Failed to look up uid %ld\",\n      (long int)system_filter_uid);\n  system_filter_gid = pw->pw_gid;\n  system_filter_gid_set = TRUE;\n  }\n\n\/* If the errors_reply_to field is set, check that it is syntactically valid\nand ensure it contains a domain. *\/\n\nif (errors_reply_to != NULL)\n  {\n  uschar *errmess;\n  int start, end, domain;\n  uschar *recipient = parse_extract_address(errors_reply_to, &errmess,\n    &start, &end, &domain, FALSE);\n\n  if (recipient == NULL)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"error in errors_reply_to (%s): %s\", errors_reply_to, errmess);\n\n  if (domain == 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"errors_reply_to (%s) does not contain a domain\", errors_reply_to);\n  }\n\n\/* If smtp_accept_queue or smtp_accept_max_per_host is set, then\nsmtp_accept_max must also be set. *\/\n\nif (smtp_accept_max == 0 &&\n    (smtp_accept_queue > 0 || smtp_accept_max_per_host != NULL))\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n    \"smtp_accept_max must be set if smtp_accept_queue or \"\n    \"smtp_accept_max_per_host is set\");\n\n\/* Set up the host number if anything is specified. It is an expanded string\nso that it can be computed from the host name, for example. We do this last\nso as to ensure that everything else is set up before the expansion. *\/\n\nif (host_number_string != NULL)\n  {\n  uschar *end;\n  uschar *s = expand_string(host_number_string);\n  long int n = Ustrtol(s, &end, 0);\n  while (isspace(*end)) end++;\n  if (*end != 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"localhost_number value is not a number: %s\", s);\n  if (n > LOCALHOST_MAX)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"localhost_number is greater than the maximum allowed value (%d)\",\n        LOCALHOST_MAX);\n  host_number = n;\n  }\n\n#ifdef SUPPORT_TLS\n\/* If tls_verify_hosts is set, tls_verify_certificates must also be set *\/\n\nif ((tls_verify_hosts != NULL || tls_try_verify_hosts != NULL) &&\n     tls_verify_certificates == NULL)\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n    \"tls_%sverify_hosts is set, but tls_verify_certificates is not set\",\n    (tls_verify_hosts != NULL)? \"\" : \"try_\");\n\n\/* If openssl_options is set, validate it *\/\nif (openssl_options != NULL)\n  {\n# ifdef USE_GNUTLS\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n    \"openssl_options is set but we're using GnuTLS\");\n# else\n  long dummy;\n  if (!(tls_openssl_options_parse(openssl_options, &dummy)))\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"openssl_options parse error: %s\", openssl_options);\n# endif\n  }\n#endif\n}","target":1,"code_token_length":3679,"total_token_length":3915,"max_tokens_setting":4096}
+{"idx":199851,"func":"ex_retab(exarg_T *eap)\n{\n    linenr_T\tlnum;\n    int\t\tgot_tab = FALSE;\n    long\tnum_spaces = 0;\n    long\tnum_tabs;\n    long\tlen;\n    long\tcol;\n    long\tvcol;\n    long\tstart_col = 0;\t\t\/\/ For start of white-space string\n    long\tstart_vcol = 0;\t\t\/\/ For start of white-space string\n    long\told_len;\n    char_u\t*ptr;\n    char_u\t*new_line = (char_u *)1; \/\/ init to non-NULL\n    int\t\tdid_undo;\t\t\/\/ called u_save for current line\n#ifdef FEAT_VARTABS\n    int\t\t*new_vts_array = NULL;\n    char_u\t*new_ts_str;\t\t\/\/ string value of tab argument\n#else\n    int\t\ttemp;\n    int\t\tnew_ts;\n#endif\n    int\t\tsave_list;\n    linenr_T\tfirst_line = 0;\t\t\/\/ first changed line\n    linenr_T\tlast_line = 0;\t\t\/\/ last changed line\n\n    save_list = curwin->w_p_list;\n    curwin->w_p_list = 0;\t    \/\/ don't want list mode here\n\n#ifdef FEAT_VARTABS\n    new_ts_str = eap->arg;\n    if (tabstop_set(eap->arg, &new_vts_array) == FAIL)\n\treturn;\n    while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')\n\t++(eap->arg);\n\n    \/\/ This ensures that either new_vts_array and new_ts_str are freshly\n    \/\/ allocated, or new_vts_array points to an existing array and new_ts_str\n    \/\/ is null.\n    if (new_vts_array == NULL)\n    {\n\tnew_vts_array = curbuf->b_p_vts_array;\n\tnew_ts_str = NULL;\n    }\n    else\n\tnew_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);\n#else\n    ptr = eap->arg;\n    new_ts = getdigits(&ptr);\n    if (new_ts < 0 && *eap->arg == '-')\n    {\n\temsg(_(e_argument_must_be_positive));\n\treturn;\n    }\n    if (new_ts < 0 || new_ts > TABSTOP_MAX)\n    {\n\tsemsg(_(e_invalid_argument_str), eap->arg);\n\treturn;\n    }\n    if (new_ts == 0)\n\tnew_ts = curbuf->b_p_ts;\n#endif\n    for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)\n    {\n\tptr = ml_get(lnum);\n\tcol = 0;\n\tvcol = 0;\n\tdid_undo = FALSE;\n\tfor (;;)\n\t{\n\t    if (VIM_ISWHITE(ptr[col]))\n\t    {\n\t\tif (!got_tab && num_spaces == 0)\n\t\t{\n\t\t    \/\/ First consecutive white-space\n\t\t    start_vcol = vcol;\n\t\t    start_col = col;\n\t\t}\n\t\tif (ptr[col] == ' ')\n\t\t    num_spaces++;\n\t\telse\n\t\t    got_tab = TRUE;\n\t    }\n\t    else\n\t    {\n\t\tif (got_tab || (eap->forceit && num_spaces > 1))\n\t\t{\n\t\t    \/\/ Retabulate this string of white-space\n\n\t\t    \/\/ len is virtual length of white string\n\t\t    len = num_spaces = vcol - start_vcol;\n\t\t    num_tabs = 0;\n\t\t    if (!curbuf->b_p_et)\n\t\t    {\n#ifdef FEAT_VARTABS\n\t\t\tint t, s;\n\n\t\t\ttabstop_fromto(start_vcol, vcol,\n\t\t\t\t\tcurbuf->b_p_ts, new_vts_array, &t, &s);\n\t\t\tnum_tabs = t;\n\t\t\tnum_spaces = s;\n#else\n\t\t\ttemp = new_ts - (start_vcol % new_ts);\n\t\t\tif (num_spaces >= temp)\n\t\t\t{\n\t\t\t    num_spaces -= temp;\n\t\t\t    num_tabs++;\n\t\t\t}\n\t\t\tnum_tabs += num_spaces \/ new_ts;\n\t\t\tnum_spaces -= (num_spaces \/ new_ts) * new_ts;\n#endif\n\t\t    }\n\t\t    if (curbuf->b_p_et || got_tab ||\n\t\t\t\t\t(num_spaces + num_tabs < len))\n\t\t    {\n\t\t\tif (did_undo == FALSE)\n\t\t\t{\n\t\t\t    did_undo = TRUE;\n\t\t\t    if (u_save((linenr_T)(lnum - 1),\n\t\t\t\t\t\t(linenr_T)(lnum + 1)) == FAIL)\n\t\t\t    {\n\t\t\t\tnew_line = NULL;\t\/\/ flag out-of-memory\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t}\n\n\t\t\t\/\/ len is actual number of white characters used\n\t\t\tlen = num_spaces + num_tabs;\n\t\t\told_len = (long)STRLEN(ptr);\n\t\t\tnew_line = alloc(old_len - col + start_col + len + 1);\n\t\t\tif (new_line == NULL)\n\t\t\t    break;\n\t\t\tif (start_col > 0)\n\t\t\t    mch_memmove(new_line, ptr, (size_t)start_col);\n\t\t\tmch_memmove(new_line + start_col + len,\n\t\t\t\t      ptr + col, (size_t)(old_len - col + 1));\n\t\t\tptr = new_line + start_col;\n\t\t\tfor (col = 0; col < len; col++)\n\t\t\t    ptr[col] = (col < num_tabs) ? '\\t' : ' ';\n\t\t\tif (ml_replace(lnum, new_line, FALSE) == OK)\n\t\t\t    \/\/ \"new_line\" may have been copied\n\t\t\t    new_line = curbuf->b_ml.ml_line_ptr;\n\t\t\tif (first_line == 0)\n\t\t\t    first_line = lnum;\n\t\t\tlast_line = lnum;\n\t\t\tptr = new_line;\n\t\t\tcol = start_col + len;\n\t\t    }\n\t\t}\n\t\tgot_tab = FALSE;\n\t\tnum_spaces = 0;\n\t    }\n\t    if (ptr[col] == NUL)\n\t\tbreak;\n\t    vcol += chartabsize(ptr + col, (colnr_T)vcol);\n\t    if (has_mbyte)\n\t\tcol += (*mb_ptr2len)(ptr + col);\n\t    else\n\t\t++col;\n\t}\n\tif (new_line == NULL)\t\t    \/\/ out of memory\n\t    break;\n\tline_breakcheck();\n    }\n    if (got_int)\n\temsg(_(e_interrupted));\n\n#ifdef FEAT_VARTABS\n    \/\/ If a single value was given then it can be considered equal to\n    \/\/ either the value of 'tabstop' or the value of 'vartabstop'.\n    if (tabstop_count(curbuf->b_p_vts_array) == 0\n\t&& tabstop_count(new_vts_array) == 1\n\t&& curbuf->b_p_ts == tabstop_first(new_vts_array))\n\t; \/\/ not changed\n    else if (tabstop_count(curbuf->b_p_vts_array) > 0\n        && tabstop_eq(curbuf->b_p_vts_array, new_vts_array))\n\t; \/\/ not changed\n    else\n\tredraw_curbuf_later(NOT_VALID);\n#else\n    if (curbuf->b_p_ts != new_ts)\n\tredraw_curbuf_later(NOT_VALID);\n#endif\n    if (first_line != 0)\n\tchanged_lines(first_line, 0, last_line + 1, 0L);\n\n    curwin->w_p_list = save_list;\t\/\/ restore 'list'\n\n#ifdef FEAT_VARTABS\n    if (new_ts_str != NULL)\t\t\/\/ set the new tabstop\n    {\n\t\/\/ If 'vartabstop' is in use or if the value given to retab has more\n\t\/\/ than one tabstop then update 'vartabstop'.\n\tint *old_vts_ary = curbuf->b_p_vts_array;\n\n\tif (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)\n\t{\n\t    set_string_option_direct((char_u *)\"vts\", -1, new_ts_str,\n\t\t\t\t\t\t\tOPT_FREE|OPT_LOCAL, 0);\n\t    curbuf->b_p_vts_array = new_vts_array;\n\t    vim_free(old_vts_ary);\n\t}\n\telse\n\t{\n\t    \/\/ 'vartabstop' wasn't in use and a single value was given to\n\t    \/\/ retab then update 'tabstop'.\n\t    curbuf->b_p_ts = tabstop_first(new_vts_array);\n\t    vim_free(new_vts_array);\n\t}\n\tvim_free(new_ts_str);\n    }\n#else\n    curbuf->b_p_ts = new_ts;\n#endif\n    coladvance(curwin->w_curswant);\n\n    u_clearline();\n}","target":1,"code_token_length":1827,"total_token_length":2063,"max_tokens_setting":4096}
+{"idx":332390,"func":"cursor_pos_info(dict_T *dict)\n{\n    char_u\t*p;\n    char_u\tbuf1[50];\n    char_u\tbuf2[40];\n    linenr_T\tlnum;\n    varnumber_T\tbyte_count = 0;\n    varnumber_T\tbom_count  = 0;\n    varnumber_T\tbyte_count_cursor = 0;\n    varnumber_T\tchar_count = 0;\n    varnumber_T\tchar_count_cursor = 0;\n    varnumber_T\tword_count = 0;\n    varnumber_T\tword_count_cursor = 0;\n    int\t\teol_size;\n    varnumber_T\tlast_check = 100000L;\n    long\tline_count_selected = 0;\n    pos_T\tmin_pos, max_pos;\n    oparg_T\toparg;\n    struct block_def\tbd;\n\n    \/*\n     * Compute the length of the file in characters.\n     *\/\n    if (curbuf->b_ml.ml_flags & ML_EMPTY)\n    {\n\tif (dict == NULL)\n\t{\n\t    msg(_(no_lines_msg));\n\t    return;\n\t}\n    }\n    else\n    {\n\tif (get_fileformat(curbuf) == EOL_DOS)\n\t    eol_size = 2;\n\telse\n\t    eol_size = 1;\n\n\tif (VIsual_active)\n\t{\n\t    if (LT_POS(VIsual, curwin->w_cursor))\n\t    {\n\t\tmin_pos = VIsual;\n\t\tmax_pos = curwin->w_cursor;\n\t    }\n\t    else\n\t    {\n\t\tmin_pos = curwin->w_cursor;\n\t\tmax_pos = VIsual;\n\t    }\n\t    if (*p_sel == 'e' && max_pos.col > 0)\n\t\t--max_pos.col;\n\n\t    if (VIsual_mode == Ctrl_V)\n\t    {\n#ifdef FEAT_LINEBREAK\n\t\tchar_u * saved_sbr = p_sbr;\n\t\tchar_u * saved_w_sbr = curwin->w_p_sbr;\n\n\t\t\/\/ Make 'sbr' empty for a moment to get the correct size.\n\t\tp_sbr = empty_option;\n\t\tcurwin->w_p_sbr = empty_option;\n#endif\n\t\toparg.is_VIsual = 1;\n\t\toparg.block_mode = TRUE;\n\t\toparg.op_type = OP_NOP;\n\t\tgetvcols(curwin, &min_pos, &max_pos,\n\t\t\t\t\t  &oparg.start_vcol, &oparg.end_vcol);\n#ifdef FEAT_LINEBREAK\n\t\tp_sbr = saved_sbr;\n\t\tcurwin->w_p_sbr = saved_w_sbr;\n#endif\n\t\tif (curwin->w_curswant == MAXCOL)\n\t\t    oparg.end_vcol = MAXCOL;\n\t\t\/\/ Swap the start, end vcol if needed\n\t\tif (oparg.end_vcol < oparg.start_vcol)\n\t\t{\n\t\t    oparg.end_vcol += oparg.start_vcol;\n\t\t    oparg.start_vcol = oparg.end_vcol - oparg.start_vcol;\n\t\t    oparg.end_vcol -= oparg.start_vcol;\n\t\t}\n\t    }\n\t    line_count_selected = max_pos.lnum - min_pos.lnum + 1;\n\t}\n\n\tfor (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)\n\t{\n\t    \/\/ Check for a CTRL-C every 100000 characters.\n\t    if (byte_count > last_check)\n\t    {\n\t\tui_breakcheck();\n\t\tif (got_int)\n\t\t    return;\n\t\tlast_check = byte_count + 100000L;\n\t    }\n\n\t    \/\/ Do extra processing for VIsual mode.\n\t    if (VIsual_active\n\t\t    && lnum >= min_pos.lnum && lnum <= max_pos.lnum)\n\t    {\n\t\tchar_u\t    *s = NULL;\n\t\tlong\t    len = 0L;\n\n\t\tswitch (VIsual_mode)\n\t\t{\n\t\t    case Ctrl_V:\n\t\t\tvirtual_op = virtual_active();\n\t\t\tblock_prep(&oparg, &bd, lnum, 0);\n\t\t\tvirtual_op = MAYBE;\n\t\t\ts = bd.textstart;\n\t\t\tlen = (long)bd.textlen;\n\t\t\tbreak;\n\t\t    case 'V':\n\t\t\ts = ml_get(lnum);\n\t\t\tlen = MAXCOL;\n\t\t\tbreak;\n\t\t    case 'v':\n\t\t\t{\n\t\t\t    colnr_T start_col = (lnum == min_pos.lnum)\n\t\t\t\t\t\t\t   ? min_pos.col : 0;\n\t\t\t    colnr_T end_col = (lnum == max_pos.lnum)\n\t\t\t\t      ? max_pos.col - start_col + 1 : MAXCOL;\n\n\t\t\t    s = ml_get(lnum) + start_col;\n\t\t\t    len = end_col;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (s != NULL)\n\t\t{\n\t\t    byte_count_cursor += line_count_info(s, &word_count_cursor,\n\t\t\t\t\t   &char_count_cursor, len, eol_size);\n\t\t    if (lnum == curbuf->b_ml.ml_line_count\n\t\t\t    && !curbuf->b_p_eol\n\t\t\t    && (curbuf->b_p_bin || !curbuf->b_p_fixeol)\n\t\t\t    && (long)STRLEN(s) < len)\n\t\t\tbyte_count_cursor -= eol_size;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ In non-visual mode, check for the line the cursor is on\n\t\tif (lnum == curwin->w_cursor.lnum)\n\t\t{\n\t\t    word_count_cursor += word_count;\n\t\t    char_count_cursor += char_count;\n\t\t    byte_count_cursor = byte_count +\n\t\t\tline_count_info(ml_get(lnum),\n\t\t\t\t&word_count_cursor, &char_count_cursor,\n\t\t\t\t(varnumber_T)(curwin->w_cursor.col + 1),\n\t\t\t\teol_size);\n\t\t}\n\t    }\n\t    \/\/ Add to the running totals\n\t    byte_count += line_count_info(ml_get(lnum), &word_count,\n\t\t\t\t\t &char_count, (varnumber_T)MAXCOL,\n\t\t\t\t\t eol_size);\n\t}\n\n\t\/\/ Correction for when last line doesn't have an EOL.\n\tif (!curbuf->b_p_eol && (curbuf->b_p_bin || !curbuf->b_p_fixeol))\n\t    byte_count -= eol_size;\n\n\tif (dict == NULL)\n\t{\n\t    if (VIsual_active)\n\t    {\n\t\tif (VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL)\n\t\t{\n\t\t    getvcols(curwin, &min_pos, &max_pos, &min_pos.col,\n\t\t\t\t\t\t\t\t    &max_pos.col);\n\t\t    vim_snprintf((char *)buf1, sizeof(buf1), _(\"%ld Cols; \"),\n\t\t\t    (long)(oparg.end_vcol - oparg.start_vcol + 1));\n\t\t}\n\t\telse\n\t\t    buf1[0] = NUL;\n\n\t\tif (char_count_cursor == byte_count_cursor\n\t\t\t\t\t\t    && char_count == byte_count)\n\t\t    vim_snprintf((char *)IObuff, IOSIZE,\n\t\t\t    _(\"Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes\"),\n\t\t\t    buf1, line_count_selected,\n\t\t\t    (long)curbuf->b_ml.ml_line_count,\n\t\t\t    (varnumber_T)word_count_cursor,\n\t\t\t    (varnumber_T)word_count,\n\t\t\t    (varnumber_T)byte_count_cursor,\n\t\t\t    (varnumber_T)byte_count);\n\t\telse\n\t\t    vim_snprintf((char *)IObuff, IOSIZE,\n\t\t\t    _(\"Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes\"),\n\t\t\t    buf1, line_count_selected,\n\t\t\t    (long)curbuf->b_ml.ml_line_count,\n\t\t\t    (varnumber_T)word_count_cursor,\n\t\t\t    (varnumber_T)word_count,\n\t\t\t    (varnumber_T)char_count_cursor,\n\t\t\t    (varnumber_T)char_count,\n\t\t\t    (varnumber_T)byte_count_cursor,\n\t\t\t    (varnumber_T)byte_count);\n\t    }\n\t    else\n\t    {\n\t\tp = ml_get_curline();\n\t\tvalidate_virtcol();\n\t\tcol_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,\n\t\t\t(int)curwin->w_virtcol + 1);\n\t\tcol_print(buf2, sizeof(buf2), (int)STRLEN(p),\n\t\t\t\t    linetabsize(p));\n\n\t\tif (char_count_cursor == byte_count_cursor\n\t\t\t&& char_count == byte_count)\n\t\t    vim_snprintf((char *)IObuff, IOSIZE,\n\t\t\t_(\"Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld\"),\n\t\t\t(char *)buf1, (char *)buf2,\n\t\t\t(long)curwin->w_cursor.lnum,\n\t\t\t(long)curbuf->b_ml.ml_line_count,\n\t\t\t(varnumber_T)word_count_cursor, (varnumber_T)word_count,\n\t\t\t(varnumber_T)byte_count_cursor, (varnumber_T)byte_count);\n\t\telse\n\t\t    vim_snprintf((char *)IObuff, IOSIZE,\n\t\t\t_(\"Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld\"),\n\t\t\t(char *)buf1, (char *)buf2,\n\t\t\t(long)curwin->w_cursor.lnum,\n\t\t\t(long)curbuf->b_ml.ml_line_count,\n\t\t\t(varnumber_T)word_count_cursor, (varnumber_T)word_count,\n\t\t\t(varnumber_T)char_count_cursor, (varnumber_T)char_count,\n\t\t\t(varnumber_T)byte_count_cursor, (varnumber_T)byte_count);\n\t    }\n\t}\n\n\tbom_count = bomb_size();\n\tif (dict == NULL && bom_count > 0)\n\t{\n\t    size_t len = STRLEN(IObuff);\n\n\t    vim_snprintf((char *)IObuff + len, IOSIZE - len,\n\t\t\t\t _(\"(+%lld for BOM)\"), (varnumber_T)bom_count);\n\t}\n\tif (dict == NULL)\n\t{\n\t    \/\/ Don't shorten this message, the user asked for it.\n\t    p = p_shm;\n\t    p_shm = (char_u *)\"\";\n\t    msg((char *)IObuff);\n\t    p_shm = p;\n\t}\n    }\n#if defined(FEAT_EVAL)\n    if (dict != NULL)\n    {\n\tdict_add_number(dict, \"words\", word_count);\n\tdict_add_number(dict, \"chars\", char_count);\n\tdict_add_number(dict, \"bytes\", byte_count + bom_count);\n\tdict_add_number(dict, VIsual_active ? \"visual_bytes\" : \"cursor_bytes\",\n\t\tbyte_count_cursor);\n\tdict_add_number(dict, VIsual_active ? \"visual_chars\" : \"cursor_chars\",\n\t\tchar_count_cursor);\n\tdict_add_number(dict, VIsual_active ? \"visual_words\" : \"cursor_words\",\n\t\tword_count_cursor);\n    }\n#endif\n}","target":0,"code_token_length":2299,"total_token_length":2535,"max_tokens_setting":4096}
+{"idx":376678,"func":"load_image (const gchar  *filename,\n            GError      **error)\n{\n  gchar             *name;\n  gint               fd;\n  BrushHeader        bh;\n  guchar            *brush_buf = NULL;\n  gint32             image_ID;\n  gint32             layer_ID;\n  GimpParasite      *parasite;\n  GimpDrawable      *drawable;\n  GimpPixelRgn       pixel_rgn;\n  gint               bn_size;\n  GimpImageBaseType  base_type;\n  GimpImageType      image_type;\n  gsize              size;\n\n  fd = g_open (filename, O_RDONLY | _O_BINARY, 0);\n\n  if (fd == -1)\n    {\n      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),\n                   _(\"Could not open '%s' for reading: %s\"),\n                   gimp_filename_to_utf8 (filename), g_strerror (errno));\n      return -1;\n    }\n\n  gimp_progress_init_printf (_(\"Opening '%s'\"),\n                             gimp_filename_to_utf8 (filename));\n\n  if (read (fd, &bh, sizeof (BrushHeader)) != sizeof (BrushHeader))\n    {\n      close (fd);\n      return -1;\n    }\n\n  \/*  rearrange the bytes in each unsigned int  *\/\n  bh.header_size  = g_ntohl (bh.header_size);\n  bh.version      = g_ntohl (bh.version);\n  bh.width        = g_ntohl (bh.width);\n  bh.height       = g_ntohl (bh.height);\n  bh.bytes        = g_ntohl (bh.bytes);\n  bh.magic_number = g_ntohl (bh.magic_number);\n  bh.spacing      = g_ntohl (bh.spacing);\n\n  \/* Sanitize values *\/\n  if ((bh.width == 0) || (bh.width > GIMP_MAX_IMAGE_SIZE) ||\n      (bh.height == 0) || (bh.height > GIMP_MAX_IMAGE_SIZE) ||\n      ((bh.bytes != 1) && (bh.bytes != 2) && (bh.bytes != 4) &&\n       (bh.bytes != 18)) ||\n      (G_MAXSIZE \/ bh.width \/ bh.height \/ bh.bytes < 1))\n    {\n      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,\n                   _(\"Invalid header data in '%s': width=%lu, height=%lu, \"\n                     \"bytes=%lu\"), gimp_filename_to_utf8 (filename),\n                   (unsigned long int)bh.width, (unsigned long int)bh.height,\n                   (unsigned long int)bh.bytes);\n      return -1;\n    }\n\n  switch (bh.version)\n    {\n    case 1:\n      \/* Version 1 didn't have a magic number and had no spacing  *\/\n      bh.spacing = 25;\n      \/* And we need to rewind the handle, 4 due spacing and 4 due magic *\/\n      lseek (fd, -8, SEEK_CUR);\n      bh.header_size += 8;\n      break;\n\n    case 3: \/*  cinepaint brush  *\/\n      if (bh.bytes == 18 \/* FLOAT16_GRAY_GIMAGE *\/)\n        {\n          bh.bytes = 2;\n        }\n      else\n        {\n          g_message (_(\"Unsupported brush format\"));\n          close (fd);\n          return -1;\n        }\n      \/*  fallthrough  *\/\n\n    case 2:\n      if (bh.magic_number == GBRUSH_MAGIC &&\n          bh.header_size  >  sizeof (BrushHeader))\n        break;\n\n    default:\n      g_message (_(\"Unsupported brush format\"));\n      close (fd);\n      return -1;\n    }\n\n  if ((bn_size = (bh.header_size - sizeof (BrushHeader))) > 0)\n    {\n      gchar *temp = g_new (gchar, bn_size);\n\n      if ((read (fd, temp, bn_size)) < bn_size ||\n          temp[bn_size - 1] != '\\0')\n        {\n          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,\n                       _(\"Error in GIMP brush file '%s'\"),\n                       gimp_filename_to_utf8 (filename));\n          close (fd);\n          g_free (temp);\n          return -1;\n        }\n\n      name = gimp_any_to_utf8 (temp, -1,\n                               _(\"Invalid UTF-8 string in brush file '%s'.\"),\n                               gimp_filename_to_utf8 (filename));\n      g_free (temp);\n    }\n  else\n    {\n      name = g_strdup (_(\"Unnamed\"));\n    }\n\n  \/* Now there's just raw data left. *\/\n\n  size = bh.width * bh.height * bh.bytes;\n  brush_buf = g_malloc (size);\n\n  if (read (fd, brush_buf, size) != size)\n    {\n      close (fd);\n      g_free (brush_buf);\n      g_free (name);\n      return -1;\n    }\n\n  switch (bh.bytes)\n    {\n    case 1:\n      {\n        PatternHeader ph;\n\n        \/*  For backwards-compatibility, check if a pattern follows.\n            The obsolete .gpb format did it this way.  *\/\n\n        if (read (fd, &ph, sizeof (PatternHeader)) == sizeof(PatternHeader))\n          {\n            \/*  rearrange the bytes in each unsigned int  *\/\n            ph.header_size  = g_ntohl (ph.header_size);\n            ph.version      = g_ntohl (ph.version);\n            ph.width        = g_ntohl (ph.width);\n            ph.height       = g_ntohl (ph.height);\n            ph.bytes        = g_ntohl (ph.bytes);\n            ph.magic_number = g_ntohl (ph.magic_number);\n\n            if (ph.magic_number == GPATTERN_MAGIC        &&\n                ph.version      == 1                     &&\n                ph.header_size  > sizeof (PatternHeader) &&\n                ph.bytes        == 3                     &&\n                ph.width        == bh.width              &&\n                ph.height       == bh.height             &&\n                lseek (fd, ph.header_size - sizeof (PatternHeader),\n                       SEEK_CUR) > 0)\n              {\n                guchar *plain_brush = brush_buf;\n                gint    i;\n\n                bh.bytes = 4;\n                brush_buf = g_malloc (4 * bh.width * bh.height);\n\n                for (i = 0; i < ph.width * ph.height; i++)\n                  {\n                    if (read (fd, brush_buf + i * 4, 3) != 3)\n                      {\n                        close (fd);\n                        g_free (name);\n                        g_free (plain_brush);\n                        g_free (brush_buf);\n                        return -1;\n                      }\n                    brush_buf[i * 4 + 3] = plain_brush[i];\n                  }\n                g_free (plain_brush);\n              }\n          }\n      }\n      break;\n\n    case 2:\n      {\n        guint16 *buf = (guint16 *) brush_buf;\n        gint     i;\n\n        for (i = 0; i < bh.width * bh.height; i++, buf++)\n          {\n            union\n            {\n              guint16 u[2];\n              gfloat  f;\n            } short_float;\n\n#if G_BYTE_ORDER == G_LITTLE_ENDIAN\n            short_float.u[0] = 0;\n            short_float.u[1] = GUINT16_FROM_BE (*buf);\n#else\n            short_float.u[0] = GUINT16_FROM_BE (*buf);\n            short_float.u[1] = 0;\n#endif\n\n            brush_buf[i] = (guchar) (short_float.f * 255.0 + 0.5);\n          }\n\n        bh.bytes = 1;\n      }\n      break;\n\n    default:\n      break;\n    }\n\n  \/*\n   * Create a new image of the proper size and\n   * associate the filename with it.\n   *\/\n\n  switch (bh.bytes)\n    {\n    case 1:\n      base_type = GIMP_GRAY;\n      image_type = GIMP_GRAY_IMAGE;\n      break;\n\n    case 4:\n      base_type = GIMP_RGB;\n      image_type = GIMP_RGBA_IMAGE;\n      break;\n\n    default:\n      g_message (\"Unsupported brush depth: %d\\n\"\n                 \"GIMP Brushes must be GRAY or RGBA\\n\",\n                 bh.bytes);\n      g_free (name);\n      return -1;\n    }\n\n  image_ID = gimp_image_new (bh.width, bh.height, base_type);\n  gimp_image_set_filename (image_ID, filename);\n\n  parasite = gimp_parasite_new (\"gimp-brush-name\",\n                                GIMP_PARASITE_PERSISTENT,\n                                strlen (name) + 1, name);\n  gimp_image_attach_parasite (image_ID, parasite);\n  gimp_parasite_free (parasite);\n\n  layer_ID = gimp_layer_new (image_ID, name, bh.width, bh.height,\n                             image_type, 100, GIMP_NORMAL_MODE);\n  gimp_image_insert_layer (image_ID, layer_ID, -1, 0);\n\n  g_free (name);\n\n  drawable = gimp_drawable_get (layer_ID);\n  gimp_pixel_rgn_init (&pixel_rgn, drawable,\n                       0, 0, drawable->width, drawable->height,\n                       TRUE, FALSE);\n\n  gimp_pixel_rgn_set_rect (&pixel_rgn, brush_buf,\n                           0, 0, bh.width, bh.height);\n  g_free (brush_buf);\n\n  if (image_type == GIMP_GRAY_IMAGE)\n    gimp_invert (layer_ID);\n\n  close (fd);\n\n  gimp_drawable_flush (drawable);\n  gimp_progress_update (1.0);\n\n  return image_ID;\n}","target":0,"code_token_length":2017,"total_token_length":2253,"max_tokens_setting":4096}
+{"idx":246731,"func":"static GF_Err do_track_act()\n{\n\tu32 j;\n\tfor (j=0; j<nb_track_act; j++) {\n\t\tu32 i;\n\t\tGF_Err e = GF_OK;\n\t\tTrackAction *tka = &tracks[j];\n\t\tu32 track = tka->trackID ? gf_isom_get_track_by_id(file, tka->trackID) : 0;\n\n\t\ttimescale = gf_isom_get_timescale(file);\n\t\tswitch (tka->act_type) {\n\t\tcase TRAC_ACTION_REM_TRACK:\n\t\t\te = gf_isom_remove_track(file, track);\n\t\t\tif (e) {\n\t\t\t\tM4_LOG(GF_LOG_ERROR, (\"Error Removing track ID %d: %s\\n\", tka->trackID, gf_error_to_string(e)));\n\t\t\t} else {\n\t\t\t\tM4_LOG(GF_LOG_INFO, (\"Removing track ID %d\\n\", tka->trackID));\n\t\t\t}\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_LANGUAGE:\n\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\tif (track && (track != i+1)) continue;\n\t\t\t\te = gf_isom_set_media_language(file, i+1, tka->lang);\n\t\t\t\tif (e) return e;\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_KIND:\n\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\tif (track && (track != i+1)) continue;\n\t\t\t\te = gf_isom_add_track_kind(file, i+1, tka->kind_scheme, tka->kind_value);\n\t\t\t\tif (e) return e;\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_REM_KIND:\n\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\tif (track && (track != i+1)) continue;\n\t\t\t\te = gf_isom_remove_track_kind(file, i+1, tka->kind_scheme, tka->kind_value);\n\t\t\t\tif (e) return e;\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_DELAY:\n\t\t\tif (tka->delay.num && tka->delay.den) {\n\t\t\t\tu64 tk_dur;\n\n\t\t\t\te = gf_isom_remove_edits(file, track);\n\t\t\t\tif (e) return e;\n\t\t\t\ttk_dur = gf_isom_get_track_duration(file, track);\n\t\t\t\tif (gf_isom_get_edits_count(file, track))\n\t\t\t\t\tdo_save = GF_TRUE;\n\t\t\t\tif (tka->delay.num>0) {\n\t\t\t\t\t\/\/cast to u64, delay_ms * timescale can be quite big before \/ 1000\n\t\t\t\t\te = gf_isom_append_edit(file, track, ((u64) tka->delay.num) * timescale \/ tka->delay.den, 0, GF_ISOM_EDIT_EMPTY);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\te = gf_isom_append_edit(file, track, tk_dur, 0, GF_ISOM_EDIT_NORMAL);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\tdo_save = GF_TRUE;\n\t\t\t\t} else {\n\t\t\t\t\t\/\/cast to u64, delay_ms * timescale can be quite big before \/ 1000\n\t\t\t\t\tu64 to_skip = ((u64) -tka->delay.num) * timescale \/ tka->delay.den;\n\t\t\t\t\tif (to_skip<tk_dur) {\n\t\t\t\t\t\t\/\/cast to u64, delay_ms * timescale can be quite big before \/ 1000\n\t\t\t\t\t\tu64 media_time = ((u64) -tka->delay.num) * gf_isom_get_media_timescale(file, track) \/ tka->delay.den;\n\t\t\t\t\t\te = gf_isom_append_edit(file, track, tk_dur-to_skip, media_time, GF_ISOM_EDIT_NORMAL);\n\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\tdo_save = GF_TRUE;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tM4_LOG(GF_LOG_WARNING, (\"Warning: request negative delay longer than track duration - ignoring\\n\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (gf_isom_get_edits_count(file, track)) {\n\t\t\t\te = gf_isom_remove_edits(file, track);\n\t\t\t\tif (e) return e;\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_KMS_URI:\n\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\tif (track && (track != i+1)) continue;\n\t\t\t\tif (!gf_isom_is_media_encrypted(file, i+1, 1)) continue;\n\t\t\t\tif (!gf_isom_is_ismacryp_media(file, i+1, 1)) continue;\n\t\t\t\te = gf_isom_change_ismacryp_protection(file, i+1, 1, NULL, (char *) tka->kms);\n\t\t\t\tif (e) return e;\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_ID:\n\t\t\tif (!tka->trackID && (gf_isom_get_track_count(file) == 1)) {\n\t\t\t\tM4_LOG(GF_LOG_WARNING, (\"Warning: track id is not specified, but file has only one track - assume that you want to change id for this track\\n\"));\n\t\t\t\ttrack = 1;\n\t\t\t}\n\t\t\tif (track) {\n\t\t\t\tu32 newTrack;\n\t\t\t\tnewTrack = gf_isom_get_track_by_id(file, tka->newTrackID);\n\t\t\t\tif (newTrack != 0) {\n\t\t\t\t\tM4_LOG(GF_LOG_WARNING, (\"Cannot set track id with value %d because a track already exists - ignoring\", tka->newTrackID));\n\t\t\t\t} else {\n\t\t\t\t\te = gf_isom_set_track_id(file, track, tka->newTrackID);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\tdo_save = GF_TRUE;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tM4_LOG(GF_LOG_WARNING, (\"Error: Cannot change id for track %d because it does not exist - ignoring\", tka->trackID));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SWAP_ID:\n\t\t\tif (track) {\n\t\t\t\tu32 tk1, tk2;\n\t\t\t\ttk1 = gf_isom_get_track_by_id(file, tka->trackID);\n\t\t\t\ttk2 = gf_isom_get_track_by_id(file, tka->newTrackID);\n\t\t\t\tif (!tk1 || !tk2) {\n\t\t\t\t\tM4_LOG(GF_LOG_WARNING, (\"Error: Cannot swap track IDs because not existing - ignoring\"));\n\t\t\t\t} else {\n\t\t\t\t\te = gf_isom_set_track_id(file, tk2, 0);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\te = gf_isom_set_track_id(file, tk1, tka->newTrackID);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\te = gf_isom_set_track_id(file, tk2, tka->trackID);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t\tdo_save = GF_TRUE;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tM4_LOG(GF_LOG_WARNING, (\"Error: Cannot change id for track %d because it does not exist - ignoring\", tka->trackID));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_PAR:\n\t\t\te = gf_media_change_par(file, track, tka->par_num, tka->par_den, tka->force_par, tka->rewrite_bs);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_CLAP:\n\t\t\te = gf_isom_set_clean_aperture(file, track, 1, tka->clap_wnum, tka->clap_wden, tka->clap_hnum, tka->clap_hden, tka->clap_honum, tka->clap_hoden, tka->clap_vonum, tka->clap_voden);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_MX:\n\t\t\te = gf_isom_set_track_matrix(file, track, tka->mx);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_HANDLER_NAME:\n\t\t\te = gf_isom_set_handler_name(file, track, tka->hdl_name);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_ENABLE:\n\t\t\tif (!gf_isom_is_track_enabled(file, track)) {\n\t\t\t\te = gf_isom_set_track_enabled(file, track, GF_TRUE);\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_DISABLE:\n\t\t\tif (gf_isom_is_track_enabled(file, track)) {\n\t\t\t\te = gf_isom_set_track_enabled(file, track, GF_FALSE);\n\t\t\t\tdo_save = GF_TRUE;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_REFERENCE:\n\t\t\te = gf_isom_set_track_reference(file, track, GF_4CC(tka->lang[0], tka->lang[1], tka->lang[2], tka->lang[3]), tka->newTrackID);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_REM_NON_RAP:\n\t\t\te = gf_media_remove_non_rap(file, track, GF_FALSE);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_REM_NON_REFS:\n\t\t\te = gf_media_remove_non_rap(file, track, GF_TRUE);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_UDTA:\n\t\t\te = set_file_udta(file, track, tka->udta_type, tka->string ? tka->string : tka->src_name , tka->sample_num ? GF_TRUE : GF_FALSE, tka->string ? GF_TRUE : GF_FALSE);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_EDITS:\n\t\t\te = apply_edits(file, track, tka->string);\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_TIME:\n\t\t\tif (!tka->trackID) {\n\t\t\t\te = gf_isom_set_creation_time(file, tka->time, tka->time);\n\t\t\t\tif (e) return e;\n\t\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\t\te = gf_isom_set_track_creation_time(file, i+1, tka->time, tka->time);\n\t\t\t\t\tif (e) return e;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\te = gf_isom_set_track_creation_time(file, track, tka->time, tka->time);\n\t\t\t}\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tcase TRAC_ACTION_SET_MEDIA_TIME:\n\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\tif (track && (track != i+1)) continue;\n\t\t\t\te = gf_isom_set_media_creation_time(file, i+1, tka->time, tka->time);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\t\t\tdo_save = GF_TRUE;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":2439,"total_token_length":2675,"max_tokens_setting":4096}
+{"idx":225000,"func":"ldapServiceLookup(const char *purl, PQconninfoOption *options,\n\t\t\t\t  PQExpBuffer errorMessage)\n{\n\tint\t\t\tport = LDAP_DEF_PORT,\n\t\t\t\tscope,\n\t\t\t\trc,\n\t\t\t\tsize,\n\t\t\t\tstate,\n\t\t\t\toldstate,\n\t\t\t\ti;\n#ifndef WIN32\n\tint\t\t\tmsgid;\n#endif\n\tbool\t\tfound_keyword;\n\tchar\t   *url,\n\t\t\t   *hostname,\n\t\t\t   *portstr,\n\t\t\t   *endptr,\n\t\t\t   *dn,\n\t\t\t   *scopestr,\n\t\t\t   *filter,\n\t\t\t   *result,\n\t\t\t   *p,\n\t\t\t   *p1 = NULL,\n\t\t\t   *optname = NULL,\n\t\t\t   *optval = NULL;\n\tchar\t   *attrs[2] = {NULL, NULL};\n\tLDAP\t   *ld = NULL;\n\tLDAPMessage *res,\n\t\t\t   *entry;\n\tstruct berval **values;\n\tLDAP_TIMEVAL time = {PGLDAP_TIMEOUT, 0};\n\n\tif ((url = strdup(purl)) == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage, libpq_gettext(\"out of memory\\n\"));\n\t\treturn 3;\n\t}\n\n\t\/*\n\t * Parse URL components, check for correctness.  Basically, url has '\\0'\n\t * placed at component boundaries and variables are pointed at each\n\t * component.\n\t *\/\n\n\tif (pg_strncasecmp(url, LDAP_URL, strlen(LDAP_URL)) != 0)\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": scheme must be ldap:\/\/\\n\"), purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\n\t\/* hostname *\/\n\thostname = url + strlen(LDAP_URL);\n\tif (*hostname == '\/')\t\t\/* no hostname? *\/\n\t\thostname = DefaultHost; \/* the default *\/\n\n\t\/* dn, \"distinguished name\" *\/\n\tp = strchr(url + strlen(LDAP_URL), '\/');\n\tif (p == NULL || *(p + 1) == '\\0' || *(p + 1) == '?')\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": missing distinguished name\\n\"),\n\t\t\t\t\t\t  purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\t*p = '\\0';\t\t\t\t\t\/* terminate hostname *\/\n\tdn = p + 1;\n\n\t\/* attribute *\/\n\tif ((p = strchr(dn, '?')) == NULL || *(p + 1) == '\\0' || *(p + 1) == '?')\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": must have exactly one attribute\\n\"),\n\t\t\t\t\t\t  purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\t*p = '\\0';\n\tattrs[0] = p + 1;\n\n\t\/* scope *\/\n\tif ((p = strchr(attrs[0], '?')) == NULL || *(p + 1) == '\\0' || *(p + 1) == '?')\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": must have search scope (base\/one\/sub)\\n\"),\n\t\t\t\t\t\t  purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\t*p = '\\0';\n\tscopestr = p + 1;\n\n\t\/* filter *\/\n\tif ((p = strchr(scopestr, '?')) == NULL || *(p + 1) == '\\0' || *(p + 1) == '?')\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": no filter\\n\"),\n\t\t\t\t\t\t  purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\t*p = '\\0';\n\tfilter = p + 1;\n\tif ((p = strchr(filter, '?')) != NULL)\n\t\t*p = '\\0';\n\n\t\/* port number? *\/\n\tif ((p1 = strchr(hostname, ':')) != NULL)\n\t{\n\t\tlong\t\tlport;\n\n\t\t*p1 = '\\0';\n\t\tportstr = p1 + 1;\n\t\terrno = 0;\n\t\tlport = strtol(portstr, &endptr, 10);\n\t\tif (*portstr == '\\0' || *endptr != '\\0' || errno || lport < 0 || lport > 65535)\n\t\t{\n\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": invalid port number\\n\"),\n\t\t\t\t\t\t\t  purl);\n\t\t\tfree(url);\n\t\t\treturn 3;\n\t\t}\n\t\tport = (int) lport;\n\t}\n\n\t\/* Allow only one attribute *\/\n\tif (strchr(attrs[0], ',') != NULL)\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": must have exactly one attribute\\n\"),\n\t\t\t\t\t\t  purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\n\t\/* set scope *\/\n\tif (pg_strcasecmp(scopestr, \"base\") == 0)\n\t\tscope = LDAP_SCOPE_BASE;\n\telse if (pg_strcasecmp(scopestr, \"one\") == 0)\n\t\tscope = LDAP_SCOPE_ONELEVEL;\n\telse if (pg_strcasecmp(scopestr, \"sub\") == 0)\n\t\tscope = LDAP_SCOPE_SUBTREE;\n\telse\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"invalid LDAP URL \\\"%s\\\": must have search scope (base\/one\/sub)\\n\"),\n\t\t\t\t\t\t  purl);\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\n\t\/* initialize LDAP structure *\/\n\tif ((ld = ldap_init(hostname, port)) == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"could not create LDAP structure\\n\"));\n\t\tfree(url);\n\t\treturn 3;\n\t}\n\n\t\/*\n\t * Perform an explicit anonymous bind.\n\t *\n\t * LDAP does not require that an anonymous bind is performed explicitly,\n\t * but we want to distinguish between the case where LDAP bind does not\n\t * succeed within PGLDAP_TIMEOUT seconds (return 2 to continue parsing the\n\t * service control file) and the case where querying the LDAP server fails\n\t * (return 1 to end parsing).\n\t *\n\t * Unfortunately there is no way of setting a timeout that works for both\n\t * Windows and OpenLDAP.\n\t *\/\n#ifdef WIN32\n\t\/* the nonstandard ldap_connect function performs an anonymous bind *\/\n\tif (ldap_connect(ld, &time) != LDAP_SUCCESS)\n\t{\n\t\t\/* error or timeout in ldap_connect *\/\n\t\tfree(url);\n\t\tldap_unbind(ld);\n\t\treturn 2;\n\t}\n#else\t\t\t\t\t\t\t\/* !WIN32 *\/\n\t\/* in OpenLDAP, use the LDAP_OPT_NETWORK_TIMEOUT option *\/\n\tif (ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &time) != LDAP_SUCCESS)\n\t{\n\t\tfree(url);\n\t\tldap_unbind(ld);\n\t\treturn 3;\n\t}\n\n\t\/* anonymous bind *\/\n\tif ((msgid = ldap_simple_bind(ld, NULL, NULL)) == -1)\n\t{\n\t\t\/* error or network timeout *\/\n\t\tfree(url);\n\t\tldap_unbind(ld);\n\t\treturn 2;\n\t}\n\n\t\/* wait some time for the connection to succeed *\/\n\tres = NULL;\n\tif ((rc = ldap_result(ld, msgid, LDAP_MSG_ALL, &time, &res)) == -1 ||\n\t\tres == NULL)\n\t{\n\t\t\/* error or timeout *\/\n\t\tif (res != NULL)\n\t\t\tldap_msgfree(res);\n\t\tfree(url);\n\t\tldap_unbind(ld);\n\t\treturn 2;\n\t}\n\tldap_msgfree(res);\n\n\t\/* reset timeout *\/\n\ttime.tv_sec = -1;\n\tif (ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &time) != LDAP_SUCCESS)\n\t{\n\t\tfree(url);\n\t\tldap_unbind(ld);\n\t\treturn 3;\n\t}\n#endif\t\t\t\t\t\t\t\/* WIN32 *\/\n\n\t\/* search *\/\n\tres = NULL;\n\tif ((rc = ldap_search_st(ld, dn, scope, filter, attrs, 0, &time, &res))\n\t\t!= LDAP_SUCCESS)\n\t{\n\t\tif (res != NULL)\n\t\t\tldap_msgfree(res);\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"lookup on LDAP server failed: %s\\n\"),\n\t\t\t\t\t\t  ldap_err2string(rc));\n\t\tldap_unbind(ld);\n\t\tfree(url);\n\t\treturn 1;\n\t}\n\n\t\/* complain if there was not exactly one result *\/\n\tif ((rc = ldap_count_entries(ld, res)) != 1)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t rc ? libpq_gettext(\"more than one entry found on LDAP lookup\\n\")\n\t\t\t\t\t\t\t : libpq_gettext(\"no entry found on LDAP lookup\\n\"));\n\t\tldap_msgfree(res);\n\t\tldap_unbind(ld);\n\t\tfree(url);\n\t\treturn 1;\n\t}\n\n\t\/* get entry *\/\n\tif ((entry = ldap_first_entry(ld, res)) == NULL)\n\t{\n\t\t\/* should never happen *\/\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"no entry found on LDAP lookup\\n\"));\n\t\tldap_msgfree(res);\n\t\tldap_unbind(ld);\n\t\tfree(url);\n\t\treturn 1;\n\t}\n\n\t\/* get values *\/\n\tif ((values = ldap_get_values_len(ld, entry, attrs[0])) == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"attribute has no values on LDAP lookup\\n\"));\n\t\tldap_msgfree(res);\n\t\tldap_unbind(ld);\n\t\tfree(url);\n\t\treturn 1;\n\t}\n\n\tldap_msgfree(res);\n\tfree(url);\n\n\tif (values[0] == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"attribute has no values on LDAP lookup\\n\"));\n\t\tldap_value_free_len(values);\n\t\tldap_unbind(ld);\n\t\treturn 1;\n\t}\n\n\t\/* concatenate values into a single string with newline terminators *\/\n\tsize = 1;\t\t\t\t\t\/* for the trailing null *\/\n\tfor (i = 0; values[i] != NULL; i++)\n\t\tsize += values[i]->bv_len + 1;\n\tif ((result = malloc(size)) == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"out of memory\\n\"));\n\t\tldap_value_free_len(values);\n\t\tldap_unbind(ld);\n\t\treturn 3;\n\t}\n\tp = result;\n\tfor (i = 0; values[i] != NULL; i++)\n\t{\n\t\tmemcpy(p, values[i]->bv_val, values[i]->bv_len);\n\t\tp += values[i]->bv_len;\n\t\t*(p++) = '\\n';\n\t}\n\t*p = '\\0';\n\n\tldap_value_free_len(values);\n\tldap_unbind(ld);\n\n\t\/* parse result string *\/\n\toldstate = state = 0;\n\tfor (p = result; *p != '\\0'; ++p)\n\t{\n\t\tswitch (state)\n\t\t{\n\t\t\tcase 0:\t\t\t\t\/* between entries *\/\n\t\t\t\tif (!ld_is_sp_tab(*p) && !ld_is_nl_cr(*p))\n\t\t\t\t{\n\t\t\t\t\toptname = p;\n\t\t\t\t\tstate = 1;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\t\t\t\t\/* in option name *\/\n\t\t\t\tif (ld_is_sp_tab(*p))\n\t\t\t\t{\n\t\t\t\t\t*p = '\\0';\n\t\t\t\t\tstate = 2;\n\t\t\t\t}\n\t\t\t\telse if (ld_is_nl_cr(*p))\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"missing \\\"=\\\" after \\\"%s\\\" in connection info string\\n\"),\n\t\t\t\t\t\t\t\t\t  optname);\n\t\t\t\t\tfree(result);\n\t\t\t\t\treturn 3;\n\t\t\t\t}\n\t\t\t\telse if (*p == '=')\n\t\t\t\t{\n\t\t\t\t\t*p = '\\0';\n\t\t\t\t\tstate = 3;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 2:\t\t\t\t\/* after option name *\/\n\t\t\t\tif (*p == '=')\n\t\t\t\t{\n\t\t\t\t\tstate = 3;\n\t\t\t\t}\n\t\t\t\telse if (!ld_is_sp_tab(*p))\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"missing \\\"=\\\" after \\\"%s\\\" in connection info string\\n\"),\n\t\t\t\t\t\t\t\t\t  optname);\n\t\t\t\t\tfree(result);\n\t\t\t\t\treturn 3;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 3:\t\t\t\t\/* before option value *\/\n\t\t\t\tif (*p == '\\'')\n\t\t\t\t{\n\t\t\t\t\toptval = p + 1;\n\t\t\t\t\tp1 = p + 1;\n\t\t\t\t\tstate = 5;\n\t\t\t\t}\n\t\t\t\telse if (ld_is_nl_cr(*p))\n\t\t\t\t{\n\t\t\t\t\toptval = optname + strlen(optname); \/* empty *\/\n\t\t\t\t\tstate = 0;\n\t\t\t\t}\n\t\t\t\telse if (!ld_is_sp_tab(*p))\n\t\t\t\t{\n\t\t\t\t\toptval = p;\n\t\t\t\t\tstate = 4;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 4:\t\t\t\t\/* in unquoted option value *\/\n\t\t\t\tif (ld_is_sp_tab(*p) || ld_is_nl_cr(*p))\n\t\t\t\t{\n\t\t\t\t\t*p = '\\0';\n\t\t\t\t\tstate = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 5:\t\t\t\t\/* in quoted option value *\/\n\t\t\t\tif (*p == '\\'')\n\t\t\t\t{\n\t\t\t\t\t*p1 = '\\0';\n\t\t\t\t\tstate = 0;\n\t\t\t\t}\n\t\t\t\telse if (*p == '\\\\')\n\t\t\t\t\tstate = 6;\n\t\t\t\telse\n\t\t\t\t\t*(p1++) = *p;\n\t\t\t\tbreak;\n\t\t\tcase 6:\t\t\t\t\/* in quoted option value after escape *\/\n\t\t\t\t*(p1++) = *p;\n\t\t\t\tstate = 5;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (state == 0 && oldstate != 0)\n\t\t{\n\t\t\tfound_keyword = false;\n\t\t\tfor (i = 0; options[i].keyword; i++)\n\t\t\t{\n\t\t\t\tif (strcmp(options[i].keyword, optname) == 0)\n\t\t\t\t{\n\t\t\t\t\tif (options[i].val == NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\toptions[i].val = strdup(optval);\n\t\t\t\t\t\tif (!options[i].val)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t libpq_gettext(\"out of memory\\n\"));\n\t\t\t\t\t\t\tfree(result);\n\t\t\t\t\t\t\treturn 3;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfound_keyword = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!found_keyword)\n\t\t\t{\n\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"invalid connection option \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t  optname);\n\t\t\t\tfree(result);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\toptname = NULL;\n\t\t\toptval = NULL;\n\t\t}\n\t\toldstate = state;\n\t}\n\n\tfree(result);\n\n\tif (state == 5 || state == 6)\n\t{\n\t\tappendPQExpBufferStr(errorMessage,\n\t\t\t\t\t\t\t libpq_gettext(\"unterminated quoted string in connection info string\\n\"));\n\t\treturn 3;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":3079,"total_token_length":3315,"max_tokens_setting":4096}
+{"idx":200320,"func":"static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,\n\t\t\t      struct files_struct *fsp,\n\t\t\t      TALLOC_CTX *ctx,\n\t\t\t      uint32_t function,\n\t\t\t      uint16_t req_flags, \/* Needed for UNICODE ... *\/\n\t\t\t      const uint8_t *_in_data,\n\t\t\t      uint32_t in_len,\n\t\t\t      uint8_t **_out_data,\n\t\t\t      uint32_t max_out_len,\n\t\t\t      uint32_t *out_len)\n{\n\tconst char *in_data = (const char *)_in_data;\n\tchar **out_data = (char **)_out_data;\n\n\tswitch (function) {\n\tcase FSCTL_SET_SPARSE:\n\t{\n\t\tbool set_sparse = true;\n\t\tNTSTATUS status;\n\n\t\tif (in_len >= 1 && in_data[0] == 0) {\n\t\t\tset_sparse = false;\n\t\t}\n\n\t\tstatus = file_set_sparse(handle->conn, fsp, set_sparse);\n\t\t\n\t\tDEBUG(NT_STATUS_IS_OK(status) ? 10 : 9,\n\t\t      (\"FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\\n\",\n\t\t       smb_fname_str_dbg(fsp->fsp_name), set_sparse, \n\t\t       nt_errstr(status)));\n\n\t\treturn status;\n\t}\n\n\tcase FSCTL_CREATE_OR_GET_OBJECT_ID:\n\t{\n\t\tunsigned char objid[16];\n\t\tchar *return_data = NULL;\n\n\t\t\/* This should return the object-id on this file.\n\t\t * I think I'll make this be the inode+dev. JRA.\n\t\t *\/\n\n\t\tDEBUG(10,(\"FSCTL_CREATE_OR_GET_OBJECT_ID: called on %s\\n\",\n\t\t\t  fsp_fnum_dbg(fsp)));\n\n\t\t*out_len = (max_out_len >= 64) ? 64 : max_out_len;\n\t\t\/* Hmmm, will this cause problems if less data asked for? *\/\n\t\treturn_data = talloc_array(ctx, char, 64);\n\t\tif (return_data == NULL) {\n\t\t\treturn NT_STATUS_NO_MEMORY;\n\t\t}\n\n\t\t\/* For backwards compatibility only store the dev\/inode. *\/\n\t\tpush_file_id_16(return_data, &fsp->file_id);\n\t\tmemcpy(return_data+16,create_volume_objectid(fsp->conn,objid),16);\n\t\tpush_file_id_16(return_data+32, &fsp->file_id);\n\t\t*out_data = return_data;\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tcase FSCTL_GET_REPARSE_POINT:\n\t{\n\t\t\/* Fail it with STATUS_NOT_A_REPARSE_POINT *\/\n\t\tDEBUG(10, (\"FSCTL_GET_REPARSE_POINT: called on %s. \"\n\t\t\t   \"Status: NOT_IMPLEMENTED\\n\", fsp_fnum_dbg(fsp)));\n\t\treturn NT_STATUS_NOT_A_REPARSE_POINT;\n\t}\n\n\tcase FSCTL_SET_REPARSE_POINT:\n\t{\n\t\t\/* Fail it with STATUS_NOT_A_REPARSE_POINT *\/\n\t\tDEBUG(10, (\"FSCTL_SET_REPARSE_POINT: called on %s. \"\n\t\t\t   \"Status: NOT_IMPLEMENTED\\n\", fsp_fnum_dbg(fsp)));\n\t\treturn NT_STATUS_NOT_A_REPARSE_POINT;\n\t}\n\n\tcase FSCTL_GET_SHADOW_COPY_DATA:\n\t{\n\t\t\/*\n\t\t * This is called to retrieve the number of Shadow Copies (a.k.a. snapshots)\n\t\t * and return their volume names.  If max_data_count is 16, then it is just\n\t\t * asking for the number of volumes and length of the combined names.\n\t\t *\n\t\t * pdata is the data allocated by our caller, but that uses\n\t\t * total_data_count (which is 0 in our case) rather than max_data_count.\n\t\t * Allocate the correct amount and return the pointer to let\n\t\t * it be deallocated when we return.\n\t\t *\/\n\t\tstruct shadow_copy_data *shadow_data = NULL;\n\t\tbool labels = False;\n\t\tuint32 labels_data_count = 0;\n\t\tuint32 i;\n\t\tchar *cur_pdata = NULL;\n\n\t\tif (max_out_len < 16) {\n\t\t\tDEBUG(0,(\"FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) < 16 is invalid!\\n\",\n\t\t\t\tmax_out_len));\n\t\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t\t}\n\n\t\tif (max_out_len > 16) {\n\t\t\tlabels = True;\n\t\t}\n\n\t\tshadow_data = talloc_zero(ctx, struct shadow_copy_data);\n\t\tif (shadow_data == NULL) {\n\t\t\tDEBUG(0,(\"TALLOC_ZERO() failed!\\n\"));\n\t\t\treturn NT_STATUS_NO_MEMORY;\n\t\t}\n\n\t\t\/*\n\t\t * Call the VFS routine to actually do the work.\n\t\t *\/\n\t\tif (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {\n\t\t\tTALLOC_FREE(shadow_data);\n\t\t\tif (errno == ENOSYS) {\n\t\t\t\tDEBUG(5,(\"FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\\n\", \n\t\t\t\t\tfsp->conn->connectpath));\n\t\t\t\treturn NT_STATUS_NOT_SUPPORTED;\n\t\t\t} else {\n\t\t\t\tDEBUG(0,(\"FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\\n\", \n\t\t\t\t\tfsp->conn->connectpath));\n\t\t\t\treturn NT_STATUS_UNSUCCESSFUL;\n\t\t\t}\n\t\t}\n\n\t\tlabels_data_count = (shadow_data->num_volumes * 2 * \n\t\t\t\t\tsizeof(SHADOW_COPY_LABEL)) + 2;\n\n\t\tif (!labels) {\n\t\t\t*out_len = 16;\n\t\t} else {\n\t\t\t*out_len = 12 + labels_data_count + 4;\n\t\t}\n\n\t\tif (max_out_len < *out_len) {\n\t\t\tDEBUG(0,(\"FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\\n\",\n\t\t\t\tmax_out_len, *out_len));\n\t\t\tTALLOC_FREE(shadow_data);\n\t\t\treturn NT_STATUS_BUFFER_TOO_SMALL;\n\t\t}\n\n\t\tcur_pdata = talloc_zero_array(ctx, char, *out_len);\n\t\tif (cur_pdata == NULL) {\n\t\t\tTALLOC_FREE(shadow_data);\n\t\t\treturn NT_STATUS_NO_MEMORY;\n\t\t}\n\n\t\t*out_data = cur_pdata;\n\n\t\t\/* num_volumes 4 bytes *\/\n\t\tSIVAL(cur_pdata, 0, shadow_data->num_volumes);\n\n\t\tif (labels) {\n\t\t\t\/* num_labels 4 bytes *\/\n\t\t\tSIVAL(cur_pdata, 4, shadow_data->num_volumes);\n\t\t}\n\n\t\t\/* needed_data_count 4 bytes *\/\n\t\tSIVAL(cur_pdata, 8, labels_data_count + 4);\n\n\t\tcur_pdata += 12;\n\n\t\tDEBUG(10,(\"FSCTL_GET_SHADOW_COPY_DATA: %u volumes for path[%s].\\n\",\n\t\t\t  shadow_data->num_volumes, fsp_str_dbg(fsp)));\n\t\tif (labels && shadow_data->labels) {\n\t\t\tfor (i=0; i<shadow_data->num_volumes; i++) {\n\t\t\t\tsrvstr_push(cur_pdata, req_flags,\n\t\t\t\t\t    cur_pdata, shadow_data->labels[i],\n\t\t\t\t\t    2 * sizeof(SHADOW_COPY_LABEL),\n\t\t\t\t\t    STR_UNICODE|STR_TERMINATE);\n\t\t\t\tcur_pdata += 2 * sizeof(SHADOW_COPY_LABEL);\n\t\t\t\tDEBUGADD(10,(\"Label[%u]: '%s'\\n\",i,shadow_data->labels[i]));\n\t\t\t}\n\t\t}\n\n\t\tTALLOC_FREE(shadow_data);\n\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tcase FSCTL_FIND_FILES_BY_SID:\n\t{\n\t\t\/* pretend this succeeded -\n\t\t *\n\t\t * we have to send back a list with all files owned by this SID\n\t\t *\n\t\t * but I have to check that --metze\n\t\t *\/\n\t\tstruct dom_sid sid;\n\t\tuid_t uid;\n\t\tsize_t sid_len;\n\n\t\tDEBUG(10, (\"FSCTL_FIND_FILES_BY_SID: called on %s\\n\",\n\t\t\t   fsp_fnum_dbg(fsp)));\n\n\t\tif (in_len < 8) {\n\t\t\t\/* NT_STATUS_BUFFER_TOO_SMALL maybe? *\/\n\t\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t\t}\n\n\t\tsid_len = MIN(in_len - 4,SID_MAX_SIZE);\n\n\t\t\/* unknown 4 bytes: this is not the length of the sid :-(  *\/\n\t\t\/*unknown = IVAL(pdata,0);*\/\n\n\t\tif (!sid_parse(in_data + 4, sid_len, &sid)) {\n\t\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t\t}\n\t\tDEBUGADD(10, (\"for SID: %s\\n\", sid_string_dbg(&sid)));\n\n\t\tif (!sid_to_uid(&sid, &uid)) {\n\t\t\tDEBUG(0,(\"sid_to_uid: failed, sid[%s] sid_len[%lu]\\n\",\n\t\t\t\t sid_string_dbg(&sid),\n\t\t\t\t (unsigned long)sid_len));\n\t\t\tuid = (-1);\n\t\t}\n\n\t\t\/* we can take a look at the find source :-)\n\t\t *\n\t\t * find .\/ -uid $uid  -name '*'   is what we need here\n\t\t *\n\t\t *\n\t\t * and send 4bytes len and then NULL terminated unicode strings\n\t\t * for each file\n\t\t *\n\t\t * but I don't know how to deal with the paged results\n\t\t * (maybe we can hang the result anywhere in the fsp struct)\n\t\t *\n\t\t * but I don't know how to deal with the paged results\n\t\t * (maybe we can hang the result anywhere in the fsp struct)\n\t\t *\n\t\t * we don't send all files at once\n\t\t * and at the next we should *not* start from the beginning,\n\t\t * so we have to cache the result\n\t\t *\n\t\t * --metze\n\t\t *\/\n\n\t\t\/* this works for now... *\/\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tcase FSCTL_QUERY_ALLOCATED_RANGES:\n\t{\n\t\t\/* FIXME: This is just a dummy reply, telling that all of the\n\t\t * file is allocated. MKS cp needs that.\n\t\t * Adding the real allocated ranges via FIEMAP on Linux\n\t\t * and SEEK_DATA\/SEEK_HOLE on Solaris is needed to make\n\t\t * this FSCTL correct for sparse files.\n\t\t *\/\n\t\tNTSTATUS status;\n\t\tuint64_t offset, length;\n\t\tchar *out_data_tmp = NULL;\n\n\t\tif (in_len != 16) {\n\t\t\tDEBUG(0,(\"FSCTL_QUERY_ALLOCATED_RANGES: data_count(%u) != 16 is invalid!\\n\",\n\t\t\t\tin_len));\n\t\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t\t}\n\n\t\tif (max_out_len < 16) {\n\t\t\tDEBUG(0,(\"FSCTL_QUERY_ALLOCATED_RANGES: max_out_len (%u) < 16 is invalid!\\n\",\n\t\t\t\tmax_out_len));\n\t\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t\t}\n\n\t\toffset = BVAL(in_data,0);\n\t\tlength = BVAL(in_data,8);\n\n\t\tif (offset + length < offset) {\n\t\t\t\/* No 64-bit integer wrap. *\/\n\t\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t\t}\n\n\t\t\/* Shouldn't this be SMB_VFS_STAT ... ? *\/\n\t\tstatus = vfs_stat_fsp(fsp);\n\t\tif (!NT_STATUS_IS_OK(status)) {\n\t\t\treturn status;\n\t\t}\n\n\t\t*out_len = 16;\n\t\tout_data_tmp = talloc_array(ctx, char, *out_len);\n\t\tif (out_data_tmp == NULL) {\n\t\t\tDEBUG(10, (\"unable to allocate memory for response\\n\"));\n\t\t\treturn NT_STATUS_NO_MEMORY;\n\t\t}\n\n\t\tif (offset > fsp->fsp_name->st.st_ex_size ||\n\t\t\t\tfsp->fsp_name->st.st_ex_size == 0 ||\n\t\t\t\tlength == 0) {\n\t\t\tmemset(out_data_tmp, 0, *out_len);\n\t\t} else {\n\t\t\tuint64_t end = offset + length;\n\t\t\tend = MIN(end, fsp->fsp_name->st.st_ex_size);\n\t\t\tSBVAL(out_data_tmp, 0, 0);\n\t\t\tSBVAL(out_data_tmp, 8, end);\n\t\t}\n\n\t\t*out_data = out_data_tmp;\n\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tcase FSCTL_IS_VOLUME_DIRTY:\n\t{\n\t\tDEBUG(10,(\"FSCTL_IS_VOLUME_DIRTY: called on %s \"\n\t\t\t  \"(but remotely not supported)\\n\", fsp_fnum_dbg(fsp)));\n\t\t\/*\n\t\t * http:\/\/msdn.microsoft.com\/en-us\/library\/cc232128%28PROT.10%29.aspx\n\t\t * says we have to respond with NT_STATUS_INVALID_PARAMETER\n\t\t *\/\n\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t}\n\n\tdefault:\n\t\t\/* \n\t\t * Only print once ... unfortunately there could be lots of\n\t\t * different FSCTLs that are called.\n\t\t *\/\n\t\tif (!vfswrap_logged_ioctl_message) {\n\t\t\tvfswrap_logged_ioctl_message = true;\n\t\t\tDEBUG(2, (\"%s (0x%x): Currently not implemented.\\n\",\n\t\t\t__func__, function));\n\t\t}\n\t}\n\n\treturn NT_STATUS_NOT_SUPPORTED;\n}","target":1,"code_token_length":2730,"total_token_length":2966,"max_tokens_setting":4096}
+{"idx":195237,"func":"static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define CropBox  \"CropBox\"\n#define DeviceCMYK  \"DeviceCMYK\"\n#define MediaBox  \"MediaBox\"\n#define RenderPCLText  \"  Rendering PCL...  \"\n\n  char\n    command[MagickPathExtent],\n    *density,\n    filename[MagickPathExtent],\n    geometry[MagickPathExtent],\n    *options,\n    input_filename[MagickPathExtent];\n\n  const DelegateInfo\n    *delegate_info;\n\n  Image\n    *image,\n    *next_image;\n\n  ImageInfo\n    *read_info;\n\n  MagickBooleanType\n    cmyk,\n    status;\n\n  PointInfo\n    delta;\n\n  RectangleInfo\n    bounding_box,\n    page;\n\n  char\n    *p;\n\n  ssize_t\n    c;\n\n  SegmentInfo\n    bounds;\n\n  size_t\n    height,\n    width;\n\n  ssize_t\n    count;\n\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  \/*\n    Open image file.\n  *\/\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  status=AcquireUniqueSymbolicLink(image_info->filename,input_filename);\n  if (status == MagickFalse)\n    {\n      ThrowFileException(exception,FileOpenError,\"UnableToCreateTemporaryFile\",\n        image_info->filename);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Set the page density.\n  *\/\n  delta.x=DefaultResolution;\n  delta.y=DefaultResolution;\n  if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))\n    {\n      GeometryInfo\n        geometry_info;\n\n      MagickStatusType\n        flags;\n\n      flags=ParseGeometry(PSDensityGeometry,&geometry_info);\n      if ((flags & RhoValue) != 0)\n        image->resolution.x=geometry_info.rho;\n      image->resolution.y=image->resolution.x;\n      if ((flags & SigmaValue) != 0)\n        image->resolution.y=geometry_info.sigma;\n    }\n  \/*\n    Determine page geometry from the PCL media box.\n  *\/\n  cmyk=image->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;\n  count=0;\n  (void) memset(&bounding_box,0,sizeof(bounding_box));\n  (void) memset(&bounds,0,sizeof(bounds));\n  (void) memset(&page,0,sizeof(page));\n  (void) memset(command,0,sizeof(command));\n  p=command;\n  for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))\n  {\n    if (image_info->page != (char *) NULL)\n      continue;\n    \/*\n      Note PCL elements.\n    *\/\n    *p++=(char) c;\n    if ((c != (int) '\/') && (c != '\\n') &&\n        ((size_t) (p-command) < (MagickPathExtent-1)))\n      continue;\n    *p='\\0';\n    p=command;\n    \/*\n      Is this a CMYK document?\n    *\/\n    if (LocaleNCompare(DeviceCMYK,command,strlen(DeviceCMYK)) == 0)\n      cmyk=MagickTrue;\n    if (LocaleNCompare(CropBox,command,strlen(CropBox)) == 0)\n      {\n        \/*\n          Note region defined by crop box.\n        *\/\n        count=(ssize_t) sscanf(command,\"CropBox [%lf %lf %lf %lf\",\n          &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n        if (count != 4)\n          count=(ssize_t) sscanf(command,\"CropBox[%lf %lf %lf %lf\",\n            &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n      }\n    if (LocaleNCompare(MediaBox,command,strlen(MediaBox)) == 0)\n      {\n        \/*\n          Note region defined by media box.\n        *\/\n        count=(ssize_t) sscanf(command,\"MediaBox [%lf %lf %lf %lf\",\n          &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n        if (count != 4)\n          count=(ssize_t) sscanf(command,\"MediaBox[%lf %lf %lf %lf\",\n            &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n      }\n    if (count != 4)\n      continue;\n    \/*\n      Set PCL render geometry.\n    *\/\n    width=(size_t) floor(bounds.x2-bounds.x1+0.5);\n    height=(size_t) floor(bounds.y2-bounds.y1+0.5);\n    if (width > page.width)\n      page.width=width;\n    if (height > page.height)\n      page.height=height;\n  }\n  (void) CloseBlob(image);\n  \/*\n    Render PCL with the GhostPCL delegate.\n  *\/\n  if ((page.width == 0) || (page.height == 0))\n    (void) ParseAbsoluteGeometry(PSPageGeometry,&page);\n  if (image_info->page != (char *) NULL)\n    (void) ParseAbsoluteGeometry(image_info->page,&page);\n  (void) FormatLocaleString(geometry,MagickPathExtent,\"%.20gx%.20g\",(double)\n    page.width,(double) page.height);\n  if (image_info->monochrome != MagickFalse)\n    delegate_info=GetDelegateInfo(\"pcl:mono\",(char *) NULL,exception);\n  else\n     if (cmyk != MagickFalse)\n       delegate_info=GetDelegateInfo(\"pcl:cmyk\",(char *) NULL,exception);\n     else\n       delegate_info=GetDelegateInfo(\"pcl:color\",(char *) NULL,exception);\n  if (delegate_info == (const DelegateInfo *) NULL)\n    {\n      image=DestroyImage(image);\n      return((Image *) NULL);\n    }\n  if ((page.width == 0) || (page.height == 0))\n    (void) ParseAbsoluteGeometry(PSPageGeometry,&page);\n  if (image_info->page != (char *) NULL)\n    (void) ParseAbsoluteGeometry(image_info->page,&page);\n  density=AcquireString(\"\");\n  options=AcquireString(\"\");\n  (void) FormatLocaleString(density,MagickPathExtent,\"%gx%g\",\n    image->resolution.x,image->resolution.y);\n  if (image_info->ping != MagickFalse)\n    (void) FormatLocaleString(density,MagickPathExtent,\"2.0x2.0\");\n  page.width=(size_t) floor(page.width*image->resolution.x\/delta.x+0.5);\n  page.height=(size_t) floor(page.height*image->resolution.y\/delta.y+0.5);\n  (void) FormatLocaleString(options,MagickPathExtent,\"-g%.20gx%.20g \",(double)\n    page.width,(double) page.height);\n  image=DestroyImage(image);\n  read_info=CloneImageInfo(image_info);\n  *read_info->magick='\\0';\n  if (read_info->number_scenes != 0)\n    {\n      if (read_info->number_scenes != 1)\n        (void) FormatLocaleString(options,MagickPathExtent,\"-dLastPage=%.20g\",\n          (double) (read_info->scene+read_info->number_scenes));\n      else\n        (void) FormatLocaleString(options,MagickPathExtent,\n          \"-dFirstPage=%.20g -dLastPage=%.20g\",(double) read_info->scene+1,\n          (double) (read_info->scene+read_info->number_scenes));\n      read_info->number_scenes=0;\n      if (read_info->scenes != (char *) NULL)\n        *read_info->scenes='\\0';\n    }\n  (void) CopyMagickString(filename,read_info->filename,MagickPathExtent);\n  (void) AcquireUniqueFilename(read_info->filename);\n  (void) FormatLocaleString(command,MagickPathExtent,\n    GetDelegateCommands(delegate_info),\n    read_info->antialias != MagickFalse ? 4 : 1,\n    read_info->antialias != MagickFalse ? 4 : 1,density,options,\n    read_info->filename,input_filename);\n  options=DestroyString(options);\n  density=DestroyString(density);\n  status=ExternalDelegateCommand(MagickFalse,read_info->verbose,command,\n    (char *) NULL,exception) != 0 ? MagickTrue : MagickFalse;\n  image=ReadImage(read_info,exception);\n  (void) RelinquishUniqueFileResource(read_info->filename);\n  (void) RelinquishUniqueFileResource(input_filename);\n  read_info=DestroyImageInfo(read_info);\n  if (image == (Image *) NULL)\n    ThrowReaderException(DelegateError,\"PCLDelegateFailed\");\n  if (LocaleCompare(image->magick,\"BMP\") == 0)\n    {\n      Image\n        *cmyk_image;\n\n      cmyk_image=ConsolidateCMYKImages(image,exception);\n      if (cmyk_image != (Image *) NULL)\n        {\n          image=DestroyImageList(image);\n          image=cmyk_image;\n        }\n    }\n  do\n  {\n    (void) CopyMagickString(image->filename,filename,MagickPathExtent);\n    image->page=page;\n    if (image_info->ping != MagickFalse)\n      {\n        image->magick_columns*=image->resolution.x\/2.0;\n        image->magick_rows*=image->resolution.y\/2.0;\n        image->columns*=image->resolution.x\/2.0;\n        image->rows*=image->resolution.y\/2.0;\n      }\n    next_image=SyncNextImageInList(image);\n    if (next_image != (Image *) NULL)\n      image=next_image;\n  } while (next_image != (Image *) NULL);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":2218,"total_token_length":2454,"max_tokens_setting":4096}
+{"idx":462222,"func":"PJ_DEF(pj_status_t) pj_stun_msg_decode(pj_pool_t *pool,\n\t\t\t\t       const pj_uint8_t *pdu,\n\t\t\t\t       pj_size_t pdu_len,\n\t\t\t\t       unsigned options,\n\t\t\t\t       pj_stun_msg **p_msg,\n\t\t\t\t       pj_size_t *p_parsed_len,\n\t\t\t\t       pj_stun_msg **p_response)\n{\n    \n    pj_stun_msg *msg;\n    const pj_uint8_t *start_pdu = pdu;\n    pj_bool_t has_msg_int = PJ_FALSE;\n    pj_bool_t has_fingerprint = PJ_FALSE;\n    pj_status_t status;\n\n    PJ_UNUSED_ARG(options);\n\n    PJ_ASSERT_RETURN(pool && pdu && pdu_len && p_msg, PJ_EINVAL);\n    PJ_ASSERT_RETURN(sizeof(pj_stun_msg_hdr) == 20, PJ_EBUG);\n\n    if (p_parsed_len)\n\t*p_parsed_len = 0;\n    if (p_response)\n\t*p_response = NULL;\n\n    \/* Check if this is a STUN message, if necessary *\/\n    if (options & PJ_STUN_CHECK_PACKET) {\n\tstatus = pj_stun_msg_check(pdu, pdu_len, options);\n\tif (status != PJ_SUCCESS)\n\t    return status;\n    }\n\n    \/* Create the message, copy the header, and convert to host byte order *\/\n    msg = PJ_POOL_ZALLOC_T(pool, pj_stun_msg);\n    pj_memcpy(&msg->hdr, pdu, sizeof(pj_stun_msg_hdr));\n    msg->hdr.type = pj_ntohs(msg->hdr.type);\n    msg->hdr.length = pj_ntohs(msg->hdr.length);\n    msg->hdr.magic = pj_ntohl(msg->hdr.magic);\n\n    pdu += sizeof(pj_stun_msg_hdr);\n    \/* pdu_len -= sizeof(pj_stun_msg_hdr); *\/\n    pdu_len = msg->hdr.length;\n\n    \/* No need to create response if this is not a request *\/\n    if (!PJ_STUN_IS_REQUEST(msg->hdr.type))\n\tp_response = NULL;\n\n    \/* Parse attributes *\/\n    while (pdu_len >= 4) {\n\tunsigned attr_type, attr_val_len;\n\tconst struct attr_desc *adesc;\n\n\t\/* Get attribute type and length. If length is not aligned\n\t * to 4 bytes boundary, add padding.\n\t *\/\n\tattr_type = GETVAL16H(pdu, 0);\n\tattr_val_len = GETVAL16H(pdu, 2);\n\tattr_val_len = (attr_val_len + 3) & (~3);\n\n\t\/* Check length *\/\n\tif (pdu_len < attr_val_len) {\n\t    pj_str_t err_msg;\n\t    char err_msg_buf[80];\n\n\t    err_msg.ptr = err_msg_buf;\n\t    err_msg.slen = pj_ansi_snprintf(err_msg_buf, sizeof(err_msg_buf),\n\t\t\t\t\t    \"Attribute %s has invalid length\",\n\t\t\t\t\t    pj_stun_get_attr_name(attr_type));\n\n\t    PJ_LOG(4,(THIS_FILE, \"Error decoding message: %.*s\",\n\t\t      (int)err_msg.slen, err_msg.ptr));\n\n\t    if (p_response) {\n\t\tpj_stun_msg_create_response(pool, msg, \n\t\t\t\t\t    PJ_STUN_SC_BAD_REQUEST, \n\t\t\t\t\t    &err_msg, p_response);\n\t    }\n\t    return PJNATH_ESTUNINATTRLEN;\n\t}\n\n\t\/* Get the attribute descriptor *\/\n\tadesc = find_attr_desc(attr_type);\n\n\tif (adesc == NULL) {\n\t    \/* Unrecognized attribute *\/\n\t    pj_stun_binary_attr *attr = NULL;\n\n\t    PJ_LOG(5,(THIS_FILE, \"Unrecognized attribute type 0x%x\", \n\t\t      attr_type));\n\n\t    \/* Is this a fatal condition? *\/\n\t    if (attr_type <= 0x7FFF) {\n\t\t\/* This is a mandatory attribute, we must return error\n\t\t * if we don't understand the attribute.\n\t\t *\/\n\t\tif (p_response) {\n\t\t    unsigned err_code = PJ_STUN_SC_UNKNOWN_ATTRIBUTE;\n\n\t\t    status = pj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\t\t err_code, NULL, \n\t\t\t\t\t\t\t p_response);\n\t\t    if (status==PJ_SUCCESS) {\n\t\t\tpj_uint16_t d = (pj_uint16_t)attr_type;\n\t\t\tpj_stun_msg_add_unknown_attr(pool, *p_response, 1, &d);\n\t\t    }\n\t\t}\n\n\t\treturn PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_UNKNOWN_ATTRIBUTE);\n\t    }\n\n\t    \/* Make sure we have rooms for the new attribute *\/\n\t    if (msg->attr_count >= PJ_STUN_MAX_ATTR) {\n\t\tif (p_response) {\n\t\t    pj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\tPJ_STUN_SC_SERVER_ERROR,\n\t\t\t\t\t\tNULL, p_response);\n\t\t}\n\t\treturn PJNATH_ESTUNTOOMANYATTR;\n\t    }\n\n\t    \/* Create binary attribute to represent this *\/\n\t    status = pj_stun_binary_attr_create(pool, attr_type, pdu+4, \n\t\t\t\t\t\tGETVAL16H(pdu, 2), &attr);\n\t    if (status != PJ_SUCCESS) {\n\t\tif (p_response) {\n\t\t    pj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\tPJ_STUN_SC_SERVER_ERROR,\n\t\t\t\t\t\tNULL, p_response);\n\t\t}\n\n\t\tPJ_LOG(4,(THIS_FILE, \n\t\t\t  \"Error parsing unknown STUN attribute type %d\",\n\t\t\t  attr_type));\n\n\t\treturn status;\n\t    }\n\n\t    \/* Add the attribute *\/\n\t    msg->attr[msg->attr_count++] = &attr->hdr;\n\n\t} else {\n\t    void *attr;\n\t    char err_msg1[PJ_ERR_MSG_SIZE],\n\t\t err_msg2[PJ_ERR_MSG_SIZE];\n\n\t    \/* Parse the attribute *\/\n\t    status = (adesc->decode_attr)(pool, pdu, &msg->hdr, &attr);\n\n\t    if (status != PJ_SUCCESS) {\n\t\tpj_strerror(status, err_msg1, sizeof(err_msg1));\n\n\t\tif (p_response) {\n\t\t    pj_str_t e;\n\n\t\t    e.ptr = err_msg2;\n\t\t    e.slen= pj_ansi_snprintf(err_msg2, sizeof(err_msg2),\n\t\t\t\t\t     \"%s in %s\",\n\t\t\t\t\t     err_msg1,\n\t\t\t\t\t     pj_stun_get_attr_name(attr_type));\n\t\t    if (e.slen < 1 || e.slen >= (int)sizeof(err_msg2))\n\t\t\te.slen = sizeof(err_msg2) - 1;\n\t\t    pj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\tPJ_STUN_SC_BAD_REQUEST,\n\t\t\t\t\t\t&e, p_response);\n\t\t}\n\n\t\tPJ_LOG(4,(THIS_FILE, \n\t\t\t  \"Error parsing STUN attribute %s: %s\",\n\t\t\t  pj_stun_get_attr_name(attr_type), \n\t\t\t  err_msg1));\n\n\t\treturn status;\n\t    }\n\n\t    if (attr_type == PJ_STUN_ATTR_MESSAGE_INTEGRITY && \n\t\t!has_fingerprint) \n\t    {\n\t\tif (has_msg_int) {\n\t\t    \/* Already has MESSAGE-INTEGRITY *\/\n\t\t    if (p_response) {\n\t\t\tpj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\t    PJ_STUN_SC_BAD_REQUEST,\n\t\t\t\t\t\t    NULL, p_response);\n\t\t    }\n\t\t    return PJNATH_ESTUNDUPATTR;\n\t\t}\n\t\thas_msg_int = PJ_TRUE;\n\n\t    } else if (attr_type == PJ_STUN_ATTR_FINGERPRINT) {\n\t\tif (has_fingerprint) {\n\t\t    \/* Already has FINGERPRINT *\/\n\t\t    if (p_response) {\n\t\t\tpj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\t    PJ_STUN_SC_BAD_REQUEST,\n\t\t\t\t\t\t    NULL, p_response);\n\t\t    }\n\t\t    return PJNATH_ESTUNDUPATTR;\n\t\t}\n\t\thas_fingerprint = PJ_TRUE;\n\t    } else {\n\t\tif (has_fingerprint) {\n\t\t    \/* Another attribute is found which is not FINGERPRINT\n\t\t     * after FINGERPRINT. Note that non-FINGERPRINT is\n\t\t     * allowed to appear after M-I\n\t\t     *\/\n\t\t    if (p_response) {\n\t\t\tpj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\t    PJ_STUN_SC_BAD_REQUEST,\n\t\t\t\t\t\t    NULL, p_response);\n\t\t    }\n\t\t    return PJNATH_ESTUNFINGERPOS;\n\t\t}\n\t    }\n\n\t    \/* Make sure we have rooms for the new attribute *\/\n\t    if (msg->attr_count >= PJ_STUN_MAX_ATTR) {\n\t\tif (p_response) {\n\t\t    pj_stun_msg_create_response(pool, msg,\n\t\t\t\t\t\tPJ_STUN_SC_SERVER_ERROR,\n\t\t\t\t\t\tNULL, p_response);\n\t\t}\n\t\treturn PJNATH_ESTUNTOOMANYATTR;\n\t    }\n\n\t    \/* Add the attribute *\/\n\t    msg->attr[msg->attr_count++] = (pj_stun_attr_hdr*)attr;\n\t}\n\n\t\/* Next attribute *\/\n\tif (attr_val_len + 4 >= pdu_len) {\n\t    pdu += pdu_len;\n\t    pdu_len = 0;\n\t} else {\n\t    pdu += (attr_val_len + 4);\n\t    pdu_len -= (attr_val_len + 4);\n\t}\n    }\n\n    if (pdu_len > 0) {\n\t\/* Stray trailing bytes *\/\n\tPJ_LOG(4,(THIS_FILE, \n\t\t  \"Error decoding STUN message: unparsed trailing %d bytes\",\n\t\t  pdu_len));\n\treturn PJNATH_EINSTUNMSGLEN;\n    }\n\n    *p_msg = msg;\n\n    if (p_parsed_len)\n\t*p_parsed_len = (pdu - start_pdu);\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":1921,"total_token_length":2157,"max_tokens_setting":4096}
+{"idx":230142,"func":"static json_t * check_attestation_packed(json_t * j_params, cbor_item_t * auth_data, cbor_item_t * att_stmt, const unsigned char * client_data, gnutls_pubkey_t g_key) {\n  json_t * j_error = json_array(), * j_return;\n  cbor_item_t * key, * alg = NULL, * sig = NULL, * x5c_array = NULL, * cert_leaf = NULL;\n  size_t i, client_data_hash_len = 32, cert_export_len = 128, cert_export_b64_len = 0;\n  char * message;\n  gnutls_pubkey_t pubkey = NULL;\n  gnutls_x509_crt_t cert = NULL;\n  gnutls_datum_t cert_dat, data, signature, cert_issued_by;\n  int ret, sig_alg = GNUTLS_SIGN_UNKNOWN;\n  unsigned char client_data_hash[32], cert_export[128], cert_export_b64[256];\n\n  data.data = NULL;\n  UNUSED(j_params);\n\n  if (j_error != NULL) {\n    do {\n      for (i=0; i<cbor_map_size(att_stmt); i++) {\n        key = cbor_map_handle(att_stmt)[i].key;\n        if (cbor_isa_string(key)) {\n          if (0 == o_strncmp((const char *)cbor_string_handle(key), \"alg\", MIN(o_strlen(\"alg\"), cbor_string_length(key))) && cbor_isa_negint(cbor_map_handle(att_stmt)[i].value)) {\n            alg = cbor_map_handle(att_stmt)[i].value;\n            if (cbor_get_int(alg) == 6) {\n              sig_alg = GNUTLS_SIGN_ECDSA_SHA256;\n            } else if (cbor_get_int(alg) == 34) {\n              sig_alg = GNUTLS_SIGN_ECDSA_SHA384;\n            } else if (cbor_get_int(alg) == 35) {\n              sig_alg = GNUTLS_SIGN_ECDSA_SHA512;\n            }\n            if (sig_alg == GNUTLS_SIGN_UNKNOWN) {\n              json_array_append_new(j_error, json_string(\"Signature algorithm not supported\"));\n              break;\n            }\n          } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"sig\", MIN(o_strlen(\"sig\"), cbor_string_length(key))) && cbor_isa_bytestring(cbor_map_handle(att_stmt)[i].value)) {\n            sig = cbor_map_handle(att_stmt)[i].value;\n          } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"x5c\", MIN(o_strlen(\"x5c\"), cbor_string_length(key))) && cbor_isa_array(cbor_map_handle(att_stmt)[i].value) && cbor_array_size(cbor_map_handle(att_stmt)[i].value)) {\n            x5c_array = cbor_map_handle(att_stmt)[i].value;\n          } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"ecdaaKeyId\", MIN(o_strlen(\"ecdaaKeyId\"), cbor_string_length(key)))) {\n            json_array_append_new(j_error, json_string(\"ecdaaKeyId not supported\"));\n            break;\n          }\n        } else {\n          message = msprintf(\"attStmt map element %zu key is not a string\", i);\n          json_array_append_new(j_error, json_string(message));\n          o_free(message);\n          break;\n        }\n      }\n\n      if (json_array_size(j_error)) {\n        break;\n      }\n\n      if (alg == NULL || sig == NULL) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_packed - Error alg or sig are not mapped in att_stmt\");\n        break;\n      }\n\n      if (!generate_digest_raw(digest_SHA256, client_data, o_strlen((char *)client_data), client_data_hash, &client_data_hash_len)) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Error generate_digest_raw client_data\");\n        break;\n      }\n\n      if ((data.data = o_malloc(cbor_bytestring_length(auth_data) + client_data_hash_len)) == NULL) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Error o_malloc data.data\");\n        break;\n      }\n\n      signature.data = cbor_bytestring_handle(sig);\n      signature.size = cbor_bytestring_length(sig);\n\n      memcpy(data.data, cbor_bytestring_handle(auth_data), cbor_bytestring_length(auth_data));\n      memcpy(data.data + cbor_bytestring_length(auth_data), client_data_hash, client_data_hash_len);\n      data.size = cbor_bytestring_length(auth_data) + client_data_hash_len;\n\n      \/\/ packed disable SELF attestation for now\n      if (x5c_array == NULL) {\n        if (gnutls_pubkey_verify_data2(g_key, sig_alg, 0, &data, &signature)) {\n          json_array_append_new(j_error, json_string(\"Invalid signature\"));\n          break;\n        }\n\n        cert_export_b64_len = 0;\n        cert_export_b64[0] = '\\0';\n      } else {\n        if (gnutls_x509_crt_init(&cert)) {\n          json_array_append_new(j_error, json_string(\"check_attestation_packed - Error gnutls_x509_crt_init\"));\n          break;\n        }\n        if (gnutls_pubkey_init(&pubkey)) {\n          json_array_append_new(j_error, json_string(\"check_attestation_packed - Error gnutls_pubkey_init\"));\n          break;\n        }\n\n        cert_leaf = cbor_array_get(x5c_array, 0);\n        cert_dat.data = cbor_bytestring_handle(cert_leaf);\n        cert_dat.size = cbor_bytestring_length(cert_leaf);\n\n        if ((ret = gnutls_x509_crt_import(cert, &cert_dat, GNUTLS_X509_FMT_DER)) < 0) {\n          json_array_append_new(j_error, json_string(\"Error importing x509 certificate\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Error gnutls_pcert_import_x509_raw: %d\", ret);\n          break;\n        }\n\n        if ((ret = gnutls_pubkey_import_x509(pubkey, cert, 0)) < 0) {\n          json_array_append_new(j_error, json_string(\"Error importing x509 certificate\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Error gnutls_pubkey_import_x509: %d\", ret);\n          break;\n        }\n\n        if (gnutls_pubkey_verify_data2(pubkey, sig_alg, 0, &data, &signature)) {\n          json_array_append_new(j_error, json_string(\"Invalid signature\"));\n          break;\n        }\n\n        if (validate_packed_leaf_certificate(cert, (cbor_bytestring_handle(auth_data)+ATTESTED_CRED_DATA_OFFSET)) != G_OK) {\n          json_array_append_new(j_error, json_string(\"Invalid certificate\"));\n          break;\n        }\n\n        if ((ret = gnutls_x509_crt_get_key_id(cert, GNUTLS_KEYID_USE_SHA256, cert_export, &cert_export_len)) < 0) {\n          json_array_append_new(j_error, json_string(\"Error exporting x509 certificate\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Error gnutls_x509_crt_get_key_id: %d\", ret);\n          break;\n        }\n\n        if (json_object_get(j_params, \"root-ca-list\") != json_null() && validate_certificate_from_root(j_params, cert, x5c_array) != G_OK) {\n          json_array_append_new(j_error, json_string(\"Unrecognized certificate authority\"));\n          if (gnutls_x509_crt_get_issuer_dn2(cert, &cert_issued_by) >= 0) {\n            message = msprintf(\"Unrecognized certificate autohority: %.*s\", cert_issued_by.size, cert_issued_by.data);\n            y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - %s\", message);\n            o_free(message);\n            gnutls_free(cert_issued_by.data);\n          } else {\n            y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Unrecognized certificate autohority (unable to get issuer dn)\");\n          }\n          break;\n        }\n\n        if (!o_base64_encode(cert_export, cert_export_len, cert_export_b64, &cert_export_b64_len)) {\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_packed - Error o_base64_encode cert_export\");\n          break;\n        }\n      }\n\n    } while (0);\n\n    if (json_array_size(j_error)) {\n      j_return = json_pack(\"{sisO}\", \"result\", G_ERROR_PARAM, \"error\", j_error);\n    } else {\n      j_return = json_pack(\"{sis{ss%}}\", \"result\", G_OK, \"data\", \"certificate\", cert_export_b64, cert_export_b64_len);\n    }\n    json_decref(j_error);\n    gnutls_x509_crt_deinit(cert);\n    gnutls_pubkey_deinit(pubkey);\n    o_free(data.data);\n    if (cert_leaf != NULL) {\n      cbor_decref(&cert_leaf);\n    }\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_packed - Error allocating resources for j_error\");\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n  }\n  return j_return;\n}","target":0,"code_token_length":2131,"total_token_length":2367,"max_tokens_setting":4096}
+{"idx":274683,"func":"aperture_report(gerbv_aperture_t *apertures[], int aperture_num,\n\t\tdouble x, double y, gerbv_image_t *img, gerbv_project_t *prj)\n{\n\tgerbv_aperture_type_t type = apertures[aperture_num]->type;\n\tdouble *params = apertures[aperture_num]->parameter;\n\tgerbv_simplified_amacro_t *sam = apertures[aperture_num]->simplified;\n\n\tg_message (_(\"    Aperture used: D%d\"), aperture_num);\n\tg_message (_(\"    Aperture type: %s\"),\n\t\t(type == GERBV_APTYPE_MACRO)?\n\t\t\t_(gerbv_aperture_type_name(sam->type)):\n\t\t\t_(gerbv_aperture_type_name(type)));\n\n\tswitch (type) {\n\tcase GERBV_APTYPE_CIRCLE:\n\t\tg_message (_(\"    Diameter: %g %s\"),\n\t\t\tscreen_units(params[0]),\n\t\t\tscreen_units_str());\n\t\tbreak;\n\tcase GERBV_APTYPE_RECTANGLE:\n\tcase GERBV_APTYPE_OVAL:\n\t\tg_message (_(\"    Dimensions: %gx%g %s\"),\n\t\t\tscreen_units(params[0]),\n\t\t\tscreen_units(params[1]),\n\t\t\tscreen_units_str());\n\t\tbreak;\n\tcase GERBV_APTYPE_MACRO: {\n\t\tswitch (sam->type) {\n\t\tcase GERBV_APTYPE_MACRO_CIRCLE:\n\t\t\tg_message (_(\"    Diameter: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[CIRCLE_DIAMETER]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[CIRCLE_CENTER_X];\n\t\t\ty += sam->parameter[CIRCLE_CENTER_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Center: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_OUTLINE:\n\t\t\tg_message (_(\"    Number of points: %g\"),\n\t\t\t\tsam->parameter[OUTLINE_NUMBER_OF_POINTS]);\n\t\t\tx += sam->parameter[OUTLINE_FIRST_X];\n\t\t\ty += sam->parameter[OUTLINE_FIRST_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Start: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\tsam->parameter[OUTLINE_ROTATION_IDX(sam->parameter)]);\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_POLYGON:\n\t\t\tg_message (_(\"    Number of points: %g\"),\n\t\t\t\tsam->parameter[POLYGON_NUMBER_OF_POINTS]);\n\t\t\tg_message (_(\"    Diameter: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[POLYGON_DIAMETER]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[POLYGON_CENTER_X];\n\t\t\ty += sam->parameter[POLYGON_CENTER_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Center: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\tsam->parameter[POLYGON_ROTATION]);\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_MOIRE:\n\t\t\tg_message (_(\"    Outside diameter: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[MOIRE_OUTSIDE_DIAMETER]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Ring thickness: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[MOIRE_CIRCLE_THICKNESS]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Gap width: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[MOIRE_GAP_WIDTH]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Number of rings: %g\"),\n\t\t\t\tsam->parameter[MOIRE_NUMBER_OF_CIRCLES]);\n\t\t\tg_message (_(\"    Crosshair thickness: %g %s\"),\n\t\t\t\tscreen_units(\n\t\t\t\t\tsam->parameter[MOIRE_CROSSHAIR_THICKNESS]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Crosshair length: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[MOIRE_CROSSHAIR_LENGTH]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[MOIRE_CENTER_X];\n\t\t\ty += sam->parameter[MOIRE_CENTER_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Center: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\tsam->parameter[MOIRE_ROTATION]);\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_THERMAL:\n\t\t\tg_message (_(\"    Outside diameter: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[THERMAL_OUTSIDE_DIAMETER]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Inside diameter: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[THERMAL_INSIDE_DIAMETER]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Crosshair thickness: %g %s\"),\n\t\t\t\tscreen_units(\n\t\t\t\t\tsam->parameter[THERMAL_CROSSHAIR_THICKNESS]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[THERMAL_CENTER_X];\n\t\t\ty += sam->parameter[THERMAL_CENTER_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Center: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\tsam->parameter[THERMAL_ROTATION]);\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_LINE20:\n\t\t\tg_message (_(\"    Width: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[LINE20_WIDTH]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[LINE20_START_X];\n\t\t\ty += sam->parameter[LINE20_START_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Start: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[LINE20_END_X];\n\t\t\ty += sam->parameter[LINE20_END_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Stop: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\t\tsam->parameter[LINE20_ROTATION]);\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_LINE21:\n\t\t\tg_message (_(\"    Width: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[LINE21_WIDTH]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Height: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[LINE21_HEIGHT]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[LINE21_CENTER_X];\n\t\t\ty += sam->parameter[LINE21_CENTER_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Center: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\t\tsam->parameter[LINE21_ROTATION]);\n\t\t\tbreak;\n\n\t\tcase GERBV_APTYPE_MACRO_LINE22:\n\t\t\tg_message (_(\"    Width: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[LINE22_WIDTH]),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Height: %g %s\"),\n\t\t\t\tscreen_units(sam->parameter[LINE22_HEIGHT]),\n\t\t\t\tscreen_units_str());\n\t\t\tx += sam->parameter[LINE22_LOWER_LEFT_X];\n\t\t\ty += sam->parameter[LINE22_LOWER_LEFT_Y];\n\t\t\tgerbv_transform_coord_for_image(&x, &y, img, prj);\n\t\t\tg_message (_(\"    Lower left: (%g, %g) %s\"),\n\t\t\t\tscreen_units(x), screen_units(y),\n\t\t\t\tscreen_units_str());\n\t\t\tg_message (_(\"    Rotation: %g deg\"),\n\t\t\t\t\tsam->parameter[LINE22_ROTATION]);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\t}\n\tdefault:\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":1838,"total_token_length":2074,"max_tokens_setting":4096}
+{"idx":413663,"func":"static int core_anal_graph_construct_nodes(RCore *core, RAnalFunction *fcn, int opts, PJ *pj, Sdb *DB) {\n\tRAnalBlock *bbi;\n\tRListIter *iter;\n\tint is_keva = opts & R_CORE_ANAL_KEYVALUE;\n\tint is_star = opts & R_CORE_ANAL_STAR;\n\tint is_json = opts & R_CORE_ANAL_JSON;\n\tint is_html = r_cons_context ()->is_html;\n\tint left = 300;\n\tint top = 0;\n\n\tint is_json_format_disasm = opts & R_CORE_ANAL_JSON_FORMAT_DISASM;\n\tchar *pal_curr = palColorFor (\"graph.current\");\n\tchar *pal_traced = palColorFor (\"graph.traced\");\n\tchar *pal_box4 = palColorFor (\"graph.box4\");\n\tconst char *font = r_config_get (core->config, \"graph.font\");\n\tbool color_current = r_config_get_i (core->config, \"graph.gv.current\");\n\tchar *str;\n\tint nodes = 0;\n\tr_list_foreach (fcn->bbs, iter, bbi) {\n\t\tif (is_keva) {\n\t\t\tchar key[128];\n\t\t\tsdb_array_push_num (DB, \"bbs\", bbi->addr, 0);\n\t\t\tsnprintf (key, sizeof (key), \"bb.0x%08\"PFMT64x\".size\", bbi->addr);\n\t\t\tsdb_num_set (DB, key, bbi->size, 0); \/\/ bb.<addr>.size=<num>\n\t\t} else if (is_json) {\n\t\t\tRDebugTracepoint *t = r_debug_trace_get (core->dbg, bbi->addr);\n\t\t\tpj_o (pj);\n\t\t\tpj_kn (pj, \"offset\", bbi->addr);\n\t\t\tpj_kn (pj, \"size\", bbi->size);\n\t\t\tif (bbi->jump != UT64_MAX) {\n\t\t\t\tpj_kn (pj, \"jump\", bbi->jump);\n\t\t\t}\n\t\t\tif (bbi->fail != -1) {\n\t\t\t\tpj_kn (pj, \"fail\", bbi->fail);\n\t\t\t}\n\t\t\tif (bbi->switch_op) {\n\t\t\t\tRAnalSwitchOp *op = bbi->switch_op;\n\t\t\t\tpj_k (pj, \"switchop\");\n\t\t\t\tpj_o (pj);\n\t\t\t\tpj_kn (pj, \"offset\", op->addr);\n\t\t\t\tpj_kn (pj, \"defval\", op->def_val);\n\t\t\t\tpj_kn (pj, \"maxval\", op->max_val);\n\t\t\t\tpj_kn (pj, \"minval\", op->min_val);\n\t\t\t\tpj_k (pj, \"cases\");\n\t\t\t\tpj_a (pj);\n\t\t\t\tRAnalCaseOp *case_op;\n\t\t\t\tRListIter *case_iter;\n\t\t\t\tr_list_foreach (op->cases, case_iter, case_op) {\n\t\t\t\t\tpj_o (pj);\n\t\t\t\t\tpj_kn (pj, \"offset\", case_op->addr);\n\t\t\t\t\tpj_kn (pj, \"value\", case_op->value);\n\t\t\t\t\tpj_kn (pj, \"jump\", case_op->jump);\n\t\t\t\t\tpj_end (pj);\n\t\t\t\t}\n\t\t\t\tpj_end (pj);\n\t\t\t\tpj_end (pj);\n\t\t\t}\n\t\t\tif (t) {\n\t\t\t\tpj_k (pj, \"trace\");\n\t\t\t\tpj_o (pj);\n\t\t\t\tpj_ki (pj, \"count\", t->count);\n\t\t\t\tpj_ki (pj, \"times\", t->times);\n\t\t\t\tpj_end (pj);\n\t\t\t}\n\t\t\tif (bbi->color.r || bbi->color.g || bbi->color.b) {\n\t\t\t\tchar *s = r_cons_rgb_tostring (bbi->color.r, bbi->color.g, bbi->color.b);\n\t\t\t\tpj_ks (pj, \"color\", s);\n\t\t\t\tfree (s);\n\t\t\t}\n\t\t\tpj_k (pj, \"ops\");\n\t\t\tpj_a (pj);\n\t\t\tut8 *buf = malloc (bbi->size);\n\t\t\tif (buf) {\n\t\t\t\tr_io_read_at (core->io, bbi->addr, buf, bbi->size);\n\t\t\t\tif (is_json_format_disasm) {\n\t\t\t\t\tr_core_print_disasm (core, bbi->addr, buf, bbi->size, bbi->size, 0, NULL, true, true, pj, NULL);\n\t\t\t\t} else {\n\t\t\t\t\tr_core_print_disasm_json (core, bbi->addr, buf, bbi->size, 0, pj);\n\t\t\t\t}\n\t\t\t\tfree (buf);\n\t\t\t} else {\n\t\t\t\teprintf (\"cannot allocate %\"PFMT64u\" byte(s)\\n\", bbi->size);\n\t\t\t}\n\t\t\tpj_end (pj);\n\t\t\tpj_end (pj);\n\t\t\tcontinue;\n\t\t}\n\t\tif ((str = core_anal_graph_label (core, bbi, opts))) {\n\t\t\tif (opts & R_CORE_ANAL_GRAPHDIFF) {\n\t\t\t\tconst char *difftype = bbi->diff? (\\\n\t\t\t\tbbi->diff->type==R_ANAL_DIFF_TYPE_MATCH? \"lightgray\":\n\t\t\t\tbbi->diff->type==R_ANAL_DIFF_TYPE_UNMATCH? \"yellow\": \"red\"): \"orange\";\n\t\t\t\tconst char *diffname = bbi->diff? (\\\n\t\t\t\tbbi->diff->type==R_ANAL_DIFF_TYPE_MATCH? \"match\":\n\t\t\t\tbbi->diff->type==R_ANAL_DIFF_TYPE_UNMATCH? \"unmatch\": \"new\"): \"unk\";\n\t\t\t\tif (is_keva) {\n\t\t\t\t\tsdb_set (DB, \"diff\", diffname, 0);\n\t\t\t\t\tsdb_set (DB, \"label\", str, 0);\n\t\t\t\t} else if (!is_json) {\n\t\t\t\t\tnodes++;\n\t\t\t\t\tRConfigHold *hc = r_config_hold_new (core->config);\n\t\t\t\t\tr_config_hold (hc, \"scr.color\", \"scr.utf8\", \"asm.offset\", \"asm.lines\",\n\t\t\t\t\t\t\t\"asm.cmt.right\", \"asm.lines.fcn\", \"asm.bytes\", NULL);\n\t\t\t\t\tRDiff *d = r_diff_new ();\n\t\t\t\t\tr_config_set_i (core->config, \"scr.utf8\", 0);\n\t\t\t\t\tr_config_set_i (core->config, \"asm.offset\", 0);\n\t\t\t\t\tr_config_set_i (core->config, \"asm.lines\", 0);\n\t\t\t\t\tr_config_set_i (core->config, \"asm.cmt.right\", 0);\n\t\t\t\t\tr_config_set_i (core->config, \"asm.lines.fcn\", 0);\n\t\t\t\t\tr_config_set_i (core->config, \"asm.bytes\", 0);\n\t\t\t\t\tif (!is_star) {\n\t\t\t\t\t\tr_config_set_i (core->config, \"scr.color\", 0);\t\/\/ disable color for dot\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bbi->diff && bbi->diff->type != R_ANAL_DIFF_TYPE_MATCH && core->c2) {\n\t\t\t\t\t\tRCore *c = core->c2;\n\t\t\t\t\t\tRConfig *oc = c->config;\n\t\t\t\t\t\tchar *str = r_core_cmd_strf (core, \"pdb @ 0x%08\"PFMT64x, bbi->addr);\n\t\t\t\t\t\tc->config = core->config;\n\t\t\t\t\t\t\/\/ XXX. the bbi->addr doesnt needs to be in the same address in core2\n\t\t\t\t\t\tchar *str2 = r_core_cmd_strf (c, \"pdb @ 0x%08\"PFMT64x, bbi->diff->addr);\n\t\t\t\t\t\tchar *diffstr = r_diff_buffers_to_string (d,\n\t\t\t\t\t\t\t\t(const ut8*)str, strlen (str),\n\t\t\t\t\t\t\t\t(const ut8*)str2, strlen (str2));\n\n\t\t\t\t\t\tif (diffstr) {\n\t\t\t\t\t\t\tchar *nl = strchr (diffstr, '\\n');\n\t\t\t\t\t\t\tif (nl) {\n\t\t\t\t\t\t\t\tnl = strchr (nl + 1, '\\n');\n\t\t\t\t\t\t\t\tif (nl) {\n\t\t\t\t\t\t\t\t\tnl = strchr (nl + 1, '\\n');\n\t\t\t\t\t\t\t\t\tif (nl) {\n\t\t\t\t\t\t\t\t\t\tr_str_cpy (diffstr, nl + 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\t\tchar *title = get_title (bbi->addr);\n\t\t\t\t\t\t\tchar *body_b64 = r_base64_encode_dyn (diffstr, -1);\n\t\t\t\t\t\t\tif (!title  || !body_b64) {\n\t\t\t\t\t\t\t\tfree (body_b64);\n\t\t\t\t\t\t\t\tfree (title);\n\t\t\t\t\t\t\t\tr_diff_free (d);\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbody_b64 = r_str_prepend (body_b64, \"base64:\");\n\t\t\t\t\t\t\tr_cons_printf (\"agn %s %s %d\\n\", title, body_b64, bbi->diff->type);\n\t\t\t\t\t\t\tfree (body_b64);\n\t\t\t\t\t\t\tfree (title);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdiffstr = r_str_replace (diffstr, \"\\n\", \"\\\\l\", 1);\n\t\t\t\t\t\t\tdiffstr = r_str_replace (diffstr, \"\\\"\", \"'\", 1);\n\t\t\t\t\t\t\tr_cons_printf(\" \\\"0x%08\"PFMT64x\"\\\" [fillcolor=\\\"%s\\\",\"\n\t\t\t\t\t\t\t\"color=\\\"black\\\", fontname=\\\"%s\\\",\"\n\t\t\t\t\t\t\t\" label=\\\"%s\\\", URL=\\\"%s\/0x%08\"PFMT64x\"\\\"]\\n\",\n\t\t\t\t\t\t\tbbi->addr, difftype, font, diffstr, fcn->name,\n\t\t\t\t\t\t\tbbi->addr);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfree (diffstr);\n\t\t\t\t\t\tc->config = oc;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\t\tchar *title = get_title (bbi->addr);\n\t\t\t\t\t\t\tchar *body_b64 = r_base64_encode_dyn (str, -1);\n\t\t\t\t\t\t\tint color = (bbi && bbi->diff) ? bbi->diff->type : 0;\n\t\t\t\t\t\t\tif (!title  || !body_b64) {\n\t\t\t\t\t\t\t\tfree (body_b64);\n\t\t\t\t\t\t\t\tfree (title);\n\t\t\t\t\t\t\t\tr_diff_free (d);\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbody_b64 = r_str_prepend (body_b64, \"base64:\");\n\t\t\t\t\t\t\tr_cons_printf (\"agn %s %s %d\\n\", title, body_b64, color);\n\t\t\t\t\t\t\tfree (body_b64);\n\t\t\t\t\t\t\tfree (title);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tr_cons_printf(\" \\\"0x%08\"PFMT64x\"\\\" [fillcolor=\\\"%s\\\",\"\n\t\t\t\t\t\t\t\t\t\"color=\\\"black\\\", fontname=\\\"%s\\\",\"\n\t\t\t\t\t\t\t\t\t\" label=\\\"%s\\\", URL=\\\"%s\/0x%08\"PFMT64x\"\\\"]\\n\",\n\t\t\t\t\t\t\t\t\tbbi->addr, difftype, font, str, fcn->name, bbi->addr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tr_diff_free (d);\n\t\t\t\t\tr_config_set_i (core->config, \"scr.color\", 1);\n\t\t\t\t\tr_config_hold_free (hc);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (is_html) {\n\t\t\t\t\t\tnodes++;\n\t\t\t\t\t\tr_cons_printf (\"<p class=\\\"block draggable\\\" style=\\\"\"\n\t\t\t\t\t\t\t\t\t\t\t\t\"top: %dpx; left: %dpx; width: 400px;\\\" id=\\\"\"\n\t\t\t\t\t\t\t\t\t\t\t\t\"_0x%08\"PFMT64x\"\\\">\\n%s<\/p>\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\ttop, left, bbi->addr, str);\n\t\t\t\t\t\tleft = left? 0: 600;\n\t\t\t\t\t\tif (!left) {\n\t\t\t\t\t\t\t\ttop += 250;\n\t\t\t\t\t\t}\n\t\t\t\t} else if (!is_json && !is_keva) {\n\t\t\t\t\tbool current = r_anal_block_contains (bbi, core->offset);\n\t\t\t\t\tconst char *label_color = bbi->traced\n\t\t\t\t\t\t\t? pal_traced\n\t\t\t\t\t\t\t: (current && color_current)\n\t\t\t\t\t\t\t? pal_curr\n\t\t\t\t\t\t\t: pal_box4;\n\t\t\t\t\tconst char *fill_color = ((current && color_current) || label_color == pal_traced)? pal_traced: \"white\";\n\t\t\t\t\tnodes++;\n\t\t\t\t\tif (is_star) {\n\t\t\t\t\t\tchar *title = get_title (bbi->addr);\n\t\t\t\t\t\tchar *body_b64 = r_base64_encode_dyn (str, -1);\n\t\t\t\t\t\tint color = (bbi && bbi->diff) ? bbi->diff->type : 0;\n\t\t\t\t\t\tif (!title  || !body_b64) {\n\t\t\t\t\t\t\t\tfree (body_b64);\n\t\t\t\t\t\t\t\tfree (title);\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbody_b64 = r_str_prepend (body_b64, \"base64:\");\n\t\t\t\t\t\tr_cons_printf (\"agn %s %s %d\\n\", title, body_b64, color);\n\t\t\t\t\t\tfree (body_b64);\n\t\t\t\t\t\tfree (title);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr_cons_printf (\"\\t\\\"0x%08\"PFMT64x\"\\\" [\"\n\t\t\t\t\t\t\t\t\"URL=\\\"%s\/0x%08\"PFMT64x\"\\\", fillcolor=\\\"%s\\\",\"\n\t\t\t\t\t\t\t\t\"color=\\\"%s\\\", fontname=\\\"%s\\\",\"\n\t\t\t\t\t\t\t\t\"label=\\\"%s\\\"]\\n\",\n\t\t\t\t\t\t\t\tbbi->addr, fcn->name, bbi->addr,\n\t\t\t\t\t\t\t\tfill_color, label_color, font, str);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfree (str);\n\t\t}\n\t}\n\treturn nodes;\n}","target":0,"code_token_length":2815,"total_token_length":3051,"max_tokens_setting":4096}
+{"idx":299905,"func":"readconf_main(void)\n{\nint sep = 0;\nstruct stat statbuf;\nuschar *s, *filename;\nuschar *list = config_main_filelist;\n\n\/* Loop through the possible file names *\/\n\nwhile((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size))\n       != NULL)\n  {\n  \/* Cut out all the fancy processing unless specifically wanted *\/\n\n  #if defined(CONFIGURE_FILE_USE_NODE) || defined(CONFIGURE_FILE_USE_EUID)\n  uschar *suffix = filename + Ustrlen(filename);\n\n  \/* Try for the node-specific file if a node name exists *\/\n\n  #ifdef CONFIGURE_FILE_USE_NODE\n  struct utsname uts;\n  if (uname(&uts) >= 0)\n    {\n    #ifdef CONFIGURE_FILE_USE_EUID\n    sprintf(CS suffix, \".%ld.%.256s\", (long int)original_euid, uts.nodename);\n    config_file = Ufopen(filename, \"rb\");\n    if (config_file == NULL)\n    #endif  \/* CONFIGURE_FILE_USE_EUID *\/\n      {\n      sprintf(CS suffix, \".%.256s\", uts.nodename);\n      config_file = Ufopen(filename, \"rb\");\n      }\n    }\n  #endif  \/* CONFIGURE_FILE_USE_NODE *\/\n\n  \/* Otherwise, try the generic name, possibly with the euid added *\/\n\n  #ifdef CONFIGURE_FILE_USE_EUID\n  if (config_file == NULL)\n    {\n    sprintf(CS suffix, \".%ld\", (long int)original_euid);\n    config_file = Ufopen(filename, \"rb\");\n    }\n  #endif  \/* CONFIGURE_FILE_USE_EUID *\/\n\n  \/* Finally, try the unadorned name *\/\n\n  if (config_file == NULL)\n    {\n    *suffix = 0;\n    config_file = Ufopen(filename, \"rb\");\n    }\n  #else  \/* if neither defined *\/\n\n  \/* This is the common case when the fancy processing is not included. *\/\n\n  config_file = Ufopen(filename, \"rb\");\n  #endif\n\n  \/* If the file does not exist, continue to try any others. For any other\n  error, break out (and die). *\/\n\n  if (config_file != NULL || errno != ENOENT) break;\n  }\n\n\/* On success, save the name for verification; config_filename is used when\nlogging configuration errors (it changes for .included files) whereas\nconfig_main_filename is the name shown by -bP. Failure to open a configuration\nfile is a serious disaster. *\/\n\nif (config_file != NULL)\n  {\n  config_filename = config_main_filename = string_copy(filename);\n  }\nelse\n  {\n  if (filename == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"non-existent configuration file(s): \"\n      \"%s\", config_main_filelist);\n  else\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"%s\", string_open_failed(errno,\n      \"configuration file %s\", filename));\n  }\n\n\/* Check the status of the file we have opened, if we have retained root\nprivileges. *\/\n\nif (trusted_config)\n  {\n  if (fstat(fileno(config_file), &statbuf) != 0)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to stat configuration file %s\",\n      big_buffer);\n\n  if ((statbuf.st_uid != root_uid                \/* owner not root *\/\n       #ifdef CONFIGURE_OWNER\n       && statbuf.st_uid != config_uid           \/* owner not the special one *\/\n       #endif\n         ) ||                                    \/* or *\/\n      (statbuf.st_gid != root_gid                \/* group not root & *\/\n       #ifdef CONFIGURE_GROUP\n       && statbuf.st_gid != config_gid           \/* group not the special one *\/\n       #endif\n       && (statbuf.st_mode & 020) != 0) ||       \/* group writeable  *\/\n                                                 \/* or *\/\n      ((statbuf.st_mode & 2) != 0))              \/* world writeable  *\/\n\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"Exim configuration file %s has the \"\n      \"wrong owner, group, or mode\", big_buffer);\n  }\n\n\/* Process the main configuration settings. They all begin with a lower case\nletter. If we see something starting with an upper case letter, it is taken as\na macro definition. *\/\n\nwhile ((s = get_config_line()) != NULL)\n  {\n  if (isupper(s[0])) read_macro_assignment(s);\n\n  else if (Ustrncmp(s, \"domainlist\", 10) == 0)\n    read_named_list(&domainlist_anchor, &domainlist_count,\n      MAX_NAMED_LIST, s+10, US\"domain list\");\n\n  else if (Ustrncmp(s, \"hostlist\", 8) == 0)\n    read_named_list(&hostlist_anchor, &hostlist_count,\n      MAX_NAMED_LIST, s+8, US\"host list\");\n\n  else if (Ustrncmp(s, US\"addresslist\", 11) == 0)\n    read_named_list(&addresslist_anchor, &addresslist_count,\n      MAX_NAMED_LIST, s+11, US\"address list\");\n\n  else if (Ustrncmp(s, US\"localpartlist\", 13) == 0)\n    read_named_list(&localpartlist_anchor, &localpartlist_count,\n      MAX_NAMED_LIST, s+13, US\"local part list\");\n\n  else\n    (void) readconf_handle_option(s, optionlist_config, optionlist_config_size,\n      NULL, US\"main option \\\"%s\\\" unknown\");\n  }\n\n\n\/* If local_sender_retain is set, local_from_check must be unset. *\/\n\nif (local_sender_retain && local_from_check)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"both local_from_check and \"\n    \"local_sender_retain are set; this combination is not allowed\");\n\n\/* If the timezone string is empty, set it to NULL, implying no TZ variable\nwanted. *\/\n\nif (timezone_string != NULL && *timezone_string == 0) timezone_string = NULL;\n\n\/* The max retry interval must not be greater than 24 hours. *\/\n\nif (retry_interval_max > 24*60*60) retry_interval_max = 24*60*60;\n\n\/* remote_max_parallel must be > 0 *\/\n\nif (remote_max_parallel <= 0) remote_max_parallel = 1;\n\n\/* Save the configured setting of freeze_tell, so we can re-instate it at the\nstart of a new SMTP message. *\/\n\nfreeze_tell_config = freeze_tell;\n\n\/* The primary host name may be required for expansion of spool_directory\nand log_file_path, so make sure it is set asap. It is obtained from uname(),\nbut if that yields an unqualified value, make a FQDN by using gethostbyname to\ncanonize it. Some people like upper case letters in their host names, so we\ndon't force the case. *\/\n\nif (primary_hostname == NULL)\n  {\n  uschar *hostname;\n  struct utsname uts;\n  if (uname(&uts) < 0)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"uname() failed to yield host name\");\n  hostname = US uts.nodename;\n\n  if (Ustrchr(hostname, '.') == NULL)\n    {\n    int af = AF_INET;\n    struct hostent *hostdata;\n\n    #if HAVE_IPV6\n    if (!disable_ipv6 && (dns_ipv4_lookup == NULL ||\n         match_isinlist(hostname, &dns_ipv4_lookup, 0, NULL, NULL, MCL_DOMAIN,\n           TRUE, NULL) != OK))\n      af = AF_INET6;\n    #else\n    af = AF_INET;\n    #endif\n\n    for (;;)\n      {\n      #if HAVE_IPV6\n        #if HAVE_GETIPNODEBYNAME\n        int error_num;\n        hostdata = getipnodebyname(CS hostname, af, 0, &error_num);\n        #else\n        hostdata = gethostbyname2(CS hostname, af);\n        #endif\n      #else\n      hostdata = gethostbyname(CS hostname);\n      #endif\n\n      if (hostdata != NULL)\n        {\n        hostname = US hostdata->h_name;\n        break;\n        }\n\n      if (af == AF_INET) break;\n      af = AF_INET;\n      }\n    }\n\n  primary_hostname = string_copy(hostname);\n  }\n\n\/* Set up default value for smtp_active_hostname *\/\n\nsmtp_active_hostname = primary_hostname;\n\n\/* If spool_directory wasn't set in the build-time configuration, it must have\ngot set above. Of course, writing to the log may not work if log_file_path is\nnot set, but it will at least get to syslog or somewhere, with any luck. *\/\n\nif (*spool_directory == 0)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"spool_directory undefined: cannot \"\n    \"proceed\");\n\n\/* Expand the spool directory name; it may, for example, contain the primary\nhost name. Same comment about failure. *\/\n\ns = expand_string(spool_directory);\nif (s == NULL)\n  log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to expand spool_directory \"\n    \"\\\"%s\\\": %s\", spool_directory, expand_string_message);\nspool_directory = s;\n\n\/* Expand log_file_path, which must contain \"%s\" in any component that isn't\nthe null string or \"syslog\". It is also allowed to contain one instance of %D.\nHowever, it must NOT contain % followed by anything else. *\/\n\nif (*log_file_path != 0)\n  {\n  uschar *ss, *sss;\n  int sep = ':';                       \/* Fixed for log file path *\/\n  s = expand_string(log_file_path);\n  if (s == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to expand log_file_path \"\n      \"\\\"%s\\\": %s\", log_file_path, expand_string_message);\n\n  ss = s;\n  while ((sss = string_nextinlist(&ss,&sep,big_buffer,big_buffer_size)) != NULL)\n    {\n    uschar *t;\n    if (sss[0] == 0 || Ustrcmp(sss, \"syslog\") == 0) continue;\n    t = Ustrstr(sss, \"%s\");\n    if (t == NULL)\n      log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"log_file_path \\\"%s\\\" does not \"\n        \"contain \\\"%%s\\\"\", sss);\n    *t = 'X';\n    t = Ustrchr(sss, '%');\n    if (t != NULL)\n      {\n      if (t[1] != 'D' || Ustrchr(t+2, '%') != NULL)\n        log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"log_file_path \\\"%s\\\" contains \"\n          \"unexpected \\\"%%\\\" character\", s);\n      }\n    }\n\n  log_file_path = s;\n  }\n\n\/* Interpret syslog_facility into an integer argument for 'ident' param to\nopenlog(). Default is LOG_MAIL set in globals.c. Allow the user to omit the\nleading \"log_\". *\/\n\nif (syslog_facility_str != NULL)\n  {\n  int i;\n  uschar *s = syslog_facility_str;\n\n  if ((Ustrlen(syslog_facility_str) >= 4) &&\n        (strncmpic(syslog_facility_str, US\"log_\", 4) == 0))\n    s += 4;\n\n  for (i = 0; i < syslog_list_size; i++)\n    {\n    if (strcmpic(s, syslog_list[i].name) == 0)\n      {\n      syslog_facility = syslog_list[i].value;\n      break;\n      }\n    }\n\n  if (i >= syslog_list_size)\n    {\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"failed to interpret syslog_facility \\\"%s\\\"\", syslog_facility_str);\n    }\n  }\n\n\/* Expand pid_file_path *\/\n\nif (*pid_file_path != 0)\n  {\n  s = expand_string(pid_file_path);\n  if (s == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"failed to expand pid_file_path \"\n      \"\\\"%s\\\": %s\", pid_file_path, expand_string_message);\n  pid_file_path = s;\n  }\n\n\/* Compile the regex for matching a UUCP-style \"From_\" line in an incoming\nmessage. *\/\n\nregex_From = regex_must_compile(uucp_from_pattern, FALSE, TRUE);\n\n\/* Unpick the SMTP rate limiting options, if set *\/\n\nif (smtp_ratelimit_mail != NULL)\n  {\n  unpick_ratelimit(smtp_ratelimit_mail, &smtp_rlm_threshold,\n    &smtp_rlm_base, &smtp_rlm_factor, &smtp_rlm_limit);\n  }\n\nif (smtp_ratelimit_rcpt != NULL)\n  {\n  unpick_ratelimit(smtp_ratelimit_rcpt, &smtp_rlr_threshold,\n    &smtp_rlr_base, &smtp_rlr_factor, &smtp_rlr_limit);\n  }\n\n\/* The qualify domains default to the primary host name *\/\n\nif (qualify_domain_sender == NULL)\n  qualify_domain_sender = primary_hostname;\nif (qualify_domain_recipient == NULL)\n  qualify_domain_recipient = qualify_domain_sender;\n\n\/* Setting system_filter_user in the configuration sets the gid as well if a\nname is given, but a numerical value does not. *\/\n\nif (system_filter_uid_set && !system_filter_gid_set)\n  {\n  struct passwd *pw = getpwuid(system_filter_uid);\n  if (pw == NULL)\n    log_write(0, LOG_MAIN|LOG_PANIC_DIE, \"Failed to look up uid %ld\",\n      (long int)system_filter_uid);\n  system_filter_gid = pw->pw_gid;\n  system_filter_gid_set = TRUE;\n  }\n\n\/* If the errors_reply_to field is set, check that it is syntactically valid\nand ensure it contains a domain. *\/\n\nif (errors_reply_to != NULL)\n  {\n  uschar *errmess;\n  int start, end, domain;\n  uschar *recipient = parse_extract_address(errors_reply_to, &errmess,\n    &start, &end, &domain, FALSE);\n\n  if (recipient == NULL)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"error in errors_reply_to (%s): %s\", errors_reply_to, errmess);\n\n  if (domain == 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"errors_reply_to (%s) does not contain a domain\", errors_reply_to);\n  }\n\n\/* If smtp_accept_queue or smtp_accept_max_per_host is set, then\nsmtp_accept_max must also be set. *\/\n\nif (smtp_accept_max == 0 &&\n    (smtp_accept_queue > 0 || smtp_accept_max_per_host != NULL))\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n    \"smtp_accept_max must be set if smtp_accept_queue or \"\n    \"smtp_accept_max_per_host is set\");\n\n\/* Set up the host number if anything is specified. It is an expanded string\nso that it can be computed from the host name, for example. We do this last\nso as to ensure that everything else is set up before the expansion. *\/\n\nif (host_number_string != NULL)\n  {\n  uschar *end;\n  uschar *s = expand_string(host_number_string);\n  long int n = Ustrtol(s, &end, 0);\n  while (isspace(*end)) end++;\n  if (*end != 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"localhost_number value is not a number: %s\", s);\n  if (n > LOCALHOST_MAX)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"localhost_number is greater than the maximum allowed value (%d)\",\n        LOCALHOST_MAX);\n  host_number = n;\n  }\n\n#ifdef SUPPORT_TLS\n\/* If tls_verify_hosts is set, tls_verify_certificates must also be set *\/\n\nif ((tls_verify_hosts != NULL || tls_try_verify_hosts != NULL) &&\n     tls_verify_certificates == NULL)\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n    \"tls_%sverify_hosts is set, but tls_verify_certificates is not set\",\n    (tls_verify_hosts != NULL)? \"\" : \"try_\");\n\n\/* If openssl_options is set, validate it *\/\nif (openssl_options != NULL)\n  {\n# ifdef USE_GNUTLS\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n    \"openssl_options is set but we're using GnuTLS\");\n# else\n  long dummy;\n  if (!(tls_openssl_options_parse(openssl_options, &dummy)))\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG,\n      \"openssl_options parse error: %s\", openssl_options);\n# endif\n  }\n#endif\n}","target":0,"code_token_length":3667,"total_token_length":3903,"max_tokens_setting":4096}
+{"idx":217567,"func":"static char *TracePSClippath(const unsigned char *blob,size_t length,\n  const size_t magick_unused(columns),const size_t magick_unused(rows))\n{\n  char\n    *path,\n    *message;\n\n  MagickBooleanType\n    in_subpath;\n\n  PointInfo\n    first[3],\n    last[3],\n    point[3];\n\n  ssize_t\n    i,\n    x;\n\n  ssize_t\n    knot_count,\n    selector,\n    y;\n\n  magick_unreferenced(columns);\n  magick_unreferenced(rows);\n\n  path=AcquireString((char *) NULL);\n  if (path == (char *) NULL)\n    return((char *) NULL);\n  message=AcquireString((char *) NULL);\n  (void) FormatLocaleString(message,MaxTextExtent,\"\/ClipImage\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"{\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"  \/c {curveto} bind def\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"  \/l {lineto} bind def\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"  \/m {moveto} bind def\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\n    \"  \/v {currentpoint 6 2 roll curveto} bind def\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\n    \"  \/y {2 copy curveto} bind def\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\n    \"  \/z {closepath} bind def\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"  newpath\\n\");\n  (void) ConcatenateString(&path,message);\n  \/*\n    The clipping path format is defined in \"Adobe Photoshop File\n    Formats Specification\" version 6.0 downloadable from adobe.com.\n  *\/\n  (void) memset(point,0,sizeof(point));\n  (void) memset(first,0,sizeof(first));\n  (void) memset(last,0,sizeof(last));\n  knot_count=0;\n  in_subpath=MagickFalse;\n  while (length > 0)\n  {\n    selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);\n    switch (selector)\n    {\n      case 0:\n      case 3:\n      {\n        if (knot_count != 0)\n          {\n            blob+=24;\n            length-=MagickMin(24,(ssize_t) length);\n            break;\n          }\n        \/*\n          Expected subpath length record.\n        *\/\n        knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);\n        blob+=22;\n        length-=MagickMin(22,(ssize_t) length);\n        break;\n      }\n      case 1:\n      case 2:\n      case 4:\n      case 5:\n      {\n        if (knot_count == 0)\n          {\n            \/*\n              Unexpected subpath knot\n            *\/\n            blob+=24;\n            length-=MagickMin(24,(ssize_t) length);\n            break;\n          }\n        \/*\n          Add sub-path knot\n        *\/\n        for (i=0; i < 3; i++)\n        {\n          y=(size_t) ReadPropertyMSBLong(&blob,&length);\n          x=(size_t) ReadPropertyMSBLong(&blob,&length);\n          point[i].x=(double) x\/4096.0\/4096.0;\n          point[i].y=1.0-(double) y\/4096.0\/4096.0;\n        }\n        if (in_subpath == MagickFalse)\n          {\n            (void) FormatLocaleString(message,MaxTextExtent,\"  %g %g m\\n\",\n              point[1].x,point[1].y);\n            for (i=0; i < 3; i++)\n            {\n              first[i]=point[i];\n              last[i]=point[i];\n            }\n          }\n        else\n          {\n            \/*\n              Handle special cases when Bezier curves are used to describe\n              corners and straight lines.\n            *\/\n            if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&\n                (point[0].x == point[1].x) && (point[0].y == point[1].y))\n              (void) FormatLocaleString(message,MaxTextExtent,\n                \"  %g %g l\\n\",point[1].x,point[1].y);\n            else\n              if ((last[1].x == last[2].x) && (last[1].y == last[2].y))\n                (void) FormatLocaleString(message,MaxTextExtent,\n                  \"  %g %g %g %g v\\n\",point[0].x,point[0].y,\n                  point[1].x,point[1].y);\n              else\n                if ((point[0].x == point[1].x) && (point[0].y == point[1].y))\n                  (void) FormatLocaleString(message,MaxTextExtent,\n                    \"  %g %g %g %g y\\n\",last[2].x,last[2].y,\n                    point[1].x,point[1].y);\n                else\n                  (void) FormatLocaleString(message,MaxTextExtent,\n                    \"  %g %g %g %g %g %g c\\n\",last[2].x,\n                    last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);\n            for (i=0; i < 3; i++)\n              last[i]=point[i];\n          }\n        (void) ConcatenateString(&path,message);\n        in_subpath=MagickTrue;\n        knot_count--;\n        \/*\n          Close the subpath if there are no more knots.\n        *\/\n        if (knot_count == 0)\n          {\n            \/*\n              Same special handling as above except we compare to the\n              first point in the path and close the path.\n            *\/\n            if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&\n                (first[0].x == first[1].x) && (first[0].y == first[1].y))\n              (void) FormatLocaleString(message,MaxTextExtent,\n                \"  %g %g l z\\n\",first[1].x,first[1].y);\n            else\n              if ((last[1].x == last[2].x) && (last[1].y == last[2].y))\n                (void) FormatLocaleString(message,MaxTextExtent,\n                  \"  %g %g %g %g v z\\n\",first[0].x,first[0].y,\n                  first[1].x,first[1].y);\n              else\n                if ((first[0].x == first[1].x) && (first[0].y == first[1].y))\n                  (void) FormatLocaleString(message,MaxTextExtent,\n                    \"  %g %g %g %g y z\\n\",last[2].x,last[2].y,\n                    first[1].x,first[1].y);\n                else\n                  (void) FormatLocaleString(message,MaxTextExtent,\n                    \"  %g %g %g %g %g %g c z\\n\",last[2].x,\n                    last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);\n            (void) ConcatenateString(&path,message);\n            in_subpath=MagickFalse;\n          }\n        break;\n      }\n      case 6:\n      case 7:\n      case 8:\n      default:\n      {\n        blob+=24;\n        length-=MagickMin(24,(ssize_t) length);\n        break;\n      }\n    }\n  }\n  \/*\n    Returns an empty PS path if the path has no knots.\n  *\/\n  (void) FormatLocaleString(message,MaxTextExtent,\"  eoclip\\n\");\n  (void) ConcatenateString(&path,message);\n  (void) FormatLocaleString(message,MaxTextExtent,\"} bind def\");\n  (void) ConcatenateString(&path,message);\n  message=DestroyString(message);\n  return(path);\n}","target":0,"code_token_length":1906,"total_token_length":2142,"max_tokens_setting":4096}
+{"idx":216861,"func":"EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params)\n{\n    int ok = 0, tmp;\n    EC_GROUP *ret = NULL, *dup = NULL;\n    BIGNUM *p = NULL, *a = NULL, *b = NULL;\n    EC_POINT *point = NULL;\n    long field_bits;\n    int curve_name = NID_undef;\n    BN_CTX *ctx = NULL;\n\n    if (!params->fieldID || !params->fieldID->fieldType ||\n        !params->fieldID->p.ptr) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n\n    \/*\n     * Now extract the curve parameters a and b. Note that, although SEC 1\n     * specifies the length of their encodings, historical versions of OpenSSL\n     * encoded them incorrectly, so we must accept any length for backwards\n     * compatibility.\n     *\/\n    if (!params->curve || !params->curve->a ||\n        !params->curve->a->data || !params->curve->b ||\n        !params->curve->b->data) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    a = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL);\n    if (a == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    b = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL);\n    if (b == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    \/* get the field parameters *\/\n    tmp = OBJ_obj2nid(params->fieldID->fieldType);\n    if (tmp == NID_X9_62_characteristic_two_field)\n#ifdef OPENSSL_NO_EC2M\n    {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_GF2M_NOT_SUPPORTED);\n        goto err;\n    }\n#else\n    {\n        X9_62_CHARACTERISTIC_TWO *char_two;\n\n        char_two = params->fieldID->p.char_two;\n\n        field_bits = char_two->m;\n        if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE);\n            goto err;\n        }\n\n        if ((p = BN_new()) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n\n        \/* get the base type *\/\n        tmp = OBJ_obj2nid(char_two->type);\n\n        if (tmp == NID_X9_62_tpBasis) {\n            long tmp_long;\n\n            if (!char_two->p.tpBasis) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n                goto err;\n            }\n\n            tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis);\n\n            if (!(char_two->m > tmp_long && tmp_long > 0)) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS,\n                      EC_R_INVALID_TRINOMIAL_BASIS);\n                goto err;\n            }\n\n            \/* create the polynomial *\/\n            if (!BN_set_bit(p, (int)char_two->m))\n                goto err;\n            if (!BN_set_bit(p, (int)tmp_long))\n                goto err;\n            if (!BN_set_bit(p, 0))\n                goto err;\n        } else if (tmp == NID_X9_62_ppBasis) {\n            X9_62_PENTANOMIAL *penta;\n\n            penta = char_two->p.ppBasis;\n            if (!penta) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n                goto err;\n            }\n\n            if (!\n                (char_two->m > penta->k3 && penta->k3 > penta->k2\n                 && penta->k2 > penta->k1 && penta->k1 > 0)) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS,\n                      EC_R_INVALID_PENTANOMIAL_BASIS);\n                goto err;\n            }\n\n            \/* create the polynomial *\/\n            if (!BN_set_bit(p, (int)char_two->m))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k1))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k2))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k3))\n                goto err;\n            if (!BN_set_bit(p, 0))\n                goto err;\n        } else if (tmp == NID_X9_62_onBasis) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_NOT_IMPLEMENTED);\n            goto err;\n        } else {                \/* error *\/\n\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n            goto err;\n        }\n\n        \/* create the EC_GROUP structure *\/\n        ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL);\n    }\n#endif\n    else if (tmp == NID_X9_62_prime_field) {\n        \/* we have a curve over a prime field *\/\n        \/* extract the prime number *\/\n        if (!params->fieldID->p.prime) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n            goto err;\n        }\n        p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL);\n        if (p == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n            goto err;\n        }\n\n        if (BN_is_negative(p) || BN_is_zero(p)) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD);\n            goto err;\n        }\n\n        field_bits = BN_num_bits(p);\n        if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE);\n            goto err;\n        }\n\n        \/* create the EC_GROUP structure *\/\n        ret = EC_GROUP_new_curve_GFp(p, a, b, NULL);\n    } else {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD);\n        goto err;\n    }\n\n    if (ret == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n\n    \/* extract seed (optional) *\/\n    if (params->curve->seed != NULL) {\n        OPENSSL_free(ret->seed);\n        if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        memcpy(ret->seed, params->curve->seed->data,\n               params->curve->seed->length);\n        ret->seed_len = params->curve->seed->length;\n    }\n\n    if (!params->order || !params->base || !params->base->data) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n\n    if ((point = EC_POINT_new(ret)) == NULL)\n        goto err;\n\n    \/* set the point conversion form *\/\n    EC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t)\n                                       (params->base->data[0] & ~0x01));\n\n    \/* extract the ec point *\/\n    if (!EC_POINT_oct2point(ret, point, params->base->data,\n                            params->base->length, NULL)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n\n    \/* extract the order *\/\n    if ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n    if (BN_is_negative(a) || BN_is_zero(a)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (BN_num_bits(a) > (int)field_bits + 1) { \/* Hasse bound *\/\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n\n    \/* extract the cofactor (optional) *\/\n    if (params->cofactor == NULL) {\n        BN_free(b);\n        b = NULL;\n    } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n    \/* set the generator, order and cofactor (if present) *\/\n    if (!EC_GROUP_set_generator(ret, point, a, b)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n\n    \/*\n     * Check if the explicit parameters group just created matches one of the\n     * built-in curves.\n     *\n     * We create a copy of the group just built, so that we can remove optional\n     * fields for the lookup: we do this to avoid the possibility that one of\n     * the optional parameters is used to force the library into using a less\n     * performant and less secure EC_METHOD instead of the specialized one.\n     * In any case, `seed` is not really used in any computation, while a\n     * cofactor different from the one in the built-in table is just\n     * mathematically wrong anyway and should not be used.\n     *\/\n    if ((ctx = BN_CTX_new()) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((dup = EC_GROUP_dup(ret)) == NULL\n            || EC_GROUP_set_seed(dup, NULL, 0) != 1\n            || !EC_GROUP_set_generator(dup, point, a, NULL)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if ((curve_name = ec_curve_nid_from_params(dup, ctx)) != NID_undef) {\n        \/*\n         * The input explicit parameters successfully matched one of the\n         * built-in curves: often for built-in curves we have specialized\n         * methods with better performance and hardening.\n         *\n         * In this case we replace the `EC_GROUP` created through explicit\n         * parameters with one created from a named group.\n         *\/\n        EC_GROUP *named_group = NULL;\n\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n        \/*\n         * NID_wap_wsg_idm_ecid_wtls12 and NID_secp224r1 are both aliases for\n         * the same curve, we prefer the SECP nid when matching explicit\n         * parameters as that is associated with a specialized EC_METHOD.\n         *\/\n        if (curve_name == NID_wap_wsg_idm_ecid_wtls12)\n            curve_name = NID_secp224r1;\n#endif \/* !def(OPENSSL_NO_EC_NISTP_64_GCC_128) *\/\n\n        if ((named_group = EC_GROUP_new_by_curve_name(curve_name)) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n            goto err;\n        }\n        EC_GROUP_free(ret);\n        ret = named_group;\n\n        \/*\n         * Set the flag so that EC_GROUPs created from explicit parameters are\n         * serialized using explicit parameters by default.\n         *\/\n        EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_EXPLICIT_CURVE);\n\n        \/*\n         * If the input params do not contain the optional seed field we make\n         * sure it is not added to the returned group.\n         *\n         * The seed field is not really used inside libcrypto anyway, and\n         * adding it to parsed explicit parameter keys would alter their DER\n         * encoding output (because of the extra field) which could impact\n         * applications fingerprinting keys by their DER encoding.\n         *\/\n        if (params->curve->seed == NULL) {\n            if (EC_GROUP_set_seed(ret, NULL, 0) != 1)\n                goto err;\n        }\n    }\n\n    ok = 1;\n\n err:\n    if (!ok) {\n        EC_GROUP_free(ret);\n        ret = NULL;\n    }\n    EC_GROUP_free(dup);\n\n    BN_free(p);\n    BN_free(a);\n    BN_free(b);\n    EC_POINT_free(point);\n\n    BN_CTX_free(ctx);\n\n    return ret;\n}","target":1,"code_token_length":2828,"total_token_length":3064,"max_tokens_setting":4096}
+{"idx":198010,"func":"static int string_scan_range(RList *list, RBinFile *bf, int min,\n\t\t\t      const ut64 from, const ut64 to, int type, int raw, RBinSection *section) {\n\tRBin *bin = bf->rbin;\n\tut8 tmp[R_STRING_SCAN_BUFFER_SIZE];\n\tut64 str_start, needle = from;\n\tint count = 0, i, rc, runes;\n\tint str_type = R_STRING_TYPE_DETECT;\n\n\t\/\/ if list is null it means its gonna dump\n\tr_return_val_if_fail (bf, -1);\n\n\tif (type == -1) {\n\t\ttype = R_STRING_TYPE_DETECT;\n\t}\n\tif (from == to) {\n\t\treturn 0;\n\t}\n\tif (from > to) {\n\t\teprintf (\"Invalid range to find strings 0x%\"PFMT64x\" .. 0x%\"PFMT64x\"\\n\", from, to);\n\t\treturn -1;\n\t}\n\tst64 len = (st64)(to - from);\n\tif (len < 1 || len > ST32_MAX) {\n\t\teprintf (\"String scan range is invalid (%\"PFMT64d\" bytes)\\n\", len);\n\t\treturn -1;\n\t}\n\tut8 *buf = calloc (len, 1);\n\tif (!buf || !min) {\n\t\tfree (buf);\n\t\treturn -1;\n\t}\n\tst64 vdelta = 0, pdelta = 0;\n\tRBinSection *s = NULL;\n\tbool ascii_only = false;\n\tPJ *pj = NULL;\n\tif (bf->strmode == R_MODE_JSON && !list) {\n\t\tpj = pj_new ();\n\t\tif (pj) {\n\t\t\tpj_a (pj);\n\t\t}\n\t}\n\tr_buf_read_at (bf->buf, from, buf, len);\n\tchar *charset = r_sys_getenv (\"RABIN2_CHARSET\");\n\tif (!R_STR_ISEMPTY (charset)) {\n\t\tRCharset *ch = r_charset_new ();\n\t\tif (r_charset_use (ch, charset)) {\n\t\t\tint outlen = len * 4;\n\t\t\tut8 *out = calloc (len, 4);\n\t\t\tif (out) {\n\t\t\t\tint res = r_charset_encode_str (ch, out, outlen, buf, len);\n\t\t\t\tint i;\n\t\t\t\t\/\/ TODO unknown chars should be translated to null bytes\n\t\t\t\tfor (i = 0; i < res; i++) {\n\t\t\t\t\tif (out[i] == '?') {\n\t\t\t\t\t\tout[i] = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlen = res;\n\t\t\t\tfree (buf);\n\t\t\t\tbuf = out;\n\t\t\t} else {\n\t\t\t\teprintf (\"Cannot allocate\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\teprintf (\"Invalid value for RABIN2_CHARSET.\\n\");\n\t\t}\n\t\tr_charset_free (ch);\n\t}\n\tfree (charset);\n\tRConsIsBreaked is_breaked = (bin && bin->consb.is_breaked)? bin->consb.is_breaked: NULL;\n\t\/\/ may oobread\n\twhile (needle < to) {\n\t\tif (is_breaked && is_breaked ()) {\n\t\t\tbreak;\n\t\t}\n\t\t\/\/ smol optimization\n\t\tif (needle + 4 < to) {\n\t\t\tut32 n1 = r_read_le32 (buf + needle - from);\n\t\t\tif (!n1) {\n\t\t\t\tneedle += 4;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\trc = r_utf8_decode (buf + needle - from, to - needle, NULL);\n\t\tif (!rc) {\n\t\t\tneedle++;\n\t\t\tcontinue;\n\t\t}\n\t\tbool addr_aligned = !(needle % 4);\n\n\t\tif (type == R_STRING_TYPE_DETECT) {\n\t\t\tchar *w = (char *)buf + needle + rc - from;\n\t\t\tif (((to - needle) > 8 + rc)) {\n\t\t\t\t\/\/ TODO: support le and be\n\t\t\t\tbool is_wide32le = (needle + rc + 2 < to) && (!w[0] && !w[1] && !w[2] && w[3] && !w[4]);\n\t\t\t\t\/\/ reduce false positives\n\t\t\t\tif (is_wide32le) {\n\t\t\t\t\tif (!w[5] && !w[6] && w[7] && w[8]) {\n\t\t\t\t\t\tis_wide32le = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!addr_aligned) {\n\t\t\t\t\tis_wide32le = false;\n\t\t\t\t}\n\t\t\t\t\/\/\/is_wide32be &= (n1 < 0xff && n11 < 0xff); \/\/ false; \/\/ n11 < 0xff;\n\t\t\t\tif (is_wide32le  && addr_aligned) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_WIDE32; \/\/ asume big endian,is there little endian w32?\n\t\t\t\t} else {\n\t\t\t\t\t\/\/ bool is_wide = (n1 && n2 && n1 < 0xff && (!n2 || n2 < 0xff));\n\t\t\t\t\tbool is_wide = needle + rc + 4 < to && !w[0] && w[1] && !w[2] && w[3] && !w[4];\n\t\t\t\t\tstr_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8; \/\/ could be charset if set :?\n\t\t\t\t} else {\n\t\t\t\t\tstr_type = R_STRING_TYPE_ASCII;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (type == R_STRING_TYPE_UTF8) {\n\t\t\tstr_type = R_STRING_TYPE_ASCII; \/\/ initial assumption\n\t\t} else {\n\t\t\tstr_type = type;\n\t\t}\n\t\trunes = 0;\n\t\tstr_start = needle;\n\n\t\t\/* Eat a whole C string *\/\n\t\tfor (i = 0; i < sizeof (tmp) - 4 && needle < to; i += rc) {\n\t\t\tRRune r = {0};\n\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\trc = r_utf32le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc) {\n\t\t\t\t\trc = 4;\n\t\t\t\t}\n\t\t\t} else if (str_type == R_STRING_TYPE_WIDE) {\n\t\t\t\trc = r_utf16le_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc == 1) {\n\t\t\t\t\trc = 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trc = r_utf8_decode (buf + needle - from, to - needle, &r);\n\t\t\t\tif (rc > 1) {\n\t\t\t\t\tstr_type = R_STRING_TYPE_UTF8;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/* Invalid sequence detected *\/\n\t\t\tif (!rc || (ascii_only && r > 0x7f)) {\n\t\t\t\tneedle++;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tneedle += rc;\n\n\t\t\tif (r_isprint (r) && r != '\\\\') {\n\t\t\t\tif (str_type == R_STRING_TYPE_WIDE32) {\n\t\t\t\t\tif (r == 0xff) {\n\t\t\t\t\t\tr = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trc = r_utf8_encode (tmp + i, r);\n\t\t\t\trunes++;\n\t\t\t\t\/* Print the escape code *\/\n\t\t\t} else if (r && r < 0x100 && strchr (\"\\b\\v\\f\\n\\r\\t\\a\\033\\\\\", (char)r)) {\n\t\t\t\tif ((i + 32) < sizeof (tmp) && r < 93) {\n\t\t\t\t\ttmp[i + 0] = '\\\\';\n\t\t\t\t\ttmp[i + 1] = \"       abtnvfr             e  \"\n\t\t\t\t\t             \"                              \"\n\t\t\t\t\t             \"                              \"\n\t\t\t\t\t             \"  \\\\\"[r];\n\t\t\t\t} else {\n\t\t\t\t\t\/\/ string too long\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\trc = 2;\n\t\t\t\trunes++;\n\t\t\t} else {\n\t\t\t\t\/* \\0 marks the end of C-strings *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\ttmp[i++] = '\\0';\n\n\t\tif (runes < min && runes >= 2 && str_type == R_STRING_TYPE_ASCII && needle < to) {\n\t\t\t\/\/ back up past the \\0 to the last char just in case it starts a wide string\n\t\t\tneedle -= 2;\n\t\t}\n\t\tif (runes >= min) {\n\t\t\t\/\/ reduce false positives\n\t\t\tint j, num_blocks, *block_list;\n\t\t\tint *freq_list = NULL, expected_ascii, actual_ascii, num_chars;\n\t\t\tif (str_type == R_STRING_TYPE_ASCII) {\n\t\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\t\tchar ch = tmp[j];\n\t\t\t\t\tif (ch != '\\n' && ch != '\\r' && ch != '\\t') {\n\t\t\t\t\t\tif (!IS_PRINTABLE (tmp[j])) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (str_type) {\n\t\t\tcase R_STRING_TYPE_UTF8:\n\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\tnum_blocks = 0;\n\t\t\t\tblock_list = r_utf_block_list ((const ut8*)tmp, i - 1,\n\t\t\t\t\t\tstr_type == R_STRING_TYPE_WIDE? &freq_list: NULL);\n\t\t\t\tif (block_list) {\n\t\t\t\t\tfor (j = 0; block_list[j] != -1; j++) {\n\t\t\t\t\t\tnum_blocks++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (freq_list) {\n\t\t\t\t\tnum_chars = 0;\n\t\t\t\t\tactual_ascii = 0;\n\t\t\t\t\tfor (j = 0; freq_list[j] != -1; j++) {\n\t\t\t\t\t\tnum_chars += freq_list[j];\n\t\t\t\t\t\tif (!block_list[j]) { \/\/ ASCII\n\t\t\t\t\t\t\tactual_ascii = freq_list[j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfree (freq_list);\n\t\t\t\t\texpected_ascii = num_blocks ? num_chars \/ num_blocks : 0;\n\t\t\t\t\tif (actual_ascii > expected_ascii) {\n\t\t\t\t\t\tascii_only = true;\n\t\t\t\t\t\tneedle = str_start;\n\t\t\t\t\t\tfree (block_list);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfree (block_list);\n\t\t\t\tif (num_blocks > R_STRING_MAX_UNI_BLOCKS) {\n\t\t\t\t\tneedle++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tRBinString *bs = R_NEW0 (RBinString);\n\t\t\tif (!bs) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbs->type = str_type;\n\t\t\tbs->length = runes;\n\t\t\tbs->size = needle - str_start;\n\t\t\tbs->ordinal = count++;\n\t\t\t\/\/ TODO: move into adjust_offset\n\t\t\tswitch (str_type) {\n\t\t\tcase R_STRING_TYPE_WIDE:\n\t\t\t\tif (str_start - from > 1) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 2 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 2; \/\/ \\xff\\xfe\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_STRING_TYPE_WIDE32:\n\t\t\t\tif (str_start - from > 3) {\n\t\t\t\t\tconst ut8 *p = buf + str_start - 4 - from;\n\t\t\t\t\tif (p[0] == 0xff && p[1] == 0xfe) {\n\t\t\t\t\t\tstr_start -= 4; \/\/ \\xff\\xfe\\x00\\x00\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!s) {\n\t\t\t\tif (section) {\n\t\t\t\t\ts = section;\n\t\t\t\t} else if (bf->o) {\n\t\t\t\t\ts = r_bin_get_section_at (bf->o, str_start, false);\n\t\t\t\t}\n\t\t\t\tif (s) {\n\t\t\t\t\tvdelta = s->vaddr;\n\t\t\t\t\tpdelta = s->paddr;\n\t\t\t\t}\n\t\t\t}\n\t\t\tut64 baddr = bf->loadaddr && bf->o? bf->o->baddr: bf->loadaddr;\n\t\t\tbs->paddr = str_start + baddr;\n\t\t\tbs->vaddr = str_start - pdelta + vdelta + baddr;\n\t\t\tbs->string = r_str_ndup ((const char *)tmp, i);\n\t\t\tif (list) {\n\t\t\t\tr_list_append (list, bs);\n\t\t\t\tif (bf->o) {\n\t\t\t\t\tht_up_insert (bf->o->strings_db, bs->vaddr, bs);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprint_string (bf, bs, raw, pj);\n\t\t\t\tr_bin_string_free (bs);\n\t\t\t}\n\t\t\tif (from == 0 && to == bf->size) {\n\t\t\t\t\/* force lookup section at the next one *\/\n\t\t\t\ts = NULL;\n\t\t\t}\n\t\t}\n\t\tascii_only = false;\n\t}\n\tfree (buf);\n\tif (pj) {\n\t\tpj_end (pj);\n\t\tif (bin) {\n\t\t\tRIO *io = bin->iob.io;\n\t\t\tif (io) {\n\t\t\t\tio->cb_printf (\"%s\", pj_string (pj));\n\t\t\t}\n\t\t}\n\t\tpj_free (pj);\n\t}\n\treturn count;\n}","target":1,"code_token_length":2792,"total_token_length":3028,"max_tokens_setting":4096}
+{"idx":279950,"func":"do_filter(\n    linenr_T\tline1,\n    linenr_T\tline2,\n    exarg_T\t*eap,\t\t\/\/ for forced 'ff' and 'fenc'\n    char_u\t*cmd,\n    int\t\tdo_in,\n    int\t\tdo_out)\n{\n    char_u\t*itmp = NULL;\n    char_u\t*otmp = NULL;\n    linenr_T\tlinecount;\n    linenr_T\tread_linecount;\n    pos_T\tcursor_save;\n    char_u\t*cmd_buf;\n    buf_T\t*old_curbuf = curbuf;\n    int\t\tshell_flags = 0;\n    pos_T\torig_start = curbuf->b_op_start;\n    pos_T\torig_end = curbuf->b_op_end;\n    int\t\tsave_cmod_flags = cmdmod.cmod_flags;\n#ifdef FEAT_FILTERPIPE\n    int\t\tstmp = p_stmp;\n#endif\n\n    if (*cmd == NUL)\t    \/\/ no filter command\n\treturn;\n\n    \/\/ Temporarily disable lockmarks since that's needed to propagate changed\n    \/\/ regions of the buffer for foldUpdate(), linecount, etc.\n    cmdmod.cmod_flags &= ~CMOD_LOCKMARKS;\n\n    cursor_save = curwin->w_cursor;\n    linecount = line2 - line1 + 1;\n    curwin->w_cursor.lnum = line1;\n    curwin->w_cursor.col = 0;\n    changed_line_abv_curs();\n    invalidate_botline();\n\n    \/*\n     * When using temp files:\n     * 1. * Form temp file names\n     * 2. * Write the lines to a temp file\n     * 3.   Run the filter command on the temp file\n     * 4. * Read the output of the command into the buffer\n     * 5. * Delete the original lines to be filtered\n     * 6. * Remove the temp files\n     *\n     * When writing the input with a pipe or when catching the output with a\n     * pipe only need to do 3.\n     *\/\n\n    if (do_out)\n\tshell_flags |= SHELL_DOOUT;\n\n#ifdef FEAT_FILTERPIPE\n# ifdef VIMDLL\n    if (!gui.in_use && !gui.starting)\n\tstmp = 1;   \/\/ Console mode doesn't support filterpipe.\n# endif\n\n    if (!do_in && do_out && !stmp)\n    {\n\t\/\/ Use a pipe to fetch stdout of the command, do not use a temp file.\n\tshell_flags |= SHELL_READ;\n\tcurwin->w_cursor.lnum = line2;\n    }\n    else if (do_in && !do_out && !stmp)\n    {\n\t\/\/ Use a pipe to write stdin of the command, do not use a temp file.\n\tshell_flags |= SHELL_WRITE;\n\tcurbuf->b_op_start.lnum = line1;\n\tcurbuf->b_op_end.lnum = line2;\n    }\n    else if (do_in && do_out && !stmp)\n    {\n\t\/\/ Use a pipe to write stdin and fetch stdout of the command, do not\n\t\/\/ use a temp file.\n\tshell_flags |= SHELL_READ|SHELL_WRITE;\n\tcurbuf->b_op_start.lnum = line1;\n\tcurbuf->b_op_end.lnum = line2;\n\tcurwin->w_cursor.lnum = line2;\n    }\n    else\n#endif\n\tif ((do_in && (itmp = vim_tempname('i', FALSE)) == NULL)\n\t\t|| (do_out && (otmp = vim_tempname('o', FALSE)) == NULL))\n\t{\n\t    emsg(_(e_cant_get_temp_file_name));\n\t    goto filterend;\n\t}\n\n\/*\n * The writing and reading of temp files will not be shown.\n * Vi also doesn't do this and the messages are not very informative.\n *\/\n    ++no_wait_return;\t\t\/\/ don't call wait_return() while busy\n    if (itmp != NULL && buf_write(curbuf, itmp, NULL, line1, line2, eap,\n\t\t\t\t\t   FALSE, FALSE, FALSE, TRUE) == FAIL)\n    {\n\tmsg_putchar('\\n');\t\t\/\/ keep message from buf_write()\n\t--no_wait_return;\n#if defined(FEAT_EVAL)\n\tif (!aborting())\n#endif\n\t    (void)semsg(_(e_cant_create_file_str), itmp);\t\/\/ will call wait_return\n\tgoto filterend;\n    }\n    if (curbuf != old_curbuf)\n\tgoto filterend;\n\n    if (!do_out)\n\tmsg_putchar('\\n');\n\n    \/\/ Create the shell command in allocated memory.\n    cmd_buf = make_filter_cmd(cmd, itmp, otmp);\n    if (cmd_buf == NULL)\n\tgoto filterend;\n\n    windgoto((int)Rows - 1, 0);\n    cursor_on();\n\n    \/*\n     * When not redirecting the output the command can write anything to the\n     * screen. If 'shellredir' is equal to \">\", screen may be messed up by\n     * stderr output of external command. Clear the screen later.\n     * If do_in is FALSE, this could be something like \":r !cat\", which may\n     * also mess up the screen, clear it later.\n     *\/\n    if (!do_out || STRCMP(p_srr, \">\") == 0 || !do_in)\n\tredraw_later_clear();\n\n    if (do_out)\n    {\n\tif (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL)\n\t{\n\t    vim_free(cmd_buf);\n\t    goto error;\n\t}\n\tredraw_curbuf_later(VALID);\n    }\n    read_linecount = curbuf->b_ml.ml_line_count;\n\n    \/*\n     * When call_shell() fails wait_return() is called to give the user a\n     * chance to read the error messages. Otherwise errors are ignored, so you\n     * can see the error messages from the command that appear on stdout; use\n     * 'u' to fix the text\n     * Switch to cooked mode when not redirecting stdin, avoids that something\n     * like \":r !cat\" hangs.\n     * Pass on the SHELL_DOOUT flag when the output is being redirected.\n     *\/\n    if (call_shell(cmd_buf, SHELL_FILTER | SHELL_COOKED | shell_flags))\n    {\n\tredraw_later_clear();\n\twait_return(FALSE);\n    }\n    vim_free(cmd_buf);\n\n    did_check_timestamps = FALSE;\n    need_check_timestamps = TRUE;\n\n    \/\/ When interrupting the shell command, it may still have produced some\n    \/\/ useful output.  Reset got_int here, so that readfile() won't cancel\n    \/\/ reading.\n    ui_breakcheck();\n    got_int = FALSE;\n\n    if (do_out)\n    {\n\tif (otmp != NULL)\n\t{\n\t    if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM,\n\t\t\t\t\t\t    eap, READ_FILTER) != OK)\n\t    {\n#if defined(FEAT_EVAL)\n\t\tif (!aborting())\n#endif\n\t\t{\n\t\t    msg_putchar('\\n');\n\t\t    semsg(_(e_cant_read_file_str), otmp);\n\t\t}\n\t\tgoto error;\n\t    }\n\t    if (curbuf != old_curbuf)\n\t\tgoto filterend;\n\t}\n\n\tread_linecount = curbuf->b_ml.ml_line_count - read_linecount;\n\n\tif (shell_flags & SHELL_READ)\n\t{\n\t    curbuf->b_op_start.lnum = line2 + 1;\n\t    curbuf->b_op_end.lnum = curwin->w_cursor.lnum;\n\t    appended_lines_mark(line2, read_linecount);\n\t}\n\n\tif (do_in)\n\t{\n\t    if ((cmdmod.cmod_flags & CMOD_KEEPMARKS)\n\t\t\t\t     || vim_strchr(p_cpo, CPO_REMMARK) == NULL)\n\t    {\n\t\tif (read_linecount >= linecount)\n\t\t    \/\/ move all marks from old lines to new lines\n\t\t    mark_adjust(line1, line2, linecount, 0L);\n\t\telse if (save_cmod_flags & CMOD_LOCKMARKS)\n\t\t{\n\t\t    \/\/ Move marks from the lines below the new lines down by\n\t\t    \/\/ the number of lines lost.\n\t\t    \/\/ Move marks from the lines that will be deleted to the\n\t\t    \/\/ new lines and below.\n\t\t    mark_adjust(line2 + 1, (linenr_T)MAXLNUM,\n\t\t\t\t\t       linecount - read_linecount, 0L);\n\t\t    mark_adjust(line1, line2, linecount, 0L);\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ move marks from old lines to new lines, delete marks\n\t\t    \/\/ that are in deleted lines\n\t\t    mark_adjust(line1, line1 + read_linecount - 1,\n\t\t\t\t\t\t\t\tlinecount, 0L);\n\t\t    mark_adjust(line1 + read_linecount, line2, MAXLNUM, 0L);\n\t\t}\n\t    }\n\n\t    \/*\n\t     * Put cursor on first filtered line for \":range!cmd\".\n\t     * Adjust '[ and '] (set by buf_write()).\n\t     *\/\n\t    curwin->w_cursor.lnum = line1;\n\t    del_lines(linecount, TRUE);\n\t    curbuf->b_op_start.lnum -= linecount;\t\/\/ adjust '[\n\t    curbuf->b_op_end.lnum -= linecount;\t\t\/\/ adjust ']\n\t    write_lnum_adjust(-linecount);\t\t\/\/ adjust last line\n\t\t\t\t\t\t\t\/\/ for next write\n#ifdef FEAT_FOLDING\n\t    foldUpdate(curwin, curbuf->b_op_start.lnum, curbuf->b_op_end.lnum);\n#endif\n\t}\n\telse\n\t{\n\t    \/*\n\t     * Put cursor on last new line for \":r !cmd\".\n\t     *\/\n\t    linecount = curbuf->b_op_end.lnum - curbuf->b_op_start.lnum + 1;\n\t    curwin->w_cursor.lnum = curbuf->b_op_end.lnum;\n\t}\n\n\tbeginline(BL_WHITE | BL_FIX);\t    \/\/ cursor on first non-blank\n\t--no_wait_return;\n\n\tif (linecount > p_report)\n\t{\n\t    if (do_in)\n\t    {\n\t\tvim_snprintf(msg_buf, sizeof(msg_buf),\n\t\t\t\t    _(\"%ld lines filtered\"), (long)linecount);\n\t\tif (msg(msg_buf) && !msg_scroll)\n\t\t    \/\/ save message to display it after redraw\n\t\t    set_keep_msg((char_u *)msg_buf, 0);\n\t    }\n\t    else\n\t\tmsgmore((long)linecount);\n\t}\n    }\n    else\n    {\nerror:\n\t\/\/ put cursor back in same position for \":w !cmd\"\n\tcurwin->w_cursor = cursor_save;\n\t--no_wait_return;\n\twait_return(FALSE);\n    }\n\nfilterend:\n\n    cmdmod.cmod_flags = save_cmod_flags;\n    if (curbuf != old_curbuf)\n    {\n\t--no_wait_return;\n\temsg(_(e_filter_autocommands_must_not_change_current_buffer));\n    }\n    else if (cmdmod.cmod_flags & CMOD_LOCKMARKS)\n    {\n\tcurbuf->b_op_start = orig_start;\n\tcurbuf->b_op_end = orig_end;\n    }\n\n    if (itmp != NULL)\n\tmch_remove(itmp);\n    if (otmp != NULL)\n\tmch_remove(otmp);\n    vim_free(itmp);\n    vim_free(otmp);\n}","target":0,"code_token_length":2400,"total_token_length":2636,"max_tokens_setting":4096}
+{"idx":211839,"func":"do_buffer_ext(\n    int\t\taction,\n    int\t\tstart,\n    int\t\tdir,\t\t\/\/ FORWARD or BACKWARD\n    int\t\tcount,\t\t\/\/ buffer number or number of buffers\n    int\t\tflags)\t\t\/\/ DOBUF_FORCEIT etc.\n{\n    buf_T\t*buf;\n    buf_T\t*bp;\n    int\t\tunload = (action == DOBUF_UNLOAD || action == DOBUF_DEL\n\t\t\t|| action == DOBUF_WIPE || action == DOBUF_WIPE_REUSE);\n\n    switch (start)\n    {\n\tcase DOBUF_FIRST:   buf = firstbuf; break;\n\tcase DOBUF_LAST:    buf = lastbuf;  break;\n\tdefault:\t    buf = curbuf;   break;\n    }\n    if (start == DOBUF_MOD)\t    \/\/ find next modified buffer\n    {\n\twhile (count-- > 0)\n\t{\n\t    do\n\t    {\n\t\tbuf = buf->b_next;\n\t\tif (buf == NULL)\n\t\t    buf = firstbuf;\n\t    }\n\t    while (buf != curbuf && !bufIsChanged(buf));\n\t}\n\tif (!bufIsChanged(buf))\n\t{\n\t    emsg(_(e_no_modified_buffer_found));\n\t    return FAIL;\n\t}\n    }\n    else if (start == DOBUF_FIRST && count) \/\/ find specified buffer number\n    {\n\twhile (buf != NULL && buf->b_fnum != count)\n\t    buf = buf->b_next;\n    }\n    else\n    {\n\tbp = NULL;\n\twhile (count > 0 || (!unload && !buf->b_p_bl && bp != buf))\n\t{\n\t    \/\/ remember the buffer where we start, we come back there when all\n\t    \/\/ buffers are unlisted.\n\t    if (bp == NULL)\n\t\tbp = buf;\n\t    if (dir == FORWARD)\n\t    {\n\t\tbuf = buf->b_next;\n\t\tif (buf == NULL)\n\t\t    buf = firstbuf;\n\t    }\n\t    else\n\t    {\n\t\tbuf = buf->b_prev;\n\t\tif (buf == NULL)\n\t\t    buf = lastbuf;\n\t    }\n\t    \/\/ don't count unlisted buffers\n\t    if (unload || buf->b_p_bl)\n\t    {\n\t\t --count;\n\t\t bp = NULL;\t\/\/ use this buffer as new starting point\n\t    }\n\t    if (bp == buf)\n\t    {\n\t\t\/\/ back where we started, didn't find anything.\n\t\temsg(_(e_there_is_no_listed_buffer));\n\t\treturn FAIL;\n\t    }\n\t}\n    }\n\n    if (buf == NULL)\t    \/\/ could not find it\n    {\n\tif (start == DOBUF_FIRST)\n\t{\n\t    \/\/ don't warn when deleting\n\t    if (!unload)\n\t\tsemsg(_(e_buffer_nr_does_not_exist), count);\n\t}\n\telse if (dir == FORWARD)\n\t    emsg(_(e_cannot_go_beyond_last_buffer));\n\telse\n\t    emsg(_(e_cannot_go_before_first_buffer));\n\treturn FAIL;\n    }\n#ifdef FEAT_PROP_POPUP\n    if ((flags & DOBUF_NOPOPUP) && bt_popup(buf)\n# ifdef FEAT_TERMINAL\n\t\t\t\t&& !bt_terminal(buf)\n#endif\n       )\n\treturn OK;\n#endif\n\n#ifdef FEAT_GUI\n    need_mouse_correct = TRUE;\n#endif\n\n    \/*\n     * delete buffer \"buf\" from memory and\/or the list\n     *\/\n    if (unload)\n    {\n\tint\tforward;\n\tbufref_T bufref;\n\n\tif (!can_unload_buffer(buf))\n\t    return FAIL;\n\n\tset_bufref(&bufref, buf);\n\n\t\/\/ When unloading or deleting a buffer that's already unloaded and\n\t\/\/ unlisted: fail silently.\n\tif (action != DOBUF_WIPE && action != DOBUF_WIPE_REUSE\n\t\t\t\t   && buf->b_ml.ml_mfp == NULL && !buf->b_p_bl)\n\t    return FAIL;\n\n\tif ((flags & DOBUF_FORCEIT) == 0 && bufIsChanged(buf))\n\t{\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\t    if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)\n\t    {\n\t\tdialog_changed(buf, FALSE);\n\t\tif (!bufref_valid(&bufref))\n\t\t    \/\/ Autocommand deleted buffer, oops!  It's not changed\n\t\t    \/\/ now.\n\t\t    return FAIL;\n\t\t\/\/ If it's still changed fail silently, the dialog already\n\t\t\/\/ mentioned why it fails.\n\t\tif (bufIsChanged(buf))\n\t\t    return FAIL;\n\t    }\n\t    else\n#endif\n\t    {\n\t\tsemsg(_(e_no_write_since_last_change_for_buffer_nr_add_bang_to_override),\n\t\t\t\t\t\t\t\t buf->b_fnum);\n\t\treturn FAIL;\n\t    }\n\t}\n\n\t\/\/ When closing the current buffer stop Visual mode.\n\tif (buf == curbuf && VIsual_active)\n\t    end_visual_mode();\n\n\t\/\/ If deleting the last (listed) buffer, make it empty.\n\t\/\/ The last (listed) buffer cannot be unloaded.\n\tFOR_ALL_BUFFERS(bp)\n\t    if (bp->b_p_bl && bp != buf)\n\t\tbreak;\n\tif (bp == NULL && buf == curbuf)\n\t    return empty_curbuf(TRUE, (flags & DOBUF_FORCEIT), action);\n\n\t\/\/ If the deleted buffer is the current one, close the current window\n\t\/\/ (unless it's the only window).  Repeat this so long as we end up in\n\t\/\/ a window with this buffer.\n\twhile (buf == curbuf\n\t\t   && !(curwin->w_closing || curwin->w_buffer->b_locked > 0)\n\t\t   && (!ONE_WINDOW || first_tabpage->tp_next != NULL))\n\t{\n\t    if (win_close(curwin, FALSE) == FAIL)\n\t\tbreak;\n\t}\n\n\t\/\/ If the buffer to be deleted is not the current one, delete it here.\n\tif (buf != curbuf)\n\t{\n\t    close_windows(buf, FALSE);\n\t    if (buf != curbuf && bufref_valid(&bufref) && buf->b_nwindows <= 0)\n\t\t    close_buffer(NULL, buf, action, FALSE, FALSE);\n\t    return OK;\n\t}\n\n\t\/*\n\t * Deleting the current buffer: Need to find another buffer to go to.\n\t * There should be another, otherwise it would have been handled\n\t * above.  However, autocommands may have deleted all buffers.\n\t * First use au_new_curbuf.br_buf, if it is valid.\n\t * Then prefer the buffer we most recently visited.\n\t * Else try to find one that is loaded, after the current buffer,\n\t * then before the current buffer.\n\t * Finally use any buffer.\n\t *\/\n\tbuf = NULL;\t\/\/ selected buffer\n\tbp = NULL;\t\/\/ used when no loaded buffer found\n\tif (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf))\n\t    buf = au_new_curbuf.br_buf;\n\telse if (curwin->w_jumplistlen > 0)\n\t{\n\t    int     jumpidx;\n\n\t    jumpidx = curwin->w_jumplistidx - 1;\n\t    if (jumpidx < 0)\n\t\tjumpidx = curwin->w_jumplistlen - 1;\n\n\t    forward = jumpidx;\n\t    while (jumpidx != curwin->w_jumplistidx)\n\t    {\n\t\tbuf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);\n\t\tif (buf != NULL)\n\t\t{\n\t\t    if (buf == curbuf || !buf->b_p_bl)\n\t\t\tbuf = NULL;\t\/\/ skip current and unlisted bufs\n\t\t    else if (buf->b_ml.ml_mfp == NULL)\n\t\t    {\n\t\t\t\/\/ skip unloaded buf, but may keep it for later\n\t\t\tif (bp == NULL)\n\t\t\t    bp = buf;\n\t\t\tbuf = NULL;\n\t\t    }\n\t\t}\n\t\tif (buf != NULL)   \/\/ found a valid buffer: stop searching\n\t\t    break;\n\t\t\/\/ advance to older entry in jump list\n\t\tif (!jumpidx && curwin->w_jumplistidx == curwin->w_jumplistlen)\n\t\t    break;\n\t\tif (--jumpidx < 0)\n\t\t    jumpidx = curwin->w_jumplistlen - 1;\n\t\tif (jumpidx == forward)\t\t\/\/ List exhausted for sure\n\t\t    break;\n\t    }\n\t}\n\n\tif (buf == NULL)\t\/\/ No previous buffer, Try 2'nd approach\n\t{\n\t    forward = TRUE;\n\t    buf = curbuf->b_next;\n\t    for (;;)\n\t    {\n\t\tif (buf == NULL)\n\t\t{\n\t\t    if (!forward)\t\/\/ tried both directions\n\t\t\tbreak;\n\t\t    buf = curbuf->b_prev;\n\t\t    forward = FALSE;\n\t\t    continue;\n\t\t}\n\t\t\/\/ in non-help buffer, try to skip help buffers, and vv\n\t\tif (buf->b_help == curbuf->b_help && buf->b_p_bl)\n\t\t{\n\t\t    if (buf->b_ml.ml_mfp != NULL)   \/\/ found loaded buffer\n\t\t\tbreak;\n\t\t    if (bp == NULL)\t\/\/ remember unloaded buf for later\n\t\t\tbp = buf;\n\t\t}\n\t\tif (forward)\n\t\t    buf = buf->b_next;\n\t\telse\n\t\t    buf = buf->b_prev;\n\t    }\n\t}\n\tif (buf == NULL)\t\/\/ No loaded buffer, use unloaded one\n\t    buf = bp;\n\tif (buf == NULL)\t\/\/ No loaded buffer, find listed one\n\t{\n\t    FOR_ALL_BUFFERS(buf)\n\t\tif (buf->b_p_bl && buf != curbuf)\n\t\t    break;\n\t}\n\tif (buf == NULL)\t\/\/ Still no buffer, just take one\n\t{\n\t    if (curbuf->b_next != NULL)\n\t\tbuf = curbuf->b_next;\n\t    else\n\t\tbuf = curbuf->b_prev;\n\t}\n    }\n\n    if (buf == NULL)\n    {\n\t\/\/ Autocommands must have wiped out all other buffers.  Only option\n\t\/\/ now is to make the current buffer empty.\n\treturn empty_curbuf(FALSE, (flags & DOBUF_FORCEIT), action);\n    }\n\n    \/*\n     * make \"buf\" the current buffer\n     *\/\n    if (action == DOBUF_SPLIT)\t    \/\/ split window first\n    {\n\t\/\/ If 'switchbuf' contains \"useopen\": jump to first window containing\n\t\/\/ \"buf\" if one exists\n\tif ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf))\n\t    return OK;\n\t\/\/ If 'switchbuf' contains \"usetab\": jump to first window in any tab\n\t\/\/ page containing \"buf\" if one exists\n\tif ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf))\n\t    return OK;\n\tif (win_split(0, 0) == FAIL)\n\t    return FAIL;\n    }\n\n    \/\/ go to current buffer - nothing to do\n    if (buf == curbuf)\n\treturn OK;\n\n    \/\/ Check if the current buffer may be abandoned.\n    if (action == DOBUF_GOTO && !can_abandon(curbuf, (flags & DOBUF_FORCEIT)))\n    {\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\tif ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)\n\t{\n\t    bufref_T bufref;\n\n\t    set_bufref(&bufref, buf);\n\t    dialog_changed(curbuf, FALSE);\n\t    if (!bufref_valid(&bufref))\n\t\t\/\/ Autocommand deleted buffer, oops!\n\t\treturn FAIL;\n\t}\n\tif (bufIsChanged(curbuf))\n#endif\n\t{\n\t    no_write_message();\n\t    return FAIL;\n\t}\n    }\n\n    \/\/ Go to the other buffer.\n    set_curbuf(buf, action);\n\n    if (action == DOBUF_SPLIT)\n\tRESET_BINDING(curwin);\t\/\/ reset 'scrollbind' and 'cursorbind'\n\n#if defined(FEAT_EVAL)\n    if (aborting())\t    \/\/ autocmds may abort script processing\n\treturn FAIL;\n#endif\n\n    return OK;\n}","target":1,"code_token_length":2521,"total_token_length":2757,"max_tokens_setting":4096}
+{"idx":439096,"func":"static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define BitSet(byte,bit)  (((byte) & (bit)) == (bit))\n#define LSBFirstOrder(x,y)  (((y) << 8) | (x))\n#define ThrowGIFException(exception,message) \\\n{ \\\n  if (profiles != (LinkedListInfo *) NULL) \\\n    profiles=DestroyLinkedList(profiles,DestroyGIFProfile); \\\n  if (global_colormap != (unsigned char *) NULL) \\\n    global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap); \\\n  if (meta_image != (Image *) NULL) \\\n    meta_image=DestroyImage(meta_image); \\\n  ThrowReaderException((exception),(message)); \\\n}\n\n  Image\n    *image,\n    *meta_image;\n\n  LinkedListInfo\n    *profiles;\n\n  MagickBooleanType\n    status;\n\n  register ssize_t\n    i;\n\n  register unsigned char\n    *p;\n\n  size_t\n    duration,\n    global_colors,\n    image_count,\n    local_colors,\n    one;\n\n  ssize_t\n    count,\n    opacity;\n\n  unsigned char\n    background,\n    buffer[257],\n    c,\n    flag,\n    *global_colormap,\n    magick[12];\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Determine if this a GIF file.\n  *\/\n  count=ReadBlob(image,6,magick);\n  if ((count != 6) || ((LocaleNCompare((char *) magick,\"GIF87\",5) != 0) &&\n      (LocaleNCompare((char *) magick,\"GIF89\",5) != 0)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  (void) memset(buffer,0,sizeof(buffer));\n  meta_image=AcquireImage(image_info);  \/* metadata container *\/\n  meta_image->page.width=ReadBlobLSBShort(image);\n  meta_image->page.height=ReadBlobLSBShort(image);\n  flag=(unsigned char) ReadBlobByte(image);\n  background=(unsigned char) ReadBlobByte(image);\n  c=(unsigned char) ReadBlobByte(image);  \/* reserved *\/\n  profiles=(LinkedListInfo *) NULL;\n  one=1;\n  global_colors=one << (((size_t) flag & 0x07)+1);\n  global_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n    MagickMax(global_colors,256),3UL*sizeof(*global_colormap));\n  if (global_colormap == (unsigned char *) NULL)\n    ThrowGIFException(ResourceLimitError,\"MemoryAllocationFailed\");\n  (void) memset(global_colormap,0,3*MagickMax(global_colors,256)*\n    sizeof(*global_colormap));\n  if (BitSet((int) flag,0x80) != 0)\n    {\n      count=ReadBlob(image,(size_t) (3*global_colors),global_colormap);\n      if (count != (ssize_t) (3*global_colors))\n        ThrowGIFException(CorruptImageError,\"InsufficientImageDataInFile\");\n    }\n  duration=0;\n  opacity=(-1);\n  image_count=0;\n  for ( ; ; )\n  {\n    count=ReadBlob(image,1,&c);\n    if (count != 1)\n      break;\n    if (c == (unsigned char) ';')\n      break;  \/* terminator *\/\n    if (c == (unsigned char) '!')\n      {\n        \/*\n          GIF Extension block.\n        *\/\n        count=ReadBlob(image,1,&c);\n        if (count != 1)\n          ThrowGIFException(CorruptImageError,\"UnableToReadExtensionBlock\");\n        (void) memset(buffer,0,sizeof(buffer));\n        switch (c)\n        {\n          case 0xf9:\n          {\n            \/*\n              Read graphics control extension.\n            *\/\n            while (ReadBlobBlock(image,buffer) != 0) ;\n            meta_image->dispose=(DisposeType) ((buffer[0] >> 2) & 0x07);\n            meta_image->delay=((size_t) buffer[2] << 8) | buffer[1];\n            if ((ssize_t) (buffer[0] & 0x01) == 0x01)\n              opacity=(ssize_t) buffer[3];\n            break;\n          }\n          case 0xfe:\n          {\n            char\n              *comments;\n\n            size_t\n              length;\n\n            \/*\n              Read comment extension.\n            *\/\n            comments=AcquireString((char *) NULL);\n            for (length=0; ; length+=count)\n            {\n              count=ReadBlobBlock(image,buffer);\n              if (count == 0)\n                break;\n              buffer[count]='\\0';\n              (void) ConcatenateString(&comments,(const char *) buffer);\n            }\n            (void) SetImageProperty(meta_image,\"comment\",comments);\n            comments=DestroyString(comments);\n            break;\n          }\n          case 0xff:\n          {\n            MagickBooleanType\n              loop;\n\n            \/*\n              Read Netscape Loop extension.\n            *\/\n            loop=MagickFalse;\n            if (ReadBlobBlock(image,buffer) != 0)\n              loop=LocaleNCompare((char *) buffer,\"NETSCAPE2.0\",11) == 0 ?\n                MagickTrue : MagickFalse;\n            if (loop != MagickFalse)\n              while (ReadBlobBlock(image,buffer) != 0)\n              {\n                meta_image->iterations=((size_t) buffer[2] << 8) | buffer[1];\n                if (meta_image->iterations != 0)\n                  meta_image->iterations++;\n              }\n            else\n              {\n                char\n                  name[MaxTextExtent];\n\n                int\n                  block_length,\n                  info_length,\n                  reserved_length;\n\n                MagickBooleanType\n                  i8bim,\n                  icc,\n                  iptc,\n                  magick;\n\n                StringInfo\n                  *profile;\n\n                unsigned char\n                  *info;\n\n                \/*\n                  Store GIF application extension as a generic profile.\n                *\/\n                icc=LocaleNCompare((char *) buffer,\"ICCRGBG1012\",11) == 0 ?\n                  MagickTrue : MagickFalse;\n                magick=LocaleNCompare((char *) buffer,\"ImageMagick\",11) == 0 ?\n                  MagickTrue : MagickFalse;\n                i8bim=LocaleNCompare((char *) buffer,\"MGK8BIM0000\",11) == 0 ?\n                  MagickTrue : MagickFalse;\n                iptc=LocaleNCompare((char *) buffer,\"MGKIPTC0000\",11) == 0 ?\n                  MagickTrue : MagickFalse;\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"    Reading GIF application extension\");\n                info=(unsigned char *) AcquireQuantumMemory(255UL,\n                  sizeof(*info));\n                if (info == (unsigned char *) NULL)\n                  ThrowGIFException(ResourceLimitError,\n                    \"MemoryAllocationFailed\");\n                (void) memset(info,0,255UL*sizeof(*info));\n                reserved_length=255;\n                for (info_length=0; ; )\n                {\n                  block_length=(int) ReadBlobBlock(image,&info[info_length]);\n                  if (block_length == 0)\n                    break;\n                  info_length+=block_length;\n                  if (info_length > (reserved_length-255))\n                    {\n                      reserved_length+=4096;\n                      info=(unsigned char *) ResizeQuantumMemory(info,(size_t)\n                        reserved_length,sizeof(*info));\n                      if (info == (unsigned char *) NULL)\n                        {\n                          info=(unsigned char *) RelinquishMagickMemory(info);\n                          ThrowGIFException(ResourceLimitError,\n                            \"MemoryAllocationFailed\");\n                        }\n                    }\n                }\n                profile=BlobToStringInfo(info,(size_t) info_length);\n                if (profile == (StringInfo *) NULL)\n                  {\n                    info=(unsigned char *) RelinquishMagickMemory(info);\n                    ThrowGIFException(ResourceLimitError,\n                      \"MemoryAllocationFailed\");\n                  }\n                if (i8bim != MagickFalse)\n                  (void) CopyMagickString(name,\"8bim\",sizeof(name));\n                else if (icc != MagickFalse)\n                  (void) CopyMagickString(name,\"icc\",sizeof(name));\n                else if (iptc != MagickFalse)\n                  (void) CopyMagickString(name,\"iptc\",sizeof(name));\n                else if (magick != MagickFalse)\n                  {\n                    (void) CopyMagickString(name,\"magick\",sizeof(name));\n                    meta_image->gamma=StringToDouble((char *) info+6,\n                      (char **) NULL);\n                  }\n                else\n                  (void) FormatLocaleString(name,sizeof(name),\"gif:%.11s\",\n                    buffer);\n                info=(unsigned char *) RelinquishMagickMemory(info);\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"      profile name=%s\",name);\n                if (magick != MagickFalse)\n                  profile=DestroyStringInfo(profile);\n                else\n                  {\n                    if (profiles == (LinkedListInfo *) NULL)\n                      profiles=NewLinkedList(0);\n                    SetStringInfoName(profile,name);\n                    (void) AppendValueToLinkedList(profiles,profile);\n                  }\n              }\n            break;\n          }\n          default:\n          {\n            while (ReadBlobBlock(image,buffer) != 0) ;\n            break;\n          }\n        }\n      }\n    if (c != (unsigned char) ',')\n      continue;\n    if (image_count != 0)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n      }\n    image_count++;\n    \/*\n      Read image attributes.\n    *\/\n    meta_image->page.x=(ssize_t) ReadBlobLSBShort(image);\n    meta_image->page.y=(ssize_t) ReadBlobLSBShort(image);\n    meta_image->scene=image->scene;\n    (void) CloneImageProperties(image,meta_image);\n    DestroyImageProperties(meta_image);\n    image->storage_class=PseudoClass;\n    image->compression=LZWCompression;\n    image->columns=ReadBlobLSBShort(image);\n    image->rows=ReadBlobLSBShort(image);\n    image->depth=8;\n    flag=(unsigned char) ReadBlobByte(image);\n    image->interlace=BitSet((int) flag,0x40) != 0 ? GIFInterlace : NoInterlace;\n    local_colors=BitSet((int) flag,0x80) == 0 ? global_colors : one <<\n      ((size_t) (flag & 0x07)+1);\n    image->colors=local_colors;\n    if (opacity >= (ssize_t) image->colors)\n      image->colors=(size_t) (opacity+1);\n    image->ticks_per_second=100;\n    image->matte=opacity >= 0 ? MagickTrue : MagickFalse;\n    if ((image->columns == 0) || (image->rows == 0))\n      ThrowGIFException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    \/*\n      Inititialize colormap.\n    *\/\n    if (AcquireImageColormap(image,image->colors) == MagickFalse)\n      ThrowGIFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (BitSet((int) flag,0x80) == 0)\n      {\n        \/*\n          Use global colormap.\n        *\/\n        p=global_colormap;\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].red=ScaleCharToQuantum(*p++);\n          image->colormap[i].green=ScaleCharToQuantum(*p++);\n          image->colormap[i].blue=ScaleCharToQuantum(*p++);\n          if (i == opacity)\n            {\n              image->colormap[i].opacity=(Quantum) TransparentOpacity;\n              image->transparent_color=image->colormap[opacity];\n            }\n        }\n        image->background_color=image->colormap[MagickMin((ssize_t) background,\n          (ssize_t) image->colors-1)];\n      }\n    else\n      {\n        unsigned char\n          *colormap;\n\n        \/*\n          Read local colormap.\n        *\/\n        colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n          MagickMax(local_colors,256),3UL*sizeof(*colormap));\n        if (colormap == (unsigned char *) NULL)\n          ThrowGIFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(colormap,0,3*MagickMax(local_colors,256)*\n          sizeof(*colormap));\n        count=ReadBlob(image,(3*local_colors)*sizeof(*colormap),colormap);\n        if (count != (ssize_t) (3*local_colors))\n          {\n            colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n            ThrowGIFException(CorruptImageError,\"InsufficientImageDataInFile\");\n          }\n        p=colormap;\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].red=ScaleCharToQuantum(*p++);\n          image->colormap[i].green=ScaleCharToQuantum(*p++);\n          image->colormap[i].blue=ScaleCharToQuantum(*p++);\n          if (i == opacity)\n            image->colormap[i].opacity=(Quantum) TransparentOpacity;\n        }\n        colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n      }\n    if (image->gamma == 1.0)\n      {\n        for (i=0; i < (ssize_t) image->colors; i++)\n          if (IsGrayPixel(image->colormap+i) == MagickFalse)\n            break;\n        (void) SetImageColorspace(image,i == (ssize_t) image->colors ?\n          LinearGRAYColorspace : RGBColorspace);\n      }\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        if (profiles != (LinkedListInfo *) NULL)\n          profiles=DestroyLinkedList(profiles,DestroyGIFProfile);\n        global_colormap=(unsigned char *) RelinquishMagickMemory(\n          global_colormap);\n        meta_image=DestroyImage(meta_image);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    \/*\n      Decode image.\n    *\/\n    if (image_info->ping != MagickFalse)\n      status=PingGIFImage(image);\n    else\n      status=DecodeImage(image,opacity);\n    InheritException(exception,&image->exception);\n    if ((image_info->ping == MagickFalse) && (status == MagickFalse))\n      ThrowGIFException(CorruptImageError,\"CorruptImage\");\n    if (profiles != (LinkedListInfo *) NULL)\n      {\n        StringInfo\n          *profile;\n\n        \/*\n          Set image profiles.\n        *\/\n        ResetLinkedListIterator(profiles);\n        profile=(StringInfo *) GetNextValueInLinkedList(profiles);\n        while (profile != (StringInfo *) NULL)\n        {\n          (void) SetImageProfile(image,GetStringInfoName(profile),profile);\n          profile=(StringInfo *) GetNextValueInLinkedList(profiles);\n        }\n        profiles=DestroyLinkedList(profiles,DestroyGIFProfile);\n      }\n    duration+=image->delay*image->iterations;\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    opacity=(-1);\n    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) image->scene-\n      1,image->scene);\n    if (status == MagickFalse)\n      break;\n  }\n  image->duration=duration;\n  if (profiles != (LinkedListInfo *) NULL)\n    profiles=DestroyLinkedList(profiles,DestroyGIFProfile);\n  meta_image=DestroyImage(meta_image);\n  global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);\n  if ((image->columns == 0) || (image->rows == 0))\n    ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":3694,"total_token_length":3930,"max_tokens_setting":4096}
+{"idx":273403,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor* seq_len_max_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"seq_len_max\", &seq_len_max_tensor));\n\n    const Tensor* x;\n    OP_REQUIRES_OK(ctx, ctx->input(\"x\", &x));\n    OP_REQUIRES(ctx, x->dims() == 3, errors::InvalidArgument(\"x must be 3D\"));\n    const int64_t timelen = x->dim_size(0);\n    const int64_t batch_size = x->dim_size(1);\n    const int64_t input_size = x->dim_size(2);\n\n    const Tensor* cs_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"cs_prev\", &cs_prev_tensor));\n    OP_REQUIRES(ctx, cs_prev_tensor->dims() == 2,\n                errors::InvalidArgument(\"cs_prev must be 2D\"));\n    OP_REQUIRES(ctx, cs_prev_tensor->dim_size(0) == batch_size,\n                errors::InvalidArgument(\"cs_prev.dims(0) != batch_size: \",\n                                        cs_prev_tensor->dim_size(0), \" vs. \",\n                                        batch_size));\n    const int64_t cell_size = cs_prev_tensor->dim_size(1);\n\n    if (batch_size * input_size % 2 == 1) {\n      LOG(WARNING) << \"BlockLSTMOp is inefficient when both batch_size and \"\n                   << \"input_size are odd. You are using: batch_size=\"\n                   << batch_size << \", input_size=\" << input_size;\n    }\n    if (batch_size * cell_size % 2 == 1) {\n      LOG(WARNING) << \"BlockLSTMOp is inefficient when both batch_size and \"\n                   << \"cell_size are odd. You are using: batch_size=\"\n                   << batch_size << \", cell_size=\" << cell_size;\n    }\n\n    const Tensor* h_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"h_prev\", &h_prev_tensor));\n    OP_REQUIRES(ctx, h_prev_tensor->dims() == 2,\n                errors::InvalidArgument(\"h_prev must be 2D\"));\n    OP_REQUIRES(ctx, h_prev_tensor->dim_size(0) == batch_size,\n                errors::InvalidArgument(\"h_prev.dims(0) != batch_size: \",\n                                        h_prev_tensor->dim_size(0), \" vs. \",\n                                        batch_size));\n    OP_REQUIRES(ctx, h_prev_tensor->dim_size(1) == cell_size,\n                errors::InvalidArgument(\n                    \"h_prev.dims(1) != cell_size: \", h_prev_tensor->dim_size(1),\n                    \" vs. \", cell_size));\n\n    const Tensor* w_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"w\", &w_tensor));\n    OP_REQUIRES(ctx, w_tensor->dims() == 2,\n                errors::InvalidArgument(\"w must be 2D\"));\n    OP_REQUIRES(ctx, w_tensor->dim_size(0) == input_size + cell_size,\n                errors::InvalidArgument(\n                    \"w.dim_size(0) != input_size + cell_size: \",\n                    w_tensor->dim_size(0), \" vs. \", input_size + cell_size));\n    OP_REQUIRES(ctx, w_tensor->dim_size(1) == cell_size * 4,\n                errors::InvalidArgument(\n                    \"w.dim_size(1) != cell_size * 4: \", w_tensor->dim_size(1),\n                    \" vs. \", cell_size * 4));\n\n    const Tensor* wci_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wci\", &wci_tensor));\n    OP_REQUIRES(ctx, wci_tensor->dims() == 1,\n                errors::InvalidArgument(\"wci must be 1D\"));\n    OP_REQUIRES(ctx, wci_tensor->dim_size(0) == cell_size,\n                errors::InvalidArgument(\n                    \"wci.dim_size(0) != cell_size: \", wci_tensor->dim_size(0),\n                    \" vs. \", cell_size));\n\n    const Tensor* wcf_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wcf\", &wcf_tensor));\n    OP_REQUIRES(ctx, wcf_tensor->dims() == 1,\n                errors::InvalidArgument(\"wcf must be 1D\"));\n    OP_REQUIRES(ctx, wcf_tensor->dim_size(0) == cell_size,\n                errors::InvalidArgument(\n                    \"wcf.dim_size(0) != cell_size: \", wcf_tensor->dim_size(0),\n                    \" vs. \", cell_size));\n\n    const Tensor* wco_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wco\", &wco_tensor));\n    OP_REQUIRES(ctx, wco_tensor->dims() == 1,\n                errors::InvalidArgument(\"wco must be 1D\"));\n    OP_REQUIRES(ctx, wco_tensor->dim_size(0) == cell_size,\n                errors::InvalidArgument(\n                    \"wco.dim_size(0) != cell_size: \", wco_tensor->dim_size(0),\n                    \" vs. \", cell_size));\n\n    const Tensor* b_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"b\", &b_tensor));\n    OP_REQUIRES(ctx, b_tensor->dims() == 1,\n                errors::InvalidArgument(\"b must be 1D\"));\n    OP_REQUIRES(ctx, b_tensor->dim_size(0) == cell_size * 4,\n                errors::InvalidArgument(\n                    \"b.dim_size(0) != cell_size * 4: \", b_tensor->dim_size(0),\n                    \" vs. \", cell_size * 4));\n\n    TensorShape batch_cell_shape({timelen, batch_size, cell_size});\n    Tensor* i_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"i\", batch_cell_shape, &i_out));\n\n    Tensor* cs_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"cs\", batch_cell_shape, &cs_out));\n\n    Tensor* f_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"f\", batch_cell_shape, &f_out));\n\n    Tensor* o_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"o\", batch_cell_shape, &o_out));\n\n    Tensor* ci_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"ci\", batch_cell_shape, &ci_out));\n\n    Tensor* co_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"co\", batch_cell_shape, &co_out));\n\n    Tensor* h_out;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"h\", batch_cell_shape, &h_out));\n\n    Tensor xh_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(\n                            DataTypeToEnum<T>::v(),\n                            TensorShape({batch_size, input_size + cell_size}),\n                            &xh_tensor));\n\n    Tensor gates_tensor;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                      TensorShape({batch_size, cell_size * 4}),\n                                      &gates_tensor));\n\n    const Device& device = ctx->eigen_device<Device>();\n\n    const int64_t seq_len_max = seq_len_max_tensor->scalar<int64_t>()();\n    SliceHelper<Device, T> slicer(ctx);\n    for (int64_t t = 0; t < seq_len_max; ++t) {\n      const Tensor x_tensor = slicer.InputSlice(*x, t, \"x\");\n      const Tensor& cs_prev_tensor2 =\n          t == 0 ? *cs_prev_tensor\n                 : slicer.OutputSlice(cs_out, t - 1, \"cs_prev\");\n      const Tensor& h_prev_tensor2 =\n          t == 0 ? *h_prev_tensor : slicer.OutputSlice(h_out, t - 1, \"h_prev\");\n\n      Tensor i_tensor = slicer.OutputSlice(i_out, t, \"i_out\");\n      Tensor cs_tensor = slicer.OutputSlice(cs_out, t, \"cs_out\");\n      Tensor f_tensor = slicer.OutputSlice(f_out, t, \"f_out\");\n      Tensor o_tensor = slicer.OutputSlice(o_out, t, \"o_out\");\n      Tensor ci_tensor = slicer.OutputSlice(ci_out, t, \"ci_out\");\n      Tensor co_tensor = slicer.OutputSlice(co_out, t, \"co_out\");\n      Tensor h_tensor = slicer.OutputSlice(h_out, t, \"h_out\");\n\n      functor::LSTMBlockCellFprop<Device, T, USE_CUBLAS, gate_layout>(\n          batch_size, input_size, cell_size)(\n          ctx, device, forget_bias_, cell_clip_, use_peephole_,\n          x_tensor.matrix<T>(), cs_prev_tensor2.matrix<T>(),\n          h_prev_tensor2.matrix<T>(), w_tensor->matrix<T>(),\n          wci_tensor->vec<T>(), wcf_tensor->vec<T>(), wco_tensor->vec<T>(),\n          b_tensor->vec<T>(), xh_tensor.matrix<T>(), i_tensor.matrix<T>(),\n          cs_tensor.matrix<T>(), f_tensor.matrix<T>(), o_tensor.matrix<T>(),\n          ci_tensor.matrix<T>(), co_tensor.matrix<T>(),\n          gates_tensor.matrix<T>(), h_tensor.matrix<T>());\n      slicer.FinishTimeStep();\n    }\n\n    if (seq_len_max < timelen) {\n      Tensor cs_tensor = cs_out->Slice(seq_len_max, timelen);\n      Tensor h_tensor = h_out->Slice(seq_len_max, timelen);\n\n      functor::TensorUnalignedZero<Device, T>()(device,\n                                                cs_tensor.unaligned_flat<T>());\n      functor::TensorUnalignedZero<Device, T>()(device,\n                                                h_tensor.unaligned_flat<T>());\n    }\n  }","target":0,"code_token_length":2054,"total_token_length":2290,"max_tokens_setting":4096}
+{"idx":261424,"func":"void slice_segment_header::dump_slice_segment_header(const decoder_context* ctx, int fd) const\n{\n  FILE* fh;\n  if (fd==1) fh=stdout;\n  else if (fd==2) fh=stderr;\n  else { return; }\n\n#define LOG0(t) log2fh(fh, t)\n#define LOG1(t,d) log2fh(fh, t,d)\n#define LOG2(t,d1,d2) log2fh(fh, t,d1,d2)\n#define LOG3(t,d1,d2,d3) log2fh(fh, t,d1,d2,d3)\n#define LOG4(t,d1,d2,d3,d4) log2fh(fh, t,d1,d2,d3,d4)\n\n  const pic_parameter_set* pps = ctx->get_pps(slice_pic_parameter_set_id);\n  assert(pps->pps_read); \/\/ TODO: error handling\n\n  const seq_parameter_set* sps = ctx->get_sps((int)pps->seq_parameter_set_id);\n  assert(sps->sps_read); \/\/ TODO: error handling\n\n\n  LOG0(\"----------------- SLICE -----------------\\n\");\n  LOG1(\"first_slice_segment_in_pic_flag      : %d\\n\", first_slice_segment_in_pic_flag);\n  if (ctx->get_nal_unit_type() >= NAL_UNIT_BLA_W_LP &&\n      ctx->get_nal_unit_type() <= NAL_UNIT_RESERVED_IRAP_VCL23) {\n    LOG1(\"no_output_of_prior_pics_flag         : %d\\n\", no_output_of_prior_pics_flag);\n  }\n\n  LOG1(\"slice_pic_parameter_set_id           : %d\\n\", slice_pic_parameter_set_id);\n\n  if (!first_slice_segment_in_pic_flag) {\n    \/\/if (pps->dependent_slice_segments_enabled_flag) {\n      LOG1(\"dependent_slice_segment_flag         : %d\\n\", dependent_slice_segment_flag);\n      \/\/}\n    LOG1(\"slice_segment_address                : %d\\n\", slice_segment_address);\n  }\n\n  \/\/if (!dependent_slice_segment_flag)\n    {\n    \/\/for (int i=0; i<pps->num_extra_slice_header_bits; i++) {\n    \/\/slice_reserved_flag[i]\n\n    LOG1(\"slice_type                           : %c\\n\",\n         slice_type == 0 ? 'B' :\n         slice_type == 1 ? 'P' : 'I');\n\n    if (pps->output_flag_present_flag) {\n      LOG1(\"pic_output_flag                      : %d\\n\", pic_output_flag);\n    }\n\n    if (sps->separate_colour_plane_flag == 1) {\n      LOG1(\"colour_plane_id                      : %d\\n\", colour_plane_id);\n    }\n\n    LOG1(\"slice_pic_order_cnt_lsb              : %d\\n\", slice_pic_order_cnt_lsb);\n\n    if (ctx->get_nal_unit_type() != NAL_UNIT_IDR_W_RADL &&\n        ctx->get_nal_unit_type() != NAL_UNIT_IDR_N_LP) {\n      LOG1(\"short_term_ref_pic_set_sps_flag      : %d\\n\", short_term_ref_pic_set_sps_flag);\n\n      if (!short_term_ref_pic_set_sps_flag) {\n        LOG1(\"ref_pic_set[ %2d ]: \",sps->num_short_term_ref_pic_sets());\n        dump_compact_short_term_ref_pic_set(&slice_ref_pic_set, 16, fh);\n      }\n      else if (sps->num_short_term_ref_pic_sets() > 1) {\n        LOG1(\"short_term_ref_pic_set_idx           : %d\\n\", short_term_ref_pic_set_idx);\n        dump_compact_short_term_ref_pic_set(&sps->ref_pic_sets[short_term_ref_pic_set_idx], 16, fh);\n      }\n\n      if (sps->long_term_ref_pics_present_flag) {\n        if (sps->num_long_term_ref_pics_sps > 0) {\n          LOG1(\"num_long_term_sps                        : %d\\n\", num_long_term_sps);\n        }\n\n        LOG1(\"num_long_term_pics                       : %d\\n\", num_long_term_pics);\n\n#if 0\n        for (int i=0; i<num_long_term_sps + num_long_term_pics; i++) {\n          LOG2(\"PocLsbLt[%d]            : %d\\n\", i, ctx->PocLsbLt[i]);\n          LOG2(\"UsedByCurrPicLt[%d]     : %d\\n\", i, ctx->UsedByCurrPicLt[i]);\n          LOG2(\"DeltaPocMsbCycleLt[%d]  : %d\\n\", i, ctx->DeltaPocMsbCycleLt[i]);\n        }\n#endif\n      }\n\n      if (sps->sps_temporal_mvp_enabled_flag) {\n        LOG1(\"slice_temporal_mvp_enabled_flag : %d\\n\", slice_temporal_mvp_enabled_flag);\n      }\n    }\n\n\n    if (sps->sample_adaptive_offset_enabled_flag) {\n      LOG1(\"slice_sao_luma_flag             : %d\\n\", slice_sao_luma_flag);\n      LOG1(\"slice_sao_chroma_flag           : %d\\n\", slice_sao_chroma_flag);\n    }\n\n\n    if (slice_type == SLICE_TYPE_P || slice_type == SLICE_TYPE_B) {\n      LOG1(\"num_ref_idx_active_override_flag : %d\\n\", num_ref_idx_active_override_flag);\n\n      LOG2(\"num_ref_idx_l0_active          : %d %s\\n\", num_ref_idx_l0_active,\n           num_ref_idx_active_override_flag ? \"\" : \"(from PPS)\");\n\n      if (slice_type == SLICE_TYPE_B) {\n        LOG2(\"num_ref_idx_l1_active          : %d %s\\n\", num_ref_idx_l1_active,\n             num_ref_idx_active_override_flag ? \"\" : \"(from PPS)\");\n      }\n\n      if (pps->lists_modification_present_flag && NumPocTotalCurr > 1)\n        {\n          LOG1(\"ref_pic_list_modification_flag_l0 : %d\\n\", ref_pic_list_modification_flag_l0);\n          if (ref_pic_list_modification_flag_l0) {\n            for (int i=0;i<num_ref_idx_l0_active;i++) {\n              LOG2(\"  %d: %d\\n\",i,list_entry_l0[i]);\n            }\n          }\n\n          LOG1(\"ref_pic_list_modification_flag_l1 : %d\\n\", ref_pic_list_modification_flag_l1);\n          if (ref_pic_list_modification_flag_l1) {\n            for (int i=0;i<num_ref_idx_l1_active;i++) {\n              LOG2(\"  %d: %d\\n\",i,list_entry_l1[i]);\n            }\n          }\n        }\n\n      if (slice_type == SLICE_TYPE_B) {\n        LOG1(\"mvd_l1_zero_flag               : %d\\n\", mvd_l1_zero_flag);\n      }\n\n      LOG1(\"cabac_init_flag                : %d\\n\", cabac_init_flag);\n\n      if (slice_temporal_mvp_enabled_flag) {\n        LOG1(\"collocated_from_l0_flag        : %d\\n\", collocated_from_l0_flag);\n        LOG1(\"collocated_ref_idx             : %d\\n\", collocated_ref_idx);\n      }\n\n      if ((pps->weighted_pred_flag   && slice_type == SLICE_TYPE_P) ||\n          (pps->weighted_bipred_flag && slice_type == SLICE_TYPE_B))\n        {\n          LOG1(\"luma_log2_weight_denom         : %d\\n\", luma_log2_weight_denom);\n          if (sps->chroma_format_idc != 0) {\n            LOG1(\"ChromaLog2WeightDenom          : %d\\n\", ChromaLog2WeightDenom);\n          }\n\n          for (int l=0;l<=1;l++)\n            if (l==0 || (l==1 && slice_type == SLICE_TYPE_B))\n              {\n                int num_ref = (l==0 ?\n                               num_ref_idx_l0_active-1 :\n                               num_ref_idx_l1_active-1);\n\n                if (false) { \/\/ do not show these flags\n                  for (int i=0;i<=num_ref;i++) {\n                    LOG3(\"luma_weight_flag_l%d[%d]        : %d\\n\",l,i,luma_weight_flag[l][i]);\n                  }\n\n                  if (sps->chroma_format_idc != 0) {\n                    for (int i=0;i<=num_ref;i++) {\n                      LOG3(\"chroma_weight_flag_l%d[%d]      : %d\\n\",l,i,chroma_weight_flag[l][i]);\n                    }\n                  }\n                }\n\n                for (int i=0;i<=num_ref;i++) {\n                  LOG3(\"LumaWeight_L%d[%d]             : %d\\n\",l,i,LumaWeight[l][i]);\n                  LOG3(\"luma_offset_l%d[%d]            : %d\\n\",l,i,luma_offset[l][i]);\n\n                  for (int j=0;j<2;j++) {\n                    LOG4(\"ChromaWeight_L%d[%d][%d]        : %d\\n\",l,i,j,ChromaWeight[l][i][j]);\n                    LOG4(\"ChromaOffset_L%d[%d][%d]        : %d\\n\",l,i,j,ChromaOffset[l][i][j]);\n                  }\n                }\n              }\n        }\n\n      LOG1(\"five_minus_max_num_merge_cand  : %d\\n\", five_minus_max_num_merge_cand);\n    }\n\n\n    LOG1(\"slice_qp_delta         : %d\\n\", slice_qp_delta);\n    if (pps->pps_slice_chroma_qp_offsets_present_flag) {\n      LOG1(\"slice_cb_qp_offset     : %d\\n\", slice_cb_qp_offset);\n      LOG1(\"slice_cr_qp_offset     : %d\\n\", slice_cr_qp_offset);\n    }\n\n    if (pps->deblocking_filter_override_enabled_flag) {\n      LOG1(\"deblocking_filter_override_flag : %d\\n\", deblocking_filter_override_flag);\n    }\n\n    LOG2(\"slice_deblocking_filter_disabled_flag : %d %s\\n\",\n         slice_deblocking_filter_disabled_flag,\n         (deblocking_filter_override_flag ? \"(override)\" : \"(from pps)\"));\n\n    if (deblocking_filter_override_flag) {\n\n      if (!slice_deblocking_filter_disabled_flag) {\n        LOG1(\"slice_beta_offset  : %d\\n\", slice_beta_offset);\n        LOG1(\"slice_tc_offset    : %d\\n\", slice_tc_offset);\n      }\n    }\n\n    if (pps->pps_loop_filter_across_slices_enabled_flag  &&\n        (slice_sao_luma_flag || slice_sao_chroma_flag ||\n         !slice_deblocking_filter_disabled_flag)) {\n      LOG1(\"slice_loop_filter_across_slices_enabled_flag : %d\\n\",\n           slice_loop_filter_across_slices_enabled_flag);\n    }\n  }\n\n  if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {\n    LOG1(\"num_entry_point_offsets    : %d\\n\", num_entry_point_offsets);\n\n    if (num_entry_point_offsets > 0) {\n      LOG1(\"offset_len                 : %d\\n\", offset_len);\n\n      for (int i=0; i<num_entry_point_offsets; i++) {\n        LOG2(\"entry point [%i] : %d\\n\", i, entry_point_offset[i]);\n      }\n    }\n  }\n\n  \/*\n    if( slice_segment_header_extension_present_flag ) {\n    slice_segment_header_extension_length\n    for( i = 0; i < slice_segment_header_extension_length; i++)\n    slice_segment_header_extension_data_byte[i]\n    }\n    byte_alignment()\n    }\n  *\/\n\n#undef LOG0\n#undef LOG1\n#undef LOG2\n#undef LOG3\n#undef LOG4\n  \/\/#endif\n}","target":0,"code_token_length":2471,"total_token_length":2707,"max_tokens_setting":4096}
+{"idx":218768,"func":"static MagickBooleanType ReadPSDLayersInternal(Image *image,\n  const ImageInfo *image_info,const PSDInfo *psd_info,\n  const MagickBooleanType skip_layers,ExceptionInfo *exception)\n{\n  char\n    type[4];\n\n  LayerInfo\n    *layer_info;\n\n  MagickSizeType\n    size;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    i;\n\n  ssize_t\n    count,\n    j,\n    number_layers;\n\n  size=GetLayerInfoSize(psd_info,image);\n  status=MagickTrue;\n  if (size != 0)\n    {\n      layer_info=(LayerInfo *) NULL;\n      number_layers=(ssize_t) ReadBlobSignedShort(image);\n\n      if (number_layers < 0)\n        {\n          \/*\n            The first alpha channel in the merged result contains the\n            transparency data for the merged result.\n          *\/\n          number_layers=MagickAbsoluteValue(number_layers);\n          if (image->debug != MagickFalse)\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  negative layer count corrected for\");\n          image->matte=MagickTrue;\n        }\n\n      \/*\n        We only need to know if the image has an alpha channel\n      *\/\n      if (skip_layers != MagickFalse)\n        return(MagickTrue);\n\n      if (image->debug != MagickFalse)\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"  image contains %.20g layers\",(double) number_layers);\n\n      if (number_layers == 0)\n        ThrowBinaryException(CorruptImageError,\"InvalidNumberOfLayers\",\n          image->filename);\n\n      layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers,\n        sizeof(*layer_info));\n      if (layer_info == (LayerInfo *) NULL)\n        {\n          if (image->debug != MagickFalse)\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  allocation of LayerInfo failed\");\n          ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n            image->filename);\n        }\n      (void) memset(layer_info,0,(size_t) number_layers*sizeof(*layer_info));\n\n      for (i=0; i < number_layers; i++)\n      {\n        ssize_t\n          top,\n          left,\n          bottom,\n          right;\n\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  reading layer #%.20g\",(double) i+1);\n        top=(ssize_t) ReadBlobSignedLong(image);\n        left=(ssize_t) ReadBlobSignedLong(image);\n        bottom=(ssize_t) ReadBlobSignedLong(image);\n        right=(ssize_t) ReadBlobSignedLong(image);\n        if ((right < left) || (bottom < top))\n          {\n            layer_info=DestroyLayerInfo(layer_info,number_layers);\n            ThrowBinaryException(CorruptImageError,\"ImproperImageHeader\",\n              image->filename);\n          }\n        layer_info[i].page.y=top;\n        layer_info[i].page.x=left;\n        layer_info[i].page.width=(size_t) (right-left);\n        layer_info[i].page.height=(size_t) (bottom-top);\n        layer_info[i].channels=ReadBlobShort(image);\n        if (layer_info[i].channels > MaxPSDChannels)\n          {\n            layer_info=DestroyLayerInfo(layer_info,number_layers);\n            ThrowBinaryException(CorruptImageError,\"MaximumChannelsExceeded\",\n              image->filename);\n          }\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"    offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g\",\n            (double) layer_info[i].page.x,(double) layer_info[i].page.y,\n            (double) layer_info[i].page.height,(double)\n            layer_info[i].page.width,(double) layer_info[i].channels);\n        for (j=0; j < (ssize_t) layer_info[i].channels; j++)\n        {\n          layer_info[i].channel_info[j].type=(short) ReadBlobShort(image);\n          if ((layer_info[i].channel_info[j].type < -4) ||\n              (layer_info[i].channel_info[j].type > 4))\n            {\n              layer_info=DestroyLayerInfo(layer_info,number_layers);\n              ThrowBinaryException(CorruptImageError,\"NoSuchImageChannel\",\n                image->filename);\n            }\n          layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info,\n            image);\n          if (image->debug != MagickFalse)\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"    channel[%.20g]: type=%.20g, size=%.20g\",(double) j,\n              (double) layer_info[i].channel_info[j].type,\n              (double) layer_info[i].channel_info[j].size);\n        }\n        if (CheckPSDChannels(image,psd_info,&layer_info[i]) == MagickFalse)\n          {\n            layer_info=DestroyLayerInfo(layer_info,number_layers);\n            ThrowBinaryException(CorruptImageError,\"ImproperImageHeader\",\n              image->filename);\n          }\n        count=ReadPSDString(image,type,4);\n        if ((count != 4) || (LocaleNCompare(type,\"8BIM\",4) != 0))\n          {\n            if (image->debug != MagickFalse)\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"  layer type was %.4s instead of 8BIM\", type);\n            layer_info=DestroyLayerInfo(layer_info,number_layers);\n            ThrowBinaryException(CorruptImageError,\"ImproperImageHeader\",\n              image->filename);\n          }\n        count=ReadPSDString(image,layer_info[i].blendkey,4);\n        if (count != 4)\n          {\n            layer_info=DestroyLayerInfo(layer_info,number_layers);\n            ThrowBinaryException(CorruptImageError,\"ImproperImageHeader\",\n              image->filename);\n          }\n        layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char)\n          ReadBlobByte(image));\n        layer_info[i].clipping=(unsigned char) ReadBlobByte(image);\n        layer_info[i].flags=(unsigned char) ReadBlobByte(image);\n        layer_info[i].visible=!(layer_info[i].flags & 0x02);\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"   blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s\",\n            layer_info[i].blendkey,(double) layer_info[i].opacity,\n            layer_info[i].clipping ? \"true\" : \"false\",layer_info[i].flags,\n            layer_info[i].visible ? \"true\" : \"false\");\n        (void) ReadBlobByte(image);  \/* filler *\/\n\n        size=ReadBlobLong(image);\n        if (size != 0)\n          {\n            MagickSizeType\n              combined_length,\n              length;\n\n            if (image->debug != MagickFalse)\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"    layer contains additional info\");\n            length=ReadBlobLong(image);\n            combined_length=length+4;\n            if (length != 0)\n              {\n                \/*\n                  Layer mask info.\n                *\/\n                layer_info[i].mask.page.y=(ssize_t) ReadBlobSignedLong(image);\n                layer_info[i].mask.page.x=(ssize_t) ReadBlobSignedLong(image);\n                layer_info[i].mask.page.height=(size_t) (\n                  ReadBlobSignedLong(image)-layer_info[i].mask.page.y);\n                layer_info[i].mask.page.width=(size_t) (\n                  ReadBlobSignedLong(image)-layer_info[i].mask.page.x);\n                layer_info[i].mask.background=(unsigned char) ReadBlobByte(\n                  image);\n                layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image);\n                if (!(layer_info[i].mask.flags & 0x01))\n                  {\n                    layer_info[i].mask.page.y=layer_info[i].mask.page.y-\n                      layer_info[i].page.y;\n                    layer_info[i].mask.page.x=layer_info[i].mask.page.x-\n                      layer_info[i].page.x;\n                  }\n                if (image->debug != MagickFalse)\n                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                    \"      layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g\",\n                    (double) layer_info[i].mask.page.x,(double)\n                    layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width,\n                    (double) layer_info[i].mask.page.height,(double)\n                    ((MagickOffsetType) length)-18);\n                \/*\n                  Skip over the rest of the layer mask information.\n                *\/\n                if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse)\n                  {\n                    layer_info=DestroyLayerInfo(layer_info,number_layers);\n                    ThrowBinaryException(CorruptImageError,\"UnexpectedEndOfFile\",\n                      image->filename);\n                  }\n              }\n            length=ReadBlobLong(image);\n            combined_length+=length+4;\n            if (length != 0)\n              {\n                \/*\n                  Layer blending ranges info.\n                *\/\n                if (image->debug != MagickFalse)\n                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                    \"      layer blending ranges: length=%.20g\",(double)\n                    ((MagickOffsetType) length));\n                if (DiscardBlobBytes(image,length) == MagickFalse)\n                  {\n                    layer_info=DestroyLayerInfo(layer_info,number_layers);\n                    ThrowBinaryException(CorruptImageError,\n                      \"UnexpectedEndOfFile\",image->filename);\n                  }\n              }\n            \/*\n              Layer name.\n            *\/\n            length=(MagickSizeType) (unsigned char) ReadBlobByte(image);\n            combined_length+=length+1;\n            if (length > 0)\n              (void) ReadBlob(image,(size_t) length++,layer_info[i].name);\n            layer_info[i].name[length]='\\0';\n            if (image->debug != MagickFalse)\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"      layer name: %s\",layer_info[i].name);\n            if ((length % 4) != 0)\n              {\n                length=4-(length % 4);\n                combined_length+=length;\n                \/* Skip over the padding of the layer name *\/\n                if (DiscardBlobBytes(image,length) == MagickFalse)\n                  {\n                    layer_info=DestroyLayerInfo(layer_info,number_layers);\n                    ThrowBinaryException(CorruptImageError,\n                      \"UnexpectedEndOfFile\",image->filename);\n                  }\n              }\n            length=(MagickSizeType) size-combined_length;\n            if (length > 0)\n              {\n                unsigned char\n                  *info;\n\n                if (length > GetBlobSize(image))\n                  {\n                    layer_info=DestroyLayerInfo(layer_info,number_layers);\n                    ThrowBinaryException(CorruptImageError,\n                      \"InsufficientImageDataInFile\",image->filename);\n                  }\n                layer_info[i].info=AcquireStringInfo((const size_t) length);\n                info=GetStringInfoDatum(layer_info[i].info);\n                (void) ReadBlob(image,(const size_t) length,info);\n              }\n          }\n      }\n\n      for (i=0; i < number_layers; i++)\n      {\n        if ((layer_info[i].page.width == 0) ||\n              (layer_info[i].page.height == 0))\n          {\n            if (image->debug != MagickFalse)\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"      layer data is empty\");\n            if (layer_info[i].info != (StringInfo *) NULL)\n              layer_info[i].info=DestroyStringInfo(layer_info[i].info);\n            continue;\n          }\n        \/*\n          Allocate layered image.\n        *\/\n        layer_info[i].image=CloneImage(image,layer_info[i].page.width,\n          layer_info[i].page.height,MagickFalse,exception);\n        if (layer_info[i].image == (Image *) NULL)\n          {\n            layer_info=DestroyLayerInfo(layer_info,number_layers);\n            if (image->debug != MagickFalse)\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"  allocation of image for layer %.20g failed\",(double) i);\n            ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n              image->filename);\n          }\n        if (layer_info[i].info != (StringInfo *) NULL)\n          {\n            (void) SetImageProfile(layer_info[i].image,\"psd:additional-info\",\n              layer_info[i].info);\n            layer_info[i].info=DestroyStringInfo(layer_info[i].info);\n          }\n      }\n\n      if (image_info->ping == MagickFalse)\n        {\n          for (i=0; i < number_layers; i++)\n          {\n            if (layer_info[i].image == (Image *) NULL)\n              {\n                for (j=0; j < (ssize_t) layer_info[i].channels; j++)\n                {\n                  if (DiscardBlobBytes(image,(MagickSizeType)\n                      layer_info[i].channel_info[j].size) == MagickFalse)\n                    {\n                      layer_info=DestroyLayerInfo(layer_info,number_layers);\n                      ThrowBinaryException(CorruptImageError,\n                        \"UnexpectedEndOfFile\",image->filename);\n                    }\n                }\n                continue;\n              }\n\n            if (image->debug != MagickFalse)\n              (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                \"  reading data for layer %.20g\",(double) i);\n            status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i],\n              exception);\n            if (status == MagickFalse)\n              break;\n\n            status=SetImageProgress(image,LoadImagesTag,(MagickOffsetType) i,\n              (MagickSizeType) number_layers);\n            if (status == MagickFalse)\n              break;\n          }\n        }\n\n      if (status != MagickFalse)\n        {\n          for (i=0; i < number_layers; i++)\n          {\n            if (layer_info[i].image == (Image *) NULL)\n              {\n                for (j=i; j < number_layers - 1; j++)\n                  layer_info[j] = layer_info[j+1];\n                number_layers--;\n                i--;\n              }\n          }\n\n          if (number_layers > 0)\n            {\n              for (i=0; i < number_layers; i++)\n              {\n                if (i > 0)\n                  layer_info[i].image->previous=layer_info[i-1].image;\n                if (i < (number_layers-1))\n                  layer_info[i].image->next=layer_info[i+1].image;\n                layer_info[i].image->page=layer_info[i].page;\n              }\n              image->next=layer_info[0].image;\n              layer_info[0].image->previous=image;\n            }\n          layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info);\n        }\n      else\n        layer_info=DestroyLayerInfo(layer_info,number_layers);\n    }\n\n  return(status);\n}","target":0,"code_token_length":3282,"total_token_length":3518,"max_tokens_setting":4096}
+{"idx":223384,"func":"static void do_utfpeakcharback_invalid(compiler_common *common)\n{\n\/* Peak a character back. Does not modify STR_PTR. *\/\nDEFINE_COMPILER;\nsljit_s32 i;\nsljit_s32 has_cmov = sljit_has_cpu_feature(SLJIT_HAS_CMOV);\nstruct sljit_jump *jump[2];\nstruct sljit_label *two_byte_entry;\nstruct sljit_label *three_byte_entry;\nstruct sljit_label *exit_invalid_label;\nstruct sljit_jump *exit_invalid[8];\n\nsljit_emit_fast_enter(compiler, RETURN_ADDR, 0);\n\nOP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(3));\nexit_invalid[0] = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xc0);\njump[0] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, STR_PTR, 0);\n\n\/* Two-byte sequence. *\/\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2);\njump[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x1e);\n\ntwo_byte_entry = LABEL();\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);\n\/* If TMP1 is in 0x80-0xbf range, TMP1 is also increased by (0x2 << 6). *\/\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\nJUMPHERE(jump[1]);\nOP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2 - 0x80);\nOP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x80);\nexit_invalid[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);\nOP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);\n\n\/* Three-byte sequence. *\/\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-3));\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xe0);\njump[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x10);\n\nthree_byte_entry = LABEL();\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);\nOP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);\n\nOP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xd800);\nif (has_cmov)\n  {\n  OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP1, 0, SLJIT_IMM, 0x800);\n  CMOV(SLJIT_LESS, TMP1, SLJIT_IMM, -0xd800);\n  exit_invalid[2] = NULL;\n  }\nelse\n  exit_invalid[2] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0x800);\n\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xd800);\nif (has_cmov)\n  {\n  OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP1, 0, SLJIT_IMM, 0x800);\n  CMOV(SLJIT_LESS, TMP1, SLJIT_IMM, INVALID_UTF_CHAR);\n  exit_invalid[3] = NULL;\n  }\nelse\n  exit_invalid[3] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0x800);\n\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\nJUMPHERE(jump[1]);\nOP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xe0 - 0x80);\nexit_invalid[4] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);\nOP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);\n\n\/* Four-byte sequence. *\/\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-4));\nOP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000);\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xf0);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 18);\n\/* ADD is used instead of OR because of the SUB 0x10000 above. *\/\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\n\nif (has_cmov)\n  {\n  OP2U(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x100000);\n  CMOV(SLJIT_GREATER_EQUAL, TMP1, SLJIT_IMM, INVALID_UTF_CHAR - 0x10000);\n  exit_invalid[5] = NULL;\n  }\nelse\n  exit_invalid[5] = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x100000);\n\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\nJUMPHERE(jump[0]);\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));\njump[0] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, STR_PTR, 0);\n\n\/* Two-byte sequence. *\/\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2);\nCMPTO(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x1e, two_byte_entry);\n\nOP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2 - 0x80);\nOP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x80);\nexit_invalid[6] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);\nOP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);\n\n\/* Three-byte sequence. *\/\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-3));\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xe0);\nCMPTO(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x10, three_byte_entry);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\nJUMPHERE(jump[0]);\nexit_invalid[7] = CMP(SLJIT_GREATER, TMP2, 0, STR_PTR, 0);\n\n\/* Two-byte sequence. *\/\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2);\nCMPTO(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x1e, two_byte_entry);\n\nexit_invalid_label = LABEL();\nfor (i = 0; i < 8; i++)\n  sljit_set_label(exit_invalid[i], exit_invalid_label);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n}","target":0,"code_token_length":2166,"total_token_length":2402,"max_tokens_setting":4096}
+{"idx":212083,"func":"static int ismt_access(struct i2c_adapter *adap, u16 addr,\n\t\t       unsigned short flags, char read_write, u8 command,\n\t\t       int size, union i2c_smbus_data *data)\n{\n\tint ret;\n\tunsigned long time_left;\n\tdma_addr_t dma_addr = 0; \/* address of the data buffer *\/\n\tu8 dma_size = 0;\n\tenum dma_data_direction dma_direction = 0;\n\tstruct ismt_desc *desc;\n\tstruct ismt_priv *priv = i2c_get_adapdata(adap);\n\tstruct device *dev = &priv->pci_dev->dev;\n\tu8 *dma_buffer = PTR_ALIGN(&priv->buffer[0], 16);\n\n\tdesc = &priv->hw[priv->head];\n\n\t\/* Initialize the DMA buffer *\/\n\tmemset(priv->buffer, 0, sizeof(priv->buffer));\n\n\t\/* Initialize the descriptor *\/\n\tmemset(desc, 0, sizeof(struct ismt_desc));\n\tdesc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, read_write);\n\n\t\/* Always clear the log entries *\/\n\tmemset(priv->log, 0, ISMT_LOG_ENTRIES * sizeof(u32));\n\n\t\/* Initialize common control bits *\/\n\tif (likely(pci_dev_msi_enabled(priv->pci_dev)))\n\t\tdesc->control = ISMT_DESC_INT | ISMT_DESC_FAIR;\n\telse\n\t\tdesc->control = ISMT_DESC_FAIR;\n\n\tif ((flags & I2C_CLIENT_PEC) && (size != I2C_SMBUS_QUICK)\n\t    && (size != I2C_SMBUS_I2C_BLOCK_DATA))\n\t\tdesc->control |= ISMT_DESC_PEC;\n\n\tswitch (size) {\n\tcase I2C_SMBUS_QUICK:\n\t\tdev_dbg(dev, \"I2C_SMBUS_QUICK\\n\");\n\t\tbreak;\n\n\tcase I2C_SMBUS_BYTE:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/*\n\t\t\t * Send Byte\n\t\t\t * The command field contains the write data\n\t\t\t *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE:  WRITE\\n\");\n\t\t\tdesc->control |= ISMT_DESC_CWRL;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t} else {\n\t\t\t\/* Receive Byte *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE:  READ\\n\");\n\t\t\tdma_size = 1;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t\tdesc->rd_len = 1;\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_BYTE_DATA:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/*\n\t\t\t * Write Byte\n\t\t\t * Command plus 1 data byte\n\t\t\t *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE_DATA:  WRITE\\n\");\n\t\t\tdesc->wr_len_cmd = 2;\n\t\t\tdma_size = 2;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdma_buffer[0] = command;\n\t\t\tdma_buffer[1] = data->byte;\n\t\t} else {\n\t\t\t\/* Read Byte *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BYTE_DATA:  READ\\n\");\n\t\t\tdesc->control |= ISMT_DESC_CWRL;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->rd_len = 1;\n\t\t\tdma_size = 1;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_WORD_DATA:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/* Write Word *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_WORD_DATA:  WRITE\\n\");\n\t\t\tdesc->wr_len_cmd = 3;\n\t\t\tdma_size = 3;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdma_buffer[0] = command;\n\t\t\tdma_buffer[1] = data->word & 0xff;\n\t\t\tdma_buffer[2] = data->word >> 8;\n\t\t} else {\n\t\t\t\/* Read Word *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_WORD_DATA:  READ\\n\");\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->control |= ISMT_DESC_CWRL;\n\t\t\tdesc->rd_len = 2;\n\t\t\tdma_size = 2;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_PROC_CALL:\n\t\tdev_dbg(dev, \"I2C_SMBUS_PROC_CALL\\n\");\n\t\tdesc->wr_len_cmd = 3;\n\t\tdesc->rd_len = 2;\n\t\tdma_size = 3;\n\t\tdma_direction = DMA_BIDIRECTIONAL;\n\t\tdma_buffer[0] = command;\n\t\tdma_buffer[1] = data->word & 0xff;\n\t\tdma_buffer[2] = data->word >> 8;\n\t\tbreak;\n\n\tcase I2C_SMBUS_BLOCK_DATA:\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/* Block Write *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BLOCK_DATA:  WRITE\\n\");\n\t\t\tdma_size = data->block[0] + 1;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdesc->wr_len_cmd = dma_size;\n\t\t\tdesc->control |= ISMT_DESC_BLK;\n\t\t\tdma_buffer[0] = command;\n\t\t\tmemcpy(&dma_buffer[1], &data->block[1], dma_size - 1);\n\t\t} else {\n\t\t\t\/* Block Read *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_BLOCK_DATA:  READ\\n\");\n\t\t\tdma_size = I2C_SMBUS_BLOCK_MAX;\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t\tdesc->rd_len = dma_size;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->control |= (ISMT_DESC_BLK | ISMT_DESC_CWRL);\n\t\t}\n\t\tbreak;\n\n\tcase I2C_SMBUS_BLOCK_PROC_CALL:\n\t\tdev_dbg(dev, \"I2C_SMBUS_BLOCK_PROC_CALL\\n\");\n\t\tdma_size = I2C_SMBUS_BLOCK_MAX;\n\t\tdesc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, 1);\n\t\tdesc->wr_len_cmd = data->block[0] + 1;\n\t\tdesc->rd_len = dma_size;\n\t\tdesc->control |= ISMT_DESC_BLK;\n\t\tdma_direction = DMA_BIDIRECTIONAL;\n\t\tdma_buffer[0] = command;\n\t\tmemcpy(&dma_buffer[1], &data->block[1], data->block[0]);\n\t\tbreak;\n\n\tcase I2C_SMBUS_I2C_BLOCK_DATA:\n\t\t\/* Make sure the length is valid *\/\n\t\tif (data->block[0] < 1)\n\t\t\tdata->block[0] = 1;\n\n\t\tif (data->block[0] > I2C_SMBUS_BLOCK_MAX)\n\t\t\tdata->block[0] = I2C_SMBUS_BLOCK_MAX;\n\n\t\tif (read_write == I2C_SMBUS_WRITE) {\n\t\t\t\/* i2c Block Write *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_I2C_BLOCK_DATA:  WRITE\\n\");\n\t\t\tdma_size = data->block[0] + 1;\n\t\t\tdma_direction = DMA_TO_DEVICE;\n\t\t\tdesc->wr_len_cmd = dma_size;\n\t\t\tdesc->control |= ISMT_DESC_I2C;\n\t\t\tdma_buffer[0] = command;\n\t\t\tmemcpy(&dma_buffer[1], &data->block[1], dma_size - 1);\n\t\t} else {\n\t\t\t\/* i2c Block Read *\/\n\t\t\tdev_dbg(dev, \"I2C_SMBUS_I2C_BLOCK_DATA:  READ\\n\");\n\t\t\tdma_size = data->block[0];\n\t\t\tdma_direction = DMA_FROM_DEVICE;\n\t\t\tdesc->rd_len = dma_size;\n\t\t\tdesc->wr_len_cmd = command;\n\t\t\tdesc->control |= (ISMT_DESC_I2C | ISMT_DESC_CWRL);\n\t\t\t\/*\n\t\t\t * Per the \"Table 15-15. I2C Commands\",\n\t\t\t * in the External Design Specification (EDS),\n\t\t\t * (Document Number: 508084, Revision: 2.0),\n\t\t\t * the _rw bit must be 0\n\t\t\t *\/\n\t\t\tdesc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, 0);\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tdev_err(dev, \"Unsupported transaction %d\\n\",\n\t\t\tsize);\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\t\/* map the data buffer *\/\n\tif (dma_size != 0) {\n\t\tdev_dbg(dev, \" dev=%p\\n\", dev);\n\t\tdev_dbg(dev, \" data=%p\\n\", data);\n\t\tdev_dbg(dev, \" dma_buffer=%p\\n\", dma_buffer);\n\t\tdev_dbg(dev, \" dma_size=%d\\n\", dma_size);\n\t\tdev_dbg(dev, \" dma_direction=%d\\n\", dma_direction);\n\n\t\tdma_addr = dma_map_single(dev,\n\t\t\t\t      dma_buffer,\n\t\t\t\t      dma_size,\n\t\t\t\t      dma_direction);\n\n\t\tif (dma_mapping_error(dev, dma_addr)) {\n\t\t\tdev_err(dev, \"Error in mapping dma buffer %p\\n\",\n\t\t\t\tdma_buffer);\n\t\t\treturn -EIO;\n\t\t}\n\n\t\tdev_dbg(dev, \" dma_addr = %pad\\n\", &dma_addr);\n\n\t\tdesc->dptr_low = lower_32_bits(dma_addr);\n\t\tdesc->dptr_high = upper_32_bits(dma_addr);\n\t}\n\n\treinit_completion(&priv->cmp);\n\n\t\/* Add the descriptor *\/\n\tismt_submit_desc(priv);\n\n\t\/* Now we wait for interrupt completion, 1s *\/\n\ttime_left = wait_for_completion_timeout(&priv->cmp, HZ*1);\n\n\t\/* unmap the data buffer *\/\n\tif (dma_size != 0)\n\t\tdma_unmap_single(dev, dma_addr, dma_size, dma_direction);\n\n\tif (unlikely(!time_left)) {\n\t\tdev_err(dev, \"completion wait timed out\\n\");\n\t\tret = -ETIMEDOUT;\n\t\tgoto out;\n\t}\n\n\t\/* do any post processing of the descriptor here *\/\n\tret = ismt_process_desc(desc, data, priv, size, read_write);\n\nout:\n\t\/* Update the ring pointer *\/\n\tpriv->head++;\n\tpriv->head %= ISMT_DESC_ENTRIES;\n\n\treturn ret;\n}","target":1,"code_token_length":2173,"total_token_length":2409,"max_tokens_setting":4096}
+{"idx":208140,"func":"int main(int argc, char **argv)\n{\n\tint c, rc = MOUNT_EX_SUCCESS, all = 0, show_labels = 0;\n\tstruct libmnt_context *cxt;\n\tstruct libmnt_table *fstab = NULL;\n\tchar *srcbuf = NULL;\n\tchar *types = NULL;\n\tunsigned long oper = 0;\n\n\tenum {\n\t\tMOUNT_OPT_SHARED = CHAR_MAX + 1,\n\t\tMOUNT_OPT_SLAVE,\n\t\tMOUNT_OPT_PRIVATE,\n\t\tMOUNT_OPT_UNBINDABLE,\n\t\tMOUNT_OPT_RSHARED,\n\t\tMOUNT_OPT_RSLAVE,\n\t\tMOUNT_OPT_RPRIVATE,\n\t\tMOUNT_OPT_RUNBINDABLE,\n\t\tMOUNT_OPT_TARGET,\n\t\tMOUNT_OPT_SOURCE\n\t};\n\n\tstatic const struct option longopts[] = {\n\t\t{ \"all\", 0, 0, 'a' },\n\t\t{ \"fake\", 0, 0, 'f' },\n\t\t{ \"fstab\", 1, 0, 'T' },\n\t\t{ \"fork\", 0, 0, 'F' },\n\t\t{ \"help\", 0, 0, 'h' },\n\t\t{ \"no-mtab\", 0, 0, 'n' },\n\t\t{ \"read-only\", 0, 0, 'r' },\n\t\t{ \"ro\", 0, 0, 'r' },\n\t\t{ \"verbose\", 0, 0, 'v' },\n\t\t{ \"version\", 0, 0, 'V' },\n\t\t{ \"read-write\", 0, 0, 'w' },\n\t\t{ \"rw\", 0, 0, 'w' },\n\t\t{ \"options\", 1, 0, 'o' },\n\t\t{ \"test-opts\", 1, 0, 'O' },\n\t\t{ \"pass-fd\", 1, 0, 'p' },\n\t\t{ \"types\", 1, 0, 't' },\n\t\t{ \"uuid\", 1, 0, 'U' },\n\t\t{ \"label\", 1, 0, 'L'},\n\t\t{ \"bind\", 0, 0, 'B' },\n\t\t{ \"move\", 0, 0, 'M' },\n\t\t{ \"rbind\", 0, 0, 'R' },\n\t\t{ \"make-shared\", 0, 0, MOUNT_OPT_SHARED },\n\t\t{ \"make-slave\", 0, 0, MOUNT_OPT_SLAVE },\n\t\t{ \"make-private\", 0, 0, MOUNT_OPT_PRIVATE },\n\t\t{ \"make-unbindable\", 0, 0, MOUNT_OPT_UNBINDABLE },\n\t\t{ \"make-rshared\", 0, 0, MOUNT_OPT_RSHARED },\n\t\t{ \"make-rslave\", 0, 0, MOUNT_OPT_RSLAVE },\n\t\t{ \"make-rprivate\", 0, 0, MOUNT_OPT_RPRIVATE },\n\t\t{ \"make-runbindable\", 0, 0, MOUNT_OPT_RUNBINDABLE },\n\t\t{ \"no-canonicalize\", 0, 0, 'c' },\n\t\t{ \"internal-only\", 0, 0, 'i' },\n\t\t{ \"show-labels\", 0, 0, 'l' },\n\t\t{ \"target\", 1, 0, MOUNT_OPT_TARGET },\n\t\t{ \"source\", 1, 0, MOUNT_OPT_SOURCE },\n\t\t{ NULL, 0, 0, 0 }\n\t};\n\n\tstatic const ul_excl_t excl[] = {       \/* rows and cols in in ASCII order *\/\n\t\t{ 'B','M','R',\t\t\t\/* bind,move,rbind *\/\n\t\t   MOUNT_OPT_SHARED,   MOUNT_OPT_SLAVE,\n\t\t   MOUNT_OPT_PRIVATE,  MOUNT_OPT_UNBINDABLE,\n\t\t   MOUNT_OPT_RSHARED,  MOUNT_OPT_RSLAVE,\n\t\t   MOUNT_OPT_RPRIVATE, MOUNT_OPT_RUNBINDABLE },\n\n\t\t{ 'L','U', MOUNT_OPT_SOURCE },\t\/* label,uuid,source *\/\n\t\t{ 0 }\n\t};\n\tint excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;\n\n\tsanitize_env();\n\tsetlocale(LC_ALL, \"\");\n\tbindtextdomain(PACKAGE, LOCALEDIR);\n\ttextdomain(PACKAGE);\n\tatexit(close_stdout);\n\n\tmnt_init_debug(0);\n\tcxt = mnt_new_context();\n\tif (!cxt)\n\t\terr(MOUNT_EX_SYSERR, _(\"libmount context allocation failed\"));\n\n\tmnt_context_set_tables_errcb(cxt, table_parser_errcb);\n\n\twhile ((c = getopt_long(argc, argv, \"aBcfFhilL:Mno:O:p:rRsU:vVwt:T:\",\n\t\t\t\t\tlongopts, NULL)) != -1) {\n\n\t\t\/* only few options are allowed for non-root users *\/\n\t\tif (mnt_context_is_restricted(cxt) &&\n\t\t    !strchr(\"hlLUVvpris\", c) &&\n\t\t    c != MOUNT_OPT_TARGET &&\n\t\t    c != MOUNT_OPT_SOURCE)\n\t\t\texit_non_root(option_to_longopt(c, longopts));\n\n\t\terr_exclusive_options(c, longopts, excl, excl_st);\n\n\t\tswitch(c) {\n\t\tcase 'a':\n\t\t\tall = 1;\n\t\t\tbreak;\n\t\tcase 'c':\n\t\t\tmnt_context_disable_canonicalize(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'f':\n\t\t\tmnt_context_enable_fake(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'F':\n\t\t\tmnt_context_enable_fork(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'h':\n\t\t\tusage(stdout);\n\t\t\tbreak;\n\t\tcase 'i':\n\t\t\tmnt_context_disable_helpers(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'n':\n\t\t\tmnt_context_disable_mtab(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'r':\n\t\t\tif (mnt_context_append_options(cxt, \"ro\"))\n\t\t\t\terr(MOUNT_EX_SYSERR, _(\"failed to append options\"));\n\t\t\treadwrite = 0;\n\t\t\tbreak;\n\t\tcase 'v':\n\t\t\tmnt_context_enable_verbose(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'V':\n\t\t\tprint_version();\n\t\t\tbreak;\n\t\tcase 'w':\n\t\t\tif (mnt_context_append_options(cxt, \"rw\"))\n\t\t\t\terr(MOUNT_EX_SYSERR, _(\"failed to append options\"));\n\t\t\treadwrite = 1;\n\t\t\tbreak;\n\t\tcase 'o':\n\t\t\tif (mnt_context_append_options(cxt, optarg))\n\t\t\t\terr(MOUNT_EX_SYSERR, _(\"failed to append options\"));\n\t\t\tbreak;\n\t\tcase 'O':\n\t\t\tif (mnt_context_set_options_pattern(cxt, optarg))\n\t\t\t\terr(MOUNT_EX_SYSERR, _(\"failed to set options pattern\"));\n\t\t\tbreak;\n\t\tcase 'p':\n                        warnx(_(\"--pass-fd is no longer supported\"));\n\t\t\tbreak;\n\t\tcase 'L':\n\t\t\txasprintf(&srcbuf, \"LABEL=\\\"%s\\\"\", optarg);\n\t\t\tmnt_context_disable_swapmatch(cxt, 1);\n\t\t\tmnt_context_set_source(cxt, srcbuf);\n\t\t\tfree(srcbuf);\n\t\t\tbreak;\n\t\tcase 'U':\n\t\t\txasprintf(&srcbuf, \"UUID=\\\"%s\\\"\", optarg);\n\t\t\tmnt_context_disable_swapmatch(cxt, 1);\n\t\t\tmnt_context_set_source(cxt, srcbuf);\n\t\t\tfree(srcbuf);\n\t\t\tbreak;\n\t\tcase 'l':\n\t\t\tshow_labels = 1;\n\t\t\tbreak;\n\t\tcase 't':\n\t\t\ttypes = optarg;\n\t\t\tbreak;\n\t\tcase 'T':\n\t\t\tfstab = append_fstab(cxt, fstab, optarg);\n\t\t\tbreak;\n\t\tcase 's':\n\t\t\tmnt_context_enable_sloppy(cxt, TRUE);\n\t\t\tbreak;\n\t\tcase 'B':\n\t\t\toper |= MS_BIND;\n\t\t\tbreak;\n\t\tcase 'M':\n\t\t\toper |= MS_MOVE;\n\t\t\tbreak;\n\t\tcase 'R':\n\t\t\toper |= (MS_BIND | MS_REC);\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_SHARED:\n\t\t\toper |= MS_SHARED;\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_SLAVE:\n\t\t\toper |= MS_SLAVE;\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_PRIVATE:\n\t\t\toper |= MS_PRIVATE;\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_UNBINDABLE:\n\t\t\toper |= MS_UNBINDABLE;\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_RSHARED:\n\t\t\toper |= (MS_SHARED | MS_REC);\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_RSLAVE:\n\t\t\toper |= (MS_SLAVE | MS_REC);\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_RPRIVATE:\n\t\t\toper |= (MS_PRIVATE | MS_REC);\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_RUNBINDABLE:\n\t\t\toper |= (MS_UNBINDABLE | MS_REC);\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_TARGET:\n\t\t\tmnt_context_disable_swapmatch(cxt, 1);\n\t\t\tmnt_context_set_target(cxt, optarg);\n\t\t\tbreak;\n\t\tcase MOUNT_OPT_SOURCE:\n\t\t\tmnt_context_disable_swapmatch(cxt, 1);\n\t\t\tmnt_context_set_source(cxt, optarg);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tusage(stderr);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\targc -= optind;\n\targv += optind;\n\n\tif (fstab && !mnt_context_is_nocanonicalize(cxt)) {\n\t\t\/*\n\t\t * We have external (context independent) fstab instance, let's\n\t\t * make a connection between the fstab and the canonicalization\n\t\t * cache.\n\t\t *\/\n\t\tstruct libmnt_cache *cache = mnt_context_get_cache(cxt);\n\t\tmnt_table_set_cache(fstab, cache);\n\t}\n\n\tif (!mnt_context_get_source(cxt) &&\n\t    !mnt_context_get_target(cxt) &&\n\t    !argc &&\n\t    !all) {\n\t\tif (oper)\n\t\t\tusage(stderr);\n\t\tprint_all(cxt, types, show_labels);\n\t\tgoto done;\n\t}\n\n\tif (oper && (types || all || mnt_context_get_source(cxt)))\n\t\tusage(stderr);\n\n\tif (types && (all || strchr(types, ',') ||\n\t\t\t     strncmp(types, \"no\", 2) == 0))\n\t\tmnt_context_set_fstype_pattern(cxt, types);\n\telse if (types)\n\t\tmnt_context_set_fstype(cxt, types);\n\n\tif (all) {\n\t\t\/*\n\t\t * A) Mount all\n\t\t *\/\n\t\trc = mount_all(cxt);\n\t\tgoto done;\n\n\t} else if (argc == 0 && (mnt_context_get_source(cxt) ||\n\t\t\t\t mnt_context_get_target(cxt))) {\n\t\t\/*\n\t\t * B) mount -L|-U|--source|--target\n\t\t *\/\n\t\tif (mnt_context_is_restricted(cxt) &&\n\t\t    mnt_context_get_source(cxt) &&\n\t\t    mnt_context_get_target(cxt))\n\t\t\texit_non_root(NULL);\n\n\t} else if (argc == 1) {\n\t\t\/*\n\t\t * C) mount [-L|-U|--source] <target>\n\t\t *    mount <source|target>\n\t\t *\n\t\t * non-root may specify source *or* target, but not both\n\t\t *\/\n\t\tif (mnt_context_is_restricted(cxt) &&\n\t\t    mnt_context_get_source(cxt))\n\t\t\texit_non_root(NULL);\n\n\t\tmnt_context_set_target(cxt, argv[0]);\n\n\t} else if (argc == 2 && !mnt_context_get_source(cxt)\n\t\t\t     && !mnt_context_get_target(cxt)) {\n\t\t\/*\n\t\t * D) mount <source> <target>\n\t\t *\/\n\t\tif (mnt_context_is_restricted(cxt))\n\t\t\texit_non_root(NULL);\n\t\tmnt_context_set_source(cxt, argv[0]);\n\t\tmnt_context_set_target(cxt, argv[1]);\n\n\t} else\n\t\tusage(stderr);\n\n\tif (oper) {\n\t\t\/* MS_PROPAGATION operations, let's set the mount flags *\/\n\t\tmnt_context_set_mflags(cxt, oper);\n\n\t\t\/* For -make* or --bind is fstab unnecessary *\/\n\t\tmnt_context_set_optsmode(cxt, MNT_OMODE_NOTAB);\n\t}\n\n\trc = mnt_context_mount(cxt);\n\trc = mk_exit_code(cxt, rc);\n\n\tif (rc == MOUNT_EX_SUCCESS && mnt_context_is_verbose(cxt))\n\t\tsuccess_message(cxt);\ndone:\n\tmnt_free_context(cxt);\n\tmnt_free_table(fstab);\n\treturn rc;\n}","target":1,"code_token_length":2596,"total_token_length":2832,"max_tokens_setting":4096}
+{"idx":309963,"func":"TransformLine(NCURSES_SP_DCLx int const lineno)\n{\n    int firstChar, oLastChar, nLastChar;\n    NCURSES_CH_T *newLine = NewScreen(SP_PARM)->_line[lineno].text;\n    NCURSES_CH_T *oldLine = CurScreen(SP_PARM)->_line[lineno].text;\n    int n;\n    bool attrchanged = FALSE;\n\n    TR(TRACE_UPDATE, (T_CALLED(\"TransformLine(%p, %d)\"), (void *) SP_PARM, lineno));\n\n    \/* copy new hash value to old one *\/\n    if (SP_PARM->oldhash && SP_PARM->newhash)\n\tSP_PARM->oldhash[lineno] = SP_PARM->newhash[lineno];\n\n    \/*\n     * If we have colors, there is the possibility of having two color pairs\n     * that display as the same colors.  For instance, Lynx does this.  Check\n     * for this case, and update the old line with the new line's colors when\n     * they are equivalent.\n     *\/\n    if (SP_PARM->_coloron) {\n\tint oldPair;\n\tint newPair;\n\n\tfor (n = 0; n < screen_columns(SP_PARM); n++) {\n\t    if (!CharEq(newLine[n], oldLine[n])) {\n\t\toldPair = GetPair(oldLine[n]);\n\t\tnewPair = GetPair(newLine[n]);\n\t\tif (oldPair != newPair\n\t\t    && unColor(oldLine[n]) == unColor(newLine[n])) {\n\t\t    if (oldPair < SP_PARM->_pair_limit\n\t\t\t&& newPair < SP_PARM->_pair_limit\n\t\t\t&& (isSamePair(SP_PARM->_color_pairs[oldPair],\n\t\t\t\t       SP_PARM->_color_pairs[newPair]))) {\n\t\t\tSetPair(oldLine[n], GetPair(newLine[n]));\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n\n    if (ceol_standout_glitch && clr_eol) {\n\tfirstChar = 0;\n\twhile (firstChar < screen_columns(SP_PARM)) {\n\t    if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {\n\t\tattrchanged = TRUE;\n\t\tbreak;\n\t    }\n\t    firstChar++;\n\t}\n    }\n\n    firstChar = 0;\n\n    if (attrchanged) {\t\t\/* we may have to disregard the whole line *\/\n\tGoTo(NCURSES_SP_ARGx lineno, firstChar);\n\tClrToEOL(NCURSES_SP_ARGx\n\t\t ClrBlank(NCURSES_SP_ARGx\n\t\t\t  CurScreen(SP_PARM)), FALSE);\n\tPutRange(NCURSES_SP_ARGx\n\t\t oldLine, newLine, lineno, 0,\n\t\t screen_columns(SP_PARM) - 1);\n#if USE_XMC_SUPPORT\n\n\t\/*\n\t * This is a very simple loop to paint characters which may have the\n\t * magic cookie glitch embedded.  It doesn't know much about video\n\t * attributes which are continued from one line to the next.  It\n\t * assumes that we have filtered out requests for attribute changes\n\t * that do not get mapped to blank positions.\n\t *\n\t * FIXME: we are not keeping track of where we put the cookies, so this\n\t * will work properly only once, since we may overwrite a cookie in a\n\t * following operation.\n\t *\/\n    } else if (magic_cookie_glitch > 0) {\n\tGoTo(NCURSES_SP_ARGx lineno, firstChar);\n\tfor (n = 0; n < screen_columns(SP_PARM); n++) {\n\t    int m = n + magic_cookie_glitch;\n\n\t    \/* check for turn-on:\n\t     * If we are writing an attributed blank, where the\n\t     * previous cell is not attributed.\n\t     *\/\n\t    if (ISBLANK(newLine[n])\n\t\t&& ((n > 0\n\t\t     && xmc_turn_on(SP_PARM, newLine[n - 1], newLine[n]))\n\t\t    || (n == 0\n\t\t\t&& lineno > 0\n\t\t\t&& xmc_turn_on(SP_PARM,\n\t\t\t\t       xmc_new(SP_PARM, lineno - 1,\n\t\t\t\t\t       screen_columns(SP_PARM) - 1),\n\t\t\t\t       newLine[n])))) {\n\t\tn = m;\n\t    }\n\n\t    PutChar(NCURSES_SP_ARGx CHREF(newLine[n]));\n\n\t    \/* check for turn-off:\n\t     * If we are writing an attributed non-blank, where the\n\t     * next cell is blank, and not attributed.\n\t     *\/\n\t    if (!ISBLANK(newLine[n])\n\t\t&& ((n + 1 < screen_columns(SP_PARM)\n\t\t     && xmc_turn_off(SP_PARM, newLine[n], newLine[n + 1]))\n\t\t    || (n + 1 >= screen_columns(SP_PARM)\n\t\t\t&& lineno + 1 < screen_lines(SP_PARM)\n\t\t\t&& xmc_turn_off(SP_PARM,\n\t\t\t\t\tnewLine[n],\n\t\t\t\t\txmc_new(SP_PARM, lineno + 1, 0))))) {\n\t\tn = m;\n\t    }\n\n\t}\n#endif\n    } else {\n\tNCURSES_CH_T blank;\n\n\t\/* it may be cheap to clear leading whitespace with clr_bol *\/\n\tblank = newLine[0];\n\tif (clr_bol && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {\n\t    int oFirstChar, nFirstChar;\n\n\t    for (oFirstChar = 0;\n\t\t oFirstChar < screen_columns(SP_PARM);\n\t\t oFirstChar++)\n\t\tif (!CharEq(oldLine[oFirstChar], blank))\n\t\t    break;\n\t    for (nFirstChar = 0;\n\t\t nFirstChar < screen_columns(SP_PARM);\n\t\t nFirstChar++)\n\t\tif (!CharEq(newLine[nFirstChar], blank))\n\t\t    break;\n\n\t    if (nFirstChar == oFirstChar) {\n\t\tfirstChar = nFirstChar;\n\t\t\/* find the first differing character *\/\n\t\twhile (firstChar < screen_columns(SP_PARM)\n\t\t       && CharEq(newLine[firstChar], oldLine[firstChar]))\n\t\t    firstChar++;\n\t    } else if (oFirstChar > nFirstChar) {\n\t\tfirstChar = nFirstChar;\n\t    } else {\t\t\/* oFirstChar < nFirstChar *\/\n\t\tfirstChar = oFirstChar;\n\t\tif (SP_PARM->_el1_cost < nFirstChar - oFirstChar) {\n\t\t    if (nFirstChar >= screen_columns(SP_PARM)\n\t\t\t&& SP_PARM->_el_cost <= SP_PARM->_el1_cost) {\n\t\t\tGoTo(NCURSES_SP_ARGx lineno, 0);\n\t\t\tUpdateAttrs(SP_PARM, blank);\n\t\t\tNCURSES_PUTP2(\"clr_eol\", clr_eol);\n\t\t    } else {\n\t\t\tGoTo(NCURSES_SP_ARGx lineno, nFirstChar - 1);\n\t\t\tUpdateAttrs(SP_PARM, blank);\n\t\t\tNCURSES_PUTP2(\"clr_bol\", clr_bol);\n\t\t    }\n\n\t\t    while (firstChar < nFirstChar)\n\t\t\toldLine[firstChar++] = blank;\n\t\t}\n\t    }\n\t} else {\n\t    \/* find the first differing character *\/\n\t    while (firstChar < screen_columns(SP_PARM)\n\t\t   && CharEq(newLine[firstChar], oldLine[firstChar]))\n\t\tfirstChar++;\n\t}\n\t\/* if there wasn't one, we're done *\/\n\tif (firstChar >= screen_columns(SP_PARM)) {\n\t    TR(TRACE_UPDATE, (T_RETURN(\"\")));\n\t    return;\n\t}\n\n\tblank = newLine[screen_columns(SP_PARM) - 1];\n\n\tif (!can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {\n\t    \/* find the last differing character *\/\n\t    nLastChar = screen_columns(SP_PARM) - 1;\n\n\t    while (nLastChar > firstChar\n\t\t   && CharEq(newLine[nLastChar], oldLine[nLastChar]))\n\t\tnLastChar--;\n\n\t    if (nLastChar >= firstChar) {\n\t\tGoTo(NCURSES_SP_ARGx lineno, firstChar);\n\t\tPutRange(NCURSES_SP_ARGx\n\t\t\t oldLine,\n\t\t\t newLine,\n\t\t\t lineno,\n\t\t\t firstChar,\n\t\t\t nLastChar);\n\t\tmemcpy(oldLine + firstChar,\n\t\t       newLine + firstChar,\n\t\t       (unsigned) (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));\n\t    }\n\t    TR(TRACE_UPDATE, (T_RETURN(\"\")));\n\t    return;\n\t}\n\n\t\/* find last non-blank character on old line *\/\n\toLastChar = screen_columns(SP_PARM) - 1;\n\twhile (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))\n\t    oLastChar--;\n\n\t\/* find last non-blank character on new line *\/\n\tnLastChar = screen_columns(SP_PARM) - 1;\n\twhile (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))\n\t    nLastChar--;\n\n\tif ((nLastChar == firstChar)\n\t    && (SP_PARM->_el_cost < (oLastChar - nLastChar))) {\n\t    GoTo(NCURSES_SP_ARGx lineno, firstChar);\n\t    if (!CharEq(newLine[firstChar], blank))\n\t\tPutChar(NCURSES_SP_ARGx CHREF(newLine[firstChar]));\n\t    ClrToEOL(NCURSES_SP_ARGx blank, FALSE);\n\t} else if ((nLastChar != oLastChar)\n\t\t   && (!CharEq(newLine[nLastChar], oldLine[oLastChar])\n\t\t       || !(SP_PARM->_nc_sp_idcok\n\t\t\t    && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)))) {\n\t    GoTo(NCURSES_SP_ARGx lineno, firstChar);\n\t    if ((oLastChar - nLastChar) > SP_PARM->_el_cost) {\n\t\tif (PutRange(NCURSES_SP_ARGx\n\t\t\t     oldLine,\n\t\t\t     newLine,\n\t\t\t     lineno,\n\t\t\t     firstChar,\n\t\t\t     nLastChar)) {\n\t\t    GoTo(NCURSES_SP_ARGx lineno, nLastChar + 1);\n\t\t}\n\t\tClrToEOL(NCURSES_SP_ARGx blank, FALSE);\n\t    } else {\n\t\tn = max(nLastChar, oLastChar);\n\t\tPutRange(NCURSES_SP_ARGx\n\t\t\t oldLine,\n\t\t\t newLine,\n\t\t\t lineno,\n\t\t\t firstChar,\n\t\t\t n);\n\t    }\n\t} else {\n\t    int nLastNonblank = nLastChar;\n\t    int oLastNonblank = oLastChar;\n\n\t    \/* find the last characters that really differ *\/\n\t    \/* can be -1 if no characters differ *\/\n\t    while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {\n\t\t\/* don't split a wide char *\/\n\t\tif (isWidecExt(newLine[nLastChar]) &&\n\t\t    !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))\n\t\t    break;\n\t\tnLastChar--;\n\t\toLastChar--;\n\t\tif (nLastChar == -1 || oLastChar == -1)\n\t\t    break;\n\t    }\n\n\t    n = min(oLastChar, nLastChar);\n\t    if (n >= firstChar) {\n\t\tGoTo(NCURSES_SP_ARGx lineno, firstChar);\n\t\tPutRange(NCURSES_SP_ARGx\n\t\t\t oldLine,\n\t\t\t newLine,\n\t\t\t lineno,\n\t\t\t firstChar,\n\t\t\t n);\n\t    }\n\n\t    if (oLastChar < nLastChar) {\n\t\tint m = max(nLastNonblank, oLastNonblank);\n#if USE_WIDEC_SUPPORT\n\t\tif (n) {\n\t\t    while (isWidecExt(newLine[n + 1]) && n) {\n\t\t\t--n;\n\t\t\t--oLastChar;\t\/* increase cost *\/\n\t\t    }\n\t\t} else if (n >= firstChar &&\n\t\t\t   isWidecBase(newLine[n])) {\n\t\t    while (isWidecExt(newLine[n + 1])) {\n\t\t\t++n;\n\t\t\t++oLastChar;\t\/* decrease cost *\/\n\t\t    }\n\t\t}\n#endif\n\t\tGoTo(NCURSES_SP_ARGx lineno, n + 1);\n\t\tif ((nLastChar < nLastNonblank)\n\t\t    || InsCharCost(SP_PARM, nLastChar - oLastChar) > (m - n)) {\n\t\t    PutRange(NCURSES_SP_ARGx\n\t\t\t     oldLine,\n\t\t\t     newLine,\n\t\t\t     lineno,\n\t\t\t     n + 1,\n\t\t\t     m);\n\t\t} else {\n\t\t    InsStr(NCURSES_SP_ARGx &newLine[n + 1], nLastChar - oLastChar);\n\t\t}\n\t    } else if (oLastChar > nLastChar) {\n\t\tGoTo(NCURSES_SP_ARGx lineno, n + 1);\n\t\tif (DelCharCost(SP_PARM, oLastChar - nLastChar)\n\t\t    > SP_PARM->_el_cost + nLastNonblank - (n + 1)) {\n\t\t    if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,\n\t\t\t\t n + 1, nLastNonblank)) {\n\t\t\tGoTo(NCURSES_SP_ARGx lineno, nLastNonblank + 1);\n\t\t    }\n\t\t    ClrToEOL(NCURSES_SP_ARGx blank, FALSE);\n\t\t} else {\n\t\t    \/*\n\t\t     * The delete-char sequence will\n\t\t     * effectively shift in blanks from the\n\t\t     * right margin of the screen.  Ensure\n\t\t     * that they are the right color by\n\t\t     * setting the video attributes from\n\t\t     * the last character on the row.\n\t\t     *\/\n\t\t    UpdateAttrs(SP_PARM, blank);\n\t\t    DelChar(NCURSES_SP_ARGx oLastChar - nLastChar);\n\t\t}\n\t    }\n\t}\n    }\n\n    \/* update the code's internal representation *\/\n    if (screen_columns(SP_PARM) > firstChar)\n\tmemcpy(oldLine + firstChar,\n\t       newLine + firstChar,\n\t       (unsigned) (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T));\n    TR(TRACE_UPDATE, (T_RETURN(\"\")));\n    return;\n}","target":0,"code_token_length":2942,"total_token_length":3178,"max_tokens_setting":4096}
+{"idx":432691,"func":"static void util_set_brush(wmfAPI *API, wmfDC *dc,const BrushApply brush_apply)\n{\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  wmfBrush\n    *brush = WMF_DC_BRUSH(dc);\n\n  \/* Set polygon fill rule *\/\n  switch (WMF_DC_POLYFILL(dc))  \/* Is this correct ?? *\/\n    {\n    case WINDING:\n      DrawSetClipRule(WmfDrawingWand,NonZeroRule);\n      break;\n\n    case ALTERNATE:\n    default:\n      DrawSetClipRule(WmfDrawingWand,EvenOddRule);\n      break;\n    }\n\n  switch (WMF_BRUSH_STYLE(brush))\n    {\n    case BS_SOLID \/* 0 *\/:\n      \/* WMF_BRUSH_COLOR specifies brush color, WMF_BRUSH_HATCH\n         ignored *\/\n      {\n        if ( brush_apply == BrushApplyStroke )\n          draw_stroke_color_rgb(API,WMF_BRUSH_COLOR(brush));\n        else\n          draw_fill_color_rgb(API,WMF_BRUSH_COLOR(brush));\n        break;\n      }\n    case BS_HOLLOW \/* 1 *\/:    \/* BS_HOLLOW & BS_NULL share enum *\/\n      \/* WMF_BRUSH_COLOR and WMF_BRUSH_HATCH ignored *\/\n      {\n        if ( brush_apply == BrushApplyStroke )\n          draw_stroke_color_string(WmfDrawingWand,\"none\");\n        else\n          draw_fill_color_string(WmfDrawingWand,\"none\");\n        break;\n      }\n    case BS_HATCHED \/* 2 *\/:\n      \/* WMF_BRUSH_COLOR specifies the hatch color, WMF_BRUSH_HATCH\n         specifies the hatch brush style. If WMF_DC_OPAQUE, then\n         WMF_DC_BACKGROUND specifies hatch background color.  *\/\n      {\n        DrawPushDefs(WmfDrawingWand);\n        draw_pattern_push(API, ddata->pattern_id, 8, 8);\n        (void) PushDrawingWand(WmfDrawingWand);\n\n        if (WMF_DC_OPAQUE(dc))\n          {\n            if ( brush_apply == BrushApplyStroke )\n              draw_stroke_color_rgb(API,WMF_DC_BACKGROUND(dc));\n            else\n              draw_fill_color_rgb(API,WMF_DC_BACKGROUND(dc));\n\n            DrawRectangle(WmfDrawingWand, 0, 0, 7, 7 );\n          }\n\n        DrawSetStrokeAntialias(WmfDrawingWand, MagickFalse);\n        DrawSetStrokeWidth(WmfDrawingWand, 1);\n\n        draw_stroke_color_rgb(API,WMF_BRUSH_COLOR(brush));\n\n        switch ((unsigned int) WMF_BRUSH_HATCH(brush))\n          {\n\n          case HS_HORIZONTAL:  \/* ----- *\/\n            {\n              DrawLine(WmfDrawingWand, 0, 3, 7,3);\n              break;\n            }\n          case HS_VERTICAL:  \/* ||||| *\/\n            {\n              DrawLine(WmfDrawingWand, 3, 0, 3, 7);\n              break;\n            }\n          case HS_FDIAGONAL:  \/* \\\\\\\\\\ *\/\n            {\n              DrawLine(WmfDrawingWand, 0, 0, 7, 7);\n              break;\n            }\n          case HS_BDIAGONAL:  \/* \/ *\/\n            {\n              DrawLine(WmfDrawingWand, 0, 7, 7, 0 );\n              break;\n            }\n          case HS_CROSS:  \/* +++++ *\/\n            {\n              DrawLine(WmfDrawingWand, 0, 3, 7, 3 );\n              DrawLine(WmfDrawingWand, 3, 0, 3, 7 );\n              break;\n            }\n          case HS_DIAGCROSS:  \/* xxxxx *\/\n            {\n              DrawLine(WmfDrawingWand, 0, 0, 7, 7 );\n              DrawLine(WmfDrawingWand, 0, 7, 7, 0 );\n              break;\n            }\n          default:\n            {\n              printf(\"util_set_brush: unexpected brush hatch enumeration %u\\n\",\n                     (unsigned int)WMF_BRUSH_HATCH(brush));\n            }\n          }\n        (void) PopDrawingWand(WmfDrawingWand);\n        (void) DrawPopPattern(WmfDrawingWand);\n        DrawPopDefs(WmfDrawingWand);\n        {\n          char\n            pattern_id[MagickPathExtent];\n\n          (void) FormatLocaleString(pattern_id,MagickPathExtent,\"#brush_%lu\",\n            ddata->pattern_id);\n          if (brush_apply == BrushApplyStroke )\n            (void) DrawSetStrokePatternURL(WmfDrawingWand,pattern_id);\n          else\n            (void) DrawSetFillPatternURL(WmfDrawingWand,pattern_id);\n          ++ddata->pattern_id;\n        }\n        break;\n      }\n    case BS_PATTERN \/* 3 *\/:\n      \/* WMF_BRUSH_COLOR ignored, WMF_BRUSH_HATCH provides handle to\n         bitmap *\/\n      {\n        printf(\"util_set_brush: BS_PATTERN not supported\\n\");\n        break;\n      }\n    case BS_INDEXED \/* 4 *\/:\n      {\n        printf(\"util_set_brush: BS_INDEXED not supported\\n\");\n        break;\n      }\n    case BS_DIBPATTERN \/* 5 *\/:\n      {\n        wmfBMP\n          *brush_bmp = WMF_BRUSH_BITMAP(brush);\n\n        if (brush_bmp && brush_bmp->data != 0)\n          {\n            CompositeOperator\n              mode;\n\n            const Image\n              *image;\n\n            MagickWand\n              *magick_wand;\n\n            image = (Image*)brush_bmp->data;\n\n            mode = CopyCompositeOp;  \/* Default is copy *\/\n            switch (WMF_DC_ROP(dc))\n              {\n                \/* Binary raster ops *\/\n              case R2_BLACK:\n                printf(\"util_set_brush: R2_BLACK ROP2 mode not supported!\\n\");\n                break;\n              case R2_NOTMERGEPEN:\n                printf(\"util_set_brush: R2_NOTMERGEPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_MASKNOTPEN:\n                printf(\"util_set_brush R2_MASKNOTPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_NOTCOPYPEN:\n                printf(\"util_set_brush: R2_NOTCOPYPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_MASKPENNOT:\n                printf(\"util_set_brush: R2_MASKPENNOT ROP2 mode not supported!\\n\");\n                break;\n              case R2_NOT:\n                printf(\"util_set_brush: R2_NOT ROP2 mode not supported!\\n\");\n                break;\n              case R2_XORPEN:\n                printf(\"util_set_brush: R2_XORPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_NOTMASKPEN:\n                printf(\"util_set_brush: R2_NOTMASKPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_MASKPEN:\n                printf(\"util_set_brush: R2_MASKPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_NOTXORPEN:\n                printf(\"util_set_brush: R2_NOTXORPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_NOP:\n                printf(\"util_set_brush: R2_NOP ROP2 mode not supported!\\n\");\n                break;\n              case R2_MERGENOTPEN:\n                printf(\"util_set_brush: R2_MERGENOTPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_COPYPEN:\n                mode = CopyCompositeOp;\n                break;\n              case R2_MERGEPENNOT:\n                printf(\"util_set_brush: R2_MERGEPENNOT ROP2 mode not supported!\\n\");\n                break;\n              case R2_MERGEPEN:\n                printf(\"util_set_brush: R2_MERGEPEN ROP2 mode not supported!\\n\");\n                break;\n              case R2_WHITE:\n                printf(\"util_set_brush: R2_WHITE ROP2 mode not supported!\\n\");\n                break;\n              default:\n                {\n                  printf(\"util_set_brush: unexpected ROP2 enumeration %u!\\n\",\n                         (unsigned int)WMF_DC_ROP(dc));\n                }\n              }\n\n            DrawPushDefs(WmfDrawingWand);\n            draw_pattern_push(API, ddata->pattern_id, brush_bmp->width,\n              brush_bmp->height);\n            magick_wand=NewMagickWandFromImage(image);\n            (void) DrawComposite(WmfDrawingWand,mode, 0, 0, brush_bmp->width,\n              brush_bmp->height, magick_wand);\n            magick_wand=DestroyMagickWand(magick_wand);\n            (void) DrawPopPattern(WmfDrawingWand);\n            DrawPopDefs(WmfDrawingWand);\n\n            {\n              char\n                pattern_id[MagickPathExtent];\n\n              (void) FormatLocaleString(pattern_id,MagickPathExtent,\"#brush_%lu\",\n                ddata->pattern_id);\n              if ( brush_apply == BrushApplyStroke )\n                (void) DrawSetStrokePatternURL(WmfDrawingWand,pattern_id);\n              else\n                (void) DrawSetFillPatternURL(WmfDrawingWand,pattern_id);\n              ++ddata->pattern_id;\n            }\n          }\n        else\n          printf(\"util_set_brush: no BMP image data!\\n\");\n\n        break;\n      }\n    case BS_DIBPATTERNPT \/* 6 *\/:\n      \/* WMF_BRUSH_COLOR ignored, WMF_BRUSH_HATCH provides pointer to\n         DIB *\/\n      {\n        printf(\"util_set_brush: BS_DIBPATTERNPT not supported\\n\");\n        break;\n      }\n    case BS_PATTERN8X8 \/* 7 *\/:\n      {\n        printf(\"util_set_brush: BS_PATTERN8X8 not supported\\n\");\n        break;\n      }\n    case BS_DIBPATTERN8X8 \/* 8 *\/:\n      {\n        printf(\"util_set_brush: BS_DIBPATTERN8X8 not supported\\n\");\n        break;\n      }\n    default:\n      {\n      }\n    }\n}","target":0,"code_token_length":2194,"total_token_length":2430,"max_tokens_setting":4096}
+{"idx":195549,"func":"bool JSON_parser(Variant &z, const char *p, int length, bool const assoc,\n                 int depth, int64_t options) {\n  \/\/ No GC safepoints during JSON parsing, please. Code is not re-entrant.\n  NoHandleSurpriseScope no_surprise(SafepointFlags);\n\n  json_parser *json = s_json_parser.get(); \/* the parser state *\/\n  \/\/ Clear and reuse the thread-local string buffers. They are only freed if\n  \/\/ they exceed kMaxPersistentStringBufferCapacity at exit or if the thread\n  \/\/ is explicitly flushed (e.g., due to being idle).\n  json->initSb(length);\n  SCOPE_EXIT {\n    constexpr int kMaxPersistentStringBufferCapacity = 256 * 1024;\n    if (json->sb_cap > kMaxPersistentStringBufferCapacity) json->flushSb();\n  };\n  \/\/ SimpleParser only handles the most common set of options. Also, only use it\n  \/\/ if its array nesting depth check is *more* restrictive than what the user\n  \/\/ asks for, to ensure that the precise semantics of the general case is\n  \/\/ applied for all nesting overflows.\n  if (assoc &&\n      options == (options & (k_JSON_FB_LOOSE |\n                             k_JSON_FB_DARRAYS |\n                             k_JSON_FB_DARRAYS_AND_VARRAYS |\n                             k_JSON_FB_HACK_ARRAYS |\n                             k_JSON_FB_THRIFT_SIMPLE_JSON |\n                             k_JSON_FB_LEGACY_HACK_ARRAYS)) &&\n      depth >= SimpleParser::kMaxArrayDepth &&\n      length <= RuntimeOption::EvalSimpleJsonMaxLength &&\n      SimpleParser::TryParse(p, length, json->tl_buffer.tv, z,\n                             get_container_type_from_options(options),\n                             options & k_JSON_FB_THRIFT_SIMPLE_JSON)) {\n    return true;\n  }\n\n  int b;  \/* the next character *\/\n  int c;  \/* the next character class *\/\n  int s;  \/* the next state *\/\n  int state = 0;\n\n  \/*<fb>*\/\n  bool const loose = options & k_JSON_FB_LOOSE;\n  JSONContainerType const container_type =\n    get_container_type_from_options(options);\n  int qchr = 0;\n  int8_t const *byte_class;\n  int8_t const (*next_state_table)[32];\n  if (loose) {\n    byte_class = loose_ascii_class;\n    next_state_table = loose_state_transition_table;\n  } else {\n    byte_class = ascii_class;\n    next_state_table = state_transition_table;\n  }\n  \/*<\/fb>*\/\n\n  UncheckedBuffer *buf = &json->sb_buf;\n  UncheckedBuffer *key = &json->sb_key;\n\n  DataType type = kInvalidDataType;\n  unsigned short escaped_bytes = 0;\n\n  auto reset_type = [&] { type = kInvalidDataType; };\n\n  json->depth = depth;\n  \/\/ Since the stack is maintainined on a per request basis, for performance\n  \/\/ reasons, it only makes sense to expand if necessary and cycles are wasted\n  \/\/ contracting. Calls with a depth other than default should be rare.\n  if (depth > json->stack.size()) {\n    json->stack.resize(depth);\n  }\n  SCOPE_EXIT {\n    if (json->stack.empty()) return;\n    for (int i = 0; i <= json->mark; i++) {\n      json->stack[i].key.reset();\n      json->stack[i].val.unset();\n    }\n    json->mark = -1;\n  };\n\n  json->mark = json->top = -1;\n  push(json, Mode::DONE);\n\n  UTF8To16Decoder decoder(p, length, loose);\n  for (;;) {\n    b = decoder.decode();\n    \/\/ Fast-case most common transition: append a simple string character.\n    if (state == 3 && type == KindOfString) {\n      while (b != '\\\"' &&  b != '\\\\' && b != '\\'' && b <= 127 && b >= ' ') {\n        buf->append((char)b);\n        b = decoder.decode();\n      }\n    }\n    if (b == UTF8_END) break; \/\/ UTF-8 decoding finishes successfully.\n    if (b == UTF8_ERROR) {\n      s_json_parser->error_code = JSON_ERROR_UTF8;\n      return false;\n    }\n    assertx(b >= 0);\n\n    if ((b & 127) == b) {\n      \/*<fb>*\/\n      c = byte_class[b];\n      \/*<\/fb>*\/\n      if (c <= S_ERR) {\n        s_json_parser->error_code = JSON_ERROR_CTRL_CHAR;\n        return false;\n      }\n    } else {\n      c = S_ETC;\n    }\n    \/*\n      Get the next state from the transition table.\n    *\/\n\n    \/*<fb>*\/\n    s = next_state_table[state][c];\n\n    if (s == -4) {\n      if (b != qchr) {\n        s = 3;\n      } else {\n        qchr = 0;\n      }\n    }\n    \/*<\/fb>*\/\n\n    if (s < 0) {\n      \/*\n        Perform one of the predefined actions.\n      *\/\n      switch (s) {\n        \/*\n          empty }\n        *\/\n      case -9:\n        \/*<fb>*\/\n        if (json->top == 1) z = json->stack[json->top].val;\n        else {\n        \/*<\/fb>*\/\n          attach_zval(json, json->stack[json->top].key, assoc, container_type);\n        \/*<fb>*\/\n        }\n        \/*<\/fb>*\/\n        if (!pop(json, Mode::KEY)) {\n          return false;\n        }\n        state = 9;\n        break;\n        \/*\n          {\n        *\/\n      case -8:\n        if (!push(json, Mode::KEY)) {\n          s_json_parser->error_code = JSON_ERROR_DEPTH;\n          return false;\n        }\n\n        state = 1;\n        if (json->top > 0) {\n          Variant &top = json->stack[json->top].val;\n          \/*<fb>*\/\n          if (container_type == JSONContainerType::COLLECTIONS) {\n            \/\/ stable_maps is meaningless\n            top = req::make<c_Map>();\n          } else {\n          \/*<\/fb>*\/\n            if (!assoc) {\n              top = SystemLib::AllocStdClassObject();\n            \/* <fb> *\/\n            } else if (container_type == JSONContainerType::HACK_ARRAYS) {\n              top = Array::CreateDict();\n            } else if (container_type == JSONContainerType::DARRAYS ||\n                       container_type == JSONContainerType::DARRAYS_AND_VARRAYS)\n            {\n              top = Array::CreateDArray();\n            \/* <\/fb> *\/\n            } else if (\n              container_type == JSONContainerType::LEGACY_HACK_ARRAYS) {\n              auto arr = staticEmptyDictArray()->copy();\n              arr->setLegacyArray(true);\n              top = arr;\n            } else {\n              top = Array::CreateDArray();\n            }\n          \/*<fb>*\/\n          }\n          \/*<\/fb>*\/\n          json->stack[json->top].key = copy_and_clear(*key);\n          reset_type();\n        }\n        break;\n        \/*\n          }\n        *\/\n      case -7:\n        \/*** BEGIN Facebook: json_utf8_loose ***\/\n        \/*\n          If this is a trailing comma in an object definition,\n          we're in Mode::KEY. In that case, throw that off the\n          stack and restore Mode::OBJECT so that we pretend the\n          trailing comma just didn't happen.\n        *\/\n        if (loose) {\n          if (pop(json, Mode::KEY)) {\n            push(json, Mode::OBJECT);\n          }\n        }\n        \/*** END Facebook: json_utf8_loose ***\/\n\n        if (type != kInvalidDataType &&\n            json->stack[json->top].mode == Mode::OBJECT) {\n          Variant mval;\n          json_create_zval(mval, *buf, type, options);\n          Variant &top = json->stack[json->top].val;\n          object_set(json, top, copy_and_clear(*key),\n                     mval, assoc, container_type);\n          buf->clear();\n          reset_type();\n        }\n\n        \/*<fb>*\/\n        if (json->top == 1) z = json->stack[json->top].val;\n        else {\n        \/*<\/fb>*\/\n          attach_zval(json, json->stack[json->top].key,\n            assoc, container_type);\n        \/*<fb>*\/\n        }\n        \/*<\/fb>*\/\n        if (!pop(json, Mode::OBJECT)) {\n          s_json_parser->error_code = JSON_ERROR_STATE_MISMATCH;\n          return false;\n        }\n        state = 9;\n        break;\n        \/*\n          [\n        *\/\n      case -6:\n        if (!push(json, Mode::ARRAY)) {\n          s_json_parser->error_code = JSON_ERROR_DEPTH;\n          return false;\n        }\n        state = 2;\n\n        if (json->top > 0) {\n          Variant &top = json->stack[json->top].val;\n          \/*<fb>*\/\n          if (container_type == JSONContainerType::COLLECTIONS) {\n            top = req::make<c_Vector>();\n          } else if (container_type == JSONContainerType::HACK_ARRAYS) {\n            top = Array::CreateVec();\n          } else if (container_type == JSONContainerType::DARRAYS_AND_VARRAYS) {\n            top = Array::CreateVArray();\n          } else if (container_type == JSONContainerType::DARRAYS) {\n            top = Array::CreateDArray();\n          } else if (container_type == JSONContainerType::LEGACY_HACK_ARRAYS) {\n            auto arr = staticEmptyVecArray()->copy();\n            arr->setLegacyArray(true);\n            top = arr;\n          } else {\n            top = Array::CreateDArray();\n          }\n          \/*<\/fb>*\/\n          json->stack[json->top].key = copy_and_clear(*key);\n          reset_type();\n        }\n        break;\n        \/*\n          ]\n        *\/\n      case -5:\n        {\n          if (type != kInvalidDataType &&\n               json->stack[json->top].mode == Mode::ARRAY) {\n            Variant mval;\n            json_create_zval(mval, *buf, type, options);\n            auto& top = json->stack[json->top].val;\n            if (container_type == JSONContainerType::COLLECTIONS) {\n              collections::append(top.getObjectData(), mval.asTypedValue());\n            } else {\n              top.asArrRef().append(mval);\n            }\n            buf->clear();\n            reset_type();\n          }\n\n          \/*<fb>*\/\n          if (json->top == 1) z = json->stack[json->top].val;\n          else {\n          \/*<\/fb>*\/\n            attach_zval(json, json->stack[json->top].key, assoc,\n              container_type);\n          \/*<fb>*\/\n          }\n          \/*<\/fb>*\/\n          if (!pop(json, Mode::ARRAY)) {\n            s_json_parser->error_code = JSON_ERROR_STATE_MISMATCH;\n            return false;\n          }\n          state = 9;\n        }\n        break;\n        \/*\n          \"\n        *\/\n      case -4:\n        switch (json->stack[json->top].mode) {\n        case Mode::KEY:\n          state = 27;\n          std::swap(buf, key);\n          reset_type();\n          break;\n        case Mode::ARRAY:\n        case Mode::OBJECT:\n          state = 9;\n          break;\n        case Mode::DONE:\n          if (type == KindOfString) {\n            z = copy_and_clear(*buf);\n            state = 9;\n            break;\n          }\n          \/* fall through if not KindOfString *\/\n        default:\n          s_json_parser->error_code = JSON_ERROR_SYNTAX;\n          return false;\n        }\n        break;\n        \/*\n          ,\n        *\/\n      case -3:\n        {\n          Variant mval;\n          if (type != kInvalidDataType &&\n              (json->stack[json->top].mode == Mode::OBJECT ||\n               json->stack[json->top].mode == Mode::ARRAY)) {\n            json_create_zval(mval, *buf, type, options);\n          }\n\n          switch (json->stack[json->top].mode) {\n          case Mode::OBJECT:\n            if (pop(json, Mode::OBJECT) &&\n                push(json, Mode::KEY)) {\n              if (type != kInvalidDataType) {\n                Variant &top = json->stack[json->top].val;\n                object_set(\n                  json,\n                  top,\n                  copy_and_clear(*key),\n                  mval,\n                  assoc,\n                  container_type\n                );\n              }\n              state = 29;\n            }\n            break;\n          case Mode::ARRAY:\n            if (type != kInvalidDataType) {\n              auto& top = json->stack[json->top].val;\n              if (container_type == JSONContainerType::COLLECTIONS) {\n                collections::append(top.getObjectData(), mval.asTypedValue());\n              } else {\n                top.asArrRef().append(mval);\n              }\n            }\n            state = 28;\n            break;\n          default:\n            s_json_parser->error_code = JSON_ERROR_SYNTAX;\n            return false;\n          }\n          buf->clear();\n          reset_type();\n          check_non_safepoint_surprise();\n        }\n        break;\n\n        \/*<fb>*\/\n        \/*\n          : (after unquoted string)\n        *\/\n      case -10:\n        if (json->stack[json->top].mode == Mode::KEY) {\n          state = 27;\n          std::swap(buf, key);\n          reset_type();\n          s = -2;\n        } else {\n          s = 3;\n          break;\n        }\n        \/*<\/fb>*\/\n\n        \/*\n          :\n        *\/\n      case -2:\n        if (pop(json, Mode::KEY) && push(json, Mode::OBJECT)) {\n          state = 28;\n          break;\n        }\n        \/*\n          syntax error\n        *\/\n      case -1:\n        s_json_parser->error_code = JSON_ERROR_SYNTAX;\n        return false;\n      }\n    } else {\n      \/*\n        Change the state and iterate.\n      *\/\n      bool is_tsimplejson = options & k_JSON_FB_THRIFT_SIMPLE_JSON;\n      if (type == KindOfString) {\n        if (\/*<fb>*\/(\/*<\/fb>*\/s == 3\/*<fb>*\/ || s == 30)\/*<\/fb>*\/ &&\n            state != 8) {\n          if (state != 4) {\n            utf16_to_utf8(*buf, b);\n          } else {\n            switch (b) {\n            case 'b': buf->append('\\b'); break;\n            case 't': buf->append('\\t'); break;\n            case 'n': buf->append('\\n'); break;\n            case 'f': buf->append('\\f'); break;\n            case 'r': buf->append('\\r'); break;\n            default:\n              utf16_to_utf8(*buf, b);\n              break;\n            }\n          }\n        } else if (s == 6) {\n          if (UNLIKELY(is_tsimplejson)) {\n            if (UNLIKELY(b != '0'))  {\n              s_json_parser->error_code = JSON_ERROR_SYNTAX;\n              return false;\n            }\n            escaped_bytes = 0;\n          } else {\n            escaped_bytes = dehexchar(b) << 12;\n          }\n        } else if (s == 7) {\n          if (UNLIKELY(is_tsimplejson)) {\n            if (UNLIKELY(b != '0'))  {\n              s_json_parser->error_code = JSON_ERROR_SYNTAX;\n              return false;\n            }\n          } else {\n            escaped_bytes += dehexchar(b) << 8;\n          }\n        } else if (s == 8) {\n          escaped_bytes += dehexchar(b) << 4;\n        } else if (s == 3 && state == 8) {\n          escaped_bytes += dehexchar(b);\n          if (UNLIKELY(is_tsimplejson)) {\n            buf->append((char)escaped_bytes);\n          } else {\n            utf16_to_utf8(*buf, escaped_bytes);\n          }\n        }\n      } else if ((type == kInvalidDataType || type == KindOfNull) &&\n                 (c == S_DIG || c == S_ZER)) {\n        type = KindOfInt64;\n        buf->append((char)b);\n      } else if (type == KindOfInt64 && s == 24) {\n        type = KindOfDouble;\n        buf->append((char)b);\n      } else if ((type == kInvalidDataType || type == KindOfNull ||\n                  type == KindOfInt64) &&\n                 c == S_DOT) {\n        type = KindOfDouble;\n        buf->append((char)b);\n      } else if (type != KindOfString && c == S_QUO) {\n        type = KindOfString;\n        \/*<fb>*\/qchr = b;\/*<\/fb>*\/\n      } else if ((type == kInvalidDataType || type == KindOfNull ||\n                  type == KindOfInt64 || type == KindOfDouble) &&\n                 ((state == 12 && s == 9) ||\n                  (state == 16 && s == 9))) {\n        type = KindOfBoolean;\n      } else if (type == kInvalidDataType && state == 19 && s == 9) {\n        type = KindOfNull;\n      } else if (type != KindOfString && c > S_WSP) {\n        utf16_to_utf8(*buf, b);\n      }\n\n      state = s;\n    }\n  }\n\n  if (state == 9 && pop(json, Mode::DONE)) {\n    s_json_parser->error_code = JSON_ERROR_NONE;\n    return true;\n  }\n\n  s_json_parser->error_code = JSON_ERROR_SYNTAX;\n  return false;\n}","target":1,"code_token_length":3769,"total_token_length":4005,"max_tokens_setting":4096}
+{"idx":473821,"func":"onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,\n    OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end,\n    OnigCaseFoldCodeItem items[])\n{\n  int n, i, j, k, len;\n  OnigCodePoint code, codes[3];\n  CodePointList3 *to, *z3;\n  CodePointList2 *z2;\n\n  if (CaseFoldInited == 0) init_case_fold_table();\n\n  n = 0;\n\n  code = ONIGENC_MBC_TO_CODE(enc, p, end);\n  len = enclen(enc, p, end);\n\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n  if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {\n    if (code == 0x0049) {\n      items[0].byte_len = len;\n      items[0].code_len = 1;\n      items[0].code[0]  = 0x0131;\n      return 1;\n    }\n    else if (code == 0x0130) {\n      items[0].byte_len = len;\n      items[0].code_len = 1;\n      items[0].code[0]  = 0x0069;\n      return 1;\n    }\n    else if (code == 0x0131) {\n      items[0].byte_len = len;\n      items[0].code_len = 1;\n      items[0].code[0]  = 0x0049;\n      return 1;\n    }\n    else if (code == 0x0069) {\n      items[0].byte_len = len;\n      items[0].code_len = 1;\n      items[0].code[0]  = 0x0130;\n      return 1;\n    }\n  }\n#endif\n\n  if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) {\n    if (to->n == 1) {\n      OnigCodePoint orig_code = code;\n\n      items[0].byte_len = len;\n      items[0].code_len = 1;\n      items[0].code[0]  = to->code[0];\n      n++;\n\n      code = to->code[0];\n      if (onig_st_lookup(Unfold1Table, (st_data_t )code, (void* )&to) != 0) {\n\tfor (i = 0; i < to->n; i++) {\n\t  if (to->code[i] != orig_code) {\n\t    items[n].byte_len = len;\n\t    items[n].code_len = 1;\n\t    items[n].code[0]  = to->code[i];\n\t    n++;\n\t  }\n\t}\n      }\n    }\n    else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n      OnigCodePoint cs[3][4];\n      int fn, ncs[3];\n\n      for (fn = 0; fn < to->n; fn++) {\n\tcs[fn][0] = to->code[fn];\n\tif (onig_st_lookup(Unfold1Table, (st_data_t )cs[fn][0],\n\t\t\t   (void* )&z3) != 0) {\n\t  for (i = 0; i < z3->n; i++) {\n\t    cs[fn][i+1] = z3->code[i];\n\t  }\n\t  ncs[fn] = z3->n + 1;\n\t}\n\telse\n\t  ncs[fn] = 1;\n      }\n\n      if (fn == 2) {\n\tfor (i = 0; i < ncs[0]; i++) {\n\t  for (j = 0; j < ncs[1]; j++) {\n\t    items[n].byte_len = len;\n\t    items[n].code_len = 2;\n\t    items[n].code[0]  = cs[0][i];\n\t    items[n].code[1]  = cs[1][j];\n\t    n++;\n\t  }\n\t}\n\n\tif (onig_st_lookup(Unfold2Table, (st_data_t )to->code,\n\t\t\t   (void* )&z2) != 0) {\n\t  for (i = 0; i < z2->n; i++) {\n\t    if (z2->code[i] == code) continue;\n\n\t    items[n].byte_len = len;\n\t    items[n].code_len = 1;\n\t    items[n].code[0]  = z2->code[i];\n\t    n++;\n\t  }\n\t}\n      }\n      else {\n\tfor (i = 0; i < ncs[0]; i++) {\n\t  for (j = 0; j < ncs[1]; j++) {\n\t    for (k = 0; k < ncs[2]; k++) {\n\t      items[n].byte_len = len;\n\t      items[n].code_len = 3;\n\t      items[n].code[0]  = cs[0][i];\n\t      items[n].code[1]  = cs[1][j];\n\t      items[n].code[2]  = cs[2][k];\n\t      n++;\n\t    }\n\t  }\n\t}\n\n\tif (onig_st_lookup(Unfold3Table, (st_data_t )to->code,\n\t\t\t   (void* )&z2) != 0) {\n\t  for (i = 0; i < z2->n; i++) {\n\t    if (z2->code[i] == code) continue;\n\n\t    items[n].byte_len = len;\n\t    items[n].code_len = 1;\n\t    items[n].code[0]  = z2->code[i];\n\t    n++;\n\t  }\n\t}\n      }\n\n      \/* multi char folded code is not head of another folded multi char *\/\n      flag = 0; \/* DISABLE_CASE_FOLD_MULTI_CHAR(flag); *\/\n    }\n  }\n  else {\n    if (onig_st_lookup(Unfold1Table, (st_data_t )code, (void* )&to) != 0) {\n      for (i = 0; i < to->n; i++) {\n\titems[n].byte_len = len;\n\titems[n].code_len = 1;\n\titems[n].code[0]  = to->code[i];\n\tn++;\n      }\n    }\n  }\n\n\n  if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    p += len;\n    if (p < end) {\n      int clen;\n\n      codes[0] = code;\n      code = ONIGENC_MBC_TO_CODE(enc, p, end);\n      if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0\n\t  && to->n == 1) {\n\tcodes[1] = to->code[0];\n      }\n      else\n\tcodes[1] = code;\n\n      clen = enclen(enc, p, end);\n      len += clen;\n      if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) {\n\tfor (i = 0; i < z2->n; i++) {\n\t  items[n].byte_len = len;\n\t  items[n].code_len = 1;\n\t  items[n].code[0]  = z2->code[i];\n\t  n++;\n\t}\n      }\n\n      p += clen;\n      if (p < end) {\n\tcode = ONIGENC_MBC_TO_CODE(enc, p, end);\n\tif (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0\n\t    && to->n == 1) {\n\t  codes[2] = to->code[0];\n\t}\n\telse\n\t  codes[2] = code;\n\n\tclen = enclen(enc, p, end);\n\tlen += clen;\n\tif (onig_st_lookup(Unfold3Table, (st_data_t )codes,\n\t\t\t   (void* )&z2) != 0) {\n\t  for (i = 0; i < z2->n; i++) {\n\t    items[n].byte_len = len;\n\t    items[n].code_len = 1;\n\t    items[n].code[0]  = z2->code[i];\n\t    n++;\n\t  }\n\t}\n      }\n    }\n  }\n\n  return n;\n}","target":0,"code_token_length":1836,"total_token_length":2072,"max_tokens_setting":4096}
+{"idx":448535,"func":"static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)\n{\n\tiana_afi_t pkt_afi;\n\tafi_t afi;\n\tiana_safi_t pkt_safi;\n\tsafi_t safi;\n\tstruct stream *s;\n\tstruct peer_af *paf;\n\tstruct update_group *updgrp;\n\tstruct peer *updgrp_peer;\n\tuint8_t subtype;\n\tbool force_update = false;\n\tbgp_size_t msg_length =\n\t\tsize - (BGP_MSG_ROUTE_REFRESH_MIN_SIZE - BGP_HEADER_SIZE);\n\n\t\/* If peer does not have the capability, send notification. *\/\n\tif (!CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_ADV)) {\n\t\tflog_err(EC_BGP_NO_CAP,\n\t\t\t \"%s [Error] BGP route refresh is not enabled\",\n\t\t\t peer->host);\n\t\tbgp_notify_send(peer, BGP_NOTIFY_HEADER_ERR,\n\t\t\t\tBGP_NOTIFY_HEADER_BAD_MESTYPE);\n\t\treturn BGP_Stop;\n\t}\n\n\t\/* Status must be Established. *\/\n\tif (!peer_established(peer)) {\n\t\tflog_err(\n\t\t\tEC_BGP_INVALID_STATUS,\n\t\t\t\"%s [Error] Route refresh packet received under status %s\",\n\t\t\tpeer->host,\n\t\t\tlookup_msg(bgp_status_msg, peer->status, NULL));\n\t\tbgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,\n\t\t\t\tbgp_fsm_error_subcode(peer->status));\n\t\treturn BGP_Stop;\n\t}\n\n\ts = peer->curr;\n\n\t\/* Parse packet. *\/\n\tpkt_afi = stream_getw(s);\n\tsubtype = stream_getc(s);\n\tpkt_safi = stream_getc(s);\n\n\t\/* Convert AFI, SAFI to internal values and check. *\/\n\tif (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) {\n\t\tzlog_info(\n\t\t\t\"%s REFRESH_REQ for unrecognized afi\/safi: %s\/%s - ignored\",\n\t\t\tpeer->host, iana_afi2str(pkt_afi),\n\t\t\tiana_safi2str(pkt_safi));\n\t\treturn BGP_PACKET_NOOP;\n\t}\n\n\tif (size != BGP_MSG_ROUTE_REFRESH_MIN_SIZE - BGP_HEADER_SIZE) {\n\t\tuint8_t *end;\n\t\tuint8_t when_to_refresh;\n\t\tuint8_t orf_type;\n\t\tuint16_t orf_len;\n\n\t\tif (subtype) {\n\t\t\t\/* If the length, excluding the fixed-size message\n\t\t\t * header, of the received ROUTE-REFRESH message with\n\t\t\t * Message Subtype 1 and 2 is not 4, then the BGP\n\t\t\t * speaker MUST send a NOTIFICATION message with the\n\t\t\t * Error Code of \"ROUTE-REFRESH Message Error\" and the\n\t\t\t * subcode of \"Invalid Message Length\".\n\t\t\t *\/\n\t\t\tif (msg_length != 4) {\n\t\t\t\tzlog_err(\n\t\t\t\t\t\"%s Enhanced Route Refresh message length error\",\n\t\t\t\t\tpeer->host);\n\t\t\t\tbgp_notify_send(\n\t\t\t\t\tpeer, BGP_NOTIFY_ROUTE_REFRESH_ERR,\n\t\t\t\t\tBGP_NOTIFY_ROUTE_REFRESH_INVALID_MSG_LEN);\n\t\t\t}\n\n\t\t\t\/* When the BGP speaker receives a ROUTE-REFRESH message\n\t\t\t * with a \"Message Subtype\" field other than 0, 1, or 2,\n\t\t\t * it MUST ignore the received ROUTE-REFRESH message.\n\t\t\t *\/\n\t\t\tif (subtype > 2)\n\t\t\t\tzlog_err(\n\t\t\t\t\t\"%s Enhanced Route Refresh invalid subtype\",\n\t\t\t\t\tpeer->host);\n\t\t}\n\n\t\tif (msg_length < 5) {\n\t\t\tzlog_info(\"%s ORF route refresh length error\",\n\t\t\t\t  peer->host);\n\t\t\tbgp_notify_send(peer, BGP_NOTIFY_CEASE,\n\t\t\t\t\tBGP_NOTIFY_SUBCODE_UNSPECIFIC);\n\t\t\treturn BGP_Stop;\n\t\t}\n\n\t\twhen_to_refresh = stream_getc(s);\n\t\tend = stream_pnt(s) + (size - 5);\n\n\t\twhile ((stream_pnt(s) + 2) < end) {\n\t\t\torf_type = stream_getc(s);\n\t\t\torf_len = stream_getw(s);\n\n\t\t\t\/* orf_len in bounds? *\/\n\t\t\tif ((stream_pnt(s) + orf_len) > end)\n\t\t\t\tbreak; \/* XXX: Notify instead?? *\/\n\t\t\tif (orf_type == ORF_TYPE_PREFIX\n\t\t\t    || orf_type == ORF_TYPE_PREFIX_OLD) {\n\t\t\t\tuint8_t *p_pnt = stream_pnt(s);\n\t\t\t\tuint8_t *p_end = stream_pnt(s) + orf_len;\n\t\t\t\tstruct orf_prefix orfp;\n\t\t\t\tuint8_t common = 0;\n\t\t\t\tuint32_t seq;\n\t\t\t\tint psize;\n\t\t\t\tchar name[BUFSIZ];\n\t\t\t\tint ret = CMD_SUCCESS;\n\n\t\t\t\tif (bgp_debug_neighbor_events(peer)) {\n\t\t\t\t\tzlog_debug(\n\t\t\t\t\t\t\"%pBP rcvd Prefixlist ORF(%d) length %d\",\n\t\t\t\t\t\tpeer, orf_type, orf_len);\n\t\t\t\t}\n\n\t\t\t\t\/* we're going to read at least 1 byte of common\n\t\t\t\t * ORF header,\n\t\t\t\t * and 7 bytes of ORF Address-filter entry from\n\t\t\t\t * the stream\n\t\t\t\t *\/\n\t\t\t\tif (orf_len < 7)\n\t\t\t\t\tbreak;\n\n\t\t\t\t\/* ORF prefix-list name *\/\n\t\t\t\tsnprintf(name, sizeof(name), \"%s.%d.%d\",\n\t\t\t\t\t peer->host, afi, safi);\n\n\t\t\t\twhile (p_pnt < p_end) {\n\t\t\t\t\t\/* If the ORF entry is malformed, want\n\t\t\t\t\t * to read as much of it\n\t\t\t\t\t * as possible without going beyond the\n\t\t\t\t\t * bounds of the entry,\n\t\t\t\t\t * to maximise debug information.\n\t\t\t\t\t *\/\n\t\t\t\t\tint ok;\n\t\t\t\t\tmemset(&orfp, 0, sizeof(orfp));\n\t\t\t\t\tcommon = *p_pnt++;\n\t\t\t\t\t\/* after ++: p_pnt <= p_end *\/\n\t\t\t\t\tif (common\n\t\t\t\t\t    & ORF_COMMON_PART_REMOVE_ALL) {\n\t\t\t\t\t\tif (bgp_debug_neighbor_events(\n\t\t\t\t\t\t\t    peer))\n\t\t\t\t\t\t\tzlog_debug(\n\t\t\t\t\t\t\t\t\"%pBP rcvd Remove-All pfxlist ORF request\",\n\t\t\t\t\t\t\t\tpeer);\n\t\t\t\t\t\tprefix_bgp_orf_remove_all(afi,\n\t\t\t\t\t\t\t\t\t  name);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tok = ((uint32_t)(p_end - p_pnt)\n\t\t\t\t\t      >= sizeof(uint32_t));\n\t\t\t\t\tif (ok) {\n\t\t\t\t\t\tmemcpy(&seq, p_pnt,\n\t\t\t\t\t\t       sizeof(uint32_t));\n\t\t\t\t\t\tp_pnt += sizeof(uint32_t);\n\t\t\t\t\t\torfp.seq = ntohl(seq);\n\t\t\t\t\t} else\n\t\t\t\t\t\tp_pnt = p_end;\n\n\t\t\t\t\t\/* val checked in prefix_bgp_orf_set *\/\n\t\t\t\t\tif (p_pnt < p_end)\n\t\t\t\t\t\torfp.ge = *p_pnt++;\n\n\t\t\t\t\t\/* val checked in prefix_bgp_orf_set *\/\n\t\t\t\t\tif (p_pnt < p_end)\n\t\t\t\t\t\torfp.le = *p_pnt++;\n\n\t\t\t\t\tif ((ok = (p_pnt < p_end)))\n\t\t\t\t\t\torfp.p.prefixlen = *p_pnt++;\n\n\t\t\t\t\t\/* afi checked already *\/\n\t\t\t\t\torfp.p.family = afi2family(afi);\n\n\t\t\t\t\t\/* 0 if not ok *\/\n\t\t\t\t\tpsize = PSIZE(orfp.p.prefixlen);\n\t\t\t\t\t\/* valid for family ? *\/\n\t\t\t\t\tif (psize > prefix_blen(&orfp.p)) {\n\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\tpsize = prefix_blen(&orfp.p);\n\t\t\t\t\t}\n\t\t\t\t\t\/* valid for packet ? *\/\n\t\t\t\t\tif (psize > (p_end - p_pnt)) {\n\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\tpsize = p_end - p_pnt;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (psize > 0)\n\t\t\t\t\t\tmemcpy(&orfp.p.u.prefix, p_pnt,\n\t\t\t\t\t\t       psize);\n\t\t\t\t\tp_pnt += psize;\n\n\t\t\t\t\tif (bgp_debug_neighbor_events(peer)) {\n\t\t\t\t\t\tchar buf[INET6_BUFSIZ];\n\n\t\t\t\t\t\tzlog_debug(\n\t\t\t\t\t\t\t\"%pBP rcvd %s %s seq %u %s\/%d ge %d le %d%s\",\n\t\t\t\t\t\t\tpeer,\n\t\t\t\t\t\t\t(common & ORF_COMMON_PART_REMOVE\n\t\t\t\t\t\t\t\t ? \"Remove\"\n\t\t\t\t\t\t\t\t : \"Add\"),\n\t\t\t\t\t\t\t(common & ORF_COMMON_PART_DENY\n\t\t\t\t\t\t\t\t ? \"deny\"\n\t\t\t\t\t\t\t\t : \"permit\"),\n\t\t\t\t\t\t\torfp.seq,\n\t\t\t\t\t\t\tinet_ntop(\n\t\t\t\t\t\t\t\torfp.p.family,\n\t\t\t\t\t\t\t\t&orfp.p.u.prefix,\n\t\t\t\t\t\t\t\tbuf,\n\t\t\t\t\t\t\t\tINET6_BUFSIZ),\n\t\t\t\t\t\t\torfp.p.prefixlen,\n\t\t\t\t\t\t\torfp.ge, orfp.le,\n\t\t\t\t\t\t\tok ? \"\" : \" MALFORMED\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ok)\n\t\t\t\t\t\tret = prefix_bgp_orf_set(\n\t\t\t\t\t\t\tname, afi, &orfp,\n\t\t\t\t\t\t\t(common & ORF_COMMON_PART_DENY\n\t\t\t\t\t\t\t\t ? 0\n\t\t\t\t\t\t\t\t : 1),\n\t\t\t\t\t\t\t(common & ORF_COMMON_PART_REMOVE\n\t\t\t\t\t\t\t\t ? 0\n\t\t\t\t\t\t\t\t : 1));\n\n\t\t\t\t\tif (!ok || (ok && ret != CMD_SUCCESS)) {\n\t\t\t\t\t\tzlog_info(\n\t\t\t\t\t\t\t\"%pBP Received misformatted prefixlist ORF. Remove All pfxlist\",\n\t\t\t\t\t\t\tpeer);\n\t\t\t\t\t\tprefix_bgp_orf_remove_all(afi,\n\t\t\t\t\t\t\t\t\t  name);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpeer->orf_plist[afi][safi] =\n\t\t\t\t\tprefix_bgp_orf_lookup(afi, name);\n\t\t\t}\n\t\t\tstream_forward_getp(s, orf_len);\n\t\t}\n\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\tzlog_debug(\"%pBP rcvd Refresh %s ORF request\", peer,\n\t\t\t\t   when_to_refresh == REFRESH_DEFER\n\t\t\t\t\t   ? \"Defer\"\n\t\t\t\t\t   : \"Immediate\");\n\t\tif (when_to_refresh == REFRESH_DEFER)\n\t\t\treturn BGP_PACKET_NOOP;\n\t}\n\n\t\/* First update is deferred until ORF or ROUTE-REFRESH is received *\/\n\tif (CHECK_FLAG(peer->af_sflags[afi][safi],\n\t\t       PEER_STATUS_ORF_WAIT_REFRESH))\n\t\tUNSET_FLAG(peer->af_sflags[afi][safi],\n\t\t\t   PEER_STATUS_ORF_WAIT_REFRESH);\n\n\tpaf = peer_af_find(peer, afi, safi);\n\tif (paf && paf->subgroup) {\n\t\tif (peer->orf_plist[afi][safi]) {\n\t\t\tupdgrp = PAF_UPDGRP(paf);\n\t\t\tupdgrp_peer = UPDGRP_PEER(updgrp);\n\t\t\tupdgrp_peer->orf_plist[afi][safi] =\n\t\t\t\tpeer->orf_plist[afi][safi];\n\t\t}\n\n\t\t\/* Avoid supressing duplicate routes later\n\t\t * when processing in subgroup_announce_table().\n\t\t *\/\n\t\tforce_update = true;\n\n\t\t\/* If the peer is configured for default-originate clear the\n\t\t * SUBGRP_STATUS_DEFAULT_ORIGINATE flag so that we will\n\t\t * re-advertise the\n\t\t * default\n\t\t *\/\n\t\tif (CHECK_FLAG(paf->subgroup->sflags,\n\t\t\t       SUBGRP_STATUS_DEFAULT_ORIGINATE))\n\t\t\tUNSET_FLAG(paf->subgroup->sflags,\n\t\t\t\t   SUBGRP_STATUS_DEFAULT_ORIGINATE);\n\t}\n\n\tif (subtype == BGP_ROUTE_REFRESH_BORR) {\n\t\t\/* A BGP speaker that has received the Graceful Restart\n\t\t * Capability from its neighbor MUST ignore any BoRRs for\n\t\t * an <AFI, SAFI> from the neighbor before the speaker\n\t\t * receives the EoR for the given <AFI, SAFI> from the\n\t\t * neighbor.\n\t\t *\/\n\t\tif (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)\n\t\t    && !CHECK_FLAG(peer->af_sflags[afi][safi],\n\t\t\t\t   PEER_STATUS_EOR_RECEIVED)) {\n\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\tzlog_debug(\n\t\t\t\t\t\"%pBP rcvd route-refresh (BoRR) for %s\/%s before EoR\",\n\t\t\t\t\tpeer, afi2str(afi), safi2str(safi));\n\t\t\treturn BGP_PACKET_NOOP;\n\t\t}\n\n\t\tif (peer->t_refresh_stalepath) {\n\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\tzlog_debug(\n\t\t\t\t\t\"%pBP rcvd route-refresh (BoRR) for %s\/%s, whereas BoRR already received\",\n\t\t\t\t\tpeer, afi2str(afi), safi2str(safi));\n\t\t\treturn BGP_PACKET_NOOP;\n\t\t}\n\n\t\tSET_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_BORR_RECEIVED);\n\t\tUNSET_FLAG(peer->af_sflags[afi][safi],\n\t\t\t   PEER_STATUS_EORR_RECEIVED);\n\n\t\t\/* When a BGP speaker receives a BoRR message from\n\t\t * a peer, it MUST mark all the routes with the given\n\t\t * Address Family Identifier and Subsequent Address\n\t\t * Family Identifier, <AFI, SAFI> [RFC2918], from\n\t\t * that peer as stale.\n\t\t *\/\n\t\tif (peer_active_nego(peer)) {\n\t\t\tSET_FLAG(peer->af_sflags[afi][safi],\n\t\t\t\t PEER_STATUS_ENHANCED_REFRESH);\n\t\t\tbgp_set_stale_route(peer, afi, safi);\n\t\t}\n\n\t\tif (peer_established(peer))\n\t\t\tthread_add_timer(bm->master,\n\t\t\t\t\t bgp_refresh_stalepath_timer_expire,\n\t\t\t\t\t paf, peer->bgp->stalepath_time,\n\t\t\t\t\t &peer->t_refresh_stalepath);\n\n\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\tzlog_debug(\n\t\t\t\t\"%pBP rcvd route-refresh (BoRR) for %s\/%s, triggering timer for %u seconds\",\n\t\t\t\tpeer, afi2str(afi), safi2str(safi),\n\t\t\t\tpeer->bgp->stalepath_time);\n\t} else if (subtype == BGP_ROUTE_REFRESH_EORR) {\n\t\tif (!peer->t_refresh_stalepath) {\n\t\t\tzlog_err(\n\t\t\t\t\"%pBP rcvd route-refresh (EoRR) for %s\/%s, whereas no BoRR received\",\n\t\t\t\tpeer, afi2str(afi), safi2str(safi));\n\t\t\treturn BGP_PACKET_NOOP;\n\t\t}\n\n\t\tTHREAD_OFF(peer->t_refresh_stalepath);\n\n\t\tSET_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_EORR_RECEIVED);\n\t\tUNSET_FLAG(peer->af_sflags[afi][safi],\n\t\t\t   PEER_STATUS_BORR_RECEIVED);\n\n\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\tzlog_debug(\n\t\t\t\t\"%pBP rcvd route-refresh (EoRR) for %s\/%s, stopping BoRR timer\",\n\t\t\t\tpeer, afi2str(afi), safi2str(safi));\n\n\t\tif (peer->nsf[afi][safi])\n\t\t\tbgp_clear_stale_route(peer, afi, safi);\n\t} else {\n\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\tzlog_debug(\n\t\t\t\t\"%pBP rcvd route-refresh (REQUEST) for %s\/%s\",\n\t\t\t\tpeer, afi2str(afi), safi2str(safi));\n\n\t\t\/* In response to a \"normal route refresh request\" from the\n\t\t * peer, the speaker MUST send a BoRR message.\n\t\t *\/\n\t\tif (CHECK_FLAG(peer->cap, PEER_CAP_ENHANCED_RR_RCV)) {\n\t\t\t\/* For a BGP speaker that supports the BGP Graceful\n\t\t\t * Restart, it MUST NOT send a BoRR for an <AFI, SAFI>\n\t\t\t * to a neighbor before it sends the EoR for the\n\t\t\t * <AFI, SAFI> to the neighbor.\n\t\t\t *\/\n\t\t\tif (!CHECK_FLAG(peer->af_sflags[afi][safi],\n\t\t\t\t\tPEER_STATUS_EOR_SEND)) {\n\t\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\t\tzlog_debug(\n\t\t\t\t\t\t\"%pBP rcvd route-refresh (REQUEST) for %s\/%s before EoR\",\n\t\t\t\t\t\tpeer, afi2str(afi),\n\t\t\t\t\t\tsafi2str(safi));\n\t\t\t\treturn BGP_PACKET_NOOP;\n\t\t\t}\n\n\t\t\tbgp_route_refresh_send(peer, afi, safi, 0, 0, 0,\n\t\t\t\t\t       BGP_ROUTE_REFRESH_BORR);\n\n\t\t\tif (bgp_debug_neighbor_events(peer))\n\t\t\t\tzlog_debug(\n\t\t\t\t\t\"%pBP sending route-refresh (BoRR) for %s\/%s\",\n\t\t\t\t\tpeer, afi2str(afi), safi2str(safi));\n\n\t\t\t\/* Set flag Ready-To-Send to know when we can send EoRR\n\t\t\t * message.\n\t\t\t *\/\n\t\t\tSET_FLAG(peer->af_sflags[afi][safi],\n\t\t\t\t PEER_STATUS_BORR_SEND);\n\t\t\tUNSET_FLAG(peer->af_sflags[afi][safi],\n\t\t\t\t   PEER_STATUS_EORR_SEND);\n\t\t}\n\t}\n\n\t\/* Perform route refreshment to the peer *\/\n\tbgp_announce_route(peer, afi, safi, force_update);\n\n\t\/* No FSM action necessary *\/\n\treturn BGP_PACKET_NOOP;\n}","target":0,"code_token_length":3597,"total_token_length":3833,"max_tokens_setting":4096}
+{"idx":498620,"func":"save_image (const gchar  *filename,\n            gint32        image_ID,\n            gint32        drawable_ID,\n            GError      **error)\n{\n  GeglBuffer    *buffer;\n  const Babl    *format = NULL;\n  GimpImageType  dtype;\n  gint           width;\n  gint           height;\n  FILE          *fp;\n  gint           out_bpp = 0;\n  gboolean       status  = TRUE;\n  gint           i, row;\n  guchar         header[18];\n  guchar         footer[26];\n  guchar        *pixels;\n  guchar        *data;\n  gint           num_colors;\n  guchar        *gimp_cmap = NULL;\n\n  buffer = gimp_drawable_get_buffer (drawable_ID);\n\n  dtype = gimp_drawable_type (drawable_ID);\n\n  width  = gegl_buffer_get_width  (buffer);\n  height = gegl_buffer_get_height (buffer);\n\n  gimp_progress_init_printf (_(\"Exporting '%s'\"),\n                             gimp_filename_to_utf8 (filename));\n\n  if ((fp = g_fopen (filename, \"wb\")) == NULL)\n    {\n      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),\n                   _(\"Could not open '%s' for writing: %s\"),\n                   gimp_filename_to_utf8 (filename), g_strerror (errno));\n      return FALSE;\n    }\n\n  header[0] = 0; \/* No image identifier \/ description *\/\n\n  if (dtype == GIMP_INDEXED_IMAGE)\n    {\n      gimp_cmap = gimp_image_get_colormap (image_ID, &num_colors);\n\n      header[1] = 1; \/* cmap type *\/\n      header[2] = (tsvals.rle) ? 9 : 1;\n      header[3] = header[4] = 0; \/* no offset *\/\n      header[5] = num_colors % 256;\n      header[6] = num_colors \/ 256;\n      header[7] = 24; \/* cmap size \/ bits *\/\n    }\n  else if (dtype == GIMP_INDEXEDA_IMAGE)\n    {\n      gimp_cmap = gimp_image_get_colormap (image_ID, &num_colors);\n\n      header[1] = 1; \/* cmap type *\/\n      header[2] = (tsvals.rle) ? 9 : 1;\n      header[3] = header[4] = 0; \/* no offset *\/\n      header[5] = (num_colors + 1) % 256;\n      header[6] = (num_colors + 1) \/ 256;\n      header[7] = 32; \/* cmap size \/ bits *\/\n    }\n  else\n    {\n      header[1]= 0;\n\n      if (dtype == GIMP_RGB_IMAGE || dtype == GIMP_RGBA_IMAGE)\n        {\n          header[2]= (tsvals.rle) ? 10 : 2;\n        }\n      else\n        {\n          header[2]= (tsvals.rle) ? 11 : 3;\n        }\n\n      header[3] = header[4] = header[5] = header[6] = header[7] = 0;\n    }\n\n  header[8]  = header[9] = 0;                           \/* xorigin *\/\n  header[10] = tsvals.origin ? 0 : (height % 256);      \/* yorigin *\/\n  header[11] = tsvals.origin ? 0 : (height \/ 256);      \/* yorigin *\/\n\n\n  header[12] = width % 256;\n  header[13] = width \/ 256;\n\n  header[14] = height % 256;\n  header[15] = height \/ 256;\n\n  switch (dtype)\n    {\n    case GIMP_INDEXED_IMAGE:\n    case GIMP_INDEXEDA_IMAGE:\n      format  = NULL;\n      out_bpp = 1;\n      header[16] = 8; \/* bpp *\/\n      header[17] = tsvals.origin ? 0 : 0x20; \/* alpha + orientation *\/\n      break;\n\n    case GIMP_GRAY_IMAGE:\n      format  = babl_format (\"Y' u8\");\n      out_bpp = 1;\n      header[16] = 8; \/* bpp *\/\n      header[17] = tsvals.origin ? 0 : 0x20; \/* alpha + orientation *\/\n      break;\n\n    case GIMP_GRAYA_IMAGE:\n      format  = babl_format (\"Y'A u8\");\n      out_bpp = 2;\n      header[16] = 16; \/* bpp *\/\n      header[17] = tsvals.origin ? 8 : 0x28; \/* alpha + orientation *\/\n      break;\n\n    case GIMP_RGB_IMAGE:\n      format  = babl_format (\"R'G'B' u8\");\n      out_bpp = 3;\n      header[16] = 24; \/* bpp *\/\n      header[17] = tsvals.origin ? 0 : 0x20; \/* alpha + orientation *\/\n      break;\n\n    case GIMP_RGBA_IMAGE:\n      format  = babl_format (\"R'G'B'A u8\");\n      out_bpp = 4;\n      header[16] = 32; \/* bpp *\/\n      header[17] = tsvals.origin ? 8 : 0x28; \/* alpha + orientation *\/\n      break;\n    }\n\n  \/* write header to front of file *\/\n  fwrite (header, sizeof (header), 1, fp);\n\n  if (dtype == GIMP_INDEXED_IMAGE)\n    {\n      \/* write out palette *\/\n      for (i = 0; i < num_colors; ++i)\n        {\n          fputc (gimp_cmap[(i * 3) + 2], fp);\n          fputc (gimp_cmap[(i * 3) + 1], fp);\n          fputc (gimp_cmap[(i * 3) + 0], fp);\n        }\n    }\n  else if (dtype == GIMP_INDEXEDA_IMAGE)\n    {\n      \/* write out palette *\/\n      for (i = 0; i < num_colors; ++i)\n        {\n          fputc (gimp_cmap[(i * 3) + 2], fp);\n          fputc (gimp_cmap[(i * 3) + 1], fp);\n          fputc (gimp_cmap[(i * 3) + 0], fp);\n          fputc (255, fp);\n        }\n\n      fputc (0, fp);\n      fputc (0, fp);\n      fputc (0, fp);\n      fputc (0, fp);\n    }\n\n  pixels = g_new (guchar, width * out_bpp);\n  data   = g_new (guchar, width * out_bpp);\n\n  for (row = 0; row < height; ++row)\n    {\n      if (tsvals.origin)\n        {\n          gegl_buffer_get (buffer,\n                           GEGL_RECTANGLE (0, height - (row + 1), width, 1), 1.0,\n                           format, pixels,\n                           GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);\n        }\n      else\n        {\n          gegl_buffer_get (buffer,\n                           GEGL_RECTANGLE (0, row, width, 1), 1.0,\n                           format, pixels,\n                           GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);\n        }\n\n      if (dtype == GIMP_RGB_IMAGE)\n        {\n          bgr2rgb (data, pixels, width, out_bpp, 0);\n        }\n      else if (dtype == GIMP_RGBA_IMAGE)\n        {\n          bgr2rgb (data, pixels, width, out_bpp, 1);\n        }\n      else if (dtype == GIMP_INDEXEDA_IMAGE)\n        {\n          for (i = 0; i < width; ++i)\n            {\n              if (pixels[i * 2 + 1] > 127)\n                data[i] = pixels[i * 2];\n              else\n                data[i] = num_colors;\n            }\n        }\n      else\n        {\n          memcpy (data, pixels, width * out_bpp);\n        }\n\n      if (tsvals.rle)\n        {\n          rle_write (fp, data, width, out_bpp);\n        }\n      else\n        {\n          fwrite (data, width * out_bpp, 1, fp);\n        }\n\n      if (row % 16 == 0)\n        gimp_progress_update ((gdouble) row \/ (gdouble) height);\n    }\n\n  g_object_unref (buffer);\n\n  g_free (data);\n  g_free (pixels);\n\n  \/* footer must be the last thing written to file *\/\n  memset (footer, 0, 8); \/* No extensions, no developer directory *\/\n  memcpy (footer + 8, magic, sizeof (magic)); \/* magic signature *\/\n  fwrite (footer, sizeof (footer), 1, fp);\n\n  fclose (fp);\n\n  gimp_progress_update (1.0);\n\n  return status;\n}","target":0,"code_token_length":1968,"total_token_length":2204,"max_tokens_setting":4096}
+{"idx":439126,"func":"static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define RMT_EQUAL_RGB  1\n#define RMT_NONE  0\n#define RMT_RAW  2\n#define RT_STANDARD  1\n#define RT_ENCODED  2\n#define RT_FORMAT_RGB  3\n\n  typedef struct _SUNInfo\n  {\n    unsigned int\n      magic,\n      width,\n      height,\n      depth,\n      length,\n      type,\n      maptype,\n      maplength;\n  } SUNInfo;\n\n  Image\n    *image;\n\n  int\n    bit;\n\n  MagickBooleanType\n    status;\n\n  MagickSizeType\n    number_pixels;\n\n  register IndexPacket\n    *indexes;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *p;\n\n  size_t\n    bytes_per_line,\n    extent,\n    height,\n    pixels_length,\n    quantum;\n\n  ssize_t\n    count,\n    y;\n\n  SUNInfo\n    sun_info;\n\n  unsigned char\n    *sun_data,\n    *sun_pixels;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read SUN raster header.\n  *\/\n  (void) memset(&sun_info,0,sizeof(sun_info));\n  sun_info.magic=ReadBlobMSBLong(image);\n  do\n  {\n    \/*\n      Verify SUN identifier.\n    *\/\n    if (sun_info.magic != 0x59a66a95)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    sun_info.width=ReadBlobMSBLong(image);\n    sun_info.height=ReadBlobMSBLong(image);\n    sun_info.depth=ReadBlobMSBLong(image);\n    sun_info.length=ReadBlobMSBLong(image);\n    sun_info.type=ReadBlobMSBLong(image);\n    sun_info.maptype=ReadBlobMSBLong(image);\n    sun_info.maplength=ReadBlobMSBLong(image);\n    if (sun_info.maplength > GetBlobSize(image))\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    extent=sun_info.height*sun_info.width;\n    if ((sun_info.height != 0) && (sun_info.width != extent\/sun_info.height))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) &&\n        (sun_info.type != RT_FORMAT_RGB))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((sun_info.maptype == RMT_NONE) && (sun_info.maplength != 0))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((sun_info.depth != 1) && (sun_info.depth != 8) &&\n        (sun_info.depth != 24) && (sun_info.depth != 32))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((sun_info.maptype != RMT_NONE) && (sun_info.maptype != RMT_EQUAL_RGB) &&\n        (sun_info.maptype != RMT_RAW))\n      ThrowReaderException(CoderError,\"ColormapTypeNotSupported\");\n    image->columns=sun_info.width;\n    image->rows=sun_info.height;\n    image->depth=sun_info.depth <= 8 ? sun_info.depth :\n      MAGICKCORE_QUANTUM_DEPTH;\n    if (sun_info.depth < 24)\n      {\n        size_t\n          one;\n\n        image->colors=sun_info.maplength;\n        one=1;\n        if (sun_info.maptype == RMT_NONE)\n          image->colors=one << sun_info.depth;\n        if (sun_info.maptype == RMT_EQUAL_RGB)\n          image->colors=sun_info.maplength\/3;\n        if (image->colors == 0)\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n        if (AcquireImageColormap(image,image->colors) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n    switch (sun_info.maptype)\n    {\n      case RMT_NONE:\n        break;\n      case RMT_EQUAL_RGB:\n      {\n        unsigned char\n          *sun_colormap;\n\n        \/*\n          Read SUN raster colormap.\n        *\/\n        sun_colormap=(unsigned char *) AcquireQuantumMemory(image->colors,\n          sizeof(*sun_colormap));\n        if (sun_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        count=ReadBlob(image,image->colors,sun_colormap);\n        if (count != (ssize_t) image->colors)\n          {\n            sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n            ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n          }\n        for (i=0; i < (ssize_t) image->colors; i++)\n          image->colormap[i].red=ScaleCharToQuantum(sun_colormap[i]);\n        count=ReadBlob(image,image->colors,sun_colormap);\n        if (count != (ssize_t) image->colors)\n          {\n            sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n            ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n          }\n        for (i=0; i < (ssize_t) image->colors; i++)\n          image->colormap[i].green=ScaleCharToQuantum(sun_colormap[i]);\n        count=ReadBlob(image,image->colors,sun_colormap);\n        if (count != (ssize_t) image->colors)\n          {\n            sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n            ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n          }\n        for (i=0; i < (ssize_t) image->colors; i++)\n          image->colormap[i].blue=ScaleCharToQuantum(sun_colormap[i]);\n        sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n        break;\n      }\n      case RMT_RAW:\n      {\n        unsigned char\n          *sun_colormap;\n\n        \/*\n          Read SUN raster colormap.\n        *\/\n        sun_colormap=(unsigned char *) AcquireQuantumMemory(sun_info.maplength,\n          sizeof(*sun_colormap));\n        if (sun_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        count=ReadBlob(image,sun_info.maplength,sun_colormap);\n        sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n        if (count != (ssize_t) sun_info.maplength)\n          ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n        break;\n      }\n      default:\n        break;\n    }\n    image->matte=sun_info.depth == 32 ? MagickTrue : MagickFalse;\n    image->columns=sun_info.width;\n    image->rows=sun_info.height;\n    if (image_info->ping != MagickFalse)\n      {\n        (void) CloseBlob(image);\n        return(GetFirstImageInList(image));\n      }\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    if (sun_info.length == 0)\n      ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n    number_pixels=(MagickSizeType) (image->columns*image->rows);\n    if ((sun_info.type != RT_ENCODED) &&\n        ((number_pixels*sun_info.depth) > (8UL*sun_info.length)))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if (HeapOverflowSanityCheck(sun_info.width,sun_info.depth) != MagickFalse)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    bytes_per_line=sun_info.width*sun_info.depth;\n    if (sun_info.length > GetBlobSize(image))\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    sun_data=(unsigned char *) AcquireQuantumMemory(sun_info.length,\n      sizeof(*sun_data));\n    if (sun_data == (unsigned char *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    count=(ssize_t) ReadBlob(image,sun_info.length,sun_data);\n    if (count != (ssize_t) sun_info.length)\n      {\n        sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n        ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n      }\n    height=sun_info.height;\n    if ((height == 0) || (sun_info.width == 0) || (sun_info.depth == 0) ||\n        ((bytes_per_line\/sun_info.depth) != sun_info.width))\n      {\n        sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n        ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n      }\n    quantum=sun_info.depth == 1 ? 15 : 7;\n    bytes_per_line+=quantum;\n    bytes_per_line<<=1;\n    if ((bytes_per_line >> 1) != (sun_info.width*sun_info.depth+quantum))\n      {\n        sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n        ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n      }\n    bytes_per_line>>=4;\n    if (HeapOverflowSanityCheck(height,bytes_per_line) != MagickFalse)\n      {\n        sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n        ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n      }\n    pixels_length=height*bytes_per_line;\n    sun_pixels=(unsigned char *) AcquireQuantumMemory(pixels_length+image->rows,\n      sizeof(*sun_pixels));\n    if (sun_pixels == (unsigned char *) NULL)\n      {\n        sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n    (void) memset(sun_pixels,0,(pixels_length+image->rows)*\n      sizeof(*sun_pixels));\n    if (sun_info.type == RT_ENCODED)\n      {\n        status=DecodeImage(sun_data,sun_info.length,sun_pixels,pixels_length);\n        if (status == MagickFalse)\n          {\n            sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n            sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels);\n            ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n          }\n      }\n    else\n      {\n        if (sun_info.length > pixels_length)\n          {\n            sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n            sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels);\n            ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n          }\n        (void) memcpy(sun_pixels,sun_data,sun_info.length);\n      }\n    sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n    \/*\n      Convert SUN raster image to pixel packets.\n    *\/\n    p=sun_pixels;\n    if (sun_info.depth == 1)\n      for (y=0; y < (ssize_t) image->rows; y++)\n      {\n        q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n        if (q == (PixelPacket *) NULL)\n          break;\n        indexes=GetAuthenticIndexQueue(image);\n        for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n        {\n          for (bit=7; bit >= 0; bit--)\n            SetPixelIndex(indexes+x+7-bit,((*p) & (0x01 << bit) ? 0x00 : 0x01));\n          p++;\n        }\n        if ((image->columns % 8) != 0)\n          {\n            for (bit=7; bit >= (int) (8-(image->columns % 8)); bit--)\n              SetPixelIndex(indexes+x+7-bit,(*p) & (0x01 << bit) ? 0x00 : 0x01);\n            p++;\n          }\n        if ((((image->columns\/8)+(image->columns % 8 ? 1 : 0)) % 2) != 0)\n          p++;\n        if (SyncAuthenticPixels(image,exception) == MagickFalse)\n          break;\n        if (image->previous == (Image *) NULL)\n          {\n            status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n              image->rows);\n            if (status == MagickFalse)\n              break;\n          }\n      }\n    else\n      if (image->storage_class == PseudoClass)\n        {\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (PixelPacket *) NULL)\n              break;\n            indexes=GetAuthenticIndexQueue(image);\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              SetPixelIndex(indexes+x,ConstrainColormapIndex(image,*p));\n              p++;\n            }\n            if ((image->columns % 2) != 0)\n              p++;\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n        }\n      else\n        {\n          size_t\n            bytes_per_pixel;\n\n          bytes_per_pixel=3;\n          if (image->matte != MagickFalse)\n            bytes_per_pixel++;\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (PixelPacket *) NULL)\n              break;\n            for (x=0; x < (ssize_t) image->columns; x++)\n            {\n              if (image->matte != MagickFalse)\n                SetPixelAlpha(q,ScaleCharToQuantum(*p++));\n              if (sun_info.type == RT_STANDARD)\n                {\n                  SetPixelBlue(q,ScaleCharToQuantum(*p++));\n                  SetPixelGreen(q,ScaleCharToQuantum(*p++));\n                  SetPixelRed(q,ScaleCharToQuantum(*p++));\n                }\n              else\n                {\n                  SetPixelRed(q,ScaleCharToQuantum(*p++));\n                  SetPixelGreen(q,ScaleCharToQuantum(*p++));\n                  SetPixelBlue(q,ScaleCharToQuantum(*p++));\n                }\n              if (image->colors != 0)\n                {\n                  SetPixelRed(q,image->colormap[(ssize_t)\n                    GetPixelRed(q)].red);\n                  SetPixelGreen(q,image->colormap[(ssize_t)\n                    GetPixelGreen(q)].green);\n                  SetPixelBlue(q,image->colormap[(ssize_t)\n                    GetPixelBlue(q)].blue);\n                }\n              q++;\n            }\n            if (((bytes_per_pixel*image->columns) % 2) != 0)\n              p++;\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n        }\n    if (image->storage_class == PseudoClass)\n      (void) SyncImage(image);\n    sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    sun_info.magic=ReadBlobMSBLong(image);\n    if (sun_info.magic == 0x59a66a95)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (sun_info.magic == 0x59a66a95);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":3807,"total_token_length":4043,"max_tokens_setting":4096}
+{"idx":211179,"func":"    void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,uint32_t start,bool bSwap,char c,int depth)\n    {\n        depth++;\n        bool bFirst  = true  ;\n\n        \/\/ buffer\n        const size_t dirSize = 32;\n        DataBuf  dir(dirSize);\n        bool bPrint = option == kpsBasic || option == kpsRecursive;\n\n        do {\n            \/\/ Read top of directory\n            io.seek(start,BasicIo::beg);\n            io.read(dir.pData_, 2);\n            uint16_t   dirLength = byteSwap2(dir,0,bSwap);\n\n            bool tooBig = dirLength > 500;\n            if ( tooBig ) throw Error(55);\n\n            if ( bFirst && bPrint ) {\n                out << Internal::indent(depth) << Internal::stringFormat(\"STRUCTURE OF TIFF FILE (%c%c): \",c,c) << io.path() << std::endl;\n                if ( tooBig ) out << Internal::indent(depth) << \"dirLength = \" << dirLength << std::endl;\n            }\n\n            \/\/ Read the dictionary\n            for ( int i = 0 ; i < dirLength ; i ++ ) {\n                if ( bFirst && bPrint ) {\n                    out << Internal::indent(depth)\n                        << \" address |    tag                              |     \"\n                        << \" type |    count |    offset | value\\n\";\n                }\n                bFirst = false;\n\n                io.read(dir.pData_, 12);\n                uint16_t tag    = byteSwap2(dir,0,bSwap);\n                uint16_t type   = byteSwap2(dir,2,bSwap);\n                uint32_t count  = byteSwap4(dir,4,bSwap);\n                uint32_t offset = byteSwap4(dir,8,bSwap);\n\n                \/\/ Break for unknown tag types else we may segfault.\n                if ( !typeValid(type) ) {\n                    std::cerr << \"invalid type value detected in Image::printIFDStructure:  \" << type << std::endl;\n                    start = 0; \/\/ break from do loop\n                    throw Error(56);\n                    break; \/\/ break from for loop\n                }\n\n                std::string sp  = \"\" ; \/\/ output spacer\n\n                \/\/prepare to print the value\n                uint32_t kount  = isPrintXMP(tag,option) ? count \/\/ haul in all the data\n                                : isPrintICC(tag,option) ? count \/\/ ditto\n                                : isStringType(type)     ? (count > 32 ? 32 : count) \/\/ restrict long arrays\n                                : count > 5              ? 5\n                                : count\n                                ;\n                uint32_t pad    = isStringType(type) ? 1 : 0;\n                uint32_t size   = isStringType(type) ? 1\n                                : is2ByteType(type)  ? 2\n                                : is4ByteType(type)  ? 4\n                                : is8ByteType(type)  ? 8\n                                : 1\n                                ;\n\n                \/\/ if ( offset > io.size() ) offset = 0; \/\/ Denial of service?\n                DataBuf  buf(size*count + pad+20);  \/\/ allocate a buffer\n                std::memcpy(buf.pData_,dir.pData_+8,4);  \/\/ copy dir[8:11] into buffer (short strings)\n                const bool bOffsetIsPointer = count*size > 4;\n\n                if ( bOffsetIsPointer ) {         \/\/ read into buffer\n                    size_t   restore = io.tell();  \/\/ save\n                    io.seek(offset,BasicIo::beg);  \/\/ position\n                    io.read(buf.pData_,count*size);\/\/ read\n                    io.seek(restore,BasicIo::beg); \/\/ restore\n                }\n\n                if ( bPrint ) {\n                    const uint32_t address = start + 2 + i*12 ;\n                    const std::string offsetString = bOffsetIsPointer?\n                        Internal::stringFormat(\"%10u\", offset):\n                        \"\";\n\n                    out << Internal::indent(depth)\n                    << Internal::stringFormat(\"%8u | %#06x %-28s |%10s |%9u |%10s | \"\n                                              ,address,tag,tagName(tag).c_str(),typeName(type),count,offsetString.c_str());\n                    if ( isShortType(type) ){\n                        for ( size_t k = 0 ; k < kount ; k++ ) {\n                            out << sp << byteSwap2(buf,k*size,bSwap);\n                            sp = \" \";\n                        }\n                    } else if ( isLongType(type) ){\n                        for ( size_t k = 0 ; k < kount ; k++ ) {\n                            out << sp << byteSwap4(buf,k*size,bSwap);\n                            sp = \" \";\n                        }\n\n                    } else if ( isRationalType(type) ){\n                        for ( size_t k = 0 ; k < kount ; k++ ) {\n                            uint32_t a = byteSwap4(buf,k*size+0,bSwap);\n                            uint32_t b = byteSwap4(buf,k*size+4,bSwap);\n                            out << sp << a << \"\/\" << b;\n                            sp = \" \";\n                        }\n                    } else if ( isStringType(type) ) {\n                        out << sp << Internal::binaryToString(buf, kount);\n                    }\n\n                    sp = kount == count ? \"\" : \" ...\";\n                    out << sp << std::endl;\n\n                    if ( option == kpsRecursive && (tag == 0x8769 \/* ExifTag *\/ || tag == 0x014a\/*SubIFDs*\/  || type == tiffIfd) ) {\n                        for ( size_t k = 0 ; k < count ; k++ ) {\n                            size_t   restore = io.tell();\n                            uint32_t offset = byteSwap4(buf,k*size,bSwap);\n                            printIFDStructure(io,out,option,offset,bSwap,c,depth);\n                            io.seek(restore,BasicIo::beg);\n                        }\n                    } else if ( option == kpsRecursive && tag == 0x83bb \/* IPTCNAA *\/ ) {\n                        size_t   restore = io.tell();  \/\/ save\n                        io.seek(offset,BasicIo::beg);  \/\/ position\n                        byte* bytes=new byte[count] ;  \/\/ allocate memory\n                        io.read(bytes,count)        ;  \/\/ read\n                        io.seek(restore,BasicIo::beg); \/\/ restore\n                        IptcData::printStructure(out,bytes,count,depth);\n                        delete[] bytes;                \/\/ free\n                    }  else if ( option == kpsRecursive && tag == 0x927c \/* MakerNote *\/ && count > 10) {\n                        size_t   restore = io.tell();  \/\/ save\n\n                        uint32_t jump= 10           ;\n                        byte     bytes[20]          ;\n                        const char* chars = (const char*) &bytes[0] ;\n                        io.seek(offset,BasicIo::beg);  \/\/ position\n                        io.read(bytes,jump    )     ;  \/\/ read\n                        bytes[jump]=0               ;\n                        if ( ::strcmp(\"Nikon\",chars) == 0 ) {\n                            \/\/ tag is an embedded tiff\n                            byte* bytes=new byte[count-jump] ;  \/\/ allocate memory\n                            io.read(bytes,count-jump)        ;  \/\/ read\n                            MemIo memIo(bytes,count-jump)    ;  \/\/ create a file\n                            printTiffStructure(memIo,out,option,depth);\n                            delete[] bytes                   ;  \/\/ free\n                        } else {\n                            \/\/ tag is an IFD\n                            io.seek(0,BasicIo::beg);  \/\/ position\n                            printIFDStructure(io,out,option,offset,bSwap,c,depth);\n                        }\n\n                        io.seek(restore,BasicIo::beg); \/\/ restore\n                    }\n                }\n\n                if ( isPrintXMP(tag,option) ) {\n                    buf.pData_[count]=0;\n                    out << (char*) buf.pData_;\n                }\n                if ( isPrintICC(tag,option) ) {\n                    out.write((const char*)buf.pData_,count);\n                }\n            }\n            if ( start ) {\n                io.read(dir.pData_, 4);\n                start = tooBig ? 0 : byteSwap4(dir,0,bSwap);\n            }\n        } while (start) ;\n\n        if ( bPrint ) {\n            out << Internal::indent(depth) << \"END \" << io.path() << std::endl;\n        }\n        out.flush();\n        depth--;\n    }","target":1,"code_token_length":1839,"total_token_length":2075,"max_tokens_setting":4096}
+{"idx":294538,"func":"d_lite_plus(VALUE self, VALUE other)\n{\n    int try_rational = 1;\n    get_d1(self);\n\n  again:\n    switch (TYPE(other)) {\n      case T_FIXNUM:\n\t{\n\t    VALUE nth;\n\t    long t;\n\t    int jd;\n\n\t    nth = m_nth(dat);\n\t    t = FIX2LONG(other);\n\t    if (DIV(t, CM_PERIOD)) {\n\t\tnth = f_add(nth, INT2FIX(DIV(t, CM_PERIOD)));\n\t\tt = MOD(t, CM_PERIOD);\n\t    }\n\n\t    if (!t)\n\t\tjd = m_jd(dat);\n\t    else {\n\t\tjd = m_jd(dat) + (int)t;\n\t\tcanonicalize_jd(nth, jd);\n\t    }\n\n\t    if (simple_dat_p(dat))\n\t\treturn d_simple_new_internal(rb_obj_class(self),\n\t\t\t\t\t     nth, jd,\n\t\t\t\t\t     dat->s.sg,\n\t\t\t\t\t     0, 0, 0,\n\t\t\t\t\t     (dat->s.flags | HAVE_JD) &\n\t\t\t\t\t     ~HAVE_CIVIL);\n\t    else\n\t\treturn d_complex_new_internal(rb_obj_class(self),\n\t\t\t\t\t      nth, jd,\n\t\t\t\t\t      dat->c.df, dat->c.sf,\n\t\t\t\t\t      dat->c.of, dat->c.sg,\n\t\t\t\t\t      0, 0, 0,\n#ifndef USE_PACK\n\t\t\t\t\t      dat->c.hour,\n\t\t\t\t\t      dat->c.min,\n\t\t\t\t\t      dat->c.sec,\n#else\n\t\t\t\t\t      EX_HOUR(dat->c.pc),\n\t\t\t\t\t      EX_MIN(dat->c.pc),\n\t\t\t\t\t      EX_SEC(dat->c.pc),\n#endif\n\t\t\t\t\t      (dat->c.flags | HAVE_JD) &\n\t\t\t\t\t      ~HAVE_CIVIL);\n\t}\n\tbreak;\n      case T_BIGNUM:\n\t{\n\t    VALUE nth;\n\t    int jd, s;\n\n\t    if (f_positive_p(other))\n\t\ts = +1;\n\t    else {\n\t\ts = -1;\n\t\tother = f_negate(other);\n\t    }\n\n\t    nth = f_idiv(other, INT2FIX(CM_PERIOD));\n\t    jd = FIX2INT(f_mod(other, INT2FIX(CM_PERIOD)));\n\n\t    if (s < 0) {\n\t\tnth = f_negate(nth);\n\t\tjd = -jd;\n\t    }\n\n\t    if (!jd)\n\t\tjd = m_jd(dat);\n\t    else {\n\t\tjd = m_jd(dat) + jd;\n\t\tcanonicalize_jd(nth, jd);\n\t    }\n\n\t    if (f_zero_p(nth))\n\t\tnth = m_nth(dat);\n\t    else\n\t\tnth = f_add(m_nth(dat), nth);\n\n\t    if (simple_dat_p(dat))\n\t\treturn d_simple_new_internal(rb_obj_class(self),\n\t\t\t\t\t     nth, jd,\n\t\t\t\t\t     dat->s.sg,\n\t\t\t\t\t     0, 0, 0,\n\t\t\t\t\t     (dat->s.flags | HAVE_JD) &\n\t\t\t\t\t     ~HAVE_CIVIL);\n\t    else\n\t\treturn d_complex_new_internal(rb_obj_class(self),\n\t\t\t\t\t      nth, jd,\n\t\t\t\t\t      dat->c.df, dat->c.sf,\n\t\t\t\t\t      dat->c.of, dat->c.sg,\n\t\t\t\t\t      0, 0, 0,\n#ifndef USE_PACK\n\t\t\t\t\t      dat->c.hour,\n\t\t\t\t\t      dat->c.min,\n\t\t\t\t\t      dat->c.sec,\n#else\n\t\t\t\t\t      EX_HOUR(dat->c.pc),\n\t\t\t\t\t      EX_MIN(dat->c.pc),\n\t\t\t\t\t      EX_SEC(dat->c.pc),\n#endif\n\t\t\t\t\t      (dat->c.flags | HAVE_JD) &\n\t\t\t\t\t      ~HAVE_CIVIL);\n\t}\n\tbreak;\n      case T_FLOAT:\n\t{\n\t    double jd, o, tmp;\n\t    int s, df;\n\t    VALUE nth, sf;\n\n\t    o = RFLOAT_VALUE(other);\n\n\t    if (o > 0)\n\t\ts = +1;\n\t    else {\n\t\ts = -1;\n\t\to = -o;\n\t    }\n\n\t    o = modf(o, &tmp);\n\n\t    if (!floor(tmp \/ CM_PERIOD)) {\n\t\tnth = INT2FIX(0);\n\t\tjd = (int)tmp;\n\t    }\n\t    else {\n\t\tdouble i, f;\n\n\t\tf = modf(tmp \/ CM_PERIOD, &i);\n\t\tnth = f_floor(DBL2NUM(i));\n\t\tjd = (int)(f * CM_PERIOD);\n\t    }\n\n\t    o *= DAY_IN_SECONDS;\n\t    o = modf(o, &tmp);\n\t    df = (int)tmp;\n\t    o *= SECOND_IN_NANOSECONDS;\n\t    sf = INT2FIX((int)round(o));\n\n\t    if (s < 0) {\n\t\tjd = -jd;\n\t\tdf = -df;\n\t\tsf = f_negate(sf);\n\t    }\n\n\t    if (f_zero_p(sf))\n\t\tsf = m_sf(dat);\n\t    else {\n\t\tsf = f_add(m_sf(dat), sf);\n\t\tif (f_lt_p(sf, INT2FIX(0))) {\n\t\t    df -= 1;\n\t\t    sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));\n\t\t}\n\t\telse if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {\n\t\t    df += 1;\n\t\t    sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));\n\t\t}\n\t    }\n\n\t    if (!df)\n\t\tdf = m_df(dat);\n\t    else {\n\t\tdf = m_df(dat) + df;\n\t\tif (df < 0) {\n\t\t    jd -= 1;\n\t\t    df += DAY_IN_SECONDS;\n\t\t}\n\t\telse if (df >= DAY_IN_SECONDS) {\n\t\t    jd += 1;\n\t\t    df -= DAY_IN_SECONDS;\n\t\t}\n\t    }\n\n\t    if (!jd)\n\t\tjd = m_jd(dat);\n\t    else {\n\t\tjd = m_jd(dat) + jd;\n\t\tcanonicalize_jd(nth, jd);\n\t    }\n\n\t    if (f_zero_p(nth))\n\t\tnth = m_nth(dat);\n\t    else\n\t\tnth = f_add(m_nth(dat), nth);\n\n\t    if (!df && f_zero_p(sf) && !m_of(dat))\n\t\treturn d_simple_new_internal(rb_obj_class(self),\n\t\t\t\t\t     nth, (int)jd,\n\t\t\t\t\t     m_sg(dat),\n\t\t\t\t\t     0, 0, 0,\n\t\t\t\t\t     (dat->s.flags | HAVE_JD) &\n\t\t\t\t\t     ~(HAVE_CIVIL | HAVE_TIME |\n\t\t\t\t\t       COMPLEX_DAT));\n\t    else\n\t\treturn d_complex_new_internal(rb_obj_class(self),\n\t\t\t\t\t      nth, (int)jd,\n\t\t\t\t\t      df, sf,\n\t\t\t\t\t      m_of(dat), m_sg(dat),\n\t\t\t\t\t      0, 0, 0,\n\t\t\t\t\t      0, 0, 0,\n\t\t\t\t\t      (dat->c.flags |\n\t\t\t\t\t       HAVE_JD | HAVE_DF) &\n\t\t\t\t\t      ~(HAVE_CIVIL | HAVE_TIME));\n\t}\n\tbreak;\n      default:\n\texpect_numeric(other);\n\tother = f_to_r(other);\n\tif (!k_rational_p(other)) {\n\t    if (!try_rational) Check_Type(other, T_RATIONAL);\n\t    try_rational = 0;\n\t    goto again;\n\t}\n\t\/* fall through *\/\n      case T_RATIONAL:\n\t{\n\t    VALUE nth, sf, t;\n\t    int jd, df, s;\n\n\t    if (wholenum_p(other)) {\n\t\tother = rb_rational_num(other);\n\t\tgoto again;\n\t    }\n\n\t    if (f_positive_p(other))\n\t\ts = +1;\n\t    else {\n\t\ts = -1;\n\t\tother = f_negate(other);\n\t    }\n\n\t    nth = f_idiv(other, INT2FIX(CM_PERIOD));\n\t    t = f_mod(other, INT2FIX(CM_PERIOD));\n\n\t    jd = FIX2INT(f_idiv(t, INT2FIX(1)));\n\t    t = f_mod(t, INT2FIX(1));\n\n\t    t = f_mul(t, INT2FIX(DAY_IN_SECONDS));\n\t    df = FIX2INT(f_idiv(t, INT2FIX(1)));\n\t    t = f_mod(t, INT2FIX(1));\n\n\t    sf = f_mul(t, INT2FIX(SECOND_IN_NANOSECONDS));\n\n\t    if (s < 0) {\n\t\tnth = f_negate(nth);\n\t\tjd = -jd;\n\t\tdf = -df;\n\t\tsf = f_negate(sf);\n\t    }\n\n\t    if (f_zero_p(sf))\n\t\tsf = m_sf(dat);\n\t    else {\n\t\tsf = f_add(m_sf(dat), sf);\n\t\tif (f_lt_p(sf, INT2FIX(0))) {\n\t\t    df -= 1;\n\t\t    sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));\n\t\t}\n\t\telse if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {\n\t\t    df += 1;\n\t\t    sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));\n\t\t}\n\t    }\n\n\t    if (!df)\n\t\tdf = m_df(dat);\n\t    else {\n\t\tdf = m_df(dat) + df;\n\t\tif (df < 0) {\n\t\t    jd -= 1;\n\t\t    df += DAY_IN_SECONDS;\n\t\t}\n\t\telse if (df >= DAY_IN_SECONDS) {\n\t\t    jd += 1;\n\t\t    df -= DAY_IN_SECONDS;\n\t\t}\n\t    }\n\n\t    if (!jd)\n\t\tjd = m_jd(dat);\n\t    else {\n\t\tjd = m_jd(dat) + jd;\n\t\tcanonicalize_jd(nth, jd);\n\t    }\n\n\t    if (f_zero_p(nth))\n\t\tnth = m_nth(dat);\n\t    else\n\t\tnth = f_add(m_nth(dat), nth);\n\n\t    if (!df && f_zero_p(sf) && !m_of(dat))\n\t\treturn d_simple_new_internal(rb_obj_class(self),\n\t\t\t\t\t     nth, jd,\n\t\t\t\t\t     m_sg(dat),\n\t\t\t\t\t     0, 0, 0,\n\t\t\t\t\t     (dat->s.flags | HAVE_JD) &\n\t\t\t\t\t     ~(HAVE_CIVIL | HAVE_TIME |\n\t\t\t\t\t       COMPLEX_DAT));\n\t    else\n\t\treturn d_complex_new_internal(rb_obj_class(self),\n\t\t\t\t\t      nth, jd,\n\t\t\t\t\t      df, sf,\n\t\t\t\t\t      m_of(dat), m_sg(dat),\n\t\t\t\t\t      0, 0, 0,\n\t\t\t\t\t      0, 0, 0,\n\t\t\t\t\t      (dat->c.flags |\n\t\t\t\t\t       HAVE_JD | HAVE_DF) &\n\t\t\t\t\t      ~(HAVE_CIVIL | HAVE_TIME));\n\t}\n\tbreak;\n    }\n}","target":0,"code_token_length":2118,"total_token_length":2354,"max_tokens_setting":4096}
+{"idx":346462,"func":"do_source_ext(\n    char_u\t*fname,\n    int\t\tcheck_other,\t    \/\/ check for .vimrc and _vimrc\n    int\t\tis_vimrc,\t    \/\/ DOSO_ value\n    int\t\t*ret_sid UNUSED,\n    exarg_T\t*eap,\n    int\t\tclearvars UNUSED)\n{\n    source_cookie_T\t    cookie;\n    char_u\t\t    *p;\n    char_u\t\t    *fname_exp;\n    char_u\t\t    *firstline = NULL;\n    int\t\t\t    retval = FAIL;\n    sctx_T\t\t    save_current_sctx;\n#ifdef FEAT_EVAL\n    funccal_entry_T\t    funccalp_entry;\n    int\t\t\t    save_debug_break_level = debug_break_level;\n    int\t\t\t    sid;\n    scriptitem_T\t    *si = NULL;\n    int\t\t\t    save_estack_compiling = estack_compiling;\n#endif\n#ifdef STARTUPTIME\n    struct timeval\t    tv_rel;\n    struct timeval\t    tv_start;\n#endif\n#ifdef FEAT_PROFILE\n    proftime_T\t\t    wait_start;\n#endif\n    int\t\t\t    save_sticky_cmdmod_flags = sticky_cmdmod_flags;\n    int\t\t\t    trigger_source_post = FALSE;\n    ESTACK_CHECK_DECLARATION\n\n    CLEAR_FIELD(cookie);\n    if (fname == NULL)\n    {\n\t\/\/ sourcing lines from a buffer\n\tfname_exp = do_source_buffer_init(&cookie, eap);\n\tif (fname_exp == NULL)\n\t    return FAIL;\n    }\n    else\n    {\n\tp = expand_env_save(fname);\n\tif (p == NULL)\n\t    return retval;\n\tfname_exp = fix_fname(p);\n\tvim_free(p);\n\tif (fname_exp == NULL)\n\t    return retval;\n\tif (mch_isdir(fname_exp))\n\t{\n\t    smsg(_(\"Cannot source a directory: \\\"%s\\\"\"), fname);\n\t    goto theend;\n\t}\n    }\n#ifdef FEAT_EVAL\n    estack_compiling = FALSE;\n\n    \/\/ See if we loaded this script before.\n    sid = find_script_by_name(fname_exp);\n    if (sid > 0 && ret_sid != NULL\n\t\t\t  && SCRIPT_ITEM(sid)->sn_state != SN_STATE_NOT_LOADED)\n    {\n\t\/\/ Already loaded and no need to load again, return here.\n\t*ret_sid = sid;\n\tretval = OK;\n\tgoto theend;\n    }\n#endif\n\n    \/\/ Apply SourceCmd autocommands, they should get the file and source it.\n    if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL)\n\t    && apply_autocmds(EVENT_SOURCECMD, fname_exp, fname_exp,\n\t\t\t\t\t\t\t       FALSE, curbuf))\n    {\n#ifdef FEAT_EVAL\n\tretval = aborting() ? FAIL : OK;\n#else\n\tretval = OK;\n#endif\n\tif (retval == OK)\n\t    \/\/ Apply SourcePost autocommands.\n\t    apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp,\n\t\t\t\t\t\t\t\tFALSE, curbuf);\n\tgoto theend;\n    }\n\n    \/\/ Apply SourcePre autocommands, they may get the file.\n    apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, FALSE, curbuf);\n\n    if (!cookie.source_from_buf)\n    {\n#ifdef USE_FOPEN_NOINH\n\tcookie.fp = fopen_noinh_readbin((char *)fname_exp);\n#else\n\tcookie.fp = mch_fopen((char *)fname_exp, READBIN);\n#endif\n    }\n    if (cookie.fp == NULL && check_other)\n    {\n\t\/\/ Try again, replacing file name \".vimrc\" by \"_vimrc\" or vice versa,\n\t\/\/ and \".exrc\" by \"_exrc\" or vice versa.\n\tp = gettail(fname_exp);\n\tif ((*p == '.' || *p == '_')\n\t\t&& (STRICMP(p + 1, \"vimrc\") == 0\n\t\t    || STRICMP(p + 1, \"gvimrc\") == 0\n\t\t    || STRICMP(p + 1, \"exrc\") == 0))\n\t{\n\t    if (*p == '_')\n\t\t*p = '.';\n\t    else\n\t\t*p = '_';\n#ifdef USE_FOPEN_NOINH\n\t    cookie.fp = fopen_noinh_readbin((char *)fname_exp);\n#else\n\t    cookie.fp = mch_fopen((char *)fname_exp, READBIN);\n#endif\n\t}\n    }\n\n    if (cookie.fp == NULL && !cookie.source_from_buf)\n    {\n\tif (p_verbose > 0)\n\t{\n\t    verbose_enter();\n\t    if (SOURCING_NAME == NULL)\n\t\tsmsg(_(\"could not source \\\"%s\\\"\"), fname);\n\t    else\n\t\tsmsg(_(\"line %ld: could not source \\\"%s\\\"\"),\n\t\t\t\t\t\t\tSOURCING_LNUM, fname);\n\t    verbose_leave();\n\t}\n\tgoto theend;\n    }\n\n    \/\/ The file exists.\n    \/\/ - In verbose mode, give a message.\n    \/\/ - For a vimrc file, may want to set 'compatible', call vimrc_found().\n    if (p_verbose > 1)\n    {\n\tverbose_enter();\n\tif (SOURCING_NAME == NULL)\n\t    smsg(_(\"sourcing \\\"%s\\\"\"), fname);\n\telse\n\t    smsg(_(\"line %ld: sourcing \\\"%s\\\"\"), SOURCING_LNUM, fname);\n\tverbose_leave();\n    }\n    if (is_vimrc == DOSO_VIMRC)\n\tvimrc_found(fname_exp, (char_u *)\"MYVIMRC\");\n    else if (is_vimrc == DOSO_GVIMRC)\n\tvimrc_found(fname_exp, (char_u *)\"MYGVIMRC\");\n\n#ifdef USE_CRNL\n    \/\/ If no automatic file format: Set default to CR-NL.\n    if (*p_ffs == NUL)\n\tcookie.fileformat = EOL_DOS;\n    else\n\tcookie.fileformat = EOL_UNKNOWN;\n#endif\n\n    if (fname == NULL)\n\t\/\/ When sourcing a range of lines from a buffer, use the buffer line\n\t\/\/ number.\n\tcookie.sourcing_lnum = eap->line1 - 1;\n    else\n\tcookie.sourcing_lnum = 0;\n\n#ifdef FEAT_EVAL\n    \/\/ Check if this script has a breakpoint.\n    cookie.breakpoint = dbg_find_breakpoint(TRUE, fname_exp, (linenr_T)0);\n    cookie.fname = fname_exp;\n    cookie.dbg_tick = debug_tick;\n\n    cookie.level = ex_nesting_level;\n#endif\n\n    \/\/ Keep the sourcing name\/lnum, for recursive calls.\n    estack_push(ETYPE_SCRIPT, fname_exp, 0);\n    ESTACK_CHECK_SETUP\n\n#ifdef STARTUPTIME\n    if (time_fd != NULL)\n\ttime_push(&tv_rel, &tv_start);\n#endif\n\n    \/\/ \"legacy\" does not apply to commands in the script\n    sticky_cmdmod_flags = 0;\n\n    save_current_sctx = current_sctx;\n    if (cmdmod.cmod_flags & CMOD_VIM9CMD)\n\t\/\/ When the \":vim9cmd\" command modifier is used, source the script as a\n\t\/\/ Vim9 script.\n\tcurrent_sctx.sc_version = SCRIPT_VERSION_VIM9;\n    else\n\tcurrent_sctx.sc_version = 1;  \/\/ default script version\n\n#ifdef FEAT_EVAL\n# ifdef FEAT_PROFILE\n    if (do_profiling == PROF_YES)\n\tprof_child_enter(&wait_start);\t\t\/\/ entering a child now\n# endif\n\n    \/\/ Don't use local function variables, if called from a function.\n    \/\/ Also starts profiling timer for nested script.\n    save_funccal(&funccalp_entry);\n\n    current_sctx.sc_lnum = 0;\n\n    \/\/ Check if this script was sourced before to find its SID.\n    \/\/ Always use a new sequence number.\n    current_sctx.sc_seq = ++last_current_SID_seq;\n    if (sid > 0)\n    {\n\thashtab_T\t*ht;\n\tint\t\ttodo;\n\thashitem_T\t*hi;\n\tdictitem_T\t*di;\n\n\t\/\/ loading the same script again\n\tcurrent_sctx.sc_sid = sid;\n\tsi = SCRIPT_ITEM(sid);\n\tif (si->sn_state == SN_STATE_NOT_LOADED)\n\t{\n\t    \/\/ this script was found but not loaded yet\n\t    si->sn_state = SN_STATE_NEW;\n\t}\n\telse\n\t{\n\t    si->sn_state = SN_STATE_RELOAD;\n\n\t    if (!clearvars)\n\t    {\n\t\t\/\/ Script-local variables remain but \"const\" can be set again.\n\t\t\/\/ In Vim9 script variables will be cleared when \"vim9script\"\n\t\t\/\/ is encountered without the \"noclear\" argument.\n\t\tht = &SCRIPT_VARS(sid);\n\t\ttodo = (int)ht->ht_used;\n\t\tfor (hi = ht->ht_array; todo > 0; ++hi)\n\t\t    if (!HASHITEM_EMPTY(hi))\n\t\t    {\n\t\t\t--todo;\n\t\t\tdi = HI2DI(hi);\n\t\t\tdi->di_flags |= DI_FLAGS_RELOAD;\n\t\t    }\n\t\t\/\/ imports can be redefined once\n\t\tmark_imports_for_reload(sid);\n\t    }\n\t    else\n\t\tclear_vim9_scriptlocal_vars(sid);\n\n\t    \/\/ reset version, \"vim9script\" may have been added or removed.\n\t    si->sn_version = 1;\n\t}\n    }\n    else\n    {\n\tint error = OK;\n\n\t\/\/ It's new, generate a new SID and initialize the scriptitem.\n\tcurrent_sctx.sc_sid = get_new_scriptitem(&error);\n\tif (error == FAIL)\n\t    goto almosttheend;\n\tsi = SCRIPT_ITEM(current_sctx.sc_sid);\n\tsi->sn_name = fname_exp;\n\tfname_exp = vim_strsave(si->sn_name);  \/\/ used for autocmd\n\tif (ret_sid != NULL)\n\t    *ret_sid = current_sctx.sc_sid;\n\n\t\/\/ Remember the \"is_vimrc\" flag for when the file is sourced again.\n\tsi->sn_is_vimrc = is_vimrc;\n    }\n\n# ifdef FEAT_PROFILE\n    if (do_profiling == PROF_YES)\n    {\n\tint\tforceit;\n\n\t\/\/ Check if we do profiling for this script.\n\tif (!si->sn_prof_on && has_profiling(TRUE, si->sn_name, &forceit))\n\t{\n\t    script_do_profile(si);\n\t    si->sn_pr_force = forceit;\n\t}\n\tif (si->sn_prof_on)\n\t{\n\t    ++si->sn_pr_count;\n\t    profile_start(&si->sn_pr_start);\n\t    profile_zero(&si->sn_pr_children);\n\t}\n    }\n# endif\n#endif\n\n    cookie.conv.vc_type = CONV_NONE;\t\t\/\/ no conversion\n\n    \/\/ Read the first line so we can check for a UTF-8 BOM.\n    firstline = getsourceline(0, (void *)&cookie, 0, TRUE);\n    if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef\n\t\t\t      && firstline[1] == 0xbb && firstline[2] == 0xbf)\n    {\n\t\/\/ Found BOM; setup conversion, skip over BOM and recode the line.\n\tconvert_setup(&cookie.conv, (char_u *)\"utf-8\", p_enc);\n\tp = string_convert(&cookie.conv, firstline + 3, NULL);\n\tif (p == NULL)\n\t    p = vim_strsave(firstline + 3);\n\tif (p != NULL)\n\t{\n\t    vim_free(firstline);\n\t    firstline = p;\n\t}\n    }\n\n    \/\/ Call do_cmdline, which will call getsourceline() to get the lines.\n    do_cmdline(firstline, getsourceline, (void *)&cookie,\n\t\t\t\t     DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);\n    retval = OK;\n\n#ifdef FEAT_PROFILE\n    if (do_profiling == PROF_YES)\n    {\n\t\/\/ Get \"si\" again, \"script_items\" may have been reallocated.\n\tsi = SCRIPT_ITEM(current_sctx.sc_sid);\n\tif (si->sn_prof_on)\n\t{\n\t    profile_end(&si->sn_pr_start);\n\t    profile_sub_wait(&wait_start, &si->sn_pr_start);\n\t    profile_add(&si->sn_pr_total, &si->sn_pr_start);\n\t    profile_self(&si->sn_pr_self, &si->sn_pr_start,\n\t\t\t\t\t\t\t &si->sn_pr_children);\n\t}\n    }\n#endif\n\n    if (got_int)\n\temsg(_(e_interrupted));\n    ESTACK_CHECK_NOW\n    estack_pop();\n    if (p_verbose > 1)\n    {\n\tverbose_enter();\n\tsmsg(_(\"finished sourcing %s\"), fname);\n\tif (SOURCING_NAME != NULL)\n\t    smsg(_(\"continuing in %s\"), SOURCING_NAME);\n\tverbose_leave();\n    }\n#ifdef STARTUPTIME\n    if (time_fd != NULL)\n    {\n\tvim_snprintf((char *)IObuff, IOSIZE, \"sourcing %s\", fname);\n\ttime_msg((char *)IObuff, &tv_start);\n\ttime_pop(&tv_rel);\n    }\n#endif\n\n    if (!got_int)\n\ttrigger_source_post = TRUE;\n\n#ifdef FEAT_EVAL\n    \/\/ After a \"finish\" in debug mode, need to break at first command of next\n    \/\/ sourced file.\n    if (save_debug_break_level > ex_nesting_level\n\t    && debug_break_level == ex_nesting_level)\n\t++debug_break_level;\n#endif\n\n#ifdef FEAT_EVAL\nalmosttheend:\n    \/\/ If \"sn_save_cpo\" is set that means we encountered \"vim9script\": restore\n    \/\/ 'cpoptions', unless in the main .vimrc file.\n    \/\/ Get \"si\" again, \"script_items\" may have been reallocated.\n    si = SCRIPT_ITEM(current_sctx.sc_sid);\n    if (si->sn_save_cpo != NULL && si->sn_is_vimrc == DOSO_NONE)\n    {\n\tif (STRCMP(p_cpo, CPO_VIM) != 0)\n\t{\n\t    char_u *f;\n\t    char_u *t;\n\n\t    \/\/ 'cpo' was changed in the script.  Apply the same change to the\n\t    \/\/ saved value, if possible.\n\t    for (f = (char_u *)CPO_VIM; *f != NUL; ++f)\n\t\tif (vim_strchr(p_cpo, *f) == NULL\n\t\t\t&& (t = vim_strchr(si->sn_save_cpo, *f)) != NULL)\n\t\t    \/\/ flag was removed, also remove it from the saved 'cpo'\n\t\t    mch_memmove(t, t + 1, STRLEN(t));\n\t    for (f = p_cpo; *f != NUL; ++f)\n\t\tif (vim_strchr((char_u *)CPO_VIM, *f) == NULL\n\t\t\t&& vim_strchr(si->sn_save_cpo, *f) == NULL)\n\t\t{\n\t\t    \/\/ flag was added, also add it to the saved 'cpo'\n\t\t    t = alloc(STRLEN(si->sn_save_cpo) + 2);\n\t\t    if (t != NULL)\n\t\t    {\n\t\t\t*t = *f;\n\t\t\tSTRCPY(t + 1, si->sn_save_cpo);\n\t\t\tvim_free(si->sn_save_cpo);\n\t\t\tsi->sn_save_cpo = t;\n\t\t    }\n\t\t}\n\t}\n\tset_option_value_give_err((char_u *)\"cpo\",\n\t\t\t\t\t   0L, si->sn_save_cpo, OPT_NO_REDRAW);\n    }\n    VIM_CLEAR(si->sn_save_cpo);\n\n    restore_funccal();\n# ifdef FEAT_PROFILE\n    if (do_profiling == PROF_YES)\n\tprof_child_exit(&wait_start);\t\t\/\/ leaving a child now\n# endif\n#endif\n    current_sctx = save_current_sctx;\n\n    if (cookie.fp != NULL)\n\tfclose(cookie.fp);\n    if (cookie.source_from_buf)\n\tga_clear_strings(&cookie.buflines);\n    vim_free(cookie.nextline);\n    vim_free(firstline);\n    convert_setup(&cookie.conv, NULL, NULL);\n\n    if (trigger_source_post)\n\tapply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf);\n\ntheend:\n    vim_free(fname_exp);\n    sticky_cmdmod_flags = save_sticky_cmdmod_flags;\n#ifdef FEAT_EVAL\n    estack_compiling = save_estack_compiling;\n#endif\n    return retval;\n}","target":0,"code_token_length":3428,"total_token_length":3664,"max_tokens_setting":4096}
+{"idx":230632,"func":"void derive_spatial_luma_vector_prediction(base_context* ctx,\n                                           de265_image* img,\n                                           const slice_segment_header* shdr,\n                                           int xC,int yC,int nCS,int xP,int yP,\n                                           int nPbW,int nPbH, int X,\n                                           int refIdxLX, int partIdx,\n                                           uint8_t out_availableFlagLXN[2],\n                                           MotionVector out_mvLXN[2])\n{\n  int isScaledFlagLX = 0;\n\n  const int A=0;\n  const int B=1;\n\n  out_availableFlagLXN[A] = 0;\n  out_availableFlagLXN[B] = 0;\n\n\n  \/\/ --- A ---\n\n  \/\/ 1.\n\n  int xA[2], yA[2];\n  xA[0] = xP-1;\n  yA[0] = yP + nPbH;\n  xA[1] = xA[0];\n  yA[1] = yA[0]-1;\n\n  \/\/ 2.\n\n  out_availableFlagLXN[A] = 0;\n  out_mvLXN[A].x = 0;\n  out_mvLXN[A].y = 0;\n\n  \/\/ 3. \/ 4.\n\n  bool availableA[2];\n  availableA[0] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA[0],yA[0]);\n  availableA[1] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA[1],yA[1]);\n\n  \/\/ 5.\n\n  if (availableA[0] || availableA[1]) {\n    isScaledFlagLX = 1;\n  }\n\n  \/\/ 6.  test A0 and A1  (Ak)\n\n  int refIdxA=-1;\n\n  \/\/ the POC we want to reference in this PB\n  const de265_image* tmpimg = ctx->get_image(shdr->RefPicList[X][ refIdxLX ]);\n  if (tmpimg==NULL) { return; }\n  const int referenced_POC = tmpimg->PicOrderCntVal;\n\n  for (int k=0;k<=1;k++) {\n    if (availableA[k] &&\n        out_availableFlagLXN[A]==0 && \/\/ no A?-predictor so far\n        img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) {\n\n      int Y=1-X;\n\n      const PBMotion& vi = img->get_mv_info(xA[k],yA[k]);\n      logtrace(LogMotion,\"MVP A%d=\\n\",k);\n      logmvcand(vi);\n\n      const de265_image* imgX = NULL;\n      if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]);\n      const de265_image* imgY = NULL;\n      if (vi.predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]);\n\n      \/\/ check whether the predictor X is available and references the same POC\n      if (vi.predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) {\n\n        logtrace(LogMotion,\"take A%d\/L%d as A candidate with same POC\\n\",k,X);\n\n        out_availableFlagLXN[A]=1;\n        out_mvLXN[A] = vi.mv[X];\n        refIdxA = vi.refIdx[X];\n      }\n      \/\/ check whether the other predictor (Y) is available and references the same POC\n      else if (vi.predFlag[Y] && imgY && imgY->PicOrderCntVal == referenced_POC) {\n\n        logtrace(LogMotion,\"take A%d\/L%d as A candidate with same POC\\n\",k,Y);\n\n        out_availableFlagLXN[A]=1;\n        out_mvLXN[A] = vi.mv[Y];\n        refIdxA = vi.refIdx[Y];\n      }\n    }\n  }\n\n  \/\/ 7. If there is no predictor referencing the same POC, we take any other reference as\n  \/\/    long as it is the same type of reference (long-term \/ short-term)\n\n  for (int k=0 ; k<=1 && out_availableFlagLXN[A]==0 ; k++) {\n    int refPicList=-1;\n\n    if (availableA[k] &&\n        \/\/ TODO: we could remove this call by storing the result of the similar computation above\n        img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) {\n\n      int Y=1-X;\n\n      const PBMotion& vi = img->get_mv_info(xA[k],yA[k]);\n      if (vi.predFlag[X]==1 &&\n          shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[X][ vi.refIdx[X] ]) {\n\n        logtrace(LogMotion,\"take A%D\/L%d as A candidate with different POCs\\n\",k,X);\n\n        out_availableFlagLXN[A]=1;\n        out_mvLXN[A] = vi.mv[X];\n        refIdxA = vi.refIdx[X];\n        refPicList = X;\n      }\n      else if (vi.predFlag[Y]==1 &&\n               shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[Y][ vi.refIdx[Y] ]) {\n\n        logtrace(LogMotion,\"take A%d\/L%d as A candidate with different POCs\\n\",k,Y);\n\n        out_availableFlagLXN[A]=1;\n        out_mvLXN[A] = vi.mv[Y];\n        refIdxA = vi.refIdx[Y];\n        refPicList = Y;\n      }\n    }\n\n    if (out_availableFlagLXN[A]==1) {\n      if (refIdxA<0) {\n        out_availableFlagLXN[0] = out_availableFlagLXN[1] = false;\n        return; \/\/ error\n      }\n\n      assert(refIdxA>=0);\n      assert(refPicList>=0);\n\n      const de265_image* refPicA = ctx->get_image(shdr->RefPicList[refPicList][refIdxA ]);\n      const de265_image* refPicX = ctx->get_image(shdr->RefPicList[X         ][refIdxLX]);\n\n      \/\/int picStateA = shdr->RefPicList_PicState[refPicList][refIdxA ];\n      \/\/int picStateX = shdr->RefPicList_PicState[X         ][refIdxLX];\n\n      int isLongTermA = shdr->LongTermRefPic[refPicList][refIdxA ];\n      int isLongTermX = shdr->LongTermRefPic[X         ][refIdxLX];\n\n      logtrace(LogMotion,\"scale MVP A: A-POC:%d X-POC:%d\\n\",\n               refPicA->PicOrderCntVal,refPicX->PicOrderCntVal);\n\n      if (!isLongTermA && !isLongTermX)\n      \/*\n      if (picStateA == UsedForShortTermReference &&\n          picStateX == UsedForShortTermReference)\n      *\/\n        {\n          int distA = img->PicOrderCntVal - refPicA->PicOrderCntVal;\n          int distX = img->PicOrderCntVal - referenced_POC;\n\n          if (!scale_mv(&out_mvLXN[A], out_mvLXN[A], distA, distX)) {\n            ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);\n            img->integrity = INTEGRITY_DECODING_ERRORS;\n          }\n        }\n    }\n  }\n\n\n  \/\/ --- B ---\n\n  \/\/ 1.\n\n  int xB[3], yB[3];\n  xB[0] = xP+nPbW;\n  yB[0] = yP-1;\n  xB[1] = xB[0]-1;\n  yB[1] = yP-1;\n  xB[2] = xP-1;\n  yB[2] = yP-1;\n\n  \/\/ 2.\n\n  out_availableFlagLXN[B] = 0;\n  out_mvLXN[B].x = 0;\n  out_mvLXN[B].y = 0;\n\n  \/\/ 3. test B0,B1,B2 (Bk)\n\n  int refIdxB=-1;\n\n  bool availableB[3];\n  for (int k=0;k<3;k++) {\n    availableB[k] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xB[k],yB[k]);\n\n    if (availableB[k] && out_availableFlagLXN[B]==0) {\n\n      int Y=1-X;\n\n      const PBMotion& vi = img->get_mv_info(xB[k],yB[k]);\n      logtrace(LogMotion,\"MVP B%d=\\n\",k);\n      logmvcand(vi);\n\n\n      const de265_image* imgX = NULL;\n      if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]);\n      const de265_image* imgY = NULL;\n      if (vi.predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]);\n\n      if (vi.predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) {\n        logtrace(LogMotion,\"a) take B%d\/L%d as B candidate with same POC\\n\",k,X);\n\n        out_availableFlagLXN[B]=1;\n        out_mvLXN[B] = vi.mv[X];\n        refIdxB = vi.refIdx[X];\n      }\n      else if (vi.predFlag[Y] && imgY && imgY->PicOrderCntVal == referenced_POC) {\n        logtrace(LogMotion,\"b) take B%d\/L%d as B candidate with same POC\\n\",k,Y);\n\n        out_availableFlagLXN[B]=1;\n        out_mvLXN[B] = vi.mv[Y];\n        refIdxB = vi.refIdx[Y];\n      }\n    }\n  }\n\n  \/\/ 4.\n\n  if (isScaledFlagLX==0 &&      \/\/ no A predictor,\n      out_availableFlagLXN[B])  \/\/ but an unscaled B predictor\n    {\n      \/\/ use unscaled B predictor as A predictor\n\n      logtrace(LogMotion,\"copy the same-POC B candidate as additional A candidate\\n\");\n\n      out_availableFlagLXN[A]=1;\n      out_mvLXN[A] = out_mvLXN[B];\n      refIdxA = refIdxB;\n    }\n\n  \/\/ 5.\n\n  \/\/ If no A predictor, we output the unscaled B as the A predictor (above)\n  \/\/ and also add a scaled B predictor here.\n  \/\/ If there is (probably) an A predictor, no differing-POC B predictor is generated.\n  if (isScaledFlagLX==0) {\n    out_availableFlagLXN[B]=0;\n\n    for (int k=0 ; k<=2 && out_availableFlagLXN[B]==0 ; k++) {\n      int refPicList=-1;\n\n      if (availableB[k]) {\n        int Y=1-X;\n\n        const PBMotion& vi = img->get_mv_info(xB[k],yB[k]);\n\n        if (vi.predFlag[X]==1 &&\n            shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[X][ vi.refIdx[X] ]) {\n          out_availableFlagLXN[B]=1;\n          out_mvLXN[B] = vi.mv[X];\n          refIdxB = vi.refIdx[X];\n          refPicList = X;\n        }\n        else if (vi.predFlag[Y]==1 &&\n                 shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[Y][ vi.refIdx[Y] ]) {\n          out_availableFlagLXN[B]=1;\n          out_mvLXN[B] = vi.mv[Y];\n          refIdxB = vi.refIdx[Y];\n          refPicList = Y;\n        }\n      }\n\n      if (out_availableFlagLXN[B]==1) {\n        if (refIdxB<0) {\n          out_availableFlagLXN[0] = out_availableFlagLXN[1] = false;\n          return; \/\/ error\n        }\n\n        assert(refPicList>=0);\n        assert(refIdxB>=0);\n\n        const de265_image* refPicB=ctx->get_image(shdr->RefPicList[refPicList][refIdxB ]);\n        const de265_image* refPicX=ctx->get_image(shdr->RefPicList[X         ][refIdxLX]);\n\n        int isLongTermB = shdr->LongTermRefPic[refPicList][refIdxB ];\n        int isLongTermX = shdr->LongTermRefPic[X         ][refIdxLX];\n\n        if (refPicB==NULL || refPicX==NULL) {\n          img->decctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED,false);\n          img->integrity = INTEGRITY_DECODING_ERRORS;\n        }\n        else if (refPicB->PicOrderCntVal != refPicX->PicOrderCntVal &&\n                 !isLongTermB && !isLongTermX) {\n          int distB = img->PicOrderCntVal - refPicB->PicOrderCntVal;\n          int distX = img->PicOrderCntVal - referenced_POC;\n\n          logtrace(LogMotion,\"scale MVP B: B-POC:%d X-POC:%d\\n\",refPicB->PicOrderCntVal,refPicX->PicOrderCntVal);\n\n          if (!scale_mv(&out_mvLXN[B], out_mvLXN[B], distB, distX)) {\n            ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);\n            img->integrity = INTEGRITY_DECODING_ERRORS;\n          }\n        }\n      }\n    }\n  }\n}","target":0,"code_token_length":3123,"total_token_length":3359,"max_tokens_setting":4096}
+{"idx":446064,"func":"LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)\n{\n\tstatic const char module[] = \"LZWDecode\";\n\tLZWCodecState *sp = DecoderState(tif);\n\tchar *op = (char*) op0;\n\tlong occ = (long) occ0;\n\tchar *tp;\n\tunsigned char *bp;\n\thcode_t code;\n\tint len;\n\tlong nbits, nextbits, nbitsmask;\n        unsigned long nextdata;\n\tcode_t *codep, *free_entp, *maxcodep, *oldcodep;\n\n\t(void) s;\n\tassert(sp != NULL);\n        assert(sp->dec_codetab != NULL);\n\n\t\/*\n\t  Fail if value does not fit in long.\n\t*\/\n\tif ((tmsize_t) occ != occ0)\n\t        return (0);\n\t\/*\n\t * Restart interrupted output operation.\n\t *\/\n\tif (sp->dec_restart) {\n\t\tlong residue;\n\n\t\tcodep = sp->dec_codep;\n\t\tresidue = codep->length - sp->dec_restart;\n\t\tif (residue > occ) {\n\t\t\t\/*\n\t\t\t * Residue from previous decode is sufficient\n\t\t\t * to satisfy decode request.  Skip to the\n\t\t\t * start of the decoded string, place decoded\n\t\t\t * values in the output buffer, and return.\n\t\t\t *\/\n\t\t\tsp->dec_restart += occ;\n\t\t\tdo {\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--residue > occ && codep);\n\t\t\tif (codep) {\n\t\t\t\ttp = op + occ;\n\t\t\t\tdo {\n\t\t\t\t\t*--tp = codep->value;\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (--occ && codep);\n\t\t\t}\n\t\t\treturn (1);\n\t\t}\n\t\t\/*\n\t\t * Residue satisfies only part of the decode request.\n\t\t *\/\n\t\top += residue;\n\t\tocc -= residue;\n\t\ttp = op;\n\t\tdo {\n\t\t\tint t;\n\t\t\t--tp;\n\t\t\tt = codep->value;\n\t\t\tcodep = codep->next;\n\t\t\t*tp = (char)t;\n\t\t} while (--residue && codep);\n\t\tsp->dec_restart = 0;\n\t}\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n#ifdef LZW_CHECKEOS\n\tsp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);\n#endif\n\tnbits = sp->lzw_nbits;\n\tnextdata = sp->lzw_nextdata;\n\tnextbits = sp->lzw_nextbits;\n\tnbitsmask = sp->dec_nbitsmask;\n\toldcodep = sp->dec_oldcodep;\n\tfree_entp = sp->dec_free_entp;\n\tmaxcodep = sp->dec_maxcodep;\n\n\twhile (occ > 0) {\n\t\tNextCode(tif, sp, bp, code, GetNextCode);\n\t\tif (code == CODE_EOI)\n\t\t\tbreak;\n\t\tif (code == CODE_CLEAR) {\n\t\t\tdo {\n\t\t\t\tfree_entp = sp->dec_codetab + CODE_FIRST;\n\t\t\t\t_TIFFmemset(free_entp, 0,\n\t\t\t\t\t    (CSIZE - CODE_FIRST) * sizeof (code_t));\n\t\t\t\tnbits = BITS_MIN;\n\t\t\t\tnbitsmask = MAXCODE(BITS_MIN);\n\t\t\t\tmaxcodep = sp->dec_codetab + nbitsmask-1;\n\t\t\t\tNextCode(tif, sp, bp, code, GetNextCode);\n\t\t\t} while (code == CODE_CLEAR);\t\/* consecutive CODE_CLEAR codes *\/\n\t\t\tif (code == CODE_EOI)\n\t\t\t\tbreak;\n\t\t\tif (code > CODE_CLEAR) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, tif->tif_name,\n\t\t\t\t\"LZWDecode: Corrupted LZW table at scanline %d\",\n\t\t\t\t\t     tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t\toldcodep = sp->dec_codetab + code;\n\t\t\tcontinue;\n\t\t}\n\t\tcodep = sp->dec_codetab + code;\n\n\t\t\/*\n\t\t * Add the new entry to the code table.\n\t\t *\/\n\t\tif (free_entp < &sp->dec_codetab[0] ||\n\t\t    free_entp >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    \"Corrupted LZW table at scanline %d\",\n\t\t\t    tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\n\t\tfree_entp->next = oldcodep;\n\t\tif (free_entp->next < &sp->dec_codetab[0] ||\n\t\t    free_entp->next >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    \"Corrupted LZW table at scanline %d\",\n\t\t\t    tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\t\tfree_entp->firstchar = free_entp->next->firstchar;\n\t\tfree_entp->length = free_entp->next->length+1;\n\t\tfree_entp->value = (codep < free_entp) ?\n\t\t    codep->firstchar : free_entp->firstchar;\n\t\tif (++free_entp > maxcodep) {\n\t\t\tif (++nbits > BITS_MAX)\t\t\/* should not happen *\/\n\t\t\t\tnbits = BITS_MAX;\n\t\t\tnbitsmask = MAXCODE(nbits);\n\t\t\tmaxcodep = sp->dec_codetab + nbitsmask-1;\n\t\t}\n\t\toldcodep = codep;\n\t\tif (code >= 256) {\n\t\t\t\/*\n\t\t\t * Code maps to a string, copy string\n\t\t\t * value to output (written in reverse).\n\t\t\t *\/\n\t\t\tif(codep->length == 0) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\t    \"Wrong length of decoded string: \"\n\t\t\t\t    \"data probably corrupted at scanline %d\",\n\t\t\t\t    tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\tif (codep->length > occ) {\n\t\t\t\t\/*\n\t\t\t\t * String is too long for decode buffer,\n\t\t\t\t * locate portion that will fit, copy to\n\t\t\t\t * the decode buffer, and setup restart\n\t\t\t\t * logic for the next decoding call.\n\t\t\t\t *\/\n\t\t\t\tsp->dec_codep = codep;\n\t\t\t\tdo {\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (codep && codep->length > occ);\n\t\t\t\tif (codep) {\n\t\t\t\t\tsp->dec_restart = (long)occ;\n\t\t\t\t\ttp = op + occ;\n\t\t\t\t\tdo  {\n\t\t\t\t\t\t*--tp = codep->value;\n\t\t\t\t\t\tcodep = codep->next;\n\t\t\t\t\t}  while (--occ && codep);\n\t\t\t\t\tif (codep)\n\t\t\t\t\t\tcodeLoop(tif, module);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlen = codep->length;\n\t\t\ttp = op + len;\n\t\t\tdo {\n\t\t\t\tint t;\n\t\t\t\t--tp;\n\t\t\t\tt = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t\t*tp = (char)t;\n\t\t\t} while (codep && tp > op);\n\t\t\tif (codep) {\n\t\t\t    codeLoop(tif, module);\n\t\t\t    break;\n\t\t\t}\n\t\t\tassert(occ >= len);\n\t\t\top += len;\n\t\t\tocc -= len;\n\t\t} else {\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t}\n\t}\n\n\ttif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );\n\ttif->tif_rawcp = (uint8*) bp;\n\tsp->lzw_nbits = (unsigned short) nbits;\n\tsp->lzw_nextdata = nextdata;\n\tsp->lzw_nextbits = nextbits;\n\tsp->dec_nbitsmask = nbitsmask;\n\tsp->dec_oldcodep = oldcodep;\n\tsp->dec_free_entp = free_entp;\n\tsp->dec_maxcodep = maxcodep;\n\n\tif (occ > 0) {\n#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %I64d bytes)\",\n\t\t\t     tif->tif_row, (unsigned __int64) occ);\n#else\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %llu bytes)\",\n\t\t\t     tif->tif_row, (unsigned long long) occ);\n#endif\n\t\treturn (0);\n\t}\n\treturn (1);\n}","target":0,"code_token_length":1843,"total_token_length":2079,"max_tokens_setting":4096}
+{"idx":206273,"func":"static void extract_arg(RAnal *anal, RAnalFunction *fcn, RAnalOp *op, const char *reg, const char *sign, char type) {\n\tst64 ptr = 0;\n\tchar *addr, *esil_buf = NULL;\n\tconst st64 maxstackframe = 1024 * 8; \n\n\tr_return_if_fail (anal && fcn && op && reg);\n\n\tsize_t i;\n\tfor (i = 0; i < R_ARRAY_SIZE (op->src); i++) {\n\t\tif (op->src[i] && op->src[i]->reg && op->src[i]->reg->name) {\n\t\t\tif (!strcmp (reg, op->src[i]->reg->name)) {\n\t\t\t\tst64 delta = op->src[i]->delta;\n\t\t\t\tif ((delta > 0 && *sign == '+') || (delta < 0 && *sign == '-')) {\n\t\t\t\t\tptr = R_ABS (op->src[i]->delta);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!ptr) {\n\t\tconst char *op_esil = r_strbuf_get (&op->esil);\n\t\tif (!op_esil) {\n\t\t\treturn;\n\t\t}\n\t\tesil_buf = strdup (op_esil);\n\t\tif (!esil_buf) {\n\t\t\treturn;\n\t\t}\n\t\tr_strf_var (esilexpr, 64, \",%s,%s,\", reg, sign);\n\t\tchar *ptr_end = strstr (esil_buf, esilexpr);\n\t\tif (!ptr_end) {\n\t\t\tfree (esil_buf);\n\t\t\treturn;\n\t\t}\n\t\t*ptr_end = 0;\n\t\taddr = ptr_end;\n\t\twhile ((addr[0] != '0' || addr[1] != 'x') && addr >= esil_buf + 1 && *addr != ',') {\n\t\t\taddr--;\n\t\t}\n\t\tif (strncmp (addr, \"0x\", 2)) {\n\t\t\t\/\/XXX: This is a workaround for inconsistent esil\n\t\t\tif (!op->stackop && op->dst) {\n\t\t\t\tconst char *sp = r_reg_get_name (anal->reg, R_REG_NAME_SP);\n\t\t\t\tconst char *bp = r_reg_get_name (anal->reg, R_REG_NAME_BP);\n\t\t\t\tconst char *rn = op->dst->reg ? op->dst->reg->name : NULL;\n\t\t\t\tif (rn && ((bp && !strcmp (bp, rn)) || (sp && !strcmp (sp, rn)))) {\n\t\t\t\t\tif (anal->verbose) {\n\t\t\t\t\t\teprintf (\"Warning: Analysis didn't fill op->stackop for instruction that alters stack at 0x%\" PFMT64x \".\\n\", op->addr);\n\t\t\t\t\t}\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (*addr == ',') {\n\t\t\t\taddr++;\n\t\t\t}\n\t\t\tif (!op->stackop && op->type != R_ANAL_OP_TYPE_PUSH && op->type != R_ANAL_OP_TYPE_POP\n\t\t\t\t&& op->type != R_ANAL_OP_TYPE_RET && r_str_isnumber (addr)) {\n\t\t\t\tptr = (st64)r_num_get (NULL, addr);\n\t\t\t\tif (ptr && op->src[0] && ptr == op->src[0]->imm) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t} else if ((op->stackop == R_ANAL_STACK_SET) || (op->stackop == R_ANAL_STACK_GET)) {\n\t\t\t\tif (op->ptr % 4) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t\tptr = R_ABS (op->ptr);\n\t\t\t} else {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t} else {\n\t\t\tptr = (st64)r_num_get (NULL, addr);\n\t\t}\n\t}\n\n\tif (anal->verbose && (!op->src[0] || !op->dst)) {\n\t\teprintf (\"Warning: Analysis didn't fill op->src\/dst at 0x%\" PFMT64x \".\\n\", op->addr);\n\t}\n\n\tint rw = (op->direction == R_ANAL_OP_DIR_WRITE) ? R_ANAL_VAR_ACCESS_TYPE_WRITE : R_ANAL_VAR_ACCESS_TYPE_READ;\n\tif (*sign == '+') {\n\t\tconst bool isarg = type == R_ANAL_VAR_KIND_SPV ? ptr >= fcn->stack : ptr >= fcn->bp_off;\n\t\tconst char *pfx = isarg ? ARGPREFIX : VARPREFIX;\n\t\tst64 frame_off;\n\t\tif (type == R_ANAL_VAR_KIND_SPV) {\n\t\t\tframe_off = ptr - fcn->stack;\n\t\t} else {\n\t\t\tframe_off = ptr - fcn->bp_off;\n\t\t}\n\t\tif (maxstackframe != 0 && (frame_off > maxstackframe || frame_off < -maxstackframe)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tRAnalVar *var = get_stack_var (fcn, frame_off);\n\t\tif (var) {\n\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, ptr);\n\t\t\tgoto beach;\n\t\t}\n\t\tchar *varname = NULL, *vartype = NULL;\n\t\tif (isarg) {\n\t\t\tconst char *place = fcn->cc ? r_anal_cc_arg (anal, fcn->cc, ST32_MAX) : NULL;\n\t\t\tbool stack_rev = place ? !strcmp (place, \"stack_rev\") : false;\n\t\t\tchar *fname = r_type_func_guess (anal->sdb_types, fcn->name);\n\t\t\tif (fname) {\n\t\t\t\tut64 sum_sz = 0;\n\t\t\t\tsize_t from, to, i;\n\t\t\t\tif (stack_rev) {\n\t\t\t\t\tconst size_t cnt = r_type_func_args_count (anal->sdb_types, fname);\n\t\t\t\t\tfrom = cnt ? cnt - 1 : cnt;\n\t\t\t\t\tto = fcn->cc ? r_anal_cc_max_arg (anal, fcn->cc) : 0;\n\t\t\t\t} else {\n\t\t\t\t\tfrom = fcn->cc ? r_anal_cc_max_arg (anal, fcn->cc) : 0;\n\t\t\t\t\tto = r_type_func_args_count (anal->sdb_types, fname);\n\t\t\t\t}\n\t\t\t\tconst int bytes = (fcn->bits ? fcn->bits : anal->bits) \/ 8;\n\t\t\t\tfor (i = from; stack_rev ? i >= to : i < to; stack_rev ? i-- : i++) {\n\t\t\t\t\tchar *tp = r_type_func_args_type (anal->sdb_types, fname, i);\n\t\t\t\t\tif (!tp) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (sum_sz == frame_off) {\n\t\t\t\t\t\tvartype = tp;\n\t\t\t\t\t\tvarname = strdup (r_type_func_args_name (anal->sdb_types, fname, i));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tut64 bit_sz = r_type_get_bitsize (anal->sdb_types, tp);\n\t\t\t\t\tsum_sz += bit_sz ? bit_sz \/ 8 : bytes;\n\t\t\t\t\tsum_sz = R_ROUND (sum_sz, bytes);\n\t\t\t\t\tfree (tp);\n\t\t\t\t}\n\t\t\t\tfree (fname);\n\t\t\t}\n\t\t}\n\t\tif (!varname) {\n\t\t\tif (anal->opt.varname_stack) {\n\t\t\t\tvarname = r_str_newf (\"%s_%\" PFMT64x \"h\", pfx, R_ABS (frame_off));\n\t\t\t} else {\n\t\t\t\tvarname = r_anal_function_autoname_var (fcn, type, pfx, ptr);\n\t\t\t}\n\t\t}\n\t\tif (varname) {\n#if 0\n\t\t\tif (isarg && frame_off > 48) {\n\t\t\t\tfree (varname);\n\t\t\t\tgoto beach;\n\t\t\t}\n#endif\n\t\t\tRAnalVar *var = r_anal_function_set_var (fcn, frame_off, type, vartype, anal->bits \/ 8, isarg, varname);\n\t\t\tif (var) {\n\t\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, ptr);\n\t\t\t}\n\t\t\tfree (varname);\n\t\t}\n\t\tfree (vartype);\n\t} else {\n\t\tst64 frame_off = -(ptr + fcn->bp_off);\n\t\tif (maxstackframe != 0 && (frame_off > maxstackframe || frame_off < -maxstackframe)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tRAnalVar *var = get_stack_var (fcn, frame_off);\n\t\tif (var) {\n\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, -ptr);\n\t\t\tgoto beach;\n\t\t}\n\t\tchar *varname = anal->opt.varname_stack\n\t\t\t? r_str_newf (\"%s_%\" PFMT64x \"h\", VARPREFIX, R_ABS (frame_off))\n\t\t\t: r_anal_function_autoname_var (fcn, type, VARPREFIX, -ptr);\n\t\tif (varname) {\n\t\t\tRAnalVar *var = r_anal_function_set_var (fcn, frame_off, type, NULL, anal->bits \/ 8, false, varname);\n\t\t\tif (var) {\n\t\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, -ptr);\n\t\t\t}\n\t\t\tfree (varname);\n\t\t}\n\t}\nbeach:\n\tfree (esil_buf);\n}","target":1,"code_token_length":1961,"total_token_length":2197,"max_tokens_setting":4096}
+{"idx":204544,"func":"static int em28xx_usb_probe(struct usb_interface *intf,\n\t\t\t    const struct usb_device_id *id)\n{\n\tstruct usb_device *udev;\n\tstruct em28xx *dev = NULL;\n\tint retval;\n\tbool has_vendor_audio = false, has_video = false, has_dvb = false;\n\tint i, nr, try_bulk;\n\tconst int ifnum = intf->altsetting[0].desc.bInterfaceNumber;\n\tchar *speed;\n\n\tudev = usb_get_dev(interface_to_usbdev(intf));\n\n\t\/* Check to see next free device and mark as used *\/\n\tdo {\n\t\tnr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);\n\t\tif (nr >= EM28XX_MAXBOARDS) {\n\t\t\t\/* No free device slots *\/\n\t\t\tdev_err(&intf->dev,\n\t\t\t\t\"Driver supports up to %i em28xx boards.\\n\",\n\t\t\t       EM28XX_MAXBOARDS);\n\t\t\tretval = -ENOMEM;\n\t\t\tgoto err_no_slot;\n\t\t}\n\t} while (test_and_set_bit(nr, em28xx_devused));\n\n\t\/* Don't register audio interfaces *\/\n\tif (intf->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {\n\t\tdev_info(&intf->dev,\n\t\t\t\"audio device (%04x:%04x): interface %i, class %i\\n\",\n\t\t\tle16_to_cpu(udev->descriptor.idVendor),\n\t\t\tle16_to_cpu(udev->descriptor.idProduct),\n\t\t\tifnum,\n\t\t\tintf->altsetting[0].desc.bInterfaceClass);\n\n\t\tretval = -ENODEV;\n\t\tgoto err;\n\t}\n\n\t\/* allocate memory for our device state and initialize it *\/\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev) {\n\t\tretval = -ENOMEM;\n\t\tgoto err;\n\t}\n\n\t\/* compute alternate max packet sizes *\/\n\tdev->alt_max_pkt_size_isoc = kcalloc(intf->num_altsetting,\n\t\t\t\t\t     sizeof(dev->alt_max_pkt_size_isoc[0]),\n\t\t\t\t\t     GFP_KERNEL);\n\tif (!dev->alt_max_pkt_size_isoc) {\n\t\tkfree(dev);\n\t\tretval = -ENOMEM;\n\t\tgoto err;\n\t}\n\n\t\/* Get endpoints *\/\n\tfor (i = 0; i < intf->num_altsetting; i++) {\n\t\tint ep;\n\n\t\tfor (ep = 0;\n\t\t     ep < intf->altsetting[i].desc.bNumEndpoints;\n\t\t     ep++)\n\t\t\tem28xx_check_usb_descriptor(dev, udev, intf,\n\t\t\t\t\t\t    i, ep,\n\t\t\t\t\t\t    &has_vendor_audio,\n\t\t\t\t\t\t    &has_video,\n\t\t\t\t\t\t    &has_dvb);\n\t}\n\n\tif (!(has_vendor_audio || has_video || has_dvb)) {\n\t\tretval = -ENODEV;\n\t\tgoto err_free;\n\t}\n\n\tswitch (udev->speed) {\n\tcase USB_SPEED_LOW:\n\t\tspeed = \"1.5\";\n\t\tbreak;\n\tcase USB_SPEED_UNKNOWN:\n\tcase USB_SPEED_FULL:\n\t\tspeed = \"12\";\n\t\tbreak;\n\tcase USB_SPEED_HIGH:\n\t\tspeed = \"480\";\n\t\tbreak;\n\tdefault:\n\t\tspeed = \"unknown\";\n\t}\n\n\tdev_info(&intf->dev,\n\t\t\"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\\n\",\n\t\tudev->manufacturer ? udev->manufacturer : \"\",\n\t\tudev->product ? udev->product : \"\",\n\t\tspeed,\n\t\tle16_to_cpu(udev->descriptor.idVendor),\n\t\tle16_to_cpu(udev->descriptor.idProduct),\n\t\tifnum,\n\t\tintf->altsetting->desc.bInterfaceNumber);\n\n\t\/*\n\t * Make sure we have 480 Mbps of bandwidth, otherwise things like\n\t * video stream wouldn't likely work, since 12 Mbps is generally\n\t * not enough even for most Digital TV streams.\n\t *\/\n\tif (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {\n\t\tdev_err(&intf->dev, \"Device initialization failed.\\n\");\n\t\tdev_err(&intf->dev,\n\t\t\t\"Device must be connected to a high-speed USB 2.0 port.\\n\");\n\t\tretval = -ENODEV;\n\t\tgoto err_free;\n\t}\n\n\tdev->devno = nr;\n\tdev->model = id->driver_info;\n\tdev->alt   = -1;\n\tdev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);\n\tdev->has_video = has_video;\n\tdev->ifnum = ifnum;\n\n\tdev->ts = PRIMARY_TS;\n\tsnprintf(dev->name, 28, \"em28xx\");\n\tdev->dev_next = NULL;\n\n\tif (has_vendor_audio) {\n\t\tdev_info(&intf->dev,\n\t\t\t\"Audio interface %i found (Vendor Class)\\n\", ifnum);\n\t\tdev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;\n\t}\n\t\/* Checks if audio is provided by a USB Audio Class intf *\/\n\tfor (i = 0; i < udev->config->desc.bNumInterfaces; i++) {\n\t\tstruct usb_interface *uif = udev->config->interface[i];\n\n\t\tif (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {\n\t\t\tif (has_vendor_audio)\n\t\t\t\tdev_err(&intf->dev,\n\t\t\t\t\t\"em28xx: device seems to have vendor AND usb audio class interfaces !\\n\"\n\t\t\t\t\t\"\\t\\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\\n\");\n\t\t\tdev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (has_video)\n\t\tdev_info(&intf->dev, \"Video interface %i found:%s%s\\n\",\n\t\t\tifnum,\n\t\t\tdev->analog_ep_bulk ? \" bulk\" : \"\",\n\t\t\tdev->analog_ep_isoc ? \" isoc\" : \"\");\n\tif (has_dvb)\n\t\tdev_info(&intf->dev, \"DVB interface %i found:%s%s\\n\",\n\t\t\tifnum,\n\t\t\tdev->dvb_ep_bulk ? \" bulk\" : \"\",\n\t\t\tdev->dvb_ep_isoc ? \" isoc\" : \"\");\n\n\tdev->num_alt = intf->num_altsetting;\n\n\tif ((unsigned int)card[nr] < em28xx_bcount)\n\t\tdev->model = card[nr];\n\n\t\/* save our data pointer in this intf device *\/\n\tusb_set_intfdata(intf, dev);\n\n\t\/* allocate device struct and check if the device is a webcam *\/\n\tmutex_init(&dev->lock);\n\tretval = em28xx_init_dev(dev, udev, intf, nr);\n\tif (retval)\n\t\tgoto err_free;\n\n\tif (usb_xfer_mode < 0) {\n\t\tif (dev->is_webcam)\n\t\t\ttry_bulk = 1;\n\t\telse\n\t\t\ttry_bulk = 0;\n\t} else {\n\t\ttry_bulk = usb_xfer_mode > 0;\n\t}\n\n\t\/* Disable V4L2 if the device doesn't have a decoder or image sensor *\/\n\tif (has_video &&\n\t    dev->board.decoder == EM28XX_NODECODER &&\n\t    dev->em28xx_sensor == EM28XX_NOSENSOR) {\n\t\tdev_err(&intf->dev,\n\t\t\t\"Currently, V4L2 is not supported on this model\\n\");\n\t\thas_video = false;\n\t\tdev->has_video = false;\n\t}\n\n\tif (dev->board.has_dual_ts &&\n\t    (dev->tuner_type != TUNER_ABSENT || INPUT(0)->type)) {\n\t\t\/*\n\t\t * The logic with sets alternate is not ready for dual-tuners\n\t\t * which analog modes.\n\t\t *\/\n\t\tdev_err(&intf->dev,\n\t\t\t\"We currently don't support analog TV or stream capture on dual tuners.\\n\");\n\t\thas_video = false;\n\t}\n\n\t\/* Select USB transfer types to use *\/\n\tif (has_video) {\n\t\tif (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))\n\t\t\tdev->analog_xfer_bulk = 1;\n\t\tdev_info(&intf->dev, \"analog set to %s mode.\\n\",\n\t\t\tdev->analog_xfer_bulk ? \"bulk\" : \"isoc\");\n\t}\n\tif (has_dvb) {\n\t\tif (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))\n\t\t\tdev->dvb_xfer_bulk = 1;\n\t\tdev_info(&intf->dev, \"dvb set to %s mode.\\n\",\n\t\t\tdev->dvb_xfer_bulk ? \"bulk\" : \"isoc\");\n\t}\n\n\tif (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {\n\t\tdev->dev_next->ts = SECONDARY_TS;\n\t\tdev->dev_next->alt   = -1;\n\t\tdev->dev_next->is_audio_only = has_vendor_audio &&\n\t\t\t\t\t\t!(has_video || has_dvb);\n\t\tdev->dev_next->has_video = false;\n\t\tdev->dev_next->ifnum = ifnum;\n\t\tdev->dev_next->model = id->driver_info;\n\n\t\tmutex_init(&dev->dev_next->lock);\n\t\tretval = em28xx_init_dev(dev->dev_next, udev, intf,\n\t\t\t\t\t dev->dev_next->devno);\n\t\tif (retval)\n\t\t\tgoto err_free;\n\n\t\tdev->dev_next->board.ir_codes = NULL; \/* No IR for 2nd tuner *\/\n\t\tdev->dev_next->board.has_ir_i2c = 0; \/* No IR for 2nd tuner *\/\n\n\t\tif (usb_xfer_mode < 0) {\n\t\t\tif (dev->dev_next->is_webcam)\n\t\t\t\ttry_bulk = 1;\n\t\t\telse\n\t\t\t\ttry_bulk = 0;\n\t\t} else {\n\t\t\ttry_bulk = usb_xfer_mode > 0;\n\t\t}\n\n\t\t\/* Select USB transfer types to use *\/\n\t\tif (has_dvb) {\n\t\t\tif (!dev->dvb_ep_isoc_ts2 ||\n\t\t\t    (try_bulk && dev->dvb_ep_bulk_ts2))\n\t\t\t\tdev->dev_next->dvb_xfer_bulk = 1;\n\t\t\tdev_info(&dev->intf->dev, \"dvb ts2 set to %s mode.\\n\",\n\t\t\t\t dev->dev_next->dvb_xfer_bulk ? \"bulk\" : \"isoc\");\n\t\t}\n\n\t\tdev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;\n\t\tdev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;\n\t\tdev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;\n\t\tdev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;\n\n\t\t\/* Configure hardware to support TS2*\/\n\t\tif (dev->dvb_xfer_bulk) {\n\t\t\t\/* The ep4 and ep5 are configured for BULK *\/\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x96);\n\t\t\tmdelay(100);\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x80);\n\t\t\tmdelay(100);\n\t\t} else {\n\t\t\t\/* The ep4 and ep5 are configured for ISO *\/\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x96);\n\t\t\tmdelay(100);\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x82);\n\t\t\tmdelay(100);\n\t\t}\n\n\t\tkref_init(&dev->dev_next->ref);\n\t}\n\n\tkref_init(&dev->ref);\n\n\trequest_modules(dev);\n\n\t\/*\n\t * Do it at the end, to reduce dynamic configuration changes during\n\t * the device init. Yet, as request_modules() can be async, the\n\t * topology will likely change after the load of the em28xx subdrivers.\n\t *\/\n#ifdef CONFIG_MEDIA_CONTROLLER\n\tretval = media_device_register(dev->media_dev);\n#endif\n\n\treturn 0;\n\nerr_free:\n\tkfree(dev->alt_max_pkt_size_isoc);\n\tkfree(dev);\n\nerr:\n\tclear_bit(nr, em28xx_devused);\n\nerr_no_slot:\n\tusb_put_dev(udev);\n\treturn retval;\n}","target":1,"code_token_length":2598,"total_token_length":2834,"max_tokens_setting":4096}
+{"idx":195405,"func":"static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define CropBox  \"CropBox\"\n#define DeviceCMYK  \"DeviceCMYK\"\n#define MediaBox  \"MediaBox\"\n#define RenderPCLText  \"  Rendering PCL...  \"\n\n  char\n    command[MaxTextExtent],\n    *density,\n    filename[MaxTextExtent],\n    geometry[MaxTextExtent],\n    *options,\n    input_filename[MaxTextExtent];\n\n  const DelegateInfo\n    *delegate_info;\n\n  Image\n    *image,\n    *next_image;\n\n  ImageInfo\n    *read_info;\n\n  int\n    c;\n\n  MagickBooleanType\n    cmyk,\n    status;\n\n  PointInfo\n    delta;\n\n  RectangleInfo\n    bounding_box,\n    page;\n\n  char\n    *p;\n\n  SegmentInfo\n    bounds;\n\n  size_t\n    height,\n    width;\n\n  ssize_t\n    count;\n\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  \/*\n    Open image file.\n  *\/\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  status=AcquireUniqueSymbolicLink(image_info->filename,input_filename);\n  if (status == MagickFalse)\n    {\n      ThrowFileException(exception,FileOpenError,\"UnableToCreateTemporaryFile\",\n        image_info->filename);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Set the page density.\n  *\/\n  delta.x=DefaultResolution;\n  delta.y=DefaultResolution;\n  if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))\n    {\n      GeometryInfo\n        geometry_info;\n\n      MagickStatusType\n        flags;\n\n      flags=ParseGeometry(PSDensityGeometry,&geometry_info);\n      if ((flags & RhoValue) != 0)\n        image->x_resolution=geometry_info.rho;\n      image->y_resolution=image->x_resolution;\n      if ((flags & SigmaValue) != 0)\n        image->y_resolution=geometry_info.sigma;\n    }\n  \/*\n    Determine page geometry from the PCL media box.\n  *\/\n  cmyk=image->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;\n  count=0;\n  (void) memset(&bounding_box,0,sizeof(bounding_box));\n  (void) memset(&bounds,0,sizeof(bounds));\n  (void) memset(&page,0,sizeof(page));\n  (void) memset(command,0,sizeof(command));\n  p=command;\n  for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))\n  {\n    if (image_info->page != (char *) NULL)\n      continue;\n    \/*\n      Note PCL elements.\n    *\/\n    *p++=(char) c;\n    if ((c != (int) '\/') && (c != '\\n') &&\n        ((size_t) (p-command) < (MaxTextExtent-1)))\n      continue;\n    *p='\\0';\n    p=command;\n    \/*\n      Is this a CMYK document?\n    *\/\n    if (LocaleNCompare(DeviceCMYK,command,strlen(DeviceCMYK)) == 0)\n      cmyk=MagickTrue;\n    if (LocaleNCompare(CropBox,command,strlen(CropBox)) == 0)\n      {\n        \/*\n          Note region defined by crop box.\n        *\/\n        count=(ssize_t) sscanf(command,\"CropBox [%lf %lf %lf %lf\",\n          &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n        if (count != 4)\n          count=(ssize_t) sscanf(command,\"CropBox[%lf %lf %lf %lf\",\n            &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n      }\n    if (LocaleNCompare(MediaBox,command,strlen(MediaBox)) == 0)\n      {\n        \/*\n          Note region defined by media box.\n        *\/\n        count=(ssize_t) sscanf(command,\"MediaBox [%lf %lf %lf %lf\",\n          &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n        if (count != 4)\n          count=(ssize_t) sscanf(command,\"MediaBox[%lf %lf %lf %lf\",\n            &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);\n      }\n    if (count != 4)\n      continue;\n    \/*\n      Set PCL render geometry.\n    *\/\n    width=(size_t) floor(bounds.x2-bounds.x1+0.5);\n    height=(size_t) floor(bounds.y2-bounds.y1+0.5);\n    if (width > page.width)\n      page.width=width;\n    if (height > page.height)\n      page.height=height;\n  }\n  (void) CloseBlob(image);\n  \/*\n    Render PCL with the GhostPCL delegate.\n  *\/\n  if ((page.width == 0) || (page.height == 0))\n    (void) ParseAbsoluteGeometry(PSPageGeometry,&page);\n  if (image_info->page != (char *) NULL)\n    (void) ParseAbsoluteGeometry(image_info->page,&page);\n  (void) FormatLocaleString(geometry,MaxTextExtent,\"%.20gx%.20g\",(double)\n    page.width,(double) page.height);\n  if (image_info->monochrome != MagickFalse)\n    delegate_info=GetDelegateInfo(\"pcl:mono\",(char *) NULL,exception);\n  else\n     if (cmyk != MagickFalse)\n       delegate_info=GetDelegateInfo(\"pcl:cmyk\",(char *) NULL,exception);\n     else\n       delegate_info=GetDelegateInfo(\"pcl:color\",(char *) NULL,exception);\n  if (delegate_info == (const DelegateInfo *) NULL)\n    {\n      image=DestroyImage(image);\n      return((Image *) NULL);\n    }\n  if ((page.width == 0) || (page.height == 0))\n    (void) ParseAbsoluteGeometry(PSPageGeometry,&page);\n  if (image_info->page != (char *) NULL)\n    (void) ParseAbsoluteGeometry(image_info->page,&page);\n  density=AcquireString(\"\");\n  options=AcquireString(\"\");\n  (void) FormatLocaleString(density,MaxTextExtent,\"%gx%g\",\n    image->x_resolution,image->y_resolution);\n  if (image_info->ping != MagickFalse)\n    (void) FormatLocaleString(density,MagickPathExtent,\"2.0x2.0\");\n  page.width=(size_t) floor((double) page.width*image->x_resolution\/delta.x+\n    0.5);\n  page.height=(size_t) floor((double) page.height*image->y_resolution\/delta.y+\n    0.5);\n  (void) FormatLocaleString(options,MaxTextExtent,\"-g%.20gx%.20g \",(double)\n     page.width,(double) page.height);\n  image=DestroyImage(image);\n  read_info=CloneImageInfo(image_info);\n  *read_info->magick='\\0';\n  if (read_info->number_scenes != 0)\n    {\n      if (read_info->number_scenes != 1)\n        (void) FormatLocaleString(options,MaxTextExtent,\"-dLastPage=%.20g\",\n          (double) (read_info->scene+read_info->number_scenes));\n      else\n        (void) FormatLocaleString(options,MaxTextExtent,\n          \"-dFirstPage=%.20g -dLastPage=%.20g\",(double) read_info->scene+1,\n          (double) (read_info->scene+read_info->number_scenes));\n      read_info->number_scenes=0;\n      if (read_info->scenes != (char *) NULL)\n        *read_info->scenes='\\0';\n    }\n  (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);\n  (void) AcquireUniqueFilename(read_info->filename);\n  (void) FormatLocaleString(command,MaxTextExtent,\n    GetDelegateCommands(delegate_info),\n    read_info->antialias != MagickFalse ? 4 : 1,\n    read_info->antialias != MagickFalse ? 4 : 1,density,options,\n    read_info->filename,input_filename);\n  options=DestroyString(options);\n  density=DestroyString(density);\n  status=ExternalDelegateCommand(MagickFalse,read_info->verbose,command,\n    (char *) NULL,exception) != 0 ? MagickTrue : MagickFalse;\n  image=ReadImage(read_info,exception);\n  (void) RelinquishUniqueFileResource(read_info->filename);\n  (void) RelinquishUniqueFileResource(input_filename);\n  read_info=DestroyImageInfo(read_info);\n  if (image == (Image *) NULL)\n    ThrowReaderException(DelegateError,\"PCLDelegateFailed\");\n  if (LocaleCompare(image->magick,\"BMP\") == 0)\n    {\n      Image\n        *cmyk_image;\n\n      cmyk_image=ConsolidateCMYKImages(image,&image->exception);\n      if (cmyk_image != (Image *) NULL)\n        {\n          image=DestroyImageList(image);\n          image=cmyk_image;\n        }\n    }\n  do\n  {\n    (void) CopyMagickString(image->filename,filename,MaxTextExtent);\n    image->page=page;\n    if (image_info->ping != MagickFalse)\n      {\n        image->magick_columns*=image->x_resolution\/2.0;\n        image->magick_rows*=image->y_resolution\/2.0;\n        image->columns*=image->x_resolution\/2.0;\n        image->rows*=image->y_resolution\/2.0;\n      }\n    next_image=SyncNextImageInList(image);\n    if (next_image != (Image *) NULL)\n      image=next_image;\n  } while (next_image != (Image *) NULL);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":2214,"total_token_length":2450,"max_tokens_setting":4096}
+{"idx":242649,"func":"void isor_reader_get_sample(ISOMChannel *ch)\n{\n\tGF_Err e;\n\tu32 sample_desc_index;\n\tif (ch->sample) return;\n\n\tif (ch->next_track) {\n\t\tch->track = ch->next_track;\n\t\tch->next_track = 0;\n\t}\n\n\tif (ch->to_init) {\n\t\tinit_reader(ch);\n\t\tsample_desc_index = ch->last_sample_desc_index;\n\t} else if (ch->speed < 0) {\n\t\tif (ch->last_state == GF_EOS) {\n\t\t\tch->sample = NULL;\n\t\t\treturn;\n\t\t}\n\n\t\tif (ch->static_sample->IsRAP) {\n\t\t\tch->last_rap_sample_time = ch->sample_time;\n\t\t}\n\n\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &sample_desc_index, GF_ISOM_SEARCH_FORWARD, &ch->static_sample, &ch->sample_num, NULL);\n\n\t\tif ((e==GF_EOS) || (ch->static_sample->IsRAP)) {\n\t\t\tif (!ch->last_rap_sample_time) {\n\t\t\t\te = GF_EOS;\n\t\t\t} else {\n\t\t\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->last_rap_sample_time - 1, &sample_desc_index, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->static_sample, &ch->sample_num, NULL);\n\t\t\t}\n\t\t}\n\n\t\tif (e) {\n\t\t\tif ((e==GF_EOS) && !ch->owner->frag_type) {\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t}\n\t\t\tch->sample = NULL;\n\t\t\treturn;\n\t\t}\n\t\tch->sample = ch->static_sample;\n\n\t\tif (ch->sample->DTS == ch->sample_time) {\n\t\t\tif (!ch->owner->frag_type) {\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t}\n\t\t}\n\t\tif (ch->sample) {\n\t\t\tch->sample_time = ch->sample->DTS;\n\t\t}\n\n\t} else if (ch->has_edit_list) {\n\t\tu32 prev_sample = ch->sample_num;\n\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &sample_desc_index, GF_ISOM_SEARCH_FORWARD, &ch->static_sample, &ch->sample_num, &ch->sample_data_offset);\n\n\t\tif (e == GF_OK) {\n\t\t\tch->sample = ch->static_sample;\n\n\t\t\t\/*we are in forced seek mode: fetch all samples before the one matching the sample time*\/\n\t\t\tif (ch->edit_sync_frame) {\n\t\t\t\tch->edit_sync_frame++;\n\t\t\t\tif (ch->edit_sync_frame < ch->sample_num) {\n\t\t\t\t\tch->sample = gf_isom_get_sample_ex(ch->owner->mov, ch->track, ch->edit_sync_frame, &sample_desc_index, ch->static_sample, &ch->sample_data_offset);\n\t\t\t\t\tch->sample->DTS = ch->sample_time;\n\t\t\t\t\tch->sample->CTS_Offset = 0;\n\t\t\t\t} else {\n\t\t\t\t\tch->edit_sync_frame = 0;\n\t\t\t\t\tif (ch->sample) ch->sample_time = ch->sample->DTS;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t\/*if we get the same sample, figure out next interesting time (current sample + DTS gap to next sample should be a good bet)*\/\n\t\t\t\tif (prev_sample == ch->sample_num) {\n\t\t\t\t\tif (ch->owner->frag_type && (ch->sample_num==gf_isom_get_sample_count(ch->owner->mov, ch->track))) {\n\t\t\t\t\t\tch->sample = NULL;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tu32 sample_num = ch->sample_num ? ch->sample_num : 1;\n\n\t\t\t\t\t\tif (sample_num >= gf_isom_get_sample_count(ch->owner->mov, ch->track) ) {\n\t\t\t\t\t\t\t\/\/e = GF_EOS;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tu32 time_diff = gf_isom_get_sample_duration(ch->owner->mov, ch->track, sample_num);\n\t\t\t\t\t\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + time_diff, &sample_desc_index, GF_ISOM_SEARCH_FORWARD, &ch->static_sample, &ch->sample_num, &ch->sample_data_offset);\n\t\t\t\t\t\t\tif (e==GF_OK) {\n\t\t\t\t\t\t\t\tif (ch->sample_num == prev_sample) {\n\t\t\t\t\t\t\t\t\tch->sample_time += time_diff;\n\t\t\t\t\t\t\t\t\tch->sample = NULL;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tch->sample = ch->static_sample;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t\/*we jumped to another segment - if RAP is needed look for closest rap in decoding order and\n\t\t\t\tforce seek mode*\/\n\t\t\t\tif (ch->sample && !ch->sample->IsRAP && ch->has_rap && (ch->sample_num != prev_sample+1)) {\n\t\t\t\t\tGF_ISOSample *found = ch->static_sample;\n\t\t\t\t\tu32 samp_num = ch->sample_num;\n\t\t\t\t\tch->sample = NULL;\n\t\t\t\t\te = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &sample_desc_index, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->static_sample, &ch->sample_num, &ch->sample_data_offset);\n\n\t\t\t\t\tif (e == GF_OK) ch->sample = ch->static_sample;\n\n\t\t\t\t\t\/*if no sync point in the past, use the first non-sync for the given time*\/\n\t\t\t\t\tif (!ch->sample || !ch->sample->data) {\n\t\t\t\t\t\tch->sample = ch->static_sample = found;\n\t\t\t\t\t\tch->sample_time = ch->sample->DTS;\n\t\t\t\t\t\tch->sample_num = samp_num;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tch->sample = ch->static_sample;\n\t\t\t\t\t\tch->edit_sync_frame = ch->sample_num;\n\t\t\t\t\t\tch->sample->DTS = ch->sample_time;\n\t\t\t\t\t\tch->sample->CTS_Offset = 0;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (ch->sample) ch->sample_time = ch->sample->DTS;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tBool do_fetch = GF_TRUE;\n\t\tch->sample_num++;\n\n\t\tif (ch->sap_only) {\n\t\t\tBool is_rap = gf_isom_get_sample_sync(ch->owner->mov, ch->track, ch->sample_num);\n\t\t\tif (!is_rap) {\n\t\t\t\tGF_ISOSampleRollType roll_type;\n\t\t\t\tgf_isom_get_sample_rap_roll_info(ch->owner->mov, ch->track, ch->sample_num, &is_rap, &roll_type, NULL);\n\t\t\t\tif (roll_type) is_rap = GF_TRUE;\n\t\t\t}\n\n\t\t\tif (!is_rap) {\n\t\t\t\tdo_fetch = GF_FALSE;\n\t\t\t} else if (ch->sap_only==2) {\n\t\t\t\tch->sap_only = 0;\n\t\t\t}\n\t\t}\n\t\tif (do_fetch) {\n\t\t\tif (ch->owner->nodata) {\n\t\t\t\tch->sample = gf_isom_get_sample_info_ex(ch->owner->mov, ch->track, ch->sample_num, &sample_desc_index, &ch->sample_data_offset, ch->static_sample);\n\t\t\t} else {\n\t\t\t\tch->sample = gf_isom_get_sample_ex(ch->owner->mov, ch->track, ch->sample_num, &sample_desc_index, ch->static_sample, &ch->sample_data_offset);\n\t\t\t}\n\t\t\t\/*if sync shadow \/ carousel RAP skip*\/\n\t\t\tif (ch->sample && (ch->sample->IsRAP==RAP_REDUNDANT)) {\n\t\t\t\tch->sample = NULL;\n\t\t\t\tch->sample_num++;\n\t\t\t\tisor_reader_get_sample(ch);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/\/check scalable track change\n\tif (ch->sample && ch->sample->IsRAP && ch->next_track) {\n\t\tch->track = ch->next_track;\n\t\tch->next_track = 0;\n\t\tch->sample = NULL;\n\t\tisor_reader_get_sample(ch);\n\t\treturn;\n\t}\n\n\tif (!ch->sample) {\n\t\tu32 sample_count = gf_isom_get_sample_count(ch->owner->mov, ch->track);\n\t\tch->sample_data_offset = 0;\n\t\t\/*incomplete file - check if we're still downloading or not*\/\n\t\tif (gf_isom_get_missing_bytes(ch->owner->mov, ch->track)) {\n\t\t\tch->last_state = GF_ISOM_INCOMPLETE_FILE;\n\t\t\tif (ch->owner->mem_load_mode==2)\n\t\t\t\tch->owner->force_fetch = GF_TRUE;\n\n\t\t\tif (!ch->owner->input_loaded) {\n\t\t\t\tch->last_state = GF_OK;\n\t\t\t\tif (!ch->has_edit_list && ch->sample_num)\n\t\t\t\t\tch->sample_num--;\n\t\t\t} else {\n\t\t\t\tif (ch->to_init && ch->sample_num) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[IsoMedia] Failed to fetch initial sample %d for track %d\\n\"));\n\t\t\t\t\tch->last_state = GF_ISOM_INVALID_FILE;\n\t\t\t\t}\n\t\t\t\tif (ch->sample_num >= gf_isom_get_sample_count(ch->owner->mov, ch->track)) {\n\t\t\t\t\tch->last_state = GF_EOS;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (!ch->sample_num\n\t\t         || ((ch->speed >= 0) && (ch->sample_num >= sample_count))\n\t\t         || ((ch->speed < 0) && (ch->sample_time == gf_isom_get_current_tfdt(ch->owner->mov, ch->track) ))\n\t\t        ) {\n\n\t\t\tif (ch->owner->frag_type==1) {\n\t\t\t\t\/*if sample cannot be found and file is fragmented, rewind sample*\/\n\t\t\t\tif (ch->sample_num) ch->sample_num--;\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t} else if (ch->last_state != GF_EOS) {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[IsoMedia] Track #%d end of stream reached\\n\", ch->track));\n\t\t\t\tch->last_state = GF_EOS;\n\t\t\t\tif (ch->sample_num>sample_count) ch->sample_num = sample_count;\n\t\t\t} else {\n\t\t\t\tif (ch->sample_num>sample_count) ch->sample_num = sample_count;\n\t\t\t}\n\t\t} else {\n\t\t\te = gf_isom_last_error(ch->owner->mov);\n\t\t\tGF_LOG((e==GF_ISOM_INCOMPLETE_FILE) ? GF_LOG_DEBUG : GF_LOG_WARNING, GF_LOG_DASH, (\"[IsoMedia] Track #%d fail to fetch sample %d \/ %d: %s\\n\", ch->track, ch->sample_num, gf_isom_get_sample_count(ch->owner->mov, ch->track), gf_error_to_string(e) ));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (sample_desc_index != ch->last_sample_desc_index) {\n\t\tif (!ch->owner->stsd) {\n\t\t\t\/\/we used sample entry 1 by default to setup, if no active prev sample (edit list might trigger this)\n\t\t\t\/\/and new sample desc is 1, do not reconfigure\n\t\t\tif (!ch->last_sample_desc_index && (sample_desc_index==1)) {\n\n\t\t\t} else {\n\t\t\t\tch->needs_pid_reconfig = GF_TRUE;\n\t\t\t}\n\t\t}\n\t\tch->last_sample_desc_index = sample_desc_index;\n\t}\n\n\tch->last_state = GF_OK;\n\tch->au_duration = gf_isom_get_sample_duration(ch->owner->mov, ch->track, ch->sample_num);\n\n\tch->sap_3 = GF_FALSE;\n\tch->sap_4_type = 0;\n\tch->roll = 0;\n\tch->set_disc = ch->owner->clock_discontinuity ? 2 : 0;\n\tch->owner->clock_discontinuity = 0;\n\n\tif (ch->sample) {\n\t\tgf_isom_get_sample_rap_roll_info(ch->owner->mov, ch->track, ch->sample_num, &ch->sap_3, &ch->sap_4_type, &ch->roll);\n\n\t\t\/*still seeking or not ?\n\t\t 1- when speed is negative, the RAP found is \"after\" the seek point in playback order since we used backward RAP search: nothing to do\n\t\t 2- otherwise set DTS+CTS to start value\n\t\t *\/\n\t\tif ((ch->speed < 0) || (ch->start <= ch->sample->DTS + ch->sample->CTS_Offset)) {\n\t\t\tch->dts = ch->sample->DTS;\n\t\t\tch->cts = ch->sample->DTS + ch->sample->CTS_Offset;\n\t\t\tch->seek_flag = 0;\n\t\t} else {\n\t\t\tch->cts = ch->start;\n\t\t\tch->seek_flag = 1;\n\t\t\tch->dts = ch->start;\n\t\t}\n\n\t\tif (ch->end && (ch->end < ch->sample->DTS + ch->sample->CTS_Offset + ch->au_duration)) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] End of Channel \"LLD\" (CTS \"LLD\")\\n\", ch->end, ch->sample->DTS + ch->sample->CTS_Offset));\n\t\t\tch->sample = NULL;\n\t\t\tch->last_state = GF_EOS;\n\t\t\tch->playing = 2;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (ch->owner->last_sender_ntp && ch->cts==ch->owner->cts_for_last_sender_ntp) {\n\t\tch->sender_ntp = ch->owner->last_sender_ntp;\n\t\tch->ntp_at_server_ntp = ch->owner->ntp_at_last_sender_ntp;\n\t} else if (ch->owner->last_sender_ntp && ch->dts==ch->owner->cts_for_last_sender_ntp) {\n\t\tch->sender_ntp = ch->owner->last_sender_ntp;\n\t\tch->ntp_at_server_ntp = ch->owner->ntp_at_last_sender_ntp;\n\t} else {\n\t\tch->sender_ntp = ch->ntp_at_server_ntp = 0;\n\t}\n\n\tif (!ch->sample_num) return;\n\n\tgf_isom_get_sample_flags(ch->owner->mov, ch->track, ch->sample_num, &ch->isLeading, &ch->dependsOn, &ch->dependedOn, &ch->redundant);\n\n\tif (ch->is_encrypted) {\n\t\t\/*in case of CENC: we write sample auxiliary information to slh->sai; its size is in saiz*\/\n\t\tif (gf_isom_is_cenc_media(ch->owner->mov, ch->track, ch->last_sample_desc_index)) {\n\t\t\tisor_update_cenc_info(ch, GF_FALSE);\n\n\t\t} else if (gf_isom_is_media_encrypted(ch->owner->mov, ch->track, ch->last_sample_desc_index)) {\n\t\t\tch->pck_encrypted = GF_TRUE;\n\t\t} else {\n\t\t\tch->pck_encrypted = GF_FALSE;\n\t\t}\n\t}\n\tif (ch->sample && ch->sample->nb_pack)\n\t\tch->sample_num += ch->sample->nb_pack-1;\n}","target":0,"code_token_length":3284,"total_token_length":3520,"max_tokens_setting":4096}
+{"idx":359610,"func":"bgp_update_receive (struct peer *peer, bgp_size_t size)\n{\n  int ret;\n  u_char *end;\n  struct stream *s;\n  struct attr attr;\n  bgp_size_t attribute_len;\n  bgp_size_t update_len;\n  bgp_size_t withdraw_len;\n  struct bgp_nlri update;\n  struct bgp_nlri withdraw;\n  struct bgp_nlri mp_update;\n  struct bgp_nlri mp_withdraw;\n  char attrstr[BUFSIZ] = \"\";\n\n  \/* Status must be Established. *\/\n  if (peer->status != Established) \n    {\n      zlog_err (\"%s [FSM] Update packet received under status %s\",\n\t\tpeer->host, LOOKUP (bgp_status_msg, peer->status));\n      bgp_notify_send (peer, BGP_NOTIFY_FSM_ERR, 0);\n      return -1;\n    }\n\n  \/* Set initial values. *\/\n  memset (&attr, 0, sizeof (struct attr));\n  memset (&update, 0, sizeof (struct bgp_nlri));\n  memset (&withdraw, 0, sizeof (struct bgp_nlri));\n  memset (&mp_update, 0, sizeof (struct bgp_nlri));\n  memset (&mp_withdraw, 0, sizeof (struct bgp_nlri));\n\n  s = peer->ibuf;\n  end = stream_pnt (s) + size;\n\n  \/* RFC1771 6.3 If the Unfeasible Routes Length or Total Attribute\n     Length is too large (i.e., if Unfeasible Routes Length + Total\n     Attribute Length + 23 exceeds the message Length), then the Error\n     Subcode is set to Malformed Attribute List.  *\/\n  if (stream_pnt (s) + 2 > end)\n    {\n      zlog_err (\"%s [Error] Update packet error\"\n\t\t\" (packet length is short for unfeasible length)\",\n\t\tpeer->host);\n      bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, \n\t\t       BGP_NOTIFY_UPDATE_MAL_ATTR);\n      return -1;\n    }\n\n  \/* Unfeasible Route Length. *\/\n  withdraw_len = stream_getw (s);\n\n  \/* Unfeasible Route Length check. *\/\n  if (stream_pnt (s) + withdraw_len > end)\n    {\n      zlog_err (\"%s [Error] Update packet error\"\n\t\t\" (packet unfeasible length overflow %d)\",\n\t\tpeer->host, withdraw_len);\n      bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, \n\t\t       BGP_NOTIFY_UPDATE_MAL_ATTR);\n      return -1;\n    }\n\n  \/* Unfeasible Route packet format check. *\/\n  if (withdraw_len > 0)\n    {\n      ret = bgp_nlri_sanity_check (peer, AFI_IP, stream_pnt (s), withdraw_len);\n      if (ret < 0)\n\treturn -1;\n\n      if (BGP_DEBUG (packet, PACKET_RECV))\n\tzlog_debug (\"%s [Update:RECV] Unfeasible NLRI received\", peer->host);\n\n      withdraw.afi = AFI_IP;\n      withdraw.safi = SAFI_UNICAST;\n      withdraw.nlri = stream_pnt (s);\n      withdraw.length = withdraw_len;\n      stream_forward_getp (s, withdraw_len);\n    }\n  \n  \/* Attribute total length check. *\/\n  if (stream_pnt (s) + 2 > end)\n    {\n      zlog_warn (\"%s [Error] Packet Error\"\n\t\t \" (update packet is short for attribute length)\",\n\t\t peer->host);\n      bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, \n\t\t       BGP_NOTIFY_UPDATE_MAL_ATTR);\n      return -1;\n    }\n\n  \/* Fetch attribute total length. *\/\n  attribute_len = stream_getw (s);\n\n  \/* Attribute length check. *\/\n  if (stream_pnt (s) + attribute_len > end)\n    {\n      zlog_warn (\"%s [Error] Packet Error\"\n\t\t \" (update packet attribute length overflow %d)\",\n\t\t peer->host, attribute_len);\n      bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, \n\t\t       BGP_NOTIFY_UPDATE_MAL_ATTR);\n      return -1;\n    }\n\n  \/* Parse attribute when it exists. *\/\n  if (attribute_len)\n    {\n      ret = bgp_attr_parse (peer, &attr, attribute_len, \n\t\t\t    &mp_update, &mp_withdraw);\n      if (ret < 0)\n\treturn -1;\n    }\n\n  \/* Logging the attribute. *\/\n  if (BGP_DEBUG (update, UPDATE_IN))\n    {\n      ret= bgp_dump_attr (peer, &attr, attrstr, BUFSIZ);\n\n      if (ret)\n\tzlog (peer->log, LOG_DEBUG, \"%s rcvd UPDATE w\/ attr: %s\",\n\t      peer->host, attrstr);\n    }\n\n  \/* Network Layer Reachability Information. *\/\n  update_len = end - stream_pnt (s);\n\n  if (update_len)\n    {\n      \/* Check NLRI packet format and prefix length. *\/\n      ret = bgp_nlri_sanity_check (peer, AFI_IP, stream_pnt (s), update_len);\n      if (ret < 0)\n\treturn -1;\n\n      \/* Set NLRI portion to structure. *\/\n      update.afi = AFI_IP;\n      update.safi = SAFI_UNICAST;\n      update.nlri = stream_pnt (s);\n      update.length = update_len;\n      stream_forward_getp (s, update_len);\n    }\n\n  \/* NLRI is processed only when the peer is configured specific\n     Address Family and Subsequent Address Family. *\/\n  if (peer->afc[AFI_IP][SAFI_UNICAST])\n    {\n      if (withdraw.length)\n\tbgp_nlri_parse (peer, NULL, &withdraw);\n\n      if (update.length)\n\t{\n\t  \/* We check well-known attribute only for IPv4 unicast\n\t     update. *\/\n\t  ret = bgp_attr_check (peer, &attr);\n\t  if (ret < 0)\n\t    return -1;\n\n\t  bgp_nlri_parse (peer, &attr, &update);\n\t}\n\n      if (mp_update.length\n\t  && mp_update.afi == AFI_IP \n\t  && mp_update.safi == SAFI_UNICAST)\n\tbgp_nlri_parse (peer, &attr, &mp_update);\n\n      if (mp_withdraw.length\n\t  && mp_withdraw.afi == AFI_IP \n\t  && mp_withdraw.safi == SAFI_UNICAST)\n\tbgp_nlri_parse (peer, NULL, &mp_withdraw);\n\n      if (! attribute_len && ! withdraw_len)\n\t{\n\t  \/* End-of-RIB received *\/\n\t  SET_FLAG (peer->af_sflags[AFI_IP][SAFI_UNICAST],\n\t\t    PEER_STATUS_EOR_RECEIVED);\n\n\t  \/* NSF delete stale route *\/\n\t  if (peer->nsf[AFI_IP][SAFI_UNICAST])\n\t    bgp_clear_stale_route (peer, AFI_IP, SAFI_UNICAST);\n\n\t  if (BGP_DEBUG (normal, NORMAL))\n\t    zlog (peer->log, LOG_DEBUG, \"rcvd End-of-RIB for IPv4 Unicast from %s\",\n\t\t  peer->host);\n\t}\n    }\n  if (peer->afc[AFI_IP][SAFI_MULTICAST])\n    {\n      if (mp_update.length\n\t  && mp_update.afi == AFI_IP \n\t  && mp_update.safi == SAFI_MULTICAST)\n\tbgp_nlri_parse (peer, &attr, &mp_update);\n\n      if (mp_withdraw.length\n\t  && mp_withdraw.afi == AFI_IP \n\t  && mp_withdraw.safi == SAFI_MULTICAST)\n\tbgp_nlri_parse (peer, NULL, &mp_withdraw);\n\n      if (! withdraw_len\n\t  && mp_withdraw.afi == AFI_IP\n\t  && mp_withdraw.safi == SAFI_MULTICAST\n\t  && mp_withdraw.length == 0)\n\t{\n\t  \/* End-of-RIB received *\/\n\t  SET_FLAG (peer->af_sflags[AFI_IP][SAFI_MULTICAST],\n\t\t    PEER_STATUS_EOR_RECEIVED);\n\n\t  \/* NSF delete stale route *\/\n\t  if (peer->nsf[AFI_IP][SAFI_MULTICAST])\n\t    bgp_clear_stale_route (peer, AFI_IP, SAFI_MULTICAST);\n\n\t  if (BGP_DEBUG (normal, NORMAL))\n\t    zlog (peer->log, LOG_DEBUG, \"rcvd End-of-RIB for IPv4 Multicast from %s\",\n\t\t  peer->host);\n\t}\n    }\n  if (peer->afc[AFI_IP6][SAFI_UNICAST])\n    {\n      if (mp_update.length \n\t  && mp_update.afi == AFI_IP6 \n\t  && mp_update.safi == SAFI_UNICAST)\n\tbgp_nlri_parse (peer, &attr, &mp_update);\n\n      if (mp_withdraw.length \n\t  && mp_withdraw.afi == AFI_IP6 \n\t  && mp_withdraw.safi == SAFI_UNICAST)\n\tbgp_nlri_parse (peer, NULL, &mp_withdraw);\n\n      if (! withdraw_len\n\t  && mp_withdraw.afi == AFI_IP6\n\t  && mp_withdraw.safi == SAFI_UNICAST\n\t  && mp_withdraw.length == 0)\n\t{\n\t  \/* End-of-RIB received *\/\n\t  SET_FLAG (peer->af_sflags[AFI_IP6][SAFI_UNICAST], PEER_STATUS_EOR_RECEIVED);\n\n\t  \/* NSF delete stale route *\/\n\t  if (peer->nsf[AFI_IP6][SAFI_UNICAST])\n\t    bgp_clear_stale_route (peer, AFI_IP6, SAFI_UNICAST);\n\n\t  if (BGP_DEBUG (normal, NORMAL))\n\t    zlog (peer->log, LOG_DEBUG, \"rcvd End-of-RIB for IPv6 Unicast from %s\",\n\t\t  peer->host);\n\t}\n    }\n  if (peer->afc[AFI_IP6][SAFI_MULTICAST])\n    {\n      if (mp_update.length \n\t  && mp_update.afi == AFI_IP6 \n\t  && mp_update.safi == SAFI_MULTICAST)\n\tbgp_nlri_parse (peer, &attr, &mp_update);\n\n      if (mp_withdraw.length \n\t  && mp_withdraw.afi == AFI_IP6 \n\t  && mp_withdraw.safi == SAFI_MULTICAST)\n\tbgp_nlri_parse (peer, NULL, &mp_withdraw);\n\n      if (! withdraw_len\n\t  && mp_withdraw.afi == AFI_IP6\n\t  && mp_withdraw.safi == SAFI_MULTICAST\n\t  && mp_withdraw.length == 0)\n\t{\n\t  \/* End-of-RIB received *\/\n\n\t  \/* NSF delete stale route *\/\n\t  if (peer->nsf[AFI_IP6][SAFI_MULTICAST])\n\t    bgp_clear_stale_route (peer, AFI_IP6, SAFI_MULTICAST);\n\n\t  if (BGP_DEBUG (update, UPDATE_IN))\n\t    zlog (peer->log, LOG_DEBUG, \"rcvd End-of-RIB for IPv6 Multicast from %s\",\n\t\t  peer->host);\n\t}\n    }\n  if (peer->afc[AFI_IP][SAFI_MPLS_VPN])\n    {\n      if (mp_update.length \n\t  && mp_update.afi == AFI_IP \n\t  && mp_update.safi == BGP_SAFI_VPNV4)\n\tbgp_nlri_parse_vpnv4 (peer, &attr, &mp_update);\n\n      if (mp_withdraw.length \n\t  && mp_withdraw.afi == AFI_IP \n\t  && mp_withdraw.safi == BGP_SAFI_VPNV4)\n\tbgp_nlri_parse_vpnv4 (peer, NULL, &mp_withdraw);\n\n      if (! withdraw_len\n\t  && mp_withdraw.afi == AFI_IP\n\t  && mp_withdraw.safi == BGP_SAFI_VPNV4\n\t  && mp_withdraw.length == 0)\n\t{\n\t  \/* End-of-RIB received *\/\n\n\t  if (BGP_DEBUG (update, UPDATE_IN))\n\t    zlog (peer->log, LOG_DEBUG, \"rcvd End-of-RIB for VPNv4 Unicast from %s\",\n\t\t  peer->host);\n\t}\n    }\n\n  \/* Everything is done.  We unintern temporary structures which\n     interned in bgp_attr_parse(). *\/\n  if (attr.aspath)\n    aspath_unintern (attr.aspath);\n  if (attr.community)\n    community_unintern (attr.community);\n  if (attr.extra)\n    {\n      if (attr.extra->ecommunity)\n        ecommunity_unintern (attr.extra->ecommunity);\n      if (attr.extra->cluster)\n        cluster_unintern (attr.extra->cluster);\n      if (attr.extra->transit)\n        transit_unintern (attr.extra->transit);\n      bgp_attr_extra_free (&attr);\n    }\n\n  \/* If peering is stopped due to some reason, do not generate BGP\n     event.  *\/\n  if (peer->status != Established)\n    return 0;\n\n  \/* Increment packet counter. *\/\n  peer->update_in++;\n  peer->update_time = time (NULL);\n\n  \/* Generate BGP event. *\/\n  BGP_EVENT_ADD (peer, Receive_UPDATE_message);\n\n  return 0;\n}","target":0,"code_token_length":2807,"total_token_length":3043,"max_tokens_setting":4096}
+{"idx":259181,"func":"static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    char tmp_key[AV_FOURCC_MAX_STRING_SIZE] = {0};\n    char key2[32], language[4] = {0};\n    char *str = NULL;\n    const char *key = NULL;\n    uint16_t langcode = 0;\n    uint32_t data_type = 0, str_size, str_size_alloc;\n    int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL;\n    int raw = 0;\n    int num = 0;\n\n    switch (atom.type) {\n    case MKTAG( '@','P','R','M'): key = \"premiere_version\"; raw = 1; break;\n    case MKTAG( '@','P','R','Q'): key = \"quicktime_version\"; raw = 1; break;\n    case MKTAG( 'X','M','P','_'):\n        if (c->export_xmp) { key = \"xmp\"; raw = 1; } break;\n    case MKTAG( 'a','A','R','T'): key = \"album_artist\";    break;\n    case MKTAG( 'a','k','I','D'): key = \"account_type\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 'a','p','I','D'): key = \"account_id\"; break;\n    case MKTAG( 'c','a','t','g'): key = \"category\"; break;\n    case MKTAG( 'c','p','i','l'): key = \"compilation\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 'c','p','r','t'): key = \"copyright\"; break;\n    case MKTAG( 'd','e','s','c'): key = \"description\"; break;\n    case MKTAG( 'd','i','s','k'): key = \"disc\";\n        parse = mov_metadata_track_or_disc_number; break;\n    case MKTAG( 'e','g','i','d'): key = \"episode_uid\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 'F','I','R','M'): key = \"firmware\"; raw = 1; break;\n    case MKTAG( 'g','n','r','e'): key = \"genre\";\n        parse = mov_metadata_gnre; break;\n    case MKTAG( 'h','d','v','d'): key = \"hd_video\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 'H','M','M','T'):\n        return mov_metadata_hmmt(c, pb, atom.size);\n    case MKTAG( 'k','e','y','w'): key = \"keywords\";  break;\n    case MKTAG( 'l','d','e','s'): key = \"synopsis\";  break;\n    case MKTAG( 'l','o','c','i'):\n        return mov_metadata_loci(c, pb, atom.size);\n    case MKTAG( 'm','a','n','u'): key = \"make\"; break;\n    case MKTAG( 'm','o','d','l'): key = \"model\"; break;\n    case MKTAG( 'p','c','s','t'): key = \"podcast\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 'p','g','a','p'): key = \"gapless_playback\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 'p','u','r','d'): key = \"purchase_date\"; break;\n    case MKTAG( 'r','t','n','g'): key = \"rating\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 's','o','a','a'): key = \"sort_album_artist\"; break;\n    case MKTAG( 's','o','a','l'): key = \"sort_album\";   break;\n    case MKTAG( 's','o','a','r'): key = \"sort_artist\";  break;\n    case MKTAG( 's','o','c','o'): key = \"sort_composer\"; break;\n    case MKTAG( 's','o','n','m'): key = \"sort_name\";    break;\n    case MKTAG( 's','o','s','n'): key = \"sort_show\";    break;\n    case MKTAG( 's','t','i','k'): key = \"media_type\";\n        parse = mov_metadata_int8_no_padding; break;\n    case MKTAG( 't','r','k','n'): key = \"track\";\n        parse = mov_metadata_track_or_disc_number; break;\n    case MKTAG( 't','v','e','n'): key = \"episode_id\"; break;\n    case MKTAG( 't','v','e','s'): key = \"episode_sort\";\n        parse = mov_metadata_int8_bypass_padding; break;\n    case MKTAG( 't','v','n','n'): key = \"network\";   break;\n    case MKTAG( 't','v','s','h'): key = \"show\";      break;\n    case MKTAG( 't','v','s','n'): key = \"season_number\";\n        parse = mov_metadata_int8_bypass_padding; break;\n    case MKTAG(0xa9,'A','R','T'): key = \"artist\";    break;\n    case MKTAG(0xa9,'P','R','D'): key = \"producer\";  break;\n    case MKTAG(0xa9,'a','l','b'): key = \"album\";     break;\n    case MKTAG(0xa9,'a','u','t'): key = \"artist\";    break;\n    case MKTAG(0xa9,'c','h','p'): key = \"chapter\";   break;\n    case MKTAG(0xa9,'c','m','t'): key = \"comment\";   break;\n    case MKTAG(0xa9,'c','o','m'): key = \"composer\";  break;\n    case MKTAG(0xa9,'c','p','y'): key = \"copyright\"; break;\n    case MKTAG(0xa9,'d','a','y'): key = \"date\";      break;\n    case MKTAG(0xa9,'d','i','r'): key = \"director\";  break;\n    case MKTAG(0xa9,'d','i','s'): key = \"disclaimer\"; break;\n    case MKTAG(0xa9,'e','d','1'): key = \"edit_date\"; break;\n    case MKTAG(0xa9,'e','n','c'): key = \"encoder\";   break;\n    case MKTAG(0xa9,'f','m','t'): key = \"original_format\"; break;\n    case MKTAG(0xa9,'g','e','n'): key = \"genre\";     break;\n    case MKTAG(0xa9,'g','r','p'): key = \"grouping\";  break;\n    case MKTAG(0xa9,'h','s','t'): key = \"host_computer\"; break;\n    case MKTAG(0xa9,'i','n','f'): key = \"comment\";   break;\n    case MKTAG(0xa9,'l','y','r'): key = \"lyrics\";    break;\n    case MKTAG(0xa9,'m','a','k'): key = \"make\";      break;\n    case MKTAG(0xa9,'m','o','d'): key = \"model\";     break;\n    case MKTAG(0xa9,'n','a','m'): key = \"title\";     break;\n    case MKTAG(0xa9,'o','p','e'): key = \"original_artist\"; break;\n    case MKTAG(0xa9,'p','r','d'): key = \"producer\";  break;\n    case MKTAG(0xa9,'p','r','f'): key = \"performers\"; break;\n    case MKTAG(0xa9,'r','e','q'): key = \"playback_requirements\"; break;\n    case MKTAG(0xa9,'s','r','c'): key = \"original_source\"; break;\n    case MKTAG(0xa9,'s','t','3'): key = \"subtitle\";  break;\n    case MKTAG(0xa9,'s','w','r'): key = \"encoder\";   break;\n    case MKTAG(0xa9,'t','o','o'): key = \"encoder\";   break;\n    case MKTAG(0xa9,'t','r','k'): key = \"track\";     break;\n    case MKTAG(0xa9,'u','r','l'): key = \"URL\";       break;\n    case MKTAG(0xa9,'w','r','n'): key = \"warning\";   break;\n    case MKTAG(0xa9,'w','r','t'): key = \"composer\";  break;\n    case MKTAG(0xa9,'x','y','z'): key = \"location\";  break;\n    }\nretry:\n    if (c->itunes_metadata && atom.size > 8) {\n        int data_size = avio_rb32(pb);\n        int tag = avio_rl32(pb);\n        if (tag == MKTAG('d','a','t','a') && data_size <= atom.size && data_size >= 16) {\n            data_type = avio_rb32(pb); \/\/ type\n            avio_rb32(pb); \/\/ unknown\n            str_size = data_size - 16;\n            atom.size -= 16;\n\n            if (!key && c->found_hdlr_mdta && c->meta_keys) {\n                uint32_t index = av_bswap32(atom.type); \/\/ BE number has been read as LE\n                if (index < c->meta_keys_count && index > 0) {\n                    key = c->meta_keys[index];\n                } else if (atom.type != MKTAG('c', 'o', 'v', 'r')) {\n                    av_log(c->fc, AV_LOG_WARNING,\n                           \"The index of 'data' is out of range: %\"PRId32\" < 1 or >= %d.\\n\",\n                           index, c->meta_keys_count);\n                }\n            }\n            if (atom.type == MKTAG('c', 'o', 'v', 'r') ||\n                (key && !strcmp(key, \"com.apple.quicktime.artwork\"))) {\n                int ret = mov_read_covr(c, pb, data_type, str_size);\n                if (ret < 0) {\n                    av_log(c->fc, AV_LOG_ERROR, \"Error parsing cover art.\\n\");\n                    return ret;\n                }\n                atom.size -= str_size;\n                if (atom.size > 8)\n                    goto retry;\n                return ret;\n            }\n        } else return 0;\n    } else if (atom.size > 4 && key && !c->itunes_metadata && !raw) {\n        str_size = avio_rb16(pb); \/\/ string length\n        if (str_size > atom.size) {\n            raw = 1;\n            avio_seek(pb, -2, SEEK_CUR);\n            av_log(c->fc, AV_LOG_WARNING, \"UDTA parsing failed retrying raw\\n\");\n            goto retry;\n        }\n        langcode = avio_rb16(pb);\n        ff_mov_lang_to_iso639(langcode, language);\n        atom.size -= 4;\n    } else\n        str_size = atom.size;\n\n    if (c->export_all && !key) {\n        key = av_fourcc_make_string(tmp_key, atom.type);\n    }\n\n    if (!key)\n        return 0;\n    if (atom.size < 0 || str_size >= INT_MAX\/2)\n        return AVERROR_INVALIDDATA;\n\n    \/\/ Allocates enough space if data_type is a int32 or float32 number, otherwise\n    \/\/ worst-case requirement for output string in case of utf8 coded input\n    num = (data_type >= 21 && data_type <= 23);\n    str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1;\n    str = av_mallocz(str_size_alloc);\n    if (!str)\n        return AVERROR(ENOMEM);\n\n    if (parse)\n        parse(c, pb, str_size, key);\n    else {\n        if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) { \/\/ MAC Encoded\n            mov_read_mac_string(c, pb, str_size, str, str_size_alloc);\n        } else if (data_type == 21) { \/\/ BE signed integer, variable size\n            int val = 0;\n            if (str_size == 1)\n                val = (int8_t)avio_r8(pb);\n            else if (str_size == 2)\n                val = (int16_t)avio_rb16(pb);\n            else if (str_size == 3)\n                val = ((int32_t)(avio_rb24(pb)<<8))>>8;\n            else if (str_size == 4)\n                val = (int32_t)avio_rb32(pb);\n            if (snprintf(str, str_size_alloc, \"%d\", val) >= str_size_alloc) {\n                av_log(c->fc, AV_LOG_ERROR,\n                       \"Failed to store the number (%d) in string.\\n\", val);\n                av_free(str);\n                return AVERROR_INVALIDDATA;\n            }\n        } else if (data_type == 22) { \/\/ BE unsigned integer, variable size\n            unsigned int val = 0;\n            if (str_size == 1)\n                val = avio_r8(pb);\n            else if (str_size == 2)\n                val = avio_rb16(pb);\n            else if (str_size == 3)\n                val = avio_rb24(pb);\n            else if (str_size == 4)\n                val = avio_rb32(pb);\n            if (snprintf(str, str_size_alloc, \"%u\", val) >= str_size_alloc) {\n                av_log(c->fc, AV_LOG_ERROR,\n                       \"Failed to store the number (%u) in string.\\n\", val);\n                av_free(str);\n                return AVERROR_INVALIDDATA;\n            }\n        } else if (data_type == 23 && str_size >= 4) {  \/\/ BE float32\n            float val = av_int2float(avio_rb32(pb));\n            if (snprintf(str, str_size_alloc, \"%f\", val) >= str_size_alloc) {\n                av_log(c->fc, AV_LOG_ERROR,\n                       \"Failed to store the float32 number (%f) in string.\\n\", val);\n                av_free(str);\n                return AVERROR_INVALIDDATA;\n            }\n        } else if (data_type > 1 && data_type != 4) {\n            \/\/ data_type can be 0 if not set at all above. data_type 1 means\n            \/\/ UTF8 and 4 means \"UTF8 sort\". For any other type (UTF16 or e.g.\n            \/\/ a picture), don't return it blindly in a string that is supposed\n            \/\/ to be UTF8 text.\n            av_log(c->fc, AV_LOG_WARNING, \"Skipping unhandled metadata %s of type %d\\n\", key, data_type);\n            av_free(str);\n            return 0;\n        } else {\n            int ret = ffio_read_size(pb, str, str_size);\n            if (ret < 0) {\n                av_free(str);\n                return ret;\n            }\n            str[str_size] = 0;\n        }\n        c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;\n        av_dict_set(&c->fc->metadata, key, str, 0);\n        if (*language && strcmp(language, \"und\")) {\n            snprintf(key2, sizeof(key2), \"%s-%s\", key, language);\n            av_dict_set(&c->fc->metadata, key2, str, 0);\n        }\n        if (!strcmp(key, \"encoder\")) {\n            int major, minor, micro;\n            if (sscanf(str, \"HandBrake %d.%d.%d\", &major, &minor, µ) == 3) {\n                c->handbrake_version = 1000000*major + 1000*minor + micro;\n            }\n        }\n    }\n\n    av_freep(&str);\n    return 0;\n}","target":0,"code_token_length":3571,"total_token_length":3807,"max_tokens_setting":4096}
+{"idx":442960,"func":"update_screen(int type_arg)\n{\n    int\t\ttype = type_arg;\n    win_T\t*wp;\n    static int\tdid_intro = FALSE;\n#ifdef FEAT_GUI\n    int\t\tdid_one = FALSE;\n    int\t\tdid_undraw = FALSE;\n    int\t\tgui_cursor_col = 0;\n    int\t\tgui_cursor_row = 0;\n#endif\n    int\t\tno_update = FALSE;\n    int\t\tsave_pum_will_redraw = pum_will_redraw;\n\n    \/\/ Don't do anything if the screen structures are (not yet) valid.\n    if (!screen_valid(TRUE))\n\treturn FAIL;\n\n    if (type == VALID_NO_UPDATE)\n    {\n\tno_update = TRUE;\n\ttype = 0;\n    }\n\n#ifdef FEAT_EVAL\n    {\n\tbuf_T *buf;\n\n\t\/\/ Before updating the screen, notify any listeners of changed text.\n\tFOR_ALL_BUFFERS(buf)\n\t    invoke_listeners(buf);\n    }\n#endif\n\n#ifdef FEAT_DIFF\n    \/\/ May have postponed updating diffs.\n    if (need_diff_redraw)\n\tdiff_redraw(TRUE);\n#endif\n\n    if (must_redraw)\n    {\n\tif (type < must_redraw)\t    \/\/ use maximal type\n\t    type = must_redraw;\n\n\t\/\/ must_redraw is reset here, so that when we run into some weird\n\t\/\/ reason to redraw while busy redrawing (e.g., asynchronous\n\t\/\/ scrolling), or update_topline() in win_update() will cause a\n\t\/\/ scroll, the screen will be redrawn later or in win_update().\n\tmust_redraw = 0;\n    }\n\n    \/\/ May need to update w_lines[].\n    if (curwin->w_lines_valid == 0 && type < NOT_VALID\n#ifdef FEAT_TERMINAL\n\t    && !term_do_update_window(curwin)\n#endif\n\t\t)\n\ttype = NOT_VALID;\n\n    \/\/ Postpone the redrawing when it's not needed and when being called\n    \/\/ recursively.\n    if (!redrawing() || updating_screen)\n    {\n\tredraw_later(type);\t\t\/\/ remember type for next time\n\tmust_redraw = type;\n\tif (type > INVERTED_ALL)\n\t    curwin->w_lines_valid = 0;\t\/\/ don't use w_lines[].wl_size now\n\treturn FAIL;\n    }\n    updating_screen = TRUE;\n\n#ifdef FEAT_PROP_POPUP\n    \/\/ Update popup_mask if needed.  This may set w_redraw_top and w_redraw_bot\n    \/\/ in some windows.\n    may_update_popup_mask(type);\n#endif\n\n#ifdef FEAT_SYN_HL\n    ++display_tick;\t    \/\/ let syntax code know we're in a next round of\n\t\t\t    \/\/ display updating\n#endif\n    if (no_update)\n\t++no_win_do_lines_ins;\n\n    \/\/ if the screen was scrolled up when displaying a message, scroll it down\n    if (msg_scrolled)\n    {\n\tclear_cmdline = TRUE;\n\tif (msg_scrolled > Rows - 5)\t    \/\/ clearing is faster\n\t    type = CLEAR;\n\telse if (type != CLEAR)\n\t{\n\t    check_for_delay(FALSE);\n\t    if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, 0, NULL)\n\t\t\t\t\t\t\t\t       == FAIL)\n\t\ttype = CLEAR;\n\t    FOR_ALL_WINDOWS(wp)\n\t    {\n\t\tif (wp->w_winrow < msg_scrolled)\n\t\t{\n\t\t    if (W_WINROW(wp) + wp->w_height > msg_scrolled\n\t\t\t    && wp->w_redr_type < REDRAW_TOP\n\t\t\t    && wp->w_lines_valid > 0\n\t\t\t    && wp->w_topline == wp->w_lines[0].wl_lnum)\n\t\t    {\n\t\t\twp->w_upd_rows = msg_scrolled - W_WINROW(wp);\n\t\t\twp->w_redr_type = REDRAW_TOP;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\twp->w_redr_type = NOT_VALID;\n\t\t\tif (W_WINROW(wp) + wp->w_height + wp->w_status_height\n\t\t\t\t\t\t\t       <= msg_scrolled)\n\t\t\t    wp->w_redr_status = TRUE;\n\t\t    }\n\t\t}\n\t    }\n\t    if (!no_update)\n\t\tredraw_cmdline = TRUE;\n\t    redraw_tabline = TRUE;\n\t}\n\tmsg_scrolled = 0;\n\tneed_wait_return = FALSE;\n    }\n\n    \/\/ reset cmdline_row now (may have been changed temporarily)\n    compute_cmdrow();\n\n    \/\/ Check for changed highlighting\n    if (need_highlight_changed)\n\thighlight_changed();\n\n    if (type == CLEAR)\t\t\/\/ first clear screen\n    {\n\tscreenclear();\t\t\/\/ will reset clear_cmdline\n\ttype = NOT_VALID;\n\t\/\/ must_redraw may be set indirectly, avoid another redraw later\n\tmust_redraw = 0;\n    }\n\n    if (clear_cmdline)\t\t\/\/ going to clear cmdline (done below)\n\tcheck_for_delay(FALSE);\n\n#ifdef FEAT_LINEBREAK\n    \/\/ Force redraw when width of 'number' or 'relativenumber' column\n    \/\/ changes.\n    if (curwin->w_redr_type < NOT_VALID\n\t   && curwin->w_nrwidth != ((curwin->w_p_nu || curwin->w_p_rnu)\n\t\t\t\t    ? number_width(curwin) : 0))\n\tcurwin->w_redr_type = NOT_VALID;\n#endif\n\n    \/\/ Only start redrawing if there is really something to do.\n    if (type == INVERTED)\n\tupdate_curswant();\n    if (curwin->w_redr_type < type\n\t    && !((type == VALID\n\t\t    && curwin->w_lines[0].wl_valid\n#ifdef FEAT_DIFF\n\t\t    && curwin->w_topfill == curwin->w_old_topfill\n\t\t    && curwin->w_botfill == curwin->w_old_botfill\n#endif\n\t\t    && curwin->w_topline == curwin->w_lines[0].wl_lnum)\n\t\t|| (type == INVERTED\n\t\t    && VIsual_active\n\t\t    && curwin->w_old_cursor_lnum == curwin->w_cursor.lnum\n\t\t    && curwin->w_old_visual_mode == VIsual_mode\n\t\t    && (curwin->w_valid & VALID_VIRTCOL)\n\t\t    && curwin->w_old_curswant == curwin->w_curswant)\n\t\t))\n\tcurwin->w_redr_type = type;\n\n    \/\/ Redraw the tab pages line if needed.\n    if (redraw_tabline || type >= NOT_VALID)\n\tdraw_tabline();\n\n#ifdef FEAT_SYN_HL\n    \/\/ Correct stored syntax highlighting info for changes in each displayed\n    \/\/ buffer.  Each buffer must only be done once.\n    FOR_ALL_WINDOWS(wp)\n    {\n\tif (wp->w_buffer->b_mod_set)\n\t{\n\t    win_T\t*wwp;\n\n\t    \/\/ Check if we already did this buffer.\n\t    for (wwp = firstwin; wwp != wp; wwp = wwp->w_next)\n\t\tif (wwp->w_buffer == wp->w_buffer)\n\t\t    break;\n\t    if (wwp == wp && syntax_present(wp))\n\t\tsyn_stack_apply_changes(wp->w_buffer);\n\t}\n    }\n#endif\n\n    if (pum_redraw_in_same_position())\n\t\/\/ Avoid flicker if the popup menu is going to be redrawn in the same\n\t\/\/ position.\n\tpum_will_redraw = TRUE;\n\n    \/\/ Go from top to bottom through the windows, redrawing the ones that need\n    \/\/ it.\n#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)\n    did_update_one_window = FALSE;\n#endif\n#ifdef FEAT_SEARCH_EXTRA\n    screen_search_hl.rm.regprog = NULL;\n#endif\n    FOR_ALL_WINDOWS(wp)\n    {\n\tif (wp->w_redr_type != 0)\n\t{\n\t    cursor_off();\n#ifdef FEAT_GUI\n\t    if (!did_one)\n\t    {\n\t\tdid_one = TRUE;\n\n\t\t\/\/ Remove the cursor before starting to do anything, because\n\t\t\/\/ scrolling may make it difficult to redraw the text under\n\t\t\/\/ it.\n\t\t\/\/ Also remove the cursor if it needs to be hidden due to an\n\t\t\/\/ ongoing cursor-less sleep.\n\t\tif (gui.in_use && (wp == curwin || cursor_is_sleeping()))\n\t\t{\n\t\t    gui_cursor_col = gui.cursor_col;\n\t\t    gui_cursor_row = gui.cursor_row;\n\t\t    gui_undraw_cursor();\n\t\t    did_undraw = TRUE;\n\t\t}\n\t    }\n#endif\n\t    win_update(wp);\n\t}\n\n\t\/\/ redraw status line after the window to minimize cursor movement\n\tif (wp->w_redr_status)\n\t{\n\t    cursor_off();\n\t    win_redr_status(wp, TRUE); \/\/ any popup menu will be redrawn below\n\t}\n    }\n#if defined(FEAT_SEARCH_EXTRA)\n    end_search_hl();\n#endif\n\n    \/\/ May need to redraw the popup menu.\n    pum_will_redraw = save_pum_will_redraw;\n    pum_may_redraw();\n\n    \/\/ Reset b_mod_set flags.  Going through all windows is probably faster\n    \/\/ than going through all buffers (there could be many buffers).\n    FOR_ALL_WINDOWS(wp)\n\twp->w_buffer->b_mod_set = FALSE;\n\n#ifdef FEAT_PROP_POPUP\n    \/\/ Display popup windows on top of the windows and command line.\n    update_popups(win_update);\n#endif\n\n#ifdef FEAT_TERMINAL\n    FOR_ALL_WINDOWS(wp)\n\t\/\/ If this window contains a terminal, after redrawing all windows, the\n\t\/\/ dirty row range can be reset.\n\tterm_did_update_window(wp);\n#endif\n\n    after_updating_screen(TRUE);\n\n    \/\/ Clear or redraw the command line.  Done last, because scrolling may\n    \/\/ mess up the command line.\n    if (clear_cmdline || redraw_cmdline || redraw_mode)\n\tshowmode();\n\n    if (no_update)\n\t--no_win_do_lines_ins;\n\n    \/\/ May put up an introductory message when not editing a file\n    if (!did_intro)\n\tmaybe_intro_message();\n    did_intro = TRUE;\n\n#ifdef FEAT_GUI\n    \/\/ Redraw the cursor and update the scrollbars when all screen updating is\n    \/\/ done.\n    if (gui.in_use)\n    {\n\tif (did_undraw && !gui_mch_is_blink_off())\n\t{\n\t    mch_disable_flush();\n\t    out_flush();\t\/\/ required before updating the cursor\n\t    mch_enable_flush();\n\n\t    \/\/ Put the GUI position where the cursor was, gui_update_cursor()\n\t    \/\/ uses that.\n\t    gui.col = gui_cursor_col;\n\t    gui.row = gui_cursor_row;\n\t    gui.col = mb_fix_col(gui.col, gui.row);\n\t    gui_update_cursor(FALSE, FALSE);\n\t    gui_may_flush();\n\t    screen_cur_col = gui.col;\n\t    screen_cur_row = gui.row;\n\t}\n\telse\n\t    out_flush();\n\tgui_update_scrollbars(FALSE);\n    }\n#endif\n    return OK;\n}","target":0,"code_token_length":2282,"total_token_length":2518,"max_tokens_setting":4096}
+{"idx":196993,"func":"Status DecodeImageAPNG(Span<const uint8_t> bytes, ThreadPool* pool,\n                       CodecInOut* io) {\n  Reader r;\n  unsigned int id, i, j, w, h, w0, h0, x0, y0;\n  unsigned int delay_num, delay_den, dop, bop, rowbytes, imagesize;\n  unsigned char sig[8];\n  png_structp png_ptr;\n  png_infop info_ptr;\n  CHUNK chunk;\n  CHUNK chunkIHDR;\n  std::vector<CHUNK> chunksInfo;\n  bool isAnimated = false;\n  bool skipFirst = false;\n  bool hasInfo = false;\n  bool all_dispose_bg = true;\n  APNGFrame frameRaw = {};\n\n  r = {bytes.data(), bytes.data() + bytes.size()};\n  \/\/ Not an aPNG => not an error\n  unsigned char png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n  if (r.Read(sig, 8) || memcmp(sig, png_signature, 8) != 0) {\n    return false;\n  }\n  id = read_chunk(&r, &chunkIHDR);\n\n  io->frames.clear();\n  io->dec_pixels = 0;\n  io->metadata.m.SetUintSamples(8);\n  io->metadata.m.SetAlphaBits(8);\n  io->metadata.m.color_encoding =\n      ColorEncoding::SRGB();  \/\/ todo: get data from png metadata\n  (void)io->dec_hints.Foreach(\n      [](const std::string& key, const std::string& \/*value*\/) {\n        JXL_WARNING(\"APNG decoder ignoring %s hint\", key.c_str());\n        return true;\n      });\n\n  bool errorstate = true;\n  if (id == kId_IHDR && chunkIHDR.size == 25) {\n    w0 = w = png_get_uint_32(chunkIHDR.p + 8);\n    h0 = h = png_get_uint_32(chunkIHDR.p + 12);\n\n    if (w > cMaxPNGSize || h > cMaxPNGSize) {\n      return false;\n    }\n\n    x0 = 0;\n    y0 = 0;\n    delay_num = 1;\n    delay_den = 10;\n    dop = 0;\n    bop = 0;\n    rowbytes = w * 4;\n    imagesize = h * rowbytes;\n\n    frameRaw.p = new unsigned char[imagesize];\n    frameRaw.rows = new png_bytep[h * sizeof(png_bytep)];\n    for (j = 0; j < h; j++) frameRaw.rows[j] = frameRaw.p + j * rowbytes;\n\n    if (!processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo,\n                          chunkIHDR, chunksInfo)) {\n      bool last_base_was_none = true;\n      while (!r.Eof()) {\n        id = read_chunk(&r, &chunk);\n        if (!id) break;\n        JXL_ASSERT(chunk.p != nullptr);\n\n        if (id == kId_acTL && !hasInfo && !isAnimated) {\n          isAnimated = true;\n          skipFirst = true;\n          io->metadata.m.have_animation = true;\n          io->metadata.m.animation.tps_numerator = 1000;\n        } else if (id == kId_IEND ||\n                   (id == kId_fcTL && (!hasInfo || isAnimated))) {\n          if (hasInfo) {\n            if (!processing_finish(png_ptr, info_ptr)) {\n              ImageBundle bundle(&io->metadata.m);\n              bundle.duration = delay_num * 1000 \/ delay_den;\n              bundle.origin.x0 = x0;\n              bundle.origin.y0 = y0;\n              \/\/ TODO(veluca): this could in principle be implemented.\n              if (last_base_was_none && !all_dispose_bg &&\n                  (x0 != 0 || y0 != 0 || w0 != w || h0 != h || bop != 0)) {\n                return JXL_FAILURE(\n                    \"APNG with dispose-to-0 is not supported for non-full or \"\n                    \"blended frames\");\n              }\n              switch (dop) {\n                case 0:\n                  bundle.use_for_next_frame = true;\n                  last_base_was_none = false;\n                  all_dispose_bg = false;\n                  break;\n                case 2:\n                  bundle.use_for_next_frame = false;\n                  all_dispose_bg = false;\n                  break;\n                default:\n                  bundle.use_for_next_frame = false;\n                  last_base_was_none = true;\n              }\n              bundle.blend = bop != 0;\n              io->dec_pixels += w0 * h0;\n\n              Image3F sub_frame(w0, h0);\n              ImageF sub_frame_alpha(w0, h0);\n              for (size_t y = 0; y < h0; ++y) {\n                float* const JXL_RESTRICT row_r = sub_frame.PlaneRow(0, y);\n                float* const JXL_RESTRICT row_g = sub_frame.PlaneRow(1, y);\n                float* const JXL_RESTRICT row_b = sub_frame.PlaneRow(2, y);\n                float* const JXL_RESTRICT row_alpha = sub_frame_alpha.Row(y);\n                uint8_t* const f = frameRaw.rows[y];\n                for (size_t x = 0; x < w0; ++x) {\n                  if (f[4 * x + 3] == 0) {\n                    row_alpha[x] = 0;\n                    row_r[x] = 0;\n                    row_g[x] = 0;\n                    row_b[x] = 0;\n                    continue;\n                  }\n                  row_r[x] = f[4 * x + 0] * (1.f \/ 255);\n                  row_g[x] = f[4 * x + 1] * (1.f \/ 255);\n                  row_b[x] = f[4 * x + 2] * (1.f \/ 255);\n                  row_alpha[x] = f[4 * x + 3] * (1.f \/ 255);\n                }\n              }\n              bundle.SetFromImage(std::move(sub_frame), ColorEncoding::SRGB());\n              bundle.SetAlpha(std::move(sub_frame_alpha),\n                              \/*alpha_is_premultiplied=*\/false);\n              io->frames.push_back(std::move(bundle));\n            } else {\n              delete[] chunk.p;\n              break;\n            }\n          }\n\n          if (id == kId_IEND) {\n            errorstate = false;\n            break;\n          }\n          \/\/ At this point the old frame is done. Let's start a new one.\n          w0 = png_get_uint_32(chunk.p + 12);\n          h0 = png_get_uint_32(chunk.p + 16);\n          x0 = png_get_uint_32(chunk.p + 20);\n          y0 = png_get_uint_32(chunk.p + 24);\n          delay_num = png_get_uint_16(chunk.p + 28);\n          delay_den = png_get_uint_16(chunk.p + 30);\n          dop = chunk.p[32];\n          bop = chunk.p[33];\n\n          if (w0 > cMaxPNGSize || h0 > cMaxPNGSize || x0 > cMaxPNGSize ||\n              y0 > cMaxPNGSize || x0 + w0 > w || y0 + h0 > h || dop > 2 ||\n              bop > 1) {\n            delete[] chunk.p;\n            break;\n          }\n\n          if (hasInfo) {\n            memcpy(chunkIHDR.p + 8, chunk.p + 12, 8);\n            if (processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo,\n                                 chunkIHDR, chunksInfo)) {\n              delete[] chunk.p;\n              break;\n            }\n          } else\n            skipFirst = false;\n\n          if (io->frames.size() == (skipFirst ? 1 : 0)) {\n            bop = 0;\n            if (dop == 2) dop = 1;\n          }\n        } else if (id == kId_IDAT) {\n          hasInfo = true;\n          if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) {\n            delete[] chunk.p;\n            break;\n          }\n        } else if (id == kId_fdAT && isAnimated) {\n          png_save_uint_32(chunk.p + 4, chunk.size - 16);\n          memcpy(chunk.p + 8, \"IDAT\", 4);\n          if (processing_data(png_ptr, info_ptr, chunk.p + 4, chunk.size - 4)) {\n            delete[] chunk.p;\n            break;\n          }\n        } else if (!isAbc(chunk.p[4]) || !isAbc(chunk.p[5]) ||\n                   !isAbc(chunk.p[6]) || !isAbc(chunk.p[7])) {\n          delete[] chunk.p;\n          break;\n        } else if (!hasInfo) {\n          if (processing_data(png_ptr, info_ptr, chunk.p, chunk.size)) {\n            delete[] chunk.p;\n            break;\n          }\n          chunksInfo.push_back(chunk);\n          continue;\n        }\n        delete[] chunk.p;\n      }\n    }\n    delete[] frameRaw.rows;\n    delete[] frameRaw.p;\n  }\n\n  for (i = 0; i < chunksInfo.size(); i++) delete[] chunksInfo[i].p;\n\n  chunksInfo.clear();\n  delete[] chunkIHDR.p;\n\n  if (errorstate) return false;\n  SetIntensityTarget(io);\n  return true;\n}","target":1,"code_token_length":2075,"total_token_length":2311,"max_tokens_setting":4096}
+{"idx":508412,"func":"mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,\n                    List<String> *using_fields, uint *found_using_fields)\n{\n  Field_iterator_table_ref it_1, it_2;\n  Natural_join_column *nj_col_1, *nj_col_2;\n  Query_arena *arena, backup;\n  bool result= TRUE;\n  bool first_outer_loop= TRUE;\n  \/*\n    Leaf table references to which new natural join columns are added\n    if the leaves are != NULL.\n  *\/\n  TABLE_LIST *leaf_1= (table_ref_1->nested_join &&\n                       !table_ref_1->is_natural_join) ?\n                      NULL : table_ref_1;\n  TABLE_LIST *leaf_2= (table_ref_2->nested_join &&\n                       !table_ref_2->is_natural_join) ?\n                      NULL : table_ref_2;\n\n  DBUG_ENTER(\"mark_common_columns\");\n  DBUG_PRINT(\"info\", (\"operand_1: %s  operand_2: %s\",\n                      table_ref_1->alias, table_ref_2->alias));\n\n  *found_using_fields= 0;\n  arena= thd->activate_stmt_arena_if_needed(&backup);\n\n  for (it_1.set(table_ref_1); !it_1.end_of_fields(); it_1.next())\n  {\n    bool found= FALSE;\n    const char *field_name_1;\n    \/* true if field_name_1 is a member of using_fields *\/\n    bool is_using_column_1;\n    if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1)))\n      goto err;\n    field_name_1= nj_col_1->name();\n    is_using_column_1= using_fields && \n      test_if_string_in_list(field_name_1, using_fields);\n    DBUG_PRINT (\"info\", (\"field_name_1=%s.%s\", \n                         nj_col_1->table_name() ? nj_col_1->table_name() : \"\", \n                         field_name_1));\n\n    \/*\n      Find a field with the same name in table_ref_2.\n\n      Note that for the second loop, it_2.set() will iterate over\n      table_ref_2->join_columns and not generate any new elements or\n      lists.\n    *\/\n    nj_col_2= NULL;\n    for (it_2.set(table_ref_2); !it_2.end_of_fields(); it_2.next())\n    {\n      Natural_join_column *cur_nj_col_2;\n      const char *cur_field_name_2;\n      if (!(cur_nj_col_2= it_2.get_or_create_column_ref(thd, leaf_2)))\n        goto err;\n      cur_field_name_2= cur_nj_col_2->name();\n      DBUG_PRINT (\"info\", (\"cur_field_name_2=%s.%s\", \n                           cur_nj_col_2->table_name() ? \n                             cur_nj_col_2->table_name() : \"\", \n                           cur_field_name_2));\n\n      \/*\n        Compare the two columns and check for duplicate common fields.\n        A common field is duplicate either if it was already found in\n        table_ref_2 (then found == TRUE), or if a field in table_ref_2\n        was already matched by some previous field in table_ref_1\n        (then cur_nj_col_2->is_common == TRUE).\n        Note that it is too early to check the columns outside of the\n        USING list for ambiguity because they are not actually \"referenced\"\n        here. These columns must be checked only on unqualified reference \n        by name (e.g. in SELECT list).\n      *\/\n      if (!my_strcasecmp(system_charset_info, field_name_1, cur_field_name_2))\n      {\n        DBUG_PRINT (\"info\", (\"match c1.is_common=%d\", nj_col_1->is_common));\n        if (cur_nj_col_2->is_common ||\n            (found && (!using_fields || is_using_column_1)))\n        {\n          my_error(ER_NON_UNIQ_ERROR, MYF(0), field_name_1, thd->where);\n          goto err;\n        }\n        nj_col_2= cur_nj_col_2;\n        found= TRUE;\n      }\n    }\n    if (first_outer_loop && leaf_2)\n    {\n      \/*\n        Make sure that the next inner loop \"knows\" that all columns\n        are materialized already.\n      *\/\n      leaf_2->is_join_columns_complete= TRUE;\n      first_outer_loop= FALSE;\n    }\n    if (!found)\n      continue;                                 \/\/ No matching field\n\n    \/*\n      field_1 and field_2 have the same names. Check if they are in the USING\n      clause (if present), mark them as common fields, and add a new\n      equi-join condition to the ON clause.\n    *\/\n    if (nj_col_2 && (!using_fields ||is_using_column_1))\n    {\n      \/*\n        Create non-fixed fully qualified field and let fix_fields to\n        resolve it.\n      *\/\n      Item *item_1=   nj_col_1->create_item(thd);\n      Item *item_2=   nj_col_2->create_item(thd);\n      Field *field_1= nj_col_1->field();\n      Field *field_2= nj_col_2->field();\n      Item_ident *item_ident_1, *item_ident_2;\n      Item_func_eq *eq_cond;\n\n      if (!item_1 || !item_2)\n        goto err;                               \/\/ out of memory\n\n      \/*\n        The following assert checks that the two created items are of\n        type Item_ident.\n      *\/\n      DBUG_ASSERT(!thd->lex->current_select->no_wrap_view_item);\n      \/*\n        In the case of no_wrap_view_item == 0, the created items must be\n        of sub-classes of Item_ident.\n      *\/\n      DBUG_ASSERT(item_1->type() == Item::FIELD_ITEM ||\n                  item_1->type() == Item::REF_ITEM);\n      DBUG_ASSERT(item_2->type() == Item::FIELD_ITEM ||\n                  item_2->type() == Item::REF_ITEM);\n\n      \/*\n        We need to cast item_1,2 to Item_ident, because we need to hook name\n        resolution contexts specific to each item.\n      *\/\n      item_ident_1= (Item_ident*) item_1;\n      item_ident_2= (Item_ident*) item_2;\n      \/*\n        Create and hook special name resolution contexts to each item in the\n        new join condition . We need this to both speed-up subsequent name\n        resolution of these items, and to enable proper name resolution of\n        the items during the execute phase of PS.\n      *\/\n      if (set_new_item_local_context(thd, item_ident_1, nj_col_1->table_ref) ||\n          set_new_item_local_context(thd, item_ident_2, nj_col_2->table_ref))\n        goto err;\n\n      if (!(eq_cond= new (thd->mem_root) Item_func_eq(thd, item_ident_1, item_ident_2)))\n        goto err;                               \/* Out of memory. *\/\n\n      if (field_1 && field_1->vcol_info)\n        field_1->table->mark_virtual_col(field_1);\n      if (field_2 && field_2->vcol_info)\n        field_2->table->mark_virtual_col(field_2);\n\n      \/*\n        Add the new equi-join condition to the ON clause. Notice that\n        fix_fields() is applied to all ON conditions in setup_conds()\n        so we don't do it here.\n      *\/\n      add_join_on(thd, (table_ref_1->outer_join & JOIN_TYPE_RIGHT ?\n                        table_ref_1 : table_ref_2),\n                  eq_cond);\n\n      nj_col_1->is_common= nj_col_2->is_common= TRUE;\n      DBUG_PRINT (\"info\", (\"%s.%s and %s.%s are common\", \n                           nj_col_1->table_name() ? \n                             nj_col_1->table_name() : \"\", \n                           nj_col_1->name(),\n                           nj_col_2->table_name() ? \n                             nj_col_2->table_name() : \"\", \n                           nj_col_2->name()));\n\n      if (field_1)\n      {\n        TABLE *table_1= nj_col_1->table_ref->table;\n        \/* Mark field_1 used for table cache. *\/\n        bitmap_set_bit(table_1->read_set, field_1->field_index);\n        table_1->covering_keys.intersect(field_1->part_of_key);\n      }\n      if (field_2)\n      {\n        TABLE *table_2= nj_col_2->table_ref->table;\n        \/* Mark field_2 used for table cache. *\/\n        bitmap_set_bit(table_2->read_set, field_2->field_index);\n        table_2->covering_keys.intersect(field_2->part_of_key);\n      }\n\n      if (using_fields != NULL)\n        ++(*found_using_fields);\n    }\n  }\n  if (leaf_1)\n    leaf_1->is_join_columns_complete= TRUE;\n\n  \/*\n    Everything is OK.\n    Notice that at this point there may be some column names in the USING\n    clause that are not among the common columns. This is an SQL error and\n    we check for this error in store_natural_using_join_columns() when\n    (found_using_fields < length(join_using_fields)).\n  *\/\n  result= FALSE;\n\nerr:\n  if (arena)\n    thd->restore_active_arena(arena, &backup);\n  DBUG_RETURN(result);\n}","target":0,"code_token_length":2057,"total_token_length":2293,"max_tokens_setting":4096}
+{"idx":414927,"func":"xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {\n    int depth1, depth2;\n    int misc = 0, precedence1 = 0, precedence2 = 0;\n    xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;\n    xmlNodePtr cur, root;\n    long l1, l2;\n\n    if ((node1 == NULL) || (node2 == NULL))\n\treturn(-2);\n\n    if (node1 == node2)\n\treturn(0);\n\n    \/*\n     * a couple of optimizations which will avoid computations in most cases\n     *\/\n    switch (node1->type) {\n\tcase XML_ELEMENT_NODE:\n\t    if (node2->type == XML_ELEMENT_NODE) {\n\t\tif ((0 > (long) node1->content) && \/* TODO: Would a != 0 suffice here? *\/\n\t\t    (0 > (long) node2->content) &&\n\t\t    (node1->doc == node2->doc))\n\t\t{\n\t\t    l1 = -((long) node1->content);\n\t\t    l2 = -((long) node2->content);\n\t\t    if (l1 < l2)\n\t\t\treturn(1);\n\t\t    if (l1 > l2)\n\t\t\treturn(-1);\n\t\t} else\n\t\t    goto turtle_comparison;\n\t    }\n\t    break;\n\tcase XML_ATTRIBUTE_NODE:\n\t    precedence1 = 1; \/* element is owner *\/\n\t    miscNode1 = node1;\n\t    node1 = node1->parent;\n\t    misc = 1;\n\t    break;\n\tcase XML_TEXT_NODE:\n\tcase XML_CDATA_SECTION_NODE:\n\tcase XML_COMMENT_NODE:\n\tcase XML_PI_NODE: {\n\t    miscNode1 = node1;\n\t    \/*\n\t    * Find nearest element node.\n\t    *\/\n\t    if (node1->prev != NULL) {\n\t\tdo {\n\t\t    node1 = node1->prev;\n\t\t    if (node1->type == XML_ELEMENT_NODE) {\n\t\t\tprecedence1 = 3; \/* element in prev-sibl axis *\/\n\t\t\tbreak;\n\t\t    }\n\t\t    if (node1->prev == NULL) {\n\t\t\tprecedence1 = 2; \/* element is parent *\/\n\t\t\t\/*\n\t\t\t* URGENT TODO: Are there any cases, where the\n\t\t\t* parent of such a node is not an element node?\n\t\t\t*\/\n\t\t\tnode1 = node1->parent;\n\t\t\tbreak;\n\t\t    }\n\t\t} while (1);\n\t    } else {\n\t\tprecedence1 = 2; \/* element is parent *\/\n\t\tnode1 = node1->parent;\n\t    }\n\t    if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE) ||\n\t\t(0 <= (long) node1->content)) {\n\t\t\/*\n\t\t* Fallback for whatever case.\n\t\t*\/\n\t\tnode1 = miscNode1;\n\t\tprecedence1 = 0;\n\t    } else\n\t\tmisc = 1;\n\t}\n\t    break;\n\tcase XML_NAMESPACE_DECL:\n\t    \/*\n\t    * TODO: why do we return 1 for namespace nodes?\n\t    *\/\n\t    return(1);\n\tdefault:\n\t    break;\n    }\n    switch (node2->type) {\n\tcase XML_ELEMENT_NODE:\n\t    break;\n\tcase XML_ATTRIBUTE_NODE:\n\t    precedence2 = 1; \/* element is owner *\/\n\t    miscNode2 = node2;\n\t    node2 = node2->parent;\n\t    misc = 1;\n\t    break;\n\tcase XML_TEXT_NODE:\n\tcase XML_CDATA_SECTION_NODE:\n\tcase XML_COMMENT_NODE:\n\tcase XML_PI_NODE: {\n\t    miscNode2 = node2;\n\t    if (node2->prev != NULL) {\n\t\tdo {\n\t\t    node2 = node2->prev;\n\t\t    if (node2->type == XML_ELEMENT_NODE) {\n\t\t\tprecedence2 = 3; \/* element in prev-sibl axis *\/\n\t\t\tbreak;\n\t\t    }\n\t\t    if (node2->prev == NULL) {\n\t\t\tprecedence2 = 2; \/* element is parent *\/\n\t\t\tnode2 = node2->parent;\n\t\t\tbreak;\n\t\t    }\n\t\t} while (1);\n\t    } else {\n\t\tprecedence2 = 2; \/* element is parent *\/\n\t\tnode2 = node2->parent;\n\t    }\n\t    if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) ||\n\t\t(0 <= (long) node2->content))\n\t    {\n\t\tnode2 = miscNode2;\n\t\tprecedence2 = 0;\n\t    } else\n\t\tmisc = 1;\n\t}\n\t    break;\n\tcase XML_NAMESPACE_DECL:\n\t    return(1);\n\tdefault:\n\t    break;\n    }\n    if (misc) {\n\tif (node1 == node2) {\n\t    if (precedence1 == precedence2) {\n\t\t\/*\n\t\t* The ugly case; but normally there aren't many\n\t\t* adjacent non-element nodes around.\n\t\t*\/\n\t\tcur = miscNode2->prev;\n\t\twhile (cur != NULL) {\n\t\t    if (cur == miscNode1)\n\t\t\treturn(1);\n\t\t    if (cur->type == XML_ELEMENT_NODE)\n\t\t\treturn(-1);\n\t\t    cur = cur->prev;\n\t\t}\n\t\treturn (-1);\n\t    } else {\n\t\t\/*\n\t\t* Evaluate based on higher precedence wrt to the element.\n\t\t* TODO: This assumes attributes are sorted before content.\n\t\t*   Is this 100% correct?\n\t\t*\/\n\t\tif (precedence1 < precedence2)\n\t\t    return(1);\n\t\telse\n\t\t    return(-1);\n\t    }\n\t}\n\t\/*\n\t* Special case: One of the helper-elements is contained by the other.\n\t* <foo>\n\t*   <node2>\n\t*     <node1>Text-1(precedence1 == 2)<\/node1>\n\t*   <\/node2>\n\t*   Text-6(precedence2 == 3)\n\t* <\/foo>\n\t*\/\n\tif ((precedence2 == 3) && (precedence1 > 1)) {\n\t    cur = node1->parent;\n\t    while (cur) {\n\t\tif (cur == node2)\n\t\t    return(1);\n\t\tcur = cur->parent;\n\t    }\n\t}\n\tif ((precedence1 == 3) && (precedence2 > 1)) {\n\t    cur = node2->parent;\n\t    while (cur) {\n\t\tif (cur == node1)\n\t\t    return(-1);\n\t\tcur = cur->parent;\n\t    }\n\t}\n    }\n\n    \/*\n     * Speedup using document order if availble.\n     *\/\n    if ((node1->type == XML_ELEMENT_NODE) &&\n\t(node2->type == XML_ELEMENT_NODE) &&\n\t(0 > (long) node1->content) &&\n\t(0 > (long) node2->content) &&\n\t(node1->doc == node2->doc)) {\n\n\tl1 = -((long) node1->content);\n\tl2 = -((long) node2->content);\n\tif (l1 < l2)\n\t    return(1);\n\tif (l1 > l2)\n\t    return(-1);\n    }\n\nturtle_comparison:\n\n    if (node1 == node2->prev)\n\treturn(1);\n    if (node1 == node2->next)\n\treturn(-1);\n    \/*\n     * compute depth to root\n     *\/\n    for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) {\n\tif (cur == node1)\n\t    return(1);\n\tdepth2++;\n    }\n    root = cur;\n    for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) {\n\tif (cur == node2)\n\t    return(-1);\n\tdepth1++;\n    }\n    \/*\n     * Distinct document (or distinct entities :-( ) case.\n     *\/\n    if (root != cur) {\n\treturn(-2);\n    }\n    \/*\n     * get the nearest common ancestor.\n     *\/\n    while (depth1 > depth2) {\n\tdepth1--;\n\tnode1 = node1->parent;\n    }\n    while (depth2 > depth1) {\n\tdepth2--;\n\tnode2 = node2->parent;\n    }\n    while (node1->parent != node2->parent) {\n\tnode1 = node1->parent;\n\tnode2 = node2->parent;\n\t\/* should not happen but just in case ... *\/\n\tif ((node1 == NULL) || (node2 == NULL))\n\t    return(-2);\n    }\n    \/*\n     * Find who's first.\n     *\/\n    if (node1 == node2->prev)\n\treturn(1);\n    if (node1 == node2->next)\n\treturn(-1);\n    \/*\n     * Speedup using document order if availble.\n     *\/\n    if ((node1->type == XML_ELEMENT_NODE) &&\n\t(node2->type == XML_ELEMENT_NODE) &&\n\t(0 > (long) node1->content) &&\n\t(0 > (long) node2->content) &&\n\t(node1->doc == node2->doc)) {\n\n\tl1 = -((long) node1->content);\n\tl2 = -((long) node2->content);\n\tif (l1 < l2)\n\t    return(1);\n\tif (l1 > l2)\n\t    return(-1);\n    }\n\n    for (cur = node1->next;cur != NULL;cur = cur->next)\n\tif (cur == node2)\n\t    return(1);\n    return(-1); \/* assume there is no sibling list corruption *\/\n}","target":0,"code_token_length":1988,"total_token_length":2224,"max_tokens_setting":4096}
+{"idx":293939,"func":"ex_retab(exarg_T *eap)\n{\n    linenr_T\tlnum;\n    int\t\tgot_tab = FALSE;\n    long\tnum_spaces = 0;\n    long\tnum_tabs;\n    long\tlen;\n    long\tcol;\n    long\tvcol;\n    long\tstart_col = 0;\t\t\/\/ For start of white-space string\n    long\tstart_vcol = 0;\t\t\/\/ For start of white-space string\n    long\told_len;\n    char_u\t*ptr;\n    char_u\t*new_line = (char_u *)1; \/\/ init to non-NULL\n    int\t\tdid_undo;\t\t\/\/ called u_save for current line\n#ifdef FEAT_VARTABS\n    int\t\t*new_vts_array = NULL;\n    char_u\t*new_ts_str;\t\t\/\/ string value of tab argument\n#else\n    int\t\ttemp;\n    int\t\tnew_ts;\n#endif\n    int\t\tsave_list;\n    linenr_T\tfirst_line = 0;\t\t\/\/ first changed line\n    linenr_T\tlast_line = 0;\t\t\/\/ last changed line\n\n    save_list = curwin->w_p_list;\n    curwin->w_p_list = 0;\t    \/\/ don't want list mode here\n\n#ifdef FEAT_VARTABS\n    new_ts_str = eap->arg;\n    if (tabstop_set(eap->arg, &new_vts_array) == FAIL)\n\treturn;\n    while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')\n\t++(eap->arg);\n\n    \/\/ This ensures that either new_vts_array and new_ts_str are freshly\n    \/\/ allocated, or new_vts_array points to an existing array and new_ts_str\n    \/\/ is null.\n    if (new_vts_array == NULL)\n    {\n\tnew_vts_array = curbuf->b_p_vts_array;\n\tnew_ts_str = NULL;\n    }\n    else\n\tnew_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);\n#else\n    ptr = eap->arg;\n    new_ts = getdigits(&ptr);\n    if (new_ts < 0 && *eap->arg == '-')\n    {\n\temsg(_(e_argument_must_be_positive));\n\treturn;\n    }\n    if (new_ts < 0 || new_ts > TABSTOP_MAX)\n    {\n\tsemsg(_(e_invalid_argument_str), eap->arg);\n\treturn;\n    }\n    if (new_ts == 0)\n\tnew_ts = curbuf->b_p_ts;\n#endif\n    for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)\n    {\n\tptr = ml_get(lnum);\n\tcol = 0;\n\tvcol = 0;\n\tdid_undo = FALSE;\n\tfor (;;)\n\t{\n\t    if (VIM_ISWHITE(ptr[col]))\n\t    {\n\t\tif (!got_tab && num_spaces == 0)\n\t\t{\n\t\t    \/\/ First consecutive white-space\n\t\t    start_vcol = vcol;\n\t\t    start_col = col;\n\t\t}\n\t\tif (ptr[col] == ' ')\n\t\t    num_spaces++;\n\t\telse\n\t\t    got_tab = TRUE;\n\t    }\n\t    else\n\t    {\n\t\tif (got_tab || (eap->forceit && num_spaces > 1))\n\t\t{\n\t\t    \/\/ Retabulate this string of white-space\n\n\t\t    \/\/ len is virtual length of white string\n\t\t    len = num_spaces = vcol - start_vcol;\n\t\t    num_tabs = 0;\n\t\t    if (!curbuf->b_p_et)\n\t\t    {\n#ifdef FEAT_VARTABS\n\t\t\tint t, s;\n\n\t\t\ttabstop_fromto(start_vcol, vcol,\n\t\t\t\t\tcurbuf->b_p_ts, new_vts_array, &t, &s);\n\t\t\tnum_tabs = t;\n\t\t\tnum_spaces = s;\n#else\n\t\t\ttemp = new_ts - (start_vcol % new_ts);\n\t\t\tif (num_spaces >= temp)\n\t\t\t{\n\t\t\t    num_spaces -= temp;\n\t\t\t    num_tabs++;\n\t\t\t}\n\t\t\tnum_tabs += num_spaces \/ new_ts;\n\t\t\tnum_spaces -= (num_spaces \/ new_ts) * new_ts;\n#endif\n\t\t    }\n\t\t    if (curbuf->b_p_et || got_tab ||\n\t\t\t\t\t(num_spaces + num_tabs < len))\n\t\t    {\n\t\t\tif (did_undo == FALSE)\n\t\t\t{\n\t\t\t    did_undo = TRUE;\n\t\t\t    if (u_save((linenr_T)(lnum - 1),\n\t\t\t\t\t\t(linenr_T)(lnum + 1)) == FAIL)\n\t\t\t    {\n\t\t\t\tnew_line = NULL;\t\/\/ flag out-of-memory\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t}\n\n\t\t\t\/\/ len is actual number of white characters used\n\t\t\tlen = num_spaces + num_tabs;\n\t\t\told_len = (long)STRLEN(ptr);\n\t\t\tnew_line = alloc(old_len - col + start_col + len + 1);\n\t\t\tif (new_line == NULL)\n\t\t\t    break;\n\t\t\tif (start_col > 0)\n\t\t\t    mch_memmove(new_line, ptr, (size_t)start_col);\n\t\t\tmch_memmove(new_line + start_col + len,\n\t\t\t\t      ptr + col, (size_t)(old_len - col + 1));\n\t\t\tptr = new_line + start_col;\n\t\t\tfor (col = 0; col < len; col++)\n\t\t\t    ptr[col] = (col < num_tabs) ? '\\t' : ' ';\n\t\t\tif (ml_replace(lnum, new_line, FALSE) == OK)\n\t\t\t    \/\/ \"new_line\" may have been copied\n\t\t\t    new_line = curbuf->b_ml.ml_line_ptr;\n\t\t\tif (first_line == 0)\n\t\t\t    first_line = lnum;\n\t\t\tlast_line = lnum;\n\t\t\tptr = new_line;\n\t\t\tcol = start_col + len;\n\t\t    }\n\t\t}\n\t\tgot_tab = FALSE;\n\t\tnum_spaces = 0;\n\t    }\n\t    if (ptr[col] == NUL)\n\t\tbreak;\n\t    vcol += chartabsize(ptr + col, (colnr_T)vcol);\n\t    if (vcol >= MAXCOL)\n\t    {\n\t\temsg(_(e_resulting_text_too_long));\n\t\tbreak;\n\t    }\n\t    if (has_mbyte)\n\t\tcol += (*mb_ptr2len)(ptr + col);\n\t    else\n\t\t++col;\n\t}\n\tif (new_line == NULL)\t\t    \/\/ out of memory\n\t    break;\n\tline_breakcheck();\n    }\n    if (got_int)\n\temsg(_(e_interrupted));\n\n#ifdef FEAT_VARTABS\n    \/\/ If a single value was given then it can be considered equal to\n    \/\/ either the value of 'tabstop' or the value of 'vartabstop'.\n    if (tabstop_count(curbuf->b_p_vts_array) == 0\n\t&& tabstop_count(new_vts_array) == 1\n\t&& curbuf->b_p_ts == tabstop_first(new_vts_array))\n\t; \/\/ not changed\n    else if (tabstop_count(curbuf->b_p_vts_array) > 0\n        && tabstop_eq(curbuf->b_p_vts_array, new_vts_array))\n\t; \/\/ not changed\n    else\n\tredraw_curbuf_later(NOT_VALID);\n#else\n    if (curbuf->b_p_ts != new_ts)\n\tredraw_curbuf_later(NOT_VALID);\n#endif\n    if (first_line != 0)\n\tchanged_lines(first_line, 0, last_line + 1, 0L);\n\n    curwin->w_p_list = save_list;\t\/\/ restore 'list'\n\n#ifdef FEAT_VARTABS\n    if (new_ts_str != NULL)\t\t\/\/ set the new tabstop\n    {\n\t\/\/ If 'vartabstop' is in use or if the value given to retab has more\n\t\/\/ than one tabstop then update 'vartabstop'.\n\tint *old_vts_ary = curbuf->b_p_vts_array;\n\n\tif (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)\n\t{\n\t    set_string_option_direct((char_u *)\"vts\", -1, new_ts_str,\n\t\t\t\t\t\t\tOPT_FREE|OPT_LOCAL, 0);\n\t    curbuf->b_p_vts_array = new_vts_array;\n\t    vim_free(old_vts_ary);\n\t}\n\telse\n\t{\n\t    \/\/ 'vartabstop' wasn't in use and a single value was given to\n\t    \/\/ retab then update 'tabstop'.\n\t    curbuf->b_p_ts = tabstop_first(new_vts_array);\n\t    vim_free(new_vts_array);\n\t}\n\tvim_free(new_ts_str);\n    }\n#else\n    curbuf->b_p_ts = new_ts;\n#endif\n    coladvance(curwin->w_curswant);\n\n    u_clearline();\n}","target":0,"code_token_length":1856,"total_token_length":2092,"max_tokens_setting":4096}
+{"idx":384785,"func":"read_file_or_blob(typval_T *argvars, typval_T *rettv, int always_blob)\n{\n    int\t\tbinary = FALSE;\n    int\t\tblob = always_blob;\n    int\t\tfailed = FALSE;\n    char_u\t*fname;\n    FILE\t*fd;\n    char_u\tbuf[(IOSIZE\/256)*256];\t\/\/ rounded to avoid odd + 1\n    int\t\tio_size = sizeof(buf);\n    int\t\treadlen;\t\t\/\/ size of last fread()\n    char_u\t*prev\t = NULL;\t\/\/ previously read bytes, if any\n    long\tprevlen  = 0;\t\t\/\/ length of data in prev\n    long\tprevsize = 0;\t\t\/\/ size of prev buffer\n    long\tmaxline  = MAXLNUM;\n    long\tcnt\t = 0;\n    char_u\t*p;\t\t\t\/\/ position in buf\n    char_u\t*start;\t\t\t\/\/ start of current line\n\n    if (argvars[1].v_type != VAR_UNKNOWN)\n    {\n\tif (STRCMP(tv_get_string(&argvars[1]), \"b\") == 0)\n\t    binary = TRUE;\n\tif (STRCMP(tv_get_string(&argvars[1]), \"B\") == 0)\n\t    blob = TRUE;\n\n\tif (argvars[2].v_type != VAR_UNKNOWN)\n\t    maxline = (long)tv_get_number(&argvars[2]);\n    }\n\n    if ((blob ? rettv_blob_alloc(rettv) : rettv_list_alloc(rettv)) == FAIL)\n\treturn;\n\n    \/\/ Always open the file in binary mode, library functions have a mind of\n    \/\/ their own about CR-LF conversion.\n    fname = tv_get_string(&argvars[0]);\n\n    if (mch_isdir(fname))\n    {\n\tsemsg(_(e_src_is_directory), fname);\n\treturn;\n    }\n    if (*fname == NUL || (fd = mch_fopen((char *)fname, READBIN)) == NULL)\n    {\n\tsemsg(_(e_cant_open_file_str), *fname == NUL ? (char_u *)_(\"<empty>\") : fname);\n\treturn;\n    }\n\n    if (blob)\n    {\n\tif (read_blob(fd, rettv->vval.v_blob) == FAIL)\n\t{\n\t    semsg(_(e_cant_read_file_str), fname);\n\t    \/\/ An empty blob is returned on error.\n\t    blob_free(rettv->vval.v_blob);\n\t    rettv->vval.v_blob = NULL;\n\t}\n\tfclose(fd);\n\treturn;\n    }\n\n    while (cnt < maxline || maxline < 0)\n    {\n\treadlen = (int)fread(buf, 1, io_size, fd);\n\n\t\/\/ This for loop processes what was read, but is also entered at end\n\t\/\/ of file so that either:\n\t\/\/ - an incomplete line gets written\n\t\/\/ - a \"binary\" file gets an empty line at the end if it ends in a\n\t\/\/   newline.\n\tfor (p = buf, start = buf;\n\t\tp < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));\n\t\t++p)\n\t{\n\t    if (readlen <= 0 || *p == '\\n')\n\t    {\n\t\tlistitem_T  *li;\n\t\tchar_u\t    *s\t= NULL;\n\t\tlong_u\t    len = p - start;\n\n\t\t\/\/ Finished a line.  Remove CRs before NL.\n\t\tif (readlen > 0 && !binary)\n\t\t{\n\t\t    while (len > 0 && start[len - 1] == '\\r')\n\t\t\t--len;\n\t\t    \/\/ removal may cross back to the \"prev\" string\n\t\t    if (len == 0)\n\t\t\twhile (prevlen > 0 && prev[prevlen - 1] == '\\r')\n\t\t\t    --prevlen;\n\t\t}\n\t\tif (prevlen == 0)\n\t\t    s = vim_strnsave(start, len);\n\t\telse\n\t\t{\n\t\t    \/\/ Change \"prev\" buffer to be the right size.  This way\n\t\t    \/\/ the bytes are only copied once, and very long lines are\n\t\t    \/\/ allocated only once.\n\t\t    if ((s = vim_realloc(prev, prevlen + len + 1)) != NULL)\n\t\t    {\n\t\t\tmch_memmove(s + prevlen, start, len);\n\t\t\ts[prevlen + len] = NUL;\n\t\t\tprev = NULL; \/\/ the list will own the string\n\t\t\tprevlen = prevsize = 0;\n\t\t    }\n\t\t}\n\t\tif (s == NULL)\n\t\t{\n\t\t    do_outofmem_msg((long_u) prevlen + len + 1);\n\t\t    failed = TRUE;\n\t\t    break;\n\t\t}\n\n\t\tif ((li = listitem_alloc()) == NULL)\n\t\t{\n\t\t    vim_free(s);\n\t\t    failed = TRUE;\n\t\t    break;\n\t\t}\n\t\tli->li_tv.v_type = VAR_STRING;\n\t\tli->li_tv.v_lock = 0;\n\t\tli->li_tv.vval.v_string = s;\n\t\tlist_append(rettv->vval.v_list, li);\n\n\t\tstart = p + 1; \/\/ step over newline\n\t\tif ((++cnt >= maxline && maxline >= 0) || readlen <= 0)\n\t\t    break;\n\t    }\n\t    else if (*p == NUL)\n\t\t*p = '\\n';\n\t    \/\/ Check for utf8 \"bom\"; U+FEFF is encoded as EF BB BF.  Do this\n\t    \/\/ when finding the BF and check the previous two bytes.\n\t    else if (*p == 0xbf && enc_utf8 && !binary)\n\t    {\n\t\t\/\/ Find the two bytes before the 0xbf.\tIf p is at buf, or buf\n\t\t\/\/ + 1, these may be in the \"prev\" string.\n\t\tchar_u back1 = p >= buf + 1 ? p[-1]\n\t\t\t\t     : prevlen >= 1 ? prev[prevlen - 1] : NUL;\n\t\tchar_u back2 = p >= buf + 2 ? p[-2]\n\t\t\t  : p == buf + 1 && prevlen >= 1 ? prev[prevlen - 1]\n\t\t\t  : prevlen >= 2 ? prev[prevlen - 2] : NUL;\n\n\t\tif (back2 == 0xef && back1 == 0xbb)\n\t\t{\n\t\t    char_u *dest = p - 2;\n\n\t\t    \/\/ Usually a BOM is at the beginning of a file, and so at\n\t\t    \/\/ the beginning of a line; then we can just step over it.\n\t\t    if (start == dest)\n\t\t\tstart = p + 1;\n\t\t    else\n\t\t    {\n\t\t\t\/\/ have to shuffle buf to close gap\n\t\t\tint adjust_prevlen = 0;\n\n\t\t\tif (dest < buf)\n\t\t\t{\n\t\t\t    \/\/ must be 1 or 2\n\t\t\t    adjust_prevlen = (int)(buf - dest);\n\t\t\t    dest = buf;\n\t\t\t}\n\t\t\tif (readlen > p - buf + 1)\n\t\t\t    mch_memmove(dest, p + 1, readlen - (p - buf) - 1);\n\t\t\treadlen -= 3 - adjust_prevlen;\n\t\t\tprevlen -= adjust_prevlen;\n\t\t\tp = dest - 1;\n\t\t    }\n\t\t}\n\t    }\n\t} \/\/ for\n\n\tif (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0)\n\t    break;\n\tif (start < p)\n\t{\n\t    \/\/ There's part of a line in buf, store it in \"prev\".\n\t    if (p - start + prevlen >= prevsize)\n\t    {\n\t\t\/\/ need bigger \"prev\" buffer\n\t\tchar_u *newprev;\n\n\t\t\/\/ A common use case is ordinary text files and \"prev\" gets a\n\t\t\/\/ fragment of a line, so the first allocation is made\n\t\t\/\/ small, to avoid repeatedly 'allocing' large and\n\t\t\/\/ 'reallocing' small.\n\t\tif (prevsize == 0)\n\t\t    prevsize = (long)(p - start);\n\t\telse\n\t\t{\n\t\t    long grow50pc = (prevsize * 3) \/ 2;\n\t\t    long growmin  = (long)((p - start) * 2 + prevlen);\n\t\t    prevsize = grow50pc > growmin ? grow50pc : growmin;\n\t\t}\n\t\tnewprev = vim_realloc(prev, prevsize);\n\t\tif (newprev == NULL)\n\t\t{\n\t\t    do_outofmem_msg((long_u)prevsize);\n\t\t    failed = TRUE;\n\t\t    break;\n\t\t}\n\t\tprev = newprev;\n\t    }\n\t    \/\/ Add the line part to end of \"prev\".\n\t    mch_memmove(prev + prevlen, start, p - start);\n\t    prevlen += (long)(p - start);\n\t}\n    } \/\/ while\n\n    \/\/ For a negative line count use only the lines at the end of the file,\n    \/\/ free the rest.\n    if (!failed && maxline < 0)\n\twhile (cnt > -maxline)\n\t{\n\t    listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first);\n\t    --cnt;\n\t}\n\n    if (failed)\n    {\n\t\/\/ an empty list is returned on error\n\tlist_free(rettv->vval.v_list);\n\trettv_list_alloc(rettv);\n    }\n\n    vim_free(prev);\n    fclose(fd);\n}","target":0,"code_token_length":1997,"total_token_length":2233,"max_tokens_setting":4096}
+{"idx":242637,"func":"static GF_Err isoffin_process(GF_Filter *filter)\n{\n\tISOMReader *read = gf_filter_get_udta(filter);\n\tu32 i, count = gf_list_count(read->channels);\n\tBool is_active = GF_FALSE;\n\tBool in_is_eos = GF_FALSE;\n\tBool check_forced_end = GF_FALSE;\n\tBool has_new_data = GF_FALSE;\n\tu64 min_offset_plus_one = 0;\n\tu32 nb_forced_end=0;\n\tif (read->in_error)\n\t\treturn read->in_error;\n\n\tif (read->pid) {\n\t\tBool fetch_input = GF_TRUE;\n\n\t\t\/\/we failed at loading the init segment during a dash switch, retry\n\t\tif (!read->is_partial_download && !read->mem_load_mode && (read->moov_not_loaded==2) ) {\n\t\t\tisoffin_configure_pid(filter, read->pid, GF_FALSE);\n\t\t\tif (read->moov_not_loaded) return GF_OK;\n\t\t}\n\t\tif (read->mem_load_mode==2) {\n\t\t\tif (!read->force_fetch && read->mem_blob.size > read->mstore_size) {\n\t\t\t\tfetch_input = GF_FALSE;\n\t\t\t}\n\t\t\tread->force_fetch = GF_FALSE;\n\t\t}\n\t\twhile (fetch_input) {\n\t\t\tGF_FilterPacket *pck = gf_filter_pid_get_packet(read->pid);\n\t\t\tif (!pck) {\n\t\t\t\t\/\/we issued a seek, wait for the first packet to be received before fetching channels\n\t\t\t\t\/\/otherwise we could end up reading from the wrong cache\n\t\t\t\tif (read->wait_for_source) {\n\t\t\t\t\t\/\/something went wrong during the seek request\n\t\t\t\t\tif (gf_filter_pid_is_eos(read->pid))\n\t\t\t\t\t\treturn GF_EOS;\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tread->wait_for_source = GF_FALSE;\n\n\t\t\tif (read->mem_load_mode) {\n\t\t\t\tu32 data_size;\n\t\t\t\tconst u8 *pck_data = gf_filter_pck_get_data(pck, &data_size);\n\t\t\t\tisoffin_push_buffer(filter, read, pck_data, data_size);\n\t\t\t}\n\t\t\t\/\/we just had a switch but init seg is not completely done: input packet is only a part of the init, drop it\n\t\t\telse if (read->moov_not_loaded==2) {\n\t\t\t\tgf_filter_pid_drop_packet(read->pid);\n\t\t\t\treturn GF_OK;\n\t\t\t}\n\t\t\tgf_filter_pid_drop_packet(read->pid);\n\t\t\thas_new_data = GF_TRUE;\n\t\t\tif (read->in_error)\n\t\t\t\treturn read->in_error;\n\t\t}\n\t\tif (gf_filter_pid_is_eos(read->pid)) {\n\t\t\tread->input_loaded = GF_TRUE;\n\t\t\tin_is_eos = GF_TRUE;\n\t\t}\n\t\tif (read->input_is_stop) {\n\t\t\tread->input_loaded = GF_TRUE;\n\t\t\tin_is_eos = GF_TRUE;\n\t\t\tread->input_is_stop = GF_FALSE;\n\t\t}\n\t\tif (!read->frag_type && read->input_loaded) {\n\t\t\tin_is_eos = GF_TRUE;\n\t\t}\n        \/\/segment is invalid, wait for eos on input an send eos on all channels\n        if (read->invalid_segment) {\n            if (!in_is_eos) return GF_OK;\n            read->invalid_segment = GF_FALSE;\n\n            for (i=0; i<count; i++) {\n                ISOMChannel *ch = gf_list_get(read->channels, i);\n                if (!ch->playing) {\n                    continue;\n                }\n                if (!ch->eos_sent) {\n                    ch->eos_sent = GF_TRUE;\n                    gf_filter_pid_set_eos(ch->pid);\n                }\n            }\n            read->eos_signaled = GF_TRUE;\n            return GF_EOS;\n        }\n\t} else if (read->extern_mov) {\n\t\tin_is_eos = GF_TRUE;\n\t\tread->input_loaded = GF_TRUE;\n\t}\n\tif (read->moov_not_loaded==1) {\n\t\tif (read->mem_load_mode)\n\t\t\treturn GF_OK;\n\t\tread->moov_not_loaded = GF_FALSE;\n\t\treturn isoffin_setup(filter, read);\n\t}\n\n\tif (read->refresh_fragmented) {\n\t\tconst GF_PropertyValue *prop;\n\n\t\tif (in_is_eos) {\n\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t} else {\n\t\t\tprop = gf_filter_pid_get_property(read->pid, GF_PROP_PID_FILE_CACHED);\n\t\t\tif (prop && prop->value.boolean)\n\t\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t}\n\n\t\tif (has_new_data) {\n\t\t\tu64 bytesMissing=0;\n\t\t\tGF_Err e;\n\t\t\tconst char *new_url = NULL;\n\t\t\tprop = gf_filter_pid_get_property(read->pid, GF_PROP_PID_FILEPATH);\n\t\t\tif (prop) new_url = prop->value.string;\n\n\t\t\te = gf_isom_refresh_fragmented(read->mov, &bytesMissing, new_url);\n\n\t\t\tif (e && (e!= GF_ISOM_INCOMPLETE_FILE)) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_DASH, (\"[IsoMedia] Failed to refresh current segment: %s\\n\", gf_error_to_string(e) ));\n\t\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] Refreshing current segment at UTC \"LLU\" - \"LLU\" bytes still missing - input is EOS %d\\n\", gf_net_get_utc(), bytesMissing, in_is_eos));\n\t\t\t}\n\n\t\t\tif (!read->refresh_fragmented && (e==GF_ISOM_INCOMPLETE_FILE)) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_DASH, (\"[IsoMedia] Incomplete Segment received - \"LLU\" bytes missing but EOF found\\n\", bytesMissing ));\n\t\t\t}\n\n#ifndef GPAC_DISABLE_LOG\n\t\t\tif (gf_log_tool_level_on(GF_LOG_DASH, GF_LOG_DEBUG)) {\n\t\t\t\tfor (i=0; i<count; i++) {\n\t\t\t\t\tISOMChannel *ch = gf_list_get(read->channels, i);\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] refresh track %d fragment - cur sample %d - new sample count %d\\n\", ch->track, ch->sample_num, gf_isom_get_sample_count(ch->owner->mov, ch->track) ));\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\tisor_check_producer_ref_time(read);\n\t\t\tif (!read->frag_type)\n\t\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t}\n\t}\n\n\tfor (i=0; i<count; i++) {\n\t\tu8 *data;\n\t\tu32 nb_pck=50;\n\t\tISOMChannel *ch;\n\t\tch = gf_list_get(read->channels, i);\n\t\tif (!ch->playing) {\n\t\t\tnb_forced_end++;\n\t\t\tcontinue;\n\t\t}\n\t\t\/\/eos not sent on this channel, we are active\n\t\tif (!ch->eos_sent)\n\t\t\tis_active = GF_TRUE;\n\n\t\twhile (nb_pck) {\n\t\t\tch->sample_data_offset = 0;\n\t\t\tif (!read->full_segment_flush && gf_filter_pid_would_block(ch->pid) )\n\t\t\t\tbreak;\n\n\t\t\tif (ch->item_id) {\n\t\t\t\tisor_reader_get_sample_from_item(ch);\n\t\t\t} else {\n\t\t\t\tisor_reader_get_sample(ch);\n\t\t\t}\n\n\t\t\tif (read->stsd && (ch->last_sample_desc_index != read->stsd) && ch->sample) {\n\t\t\t\tisor_reader_release_sample(ch);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch->sample) {\n\t\t\t\tu32 sample_dur;\n\t\t\t\tu8 dep_flags;\n\t\t\t\tu8 *subs_buf;\n\t\t\t\tu32 subs_buf_size;\n\t\t\t\tGF_FilterPacket *pck;\n\t\t\t\tif (ch->needs_pid_reconfig) {\n\t\t\t\t\tisor_update_channel_config(ch);\n\t\t\t\t\tch->needs_pid_reconfig = GF_FALSE;\n\t\t\t\t}\n\n\t\t\t\t\/\/we have at least two samples, update GF_PROP_PID_HAS_SYNC if needed\n\t\t\t\tif (ch->check_has_rap && (gf_isom_get_sample_count(ch->owner->mov, ch->track)>1) && (gf_isom_has_sync_points(ch->owner->mov, ch->track)==1)) {\n\t\t\t\t\tch->check_has_rap = GF_FALSE;\n\t\t\t\t\tch->has_rap = GF_TRUE;\n\t\t\t\t\tgf_filter_pid_set_property(ch->pid, GF_PROP_PID_HAS_SYNC, &PROP_BOOL(ch->has_rap) );\n\t\t\t\t}\n\n\t\t\t\t\/\/strip param sets from payload, trigger reconfig if needed\n\t\t\t\tisor_reader_check_config(ch);\n\n\t\t\t\tif (read->nodata) {\n\t\t\t\t\tpck = gf_filter_pck_new_shared(ch->pid, NULL, ch->sample->dataLength, NULL);\n\t\t\t\t\tif (!pck) return GF_OUT_OF_MEM;\n\t\t\t\t} else {\n\t\t\t\t\tpck = gf_filter_pck_new_alloc(ch->pid, ch->sample->dataLength, &data);\n\t\t\t\t\tif (!pck) return GF_OUT_OF_MEM;\n\n\t\t\t\t\tmemcpy(data, ch->sample->data, ch->sample->dataLength);\n\t\t\t\t}\n\t\t\t\tgf_filter_pck_set_dts(pck, ch->dts);\n\t\t\t\tgf_filter_pck_set_cts(pck, ch->cts);\n\t\t\t\tif (ch->sample->IsRAP==-1) {\n\t\t\t\t\tgf_filter_pck_set_sap(pck, GF_FILTER_SAP_1);\n\t\t\t\t\tch->redundant = 1;\n\t\t\t\t} else {\n\t\t\t\t\tgf_filter_pck_set_sap(pck, (GF_FilterSAPType) ch->sample->IsRAP);\n\t\t\t\t}\n\n\t\t\t\tif (ch->sap_3)\n\t\t\t\t\tgf_filter_pck_set_sap(pck, GF_FILTER_SAP_3);\n\t\t\t\telse if (ch->sap_4_type) {\n\t\t\t\t\tgf_filter_pck_set_sap(pck, (ch->sap_4_type==GF_ISOM_SAMPLE_PREROLL) ? GF_FILTER_SAP_4_PROL : GF_FILTER_SAP_4);\n\t\t\t\t\tgf_filter_pck_set_roll_info(pck, ch->roll);\n\t\t\t\t}\n\n\t\t\t\tsample_dur = ch->au_duration;\n\t\t\t\tif (ch->sample->nb_pack)\n\t\t\t\t\tsample_dur *= ch->sample->nb_pack;\n\t\t\t\tgf_filter_pck_set_duration(pck, sample_dur);\n\t\t\t\tgf_filter_pck_set_seek_flag(pck, ch->seek_flag);\n\n\t\t\t\t\/\/for now we only signal xPS mask for non-sap\n\t\t\t\tif (ch->xps_mask && !gf_filter_pck_get_sap(pck) ) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_XPS_MASK, &PROP_UINT(ch->xps_mask) );\n\t\t\t\t}\n\n\t\t\t\tdep_flags = ch->isLeading;\n\t\t\t\tdep_flags <<= 2;\n\t\t\t\tdep_flags |= ch->dependsOn;\n\t\t\t\tdep_flags <<= 2;\n\t\t\t\tdep_flags |= ch->dependedOn;\n\t\t\t\tdep_flags <<= 2;\n\t\t\t\tdep_flags |= ch->redundant;\n\n\t\t\t\tif (dep_flags)\n\t\t\t\t\tgf_filter_pck_set_dependency_flags(pck, dep_flags);\n\n\t\t\t\tgf_filter_pck_set_crypt_flags(pck, ch->pck_encrypted ? GF_FILTER_PCK_CRYPT : 0);\n\t\t\t\tgf_filter_pck_set_seq_num(pck, ch->sample_num);\n\n\n\t\t\t\tsubs_buf = gf_isom_sample_get_subsamples_buffer(read->mov, ch->track, ch->sample_num, &subs_buf_size);\n\t\t\t\tif (subs_buf) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_SUBS, &PROP_DATA_NO_COPY(subs_buf, subs_buf_size) );\n\t\t\t\t}\n\n\t\t\t\tif (ch->sai_buffer && ch->pck_encrypted) {\n\t\t\t\t\tassert(ch->sai_buffer_size);\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_CENC_SAI, &PROP_DATA(ch->sai_buffer, ch->sai_buffer_size) );\n\t\t\t\t}\n\n\t\t\t\tif (read->sigfrag) {\n\t\t\t\t\tGF_ISOFragmentBoundaryInfo finfo;\n\t\t\t\t\tif (gf_isom_sample_is_fragment_start(read->mov, ch->track, ch->sample_num, &finfo) ) {\n\t\t\t\t\t\tu64 start=0;\n\t\t\t\t\t\tu32 traf_start = finfo.seg_start_plus_one ? 2 : 1;\n\n\t\t\t\t\t\tif (finfo.seg_start_plus_one)\n\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_CUE_START, &PROP_BOOL(GF_TRUE));\n\n\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_FRAG_START, &PROP_UINT(traf_start));\n\n\t\t\t\t\t\tstart = finfo.frag_start;\n\t\t\t\t\t\tif (finfo.seg_start_plus_one) start = finfo.seg_start_plus_one-1;\n\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_FRAG_RANGE, &PROP_FRAC64_INT(start, finfo.mdat_end));\n\t\t\t\t\t\tif (finfo.moof_template) {\n\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_MOOF_TEMPLATE, &PROP_DATA((u8 *)finfo.moof_template, finfo.moof_template_size));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (finfo.sidx_end) {\n\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_SIDX_RANGE, &PROP_FRAC64_INT(finfo.sidx_start , finfo.sidx_end));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (read->seg_name_changed) {\n\t\t\t\t\t\t\tconst GF_PropertyValue *p = gf_filter_pid_get_property(read->pid, GF_PROP_PID_URL);\n\t\t\t\t\t\t\tread->seg_name_changed = GF_FALSE;\n\t\t\t\t\t\t\tif (p && p->value.string) {\n\t\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PID_URL, &PROP_STRING(p->value.string));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ch->sender_ntp) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_SENDER_NTP, &PROP_LONGUINT(ch->sender_ntp));\n\t\t\t\t\tif (ch->ntp_at_server_ntp) {\n\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_RECEIVER_NTP, &PROP_LONGUINT(ch->ntp_at_server_ntp));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tch->eos_sent = GF_FALSE;\n\n\t\t\t\t\/\/this might not be the true end of stream\n\t\t\t\tif ((ch->streamType==GF_STREAM_AUDIO) && (ch->sample_num == gf_isom_get_sample_count(read->mov, ch->track))) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_END_RANGE, &PROP_BOOL(GF_TRUE));\n\t\t\t\t}\n\n\t\t\t\tgf_filter_pck_send(pck);\n\t\t\t\tisor_reader_release_sample(ch);\n\n\t\t\t\tch->last_valid_sample_data_offset = ch->sample_data_offset;\n\t\t\t\tnb_pck--;\n\t\t\t} else if (ch->last_state==GF_EOS) {\n\t\t\t\tif (ch->playing == 2) {\n\t\t\t\t\tif (in_is_eos) {\n\t\t\t\t\t\tch->playing = GF_FALSE;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnb_forced_end++;\n\t\t\t\t\t\tcheck_forced_end = GF_TRUE;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (in_is_eos && !ch->eos_sent) {\n\t\t\t\t\tvoid *tfrf;\n\t\t\t\t\tconst void *gf_isom_get_tfrf(GF_ISOFile *movie, u32 trackNumber);\n\n\t\t\t\t\tch->eos_sent = GF_TRUE;\n\t\t\t\t\tread->eos_signaled = GF_TRUE;\n\n\t\t\t\t\ttfrf = (void *) gf_isom_get_tfrf(read->mov, ch->track);\n\t\t\t\t\tif (tfrf) {\n\t\t\t\t\t\tgf_filter_pid_set_info_str(ch->pid, \"smooth_tfrf\", &PROP_POINTER(tfrf) );\n\t\t\t\t\t\tch->last_has_tfrf = GF_TRUE;\n\t\t\t\t\t} else if (ch->last_has_tfrf) {\n\t\t\t\t\t\tgf_filter_pid_set_info_str(ch->pid, \"smooth_tfrf\", NULL);\n\t\t\t\t\t\tch->last_has_tfrf = GF_FALSE;\n\t\t\t\t\t}\n\n\t\t\t\t\tgf_filter_pid_set_eos(ch->pid);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else if (ch->last_state==GF_ISOM_INVALID_FILE) {\n\t\t\t\tif (!ch->eos_sent) {\n\t\t\t\t\tch->eos_sent = GF_TRUE;\n\t\t\t\t\tread->eos_signaled = GF_TRUE;\n\t\t\t\t\tgf_filter_pid_set_eos(ch->pid);\n\t\t\t\t}\n\t\t\t\treturn ch->last_state;\n\t\t\t} else {\n\t\t\t\tread->force_fetch = GF_TRUE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!min_offset_plus_one || (min_offset_plus_one - 1 > ch->last_valid_sample_data_offset))\n\t\t\tmin_offset_plus_one = 1 + ch->last_valid_sample_data_offset;\n\t}\n\tif (read->mem_load_mode && min_offset_plus_one) {\n\t\tisoffin_purge_mem(read, min_offset_plus_one-1);\n\t}\n\n\t\/\/we reached end of playback due to play range request, we must send eos - however for safety reason with DASH, we first need to cancel the input\n\tif (read->pid && check_forced_end && (nb_forced_end==count)) {\n\t\t\/\/abort input\n\t\tGF_FilterEvent evt;\n\t\tGF_FEVT_INIT(evt, GF_FEVT_STOP, read->pid);\n\t\tgf_filter_pid_send_event(read->pid, &evt);\n\t}\n\n\n\tif (!is_active) {\n\t\treturn GF_EOS;\n\t}\n\t\/\/if (in_is_eos)\n\/\/\tgf_filter_ask_rt_reschedule(filter, 1);\n\treturn GF_OK;\n\n}","target":0,"code_token_length":3743,"total_token_length":3979,"max_tokens_setting":4096}
+{"idx":195085,"func":"setup_seccomp (FlatpakBwrap   *bwrap,\n               const char     *arch,\n               gulong          allowed_personality,\n               FlatpakRunFlags run_flags,\n               GError        **error)\n{\n  gboolean multiarch = (run_flags & FLATPAK_RUN_FLAG_MULTIARCH) != 0;\n  gboolean devel = (run_flags & FLATPAK_RUN_FLAG_DEVEL) != 0;\n\n  __attribute__((cleanup (cleanup_seccomp))) scmp_filter_ctx seccomp = NULL;\n\n  \/**** BEGIN NOTE ON CODE SHARING\n   *\n   * There are today a number of different Linux container\n   * implementations.  That will likely continue for long into the\n   * future.  But we can still try to share code, and it's important\n   * to do so because it affects what library and application writers\n   * can do, and we should support code portability between different\n   * container tools.\n   *\n   * This syscall blocklist is copied from linux-user-chroot, which was in turn\n   * clearly influenced by the Sandstorm.io blocklist.\n   *\n   * If you make any changes here, I suggest sending the changes along\n   * to other sandbox maintainers.  Using the libseccomp list is also\n   * an appropriate venue:\n   * https:\/\/groups.google.com\/forum\/#!forum\/libseccomp\n   *\n   * A non-exhaustive list of links to container tooling that might\n   * want to share this blocklist:\n   *\n   *  https:\/\/github.com\/sandstorm-io\/sandstorm\n   *    in src\/sandstorm\/supervisor.c++\n   *  https:\/\/github.com\/flatpak\/flatpak.git\n   *    in common\/flatpak-run.c\n   *  https:\/\/git.gnome.org\/browse\/linux-user-chroot\n   *    in src\/setup-seccomp.c\n   *\n   **** END NOTE ON CODE SHARING\n   *\/\n  struct\n  {\n    int                  scall;\n    int                  errnum;\n    struct scmp_arg_cmp *arg;\n  } syscall_blocklist[] = {\n    \/* Block dmesg *\/\n    {SCMP_SYS (syslog), EPERM},\n    \/* Useless old syscall *\/\n    {SCMP_SYS (uselib), EPERM},\n    \/* Don't allow disabling accounting *\/\n    {SCMP_SYS (acct), EPERM},\n    \/* 16-bit code is unnecessary in the sandbox, and modify_ldt is a\n       historic source of interesting information leaks. *\/\n    {SCMP_SYS (modify_ldt), EPERM},\n    \/* Don't allow reading current quota use *\/\n    {SCMP_SYS (quotactl), EPERM},\n\n    \/* Don't allow access to the kernel keyring *\/\n    {SCMP_SYS (add_key), EPERM},\n    {SCMP_SYS (keyctl), EPERM},\n    {SCMP_SYS (request_key), EPERM},\n\n    \/* Scary VM\/NUMA ops *\/\n    {SCMP_SYS (move_pages), EPERM},\n    {SCMP_SYS (mbind), EPERM},\n    {SCMP_SYS (get_mempolicy), EPERM},\n    {SCMP_SYS (set_mempolicy), EPERM},\n    {SCMP_SYS (migrate_pages), EPERM},\n\n    \/* Don't allow subnamespace setups: *\/\n    {SCMP_SYS (unshare), EPERM},\n    {SCMP_SYS (mount), EPERM},\n    {SCMP_SYS (pivot_root), EPERM},\n#if defined(__s390__) || defined(__s390x__) || defined(__CRIS__)\n    \/* Architectures with CONFIG_CLONE_BACKWARDS2: the child stack\n     * and flags arguments are reversed so the flags come second *\/\n    {SCMP_SYS (clone), EPERM, &SCMP_A1 (SCMP_CMP_MASKED_EQ, CLONE_NEWUSER, CLONE_NEWUSER)},\n#else\n    \/* Normally the flags come first *\/\n    {SCMP_SYS (clone), EPERM, &SCMP_A0 (SCMP_CMP_MASKED_EQ, CLONE_NEWUSER, CLONE_NEWUSER)},\n#endif\n\n    \/* Don't allow faking input to the controlling tty (CVE-2017-5226) *\/\n    {SCMP_SYS (ioctl), EPERM, &SCMP_A1 (SCMP_CMP_MASKED_EQ, 0xFFFFFFFFu, (int) TIOCSTI)},\n  };\n\n  struct\n  {\n    int                  scall;\n    int                  errnum;\n    struct scmp_arg_cmp *arg;\n  } syscall_nondevel_blocklist[] = {\n    \/* Profiling operations; we expect these to be done by tools from outside\n     * the sandbox.  In particular perf has been the source of many CVEs.\n     *\/\n    {SCMP_SYS (perf_event_open), EPERM},\n    \/* Don't allow you to switch to bsd emulation or whatnot *\/\n    {SCMP_SYS (personality), EPERM, &SCMP_A0 (SCMP_CMP_NE, allowed_personality)},\n    {SCMP_SYS (ptrace), EPERM}\n  };\n  \/* Blocklist all but unix, inet, inet6 and netlink *\/\n  struct\n  {\n    int             family;\n    FlatpakRunFlags flags_mask;\n  } socket_family_allowlist[] = {\n    \/* NOTE: Keep in numerical order *\/\n    { AF_UNSPEC, 0 },\n    { AF_LOCAL, 0 },\n    { AF_INET, 0 },\n    { AF_INET6, 0 },\n    { AF_NETLINK, 0 },\n    { AF_CAN, FLATPAK_RUN_FLAG_CANBUS },\n    { AF_BLUETOOTH, FLATPAK_RUN_FLAG_BLUETOOTH },\n  };\n  int last_allowed_family;\n  int i, r;\n  g_auto(GLnxTmpfile) seccomp_tmpf  = { 0, };\n\n  seccomp = seccomp_init (SCMP_ACT_ALLOW);\n  if (!seccomp)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Initialize seccomp failed\"));\n\n  if (arch != NULL)\n    {\n      uint32_t arch_id = 0;\n      const uint32_t *extra_arches = NULL;\n\n      if (strcmp (arch, \"i386\") == 0)\n        {\n          arch_id = SCMP_ARCH_X86;\n        }\n      else if (strcmp (arch, \"x86_64\") == 0)\n        {\n          arch_id = SCMP_ARCH_X86_64;\n          extra_arches = seccomp_x86_64_extra_arches;\n        }\n      else if (strcmp (arch, \"arm\") == 0)\n        {\n          arch_id = SCMP_ARCH_ARM;\n        }\n#ifdef SCMP_ARCH_AARCH64\n      else if (strcmp (arch, \"aarch64\") == 0)\n        {\n          arch_id = SCMP_ARCH_AARCH64;\n          extra_arches = seccomp_aarch64_extra_arches;\n        }\n#endif\n\n      \/* We only really need to handle arches on multiarch systems.\n       * If only one arch is supported the default is fine *\/\n      if (arch_id != 0)\n        {\n          \/* This *adds* the target arch, instead of replacing the\n             native one. This is not ideal, because we'd like to only\n             allow the target arch, but we can't really disallow the\n             native arch at this point, because then bubblewrap\n             couldn't continue running. *\/\n          r = seccomp_arch_add (seccomp, arch_id);\n          if (r < 0 && r != -EEXIST)\n            return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to add architecture to seccomp filter\"));\n\n          if (multiarch && extra_arches != NULL)\n            {\n              for (i = 0; extra_arches[i] != 0; i++)\n                {\n                  r = seccomp_arch_add (seccomp, extra_arches[i]);\n                  if (r < 0 && r != -EEXIST)\n                    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to add multiarch architecture to seccomp filter\"));\n                }\n            }\n        }\n    }\n\n  \/* TODO: Should we filter the kernel keyring syscalls in some way?\n   * We do want them to be used by desktop apps, but they could also perhaps\n   * leak system stuff or secrets from other apps.\n   *\/\n\n  for (i = 0; i < G_N_ELEMENTS (syscall_blocklist); i++)\n    {\n      int scall = syscall_blocklist[i].scall;\n      int errnum = syscall_blocklist[i].errnum;\n\n      g_return_val_if_fail (errnum == EPERM || errnum == ENOSYS, FALSE);\n\n      if (syscall_blocklist[i].arg)\n        r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *syscall_blocklist[i].arg);\n      else\n        r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0);\n      if (r < 0 && r == -EFAULT \/* unknown syscall *\/)\n        return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to block syscall %d\"), scall);\n    }\n\n  if (!devel)\n    {\n      for (i = 0; i < G_N_ELEMENTS (syscall_nondevel_blocklist); i++)\n        {\n          int scall = syscall_nondevel_blocklist[i].scall;\n          int errnum = syscall_nondevel_blocklist[i].errnum;\n\n          g_return_val_if_fail (errnum == EPERM || errnum == ENOSYS, FALSE);\n\n          if (syscall_nondevel_blocklist[i].arg)\n            r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *syscall_nondevel_blocklist[i].arg);\n          else\n            r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0);\n\n          if (r < 0 && r == -EFAULT \/* unknown syscall *\/)\n            return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to block syscall %d\"), scall);\n        }\n    }\n\n  \/* Socket filtering doesn't work on e.g. i386, so ignore failures here\n   * However, we need to user seccomp_rule_add_exact to avoid libseccomp doing\n   * something else: https:\/\/github.com\/seccomp\/libseccomp\/issues\/8 *\/\n  last_allowed_family = -1;\n  for (i = 0; i < G_N_ELEMENTS (socket_family_allowlist); i++)\n    {\n      int family = socket_family_allowlist[i].family;\n      int disallowed;\n\n      if (socket_family_allowlist[i].flags_mask != 0 &&\n          (socket_family_allowlist[i].flags_mask & run_flags) != socket_family_allowlist[i].flags_mask)\n        continue;\n\n      for (disallowed = last_allowed_family + 1; disallowed < family; disallowed++)\n        {\n          \/* Blocklist the in-between valid families *\/\n          seccomp_rule_add_exact (seccomp, SCMP_ACT_ERRNO (EAFNOSUPPORT), SCMP_SYS (socket), 1, SCMP_A0 (SCMP_CMP_EQ, disallowed));\n        }\n      last_allowed_family = family;\n    }\n  \/* Blocklist the rest *\/\n  seccomp_rule_add_exact (seccomp, SCMP_ACT_ERRNO (EAFNOSUPPORT), SCMP_SYS (socket), 1, SCMP_A0 (SCMP_CMP_GE, last_allowed_family + 1));\n\n  if (!glnx_open_anonymous_tmpfile_full (O_RDWR | O_CLOEXEC, \"\/tmp\", &seccomp_tmpf, error))\n    return FALSE;\n\n  if (seccomp_export_bpf (seccomp, seccomp_tmpf.fd) != 0)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to export bpf\"));\n\n  lseek (seccomp_tmpf.fd, 0, SEEK_SET);\n\n  flatpak_bwrap_add_args_data_fd (bwrap,\n                                  \"--seccomp\", glnx_steal_fd (&seccomp_tmpf.fd), NULL);\n\n  return TRUE;\n}","target":1,"code_token_length":2694,"total_token_length":2930,"max_tokens_setting":4096}
+{"idx":273404,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor* seq_len_max_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"seq_len_max\", &seq_len_max_tensor));\n\n    const Tensor* x;\n    OP_REQUIRES_OK(ctx, ctx->input(\"x\", &x));\n    OP_REQUIRES(ctx, x->dims() == 3, errors::InvalidArgument(\"x must be 3D\"));\n    const int64_t timelen = x->dim_size(0);\n    const int64_t batch_size = x->dim_size(1);\n    const int64_t input_size = x->dim_size(2);\n\n    const Tensor* cs_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"cs_prev\", &cs_prev_tensor));\n\n    const Tensor* h_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"h_prev\", &h_prev_tensor));\n\n    const Tensor* w_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"w\", &w_tensor));\n    const int64_t cell_size = w_tensor->dim_size(1) \/ 4;\n    OP_REQUIRES(ctx, input_size + cell_size == w_tensor->dim_size(0),\n                errors::InvalidArgument(\n                    \"w matrix rows don't match: \", input_size + cell_size,\n                    \" vs. \", w_tensor->dim_size(0)));\n\n    const Tensor* wci_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wci\", &wci_tensor));\n\n    const Tensor* wcf_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wcf\", &wcf_tensor));\n\n    const Tensor* wco_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wco\", &wco_tensor));\n\n    const Tensor* b_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"b\", &b_tensor));\n    OP_REQUIRES(\n        ctx, cell_size == b_tensor->dim_size(0) \/ 4,\n        errors::InvalidArgument(\"w and b cell_size don't match: \", cell_size,\n                                \" vs. \", b_tensor->dim_size(0)));\n\n    const Tensor* i_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"i\", &i_out));\n\n    const Tensor* cs_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"cs\", &cs_out));\n\n    const Tensor* f_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"f\", &f_out));\n\n    const Tensor* o_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"o\", &o_out));\n\n    const Tensor* ci_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"ci\", &ci_out));\n\n    const Tensor* co_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"co\", &co_out));\n\n    const Tensor* h_out = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"h\", &h_out));\n\n    const Tensor* cs_grad = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"cs_grad\", &cs_grad));\n\n    const Tensor* h_grad = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"h_grad\", &h_grad));\n\n    TensorShape batch_input_shape({timelen, batch_size, input_size});\n    Tensor* x_grad;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(\"x_grad\", batch_input_shape, &x_grad));\n\n    Tensor* cs_prev_grad_tensor = nullptr;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(\"cs_prev_grad\", cs_prev_tensor->shape(),\n                                        &cs_prev_grad_tensor));\n\n    Tensor* h_prev_grad_tensor = nullptr;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(\"h_prev_grad\", h_prev_tensor->shape(),\n                                        &h_prev_grad_tensor));\n\n    Tensor* w_grad_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"w_grad\", w_tensor->shape(), &w_grad_tensor));\n\n    Tensor* wci_grad_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"wci_grad\", wci_tensor->shape(),\n                                             &wci_grad_tensor));\n\n    Tensor* wcf_grad_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"wcf_grad\", wcf_tensor->shape(),\n                                             &wcf_grad_tensor));\n\n    Tensor* wco_grad_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(\"wco_grad\", wco_tensor->shape(),\n                                             &wco_grad_tensor));\n\n    Tensor* b_grad_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"b_grad\", b_tensor->shape(), &b_grad_tensor));\n\n    TensorShape batch_cell_shape({batch_size, cell_size});\n\n    Tensor xh_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(\n                            DataTypeToEnum<T>::v(),\n                            TensorShape({batch_size, input_size + cell_size}),\n                            &xh_tensor));\n\n    Tensor xh_grad_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           xh_tensor.shape(), &xh_grad_tensor));\n\n    Tensor do_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &do_tensor));\n\n    Tensor dcs_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &dcs_tensor));\n\n    Tensor dci_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &dci_tensor));\n\n    Tensor df_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &df_tensor));\n\n    Tensor di_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &di_tensor));\n\n    Tensor dgates_tensor;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                      TensorShape({batch_size, cell_size * 4}),\n                                      &dgates_tensor));\n\n    Tensor cs_grad_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &cs_grad_tensor));\n\n    Tensor h_grad_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                           batch_cell_shape, &h_grad_tensor));\n\n    const Device& device = ctx->eigen_device<Device>();\n\n    functor::TensorZero<Device, T>()(device, cs_grad_tensor.flat<T>());\n    functor::TensorZero<Device, T>()(device, cs_prev_grad_tensor->flat<T>());\n    functor::TensorZero<Device, T>()(device, h_grad_tensor.flat<T>());\n    functor::TensorZero<Device, T>()(device, h_prev_grad_tensor->flat<T>());\n    functor::TensorZero<Device, T>()(device, w_grad_tensor->flat<T>());\n    functor::TensorZero<Device, T>()(device, wci_grad_tensor->flat<T>());\n    functor::TensorZero<Device, T>()(device, wcf_grad_tensor->flat<T>());\n    functor::TensorZero<Device, T>()(device, wco_grad_tensor->flat<T>());\n    functor::TensorZero<Device, T>()(device, b_grad_tensor->flat<T>());\n\n    const int64_t seq_len_max = seq_len_max_tensor->scalar<int64_t>()();\n    SliceHelper<Device, T> slicer(ctx);\n    for (int64_t t = seq_len_max - 1; t >= 0; --t) {\n      const Tensor& x_tensor = slicer.InputSlice(*x, t, \"x\");\n      const Tensor& cs_prev_tensor2 =\n          t == 0 ? *cs_prev_tensor\n                 : slicer.InputSlice(*cs_out, t - 1, \"cs_prev\");\n      const Tensor& h_prev_tensor2 =\n          t == 0 ? *h_prev_tensor : slicer.InputSlice(*h_out, t - 1, \"h_prev\");\n      const Tensor& i_tensor = slicer.InputSlice(*i_out, t, \"i_out\");\n      const Tensor& cs_tensor = slicer.InputSlice(*cs_out, t, \"cs_out\");\n      const Tensor& f_tensor = slicer.InputSlice(*f_out, t, \"f_out\");\n      const Tensor& o_tensor = slicer.InputSlice(*o_out, t, \"o_out\");\n      const Tensor& ci_tensor = slicer.InputSlice(*ci_out, t, \"ci_out\");\n      const Tensor& co_tensor = slicer.InputSlice(*co_out, t, \"co_out\");\n\n      \/\/ Grab previous CS grad.\n      const Tensor& const_cs_prev_grad_tensor = *cs_prev_grad_tensor;\n      const Tensor const_cs_grad_slice =\n          slicer.InputSlice(*cs_grad, t, \"cs_grad\");\n      functor::TensorAdd<Device, T>()(\n          device, const_cs_prev_grad_tensor.flat<T>(),\n          const_cs_grad_slice.flat<T>(), cs_grad_tensor.flat<T>());\n\n      \/\/ Combine previous h grad and h grad coming on top.\n      const Tensor& const_h_prev_grad_tensor = *h_prev_grad_tensor;\n      const Tensor const_h_grad_slice = slicer.InputSlice(*h_grad, t, \"h_grad\");\n      functor::TensorAdd<Device, T>()(\n          device, const_h_prev_grad_tensor.flat<T>(),\n          const_h_grad_slice.flat<T>(), h_grad_tensor.flat<T>());\n\n      const Tensor& const_cs_grad_tensor = cs_grad_tensor;\n      const Tensor& const_h_grad_tensor = h_grad_tensor;\n\n      Tensor x_grad_tensor = slicer.OutputSlice(x_grad, t, \"x_grad\");\n      functor::BlockLSTMBprop<Device, T, USE_CUBLAS, gate_layout>(\n          batch_size, input_size, cell_size)(\n          ctx, device, use_peephole_, x_tensor.matrix<T>(),\n          cs_prev_tensor2.matrix<T>(), h_prev_tensor2.matrix<T>(),\n          w_tensor->matrix<T>(), wci_tensor->vec<T>(), wcf_tensor->vec<T>(),\n          wco_tensor->vec<T>(), b_tensor->vec<T>(), xh_tensor.matrix<T>(),\n          i_tensor.matrix<T>(), cs_tensor.matrix<T>(), f_tensor.matrix<T>(),\n          o_tensor.matrix<T>(), ci_tensor.matrix<T>(), co_tensor.matrix<T>(),\n          const_cs_grad_tensor.matrix<T>(), const_h_grad_tensor.matrix<T>(),\n          do_tensor.matrix<T>(), dcs_tensor.matrix<T>(), dci_tensor.matrix<T>(),\n          df_tensor.matrix<T>(), di_tensor.matrix<T>(),\n          dgates_tensor.matrix<T>(), cs_prev_grad_tensor->matrix<T>(),\n          h_prev_grad_tensor->matrix<T>(), xh_grad_tensor.matrix<T>(),\n          x_grad_tensor.matrix<T>(), w_grad_tensor->matrix<T>(),\n          wci_grad_tensor->vec<T>(), wcf_grad_tensor->vec<T>(),\n          wco_grad_tensor->vec<T>(), b_grad_tensor->vec<T>());\n      slicer.FinishTimeStep();\n    }\n\n    if (seq_len_max < timelen) {\n      Tensor x_grad_tensor = x_grad->Slice(seq_len_max, timelen);\n      functor::TensorUnalignedZero<Device, T>()(\n          device, x_grad_tensor.unaligned_flat<T>());\n    }\n  }","target":0,"code_token_length":2402,"total_token_length":2638,"max_tokens_setting":4096}
+{"idx":379659,"func":"R_API void r_anal_extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int *reg_set, int *count) {\n\tint i, argc = 0;\n\tr_return_if_fail (anal && op && fcn);\n\tconst char *opsreg = op->src[0] ? get_regname (anal, op->src[0]) : NULL;\n\tconst char *opdreg = op->dst ? get_regname (anal, op->dst) : NULL;\n\tconst int size = (fcn->bits ? fcn->bits : anal->bits) \/ 8;\n\tif (!fcn->cc) {\n\t\tR_LOG_DEBUG (\"No calling convention for function '%s' to extract register arguments\\n\", fcn->name);\n\t\treturn;\n\t}\n\tchar *fname = r_type_func_guess (anal->sdb_types, fcn->name);\n\tSdb *TDB = anal->sdb_types;\n\tint max_count = r_anal_cc_max_arg (anal, fcn->cc);\n\tif (!max_count || (*count >= max_count)) {\n\t\tfree (fname);\n\t\treturn;\n\t}\n\tif (fname) {\n\t\targc = r_type_func_args_count (TDB, fname);\n\t}\n\n\tbool is_call = (op->type & 0xf) == R_ANAL_OP_TYPE_CALL || (op->type & 0xf) == R_ANAL_OP_TYPE_UCALL;\n\tif (is_call && *count < max_count) {\n\t\tRList *callee_rargs_l = NULL;\n\t\tint callee_rargs = 0;\n\t\tchar *callee = NULL;\n\t\tut64 offset = op->jump == UT64_MAX ? op->ptr : op->jump;\n\t\tRAnalFunction *f = r_anal_get_function_at (anal, offset);\n\t\tif (!f) {\n\t\t\tRCore *core = (RCore *)anal->coreb.core;\n\t\t\tRFlagItem *flag = r_flag_get_by_spaces (core->flags, offset, R_FLAGS_FS_IMPORTS, NULL);\n\t\t\tif (flag) {\n\t\t\t\tcallee = r_type_func_guess (TDB, flag->name);\n\t\t\t\tif (callee) {\n\t\t\t\t\tconst char *cc = r_anal_cc_func (anal, callee);\n\t\t\t\t\tif (cc && !strcmp (fcn->cc, cc)) {\n\t\t\t\t\t\tcallee_rargs = R_MIN (max_count, r_type_func_args_count (TDB, callee));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!f->is_variadic && !strcmp (fcn->cc, f->cc)) {\n\t\t\tcallee = r_type_func_guess (TDB, f->name);\n\t\t\tif (callee) {\n\t\t\t\tcallee_rargs = R_MIN (max_count, r_type_func_args_count (TDB, callee));\n\t\t\t}\n\t\t\tcallee_rargs = callee_rargs\n\t\t\t\t? callee_rargs\n\t\t\t\t: r_anal_var_count (anal, f, R_ANAL_VAR_KIND_REG, 1);\n\t\t\tcallee_rargs_l = r_anal_var_list (anal, f, R_ANAL_VAR_KIND_REG);\n\t\t}\n\t\tint i;\n\t\tfor (i = 0; i < callee_rargs; i++) {\n\t\t\tif (reg_set[i]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst char *vname = NULL;\n\t\t\tchar *type = NULL;\n\t\t\tchar *name = NULL;\n\t\t\tint delta = 0;\n\t\t\tconst char *regname = r_anal_cc_arg (anal, fcn->cc, i);\n\t\t\tRRegItem *ri = r_reg_get (anal->reg, regname, -1);\n\t\t\tif (ri) {\n\t\t\t\tdelta = ri->index;\n\t\t\t}\n\t\t\tif (fname) {\n\t\t\t\ttype = r_type_func_args_type (TDB, fname, i);\n\t\t\t\tvname = r_type_func_args_name (TDB, fname, i);\n\t\t\t}\n\t\t\tif (!vname && callee) {\n\t\t\t\ttype = r_type_func_args_type (TDB, callee, i);\n\t\t\t\tvname = r_type_func_args_name (TDB, callee, i);\n\t\t\t}\n\t\t\tif (vname) {\n\t\t\t\treg_set[i] = 1;\n\t\t\t} else {\n\t\t\t\tRListIter *it;\n\t\t\t\tRAnalVar *arg, *found_arg = NULL;\n\t\t\t\tr_list_foreach (callee_rargs_l, it, arg) {\n\t\t\t\t\tif (r_anal_var_get_argnum (arg) == i) {\n\t\t\t\t\t\tfound_arg = arg;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (found_arg) {\n\t\t\t\t\ttype = strdup (found_arg->type);\n\t\t\t\t\tvname = name = strdup (found_arg->name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!vname) {\n\t\t\t\tname = r_str_newf (\"arg%u\", (int)i + 1);\n\t\t\t\tvname = name;\n\t\t\t}\n\t\t\tr_anal_function_set_var (fcn, delta, R_ANAL_VAR_KIND_REG, type, size, true, vname);\n\t\t\t(*count)++;\n\t\t\tfree (name);\n\t\t\tfree (type);\n\t\t}\n\t\tfree (callee);\n\t\tr_list_free (callee_rargs_l);\n\t\tfree (fname);\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < max_count; i++) {\n\t\tconst char *regname = r_anal_cc_arg (anal, fcn->cc, i);\n\t\tif (regname) {\n\t\t\tint delta = 0;\n\t\t\tRRegItem *ri = NULL;\n\t\t\tRAnalVar *var = NULL;\n\t\t\tbool is_used_like_an_arg = is_used_like_arg (regname, opsreg, opdreg, op, anal);\n\t\t\tif (reg_set[i] != 2 && is_used_like_an_arg) {\n\t\t\t\tri = r_reg_get (anal->reg, regname, -1);\n\t\t\t\tif (ri) {\n\t\t\t\t\tdelta = ri->index;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (reg_set[i] == 1 && is_used_like_an_arg) {\n\t\t\t\tvar = r_anal_function_get_var (fcn, R_ANAL_VAR_KIND_REG, delta);\n\t\t\t} else if (reg_set[i] != 2 && is_used_like_an_arg) {\n\t\t\t\tconst char *vname = NULL;\n\t\t\t\tchar *type = NULL;\n\t\t\t\tchar *name = NULL;\n\t\t\t\tif ((i < argc) && fname) {\n\t\t\t\t\ttype = r_type_func_args_type (TDB, fname, i);\n\t\t\t\t\tvname = r_type_func_args_name (TDB, fname, i);\n\t\t\t\t}\n\t\t\t\tif (!vname) {\n\t\t\t\t\tname = r_str_newf (\"arg%d\", i + 1);\n\t\t\t\t\tvname = name;\n\t\t\t\t}\n\t\t\t\tvar = r_anal_function_set_var (fcn, delta, R_ANAL_VAR_KIND_REG, type, size, true, vname);\n\t\t\t\tfree (name);\n\t\t\t\tfree (type);\n\t\t\t\t(*count)++;\n\t\t\t} else {\n\t\t\t\tif (is_reg_in_src (regname, anal, op) || STR_EQUAL (opdreg, regname)) {\n\t\t\t\t\treg_set[i] = 2;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (is_reg_in_src (regname, anal, op) || STR_EQUAL (regname, opdreg)) {\n\t\t\t\treg_set[i] = 1;\n\t\t\t}\n\t\t\tif (var) {\n\t\t\t\tr_anal_var_set_access (var, var->regname, op->addr, R_ANAL_VAR_ACCESS_TYPE_READ, 0);\n\t\t\t\tr_meta_set_string (anal, R_META_TYPE_VARTYPE, op->addr, var->name);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst char *selfreg = r_anal_cc_self (anal, fcn->cc);\n\tif (selfreg) {\n\t\tbool is_used_like_an_arg = is_used_like_arg (selfreg, opsreg, opdreg, op, anal);\n\t\tif (reg_set[i] != 2 && is_used_like_an_arg) {\n\t\t\tint delta = 0;\n\t\t\tchar *vname = strdup (\"self\");\n\t\t\tRRegItem *ri = r_reg_get (anal->reg, selfreg, -1);\n\t\t\tif (ri) {\n\t\t\t\tdelta = ri->index;\n\t\t\t}\n\t\t\tRAnalVar *newvar = r_anal_function_set_var (fcn, delta, R_ANAL_VAR_KIND_REG, 0, size, true, vname);\n\t\t\tif (newvar) {\n\t\t\t\tr_anal_var_set_access (newvar, newvar->regname, op->addr, R_ANAL_VAR_ACCESS_TYPE_READ, 0);\n\t\t\t}\n\t\t\tr_meta_set_string (anal, R_META_TYPE_VARTYPE, op->addr, vname);\n\t\t\tfree (vname);\n\t\t\t(*count)++;\n\t\t} else {\n\t\t\tif (is_reg_in_src (selfreg, anal, op) || STR_EQUAL (opdreg, selfreg)) {\n\t\t\t\treg_set[i] = 2;\n\t\t\t}\n\t\t}\n\t\ti++;\n\t}\n\n\tconst char *errorreg = r_anal_cc_error (anal, fcn->cc);\n\tif (errorreg) {\n\t\tif (reg_set[i] == 0 && STR_EQUAL (opdreg, errorreg)) {\n\t\t\tint delta = 0;\n\t\t\tchar *vname = strdup (\"error\");\n\t\t\tRRegItem *ri = r_reg_get (anal->reg, errorreg, -1);\n\t\t\tif (ri) {\n\t\t\t\tdelta = ri->index;\n\t\t\t}\n\t\t\tRAnalVar *newvar = r_anal_function_set_var (fcn, delta, R_ANAL_VAR_KIND_REG, 0, size, true, vname);\n\t\t\tif (newvar) {\n\t\t\t\tr_anal_var_set_access (newvar, newvar->regname, op->addr, R_ANAL_VAR_ACCESS_TYPE_READ, 0);\n\t\t\t}\n\t\t\tr_meta_set_string (anal, R_META_TYPE_VARTYPE, op->addr, vname);\n\t\t\tfree (vname);\n\t\t\t(*count)++;\n\t\t\treg_set[i] = 2;\n\t\t}\n\t}\n\tfree (fname);\n}","target":0,"code_token_length":2122,"total_token_length":2358,"max_tokens_setting":4096}
+{"idx":195308,"func":"setup_seccomp (FlatpakBwrap   *bwrap,\n               const char     *arch,\n               gulong          allowed_personality,\n               FlatpakRunFlags run_flags,\n               GError        **error)\n{\n  gboolean multiarch = (run_flags & FLATPAK_RUN_FLAG_MULTIARCH) != 0;\n  gboolean devel = (run_flags & FLATPAK_RUN_FLAG_DEVEL) != 0;\n\n  __attribute__((cleanup (cleanup_seccomp))) scmp_filter_ctx seccomp = NULL;\n\n  \/**** BEGIN NOTE ON CODE SHARING\n   *\n   * There are today a number of different Linux container\n   * implementations.  That will likely continue for long into the\n   * future.  But we can still try to share code, and it's important\n   * to do so because it affects what library and application writers\n   * can do, and we should support code portability between different\n   * container tools.\n   *\n   * This syscall blocklist is copied from linux-user-chroot, which was in turn\n   * clearly influenced by the Sandstorm.io blocklist.\n   *\n   * If you make any changes here, I suggest sending the changes along\n   * to other sandbox maintainers.  Using the libseccomp list is also\n   * an appropriate venue:\n   * https:\/\/groups.google.com\/forum\/#!forum\/libseccomp\n   *\n   * A non-exhaustive list of links to container tooling that might\n   * want to share this blocklist:\n   *\n   *  https:\/\/github.com\/sandstorm-io\/sandstorm\n   *    in src\/sandstorm\/supervisor.c++\n   *  https:\/\/github.com\/flatpak\/flatpak.git\n   *    in common\/flatpak-run.c\n   *  https:\/\/git.gnome.org\/browse\/linux-user-chroot\n   *    in src\/setup-seccomp.c\n   *\n   * Other useful resources:\n   * https:\/\/github.com\/systemd\/systemd\/blob\/HEAD\/src\/shared\/seccomp-util.c\n   * https:\/\/github.com\/moby\/moby\/blob\/HEAD\/profiles\/seccomp\/default.json\n   *\n   **** END NOTE ON CODE SHARING\n   *\/\n  struct\n  {\n    int                  scall;\n    int                  errnum;\n    struct scmp_arg_cmp *arg;\n  } syscall_blocklist[] = {\n    \/* Block dmesg *\/\n    {SCMP_SYS (syslog), EPERM},\n    \/* Useless old syscall *\/\n    {SCMP_SYS (uselib), EPERM},\n    \/* Don't allow disabling accounting *\/\n    {SCMP_SYS (acct), EPERM},\n    \/* 16-bit code is unnecessary in the sandbox, and modify_ldt is a\n       historic source of interesting information leaks. *\/\n    {SCMP_SYS (modify_ldt), EPERM},\n    \/* Don't allow reading current quota use *\/\n    {SCMP_SYS (quotactl), EPERM},\n\n    \/* Don't allow access to the kernel keyring *\/\n    {SCMP_SYS (add_key), EPERM},\n    {SCMP_SYS (keyctl), EPERM},\n    {SCMP_SYS (request_key), EPERM},\n\n    \/* Scary VM\/NUMA ops *\/\n    {SCMP_SYS (move_pages), EPERM},\n    {SCMP_SYS (mbind), EPERM},\n    {SCMP_SYS (get_mempolicy), EPERM},\n    {SCMP_SYS (set_mempolicy), EPERM},\n    {SCMP_SYS (migrate_pages), EPERM},\n\n    \/* Don't allow subnamespace setups: *\/\n    {SCMP_SYS (unshare), EPERM},\n    {SCMP_SYS (setns), EPERM},\n    {SCMP_SYS (mount), EPERM},\n    {SCMP_SYS (umount), EPERM},\n    {SCMP_SYS (umount2), EPERM},\n    {SCMP_SYS (pivot_root), EPERM},\n#if defined(__s390__) || defined(__s390x__) || defined(__CRIS__)\n    \/* Architectures with CONFIG_CLONE_BACKWARDS2: the child stack\n     * and flags arguments are reversed so the flags come second *\/\n    {SCMP_SYS (clone), EPERM, &SCMP_A1 (SCMP_CMP_MASKED_EQ, CLONE_NEWUSER, CLONE_NEWUSER)},\n#else\n    \/* Normally the flags come first *\/\n    {SCMP_SYS (clone), EPERM, &SCMP_A0 (SCMP_CMP_MASKED_EQ, CLONE_NEWUSER, CLONE_NEWUSER)},\n#endif\n\n    \/* Don't allow faking input to the controlling tty (CVE-2017-5226) *\/\n    {SCMP_SYS (ioctl), EPERM, &SCMP_A1 (SCMP_CMP_MASKED_EQ, 0xFFFFFFFFu, (int) TIOCSTI)},\n\n    \/* seccomp can't look into clone3()'s struct clone_args to check whether\n     * the flags are OK, so we have no choice but to block clone3().\n     * Return ENOSYS so user-space will fall back to clone().\n     * (GHSA-67h7-w3jq-vh4q; see also https:\/\/github.com\/moby\/moby\/commit\/9f6b562d) *\/\n    {SCMP_SYS (clone3), ENOSYS},\n\n    \/* New mount manipulation APIs can also change our VFS. There's no\n     * legitimate reason to do these in the sandbox, so block all of them\n     * rather than thinking about which ones might be dangerous.\n     * (GHSA-67h7-w3jq-vh4q) *\/\n    {SCMP_SYS (open_tree), ENOSYS},\n    {SCMP_SYS (move_mount), ENOSYS},\n    {SCMP_SYS (fsopen), ENOSYS},\n    {SCMP_SYS (fsconfig), ENOSYS},\n    {SCMP_SYS (fsmount), ENOSYS},\n    {SCMP_SYS (fspick), ENOSYS},\n    {SCMP_SYS (mount_setattr), ENOSYS},\n  };\n\n  struct\n  {\n    int                  scall;\n    int                  errnum;\n    struct scmp_arg_cmp *arg;\n  } syscall_nondevel_blocklist[] = {\n    \/* Profiling operations; we expect these to be done by tools from outside\n     * the sandbox.  In particular perf has been the source of many CVEs.\n     *\/\n    {SCMP_SYS (perf_event_open), EPERM},\n    \/* Don't allow you to switch to bsd emulation or whatnot *\/\n    {SCMP_SYS (personality), EPERM, &SCMP_A0 (SCMP_CMP_NE, allowed_personality)},\n    {SCMP_SYS (ptrace), EPERM}\n  };\n  \/* Blocklist all but unix, inet, inet6 and netlink *\/\n  struct\n  {\n    int             family;\n    FlatpakRunFlags flags_mask;\n  } socket_family_allowlist[] = {\n    \/* NOTE: Keep in numerical order *\/\n    { AF_UNSPEC, 0 },\n    { AF_LOCAL, 0 },\n    { AF_INET, 0 },\n    { AF_INET6, 0 },\n    { AF_NETLINK, 0 },\n    { AF_CAN, FLATPAK_RUN_FLAG_CANBUS },\n    { AF_BLUETOOTH, FLATPAK_RUN_FLAG_BLUETOOTH },\n  };\n  int last_allowed_family;\n  int i, r;\n  g_auto(GLnxTmpfile) seccomp_tmpf  = { 0, };\n\n  seccomp = seccomp_init (SCMP_ACT_ALLOW);\n  if (!seccomp)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Initialize seccomp failed\"));\n\n  if (arch != NULL)\n    {\n      uint32_t arch_id = 0;\n      const uint32_t *extra_arches = NULL;\n\n      if (strcmp (arch, \"i386\") == 0)\n        {\n          arch_id = SCMP_ARCH_X86;\n        }\n      else if (strcmp (arch, \"x86_64\") == 0)\n        {\n          arch_id = SCMP_ARCH_X86_64;\n          extra_arches = seccomp_x86_64_extra_arches;\n        }\n      else if (strcmp (arch, \"arm\") == 0)\n        {\n          arch_id = SCMP_ARCH_ARM;\n        }\n#ifdef SCMP_ARCH_AARCH64\n      else if (strcmp (arch, \"aarch64\") == 0)\n        {\n          arch_id = SCMP_ARCH_AARCH64;\n          extra_arches = seccomp_aarch64_extra_arches;\n        }\n#endif\n\n      \/* We only really need to handle arches on multiarch systems.\n       * If only one arch is supported the default is fine *\/\n      if (arch_id != 0)\n        {\n          \/* This *adds* the target arch, instead of replacing the\n             native one. This is not ideal, because we'd like to only\n             allow the target arch, but we can't really disallow the\n             native arch at this point, because then bubblewrap\n             couldn't continue running. *\/\n          r = seccomp_arch_add (seccomp, arch_id);\n          if (r < 0 && r != -EEXIST)\n            return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to add architecture to seccomp filter\"));\n\n          if (multiarch && extra_arches != NULL)\n            {\n              for (i = 0; extra_arches[i] != 0; i++)\n                {\n                  r = seccomp_arch_add (seccomp, extra_arches[i]);\n                  if (r < 0 && r != -EEXIST)\n                    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to add multiarch architecture to seccomp filter\"));\n                }\n            }\n        }\n    }\n\n  \/* TODO: Should we filter the kernel keyring syscalls in some way?\n   * We do want them to be used by desktop apps, but they could also perhaps\n   * leak system stuff or secrets from other apps.\n   *\/\n\n  for (i = 0; i < G_N_ELEMENTS (syscall_blocklist); i++)\n    {\n      int scall = syscall_blocklist[i].scall;\n      int errnum = syscall_blocklist[i].errnum;\n\n      g_return_val_if_fail (errnum == EPERM || errnum == ENOSYS, FALSE);\n\n      if (syscall_blocklist[i].arg)\n        r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *syscall_blocklist[i].arg);\n      else\n        r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0);\n      if (r < 0 && r == -EFAULT \/* unknown syscall *\/)\n        return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to block syscall %d\"), scall);\n    }\n\n  if (!devel)\n    {\n      for (i = 0; i < G_N_ELEMENTS (syscall_nondevel_blocklist); i++)\n        {\n          int scall = syscall_nondevel_blocklist[i].scall;\n          int errnum = syscall_nondevel_blocklist[i].errnum;\n\n          g_return_val_if_fail (errnum == EPERM || errnum == ENOSYS, FALSE);\n\n          if (syscall_nondevel_blocklist[i].arg)\n            r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *syscall_nondevel_blocklist[i].arg);\n          else\n            r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0);\n\n          if (r < 0 && r == -EFAULT \/* unknown syscall *\/)\n            return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to block syscall %d\"), scall);\n        }\n    }\n\n  \/* Socket filtering doesn't work on e.g. i386, so ignore failures here\n   * However, we need to user seccomp_rule_add_exact to avoid libseccomp doing\n   * something else: https:\/\/github.com\/seccomp\/libseccomp\/issues\/8 *\/\n  last_allowed_family = -1;\n  for (i = 0; i < G_N_ELEMENTS (socket_family_allowlist); i++)\n    {\n      int family = socket_family_allowlist[i].family;\n      int disallowed;\n\n      if (socket_family_allowlist[i].flags_mask != 0 &&\n          (socket_family_allowlist[i].flags_mask & run_flags) != socket_family_allowlist[i].flags_mask)\n        continue;\n\n      for (disallowed = last_allowed_family + 1; disallowed < family; disallowed++)\n        {\n          \/* Blocklist the in-between valid families *\/\n          seccomp_rule_add_exact (seccomp, SCMP_ACT_ERRNO (EAFNOSUPPORT), SCMP_SYS (socket), 1, SCMP_A0 (SCMP_CMP_EQ, disallowed));\n        }\n      last_allowed_family = family;\n    }\n  \/* Blocklist the rest *\/\n  seccomp_rule_add_exact (seccomp, SCMP_ACT_ERRNO (EAFNOSUPPORT), SCMP_SYS (socket), 1, SCMP_A0 (SCMP_CMP_GE, last_allowed_family + 1));\n\n  if (!glnx_open_anonymous_tmpfile_full (O_RDWR | O_CLOEXEC, \"\/tmp\", &seccomp_tmpf, error))\n    return FALSE;\n\n  if (seccomp_export_bpf (seccomp, seccomp_tmpf.fd) != 0)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to export bpf\"));\n\n  lseek (seccomp_tmpf.fd, 0, SEEK_SET);\n\n  flatpak_bwrap_add_args_data_fd (bwrap,\n                                  \"--seccomp\", glnx_steal_fd (&seccomp_tmpf.fd), NULL);\n\n  return TRUE;\n}","target":1,"code_token_length":3050,"total_token_length":3286,"max_tokens_setting":4096}
+{"idx":211102,"func":"extract_archive_thread (GSimpleAsyncResult *result,\n\t\t\tGObject            *object,\n\t\t\tGCancellable       *cancellable)\n{\n\tExtractData          *extract_data;\n\tLoadData             *load_data;\n\tGHashTable           *checked_folders;\n\tstruct archive       *a;\n\tstruct archive_entry *entry;\n\tint                   r;\n\n\textract_data = g_simple_async_result_get_op_res_gpointer (result);\n\tload_data = LOAD_DATA (extract_data);\n\n\tchecked_folders = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);\n\tfr_archive_progress_set_total_files (load_data->archive, extract_data->n_files_to_extract);\n\n\ta = archive_read_new ();\n\tarchive_read_support_filter_all (a);\n\tarchive_read_support_format_all (a);\n\tarchive_read_open (a, load_data, load_data_open, load_data_read, load_data_close);\n\twhile ((r = archive_read_next_header (a, &entry)) == ARCHIVE_OK) {\n\t\tconst char    *pathname;\n\t\tchar          *fullpath;\n\t\tGFile         *file;\n\t\tGFile         *parent;\n\t\tGOutputStream *ostream;\n\t\tconst void    *buffer;\n\t\tsize_t         buffer_size;\n\t\tint64_t        offset;\n\t\tGError        *local_error = NULL;\n\t\t__LA_MODE_T    filetype;\n\n\t\tif (g_cancellable_is_cancelled (cancellable))\n\t\t\tbreak;\n\n\t\tpathname = archive_entry_pathname (entry);\n\t\tif (! extract_data_get_extraction_requested (extract_data, pathname)) {\n\t\t\tarchive_read_data_skip (a);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfullpath = (*pathname == '\/') ? g_strdup (pathname) : g_strconcat (\"\/\", pathname, NULL);\n\t\tfile = g_file_get_child (extract_data->destination, _g_path_get_relative_basename (fullpath, extract_data->base_dir, extract_data->junk_paths));\n\n\t\t\/* honor the skip_older and overwrite options *\/\n\n\t\tif (extract_data->skip_older || ! extract_data->overwrite) {\n\t\t\tGFileInfo *info;\n\n\t\t\tinfo = g_file_query_info (file,\n\t\t\t\t\t\t  G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME \",\" G_FILE_ATTRIBUTE_TIME_MODIFIED,\n\t\t\t\t\t\t  G_FILE_QUERY_INFO_NONE,\n\t\t\t\t\t\t  cancellable,\n\t\t\t\t\t\t  &local_error);\n\t\t\tif (info != NULL) {\n\t\t\t\tgboolean skip = FALSE;\n\n\t\t\t\tif (! extract_data->overwrite) {\n\t\t\t\t\tskip = TRUE;\n\t\t\t\t}\n\t\t\t\telse if (extract_data->skip_older) {\n\t\t\t\t\tGTimeVal modification_time;\n\n\t\t\t\t\tg_file_info_get_modification_time (info, &modification_time);\n\t\t\t\t\tif (archive_entry_mtime (entry) < modification_time.tv_sec)\n\t\t\t\t\t\tskip = TRUE;\n\t\t\t\t}\n\n\t\t\t\tg_object_unref (info);\n\n\t\t\t\tif (skip) {\n\t\t\t\t\tg_object_unref (file);\n\n\t\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\t\tfr_archive_progress_inc_completed_bytes (load_data->archive, archive_entry_size_is_set (entry) ? archive_entry_size (entry) : 0);\n\n\t\t\t\t\tif ((extract_data->file_list != NULL) && (--extract_data->n_files_to_extract == 0)) {\n\t\t\t\t\t\tr = ARCHIVE_EOF;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {\n\t\t\t\t\tload_data->error = local_error;\n\t\t\t\t\tg_object_unref (info);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tg_error_free (local_error);\n\t\t\t}\n\t\t}\n\n\t\tfr_archive_progress_inc_completed_files (load_data->archive, 1);\n\n\t\t\/* create the file parents *\/\n\n\t\tparent = g_file_get_parent (file);\n\n\t\tif ((parent != NULL)\n\t\t    && (g_hash_table_lookup (checked_folders, parent) == NULL)\n\t\t    && ! g_file_query_exists (parent, cancellable))\n\t\t{\n\t\t\tif (g_file_make_directory_with_parents (parent, cancellable, &load_data->error)) {\n\t\t\t\tGFile *grandparent;\n\n\t\t\t\tgrandparent = g_object_ref (parent);\n\t\t\t\twhile (grandparent != NULL) {\n\t\t\t\t\tif (g_hash_table_lookup (checked_folders, grandparent) == NULL)\n\t\t\t\t\t\tg_hash_table_insert (checked_folders, grandparent, GINT_TO_POINTER (1));\n\t\t\t\t\tgrandparent = g_file_get_parent (grandparent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tg_object_unref (parent);\n\n\t\t\/* create the file *\/\n\n\t\tfiletype = archive_entry_filetype (entry);\n\n\t\tif (load_data->error == NULL) {\n\t\t\tconst char  *linkname;\n\n\t\t\tlinkname = archive_entry_hardlink (entry);\n\t\t\tif (linkname != NULL) {\n\t\t\t\tchar  *link_fullpath;\n\t\t\t\tGFile *link_file;\n\t\t\t\tchar  *oldname;\n\t\t\t\tchar  *newname;\n\t\t\t\tint    r;\n\n\t\t\t\tlink_fullpath = (*linkname == '\/') ? g_strdup (linkname) : g_strconcat (\"\/\", linkname, NULL);\n\t\t\t\tlink_file = g_file_get_child (extract_data->destination, _g_path_get_relative_basename (link_fullpath, extract_data->base_dir, extract_data->junk_paths));\n\t\t\t\toldname = g_file_get_path (link_file);\n\t\t\t\tnewname = g_file_get_path (file);\n\n\t\t\t\tif ((oldname != NULL) && (newname != NULL))\n\t\t\t\t\tr = link (oldname, newname);\n\t\t\t\telse\n\t\t\t\t\tr = -1;\n\n\t\t\t\tif (r == 0) {\n\t\t\t\t\t__LA_INT64_T filesize;\n\n\t\t\t\t\tif (archive_entry_size_is_set (entry))\n\t\t\t\t\t\tfilesize = archive_entry_size (entry);\n\t\t\t\t\telse\n\t\t\t\t\t\tfilesize = -1;\n\n\t\t\t\t\tif (filesize > 0)\n\t\t\t\t\t\tfiletype = AE_IFREG; \/* treat as a regular file to save the data *\/\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tchar *uri;\n\t\t\t\t\tchar *msg;\n\n\t\t\t\t\turi = g_file_get_uri (file);\n\t\t\t\t\tmsg = g_strdup_printf (\"Could not create the hard link %s\", uri);\n\t\t\t\t\tload_data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, msg);\n\n\t\t\t\t\tg_free (msg);\n\t\t\t\t\tg_free (uri);\n\t\t\t\t}\n\n\t\t\t\tg_free (newname);\n\t\t\t\tg_free (oldname);\n\t\t\t\tg_object_unref (link_file);\n\t\t\t\tg_free (link_fullpath);\n\t\t\t}\n\t\t}\n\n\t\tif (load_data->error == NULL) {\n\t\t\tswitch (filetype) {\n\t\t\tcase AE_IFDIR:\n\t\t\t\tif (! g_file_make_directory (file, cancellable, &local_error)) {\n\t\t\t\t\tif (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))\n\t\t\t\t\t\tload_data->error = g_error_copy (local_error);\n\t\t\t\t\tg_error_free (local_error);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t_g_file_set_attributes_from_entry (file, entry, extract_data, cancellable);\n\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\tbreak;\n\n\t\t\tcase AE_IFREG:\n\t\t\t\tostream = (GOutputStream *) g_file_replace (file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, cancellable, &load_data->error);\n\t\t\t\tif (ostream == NULL)\n\t\t\t\t\tbreak;\n\n\t\t\t\twhile ((r = archive_read_data_block (a, &buffer, &buffer_size, &offset)) == ARCHIVE_OK) {\n\t\t\t\t\tif (g_output_stream_write (ostream, buffer, buffer_size, cancellable, &load_data->error) == -1)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tfr_archive_progress_inc_completed_bytes (load_data->archive, buffer_size);\n\t\t\t\t}\n\t\t\t\t_g_object_unref (ostream);\n\n\t\t\t\tif (r != ARCHIVE_EOF)\n\t\t\t\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));\n\t\t\t\telse\n\t\t\t\t\t_g_file_set_attributes_from_entry (file, entry, extract_data, cancellable);\n\t\t\t\tbreak;\n\n\t\t\tcase AE_IFLNK:\n\t\t\t\tif (! g_file_make_symbolic_link (file, archive_entry_symlink (entry), cancellable, &local_error)) {\n\t\t\t\t\tif (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))\n\t\t\t\t\t\tload_data->error = g_error_copy (local_error);\n\t\t\t\t\tg_error_free (local_error);\n\t\t\t\t}\n\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tarchive_read_data_skip (a);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tg_object_unref (file);\n\t\tg_free (fullpath);\n\n\t\tif (load_data->error != NULL)\n\t\t\tbreak;\n\n\t\tif ((extract_data->file_list != NULL) && (--extract_data->n_files_to_extract == 0)) {\n\t\t\tr = ARCHIVE_EOF;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ((load_data->error == NULL) && (r != ARCHIVE_EOF))\n\t\tload_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));\n\tif (load_data->error == NULL)\n\t\tg_cancellable_set_error_if_cancelled (cancellable, &load_data->error);\n\tif (load_data->error != NULL)\n\t\tg_simple_async_result_set_from_error (result, load_data->error);\n\n\tg_hash_table_unref (checked_folders);\n\tarchive_read_free (a);\n\textract_data_free (extract_data);\n}","target":1,"code_token_length":1939,"total_token_length":2175,"max_tokens_setting":4096}
+{"idx":338060,"func":"BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) {\n  if (pos == endOfFunction) {\n    throwError(\"Reached function end without seeing End opcode\");\n  }\n  BYN_TRACE(\"zz recurse into \" << ++depth << \" at \" << pos << std::endl);\n  readNextDebugLocation();\n  std::set<Function::DebugLocation> currDebugLocation;\n  if (debugLocation.size()) {\n    currDebugLocation.insert(*debugLocation.begin());\n  }\n  size_t startPos = pos;\n  uint8_t code = getInt8();\n  BYN_TRACE(\"readExpression seeing \" << (int)code << std::endl);\n  switch (code) {\n    case BinaryConsts::Block:\n      visitBlock((curr = allocator.alloc<Block>())->cast<Block>());\n      break;\n    case BinaryConsts::If:\n      visitIf((curr = allocator.alloc<If>())->cast<If>());\n      break;\n    case BinaryConsts::Loop:\n      visitLoop((curr = allocator.alloc<Loop>())->cast<Loop>());\n      break;\n    case BinaryConsts::Br:\n    case BinaryConsts::BrIf:\n      visitBreak((curr = allocator.alloc<Break>())->cast<Break>(), code);\n      break; \/\/ code distinguishes br from br_if\n    case BinaryConsts::BrTable:\n      visitSwitch((curr = allocator.alloc<Switch>())->cast<Switch>());\n      break;\n    case BinaryConsts::CallFunction:\n      visitCall((curr = allocator.alloc<Call>())->cast<Call>());\n      break;\n    case BinaryConsts::CallIndirect:\n      visitCallIndirect(\n        (curr = allocator.alloc<CallIndirect>())->cast<CallIndirect>());\n      break;\n    case BinaryConsts::RetCallFunction: {\n      auto call = allocator.alloc<Call>();\n      call->isReturn = true;\n      curr = call;\n      visitCall(call);\n      break;\n    }\n    case BinaryConsts::RetCallIndirect: {\n      auto call = allocator.alloc<CallIndirect>();\n      call->isReturn = true;\n      curr = call;\n      visitCallIndirect(call);\n      break;\n    }\n    case BinaryConsts::LocalGet:\n      visitLocalGet((curr = allocator.alloc<LocalGet>())->cast<LocalGet>());\n      break;\n    case BinaryConsts::LocalTee:\n    case BinaryConsts::LocalSet:\n      visitLocalSet((curr = allocator.alloc<LocalSet>())->cast<LocalSet>(),\n                    code);\n      break;\n    case BinaryConsts::GlobalGet:\n      visitGlobalGet((curr = allocator.alloc<GlobalGet>())->cast<GlobalGet>());\n      break;\n    case BinaryConsts::GlobalSet:\n      visitGlobalSet((curr = allocator.alloc<GlobalSet>())->cast<GlobalSet>());\n      break;\n    case BinaryConsts::Select:\n    case BinaryConsts::SelectWithType:\n      visitSelect((curr = allocator.alloc<Select>())->cast<Select>(), code);\n      break;\n    case BinaryConsts::Return:\n      visitReturn((curr = allocator.alloc<Return>())->cast<Return>());\n      break;\n    case BinaryConsts::Nop:\n      visitNop((curr = allocator.alloc<Nop>())->cast<Nop>());\n      break;\n    case BinaryConsts::Unreachable:\n      visitUnreachable(\n        (curr = allocator.alloc<Unreachable>())->cast<Unreachable>());\n      break;\n    case BinaryConsts::Drop:\n      visitDrop((curr = allocator.alloc<Drop>())->cast<Drop>());\n      break;\n    case BinaryConsts::End:\n      curr = nullptr;\n      \/\/ Pop the current control flow structure off the stack. If there is none\n      \/\/ then this is the \"end\" of the function itself, which also emits an\n      \/\/ \"end\" byte.\n      if (!controlFlowStack.empty()) {\n        controlFlowStack.pop_back();\n      }\n      break;\n    case BinaryConsts::Else:\n    case BinaryConsts::Catch:\n    case BinaryConsts::CatchAll: {\n      curr = nullptr;\n      if (DWARF && currFunction) {\n        assert(!controlFlowStack.empty());\n        auto currControlFlow = controlFlowStack.back();\n        BinaryLocation delimiterId;\n        if (currControlFlow->is<If>()) {\n          delimiterId = BinaryLocations::Else;\n        } else {\n          \/\/ Both Catch and CatchAll can simply append to the list as we go, as\n          \/\/ we visit them in the right order in the binary, and like the binary\n          \/\/ we store the CatchAll at the end.\n          delimiterId =\n            currFunction->delimiterLocations[currControlFlow].size();\n        }\n        currFunction->delimiterLocations[currControlFlow][delimiterId] =\n          startPos - codeSectionLocation;\n      }\n      break;\n    }\n    case BinaryConsts::Delegate: {\n      curr = nullptr;\n      if (DWARF && currFunction) {\n        assert(!controlFlowStack.empty());\n        controlFlowStack.pop_back();\n      }\n      break;\n    }\n    case BinaryConsts::RefNull:\n      visitRefNull((curr = allocator.alloc<RefNull>())->cast<RefNull>());\n      break;\n    case BinaryConsts::RefIsNull:\n      visitRefIs((curr = allocator.alloc<RefIs>())->cast<RefIs>(), code);\n      break;\n    case BinaryConsts::RefFunc:\n      visitRefFunc((curr = allocator.alloc<RefFunc>())->cast<RefFunc>());\n      break;\n    case BinaryConsts::RefEq:\n      visitRefEq((curr = allocator.alloc<RefEq>())->cast<RefEq>());\n      break;\n    case BinaryConsts::RefAsNonNull:\n      visitRefAs((curr = allocator.alloc<RefAs>())->cast<RefAs>(), code);\n      break;\n    case BinaryConsts::BrOnNull:\n      maybeVisitBrOn(curr, code);\n      break;\n    case BinaryConsts::BrOnNonNull:\n      maybeVisitBrOn(curr, code);\n      break;\n    case BinaryConsts::TableGet:\n      visitTableGet((curr = allocator.alloc<TableGet>())->cast<TableGet>());\n      break;\n    case BinaryConsts::TableSet:\n      visitTableSet((curr = allocator.alloc<TableSet>())->cast<TableSet>());\n      break;\n    case BinaryConsts::Try:\n      visitTryOrTryInBlock(curr);\n      break;\n    case BinaryConsts::Throw:\n      visitThrow((curr = allocator.alloc<Throw>())->cast<Throw>());\n      break;\n    case BinaryConsts::Rethrow:\n      visitRethrow((curr = allocator.alloc<Rethrow>())->cast<Rethrow>());\n      break;\n    case BinaryConsts::MemorySize: {\n      auto size = allocator.alloc<MemorySize>();\n      if (wasm.memory.is64()) {\n        size->make64();\n      }\n      curr = size;\n      visitMemorySize(size);\n      break;\n    }\n    case BinaryConsts::MemoryGrow: {\n      auto grow = allocator.alloc<MemoryGrow>();\n      if (wasm.memory.is64()) {\n        grow->make64();\n      }\n      curr = grow;\n      visitMemoryGrow(grow);\n      break;\n    }\n    case BinaryConsts::CallRef:\n      visitCallRef((curr = allocator.alloc<CallRef>())->cast<CallRef>());\n      break;\n    case BinaryConsts::RetCallRef: {\n      auto call = allocator.alloc<CallRef>();\n      call->isReturn = true;\n      curr = call;\n      visitCallRef(call);\n      break;\n    }\n    case BinaryConsts::Let: {\n      visitLet((curr = allocator.alloc<Block>())->cast<Block>());\n      break;\n    }\n    case BinaryConsts::AtomicPrefix: {\n      code = static_cast<uint8_t>(getU32LEB());\n      if (maybeVisitLoad(curr, code, \/*isAtomic=*\/true)) {\n        break;\n      }\n      if (maybeVisitStore(curr, code, \/*isAtomic=*\/true)) {\n        break;\n      }\n      if (maybeVisitAtomicRMW(curr, code)) {\n        break;\n      }\n      if (maybeVisitAtomicCmpxchg(curr, code)) {\n        break;\n      }\n      if (maybeVisitAtomicWait(curr, code)) {\n        break;\n      }\n      if (maybeVisitAtomicNotify(curr, code)) {\n        break;\n      }\n      if (maybeVisitAtomicFence(curr, code)) {\n        break;\n      }\n      throwError(\"invalid code after atomic prefix: \" + std::to_string(code));\n      break;\n    }\n    case BinaryConsts::MiscPrefix: {\n      auto opcode = getU32LEB();\n      if (maybeVisitTruncSat(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitMemoryInit(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitDataDrop(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitMemoryCopy(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitMemoryFill(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitTableSize(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitTableGrow(curr, opcode)) {\n        break;\n      }\n      throwError(\"invalid code after misc prefix: \" + std::to_string(opcode));\n      break;\n    }\n    case BinaryConsts::SIMDPrefix: {\n      auto opcode = getU32LEB();\n      if (maybeVisitSIMDBinary(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDUnary(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDConst(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDStore(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDExtract(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDReplace(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDShuffle(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDTernary(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDShift(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDLoad(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitSIMDLoadStoreLane(curr, opcode)) {\n        break;\n      }\n      throwError(\"invalid code after SIMD prefix: \" + std::to_string(opcode));\n      break;\n    }\n    case BinaryConsts::GCPrefix: {\n      auto opcode = getU32LEB();\n      if (maybeVisitI31New(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitI31Get(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitRefTest(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitRefCast(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitBrOn(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitRttCanon(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitRttSub(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitStructNew(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitStructGet(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitStructSet(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitArrayNew(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitArrayInit(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitArrayGet(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitArraySet(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitArrayLen(curr, opcode)) {\n        break;\n      }\n      if (maybeVisitArrayCopy(curr, opcode)) {\n        break;\n      }\n      if (opcode == BinaryConsts::RefIsFunc ||\n          opcode == BinaryConsts::RefIsData ||\n          opcode == BinaryConsts::RefIsI31) {\n        visitRefIs((curr = allocator.alloc<RefIs>())->cast<RefIs>(), opcode);\n        break;\n      }\n      if (opcode == BinaryConsts::RefAsFunc ||\n          opcode == BinaryConsts::RefAsData ||\n          opcode == BinaryConsts::RefAsI31) {\n        visitRefAs((curr = allocator.alloc<RefAs>())->cast<RefAs>(), opcode);\n        break;\n      }\n      throwError(\"invalid code after GC prefix: \" + std::to_string(opcode));\n      break;\n    }\n    default: {\n      \/\/ otherwise, the code is a subcode TODO: optimize\n      if (maybeVisitBinary(curr, code)) {\n        break;\n      }\n      if (maybeVisitUnary(curr, code)) {\n        break;\n      }\n      if (maybeVisitConst(curr, code)) {\n        break;\n      }\n      if (maybeVisitLoad(curr, code, \/*isAtomic=*\/false)) {\n        break;\n      }\n      if (maybeVisitStore(curr, code, \/*isAtomic=*\/false)) {\n        break;\n      }\n      throwError(\"bad node code \" + std::to_string(code));\n      break;\n    }\n  }\n  if (curr) {\n    if (currDebugLocation.size()) {\n      requireFunctionContext(\"debugLocation\");\n      currFunction->debugLocations[curr] = *currDebugLocation.begin();\n    }\n    if (DWARF && currFunction) {\n      currFunction->expressionLocations[curr] =\n        BinaryLocations::Span{BinaryLocation(startPos - codeSectionLocation),\n                              BinaryLocation(pos - codeSectionLocation)};\n    }\n  }\n  BYN_TRACE(\"zz recurse from \" << depth-- << \" at \" << pos << std::endl);\n  return BinaryConsts::ASTNodes(code);\n}","target":0,"code_token_length":2911,"total_token_length":3147,"max_tokens_setting":4096}
+{"idx":234181,"func":"display_gdb_index (struct dwarf_section *section,\n\t\t   void *file ATTRIBUTE_UNUSED)\n{\n  unsigned char *start = section->start;\n  uint32_t version;\n  uint32_t cu_list_offset, tu_list_offset;\n  uint32_t address_table_offset, symbol_table_offset, constant_pool_offset;\n  unsigned int cu_list_elements, tu_list_elements;\n  unsigned int address_table_elements, symbol_table_slots;\n  unsigned char *cu_list, *tu_list;\n  unsigned char *address_table, *symbol_table, *constant_pool;\n  unsigned int i;\n\n  \/* The documentation for the format of this file is in gdb\/dwarf2read.c.  *\/\n\n  introduce (section, false);\n\n  if (section->size < 6 * sizeof (uint32_t))\n    {\n      warn (_(\"Truncated header in the %s section.\\n\"), section->name);\n      return 0;\n    }\n\n  version = byte_get_little_endian (start, 4);\n  printf (_(\"Version %ld\\n\"), (long) version);\n\n  \/* Prior versions are obsolete, and future versions may not be\n     backwards compatible.  *\/\n  if (version < 3 || version > 8)\n    {\n      warn (_(\"Unsupported version %lu.\\n\"), (unsigned long) version);\n      return 0;\n    }\n  if (version < 4)\n    warn (_(\"The address table data in version 3 may be wrong.\\n\"));\n  if (version < 5)\n    warn (_(\"Version 4 does not support case insensitive lookups.\\n\"));\n  if (version < 6)\n    warn (_(\"Version 5 does not include inlined functions.\\n\"));\n  if (version < 7)\n      warn (_(\"Version 6 does not include symbol attributes.\\n\"));\n  \/* Version 7 indices generated by Gold have bad type unit references,\n     PR binutils\/15021.  But we don't know if the index was generated by\n     Gold or not, so to avoid worrying users with gdb-generated indices\n     we say nothing for version 7 here.  *\/\n\n  cu_list_offset = byte_get_little_endian (start + 4, 4);\n  tu_list_offset = byte_get_little_endian (start + 8, 4);\n  address_table_offset = byte_get_little_endian (start + 12, 4);\n  symbol_table_offset = byte_get_little_endian (start + 16, 4);\n  constant_pool_offset = byte_get_little_endian (start + 20, 4);\n\n  if (cu_list_offset > section->size\n      || tu_list_offset > section->size\n      || address_table_offset > section->size\n      || symbol_table_offset > section->size\n      || constant_pool_offset > section->size\n      || tu_list_offset < cu_list_offset\n      || address_table_offset < tu_list_offset\n      || symbol_table_offset < address_table_offset\n      || constant_pool_offset < symbol_table_offset)\n    {\n      warn (_(\"Corrupt header in the %s section.\\n\"), section->name);\n      return 0;\n    }\n\n  cu_list_elements = (tu_list_offset - cu_list_offset) \/ 16;\n  tu_list_elements = (address_table_offset - tu_list_offset) \/ 24;\n  address_table_elements = (symbol_table_offset - address_table_offset) \/ 20;\n  symbol_table_slots = (constant_pool_offset - symbol_table_offset) \/ 8;\n\n  cu_list = start + cu_list_offset;\n  tu_list = start + tu_list_offset;\n  address_table = start + address_table_offset;\n  symbol_table = start + symbol_table_offset;\n  constant_pool = start + constant_pool_offset;\n\n  printf (_(\"\\nCU table:\\n\"));\n  for (i = 0; i < cu_list_elements; i++)\n    {\n      uint64_t cu_offset = byte_get_little_endian (cu_list + i * 16, 8);\n      uint64_t cu_length = byte_get_little_endian (cu_list + i * 16 + 8, 8);\n\n      printf (_(\"[%3u] 0x%lx - 0x%lx\\n\"), i,\n\t      (unsigned long) cu_offset,\n\t      (unsigned long) (cu_offset + cu_length - 1));\n    }\n\n  printf (_(\"\\nTU table:\\n\"));\n  for (i = 0; i < tu_list_elements; i++)\n    {\n      uint64_t tu_offset = byte_get_little_endian (tu_list + i * 24, 8);\n      uint64_t type_offset = byte_get_little_endian (tu_list + i * 24 + 8, 8);\n      uint64_t signature = byte_get_little_endian (tu_list + i * 24 + 16, 8);\n\n      printf (_(\"[%3u] 0x%lx 0x%lx \"), i,\n\t      (unsigned long) tu_offset,\n\t      (unsigned long) type_offset);\n      print_dwarf_vma (signature, 8);\n      printf (\"\\n\");\n    }\n\n  printf (_(\"\\nAddress table:\\n\"));\n  for (i = 0; i < address_table_elements; i++)\n    {\n      uint64_t low = byte_get_little_endian (address_table + i * 20, 8);\n      uint64_t high = byte_get_little_endian (address_table + i * 20 + 8, 8);\n      uint32_t cu_index = byte_get_little_endian (address_table + i + 20 + 16, 4);\n\n      print_dwarf_vma (low, 8);\n      print_dwarf_vma (high, 8);\n      printf (_(\"%lu\\n\"), (unsigned long) cu_index);\n    }\n\n  printf (_(\"\\nSymbol table:\\n\"));\n  for (i = 0; i < symbol_table_slots; ++i)\n    {\n      uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4);\n      uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4);\n      uint32_t num_cus, cu;\n\n      if (name_offset != 0\n\t  || cu_vector_offset != 0)\n\t{\n\t  unsigned int j;\n\n\t  \/* PR 17531: file: 5b7b07ad.  *\/\n\t  if (name_offset >= section->size - constant_pool_offset)\n\t    {\n\t      printf (_(\"[%3u] <corrupt offset: %x>\"), i, name_offset);\n\t      warn (_(\"Corrupt name offset of 0x%x found for symbol table slot %d\\n\"),\n\t\t    name_offset, i);\n\t    }\n\t  else\n\t    printf (\"[%3u] %.*s:\", i,\n\t\t    (int) (section->size - (constant_pool_offset + name_offset)),\n\t\t    constant_pool + name_offset);\n\n\t  if (section->size - constant_pool_offset < 4\n\t      || cu_vector_offset > section->size - constant_pool_offset - 4)\n\t    {\n\t      printf (_(\"<invalid CU vector offset: %x>\\n\"), cu_vector_offset);\n\t      warn (_(\"Corrupt CU vector offset of 0x%x found for symbol table slot %d\\n\"),\n\t\t    cu_vector_offset, i);\n\t      continue;\n\t    }\n\n\t  num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4);\n\n\t  if ((uint64_t) num_cus * 4 > section->size - (constant_pool_offset\n\t\t\t\t\t\t\t+ cu_vector_offset + 4))\n\t    {\n\t      printf (\"<invalid number of CUs: %d>\\n\", num_cus);\n\t      warn (_(\"Invalid number of CUs (0x%x) for symbol table slot %d\\n\"),\n\t\t    num_cus, i);\n\t      continue;\n\t    }\n\n\t  if (num_cus > 1)\n\t    printf (\"\\n\");\n\n\t  for (j = 0; j < num_cus; ++j)\n\t    {\n\t      int is_static;\n\t      gdb_index_symbol_kind kind;\n\n\t      cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4);\n\t      is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu);\n\t      kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu);\n\t      cu = GDB_INDEX_CU_VALUE (cu);\n\t      \/* Convert to TU number if it's for a type unit.  *\/\n\t      if (cu >= cu_list_elements \/ 2)\n\t\tprintf (\"%cT%lu\", num_cus > 1 ? '\\t' : ' ',\n\t\t\t(unsigned long) (cu - cu_list_elements \/ 2));\n\t      else\n\t\tprintf (\"%c%lu\", num_cus > 1 ? '\\t' : ' ', (unsigned long) cu);\n\n\t      printf (\" [%s, %s]\",\n\t\t      is_static ? _(\"static\") : _(\"global\"),\n\t\t      get_gdb_index_symbol_kind_name (kind));\n\t      if (num_cus > 1)\n\t\tprintf (\"\\n\");\n\t    }\n\t  if (num_cus <= 1)\n\t    printf (\"\\n\");\n\t}\n    }\n\n  return 1;\n}","target":0,"code_token_length":1953,"total_token_length":2189,"max_tokens_setting":4096}
+{"idx":386538,"func":"bool DL_Dxf::checkVariable(const char* var, DL_Codes::version version) {\n    if (version>=DL_VERSION_2000) {\n        return true;\n    } else if (version==DL_VERSION_R12) {\n        \/\/ these are all the variables recognized by dxf r12:\n        if (!strcmp(var, \"$ACADVER\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ACADVER\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ANGBASE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ANGDIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ATTDIA\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ATTMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ATTREQ\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$AUNITS\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$AUPREC\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$AXISMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$AXISUNIT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$BLIPMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$CECOLOR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$CELTYPE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$CHAMFERA\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$CHAMFERB\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$CLAYER\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$COORDS\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMALT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMALTD\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMALTF\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMAPOST\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMASO\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMASZ\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMBLK\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMBLK1\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMBLK2\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMCEN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMCLRD\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMCLRE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMCLRT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMDLE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMDLI\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMEXE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMEXO\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMGAP\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMLFAC\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMLIM\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMPOST\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMRND\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSAH\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSCALE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSE1\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSE2\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSHO\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSOXD\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMSTYLE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTAD\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTFAC\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTIH\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTIX\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTM\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTOFL\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTOH\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTOL\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTP\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTSZ\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTVP\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMTXT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DIMZIN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DWGCODEPAGE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$DRAGMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ELEVATION\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$EXTMAX\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$EXTMIN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$FILLETRAD\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$FILLMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$HANDLING\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$HANDSEED\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$INSBASE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$LIMCHECK\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$LIMMAX\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$LIMMIN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$LTSCALE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$LUNITS\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$LUPREC\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$MAXACTVP\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$MENU\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$MIRRTEXT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$ORTHOMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$OSMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PDMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PDSIZE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PELEVATION\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PEXTMAX\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PEXTMIN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PLIMCHECK\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PLIMMAX\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PLIMMIN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PLINEGEN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PLINEWID\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PSLTSCALE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PUCSNAME\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PUCSORG\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PUCSXDIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$PUCSYDIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$QTEXTMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$REGENMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SHADEDGE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SHADEDIF\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SKETCHINC\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SKPOLY\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SPLFRAME\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SPLINESEGS\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SPLINETYPE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SURFTAB1\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SURFTAB2\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SURFTYPE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SURFU\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SURFV\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TDCREATE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TDINDWG\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TDUPDATE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TDUSRTIMER\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TEXTSIZE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TEXTSTYLE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$THICKNESS\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TILEMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$TRACEWID\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$UCSNAME\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$UCSORG\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$UCSXDIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$UCSYDIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$UNITMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$USERI1\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$USERR1\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$USRTIMER\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$VISRETAIN\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$WORLDVIEW\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$FASTZOOM\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$GRIDMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$GRIDUNIT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SNAPANG\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SNAPBASE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SNAPISOPAIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SNAPMODE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SNAPSTYLE\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$SNAPUNIT\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$VIEWCTR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$VIEWDIR\")) {\n            return true;\n        }\n        if (!strcmp(var, \"$VIEWSIZE\")) {\n            return true;\n        }\n        return false;\n    }\n\n    return false;\n}","target":0,"code_token_length":2603,"total_token_length":2839,"max_tokens_setting":4096}
+{"idx":353170,"func":"void SplashOutputDev::doUpdateFont(GfxState *state) {\n  GfxFont *gfxFont;\n  GfxFontLoc *fontLoc;\n  GfxFontType fontType;\n  SplashOutFontFileID *id = nullptr;\n  SplashFontFile *fontFile;\n  SplashFontSrc *fontsrc = nullptr;\n  FoFiTrueType *ff;\n  GooString *fileName;\n  char *tmpBuf;\n  int tmpBufLen;\n  int *codeToGID;\n  const double *textMat;\n  double m11, m12, m21, m22, fontSize;\n  int faceIndex = 0;\n  SplashCoord mat[4];\n  int n, i;\n  bool recreateFont = false;\n  bool doAdjustFontMatrix = false;\n\n  needFontUpdate = false;\n  font = nullptr;\n  fileName = nullptr;\n  tmpBuf = nullptr;\n  fontLoc = nullptr;\n\n  if (!(gfxFont = state->getFont())) {\n    goto err1;\n  }\n  fontType = gfxFont->getType();\n  if (fontType == fontType3) {\n    goto err1;\n  }\n\n  \/\/ sanity-check the font size - skip anything larger than 10 inches\n  \/\/ (this avoids problems allocating memory for the font cache)\n  if (state->getTransformedFontSize()\n        > 10 * (state->getHDPI() + state->getVDPI())) {\n    goto err1;\n  }\n\n  \/\/ check the font file cache\nreload:\n  delete id;\n  delete fontLoc;\n  fontLoc = nullptr;\n  if (fontsrc && !fontsrc->isFile) {\n      fontsrc->unref();\n      fontsrc = nullptr;\n  }\n\n  id = new SplashOutFontFileID(gfxFont->getID());\n  if ((fontFile = fontEngine->getFontFile(id))) {\n    delete id;\n\n  } else {\n\n    if (!(fontLoc = gfxFont->locateFont((xref) ? xref : doc->getXRef(), nullptr))) {\n      error(errSyntaxError, -1, \"Couldn't find a font for '{0:s}'\",\n\t    gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                       : \"(unnamed)\");\n      goto err2;\n    }\n\n    \/\/ embedded font\n    if (fontLoc->locType == gfxFontLocEmbedded) {\n      \/\/ if there is an embedded font, read it to memory\n      tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : doc->getXRef(), &tmpBufLen);\n      if (! tmpBuf)\n\tgoto err2;\n\n    \/\/ external font\n    } else { \/\/ gfxFontLocExternal\n      fileName = fontLoc->path;\n      fontType = fontLoc->fontType;\n      doAdjustFontMatrix = true;\n    }\n\n    fontsrc = new SplashFontSrc;\n    if (fileName)\n      fontsrc->setFile(fileName, false);\n    else\n      fontsrc->setBuf(tmpBuf, tmpBufLen, true);\n\n    \/\/ load the font file\n    switch (fontType) {\n    case fontType1:\n      if (!(fontFile = fontEngine->loadType1Font(\n\t\t\t   id,\n\t\t\t   fontsrc,\n\t\t\t   (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    case fontType1C:\n      if (!(fontFile = fontEngine->loadType1CFont(\n\t\t\t   id,\n\t\t\t   fontsrc,\n\t\t\t   (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    case fontType1COT:\n      if (!(fontFile = fontEngine->loadOpenTypeT1CFont(\n\t\t\t   id,\n\t\t\t   fontsrc,\n\t\t\t   (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    case fontTrueType:\n    case fontTrueTypeOT:\n\tif (fileName)\n\t ff = FoFiTrueType::load(fileName->c_str());\n\telse\n\tff = FoFiTrueType::make(tmpBuf, tmpBufLen);\n      if (ff) {\n\tcodeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);\n\tn = 256;\n\tdelete ff;\n\t\/\/ if we're substituting for a non-TrueType font, we need to mark\n\t\/\/ all notdef codes as \"do not draw\" (rather than drawing TrueType\n\t\/\/ notdef glyphs)\n\tif (gfxFont->getType() != fontTrueType &&\n\t    gfxFont->getType() != fontTrueTypeOT) {\n\t  for (i = 0; i < 256; ++i) {\n\t    if (codeToGID[i] == 0) {\n\t      codeToGID[i] = -1;\n\t    }\n\t  }\n\t}\n      } else {\n\tcodeToGID = nullptr;\n\tn = 0;\n      }\n      if (!(fontFile = fontEngine->loadTrueTypeFont(\n\t\t\t   id,\n\t\t\t   fontsrc,\n\t\t\t   codeToGID, n))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    case fontCIDType0:\n    case fontCIDType0C:\n      if (!(fontFile = fontEngine->loadCIDFont(\n\t\t\t   id,\n\t\t\t   fontsrc))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    case fontCIDType0COT:\n      if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {\n\tn = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();\n\tcodeToGID = (int *)gmallocn(n, sizeof(int));\n\tmemcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),\n\t       n * sizeof(int));\n      } else {\n\tcodeToGID = nullptr;\n\tn = 0;\n      }\n      if (!(fontFile = fontEngine->loadOpenTypeCFFFont(\n\t\t\t   id,\n\t\t\t   fontsrc,\n                           codeToGID, n))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    case fontCIDType2:\n    case fontCIDType2OT:\n      codeToGID = nullptr;\n      n = 0;\n      if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {\n\tn = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();\n\tif (n) {\n\t  codeToGID = (int *)gmallocn(n, sizeof(int));\n\t  memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),\n\t\t  n * sizeof(int));\n\t}\n      } else {\n\tif (fileName)\n\t  ff = FoFiTrueType::load(fileName->c_str());\n\telse\n\t  ff = FoFiTrueType::make(tmpBuf, tmpBufLen);\n\tif (! ff)\n\t{\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\t  goto err2;\n\t}\n\tcodeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);\n\tdelete ff;\n      }\n      if (!(fontFile = fontEngine->loadTrueTypeFont(\n\t\t\t   id,\n\t\t\t   fontsrc,\n\t\t\t   codeToGID, n, faceIndex))) {\n\terror(errSyntaxError, -1, \"Couldn't create a font for '{0:s}'\",\n\t      gfxFont->getName() ? gfxFont->getName()->c_str()\n\t                         : \"(unnamed)\");\n\tif (gfxFont->invalidateEmbeddedFont()) goto reload;\n\tgoto err2;\n      }\n      break;\n    default:\n      \/\/ this shouldn't happen\n      goto err2;\n    }\n    fontFile->doAdjustMatrix = doAdjustFontMatrix;\n  }\n\n  \/\/ get the font matrix\n  textMat = state->getTextMat();\n  fontSize = state->getFontSize();\n  m11 = textMat[0] * fontSize * state->getHorizScaling();\n  m12 = textMat[1] * fontSize * state->getHorizScaling();\n  m21 = textMat[2] * fontSize;\n  m22 = textMat[3] * fontSize;\n\n  \/\/ create the scaled font\n  mat[0] = m11;  mat[1] = m12;\n  mat[2] = m21;  mat[3] = m22;\n  font = fontEngine->getFont(fontFile, mat, splash->getMatrix());\n\n  \/\/ for substituted fonts: adjust the font matrix -- compare the\n  \/\/ width of 'm' in the original font and the substituted font\n  if (fontFile->doAdjustMatrix && !gfxFont->isCIDFont()) {\n    double w1, w2, w3;\n    CharCode code;\n    const char *name;\n    for (code = 0; code < 256; ++code) {\n      if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) &&\n          name[0] == 'm' && name[1] == '\\0') {\n        break;\n      }\n    }\n    if (code < 256) {\n      w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code);\n      w2 = font->getGlyphAdvance(code);\n      w3 = ((Gfx8BitFont *)gfxFont)->getWidth(0);\n      if (!gfxFont->isSymbolic() && w2 > 0 && w1 > w3) {\n        \/\/ if real font is substantially narrower than substituted\n        \/\/ font, reduce the font size accordingly\n        if (w1 > 0.01 && w1 < 0.9 * w2) {\n          w1 \/= w2;\n          m11 *= w1;\n          m21 *= w1;\n          recreateFont = true;\n        }\n      }\n    }\n  }\n\n  if (recreateFont)\n  {\n    mat[0] = m11;  mat[1] = m12;\n    mat[2] = m21;  mat[3] = m22;\n    font = fontEngine->getFont(fontFile, mat, splash->getMatrix());\n  }\n\n  delete fontLoc;\n  if (fontsrc && !fontsrc->isFile)\n      fontsrc->unref();\n  return;\n\n err2:\n  delete id;\n  delete fontLoc;\n err1:\n  if (fontsrc && !fontsrc->isFile)\n      fontsrc->unref();\n  return;\n}","target":0,"code_token_length":2563,"total_token_length":2799,"max_tokens_setting":4096}
+{"idx":196801,"func":"GF_Err gf_hinter_finalize(GF_ISOFile *file, GF_SDP_IODProfile IOD_Profile, u32 bandwidth)\n{\n\tu32 i, sceneT, odT, descIndex, size, size64;\n\tGF_InitialObjectDescriptor *iod;\n\tGF_SLConfig slc;\n\tGF_ISOSample *samp;\n\tBool remove_ocr;\n\tu8 *buffer;\n\tchar buf64[5000], sdpLine[5100];\n\n\n\tgf_isom_sdp_clean(file);\n\n\tif (bandwidth) {\n\t\tsprintf(buf64, \"b=AS:%d\", bandwidth);\n\t\tgf_isom_sdp_add_line(file, buf64);\n\t}\n    \/\/xtended attribute for copyright\n    if (gf_sys_is_test_mode()) {\n        sprintf(buf64, \"a=x-copyright: %s\", \"MP4\/3GP File hinted with GPAC - (c) Telecom ParisTech (http:\/\/gpac.io)\");\n    } else {\n        sprintf(buf64, \"a=x-copyright: MP4\/3GP File hinted with GPAC %s - %s\", gf_gpac_version(), gf_gpac_copyright() );\n    }\n\tgf_isom_sdp_add_line(file, buf64);\n\n\tif (IOD_Profile == GF_SDP_IOD_NONE) return GF_OK;\n\n\todT = sceneT = 0;\n\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\tif (!gf_isom_is_track_in_root_od(file, i+1)) continue;\n\t\tswitch (gf_isom_get_media_type(file,i+1)) {\n\t\tcase GF_ISOM_MEDIA_OD:\n\t\t\todT = i+1;\n\t\t\tbreak;\n\t\tcase GF_ISOM_MEDIA_SCENE:\n\t\t\tsceneT = i+1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tremove_ocr = 0;\n\tif (IOD_Profile == GF_SDP_IOD_ISMA_STRICT) {\n\t\tIOD_Profile = GF_SDP_IOD_ISMA;\n\t\tremove_ocr = 1;\n\t}\n\n\t\/*if we want ISMA like iods, we need at least BIFS *\/\n\tif ( (IOD_Profile == GF_SDP_IOD_ISMA) && !sceneT ) return GF_BAD_PARAM;\n\n\t\/*do NOT change PLs, we assume they are correct*\/\n\tiod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);\n\tif (!iod) return GF_NOT_SUPPORTED;\n\n\t\/*rewrite an IOD with good SL config - embbed data if possible*\/\n\tif (IOD_Profile == GF_SDP_IOD_ISMA) {\n\t\tGF_ESD *esd;\n\t\tBool is_ok = 1;\n\t\twhile (gf_list_count(iod->ESDescriptors)) {\n\t\t\tesd = (GF_ESD*)gf_list_get(iod->ESDescriptors, 0);\n\t\t\tgf_odf_desc_del((GF_Descriptor *) esd);\n\t\t\tgf_list_rem(iod->ESDescriptors, 0);\n\t\t}\n\n\n\t\t\/*get OD esd, and embbed stream data if possible*\/\n\t\tif (odT) {\n\t\t\tesd = gf_isom_get_esd(file, odT, 1);\n\t\t\tif (gf_isom_get_sample_count(file, odT)==1) {\n\t\t\t\tsamp = gf_isom_get_sample(file, odT, 1, &descIndex);\n\t\t\t\tif (samp && gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_OD)) {\n\t\t\t\t\tInitSL_NULL(&slc);\n\t\t\t\t\tslc.predefined = 0;\n\t\t\t\t\tslc.hasRandomAccessUnitsOnlyFlag = 1;\n\t\t\t\t\tslc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, odT);\n\t\t\t\t\tslc.OCRResolution = 1000;\n\t\t\t\t\tslc.startCTS = samp->DTS+samp->CTS_Offset;\n\t\t\t\t\tslc.startDTS = samp->DTS;\n\t\t\t\t\t\/\/set the SL for future extraction\n\t\t\t\t\tgf_isom_set_extraction_slc(file, odT, 1, &slc);\n\n\t\t\t\t\tsize64 = gf_base64_encode(samp->data, samp->dataLength, buf64, 2000);\n\t\t\t\t\tbuf64[size64] = 0;\n\t\t\t\t\tsprintf(sdpLine, \"data:application\/mpeg4-od-au;base64,%s\", buf64);\n\n\t\t\t\t\tif (esd->decoderConfig) {\n\t\t\t\t\t\tesd->decoderConfig->avgBitrate = 0;\n\t\t\t\t\t\tesd->decoderConfig->bufferSizeDB = samp->dataLength;\n\t\t\t\t\t\tesd->decoderConfig->maxBitrate = 0;\n\t\t\t\t\t}\n\t\t\t\t\tsize64 = (u32) strlen(sdpLine)+1;\n\t\t\t\t\tesd->URLString = (char*)gf_malloc(sizeof(char) * size64);\n\t\t\t\t\tstrcpy(esd->URLString, sdpLine);\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_RTP, (\"[rtp hinter] OD sample too large to be embedded in IOD - ISMA disabled\\n\"));\n\t\t\t\t\tis_ok = 0;\n\t\t\t\t}\n\t\t\t\tgf_isom_sample_del(&samp);\n\t\t\t}\n\t\t\tif (remove_ocr) esd->OCRESID = 0;\n\t\t\telse if (esd->OCRESID == esd->ESID) esd->OCRESID = 0;\n\n\t\t\t\/\/OK, add this to our IOD\n\t\t\tgf_list_add(iod->ESDescriptors, esd);\n\t\t}\n\n\t\tesd = gf_isom_get_esd(file, sceneT, 1);\n\t\tif (gf_isom_get_sample_count(file, sceneT)==1) {\n\t\t\tsamp = gf_isom_get_sample(file, sceneT, 1, &descIndex);\n\t\t\tif (samp && gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_SCENE)) {\n\n\t\t\t\tslc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, sceneT);\n\t\t\t\tslc.OCRResolution = 1000;\n\t\t\t\tslc.startCTS = samp->DTS+samp->CTS_Offset;\n\t\t\t\tslc.startDTS = samp->DTS;\n\t\t\t\t\/\/set the SL for future extraction\n\t\t\t\tgf_isom_set_extraction_slc(file, sceneT, 1, &slc);\n\t\t\t\t\/\/encode in Base64 the sample\n\t\t\t\tsize64 = gf_base64_encode(samp->data, samp->dataLength, buf64, 2000);\n\t\t\t\tbuf64[size64] = 0;\n\t\t\t\tsprintf(sdpLine, \"data:application\/mpeg4-bifs-au;base64,%s\", buf64);\n\n\t\t\t\tif (esd->decoderConfig) {\n\t\t\t\t\tesd->decoderConfig->avgBitrate = 0;\n\t\t\t\t\tesd->decoderConfig->bufferSizeDB = samp->dataLength;\n\t\t\t\t\tesd->decoderConfig->maxBitrate = 0;\n\t\t\t\t}\n\t\t\t\tesd->URLString = (char*)gf_malloc(sizeof(char) * (strlen(sdpLine)+1));\n\t\t\t\tstrcpy(esd->URLString, sdpLine);\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_RTP, (\"[rtp hinter] Scene description sample too large to be embedded in IOD - ISMA disabled\\n\"));\n\t\t\t\tis_ok = 0;\n\t\t\t}\n\t\t\tgf_isom_sample_del(&samp);\n\t\t}\n\t\tif (remove_ocr) esd->OCRESID = 0;\n\t\telse if (esd->OCRESID == esd->ESID) esd->OCRESID = 0;\n\n\t\tgf_list_add(iod->ESDescriptors, esd);\n\n\t\tif (is_ok) {\n\t\t\tu32 has_a, has_v, has_i_a, has_i_v;\n\t\t\thas_a = has_v = has_i_a = has_i_v = 0;\n\t\t\tfor (i=0; i<gf_isom_get_track_count(file); i++) {\n\t\t\t\tesd = gf_isom_get_esd(file, i+1, 1);\n\t\t\t\tif (!esd) continue;\n\t\t\t\tif (esd->decoderConfig) {\n\t\t\t\t\tif (esd->decoderConfig->streamType==GF_STREAM_VISUAL) {\n\t\t\t\t\t\tif (esd->decoderConfig->objectTypeIndication==GF_CODECID_MPEG4_PART2) has_i_v ++;\n\t\t\t\t\t\telse has_v++;\n\t\t\t\t\t} else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) {\n\t\t\t\t\t\tif (esd->decoderConfig->objectTypeIndication==GF_CODECID_AAC_MPEG4) has_i_a ++;\n\t\t\t\t\t\telse has_a++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgf_odf_desc_del((GF_Descriptor *)esd);\n\t\t\t}\n\t\t\t\/*only 1 MPEG-4 visual max and 1 MPEG-4 audio max for ISMA compliancy*\/\n\t\t\tif (!has_v && !has_a && (has_i_v<=1) && (has_i_a<=1)) {\n\t\t\t\tsprintf(sdpLine, \"a=isma-compliance:1,1.0,1\");\n\t\t\t\tgf_isom_sdp_add_line(file, sdpLine);\n\t\t\t}\n\t\t}\n\t}\n\n\t\/\/encode the IOD\n\tbuffer = NULL;\n\tsize = 0;\n\tgf_odf_desc_write((GF_Descriptor *) iod, &buffer, &size);\n\tgf_odf_desc_del((GF_Descriptor *)iod);\n\n\t\/\/encode in Base64 the iod\n\tsize64 = gf_base64_encode(buffer, size, buf64, 2000);\n\tbuf64[size64] = 0;\n\tgf_free(buffer);\n\n\tsprintf(sdpLine, \"a=mpeg4-iod:\\\"data:application\/mpeg4-iod;base64,%s\\\"\", buf64);\n\tgf_isom_sdp_add_line(file, sdpLine);\n\n\treturn GF_OK;\n}","target":1,"code_token_length":2117,"total_token_length":2353,"max_tokens_setting":4096}
+{"idx":200113,"func":"static Image *ReadMATImageV4(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  typedef struct {\n    unsigned char Type[4];\n    unsigned int nRows;\n    unsigned int nCols;\n    unsigned int imagf;\n    unsigned int nameLen;\n  } MAT4_HDR;\n\n  long\n    ldblk;\n\n  EndianType\n    endian;\n\n  Image\n    *rotated_image;\n\n  MagickBooleanType\n    status;\n\n  MAT4_HDR\n    HDR;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumFormatType\n    format_type;\n\n  register ssize_t\n    i;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  unsigned int\n    depth;\n\n\n  quantum_info=(QuantumInfo *) NULL;\n  (void) SeekBlob(image,0,SEEK_SET);\n  while (EOFBlob(image) == MagickFalse)\n  {\n    \/*\n     Object parser loop.\n    *\/\n    ldblk=ReadBlobLSBLong(image);\n    if ((ldblk > 9999) || (ldblk < 0))\n      break;\n    HDR.Type[3]=ldblk % 10; ldblk \/= 10;  \/* T digit *\/\n    HDR.Type[2]=ldblk % 10; ldblk \/= 10;  \/* P digit *\/\n    HDR.Type[1]=ldblk % 10; ldblk \/= 10;  \/* O digit *\/\n    HDR.Type[0]=ldblk;        \/* M digit *\/\n    if (HDR.Type[3] != 0)\n      break;  \/* Data format *\/\n    if (HDR.Type[2] != 0)\n      break;  \/* Always 0 *\/\n    if (HDR.Type[0] == 0)\n      {\n        HDR.nRows=ReadBlobLSBLong(image);\n        HDR.nCols=ReadBlobLSBLong(image);\n        HDR.imagf=ReadBlobLSBLong(image);\n        HDR.nameLen=ReadBlobLSBLong(image);\n        endian=LSBEndian;\n      }\n    else\n      {\n        HDR.nRows=ReadBlobMSBLong(image);\n        HDR.nCols=ReadBlobMSBLong(image);\n        HDR.imagf=ReadBlobMSBLong(image);\n        HDR.nameLen=ReadBlobMSBLong(image);\n        endian=MSBEndian;\n      }\n    if ((HDR.imagf != 0) && (HDR.imagf != 1))\n      break;\n    if (HDR.nameLen > 0xFFFF)\n      return(DestroyImageList(image));\n    for (i=0; i < (ssize_t) HDR.nameLen; i++)\n    {\n      int\n        byte;\n\n      \/*\n        Skip matrix name.\n      *\/\n      byte=ReadBlobByte(image);\n      if (byte == EOF)\n        {\n          ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n            image->filename);\n          break;\n        }\n    }\n    image->columns=(size_t) HDR.nRows;\n    image->rows=(size_t) HDR.nCols;\n    if ((image->columns == 0) || (image->rows == 0))\n      return(DestroyImageList(image));\n    if (image_info->ping != MagickFalse)\n      {\n        Swap(image->columns,image->rows);\n        if(HDR.imagf==1) ldblk *= 2;\n        SeekBlob(image, HDR.nCols*ldblk, SEEK_CUR);\n        if ((image->columns == 0) || (image->rows == 0))\n          return(image->previous == (Image *) NULL ? DestroyImageList(image)\n            : image);\n        goto skip_reading_current;\n      }\n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      return(DestroyImageList(image));\n    (void) SetImageBackgroundColor(image,exception);\n    (void) SetImageColorspace(image,GRAYColorspace,exception);\n    quantum_info=AcquireQuantumInfo(image_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      return(DestroyImageList(image));\n    switch(HDR.Type[1])\n    {\n      case 0:\n        format_type=FloatingPointQuantumFormat;\n        depth=64;\n        break;\n      case 1:\n        format_type=FloatingPointQuantumFormat;\n        depth=32;\n        break;\n      case 2:\n        format_type=UnsignedQuantumFormat;\n        depth=16;\n        break;\n      case 3:\n        format_type=SignedQuantumFormat;\n        depth=16;\n        break;\n      case 4:\n        format_type=UnsignedQuantumFormat;\n        depth=8;\n        break;\n      default:\n        format_type=UnsignedQuantumFormat;\n        depth=8;\n        break;\n    }\n    image->depth=depth;\n    if (HDR.Type[0] != 0)\n      SetQuantumEndian(image,quantum_info,MSBEndian);\n    status=SetQuantumFormat(image,quantum_info,format_type);\n    status=SetQuantumDepth(image,quantum_info,depth);\n    status=SetQuantumEndian(image,quantum_info,endian);\n    SetQuantumScale(quantum_info,1.0);\n    pixels=(unsigned char *) GetQuantumPixels(quantum_info);\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      register Quantum\n        *magick_restrict q;\n\n      count=ReadBlob(image,depth\/8*image->columns,(char *) pixels);\n      if (count == -1)\n        break;\n      q=QueueAuthenticPixels(image,0,image->rows-y-1,image->columns,1,\n        exception);\n      if (q == (Quantum *) NULL)\n        break;\n      (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n        GrayQuantum,pixels,exception);\n      if ((HDR.Type[1] == 2) || (HDR.Type[1] == 3))\n        FixSignedValues(image,q,(int) image->columns);\n      if (SyncAuthenticPixels(image,exception) == MagickFalse)\n        break;\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    if (HDR.imagf == 1)\n      for (y=0; y < (ssize_t) image->rows; y++)\n      {\n        \/*\n          Read complex pixels.\n        *\/\n        count=ReadBlob(image,depth\/8*image->columns,(char *) pixels);\n        if (count == -1)\n          break;\n        if (HDR.Type[1] == 0)\n          InsertComplexDoubleRow(image,(double *) pixels,y,0,0,exception);\n        else\n          InsertComplexFloatRow(image,(float *) pixels,y,0,0,exception);\n      }\n    if (quantum_info != (QuantumInfo *) NULL)\n      quantum_info=DestroyQuantumInfo(quantum_info);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    rotated_image=RotateImage(image,90.0,exception);\n    if (rotated_image != (Image *) NULL)\n      {\n        rotated_image->page.x=0;\n        rotated_image->page.y=0;\n        rotated_image->colors = image->colors;\n        DestroyBlob(rotated_image);\n        rotated_image->blob=ReferenceBlob(image->blob);\n        AppendImageToList(&image,rotated_image);\n        DeleteImageFromList(&image);\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    \/*\n      Allocate next image structure.\n    *\/\nskip_reading_current:\n    AcquireNextImage(image_info,image,exception);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      {\n        status=MagickFalse;\n        break;\n      }\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n      GetBlobSize(image));\n    if (status == MagickFalse)\n      break;\n  }\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":1829,"total_token_length":2065,"max_tokens_setting":4096}
+{"idx":199833,"func":"gif_internal_decode_frame(gif_animation *gif,\n                          unsigned int frame,\n                          bool clear_image)\n{\n        unsigned int index = 0;\n        const unsigned char *gif_data, *gif_end;\n        ssize_t gif_bytes;\n        unsigned int width, height, offset_x, offset_y;\n        unsigned int flags, colour_table_size, interlace;\n        unsigned int *colour_table;\n        unsigned int *frame_data = 0;\t\/\/ Set to 0 for no warnings\n        unsigned int *frame_scanline;\n        ssize_t save_buffer_position;\n        unsigned int return_value = 0;\n        unsigned int x, y, decode_y, burst_bytes;\n        register unsigned char colour;\n\n        \/* Ensure this frame is supposed to be decoded *\/\n        if (gif->frames[frame].display == false) {\n                return GIF_OK;\n        }\n\n        \/* Ensure the frame is in range to decode *\/\n        if (frame > gif->frame_count_partial) {\n                return GIF_INSUFFICIENT_DATA;\n        }\n\n        \/* done if frame is already decoded *\/\n        if ((!clear_image) &&\n            ((int)frame == gif->decoded_frame)) {\n                return GIF_OK;\n        }\n\n        \/* Get the start of our frame data and the end of the GIF data *\/\n        gif_data = gif->gif_data + gif->frames[frame].frame_pointer;\n        gif_end = gif->gif_data + gif->buffer_size;\n        gif_bytes = (gif_end - gif_data);\n\n        \/*\n         * Ensure there is a minimal amount of data to proceed.  The shortest\n         * block of data is a 10-byte image descriptor + 1-byte gif trailer\n         *\/\n        if (gif_bytes < 12) {\n                return GIF_INSUFFICIENT_FRAME_DATA;\n        }\n\n        \/* Save the buffer position *\/\n        save_buffer_position = gif->buffer_position;\n        gif->buffer_position = gif_data - gif->gif_data;\n\n        \/* Skip any extensions because they have allready been processed *\/\n        if ((return_value = gif_skip_frame_extensions(gif)) != GIF_OK) {\n                goto gif_decode_frame_exit;\n        }\n        gif_data = (gif->gif_data + gif->buffer_position);\n        gif_bytes = (gif_end - gif_data);\n\n        \/* Ensure we have enough data for the 10-byte image descriptor + 1-byte\n         * gif trailer\n         *\/\n        if (gif_bytes < 12) {\n                return_value = GIF_INSUFFICIENT_FRAME_DATA;\n                goto gif_decode_frame_exit;\n        }\n\n        \/* 10-byte Image Descriptor is:\n         *\n         *\t+0\tCHAR\tImage Separator (0x2c)\n         *\t+1\tSHORT\tImage Left Position\n         *\t+3\tSHORT\tImage Top Position\n         *\t+5\tSHORT\tWidth\n         *\t+7\tSHORT\tHeight\n         *\t+9\tCHAR\t__Packed Fields__\n         *\t\t\t1BIT\tLocal Colour Table Flag\n         *\t\t\t1BIT\tInterlace Flag\n         *\t\t\t1BIT\tSort Flag\n         *\t\t\t2BITS\tReserved\n         *\t\t\t3BITS\tSize of Local Colour Table\n         *\/\n        if (gif_data[0] != GIF_IMAGE_SEPARATOR) {\n                return_value = GIF_DATA_ERROR;\n                goto gif_decode_frame_exit;\n        }\n        offset_x = gif_data[1] | (gif_data[2] << 8);\n        offset_y = gif_data[3] | (gif_data[4] << 8);\n        width = gif_data[5] | (gif_data[6] << 8);\n        height = gif_data[7] | (gif_data[8] << 8);\n\n        \/* Boundary checking - shouldn't ever happen except unless the data has\n         * been modified since initialisation.\n         *\/\n        if ((offset_x + width > gif->width) ||\n            (offset_y + height > gif->height)) {\n                return_value = GIF_DATA_ERROR;\n                goto gif_decode_frame_exit;\n        }\n\n        \/* Decode the flags *\/\n        flags = gif_data[9];\n        colour_table_size = 2 << (flags & GIF_COLOUR_TABLE_SIZE_MASK);\n        interlace = flags & GIF_INTERLACE_MASK;\n\n        \/* Advance data pointer to next block either colour table or image\n         * data.\n         *\/\n        gif_data += 10;\n        gif_bytes = (gif_end - gif_data);\n\n        \/* Set up the colour table *\/\n        if (flags & GIF_COLOUR_TABLE_MASK) {\n                if (gif_bytes < (int)(3 * colour_table_size)) {\n                        return_value = GIF_INSUFFICIENT_FRAME_DATA;\n                        goto gif_decode_frame_exit;\n                }\n                colour_table = gif->local_colour_table;\n                if (!clear_image) {\n                        for (index = 0; index < colour_table_size; index++) {\n                                \/* Gif colour map contents are r,g,b.\n                                 *\n                                 * We want to pack them bytewise into the\n                                 * colour table, such that the red component\n                                 * is in byte 0 and the alpha component is in\n                                 * byte 3.\n                                 *\/\n                                unsigned char *entry =\n                                        (unsigned char *) &colour_table[index];\n\n                                entry[0] = gif_data[0];\t\/* r *\/\n                                entry[1] = gif_data[1];\t\/* g *\/\n                                entry[2] = gif_data[2];\t\/* b *\/\n                                entry[3] = 0xff;\t\/* a *\/\n\n                                gif_data += 3;\n                        }\n                } else {\n                        gif_data += 3 * colour_table_size;\n                }\n                gif_bytes = (gif_end - gif_data);\n        } else {\n                colour_table = gif->global_colour_table;\n        }\n\n        \/* Ensure sufficient data remains *\/\n        if (gif_bytes < 1) {\n                return_value = GIF_INSUFFICIENT_FRAME_DATA;\n                goto gif_decode_frame_exit;\n        }\n\n        \/* check for an end marker *\/\n        if (gif_data[0] == GIF_TRAILER) {\n                return_value = GIF_OK;\n                goto gif_decode_frame_exit;\n        }\n\n        \/* Get the frame data *\/\n        assert(gif->bitmap_callbacks.bitmap_get_buffer);\n        frame_data = (void *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);\n        if (!frame_data) {\n                return GIF_INSUFFICIENT_MEMORY;\n        }\n\n        \/* If we are clearing the image we just clear, if not decode *\/\n        if (!clear_image) {\n                lzw_result res;\n                const uint8_t *stack_base;\n                const uint8_t *stack_pos;\n\n                \/* Ensure we have enough data for a 1-byte LZW code size +\n                 * 1-byte gif trailer\n                 *\/\n                if (gif_bytes < 2) {\n                        return_value = GIF_INSUFFICIENT_FRAME_DATA;\n                        goto gif_decode_frame_exit;\n                }\n\n                \/* If we only have a 1-byte LZW code size + 1-byte gif trailer,\n                 * we're finished\n                 *\/\n                if ((gif_bytes == 2) && (gif_data[1] == GIF_TRAILER)) {\n                        return_value = GIF_OK;\n                        goto gif_decode_frame_exit;\n                }\n\n                \/* If the previous frame's disposal method requires we restore\n                 * the background colour or this is the first frame, clear\n                 * the frame data\n                 *\/\n                if ((frame == 0) || (gif->decoded_frame == GIF_INVALID_FRAME)) {\n                        memset((char*)frame_data,\n                               GIF_TRANSPARENT_COLOUR,\n                               gif->width * gif->height * sizeof(int));\n                        gif->decoded_frame = frame;\n                        \/* The line below would fill the image with its\n                         * background color, but because GIFs support\n                         * transparency we likely wouldn't want to do that. *\/\n                        \/* memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int)); *\/\n                } else if ((frame != 0) &&\n                           (gif->frames[frame - 1].disposal_method == GIF_FRAME_CLEAR)) {\n                        return_value = gif_internal_decode_frame(gif,\n                                                                 (frame - 1),\n                                                                 true);\n                        if (return_value != GIF_OK) {\n                                goto gif_decode_frame_exit;\n                        }\n\n                } else if ((frame != 0) &&\n                           (gif->frames[frame - 1].disposal_method == GIF_FRAME_RESTORE)) {\n                        \/*\n                         * If the previous frame's disposal method requires we\n                         * restore the previous image, find the last image set\n                         * to \"do not dispose\" and get that frame data\n                         *\/\n                        int last_undisposed_frame = frame - 2;\n                        while ((last_undisposed_frame >= 0) &&\n                               (gif->frames[last_undisposed_frame].disposal_method == GIF_FRAME_RESTORE)) {\n                                last_undisposed_frame--;\n                        }\n\n                        \/* If we don't find one, clear the frame data *\/\n                        if (last_undisposed_frame == -1) {\n                                \/* see notes above on transparency\n                                 * vs. background color\n                                 *\/\n                                memset((char*)frame_data,\n                                       GIF_TRANSPARENT_COLOUR,\n                                       gif->width * gif->height * sizeof(int));\n                        } else {\n                                return_value = gif_internal_decode_frame(gif, last_undisposed_frame, false);\n                                if (return_value != GIF_OK) {\n                                        goto gif_decode_frame_exit;\n                                }\n                                \/* Get this frame's data *\/\n                                assert(gif->bitmap_callbacks.bitmap_get_buffer);\n                                frame_data = (void *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);\n                                if (!frame_data) {\n                                        return GIF_INSUFFICIENT_MEMORY;\n                                }\n                        }\n                }\n                gif->decoded_frame = frame;\n                gif->buffer_position = (gif_data - gif->gif_data) + 1;\n\n                \/* Initialise the LZW decoding *\/\n                res = lzw_decode_init(gif->lzw_ctx, gif->gif_data,\n                                gif->buffer_size, gif->buffer_position,\n                                gif_data[0], &stack_base, &stack_pos);\n                if (res != LZW_OK) {\n                        return gif_error_from_lzw(res);\n                }\n\n                \/* Decompress the data *\/\n                for (y = 0; y < height; y++) {\n                        if (interlace) {\n                                decode_y = gif_interlaced_line(height, y) + offset_y;\n                        } else {\n                                decode_y = y + offset_y;\n                        }\n                        frame_scanline = frame_data + offset_x + (decode_y * gif->width);\n\n                        \/* Rather than decoding pixel by pixel, we try to burst\n                         * out streams of data to remove the need for end-of\n                         * data checks every pixel.\n                         *\/\n                        x = width;\n                        while (x > 0) {\n                                burst_bytes = (stack_pos - stack_base);\n                                if (burst_bytes > 0) {\n                                        if (burst_bytes > x) {\n                                                burst_bytes = x;\n                                        }\n                                        x -= burst_bytes;\n                                        while (burst_bytes-- > 0) {\n                                                colour = *--stack_pos;\n                                                if (((gif->frames[frame].transparency) &&\n                                                     (colour != gif->frames[frame].transparency_index)) ||\n                                                    (!gif->frames[frame].transparency)) {\n                                                        *frame_scanline = colour_table[colour];\n                                                }\n                                                frame_scanline++;\n                                        }\n                                } else {\n                                        res = lzw_decode(gif->lzw_ctx, &stack_pos);\n                                        if (res != LZW_OK) {\n                                                \/* Unexpected end of frame, try to recover *\/\n                                                if (res == LZW_OK_EOD) {\n                                                        return_value = GIF_OK;\n                                                } else {\n                                                        return_value = gif_error_from_lzw(res);\n                                                }\n                                                goto gif_decode_frame_exit;\n                                        }\n                                }\n                        }\n                }\n        } else {\n                \/* Clear our frame *\/\n                if (gif->frames[frame].disposal_method == GIF_FRAME_CLEAR) {\n                        for (y = 0; y < height; y++) {\n                                frame_scanline = frame_data + offset_x + ((offset_y + y) * gif->width);\n                                if (gif->frames[frame].transparency) {\n                                        memset(frame_scanline,\n                                               GIF_TRANSPARENT_COLOUR,\n                                               width * 4);\n                                } else {\n                                        memset(frame_scanline,\n                                               colour_table[gif->background_index],\n                                               width * 4);\n                                }\n                        }\n                }\n        }\ngif_decode_frame_exit:\n\n        \/* Check if we should test for optimisation *\/\n        if (gif->frames[frame].virgin) {\n                if (gif->bitmap_callbacks.bitmap_test_opaque) {\n                        gif->frames[frame].opaque = gif->bitmap_callbacks.bitmap_test_opaque(gif->frame_image);\n                } else {\n                        gif->frames[frame].opaque = false;\n                }\n                gif->frames[frame].virgin = false;\n        }\n\n        if (gif->bitmap_callbacks.bitmap_set_opaque) {\n                gif->bitmap_callbacks.bitmap_set_opaque(gif->frame_image, gif->frames[frame].opaque);\n        }\n\n        if (gif->bitmap_callbacks.bitmap_modified) {\n                gif->bitmap_callbacks.bitmap_modified(gif->frame_image);\n        }\n\n        \/* Restore the buffer position *\/\n        gif->buffer_position = save_buffer_position;\n\n        return return_value;\n}","target":1,"code_token_length":2776,"total_token_length":3012,"max_tokens_setting":4096}
+{"idx":310196,"func":"main(int argc, char *argv[])\n{\n    char my_tmpname[PATH_MAX];\n    char my_altfile[PATH_MAX];\n    int v_opt = -1;\n    int smart_defaults = TRUE;\n    char *termcap;\n    ENTRY *qp;\n\n    int this_opt, last_opt = '?';\n\n    int outform = F_TERMINFO;\t\/* output format *\/\n    int sortmode = S_TERMINFO;\t\/* sort_mode *\/\n\n    int width = 60;\n    int height = 65535;\n    bool formatted = FALSE;\t\/* reformat complex strings? *\/\n    bool literal = FALSE;\t\/* suppress post-processing? *\/\n    int numbers = 0;\t\t\/* format \"%'char'\" to\/from \"%{number}\" *\/\n    bool forceresolve = FALSE;\t\/* force resolution *\/\n    bool limited = TRUE;\n    char *tversion = (char *) NULL;\n    const char *source_file = \"terminfo\";\n    char *outdir = (char *) NULL;\n    bool check_only = FALSE;\n    bool suppress_untranslatable = FALSE;\n    int quickdump = 0;\n    bool quiet = FALSE;\n    bool wrap_strings = FALSE;\n\n    log_fp = stderr;\n\n    _nc_progname = _nc_rootname(argv[0]);\n    atexit(cleanup);\n\n    if ((infodump = same_program(_nc_progname, PROG_CAPTOINFO)) != FALSE) {\n\toutform = F_TERMINFO;\n\tsortmode = S_TERMINFO;\n    }\n    if ((capdump = same_program(_nc_progname, PROG_INFOTOCAP)) != FALSE) {\n\toutform = F_TERMCAP;\n\tsortmode = S_TERMCAP;\n    }\n#if NCURSES_XNAMES\n    use_extended_names(FALSE);\n#endif\n    _nc_strict_bsd = 0;\n\n    \/*\n     * Processing arguments is a little complicated, since someone made a\n     * design decision to allow the numeric values for -w, -v options to\n     * be optional.\n     *\/\n    while ((this_opt = getopt(argc, argv,\n\t\t\t      \"0123456789CDIKLNQR:TUVWace:fGgo:qrstvwx\")) != -1) {\n\tif (isdigit(this_opt)) {\n\t    switch (last_opt) {\n\t    case 'Q':\n\t\tadd_digit(&quickdump, this_opt);\n\t\tbreak;\n\t    case 'v':\n\t\tadd_digit(&v_opt, this_opt);\n\t\tbreak;\n\t    case 'w':\n\t\tadd_digit(&width, this_opt);\n\t\tbreak;\n\t    default:\n\t\tswitch (this_opt) {\n\t\tcase '0':\n\t\t    last_opt = this_opt;\n\t\t    width = 65535;\n\t\t    height = 1;\n\t\t    break;\n\t\tcase '1':\n\t\t    last_opt = this_opt;\n\t\t    width = 0;\n\t\t    break;\n\t\tdefault:\n\t\t    usage();\n\t\t}\n\t    }\n\t    continue;\n\t}\n\tswitch (this_opt) {\n\tcase 'K':\n\t    _nc_strict_bsd = 1;\n\t    \/* the initial version of -K in 20110730 fell-thru here, but the\n\t     * same flag is useful when reading sources -TD\n\t     *\/\n\t    break;\n\tcase 'C':\n\t    capdump = TRUE;\n\t    outform = F_TERMCAP;\n\t    sortmode = S_TERMCAP;\n\t    break;\n\tcase 'D':\n\t    debug_level = VtoTrace(v_opt);\n\t    set_trace_level(debug_level);\n\t    show_databases(outdir);\n\t    ExitProgram(EXIT_SUCCESS);\n\t    break;\n\tcase 'I':\n\t    infodump = TRUE;\n\t    outform = F_TERMINFO;\n\t    sortmode = S_TERMINFO;\n\t    break;\n\tcase 'L':\n\t    infodump = TRUE;\n\t    outform = F_VARIABLE;\n\t    sortmode = S_VARIABLE;\n\t    break;\n\tcase 'N':\n\t    smart_defaults = FALSE;\n\t    literal = TRUE;\n\t    break;\n\tcase 'Q':\n\t    quickdump = 0;\n\t    break;\n\tcase 'R':\n\t    tversion = optarg;\n\t    break;\n\tcase 'T':\n\t    limited = FALSE;\n\t    break;\n\tcase 'U':\n\t    literal = TRUE;\n\t    break;\n\tcase 'V':\n\t    puts(curses_version());\n\t    ExitProgram(EXIT_SUCCESS);\n\tcase 'W':\n\t    wrap_strings = TRUE;\n\t    break;\n\tcase 'c':\n\t    check_only = TRUE;\n\t    break;\n\tcase 'e':\n\t    namelst = make_namelist(optarg);\n\t    break;\n\tcase 'f':\n\t    formatted = TRUE;\n\t    break;\n\tcase 'G':\n\t    numbers = 1;\n\t    break;\n\tcase 'g':\n\t    numbers = -1;\n\t    break;\n\tcase 'o':\n\t    outdir = optarg;\n\t    break;\n\tcase 'q':\n\t    quiet = TRUE;\n\t    break;\n\tcase 'r':\n\t    forceresolve = TRUE;\n\t    break;\n\tcase 's':\n\t    showsummary = TRUE;\n\t    break;\n\tcase 'v':\n\t    v_opt = 0;\n\t    break;\n\tcase 'w':\n\t    width = 0;\n\t    break;\n#if NCURSES_XNAMES\n\tcase 't':\n\t    _nc_disable_period = FALSE;\n\t    suppress_untranslatable = TRUE;\n\t    break;\n\tcase 'a':\n\t    _nc_disable_period = TRUE;\n\t    \/* FALLTHRU *\/\n\tcase 'x':\n\t    use_extended_names(TRUE);\n\t    using_extensions = TRUE;\n\t    break;\n#endif\n\tdefault:\n\t    usage();\n\t}\n\tlast_opt = this_opt;\n    }\n\n    debug_level = VtoTrace(v_opt);\n    set_trace_level(debug_level);\n\n    if (_nc_tracing) {\n\tsave_check_termtype = _nc_check_termtype2;\n\t_nc_check_termtype2 = check_termtype;\n    }\n#if !HAVE_BIG_CORE\n    \/*\n     * Aaargh! immedhook seriously hoses us!\n     *\n     * One problem with immedhook is it means we can't do -e.  Problem\n     * is that we can't guarantee that for each terminal listed, all the\n     * terminals it depends on will have been kept in core for reference\n     * resolution -- in fact it's certain the primitive types at the end\n     * of reference chains *won't* be in core unless they were explicitly\n     * in the select list themselves.\n     *\/\n    if (namelst && (!infodump && !capdump)) {\n\t(void) fprintf(stderr,\n\t\t       \"%s: Sorry, -e can't be used without -I or -C\\n\",\n\t\t       _nc_progname);\n\tExitProgram(EXIT_FAILURE);\n    }\n#endif \/* HAVE_BIG_CORE *\/\n\n    if (optind < argc) {\n\tsource_file = argv[optind++];\n\tif (optind < argc) {\n\t    fprintf(stderr,\n\t\t    \"%s: Too many file names.  Usage:\\n\\t%s %s\",\n\t\t    _nc_progname,\n\t\t    _nc_progname,\n\t\t    usage_string);\n\t    ExitProgram(EXIT_FAILURE);\n\t}\n    } else {\n\tif (infodump == TRUE) {\n\t    \/* captoinfo's no-argument case *\/\n\t    source_file = \"\/etc\/termcap\";\n\t    if ((termcap = getenv(\"TERMCAP\")) != 0\n\t\t&& (namelst = make_namelist(getenv(\"TERM\"))) != 0) {\n\t\tif (access(termcap, F_OK) == 0) {\n\t\t    \/* file exists *\/\n\t\t    source_file = termcap;\n\t\t} else {\n\t\t    if ((tmp_fp = open_tempfile(my_tmpname)) != 0) {\n\t\t\tsource_file = my_tmpname;\n\t\t\tfprintf(tmp_fp, \"%s\\n\", termcap);\n\t\t\tfclose(tmp_fp);\n\t\t\ttmp_fp = open_input(source_file, (char *) 0);\n\t\t\tto_remove = source_file;\n\t\t    } else {\n\t\t\tfailed(\"tmpnam\");\n\t\t    }\n\t\t}\n\t    }\n\t} else {\n\t    \/* tic *\/\n\t    fprintf(stderr,\n\t\t    \"%s: File name needed.  Usage:\\n\\t%s %s\",\n\t\t    _nc_progname,\n\t\t    _nc_progname,\n\t\t    usage_string);\n\t    ExitProgram(EXIT_FAILURE);\n\t}\n    }\n\n    if (tmp_fp == 0) {\n\ttmp_fp = open_input(source_file, my_altfile);\n\tif (!strcmp(source_file, \"-\")) {\n\t    source_file = STDIN_NAME;\n\t}\n    }\n\n    if (infodump || check_only) {\n\tdump_init(tversion,\n\t\t  (smart_defaults\n\t\t   ? outform\n\t\t   : F_LITERAL),\n\t\t  sortmode,\n\t\t  wrap_strings, width, height,\n\t\t  debug_level, formatted || check_only, check_only, quickdump);\n    } else if (capdump) {\n\tdump_init(tversion,\n\t\t  outform,\n\t\t  sortmode,\n\t\t  wrap_strings, width, height,\n\t\t  debug_level, FALSE, FALSE, FALSE);\n    }\n\n    \/* parse entries out of the source file *\/\n    _nc_set_source(source_file);\n#if !HAVE_BIG_CORE\n    if (!(check_only || infodump || capdump))\n\t_nc_set_writedir(outdir);\n#endif \/* HAVE_BIG_CORE *\/\n    _nc_read_entry_source(tmp_fp, (char *) NULL,\n\t\t\t  !smart_defaults || literal, FALSE,\n\t\t\t  ((check_only || infodump || capdump)\n\t\t\t   ? NULLHOOK\n\t\t\t   : immedhook));\n\n    \/* do use resolution *\/\n    if (check_only || (!infodump && !capdump) || forceresolve) {\n\tif (!_nc_resolve_uses2(TRUE, literal) && !check_only) {\n\t    ExitProgram(EXIT_FAILURE);\n\t}\n    }\n\n    \/* length check *\/\n    if (check_only && limited && (capdump || infodump)) {\n\tfor_entry_list(qp) {\n\t    if (matches(namelst, qp->tterm.term_names)) {\n\t\tint len = fmt_entry(&qp->tterm, NULL, FALSE, TRUE, infodump, numbers);\n\n\t\tif (len > (infodump ? MAX_TERMINFO_LENGTH : MAX_TERMCAP_LENGTH))\n\t\t    (void) fprintf(stderr,\n\t\t\t\t   \"%s: resolved %s entry is %d bytes long\\n\",\n\t\t\t\t   _nc_progname,\n\t\t\t\t   _nc_first_name(qp->tterm.term_names),\n\t\t\t\t   len);\n\t    }\n\t}\n    }\n\n    \/* write or dump all entries *\/\n    if (check_only) {\n\t\/* this is in case infotocap() generates warnings *\/\n\t_nc_curr_col = _nc_curr_line = -1;\n\n\tfor_entry_list(qp) {\n\t    if (matches(namelst, qp->tterm.term_names)) {\n\t\t\/* this is in case infotocap() generates warnings *\/\n\t\t_nc_set_type(_nc_first_name(qp->tterm.term_names));\n\t\t_nc_curr_line = (int) qp->startline;\n\t\trepair_acsc(&qp->tterm);\n\t\tdump_entry(&qp->tterm, suppress_untranslatable,\n\t\t\t   limited, numbers, NULL);\n\t    }\n\t}\n    } else {\n\tif (!infodump && !capdump) {\n\t    _nc_set_writedir(outdir);\n\t    for_entry_list(qp) {\n\t\tif (matches(namelst, qp->tterm.term_names))\n\t\t    write_it(qp);\n\t    }\n\t} else {\n\t    \/* this is in case infotocap() generates warnings *\/\n\t    _nc_curr_col = _nc_curr_line = -1;\n\n\t    for_entry_list(qp) {\n\t\tif (matches(namelst, qp->tterm.term_names)) {\n\t\t    long j = qp->cend - qp->cstart;\n\t\t    int len = 0;\n\n\t\t    \/* this is in case infotocap() generates warnings *\/\n\t\t    _nc_set_type(_nc_first_name(qp->tterm.term_names));\n\n\t\t    if (!quiet) {\n\t\t\t(void) fseek(tmp_fp, qp->cstart, SEEK_SET);\n\t\t\twhile (j-- > 0) {\n\t\t\t    int ch = fgetc(tmp_fp);\n\t\t\t    if (ch == EOF || ferror(tmp_fp)) {\n\t\t\t\tbreak;\n\t\t\t    } else if (infodump) {\n\t\t\t\t(void) putchar(ch);\n\t\t\t    } else {\n\t\t\t\tput_translate(ch);\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\n\t\t    repair_acsc(&qp->tterm);\n\t\t    dump_entry(&qp->tterm, suppress_untranslatable,\n\t\t\t       limited, numbers, NULL);\n\t\t    for (j = 0; j < (long) qp->nuses; j++)\n\t\t\tdump_uses(qp->uses[j].name, !capdump);\n\t\t    len = show_entry();\n\t\t    if (debug_level != 0 && !limited)\n\t\t\tprintf(\"# length=%d\\n\", len);\n\t\t}\n\t    }\n\t    if (!namelst && _nc_tail && !quiet) {\n\t\tint c, oldc = '\\0';\n\t\tbool in_comment = FALSE;\n\t\tbool trailing_comment = FALSE;\n\n\t\t(void) fseek(tmp_fp, _nc_tail->cend, SEEK_SET);\n\t\twhile ((c = fgetc(tmp_fp)) != EOF) {\n\t\t    if (oldc == '\\n') {\n\t\t\tif (c == '#') {\n\t\t\t    trailing_comment = TRUE;\n\t\t\t    in_comment = TRUE;\n\t\t\t} else {\n\t\t\t    in_comment = FALSE;\n\t\t\t}\n\t\t    }\n\t\t    if (trailing_comment\n\t\t\t&& (in_comment || (oldc == '\\n' && c == '\\n')))\n\t\t\tputchar(c);\n\t\t    oldc = c;\n\t\t}\n\t    }\n\t}\n    }\n\n    \/* Show the directory into which entries were written, and the total\n     * number of entries\n     *\/\n    if (showsummary\n\t&& (!(check_only || infodump || capdump))) {\n\tint total = _nc_tic_written();\n\tif (total != 0)\n\t    fprintf(log_fp, \"%d entries written to %s\\n\",\n\t\t    total,\n\t\t    _nc_tic_dir((char *) 0));\n\telse\n\t    fprintf(log_fp, \"No entries written\\n\");\n    }\n    ExitProgram(EXIT_SUCCESS);\n}","target":0,"code_token_length":2897,"total_token_length":3133,"max_tokens_setting":4096}
+{"idx":353124,"func":"bool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str,\n\t\t\t\t\tconst double *ptm, int paintType, int \/*tilingType*\/, Dict *resDict,\n\t\t\t\t\tconst double *mat, const double *bbox,\n\t\t\t\t\tint x0, int y0, int x1, int y1,\n\t\t\t\t\tdouble xStep, double yStep)\n{\n  PDFRectangle box;\n  Gfx *gfx;\n  Splash *formerSplash = splash;\n  SplashBitmap *formerBitmap = bitmap;\n  double width, height;\n  int surface_width, surface_height, result_width, result_height, i;\n  int repeatX, repeatY;\n  SplashCoord matc[6];\n  Matrix m1;\n  const double *ctm;\n  double savedCTM[6];\n  double kx, ky, sx, sy;\n  bool retValue = false;\n\n  width = bbox[2] - bbox[0];\n  height = bbox[3] - bbox[1];\n\n  if (xStep != width || yStep != height)\n    return false;\n\n  \/\/ calculate offsets\n  ctm = state->getCTM();\n  for (i = 0; i < 6; ++i) {\n    savedCTM[i] = ctm[i];\n  }\n  state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);\n  state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]);\n  ctm = state->getCTM();\n  for (i = 0; i < 6; ++i) {\n    if (!std::isfinite(ctm[i])) {\n      state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n      return false;\n    }\n  }\n  matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4];\n  matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5];\n  if (splashAbs(ctm[1]) > splashAbs(ctm[0])) {\n    kx = -ctm[1];\n    ky = ctm[2] - (ctm[0] * ctm[3]) \/ ctm[1];\n  } else {\n    kx = ctm[0];\n    ky = ctm[3] - (ctm[1] * ctm[2]) \/ ctm[0];\n  }\n  result_width = (int) ceil(fabs(kx * width * (x1 - x0)));\n  result_height = (int) ceil(fabs(ky * height * (y1 - y0)));\n  kx = state->getHDPI() \/ 72.0;\n  ky = state->getVDPI() \/ 72.0;\n  m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx;\n  m1.m[1] = 0;\n  m1.m[2] = 0;\n  m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky;\n  m1.m[4] = 0;\n  m1.m[5] = 0;\n  m1.transform(width, height, &kx, &ky);\n  surface_width = (int) ceil (fabs(kx));\n  surface_height = (int) ceil (fabs(ky));\n\n  sx = (double) result_width \/ (surface_width * (x1 - x0));\n  sy = (double) result_height \/ (surface_height * (y1 - y0));\n  m1.m[0] *= sx;\n  m1.m[3] *= sy;\n  m1.transform(width, height, &kx, &ky);\n\n  if(fabs(kx) < 1 && fabs(ky) < 1) {\n    kx = std::min<double>(kx, ky);\n    ky = 2 \/ kx;\n    m1.m[0] *= ky;\n    m1.m[3] *= ky;\n    m1.transform(width, height, &kx, &ky);\n    surface_width = (int) ceil (fabs(kx));\n    surface_height = (int) ceil (fabs(ky));\n    repeatX = x1 - x0;\n    repeatY = y1 - y0;\n  } else {\n    if ((unsigned long) surface_width * surface_height > 0x800000L) {\n      state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n      return false;\n    }\n    while(fabs(kx) > 16384 || fabs(ky) > 16384) {\n      \/\/ limit pattern bitmap size\n      m1.m[0] \/= 2;\n      m1.m[3] \/= 2;\n      m1.transform(width, height, &kx, &ky);\n    }\n    surface_width = (int) ceil (fabs(kx));\n    surface_height = (int) ceil (fabs(ky));\n    \/\/ adjust repeat values to completely fill region\n    if (unlikely(surface_width == 0 || surface_height == 0)) {\n        state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n        return false;\n    }\n    repeatX = result_width \/ surface_width;\n    repeatY = result_height \/ surface_height;\n    if (surface_width * repeatX < result_width)\n      repeatX++;\n    if (surface_height * repeatY < result_height)\n      repeatY++;\n    if (x1 - x0 > repeatX)\n      repeatX = x1 - x0;\n    if (y1 - y0 > repeatY)\n      repeatY = y1 - y0;\n  }\n  \/\/ restore CTM and calculate rotate and scale with rounded matrix\n  state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n  state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);\n  state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]);\n  ctm = state->getCTM();\n  matc[0] = ctm[0];\n  matc[1] = ctm[1];\n  matc[2] = ctm[2];\n  matc[3] = ctm[3];\n\n  if (surface_width == 0 || surface_height == 0 || repeatX * repeatY <= 4) {\n    state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n    return false;\n  }\n  m1.transform(bbox[0], bbox[1], &kx, &ky);\n  m1.m[4] = -kx;\n  m1.m[5] = -ky;\n\n  bitmap = new SplashBitmap(surface_width, surface_height, 1,\n                            (paintType == 1) ? colorMode : splashModeMono8, true);\n  if (bitmap->getDataPtr() == nullptr) {\n    SplashBitmap *tBitmap = bitmap;\n    bitmap = formerBitmap;\n    delete tBitmap;\n    state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n    return false;\n  }\n  splash = new Splash(bitmap, true);\n  if (paintType == 2) {\n    SplashColor clearColor;\n#ifdef SPLASH_CMYK\n    clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF;\n#else\n    clearColor[0] = 0xFF;\n#endif\n    splash->clear(clearColor, 0);\n  } else {\n    splash->clear(paperColor, 0);\n  }\n  splash->setThinLineMode(formerSplash->getThinLineMode());\n  splash->setMinLineWidth(s_minLineWidth);\n\n  box.x1 = bbox[0]; box.y1 = bbox[1];\n  box.x2 = bbox[2]; box.y2 = bbox[3];\n  gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);\n  \/\/ set pattern transformation matrix\n  gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);\n  updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);\n  gfx->display(str);\n  delete splash;\n  splash = formerSplash;\n  TilingSplashOutBitmap imgData;\n  imgData.bitmap = bitmap;\n  imgData.paintType = paintType;\n  imgData.pattern = splash->getFillPattern();\n  imgData.colorMode = colorMode;\n  imgData.y = 0;\n  imgData.repeatX = repeatX;\n  imgData.repeatY = repeatY;\n  SplashBitmap *tBitmap = bitmap;\n  bitmap = formerBitmap;\n  result_width = tBitmap->getWidth() * imgData.repeatX;\n  result_height = tBitmap->getHeight() * imgData.repeatY;\n\n  if (splashAbs(matc[1]) > splashAbs(matc[0])) {\n    kx = -matc[1];\n    ky = matc[2] - (matc[0] * matc[3]) \/ matc[1];\n  } else {\n    kx = matc[0];\n    ky = matc[3] - (matc[1] * matc[2]) \/ matc[0];\n  }\n  kx = result_width \/ (fabs(kx) + 1);\n  ky = result_height \/ (fabs(ky) + 1);\n  state->concatCTM(kx, 0, 0, ky, 0, 0);\n  ctm = state->getCTM();\n  matc[0] = ctm[0];\n  matc[1] = ctm[1];\n  matc[2] = ctm[2];\n  matc[3] = ctm[3];\n  bool minorAxisZero = matc[1] == 0 && matc[2] == 0;\n  if (matc[0] > 0 && minorAxisZero && matc[3] > 0) {\n    \/\/ draw the tiles\n    for (int y = 0; y < imgData.repeatY; ++y) {\n      for (int x = 0; x < imgData.repeatX; ++x) {\n        x0 = splashFloor(matc[4]) + x * tBitmap->getWidth();\n        y0 = splashFloor(matc[5]) + y * tBitmap->getHeight();\n        splash->blitImage(tBitmap, true, x0, y0);\n      }\n    }\n    retValue = true;\n  } else {\n    retValue = splash->drawImage(&tilingBitmapSrc, nullptr, &imgData, colorMode, true, result_width, result_height, matc, false, true) == splashOk;\n  }\n  delete tBitmap;\n  delete gfx;\n  return retValue;\n}","target":0,"code_token_length":2636,"total_token_length":2872,"max_tokens_setting":4096}
+{"idx":224281,"func":"gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)\n{\n    char *pos = inbuf;\n    char *lpos = NULL;\n    char *tline = NULL;\n    LOCAL_ARRAY(char, line, TEMP_BUF_SIZE);\n    char *name = NULL;\n    char *selector = NULL;\n    char *host = NULL;\n    char *port = NULL;\n    char *escaped_selector = NULL;\n    const char *icon_url = NULL;\n    char gtype;\n    StoreEntry *entry = NULL;\n\n    memset(line, '\\0', TEMP_BUF_SIZE);\n\n    entry = gopherState->entry;\n\n    if (gopherState->conversion == GopherStateData::HTML_INDEX_PAGE) {\n        char *html_url = html_quote(entry->url());\n        gopherHTMLHeader(entry, \"Gopher Index %s\", html_url);\n        storeAppendPrintf(entry,\n                          \"<p>This is a searchable Gopher index. Use the search\\n\"\n                          \"function of your browser to enter search terms.\\n\"\n                          \"<ISINDEX>\\n\");\n        gopherHTMLFooter(entry);\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n        gopherState->HTML_header_added = 1;\n\n        return;\n    }\n\n    if (gopherState->conversion == GopherStateData::HTML_CSO_PAGE) {\n        char *html_url = html_quote(entry->url());\n        gopherHTMLHeader(entry, \"CSO Search of %s\", html_url);\n        storeAppendPrintf(entry,\n                          \"<P>A CSO database usually contains a phonebook or\\n\"\n                          \"directory.  Use the search function of your browser to enter\\n\"\n                          \"search terms.<\/P><ISINDEX>\\n\");\n        gopherHTMLFooter(entry);\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n        gopherState->HTML_header_added = 1;\n\n        return;\n    }\n\n    SBuf outbuf;\n\n    if (!gopherState->HTML_header_added) {\n        if (gopherState->conversion == GopherStateData::HTML_CSO_RESULT)\n            gopherHTMLHeader(entry, \"CSO Search Result\", NULL);\n        else\n            gopherHTMLHeader(entry, \"Gopher Menu\", NULL);\n\n        outbuf.append (\"<PRE>\");\n\n        gopherState->HTML_header_added = 1;\n\n        gopherState->HTML_pre = 1;\n    }\n\n    while (pos < inbuf + len) {\n        int llen;\n        int left = len - (pos - inbuf);\n        lpos = (char *)memchr(pos, '\\n', left);\n        if (lpos) {\n            ++lpos;             \/* Next line is after \\n *\/\n            llen = lpos - pos;\n        } else {\n            llen = left;\n        }\n        if (gopherState->len + llen >= TEMP_BUF_SIZE) {\n            debugs(10, DBG_IMPORTANT, \"GopherHTML: Buffer overflow. Lost some data on URL: \" << entry->url()  );\n            llen = TEMP_BUF_SIZE - gopherState->len - 1;\n            gopherState->overflowed = true; \/\/ may already be true\n        }\n        if (!lpos) {\n            \/* there is no complete line in inbuf *\/\n            \/* copy it to temp buffer *\/\n            \/* note: llen is adjusted above *\/\n            memcpy(gopherState->buf + gopherState->len, pos, llen);\n            gopherState->len += llen;\n            break;\n        }\n        if (gopherState->len != 0) {\n            \/* there is something left from last tx. *\/\n            memcpy(line, gopherState->buf, gopherState->len);\n            memcpy(line + gopherState->len, pos, llen);\n            llen += gopherState->len;\n            gopherState->len = 0;\n        } else {\n            memcpy(line, pos, llen);\n        }\n        line[llen + 1] = '\\0';\n        \/* move input to next line *\/\n        pos = lpos;\n\n        \/* at this point. We should have one line in buffer to process *\/\n\n        if (*line == '.') {\n            \/* skip it *\/\n            memset(line, '\\0', TEMP_BUF_SIZE);\n            continue;\n        }\n\n        switch (gopherState->conversion) {\n\n        case GopherStateData::HTML_INDEX_RESULT:\n\n        case GopherStateData::HTML_DIR: {\n            tline = line;\n            gtype = *tline;\n            ++tline;\n            name = tline;\n            selector = strchr(tline, TAB);\n\n            if (selector) {\n                *selector = '\\0';\n                ++selector;\n                host = strchr(selector, TAB);\n\n                if (host) {\n                    *host = '\\0';\n                    ++host;\n                    port = strchr(host, TAB);\n\n                    if (port) {\n                        char *junk;\n                        port[0] = ':';\n                        junk = strchr(host, TAB);\n\n                        if (junk)\n                            *junk++ = 0;    \/* Chop port *\/\n                        else {\n                            junk = strchr(host, '\\r');\n\n                            if (junk)\n                                *junk++ = 0;    \/* Chop port *\/\n                            else {\n                                junk = strchr(host, '\\n');\n\n                                if (junk)\n                                    *junk++ = 0;    \/* Chop port *\/\n                            }\n                        }\n\n                        if ((port[1] == '0') && (!port[2]))\n                            port[0] = 0;    \/* 0 means none *\/\n                    }\n\n                    \/* escape a selector here *\/\n                    escaped_selector = xstrdup(rfc1738_escape_part(selector));\n\n                    switch (gtype) {\n\n                    case GOPHER_DIRECTORY:\n                        icon_url = mimeGetIconURL(\"internal-menu\");\n                        break;\n\n                    case GOPHER_HTML:\n\n                    case GOPHER_FILE:\n                        icon_url = mimeGetIconURL(\"internal-text\");\n                        break;\n\n                    case GOPHER_INDEX:\n\n                    case GOPHER_CSO:\n                        icon_url = mimeGetIconURL(\"internal-index\");\n                        break;\n\n                    case GOPHER_IMAGE:\n\n                    case GOPHER_GIF:\n\n                    case GOPHER_PLUS_IMAGE:\n                        icon_url = mimeGetIconURL(\"internal-image\");\n                        break;\n\n                    case GOPHER_SOUND:\n\n                    case GOPHER_PLUS_SOUND:\n                        icon_url = mimeGetIconURL(\"internal-sound\");\n                        break;\n\n                    case GOPHER_PLUS_MOVIE:\n                        icon_url = mimeGetIconURL(\"internal-movie\");\n                        break;\n\n                    case GOPHER_TELNET:\n\n                    case GOPHER_3270:\n                        icon_url = mimeGetIconURL(\"internal-telnet\");\n                        break;\n\n                    case GOPHER_BIN:\n\n                    case GOPHER_MACBINHEX:\n\n                    case GOPHER_DOSBIN:\n\n                    case GOPHER_UUENCODED:\n                        icon_url = mimeGetIconURL(\"internal-binary\");\n                        break;\n\n                    case GOPHER_INFO:\n                        icon_url = NULL;\n                        break;\n\n                    case GOPHER_WWW:\n                        icon_url = mimeGetIconURL(\"internal-link\");\n                        break;\n\n                    default:\n                        icon_url = mimeGetIconURL(\"internal-unknown\");\n                        break;\n                    }\n\n                    if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {\n                        if (strlen(escaped_selector) != 0)\n                            outbuf.appendf(\"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"telnet:\/\/%s@%s%s%s\/\\\">%s<\/A>\\n\",\n                                     icon_url, escaped_selector, rfc1738_escape_part(host),\n                                     *port ? \":\" : \"\", port, html_quote(name));\n                        else\n                            outbuf.appendf(\"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"telnet:\/\/%s%s%s\/\\\">%s<\/A>\\n\",\n                                     icon_url, rfc1738_escape_part(host), *port ? \":\" : \"\",\n                                     port, html_quote(name));\n\n                    } else if (gtype == GOPHER_INFO) {\n                        outbuf.appendf(\"\\t%s\\n\", html_quote(name));\n                    } else {\n                        if (strncmp(selector, \"GET \/\", 5) == 0) {\n                            \/* WWW link *\/\n                            outbuf.appendf(\"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"http:\/\/%s\/%s\\\">%s<\/A>\\n\",\n                                     icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name));\n                        } else if (gtype == GOPHER_WWW) {\n                            outbuf.appendf(\"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"gopher:\/\/%s\/%c%s\\\">%s<\/A>\\n\",\n                                     icon_url, rfc1738_escape_unescaped(selector), html_quote(name));\n                        } else {\n                            \/* Standard link *\/\n                            outbuf.appendf(\"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"gopher:\/\/%s\/%c%s\\\">%s<\/A>\\n\",\n                                     icon_url, host, gtype, escaped_selector, html_quote(name));\n                        }\n                    }\n\n                    safe_free(escaped_selector);\n                } else {\n                    memset(line, '\\0', TEMP_BUF_SIZE);\n                    continue;\n                }\n            } else {\n                memset(line, '\\0', TEMP_BUF_SIZE);\n                continue;\n            }\n\n            break;\n            }           \/* HTML_DIR, HTML_INDEX_RESULT *\/\n\n        case GopherStateData::HTML_CSO_RESULT: {\n            if (line[0] == '-') {\n                int code, recno;\n                char *s_code, *s_recno, *result;\n\n                s_code = strtok(line + 1, \":\\n\");\n                s_recno = strtok(NULL, \":\\n\");\n                result = strtok(NULL, \"\\n\");\n\n                if (!result)\n                    break;\n\n                code = atoi(s_code);\n\n                recno = atoi(s_recno);\n\n                if (code != 200)\n                    break;\n\n                if (gopherState->cso_recno != recno) {\n                    outbuf.appendf(\"<\/PRE><HR noshade size=\\\"1px\\\"><H2>Record# %d<br><i>%s<\/i><\/H2>\\n<PRE>\", recno, html_quote(result));\n                    gopherState->cso_recno = recno;\n                } else {\n                    outbuf.appendf(\"%s\\n\", html_quote(result));\n                }\n\n                break;\n            } else {\n                int code;\n                char *s_code, *result;\n\n                s_code = strtok(line, \":\");\n                result = strtok(NULL, \"\\n\");\n\n                if (!result)\n                    break;\n\n                code = atoi(s_code);\n\n                switch (code) {\n\n                case 200: {\n                    \/* OK *\/\n                    \/* Do nothing here *\/\n                    break;\n                }\n\n                case 102:   \/* Number of matches *\/\n\n                case 501:   \/* No Match *\/\n\n                case 502: { \/* Too Many Matches *\/\n                    \/* Print the message the server returns *\/\n                    outbuf.appendf(\"<\/PRE><HR noshade size=\\\"1px\\\"><H2>%s<\/H2>\\n<PRE>\", html_quote(result));\n                    break;\n                }\n\n                }\n            }\n\n            break;\n            }           \/* HTML_CSO_RESULT *\/\n        default:\n            break;      \/* do nothing *\/\n\n        }           \/* switch *\/\n\n    }               \/* while loop *\/\n\n    if (outbuf.length() > 0) {\n        entry->append(outbuf.rawContent(), outbuf.length());\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n    }\n\n    return;\n}","target":0,"code_token_length":2434,"total_token_length":2670,"max_tokens_setting":4096}
+{"idx":224235,"func":"R_API bool r_io_bank_update_map_boundaries(RIO *io, const ut32 bankid, const ut32 mapid, ut64 ofrom, ut64 oto) {\n\tRIOBank *bank = r_io_bank_get (io, bankid);\n\tr_return_val_if_fail (io && bank, false);\n\tRListIter *iter;\n\tRIOMapRef *mapref;\n\tr_list_foreach_prev (bank->maprefs, iter, mapref) {\n\t\tif (mapref->id == mapid) {\n\t\t\tgoto found;\n\t\t}\n\t}\n\t\/\/ map is not referenced by this map\n\treturn false;\nfound:\n\t;RIOMap *map = r_io_map_get_by_ref (io, mapref);\n\tif (!map) {\n\t\t\/\/ inconsistent mapref\n\t\t\/\/ mapref should be deleted from bank here\n\t\treturn false;\n\t}\n\tif (r_io_map_from (map) == ofrom && r_io_map_to (map) == oto) {\n\t\t\/\/ nothing todo here\n\t\treturn true;\n\t}\n\t\/\/ allocate sm here to avoid deleting things without ensuring\n\t\/\/ that this code could at least insert 1 submap\n\tRIOSubMap *sm = r_io_submap_new (io, mapref);\n\tif (!sm) {\n\t\treturn false;\n\t}\n\n\tbank->last_used = NULL;\n\t\/\/ this problem can be divided in 2 steps:\n\t\/\/ 1. delete corresponding submaps and insert intersecting submaps with lower priority\n\t\/\/ 2. adjust addr and insert submaps at new addr respecting priority\n\tRIOMap fake_map;\n\tmemcpy (&fake_map, map, sizeof (RIOMap));\n\tfake_map.itv.addr = ofrom;\n\tfake_map.itv.size = oto - ofrom + 1;\n\t_delete_submaps_from_bank_tree (io, bank, iter, &fake_map);\n\n\tRRBNode *entry = _find_entry_submap_node (bank, sm);\n\tif (!entry) {\n\t\t\/\/ no intersection here, so just insert sm into the tree and we're done\n\t\tr_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\/\/ assumption here is that there is no need to check for return value of r_crbtree_insert,\n\t\t\/\/ since it only fails, if allocation fails and a delete was performed before, so it should just be fine\n\t\treturn true;\n\t}\n\n\tRIOSubMap *bd = (RIOSubMap *)entry->data;\n\t\/\/ check if sm has higher priority than bd by comparing their maprefs\n\tif (_mapref_priority_cmp (bank, &sm->mapref, &bd->mapref) == 1) {\n\t\t\/\/ sm has higher priority that bd => adjust bd\n\t\tif (r_io_submap_to (bd) == r_io_submap_to (sm)) {\n\t\t\tif (r_io_submap_from (bd) >= r_io_submap_from (sm)) {\n\t\t\t\t\/\/ bc of _find_entry_submap_node, we can be sure, that there is no\n\t\t\t\t\/\/ lower submap that intersects with sm\n\t\t\t\t\/\/\n\t\t\t\t\/\/ instead of deleting and inserting, just replace the mapref,\n\t\t\t\t\/\/ similar to r_io_bank_map_priorize\n\t\t\t\tmemcpy (bd, sm, sizeof (RIOSubMap));\n\t\t\t\tfree (sm);\n\t\t\t} else {\n\t\t\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\t\t\tr_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (r_io_submap_from (bd) < r_io_submap_from (sm) &&\n\t\t\tr_io_submap_to (sm) < r_io_submap_to (bd)) {\n\t\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, bd);\n\t\t\t\/\/ allocating bdsm here is fine, bc bd is already in the tree\n\t\t\tr_io_submap_set_from (bdsm, r_io_submap_to (sm) + 1);\n\t\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\t\t\/\/ What do if this fails?\n\t\t\tr_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\tr_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\treturn true;\n\t\t}\n\t\tif (r_io_submap_from (bd) < r_io_submap_from (sm)) {\n\t\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\t\tentry = r_rbnode_next (entry);\n\t\t}\n\t} else {\n\t\t\/\/ _mapref_priority_cmp cannot return 0 in this scenario,\n\t\t\/\/ since all submaps with the same mapref as sm were deleted from\n\t\t\/\/ the submap tree previously. so _mapref_priority_cmp can only return 1 or -1\n\t\t\/\/ bd has higher priority than sm => adjust sm\n\t\tif (r_io_submap_from (bd) <= r_io_submap_from (sm)) {\n\t\t\tif (r_io_submap_to (sm) <= r_io_submap_to (bd)) {\n\t\t\t\t\/\/ bd completly overlaps sm => nothing to do\n\t\t\t\tfree (sm);\n\t\t\t\treturn true;\n\t\t\t} \/\/ else\n\t\t\t\/\/ adjust sm\n\t\t\t\/\/ r_io_submap_set_from (sm, r_io_submap_to (bd) + 1);\n\t\t} else {\n\t\t\tif (r_io_submap_to (sm) <= r_io_submap_to (bd)) {\n\t\t\t\tr_io_submap_set_to (sm, r_io_submap_from (bd) - 1);\n\t\t\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\t\t\tfree (sm);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, sm);\n\t\t\tif (!bdsm) {\n\t\t\t\tfree (sm);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tr_io_submap_set_to (bdsm, r_io_submap_from (bd) - 1);\n\t\t\t\/\/ r_io_submap_set_from (sm, r_io_submap_to (bd) + 1);\n\t\t\tif (!r_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\t\tfree (bdsm);\n\t\t\t\tfree (sm);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\/\/ r_io_submap_set_from (sm, r_io_submap_to (bd) + 1);\n\t\t\tentry = r_rbnode_next (entry);\n\t\t}\n\t\tr_io_submap_set_from (sm, r_io_submap_to (bd) + 1);\n\t}\n\t\/\/ entry = r_rbnode_next (entry);\n\t\/\/ it is given that entry->data->from >= sm->from on every iteration\n\t\/\/ so only check for upper boundary of sm for intersection with entry->data\n\twhile (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\t\/\/ iterate forwards starting at entry, while entry->data and sm overlap\n\t\tbd = (RIOSubMap *)entry->data;\n\t\tentry = r_rbnode_next (entry);\n\t\t\/\/ check if sm has higher priority than bd by comparing their maprefs\n\t\tif (_mapref_priority_cmp (bank, &sm->mapref, &bd->mapref) == 1) {\n\t\t\t\/\/ delete bd\n\t\t\tr_crbtree_delete (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);\n\t\t} else {\n\t\t\t\/\/ _mapref_priority_cmp cannot return 0 in this scenario,\n\t\t\t\/\/ since all submaps with the same mapref as sm were deleted from\n\t\t\t\/\/ the submap tree previously. so _mapref_priority_cmp can only return 1 or -1\n\t\t\t\/\/ bd has higher priority than sm => adjust sm\n\t\t\tif (r_io_submap_from (bd) > r_io_submap_from (sm)) {\n\t\t\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, sm);\n\t\t\t\tr_io_submap_set_to (bdsm, r_io_submap_from (bd) - 1);\n\t\t\t\tr_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\t}\n\t\t\tif (r_io_submap_to (bd) == r_io_submap_to (sm)) {\n\t\t\t\t\/\/ in this case the size of sm would be 0,\n\t\t\t\t\/\/ but since empty maps are not allowed free sm and return\n\t\t\t\tfree (sm);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tr_io_submap_set_from (sm, r_io_submap_to (bd) + 1);\n\t\t}\n\t}\n\tif (!entry) {\n\t\treturn r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t}\n\tbd = (RIOSubMap *)entry->data;\n\tif (_mapref_priority_cmp (bank, &sm->mapref, &bd->mapref) == 1) {\n\t\tif (r_io_submap_from (bd) <= r_io_submap_to (sm)) {\n\t\t\tr_io_submap_set_from (bd, r_io_submap_to (sm) + 1);\n\t\t}\n\t\tr_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t} else {\n\t\tif (r_io_submap_from (sm) < r_io_submap_from (bd)) {\n\t\t\tif (r_io_submap_from (bd) <= r_io_submap_to (sm)) {\n\t\t\t\tr_io_submap_set_to (sm, r_io_submap_from (bd) - 1);\n\t\t\t}\n\t\t\tr_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t} else {\n\t\t\t\/\/ can this happen?\n\t\t\tfree (sm);\n\t\t}\n\t}\n\treturn true;\n}","target":0,"code_token_length":2207,"total_token_length":2443,"max_tokens_setting":4096}
+{"idx":252420,"func":"static int ParseEXRHeader(HeaderInfo *info, bool *empty_header,\n                          const EXRVersion *version, std::string *err,\n                          const unsigned char *buf, size_t size) {\n  const char *marker = reinterpret_cast<const char *>(&buf[0]);\n\n  if (empty_header) {\n    (*empty_header) = false;\n  }\n\n  if (version->multipart) {\n    if (size > 0 && marker[0] == '\\0') {\n      \/\/ End of header list.\n      if (empty_header) {\n        (*empty_header) = true;\n      }\n      return TINYEXR_SUCCESS;\n    }\n  }\n\n  \/\/ According to the spec, the header of every OpenEXR file must contain at\n  \/\/ least the following attributes:\n  \/\/\n  \/\/ channels chlist\n  \/\/ compression compression\n  \/\/ dataWindow box2i\n  \/\/ displayWindow box2i\n  \/\/ lineOrder lineOrder\n  \/\/ pixelAspectRatio float\n  \/\/ screenWindowCenter v2f\n  \/\/ screenWindowWidth float\n  bool has_channels = false;\n  bool has_compression = false;\n  bool has_data_window = false;\n  bool has_display_window = false;\n  bool has_line_order = false;\n  bool has_pixel_aspect_ratio = false;\n  bool has_screen_window_center = false;\n  bool has_screen_window_width = false;\n\n  info->data_window[0] = 0;\n  info->data_window[1] = 0;\n  info->data_window[2] = 0;\n  info->data_window[3] = 0;\n  info->line_order = 0;  \/\/ @fixme\n  info->display_window[0] = 0;\n  info->display_window[1] = 0;\n  info->display_window[2] = 0;\n  info->display_window[3] = 0;\n  info->screen_window_center[0] = 0.0f;\n  info->screen_window_center[1] = 0.0f;\n  info->screen_window_width = -1.0f;\n  info->pixel_aspect_ratio = -1.0f;\n\n  info->tile_size_x = -1;\n  info->tile_size_y = -1;\n  info->tile_level_mode = -1;\n  info->tile_rounding_mode = -1;\n\n  info->attributes.clear();\n\n  \/\/ Read attributes\n  size_t orig_size = size;\n  for (size_t nattr = 0; nattr < TINYEXR_MAX_HEADER_ATTRIBUTES; nattr++) {\n    if (0 == size) {\n      if (err) {\n        (*err) += \"Insufficient data size for attributes.\\n\";\n      }\n      return TINYEXR_ERROR_INVALID_DATA;\n    } else if (marker[0] == '\\0') {\n      size--;\n      break;\n    }\n\n    std::string attr_name;\n    std::string attr_type;\n    std::vector<unsigned char> data;\n    size_t marker_size;\n    if (!tinyexr::ReadAttribute(&attr_name, &attr_type, &data, &marker_size,\n                                marker, size)) {\n      if (err) {\n        (*err) += \"Failed to read attribute.\\n\";\n      }\n      return TINYEXR_ERROR_INVALID_DATA;\n    }\n    marker += marker_size;\n    size -= marker_size;\n\n    if (version->tiled && attr_name.compare(\"tiles\") == 0) {\n      unsigned int x_size, y_size;\n      unsigned char tile_mode;\n      assert(data.size() == 9);\n      memcpy(&x_size, &data.at(0), sizeof(int));\n      memcpy(&y_size, &data.at(4), sizeof(int));\n      tile_mode = data[8];\n      tinyexr::swap4(&x_size);\n      tinyexr::swap4(&y_size);\n\n      info->tile_size_x = static_cast<int>(x_size);\n      info->tile_size_y = static_cast<int>(y_size);\n\n      \/\/ mode = levelMode + roundingMode * 16\n      info->tile_level_mode = tile_mode & 0x3;\n      info->tile_rounding_mode = (tile_mode >> 4) & 0x1;\n\n    } else if (attr_name.compare(\"compression\") == 0) {\n      bool ok = false;\n      if (data[0] < TINYEXR_COMPRESSIONTYPE_PIZ) {\n        ok = true;\n      }\n\n      if (data[0] == TINYEXR_COMPRESSIONTYPE_PIZ) {\n#if TINYEXR_USE_PIZ\n        ok = true;\n#else\n        if (err) {\n          (*err) = \"PIZ compression is not supported.\";\n        }\n        return TINYEXR_ERROR_UNSUPPORTED_FORMAT;\n#endif\n      }\n\n      if (data[0] == TINYEXR_COMPRESSIONTYPE_ZFP) {\n#if TINYEXR_USE_ZFP\n        ok = true;\n#else\n        if (err) {\n          (*err) = \"ZFP compression is not supported.\";\n        }\n        return TINYEXR_ERROR_UNSUPPORTED_FORMAT;\n#endif\n      }\n\n      if (!ok) {\n        if (err) {\n          (*err) = \"Unknown compression type.\";\n        }\n        return TINYEXR_ERROR_UNSUPPORTED_FORMAT;\n      }\n\n      info->compression_type = static_cast<int>(data[0]);\n      has_compression = true;\n\n    } else if (attr_name.compare(\"channels\") == 0) {\n      \/\/ name: zero-terminated string, from 1 to 255 bytes long\n      \/\/ pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2\n      \/\/ pLinear: unsigned char, possible values are 0 and 1\n      \/\/ reserved: three chars, should be zero\n      \/\/ xSampling: int\n      \/\/ ySampling: int\n\n      if (!ReadChannelInfo(info->channels, data)) {\n        if (err) {\n          (*err) += \"Failed to parse channel info.\\n\";\n        }\n        return TINYEXR_ERROR_INVALID_DATA;\n      }\n\n      if (info->channels.size() < 1) {\n        if (err) {\n          (*err) += \"# of channels is zero.\\n\";\n        }\n        return TINYEXR_ERROR_INVALID_DATA;\n      }\n\n      has_channels = true;\n\n    } else if (attr_name.compare(\"dataWindow\") == 0) {\n      if (data.size() >= 16) {\n        memcpy(&info->data_window[0], &data.at(0), sizeof(int));\n        memcpy(&info->data_window[1], &data.at(4), sizeof(int));\n        memcpy(&info->data_window[2], &data.at(8), sizeof(int));\n        memcpy(&info->data_window[3], &data.at(12), sizeof(int));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&info->data_window[0]));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&info->data_window[1]));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&info->data_window[2]));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&info->data_window[3]));\n        has_data_window = true;\n      }\n    } else if (attr_name.compare(\"displayWindow\") == 0) {\n      if (data.size() >= 16) {\n        memcpy(&info->display_window[0], &data.at(0), sizeof(int));\n        memcpy(&info->display_window[1], &data.at(4), sizeof(int));\n        memcpy(&info->display_window[2], &data.at(8), sizeof(int));\n        memcpy(&info->display_window[3], &data.at(12), sizeof(int));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->display_window[0]));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->display_window[1]));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->display_window[2]));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->display_window[3]));\n\n        has_display_window = true;\n      }\n    } else if (attr_name.compare(\"lineOrder\") == 0) {\n      if (data.size() >= 1) {\n        info->line_order = static_cast<int>(data[0]);\n        has_line_order = true;\n      }\n    } else if (attr_name.compare(\"pixelAspectRatio\") == 0) {\n      if (data.size() >= sizeof(float)) {\n        memcpy(&info->pixel_aspect_ratio, &data.at(0), sizeof(float));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->pixel_aspect_ratio));\n        has_pixel_aspect_ratio = true;\n      }\n    } else if (attr_name.compare(\"screenWindowCenter\") == 0) {\n      if (data.size() >= 8) {\n        memcpy(&info->screen_window_center[0], &data.at(0), sizeof(float));\n        memcpy(&info->screen_window_center[1], &data.at(4), sizeof(float));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->screen_window_center[0]));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->screen_window_center[1]));\n        has_screen_window_center = true;\n      }\n    } else if (attr_name.compare(\"screenWindowWidth\") == 0) {\n      if (data.size() >= sizeof(float)) {\n        memcpy(&info->screen_window_width, &data.at(0), sizeof(float));\n        tinyexr::swap4(\n            reinterpret_cast<unsigned int *>(&info->screen_window_width));\n\n        has_screen_window_width = true;\n      }\n    } else if (attr_name.compare(\"chunkCount\") == 0) {\n      if (data.size() >= sizeof(int)) {\n        memcpy(&info->chunk_count, &data.at(0), sizeof(int));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&info->chunk_count));\n      }\n    } else {\n      \/\/ Custom attribute(up to TINYEXR_MAX_CUSTOM_ATTRIBUTES)\n      if (info->attributes.size() < TINYEXR_MAX_CUSTOM_ATTRIBUTES) {\n        EXRAttribute attrib;\n#ifdef _MSC_VER\n        strncpy_s(attrib.name, attr_name.c_str(), 255);\n        strncpy_s(attrib.type, attr_type.c_str(), 255);\n#else\n        strncpy(attrib.name, attr_name.c_str(), 255);\n        strncpy(attrib.type, attr_type.c_str(), 255);\n#endif\n        attrib.name[255] = '\\0';\n        attrib.type[255] = '\\0';\n        attrib.size = static_cast<int>(data.size());\n        attrib.value = static_cast<unsigned char *>(malloc(data.size()));\n        memcpy(reinterpret_cast<char *>(attrib.value), &data.at(0),\n               data.size());\n        info->attributes.push_back(attrib);\n      }\n    }\n  }\n\n  \/\/ Check if required attributes exist\n  {\n    std::stringstream ss_err;\n\n    if (!has_compression) {\n      ss_err << \"\\\"compression\\\" attribute not found in the header.\"\n             << std::endl;\n    }\n\n    if (!has_channels) {\n      ss_err << \"\\\"channels\\\" attribute not found in the header.\" << std::endl;\n    }\n\n    if (!has_line_order) {\n      ss_err << \"\\\"lineOrder\\\" attribute not found in the header.\" << std::endl;\n    }\n\n    if (!has_display_window) {\n      ss_err << \"\\\"displayWindow\\\" attribute not found in the header.\"\n             << std::endl;\n    }\n\n    if (!has_data_window) {\n      ss_err << \"\\\"dataWindow\\\" attribute not found in the header or invalid.\"\n             << std::endl;\n    }\n\n    if (!has_pixel_aspect_ratio) {\n      ss_err << \"\\\"pixelAspectRatio\\\" attribute not found in the header.\"\n             << std::endl;\n    }\n\n    if (!has_screen_window_width) {\n      ss_err << \"\\\"screenWindowWidth\\\" attribute not found in the header.\"\n             << std::endl;\n    }\n\n    if (!has_screen_window_center) {\n      ss_err << \"\\\"screenWindowCenter\\\" attribute not found in the header.\"\n             << std::endl;\n    }\n\n    if (!(ss_err.str().empty())) {\n      if (err) {\n        (*err) += ss_err.str();\n      }\n      return TINYEXR_ERROR_INVALID_HEADER;\n    }\n  }\n\n  info->header_len = static_cast<unsigned int>(orig_size - size);\n\n  return TINYEXR_SUCCESS;\n}","target":0,"code_token_length":2662,"total_token_length":2898,"max_tokens_setting":4096}
+{"idx":209802,"func":"get_address(\n    exarg_T\t*eap UNUSED,\n    char_u\t**ptr,\n    cmd_addr_T\taddr_type,\n    int\t\tskip,\t\t\/\/ only skip the address, don't use it\n    int\t\tsilent,\t\t\/\/ no errors or side effects\n    int\t\tto_other_file,  \/\/ flag: may jump to other file\n    int\t\taddress_count UNUSED) \/\/ 1 for first address, >1 after comma\n{\n    int\t\tc;\n    int\t\ti;\n    long\tn;\n    char_u\t*cmd;\n    pos_T\tpos;\n    pos_T\t*fp;\n    linenr_T\tlnum;\n    buf_T\t*buf;\n\n    cmd = skipwhite(*ptr);\n    lnum = MAXLNUM;\n    do\n    {\n\tswitch (*cmd)\n\t{\n\t    case '.':\t\t\t    \/\/ '.' - Cursor position\n\t\t++cmd;\n\t\tswitch (addr_type)\n\t\t{\n\t\t    case ADDR_LINES:\n\t\t    case ADDR_OTHER:\n\t\t\tlnum = curwin->w_cursor.lnum;\n\t\t\tbreak;\n\t\t    case ADDR_WINDOWS:\n\t\t\tlnum = CURRENT_WIN_NR;\n\t\t\tbreak;\n\t\t    case ADDR_ARGUMENTS:\n\t\t\tlnum = curwin->w_arg_idx + 1;\n\t\t\tbreak;\n\t\t    case ADDR_LOADED_BUFFERS:\n\t\t    case ADDR_BUFFERS:\n\t\t\tlnum = curbuf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_TABS:\n\t\t\tlnum = CURRENT_TAB_NR;\n\t\t\tbreak;\n\t\t    case ADDR_NONE:\n\t\t    case ADDR_TABS_RELATIVE:\n\t\t    case ADDR_UNSIGNED:\n\t\t\taddr_error(addr_type);\n\t\t\tcmd = NULL;\n\t\t\tgoto error;\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX:\n#ifdef FEAT_QUICKFIX\n\t\t\tlnum = qf_get_cur_idx(eap);\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX_VALID:\n#ifdef FEAT_QUICKFIX\n\t\t\tlnum = qf_get_cur_valid_idx(eap);\n#endif\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\t    case '$':\t\t\t    \/\/ '$' - last line\n\t\t++cmd;\n\t\tswitch (addr_type)\n\t\t{\n\t\t    case ADDR_LINES:\n\t\t    case ADDR_OTHER:\n\t\t\tlnum = curbuf->b_ml.ml_line_count;\n\t\t\tbreak;\n\t\t    case ADDR_WINDOWS:\n\t\t\tlnum = LAST_WIN_NR;\n\t\t\tbreak;\n\t\t    case ADDR_ARGUMENTS:\n\t\t\tlnum = ARGCOUNT;\n\t\t\tbreak;\n\t\t    case ADDR_LOADED_BUFFERS:\n\t\t\tbuf = lastbuf;\n\t\t\twhile (buf->b_ml.ml_mfp == NULL)\n\t\t\t{\n\t\t\t    if (buf->b_prev == NULL)\n\t\t\t\tbreak;\n\t\t\t    buf = buf->b_prev;\n\t\t\t}\n\t\t\tlnum = buf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_BUFFERS:\n\t\t\tlnum = lastbuf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_TABS:\n\t\t\tlnum = LAST_TAB_NR;\n\t\t\tbreak;\n\t\t    case ADDR_NONE:\n\t\t    case ADDR_TABS_RELATIVE:\n\t\t    case ADDR_UNSIGNED:\n\t\t\taddr_error(addr_type);\n\t\t\tcmd = NULL;\n\t\t\tgoto error;\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX:\n#ifdef FEAT_QUICKFIX\n\t\t\tlnum = qf_get_size(eap);\n\t\t\tif (lnum == 0)\n\t\t\t    lnum = 1;\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX_VALID:\n#ifdef FEAT_QUICKFIX\n\t\t\tlnum = qf_get_valid_size(eap);\n\t\t\tif (lnum == 0)\n\t\t\t    lnum = 1;\n#endif\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\t    case '\\'':\t\t\t    \/\/ ''' - mark\n\t\tif (*++cmd == NUL)\n\t\t{\n\t\t    cmd = NULL;\n\t\t    goto error;\n\t\t}\n\t\tif (addr_type != ADDR_LINES)\n\t\t{\n\t\t    addr_error(addr_type);\n\t\t    cmd = NULL;\n\t\t    goto error;\n\t\t}\n\t\tif (skip)\n\t\t    ++cmd;\n\t\telse\n\t\t{\n\t\t    \/\/ Only accept a mark in another file when it is\n\t\t    \/\/ used by itself: \":'M\".\n\t\t    fp = getmark(*cmd, to_other_file && cmd[1] == NUL);\n\t\t    ++cmd;\n\t\t    if (fp == (pos_T *)-1)\n\t\t\t\/\/ Jumped to another file.\n\t\t\tlnum = curwin->w_cursor.lnum;\n\t\t    else\n\t\t    {\n\t\t\tif (check_mark(fp) == FAIL)\n\t\t\t{\n\t\t\t    cmd = NULL;\n\t\t\t    goto error;\n\t\t\t}\n\t\t\tlnum = fp->lnum;\n\t\t    }\n\t\t}\n\t\tbreak;\n\n\t    case '\/':\n\t    case '?':\t\t\t\/\/ '\/' or '?' - search\n\t\tc = *cmd++;\n\t\tif (addr_type != ADDR_LINES)\n\t\t{\n\t\t    addr_error(addr_type);\n\t\t    cmd = NULL;\n\t\t    goto error;\n\t\t}\n\t\tif (skip)\t\/\/ skip \"\/pat\/\"\n\t\t{\n\t\t    cmd = skip_regexp(cmd, c, magic_isset());\n\t\t    if (*cmd == c)\n\t\t\t++cmd;\n\t\t}\n\t\telse\n\t\t{\n\t\t    int flags;\n\n\t\t    pos = curwin->w_cursor; \/\/ save curwin->w_cursor\n\n\t\t    \/\/ When '\/' or '?' follows another address, start from\n\t\t    \/\/ there.\n\t\t    if (lnum != MAXLNUM)\n\t\t\tcurwin->w_cursor.lnum = lnum;\n\n\t\t    \/\/ Start a forward search at the end of the line (unless\n\t\t    \/\/ before the first line).\n\t\t    \/\/ Start a backward search at the start of the line.\n\t\t    \/\/ This makes sure we never match in the current\n\t\t    \/\/ line, and can match anywhere in the\n\t\t    \/\/ next\/previous line.\n\t\t    if (c == '\/' && curwin->w_cursor.lnum > 0)\n\t\t\tcurwin->w_cursor.col = MAXCOL;\n\t\t    else\n\t\t\tcurwin->w_cursor.col = 0;\n\t\t    searchcmdlen = 0;\n\t\t    flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;\n\t\t    if (!do_search(NULL, c, c, cmd, 1L, flags, NULL))\n\t\t    {\n\t\t\tcurwin->w_cursor = pos;\n\t\t\tcmd = NULL;\n\t\t\tgoto error;\n\t\t    }\n\t\t    lnum = curwin->w_cursor.lnum;\n\t\t    curwin->w_cursor = pos;\n\t\t    \/\/ adjust command string pointer\n\t\t    cmd += searchcmdlen;\n\t\t}\n\t\tbreak;\n\n\t    case '\\\\':\t\t    \/\/ \"\\?\", \"\\\/\" or \"\\&\", repeat search\n\t\t++cmd;\n\t\tif (addr_type != ADDR_LINES)\n\t\t{\n\t\t    addr_error(addr_type);\n\t\t    cmd = NULL;\n\t\t    goto error;\n\t\t}\n\t\tif (*cmd == '&')\n\t\t    i = RE_SUBST;\n\t\telse if (*cmd == '?' || *cmd == '\/')\n\t\t    i = RE_SEARCH;\n\t\telse\n\t\t{\n\t\t    emsg(_(e_backslash_should_be_followed_by));\n\t\t    cmd = NULL;\n\t\t    goto error;\n\t\t}\n\n\t\tif (!skip)\n\t\t{\n\t\t    \/*\n\t\t     * When search follows another address, start from\n\t\t     * there.\n\t\t     *\/\n\t\t    if (lnum != MAXLNUM)\n\t\t\tpos.lnum = lnum;\n\t\t    else\n\t\t\tpos.lnum = curwin->w_cursor.lnum;\n\n\t\t    \/*\n\t\t     * Start the search just like for the above\n\t\t     * do_search().\n\t\t     *\/\n\t\t    if (*cmd != '?')\n\t\t\tpos.col = MAXCOL;\n\t\t    else\n\t\t\tpos.col = 0;\n\t\t    pos.coladd = 0;\n\t\t    if (searchit(curwin, curbuf, &pos, NULL,\n\t\t\t\t*cmd == '?' ? BACKWARD : FORWARD,\n\t\t\t\t(char_u *)\"\", 1L, SEARCH_MSG, i, NULL) != FAIL)\n\t\t\tlnum = pos.lnum;\n\t\t    else\n\t\t    {\n\t\t\tcmd = NULL;\n\t\t\tgoto error;\n\t\t    }\n\t\t}\n\t\t++cmd;\n\t\tbreak;\n\n\t    default:\n\t\tif (VIM_ISDIGIT(*cmd))\t\/\/ absolute line number\n\t\t    lnum = getdigits(&cmd);\n\t}\n\n\tfor (;;)\n\t{\n\t    cmd = skipwhite(cmd);\n\t    if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd))\n\t\tbreak;\n\n\t    if (lnum == MAXLNUM)\n\t    {\n\t\tswitch (addr_type)\n\t\t{\n\t\t    case ADDR_LINES:\n\t\t    case ADDR_OTHER:\n\t\t\t\/\/ \"+1\" is same as \".+1\"\n\t\t\tlnum = curwin->w_cursor.lnum;\n\t\t\tbreak;\n\t\t    case ADDR_WINDOWS:\n\t\t\tlnum = CURRENT_WIN_NR;\n\t\t\tbreak;\n\t\t    case ADDR_ARGUMENTS:\n\t\t\tlnum = curwin->w_arg_idx + 1;\n\t\t\tbreak;\n\t\t    case ADDR_LOADED_BUFFERS:\n\t\t    case ADDR_BUFFERS:\n\t\t\tlnum = curbuf->b_fnum;\n\t\t\tbreak;\n\t\t    case ADDR_TABS:\n\t\t\tlnum = CURRENT_TAB_NR;\n\t\t\tbreak;\n\t\t    case ADDR_TABS_RELATIVE:\n\t\t\tlnum = 1;\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX:\n#ifdef FEAT_QUICKFIX\n\t\t\tlnum = qf_get_cur_idx(eap);\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_QUICKFIX_VALID:\n#ifdef FEAT_QUICKFIX\n\t\t\tlnum = qf_get_cur_valid_idx(eap);\n#endif\n\t\t\tbreak;\n\t\t    case ADDR_NONE:\n\t\t    case ADDR_UNSIGNED:\n\t\t\tlnum = 0;\n\t\t\tbreak;\n\t\t}\n\t    }\n\n\t    if (VIM_ISDIGIT(*cmd))\n\t\ti = '+';\t\t\/\/ \"number\" is same as \"+number\"\n\t    else\n\t\ti = *cmd++;\n\t    if (!VIM_ISDIGIT(*cmd))\t\/\/ '+' is '+1', but '+0' is not '+1'\n\t\tn = 1;\n\t    else\n\t\tn = getdigits(&cmd);\n\n\t    if (addr_type == ADDR_TABS_RELATIVE)\n\t    {\n\t\temsg(_(e_invalid_range));\n\t\tcmd = NULL;\n\t\tgoto error;\n\t    }\n\t    else if (addr_type == ADDR_LOADED_BUFFERS\n\t\t    || addr_type == ADDR_BUFFERS)\n\t\tlnum = compute_buffer_local_count(\n\t\t\t\t    addr_type, lnum, (i == '-') ? -1 * n : n);\n\t    else\n\t    {\n#ifdef FEAT_FOLDING\n\t\t\/\/ Relative line addressing, need to adjust for folded lines\n\t\t\/\/ now, but only do it after the first address.\n\t\tif (addr_type == ADDR_LINES && (i == '-' || i == '+')\n\t\t\t&& address_count >= 2)\n\t\t    (void)hasFolding(lnum, NULL, &lnum);\n#endif\n\t\tif (i == '-')\n\t\t    lnum -= n;\n\t\telse\n\t\t    lnum += n;\n\t    }\n\t}\n    } while (*cmd == '\/' || *cmd == '?');\n\nerror:\n    *ptr = cmd;\n    return lnum;\n}","target":1,"code_token_length":2275,"total_token_length":2511,"max_tokens_setting":4096}
+{"idx":214335,"func":"int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,\n\t\t\t\t\t      off_t bl_len)\n{\n  const char *content_type = NULL;\n  string content_type_str;\n  map<string, string> response_attrs;\n  map<string, string>::iterator riter;\n  bufferlist metadata_bl;\n\n  string expires = get_s3_expiration_header(s, lastmod);\n\n  if (sent_header)\n    goto send_data;\n\n  if (custom_http_ret) {\n    set_req_state_err(s, 0);\n    dump_errno(s, custom_http_ret);\n  } else {\n    set_req_state_err(s, (partial_content && !op_ret) ? STATUS_PARTIAL_CONTENT\n                  : op_ret);\n    dump_errno(s);\n  }\n\n  if (op_ret)\n    goto done;\n\n  if (range_str)\n    dump_range(s, start, end, s->obj_size);\n\n  if (s->system_request &&\n      s->info.args.exists(RGW_SYS_PARAM_PREFIX \"prepend-metadata\")) {\n\n    dump_header(s, \"Rgwx-Object-Size\", (long long)total_len);\n\n    if (rgwx_stat) {\n      \/*\n       * in this case, we're not returning the object's content, only the prepended\n       * extra metadata\n       *\/\n      total_len = 0;\n    }\n\n    \/* JSON encode object metadata *\/\n    JSONFormatter jf;\n    jf.open_object_section(\"obj_metadata\");\n    encode_json(\"attrs\", attrs, &jf);\n    utime_t ut(lastmod);\n    encode_json(\"mtime\", ut, &jf);\n    jf.close_section();\n    stringstream ss;\n    jf.flush(ss);\n    metadata_bl.append(ss.str());\n    dump_header(s, \"Rgwx-Embedded-Metadata-Len\", metadata_bl.length());\n    total_len += metadata_bl.length();\n  }\n\n  if (s->system_request && !real_clock::is_zero(lastmod)) {\n    \/* we end up dumping mtime in two different methods, a bit redundant *\/\n    dump_epoch_header(s, \"Rgwx-Mtime\", lastmod);\n    uint64_t pg_ver = 0;\n    int r = decode_attr_bl_single_value(attrs, RGW_ATTR_PG_VER, &pg_ver, (uint64_t)0);\n    if (r < 0) {\n      ldpp_dout(this, 0) << \"ERROR: failed to decode pg ver attr, ignoring\" << dendl;\n    }\n    dump_header(s, \"Rgwx-Obj-PG-Ver\", pg_ver);\n\n    uint32_t source_zone_short_id = 0;\n    r = decode_attr_bl_single_value(attrs, RGW_ATTR_SOURCE_ZONE, &source_zone_short_id, (uint32_t)0);\n    if (r < 0) {\n      ldpp_dout(this, 0) << \"ERROR: failed to decode pg ver attr, ignoring\" << dendl;\n    }\n    if (source_zone_short_id != 0) {\n      dump_header(s, \"Rgwx-Source-Zone-Short-Id\", source_zone_short_id);\n    }\n  }\n\n  for (auto &it : crypt_http_responses)\n    dump_header(s, it.first, it.second);\n\n  dump_content_length(s, total_len);\n  dump_last_modified(s, lastmod);\n  dump_header_if_nonempty(s, \"x-amz-version-id\", version_id);\n  dump_header_if_nonempty(s, \"x-amz-expiration\", expires);\n\n  if (attrs.find(RGW_ATTR_APPEND_PART_NUM) != attrs.end()) {\n    dump_header(s, \"x-rgw-object-type\", \"Appendable\");\n    dump_header(s, \"x-rgw-next-append-position\", s->obj_size);\n  } else {\n    dump_header(s, \"x-rgw-object-type\", \"Normal\");\n  }\n\n  if (! op_ret) {\n    if (! lo_etag.empty()) {\n      \/* Handle etag of Swift API's large objects (DLO\/SLO). It's entirerly\n       * legit to perform GET on them through S3 API. In such situation,\n       * a client should receive the composited content with corresponding\n       * etag value. *\/\n      dump_etag(s, lo_etag);\n    } else {\n      auto iter = attrs.find(RGW_ATTR_ETAG);\n      if (iter != attrs.end()) {\n        dump_etag(s, iter->second.to_str());\n      }\n    }\n\n    for (struct response_attr_param *p = resp_attr_params; p->param; p++) {\n      bool exists;\n      string val = s->info.args.get(p->param, &exists);\n      if (exists) {\n\t\/* reject unauthenticated response header manipulation, see\n\t * https:\/\/docs.aws.amazon.com\/AmazonS3\/latest\/API\/API_GetObject.html *\/\n\tif (s->auth.identity->is_anonymous()) {\n\t  return -ERR_INVALID_REQUEST;\n\t}\n\tif (strcmp(p->param, \"response-content-type\") != 0) {\n\t  response_attrs[p->http_attr] = val;\n\t} else {\n\t  content_type_str = val;\n\t  content_type = content_type_str.c_str();\n\t}\n      }\n    }\n\n    for (auto iter = attrs.begin(); iter != attrs.end(); ++iter) {\n      const char *name = iter->first.c_str();\n      map<string, string>::iterator aiter = rgw_to_http_attrs.find(name);\n      if (aiter != rgw_to_http_attrs.end()) {\n        if (response_attrs.count(aiter->second) == 0) {\n          \/* Was not already overridden by a response param. *\/\n\n          size_t len = iter->second.length();\n          string s(iter->second.c_str(), len);\n          while (len && !s[len - 1]) {\n            --len;\n            s.resize(len);\n          }\n          response_attrs[aiter->second] = s;\n        }\n      } else if (iter->first.compare(RGW_ATTR_CONTENT_TYPE) == 0) {\n        \/* Special handling for content_type. *\/\n        if (!content_type) {\n          content_type_str = rgw_bl_str(iter->second);\n          content_type = content_type_str.c_str();\n        }\n      } else if (strcmp(name, RGW_ATTR_SLO_UINDICATOR) == 0) {\n        \/\/ this attr has an extra length prefix from encode() in prior versions\n        dump_header(s, \"X-Object-Meta-Static-Large-Object\", \"True\");\n      } else if (strncmp(name, RGW_ATTR_META_PREFIX,\n\t\t\t sizeof(RGW_ATTR_META_PREFIX)-1) == 0) {\n        \/* User custom metadata. *\/\n        name += sizeof(RGW_ATTR_PREFIX) - 1;\n        dump_header(s, name, iter->second);\n      } else if (iter->first.compare(RGW_ATTR_TAGS) == 0) {\n        RGWObjTags obj_tags;\n        try{\n          auto it = iter->second.cbegin();\n          obj_tags.decode(it);\n        } catch (buffer::error &err) {\n          ldpp_dout(this,0) << \"Error caught buffer::error couldn't decode TagSet \" << dendl;\n        }\n        dump_header(s, RGW_AMZ_TAG_COUNT, obj_tags.count());\n      } else if (iter->first.compare(RGW_ATTR_OBJECT_RETENTION) == 0 && get_retention){\n        RGWObjectRetention retention;\n        try {\n          decode(retention, iter->second);\n          dump_header(s, \"x-amz-object-lock-mode\", retention.get_mode());\n          dump_time_header(s, \"x-amz-object-lock-retain-until-date\", retention.get_retain_until_date());\n        } catch (buffer::error& err) {\n          ldpp_dout(this, 0) << \"ERROR: failed to decode RGWObjectRetention\" << dendl;\n        }\n      } else if (iter->first.compare(RGW_ATTR_OBJECT_LEGAL_HOLD) == 0 && get_legal_hold) {\n        RGWObjectLegalHold legal_hold;\n        try {\n          decode(legal_hold, iter->second);\n          dump_header(s, \"x-amz-object-lock-legal-hold\",legal_hold.get_status());\n        } catch (buffer::error& err) {\n          ldpp_dout(this, 0) << \"ERROR: failed to decode RGWObjectLegalHold\" << dendl;\n        }\n      }\n    }\n  }\n\ndone:\n  for (riter = response_attrs.begin(); riter != response_attrs.end();\n       ++riter) {\n    dump_header(s, riter->first, riter->second);\n  }\n\n  if (op_ret == -ERR_NOT_MODIFIED) {\n      end_header(s, this);\n  } else {\n      if (!content_type)\n          content_type = \"binary\/octet-stream\";\n\n      end_header(s, this, content_type);\n  }\n\n  if (metadata_bl.length()) {\n    dump_body(s, metadata_bl);\n  }\n  sent_header = true;\n\nsend_data:\n  if (get_data && !op_ret) {\n    int r = dump_body(s, bl.c_str() + bl_ofs, bl_len);\n    if (r < 0)\n      return r;\n  }\n\n  return 0;\n}","target":1,"code_token_length":1926,"total_token_length":2162,"max_tokens_setting":4096}
+{"idx":208983,"func":"jas_image_t *jp2_decode(jas_stream_t *in, char *optstr)\n{\n\tjp2_box_t *box;\n\tint found;\n\tjas_image_t *image;\n\tjp2_dec_t *dec;\n\tbool samedtype;\n\tint dtype;\n\tunsigned int i;\n\tjp2_cmap_t *cmapd;\n\tjp2_pclr_t *pclrd;\n\tjp2_cdef_t *cdefd;\n\tunsigned int channo;\n\tint newcmptno;\n\tint_fast32_t *lutents;\n#if 0\n\tjp2_cdefchan_t *cdefent;\n\tint cmptno;\n#endif\n\tjp2_cmapent_t *cmapent;\n\tjas_icchdr_t icchdr;\n\tjas_iccprof_t *iccprof;\n\n\tdec = 0;\n\tbox = 0;\n\timage = 0;\n\n\tif (!(dec = jp2_dec_create())) {\n\t\tgoto error;\n\t}\n\n\t\/* Get the first box.  This should be a JP box. *\/\n\tif (!(box = jp2_box_get(in))) {\n\t\tjas_eprintf(\"error: cannot get box\\n\");\n\t\tgoto error;\n\t}\n\tif (box->type != JP2_BOX_JP) {\n\t\tjas_eprintf(\"error: expecting signature box\\n\");\n\t\tgoto error;\n\t}\n\tif (box->data.jp.magic != JP2_JP_MAGIC) {\n\t\tjas_eprintf(\"incorrect magic number\\n\");\n\t\tgoto error;\n\t}\n\tjp2_box_destroy(box);\n\tbox = 0;\n\n\t\/* Get the second box.  This should be a FTYP box. *\/\n\tif (!(box = jp2_box_get(in))) {\n\t\tgoto error;\n\t}\n\tif (box->type != JP2_BOX_FTYP) {\n\t\tjas_eprintf(\"expecting file type box\\n\");\n\t\tgoto error;\n\t}\n\tjp2_box_destroy(box);\n\tbox = 0;\n\n\t\/* Get more boxes... *\/\n\tfound = 0;\n\twhile ((box = jp2_box_get(in))) {\n\t\tif (jas_getdbglevel() >= 1) {\n\t\t\tjas_eprintf(\"box type %s\\n\", box->info->name);\n\t\t}\n\t\tswitch (box->type) {\n\t\tcase JP2_BOX_JP2C:\n\t\t\tfound = 1;\n\t\t\tbreak;\n\t\tcase JP2_BOX_IHDR:\n\t\t\tif (!dec->ihdr) {\n\t\t\t\tdec->ihdr = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_BPCC:\n\t\t\tif (!dec->bpcc) {\n\t\t\t\tdec->bpcc = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_CDEF:\n\t\t\tif (!dec->cdef) {\n\t\t\t\tdec->cdef = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_PCLR:\n\t\t\tif (!dec->pclr) {\n\t\t\t\tdec->pclr = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_CMAP:\n\t\t\tif (!dec->cmap) {\n\t\t\t\tdec->cmap = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_COLR:\n\t\t\tif (!dec->colr) {\n\t\t\t\tdec->colr = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (box) {\n\t\t\tjp2_box_destroy(box);\n\t\t\tbox = 0;\n\t\t}\n\t\tif (found) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!found) {\n\t\tjas_eprintf(\"error: no code stream found\\n\");\n\t\tgoto error;\n\t}\n\n\tif (!(dec->image = jpc_decode(in, optstr))) {\n\t\tjas_eprintf(\"error: cannot decode code stream\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* An IHDR box must be present. *\/\n\tif (!dec->ihdr) {\n\t\tjas_eprintf(\"error: missing IHDR box\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Does the number of components indicated in the IHDR box match\n\t  the value specified in the code stream? *\/\n\tif (dec->ihdr->data.ihdr.numcmpts != JAS_CAST(uint, jas_image_numcmpts(dec->image))) {\n\t\tjas_eprintf(\"warning: number of components mismatch\\n\");\n\t}\n\n\t\/* At least one component must be present. *\/\n\tif (!jas_image_numcmpts(dec->image)) {\n\t\tjas_eprintf(\"error: no components\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Determine if all components have the same data type. *\/\n\tsamedtype = true;\n\tdtype = jas_image_cmptdtype(dec->image, 0);\n\tfor (i = 1; i < JAS_CAST(uint, jas_image_numcmpts(dec->image)); ++i) {\n\t\tif (jas_image_cmptdtype(dec->image, i) != dtype) {\n\t\t\tsamedtype = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* Is the component data type indicated in the IHDR box consistent\n\t  with the data in the code stream? *\/\n\tif ((samedtype && dec->ihdr->data.ihdr.bpc != JP2_DTYPETOBPC(dtype)) ||\n\t  (!samedtype && dec->ihdr->data.ihdr.bpc != JP2_IHDR_BPCNULL)) {\n\t\tjas_eprintf(\"warning: component data type mismatch\\n\");\n\t}\n\n\t\/* Is the compression type supported? *\/\n\tif (dec->ihdr->data.ihdr.comptype != JP2_IHDR_COMPTYPE) {\n\t\tjas_eprintf(\"error: unsupported compression type\\n\");\n\t\tgoto error;\n\t}\n\n\tif (dec->bpcc) {\n\t\t\/* Is the number of components indicated in the BPCC box\n\t\t  consistent with the code stream data? *\/\n\t\tif (dec->bpcc->data.bpcc.numcmpts != JAS_CAST(uint, jas_image_numcmpts(\n\t\t  dec->image))) {\n\t\t\tjas_eprintf(\"warning: number of components mismatch\\n\");\n\t\t}\n\t\t\/* Is the component data type information indicated in the BPCC\n\t\t  box consistent with the code stream data? *\/\n\t\tif (!samedtype) {\n\t\t\tfor (i = 0; i < JAS_CAST(uint, jas_image_numcmpts(dec->image)); ++i) {\n\t\t\t\tif (jas_image_cmptdtype(dec->image, i) != JP2_BPCTODTYPE(dec->bpcc->data.bpcc.bpcs[i])) {\n\t\t\t\t\tjas_eprintf(\"warning: component data type mismatch\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tjas_eprintf(\"warning: superfluous BPCC box\\n\");\n\t\t}\n\t}\n\n\t\/* A COLR box must be present. *\/\n\tif (!dec->colr) {\n\t\tjas_eprintf(\"error: no COLR box\\n\");\n\t\tgoto error;\n\t}\n\n\tswitch (dec->colr->data.colr.method) {\n\tcase JP2_COLR_ENUM:\n\t\tjas_image_setclrspc(dec->image, jp2_getcs(&dec->colr->data.colr));\n\t\tbreak;\n\tcase JP2_COLR_ICC:\n\t\ticcprof = jas_iccprof_createfrombuf(dec->colr->data.colr.iccp,\n\t\t  dec->colr->data.colr.iccplen);\n\t\tassert(iccprof);\n\t\tjas_iccprof_gethdr(iccprof, &icchdr);\n\t\tjas_eprintf(\"ICC Profile CS %08x\\n\", icchdr.colorspc);\n\t\tjas_image_setclrspc(dec->image, fromiccpcs(icchdr.colorspc));\n\t\tdec->image->cmprof_ = jas_cmprof_createfromiccprof(iccprof);\n\t\tassert(dec->image->cmprof_);\n\t\tjas_iccprof_destroy(iccprof);\n\t\tbreak;\n\t}\n\n\t\/* If a CMAP box is present, a PCLR box must also be present. *\/\n\tif (dec->cmap && !dec->pclr) {\n\t\tjas_eprintf(\"warning: missing PCLR box or superfluous CMAP box\\n\");\n\t\tjp2_box_destroy(dec->cmap);\n\t\tdec->cmap = 0;\n\t}\n\n\t\/* If a CMAP box is not present, a PCLR box must not be present. *\/\n\tif (!dec->cmap && dec->pclr) {\n\t\tjas_eprintf(\"warning: missing CMAP box or superfluous PCLR box\\n\");\n\t\tjp2_box_destroy(dec->pclr);\n\t\tdec->pclr = 0;\n\t}\n\n\t\/* Determine the number of channels (which is essentially the number\n\t  of components after any palette mappings have been applied). *\/\n\tdec->numchans = dec->cmap ? dec->cmap->data.cmap.numchans : JAS_CAST(uint, jas_image_numcmpts(dec->image));\n\n\t\/* Perform a basic sanity check on the CMAP box if present. *\/\n\tif (dec->cmap) {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\t\/* Is the component number reasonable? *\/\n\t\t\tif (dec->cmap->data.cmap.ents[i].cmptno >= JAS_CAST(uint, jas_image_numcmpts(dec->image))) {\n\t\t\t\tjas_eprintf(\"error: invalid component number in CMAP box\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\t\/* Is the LUT index reasonable? *\/\n\t\t\tif (dec->cmap->data.cmap.ents[i].pcol >= dec->pclr->data.pclr.numchans) {\n\t\t\t\tjas_eprintf(\"error: invalid CMAP LUT index\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Allocate space for the channel-number to component-number LUT. *\/\n\tif (!(dec->chantocmptlut = jas_malloc(dec->numchans * sizeof(uint_fast16_t)))) {\n\t\tjas_eprintf(\"error: no memory\\n\");\n\t\tgoto error;\n\t}\n\n\tif (!dec->cmap) {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\tdec->chantocmptlut[i] = i;\n\t\t}\n\t} else {\n\t\tcmapd = &dec->cmap->data.cmap;\n\t\tpclrd = &dec->pclr->data.pclr;\n\t\tcdefd = &dec->cdef->data.cdef;\n\t\tfor (channo = 0; channo < cmapd->numchans; ++channo) {\n\t\t\tcmapent = &cmapd->ents[channo];\n\t\t\tif (cmapent->map == JP2_CMAP_DIRECT) {\n\t\t\t\tdec->chantocmptlut[channo] = channo;\n\t\t\t} else if (cmapent->map == JP2_CMAP_PALETTE) {\n\t\t\t\tlutents = jas_malloc(pclrd->numlutents * sizeof(int_fast32_t));\n\t\t\t\tfor (i = 0; i < pclrd->numlutents; ++i) {\n\t\t\t\t\tlutents[i] = pclrd->lutdata[cmapent->pcol + i * pclrd->numchans];\n\t\t\t\t}\n\t\t\t\tnewcmptno = jas_image_numcmpts(dec->image);\n\t\t\t\tjas_image_depalettize(dec->image, cmapent->cmptno, pclrd->numlutents, lutents, JP2_BPCTODTYPE(pclrd->bpc[cmapent->pcol]), newcmptno);\n\t\t\t\tdec->chantocmptlut[channo] = newcmptno;\n\t\t\t\tjas_free(lutents);\n#if 0\n\t\t\t\tif (dec->cdef) {\n\t\t\t\t\tcdefent = jp2_cdef_lookup(cdefd, channo);\n\t\t\t\t\tif (!cdefent) {\n\t\t\t\t\t\tabort();\n\t\t\t\t\t}\n\t\t\t\tjas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_clrspc(dec->image), cdefent->type, cdefent->assoc));\n\t\t\t\t} else {\n\t\t\t\tjas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_clrspc(dec->image), 0, channo + 1));\n\t\t\t\t}\n#endif\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Mark all components as being of unknown type. *\/\n\n\tfor (i = 0; i < JAS_CAST(uint, jas_image_numcmpts(dec->image)); ++i) {\n\t\tjas_image_setcmpttype(dec->image, i, JAS_IMAGE_CT_UNKNOWN);\n\t}\n\n\t\/* Determine the type of each component. *\/\n\tif (dec->cdef) {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\tjas_image_setcmpttype(dec->image,\n\t\t\t  dec->chantocmptlut[dec->cdef->data.cdef.ents[i].channo],\n\t\t\t  jp2_getct(jas_image_clrspc(dec->image),\n\t\t\t  dec->cdef->data.cdef.ents[i].type, dec->cdef->data.cdef.ents[i].assoc));\n\t\t}\n\t} else {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\tjas_image_setcmpttype(dec->image, dec->chantocmptlut[i],\n\t\t\t  jp2_getct(jas_image_clrspc(dec->image), 0, i + 1));\n\t\t}\n\t}\n\n\t\/* Delete any components that are not of interest. *\/\n\tfor (i = jas_image_numcmpts(dec->image); i > 0; --i) {\n\t\tif (jas_image_cmpttype(dec->image, i - 1) == JAS_IMAGE_CT_UNKNOWN) {\n\t\t\tjas_image_delcmpt(dec->image, i - 1);\n\t\t}\n\t}\n\n\t\/* Ensure that some components survived. *\/\n\tif (!jas_image_numcmpts(dec->image)) {\n\t\tjas_eprintf(\"error: no components\\n\");\n\t\tgoto error;\n\t}\n#if 0\njas_eprintf(\"no of components is %d\\n\", jas_image_numcmpts(dec->image));\n#endif\n\n\t\/* Prevent the image from being destroyed later. *\/\n\timage = dec->image;\n\tdec->image = 0;\n\n\tjp2_dec_destroy(dec);\n\n\treturn image;\n\nerror:\n\tif (box) {\n\t\tjp2_box_destroy(box);\n\t}\n\tif (dec) {\n\t\tjp2_dec_destroy(dec);\n\t}\n\treturn 0;\n}","target":1,"code_token_length":3115,"total_token_length":3351,"max_tokens_setting":4096}
+{"idx":326100,"func":"regrepeat(\n    char_u\t*p,\n    long\tmaxcount)   \/\/ maximum number of matches allowed\n{\n    long\tcount = 0;\n    char_u\t*scan;\n    char_u\t*opnd;\n    int\t\tmask;\n    int\t\ttestval = 0;\n\n    scan = rex.input;\t    \/\/ Make local copy of rex.input for speed.\n    opnd = OPERAND(p);\n    switch (OP(p))\n    {\n      case ANY:\n      case ANY + ADD_NL:\n\twhile (count < maxcount)\n\t{\n\t    \/\/ Matching anything means we continue until end-of-line (or\n\t    \/\/ end-of-file for ANY + ADD_NL), only limited by maxcount.\n\t    while (*scan != NUL && count < maxcount)\n\t    {\n\t\t++count;\n\t\tMB_PTR_ADV(scan);\n\t    }\n\t    if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t      || rex.reg_line_lbr || count == maxcount)\n\t\tbreak;\n\t    ++count;\t\t\/\/ count the line-break\n\t    reg_nextline();\n\t    scan = rex.input;\n\t    if (got_int)\n\t\tbreak;\n\t}\n\tbreak;\n\n      case IDENT:\n      case IDENT + ADD_NL:\n\ttestval = TRUE;\n\t\/\/ FALLTHROUGH\n      case SIDENT:\n      case SIDENT + ADD_NL:\n\twhile (count < maxcount)\n\t{\n\t    if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan)))\n\t    {\n\t\tMB_PTR_ADV(scan);\n\t    }\n\t    else if (*scan == NUL)\n\t    {\n\t\tif (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t\t\t\t   || rex.reg_line_lbr)\n\t\t    break;\n\t\treg_nextline();\n\t\tscan = rex.input;\n\t\tif (got_int)\n\t\t    break;\n\t    }\n\t    else if (rex.reg_line_lbr && *scan == '\\n' && WITH_NL(OP(p)))\n\t\t++scan;\n\t    else\n\t\tbreak;\n\t    ++count;\n\t}\n\tbreak;\n\n      case KWORD:\n      case KWORD + ADD_NL:\n\ttestval = TRUE;\n\t\/\/ FALLTHROUGH\n      case SKWORD:\n      case SKWORD + ADD_NL:\n\twhile (count < maxcount)\n\t{\n\t    if (vim_iswordp_buf(scan, rex.reg_buf)\n\t\t\t\t\t  && (testval || !VIM_ISDIGIT(*scan)))\n\t    {\n\t\tMB_PTR_ADV(scan);\n\t    }\n\t    else if (*scan == NUL)\n\t    {\n\t\tif (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t\t\t\t   || rex.reg_line_lbr)\n\t\t    break;\n\t\treg_nextline();\n\t\tscan = rex.input;\n\t\tif (got_int)\n\t\t    break;\n\t    }\n\t    else if (rex.reg_line_lbr && *scan == '\\n' && WITH_NL(OP(p)))\n\t\t++scan;\n\t    else\n\t\tbreak;\n\t    ++count;\n\t}\n\tbreak;\n\n      case FNAME:\n      case FNAME + ADD_NL:\n\ttestval = TRUE;\n\t\/\/ FALLTHROUGH\n      case SFNAME:\n      case SFNAME + ADD_NL:\n\twhile (count < maxcount)\n\t{\n\t    if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan)))\n\t    {\n\t\tMB_PTR_ADV(scan);\n\t    }\n\t    else if (*scan == NUL)\n\t    {\n\t\tif (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t\t\t\t   || rex.reg_line_lbr)\n\t\t    break;\n\t\treg_nextline();\n\t\tscan = rex.input;\n\t\tif (got_int)\n\t\t    break;\n\t    }\n\t    else if (rex.reg_line_lbr && *scan == '\\n' && WITH_NL(OP(p)))\n\t\t++scan;\n\t    else\n\t\tbreak;\n\t    ++count;\n\t}\n\tbreak;\n\n      case PRINT:\n      case PRINT + ADD_NL:\n\ttestval = TRUE;\n\t\/\/ FALLTHROUGH\n      case SPRINT:\n      case SPRINT + ADD_NL:\n\twhile (count < maxcount)\n\t{\n\t    if (*scan == NUL)\n\t    {\n\t\tif (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t\t\t\t   || rex.reg_line_lbr)\n\t\t    break;\n\t\treg_nextline();\n\t\tscan = rex.input;\n\t\tif (got_int)\n\t\t    break;\n\t    }\n\t    else if (vim_isprintc(PTR2CHAR(scan)) == 1\n\t\t\t\t\t  && (testval || !VIM_ISDIGIT(*scan)))\n\t    {\n\t\tMB_PTR_ADV(scan);\n\t    }\n\t    else if (rex.reg_line_lbr && *scan == '\\n' && WITH_NL(OP(p)))\n\t\t++scan;\n\t    else\n\t\tbreak;\n\t    ++count;\n\t}\n\tbreak;\n\n      case WHITE:\n      case WHITE + ADD_NL:\n\ttestval = mask = RI_WHITE;\ndo_class:\n\twhile (count < maxcount)\n\t{\n\t    int\t\tl;\n\n\t    if (*scan == NUL)\n\t    {\n\t\tif (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t\t\t\t   || rex.reg_line_lbr)\n\t\t    break;\n\t\treg_nextline();\n\t\tscan = rex.input;\n\t\tif (got_int)\n\t\t    break;\n\t    }\n\t    else if (has_mbyte && (l = (*mb_ptr2len)(scan)) > 1)\n\t    {\n\t\tif (testval != 0)\n\t\t    break;\n\t\tscan += l;\n\t    }\n\t    else if ((class_tab[*scan] & mask) == testval)\n\t\t++scan;\n\t    else if (rex.reg_line_lbr && *scan == '\\n' && WITH_NL(OP(p)))\n\t\t++scan;\n\t    else\n\t\tbreak;\n\t    ++count;\n\t}\n\tbreak;\n\n      case NWHITE:\n      case NWHITE + ADD_NL:\n\tmask = RI_WHITE;\n\tgoto do_class;\n      case DIGIT:\n      case DIGIT + ADD_NL:\n\ttestval = mask = RI_DIGIT;\n\tgoto do_class;\n      case NDIGIT:\n      case NDIGIT + ADD_NL:\n\tmask = RI_DIGIT;\n\tgoto do_class;\n      case HEX:\n      case HEX + ADD_NL:\n\ttestval = mask = RI_HEX;\n\tgoto do_class;\n      case NHEX:\n      case NHEX + ADD_NL:\n\tmask = RI_HEX;\n\tgoto do_class;\n      case OCTAL:\n      case OCTAL + ADD_NL:\n\ttestval = mask = RI_OCTAL;\n\tgoto do_class;\n      case NOCTAL:\n      case NOCTAL + ADD_NL:\n\tmask = RI_OCTAL;\n\tgoto do_class;\n      case WORD:\n      case WORD + ADD_NL:\n\ttestval = mask = RI_WORD;\n\tgoto do_class;\n      case NWORD:\n      case NWORD + ADD_NL:\n\tmask = RI_WORD;\n\tgoto do_class;\n      case HEAD:\n      case HEAD + ADD_NL:\n\ttestval = mask = RI_HEAD;\n\tgoto do_class;\n      case NHEAD:\n      case NHEAD + ADD_NL:\n\tmask = RI_HEAD;\n\tgoto do_class;\n      case ALPHA:\n      case ALPHA + ADD_NL:\n\ttestval = mask = RI_ALPHA;\n\tgoto do_class;\n      case NALPHA:\n      case NALPHA + ADD_NL:\n\tmask = RI_ALPHA;\n\tgoto do_class;\n      case LOWER:\n      case LOWER + ADD_NL:\n\ttestval = mask = RI_LOWER;\n\tgoto do_class;\n      case NLOWER:\n      case NLOWER + ADD_NL:\n\tmask = RI_LOWER;\n\tgoto do_class;\n      case UPPER:\n      case UPPER + ADD_NL:\n\ttestval = mask = RI_UPPER;\n\tgoto do_class;\n      case NUPPER:\n      case NUPPER + ADD_NL:\n\tmask = RI_UPPER;\n\tgoto do_class;\n\n      case EXACTLY:\n\t{\n\t    int\t    cu, cl;\n\n\t    \/\/ This doesn't do a multi-byte character, because a MULTIBYTECODE\n\t    \/\/ would have been used for it.  It does handle single-byte\n\t    \/\/ characters, such as latin1.\n\t    if (rex.reg_ic)\n\t    {\n\t\tcu = MB_TOUPPER(*opnd);\n\t\tcl = MB_TOLOWER(*opnd);\n\t\twhile (count < maxcount && (*scan == cu || *scan == cl))\n\t\t{\n\t\t    count++;\n\t\t    scan++;\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tcu = *opnd;\n\t\twhile (count < maxcount && *scan == cu)\n\t\t{\n\t\t    count++;\n\t\t    scan++;\n\t\t}\n\t    }\n\t    break;\n\t}\n\n      case MULTIBYTECODE:\n\t{\n\t    int\t\ti, len, cf = 0;\n\n\t    \/\/ Safety check (just in case 'encoding' was changed since\n\t    \/\/ compiling the program).\n\t    if ((len = (*mb_ptr2len)(opnd)) > 1)\n\t    {\n\t\tif (rex.reg_ic && enc_utf8)\n\t\t    cf = utf_fold(utf_ptr2char(opnd));\n\t\twhile (count < maxcount && (*mb_ptr2len)(scan) >= len)\n\t\t{\n\t\t    for (i = 0; i < len; ++i)\n\t\t\tif (opnd[i] != scan[i])\n\t\t\t    break;\n\t\t    if (i < len && (!rex.reg_ic || !enc_utf8\n\t\t\t\t\t|| utf_fold(utf_ptr2char(scan)) != cf))\n\t\t\tbreak;\n\t\t    scan += len;\n\t\t    ++count;\n\t\t}\n\t    }\n\t}\n\tbreak;\n\n      case ANYOF:\n      case ANYOF + ADD_NL:\n\ttestval = TRUE;\n\t\/\/ FALLTHROUGH\n\n      case ANYBUT:\n      case ANYBUT + ADD_NL:\n\twhile (count < maxcount)\n\t{\n\t    int len;\n\n\t    if (*scan == NUL)\n\t    {\n\t\tif (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline\n\t\t\t\t\t\t\t   || rex.reg_line_lbr)\n\t\t    break;\n\t\treg_nextline();\n\t\tscan = rex.input;\n\t\tif (got_int)\n\t\t    break;\n\t    }\n\t    else if (rex.reg_line_lbr && *scan == '\\n' && WITH_NL(OP(p)))\n\t\t++scan;\n\t    else if (has_mbyte && (len = (*mb_ptr2len)(scan)) > 1)\n\t    {\n\t\tif ((cstrchr(opnd, (*mb_ptr2char)(scan)) == NULL) == testval)\n\t\t    break;\n\t\tscan += len;\n\t    }\n\t    else\n\t    {\n\t\tif ((cstrchr(opnd, *scan) == NULL) == testval)\n\t\t    break;\n\t\t++scan;\n\t    }\n\t    ++count;\n\t}\n\tbreak;\n\n      case NEWL:\n\twhile (count < maxcount\n\t\t&& ((*scan == NUL && rex.lnum <= rex.reg_maxline\n\t\t\t\t       && !rex.reg_line_lbr && REG_MULTI)\n\t\t    || (*scan == '\\n' && rex.reg_line_lbr)))\n\t{\n\t    count++;\n\t    if (rex.reg_line_lbr)\n\t\tADVANCE_REGINPUT();\n\t    else\n\t\treg_nextline();\n\t    scan = rex.input;\n\t    if (got_int)\n\t\tbreak;\n\t}\n\tbreak;\n\n      default:\t\t\t\/\/ Oh dear.  Called inappropriately.\n\tiemsg(_(e_corrupted_regexp_program));\n#ifdef DEBUG\n\tprintf(\"Called regrepeat with op code %d\\n\", OP(p));\n#endif\n\tbreak;\n    }\n\n    rex.input = scan;\n\n    return (int)count;\n}","target":0,"code_token_length":2442,"total_token_length":2678,"max_tokens_setting":4096}
+{"idx":230454,"func":"ra_input(void)\n{\n  uip_lladdr_t lladdr_aligned;\n\n  LOG_INFO(\"Received RA from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\" to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\"\\n\");\n  UIP_STAT(++uip_stat.nd6.recv);\n\n#if UIP_CONF_IPV6_CHECKS\n  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||\n     (!uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr)) ||\n     (UIP_ICMP_BUF->icode != 0)) {\n    LOG_ERR(\"RA received is bad\");\n    goto discard;\n  }\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n\n  if(UIP_ND6_RA_BUF->cur_ttl != 0) {\n    uip_ds6_if.cur_hop_limit = UIP_ND6_RA_BUF->cur_ttl;\n    LOG_INFO(\"uip_ds6_if.cur_hop_limit %u\\n\", uip_ds6_if.cur_hop_limit);\n  }\n\n  if(UIP_ND6_RA_BUF->reachable_time != 0) {\n    if(uip_ds6_if.base_reachable_time !=\n       uip_ntohl(UIP_ND6_RA_BUF->reachable_time)) {\n      uip_ds6_if.base_reachable_time = uip_ntohl(UIP_ND6_RA_BUF->reachable_time);\n      uip_ds6_if.reachable_time = uip_ds6_compute_reachable_time();\n    }\n  }\n  if(UIP_ND6_RA_BUF->retrans_timer != 0) {\n    uip_ds6_if.retrans_timer = uip_ntohl(UIP_ND6_RA_BUF->retrans_timer);\n  }\n\n  \/* Options processing *\/\n  nd6_opt_offset = UIP_ND6_RA_LEN;\n  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {\n    if(ND6_OPT_HDR_BUF(nd6_opt_offset)->len == 0) {\n      LOG_ERR(\"RA received is bad\");\n      goto discard;\n    }\n    switch (ND6_OPT_HDR_BUF(nd6_opt_offset)->type) {\n    case UIP_ND6_OPT_SLLAO:\n      LOG_DBG(\"Processing SLLAO option in RA\\n\");\n      nd6_opt_llao = (uint8_t *) ND6_OPT_HDR_BUF(nd6_opt_offset);\n      nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);\n      if(!extract_lladdr_from_llao_aligned(&lladdr_aligned)) {\n        \/* failed to extract llao - discard packet *\/\n        goto discard;\n      }\n      if(nbr == NULL) {\n        nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,\n                              1, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);\n      } else {\n        const uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(nbr);\n        if(lladdr == NULL) {\n          goto discard;\n        }\n        if(nbr->state == NBR_INCOMPLETE) {\n          nbr->state = NBR_STALE;\n        }\n        if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],\n                  lladdr, UIP_LLADDR_LEN) != 0) {\n          \/* change of link layer address *\/\n          if(uip_ds6_nbr_update_ll(&nbr,\n                                   (const uip_lladdr_t *)&lladdr_aligned) < 0) {\n            \/* failed to update the lladdr *\/\n            goto discard;\n          }\n          nbr->state = NBR_STALE;\n        }\n        nbr->isrouter = 1;\n      }\n      break;\n    case UIP_ND6_OPT_MTU:\n      LOG_DBG(\"Processing MTU option in RA\\n\");\n      uip_ds6_if.link_mtu =\n        uip_ntohl(((uip_nd6_opt_mtu *) ND6_OPT_HDR_BUF(nd6_opt_offset))->mtu);\n      break;\n    case UIP_ND6_OPT_PREFIX_INFO:\n      LOG_DBG(\"Processing PREFIX option in RA\\n\");\n      nd6_opt_prefix_info = (uip_nd6_opt_prefix_info *) ND6_OPT_HDR_BUF(nd6_opt_offset);\n      if((uip_ntohl(nd6_opt_prefix_info->validlt) >=\n          uip_ntohl(nd6_opt_prefix_info->preferredlt))\n         && (!uip_is_addr_linklocal(&nd6_opt_prefix_info->prefix))) {\n        \/* on-link flag related processing *\/\n        if(nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_ONLINK) {\n          prefix =\n            uip_ds6_prefix_lookup(&nd6_opt_prefix_info->prefix,\n                                  nd6_opt_prefix_info->preflen);\n          if(prefix == NULL) {\n            if(nd6_opt_prefix_info->validlt != 0) {\n              if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {\n                prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,\n                                            nd6_opt_prefix_info->preflen,\n                                            uip_ntohl(nd6_opt_prefix_info->\n                                                  validlt));\n              } else {\n                prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,\n                                            nd6_opt_prefix_info->preflen, 0);\n              }\n            }\n          } else {\n            switch (nd6_opt_prefix_info->validlt) {\n            case 0:\n              uip_ds6_prefix_rm(prefix);\n              break;\n            case UIP_ND6_INFINITE_LIFETIME:\n              prefix->isinfinite = 1;\n              break;\n            default:\n              LOG_DBG(\"Updating timer of prefix \");\n              LOG_DBG_6ADDR(&prefix->ipaddr);\n              LOG_DBG_(\" new value %\"PRIu32\"\\n\", uip_ntohl(nd6_opt_prefix_info->validlt));\n              stimer_set(&prefix->vlifetime,\n                         uip_ntohl(nd6_opt_prefix_info->validlt));\n              prefix->isinfinite = 0;\n              break;\n            }\n          }\n        }\n        \/* End of on-link flag related processing *\/\n        \/* autonomous flag related processing *\/\n        if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS)\n           && (nd6_opt_prefix_info->validlt != 0)\n           && (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) {\n\n          uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix);\n          uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);\n          addr = uip_ds6_addr_lookup(&ipaddr);\n          if((addr != NULL) && (addr->type == ADDR_AUTOCONF)) {\n            if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {\n              \/* The processing below is defined in RFC4862 section 5.5.3 e *\/\n              if((uip_ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) ||\n                 (uip_ntohl(nd6_opt_prefix_info->validlt) >\n                  stimer_remaining(&addr->vlifetime))) {\n                LOG_DBG(\"Updating timer of address \");\n                LOG_DBG_6ADDR(&addr->ipaddr);\n                LOG_DBG_(\" new value %lu\\n\",\n                       (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt));\n                stimer_set(&addr->vlifetime,\n                           uip_ntohl(nd6_opt_prefix_info->validlt));\n              } else {\n                stimer_set(&addr->vlifetime, 2 * 60 * 60);\n                LOG_DBG(\"Updating timer of address \");\n                LOG_DBG_6ADDR(&addr->ipaddr);\n                LOG_DBG_(\" new value %lu\\n\", (unsigned long)(2 * 60 * 60));\n              }\n              addr->isinfinite = 0;\n            } else {\n              addr->isinfinite = 1;\n            }\n          } else {\n            if(uip_ntohl(nd6_opt_prefix_info->validlt) ==\n               UIP_ND6_INFINITE_LIFETIME) {\n              uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);\n            } else {\n              uip_ds6_addr_add(&ipaddr, uip_ntohl(nd6_opt_prefix_info->validlt),\n                               ADDR_AUTOCONF);\n            }\n          }\n        }\n        \/* End of autonomous flag related processing *\/\n      }\n      break;\n#if UIP_ND6_RA_RDNSS\n    case UIP_ND6_OPT_RDNSS:\n      LOG_DBG(\"Processing RDNSS option\\n\");\n      uint8_t naddr = (ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len - 1) \/ 2;\n      uip_ipaddr_t *ip = (uip_ipaddr_t *)(&ND6_OPT_RDNSS_BUF(nd6_opt_offset)->ip);\n      LOG_DBG(\"got %d nameservers\\n\", naddr);\n      while(naddr-- > 0) {\n        LOG_DBG(\"nameserver: \");\n        LOG_DBG_6ADDR(ip);\n        LOG_DBG_(\" lifetime: %\"PRIx32\"\\n\", uip_ntohl(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime));\n        uip_nameserver_update(ip, uip_ntohl(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime));\n        ip++;\n      }\n      break;\n#endif \/* UIP_ND6_RA_RDNSS *\/\n    default:\n      LOG_ERR(\"ND option not supported in RA\\n\");\n      break;\n    }\n    nd6_opt_offset += (ND6_OPT_HDR_BUF(nd6_opt_offset)->len << 3);\n  }\n\n  defrt = uip_ds6_defrt_lookup(&UIP_IP_BUF->srcipaddr);\n  if(UIP_ND6_RA_BUF->router_lifetime != 0) {\n    if(nbr != NULL) {\n      nbr->isrouter = 1;\n    }\n    if(defrt == NULL) {\n      uip_ds6_defrt_add(&UIP_IP_BUF->srcipaddr,\n                        (unsigned\n                         long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime)));\n    } else {\n      stimer_set(&(defrt->lifetime),\n                 (unsigned long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime)));\n    }\n  } else {\n    if(defrt != NULL) {\n      uip_ds6_defrt_rm(defrt);\n    }\n  }\n\n#if UIP_CONF_IPV6_QUEUE_PKT\n  \/* If the nbr just became reachable (e.g. it was in NBR_INCOMPLETE state\n   * and we got a SLLAO), check if we had buffered a pkt for it *\/\n  \/*  if((nbr != NULL) && (nbr->queue_buf_len != 0)) {\n    uip_len = nbr->queue_buf_len;\n    memcpy(UIP_IP_BUF, nbr->queue_buf, uip_len);\n    nbr->queue_buf_len = 0;\n    return;\n    }*\/\n  if(nbr != NULL && uip_packetqueue_buflen(&nbr->packethandle) != 0) {\n    uip_len = uip_packetqueue_buflen(&nbr->packethandle);\n    memcpy(UIP_IP_BUF, uip_packetqueue_buf(&nbr->packethandle), uip_len);\n    uip_packetqueue_free(&nbr->packethandle);\n    return;\n  }\n\n#endif \/*UIP_CONF_IPV6_QUEUE_PKT *\/\n\ndiscard:\n  uipbuf_clear();\n  return;\n}","target":0,"code_token_length":2434,"total_token_length":2670,"max_tokens_setting":4096}
+{"idx":273407,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor* x_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"x\", &x_tensor));\n\n    const Tensor* cs_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"cs_prev\", &cs_prev_tensor));\n\n    const Tensor* h_prev_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"h_prev\", &h_prev_tensor));\n\n    const Tensor* w_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"w\", &w_tensor));\n\n    const Tensor* wci_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wci\", &wci_tensor));\n\n    const Tensor* wcf_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wcf\", &wcf_tensor));\n\n    const Tensor* wco_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"wco\", &wco_tensor));\n\n    const Tensor* b_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->input(\"b\", &b_tensor));\n\n    const int64_t batch_size = x_tensor->dim_size(0);\n    const int64_t input_size = x_tensor->dim_size(1);\n    const int64_t cell_size = cs_prev_tensor->dim_size(1);\n\n    \/\/ Sanity checks for our input shapes.\n    OP_REQUIRES(ctx, cs_prev_tensor->dim_size(0) == batch_size,\n                errors::InvalidArgument(\"cs_prev.dims(0) != batch_size: \",\n                                        cs_prev_tensor->dim_size(0), \" vs. \",\n                                        batch_size));\n    OP_REQUIRES(ctx, cs_prev_tensor->dim_size(1) == cell_size,\n                errors::InvalidArgument(\"cs_prev.dims(1) != cell_size: \",\n                                        cs_prev_tensor->dim_size(1), \" vs. \",\n                                        cell_size));\n\n    OP_REQUIRES(ctx, h_prev_tensor->dim_size(0) == batch_size,\n                errors::InvalidArgument(\"h_prev.dims(0) != batch_size: \",\n                                        h_prev_tensor->dim_size(0), \" vs. \",\n                                        batch_size));\n    OP_REQUIRES(ctx, h_prev_tensor->dim_size(1) == cell_size,\n                errors::InvalidArgument(\n                    \"h_prev.dims(1) != cell_size: \", h_prev_tensor->dim_size(1),\n                    \" vs. \", cell_size));\n\n    OP_REQUIRES(ctx, w_tensor->dim_size(0) == input_size + cell_size,\n                errors::InvalidArgument(\n                    \"w.dim_size(0) != input_size + cell_size: \",\n                    w_tensor->dim_size(0), \" vs. \", input_size + cell_size));\n    OP_REQUIRES(ctx, w_tensor->dim_size(1) == cell_size * 4,\n                errors::InvalidArgument(\n                    \"w.dim_size(1) != cell_size * 4: \", w_tensor->dim_size(1),\n                    \" vs. \", cell_size * 4));\n\n    OP_REQUIRES(ctx, b_tensor->dim_size(0) == cell_size * 4,\n                errors::InvalidArgument(\n                    \"b.dim_size(0) != cell_size * 4: \", b_tensor->dim_size(0),\n                    \" vs. \", cell_size * 4));\n\n    \/\/ Allocate our output tensors.\n    Tensor* i_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n                            {\"h_prev\"}, \"i\",\n                            TensorShape({batch_size, cell_size}), &i_tensor));\n\n    Tensor* cs_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"cs\", TensorShape({batch_size, cell_size}),\n                                  &cs_tensor));\n\n    Tensor* f_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"f\", TensorShape({batch_size, cell_size}),\n                                  &f_tensor));\n\n    Tensor* o_tensor = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n                            {\"cs_prev\"}, \"o\",\n                            TensorShape({batch_size, cell_size}), &o_tensor));\n\n    Tensor* ci_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"ci\", TensorShape({batch_size, cell_size}),\n                                  &ci_tensor));\n\n    Tensor* co_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"co\", TensorShape({batch_size, cell_size}),\n                                  &co_tensor));\n\n    Tensor* h_tensor = nullptr;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(\"h\", TensorShape({batch_size, cell_size}),\n                                  &h_tensor));\n\n    \/\/ Allocate our temp tensors.\n    Tensor xh_tensor;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(\n                            DataTypeToEnum<T>::v(),\n                            TensorShape({batch_size, input_size + cell_size}),\n                            &xh_tensor));\n\n    Tensor gates_tensor;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_temp(DataTypeToEnum<T>::v(),\n                                      TensorShape({batch_size, cell_size * 4}),\n                                      &gates_tensor));\n\n    const Device& device = ctx->eigen_device<Device>();\n\n    \/\/ Sanity check that each of the tensors have the required NDIMS.\n    OP_REQUIRES(ctx, x_tensor->dims() == 2,\n                errors::InvalidArgument(\"x_tensor must be rank 2 but is rank \",\n                                        x_tensor->dims(), \".\"));\n    OP_REQUIRES(\n        ctx, cs_prev_tensor->dims() == 2,\n        errors::InvalidArgument(\"cs_prev_tensor must be rank 2 but is rank \",\n                                cs_prev_tensor->dims(), \".\"));\n    OP_REQUIRES(\n        ctx, h_prev_tensor->dims() == 2,\n        errors::InvalidArgument(\"h_prev_tensor must be rank 2 but is rank \",\n                                h_prev_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, w_tensor->dims() == 2,\n                errors::InvalidArgument(\"w_tensor must be rank 2 but is rank \",\n                                        w_tensor->dims(), \".\"));\n    OP_REQUIRES(\n        ctx, wci_tensor->dims() == 1,\n        errors::InvalidArgument(\"wci_tensor must be rank 1 but is rank \",\n                                wci_tensor->dims(), \".\"));\n    OP_REQUIRES(\n        ctx, wcf_tensor->dims() == 1,\n        errors::InvalidArgument(\"wcf_tensor must be rank 1 but is rank \",\n                                wci_tensor->dims(), \".\"));\n    OP_REQUIRES(\n        ctx, wco_tensor->dims() == 1,\n        errors::InvalidArgument(\"wco_tensor must be rank 1 but is rank \",\n                                wco_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, b_tensor->dims() == 1,\n                errors::InvalidArgument(\"b_tensor must be rank 1 but is rank \",\n                                        b_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, xh_tensor.dims() == 2,\n                errors::InvalidArgument(\"xh_tensor must be rank 2 but is rank \",\n                                        xh_tensor.dims(), \".\"));\n    OP_REQUIRES(ctx, i_tensor->dims() == 2,\n                errors::InvalidArgument(\"i_tensor must be rank 2 but is rank \",\n                                        i_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, cs_tensor->dims() == 2,\n                errors::InvalidArgument(\"cs_tensor must be rank 2 but is rank \",\n                                        cs_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, f_tensor->dims() == 2,\n                errors::InvalidArgument(\"f_tensor must be rank 2 but is rank \",\n                                        f_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, o_tensor->dims() == 2,\n                errors::InvalidArgument(\"o_tensor must be rank 2 but is rank \",\n                                        o_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, ci_tensor->dims() == 2,\n                errors::InvalidArgument(\"ci_tensor must be rank 2 but is rank \",\n                                        ci_tensor->dims(), \".\"));\n    OP_REQUIRES(ctx, co_tensor->dims() == 2,\n                errors::InvalidArgument(\"co_tensor must be rank 2 but is rank \",\n                                        co_tensor->dims(), \".\"));\n    OP_REQUIRES(\n        ctx, gates_tensor.dims() == 2,\n        errors::InvalidArgument(\"gates_tensor must be rank 2 but is rank \",\n                                gates_tensor.dims(), \".\"));\n    OP_REQUIRES(ctx, h_tensor->dims() == 2,\n                errors::InvalidArgument(\"h_tensor must be rank 2 but is rank \",\n                                        h_tensor->dims(), \".\"));\n\n    functor::LSTMBlockCellFprop<Device, T, USE_CUBLAS, gate_layout>(\n        batch_size, input_size, cell_size)(\n        ctx, device, forget_bias_, cell_clip_, use_peephole_,\n        x_tensor->matrix<T>(), cs_prev_tensor->matrix<T>(),\n        h_prev_tensor->matrix<T>(), w_tensor->matrix<T>(), wci_tensor->vec<T>(),\n        wcf_tensor->vec<T>(), wco_tensor->vec<T>(), b_tensor->vec<T>(),\n        xh_tensor.matrix<T>(), i_tensor->matrix<T>(), cs_tensor->matrix<T>(),\n        f_tensor->matrix<T>(), o_tensor->matrix<T>(), ci_tensor->matrix<T>(),\n        co_tensor->matrix<T>(), gates_tensor.matrix<T>(),\n        h_tensor->matrix<T>());\n  }","target":0,"code_token_length":1987,"total_token_length":2223,"max_tokens_setting":4096}
+{"idx":215162,"func":"diff_mark_adjust_tp(\n    tabpage_T\t*tp,\n    int\t\tidx,\n    linenr_T\tline1,\n    linenr_T\tline2,\n    long\tamount,\n    long\tamount_after)\n{\n    diff_T\t*dp;\n    diff_T\t*dprev;\n    diff_T\t*dnext;\n    int\t\ti;\n    int\t\tinserted, deleted;\n    int\t\tn, off;\n    linenr_T\tlast;\n    linenr_T\tlnum_deleted = line1;\t\/\/ lnum of remaining deletion\n    int\t\tcheck_unchanged;\n\n    if (diff_internal())\n    {\n\t\/\/ Will update diffs before redrawing.  Set _invalid to update the\n\t\/\/ diffs themselves, set _update to also update folds properly just\n\t\/\/ before redrawing.\n\t\/\/ Do update marks here, it is needed for :%diffput.\n\ttp->tp_diff_invalid = TRUE;\n\ttp->tp_diff_update = TRUE;\n    }\n\n    if (line2 == MAXLNUM)\n    {\n\t\/\/ mark_adjust(99, MAXLNUM, 9, 0): insert lines\n\tinserted = amount;\n\tdeleted = 0;\n    }\n    else if (amount_after > 0)\n    {\n\t\/\/ mark_adjust(99, 98, MAXLNUM, 9): a change that inserts lines\n\tinserted = amount_after;\n\tdeleted = 0;\n    }\n    else\n    {\n\t\/\/ mark_adjust(98, 99, MAXLNUM, -2): delete lines\n\tinserted = 0;\n\tdeleted = -amount_after;\n    }\n\n    dprev = NULL;\n    dp = tp->tp_first_diff;\n    for (;;)\n    {\n\t\/\/ If the change is after the previous diff block and before the next\n\t\/\/ diff block, thus not touching an existing change, create a new diff\n\t\/\/ block.  Don't do this when ex_diffgetput() is busy.\n\tif ((dp == NULL || dp->df_lnum[idx] - 1 > line2\n\t\t    || (line2 == MAXLNUM && dp->df_lnum[idx] > line1))\n\t\t&& (dprev == NULL\n\t\t    || dprev->df_lnum[idx] + dprev->df_count[idx] < line1)\n\t\t&& !diff_busy)\n\t{\n\t    dnext = diff_alloc_new(tp, dprev, dp);\n\t    if (dnext == NULL)\n\t\treturn;\n\n\t    dnext->df_lnum[idx] = line1;\n\t    dnext->df_count[idx] = inserted;\n\t    for (i = 0; i < DB_COUNT; ++i)\n\t\tif (tp->tp_diffbuf[i] != NULL && i != idx)\n\t\t{\n\t\t    if (dprev == NULL)\n\t\t\tdnext->df_lnum[i] = line1;\n\t\t    else\n\t\t\tdnext->df_lnum[i] = line1\n\t\t\t    + (dprev->df_lnum[i] + dprev->df_count[i])\n\t\t\t    - (dprev->df_lnum[idx] + dprev->df_count[idx]);\n\t\t    dnext->df_count[i] = deleted;\n\t\t}\n\t}\n\n\t\/\/ if at end of the list, quit\n\tif (dp == NULL)\n\t    break;\n\n\t\/*\n\t * Check for these situations:\n\t *\t  1  2\t3\n\t *\t  1  2\t3\n\t * line1     2\t3  4  5\n\t *\t     2\t3  4  5\n\t *\t     2\t3  4  5\n\t * line2     2\t3  4  5\n\t *\t\t3     5  6\n\t *\t\t3     5  6\n\t *\/\n\t\/\/ compute last line of this change\n\tlast = dp->df_lnum[idx] + dp->df_count[idx] - 1;\n\n\t\/\/ 1. change completely above line1: nothing to do\n\tif (last >= line1 - 1)\n\t{\n\t    \/\/ 6. change below line2: only adjust for amount_after; also when\n\t    \/\/ \"deleted\" became zero when deleted all lines between two diffs\n\t    if (dp->df_lnum[idx] - (deleted + inserted != 0) > line2)\n\t    {\n\t\tif (amount_after == 0)\n\t\t    break;\t\/\/ nothing left to change\n\t\tdp->df_lnum[idx] += amount_after;\n\t    }\n\t    else\n\t    {\n\t\tcheck_unchanged = FALSE;\n\n\t\t\/\/ 2. 3. 4. 5.: inserted\/deleted lines touching this diff.\n\t\tif (deleted > 0)\n\t\t{\n\t\t    if (dp->df_lnum[idx] >= line1)\n\t\t    {\n\t\t\toff = dp->df_lnum[idx] - lnum_deleted;\n\t\t\tif (last <= line2)\n\t\t\t{\n\t\t\t    \/\/ 4. delete all lines of diff\n\t\t\t    if (dp->df_next != NULL\n\t\t\t\t    && dp->df_next->df_lnum[idx] - 1 <= line2)\n\t\t\t    {\n\t\t\t\t\/\/ delete continues in next diff, only do\n\t\t\t\t\/\/ lines until that one\n\t\t\t\tn = dp->df_next->df_lnum[idx] - lnum_deleted;\n\t\t\t\tdeleted -= n;\n\t\t\t\tn -= dp->df_count[idx];\n\t\t\t\tlnum_deleted = dp->df_next->df_lnum[idx];\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tn = deleted - dp->df_count[idx];\n\t\t\t    dp->df_count[idx] = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ 5. delete lines at or just before top of diff\n\t\t\t    n = off;\n\t\t\t    dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;\n\t\t\t    check_unchanged = TRUE;\n\t\t\t}\n\t\t\tdp->df_lnum[idx] = line1;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\toff = 0;\n\t\t\tif (last < line2)\n\t\t\t{\n\t\t\t    \/\/ 2. delete at end of diff\n\t\t\t    dp->df_count[idx] -= last - lnum_deleted + 1;\n\t\t\t    if (dp->df_next != NULL\n\t\t\t\t    && dp->df_next->df_lnum[idx] - 1 <= line2)\n\t\t\t    {\n\t\t\t\t\/\/ delete continues in next diff, only do\n\t\t\t\t\/\/ lines until that one\n\t\t\t\tn = dp->df_next->df_lnum[idx] - 1 - last;\n\t\t\t\tdeleted -= dp->df_next->df_lnum[idx]\n\t\t\t\t\t\t\t       - lnum_deleted;\n\t\t\t\tlnum_deleted = dp->df_next->df_lnum[idx];\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tn = line2 - last;\n\t\t\t    check_unchanged = TRUE;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ 3. delete lines inside the diff\n\t\t\t    n = 0;\n\t\t\t    dp->df_count[idx] -= deleted;\n\t\t\t}\n\t\t    }\n\n\t\t    for (i = 0; i < DB_COUNT; ++i)\n\t\t\tif (tp->tp_diffbuf[i] != NULL && i != idx)\n\t\t\t{\n\t\t\t    dp->df_lnum[i] -= off;\n\t\t\t    dp->df_count[i] += n;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (dp->df_lnum[idx] <= line1)\n\t\t    {\n\t\t\t\/\/ inserted lines somewhere in this diff\n\t\t\tdp->df_count[idx] += inserted;\n\t\t\tcheck_unchanged = TRUE;\n\t\t    }\n\t\t    else\n\t\t\t\/\/ inserted lines somewhere above this diff\n\t\t\tdp->df_lnum[idx] += inserted;\n\t\t}\n\n\t\tif (check_unchanged)\n\t\t    \/\/ Check if inserted lines are equal, may reduce the\n\t\t    \/\/ size of the diff.  TODO: also check for equal lines\n\t\t    \/\/ in the middle and perhaps split the block.\n\t\t    diff_check_unchanged(tp, dp);\n\t    }\n\t}\n\n\t\/\/ check if this block touches the previous one, may merge them.\n\tif (dprev != NULL && dprev->df_lnum[idx] + dprev->df_count[idx]\n\t\t\t\t\t\t\t  == dp->df_lnum[idx])\n\t{\n\t    for (i = 0; i < DB_COUNT; ++i)\n\t\tif (tp->tp_diffbuf[i] != NULL)\n\t\t    dprev->df_count[i] += dp->df_count[i];\n\t    dprev->df_next = dp->df_next;\n\t    vim_free(dp);\n\t    dp = dprev->df_next;\n\t}\n\telse\n\t{\n\t    \/\/ Advance to next entry.\n\t    dprev = dp;\n\t    dp = dp->df_next;\n\t}\n    }\n\n    dprev = NULL;\n    dp = tp->tp_first_diff;\n    while (dp != NULL)\n    {\n\t\/\/ All counts are zero, remove this entry.\n\tfor (i = 0; i < DB_COUNT; ++i)\n\t    if (tp->tp_diffbuf[i] != NULL && dp->df_count[i] != 0)\n\t\tbreak;\n\tif (i == DB_COUNT)\n\t{\n\t    dnext = dp->df_next;\n\t    vim_free(dp);\n\t    dp = dnext;\n\t    if (dprev == NULL)\n\t\ttp->tp_first_diff = dnext;\n\t    else\n\t\tdprev->df_next = dnext;\n\t}\n\telse\n\t{\n\t    \/\/ Advance to next entry.\n\t    dprev = dp;\n\t    dp = dp->df_next;\n\t}\n\n    }\n\n    if (tp == curtab)\n    {\n\t\/\/ Don't redraw right away, this updates the diffs, which can be slow.\n\tneed_diff_redraw = TRUE;\n\n\t\/\/ Need to recompute the scroll binding, may remove or add filler\n\t\/\/ lines (e.g., when adding lines above w_topline). But it's slow when\n\t\/\/ making many changes, postpone until redrawing.\n\tdiff_need_scrollbind = TRUE;\n    }\n}","target":1,"code_token_length":2091,"total_token_length":2327,"max_tokens_setting":4096}
+{"idx":231796,"func":"void processClientInitialParams(\n    QuicServerConnectionState& conn,\n    const ClientTransportParameters& clientParams) {\n  \/\/ TODO validate that we didn't receive original connection ID, stateless\n  \/\/ reset token, or preferred address.\n  auto maxData = getIntegerParameter(\n      TransportParameterId::initial_max_data, clientParams.parameters);\n  auto maxStreamDataBidiLocal = getIntegerParameter(\n      TransportParameterId::initial_max_stream_data_bidi_local,\n      clientParams.parameters);\n  auto maxStreamDataBidiRemote = getIntegerParameter(\n      TransportParameterId::initial_max_stream_data_bidi_remote,\n      clientParams.parameters);\n  auto maxStreamDataUni = getIntegerParameter(\n      TransportParameterId::initial_max_stream_data_uni,\n      clientParams.parameters);\n  auto maxStreamsBidi = getIntegerParameter(\n      TransportParameterId::initial_max_streams_bidi, clientParams.parameters);\n  auto maxStreamsUni = getIntegerParameter(\n      TransportParameterId::initial_max_streams_uni, clientParams.parameters);\n  auto idleTimeout = getIntegerParameter(\n      TransportParameterId::idle_timeout, clientParams.parameters);\n  auto ackDelayExponent = getIntegerParameter(\n      TransportParameterId::ack_delay_exponent, clientParams.parameters);\n  auto packetSize = getIntegerParameter(\n      TransportParameterId::max_packet_size, clientParams.parameters);\n  auto partialReliability = getIntegerParameter(\n      static_cast<TransportParameterId>(kPartialReliabilityParameterId),\n      clientParams.parameters);\n  auto activeConnectionIdLimit = getIntegerParameter(\n      TransportParameterId::active_connection_id_limit,\n      clientParams.parameters);\n  auto d6dBasePMTU = getIntegerParameter(\n      static_cast<TransportParameterId>(kD6DBasePMTUParameterId),\n      clientParams.parameters);\n  auto d6dRaiseTimeout = getIntegerParameter(\n      static_cast<TransportParameterId>(kD6DRaiseTimeoutParameterId),\n      clientParams.parameters);\n  auto d6dProbeTimeout = getIntegerParameter(\n      static_cast<TransportParameterId>(kD6DProbeTimeoutParameterId),\n      clientParams.parameters);\n  auto minAckDelay = getIntegerParameter(\n      TransportParameterId::min_ack_delay, clientParams.parameters);\n  if (conn.version == QuicVersion::QUIC_DRAFT) {\n    auto initialSourceConnId = getConnIdParameter(\n        TransportParameterId::initial_source_connection_id,\n        clientParams.parameters);\n    if (!initialSourceConnId ||\n        initialSourceConnId.value() !=\n            conn.readCodec->getClientConnectionId()) {\n      throw QuicTransportException(\n          \"Initial CID does not match.\",\n          TransportErrorCode::TRANSPORT_PARAMETER_ERROR);\n    }\n  }\n\n  \/\/ TODO Validate active_connection_id_limit\n  if (packetSize && *packetSize < kMinMaxUDPPayload) {\n    throw QuicTransportException(\n        folly::to<std::string>(\n            \"Max packet size too small. received max_packetSize = \",\n            *packetSize),\n        TransportErrorCode::TRANSPORT_PARAMETER_ERROR);\n  }\n\n  VLOG(10) << \"Client advertised flow control \";\n  VLOG(10) << \"conn=\" << maxData.value_or(0);\n  VLOG(10) << \" stream bidi local=\" << maxStreamDataBidiLocal.value_or(0)\n           << \" \";\n  VLOG(10) << \" stream bidi remote=\" << maxStreamDataBidiRemote.value_or(0)\n           << \" \";\n  VLOG(10) << \" stream uni=\" << maxStreamDataUni.value_or(0) << \" \";\n  VLOG(10) << conn;\n  conn.flowControlState.peerAdvertisedMaxOffset = maxData.value_or(0);\n  conn.flowControlState.peerAdvertisedInitialMaxStreamOffsetBidiLocal =\n      maxStreamDataBidiLocal.value_or(0);\n  conn.flowControlState.peerAdvertisedInitialMaxStreamOffsetBidiRemote =\n      maxStreamDataBidiRemote.value_or(0);\n  conn.flowControlState.peerAdvertisedInitialMaxStreamOffsetUni =\n      maxStreamDataUni.value_or(0);\n  conn.streamManager->setMaxLocalBidirectionalStreams(\n      maxStreamsBidi.value_or(0));\n  conn.streamManager->setMaxLocalUnidirectionalStreams(\n      maxStreamsUni.value_or(0));\n  conn.peerIdleTimeout = std::chrono::milliseconds(idleTimeout.value_or(0));\n  conn.peerIdleTimeout = timeMin(conn.peerIdleTimeout, kMaxIdleTimeout);\n  if (ackDelayExponent && *ackDelayExponent > kMaxAckDelayExponent) {\n    throw QuicTransportException(\n        \"ack_delay_exponent too large\",\n        TransportErrorCode::TRANSPORT_PARAMETER_ERROR);\n  }\n  conn.peerAckDelayExponent =\n      ackDelayExponent.value_or(kDefaultAckDelayExponent);\n  if (minAckDelay.hasValue()) {\n    conn.peerMinAckDelay = std::chrono::microseconds(minAckDelay.value());\n  }\n\n  \/\/ Default to max because we can probe PMTU now, and this will be the upper\n  \/\/ limit\n  uint64_t maxUdpPayloadSize = kDefaultMaxUDPPayload;\n  if (packetSize) {\n    maxUdpPayloadSize = std::min(*packetSize, maxUdpPayloadSize);\n    conn.peerMaxUdpPayloadSize = maxUdpPayloadSize;\n    if (conn.transportSettings.canIgnorePathMTU) {\n      if (*packetSize > kDefaultMaxUDPPayload) {\n        \/\/ A good peer should never set oversized limit, so to be safe we\n        \/\/ fallback to default\n        conn.udpSendPacketLen = kDefaultUDPSendPacketLen;\n      } else {\n        \/\/ Otherwise, canIgnorePathMTU forces us to immediately set\n        \/\/ udpSendPacketLen\n        \/\/ TODO: rename \"canIgnorePathMTU\" to \"forciblySetPathMTU\"\n        conn.udpSendPacketLen = maxUdpPayloadSize;\n      }\n    }\n  }\n\n  conn.peerActiveConnectionIdLimit =\n      activeConnectionIdLimit.value_or(kDefaultActiveConnectionIdLimit);\n\n  if (partialReliability && *partialReliability != 0 &&\n      conn.transportSettings.partialReliabilityEnabled) {\n    conn.partialReliabilityEnabled = true;\n  }\n  VLOG(10) << \"conn.partialReliabilityEnabled=\"\n           << conn.partialReliabilityEnabled;\n\n  if (conn.transportSettings.d6dConfig.enabled) {\n    \/\/ Sanity check\n    if (d6dBasePMTU) {\n      if (*d6dBasePMTU >= kMinMaxUDPPayload &&\n          *d6dBasePMTU <= kDefaultMaxUDPPayload) {\n        \/\/ The reason to take the max is because we don't want d6d to send\n        \/\/ probes with a smaller packet size than udpSendPacketLen, which would\n        \/\/ be useless and cause meaningless delay on finding the upper bound.\n        conn.d6d.basePMTU = std::max(*d6dBasePMTU, conn.udpSendPacketLen);\n        conn.d6d.maxPMTU = maxUdpPayloadSize;\n        VLOG(10) << \"conn.d6d.basePMTU=\" << conn.d6d.basePMTU;\n\n        \/\/ Start from base\n        conn.d6d.state = D6DMachineState::BASE;\n        conn.d6d.meta.lastNonSearchState = D6DMachineState::DISABLED;\n        conn.d6d.meta.timeLastNonSearchState = Clock::now();\n\n        \/\/ Temporary, should be removed after transport knob pipeline works\n        conn.d6d.noBlackholeDetection = true;\n      } else {\n        LOG(ERROR) << \"client d6dBasePMTU fails sanity check: \" << *d6dBasePMTU;\n        \/\/ We treat base pmtu transport param as client's swich to activate d6d,\n        \/\/ so not receiving that means there's no need to configure the rest d6d\n        \/\/ params\n        return;\n      }\n    }\n\n    if (d6dRaiseTimeout) {\n      if (*d6dRaiseTimeout >= kMinD6DRaiseTimeout.count()) {\n        conn.d6d.raiseTimeout = std::chrono::seconds(*d6dRaiseTimeout);\n        VLOG(10) << \"conn.d6d.raiseTimeout=\" << conn.d6d.raiseTimeout.count();\n      } else {\n        LOG(ERROR) << \"client d6dRaiseTimeout fails sanity check: \"\n                   << *d6dRaiseTimeout;\n      }\n    }\n\n    if (d6dProbeTimeout) {\n      if (*d6dProbeTimeout >= kMinD6DProbeTimeout.count()) {\n        conn.d6d.probeTimeout = std::chrono::seconds(*d6dProbeTimeout);\n        VLOG(10) << \"conn.d6d.probeTimeout=\" << conn.d6d.probeTimeout.count();\n      } else {\n        LOG(ERROR) << \"client d6dProbeTimeout fails sanity check: \"\n                   << *d6dProbeTimeout;\n      }\n    }\n  }\n}","target":0,"code_token_length":1917,"total_token_length":2153,"max_tokens_setting":4096}
+{"idx":252419,"func":"int LoadEXR(float **out_rgba, int *width, int *height, const char *filename,\n            const char **err) {\n  if (out_rgba == NULL) {\n    tinyexr::SetErrorMessage(\"Invalid argument for LoadEXR()\", err);\n    return TINYEXR_ERROR_INVALID_ARGUMENT;\n  }\n\n  EXRVersion exr_version;\n  EXRImage exr_image;\n  EXRHeader exr_header;\n  InitEXRHeader(&exr_header);\n  InitEXRImage(&exr_image);\n\n  {\n    int ret = ParseEXRVersionFromFile(&exr_version, filename);\n    if (ret != TINYEXR_SUCCESS) {\n      tinyexr::SetErrorMessage(\"Invalid EXR header.\", err);\n      return ret;\n    }\n\n    if (exr_version.multipart || exr_version.non_image) {\n      tinyexr::SetErrorMessage(\n          \"Loading multipart or DeepImage is not supported  in LoadEXR() API\",\n          err);\n      return TINYEXR_ERROR_INVALID_DATA;  \/\/ @fixme.\n    }\n  }\n\n  {\n    int ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, filename, err);\n    if (ret != TINYEXR_SUCCESS) {\n      FreeEXRHeader(&exr_header);\n      return ret;\n    }\n  }\n\n  \/\/ Read HALF channel as FLOAT.\n  for (int i = 0; i < exr_header.num_channels; i++) {\n    if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) {\n      exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;\n    }\n  }\n\n  {\n    int ret = LoadEXRImageFromFile(&exr_image, &exr_header, filename, err);\n    if (ret != TINYEXR_SUCCESS) {\n      FreeEXRHeader(&exr_header);\n      return ret;\n    }\n  }\n\n  \/\/ RGBA\n  int idxR = -1;\n  int idxG = -1;\n  int idxB = -1;\n  int idxA = -1;\n  for (int c = 0; c < exr_header.num_channels; c++) {\n    if (strcmp(exr_header.channels[c].name, \"R\") == 0) {\n      idxR = c;\n    } else if (strcmp(exr_header.channels[c].name, \"G\") == 0) {\n      idxG = c;\n    } else if (strcmp(exr_header.channels[c].name, \"B\") == 0) {\n      idxB = c;\n    } else if (strcmp(exr_header.channels[c].name, \"A\") == 0) {\n      idxA = c;\n    }\n  }\n\n  if (exr_header.num_channels == 1) {\n    \/\/ Grayscale channel only.\n\n    (*out_rgba) = reinterpret_cast<float *>(\n        malloc(4 * sizeof(float) * static_cast<size_t>(exr_image.width) *\n               static_cast<size_t>(exr_image.height)));\n\n    if (exr_header.tiled) {\n      for (int it = 0; it < exr_image.num_tiles; it++) {\n        for (int j = 0; j < exr_header.tile_size_y; j++) {\n          for (int i = 0; i < exr_header.tile_size_x; i++) {\n            const int ii =\n                exr_image.tiles[it].offset_x * exr_header.tile_size_x + i;\n            const int jj =\n                exr_image.tiles[it].offset_y * exr_header.tile_size_y + j;\n            const int idx = ii + jj * exr_image.width;\n\n            \/\/ out of region check.\n            if (ii >= exr_image.width) {\n              continue;\n            }\n            if (jj >= exr_image.height) {\n              continue;\n            }\n            const int srcIdx = i + j * exr_header.tile_size_x;\n            unsigned char **src = exr_image.tiles[it].images;\n            (*out_rgba)[4 * idx + 0] =\n                reinterpret_cast<float **>(src)[0][srcIdx];\n            (*out_rgba)[4 * idx + 1] =\n                reinterpret_cast<float **>(src)[0][srcIdx];\n            (*out_rgba)[4 * idx + 2] =\n                reinterpret_cast<float **>(src)[0][srcIdx];\n            (*out_rgba)[4 * idx + 3] =\n                reinterpret_cast<float **>(src)[0][srcIdx];\n          }\n        }\n      }\n    } else {\n      for (int i = 0; i < exr_image.width * exr_image.height; i++) {\n        const float val = reinterpret_cast<float **>(exr_image.images)[0][i];\n        (*out_rgba)[4 * i + 0] = val;\n        (*out_rgba)[4 * i + 1] = val;\n        (*out_rgba)[4 * i + 2] = val;\n        (*out_rgba)[4 * i + 3] = val;\n      }\n    }\n  } else {\n    \/\/ Assume RGB(A)\n\n    if (idxR == -1) {\n      tinyexr::SetErrorMessage(\"R channel not found\", err);\n\n      \/\/ @todo { free exr_image }\n      FreeEXRHeader(&exr_header);\n      return TINYEXR_ERROR_INVALID_DATA;\n    }\n\n    if (idxG == -1) {\n      tinyexr::SetErrorMessage(\"G channel not found\", err);\n      \/\/ @todo { free exr_image }\n      FreeEXRHeader(&exr_header);\n      return TINYEXR_ERROR_INVALID_DATA;\n    }\n\n    if (idxB == -1) {\n      tinyexr::SetErrorMessage(\"B channel not found\", err);\n      \/\/ @todo { free exr_image }\n      FreeEXRHeader(&exr_header);\n      return TINYEXR_ERROR_INVALID_DATA;\n    }\n\n    (*out_rgba) = reinterpret_cast<float *>(\n        malloc(4 * sizeof(float) * static_cast<size_t>(exr_image.width) *\n               static_cast<size_t>(exr_image.height)));\n    if (exr_header.tiled) {\n      for (int it = 0; it < exr_image.num_tiles; it++) {\n        for (int j = 0; j < exr_header.tile_size_y; j++) {\n          for (int i = 0; i < exr_header.tile_size_x; i++) {\n            const int ii =\n                exr_image.tiles[it].offset_x * exr_header.tile_size_x + i;\n            const int jj =\n                exr_image.tiles[it].offset_y * exr_header.tile_size_y + j;\n            const int idx = ii + jj * exr_image.width;\n\n            \/\/ out of region check.\n            if (ii >= exr_image.width) {\n              continue;\n            }\n            if (jj >= exr_image.height) {\n              continue;\n            }\n            const int srcIdx = i + j * exr_header.tile_size_x;\n            unsigned char **src = exr_image.tiles[it].images;\n            (*out_rgba)[4 * idx + 0] =\n                reinterpret_cast<float **>(src)[idxR][srcIdx];\n            (*out_rgba)[4 * idx + 1] =\n                reinterpret_cast<float **>(src)[idxG][srcIdx];\n            (*out_rgba)[4 * idx + 2] =\n                reinterpret_cast<float **>(src)[idxB][srcIdx];\n            if (idxA != -1) {\n              (*out_rgba)[4 * idx + 3] =\n                  reinterpret_cast<float **>(src)[idxA][srcIdx];\n            } else {\n              (*out_rgba)[4 * idx + 3] = 1.0;\n            }\n          }\n        }\n      }\n    } else {\n      for (int i = 0; i < exr_image.width * exr_image.height; i++) {\n        (*out_rgba)[4 * i + 0] =\n            reinterpret_cast<float **>(exr_image.images)[idxR][i];\n        (*out_rgba)[4 * i + 1] =\n            reinterpret_cast<float **>(exr_image.images)[idxG][i];\n        (*out_rgba)[4 * i + 2] =\n            reinterpret_cast<float **>(exr_image.images)[idxB][i];\n        if (idxA != -1) {\n          (*out_rgba)[4 * i + 3] =\n              reinterpret_cast<float **>(exr_image.images)[idxA][i];\n        } else {\n          (*out_rgba)[4 * i + 3] = 1.0;\n        }\n      }\n    }\n  }\n\n  (*width) = exr_image.width;\n  (*height) = exr_image.height;\n\n  FreeEXRHeader(&exr_header);\n  FreeEXRImage(&exr_image);\n\n  return TINYEXR_SUCCESS;\n}","target":0,"code_token_length":1872,"total_token_length":2108,"max_tokens_setting":4096}
+{"idx":355649,"func":"eval7(\n    char_u\t**arg,\n    typval_T\t*rettv,\n    evalarg_T\t*evalarg,\n    int\t\twant_string)\t\/\/ after \".\" operator\n{\n    int\t\tevaluate = evalarg != NULL\n\t\t\t\t      && (evalarg->eval_flags & EVAL_EVALUATE);\n    int\t\tlen;\n    char_u\t*s;\n    char_u\t*name_start = NULL;\n    char_u\t*start_leader, *end_leader;\n    int\t\tret = OK;\n    char_u\t*alias;\n    static\tint recurse = 0;\n\n    \/*\n     * Initialise variable so that clear_tv() can't mistake this for a\n     * string and free a string that isn't there.\n     *\/\n    rettv->v_type = VAR_UNKNOWN;\n\n    \/*\n     * Skip '!', '-' and '+' characters.  They are handled later.\n     *\/\n    start_leader = *arg;\n    if (eval_leader(arg, in_vim9script()) == FAIL)\n\treturn FAIL;\n    end_leader = *arg;\n\n    if (**arg == '.' && (!isdigit(*(*arg + 1))\n#ifdef FEAT_FLOAT\n\t    || in_old_script(2)\n#endif\n\t    ))\n    {\n\tsemsg(_(e_invalid_expression_str), *arg);\n\t++*arg;\n\treturn FAIL;\n    }\n\n    \/\/ Limit recursion to 1000 levels.  At least at 10000 we run out of stack\n    \/\/ and crash.\n    if (recurse == 1000)\n    {\n\tsemsg(_(e_expression_too_recursive_str), *arg);\n\treturn FAIL;\n    }\n    ++recurse;\n\n    switch (**arg)\n    {\n    \/*\n     * Number constant.\n     *\/\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9':\n    case '.':\tret = eval_number(arg, rettv, evaluate, want_string);\n\n\t\t\/\/ Apply prefixed \"-\" and \"+\" now.  Matters especially when\n\t\t\/\/ \"->\" follows.\n\t\tif (ret == OK && evaluate && end_leader > start_leader\n\t\t\t\t\t\t  && rettv->v_type != VAR_BLOB)\n\t\t    ret = eval7_leader(rettv, TRUE, start_leader, &end_leader);\n\t\tbreak;\n\n    \/*\n     * String constant: \"string\".\n     *\/\n    case '\"':\tret = eval_string(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * Literal string constant: 'str''ing'.\n     *\/\n    case '\\'':\tret = eval_lit_string(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * List: [expr, expr]\n     *\/\n    case '[':\tret = eval_list(arg, rettv, evalarg, TRUE);\n\t\tbreak;\n\n    \/*\n     * Dictionary: #{key: val, key: val}\n     *\/\n    case '#':\tif (in_vim9script())\n\t\t{\n\t\t    ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE;\n\t\t}\n\t\telse if ((*arg)[1] == '{')\n\t\t{\n\t\t    ++*arg;\n\t\t    ret = eval_dict(arg, rettv, evalarg, TRUE);\n\t\t}\n\t\telse\n\t\t    ret = NOTDONE;\n\t\tbreak;\n\n    \/*\n     * Lambda: {arg, arg -> expr}\n     * Dictionary: {'key': val, 'key': val}\n     *\/\n    case '{':\tif (in_vim9script())\n\t\t    ret = NOTDONE;\n\t\telse\n\t\t    ret = get_lambda_tv(arg, rettv, in_vim9script(), evalarg);\n\t\tif (ret == NOTDONE)\n\t\t    ret = eval_dict(arg, rettv, evalarg, FALSE);\n\t\tbreak;\n\n    \/*\n     * Option value: &name\n     *\/\n    case '&':\tret = eval_option(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * Environment variable: $VAR.\n     *\/\n    case '$':\tret = eval_env_var(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * Register contents: @r.\n     *\/\n    case '@':\t++*arg;\n\t\tif (evaluate)\n\t\t{\n\t\t    if (in_vim9script() && IS_WHITE_OR_NUL(**arg))\n\t\t\tsemsg(_(e_syntax_error_at_str), *arg);\n\t\t    else if (in_vim9script() && !valid_yank_reg(**arg, FALSE))\n\t\t\temsg_invreg(**arg);\n\t\t    else\n\t\t    {\n\t\t\trettv->v_type = VAR_STRING;\n\t\t\trettv->vval.v_string = get_reg_contents(**arg,\n\t\t\t\t\t\t\t\tGREG_EXPR_SRC);\n\t\t    }\n\t\t}\n\t\tif (**arg != NUL)\n\t\t    ++*arg;\n\t\tbreak;\n\n    \/*\n     * nested expression: (expression).\n     * or lambda: (arg) => expr\n     *\/\n    case '(':\tret = NOTDONE;\n\t\tif (in_vim9script())\n\t\t{\n\t\t    ret = get_lambda_tv(arg, rettv, TRUE, evalarg);\n\t\t    if (ret == OK && evaluate)\n\t\t    {\n\t\t\tufunc_T *ufunc = rettv->vval.v_partial->pt_func;\n\n\t\t\t\/\/ Compile it here to get the return type.  The return\n\t\t\t\/\/ type is optional, when it's missing use t_unknown.\n\t\t\t\/\/ This is recognized in compile_return().\n\t\t\tif (ufunc->uf_ret_type->tt_type == VAR_VOID)\n\t\t\t    ufunc->uf_ret_type = &t_unknown;\n\t\t\tif (compile_def_function(ufunc,\n\t\t\t\t     FALSE, COMPILE_TYPE(ufunc), NULL) == FAIL)\n\t\t\t{\n\t\t\t    clear_tv(rettv);\n\t\t\t    ret = FAIL;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (ret == NOTDONE)\n\t\t{\n\t\t    *arg = skipwhite_and_linebreak(*arg + 1, evalarg);\n\t\t    ret = eval1(arg, rettv, evalarg);\t\/\/ recursive!\n\n\t\t    *arg = skipwhite_and_linebreak(*arg, evalarg);\n\t\t    if (**arg == ')')\n\t\t\t++*arg;\n\t\t    else if (ret == OK)\n\t\t    {\n\t\t\temsg(_(e_missing_closing_paren));\n\t\t\tclear_tv(rettv);\n\t\t\tret = FAIL;\n\t\t    }\n\t\t}\n\t\tbreak;\n\n    default:\tret = NOTDONE;\n\t\tbreak;\n    }\n\n    if (ret == NOTDONE)\n    {\n\t\/*\n\t * Must be a variable or function name.\n\t * Can also be a curly-braces kind of name: {expr}.\n\t *\/\n\ts = *arg;\n\tlen = get_name_len(arg, &alias, evaluate, TRUE);\n\tif (alias != NULL)\n\t    s = alias;\n\n\tif (len <= 0)\n\t    ret = FAIL;\n\telse\n\t{\n\t    int\t    flags = evalarg == NULL ? 0 : evalarg->eval_flags;\n\n\t    if (evaluate && in_vim9script() && len == 1 && *s == '_')\n\t    {\n\t\temsg(_(e_cannot_use_underscore_here));\n\t\tret = FAIL;\n\t    }\n\t    else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')\n\t    {\n\t\t\/\/ \"name(...\"  recursive!\n\t\t*arg = skipwhite(*arg);\n\t\tret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);\n\t    }\n\t    else if (flags & EVAL_CONSTANT)\n\t\tret = FAIL;\n\t    else if (evaluate)\n\t    {\n\t\t\/\/ get the value of \"true\", \"false\" or a variable\n\t\tif (len == 4 && in_vim9script() && STRNCMP(s, \"true\", 4) == 0)\n\t\t{\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = VVAL_TRUE;\n\t\t    ret = OK;\n\t\t}\n\t\telse if (len == 5 && in_vim9script()\n\t\t\t\t\t\t&& STRNCMP(s, \"false\", 5) == 0)\n\t\t{\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = VVAL_FALSE;\n\t\t    ret = OK;\n\t\t}\n\t\telse if (len == 4 && in_vim9script()\n\t\t\t\t\t\t&& STRNCMP(s, \"null\", 4) == 0)\n\t\t{\n\t\t    rettv->v_type = VAR_SPECIAL;\n\t\t    rettv->vval.v_number = VVAL_NULL;\n\t\t    ret = OK;\n\t\t}\n\t\telse\n\t\t{\n\t\t    name_start = s;\n\t\t    ret = eval_variable(s, len, 0, rettv, NULL,\n\t\t\t\t\t   EVAL_VAR_VERBOSE + EVAL_VAR_IMPORT);\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ skip the name\n\t\tcheck_vars(s, len);\n\t\tret = OK;\n\t    }\n\t}\n\tvim_free(alias);\n    }\n\n    \/\/ Handle following '[', '(' and '.' for expr[expr], expr.name,\n    \/\/ expr(expr), expr->name(expr)\n    if (ret == OK)\n\tret = handle_subscript(arg, name_start, rettv, evalarg, TRUE);\n\n    \/*\n     * Apply logical NOT and unary '-', from right to left, ignore '+'.\n     *\/\n    if (ret == OK && evaluate && end_leader > start_leader)\n\tret = eval7_leader(rettv, FALSE, start_leader, &end_leader);\n\n    --recurse;\n    return ret;\n}","target":0,"code_token_length":1981,"total_token_length":2217,"max_tokens_setting":4096}
+{"idx":204243,"func":"eval7(\n    char_u\t**arg,\n    typval_T\t*rettv,\n    evalarg_T\t*evalarg,\n    int\t\twant_string)\t\/\/ after \".\" operator\n{\n    int\t\tevaluate = evalarg != NULL\n\t\t\t\t      && (evalarg->eval_flags & EVAL_EVALUATE);\n    int\t\tlen;\n    char_u\t*s;\n    char_u\t*name_start = NULL;\n    char_u\t*start_leader, *end_leader;\n    int\t\tret = OK;\n    char_u\t*alias;\n\n    \/*\n     * Initialise variable so that clear_tv() can't mistake this for a\n     * string and free a string that isn't there.\n     *\/\n    rettv->v_type = VAR_UNKNOWN;\n\n    \/*\n     * Skip '!', '-' and '+' characters.  They are handled later.\n     *\/\n    start_leader = *arg;\n    if (eval_leader(arg, in_vim9script()) == FAIL)\n\treturn FAIL;\n    end_leader = *arg;\n\n    if (**arg == '.' && (!isdigit(*(*arg + 1))\n#ifdef FEAT_FLOAT\n\t    || in_old_script(2)\n#endif\n\t    ))\n    {\n\tsemsg(_(e_invalid_expression_str), *arg);\n\t++*arg;\n\treturn FAIL;\n    }\n\n    switch (**arg)\n    {\n    \/*\n     * Number constant.\n     *\/\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9':\n    case '.':\tret = eval_number(arg, rettv, evaluate, want_string);\n\n\t\t\/\/ Apply prefixed \"-\" and \"+\" now.  Matters especially when\n\t\t\/\/ \"->\" follows.\n\t\tif (ret == OK && evaluate && end_leader > start_leader\n\t\t\t\t\t\t  && rettv->v_type != VAR_BLOB)\n\t\t    ret = eval7_leader(rettv, TRUE, start_leader, &end_leader);\n\t\tbreak;\n\n    \/*\n     * String constant: \"string\".\n     *\/\n    case '\"':\tret = eval_string(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * Literal string constant: 'str''ing'.\n     *\/\n    case '\\'':\tret = eval_lit_string(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * List: [expr, expr]\n     *\/\n    case '[':\tret = eval_list(arg, rettv, evalarg, TRUE);\n\t\tbreak;\n\n    \/*\n     * Dictionary: #{key: val, key: val}\n     *\/\n    case '#':\tif (in_vim9script())\n\t\t{\n\t\t    ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE;\n\t\t}\n\t\telse if ((*arg)[1] == '{')\n\t\t{\n\t\t    ++*arg;\n\t\t    ret = eval_dict(arg, rettv, evalarg, TRUE);\n\t\t}\n\t\telse\n\t\t    ret = NOTDONE;\n\t\tbreak;\n\n    \/*\n     * Lambda: {arg, arg -> expr}\n     * Dictionary: {'key': val, 'key': val}\n     *\/\n    case '{':\tif (in_vim9script())\n\t\t    ret = NOTDONE;\n\t\telse\n\t\t    ret = get_lambda_tv(arg, rettv, in_vim9script(), evalarg);\n\t\tif (ret == NOTDONE)\n\t\t    ret = eval_dict(arg, rettv, evalarg, FALSE);\n\t\tbreak;\n\n    \/*\n     * Option value: &name\n     *\/\n    case '&':\tret = eval_option(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * Environment variable: $VAR.\n     *\/\n    case '$':\tret = eval_env_var(arg, rettv, evaluate);\n\t\tbreak;\n\n    \/*\n     * Register contents: @r.\n     *\/\n    case '@':\t++*arg;\n\t\tif (evaluate)\n\t\t{\n\t\t    if (in_vim9script() && IS_WHITE_OR_NUL(**arg))\n\t\t\tsemsg(_(e_syntax_error_at_str), *arg);\n\t\t    else if (in_vim9script() && !valid_yank_reg(**arg, FALSE))\n\t\t\temsg_invreg(**arg);\n\t\t    else\n\t\t    {\n\t\t\trettv->v_type = VAR_STRING;\n\t\t\trettv->vval.v_string = get_reg_contents(**arg,\n\t\t\t\t\t\t\t\tGREG_EXPR_SRC);\n\t\t    }\n\t\t}\n\t\tif (**arg != NUL)\n\t\t    ++*arg;\n\t\tbreak;\n\n    \/*\n     * nested expression: (expression).\n     * or lambda: (arg) => expr\n     *\/\n    case '(':\tret = NOTDONE;\n\t\tif (in_vim9script())\n\t\t{\n\t\t    ret = get_lambda_tv(arg, rettv, TRUE, evalarg);\n\t\t    if (ret == OK && evaluate)\n\t\t    {\n\t\t\tufunc_T *ufunc = rettv->vval.v_partial->pt_func;\n\n\t\t\t\/\/ Compile it here to get the return type.  The return\n\t\t\t\/\/ type is optional, when it's missing use t_unknown.\n\t\t\t\/\/ This is recognized in compile_return().\n\t\t\tif (ufunc->uf_ret_type->tt_type == VAR_VOID)\n\t\t\t    ufunc->uf_ret_type = &t_unknown;\n\t\t\tif (compile_def_function(ufunc,\n\t\t\t\t     FALSE, COMPILE_TYPE(ufunc), NULL) == FAIL)\n\t\t\t{\n\t\t\t    clear_tv(rettv);\n\t\t\t    ret = FAIL;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (ret == NOTDONE)\n\t\t{\n\t\t    *arg = skipwhite_and_linebreak(*arg + 1, evalarg);\n\t\t    ret = eval1(arg, rettv, evalarg);\t\/\/ recursive!\n\n\t\t    *arg = skipwhite_and_linebreak(*arg, evalarg);\n\t\t    if (**arg == ')')\n\t\t\t++*arg;\n\t\t    else if (ret == OK)\n\t\t    {\n\t\t\temsg(_(e_missing_closing_paren));\n\t\t\tclear_tv(rettv);\n\t\t\tret = FAIL;\n\t\t    }\n\t\t}\n\t\tbreak;\n\n    default:\tret = NOTDONE;\n\t\tbreak;\n    }\n\n    if (ret == NOTDONE)\n    {\n\t\/*\n\t * Must be a variable or function name.\n\t * Can also be a curly-braces kind of name: {expr}.\n\t *\/\n\ts = *arg;\n\tlen = get_name_len(arg, &alias, evaluate, TRUE);\n\tif (alias != NULL)\n\t    s = alias;\n\n\tif (len <= 0)\n\t    ret = FAIL;\n\telse\n\t{\n\t    int\t    flags = evalarg == NULL ? 0 : evalarg->eval_flags;\n\n\t    if (evaluate && in_vim9script() && len == 1 && *s == '_')\n\t    {\n\t\temsg(_(e_cannot_use_underscore_here));\n\t\tret = FAIL;\n\t    }\n\t    else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')\n\t    {\n\t\t\/\/ \"name(...\"  recursive!\n\t\t*arg = skipwhite(*arg);\n\t\tret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);\n\t    }\n\t    else if (flags & EVAL_CONSTANT)\n\t\tret = FAIL;\n\t    else if (evaluate)\n\t    {\n\t\t\/\/ get the value of \"true\", \"false\" or a variable\n\t\tif (len == 4 && in_vim9script() && STRNCMP(s, \"true\", 4) == 0)\n\t\t{\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = VVAL_TRUE;\n\t\t    ret = OK;\n\t\t}\n\t\telse if (len == 5 && in_vim9script()\n\t\t\t\t\t\t&& STRNCMP(s, \"false\", 5) == 0)\n\t\t{\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = VVAL_FALSE;\n\t\t    ret = OK;\n\t\t}\n\t\telse if (len == 4 && in_vim9script()\n\t\t\t\t\t\t&& STRNCMP(s, \"null\", 4) == 0)\n\t\t{\n\t\t    rettv->v_type = VAR_SPECIAL;\n\t\t    rettv->vval.v_number = VVAL_NULL;\n\t\t    ret = OK;\n\t\t}\n\t\telse\n\t\t{\n\t\t    name_start = s;\n\t\t    ret = eval_variable(s, len, 0, rettv, NULL,\n\t\t\t\t\t   EVAL_VAR_VERBOSE + EVAL_VAR_IMPORT);\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ skip the name\n\t\tcheck_vars(s, len);\n\t\tret = OK;\n\t    }\n\t}\n\tvim_free(alias);\n    }\n\n    \/\/ Handle following '[', '(' and '.' for expr[expr], expr.name,\n    \/\/ expr(expr), expr->name(expr)\n    if (ret == OK)\n\tret = handle_subscript(arg, name_start, rettv, evalarg, TRUE);\n\n    \/*\n     * Apply logical NOT and unary '-', from right to left, ignore '+'.\n     *\/\n    if (ret == OK && evaluate && end_leader > start_leader)\n\tret = eval7_leader(rettv, FALSE, start_leader, &end_leader);\n    return ret;\n}","target":1,"code_token_length":1897,"total_token_length":2133,"max_tokens_setting":4096}
+{"idx":474095,"func":"setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)\n{\n  int type;\n  int r = 0;\n\nrestart:\n  type = NTYPE(node);\n  switch (type) {\n  case NT_LIST:\n    {\n      Node* prev = NULL_NODE;\n      do {\n\tr = setup_tree(NCAR(node), reg, state, env);\n\tif (IS_NOT_NULL(prev) && r == 0) {\n\t  r = next_setup(prev, NCAR(node), reg);\n\t}\n\tprev = NCAR(node);\n      } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));\n    }\n    break;\n\n  case NT_ALT:\n    do {\n      r = setup_tree(NCAR(node), reg, (state | IN_ALT), env);\n    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));\n    break;\n\n  case NT_CCLASS:\n    break;\n\n  case NT_STR:\n    if (IS_IGNORECASE(reg->options) && !NSTRING_IS_RAW(node)) {\n      r = expand_case_fold_string(node, reg);\n    }\n    break;\n\n  case NT_CTYPE:\n  case NT_CANY:\n    break;\n\n#ifdef USE_SUBEXP_CALL\n  case NT_CALL:\n    break;\n#endif\n\n  case NT_BREF:\n    {\n      int i;\n      int* p;\n      Node** nodes = SCANENV_MEM_NODES(env);\n      BRefNode* br = NBREF(node);\n      p = BACKREFS_P(br);\n      for (i = 0; i < br->back_num; i++) {\n\tif (p[i] > env->num_mem)  return ONIGERR_INVALID_BACKREF;\n\tBIT_STATUS_ON_AT(env->backrefed_mem, p[i]);\n\tBIT_STATUS_ON_AT(env->bt_mem_start, p[i]);\n#ifdef USE_BACKREF_WITH_LEVEL\n\tif (IS_BACKREF_NEST_LEVEL(br)) {\n\t  BIT_STATUS_ON_AT(env->bt_mem_end, p[i]);\n\t}\n#endif\n\tSET_ENCLOSE_STATUS(nodes[p[i]], NST_MEM_BACKREFED);\n      }\n    }\n    break;\n\n  case NT_QTFR:\n    {\n      OnigDistance d;\n      QtfrNode* qn = NQTFR(node);\n      Node* target = qn->target;\n\n      if ((state & IN_REPEAT) != 0) {\n        qn->state |= NST_IN_REPEAT;\n      }\n\n      if (IS_REPEAT_INFINITE(qn->upper) || qn->upper >= 1) {\n\tr = get_min_match_length(target, &d, env);\n\tif (r) break;\n\tif (d == 0) {\n\t  qn->target_empty_info = NQ_TARGET_IS_EMPTY;\n#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT\n\t  r = quantifiers_memory_node_info(target);\n\t  if (r < 0) break;\n\t  if (r > 0) {\n\t    qn->target_empty_info = r;\n\t  }\n#endif\n#if 0\n\t  r = get_max_match_length(target, &d, env);\n\t  if (r == 0 && d == 0) {\n\t    \/*  ()* ==> ()?, ()+ ==> ()  *\/\n\t    qn->upper = 1;\n\t    if (qn->lower > 1) qn->lower = 1;\n\t    if (NTYPE(target) == NT_STR) {\n\t      qn->upper = qn->lower = 0;  \/* \/(?:)+\/ ==> \/\/ *\/\n\t    }\n\t  }\n#endif\n\t}\n      }\n\n      state |= IN_REPEAT;\n      if (qn->lower != qn->upper)\n\tstate |= IN_VAR_REPEAT;\n      r = setup_tree(target, reg, state, env);\n      if (r) break;\n\n      \/* expand string *\/\n#define EXPAND_STRING_MAX_LENGTH  100\n      if (NTYPE(target) == NT_STR) {\n\tif (!IS_REPEAT_INFINITE(qn->lower) && qn->lower == qn->upper &&\n\t    qn->lower > 1 && qn->lower <= EXPAND_STRING_MAX_LENGTH) {\n\t  OnigDistance len = NSTRING_LEN(target);\n\t  StrNode* sn = NSTR(target);\n\n\t  if (len * qn->lower <= EXPAND_STRING_MAX_LENGTH) {\n\t    int i, n = qn->lower;\n\t    onig_node_conv_to_str_node(node, NSTR(target)->flag);\n\t    for (i = 0; i < n; i++) {\n\t      r = onig_node_str_cat(node, sn->s, sn->end);\n\t      if (r) break;\n\t    }\n\t    onig_node_free(target);\n\t    break; \/* break case NT_QTFR: *\/\n\t  }\n\t}\n      }\n\n#ifdef USE_OP_PUSH_OR_JUMP_EXACT\n      if (qn->greedy && (qn->target_empty_info != 0)) {\n\tif (NTYPE(target) == NT_QTFR) {\n\t  QtfrNode* tqn = NQTFR(target);\n\t  if (IS_NOT_NULL(tqn->head_exact)) {\n\t    qn->head_exact  = tqn->head_exact;\n\t    tqn->head_exact = NULL;\n\t  }\n\t}\n\telse {\n\t  qn->head_exact = get_head_value_node(qn->target, 1, reg);\n\t}\n      }\n#endif\n    }\n    break;\n\n  case NT_ENCLOSE:\n    {\n      EncloseNode* en = NENCLOSE(node);\n\n      switch (en->type) {\n      case ENCLOSE_OPTION:\n\t{\n\t  OnigOptionType options = reg->options;\n\t  reg->options = NENCLOSE(node)->option;\n\t  r = setup_tree(NENCLOSE(node)->target, reg, state, env);\n\t  reg->options = options;\n\t}\n\tbreak;\n\n      case ENCLOSE_MEMORY:\n\tif ((state & (IN_ALT | IN_NOT | IN_VAR_REPEAT)) != 0) {\n\t  BIT_STATUS_ON_AT(env->bt_mem_start, en->regnum);\n\t  \/* SET_ENCLOSE_STATUS(node, NST_MEM_IN_ALT_NOT); *\/\n\t}\n        r = setup_tree(en->target, reg, state, env);\n        break;\n\n      case ENCLOSE_STOP_BACKTRACK:\n\t{\n\t  Node* target = en->target;\n\t  r = setup_tree(target, reg, state, env);\n\t  if (NTYPE(target) == NT_QTFR) {\n\t    QtfrNode* tqn = NQTFR(target);\n\t    if (IS_REPEAT_INFINITE(tqn->upper) && tqn->lower <= 1 &&\n\t\ttqn->greedy != 0) {  \/* (?>a*), a*+ etc... *\/\n\t      int qtype = NTYPE(tqn->target);\n\t      if (IS_NODE_TYPE_SIMPLE(qtype))\n\t\tSET_ENCLOSE_STATUS(node, NST_STOP_BT_SIMPLE_REPEAT);\n\t    }\n\t  }\n\t}\n\tbreak;\n      }\n    }\n    break;\n\n  case NT_ANCHOR:\n    {\n      AnchorNode* an = NANCHOR(node);\n\n      switch (an->type) {\n      case ANCHOR_PREC_READ:\n\tr = setup_tree(an->target, reg, state, env);\n\tbreak;\n      case ANCHOR_PREC_READ_NOT:\n\tr = setup_tree(an->target, reg, (state | IN_NOT), env);\n\tbreak;\n\n\/* allowed node types in look-behind *\/\n#define ALLOWED_TYPE_IN_LB  \\\n  ( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \\\n    BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL )\n\n#define ALLOWED_ENCLOSE_IN_LB       ( ENCLOSE_MEMORY )\n#define ALLOWED_ENCLOSE_IN_LB_NOT   0\n\n#define ALLOWED_ANCHOR_IN_LB \\\n( ANCHOR_LOOK_BEHIND | ANCHOR_BEGIN_LINE | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION )\n#define ALLOWED_ANCHOR_IN_LB_NOT \\\n( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION )\n\n      case ANCHOR_LOOK_BEHIND:\n\t{\n\t  r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB,\n\t\t\t      ALLOWED_ENCLOSE_IN_LB, ALLOWED_ANCHOR_IN_LB);\n\t  if (r < 0) return r;\n\t  if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;\n\t  r = setup_look_behind(node, reg, env);\n\t  if (r != 0) return r;\n\t  if (NTYPE(node) != NT_ANCHOR) goto restart;\n\t  r = setup_tree(an->target, reg, state, env);\n\t}\n\tbreak;\n\n      case ANCHOR_LOOK_BEHIND_NOT:\n\t{\n\t  r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB,\n\t\t      ALLOWED_ENCLOSE_IN_LB_NOT, ALLOWED_ANCHOR_IN_LB_NOT);\n\t  if (r < 0) return r;\n\t  if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;\n\t  r = setup_look_behind(node, reg, env);\n\t  if (r != 0) return r;\n\t  if (NTYPE(node) != NT_ANCHOR) goto restart;\n\t  r = setup_tree(an->target, reg, (state | IN_NOT), env);\n\t}\n\tbreak;\n      }\n    }\n    break;\n\n  default:\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":2007,"total_token_length":2243,"max_tokens_setting":4096}
+{"idx":509568,"func":"int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)\n{\n  int error= 0;\n  ulonglong local_testflag= param->testflag;\n  bool optimize_done= !do_optimize, statistics_done= 0, full_repair_done= 0;\n  const char *old_proc_info= thd->proc_info;\n  char fixed_name[FN_REFLEN];\n  MARIA_SHARE *share= file->s;\n  ha_rows rows= file->state->records;\n  TRN *old_trn= file->trn;\n  my_bool locking= 0;\n  DBUG_ENTER(\"ha_maria::repair\");\n\n  \/*\n    Normally this method is entered with a properly opened table. If the\n    repair fails, it can be repeated with more elaborate options. Under\n    special circumstances it can happen that a repair fails so that it\n    closed the data file and cannot re-open it. In this case file->dfile\n    is set to -1. We must not try another repair without an open data\n    file. (Bug #25289)\n  *\/\n  if (file->dfile.file == -1)\n  {\n    sql_print_information(\"Retrying repair of: '%s' failed. \"\n                          \"Please try REPAIR EXTENDED or aria_chk\",\n                          table->s->path.str);\n    DBUG_RETURN(HA_ADMIN_FAILED);\n  }\n\n  \/*\n    If transactions was not enabled for a transactional table then\n    file->s->status is not up to date. This is needed for repair_by_sort\n    to work\n  *\/\n  if (share->base.born_transactional && !share->now_transactional)\n    _ma_copy_nontrans_state_information(file);\n\n  param->db_name= table->s->db.str;\n  param->table_name= table->alias.c_ptr();\n  param->tmpfile_createflag= O_RDWR | O_TRUNC;\n  param->using_global_keycache= 1;\n  param->thd= thd;\n  param->tmpdir= &mysql_tmpdir_list;\n  param->out_flag= 0;\n  share->state.dupp_key= MI_MAX_KEY;\n  strmov(fixed_name, share->open_file_name.str);\n  unmap_file(file);\n\n  \/*\n    Don't lock tables if we have used LOCK TABLE or if we come from\n    enable_index()\n  *\/\n  if (!thd->locked_tables_mode && ! (param->testflag & T_NO_LOCKS))\n  {\n    locking= 1;\n    if (maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))\n    {\n      _ma_check_print_error(param, ER_THD(thd, ER_CANT_LOCK), my_errno);\n      DBUG_RETURN(HA_ADMIN_FAILED);\n    }\n  }\n\n  if (!do_optimize ||\n      (((share->data_file_type == BLOCK_RECORD) ?\n        (share->state.changed & STATE_NOT_OPTIMIZED_ROWS) :\n        (file->state->del ||\n         share->state.split != file->state->records)) &&\n       (!(param->testflag & T_QUICK) ||\n        (share->state.changed & (STATE_NOT_OPTIMIZED_KEYS |\n                                 STATE_NOT_OPTIMIZED_ROWS)))))\n  {\n    ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?\n                        maria_get_mask_all_keys_active(share->base.keys) :\n                        share->state.key_map);\n    ulonglong save_testflag= param->testflag;\n    if (maria_test_if_sort_rep(file, file->state->records, key_map, 0) &&\n        (local_testflag & T_REP_BY_SORT))\n    {\n      local_testflag |= T_STATISTICS;\n      param->testflag |= T_STATISTICS;           \/\/ We get this for free\n      statistics_done= 1;\n      \/* TODO: Remove BLOCK_RECORD test when parallel works with blocks *\/\n      if (THDVAR(thd,repair_threads) > 1 &&\n          share->data_file_type != BLOCK_RECORD)\n      {\n        char buf[40];\n        \/* TODO: respect maria_repair_threads variable *\/\n        my_snprintf(buf, 40, \"Repair with %d threads\", my_count_bits(key_map));\n        thd_proc_info(thd, buf);\n        param->testflag|= T_REP_PARALLEL;\n        error= maria_repair_parallel(param, file, fixed_name,\n                                     MY_TEST(param->testflag & T_QUICK));\n        \/* to reset proc_info, as it was pointing to local buffer *\/\n        thd_proc_info(thd, \"Repair done\");\n      }\n      else\n      {\n        thd_proc_info(thd, \"Repair by sorting\");\n        param->testflag|= T_REP_BY_SORT;\n        error= maria_repair_by_sort(param, file, fixed_name,\n                                    MY_TEST(param->testflag & T_QUICK));\n      }\n      if (error && file->create_unique_index_by_sort &&\n          share->state.dupp_key != MAX_KEY)\n      {\n        my_errno= HA_ERR_FOUND_DUPP_KEY;\n        print_keydup_error(table, &table->key_info[share->state.dupp_key],\n                           MYF(0));\n      }\n    }\n    else\n    {\n      thd_proc_info(thd, \"Repair with keycache\");\n      param->testflag &= ~(T_REP_BY_SORT | T_REP_PARALLEL);\n      error= maria_repair(param, file, fixed_name,\n                          MY_TEST(param->testflag & T_QUICK));\n    }\n    param->testflag= save_testflag | (param->testflag & T_RETRY_WITHOUT_QUICK);\n    optimize_done= 1;\n    \/*\n      set full_repair_done if we re-wrote all rows and all keys\n      (and thus removed all transid's from the table\n    *\/\n    full_repair_done= !MY_TEST(param->testflag & T_QUICK);\n  }\n  if (!error)\n  {\n    if ((local_testflag & T_SORT_INDEX) &&\n        (share->state.changed & STATE_NOT_SORTED_PAGES))\n    {\n      optimize_done= 1;\n      thd_proc_info(thd, \"Sorting index\");\n      error= maria_sort_index(param, file, fixed_name);\n    }\n    if (!error && !statistics_done && (local_testflag & T_STATISTICS))\n    {\n      if (share->state.changed & STATE_NOT_ANALYZED)\n      {\n        optimize_done= 1;\n        thd_proc_info(thd, \"Analyzing\");\n        error= maria_chk_key(param, file);\n      }\n      else\n        local_testflag &= ~T_STATISTICS;        \/\/ Don't update statistics\n    }\n  }\n  thd_proc_info(thd, \"Saving state\");\n  if (full_repair_done && !error &&\n      !(param->testflag & T_NO_CREATE_RENAME_LSN))\n  {\n    \/* Set trid (needed if the table was moved from another system) *\/\n    share->state.create_trid= trnman_get_min_safe_trid();\n  }\n  mysql_mutex_lock(&share->intern_lock);\n  if (!error)\n  {\n    if ((share->state.changed & STATE_CHANGED) || maria_is_crashed(file))\n    {\n      DBUG_PRINT(\"info\", (\"Resetting crashed state\"));\n      share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED_FLAGS |\n                               STATE_IN_REPAIR | STATE_MOVED);\n      file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;\n    }\n    \/*\n      repair updates share->state.state. Ensure that file->state is up to date\n    *\/\n    if (file->state != &share->state.state)\n      *file->state= share->state.state;\n\n    if (share->base.auto_key)\n      _ma_update_auto_increment_key(param, file, 1);\n    if (optimize_done)\n      error= maria_update_state_info(param, file,\n                                     UPDATE_TIME | UPDATE_OPEN_COUNT |\n                                     (local_testflag &\n                                      T_STATISTICS ? UPDATE_STAT : 0));\n    \/* File is repaired; Mark the file as moved to this system *\/\n    (void) _ma_set_uuid(share, 0);\n\n    info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |\n         HA_STATUS_CONST);\n    if (rows != file->state->records && !(param->testflag & T_VERY_SILENT))\n    {\n      char llbuff[22], llbuff2[22];\n      _ma_check_print_warning(param, \"Number of rows changed from %s to %s\",\n                              llstr(rows, llbuff),\n                              llstr(file->state->records, llbuff2));\n    }\n  }\n  else\n  {\n    maria_mark_crashed_on_repair(file);\n    file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;\n    maria_update_state_info(param, file, 0);\n  }\n  mysql_mutex_unlock(&share->intern_lock);\n  thd_proc_info(thd, old_proc_info);\n  thd_progress_end(thd);                        \/\/ Mark done\n  if (locking)\n    maria_lock_database(file, F_UNLCK);\n\n  \/* Reset trn, that may have been set by repair *\/\n  if (old_trn && old_trn != file->trn)\n    _ma_set_trn_for_table(file, old_trn);\n  error= error ? HA_ADMIN_FAILED :\n    (optimize_done ?\n     (write_log_record_for_repair(param, file) ? HA_ADMIN_FAILED :\n      HA_ADMIN_OK) : HA_ADMIN_ALREADY_DONE);\n  DBUG_RETURN(error);\n}","target":0,"code_token_length":2025,"total_token_length":2261,"max_tokens_setting":4096}
+{"idx":221508,"func":"flatpak_run_add_app_info_args (FlatpakBwrap       *bwrap,\n                               GFile              *app_files,\n                               GFile              *original_app_files,\n                               GBytes             *app_deploy_data,\n                               const char         *app_extensions,\n                               GFile              *runtime_files,\n                               GFile              *original_runtime_files,\n                               GBytes             *runtime_deploy_data,\n                               const char         *runtime_extensions,\n                               const char         *app_id,\n                               const char         *app_branch,\n                               FlatpakDecomposed  *runtime_ref,\n                               GFile              *app_id_dir,\n                               FlatpakContext     *final_app_context,\n                               FlatpakContext     *cmdline_context,\n                               gboolean            sandbox,\n                               gboolean            build,\n                               gboolean            devel,\n                               char              **app_info_path_out,\n                               int                 instance_id_fd,\n                               char              **instance_id_host_dir_out,\n                               GError             **error)\n{\n  g_autofree char *info_path = NULL;\n  g_autofree char *bwrapinfo_path = NULL;\n  int fd, fd2, fd3;\n  g_autoptr(GKeyFile) keyfile = NULL;\n  g_autofree char *runtime_path = NULL;\n  const char *group;\n  g_autofree char *instance_id = NULL;\n  glnx_autofd int lock_fd = -1;\n  g_autofree char *instance_id_host_dir = NULL;\n  g_autofree char *instance_id_sandbox_dir = NULL;\n  g_autofree char *instance_id_lock_file = NULL;\n  g_autofree char *arch = flatpak_decomposed_dup_arch (runtime_ref);\n\n  g_return_val_if_fail (app_id != NULL, FALSE);\n\n  instance_id = flatpak_instance_allocate_id (&instance_id_host_dir, &lock_fd);\n  if (instance_id == NULL)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Unable to allocate instance id\"));\n\n  instance_id_sandbox_dir = g_strdup_printf (\"\/run\/flatpak\/.flatpak\/%s\", instance_id);\n  instance_id_lock_file = g_build_filename (instance_id_sandbox_dir, \".ref\", NULL);\n\n  flatpak_bwrap_add_args (bwrap,\n                          \"--ro-bind\",\n                          instance_id_host_dir,\n                          instance_id_sandbox_dir,\n                          \"--lock-file\",\n                          instance_id_lock_file,\n                          NULL);\n  flatpak_bwrap_add_runtime_dir_member (bwrap, \".flatpak\");\n  \/* Keep the .ref lock held until we've started bwrap to avoid races *\/\n  flatpak_bwrap_add_noinherit_fd (bwrap, glnx_steal_fd (&lock_fd));\n\n  info_path = g_build_filename (instance_id_host_dir, \"info\", NULL);\n\n  keyfile = g_key_file_new ();\n\n  if (original_app_files)\n    group = FLATPAK_METADATA_GROUP_APPLICATION;\n  else\n    group = FLATPAK_METADATA_GROUP_RUNTIME;\n\n  g_key_file_set_string (keyfile, group, FLATPAK_METADATA_KEY_NAME, app_id);\n  g_key_file_set_string (keyfile, group, FLATPAK_METADATA_KEY_RUNTIME,\n                         flatpak_decomposed_get_ref (runtime_ref));\n\n  g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                         FLATPAK_METADATA_KEY_INSTANCE_ID, instance_id);\n  if (app_id_dir)\n    {\n      g_autofree char *instance_path = g_file_get_path (app_id_dir);\n      g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                             FLATPAK_METADATA_KEY_INSTANCE_PATH, instance_path);\n    }\n\n  if (app_files)\n    {\n      g_autofree char *app_path = g_file_get_path (app_files);\n      g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                             FLATPAK_METADATA_KEY_APP_PATH, app_path);\n    }\n\n  if (original_app_files != NULL && original_app_files != app_files)\n    {\n      g_autofree char *app_path = g_file_get_path (original_app_files);\n      g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                             FLATPAK_METADATA_KEY_ORIGINAL_APP_PATH, app_path);\n    }\n\n  if (app_deploy_data)\n    g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                           FLATPAK_METADATA_KEY_APP_COMMIT, flatpak_deploy_data_get_commit (app_deploy_data));\n  if (app_extensions && *app_extensions != 0)\n    g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                           FLATPAK_METADATA_KEY_APP_EXTENSIONS, app_extensions);\n  runtime_path = g_file_get_path (runtime_files);\n  g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                         FLATPAK_METADATA_KEY_RUNTIME_PATH, runtime_path);\n\n  if (runtime_files != original_runtime_files)\n    {\n      g_autofree char *path = g_file_get_path (original_runtime_files);\n      g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                             FLATPAK_METADATA_KEY_ORIGINAL_RUNTIME_PATH, path);\n    }\n\n  if (runtime_deploy_data)\n    g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                           FLATPAK_METADATA_KEY_RUNTIME_COMMIT, flatpak_deploy_data_get_commit (runtime_deploy_data));\n  if (runtime_extensions && *runtime_extensions != 0)\n    g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                           FLATPAK_METADATA_KEY_RUNTIME_EXTENSIONS, runtime_extensions);\n  if (app_branch != NULL)\n    g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                           FLATPAK_METADATA_KEY_BRANCH, app_branch);\n  g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                         FLATPAK_METADATA_KEY_ARCH, arch);\n\n  g_key_file_set_string (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                         FLATPAK_METADATA_KEY_FLATPAK_VERSION, PACKAGE_VERSION);\n\n  if ((final_app_context->sockets & FLATPAK_CONTEXT_SOCKET_SESSION_BUS) == 0)\n    g_key_file_set_boolean (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                            FLATPAK_METADATA_KEY_SESSION_BUS_PROXY, TRUE);\n\n  if ((final_app_context->sockets & FLATPAK_CONTEXT_SOCKET_SYSTEM_BUS) == 0)\n    g_key_file_set_boolean (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                            FLATPAK_METADATA_KEY_SYSTEM_BUS_PROXY, TRUE);\n\n  if (sandbox)\n    g_key_file_set_boolean (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                            FLATPAK_METADATA_KEY_SANDBOX, TRUE);\n  if (build)\n    g_key_file_set_boolean (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                            FLATPAK_METADATA_KEY_BUILD, TRUE);\n  if (devel)\n    g_key_file_set_boolean (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                            FLATPAK_METADATA_KEY_DEVEL, TRUE);\n\n  if (cmdline_context)\n    {\n      g_autoptr(GPtrArray) cmdline_args = g_ptr_array_new_with_free_func (g_free);\n      flatpak_context_to_args (cmdline_context, cmdline_args);\n      if (cmdline_args->len > 0)\n        {\n          g_key_file_set_string_list (keyfile, FLATPAK_METADATA_GROUP_INSTANCE,\n                                      FLATPAK_METADATA_KEY_EXTRA_ARGS,\n                                      (const char * const *) cmdline_args->pdata,\n                                      cmdline_args->len);\n        }\n    }\n\n  flatpak_context_save_metadata (final_app_context, TRUE, keyfile);\n\n  if (!g_key_file_save_to_file (keyfile, info_path, error))\n    return FALSE;\n\n  \/* We want to create a file on \/.flatpak-info that the app cannot modify, which\n     we do by creating a read-only bind mount. This way one can openat()\n     \/proc\/$pid\/root, and if that succeeds use openat via that to find the\n     unfakable .flatpak-info file. However, there is a tiny race in that if\n     you manage to open \/proc\/$pid\/root, but then the pid dies, then\n     every mount but the root is unmounted in the namespace, so the\n     .flatpak-info will be empty. We fix this by first creating a real file\n     with the real info in, then bind-mounting on top of that, the same info.\n     This way even if the bind-mount is unmounted we can find the real data.\n   *\/\n\n  fd = open (info_path, O_RDONLY);\n  if (fd == -1)\n    {\n      int errsv = errno;\n      g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),\n                   _(\"Failed to open flatpak-info file: %s\"), g_strerror (errsv));\n      return FALSE;\n    }\n\n  fd2 = open (info_path, O_RDONLY);\n  if (fd2 == -1)\n    {\n      close (fd);\n      int errsv = errno;\n      g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),\n                   _(\"Failed to open flatpak-info file: %s\"), g_strerror (errsv));\n      return FALSE;\n    }\n\n  flatpak_bwrap_add_args_data_fd (bwrap,\n                                  \"--file\", fd, \"\/.flatpak-info\");\n  flatpak_bwrap_add_args_data_fd (bwrap,\n                                  \"--ro-bind-data\", fd2, \"\/.flatpak-info\");\n\n  \/* Tell the application that it's running under Flatpak in a generic way. *\/\n  flatpak_bwrap_add_args (bwrap,\n                          \"--setenv\", \"container\", \"flatpak\",\n                          NULL);\n  if (!flatpak_bwrap_add_args_data (bwrap,\n                                    \"container-manager\",\n                                    \"flatpak\\n\", -1,\n                                    \"\/run\/host\/container-manager\",\n                                    error))\n    return FALSE;\n\n  bwrapinfo_path = g_build_filename (instance_id_host_dir, \"bwrapinfo.json\", NULL);\n  fd3 = open (bwrapinfo_path, O_RDWR | O_CREAT, 0644);\n  if (fd3 == -1)\n    {\n      close (fd);\n      close (fd2);\n      int errsv = errno;\n      g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),\n                   _(\"Failed to open bwrapinfo.json file: %s\"), g_strerror (errsv));\n      return FALSE;\n    }\n\n  \/* NOTE: It is important that this takes place after bwrapinfo.json is created,\n     otherwise start notifications in the portal may not work. *\/\n  if (instance_id_fd != -1)\n    {\n      gsize instance_id_position = 0;\n      gsize instance_id_size = strlen (instance_id);\n\n      while (instance_id_size > 0)\n        {\n          gssize bytes_written = write (instance_id_fd, instance_id + instance_id_position, instance_id_size);\n          if (G_UNLIKELY (bytes_written <= 0))\n            {\n              int errsv = bytes_written == -1 ? errno : ENOSPC;\n              if (errsv == EINTR)\n                continue;\n\n              close (fd);\n              close (fd2);\n              close (fd3);\n\n              g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv),\n                           _(\"Failed to write to instance id fd: %s\"), g_strerror (errsv));\n              return FALSE;\n            }\n\n          instance_id_position += bytes_written;\n          instance_id_size -= bytes_written;\n        }\n\n      close (instance_id_fd);\n    }\n\n  flatpak_bwrap_add_args_data_fd (bwrap, \"--info-fd\", fd3, NULL);\n\n  if (app_info_path_out != NULL)\n    *app_info_path_out = g_strdup_printf (\"\/proc\/self\/fd\/%d\", fd);\n\n  if (instance_id_host_dir_out != NULL)\n    *instance_id_host_dir_out = g_steal_pointer (&instance_id_host_dir);\n\n  return TRUE;\n}","target":0,"code_token_length":2550,"total_token_length":2786,"max_tokens_setting":4096}
+{"idx":332385,"func":"op_insert(oparg_T *oap, long count1)\n{\n    long\t\tins_len, pre_textlen = 0;\n    char_u\t\t*firstline, *ins_text;\n    colnr_T\t\tind_pre_col = 0, ind_post_col;\n    int\t\t\tind_pre_vcol = 0, ind_post_vcol = 0;\n    struct block_def\tbd;\n    int\t\t\ti;\n    pos_T\t\tt1;\n    pos_T\t\tstart_insert;\n\t\t\t\/\/ offset when cursor was moved in insert mode\n    int\t\t\toffset = 0;\n\n    \/\/ edit() changes this - record it for OP_APPEND\n    bd.is_MAX = (curwin->w_curswant == MAXCOL);\n\n    \/\/ vis block is still marked. Get rid of it now.\n    curwin->w_cursor.lnum = oap->start.lnum;\n    update_screen(INVERTED);\n\n    if (oap->block_mode)\n    {\n\t\/\/ When 'virtualedit' is used, need to insert the extra spaces before\n\t\/\/ doing block_prep().  When only \"block\" is used, virtual edit is\n\t\/\/ already disabled, but still need it when calling\n\t\/\/ coladvance_force().\n\t\/\/ coladvance_force() uses get_ve_flags() to get the 'virtualedit'\n\t\/\/ state for the current window.  To override that state, we need to\n\t\/\/ set the window-local value of ve_flags rather than the global value.\n\tif (curwin->w_cursor.coladd > 0)\n\t{\n\t    int\t\told_ve_flags = curwin->w_ve_flags;\n\n\t    if (u_save_cursor() == FAIL)\n\t\treturn;\n\n\t    curwin->w_ve_flags = VE_ALL;\n\t    coladvance_force(oap->op_type == OP_APPEND\n\t\t\t\t\t   ? oap->end_vcol + 1 : getviscol());\n\t    if (oap->op_type == OP_APPEND)\n\t\t--curwin->w_cursor.col;\n\t    curwin->w_ve_flags = old_ve_flags;\n\t}\n\t\/\/ Get the info about the block before entering the text\n\tblock_prep(oap, &bd, oap->start.lnum, TRUE);\n\t\/\/ Get indent information\n\tind_pre_col = (colnr_T)getwhitecols_curline();\n\tind_pre_vcol = get_indent();\n\tfirstline = ml_get(oap->start.lnum) + bd.textcol;\n\n\tif (oap->op_type == OP_APPEND)\n\t    firstline += bd.textlen;\n\tpre_textlen = (long)STRLEN(firstline);\n    }\n\n    if (oap->op_type == OP_APPEND)\n    {\n\tif (oap->block_mode && curwin->w_cursor.coladd == 0)\n\t{\n\t    \/\/ Move the cursor to the character right of the block.\n\t    curwin->w_set_curswant = TRUE;\n\t    while (*ml_get_cursor() != NUL\n\t\t    && (curwin->w_cursor.col < bd.textcol + bd.textlen))\n\t\t++curwin->w_cursor.col;\n\t    if (bd.is_short && !bd.is_MAX)\n\t    {\n\t\t\/\/ First line was too short, make it longer and adjust the\n\t\t\/\/ values in \"bd\".\n\t\tif (u_save_cursor() == FAIL)\n\t\t    return;\n\t\tfor (i = 0; i < bd.endspaces; ++i)\n\t\t    ins_char(' ');\n\t\tbd.textlen += bd.endspaces;\n\t    }\n\t}\n\telse\n\t{\n\t    curwin->w_cursor = oap->end;\n\t    check_cursor_col();\n\n\t    \/\/ Works just like an 'i'nsert on the next character.\n\t    if (!LINEEMPTY(curwin->w_cursor.lnum)\n\t\t    && oap->start_vcol != oap->end_vcol)\n\t\tinc_cursor();\n\t}\n    }\n\n    t1 = oap->start;\n    start_insert = curwin->w_cursor;\n    (void)edit(NUL, FALSE, (linenr_T)count1);\n\n    \/\/ When a tab was inserted, and the characters in front of the tab\n    \/\/ have been converted to a tab as well, the column of the cursor\n    \/\/ might have actually been reduced, so need to adjust here.\n    if (t1.lnum == curbuf->b_op_start_orig.lnum\n\t    && LT_POS(curbuf->b_op_start_orig, t1))\n\toap->start = curbuf->b_op_start_orig;\n\n    \/\/ If user has moved off this line, we don't know what to do, so do\n    \/\/ nothing.\n    \/\/ Also don't repeat the insert when Insert mode ended with CTRL-C.\n    if (curwin->w_cursor.lnum != oap->start.lnum || got_int)\n\treturn;\n\n    if (oap->block_mode)\n    {\n\tstruct block_def\tbd2;\n\tint\t\t\tdid_indent = FALSE;\n\tsize_t\t\t\tlen;\n\tint\t\t\tadd;\n\n\t\/\/ If indent kicked in, the firstline might have changed\n\t\/\/ but only do that, if the indent actually increased.\n\tind_post_col = (colnr_T)getwhitecols_curline();\n\tif (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col)\n\t{\n\t    bd.textcol += ind_post_col - ind_pre_col;\n\t    ind_post_vcol = get_indent();\n\t    bd.start_vcol += ind_post_vcol - ind_pre_vcol;\n\t    did_indent = TRUE;\n\t}\n\n\t\/\/ The user may have moved the cursor before inserting something, try\n\t\/\/ to adjust the block for that.  But only do it, if the difference\n\t\/\/ does not come from indent kicking in.\n\tif (oap->start.lnum == curbuf->b_op_start_orig.lnum\n\t\t\t\t\t\t  && !bd.is_MAX && !did_indent)\n\t{\n\t    int t = getviscol2(curbuf->b_op_start_orig.col,\n\t\t\t\t\t       curbuf->b_op_start_orig.coladd);\n\n\t    if (!bd.is_MAX)\n\t    {\n\t\tif (oap->op_type == OP_INSERT\n\t\t\t&& oap->start.col + oap->start.coladd\n\t\t\t\t!= curbuf->b_op_start_orig.col\n\t\t\t\t\t      + curbuf->b_op_start_orig.coladd)\n\t\t{\n\t\t    oap->start.col = curbuf->b_op_start_orig.col;\n\t\t    pre_textlen -= t - oap->start_vcol;\n\t\t    oap->start_vcol = t;\n\t\t}\n\t\telse if (oap->op_type == OP_APPEND\n\t\t\t&& oap->start.col + oap->start.coladd\n\t\t\t\t>= curbuf->b_op_start_orig.col\n\t\t\t\t\t      + curbuf->b_op_start_orig.coladd)\n\t\t{\n\t\t    oap->start.col = curbuf->b_op_start_orig.col;\n\t\t    \/\/ reset pre_textlen to the value of OP_INSERT\n\t\t    pre_textlen += bd.textlen;\n\t\t    pre_textlen -= t - oap->start_vcol;\n\t\t    oap->start_vcol = t;\n\t\t    oap->op_type = OP_INSERT;\n\t\t}\n\t    }\n\t    else if (bd.is_MAX && oap->op_type == OP_APPEND)\n\t    {\n\t\t\/\/ reset pre_textlen to the value of OP_INSERT\n\t\tpre_textlen += bd.textlen;\n\t\tpre_textlen -= t - oap->start_vcol;\n\t    }\n\t}\n\n\t\/\/ Spaces and tabs in the indent may have changed to other spaces and\n\t\/\/ tabs.  Get the starting column again and correct the length.\n\t\/\/ Don't do this when \"$\" used, end-of-line will have changed.\n\t\/\/\n\t\/\/ if indent was added and the inserted text was after the indent,\n\t\/\/ correct the selection for the new indent.\n\tif (did_indent && bd.textcol - ind_post_col > 0)\n\t{\n\t    oap->start.col += ind_post_col - ind_pre_col;\n\t    oap->start_vcol += ind_post_vcol - ind_pre_vcol;\n\t    oap->end.col += ind_post_col - ind_pre_col;\n\t    oap->end_vcol += ind_post_vcol - ind_pre_vcol;\n\t}\n\tblock_prep(oap, &bd2, oap->start.lnum, TRUE);\n\tif (did_indent && bd.textcol - ind_post_col > 0)\n\t{\n\t    \/\/ undo for where \"oap\" is used below\n\t    oap->start.col -= ind_post_col - ind_pre_col;\n\t    oap->start_vcol -= ind_post_vcol - ind_pre_vcol;\n\t    oap->end.col -= ind_post_col - ind_pre_col;\n\t    oap->end_vcol -= ind_post_vcol - ind_pre_vcol;\n\t}\n\tif (!bd.is_MAX || bd2.textlen < bd.textlen)\n\t{\n\t    if (oap->op_type == OP_APPEND)\n\t    {\n\t\tpre_textlen += bd2.textlen - bd.textlen;\n\t\tif (bd2.endspaces)\n\t\t    --bd2.textlen;\n\t    }\n\t    bd.textcol = bd2.textcol;\n\t    bd.textlen = bd2.textlen;\n\t}\n\n\t\/*\n\t * Subsequent calls to ml_get() flush the firstline data - take a\n\t * copy of the required string.\n\t *\/\n\tfirstline = ml_get(oap->start.lnum);\n\tlen = STRLEN(firstline);\n\tadd = bd.textcol;\n\tif (oap->op_type == OP_APPEND)\n\t{\n\t    add += bd.textlen;\n\t    \/\/ account for pressing cursor in insert mode when '$' was used\n\t    if (bd.is_MAX\n\t\t&& (start_insert.lnum == Insstart.lnum\n\t\t\t\t\t   && start_insert.col > Insstart.col))\n\t    {\n\t\toffset = (start_insert.col - Insstart.col);\n\t\tadd -= offset;\n\t\tif (oap->end_vcol > offset)\n\t\t    oap->end_vcol -= (offset + 1);\n\t\telse\n\t\t    \/\/ moved outside of the visual block, what to do?\n\t\t    return;\n\t    }\n\t}\n\tif ((size_t)add > len)\n\t    firstline += len;  \/\/ short line, point to the NUL\n\telse\n\t    firstline += add;\n\tif (pre_textlen >= 0 && (ins_len =\n\t\t\t   (long)STRLEN(firstline) - pre_textlen - offset) > 0)\n\t{\n\t    ins_text = vim_strnsave(firstline, ins_len);\n\t    if (ins_text != NULL)\n\t    {\n\t\t\/\/ block handled here\n\t\tif (u_save(oap->start.lnum,\n\t\t\t\t\t (linenr_T)(oap->end.lnum + 1)) == OK)\n\t\t    block_insert(oap, ins_text, (oap->op_type == OP_INSERT),\n\t\t\t\t\t\t\t\t\t &bd);\n\n\t\tcurwin->w_cursor.col = oap->start.col;\n\t\tcheck_cursor();\n\t\tvim_free(ins_text);\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":2288,"total_token_length":2524,"max_tokens_setting":4096}
+{"idx":261893,"func":"njs_string_decode_uri(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t component)\n{\n    u_char                *dst;\n    int64_t               size, length;\n    uint32_t              cp;\n    njs_int_t             ret;\n    njs_chb_t             chain;\n    njs_uint_t            i, n;\n    njs_bool_t            percent;\n    njs_value_t           *value;\n    const u_char          *src, *p, *end;\n    const uint32_t        *reserve;\n    njs_string_prop_t     string;\n    njs_unicode_decode_t  ctx;\n    u_char                encode[4];\n\n    static const uint32_t  reserve_uri[] = {\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n\n                     \/* ?>=< ;:98 7654 3210  \/.-, +*)( '&%$ #\"!  *\/\n        0xac009858,  \/* 1010 1100 0000 0000  1001 1000 0101 1000 *\/\n\n                     \/* _^]\\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ *\/\n        0x00000001,  \/* 0000 0000 0000 0000  0000 0000 0000 0001 *\/\n\n                     \/*  ~}| {zyx wvut srqp  onml kjih gfed cba` *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n    };\n\n    static const uint32_t  reserve_uri_component[] = {\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n\n                     \/* ?>=< ;:98 7654 3210  \/.-, +*)( '&%$ #\"!  *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n\n                     \/* _^]\\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n\n                     \/*  ~}| {zyx wvut srqp  onml kjih gfed cba` *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n        0x00000000,  \/* 0000 0000 0000 0000  0000 0000 0000 0000 *\/\n    };\n\n    static const int8_t  hex[256]\n        njs_aligned(32) =\n    {\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n         0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1,\n        -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n    };\n\n    if (nargs < 2) {\n        vm->retval = njs_string_undefined;\n        return NJS_OK;\n    }\n\n    value = njs_argument(args, 1);\n    ret = njs_value_to_string(vm, value, value);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    reserve = component ? reserve_uri_component : reserve_uri;\n\n    njs_prefetch(reserve);\n    njs_prefetch(&hex['0']);\n\n    (void) njs_string_prop(&string, value);\n\n    length = 0;\n    src = string.start;\n    end = string.start + string.size;\n\n    njs_chb_init(&chain, vm->mem_pool);\n\n    njs_utf8_decode_init(&ctx);\n\n    while (src < end) {\n        percent = (src[0] == '%');\n        cp = njs_string_decode_uri_cp(hex, &src, end, 0);\n        if (njs_slow_path(cp > NJS_UNICODE_MAX_CODEPOINT)) {\n            goto uri_error;\n        }\n\n        if (!percent) {\n            length += 1;\n            dst = njs_chb_reserve(&chain, 4);\n            if (dst != NULL) {\n                njs_utf8_encode(dst, cp);\n                njs_chb_written(&chain, njs_utf8_size(cp));\n            }\n\n            continue;\n        }\n\n        if (cp < 0x80) {\n            if (njs_reserved(reserve, cp)) {\n                length += 3;\n                njs_chb_append(&chain, &src[-3], 3);\n\n            } else {\n                length += 1;\n                dst = njs_chb_reserve(&chain, 1);\n                if (dst != NULL) {\n                    *dst = cp;\n                    njs_chb_written(&chain, 1);\n                }\n            }\n\n            continue;\n        }\n\n        n = 1;\n\n        do {\n            n++;\n        } while (((cp << n) & 0x80));\n\n        if (njs_slow_path(n > 4)) {\n            goto uri_error;\n        }\n\n        encode[0] = cp;\n\n        for (i = 1; i < n; i++) {\n            cp = njs_string_decode_uri_cp(hex, &src, end, 1);\n            if (njs_slow_path(cp > NJS_UNICODE_MAX_CODEPOINT)) {\n                goto uri_error;\n            }\n\n            encode[i] = cp;\n        }\n\n        p = encode;\n        cp = njs_utf8_decode(&ctx, &p, p + n);\n        if (njs_slow_path(cp > NJS_UNICODE_MAX_CODEPOINT)) {\n            goto uri_error;\n        }\n\n        dst = njs_chb_reserve(&chain, 4);\n        if (dst != NULL) {\n            njs_utf8_encode(dst, cp);\n            njs_chb_written(&chain, njs_utf8_size(cp));\n        }\n\n        length += 1;\n    }\n\n    size = njs_chb_size(&chain);\n    if (njs_slow_path(size < 0)) {\n        njs_memory_error(vm);\n        return NJS_ERROR;\n    }\n\n    if (size == 0) {\n        \/* GC: retain src. *\/\n        vm->retval = *value;\n        return NJS_OK;\n    }\n\n    dst = njs_string_alloc(vm, &vm->retval, size, length);\n    if (njs_slow_path(dst == NULL)) {\n        return NJS_ERROR;\n    }\n\n    njs_chb_join_to(&chain, dst);\n    njs_chb_destroy(&chain);\n\n    return NJS_OK;\n\nuri_error:\n\n    njs_uri_error(vm, \"malformed URI\");\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":2865,"total_token_length":3101,"max_tokens_setting":4096}
+{"idx":508315,"func":"open_and_process_table(THD *thd, TABLE_LIST *tables, uint *counter, uint flags,\n                       Prelocking_strategy *prelocking_strategy,\n                       bool has_prelocking_list, Open_table_context *ot_ctx)\n{\n  bool error= FALSE;\n  bool safe_to_ignore_table= FALSE;\n  LEX *lex= thd->lex;\n  DBUG_ENTER(\"open_and_process_table\");\n  DEBUG_SYNC(thd, \"open_and_process_table\");\n\n  \/*\n    Ignore placeholders for derived tables. After derived tables\n    processing, link to created temporary table will be put here.\n    If this is derived table for view then we still want to process\n    routines used by this view.\n  *\/\n  if (tables->derived)\n  {\n    if (!tables->view)\n    {\n      if (!tables->is_derived())\n        tables->set_derived();\n      goto end;\n    }\n    \/*\n      We restore view's name and database wiped out by derived tables\n      processing and fall back to standard open process in order to\n      obtain proper metadata locks and do other necessary steps like\n      stored routine processing.\n    *\/\n    tables->db= tables->view_db.str;\n    tables->db_length= tables->view_db.length;\n    tables->table_name= tables->view_name.str;\n    tables->table_name_length= tables->view_name.length;\n  }\n\n  if (!tables->derived &&\n      is_infoschema_db(tables->db, tables->db_length))\n  {\n    \/*\n      Check whether the information schema contains a table\n      whose name is tables->schema_table_name\n    *\/\n    ST_SCHEMA_TABLE *schema_table= tables->schema_table;\n    if (!schema_table ||\n        (schema_table->hidden &&\n         ((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 ||\n          \/*\n            this check is used for show columns|keys from I_S hidden table\n          *\/\n          lex->sql_command == SQLCOM_SHOW_FIELDS ||\n          lex->sql_command == SQLCOM_SHOW_KEYS)))\n    {\n      my_error(ER_UNKNOWN_TABLE, MYF(0),\n               tables->table_name, INFORMATION_SCHEMA_NAME.str);\n      DBUG_RETURN(1);\n    }\n  }\n  \/*\n    If this TABLE_LIST object is a placeholder for an information_schema\n    table, create a temporary table to represent the information_schema\n    table in the query. Do not fill it yet - will be filled during\n    execution.\n  *\/\n  if (tables->schema_table)\n  {\n    \/*\n      If this information_schema table is merged into a mergeable\n      view, ignore it for now -- it will be filled when its respective\n      TABLE_LIST is processed. This code works only during re-execution.\n    *\/\n    if (tables->view)\n    {\n      MDL_ticket *mdl_ticket;\n      \/*\n        We still need to take a MDL lock on the merged view to protect\n        it from concurrent changes.\n      *\/\n      if (!open_table_get_mdl_lock(thd, ot_ctx, &tables->mdl_request,\n                                   flags, &mdl_ticket) &&\n          mdl_ticket != NULL)\n        goto process_view_routines;\n      \/* Fall-through to return error. *\/\n    }\n    else if (!mysql_schema_table(thd, lex, tables) &&\n             !check_and_update_table_version(thd, tables, tables->table->s))\n    {\n      goto end;\n    }\n    error= TRUE;\n    goto end;\n  }\n  DBUG_PRINT(\"tcache\", (\"opening table: '%s'.'%s'  item: %p\",\n                        tables->db, tables->table_name, tables)); \/\/psergey: invalid read of size 1 here\n  (*counter)++;\n\n  \/*\n    Not a placeholder: must be a base\/temporary table or a view. Let us open it.\n  *\/\n  if (tables->table)\n  {\n    \/*\n      If this TABLE_LIST object has an associated open TABLE object\n      (TABLE_LIST::table is not NULL), that TABLE object must be a pre-opened\n      temporary table.\n    *\/\n    DBUG_ASSERT(is_temporary_table(tables));\n  }\n  else if (tables->open_type == OT_TEMPORARY_ONLY)\n  {\n    \/*\n      OT_TEMPORARY_ONLY means that we are in CREATE TEMPORARY TABLE statement.\n      Also such table list element can't correspond to prelocking placeholder\n      or to underlying table of merge table.\n      So existing temporary table should have been preopened by this moment\n      and we can simply continue without trying to open temporary or base\n      table.\n    *\/\n    DBUG_ASSERT(tables->open_strategy);\n    DBUG_ASSERT(!tables->prelocking_placeholder);\n    DBUG_ASSERT(!tables->parent_l);\n    DBUG_RETURN(0);\n  }\n\n  \/* Not a placeholder: must be a base table or a view. Let us open it. *\/\n  if (tables->prelocking_placeholder)\n  {\n    \/*\n      For the tables added by the pre-locking code, attempt to open\n      the table but fail silently if the table does not exist.\n      The real failure will occur when\/if a statement attempts to use\n      that table.\n    *\/\n    No_such_table_error_handler no_such_table_handler;\n    thd->push_internal_handler(&no_such_table_handler);\n\n    \/*\n      We're opening a table from the prelocking list.\n\n      Since this table list element might have been added after pre-opening\n      of temporary tables we have to try to open temporary table for it.\n\n      We can't simply skip this table list element and postpone opening of\n      temporary table till the execution of substatement for several reasons:\n      - Temporary table can be a MERGE table with base underlying tables,\n        so its underlying tables has to be properly open and locked at\n        prelocking stage.\n      - Temporary table can be a MERGE table and we might be in PREPARE\n        phase for a prepared statement. In this case it is important to call\n        HA_ATTACH_CHILDREN for all merge children.\n        This is necessary because merge children remember \"TABLE_SHARE ref type\"\n        and \"TABLE_SHARE def version\" in the HA_ATTACH_CHILDREN operation.\n        If HA_ATTACH_CHILDREN is not called, these attributes are not set.\n        Then, during the first EXECUTE, those attributes need to be updated.\n        That would cause statement re-preparing (because changing those\n        attributes during EXECUTE is caught by THD::m_reprepare_observers).\n        The problem is that since those attributes are not set in merge\n        children, another round of PREPARE will not help.\n    *\/\n    error= thd->open_temporary_table(tables);\n\n    if (!error && !tables->table)\n      error= open_table(thd, tables, ot_ctx);\n\n    thd->pop_internal_handler();\n    safe_to_ignore_table= no_such_table_handler.safely_trapped_errors();\n  }\n  else if (tables->parent_l && (thd->open_options & HA_OPEN_FOR_REPAIR))\n  {\n    \/*\n      Also fail silently for underlying tables of a MERGE table if this\n      table is opened for CHECK\/REPAIR TABLE statement. This is needed\n      to provide complete list of problematic underlying tables in\n      CHECK\/REPAIR TABLE output.\n    *\/\n    Repair_mrg_table_error_handler repair_mrg_table_handler;\n    thd->push_internal_handler(&repair_mrg_table_handler);\n\n    error= thd->open_temporary_table(tables);\n\n    if (!error && !tables->table)\n      error= open_table(thd, tables, ot_ctx);\n\n    thd->pop_internal_handler();\n    safe_to_ignore_table= repair_mrg_table_handler.safely_trapped_errors();\n  }\n  else\n  {\n    if (tables->parent_l)\n    {\n      \/*\n        Even if we are opening table not from the prelocking list we\n        still might need to look for a temporary table if this table\n        list element corresponds to underlying table of a merge table.\n      *\/\n      error= thd->open_temporary_table(tables);\n    }\n\n    if (!error && !tables->table)\n      error= open_table(thd, tables, ot_ctx);\n  }\n\n  if (error)\n  {\n    if (! ot_ctx->can_recover_from_failed_open() && safe_to_ignore_table)\n    {\n      DBUG_PRINT(\"info\", (\"open_table: ignoring table '%s'.'%s'\",\n                          tables->db, tables->alias));\n      error= FALSE;\n    }\n    goto end;\n  }\n\n  \/*\n    We can't rely on simple check for TABLE_LIST::view to determine\n    that this is a view since during re-execution we might reopen\n    ordinary table in place of view and thus have TABLE_LIST::view\n    set from repvious execution and TABLE_LIST::table set from\n    current.\n  *\/\n  if (!tables->table && tables->view)\n  {\n    \/* VIEW placeholder *\/\n    (*counter)--;\n\n    \/*\n      tables->next_global list consists of two parts:\n      1) Query tables and underlying tables of views.\n      2) Tables used by all stored routines that this statement invokes on\n         execution.\n      We need to know where the bound between these two parts is. If we've\n      just opened a view, which was the last table in part #1, and it\n      has added its base tables after itself, adjust the boundary pointer\n      accordingly.\n    *\/\n    if (lex->query_tables_own_last == &(tables->next_global) &&\n        tables->view->query_tables)\n      lex->query_tables_own_last= tables->view->query_tables_last;\n    \/*\n      Let us free memory used by 'sroutines' hash here since we never\n      call destructor for this LEX.\n    *\/\n    my_hash_free(&tables->view->sroutines);\n    goto process_view_routines;\n  }\n\n  \/*\n    Special types of open can succeed but still don't set\n    TABLE_LIST::table to anything.\n  *\/\n  if (tables->open_strategy && !tables->table)\n    goto end;\n\n  error= extend_table_list(thd, tables, prelocking_strategy, has_prelocking_list);\n  if (error)\n    goto end;\n\n  \/* Copy grant information from TABLE_LIST instance to TABLE one. *\/\n  tables->table->grant= tables->grant;\n\n  \/* Check and update metadata version of a base table. *\/\n  error= check_and_update_table_version(thd, tables, tables->table->s);\n\n  if (error)\n    goto end;\n  \/*\n    After opening a MERGE table add the children to the query list of\n    tables, so that they are opened too.\n    Note that placeholders don't have the handler open.\n  *\/\n  \/* MERGE tables need to access parent and child TABLE_LISTs. *\/\n  DBUG_ASSERT(tables->table->pos_in_table_list == tables);\n  \/* Non-MERGE tables ignore this call. *\/\n  if (tables->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST))\n  {\n    error= TRUE;\n    goto end;\n  }\n\nprocess_view_routines:\n  \/*\n    Again we may need cache all routines used by this view and add\n    tables used by them to table list.\n  *\/\n  if (tables->view &&\n      thd->locked_tables_mode <= LTM_LOCK_TABLES &&\n      ! has_prelocking_list)\n  {\n    bool need_prelocking= FALSE;\n    TABLE_LIST **save_query_tables_last= lex->query_tables_last;\n\n    error= prelocking_strategy->handle_view(thd, lex, tables,\n                                            &need_prelocking);\n\n    if (need_prelocking && ! lex->requires_prelocking())\n      lex->mark_as_requiring_prelocking(save_query_tables_last);\n\n    if (error)\n      goto end;\n  }\n\nend:\n  DBUG_RETURN(error);\n}","target":0,"code_token_length":2464,"total_token_length":2700,"max_tokens_setting":4096}
+{"idx":249977,"func":"GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emulation, u64 StartOffset, Bool drift_inter)\n{\n\tu32 i, tracksDone;\n\tTrackWriter *tmp, *curWriter;\n\tGF_Err e;\n\tu32 descIndex, sampSize, chunkNumber;\n\tu64 DTS;\n\tu32 moov_timescale;\n\tu16 curGroupID;\n\tBool forceNewChunk, writeGroup;\n\tGF_StscEntry *stsc_ent;\n\t\/\/this is used to emulate the write ...\n\tu64 offset, sampOffset, size, mdatSize;\n\tu32 count;\n\tGF_ISOFile *movie = mw->movie;\n\n\tmdatSize = 0;\n\n#ifdef TEST_LARGE_FILES\n\tif (!Emulation) {\n\t\tchar *blank;\n\t\tu32 count, i;\n\t\ti = count = 0;\n\t\tblank = gf_malloc(sizeof(char)*1024*1024);\n\t\tmemset(blank, 0, sizeof(char)*1024*1024);\n\t\tcount = 4096;\n\t\tmemset(blank, 0, sizeof(char)*1024*1024);\n\t\twhile (i<count) {\n\t\t\tu32 res = gf_bs_write_data(bs, blank, 1024*1024);\n\t\t\tif (res != 1024*1024) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CORE, (\"error writing to disk: only %d bytes written\\n\", res));\n\t\t\t}\n\t\t\ti++;\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CORE, (\"writing blank block: %.02f done - %d\/%d \\r\", (100.0*i)\/count , i, count));\n\t\t}\n\t\tgf_free(blank);\n\t}\n\tmdatSize = 4096*1024;\n\tmdatSize *= 1024;\n#endif\n\n\t\/*write meta content first - WE DON'T support fragmentation of resources in ISOM atm*\/\n\tif (movie->meta) {\n\t\te = DoWriteMeta(movie, movie->meta, bs, Emulation, StartOffset, &size);\n\t\tif (e) return e;\n\t\tmdatSize += size;\n\t\tStartOffset += (u32) size;\n\t}\n\tif (movie->moov) {\n\t\tif (movie->moov->meta) {\n\t\t\te = DoWriteMeta(movie, movie->moov->meta, bs, Emulation, StartOffset, &size);\n\t\t\tif (e) return e;\n\t\t\tmdatSize += size;\n\t\t\tStartOffset += (u32) size;\n\t\t}\n\t\ti=0;\n\t\twhile ((tmp = (TrackWriter*)gf_list_enum(writers, &i))) {\n\t\t\tif (tmp->mdia->mediaTrack->meta) {\n\t\t\t\te = DoWriteMeta(movie, tmp->mdia->mediaTrack->meta, bs, Emulation, StartOffset, &size);\n\t\t\t\tif (e) return e;\n\t\t\t\tmdatSize += size;\n\t\t\t\tStartOffset += (u32) size;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tif (movie->storageMode == GF_ISOM_STORE_TIGHT)\n\t\treturn DoFullInterleave(mw, writers, bs, Emulation, StartOffset);\n\n\tcurGroupID = 1;\n\t\/\/we emulate a write from this offset...\n\toffset = StartOffset;\n\ttracksDone = 0;\n\n#ifdef TEST_LARGE_FILES\n\toffset += mdatSize;\n#endif\n\n\tmoov_timescale = movie->moov && movie->moov->mvhd ? movie->moov->mvhd->timeScale : 1000;\n\n\tcount = gf_list_count(writers);\n\t\/\/browse each groups\n\twhile (1) {\n\t\t\/*the max DTS the chunk of the current writer*\/\n\t\tu64 chunkLastDTS = 0;\n\t\t\/*the timescale related to the max DTS*\/\n\t\tu32 chunkLastScale = 0;\n\n\t\twriteGroup = 1;\n\n\t\t\/\/proceed a group\n\t\twhile (writeGroup) {\n\t\t\tcurWriter = NULL;\n\t\t\tfor (i=0 ; i < count; i++) {\n\t\t\t\ttmp = (TrackWriter*)gf_list_get(writers, i);\n\n\t\t\t\t\/\/is it done writing ?\n\t\t\t\tif (tmp->isDone) continue;\n\n\t\t\t\t\/\/is it in our group ??\n\t\t\t\tif (tmp->stbl->groupID != curGroupID) continue;\n\n\t\t\t\t\/\/write till this chunk is full on this track...\n\t\t\t\twhile (1) {\n\t\t\t\t\tBool self_contained;\n\t\t\t\t\tu32 nb_samp = 1;\n\t\t\t\t\tu32 sample_dur;\n\t\t\t\t\tu64 chunk_prev_dur;\n\t\t\t\t\t\/\/To Check: are empty sample tables allowed ???\n\t\t\t\t\tif (tmp->sampleNumber > tmp->stbl->SampleSize->sampleCount) {\n\t\t\t\t\t\ttmp->isDone = 1;\n\t\t\t\t\t\ttracksDone ++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t\/\/OK, get the current sample in this track\n\t\t\t\t\tstbl_GetSampleDTS_and_Duration(tmp->stbl->TimeToSample, tmp->sampleNumber, &DTS, &sample_dur);\n\n\t\t\t\t\t\/\/can this sample fit in our chunk ?\n\t\t\t\t\tif ( ( (DTS - tmp->DTSprev) + tmp->chunkDur) * moov_timescale > movie->interleavingTime * tmp->timeScale\n\t\t\t\t\t        \/*drift check: reject sample if outside our check window*\/\n\t\t\t\t\t        || (drift_inter && chunkLastDTS && ( ((u64)tmp->DTSprev*chunkLastScale) > ((u64)chunkLastDTS*tmp->timeScale)) )\n\t\t\t\t\t   ) {\n\t\t\t\t\t\t\/\/in case the sample is longer than InterleaveTime\n\t\t\t\t\t\tif (!tmp->chunkDur) {\n\t\t\t\t\t\t\tforceNewChunk = 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\/\/this one is full. go to next one (exit the loop)\n\t\t\t\t\t\t\ttmp->chunkDur = 0;\n\t\t\t\t\t\t\t\/\/forceNewChunk = 0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tforceNewChunk = tmp->chunkDur ? 0 : 1;\n\t\t\t\t\t}\n\t\t\t\t\t\/\/OK, we can write this track\n\t\t\t\t\tcurWriter = tmp;\n\n\t\t\t\t\t\/\/small check for first 2 samples (DTS = 0)\n\t\t\t\t\t\/\/only in the old mode can chunkdur be 0 for dts 0\n\t\t\t\t\tif (tmp->sampleNumber == 2 && !tmp->chunkDur && gf_sys_old_arch_compat() ) {\n\t\t\t\t\t\tforceNewChunk = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tchunk_prev_dur = tmp->chunkDur;\n\t\t\t\t\t\/\/FIXME we do not apply patch in test mode for now since this breaks all our hashes, remove this\n\t\t\t\t\t\/\/once we move to filters permanently\n\t\t\t\t\tif (!gf_sys_old_arch_compat()) {\n\t\t\t\t\t\ttmp->chunkDur += sample_dur;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/\/old style, compute based on DTS diff\n\t\t\t\t\t\ttmp->chunkDur += (u32) (DTS - tmp->DTSprev);\n\t\t\t\t\t}\n\t\t\t\t\ttmp->DTSprev = DTS;\n\n\t\t\t\t\te = stbl_GetSampleInfos(curWriter->stbl, curWriter->sampleNumber, &sampOffset, &chunkNumber, &descIndex, &stsc_ent);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\treturn e;\n\t\t\t\t\te = stbl_GetSampleSize(curWriter->stbl->SampleSize, curWriter->sampleNumber, &sampSize);\n\t\t\t\t\tif (e)\n\t\t\t\t\t\treturn e;\n\n\t\t\t\t\tself_contained = ((curWriter->all_dref_mode==ISOM_DREF_SELF) || Media_IsSelfContained(curWriter->mdia, descIndex)) ? GF_TRUE : GF_FALSE;\n\n\t\t\t\t\tupdate_writer_constant_dur(movie, curWriter, stsc_ent, &nb_samp, &sampSize, GF_FALSE);\n\n\t\t\t\t\tif (curWriter->stbl->MaxChunkSize && (curWriter->chunkSize + sampSize > curWriter->stbl->MaxChunkSize)) {\n\t\t\t\t\t\tcurWriter->chunkSize = 0;\n\t\t\t\t\t\ttmp->chunkDur -= chunk_prev_dur;\n\t\t\t\t\t\tforceNewChunk = 1;\n\t\t\t\t\t}\n\t\t\t\t\tcurWriter->chunkSize += sampSize;\n\n\t\t\t\t\t\/\/do we actually write, or do we emulate ?\n\t\t\t\t\tif (Emulation) {\n\t\t\t\t\t\t\/\/update our offsets...\n\t\t\t\t\t\tif (self_contained) {\n\t\t\t\t\t\t\te = stbl_SetChunkAndOffset(curWriter->stbl, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, offset, forceNewChunk, nb_samp);\n\t\t\t\t\t\t\tif (e)\n\t\t\t\t\t\t\t\treturn e;\n\t\t\t\t\t\t\toffset += sampSize;\n\t\t\t\t\t\t\tmdatSize += sampSize;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (curWriter->prev_offset != sampOffset) forceNewChunk = 1;\n\t\t\t\t\t\t\tcurWriter->prev_offset = sampOffset + sampSize;\n\n\t\t\t\t\t\t\t\/\/we have a DataRef, so use the offset idicated in sampleToChunk\n\t\t\t\t\t\t\t\/\/and ChunkOffset tables...\n\t\t\t\t\t\t\te = stbl_SetChunkAndOffset(curWriter->stbl, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, sampOffset, forceNewChunk, nb_samp);\n\t\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\/\/we're writing ....\n\t\t\t\t\t\tif (self_contained) {\n\t\t\t\t\t\t\te = WriteSample(mw, sampSize, sampOffset, stsc_ent->isEdited, bs, nb_samp);\n\t\t\t\t\t\t\tif (e)\n\t\t\t\t\t\t\t\treturn e;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\/\/ok, the sample is done\n\t\t\t\t\tif (curWriter->sampleNumber >= curWriter->stbl->SampleSize->sampleCount) {\n\t\t\t\t\t\tcurWriter->isDone = 1;\n\t\t\t\t\t\t\/\/one more track done...\n\t\t\t\t\t\ttracksDone ++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcurWriter->sampleNumber += nb_samp;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\/*record chunk end-time & track timescale for drift-controled interleaving*\/\n\t\t\t\tif (drift_inter && curWriter) {\n\t\t\t\t\tchunkLastScale = curWriter->timeScale;\n\t\t\t\t\tchunkLastDTS = curWriter->DTSprev;\n\t\t\t\t\t\/*add one interleave window drift - since the \"maxDTS\" is the previously written one, we will\n\t\t\t\t\thave the following cases:\n\t\t\t\t\t- sample doesn't fit: post-pone and force new chunk\n\t\t\t\t\t- sample time larger than previous chunk time + interleave: post-pone and force new chunk\n\t\t\t\t\t- otherwise store and track becomes current reference\n\n\t\t\t\t\tthis ensures a proper drift regulation (max DTS diff is less than the interleaving window)\n\t\t\t\t\t*\/\n\t\t\t\t\tchunkLastDTS += curWriter->timeScale * movie->interleavingTime \/ moov_timescale;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/\/no sample found, we're done with this group\n\t\t\tif (!curWriter) {\n\t\t\t\twriteGroup = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t\/\/if all our track are done, break\n\t\tif (tracksDone == gf_list_count(writers)) break;\n\t\t\/\/go to next group\n\t\tcurGroupID ++;\n\t}\n\tif (movie->mdat) movie->mdat->dataSize = mdatSize;\n\treturn GF_OK;\n}","target":0,"code_token_length":2422,"total_token_length":2658,"max_tokens_setting":4096}
+{"idx":427738,"func":"parse_options(const char *data, struct parsed_mount_info *parsed_info)\n{\n\tchar *value = NULL;\n\tchar *equals = NULL;\n\tchar *next_keyword = NULL;\n\tchar *out = parsed_info->options;\n\tunsigned long *filesys_flags = &parsed_info->flags;\n\tint out_len = 0;\n\tint word_len;\n\tint rc = 0;\n\tint got_bkupuid = 0;\n\tint got_bkupgid = 0;\n\tint got_uid = 0;\n\tint got_cruid = 0;\n\tint got_gid = 0;\n\tint got_snapshot = 0;\n\tuid_t uid, cruid = 0, bkupuid = 0;\n\tgid_t gid, bkupgid = 0;\n\tchar *ep;\n\tstruct passwd *pw;\n\tstruct group *gr;\n\t\/*\n\t * max 64-bit uint in decimal is 18446744073709551615 which is 20 chars\n\t * wide +1 for NULL, and +1 for good measure\n\t *\/\n\tchar txtbuf[22];\n\tunsigned long long snapshot;\n\tstruct tm tm;\n\n\t\/* make sure we're starting from beginning *\/\n\tout[0] = '\\0';\n\n\t\/* BB fixme check for separator override BB *\/\n\tuid = getuid();\n\tif (uid != 0)\n\t\tgot_uid = 1;\n\n\tgid = getgid();\n\tif (gid != 0)\n\t\tgot_gid = 1;\n\n\tif (!data)\n\t\treturn EX_USAGE;\n\n\t\/*\n\t * format is keyword,keyword2=value2,keyword3=value3... \n\t * data  = next keyword\n\t * value = next value ie stuff after equal sign\n\t *\/\n\twhile (data && *data) {\n\t\tnext_keyword = strchr(data, ',');\t\/* BB handle sep= *\/\n\n\t\t\/* temporarily null terminate end of keyword=value pair *\/\n\t\tif (next_keyword)\n\t\t\t*next_keyword++ = 0;\n\n\t\t\/* temporarily null terminate keyword if there's a value *\/\n\t\tvalue = NULL;\n\t\tif ((equals = strchr(data, '=')) != NULL) {\n\t\t\t*equals = '\\0';\n\t\t\tvalue = equals + 1;\n\t\t}\n\n\t\tswitch(parse_opt_token(data)) {\n\t\tcase OPT_USERS:\n\t\t\tif (!value || !*value) {\n\t\t\t\t*filesys_flags |= MS_USERS;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_USER:\n\t\t\tif (!value || !*value) {\n\t\t\t\tif (data[4] == '\\0') {\n\t\t\t\t\t*filesys_flags |= MS_USER;\n\t\t\t\t\tgoto nocopy;\n\t\t\t\t} else {\n\t\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\t\"username specified with no parameter\\n\");\n\t\t\t\t\treturn EX_USAGE;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstrlcpy(parsed_info->username, value,\n\t\t\t\t\tsizeof(parsed_info->username));\n\t\t\t\tparsed_info->got_user = 1;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\n\t\tcase OPT_PASS:\n\t\t\tif (parsed_info->got_password) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"password specified twice, ignoring second\\n\");\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\t\t\tif (!value || !*value) {\n\t\t\t\tparsed_info->got_password = 1;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\t\t\trc = set_password(parsed_info, value);\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t\tgoto nocopy;\n\n\t\tcase OPT_SEC:\n\t\t\tif (value) {\n\t\t\t\tif (!strncmp(value, \"none\", 4) ||\n\t\t\t\t    !strncmp(value, \"krb5\", 4))\n\t\t\t\t\tparsed_info->got_password = 1;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_IP:\n\t\t\tif (!value || !*value) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"target ip address argument missing\\n\");\n\t\t\t} else if (strnlen(value, MAX_ADDRESS_LEN) <=\n\t\t\t\tMAX_ADDRESS_LEN) {\n\t\t\t\tstrcpy(parsed_info->addrlist, value);\n\t\t\t\tif (parsed_info->verboseflag)\n\t\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\t\"ip address %s override specified\\n\",\n\t\t\t\t\t\tvalue);\n\t\t\t\tgoto nocopy;\n\t\t\t} else {\n\t\t\t\tfprintf(stderr, \"ip address too long\\n\");\n\t\t\t\treturn EX_USAGE;\n\n\t\t\t}\n\t\t\tbreak;\n\n\t\t\/* unc || target || path *\/\n\t\tcase OPT_UNC:\n\t\t\tif (!value || !*value) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"invalid path to network resource\\n\");\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\t\t\trc = parse_unc(value, parsed_info, thisprogram);\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t\tbreak;\n\n\t\t\/* dom || workgroup *\/\n\t\tcase OPT_DOM:\n\t\t\tif (!value) {\n\t\t\t\t\/*\n\t\t\t\t * An empty domain has been passed\n\t\t\t\t *\/\n\t\t\t\t\/* not necessary but better safe than.. *\/\n\t\t\t\tparsed_info->domain[0] = '\\0';\n\t\t\t\tparsed_info->got_domain = 1;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\t\t\tif (strnlen(value, sizeof(parsed_info->domain)) >=\n\t\t\t    sizeof(parsed_info->domain)) {\n\t\t\t\tfprintf(stderr, \"domain name too long\\n\");\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\t\t\tstrlcpy(parsed_info->domain, value,\n\t\t\t\tsizeof(parsed_info->domain));\n\t\t\tgoto nocopy;\n\n\t\tcase OPT_CRED:\n\t\t\tif (!value || !*value) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"invalid credential file name specified\\n\");\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\t\t\trc = open_cred_file(value, parsed_info);\n\t\t\tif (rc) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"error %d (%s) opening credential file %s\\n\",\n\t\t\t\t\trc, strerror(rc), value);\n\t\t\t\treturn rc;\n\t\t\t}\n\t\t\tgoto nocopy;\n\n\t\tcase OPT_UID:\n\t\t\tif (!value || !*value)\n\t\t\t\tgoto nocopy;\n\n\t\t\tgot_uid = 1;\n\t\t\tpw = getpwnam(value);\n\t\t\tif (pw) {\n\t\t\t\tuid = pw->pw_uid;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\n\t\t\terrno = 0;\n\t\t\tuid = strtoul(value, &ep, 10);\n\t\t\tif (errno == 0 && *ep == '\\0')\n\t\t\t\tgoto nocopy;\n\n\t\t\tfprintf(stderr, \"bad option uid=\\\"%s\\\"\\n\", value);\n\t\t\treturn EX_USAGE;\n\t\tcase OPT_CRUID:\n\t\t\tif (!value || !*value)\n\t\t\t\tgoto nocopy;\n\n\t\t\tgot_cruid = 1;\n\t\t\tpw = getpwnam(value);\n\t\t\tif (pw) {\n\t\t\t\tcruid = pw->pw_uid;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\n\t\t\terrno = 0;\n\t\t\tcruid = strtoul(value, &ep, 10);\n\t\t\tif (errno == 0 && *ep == '\\0')\n\t\t\t\tgoto nocopy;\n\n\t\t\tfprintf(stderr, \"bad option: cruid=\\\"%s\\\"\\n\", value);\n\t\t\treturn EX_USAGE;\n\t\tcase OPT_GID:\n\t\t\tif (!value || !*value)\n\t\t\t\tgoto nocopy;\n\n\t\t\tgot_gid = 1;\n\t\t\tgr = getgrnam(value);\n\t\t\tif (gr) {\n\t\t\t\tgid = gr->gr_gid;\n\t\t\t\tgoto nocopy;\n\t\t\t}\n\n\t\t\terrno = 0;\n\t\t\tgid = strtoul(value, &ep, 10);\n\t\t\tif (errno == 0 && *ep == '\\0')\n\t\t\t\tgoto nocopy;\n\n\t\t\tfprintf(stderr, \"bad option: gid=\\\"%s\\\"\\n\", value);\n\t\t\treturn EX_USAGE;\n\t\t\/* fmask falls through to file_mode *\/\n\t\tcase OPT_FMASK:\n\t\t\tfprintf(stderr,\n\t\t\t\t\"WARNING: CIFS mount option 'fmask' is\\\n\t\t\t\t deprecated. Use 'file_mode' instead.\\n\");\n\t\t\tdata = \"file_mode\";\t\/* BB fix this *\/\n\t\t\t\/* Fallthrough *\/\n\t\tcase OPT_FILE_MODE:\n\t\t\tif (!value || !*value) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"Option '%s' requires a numerical argument\\n\",\n\t\t\t\t\tdata);\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\n\t\t\tif (value[0] != '0')\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"WARNING: '%s' not expressed in octal.\\n\",\n\t\t\t\t\tdata);\n\t\t\tbreak;\n\n\t\t\/* dmask falls through to dir_mode *\/\n\t\tcase OPT_DMASK:\n\t\t\tfprintf(stderr,\n\t\t\t\t\"WARNING: CIFS mount option 'dmask' is\\\n\t\t\t\t deprecated. Use 'dir_mode' instead.\\n\");\n\t\t\tdata = \"dir_mode\";\n\t\t\t\/* Fallthrough *\/\n\t\tcase OPT_DIR_MODE:\n\t\t\tif (!value || !*value) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"Option '%s' requires a numerical argument\\n\",\n\t\t\t\t\tdata);\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\n\t\t\tif (value[0] != '0')\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"WARNING: '%s' not expressed in octal.\\n\",\n\t\t\t\t\tdata);\n\t\t\tbreak;\n\t\tcase OPT_NO_SUID:\n\t\t\t*filesys_flags |= MS_NOSUID;\n\t\t\tgoto nocopy;\n\t\tcase OPT_SUID:\n\t\t\t*filesys_flags &= ~MS_NOSUID;\n\t\t\tgoto nocopy;\n\t\tcase OPT_NO_DEV:\n\t\t\t*filesys_flags |= MS_NODEV;\n\t\t\tgoto nocopy;\n\t\tcase OPT_NO_LOCK:\n\t\t\t*filesys_flags &= ~MS_MANDLOCK;\n\t\t\tbreak;\n\t\tcase OPT_MAND:\n\t\t\t*filesys_flags |= MS_MANDLOCK;\n\t\t\tgoto nocopy;\n\t\tcase OPT_NOMAND:\n\t\t\t*filesys_flags &= ~MS_MANDLOCK;\n\t\t\tgoto nocopy;\n\t\tcase OPT_DEV:\n\t\t\t*filesys_flags &= ~MS_NODEV;\n\t\t\tgoto nocopy;\n\t\tcase OPT_NO_EXEC:\n\t\t\t*filesys_flags |= MS_NOEXEC;\n\t\t\tgoto nocopy;\n\t\tcase OPT_EXEC:\n\t\t\t*filesys_flags &= ~MS_NOEXEC;\n\t\t\tgoto nocopy;\n\t\tcase OPT_GUEST:\n\t\t\tparsed_info->got_user = 1;\n\t\t\tparsed_info->got_password = 1;\n\t\t\tgoto nocopy;\n\t\tcase OPT_RO:\n\t\t\t*filesys_flags |= MS_RDONLY;\n\t\t\tgoto nocopy;\n\t\tcase OPT_RW:\n\t\t\t*filesys_flags &= ~MS_RDONLY;\n\t\t\tgoto nocopy;\n\t\tcase OPT_REMOUNT:\n\t\t\t*filesys_flags |= MS_REMOUNT;\n\t\t\tgoto nocopy;\n\t\tcase OPT_IGNORE:\n\t\t\tgoto nocopy;\n\t\tcase OPT_BKUPUID:\n\t\t\tif (!value || !*value)\n\t\t\t\tgoto nocopy;\n\n\t\t\tgot_bkupuid = 1;\n\t\t\terrno = 0;\n\t\t\tbkupuid = strtoul(value, &ep, 10);\n\t\t\tif (errno == 0 && *ep == '\\0')\n\t\t\t\tgoto nocopy;\n\n\t\t\tpw = getpwnam(value);\n\t\t\tif (pw == NULL) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"bad user name \\\"%s\\\"\\n\", value);\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\n\t\t\tbkupuid = pw->pw_uid;\n\t\t\tgoto nocopy;\n\t\tcase OPT_BKUPGID:\n\t\t\tif (!value || !*value)\n\t\t\t\tgoto nocopy;\n\n\t\t\tgot_bkupgid = 1;\n\t\t\terrno = 0;\n\t\t\tbkupgid = strtoul(value, &ep, 10);\n\t\t\tif (errno == 0 && *ep == '\\0')\n\t\t\t\tgoto nocopy;\n\n\t\t\tgr = getgrnam(value);\n\t\t\tif (gr == NULL) {\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"bad group name \\\"%s\\\"\\n\", value);\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\n\t\t\tbkupgid = gr->gr_gid;\n\t\t\tgoto nocopy;\n\t\tcase OPT_NOFAIL:\n\t\t\tparsed_info->nofail = 1;\n\t\t\tgoto nocopy;\n\t\tcase OPT_SNAPSHOT:\n\t\t\tif (!value || !*value)\n\t\t\t\tgoto nocopy;\n\t\t\tif (strncmp(value, \"@GMT-\", 5))\n\t\t\t\tbreak;\n\t\t\tif ((strlen(value) != GMT_NAME_LEN) ||\n\t\t\t    (strptime(value, GMT_FORMAT, &tm) == NULL)) {\n\t\t\t\tfprintf(stderr, \"bad snapshot token\\n\");\n\t\t\t\treturn EX_USAGE;\n\t\t\t}\n\t\t\tsnapshot = timegm(&tm) * 10000000 + NTFS_TIME_OFFSET;\n\t\t\tgot_snapshot = 1;\n\t\t\tgoto nocopy;\n\t\t}\n\n\t\t\/* check size before copying option to buffer *\/\n\t\tword_len = strlen(data);\n\t\tif (value)\n\t\t\tword_len += 1 + strlen(value);\n\n\t\t\/* need 2 extra bytes for comma and null byte *\/\n\t\tif (out_len + word_len + 2 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\t\/* put back equals sign, if any *\/\n\t\tif (equals)\n\t\t\t*equals = '=';\n\n\t\t\/* go ahead and copy *\/\n\t\tif (out_len)\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\n\t\tstrlcat(out, data, MAX_OPTIONS_LEN);\n\t\tout_len = strlen(out);\nnocopy:\n\t\tdata = next_keyword;\n\t}\n\n\n\t\/* special-case the uid and gid *\/\n\tif (got_uid) {\n\t\tword_len = snprintf(txtbuf, sizeof(txtbuf), \"%u\", uid);\n\n\t\t\/* comma + \"uid=\" + terminating NULL == 6 *\/\n\t\tif (out_len + word_len + 6 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\tif (out_len) {\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\t\t\tout_len++;\n\t\t}\n\t\tsnprintf(out + out_len, word_len + 5, \"uid=%s\", txtbuf);\n\t\tout_len = strlen(out);\n\t}\n\tif (got_cruid) {\n\t\tword_len = snprintf(txtbuf, sizeof(txtbuf), \"%u\", cruid);\n\n\t\t\/* comma + \"cruid=\" + terminating NULL == 8 *\/\n\t\tif (out_len + word_len + 8 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\tif (out_len) {\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\t\t\tout_len++;\n\t\t}\n\t\tsnprintf(out + out_len, word_len + 7, \"cruid=%s\", txtbuf);\n\t\tout_len = strlen(out);\n\t}\n\tif (got_gid) {\n\t\tword_len = snprintf(txtbuf, sizeof(txtbuf), \"%u\", gid);\n\n\t\t\/* comma + \"gid=\" + terminating NULL == 6 *\/\n\t\tif (out_len + word_len + 6 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\tif (out_len) {\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\t\t\tout_len++;\n\t\t}\n\t\tsnprintf(out + out_len, word_len + 5, \"gid=%s\", txtbuf);\n\t}\n\tif (got_bkupuid) {\n\t\tword_len = snprintf(txtbuf, sizeof(txtbuf), \"%u\", bkupuid);\n\n\t\t\/* comma + \"backupuid=\" + terminating NULL == 12 *\/\n\t\tif (out_len + word_len + 12 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\tif (out_len) {\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\t\t\tout_len++;\n\t\t}\n\t\tsnprintf(out + out_len, word_len + 11, \"backupuid=%s\", txtbuf);\n\t\tout_len = strlen(out);\n\t}\n\tif (got_bkupgid) {\n\t\tword_len = snprintf(txtbuf, sizeof(txtbuf), \"%u\", bkupgid);\n\n\t\t\/* comma + \"backupgid=\" + terminating NULL == 12 *\/\n\t\tif (out_len + word_len + 12 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\tif (out_len) {\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\t\t\tout_len++;\n\t\t}\n\t\tsnprintf(out + out_len, word_len + 11, \"backupgid=%s\", txtbuf);\n\t}\n\tif (got_snapshot) {\n\t\tword_len = snprintf(txtbuf, sizeof(txtbuf), \"%llu\", snapshot);\n\n\t\t\/* comma + \"snapshot=\" + terminating NULL == 11 *\/\n\t\tif (out_len + word_len + 11 > MAX_OPTIONS_LEN) {\n\t\t\tfprintf(stderr, \"Options string too long\\n\");\n\t\t\treturn EX_USAGE;\n\t\t}\n\n\t\tif (out_len) {\n\t\t\tstrlcat(out, \",\", MAX_OPTIONS_LEN);\n\t\t\tout_len++;\n\t\t}\n\t\tsnprintf(out + out_len, word_len + 11, \"snapshot=%s\", txtbuf);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":3532,"total_token_length":3768,"max_tokens_setting":4096}
+{"idx":229333,"func":"Status GetOrCreateKernelAndDevice(\n    EagerOperation* op, TensorHandle** retvals, int* num_retvals,\n    core::RefCountPtr<KernelAndDevice>* out_kernel) {\n  EagerContext& ctx = op->EagerContext();\n  Device* device = absl::get<Device*>(op->Device());\n\n  \/\/ Set the EagerOperation's device prior to extracting the input_dev_ptrs to\n  \/\/ avoid any redundant H2D\/D2H copies.\n  if (device == nullptr && !op->is_function()) {\n    Fprint128 device_cache_key = GetDeviceCacheKey(op, ctx);\n    device = ctx.GetCachedDevice(device_cache_key);\n    if (device == nullptr) {\n      TF_RETURN_IF_ERROR(SetOpDevice(ctx, op, &device));\n      ctx.AddDeviceToCache(device_cache_key, device);\n    } else {\n      op->SetDevice(device);\n    }\n  }\n\n  \/\/ Save the original value of reuse_rendezvous_for_functions from the context.\n  bool reuse_rendezvous_for_functions_original_value =\n      ctx.GetReuseRendezvousForFunctions();\n  \/\/ When running in eager_op_as_function mode Send\/Recv ops need to be\n  \/\/ placed on the same rendezvous to match the behaviour of eager mode.\n  bool reuse_rendezvous_for_functions =\n      (ctx.RunEagerOpAsFunction() && !op->is_function()) ||\n      reuse_rendezvous_for_functions_original_value;\n\n  std::vector<Device*> input_dev_ptrs;\n  absl::flat_hash_map<string, const std::vector<string>*> composite_devices;\n  std::unordered_map<int, DtypeAndPartialTensorShape>\n      input_resource_variable_dtypes_and_shapes;\n  if (op->is_function() || ctx.RunEagerOpAsFunction()) {\n    profiler::TraceMe activity(\"EagerCopyToDevice\",\n                               profiler::TraceMeLevel::kInfo);\n    input_dev_ptrs.reserve(op->Inputs().size());\n    const absl::InlinedVector<TensorHandle*, 4>* inputs;\n    TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n    for (int i = 0, end = inputs->size(); i < end; ++i) {\n      TensorHandle* input = (*inputs)[i];\n\n      Device* input_device;\n      TF_RETURN_IF_ERROR(GetDeviceForInput(*op, ctx, input, &input_device));\n      VLOG(1) << op->Name() << \":input:\" << i << \" \" << input_device->name();\n      input_dev_ptrs.push_back(input_device);\n      CompositeDevice* composite_device = nullptr;\n      if (ctx.FindCompositeDeviceFromName(input_device->name(),\n                                          &composite_device)\n              .ok()) {\n        composite_devices[input_device->name()] =\n            composite_device->underlying_devices();\n      }\n      if (input->dtype == DT_RESOURCE) {\n        \/\/ We only care about data type and shape for resource variable inputs.\n        \/\/ But we have no way to tell if input is resource variable (other than\n        \/\/ looking it up in ResourceMgr, which is slow). So we just get\n        \/\/ resource_dtypes_and_shapes for all DT_RESOURCE inputs. If\n        \/\/ resource_dtypes_and_shapes is not empty, take the first element.\n        std::vector<DtypeAndPartialTensorShape> resource_dtypes_and_shapes;\n        TF_RETURN_IF_ERROR(input->GetResourceHandleDtypesAndShapes(\n            &resource_dtypes_and_shapes));\n        if (!resource_dtypes_and_shapes.empty()) {\n          const DtypeAndPartialTensorShape& dtype_and_shape =\n              resource_dtypes_and_shapes.at(0);\n          input_resource_variable_dtypes_and_shapes[i] = dtype_and_shape;\n        }\n      }\n    }\n  }\n\n  TF_ASSIGN_OR_RETURN(\n      Fprint128 cache_key,\n      GetKernelCacheKey(*op, op->MutableAttrs()->CacheKey(op->DeviceName()),\n                        input_dev_ptrs,\n                        input_resource_variable_dtypes_and_shapes));\n  core::RefCountPtr<KernelAndDevice> kernel = ctx.GetCachedKernel(cache_key);\n  AbstractOperationPtr wrapped_op_releaser;\n  \/\/ We can eliminate some overhead by running simple functions using regular\n  \/\/ CallOp kernel. However, it is tricky to figure out which functions should\n  \/\/ be run using CallOp. Also, currently CallOp runs neither optimization\n  \/\/ passes (needed for TPU\/XLA) nor grappler.\n  \/\/ Here are some cases where a function should be run in multi-device mode:\n  \/\/  - Function takes at least two resources on different devices.\n  \/\/  - Function takes a resource on deviceA and a body op explicitly placed\n  \/\/  on deviceB.\n  \/\/  - Function has a colocation constraint.\n  \/\/  - Function has an explicit device annotation (which might not be using\n  \/\/    full canonical device name) different from op_device. Note that false\n  \/\/    positives are ok.\n  \/\/  - Function has a node or a (node) attribute that can potentially make\n  \/\/    the function multi-device after a rewrite pass (e.g. various XLA\/TPU\n  \/\/    special nodes and attributes)\n  if (kernel == nullptr) {\n    VLOG(2) << \"Creating new kernel for \" << op->Name() << \" on device \"\n            << DeviceNameOrUnspecified(absl::get<Device*>(op->Device()));\n    bool run_function_with_flr = false;\n    bool function_outputs_on_op_device = false;\n    absl::optional<string> xla_compile_device_type;\n    if (op->is_function()) {\n      bool compile_with_xla;\n      TF_RETURN_IF_ERROR(MustCompileWithXLA(op, ctx, &compile_with_xla));\n      if (compile_with_xla) {\n        if (ctx.JitCompileRewrite()) {\n          xla_compile_device_type = op->GetDeviceParsedName().type;\n          run_function_with_flr = true;\n        } else {\n          \/\/ Note that it is not ideal, but currently correct, to set this\n          \/\/ attribute after computing the kernel cache key above.\n          \/\/ Note: If the attribute is already set to true, this is a noop.\n          op->MutableAttrs()->Set(kXlaMustCompileAttr, true);\n        }\n      } else {\n        run_function_with_flr = true;\n      }\n      GetFuncAttr(op, ctx, kOutputsOnOpDevice, &function_outputs_on_op_device)\n          .IgnoreError();\n    }\n\n    VLOG(2) << op->Name() << \" function_outputs_on_op_device: \"\n            << function_outputs_on_op_device;\n    if (device == nullptr) {\n      TF_RETURN_IF_ERROR(SetOpDevice(ctx, op, &device));\n    } else {\n      VLOG(1) << \"Device for [\" << op->Name()\n              << \"] already set to: \" << device->name();\n    }\n\n    \/\/ Note: We wrap the eager op AFTER the device has been inferred to ensure\n    \/\/ that placement of the NodeDef in the function is exactly the same as in\n    \/\/ eager mode. This is specially important for cases where the\n    \/\/ preferred device is not the actual device on which the op is run.\n    \/\/ E.g. the preferred device for a `RangeDataset` op could be set to `GPU`\n    \/\/ but `ctx->SelectDevice` would still place it on CPU. Placer on the other\n    \/\/ hand would throw an error.\n    \/\/\n    \/\/ Note: The wrapped function is never jit compiled but rather run via the\n    \/\/ FLR. This is needed because certain ops e.g. `VarHandleOp` can not be\n    \/\/ jit compiled. Ideally we would run this via the jit compiled path and\n    \/\/ expect unsupported ops to be outside compiled but that is not supported\n    \/\/ on GPUs right now.\n    bool allow_small_function_optimizations = false;\n    bool int_args_and_retvals_on_device = false;\n    bool allow_control_flow_sync_execution = false;\n    \/\/ TODO(b\/176491312): Remove this if shape inference on import flag is\n    \/\/ removed.\n    bool shape_inference_on_tfe_dialect_import = true;\n    if (ctx.RunEagerOpAsFunction() && !op->is_function()) {\n      EagerOperation* wrapped_op = nullptr;\n      TF_RETURN_IF_ERROR(ValidateOp(op));\n      TF_RETURN_IF_ERROR(WrapInCallOp(op, &wrapped_op));\n      DCHECK(wrapped_op);\n      DCHECK(wrapped_op->is_function());\n      wrapped_op_releaser.reset(wrapped_op);\n      run_function_with_flr = true;\n      allow_small_function_optimizations = true;\n      allow_control_flow_sync_execution = true;\n      shape_inference_on_tfe_dialect_import = false;\n      int_args_and_retvals_on_device = IntArgsAndRetvalsOnDevice(op);\n      op = wrapped_op;\n    }\n    const NodeDef& ndef = op->MutableAttrs()->BuildNodeDef();\n\n    FunctionLibraryRuntime* flr =\n        device == nullptr ? nullptr : ctx.func_lib(device);\n    if (device != nullptr && flr == nullptr) {\n      return errors::NotFound(\n          \"Unable to find a FunctionLibraryRuntime corresponding to device \",\n          device->name());\n    }\n    auto runner = (flr != nullptr && flr->runner() != nullptr) ? flr->runner()\n                                                               : ctx.runner();\n    GraphCollector* graph_collector = nullptr;\n    if (ctx.ShouldStoreGraphs()) {\n      graph_collector = ctx.GetGraphCollector();\n    }\n    \/\/ Treat the function as multi_device only when we are not compiling\n    \/\/ it wholly with XLA. When compiling wholly with XLA, flr->CreateKernel\n    \/\/ will create an XlaLaunchOp kernel to compile and run the function.\n    if (run_function_with_flr) {\n      \/\/ Multi-device functions don't use the rendezvous from eager context.\n      \/\/ If we use that rendezvous, multiple concurrent calls to the same\n      \/\/ function will likely result in collisions. However, this also means\n      \/\/ that we don't support legitimate sending\/receiving across function\n      \/\/ boundary.\n      VLOG(2) << \"Running \" << ndef.op() << \" using multi-device function. \"\n              << \"Full node_def=\" << ndef.DebugString();\n      std::function<int64_t()> get_op_id = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n      get_op_id = [&ctx]() { return ctx.RemoteMgr()->NextOpId(); };\n#endif  \/\/ IS_MOBILE_PLATFORM\n\n      ctx.reuse_rendezvous_for_functions_mu()->lock();\n      ctx.SetReuseRendezvousForFunctions(reuse_rendezvous_for_functions);\n      auto rendezvous_creator = ctx.RendezvousCreator();\n      ctx.SetReuseRendezvousForFunctions(\n          reuse_rendezvous_for_functions_original_value);\n      ctx.reuse_rendezvous_for_functions_mu()->unlock();\n      kernel.reset(new KernelAndDeviceFunc(\n          flr, ctx.pflr(), std::move(input_dev_ptrs),\n          std::move(composite_devices),\n          std::move(input_resource_variable_dtypes_and_shapes), runner,\n          ctx.GetCollectiveExecutorHandle(), ctx.HostCPU(), op->Name(),\n          function_outputs_on_op_device, allow_small_function_optimizations,\n          allow_control_flow_sync_execution,\n          shape_inference_on_tfe_dialect_import, int_args_and_retvals_on_device,\n          xla_compile_device_type, std::move(rendezvous_creator), get_op_id));\n    } else {\n      VLOG(2) << \"Running \" << ndef.op() << \" using op kernel. \"\n              << \". Full node_def=\" << ndef.DebugString();\n      kernel.reset(new KernelAndDeviceOp(\n          ctx.GetRendezvous(), ctx.LogMemory(), flr, runner,\n          ctx.GetCollectiveExecutorHandle(), ctx.HostCPU()));\n    }\n\n    TF_RETURN_IF_ERROR(\n        kernel->Init(ctx.LogDevicePlacement(), ndef, graph_collector));\n\n    if (op->is_function()) {\n      ctx.AddKernelToCache(cache_key, kernel.get());\n    } else {\n      \/\/ Exclude tf.data op kernels from being cached. The reason for this is\n      \/\/ that tf.data op kernels that accept a user-defined function will have a\n      \/\/ unique cache key every time they are executed (because the user-defined\n      \/\/ function is traced every time). Caching such kernels provides no\n      \/\/ benefit and in some cases results in linear memory growth of use\n      \/\/ programs that build input pipeline graphs in a loop.\n      const OpDef* op_def;\n      TF_RETURN_IF_ERROR(OpDefForOp(op->Name().data(), &op_def));\n      if (KernelCacheEnabled(*op_def)) {\n        ctx.AddKernelToCache(cache_key, kernel.get());\n      }\n    }\n  }\n\n  int num_outputs = kernel->num_outputs();\n  if (num_outputs > *num_retvals) {\n    return errors::InvalidArgument(\"Expecting \", num_outputs,\n                                   \" outputs, but *num_retvals is \",\n                                   *num_retvals);\n  }\n  *num_retvals = num_outputs;\n\n  kernel->Ref();  \/\/ Ownership of reference is passed to out_kernel.\n  out_kernel->reset(kernel.get());\n  return Status::OK();\n}","target":0,"code_token_length":2771,"total_token_length":3007,"max_tokens_setting":4096}
+{"idx":197111,"func":"static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header,\n                       const std::vector<tinyexr::tinyexr_uint64> &offsets,\n                       const unsigned char *head, const size_t size,\n                       std::string *err) {\n  int num_channels = exr_header->num_channels;\n\n  int num_scanline_blocks = 1;\n  if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) {\n    num_scanline_blocks = 16;\n  } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {\n    num_scanline_blocks = 32;\n  } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {\n    num_scanline_blocks = 16;\n  }\n\n  int data_width = exr_header->data_window[2] - exr_header->data_window[0] + 1;\n  int data_height = exr_header->data_window[3] - exr_header->data_window[1] + 1;\n\n  if ((data_width < 0) || (data_height < 0)) {\n    if (err) {\n      std::stringstream ss;\n      ss << \"Invalid data width or data height: \" << data_width << \", \"\n         << data_height << std::endl;\n      (*err) += ss.str();\n    }\n    return TINYEXR_ERROR_INVALID_DATA;\n  }\n\n  \/\/ Do not allow too large data_width and data_height. header invalid?\n  {\n    const int threshold = 1024 * 8192;  \/\/ heuristics\n    if ((data_width > threshold) || (data_height > threshold)) {\n      if (err) {\n        std::stringstream ss;\n        ss << \"data_with or data_height too large. data_width: \" << data_width\n           << \", \"\n           << \"data_height = \" << data_height << std::endl;\n        (*err) += ss.str();\n      }\n      return TINYEXR_ERROR_INVALID_DATA;\n    }\n  }\n\n  size_t num_blocks = offsets.size();\n\n  std::vector<size_t> channel_offset_list;\n  int pixel_data_size = 0;\n  size_t channel_offset = 0;\n  if (!tinyexr::ComputeChannelLayout(&channel_offset_list, &pixel_data_size,\n                                     &channel_offset, num_channels,\n                                     exr_header->channels)) {\n    if (err) {\n      (*err) += \"Failed to compute channel layout.\\n\";\n    }\n    return TINYEXR_ERROR_INVALID_DATA;\n  }\n\n  bool invalid_data = false;  \/\/ TODO(LTE): Use atomic lock for MT safety.\n\n  if (exr_header->tiled) {\n    \/\/ value check\n    if (exr_header->tile_size_x < 0) {\n      if (err) {\n        std::stringstream ss;\n        ss << \"Invalid tile size x : \" << exr_header->tile_size_x << \"\\n\";\n        (*err) += ss.str();\n      }\n      return TINYEXR_ERROR_INVALID_HEADER;\n    }\n\n    if (exr_header->tile_size_y < 0) {\n      if (err) {\n        std::stringstream ss;\n        ss << \"Invalid tile size y : \" << exr_header->tile_size_y << \"\\n\";\n        (*err) += ss.str();\n      }\n      return TINYEXR_ERROR_INVALID_HEADER;\n    }\n\n    size_t num_tiles = offsets.size();  \/\/ = # of blocks\n\n    exr_image->tiles = static_cast<EXRTile *>(\n        calloc(sizeof(EXRTile), static_cast<size_t>(num_tiles)));\n\n    for (size_t tile_idx = 0; tile_idx < num_tiles; tile_idx++) {\n      \/\/ Allocate memory for each tile.\n      exr_image->tiles[tile_idx].images = tinyexr::AllocateImage(\n          num_channels, exr_header->channels, exr_header->requested_pixel_types,\n          exr_header->tile_size_x, exr_header->tile_size_y);\n\n      \/\/ 16 byte: tile coordinates\n      \/\/ 4 byte : data size\n      \/\/ ~      : data(uncompressed or compressed)\n      if (offsets[tile_idx] + sizeof(int) * 5 > size) {\n        if (err) {\n          (*err) += \"Insufficient data size.\\n\";\n        }\n        return TINYEXR_ERROR_INVALID_DATA;\n      }\n\n      size_t data_size = size_t(size - (offsets[tile_idx] + sizeof(int) * 5));\n      const unsigned char *data_ptr =\n          reinterpret_cast<const unsigned char *>(head + offsets[tile_idx]);\n\n      int tile_coordinates[4];\n      memcpy(tile_coordinates, data_ptr, sizeof(int) * 4);\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&tile_coordinates[0]));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&tile_coordinates[1]));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&tile_coordinates[2]));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&tile_coordinates[3]));\n\n      \/\/ @todo{ LoD }\n      if (tile_coordinates[2] != 0) {\n        return TINYEXR_ERROR_UNSUPPORTED_FEATURE;\n      }\n      if (tile_coordinates[3] != 0) {\n        return TINYEXR_ERROR_UNSUPPORTED_FEATURE;\n      }\n\n      int data_len;\n      memcpy(&data_len, data_ptr + 16,\n             sizeof(int));  \/\/ 16 = sizeof(tile_coordinates)\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&data_len));\n\n      if (data_len < 4 || size_t(data_len) > data_size) {\n        if (err) {\n          (*err) += \"Insufficient data length.\\n\";\n        }\n        return TINYEXR_ERROR_INVALID_DATA;\n      }\n\n      \/\/ Move to data addr: 20 = 16 + 4;\n      data_ptr += 20;\n\n      tinyexr::DecodeTiledPixelData(\n          exr_image->tiles[tile_idx].images,\n          &(exr_image->tiles[tile_idx].width),\n          &(exr_image->tiles[tile_idx].height),\n          exr_header->requested_pixel_types, data_ptr,\n          static_cast<size_t>(data_len), exr_header->compression_type,\n          exr_header->line_order, data_width, data_height, tile_coordinates[0],\n          tile_coordinates[1], exr_header->tile_size_x, exr_header->tile_size_y,\n          static_cast<size_t>(pixel_data_size),\n          static_cast<size_t>(exr_header->num_custom_attributes),\n          exr_header->custom_attributes,\n          static_cast<size_t>(exr_header->num_channels), exr_header->channels,\n          channel_offset_list);\n\n      exr_image->tiles[tile_idx].offset_x = tile_coordinates[0];\n      exr_image->tiles[tile_idx].offset_y = tile_coordinates[1];\n      exr_image->tiles[tile_idx].level_x = tile_coordinates[2];\n      exr_image->tiles[tile_idx].level_y = tile_coordinates[3];\n\n      exr_image->num_tiles = static_cast<int>(num_tiles);\n    }\n  } else {  \/\/ scanline format\n\n    \/\/ Don't allow too large image(256GB * pixel_data_size or more). Workaround\n    \/\/ for #104.\n    size_t total_data_len =\n        size_t(data_width) * size_t(data_height) * size_t(num_channels);\n    const bool total_data_len_overflown = sizeof(void*) == 8 ? (total_data_len >= 0x4000000000) : false;\n    if ((total_data_len == 0) || total_data_len_overflown ) {\n      if (err) {\n        std::stringstream ss;\n        ss << \"Image data size is zero or too large: width = \" << data_width\n           << \", height = \" << data_height << \", channels = \" << num_channels\n           << std::endl;\n        (*err) += ss.str();\n      }\n      return TINYEXR_ERROR_INVALID_DATA;\n    }\n\n    exr_image->images = tinyexr::AllocateImage(\n        num_channels, exr_header->channels, exr_header->requested_pixel_types,\n        data_width, data_height);\n\n#ifdef _OPENMP\n#pragma omp parallel for\n#endif\n    for (int y = 0; y < static_cast<int>(num_blocks); y++) {\n      size_t y_idx = static_cast<size_t>(y);\n\n      if (offsets[y_idx] + sizeof(int) * 2 > size) {\n        invalid_data = true;\n      } else {\n        \/\/ 4 byte: scan line\n        \/\/ 4 byte: data size\n        \/\/ ~     : pixel data(uncompressed or compressed)\n        size_t data_size = size_t(size - (offsets[y_idx] + sizeof(int) * 2));\n        const unsigned char *data_ptr =\n            reinterpret_cast<const unsigned char *>(head + offsets[y_idx]);\n\n        int line_no;\n        memcpy(&line_no, data_ptr, sizeof(int));\n        int data_len;\n        memcpy(&data_len, data_ptr + 4, sizeof(int));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&line_no));\n        tinyexr::swap4(reinterpret_cast<unsigned int *>(&data_len));\n\n        if (size_t(data_len) > data_size) {\n          invalid_data = true;\n        } else if (data_len == 0) {\n          \/\/ TODO(syoyo): May be ok to raise the threshold for example `data_len\n          \/\/ < 4`\n          invalid_data = true;\n        } else {\n          \/\/ line_no may be negative.\n          int end_line_no = (std::min)(line_no + num_scanline_blocks,\n                                       (exr_header->data_window[3] + 1));\n\n          int num_lines = end_line_no - line_no;\n\n          if (num_lines <= 0) {\n            invalid_data = true;\n          } else {\n            \/\/ Move to data addr: 8 = 4 + 4;\n            data_ptr += 8;\n\n            \/\/ Adjust line_no with data_window.bmin.y\n\n            \/\/ overflow check\n            tinyexr_int64 lno = static_cast<tinyexr_int64>(line_no) - static_cast<tinyexr_int64>(exr_header->data_window[1]);\n            if (lno > std::numeric_limits<int>::max()) {\n              line_no = -1; \/\/ invalid\n            } else if (lno < -std::numeric_limits<int>::max()) {\n              line_no = -1; \/\/ invalid\n            } else {\n              line_no -= exr_header->data_window[1];\n            }\n\n            if (line_no < 0) {\n              invalid_data = true;\n            } else {\n              if (!tinyexr::DecodePixelData(\n                      exr_image->images, exr_header->requested_pixel_types,\n                      data_ptr, static_cast<size_t>(data_len),\n                      exr_header->compression_type, exr_header->line_order,\n                      data_width, data_height, data_width, y, line_no,\n                      num_lines, static_cast<size_t>(pixel_data_size),\n                      static_cast<size_t>(exr_header->num_custom_attributes),\n                      exr_header->custom_attributes,\n                      static_cast<size_t>(exr_header->num_channels),\n                      exr_header->channels, channel_offset_list)) {\n                invalid_data = true;\n              }\n            }\n          }\n        }\n      }\n    }  \/\/ omp parallel\n  }\n\n  if (invalid_data) {\n    if (err) {\n      std::stringstream ss;\n      (*err) += \"Invalid data found when decoding pixels.\\n\";\n    }\n    return TINYEXR_ERROR_INVALID_DATA;\n  }\n\n  \/\/ Overwrite `pixel_type` with `requested_pixel_type`.\n  {\n    for (int c = 0; c < exr_header->num_channels; c++) {\n      exr_header->pixel_types[c] = exr_header->requested_pixel_types[c];\n    }\n  }\n\n  {\n    exr_image->num_channels = num_channels;\n\n    exr_image->width = data_width;\n    exr_image->height = data_height;\n  }\n\n  return TINYEXR_SUCCESS;\n}","target":1,"code_token_length":2617,"total_token_length":2853,"max_tokens_setting":4096}
+{"idx":220905,"func":"void DependencyOptimizer::OptimizeNode(int node_idx,\n                                       SetVector<int>* nodes_to_simplify,\n                                       std::set<int>* nodes_to_delete) {\n  NodeDef* node = optimized_graph_->mutable_node(node_idx);\n  const bool is_noop = IsNoOp(*node);\n  const bool is_identity = IsIdentity(*node) || IsIdentityNSingleInput(*node);\n  const bool is_multi_input_identity =\n      IsIdentityN(*node) && !IsIdentityNSingleInput(*node);\n  const string node_name = node->name();\n  \/\/ Constant nodes with no input control dependency are always executed early,\n  \/\/ so we can prune all their output control dependencies.\n  if (IsConstant(*node) && node->input_size() == 0) {\n    const auto output_nodes = node_map_->GetOutputs(node_name);\n    for (NodeDef* fanout : output_nodes) {\n      bool optimize_fanout = false;\n      bool data_connection = false;\n      for (int i = fanout->input_size() - 1; i >= 0; --i) {\n        const TensorId input_tensor = ParseTensorName(fanout->input(i));\n        if (input_tensor.node() == node_name) {\n          if (input_tensor.index() < 0) {\n            fanout->mutable_input()->SwapElements(i, fanout->input_size() - 1);\n            fanout->mutable_input()->RemoveLast();\n            optimize_fanout = true;\n          } else {\n            data_connection = true;\n          }\n        }\n      }\n      if (optimize_fanout) {\n        nodes_to_simplify->PushBack(node_to_idx_[fanout]);\n        if (!data_connection) {\n          node_map_->RemoveOutput(node_name, fanout->name());\n        }\n      }\n    }\n    if (node_map_->GetOutputs(node_name).empty() && fetch_nodes_known_ &&\n        nodes_to_preserve_.find(node_name) == nodes_to_preserve_.end()) {\n      \/\/ Mark the node for deletion.\n      nodes_to_delete->insert(node_to_idx_[node]);\n    }\n    return;\n  }\n\n  \/\/ Change ops that only have control dependencies as outputs to NoOps.\n  if (!is_noop && SafeToConvertToNoOp(*node)) {\n    VLOG(2) << \"***** Replacing  \" << node_name << \" (\" << node->op()\n            << \") with NoOp.\";\n    \/\/ The outputs of this node are not consumed. Replace its inputs with\n    \/\/ control dependencies and replace the op itself with the NoOp op.\n    std::unordered_set<string> ctrl_inputs;\n    int pos = 0;\n    while (pos < node->input_size()) {\n      const string old_input = node->input(pos);\n      if (IsControlInput(old_input)) {\n        if (!ctrl_inputs.insert(old_input).second) {\n          \/\/ We found a duplicate control input. Remove it.\n          node->mutable_input()->SwapElements(pos, node->input_size() - 1);\n          node->mutable_input()->RemoveLast();\n        } else {\n          ++pos;\n        }\n        continue;\n      }\n      \/\/ Replace a normal input with a control input.\n      const string ctrl_input = ConstantFolding::AddControlDependency(\n          old_input, optimized_graph_, node_map_.get());\n      ctrl_inputs.insert(ctrl_input);\n      node->set_input(pos, ctrl_input);\n      node_map_->UpdateInput(node_name, old_input, ctrl_input);\n      const NodeDef* old_input_node = node_map_->GetNode(old_input);\n      nodes_to_simplify->PushBack(node_to_idx_[old_input_node]);\n      ++pos;\n    }\n    node->set_op(\"NoOp\");\n    EraseRegularNodeAttributes(node);\n    DedupControlInputs(node);\n    nodes_to_simplify->PushBack(node_to_idx_[node]);\n    return;\n  }\n\n  \/\/ Remove NoOp nodes if the product of their fan-in and fan-out is less than\n  \/\/ or equal to the sum of the fan-in and fan-out. The non-trivial rewrites\n  \/\/ take the following form:\n  \/\/\n  \/\/ Case a)\n  \/\/    x --^> +------+                x --^> +---+\n  \/\/    y --^> | NoOp | --^> a   ==>   y --^> | a |\n  \/\/    ...    |      |                  ...  |   |\n  \/\/    z --^> +------+                z --^> +---+\n  \/\/\n  \/\/ Case b)\n  \/\/           +------+ --^> a         +---+ --^> a\n  \/\/    x --^> | NoOp | --^> b  ==>    | x | --^> b\n  \/\/           |      | ...            |   | ...\n  \/\/           +------+ --^> c         +---+ --^> c\n  \/\/ Case c)\n  \/\/           +------+                x ---^> a\n  \/\/    x --^> | NoOp | --^> a  ==>      \\\/\n  \/\/    y --^> |      | --^> b           \/\\\n  \/\/           +------+                y ---^> b\n  \/\/\n  \/\/ We only apply this optimization if we don't increase the number of control\n  \/\/ edges across device boundaries, e.g. in cases a) and b) if NoOp and\n  \/\/ a and x, respectively, are on the same device. Control edges across device\n  \/\/ boundaries require inter-device communication (Send\/Recv pairs to be\n  \/\/ inserted in the graph), which is very costly.\n  \/\/\n  \/\/ We also remove identity nodes, subject to the same constraints on number of\n  \/\/ resulting control edges and device boundary crossings:\n  \/\/\n  \/\/ Case a)\n  \/\/          +----------+ ---> a       +---+ ---> a\n  \/\/    x --> | Identity | --^> b  ==>  | x | --^> b\n  \/\/          |          | ...          |   | ...\n  \/\/          +----------+ --^> c       +---+ --^> c\n  \/\/\n  \/\/ Case b)\n  \/\/    x ---> +----------+ ---> a      x ---> +---+\n  \/\/    y --^> | Identity |        ==>  y --^> | a |\n  \/\/    ...    |          |               ...  |   |\n  \/\/    z --^> +----------+             z --^> +---+\n  \/\/\n  \/\/ Case c)\n  \/\/           +----------+             x ---> +---+\n  \/\/    x ---> | Identity | ---> a ==>   \\--^> | a |\n  \/\/    y --^> |          | --^> b       \/\\    +---+\n  \/\/           +----------+             y --^> b\n\n  if (is_noop || ((is_identity || is_multi_input_identity) &&\n                  SafeToRemoveIdentity(*node))) {\n    const int num_inputs = node->input_size();\n    std::vector<NodeDef*> input_nodes;\n    for (int i = 0; i < num_inputs; ++i) {\n      NodeDef* input_node = node_map_->GetNode(node->input(i));\n      if (input_node == nullptr) {\n        LOG(ERROR) << \"Invalid input \" << node->input(i);\n        return;\n      }\n      input_nodes.push_back(input_node);\n    }\n    const auto& output_node_set = node_map_->GetOutputs(node_name);\n    const std::vector<NodeDef*> output_nodes(output_node_set.begin(),\n                                             output_node_set.end());\n\n    if (!BypassingNodeIsBeneficial(*node, input_nodes, output_nodes)) {\n      return;\n    }\n\n    VLOG(2) << \"***** Rerouting input around\\n\" << node->DebugString();\n    \/\/ Now remove the node and re-wire its inputs to its outputs.\n    for (auto consumer : output_nodes) {\n      bool updated_consumer = false;\n      VLOG(2) << \"consumer before:\\n\" << consumer->DebugString();\n      \/\/ Remove dependency on node from consumer.\n      for (int i = 0; i < num_inputs; ++i) {\n        const NodeDef* input = input_nodes[i];\n        \/\/ Forward dependency from input to consumer if it doesn't already\n        \/\/ depend on it.\n        if ((is_identity && i == 0) ||\n            (is_multi_input_identity && !IsControlInput(node->input(i)))) {\n          \/\/ Replace regular input from Identity node.\n          string new_input;\n          const string& input_to_forward = node->input(i);\n          CHECK(!IsControlInput(input_to_forward));\n          for (int j = 0; j < consumer->input_size(); ++j) {\n            const TensorId old_input = ParseTensorName(consumer->input(j));\n            if (old_input.node() == node_name) {\n              if (old_input.index() == i) {\n                \/\/ Regular input\n                new_input = input_to_forward;\n                node_map_->UpdateInput(consumer->name(),\n                                       string(old_input.node()), new_input);\n                consumer->set_input(j, new_input);\n              } else if (old_input.index() == -1) {\n                \/\/ Control dependency\n                new_input = AsControlDependency(NodeName(input_to_forward));\n                node_map_->UpdateInput(consumer->name(),\n                                       string(old_input.node()), new_input);\n                consumer->set_input(j, new_input);\n              }\n            }\n          }\n          updated_consumer = true;\n        } else {\n          \/\/ Forward dependency from input to consumer if it doesn't already\n          \/\/ depend on it.\n          if (node_map_->GetOutputs(input->name()).count(consumer) == 0) {\n            consumer->add_input(AsControlDependency(input->name()));\n            node_map_->AddOutput(input->name(), consumer->name());\n            nodes_to_simplify->PushBack(node_to_idx_[input]);\n            updated_consumer = true;\n          }\n        }\n      }\n      updated_consumer |= RemoveControlInput(\n          consumer, AsControlDependency(node_name), node_map_.get());\n      if (updated_consumer) {\n        nodes_to_simplify->PushBack(node_to_idx_[consumer]);\n      }\n      VLOG(2) << \"consumer after:\\n\" << consumer->DebugString();\n    }\n    node_map_->RemoveOutputs(node_name);\n    if (fetch_nodes_known_ &&\n        nodes_to_preserve_.find(node_name) == nodes_to_preserve_.end()) {\n      \/\/ Mark the node for deletion.\n      nodes_to_delete->insert(node_idx);\n\n      \/\/ Disconnect the node from its inputs to enable further optimizations.\n      node_map_->RemoveInputs(node_name);\n      node->clear_input();\n    }\n  }\n}","target":0,"code_token_length":2220,"total_token_length":2456,"max_tokens_setting":4096}
+{"idx":227015,"func":"IRC_PROTOCOL_CALLBACK(366)\n{\n    struct t_irc_channel *ptr_channel;\n    struct t_infolist *infolist;\n    struct t_config_option *ptr_option;\n    int num_nicks, num_op, num_halfop, num_voice, num_normal, length, i;\n    char *string, str_nicks_count[2048], *color;\n    const char *prefix, *prefix_color, *nickname;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n    if (ptr_channel && ptr_channel->nicks)\n    {\n        \/* display users on channel *\/\n        if (weechat_hashtable_has_key (ptr_channel->join_msg_received, \"353\")\n            || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, \"353\"))\n        {\n            infolist = weechat_infolist_get (\"nicklist\", ptr_channel->buffer, NULL);\n            if (infolist)\n            {\n                length = 0;\n                while (weechat_infolist_next (infolist))\n                {\n                    if (strcmp (weechat_infolist_string (infolist, \"type\"),\n                                \"nick\") == 0)\n                    {\n                        ptr_option = weechat_config_get (weechat_infolist_string (infolist,\n                                                                                  \"prefix_color\"));\n                        length +=\n                            ((ptr_option) ? strlen (weechat_color (weechat_config_string (ptr_option))) : 0) +\n                            strlen (weechat_infolist_string (infolist, \"prefix\")) +\n                            16 + \/* nick color *\/\n                            strlen (weechat_infolist_string (infolist, \"name\")) +\n                            16 + \/* reset color *\/\n                            1; \/* space *\/\n                    }\n                }\n                if (length > 0)\n                {\n                    string = malloc (length);\n                    if (string)\n                    {\n                        string[0] = '\\0';\n                        i = 0;\n                        while (weechat_infolist_next (infolist))\n                        {\n                            if (strcmp (weechat_infolist_string (infolist, \"type\"),\n                                        \"nick\") == 0)\n                            {\n                                if (i > 0)\n                                {\n                                    strcat (string, IRC_COLOR_RESET);\n                                    strcat (string, \" \");\n                                }\n                                prefix = weechat_infolist_string (infolist, \"prefix\");\n                                if (prefix[0] && (prefix[0] != ' '))\n                                {\n                                    prefix_color = weechat_infolist_string (infolist,\n                                                                            \"prefix_color\");\n                                    if (strchr (prefix_color, '.'))\n                                    {\n                                        ptr_option = weechat_config_get (weechat_infolist_string (infolist,\n                                                                                                  \"prefix_color\"));\n                                        if (ptr_option)\n                                            strcat (string, weechat_color (weechat_config_string (ptr_option)));\n                                    }\n                                    else\n                                    {\n                                        strcat (string, weechat_color (prefix_color));\n                                    }\n                                    strcat (string, prefix);\n                                }\n                                nickname = weechat_infolist_string (infolist, \"name\");\n                                if (weechat_config_boolean (irc_config_look_color_nicks_in_names))\n                                {\n                                    if (irc_server_strcasecmp (server, nickname, server->nick) == 0)\n                                        strcat (string, IRC_COLOR_CHAT_NICK_SELF);\n                                    else\n                                    {\n                                        color = irc_nick_find_color (nickname);\n                                        strcat (string, color);\n                                        if (color)\n                                            free (color);\n                                    }\n                                }\n                                else\n                                    strcat (string, IRC_COLOR_RESET);\n                                strcat (string, nickname);\n                                i++;\n                            }\n                        }\n                        weechat_printf_date_tags (\n                            irc_msgbuffer_get_target_buffer (\n                                server, NULL, command, \"names\",\n                                ptr_channel->buffer),\n                            date,\n                            irc_protocol_tags (\n                                command, \"irc_numeric\", NULL, NULL),\n                            _(\"%sNicks %s%s%s: %s[%s%s]\"),\n                            weechat_prefix (\"network\"),\n                            IRC_COLOR_CHAT_CHANNEL,\n                            ptr_channel->name,\n                            IRC_COLOR_RESET,\n                            IRC_COLOR_CHAT_DELIMITERS,\n                            string,\n                            IRC_COLOR_CHAT_DELIMITERS);\n                        free (string);\n                    }\n                }\n                weechat_infolist_free (infolist);\n            }\n        }\n\n        \/* display number of nicks, ops, halfops & voices on the channel *\/\n        if (weechat_hashtable_has_key (ptr_channel->join_msg_received, \"366\")\n            || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, \"366\"))\n        {\n            irc_nick_count (server, ptr_channel, &num_nicks, &num_op, &num_halfop,\n                            &num_voice, &num_normal);\n            str_nicks_count[0] = '\\0';\n            if (irc_server_get_prefix_mode_index (server, 'o') >= 0)\n            {\n                length = strlen (str_nicks_count);\n                snprintf (str_nicks_count + length,\n                          sizeof (str_nicks_count) - length,\n                          \"%s%s%d%s %s\",\n                          (str_nicks_count[0]) ? \", \" : \"\",\n                          IRC_COLOR_CHAT_CHANNEL,\n                          num_op,\n                          IRC_COLOR_RESET,\n                          NG_(\"op\", \"ops\", num_op));\n            }\n            if (irc_server_get_prefix_mode_index (server, 'h') >= 0)\n            {\n                length = strlen (str_nicks_count);\n                snprintf (str_nicks_count + length,\n                          sizeof (str_nicks_count) - length,\n                          \"%s%s%d%s %s\",\n                          (str_nicks_count[0]) ? \", \" : \"\",\n                          IRC_COLOR_CHAT_CHANNEL,\n                          num_halfop,\n                          IRC_COLOR_RESET,\n                          NG_(\"halfop\", \"halfops\", num_halfop));\n            }\n            if (irc_server_get_prefix_mode_index (server, 'v') >= 0)\n            {\n                length = strlen (str_nicks_count);\n                snprintf (str_nicks_count + length,\n                          sizeof (str_nicks_count) - length,\n                          \"%s%s%d%s %s\",\n                          (str_nicks_count[0]) ? \", \" : \"\",\n                          IRC_COLOR_CHAT_CHANNEL,\n                          num_voice,\n                          IRC_COLOR_RESET,\n                          NG_(\"voice\", \"voices\", num_voice));\n            }\n            length = strlen (str_nicks_count);\n            snprintf (str_nicks_count + length,\n                      sizeof (str_nicks_count) - length,\n                      \"%s%s%d%s %s\",\n                      (str_nicks_count[0]) ? \", \" : \"\",\n                      IRC_COLOR_CHAT_CHANNEL,\n                      num_normal,\n                      IRC_COLOR_RESET,\n                      NG_(\"normal\", \"normals\", num_normal));\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (\n                    server, NULL, command, \"names\", ptr_channel->buffer),\n                date,\n                irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n                _(\"%sChannel %s%s%s: %s%d%s %s %s(%s%s)\"),\n                weechat_prefix (\"network\"),\n                IRC_COLOR_CHAT_CHANNEL,\n                ptr_channel->name,\n                IRC_COLOR_RESET,\n                IRC_COLOR_CHAT_CHANNEL,\n                num_nicks,\n                IRC_COLOR_RESET,\n                NG_(\"nick\", \"nicks\", num_nicks),\n                IRC_COLOR_CHAT_DELIMITERS,\n                str_nicks_count,\n                IRC_COLOR_CHAT_DELIMITERS);\n        }\n\n        if (!weechat_hashtable_has_key (ptr_channel->join_msg_received, command))\n        {\n            irc_command_mode_server (server, \"MODE\", ptr_channel, NULL,\n                                     IRC_SERVER_SEND_OUTQ_PRIO_LOW);\n            irc_channel_check_whox (server, ptr_channel);\n        }\n    }\n    else\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, NULL, command, \"names\", NULL),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s%s%s: %s\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_CHANNEL,\n            argv[3],\n            IRC_COLOR_RESET,\n            (argv[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]);\n    }\n\n    if (ptr_channel)\n    {\n        weechat_hashtable_set (ptr_channel->join_msg_received, \"353\", \"1\");\n        weechat_hashtable_set (ptr_channel->join_msg_received, \"366\", \"1\");\n    }\n\n    weechat_bar_item_update (\"input_prompt\");\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":1841,"total_token_length":2077,"max_tokens_setting":4096}
+{"idx":293493,"func":"gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data)\n{\n        const unsigned char *gif_data;\n        unsigned int index;\n        gif_result return_value;\n\n        \/* Initialize values *\/\n        gif->buffer_size = size;\n        gif->gif_data = data;\n\n        if (gif->lzw_ctx == NULL) {\n                lzw_result res = lzw_context_create(\n                                (struct lzw_ctx **)&gif->lzw_ctx);\n                if (res != LZW_OK) {\n                        return gif_error_from_lzw(res);\n                }\n        }\n\n        \/* Check for sufficient data to be a GIF (6-byte header + 7-byte\n         * logical screen descriptor)\n         *\/\n        if (gif->buffer_size < GIF_STANDARD_HEADER_SIZE) {\n                return GIF_INSUFFICIENT_DATA;\n        }\n\n        \/* Get our current processing position *\/\n        gif_data = gif->gif_data + gif->buffer_position;\n\n        \/* See if we should initialise the GIF *\/\n        if (gif->buffer_position == 0) {\n                \/* We want everything to be NULL before we start so we've no\n                 * chance of freeing bad pointers (paranoia)\n                 *\/\n                gif->frame_image = NULL;\n                gif->frames = NULL;\n                gif->local_colour_table = NULL;\n                gif->global_colour_table = NULL;\n\n                \/* The caller may have been lazy and not reset any values *\/\n                gif->frame_count = 0;\n                gif->frame_count_partial = 0;\n                gif->decoded_frame = GIF_INVALID_FRAME;\n\n                \/* 6-byte GIF file header is:\n                 *\n                 *\t+0\t3CHARS\tSignature ('GIF')\n                 *\t+3\t3CHARS\tVersion ('87a' or '89a')\n                 *\/\n                if (strncmp((const char *) gif_data, \"GIF\", 3) != 0) {\n                        return GIF_DATA_ERROR;\n                }\n                gif_data += 3;\n\n                \/* Ensure GIF reports version 87a or 89a *\/\n                \/*\n                if ((strncmp(gif_data, \"87a\", 3) != 0) &&\n                    (strncmp(gif_data, \"89a\", 3) != 0))\n                               LOG((\"Unknown GIF format - proceeding anyway\"));\n                *\/\n                gif_data += 3;\n\n                \/* 7-byte Logical Screen Descriptor is:\n                 *\n                 *\t+0\tSHORT\tLogical Screen Width\n                 *\t+2\tSHORT\tLogical Screen Height\n                 *\t+4\tCHAR\t__Packed Fields__\n                 *                      1BIT\tGlobal Colour Table Flag\n                 *                      3BITS\tColour Resolution\n                 *                      1BIT\tSort Flag\n                 *                      3BITS\tSize of Global Colour Table\n                 *\t+5\tCHAR\tBackground Colour Index\n                 *\t+6\tCHAR\tPixel Aspect Ratio\n                 *\/\n                gif->width = gif_data[0] | (gif_data[1] << 8);\n                gif->height = gif_data[2] | (gif_data[3] << 8);\n                gif->global_colours = (gif_data[4] & GIF_COLOUR_TABLE_MASK);\n                gif->colour_table_size = (2 << (gif_data[4] & GIF_COLOUR_TABLE_SIZE_MASK));\n                gif->background_index = gif_data[5];\n                gif->aspect_ratio = gif_data[6];\n                gif->loop_count = 1;\n                gif_data += 7;\n\n                \/* Some broken GIFs report the size as the screen size they\n                 * were created in. As such, we detect for the common cases and\n                 * set the sizes as 0 if they are found which results in the\n                 * GIF being the maximum size of the frames.\n                 *\/\n                if (((gif->width == 640) && (gif->height == 480)) ||\n                    ((gif->width == 640) && (gif->height == 512)) ||\n                    ((gif->width == 800) && (gif->height == 600)) ||\n                    ((gif->width == 1024) && (gif->height == 768)) ||\n                    ((gif->width == 1280) && (gif->height == 1024)) ||\n                    ((gif->width == 1600) && (gif->height == 1200)) ||\n                    ((gif->width == 0) || (gif->height == 0)) ||\n                    ((gif->width > 2048) || (gif->height > 2048))) {\n                        gif->width = 1;\n                        gif->height = 1;\n                }\n\n                \/* Allocate some data irrespective of whether we've got any\n                 * colour tables. We always get the maximum size in case a GIF\n                 * is lying to us. It's far better to give the wrong colours\n                 * than to trample over some memory somewhere.\n                *\/\n                gif->global_colour_table = calloc(GIF_MAX_COLOURS, sizeof(unsigned int));\n                gif->local_colour_table = calloc(GIF_MAX_COLOURS, sizeof(unsigned int));\n                if ((gif->global_colour_table == NULL) ||\n                    (gif->local_colour_table == NULL)) {\n                        gif_finalise(gif);\n                        return GIF_INSUFFICIENT_MEMORY;\n                }\n\n                \/* Set the first colour to a value that will never occur in\n                 * reality so we know if we've processed it\n                *\/\n                gif->global_colour_table[0] = GIF_PROCESS_COLOURS;\n\n                \/* Check if the GIF has no frame data (13-byte header + 1-byte\n                 * termination block) Although generally useless, the GIF\n                 * specification does not expressly prohibit this\n                 *\/\n                if (gif->buffer_size == (GIF_STANDARD_HEADER_SIZE + 1)) {\n                        if (gif_data[0] == GIF_TRAILER) {\n                                return GIF_OK;\n                        } else {\n                                return GIF_INSUFFICIENT_DATA;\n                        }\n                }\n\n                \/* Initialise enough workspace for a frame *\/\n                if ((gif->frames = (gif_frame *)malloc(sizeof(gif_frame))) == NULL) {\n                        gif_finalise(gif);\n                        return GIF_INSUFFICIENT_MEMORY;\n                }\n                gif->frame_holders = 1;\n\n                \/* Initialise the bitmap header *\/\n                assert(gif->bitmap_callbacks.bitmap_create);\n                gif->frame_image = gif->bitmap_callbacks.bitmap_create(gif->width, gif->height);\n                if (gif->frame_image == NULL) {\n                        gif_finalise(gif);\n                        return GIF_INSUFFICIENT_MEMORY;\n                }\n\n                \/* Remember we've done this now *\/\n                gif->buffer_position = gif_data - gif->gif_data;\n        }\n\n        \/*  Do the colour map if we haven't already. As the top byte is always\n         *  0xff or 0x00 depending on the transparency we know if it's been\n         *  filled in.\n         *\/\n        if (gif->global_colour_table[0] == GIF_PROCESS_COLOURS) {\n                \/* Check for a global colour map signified by bit 7 *\/\n                if (gif->global_colours) {\n                        if (gif->buffer_size < (gif->colour_table_size * 3 + GIF_STANDARD_HEADER_SIZE)) {\n                                return GIF_INSUFFICIENT_DATA;\n                        }\n                        for (index = 0; index < gif->colour_table_size; index++) {\n                                \/* Gif colour map contents are r,g,b.\n                                 *\n                                 * We want to pack them bytewise into the\n                                 * colour table, such that the red component\n                                 * is in byte 0 and the alpha component is in\n                                 * byte 3.\n                                 *\/\n                                unsigned char *entry = (unsigned char *) &gif->\n                                                       global_colour_table[index];\n\n                                entry[0] = gif_data[0];\t\/* r *\/\n                                entry[1] = gif_data[1];\t\/* g *\/\n                                entry[2] = gif_data[2];\t\/* b *\/\n                                entry[3] = 0xff;\t\/* a *\/\n\n                                gif_data += 3;\n                        }\n                        gif->buffer_position = (gif_data - gif->gif_data);\n                } else {\n                        \/* Create a default colour table with the first two\n                         * colours as black and white\n                         *\/\n                        unsigned int *entry = gif->global_colour_table;\n\n                        entry[0] = 0x00000000;\n                        \/* Force Alpha channel to opaque *\/\n                        ((unsigned char *) entry)[3] = 0xff;\n\n                        entry[1] = 0xffffffff;\n                }\n        }\n\n        \/* Repeatedly try to initialise frames *\/\n        while ((return_value = gif_initialise_frame(gif)) == GIF_WORKING);\n\n        \/* If there was a memory error tell the caller *\/\n        if ((return_value == GIF_INSUFFICIENT_MEMORY) ||\n            (return_value == GIF_DATA_ERROR)) {\n                return return_value;\n        }\n\n        \/* If we didn't have some frames then a GIF_INSUFFICIENT_DATA becomes a\n         * GIF_INSUFFICIENT_FRAME_DATA\n         *\/\n        if ((return_value == GIF_INSUFFICIENT_DATA) &&\n            (gif->frame_count_partial > 0)) {\n                return GIF_INSUFFICIENT_FRAME_DATA;\n        }\n\n        \/* Return how many we got *\/\n        return return_value;\n}","target":0,"code_token_length":1974,"total_token_length":2210,"max_tokens_setting":4096}
+{"idx":204069,"func":"do_window(\n    int\t\tnchar,\n    long\tPrenum,\n    int\t\txchar)\t    \/\/ extra char from \":wincmd gx\" or NUL\n{\n    long\tPrenum1;\n    win_T\t*wp;\n#if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID)\n    char_u\t*ptr;\n    linenr_T    lnum = -1;\n#endif\n#ifdef FEAT_FIND_ID\n    int\t\ttype = FIND_DEFINE;\n    int\t\tlen;\n#endif\n    char_u\tcbuf[40];\n\n    if (ERROR_IF_ANY_POPUP_WINDOW)\n\treturn;\n\n#ifdef FEAT_CMDWIN\n# define CHECK_CMDWIN \\\n    do { \\\n\tif (cmdwin_type != 0) \\\n\t{ \\\n\t    emsg(_(e_invalid_in_cmdline_window)); \\\n\t    return; \\\n\t} \\\n    } while (0)\n#else\n# define CHECK_CMDWIN do { \/**\/ } while (0)\n#endif\n\n    Prenum1 = Prenum == 0 ? 1 : Prenum;\n\n    switch (nchar)\n    {\n\/\/ split current window in two parts, horizontally\n    case 'S':\n    case Ctrl_S:\n    case 's':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n#ifdef FEAT_QUICKFIX\n\t\t\/\/ When splitting the quickfix window open a new buffer in it,\n\t\t\/\/ don't replicate the quickfix buffer.\n\t\tif (bt_quickfix(curbuf))\n\t\t    goto newwindow;\n#endif\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\t(void)win_split((int)Prenum, 0);\n\t\tbreak;\n\n\/\/ split current window in two parts, vertically\n    case Ctrl_V:\n    case 'v':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n#ifdef FEAT_QUICKFIX\n\t\t\/\/ When splitting the quickfix window open a new buffer in it,\n\t\t\/\/ don't replicate the quickfix buffer.\n\t\tif (bt_quickfix(curbuf))\n\t\t    goto newwindow;\n#endif\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\t(void)win_split((int)Prenum, WSP_VERT);\n\t\tbreak;\n\n\/\/ split current window and edit alternate file\n    case Ctrl_HAT:\n    case '^':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\n\t\tif (buflist_findnr(Prenum == 0\n\t\t\t\t\t? curwin->w_alt_fnum : Prenum) == NULL)\n\t\t{\n\t\t    if (Prenum == 0)\n\t\t\temsg(_(e_no_alternate_file));\n\t\t    else\n\t\t\tsemsg(_(e_buffer_nr_not_found), Prenum);\n\t\t    break;\n\t\t}\n\n\t\tif (!curbuf_locked() && win_split(0, 0) == OK)\n\t\t    (void)buflist_getfile(\n\t\t\t    Prenum == 0 ? curwin->w_alt_fnum : Prenum,\n\t\t\t    (linenr_T)0, GETF_ALT, FALSE);\n\t\tbreak;\n\n\/\/ open new window\n    case Ctrl_N:\n    case 'n':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n#ifdef FEAT_QUICKFIX\nnewwindow:\n#endif\n\t\tif (Prenum)\n\t\t    \/\/ window height\n\t\t    vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, \"%ld\", Prenum);\n\t\telse\n\t\t    cbuf[0] = NUL;\n#if defined(FEAT_QUICKFIX)\n\t\tif (nchar == 'v' || nchar == Ctrl_V)\n\t\t    STRCAT(cbuf, \"v\");\n#endif\n\t\tSTRCAT(cbuf, \"new\");\n\t\tdo_cmdline_cmd(cbuf);\n\t\tbreak;\n\n\/\/ quit current window\n    case Ctrl_Q:\n    case 'q':\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\t\tcmd_with_count(\"quit\", cbuf, sizeof(cbuf), Prenum);\n\t\tdo_cmdline_cmd(cbuf);\n\t\tbreak;\n\n\/\/ close current window\n    case Ctrl_C:\n    case 'c':\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\t\tcmd_with_count(\"close\", cbuf, sizeof(cbuf), Prenum);\n\t\tdo_cmdline_cmd(cbuf);\n\t\tbreak;\n\n#if defined(FEAT_QUICKFIX)\n\/\/ close preview window\n    case Ctrl_Z:\n    case 'z':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\t\tdo_cmdline_cmd((char_u *)\"pclose\");\n\t\tbreak;\n\n\/\/ cursor to preview window\n    case 'P':\n\t\tFOR_ALL_WINDOWS(wp)\n\t\t    if (wp->w_p_pvw)\n\t\t\tbreak;\n\t\tif (wp == NULL)\n\t\t    emsg(_(e_there_is_no_preview_window));\n\t\telse\n\t\t    win_goto(wp);\n\t\tbreak;\n#endif\n\n\/\/ close all but current window\n    case Ctrl_O:\n    case 'o':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\t\tcmd_with_count(\"only\", cbuf, sizeof(cbuf), Prenum);\n\t\tdo_cmdline_cmd(cbuf);\n\t\tbreak;\n\n\/\/ cursor to next window with wrap around\n    case Ctrl_W:\n    case 'w':\n\/\/ cursor to previous window with wrap around\n    case 'W':\n\t\tCHECK_CMDWIN;\n\t\tif (ONE_WINDOW && Prenum != 1)\t\/\/ just one window\n\t\t    beep_flush();\n\t\telse\n\t\t{\n\t\t    if (Prenum)\t\t\t\/\/ go to specified window\n\t\t    {\n\t\t\tfor (wp = firstwin; --Prenum > 0; )\n\t\t\t{\n\t\t\t    if (wp->w_next == NULL)\n\t\t\t\tbreak;\n\t\t\t    else\n\t\t\t\twp = wp->w_next;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (nchar == 'W')\t    \/\/ go to previous window\n\t\t\t{\n\t\t\t    wp = curwin->w_prev;\n\t\t\t    if (wp == NULL)\n\t\t\t\twp = lastwin;\t    \/\/ wrap around\n\t\t\t}\n\t\t\telse\t\t\t    \/\/ go to next window\n\t\t\t{\n\t\t\t    wp = curwin->w_next;\n\t\t\t    if (wp == NULL)\n\t\t\t\twp = firstwin;\t    \/\/ wrap around\n\t\t\t}\n\t\t    }\n\t\t    win_goto(wp);\n\t\t}\n\t\tbreak;\n\n\/\/ cursor to window below\n    case 'j':\n    case K_DOWN:\n    case Ctrl_J:\n\t\tCHECK_CMDWIN;\n\t\twin_goto_ver(FALSE, Prenum1);\n\t\tbreak;\n\n\/\/ cursor to window above\n    case 'k':\n    case K_UP:\n    case Ctrl_K:\n\t\tCHECK_CMDWIN;\n\t\twin_goto_ver(TRUE, Prenum1);\n\t\tbreak;\n\n\/\/ cursor to left window\n    case 'h':\n    case K_LEFT:\n    case Ctrl_H:\n    case K_BS:\n\t\tCHECK_CMDWIN;\n\t\twin_goto_hor(TRUE, Prenum1);\n\t\tbreak;\n\n\/\/ cursor to right window\n    case 'l':\n    case K_RIGHT:\n    case Ctrl_L:\n\t\tCHECK_CMDWIN;\n\t\twin_goto_hor(FALSE, Prenum1);\n\t\tbreak;\n\n\/\/ move window to new tab page\n    case 'T':\n\t\tCHECK_CMDWIN;\n\t\tif (one_window())\n\t\t    msg(_(m_onlyone));\n\t\telse\n\t\t{\n\t\t    tabpage_T\t*oldtab = curtab;\n\t\t    tabpage_T\t*newtab;\n\n\t\t    \/\/ First create a new tab with the window, then go back to\n\t\t    \/\/ the old tab and close the window there.\n\t\t    wp = curwin;\n\t\t    if (win_new_tabpage((int)Prenum) == OK\n\t\t\t\t\t\t     && valid_tabpage(oldtab))\n\t\t    {\n\t\t\tnewtab = curtab;\n\t\t\tgoto_tabpage_tp(oldtab, TRUE, TRUE);\n\t\t\tif (curwin == wp)\n\t\t\t    win_close(curwin, FALSE);\n\t\t\tif (valid_tabpage(newtab))\n\t\t\t    goto_tabpage_tp(newtab, TRUE, TRUE);\n\t\t    }\n\t\t}\n\t\tbreak;\n\n\/\/ cursor to top-left window\n    case 't':\n    case Ctrl_T:\n\t\twin_goto(firstwin);\n\t\tbreak;\n\n\/\/ cursor to bottom-right window\n    case 'b':\n    case Ctrl_B:\n\t\twin_goto(lastwin);\n\t\tbreak;\n\n\/\/ cursor to last accessed (previous) window\n    case 'p':\n    case Ctrl_P:\n\t\tif (!win_valid(prevwin))\n\t\t    beep_flush();\n\t\telse\n\t\t    win_goto(prevwin);\n\t\tbreak;\n\n\/\/ exchange current and next window\n    case 'x':\n    case Ctrl_X:\n\t\tCHECK_CMDWIN;\n\t\twin_exchange(Prenum);\n\t\tbreak;\n\n\/\/ rotate windows downwards\n    case Ctrl_R:\n    case 'r':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\t\twin_rotate(FALSE, (int)Prenum1);    \/\/ downwards\n\t\tbreak;\n\n\/\/ rotate windows upwards\n    case 'R':\n\t\tCHECK_CMDWIN;\n\t\treset_VIsual_and_resel();\t\/\/ stop Visual mode\n\t\twin_rotate(TRUE, (int)Prenum1);\t    \/\/ upwards\n\t\tbreak;\n\n\/\/ move window to the very top\/bottom\/left\/right\n    case 'K':\n    case 'J':\n    case 'H':\n    case 'L':\n\t\tCHECK_CMDWIN;\n\t\twin_totop((int)Prenum,\n\t\t\t((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0)\n\t\t\t| ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT));\n\t\tbreak;\n\n\/\/ make all windows the same height\n    case '=':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_equal(NULL, FALSE, 'b');\n\t\tbreak;\n\n\/\/ increase current window height\n    case '+':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_setheight(curwin->w_height + (int)Prenum1);\n\t\tbreak;\n\n\/\/ decrease current window height\n    case '-':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_setheight(curwin->w_height - (int)Prenum1);\n\t\tbreak;\n\n\/\/ set current window height\n    case Ctrl__:\n    case '_':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_setheight(Prenum ? (int)Prenum : 9999);\n\t\tbreak;\n\n\/\/ increase current window width\n    case '>':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_setwidth(curwin->w_width + (int)Prenum1);\n\t\tbreak;\n\n\/\/ decrease current window width\n    case '<':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_setwidth(curwin->w_width - (int)Prenum1);\n\t\tbreak;\n\n\/\/ set current window width\n    case '|':\n#ifdef FEAT_GUI\n\t\tneed_mouse_correct = TRUE;\n#endif\n\t\twin_setwidth(Prenum != 0 ? (int)Prenum : 9999);\n\t\tbreak;\n\n\/\/ jump to tag and split window if tag exists (in preview window)\n#if defined(FEAT_QUICKFIX)\n    case '}':\n\t\tCHECK_CMDWIN;\n\t\tif (Prenum)\n\t\t    g_do_tagpreview = Prenum;\n\t\telse\n\t\t    g_do_tagpreview = p_pvh;\n#endif\n\t\t\/\/ FALLTHROUGH\n    case ']':\n    case Ctrl_RSB:\n\t\tCHECK_CMDWIN;\n\t\t\/\/ keep Visual mode, can select words to use as a tag\n\t\tif (Prenum)\n\t\t    postponed_split = Prenum;\n\t\telse\n\t\t    postponed_split = -1;\n#ifdef FEAT_QUICKFIX\n\t\tif (nchar != '}')\n\t\t    g_do_tagpreview = 0;\n#endif\n\n\t\t\/\/ Execute the command right here, required when \"wincmd ]\"\n\t\t\/\/ was used in a function.\n\t\tdo_nv_ident(Ctrl_RSB, NUL);\n\t\tbreak;\n\n#ifdef FEAT_SEARCHPATH\n\/\/ edit file name under cursor in a new window\n    case 'f':\n    case 'F':\n    case Ctrl_F:\nwingotofile:\n\t\tCHECK_CMDWIN;\n\n\t\tptr = grab_file_name(Prenum1, &lnum);\n\t\tif (ptr != NULL)\n\t\t{\n\t\t    tabpage_T\t*oldtab = curtab;\n\t\t    win_T\t*oldwin = curwin;\n# ifdef FEAT_GUI\n\t\t    need_mouse_correct = TRUE;\n# endif\n\t\t    setpcmark();\n\t\t    if (win_split(0, 0) == OK)\n\t\t    {\n\t\t\tRESET_BINDING(curwin);\n\t\t\tif (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,\n\t\t\t\t\t\t   ECMD_HIDE, NULL) == FAIL)\n\t\t\t{\n\t\t\t    \/\/ Failed to open the file, close the window\n\t\t\t    \/\/ opened for it.\n\t\t\t    win_close(curwin, FALSE);\n\t\t\t    goto_tabpage_win(oldtab, oldwin);\n\t\t\t}\n\t\t\telse if (nchar == 'F' && lnum >= 0)\n\t\t\t{\n\t\t\t    curwin->w_cursor.lnum = lnum;\n\t\t\t    check_cursor_lnum();\n\t\t\t    beginline(BL_SOL | BL_FIX);\n\t\t\t}\n\t\t    }\n\t\t    vim_free(ptr);\n\t\t}\n\t\tbreak;\n#endif\n\n#ifdef FEAT_FIND_ID\n\/\/ Go to the first occurrence of the identifier under cursor along path in a\n\/\/ new window -- webb\n    case 'i':\t\t\t    \/\/ Go to any match\n    case Ctrl_I:\n\t\ttype = FIND_ANY;\n\t\t\/\/ FALLTHROUGH\n    case 'd':\t\t\t    \/\/ Go to definition, using 'define'\n    case Ctrl_D:\n\t\tCHECK_CMDWIN;\n\t\tif ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0)\n\t\t    break;\n\t\tfind_pattern_in_path(ptr, 0, len, TRUE,\n\t\t\tPrenum == 0 ? TRUE : FALSE, type,\n\t\t\tPrenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM);\n\t\tcurwin->w_set_curswant = TRUE;\n\t\tbreak;\n#endif\n\n\/\/ Quickfix window only: view the result under the cursor in a new split.\n#if defined(FEAT_QUICKFIX)\n    case K_KENTER:\n    case CAR:\n\t\tif (bt_quickfix(curbuf))\n\t\t    qf_view_result(TRUE);\n\t\tbreak;\n#endif\n\n\/\/ CTRL-W g  extended commands\n    case 'g':\n    case Ctrl_G:\n\t\tCHECK_CMDWIN;\n#ifdef USE_ON_FLY_SCROLL\n\t\tdont_scroll = TRUE;\t\t\/\/ disallow scrolling here\n#endif\n\t\t++no_mapping;\n\t\t++allow_keys;   \/\/ no mapping for xchar, but allow key codes\n\t\tif (xchar == NUL)\n\t\t    xchar = plain_vgetc();\n\t\tLANGMAP_ADJUST(xchar, TRUE);\n\t\t--no_mapping;\n\t\t--allow_keys;\n#ifdef FEAT_CMDL_INFO\n\t\t(void)add_to_showcmd(xchar);\n#endif\n\t\tswitch (xchar)\n\t\t{\n#if defined(FEAT_QUICKFIX)\n\t\t    case '}':\n\t\t\txchar = Ctrl_RSB;\n\t\t\tif (Prenum)\n\t\t\t    g_do_tagpreview = Prenum;\n\t\t\telse\n\t\t\t    g_do_tagpreview = p_pvh;\n#endif\n\t\t\t\/\/ FALLTHROUGH\n\t\t    case ']':\n\t\t    case Ctrl_RSB:\n\t\t\t\/\/ keep Visual mode, can select words to use as a tag\n\t\t\tif (Prenum)\n\t\t\t    postponed_split = Prenum;\n\t\t\telse\n\t\t\t    postponed_split = -1;\n\n\t\t\t\/\/ Execute the command right here, required when\n\t\t\t\/\/ \"wincmd g}\" was used in a function.\n\t\t\tdo_nv_ident('g', xchar);\n\t\t\tbreak;\n\n#ifdef FEAT_SEARCHPATH\n\t\t    case 'f':\t    \/\/ CTRL-W gf: \"gf\" in a new tab page\n\t\t    case 'F':\t    \/\/ CTRL-W gF: \"gF\" in a new tab page\n\t\t\tcmdmod.cmod_tab = tabpage_index(curtab) + 1;\n\t\t\tnchar = xchar;\n\t\t\tgoto wingotofile;\n#endif\n\t\t    case 't':\t    \/\/ CTRL-W gt: go to next tab page\n\t\t\tgoto_tabpage((int)Prenum);\n\t\t\tbreak;\n\n\t\t    case 'T':\t    \/\/ CTRL-W gT: go to previous tab page\n\t\t\tgoto_tabpage(-(int)Prenum1);\n\t\t\tbreak;\n\n\t\t    case TAB:\t    \/\/ CTRL-W g<Tab>: go to last used tab page\n\t\t\tif (goto_tabpage_lastused() == FAIL)\n\t\t\t    beep_flush();\n\t\t\tbreak;\n\n\t\t    default:\n\t\t\tbeep_flush();\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n    default:\tbeep_flush();\n\t\tbreak;\n    }\n}","target":1,"code_token_length":3595,"total_token_length":3831,"max_tokens_setting":4096}
+{"idx":406212,"func":"static int mk_exit_code(struct libmnt_context *cxt, int rc)\n{\n\tint syserr;\n\tstruct stat st;\n\tunsigned long uflags = 0, mflags = 0;\n\n\tint restricted = mnt_context_is_restricted(cxt);\n\tconst char *tgt = mnt_context_get_target(cxt);\n\tconst char *src = mnt_context_get_source(cxt);\n\ntry_readonly:\n\tif (mnt_context_helper_executed(cxt))\n\t\t\/*\n\t\t * \/sbin\/mount.<type> called, return status\n\t\t *\/\n\t\treturn mnt_context_get_helper_status(cxt);\n\n\tif (rc == 0 && mnt_context_get_status(cxt) == 1) {\n\t\t\/*\n\t\t * Libmount success && syscall success.\n\t\t *\/\n\t\tselinux_warning(cxt, tgt);\n\n\t\treturn MOUNT_EX_SUCCESS;\t\/* mount(2) success *\/\n\t}\n\n\tmnt_context_get_mflags(cxt, &mflags);\t\t\/* mount(2) flags *\/\n\tmnt_context_get_user_mflags(cxt, &uflags);\t\/* userspace flags *\/\n\n\tif (!mnt_context_syscall_called(cxt)) {\n\t\t\/*\n\t\t * libmount errors (extra library checks)\n\t\t *\/\n\t\tswitch (rc) {\n\t\tcase -EPERM:\n\t\t\twarnx(_(\"only root can mount %s on %s\"), src, tgt);\n\t\t\treturn MOUNT_EX_USAGE;\n\t\tcase -EBUSY:\n\t\t\twarnx(_(\"%s is already mounted\"), src);\n\t\t\treturn MOUNT_EX_USAGE;\n\t\tcase -MNT_ERR_NOFSTAB:\n\t\t\tif (mnt_context_is_swapmatch(cxt)) {\n\t\t\t\twarnx(_(\"can't find %s in %s\"),\n\t\t\t\t\t\tsrc ? src : tgt,\n\t\t\t\t\t\tmnt_get_fstab_path());\n\t\t\t\treturn MOUNT_EX_USAGE;\n\t\t\t}\n\t\t\t\/* source\/target explicitly defined *\/\n\t\t\tif (tgt)\n\t\t\t\twarnx(_(\"can't find mountpoint %s in %s\"),\n\t\t\t\t\t\ttgt, mnt_get_fstab_path());\n\t\t\telse\n\t\t\t\twarnx(_(\"can't find mount source %s in %s\"),\n\t\t\t\t\t\tsrc, mnt_get_fstab_path());\n\t\t\treturn MOUNT_EX_USAGE;\n\t\tcase -MNT_ERR_NOFSTYPE:\n\t\t\tif (restricted)\n\t\t\t\twarnx(_(\"I could not determine the filesystem type, \"\n\t\t\t\t\t\"and none was specified\"));\n\t\t\telse\n\t\t\t\twarnx(_(\"you must specify the filesystem type\"));\n\t\t\treturn MOUNT_EX_USAGE;\n\t\tcase -MNT_ERR_NOSOURCE:\n\t\t\tif (src)\n\t\t\t\twarnx(_(\"can't find %s\"), src);\n\t\t\telse\n\t\t\t\twarnx(_(\"mount source not defined\"));\n\t\t\treturn MOUNT_EX_USAGE;\n\t\tcase -MNT_ERR_MOUNTOPT:\n\t\t\tif (errno)\n\t\t\t\twarn(_(\"failed to parse mount options\"));\n\t\t\telse\n\t\t\t\twarnx(_(\"failed to parse mount options\"));\n\t\t\treturn MOUNT_EX_USAGE;\n\t\tcase -MNT_ERR_LOOPDEV:\n\t\t\twarn(_(\"%s: failed to setup loop device\"), src);\n\t\t\treturn MOUNT_EX_FAIL;\n\t\tdefault:\n\t\t\treturn handle_generic_errors(rc, _(\"%s: mount failed\"),\n\t\t\t\t\t     tgt ? tgt : src);\n\t\t}\n\t} else if (mnt_context_get_syscall_errno(cxt) == 0) {\n\t\t\/*\n\t\t * mount(2) syscall success, but something else failed\n\t\t * (probably error in mtab processing).\n\t\t *\/\n\t\tif (rc < 0)\n\t\t\treturn handle_generic_errors(rc,\n\t\t\t\t_(\"%s: filesystem mounted, but mount(8) failed\"),\n\t\t\t\ttgt ? tgt : src);\n\n\t\treturn MOUNT_EX_SOFTWARE;\t\/* internal error *\/\n\n\t}\n\n\t\/*\n\t * mount(2) errors\n\t *\/\n\tsyserr = mnt_context_get_syscall_errno(cxt);\n\n\n\tswitch(syserr) {\n\tcase EPERM:\n\t\tif (geteuid() == 0) {\n\t\t\tif (stat(tgt, &st) || !S_ISDIR(st.st_mode))\n\t\t\t\twarnx(_(\"mount point %s is not a directory\"), tgt);\n\t\t\telse\n\t\t\t\twarnx(_(\"permission denied\"));\n\t\t} else\n\t\t\twarnx(_(\"must be superuser to use mount\"));\n\t      break;\n\n\tcase EBUSY:\n\t{\n\t\tstruct libmnt_table *tb;\n\n\t\tif (mflags & MS_REMOUNT) {\n\t\t\twarnx(_(\"%s is busy\"), tgt);\n\t\t\tbreak;\n\t\t}\n\n\t\twarnx(_(\"%s is already mounted or %s busy\"), src, tgt);\n\n\t\tif (src && mnt_context_get_mtab(cxt, &tb) == 0) {\n\t\t\tstruct libmnt_iter *itr = mnt_new_iter(MNT_ITER_FORWARD);\n\t\t\tstruct libmnt_fs *fs;\n\n\t\t\twhile(mnt_table_next_fs(tb, itr, &fs) == 0) {\n\t\t\t\tconst char *s = mnt_fs_get_srcpath(fs),\n\t\t\t\t\t   *t = mnt_fs_get_target(fs);\n\n\t\t\t\tif (t && s && mnt_fs_streq_srcpath(fs, src))\n\t\t\t\t\tfprintf(stderr, _(\n\t\t\t\t\t\t\"       %s is already mounted on %s\\n\"), s, t);\n\t\t\t}\n\t\t\tmnt_free_iter(itr);\n\t\t}\n\t\tbreak;\n\t}\n\tcase ENOENT:\n\t\tif (lstat(tgt, &st))\n\t\t\twarnx(_(\"mount point %s does not exist\"), tgt);\n\t\telse if (stat(tgt, &st))\n\t\t\twarnx(_(\"mount point %s is a symbolic link to nowhere\"), tgt);\n\t\telse if (stat(src, &st)) {\n\t\t\tif (uflags & MNT_MS_NOFAIL)\n\t\t\t\treturn MOUNT_EX_SUCCESS;\n\n\t\t\twarnx(_(\"special device %s does not exist\"), src);\n\t\t} else {\n\t\t\terrno = syserr;\n\t\t\twarn(_(\"mount(2) failed\"));\t\/* print errno *\/\n\t\t}\n\t\tbreak;\n\n\tcase ENOTDIR:\n\t\tif (stat(tgt, &st) || ! S_ISDIR(st.st_mode))\n\t\t\twarnx(_(\"mount point %s is not a directory\"), tgt);\n\t\telse if (stat(src, &st) && errno == ENOTDIR) {\n\t\t\tif (uflags & MNT_MS_NOFAIL)\n\t\t\t\treturn MOUNT_EX_SUCCESS;\n\n\t\t\twarnx(_(\"special device %s does not exist \"\n\t\t\t\t \"(a path prefix is not a directory)\"), src);\n\t\t} else {\n\t\t\terrno = syserr;\n\t\t\twarn(_(\"mount(2) failed\"));     \/* print errno *\/\n\t\t}\n\t\tbreak;\n\n\tcase EINVAL:\n\t\tif (mflags & MS_REMOUNT)\n\t\t\twarnx(_(\"%s not mounted or bad option\"), tgt);\n\t\telse if (mflags & MS_PROPAGATION)\n\t\t\twarnx(_(\"%s is not mountpoint or bad option\"), tgt);\n\t\telse\n\t\t\twarnx(_(\"wrong fs type, bad option, bad superblock on %s,\\n\"\n\t\t\t\t\"       missing codepage or helper program, or other error\"),\n\t\t\t\tsrc);\n\n\t\tif (mnt_fs_is_netfs(mnt_context_get_fs(cxt)))\n\t\t\tfprintf(stderr, _(\n\t\t\t\t\"       (for several filesystems (e.g. nfs, cifs) you might\\n\"\n\t\t\t\t\"       need a \/sbin\/mount.<type> helper program)\\n\"));\n\n\t\tfprintf(stderr, _(\n\t\t\t\t\"       In some cases useful info is found in syslog - try\\n\"\n\t\t\t\t\"       dmesg | tail or so\\n\"));\n\t\tbreak;\n\n\tcase EMFILE:\n\t\twarnx(_(\"mount table full\"));\n\t\tbreak;\n\n\tcase EIO:\n\t\twarnx(_(\"%s: can't read superblock\"), src);\n\t\tbreak;\n\n\tcase ENODEV:\n\t\twarnx(_(\"unknown filesystem type '%s'\"), mnt_context_get_fstype(cxt));\n\t\tbreak;\n\n\tcase ENOTBLK:\n\t\tif (uflags & MNT_MS_NOFAIL)\n\t\t\treturn MOUNT_EX_SUCCESS;\n\n\t\tif (stat(src, &st))\n\t\t\twarnx(_(\"%s is not a block device, and stat(2) fails?\"), src);\n\t\telse if (S_ISBLK(st.st_mode))\n\t\t\twarnx(_(\"the kernel does not recognize %s as a block device\\n\"\n\t\t\t\t\"       (maybe `modprobe driver'?)\"), src);\n\t\telse if (S_ISREG(st.st_mode))\n\t\t\twarnx(_(\"%s is not a block device (maybe try `-o loop'?)\"), src);\n\t\telse\n\t\t\twarnx(_(\" %s is not a block device\"), src);\n\t\tbreak;\n\n\tcase ENXIO:\n\t\tif (uflags & MNT_MS_NOFAIL)\n\t\t\treturn MOUNT_EX_SUCCESS;\n\n\t\twarnx(_(\"%s is not a valid block device\"), src);\n\t\tbreak;\n\n\tcase EACCES:\n\tcase EROFS:\n\t\tif (mflags & MS_RDONLY)\n\t\t\twarnx(_(\"cannot mount %s read-only\"), src);\n\n\t\telse if (readwrite)\n\t\t\twarnx(_(\"%s is write-protected but explicit `-w' flag given\"), src);\n\n\t\telse if (mflags & MS_REMOUNT)\n\t\t\twarnx(_(\"cannot remount %s read-write, is write-protected\"), src);\n\n\t\telse {\n\t\t\twarnx(_(\"%s is write-protected, mounting read-only\"), src);\n\n\t\t\tmnt_context_reset_status(cxt);\n\t\t\tmnt_context_set_mflags(cxt, mflags | MS_RDONLY);\n\t\t\trc = mnt_context_do_mount(cxt);\n\t\t\tif (!rc)\n\t\t\t\trc = mnt_context_finalize_mount(cxt);\n\n\t\t\tgoto try_readonly;\n\t\t}\n\t\tbreak;\n\n\tcase ENOMEDIUM:\n\t\twarnx(_(\"no medium found on %s\"), src);\n\t\tbreak;\n\n\tdefault:\n\t\twarn(_(\"mount %s on %s failed\"), src, tgt);\n\t\tbreak;\n\t}\n\n\treturn MOUNT_EX_FAIL;\n}","target":0,"code_token_length":2068,"total_token_length":2304,"max_tokens_setting":4096}
+{"idx":206262,"func":"parse_command_modifiers(\n\texarg_T\t    *eap,\n\tchar\t    **errormsg,\n\tcmdmod_T    *cmod,\n\tint\t    skip_only)\n{\n    char_u  *orig_cmd = eap->cmd;\n    char_u  *cmd_start = NULL;\n    int\t    use_plus_cmd = FALSE;\n    int\t    starts_with_colon = FALSE;\n    int\t    vim9script = in_vim9script();\n    int\t    has_visual_range = FALSE;\n\n    CLEAR_POINTER(cmod);\n    cmod->cmod_flags = sticky_cmdmod_flags;\n\n    if (STRNCMP(eap->cmd, \"'<,'>\", 5) == 0)\n    {\n\t\/\/ The automatically inserted Visual area range is skipped, so that\n\t\/\/ typing \":cmdmod cmd\" in Visual mode works without having to move the\n\t\/\/ range to after the modififiers. The command will be\n\t\/\/ \"'<,'>cmdmod cmd\", parse \"cmdmod cmd\" and then put back \"'<,'>\"\n\t\/\/ before \"cmd\" below.\n\teap->cmd += 5;\n\tcmd_start = eap->cmd;\n\thas_visual_range = TRUE;\n    }\n\n    \/\/ Repeat until no more command modifiers are found.\n    for (;;)\n    {\n\tchar_u  *p;\n\n\twhile (*eap->cmd == ' ' || *eap->cmd == '\\t' || *eap->cmd == ':')\n\t{\n\t    if (*eap->cmd == ':')\n\t\tstarts_with_colon = TRUE;\n\t    ++eap->cmd;\n\t}\n\n\t\/\/ in ex mode, an empty command (after modifiers) works like :+\n\tif (*eap->cmd == NUL && exmode_active\n\t\t   && (getline_equal(eap->getline, eap->cookie, getexmodeline)\n\t\t       || getline_equal(eap->getline, eap->cookie, getexline))\n\t\t\t&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)\n\t{\n\t    use_plus_cmd = TRUE;\n\t    if (!skip_only)\n\t\tex_pressedreturn = TRUE;\n\t    break;  \/\/ no modifiers following\n\t}\n\n\t\/\/ ignore comment and empty lines\n\tif (comment_start(eap->cmd, starts_with_colon))\n\t{\n\t    \/\/ a comment ends at a NL\n\t    if (eap->nextcmd == NULL)\n\t    {\n\t\teap->nextcmd = vim_strchr(eap->cmd, '\\n');\n\t\tif (eap->nextcmd != NULL)\n\t\t    ++eap->nextcmd;\n\t    }\n\t    if (vim9script && has_cmdmod(cmod, FALSE))\n\t\t*errormsg = _(e_command_modifier_without_command);\n\t    return FAIL;\n\t}\n\tif (*eap->cmd == NUL)\n\t{\n\t    if (!skip_only)\n\t    {\n\t\tex_pressedreturn = TRUE;\n\t\tif (vim9script && has_cmdmod(cmod, FALSE))\n\t\t    *errormsg = _(e_command_modifier_without_command);\n\t    }\n\t    return FAIL;\n\t}\n\n\tp = skip_range(eap->cmd, TRUE, NULL);\n\n\t\/\/ In Vim9 script a variable can shadow a command modifier:\n\t\/\/   verbose = 123\n\t\/\/   verbose += 123\n\t\/\/   silent! verbose = func()\n\t\/\/   verbose.member = 2\n\t\/\/   verbose[expr] = 2\n\t\/\/ But not:\n\t\/\/   verbose [a, b] = list\n\tif (vim9script)\n\t{\n\t    char_u *s, *n;\n\n\t    for (s = eap->cmd; ASCII_ISALPHA(*s); ++s)\n\t\t;\n\t    n = skipwhite(s);\n\t    if (*n == '.' || *n == '=' || (*n != NUL && n[1] == '=')\n\t\t    || *s == '[')\n\t\tbreak;\n\t}\n\n\tswitch (*p)\n\t{\n\t    \/\/ When adding an entry, also modify cmd_exists().\n\t    case 'a':\tif (!checkforcmd_noparen(&eap->cmd, \"aboveleft\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_ABOVE;\n\t\t\tcontinue;\n\n\t    case 'b':\tif (checkforcmd_noparen(&eap->cmd, \"belowright\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_split |= WSP_BELOW;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_opt(&eap->cmd, \"browse\", 3, TRUE))\n\t\t\t{\n#ifdef FEAT_BROWSE_CMD\n\t\t\t    cmod->cmod_flags |= CMOD_BROWSE;\n#endif\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"botright\", 2))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_BOT;\n\t\t\tcontinue;\n\n\t    case 'c':\tif (!checkforcmd_opt(&eap->cmd, \"confirm\", 4, TRUE))\n\t\t\t    break;\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\t\t\tcmod->cmod_flags |= CMOD_CONFIRM;\n#endif\n\t\t\tcontinue;\n\n\t    case 'k':\tif (checkforcmd_noparen(&eap->cmd, \"keepmarks\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPMARKS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"keepalt\", 5))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPALT;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"keeppatterns\", 5))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPPATTERNS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"keepjumps\", 5))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_KEEPJUMPS;\n\t\t\tcontinue;\n\n\t    case 'f':\t\/\/ only accept \":filter {pat} cmd\"\n\t\t\t{\n\t\t\t    char_u  *reg_pat;\n\t\t\t    char_u  *nulp = NULL;\n\t\t\t    int\t    c = 0;\n\n\t\t\t    if (!checkforcmd_noparen(&p, \"filter\", 4)\n\t\t\t\t    || *p == NUL\n\t\t\t\t    || (ends_excmd(*p)\n#ifdef FEAT_EVAL\n\t\t\t\t\t\/\/ in \":filter #pat# cmd\" # does not\n\t\t\t\t\t\/\/ start a comment\n\t\t\t\t     && (!vim9script || VIM_ISWHITE(p[1]))\n#endif\n\t\t\t\t     ))\n\t\t\t\tbreak;\n\t\t\t    if (*p == '!')\n\t\t\t    {\n\t\t\t\tcmod->cmod_filter_force = TRUE;\n\t\t\t\tp = skipwhite(p + 1);\n\t\t\t\tif (*p == NUL || ends_excmd(*p))\n\t\t\t\t    break;\n\t\t\t    }\n#ifdef FEAT_EVAL\n\t\t\t    \/\/ Avoid that \"filter(arg)\" is recognized.\n\t\t\t    if (vim9script && !VIM_ISWHITE(p[-1]))\n\t\t\t\tbreak;\n#endif\n\t\t\t    if (skip_only)\n\t\t\t\tp = skip_vimgrep_pat(p, NULL, NULL);\n\t\t\t    else\n\t\t\t\t\/\/ NOTE: This puts a NUL after the pattern.\n\t\t\t\tp = skip_vimgrep_pat_ext(p, ®_pat, NULL,\n\t\t\t\t\t\t\t\t    &nulp, &c);\n\t\t\t    if (p == NULL || *p == NUL)\n\t\t\t\tbreak;\n\t\t\t    if (!skip_only)\n\t\t\t    {\n\t\t\t\tcmod->cmod_filter_regmatch.regprog =\n\t\t\t\t\t\tvim_regcomp(reg_pat, RE_MAGIC);\n\t\t\t\tif (cmod->cmod_filter_regmatch.regprog == NULL)\n\t\t\t\t    break;\n\t\t\t\t\/\/ restore the character overwritten by NUL\n\t\t\t\tif (nulp != NULL)\n\t\t\t\t    *nulp = c;\n\t\t\t    }\n\t\t\t    eap->cmd = p;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\t\/\/ \":hide\" and \":hide | cmd\" are not modifiers\n\t    case 'h':\tif (p != eap->cmd || !checkforcmd_noparen(&p, \"hide\", 3)\n\t\t\t\t\t       || *p == NUL || ends_excmd(*p))\n\t\t\t    break;\n\t\t\teap->cmd = p;\n\t\t\tcmod->cmod_flags |= CMOD_HIDE;\n\t\t\tcontinue;\n\n\t    case 'l':\tif (checkforcmd_noparen(&eap->cmd, \"lockmarks\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_LOCKMARKS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"legacy\", 3))\n\t\t\t{\n\t\t\t    if (ends_excmd2(p, eap->cmd))\n\t\t\t    {\n\t\t\t\t*errormsg =\n\t\t\t\t      _(e_legacy_must_be_followed_by_command);\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    cmod->cmod_flags |= CMOD_LEGACY;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"leftabove\", 5))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_ABOVE;\n\t\t\tcontinue;\n\n\t    case 'n':\tif (checkforcmd_noparen(&eap->cmd, \"noautocmd\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_NOAUTOCMD;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"noswapfile\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_NOSWAPFILE;\n\t\t\tcontinue;\n\n\t    case 'r':\tif (!checkforcmd_noparen(&eap->cmd, \"rightbelow\", 6))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_BELOW;\n\t\t\tcontinue;\n\n\t    case 's':\tif (checkforcmd_noparen(&eap->cmd, \"sandbox\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_SANDBOX;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"silent\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_SILENT;\n\t\t\tif (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1]))\n\t\t\t{\n\t\t\t    \/\/ \":silent!\", but not \"silent !cmd\"\n\t\t\t    eap->cmd = skipwhite(eap->cmd + 1);\n\t\t\t    cmod->cmod_flags |= CMOD_ERRSILENT;\n\t\t\t}\n\t\t\tcontinue;\n\n\t    case 't':\tif (checkforcmd_noparen(&p, \"tab\", 3))\n\t\t\t{\n\t\t\t    if (!skip_only)\n\t\t\t    {\n\t\t\t\tlong tabnr = get_address(eap, &eap->cmd,\n\t\t\t\t\t\t    ADDR_TABS, eap->skip,\n\t\t\t\t\t\t    skip_only, FALSE, 1);\n\t\t\t\tif (tabnr == MAXLNUM)\n\t\t\t\t    cmod->cmod_tab = tabpage_index(curtab) + 1;\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    if (tabnr < 0 || tabnr > LAST_TAB_NR)\n\t\t\t\t    {\n\t\t\t\t\t*errormsg = _(e_invalid_range);\n\t\t\t\t\treturn FAIL;\n\t\t\t\t    }\n\t\t\t\t    cmod->cmod_tab = tabnr + 1;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    eap->cmd = p;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"topleft\", 2))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_TOP;\n\t\t\tcontinue;\n\n\t    case 'u':\tif (!checkforcmd_noparen(&eap->cmd, \"unsilent\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_UNSILENT;\n\t\t\tcontinue;\n\n\t    case 'v':\tif (checkforcmd_noparen(&eap->cmd, \"vertical\", 4))\n\t\t\t{\n\t\t\t    cmod->cmod_split |= WSP_VERT;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"vim9cmd\", 4))\n\t\t\t{\n\t\t\t    if (ends_excmd2(p, eap->cmd))\n\t\t\t    {\n\t\t\t\t*errormsg =\n\t\t\t\t      _(e_vim9cmd_must_be_followed_by_command);\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    cmod->cmod_flags |= CMOD_VIM9CMD;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&p, \"verbose\", 4))\n\t\t\t    break;\n\t\t\tif (vim_isdigit(*eap->cmd))\n\t\t\t{\n\t\t\t    \/\/ zero means not set, one is verbose == 0, etc.\n\t\t\t    cmod->cmod_verbose = atoi((char *)eap->cmd) + 1;\n\t\t\t}\n\t\t\telse\n\t\t\t    cmod->cmod_verbose = 2;  \/\/ default: verbose == 1\n\t\t\teap->cmd = p;\n\t\t\tcontinue;\n\t}\n\tbreak;\n    }\n\n    if (has_visual_range)\n    {\n\tif (eap->cmd > cmd_start)\n\t{\n\t    \/\/ Move the '<,'> range to after the modifiers and insert a colon.\n\t    \/\/ Since the modifiers have been parsed put the colon on top of the\n\t    \/\/ space: \"'<,'>mod cmd\" -> \"mod:'<,'>cmd\n\t    \/\/ Put eap->cmd after the colon.\n\t    if (use_plus_cmd)\n\t    {\n\t\tsize_t len = STRLEN(cmd_start);\n\n\t\t\/\/ Special case: empty command uses \"+\":\n\t\t\/\/  \"'<,'>mods\" -> \"mods'<,'>+\n\t\tmch_memmove(orig_cmd, cmd_start, len);\n\t\tSTRCPY(orig_cmd + len, \"'<,'>+\");\n\t    }\n\t    else\n\t    {\n\t\tmch_memmove(cmd_start - 5, cmd_start, eap->cmd - cmd_start);\n\t\teap->cmd -= 5;\n\t\tmch_memmove(eap->cmd - 1, \":'<,'>\", 6);\n\t    }\n\t}\n\telse\n\t    \/\/ No modifiers, move the pointer back.\n\t    \/\/ Special case: change empty command to \"+\".\n\t    if (use_plus_cmd)\n\t\teap->cmd = (char_u *)\"'<,'>+\";\n\t    else\n\t\teap->cmd = orig_cmd;\n    }\n    else if (use_plus_cmd)\n\teap->cmd = (char_u *)\"+\";\n\n    return OK;\n}","target":1,"code_token_length":3025,"total_token_length":3261,"max_tokens_setting":4096}
+{"idx":331760,"func":"void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &inPen)\n{\n#ifdef QT_DEBUG_DRAW\n    qDebug() << \"QPaintEngineEx::stroke()\" << pen;\n#endif\n\n    Q_D(QPaintEngineEx);\n\n    if (path.isEmpty())\n        return;\n\n    if (!d->strokeHandler) {\n        d->strokeHandler = new StrokeHandler(path.elementCount()+4);\n        d->stroker.setMoveToHook(qpaintengineex_moveTo);\n        d->stroker.setLineToHook(qpaintengineex_lineTo);\n        d->stroker.setCubicToHook(qpaintengineex_cubicTo);\n    }\n\n    QRectF clipRect;\n    QPen pen = inPen;\n    if (pen.style() > Qt::SolidLine) {\n        QRectF cpRect = path.controlPointRect();\n        const QTransform &xf = state()->matrix;\n        if (pen.isCosmetic()) {\n            clipRect = d->exDeviceRect;\n            cpRect.translate(xf.dx(), xf.dy());\n        } else {\n            clipRect = xf.inverted().mapRect(QRectF(d->exDeviceRect));\n        }\n        \/\/ Check to avoid generating unwieldy amount of dashes that will not be visible anyway\n        QRectF extentRect = cpRect & clipRect;\n        qreal extent = qMax(extentRect.width(), extentRect.height());\n        qreal patternLength = 0;\n        const QList<qreal> pattern = pen.dashPattern();\n        const int patternSize = qMin(pattern.size(), 32);\n        for (int i = 0; i < patternSize; i++)\n            patternLength += qMax(pattern.at(i), qreal(0));\n        if (pen.widthF())\n            patternLength *= pen.widthF();\n        if (qFuzzyIsNull(patternLength)) {\n            pen.setStyle(Qt::NoPen);\n        } else if (qFuzzyIsNull(extent) || extent \/ patternLength > 10000) {\n            \/\/ approximate stream of tiny dashes with semi-transparent solid line\n            pen.setStyle(Qt::SolidLine);\n            QColor color(pen.color());\n            color.setAlpha(color.alpha() \/ 2);\n            pen.setColor(color);\n        }\n    }\n\n    if (!qpen_fast_equals(pen, d->strokerPen)) {\n        d->strokerPen = pen;\n        d->stroker.setJoinStyle(pen.joinStyle());\n        d->stroker.setCapStyle(pen.capStyle());\n        d->stroker.setMiterLimit(pen.miterLimit());\n        qreal penWidth = pen.widthF();\n        if (penWidth == 0)\n            d->stroker.setStrokeWidth(1);\n        else\n            d->stroker.setStrokeWidth(penWidth);\n\n        Qt::PenStyle style = pen.style();\n        if (style == Qt::SolidLine) {\n            d->activeStroker = &d->stroker;\n        } else if (style == Qt::NoPen) {\n            d->activeStroker = nullptr;\n        } else {\n            d->dasher.setDashPattern(pen.dashPattern());\n            d->dasher.setDashOffset(pen.dashOffset());\n            d->activeStroker = &d->dasher;\n        }\n    }\n\n    if (!d->activeStroker) {\n        return;\n    }\n\n    if (!clipRect.isNull())\n        d->activeStroker->setClipRect(clipRect);\n\n    if (d->activeStroker == &d->stroker)\n        d->stroker.setForceOpen(path.hasExplicitOpen());\n\n    const QPainterPath::ElementType *types = path.elements();\n    const qreal *points = path.points();\n    int pointCount = path.elementCount();\n\n    const qreal *lastPoint = points + (pointCount<<1);\n\n    d->strokeHandler->types.reset();\n    d->strokeHandler->pts.reset();\n\n    \/\/ Some engines might decide to optimize for the non-shape hint later on...\n    uint flags = QVectorPath::WindingFill;\n\n    if (path.elementCount() > 2)\n        flags |= QVectorPath::NonConvexShapeMask;\n\n    if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)\n        flags |= QVectorPath::CurvedShapeMask;\n\n    \/\/ ### Perspective Xforms are currently not supported...\n    if (!pen.isCosmetic()) {\n        \/\/ We include cosmetic pens in this case to avoid having to\n        \/\/ change the current transform. Normal transformed,\n        \/\/ non-cosmetic pens will be transformed as part of fill\n        \/\/ later, so they are also covered here..\n        d->activeStroker->setCurveThresholdFromTransform(state()->matrix);\n        d->activeStroker->begin(d->strokeHandler);\n        if (types) {\n            while (points < lastPoint) {\n                switch (*types) {\n                case QPainterPath::MoveToElement:\n                    d->activeStroker->moveTo(points[0], points[1]);\n                    points += 2;\n                    ++types;\n                    break;\n                case QPainterPath::LineToElement:\n                    d->activeStroker->lineTo(points[0], points[1]);\n                    points += 2;\n                    ++types;\n                    break;\n                case QPainterPath::CurveToElement:\n                    d->activeStroker->cubicTo(points[0], points[1],\n                                              points[2], points[3],\n                                              points[4], points[5]);\n                    points += 6;\n                    types += 3;\n                    flags |= QVectorPath::CurvedShapeMask;\n                    break;\n                default:\n                    break;\n                }\n            }\n            if (path.hasImplicitClose())\n                d->activeStroker->lineTo(path.points()[0], path.points()[1]);\n\n        } else {\n            d->activeStroker->moveTo(points[0], points[1]);\n            points += 2;\n            while (points < lastPoint) {\n                d->activeStroker->lineTo(points[0], points[1]);\n                points += 2;\n            }\n            if (path.hasImplicitClose())\n                d->activeStroker->lineTo(path.points()[0], path.points()[1]);\n        }\n        d->activeStroker->end();\n\n        if (!d->strokeHandler->types.size()) \/\/ an empty path...\n            return;\n\n        QVectorPath strokePath(d->strokeHandler->pts.data(),\n                               d->strokeHandler->types.size(),\n                               d->strokeHandler->types.data(),\n                               flags);\n        fill(strokePath, pen.brush());\n    } else {\n        \/\/ For cosmetic pens we need a bit of trickery... We to process xform the input points\n        if (state()->matrix.type() >= QTransform::TxProject) {\n            QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());\n            d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());\n        } else {\n            d->activeStroker->setCurveThresholdFromTransform(QTransform());\n            d->activeStroker->begin(d->strokeHandler);\n            if (types) {\n                while (points < lastPoint) {\n                    switch (*types) {\n                    case QPainterPath::MoveToElement: {\n                        QPointF pt = (*(const QPointF *) points) * state()->matrix;\n                        d->activeStroker->moveTo(pt.x(), pt.y());\n                        points += 2;\n                        ++types;\n                        break;\n                    }\n                    case QPainterPath::LineToElement: {\n                        QPointF pt = (*(const QPointF *) points) * state()->matrix;\n                        d->activeStroker->lineTo(pt.x(), pt.y());\n                        points += 2;\n                        ++types;\n                        break;\n                    }\n                    case QPainterPath::CurveToElement: {\n                        QPointF c1 = ((const QPointF *) points)[0] * state()->matrix;\n                        QPointF c2 = ((const QPointF *) points)[1] * state()->matrix;\n                        QPointF e =  ((const QPointF *) points)[2] * state()->matrix;\n                        d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());\n                        points += 6;\n                        types += 3;\n                        flags |= QVectorPath::CurvedShapeMask;\n                        break;\n                    }\n                    default:\n                        break;\n                    }\n                }\n                if (path.hasImplicitClose()) {\n                    QPointF pt = * ((const QPointF *) path.points()) * state()->matrix;\n                    d->activeStroker->lineTo(pt.x(), pt.y());\n                }\n\n            } else {\n                QPointF p = ((const QPointF *)points)[0] * state()->matrix;\n                d->activeStroker->moveTo(p.x(), p.y());\n                points += 2;\n                while (points < lastPoint) {\n                    QPointF p = ((const QPointF *)points)[0] * state()->matrix;\n                    d->activeStroker->lineTo(p.x(), p.y());\n                    points += 2;\n                }\n                if (path.hasImplicitClose())\n                    d->activeStroker->lineTo(p.x(), p.y());\n            }\n            d->activeStroker->end();\n        }\n\n        QVectorPath strokePath(d->strokeHandler->pts.data(),\n                               d->strokeHandler->types.size(),\n                               d->strokeHandler->types.data(),\n                               flags);\n\n        QTransform xform = state()->matrix;\n        state()->matrix = QTransform();\n        transformChanged();\n\n        QBrush brush = pen.brush();\n        if (qbrush_style(brush) != Qt::SolidPattern)\n            brush.setTransform(brush.transform() * xform);\n\n        fill(strokePath, brush);\n\n        state()->matrix = xform;\n        transformChanged();\n    }\n}","target":0,"code_token_length":2022,"total_token_length":2258,"max_tokens_setting":4096}
+{"idx":413620,"func":"R_API void r_core_anal_callgraph(RCore *core, ut64 addr, int fmt) {\n\tconst char *font = r_config_get (core->config, \"graph.font\");\n\tint is_html = r_cons_context ()->is_html;\n\tbool refgraph = r_config_get_i (core->config, \"graph.refs\");\n\tRListIter *iter, *iter2;\n\tint usenames = r_config_get_i (core->config, \"graph.json.usenames\");;\n\tRAnalFunction *fcni;\n\tRAnalRef *fcnr;\n\tPJ *pj = NULL;\n\n\tut64 from = r_config_get_i (core->config, \"graph.from\");\n\tut64 to = r_config_get_i (core->config, \"graph.to\");\n\n\tswitch (fmt) {\n\tcase R_GRAPH_FORMAT_JSON:\n\t\tpj = pj_new ();\n\t\tif (!pj) {\n\t\t\treturn;\n\t\t}\n\t\tpj_a (pj);\n\t\tbreak;\n\tcase R_GRAPH_FORMAT_GML:\n\tcase R_GRAPH_FORMAT_GMLFCN:\n\t\tr_cons_printf (\"graph\\n[\\n\"\n\t\t\t\t\"hierarchic  1\\n\"\n\t\t\t\t\"label  \\\"\\\"\\n\"\n\t\t\t\t\"directed  1\\n\");\n\t\tbreak;\n\tcase R_GRAPH_FORMAT_DOT:\n\t\tif (!is_html) {\n\t\t\tconst char * gv_edge = r_config_get (core->config, \"graph.gv.edge\");\n\t\t\tchar * gv_node = strdup (r_config_get (core->config, \"graph.gv.node\"));\n\t\t\tconst char * gv_grph = r_config_get (core->config, \"graph.gv.graph\");\n\t\t\tconst char * gv_spline = r_config_get (core->config, \"graph.gv.spline\");\n\t\t\tif (!gv_edge || !*gv_edge) {\n\t\t\t\tgv_edge = \"arrowhead=\\\"normal\\\" style=bold weight=2\";\n\t\t\t}\n\t\t\tif (!gv_node || !*gv_node) {\n\t\t\t\tconst char *font = r_config_get (core->config, \"graph.font\");\n\t\t\t\tfree (gv_node);\n\t\t\t\tgv_node = r_str_newf (\"penwidth=4 fillcolor=white style=filled fontname=\\\"%s Bold\\\" fontsize=14 shape=box\", font);\n\t\t\t}\n\t\t\tif (!gv_grph || !*gv_grph) {\n\t\t\t\tgv_grph = \"bgcolor=azure\";\n\t\t\t}\n\t\t\tif (!gv_spline || !*gv_spline) {\n\t\t\t\t\/\/ ortho for bbgraph and curved for callgraph\n\t\t\t\tgv_spline = \"splines=\\\"curved\\\"\";\n\t\t\t}\n\t\t\tr_cons_printf (\"digraph code {\\n\"\n\t\t\t\t\t\"rankdir=LR;\\n\"\n\t\t\t\t\t\"outputorder=edgesfirst;\\n\"\n\t\t\t\t\t\"graph [%s fontname=\\\"%s\\\" %s];\\n\"\n\t\t\t\t\t\"node [%s];\\n\"\n\t\t\t\t\t\"edge [%s];\\n\", gv_grph, font, gv_spline,\n\t\t\t\t\tgv_node, gv_edge);\n\t\t\tfree (gv_node);\n\t\t}\n\t\tbreak;\n\t}\n\tut64 base = UT64_MAX;\n\tint iteration = 0;\nrepeat:\n\tr_list_foreach (core->anal->fcns, iter, fcni) {\n\t\tif (base == UT64_MAX) {\n\t\t\tbase = fcni->addr;\n\t\t}\n\t\tif (from != UT64_MAX && fcni->addr < from) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (to != UT64_MAX && fcni->addr > to) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (addr != UT64_MAX && addr != fcni->addr) {\n\t\t\tcontinue;\n\t\t}\n\t\tRList *refs = r_anal_function_get_refs (fcni);\n\t\tRList *calls = r_list_new ();\n\t\t\/\/ TODO: maybe fcni->calls instead ?\n\t\tr_list_foreach (refs, iter2, fcnr) {\n\t\t\t\/\/  TODO: tail calll jumps are also calls\n\t\t\tif (fcnr->type == 'C' && r_list_find(calls, fcnr, (RListComparator)RAnalRef_cmp) == NULL) {\n\t\t\t\tr_list_append (calls, fcnr);\n\t\t\t}\n\t\t}\n\t\tif (r_list_empty(calls)) {\n\t\t\tr_list_free (refs);\n\t\t\tr_list_free (calls);\n\t\t\tcontinue;\n\t\t}\n\t\tswitch (fmt) {\n\t\tcase R_GRAPH_FORMAT_NO:\n\t\t\tr_cons_printf (\"0x%08\"PFMT64x\"\\n\", fcni->addr);\n\t\t\tbreak;\n\t\tcase R_GRAPH_FORMAT_GML:\n\t\tcase R_GRAPH_FORMAT_GMLFCN: {\n\t\t\tRFlagItem *flag = r_flag_get_i (core->flags, fcni->addr);\n\t\t\tif (iteration == 0) {\n\t\t\t\tchar *msg = flag? strdup (flag->name): r_str_newf (\"0x%08\"PFMT64x, fcni->addr);\n\t\t\t\tr_cons_printf (\"  node [\\n\"\n\t\t\t\t\t\t\"  id  %\"PFMT64d\"\\n\"\n\t\t\t\t\t\t\"    label  \\\"%s\\\"\\n\"\n\t\t\t\t\t\t\"  ]\\n\", fcni->addr - base, msg);\n\t\t\t\tfree (msg);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase R_GRAPH_FORMAT_JSON:\n\t\t\tpj_o (pj);\n\t\t\tif (usenames) {\n\t\t\t\tpj_ks (pj, \"name\", fcni->name);\n\t\t\t} else {\n\t\t\t\tchar fcni_addr[20];\n\t\t\t\tsnprintf (fcni_addr, sizeof (fcni_addr) - 1, \"0x%08\" PFMT64x, fcni->addr);\n\t\t\t\tpj_ks (pj, \"name\", fcni_addr);\n\t\t\t}\n\t\t\tpj_kn (pj, \"size\", r_anal_function_linear_size (fcni));\n\t\t\tpj_ka (pj, \"imports\");\n\t\t\tbreak;\n\t\tcase R_GRAPH_FORMAT_DOT:\n\t\t\tr_cons_printf (\"  \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\"[label=\\\"%s\\\"\"\n\t\t\t\t\t\" URL=\\\"%s\/0x%08\"PFMT64x\"\\\"];\\n\",\n\t\t\t\t\tfcni->addr, fcni->name,\n\t\t\t\t\tfcni->name, fcni->addr);\n\t\t}\n\t\tr_list_foreach (calls, iter2, fcnr) {\n\t\t\t\/\/ TODO: display only code or data refs?\n\t\t\tRFlagItem *flag = r_flag_get_i (core->flags, fcnr->addr);\n\t\t\tchar *fcnr_name = (flag && flag->name) ? flag->name : r_str_newf (\"unk.0x%\"PFMT64x, fcnr->addr);\n\t\t\tswitch (fmt) {\n\t\t\tcase R_GRAPH_FORMAT_GMLFCN:\n\t\t\t\tif (iteration == 0) {\n\t\t\t\t\tr_cons_printf (\"  node [\\n\"\n\t\t\t\t\t\t\t\"    id  %\"PFMT64d\"\\n\"\n\t\t\t\t\t\t\t\"    label  \\\"%s\\\"\\n\"\n\t\t\t\t\t\t\t\"  ]\\n\", fcnr->addr - base, fcnr_name);\n\t\t\t\t\tr_cons_printf (\"  edge [\\n\"\n\t\t\t\t\t\t\t\"    source  %\"PFMT64d\"\\n\"\n\t\t\t\t\t\t\t\"    target  %\"PFMT64d\"\\n\"\n\t\t\t\t\t\t\t\"  ]\\n\", fcni->addr-base, fcnr->addr-base);\n\t\t\t\t}\n\t\t\tcase R_GRAPH_FORMAT_GML:\n\t\t\t\tif (iteration != 0) {\n\t\t\t\t\tr_cons_printf (\"  edge [\\n\"\n\t\t\t\t\t\t\t\"    source  %\"PFMT64d\"\\n\"\n\t\t\t\t\t\t\t\"    target  %\"PFMT64d\"\\n\"\n\t\t\t\t\t\t\t\"  ]\\n\", fcni->addr-base, fcnr->addr-base); \/\/, \"#000000\"\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase R_GRAPH_FORMAT_DOT:\n\t\t\t\tr_cons_printf (\"  \\\"0x%08\"PFMT64x\"\\\" -> \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\"[color=\\\"%s\\\" URL=\\\"%s\/0x%08\"PFMT64x\"\\\"];\\n\",\n\t\t\t\t\t\t\/\/\"[label=\\\"%s\\\" color=\\\"%s\\\" URL=\\\"%s\/0x%08\"PFMT64x\"\\\"];\\n\",\n\t\t\t\t\t\tfcni->addr, fcnr->addr, \/\/, fcnr_name,\n\t\t\t\t\t\t\"#61afef\",\n\t\t\t\t\t\tfcnr_name, fcnr->addr);\n\t\t\t\tr_cons_printf (\"  \\\"0x%08\"PFMT64x\"\\\" \"\n\t\t\t\t\t\t\"[label=\\\"%s\\\"\"\n\t\t\t\t\t\t\" URL=\\\"%s\/0x%08\"PFMT64x\"\\\"];\\n\",\n\t\t\t\t\t\tfcnr->addr, fcnr_name,\n\t\t\t\t\t\tfcnr_name, fcnr->addr);\n\t\t\t\tbreak;\n\t\t\tcase R_GRAPH_FORMAT_JSON:\n\t\t\t\tif (usenames) {\n\t\t\t\t\tpj_s (pj, fcnr_name);\n\t\t\t\t} else {\n\t\t\t\t\tchar fcnr_addr[20];\n\t\t\t\t\tsnprintf (fcnr_addr, sizeof (fcnr_addr) - 1, \"0x%08\" PFMT64x, fcnr->addr);\n\t\t\t\t\tpj_s (pj, fcnr_addr);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (refgraph || fcnr->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\t\t\t\/\/ TODO: avoid recreating nodes unnecessarily\n\t\t\t\t\tr_cons_printf (\"agn %s\\n\", fcni->name);\n\t\t\t\t\tr_cons_printf (\"agn %s\\n\", fcnr_name);\n\t\t\t\t\tr_cons_printf (\"age %s %s\\n\", fcni->name, fcnr_name);\n\t\t\t\t} else {\n\t\t\t\t\tr_cons_printf (\"# - 0x%08\"PFMT64x\" (%c)\\n\", fcnr->addr, fcnr->type);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(flag && flag->name)) {\n\t\t\t\tfree(fcnr_name);\n\t\t\t}\n\t\t}\n\t\tr_list_free (refs);\n\t\tr_list_free (calls);\n\t\tif (fmt == R_GRAPH_FORMAT_JSON) {\n\t\t\tpj_end (pj);\n\t\t\tpj_end (pj);\n\t\t}\n\t}\n\tif (iteration == 0 && fmt == R_GRAPH_FORMAT_GML) {\n\t\titeration++;\n\t\tgoto repeat;\n\t}\n\tif (iteration == 0 && fmt == R_GRAPH_FORMAT_GMLFCN) {\n\t\titeration++;\n\t}\n\tswitch (fmt) {\n\tcase R_GRAPH_FORMAT_GML:\n\tcase R_GRAPH_FORMAT_GMLFCN:\n\tcase R_GRAPH_FORMAT_JSON:\n\t\tpj_end (pj);\n\t\tr_cons_println (pj_string (pj));\n\t\tpj_free (pj);\n\t\tbreak;\n\tcase R_GRAPH_FORMAT_DOT:\n\t\tr_cons_printf (\"}\\n\");\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":2308,"total_token_length":2544,"max_tokens_setting":4096}
+{"idx":224479,"func":"static GF_Err gf_text_ttml_setup(GF_Filter *filter, GF_TXTIn *ctx)\n{\n\tGF_Err e;\n\tu32 i, nb_children, ID;\n\tu64 file_size;\n\ts32 sub_fps_num, sub_fps_den;\n\tGF_XMLAttribute *att;\n\tGF_XMLNode *root, *node, *body_node;\n\tconst char *lang = ctx->lang;\n\n\n\tctx->is_setup = GF_TRUE;\n\tctx->parser = gf_xml_dom_new();\n\te = gf_xml_dom_parse(ctx->parser, ctx->file_name, ttxt_dom_progress, ctx);\n\tif (e) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Error parsing TTML file: Line %d - %s. Abort.\\n\", gf_xml_dom_get_line(ctx->parser), gf_xml_dom_get_error(ctx->parser) ));\n\t\tctx->is_setup = GF_TRUE;\n\t\tctx->non_compliant_ttml = GF_TRUE;\n\t\treturn e;\n\t}\n\troot = gf_xml_dom_get_root(ctx->parser);\n\tif (!root) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Error parsing TTML file: no root XML element found. Abort.\\n\"));\n\t\tctx->non_compliant_ttml = GF_TRUE;\n\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t}\n\n\t\/*look for TTML*\/\n\tif (gf_xml_get_element_check_namespace(root, \"tt\", NULL) != GF_OK) {\n\t\tif (root->ns) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"TTML file not recognized: root element is \\\"%s:%s\\\" (check your namespaces)\\n\", root->ns, root->name));\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"TTML file not recognized: root element is \\\"%s\\\"\\n\", root->name));\n\t\t}\n\t\tctx->non_compliant_ttml = GF_TRUE;\n\t\treturn GF_NOT_SUPPORTED;\n\t}\n\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, (\"[TXTIn] TTML EBU-TTD detected\\n\"));\n\n\troot = gf_xml_dom_get_root(ctx->parser);\n\n\n\t\/*** root (including language) ***\/\n\tsub_fps_num = 0;\n\tsub_fps_den = 0;\n\ti=0;\n\twhile ( (att = (GF_XMLAttribute *)gf_list_enum(root->attributes, &i))) {\n\t\tconst char *att_name;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, (\"[TTML] Found root attribute name %s, value %s\\n\", att->name, att->value));\n\n\t\tatt_name = strchr(att->name, ':');\n\t\tif (att_name) att_name++;\n\t\telse att_name = att->name;\n\n\t\tif (!strcmp(att->name, \"xmlns\")) {\n\t\t\tif (strcmp(att->value, TTML_NAMESPACE)) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TTML] XML Namespace %s not recognized, expecting %s\\n\", att->name, att->value, TTML_NAMESPACE));\n\t\t\t\tctx->non_compliant_ttml = GF_TRUE;\n\t\t\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t\t\t}\n\t\t}\n\t\telse if (!strcmp(att->name, \"xml:lang\") && att->value && strlen(att->value)) {\n\t\t\tlang = att->value;\n\t\t}\n\t\telse if (!strcmp(att_name, \"tickRate\") && att->value) {\n\t\t\tctx->tick_rate = atoi(att->value);\n\t\t}\n\t\telse if (!strcmp(att_name, \"frameRate\") && att->value) {\n\t\t\tctx->ttml_fps_num = atoi(att->value);\n\t\t\tctx->ttml_fps_den = 1;\n\t\t}\n\t\telse if (!strcmp(att_name, \"frameRateMultiplier\") && att->value) {\n\t\t\tchar *sep = strchr(att->value, ' ');\n\t\t\tif (!sep) sep = strchr(att->value, '\\t');\n\t\t\tif (sep) {\n\t\t\t\tu8 c = sep[0];\n\t\t\t\tsep[0] = 0;\n\t\t\t\tsub_fps_num = atoi(sep);\n\t\t\t\tsep[0] = c;\n\t\t\t\twhile ((sep[0]==' ') || (sep[0]=='\\t'))\n\t\t\t\t\tsep++;\n\t\t\t\tsub_fps_den = atoi(sep);\n\t\t\t}\n\t\t}\n\t\telse if (!strcmp(att_name, \"subFrameRate\") && att->value) {\n\t\t\tctx->ttml_sfps = atoi(att->value);\n\t\t}\n\t}\n\n\tif (sub_fps_num && sub_fps_den && ctx->ttml_fps_num) {\n\t\tctx->ttml_fps_num *= sub_fps_num;\n\t\tctx->ttml_fps_den = sub_fps_den;\n\t}\n\n\t\/\/locate body\n\tnb_children = gf_list_count(root->content);\n\tbody_node = NULL;\n\n\ti=0;\n\twhile ( (node = (GF_XMLNode*)gf_list_enum(root->content, &i))) {\n\t\tif (node->type) {\n\t\t\tnb_children--;\n\t\t\tcontinue;\n\t\t}\n\t\te = gf_xml_get_element_check_namespace(node, \"body\", root->ns);\n\t\tif (e == GF_BAD_PARAM) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] ignored \\\"%s\\\" node, check your namespaces\\n\", node->name));\n\t\t} else if (e == GF_OK) {\n\t\t\tif (body_node) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TTML EBU-TTD] duplicated \\\"body\\\" element. Abort.\\n\"));\n\t\t\t\tctx->non_compliant_ttml = GF_TRUE;\n\t\t\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t\t\t}\n\t\t\tbody_node = node;\n\t\t}\n\t}\n\tif (!body_node) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, (\"[TTML EBU-TTD] \\\"body\\\" element not found, assuming empty doc\\n\"));\n\t}\n\n\tif (!ctx->div_nodes_list) {\n\t\tctx->div_nodes_list = gf_list_new();\n\t\tif (!ctx->div_nodes_list) return GF_OUT_OF_MEM;\n\t} else {\n\t\tgf_list_reset(ctx->div_nodes_list);\n\t}\n\n\tif (body_node) {\n\t\ti=0;\n\t\twhile ( (node = (GF_XMLNode*)gf_list_enum(body_node->content, &i))) {\n\t\t\tif (!node->type) {\n\t\t\t\te = gf_xml_get_element_check_namespace(node, \"div\", root->ns);\n\t\t\t\tif (e == GF_BAD_PARAM) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"[TTML EBU-TTD] ignored \\\"%s\\\" node, check your namespaces\\n\", node->name));\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_list_add(ctx->div_nodes_list, node);\n\t\t}\n\t}\n\tfile_size = ctx->end;\n\tif (!ctx->timescale) ctx->timescale = 1000;\n\n\tif (!ctx->opid) ctx->opid = gf_filter_pid_new(filter);\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_TEXT) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, &PROP_UINT(GF_CODECID_SUBS_XML) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(ctx->timescale) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DOWN_SIZE, &PROP_LONGUINT(file_size) );\n\n\tID = 1;\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ID, &PROP_UINT(ID) );\n\tif (ctx->width) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH, &PROP_UINT(ctx->width) );\n\tif (ctx->height) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT, &PROP_UINT(ctx->height) );\n\tif (ctx->zorder) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ZORDER, &PROP_SINT(ctx->zorder) );\n\tif (lang) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_LANGUAGE, &PROP_STRING( lang) );\n\tgf_filter_pid_set_property_str(ctx->opid, \"meta:xmlns\", &PROP_STRING(TTML_NAMESPACE) );\n\n\t\/*** body ***\/\n\tctx->parser_working_copy = gf_xml_dom_new();\n\te = gf_xml_dom_parse(ctx->parser_working_copy, ctx->file_name, NULL, NULL);\n\tassert (e == GF_OK);\n\tctx->root_working_copy = gf_xml_dom_get_root(ctx->parser_working_copy);\n\tassert(ctx->root_working_copy);\n\n\tif (body_node) {\n\t\t\/*remove all the sample entries (instances in body) entries from the working copy, we will add each sample in this clone DOM  to create full XML of each sample*\/\n\t\tebu_ttd_remove_samples(ctx->root_working_copy, &ctx->body_node);\n\t\tif (!ctx->body_node) {\n\t\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t\t}\n\t} else {\n\t\tctx->body_node = NULL;\n\t}\n\n\tctx->current_tt_interval = 0;\n\n\tctx->last_sample_duration = 0;\n\tctx->end = 0;\n\tctx->first_samp = GF_TRUE;\n\n\ttxtin_probe_duration(ctx);\n\n\te = ttml_setup_intervals(ctx);\n\tif (e) return e;\n\n\tif (ctx->has_images) {\n\t\tchar *mime_cfg = \"application\/ttml+xml;codecs=im1i\";\n\t\tgf_filter_pid_set_property_str(ctx->opid, \"meta:mime\", &PROP_STRING(mime_cfg) );\n\t} else {\n\t\tgf_filter_pid_set_property_str(ctx->opid, \"meta:mime\", NULL);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":2063,"total_token_length":2299,"max_tokens_setting":4096}
+{"idx":252445,"func":"mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,\n                               const char *pSrc_filename, const void *pComment,\n                               mz_uint16 comment_size,\n                               mz_uint level_and_flags) {\n  mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;\n  mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;\n  mz_uint64 local_dir_header_ofs = pZip->m_archive_size,\n            cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0,\n            comp_size = 0;\n  size_t archive_name_size;\n  mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];\n  MZ_FILE *pSrc_file = NULL;\n\n  if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL;\n  level = level_and_flags & 0xF;\n\n  if ((!pZip) || (!pZip->m_pState) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) ||\n      ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION))\n    return MZ_FALSE;\n  if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) return MZ_FALSE;\n  if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE;\n\n  archive_name_size = strlen(pArchive_name);\n  if (archive_name_size > 0xFFFF) return MZ_FALSE;\n\n  num_alignment_padding_bytes =\n      mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);\n\n  \/\/ no zip64 support yet\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + num_alignment_padding_bytes +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n        comment_size + archive_name_size) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date))\n    return MZ_FALSE;\n\n  pSrc_file = MZ_FOPEN(pSrc_filename, \"rb\");\n  if (!pSrc_file) return MZ_FALSE;\n  MZ_FSEEK64(pSrc_file, 0, SEEK_END);\n  uncomp_size = MZ_FTELL64(pSrc_file);\n  MZ_FSEEK64(pSrc_file, 0, SEEK_SET);\n\n  if (uncomp_size > 0xFFFFFFFF) {\n    \/\/ No zip64 support yet\n    MZ_FCLOSE(pSrc_file);\n    return MZ_FALSE;\n  }\n  if (uncomp_size <= 3) level = 0;\n\n  if (!mz_zip_writer_write_zeros(\n          pZip, cur_archive_file_ofs,\n          num_alignment_padding_bytes + sizeof(local_dir_header))) {\n    MZ_FCLOSE(pSrc_file);\n    return MZ_FALSE;\n  }\n  local_dir_header_ofs += num_alignment_padding_bytes;\n  if (pZip->m_file_offset_alignment) {\n    MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) ==\n              0);\n  }\n  cur_archive_file_ofs +=\n      num_alignment_padding_bytes + sizeof(local_dir_header);\n\n  MZ_CLEAR_OBJ(local_dir_header);\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name,\n                     archive_name_size) != archive_name_size) {\n    MZ_FCLOSE(pSrc_file);\n    return MZ_FALSE;\n  }\n  cur_archive_file_ofs += archive_name_size;\n\n  if (uncomp_size) {\n    mz_uint64 uncomp_remaining = uncomp_size;\n    void *pRead_buf =\n        pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE);\n    if (!pRead_buf) {\n      MZ_FCLOSE(pSrc_file);\n      return MZ_FALSE;\n    }\n\n    if (!level) {\n      while (uncomp_remaining) {\n        mz_uint n =\n            (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);\n        if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) ||\n            (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf,\n                            n) != n)) {\n          pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n          MZ_FCLOSE(pSrc_file);\n          return MZ_FALSE;\n        }\n        uncomp_crc32 =\n            (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);\n        uncomp_remaining -= n;\n        cur_archive_file_ofs += n;\n      }\n      comp_size = uncomp_size;\n    } else {\n      mz_bool result = MZ_FALSE;\n      mz_zip_writer_add_state state;\n      tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(\n          pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor));\n      if (!pComp) {\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n        MZ_FCLOSE(pSrc_file);\n        return MZ_FALSE;\n      }\n\n      state.m_pZip = pZip;\n      state.m_cur_archive_file_ofs = cur_archive_file_ofs;\n      state.m_comp_size = 0;\n\n      if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state,\n                     tdefl_create_comp_flags_from_zip_params(\n                         level, -15, MZ_DEFAULT_STRATEGY)) !=\n          TDEFL_STATUS_OKAY) {\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n        MZ_FCLOSE(pSrc_file);\n        return MZ_FALSE;\n      }\n\n      for (;;) {\n        size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining,\n                                               (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE);\n        tdefl_status status;\n\n        if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)\n          break;\n\n        uncomp_crc32 = (mz_uint32)mz_crc32(\n            uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);\n        uncomp_remaining -= in_buf_size;\n\n        status = tdefl_compress_buffer(\n            pComp, pRead_buf, in_buf_size,\n            uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH);\n        if (status == TDEFL_STATUS_DONE) {\n          result = MZ_TRUE;\n          break;\n        } else if (status != TDEFL_STATUS_OKAY)\n          break;\n      }\n\n      pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);\n\n      if (!result) {\n        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n        MZ_FCLOSE(pSrc_file);\n        return MZ_FALSE;\n      }\n\n      comp_size = state.m_comp_size;\n      cur_archive_file_ofs = state.m_cur_archive_file_ofs;\n\n      method = MZ_DEFLATED;\n    }\n\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);\n  }\n\n  MZ_FCLOSE(pSrc_file);\n  pSrc_file = NULL;\n\n  \/\/ no zip64 support yet\n  if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_create_local_dir_header(\n          pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size,\n          comp_size, uncomp_crc32, method, 0, dos_time, dos_date))\n    return MZ_FALSE;\n\n  if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header,\n                     sizeof(local_dir_header)) != sizeof(local_dir_header))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_add_to_central_dir(\n          pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment,\n          comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0,\n          dos_time, dos_date, local_dir_header_ofs, ext_attributes))\n    return MZ_FALSE;\n\n  pZip->m_total_files++;\n  pZip->m_archive_size = cur_archive_file_ofs;\n\n  return MZ_TRUE;\n}","target":0,"code_token_length":1921,"total_token_length":2157,"max_tokens_setting":4096}
+{"idx":310276,"func":"dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,\n                                        authority_cert_t *cert)\n{\n  or_options_t *options = get_options();\n  networkstatus_t *v3_out = NULL;\n  uint32_t addr;\n  char *hostname = NULL, *client_versions = NULL, *server_versions = NULL;\n  const char *contact;\n  smartlist_t *routers, *routerstatuses;\n  char identity_digest[DIGEST_LEN];\n  char signing_key_digest[DIGEST_LEN];\n  int naming = options->NamingAuthoritativeDir;\n  int listbadexits = options->AuthDirListBadExits;\n  int listbaddirs = options->AuthDirListBadDirs;\n  int vote_on_hsdirs = options->VoteOnHidServDirectoriesV2;\n  routerlist_t *rl = router_get_routerlist();\n  time_t now = time(NULL);\n  time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;\n  networkstatus_voter_info_t *voter = NULL;\n  vote_timing_t timing;\n  digestmap_t *omit_as_sybil = NULL;\n  const int vote_on_reachability = running_long_enough_to_decide_unreachable();\n  smartlist_t *microdescriptors = NULL;\n\n  tor_assert(private_key);\n  tor_assert(cert);\n\n  if (resolve_my_address(LOG_WARN, options, &addr, &hostname)<0) {\n    log_warn(LD_NET, \"Couldn't resolve my hostname\");\n    return NULL;\n  }\n  if (!strchr(hostname, '.')) {\n    tor_free(hostname);\n    hostname = tor_dup_ip(addr);\n  }\n  if (crypto_pk_get_digest(private_key, signing_key_digest)<0) {\n    log_err(LD_BUG, \"Error computing signing key digest\");\n    return NULL;\n  }\n  if (crypto_pk_get_digest(cert->identity_key, identity_digest)<0) {\n    log_err(LD_BUG, \"Error computing identity key digest\");\n    return NULL;\n  }\n\n  if (options->VersioningAuthoritativeDir) {\n    client_versions = format_versions_list(options->RecommendedClientVersions);\n    server_versions = format_versions_list(options->RecommendedServerVersions);\n  }\n\n  contact = get_options()->ContactInfo;\n  if (!contact)\n    contact = \"(none)\";\n\n  \/* precompute this part, since we need it to decide what \"stable\"\n   * means. *\/\n  SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {\n    dirserv_set_router_is_running(ri, now);\n  });\n\n  dirserv_compute_performance_thresholds(rl);\n\n  routers = smartlist_create();\n  smartlist_add_all(routers, rl->routers);\n  routers_sort_by_identity(routers);\n  omit_as_sybil = get_possible_sybil_list(routers);\n\n  routerstatuses = smartlist_create();\n  microdescriptors = smartlist_create();\n\n  SMARTLIST_FOREACH_BEGIN(routers, routerinfo_t *, ri) {\n    if (ri->cache_info.published_on >= cutoff) {\n      routerstatus_t *rs;\n      vote_routerstatus_t *vrs;\n      microdesc_t *md;\n\n      vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));\n      rs = &vrs->status;\n      set_routerstatus_from_routerinfo(rs, ri, now,\n                                       naming, listbadexits, listbaddirs,\n                                       vote_on_hsdirs);\n\n      if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest))\n        clear_status_flags_on_sybil(rs);\n\n      if (!vote_on_reachability)\n        rs->is_running = 0;\n\n      vrs->version = version_from_platform(ri->platform);\n      md = dirvote_create_microdescriptor(ri);\n      if (md) {\n        char buf[128];\n        vote_microdesc_hash_t *h;\n        dirvote_format_microdesc_vote_line(buf, sizeof(buf), md);\n        h = tor_malloc(sizeof(vote_microdesc_hash_t));\n        h->microdesc_hash_line = tor_strdup(buf);\n        h->next = NULL;\n        vrs->microdesc = h;\n        md->last_listed = now;\n        smartlist_add(microdescriptors, md);\n      }\n\n      smartlist_add(routerstatuses, vrs);\n    }\n  } SMARTLIST_FOREACH_END(ri);\n\n  {\n    smartlist_t *added =\n      microdescs_add_list_to_cache(get_microdesc_cache(),\n                                   microdescriptors, SAVED_NOWHERE, 0);\n    smartlist_free(added);\n    smartlist_free(microdescriptors);\n  }\n\n  smartlist_free(routers);\n  digestmap_free(omit_as_sybil, NULL);\n\n  if (options->V3BandwidthsFile) {\n    dirserv_read_measured_bandwidths(options->V3BandwidthsFile,\n                                     routerstatuses);\n  }\n\n  v3_out = tor_malloc_zero(sizeof(networkstatus_t));\n\n  v3_out->type = NS_TYPE_VOTE;\n  dirvote_get_preferred_voting_intervals(&timing);\n  v3_out->published = now;\n  {\n    char tbuf[ISO_TIME_LEN+1];\n    networkstatus_t *current_consensus =\n      networkstatus_get_live_consensus(now);\n    long last_consensus_interval; \/* only used to pick a valid_after *\/\n    if (current_consensus)\n      last_consensus_interval = current_consensus->fresh_until -\n        current_consensus->valid_after;\n    else\n      last_consensus_interval = options->TestingV3AuthInitialVotingInterval;\n    v3_out->valid_after =\n      dirvote_get_start_of_next_interval(now, (int)last_consensus_interval);\n    format_iso_time(tbuf, v3_out->valid_after);\n    log_notice(LD_DIR,\"Choosing valid-after time in vote as %s: \"\n               \"consensus_set=%d, last_interval=%d\",\n               tbuf, current_consensus?1:0, (int)last_consensus_interval);\n  }\n  v3_out->fresh_until = v3_out->valid_after + timing.vote_interval;\n  v3_out->valid_until = v3_out->valid_after +\n    (timing.vote_interval * timing.n_intervals_valid);\n  v3_out->vote_seconds = timing.vote_delay;\n  v3_out->dist_seconds = timing.dist_delay;\n  tor_assert(v3_out->vote_seconds > 0);\n  tor_assert(v3_out->dist_seconds > 0);\n  tor_assert(timing.n_intervals_valid > 0);\n\n  v3_out->client_versions = client_versions;\n  v3_out->server_versions = server_versions;\n  v3_out->known_flags = smartlist_create();\n  smartlist_split_string(v3_out->known_flags,\n                \"Authority Exit Fast Guard Stable V2Dir Valid\",\n                0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);\n  if (vote_on_reachability)\n    smartlist_add(v3_out->known_flags, tor_strdup(\"Running\"));\n  if (listbaddirs)\n    smartlist_add(v3_out->known_flags, tor_strdup(\"BadDirectory\"));\n  if (listbadexits)\n    smartlist_add(v3_out->known_flags, tor_strdup(\"BadExit\"));\n  if (naming) {\n    smartlist_add(v3_out->known_flags, tor_strdup(\"Named\"));\n    smartlist_add(v3_out->known_flags, tor_strdup(\"Unnamed\"));\n  }\n  if (vote_on_hsdirs)\n    smartlist_add(v3_out->known_flags, tor_strdup(\"HSDir\"));\n  smartlist_sort_strings(v3_out->known_flags);\n\n  if (options->ConsensusParams) {\n    v3_out->net_params = smartlist_create();\n    smartlist_split_string(v3_out->net_params,\n                           options->ConsensusParams, NULL, 0, 0);\n    smartlist_sort_strings(v3_out->net_params);\n  }\n\n  voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t));\n  voter->nickname = tor_strdup(options->Nickname);\n  memcpy(voter->identity_digest, identity_digest, DIGEST_LEN);\n  voter->sigs = smartlist_create();\n  voter->address = hostname;\n  voter->addr = addr;\n  voter->dir_port = router_get_advertised_dir_port(options, 0);\n  voter->or_port = router_get_advertised_or_port(options);\n  voter->contact = tor_strdup(contact);\n  if (options->V3AuthUseLegacyKey) {\n    authority_cert_t *c = get_my_v3_legacy_cert();\n    if (c) {\n      if (crypto_pk_get_digest(c->identity_key, voter->legacy_id_digest)) {\n        log_warn(LD_BUG, \"Unable to compute digest of legacy v3 identity key\");\n        memset(voter->legacy_id_digest, 0, DIGEST_LEN);\n      }\n    }\n  }\n\n  v3_out->voters = smartlist_create();\n  smartlist_add(v3_out->voters, voter);\n  v3_out->cert = authority_cert_dup(cert);\n  v3_out->routerstatus_list = routerstatuses;\n  \/* Note: networkstatus_digest is unset; it won't get set until we actually\n   * format the vote. *\/\n\n  return v3_out;\n}","target":0,"code_token_length":1924,"total_token_length":2160,"max_tokens_setting":4096}
+{"idx":384124,"func":"raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,\n                                       raptor_xml_element* element,\n                                       int auto_empty)\n{\n  raptor_iostream* iostr = xml_writer->iostr;\n  raptor_namespace_stack *nstack = xml_writer->nstack;\n  int depth = xml_writer->depth;\n  int auto_indent = XML_WRITER_AUTO_INDENT(xml_writer);\n  struct nsd *nspace_declarations = NULL;\n  size_t nspace_declarations_count = 0;  \n  unsigned int i;\n\n  if(nstack) {\n    int nspace_max_count = element->attribute_count * 2; \/* attr and value *\/\n    if(element->name->nspace)\n      nspace_max_count++;\n    if(element->declared_nspaces)\n      nspace_max_count += raptor_sequence_size(element->declared_nspaces);\n    if(element->xml_language)\n      nspace_max_count++;\n\n    nspace_declarations = RAPTOR_CALLOC(struct nsd*, nspace_max_count,\n                                        sizeof(struct nsd));\n    if(!nspace_declarations)\n      return 1;\n  }\n\n  if(element->name->nspace) {\n    if(nstack && !raptor_namespaces_namespace_in_scope(nstack, element->name->nspace)) {\n      nspace_declarations[0].declaration=\n        raptor_namespace_format_as_xml(element->name->nspace,\n                                       &nspace_declarations[0].length);\n      if(!nspace_declarations[0].declaration)\n        goto error;\n      nspace_declarations[0].nspace = element->name->nspace;\n      nspace_declarations_count++;\n    }\n  }\n\n  if(nstack && element->attributes) {\n    for(i = 0; i < element->attribute_count; i++) {\n      \/* qname *\/\n      if(element->attributes[i]->nspace) {\n        \/* Check if we need a namespace declaration attribute *\/\n        if(nstack && \n           !raptor_namespaces_namespace_in_scope(nstack, element->attributes[i]->nspace) && element->attributes[i]->nspace != element->name->nspace) {\n          \/* not in scope and not same as element (so already going to be declared)*\/\n          unsigned int j;\n          int declare_me = 1;\n          \n          \/* check it wasn't an earlier declaration too *\/\n          for(j = 0; j < nspace_declarations_count; j++)\n            if(nspace_declarations[j].nspace == element->attributes[j]->nspace) {\n              declare_me = 0;\n              break;\n            }\n            \n          if(declare_me) {\n            nspace_declarations[nspace_declarations_count].declaration=\n              raptor_namespace_format_as_xml(element->attributes[i]->nspace,\n                                             &nspace_declarations[nspace_declarations_count].length);\n            if(!nspace_declarations[nspace_declarations_count].declaration)\n              goto error;\n            nspace_declarations[nspace_declarations_count].nspace = element->attributes[i]->nspace;\n            nspace_declarations_count++;\n          }\n        }\n      }\n\n      \/* Add the attribute's value *\/\n      nspace_declarations[nspace_declarations_count].declaration=\n        raptor_qname_format_as_xml(element->attributes[i],\n                                   &nspace_declarations[nspace_declarations_count].length);\n      if(!nspace_declarations[nspace_declarations_count].declaration)\n        goto error;\n      nspace_declarations[nspace_declarations_count].nspace = NULL;\n      nspace_declarations_count++;\n\n    }\n  }\n\n  if(nstack && element->declared_nspaces &&\n     raptor_sequence_size(element->declared_nspaces) > 0) {\n    for(i = 0; i< (unsigned int)raptor_sequence_size(element->declared_nspaces); i++) {\n      raptor_namespace* nspace = (raptor_namespace*)raptor_sequence_get_at(element->declared_nspaces, i);\n      unsigned int j;\n      int declare_me = 1;\n      \n      \/* check it wasn't an earlier declaration too *\/\n      for(j = 0; j < nspace_declarations_count; j++)\n        if(nspace_declarations[j].nspace == nspace) {\n          declare_me = 0;\n          break;\n        }\n      \n      if(declare_me) {\n        nspace_declarations[nspace_declarations_count].declaration=\n          raptor_namespace_format_as_xml(nspace,\n                                         &nspace_declarations[nspace_declarations_count].length);\n        if(!nspace_declarations[nspace_declarations_count].declaration)\n          goto error;\n        nspace_declarations[nspace_declarations_count].nspace = nspace;\n        nspace_declarations_count++;\n      }\n\n    }\n  }\n\n  if(nstack && element->xml_language) {\n    size_t lang_len = strlen(RAPTOR_GOOD_CAST(char*, element->xml_language));\n#define XML_LANG_PREFIX_LEN 10\n    size_t buf_length = XML_LANG_PREFIX_LEN + lang_len + 1;\n    unsigned char* buffer = RAPTOR_MALLOC(unsigned char*, buf_length + 1);\n    const char quote = '\\\"';\n    unsigned char* p;\n\n    memcpy(buffer, \"xml:lang=\\\"\", XML_LANG_PREFIX_LEN);\n    p = buffer + XML_LANG_PREFIX_LEN;\n    p += raptor_xml_escape_string(xml_writer->world,\n                                  element->xml_language, lang_len,\n                                  p, buf_length, quote);\n    *p++ = quote;\n    *p = '\\0';\n\n    nspace_declarations[nspace_declarations_count].declaration = buffer;\n    nspace_declarations[nspace_declarations_count].length = buf_length;\n    nspace_declarations[nspace_declarations_count].nspace = NULL;\n    nspace_declarations_count++;\n  }\n  \n\n  raptor_iostream_write_byte('<', iostr);\n\n  if(element->name->nspace && element->name->nspace->prefix_length > 0) {\n    raptor_iostream_counted_string_write((const char*)element->name->nspace->prefix, \n                                         element->name->nspace->prefix_length,\n                                         iostr);\n    raptor_iostream_write_byte(':', iostr);\n  }\n  raptor_iostream_counted_string_write((const char*)element->name->local_name,\n                                       element->name->local_name_length,\n                                       iostr);\n\n  \/* declare namespaces and attributes *\/\n  if(nspace_declarations_count) {\n    int need_indent = 0;\n    \n    \/* sort them into the canonical order *\/\n    qsort((void*)nspace_declarations, \n          nspace_declarations_count, sizeof(struct nsd),\n          raptor_xml_writer_nsd_compare);\n\n    \/* declare namespaces first *\/\n    for(i = 0; i < nspace_declarations_count; i++) {\n      if(!nspace_declarations[i].nspace)\n        continue;\n\n      if(auto_indent && need_indent) {\n        \/* indent attributes *\/\n        raptor_xml_writer_newline(xml_writer);\n        xml_writer->depth++;\n        raptor_xml_writer_indent(xml_writer);\n        xml_writer->depth--;\n      }\n      raptor_iostream_write_byte(' ', iostr);\n      raptor_iostream_counted_string_write((const char*)nspace_declarations[i].declaration,\n                                           nspace_declarations[i].length,\n                                           iostr);\n      RAPTOR_FREE(char*, nspace_declarations[i].declaration);\n      nspace_declarations[i].declaration = NULL;\n      need_indent = 1;\n      \n      if(raptor_namespace_stack_start_namespace(nstack,\n                                                (raptor_namespace*)nspace_declarations[i].nspace,\n                                                depth))\n        goto error;\n    }\n\n    \/* declare attributes *\/\n    for(i = 0; i < nspace_declarations_count; i++) {\n      if(nspace_declarations[i].nspace)\n        continue;\n\n      if(auto_indent && need_indent) {\n        \/* indent attributes *\/\n        raptor_xml_writer_newline(xml_writer);\n        xml_writer->depth++;\n        raptor_xml_writer_indent(xml_writer);\n        xml_writer->depth--;\n      }\n      raptor_iostream_write_byte(' ', iostr);\n      raptor_iostream_counted_string_write((const char*)nspace_declarations[i].declaration,\n                                           nspace_declarations[i].length,\n                                           iostr);\n      need_indent = 1;\n\n      RAPTOR_FREE(char*, nspace_declarations[i].declaration);\n      nspace_declarations[i].declaration = NULL;\n    }\n  }\n\n  if(!auto_empty)\n    raptor_iostream_write_byte('>', iostr);\n\n  if(nstack)\n    RAPTOR_FREE(stringarray, nspace_declarations);\n\n  return 0;\n\n  \/* Clean up nspace_declarations on error *\/\n  error:\n\n  for(i = 0; i < nspace_declarations_count; i++) {\n    if(nspace_declarations[i].declaration)\n      RAPTOR_FREE(char*, nspace_declarations[i].declaration);\n  }\n\n  RAPTOR_FREE(stringarray, nspace_declarations);\n\n  return 1;\n}","target":0,"code_token_length":1881,"total_token_length":2117,"max_tokens_setting":4096}
+{"idx":343314,"func":"void dopass(char *password)\n{\n    static unsigned int tapping;\n    char *hd;\n#if !defined(MINIMAL) && defined(HAVE_GETGROUPS) && defined(DISPLAY_GROUPS)\n    gid_t *groups = NULL;\n    int ngroups;\n# if defined(NGROUPS_MAX) && NGROUPS_MAX > 0\n    int ngroups_max = NGROUPS_MAX; \/* Use the compile time value *\/\n# else\n    int ngroups_max = 1; \/* use a sane default *\/\n# endif\n#endif\n\n    if (loggedin != 0) {\n        if (guest != 0) {\n            addreply_noformat(230, MSG_NO_PASSWORD_NEEDED);\n#ifdef LOG_ANON_EMAIL\n            snprintf(account, sizeof account, \"ftp: <%s> \", password);\n#endif\n        } else {\n            addreply_noformat(530, MSG_CANT_DO_TWICE);\n        }\n        return;\n    }\n    if (*account == 0) {\n        addreply_noformat(530, MSG_WHOAREYOU);\n        return;\n    }\n    if (strlen(password) >= MAX_PASSWORD_LEN) {\n        addreply_noformat(530, MSG_LINE_TOO_LONG);\n        return;\n    }\n    authresult = pw_check(account, password, &ctrlconn, &peer);\n    pure_memzero(password, strlen(password));\n    if (authresult.auth_ok != 1) {\n        tapping++;\n        randomsleep(tapping);\n        addreply_noformat(530, MSG_AUTH_FAILED);\n        doreply();\n        if (tapping > MAX_PASSWD_TRIES) {\n            logfile(LOG_ERR, MSG_AUTH_TOOMANY);\n            _EXIT(EXIT_FAILURE);\n        }\n        logfile(LOG_WARNING, MSG_AUTH_FAILED_LOG, account);\n        return;\n    }\n    if (authresult.uid < useruid) {\n        logfile(LOG_WARNING, MSG_ACCOUNT_DISABLED \" (uid < %lu)\",\n                account, (unsigned long) useruid);\n        randomsleep(tapping);\n        if (tapping >= MAX_PASSWD_TRIES) {\n            addreply_noformat(530, MSG_AUTH_FAILED);\n            doreply();\n            _EXIT(EXIT_FAILURE);\n        }\n        addreply_noformat(530, MSG_NOTRUST);\n        doreply();\n        return;\n    }\n\n#ifdef PER_USER_LIMITS\n    if (per_user_max > 0U && ftpwho_read_count(account) >= per_user_max) {\n        addreply(421, MSG_PERUSER_MAX, (unsigned long) per_user_max);\n        doreply();\n        _EXIT(1);\n    }\n#endif\n\n    \/* Add username and primary group to the uid\/gid cache *\/\n    (void) getname(authresult.uid);\n    (void) getgroup(authresult.gid);\n\n    if (\n#if defined(WITH_LDAP) || defined(WITH_MYSQL) || defined(WITH_PGSQL) || defined(WITH_PUREDB) || defined(WITH_EXTAUTH)\n        doinitsupgroups(NULL, authresult.uid, authresult.gid) != 0\n#else\n        doinitsupgroups(account, (uid_t) -1, authresult.gid) != 0\n#endif\n        ) {\n#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n        (void) 0;\n#else\n        die(421, LOG_WARNING, MSG_NOTRUST);\n#endif\n    }\n\n    \/* handle \/home\/user\/.\/public_html form *\/\n    if ((root_directory = strdup(authresult.dir)) == NULL) {\n        die_mem();\n    }\n    hd = strstr(root_directory, \"\/.\/\");\n    if (hd != NULL) {\n        if (chrooted != 0) {\n            die(421, LOG_DEBUG, MSG_CANT_DO_TWICE);\n        }\n        if (create_home_and_chdir(root_directory)) {\n            die(421, LOG_ERR, MSG_NO_HOMEDIR);\n        }\n        *++hd = 0;\n        hd++;\n        if (chroot(root_directory) || chdir(hd)) {\n            die(421, LOG_ERR, MSG_NO_HOMEDIR);\n        }\n        chrooted = 1;\n#ifdef RATIOS\n        if (ratio_for_non_anon == 0) {\n            ratio_upload = ratio_download = 0U;\n        }\n        if (check_trustedgroup(authresult.uid, authresult.gid) != 0) {\n            dot_write_ok = dot_read_ok = 1;\n            ratio_upload = ratio_download = 0U;\n            keepallfiles = 0;\n        }\n#endif\n    } else {\n        (void) free(root_directory);\n        root_directory = (char *) \"\/\";\n        if (create_home_and_chdir(authresult.dir)) {\n            die(421, LOG_ERR, MSG_NO_HOMEDIR);\n        }\n    }\n    if (getcwd(wd, sizeof wd - (size_t) 1U) == NULL) {\n        wd[0] = '\/';\n        wd[1] = 0;\n    }\n#ifndef NON_ROOT_FTP\n    if (setgid(authresult.gid) || setegid(authresult.gid)) {\n        _EXIT(EXIT_FAILURE);\n    }\n#endif\n    if (check_trustedgroup(authresult.uid, authresult.gid) != 0) {\n        userchroot = 0;\n        dot_write_ok = dot_read_ok = 1;\n        keepallfiles = 0;\n#ifdef RATIOS\n        ratio_upload = ratio_download = 0U;\n#endif\n#ifdef QUOTAS\n        user_quota_files = user_quota_size = ULONG_LONG_MAX;\n#endif\n    }\n#ifdef QUOTAS\n    if (hasquota() == 0) {\n        userchroot = 1;\n    }\n#endif\n    if (loggedin == 0) {\n        candownload = 1;        \/* real users can always download *\/\n    }\n#ifdef THROTTLING\n    if ((throttling == 2) || (guest != 0 && throttling == 1)) {\n        addreply_noformat(0, MSG_BANDWIDTH_RESTRICTED);\n        (void) nice(NICE_VALUE);\n    } else {\n        throttling_delay = throttling_bandwidth_dl =\n            throttling_bandwidth_ul = 0UL;\n    }\n#endif\n#if !defined(MINIMAL) && defined(HAVE_GETGROUPS) && defined(DISPLAY_GROUPS)\n# ifdef SAFE_GETGROUPS_0\n    ngroups = getgroups(0, NULL);\n    if (ngroups > ngroups_max) {\n        ngroups_max = ngroups;\n    }\n# elif defined(_SC_NGROUPS_MAX)\n    \/* get the run time value *\/\n    ngroups = (int) sysconf(_SC_NGROUPS_MAX);\n    if (ngroups > ngroups_max) {\n        ngroups_max = ngroups;\n    }\n# endif\n    if ((groups = malloc(sizeof(GETGROUPS_T) * ngroups_max)) == NULL) {\n        die_mem();\n    }\n    ngroups = getgroups(ngroups_max, groups);\n    if (guest == 0 && ngroups > 0) {\n        char reply[80 + MAX_USER_LENGTH];\n        const char *q;\n        size_t p;\n\n        if (SNCHECK(snprintf(reply, sizeof reply,\n                             MSG_USER_GROUP_ACCESS \": \", account),\n                    sizeof reply)) {\n            _EXIT(EXIT_FAILURE);\n        }\n        p = strlen(reply);\n        do {\n            ngroups--;\n            if ((ngroups != 0 && groups[ngroups] == groups[0]) ||\n                (q = getgroup(groups[ngroups])) == NULL) {\n                continue;\n            }\n            if (p + strlen(q) > 75) {\n                reply[p] = 0;\n                addreply(0, \"%s\", reply);\n                *reply = 0;\n                p = (size_t) 0U;\n            }\n            reply[p++] = ' ';\n            while (*q != 0 && p < sizeof reply - (size_t) 1U) {\n                reply[p++] = *q++;\n            }\n        } while (ngroups > 0);\n        reply[p] = 0;\n        addreply(0, \"%s\", reply);\n    }\n    free(groups);\n#endif\n    if (guest == 0 && allowfxp == 1) {\n        addreply_noformat(0, MSG_FXP_SUPPORT);\n    }\n#ifdef RATIOS\n    if (ratio_for_non_anon != 0 && ratio_upload > 0) {\n        addreply(0, MSG_RATIO, ratio_upload, ratio_download);\n    }\n#endif\n    if (userchroot != 0 && chrooted == 0) {\n        if (chdir(wd) || chroot(wd)) {    \/* should never fail *\/\n            die(421, LOG_ERR, MSG_CHROOT_FAILED);\n        }\n        chrooted = 1;\n#ifdef RATIOS\n        if (ratio_for_non_anon == 0) {\n            ratio_upload = ratio_download = 0U;\n        }\n#endif\n        {\n            const size_t rd_len = strlen(wd) + sizeof \"\/\";\n\n            if ((root_directory = malloc(rd_len)) == NULL) {\n                die_mem();\n            }\n            snprintf(root_directory, rd_len, \"%s\/\", wd);\n        }\n        wd[0] = '\/';\n        wd[1] = 0;\n        if (chdir(wd)) {\n            _EXIT(EXIT_FAILURE);\n        }\n        addreply(230, MSG_CURRENT_RESTRICTED_DIR_IS, wd);\n    } else {\n        addreply(230, MSG_CURRENT_DIR_IS, wd);\n    }\n\n#ifndef NON_ROOT_FTP\n    disablesignals();\n# ifndef WITHOUT_PRIVSEP\n    if (setuid(authresult.uid) != 0 || seteuid(authresult.uid) != 0) {\n        _EXIT(EXIT_FAILURE);\n    }\n# else\n    if (seteuid(authresult.uid) != 0) {\n        _EXIT(EXIT_FAILURE);\n    }\n#  ifdef USE_CAPABILITIES\n    drop_login_caps();\n#  endif\n# endif\n    enablesignals();\n#endif\n    logfile(LOG_INFO, MSG_IS_NOW_LOGGED_IN, account);\n#ifdef FTPWHO\n    if (shm_data_cur != NULL) {\n        ftpwho_lock();\n        strncpy(shm_data_cur->account, account,\n                sizeof shm_data_cur->account - (size_t) 1U);\n        shm_data_cur->account[sizeof shm_data_cur->account - 1U] = 0;\n        ftpwho_unlock();\n        state_needs_update = 1;\n    }\n#endif\n    loggedin = 1;\n    if (getcwd(wd, sizeof wd - (size_t) 1U) == NULL) {\n        wd[0] = '\/';\n        wd[1] = 0;\n    }\n#ifndef MINIMAL\n    dobanner(0);\n#endif\n#ifdef QUOTAS\n    displayquota(NULL);\n#endif\n#ifdef WITH_BONJOUR\n    refreshManager();\n#endif\n}","target":0,"code_token_length":2332,"total_token_length":2568,"max_tokens_setting":4096}
+{"idx":442826,"func":"static void help(void)\n{\n  int i;\n  static const char * const helptext[]={\n    \"Usage: curl [options...] <url>\",\n    \"Options: (H) means HTTP\/HTTPS only, (F) means FTP only\",\n    \" -a\/--append        Append to target file when uploading (F)\",\n    \" -A\/--user-agent <string> User-Agent to send to server (H)\",\n    \"    --anyauth       Pick \\\"any\\\" authentication method (H)\",\n    \" -b\/--cookie <name=string\/file> Cookie string or file to read cookies from (H)\",\n    \"    --basic         Use HTTP Basic Authentication (H)\",\n    \" -B\/--use-ascii     Use ASCII\/text transfer\",\n    \" -c\/--cookie-jar <file> Write cookies to this file after operation (H)\",\n    \" -C\/--continue-at <offset> Resumed transfer offset\",\n    \" -d\/--data <data>   HTTP POST data (H)\",\n    \"    --data-ascii <data>  HTTP POST ASCII data (H)\",\n    \"    --data-binary <data> HTTP POST binary data (H)\",\n    \"    --negotiate     Use HTTP Negotiate Authentication (H)\",\n    \"    --digest        Use HTTP Digest Authentication (H)\",\n    \"    --disable-eprt  Inhibit using EPRT or LPRT (F)\",\n    \"    --disable-epsv  Inhibit using EPSV (F)\",\n    \" -D\/--dump-header <file> Write the headers to this file\",\n    \"    --egd-file <file> EGD socket path for random data (SSL)\",\n    \"    --tcp-nodelay   Use the TCP_NODELAY option\",\n#ifdef USE_ENVIRONMENT\n    \"    --environment   Write results to environment variables (RISC OS)\",\n#endif\n    \" -e\/--referer       Referer URL (H)\",\n    \" -E\/--cert <cert[:passwd]> Client certificate file and password (SSL)\",\n    \"    --cert-type <type> Certificate file type (DER\/PEM\/ENG) (SSL)\",\n    \"    --key <key>     Private key file name (SSL\/SSH)\",\n    \"    --key-type <type> Private key file type (DER\/PEM\/ENG) (SSL)\",\n    \"    --pass  <pass>  Pass phrase for the private key (SSL\/SSH)\",\n    \"    --pubkey <key>  Public key file name (SSH)\",\n    \"    --engine <eng>  Crypto engine to use (SSL). \\\"--engine list\\\" for list\",\n    \"    --cacert <file> CA certificate to verify peer against (SSL)\",\n    \"    --capath <directory> CA directory (made using c_rehash) to verify\",\n    \"                    peer against (SSL)\",\n    \"    --ciphers <list> SSL ciphers to use (SSL)\",\n    \"    --compressed    Request compressed response (using deflate or gzip)\",\n    \"    --connect-timeout <seconds> Maximum time allowed for connection\",\n    \"    --create-dirs   Create necessary local directory hierarchy\",\n    \"    --crlf          Convert LF to CRLF in upload\",\n    \" -f\/--fail          Fail silently (no output at all) on HTTP errors (H)\",\n    \"    --ftp-account <data> Account data to send when requested by server (F)\",\n    \"    --ftp-alternative-to-user String to replace \\\"USER [name]\\\" (F)\",\n    \"    --ftp-create-dirs Create the remote dirs if not present (F)\",\n    \"    --ftp-method [multicwd\/nocwd\/singlecwd] Control CWD usage (F)\",\n    \"    --ftp-pasv      Use PASV\/EPSV instead of PORT (F)\",\n    \"    --ftp-skip-pasv-ip Skip the IP address for PASV (F)\\n\"\n    \"    --ftp-ssl       Try SSL\/TLS for ftp transfer (F)\",\n    \"    --ftp-ssl-control Require SSL\/TLS for ftp login, clear for transfer (F)\",\n    \"    --ftp-ssl-reqd  Require SSL\/TLS for ftp transfer (F)\",\n    \"    --ftp-ssl-ccc   Send CCC after authenticating (F)\",\n    \"    --ftp-ssl-ccc-mode [active\/passive] Set CCC mode (F)\",\n    \" -F\/--form <name=content> Specify HTTP multipart POST data (H)\",\n    \"    --form-string <name=string> Specify HTTP multipart POST data (H)\",\n    \" -g\/--globoff       Disable URL sequences and ranges using {} and []\",\n    \" -G\/--get           Send the -d data with a HTTP GET (H)\",\n    \" -h\/--help          This help text\",\n    \" -H\/--header <line> Custom header to pass to server (H)\",\n    \"    --ignore-content-length  Ignore the HTTP Content-Length header\",\n    \" -i\/--include       Include protocol headers in the output (H\/F)\",\n    \" -I\/--head          Show document info only\",\n    \" -j\/--junk-session-cookies Ignore session cookies read from file (H)\",\n    \"    --interface <interface> Specify network interface\/address to use\",\n    \"    --krb4 <level>  Enable krb4 with specified security level (F)\",\n    \" -k\/--insecure      Allow connections to SSL sites without certs (H)\",\n    \" -K\/--config        Specify which config file to read\",\n    \"    --libcurl <file> Dump libcurl equivalent code of this command line\",\n    \" -l\/--list-only     List only names of an FTP directory (F)\",\n    \"    --limit-rate <rate> Limit transfer speed to this rate\",\n    \"    --local-port <num>[-num] Force use of these local port numbers\\n\",\n    \" -L\/--location      Follow Location: hints (H)\",\n    \"    --location-trusted Follow Location: and send authentication even \",\n    \"                    to other hostnames (H)\",\n    \" -m\/--max-time <seconds> Maximum time allowed for the transfer\",\n    \"    --max-redirs <num> Maximum number of redirects allowed (H)\",\n    \"    --max-filesize <bytes> Maximum file size to download (H\/F)\",\n    \" -M\/--manual        Display the full manual\",\n    \" -n\/--netrc         Must read .netrc for user name and password\",\n    \"    --netrc-optional Use either .netrc or URL; overrides -n\",\n    \"    --ntlm          Use HTTP NTLM authentication (H)\",\n    \" -N\/--no-buffer     Disable buffering of the output stream\",\n    \"    --no-sessionid  Disable SSL session-ID reusing (SSL)\",\n    \" -o\/--output <file> Write output to <file> instead of stdout\",\n    \" -O\/--remote-name   Write output to a file named as the remote file\",\n    \" -p\/--proxytunnel   Operate through a HTTP proxy tunnel (using CONNECT)\",\n    \"    --proxy-anyauth Pick \\\"any\\\" proxy authentication method (H)\",\n    \"    --proxy-basic   Use Basic authentication on the proxy (H)\",\n    \"    --proxy-digest  Use Digest authentication on the proxy (H)\",\n    \"    --proxy-ntlm    Use NTLM authentication on the proxy (H)\",\n    \" -P\/--ftp-port <address> Use PORT with address instead of PASV (F)\",\n    \" -q                 If used as the first parameter disables .curlrc\",\n    \" -Q\/--quote <cmd>   Send command(s) to server before file transfer (F\/SFTP)\",\n    \" -r\/--range <range> Retrieve a byte range from a HTTP\/1.1 or FTP server\",\n    \"    --random-file <file> File for reading random data from (SSL)\",\n    \"    --raw           Pass HTTP \\\"raw\\\", without any transfer decoding (H)\",\n    \" -R\/--remote-time   Set the remote file's time on the local output\",\n    \"    --retry <num>   Retry request <num> times if transient problems occur\",\n    \"    --retry-delay <seconds> When retrying, wait this many seconds between each\",\n    \"    --retry-max-time <seconds> Retry only within this period\",\n    \" -s\/--silent        Silent mode. Don't output anything\",\n    \" -S\/--show-error    Show error. With -s, make curl show errors when they occur\",\n    \"    --socks4 <host[:port]> Use SOCKS4 proxy on given host + port\",\n    \"    --socks5 <host[:port]> Use SOCKS5 proxy on given host + port\",\n    \"    --stderr <file> Where to redirect stderr. - means stdout\",\n    \" -t\/--telnet-option <OPT=val> Set telnet option\",\n    \"    --trace <file>  Write a debug trace to the given file\",\n    \"    --trace-ascii <file> Like --trace but without the hex output\",\n    \"    --trace-time    Add time stamps to trace\/verbose output\",\n    \" -T\/--upload-file <file> Transfer <file> to remote site\",\n    \"    --url <URL>     Set URL to work with\",\n    \" -u\/--user <user[:password]> Set server user and password\",\n    \" -U\/--proxy-user <user[:password]> Set proxy user and password\",\n    \" -v\/--verbose       Make the operation more talkative\",\n    \" -V\/--version       Show version number and quit\",\n#ifdef MSDOS\n    \"    --wdebug        Turn on Watt-32 debugging under DJGPP\",\n#endif\n    \" -w\/--write-out [format] What to output after completion\",\n    \" -x\/--proxy <host[:port]> Use HTTP proxy on given port\",\n    \" -X\/--request <command> Specify request command to use\",\n    \" -y\/--speed-time    Time needed to trig speed-limit abort. Defaults to 30\",\n    \" -Y\/--speed-limit   Stop transfer if below speed-limit for 'speed-time' secs\",\n    \" -z\/--time-cond <time> Transfer based on a time condition\",\n    \" -0\/--http1.0       Use HTTP 1.0 (H)\",\n    \" -1\/--tlsv1         Use TLSv1 (SSL)\",\n    \" -2\/--sslv2         Use SSLv2 (SSL)\",\n    \" -3\/--sslv3         Use SSLv3 (SSL)\",\n    \" -4\/--ipv4          Resolve name to IPv4 address\",\n    \" -6\/--ipv6          Resolve name to IPv6 address\",\n    \" -#\/--progress-bar  Display transfer progress as a progress bar\",\n    NULL\n  };\n  for(i=0; helptext[i]; i++) {\n    puts(helptext[i]);\n#ifdef __NOVELL_LIBC__\n    if (i && ((i % 23) == 0))\n      pressanykey();\n#endif\n  }\n}","target":0,"code_token_length":2311,"total_token_length":2547,"max_tokens_setting":4096}
+{"idx":242937,"func":"int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n    size_t n;\n\n    if( ssl == NULL || ssl->conf == NULL )\n        return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> read\" ) );\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 )\n            return( ret );\n\n        if( ssl->handshake != NULL &&\n            ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING )\n        {\n            if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 )\n                return( ret );\n        }\n    }\n#endif\n\n    \/*\n     * Check if renegotiation is necessary and\/or handshake is\n     * in process. If yes, perform\/continue, and fall through\n     * if an unexpected packet is received while the client\n     * is waiting for the ServerHello.\n     *\n     * (There is no equivalent to the last condition on\n     *  the server-side as it is not treated as within\n     *  a handshake while waiting for the ClientHello\n     *  after a renegotiation request.)\n     *\/\n\n#if defined(MBEDTLS_SSL_RENEGOTIATION)\n    ret = ssl_check_ctr_renegotiate( ssl );\n    if( ret != MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO &&\n        ret != 0 )\n    {\n        MBEDTLS_SSL_DEBUG_RET( 1, \"ssl_check_ctr_renegotiate\", ret );\n        return( ret );\n    }\n#endif\n\n    if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER )\n    {\n        ret = mbedtls_ssl_handshake( ssl );\n        if( ret != MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO &&\n            ret != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_handshake\", ret );\n            return( ret );\n        }\n    }\n\n    \/* Loop as long as no application data record is available *\/\n    while( ssl->in_offt == NULL )\n    {\n        \/* Start timer if not already running *\/\n        if( ssl->f_get_timer != NULL &&\n            ssl->f_get_timer( ssl->p_timer ) == -1 )\n        {\n            mbedtls_ssl_set_timer( ssl, ssl->conf->read_timeout );\n        }\n\n        if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 )\n        {\n            if( ret == MBEDTLS_ERR_SSL_CONN_EOF )\n                return( 0 );\n\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_read_record\", ret );\n            return( ret );\n        }\n\n        if( ssl->in_msglen  == 0 &&\n            ssl->in_msgtype == MBEDTLS_SSL_MSG_APPLICATION_DATA )\n        {\n            \/*\n             * OpenSSL sends empty messages to randomize the IV\n             *\/\n            if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 )\n            {\n                if( ret == MBEDTLS_ERR_SSL_CONN_EOF )\n                    return( 0 );\n\n                MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_read_record\", ret );\n                return( ret );\n            }\n        }\n\n        if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"received handshake message\" ) );\n\n            \/*\n             * - For client-side, expect SERVER_HELLO_REQUEST.\n             * - For server-side, expect CLIENT_HELLO.\n             * - Fail (TLS) or silently drop record (DTLS) in other cases.\n             *\/\n\n#if defined(MBEDTLS_SSL_CLI_C)\n            if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT &&\n                ( ssl->in_msg[0] != MBEDTLS_SSL_HS_HELLO_REQUEST ||\n                  ssl->in_hslen  != mbedtls_ssl_hs_hdr_len( ssl ) ) )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"handshake received (not HelloRequest)\" ) );\n\n                \/* With DTLS, drop the packet (probably from last handshake) *\/\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n                if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n                {\n                    continue;\n                }\n#endif\n                return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );\n            }\n#endif \/* MBEDTLS_SSL_CLI_C *\/\n\n#if defined(MBEDTLS_SSL_SRV_C)\n            if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER &&\n                ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_HELLO )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 1, ( \"handshake received (not ClientHello)\" ) );\n\n                \/* With DTLS, drop the packet (probably from last handshake) *\/\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n                if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n                {\n                    continue;\n                }\n#endif\n                return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );\n            }\n#endif \/* MBEDTLS_SSL_SRV_C *\/\n\n#if defined(MBEDTLS_SSL_RENEGOTIATION)\n            \/* Determine whether renegotiation attempt should be accepted *\/\n            if( ! ( ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED ||\n                    ( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION &&\n                      ssl->conf->allow_legacy_renegotiation ==\n                                                   MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) ) )\n            {\n                \/*\n                 * Accept renegotiation request\n                 *\/\n\n                \/* DTLS clients need to know renego is server-initiated *\/\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n                if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&\n                    ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT )\n                {\n                    ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_PENDING;\n                }\n#endif\n                ret = mbedtls_ssl_start_renegotiation( ssl );\n                if( ret != MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO &&\n                    ret != 0 )\n                {\n                    MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_start_renegotiation\",\n                                           ret );\n                    return( ret );\n                }\n            }\n            else\n#endif \/* MBEDTLS_SSL_RENEGOTIATION *\/\n            {\n                \/*\n                 * Refuse renegotiation\n                 *\/\n\n                MBEDTLS_SSL_DEBUG_MSG( 3, ( \"refusing renegotiation, sending alert\" ) );\n\n#if defined(MBEDTLS_SSL_PROTO_SSL3)\n                if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 )\n                {\n                    \/* SSLv3 does not have a \"no_renegotiation\" warning, so\n                       we send a fatal alert and abort the connection. *\/\n                    mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n                                                    MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );\n                    return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );\n                }\n                else\n#endif \/* MBEDTLS_SSL_PROTO_SSL3 *\/\n#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \\\n    defined(MBEDTLS_SSL_PROTO_TLS1_2)\n                if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 )\n                {\n                    if( ( ret = mbedtls_ssl_send_alert_message( ssl,\n                                    MBEDTLS_SSL_ALERT_LEVEL_WARNING,\n                                    MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION ) ) != 0 )\n                    {\n                        return( ret );\n                    }\n                }\n                else\n#endif \/* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 ||\n          MBEDTLS_SSL_PROTO_TLS1_2 *\/\n                {\n                    MBEDTLS_SSL_DEBUG_MSG( 1, ( \"should never happen\" ) );\n                    return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n                }\n            }\n\n            \/* At this point, we don't know whether the renegotiation has been\n             * completed or not. The cases to consider are the following:\n             * 1) The renegotiation is complete. In this case, no new record\n             *    has been read yet.\n             * 2) The renegotiation is incomplete because the client received\n             *    an application data record while awaiting the ServerHello.\n             * 3) The renegotiation is incomplete because the client received\n             *    a non-handshake, non-application data message while awaiting\n             *    the ServerHello.\n             * In each of these case, looping will be the proper action:\n             * - For 1), the next iteration will read a new record and check\n             *   if it's application data.\n             * - For 2), the loop condition isn't satisfied as application data\n             *   is present, hence continue is the same as break\n             * - For 3), the loop condition is satisfied and read_record\n             *   will re-deliver the message that was held back by the client\n             *   when expecting the ServerHello.\n             *\/\n            continue;\n        }\n#if defined(MBEDTLS_SSL_RENEGOTIATION)\n        else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING )\n        {\n            if( ssl->conf->renego_max_records >= 0 )\n            {\n                if( ++ssl->renego_records_seen > ssl->conf->renego_max_records )\n                {\n                    MBEDTLS_SSL_DEBUG_MSG( 1, ( \"renegotiation requested, \"\n                                        \"but not honored by client\" ) );\n                    return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );\n                }\n            }\n        }\n#endif \/* MBEDTLS_SSL_RENEGOTIATION *\/\n\n        \/* Fatal and closure alerts handled by mbedtls_ssl_read_record() *\/\n        if( ssl->in_msgtype == MBEDTLS_SSL_MSG_ALERT )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"ignoring non-fatal non-closure alert\" ) );\n            return( MBEDTLS_ERR_SSL_WANT_READ );\n        }\n\n        if( ssl->in_msgtype != MBEDTLS_SSL_MSG_APPLICATION_DATA )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad application data message\" ) );\n            return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );\n        }\n\n        ssl->in_offt = ssl->in_msg;\n\n        \/* We're going to return something now, cancel timer,\n         * except if handshake (renegotiation) is in progress *\/\n        if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER )\n            mbedtls_ssl_set_timer( ssl, 0 );\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n        \/* If we requested renego but received AppData, resend HelloRequest.\n         * Do it now, after setting in_offt, to avoid taking this branch\n         * again if ssl_write_hello_request() returns WANT_WRITE *\/\n#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_RENEGOTIATION)\n        if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER &&\n            ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING )\n        {\n            if( ( ret = mbedtls_ssl_resend_hello_request( ssl ) ) != 0 )\n            {\n                MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_resend_hello_request\",\n                                       ret );\n                return( ret );\n            }\n        }\n#endif \/* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_RENEGOTIATION *\/\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n    }\n\n    n = ( len < ssl->in_msglen )\n        ? len : ssl->in_msglen;\n\n    memcpy( buf, ssl->in_offt, n );\n    ssl->in_msglen -= n;\n\n    \/* Zeroising the plaintext buffer to erase unused application data\n       from the memory. *\/\n    mbedtls_platform_zeroize( ssl->in_offt, n );\n\n    if( ssl->in_msglen == 0 )\n    {\n        \/* all bytes consumed *\/\n        ssl->in_offt = NULL;\n        ssl->keep_current_message = 0;\n    }\n    else\n    {\n        \/* more data available *\/\n        ssl->in_offt += n;\n    }\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= read\" ) );\n\n    return( (int) n );\n}","target":0,"code_token_length":2680,"total_token_length":2916,"max_tokens_setting":4096}
+{"idx":428228,"func":"ConnectionExists(struct SessionHandle *data,\n                 struct connectdata *needle,\n                 struct connectdata **usethis,\n                 bool *force_reuse)\n{\n  struct connectdata *check;\n  struct connectdata *chosen = 0;\n  bool canPipeline = IsPipeliningPossible(data, needle);\n  bool wantNTLMhttp = ((data->state.authhost.want & CURLAUTH_NTLM) ||\n                       (data->state.authhost.want & CURLAUTH_NTLM_WB)) &&\n    (needle->handler->protocol & PROTO_FAMILY_HTTP) ? TRUE : FALSE;\n  struct connectbundle *bundle;\n\n  *force_reuse = FALSE;\n\n  \/* We can't pipe if the site is blacklisted *\/\n  if(canPipeline && Curl_pipeline_site_blacklisted(data, needle)) {\n    canPipeline = FALSE;\n  }\n\n  \/* Look up the bundle with all the connections to this\n     particular host *\/\n  bundle = Curl_conncache_find_bundle(data->state.conn_cache,\n                                      needle->host.name);\n  if(bundle) {\n    size_t max_pipe_len = Curl_multi_max_pipeline_length(data->multi);\n    size_t best_pipe_len = max_pipe_len;\n    struct curl_llist_element *curr;\n\n    infof(data, \"Found bundle for host %s: %p\\n\",\n          needle->host.name, (void *)bundle);\n\n    \/* We can't pipe if we don't know anything about the server *\/\n    if(canPipeline && !bundle->server_supports_pipelining) {\n      infof(data, \"Server doesn't support pipelining\\n\");\n      canPipeline = FALSE;\n    }\n\n    curr = bundle->conn_list->head;\n    while(curr) {\n      bool match = FALSE;\n#if defined(USE_NTLM)\n      bool credentialsMatch = FALSE;\n#endif\n      size_t pipeLen;\n\n      \/*\n       * Note that if we use a HTTP proxy, we check connections to that\n       * proxy and not to the actual remote server.\n       *\/\n      check = curr->ptr;\n      curr = curr->next;\n\n      if(disconnect_if_dead(check, data))\n        continue;\n\n      pipeLen = check->send_pipe->size + check->recv_pipe->size;\n\n      if(canPipeline) {\n        \/* Make sure the pipe has only GET requests *\/\n        struct SessionHandle* sh = gethandleathead(check->send_pipe);\n        struct SessionHandle* rh = gethandleathead(check->recv_pipe);\n        if(sh) {\n          if(!IsPipeliningPossible(sh, check))\n            continue;\n        }\n        else if(rh) {\n          if(!IsPipeliningPossible(rh, check))\n            continue;\n        }\n      }\n      else {\n        if(pipeLen > 0) {\n          \/* can only happen within multi handles, and means that another easy\n             handle is using this connection *\/\n          continue;\n        }\n\n        if(Curl_resolver_asynch()) {\n          \/* ip_addr_str[0] is NUL only if the resolving of the name hasn't\n             completed yet and until then we don't re-use this connection *\/\n          if(!check->ip_addr_str[0]) {\n            infof(data,\n                  \"Connection #%ld is still name resolving, can't reuse\\n\",\n                  check->connection_id);\n            continue;\n          }\n        }\n\n        if((check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) ||\n           check->bits.close) {\n          \/* Don't pick a connection that hasn't connected yet or that is going\n             to get closed. *\/\n          infof(data, \"Connection #%ld isn't open enough, can't reuse\\n\",\n                check->connection_id);\n#ifdef DEBUGBUILD\n          if(check->recv_pipe->size > 0) {\n            infof(data,\n                  \"BAD! Unconnected #%ld has a non-empty recv pipeline!\\n\",\n                  check->connection_id);\n          }\n#endif\n          continue;\n        }\n      }\n\n      if((needle->handler->flags&PROTOPT_SSL) !=\n         (check->handler->flags&PROTOPT_SSL))\n        \/* don't do mixed SSL and non-SSL connections *\/\n        if(!(needle->handler->protocol & check->handler->protocol))\n          \/* except protocols that have been upgraded via TLS *\/\n          continue;\n\n      if(needle->handler->flags&PROTOPT_SSL) {\n        if((data->set.ssl.verifypeer != check->verifypeer) ||\n           (data->set.ssl.verifyhost != check->verifyhost))\n          continue;\n      }\n\n      if(needle->bits.proxy != check->bits.proxy)\n        \/* don't do mixed proxy and non-proxy connections *\/\n        continue;\n\n      if(!canPipeline && check->inuse)\n        \/* this request can't be pipelined but the checked connection is\n           already in use so we skip it *\/\n        continue;\n\n      if(needle->localdev || needle->localport) {\n        \/* If we are bound to a specific local end (IP+port), we must not\n           re-use a random other one, although if we didn't ask for a\n           particular one we can reuse one that was bound.\n\n           This comparison is a bit rough and too strict. Since the input\n           parameters can be specified in numerous ways and still end up the\n           same it would take a lot of processing to make it really accurate.\n           Instead, this matching will assume that re-uses of bound connections\n           will most likely also re-use the exact same binding parameters and\n           missing out a few edge cases shouldn't hurt anyone very much.\n        *\/\n        if((check->localport != needle->localport) ||\n           (check->localportrange != needle->localportrange) ||\n           !check->localdev ||\n           !needle->localdev ||\n           strcmp(check->localdev, needle->localdev))\n          continue;\n      }\n\n      if((!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) ||\n         wantNTLMhttp) {\n        \/* This protocol requires credentials per connection or is HTTP+NTLM,\n           so verify that we're using the same name and password as well *\/\n        if(!strequal(needle->user, check->user) ||\n           !strequal(needle->passwd, check->passwd)) {\n          \/* one of them was different *\/\n          continue;\n        }\n#if defined(USE_NTLM)\n        credentialsMatch = TRUE;\n#endif\n      }\n\n      if(!needle->bits.httpproxy || needle->handler->flags&PROTOPT_SSL ||\n         (needle->bits.httpproxy && check->bits.httpproxy &&\n          needle->bits.tunnel_proxy && check->bits.tunnel_proxy &&\n          Curl_raw_equal(needle->proxy.name, check->proxy.name) &&\n          (needle->port == check->port))) {\n        \/* The requested connection does not use a HTTP proxy or it uses SSL or\n           it is a non-SSL protocol tunneled over the same http proxy name and\n           port number or it is a non-SSL protocol which is allowed to be\n           upgraded via TLS *\/\n\n        if((Curl_raw_equal(needle->handler->scheme, check->handler->scheme) ||\n            needle->handler->protocol & check->handler->protocol) &&\n           Curl_raw_equal(needle->host.name, check->host.name) &&\n           needle->remote_port == check->remote_port) {\n          if(needle->handler->flags & PROTOPT_SSL) {\n            \/* This is a SSL connection so verify that we're using the same\n               SSL options as well *\/\n            if(!Curl_ssl_config_matches(&needle->ssl_config,\n                                        &check->ssl_config)) {\n              DEBUGF(infof(data,\n                           \"Connection #%ld has different SSL parameters, \"\n                           \"can't reuse\\n\",\n                           check->connection_id));\n              continue;\n            }\n            else if(check->ssl[FIRSTSOCKET].state != ssl_connection_complete) {\n              DEBUGF(infof(data,\n                           \"Connection #%ld has not started SSL connect, \"\n                           \"can't reuse\\n\",\n                           check->connection_id));\n              continue;\n            }\n          }\n          match = TRUE;\n        }\n      }\n      else { \/* The requested needle connection is using a proxy,\n                is the checked one using the same host, port and type? *\/\n        if(check->bits.proxy &&\n           (needle->proxytype == check->proxytype) &&\n           (needle->bits.tunnel_proxy == check->bits.tunnel_proxy) &&\n           Curl_raw_equal(needle->proxy.name, check->proxy.name) &&\n           needle->port == check->port) {\n          \/* This is the same proxy connection, use it! *\/\n          match = TRUE;\n        }\n      }\n\n      if(match) {\n#if defined(USE_NTLM)\n        \/* If we are looking for an HTTP+NTLM connection, check if this is\n           already authenticating with the right credentials. If not, keep\n           looking so that we can reuse NTLM connections if\n           possible. (Especially we must not reuse the same connection if\n           partway through a handshake!) *\/\n        if(wantNTLMhttp) {\n          if(credentialsMatch && check->ntlm.state != NTLMSTATE_NONE) {\n            chosen = check;\n\n            \/* We must use this connection, no other *\/\n            *force_reuse = TRUE;\n            break;\n          }\n          else if(credentialsMatch)\n            \/* this is a backup choice *\/\n            chosen = check;\n          continue;\n        }\n#endif\n\n        if(canPipeline) {\n          \/* We can pipeline if we want to. Let's continue looking for\n             the optimal connection to use, i.e the shortest pipe that is not\n             blacklisted. *\/\n\n          if(pipeLen == 0) {\n            \/* We have the optimal connection. Let's stop looking. *\/\n            chosen = check;\n            break;\n          }\n\n          \/* We can't use the connection if the pipe is full *\/\n          if(pipeLen >= max_pipe_len)\n            continue;\n\n          \/* We can't use the connection if the pipe is penalized *\/\n          if(Curl_pipeline_penalized(data, check))\n            continue;\n\n          if(pipeLen < best_pipe_len) {\n            \/* This connection has a shorter pipe so far. We'll pick this\n               and continue searching *\/\n            chosen = check;\n            best_pipe_len = pipeLen;\n            continue;\n          }\n        }\n        else {\n          \/* We have found a connection. Let's stop searching. *\/\n          chosen = check;\n          break;\n        }\n      }\n    }\n  }\n\n  if(chosen) {\n    *usethis = chosen;\n    return TRUE; \/* yes, we found one to use! *\/\n  }\n\n  return FALSE; \/* no matching connecting exists *\/\n}","target":0,"code_token_length":2218,"total_token_length":2454,"max_tokens_setting":4096}
+{"idx":439140,"func":"static Image *ReadPALMImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  Image\n    *image;\n\n  IndexPacket\n    index;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    totalOffset,\n    seekNextDepth;\n\n  MagickPixelPacket\n    transpix;\n\n  register IndexPacket\n    *indexes;\n\n  register ssize_t\n    i,\n    x;\n\n  register PixelPacket\n    *q;\n\n  size_t\n    bytes_per_row,\n    bits_per_pixel,\n    extent,\n    flags,\n    version,\n    nextDepthOffset,\n    transparentIndex,\n    compressionType,\n    byte,\n    mask,\n    redbits,\n    greenbits,\n    bluebits,\n    one,\n    pad,\n    size,\n    bit;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *last_row,\n    *one_row,\n    *ptr;\n\n  unsigned short\n    color16;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      (void) DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  totalOffset=0;\n  do\n  {\n    image->columns=ReadBlobMSBShort(image);\n    image->rows=ReadBlobMSBShort(image);\n    if (EOFBlob(image) != MagickFalse)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if ((image->columns == 0) || (image->rows == 0))\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    (void) SetImageBackgroundColor(image);\n    bytes_per_row=ReadBlobMSBShort(image);\n    flags=ReadBlobMSBShort(image);\n    bits_per_pixel=(size_t) ReadBlobByte(image);\n    if ((bits_per_pixel != 1) && (bits_per_pixel != 2) &&\n        (bits_per_pixel != 4) && (bits_per_pixel != 8) &&\n        (bits_per_pixel != 16))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    version=(size_t) ReadBlobByte(image);\n    if ((version != 0) && (version != 1) && (version != 2))\n      ThrowReaderException(CorruptImageError,\"FileFormatVersionMismatch\");\n    nextDepthOffset=(size_t) ReadBlobMSBShort(image);\n    transparentIndex=(size_t) ReadBlobByte(image);\n    compressionType=(size_t) ReadBlobByte(image);\n    if ((compressionType != PALM_COMPRESSION_NONE) &&\n        (compressionType != PALM_COMPRESSION_SCANLINE ) &&\n        (compressionType != PALM_COMPRESSION_RLE))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedImageCompression\");\n    pad=ReadBlobMSBShort(image);\n    (void) pad;\n    \/*\n      Initialize image colormap.\n    *\/\n    one=1;\n    if ((bits_per_pixel < 16) &&\n        (AcquireImageColormap(image,one << bits_per_pixel) == MagickFalse))\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    GetMagickPixelPacket(image,&transpix);\n    if (bits_per_pixel == 16)  \/* Direct Color *\/\n      {\n        redbits=(size_t) ReadBlobByte(image);  \/* # of bits of red *\/\n        (void) redbits;\n        greenbits=(size_t) ReadBlobByte(image);  \/* # of bits of green *\/\n        (void) greenbits;\n        bluebits=(size_t) ReadBlobByte(image);  \/* # of bits of blue *\/\n        (void) bluebits;\n        ReadBlobByte(image);  \/* reserved by Palm *\/\n        ReadBlobByte(image);  \/* reserved by Palm *\/\n        transpix.red=(MagickRealType) (QuantumRange*ReadBlobByte(image)\/31);\n        transpix.green=(MagickRealType) (QuantumRange*ReadBlobByte(image)\/63);\n        transpix.blue=(MagickRealType) (QuantumRange*ReadBlobByte(image)\/31);\n      }\n    if (bits_per_pixel == 8)\n      {\n        IndexPacket\n          index;\n\n        if (flags & PALM_HAS_COLORMAP_FLAG)\n          {\n            count=(ssize_t) ReadBlobMSBShort(image);\n            for (i=0; i < (ssize_t) count; i++)\n            {\n              ReadBlobByte(image);\n              index=ConstrainColormapIndex(image,(ssize_t) (255-i));\n              image->colormap[(int) index].red=ScaleCharToQuantum(\n                (unsigned char) ReadBlobByte(image));\n              image->colormap[(int) index].green=ScaleCharToQuantum(\n                (unsigned char) ReadBlobByte(image));\n              image->colormap[(int) index].blue=ScaleCharToQuantum(\n                (unsigned char) ReadBlobByte(image));\n          }\n        }\n      else\n        for (i=0; i < (ssize_t) (1L << bits_per_pixel); i++)\n        {\n          index=ConstrainColormapIndex(image,(ssize_t) (255-i));\n          image->colormap[(int) index].red=ScaleCharToQuantum(\n            PalmPalette[i][0]);\n          image->colormap[(int) index].green=ScaleCharToQuantum(\n            PalmPalette[i][1]);\n          image->colormap[(int) index].blue=ScaleCharToQuantum(\n            PalmPalette[i][2]);\n        }\n      }\n    if (flags & PALM_IS_COMPRESSED_FLAG)\n      size=ReadBlobMSBShort(image);\n    (void) size;\n    image->storage_class=DirectClass;\n    if (bits_per_pixel < 16)\n      {\n        image->storage_class=PseudoClass;\n        image->depth=8;\n      }\n    if (image_info->ping != MagickFalse)\n      {\n        (void) CloseBlob(image);\n        return(image);\n      }\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    extent=MagickMax(bytes_per_row,2*image->columns);\n    one_row=(unsigned char *) AcquireQuantumMemory(extent,sizeof(*one_row));\n    if (one_row == (unsigned char *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    (void) memset(one_row,0,extent*sizeof(*one_row));\n    last_row=(unsigned char *) NULL;\n    if (compressionType == PALM_COMPRESSION_SCANLINE)\n      {\n        last_row=(unsigned char *) AcquireQuantumMemory(MagickMax(bytes_per_row,\n          2*image->columns),sizeof(*last_row));\n        if (last_row == (unsigned char *) NULL)\n          {\n            one_row=(unsigned char *) RelinquishMagickMemory(one_row);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n         (void) memset(last_row,0,MagickMax(bytes_per_row,2*image->columns)*\n           sizeof(*last_row));\n      }\n    mask=(size_t) (1U << bits_per_pixel)-1;\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      if ((flags & PALM_IS_COMPRESSED_FLAG) == 0)\n        {\n          \/* TODO move out of loop! *\/\n          image->compression=NoCompression;\n          count=ReadBlob(image,bytes_per_row,one_row);\n          if (count != (ssize_t) bytes_per_row)\n            break;\n        }\n      else\n        {\n          if (compressionType == PALM_COMPRESSION_RLE)\n            {\n              \/* TODO move out of loop! *\/\n              image->compression=RLECompression;\n              for (i=0; i < (ssize_t) bytes_per_row; )\n              {\n                count=(ssize_t) ReadBlobByte(image);\n                if (count < 0)\n                  break;\n                count=MagickMin(count,(ssize_t) bytes_per_row-i);\n                byte=(size_t) ReadBlobByte(image);\n                (void) memset(one_row+i,(int) byte,(size_t) count);\n                i+=count;\n              }\n          }\n        else\n          if (compressionType == PALM_COMPRESSION_SCANLINE)\n            {\n              size_t\n                one;\n\n              \/* TODO move out of loop! *\/\n              one=1;\n              image->compression=FaxCompression;\n              for (i=0; i < (ssize_t) bytes_per_row; i+=8)\n              {\n                count=(ssize_t) ReadBlobByte(image);\n                if (count < 0)\n                  break;\n                byte=(size_t) MagickMin((ssize_t) bytes_per_row-i,8);\n                for (bit=0; bit < byte; bit++)\n                {\n                  if ((y == 0) || (count & (one << (7 - bit))))\n                    one_row[i+bit]=(unsigned char) ReadBlobByte(image);\n                  else\n                    one_row[i+bit]=last_row[i+bit];\n                }\n              }\n              (void) memcpy(last_row, one_row, bytes_per_row);\n            }\n        }\n      ptr=one_row;\n      q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n      if (q == (PixelPacket *) NULL)\n        break;\n      indexes=GetAuthenticIndexQueue(image);\n      if (bits_per_pixel == 16)\n        {\n          if (image->columns > (2*bytes_per_row))\n            {\n              one_row=(unsigned char *) RelinquishMagickMemory(one_row);\n              if (compressionType == PALM_COMPRESSION_SCANLINE)\n                last_row=(unsigned char *) RelinquishMagickMemory(last_row);\n              ThrowReaderException(CorruptImageError,\"CorruptImage\");\n            }\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            color16=(*ptr++ << 8);\n            color16|=(*ptr++);\n            SetPixelRed(q,(QuantumRange*((color16 >> 11) & 0x1f))\/0x1f);\n            SetPixelGreen(q,(QuantumRange*((color16 >> 5) & 0x3f))\/0x3f);\n            SetPixelBlue(q,(QuantumRange*((color16 >> 0) & 0x1f))\/0x1f);\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n        }\n      else\n        {\n          bit=8-bits_per_pixel;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            if ((size_t) (ptr-one_row) >= bytes_per_row)\n              {\n                one_row=(unsigned char *) RelinquishMagickMemory(one_row);\n                if (compressionType == PALM_COMPRESSION_SCANLINE)\n                  last_row=(unsigned char *) RelinquishMagickMemory(last_row);\n                ThrowReaderException(CorruptImageError,\"CorruptImage\");\n              }\n            index=(IndexPacket) (mask-(((*ptr) & (mask << bit)) >> bit));\n            SetPixelIndex(indexes+x,index);\n            SetPixelRGBO(q,image->colormap+(ssize_t) index);\n            if (bit)\n              bit-=bits_per_pixel;\n            else\n              {\n                ptr++;\n                bit=8-bits_per_pixel;\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n        }\n        if (image->previous == (Image *) NULL)\n          {\n            status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n              image->rows);\n            if (status == MagickFalse)\n              break;\n          }\n      }\n    if (flags & PALM_HAS_TRANSPARENCY_FLAG)\n      {\n        IndexPacket index=ConstrainColormapIndex(image,(mask-transparentIndex));\n        if (bits_per_pixel != 16)\n          SetMagickPixelPacket(image,image->colormap+(ssize_t) index,\n            (const IndexPacket *) NULL,&transpix);\n        (void) TransparentPaintImage(image,&transpix,(Quantum)\n          TransparentOpacity,MagickFalse);\n      }\n    one_row=(unsigned char *) RelinquishMagickMemory(one_row);\n    if (compressionType == PALM_COMPRESSION_SCANLINE)\n      last_row=(unsigned char *) RelinquishMagickMemory(last_row);\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image. Copied from coders\/pnm.c\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    if (nextDepthOffset != 0)\n      {\n        \/*\n          Skip to next image.\n        *\/\n        totalOffset+=(MagickOffsetType) (nextDepthOffset*4);\n        if (totalOffset >= (MagickOffsetType) GetBlobSize(image))\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\")\n        else\n          seekNextDepth=SeekBlob(image,totalOffset,SEEK_SET);\n        if (seekNextDepth != totalOffset)\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n        \/*\n          Allocate next image structure. Copied from coders\/pnm.c\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (nextDepthOffset != 0);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":3150,"total_token_length":3386,"max_tokens_setting":4096}
+{"idx":197517,"func":"static json_t * check_attestation_fido_u2f(json_t * j_params, unsigned char * credential_id, size_t credential_id_len, unsigned char * cert_x, size_t cert_x_len, unsigned char * cert_y, size_t cert_y_len, cbor_item_t * att_stmt, unsigned char * rpid_hash, size_t rpid_hash_len, const unsigned char * client_data) {\n  json_t * j_error = json_array(), * j_return;\n  cbor_item_t * key = NULL, * x5c = NULL, * sig = NULL, * att_cert = NULL;\n  int i, ret;\n  char * message = NULL;\n  gnutls_pubkey_t pubkey = NULL;\n  gnutls_x509_crt_t cert = NULL;\n  gnutls_datum_t cert_dat, data, signature, cert_issued_by;\n  unsigned char data_signed[200], client_data_hash[32], cert_export[32], cert_export_b64[64];\n  size_t data_signed_offset = 0, client_data_hash_len = 32, cert_export_len = 32, cert_export_b64_len = 0;\n  \n  if (j_error != NULL) {\n    do {\n      if (gnutls_x509_crt_init(&cert)) {\n        json_array_append_new(j_error, json_string(\"check_attestation_fido_u2f - Error gnutls_x509_crt_init\"));\n        break;\n      }\n      if (gnutls_pubkey_init(&pubkey)) {\n        json_array_append_new(j_error, json_string(\"check_attestation_fido_u2f - Error gnutls_pubkey_init\"));\n        break;\n      }\n      \n      \/\/ Step 1\n      if (att_stmt == NULL || !cbor_isa_map(att_stmt) || cbor_map_size(att_stmt) != 2) {\n        json_array_append_new(j_error, json_string(\"CBOR map value 'attStmt' invalid format\"));\n        break;\n      }\n      for (i=0; i<2; i++) {\n        key = cbor_map_handle(att_stmt)[i].key;\n        if (cbor_isa_string(key)) {\n          if (0 == o_strncmp((const char *)cbor_string_handle(key), \"x5c\", MIN(o_strlen(\"x5c\"), cbor_string_length(key)))) {\n            x5c = cbor_map_handle(att_stmt)[i].value;\n          } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"sig\", MIN(o_strlen(\"sig\"), cbor_string_length(key)))) {\n            sig = cbor_map_handle(att_stmt)[i].value;\n          } else {\n            message = msprintf(\"attStmt map element %d key is not valid: '%.*s'\", i, cbor_string_length(key), cbor_string_handle(key));\n            json_array_append_new(j_error, json_string(message));\n            o_free(message);\n            break;\n          }\n        } else {\n          message = msprintf(\"attStmt map element %d key is not a string\", i);\n          json_array_append_new(j_error, json_string(message));\n          o_free(message);\n          break;\n        }\n      }\n      if (x5c == NULL || !cbor_isa_array(x5c) || cbor_array_size(x5c) != 1) {\n        json_array_append_new(j_error, json_string(\"CBOR map value 'x5c' invalid format\"));\n        break;\n      }\n      att_cert = cbor_array_get(x5c, 0);\n      cert_dat.data = cbor_bytestring_handle(att_cert);\n      cert_dat.size = cbor_bytestring_length(att_cert);\n      if ((ret = gnutls_x509_crt_import(cert, &cert_dat, GNUTLS_X509_FMT_DER)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error importing x509 certificate\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_fido_u2f - Error gnutls_pcert_import_x509_raw: %d\", ret);\n        break;\n      }\n      if (json_object_get(j_params, \"root-ca-list\") != json_null() && validate_certificate_from_root(j_params, cert, x5c) != G_OK) {\n        json_array_append_new(j_error, json_string(\"Unrecognized certificate authority\"));\n        if (gnutls_x509_crt_get_issuer_dn2(cert, &cert_issued_by) >= 0) {\n          message = msprintf(\"Unrecognized certificate autohority: %.*s\", cert_issued_by.size, cert_issued_by.data);\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_fido_u2f - %s\", message);\n          o_free(message);\n          gnutls_free(cert_issued_by.data);\n        } else {\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_fido_u2f - Unrecognized certificate autohority (unable to get issuer dn)\");\n        }\n        break;\n      }\n      if ((ret = gnutls_pubkey_import_x509(pubkey, cert, 0)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error importing x509 certificate\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_fido_u2f - Error gnutls_pubkey_import_x509: %d\", ret);\n        break;\n      }\n      if ((ret = gnutls_x509_crt_get_key_id(cert, GNUTLS_KEYID_USE_SHA256, cert_export, &cert_export_len)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error exporting x509 certificate\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_fido_u2f - Error gnutls_x509_crt_get_key_id: %d\", ret);\n        break;\n      }\n      if (!o_base64_encode(cert_export, cert_export_len, cert_export_b64, &cert_export_b64_len)) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_fido_u2f - Error o_base64_encode cert_export\");\n        break;\n      }\n      if (!generate_digest_raw(digest_SHA256, client_data, o_strlen((char *)client_data), client_data_hash, &client_data_hash_len)) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_fido_u2f - Error generate_digest_raw client_data\");\n        break;\n      }\n\n      if (sig == NULL || !cbor_isa_bytestring(sig)) {\n        json_array_append_new(j_error, json_string(\"Error sig is not a bytestring\"));\n        break;\n      }\n      \n      \/\/ Build bytestring to verify signature\n      data_signed[0] = 0x0;\n      data_signed_offset = 1;\n      \n      memcpy(data_signed+data_signed_offset, rpid_hash, rpid_hash_len);\n      data_signed_offset += rpid_hash_len;\n      \n      memcpy(data_signed+data_signed_offset, client_data_hash, client_data_hash_len);\n      data_signed_offset+=client_data_hash_len;\n      \n      memcpy(data_signed+data_signed_offset, credential_id, credential_id_len);\n      data_signed_offset+=credential_id_len;\n      \n      data_signed[data_signed_offset] = 0x04;\n      data_signed_offset++;\n      \n      memcpy(data_signed+data_signed_offset, cert_x, cert_x_len);\n      data_signed_offset+=cert_x_len;\n      \n      memcpy(data_signed+data_signed_offset, cert_y, cert_y_len);\n      data_signed_offset+=cert_y_len;\n        \n      \/\/ Let's verify sig over data_signed\n      data.data = data_signed;\n      data.size = data_signed_offset;\n      \n      signature.data = cbor_bytestring_handle(sig);\n      signature.size = cbor_bytestring_length(sig);\n      \n      if (gnutls_pubkey_verify_data2(pubkey, GNUTLS_SIGN_ECDSA_SHA256, 0, &data, &signature)) {\n        json_array_append_new(j_error, json_string(\"Invalid signature\"));\n      }\n      \n    } while (0);\n    \n    if (json_array_size(j_error)) {\n      j_return = json_pack(\"{sisO}\", \"result\", G_ERROR_PARAM, \"error\", j_error);\n    } else {\n      j_return = json_pack(\"{sis{ss%}}\", \"result\", G_OK, \"data\", \"certificate\", cert_export_b64, cert_export_b64_len);\n    }\n    json_decref(j_error);\n    gnutls_pubkey_deinit(pubkey);\n    gnutls_x509_crt_deinit(cert);\n    if (att_cert != NULL) {\n      cbor_decref(&att_cert);\n    }\n    \n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_fido_u2f - Error allocating resources for j_error\");\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n  }\n  return j_return;\n}","target":1,"code_token_length":1953,"total_token_length":2189,"max_tokens_setting":4096}
+{"idx":230461,"func":"ns_input(void)\n{\n  uint8_t flags = 0;\n\n  LOG_INFO(\"Received NS from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\" to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\" with target address \");\n  LOG_INFO_6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));\n  LOG_INFO_(\"\\n\");\n  UIP_STAT(++uip_stat.nd6.recv);\n\n#if UIP_CONF_IPV6_CHECKS\n  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||\n     (uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||\n     (UIP_ICMP_BUF->icode != 0)) {\n    LOG_ERR(\"NS received is bad\\n\");\n    goto discard;\n  }\n#endif \/* UIP_CONF_IPV6_CHECKS *\/\n\n  \/* Options processing *\/\n  nd6_opt_llao = NULL;\n  nd6_opt_offset = UIP_ND6_NS_LEN;\n  while(uip_l3_icmp_hdr_len + nd6_opt_offset + UIP_ND6_OPT_HDR_LEN < uip_len) {\n#if UIP_CONF_IPV6_CHECKS\n    if(ND6_OPT_HDR_BUF(nd6_opt_offset)->len == 0) {\n      LOG_ERR(\"NS received is bad\\n\");\n      goto discard;\n    }\n#endif \/* UIP_CONF_IPV6_CHECKS *\/\n    switch (ND6_OPT_HDR_BUF(nd6_opt_offset)->type) {\n    case UIP_ND6_OPT_SLLAO:\n      if(uip_l3_icmp_hdr_len + nd6_opt_offset +\n         UIP_ND6_OPT_DATA_OFFSET + UIP_LLADDR_LEN > uip_len) {\n        LOG_ERR(\"Insufficient data for NS SLLAO option\\n\");\n        goto discard;\n      }\n      nd6_opt_llao = &uip_buf[uip_l3_icmp_hdr_len + nd6_opt_offset];\n#if UIP_CONF_IPV6_CHECKS\n      \/* There must be NO option in a DAD NS *\/\n      if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {\n        LOG_ERR(\"NS received is bad\\n\");\n        goto discard;\n      } else {\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n        uip_lladdr_t lladdr_aligned;\n        extract_lladdr_from_llao_aligned(&lladdr_aligned);\n        nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);\n        if(nbr == NULL) {\n          uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,\n\t\t\t  0, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);\n        } else {\n          const uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(nbr);\n          if(lladdr == NULL) {\n            goto discard;\n          }\n          if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],\n              lladdr, UIP_LLADDR_LEN) != 0) {\n            if(uip_ds6_nbr_update_ll(&nbr,\n                                     (const uip_lladdr_t *)&lladdr_aligned)\n               < 0) {\n              \/* failed to update the lladdr *\/\n              goto discard;\n            }\n            nbr->state = NBR_STALE;\n          } else {\n            if(nbr->state == NBR_INCOMPLETE) {\n              nbr->state = NBR_STALE;\n            }\n          }\n        }\n#if UIP_CONF_IPV6_CHECKS\n      }\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n      break;\n    default:\n      LOG_WARN(\"ND option not supported in NS\");\n      break;\n    }\n    nd6_opt_offset += (ND6_OPT_HDR_BUF(nd6_opt_offset)->len << 3);\n  }\n\n  addr = uip_ds6_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr);\n  if(addr != NULL) {\n    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {\n      \/* DAD CASE *\/\n#if UIP_ND6_DEF_MAXDADNS > 0\n#if UIP_CONF_IPV6_CHECKS\n      if(!uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) {\n        LOG_ERR(\"NS received is bad\\n\");\n        goto discard;\n      }\n#endif \/* UIP_CONF_IPV6_CHECKS *\/\n      if(addr->state != ADDR_TENTATIVE) {\n        uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);\n        uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);\n        flags = UIP_ND6_NA_FLAG_OVERRIDE;\n        goto create_na;\n      } else {\n          \/** \\todo if I sent a NS before him, I win *\/\n        uip_ds6_dad_failed(addr);\n        goto discard;\n      }\n#else \/* UIP_ND6_DEF_MAXDADNS > 0 *\/\n      goto discard;  \/* DAD CASE *\/\n#endif \/* UIP_ND6_DEF_MAXDADNS > 0 *\/\n    }\n#if UIP_CONF_IPV6_CHECKS\n    if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)) {\n        \/**\n         * \\NOTE do we do something here? we both are using the same address.\n         * If we are doing dad, we could cancel it, though we should receive a\n         * NA in response of DAD NS we sent, hence DAD will fail anyway. If we\n         * were not doing DAD, it means there is a duplicate in the network!\n         *\/\n      LOG_ERR(\"NS received is bad\\n\");\n      goto discard;\n    }\n#endif \/*UIP_CONF_IPV6_CHECKS *\/\n\n    \/* Address resolution case *\/\n    if(uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) {\n      uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr);\n      uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &UIP_ND6_NS_BUF->tgtipaddr);\n      flags = UIP_ND6_NA_FLAG_SOLICITED | UIP_ND6_NA_FLAG_OVERRIDE;\n      goto create_na;\n    }\n\n    \/* NUD CASE *\/\n    if(uip_ds6_addr_lookup(&UIP_IP_BUF->destipaddr) == addr) {\n      uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr);\n      uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &UIP_ND6_NS_BUF->tgtipaddr);\n      flags = UIP_ND6_NA_FLAG_SOLICITED | UIP_ND6_NA_FLAG_OVERRIDE;\n      goto create_na;\n    } else {\n#if UIP_CONF_IPV6_CHECKS\n      LOG_ERR(\"NS received is bad\\n\");\n      goto discard;\n#endif \/* UIP_CONF_IPV6_CHECKS *\/\n    }\n  } else {\n    goto discard;\n  }\n\n\ncreate_na:\n    \/* If the node is a router it should set R flag in NAs *\/\n#if UIP_CONF_ROUTER\n    flags = flags | UIP_ND6_NA_FLAG_ROUTER;\n#endif\n  uipbuf_clear();\n  UIP_IP_BUF->vtc = 0x60;\n  UIP_IP_BUF->tcflow = 0;\n  UIP_IP_BUF->flow = 0;\n  uipbuf_set_len_field(UIP_IP_BUF, UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN);\n  UIP_IP_BUF->proto = UIP_PROTO_ICMP6;\n  UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;\n\n  UIP_ICMP_BUF->type = ICMP6_NA;\n  UIP_ICMP_BUF->icode = 0;\n\n  UIP_ND6_NA_BUF->flagsreserved = flags;\n  memcpy(&UIP_ND6_NA_BUF->tgtipaddr, &addr->ipaddr, sizeof(uip_ipaddr_t));\n\n  create_llao(&uip_buf[uip_l3_icmp_hdr_len + UIP_ND6_NA_LEN],\n              UIP_ND6_OPT_TLLAO);\n\n  UIP_ICMP_BUF->icmpchksum = 0;\n  UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();\n\n  uipbuf_set_len(UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN);\n\n  UIP_STAT(++uip_stat.nd6.sent);\n  LOG_INFO(\"Sending NA to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\" from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\" with target address \");\n  LOG_INFO_6ADDR(&UIP_ND6_NA_BUF->tgtipaddr);\n  LOG_INFO_(\"\\n\");\n  return;\n\ndiscard:\n  uipbuf_clear();\n  return;\n}","target":0,"code_token_length":1908,"total_token_length":2144,"max_tokens_setting":4096}
+{"idx":509487,"func":"static int table2maria(TABLE *table_arg, data_file_type row_type,\n                       MARIA_KEYDEF **keydef_out,\n                       MARIA_COLUMNDEF **recinfo_out, uint *records_out,\n                       MARIA_CREATE_INFO *create_info)\n{\n  uint i, j, recpos, minpos, fieldpos, temp_length, length;\n  enum ha_base_keytype type= HA_KEYTYPE_BINARY;\n  uchar *record;\n  KEY *pos;\n  MARIA_KEYDEF *keydef;\n  MARIA_COLUMNDEF *recinfo, *recinfo_pos;\n  HA_KEYSEG *keyseg;\n  TABLE_SHARE *share= table_arg->s;\n  uint options= share->db_options_in_use;\n  DBUG_ENTER(\"table2maria\");\n\n  if (row_type == BLOCK_RECORD)\n    options|= HA_OPTION_PACK_RECORD;\n\n  if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),\n          recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF),\n          keydef_out, share->keys * sizeof(MARIA_KEYDEF),\n          &keyseg,\n          (share->key_parts + share->keys) * sizeof(HA_KEYSEG),\n          NullS)))\n    DBUG_RETURN(HA_ERR_OUT_OF_MEM); \/* purecov: inspected *\/\n  keydef= *keydef_out;\n  recinfo= *recinfo_out;\n  pos= table_arg->key_info;\n  for (i= 0; i < share->keys; i++, pos++)\n  {\n    keydef[i].flag= (uint16) (pos->flags & (HA_NOSAME | HA_FULLTEXT |\n                                            HA_SPATIAL));\n    keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?\n      (pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :\n      pos->algorithm;\n    keydef[i].block_length= pos->block_size;\n    keydef[i].seg= keyseg;\n    keydef[i].keysegs= pos->user_defined_key_parts;\n    for (j= 0; j < pos->user_defined_key_parts; j++)\n    {\n      Field *field= pos->key_part[j].field;\n\n      if (!table_arg->field[field->field_index]->stored_in_db())\n      {\n        my_free(*recinfo_out);\n        if (table_arg->s->long_unique_table)\n        {\n          my_error(ER_TOO_LONG_KEY, MYF(0), table_arg->file->max_key_length());\n          DBUG_RETURN(HA_ERR_INDEX_COL_TOO_LONG);\n        }\n        my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN, MYF(0));\n        DBUG_RETURN(HA_ERR_UNSUPPORTED);\n      }\n\n      type= field->key_type();\n      keydef[i].seg[j].flag= pos->key_part[j].key_part_flag;\n\n      if (options & HA_OPTION_PACK_KEYS ||\n          (pos->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY |\n                         HA_SPACE_PACK_USED)))\n      {\n        if (pos->key_part[j].length > 8 &&\n            (type == HA_KEYTYPE_TEXT ||\n             type == HA_KEYTYPE_NUM ||\n             (type == HA_KEYTYPE_BINARY && !field->zero_pack())))\n        {\n          \/* No blobs here *\/\n          if (j == 0)\n            keydef[i].flag|= HA_PACK_KEY;\n          if (!(field->flags & ZEROFILL_FLAG) &&\n              (field->type() == MYSQL_TYPE_STRING ||\n               field->type() == MYSQL_TYPE_VAR_STRING ||\n               ((int) (pos->key_part[j].length - field->decimals())) >= 4))\n            keydef[i].seg[j].flag|= HA_SPACE_PACK;\n        }\n        else if (j == 0 && (!(pos->flags & HA_NOSAME) || pos->key_length > 16))\n          keydef[i].flag|= HA_BINARY_PACK_KEY;\n      }\n      keydef[i].seg[j].type= (int) type;\n      keydef[i].seg[j].start= pos->key_part[j].offset;\n      keydef[i].seg[j].length= pos->key_part[j].length;\n      keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_length= 0;\n      keydef[i].seg[j].bit_pos= 0;\n      keydef[i].seg[j].language= field->charset()->number;\n\n      if (field->null_ptr)\n      {\n        keydef[i].seg[j].null_bit= field->null_bit;\n        keydef[i].seg[j].null_pos= (uint) (field->null_ptr-\n                                           (uchar*) table_arg->record[0]);\n      }\n      else\n      {\n        keydef[i].seg[j].null_bit= 0;\n        keydef[i].seg[j].null_pos= 0;\n      }\n      if (field->type() == MYSQL_TYPE_BLOB ||\n          field->type() == MYSQL_TYPE_GEOMETRY)\n      {\n        keydef[i].seg[j].flag|= HA_BLOB_PART;\n        \/* save number of bytes used to pack length *\/\n        keydef[i].seg[j].bit_start= (uint) (field->pack_length() -\n                                            portable_sizeof_char_ptr);\n      }\n      else if (field->type() == MYSQL_TYPE_BIT)\n      {\n        keydef[i].seg[j].bit_length= ((Field_bit *) field)->bit_len;\n        keydef[i].seg[j].bit_start= ((Field_bit *) field)->bit_ofs;\n        keydef[i].seg[j].bit_pos= (uint) (((Field_bit *) field)->bit_ptr -\n                                          (uchar*) table_arg->record[0]);\n      }\n    }\n    keyseg+= pos->user_defined_key_parts;\n  }\n  if (table_arg->found_next_number_field)\n    keydef[share->next_number_index].flag|= HA_AUTO_KEY;\n  record= table_arg->record[0];\n  recpos= 0;\n  recinfo_pos= recinfo;\n  create_info->null_bytes= table_arg->s->null_bytes;\n\n  while (recpos < (uint) share->stored_rec_length)\n  {\n    Field **field, *found= 0;\n    minpos= share->reclength;\n    length= 0;\n\n    for (field= table_arg->field; *field; field++)\n    {\n      if ((fieldpos= (*field)->offset(record)) >= recpos &&\n          fieldpos <= minpos)\n      {\n        \/* skip null fields *\/\n        if (!(temp_length= (*field)->pack_length_in_rec()))\n          continue; \/* Skip null-fields *\/\n        if (! found || fieldpos < minpos ||\n            (fieldpos == minpos && temp_length < length))\n        {\n          minpos= fieldpos;\n          found= *field;\n          length= temp_length;\n        }\n      }\n    }\n    DBUG_PRINT(\"loop\", (\"found: %p  recpos: %d  minpos: %d  length: %d\",\n                        found, recpos, minpos, length));\n    if (!found)\n      break;\n\n    if (found->flags & BLOB_FLAG)\n      recinfo_pos->type= FIELD_BLOB;\n    else if (found->type() == MYSQL_TYPE_TIMESTAMP)\n      recinfo_pos->type= FIELD_NORMAL;\n    else if (found->type() == MYSQL_TYPE_VARCHAR)\n      recinfo_pos->type= FIELD_VARCHAR;\n    else if (!(options & HA_OPTION_PACK_RECORD) ||\n             (found->zero_pack() && (found->flags & PRI_KEY_FLAG)))\n      recinfo_pos->type= FIELD_NORMAL;\n    else if (found->zero_pack())\n      recinfo_pos->type= FIELD_SKIP_ZERO;\n    else\n      recinfo_pos->type= ((length <= 3 ||\n                           (found->flags & ZEROFILL_FLAG)) ?\n                          FIELD_NORMAL :\n                          found->type() == MYSQL_TYPE_STRING ||\n                          found->type() == MYSQL_TYPE_VAR_STRING ?\n                          FIELD_SKIP_ENDSPACE :\n                          FIELD_SKIP_PRESPACE);\n    if (found->null_ptr)\n    {\n      recinfo_pos->null_bit= found->null_bit;\n      recinfo_pos->null_pos= (uint) (found->null_ptr -\n                                     (uchar*) table_arg->record[0]);\n    }\n    else\n    {\n      recinfo_pos->null_bit= 0;\n      recinfo_pos->null_pos= 0;\n    }\n    (recinfo_pos++)->length= (uint16) length;\n    recpos= minpos + length;\n    DBUG_PRINT(\"loop\", (\"length: %d  type: %d\",\n                        recinfo_pos[-1].length,recinfo_pos[-1].type));\n  }\n  *records_out= (uint) (recinfo_pos - recinfo);\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":1873,"total_token_length":2109,"max_tokens_setting":4096}
+{"idx":384535,"func":"void MACH0_(mach_headerfields)(RBinFile *bf) {\n\tPrintfCallback cb_printf = bf->rbin->cb_printf;\n\tif (!cb_printf) {\n\t\tcb_printf = printf;\n\t}\n\tRBuffer *buf = bf->buf;\n\tut64 length = r_buf_size (buf);\n\tint n = 0;\n\tstruct MACH0_(mach_header) *mh = MACH0_(get_hdr)(buf);\n\tif (!mh) {\n\t\treturn;\n\t}\n\tut64 pvaddr = pa2va (bf, 0);\n\tcb_printf (\"pf.mach0_header @ 0x%08\"PFMT64x\"\\n\", pvaddr);\n\tcb_printf (\"0x%08\"PFMT64x\"  Magic       0x%x\\n\", pvaddr, mh->magic);\n\tpvaddr += 4;\n\tcb_printf (\"0x%08\"PFMT64x\"  CpuType     0x%x\\n\", pvaddr, mh->cputype);\n\tpvaddr += 4;\n\tcb_printf (\"0x%08\"PFMT64x\"  CpuSubType  0x%x\\n\", pvaddr, mh->cpusubtype);\n\tpvaddr += 4;\n\tcb_printf (\"0x%08\"PFMT64x\"  FileType    0x%x\\n\", pvaddr, mh->filetype);\n\tpvaddr += 4;\n\tcb_printf (\"0x%08\"PFMT64x\"  nCmds       %d\\n\", pvaddr, mh->ncmds);\n\tpvaddr += 4;\n\tcb_printf (\"0x%08\"PFMT64x\"  sizeOfCmds  %d\\n\", pvaddr, mh->sizeofcmds);\n\tpvaddr += 4;\n\tcb_printf (\"0x%08\"PFMT64x\"  Flags       0x%x\\n\", pvaddr, mh->flags);\n\tpvaddr += 4;\n\tbool is64 = mh->cputype >> 16;\n\n\tut64 addr = 0x20 - 4;\n\tut32 word = 0;\n\tut8 wordbuf[sizeof (word)];\n\tbool isBe = false;\n\tswitch (mh->cputype) {\n\tcase CPU_TYPE_POWERPC:\n\tcase CPU_TYPE_POWERPC64:\n\t\tisBe = true;\n\t\tbreak;\n\t}\n#define READWORD() \\\n\t\tif (r_buf_read_at (buf, addr, (ut8*)wordbuf, 4) != 4) { \\\n\t\t\teprintf (\"Invalid address in buffer.\"); \\\n\t\t\tbreak; \\\n\t\t} \\\n\t\taddr += 4; \\\n\t\tpvaddr += 4;\\\n\t\tword = isBe? r_read_be32 (wordbuf): r_read_le32 (wordbuf);\n\tif (is64) {\n\t\taddr += 4;\n\t\tpvaddr += 4;\n\t}\n\tfor (n = 0; n < mh->ncmds && addr < length; n++) {\n\t\tREADWORD ();\n\t\tut32 lcType = word;\n\t\tconst char *pf_definition = cmd_to_pf_definition (lcType);\n\t\tif (pf_definition) {\n\t\t\tcb_printf (\"pf.%s @ 0x%08\"PFMT64x\"\\n\", pf_definition, pvaddr - 4);\n\t\t}\n\t\tcb_printf (\"0x%08\"PFMT64x\"  cmd %7d 0x%x %s\\n\",\n\t\t\tpvaddr - 4, n, lcType, cmd_to_string (lcType));\n\t\tREADWORD ();\n\t\tif (addr > length) {\n\t\t\tbreak;\n\t\t}\n\t\tint lcSize = word;\n\t\tword &= 0xFFFFFF;\n\t\tcb_printf (\"0x%08\"PFMT64x\"  cmdsize     %d\\n\", pvaddr - 4, word);\n\t\tif (lcSize < 1) {\n\t\t\teprintf (\"Invalid size for a load command\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tswitch (lcType) {\n\t\tcase LC_BUILD_VERSION: {\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  platform    %s\\n\",\n\t\t\t\tpvaddr, build_version_platform_to_string (r_buf_read_le32_at (buf, addr)));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  minos       %d.%d.%d\\n\",\n\t\t\t\tpvaddr + 4, r_buf_read_le16_at (buf, addr + 6), r_buf_read8_at (buf, addr + 5),\n\t\t\t\tr_buf_read8_at (buf, addr + 4));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  sdk         %d.%d.%d\\n\",\n\t\t\t\tpvaddr + 8, r_buf_read_le16_at (buf, addr + 10), r_buf_read8_at (buf, addr + 9),\n\t\t\t\tr_buf_read8_at (buf, addr + 8));\n\t\t\tut32 ntools = r_buf_read_le32_at (buf, addr + 12);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  ntools      %d\\n\",\n\t\t\t\tpvaddr + 12, ntools);\n\t\t\tut64 off = 16;\n\t\t\twhile (off < (lcSize - 8) && ntools--) {\n\t\t\t\tcb_printf (\"pf.mach0_build_version_tool @ 0x%08\"PFMT64x\"\\n\", pvaddr + off);\n\t\t\t\tcb_printf (\"0x%08\"PFMT64x\"  tool        %s\\n\",\n\t\t\t\t\tpvaddr + off, build_version_tool_to_string (r_buf_read_le32_at (buf, addr + off)));\n\t\t\t\toff += 4;\n\t\t\t\tif (off >= (lcSize - 8)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcb_printf (\"0x%08\"PFMT64x\"  version     %d.%d.%d\\n\",\n\t\t\t\t\tpvaddr + off, r_buf_read_le16_at (buf, addr + off + 2), r_buf_read8_at (buf, addr + off + 1),\n\t\t\t\t\tr_buf_read8_at (buf, addr + off));\n\t\t\t\toff += 4;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LC_MAIN:\n\t\t\t{\n\t\t\t\tut8 data[64] = {0};\n\t\t\t\tr_buf_read_at (buf, addr, data, sizeof (data));\n#if R_BIN_MACH064\n\t\t\t\tut64 ep = r_read_ble64 (&data, false); \/\/  bin->big_endian);\n\t\t\t\tcb_printf (\"0x%08\"PFMT64x\"  entry0      0x%\" PFMT64x \"\\n\", pvaddr, ep);\n\t\t\t\tut64 ss = r_read_ble64 (&data[8], false); \/\/  bin->big_endian);\n\t\t\t\tcb_printf (\"0x%08\"PFMT64x\"  stacksize   0x%\" PFMT64x \"\\n\", pvaddr +  8, ss);\n#else\n\t\t\t\tut32 ep = r_read_ble32 (&data, false); \/\/  bin->big_endian);\n\t\t\t\tcb_printf (\"0x%08\"PFMT32x\"  entry0      0x%\" PFMT32x \"\\n\", (ut32)pvaddr, ep);\n\t\t\t\tut32 ss = r_read_ble32 (&data[4], false); \/\/  bin->big_endian);\n\t\t\t\tcb_printf (\"0x%08\"PFMT32x\"  stacksize   0x%\" PFMT32x \"\\n\", (ut32)pvaddr +  4, ss);\n#endif\n\t\t\t}\n\t\t\tbreak;\n\t\tcase LC_SYMTAB:\n#if 0\n\t\t\t{\n\t\t\tchar *id = r_buf_get_string (buf, addr + 20);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  id         0x%x\\n\", addr + 20, r_str_get (id));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  symooff    0x%x\\n\", addr + 20, r_str_get (id));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  nsyms      %d\\n\", addr + 20, r_str_get (id));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  stroff     0x%x\\n\", addr + 20, r_str_get (id));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  strsize    0x%x\\n\", addr + 20, r_str_get (id));\n\t\t\tfree (id);\n\t\t\t}\n#endif\n\t\t\tbreak;\n\t\tcase LC_ID_DYLIB: { \/\/ install_name_tool\n\t\t\tut32 str_off = r_buf_read_ble32_at (buf, addr, isBe);\n\t\t\tchar *id = r_buf_get_string (buf, addr + str_off - 8);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  current     %d.%d.%d\\n\",\n\t\t\t\tpvaddr + 8, r_buf_read_le16_at (buf, addr + 10), r_buf_read8_at (buf, addr + 9),\n\t\t\t\tr_buf_read8_at (buf, addr + 8));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  compat      %d.%d.%d\\n\",\n\t\t\t\tpvaddr + 12, r_buf_read_le16_at (buf, addr + 14), r_buf_read8_at (buf, addr + 13),\n\t\t\t\tr_buf_read8_at (buf, addr + 12));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  id          %s\\n\",\n\t\t\t\tpvaddr + str_off - 8, r_str_get (id));\n\t\t\tif (id) {\n\t\t\t\tfree (id);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LC_UUID:\n\t\t\t{\n\t\t\t\tut8 i, uuid[16];\n\t\t\t\tr_buf_read_at (buf, addr, uuid, sizeof (uuid));\n\t\t\t\tcb_printf (\"0x%08\"PFMT64x\"  uuid        \", pvaddr);\n\t\t\t\tfor (i = 0; i < sizeof (uuid); i++) {\n\t\t\t\t\tcb_printf (\"%02x\", uuid[i]);\n\t\t\t\t}\n\t\t\t\tcb_printf (\"\\n\");\n\t\t\t}\n\t\t\tbreak;\n\t\tcase LC_SEGMENT:\n\t\tcase LC_SEGMENT_64:\n\t\t\t{\n\t\t\t\tut8 name[17] = {0};\n\t\t\t\tr_buf_read_at (buf, addr, name, sizeof (name) - 1);\n\t\t\t\tcb_printf (\"0x%08\"PFMT64x\"  name        %s\\n\", pvaddr, name);\n\t\t\t\tut32 nsects = r_buf_read_le32_at (buf, addr - 8 + (is64 ? 64 : 48));\n\t\t\t\tut64 off = is64 ? 72 : 56;\n\t\t\t\twhile (off < lcSize && nsects--) {\n\t\t\t\t\tif (is64) {\n\t\t\t\t\t\tcb_printf (\"pf.mach0_section64 @ 0x%08\"PFMT64x\"\\n\", pvaddr - 8 + off);\n\t\t\t\t\t\toff += 80;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcb_printf (\"pf.mach0_section @ 0x%08\"PFMT64x\"\\n\", pvaddr - 8 + off);\n\t\t\t\t\t\toff += 68;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase LC_LOAD_DYLIB:\n\t\tcase LC_LOAD_WEAK_DYLIB: {\n\t\t\tut32 str_off = r_buf_read_ble32_at (buf, addr, isBe);\n\t\t\tchar *load_dylib = r_buf_get_string (buf, addr + str_off - 8);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  current     %d.%d.%d\\n\",\n\t\t\t\tpvaddr + 8, r_buf_read_le16_at (buf, addr + 10), r_buf_read8_at (buf, addr + 9),\n\t\t\t\tr_buf_read8_at (buf, addr + 8));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  compat      %d.%d.%d\\n\",\n\t\t\t\tpvaddr + 12, r_buf_read_le16_at (buf, addr + 14), r_buf_read8_at (buf, addr + 13),\n\t\t\t\tr_buf_read8_at (buf, addr + 12));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  load_dylib  %s\\n\",\n\t\t\t\tpvaddr + str_off - 8, r_str_get (load_dylib));\n\t\t\tif (load_dylib) {\n\t\t\t\tfree (load_dylib);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LC_RPATH: {\n\t\t\tchar *rpath = r_buf_get_string (buf, addr + 4);\n\t\t\tcb_printf (\"0x%08\" PFMT64x \"  rpath       %s\\n\",\n\t\t\t\tpvaddr + 4, r_str_get (rpath));\n\t\t\tif (rpath) {\n\t\t\t\tfree (rpath);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LC_ENCRYPTION_INFO:\n\t\tcase LC_ENCRYPTION_INFO_64: {\n\t\t\tut32 word = r_buf_read_le32_at (buf, addr);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  cryptoff   0x%08x\\n\", pvaddr, word);\n\t\t\tword = r_buf_read_le32_at (buf, addr + 4);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  cryptsize  %d\\n\", pvaddr + 4, word);\n\t\t\tword = r_buf_read_le32_at (buf, addr + 8);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  cryptid    %d\\n\", pvaddr + 8, word);\n\t\t\tbreak;\n\t\t}\n\t\tcase LC_CODE_SIGNATURE: {\n\t\t\tut32 words[2];\n\t\t\tr_buf_read_at (buf, addr, (ut8 *)words, sizeof (words));\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  dataoff     0x%08x\\n\", pvaddr, words[0]);\n\t\t\tcb_printf (\"0x%08\"PFMT64x\"  datasize    %d\\n\", pvaddr + 4, words[1]);\n\t\t\tcb_printf (\"# wtf mach0.sign %d @ 0x%x\\n\", words[1], words[0]);\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t\taddr += word - 8;\n\t\tpvaddr += word - 8;\n\t}\n\tfree (mh);\n}","target":0,"code_token_length":3277,"total_token_length":3513,"max_tokens_setting":4096}
+{"idx":261244,"func":"static int SN_Client_HandlePacket(MqttClient* client, SN_MsgType packet_type,\n    void* packet_obj, int timeout)\n{\n    int rc = MQTT_CODE_SUCCESS;\n    word16 packet_id = 0;\n\n    (void)timeout;\n\n    switch ((int)packet_type)\n    {\n        case SN_MSG_TYPE_GWINFO:\n        {\n            SN_GwInfo info, *p_info = &info;\n            if (packet_obj) {\n                p_info = (SN_GwInfo*)packet_obj;\n            }\n            else {\n                XMEMSET(p_info, 0, sizeof(SN_GwInfo));\n            }\n\n            rc = SN_Decode_GWInfo(client->rx_buf, client->packet.buf_len,\n                    p_info);\n            if (rc <= 0) {\n                return rc;\n            }\n            break;\n        }\n        case SN_MSG_TYPE_CONNACK:\n        {\n            \/* Decode connect ack *\/\n            SN_ConnectAck connect_ack, *p_connect_ack = &connect_ack;\n            if (packet_obj) {\n                p_connect_ack = (SN_ConnectAck*)packet_obj;\n            }\n            else {\n                XMEMSET(p_connect_ack, 0, sizeof(SN_ConnectAck));\n            }\n            p_connect_ack->return_code =\n                    client->rx_buf[client->packet.buf_len-1];\n\n            break;\n        }\n        case SN_MSG_TYPE_WILLTOPICREQ:\n        {\n            rc = SN_Decode_WillTopicReq(client->rx_buf, client->packet.buf_len);\n            break;\n        }\n        case SN_MSG_TYPE_WILLMSGREQ:\n        {\n            rc = SN_Decode_WillMsgReq(client->rx_buf, client->packet.buf_len);\n            break;\n        }\n        case SN_MSG_TYPE_REGISTER:\n        {\n            \/* Decode register *\/\n            SN_Register reg_s;\n            int len;\n\n            XMEMSET(®_s, 0, sizeof(SN_Register));\n\n            rc = SN_Decode_Register(client->rx_buf, client->packet.buf_len,\n                    ®_s);\n\n            if (rc > 0) {\n                \/* Initialize the regack *\/\n                reg_s.regack.packet_id = reg_s.packet_id;\n                reg_s.regack.topicId = reg_s.topicId;\n                reg_s.regack.return_code = SN_RC_NOTSUPPORTED;\n\n                \/* Call the register callback to allow app to\n                   handle new topic ID assignment. *\/\n                if (client->reg_cb != NULL) {\n                     rc = client->reg_cb(reg_s.topicId,\n                            reg_s.topicName, client->reg_ctx);\n                     \/* Set the regack return code *\/\n                     reg_s.regack.return_code = (rc >= 0) ? SN_RC_ACCEPTED :\n                             SN_RC_INVTOPICNAME;\n                }\n\n            #ifdef WOLFMQTT_MULTITHREAD\n                \/* Lock send socket mutex *\/\n                rc = wm_SemLock(&client->lockSend);\n                if (rc != 0) {\n                    return rc;\n                }\n            #endif\n\n                \/* Encode the register acknowledgment *\/\n                rc = SN_Encode_RegAck(client->tx_buf, client->tx_buf_len,\n                        ®_s.regack);\n            #ifdef WOLFMQTT_DEBUG_CLIENT\n                PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d\",\n                    rc, SN_Packet_TypeDesc(SN_MSG_TYPE_REGACK),\n                    SN_MSG_TYPE_REGACK, reg_s.packet_id);\n            #endif\n                if (rc <= 0) {\n                #ifdef WOLFMQTT_MULTITHREAD\n                    wm_SemUnlock(&client->lockSend);\n                #endif\n                    return rc;\n                }\n                len = rc;\n\n                \/* Send regack packet *\/\n                rc = MqttPacket_Write(client, client->tx_buf, len);\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n                if (rc != len) { return rc; }\n            }\n\n            break;\n        }\n        case SN_MSG_TYPE_REGACK:\n        {\n            \/* Decode register ack *\/\n            SN_RegAck regack_s, *p_regack = ®ack_s;\n            if (packet_obj) {\n                p_regack = (SN_RegAck*)packet_obj;\n            }\n            else {\n                XMEMSET(p_regack, 0, sizeof(SN_RegAck));\n            }\n\n            rc = SN_Decode_RegAck(client->rx_buf, client->packet.buf_len,\n                    p_regack);\n            if (rc > 0) {\n                packet_id = p_regack->packet_id;\n            }\n\n            break;\n        }\n        case SN_MSG_TYPE_PUBLISH:\n        {\n            SN_Publish pub, *p_pub = &pub;\n            if (packet_obj) {\n                p_pub = (SN_Publish*)packet_obj;\n            }\n            else {\n                XMEMSET(p_pub, 0, sizeof(SN_Publish));\n            }\n\n            \/* Decode publish message *\/\n            rc = SN_Decode_Publish(client->rx_buf, client->packet.buf_len,\n                   p_pub);\n            if (rc <= 0) {\n                return rc;\n            }\n\n            \/* Issue callback for new message *\/\n            if (client->msg_cb) {\n                \/* if using the temp publish message buffer,\n                   then populate message context with client context *\/\n                if (&client->msgSN.publish == p_pub)\n                    p_pub->ctx = client->ctx;\n                rc = client->msg_cb(client, (MqttMessage*)p_pub, 1, 1);\n                if (rc != MQTT_CODE_SUCCESS) {\n                    return rc;\n                };\n            }\n\n            \/* Handle Qos *\/\n            if (p_pub->qos > MQTT_QOS_0) {\n                SN_MsgType type;\n\n                packet_id = p_pub->packet_id;\n\n                \/* Determine packet type to write *\/\n                type = (p_pub->qos == MQTT_QOS_1) ?\n                        SN_MSG_TYPE_PUBACK :\n                        SN_MSG_TYPE_PUBREC;\n                p_pub->resp.packet_id = packet_id;\n\n            #ifdef WOLFMQTT_MULTITHREAD\n                \/* Lock send socket mutex *\/\n                rc = wm_SemLock(&client->lockSend);\n                if (rc != 0) {\n                    return rc;\n                }\n            #endif\n\n                \/* Encode publish response *\/\n                rc = SN_Encode_PublishResp(client->tx_buf,\n                                    client->tx_buf_len, type, &p_pub->resp);\n            #ifdef WOLFMQTT_DEBUG_CLIENT\n                PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d,\"\n                        \" QoS %d\",\n                    rc, SN_Packet_TypeDesc(type), type, packet_id,\n                    p_pub->qos);\n            #endif\n                if (rc <= 0) {\n                #ifdef WOLFMQTT_MULTITHREAD\n                    wm_SemUnlock(&client->lockSend);\n                #endif\n                    return rc;\n                }\n                client->packet.buf_len = rc;\n\n                \/* Send packet *\/\n                rc = MqttPacket_Write(client, client->tx_buf,\n                                                    client->packet.buf_len);\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n            }\n            break;\n        }\n        case SN_MSG_TYPE_PUBACK:\n        case SN_MSG_TYPE_PUBCOMP:\n        case SN_MSG_TYPE_PUBREC:\n        case SN_MSG_TYPE_PUBREL:\n        {\n            SN_PublishResp publish_resp;\n            XMEMSET(&publish_resp, 0, sizeof(SN_PublishResp));\n\n            \/* Decode publish response message *\/\n            rc = SN_Decode_PublishResp(client->rx_buf, client->packet.buf_len,\n                packet_type, &publish_resp);\n            if (rc <= 0) {\n                return rc;\n            }\n            packet_id = publish_resp.packet_id;\n\n            \/* If Qos then send response *\/\n            if (packet_type == SN_MSG_TYPE_PUBREC ||\n                packet_type == SN_MSG_TYPE_PUBREL) {\n\n                byte resp_type = (packet_type == SN_MSG_TYPE_PUBREC) ?\n                        SN_MSG_TYPE_PUBREL : SN_MSG_TYPE_PUBCOMP;\n\n            #ifdef WOLFMQTT_MULTITHREAD\n                \/* Lock send socket mutex *\/\n                rc = wm_SemLock(&client->lockSend);\n                if (rc != 0) {\n                    return rc;\n                }\n            #endif\n\n                \/* Encode publish response *\/\n                publish_resp.packet_id = packet_id;\n                rc = SN_Encode_PublishResp(client->tx_buf,\n                    client->tx_buf_len, resp_type, &publish_resp);\n            #ifdef WOLFMQTT_DEBUG_CLIENT\n                PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d\",\n                    rc, MqttPacket_TypeDesc(resp_type), resp_type, packet_id);\n            #endif\n                if (rc <= 0) {\n                #ifdef WOLFMQTT_MULTITHREAD\n                    wm_SemUnlock(&client->lockSend);\n                #endif\n                    return rc;\n                }\n                client->packet.buf_len = rc;\n\n                \/* Send packet *\/\n                rc = MqttPacket_Write(client, client->tx_buf,\n                        client->packet.buf_len);\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n            }\n            break;\n        }\n        case SN_MSG_TYPE_SUBACK:\n        {\n            \/* Decode subscribe ack *\/\n            SN_SubAck subscribe_ack, *p_subscribe_ack = &subscribe_ack;\n            if (packet_obj) {\n                p_subscribe_ack = (SN_SubAck*)packet_obj;\n            }\n            else {\n                XMEMSET(p_subscribe_ack, 0, sizeof(SN_SubAck));\n            }\n\n            rc = SN_Decode_SubscribeAck(client->rx_buf, client->packet.buf_len,\n                    p_subscribe_ack);\n            if (rc <= 0) {\n                return rc;\n            }\n            packet_id = p_subscribe_ack->packet_id;\n\n            break;\n        }\n        case SN_MSG_TYPE_UNSUBACK:\n        {\n            \/* Decode unsubscribe ack *\/\n            SN_UnsubscribeAck unsubscribe_ack,\n                              *p_unsubscribe_ack = &unsubscribe_ack;\n            if (packet_obj) {\n                p_unsubscribe_ack = (SN_UnsubscribeAck*)packet_obj;\n            }\n            else {\n                XMEMSET(p_unsubscribe_ack, 0, sizeof(SN_UnsubscribeAck));\n            }\n            rc = SN_Decode_UnsubscribeAck(client->rx_buf,\n                    client->packet.buf_len, p_unsubscribe_ack);\n            if (rc <= 0) {\n                return rc;\n            }\n            packet_id = p_unsubscribe_ack->packet_id;\n\n            break;\n        }\n        case SN_MSG_TYPE_PING_RESP:\n        {\n            \/* Decode ping *\/\n            rc = SN_Decode_Ping(client->rx_buf, client->packet.buf_len);\n            break;\n        }\n        case SN_MSG_TYPE_PING_REQ:\n        {\n            int len;\n\n            \/* Decode ping *\/\n            rc = SN_Decode_Ping(client->rx_buf, client->packet.buf_len);\n            if (rc <= 0) { return rc; }\n\n        #ifdef WOLFMQTT_MULTITHREAD\n            \/* Lock send socket mutex *\/\n            rc = wm_SemLock(&client->lockSend);\n            if (rc != 0) {\n                return rc;\n            }\n        #endif\n\n            \/* Encode the ping packet as a response *\/\n            rc = SN_Encode_Ping(client->tx_buf, client->tx_buf_len, NULL,\n                    SN_MSG_TYPE_PING_RESP);\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d)\",\n                rc, SN_Packet_TypeDesc(SN_MSG_TYPE_PING_RESP),\n                SN_MSG_TYPE_PING_RESP);\n        #endif\n            if (rc <= 0) {\n            #ifdef WOLFMQTT_MULTITHREAD\n                wm_SemUnlock(&client->lockSend);\n            #endif\n                return rc;\n            }\n            len = rc;\n\n            \/* Send ping resp packet *\/\n            rc = MqttPacket_Write(client, client->tx_buf, len);\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            if (rc != len) { return rc; }\n\n            break;\n        }\n        case SN_MSG_TYPE_WILLTOPICRESP:\n        {\n            \/* Decode Will Topic Response *\/\n            SN_WillTopicResp resp_s, *resp = &resp_s;\n            if (packet_obj) {\n                resp = (SN_WillTopicResp*)packet_obj;\n            }\n            else {\n                XMEMSET(resp, 0, sizeof(SN_WillTopicResp));\n            }\n            rc = SN_Decode_WillTopicResponse(client->rx_buf,\n                    client->packet.buf_len, &resp->return_code);\n            break;\n        }\n        case SN_MSG_TYPE_WILLMSGRESP:\n        {\n            \/* Decode Will Message Response *\/\n            SN_WillMsgResp resp_s, *resp = &resp_s;\n            if (packet_obj) {\n                resp = (SN_WillMsgResp*)packet_obj;\n            }\n            else {\n                XMEMSET(resp, 0, sizeof(SN_WillMsgResp));\n            }\n            rc = SN_Decode_WillMsgResponse(client->rx_buf,\n                    client->packet.buf_len, &resp->return_code);\n            break;\n        }\n        case SN_MSG_TYPE_DISCONNECT:\n        {\n            \/* Decode Disconnect *\/\n            rc = SN_Decode_Disconnect(client->rx_buf, client->packet.buf_len);\n            break;\n        }\n\n        default:\n        {\n            \/* Other types are server side only, ignore *\/\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"SN_Client_HandlePacket: Invalid client packet type %u!\",\n                packet_type);\n        #endif\n            break;\n        }\n    } \/* switch (packet_type) *\/\n\n    (void)packet_id;\n\n    return rc;\n}","target":0,"code_token_length":2951,"total_token_length":3187,"max_tokens_setting":4096}
+{"idx":242978,"func":"static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,\n                                    unsigned char *buf,\n                                    size_t len,\n                                    mbedtls_record *rec )\n{\n    int major_ver, minor_ver;\n\n    size_t const rec_hdr_type_offset    = 0;\n    size_t const rec_hdr_type_len       = 1;\n\n    size_t const rec_hdr_version_offset = rec_hdr_type_offset +\n                                          rec_hdr_type_len;\n    size_t const rec_hdr_version_len    = 2;\n\n    size_t const rec_hdr_ctr_len        = 8;\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    uint32_t     rec_epoch;\n    size_t const rec_hdr_ctr_offset     = rec_hdr_version_offset +\n                                          rec_hdr_version_len;\n\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)\n    size_t const rec_hdr_cid_offset     = rec_hdr_ctr_offset +\n                                          rec_hdr_ctr_len;\n    size_t       rec_hdr_cid_len        = 0;\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\n    size_t       rec_hdr_len_offset; \/* To be determined *\/\n    size_t const rec_hdr_len_len    = 2;\n\n    \/*\n     * Check minimum lengths for record header.\n     *\/\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        rec_hdr_len_offset = rec_hdr_ctr_offset + rec_hdr_ctr_len;\n    }\n    else\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n    {\n        rec_hdr_len_offset = rec_hdr_version_offset + rec_hdr_version_len;\n    }\n\n    if( len < rec_hdr_len_offset + rec_hdr_len_len )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"datagram of length %u too small to hold DTLS record header of length %u\",\n                 (unsigned) len,\n                 (unsigned)( rec_hdr_len_len + rec_hdr_len_len ) ) );\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n    }\n\n    \/*\n     * Parse and validate record content type\n     *\/\n\n    rec->type = buf[ rec_hdr_type_offset ];\n\n    \/* Check record content type *\/\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)\n    rec->cid_len = 0;\n\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&\n        ssl->conf->cid_len != 0                                &&\n        rec->type == MBEDTLS_SSL_MSG_CID )\n    {\n        \/* Shift pointers to account for record header including CID\n         * struct {\n         *   ContentType special_type = tls12_cid;\n         *   ProtocolVersion version;\n         *   uint16 epoch;\n         *   uint48 sequence_number;\n         *   opaque cid[cid_length]; \/\/ Additional field compared to\n         *                           \/\/ default DTLS record format\n         *   uint16 length;\n         *   opaque enc_content[DTLSCiphertext.length];\n         * } DTLSCiphertext;\n         *\/\n\n        \/* So far, we only support static CID lengths\n         * fixed in the configuration. *\/\n        rec_hdr_cid_len = ssl->conf->cid_len;\n        rec_hdr_len_offset += rec_hdr_cid_len;\n\n        if( len < rec_hdr_len_offset + rec_hdr_len_len )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"datagram of length %u too small to hold DTLS record header including CID, length %u\",\n                (unsigned) len,\n                (unsigned)( rec_hdr_len_offset + rec_hdr_len_len ) ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n\n        \/* configured CID len is guaranteed at most 255, see\n         * MBEDTLS_SSL_CID_OUT_LEN_MAX in check_config.h *\/\n        rec->cid_len = (uint8_t) rec_hdr_cid_len;\n        memcpy( rec->cid, buf + rec_hdr_cid_offset, rec_hdr_cid_len );\n    }\n    else\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n    {\n        if( ssl_check_record_type( rec->type ) )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"unknown record type %u\",\n                                        (unsigned) rec->type ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n    }\n\n    \/*\n     * Parse and validate record version\n     *\/\n    rec->ver[0] = buf[ rec_hdr_version_offset + 0 ];\n    rec->ver[1] = buf[ rec_hdr_version_offset + 1 ];\n    mbedtls_ssl_read_version( &major_ver, &minor_ver,\n                              ssl->conf->transport,\n                              &rec->ver[0] );\n\n    if( major_ver != ssl->major_ver )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"major version mismatch: got %u, expected %u\",\n                                    (unsigned) major_ver,\n                                    (unsigned) ssl->major_ver ) );\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n    }\n\n    if( minor_ver > ssl->conf->max_minor_ver )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"minor version mismatch: got %u, expected max %u\",\n                                    (unsigned) minor_ver,\n                                    (unsigned) ssl->conf->max_minor_ver ) );\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n    }\n    \/*\n     * Parse\/Copy record sequence number.\n     *\/\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        \/* Copy explicit record sequence number from input buffer. *\/\n        memcpy( &rec->ctr[0], buf + rec_hdr_ctr_offset,\n                rec_hdr_ctr_len );\n    }\n    else\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n    {\n        \/* Copy implicit record sequence number from SSL context structure. *\/\n        memcpy( &rec->ctr[0], ssl->in_ctr, rec_hdr_ctr_len );\n    }\n\n    \/*\n     * Parse record length.\n     *\/\n\n    rec->data_offset = rec_hdr_len_offset + rec_hdr_len_len;\n    rec->data_len    = ( (size_t) buf[ rec_hdr_len_offset + 0 ] << 8 ) |\n                       ( (size_t) buf[ rec_hdr_len_offset + 1 ] << 0 );\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"input record header\", buf, rec->data_offset );\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"input record: msgtype = %u, \"\n                                \"version = [%d:%d], msglen = %\" MBEDTLS_PRINTF_SIZET,\n                                rec->type,\n                                major_ver, minor_ver, rec->data_len ) );\n\n    rec->buf     = buf;\n    rec->buf_len = rec->data_offset + rec->data_len;\n\n    if( rec->data_len == 0 )\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n\n    \/*\n     * DTLS-related tests.\n     * Check epoch before checking length constraint because\n     * the latter varies with the epoch. E.g., if a ChangeCipherSpec\n     * message gets duplicated before the corresponding Finished message,\n     * the second ChangeCipherSpec should be discarded because it belongs\n     * to an old epoch, but not because its length is shorter than\n     * the minimum record length for packets using the new record transform.\n     * Note that these two kinds of failures are handled differently,\n     * as an unexpected record is silently skipped but an invalid\n     * record leads to the entire datagram being dropped.\n     *\/\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n        rec_epoch = ( rec->ctr[0] << 8 ) | rec->ctr[1];\n\n        \/* Check that the datagram is large enough to contain a record\n         * of the advertised length. *\/\n        if( len < rec->data_offset + rec->data_len )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"Datagram of length %u too small to contain record of advertised length %u.\",\n                             (unsigned) len,\n                             (unsigned)( rec->data_offset + rec->data_len ) ) );\n            return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n        }\n\n        \/* Records from other, non-matching epochs are silently discarded.\n         * (The case of same-port Client reconnects must be considered in\n         *  the caller). *\/\n        if( rec_epoch != ssl->in_epoch )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"record from another epoch: \"\n                                        \"expected %u, received %lu\",\n                                        ssl->in_epoch, (unsigned long) rec_epoch ) );\n\n            \/* Records from the next epoch are considered for buffering\n             * (concretely: early Finished messages). *\/\n            if( rec_epoch == (unsigned) ssl->in_epoch + 1 )\n            {\n                MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Consider record for buffering\" ) );\n                return( MBEDTLS_ERR_SSL_EARLY_MESSAGE );\n            }\n\n            return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD );\n        }\n#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)\n        \/* For records from the correct epoch, check whether their\n         * sequence number has been seen before. *\/\n        else if( mbedtls_ssl_dtls_record_replay_check( (mbedtls_ssl_context *) ssl,\n            &rec->ctr[0] ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"replayed record\" ) );\n            return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD );\n        }\n#endif\n    }\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\n    return( 0 );\n}","target":0,"code_token_length":2058,"total_token_length":2294,"max_tokens_setting":4096}
+{"idx":522329,"func":"int64_t GmfOpenMesh(const char *FilNam, int mod, ...)\n{\n   int      KwdCod, res, *PtrVer, *PtrDim, err;\n   int64_t  MshIdx;\n   char     str[ GmfStrSiz ];\n   va_list  VarArg;\n   GmfMshSct *msh;\n\n   \/*---------------------*\/\n   \/* MESH STRUCTURE INIT *\/\n   \/*---------------------*\/\n\n   if(!(msh = calloc(1, sizeof(GmfMshSct))))\n      return(0);\n\n   MshIdx = (int64_t)msh;\n\n   \/\/ Save the current stack environment for longjmp\n   if( (err = setjmp(msh->err)) != 0)\n   {\n#ifdef GMFDEBUG\n      printf(\"libMeshb : mesh %p : error %d\\n\", msh, err);\n#endif\n      if(msh->hdl != NULL)\n         fclose(msh->hdl);\n\n      if(msh->FilDes != 0)\n#ifdef GMF_WINDOWS\n         _close(msh->FilDes);\n#else\n         close(msh->FilDes);\n#endif\n\n      free(msh);\n      return(0);\n   }\n\n   \/\/ Copy the FilNam into the structure\n   if(strlen(FilNam) + 7 >= GmfStrSiz)\n      longjmp(msh->err, -4);\n\n   strcpy(msh->FilNam, FilNam);\n\n   \/\/ Store the opening mod (read or write) and guess\n   \/\/ the filetype (binary or ascii) depending on the extension\n   msh->mod = mod;\n   msh->buf = (void *)msh->DblBuf;\n   msh->FltBuf = (void *)msh->DblBuf;\n   msh->IntBuf = (void *)msh->DblBuf;\n\n   if(strstr(msh->FilNam, \".meshb\"))\n      msh->typ |= (Bin | MshFil);\n   else if(strstr(msh->FilNam, \".mesh\"))\n      msh->typ |= (Asc | MshFil);\n   else if(strstr(msh->FilNam, \".solb\"))\n      msh->typ |= (Bin | SolFil);\n   else if(strstr(msh->FilNam, \".sol\"))\n      msh->typ |= (Asc | SolFil);\n   else\n      longjmp(msh->err, -5);\n\n   \/\/ Open the file in the required mod and initialize the mesh structure\n   if(msh->mod == GmfRead)\n   {\n\n      \/*-----------------------*\/\n      \/* OPEN FILE FOR READING *\/\n      \/*-----------------------*\/\n\n      va_start(VarArg, mod);\n      PtrVer = va_arg(VarArg, int *);\n      PtrDim = va_arg(VarArg, int *);\n      va_end(VarArg);\n\n      \/\/ Read the endian coding tag, the mesh version\n      \/\/ and the mesh dimension (mandatory kwd)\n      if(msh->typ & Bin)\n      {\n         \/\/ Create the name string and open the file\n#ifdef WITH_GMF_AIO\n         \/\/ [Bruno] added binary flag (necessary under Windows)\n         msh->FilDes = open(msh->FilNam, OPEN_READ_FLAGS, OPEN_READ_MODE);\n\n         if(msh->FilDes <= 0)\n            longjmp(msh->err, -6);\n\n         \/\/ Read the endian coding tag\n         if(read(msh->FilDes, &msh->cod, WrdSiz) != WrdSiz)\n            longjmp(msh->err, -7);\n#else\n         \/\/ [Bruno] added binary flag (necessary under Windows)\n         if(!(msh->hdl = fopen(msh->FilNam, \"rb\")))\n            longjmp(msh->err, -8);\n\n         \/\/ Read the endian coding tag\n         safe_fread(&msh->cod, WrdSiz, 1, msh->hdl, msh->err);\n#endif\n\n         \/\/ Read the mesh version and the mesh dimension (mandatory kwd)\n         if( (msh->cod != 1) && (msh->cod != 16777216) )\n            longjmp(msh->err, -9);\n\n         ScaWrd(msh, (unsigned char *)&msh->ver);\n\n         if( (msh->ver < 1) || (msh->ver > 4) )\n            longjmp(msh->err, -10);\n\n         if( (msh->ver >= 3) && (sizeof(int64_t) != 8) )\n            longjmp(msh->err, -11);\n\n         ScaWrd(msh, (unsigned char *)&KwdCod);\n\n         if(KwdCod != GmfDimension)\n            longjmp(msh->err, -12);\n\n         GetPos(msh);\n         ScaWrd(msh, (unsigned char *)&msh->dim);\n      }\n      else\n      {\n         \/\/ Create the name string and open the file\n         if(!(msh->hdl = fopen(msh->FilNam, \"rb\")))\n            longjmp(msh->err, -13);\n\n         do\n         {\n            res = fscanf(msh->hdl, \"%100s\", str);\n         }while( (res != EOF) && strcmp(str, \"MeshVersionFormatted\") );\n\n         if(res == EOF)\n            longjmp(msh->err, -14);\n\n         safe_fscanf(msh->hdl, \"%d\", &msh->ver, msh->err);\n\n         if( (msh->ver < 1) || (msh->ver > 4) )\n            longjmp(msh->err, -15);\n\n         do\n         {\n            res = fscanf(msh->hdl, \"%100s\", str);\n         }while( (res != EOF) && strcmp(str, \"Dimension\") );\n\n         if(res == EOF)\n            longjmp(msh->err, -16);\n\n         safe_fscanf(msh->hdl, \"%d\", &msh->dim, msh->err);\n      }\n\n      if( (msh->dim != 2) && (msh->dim != 3) )\n         longjmp(msh->err, -17);\n\n      (*PtrVer) = msh->ver;\n      (*PtrDim) = msh->dim;\n\n      \/\/ Set default real numbers size\n      if(msh->ver == 1)\n         msh->FltSiz = 32;\n      else\n         msh->FltSiz = 64;\n\n      \/*------------*\/\n      \/* KW READING *\/\n      \/*------------*\/\n\n      \/\/ Read the list of kw present in the file\n      if(!ScaKwdTab(msh))\n         return(0);\n\n      return(MshIdx);\n   }\n   else if(msh->mod == GmfWrite)\n   {\n\n      \/*-----------------------*\/\n      \/* OPEN FILE FOR WRITING *\/\n      \/*-----------------------*\/\n\n      msh->cod = 1;\n\n      \/\/ Check if the user provided a valid version number and dimension\n      va_start(VarArg, mod);\n      msh->ver = va_arg(VarArg, int);\n      msh->dim = va_arg(VarArg, int);\n      va_end(VarArg);\n\n      if( (msh->ver < 1) || (msh->ver > 4) )\n         longjmp(msh->err, -18);\n\n      if( (msh->ver >= 3) && (sizeof(int64_t) != 8) )\n         longjmp(msh->err, -19);\n\n      if( (msh->dim != 2) && (msh->dim != 3) )\n         longjmp(msh->err, -20);\n\n      \/\/ Set default real numbers size\n      if(msh->ver == 1)\n         msh->FltSiz = 32;\n      else\n         msh->FltSiz = 64;\n\n      \/\/ Create the mesh file\n      if(msh->typ & Bin) \n      {\n         \/* \n          * [Bruno] replaced previous call to creat():\n          * with a call to open(), because Windows needs the\n          * binary flag to be specified.\n          *\/\n#ifdef WITH_GMF_AIO\n         msh->FilDes = open(msh->FilNam, OPEN_WRITE_FLAGS, OPEN_WRITE_MODE);\n\n         if(msh->FilDes <= 0)\n            longjmp(msh->err, -21);\n#else\n         if(!(msh->hdl = fopen(msh->FilNam, \"wb\")))\n            longjmp(msh->err, -22);\n#endif\n      }\n      else if(!(msh->hdl = fopen(msh->FilNam, \"wb\")))\n         longjmp(msh->err, -23);\n\n\n      \/*------------*\/\n      \/* KW WRITING *\/\n      \/*------------*\/\n\n      \/\/ Write the mesh version and dimension\n      if(msh->typ & Asc)\n      {\n         fprintf(msh->hdl, \"%s %d\\n\\n\",\n               GmfKwdFmt[ GmfVersionFormatted ][0], msh->ver);\n         fprintf(msh->hdl, \"%s %d\\n\",\n               GmfKwdFmt[ GmfDimension ][0], msh->dim);\n      }\n      else\n      {\n         RecWrd(msh, (unsigned char *)&msh->cod);\n         RecWrd(msh, (unsigned char *)&msh->ver);\n         GmfSetKwd(MshIdx, GmfDimension, 0);\n         RecWrd(msh, (unsigned char *)&msh->dim);\n      }\n\n      return(MshIdx);\n   }\n   else\n   {\n      free(msh);\n      return(0);\n   }\n}","target":0,"code_token_length":2071,"total_token_length":2307,"max_tokens_setting":4096}
+{"idx":224489,"func":"static GF_Err txtin_setup_ttxt(GF_Filter *filter, GF_TXTIn *ctx)\n{\n\tGF_Err e;\n\tu32 j, k, ID, OCR_ES_ID;\n\tu64 file_size;\n\tGF_XMLNode *root, *ext;\n\tGF_PropertyValue *dcd;\n\n\tctx->parser = gf_xml_dom_new();\n\te = gf_xml_dom_parse(ctx->parser, ctx->file_name, ttxt_dom_progress, ctx);\n\tif (e) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Error parsing TTXT file: Line %d - %s\\n\", gf_xml_dom_get_line(ctx->parser), gf_xml_dom_get_error(ctx->parser)));\n\t\treturn e;\n\t}\n\troot = gf_xml_dom_get_root(ctx->parser);\n\n\tif (strcmp(root->name, \"TextStream\")) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Invalid Timed Text file - expecting \\\"TextStream\\\" got %s\", root->name));\n\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t}\n\tfile_size = ctx->end;\n\tctx->end = 0;\n\n\t\/*setup track in 3GP format directly (no ES desc)*\/\n\tif (!ctx->timescale) ctx->timescale = 1000;\n\tOCR_ES_ID = ID = 0;\n\n\tif (!ctx->opid) ctx->opid = gf_filter_pid_new(filter);\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_TEXT) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, &PROP_UINT(GF_CODECID_TX3G) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(ctx->timescale) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DOWN_SIZE, &PROP_LONGUINT(file_size) );\n\n\tif (!ID) ID = 1;\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ID, &PROP_UINT(ID) );\n\tif (OCR_ES_ID) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CLOCK_ID, &PROP_UINT(OCR_ES_ID) );\n\n\tctx->nb_children = gf_list_count(root->content);\n\n\tctx->cur_child_idx = 0;\n\tfor (ctx->cur_child_idx=0; ctx->cur_child_idx < ctx->nb_children; ctx->cur_child_idx++) {\n\t\tGF_XMLNode *node = (GF_XMLNode*) gf_list_get(root->content, ctx->cur_child_idx);\n\n\t\tif (node->type) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!strcmp(node->name, \"TextStreamHeader\")) {\n\t\t\tGF_XMLNode *sdesc;\n\t\t\ts32 w, h, tx, ty, layer;\n\t\t\tu32 tref_id;\n\t\t\tGF_XMLAttribute *att;\n\t\t\tw = ctx->width;\n\t\t\th = ctx->height;\n\t\t\ttx = ctx->txtx;\n\t\t\tty = ctx->txty;\n\t\t\tlayer = ctx->zorder;\n\t\t\ttref_id = 0;\n\n\t\t\tj=0;\n\t\t\twhile ( (att=(GF_XMLAttribute *)gf_list_enum(node->attributes, &j))) {\n\t\t\t\tif (!strcmp(att->name, \"width\")) w = atoi(att->value);\n\t\t\t\telse if (!strcmp(att->name, \"height\")) h = atoi(att->value);\n\t\t\t\telse if (!strcmp(att->name, \"layer\")) layer = atoi(att->value);\n\t\t\t\telse if (!strcmp(att->name, \"translation_x\")) tx = atoi(att->value);\n\t\t\t\telse if (!strcmp(att->name, \"translation_y\")) ty = atoi(att->value);\n\t\t\t\telse if (!strcmp(att->name, \"trefID\")) tref_id = atoi(att->value);\n\t\t\t}\n\n\t\t\tif (tref_id) {\n\t\t\t\tgf_filter_pid_set_property_str(ctx->opid, \"tref:chap\", &PROP_UINT(tref_id) );\n\t\t\t}\n\n\t\t\tif (w) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH, &PROP_UINT(w) );\n\t\t\tif (h) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT, &PROP_UINT(h) );\n\t\t\tif (tx) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TRANS_X, &PROP_UINT(tx) );\n\t\t\tif (ty) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TRANS_X, &PROP_UINT(ty) );\n\t\t\tif (layer) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ZORDER, &PROP_SINT(ctx->zorder) );\n\t\t\tif (ctx->lang) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_LANGUAGE, &PROP_STRING( ctx->lang) );\n\n\t\t\tj=0;\n\t\t\twhile ( (sdesc=(GF_XMLNode*)gf_list_enum(node->content, &j))) {\n\t\t\t\tif (sdesc->type) continue;\n\n\t\t\t\tif (!strcmp(sdesc->name, \"TextSampleDescription\")) {\n\t\t\t\t\tGF_TextSampleDescriptor td;\n\t\t\t\t\tmemset(&td, 0, sizeof(GF_TextSampleDescriptor));\n\t\t\t\t\ttd.tag = GF_ODF_TEXT_CFG_TAG;\n\t\t\t\t\ttd.vert_justif = (s8) -1;\n\t\t\t\t\ttd.default_style.fontID = 1;\n\t\t\t\t\ttd.default_style.font_size = ctx->fontsize;\n\n\t\t\t\t\tk=0;\n\t\t\t\t\twhile ( (att=(GF_XMLAttribute *)gf_list_enum(sdesc->attributes, &k))) {\n\t\t\t\t\t\tif (!strcmp(att->name, \"horizontalJustification\")) {\n\t\t\t\t\t\t\tif (!stricmp(att->value, \"center\")) td.horiz_justif = 1;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"right\")) td.horiz_justif = (s8) -1;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"left\")) td.horiz_justif = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (!strcmp(att->name, \"verticalJustification\")) {\n\t\t\t\t\t\t\tif (!stricmp(att->value, \"center\")) td.vert_justif = 1;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"bottom\")) td.vert_justif = (s8) -1;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"top\")) td.vert_justif = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (!strcmp(att->name, \"backColor\")) td.back_color = ttxt_get_color(att->value);\n\t\t\t\t\t\telse if (!strcmp(att->name, \"verticalText\") && !stricmp(att->value, \"yes\") ) td.displayFlags |= GF_TXT_VERTICAL;\n\t\t\t\t\t\telse if (!strcmp(att->name, \"fillTextRegion\") && !stricmp(att->value, \"yes\") ) td.displayFlags |= GF_TXT_FILL_REGION;\n\t\t\t\t\t\telse if (!strcmp(att->name, \"continuousKaraoke\") && !stricmp(att->value, \"yes\") ) td.displayFlags |= GF_TXT_KARAOKE;\n\t\t\t\t\t\telse if (!strcmp(att->name, \"scroll\")) {\n\t\t\t\t\t\t\tif (!stricmp(att->value, \"inout\")) td.displayFlags |= GF_TXT_SCROLL_IN | GF_TXT_SCROLL_OUT;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"in\")) td.displayFlags |= GF_TXT_SCROLL_IN;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"out\")) td.displayFlags |= GF_TXT_SCROLL_OUT;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (!strcmp(att->name, \"scrollMode\")) {\n\t\t\t\t\t\t\tu32 scroll_mode = GF_TXT_SCROLL_CREDITS;\n\t\t\t\t\t\t\tif (!stricmp(att->value, \"Credits\")) scroll_mode = GF_TXT_SCROLL_CREDITS;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"Marquee\")) scroll_mode = GF_TXT_SCROLL_MARQUEE;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"Right\")) scroll_mode = GF_TXT_SCROLL_RIGHT;\n\t\t\t\t\t\t\telse if (!stricmp(att->value, \"Down\")) scroll_mode = GF_TXT_SCROLL_DOWN;\n\t\t\t\t\t\t\ttd.displayFlags |= ((scroll_mode<<7) & GF_TXT_SCROLL_DIRECTION);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tk=0;\n\t\t\t\t\twhile ( (ext=(GF_XMLNode*)gf_list_enum(sdesc->content, &k))) {\n\t\t\t\t\t\tif (ext->type) continue;\n\t\t\t\t\t\tif (!strcmp(ext->name, \"TextBox\")) ttxt_parse_text_box(ext, &td.default_pos);\n\t\t\t\t\t\telse if (!strcmp(ext->name, \"Style\")) ttxt_parse_text_style(ctx, ext, &td.default_style);\n\t\t\t\t\t\telse if (!strcmp(ext->name, \"FontTable\")) {\n\t\t\t\t\t\t\tGF_XMLNode *ftable;\n\t\t\t\t\t\t\tu32 z=0;\n\t\t\t\t\t\t\twhile ( (ftable=(GF_XMLNode*)gf_list_enum(ext->content, &z))) {\n\t\t\t\t\t\t\t\tu32 m;\n\t\t\t\t\t\t\t\tif (ftable->type || strcmp(ftable->name, \"FontTableEntry\")) continue;\n\t\t\t\t\t\t\t\ttd.font_count += 1;\n\t\t\t\t\t\t\t\ttd.fonts = (GF_FontRecord*)gf_realloc(td.fonts, sizeof(GF_FontRecord)*td.font_count);\n\t\t\t\t\t\t\t\tm=0;\n\t\t\t\t\t\t\t\twhile ( (att=(GF_XMLAttribute *)gf_list_enum(ftable->attributes, &m))) {\n\t\t\t\t\t\t\t\t\tif (!stricmp(att->name, \"fontID\")) td.fonts[td.font_count-1].fontID = atoi(att->value);\n\t\t\t\t\t\t\t\t\telse if (!stricmp(att->name, \"fontName\")) td.fonts[td.font_count-1].fontName = gf_strdup(att->value);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx->nodefbox) {\n\t\t\t\t\t\ttd.default_pos.top = td.default_pos.left = td.default_pos.right = td.default_pos.bottom = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ((td.default_pos.bottom==td.default_pos.top) || (td.default_pos.right==td.default_pos.left)) {\n\t\t\t\t\t\t\ttd.default_pos.top = td.default_pos.left = 0;\n\t\t\t\t\t\t\ttd.default_pos.right = w;\n\t\t\t\t\t\t\ttd.default_pos.bottom = h;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!td.fonts) {\n\t\t\t\t\t\ttd.font_count = 1;\n\t\t\t\t\t\ttd.fonts = (GF_FontRecord*)gf_malloc(sizeof(GF_FontRecord));\n\t\t\t\t\t\ttd.fonts[0].fontID = 1;\n\t\t\t\t\t\ttd.fonts[0].fontName = gf_strdup(\"Serif\");\n\t\t\t\t\t}\n\t\t\t\t\tGF_SAFEALLOC(dcd, GF_PropertyValue);\n\t\t\t\t\tif (dcd) {\n\t\t\t\t\t\tdcd->type = GF_PROP_DATA;\n\n\t\t\t\t\t\tgf_odf_tx3g_write(&td, &dcd->value.data.ptr, &dcd->value.data.size);\n\t\t\t\t\t\tif (!ctx->text_descs) ctx->text_descs = gf_list_new();\n\t\t\t\t\t\tgf_list_add(ctx->text_descs, dcd);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (k=0; k<td.font_count; k++) gf_free(td.fonts[k].fontName);\n\t\t\t\t\tgf_free(td.fonts);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!ctx->text_descs) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Invalid Timed Text file - text stream header not found or empty\\n\"));\n\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t}\n\tdcd = gf_list_get(ctx->text_descs, 0);\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, dcd);\n\tctx->last_desc_idx = 1;\n\n\tctx->first_samp = GF_TRUE;\n\tctx->last_sample_empty = GF_FALSE;\n\tctx->last_sample_duration = 0;\n\n\ttxtin_probe_duration(ctx);\n\n\treturn GF_OK;\n}","target":0,"code_token_length":2449,"total_token_length":2685,"max_tokens_setting":4096}
+{"idx":259531,"func":"CURLUcode curl_url_set(CURLU *u, CURLUPart what,\n                       const char *part, unsigned int flags)\n{\n  char **storep = NULL;\n  long port = 0;\n  bool urlencode = (flags & CURLU_URLENCODE)? 1 : 0;\n  bool plusencode = FALSE;\n  bool urlskipslash = FALSE;\n  bool appendquery = FALSE;\n  bool equalsencode = FALSE;\n\n  if(!u)\n    return CURLUE_BAD_HANDLE;\n  if(!part) {\n    \/* setting a part to NULL clears it *\/\n    switch(what) {\n    case CURLUPART_URL:\n      break;\n    case CURLUPART_SCHEME:\n      storep = &u->scheme;\n      break;\n    case CURLUPART_USER:\n      storep = &u->user;\n      break;\n    case CURLUPART_PASSWORD:\n      storep = &u->password;\n      break;\n    case CURLUPART_OPTIONS:\n      storep = &u->options;\n      break;\n    case CURLUPART_HOST:\n      storep = &u->host;\n      break;\n    case CURLUPART_ZONEID:\n      storep = &u->zoneid;\n      break;\n    case CURLUPART_PORT:\n      u->portnum = 0;\n      storep = &u->port;\n      break;\n    case CURLUPART_PATH:\n      storep = &u->path;\n      break;\n    case CURLUPART_QUERY:\n      storep = &u->query;\n      break;\n    case CURLUPART_FRAGMENT:\n      storep = &u->fragment;\n      break;\n    default:\n      return CURLUE_UNKNOWN_PART;\n    }\n    if(storep && *storep) {\n      Curl_safefree(*storep);\n    }\n    return CURLUE_OK;\n  }\n\n  switch(what) {\n  case CURLUPART_SCHEME:\n    if(strlen(part) > MAX_SCHEME_LEN)\n      \/* too long *\/\n      return CURLUE_BAD_SCHEME;\n    if(!(flags & CURLU_NON_SUPPORT_SCHEME) &&\n       \/* verify that it is a fine scheme *\/\n       !Curl_builtin_scheme(part))\n      return CURLUE_UNSUPPORTED_SCHEME;\n    storep = &u->scheme;\n    urlencode = FALSE; \/* never *\/\n    break;\n  case CURLUPART_USER:\n    storep = &u->user;\n    break;\n  case CURLUPART_PASSWORD:\n    storep = &u->password;\n    break;\n  case CURLUPART_OPTIONS:\n    storep = &u->options;\n    break;\n  case CURLUPART_HOST: {\n    size_t len = strcspn(part, \" \\r\\n\");\n    if(strlen(part) != len)\n      \/* hostname with bad content *\/\n      return CURLUE_BAD_HOSTNAME;\n    storep = &u->host;\n    Curl_safefree(u->zoneid);\n    break;\n  }\n  case CURLUPART_ZONEID:\n    storep = &u->zoneid;\n    break;\n  case CURLUPART_PORT:\n  {\n    char *endp;\n    urlencode = FALSE; \/* never *\/\n    port = strtol(part, &endp, 10);  \/* Port number must be decimal *\/\n    if((port <= 0) || (port > 0xffff))\n      return CURLUE_BAD_PORT_NUMBER;\n    if(*endp)\n      \/* weirdly provided number, not good! *\/\n      return CURLUE_BAD_PORT_NUMBER;\n    storep = &u->port;\n  }\n  break;\n  case CURLUPART_PATH:\n    urlskipslash = TRUE;\n    storep = &u->path;\n    break;\n  case CURLUPART_QUERY:\n    plusencode = urlencode;\n    appendquery = (flags & CURLU_APPENDQUERY)?1:0;\n    equalsencode = appendquery;\n    storep = &u->query;\n    break;\n  case CURLUPART_FRAGMENT:\n    storep = &u->fragment;\n    break;\n  case CURLUPART_URL: {\n    \/*\n     * Allow a new URL to replace the existing (if any) contents.\n     *\n     * If the existing contents is enough for a URL, allow a relative URL to\n     * replace it.\n     *\/\n    CURLUcode result;\n    char *oldurl;\n    char *redired_url;\n\n    \/* if the new thing is absolute or the old one is not\n     * (we could not get an absolute url in 'oldurl'),\n     * then replace the existing with the new. *\/\n    if(Curl_is_absolute_url(part, NULL, 0)\n       || curl_url_get(u, CURLUPART_URL, &oldurl, flags)) {\n      return parseurl_and_replace(part, u, flags);\n    }\n\n    \/* apply the relative part to create a new URL\n     * and replace the existing one with it. *\/\n    redired_url = concat_url(oldurl, part);\n    free(oldurl);\n    if(!redired_url)\n      return CURLUE_OUT_OF_MEMORY;\n\n    result = parseurl_and_replace(redired_url, u, flags);\n    free(redired_url);\n    return result;\n  }\n  default:\n    return CURLUE_UNKNOWN_PART;\n  }\n  DEBUGASSERT(storep);\n  {\n    const char *newp = part;\n    size_t nalloc = strlen(part);\n\n    if(nalloc > CURL_MAX_INPUT_LENGTH)\n      \/* excessive input length *\/\n      return CURLUE_MALFORMED_INPUT;\n\n    if(urlencode) {\n      const unsigned char *i;\n      char *o;\n      char *enc = malloc(nalloc * 3 + 1); \/* for worst case! *\/\n      if(!enc)\n        return CURLUE_OUT_OF_MEMORY;\n      for(i = (const unsigned char *)part, o = enc; *i; i++) {\n        if((*i == ' ') && plusencode) {\n          *o = '+';\n          o++;\n        }\n        else if(Curl_isunreserved(*i) ||\n                ((*i == '\/') && urlskipslash) ||\n                ((*i == '=') && equalsencode)) {\n          if((*i == '=') && equalsencode)\n            \/* only skip the first equals sign *\/\n            equalsencode = FALSE;\n          *o = *i;\n          o++;\n        }\n        else {\n          msnprintf(o, 4, \"%%%02x\", *i);\n          o += 3;\n        }\n      }\n      *o = 0; \/* null-terminate *\/\n      newp = enc;\n    }\n    else {\n      char *p;\n      newp = strdup(part);\n      if(!newp)\n        return CURLUE_OUT_OF_MEMORY;\n      p = (char *)newp;\n      while(*p) {\n        \/* make sure percent encoded are lower case *\/\n        if((*p == '%') && ISXDIGIT(p[1]) && ISXDIGIT(p[2]) &&\n           (ISUPPER(p[1]) || ISUPPER(p[2]))) {\n          p[1] = (char)TOLOWER(p[1]);\n          p[2] = (char)TOLOWER(p[2]);\n          p += 3;\n        }\n        else\n          p++;\n      }\n    }\n\n    if(appendquery) {\n      \/* Append the string onto the old query. Add a '&' separator if none is\n         present at the end of the exsting query already *\/\n      size_t querylen = u->query ? strlen(u->query) : 0;\n      bool addamperand = querylen && (u->query[querylen -1] != '&');\n      if(querylen) {\n        size_t newplen = strlen(newp);\n        char *p = malloc(querylen + addamperand + newplen + 1);\n        if(!p) {\n          free((char *)newp);\n          return CURLUE_OUT_OF_MEMORY;\n        }\n        strcpy(p, u->query); \/* original query *\/\n        if(addamperand)\n          p[querylen] = '&'; \/* ampersand *\/\n        strcpy(&p[querylen + addamperand], newp); \/* new suffix *\/\n        free((char *)newp);\n        free(*storep);\n        *storep = p;\n        return CURLUE_OK;\n      }\n    }\n\n    if(what == CURLUPART_HOST) {\n      if(0 == strlen(newp) && (flags & CURLU_NO_AUTHORITY)) {\n        \/* Skip hostname check, it's allowed to be empty. *\/\n      }\n      else {\n        if(hostname_check(u, (char *)newp)) {\n          free((char *)newp);\n          return CURLUE_BAD_HOSTNAME;\n        }\n      }\n    }\n\n    free(*storep);\n    *storep = (char *)newp;\n  }\n  \/* set after the string, to make it not assigned if the allocation above\n     fails *\/\n  if(port)\n    u->portnum = port;\n  return CURLUE_OK;\n}","target":0,"code_token_length":1871,"total_token_length":2107,"max_tokens_setting":4096}
+{"idx":242575,"func":"handle_image (void *data, unsigned int datasize,\n\t      EFI_LOADED_IMAGE *li,\n\t      EFI_IMAGE_ENTRY_POINT *entry_point,\n\t      EFI_PHYSICAL_ADDRESS *alloc_address,\n\t      UINTN *alloc_pages)\n{\n\tEFI_STATUS efi_status;\n\tchar *buffer;\n\tint i;\n\tEFI_IMAGE_SECTION_HEADER *Section;\n\tchar *base, *end;\n\tUINT32 size;\n\tPE_COFF_LOADER_IMAGE_CONTEXT context;\n\tunsigned int alignment, alloc_size;\n\tint found_entry_point = 0;\n\tUINT8 sha1hash[SHA1_DIGEST_SIZE];\n\tUINT8 sha256hash[SHA256_DIGEST_SIZE];\n\n\t\/*\n\t * The binary header contains relevant context and section pointers\n\t *\/\n\tefi_status = read_header(data, datasize, &context);\n\tif (EFI_ERROR(efi_status)) {\n\t\tperror(L\"Failed to read header: %r\\n\", efi_status);\n\t\treturn efi_status;\n\t}\n\n\t\/*\n\t * Perform the image verification before we start copying data around\n\t * in order to load it.\n\t *\/\n\tif (secure_mode ()) {\n\t\tefi_status = verify_buffer(data, datasize, &context, sha256hash,\n\t\t\t\t\t   sha1hash);\n\n\t\tif (EFI_ERROR(efi_status)) {\n\t\t\tif (verbose)\n\t\t\t\tconsole_print(L\"Verification failed: %r\\n\", efi_status);\n\t\t\telse\n\t\t\t\tconsole_error(L\"Verification failed\", efi_status);\n\t\t\treturn efi_status;\n\t\t} else {\n\t\t\tif (verbose)\n\t\t\t\tconsole_print(L\"Verification succeeded\\n\");\n\t\t}\n\t}\n\n\t\/*\n\t * Calculate the hash for the TPM measurement.\n\t * XXX: We're computing these twice in secure boot mode when the\n\t *  buffers already contain the previously computed hashes. Also,\n\t *  this is only useful for the TPM1.2 case. We should try to fix\n\t *  this in a follow-up.\n\t *\/\n\tefi_status = generate_hash(data, datasize, &context, sha256hash,\n\t\t\t\t   sha1hash);\n\tif (EFI_ERROR(efi_status))\n\t\treturn efi_status;\n\n\t\/* Measure the binary into the TPM *\/\n#ifdef REQUIRE_TPM\n\tefi_status =\n#endif\n\ttpm_log_pe((EFI_PHYSICAL_ADDRESS)(UINTN)data, datasize,\n\t\t   (EFI_PHYSICAL_ADDRESS)(UINTN)context.ImageAddress,\n\t\t   li->FilePath, sha1hash, 4);\n#ifdef REQUIRE_TPM\n\tif (efi_status != EFI_SUCCESS) {\n\t\treturn efi_status;\n\t}\n#endif\n\n\t\/* The spec says, uselessly, of SectionAlignment:\n\t * =====\n\t * The alignment (in bytes) of sections when they are loaded into\n\t * memory. It must be greater than or equal to FileAlignment. The\n\t * default is the page size for the architecture.\n\t * =====\n\t * Which doesn't tell you whose responsibility it is to enforce the\n\t * \"default\", or when.  It implies that the value in the field must\n\t * be > FileAlignment (also poorly defined), but it appears visual\n\t * studio will happily write 512 for FileAlignment (its default) and\n\t * 0 for SectionAlignment, intending to imply PAGE_SIZE.\n\t *\n\t * We only support one page size, so if it's zero, nerf it to 4096.\n\t *\/\n\talignment = context.SectionAlignment;\n\tif (!alignment)\n\t\talignment = 4096;\n\n\talloc_size = ALIGN_VALUE(context.ImageSize + context.SectionAlignment,\n\t\t\t\t PAGE_SIZE);\n\t*alloc_pages = alloc_size \/ PAGE_SIZE;\n\n\tefi_status = BS->AllocatePages(AllocateAnyPages, EfiLoaderCode,\n\t\t\t\t       *alloc_pages, alloc_address);\n\tif (EFI_ERROR(efi_status)) {\n\t\tperror(L\"Failed to allocate image buffer\\n\");\n\t\treturn EFI_OUT_OF_RESOURCES;\n\t}\n\n\tbuffer = (void *)ALIGN_VALUE((unsigned long)*alloc_address, alignment);\n\tdprint(L\"Loading 0x%llx bytes at 0x%llx\\n\",\n\t       (unsigned long long)context.ImageSize,\n\t       (unsigned long long)(uintptr_t)buffer);\n\tupdate_mem_attrs((uintptr_t)buffer, alloc_size, MEM_ATTR_R|MEM_ATTR_W,\n\t\t\t MEM_ATTR_X);\n\n\tCopyMem(buffer, data, context.SizeOfHeaders);\n\n\t*entry_point = ImageAddress(buffer, context.ImageSize, context.EntryPoint);\n\tif (!*entry_point) {\n\t\tperror(L\"Entry point is invalid\\n\");\n\t\tBS->FreePages(*alloc_address, *alloc_pages);\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tchar *RelocBase, *RelocBaseEnd;\n\t\/*\n\t * These are relative virtual addresses, so we have to check them\n\t * against the image size, not the data size.\n\t *\/\n\tRelocBase = ImageAddress(buffer, context.ImageSize,\n\t\t\t\t context.RelocDir->VirtualAddress);\n\t\/*\n\t * RelocBaseEnd here is the address of the last byte of the table\n\t *\/\n\tRelocBaseEnd = ImageAddress(buffer, context.ImageSize,\n\t\t\t\t    context.RelocDir->VirtualAddress +\n\t\t\t\t    context.RelocDir->Size - 1);\n\n\tEFI_IMAGE_SECTION_HEADER *RelocSection = NULL;\n\n\t\/*\n\t * Copy the executable's sections to their desired offsets\n\t *\/\n\tSection = context.FirstSection;\n\tfor (i = 0; i < context.NumberOfSections; i++, Section++) {\n\t\t\/* Don't try to copy discardable sections with zero size *\/\n\t\tif ((Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) &&\n\t\t    !Section->Misc.VirtualSize)\n\t\t\tcontinue;\n\n\t\t\/*\n\t\t * Skip sections that aren't marked readable.\n\t\t *\/\n\t\tif (!(Section->Characteristics & EFI_IMAGE_SCN_MEM_READ))\n\t\t\tcontinue;\n\n\t\tif (!(Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) &&\n\t\t    (Section->Characteristics & EFI_IMAGE_SCN_MEM_WRITE) &&\n\t\t    (Section->Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) &&\n\t\t    (mok_policy & MOK_POLICY_REQUIRE_NX)) {\n\t\t\tperror(L\"Section %d is writable and executable\\n\", i);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\tbase = ImageAddress (buffer, context.ImageSize,\n\t\t\t\t     Section->VirtualAddress);\n\t\tend = ImageAddress (buffer, context.ImageSize,\n\t\t\t\t    Section->VirtualAddress\n\t\t\t\t     + Section->Misc.VirtualSize - 1);\n\n\t\tif (end < base) {\n\t\t\tperror(L\"Section %d has negative size\\n\", i);\n\t\t\tBS->FreePages(*alloc_address, *alloc_pages);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\tif (Section->VirtualAddress <= context.EntryPoint &&\n\t\t    (Section->VirtualAddress + Section->SizeOfRawData - 1)\n\t\t    > context.EntryPoint)\n\t\t\tfound_entry_point++;\n\n\t\t\/* We do want to process .reloc, but it's often marked\n\t\t * discardable, so we don't want to memcpy it. *\/\n\t\tif (CompareMem(Section->Name, \".reloc\\0\\0\", 8) == 0) {\n\t\t\tif (RelocSection) {\n\t\t\t\tperror(L\"Image has multiple relocation sections\\n\");\n\t\t\t\treturn EFI_UNSUPPORTED;\n\t\t\t}\n\t\t\t\/* If it has nonzero sizes, and our bounds check\n\t\t\t * made sense, and the VA and size match RelocDir's\n\t\t\t * versions, then we believe in this section table. *\/\n\t\t\tif (Section->SizeOfRawData &&\n\t\t\t\t\tSection->Misc.VirtualSize &&\n\t\t\t\t\tbase && end &&\n\t\t\t\t\tRelocBase == base &&\n\t\t\t\t\tRelocBaseEnd == end) {\n\t\t\t\tRelocSection = Section;\n\t\t\t}\n\t\t}\n\n\t\tif (Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!base) {\n\t\t\tperror(L\"Section %d has invalid base address\\n\", i);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\t\tif (!end) {\n\t\t\tperror(L\"Section %d has zero size\\n\", i);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\tif (!(Section->Characteristics & EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA) &&\n\t\t    (Section->VirtualAddress < context.SizeOfHeaders ||\n\t\t     Section->PointerToRawData < context.SizeOfHeaders)) {\n\t\t\tperror(L\"Section %d is inside image headers\\n\", i);\n\t\t\treturn EFI_UNSUPPORTED;\n\t\t}\n\n\t\tif (Section->Characteristics & EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA) {\n\t\t\tZeroMem(base, Section->Misc.VirtualSize);\n\t\t} else {\n\t\t\tif (Section->PointerToRawData < context.SizeOfHeaders) {\n\t\t\t\tperror(L\"Section %d is inside image headers\\n\", i);\n\t\t\t\treturn EFI_UNSUPPORTED;\n\t\t\t}\n\n\t\t\tsize = Section->Misc.VirtualSize;\n\t\t\tif (size > Section->SizeOfRawData)\n\t\t\t\tsize = Section->SizeOfRawData;\n\n\t\t\tif (size > 0)\n\t\t\t\tCopyMem(base, data + Section->PointerToRawData, size);\n\n\t\t\tif (size < Section->Misc.VirtualSize)\n\t\t\t\tZeroMem(base + size, Section->Misc.VirtualSize - size);\n\t\t}\n\t}\n\n\tif (context.NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\n\t\tperror(L\"Image has no relocation entry\\n\");\n\t\tFreePool(buffer);\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\tif (context.RelocDir->Size && RelocSection) {\n\t\t\/*\n\t\t * Run the relocation fixups\n\t\t *\/\n\t\tefi_status = relocate_coff(&context, RelocSection, data,\n\t\t\t\t\t   buffer);\n\n\t\tif (EFI_ERROR(efi_status)) {\n\t\t\tperror(L\"Relocation failed: %r\\n\", efi_status);\n\t\t\tFreePool(buffer);\n\t\t\treturn efi_status;\n\t\t}\n\t}\n\n\t\/*\n\t * Now set the page permissions appropriately.\n\t *\/\n\tSection = context.FirstSection;\n\tfor (i = 0; i < context.NumberOfSections; i++, Section++) {\n\t\tuint64_t set_attrs = MEM_ATTR_R;\n\t\tuint64_t clear_attrs = MEM_ATTR_W|MEM_ATTR_X;\n\t\tuintptr_t addr;\n\t\tuint64_t length;\n\n\t\t\/*\n\t\t * Skip discardable sections with zero size\n\t\t *\/\n\t\tif ((Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) &&\n\t\t    !Section->Misc.VirtualSize)\n\t\t\tcontinue;\n\n\t\t\/*\n\t\t * Skip sections that aren't marked readable.\n\t\t *\/\n\t\tif (!(Section->Characteristics & EFI_IMAGE_SCN_MEM_READ))\n\t\t\tcontinue;\n\n\t\tbase = ImageAddress (buffer, context.ImageSize,\n\t\t\t\t     Section->VirtualAddress);\n\t\tend = ImageAddress (buffer, context.ImageSize,\n\t\t\t\t    Section->VirtualAddress\n\t\t\t\t     + Section->Misc.VirtualSize - 1);\n\n\t\taddr = (uintptr_t)base;\n\t\tlength = (uintptr_t)end - (uintptr_t)base + 1;\n\n\t\tif (Section->Characteristics & EFI_IMAGE_SCN_MEM_WRITE) {\n\t\t\tset_attrs |= MEM_ATTR_W;\n\t\t\tclear_attrs &= ~MEM_ATTR_W;\n\t\t}\n\t\tif (Section->Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) {\n\t\t\tset_attrs |= MEM_ATTR_X;\n\t\t\tclear_attrs &= ~MEM_ATTR_X;\n\t\t}\n\t\tupdate_mem_attrs(addr, length, set_attrs, clear_attrs);\n\t}\n\n\n\t\/*\n\t * grub needs to know its location and size in memory, so fix up\n\t * the loaded image protocol values\n\t *\/\n\tli->ImageBase = buffer;\n\tli->ImageSize = context.ImageSize;\n\n\t\/* Pass the load options to the second stage loader *\/\n\tli->LoadOptions = load_options;\n\tli->LoadOptionsSize = load_options_size;\n\n\tif (!found_entry_point) {\n\t\tperror(L\"Entry point is not within sections\\n\");\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\tif (found_entry_point > 1) {\n\t\tperror(L\"%d sections contain entry point\\n\", found_entry_point);\n\t\treturn EFI_UNSUPPORTED;\n\t}\n\n\treturn EFI_SUCCESS;\n}","target":0,"code_token_length":2527,"total_token_length":2763,"max_tokens_setting":4096}
+{"idx":206417,"func":"ins_bs(\n    int\t\tc,\n    int\t\tmode,\n    int\t\t*inserted_space_p)\n{\n    linenr_T\tlnum;\n    int\t\tcc;\n    int\t\ttemp = 0;\t    \/\/ init for GCC\n    colnr_T\tsave_col;\n    colnr_T\tmincol;\n    int\t\tdid_backspace = FALSE;\n    int\t\tin_indent;\n    int\t\toldState;\n    int\t\tcpc[MAX_MCO];\t    \/\/ composing characters\n    int\t\tcall_fix_indent = FALSE;\n\n    \/*\n     * can't delete anything in an empty file\n     * can't backup past first character in buffer\n     * can't backup past starting point unless 'backspace' > 1\n     * can backup to a previous line if 'backspace' == 0\n     *\/\n    if (       BUFEMPTY()\n\t    || (\n#ifdef FEAT_RIGHTLEFT\n\t\t!revins_on &&\n#endif\n\t\t((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0)\n\t\t    || (!can_bs(BS_START)\n\t\t\t&& ((arrow_used\n#ifdef FEAT_JOB_CHANNEL\n\t\t\t\t&& !bt_prompt(curbuf)\n#endif\n\t\t\t) || (curwin->w_cursor.lnum == Insstart_orig.lnum\n\t\t\t\t&& curwin->w_cursor.col <= Insstart_orig.col)))\n\t\t    || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0\n\t\t\t\t\t && curwin->w_cursor.col <= ai_col)\n\t\t    || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0))))\n    {\n\tvim_beep(BO_BS);\n\treturn FALSE;\n    }\n\n    if (stop_arrow() == FAIL)\n\treturn FALSE;\n    in_indent = inindent(0);\n    if (in_indent)\n\tcan_cindent = FALSE;\n    end_comment_pending = NUL;\t\/\/ After BS, don't auto-end comment\n#ifdef FEAT_RIGHTLEFT\n    if (revins_on)\t    \/\/ put cursor after last inserted char\n\tinc_cursor();\n#endif\n\n    \/\/ Virtualedit:\n    \/\/\tBACKSPACE_CHAR eats a virtual space\n    \/\/\tBACKSPACE_WORD eats all coladd\n    \/\/\tBACKSPACE_LINE eats all coladd and keeps going\n    if (curwin->w_cursor.coladd > 0)\n    {\n\tif (mode == BACKSPACE_CHAR)\n\t{\n\t    --curwin->w_cursor.coladd;\n\t    return TRUE;\n\t}\n\tif (mode == BACKSPACE_WORD)\n\t{\n\t    curwin->w_cursor.coladd = 0;\n\t    return TRUE;\n\t}\n\tcurwin->w_cursor.coladd = 0;\n    }\n\n    \/*\n     * Delete newline!\n     *\/\n    if (curwin->w_cursor.col == 0)\n    {\n\tlnum = Insstart.lnum;\n\tif (curwin->w_cursor.lnum == lnum\n#ifdef FEAT_RIGHTLEFT\n\t\t\t|| revins_on\n#endif\n\t\t\t\t    )\n\t{\n\t    if (u_save((linenr_T)(curwin->w_cursor.lnum - 2),\n\t\t\t       (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL)\n\t\treturn FALSE;\n\t    --Insstart.lnum;\n\t    Insstart.col = (colnr_T)STRLEN(ml_get(Insstart.lnum));\n\t}\n\t\/*\n\t * In replace mode:\n\t * cc < 0: NL was inserted, delete it\n\t * cc >= 0: NL was replaced, put original characters back\n\t *\/\n\tcc = -1;\n\tif (State & REPLACE_FLAG)\n\t    cc = replace_pop();\t    \/\/ returns -1 if NL was inserted\n\t\/*\n\t * In replace mode, in the line we started replacing, we only move the\n\t * cursor.\n\t *\/\n\tif ((State & REPLACE_FLAG) && curwin->w_cursor.lnum <= lnum)\n\t{\n\t    dec_cursor();\n\t}\n\telse\n\t{\n\t    if (!(State & VREPLACE_FLAG)\n\t\t\t\t   || curwin->w_cursor.lnum > orig_line_count)\n\t    {\n\t\ttemp = gchar_cursor();\t\/\/ remember current char\n\t\t--curwin->w_cursor.lnum;\n\n\t\t\/\/ When \"aw\" is in 'formatoptions' we must delete the space at\n\t\t\/\/ the end of the line, otherwise the line will be broken\n\t\t\/\/ again when auto-formatting.\n\t\tif (has_format_option(FO_AUTO)\n\t\t\t\t\t   && has_format_option(FO_WHITE_PAR))\n\t\t{\n\t\t    char_u  *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum,\n\t\t\t\t\t\t\t\t\tTRUE);\n\t\t    int\t    len;\n\n\t\t    len = (int)STRLEN(ptr);\n\t\t    if (len > 0 && ptr[len - 1] == ' ')\n\t\t\tptr[len - 1] = NUL;\n\t\t}\n\n\t\t(void)do_join(2, FALSE, FALSE, FALSE, FALSE);\n\t\tif (temp == NUL && gchar_cursor() != NUL)\n\t\t    inc_cursor();\n\t    }\n\t    else\n\t\tdec_cursor();\n\n\t    \/*\n\t     * In MODE_REPLACE mode we have to put back the text that was\n\t     * replaced by the NL. On the replace stack is first a\n\t     * NUL-terminated sequence of characters that were deleted and then\n\t     * the characters that NL replaced.\n\t     *\/\n\t    if (State & REPLACE_FLAG)\n\t    {\n\t\t\/*\n\t\t * Do the next ins_char() in MODE_NORMAL state, to\n\t\t * prevent ins_char() from replacing characters and\n\t\t * avoiding showmatch().\n\t\t *\/\n\t\toldState = State;\n\t\tState = MODE_NORMAL;\n\t\t\/*\n\t\t * restore characters (blanks) deleted after cursor\n\t\t *\/\n\t\twhile (cc > 0)\n\t\t{\n\t\t    save_col = curwin->w_cursor.col;\n\t\t    mb_replace_pop_ins(cc);\n\t\t    curwin->w_cursor.col = save_col;\n\t\t    cc = replace_pop();\n\t\t}\n\t\t\/\/ restore the characters that NL replaced\n\t\treplace_pop_ins();\n\t\tState = oldState;\n\t    }\n\t}\n\tdid_ai = FALSE;\n    }\n    else\n    {\n\t\/*\n\t * Delete character(s) before the cursor.\n\t *\/\n#ifdef FEAT_RIGHTLEFT\n\tif (revins_on)\t\t\/\/ put cursor on last inserted char\n\t    dec_cursor();\n#endif\n\tmincol = 0;\n\t\t\t\t\t\t\/\/ keep indent\n\tif (mode == BACKSPACE_LINE\n\t\t&& (curbuf->b_p_ai || cindent_on())\n#ifdef FEAT_RIGHTLEFT\n\t\t&& !revins_on\n#endif\n\t\t\t    )\n\t{\n\t    save_col = curwin->w_cursor.col;\n\t    beginline(BL_WHITE);\n\t    if (curwin->w_cursor.col < save_col)\n\t    {\n\t\tmincol = curwin->w_cursor.col;\n\t\t\/\/ should now fix the indent to match with the previous line\n\t\tcall_fix_indent = TRUE;\n\t    }\n\t    curwin->w_cursor.col = save_col;\n\t}\n\n\t\/*\n\t * Handle deleting one 'shiftwidth' or 'softtabstop'.\n\t *\/\n\tif (\t   mode == BACKSPACE_CHAR\n\t\t&& ((p_sta && in_indent)\n\t\t    || ((get_sts_value() != 0\n#ifdef FEAT_VARTABS\n\t\t\t|| tabstop_count(curbuf->b_p_vsts_array)\n#endif\n\t\t\t)\n\t\t\t&& curwin->w_cursor.col > 0\n\t\t\t&& (*(ml_get_cursor() - 1) == TAB\n\t\t\t    || (*(ml_get_cursor() - 1) == ' '\n\t\t\t\t&& (!*inserted_space_p\n\t\t\t\t    || arrow_used))))))\n\t{\n\t    int\t\tts;\n\t    colnr_T\tvcol;\n\t    colnr_T\twant_vcol;\n\t    colnr_T\tstart_vcol;\n\n\t    *inserted_space_p = FALSE;\n\t    \/\/ Compute the virtual column where we want to be.  Since\n\t    \/\/ 'showbreak' may get in the way, need to get the last column of\n\t    \/\/ the previous character.\n\t    getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);\n\t    start_vcol = vcol;\n\t    dec_cursor();\n\t    getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);\n\t    inc_cursor();\n#ifdef FEAT_VARTABS\n\t    if (p_sta && in_indent)\n\t    {\n\t\tts = (int)get_sw_value(curbuf);\n\t\twant_vcol = (want_vcol \/ ts) * ts;\n\t    }\n\t    else\n\t\twant_vcol = tabstop_start(want_vcol, get_sts_value(),\n\t\t\t\t\t\t       curbuf->b_p_vsts_array);\n#else\n\t    if (p_sta && in_indent)\n\t\tts = (int)get_sw_value(curbuf);\n\t    else\n\t\tts = (int)get_sts_value();\n\t    want_vcol = (want_vcol \/ ts) * ts;\n#endif\n\n\t    \/\/ delete characters until we are at or before want_vcol\n\t    while (vcol > want_vcol\n\t\t    && (cc = *(ml_get_cursor() - 1), VIM_ISWHITE(cc)))\n\t\tins_bs_one(&vcol);\n\n\t    \/\/ insert extra spaces until we are at want_vcol\n\t    while (vcol < want_vcol)\n\t    {\n\t\t\/\/ Remember the first char we inserted\n\t\tif (curwin->w_cursor.lnum == Insstart_orig.lnum\n\t\t\t\t   && curwin->w_cursor.col < Insstart_orig.col)\n\t\t    Insstart_orig.col = curwin->w_cursor.col;\n\n\t\tif (State & VREPLACE_FLAG)\n\t\t    ins_char(' ');\n\t\telse\n\t\t{\n\t\t    ins_str((char_u *)\" \");\n\t\t    if ((State & REPLACE_FLAG))\n\t\t\treplace_push(NUL);\n\t\t}\n\t\tgetvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);\n\t    }\n\n\t    \/\/ If we are now back where we started delete one character.  Can\n\t    \/\/ happen when using 'sts' and 'linebreak'.\n\t    if (vcol >= start_vcol)\n\t\tins_bs_one(&vcol);\n\t}\n\n\t\/*\n\t * Delete up to starting point, start of line or previous word.\n\t *\/\n\telse\n\t{\n\t    int cclass = 0, prev_cclass = 0;\n\n\t    if (has_mbyte)\n\t\tcclass = mb_get_class(ml_get_cursor());\n\t    do\n\t    {\n#ifdef FEAT_RIGHTLEFT\n\t\tif (!revins_on) \/\/ put cursor on char to be deleted\n#endif\n\t\t    dec_cursor();\n\n\t\tcc = gchar_cursor();\n\t\t\/\/ look multi-byte character class\n\t\tif (has_mbyte)\n\t\t{\n\t\t    prev_cclass = cclass;\n\t\t    cclass = mb_get_class(ml_get_cursor());\n\t\t}\n\n\t\t\/\/ start of word?\n\t\tif (mode == BACKSPACE_WORD && !vim_isspace(cc))\n\t\t{\n\t\t    mode = BACKSPACE_WORD_NOT_SPACE;\n\t\t    temp = vim_iswordc(cc);\n\t\t}\n\t\t\/\/ end of word?\n\t\telse if (mode == BACKSPACE_WORD_NOT_SPACE\n\t\t\t&& ((vim_isspace(cc) || vim_iswordc(cc) != temp)\n\t\t\t|| prev_cclass != cclass))\n\t\t{\n#ifdef FEAT_RIGHTLEFT\n\t\t    if (!revins_on)\n#endif\n\t\t\tinc_cursor();\n#ifdef FEAT_RIGHTLEFT\n\t\t    else if (State & REPLACE_FLAG)\n\t\t\tdec_cursor();\n#endif\n\t\t    break;\n\t\t}\n\t\tif (State & REPLACE_FLAG)\n\t\t    replace_do_bs(-1);\n\t\telse\n\t\t{\n\t\t    if (enc_utf8 && p_deco)\n\t\t\t(void)utfc_ptr2char(ml_get_cursor(), cpc);\n\t\t    (void)del_char(FALSE);\n\t\t    \/*\n\t\t     * If there are combining characters and 'delcombine' is set\n\t\t     * move the cursor back.  Don't back up before the base\n\t\t     * character.\n\t\t     *\/\n\t\t    if (enc_utf8 && p_deco && cpc[0] != NUL)\n\t\t\tinc_cursor();\n#ifdef FEAT_RIGHTLEFT\n\t\t    if (revins_chars)\n\t\t    {\n\t\t\trevins_chars--;\n\t\t\trevins_legal++;\n\t\t    }\n\t\t    if (revins_on && gchar_cursor() == NUL)\n\t\t\tbreak;\n#endif\n\t\t}\n\t\t\/\/ Just a single backspace?:\n\t\tif (mode == BACKSPACE_CHAR)\n\t\t    break;\n\t    } while (\n#ifdef FEAT_RIGHTLEFT\n\t\t    revins_on ||\n#endif\n\t\t    (curwin->w_cursor.col > mincol\n\t\t    &&  (can_bs(BS_NOSTOP)\n\t\t\t|| (curwin->w_cursor.lnum != Insstart_orig.lnum\n\t\t\t|| curwin->w_cursor.col != Insstart_orig.col)\n\t\t    )));\n\t}\n\tdid_backspace = TRUE;\n    }\n    did_si = FALSE;\n    can_si = FALSE;\n    can_si_back = FALSE;\n    if (curwin->w_cursor.col <= 1)\n\tdid_ai = FALSE;\n\n    if (call_fix_indent)\n\tfix_indent();\n\n    \/*\n     * It's a little strange to put backspaces into the redo\n     * buffer, but it makes auto-indent a lot easier to deal\n     * with.\n     *\/\n    AppendCharToRedobuff(c);\n\n    \/\/ If deleted before the insertion point, adjust it\n    if (curwin->w_cursor.lnum == Insstart_orig.lnum\n\t\t\t\t  && curwin->w_cursor.col < Insstart_orig.col)\n\tInsstart_orig.col = curwin->w_cursor.col;\n\n    \/\/ vi behaviour: the cursor moves backward but the character that\n    \/\/\t\t     was there remains visible\n    \/\/ Vim behaviour: the cursor moves backward and the character that\n    \/\/\t\t      was there is erased from the screen.\n    \/\/ We can emulate the vi behaviour by pretending there is a dollar\n    \/\/ displayed even when there isn't.\n    \/\/  --pkv Sun Jan 19 01:56:40 EST 2003\n    if (vim_strchr(p_cpo, CPO_BACKSPACE) != NULL && dollar_vcol == -1)\n\tdollar_vcol = curwin->w_virtcol;\n\n#ifdef FEAT_FOLDING\n    \/\/ When deleting a char the cursor line must never be in a closed fold.\n    \/\/ E.g., when 'foldmethod' is indent and deleting the first non-white\n    \/\/ char before a Tab.\n    if (did_backspace)\n\tfoldOpenCursor();\n#endif\n\n    return did_backspace;\n}","target":1,"code_token_length":3041,"total_token_length":3277,"max_tokens_setting":4096}
+{"idx":206123,"func":"RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut64 off, int bits, char * file_name) {\n\tRCoreSymCacheElement *result = NULL;\n\tut8 *b = NULL;\n\tRCoreSymCacheElementHdr *hdr = r_coresym_cache_element_header_new (buf, off, bits);\n\tif (!hdr) {\n\t\treturn NULL;\n\t}\n\tif (hdr->version != 1) {\n\t\teprintf (\"Unsupported CoreSymbolication cache version (%d)\\n\", hdr->version);\n\t\tgoto beach;\n\t}\n\tif (hdr->size == 0 || hdr->size > r_buf_size (buf) - off) {\n\t\teprintf (\"Corrupted CoreSymbolication header: size out of bounds (0x%x)\\n\", hdr->size);\n\t\tgoto beach;\n\t}\n\tresult = R_NEW0 (RCoreSymCacheElement);\n\tif (!result) {\n\t\tgoto beach;\n\t}\n\tresult->hdr = hdr;\n\tb = malloc (hdr->size);\n\tif (!b) {\n\t\tgoto beach;\n\t}\n\tif (r_buf_read_at (buf, off, b, hdr->size) != hdr->size) {\n\t\tgoto beach;\n\t}\n\tut8 *end = b + hdr->size;\n\tif (file_name) {\n\t\tresult->file_name = file_name;\n\t} else if (hdr->file_name_off) {\n\t\tresult->file_name = str_dup_safe (b, b + (size_t)hdr->file_name_off, end);\n\t}\n\tif (hdr->version_off) {\n\t\tresult->binary_version = str_dup_safe (b, b + (size_t)hdr->version_off, end);\n\t}\n\tconst size_t word_size = bits \/ 8;\n\tconst ut64 start_of_sections = (ut64)hdr->n_segments * R_CS_EL_SIZE_SEG + R_CS_EL_OFF_SEGS;\n\tconst ut64 sect_size = (bits == 32) ? R_CS_EL_SIZE_SECT_32 : R_CS_EL_SIZE_SECT_64;\n\tconst ut64 start_of_symbols = start_of_sections + (ut64)hdr->n_sections * sect_size;\n\tconst ut64 start_of_lined_symbols = start_of_symbols + (ut64)hdr->n_symbols * R_CS_EL_SIZE_SYM;\n\tconst ut64 start_of_line_info = start_of_lined_symbols + (ut64)hdr->n_lined_symbols * R_CS_EL_SIZE_LSYM;\n\tconst ut64 start_of_unknown_pairs = start_of_line_info + (ut64)hdr->n_line_info * R_CS_EL_SIZE_LINFO;\n\tconst ut64 start_of_strings = start_of_unknown_pairs + (ut64)hdr->n_symbols * 8;\n\n\tut64 page_zero_size = 0;\n\tsize_t page_zero_idx = 0;\n\tif (UT32_MUL_OVFCHK (hdr->n_segments, sizeof (RCoreSymCacheElementSegment))) {\n\t\tgoto beach;\n\t} else if (UT32_MUL_OVFCHK (hdr->n_sections, sizeof (RCoreSymCacheElementSection))) {\n\t\tgoto beach;\n\t} else if (UT32_MUL_OVFCHK (hdr->n_symbols, sizeof (RCoreSymCacheElementSymbol))) {\n\t\tgoto beach;\n\t} else if (UT32_MUL_OVFCHK (hdr->n_lined_symbols, sizeof (RCoreSymCacheElementLinedSymbol))) {\n\t\tgoto beach;\n\t} else if (UT32_MUL_OVFCHK (hdr->n_line_info, sizeof (RCoreSymCacheElementLineInfo))) {\n\t\tgoto beach;\n\t}\n\tif (hdr->n_segments > 0) {\n\t\tresult->segments = R_NEWS0 (RCoreSymCacheElementSegment, hdr->n_segments);\n\t\tif (!result->segments) {\n\t\t\tgoto beach;\n\t\t}\n\t\tsize_t i;\n\t\tut8 *cursor = b + R_CS_EL_OFF_SEGS;\n\t\tfor (i = 0; i < hdr->n_segments && cursor + sizeof (RCoreSymCacheElementSegment) < end; i++) {\n\t\t\tRCoreSymCacheElementSegment *seg = &result->segments[i];\n\t\t\tseg->paddr = seg->vaddr = r_read_le64 (cursor);\n\t\t\tcursor += 8;\n\t\t\tif (cursor >= end) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tseg->size = seg->vsize = r_read_le64 (cursor);\n\t\t\tcursor += 8;\n\t\t\tif (cursor >= end) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tseg->name = str_dup_safe_fixed (b, cursor, 16, end);\n\t\t\tcursor += 16;\n\t\t\tif (!seg->name) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!strcmp (seg->name, \"__PAGEZERO\")) {\n\t\t\t\tpage_zero_size = seg->size;\n\t\t\t\tpage_zero_idx = i;\n\t\t\t\tseg->paddr = seg->vaddr = 0;\n\t\t\t\tseg->size = 0;\n\t\t\t}\n\t\t}\n\t\tfor (i = 0; i < hdr->n_segments && page_zero_size > 0; i++) {\n\t\t\tif (i == page_zero_idx) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tRCoreSymCacheElementSegment *seg = &result->segments[i];\n\t\t\tif (seg->vaddr < page_zero_size) {\n\t\t\t\tseg->vaddr += page_zero_size;\n\t\t\t}\n\t\t}\n\t}\n\tbool relative_to_strings = false;\n\tut8* string_origin;\n\tif (hdr->n_sections > 0) {\n\t\tresult->sections = R_NEWS0 (RCoreSymCacheElementSection, hdr->n_sections);\n\t\tif (!result->sections) {\n\t\t\tgoto beach;\n\t\t}\n\t\tsize_t i;\n\t\tut8 *cursor = b + start_of_sections;\n\t\tfor (i = 0; i < hdr->n_sections && cursor < end; i++) {\n\t\t\tut8 *sect_start = cursor;\n\t\t\tRCoreSymCacheElementSection *sect = &result->sections[i];\n\t\t\tsect->vaddr = sect->paddr = r_read_ble (cursor, false, bits);\n\t\t\tif (sect->vaddr < page_zero_size) {\n\t\t\t\tsect->vaddr += page_zero_size;\n\t\t\t}\n\t\t\tcursor += word_size;\n\t\t\tif (cursor >= end) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsect->size = r_read_ble (cursor, false, bits);\n\t\t\tcursor += word_size;\n\t\t\tif (cursor >= end) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tut64 sect_name_off = r_read_ble (cursor, false, bits);\n\t\t\tif (!i && !sect_name_off) {\n\t\t\t\trelative_to_strings = true;\n\t\t\t}\n\t\t\tcursor += word_size;\n\t\t\tif (bits == 32) {\n\t\t\t\tcursor += word_size;\n\t\t\t}\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : sect_start;\n\t\t\tsect->name = str_dup_safe (b, string_origin + (size_t)sect_name_off, end);\n\t\t}\n\t}\n\tif (hdr->n_symbols) {\n\t\tresult->symbols = R_NEWS0 (RCoreSymCacheElementSymbol, hdr->n_symbols);\n\t\tif (!result->symbols) {\n\t\t\tgoto beach;\n\t\t}\n\t\tsize_t i;\n\t\tut8 *cursor = b + start_of_symbols;\n\t\tfor (i = 0; i < hdr->n_symbols && cursor + R_CS_EL_SIZE_SYM <= end; i++) {\n\t\t\tRCoreSymCacheElementSymbol *sym = &result->symbols[i];\n\t\t\tsym->paddr = r_read_le32 (cursor);\n\t\t\tsym->size = r_read_le32 (cursor + 0x4);\n\t\t\tsym->unk1 = r_read_le32 (cursor + 0x8);\n\t\t\tsize_t name_off = r_read_le32 (cursor + 0xc);\n\t\t\tsize_t mangled_name_off = r_read_le32 (cursor + 0x10);\n\t\t\tsym->unk2 = (st32)r_read_le32 (cursor + 0x14);\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : cursor;\n\t\t\tsym->name = str_dup_safe (b, string_origin + name_off, end);\n\t\t\tif (!sym->name) {\n\t\t\t\tcursor += R_CS_EL_SIZE_SYM;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : cursor;\n\t\t\tsym->mangled_name = str_dup_safe (b, string_origin + mangled_name_off, end);\n\t\t\tif (!sym->mangled_name) {\n\t\t\t\tcursor += R_CS_EL_SIZE_SYM;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcursor += R_CS_EL_SIZE_SYM;\n\t\t}\n\t}\n\tif (hdr->n_lined_symbols) {\n\t\tresult->lined_symbols = R_NEWS0 (RCoreSymCacheElementLinedSymbol, hdr->n_lined_symbols);\n\t\tif (!result->lined_symbols) {\n\t\t\tgoto beach;\n\t\t}\n\t\tsize_t i;\n\t\tut8 *cursor = b + start_of_lined_symbols;\n\t\tfor (i = 0; i < hdr->n_lined_symbols && cursor + R_CS_EL_SIZE_LSYM <= end; i++) {\n\t\t\tRCoreSymCacheElementLinedSymbol *lsym = &result->lined_symbols[i];\n\t\t\tlsym->sym.paddr = r_read_le32 (cursor);\n\t\t\tlsym->sym.size = r_read_le32 (cursor + 0x4);\n\t\t\tlsym->sym.unk1 = r_read_le32 (cursor + 0x8);\n\t\t\tsize_t name_off = r_read_le32 (cursor + 0xc);\n\t\t\tsize_t mangled_name_off = r_read_le32 (cursor + 0x10);\n\t\t\tlsym->sym.unk2 = (st32)r_read_le32 (cursor + 0x14);\n\t\t\tsize_t file_name_off = r_read_le32 (cursor + 0x18);\n\t\t\tlsym->flc.line = r_read_le32 (cursor + 0x1c);\n\t\t\tlsym->flc.col = r_read_le32 (cursor + 0x20);\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : cursor;\n\t\t\tlsym->sym.name = str_dup_safe (b, string_origin + name_off, end);\n\t\t\tif (!lsym->sym.name) {\n\t\t\t\tcursor += R_CS_EL_SIZE_LSYM;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : cursor;\n\t\t\tlsym->sym.mangled_name = str_dup_safe (b, string_origin + mangled_name_off, end);\n\t\t\tif (!lsym->sym.mangled_name) {\n\t\t\t\tcursor += R_CS_EL_SIZE_LSYM;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : cursor;\n\t\t\tlsym->flc.file = str_dup_safe (b, string_origin + file_name_off, end);\n\t\t\tif (!lsym->flc.file) {\n\t\t\t\tcursor += R_CS_EL_SIZE_LSYM;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcursor += R_CS_EL_SIZE_LSYM;\n\t\t\tmeta_add_fileline (bf, r_coresym_cache_element_pa2va (result, lsym->sym.paddr), lsym->sym.size, &lsym->flc);\n\t\t}\n\t}\n\tif (hdr->n_line_info) {\n\t\tresult->line_info = R_NEWS0 (RCoreSymCacheElementLineInfo, hdr->n_line_info);\n\t\tif (!result->line_info) {\n\t\t\tgoto beach;\n\t\t}\n\t\tsize_t i;\n\t\tut8 *cursor = b + start_of_line_info;\n\t\tfor (i = 0; i < hdr->n_line_info && cursor + R_CS_EL_SIZE_LINFO <= end; i++) {\n\t\t\tRCoreSymCacheElementLineInfo *info = &result->line_info[i];\n\t\t\tinfo->paddr = r_read_le32 (cursor);\n\t\t\tinfo->size = r_read_le32 (cursor + 4);\n\t\t\tsize_t file_name_off = r_read_le32 (cursor + 8);\n\t\t\tinfo->flc.line = r_read_le32 (cursor + 0xc);\n\t\t\tinfo->flc.col = r_read_le32 (cursor + 0x10);\n\t\t\tstring_origin = relative_to_strings? b + start_of_strings : cursor;\n\t\t\tinfo->flc.file = str_dup_safe (b, string_origin + file_name_off, end);\n\t\t\tif (!info->flc.file) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcursor += R_CS_EL_SIZE_LINFO;\n\t\t\tmeta_add_fileline (bf, r_coresym_cache_element_pa2va (result, info->paddr), info->size, &info->flc);\n\t\t}\n\t}\n\n\t\/*\n\t * TODO:\n\t * Figure out the meaning of the 2 arrays of hdr->n_symbols\n\t * 32-bit integers located at the end of line info.\n\t * Those are the last info before the strings at the end.\n\t *\/\n\nbeach:\n\tfree (b);\n\treturn result;\n}","target":1,"code_token_length":2812,"total_token_length":3048,"max_tokens_setting":4096}
+{"idx":428229,"func":"static CURLcode parseurlandfillconn(struct SessionHandle *data,\n                                    struct connectdata *conn,\n                                    bool *prot_missing,\n                                    char **userp, char **passwdp,\n                                    char **optionsp)\n{\n  char *at;\n  char *fragment;\n  char *path = data->state.path;\n  char *query;\n  int rc;\n  char protobuf[16] = \"\";\n  const char *protop = \"\";\n  CURLcode result;\n  bool rebuild_url = FALSE;\n\n  *prot_missing = FALSE;\n\n  \/* We might pass the entire URL into the request so we need to make sure\n   * there are no bad characters in there.*\/\n  if(strpbrk(data->change.url, \"\\r\\n\")) {\n    failf(data, \"Illegal characters found in URL\");\n    return CURLE_URL_MALFORMAT;\n  }\n\n  \/*************************************************************\n   * Parse the URL.\n   *\n   * We need to parse the url even when using the proxy, because we will need\n   * the hostname and port in case we are trying to SSL connect through the\n   * proxy -- and we don't know if we will need to use SSL until we parse the\n   * url ...\n   ************************************************************\/\n  if((2 == sscanf(data->change.url, \"%15[^:]:%[^\\n]\",\n                  protobuf, path)) &&\n     Curl_raw_equal(protobuf, \"file\")) {\n    if(path[0] == '\/' && path[1] == '\/') {\n      \/* Allow omitted hostname (e.g. file:\/<path>).  This is not strictly\n       * speaking a valid file: URL by RFC 1738, but treating file:\/<path> as\n       * file:\/\/localhost\/<path> is similar to how other schemes treat missing\n       * hostnames.  See RFC 1808. *\/\n\n      \/* This cannot be done with strcpy() in a portable manner, since the\n         memory areas overlap! *\/\n      memmove(path, path + 2, strlen(path + 2)+1);\n    }\n    \/*\n     * we deal with file:\/\/<host>\/<path> differently since it supports no\n     * hostname other than \"localhost\" and \"127.0.0.1\", which is unique among\n     * the URL protocols specified in RFC 1738\n     *\/\n    if(path[0] != '\/') {\n      \/* the URL included a host name, we ignore host names in file:\/\/ URLs\n         as the standards don't define what to do with them *\/\n      char *ptr=strchr(path, '\/');\n      if(ptr) {\n        \/* there was a slash present\n\n           RFC1738 (section 3.1, page 5) says:\n\n           The rest of the locator consists of data specific to the scheme,\n           and is known as the \"url-path\". It supplies the details of how the\n           specified resource can be accessed. Note that the \"\/\" between the\n           host (or port) and the url-path is NOT part of the url-path.\n\n           As most agents use file:\/\/localhost\/foo to get '\/foo' although the\n           slash preceding foo is a separator and not a slash for the path,\n           a URL as file:\/\/localhost\/\/foo must be valid as well, to refer to\n           the same file with an absolute path.\n        *\/\n\n        if(ptr[1] && ('\/' == ptr[1]))\n          \/* if there was two slashes, we skip the first one as that is then\n             used truly as a separator *\/\n          ptr++;\n\n        \/* This cannot be made with strcpy, as the memory chunks overlap! *\/\n        memmove(path, ptr, strlen(ptr)+1);\n      }\n    }\n\n    protop = \"file\"; \/* protocol string *\/\n  }\n  else {\n    \/* clear path *\/\n    path[0]=0;\n\n    if(2 > sscanf(data->change.url,\n                   \"%15[^\\n:]:\/\/%[^\\n\/?]%[^\\n]\",\n                   protobuf,\n                   conn->host.name, path)) {\n\n      \/*\n       * The URL was badly formatted, let's try the browser-style _without_\n       * protocol specified like 'http:\/\/'.\n       *\/\n      rc = sscanf(data->change.url, \"%[^\\n\/?]%[^\\n]\", conn->host.name, path);\n      if(1 > rc) {\n        \/*\n         * We couldn't even get this format.\n         * djgpp 2.04 has a sscanf() bug where 'conn->host.name' is\n         * assigned, but the return value is EOF!\n         *\/\n#if defined(__DJGPP__) && (DJGPP_MINOR == 4)\n        if(!(rc == -1 && *conn->host.name))\n#endif\n        {\n          failf(data, \"<url> malformed\");\n          return CURLE_URL_MALFORMAT;\n        }\n      }\n\n      \/*\n       * Since there was no protocol part specified, we guess what protocol it\n       * is based on the first letters of the server name.\n       *\/\n\n      \/* Note: if you add a new protocol, please update the list in\n       * lib\/version.c too! *\/\n\n      if(checkprefix(\"FTP.\", conn->host.name))\n        protop = \"ftp\";\n      else if(checkprefix(\"DICT.\", conn->host.name))\n        protop = \"DICT\";\n      else if(checkprefix(\"LDAP.\", conn->host.name))\n        protop = \"LDAP\";\n      else if(checkprefix(\"IMAP.\", conn->host.name))\n        protop = \"IMAP\";\n      else if(checkprefix(\"SMTP.\", conn->host.name))\n        protop = \"smtp\";\n      else if(checkprefix(\"POP3.\", conn->host.name))\n        protop = \"pop3\";\n      else {\n        protop = \"http\";\n      }\n\n      *prot_missing = TRUE; \/* not given in URL *\/\n    }\n    else\n      protop = protobuf;\n  }\n\n  \/* We search for '?' in the host name (but only on the right side of a\n   * @-letter to allow ?-letters in username and password) to handle things\n   * like http:\/\/example.com?param= (notice the missing '\/').\n   *\/\n  at = strchr(conn->host.name, '@');\n  if(at)\n    query = strchr(at+1, '?');\n  else\n    query = strchr(conn->host.name, '?');\n\n  if(query) {\n    \/* We must insert a slash before the '?'-letter in the URL. If the URL had\n       a slash after the '?', that is where the path currently begins and the\n       '?string' is still part of the host name.\n\n       We must move the trailing part from the host name and put it first in\n       the path. And have it all prefixed with a slash.\n    *\/\n\n    size_t hostlen = strlen(query);\n    size_t pathlen = strlen(path);\n\n    \/* move the existing path plus the zero byte forward, to make room for\n       the host-name part *\/\n    memmove(path+hostlen+1, path, pathlen+1);\n\n     \/* now copy the trailing host part in front of the existing path *\/\n    memcpy(path+1, query, hostlen);\n\n    path[0]='\/'; \/* prepend the missing slash *\/\n    rebuild_url = TRUE;\n\n    *query=0; \/* now cut off the hostname at the ? *\/\n  }\n  else if(!path[0]) {\n    \/* if there's no path set, use a single slash *\/\n    strcpy(path, \"\/\");\n    rebuild_url = TRUE;\n  }\n\n  \/* If the URL is malformatted (missing a '\/' after hostname before path) we\n   * insert a slash here. The only letter except '\/' we accept to start a path\n   * is '?'.\n   *\/\n  if(path[0] == '?') {\n    \/* We need this function to deal with overlapping memory areas. We know\n       that the memory area 'path' points to is 'urllen' bytes big and that\n       is bigger than the path. Use +1 to move the zero byte too. *\/\n    memmove(&path[1], path, strlen(path)+1);\n    path[0] = '\/';\n    rebuild_url = TRUE;\n  }\n  else {\n    \/* sanitise paths and remove ..\/ and .\/ sequences according to RFC3986 *\/\n    char *newp = Curl_dedotdotify(path);\n    if(!newp)\n      return CURLE_OUT_OF_MEMORY;\n\n    if(strcmp(newp, path)) {\n      rebuild_url = TRUE;\n      free(data->state.pathbuffer);\n      data->state.pathbuffer = newp;\n      data->state.path = newp;\n      path = newp;\n    }\n    else\n      free(newp);\n  }\n\n  \/*\n   * \"rebuild_url\" means that one or more URL components have been modified so\n   * we need to generate an updated full version.  We need the corrected URL\n   * when communicating over HTTP proxy and we don't know at this point if\n   * we're using a proxy or not.\n   *\/\n  if(rebuild_url) {\n    char *reurl;\n\n    size_t plen = strlen(path); \/* new path, should be 1 byte longer than\n                                   the original *\/\n    size_t urllen = strlen(data->change.url); \/* original URL length *\/\n\n    size_t prefixlen = strlen(conn->host.name);\n\n    if(!*prot_missing)\n      prefixlen += strlen(protop) + strlen(\":\/\/\");\n\n    reurl = malloc(urllen + 2); \/* 2 for zerobyte + slash *\/\n    if(!reurl)\n      return CURLE_OUT_OF_MEMORY;\n\n    \/* copy the prefix *\/\n    memcpy(reurl, data->change.url, prefixlen);\n\n    \/* append the trailing piece + zerobyte *\/\n    memcpy(&reurl[prefixlen], path, plen + 1);\n\n    \/* possible free the old one *\/\n    if(data->change.url_alloc) {\n      Curl_safefree(data->change.url);\n      data->change.url_alloc = FALSE;\n    }\n\n    infof(data, \"Rebuilt URL to: %s\\n\", reurl);\n\n    data->change.url = reurl;\n    data->change.url_alloc = TRUE; \/* free this later *\/\n  }\n\n  \/*\n   * Parse the login details from the URL and strip them out of\n   * the host name\n   *\/\n  result = parse_url_login(data, conn, userp, passwdp, optionsp);\n  if(result)\n    return result;\n\n  if(conn->host.name[0] == '[') {\n    \/* This looks like an IPv6 address literal.  See if there is an address\n       scope if there is no location header *\/\n    char *percent = strchr(conn->host.name, '%');\n    if(percent) {\n      unsigned int identifier_offset = 3;\n      char *endp;\n      unsigned long scope;\n      if(strncmp(\"%25\", percent, 3) != 0) {\n        infof(data,\n              \"Please URL encode %% as %%25, see RFC 6874.\\n\");\n        identifier_offset = 1;\n      }\n      scope = strtoul(percent + identifier_offset, &endp, 10);\n      if(*endp == ']') {\n        \/* The address scope was well formed.  Knock it out of the\n           hostname. *\/\n        memmove(percent, endp, strlen(endp)+1);\n        conn->scope_id = (unsigned int)scope;\n      }\n      else {\n        \/* Zone identifier is not numeric *\/\n#if defined(HAVE_NET_IF_H) && defined(IFNAMSIZ) && defined(HAVE_IF_NAMETOINDEX)\n        char ifname[IFNAMSIZ + 2];\n        char *square_bracket;\n        unsigned int scopeidx = 0;\n        strncpy(ifname, percent + identifier_offset, IFNAMSIZ + 2);\n        \/* Ensure nullbyte termination *\/\n        ifname[IFNAMSIZ + 1] = '\\0';\n        square_bracket = strchr(ifname, ']');\n        if(square_bracket) {\n          \/* Remove ']' *\/\n          *square_bracket = '\\0';\n          scopeidx = if_nametoindex(ifname);\n          if(scopeidx == 0) {\n            infof(data, \"Invalid network interface: %s; %s\\n\", ifname,\n                  strerror(errno));\n          }\n        }\n        if(scopeidx > 0) {\n          char *p = percent + identifier_offset + strlen(ifname);\n\n          \/* Remove zone identifier from hostname *\/\n          memmove(percent, p, strlen(p) + 1);\n          conn->scope_id = scopeidx;\n        }\n        else\n#endif \/* HAVE_NET_IF_H && IFNAMSIZ *\/\n          infof(data, \"Invalid IPv6 address format\\n\");\n      }\n    }\n  }\n\n  if(data->set.scope_id)\n    \/* Override any scope that was set above.  *\/\n    conn->scope_id = data->set.scope_id;\n\n  \/* Remove the fragment part of the path. Per RFC 2396, this is always the\n     last part of the URI. We are looking for the first '#' so that we deal\n     gracefully with non conformant URI such as http:\/\/example.com#foo#bar. *\/\n  fragment = strchr(path, '#');\n  if(fragment) {\n    *fragment = 0;\n\n    \/* we know the path part ended with a fragment, so we know the full URL\n       string does too and we need to cut it off from there so it isn't used\n       over proxy *\/\n    fragment = strchr(data->change.url, '#');\n    if(fragment)\n      *fragment = 0;\n  }\n\n  \/*\n   * So if the URL was A:\/\/B\/C#D,\n   *   protop is A\n   *   conn->host.name is B\n   *   data->state.path is \/C\n   *\/\n\n  return findprotocol(data, conn, protop);\n}","target":0,"code_token_length":2916,"total_token_length":3152,"max_tokens_setting":4096}
+{"idx":234195,"func":"display_debug_loc (struct dwarf_section *section, void *file)\n{\n  unsigned char *start = section->start, *vstart = NULL;\n  dwarf_vma bytes;\n  unsigned char *section_begin = start;\n  unsigned int num_loc_list = 0;\n  dwarf_vma last_offset = 0;\n  dwarf_vma last_view = 0;\n  unsigned int first = 0;\n  unsigned int i;\n  unsigned int j;\n  int seen_first_offset = 0;\n  int locs_sorted = 1;\n  unsigned char *next = start, *vnext = vstart;\n  unsigned int *array = NULL;\n  const char *suffix = strrchr (section->name, '.');\n  bool is_dwo = false;\n  int is_loclists = strstr (section->name, \"debug_loclists\") != NULL;\n  dwarf_vma expected_start = 0;\n\n  if (suffix && strcmp (suffix, \".dwo\") == 0)\n    is_dwo = true;\n\n  bytes = section->size;\n\n  if (bytes == 0)\n    {\n      printf (_(\"\\nThe %s section is empty.\\n\"), section->name);\n      return 0;\n    }\n\n  if (is_loclists)\n    {\n      unsigned char *hdrptr = section_begin;\n      dwarf_vma ll_length;\n      unsigned short ll_version;\n      unsigned char *end = section_begin + section->size;\n      unsigned char address_size, segment_selector_size;\n      uint32_t offset_entry_count;\n\n      SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 4, end);\n      if (ll_length == 0xffffffff)\n\tSAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 8, end);\n\n      SAFE_BYTE_GET_AND_INC (ll_version, hdrptr, 2, end);\n      if (ll_version != 5)\n\t{\n\t  warn (_(\"The %s section contains corrupt or \"\n\t\t  \"unsupported version number: %d.\\n\"),\n\t\tsection->name, ll_version);\n\t  return 0;\n\t}\n\n      SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end);\n\n      SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end);\n      if (segment_selector_size != 0)\n\t{\n\t  warn (_(\"The %s section contains \"\n\t\t  \"unsupported segment selector size: %d.\\n\"),\n\t\tsection->name, segment_selector_size);\n\t  return 0;\n\t}\n\n      SAFE_BYTE_GET_AND_INC (offset_entry_count, hdrptr, 4, end);\n\n      if (offset_entry_count != 0)\n\treturn display_offset_entry_loclists (section);\n\n      expected_start = hdrptr - section_begin;\n    }\n\n  if (load_debug_info (file) == 0)\n    {\n      warn (_(\"Unable to load\/parse the .debug_info section, so cannot interpret the %s section.\\n\"),\n\t    section->name);\n      return 0;\n    }\n\n  \/* Check the order of location list in .debug_info section. If\n     offsets of location lists are in the ascending order, we can\n     use `debug_information' directly.  *\/\n  for (i = 0; i < num_debug_info_entries; i++)\n    {\n      unsigned int num;\n\n      num = debug_information [i].num_loc_offsets;\n      if (num > num_loc_list)\n\tnum_loc_list = num;\n\n      \/* Check if we can use `debug_information' directly.  *\/\n      if (locs_sorted && num != 0)\n\t{\n\t  if (!seen_first_offset)\n\t    {\n\t      \/* This is the first location list.  *\/\n\t      last_offset = debug_information [i].loc_offsets [0];\n\t      last_view = debug_information [i].loc_views [0];\n\t      first = i;\n\t      seen_first_offset = 1;\n\t      j = 1;\n\t    }\n\t  else\n\t    j = 0;\n\n\t  for (; j < num; j++)\n\t    {\n\t      if (last_offset >\n\t\t  debug_information [i].loc_offsets [j]\n\t\t  || (last_offset == debug_information [i].loc_offsets [j]\n\t\t      && last_view > debug_information [i].loc_views [j]))\n\t\t{\n\t\t  locs_sorted = 0;\n\t\t  break;\n\t\t}\n\t      last_offset = debug_information [i].loc_offsets [j];\n\t      last_view = debug_information [i].loc_views [j];\n\t    }\n\t}\n    }\n\n  if (!seen_first_offset)\n    error (_(\"No location lists in .debug_info section!\\n\"));\n\n  if (debug_information [first].num_loc_offsets > 0\n      && debug_information [first].loc_offsets [0] != expected_start\n      && debug_information [first].loc_views [0] != expected_start)\n    warn (_(\"Location lists in %s section start at 0x%s rather than 0x%s\\n\"),\n\t  section->name,\n\t  dwarf_vmatoa (\"x\", debug_information [first].loc_offsets [0]),\n\t  dwarf_vmatoa (\"x\", expected_start));\n\n  if (!locs_sorted)\n    array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int));\n\n  introduce (section, false);\n\n  if (reloc_at (section, 0))\n    printf (_(\" Warning: This section has relocations - addresses seen here may not be accurate.\\n\\n\"));\n\n  printf (_(\"    Offset   Begin            End              Expression\\n\"));\n\n  seen_first_offset = 0;\n  for (i = first; i < num_debug_info_entries; i++)\n    {\n      dwarf_vma offset, voffset;\n      dwarf_vma base_address;\n      unsigned int k;\n      int has_frame_base;\n\n      if (!locs_sorted)\n\t{\n\t  for (k = 0; k < debug_information [i].num_loc_offsets; k++)\n\t    array[k] = k;\n\t  loc_offsets = debug_information [i].loc_offsets;\n\t  loc_views = debug_information [i].loc_views;\n\t  qsort (array, debug_information [i].num_loc_offsets,\n\t\t sizeof (*array), loc_offsets_compar);\n\t}\n\n      int adjacent_view_loclists = 1;\n      for (k = 0; k < debug_information [i].num_loc_offsets; k++)\n\t{\n\t  j = locs_sorted ? k : array[k];\n\t  if (k\n\t      && (debug_information [i].loc_offsets [locs_sorted\n\t\t\t\t\t\t    ? k - 1 : array [k - 1]]\n\t\t  == debug_information [i].loc_offsets [j])\n\t      && (debug_information [i].loc_views [locs_sorted\n\t\t\t\t\t\t   ? k - 1 : array [k - 1]]\n\t\t  == debug_information [i].loc_views [j]))\n\t    continue;\n\t  has_frame_base = debug_information [i].have_frame_base [j];\n\t  offset = debug_information [i].loc_offsets [j];\n\t  next = section_begin + offset;\n\t  voffset = debug_information [i].loc_views [j];\n\t  if (voffset != vm1)\n\t    vnext = section_begin + voffset;\n\t  else\n\t    vnext = NULL;\n\t  base_address = debug_information [i].base_address;\n\n\t  if (vnext && vnext < next)\n\t    {\n\t      vstart = vnext;\n\t      display_view_pair_list (section, &vstart, i, next);\n\t      if (start == vnext)\n\t\tstart = vstart;\n\t    }\n\n\t  if (!seen_first_offset || !adjacent_view_loclists)\n\t    seen_first_offset = 1;\n\t  else\n\t    {\n\t      if (start < next)\n\t\twarn (_(\"There is a hole [0x%lx - 0x%lx] in %s section.\\n\"),\n\t\t      (unsigned long) (start - section_begin),\n\t\t      (unsigned long) offset,\n\t\t      section->name);\n\t      else if (start > next)\n\t\twarn (_(\"There is an overlap [0x%lx - 0x%lx] in %s section.\\n\"),\n\t\t      (unsigned long) (start - section_begin),\n\t\t      (unsigned long) offset,\n\t\t      section->name);\n\t    }\n\t  start = next;\n\t  vstart = vnext;\n\n\t  if (offset >= bytes)\n\t    {\n\t      warn (_(\"Offset 0x%lx is bigger than %s section size.\\n\"),\n\t\t    (unsigned long) offset,\n\t\t    section->name);\n\t      continue;\n\t    }\n\n\t  if (vnext && voffset >= bytes)\n\t    {\n\t      warn (_(\"View Offset 0x%lx is bigger than %s section size.\\n\"),\n\t\t    (unsigned long) voffset,\n\t\t    section->name);\n\t      continue;\n\t    }\n\n\t  if (!is_loclists)\n\t    {\n\t      if (is_dwo)\n\t\tdisplay_loc_list_dwo (section, &start, i, offset,\n\t\t\t\t      &vstart, has_frame_base);\n\t      else\n\t\tdisplay_loc_list (section, &start, i, offset, base_address,\n\t\t\t\t  &vstart, has_frame_base);\n\t    }\n\t  else\n\t    {\n\t      if (is_dwo)\n\t\twarn (_(\"DWO is not yet supported.\\n\"));\n\t      else\n\t\tdisplay_loclists_list (section, &start, i, offset, base_address,\n\t\t\t\t       &vstart, has_frame_base);\n\t    }\n\n\t  \/* FIXME: this arrangement is quite simplistic.  Nothing\n\t     requires locview lists to be adjacent to corresponding\n\t     loclists, and a single loclist could be augmented by\n\t     different locview lists, and vice-versa, unlikely as it\n\t     is that it would make sense to do so.  Hopefully we'll\n\t     have view pair support built into loclists before we ever\n\t     need to address all these possibilities.  *\/\n\t  if (adjacent_view_loclists && vnext\n\t      && vnext != start && vstart != next)\n\t    {\n\t      adjacent_view_loclists = 0;\n\t      warn (_(\"Hole and overlap detection requires adjacent view lists and loclists.\\n\"));\n\t    }\n\n\t  if (vnext && vnext == start)\n\t    display_view_pair_list (section, &start, i, vstart);\n\t}\n    }\n\n  if (start < section->start + section->size)\n    warn (ngettext (\"There is %ld unused byte at the end of section %s\\n\",\n\t\t    \"There are %ld unused bytes at the end of section %s\\n\",\n\t\t    (long) (section->start + section->size - start)),\n\t  (long) (section->start + section->size - start), section->name);\n  putchar ('\\n');\n  free (array);\n  return 1;\n}","target":0,"code_token_length":2229,"total_token_length":2465,"max_tokens_setting":4096}
+{"idx":223388,"func":"static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common)\n{\nDEFINE_COMPILER;\nstruct sljit_label *start;\nstruct sljit_jump *match;\nfast_forward_char_data chars[MAX_N_CHARS];\nsljit_s32 offset;\nPCRE2_UCHAR mask;\nPCRE2_UCHAR *char_set, *char_set_end;\nint i, max, from;\nint range_right = -1, range_len;\nsljit_u8 *update_table = NULL;\nBOOL in_range;\nsljit_u32 rec_count;\n\nfor (i = 0; i < MAX_N_CHARS; i++)\n  {\n  chars[i].count = 0;\n  chars[i].last_count = 0;\n  }\n\nrec_count = 10000;\nmax = scan_prefix(common, common->start, chars, MAX_N_CHARS, &rec_count);\n\nif (max < 1)\n  return FALSE;\n\n\/* Convert last_count to priority. *\/\nfor (i = 0; i < max; i++)\n  {\n  SLJIT_ASSERT(chars[i].count > 0 && chars[i].last_count <= chars[i].count);\n\n  if (chars[i].count == 1)\n    {\n    chars[i].last_count = (chars[i].last_count == 1) ? 7 : 5;\n    \/* Simplifies algorithms later. *\/\n    chars[i].chars[1] = chars[i].chars[0];\n    }\n  else if (chars[i].count == 2)\n    {\n    SLJIT_ASSERT(chars[i].chars[0] != chars[i].chars[1]);\n\n    if (is_powerof2(chars[i].chars[0] ^ chars[i].chars[1]))\n      chars[i].last_count = (chars[i].last_count == 2) ? 6 : 4;\n    else\n      chars[i].last_count = (chars[i].last_count == 2) ? 3 : 2;\n    }\n  else\n    chars[i].last_count = (chars[i].count == 255) ? 0 : 1;\n  }\n\n#ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD\nif (JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD && check_fast_forward_char_pair_simd(common, chars, max))\n  return TRUE;\n#endif\n\nin_range = FALSE;\n\/* Prevent compiler \"uninitialized\" warning *\/\nfrom = 0;\nrange_len = 4 \/* minimum length *\/ - 1;\nfor (i = 0; i <= max; i++)\n  {\n  if (in_range && (i - from) > range_len && (chars[i - 1].count < 255))\n    {\n    range_len = i - from;\n    range_right = i - 1;\n    }\n\n  if (i < max && chars[i].count < 255)\n    {\n    SLJIT_ASSERT(chars[i].count > 0);\n    if (!in_range)\n      {\n      in_range = TRUE;\n      from = i;\n      }\n    }\n  else\n    in_range = FALSE;\n  }\n\nif (range_right >= 0)\n  {\n  update_table = (sljit_u8 *)allocate_read_only_data(common, 256);\n  if (update_table == NULL)\n    return TRUE;\n  memset(update_table, IN_UCHARS(range_len), 256);\n\n  for (i = 0; i < range_len; i++)\n    {\n    SLJIT_ASSERT(chars[range_right - i].count > 0 && chars[range_right - i].count < 255);\n\n    char_set = chars[range_right - i].chars;\n    char_set_end = char_set + chars[range_right - i].count;\n    do\n      {\n      if (update_table[(*char_set) & 0xff] > IN_UCHARS(i))\n        update_table[(*char_set) & 0xff] = IN_UCHARS(i);\n      char_set++;\n      }\n    while (char_set < char_set_end);\n    }\n  }\n\noffset = -1;\n\/* Scan forward. *\/\nfor (i = 0; i < max; i++)\n  {\n  if (range_right == i)\n    continue;\n\n  if (offset == -1)\n    {\n    if (chars[i].last_count >= 2)\n      offset = i;\n    }\n  else if (chars[offset].last_count < chars[i].last_count)\n    offset = i;\n  }\n\nSLJIT_ASSERT(offset == -1 || (chars[offset].count >= 1 && chars[offset].count <= 2));\n\nif (range_right < 0)\n  {\n  if (offset < 0)\n    return FALSE;\n  \/* Works regardless the value is 1 or 2. *\/\n  fast_forward_first_char2(common, chars[offset].chars[0], chars[offset].chars[1], offset);\n  return TRUE;\n  }\n\nSLJIT_ASSERT(range_right != offset);\n\nif (common->match_end_ptr != 0)\n  {\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);\n  OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);\n  OP2(SLJIT_SUB | SLJIT_SET_LESS, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));\n  add_jump(compiler, &common->failed_match, JUMP(SLJIT_LESS));\n  OP2U(SLJIT_SUB | SLJIT_SET_GREATER, STR_END, 0, TMP1, 0);\n  CMOV(SLJIT_GREATER, STR_END, TMP1, 0);\n  }\nelse\n  {\n  OP2(SLJIT_SUB | SLJIT_SET_LESS, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));\n  add_jump(compiler, &common->failed_match, JUMP(SLJIT_LESS));\n  }\n\nSLJIT_ASSERT(range_right >= 0);\n\nif (!HAS_VIRTUAL_REGISTERS)\n  OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table);\n\nstart = LABEL();\nadd_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0));\n\n#if PCRE2_CODE_UNIT_WIDTH == 8 || (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)\nOP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right));\n#else\nOP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right + 1) - 1);\n#endif\n\nif (!HAS_VIRTUAL_REGISTERS)\n  OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0);\nelse\n  OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table);\n\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);\nCMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, start);\n\nif (offset >= 0)\n  {\n  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offset));\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n  if (chars[offset].count == 1)\n    CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset].chars[0], start);\n  else\n    {\n    mask = chars[offset].chars[0] ^ chars[offset].chars[1];\n    if (is_powerof2(mask))\n      {\n      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, mask);\n      CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset].chars[0] | mask, start);\n      }\n    else\n      {\n      match = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset].chars[0]);\n      CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[offset].chars[1], start);\n      JUMPHERE(match);\n      }\n    }\n  }\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\nif (common->utf && offset != 0)\n  {\n  if (offset < 0)\n    {\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n    }\n  else\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));\n\n  jumpto_if_not_utf_char_start(compiler, TMP1, start);\n\n  if (offset < 0)\n    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  }\n#endif\n\nif (offset >= 0)\n  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\nif (common->match_end_ptr != 0)\n  OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);\nelse\n  OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));\nreturn TRUE;\n}","target":0,"code_token_length":2178,"total_token_length":2414,"max_tokens_setting":4096}
+{"idx":259226,"func":"static void mov_build_index(MOVContext *mov, AVStream *st)\n{\n    MOVStreamContext *sc = st->priv_data;\n    FFStream *const sti = ffstream(st);\n    int64_t current_offset;\n    int64_t current_dts = 0;\n    unsigned int stts_index = 0;\n    unsigned int stsc_index = 0;\n    unsigned int stss_index = 0;\n    unsigned int stps_index = 0;\n    unsigned int i, j;\n    uint64_t stream_size = 0;\n    MOVCtts *ctts_data_old = sc->ctts_data;\n    unsigned int ctts_count_old = sc->ctts_count;\n\n    int ret = build_open_gop_key_points(st);\n    if (ret < 0)\n        return;\n\n    if (sc->elst_count) {\n        int i, edit_start_index = 0, multiple_edits = 0;\n        int64_t empty_duration = 0; \/\/ empty duration of the first edit list entry\n        int64_t start_time = 0; \/\/ start time of the media\n\n        for (i = 0; i < sc->elst_count; i++) {\n            const MOVElst *e = &sc->elst_data[i];\n            if (i == 0 && e->time == -1) {\n                \/* if empty, the first entry is the start time of the stream\n                 * relative to the presentation itself *\/\n                empty_duration = e->duration;\n                edit_start_index = 1;\n            } else if (i == edit_start_index && e->time >= 0) {\n                start_time = e->time;\n            } else {\n                multiple_edits = 1;\n            }\n        }\n\n        if (multiple_edits && !mov->advanced_editlist)\n            av_log(mov->fc, AV_LOG_WARNING, \"multiple edit list entries, \"\n                   \"Use -advanced_editlist to correctly decode otherwise \"\n                   \"a\/v desync might occur\\n\");\n\n        \/* adjust first dts according to edit list *\/\n        if ((empty_duration || start_time) && mov->time_scale > 0) {\n            if (empty_duration)\n                empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale);\n\n            if (av_sat_sub64(start_time, empty_duration) != start_time - (uint64_t)empty_duration)\n                av_log(mov->fc, AV_LOG_WARNING, \"start_time - empty_duration is not representable\\n\");\n\n            sc->time_offset = start_time -  (uint64_t)empty_duration;\n            sc->min_corrected_pts = start_time;\n            if (!mov->advanced_editlist)\n                current_dts = -sc->time_offset;\n        }\n\n        if (!multiple_edits && !mov->advanced_editlist &&\n            st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)\n            sc->start_pad = start_time;\n    }\n\n    \/* only use old uncompressed audio chunk demuxing when stts specifies it *\/\n    if (!(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&\n          sc->stts_count == 1 && sc->stts_data[0].duration == 1)) {\n        unsigned int current_sample = 0;\n        unsigned int stts_sample = 0;\n        unsigned int sample_size;\n        unsigned int distance = 0;\n        unsigned int rap_group_index = 0;\n        unsigned int rap_group_sample = 0;\n        int rap_group_present = sc->rap_group_count && sc->rap_group;\n        int key_off = (sc->keyframe_count && sc->keyframes[0] > 0) || (sc->stps_count && sc->stps_data[0] > 0);\n\n        current_dts -= sc->dts_shift;\n\n        if (!sc->sample_count || sti->nb_index_entries)\n            return;\n        if (sc->sample_count >= UINT_MAX \/ sizeof(*sti->index_entries) - sti->nb_index_entries)\n            return;\n        if (av_reallocp_array(&sti->index_entries,\n                              sti->nb_index_entries + sc->sample_count,\n                              sizeof(*sti->index_entries)) < 0) {\n            sti->nb_index_entries = 0;\n            return;\n        }\n        sti->index_entries_allocated_size = (sti->nb_index_entries + sc->sample_count) * sizeof(*sti->index_entries);\n\n        if (ctts_data_old) {\n            \/\/ Expand ctts entries such that we have a 1-1 mapping with samples\n            if (sc->sample_count >= UINT_MAX \/ sizeof(*sc->ctts_data))\n                return;\n            sc->ctts_count = 0;\n            sc->ctts_allocated_size = 0;\n            sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size,\n                                    sc->sample_count * sizeof(*sc->ctts_data));\n            if (!sc->ctts_data) {\n                av_free(ctts_data_old);\n                return;\n            }\n\n            memset((uint8_t*)(sc->ctts_data), 0, sc->ctts_allocated_size);\n\n            for (i = 0; i < ctts_count_old &&\n                        sc->ctts_count < sc->sample_count; i++)\n                for (j = 0; j < ctts_data_old[i].count &&\n                            sc->ctts_count < sc->sample_count; j++)\n                    add_ctts_entry(&sc->ctts_data, &sc->ctts_count,\n                                   &sc->ctts_allocated_size, 1,\n                                   ctts_data_old[i].duration);\n            av_free(ctts_data_old);\n        }\n\n        for (i = 0; i < sc->chunk_count; i++) {\n            int64_t next_offset = i+1 < sc->chunk_count ? sc->chunk_offsets[i+1] : INT64_MAX;\n            current_offset = sc->chunk_offsets[i];\n            while (mov_stsc_index_valid(stsc_index, sc->stsc_count) &&\n                i + 1 == sc->stsc_data[stsc_index + 1].first)\n                stsc_index++;\n\n            if (next_offset > current_offset && sc->sample_size>0 && sc->sample_size < sc->stsz_sample_size &&\n                sc->stsc_data[stsc_index].count * (int64_t)sc->stsz_sample_size > next_offset - current_offset) {\n                av_log(mov->fc, AV_LOG_WARNING, \"STSZ sample size %d invalid (too large), ignoring\\n\", sc->stsz_sample_size);\n                sc->stsz_sample_size = sc->sample_size;\n            }\n            if (sc->stsz_sample_size>0 && sc->stsz_sample_size < sc->sample_size) {\n                av_log(mov->fc, AV_LOG_WARNING, \"STSZ sample size %d invalid (too small), ignoring\\n\", sc->stsz_sample_size);\n                sc->stsz_sample_size = sc->sample_size;\n            }\n\n            for (j = 0; j < sc->stsc_data[stsc_index].count; j++) {\n                int keyframe = 0;\n                if (current_sample >= sc->sample_count) {\n                    av_log(mov->fc, AV_LOG_ERROR, \"wrong sample count\\n\");\n                    return;\n                }\n\n                if (!sc->keyframe_absent && (!sc->keyframe_count || current_sample+key_off == sc->keyframes[stss_index])) {\n                    keyframe = 1;\n                    if (stss_index + 1 < sc->keyframe_count)\n                        stss_index++;\n                } else if (sc->stps_count && current_sample+key_off == sc->stps_data[stps_index]) {\n                    keyframe = 1;\n                    if (stps_index + 1 < sc->stps_count)\n                        stps_index++;\n                }\n                if (rap_group_present && rap_group_index < sc->rap_group_count) {\n                    if (sc->rap_group[rap_group_index].index > 0)\n                        keyframe = 1;\n                    if (++rap_group_sample == sc->rap_group[rap_group_index].count) {\n                        rap_group_sample = 0;\n                        rap_group_index++;\n                    }\n                }\n                if (sc->keyframe_absent\n                    && !sc->stps_count\n                    && !rap_group_present\n                    && (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || (i==0 && j==0)))\n                     keyframe = 1;\n                if (keyframe)\n                    distance = 0;\n                sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample];\n                if (sc->pseudo_stream_id == -1 ||\n                   sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) {\n                    AVIndexEntry *e;\n                    if (sample_size > 0x3FFFFFFF) {\n                        av_log(mov->fc, AV_LOG_ERROR, \"Sample size %u is too large\\n\", sample_size);\n                        return;\n                    }\n                    e = &sti->index_entries[sti->nb_index_entries++];\n                    e->pos = current_offset;\n                    e->timestamp = current_dts;\n                    e->size = sample_size;\n                    e->min_distance = distance;\n                    e->flags = keyframe ? AVINDEX_KEYFRAME : 0;\n                    av_log(mov->fc, AV_LOG_TRACE, \"AVIndex stream %d, sample %u, offset %\"PRIx64\", dts %\"PRId64\", \"\n                            \"size %u, distance %u, keyframe %d\\n\", st->index, current_sample,\n                            current_offset, current_dts, sample_size, distance, keyframe);\n                    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sti->nb_index_entries < 100)\n                        ff_rfps_add_frame(mov->fc, st, current_dts);\n                }\n\n                current_offset += sample_size;\n                stream_size += sample_size;\n\n                current_dts += sc->stts_data[stts_index].duration;\n\n                distance++;\n                stts_sample++;\n                current_sample++;\n                if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) {\n                    stts_sample = 0;\n                    stts_index++;\n                }\n            }\n        }\n        if (st->duration > 0)\n            st->codecpar->bit_rate = stream_size*8*sc->time_scale\/st->duration;\n    } else {\n        unsigned chunk_samples, total = 0;\n\n        if (!sc->chunk_count)\n            return;\n\n        \/\/ compute total chunk count\n        for (i = 0; i < sc->stsc_count; i++) {\n            unsigned count, chunk_count;\n\n            chunk_samples = sc->stsc_data[i].count;\n            if (i != sc->stsc_count - 1 &&\n                sc->samples_per_frame && chunk_samples % sc->samples_per_frame) {\n                av_log(mov->fc, AV_LOG_ERROR, \"error unaligned chunk\\n\");\n                return;\n            }\n\n            if (sc->samples_per_frame >= 160) { \/\/ gsm\n                count = chunk_samples \/ sc->samples_per_frame;\n            } else if (sc->samples_per_frame > 1) {\n                unsigned samples = (1024\/sc->samples_per_frame)*sc->samples_per_frame;\n                count = (chunk_samples+samples-1) \/ samples;\n            } else {\n                count = (chunk_samples+1023) \/ 1024;\n            }\n\n            if (mov_stsc_index_valid(i, sc->stsc_count))\n                chunk_count = sc->stsc_data[i+1].first - sc->stsc_data[i].first;\n            else\n                chunk_count = sc->chunk_count - (sc->stsc_data[i].first - 1);\n            total += chunk_count * count;\n        }\n\n        av_log(mov->fc, AV_LOG_TRACE, \"chunk count %u\\n\", total);\n        if (total >= UINT_MAX \/ sizeof(*sti->index_entries) - sti->nb_index_entries)\n            return;\n        if (av_reallocp_array(&sti->index_entries,\n                              sti->nb_index_entries + total,\n                              sizeof(*sti->index_entries)) < 0) {\n            sti->nb_index_entries = 0;\n            return;\n        }\n        sti->index_entries_allocated_size = (sti->nb_index_entries + total) * sizeof(*sti->index_entries);\n\n        \/\/ populate index\n        for (i = 0; i < sc->chunk_count; i++) {\n            current_offset = sc->chunk_offsets[i];\n            if (mov_stsc_index_valid(stsc_index, sc->stsc_count) &&\n                i + 1 == sc->stsc_data[stsc_index + 1].first)\n                stsc_index++;\n            chunk_samples = sc->stsc_data[stsc_index].count;\n\n            while (chunk_samples > 0) {\n                AVIndexEntry *e;\n                unsigned size, samples;\n\n                if (sc->samples_per_frame > 1 && !sc->bytes_per_frame) {\n                    avpriv_request_sample(mov->fc,\n                           \"Zero bytes per frame, but %d samples per frame\",\n                           sc->samples_per_frame);\n                    return;\n                }\n\n                if (sc->samples_per_frame >= 160) { \/\/ gsm\n                    samples = sc->samples_per_frame;\n                    size = sc->bytes_per_frame;\n                } else {\n                    if (sc->samples_per_frame > 1) {\n                        samples = FFMIN((1024 \/ sc->samples_per_frame)*\n                                        sc->samples_per_frame, chunk_samples);\n                        size = (samples \/ sc->samples_per_frame) * sc->bytes_per_frame;\n                    } else {\n                        samples = FFMIN(1024, chunk_samples);\n                        size = samples * sc->sample_size;\n                    }\n                }\n\n                if (sti->nb_index_entries >= total) {\n                    av_log(mov->fc, AV_LOG_ERROR, \"wrong chunk count %u\\n\", total);\n                    return;\n                }\n                if (size > 0x3FFFFFFF) {\n                    av_log(mov->fc, AV_LOG_ERROR, \"Sample size %u is too large\\n\", size);\n                    return;\n                }\n                e = &sti->index_entries[sti->nb_index_entries++];\n                e->pos = current_offset;\n                e->timestamp = current_dts;\n                e->size = size;\n                e->min_distance = 0;\n                e->flags = AVINDEX_KEYFRAME;\n                av_log(mov->fc, AV_LOG_TRACE, \"AVIndex stream %d, chunk %u, offset %\"PRIx64\", dts %\"PRId64\", \"\n                       \"size %u, duration %u\\n\", st->index, i, current_offset, current_dts,\n                       size, samples);\n\n                current_offset += size;\n                current_dts += samples;\n                chunk_samples -= samples;\n            }\n        }\n    }\n\n    if (!mov->ignore_editlist && mov->advanced_editlist) {\n        \/\/ Fix index according to edit lists.\n        mov_fix_index(mov, st);\n    }\n\n    \/\/ Update start time of the stream.\n    if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sti->nb_index_entries > 0) {\n        st->start_time = sti->index_entries[0].timestamp + sc->dts_shift;\n        if (sc->ctts_data) {\n            st->start_time += sc->ctts_data[0].duration;\n        }\n    }\n\n    mov_estimate_video_delay(mov, st);\n}","target":0,"code_token_length":3382,"total_token_length":3618,"max_tokens_setting":4096}
+{"idx":447060,"func":"                void printIFD(std::ostream& out, PrintStructureOption option, uint64_t dir_offset, int depth)\n                {\n                    BasicIo& io = Image::io();\n\n                    depth++;\n                    bool bFirst  = true;\n\n                    \/\/ buffer\n                    bool bPrint = true;\n\n                    do\n                    {\n                        \/\/ Read top of directory\n                        io.seek(dir_offset, BasicIo::beg);\n\n                        const uint64_t entries = readData(header_.format() == Header::StandardTiff? 2: 8);\n                        const bool tooBig = entries > 500;\n\n                        if ( bFirst && bPrint )\n                        {\n                            out << Internal::indent(depth) << Internal::stringFormat(\"STRUCTURE OF BIGTIFF FILE \") << io.path() << std::endl;\n                            if (tooBig)\n                                out << Internal::indent(depth) << \"entries = \" << entries << std::endl;\n                        }\n\n                        if (tooBig)\n                            break;\n\n                        \/\/ Read the dictionary\n                        for ( uint64_t i = 0; i < entries; i ++ )\n                        {\n                            if ( bFirst && bPrint )\n                                out << Internal::indent(depth)\n                                    << \" address |    tag                           |     \"\n                                    << \" type |    count |    offset | value\\n\";\n\n                            bFirst = false;\n\n                            const uint16_t tag   = readData(2);\n                            const uint16_t type  = readData(2);\n                            const uint64_t count = readData(dataSize_);\n                            const DataBuf  data  = io.read(dataSize_);        \/\/ Read data as raw value. what should be done about it will be decided depending on type\n\n                            std::string sp = \"\" ; \/\/ output spacer\n\n                            \/\/prepare to print the value\n                            \/\/ TODO: figure out what's going on with kount\n                            const uint64_t kount  = isStringType(type)? (count > 32 ? 32 : count) \/\/ restrict long arrays\n                                                            : count > 5              ? 5\n                                                            : count\n                                                            ;\n                            const uint32_t pad    = isStringType(type) ? 1 : 0;\n                            const uint32_t size   = isStringType(type) ? 1\n                                                  : is2ByteType(type)  ? 2\n                                                  : is4ByteType(type)  ? 4\n                                                  : is8ByteType(type)  ? 8\n                                                  : 1;\n\n                \t\t\t\/\/ #55 memory allocation crash test\/data\/POC8\n                \t\t\tlong long allocate = (long long) (size*count + pad);\n                \t\t\tif ( allocate > (long long) io.size() ) {\n                    \t\t\tthrow Error(57);\n                \t\t\t}\n\n                            DataBuf buf(allocate);\n\n                            const uint64_t offset = header_.format() == Header::StandardTiff?\n                                    byteSwap4(data, 0, doSwap_):\n                                    byteSwap8(data, 0, doSwap_);\n\n                            \/\/ big data? Use 'data' as pointer to real data\n                            const bool usePointer = (size_t) count*size > (size_t) dataSize_;\n\n                            if ( usePointer )                          \/\/ read into buffer\n                            {\n                                size_t   restore = io.tell();          \/\/ save\n                                io.seek(offset, BasicIo::beg);         \/\/ position\n                                io.read(buf.pData_, count * size);     \/\/ read\n                                io.seek(restore, BasicIo::beg);        \/\/ restore\n                            }\n                            else  \/\/ use 'data' as data :)\n                                std::memcpy(buf.pData_, data.pData_, count * size);     \/\/ copy data\n\n                            if ( bPrint )\n                            {\n                                const int entrySize = header_.format() == Header::StandardTiff? 12: 20;\n                                const uint64_t address = dir_offset + 2 + i * entrySize;\n                                const std::string offsetString = usePointer?\n                                    Internal::stringFormat(\"%10u\", offset):\n                                    \"\";\n\n                                out << Internal::indent(depth)\n                                    << Internal::stringFormat(\"%8u | %#06x %-25s |%10s |%9u |%10s | \",\n                                        address, tag, tagName(tag).c_str(), typeName(type), count, offsetString.c_str());\n\n                                if ( isShortType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        out << sp << byteSwap2(buf, k*size, doSwap_);\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isLongType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        out << sp << byteSwap4(buf, k*size, doSwap_);\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isLongLongType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        out << sp << byteSwap8(buf, k*size, doSwap_);\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isRationalType(type) )\n                                {\n                                    for ( size_t k = 0 ; k < kount ; k++ )\n                                    {\n                                        uint32_t a = byteSwap4(buf, k*size+0, doSwap_);\n                                        uint32_t b = byteSwap4(buf, k*size+4, doSwap_);\n                                        out << sp << a << \"\/\" << b;\n                                        sp = \" \";\n                                    }\n                                }\n                                else if ( isStringType(type) )\n                                    out << sp << Internal::binaryToString(buf, kount);\n\n                                sp = kount == count ? \"\" : \" ...\";\n                                out << sp << std::endl;\n\n                                if ( option == kpsRecursive &&\n                                        (tag == 0x8769 \/* ExifTag *\/ || tag == 0x014a\/*SubIFDs*\/ || type == tiffIfd || type == tiffIfd8) )\n                                {\n                                    for ( size_t k = 0 ; k < count ; k++ )\n                                    {\n                                        const size_t restore = io.tell();\n                                        const uint64_t ifdOffset = type == tiffIfd8?\n                                            byteSwap8(buf, k*size, doSwap_):\n                                            byteSwap4(buf, k*size, doSwap_);\n\n                                        std::cerr << \"tag = \" << Internal::stringFormat(\"%#x\",tag) << std::endl;\n                                        printIFD(out, option, ifdOffset, depth);\n                                        io.seek(restore, BasicIo::beg);\n                                    }\n                                }\n                                else if ( option == kpsRecursive && tag == 0x83bb \/* IPTCNAA *\/ )\n                                {\n                                    const size_t restore = io.tell();  \/\/ save\n                                    io.seek(offset, BasicIo::beg);     \/\/ position\n                                    byte* bytes=new byte[count] ;      \/\/ allocate memory\n                                    io.read(bytes,count)        ;      \/\/ read\n                                    io.seek(restore, BasicIo::beg);    \/\/ restore\n                                    IptcData::printStructure(out,bytes,count,depth);\n                                    delete[] bytes;                \/\/ free\n                                }\n                                else if ( option == kpsRecursive && tag == 0x927c \/* MakerNote *\/ && count > 10)\n                                {\n                                    size_t   restore = io.tell();  \/\/ save\n\n                                    uint32_t jump= 10           ;\n                                    byte     bytes[20]          ;\n                                    const char* chars = (const char*) &bytes[0] ;\n                                    io.seek(dir_offset, BasicIo::beg);  \/\/ position\n                                    io.read(bytes,jump    )     ;  \/\/ read\n                                    bytes[jump]=0               ;\n                                    if ( ::strcmp(\"Nikon\",chars) == 0 )\n                                    {\n                                        \/\/ tag is an embedded tiff\n                                        byte* bytes=new byte[count-jump] ;  \/\/ allocate memory\n                                        io.read(bytes,count-jump)        ;  \/\/ read\n                                        MemIo memIo(bytes,count-jump)    ;  \/\/ create a file\n                                        std::cerr << \"Nikon makernote\" << std::endl;\n                                        \/\/ printTiffStructure(memIo,out,option,depth);  TODO: fix it\n                                        delete[] bytes                   ;  \/\/ free\n                                    }\n                                    else\n                                    {\n                                        \/\/ tag is an IFD\n                                        io.seek(0, BasicIo::beg);  \/\/ position\n                                        std::cerr << \"makernote\" << std::endl;\n                                        printIFD(out,option,offset,depth);\n                                    }\n\n                                    io.seek(restore,BasicIo::beg); \/\/ restore\n                                }\n                            }\n                        }\n\n                        const uint64_t nextDirOffset = readData(dataSize_);\n\n                        dir_offset = tooBig ? 0 : nextDirOffset;\n                        out.flush();\n                    } while (dir_offset != 0);\n\n                    if ( bPrint )\n                        out << Internal::indent(depth) << \"END \" << io.path() << std::endl;\n\n                    depth--;\n                }","target":0,"code_token_length":1918,"total_token_length":2154,"max_tokens_setting":4096}
+{"idx":380955,"func":"ins_bs(\n    int\t\tc,\n    int\t\tmode,\n    int\t\t*inserted_space_p)\n{\n    linenr_T\tlnum;\n    int\t\tcc;\n    int\t\ttemp = 0;\t    \/\/ init for GCC\n    colnr_T\tsave_col;\n    colnr_T\tmincol;\n    int\t\tdid_backspace = FALSE;\n    int\t\tin_indent;\n    int\t\toldState;\n    int\t\tcpc[MAX_MCO];\t    \/\/ composing characters\n    int\t\tcall_fix_indent = FALSE;\n\n    \/*\n     * can't delete anything in an empty file\n     * can't backup past first character in buffer\n     * can't backup past starting point unless 'backspace' > 1\n     * can backup to a previous line if 'backspace' == 0\n     *\/\n    if (       BUFEMPTY()\n\t    || (\n#ifdef FEAT_RIGHTLEFT\n\t\t!revins_on &&\n#endif\n\t\t((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0)\n\t\t    || (!can_bs(BS_START)\n\t\t\t&& ((arrow_used\n#ifdef FEAT_JOB_CHANNEL\n\t\t\t\t&& !bt_prompt(curbuf)\n#endif\n\t\t\t) || (curwin->w_cursor.lnum == Insstart_orig.lnum\n\t\t\t\t&& curwin->w_cursor.col <= Insstart_orig.col)))\n\t\t    || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0\n\t\t\t\t\t && curwin->w_cursor.col <= ai_col)\n\t\t    || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0))))\n    {\n\tvim_beep(BO_BS);\n\treturn FALSE;\n    }\n\n    if (stop_arrow() == FAIL)\n\treturn FALSE;\n    in_indent = inindent(0);\n    if (in_indent)\n\tcan_cindent = FALSE;\n    end_comment_pending = NUL;\t\/\/ After BS, don't auto-end comment\n#ifdef FEAT_RIGHTLEFT\n    if (revins_on)\t    \/\/ put cursor after last inserted char\n\tinc_cursor();\n#endif\n\n    \/\/ Virtualedit:\n    \/\/\tBACKSPACE_CHAR eats a virtual space\n    \/\/\tBACKSPACE_WORD eats all coladd\n    \/\/\tBACKSPACE_LINE eats all coladd and keeps going\n    if (curwin->w_cursor.coladd > 0)\n    {\n\tif (mode == BACKSPACE_CHAR)\n\t{\n\t    --curwin->w_cursor.coladd;\n\t    return TRUE;\n\t}\n\tif (mode == BACKSPACE_WORD)\n\t{\n\t    curwin->w_cursor.coladd = 0;\n\t    return TRUE;\n\t}\n\tcurwin->w_cursor.coladd = 0;\n    }\n\n    \/*\n     * Delete newline!\n     *\/\n    if (curwin->w_cursor.col == 0)\n    {\n\tlnum = Insstart.lnum;\n\tif (curwin->w_cursor.lnum == lnum\n#ifdef FEAT_RIGHTLEFT\n\t\t\t|| revins_on\n#endif\n\t\t\t\t    )\n\t{\n\t    if (u_save((linenr_T)(curwin->w_cursor.lnum - 2),\n\t\t\t       (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL)\n\t\treturn FALSE;\n\t    --Insstart.lnum;\n\t    Insstart.col = (colnr_T)STRLEN(ml_get(Insstart.lnum));\n\t}\n\t\/*\n\t * In replace mode:\n\t * cc < 0: NL was inserted, delete it\n\t * cc >= 0: NL was replaced, put original characters back\n\t *\/\n\tcc = -1;\n\tif (State & REPLACE_FLAG)\n\t    cc = replace_pop();\t    \/\/ returns -1 if NL was inserted\n\t\/*\n\t * In replace mode, in the line we started replacing, we only move the\n\t * cursor.\n\t *\/\n\tif ((State & REPLACE_FLAG) && curwin->w_cursor.lnum <= lnum)\n\t{\n\t    dec_cursor();\n\t}\n\telse\n\t{\n\t    if (!(State & VREPLACE_FLAG)\n\t\t\t\t   || curwin->w_cursor.lnum > orig_line_count)\n\t    {\n\t\ttemp = gchar_cursor();\t\/\/ remember current char\n\t\t--curwin->w_cursor.lnum;\n\n\t\t\/\/ When \"aw\" is in 'formatoptions' we must delete the space at\n\t\t\/\/ the end of the line, otherwise the line will be broken\n\t\t\/\/ again when auto-formatting.\n\t\tif (has_format_option(FO_AUTO)\n\t\t\t\t\t   && has_format_option(FO_WHITE_PAR))\n\t\t{\n\t\t    char_u  *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum,\n\t\t\t\t\t\t\t\t\tTRUE);\n\t\t    int\t    len;\n\n\t\t    len = (int)STRLEN(ptr);\n\t\t    if (len > 0 && ptr[len - 1] == ' ')\n\t\t\tptr[len - 1] = NUL;\n\t\t}\n\n\t\t(void)do_join(2, FALSE, FALSE, FALSE, FALSE);\n\t\tif (temp == NUL && gchar_cursor() != NUL)\n\t\t    inc_cursor();\n\t    }\n\t    else\n\t\tdec_cursor();\n\n\t    \/*\n\t     * In MODE_REPLACE mode we have to put back the text that was\n\t     * replaced by the NL. On the replace stack is first a\n\t     * NUL-terminated sequence of characters that were deleted and then\n\t     * the characters that NL replaced.\n\t     *\/\n\t    if (State & REPLACE_FLAG)\n\t    {\n\t\t\/*\n\t\t * Do the next ins_char() in MODE_NORMAL state, to\n\t\t * prevent ins_char() from replacing characters and\n\t\t * avoiding showmatch().\n\t\t *\/\n\t\toldState = State;\n\t\tState = MODE_NORMAL;\n\t\t\/*\n\t\t * restore characters (blanks) deleted after cursor\n\t\t *\/\n\t\twhile (cc > 0)\n\t\t{\n\t\t    save_col = curwin->w_cursor.col;\n\t\t    mb_replace_pop_ins(cc);\n\t\t    curwin->w_cursor.col = save_col;\n\t\t    cc = replace_pop();\n\t\t}\n\t\t\/\/ restore the characters that NL replaced\n\t\treplace_pop_ins();\n\t\tState = oldState;\n\t    }\n\t}\n\tdid_ai = FALSE;\n    }\n    else\n    {\n\t\/*\n\t * Delete character(s) before the cursor.\n\t *\/\n#ifdef FEAT_RIGHTLEFT\n\tif (revins_on)\t\t\/\/ put cursor on last inserted char\n\t    dec_cursor();\n#endif\n\tmincol = 0;\n\t\t\t\t\t\t\/\/ keep indent\n\tif (mode == BACKSPACE_LINE\n\t\t&& (curbuf->b_p_ai || cindent_on())\n#ifdef FEAT_RIGHTLEFT\n\t\t&& !revins_on\n#endif\n\t\t\t    )\n\t{\n\t    save_col = curwin->w_cursor.col;\n\t    beginline(BL_WHITE);\n\t    if (curwin->w_cursor.col < save_col)\n\t    {\n\t\tmincol = curwin->w_cursor.col;\n\t\t\/\/ should now fix the indent to match with the previous line\n\t\tcall_fix_indent = TRUE;\n\t    }\n\t    curwin->w_cursor.col = save_col;\n\t}\n\n\t\/*\n\t * Handle deleting one 'shiftwidth' or 'softtabstop'.\n\t *\/\n\tif (\t   mode == BACKSPACE_CHAR\n\t\t&& ((p_sta && in_indent)\n\t\t    || ((get_sts_value() != 0\n#ifdef FEAT_VARTABS\n\t\t\t|| tabstop_count(curbuf->b_p_vsts_array)\n#endif\n\t\t\t)\n\t\t\t&& curwin->w_cursor.col > 0\n\t\t\t&& (*(ml_get_cursor() - 1) == TAB\n\t\t\t    || (*(ml_get_cursor() - 1) == ' '\n\t\t\t\t&& (!*inserted_space_p\n\t\t\t\t    || arrow_used))))))\n\t{\n\t    int\t\tts;\n\t    colnr_T\tvcol;\n\t    colnr_T\twant_vcol;\n\t    colnr_T\tstart_vcol;\n\n\t    *inserted_space_p = FALSE;\n\t    \/\/ Compute the virtual column where we want to be.  Since\n\t    \/\/ 'showbreak' may get in the way, need to get the last column of\n\t    \/\/ the previous character.\n\t    getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);\n\t    start_vcol = vcol;\n\t    dec_cursor();\n\t    getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);\n\t    inc_cursor();\n#ifdef FEAT_VARTABS\n\t    if (p_sta && in_indent)\n\t    {\n\t\tts = (int)get_sw_value(curbuf);\n\t\twant_vcol = (want_vcol \/ ts) * ts;\n\t    }\n\t    else\n\t\twant_vcol = tabstop_start(want_vcol, get_sts_value(),\n\t\t\t\t\t\t       curbuf->b_p_vsts_array);\n#else\n\t    if (p_sta && in_indent)\n\t\tts = (int)get_sw_value(curbuf);\n\t    else\n\t\tts = (int)get_sts_value();\n\t    want_vcol = (want_vcol \/ ts) * ts;\n#endif\n\n\t    \/\/ delete characters until we are at or before want_vcol\n\t    while (vcol > want_vcol && curwin->w_cursor.col > 0\n\t\t    && (cc = *(ml_get_cursor() - 1), VIM_ISWHITE(cc)))\n\t\tins_bs_one(&vcol);\n\n\t    \/\/ insert extra spaces until we are at want_vcol\n\t    while (vcol < want_vcol)\n\t    {\n\t\t\/\/ Remember the first char we inserted\n\t\tif (curwin->w_cursor.lnum == Insstart_orig.lnum\n\t\t\t\t   && curwin->w_cursor.col < Insstart_orig.col)\n\t\t    Insstart_orig.col = curwin->w_cursor.col;\n\n\t\tif (State & VREPLACE_FLAG)\n\t\t    ins_char(' ');\n\t\telse\n\t\t{\n\t\t    ins_str((char_u *)\" \");\n\t\t    if ((State & REPLACE_FLAG))\n\t\t\treplace_push(NUL);\n\t\t}\n\t\tgetvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);\n\t    }\n\n\t    \/\/ If we are now back where we started delete one character.  Can\n\t    \/\/ happen when using 'sts' and 'linebreak'.\n\t    if (vcol >= start_vcol)\n\t\tins_bs_one(&vcol);\n\t}\n\n\t\/*\n\t * Delete up to starting point, start of line or previous word.\n\t *\/\n\telse\n\t{\n\t    int cclass = 0, prev_cclass = 0;\n\n\t    if (has_mbyte)\n\t\tcclass = mb_get_class(ml_get_cursor());\n\t    do\n\t    {\n#ifdef FEAT_RIGHTLEFT\n\t\tif (!revins_on) \/\/ put cursor on char to be deleted\n#endif\n\t\t    dec_cursor();\n\n\t\tcc = gchar_cursor();\n\t\t\/\/ look multi-byte character class\n\t\tif (has_mbyte)\n\t\t{\n\t\t    prev_cclass = cclass;\n\t\t    cclass = mb_get_class(ml_get_cursor());\n\t\t}\n\n\t\t\/\/ start of word?\n\t\tif (mode == BACKSPACE_WORD && !vim_isspace(cc))\n\t\t{\n\t\t    mode = BACKSPACE_WORD_NOT_SPACE;\n\t\t    temp = vim_iswordc(cc);\n\t\t}\n\t\t\/\/ end of word?\n\t\telse if (mode == BACKSPACE_WORD_NOT_SPACE\n\t\t\t&& ((vim_isspace(cc) || vim_iswordc(cc) != temp)\n\t\t\t|| prev_cclass != cclass))\n\t\t{\n#ifdef FEAT_RIGHTLEFT\n\t\t    if (!revins_on)\n#endif\n\t\t\tinc_cursor();\n#ifdef FEAT_RIGHTLEFT\n\t\t    else if (State & REPLACE_FLAG)\n\t\t\tdec_cursor();\n#endif\n\t\t    break;\n\t\t}\n\t\tif (State & REPLACE_FLAG)\n\t\t    replace_do_bs(-1);\n\t\telse\n\t\t{\n\t\t    if (enc_utf8 && p_deco)\n\t\t\t(void)utfc_ptr2char(ml_get_cursor(), cpc);\n\t\t    (void)del_char(FALSE);\n\t\t    \/*\n\t\t     * If there are combining characters and 'delcombine' is set\n\t\t     * move the cursor back.  Don't back up before the base\n\t\t     * character.\n\t\t     *\/\n\t\t    if (enc_utf8 && p_deco && cpc[0] != NUL)\n\t\t\tinc_cursor();\n#ifdef FEAT_RIGHTLEFT\n\t\t    if (revins_chars)\n\t\t    {\n\t\t\trevins_chars--;\n\t\t\trevins_legal++;\n\t\t    }\n\t\t    if (revins_on && gchar_cursor() == NUL)\n\t\t\tbreak;\n#endif\n\t\t}\n\t\t\/\/ Just a single backspace?:\n\t\tif (mode == BACKSPACE_CHAR)\n\t\t    break;\n\t    } while (\n#ifdef FEAT_RIGHTLEFT\n\t\t    revins_on ||\n#endif\n\t\t    (curwin->w_cursor.col > mincol\n\t\t    &&  (can_bs(BS_NOSTOP)\n\t\t\t|| (curwin->w_cursor.lnum != Insstart_orig.lnum\n\t\t\t|| curwin->w_cursor.col != Insstart_orig.col)\n\t\t    )));\n\t}\n\tdid_backspace = TRUE;\n    }\n    did_si = FALSE;\n    can_si = FALSE;\n    can_si_back = FALSE;\n    if (curwin->w_cursor.col <= 1)\n\tdid_ai = FALSE;\n\n    if (call_fix_indent)\n\tfix_indent();\n\n    \/*\n     * It's a little strange to put backspaces into the redo\n     * buffer, but it makes auto-indent a lot easier to deal\n     * with.\n     *\/\n    AppendCharToRedobuff(c);\n\n    \/\/ If deleted before the insertion point, adjust it\n    if (curwin->w_cursor.lnum == Insstart_orig.lnum\n\t\t\t\t  && curwin->w_cursor.col < Insstart_orig.col)\n\tInsstart_orig.col = curwin->w_cursor.col;\n\n    \/\/ vi behaviour: the cursor moves backward but the character that\n    \/\/\t\t     was there remains visible\n    \/\/ Vim behaviour: the cursor moves backward and the character that\n    \/\/\t\t      was there is erased from the screen.\n    \/\/ We can emulate the vi behaviour by pretending there is a dollar\n    \/\/ displayed even when there isn't.\n    \/\/  --pkv Sun Jan 19 01:56:40 EST 2003\n    if (vim_strchr(p_cpo, CPO_BACKSPACE) != NULL && dollar_vcol == -1)\n\tdollar_vcol = curwin->w_virtcol;\n\n#ifdef FEAT_FOLDING\n    \/\/ When deleting a char the cursor line must never be in a closed fold.\n    \/\/ E.g., when 'foldmethod' is indent and deleting the first non-white\n    \/\/ char before a Tab.\n    if (did_backspace)\n\tfoldOpenCursor();\n#endif\n\n    return did_backspace;\n}","target":0,"code_token_length":3051,"total_token_length":3287,"max_tokens_setting":4096}
+{"idx":380952,"func":"insertchar(\n    int\t\tc,\t\t\t\/\/ character to insert or NUL\n    int\t\tflags,\t\t\t\/\/ INSCHAR_FORMAT, etc.\n    int\t\tsecond_indent)\t\t\/\/ indent for second line if >= 0\n{\n    int\t\ttextwidth;\n    char_u\t*p;\n    int\t\tfo_ins_blank;\n    int\t\tforce_format = flags & INSCHAR_FORMAT;\n\n    textwidth = comp_textwidth(force_format);\n    fo_ins_blank = has_format_option(FO_INS_BLANK);\n\n    \/*\n     * Try to break the line in two or more pieces when:\n     * - Always do this if we have been called to do formatting only.\n     * - Always do this when 'formatoptions' has the 'a' flag and the line\n     *   ends in white space.\n     * - Otherwise:\n     *\t - Don't do this if inserting a blank\n     *\t - Don't do this if an existing character is being replaced, unless\n     *\t   we're in MODE_VREPLACE state.\n     *\t - Do this if the cursor is not on the line where insert started\n     *\t or - 'formatoptions' doesn't have 'l' or the line was not too long\n     *\t       before the insert.\n     *\t    - 'formatoptions' doesn't have 'b' or a blank was inserted at or\n     *\t      before 'textwidth'\n     *\/\n    if (textwidth > 0\n\t    && (force_format\n\t\t|| (!VIM_ISWHITE(c)\n\t\t    && !((State & REPLACE_FLAG)\n\t\t\t&& !(State & VREPLACE_FLAG)\n\t\t\t&& *ml_get_cursor() != NUL)\n\t\t    && (curwin->w_cursor.lnum != Insstart.lnum\n\t\t\t|| ((!has_format_option(FO_INS_LONG)\n\t\t\t\t|| Insstart_textlen <= (colnr_T)textwidth)\n\t\t\t    && (!fo_ins_blank\n\t\t\t\t|| Insstart_blank_vcol <= (colnr_T)textwidth\n\t\t\t    ))))))\n    {\n\t\/\/ Format with 'formatexpr' when it's set.  Use internal formatting\n\t\/\/ when 'formatexpr' isn't set or it returns non-zero.\n#if defined(FEAT_EVAL)\n\tint     do_internal = TRUE;\n\tcolnr_T virtcol = get_nolist_virtcol()\n\t\t\t\t  + char2cells(c != NUL ? c : gchar_cursor());\n\n\tif (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0\n\t\t&& (force_format || virtcol > (colnr_T)textwidth))\n\t{\n\t    do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);\n\t    \/\/ It may be required to save for undo again, e.g. when setline()\n\t    \/\/ was called.\n\t    ins_need_undo = TRUE;\n\t}\n\tif (do_internal)\n#endif\n\t    internal_format(textwidth, second_indent, flags, c == NUL, c);\n    }\n\n    if (c == NUL)\t    \/\/ only formatting was wanted\n\treturn;\n\n    \/\/ Check whether this character should end a comment.\n    if (did_ai && c == end_comment_pending)\n    {\n\tchar_u  *line;\n\tchar_u\tlead_end[COM_MAX_LEN];\t    \/\/ end-comment string\n\tint\tmiddle_len, end_len;\n\tint\ti;\n\n\t\/*\n\t * Need to remove existing (middle) comment leader and insert end\n\t * comment leader.  First, check what comment leader we can find.\n\t *\/\n\ti = get_leader_len(line = ml_get_curline(), &p, FALSE, TRUE);\n\tif (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL)\t\/\/ Just checking\n\t{\n\t    \/\/ Skip middle-comment string\n\t    while (*p && p[-1] != ':')\t\/\/ find end of middle flags\n\t\t++p;\n\t    middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, \",\");\n\t    \/\/ Don't count trailing white space for middle_len\n\t    while (middle_len > 0 && VIM_ISWHITE(lead_end[middle_len - 1]))\n\t\t--middle_len;\n\n\t    \/\/ Find the end-comment string\n\t    while (*p && p[-1] != ':')\t\/\/ find end of end flags\n\t\t++p;\n\t    end_len = copy_option_part(&p, lead_end, COM_MAX_LEN, \",\");\n\n\t    \/\/ Skip white space before the cursor\n\t    i = curwin->w_cursor.col;\n\t    while (--i >= 0 && VIM_ISWHITE(line[i]))\n\t\t;\n\t    i++;\n\n\t    \/\/ Skip to before the middle leader\n\t    i -= middle_len;\n\n\t    \/\/ Check some expected things before we go on\n\t    if (i >= 0 && lead_end[end_len - 1] == end_comment_pending)\n\t    {\n\t\t\/\/ Backspace over all the stuff we want to replace\n\t\tbackspace_until_column(i);\n\n\t\t\/\/ Insert the end-comment string, except for the last\n\t\t\/\/ character, which will get inserted as normal later.\n\t\tins_bytes_len(lead_end, end_len - 1);\n\t    }\n\t}\n    }\n    end_comment_pending = NUL;\n\n    did_ai = FALSE;\n    did_si = FALSE;\n    can_si = FALSE;\n    can_si_back = FALSE;\n\n    \/*\n     * If there's any pending input, grab up to INPUT_BUFLEN at once.\n     * This speeds up normal text input considerably.\n     * Don't do this when 'cindent' or 'indentexpr' is set, because we might\n     * need to re-indent at a ':', or any other character (but not what\n     * 'paste' is set)..\n     * Don't do this when there an InsertCharPre autocommand is defined,\n     * because we need to fire the event for every character.\n     * Do the check for InsertCharPre before the call to vpeekc() because the\n     * InsertCharPre autocommand could change the input buffer.\n     *\/\n#ifdef USE_ON_FLY_SCROLL\n    dont_scroll = FALSE;\t\t\/\/ allow scrolling here\n#endif\n\n    if (       !ISSPECIAL(c)\n\t    && (!has_mbyte || (*mb_char2len)(c) == 1)\n\t    && !has_insertcharpre()\n\t    && vpeekc() != NUL\n\t    && !(State & REPLACE_FLAG)\n\t    && !cindent_on()\n#ifdef FEAT_RIGHTLEFT\n\t    && !p_ri\n#endif\n\t   )\n    {\n#define INPUT_BUFLEN 100\n\tchar_u\t\tbuf[INPUT_BUFLEN + 1];\n\tint\t\ti;\n\tcolnr_T\t\tvirtcol = 0;\n\n\tbuf[0] = c;\n\ti = 1;\n\tif (textwidth > 0)\n\t    virtcol = get_nolist_virtcol();\n\t\/*\n\t * Stop the string when:\n\t * - no more chars available\n\t * - finding a special character (command key)\n\t * - buffer is full\n\t * - running into the 'textwidth' boundary\n\t * - need to check for abbreviation: A non-word char after a word-char\n\t *\/\n\twhile (\t   (c = vpeekc()) != NUL\n\t\t&& !ISSPECIAL(c)\n\t\t&& (!has_mbyte || MB_BYTE2LEN_CHECK(c) == 1)\n\t\t&& i < INPUT_BUFLEN\n\t\t&& (textwidth == 0\n\t\t    || (virtcol += byte2cells(buf[i - 1])) < (colnr_T)textwidth)\n\t\t&& !(!no_abbr && !vim_iswordc(c) && vim_iswordc(buf[i - 1])))\n\t{\n#ifdef FEAT_RIGHTLEFT\n\t    c = vgetc();\n\t    if (p_hkmap && KeyTyped)\n\t\tc = hkmap(c);\t\t    \/\/ Hebrew mode mapping\n\t    buf[i++] = c;\n#else\n\t    buf[i++] = vgetc();\n#endif\n\t}\n\n#ifdef FEAT_DIGRAPHS\n\tdo_digraph(-1);\t\t\t\/\/ clear digraphs\n\tdo_digraph(buf[i-1]);\t\t\/\/ may be the start of a digraph\n#endif\n\tbuf[i] = NUL;\n\tins_str(buf);\n\tif (flags & INSCHAR_CTRLV)\n\t{\n\t    redo_literal(*buf);\n\t    i = 1;\n\t}\n\telse\n\t    i = 0;\n\tif (buf[i] != NUL)\n\t    AppendToRedobuffLit(buf + i, -1);\n    }\n    else\n    {\n\tint\t\tcc;\n\n\tif (has_mbyte && (cc = (*mb_char2len)(c)) > 1)\n\t{\n\t    char_u\tbuf[MB_MAXBYTES + 1];\n\n\t    (*mb_char2bytes)(c, buf);\n\t    buf[cc] = NUL;\n\t    ins_char_bytes(buf, cc);\n\t    AppendCharToRedobuff(c);\n\t}\n\telse\n\t{\n\t    ins_char(c);\n\t    if (flags & INSCHAR_CTRLV)\n\t\tredo_literal(c);\n\t    else\n\t\tAppendCharToRedobuff(c);\n\t}\n    }\n}","target":0,"code_token_length":1917,"total_token_length":2153,"max_tokens_setting":4096}
+{"idx":214160,"func":"composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)\n{\n\tstruct usb_composite_dev\t*cdev = get_gadget_data(gadget);\n\tstruct usb_request\t\t*req = cdev->req;\n\tint\t\t\t\tvalue = -EOPNOTSUPP;\n\tint\t\t\t\tstatus = 0;\n\tu16\t\t\t\tw_index = le16_to_cpu(ctrl->wIndex);\n\tu8\t\t\t\tintf = w_index & 0xFF;\n\tu16\t\t\t\tw_value = le16_to_cpu(ctrl->wValue);\n\tu16\t\t\t\tw_length = le16_to_cpu(ctrl->wLength);\n\tstruct usb_function\t\t*f = NULL;\n\tu8\t\t\t\tendp;\n\n\tif (w_length > USB_COMP_EP0_BUFSIZ) {\n\t\tif (ctrl->bRequestType & USB_DIR_IN) {\n\t\t\t\/* Cast away the const, we are going to overwrite on purpose. *\/\n\t\t\t__le16 *temp = (__le16 *)&ctrl->wLength;\n\n\t\t\t*temp = cpu_to_le16(USB_COMP_EP0_BUFSIZ);\n\t\t\tw_length = USB_COMP_EP0_BUFSIZ;\n\t\t} else {\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\t\/* partial re-init of the response message; the function or the\n\t * gadget might need to intercept e.g. a control-OUT completion\n\t * when we delegate to it.\n\t *\/\n\treq->zero = 0;\n\treq->context = cdev;\n\treq->complete = composite_setup_complete;\n\treq->length = 0;\n\tgadget->ep0->driver_data = cdev;\n\n\t\/*\n\t * Don't let non-standard requests match any of the cases below\n\t * by accident.\n\t *\/\n\tif ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)\n\t\tgoto unknown;\n\n\tswitch (ctrl->bRequest) {\n\n\t\/* we handle all standard USB descriptors *\/\n\tcase USB_REQ_GET_DESCRIPTOR:\n\t\tif (ctrl->bRequestType != USB_DIR_IN)\n\t\t\tgoto unknown;\n\t\tswitch (w_value >> 8) {\n\n\t\tcase USB_DT_DEVICE:\n\t\t\tcdev->desc.bNumConfigurations =\n\t\t\t\tcount_configs(cdev, USB_DT_DEVICE);\n\t\t\tcdev->desc.bMaxPacketSize0 =\n\t\t\t\tcdev->gadget->ep0->maxpacket;\n\t\t\tif (gadget_is_superspeed(gadget)) {\n\t\t\t\tif (gadget->speed >= USB_SPEED_SUPER) {\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0320);\n\t\t\t\t\tcdev->desc.bMaxPacketSize0 = 9;\n\t\t\t\t} else {\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0210);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (gadget->lpm_capable)\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0201);\n\t\t\t\telse\n\t\t\t\t\tcdev->desc.bcdUSB = cpu_to_le16(0x0200);\n\t\t\t}\n\n\t\t\tvalue = min(w_length, (u16) sizeof cdev->desc);\n\t\t\tmemcpy(req->buf, &cdev->desc, value);\n\t\t\tbreak;\n\t\tcase USB_DT_DEVICE_QUALIFIER:\n\t\t\tif (!gadget_is_dualspeed(gadget) ||\n\t\t\t    gadget->speed >= USB_SPEED_SUPER)\n\t\t\t\tbreak;\n\t\t\tdevice_qual(cdev);\n\t\t\tvalue = min_t(int, w_length,\n\t\t\t\tsizeof(struct usb_qualifier_descriptor));\n\t\t\tbreak;\n\t\tcase USB_DT_OTHER_SPEED_CONFIG:\n\t\t\tif (!gadget_is_dualspeed(gadget) ||\n\t\t\t    gadget->speed >= USB_SPEED_SUPER)\n\t\t\t\tbreak;\n\t\t\tfallthrough;\n\t\tcase USB_DT_CONFIG:\n\t\t\tvalue = config_desc(cdev, w_value);\n\t\t\tif (value >= 0)\n\t\t\t\tvalue = min(w_length, (u16) value);\n\t\t\tbreak;\n\t\tcase USB_DT_STRING:\n\t\t\tvalue = get_string(cdev, req->buf,\n\t\t\t\t\tw_index, w_value & 0xff);\n\t\t\tif (value >= 0)\n\t\t\t\tvalue = min(w_length, (u16) value);\n\t\t\tbreak;\n\t\tcase USB_DT_BOS:\n\t\t\tif (gadget_is_superspeed(gadget) ||\n\t\t\t    gadget->lpm_capable) {\n\t\t\t\tvalue = bos_desc(cdev);\n\t\t\t\tvalue = min(w_length, (u16) value);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase USB_DT_OTG:\n\t\t\tif (gadget_is_otg(gadget)) {\n\t\t\t\tstruct usb_configuration *config;\n\t\t\t\tint otg_desc_len = 0;\n\n\t\t\t\tif (cdev->config)\n\t\t\t\t\tconfig = cdev->config;\n\t\t\t\telse\n\t\t\t\t\tconfig = list_first_entry(\n\t\t\t\t\t\t\t&cdev->configs,\n\t\t\t\t\t\tstruct usb_configuration, list);\n\t\t\t\tif (!config)\n\t\t\t\t\tgoto done;\n\n\t\t\t\tif (gadget->otg_caps &&\n\t\t\t\t\t(gadget->otg_caps->otg_rev >= 0x0200))\n\t\t\t\t\totg_desc_len += sizeof(\n\t\t\t\t\t\tstruct usb_otg20_descriptor);\n\t\t\t\telse\n\t\t\t\t\totg_desc_len += sizeof(\n\t\t\t\t\t\tstruct usb_otg_descriptor);\n\n\t\t\t\tvalue = min_t(int, w_length, otg_desc_len);\n\t\t\t\tmemcpy(req->buf, config->descriptors[0], value);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\t\/* any number of configs can work *\/\n\tcase USB_REQ_SET_CONFIGURATION:\n\t\tif (ctrl->bRequestType != 0)\n\t\t\tgoto unknown;\n\t\tif (gadget_is_otg(gadget)) {\n\t\t\tif (gadget->a_hnp_support)\n\t\t\t\tDBG(cdev, \"HNP available\\n\");\n\t\t\telse if (gadget->a_alt_hnp_support)\n\t\t\t\tDBG(cdev, \"HNP on another port\\n\");\n\t\t\telse\n\t\t\t\tVDBG(cdev, \"HNP inactive\\n\");\n\t\t}\n\t\tspin_lock(&cdev->lock);\n\t\tvalue = set_config(cdev, ctrl, w_value);\n\t\tspin_unlock(&cdev->lock);\n\t\tbreak;\n\tcase USB_REQ_GET_CONFIGURATION:\n\t\tif (ctrl->bRequestType != USB_DIR_IN)\n\t\t\tgoto unknown;\n\t\tif (cdev->config)\n\t\t\t*(u8 *)req->buf = cdev->config->bConfigurationValue;\n\t\telse\n\t\t\t*(u8 *)req->buf = 0;\n\t\tvalue = min(w_length, (u16) 1);\n\t\tbreak;\n\n\t\/* function drivers must handle get\/set altsetting *\/\n\tcase USB_REQ_SET_INTERFACE:\n\t\tif (ctrl->bRequestType != USB_RECIP_INTERFACE)\n\t\t\tgoto unknown;\n\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\tbreak;\n\t\tf = cdev->config->interface[intf];\n\t\tif (!f)\n\t\t\tbreak;\n\n\t\t\/*\n\t\t * If there's no get_alt() method, we know only altsetting zero\n\t\t * works. There is no need to check if set_alt() is not NULL\n\t\t * as we check this in usb_add_function().\n\t\t *\/\n\t\tif (w_value && !f->get_alt)\n\t\t\tbreak;\n\n\t\tspin_lock(&cdev->lock);\n\t\tvalue = f->set_alt(f, w_index, w_value);\n\t\tif (value == USB_GADGET_DELAYED_STATUS) {\n\t\t\tDBG(cdev,\n\t\t\t \"%s: interface %d (%s) requested delayed status\\n\",\n\t\t\t\t\t__func__, intf, f->name);\n\t\t\tcdev->delayed_status++;\n\t\t\tDBG(cdev, \"delayed_status count %d\\n\",\n\t\t\t\t\tcdev->delayed_status);\n\t\t}\n\t\tspin_unlock(&cdev->lock);\n\t\tbreak;\n\tcase USB_REQ_GET_INTERFACE:\n\t\tif (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))\n\t\t\tgoto unknown;\n\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\tbreak;\n\t\tf = cdev->config->interface[intf];\n\t\tif (!f)\n\t\t\tbreak;\n\t\t\/* lots of interfaces only need altsetting zero... *\/\n\t\tvalue = f->get_alt ? f->get_alt(f, w_index) : 0;\n\t\tif (value < 0)\n\t\t\tbreak;\n\t\t*((u8 *)req->buf) = value;\n\t\tvalue = min(w_length, (u16) 1);\n\t\tbreak;\n\tcase USB_REQ_GET_STATUS:\n\t\tif (gadget_is_otg(gadget) && gadget->hnp_polling_support &&\n\t\t\t\t\t\t(w_index == OTG_STS_SELECTOR)) {\n\t\t\tif (ctrl->bRequestType != (USB_DIR_IN |\n\t\t\t\t\t\t\tUSB_RECIP_DEVICE))\n\t\t\t\tgoto unknown;\n\t\t\t*((u8 *)req->buf) = gadget->host_request_flag;\n\t\t\tvalue = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * USB 3.0 additions:\n\t\t * Function driver should handle get_status request. If such cb\n\t\t * wasn't supplied we respond with default value = 0\n\t\t * Note: function driver should supply such cb only for the\n\t\t * first interface of the function\n\t\t *\/\n\t\tif (!gadget_is_superspeed(gadget))\n\t\t\tgoto unknown;\n\t\tif (ctrl->bRequestType != (USB_DIR_IN | USB_RECIP_INTERFACE))\n\t\t\tgoto unknown;\n\t\tvalue = 2;\t\/* This is the length of the get_status reply *\/\n\t\tput_unaligned_le16(0, req->buf);\n\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\tbreak;\n\t\tf = cdev->config->interface[intf];\n\t\tif (!f)\n\t\t\tbreak;\n\t\tstatus = f->get_status ? f->get_status(f) : 0;\n\t\tif (status < 0)\n\t\t\tbreak;\n\t\tput_unaligned_le16(status & 0x0000ffff, req->buf);\n\t\tbreak;\n\t\/*\n\t * Function drivers should handle SetFeature\/ClearFeature\n\t * (FUNCTION_SUSPEND) request. function_suspend cb should be supplied\n\t * only for the first interface of the function\n\t *\/\n\tcase USB_REQ_CLEAR_FEATURE:\n\tcase USB_REQ_SET_FEATURE:\n\t\tif (!gadget_is_superspeed(gadget))\n\t\t\tgoto unknown;\n\t\tif (ctrl->bRequestType != (USB_DIR_OUT | USB_RECIP_INTERFACE))\n\t\t\tgoto unknown;\n\t\tswitch (w_value) {\n\t\tcase USB_INTRF_FUNC_SUSPEND:\n\t\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\t\tbreak;\n\t\t\tf = cdev->config->interface[intf];\n\t\t\tif (!f)\n\t\t\t\tbreak;\n\t\t\tvalue = 0;\n\t\t\tif (f->func_suspend)\n\t\t\t\tvalue = f->func_suspend(f, w_index >> 8);\n\t\t\tif (value < 0) {\n\t\t\t\tERROR(cdev,\n\t\t\t\t      \"func_suspend() returned error %d\\n\",\n\t\t\t\t      value);\n\t\t\t\tvalue = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tdefault:\nunknown:\n\t\t\/*\n\t\t * OS descriptors handling\n\t\t *\/\n\t\tif (cdev->use_os_string && cdev->os_desc_config &&\n\t\t    (ctrl->bRequestType & USB_TYPE_VENDOR) &&\n\t\t    ctrl->bRequest == cdev->b_vendor_code) {\n\t\t\tstruct usb_configuration\t*os_desc_cfg;\n\t\t\tu8\t\t\t\t*buf;\n\t\t\tint\t\t\t\tinterface;\n\t\t\tint\t\t\t\tcount = 0;\n\n\t\t\treq = cdev->os_desc_req;\n\t\t\treq->context = cdev;\n\t\t\treq->complete = composite_setup_complete;\n\t\t\tbuf = req->buf;\n\t\t\tos_desc_cfg = cdev->os_desc_config;\n\t\t\tw_length = min_t(u16, w_length, USB_COMP_EP0_OS_DESC_BUFSIZ);\n\t\t\tmemset(buf, 0, w_length);\n\t\t\tbuf[5] = 0x01;\n\t\t\tswitch (ctrl->bRequestType & USB_RECIP_MASK) {\n\t\t\tcase USB_RECIP_DEVICE:\n\t\t\t\tif (w_index != 0x4 || (w_value >> 8))\n\t\t\t\t\tbreak;\n\t\t\t\tbuf[6] = w_index;\n\t\t\t\t\/* Number of ext compat interfaces *\/\n\t\t\t\tcount = count_ext_compat(os_desc_cfg);\n\t\t\t\tbuf[8] = count;\n\t\t\t\tcount *= 24; \/* 24 B\/ext compat desc *\/\n\t\t\t\tcount += 16; \/* header *\/\n\t\t\t\tput_unaligned_le32(count, buf);\n\t\t\t\tvalue = w_length;\n\t\t\t\tif (w_length > 0x10) {\n\t\t\t\t\tvalue = fill_ext_compat(os_desc_cfg, buf);\n\t\t\t\t\tvalue = min_t(u16, w_length, value);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase USB_RECIP_INTERFACE:\n\t\t\t\tif (w_index != 0x5 || (w_value >> 8))\n\t\t\t\t\tbreak;\n\t\t\t\tinterface = w_value & 0xFF;\n\t\t\t\tbuf[6] = w_index;\n\t\t\t\tcount = count_ext_prop(os_desc_cfg,\n\t\t\t\t\tinterface);\n\t\t\t\tput_unaligned_le16(count, buf + 8);\n\t\t\t\tcount = len_ext_prop(os_desc_cfg,\n\t\t\t\t\tinterface);\n\t\t\t\tput_unaligned_le32(count, buf);\n\t\t\t\tvalue = w_length;\n\t\t\t\tif (w_length > 0x0A) {\n\t\t\t\t\tvalue = fill_ext_prop(os_desc_cfg,\n\t\t\t\t\t\t\t      interface, buf);\n\t\t\t\t\tif (value >= 0)\n\t\t\t\t\t\tvalue = min_t(u16, w_length, value);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tgoto check_value;\n\t\t}\n\n\t\tVDBG(cdev,\n\t\t\t\"non-core control req%02x.%02x v%04x i%04x l%d\\n\",\n\t\t\tctrl->bRequestType, ctrl->bRequest,\n\t\t\tw_value, w_index, w_length);\n\n\t\t\/* functions always handle their interfaces and endpoints...\n\t\t * punt other recipients (other, WUSB, ...) to the current\n\t\t * configuration code.\n\t\t *\/\n\t\tif (cdev->config) {\n\t\t\tlist_for_each_entry(f, &cdev->config->functions, list)\n\t\t\t\tif (f->req_match &&\n\t\t\t\t    f->req_match(f, ctrl, false))\n\t\t\t\t\tgoto try_fun_setup;\n\t\t} else {\n\t\t\tstruct usb_configuration *c;\n\t\t\tlist_for_each_entry(c, &cdev->configs, list)\n\t\t\t\tlist_for_each_entry(f, &c->functions, list)\n\t\t\t\t\tif (f->req_match &&\n\t\t\t\t\t    f->req_match(f, ctrl, true))\n\t\t\t\t\t\tgoto try_fun_setup;\n\t\t}\n\t\tf = NULL;\n\n\t\tswitch (ctrl->bRequestType & USB_RECIP_MASK) {\n\t\tcase USB_RECIP_INTERFACE:\n\t\t\tif (!cdev->config || intf >= MAX_CONFIG_INTERFACES)\n\t\t\t\tbreak;\n\t\t\tf = cdev->config->interface[intf];\n\t\t\tbreak;\n\n\t\tcase USB_RECIP_ENDPOINT:\n\t\t\tif (!cdev->config)\n\t\t\t\tbreak;\n\t\t\tendp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);\n\t\t\tlist_for_each_entry(f, &cdev->config->functions, list) {\n\t\t\t\tif (test_bit(endp, f->endpoints))\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (&f->list == &cdev->config->functions)\n\t\t\t\tf = NULL;\n\t\t\tbreak;\n\t\t}\ntry_fun_setup:\n\t\tif (f && f->setup)\n\t\t\tvalue = f->setup(f, ctrl);\n\t\telse {\n\t\t\tstruct usb_configuration\t*c;\n\n\t\t\tc = cdev->config;\n\t\t\tif (!c)\n\t\t\t\tgoto done;\n\n\t\t\t\/* try current config's setup *\/\n\t\t\tif (c->setup) {\n\t\t\t\tvalue = c->setup(c, ctrl);\n\t\t\t\tgoto done;\n\t\t\t}\n\n\t\t\t\/* try the only function in the current config *\/\n\t\t\tif (!list_is_singular(&c->functions))\n\t\t\t\tgoto done;\n\t\t\tf = list_first_entry(&c->functions, struct usb_function,\n\t\t\t\t\t     list);\n\t\t\tif (f->setup)\n\t\t\t\tvalue = f->setup(f, ctrl);\n\t\t}\n\n\t\tgoto done;\n\t}\n\ncheck_value:\n\t\/* respond with data transfer before status phase? *\/\n\tif (value >= 0 && value != USB_GADGET_DELAYED_STATUS) {\n\t\treq->length = value;\n\t\treq->context = cdev;\n\t\treq->zero = value < w_length;\n\t\tvalue = composite_ep0_queue(cdev, req, GFP_ATOMIC);\n\t\tif (value < 0) {\n\t\t\tDBG(cdev, \"ep_queue --> %d\\n\", value);\n\t\t\treq->status = 0;\n\t\t\tcomposite_setup_complete(gadget->ep0, req);\n\t\t}\n\t} else if (value == USB_GADGET_DELAYED_STATUS && w_length != 0) {\n\t\tWARN(cdev,\n\t\t\t\"%s: Delayed status not supported for w_length != 0\",\n\t\t\t__func__);\n\t}\n\ndone:\n\t\/* device either stalls (value < 0) or reports success *\/\n\treturn value;\n}","target":1,"code_token_length":3542,"total_token_length":3778,"max_tokens_setting":4096}
+{"idx":361755,"func":"static int em28xx_usb_probe(struct usb_interface *intf,\n\t\t\t    const struct usb_device_id *id)\n{\n\tstruct usb_device *udev;\n\tstruct em28xx *dev = NULL;\n\tint retval;\n\tbool has_vendor_audio = false, has_video = false, has_dvb = false;\n\tint i, nr, try_bulk;\n\tconst int ifnum = intf->altsetting[0].desc.bInterfaceNumber;\n\tchar *speed;\n\n\tudev = usb_get_dev(interface_to_usbdev(intf));\n\n\t\/* Check to see next free device and mark as used *\/\n\tdo {\n\t\tnr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);\n\t\tif (nr >= EM28XX_MAXBOARDS) {\n\t\t\t\/* No free device slots *\/\n\t\t\tdev_err(&intf->dev,\n\t\t\t\t\"Driver supports up to %i em28xx boards.\\n\",\n\t\t\t       EM28XX_MAXBOARDS);\n\t\t\tretval = -ENOMEM;\n\t\t\tgoto err_no_slot;\n\t\t}\n\t} while (test_and_set_bit(nr, em28xx_devused));\n\n\t\/* Don't register audio interfaces *\/\n\tif (intf->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {\n\t\tdev_info(&intf->dev,\n\t\t\t\"audio device (%04x:%04x): interface %i, class %i\\n\",\n\t\t\tle16_to_cpu(udev->descriptor.idVendor),\n\t\t\tle16_to_cpu(udev->descriptor.idProduct),\n\t\t\tifnum,\n\t\t\tintf->altsetting[0].desc.bInterfaceClass);\n\n\t\tretval = -ENODEV;\n\t\tgoto err;\n\t}\n\n\t\/* allocate memory for our device state and initialize it *\/\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev) {\n\t\tretval = -ENOMEM;\n\t\tgoto err;\n\t}\n\n\t\/* compute alternate max packet sizes *\/\n\tdev->alt_max_pkt_size_isoc = kcalloc(intf->num_altsetting,\n\t\t\t\t\t     sizeof(dev->alt_max_pkt_size_isoc[0]),\n\t\t\t\t\t     GFP_KERNEL);\n\tif (!dev->alt_max_pkt_size_isoc) {\n\t\tkfree(dev);\n\t\tretval = -ENOMEM;\n\t\tgoto err;\n\t}\n\n\t\/* Get endpoints *\/\n\tfor (i = 0; i < intf->num_altsetting; i++) {\n\t\tint ep;\n\n\t\tfor (ep = 0;\n\t\t     ep < intf->altsetting[i].desc.bNumEndpoints;\n\t\t     ep++)\n\t\t\tem28xx_check_usb_descriptor(dev, udev, intf,\n\t\t\t\t\t\t    i, ep,\n\t\t\t\t\t\t    &has_vendor_audio,\n\t\t\t\t\t\t    &has_video,\n\t\t\t\t\t\t    &has_dvb);\n\t}\n\n\tif (!(has_vendor_audio || has_video || has_dvb)) {\n\t\tretval = -ENODEV;\n\t\tgoto err_free;\n\t}\n\n\tswitch (udev->speed) {\n\tcase USB_SPEED_LOW:\n\t\tspeed = \"1.5\";\n\t\tbreak;\n\tcase USB_SPEED_UNKNOWN:\n\tcase USB_SPEED_FULL:\n\t\tspeed = \"12\";\n\t\tbreak;\n\tcase USB_SPEED_HIGH:\n\t\tspeed = \"480\";\n\t\tbreak;\n\tdefault:\n\t\tspeed = \"unknown\";\n\t}\n\n\tdev_info(&intf->dev,\n\t\t\"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\\n\",\n\t\tudev->manufacturer ? udev->manufacturer : \"\",\n\t\tudev->product ? udev->product : \"\",\n\t\tspeed,\n\t\tle16_to_cpu(udev->descriptor.idVendor),\n\t\tle16_to_cpu(udev->descriptor.idProduct),\n\t\tifnum,\n\t\tintf->altsetting->desc.bInterfaceNumber);\n\n\t\/*\n\t * Make sure we have 480 Mbps of bandwidth, otherwise things like\n\t * video stream wouldn't likely work, since 12 Mbps is generally\n\t * not enough even for most Digital TV streams.\n\t *\/\n\tif (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {\n\t\tdev_err(&intf->dev, \"Device initialization failed.\\n\");\n\t\tdev_err(&intf->dev,\n\t\t\t\"Device must be connected to a high-speed USB 2.0 port.\\n\");\n\t\tretval = -ENODEV;\n\t\tgoto err_free;\n\t}\n\n\tkref_init(&dev->ref);\n\n\tdev->devno = nr;\n\tdev->model = id->driver_info;\n\tdev->alt   = -1;\n\tdev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);\n\tdev->has_video = has_video;\n\tdev->ifnum = ifnum;\n\n\tdev->ts = PRIMARY_TS;\n\tsnprintf(dev->name, 28, \"em28xx\");\n\tdev->dev_next = NULL;\n\n\tif (has_vendor_audio) {\n\t\tdev_info(&intf->dev,\n\t\t\t\"Audio interface %i found (Vendor Class)\\n\", ifnum);\n\t\tdev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;\n\t}\n\t\/* Checks if audio is provided by a USB Audio Class intf *\/\n\tfor (i = 0; i < udev->config->desc.bNumInterfaces; i++) {\n\t\tstruct usb_interface *uif = udev->config->interface[i];\n\n\t\tif (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {\n\t\t\tif (has_vendor_audio)\n\t\t\t\tdev_err(&intf->dev,\n\t\t\t\t\t\"em28xx: device seems to have vendor AND usb audio class interfaces !\\n\"\n\t\t\t\t\t\"\\t\\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\\n\");\n\t\t\tdev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (has_video)\n\t\tdev_info(&intf->dev, \"Video interface %i found:%s%s\\n\",\n\t\t\tifnum,\n\t\t\tdev->analog_ep_bulk ? \" bulk\" : \"\",\n\t\t\tdev->analog_ep_isoc ? \" isoc\" : \"\");\n\tif (has_dvb)\n\t\tdev_info(&intf->dev, \"DVB interface %i found:%s%s\\n\",\n\t\t\tifnum,\n\t\t\tdev->dvb_ep_bulk ? \" bulk\" : \"\",\n\t\t\tdev->dvb_ep_isoc ? \" isoc\" : \"\");\n\n\tdev->num_alt = intf->num_altsetting;\n\n\tif ((unsigned int)card[nr] < em28xx_bcount)\n\t\tdev->model = card[nr];\n\n\t\/* save our data pointer in this intf device *\/\n\tusb_set_intfdata(intf, dev);\n\n\t\/* allocate device struct and check if the device is a webcam *\/\n\tmutex_init(&dev->lock);\n\tretval = em28xx_init_dev(dev, udev, intf, nr);\n\tif (retval)\n\t\tgoto err_free;\n\n\tif (usb_xfer_mode < 0) {\n\t\tif (dev->is_webcam)\n\t\t\ttry_bulk = 1;\n\t\telse\n\t\t\ttry_bulk = 0;\n\t} else {\n\t\ttry_bulk = usb_xfer_mode > 0;\n\t}\n\n\t\/* Disable V4L2 if the device doesn't have a decoder or image sensor *\/\n\tif (has_video &&\n\t    dev->board.decoder == EM28XX_NODECODER &&\n\t    dev->em28xx_sensor == EM28XX_NOSENSOR) {\n\t\tdev_err(&intf->dev,\n\t\t\t\"Currently, V4L2 is not supported on this model\\n\");\n\t\thas_video = false;\n\t\tdev->has_video = false;\n\t}\n\n\tif (dev->board.has_dual_ts &&\n\t    (dev->tuner_type != TUNER_ABSENT || INPUT(0)->type)) {\n\t\t\/*\n\t\t * The logic with sets alternate is not ready for dual-tuners\n\t\t * which analog modes.\n\t\t *\/\n\t\tdev_err(&intf->dev,\n\t\t\t\"We currently don't support analog TV or stream capture on dual tuners.\\n\");\n\t\thas_video = false;\n\t}\n\n\t\/* Select USB transfer types to use *\/\n\tif (has_video) {\n\t\tif (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))\n\t\t\tdev->analog_xfer_bulk = 1;\n\t\tdev_info(&intf->dev, \"analog set to %s mode.\\n\",\n\t\t\tdev->analog_xfer_bulk ? \"bulk\" : \"isoc\");\n\t}\n\tif (has_dvb) {\n\t\tif (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))\n\t\t\tdev->dvb_xfer_bulk = 1;\n\t\tdev_info(&intf->dev, \"dvb set to %s mode.\\n\",\n\t\t\tdev->dvb_xfer_bulk ? \"bulk\" : \"isoc\");\n\t}\n\n\tif (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {\n\t\tkref_init(&dev->dev_next->ref);\n\n\t\tdev->dev_next->ts = SECONDARY_TS;\n\t\tdev->dev_next->alt   = -1;\n\t\tdev->dev_next->is_audio_only = has_vendor_audio &&\n\t\t\t\t\t\t!(has_video || has_dvb);\n\t\tdev->dev_next->has_video = false;\n\t\tdev->dev_next->ifnum = ifnum;\n\t\tdev->dev_next->model = id->driver_info;\n\n\t\tmutex_init(&dev->dev_next->lock);\n\t\tretval = em28xx_init_dev(dev->dev_next, udev, intf,\n\t\t\t\t\t dev->dev_next->devno);\n\t\tif (retval)\n\t\t\tgoto err_free;\n\n\t\tdev->dev_next->board.ir_codes = NULL; \/* No IR for 2nd tuner *\/\n\t\tdev->dev_next->board.has_ir_i2c = 0; \/* No IR for 2nd tuner *\/\n\n\t\tif (usb_xfer_mode < 0) {\n\t\t\tif (dev->dev_next->is_webcam)\n\t\t\t\ttry_bulk = 1;\n\t\t\telse\n\t\t\t\ttry_bulk = 0;\n\t\t} else {\n\t\t\ttry_bulk = usb_xfer_mode > 0;\n\t\t}\n\n\t\t\/* Select USB transfer types to use *\/\n\t\tif (has_dvb) {\n\t\t\tif (!dev->dvb_ep_isoc_ts2 ||\n\t\t\t    (try_bulk && dev->dvb_ep_bulk_ts2))\n\t\t\t\tdev->dev_next->dvb_xfer_bulk = 1;\n\t\t\tdev_info(&dev->intf->dev, \"dvb ts2 set to %s mode.\\n\",\n\t\t\t\t dev->dev_next->dvb_xfer_bulk ? \"bulk\" : \"isoc\");\n\t\t}\n\n\t\tdev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;\n\t\tdev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;\n\t\tdev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;\n\t\tdev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;\n\n\t\t\/* Configure hardware to support TS2*\/\n\t\tif (dev->dvb_xfer_bulk) {\n\t\t\t\/* The ep4 and ep5 are configured for BULK *\/\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x96);\n\t\t\tmdelay(100);\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x80);\n\t\t\tmdelay(100);\n\t\t} else {\n\t\t\t\/* The ep4 and ep5 are configured for ISO *\/\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x96);\n\t\t\tmdelay(100);\n\t\t\tem28xx_write_reg(dev, 0x0b, 0x82);\n\t\t\tmdelay(100);\n\t\t}\n\t}\n\n\trequest_modules(dev);\n\n\t\/*\n\t * Do it at the end, to reduce dynamic configuration changes during\n\t * the device init. Yet, as request_modules() can be async, the\n\t * topology will likely change after the load of the em28xx subdrivers.\n\t *\/\n#ifdef CONFIG_MEDIA_CONTROLLER\n\tretval = media_device_register(dev->media_dev);\n#endif\n\n\treturn 0;\n\nerr_free:\n\tkfree(dev->alt_max_pkt_size_isoc);\n\tkfree(dev);\n\nerr:\n\tclear_bit(nr, em28xx_devused);\n\nerr_no_slot:\n\tusb_put_dev(udev);\n\treturn retval;\n}","target":0,"code_token_length":2598,"total_token_length":2834,"max_tokens_setting":4096}
+{"idx":359841,"func":"static Image *SparseColorOption(const Image *image,\n  const SparseColorMethod method,const char *arguments,ExceptionInfo *exception)\n{\n  char\n    token[MagickPathExtent];\n\n  const char\n    *p;\n\n  double\n    *sparse_arguments;\n\n  Image\n    *sparse_image;\n\n  PixelInfo\n    color;\n\n  MagickBooleanType\n    error;\n\n  size_t\n    x;\n\n  size_t\n    number_arguments,\n    number_colors;\n\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  \/*\n    Limit channels according to image\n    add up number of values needed per color.\n  *\/\n  number_colors=0;\n  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)\n    number_colors++;\n  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)\n    number_colors++;\n  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)\n    number_colors++;\n  if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&\n      (image->colorspace == CMYKColorspace))\n    number_colors++;\n  if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&\n      image->alpha_trait != UndefinedPixelTrait)\n    number_colors++;\n\n  \/*\n    Read string, to determine number of arguments needed,\n  *\/\n  p=arguments;\n  x=0;\n  while( *p != '\\0' )\n  {\n    (void) GetNextToken(p,&p,MagickPathExtent,token);\n    if (*token == ',') continue;\n    if ( isalpha((int) ((unsigned char) *token)) || *token == '#' )\n      x += number_colors;  \/* color argument found *\/\n    else\n      x++;   \/* floating point argument *\/\n  }\n  \/* control points and color values *\/\n  if ((x % (2+number_colors)) != 0)\n    {\n      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n        \"InvalidArgument\",\"'%s': %s\", \"sparse-color\",\n        \"Invalid number of Arguments\");\n      return( (Image *) NULL);\n    }\n  error=MagickFalse;\n  number_arguments=x;\n\n  \/* Allocate and fill in the floating point arguments *\/\n  sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,\n    sizeof(*sparse_arguments));\n  if (sparse_arguments == (double *) NULL) {\n    (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,\n      \"MemoryAllocationFailed\",\"%s\",\"SparseColorOption\");\n    return( (Image *) NULL);\n  }\n  (void) memset(sparse_arguments,0,number_arguments*\n    sizeof(*sparse_arguments));\n  p=arguments;\n  x=0;\n  while ((*p != '\\0') && (x < number_arguments))\n  {\n    \/* X coordinate *\/\n    *token=',';\n    while (*token == ',')\n      (void) GetNextToken(p,&p,MagickPathExtent,token);\n    if (*token == '\\0')\n      break;\n    if ( isalpha((int) ((unsigned char) *token)) || *token == '#' ) {\n      (void) ThrowMagickException(exception,GetMagickModule(),\n            OptionError, \"InvalidArgument\", \"'%s': %s\", \"sparse-color\",\n            \"Color found, instead of X-coord\");\n      error=MagickTrue;\n      break;\n    }\n    sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n    \/* Y coordinate *\/\n    *token=',';\n    while (*token == ',')\n      (void) GetNextToken(p,&p,MagickPathExtent,token);\n    if (*token == '\\0')\n      break;\n    if ( isalpha((int) ((unsigned char) *token)) || *token == '#' ) {\n      (void) ThrowMagickException(exception,GetMagickModule(),\n            OptionError, \"InvalidArgument\", \"'%s': %s\", \"sparse-color\",\n            \"Color found, instead of Y-coord\");\n      error=MagickTrue;\n      break;\n    }\n    sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n    \/* color name or function given in string argument *\/\n    *token=',';\n    while (*token == ',')\n      (void) GetNextToken(p,&p,MagickPathExtent,token);\n    if (*token == '\\0') break;\n    if ( isalpha((int) ((unsigned char) *token)) || *token == '#' ) {\n      \/* Color string given *\/\n      (void) QueryColorCompliance(token,AllCompliance,&color,\n                exception);\n      if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)\n        sparse_arguments[x++] = QuantumScale*color.red;\n      if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)\n        sparse_arguments[x++] = QuantumScale*color.green;\n      if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)\n        sparse_arguments[x++] = QuantumScale*color.blue;\n      if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&\n          (image->colorspace == CMYKColorspace))\n        sparse_arguments[x++] = QuantumScale*color.black;\n      if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&\n          image->alpha_trait != UndefinedPixelTrait)\n        sparse_arguments[x++] = QuantumScale*color.alpha;\n    }\n    else {\n      \/* Colors given as a set of floating point values - experimental *\/\n      \/* NB: token contains the first floating point value to use! *\/\n      if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)\n        {\n          while (*token == ',')\n            (void) GetNextToken(p,&p,MagickPathExtent,token);\n          if ((*token == '\\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' )\n            break;\n          sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n          *token=','; \/* used this token - get another *\/\n        }\n      if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)\n        {\n          while (*token == ',')\n            (void) GetNextToken(p,&p,MagickPathExtent,token);\n          if ((*token == '\\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' )\n            break;\n          sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n          *token=','; \/* used this token - get another *\/\n        }\n      if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)\n        {\n          while (*token == ',')\n           (void) GetNextToken(p,&p,MagickPathExtent,token);\n          if ((*token == '\\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' )\n            break;\n          sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n          *token = ','; \/* used this token - get another *\/\n        }\n      if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&\n          (image->colorspace == CMYKColorspace))\n        {\n          while (*token == ',')\n            (void) GetNextToken(p,&p,MagickPathExtent,token);\n          if ((*token == '\\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' )\n            break;\n          sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n          *token=','; \/* used this token - get another *\/\n        }\n      if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&\n          image->alpha_trait != UndefinedPixelTrait)\n        {\n          while (*token == ',')\n            (void) GetNextToken(p,&p,MagickPathExtent,token);\n          if ((*token == '\\0') || isalpha((int) ((unsigned char) *token)) || *token == '#' )\n            break;\n          sparse_arguments[x++]=StringToDouble(token,(char **) NULL);\n          *token = ','; \/* used this token - get another *\/\n        }\n    }\n  }\n  if (error != MagickFalse)\n    {\n      sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);\n      return((Image *) NULL);\n    }\n  if (number_arguments != x)\n    {\n      sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);\n      (void) ThrowMagickException(exception,GetMagickModule(),OptionError,\n        \"InvalidArgument\",\"'%s': %s\",\"sparse-color\",\"Argument Parsing Error\");\n      return((Image *) NULL);\n    }\n  \/* Call the Sparse Color Interpolation function with the parsed arguments *\/\n  sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,\n    exception);\n  sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);\n  return( sparse_image );\n}","target":0,"code_token_length":1962,"total_token_length":2198,"max_tokens_setting":4096}
+{"idx":261419,"func":"int read_transform_unit(thread_context* tctx,\n                        int x0, int y0,        \/\/ position of TU in frame\n                        int xBase, int yBase,  \/\/ position of parent TU in frame\n                        int xCUBase,int yCUBase,  \/\/ position of CU in frame\n                        int log2TrafoSize,\n                        int trafoDepth,\n                        int blkIdx,\n                        int cbf_luma, int cbf_cb, int cbf_cr)\n{\n  logtrace(LogSlice,\"- read_transform_unit x0:%d y0:%d xBase:%d yBase:%d nT:%d cbf:%d:%d:%d\\n\",\n           x0,y0,xBase,yBase, 1<<log2TrafoSize, cbf_luma, cbf_cb, cbf_cr);\n\n  assert(cbf_cb != -1);\n  assert(cbf_cr != -1);\n  assert(cbf_luma != -1);\n\n  const seq_parameter_set& sps = tctx->img->get_sps();\n\n  const int ChromaArrayType = sps.ChromaArrayType;\n\n  int log2TrafoSizeC = (ChromaArrayType==CHROMA_444 ? log2TrafoSize : log2TrafoSize-1);\n  log2TrafoSizeC = libde265_max(2, log2TrafoSizeC);\n\n  const int cbfLuma   = cbf_luma;\n  const int cbfChroma = cbf_cb | cbf_cr;\n\n  tctx->transform_skip_flag[0]=0;\n  tctx->transform_skip_flag[1]=0;\n  tctx->transform_skip_flag[2]=0;\n\n  tctx->explicit_rdpcm_flag = false;\n\n\n  enum PredMode cuPredMode = tctx->img->get_pred_mode(x0,y0);\n\n  if (cbfLuma || cbfChroma)\n    {\n      bool doDecodeQuantParameters = false;\n\n      if (tctx->img->get_pps().cu_qp_delta_enabled_flag &&\n          !tctx->IsCuQpDeltaCoded) {\n\n        int cu_qp_delta_abs = decode_cu_qp_delta_abs(tctx);\n        int cu_qp_delta_sign=0;\n        if (cu_qp_delta_abs) {\n          cu_qp_delta_sign = decode_CABAC_bypass(&tctx->cabac_decoder);\n        }\n\n        tctx->IsCuQpDeltaCoded = 1;\n        tctx->CuQpDelta = cu_qp_delta_abs*(1-2*cu_qp_delta_sign);\n\n        \/\/printf(\"read cu_qp_delta (%d;%d) = %d\\n\",x0,y0,tctx->CuQpDelta);\n\n        logtrace(LogSlice,\"cu_qp_delta_abs = %d\\n\",cu_qp_delta_abs);\n        logtrace(LogSlice,\"cu_qp_delta_sign = %d\\n\",cu_qp_delta_sign);\n        logtrace(LogSlice,\"CuQpDelta = %d\\n\",tctx->CuQpDelta);\n\n        doDecodeQuantParameters = true;\n        \/\/decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);\n      }\n\n      if (tctx->shdr->cu_chroma_qp_offset_enabled_flag && cbfChroma &&\n          !tctx->cu_transquant_bypass_flag && !tctx->IsCuChromaQpOffsetCoded ) {\n        logtrace(LogSlice,\"# cu_chroma_qp_offset_flag\\n\");\n\n        int cu_chroma_qp_offset_flag = decode_CABAC_bit(&tctx->cabac_decoder,\n                                                        &tctx->ctx_model[CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG]);\n\n\n        const pic_parameter_set& pps = tctx->img->get_pps();\n\n        int cu_chroma_qp_offset_idx = 0;\n        if (cu_chroma_qp_offset_flag && pps.range_extension.chroma_qp_offset_list_len > 1) {\n          cu_chroma_qp_offset_idx = decode_CABAC_bit(&tctx->cabac_decoder,\n                                                     &tctx->ctx_model[CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX]);\n        }\n\n        tctx->IsCuChromaQpOffsetCoded = 1;\n\n        if (cu_chroma_qp_offset_flag) {\n          tctx->CuQpOffsetCb = pps.range_extension.cb_qp_offset_list[ cu_chroma_qp_offset_idx ];\n          tctx->CuQpOffsetCr = pps.range_extension.cr_qp_offset_list[ cu_chroma_qp_offset_idx ];\n        }\n        else {\n          tctx->CuQpOffsetCb = 0;\n          tctx->CuQpOffsetCr = 0;\n        }\n\n        doDecodeQuantParameters = true;\n        \/\/decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);\n      }\n\n\n      if (doDecodeQuantParameters) {\n        decode_quantization_parameters(tctx, x0,y0, xCUBase, yCUBase);\n      }\n    }\n\n  \/\/ position of TU in local CU\n  int xL = x0 - xCUBase;\n  int yL = y0 - yCUBase;\n  int nT = 1<<log2TrafoSize;\n  int nTC = 1<<log2TrafoSizeC;\n\n  const int SubWidthC  = sps.SubWidthC;\n  const int SubHeightC = sps.SubHeightC;\n\n  \/\/ --- luma ---\n\n  tctx->ResScaleVal = 0;\n\n  int err;\n  if (cbf_luma) {\n    if ((err=residual_coding(tctx,x0,y0, log2TrafoSize,0)) != DE265_OK) return err;\n  }\n\n  decode_TU(tctx, x0,y0, xCUBase,yCUBase, nT, 0, cuPredMode, cbf_luma);\n\n\n  \/\/ --- chroma ---\n\n  const int yOffset422 = 1<<log2TrafoSizeC;\n\n  if (log2TrafoSize>2 || ChromaArrayType == CHROMA_444) {\n    \/\/ TODO: cross-component prediction\n\n    const bool do_cross_component_prediction =\n      (tctx->img->get_pps().range_extension.cross_component_prediction_enabled_flag &&\n       cbf_luma &&\n       (cuPredMode == MODE_INTER || tctx->img->is_IntraPredModeC_Mode4(x0,y0)));\n\n    if (do_cross_component_prediction) {\n      read_cross_comp_pred(tctx, 0);\n    }\n    else {\n      tctx->ResScaleVal = 0;\n    }\n\n    {\n      if (cbf_cb & 1) {\n        if ((err=residual_coding(tctx,x0,y0,log2TrafoSizeC,1)) != DE265_OK) return err;\n      }\n\n      if (sps.ChromaArrayType != CHROMA_MONO) {\n        decode_TU(tctx,\n                  x0\/SubWidthC,y0\/SubHeightC,\n                  xCUBase\/SubWidthC,yCUBase\/SubHeightC, nTC, 1, cuPredMode, cbf_cb & 1);\n      }\n    }\n\n    \/\/ 4:2:2\n    if (ChromaArrayType == CHROMA_422) {\n      const int yOffset = 1<<log2TrafoSizeC;\n\n      if (cbf_cb & 2) {\n        if ((err=residual_coding(tctx,\n                                 x0,y0+yOffset*SubHeightC,\n                                 log2TrafoSizeC,1)) != DE265_OK) return err;\n      }\n\n      decode_TU(tctx,\n                x0\/SubWidthC,y0\/SubHeightC + yOffset,\n                xCUBase\/SubWidthC,yCUBase\/SubHeightC +yOffset,\n                nTC, 1, cuPredMode, cbf_cb & 2);\n    }\n\n\n    if (do_cross_component_prediction) {\n      read_cross_comp_pred(tctx, 1);\n    }\n    else {\n      tctx->ResScaleVal = 0;\n    }\n\n    {\n      if (cbf_cr & 1) {\n        if ((err=residual_coding(tctx,x0,y0,log2TrafoSizeC,2)) != DE265_OK) return err;\n      }\n\n      if (sps.ChromaArrayType != CHROMA_MONO) {\n        decode_TU(tctx,\n                  x0\/SubWidthC,y0\/SubHeightC,\n                  xCUBase\/SubWidthC,yCUBase\/SubHeightC,\n                  nTC, 2, cuPredMode, cbf_cr & 1);\n      }\n    }\n\n    \/\/ 4:2:2\n    if (ChromaArrayType == CHROMA_422) {\n      const int yOffset = 1<<log2TrafoSizeC;\n\n      if (cbf_cr & 2) {\n        if ((err=residual_coding(tctx,\n                                 x0,y0+yOffset*SubHeightC,\n                                 log2TrafoSizeC,2)) != DE265_OK) return err;\n      }\n\n      decode_TU(tctx,\n                x0\/SubWidthC,y0\/SubHeightC+yOffset,\n                xCUBase\/SubWidthC,yCUBase\/SubHeightC+yOffset,\n                nTC, 2, cuPredMode, cbf_cr & 2);\n    }\n  }\n  else if (blkIdx==3) {\n    if (cbf_cb & 1) {\n      if ((err=residual_coding(tctx,xBase,yBase,\n                               log2TrafoSize,1)) != DE265_OK) return err;\n    }\n\n    if (sps.ChromaArrayType != CHROMA_MONO) {\n      decode_TU(tctx,\n                xBase\/SubWidthC,  yBase\/SubHeightC,\n                xCUBase\/SubWidthC,yCUBase\/SubHeightC, nT, 1, cuPredMode, cbf_cb & 1);\n    }\n\n    \/\/ 4:2:2\n    if (cbf_cb & 2) {\n      if ((err=residual_coding(tctx,\n                               xBase        ,yBase        +(1<<log2TrafoSize),\n                               log2TrafoSize,1)) != DE265_OK) return err;\n    }\n\n    if (ChromaArrayType == CHROMA_422) {\n      decode_TU(tctx,\n                xBase\/SubWidthC,  yBase\/SubHeightC + (1<<log2TrafoSize),\n                xCUBase\/SubWidthC,yCUBase\/SubHeightC, nT, 1, cuPredMode, cbf_cb & 2);\n    }\n\n    if (cbf_cr & 1) {\n      if ((err=residual_coding(tctx,xBase,yBase,\n                               log2TrafoSize,2)) != DE265_OK) return err;\n    }\n\n    if (sps.ChromaArrayType != CHROMA_MONO) {\n      decode_TU(tctx,\n                xBase\/SubWidthC,  yBase\/SubHeightC,\n                xCUBase\/SubWidthC,yCUBase\/SubHeightC, nT, 2, cuPredMode, cbf_cr & 1);\n    }\n\n    \/\/ 4:2:2\n    if (cbf_cr & 2) {\n      if ((err=residual_coding(tctx,\n                               xBase        ,yBase        +(1<<log2TrafoSizeC),\n                               log2TrafoSize,2)) != DE265_OK) return err;\n    }\n\n    if (ChromaArrayType == CHROMA_422) {\n      decode_TU(tctx,\n                xBase\/SubWidthC,  yBase\/SubHeightC + (1<<log2TrafoSize),\n                xCUBase\/SubWidthC,yCUBase\/SubHeightC, nT, 2, cuPredMode, cbf_cr & 2);\n    }\n  }\n\n\n  return DE265_OK;\n}","target":0,"code_token_length":2529,"total_token_length":2765,"max_tokens_setting":4096}
+{"idx":246670,"func":"static Bool create_new_track_action(char *arg_val, u32 act_type, u32 dump_type)\n{\n\tTrackAction *tka;\n\tchar *param = arg_val;\n\ttracks = (TrackAction *)gf_realloc(tracks, sizeof(TrackAction) * (nb_track_act+1));\n\tif (!tracks) return GF_FALSE;\n\n\ttka = & tracks[nb_track_act];\n\tnb_track_act++;\n\n\tmemset(tka, 0, sizeof(TrackAction) );\n\ttka->act_type = act_type;\n\ttka->dump_type = dump_type;\n\tif (act_type != TRAC_ACTION_RAW_EXTRACT) {\n\t\topen_edit = GF_TRUE;\n\t\tdo_save = GF_TRUE;\n\t}\n\n\tif ((act_type==TRAC_ACTION_SET_ID) || (act_type==TRAC_ACTION_SWAP_ID)) {\n\t\tif (sscanf(param, \"%d:%u\", &tka->trackID, &tka->newTrackID) != 2) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for -set-track-id - expecting \\\"id1:id2\\\" got \\\"%s\\\"\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_PAR) {\n\t\tchar *ext;\n\t\text = strchr(param, '=');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track par - expecting tkID=none or tkID=PAR_NUM:PAR_DEN got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\n\t\tif (!stricmp(ext+1, \"none\"))\n\t\t\ttka->par_num = tka->par_den = 0;\n\t\telse if (!stricmp(ext+1, \"auto\")) {\n\t\t\ttka->par_num = tka->par_den = -1;\n\t\t\ttka->force_par = 1;\n\t\t}\n\t\telse if (!stricmp(ext+1, \"force\")) {\n\t\t\ttka->par_num = tka->par_den = 1;\n\t\t\ttka->force_par = 1;\n\t\t}\n\t\telse {\n\t\t\tif (ext[1]=='w') {\n\t\t\t\ttka->rewrite_bs = 1;\n\t\t\t\text++;\n\t\t\t}\n\t\t\tif (sscanf(ext+1, \"%d:%d\", &tka->par_num, &tka->par_den) != 2) {\n\t\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track par - expecting tkID=PAR_NUM:PAR_DEN got %s\\n\", param));\n\t\t\t\treturn GF_FALSE;\n\t\t\t}\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_CLAP) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track clap - expecting tkID=none or tkID=Wn,Wd,Hn,Hd,HOn,HOd,VOn,VOd got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\t\tif (stricmp(ext + 1, \"none\")) {\n\t\t\tif (sscanf(ext + 1, \"%d,%d,%d,%d,%d,%d,%d,%d\", &tka->clap_wnum, &tka->clap_wden, &tka->clap_hnum, &tka->clap_hden, &tka->clap_honum, &tka->clap_hoden, &tka->clap_vonum, &tka->clap_voden) != 8) {\n\n\t\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track clap - expecting tkID=none or tkID=Wn,Wd,Hn,Hd,HOn,HOd,VOn,VOd got %s\\n\", param));\n\t\t\t\treturn GF_FALSE;\n\t\t\t}\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\n\tif (act_type==TRAC_ACTION_SET_MX) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track matrix - expecting ID=none or ID=M1:M2:M3:M4:M5:M6:M7:M8:M9 got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\t\tif (!stricmp(ext + 1, \"none\")) {\n\t\t\tmemset(tka->mx, 0, sizeof(s32)*9);\n\t\t\ttka->mx[0] = tka->mx[4] = tka->mx[8] = 1;\n\t\t} else {\n\t\t\ts32 res;\n\t\t\tif (strstr(ext+1, \"0x\")) {\n\t\t\t\tres = sscanf(ext + 1, \"0x%d:0x%d:0x%d:0x%d:0x%d:0x%d:0x%d:0x%d:0x%d\", &tka->mx[0], &tka->mx[1], &tka->mx[2], &tka->mx[3], &tka->mx[4], &tka->mx[5], &tka->mx[6], &tka->mx[7], &tka->mx[8]);\n\t\t\t} else {\n\t\t\t\tres = sscanf(ext + 1, \"%d:%d:%d:%d:%d:%d:%d:%d:%d\", &tka->mx[0], &tka->mx[1], &tka->mx[2], &tka->mx[3], &tka->mx[4], &tka->mx[5], &tka->mx[6], &tka->mx[7], &tka->mx[8]);\n\t\t\t}\n\t\t\tif (res != 9) {\n\t\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track matrix - expecting ID=none or ID=M1:M2:M3:M4:M5:M6:M7:M8:M9 got %s\\n\", param));\n\t\t\t\treturn GF_FALSE;\n\t\t\t}\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_EDITS) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track edits - expecting ID=EDITS got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\t\ttka->string = gf_strdup(ext+1);\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_LANGUAGE) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!strnicmp(param, \"all=\", 4)) {\n\t\t\tstrncpy(tka->lang, param + 4, 10-1);\n\t\t}\n\t\telse if (!ext) {\n\t\t\tstrncpy(tka->lang, param, 10-1);\n\t\t} else {\n\t\t\tstrncpy(tka->lang, ext + 1, 10-1);\n\t\t\text[0] = 0;\n\t\t\ttka->trackID = atoi(param);\n\t\t\text[0] = '=';\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif ((act_type==TRAC_ACTION_SET_KIND) || (act_type==TRAC_ACTION_REM_KIND)) {\n\t\tchar *ext;\n\t\tchar *scheme_start = NULL;\n\n\t\t\/\/extract trackID\n\t\tif (!strnicmp(param, \"all=\", 4)) {\n\t\t\tscheme_start = param + 4;\n\t\t} else {\n\t\t\text = strchr(param, '=');\n\t\t\tif (ext) {\n\t\t\t\text[0] = 0;\n\t\t\t\tif (sscanf(param, \"%d\", &tka->trackID) == 1) {\n\t\t\t\t\tscheme_start = ext + 1;\n\t\t\t\t} else {\n\t\t\t\t\tscheme_start = param;\n\t\t\t\t}\n\t\t\t\text[0] = '=';\n\t\t\t} else {\n\t\t\t\tscheme_start = param;\n\t\t\t}\n\t\t}\n\n\t\t\/\/extract scheme and value - if not, remove kind\n\t\tif (!scheme_start || !scheme_start[0]) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Missing kind scheme - expecting ID=schemeURI=value got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t} else {\n\t\t\text = strchr(scheme_start, '=');\n\t\t\tif (!ext) {\n\t\t\t\ttka->kind_scheme = gf_strdup(scheme_start);\n\t\t\t} else {\n\t\t\t\text[0] = 0;\n\t\t\t\ttka->kind_scheme = gf_strdup(scheme_start);\n\t\t\t\text[0] = '=';\n\t\t\t\ttka->kind_value = gf_strdup(ext + 1);\n\t\t\t}\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_DELAY) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track delay - expecting tkID=DLAY got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\t\tif (sscanf(ext+1, \"%d\/%u\", &tka->delay.num, &tka->delay.den) != 2) {\n\t\t\ttka->delay.num = atoi(ext + 1);\n\t\t\ttka->delay.den = 1000;\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_REFERENCE) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!ext) ext = strchr(param, ':');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track reference - expecting tkID:XXXX:refID got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\n\t\tchar *ext2 = strchr(ext, ':');\n\t\tif (!ext2) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track reference - expecting tkID:XXXX:refID got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text2[0] = 0;\n\t\tstrncpy(tka->lang, ext+1, 9);\n\t\text2[0] = ':';\n\t\ttka->newTrackID = (s32) atoi(ext2 + 1);\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_HANDLER_NAME) {\n\t\tchar *ext = strchr(param, '=');\n\t\tif (!ext) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Bad format for track name - expecting tkID=name got %s\\n\", param));\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\text[0] = 0;\n\t\ttka->trackID = atoi(param);\n\t\text[0] = '=';\n\t\ttka->hdl_name = ext + 1;\n\t\treturn GF_TRUE;\n\t}\n\tif (act_type==TRAC_ACTION_SET_KMS_URI) {\n\t\tchar *ext = strchr(param, '=');\n\n\t\tif (!strnicmp(param, \"all=\", 4)) {\n\t\t\ttka->kms = param + 4;\n\t\t} else if (!ext) {\n\t\t\ttka->kms = param;\n\t\t} else {\n\t\t\ttka->kms = ext + 1;\n\t\t\text[0] = 0;\n\t\t\ttka->trackID = atoi(param);\n\t\t\text[0] = '=';\n\t\t}\n\t\treturn GF_TRUE;\n\t}\n\tif ((act_type==TRAC_ACTION_SET_TIME) || (act_type==TRAC_ACTION_SET_MEDIA_TIME)) {\n\t\tstruct tm time;\n\t\tchar *ext = strchr(arg_val, '=');\n\t\tif (ext) {\n\t\t\text[0] = 0;\n\t\t\ttka->trackID = atoi(arg_val);\n\t\t\text[0] = '=';\n\t\t\targ_val = ext+1;\n\t\t}\n\t\tmemset(&time, 0, sizeof(struct tm));\n\t\tsscanf(arg_val, \"%d\/%d\/%d-%d:%d:%d\", &time.tm_mday, &time.tm_mon, &time.tm_year, &time.tm_hour, &time.tm_min, &time.tm_sec);\n\t\ttime.tm_isdst = 0;\n\t\ttime.tm_year -= 1900;\n\t\ttime.tm_mon -= 1;\n\t\ttka->time = 2082758400;\n\t\ttka->time += mktime(&time);\n\t\treturn GF_TRUE;\n\t}\n\n\twhile (param) {\n\t\tparam = gf_url_colon_suffix(param);\n\t\tif (param) {\n\t\t\t*param = 0;\n\t\t\tparam++;\n#ifndef GPAC_DISABLE_MEDIA_EXPORT\n\t\t\tif (!strncmp(\"vttnomerge\", param, 10)) {\n\t\t\t\ttka->dump_type |= GF_EXPORT_WEBVTT_NOMERGE;\n\t\t\t} else if (!strncmp(\"layer\", param, 5)) {\n\t\t\t\ttka->dump_type |= GF_EXPORT_SVC_LAYER;\n\t\t\t} else if (!strncmp(\"full\", param, 4)) {\n\t\t\t\ttka->dump_type |= GF_EXPORT_NHML_FULL;\n\t\t\t} else if (!strncmp(\"embedded\", param, 8)) {\n\t\t\t\ttka->dump_type |= GF_EXPORT_WEBVTT_META_EMBEDDED;\n\t\t\t} else if (!strncmp(\"output=\", param, 7)) {\n\t\t\t\ttka->out_name = gf_strdup(param+7);\n\t\t\t} else if (!strncmp(\"src=\", param, 4)) {\n\t\t\t\ttka->src_name = gf_strdup(param+4);\n\t\t\t} else if (!strncmp(\"str=\", param, 4)) {\n\t\t\t\ttka->string = gf_strdup(param+4);\n\t\t\t} else if (!strncmp(\"box=\", param, 4)) {\n\t\t\t\ttka->src_name = gf_strdup(param+4);\n\t\t\t\ttka->sample_num = 1;\n\t\t\t} else if (!strncmp(\"type=\", param, 4)) {\n\t\t\t\ttka->udta_type = GF_4CC(param[5], param[6], param[7], param[8]);\n\t\t\t} else if (tka->dump_type == GF_EXPORT_RAW_SAMPLES) {\n\t\t\t\ttka->sample_num = atoi(param);\n\t\t\t}\n#endif\n\t\t}\n\t}\n\tif (arg_val) {\n\t\tif (!strcmp(arg_val, \"*\")) {\n\t\t\ttka->trackID = (u32) -1;\n\t\t} else {\n\t\t\tif (act_type==TRAC_ACTION_RAW_EXTRACT) {\n\t\t\t\tif (!strncmp(arg_val, \"video\", 5)) {\n\t\t\t\t\targ_val += 5;\n\t\t\t\t\ttka->dump_track_type = 1;\n\t\t\t\t}\n\t\t\t\telse if (!strncmp(arg_val, \"audio\", 5)) {\n\t\t\t\t\targ_val += 5;\n\t\t\t\t\ttka->dump_track_type = 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (arg_val[0])\n\t\t\t\ttka->trackID = atoi(arg_val);\n\t\t}\n\t}\n\treturn GF_TRUE;\n}","target":0,"code_token_length":3300,"total_token_length":3536,"max_tokens_setting":4096}
+{"idx":343298,"func":"void dostor(char *name, const int append, const int autorename)\n{\n    ULHandler ulhandler;\n    int f;\n    const char *ul_name = NULL;\n    const char *atomic_file = NULL;\n    off_t filesize = (off_t) 0U;\n    struct stat st;\n    double started = 0.0;\n    signed char overwrite = 0;\n    int overflow = 0;\n    int ret = -1;\n    off_t max_filesize = (off_t) -1;\n#ifdef QUOTAS\n    Quota quota;\n#endif\n    const char *name2 = NULL;\n\n    if (type < 1 || (type == 1 && restartat > (off_t) 1)) {\n        addreply_noformat(503, MSG_NO_ASCII_RESUME);\n        goto end;\n    }\n#ifndef ANON_CAN_RESUME\n    if (guest != 0 && anon_noupload != 0) {\n        addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);\n        goto end;\n    }\n#endif\n    if (ul_check_free_space(name, -1.0) == 0) {\n        addreply_noformat(552, MSG_NO_DISK_SPACE);\n        goto end;\n    }\n    if (checknamesanity(name, dot_write_ok) != 0) {\n        addreply(553, MSG_SANITY_FILE_FAILURE, name);\n        goto end;\n    }\n    if (autorename != 0) {\n        no_truncate = 1;\n    }\n    if (restartat > (off_t) 0 || no_truncate != 0) {\n        if ((atomic_file = get_atomic_file(name)) == NULL) {\n            addreply(553, MSG_SANITY_FILE_FAILURE, name);\n            goto end;\n        }\n        if (restartat > (off_t) 0 &&\n            rename(name, atomic_file) != 0 && errno != ENOENT) {\n            error(553, MSG_RENAME_FAILURE);\n            atomic_file = NULL;\n            goto end;\n        }\n    }\n    if (atomic_file != NULL) {\n        ul_name = atomic_file;\n    } else {\n        ul_name = name;\n    }\n    if (atomic_file == NULL &&\n        (f = open(ul_name, O_WRONLY | O_NOFOLLOW)) != -1) {\n        overwrite++;\n    } else if ((f = open(ul_name, O_CREAT | O_WRONLY | O_NOFOLLOW,\n                         (mode_t) 0777 & ~u_mask)) == -1) {\n        error(553, MSG_OPEN_FAILURE2);\n        goto end;\n    }\n    if (fstat(f, &st) < 0) {\n        (void) close(f);\n        error(553, MSG_STAT_FAILURE2);\n        goto end;\n    }\n    if (!S_ISREG(st.st_mode)) {\n        (void) close(f);\n        addreply_noformat(550, MSG_NOT_REGULAR_FILE);\n        goto end;\n    }\n    alarm(MAX_SESSION_XFER_IDLE);\n\n    \/* Anonymous users *CAN* overwrite 0-bytes files - This is the right behavior *\/\n    if (st.st_size > (off_t) 0) {\n#ifndef ANON_CAN_RESUME\n        if (guest != 0) {\n            addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);\n            (void) close(f);\n            goto end;\n        }\n#endif\n        if (append != 0) {\n            restartat = st.st_size;\n        }\n    } else {\n        restartat = (off_t) 0;\n    }\n    if (restartat > st.st_size) {\n        restartat = st.st_size;\n    }\n    if (restartat > (off_t) 0 && lseek(f, restartat, SEEK_SET) < (off_t) 0) {\n        (void) close(f);\n        error(451, \"seek\");\n        goto end;\n    }\n    if (restartat < st.st_size) {\n        if (ftruncate(f, restartat) < 0) {\n            (void) close(f);\n            error(451, \"ftruncate\");\n            goto end;\n        }\n#ifdef QUOTAS\n        if (restartat != st.st_size) {\n            (void) quota_update(NULL, 0LL,\n                                (long long) (restartat - st.st_size),\n                                &overflow);\n        }\n#endif\n    }\n#ifdef QUOTAS\n    if (quota_update("a, 0LL, 0LL, &overflow) == 0 &&\n        (overflow > 0 || quota.files >= user_quota_files ||\n         quota.size > user_quota_size ||\n         (max_filesize = user_quota_size - quota.size) < (off_t) 0)) {\n        overflow = 1;\n        (void) close(f);\n        goto afterquota;\n    }\n#endif\n    opendata();\n    if (xferfd == -1) {\n        (void) close(f);\n        goto end;\n    }\n    doreply();\n# ifdef WITH_TLS\n    if (data_protection_level == CPL_PRIVATE) {\n        tls_init_data_session(xferfd, passive);\n    }\n# endif\n    state_needs_update = 1;\n    setprocessname(\"pure-ftpd (UPLOAD)\");\n    filesize = restartat;\n\n#ifdef FTPWHO\n    if (shm_data_cur != NULL) {\n        const size_t sl = strlen(name);\n\n        ftpwho_lock();\n        shm_data_cur->state = FTPWHO_STATE_UPLOAD;\n        shm_data_cur->download_total_size = (off_t) 0U;\n        shm_data_cur->download_current_size = (off_t) filesize;\n        shm_data_cur->restartat = restartat;\n        (void) time(&shm_data_cur->xfer_date);\n        if (sl < sizeof shm_data_cur->filename) {\n            memcpy(shm_data_cur->filename, name, sl);\n            shm_data_cur->filename[sl] = 0;\n        } else {\n            memcpy(shm_data_cur->filename,\n                   &name[sl - sizeof shm_data_cur->filename - 1U],\n                   sizeof shm_data_cur->filename);\n        }\n        ftpwho_unlock();\n    }\n#endif\n\n    \/* Here starts the real upload code *\/\n\n    started = get_usec_time();\n\n    if (ul_init(&ulhandler, clientfd, tls_cnx, xferfd, name, f, tls_data_cnx,\n                restartat, type == 1, throttling_bandwidth_ul,\n                max_filesize) == 0) {\n        ret = ul_send(&ulhandler);\n        ul_exit(&ulhandler);\n    } else {\n        ret = -1;\n    }\n    (void) close(f);\n    closedata();\n\n    \/* Here ends the real upload code *\/\n\n#ifdef SHOW_REAL_DISK_SPACE\n    if (FSTATFS(f, &statfsbuf) == 0) {\n        double space;\n\n        space = (double) STATFS_BAVAIL(statfsbuf) *\n            (double) STATFS_FRSIZE(statfsbuf);\n        if (space > 524288.0) {\n            addreply(0, MSG_SPACE_FREE_M, space \/ 1048576.0);\n        } else {\n            addreply(0, MSG_SPACE_FREE_K, space \/ 1024.0);\n        }\n    }\n#endif\n\n    uploaded += (unsigned long long) ulhandler.total_uploaded;\n    {\n        off_t atomic_file_size;\n        off_t original_file_size;\n        int files_count;\n\n        if (overwrite == 0) {\n            files_count = 1;\n        } else {\n            files_count = 0;\n        }\n        if (autorename != 0 && restartat == (off_t) 0) {\n            if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {\n                goto afterquota;\n            }\n            if (tryautorename(atomic_file, name, &name2) != 0) {\n                error(553, MSG_RENAME_FAILURE);\n                goto afterquota;\n            } else {\n#ifdef QUOTAS\n                ul_quota_update(name2 ? name2 : name, 1, atomic_file_size);\n#endif\n                atomic_file = NULL;\n            }\n        } else if (atomic_file != NULL) {\n            if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {\n                goto afterquota;\n            }\n            if ((original_file_size = get_file_size(name)) < (off_t) 0 ||\n                restartat > original_file_size) {\n                original_file_size = restartat;\n            }\n            if (rename(atomic_file, name) != 0) {\n                error(553, MSG_RENAME_FAILURE);\n                goto afterquota;\n            } else {\n#ifdef QUOTAS\n                overflow = ul_quota_update\n                    (name, files_count, atomic_file_size - original_file_size);\n#endif\n                atomic_file = NULL;\n            }\n        } else {\n#ifdef QUOTAS\n            overflow = ul_quota_update\n                (name, files_count, ulhandler.total_uploaded);\n#endif\n        }\n    }\n    afterquota:\n    if (overflow > 0) {\n        addreply(552, MSG_QUOTA_EXCEEDED, name);\n    } else {\n        if (ret == 0) {\n            addreply_noformat(226, MSG_TRANSFER_SUCCESSFUL);\n        } else {\n            addreply_noformat(451, MSG_ABORTED);\n        }\n        displayrate(MSG_UPLOADED, ulhandler.total_uploaded, started,\n                    name2 ? name2 : name, 1);\n    }\n    end:\n    restartat = (off_t) 0;\n    if (atomic_file != NULL) {\n        unlink(atomic_file);\n        atomic_file = NULL;\n    }\n}","target":0,"code_token_length":2089,"total_token_length":2325,"max_tokens_setting":4096}
+{"idx":364746,"func":"jumpto_tag(\n    char_u\t*lbuf_arg,\t\/\/ line from the tags file for this tag\n    int\t\tforceit,\t\/\/ :ta with !\n    int\t\tkeep_help)\t\/\/ keep help flag (FALSE for cscope)\n{\n    optmagic_T\tsave_magic_overruled;\n    int\t\tsave_p_ws, save_p_scs, save_p_ic;\n    linenr_T\tsave_lnum;\n    char_u\t*str;\n    char_u\t*pbuf;\t\t\t\/\/ search pattern buffer\n    char_u\t*pbuf_end;\n    char_u\t*tofree_fname = NULL;\n    char_u\t*fname;\n    tagptrs_T\ttagp;\n    int\t\tretval = FAIL;\n    int\t\tgetfile_result = GETFILE_UNUSED;\n    int\t\tsearch_options;\n#ifdef FEAT_SEARCH_EXTRA\n    int\t\tsave_no_hlsearch;\n#endif\n#if defined(FEAT_QUICKFIX)\n    win_T\t*curwin_save = NULL;\n#endif\n    char_u\t*full_fname = NULL;\n#ifdef FEAT_FOLDING\n    int\t\told_KeyTyped = KeyTyped;    \/\/ getting the file may reset it\n#endif\n    size_t\tlen;\n    char_u\t*lbuf;\n\n    \/\/ Make a copy of the line, it can become invalid when an autocommand calls\n    \/\/ back here recursively.\n    len = matching_line_len(lbuf_arg) + 1;\n    lbuf = alloc(len);\n    if (lbuf != NULL)\n\tmch_memmove(lbuf, lbuf_arg, len);\n\n    pbuf = alloc(LSIZE);\n\n    \/\/ parse the match line into the tagp structure\n    if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL)\n    {\n\ttagp.fname_end = NULL;\n\tgoto erret;\n    }\n\n    \/\/ truncate the file name, so it can be used as a string\n    *tagp.fname_end = NUL;\n    fname = tagp.fname;\n\n    \/\/ copy the command to pbuf[], remove trailing CR\/NL\n    str = tagp.command;\n    for (pbuf_end = pbuf; *str && *str != '\\n' && *str != '\\r'; )\n    {\n#ifdef FEAT_EMACS_TAGS\n\tif (tagp.is_etag && *str == ',')\/\/ stop at ',' after line number\n\t    break;\n#endif\n\t*pbuf_end++ = *str++;\n\tif (pbuf_end - pbuf + 1 >= LSIZE)\n\t    break;\n    }\n    *pbuf_end = NUL;\n\n#ifdef FEAT_EMACS_TAGS\n    if (!tagp.is_etag)\n#endif\n    {\n\t\/*\n\t * Remove the \"<Tab>fieldname:value\" stuff; we don't need it here.\n\t *\/\n\tstr = pbuf;\n\tif (find_extra(&str) == OK)\n\t{\n\t    pbuf_end = str;\n\t    *pbuf_end = NUL;\n\t}\n    }\n\n    \/*\n     * Expand file name, when needed (for environment variables).\n     * If 'tagrelative' option set, may change file name.\n     *\/\n    fname = expand_tag_fname(fname, tagp.tag_fname, TRUE);\n    if (fname == NULL)\n\tgoto erret;\n    tofree_fname = fname;\t\/\/ free() it later\n\n    \/*\n     * Check if the file with the tag exists before abandoning the current\n     * file.  Also accept a file name for which there is a matching BufReadCmd\n     * autocommand event (e.g., http:\/\/sys\/file).\n     *\/\n    if (mch_getperm(fname) < 0 && !has_autocmd(EVENT_BUFREADCMD, fname, NULL))\n    {\n\tretval = NOTAGFILE;\n\tvim_free(nofile_fname);\n\tnofile_fname = vim_strsave(fname);\n\tif (nofile_fname == NULL)\n\t    nofile_fname = empty_option;\n\tgoto erret;\n    }\n\n    ++RedrawingDisabled;\n\n#ifdef FEAT_GUI\n    need_mouse_correct = TRUE;\n#endif\n\n#if defined(FEAT_QUICKFIX)\n    if (g_do_tagpreview != 0)\n    {\n\tpostponed_split = 0;\t\/\/ don't split again below\n\tcurwin_save = curwin;\t\/\/ Save current window\n\n\t\/*\n\t * If we are reusing a window, we may change dir when\n\t * entering it (autocommands) so turn the tag filename\n\t * into a fullpath\n\t *\/\n\tif (!curwin->w_p_pvw)\n\t{\n\t    full_fname = FullName_save(fname, FALSE);\n\t    fname = full_fname;\n\n\t    \/*\n\t     * Make the preview window the current window.\n\t     * Open a preview window when needed.\n\t     *\/\n\t    prepare_tagpreview(TRUE, TRUE, FALSE);\n\t}\n    }\n\n    \/\/ If it was a CTRL-W CTRL-] command split window now.  For \":tab tag\"\n    \/\/ open a new tab page.\n    if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB)))\n    {\n\tbuf_T *existing_buf = buflist_findname_exp(fname);\n\n\tif (existing_buf != NULL)\n\t{\n\t    win_T *wp = NULL;\n\n\t    if (swb_flags & SWB_USEOPEN)\n\t\twp = buf_jump_open_win(existing_buf);\n\n\t    \/\/ If 'switchbuf' contains \"usetab\": jump to first window in any tab\n\t    \/\/ page containing \"existing_buf\" if one exists\n\t    if (wp == NULL && (swb_flags & SWB_USETAB))\n\t\twp = buf_jump_open_tab(existing_buf);\n\t    \/\/ We've switched to the buffer, the usual loading of the file must\n\t    \/\/ be skipped.\n\t    if (wp != NULL)\n\t\tgetfile_result = GETFILE_SAME_FILE;\n\t}\n    }\n    if (getfile_result == GETFILE_UNUSED\n\t\t\t\t  && (postponed_split || cmdmod.cmod_tab != 0))\n    {\n\tif (win_split(postponed_split > 0 ? postponed_split : 0,\n\t\t\t\t\t\tpostponed_split_flags) == FAIL)\n\t{\n\t    --RedrawingDisabled;\n\t    goto erret;\n\t}\n\tRESET_BINDING(curwin);\n    }\n#endif\n\n    if (keep_help)\n    {\n\t\/\/ A :ta from a help file will keep the b_help flag set.  For \":ptag\"\n\t\/\/ we need to use the flag from the window where we came from.\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t    keep_help_flag = bt_help(curwin_save->w_buffer);\n\telse\n#endif\n\t    keep_help_flag = curbuf->b_help;\n    }\n\n    if (getfile_result == GETFILE_UNUSED)\n\t\/\/ Careful: getfile() may trigger autocommands and call jumpto_tag()\n\t\/\/ recursively.\n\tgetfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit);\n    keep_help_flag = FALSE;\n\n    if (GETFILE_SUCCESS(getfile_result))\t\/\/ got to the right file\n    {\n\tcurwin->w_set_curswant = TRUE;\n\tpostponed_split = 0;\n\n\tsave_magic_overruled = magic_overruled;\n\tmagic_overruled = OPTION_MAGIC_OFF;\t\/\/ always execute with 'nomagic'\n#ifdef FEAT_SEARCH_EXTRA\n\t\/\/ Save value of no_hlsearch, jumping to a tag is not a real search\n\tsave_no_hlsearch = no_hlsearch;\n#endif\n#if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)\n\t\/\/ getfile() may have cleared options, apply 'previewpopup' again.\n\tif (g_do_tagpreview != 0 && *p_pvp != NUL)\n\t    parse_previewpopup(curwin);\n#endif\n\n\t\/*\n\t * If 'cpoptions' contains 't', store the search pattern for the \"n\"\n\t * command.  If 'cpoptions' does not contain 't', the search pattern\n\t * is not stored.\n\t *\/\n\tif (vim_strchr(p_cpo, CPO_TAGPAT) != NULL)\n\t    search_options = 0;\n\telse\n\t    search_options = SEARCH_KEEP;\n\n\t\/*\n\t * If the command is a search, try here.\n\t *\n\t * Reset 'smartcase' for the search, since the search pattern was not\n\t * typed by the user.\n\t * Only use do_search() when there is a full search command, without\n\t * anything following.\n\t *\/\n\tstr = pbuf;\n\tif (pbuf[0] == '\/' || pbuf[0] == '?')\n\t    str = skip_regexp(pbuf + 1, pbuf[0], FALSE) + 1;\n\tif (str > pbuf_end - 1)\t\/\/ search command with nothing following\n\t{\n\t    save_p_ws = p_ws;\n\t    save_p_ic = p_ic;\n\t    save_p_scs = p_scs;\n\t    p_ws = TRUE;\t\/\/ need 'wrapscan' for backward searches\n\t    p_ic = FALSE;\t\/\/ don't ignore case now\n\t    p_scs = FALSE;\n\t    save_lnum = curwin->w_cursor.lnum;\n\t    if (tagp.tagline > 0)\n\t\t\/\/ start search before line from \"line:\" field\n\t\tcurwin->w_cursor.lnum = tagp.tagline - 1;\n\t    else\n\t\t\/\/ start search before first line\n\t\tcurwin->w_cursor.lnum = 0;\n\t    if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1,\n\t\t\t\t\t\t\t search_options, NULL))\n\t\tretval = OK;\n\t    else\n\t    {\n\t\tint\tfound = 1;\n\t\tint\tcc;\n\n\t\t\/*\n\t\t * try again, ignore case now\n\t\t *\/\n\t\tp_ic = TRUE;\n\t\tif (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1,\n\t\t\t\t\t\t\t search_options, NULL))\n\t\t{\n\t\t    \/*\n\t\t     * Failed to find pattern, take a guess: \"^func  (\"\n\t\t     *\/\n\t\t    found = 2;\n\t\t    (void)test_for_static(&tagp);\n\t\t    cc = *tagp.tagname_end;\n\t\t    *tagp.tagname_end = NUL;\n\t\t    sprintf((char *)pbuf, \"^%s\\\\s\\\\*(\", tagp.tagname);\n\t\t    if (!do_search(NULL, '\/', '\/', pbuf, (long)1,\n\t\t\t\t\t\t\t search_options, NULL))\n\t\t    {\n\t\t\t\/\/ Guess again: \"^char * \\<func  (\"\n\t\t\tsprintf((char *)pbuf, \"^\\\\[#a-zA-Z_]\\\\.\\\\*\\\\<%s\\\\s\\\\*(\",\n\t\t\t\t\t\t\t\ttagp.tagname);\n\t\t\tif (!do_search(NULL, '\/', '\/', pbuf, (long)1,\n\t\t\t\t\t\t\t search_options, NULL))\n\t\t\t    found = 0;\n\t\t    }\n\t\t    *tagp.tagname_end = cc;\n\t\t}\n\t\tif (found == 0)\n\t\t{\n\t\t    emsg(_(e_canot_find_tag_pattern));\n\t\t    curwin->w_cursor.lnum = save_lnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/*\n\t\t     * Only give a message when really guessed, not when 'ic'\n\t\t     * is set and match found while ignoring case.\n\t\t     *\/\n\t\t    if (found == 2 || !save_p_ic)\n\t\t    {\n\t\t\tmsg(_(e_couldnt_find_tag_just_guessing));\n\t\t\tif (!msg_scrolled && msg_silent == 0)\n\t\t\t{\n\t\t\t    out_flush();\n\t\t\t    ui_delay(1010L, TRUE);\n\t\t\t}\n\t\t    }\n\t\t    retval = OK;\n\t\t}\n\t    }\n\t    p_ws = save_p_ws;\n\t    p_ic = save_p_ic;\n\t    p_scs = save_p_scs;\n\n\t    \/\/ A search command may have positioned the cursor beyond the end\n\t    \/\/ of the line.  May need to correct that here.\n\t    check_cursor();\n\t}\n\telse\n\t{\n\t    int\t\tsave_secure = secure;\n\n\t    \/\/ Setup the sandbox for executing the command from the tags file.\n\t    secure = 1;\n#ifdef HAVE_SANDBOX\n\t    ++sandbox;\n#endif\n\t    curwin->w_cursor.lnum = 1;\t\t\/\/ start command in line 1\n\t    do_cmdline_cmd(pbuf);\n\t    retval = OK;\n\n\t    \/\/ When the command has done something that is not allowed make\n\t    \/\/ sure the error message can be seen.\n\t    if (secure == 2)\n\t\twait_return(TRUE);\n\t    secure = save_secure;\n#ifdef HAVE_SANDBOX\n\t    --sandbox;\n#endif\n\t}\n\n\tmagic_overruled = save_magic_overruled;\n#ifdef FEAT_SEARCH_EXTRA\n\t\/\/ restore no_hlsearch when keeping the old search pattern\n\tif (search_options)\n\t    set_no_hlsearch(save_no_hlsearch);\n#endif\n\n\t\/\/ Return OK if jumped to another file (at least we found the file!).\n\tif (getfile_result == GETFILE_OPEN_OTHER)\n\t    retval = OK;\n\n\tif (retval == OK)\n\t{\n\t    \/*\n\t     * For a help buffer: Put the cursor line at the top of the window,\n\t     * the help subject will be below it.\n\t     *\/\n\t    if (curbuf->b_help)\n\t\tset_topline(curwin, curwin->w_cursor.lnum);\n#ifdef FEAT_FOLDING\n\t    if ((fdo_flags & FDO_TAG) && old_KeyTyped)\n\t\tfoldOpenCursor();\n#endif\n\t}\n\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0\n\t\t\t   && curwin != curwin_save && win_valid(curwin_save))\n\t{\n\t    \/\/ Return cursor to where we were\n\t    validate_cursor();\n\t    redraw_later(UPD_VALID);\n\t    win_enter(curwin_save, TRUE);\n\t}\n#endif\n\n\t--RedrawingDisabled;\n    }\n    else\n    {\n\t--RedrawingDisabled;\n\tgot_int = FALSE;  \/\/ don't want entering window to fail\n\n\tif (postponed_split)\t\t\/\/ close the window\n\t{\n\t    win_close(curwin, FALSE);\n\t    postponed_split = 0;\n\t}\n#if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP)\n\telse if (WIN_IS_POPUP(curwin))\n\t{\n\t    win_T   *wp = curwin;\n\n\t    if (win_valid(curwin_save))\n\t\twin_enter(curwin_save, TRUE);\n\t    popup_close(wp->w_id, FALSE);\n\t}\n#endif\n    }\n#if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP)\n    if (WIN_IS_POPUP(curwin))\n\t\/\/ something went wrong, still in popup, but it can't have focus\n\twin_enter(firstwin, TRUE);\n#endif\n\nerret:\n#if defined(FEAT_QUICKFIX)\n    g_do_tagpreview = 0; \/\/ For next time\n#endif\n    vim_free(lbuf);\n    vim_free(pbuf);\n    vim_free(tofree_fname);\n    vim_free(full_fname);\n\n    return retval;\n}","target":0,"code_token_length":3154,"total_token_length":3390,"max_tokens_setting":4096}
+{"idx":195309,"func":"gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)\n{\n    char *pos = inbuf;\n    char *lpos = NULL;\n    char *tline = NULL;\n    LOCAL_ARRAY(char, line, TEMP_BUF_SIZE);\n    LOCAL_ARRAY(char, tmpbuf, TEMP_BUF_SIZE);\n    char *name = NULL;\n    char *selector = NULL;\n    char *host = NULL;\n    char *port = NULL;\n    char *escaped_selector = NULL;\n    const char *icon_url = NULL;\n    char gtype;\n    StoreEntry *entry = NULL;\n\n    memset(tmpbuf, '\\0', TEMP_BUF_SIZE);\n    memset(line, '\\0', TEMP_BUF_SIZE);\n\n    entry = gopherState->entry;\n\n    if (gopherState->conversion == GopherStateData::HTML_INDEX_PAGE) {\n        char *html_url = html_quote(entry->url());\n        gopherHTMLHeader(entry, \"Gopher Index %s\", html_url);\n        storeAppendPrintf(entry,\n                          \"<p>This is a searchable Gopher index. Use the search\\n\"\n                          \"function of your browser to enter search terms.\\n\"\n                          \"<ISINDEX>\\n\");\n        gopherHTMLFooter(entry);\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n        gopherState->HTML_header_added = 1;\n\n        return;\n    }\n\n    if (gopherState->conversion == GopherStateData::HTML_CSO_PAGE) {\n        char *html_url = html_quote(entry->url());\n        gopherHTMLHeader(entry, \"CSO Search of %s\", html_url);\n        storeAppendPrintf(entry,\n                          \"<P>A CSO database usually contains a phonebook or\\n\"\n                          \"directory.  Use the search function of your browser to enter\\n\"\n                          \"search terms.<\/P><ISINDEX>\\n\");\n        gopherHTMLFooter(entry);\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n        gopherState->HTML_header_added = 1;\n\n        return;\n    }\n\n    String outbuf;\n\n    if (!gopherState->HTML_header_added) {\n        if (gopherState->conversion == GopherStateData::HTML_CSO_RESULT)\n            gopherHTMLHeader(entry, \"CSO Search Result\", NULL);\n        else\n            gopherHTMLHeader(entry, \"Gopher Menu\", NULL);\n\n        outbuf.append (\"<PRE>\");\n\n        gopherState->HTML_header_added = 1;\n\n        gopherState->HTML_pre = 1;\n    }\n\n    while (pos < inbuf + len) {\n        int llen;\n        int left = len - (pos - inbuf);\n        lpos = (char *)memchr(pos, '\\n', left);\n        if (lpos) {\n            ++lpos;             \/* Next line is after \\n *\/\n            llen = lpos - pos;\n        } else {\n            llen = left;\n        }\n        if (gopherState->len + llen >= TEMP_BUF_SIZE) {\n            debugs(10, DBG_IMPORTANT, \"GopherHTML: Buffer overflow. Lost some data on URL: \" << entry->url()  );\n            llen = TEMP_BUF_SIZE - gopherState->len - 1;\n            gopherState->overflowed = true; \/\/ may already be true\n        }\n        if (!lpos) {\n            \/* there is no complete line in inbuf *\/\n            \/* copy it to temp buffer *\/\n            \/* note: llen is adjusted above *\/\n            memcpy(gopherState->buf + gopherState->len, pos, llen);\n            gopherState->len += llen;\n            break;\n        }\n        if (gopherState->len != 0) {\n            \/* there is something left from last tx. *\/\n            memcpy(line, gopherState->buf, gopherState->len);\n            memcpy(line + gopherState->len, pos, llen);\n            llen += gopherState->len;\n            gopherState->len = 0;\n        } else {\n            memcpy(line, pos, llen);\n        }\n        line[llen + 1] = '\\0';\n        \/* move input to next line *\/\n        pos = lpos;\n\n        \/* at this point. We should have one line in buffer to process *\/\n\n        if (*line == '.') {\n            \/* skip it *\/\n            memset(line, '\\0', TEMP_BUF_SIZE);\n            continue;\n        }\n\n        switch (gopherState->conversion) {\n\n        case GopherStateData::HTML_INDEX_RESULT:\n\n        case GopherStateData::HTML_DIR: {\n            tline = line;\n            gtype = *tline;\n            ++tline;\n            name = tline;\n            selector = strchr(tline, TAB);\n\n            if (selector) {\n                *selector = '\\0';\n                ++selector;\n                host = strchr(selector, TAB);\n\n                if (host) {\n                    *host = '\\0';\n                    ++host;\n                    port = strchr(host, TAB);\n\n                    if (port) {\n                        char *junk;\n                        port[0] = ':';\n                        junk = strchr(host, TAB);\n\n                        if (junk)\n                            *junk++ = 0;    \/* Chop port *\/\n                        else {\n                            junk = strchr(host, '\\r');\n\n                            if (junk)\n                                *junk++ = 0;    \/* Chop port *\/\n                            else {\n                                junk = strchr(host, '\\n');\n\n                                if (junk)\n                                    *junk++ = 0;    \/* Chop port *\/\n                            }\n                        }\n\n                        if ((port[1] == '0') && (!port[2]))\n                            port[0] = 0;    \/* 0 means none *\/\n                    }\n\n                    \/* escape a selector here *\/\n                    escaped_selector = xstrdup(rfc1738_escape_part(selector));\n\n                    switch (gtype) {\n\n                    case GOPHER_DIRECTORY:\n                        icon_url = mimeGetIconURL(\"internal-menu\");\n                        break;\n\n                    case GOPHER_HTML:\n\n                    case GOPHER_FILE:\n                        icon_url = mimeGetIconURL(\"internal-text\");\n                        break;\n\n                    case GOPHER_INDEX:\n\n                    case GOPHER_CSO:\n                        icon_url = mimeGetIconURL(\"internal-index\");\n                        break;\n\n                    case GOPHER_IMAGE:\n\n                    case GOPHER_GIF:\n\n                    case GOPHER_PLUS_IMAGE:\n                        icon_url = mimeGetIconURL(\"internal-image\");\n                        break;\n\n                    case GOPHER_SOUND:\n\n                    case GOPHER_PLUS_SOUND:\n                        icon_url = mimeGetIconURL(\"internal-sound\");\n                        break;\n\n                    case GOPHER_PLUS_MOVIE:\n                        icon_url = mimeGetIconURL(\"internal-movie\");\n                        break;\n\n                    case GOPHER_TELNET:\n\n                    case GOPHER_3270:\n                        icon_url = mimeGetIconURL(\"internal-telnet\");\n                        break;\n\n                    case GOPHER_BIN:\n\n                    case GOPHER_MACBINHEX:\n\n                    case GOPHER_DOSBIN:\n\n                    case GOPHER_UUENCODED:\n                        icon_url = mimeGetIconURL(\"internal-binary\");\n                        break;\n\n                    case GOPHER_INFO:\n                        icon_url = NULL;\n                        break;\n\n                    case GOPHER_WWW:\n                        icon_url = mimeGetIconURL(\"internal-link\");\n                        break;\n\n                    default:\n                        icon_url = mimeGetIconURL(\"internal-unknown\");\n                        break;\n                    }\n\n                    memset(tmpbuf, '\\0', TEMP_BUF_SIZE);\n\n                    if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {\n                        if (strlen(escaped_selector) != 0)\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"telnet:\/\/%s@%s%s%s\/\\\">%s<\/A>\\n\",\n                                     icon_url, escaped_selector, rfc1738_escape_part(host),\n                                     *port ? \":\" : \"\", port, html_quote(name));\n                        else\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"telnet:\/\/%s%s%s\/\\\">%s<\/A>\\n\",\n                                     icon_url, rfc1738_escape_part(host), *port ? \":\" : \"\",\n                                     port, html_quote(name));\n\n                    } else if (gtype == GOPHER_INFO) {\n                        snprintf(tmpbuf, TEMP_BUF_SIZE, \"\\t%s\\n\", html_quote(name));\n                    } else {\n                        if (strncmp(selector, \"GET \/\", 5) == 0) {\n                            \/* WWW link *\/\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"http:\/\/%s\/%s\\\">%s<\/A>\\n\",\n                                     icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name));\n                        } else if (gtype == GOPHER_WWW) {\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"%s\\\">%s<\/A>\\n\",\n                                     icon_url, rfc1738_escape_unescaped(selector), html_quote(name));\n                        } else {\n                            \/* Standard link *\/\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"gopher:\/\/%s\/%c%s\\\">%s<\/A>\\n\",\n                                     icon_url, host, gtype, escaped_selector, html_quote(name));\n                        }\n                    }\n\n                    safe_free(escaped_selector);\n                    outbuf.append(tmpbuf);\n                } else {\n                    memset(line, '\\0', TEMP_BUF_SIZE);\n                    continue;\n                }\n            } else {\n                memset(line, '\\0', TEMP_BUF_SIZE);\n                continue;\n            }\n\n            break;\n            }           \/* HTML_DIR, HTML_INDEX_RESULT *\/\n\n        case GopherStateData::HTML_CSO_RESULT: {\n            if (line[0] == '-') {\n                int code, recno;\n                char *s_code, *s_recno, *result;\n\n                s_code = strtok(line + 1, \":\\n\");\n                s_recno = strtok(NULL, \":\\n\");\n                result = strtok(NULL, \"\\n\");\n\n                if (!result)\n                    break;\n\n                code = atoi(s_code);\n\n                recno = atoi(s_recno);\n\n                if (code != 200)\n                    break;\n\n                if (gopherState->cso_recno != recno) {\n                    snprintf(tmpbuf, TEMP_BUF_SIZE, \"<\/PRE><HR noshade size=\\\"1px\\\"><H2>Record# %d<br><i>%s<\/i><\/H2>\\n<PRE>\", recno, html_quote(result));\n                    gopherState->cso_recno = recno;\n                } else {\n                    snprintf(tmpbuf, TEMP_BUF_SIZE, \"%s\\n\", html_quote(result));\n                }\n\n                outbuf.append(tmpbuf);\n                break;\n            } else {\n                int code;\n                char *s_code, *result;\n\n                s_code = strtok(line, \":\");\n                result = strtok(NULL, \"\\n\");\n\n                if (!result)\n                    break;\n\n                code = atoi(s_code);\n\n                switch (code) {\n\n                case 200: {\n                    \/* OK *\/\n                    \/* Do nothing here *\/\n                    break;\n                }\n\n                case 102:   \/* Number of matches *\/\n\n                case 501:   \/* No Match *\/\n\n                case 502: { \/* Too Many Matches *\/\n                    \/* Print the message the server returns *\/\n                    snprintf(tmpbuf, TEMP_BUF_SIZE, \"<\/PRE><HR noshade size=\\\"1px\\\"><H2>%s<\/H2>\\n<PRE>\", html_quote(result));\n                    outbuf.append(tmpbuf);\n                    break;\n                }\n\n                }\n            }\n\n            break;\n            }           \/* HTML_CSO_RESULT *\/\n        default:\n            break;      \/* do nothing *\/\n\n        }           \/* switch *\/\n\n    }               \/* while loop *\/\n\n    if (outbuf.size() > 0) {\n        entry->append(outbuf.rawBuf(), outbuf.size());\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n    }\n\n    outbuf.clean();\n    return;\n}","target":1,"code_token_length":2525,"total_token_length":2761,"max_tokens_setting":4096}
+{"idx":309893,"func":"main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)\n{\n    _nc_STRCPY(tname, getenv(\"TERM\"), sizeof(tname));\n    load_term();\n    _nc_setupscreen(lines, columns, stdout, FALSE, 0);\n    baudrate();\n\n    _nc_mvcur_init();\n\n    (void) puts(\"The mvcur tester.  Type ? for help\");\n\n    fputs(\"smcup:\", stdout);\n    putchar('\\n');\n\n    for (;;) {\n\tint fy, fx, ty, tx, n, i;\n\tchar buf[BUFSIZ], capname[BUFSIZ];\n\n\tif (fputs(\"> \", stdout) == EOF)\n\t    break;\n\tif (fgets(buf, sizeof(buf), stdin) == 0)\n\t    break;\n\n#define PUTS(s)   (void) puts(s)\n#define PUTF(s,t) (void) printf(s,t)\n\tif (buf[0] == '?') {\n\t    PUTS(\"?                -- display this help message\");\n\t    PUTS(\"fy fx ty tx      -- (4 numbers) display (fy,fx)->(ty,tx) move\");\n\t    PUTS(\"s[croll] n t b m -- display scrolling sequence\");\n\t    PUTF(\"r[eload]         -- reload terminal info for %s\\n\",\n\t\t termname());\n\t    PUTS(\"l[oad] <term>    -- load terminal info for type <term>\");\n\t    PUTS(\"d[elete] <cap>   -- delete named capability\");\n\t    PUTS(\"i[nspect]        -- display terminal capabilities\");\n\t    PUTS(\"c[ost]           -- dump cursor-optimization cost table\");\n\t    PUTS(\"o[optimize]      -- toggle movement optimization\");\n\t    PUTS(\"t[orture] <num>  -- torture-test with <num> random moves\");\n\t    PUTS(\"q[uit]           -- quit the program\");\n\t} else if (sscanf(buf, \"%d %d %d %d\", &fy, &fx, &ty, &tx) == 4) {\n\t    struct timeval before, after;\n\n\t    putchar('\"');\n\n\t    gettimeofday(&before, NULL);\n\t    mvcur(fy, fx, ty, tx);\n\t    gettimeofday(&after, NULL);\n\n\t    printf(\"\\\" (%ld msec)\\n\",\n\t\t   (long) (after.tv_usec - before.tv_usec\n\t\t\t   + (after.tv_sec - before.tv_sec)\n\t\t\t   * 1000000));\n\t} else if (sscanf(buf, \"s %d %d %d %d\", &fy, &fx, &ty, &tx) == 4) {\n\t    struct timeval before, after;\n\n\t    putchar('\"');\n\n\t    gettimeofday(&before, NULL);\n\t    _nc_scrolln(fy, fx, ty, tx);\n\t    gettimeofday(&after, NULL);\n\n\t    printf(\"\\\" (%ld msec)\\n\",\n\t\t   (long) (after.tv_usec - before.tv_usec + (after.tv_sec -\n\t\t\t\t\t\t\t     before.tv_sec)\n\t\t\t   * 1000000));\n\t} else if (buf[0] == 'r') {\n\t    _nc_STRCPY(tname, termname(), sizeof(tname));\n\t    load_term();\n\t} else if (sscanf(buf, \"l %s\", tname) == 1) {\n\t    load_term();\n\t} else if (sscanf(buf, \"d %s\", capname) == 1) {\n\t    struct name_table_entry const *np = _nc_find_entry(capname,\n\t\t\t\t\t\t\t       _nc_get_hash_table(FALSE));\n\n\t    if (np == NULL)\n\t\t(void) printf(\"No such capability as \\\"%s\\\"\\n\", capname);\n\t    else {\n\t\tswitch (np->nte_type) {\n\t\tcase BOOLEAN:\n\t\t    cur_term->type.Booleans[np->nte_index] = FALSE;\n\t\t    (void)\n\t\t\tprintf(\"Boolean capability `%s' (%d) turned off.\\n\",\n\t\t\t       np->nte_name, np->nte_index);\n\t\t    break;\n\n\t\tcase NUMBER:\n\t\t    cur_term->type.Numbers[np->nte_index] = ABSENT_NUMERIC;\n\t\t    (void) printf(\"Number capability `%s' (%d) set to -1.\\n\",\n\t\t\t\t  np->nte_name, np->nte_index);\n\t\t    break;\n\n\t\tcase STRING:\n\t\t    cur_term->type.Strings[np->nte_index] = ABSENT_STRING;\n\t\t    (void) printf(\"String capability `%s' (%d) deleted.\\n\",\n\t\t\t\t  np->nte_name, np->nte_index);\n\t\t    break;\n\t\t}\n\t    }\n\t} else if (buf[0] == 'i') {\n\t    dump_init(NULL, F_TERMINFO, S_TERMINFO,\n\t\t      FALSE, 70, 0, 0, FALSE, FALSE, 0);\n\t    dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, 0);\n\t    putchar('\\n');\n\t} else if (buf[0] == 'o') {\n\t    if (_nc_optimize_enable & OPTIMIZE_MVCUR) {\n\t\t_nc_optimize_enable &= ~OPTIMIZE_MVCUR;\n\t\t(void) puts(\"Optimization is now off.\");\n\t    } else {\n\t\t_nc_optimize_enable |= OPTIMIZE_MVCUR;\n\t\t(void) puts(\"Optimization is now on.\");\n\t    }\n\t}\n\t\/*\n\t * You can use the `t' test to profile and tune the movement\n\t * optimizer.  Use iteration values in three digits or more.\n\t * At above 5000 iterations the profile timing averages are stable\n\t * to within a millisecond or three.\n\t *\n\t * The `overhead' field of the report will help you pick a\n\t * COMPUTE_OVERHEAD figure appropriate for your processor and\n\t * expected line speed.  The `total estimated time' is\n\t * computation time plus a character-transmission time\n\t * estimate computed from the number of transmits and the baud\n\t * rate.\n\t *\n\t * Use this together with the `o' command to get a read on the\n\t * optimizer's effectiveness.  Compare the total estimated times\n\t * for `t' runs of the same length in both optimized and un-optimized\n\t * modes.  As long as the optimized times are less, the optimizer\n\t * is winning.\n\t *\/\n\telse if (sscanf(buf, \"t %d\", &n) == 1) {\n\t    float cumtime = 0.0, perchar;\n\t    int speeds[] =\n\t    {2400, 9600, 14400, 19200, 28800, 38400, 0};\n\n\t    srand((unsigned) (getpid() + time((time_t *) 0)));\n\t    profiling = TRUE;\n\t    xmits = 0;\n\t    for (i = 0; i < n; i++) {\n\t\t\/*\n\t\t * This does a move test between two random locations,\n\t\t * Random moves probably short-change the optimizer,\n\t\t * which will work better on the short moves probably\n\t\t * typical of doupdate()'s usage pattern.  Still,\n\t\t * until we have better data...\n\t\t *\/\n#ifdef FIND_COREDUMP\n\t\tint from_y = roll(lines);\n\t\tint to_y = roll(lines);\n\t\tint from_x = roll(columns);\n\t\tint to_x = roll(columns);\n\n\t\tprintf(\"(%d,%d) -> (%d,%d)\\n\", from_y, from_x, to_y, to_x);\n\t\tmvcur(from_y, from_x, to_y, to_x);\n#else\n\t\tmvcur(roll(lines), roll(columns), roll(lines), roll(columns));\n#endif \/* FIND_COREDUMP *\/\n\t\tif (diff)\n\t\t    cumtime += diff;\n\t    }\n\t    profiling = FALSE;\n\n\t    \/*\n\t     * Average milliseconds per character optimization time.\n\t     * This is the key figure to watch when tuning the optimizer.\n\t     *\/\n\t    perchar = cumtime \/ n;\n\n\t    (void) printf(\"%d moves (%ld chars) in %d msec, %f msec each:\\n\",\n\t\t\t  n, xmits, (int) cumtime, perchar);\n\n\t    for (i = 0; speeds[i]; i++) {\n\t\t\/*\n\t\t * Total estimated time for the moves, computation and\n\t\t * transmission both. Transmission time is an estimate\n\t\t * assuming 9 bits\/char, 8 bits + 1 stop bit.\n\t\t *\/\n\t\tfloat totalest = cumtime + xmits * 9 * 1e6 \/ speeds[i];\n\n\t\t\/*\n\t\t * Per-character optimization overhead in character transmits\n\t\t * at the current speed.  Round this to the nearest integer\n\t\t * to figure COMPUTE_OVERHEAD for the speed.\n\t\t *\/\n\t\tfloat overhead = speeds[i] * perchar \/ 1e6;\n\n\t\t(void)\n\t\t    printf(\"%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\\n\",\n\t\t\t   speeds[i], overhead, totalest);\n\t    }\n\t} else if (buf[0] == 'c') {\n\t    (void) printf(\"char padding: %d\\n\", CURRENT_SCREEN->_char_padding);\n\t    (void) printf(\"cr cost: %d\\n\", CURRENT_SCREEN->_cr_cost);\n\t    (void) printf(\"cup cost: %d\\n\", CURRENT_SCREEN->_cup_cost);\n\t    (void) printf(\"home cost: %d\\n\", CURRENT_SCREEN->_home_cost);\n\t    (void) printf(\"ll cost: %d\\n\", CURRENT_SCREEN->_ll_cost);\n#if USE_HARD_TABS\n\t    (void) printf(\"ht cost: %d\\n\", CURRENT_SCREEN->_ht_cost);\n\t    (void) printf(\"cbt cost: %d\\n\", CURRENT_SCREEN->_cbt_cost);\n#endif \/* USE_HARD_TABS *\/\n\t    (void) printf(\"cub1 cost: %d\\n\", CURRENT_SCREEN->_cub1_cost);\n\t    (void) printf(\"cuf1 cost: %d\\n\", CURRENT_SCREEN->_cuf1_cost);\n\t    (void) printf(\"cud1 cost: %d\\n\", CURRENT_SCREEN->_cud1_cost);\n\t    (void) printf(\"cuu1 cost: %d\\n\", CURRENT_SCREEN->_cuu1_cost);\n\t    (void) printf(\"cub cost: %d\\n\", CURRENT_SCREEN->_cub_cost);\n\t    (void) printf(\"cuf cost: %d\\n\", CURRENT_SCREEN->_cuf_cost);\n\t    (void) printf(\"cud cost: %d\\n\", CURRENT_SCREEN->_cud_cost);\n\t    (void) printf(\"cuu cost: %d\\n\", CURRENT_SCREEN->_cuu_cost);\n\t    (void) printf(\"hpa cost: %d\\n\", CURRENT_SCREEN->_hpa_cost);\n\t    (void) printf(\"vpa cost: %d\\n\", CURRENT_SCREEN->_vpa_cost);\n\t} else if (buf[0] == 'x' || buf[0] == 'q')\n\t    break;\n\telse\n\t    (void) puts(\"Invalid command.\");\n    }\n\n    (void) fputs(\"rmcup:\", stdout);\n    _nc_mvcur_wrap();\n    putchar('\\n');\n\n    return (0);\n}","target":0,"code_token_length":2327,"total_token_length":2563,"max_tokens_setting":4096}
+{"idx":439087,"func":"static MagickBooleanType WritePALMImage(const ImageInfo *image_info,\n  Image *image)\n{\n  ExceptionInfo\n    *exception;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    currentOffset,\n    offset,\n    scene;\n\n  MagickSizeType\n    cc;\n\n  PixelPacket\n    transpix;\n\n  QuantizeInfo\n    *quantize_info;\n\n  register IndexPacket\n    *indexes;\n\n  register ssize_t\n    x;\n\n  register PixelPacket\n    *p;\n\n  ssize_t\n    y;\n\n  size_t\n    count,\n    bits_per_pixel,\n    bytes_per_row,\n    imageListLength,\n    nextDepthOffset,\n    one;\n\n  unsigned char\n    bit,\n    byte,\n    color,\n    *last_row,\n    *one_row,\n    *ptr,\n    version;\n\n  unsigned int\n    transparentIndex;\n\n  unsigned short\n    color16,\n    flags;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  exception=AcquireExceptionInfo();\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  quantize_info=AcquireQuantizeInfo(image_info);\n  flags=0;\n  currentOffset=0;\n  transparentIndex=0;\n  transpix.red=0;\n  transpix.green=0;\n  transpix.blue=0;\n  transpix.opacity=0;\n  one=1;\n  version=0;\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    (void) TransformImageColorspace(image,sRGBColorspace);\n    count=GetNumberColors(image,NULL,exception);\n    for (bits_per_pixel=1;  (one << bits_per_pixel) < count; bits_per_pixel*=2) ;\n    if (bits_per_pixel > 16)\n      bits_per_pixel=16;\n    else\n      if (bits_per_pixel < 16)\n        (void) TransformImageColorspace(image,image->colorspace);\n    if (bits_per_pixel < 8)\n      {\n        (void) TransformImageColorspace(image,GRAYColorspace);\n        (void) SetImageType(image,PaletteType);\n        (void) SortColormapByIntensity(image);\n      }\n    if ((image->storage_class == PseudoClass) && (image->colors > 256))\n      (void) SetImageStorageClass(image,DirectClass);\n    if (image->storage_class == PseudoClass)\n      flags|=PALM_HAS_COLORMAP_FLAG;\n    else\n      flags|=PALM_IS_DIRECT_COLOR;\n    (void) WriteBlobMSBShort(image,(unsigned short) image->columns); \/* width *\/\n    (void) WriteBlobMSBShort(image,(unsigned short) image->rows);  \/* height *\/\n    bytes_per_row=((image->columns+(16\/bits_per_pixel-1))\/(16\/\n      bits_per_pixel))*2;\n    (void) WriteBlobMSBShort(image,(unsigned short) bytes_per_row);\n    if ((image_info->compression == RLECompression) ||\n        (image_info->compression == FaxCompression))\n      flags|=PALM_IS_COMPRESSED_FLAG;\n    (void) WriteBlobMSBShort(image, flags);\n    (void) WriteBlobByte(image,(unsigned char) bits_per_pixel);\n    if (bits_per_pixel > 1)\n      version=1;\n    if ((image_info->compression == RLECompression) ||\n        (image_info->compression == FaxCompression))\n      version=2;\n    (void) WriteBlobByte(image,version);\n    (void) WriteBlobMSBShort(image,0);  \/* nextDepthOffset *\/\n    (void) WriteBlobByte(image,(unsigned char) transparentIndex);\n    if (image_info->compression == RLECompression)\n      (void) WriteBlobByte(image,PALM_COMPRESSION_RLE);\n    else\n      if (image_info->compression == FaxCompression)\n        (void) WriteBlobByte(image,PALM_COMPRESSION_SCANLINE);\n      else\n        (void) WriteBlobByte(image,PALM_COMPRESSION_NONE);\n    (void) WriteBlobMSBShort(image,0);  \/* reserved *\/\n    offset=16;\n    if (bits_per_pixel == 16)\n      {\n        (void) WriteBlobByte(image,5);  \/* # of bits of red *\/\n        (void) WriteBlobByte(image,6);  \/* # of bits of green *\/\n        (void) WriteBlobByte(image,5);  \/* # of bits of blue *\/\n        (void) WriteBlobByte(image,0);  \/* reserved by Palm *\/\n        (void) WriteBlobMSBLong(image,0);  \/* no transparent color, YET *\/\n        offset+=8;\n      }\n    if (bits_per_pixel == 8)\n      {\n        if (flags & PALM_HAS_COLORMAP_FLAG)  \/* Write out colormap *\/\n          {\n            quantize_info->dither=IsPaletteImage(image,&image->exception);\n            quantize_info->number_colors=image->colors;\n            (void) QuantizeImage(quantize_info,image);\n            (void) WriteBlobMSBShort(image,(unsigned short) image->colors);\n            for (count = 0; count < image->colors; count++)\n            {\n              (void) WriteBlobByte(image,(unsigned char) count);\n              (void) WriteBlobByte(image,ScaleQuantumToChar(\n                image->colormap[count].red));\n              (void) WriteBlobByte(image,\n                ScaleQuantumToChar(image->colormap[count].green));\n              (void) WriteBlobByte(image,\n                ScaleQuantumToChar(image->colormap[count].blue));\n            }\n            offset+=2+count*4;\n          }\n      else  \/* Map colors to Palm standard colormap *\/\n        {\n          Image\n            *affinity_image;\n\n          affinity_image=ConstituteImage(256,1,\"RGB\",CharPixel,&PalmPalette,\n            exception);\n          (void) TransformImageColorspace(affinity_image,\n            affinity_image->colorspace);\n          (void) RemapImage(quantize_info,image,affinity_image);\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            p=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n            indexes=GetAuthenticIndexQueue(image);\n            for (x=0; x < (ssize_t) image->columns; x++)\n              SetPixelIndex(indexes+x,FindColor(&image->colormap[\n                (ssize_t) GetPixelIndex(indexes+x)]));\n          }\n          affinity_image=DestroyImage(affinity_image);\n        }\n      }\n    if (flags & PALM_IS_COMPRESSED_FLAG)\n      (void) WriteBlobMSBShort(image,0);  \/* fill in size later *\/\n    last_row=(unsigned char *) NULL;\n    if (image_info->compression == FaxCompression)\n      {\n        last_row=(unsigned char *) AcquireQuantumMemory(bytes_per_row,\n          sizeof(*last_row));\n        if (last_row == (unsigned char *) NULL)\n          {\n            quantize_info=DestroyQuantizeInfo(quantize_info);\n            ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    one_row=(unsigned char *) AcquireQuantumMemory(bytes_per_row,\n      sizeof(*one_row));\n    if (one_row == (unsigned char *) NULL)\n      {\n        if (last_row != (unsigned char *) NULL)\n          last_row=(unsigned char *) RelinquishMagickMemory(last_row);\n        quantize_info=DestroyQuantizeInfo(quantize_info);\n        ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      ptr=one_row;\n      (void) memset(ptr,0,bytes_per_row);\n      p=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n      if (p == (PixelPacket *) NULL)\n        break;\n      indexes=GetAuthenticIndexQueue(image);\n      if (bits_per_pixel == 16)\n        {\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            color16=(unsigned short) ((((31*(size_t) GetPixelRed(p))\/\n              (size_t) QuantumRange) << 11) |\n              (((63*(size_t) GetPixelGreen(p))\/(size_t) QuantumRange) << 5) |\n              ((31*(size_t) GetPixelBlue(p))\/(size_t) QuantumRange));\n            if (GetPixelOpacity(p) == (Quantum) TransparentOpacity)\n              {\n                transpix.red=GetPixelRed(p);\n                transpix.green=GetPixelGreen(p);\n                transpix.blue=GetPixelBlue(p);\n                transpix.opacity=GetPixelOpacity(p);\n                flags|=PALM_HAS_TRANSPARENCY_FLAG;\n              }\n            *ptr++=(unsigned char) ((color16 >> 8) & 0xff);\n            *ptr++=(unsigned char) (color16 & 0xff);\n            p++;\n          }\n        }\n      else\n        {\n          byte=0x00;\n          bit=(unsigned char) (8-bits_per_pixel);\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            if (bits_per_pixel >= 8)\n              color=(unsigned char) GetPixelIndex(indexes+x);\n            else\n              color=(unsigned char) (GetPixelIndex(indexes+x)*\n                ((one << bits_per_pixel)-1)\/MagickMax(1*image->colors-1,1));\n            byte|=color << bit;\n            if (bit != 0)\n              bit-=(unsigned char) bits_per_pixel;\n            else\n              {\n                *ptr++=byte;\n                byte=0x00;\n                bit=(unsigned char) (8-bits_per_pixel);\n              }\n          }\n          if ((image->columns % (8\/bits_per_pixel)) != 0)\n            *ptr++=byte;\n        }\n      if (image_info->compression == RLECompression)\n        {\n          x=0;\n          while (x < (ssize_t) bytes_per_row)\n          {\n            byte=one_row[x];\n            count=1;\n            while ((one_row[++x] == byte) && (count < 255) &&\n                   (x < (ssize_t) bytes_per_row))\n              count++;\n            (void) WriteBlobByte(image,(unsigned char) count);\n            (void) WriteBlobByte(image,(unsigned char) byte);\n          }\n        }\n      else\n        if (image_info->compression == FaxCompression)\n          {\n            char\n              tmpbuf[8],\n              *tptr;\n\n            for (x = 0;  x < (ssize_t) bytes_per_row;  x += 8)\n            {\n              tptr = tmpbuf;\n              for (bit=0, byte=0; bit < (unsigned char) MagickMin(8,(ssize_t) bytes_per_row-x); bit++)\n              {\n                if ((y == 0) || (last_row[x + bit] != one_row[x + bit]))\n                  {\n                    byte |= (1 << (7 - bit));\n                    *tptr++ = (char) one_row[x + bit];\n                  }\n              }\n              (void) WriteBlobByte(image, byte);\n              (void) WriteBlob(image,tptr-tmpbuf,(unsigned char *) tmpbuf);\n            }\n            (void) memcpy(last_row,one_row,bytes_per_row);\n          }\n        else\n          (void) WriteBlob(image,bytes_per_row,one_row);\n      }\n    if (flags & PALM_HAS_TRANSPARENCY_FLAG)\n      {\n        offset=SeekBlob(image,currentOffset+6,SEEK_SET);\n        (void) WriteBlobMSBShort(image,flags);\n        offset=SeekBlob(image,currentOffset+12,SEEK_SET);\n        (void) WriteBlobByte(image,(unsigned char) transparentIndex);  \/* trans index *\/\n      }\n    if (bits_per_pixel == 16)\n      {\n        offset=SeekBlob(image,currentOffset+20,SEEK_SET);\n        (void) WriteBlobByte(image,0);  \/* reserved by Palm *\/\n        (void) WriteBlobByte(image,(unsigned char) ((31*transpix.red)\/\n          QuantumRange));\n        (void) WriteBlobByte(image,(unsigned char) ((63*transpix.green)\/\n          QuantumRange));\n        (void) WriteBlobByte(image,(unsigned char) ((31*transpix.blue)\/\n          QuantumRange));\n      }\n    if (flags & PALM_IS_COMPRESSED_FLAG)  \/* fill in size now *\/\n      {\n        offset=SeekBlob(image,currentOffset+offset,SEEK_SET);\n        (void) WriteBlobMSBShort(image,(unsigned short) (GetBlobSize(image)-\n          currentOffset-offset));\n      }\n    if (one_row != (unsigned char *) NULL)\n      one_row=(unsigned char *) RelinquishMagickMemory(one_row);\n    if (last_row != (unsigned char *) NULL)\n      last_row=(unsigned char *) RelinquishMagickMemory(last_row);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    \/* padding to 4 byte word *\/\n    for (cc=(GetBlobSize(image)) % 4; cc > 0; cc--)\n      (void) WriteBlobByte(image,0);\n    \/* write nextDepthOffset and return to end of image *\/\n    (void) SeekBlob(image,currentOffset+10,SEEK_SET);\n    nextDepthOffset=(size_t) ((GetBlobSize(image)-currentOffset)\/4);\n    (void) WriteBlobMSBShort(image,(unsigned short) nextDepthOffset);\n    currentOffset=(MagickOffsetType) GetBlobSize(image);\n    (void) SeekBlob(image,currentOffset,SEEK_SET);\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  quantize_info=DestroyQuantizeInfo(quantize_info);\n  (void) CloseBlob(image);\n  (void) DestroyExceptionInfo(exception);\n  return(MagickTrue);\n}","target":0,"code_token_length":3117,"total_token_length":3353,"max_tokens_setting":4096}
+{"idx":438652,"func":"u_undoredo(int undo)\n{\n    undoline_T\t*newarray = NULL;\n    linenr_T\toldsize;\n    linenr_T\tnewsize;\n    linenr_T\ttop, bot;\n    linenr_T\tlnum;\n    linenr_T\tnewlnum = MAXLNUM;\n    pos_T\tnew_curpos = curwin->w_cursor;\n    long\ti;\n    u_entry_T\t*uep, *nuep;\n    u_entry_T\t*newlist = NULL;\n    int\t\told_flags;\n    int\t\tnew_flags;\n    pos_T\tnamedm[NMARKS];\n    visualinfo_T visualinfo;\n    int\t\tempty_buffer;\t\t    \/\/ buffer became empty\n    u_header_T\t*curhead = curbuf->b_u_curhead;\n\n    \/\/ Don't want autocommands using the undo structures here, they are\n    \/\/ invalid till the end.\n    block_autocmds();\n\n#ifdef U_DEBUG\n    u_check(FALSE);\n#endif\n    old_flags = curhead->uh_flags;\n    new_flags = (curbuf->b_changed ? UH_CHANGED : 0) +\n\t       ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0);\n    setpcmark();\n\n    \/*\n     * save marks before undo\/redo\n     *\/\n    mch_memmove(namedm, curbuf->b_namedm, sizeof(pos_T) * NMARKS);\n    visualinfo = curbuf->b_visual;\n    curbuf->b_op_start.lnum = curbuf->b_ml.ml_line_count;\n    curbuf->b_op_start.col = 0;\n    curbuf->b_op_end.lnum = 0;\n    curbuf->b_op_end.col = 0;\n\n    for (uep = curhead->uh_entry; uep != NULL; uep = nuep)\n    {\n\ttop = uep->ue_top;\n\tbot = uep->ue_bot;\n\tif (bot == 0)\n\t    bot = curbuf->b_ml.ml_line_count + 1;\n\tif (top > curbuf->b_ml.ml_line_count || top >= bot\n\t\t\t\t      || bot > curbuf->b_ml.ml_line_count + 1)\n\t{\n\t    unblock_autocmds();\n\t    iemsg(_(e_u_undo_line_numbers_wrong));\n\t    changed();\t\t\/\/ don't want UNCHANGED now\n\t    return;\n\t}\n\n\toldsize = bot - top - 1;    \/\/ number of lines before undo\n\tnewsize = uep->ue_size;\t    \/\/ number of lines after undo\n\n\t\/\/ Decide about the cursor position, depending on what text changed.\n\t\/\/ Don't set it yet, it may be invalid if lines are going to be added.\n\tif (top < newlnum)\n\t{\n\t    \/\/ If the saved cursor is somewhere in this undo block, move it to\n\t    \/\/ the remembered position.  Makes \"gwap\" put the cursor back\n\t    \/\/ where it was.\n\t    lnum = curhead->uh_cursor.lnum;\n\t    if (lnum >= top && lnum <= top + newsize + 1)\n\t    {\n\t\tnew_curpos = curhead->uh_cursor;\n\t\tnewlnum = new_curpos.lnum - 1;\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Use the first line that actually changed.  Avoids that\n\t\t\/\/ undoing auto-formatting puts the cursor in the previous\n\t\t\/\/ line.\n\t\tfor (i = 0; i < newsize && i < oldsize; ++i)\n\t\t{\n\t\t    char_u *p = ml_get(top + 1 + i);\n\n\t\t    if (curbuf->b_ml.ml_line_len != uep->ue_array[i].ul_len\n\t\t\t    || memcmp(uep->ue_array[i].ul_line, p,\n\t\t\t\t\t\tcurbuf->b_ml.ml_line_len) != 0)\n\t\t\tbreak;\n\t\t}\n\t\tif (i == newsize && newlnum == MAXLNUM && uep->ue_next == NULL)\n\t\t{\n\t\t    newlnum = top;\n\t\t    new_curpos.lnum = newlnum + 1;\n\t\t}\n\t\telse if (i < newsize)\n\t\t{\n\t\t    newlnum = top + i;\n\t\t    new_curpos.lnum = newlnum + 1;\n\t\t}\n\t    }\n\t}\n\n\tempty_buffer = FALSE;\n\n\t\/*\n\t * Delete the lines between top and bot and save them in newarray.\n\t *\/\n\tif (oldsize > 0)\n\t{\n\t    if ((newarray = U_ALLOC_LINE(sizeof(undoline_T) * oldsize)) == NULL)\n\t    {\n\t\tdo_outofmem_msg((long_u)(sizeof(undoline_T) * oldsize));\n\n\t\t\/\/ We have messed up the entry list, repair is impossible.\n\t\t\/\/ we have to free the rest of the list.\n\t\twhile (uep != NULL)\n\t\t{\n\t\t    nuep = uep->ue_next;\n\t\t    u_freeentry(uep, uep->ue_size);\n\t\t    uep = nuep;\n\t\t}\n\t\tbreak;\n\t    }\n\t    \/\/ delete backwards, it goes faster in most cases\n\t    for (lnum = bot - 1, i = oldsize; --i >= 0; --lnum)\n\t    {\n\t\t\/\/ what can we do when we run out of memory?\n\t\tif (u_save_line(&newarray[i], lnum) == FAIL)\n\t\t    do_outofmem_msg((long_u)0);\n\t\t\/\/ remember we deleted the last line in the buffer, and a\n\t\t\/\/ dummy empty line will be inserted\n\t\tif (curbuf->b_ml.ml_line_count == 1)\n\t\t    empty_buffer = TRUE;\n\t\tml_delete_flags(lnum, ML_DEL_UNDO);\n\t    }\n\t}\n\telse\n\t    newarray = NULL;\n\n\t\/\/ make sure the cursor is on a valid line after the deletions\n\tcheck_cursor_lnum();\n\n\t\/*\n\t * Insert the lines in u_array between top and bot.\n\t *\/\n\tif (newsize)\n\t{\n\t    for (lnum = top, i = 0; i < newsize; ++i, ++lnum)\n\t    {\n\t\t\/\/ If the file is empty, there is an empty line 1 that we\n\t\t\/\/ should get rid of, by replacing it with the new line.\n\t\tif (empty_buffer && lnum == 0)\n\t\t    ml_replace_len((linenr_T)1, uep->ue_array[i].ul_line,\n\t\t\t\t\t  uep->ue_array[i].ul_len, TRUE, TRUE);\n\t\telse\n\t\t    ml_append_flags(lnum, uep->ue_array[i].ul_line,\n\t\t\t     (colnr_T)uep->ue_array[i].ul_len, ML_APPEND_UNDO);\n\t\tvim_free(uep->ue_array[i].ul_line);\n\t    }\n\t    vim_free((char_u *)uep->ue_array);\n\t}\n\n\t\/\/ adjust marks\n\tif (oldsize != newsize)\n\t{\n\t    mark_adjust(top + 1, top + oldsize, (long)MAXLNUM,\n\t\t\t\t\t       (long)newsize - (long)oldsize);\n\t    if (curbuf->b_op_start.lnum > top + oldsize)\n\t\tcurbuf->b_op_start.lnum += newsize - oldsize;\n\t    if (curbuf->b_op_end.lnum > top + oldsize)\n\t\tcurbuf->b_op_end.lnum += newsize - oldsize;\n\t}\n\n\tchanged_lines(top + 1, 0, bot, newsize - oldsize);\n\n\t\/\/ set '[ and '] mark\n\tif (top + 1 < curbuf->b_op_start.lnum)\n\t    curbuf->b_op_start.lnum = top + 1;\n\tif (newsize == 0 && top + 1 > curbuf->b_op_end.lnum)\n\t    curbuf->b_op_end.lnum = top + 1;\n\telse if (top + newsize > curbuf->b_op_end.lnum)\n\t    curbuf->b_op_end.lnum = top + newsize;\n\n\tu_newcount += newsize;\n\tu_oldcount += oldsize;\n\tuep->ue_size = oldsize;\n\tuep->ue_array = newarray;\n\tuep->ue_bot = top + newsize + 1;\n\n\t\/*\n\t * insert this entry in front of the new entry list\n\t *\/\n\tnuep = uep->ue_next;\n\tuep->ue_next = newlist;\n\tnewlist = uep;\n    }\n\n    \/\/ Set the cursor to the desired position.  Check that the line is valid.\n    curwin->w_cursor = new_curpos;\n    check_cursor_lnum();\n\n    curhead->uh_entry = newlist;\n    curhead->uh_flags = new_flags;\n    if ((old_flags & UH_EMPTYBUF) && BUFEMPTY())\n\tcurbuf->b_ml.ml_flags |= ML_EMPTY;\n    if (old_flags & UH_CHANGED)\n\tchanged();\n    else\n#ifdef FEAT_NETBEANS_INTG\n\t\/\/ per netbeans undo rules, keep it as modified\n\tif (!isNetbeansModified(curbuf))\n#endif\n\tunchanged(curbuf, FALSE, TRUE);\n\n    \/*\n     * restore marks from before undo\/redo\n     *\/\n    for (i = 0; i < NMARKS; ++i)\n    {\n\tif (curhead->uh_namedm[i].lnum != 0)\n\t    curbuf->b_namedm[i] = curhead->uh_namedm[i];\n\tif (namedm[i].lnum != 0)\n\t    curhead->uh_namedm[i] = namedm[i];\n\telse\n\t    curhead->uh_namedm[i].lnum = 0;\n    }\n    if (curhead->uh_visual.vi_start.lnum != 0)\n    {\n\tcurbuf->b_visual = curhead->uh_visual;\n\tcurhead->uh_visual = visualinfo;\n    }\n\n    \/*\n     * If the cursor is only off by one line, put it at the same position as\n     * before starting the change (for the \"o\" command).\n     * Otherwise the cursor should go to the first undone line.\n     *\/\n    if (curhead->uh_cursor.lnum + 1 == curwin->w_cursor.lnum\n\t\t\t\t\t\t && curwin->w_cursor.lnum > 1)\n\t--curwin->w_cursor.lnum;\n    if (curwin->w_cursor.lnum <= curbuf->b_ml.ml_line_count)\n    {\n\tif (curhead->uh_cursor.lnum == curwin->w_cursor.lnum)\n\t{\n\t    curwin->w_cursor.col = curhead->uh_cursor.col;\n\t    if (virtual_active() && curhead->uh_cursor_vcol >= 0)\n\t\tcoladvance((colnr_T)curhead->uh_cursor_vcol);\n\t    else\n\t\tcurwin->w_cursor.coladd = 0;\n\t}\n\telse\n\t    beginline(BL_SOL | BL_FIX);\n    }\n    else\n    {\n\t\/\/ We get here with the current cursor line being past the end (eg\n\t\/\/ after adding lines at the end of the file, and then undoing it).\n\t\/\/ check_cursor() will move the cursor to the last line.  Move it to\n\t\/\/ the first column here.\n\tcurwin->w_cursor.col = 0;\n\tcurwin->w_cursor.coladd = 0;\n    }\n\n    \/\/ Make sure the cursor is on an existing line and column.\n    check_cursor();\n\n    \/\/ Remember where we are for \"g-\" and \":earlier 10s\".\n    curbuf->b_u_seq_cur = curhead->uh_seq;\n    if (undo)\n    {\n\t\/\/ We are below the previous undo.  However, to make \":earlier 1s\"\n\t\/\/ work we compute this as being just above the just undone change.\n\tif (curhead->uh_next.ptr != NULL)\n\t    curbuf->b_u_seq_cur = curhead->uh_next.ptr->uh_seq;\n\telse\n\t    curbuf->b_u_seq_cur = 0;\n    }\n\n    \/\/ Remember where we are for \":earlier 1f\" and \":later 1f\".\n    if (curhead->uh_save_nr != 0)\n    {\n\tif (undo)\n\t    curbuf->b_u_save_nr_cur = curhead->uh_save_nr - 1;\n\telse\n\t    curbuf->b_u_save_nr_cur = curhead->uh_save_nr;\n    }\n\n    \/\/ The timestamp can be the same for multiple changes, just use the one of\n    \/\/ the undone\/redone change.\n    curbuf->b_u_time_cur = curhead->uh_time;\n\n    unblock_autocmds();\n#ifdef U_DEBUG\n    u_check(FALSE);\n#endif\n}","target":0,"code_token_length":2676,"total_token_length":2912,"max_tokens_setting":4096}
+{"idx":404193,"func":"static void copy_recurse_data(compiler_common *common, PCRE2_SPTR cc, PCRE2_SPTR ccend,\n  int type, int stackptr, int stacktop, BOOL has_quit)\n{\ndelayed_mem_copy_status status;\nPCRE2_SPTR alternative;\nsljit_sw private_srcw[2];\nsljit_sw shared_srcw[3];\nsljit_sw kept_shared_srcw[2];\nint private_count, shared_count, kept_shared_count;\nint from_sp, base_reg, offset, i;\n\nmemset(common->recurse_bitset, 0, common->recurse_bitset_size);\n\n#if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD\nSLJIT_ASSERT(common->control_head_ptr != 0);\nrecurse_check_bit(common, common->control_head_ptr);\n#endif\n\nswitch (type)\n  {\n  case recurse_copy_from_global:\n  from_sp = TRUE;\n  base_reg = STACK_TOP;\n  break;\n\n  case recurse_copy_private_to_global:\n  case recurse_copy_shared_to_global:\n  case recurse_copy_kept_shared_to_global:\n  from_sp = FALSE;\n  base_reg = STACK_TOP;\n  break;\n\n  default:\n  SLJIT_ASSERT(type == recurse_swap_global);\n  from_sp = FALSE;\n  base_reg = TMP2;\n  break;\n  }\n\nstackptr = STACK(stackptr);\nstacktop = STACK(stacktop);\n\nstatus.tmp_regs[0] = TMP1;\nstatus.saved_tmp_regs[0] = TMP1;\n\nif (base_reg != TMP2)\n  {\n  status.tmp_regs[1] = TMP2;\n  status.saved_tmp_regs[1] = TMP2;\n  }\nelse\n  {\n  status.saved_tmp_regs[1] = RETURN_ADDR;\n  if (HAS_VIRTUAL_REGISTERS)\n    status.tmp_regs[1] = STR_PTR;\n  else\n    status.tmp_regs[1] = RETURN_ADDR;\n  }\n\nstatus.saved_tmp_regs[2] = TMP3;\nif (HAS_VIRTUAL_REGISTERS)\n  status.tmp_regs[2] = STR_END;\nelse\n  status.tmp_regs[2] = TMP3;\n\ndelayed_mem_copy_init(&status, common);\n\nif (type != recurse_copy_shared_to_global && type != recurse_copy_kept_shared_to_global)\n  {\n  SLJIT_ASSERT(type == recurse_copy_from_global || type == recurse_copy_private_to_global || type == recurse_swap_global);\n\n  if (!from_sp)\n    delayed_mem_copy_move(&status, base_reg, stackptr, SLJIT_SP, common->recursive_head_ptr);\n\n  if (from_sp || type == recurse_swap_global)\n    delayed_mem_copy_move(&status, SLJIT_SP, common->recursive_head_ptr, base_reg, stackptr);\n  }\n\nstackptr += sizeof(sljit_sw);\n\n#if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD\nif (type != recurse_copy_shared_to_global)\n  {\n  if (!from_sp)\n    delayed_mem_copy_move(&status, base_reg, stackptr, SLJIT_SP, common->control_head_ptr);\n\n  if (from_sp || type == recurse_swap_global)\n    delayed_mem_copy_move(&status, SLJIT_SP, common->control_head_ptr, base_reg, stackptr);\n  }\n\nstackptr += sizeof(sljit_sw);\n#endif\n\nwhile (cc < ccend)\n  {\n  private_count = 0;\n  shared_count = 0;\n  kept_shared_count = 0;\n\n  switch(*cc)\n    {\n    case OP_SET_SOM:\n    SLJIT_ASSERT(common->has_set_som);\n    if (has_quit && recurse_check_bit(common, OVECTOR(0)))\n      {\n      kept_shared_srcw[0] = OVECTOR(0);\n      kept_shared_count = 1;\n      }\n    cc += 1;\n    break;\n\n    case OP_RECURSE:\n    if (has_quit)\n      {\n      if (common->has_set_som && recurse_check_bit(common, OVECTOR(0)))\n        {\n        kept_shared_srcw[0] = OVECTOR(0);\n        kept_shared_count = 1;\n        }\n      if (common->mark_ptr != 0 && recurse_check_bit(common, common->mark_ptr))\n        {\n        kept_shared_srcw[kept_shared_count] = common->mark_ptr;\n        kept_shared_count++;\n        }\n      }\n    if (common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))\n      {\n      shared_srcw[0] = common->capture_last_ptr;\n      shared_count = 1;\n      }\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_KET:\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0)\n      {\n      if (recurse_check_bit(common, private_srcw[0]))\n        private_count = 1;\n      SLJIT_ASSERT(PRIVATE_DATA(cc + 1) != 0);\n      cc += PRIVATE_DATA(cc + 1);\n      }\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_ASSERT:\n    case OP_ASSERT_NOT:\n    case OP_ASSERTBACK:\n    case OP_ASSERTBACK_NOT:\n    case OP_ASSERT_NA:\n    case OP_ASSERTBACK_NA:\n    case OP_ONCE:\n    case OP_SCRIPT_RUN:\n    case OP_BRAPOS:\n    case OP_SBRA:\n    case OP_SBRAPOS:\n    case OP_SCOND:\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (recurse_check_bit(common, private_srcw[0]))\n      private_count = 1;\n    cc += 1 + LINK_SIZE;\n    break;\n\n    case OP_CBRA:\n    case OP_SCBRA:\n    offset = GET2(cc, 1 + LINK_SIZE);\n    shared_srcw[0] = OVECTOR(offset << 1);\n    if (recurse_check_bit(common, shared_srcw[0]))\n      {\n      shared_srcw[1] = shared_srcw[0] + sizeof(sljit_sw);\n      SLJIT_ASSERT(recurse_check_bit(common, shared_srcw[1]));\n      shared_count = 2;\n      }\n\n    if (common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))\n      {\n      shared_srcw[shared_count] = common->capture_last_ptr;\n      shared_count++;\n      }\n\n    if (common->optimized_cbracket[offset] == 0)\n      {\n      private_srcw[0] = OVECTOR_PRIV(offset);\n      if (recurse_check_bit(common, private_srcw[0]))\n        private_count = 1;\n      }\n\n    cc += 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_CBRAPOS:\n    case OP_SCBRAPOS:\n    offset = GET2(cc, 1 + LINK_SIZE);\n    shared_srcw[0] = OVECTOR(offset << 1);\n    if (recurse_check_bit(common, shared_srcw[0]))\n      {\n      shared_srcw[1] = shared_srcw[0] + sizeof(sljit_sw);\n      SLJIT_ASSERT(recurse_check_bit(common, shared_srcw[1]));\n      shared_count = 2;\n      }\n\n    if (common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))\n      {\n      shared_srcw[shared_count] = common->capture_last_ptr;\n      shared_count++;\n      }\n\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (recurse_check_bit(common, private_srcw[0]))\n      private_count = 1;\n\n    offset = OVECTOR_PRIV(offset);\n    if (recurse_check_bit(common, offset))\n      {\n      private_srcw[private_count] = offset;\n      private_count++;\n      }\n    cc += 1 + LINK_SIZE + IMM2_SIZE;\n    break;\n\n    case OP_COND:\n    \/* Might be a hidden SCOND. *\/\n    alternative = cc + GET(cc, 1);\n    if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)\n      {\n      private_srcw[0] = PRIVATE_DATA(cc);\n      if (recurse_check_bit(common, private_srcw[0]))\n        private_count = 1;\n      }\n    cc += 1 + LINK_SIZE;\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_1\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))\n      private_count = 1;\n    cc += 2;\n#ifdef SUPPORT_UNICODE\n    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_2A\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))\n      {\n      private_count = 2;\n      private_srcw[1] = private_srcw[0] + sizeof(sljit_sw);\n      SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));\n      }\n    cc += 2;\n#ifdef SUPPORT_UNICODE\n    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n    break;\n\n    CASE_ITERATOR_PRIVATE_DATA_2B\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))\n      {\n      private_count = 2;\n      private_srcw[1] = private_srcw[0] + sizeof(sljit_sw);\n      SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));\n      }\n    cc += 2 + IMM2_SIZE;\n#ifdef SUPPORT_UNICODE\n    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);\n#endif\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_1\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))\n      private_count = 1;\n    cc += 1;\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_2A\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))\n      {\n      private_count = 2;\n      private_srcw[1] = private_srcw[0] + sizeof(sljit_sw);\n      SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));\n      }\n    cc += 1;\n    break;\n\n    CASE_ITERATOR_TYPE_PRIVATE_DATA_2B\n    private_srcw[0] = PRIVATE_DATA(cc);\n    if (private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))\n      {\n      private_count = 2;\n      private_srcw[1] = private_srcw[0] + sizeof(sljit_sw);\n      SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));\n      }\n    cc += 1 + IMM2_SIZE;\n    break;\n\n    case OP_CLASS:\n    case OP_NCLASS:\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8\n    case OP_XCLASS:\n    i = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 \/ (int)sizeof(PCRE2_UCHAR);\n#else\n    i = 1 + 32 \/ (int)sizeof(PCRE2_UCHAR);\n#endif\n    if (PRIVATE_DATA(cc) != 0)\n      switch(get_class_iterator_size(cc + i))\n        {\n        case 1:\n        private_srcw[0] = PRIVATE_DATA(cc);\n        break;\n\n        case 2:\n        private_srcw[0] = PRIVATE_DATA(cc);\n        if (recurse_check_bit(common, private_srcw[0]))\n          {\n          private_count = 2;\n          private_srcw[1] = private_srcw[0] + sizeof(sljit_sw);\n          SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));\n          }\n        break;\n\n        default:\n        SLJIT_UNREACHABLE();\n        break;\n        }\n    cc += i;\n    break;\n\n    case OP_MARK:\n    case OP_COMMIT_ARG:\n    case OP_PRUNE_ARG:\n    case OP_THEN_ARG:\n    SLJIT_ASSERT(common->mark_ptr != 0);\n    if (has_quit && recurse_check_bit(common, common->mark_ptr))\n      {\n      kept_shared_srcw[0] = common->mark_ptr;\n      kept_shared_count = 1;\n      }\n    if (common->control_head_ptr != 0 && recurse_check_bit(common, common->control_head_ptr))\n      {\n      private_srcw[0] = common->control_head_ptr;\n      private_count = 1;\n      }\n    cc += 1 + 2 + cc[1];\n    break;\n\n    case OP_THEN:\n    SLJIT_ASSERT(common->control_head_ptr != 0);\n    if (recurse_check_bit(common, common->control_head_ptr))\n      {\n      private_srcw[0] = common->control_head_ptr;\n      private_count = 1;\n      }\n    cc++;\n    break;\n\n    default:\n    cc = next_opcode(common, cc);\n    SLJIT_ASSERT(cc != NULL);\n    continue;\n    }\n\n  if (type != recurse_copy_shared_to_global && type != recurse_copy_kept_shared_to_global)\n    {\n    SLJIT_ASSERT(type == recurse_copy_from_global || type == recurse_copy_private_to_global || type == recurse_swap_global);\n\n    for (i = 0; i < private_count; i++)\n      {\n      SLJIT_ASSERT(private_srcw[i] != 0);\n\n      if (!from_sp)\n        delayed_mem_copy_move(&status, base_reg, stackptr, SLJIT_SP, private_srcw[i]);\n\n      if (from_sp || type == recurse_swap_global)\n        delayed_mem_copy_move(&status, SLJIT_SP, private_srcw[i], base_reg, stackptr);\n\n      stackptr += sizeof(sljit_sw);\n      }\n    }\n  else\n    stackptr += sizeof(sljit_sw) * private_count;\n\n  if (type != recurse_copy_private_to_global && type != recurse_copy_kept_shared_to_global)\n    {\n    SLJIT_ASSERT(type == recurse_copy_from_global || type == recurse_copy_shared_to_global || type == recurse_swap_global);\n\n    for (i = 0; i < shared_count; i++)\n      {\n      SLJIT_ASSERT(shared_srcw[i] != 0);\n\n      if (!from_sp)\n        delayed_mem_copy_move(&status, base_reg, stackptr, SLJIT_SP, shared_srcw[i]);\n\n      if (from_sp || type == recurse_swap_global)\n        delayed_mem_copy_move(&status, SLJIT_SP, shared_srcw[i], base_reg, stackptr);\n\n      stackptr += sizeof(sljit_sw);\n      }\n    }\n  else\n    stackptr += sizeof(sljit_sw) * shared_count;\n\n  if (type != recurse_copy_private_to_global && type != recurse_swap_global)\n    {\n    SLJIT_ASSERT(type == recurse_copy_from_global || type == recurse_copy_shared_to_global || type == recurse_copy_kept_shared_to_global);\n\n    for (i = 0; i < kept_shared_count; i++)\n      {\n      SLJIT_ASSERT(kept_shared_srcw[i] != 0);\n\n      if (!from_sp)\n        delayed_mem_copy_move(&status, base_reg, stackptr, SLJIT_SP, kept_shared_srcw[i]);\n\n      if (from_sp || type == recurse_swap_global)\n        delayed_mem_copy_move(&status, SLJIT_SP, kept_shared_srcw[i], base_reg, stackptr);\n\n      stackptr += sizeof(sljit_sw);\n      }\n    }\n  else\n    stackptr += sizeof(sljit_sw) * kept_shared_count;\n  }\n\nSLJIT_ASSERT(cc == ccend && stackptr == stacktop);\n\ndelayed_mem_copy_finish(&status);\n}","target":0,"code_token_length":3415,"total_token_length":3651,"max_tokens_setting":4096}
+{"idx":310197,"func":"NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx\n\t\t\t  chtype newmode,\n\t\t\t  NCURSES_SP_OUTC outc)\n{\n    attr_t turn_on, turn_off;\n    int pair;\n    bool reverse = FALSE;\n    bool can_color = (SP_PARM == 0 || SP_PARM->_coloron);\n#if NCURSES_EXT_FUNCS\n    bool fix_pair0 = (SP_PARM != 0 && SP_PARM->_coloron && !SP_PARM->_default_color);\n#else\n#define fix_pair0 FALSE\n#endif\n\n    newmode &= A_ATTRIBUTES;\n\n    T((T_CALLED(\"vidputs(%p,%s)\"), (void *) SP_PARM, _traceattr(newmode)));\n\n    if (!IsValidTIScreen(SP_PARM))\n\treturnCode(ERR);\n\n    \/* this allows us to go on whether or not newterm() has been called *\/\n    if (SP_PARM)\n\tPreviousAttr = AttrOf(SCREEN_ATTRS(SP_PARM));\n\n    TR(TRACE_ATTRS, (\"previous attribute was %s\", _traceattr(PreviousAttr)));\n\n    if ((SP_PARM != 0)\n\t&& (magic_cookie_glitch > 0)) {\n#if USE_XMC_SUPPORT\n\tstatic const chtype table[] =\n\t{\n\t    A_STANDOUT,\n\t    A_UNDERLINE,\n\t    A_REVERSE,\n\t    A_BLINK,\n\t    A_DIM,\n\t    A_BOLD,\n\t    A_INVIS,\n\t    A_PROTECT,\n#if USE_ITALIC\n\t    A_ITALIC,\n#endif\n\t};\n\tunsigned n;\n\tint used = 0;\n#ifdef max_attributes\t\t\/* not in U\/Win *\/\n\tint limit = (max_attributes <= 0) ? 1 : max_attributes;\n#else\n\tint limit = 1;\n#endif\n\tchtype retain = 0;\n\n\t\/*\n\t * Limit the number of attribute bits set in the newmode according to\n\t * the terminfo max_attributes value.\n\t *\/\n\tfor (n = 0; n < SIZEOF(table); ++n) {\n\t    if ((table[n] & SP_PARM->_ok_attributes) == 0) {\n\t\tnewmode &= ~table[n];\n\t    } else if ((table[n] & newmode) != 0) {\n\t\tif (used++ >= limit) {\n\t\t    newmode &= ~table[n];\n\t\t    if (newmode == retain)\n\t\t\tbreak;\n\t\t} else {\n\t\t    retain = newmode;\n\t\t}\n\t    }\n\t}\n#else\n\tnewmode &= ~(SP_PARM->_xmc_suppress);\n#endif\n\tTR(TRACE_ATTRS, (\"suppressed attribute is %s\", _traceattr(newmode)));\n    }\n\n    \/*\n     * If we have a terminal that cannot combine color with video\n     * attributes, use the colors in preference.\n     *\/\n    if (((newmode & A_COLOR) != 0\n\t || fix_pair0)\n\t&& (no_color_video > 0)) {\n\t\/*\n\t * If we had chosen the A_xxx definitions to correspond to the\n\t * no_color_video mask, we could simply shift it up and mask off the\n\t * attributes.  But we did not (actually copied Solaris' definitions).\n\t * However, this is still simpler\/faster than a lookup table.\n\t *\n\t * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK,\n\t * A_DIM, A_BOLD which are 1:1 with no_color_video.  The bits that\n\t * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and\n\t * A_ALTCHARSET (256) down 2 to line up.  We use the NCURSES_BITS\n\t * macro so this will work properly for the wide-character layout.\n\t *\/\n\tunsigned value = (unsigned) no_color_video;\n\tattr_t mask = NCURSES_BITS((value & 63)\n\t\t\t\t   | ((value & 192) << 1)\n\t\t\t\t   | ((value & 256) >> 2), 8);\n\n\tif ((mask & A_REVERSE) != 0\n\t    && (newmode & A_REVERSE) != 0) {\n\t    reverse = TRUE;\n\t    mask &= ~A_REVERSE;\n\t}\n\tnewmode &= ~mask;\n    }\n\n    if (newmode == PreviousAttr)\n\treturnCode(OK);\n\n    pair = PairNumber(newmode);\n\n    if (reverse) {\n\tnewmode &= ~A_REVERSE;\n    }\n\n    turn_off = (~newmode & PreviousAttr) & ALL_BUT_COLOR;\n    turn_on = (newmode & ~(PreviousAttr & TPARM_ATTR)) & ALL_BUT_COLOR;\n\n    SetColorsIf(((pair == 0) && !fix_pair0), PreviousAttr);\n\n    if (newmode == A_NORMAL) {\n\tif ((PreviousAttr & A_ALTCHARSET) && exit_alt_charset_mode) {\n\t    doPut(exit_alt_charset_mode);\n\t    PreviousAttr &= ~A_ALTCHARSET;\n\t}\n\tif (PreviousAttr) {\n\t    if (exit_attribute_mode) {\n\t\tdoPut(exit_attribute_mode);\n\t    } else {\n\t\tif (!SP_PARM || SP_PARM->_use_rmul) {\n\t\t    TurnOff(A_UNDERLINE, exit_underline_mode);\n\t\t}\n\t\tif (!SP_PARM || SP_PARM->_use_rmso) {\n\t\t    TurnOff(A_STANDOUT, exit_standout_mode);\n\t\t}\n#if USE_ITALIC\n\t\tif (!SP_PARM || SP_PARM->_use_ritm) {\n\t\t    TurnOff(A_ITALIC, exit_italics_mode);\n\t\t}\n#endif\n\t    }\n\t    PreviousAttr &= ALL_BUT_COLOR;\n\t}\n\n\tSetColorsIf((pair != 0) || fix_pair0, PreviousAttr);\n    } else if (set_attributes) {\n\tif (turn_on || turn_off) {\n\t    TPUTS_TRACE(\"set_attributes\");\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_9(set_attributes,\n\t\t\t\t\t     (newmode & A_STANDOUT) != 0,\n\t\t\t\t\t     (newmode & A_UNDERLINE) != 0,\n\t\t\t\t\t     (newmode & A_REVERSE) != 0,\n\t\t\t\t\t     (newmode & A_BLINK) != 0,\n\t\t\t\t\t     (newmode & A_DIM) != 0,\n\t\t\t\t\t     (newmode & A_BOLD) != 0,\n\t\t\t\t\t     (newmode & A_INVIS) != 0,\n\t\t\t\t\t     (newmode & A_PROTECT) != 0,\n\t\t\t\t\t     (newmode & A_ALTCHARSET) != 0),\n\t\t\t\t    1, outc);\n\t    PreviousAttr &= ALL_BUT_COLOR;\n\t}\n#if USE_ITALIC\n\tif (!SP_PARM || SP_PARM->_use_ritm) {\n\t    if (turn_on & A_ITALIC) {\n\t\tTurnOn(A_ITALIC, enter_italics_mode);\n\t    } else if (turn_off & A_ITALIC) {\n\t\tTurnOff(A_ITALIC, exit_italics_mode);\n\t    }\n\t}\n#endif\n\tSetColorsIf((pair != 0) || fix_pair0, PreviousAttr);\n    } else {\n\n\tTR(TRACE_ATTRS, (\"turning %s off\", _traceattr(turn_off)));\n\n\tTurnOff(A_ALTCHARSET, exit_alt_charset_mode);\n\n\tif (!SP_PARM || SP_PARM->_use_rmul) {\n\t    TurnOff(A_UNDERLINE, exit_underline_mode);\n\t}\n\n\tif (!SP_PARM || SP_PARM->_use_rmso) {\n\t    TurnOff(A_STANDOUT, exit_standout_mode);\n\t}\n#if USE_ITALIC\n\tif (!SP_PARM || SP_PARM->_use_ritm) {\n\t    TurnOff(A_ITALIC, exit_italics_mode);\n\t}\n#endif\n\tif (turn_off && exit_attribute_mode) {\n\t    doPut(exit_attribute_mode);\n\t    turn_on |= (newmode & ALL_BUT_COLOR);\n\t    PreviousAttr &= ALL_BUT_COLOR;\n\t}\n\tSetColorsIf((pair != 0) || fix_pair0, PreviousAttr);\n\n\tTR(TRACE_ATTRS, (\"turning %s on\", _traceattr(turn_on)));\n\t\/* *INDENT-OFF* *\/\n\tTurnOn(A_ALTCHARSET,\tenter_alt_charset_mode);\n\tTurnOn(A_BLINK,\t\tenter_blink_mode);\n\tTurnOn(A_BOLD,\t\tenter_bold_mode);\n\tTurnOn(A_DIM,\t\tenter_dim_mode);\n\tTurnOn(A_REVERSE,\tenter_reverse_mode);\n\tTurnOn(A_STANDOUT,\tenter_standout_mode);\n\tTurnOn(A_PROTECT,\tenter_protected_mode);\n\tTurnOn(A_INVIS,\t\tenter_secure_mode);\n\tTurnOn(A_UNDERLINE,\tenter_underline_mode);\n#if USE_ITALIC\n\tTurnOn(A_ITALIC,\tenter_italics_mode);\n#endif\n#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode)\n\tTurnOn(A_HORIZONTAL,\tenter_horizontal_hl_mode);\n\tTurnOn(A_LEFT,\t\tenter_left_hl_mode);\n\tTurnOn(A_LOW,\t\tenter_low_hl_mode);\n\tTurnOn(A_RIGHT,\t\tenter_right_hl_mode);\n\tTurnOn(A_TOP,\t\tenter_top_hl_mode);\n\tTurnOn(A_VERTICAL,\tenter_vertical_hl_mode);\n#endif\n\t\/* *INDENT-ON* *\/\n    }\n\n    if (reverse)\n\tnewmode |= A_REVERSE;\n\n    if (SP_PARM)\n\tSetAttr(SCREEN_ATTRS(SP_PARM), newmode);\n    else\n\tPreviousAttr = newmode;\n\n    returnCode(OK);\n}","target":0,"code_token_length":2017,"total_token_length":2253,"max_tokens_setting":4096}
+{"idx":204137,"func":"bool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str,\n\t\t\t\t\tconst double *ptm, int paintType, int \/*tilingType*\/, Dict *resDict,\n\t\t\t\t\tconst double *mat, const double *bbox,\n\t\t\t\t\tint x0, int y0, int x1, int y1,\n\t\t\t\t\tdouble xStep, double yStep)\n{\n  PDFRectangle box;\n  Gfx *gfx;\n  Splash *formerSplash = splash;\n  SplashBitmap *formerBitmap = bitmap;\n  double width, height;\n  int surface_width, surface_height, result_width, result_height, i;\n  int repeatX, repeatY;\n  SplashCoord matc[6];\n  Matrix m1;\n  const double *ctm;\n  double savedCTM[6];\n  double kx, ky, sx, sy;\n  bool retValue = false;\n\n  width = bbox[2] - bbox[0];\n  height = bbox[3] - bbox[1];\n\n  if (xStep != width || yStep != height)\n    return false;\n\n  \/\/ calculate offsets\n  ctm = state->getCTM();\n  for (i = 0; i < 6; ++i) {\n    savedCTM[i] = ctm[i];\n  }\n  state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);\n  state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]);\n  ctm = state->getCTM();\n  for (i = 0; i < 6; ++i) {\n    if (!std::isfinite(ctm[i])) {\n      state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n      return false;\n    }\n  }\n  matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4];\n  matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5];\n  if (splashAbs(ctm[1]) > splashAbs(ctm[0])) {\n    kx = -ctm[1];\n    ky = ctm[2] - (ctm[0] * ctm[3]) \/ ctm[1];\n  } else {\n    kx = ctm[0];\n    ky = ctm[3] - (ctm[1] * ctm[2]) \/ ctm[0];\n  }\n  result_width = (int) ceil(fabs(kx * width * (x1 - x0)));\n  result_height = (int) ceil(fabs(ky * height * (y1 - y0)));\n  kx = state->getHDPI() \/ 72.0;\n  ky = state->getVDPI() \/ 72.0;\n  m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx;\n  m1.m[1] = 0;\n  m1.m[2] = 0;\n  m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky;\n  m1.m[4] = 0;\n  m1.m[5] = 0;\n  m1.transform(width, height, &kx, &ky);\n  surface_width = (int) ceil (fabs(kx));\n  surface_height = (int) ceil (fabs(ky));\n\n  sx = (double) result_width \/ (surface_width * (x1 - x0));\n  sy = (double) result_height \/ (surface_height * (y1 - y0));\n  m1.m[0] *= sx;\n  m1.m[3] *= sy;\n  m1.transform(width, height, &kx, &ky);\n\n  if(fabs(kx) < 1 && fabs(ky) < 1) {\n    kx = std::min<double>(kx, ky);\n    ky = 2 \/ kx;\n    m1.m[0] *= ky;\n    m1.m[3] *= ky;\n    m1.transform(width, height, &kx, &ky);\n    surface_width = (int) ceil (fabs(kx));\n    surface_height = (int) ceil (fabs(ky));\n    repeatX = x1 - x0;\n    repeatY = y1 - y0;\n  } else {\n    if ((unsigned long) surface_width * surface_height > 0x800000L) {\n      state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n      return false;\n    }\n    while(fabs(kx) > 16384 || fabs(ky) > 16384) {\n      \/\/ limit pattern bitmap size\n      m1.m[0] \/= 2;\n      m1.m[3] \/= 2;\n      m1.transform(width, height, &kx, &ky);\n    }\n    surface_width = (int) ceil (fabs(kx));\n    surface_height = (int) ceil (fabs(ky));\n    \/\/ adjust repeat values to completely fill region\n    repeatX = result_width \/ surface_width;\n    repeatY = result_height \/ surface_height;\n    if (surface_width * repeatX < result_width)\n      repeatX++;\n    if (surface_height * repeatY < result_height)\n      repeatY++;\n    if (x1 - x0 > repeatX)\n      repeatX = x1 - x0;\n    if (y1 - y0 > repeatY)\n      repeatY = y1 - y0;\n  }\n  \/\/ restore CTM and calculate rotate and scale with rounded matrix\n  state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n  state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);\n  state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]);\n  ctm = state->getCTM();\n  matc[0] = ctm[0];\n  matc[1] = ctm[1];\n  matc[2] = ctm[2];\n  matc[3] = ctm[3];\n\n  if (surface_width == 0 || surface_height == 0 || repeatX * repeatY <= 4) {\n    state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n    return false;\n  }\n  m1.transform(bbox[0], bbox[1], &kx, &ky);\n  m1.m[4] = -kx;\n  m1.m[5] = -ky;\n\n  bitmap = new SplashBitmap(surface_width, surface_height, 1,\n                            (paintType == 1) ? colorMode : splashModeMono8, true);\n  if (bitmap->getDataPtr() == nullptr) {\n    SplashBitmap *tBitmap = bitmap;\n    bitmap = formerBitmap;\n    delete tBitmap;\n    state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);\n    return false;\n  }\n  splash = new Splash(bitmap, true);\n  if (paintType == 2) {\n    SplashColor clearColor;\n#ifdef SPLASH_CMYK\n    clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF;\n#else\n    clearColor[0] = 0xFF;\n#endif\n    splash->clear(clearColor, 0);\n  } else {\n    splash->clear(paperColor, 0);\n  }\n  splash->setThinLineMode(formerSplash->getThinLineMode());\n  splash->setMinLineWidth(s_minLineWidth);\n\n  box.x1 = bbox[0]; box.y1 = bbox[1];\n  box.x2 = bbox[2]; box.y2 = bbox[3];\n  gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);\n  \/\/ set pattern transformation matrix\n  gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);\n  updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);\n  gfx->display(str);\n  delete splash;\n  splash = formerSplash;\n  TilingSplashOutBitmap imgData;\n  imgData.bitmap = bitmap;\n  imgData.paintType = paintType;\n  imgData.pattern = splash->getFillPattern();\n  imgData.colorMode = colorMode;\n  imgData.y = 0;\n  imgData.repeatX = repeatX;\n  imgData.repeatY = repeatY;\n  SplashBitmap *tBitmap = bitmap;\n  bitmap = formerBitmap;\n  result_width = tBitmap->getWidth() * imgData.repeatX;\n  result_height = tBitmap->getHeight() * imgData.repeatY;\n\n  if (splashAbs(matc[1]) > splashAbs(matc[0])) {\n    kx = -matc[1];\n    ky = matc[2] - (matc[0] * matc[3]) \/ matc[1];\n  } else {\n    kx = matc[0];\n    ky = matc[3] - (matc[1] * matc[2]) \/ matc[0];\n  }\n  kx = result_width \/ (fabs(kx) + 1);\n  ky = result_height \/ (fabs(ky) + 1);\n  state->concatCTM(kx, 0, 0, ky, 0, 0);\n  ctm = state->getCTM();\n  matc[0] = ctm[0];\n  matc[1] = ctm[1];\n  matc[2] = ctm[2];\n  matc[3] = ctm[3];\n  bool minorAxisZero = matc[1] == 0 && matc[2] == 0;\n  if (matc[0] > 0 && minorAxisZero && matc[3] > 0) {\n    \/\/ draw the tiles\n    for (int y = 0; y < imgData.repeatY; ++y) {\n      for (int x = 0; x < imgData.repeatX; ++x) {\n        x0 = splashFloor(matc[4]) + x * tBitmap->getWidth();\n        y0 = splashFloor(matc[5]) + y * tBitmap->getHeight();\n        splash->blitImage(tBitmap, true, x0, y0);\n      }\n    }\n    retValue = true;\n  } else {\n    retValue = splash->drawImage(&tilingBitmapSrc, nullptr, &imgData, colorMode, true, result_width, result_height, matc, false, true) == splashOk;\n  }\n  delete tBitmap;\n  delete gfx;\n  return retValue;\n}","target":1,"code_token_length":2571,"total_token_length":2807,"max_tokens_setting":4096}
+{"idx":196841,"func":"inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord, const DivPattern** patCache) {\n  static char id[32];\n  bool selectedRow=(i>=sel1.y && i<=sel2.y);\n  ImGui::TableNextRow(0,lineHeight);\n  ImGui::TableNextColumn();\n  float cursorPosY=ImGui::GetCursorPos().y-ImGui::GetScrollY();\n  \/\/ check if the row is visible\n  if (cursorPosY<-lineHeight || cursorPosY>ImGui::GetWindowSize().y) {\n    return;\n  }\n  \/\/ check if we are in range\n  if (ord<0 || ord>=e->song.ordersLen) {\n    return;\n  }\n  if (i<0 || i>=e->song.patLen) {\n    return;\n  }\n  bool isPushing=false;\n  ImVec4 activeColor=uiColors[GUI_COLOR_PATTERN_ACTIVE];\n  ImVec4 inactiveColor=uiColors[GUI_COLOR_PATTERN_INACTIVE];\n  ImVec4 rowIndexColor=uiColors[GUI_COLOR_PATTERN_ROW_INDEX];\n  if (e->song.hilightB>0 && !(i%e->song.hilightB)) {\n    activeColor=uiColors[GUI_COLOR_PATTERN_ACTIVE_HI2];\n    inactiveColor=uiColors[GUI_COLOR_PATTERN_INACTIVE_HI2];\n    rowIndexColor=uiColors[GUI_COLOR_PATTERN_ROW_INDEX_HI2];\n  } else if (e->song.hilightA>0 && !(i%e->song.hilightA)) {\n    activeColor=uiColors[GUI_COLOR_PATTERN_ACTIVE_HI1];\n    inactiveColor=uiColors[GUI_COLOR_PATTERN_INACTIVE_HI1];\n    rowIndexColor=uiColors[GUI_COLOR_PATTERN_ROW_INDEX_HI1];\n  }\n  \/\/ check overflow highlight\n  if (settings.overflowHighlight) {\n    if (edit && cursor.y==i) {\n      ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,ImGui::GetColorU32(uiColors[GUI_COLOR_EDITING]));\n    } else if (isPlaying && oldRow==i) {\n      ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PLAY_HEAD]));\n    } else if (e->song.hilightB>0 && !(i%e->song.hilightB)) {\n      ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_HI_2]));\n    } else if (e->song.hilightA>0 && !(i%e->song.hilightA)) {\n      ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_HI_1]));\n    }\n  } else {\n    isPushing=true;\n    if (edit && cursor.y==i) {\n      ImGui::PushStyleColor(ImGuiCol_Header,ImGui::GetColorU32(uiColors[GUI_COLOR_EDITING]));\n    } else if (isPlaying && oldRow==i) {\n      ImGui::PushStyleColor(ImGuiCol_Header,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PLAY_HEAD]));\n    } else if (e->song.hilightB>0 && !(i%e->song.hilightB)) {\n      ImGui::PushStyleColor(ImGuiCol_Header,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_HI_2]));\n    } else if (e->song.hilightA>0 && !(i%e->song.hilightA)) {\n      ImGui::PushStyleColor(ImGuiCol_Header,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_HI_1]));\n    } else {\n      isPushing=false;\n    }\n  }\n  \/\/ row number\n  if (settings.patRowsBase==1) {\n    ImGui::TextColored(rowIndexColor,\" %.2X \",i);\n  } else {\n    ImGui::TextColored(rowIndexColor,\"%3d \",i);\n  }\n  \/\/ for each column\n  for (int j=0; j<chans; j++) {\n    \/\/ check if channel is not hidden\n    if (!e->song.chanShow[j]) {\n      patChanX[j]=ImGui::GetCursorPosX();\n      continue;\n    }\n    int chanVolMax=e->getMaxVolumeChan(j);\n    if (chanVolMax<1) chanVolMax=1;\n    const DivPattern* pat=patCache[j];\n    ImGui::TableNextColumn();\n    patChanX[j]=ImGui::GetCursorPosX();\n\n    \/\/ selection highlight flags\n    int sel1XSum=sel1.xCoarse*32+sel1.xFine;\n    int sel2XSum=sel2.xCoarse*32+sel2.xFine;\n    int j32=j*32;\n    bool selectedNote=selectedRow && (j32>=sel1XSum && j32<=sel2XSum);\n    bool selectedIns=selectedRow && (j32+1>=sel1XSum && j32+1<=sel2XSum);\n    bool selectedVol=selectedRow && (j32+2>=sel1XSum && j32+2<=sel2XSum);\n    bool cursorNote=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==0);\n    bool cursorIns=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==1);\n    bool cursorVol=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==2);\n\n    \/\/ note\n    sprintf(id,\"%s##PN_%d_%d\",noteName(pat->data[i][0],pat->data[i][1]),i,j);\n    if (pat->data[i][0]==0 && pat->data[i][1]==0) {\n      ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);\n    } else {\n      ImGui::PushStyleColor(ImGuiCol_Text,activeColor);\n    }\n    if (cursorNote) {\n      ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_CURSOR]);\n      ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_CURSOR_ACTIVE]);\n      ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_CURSOR_HOVER]);\n      ImGui::Selectable(id,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,threeChars);\n      demandX=ImGui::GetCursorPosX();\n      ImGui::PopStyleColor(3);\n    } else {\n      if (selectedNote) ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]);\n      ImGui::Selectable(id,isPushing || selectedNote,ImGuiSelectableFlags_NoPadWithHalfSpacing,threeChars);\n      if (selectedNote) ImGui::PopStyleColor();\n    }\n    if (ImGui::IsItemClicked()) {\n      startSelection(j,0,i);\n    }\n    if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {\n      updateSelection(j,0,i);\n    }\n    ImGui::PopStyleColor();\n\n    \/\/ the following is only visible when the channel is not collapsed\n    if (!e->song.chanCollapse[j]) {\n      \/\/ instrument\n      if (pat->data[i][2]==-1) {\n        ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);\n        sprintf(id,\"..##PI_%d_%d\",i,j);\n      } else {\n        if (pat->data[i][2]<0 || pat->data[i][2]>=e->song.insLen) {\n          ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_INS_ERROR]);\n        } else {\n          DivInstrumentType t=e->song.ins[pat->data[i][2]]->type;\n          if (t!=DIV_INS_AMIGA && t!=e->getPreferInsType(j)) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_INS_WARN]);\n          } else {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_INS]);\n          }\n        }\n        sprintf(id,\"%.2X##PI_%d_%d\",pat->data[i][2],i,j);\n      }\n      ImGui::SameLine(0.0f,0.0f);\n      if (cursorIns) {\n        ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_CURSOR]);\n        ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_CURSOR_ACTIVE]);\n        ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_CURSOR_HOVER]);\n        ImGui::Selectable(id,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n        demandX=ImGui::GetCursorPosX();\n        ImGui::PopStyleColor(3);\n      } else {\n        if (selectedIns) ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]);\n        ImGui::Selectable(id,isPushing || selectedIns,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n        if (selectedIns) ImGui::PopStyleColor();\n      }\n      if (ImGui::IsItemClicked()) {\n        startSelection(j,1,i);\n      }\n      if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {\n        updateSelection(j,1,i);\n      }\n      ImGui::PopStyleColor();\n\n      \/\/ volume\n      if (pat->data[i][3]==-1) {\n        sprintf(id,\"..##PV_%d_%d\",i,j);\n        ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);\n      } else {\n        int volColor=(pat->data[i][3]*127)\/chanVolMax;\n        if (volColor>127) volColor=127;\n        if (volColor<0) volColor=0;\n        sprintf(id,\"%.2X##PV_%d_%d\",pat->data[i][3],i,j);\n        ImGui::PushStyleColor(ImGuiCol_Text,volColors[volColor]);\n      }\n      ImGui::SameLine(0.0f,0.0f);\n      if (cursorVol) {\n        ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_CURSOR]);\n        ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_CURSOR_ACTIVE]);\n        ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_CURSOR_HOVER]);\n        ImGui::Selectable(id,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n        demandX=ImGui::GetCursorPosX();\n        ImGui::PopStyleColor(3);\n      } else {\n        if (selectedVol) ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]);\n        ImGui::Selectable(id,isPushing || selectedVol,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n        if (selectedVol) ImGui::PopStyleColor();\n      }\n      if (ImGui::IsItemClicked()) {\n        startSelection(j,2,i);\n      }\n      if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {\n        updateSelection(j,2,i);\n      }\n      ImGui::PopStyleColor();\n\n      \/\/ effects\n      for (int k=0; k<e->song.pat[j].effectRows; k++) {\n        int index=4+(k<<1);\n        bool selectedEffect=selectedRow && (j32+index-1>=sel1XSum && j32+index-1<=sel2XSum);\n        bool selectedEffectVal=selectedRow && (j32+index>=sel1XSum && j32+index<=sel2XSum);\n        bool cursorEffect=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==index-1);\n        bool cursorEffectVal=(cursor.y==i && cursor.xCoarse==j && cursor.xFine==index);\n        \n        \/\/ effect\n        if (pat->data[i][index]==-1) {\n          sprintf(id,\"..##PE%d_%d_%d\",k,i,j);\n          ImGui::PushStyleColor(ImGuiCol_Text,inactiveColor);\n        } else {\n          sprintf(id,\"%.2X##PE%d_%d_%d\",pat->data[i][index],k,i,j);\n          if (pat->data[i][index]<0x10) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColors[pat->data[i][index]]]);\n          } else if (pat->data[i][index]<0x20) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY]);\n          } else if (pat->data[i][index]<0x30) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY]);\n          } else if (pat->data[i][index]<0x48) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY]);\n          } else if (pat->data[i][index]<0x90) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);\n          } else if (pat->data[i][index]<0xa0) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_MISC]);\n          } else if (pat->data[i][index]<0xc0) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);\n          } else if (pat->data[i][index]<0xd0) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_SPEED]);\n          } else if (pat->data[i][index]<0xe0) {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);\n          } else {\n            ImGui::PushStyleColor(ImGuiCol_Text,uiColors[extFxColors[pat->data[i][index]-0xe0]]);\n          }\n        }\n        ImGui::SameLine(0.0f,0.0f);\n        if (cursorEffect) {\n          ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_CURSOR]);  \n          ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_CURSOR_ACTIVE]);\n          ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_CURSOR_HOVER]);\n          ImGui::Selectable(id,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n          demandX=ImGui::GetCursorPosX();\n          ImGui::PopStyleColor(3);\n        } else {\n          if (selectedEffect) ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]);\n          ImGui::Selectable(id,isPushing || selectedEffect,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n          if (selectedEffect) ImGui::PopStyleColor();\n        }\n        if (ImGui::IsItemClicked()) {\n          startSelection(j,index-1,i);\n        }\n        if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {\n          updateSelection(j,index-1,i);\n        }\n\n        \/\/ effect value\n        if (pat->data[i][index+1]==-1) {\n          sprintf(id,\"..##PF%d_%d_%d\",k,i,j);\n        } else {\n          sprintf(id,\"%.2X##PF%d_%d_%d\",pat->data[i][index+1],k,i,j);\n        }\n        ImGui::SameLine(0.0f,0.0f);\n        if (cursorEffectVal) {\n          ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_CURSOR]);  \n          ImGui::PushStyleColor(ImGuiCol_HeaderActive,uiColors[GUI_COLOR_PATTERN_CURSOR_ACTIVE]);\n          ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_CURSOR_HOVER]);\n          ImGui::Selectable(id,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n          demandX=ImGui::GetCursorPosX();\n          ImGui::PopStyleColor(3);\n        } else {\n          if (selectedEffectVal) ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]);\n          ImGui::Selectable(id,isPushing || selectedEffectVal,ImGuiSelectableFlags_NoPadWithHalfSpacing,twoChars);\n          if (selectedEffectVal) ImGui::PopStyleColor();\n        }\n        if (ImGui::IsItemClicked()) {\n          startSelection(j,index,i);\n        }\n        if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {\n          updateSelection(j,index,i);\n        }\n        ImGui::PopStyleColor();\n      }\n    }\n  }\n  if (isPushing) {\n    ImGui::PopStyleColor();\n  }\n  ImGui::TableNextColumn();\n  patChanX[chans]=ImGui::GetCursorPosX();\n}","target":1,"code_token_length":3623,"total_token_length":3859,"max_tokens_setting":4096}
+{"idx":234254,"func":"display_debug_lines_raw (struct dwarf_section *  section,\n\t\t\t unsigned char *         data,\n\t\t\t unsigned char *         end,\n\t\t\t void *                  file)\n{\n  unsigned char *start = section->start;\n  int verbose_view = 0;\n\n  introduce (section, true);\n\n  while (data < end)\n    {\n      static DWARF2_Internal_LineInfo saved_linfo;\n      DWARF2_Internal_LineInfo linfo;\n      unsigned char *standard_opcodes;\n      unsigned char *end_of_sequence;\n      int i;\n\n      if (startswith (section->name, \".debug_line.\")\n\t  \/* Note: the following does not apply to .debug_line.dwo sections.\n\t     These are full debug_line sections.  *\/\n\t  && strcmp (section->name, \".debug_line.dwo\") != 0)\n\t{\n\t  \/* Sections named .debug_line.<foo> are fragments of a .debug_line\n\t     section containing just the Line Number Statements.  They are\n\t     created by the assembler and intended to be used alongside gcc's\n\t     -ffunction-sections command line option.  When the linker's\n\t     garbage collection decides to discard a .text.<foo> section it\n\t     can then also discard the line number information in .debug_line.<foo>.\n\n\t     Since the section is a fragment it does not have the details\n\t     needed to fill out a LineInfo structure, so instead we use the\n\t     details from the last full debug_line section that we processed.  *\/\n\t  end_of_sequence = end;\n\t  standard_opcodes = NULL;\n\t  linfo = saved_linfo;\n\t  \/* PR 17531: file: 0522b371.  *\/\n\t  if (linfo.li_line_range == 0)\n\t    {\n\t      warn (_(\"Partial .debug_line. section encountered without a prior full .debug_line section\\n\"));\n\t      return 0;\n\t    }\n\t  reset_state_machine (linfo.li_default_is_stmt);\n\t}\n      else\n\t{\n\t  unsigned char * hdrptr;\n\n\t  if ((hdrptr = read_debug_line_header (section, data, end, & linfo,\n\t\t\t\t\t\t& end_of_sequence)) == NULL)\n\t    return 0;\n\n\t  printf (_(\"  Offset:                      0x%lx\\n\"), (long)(data - start));\n\t  printf (_(\"  Length:                      %ld\\n\"), (long) linfo.li_length);\n\t  printf (_(\"  DWARF Version:               %d\\n\"), linfo.li_version);\n\t  if (linfo.li_version >= 5)\n\t    {\n\t      printf (_(\"  Address size (bytes):        %d\\n\"), linfo.li_address_size);\n\t      printf (_(\"  Segment selector (bytes):    %d\\n\"), linfo.li_segment_size);\n\t    }\n\t  printf (_(\"  Prologue Length:             %d\\n\"), (int) linfo.li_prologue_length);\n\t  printf (_(\"  Minimum Instruction Length:  %d\\n\"), linfo.li_min_insn_length);\n\t  if (linfo.li_version >= 4)\n\t    printf (_(\"  Maximum Ops per Instruction: %d\\n\"), linfo.li_max_ops_per_insn);\n\t  printf (_(\"  Initial value of 'is_stmt':  %d\\n\"), linfo.li_default_is_stmt);\n\t  printf (_(\"  Line Base:                   %d\\n\"), linfo.li_line_base);\n\t  printf (_(\"  Line Range:                  %d\\n\"), linfo.li_line_range);\n\t  printf (_(\"  Opcode Base:                 %d\\n\"), linfo.li_opcode_base);\n\n\t  \/* PR 17512: file: 1665-6428-0.004.  *\/\n\t  if (linfo.li_line_range == 0)\n\t    {\n\t      warn (_(\"Line range of 0 is invalid, using 1 instead\\n\"));\n\t      linfo.li_line_range = 1;\n\t    }\n\n\t  reset_state_machine (linfo.li_default_is_stmt);\n\n\t  \/* Display the contents of the Opcodes table.  *\/\n\t  standard_opcodes = hdrptr;\n\n\t  \/* PR 17512: file: 002-417945-0.004.  *\/\n\t  if (standard_opcodes + linfo.li_opcode_base >= end)\n\t    {\n\t      warn (_(\"Line Base extends beyond end of section\\n\"));\n\t      return 0;\n\t    }\n\n\t  printf (_(\"\\n Opcodes:\\n\"));\n\n\t  for (i = 1; i < linfo.li_opcode_base; i++)\n\t    printf (ngettext (\"  Opcode %d has %d arg\\n\",\n\t\t\t      \"  Opcode %d has %d args\\n\",\n\t\t\t      standard_opcodes[i - 1]),\n\t\t    i, standard_opcodes[i - 1]);\n\n\t  \/* Display the contents of the Directory table.  *\/\n\t  data = standard_opcodes + linfo.li_opcode_base - 1;\n\n\t  if (linfo.li_version >= 5)\n\t    {\n\t      load_debug_section_with_follow (line_str, file);\n\n\t      data = display_formatted_table (data, start, end, &linfo, section,\n\t\t\t\t\t      true);\n\t      data = display_formatted_table (data, start, end, &linfo, section,\n\t\t\t\t\t      false);\n\t    }\n\t  else\n\t    {\n\t      if (*data == 0)\n\t\tprintf (_(\"\\n The Directory Table is empty.\\n\"));\n\t      else\n\t\t{\n\t\t  unsigned int last_dir_entry = 0;\n\n\t\t  printf (_(\"\\n The Directory Table (offset 0x%lx):\\n\"),\n\t\t\t  (long)(data - start));\n\n\t\t  while (data < end && *data != 0)\n\t\t    {\n\t\t      printf (\"  %d\\t%.*s\\n\", ++last_dir_entry, (int) (end - data), data);\n\n\t\t      data += strnlen ((char *) data, end - data);\n\t\t      if (data < end)\n\t\t\tdata++;\n\t\t    }\n\n\t\t  \/* PR 17512: file: 002-132094-0.004.  *\/\n\t\t  if (data >= end - 1)\n\t\t    break;\n\t\t}\n\n\t      \/* Skip the NUL at the end of the table.  *\/\n\t      if (data < end)\n\t\tdata++;\n\n\t      \/* Display the contents of the File Name table.  *\/\n\t      if (data >= end || *data == 0)\n\t\tprintf (_(\"\\n The File Name Table is empty.\\n\"));\n\t      else\n\t\t{\n\t\t  printf (_(\"\\n The File Name Table (offset 0x%lx):\\n\"),\n\t\t\t  (long)(data - start));\n\t\t  printf (_(\"  Entry\\tDir\\tTime\\tSize\\tName\\n\"));\n\n\t\t  while (data < end && *data != 0)\n\t\t    {\n\t\t      unsigned char *name;\n\t\t      dwarf_vma val;\n\n\t\t      printf (\"  %d\\t\", ++state_machine_regs.last_file_entry);\n\t\t      name = data;\n\t\t      data += strnlen ((char *) data, end - data);\n\t\t      if (data < end)\n\t\t\tdata++;\n\n\t\t      READ_ULEB (val, data, end);\n\t\t      printf (\"%s\\t\", dwarf_vmatoa (\"u\", val));\n\t\t      READ_ULEB (val, data, end);\n\t\t      printf (\"%s\\t\", dwarf_vmatoa (\"u\", val));\n\t\t      READ_ULEB (val, data, end);\n\t\t      printf (\"%s\\t\", dwarf_vmatoa (\"u\", val));\n\t\t      printf (\"%.*s\\n\", (int)(end - name), name);\n\n\t\t      if (data >= end)\n\t\t\t{\n\t\t\t  warn (_(\"Corrupt file name table entry\\n\"));\n\t\t\t  break;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t      \/* Skip the NUL at the end of the table.  *\/\n\t      if (data < end)\n\t\tdata++;\n\t    }\n\n\t  putchar ('\\n');\n\t  saved_linfo = linfo;\n\t}\n\n      \/* Now display the statements.  *\/\n      if (data >= end_of_sequence)\n\tprintf (_(\" No Line Number Statements.\\n\"));\n      else\n\t{\n\t  printf (_(\" Line Number Statements:\\n\"));\n\n\t  while (data < end_of_sequence)\n\t    {\n\t      unsigned char op_code;\n\t      dwarf_signed_vma adv;\n\t      dwarf_vma uladv;\n\n\t      printf (\"  [0x%08lx]\", (long)(data - start));\n\n\t      op_code = *data++;\n\n\t      if (op_code >= linfo.li_opcode_base)\n\t\t{\n\t\t  op_code -= linfo.li_opcode_base;\n\t\t  uladv = (op_code \/ linfo.li_line_range);\n\t\t  if (linfo.li_max_ops_per_insn == 1)\n\t\t    {\n\t\t      uladv *= linfo.li_min_insn_length;\n\t\t      state_machine_regs.address += uladv;\n\t\t      if (uladv)\n\t\t\tstate_machine_regs.view = 0;\n\t\t      printf (_(\"  Special opcode %d: \"\n\t\t\t\t\"advance Address by %s to 0x%s%s\"),\n\t\t\t      op_code, dwarf_vmatoa (\"u\", uladv),\n\t\t\t      dwarf_vmatoa (\"x\", state_machine_regs.address),\n\t\t\t      verbose_view && uladv\n\t\t\t      ? _(\" (reset view)\") : \"\");\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      unsigned addrdelta\n\t\t\t= ((state_machine_regs.op_index + uladv)\n\t\t\t    \/ linfo.li_max_ops_per_insn)\n\t\t\t* linfo.li_min_insn_length;\n\n\t\t      state_machine_regs.address += addrdelta;\n\t\t      state_machine_regs.op_index\n\t\t\t= (state_machine_regs.op_index + uladv)\n\t\t\t% linfo.li_max_ops_per_insn;\n\t\t      if (addrdelta)\n\t\t\tstate_machine_regs.view = 0;\n\t\t      printf (_(\"  Special opcode %d: \"\n\t\t\t\t\"advance Address by %s to 0x%s[%d]%s\"),\n\t\t\t      op_code, dwarf_vmatoa (\"u\", uladv),\n\t\t\t      dwarf_vmatoa (\"x\", state_machine_regs.address),\n\t\t\t      state_machine_regs.op_index,\n\t\t\t      verbose_view && addrdelta\n\t\t\t      ? _(\" (reset view)\") : \"\");\n\t\t    }\n\t\t  adv = (op_code % linfo.li_line_range) + linfo.li_line_base;\n\t\t  state_machine_regs.line += adv;\n\t\t  printf (_(\" and Line by %s to %d\"),\n\t\t\t  dwarf_vmatoa (\"d\", adv), state_machine_regs.line);\n\t\t  if (verbose_view || state_machine_regs.view)\n\t\t    printf (_(\" (view %u)\\n\"), state_machine_regs.view);\n\t\t  else\n\t\t    putchar ('\\n');\n\t\t  state_machine_regs.view++;\n\t\t}\n\t      else\n\t\tswitch (op_code)\n\t\t  {\n\t\t  case DW_LNS_extended_op:\n\t\t    data += process_extended_line_op (data,\n\t\t\t\t\t\t      linfo.li_default_is_stmt,\n\t\t\t\t\t\t      end);\n\t\t    break;\n\n\t\t  case DW_LNS_copy:\n\t\t    printf (_(\"  Copy\"));\n\t\t    if (verbose_view || state_machine_regs.view)\n\t\t      printf (_(\" (view %u)\\n\"), state_machine_regs.view);\n\t\t    else\n\t\t      putchar ('\\n');\n\t\t    state_machine_regs.view++;\n\t\t    break;\n\n\t\t  case DW_LNS_advance_pc:\n\t\t    READ_ULEB (uladv, data, end);\n\t\t    if (linfo.li_max_ops_per_insn == 1)\n\t\t      {\n\t\t\tuladv *= linfo.li_min_insn_length;\n\t\t\tstate_machine_regs.address += uladv;\n\t\t\tif (uladv)\n\t\t\t  state_machine_regs.view = 0;\n\t\t\tprintf (_(\"  Advance PC by %s to 0x%s%s\\n\"),\n\t\t\t\tdwarf_vmatoa (\"u\", uladv),\n\t\t\t\tdwarf_vmatoa (\"x\", state_machine_regs.address),\n\t\t\t\tverbose_view && uladv\n\t\t\t\t? _(\" (reset view)\") : \"\");\n\t\t      }\n\t\t    else\n\t\t      {\n\t\t\tunsigned addrdelta\n\t\t\t  = ((state_machine_regs.op_index + uladv)\n\t\t\t     \/ linfo.li_max_ops_per_insn)\n\t\t\t  * linfo.li_min_insn_length;\n\t\t\tstate_machine_regs.address\n\t\t\t  += addrdelta;\n\t\t\tstate_machine_regs.op_index\n\t\t\t  = (state_machine_regs.op_index + uladv)\n\t\t\t  % linfo.li_max_ops_per_insn;\n\t\t\tif (addrdelta)\n\t\t\t  state_machine_regs.view = 0;\n\t\t\tprintf (_(\"  Advance PC by %s to 0x%s[%d]%s\\n\"),\n\t\t\t\tdwarf_vmatoa (\"u\", uladv),\n\t\t\t\tdwarf_vmatoa (\"x\", state_machine_regs.address),\n\t\t\t\tstate_machine_regs.op_index,\n\t\t\t\tverbose_view && addrdelta\n\t\t\t\t? _(\" (reset view)\") : \"\");\n\t\t      }\n\t\t    break;\n\n\t\t  case DW_LNS_advance_line:\n\t\t    READ_SLEB (adv, data, end);\n\t\t    state_machine_regs.line += adv;\n\t\t    printf (_(\"  Advance Line by %s to %d\\n\"),\n\t\t\t    dwarf_vmatoa (\"d\", adv),\n\t\t\t    state_machine_regs.line);\n\t\t    break;\n\n\t\t  case DW_LNS_set_file:\n\t\t    READ_ULEB (uladv, data, end);\n\t\t    printf (_(\"  Set File Name to entry %s in the File Name Table\\n\"),\n\t\t\t    dwarf_vmatoa (\"u\", uladv));\n\t\t    state_machine_regs.file = uladv;\n\t\t    break;\n\n\t\t  case DW_LNS_set_column:\n\t\t    READ_ULEB (uladv, data, end);\n\t\t    printf (_(\"  Set column to %s\\n\"),\n\t\t\t    dwarf_vmatoa (\"u\", uladv));\n\t\t    state_machine_regs.column = uladv;\n\t\t    break;\n\n\t\t  case DW_LNS_negate_stmt:\n\t\t    adv = state_machine_regs.is_stmt;\n\t\t    adv = ! adv;\n\t\t    printf (_(\"  Set is_stmt to %s\\n\"), dwarf_vmatoa (\"d\", adv));\n\t\t    state_machine_regs.is_stmt = adv;\n\t\t    break;\n\n\t\t  case DW_LNS_set_basic_block:\n\t\t    printf (_(\"  Set basic block\\n\"));\n\t\t    state_machine_regs.basic_block = 1;\n\t\t    break;\n\n\t\t  case DW_LNS_const_add_pc:\n\t\t    uladv = ((255 - linfo.li_opcode_base) \/ linfo.li_line_range);\n\t\t    if (linfo.li_max_ops_per_insn)\n\t\t      {\n\t\t\tuladv *= linfo.li_min_insn_length;\n\t\t\tstate_machine_regs.address += uladv;\n\t\t\tif (uladv)\n\t\t\t  state_machine_regs.view = 0;\n\t\t\tprintf (_(\"  Advance PC by constant %s to 0x%s%s\\n\"),\n\t\t\t\tdwarf_vmatoa (\"u\", uladv),\n\t\t\t\tdwarf_vmatoa (\"x\", state_machine_regs.address),\n\t\t\t\tverbose_view && uladv\n\t\t\t\t? _(\" (reset view)\") : \"\");\n\t\t      }\n\t\t    else\n\t\t      {\n\t\t\tunsigned addrdelta\n\t\t\t  = ((state_machine_regs.op_index + uladv)\n\t\t\t     \/ linfo.li_max_ops_per_insn)\n\t\t\t  * linfo.li_min_insn_length;\n\t\t\tstate_machine_regs.address\n\t\t\t  += addrdelta;\n\t\t\tstate_machine_regs.op_index\n\t\t\t  = (state_machine_regs.op_index + uladv)\n\t\t\t  % linfo.li_max_ops_per_insn;\n\t\t\tif (addrdelta)\n\t\t\t  state_machine_regs.view = 0;\n\t\t\tprintf (_(\"  Advance PC by constant %s to 0x%s[%d]%s\\n\"),\n\t\t\t\tdwarf_vmatoa (\"u\", uladv),\n\t\t\t\tdwarf_vmatoa (\"x\", state_machine_regs.address),\n\t\t\t\tstate_machine_regs.op_index,\n\t\t\t\tverbose_view && addrdelta\n\t\t\t\t? _(\" (reset view)\") : \"\");\n\t\t      }\n\t\t    break;\n\n\t\t  case DW_LNS_fixed_advance_pc:\n\t\t    SAFE_BYTE_GET_AND_INC (uladv, data, 2, end);\n\t\t    state_machine_regs.address += uladv;\n\t\t    state_machine_regs.op_index = 0;\n\t\t    printf (_(\"  Advance PC by fixed size amount %s to 0x%s\\n\"),\n\t\t\t    dwarf_vmatoa (\"u\", uladv),\n\t\t\t    dwarf_vmatoa (\"x\", state_machine_regs.address));\n\t\t    \/* Do NOT reset view.  *\/\n\t\t    break;\n\n\t\t  case DW_LNS_set_prologue_end:\n\t\t    printf (_(\"  Set prologue_end to true\\n\"));\n\t\t    break;\n\n\t\t  case DW_LNS_set_epilogue_begin:\n\t\t    printf (_(\"  Set epilogue_begin to true\\n\"));\n\t\t    break;\n\n\t\t  case DW_LNS_set_isa:\n\t\t    READ_ULEB (uladv, data, end);\n\t\t    printf (_(\"  Set ISA to %s\\n\"), dwarf_vmatoa (\"u\", uladv));\n\t\t    break;\n\n\t\t  default:\n\t\t    printf (_(\"  Unknown opcode %d with operands: \"), op_code);\n\n\t\t    if (standard_opcodes != NULL)\n\t\t      for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)\n\t\t\t{\n\t\t\t  READ_ULEB (uladv, data, end);\n\t\t\t  printf (\"0x%s%s\", dwarf_vmatoa (\"x\", uladv),\n\t\t\t\t  i == 1 ? \"\" : \", \");\n\t\t\t}\n\t\t    putchar ('\\n');\n\t\t    break;\n\t\t  }\n\t    }\n\t  putchar ('\\n');\n\t}\n    }\n\n  return 1;\n}","target":0,"code_token_length":3508,"total_token_length":3744,"max_tokens_setting":4096}
+{"idx":238571,"func":"static int check_cond_jmp_op(struct bpf_verifier_env *env,\n\t\t\t     struct bpf_insn *insn, int *insn_idx)\n{\n\tstruct bpf_verifier_state *this_branch = env->cur_state;\n\tstruct bpf_verifier_state *other_branch;\n\tstruct bpf_reg_state *regs = this_branch->frame[this_branch->curframe]->regs;\n\tstruct bpf_reg_state *dst_reg, *other_branch_regs, *src_reg = NULL;\n\tu8 opcode = BPF_OP(insn->code);\n\tbool is_jmp32;\n\tint pred = -1;\n\tint err;\n\n\t\/* Only conditional jumps are expected to reach here. *\/\n\tif (opcode == BPF_JA || opcode > BPF_JSLE) {\n\t\tverbose(env, \"invalid BPF_JMP\/JMP32 opcode %x\\n\", opcode);\n\t\treturn -EINVAL;\n\t}\n\n\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\tif (insn->imm != 0) {\n\t\t\tverbose(env, \"BPF_JMP\/JMP32 uses reserved fields\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\t\/* check src1 operand *\/\n\t\terr = check_reg_arg(env, insn->src_reg, SRC_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (is_pointer_value(env, insn->src_reg)) {\n\t\t\tverbose(env, \"R%d pointer comparison prohibited\\n\",\n\t\t\t\tinsn->src_reg);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tsrc_reg = ®s[insn->src_reg];\n\t} else {\n\t\tif (insn->src_reg != BPF_REG_0) {\n\t\t\tverbose(env, \"BPF_JMP\/JMP32 uses reserved fields\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\t\/* check src2 operand *\/\n\terr = check_reg_arg(env, insn->dst_reg, SRC_OP);\n\tif (err)\n\t\treturn err;\n\n\tdst_reg = ®s[insn->dst_reg];\n\tis_jmp32 = BPF_CLASS(insn->code) == BPF_JMP32;\n\n\tif (BPF_SRC(insn->code) == BPF_K) {\n\t\tpred = is_branch_taken(dst_reg, insn->imm, opcode, is_jmp32);\n\t} else if (src_reg->type == SCALAR_VALUE &&\n\t\t   is_jmp32 && tnum_is_const(tnum_subreg(src_reg->var_off))) {\n\t\tpred = is_branch_taken(dst_reg,\n\t\t\t\t       tnum_subreg(src_reg->var_off).value,\n\t\t\t\t       opcode,\n\t\t\t\t       is_jmp32);\n\t} else if (src_reg->type == SCALAR_VALUE &&\n\t\t   !is_jmp32 && tnum_is_const(src_reg->var_off)) {\n\t\tpred = is_branch_taken(dst_reg,\n\t\t\t\t       src_reg->var_off.value,\n\t\t\t\t       opcode,\n\t\t\t\t       is_jmp32);\n\t} else if (reg_is_pkt_pointer_any(dst_reg) &&\n\t\t   reg_is_pkt_pointer_any(src_reg) &&\n\t\t   !is_jmp32) {\n\t\tpred = is_pkt_ptr_branch_taken(dst_reg, src_reg, opcode);\n\t}\n\n\tif (pred >= 0) {\n\t\t\/* If we get here with a dst_reg pointer type it is because\n\t\t * above is_branch_taken() special cased the 0 comparison.\n\t\t *\/\n\t\tif (!__is_pointer_value(false, dst_reg))\n\t\t\terr = mark_chain_precision(env, insn->dst_reg);\n\t\tif (BPF_SRC(insn->code) == BPF_X && !err &&\n\t\t    !__is_pointer_value(false, src_reg))\n\t\t\terr = mark_chain_precision(env, insn->src_reg);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\tif (pred == 1) {\n\t\t\/* Only follow the goto, ignore fall-through. If needed, push\n\t\t * the fall-through branch for simulation under speculative\n\t\t * execution.\n\t\t *\/\n\t\tif (!env->bypass_spec_v1 &&\n\t\t    !sanitize_speculative_path(env, insn, *insn_idx + 1,\n\t\t\t\t\t       *insn_idx))\n\t\t\treturn -EFAULT;\n\t\t*insn_idx += insn->off;\n\t\treturn 0;\n\t} else if (pred == 0) {\n\t\t\/* Only follow the fall-through branch, since that's where the\n\t\t * program will go. If needed, push the goto branch for\n\t\t * simulation under speculative execution.\n\t\t *\/\n\t\tif (!env->bypass_spec_v1 &&\n\t\t    !sanitize_speculative_path(env, insn,\n\t\t\t\t\t       *insn_idx + insn->off + 1,\n\t\t\t\t\t       *insn_idx))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\n\tother_branch = push_stack(env, *insn_idx + insn->off + 1, *insn_idx,\n\t\t\t\t  false);\n\tif (!other_branch)\n\t\treturn -EFAULT;\n\tother_branch_regs = other_branch->frame[other_branch->curframe]->regs;\n\n\t\/* detect if we are comparing against a constant value so we can adjust\n\t * our min\/max values for our dst register.\n\t * this is only legit if both are scalars (or pointers to the same\n\t * object, I suppose, but we don't support that right now), because\n\t * otherwise the different base pointers mean the offsets aren't\n\t * comparable.\n\t *\/\n\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\tstruct bpf_reg_state *src_reg = ®s[insn->src_reg];\n\n\t\tif (dst_reg->type == SCALAR_VALUE &&\n\t\t    src_reg->type == SCALAR_VALUE) {\n\t\t\tif (tnum_is_const(src_reg->var_off) ||\n\t\t\t    (is_jmp32 &&\n\t\t\t     tnum_is_const(tnum_subreg(src_reg->var_off))))\n\t\t\t\treg_set_min_max(&other_branch_regs[insn->dst_reg],\n\t\t\t\t\t\tdst_reg,\n\t\t\t\t\t\tsrc_reg->var_off.value,\n\t\t\t\t\t\ttnum_subreg(src_reg->var_off).value,\n\t\t\t\t\t\topcode, is_jmp32);\n\t\t\telse if (tnum_is_const(dst_reg->var_off) ||\n\t\t\t\t (is_jmp32 &&\n\t\t\t\t  tnum_is_const(tnum_subreg(dst_reg->var_off))))\n\t\t\t\treg_set_min_max_inv(&other_branch_regs[insn->src_reg],\n\t\t\t\t\t\t    src_reg,\n\t\t\t\t\t\t    dst_reg->var_off.value,\n\t\t\t\t\t\t    tnum_subreg(dst_reg->var_off).value,\n\t\t\t\t\t\t    opcode, is_jmp32);\n\t\t\telse if (!is_jmp32 &&\n\t\t\t\t (opcode == BPF_JEQ || opcode == BPF_JNE))\n\t\t\t\t\/* Comparing for equality, we can combine knowledge *\/\n\t\t\t\treg_combine_min_max(&other_branch_regs[insn->src_reg],\n\t\t\t\t\t\t    &other_branch_regs[insn->dst_reg],\n\t\t\t\t\t\t    src_reg, dst_reg, opcode);\n\t\t\tif (src_reg->id &&\n\t\t\t    !WARN_ON_ONCE(src_reg->id != other_branch_regs[insn->src_reg].id)) {\n\t\t\t\tfind_equal_scalars(this_branch, src_reg);\n\t\t\t\tfind_equal_scalars(other_branch, &other_branch_regs[insn->src_reg]);\n\t\t\t}\n\n\t\t}\n\t} else if (dst_reg->type == SCALAR_VALUE) {\n\t\treg_set_min_max(&other_branch_regs[insn->dst_reg],\n\t\t\t\t\tdst_reg, insn->imm, (u32)insn->imm,\n\t\t\t\t\topcode, is_jmp32);\n\t}\n\n\tif (dst_reg->type == SCALAR_VALUE && dst_reg->id &&\n\t    !WARN_ON_ONCE(dst_reg->id != other_branch_regs[insn->dst_reg].id)) {\n\t\tfind_equal_scalars(this_branch, dst_reg);\n\t\tfind_equal_scalars(other_branch, &other_branch_regs[insn->dst_reg]);\n\t}\n\n\t\/* detect if R == 0 where R is returned from bpf_map_lookup_elem().\n\t * NOTE: these optimizations below are related with pointer comparison\n\t *       which will never be JMP32.\n\t *\/\n\tif (!is_jmp32 && BPF_SRC(insn->code) == BPF_K &&\n\t    insn->imm == 0 && (opcode == BPF_JEQ || opcode == BPF_JNE) &&\n\t    type_may_be_null(dst_reg->type)) {\n\t\t\/* Mark all identical registers in each branch as either\n\t\t * safe or unknown depending R == 0 or R != 0 conditional.\n\t\t *\/\n\t\tmark_ptr_or_null_regs(this_branch, insn->dst_reg,\n\t\t\t\t      opcode == BPF_JNE);\n\t\tmark_ptr_or_null_regs(other_branch, insn->dst_reg,\n\t\t\t\t      opcode == BPF_JEQ);\n\t} else if (!try_match_pkt_pointers(insn, dst_reg, ®s[insn->src_reg],\n\t\t\t\t\t   this_branch, other_branch) &&\n\t\t   is_pointer_value(env, insn->dst_reg)) {\n\t\tverbose(env, \"R%d pointer comparison prohibited\\n\",\n\t\t\tinsn->dst_reg);\n\t\treturn -EACCES;\n\t}\n\tif (env->log.level & BPF_LOG_LEVEL)\n\t\tprint_insn_state(env, this_branch->frame[this_branch->curframe]);\n\treturn 0;\n}","target":0,"code_token_length":1894,"total_token_length":2130,"max_tokens_setting":4096}
+{"idx":232336,"func":"GF_Err gf_isom_box_parse_ex(GF_Box **outBox, GF_BitStream *bs, u32 parent_type, Bool is_root_box, u64 parent_size)\n{\n\tu32 type, uuid_type, hdr_size, restore_type;\n\tu64 size, start, comp_start, end;\n\tchar uuid[16];\n\tGF_Err e;\n\tGF_BitStream *uncomp_bs = NULL;\n\tu8 *uncomp_data = NULL;\n\tu32 compressed_size=0;\n\tGF_Box *newBox;\n\tBool skip_logs = (gf_bs_get_cookie(bs) & GF_ISOM_BS_COOKIE_NO_LOGS ) ? GF_TRUE : GF_FALSE;\n\tBool is_special = GF_TRUE;\n\t\n\tif ((bs == NULL) || (outBox == NULL) ) return GF_BAD_PARAM;\n\t*outBox = NULL;\n\tif (gf_bs_available(bs) < 8) {\n\t\treturn GF_ISOM_INCOMPLETE_FILE;\n\t}\n\n\tcomp_start = start = gf_bs_get_position(bs);\n\n\tuuid_type = 0;\n\tsize = (u64) gf_bs_read_u32(bs);\n\thdr_size = 4;\n\t\/*fix for some boxes found in some old hinted files*\/\n\tif ((size >= 2) && (size <= 4)) {\n\t\tsize = 4;\n\t\ttype = GF_ISOM_BOX_TYPE_VOID;\n\t} else {\n\t\ttype = gf_bs_read_u32(bs);\n\t\thdr_size += 4;\n\t\t\/*no size means till end of file - EXCEPT FOR some old QuickTime boxes...*\/\n\t\tif (type == GF_ISOM_BOX_TYPE_TOTL)\n\t\t\tsize = 12;\n\t\tif (!size) {\n\t\t\tif (is_root_box) {\n\t\t\t\tif (!skip_logs) {\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] Warning Read Box type %s (0x%08X) size 0 reading till the end of file\\n\", gf_4cc_to_str(type), type));\n\t\t\t\t}\n\t\t\t\tsize = gf_bs_available(bs) + 8;\n\t\t\t} else {\n\t\t\t\tif (!skip_logs) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Read Box type %s (0x%08X) at position \"LLU\" has size 0 but is not at root\/file level. Forbidden, skipping end of parent box !\\n\", gf_4cc_to_str(type), type, start));\n\t\t\t\t\treturn GF_SKIP_BOX;\n\t\t\t\t}\n\t\t\t\treturn GF_OK;\n\t\t\t}\n\t\t}\n\t\tif (is_root_box && (size>=8)) {\n\t\t\tBool do_uncompress = GF_FALSE;\n\t\t\tu8 *compb = NULL;\n\t\t\tu32 osize = 0;\n\t\t\tu32 otype = type;\n\t\t\tif (type==GF_4CC('!', 'm', 'o', 'f')) {\n\t\t\t\tdo_uncompress = GF_TRUE;\n\t\t\t\ttype = GF_ISOM_BOX_TYPE_MOOF;\n\t\t\t}\n\t\t\telse if (type==GF_4CC('!', 'm', 'o', 'v')) {\n\t\t\t\tdo_uncompress = GF_TRUE;\n\t\t\t\ttype = GF_ISOM_BOX_TYPE_MOOV;\n\t\t\t}\n\t\t\telse if (type==GF_4CC('!', 's', 'i', 'x')) {\n\t\t\t\tdo_uncompress = GF_TRUE;\n\t\t\t\ttype = GF_ISOM_BOX_TYPE_SIDX;\n\t\t\t}\n\t\t\telse if (type==GF_4CC('!', 's', 's', 'x')) {\n\t\t\t\tdo_uncompress = GF_TRUE;\n\t\t\t\ttype = GF_ISOM_BOX_TYPE_SSIX;\n\t\t\t}\n\n\t\t\tif (do_uncompress) {\n\t\t\t\tcompb = gf_malloc((u32) (size-8));\n\n\t\t\t\tcompressed_size = (u32) (size - 8);\n\t\t\t\tgf_bs_read_data(bs, compb, compressed_size);\n\t\t\t\te = gf_gz_decompress_payload(compb, compressed_size, &uncomp_data, &osize);\n\t\t\t\tif (e) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Failed to uncompress payload for box type %s (0x%08X)\\n\", gf_4cc_to_str(otype), otype));\n\t\t\t\t\treturn e;\n\t\t\t\t}\n\n\t\t\t\t\/\/keep size as complete box size for tests below\n\t\t\t\tsize = osize + 8;\n\t\t\t\tuncomp_bs = gf_bs_new(uncomp_data, osize, GF_BITSTREAM_READ);\n\t\t\t\tbs = uncomp_bs;\n\t\t\t\tstart = 0;\n\t\t\t\tgf_free(compb);\n\t\t\t}\n\t\t}\n\t}\n\t\/*handle uuid*\/\n\tmemset(uuid, 0, 16);\n\tif (type == GF_ISOM_BOX_TYPE_UUID ) {\n\t\tif (gf_bs_available(bs) < 16) {\n\t\t\treturn GF_ISOM_INCOMPLETE_FILE;\n\t\t}\n\t\tgf_bs_read_data(bs, uuid, 16);\n\t\thdr_size += 16;\n\t\tuuid_type = gf_isom_solve_uuid_box(uuid);\n\t}\n\n\t\/\/handle large box\n\tif (size == 1) {\n\t\tif (gf_bs_available(bs) < 8) {\n\t\t\treturn GF_ISOM_INCOMPLETE_FILE;\n\t\t}\n\t\tsize = gf_bs_read_u64(bs);\n\t\thdr_size += 8;\n\t}\n\tif (!skip_logs)\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] Read Box type %s size \"LLD\" start \"LLD\"\\n\", gf_4cc_to_str(type), size,  start));\n\n\tif ( size < hdr_size ) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Box %s size \"LLD\" less than box header size %d\\n\", gf_4cc_to_str(type), size, hdr_size));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\t\/\/if parent size is given, make sure box fits within parent\n\tif (parent_size && (parent_size<size)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Box %s size \"LLU\" is larger than remaining parent size \"LLU\"\\n\", gf_4cc_to_str(type), size, parent_size ));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\trestore_type = 0;\n\tif ((parent_type==GF_ISOM_BOX_TYPE_STSD) && (type==GF_QT_SUBTYPE_RAW) ) {\n\t\tu64 cookie = gf_bs_get_cookie(bs);\n\t\trestore_type = type;\n\t\tif (cookie & GF_ISOM_BS_COOKIE_VISUAL_TRACK)\n\t\t\ttype = GF_QT_SUBTYPE_RAW_VID;\n\t\telse\n\t\t\ttype = GF_QT_SUBTYPE_RAW_AUD;\n\n\t}\n\n\t\/\/some special boxes (references and track groups) are handled by a single generic box with an associated ref\/group type\n\tif (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TREF)) {\n\t\tnewBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFT);\n\t\tif (!newBox) return GF_OUT_OF_MEM;\n\t\t((GF_TrackReferenceTypeBox*)newBox)->reference_type = type;\n\t} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_IREF)) {\n\t\tnewBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFI);\n\t\tif (!newBox) return GF_OUT_OF_MEM;\n\t\t((GF_ItemReferenceTypeBox*)newBox)->reference_type = type;\n\t} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TRGR)) {\n\t\tnewBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_TRGT);\n\t\tif (!newBox) return GF_OUT_OF_MEM;\n\t\t((GF_TrackGroupTypeBox*)newBox)->group_type = type;\n\t} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_GRPL)) {\n\t\tnewBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_GRPT);\n\t\tif (!newBox) return GF_OUT_OF_MEM;\n\t\t((GF_EntityToGroupTypeBox*)newBox)->grouping_type = type;\n\t} else {\n\t\t\/\/OK, create the box based on the type\n\t\tis_special = GF_FALSE;\n\t\tnewBox = gf_isom_box_new_ex(uuid_type ? uuid_type : type, parent_type, skip_logs, is_root_box);\n\t\tif (!newBox) return GF_OUT_OF_MEM;\n\t}\n\n\t\/\/OK, init and read this box\n\tif (type==GF_ISOM_BOX_TYPE_UUID && !is_special) {\n\t\tmemcpy(((GF_UUIDBox *)newBox)->uuid, uuid, 16);\n\t\t((GF_UUIDBox *)newBox)->internal_4cc = uuid_type;\n\t}\n\n\tif (!newBox->type) newBox->type = type;\n\tif (restore_type)\n\t\tnewBox->type = restore_type;\n\n\tend = gf_bs_available(bs);\n\tif (size - hdr_size > end ) {\n\t\tnewBox->size = size - hdr_size - end;\n\t\t*outBox = newBox;\n\t\treturn GF_ISOM_INCOMPLETE_FILE;\n\t}\n\n\tnewBox->size = size - hdr_size;\n\n\te = gf_isom_full_box_read(newBox, bs);\n\tif (!e) e = gf_isom_box_read(newBox, bs);\n\tif (e) {\n\t\tif (gf_opts_get_bool(\"core\", \"no-check\"))\n\t\t\te = GF_OK;\n\t}\n\tnewBox->size = size;\n\tend = gf_bs_get_position(bs);\n\n\tif (uncomp_bs) {\n\t\tgf_free(uncomp_data);\n\t\tgf_bs_del(uncomp_bs);\n\t\tif (e) {\n\t\t\tgf_isom_box_del(newBox);\n\t\t\t*outBox = NULL;\n\t\t\treturn e;\n\t\t}\n\t\t\/\/move size to real bitstream offsets for tests below\n\t\tsize -= 8;\n\t\t\/\/remember compressed vs real size info for moof in order to properly recompute data_offset\/base_data_offset\n\t\tif (type==GF_ISOM_BOX_TYPE_MOOF) {\n\t\t\t((GF_MovieFragmentBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;\n\t\t}\n\t\t\/\/remember compressed vs real size info for moov in order to properly recompute chunk offset\n\t\telse if (type==GF_ISOM_BOX_TYPE_MOOV) {\n\t\t\t((GF_MovieBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;\n\t\t\t((GF_MovieBox *)newBox)->file_offset = comp_start;\n\t\t}\n\t\t\/\/remember compressed vs real size info for dump\n\t\telse if (type==GF_ISOM_BOX_TYPE_SIDX) {\n\t\t\t((GF_SegmentIndexBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;\n\t\t}\n\t\t\/\/remember compressed vs real size info for dump\n\t\telse if (type==GF_ISOM_BOX_TYPE_SSIX) {\n\t\t\t((GF_SubsegmentIndexBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;\n\t\t}\n\t\tnewBox->internal_flags = GF_ISOM_BOX_COMPRESSED;\n\t}\n\n\n\tif (e && (e != GF_ISOM_INCOMPLETE_FILE)) {\n\t\tgf_isom_box_del(newBox);\n\t\t*outBox = NULL;\n\t\tif (is_root_box && (e==GF_SKIP_BOX))\n\t\t\te = GF_ISOM_INVALID_FILE;\n\n\t\tif (!skip_logs && (e!=GF_SKIP_BOX)) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Read Box \\\"%s\\\" (start \"LLU\") failed (%s) - skipping\\n\", gf_4cc_to_str(type), start, gf_error_to_string(e)));\n\t\t}\n\t\t\/\/we don't try to reparse known boxes that have been failing (too dangerous)\n\t\treturn e;\n\t}\n\n\tif (end-start > size) {\n\t\tif (!skip_logs) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Box \\\"%s\\\" size \"LLU\" (start \"LLU\") invalid (read \"LLU\")\\n\", gf_4cc_to_str(type), size, start, (end-start) ));\n\t\t}\n\t\t\/*let's still try to load the file since no error was notified*\/\n\t\tgf_bs_seek(bs, start+size);\n\t} else if (end-start < size) {\n\t\tu32 to_skip = (u32) (size-(end-start));\n\t\tif (!skip_logs) {\n\t\t\tif ((to_skip!=4) || gf_bs_peek_bits(bs, 32, 0)) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Box \\\"%s\\\" (start \"LLU\") has %u extra bytes\\n\", gf_4cc_to_str(type), start, to_skip));\n\t\t\t\tunused_bytes += to_skip;\n\t\t\t}\n\t\t}\n\t\tgf_bs_skip_bytes(bs, to_skip);\n\t}\n\t*outBox = newBox;\n\n\treturn e;\n}","target":0,"code_token_length":2771,"total_token_length":3007,"max_tokens_setting":4096}
+{"idx":500052,"func":"kssl_sget_tkt(\t\/* UPDATE *\/\tKSSL_CTX\t\t*kssl_ctx,\n\t\t\/* IN     *\/\tkrb5_data\t\t*indata,\n\t\t\/* OUT    *\/\tkrb5_ticket_times\t*ttimes,\n\t\t\/* OUT    *\/\tKSSL_ERR\t\t*kssl_err  )\n        {\n        krb5_error_code\t\t\tkrb5rc = KRB5KRB_ERR_GENERIC;\n        static krb5_context\t\tkrb5context = NULL;\n\tstatic krb5_auth_context\tkrb5auth_context = NULL;\n\tkrb5_ticket \t\t\t*krb5ticket = NULL;\n\tKRB5_TKTBODY \t\t\t*asn1ticket = NULL;\n\tconst unsigned char\t\t*p;\n\tkrb5_keytab \t\t\tkrb5keytab = NULL;\n\tkrb5_keytab_entry\t\tkt_entry;\n\tkrb5_principal\t\t\tkrb5server;\n        krb5_rcache                     rcache = NULL;\n\n\tkssl_err_set(kssl_err, 0, \"\");\n\n\tif (!kssl_ctx)\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n\t\t\t\"No kssl_ctx defined.\\n\");\n\t\tgoto err;\n\t\t}\n\n#ifdef KSSL_DEBUG\n\tprintf(\"in kssl_sget_tkt(%s)\\n\", kstring(kssl_ctx->service_name));\n#endif\t\/* KSSL_DEBUG *\/\n\n\tif (!krb5context  &&  (krb5rc = krb5_init_context(&krb5context)))\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"krb5_init_context() fails.\\n\");\n\t\tgoto err;\n\t\t}\n\tif (krb5auth_context  &&\n\t\t(krb5rc = krb5_auth_con_free(krb5context, krb5auth_context)))\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"krb5_auth_con_free() fails.\\n\");\n\t\tgoto err;\n\t\t}\n\telse  krb5auth_context = NULL;\n\tif (!krb5auth_context  &&\n\t\t(krb5rc = krb5_auth_con_init(krb5context, &krb5auth_context)))\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"krb5_auth_con_init() fails.\\n\");\n\t\tgoto err;\n\t\t}\n\n \n\tif ((krb5rc = krb5_auth_con_getrcache(krb5context, krb5auth_context,\n\t\t&rcache)))\n\t\t{\n \t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n\t\t\t\"krb5_auth_con_getrcache() fails.\\n\");\n \t\tgoto err;\n\t\t}\n \n\tif ((krb5rc = krb5_sname_to_principal(krb5context, NULL,\n                (kssl_ctx->service_name)? kssl_ctx->service_name: KRB5SVC,\n                KRB5_NT_SRV_HST, &krb5server)) != 0)\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                        \"krb5_sname_to_principal() fails.\\n\");\n\t\tgoto err;\n\t\t}\n\n\tif (rcache == NULL) \n                {\n                if ((krb5rc = krb5_get_server_rcache(krb5context,\n\t\t\tkrb5_princ_component(krb5context, krb5server, 0),\n\t\t\t&rcache)))\n                        {\n\t\t        kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n                                \"krb5_get_server_rcache() fails.\\n\");\n                  \tgoto err;\n                        }\n                }\n\n        if ((krb5rc = krb5_auth_con_setrcache(krb5context, krb5auth_context, rcache)))\n                {\n                kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n\t\t\t\"krb5_auth_con_setrcache() fails.\\n\");\n                goto err;\n                }\n\n\n\t\/*\tkssl_ctx->keytab_file == NULL ==> use Kerberos default\n\t*\/\n\tif (kssl_ctx->keytab_file)\n\t\t{\n\t\tkrb5rc = krb5_kt_resolve(krb5context, kssl_ctx->keytab_file,\n                        &krb5keytab);\n\t\tif (krb5rc)\n\t\t\t{\n\t\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,\n\t\t\t\t\"krb5_kt_resolve() fails.\\n\");\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n                krb5rc = krb5_kt_default(krb5context,&krb5keytab);\n                if (krb5rc)\n\t\t\t{\n\t\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, \n\t\t\t\t\"krb5_kt_default() fails.\\n\");\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\n\t\/*\tActual Kerberos5 krb5_recvauth() has initial conversation here\n\t**\to\tcheck KRB5_SENDAUTH_BADAUTHVERS\n\t**\t\tunless KRB5_RECVAUTH_SKIP_VERSION\n\t**\to\tcheck KRB5_SENDAUTH_BADAPPLVERS\n\t**\to\tsend \"0\" msg if all OK\n\t*\/\n\n\t\/*  20010411 was using AP_REQ instead of true KerberosWrapper\n\t**\n\t**  if ((krb5rc = krb5_rd_req(krb5context, &krb5auth_context,\n\t**\t\t\t&krb5in_data, krb5server, krb5keytab,\n\t**\t\t\t&ap_option, &krb5ticket)) != 0)  { Error }\n\t*\/\n\n\tp = (unsigned char *)indata->data;\n\tif ((asn1ticket = (KRB5_TKTBODY *) d2i_KRB5_TICKET(NULL, &p,\n\t\t\t\t\t\t(long) indata->length)) == NULL)\n\t\t{\n\t\tBIO_snprintf(kssl_err->text, KSSL_ERR_MAX,\n\t\t\t\"d2i_KRB5_TICKET() ASN.1 decode failure.\\n\");\n\t\tkssl_err->reason = SSL_R_KRB5_S_RD_REQ;\n\t\tgoto err;\n\t\t}\n\t\n\t\/* Was:  krb5rc = krb5_decode_ticket(krb5in_data,&krb5ticket)) != 0) *\/\n\tif ((krb5rc = kssl_TKT2tkt(krb5context, asn1ticket, &krb5ticket,\n\t\t\t\t\tkssl_err)) != 0)\n\t\t{\n\t\tBIO_snprintf(kssl_err->text, KSSL_ERR_MAX,\n\t\t\t\"Error converting ASN.1 ticket to krb5_ticket.\\n\");\n\t\tkssl_err->reason = SSL_R_KRB5_S_RD_REQ;\n\t\tgoto err;\n\t\t}\n\n\tif (! krb5_principal_compare(krb5context, krb5server,\n\t\t\t\t\t\t  krb5ticket->server))  {\n\t\tkrb5rc = KRB5_PRINC_NOMATCH;\n\t\tBIO_snprintf(kssl_err->text, KSSL_ERR_MAX,\n\t\t\t\"server principal != ticket principal\\n\");\n\t\tkssl_err->reason = SSL_R_KRB5_S_RD_REQ;\n\t\tgoto err;\n\t\t}\n\tif ((krb5rc = krb5_kt_get_entry(krb5context, krb5keytab,\n\t\t\tkrb5ticket->server, krb5ticket->enc_part.kvno,\n\t\t\tkrb5ticket->enc_part.enctype, &kt_entry)) != 0)  {\n\t\tBIO_snprintf(kssl_err->text, KSSL_ERR_MAX,\n\t\t\t\"krb5_kt_get_entry() fails with %x.\\n\", krb5rc);\n\t\tkssl_err->reason = SSL_R_KRB5_S_RD_REQ;\n\t\tgoto err;\n\t\t}\n\tif ((krb5rc = krb5_decrypt_tkt_part(krb5context, &kt_entry.key,\n\t\t\tkrb5ticket)) != 0)  {\n\t\tBIO_snprintf(kssl_err->text, KSSL_ERR_MAX,\n\t\t\t\"krb5_decrypt_tkt_part() failed.\\n\");\n\t\tkssl_err->reason = SSL_R_KRB5_S_RD_REQ;\n\t\tgoto err;\n\t\t}\n\telse  {\n\t\tkrb5_kt_free_entry(krb5context, &kt_entry);\n#ifdef KSSL_DEBUG\n\t\t{\n\t\tint i; krb5_address **paddr = krb5ticket->enc_part2->caddrs;\n\t\tprintf(\"Decrypted ticket fields:\\n\");\n\t\tprintf(\"\\tflags: %X, transit-type: %X\",\n\t\t\tkrb5ticket->enc_part2->flags,\n\t\t\tkrb5ticket->enc_part2->transited.tr_type);\n\t\tprint_krb5_data(\"\\ttransit-data: \",\n\t\t\t&(krb5ticket->enc_part2->transited.tr_contents));\n\t\tprintf(\"\\tcaddrs: %p, authdata: %p\\n\",\n\t\t\tkrb5ticket->enc_part2->caddrs,\n\t\t\tkrb5ticket->enc_part2->authorization_data);\n\t\tif (paddr)\n\t\t\t{\n\t\t\tprintf(\"\\tcaddrs:\\n\");\n\t\t\tfor (i=0; paddr[i] != NULL; i++)\n\t\t\t\t{\n\t\t\t\tkrb5_data d;\n\t\t\t\td.length=paddr[i]->length;\n\t\t\t\td.data=paddr[i]->contents;\n\t\t\t\tprint_krb5_data(\"\\t\\tIP: \", &d);\n\t\t\t\t}\n\t\t\t}\n\t\tprintf(\"\\tstart\/auth\/end times: %d \/ %d \/ %d\\n\",\n\t\t\tkrb5ticket->enc_part2->times.starttime,\n\t\t\tkrb5ticket->enc_part2->times.authtime,\n\t\t\tkrb5ticket->enc_part2->times.endtime);\n\t\t}\n#endif\t\/* KSSL_DEBUG *\/\n\t\t}\n\n\tkrb5rc = KRB5_NO_TKT_SUPPLIED;\n\tif (!krb5ticket  ||\t!krb5ticket->enc_part2  ||\n                !krb5ticket->enc_part2->client  ||\n                !krb5ticket->enc_part2->client->data  ||\n                !krb5ticket->enc_part2->session)\n                {\n                kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,\n                        \"bad ticket from krb5_rd_req.\\n\");\n\t\t}\n\telse if (kssl_ctx_setprinc(kssl_ctx, KSSL_CLIENT,\n\t\t &krb5ticket->enc_part2->client->realm,\n\t\t krb5ticket->enc_part2->client->data,\n\t\t krb5ticket->enc_part2->client->length))\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,\n                        \"kssl_ctx_setprinc() fails.\\n\");\n\t\t}\n\telse if (kssl_ctx_setkey(kssl_ctx, krb5ticket->enc_part2->session))\n                {\n\t\tkssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,\n                        \"kssl_ctx_setkey() fails.\\n\");\n\t\t}\n\telse if (krb5ticket->enc_part2->flags & TKT_FLG_INVALID)\n                {\n\t\tkrb5rc = KRB5KRB_AP_ERR_TKT_INVALID;\n                kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,\n                        \"invalid ticket from krb5_rd_req.\\n\");\n\t\t}\n\telse\tkrb5rc = 0;\n\n\tkssl_ctx->enctype\t= krb5ticket->enc_part.enctype;\n\tttimes->authtime\t= krb5ticket->enc_part2->times.authtime;\n\tttimes->starttime\t= krb5ticket->enc_part2->times.starttime;\n\tttimes->endtime \t= krb5ticket->enc_part2->times.endtime;\n\tttimes->renew_till\t= krb5ticket->enc_part2->times.renew_till;\n\n err:\n#ifdef KSSL_DEBUG\n\tkssl_ctx_show(kssl_ctx);\n#endif\t\/* KSSL_DEBUG *\/\n\n\tif (asn1ticket) \tKRB5_TICKET_free((KRB5_TICKET *) asn1ticket);\n        if (krb5keytab)         krb5_kt_close(krb5context, krb5keytab);\n\tif (krb5ticket) \tkrb5_free_ticket(krb5context, krb5ticket);\n\tif (krb5server) \tkrb5_free_principal(krb5context, krb5server);\n\treturn (krb5rc);\n        }","target":0,"code_token_length":2681,"total_token_length":2917,"max_tokens_setting":4096}
+{"idx":265435,"func":"int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,\n\t      loff_t *actread)\n{\n\tchar *dir = NULL, *fragment_block, *datablock = NULL;\n\tchar *fragment = NULL, *file = NULL, *resolved, *data;\n\tu64 start, n_blks, table_size, data_offset, table_offset, sparse_size;\n\tint ret, j, i_number, datablk_count = 0;\n\tstruct squashfs_super_block *sblk = ctxt.sblk;\n\tstruct squashfs_fragment_block_entry frag_entry;\n\tstruct squashfs_file_info finfo = {0};\n\tstruct squashfs_symlink_inode *symlink;\n\tstruct fs_dir_stream *dirsp = NULL;\n\tstruct squashfs_dir_stream *dirs;\n\tstruct squashfs_lreg_inode *lreg;\n\tstruct squashfs_base_inode *base;\n\tstruct squashfs_reg_inode *reg;\n\tunsigned long dest_len;\n\tstruct fs_dirent *dent;\n\tunsigned char *ipos;\n\n\t*actread = 0;\n\n\tif (offset) {\n\t\t\/*\n\t\t * TODO: implement reading at an offset in file\n\t\t *\/\n\t\tprintf(\"Error: reading at a specific offset in a squashfs file is not supported yet.\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t\/*\n\t * sqfs_opendir will uncompress inode and directory tables, and will\n\t * return a pointer to the directory that contains the requested file.\n\t *\/\n\tsqfs_split_path(&file, &dir, filename);\n\tret = sqfs_opendir(dir, &dirsp);\n\tif (ret) {\n\t\tgoto out;\n\t}\n\n\tdirs = (struct squashfs_dir_stream *)dirsp;\n\n\t\/* For now, only regular files are able to be loaded *\/\n\twhile (!sqfs_readdir(dirsp, &dent)) {\n\t\tret = strcmp(dent->name, file);\n\t\tif (!ret)\n\t\t\tbreak;\n\n\t\tfree(dirs->entry);\n\t\tdirs->entry = NULL;\n\t}\n\n\tif (ret) {\n\t\tprintf(\"File not found.\\n\");\n\t\t*actread = 0;\n\t\tret = -ENOENT;\n\t\tgoto out;\n\t}\n\n\ti_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;\n\tipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,\n\t\t\t       sblk->block_size);\n\n\tbase = (struct squashfs_base_inode *)ipos;\n\tswitch (get_unaligned_le16(&base->inode_type)) {\n\tcase SQFS_REG_TYPE:\n\t\treg = (struct squashfs_reg_inode *)ipos;\n\t\tdatablk_count = sqfs_get_regfile_info(reg, &finfo, &frag_entry,\n\t\t\t\t\t\t      sblk->block_size);\n\t\tif (datablk_count < 0) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\tmemcpy(finfo.blk_sizes, ipos + sizeof(*reg),\n\t\t       datablk_count * sizeof(u32));\n\t\tbreak;\n\tcase SQFS_LREG_TYPE:\n\t\tlreg = (struct squashfs_lreg_inode *)ipos;\n\t\tdatablk_count = sqfs_get_lregfile_info(lreg, &finfo,\n\t\t\t\t\t\t       &frag_entry,\n\t\t\t\t\t\t       sblk->block_size);\n\t\tif (datablk_count < 0) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\tmemcpy(finfo.blk_sizes, ipos + sizeof(*lreg),\n\t\t       datablk_count * sizeof(u32));\n\t\tbreak;\n\tcase SQFS_SYMLINK_TYPE:\n\tcase SQFS_LSYMLINK_TYPE:\n\t\tsymlink = (struct squashfs_symlink_inode *)ipos;\n\t\tresolved = sqfs_resolve_symlink(symlink, filename);\n\t\tret = sqfs_read(resolved, buf, offset, len, actread);\n\t\tfree(resolved);\n\t\tgoto out;\n\tcase SQFS_BLKDEV_TYPE:\n\tcase SQFS_CHRDEV_TYPE:\n\tcase SQFS_LBLKDEV_TYPE:\n\tcase SQFS_LCHRDEV_TYPE:\n\tcase SQFS_FIFO_TYPE:\n\tcase SQFS_SOCKET_TYPE:\n\tcase SQFS_LFIFO_TYPE:\n\tcase SQFS_LSOCKET_TYPE:\n\tdefault:\n\t\tprintf(\"Unsupported entry type\\n\");\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* If the user specifies a length, check its sanity *\/\n\tif (len) {\n\t\tif (len > finfo.size) {\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\tfinfo.size = len;\n\t} else {\n\t\tlen = finfo.size;\n\t}\n\n\tif (datablk_count) {\n\t\tdata_offset = finfo.start;\n\t\tdatablock = malloc(get_unaligned_le32(&sblk->block_size));\n\t\tif (!datablock) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tfor (j = 0; j < datablk_count; j++) {\n\t\tchar *data_buffer;\n\n\t\tstart = lldiv(data_offset, ctxt.cur_dev->blksz);\n\t\ttable_size = SQFS_BLOCK_SIZE(finfo.blk_sizes[j]);\n\t\ttable_offset = data_offset - (start * ctxt.cur_dev->blksz);\n\t\tn_blks = DIV_ROUND_UP(table_size + table_offset,\n\t\t\t\t      ctxt.cur_dev->blksz);\n\n\t\t\/* Don't load any data for sparse blocks *\/\n\t\tif (finfo.blk_sizes[j] == 0) {\n\t\t\tn_blks = 0;\n\t\t\ttable_offset = 0;\n\t\t\tdata_buffer = NULL;\n\t\t\tdata = NULL;\n\t\t} else {\n\t\t\tdata_buffer = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);\n\n\t\t\tif (!data_buffer) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\tret = sqfs_disk_read(start, n_blks, data_buffer);\n\t\t\tif (ret < 0) {\n\t\t\t\t\/*\n\t\t\t\t * Possible causes: too many data blocks or too large\n\t\t\t\t * SquashFS block size. Tip: re-compile the SquashFS\n\t\t\t\t * image with mksquashfs's -b <block_size> option.\n\t\t\t\t *\/\n\t\t\t\tprintf(\"Error: too many data blocks to be read.\\n\");\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\tdata = data_buffer + table_offset;\n\t\t}\n\n\t\t\/* Load the data *\/\n\t\tif (finfo.blk_sizes[j] == 0) {\n\t\t\t\/* This is a sparse block *\/\n\t\t\tsparse_size = get_unaligned_le32(&sblk->block_size);\n\t\t\tif ((*actread + sparse_size) > len)\n\t\t\t\tsparse_size = len - *actread;\n\t\t\tmemset(buf + *actread, 0, sparse_size);\n\t\t\t*actread += sparse_size;\n\t\t} else if (SQFS_COMPRESSED_BLOCK(finfo.blk_sizes[j])) {\n\t\t\tdest_len = get_unaligned_le32(&sblk->block_size);\n\t\t\tret = sqfs_decompress(&ctxt, datablock, &dest_len,\n\t\t\t\t\t      data, table_size);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\n\t\t\tif ((*actread + dest_len) > len)\n\t\t\t\tdest_len = len - *actread;\n\t\t\tmemcpy(buf + *actread, datablock, dest_len);\n\t\t\t*actread += dest_len;\n\t\t} else {\n\t\t\tif ((*actread + table_size) > len)\n\t\t\t\ttable_size = len - *actread;\n\t\t\tmemcpy(buf + *actread, data, table_size);\n\t\t\t*actread += table_size;\n\t\t}\n\n\t\tdata_offset += table_size;\n\t\tfree(data_buffer);\n\t\tif (*actread >= len)\n\t\t\tbreak;\n\t}\n\n\t\/*\n\t * There is no need to continue if the file is not fragmented.\n\t *\/\n\tif (!finfo.frag) {\n\t\tret = 0;\n\t\tgoto out;\n\t}\n\n\tstart = lldiv(frag_entry.start, ctxt.cur_dev->blksz);\n\ttable_size = SQFS_BLOCK_SIZE(frag_entry.size);\n\ttable_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);\n\tn_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);\n\n\tfragment = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);\n\n\tif (!fragment) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tret = sqfs_disk_read(start, n_blks, fragment);\n\tif (ret < 0)\n\t\tgoto out;\n\n\t\/* File compressed and fragmented *\/\n\tif (finfo.frag && finfo.comp) {\n\t\tdest_len = get_unaligned_le32(&sblk->block_size);\n\t\tfragment_block = malloc(dest_len);\n\t\tif (!fragment_block) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\tret = sqfs_decompress(&ctxt, fragment_block, &dest_len,\n\t\t\t\t      (void *)fragment  + table_offset,\n\t\t\t\t      frag_entry.size);\n\t\tif (ret) {\n\t\t\tfree(fragment_block);\n\t\t\tgoto out;\n\t\t}\n\n\t\tmemcpy(buf + *actread, &fragment_block[finfo.offset], finfo.size - *actread);\n\t\t*actread = finfo.size;\n\n\t\tfree(fragment_block);\n\n\t} else if (finfo.frag && !finfo.comp) {\n\t\tfragment_block = (void *)fragment + table_offset;\n\n\t\tmemcpy(buf + *actread, &fragment_block[finfo.offset], finfo.size - *actread);\n\t\t*actread = finfo.size;\n\t}\n\nout:\n\tfree(fragment);\n\tfree(datablock);\n\tfree(file);\n\tfree(dir);\n\tfree(finfo.blk_sizes);\n\tsqfs_closedir(dirsp);\n\n\treturn ret;\n}","target":0,"code_token_length":2014,"total_token_length":2250,"max_tokens_setting":4096}
+{"idx":450815,"func":"glob_in_dir (const char *pattern, const char *directory, int flags,\n             int (*errfunc) (const char *, int),\n             glob_t *pglob, size_t alloca_used)\n{\n  size_t dirlen = strlen (directory);\n  void *stream = NULL;\n# define GLOBNAMES_MEMBERS(nnames) \\\n    struct globnames *next; size_t count; char *name[nnames];\n  struct globnames { GLOBNAMES_MEMBERS (FLEXIBLE_ARRAY_MEMBER) };\n  struct { GLOBNAMES_MEMBERS (64) } init_names_buf;\n  struct globnames *init_names = (struct globnames *) &init_names_buf;\n  struct globnames *names = init_names;\n  struct globnames *names_alloca = init_names;\n  size_t nfound = 0;\n  size_t cur = 0;\n  int meta;\n  int save;\n  int result;\n\n  alloca_used += sizeof init_names_buf;\n\n  init_names->next = NULL;\n  init_names->count = ((sizeof init_names_buf\n                        - offsetof (struct globnames, name))\n                       \/ sizeof init_names->name[0]);\n\n  meta = __glob_pattern_type (pattern, !(flags & GLOB_NOESCAPE));\n  if (meta == GLOBPAT_NONE && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))\n    {\n      \/* We need not do any tests.  The PATTERN contains no meta\n         characters and we must not return an error therefore the\n         result will always contain exactly one name.  *\/\n      flags |= GLOB_NOCHECK;\n    }\n  else if (meta == GLOBPAT_NONE)\n    {\n      union\n      {\n        struct stat st;\n        struct_stat64 st64;\n      } ust;\n      size_t patlen = strlen (pattern);\n      size_t fullsize;\n      bool alloca_fullname\n        = (! size_add_wrapv (dirlen + 1, patlen + 1, &fullsize)\n           && glob_use_alloca (alloca_used, fullsize));\n      char *fullname;\n      if (alloca_fullname)\n        fullname = alloca_account (fullsize, alloca_used);\n      else\n        {\n          fullname = malloc (fullsize);\n          if (fullname == NULL)\n            return GLOB_NOSPACE;\n        }\n\n      mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),\n                        \"\/\", 1),\n               pattern, patlen + 1);\n      if (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)\n            ? (*pglob->gl_lstat) (fullname, &ust.st)\n            : __lstat64 (fullname, &ust.st64))\n           == 0)\n          || errno == EOVERFLOW)\n        \/* We found this file to be existing.  Now tell the rest\n           of the function to copy this name into the result.  *\/\n        flags |= GLOB_NOCHECK;\n\n      if (__glibc_unlikely (!alloca_fullname))\n        free (fullname);\n    }\n  else\n    {\n      stream = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)\n                ? (*pglob->gl_opendir) (directory)\n                : opendir (directory));\n      if (stream == NULL)\n        {\n          if (errno != ENOTDIR\n              && ((errfunc != NULL && (*errfunc) (directory, errno))\n                  || (flags & GLOB_ERR)))\n            return GLOB_ABORTED;\n        }\n      else\n        {\n          int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)\n                           | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0));\n          flags |= GLOB_MAGCHAR;\n\n          while (1)\n            {\n              struct readdir_result d;\n              {\n                if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))\n                  d = convert_dirent (GL_READDIR (pglob, stream));\n                else\n                  {\n#ifdef COMPILE_GLOB64\n                    d = convert_dirent (__readdir (stream));\n#else\n                    d = convert_dirent64 (__readdir64 (stream));\n#endif\n                  }\n              }\n              if (d.name == NULL)\n                break;\n\n              \/* If we shall match only directories use the information\n                 provided by the dirent call if possible.  *\/\n              if (flags & GLOB_ONLYDIR)\n                switch (readdir_result_type (d))\n                  {\n                  case DT_DIR: case DT_LNK: case DT_UNKNOWN: break;\n                  default: continue;\n                  }\n\n              if (fnmatch (pattern, d.name, fnm_flags) == 0)\n                {\n                  if (cur == names->count)\n                    {\n                      struct globnames *newnames;\n                      size_t count = names->count * 2;\n                      size_t nameoff = offsetof (struct globnames, name);\n                      size_t size = FLEXSIZEOF (struct globnames, name,\n                                                count * sizeof (char *));\n                      if ((SIZE_MAX - nameoff) \/ 2 \/ sizeof (char *)\n                          < names->count)\n                        goto memory_error;\n                      if (glob_use_alloca (alloca_used, size))\n                        newnames = names_alloca\n                          = alloca_account (size, alloca_used);\n                      else if ((newnames = malloc (size))\n                               == NULL)\n                        goto memory_error;\n                      newnames->count = count;\n                      newnames->next = names;\n                      names = newnames;\n                      cur = 0;\n                    }\n                  names->name[cur] = strdup (d.name);\n                  if (names->name[cur] == NULL)\n                    goto memory_error;\n                  ++cur;\n                  ++nfound;\n                  if (SIZE_MAX - pglob->gl_offs <= nfound)\n                    goto memory_error;\n                }\n            }\n        }\n    }\n\n  if (nfound == 0 && (flags & GLOB_NOCHECK))\n    {\n      size_t len = strlen (pattern);\n      nfound = 1;\n      names->name[cur] = malloc (len + 1);\n      if (names->name[cur] == NULL)\n        goto memory_error;\n      *((char *) mempcpy (names->name[cur++], pattern, len)) = '\\0';\n    }\n\n  result = GLOB_NOMATCH;\n  if (nfound != 0)\n    {\n      char **new_gl_pathv;\n      result = 0;\n\n      if (SIZE_MAX \/ sizeof (char *) - pglob->gl_pathc\n          < pglob->gl_offs + nfound + 1)\n        goto memory_error;\n\n      new_gl_pathv\n        = realloc (pglob->gl_pathv,\n                   (pglob->gl_pathc + pglob->gl_offs + nfound + 1)\n                    * sizeof (char *));\n\n      if (new_gl_pathv == NULL)\n        {\n        memory_error:\n          while (1)\n            {\n              struct globnames *old = names;\n              for (size_t i = 0; i < cur; ++i)\n                free (names->name[i]);\n              names = names->next;\n              \/* NB: we will not leak memory here if we exit without\n                 freeing the current block assigned to OLD.  At least\n                 the very first block is always allocated on the stack\n                 and this is the block assigned to OLD here.  *\/\n              if (names == NULL)\n                {\n                  assert (old == init_names);\n                  break;\n                }\n              cur = names->count;\n              if (old == names_alloca)\n                names_alloca = names;\n              else\n                free (old);\n            }\n          result = GLOB_NOSPACE;\n        }\n      else\n        {\n          while (1)\n            {\n              struct globnames *old = names;\n              for (size_t i = 0; i < cur; ++i)\n                new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]\n                  = names->name[i];\n              names = names->next;\n              \/* NB: we will not leak memory here if we exit without\n                 freeing the current block assigned to OLD.  At least\n                 the very first block is always allocated on the stack\n                 and this is the block assigned to OLD here.  *\/\n              if (names == NULL)\n                {\n                  assert (old == init_names);\n                  break;\n                }\n              cur = names->count;\n              if (old == names_alloca)\n                names_alloca = names;\n              else\n                free (old);\n            }\n\n          pglob->gl_pathv = new_gl_pathv;\n\n          pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;\n\n          pglob->gl_flags = flags;\n        }\n    }\n\n  if (stream != NULL)\n    {\n      save = errno;\n      if (__glibc_unlikely (flags & GLOB_ALTDIRFUNC))\n        (*pglob->gl_closedir) (stream);\n      else\n        closedir (stream);\n      __set_errno (save);\n    }\n\n  return result;\n}","target":0,"code_token_length":1944,"total_token_length":2180,"max_tokens_setting":4096}
+{"idx":380949,"func":"ins_tab(void)\n{\n    int\t\tind;\n    int\t\ti;\n    int\t\ttemp;\n\n    if (Insstart_blank_vcol == MAXCOL && curwin->w_cursor.lnum == Insstart.lnum)\n\tInsstart_blank_vcol = get_nolist_virtcol();\n    if (echeck_abbr(TAB + ABBR_OFF))\n\treturn FALSE;\n\n    ind = inindent(0);\n    if (ind)\n\tcan_cindent = FALSE;\n\n    \/*\n     * When nothing special, insert TAB like a normal character.\n     *\/\n    if (!curbuf->b_p_et\n#ifdef FEAT_VARTABS\n\t    && !(p_sta && ind\n\t\t\/\/ These five lines mean 'tabstop' != 'shiftwidth'\n\t\t&& ((tabstop_count(curbuf->b_p_vts_array) > 1)\n\t\t    || (tabstop_count(curbuf->b_p_vts_array) == 1\n\t\t\t&& tabstop_first(curbuf->b_p_vts_array)\n\t\t\t\t\t\t       != get_sw_value(curbuf))\n\t\t    || (tabstop_count(curbuf->b_p_vts_array) == 0\n\t\t\t&& curbuf->b_p_ts != get_sw_value(curbuf))))\n\t    && tabstop_count(curbuf->b_p_vsts_array) == 0\n#else\n\t    && !(p_sta && ind && curbuf->b_p_ts != get_sw_value(curbuf))\n#endif\n\t    && get_sts_value() == 0)\n\treturn TRUE;\n\n    if (stop_arrow() == FAIL)\n\treturn TRUE;\n\n    did_ai = FALSE;\n    did_si = FALSE;\n    can_si = FALSE;\n    can_si_back = FALSE;\n    AppendToRedobuff((char_u *)\"\\t\");\n\n#ifdef FEAT_VARTABS\n    if (p_sta && ind)\t\t\/\/ insert tab in indent, use 'shiftwidth'\n    {\n\ttemp = (int)get_sw_value(curbuf);\n\ttemp -= get_nolist_virtcol() % temp;\n    }\n    else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0)\n\t\t\t\t\/\/ use 'softtabstop' when set\n\ttemp = tabstop_padding(get_nolist_virtcol(), get_sts_value(),\n\t\t\t\t\t\t     curbuf->b_p_vsts_array);\n    else\t\t\t\/\/ otherwise use 'tabstop'\n\ttemp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_ts,\n\t\t\t\t\t\t     curbuf->b_p_vts_array);\n#else\n    if (p_sta && ind)\t\t\/\/ insert tab in indent, use 'shiftwidth'\n\ttemp = (int)get_sw_value(curbuf);\n    else if (curbuf->b_p_sts != 0) \/\/ use 'softtabstop' when set\n\ttemp = (int)get_sts_value();\n    else\t\t\t\/\/ otherwise use 'tabstop'\n\ttemp = (int)curbuf->b_p_ts;\n    temp -= get_nolist_virtcol() % temp;\n#endif\n\n    \/*\n     * Insert the first space with ins_char().\tIt will delete one char in\n     * replace mode.  Insert the rest with ins_str(); it will not delete any\n     * chars.  For MODE_VREPLACE state, we use ins_char() for all characters.\n     *\/\n    ins_char(' ');\n    while (--temp > 0)\n    {\n\tif (State & VREPLACE_FLAG)\n\t    ins_char(' ');\n\telse\n\t{\n\t    ins_str((char_u *)\" \");\n\t    if (State & REPLACE_FLAG)\t    \/\/ no char replaced\n\t\treplace_push(NUL);\n\t}\n    }\n\n    \/*\n     * When 'expandtab' not set: Replace spaces by TABs where possible.\n     *\/\n#ifdef FEAT_VARTABS\n    if (!curbuf->b_p_et && (tabstop_count(curbuf->b_p_vsts_array) > 0\n\t\t\t    || get_sts_value() > 0\n\t\t\t    || (p_sta && ind)))\n#else\n    if (!curbuf->b_p_et && (get_sts_value() || (p_sta && ind)))\n#endif\n    {\n\tchar_u\t\t*ptr;\n\tchar_u\t\t*saved_line = NULL;\t\/\/ init for GCC\n\tpos_T\t\tpos;\n\tpos_T\t\tfpos;\n\tpos_T\t\t*cursor;\n\tcolnr_T\t\twant_vcol, vcol;\n\tint\t\tchange_col = -1;\n\tint\t\tsave_list = curwin->w_p_list;\n\n\t\/*\n\t * Get the current line.  For MODE_VREPLACE state, don't make real\n\t * changes yet, just work on a copy of the line.\n\t *\/\n\tif (State & VREPLACE_FLAG)\n\t{\n\t    pos = curwin->w_cursor;\n\t    cursor = &pos;\n\t    saved_line = vim_strsave(ml_get_curline());\n\t    if (saved_line == NULL)\n\t\treturn FALSE;\n\t    ptr = saved_line + pos.col;\n\t}\n\telse\n\t{\n\t    ptr = ml_get_cursor();\n\t    cursor = &curwin->w_cursor;\n\t}\n\n\t\/\/ When 'L' is not in 'cpoptions' a tab always takes up 'ts' spaces.\n\tif (vim_strchr(p_cpo, CPO_LISTWM) == NULL)\n\t    curwin->w_p_list = FALSE;\n\n\t\/\/ Find first white before the cursor\n\tfpos = curwin->w_cursor;\n\twhile (fpos.col > 0 && VIM_ISWHITE(ptr[-1]))\n\t{\n\t    --fpos.col;\n\t    --ptr;\n\t}\n\n\t\/\/ In Replace mode, don't change characters before the insert point.\n\tif ((State & REPLACE_FLAG)\n\t\t&& fpos.lnum == Insstart.lnum\n\t\t&& fpos.col < Insstart.col)\n\t{\n\t    ptr += Insstart.col - fpos.col;\n\t    fpos.col = Insstart.col;\n\t}\n\n\t\/\/ compute virtual column numbers of first white and cursor\n\tgetvcol(curwin, &fpos, &vcol, NULL, NULL);\n\tgetvcol(curwin, cursor, &want_vcol, NULL, NULL);\n\n\t\/\/ Use as many TABs as possible.  Beware of 'breakindent', 'showbreak'\n\t\/\/ and 'linebreak' adding extra virtual columns.\n\twhile (VIM_ISWHITE(*ptr))\n\t{\n\t    i = lbr_chartabsize(NULL, (char_u *)\"\\t\", vcol);\n\t    if (vcol + i > want_vcol)\n\t\tbreak;\n\t    if (*ptr != TAB)\n\t    {\n\t\t*ptr = TAB;\n\t\tif (change_col < 0)\n\t\t{\n\t\t    change_col = fpos.col;  \/\/ Column of first change\n\t\t    \/\/ May have to adjust Insstart\n\t\t    if (fpos.lnum == Insstart.lnum && fpos.col < Insstart.col)\n\t\t\tInsstart.col = fpos.col;\n\t\t}\n\t    }\n\t    ++fpos.col;\n\t    ++ptr;\n\t    vcol += i;\n\t}\n\n\tif (change_col >= 0)\n\t{\n\t    int repl_off = 0;\n\t    char_u *line = ptr;\n\n\t    \/\/ Skip over the spaces we need.\n\t    while (vcol < want_vcol && *ptr == ' ')\n\t    {\n\t\tvcol += lbr_chartabsize(line, ptr, vcol);\n\t\t++ptr;\n\t\t++repl_off;\n\t    }\n\t    if (vcol > want_vcol)\n\t    {\n\t\t\/\/ Must have a char with 'showbreak' just before it.\n\t\t--ptr;\n\t\t--repl_off;\n\t    }\n\t    fpos.col += repl_off;\n\n\t    \/\/ Delete following spaces.\n\t    i = cursor->col - fpos.col;\n\t    if (i > 0)\n\t    {\n#ifdef FEAT_PROP_POPUP\n\t\tif (!(State & VREPLACE_FLAG))\n\t\t{\n\t\t    char_u  *newp;\n\t\t    int\t    col;\n\n\t\t    newp = alloc(curbuf->b_ml.ml_line_len - i);\n\t\t    if (newp == NULL)\n\t\t\treturn FALSE;\n\n\t\t    col = ptr - curbuf->b_ml.ml_line_ptr;\n\t\t    if (col > 0)\n\t\t\tmch_memmove(newp, ptr - col, col);\n\t\t    mch_memmove(newp + col, ptr + i,\n\t\t\t\t\t   curbuf->b_ml.ml_line_len - col - i);\n\n\t\t    if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY)\n\t\t\tvim_free(curbuf->b_ml.ml_line_ptr);\n\t\t    curbuf->b_ml.ml_line_ptr = newp;\n\t\t    curbuf->b_ml.ml_line_len -= i;\n\t\t    curbuf->b_ml.ml_flags =\n\t\t\t   (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY;\n\t\t}\n\t\telse\n#endif\n\t\t    STRMOVE(ptr, ptr + i);\n\t\t\/\/ correct replace stack.\n\t\tif ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))\n\t\t    for (temp = i; --temp >= 0; )\n\t\t\treplace_join(repl_off);\n\t    }\n#ifdef FEAT_NETBEANS_INTG\n\t    if (netbeans_active())\n\t    {\n\t\tnetbeans_removed(curbuf, fpos.lnum, cursor->col, (long)(i + 1));\n\t\tnetbeans_inserted(curbuf, fpos.lnum, cursor->col,\n\t\t\t\t\t\t\t   (char_u *)\"\\t\", 1);\n\t    }\n#endif\n\t    cursor->col -= i;\n\n\t    \/*\n\t     * In MODE_VREPLACE state, we haven't changed anything yet.  Do it\n\t     * now by backspacing over the changed spacing and then inserting\n\t     * the new spacing.\n\t     *\/\n\t    if (State & VREPLACE_FLAG)\n\t    {\n\t\t\/\/ Backspace from real cursor to change_col\n\t\tbackspace_until_column(change_col);\n\n\t\t\/\/ Insert each char in saved_line from changed_col to\n\t\t\/\/ ptr-cursor\n\t\tins_bytes_len(saved_line + change_col,\n\t\t\t\t\t\t    cursor->col - change_col);\n\t    }\n\t}\n\n\tif (State & VREPLACE_FLAG)\n\t    vim_free(saved_line);\n\tcurwin->w_p_list = save_list;\n    }\n\n    return FALSE;\n}","target":0,"code_token_length":2121,"total_token_length":2357,"max_tokens_setting":4096}
+{"idx":462224,"func":"PJ_DEF(pj_status_t) pj_stun_msg_encode(pj_stun_msg *msg,\n\t\t\t\t       pj_uint8_t *buf, pj_size_t buf_size,\n\t\t\t\t       unsigned options,\n\t\t\t\t       const pj_str_t *key,\n\t\t\t\t       pj_size_t *p_msg_len)\n{\n    pj_uint8_t *start = buf;\n    pj_stun_msgint_attr *amsgint = NULL;\n    pj_stun_fingerprint_attr *afingerprint = NULL;\n    unsigned printed = 0, body_len;\n    pj_status_t status;\n    unsigned i;\n\n\n    PJ_ASSERT_RETURN(msg && buf && buf_size, PJ_EINVAL);\n\n    PJ_UNUSED_ARG(options);\n    PJ_ASSERT_RETURN(options == 0, PJ_EINVAL);\n\n    \/* Copy the message header part and convert the header fields to\n     * network byte order\n     *\/\n    if (buf_size < sizeof(pj_stun_msg_hdr))\n\treturn PJ_ETOOSMALL;\n    \n    PUTVAL16H(buf, 0, msg->hdr.type);\n    PUTVAL16H(buf, 2, 0);   \/* length will be calculated later *\/\n    PUTVAL32H(buf, 4, msg->hdr.magic);\n    pj_memcpy(buf+8, msg->hdr.tsx_id, sizeof(msg->hdr.tsx_id));\n\n    buf += sizeof(pj_stun_msg_hdr);\n    buf_size -= sizeof(pj_stun_msg_hdr);\n\n    \/* Encode each attribute to the message *\/\n    for (i=0; i<msg->attr_count; ++i) {\n\tconst struct attr_desc *adesc;\n\tconst pj_stun_attr_hdr *attr_hdr = msg->attr[i];\n\n\tif (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {\n\t    pj_assert(amsgint == NULL);\n\t    amsgint = (pj_stun_msgint_attr*) attr_hdr;\n\n\t    \/* Stop when encountering MESSAGE-INTEGRITY *\/\n\t    break;\n\n\t} else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) {\n\t    afingerprint = (pj_stun_fingerprint_attr*) attr_hdr;\n\t    break;\n\t}\n\n\tadesc = find_attr_desc(attr_hdr->type);\n\tif (adesc) {\n\t    status = adesc->encode_attr(attr_hdr, buf, (unsigned)buf_size, \n\t\t\t\t\t&msg->hdr, &printed);\n\t} else {\n\t    \/* This may be a generic attribute *\/\n\t    const pj_stun_binary_attr *bin_attr = (const pj_stun_binary_attr*) \n\t\t\t\t\t\t   attr_hdr;\n\t    PJ_ASSERT_RETURN(bin_attr->magic == PJ_STUN_MAGIC, PJ_EBUG);\n\t    status = encode_binary_attr(bin_attr, buf, (unsigned)buf_size, \n\t\t\t\t\t&msg->hdr, &printed);\n\t}\n\n\tif (status != PJ_SUCCESS)\n\t    return status;\n\n\tbuf += printed;\n\tbuf_size -= printed;\n    }\n\n    \/* We may have stopped printing attribute because we found\n     * MESSAGE-INTEGRITY or FINGERPRINT. Scan the rest of the\n     * attributes.\n     *\/\n    for ( ++i; i<msg->attr_count; ++i) {\n\tconst pj_stun_attr_hdr *attr_hdr = msg->attr[i];\n\n\t\/* There mustn't any attribute after FINGERPRINT *\/\n\tPJ_ASSERT_RETURN(afingerprint == NULL, PJNATH_ESTUNFINGERPOS);\n\n\tif (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {\n\t    \/* There mustn't be MESSAGE-INTEGRITY before *\/\n\t    PJ_ASSERT_RETURN(amsgint == NULL, \n\t\t\t     PJNATH_ESTUNMSGINTPOS);\n\t    amsgint = (pj_stun_msgint_attr*) attr_hdr;\n\n\t} else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) {\n\t    afingerprint = (pj_stun_fingerprint_attr*) attr_hdr;\n\t}\n    }\n\n#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT\n    \/*\n     * This is the old style MESSAGE-INTEGRITY and FINGERPRINT\n     * calculation, used in rfc3489bis-06 and older.\n     *\/\n    \/* We MUST update the message length in the header NOW before\n     * calculating MESSAGE-INTEGRITY and FINGERPRINT. \n     * Note that length is not including the 20 bytes header.\n      *\/\n    if (amsgint && afingerprint) {\n\tbody_len = (pj_uint16_t)((buf - start) - 20 + 24 + 8);\n    } else if (amsgint) {\n\tbody_len = (pj_uint16_t)((buf - start) - 20 + 24);\n    } else if (afingerprint) {\n\tbody_len = (pj_uint16_t)((buf - start) - 20 + 8);\n    } else {\n\tbody_len = (pj_uint16_t)((buf - start) - 20);\n    }\n#else\n    \/* If MESSAGE-INTEGRITY is present, include the M-I attribute\n     * in message length before calculating M-I\n     *\/\n    if (amsgint) {\n\tbody_len = (pj_uint16_t)((buf - start) - 20 + 24);\n    } else {\n\tbody_len = (pj_uint16_t)((buf - start) - 20);\n    }\n#endif\t\/* PJ_STUN_OLD_STYLE_MI_FINGERPRINT *\/\n\n    \/* hdr->length = pj_htons(length); *\/\n    PUTVAL16H(start, 2, (pj_uint16_t)body_len);\n\n    \/* Calculate message integrity, if present *\/\n    if (amsgint != NULL) {\n\tpj_hmac_sha1_context ctx;\n\n\t\/* Key MUST be specified *\/\n\tPJ_ASSERT_RETURN(key, PJ_EINVALIDOP);\n\n\t\/* MESSAGE-INTEGRITY must be the last attribute in the message, or\n\t * the last attribute before FINGERPRINT.\n\t *\/\n\tif (msg->attr_count>1 && i < msg->attr_count-2) {\n\t    \/* Should not happen for message generated by us *\/\n\t    pj_assert(PJ_FALSE);\n\t    return PJNATH_ESTUNMSGINTPOS;\n\n\t} else if (i == msg->attr_count-2)  {\n\t    if (msg->attr[i+1]->type != PJ_STUN_ATTR_FINGERPRINT) {\n\t\t\/* Should not happen for message generated by us *\/\n\t\tpj_assert(PJ_FALSE);\n\t\treturn PJNATH_ESTUNMSGINTPOS;\n\t    } else {\n\t\tafingerprint = (pj_stun_fingerprint_attr*) msg->attr[i+1];\n\t    }\n\t}\n\n\t\/* Calculate HMAC-SHA1 digest, add zero padding to input\n\t * if necessary to make the input 64 bytes aligned.\n\t *\/\n\tpj_hmac_sha1_init(&ctx, (const pj_uint8_t*)key->ptr, \n\t\t\t  (unsigned)key->slen);\n\tpj_hmac_sha1_update(&ctx, (const pj_uint8_t*)start, \n\t\t\t    (unsigned)(buf-start));\n#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT\n\t\/\/ These are obsoleted in rfc3489bis-08\n\tif ((buf-start) & 0x3F) {\n\t    pj_uint8_t zeroes[64];\n\t    pj_bzero(zeroes, sizeof(zeroes));\n\t    pj_hmac_sha1_update(&ctx, zeroes, 64-((buf-start) & 0x3F));\n\t}\n#endif\t\/* PJ_STUN_OLD_STYLE_MI_FINGERPRINT *\/\n\tpj_hmac_sha1_final(&ctx, amsgint->hmac);\n\n\t\/* Put this attribute in the message *\/\n\tstatus = encode_msgint_attr(amsgint, buf, (unsigned)buf_size, \n\t\t\t            &msg->hdr, &printed);\n\tif (status != PJ_SUCCESS)\n\t    return status;\n\n\tbuf += printed;\n\tbuf_size -= printed;\n    }\n\n    \/* Calculate FINGERPRINT if present *\/\n    if (afingerprint != NULL) {\n\n#if !PJ_STUN_OLD_STYLE_MI_FINGERPRINT\n\t\/* Update message length *\/\n\tPUTVAL16H(start, 2, \n\t\t (pj_uint16_t)(GETVAL16H(start, 2)+8));\n#endif\n\n\tafingerprint->value = pj_crc32_calc(start, buf-start);\n\tafingerprint->value ^= STUN_XOR_FINGERPRINT;\n\n\t\/* Put this attribute in the message *\/\n\tstatus = encode_uint_attr(afingerprint, buf, (unsigned)buf_size, \n\t\t\t\t  &msg->hdr, &printed);\n\tif (status != PJ_SUCCESS)\n\t    return status;\n\n\tbuf += printed;\n\tbuf_size -= printed;\n    }\n\n    \/* Update message length. *\/\n    msg->hdr.length = (pj_uint16_t) ((buf - start) - 20);\n\n    \/* Return the length *\/\n    if (p_msg_len)\n\t*p_msg_len = (buf - start);\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":1854,"total_token_length":2090,"max_tokens_setting":4096}
+{"idx":386577,"func":"bool DL_Dxf::processDXFGroup(DL_CreationInterface* creationInterface,\n                             int groupCode, const std::string& groupValue) {\n\n    \/\/printf(\"%d\\n\", groupCode);\n    \/\/printf(\"%s\\n\", groupValue.c_str());\n\n    \/\/ Init values on first call\n    if (firstCall) {\n        settingValue[0] = '\\0';\n        firstCall=false;\n    }\n\n    \/\/ Indicates comment or dxflib version:\n    if (groupCode==999) {\n        if (!groupValue.empty()) {\n            if (groupValue.substr(0, 6)==\"dxflib\") {\n                libVersion = getLibVersion(groupValue.substr(7));\n            }\n            \n            addComment(creationInterface, groupValue);\n        }\n    }\n\n    \/\/ Indicates start of new entity or variable:\n    else if (groupCode==0 || groupCode==9) {\n        \/\/ If new entity is encountered, the last one is complete.\n        \/\/ Prepare default attributes for next entity:\n        std::string layer = getStringValue(8, \"0\");\n\n        int width;\n        \/\/ Compatibility with qcad1:\n        if (hasValue(39) && !hasValue(370)) {\n            width = getIntValue(39, -1);\n        }\n        \/\/ since autocad 2002:\n        else if (hasValue(370)) {\n            width = getIntValue(370, -1);\n        }\n        \/\/ default to BYLAYER:\n        else {\n            width = -1;\n        }\n\n        int color;\n        color = getIntValue(62, 256);\n        int color24;\n        color24 = getIntValue(420, -1);\n        int handle;\n        handle = getInt16Value(5, -1);\n\n        std::string linetype = getStringValue(6, \"BYLAYER\");\n\n        attrib = DL_Attributes(layer,                   \/\/ layer\n                               color,                   \/\/ color\n                               color24,                 \/\/ 24 bit color\n                               width,                   \/\/ width\n                               linetype,                \/\/ linetype\n                               handle);                 \/\/ handle\n        attrib.setInPaperSpace((bool)getIntValue(67, 0));\n        attrib.setLinetypeScale(getRealValue(48, 1.0));\n        creationInterface->setAttributes(attrib);\n\n        int elevationGroupCode=30;\n        if (currentObjectType==DL_ENTITY_LWPOLYLINE ) {\n            \/\/ see lwpolyline group codes reference\n            elevationGroupCode=38;\n        }\n        else {\n            \/\/ see polyline group codes reference\n            elevationGroupCode=30;\n        }\n\n        creationInterface->setExtrusion(getRealValue(210, 0.0),\n                                        getRealValue(220, 0.0),\n                                        getRealValue(230, 1.0),\n                                        getRealValue(elevationGroupCode, 0.0));\n\n        \/\/ Add the previously parsed entity via creationInterface\n        switch (currentObjectType) {\n        case DL_SETTING:\n            addSetting(creationInterface);\n            break;\n\n        case DL_LAYER:\n            addLayer(creationInterface);\n            break;\n\n        case DL_LINETYPE:\n            addLinetype(creationInterface);\n            break;\n\n        case DL_BLOCK:\n            addBlock(creationInterface);\n            break;\n\n        case DL_ENDBLK:\n            endBlock(creationInterface);\n            break;\n\n        case DL_STYLE:\n            addTextStyle(creationInterface);\n            break;\n\n        case DL_ENTITY_POINT:\n            addPoint(creationInterface);\n            break;\n\n        case DL_ENTITY_LINE:\n            addLine(creationInterface);\n            break;\n\n        case DL_ENTITY_XLINE:\n            addXLine(creationInterface);\n            break;\n\n        case DL_ENTITY_RAY:\n            addRay(creationInterface);\n            break;\n\n        case DL_ENTITY_POLYLINE:\n        case DL_ENTITY_LWPOLYLINE:\n            addPolyline(creationInterface);\n            break;\n\n        case DL_ENTITY_VERTEX:\n            addVertex(creationInterface);\n            break;\n\n        case DL_ENTITY_SPLINE:\n            addSpline(creationInterface);\n            break;\n\n        case DL_ENTITY_ARC:\n            addArc(creationInterface);\n            break;\n\n        case DL_ENTITY_CIRCLE:\n            addCircle(creationInterface);\n            break;\n\n        case DL_ENTITY_ELLIPSE:\n            addEllipse(creationInterface);\n            break;\n\n        case DL_ENTITY_INSERT:\n            addInsert(creationInterface);\n            break;\n\n        case DL_ENTITY_MTEXT:\n            addMText(creationInterface);\n            break;\n\n        case DL_ENTITY_TEXT:\n            addText(creationInterface);\n            break;\n\n        case DL_ENTITY_ARCALIGNEDTEXT:\n            addArcAlignedText(creationInterface);\n            break;\n\n        case DL_ENTITY_ATTRIB:\n            addAttribute(creationInterface);\n            break;\n\n        case DL_ENTITY_DIMENSION: {\n                int type = (getIntValue(70, 0)&0x07);\n\n                switch (type) {\n                case 0:\n                    addDimLinear(creationInterface);\n                    break;\n\n                case 1:\n                    addDimAligned(creationInterface);\n                    break;\n\n                case 2:\n                    addDimAngular(creationInterface);\n                    break;\n\n                case 3:\n                    addDimDiametric(creationInterface);\n                    break;\n\n                case 4:\n                    addDimRadial(creationInterface);\n                    break;\n\n                case 5:\n                    addDimAngular3P(creationInterface);\n                    break;\n                \n                case 6:\n                    addDimOrdinate(creationInterface);\n                    break;\n\n                default:\n                    break;\n                }\n            }\n            break;\n\n        case DL_ENTITY_LEADER:\n            addLeader(creationInterface);\n            break;\n\n        case DL_ENTITY_HATCH:\n            \/\/addHatch(creationInterface);\n            handleHatchData(creationInterface);\n            break;\n\n        case DL_ENTITY_IMAGE:\n            addImage(creationInterface);\n            break;\n\n        case DL_ENTITY_IMAGEDEF:\n            addImageDef(creationInterface);\n            break;\n\n        case DL_ENTITY_TRACE:\n            addTrace(creationInterface);\n            break;\n        \n        case DL_ENTITY_3DFACE:\n            add3dFace(creationInterface);\n            break;\n\n        case DL_ENTITY_SOLID:\n            addSolid(creationInterface);\n            break;\n\n        case DL_ENTITY_SEQEND:\n            endSequence(creationInterface);\n            break;\n\n        default:\n            break;\n        }\n\n        creationInterface->endSection();\n\n        \/\/ reset all values (they are not persistent and only this\n        \/\/  way we can set defaults for omitted values)\n\/\/        for (int i=0; i<DL_DXF_MAXGROUPCODE; ++i) {\n\/\/            values[i][0] = '\\0';\n\/\/        }\n        values.clear();\n        settingValue[0] = '\\0';\n        settingKey = \"\";\n        firstHatchLoop = true;\n        \/\/firstHatchEdge = true;\n        hatchEdge = DL_HatchEdgeData();\n        \/\/xRecordHandle = \"\";\n        xRecordValues = false;\n\n        \/\/ Last DXF entity or setting has been handled\n        \/\/ Now determine what the next entity or setting type is\n\n        int prevEntity = currentObjectType;\n\n        \/\/ Read DXF variable:\n        if (groupValue[0]=='$') {\n            currentObjectType = DL_SETTING;\n            settingKey = groupValue;\n        }\n\n        \/\/ Read Layers:\n        else if (groupValue==\"LAYER\") {\n            currentObjectType = DL_LAYER;\n        }\n\n        \/\/ Read Linetypes:\n        else if (groupValue==\"LTYPE\") {\n            currentObjectType = DL_LINETYPE;\n        }\n\n        \/\/ Read Blocks:\n        else if (groupValue==\"BLOCK\") {\n            currentObjectType = DL_BLOCK;\n        } else if (groupValue==\"ENDBLK\") {\n            currentObjectType = DL_ENDBLK;\n        }\n\n        \/\/ Read text styles:\n        else if (groupValue==\"STYLE\") {\n            currentObjectType = DL_STYLE;\n        }\n\n        \/\/ Read entities:\n        else if (groupValue==\"POINT\") {\n            currentObjectType = DL_ENTITY_POINT;\n        } else if (groupValue==\"LINE\") {\n            currentObjectType = DL_ENTITY_LINE;\n        } else if (groupValue==\"XLINE\") {\n            currentObjectType = DL_ENTITY_XLINE;\n        } else if (groupValue==\"RAY\") {\n            currentObjectType = DL_ENTITY_RAY;\n        } else if (groupValue==\"POLYLINE\") {\n            currentObjectType = DL_ENTITY_POLYLINE;\n        } else if (groupValue==\"LWPOLYLINE\") {\n            currentObjectType = DL_ENTITY_LWPOLYLINE;\n        } else if (groupValue==\"VERTEX\") {\n            currentObjectType = DL_ENTITY_VERTEX;\n        } else if (groupValue==\"SPLINE\") {\n            currentObjectType = DL_ENTITY_SPLINE;\n        } else if (groupValue==\"ARC\") {\n            currentObjectType = DL_ENTITY_ARC;\n        } else if (groupValue==\"ELLIPSE\") {\n            currentObjectType = DL_ENTITY_ELLIPSE;\n        } else if (groupValue==\"CIRCLE\") {\n            currentObjectType = DL_ENTITY_CIRCLE;\n        } else if (groupValue==\"INSERT\") {\n            currentObjectType = DL_ENTITY_INSERT;\n        } else if (groupValue==\"TEXT\") {\n            currentObjectType = DL_ENTITY_TEXT;\n        } else if (groupValue==\"MTEXT\") {\n            currentObjectType = DL_ENTITY_MTEXT;\n        } else if (groupValue==\"ARCALIGNEDTEXT\") {\n            currentObjectType = DL_ENTITY_ARCALIGNEDTEXT;\n        } else if (groupValue==\"ATTRIB\") {\n            currentObjectType = DL_ENTITY_ATTRIB;\n        } else if (groupValue==\"DIMENSION\") {\n            currentObjectType = DL_ENTITY_DIMENSION;\n        } else if (groupValue==\"LEADER\") {\n            currentObjectType = DL_ENTITY_LEADER;\n        } else if (groupValue==\"HATCH\") {\n            currentObjectType = DL_ENTITY_HATCH;\n        } else if (groupValue==\"IMAGE\") {\n            currentObjectType = DL_ENTITY_IMAGE;\n        } else if (groupValue==\"IMAGEDEF\") {\n            currentObjectType = DL_ENTITY_IMAGEDEF;\n        } else if (groupValue==\"TRACE\") {\n           currentObjectType = DL_ENTITY_TRACE;\n        } else if (groupValue==\"SOLID\") {\n           currentObjectType = DL_ENTITY_SOLID;\n        } else if (groupValue==\"3DFACE\") {\n           currentObjectType = DL_ENTITY_3DFACE;\n        } else if (groupValue==\"SEQEND\") {\n            currentObjectType = DL_ENTITY_SEQEND;\n        } else if (groupValue==\"XRECORD\") {\n            currentObjectType = DL_XRECORD;\n        } else if (groupValue==\"DICTIONARY\") {\n            currentObjectType = DL_DICTIONARY;\n        } else {\n            currentObjectType = DL_UNKNOWN;\n        }\n\n        \/\/ end of old style POLYLINE entity\n        if (prevEntity==DL_ENTITY_VERTEX && currentObjectType!=DL_ENTITY_VERTEX) {\n            endEntity(creationInterface);\n        }\n\n        \/\/ TODO: end of SPLINE entity\n        \/\/if (prevEntity==DL_ENTITY_CONTROLPOINT && currentEntity!=DL_ENTITY_CONTROLPOINT) {\n        \/\/    endEntity(creationInterface);\n        \/\/}\n\n        return true;\n\n    } else {\n        \/\/ Group code does not indicate start of new entity or setting,\n        \/\/ so this group must be continuation of data for the current\n        \/\/ one.\n        if (groupCode<DL_DXF_MAXGROUPCODE) {\n\n            bool handled = false;\n\n            switch (currentObjectType) {\n            case DL_ENTITY_MTEXT:\n                handled = handleMTextData(creationInterface);\n                break;\n\n            case DL_ENTITY_LWPOLYLINE:\n                handled = handleLWPolylineData(creationInterface);\n                break;\n\n            case DL_ENTITY_SPLINE:\n                handled = handleSplineData(creationInterface);\n                break;\n\n            case DL_ENTITY_LEADER:\n                handled = handleLeaderData(creationInterface);\n                break;\n\n            case DL_ENTITY_HATCH:\n                handled = handleHatchData(creationInterface);\n                break;\n\n            case DL_XRECORD:\n                handled = handleXRecordData(creationInterface);\n                break;\n\n            case DL_DICTIONARY:\n                handled = handleDictionaryData(creationInterface);\n                break;\n\n            case DL_LINETYPE:\n                handled = handleLinetypeData(creationInterface);\n                break;\n\n            default:\n                break;\n            }\n\n            \/\/ Always try to handle XData, unless we're in an XData record:\n            if (currentObjectType!=DL_XRECORD) {\n                handled = handleXData(creationInterface);\n            }\n\n            if (!handled) {\n                \/\/ Normal group \/ value pair:\n                values[groupCode] = groupValue;\n            }\n        }\n\n        return false;\n    }\n    return false;\n}","target":0,"code_token_length":2653,"total_token_length":2889,"max_tokens_setting":4096}
+{"idx":247578,"func":"void testUtilV2(const TestUtilOptionsV2& options) {\n  Event::SimulatedTimeSystem time_system;\n  ContextManagerImpl manager(*time_system);\n\n  \/\/ SNI-based selection logic isn't happening in SslSocket anymore.\n  ASSERT(options.listener().filter_chains().size() == 1);\n  const auto& filter_chain = options.listener().filter_chains(0);\n  std::vector<std::string> server_names(filter_chain.filter_chain_match().server_names().begin(),\n                                        filter_chain.filter_chain_match().server_names().end());\n  Stats::TestUtil::TestStore server_stats_store;\n  Api::ApiPtr server_api = Api::createApiForTest(server_stats_store, time_system);\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>\n      server_factory_context;\n  NiceMock<Runtime::MockLoader> runtime;\n  ON_CALL(server_factory_context, api()).WillByDefault(ReturnRef(*server_api));\n\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  const envoy::config::core::v3::TransportSocket& transport_socket =\n      filter_chain.transport_socket();\n  ASSERT(transport_socket.has_typed_config());\n  transport_socket.typed_config().UnpackTo(&tls_context);\n\n  auto server_cfg = std::make_unique<ServerContextConfigImpl>(tls_context, server_factory_context);\n\n  ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager,\n                                                   server_stats_store, server_names);\n  EXPECT_FALSE(server_ssl_socket_factory.usesProxyProtocolOptions());\n\n  Event::DispatcherPtr dispatcher(server_api->allocateDispatcher(\"test_thread\"));\n  auto socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(\n      Network::Test::getCanonicalLoopbackAddress(options.version()));\n  NiceMock<Network::MockTcpListenerCallbacks> callbacks;\n  Network::ListenerPtr listener =\n      dispatcher->createListener(socket, callbacks, runtime, true, false);\n\n  Stats::TestUtil::TestStore client_stats_store;\n  Api::ApiPtr client_api = Api::createApiForTest(client_stats_store, time_system);\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>\n      client_factory_context;\n  ON_CALL(client_factory_context, api()).WillByDefault(ReturnRef(*client_api));\n\n  auto client_cfg =\n      std::make_unique<ClientContextConfigImpl>(options.clientCtxProto(), client_factory_context);\n  ClientSslSocketFactory client_ssl_socket_factory(std::move(client_cfg), manager,\n                                                   client_stats_store);\n  Network::ClientConnectionPtr client_connection = dispatcher->createClientConnection(\n      socket->connectionInfoProvider().localAddress(), Network::Address::InstanceConstSharedPtr(),\n      client_ssl_socket_factory.createTransportSocket(options.transportSocketOptions()), nullptr);\n\n  if (!options.clientSession().empty()) {\n    const SslHandshakerImpl* ssl_socket =\n        dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());\n    SSL* client_ssl_socket = ssl_socket->ssl();\n    SSL_CTX* client_ssl_context = SSL_get_SSL_CTX(client_ssl_socket);\n    SSL_SESSION* client_ssl_session =\n        SSL_SESSION_from_bytes(reinterpret_cast<const uint8_t*>(options.clientSession().data()),\n                               options.clientSession().size(), client_ssl_context);\n    int rc = SSL_set_session(client_ssl_socket, client_ssl_session);\n    ASSERT(rc == 1);\n    SSL_SESSION_free(client_ssl_session);\n  }\n\n  Network::ConnectionPtr server_connection;\n  Network::MockConnectionCallbacks server_connection_callbacks;\n  NiceMock<StreamInfo::MockStreamInfo> stream_info;\n  EXPECT_CALL(callbacks, onAccept_(_))\n      .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {\n        std::string sni = options.transportSocketOptions() != nullptr &&\n                                  options.transportSocketOptions()->serverNameOverride().has_value()\n                              ? options.transportSocketOptions()->serverNameOverride().value()\n                              : options.clientCtxProto().sni();\n        socket->setRequestedServerName(sni);\n        Network::TransportSocketPtr transport_socket =\n            server_ssl_socket_factory.createTransportSocket(nullptr);\n        EXPECT_FALSE(transport_socket->startSecureTransport());\n        server_connection = dispatcher->createServerConnection(\n            std::move(socket), std::move(transport_socket), stream_info);\n        server_connection->addConnectionCallbacks(server_connection_callbacks);\n      }));\n\n  Network::MockConnectionCallbacks client_connection_callbacks;\n  client_connection->addConnectionCallbacks(client_connection_callbacks);\n  client_connection->connect();\n\n  size_t connect_count = 0;\n  auto connect_second_time = [&]() {\n    if (++connect_count == 2) {\n      if (!options.expectedServerCertDigest().empty()) {\n        EXPECT_EQ(options.expectedServerCertDigest(),\n                  client_connection->ssl()->sha256PeerCertificateDigest());\n      }\n      if (!options.expectedALPNProtocol().empty()) {\n        EXPECT_EQ(options.expectedALPNProtocol(), client_connection->nextProtocol());\n      }\n      EXPECT_EQ(options.expectedClientCertUri(), server_connection->ssl()->uriSanPeerCertificate());\n      const SslHandshakerImpl* ssl_socket =\n          dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());\n      SSL* client_ssl_socket = ssl_socket->ssl();\n      if (!options.expectedProtocolVersion().empty()) {\n        \/\/ Assert twice to ensure a cached value is returned and still valid.\n        EXPECT_EQ(options.expectedProtocolVersion(), client_connection->ssl()->tlsVersion());\n        EXPECT_EQ(options.expectedProtocolVersion(), client_connection->ssl()->tlsVersion());\n      }\n      if (!options.expectedCiphersuite().empty()) {\n        EXPECT_EQ(options.expectedCiphersuite(), client_connection->ssl()->ciphersuiteString());\n        const SSL_CIPHER* cipher =\n            SSL_get_cipher_by_value(client_connection->ssl()->ciphersuiteId());\n        EXPECT_NE(nullptr, cipher);\n        EXPECT_EQ(options.expectedCiphersuite(), SSL_CIPHER_get_name(cipher));\n      }\n\n      absl::optional<std::string> server_ssl_requested_server_name;\n      const SslHandshakerImpl* server_ssl_socket =\n          dynamic_cast<const SslHandshakerImpl*>(server_connection->ssl().get());\n      SSL* server_ssl = server_ssl_socket->ssl();\n      auto requested_server_name = SSL_get_servername(server_ssl, TLSEXT_NAMETYPE_host_name);\n      if (requested_server_name != nullptr) {\n        server_ssl_requested_server_name = std::string(requested_server_name);\n      }\n\n      if (!options.expectedRequestedServerName().empty()) {\n        EXPECT_TRUE(server_ssl_requested_server_name.has_value());\n        EXPECT_EQ(options.expectedRequestedServerName(), server_ssl_requested_server_name.value());\n      } else {\n        EXPECT_FALSE(server_ssl_requested_server_name.has_value());\n      }\n\n      const uint16_t tls_version = SSL_version(client_ssl_socket);\n      if (SSL3_VERSION <= tls_version && tls_version <= TLS1_2_VERSION) {\n        \/\/ Prior to TLS 1.3, one should be able to resume the session. With TLS\n        \/\/ 1.3, tickets come after the handshake and the SSL_SESSION on the\n        \/\/ client is a dummy object.\n        SSL_SESSION* client_ssl_session = SSL_get_session(client_ssl_socket);\n        EXPECT_TRUE(SSL_SESSION_is_resumable(client_ssl_session));\n      }\n      server_connection->close(Network::ConnectionCloseType::NoFlush);\n      client_connection->close(Network::ConnectionCloseType::NoFlush);\n      dispatcher->exit();\n    }\n  };\n\n  size_t close_count = 0;\n  auto close_second_time = [&close_count, &dispatcher]() {\n    if (++close_count == 2) {\n      dispatcher->exit();\n    }\n  };\n\n  if (options.expectSuccess()) {\n    EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { connect_second_time(); }));\n    EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void {\n          EXPECT_EQ(options.expectedRequestedServerName(),\n                    server_connection->requestedServerName());\n          connect_second_time();\n        }));\n    EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));\n    EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));\n  } else {\n    EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::RemoteClose))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { close_second_time(); }));\n    EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::RemoteClose))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { close_second_time(); }));\n  }\n\n  dispatcher->run(Event::Dispatcher::RunType::Block);\n\n  if (!options.expectedServerStats().empty()) {\n    EXPECT_EQ(1UL, server_stats_store.counter(options.expectedServerStats()).value())\n        << options.expectedServerStats();\n  }\n\n  if (!options.expectedClientStats().empty()) {\n    EXPECT_EQ(1UL, client_stats_store.counter(options.expectedClientStats()).value());\n  }\n\n  if (options.expectSuccess()) {\n    EXPECT_EQ(\"\", client_connection->transportFailureReason());\n    EXPECT_EQ(\"\", server_connection->transportFailureReason());\n  } else {\n    EXPECT_THAT(std::string(client_connection->transportFailureReason()),\n                ContainsRegex(options.expectedTransportFailureReasonContains()));\n    EXPECT_NE(\"\", server_connection->transportFailureReason());\n  }\n}","target":0,"code_token_length":1952,"total_token_length":2188,"max_tokens_setting":4096}
+{"idx":213515,"func":"spell_suggest(int count)\n{\n    char_u\t*line;\n    pos_T\tprev_cursor = curwin->w_cursor;\n    char_u\twcopy[MAXWLEN + 2];\n    char_u\t*p;\n    int\t\ti;\n    int\t\tc;\n    suginfo_T\tsug;\n    suggest_T\t*stp;\n    int\t\tmouse_used;\n    int\t\tneed_cap;\n    int\t\tlimit;\n    int\t\tselected = count;\n    int\t\tbadlen = 0;\n    int\t\tmsg_scroll_save = msg_scroll;\n    int\t\two_spell_save = curwin->w_p_spell;\n\n    if (!curwin->w_p_spell)\n    {\n\tdid_set_spelllang(curwin);\n\tcurwin->w_p_spell = TRUE;\n    }\n\n    if (*curwin->w_s->b_p_spl == NUL)\n    {\n\temsg(_(e_spell_checking_is_not_possible));\n\treturn;\n    }\n\n    if (VIsual_active)\n    {\n\t\/\/ Use the Visually selected text as the bad word.  But reject\n\t\/\/ a multi-line selection.\n\tif (curwin->w_cursor.lnum != VIsual.lnum)\n\t{\n\t    vim_beep(BO_SPELL);\n\t    return;\n\t}\n\tbadlen = (int)curwin->w_cursor.col - (int)VIsual.col;\n\tif (badlen < 0)\n\t    badlen = -badlen;\n\telse\n\t    curwin->w_cursor.col = VIsual.col;\n\t++badlen;\n\tend_visual_mode();\n    }\n    \/\/ Find the start of the badly spelled word.\n    else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0\n\t    || curwin->w_cursor.col > prev_cursor.col)\n    {\n\t\/\/ No bad word or it starts after the cursor: use the word under the\n\t\/\/ cursor.\n\tcurwin->w_cursor = prev_cursor;\n\tline = ml_get_curline();\n\tp = line + curwin->w_cursor.col;\n\t\/\/ Backup to before start of word.\n\twhile (p > line && spell_iswordp_nmw(p, curwin))\n\t    MB_PTR_BACK(line, p);\n\t\/\/ Forward to start of word.\n\twhile (*p != NUL && !spell_iswordp_nmw(p, curwin))\n\t    MB_PTR_ADV(p);\n\n\tif (!spell_iswordp_nmw(p, curwin))\t\t\/\/ No word found.\n\t{\n\t    beep_flush();\n\t    return;\n\t}\n\tcurwin->w_cursor.col = (colnr_T)(p - line);\n    }\n\n    \/\/ Get the word and its length.\n\n    \/\/ Figure out if the word should be capitalised.\n    need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);\n\n    \/\/ Make a copy of current line since autocommands may free the line.\n    line = vim_strsave(ml_get_curline());\n    if (line == NULL)\n\tgoto skip;\n\n    \/\/ Get the list of suggestions.  Limit to 'lines' - 2 or the number in\n    \/\/ 'spellsuggest', whatever is smaller.\n    if (sps_limit > (int)Rows - 2)\n\tlimit = (int)Rows - 2;\n    else\n\tlimit = sps_limit;\n    spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit,\n\t\t\t\t\t\t\tTRUE, need_cap, TRUE);\n\n    if (sug.su_ga.ga_len == 0)\n\tmsg(_(\"Sorry, no suggestions\"));\n    else if (count > 0)\n    {\n\tif (count > sug.su_ga.ga_len)\n\t    smsg(_(\"Sorry, only %ld suggestions\"), (long)sug.su_ga.ga_len);\n    }\n    else\n    {\n#ifdef FEAT_RIGHTLEFT\n\t\/\/ When 'rightleft' is set the list is drawn right-left.\n\tcmdmsg_rl = curwin->w_p_rl;\n\tif (cmdmsg_rl)\n\t    msg_col = Columns - 1;\n#endif\n\n\t\/\/ List the suggestions.\n\tmsg_start();\n\tmsg_row = Rows - 1;\t\/\/ for when 'cmdheight' > 1\n\tlines_left = Rows;\t\/\/ avoid more prompt\n\tvim_snprintf((char *)IObuff, IOSIZE, _(\"Change \\\"%.*s\\\" to:\"),\n\t\t\t\t\t\tsug.su_badlen, sug.su_badptr);\n#ifdef FEAT_RIGHTLEFT\n\tif (cmdmsg_rl && STRNCMP(IObuff, \"Change\", 6) == 0)\n\t{\n\t    \/\/ And now the rabbit from the high hat: Avoid showing the\n\t    \/\/ untranslated message rightleft.\n\t    vim_snprintf((char *)IObuff, IOSIZE, \":ot \\\"%.*s\\\" egnahC\",\n\t\t\t\t\t\tsug.su_badlen, sug.su_badptr);\n\t}\n#endif\n\tmsg_puts((char *)IObuff);\n\tmsg_clr_eos();\n\tmsg_putchar('\\n');\n\n\tmsg_scroll = TRUE;\n\tfor (i = 0; i < sug.su_ga.ga_len; ++i)\n\t{\n\t    stp = &SUG(sug.su_ga, i);\n\n\t    \/\/ The suggested word may replace only part of the bad word, add\n\t    \/\/ the not replaced part.\n\t    vim_strncpy(wcopy, stp->st_word, MAXWLEN);\n\t    if (sug.su_badlen > stp->st_orglen)\n\t\tvim_strncpy(wcopy + stp->st_wordlen,\n\t\t\t\t\t       sug.su_badptr + stp->st_orglen,\n\t\t\t\t\t      sug.su_badlen - stp->st_orglen);\n\t    vim_snprintf((char *)IObuff, IOSIZE, \"%2d\", i + 1);\n#ifdef FEAT_RIGHTLEFT\n\t    if (cmdmsg_rl)\n\t\trl_mirror(IObuff);\n#endif\n\t    msg_puts((char *)IObuff);\n\n\t    vim_snprintf((char *)IObuff, IOSIZE, \" \\\"%s\\\"\", wcopy);\n\t    msg_puts((char *)IObuff);\n\n\t    \/\/ The word may replace more than \"su_badlen\".\n\t    if (sug.su_badlen < stp->st_orglen)\n\t    {\n\t\tvim_snprintf((char *)IObuff, IOSIZE, _(\" < \\\"%.*s\\\"\"),\n\t\t\t\t\t       stp->st_orglen, sug.su_badptr);\n\t\tmsg_puts((char *)IObuff);\n\t    }\n\n\t    if (p_verbose > 0)\n\t    {\n\t\t\/\/ Add the score.\n\t\tif (sps_flags & (SPS_DOUBLE | SPS_BEST))\n\t\t    vim_snprintf((char *)IObuff, IOSIZE, \" (%s%d - %d)\",\n\t\t\tstp->st_salscore ? \"s \" : \"\",\n\t\t\tstp->st_score, stp->st_altscore);\n\t\telse\n\t\t    vim_snprintf((char *)IObuff, IOSIZE, \" (%d)\",\n\t\t\t    stp->st_score);\n#ifdef FEAT_RIGHTLEFT\n\t\tif (cmdmsg_rl)\n\t\t    \/\/ Mirror the numbers, but keep the leading space.\n\t\t    rl_mirror(IObuff + 1);\n#endif\n\t\tmsg_advance(30);\n\t\tmsg_puts((char *)IObuff);\n\t    }\n\t    msg_putchar('\\n');\n\t}\n\n#ifdef FEAT_RIGHTLEFT\n\tcmdmsg_rl = FALSE;\n\tmsg_col = 0;\n#endif\n\t\/\/ Ask for choice.\n\tselected = prompt_for_number(&mouse_used);\n\tif (mouse_used)\n\t    selected -= lines_left;\n\tlines_left = Rows;\t\t\/\/ avoid more prompt\n\t\/\/ don't delay for 'smd' in normal_cmd()\n\tmsg_scroll = msg_scroll_save;\n    }\n\n    if (selected > 0 && selected <= sug.su_ga.ga_len && u_save_cursor() == OK)\n    {\n\t\/\/ Save the from and to text for :spellrepall.\n\tVIM_CLEAR(repl_from);\n\tVIM_CLEAR(repl_to);\n\n\tstp = &SUG(sug.su_ga, selected - 1);\n\tif (sug.su_badlen > stp->st_orglen)\n\t{\n\t    \/\/ Replacing less than \"su_badlen\", append the remainder to\n\t    \/\/ repl_to.\n\t    repl_from = vim_strnsave(sug.su_badptr, sug.su_badlen);\n\t    vim_snprintf((char *)IObuff, IOSIZE, \"%s%.*s\", stp->st_word,\n\t\t    sug.su_badlen - stp->st_orglen,\n\t\t\t\t\t      sug.su_badptr + stp->st_orglen);\n\t    repl_to = vim_strsave(IObuff);\n\t}\n\telse\n\t{\n\t    \/\/ Replacing su_badlen or more, use the whole word.\n\t    repl_from = vim_strnsave(sug.su_badptr, stp->st_orglen);\n\t    repl_to = vim_strsave(stp->st_word);\n\t}\n\n\t\/\/ Replace the word.\n\tp = alloc(STRLEN(line) - stp->st_orglen + stp->st_wordlen + 1);\n\tif (p != NULL)\n\t{\n\t    c = (int)(sug.su_badptr - line);\n\t    mch_memmove(p, line, c);\n\t    STRCPY(p + c, stp->st_word);\n\t    STRCAT(p, sug.su_badptr + stp->st_orglen);\n\n\t    \/\/ For redo we use a change-word command.\n\t    ResetRedobuff();\n\t    AppendToRedobuff((char_u *)\"ciw\");\n\t    AppendToRedobuffLit(p + c,\n\t\t\t    stp->st_wordlen + sug.su_badlen - stp->st_orglen);\n\t    AppendCharToRedobuff(ESC);\n\n\t    \/\/ \"p\" may be freed here\n\t    ml_replace(curwin->w_cursor.lnum, p, FALSE);\n\t    curwin->w_cursor.col = c;\n\n\t    changed_bytes(curwin->w_cursor.lnum, c);\n\t}\n    }\n    else\n\tcurwin->w_cursor = prev_cursor;\n\n    spell_find_cleanup(&sug);\nskip:\n    vim_free(line);\n    curwin->w_p_spell = wo_spell_save;\n}","target":1,"code_token_length":2105,"total_token_length":2341,"max_tokens_setting":4096}
+{"idx":195022,"func":"int callback_glewlwyd_user_auth (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_result = NULL;\n  const char * ip_source = get_ip_source(request);\n  char * issued_for = get_client_hostname(request);\n  char * session_uid, expires[129];\n  time_t now;\n  struct tm ts;\n  \n  time(&now);\n  now += GLEWLWYD_DEFAULT_SESSION_EXPIRATION_COOKIE;\n  gmtime_r(&now, &ts);\n  strftime(expires, 128, \"%a, %d %b %Y %T %Z\", &ts);\n  if (j_param != NULL) {\n    if (json_string_length(json_object_get(j_param, \"username\"))) {\n      if (json_object_get(j_param, \"scheme_type\") == NULL || 0 == o_strcmp(json_string_value(json_object_get(j_param, \"scheme_type\")), \"password\")) {\n        if (json_string_length(json_object_get(j_param, \"password\"))) {\n          j_result = auth_check_user_credentials(config, json_string_value(json_object_get(j_param, \"username\")), json_string_value(json_object_get(j_param, \"password\")));\n          if (check_result_value(j_result, G_OK)) {\n            if ((session_uid = get_session_id(config, request)) == NULL) {\n              session_uid = generate_session_id();\n            }\n            if (user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), NULL, 1) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (1)\");\n              response->status = 500;\n            } else {\n              ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n              y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' authenticated with password\", json_string_value(json_object_get(j_param, \"username\")));\n            }\n            o_free(session_uid);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, \"scheme_type\", \"password\", NULL);\n          } else {\n            if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n              y_log_message(Y_LOG_LEVEL_WARNING, \"Security - Authorization invalid for username %s at IP Address %s\", json_string_value(json_object_get(j_param, \"username\")), ip_source);\n            }\n            if ((session_uid = get_session_id(config, request)) != NULL && user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), NULL, 1) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (2)\");\n            }\n            o_free(session_uid);\n            response->status = 401;\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, \"scheme_type\", \"password\", NULL);\n          }\n          json_decref(j_result);\n        } else if (json_object_get(j_param, \"password\") != NULL && !json_is_string(json_object_get(j_param, \"password\"))) {\n          ulfius_set_string_body_response(response, 400, \"password must be a string\");\n        } else {\n          session_uid = get_session_id(config, request);\n          j_result = get_users_for_session(config, session_uid);\n          if (check_result_value(j_result, G_OK)) {\n            \/\/ Refresh username to set as default\n            if (user_session_update(config, u_map_get(request->map_cookie, config->session_key), u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), NULL, 0) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (3)\");\n              response->status = 500;\n            } else {\n              ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n            }\n          } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) {\n            response->status = 401;\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error get_users_for_session\");\n            response->status = 500;\n          }\n          o_free(session_uid);\n          json_decref(j_result);\n        }\n      } else {\n        if (json_string_length(json_object_get(j_param, \"scheme_type\")) && json_string_length(json_object_get(j_param, \"scheme_name\")) && json_is_object(json_object_get(j_param, \"value\"))) {\n          j_result = auth_check_user_scheme(config, json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")), json_string_value(json_object_get(j_param, \"username\")), json_object_get(j_param, \"value\"), request);\n          if (check_result_value(j_result, G_ERROR_PARAM)) {\n            ulfius_set_string_body_response(response, 400, \"bad scheme response\");\n          } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n            y_log_message(Y_LOG_LEVEL_WARNING, \"Security - Authorization invalid for username %s at IP Address %s\", json_string_value(json_object_get(j_param, \"username\")), ip_source);\n            response->status = 401;\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, \"scheme_type\", json_string_value(json_object_get(j_param, \"scheme_type\")), \"scheme_name\", json_string_value(json_object_get(j_param, \"scheme_name\")), NULL);\n          } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) {\n            response->status = 404;\n          } else if (check_result_value(j_result, G_OK)) {\n            if ((session_uid = get_session_id(config, request)) == NULL) {\n              session_uid = generate_session_id();\n            }\n            if (user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), json_string_value(json_object_get(j_param, \"scheme_name\")), 1) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (4)\");\n              response->status = 500;\n            } else {\n              ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n              y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' authenticated with scheme '%s\/%s'\", json_string_value(json_object_get(j_param, \"username\")), json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")));\n            }\n            o_free(session_uid);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, \"scheme_type\", json_string_value(json_object_get(j_param, \"scheme_type\")), \"scheme_name\", json_string_value(json_object_get(j_param, \"scheme_name\")), NULL);\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error auth_check_user_scheme\");\n            response->status = 500;\n          }\n          json_decref(j_result);\n        } else {\n          ulfius_set_string_body_response(response, 400, \"scheme_type, scheme_name and value are mandatory\");\n        }\n      }\n    } else {\n      if (json_string_length(json_object_get(j_param, \"scheme_type\")) && json_string_length(json_object_get(j_param, \"scheme_name\")) && json_is_object(json_object_get(j_param, \"value\"))) {\n        j_result = auth_check_identify_scheme(config, json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")), json_object_get(j_param, \"value\"), request);\n        if (check_result_value(j_result, G_ERROR_PARAM)) {\n          ulfius_set_string_body_response(response, 400, \"bad scheme response\");\n        } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n          y_log_message(Y_LOG_LEVEL_WARNING, \"Security - Authorization invalid for username <UNKNOWN> at IP Address %s\", ip_source);\n          response->status = 401;\n        } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) {\n          response->status = 404;\n        } else if (check_result_value(j_result, G_OK)) {\n          if ((session_uid = get_session_id(config, request)) == NULL) {\n            session_uid = generate_session_id();\n          }\n          if (user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_result, \"username\")), json_string_value(json_object_get(j_param, \"scheme_name\")), 1) != G_OK) {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (4)\");\n            response->status = 500;\n          } else {\n            ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n            y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' authenticated with scheme '%s\/%s'\", json_string_value(json_object_get(j_result, \"username\")), json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")));\n          }\n          o_free(session_uid);\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error auth_check_user_scheme\");\n          response->status = 500;\n        }\n        json_decref(j_result);\n      } else {\n        ulfius_set_string_body_response(response, 400, \"username is mandatory\");\n      }\n    }\n  } else {\n    ulfius_set_string_body_response(response, 400, \"Input parameters must be in JSON format\");\n  }\n  json_decref(j_param);\n  o_free(issued_for);\n\n  return U_CALLBACK_CONTINUE;\n}","target":1,"code_token_length":2431,"total_token_length":2667,"max_tokens_setting":4096}
+{"idx":231532,"func":"__getcwd_generic (char *buf, size_t size)\n{\n  \/* Lengths of big file name components and entire file names, and a\n     deep level of file name nesting.  These numbers are not upper\n     bounds; they are merely large values suitable for initial\n     allocations, designed to be large enough for most real-world\n     uses.  *\/\n  enum\n    {\n      BIG_FILE_NAME_COMPONENT_LENGTH = 255,\n      BIG_FILE_NAME_LENGTH = MIN (4095, PATH_MAX - 1),\n      DEEP_NESTING = 100\n    };\n\n#if HAVE_OPENAT_SUPPORT\n  int fd = AT_FDCWD;\n  bool fd_needs_closing = false;\n#else\n  char dots[DEEP_NESTING * sizeof \"..\" + BIG_FILE_NAME_COMPONENT_LENGTH + 1];\n  char *dotlist = dots;\n  size_t dotsize = sizeof dots;\n  size_t dotlen = 0;\n#endif\n  DIR *dirstream = NULL;\n  dev_t rootdev, thisdev;\n  ino_t rootino, thisino;\n  char *dir;\n  register char *dirp;\n  struct __stat64_t64 st;\n  size_t allocated = size;\n  size_t used;\n\n  \/* A size of 1 byte is never useful.  *\/\n  if (allocated == 1)\n    {\n      __set_errno (ERANGE);\n      return NULL;\n    }\n\n#if HAVE_MINIMALLY_WORKING_GETCWD\n  \/* If AT_FDCWD is not defined, the algorithm below is O(N**2) and\n     this is much slower than the system getcwd (at least on\n     GNU\/Linux).  So trust the system getcwd's results unless they\n     look suspicious.\n\n     Use the system getcwd even if we have openat support, since the\n     system getcwd works even when a parent is unreadable, while the\n     openat-based approach does not.\n\n     But on AIX 5.1..7.1, the system getcwd is not even minimally\n     working: If the current directory name is slightly longer than\n     PATH_MAX, it omits the first directory component and returns\n     this wrong result with errno = 0.  *\/\n\n# undef getcwd\n  dir = getcwd_system (buf, size);\n  if (dir || (size && errno == ERANGE))\n    return dir;\n\n  \/* Solaris getcwd (NULL, 0) fails with errno == EINVAL, but it has\n     internal magic that lets it work even if an ancestor directory is\n     inaccessible, which is better in many cases.  So in this case try\n     again with a buffer that's almost always big enough.  *\/\n  if (errno == EINVAL && buf == NULL && size == 0)\n    {\n      char big_buffer[BIG_FILE_NAME_LENGTH + 1];\n      dir = getcwd_system (big_buffer, sizeof big_buffer);\n      if (dir)\n        return strdup (dir);\n    }\n\n# if HAVE_PARTLY_WORKING_GETCWD\n  \/* The system getcwd works, except it sometimes fails when it\n     shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT.    *\/\n  if (errno != ERANGE && errno != ENAMETOOLONG && errno != ENOENT)\n    return NULL;\n# endif\n#endif\n  if (size == 0)\n    {\n      if (buf != NULL)\n        {\n          __set_errno (EINVAL);\n          return NULL;\n        }\n\n      allocated = BIG_FILE_NAME_LENGTH + 1;\n    }\n\n  if (buf == NULL)\n    {\n      dir = malloc (allocated);\n      if (dir == NULL)\n        return NULL;\n    }\n  else\n    dir = buf;\n\n  dirp = dir + allocated;\n  *--dirp = '\\0';\n\n  if (__lstat64_time64 (\".\", &st) < 0)\n    goto lose;\n  thisdev = st.st_dev;\n  thisino = st.st_ino;\n\n  if (__lstat64_time64 (\"\/\", &st) < 0)\n    goto lose;\n  rootdev = st.st_dev;\n  rootino = st.st_ino;\n\n  while (!(thisdev == rootdev && thisino == rootino))\n    {\n      struct dirent64 *d;\n      dev_t dotdev;\n      ino_t dotino;\n      bool mount_point;\n      int parent_status;\n      size_t dirroom;\n      size_t namlen;\n      bool use_d_ino = true;\n\n      \/* Look at the parent directory.  *\/\n#if HAVE_OPENAT_SUPPORT\n      fd = __openat64 (fd, \"..\", O_RDONLY);\n      if (fd < 0)\n        goto lose;\n      fd_needs_closing = true;\n      parent_status = __fstat64_time64 (fd, &st);\n#else\n      dotlist[dotlen++] = '.';\n      dotlist[dotlen++] = '.';\n      dotlist[dotlen] = '\\0';\n      parent_status = __lstat64_time64 (dotlist, &st);\n#endif\n      if (parent_status != 0)\n        goto lose;\n\n      if (dirstream && __closedir (dirstream) != 0)\n        {\n          dirstream = NULL;\n          goto lose;\n        }\n\n      \/* Figure out if this directory is a mount point.  *\/\n      dotdev = st.st_dev;\n      dotino = st.st_ino;\n      mount_point = dotdev != thisdev;\n\n      \/* Search for the last directory.  *\/\n#if HAVE_OPENAT_SUPPORT\n      dirstream = __fdopendir (fd);\n      if (dirstream == NULL)\n        goto lose;\n      fd_needs_closing = false;\n#else\n      dirstream = __opendir (dotlist);\n      if (dirstream == NULL)\n        goto lose;\n      dotlist[dotlen++] = '\/';\n#endif\n      for (;;)\n        {\n          \/* Clear errno to distinguish EOF from error if readdir returns\n             NULL.  *\/\n          __set_errno (0);\n          d = __readdir64 (dirstream);\n\n          \/* When we've iterated through all directory entries without finding\n             one with a matching d_ino, rewind the stream and consider each\n             name again, but this time, using lstat.  This is necessary in a\n             chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where\n             .., ..\/.., ..\/..\/.., etc. all had the same device number, yet the\n             d_ino values for entries in \/ did not match those obtained\n             via lstat.  *\/\n          if (d == NULL && errno == 0 && use_d_ino)\n            {\n              use_d_ino = false;\n              __rewinddir (dirstream);\n              d = __readdir64 (dirstream);\n            }\n\n          if (d == NULL)\n            {\n              if (errno == 0)\n                \/* EOF on dirstream, which can mean e.g., that the current\n                   directory has been removed.  *\/\n                __set_errno (ENOENT);\n              goto lose;\n            }\n          if (d->d_name[0] == '.' &&\n              (d->d_name[1] == '\\0' ||\n               (d->d_name[1] == '.' && d->d_name[2] == '\\0')))\n            continue;\n\n          if (use_d_ino)\n            {\n              bool match = (MATCHING_INO (d, thisino) || mount_point);\n              if (! match)\n                continue;\n            }\n\n          {\n            int entry_status;\n#if HAVE_OPENAT_SUPPORT\n            entry_status = __fstatat64_time64 (fd, d->d_name, &st,\n\t\t\t\t\t       AT_SYMLINK_NOFOLLOW);\n#else\n            \/* Compute size needed for this file name, or for the file\n               name \"..\" in the same directory, whichever is larger.\n               Room for \"..\" might be needed the next time through\n               the outer loop.  *\/\n            size_t name_alloc = _D_ALLOC_NAMLEN (d);\n            size_t filesize = dotlen + MAX (sizeof \"..\", name_alloc);\n\n            if (filesize < dotlen)\n              goto memory_exhausted;\n\n            if (dotsize < filesize)\n              {\n                \/* My, what a deep directory tree you have, Grandma.  *\/\n                size_t newsize = MAX (filesize, dotsize * 2);\n                size_t i;\n                if (newsize < dotsize)\n                  goto memory_exhausted;\n                if (dotlist != dots)\n                  free (dotlist);\n                dotlist = malloc (newsize);\n                if (dotlist == NULL)\n                  goto lose;\n                dotsize = newsize;\n\n                i = 0;\n                do\n                  {\n                    dotlist[i++] = '.';\n                    dotlist[i++] = '.';\n                    dotlist[i++] = '\/';\n                  }\n                while (i < dotlen);\n              }\n\n            memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d));\n            entry_status = __lstat64_time64 (dotlist, &st);\n#endif\n            \/* We don't fail here if we cannot stat() a directory entry.\n               This can happen when (network) file systems fail.  If this\n               entry is in fact the one we are looking for we will find\n               out soon as we reach the end of the directory without\n               having found anything.  *\/\n            if (entry_status == 0 && S_ISDIR (st.st_mode)\n                && st.st_dev == thisdev && st.st_ino == thisino)\n              break;\n          }\n        }\n\n      dirroom = dirp - dir;\n      namlen = _D_EXACT_NAMLEN (d);\n\n      if (dirroom <= namlen)\n        {\n          if (size != 0)\n            {\n              __set_errno (ERANGE);\n              goto lose;\n            }\n          else\n            {\n              char *tmp;\n              size_t oldsize = allocated;\n\n              allocated += MAX (allocated, namlen);\n              if (allocated < oldsize\n                  || ! (tmp = realloc (dir, allocated)))\n                goto memory_exhausted;\n\n              \/* Move current contents up to the end of the buffer.\n                 This is guaranteed to be non-overlapping.  *\/\n              dirp = memcpy (tmp + allocated - (oldsize - dirroom),\n                             tmp + dirroom,\n                             oldsize - dirroom);\n              dir = tmp;\n            }\n        }\n      dirp -= namlen;\n      memcpy (dirp, d->d_name, namlen);\n      *--dirp = '\/';\n\n      thisdev = dotdev;\n      thisino = dotino;\n    }\n\n  if (dirstream && __closedir (dirstream) != 0)\n    {\n      dirstream = NULL;\n      goto lose;\n    }\n\n  if (dirp == &dir[allocated - 1])\n    *--dirp = '\/';\n\n#if ! HAVE_OPENAT_SUPPORT\n  if (dotlist != dots)\n    free (dotlist);\n#endif\n\n  used = dir + allocated - dirp;\n  memmove (dir, dirp, used);\n\n  if (size == 0)\n    \/* Ensure that the buffer is only as large as necessary.  *\/\n    buf = (used < allocated ? realloc (dir, used) : dir);\n\n  if (buf == NULL)\n    \/* Either buf was NULL all along, or 'realloc' failed but\n       we still have the original string.  *\/\n    buf = dir;\n\n  return buf;\n\n memory_exhausted:\n  __set_errno (ENOMEM);\n lose:\n  {\n    int save = errno;\n    if (dirstream)\n      __closedir (dirstream);\n#if HAVE_OPENAT_SUPPORT\n    if (fd_needs_closing)\n       __close_nocancel_nostatus (fd);\n#else\n    if (dotlist != dots)\n      free (dotlist);\n#endif\n    if (buf == NULL)\n      free (dir);\n    __set_errno (save);\n  }\n  return NULL;\n}","target":0,"code_token_length":2585,"total_token_length":2821,"max_tokens_setting":4096}
+{"idx":247627,"func":"void testUtil(const TestUtilOptions& options) {\n  Event::SimulatedTimeSystem time_system;\n\n  Stats::TestUtil::TestStore server_stats_store;\n  Api::ApiPtr server_api = Api::createApiForTest(server_stats_store, time_system);\n  NiceMock<Runtime::MockLoader> runtime;\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>\n      server_factory_context;\n  ON_CALL(server_factory_context, api()).WillByDefault(ReturnRef(*server_api));\n\n  \/\/ For private key method testing.\n  NiceMock<Ssl::MockContextManager> context_manager;\n  Extensions::PrivateKeyMethodProvider::TestPrivateKeyMethodFactory test_factory;\n  Registry::InjectFactory<Ssl::PrivateKeyMethodProviderInstanceFactory>\n      test_private_key_method_factory(test_factory);\n  PrivateKeyMethodManagerImpl private_key_method_manager;\n  if (options.expectedPrivateKeyMethod()) {\n    EXPECT_CALL(server_factory_context, sslContextManager())\n        .WillOnce(ReturnRef(context_manager))\n        .WillRepeatedly(ReturnRef(context_manager));\n    EXPECT_CALL(context_manager, privateKeyMethodManager())\n        .WillOnce(ReturnRef(private_key_method_manager))\n        .WillRepeatedly(ReturnRef(private_key_method_manager));\n  }\n\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext server_tls_context;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(options.serverCtxYaml()),\n                            server_tls_context);\n  auto server_cfg =\n      std::make_unique<ServerContextConfigImpl>(server_tls_context, server_factory_context);\n  ContextManagerImpl manager(*time_system);\n  ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager,\n                                                   server_stats_store, std::vector<std::string>{});\n\n  Event::DispatcherPtr dispatcher = server_api->allocateDispatcher(\"test_thread\");\n  auto socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(\n      Network::Test::getCanonicalLoopbackAddress(options.version()));\n  Network::MockTcpListenerCallbacks callbacks;\n  Network::ListenerPtr listener =\n      dispatcher->createListener(socket, callbacks, runtime, true, false);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client_tls_context;\n  TestUtility::loadFromYaml(TestEnvironment::substitute(options.clientCtxYaml()),\n                            client_tls_context);\n\n  Stats::TestUtil::TestStore client_stats_store;\n  Api::ApiPtr client_api = Api::createApiForTest(client_stats_store, time_system);\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>\n      client_factory_context;\n  ON_CALL(client_factory_context, api()).WillByDefault(ReturnRef(*client_api));\n\n  auto client_cfg =\n      std::make_unique<ClientContextConfigImpl>(client_tls_context, client_factory_context);\n  ClientSslSocketFactory client_ssl_socket_factory(std::move(client_cfg), manager,\n                                                   client_stats_store);\n  Network::ClientConnectionPtr client_connection = dispatcher->createClientConnection(\n      socket->connectionInfoProvider().localAddress(), Network::Address::InstanceConstSharedPtr(),\n      client_ssl_socket_factory.createTransportSocket(nullptr), nullptr);\n  Network::ConnectionPtr server_connection;\n  Network::MockConnectionCallbacks server_connection_callbacks;\n  NiceMock<StreamInfo::MockStreamInfo> stream_info;\n  EXPECT_CALL(callbacks, onAccept_(_))\n      .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {\n        auto ssl_socket = server_ssl_socket_factory.createTransportSocket(nullptr);\n        \/\/ configureInitialCongestionWindow is an unimplemented empty function, this is just to\n        \/\/ increase code coverage.\n        ssl_socket->configureInitialCongestionWindow(100, std::chrono::microseconds(123));\n        server_connection = dispatcher->createServerConnection(std::move(socket),\n                                                               std::move(ssl_socket), stream_info);\n        server_connection->addConnectionCallbacks(server_connection_callbacks);\n      }));\n\n  if (options.ocspStaplingEnabled()) {\n    const SslHandshakerImpl* ssl_socket =\n        dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());\n    SSL_enable_ocsp_stapling(ssl_socket->ssl());\n  }\n\n  Network::MockConnectionCallbacks client_connection_callbacks;\n  client_connection->addConnectionCallbacks(client_connection_callbacks);\n  client_connection->connect();\n\n  size_t connect_count = 0;\n  auto connect_second_time = [&]() {\n    if (++connect_count == 2) {\n      if (!options.expectedSha256Digest().empty()) {\n        \/\/ Assert twice to ensure a cached value is returned and still valid.\n        EXPECT_EQ(options.expectedSha256Digest(),\n                  server_connection->ssl()->sha256PeerCertificateDigest());\n        EXPECT_EQ(options.expectedSha256Digest(),\n                  server_connection->ssl()->sha256PeerCertificateDigest());\n      }\n      if (!options.expectedSha1Digest().empty()) {\n        \/\/ Assert twice to ensure a cached value is returned and still valid.\n        EXPECT_EQ(options.expectedSha1Digest(),\n                  server_connection->ssl()->sha1PeerCertificateDigest());\n        EXPECT_EQ(options.expectedSha1Digest(),\n                  server_connection->ssl()->sha1PeerCertificateDigest());\n      }\n      \/\/ Assert twice to ensure a cached value is returned and still valid.\n      EXPECT_EQ(options.expectedClientCertUri(), server_connection->ssl()->uriSanPeerCertificate());\n      EXPECT_EQ(options.expectedClientCertUri(), server_connection->ssl()->uriSanPeerCertificate());\n\n      if (!options.expectedLocalUri().empty()) {\n        \/\/ Assert twice to ensure a cached value is returned and still valid.\n        EXPECT_EQ(options.expectedLocalUri(), server_connection->ssl()->uriSanLocalCertificate());\n        EXPECT_EQ(options.expectedLocalUri(), server_connection->ssl()->uriSanLocalCertificate());\n      }\n      EXPECT_EQ(options.expectedSerialNumber(),\n                server_connection->ssl()->serialNumberPeerCertificate());\n      if (!options.expectedPeerIssuer().empty()) {\n        EXPECT_EQ(options.expectedPeerIssuer(), server_connection->ssl()->issuerPeerCertificate());\n      }\n      if (!options.expectedPeerSubject().empty()) {\n        EXPECT_EQ(options.expectedPeerSubject(),\n                  server_connection->ssl()->subjectPeerCertificate());\n      }\n      if (!options.expectedLocalSubject().empty()) {\n        EXPECT_EQ(options.expectedLocalSubject(),\n                  server_connection->ssl()->subjectLocalCertificate());\n      }\n      if (!options.expectedPeerCert().empty()) {\n        std::string urlencoded = absl::StrReplaceAll(\n            options.expectedPeerCert(),\n            {{\"\\r\", \"\"}, {\"\\n\", \"%0A\"}, {\" \", \"%20\"}, {\"+\", \"%2B\"}, {\"\/\", \"%2F\"}, {\"=\", \"%3D\"}});\n        \/\/ Assert twice to ensure a cached value is returned and still valid.\n        EXPECT_EQ(urlencoded, server_connection->ssl()->urlEncodedPemEncodedPeerCertificate());\n        EXPECT_EQ(urlencoded, server_connection->ssl()->urlEncodedPemEncodedPeerCertificate());\n      }\n      if (!options.expectedPeerCertChain().empty()) {\n        std::string cert_chain = absl::StrReplaceAll(\n            options.expectedPeerCertChain(),\n            {{\"\\r\", \"\"}, {\"\\n\", \"%0A\"}, {\" \", \"%20\"}, {\"+\", \"%2B\"}, {\"\/\", \"%2F\"}, {\"=\", \"%3D\"}});\n        \/\/ Assert twice to ensure a cached value is returned and still valid.\n        EXPECT_EQ(cert_chain, server_connection->ssl()->urlEncodedPemEncodedPeerCertificateChain());\n        EXPECT_EQ(cert_chain, server_connection->ssl()->urlEncodedPemEncodedPeerCertificateChain());\n      }\n      if (!options.expectedValidFromTimePeerCert().empty()) {\n        const std::string formatted = TestUtility::formatTime(\n            server_connection->ssl()->validFromPeerCertificate().value(), \"%b %e %H:%M:%S %Y GMT\");\n        EXPECT_EQ(options.expectedValidFromTimePeerCert(), formatted);\n      }\n      if (!options.expectedExpirationTimePeerCert().empty()) {\n        const std::string formatted = TestUtility::formatTime(\n            server_connection->ssl()->expirationPeerCertificate().value(), \"%b %e %H:%M:%S %Y GMT\");\n        EXPECT_EQ(options.expectedExpirationTimePeerCert(), formatted);\n      }\n      if (options.expectNoCert()) {\n        EXPECT_FALSE(server_connection->ssl()->peerCertificatePresented());\n        EXPECT_FALSE(server_connection->ssl()->validFromPeerCertificate().has_value());\n        EXPECT_FALSE(server_connection->ssl()->expirationPeerCertificate().has_value());\n        EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->sha256PeerCertificateDigest());\n        EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->sha1PeerCertificateDigest());\n        EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->urlEncodedPemEncodedPeerCertificate());\n        EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->subjectPeerCertificate());\n        EXPECT_EQ(std::vector<std::string>{}, server_connection->ssl()->dnsSansPeerCertificate());\n      }\n      if (options.expectNoCertChain()) {\n        EXPECT_EQ(EMPTY_STRING,\n                  server_connection->ssl()->urlEncodedPemEncodedPeerCertificateChain());\n      }\n\n      const SslHandshakerImpl* ssl_socket =\n          dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());\n      SSL* client_ssl_socket = ssl_socket->ssl();\n      const uint8_t* response_head;\n      size_t response_len;\n      SSL_get0_ocsp_response(client_ssl_socket, &response_head, &response_len);\n      std::string ocsp_response{reinterpret_cast<const char*>(response_head), response_len};\n      EXPECT_EQ(options.expectedOcspResponse(), ocsp_response);\n\n      \/\/ By default, the session is not created with session resumption. The\n      \/\/ client should see a session ID but the server should not.\n      EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->sessionId());\n      EXPECT_NE(EMPTY_STRING, client_connection->ssl()->sessionId());\n\n      server_connection->close(Network::ConnectionCloseType::NoFlush);\n      client_connection->close(Network::ConnectionCloseType::NoFlush);\n      dispatcher->exit();\n    }\n  };\n\n  size_t close_count = 0;\n  auto close_second_time = [&close_count, &dispatcher]() {\n    if (++close_count == 2) {\n      dispatcher->exit();\n    }\n  };\n\n  if (options.expectSuccess()) {\n    EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { connect_second_time(); }));\n    EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { connect_second_time(); }));\n    EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));\n    EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));\n  } else {\n    EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::RemoteClose))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { close_second_time(); }));\n    EXPECT_CALL(server_connection_callbacks, onEvent(options.expectedServerCloseEvent()))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { close_second_time(); }));\n  }\n\n  if (options.expectedVerifyErrorCode() != -1) {\n    EXPECT_LOG_CONTAINS(\"debug\", X509_verify_cert_error_string(options.expectedVerifyErrorCode()),\n                        dispatcher->run(Event::Dispatcher::RunType::Block));\n  } else {\n    dispatcher->run(Event::Dispatcher::RunType::Block);\n  }\n\n  if (!options.expectedServerStats().empty()) {\n    EXPECT_EQ(1UL, server_stats_store.counter(options.expectedServerStats()).value());\n  }\n\n  if (!options.notExpectedClientStats().empty()) {\n    EXPECT_EQ(0, client_stats_store.counter(options.notExpectedClientStats()).value());\n  }\n\n  if (options.expectSuccess()) {\n    EXPECT_EQ(\"\", client_connection->transportFailureReason());\n    EXPECT_EQ(\"\", server_connection->transportFailureReason());\n  } else {\n    EXPECT_THAT(std::string(client_connection->transportFailureReason()),\n                ContainsRegex(options.expectedTransportFailureReasonContains()));\n    EXPECT_NE(\"\", server_connection->transportFailureReason());\n  }\n}","target":0,"code_token_length":2522,"total_token_length":2758,"max_tokens_setting":4096}
+{"idx":256435,"func":"static void parse_rtcp_report( pjmedia_rtcp_session *sess,\n\t\t\t       const void *pkt,\n\t\t\t       pj_size_t size)\n{\n    pjmedia_rtcp_common *common = (pjmedia_rtcp_common*) pkt;\n    const pjmedia_rtcp_rr *rr = NULL;\n    const pjmedia_rtcp_sr *sr = NULL;\n    pj_uint32_t last_loss, jitter_samp, jitter;\n\n    \/* Parse RTCP *\/\n    if (common->pt == RTCP_SR) {\n        if (sizeof (pjmedia_rtcp_common) + sizeof (pjmedia_rtcp_sr) > size) {\n\t    TRACE_((sess->name, \"Discarding RTCP SR due to truncated size \"\n\t    \t\t\t\"%d bytes\", size));\n            return;\n        }\n\tsr = (pjmedia_rtcp_sr*) (((char*)pkt) + sizeof(pjmedia_rtcp_common));\n\tif (common->count > 0 && size >= (sizeof(pjmedia_rtcp_sr_pkt))) {\n\t    rr = (pjmedia_rtcp_rr*)(((char*)pkt) + (sizeof(pjmedia_rtcp_common)\n\t\t\t\t    + sizeof(pjmedia_rtcp_sr)));\n\t}\n    } else if (common->pt == RTCP_RR && common->count > 0) {\n\tif (sizeof (pjmedia_rtcp_common) + sizeof (pjmedia_rtcp_rr) > size) {\n\t    TRACE_((sess->name, \"Discarding RTCP RR due to truncated size \"\n\t    \t\t\t\"%d bytes\", size));\n\t    return;\n\t}\n\trr = (pjmedia_rtcp_rr*)(((char*)pkt) + sizeof(pjmedia_rtcp_common));\n#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)\n    } else if (common->pt == RTCP_XR) {\n\tif (sess->xr_enabled)\n\t    pjmedia_rtcp_xr_rx_rtcp_xr(&sess->xr_session, pkt, size);\n\n\treturn;\n#endif\n    }\n\n\n    if (sr) {\n\t\/* Save LSR from NTP timestamp of RTCP packet *\/\n\tsess->rx_lsr = ((pj_ntohl(sr->ntp_sec) & 0x0000FFFF) << 16) | \n\t\t       ((pj_ntohl(sr->ntp_frac) >> 16) & 0xFFFF);\n\n\t\/* Calculate SR arrival time for DLSR *\/\n\tpj_get_timestamp(&sess->rx_lsr_time);\n\n\tTRACE_((sess->name, \"Rx RTCP SR: ntp_ts=%p\", \n\t\tsess->rx_lsr,\n\t\t(pj_uint32_t)(sess->rx_lsr_time.u64*65536\/sess->ts_freq.u64)));\n    }\n\n\n    \/* Nothing more to do if there's no RR packet *\/\n    if (rr == NULL)\n\treturn;\n\n\n    last_loss = sess->stat.tx.loss;\n\n    \/* Get packet loss *\/\n    sess->stat.tx.loss = (rr->total_lost_2 << 16) +\n\t\t\t (rr->total_lost_1 << 8) +\n\t\t\t  rr->total_lost_0;\n\n    TRACE_((sess->name, \"Rx RTCP RR: total_lost_2=%x, 1=%x, 0=%x, lost=%d\", \n\t    (int)rr->total_lost_2,\n\t    (int)rr->total_lost_1,\n\t    (int)rr->total_lost_0,\n\t    sess->stat.tx.loss));\n    \n    \/* We can't calculate the exact loss period for TX, so just give the\n     * best estimation.\n     *\/\n    if (sess->stat.tx.loss > last_loss) {\n\tunsigned period;\n\n\t\/* Loss period in msec *\/\n\tperiod = (sess->stat.tx.loss - last_loss) * sess->pkt_size *\n\t\t 1000 \/ sess->clock_rate;\n\n\t\/* Loss period in usec *\/\n\tperiod *= 1000;\n\n\t\/* Update loss period stat *\/\n\tpj_math_stat_update(&sess->stat.tx.loss_period, period);\n    }\n\n    \/* Get jitter value in usec *\/\n    jitter_samp = pj_ntohl(rr->jitter);\n    \/* Calculate jitter in usec, avoiding overflows *\/\n    if (jitter_samp <= 4294)\n\tjitter = jitter_samp * 1000000 \/ sess->clock_rate;\n    else {\n\tjitter = jitter_samp * 1000 \/ sess->clock_rate;\n\tjitter *= 1000;\n    }\n\n    \/* Update jitter statistics *\/\n    pj_math_stat_update(&sess->stat.tx.jitter, jitter);\n\n    \/* Can only calculate if LSR and DLSR is present in RR *\/\n    if (rr->lsr && rr->dlsr) {\n\tpj_uint32_t lsr, now, dlsr;\n\tpj_uint64_t eedelay;\n\tpjmedia_rtcp_ntp_rec ntp;\n\n\t\/* LSR is the middle 32bit of NTP. It has 1\/65536 second \n\t * resolution \n\t *\/\n\tlsr = pj_ntohl(rr->lsr);\n\n\t\/* DLSR is delay since LSR, also in 1\/65536 resolution *\/\n\tdlsr = pj_ntohl(rr->dlsr);\n\n\t\/* Get current time, and convert to 1\/65536 resolution *\/\n\tpjmedia_rtcp_get_ntp_time(sess, &ntp);\n\tnow = ((ntp.hi & 0xFFFF) << 16) + (ntp.lo >> 16);\n\n\t\/* End-to-end delay is (now-lsr-dlsr) *\/\n\teedelay = now - lsr - dlsr;\n\n\t\/* Convert end to end delay to usec (keeping the calculation in\n         * 64bit space)::\n\t *   sess->ee_delay = (eedelay * 1000) \/ 65536;\n\t *\/\n\tif (eedelay < 4294) {\n\t    eedelay = (eedelay * 1000000) >> 16;\n\t} else {\n\t    eedelay = (eedelay * 1000) >> 16;\n\t    eedelay *= 1000;\n\t}\n\n\tTRACE_((sess->name, \"Rx RTCP RR: lsr=%p, dlsr=%p (%d:%03dms), \"\n\t\t\t   \"now=%p, rtt=%p\",\n\t\tlsr, dlsr, dlsr\/65536, (dlsr%65536)*1000\/65536,\n\t\tnow, (pj_uint32_t)eedelay));\n\t\n\t\/* Only save calculation if \"now\" is greater than lsr, or\n\t * otherwise rtt will be invalid \n\t *\/\n\tif (now-dlsr >= lsr) {\n\t    unsigned rtt = (pj_uint32_t)eedelay;\n\t    \n\t    \/* Check that eedelay value really makes sense. \n\t     * We allow up to 30 seconds RTT!\n\t     *\/\n\t    if (eedelay > 30 * 1000 * 1000UL) {\n\n\t\tTRACE_((sess->name, \"RTT not making any sense, ignored..\"));\n\t\tgoto end_rtt_calc;\n\t    }\n\n#if defined(PJMEDIA_RTCP_NORMALIZE_FACTOR) && PJMEDIA_RTCP_NORMALIZE_FACTOR!=0\n\t    \/* \"Normalize\" rtt value that is exceptionally high. For such\n\t     * values, \"normalize\" the rtt to be PJMEDIA_RTCP_NORMALIZE_FACTOR\n\t     * times the average value.\n\t     *\/\n\t    if (rtt > ((unsigned)sess->stat.rtt.mean *\n\t\t       PJMEDIA_RTCP_NORMALIZE_FACTOR) && sess->stat.rtt.n!=0)\n\t    {\n\t\tunsigned orig_rtt = rtt;\n\t\trtt = sess->stat.rtt.mean * PJMEDIA_RTCP_NORMALIZE_FACTOR;\n\t\tPJ_LOG(5,(sess->name,\n\t\t\t  \"RTT value %d usec is normalized to %d usec\",\n\t\t\t  orig_rtt, rtt));\n\t    }\n#endif\n\t    TRACE_((sess->name, \"RTCP RTT is set to %d usec\", rtt));\n\n\t    \/* Update RTT stat *\/\n\t    pj_math_stat_update(&sess->stat.rtt, rtt);\n\n\t} else {\n\t    PJ_LOG(5, (sess->name, \"Internal RTCP NTP clock skew detected: \"\n\t\t\t\t   \"lsr=%p, now=%p, dlsr=%p (%d:%03dms), \"\n\t\t\t\t   \"diff=%d\",\n\t\t\t\t   lsr, now, dlsr, dlsr\/65536,\n\t\t\t\t   (dlsr%65536)*1000\/65536,\n\t\t\t\t   dlsr-(now-lsr)));\n\t}\n    }\n\nend_rtt_calc:\n\n    pj_gettimeofday(&sess->stat.tx.update);\n    sess->stat.tx.update_cnt++;\n}","target":0,"code_token_length":1924,"total_token_length":2160,"max_tokens_setting":4096}
+{"idx":211155,"func":"int tcp_emu(struct socket *so, struct mbuf *m)\n{\n    Slirp *slirp = so->slirp;\n    unsigned n1, n2, n3, n4, n5, n6;\n    char buff[257];\n    uint32_t laddr;\n    unsigned lport;\n    char *bptr;\n\n    DEBUG_CALL(\"tcp_emu\");\n    DEBUG_ARG(\"so = %p\", so);\n    DEBUG_ARG(\"m = %p\", m);\n\n    switch (so->so_emu) {\n        int x, i;\n\n        \/* TODO: IPv6 *\/\n    case EMU_IDENT:\n        \/*\n         * Identification protocol as per rfc-1413\n         *\/\n\n        {\n            struct socket *tmpso;\n            struct sockaddr_in addr;\n            socklen_t addrlen = sizeof(struct sockaddr_in);\n            char *eol = g_strstr_len(m->m_data, m->m_len, \"\\r\\n\");\n\n            if (!eol) {\n                return 1;\n            }\n\n            *eol = '\\0';\n            if (sscanf(m->m_data, \"%u%*[ ,]%u\", &n1, &n2) == 2) {\n                HTONS(n1);\n                HTONS(n2);\n                \/* n2 is the one on our host *\/\n                for (tmpso = slirp->tcb.so_next; tmpso != &slirp->tcb;\n                     tmpso = tmpso->so_next) {\n                    if (tmpso->so_laddr.s_addr == so->so_laddr.s_addr &&\n                        tmpso->so_lport == n2 &&\n                        tmpso->so_faddr.s_addr == so->so_faddr.s_addr &&\n                        tmpso->so_fport == n1) {\n                        if (getsockname(tmpso->s, (struct sockaddr *)&addr,\n                                        &addrlen) == 0)\n                            n2 = addr.sin_port;\n                        break;\n                    }\n                }\n                NTOHS(n1);\n                NTOHS(n2);\n                m_inc(m, snprintf(NULL, 0, \"%d,%d\\r\\n\", n1, n2) + 1);\n                m->m_len = snprintf(m->m_data, M_ROOM(m), \"%d,%d\\r\\n\", n1, n2);\n                assert(m->m_len < M_ROOM(m));\n            } else {\n                *eol = '\\r';\n            }\n\n            return 1;\n        }\n\n    case EMU_FTP: \/* ftp *\/\n        m_inc(m, m->m_len + 1);\n        *(m->m_data + m->m_len) = 0; \/* NUL terminate for strstr *\/\n        if ((bptr = (char *)strstr(m->m_data, \"ORT\")) != NULL) {\n            \/*\n             * Need to emulate the PORT command\n             *\/\n            x = sscanf(bptr, \"ORT %u,%u,%u,%u,%u,%u\\r\\n%256[^\\177]\", &n1, &n2,\n                       &n3, &n4, &n5, &n6, buff);\n            if (x < 6)\n                return 1;\n\n            laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));\n            lport = htons((n5 << 8) | (n6));\n\n            if ((so = tcp_listen(slirp, INADDR_ANY, 0, laddr, lport,\n                                 SS_FACCEPTONCE)) == NULL) {\n                return 1;\n            }\n            n6 = ntohs(so->so_fport);\n\n            n5 = (n6 >> 8) & 0xff;\n            n6 &= 0xff;\n\n            laddr = ntohl(so->so_faddr.s_addr);\n\n            n1 = ((laddr >> 24) & 0xff);\n            n2 = ((laddr >> 16) & 0xff);\n            n3 = ((laddr >> 8) & 0xff);\n            n4 = (laddr & 0xff);\n\n            m->m_len = bptr - m->m_data; \/* Adjust length *\/\n            m->m_len += snprintf(bptr, m->m_size - m->m_len,\n                                 \"ORT %d,%d,%d,%d,%d,%d\\r\\n%s\", n1, n2, n3, n4,\n                                 n5, n6, x == 7 ? buff : \"\");\n            return 1;\n        } else if ((bptr = (char *)strstr(m->m_data, \"27 Entering\")) != NULL) {\n            \/*\n             * Need to emulate the PASV response\n             *\/\n            x = sscanf(\n                bptr,\n                \"27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\\r\\n%256[^\\177]\",\n                &n1, &n2, &n3, &n4, &n5, &n6, buff);\n            if (x < 6)\n                return 1;\n\n            laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));\n            lport = htons((n5 << 8) | (n6));\n\n            if ((so = tcp_listen(slirp, INADDR_ANY, 0, laddr, lport,\n                                 SS_FACCEPTONCE)) == NULL) {\n                return 1;\n            }\n            n6 = ntohs(so->so_fport);\n\n            n5 = (n6 >> 8) & 0xff;\n            n6 &= 0xff;\n\n            laddr = ntohl(so->so_faddr.s_addr);\n\n            n1 = ((laddr >> 24) & 0xff);\n            n2 = ((laddr >> 16) & 0xff);\n            n3 = ((laddr >> 8) & 0xff);\n            n4 = (laddr & 0xff);\n\n            m->m_len = bptr - m->m_data; \/* Adjust length *\/\n            m->m_len +=\n                snprintf(bptr, m->m_size - m->m_len,\n                         \"27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\\r\\n%s\",\n                         n1, n2, n3, n4, n5, n6, x == 7 ? buff : \"\");\n\n            return 1;\n        }\n\n        return 1;\n\n    case EMU_KSH:\n        \/*\n         * The kshell (Kerberos rsh) and shell services both pass\n         * a local port port number to carry signals to the server\n         * and stderr to the client.  It is passed at the beginning\n         * of the connection as a NUL-terminated decimal ASCII string.\n         *\/\n        so->so_emu = 0;\n        for (lport = 0, i = 0; i < m->m_len - 1; ++i) {\n            if (m->m_data[i] < '0' || m->m_data[i] > '9')\n                return 1; \/* invalid number *\/\n            lport *= 10;\n            lport += m->m_data[i] - '0';\n        }\n        if (m->m_data[m->m_len - 1] == '\\0' && lport != 0 &&\n            (so = tcp_listen(slirp, INADDR_ANY, 0, so->so_laddr.s_addr,\n                             htons(lport), SS_FACCEPTONCE)) != NULL)\n            m->m_len =\n                snprintf(m->m_data, m->m_size, \"%d\", ntohs(so->so_fport)) + 1;\n        return 1;\n\n    case EMU_IRC:\n        \/*\n         * Need to emulate DCC CHAT, DCC SEND and DCC MOVE\n         *\/\n        m_inc(m, m->m_len + 1);\n        *(m->m_data + m->m_len) = 0; \/* NULL terminate the string for strstr *\/\n        if ((bptr = (char *)strstr(m->m_data, \"DCC\")) == NULL)\n            return 1;\n\n        \/* The %256s is for the broken mIRC *\/\n        if (sscanf(bptr, \"DCC CHAT %256s %u %u\", buff, &laddr, &lport) == 3) {\n            if ((so = tcp_listen(slirp, INADDR_ANY, 0, htonl(laddr),\n                                 htons(lport), SS_FACCEPTONCE)) == NULL) {\n                return 1;\n            }\n            m->m_len = bptr - m->m_data; \/* Adjust length *\/\n            m->m_len += snprintf(bptr, m->m_size, \"DCC CHAT chat %lu %u%c\\n\",\n                                 (unsigned long)ntohl(so->so_faddr.s_addr),\n                                 ntohs(so->so_fport), 1);\n        } else if (sscanf(bptr, \"DCC SEND %256s %u %u %u\", buff, &laddr, &lport,\n                          &n1) == 4) {\n            if ((so = tcp_listen(slirp, INADDR_ANY, 0, htonl(laddr),\n                                 htons(lport), SS_FACCEPTONCE)) == NULL) {\n                return 1;\n            }\n            m->m_len = bptr - m->m_data; \/* Adjust length *\/\n            m->m_len +=\n                snprintf(bptr, m->m_size, \"DCC SEND %s %lu %u %u%c\\n\", buff,\n                         (unsigned long)ntohl(so->so_faddr.s_addr),\n                         ntohs(so->so_fport), n1, 1);\n        } else if (sscanf(bptr, \"DCC MOVE %256s %u %u %u\", buff, &laddr, &lport,\n                          &n1) == 4) {\n            if ((so = tcp_listen(slirp, INADDR_ANY, 0, htonl(laddr),\n                                 htons(lport), SS_FACCEPTONCE)) == NULL) {\n                return 1;\n            }\n            m->m_len = bptr - m->m_data; \/* Adjust length *\/\n            m->m_len +=\n                snprintf(bptr, m->m_size, \"DCC MOVE %s %lu %u %u%c\\n\", buff,\n                         (unsigned long)ntohl(so->so_faddr.s_addr),\n                         ntohs(so->so_fport), n1, 1);\n        }\n        return 1;\n\n    case EMU_REALAUDIO:\n        \/*\n         * RealAudio emulation - JP. We must try to parse the incoming\n         * data and try to find the two characters that contain the\n         * port number. Then we redirect an udp port and replace the\n         * number with the real port we got.\n         *\n         * The 1.0 beta versions of the player are not supported\n         * any more.\n         *\n         * A typical packet for player version 1.0 (release version):\n         *\n         * 0000:50 4E 41 00 05\n         * 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 ........g.l.c..P\n         * 0010:4E 43 4C 49 45 4E 54 20 31 30 31 20 41 4C 50 48 NCLIENT 101 ALPH\n         * 0020:41 6C 00 00 52 00 17 72 61 66 69 6C 65 73 2F 76 Al..R..rafiles\/v\n         * 0030:6F 61 2F 65 6E 67 6C 69 73 68 5F 2E 72 61 79 42 oa\/english_.rayB\n         *\n         * Now the port number 0x1BD7 is found at offset 0x04 of the\n         * Now the port number 0x1BD7 is found at offset 0x04 of the\n         * second packet. This time we received five bytes first and\n         * then the rest. You never know how many bytes you get.\n         *\n         * A typical packet for player version 2.0 (beta):\n         *\n         * 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA.............\n         * 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .gux.c..Win2.0.0\n         * 0020:2E 35 6C 00 00 52 00 1C 72 61 66 69 6C 65 73 2F .5l..R..rafiles\/\n         * 0030:77 65 62 73 69 74 65 2F 32 30 72 65 6C 65 61 73 website\/20releas\n         * 0040:65 2E 72 61 79 53 00 00 06 36 42                e.rayS...6B\n         *\n         * Port number 0x1BC1 is found at offset 0x0d.\n         *\n         * This is just a horrible switch statement. Variable ra tells\n         * us where we're going.\n         *\/\n\n        bptr = m->m_data;\n        while (bptr < m->m_data + m->m_len) {\n            uint16_t p;\n            static int ra = 0;\n            char ra_tbl[4];\n\n            ra_tbl[0] = 0x50;\n            ra_tbl[1] = 0x4e;\n            ra_tbl[2] = 0x41;\n            ra_tbl[3] = 0;\n\n            switch (ra) {\n            case 0:\n            case 2:\n            case 3:\n                if (*bptr++ != ra_tbl[ra]) {\n                    ra = 0;\n                    continue;\n                }\n                break;\n\n            case 1:\n                \/*\n                 * We may get 0x50 several times, ignore them\n                 *\/\n                if (*bptr == 0x50) {\n                    ra = 1;\n                    bptr++;\n                    continue;\n                } else if (*bptr++ != ra_tbl[ra]) {\n                    ra = 0;\n                    continue;\n                }\n                break;\n\n            case 4:\n                \/*\n                 * skip version number\n                 *\/\n                bptr++;\n                break;\n\n            case 5:\n                \/*\n                 * The difference between versions 1.0 and\n                 * 2.0 is here. For future versions of\n                 * the player this may need to be modified.\n                 *\/\n                if (*(bptr + 1) == 0x02)\n                    bptr += 8;\n                else\n                    bptr += 4;\n                break;\n\n            case 6:\n                \/* This is the field containing the port\n                 * number that RA-player is listening to.\n                 *\/\n                lport = (((uint8_t *)bptr)[0] << 8) + ((uint8_t *)bptr)[1];\n                if (lport < 6970)\n                    lport += 256; \/* don't know why *\/\n                if (lport < 6970 || lport > 7170)\n                    return 1; \/* failed *\/\n\n                \/* try to get udp port between 6970 - 7170 *\/\n                for (p = 6970; p < 7071; p++) {\n                    if (udp_listen(slirp, INADDR_ANY, htons(p),\n                                   so->so_laddr.s_addr, htons(lport),\n                                   SS_FACCEPTONCE)) {\n                        break;\n                    }\n                }\n                if (p == 7071)\n                    p = 0;\n                *(uint8_t *)bptr++ = (p >> 8) & 0xff;\n                *(uint8_t *)bptr = p & 0xff;\n                ra = 0;\n                return 1; \/* port redirected, we're done *\/\n                break;\n\n            default:\n                ra = 0;\n            }\n            ra++;\n        }\n        return 1;\n\n    default:\n        \/* Ooops, not emulated, won't call tcp_emu again *\/\n        so->so_emu = 0;\n        return 1;\n    }\n}","target":1,"code_token_length":3767,"total_token_length":4003,"max_tokens_setting":4096}
+{"idx":434093,"func":"do_arg_all(\n    int\tcount,\n    int\tforceit,\t\t\/\/ hide buffers in current windows\n    int keep_tabs)\t\t\/\/ keep current tabs, for \":tab drop file\"\n{\n    int\t\ti;\n    win_T\t*wp, *wpnext;\n    char_u\t*opened;\t\/\/ Array of weight for which args are open:\n\t\t\t\t\/\/  0: not opened\n\t\t\t\t\/\/  1: opened in other tab\n\t\t\t\t\/\/  2: opened in curtab\n\t\t\t\t\/\/  3: opened in curtab and curwin\n\t\t\t\t\/\/\n    int\t\topened_len;\t\/\/ length of opened[]\n    int\t\tuse_firstwin = FALSE;\t\/\/ use first window for arglist\n    int\t\ttab_drop_empty_window = FALSE;\n    int\t\tsplit_ret = OK;\n    int\t\tp_ea_save;\n    alist_T\t*alist;\t\t\/\/ argument list to be used\n    buf_T\t*buf;\n    tabpage_T\t*tpnext;\n    int\t\thad_tab = cmdmod.cmod_tab;\n    win_T\t*old_curwin, *last_curwin;\n    tabpage_T\t*old_curtab, *last_curtab;\n    win_T\t*new_curwin = NULL;\n    tabpage_T\t*new_curtab = NULL;\n    int\t\tprev_arglist_locked = arglist_locked;\n\n#ifdef FEAT_CMDWIN\n    if (cmdwin_type != 0)\n    {\n\temsg(_(e_invalid_in_cmdline_window));\n\treturn;\n    }\n#endif\n    if (ARGCOUNT <= 0)\n    {\n\t\/\/ Don't give an error message.  We don't want it when the \":all\"\n\t\/\/ command is in the .vimrc.\n\treturn;\n    }\n    setpcmark();\n\n    opened_len = ARGCOUNT;\n    opened = alloc_clear(opened_len);\n    if (opened == NULL)\n\treturn;\n\n    \/\/ Autocommands may do anything to the argument list.  Make sure it's not\n    \/\/ freed while we are working here by \"locking\" it.  We still have to\n    \/\/ watch out for its size to be changed.\n    alist = curwin->w_alist;\n    ++alist->al_refcount;\n    arglist_locked = TRUE;\n\n    old_curwin = curwin;\n    old_curtab = curtab;\n\n# ifdef FEAT_GUI\n    need_mouse_correct = TRUE;\n# endif\n\n    \/\/ Try closing all windows that are not in the argument list.\n    \/\/ Also close windows that are not full width;\n    \/\/ When 'hidden' or \"forceit\" set the buffer becomes hidden.\n    \/\/ Windows that have a changed buffer and can't be hidden won't be closed.\n    \/\/ When the \":tab\" modifier was used do this for all tab pages.\n    if (had_tab > 0)\n\tgoto_tabpage_tp(first_tabpage, TRUE, TRUE);\n    for (;;)\n    {\n\ttpnext = curtab->tp_next;\n\tfor (wp = firstwin; wp != NULL; wp = wpnext)\n\t{\n\t    wpnext = wp->w_next;\n\t    buf = wp->w_buffer;\n\t    if (buf->b_ffname == NULL\n\t\t    || (!keep_tabs && (buf->b_nwindows > 1\n\t\t\t    || wp->w_width != Columns)))\n\t\ti = opened_len;\n\t    else\n\t    {\n\t\t\/\/ check if the buffer in this window is in the arglist\n\t\tfor (i = 0; i < opened_len; ++i)\n\t\t{\n\t\t    if (i < alist->al_ga.ga_len\n\t\t\t    && (AARGLIST(alist)[i].ae_fnum == buf->b_fnum\n\t\t\t\t|| fullpathcmp(alist_name(&AARGLIST(alist)[i]),\n\t\t\t\t\tbuf->b_ffname, TRUE, TRUE) & FPC_SAME))\n\t\t    {\n\t\t\tint weight = 1;\n\n\t\t\tif (old_curtab == curtab)\n\t\t\t{\n\t\t\t    ++weight;\n\t\t\t    if (old_curwin == wp)\n\t\t\t\t++weight;\n\t\t\t}\n\n\t\t\tif (weight > (int)opened[i])\n\t\t\t{\n\t\t\t    opened[i] = (char_u)weight;\n\t\t\t    if (i == 0)\n\t\t\t    {\n\t\t\t\tif (new_curwin != NULL)\n\t\t\t\t    new_curwin->w_arg_idx = opened_len;\n\t\t\t\tnew_curwin = wp;\n\t\t\t\tnew_curtab = curtab;\n\t\t\t    }\n\t\t\t}\n\t\t\telse if (keep_tabs)\n\t\t\t    i = opened_len;\n\n\t\t\tif (wp->w_alist != alist)\n\t\t\t{\n\t\t\t    \/\/ Use the current argument list for all windows\n\t\t\t    \/\/ containing a file from it.\n\t\t\t    alist_unlink(wp->w_alist);\n\t\t\t    wp->w_alist = alist;\n\t\t\t    ++wp->w_alist->al_refcount;\n\t\t\t}\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t    wp->w_arg_idx = i;\n\n\t    if (i == opened_len && !keep_tabs)\/\/ close this window\n\t    {\n\t\tif (buf_hide(buf) || forceit || buf->b_nwindows > 1\n\t\t\t\t\t\t\t|| !bufIsChanged(buf))\n\t\t{\n\t\t    \/\/ If the buffer was changed, and we would like to hide it,\n\t\t    \/\/ try autowriting.\n\t\t    if (!buf_hide(buf) && buf->b_nwindows <= 1\n\t\t\t\t\t\t\t && bufIsChanged(buf))\n\t\t    {\n\t\t\tbufref_T    bufref;\n\n\t\t\tset_bufref(&bufref, buf);\n\n\t\t\t(void)autowrite(buf, FALSE);\n\n\t\t\t\/\/ check if autocommands removed the window\n\t\t\tif (!win_valid(wp) || !bufref_valid(&bufref))\n\t\t\t{\n\t\t\t    wpnext = firstwin;\t\/\/ start all over...\n\t\t\t    continue;\n\t\t\t}\n\t\t    }\n\t\t    \/\/ don't close last window\n\t\t    if (ONE_WINDOW\n\t\t\t    && (first_tabpage->tp_next == NULL || !had_tab))\n\t\t\tuse_firstwin = TRUE;\n\t\t    else\n\t\t    {\n\t\t\twin_close(wp, !buf_hide(buf) && !bufIsChanged(buf));\n\n\t\t\t\/\/ check if autocommands removed the next window\n\t\t\tif (!win_valid(wpnext))\n\t\t\t    wpnext = firstwin;\t\/\/ start all over...\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n\t\/\/ Without the \":tab\" modifier only do the current tab page.\n\tif (had_tab == 0 || tpnext == NULL)\n\t    break;\n\n\t\/\/ check if autocommands removed the next tab page\n\tif (!valid_tabpage(tpnext))\n\t    tpnext = first_tabpage;\t\/\/ start all over...\n\n\tgoto_tabpage_tp(tpnext, TRUE, TRUE);\n    }\n\n    \/\/ Open a window for files in the argument list that don't have one.\n    \/\/ ARGCOUNT may change while doing this, because of autocommands.\n    if (count > opened_len || count <= 0)\n\tcount = opened_len;\n\n    \/\/ Don't execute Win\/Buf Enter\/Leave autocommands here.\n    ++autocmd_no_enter;\n    ++autocmd_no_leave;\n    last_curwin = curwin;\n    last_curtab = curtab;\n    win_enter(lastwin, FALSE);\n    \/\/ \":tab drop file\" should re-use an empty window to avoid \"--remote-tab\"\n    \/\/ leaving an empty tab page when executed locally.\n    if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1\n\t\t\t    && curbuf->b_ffname == NULL && !curbuf->b_changed)\n    {\n\tuse_firstwin = TRUE;\n\ttab_drop_empty_window = TRUE;\n    }\n\n    for (i = 0; i < count && !got_int; ++i)\n    {\n\tif (alist == &global_alist && i == global_alist.al_ga.ga_len - 1)\n\t    arg_had_last = TRUE;\n\tif (opened[i] > 0)\n\t{\n\t    \/\/ Move the already present window to below the current window\n\t    if (curwin->w_arg_idx != i)\n\t    {\n\t\tFOR_ALL_WINDOWS(wpnext)\n\t\t{\n\t\t    if (wpnext->w_arg_idx == i)\n\t\t    {\n\t\t\tif (keep_tabs)\n\t\t\t{\n\t\t\t    new_curwin = wpnext;\n\t\t\t    new_curtab = curtab;\n\t\t\t}\n\t\t\telse if (wpnext->w_frame->fr_parent\n\t\t\t\t\t\t != curwin->w_frame->fr_parent)\n\t\t\t{\n\t\t\t    emsg(_(\"E249: window layout changed unexpectedly\"));\n\t\t\t    i = count;\n\t\t\t    break;\n\t\t\t}\n\t\t\telse\n\t\t\t    win_move_after(wpnext, curwin);\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\telse if (split_ret == OK)\n\t{\n\t    \/\/ trigger events for tab drop\n\t    if (tab_drop_empty_window && i == count - 1)\n\t\t--autocmd_no_enter;\n\t    if (!use_firstwin)\t\t\/\/ split current window\n\t    {\n\t\tp_ea_save = p_ea;\n\t\tp_ea = TRUE;\t\t\/\/ use space from all windows\n\t\tsplit_ret = win_split(0, WSP_ROOM | WSP_BELOW);\n\t\tp_ea = p_ea_save;\n\t\tif (split_ret == FAIL)\n\t\t    continue;\n\t    }\n\t    else    \/\/ first window: do autocmd for leaving this buffer\n\t\t--autocmd_no_leave;\n\n\t    \/\/ edit file \"i\"\n\t    curwin->w_arg_idx = i;\n\t    if (i == 0)\n\t    {\n\t\tnew_curwin = curwin;\n\t\tnew_curtab = curtab;\n\t    }\n\t    (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL,\n\t\t      ECMD_ONE,\n\t\t      ((buf_hide(curwin->w_buffer)\n\t\t\t   || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)\n\t\t\t\t\t\t       + ECMD_OLDBUF, curwin);\n\t    if (tab_drop_empty_window && i == count - 1)\n\t\t++autocmd_no_enter;\n\t    if (use_firstwin)\n\t\t++autocmd_no_leave;\n\t    use_firstwin = FALSE;\n\t}\n\tui_breakcheck();\n\n\t\/\/ When \":tab\" was used open a new tab for a new window repeatedly.\n\tif (had_tab > 0 && tabpage_index(NULL) <= p_tpm)\n\t    cmdmod.cmod_tab = 9999;\n    }\n\n    \/\/ Remove the \"lock\" on the argument list.\n    alist_unlink(alist);\n    arglist_locked = prev_arglist_locked;\n\n    --autocmd_no_enter;\n\n    \/\/ restore last referenced tabpage's curwin\n    if (last_curtab != new_curtab)\n    {\n\tif (valid_tabpage(last_curtab))\n\t    goto_tabpage_tp(last_curtab, TRUE, TRUE);\n\tif (win_valid(last_curwin))\n\t    win_enter(last_curwin, FALSE);\n    }\n    \/\/ to window with first arg\n    if (valid_tabpage(new_curtab))\n\tgoto_tabpage_tp(new_curtab, TRUE, TRUE);\n    if (win_valid(new_curwin))\n\twin_enter(new_curwin, FALSE);\n\n    --autocmd_no_leave;\n    vim_free(opened);\n}","target":0,"code_token_length":2363,"total_token_length":2599,"max_tokens_setting":4096}
+{"idx":218808,"func":"MagickExport void XNoticeWidget(Display *display,XWindows *windows,\n  const char *reason,const char *description)\n{\n#define DismissButtonText  \"Dismiss\"\n#define Timeout  8\n\n  const char\n    *text;\n\n  int\n    x,\n    y;\n\n  Status\n    status;\n\n  time_t\n    timer;\n\n  unsigned int\n    height,\n    width;\n\n  size_t\n    state;\n\n  XEvent\n    event;\n\n  XFontStruct\n    *font_info;\n\n  XTextProperty\n    window_name;\n\n  XWidgetInfo\n    dismiss_info;\n\n  XWindowChanges\n    window_changes;\n\n  \/*\n    Determine Notice widget attributes.\n  *\/\n  assert(display != (Display *) NULL);\n  assert(windows != (XWindows *) NULL);\n  assert(reason != (char *) NULL);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",reason);\n  XDelay(display,SuspendTime << 3);  \/* avoid surpise with delay *\/\n  XSetCursorState(display,windows,MagickTrue);\n  XCheckRefreshWindows(display,windows);\n  font_info=windows->widget.font_info;\n  width=WidgetTextWidth(font_info,DismissButtonText);\n  text=GetLocaleExceptionMessage(XServerError,reason);\n  if (text != (char *) NULL)\n    if (WidgetTextWidth(font_info,(char *) text) > width)\n      width=WidgetTextWidth(font_info,(char *) text);\n  if (description != (char *) NULL)\n    {\n      text=GetLocaleExceptionMessage(XServerError,description);\n      if (text != (char *) NULL)\n        if (WidgetTextWidth(font_info,(char *) text) > width)\n          width=WidgetTextWidth(font_info,(char *) text);\n    }\n  height=(unsigned int) (font_info->ascent+font_info->descent);\n  \/*\n    Position Notice widget.\n  *\/\n  windows->widget.width=width+4*QuantumMargin;\n  windows->widget.min_width=width+QuantumMargin;\n  if (windows->widget.width < windows->widget.min_width)\n    windows->widget.width=windows->widget.min_width;\n  windows->widget.height=(unsigned int) (12*height);\n  windows->widget.min_height=(unsigned int) (7*height);\n  if (windows->widget.height < windows->widget.min_height)\n    windows->widget.height=windows->widget.min_height;\n  XConstrainWindowPosition(display,&windows->widget);\n  \/*\n    Map Notice widget.\n  *\/\n  (void) CopyMagickString(windows->widget.name,\"Notice\",MaxTextExtent);\n  status=XStringListToTextProperty(&windows->widget.name,1,&window_name);\n  if (status != False)\n    {\n      XSetWMName(display,windows->widget.id,&window_name);\n      XSetWMIconName(display,windows->widget.id,&window_name);\n      (void) XFree((void *) window_name.value);\n    }\n  window_changes.width=(int) windows->widget.width;\n  window_changes.height=(int) windows->widget.height;\n  window_changes.x=windows->widget.x;\n  window_changes.y=windows->widget.y;\n  (void) XReconfigureWMWindow(display,windows->widget.id,windows->widget.screen,\n    (unsigned int) (CWWidth | CWHeight | CWX | CWY),&window_changes);\n  (void) XMapRaised(display,windows->widget.id);\n  windows->widget.mapped=MagickFalse;\n  (void) XBell(display,0);\n  \/*\n    Respond to X events.\n  *\/\n  timer=GetMagickTime()+Timeout;\n  state=UpdateConfigurationState;\n  do\n  {\n    if (GetMagickTime() > timer)\n      break;\n    if (state & UpdateConfigurationState)\n      {\n        \/*\n          Initialize Dismiss button information.\n        *\/\n        XGetWidgetInfo(DismissButtonText,&dismiss_info);\n        dismiss_info.width=(unsigned int) QuantumMargin+\n          WidgetTextWidth(font_info,DismissButtonText);\n        dismiss_info.height=(unsigned int) ((3*height) >> 1);\n        dismiss_info.x=(int)\n          ((windows->widget.width >> 1)-(dismiss_info.width >> 1));\n        dismiss_info.y=(int)\n          (windows->widget.height-(dismiss_info.height << 1));\n        state&=(~UpdateConfigurationState);\n      }\n    if (state & RedrawWidgetState)\n      {\n        \/*\n          Redraw Notice widget.\n        *\/\n        width=WidgetTextWidth(font_info,(char *) reason);\n        x=(int) ((windows->widget.width >> 1)-(width >> 1));\n        y=(int) ((windows->widget.height >> 1)-(height << 1));\n        (void) XDrawString(display,windows->widget.id,\n          windows->widget.annotate_context,x,y,(char *) reason,Extent(reason));\n        if (description != (char *) NULL)\n          {\n            width=WidgetTextWidth(font_info,(char *) description);\n            x=(int) ((windows->widget.width >> 1)-(width >> 1));\n            y+=height;\n            (void) XDrawString(display,windows->widget.id,\n              windows->widget.annotate_context,x,y,(char *) description,\n              Extent(description));\n          }\n        XDrawBeveledButton(display,&windows->widget,&dismiss_info);\n        XHighlightWidget(display,&windows->widget,BorderOffset,BorderOffset);\n        state&=(~RedrawWidgetState);\n      }\n    \/*\n      Wait for next event.\n    *\/\n    if (XCheckIfEvent(display,&event,XScreenEvent,(char *) windows) == MagickFalse)\n      {\n        \/*\n          Do not block if delay > 0.\n        *\/\n        XDelay(display,SuspendTime << 2);\n        continue;\n      }\n    switch (event.type)\n    {\n      case ButtonPress:\n      {\n        if (MatteIsActive(dismiss_info,event.xbutton))\n          {\n            \/*\n              User pressed Dismiss button.\n            *\/\n            dismiss_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&dismiss_info);\n            break;\n          }\n        break;\n      }\n      case ButtonRelease:\n      {\n        if (windows->widget.mapped == MagickFalse)\n          break;\n        if (dismiss_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              if (MatteIsActive(dismiss_info,event.xbutton))\n                state|=ExitState;\n            dismiss_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&dismiss_info);\n          }\n        break;\n      }\n      case ClientMessage:\n      {\n        \/*\n          If client window delete message, exit.\n        *\/\n        if (event.xclient.message_type != windows->wm_protocols)\n          break;\n        if (*event.xclient.data.l == (int) windows->wm_take_focus)\n          {\n            (void) XSetInputFocus(display,event.xclient.window,RevertToParent,\n              (Time) event.xclient.data.l[1]);\n            break;\n          }\n        if (*event.xclient.data.l != (int) windows->wm_delete_window)\n          break;\n        if (event.xclient.window == windows->widget.id)\n          {\n            state|=ExitState;\n            break;\n          }\n        break;\n      }\n      case ConfigureNotify:\n      {\n        \/*\n          Update widget configuration.\n        *\/\n        if (event.xconfigure.window != windows->widget.id)\n          break;\n        if ((event.xconfigure.width == (int) windows->widget.width) &&\n            (event.xconfigure.height == (int) windows->widget.height))\n          break;\n        windows->widget.width=(unsigned int)\n          MagickMax(event.xconfigure.width,(int) windows->widget.min_width);\n        windows->widget.height=(unsigned int)\n          MagickMax(event.xconfigure.height,(int) windows->widget.min_height);\n        state|=UpdateConfigurationState;\n        break;\n      }\n      case EnterNotify:\n      {\n        if (event.xcrossing.window != windows->widget.id)\n          break;\n        state&=(~InactiveWidgetState);\n        break;\n      }\n      case Expose:\n      {\n        if (event.xexpose.window != windows->widget.id)\n          break;\n        if (event.xexpose.count != 0)\n          break;\n        state|=RedrawWidgetState;\n        break;\n      }\n      case KeyPress:\n      {\n        static char\n          command[MaxTextExtent];\n\n        static KeySym\n          key_symbol;\n\n        \/*\n          Respond to a user key press.\n        *\/\n        if (event.xkey.window != windows->widget.id)\n          break;\n        (void) XLookupString((XKeyEvent *) &event.xkey,command,\n          (int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);\n        if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))\n          {\n            dismiss_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&dismiss_info);\n            state|=ExitState;\n            break;\n          }\n        break;\n      }\n      case LeaveNotify:\n      {\n        if (event.xcrossing.window != windows->widget.id)\n          break;\n        state|=InactiveWidgetState;\n        break;\n      }\n      case MotionNotify:\n      {\n        \/*\n          Discard pending button motion events.\n        *\/\n        while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ;\n        if (state & InactiveWidgetState)\n          break;\n        if (dismiss_info.raised == MatteIsActive(dismiss_info,event.xmotion))\n          {\n            \/*\n              Dismiss button status changed.\n            *\/\n            dismiss_info.raised=\n              dismiss_info.raised == MagickFalse ? MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&dismiss_info);\n            break;\n          }\n        break;\n      }\n      default:\n        break;\n    }\n  } while ((state & ExitState) == 0);\n  XSetCursorState(display,windows,MagickFalse);\n  (void) XWithdrawWindow(display,windows->widget.id,windows->widget.screen);\n  XCheckRefreshWindows(display,windows);\n}","target":0,"code_token_length":2127,"total_token_length":2363,"max_tokens_setting":4096}
+{"idx":206625,"func":"raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,\n                                       raptor_xml_element* element,\n                                       int auto_empty)\n{\n  raptor_iostream* iostr = xml_writer->iostr;\n  raptor_namespace_stack *nstack = xml_writer->nstack;\n  int depth = xml_writer->depth;\n  int auto_indent = XML_WRITER_AUTO_INDENT(xml_writer);\n  struct nsd *nspace_declarations = NULL;\n  size_t nspace_declarations_count = 0;  \n  unsigned int i;\n\n  \/* max is 1 per element and 1 for each attribute + size of declared *\/\n  if(nstack) {\n    int nspace_max_count = element->attribute_count+1;\n    if(element->declared_nspaces)\n      nspace_max_count += raptor_sequence_size(element->declared_nspaces);\n    if(element->xml_language)\n      nspace_max_count++;\n\n    nspace_declarations = RAPTOR_CALLOC(struct nsd*, nspace_max_count,\n                                        sizeof(struct nsd));\n    if(!nspace_declarations)\n      return 1;\n  }\n\n  if(element->name->nspace) {\n    if(nstack && !raptor_namespaces_namespace_in_scope(nstack, element->name->nspace)) {\n      nspace_declarations[0].declaration=\n        raptor_namespace_format_as_xml(element->name->nspace,\n                                       &nspace_declarations[0].length);\n      if(!nspace_declarations[0].declaration)\n        goto error;\n      nspace_declarations[0].nspace = element->name->nspace;\n      nspace_declarations_count++;\n    }\n  }\n\n  if(nstack && element->attributes) {\n    for(i = 0; i < element->attribute_count; i++) {\n      \/* qname *\/\n      if(element->attributes[i]->nspace) {\n        \/* Check if we need a namespace declaration attribute *\/\n        if(nstack && \n           !raptor_namespaces_namespace_in_scope(nstack, element->attributes[i]->nspace) && element->attributes[i]->nspace != element->name->nspace) {\n          \/* not in scope and not same as element (so already going to be declared)*\/\n          unsigned int j;\n          int declare_me = 1;\n          \n          \/* check it wasn't an earlier declaration too *\/\n          for(j = 0; j < nspace_declarations_count; j++)\n            if(nspace_declarations[j].nspace == element->attributes[j]->nspace) {\n              declare_me = 0;\n              break;\n            }\n            \n          if(declare_me) {\n            nspace_declarations[nspace_declarations_count].declaration=\n              raptor_namespace_format_as_xml(element->attributes[i]->nspace,\n                                             &nspace_declarations[nspace_declarations_count].length);\n            if(!nspace_declarations[nspace_declarations_count].declaration)\n              goto error;\n            nspace_declarations[nspace_declarations_count].nspace = element->attributes[i]->nspace;\n            nspace_declarations_count++;\n          }\n        }\n      }\n\n      \/* Add the attribute + value *\/\n      nspace_declarations[nspace_declarations_count].declaration=\n        raptor_qname_format_as_xml(element->attributes[i],\n                                   &nspace_declarations[nspace_declarations_count].length);\n      if(!nspace_declarations[nspace_declarations_count].declaration)\n        goto error;\n      nspace_declarations[nspace_declarations_count].nspace = NULL;\n      nspace_declarations_count++;\n\n    }\n  }\n\n  if(nstack && element->declared_nspaces &&\n     raptor_sequence_size(element->declared_nspaces) > 0) {\n    for(i = 0; i< (unsigned int)raptor_sequence_size(element->declared_nspaces); i++) {\n      raptor_namespace* nspace = (raptor_namespace*)raptor_sequence_get_at(element->declared_nspaces, i);\n      unsigned int j;\n      int declare_me = 1;\n      \n      \/* check it wasn't an earlier declaration too *\/\n      for(j = 0; j < nspace_declarations_count; j++)\n        if(nspace_declarations[j].nspace == nspace) {\n          declare_me = 0;\n          break;\n        }\n      \n      if(declare_me) {\n        nspace_declarations[nspace_declarations_count].declaration=\n          raptor_namespace_format_as_xml(nspace,\n                                         &nspace_declarations[nspace_declarations_count].length);\n        if(!nspace_declarations[nspace_declarations_count].declaration)\n          goto error;\n        nspace_declarations[nspace_declarations_count].nspace = nspace;\n        nspace_declarations_count++;\n      }\n\n    }\n  }\n\n  if(nstack && element->xml_language) {\n    size_t lang_len = strlen(RAPTOR_GOOD_CAST(char*, element->xml_language));\n#define XML_LANG_PREFIX_LEN 10\n    size_t buf_length = XML_LANG_PREFIX_LEN + lang_len + 1;\n    unsigned char* buffer = RAPTOR_MALLOC(unsigned char*, buf_length + 1);\n    const char quote = '\\\"';\n    unsigned char* p;\n\n    memcpy(buffer, \"xml:lang=\\\"\", XML_LANG_PREFIX_LEN);\n    p = buffer + XML_LANG_PREFIX_LEN;\n    p += raptor_xml_escape_string(xml_writer->world,\n                                  element->xml_language, lang_len,\n                                  p, buf_length, quote);\n    *p++ = quote;\n    *p = '\\0';\n\n    nspace_declarations[nspace_declarations_count].declaration = buffer;\n    nspace_declarations[nspace_declarations_count].length = buf_length;\n    nspace_declarations[nspace_declarations_count].nspace = NULL;\n    nspace_declarations_count++;\n  }\n  \n\n  raptor_iostream_write_byte('<', iostr);\n\n  if(element->name->nspace && element->name->nspace->prefix_length > 0) {\n    raptor_iostream_counted_string_write((const char*)element->name->nspace->prefix, \n                                         element->name->nspace->prefix_length,\n                                         iostr);\n    raptor_iostream_write_byte(':', iostr);\n  }\n  raptor_iostream_counted_string_write((const char*)element->name->local_name,\n                                       element->name->local_name_length,\n                                       iostr);\n\n  \/* declare namespaces and attributes *\/\n  if(nspace_declarations_count) {\n    int need_indent = 0;\n    \n    \/* sort them into the canonical order *\/\n    qsort((void*)nspace_declarations, \n          nspace_declarations_count, sizeof(struct nsd),\n          raptor_xml_writer_nsd_compare);\n\n    \/* declare namespaces first *\/\n    for(i = 0; i < nspace_declarations_count; i++) {\n      if(!nspace_declarations[i].nspace)\n        continue;\n\n      if(auto_indent && need_indent) {\n        \/* indent attributes *\/\n        raptor_xml_writer_newline(xml_writer);\n        xml_writer->depth++;\n        raptor_xml_writer_indent(xml_writer);\n        xml_writer->depth--;\n      }\n      raptor_iostream_write_byte(' ', iostr);\n      raptor_iostream_counted_string_write((const char*)nspace_declarations[i].declaration,\n                                           nspace_declarations[i].length,\n                                           iostr);\n      RAPTOR_FREE(char*, nspace_declarations[i].declaration);\n      nspace_declarations[i].declaration = NULL;\n      need_indent = 1;\n      \n      if(raptor_namespace_stack_start_namespace(nstack,\n                                                (raptor_namespace*)nspace_declarations[i].nspace,\n                                                depth))\n        goto error;\n    }\n\n    \/* declare attributes *\/\n    for(i = 0; i < nspace_declarations_count; i++) {\n      if(nspace_declarations[i].nspace)\n        continue;\n\n      if(auto_indent && need_indent) {\n        \/* indent attributes *\/\n        raptor_xml_writer_newline(xml_writer);\n        xml_writer->depth++;\n        raptor_xml_writer_indent(xml_writer);\n        xml_writer->depth--;\n      }\n      raptor_iostream_write_byte(' ', iostr);\n      raptor_iostream_counted_string_write((const char*)nspace_declarations[i].declaration,\n                                           nspace_declarations[i].length,\n                                           iostr);\n      need_indent = 1;\n\n      RAPTOR_FREE(char*, nspace_declarations[i].declaration);\n      nspace_declarations[i].declaration = NULL;\n    }\n  }\n\n  if(!auto_empty)\n    raptor_iostream_write_byte('>', iostr);\n\n  if(nstack)\n    RAPTOR_FREE(stringarray, nspace_declarations);\n\n  return 0;\n\n  \/* Clean up nspace_declarations on error *\/\n  error:\n\n  for(i = 0; i < nspace_declarations_count; i++) {\n    if(nspace_declarations[i].declaration)\n      RAPTOR_FREE(char*, nspace_declarations[i].declaration);\n  }\n\n  RAPTOR_FREE(stringarray, nspace_declarations);\n\n  return 1;\n}","target":1,"code_token_length":1879,"total_token_length":2115,"max_tokens_setting":4096}
+{"idx":241313,"func":"mrb_init_class(mrb_state *mrb)\n{\n  struct RClass *bob;           \/* BasicObject *\/\n  struct RClass *obj;           \/* Object *\/\n  struct RClass *mod;           \/* Module *\/\n  struct RClass *cls;           \/* Class *\/\n\n  \/* boot class hierarchy *\/\n  bob = boot_defclass(mrb, 0);\n  obj = boot_defclass(mrb, bob); mrb->object_class = obj;\n  mod = boot_defclass(mrb, obj); mrb->module_class = mod;\/* obj -> mod *\/\n  cls = boot_defclass(mrb, mod); mrb->class_class = cls; \/* obj -> cls *\/\n  \/* fix-up loose ends *\/\n  bob->c = obj->c = mod->c = cls->c = cls;\n  make_metaclass(mrb, bob);\n  make_metaclass(mrb, obj);\n  make_metaclass(mrb, mod);\n  make_metaclass(mrb, cls);\n\n  \/* name basic classes *\/\n  mrb_define_const_id(mrb, bob, MRB_SYM(BasicObject), mrb_obj_value(bob));\n  mrb_define_const_id(mrb, obj, MRB_SYM(Object),      mrb_obj_value(obj));\n  mrb_define_const_id(mrb, obj, MRB_SYM(Module),      mrb_obj_value(mod));\n  mrb_define_const_id(mrb, obj, MRB_SYM(Class),       mrb_obj_value(cls));\n\n  \/* name each classes *\/\n  mrb_class_name_class(mrb, NULL, bob, MRB_SYM(BasicObject));\n  mrb_class_name_class(mrb, NULL, obj, MRB_SYM(Object)); \/* 15.2.1 *\/\n  mrb_class_name_class(mrb, NULL, mod, MRB_SYM(Module)); \/* 15.2.2 *\/\n  mrb_class_name_class(mrb, NULL, cls, MRB_SYM(Class));  \/* 15.2.3 *\/\n\n  mrb->proc_class = mrb_define_class(mrb, \"Proc\", mrb->object_class);  \/* 15.2.17 *\/\n  MRB_SET_INSTANCE_TT(mrb->proc_class, MRB_TT_PROC);\n\n  MRB_SET_INSTANCE_TT(cls, MRB_TT_CLASS);\n  mrb_define_method(mrb, bob, \"initialize\",              mrb_do_nothing,           MRB_ARGS_NONE());\n  mrb_define_method(mrb, bob, \"!\",                       mrb_bob_not,              MRB_ARGS_NONE());\n  mrb_define_method(mrb, bob, \"==\",                      mrb_obj_equal_m,          MRB_ARGS_REQ(1)); \/* 15.3.1.3.1  *\/\n  mrb_define_method(mrb, bob, \"__id__\",                  mrb_obj_id_m,             MRB_ARGS_NONE()); \/* 15.3.1.3.4  *\/\n  mrb_define_method(mrb, bob, \"__send__\",                mrb_f_send,               MRB_ARGS_REQ(1)|MRB_ARGS_REST()|MRB_ARGS_BLOCK());  \/* 15.3.1.3.5  *\/\n  mrb_define_method(mrb, bob, \"equal?\",                  mrb_obj_equal_m,          MRB_ARGS_REQ(1)); \/* 15.3.1.3.11 *\/\n  mrb_define_method(mrb, bob, \"instance_eval\",           mrb_obj_instance_eval,    MRB_ARGS_OPT(1)|MRB_ARGS_BLOCK());  \/* 15.3.1.3.18 *\/\n  mrb_define_method(mrb, bob, \"singleton_method_added\",  mrb_do_nothing,           MRB_ARGS_REQ(1));\n\n  mrb_define_class_method(mrb, cls, \"new\",               mrb_class_new_class,      MRB_ARGS_OPT(1)|MRB_ARGS_BLOCK());\n  mrb_define_method(mrb, cls, \"allocate\",                mrb_instance_alloc,       MRB_ARGS_NONE());\n  mrb_define_method(mrb, cls, \"superclass\",              mrb_class_superclass,     MRB_ARGS_NONE()); \/* 15.2.3.3.4 *\/\n  mrb_define_method(mrb, cls, \"initialize\",              mrb_class_initialize,     MRB_ARGS_OPT(1)); \/* 15.2.3.3.1 *\/\n  mrb_define_method(mrb, cls, \"inherited\",               mrb_do_nothing,           MRB_ARGS_REQ(1));\n\n  init_class_new(mrb, cls);\n\n  MRB_SET_INSTANCE_TT(mod, MRB_TT_MODULE);\n  mrb_define_method(mrb, mod, \"extend_object\",           mrb_mod_extend_object,    MRB_ARGS_REQ(1)); \/* 15.2.2.4.25 *\/\n  mrb_define_method(mrb, mod, \"extended\",                mrb_do_nothing,           MRB_ARGS_REQ(1)); \/* 15.2.2.4.26 *\/\n  mrb_define_method(mrb, mod, \"prepended\",               mrb_do_nothing,           MRB_ARGS_REQ(1));\n  mrb_define_method(mrb, mod, \"prepend_features\",        mrb_mod_prepend_features, MRB_ARGS_REQ(1));\n  mrb_define_method(mrb, mod, \"include?\",                mrb_mod_include_p,        MRB_ARGS_REQ(1)); \/* 15.2.2.4.28 *\/\n  mrb_define_method(mrb, mod, \"append_features\",         mrb_mod_append_features,  MRB_ARGS_REQ(1)); \/* 15.2.2.4.10 *\/\n  mrb_define_method(mrb, mod, \"class_eval\",              mrb_mod_module_eval,      MRB_ARGS_ANY());  \/* 15.2.2.4.15 *\/\n  mrb_define_method(mrb, mod, \"included\",                mrb_do_nothing,           MRB_ARGS_REQ(1)); \/* 15.2.2.4.29 *\/\n  mrb_define_method(mrb, mod, \"initialize\",              mrb_mod_initialize,       MRB_ARGS_NONE()); \/* 15.2.2.4.31 *\/\n  mrb_define_method(mrb, mod, \"module_eval\",             mrb_mod_module_eval,      MRB_ARGS_ANY());  \/* 15.2.2.4.35 *\/\n  mrb_define_method(mrb, mod, \"module_function\",         mrb_mod_module_function,  MRB_ARGS_ANY());\n  mrb_define_method(mrb, mod, \"private\",                 mrb_mod_dummy_visibility, MRB_ARGS_ANY());  \/* 15.2.2.4.36 *\/\n  mrb_define_method(mrb, mod, \"protected\",               mrb_mod_dummy_visibility, MRB_ARGS_ANY());  \/* 15.2.2.4.37 *\/\n  mrb_define_method(mrb, mod, \"public\",                  mrb_mod_dummy_visibility, MRB_ARGS_ANY());  \/* 15.2.2.4.38 *\/\n  mrb_define_method(mrb, mod, \"attr_reader\",             mrb_mod_attr_reader,      MRB_ARGS_ANY());  \/* 15.2.2.4.13 *\/\n  mrb_define_method(mrb, mod, \"attr_writer\",             mrb_mod_attr_writer,      MRB_ARGS_ANY());  \/* 15.2.2.4.14 *\/\n  mrb_define_method(mrb, mod, \"to_s\",                    mrb_mod_to_s,             MRB_ARGS_NONE());\n  mrb_define_method(mrb, mod, \"inspect\",                 mrb_mod_to_s,             MRB_ARGS_NONE());\n  mrb_define_method(mrb, mod, \"alias_method\",            mrb_mod_alias,            MRB_ARGS_ANY());  \/* 15.2.2.4.8 *\/\n  mrb_define_method(mrb, mod, \"ancestors\",               mrb_mod_ancestors,        MRB_ARGS_NONE()); \/* 15.2.2.4.9 *\/\n  mrb_define_method(mrb, mod, \"undef_method\",            mrb_mod_undef,            MRB_ARGS_ANY());  \/* 15.2.2.4.41 *\/\n  mrb_define_method(mrb, mod, \"const_defined?\",          mrb_mod_const_defined,    MRB_ARGS_ARG(1,1)); \/* 15.2.2.4.20 *\/\n  mrb_define_method(mrb, mod, \"const_get\",               mrb_mod_const_get,        MRB_ARGS_REQ(1)); \/* 15.2.2.4.21 *\/\n  mrb_define_method(mrb, mod, \"const_set\",               mrb_mod_const_set,        MRB_ARGS_REQ(2)); \/* 15.2.2.4.23 *\/\n  mrb_define_method(mrb, mod, \"remove_const\",            mrb_mod_remove_const,     MRB_ARGS_REQ(1)); \/* 15.2.2.4.40 *\/\n  mrb_define_method(mrb, mod, \"const_missing\",           mrb_mod_const_missing,    MRB_ARGS_REQ(1));\n  mrb_define_method(mrb, mod, \"method_defined?\",         mrb_mod_method_defined,   MRB_ARGS_REQ(1)); \/* 15.2.2.4.34 *\/\n  mrb_define_method(mrb, mod, \"define_method\",           mod_define_method,        MRB_ARGS_ARG(1,1));\n  mrb_define_method(mrb, mod, \"===\",                     mrb_mod_eqq,              MRB_ARGS_REQ(1)); \/* 15.2.2.4.7 *\/\n  mrb_define_method(mrb, mod, \"dup\",                     mrb_mod_dup,              MRB_ARGS_NONE());\n  mrb_define_method(mrb, bob, \"method_added\",            mrb_do_nothing,           MRB_ARGS_REQ(1));\n\n  mrb_undef_method(mrb, cls, \"append_features\");\n  mrb_undef_method(mrb, cls, \"prepend_features\");\n  mrb_undef_method(mrb, cls, \"extend_object\");\n  mrb_undef_method(mrb, cls, \"module_function\");\n\n  mrb->top_self = MRB_OBJ_ALLOC(mrb, MRB_TT_OBJECT, mrb->object_class);\n  mrb_define_singleton_method(mrb, mrb->top_self, \"inspect\", inspect_main, MRB_ARGS_NONE());\n  mrb_define_singleton_method(mrb, mrb->top_self, \"to_s\", inspect_main, MRB_ARGS_NONE());\n  mrb_define_singleton_method(mrb, mrb->top_self, \"define_method\", top_define_method, MRB_ARGS_ARG(1,1));\n}","target":0,"code_token_length":2205,"total_token_length":2441,"max_tokens_setting":4096}
+{"idx":223411,"func":"static void compile_matchingpath(compiler_common *common, PCRE2_SPTR cc, PCRE2_SPTR ccend, backtrack_common *parent)\n{\nDEFINE_COMPILER;\nbacktrack_common *backtrack;\nBOOL has_then_trap = FALSE;\nthen_trap_backtrack *save_then_trap = NULL;\n\nSLJIT_ASSERT(*ccend == OP_END || (*ccend >= OP_ALT && *ccend <= OP_KETRPOS));\n\nif (common->has_then && common->then_offsets[cc - common->start] != 0)\n  {\n  SLJIT_ASSERT(*ccend != OP_END && common->control_head_ptr != 0);\n  has_then_trap = TRUE;\n  save_then_trap = common->then_trap;\n  \/* Tail item on backtrack. *\/\n  compile_then_trap_matchingpath(common, cc, ccend, parent);\n  }\n\nwhile (cc < ccend)\n  {\n  switch(*cc)\n    {\n    case OP_SOD:\n    case OP_SOM:\n    case OP_NOT_WORD_BOUNDARY:\n    case OP_WORD_BOUNDARY:\n    case OP_EODN:\n    case OP_EOD:\n    case OP_DOLL:\n    case OP_DOLLM:\n    case OP_CIRC:\n    case OP_CIRCM:\n    case OP_REVERSE:\n    cc = compile_simple_assertion_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);\n    break;\n\n    case OP_NOT_DIGIT:\n    case OP_DIGIT:\n    case OP_NOT_WHITESPACE:\n    case OP_WHITESPACE:\n    case OP_NOT_WORDCHAR:\n    case OP_WORDCHAR:\n    case OP_ANY:\n    case OP_ALLANY:\n    case OP_ANYBYTE:\n    case OP_NOTPROP:\n    case OP_PROP:\n    case OP_ANYNL:\n    case OP_NOT_HSPACE:\n    case OP_HSPACE:\n    case OP_NOT_VSPACE:\n    case OP_VSPACE:\n    case OP_EXTUNI:\n    case OP_NOT:\n    case OP_NOTI:\n    cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE);\n    break;\n\n    case OP_SET_SOM:\n    PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));\n    allocate_stack(common, 1);\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), STR_PTR, 0);\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);\n    cc++;\n    break;\n\n    case OP_CHAR:\n    case OP_CHARI:\n    if (common->mode == PCRE2_JIT_COMPLETE)\n      cc = compile_charn_matchingpath(common, cc, ccend, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);\n    else\n      cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE);\n    break;\n\n    case OP_STAR:\n    case OP_MINSTAR:\n    case OP_PLUS:\n    case OP_MINPLUS:\n    case OP_QUERY:\n    case OP_MINQUERY:\n    case OP_UPTO:\n    case OP_MINUPTO:\n    case OP_EXACT:\n    case OP_POSSTAR:\n    case OP_POSPLUS:\n    case OP_POSQUERY:\n    case OP_POSUPTO:\n    case OP_STARI:\n    case OP_MINSTARI:\n    case OP_PLUSI:\n    case OP_MINPLUSI:\n    case OP_QUERYI:\n    case OP_MINQUERYI:\n    case OP_UPTOI:\n    case OP_MINUPTOI:\n    case OP_EXACTI:\n    case OP_POSSTARI:\n    case OP_POSPLUSI:\n    case OP_POSQUERYI:\n    case OP_POSUPTOI:\n    case OP_NOTSTAR:\n    case OP_NOTMINSTAR:\n    case OP_NOTPLUS:\n    case OP_NOTMINPLUS:\n    case OP_NOTQUERY:\n    case OP_NOTMINQUERY:\n    case OP_NOTUPTO:\n    case OP_NOTMINUPTO:\n    case OP_NOTEXACT:\n    case OP_NOTPOSSTAR:\n    case OP_NOTPOSPLUS:\n    case OP_NOTPOSQUERY:\n    case OP_NOTPOSUPTO:\n    case OP_NOTSTARI:\n    case OP_NOTMINSTARI:\n    case OP_NOTPLUSI:\n    case OP_NOTMINPLUSI:\n    case OP_NOTQUERYI:\n    case OP_NOTMINQUERYI:\n    case OP_NOTUPTOI:\n    case OP_NOTMINUPTOI:\n    case OP_NOTEXACTI:\n    case OP_NOTPOSSTARI:\n    case OP_NOTPOSPLUSI:\n    case OP_NOTPOSQUERYI:\n    case OP_NOTPOSUPTOI:\n    case OP_TYPESTAR:\n    case OP_TYPEMINSTAR:\n    case OP_TYPEPLUS:\n    case OP_TYPEMINPLUS:\n    case OP_TYPEQUERY:\n    case OP_TYPEMINQUERY:\n    case OP_TYPEUPTO:\n    case OP_TYPEMINUPTO:\n    case OP_TYPEEXACT:\n    case OP_TYPEPOSSTAR:\n    case OP_TYPEPOSPLUS:\n    case OP_TYPEPOSQUERY:\n    case OP_TYPEPOSUPTO:\n    cc = compile_iterator_matchingpath(common, cc, parent);\n    break;\n\n    case OP_CLASS:\n    case OP_NCLASS:\n    if (cc[1 + (32 \/ sizeof(PCRE2_UCHAR))] >= OP_CRSTAR && cc[1 + (32 \/ sizeof(PCRE2_UCHAR))] <= OP_CRPOSRANGE)\n      cc = compile_iterator_matchingpath(common, cc, parent);\n    else\n      cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE);\n    break;\n\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32\n    case OP_XCLASS:\n    if (*(cc + GET(cc, 1)) >= OP_CRSTAR && *(cc + GET(cc, 1)) <= OP_CRPOSRANGE)\n      cc = compile_iterator_matchingpath(common, cc, parent);\n    else\n      cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE);\n    break;\n#endif\n\n    case OP_REF:\n    case OP_REFI:\n    if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRPOSRANGE)\n      cc = compile_ref_iterator_matchingpath(common, cc, parent);\n    else\n      {\n      compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);\n      cc += 1 + IMM2_SIZE;\n      }\n    break;\n\n    case OP_DNREF:\n    case OP_DNREFI:\n    if (cc[1 + 2 * IMM2_SIZE] >= OP_CRSTAR && cc[1 + 2 * IMM2_SIZE] <= OP_CRPOSRANGE)\n      cc = compile_ref_iterator_matchingpath(common, cc, parent);\n    else\n      {\n      compile_dnref_search(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);\n      compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);\n      cc += 1 + 2 * IMM2_SIZE;\n      }\n    break;\n\n    case OP_RECURSE:\n    cc = compile_recurse_matchingpath(common, cc, parent);\n    break;\n\n    case OP_CALLOUT:\n    case OP_CALLOUT_STR:\n    cc = compile_callout_matchingpath(common, cc, parent);\n    break;\n\n    case OP_ASSERT:\n    case OP_ASSERT_NOT:\n    case OP_ASSERTBACK:\n    case OP_ASSERTBACK_NOT:\n    PUSH_BACKTRACK_NOVALUE(sizeof(assert_backtrack), cc);\n    cc = compile_assert_matchingpath(common, cc, BACKTRACK_AS(assert_backtrack), FALSE);\n    break;\n\n    case OP_BRAMINZERO:\n    PUSH_BACKTRACK_NOVALUE(sizeof(braminzero_backtrack), cc);\n    cc = bracketend(cc + 1);\n    if (*(cc - 1 - LINK_SIZE) != OP_KETRMIN)\n      {\n      allocate_stack(common, 1);\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);\n      }\n    else\n      {\n      allocate_stack(common, 2);\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), STR_PTR, 0);\n      }\n    BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();\n    count_match(common);\n    break;\n\n    case OP_ASSERT_NA:\n    case OP_ASSERTBACK_NA:\n    case OP_ONCE:\n    case OP_SCRIPT_RUN:\n    case OP_BRA:\n    case OP_CBRA:\n    case OP_COND:\n    case OP_SBRA:\n    case OP_SCBRA:\n    case OP_SCOND:\n    cc = compile_bracket_matchingpath(common, cc, parent);\n    break;\n\n    case OP_BRAZERO:\n    if (cc[1] > OP_ASSERTBACK_NOT)\n      cc = compile_bracket_matchingpath(common, cc, parent);\n    else\n      {\n      PUSH_BACKTRACK_NOVALUE(sizeof(assert_backtrack), cc);\n      cc = compile_assert_matchingpath(common, cc, BACKTRACK_AS(assert_backtrack), FALSE);\n      }\n    break;\n\n    case OP_BRAPOS:\n    case OP_CBRAPOS:\n    case OP_SBRAPOS:\n    case OP_SCBRAPOS:\n    case OP_BRAPOSZERO:\n    cc = compile_bracketpos_matchingpath(common, cc, parent);\n    break;\n\n    case OP_MARK:\n    PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);\n    SLJIT_ASSERT(common->mark_ptr != 0);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr);\n    allocate_stack(common, common->has_skip_arg ? 5 : 1);\n    if (HAS_VIRTUAL_REGISTERS)\n      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(common->has_skip_arg ? 4 : 0), TMP2, 0);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP2, 0);\n    OP1(SLJIT_MOV, SLJIT_MEM1(HAS_VIRTUAL_REGISTERS ? TMP1 : ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);\n    if (common->has_skip_arg)\n      {\n      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, STACK_TOP, 0);\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, type_mark);\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), SLJIT_IMM, (sljit_sw)(cc + 2));\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(3), STR_PTR, 0);\n      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);\n      }\n    cc += 1 + 2 + cc[1];\n    break;\n\n    case OP_PRUNE:\n    case OP_PRUNE_ARG:\n    case OP_SKIP:\n    case OP_SKIP_ARG:\n    case OP_THEN:\n    case OP_THEN_ARG:\n    case OP_COMMIT:\n    case OP_COMMIT_ARG:\n    cc = compile_control_verb_matchingpath(common, cc, parent);\n    break;\n\n    case OP_FAIL:\n    case OP_ACCEPT:\n    case OP_ASSERT_ACCEPT:\n    cc = compile_fail_accept_matchingpath(common, cc, parent);\n    break;\n\n    case OP_CLOSE:\n    cc = compile_close_matchingpath(common, cc);\n    break;\n\n    case OP_SKIPZERO:\n    cc = bracketend(cc + 1);\n    break;\n\n    default:\n    SLJIT_UNREACHABLE();\n    return;\n    }\n  if (cc == NULL)\n    return;\n  }\n\nif (has_then_trap)\n  {\n  \/* Head item on backtrack. *\/\n  PUSH_BACKTRACK_NOVALUE(sizeof(then_trap_backtrack), cc);\n  BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;\n  BACKTRACK_AS(then_trap_backtrack)->then_trap = common->then_trap;\n  common->then_trap = save_then_trap;\n  }\nSLJIT_ASSERT(cc == ccend);\n}","target":0,"code_token_length":2932,"total_token_length":3168,"max_tokens_setting":4096}
+{"idx":209049,"func":"xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,\n                  const xmlChar **URI, int *tlen) {\n    const xmlChar *localname;\n    const xmlChar *prefix;\n    const xmlChar *attname;\n    const xmlChar *aprefix;\n    const xmlChar *nsname;\n    xmlChar *attvalue;\n    const xmlChar **atts = ctxt->atts;\n    int maxatts = ctxt->maxatts;\n    int nratts, nbatts, nbdef;\n    int i, j, nbNs, attval, oldline, oldcol;\n    const xmlChar *base;\n    unsigned long cur;\n    int nsNr = ctxt->nsNr;\n\n    if (RAW != '<') return(NULL);\n    NEXT1;\n\n    \/*\n     * NOTE: it is crucial with the SAX2 API to never call SHRINK beyond that\n     *       point since the attribute values may be stored as pointers to\n     *       the buffer and calling SHRINK would destroy them !\n     *       The Shrinking is only possible once the full set of attribute\n     *       callbacks have been done.\n     *\/\nreparse:\n    SHRINK;\n    base = ctxt->input->base;\n    cur = ctxt->input->cur - ctxt->input->base;\n    oldline = ctxt->input->line;\n    oldcol = ctxt->input->col;\n    nbatts = 0;\n    nratts = 0;\n    nbdef = 0;\n    nbNs = 0;\n    attval = 0;\n    \/* Forget any namespaces added during an earlier parse of this element. *\/\n    ctxt->nsNr = nsNr;\n\n    localname = xmlParseQName(ctxt, &prefix);\n    if (localname == NULL) {\n\txmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,\n\t\t       \"StartTag: invalid element name\\n\");\n        return(NULL);\n    }\n    *tlen = ctxt->input->cur - ctxt->input->base - cur;\n\n    \/*\n     * Now parse the attributes, it ends up with the ending\n     *\n     * (S Attribute)* S?\n     *\/\n    SKIP_BLANKS;\n    GROW;\n    if (ctxt->input->base != base) goto base_changed;\n\n    while (((RAW != '>') &&\n\t   ((RAW != '\/') || (NXT(1) != '>')) &&\n\t   (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {\n\tconst xmlChar *q = CUR_PTR;\n\tunsigned int cons = ctxt->input->consumed;\n\tint len = -1, alloc = 0;\n\n\tattname = xmlParseAttribute2(ctxt, prefix, localname,\n\t                             &aprefix, &attvalue, &len, &alloc);\n\tif (ctxt->input->base != base) {\n\t    if ((attvalue != NULL) && (alloc != 0))\n\t        xmlFree(attvalue);\n\t    attvalue = NULL;\n\t    goto base_changed;\n\t}\n        if ((attname != NULL) && (attvalue != NULL)) {\n\t    if (len < 0) len = xmlStrlen(attvalue);\n            if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {\n\t        const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);\n\t\txmlURIPtr uri;\n\n                if (URL == NULL) {\n\t\t    xmlErrMemory(ctxt, \"dictionary allocation failure\");\n\t\t    if ((attvalue != NULL) && (alloc != 0))\n\t\t\txmlFree(attvalue);\n\t\t    return(NULL);\n\t\t}\n                if (*URL != 0) {\n\t\t    uri = xmlParseURI((const char *) URL);\n\t\t    if (uri == NULL) {\n\t\t\txmlNsErr(ctxt, XML_WAR_NS_URI,\n\t\t\t         \"xmlns: '%s' is not a valid URI\\n\",\n\t\t\t\t\t   URL, NULL, NULL);\n\t\t    } else {\n\t\t\tif (uri->scheme == NULL) {\n\t\t\t    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,\n\t\t\t\t      \"xmlns: URI %s is not absolute\\n\",\n\t\t\t\t      URL, NULL, NULL);\n\t\t\t}\n\t\t\txmlFreeURI(uri);\n\t\t    }\n\t\t    if (URL == ctxt->str_xml_ns) {\n\t\t\tif (attname != ctxt->str_xml) {\n\t\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t \"xml namespace URI cannot be the default namespace\\n\",\n\t\t\t\t     NULL, NULL, NULL);\n\t\t\t}\n\t\t\tgoto skip_default_ns;\n\t\t    }\n\t\t    if ((len == 29) &&\n\t\t\t(xmlStrEqual(URL,\n\t\t\t\t BAD_CAST \"http:\/\/www.w3.org\/2000\/xmlns\/\"))) {\n\t\t\txmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t     \"reuse of the xmlns namespace name is forbidden\\n\",\n\t\t\t\t NULL, NULL, NULL);\n\t\t\tgoto skip_default_ns;\n\t\t    }\n\t\t}\n\t\t\/*\n\t\t * check that it's not a defined namespace\n\t\t *\/\n\t\tfor (j = 1;j <= nbNs;j++)\n\t\t    if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)\n\t\t\tbreak;\n\t\tif (j <= nbNs)\n\t\t    xmlErrAttributeDup(ctxt, NULL, attname);\n\t\telse\n\t\t    if (nsPush(ctxt, NULL, URL) > 0) nbNs++;\nskip_default_ns:\n\t\tif (alloc != 0) xmlFree(attvalue);\n\t\tif ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n\t\t    break;\n\t\tif (!IS_BLANK_CH(RAW)) {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n\t\t\t\t   \"attributes construct error\\n\");\n\t\t    break;\n\t\t}\n\t\tSKIP_BLANKS;\n\t\tcontinue;\n\t    }\n            if (aprefix == ctxt->str_xmlns) {\n\t        const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);\n\t\txmlURIPtr uri;\n\n                if (attname == ctxt->str_xml) {\n\t\t    if (URL != ctxt->str_xml_ns) {\n\t\t        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t         \"xml namespace prefix mapped to wrong URI\\n\",\n\t\t\t         NULL, NULL, NULL);\n\t\t    }\n\t\t    \/*\n\t\t     * Do not keep a namespace definition node\n\t\t     *\/\n\t\t    goto skip_ns;\n\t\t}\n                if (URL == ctxt->str_xml_ns) {\n\t\t    if (attname != ctxt->str_xml) {\n\t\t        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t         \"xml namespace URI mapped to wrong prefix\\n\",\n\t\t\t         NULL, NULL, NULL);\n\t\t    }\n\t\t    goto skip_ns;\n\t\t}\n                if (attname == ctxt->str_xmlns) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t     \"redefinition of the xmlns prefix is forbidden\\n\",\n\t\t\t     NULL, NULL, NULL);\n\t\t    goto skip_ns;\n\t\t}\n\t\tif ((len == 29) &&\n\t\t    (xmlStrEqual(URL,\n\t\t                 BAD_CAST \"http:\/\/www.w3.org\/2000\/xmlns\/\"))) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t     \"reuse of the xmlns namespace name is forbidden\\n\",\n\t\t\t     NULL, NULL, NULL);\n\t\t    goto skip_ns;\n\t\t}\n\t\tif ((URL == NULL) || (URL[0] == 0)) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t             \"xmlns:%s: Empty XML namespace is not allowed\\n\",\n\t\t\t          attname, NULL, NULL);\n\t\t    goto skip_ns;\n\t\t} else {\n\t\t    uri = xmlParseURI((const char *) URL);\n\t\t    if (uri == NULL) {\n\t\t\txmlNsErr(ctxt, XML_WAR_NS_URI,\n\t\t\t     \"xmlns:%s: '%s' is not a valid URI\\n\",\n\t\t\t\t\t   attname, URL, NULL);\n\t\t    } else {\n\t\t\tif ((ctxt->pedantic) && (uri->scheme == NULL)) {\n\t\t\t    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,\n\t\t\t\t      \"xmlns:%s: URI %s is not absolute\\n\",\n\t\t\t\t      attname, URL, NULL);\n\t\t\t}\n\t\t\txmlFreeURI(uri);\n\t\t    }\n\t\t}\n\n\t\t\/*\n\t\t * check that it's not a defined namespace\n\t\t *\/\n\t\tfor (j = 1;j <= nbNs;j++)\n\t\t    if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)\n\t\t\tbreak;\n\t\tif (j <= nbNs)\n\t\t    xmlErrAttributeDup(ctxt, aprefix, attname);\n\t\telse\n\t\t    if (nsPush(ctxt, attname, URL) > 0) nbNs++;\nskip_ns:\n\t\tif (alloc != 0) xmlFree(attvalue);\n\t\tif ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n\t\t    break;\n\t\tif (!IS_BLANK_CH(RAW)) {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n\t\t\t\t   \"attributes construct error\\n\");\n\t\t    break;\n\t\t}\n\t\tSKIP_BLANKS;\n\t\tif (ctxt->input->base != base) goto base_changed;\n\t\tcontinue;\n\t    }\n\n\t    \/*\n\t     * Add the pair to atts\n\t     *\/\n\t    if ((atts == NULL) || (nbatts + 5 > maxatts)) {\n\t        if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {\n\t\t    if (attvalue[len] == 0)\n\t\t\txmlFree(attvalue);\n\t\t    goto failed;\n\t\t}\n\t        maxatts = ctxt->maxatts;\n\t\tatts = ctxt->atts;\n\t    }\n\t    ctxt->attallocs[nratts++] = alloc;\n\t    atts[nbatts++] = attname;\n\t    atts[nbatts++] = aprefix;\n\t    atts[nbatts++] = NULL; \/* the URI will be fetched later *\/\n\t    atts[nbatts++] = attvalue;\n\t    attvalue += len;\n\t    atts[nbatts++] = attvalue;\n\t    \/*\n\t     * tag if some deallocation is needed\n\t     *\/\n\t    if (alloc != 0) attval = 1;\n\t} else {\n\t    if ((attvalue != NULL) && (attvalue[len] == 0))\n\t\txmlFree(attvalue);\n\t}\n\nfailed:\n\n\tGROW\n        if (ctxt->instate == XML_PARSER_EOF)\n            break;\n\tif (ctxt->input->base != base) goto base_changed;\n\tif ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n\t    break;\n\tif (!IS_BLANK_CH(RAW)) {\n\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n\t\t\t   \"attributes construct error\\n\");\n\t    break;\n\t}\n\tSKIP_BLANKS;\n        if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&\n            (attname == NULL) && (attvalue == NULL)) {\n\t    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,\n\t         \"xmlParseStartTag: problem parsing attributes\\n\");\n\t    break;\n\t}\n        GROW;\n\tif (ctxt->input->base != base) goto base_changed;\n    }\n\n    \/*\n     * The attributes defaulting\n     *\/\n    if (ctxt->attsDefault != NULL) {\n        xmlDefAttrsPtr defaults;\n\n\tdefaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix);\n\tif (defaults != NULL) {\n\t    for (i = 0;i < defaults->nbAttrs;i++) {\n\t        attname = defaults->values[5 * i];\n\t\taprefix = defaults->values[5 * i + 1];\n\n                \/*\n\t\t * special work for namespaces defaulted defs\n\t\t *\/\n\t\tif ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {\n\t\t    \/*\n\t\t     * check that it's not a defined namespace\n\t\t     *\/\n\t\t    for (j = 1;j <= nbNs;j++)\n\t\t        if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)\n\t\t\t    break;\n\t            if (j <= nbNs) continue;\n\n\t\t    nsname = xmlGetNamespace(ctxt, NULL);\n\t\t    if (nsname != defaults->values[5 * i + 2]) {\n\t\t\tif (nsPush(ctxt, NULL,\n\t\t\t           defaults->values[5 * i + 2]) > 0)\n\t\t\t    nbNs++;\n\t\t    }\n\t\t} else if (aprefix == ctxt->str_xmlns) {\n\t\t    \/*\n\t\t     * check that it's not a defined namespace\n\t\t     *\/\n\t\t    for (j = 1;j <= nbNs;j++)\n\t\t        if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)\n\t\t\t    break;\n\t            if (j <= nbNs) continue;\n\n\t\t    nsname = xmlGetNamespace(ctxt, attname);\n\t\t    if (nsname != defaults->values[2]) {\n\t\t\tif (nsPush(ctxt, attname,\n\t\t\t           defaults->values[5 * i + 2]) > 0)\n\t\t\t    nbNs++;\n\t\t    }\n\t\t} else {\n\t\t    \/*\n\t\t     * check that it's not a defined attribute\n\t\t     *\/\n\t\t    for (j = 0;j < nbatts;j+=5) {\n\t\t\tif ((attname == atts[j]) && (aprefix == atts[j+1]))\n\t\t\t    break;\n\t\t    }\n\t\t    if (j < nbatts) continue;\n\n\t\t    if ((atts == NULL) || (nbatts + 5 > maxatts)) {\n\t\t\tif (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {\n\t\t\t    return(NULL);\n\t\t\t}\n\t\t\tmaxatts = ctxt->maxatts;\n\t\t\tatts = ctxt->atts;\n\t\t    }\n\t\t    atts[nbatts++] = attname;\n\t\t    atts[nbatts++] = aprefix;\n\t\t    if (aprefix == NULL)\n\t\t\tatts[nbatts++] = NULL;\n\t\t    else\n\t\t        atts[nbatts++] = xmlGetNamespace(ctxt, aprefix);\n\t\t    atts[nbatts++] = defaults->values[5 * i + 2];\n\t\t    atts[nbatts++] = defaults->values[5 * i + 3];\n\t\t    if ((ctxt->standalone == 1) &&\n\t\t        (defaults->values[5 * i + 4] != NULL)) {\n\t\t\txmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED,\n\t  \"standalone: attribute %s on %s defaulted from external subset\\n\",\n\t                                 attname, localname);\n\t\t    }\n\t\t    nbdef++;\n\t\t}\n\t    }\n\t}\n    }\n\n    \/*\n     * The attributes checkings\n     *\/\n    for (i = 0; i < nbatts;i += 5) {\n        \/*\n\t* The default namespace does not apply to attribute names.\n\t*\/\n\tif (atts[i + 1] != NULL) {\n\t    nsname = xmlGetNamespace(ctxt, atts[i + 1]);\n\t    if (nsname == NULL) {\n\t\txmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,\n\t\t    \"Namespace prefix %s for %s on %s is not defined\\n\",\n\t\t    atts[i + 1], atts[i], localname);\n\t    }\n\t    atts[i + 2] = nsname;\n\t} else\n\t    nsname = NULL;\n\t\/*\n\t * [ WFC: Unique Att Spec ]\n\t * No attribute name may appear more than once in the same\n\t * start-tag or empty-element tag.\n\t * As extended by the Namespace in XML REC.\n\t *\/\n        for (j = 0; j < i;j += 5) {\n\t    if (atts[i] == atts[j]) {\n\t        if (atts[i+1] == atts[j+1]) {\n\t\t    xmlErrAttributeDup(ctxt, atts[i+1], atts[i]);\n\t\t    break;\n\t\t}\n\t\tif ((nsname != NULL) && (atts[j + 2] == nsname)) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,\n\t\t\t     \"Namespaced Attribute %s in '%s' redefined\\n\",\n\t\t\t     atts[i], nsname, NULL);\n\t\t    break;\n\t\t}\n\t    }\n\t}\n    }\n\n    nsname = xmlGetNamespace(ctxt, prefix);\n    if ((prefix != NULL) && (nsname == NULL)) {\n\txmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,\n\t         \"Namespace prefix %s on %s is not defined\\n\",\n\t\t prefix, localname, NULL);\n    }\n    *pref = prefix;\n    *URI = nsname;\n\n    \/*\n     * SAX: Start of Element !\n     *\/\n    if ((ctxt->sax != NULL) && (ctxt->sax->startElementNs != NULL) &&\n\t(!ctxt->disableSAX)) {\n\tif (nbNs > 0)\n\t    ctxt->sax->startElementNs(ctxt->userData, localname, prefix,\n\t\t\t  nsname, nbNs, &ctxt->nsTab[ctxt->nsNr - 2 * nbNs],\n\t\t\t  nbatts \/ 5, nbdef, atts);\n\telse\n\t    ctxt->sax->startElementNs(ctxt->userData, localname, prefix,\n\t                  nsname, 0, NULL, nbatts \/ 5, nbdef, atts);\n    }\n\n    \/*\n     * Free up attribute allocated strings if needed\n     *\/\n    if (attval != 0) {\n\tfor (i = 3,j = 0; j < nratts;i += 5,j++)\n\t    if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))\n\t        xmlFree((xmlChar *) atts[i]);\n    }\n\n    return(localname);\n\nbase_changed:\n    \/*\n     * the attribute strings are valid iif the base didn't changed\n     *\/\n    if (attval != 0) {\n\tfor (i = 3,j = 0; j < nratts;i += 5,j++)\n\t    if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))\n\t        xmlFree((xmlChar *) atts[i]);\n    }\n    ctxt->input->cur = ctxt->input->base + cur;\n    ctxt->input->line = oldline;\n    ctxt->input->col = oldcol;\n    if (ctxt->wellFormed == 1) {\n\tgoto reparse;\n    }\n    return(NULL);\n}","target":1,"code_token_length":3859,"total_token_length":4095,"max_tokens_setting":4096}
+{"idx":238651,"func":"int bpf_check_attach_target(struct bpf_verifier_log *log,\n\t\t\t    const struct bpf_prog *prog,\n\t\t\t    const struct bpf_prog *tgt_prog,\n\t\t\t    u32 btf_id,\n\t\t\t    struct bpf_attach_target_info *tgt_info)\n{\n\tbool prog_extension = prog->type == BPF_PROG_TYPE_EXT;\n\tconst char prefix[] = \"btf_trace_\";\n\tint ret = 0, subprog = -1, i;\n\tconst struct btf_type *t;\n\tbool conservative = true;\n\tconst char *tname;\n\tstruct btf *btf;\n\tlong addr = 0;\n\n\tif (!btf_id) {\n\t\tbpf_log(log, \"Tracing programs must provide btf_id\\n\");\n\t\treturn -EINVAL;\n\t}\n\tbtf = tgt_prog ? tgt_prog->aux->btf : prog->aux->attach_btf;\n\tif (!btf) {\n\t\tbpf_log(log,\n\t\t\t\"FENTRY\/FEXIT program can only be attached to another program annotated with BTF\\n\");\n\t\treturn -EINVAL;\n\t}\n\tt = btf_type_by_id(btf, btf_id);\n\tif (!t) {\n\t\tbpf_log(log, \"attach_btf_id %u is invalid\\n\", btf_id);\n\t\treturn -EINVAL;\n\t}\n\ttname = btf_name_by_offset(btf, t->name_off);\n\tif (!tname) {\n\t\tbpf_log(log, \"attach_btf_id %u doesn't have a name\\n\", btf_id);\n\t\treturn -EINVAL;\n\t}\n\tif (tgt_prog) {\n\t\tstruct bpf_prog_aux *aux = tgt_prog->aux;\n\n\t\tfor (i = 0; i < aux->func_info_cnt; i++)\n\t\t\tif (aux->func_info[i].type_id == btf_id) {\n\t\t\t\tsubprog = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (subprog == -1) {\n\t\t\tbpf_log(log, \"Subprog %s doesn't exist\\n\", tname);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tconservative = aux->func_info_aux[subprog].unreliable;\n\t\tif (prog_extension) {\n\t\t\tif (conservative) {\n\t\t\t\tbpf_log(log,\n\t\t\t\t\t\"Cannot replace static functions\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tif (!prog->jit_requested) {\n\t\t\t\tbpf_log(log,\n\t\t\t\t\t\"Extension programs should be JITed\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\t\tif (!tgt_prog->jited) {\n\t\t\tbpf_log(log, \"Can attach to only JITed progs\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (tgt_prog->type == prog->type) {\n\t\t\t\/* Cannot fentry\/fexit another fentry\/fexit program.\n\t\t\t * Cannot attach program extension to another extension.\n\t\t\t * It's ok to attach fentry\/fexit to extension program.\n\t\t\t *\/\n\t\t\tbpf_log(log, \"Cannot recursively attach\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (tgt_prog->type == BPF_PROG_TYPE_TRACING &&\n\t\t    prog_extension &&\n\t\t    (tgt_prog->expected_attach_type == BPF_TRACE_FENTRY ||\n\t\t     tgt_prog->expected_attach_type == BPF_TRACE_FEXIT)) {\n\t\t\t\/* Program extensions can extend all program types\n\t\t\t * except fentry\/fexit. The reason is the following.\n\t\t\t * The fentry\/fexit programs are used for performance\n\t\t\t * analysis, stats and can be attached to any program\n\t\t\t * type except themselves. When extension program is\n\t\t\t * replacing XDP function it is necessary to allow\n\t\t\t * performance analysis of all functions. Both original\n\t\t\t * XDP program and its program extension. Hence\n\t\t\t * attaching fentry\/fexit to BPF_PROG_TYPE_EXT is\n\t\t\t * allowed. If extending of fentry\/fexit was allowed it\n\t\t\t * would be possible to create long call chain\n\t\t\t * fentry->extension->fentry->extension beyond\n\t\t\t * reasonable stack size. Hence extending fentry is not\n\t\t\t * allowed.\n\t\t\t *\/\n\t\t\tbpf_log(log, \"Cannot extend fentry\/fexit\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t} else {\n\t\tif (prog_extension) {\n\t\t\tbpf_log(log, \"Cannot replace kernel functions\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\tswitch (prog->expected_attach_type) {\n\tcase BPF_TRACE_RAW_TP:\n\t\tif (tgt_prog) {\n\t\t\tbpf_log(log,\n\t\t\t\t\"Only FENTRY\/FEXIT progs are attachable to another BPF prog\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (!btf_type_is_typedef(t)) {\n\t\t\tbpf_log(log, \"attach_btf_id %u is not a typedef\\n\",\n\t\t\t\tbtf_id);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (strncmp(prefix, tname, sizeof(prefix) - 1)) {\n\t\t\tbpf_log(log, \"attach_btf_id %u points to wrong type name %s\\n\",\n\t\t\t\tbtf_id, tname);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\ttname += sizeof(prefix) - 1;\n\t\tt = btf_type_by_id(btf, t->type);\n\t\tif (!btf_type_is_ptr(t))\n\t\t\t\/* should never happen in valid vmlinux build *\/\n\t\t\treturn -EINVAL;\n\t\tt = btf_type_by_id(btf, t->type);\n\t\tif (!btf_type_is_func_proto(t))\n\t\t\t\/* should never happen in valid vmlinux build *\/\n\t\t\treturn -EINVAL;\n\n\t\tbreak;\n\tcase BPF_TRACE_ITER:\n\t\tif (!btf_type_is_func(t)) {\n\t\t\tbpf_log(log, \"attach_btf_id %u is not a function\\n\",\n\t\t\t\tbtf_id);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tt = btf_type_by_id(btf, t->type);\n\t\tif (!btf_type_is_func_proto(t))\n\t\t\treturn -EINVAL;\n\t\tret = btf_distill_func_proto(log, btf, t, tname, &tgt_info->fmodel);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tbreak;\n\tdefault:\n\t\tif (!prog_extension)\n\t\t\treturn -EINVAL;\n\t\tfallthrough;\n\tcase BPF_MODIFY_RETURN:\n\tcase BPF_LSM_MAC:\n\tcase BPF_TRACE_FENTRY:\n\tcase BPF_TRACE_FEXIT:\n\t\tif (!btf_type_is_func(t)) {\n\t\t\tbpf_log(log, \"attach_btf_id %u is not a function\\n\",\n\t\t\t\tbtf_id);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (prog_extension &&\n\t\t    btf_check_type_match(log, prog, btf, t))\n\t\t\treturn -EINVAL;\n\t\tt = btf_type_by_id(btf, t->type);\n\t\tif (!btf_type_is_func_proto(t))\n\t\t\treturn -EINVAL;\n\n\t\tif ((prog->aux->saved_dst_prog_type || prog->aux->saved_dst_attach_type) &&\n\t\t    (!tgt_prog || prog->aux->saved_dst_prog_type != tgt_prog->type ||\n\t\t     prog->aux->saved_dst_attach_type != tgt_prog->expected_attach_type))\n\t\t\treturn -EINVAL;\n\n\t\tif (tgt_prog && conservative)\n\t\t\tt = NULL;\n\n\t\tret = btf_distill_func_proto(log, btf, t, tname, &tgt_info->fmodel);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\n\t\tif (tgt_prog) {\n\t\t\tif (subprog == 0)\n\t\t\t\taddr = (long) tgt_prog->bpf_func;\n\t\t\telse\n\t\t\t\taddr = (long) tgt_prog->aux->func[subprog]->bpf_func;\n\t\t} else {\n\t\t\taddr = kallsyms_lookup_name(tname);\n\t\t\tif (!addr) {\n\t\t\t\tbpf_log(log,\n\t\t\t\t\t\"The address of function %s cannot be found\\n\",\n\t\t\t\t\ttname);\n\t\t\t\treturn -ENOENT;\n\t\t\t}\n\t\t}\n\n\t\tif (prog->aux->sleepable) {\n\t\t\tret = -EINVAL;\n\t\t\tswitch (prog->type) {\n\t\t\tcase BPF_PROG_TYPE_TRACING:\n\t\t\t\t\/* fentry\/fexit\/fmod_ret progs can be sleepable only if they are\n\t\t\t\t * attached to ALLOW_ERROR_INJECTION and are not in denylist.\n\t\t\t\t *\/\n\t\t\t\tif (!check_non_sleepable_error_inject(btf_id) &&\n\t\t\t\t    within_error_injection_list(addr))\n\t\t\t\t\tret = 0;\n\t\t\t\tbreak;\n\t\t\tcase BPF_PROG_TYPE_LSM:\n\t\t\t\t\/* LSM progs check that they are attached to bpf_lsm_*() funcs.\n\t\t\t\t * Only some of them are sleepable.\n\t\t\t\t *\/\n\t\t\t\tif (bpf_lsm_is_sleepable_hook(btf_id))\n\t\t\t\t\tret = 0;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (ret) {\n\t\t\t\tbpf_log(log, \"%s is not sleepable\\n\", tname);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t} else if (prog->expected_attach_type == BPF_MODIFY_RETURN) {\n\t\t\tif (tgt_prog) {\n\t\t\t\tbpf_log(log, \"can't modify return codes of BPF programs\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tret = check_attach_modify_return(addr, tname);\n\t\t\tif (ret) {\n\t\t\t\tbpf_log(log, \"%s() is not modifiable\\n\", tname);\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\n\t\tbreak;\n\t}\n\ttgt_info->tgt_addr = addr;\n\ttgt_info->tgt_name = tname;\n\ttgt_info->tgt_type = t;\n\treturn 0;\n}","target":0,"code_token_length":1990,"total_token_length":2226,"max_tokens_setting":4096}
+{"idx":230127,"func":"json_t * user_auth_scheme_module_register(struct config_module * config, const struct _u_request * http_request, const char * username, json_t * j_scheme_data, void * cls) {\n  UNUSED(config);\n  UNUSED(http_request);\n  json_t * j_return, * j_result, * j_credential, * j_user_id, * j_assertion;\n  int res;\n\n  if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"new-credential\")) {\n    j_user_id = get_user_id_from_username(config, (json_t *)cls, username, 1);\n    if (check_result_value(j_user_id, G_OK)) {\n      j_credential = generate_new_credential(config, (json_t *)cls, username);\n      if (check_result_value(j_credential, G_OK)) {\n        j_return = json_pack(\"{sis{sOsOsOsss{sOss}sO}}\",\n                              \"result\", G_OK,\n                              \"response\",\n                                \"session\", json_object_get(json_object_get(j_credential, \"credential\"), \"session\"),\n                                \"challenge\", json_object_get(json_object_get(j_credential, \"credential\"), \"challenge\"),\n                                \"pubKey-cred-params\", json_object_get((json_t *)cls, \"pubKey-cred-params\"),\n                                \"attestation-required\", json_object_get((json_t *)cls, \"force-fmt-none\")==json_true()?\"none\":\"direct\",\n                                \"user\",\n                                  \"id\", json_object_get(j_user_id, \"user_id\"),\n                                  \"name\", username,\n                                \"rpId\", json_object_get((json_t *)cls, \"rp-origin\")\n                             );\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error generate_new_credential\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n      json_decref(j_credential);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_user_id_from_username\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_user_id);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"register-credential\")) {\n    j_credential = get_credential_from_session(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"session\")));\n    if (check_result_value(j_credential, G_OK)) {\n      j_result = register_new_attestation(config, (json_t *)cls, j_scheme_data, json_object_get(j_credential, \"credential\"));\n      if (check_result_value(j_result, G_OK)) {\n        j_return = json_pack(\"{si}\", \"result\", G_OK);\n      } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n        j_return = json_pack(\"{sisO}\", \"result\", G_ERROR_UNAUTHORIZED, \"response\", json_object_get(j_result, \"error\"));\n      } else if (check_result_value(j_result, G_ERROR_PARAM)) {\n        j_return = json_pack(\"{sisO}\", \"result\", G_ERROR_PARAM, \"response\", json_object_get(j_result, \"error\"));\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error register_new_attestation\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n      json_decref(j_result);\n    } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_NOT_FOUND);\n    } else if (check_result_value(j_credential, G_ERROR_PARAM)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential_from_session\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_credential);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"remove-credential\") && json_string_length(json_object_get(j_scheme_data, \"credential_id\"))) {\n    j_credential = get_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")));\n    if (check_result_value(j_credential, G_OK)) {\n      if ((res = update_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")), 4)) == G_OK) {\n        j_return = json_pack(\"{si}\", \"result\", G_OK);\n      } else if (res == G_ERROR_PARAM) {\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error update_credential\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n    } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_NOT_FOUND);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_credential);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"disable-credential\") && json_string_length(json_object_get(j_scheme_data, \"credential_id\"))) {\n    j_credential = get_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")));\n    if (check_result_value(j_credential, G_OK)) {\n      if ((res = update_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")), 3)) == G_OK) {\n        j_return = json_pack(\"{si}\", \"result\", G_OK);\n      } else if (res == G_ERROR_PARAM) {\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error update_credential\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n    } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_NOT_FOUND);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_credential);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"enable-credential\") && json_string_length(json_object_get(j_scheme_data, \"credential_id\"))) {\n    j_credential = get_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")));\n    if (check_result_value(j_credential, G_OK)) {\n      if ((res = update_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")), 1)) == G_OK) {\n        j_return = json_pack(\"{si}\", \"result\", G_OK);\n      } else if (res == G_ERROR_PARAM) {\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error update_credential\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n    } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_NOT_FOUND);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_credential);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"edit-credential\") && json_string_length(json_object_get(j_scheme_data, \"credential_id\")) && json_string_length(json_object_get(j_scheme_data, \"name\"))) {\n    j_credential = get_credential(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")));\n    if (check_result_value(j_credential, G_OK)) {\n      if ((res = update_credential_name(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"credential_id\")), json_string_value(json_object_get(j_scheme_data, \"name\")))) == G_OK) {\n        j_return = json_pack(\"{si}\", \"result\", G_OK);\n      } else if (res == G_ERROR_PARAM) {\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error update_credential_name\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n    } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_NOT_FOUND);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_credential);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"trigger-assertion\")) {\n    j_user_id = get_user_id_from_username(config, (json_t *)cls, username, 0);\n    if (check_result_value(j_user_id, G_OK)) {\n      j_credential = get_credential_list(config, (json_t *)cls, username, 1);\n      if (check_result_value(j_credential, G_OK)) {\n        j_assertion = generate_new_assertion(config, (json_t *)cls, username, 1);\n        if (check_result_value(j_assertion, G_OK)) {\n          j_return = json_pack(\"{sis{sOsOsOs{sOss}sO}}\",\n                              \"result\", G_OK,\n                              \"response\",\n                                \"allowCredentials\", json_object_get(j_credential, \"credential\"),\n                                \"session\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"session\"),\n                                \"challenge\", json_object_get(json_object_get(j_assertion, \"assertion\"), \"challenge\"),\n                                \"user\",\n                                  \"id\", json_object_get(j_user_id, \"user_id\"),\n                                  \"name\", username,\n                                \"rpId\", json_object_get((json_t *)cls, \"rp-origin\")\n                              );\n        } else if (check_result_value(j_assertion, G_ERROR_UNAUTHORIZED)) {\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error register_new_assertion\");\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n        }\n        json_decref(j_assertion);\n      } else if (check_result_value(j_credential, G_ERROR_NOT_FOUND)) {\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_trigger webauthn - Error get_credential_list\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n      json_decref(j_credential);\n    } else if (check_result_value(j_user_id, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_user_id_from_username\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_user_id);\n  } else if (0 == o_strcmp(json_string_value(json_object_get(j_scheme_data, \"register\")), \"validate-assertion\")) {\n    j_user_id = get_user_id_from_username(config, (json_t *)cls, username, 0);\n    if (check_result_value(j_user_id, G_OK)) {\n      j_assertion = get_assertion_from_session(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"session\")), 1);\n      if (check_result_value(j_assertion, G_OK)) {\n        if ((res = check_assertion(config, (json_t *)cls, username, j_scheme_data, json_object_get(j_assertion, \"assertion\"))) == G_OK) {\n          j_return = json_pack(\"{si}\", \"result\", G_OK);\n        } else if (res == G_ERROR_UNAUTHORIZED || res == G_ERROR_PARAM) {\n          j_return = json_pack(\"{si}\", \"result\", res);\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error check_assertion\");\n          j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n        }\n      } else if (check_result_value(j_assertion, G_ERROR_NOT_FOUND)) {\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential\");\n        j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n      }\n      json_decref(j_assertion);\n    } else if (check_result_value(j_user_id, G_ERROR_NOT_FOUND)) {\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR_UNAUTHORIZED);\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_validate webauthn - Error get_user_id_from_username\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n    json_decref(j_user_id);\n  } else {\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR_PARAM);\n  }\n\n  return j_return;\n}","target":0,"code_token_length":3107,"total_token_length":3343,"max_tokens_setting":4096}
+{"idx":210511,"func":"win_close(win_T *win, int free_buf)\n{\n    win_T\t*wp;\n    int\t\tother_buffer = FALSE;\n    int\t\tclose_curwin = FALSE;\n    int\t\tdir;\n    int\t\thelp_window = FALSE;\n    tabpage_T   *prev_curtab = curtab;\n    frame_T\t*win_frame = win->w_frame->fr_parent;\n#ifdef FEAT_DIFF\n    int\t\thad_diffmode = win->w_p_diff;\n#endif\n#ifdef MESSAGE_QUEUE\n    int\t\tdid_decrement = FALSE;\n#endif\n\n#if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP)\n    \/\/ Can close a popup window with a terminal if the job has finished.\n    if (may_close_term_popup() == OK)\n\treturn OK;\n#endif\n    if (ERROR_IF_ANY_POPUP_WINDOW)\n\treturn FAIL;\n\n    if (last_window())\n    {\n\temsg(_(e_cannot_close_last_window));\n\treturn FAIL;\n    }\n\n    if (win->w_closing || (win->w_buffer != NULL\n\t\t\t\t\t       && win->w_buffer->b_locked > 0))\n\treturn FAIL; \/\/ window is already being closed\n    if (win_unlisted(win))\n    {\n\temsg(_(e_cannot_close_autocmd_or_popup_window));\n\treturn FAIL;\n    }\n    if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())\n    {\n\temsg(_(e_cannot_close_window_only_autocmd_window_would_remain));\n\treturn FAIL;\n    }\n\n    \/\/ When closing the last window in a tab page first go to another tab page\n    \/\/ and then close the window and the tab page to avoid that curwin and\n    \/\/ curtab are invalid while we are freeing memory.\n    if (close_last_window_tabpage(win, free_buf, prev_curtab))\n      return FAIL;\n\n    \/\/ When closing the help window, try restoring a snapshot after closing\n    \/\/ the window.  Otherwise clear the snapshot, it's now invalid.\n    if (bt_help(win->w_buffer))\n\thelp_window = TRUE;\n    else\n\tclear_snapshot(curtab, SNAP_HELP_IDX);\n\n    if (win == curwin)\n    {\n#ifdef FEAT_JOB_CHANNEL\n\tleaving_window(curwin);\n#endif\n\t\/*\n\t * Guess which window is going to be the new current window.\n\t * This may change because of the autocommands (sigh).\n\t *\/\n\twp = frame2win(win_altframe(win, NULL));\n\n\t\/*\n\t * Be careful: If autocommands delete the window or cause this window\n\t * to be the last one left, return now.\n\t *\/\n\tif (wp->w_buffer != curbuf)\n\t{\n\t    other_buffer = TRUE;\n\t    win->w_closing = TRUE;\n\t    apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);\n\t    if (!win_valid(win))\n\t\treturn FAIL;\n\t    win->w_closing = FALSE;\n\t    if (last_window())\n\t\treturn FAIL;\n\t}\n\twin->w_closing = TRUE;\n\tapply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf);\n\tif (!win_valid(win))\n\t    return FAIL;\n\twin->w_closing = FALSE;\n\tif (last_window())\n\t    return FAIL;\n#ifdef FEAT_EVAL\n\t\/\/ autocmds may abort script processing\n\tif (aborting())\n\t    return FAIL;\n#endif\n    }\n\n#ifdef FEAT_GUI\n    \/\/ Avoid trouble with scrollbars that are going to be deleted in\n    \/\/ win_free().\n    if (gui.in_use)\n\tout_flush();\n#endif\n\n#ifdef FEAT_PROP_POPUP\n    if (popup_win_closed(win) && !win_valid(win))\n\treturn FAIL;\n#endif\n\n    \/\/ Trigger WinClosed just before starting to free window-related resources.\n    trigger_winclosed(win);\n    \/\/ autocmd may have freed the window already.\n    if (!win_valid_any_tab(win))\n\treturn OK;\n\n    win_close_buffer(win, free_buf ? DOBUF_UNLOAD : 0, TRUE);\n\n    if (only_one_window() && win_valid(win) && win->w_buffer == NULL\n\t    && (last_window() || curtab != prev_curtab\n\t\t|| close_last_window_tabpage(win, free_buf, prev_curtab)))\n    {\n\t\/\/ Autocommands have closed all windows, quit now.  Restore\n\t\/\/ curwin->w_buffer, otherwise writing viminfo may fail.\n\tif (curwin->w_buffer == NULL)\n\t    curwin->w_buffer = curbuf;\n\tgetout(0);\n    }\n\n    \/\/ Autocommands may have moved to another tab page.\n    if (curtab != prev_curtab && win_valid_any_tab(win)\n\t\t\t\t\t\t      && win->w_buffer == NULL)\n    {\n\t\/\/ Need to close the window anyway, since the buffer is NULL.\n\twin_close_othertab(win, FALSE, prev_curtab);\n\treturn FAIL;\n    }\n\n    \/\/ Autocommands may have closed the window already or closed the only\n    \/\/ other window.\n    if (!win_valid(win) || last_window()\n\t    || close_last_window_tabpage(win, free_buf, prev_curtab))\n\treturn FAIL;\n\n    \/\/ Now we are really going to close the window.  Disallow any autocommand\n    \/\/ to split a window to avoid trouble.\n    \/\/ Also bail out of parse_queued_messages() to avoid it tries to update the\n    \/\/ screen.\n    ++split_disallowed;\n#ifdef MESSAGE_QUEUE\n    ++dont_parse_messages;\n#endif\n\n    \/\/ Free the memory used for the window and get the window that received\n    \/\/ the screen space.\n    wp = win_free_mem(win, &dir, NULL);\n\n    if (help_window)\n    {\n\t\/\/ Closing the help window moves the cursor back to the current window\n\t\/\/ of the snapshot.\n\twin_T *prev_win = get_snapshot_curwin(SNAP_HELP_IDX);\n\n\tif (win_valid(prev_win))\n\t    wp = prev_win;\n    }\n\n    \/\/ Make sure curwin isn't invalid.  It can cause severe trouble when\n    \/\/ printing an error message.  For win_equal() curbuf needs to be valid\n    \/\/ too.\n    if (win == curwin)\n    {\n\tcurwin = wp;\n#ifdef FEAT_QUICKFIX\n\tif (wp->w_p_pvw || bt_quickfix(wp->w_buffer))\n\t{\n\t    \/*\n\t     * If the cursor goes to the preview or the quickfix window, try\n\t     * finding another window to go to.\n\t     *\/\n\t    for (;;)\n\t    {\n\t\tif (wp->w_next == NULL)\n\t\t    wp = firstwin;\n\t\telse\n\t\t    wp = wp->w_next;\n\t\tif (wp == curwin)\n\t\t    break;\n\t\tif (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer))\n\t\t{\n\t\t    curwin = wp;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n#endif\n\tcurbuf = curwin->w_buffer;\n\tclose_curwin = TRUE;\n\n\t\/\/ The cursor position may be invalid if the buffer changed after last\n\t\/\/ using the window.\n\tcheck_cursor();\n    }\n    if (p_ea && (*p_ead == 'b' || *p_ead == dir))\n\t\/\/ If the frame of the closed window contains the new current window,\n\t\/\/ only resize that frame.  Otherwise resize all windows.\n\twin_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir);\n    else\n\twin_comp_pos();\n    if (close_curwin)\n    {\n\t\/\/ Pass WEE_ALLOW_PARSE_MESSAGES to decrement dont_parse_messages\n\t\/\/ before autocommands.\n#ifdef MESSAGE_QUEUE\n\tdid_decrement =\n#else\n\t(void)\n#endif\n\t    win_enter_ext(wp,\n\t\tWEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS\n\t\t      | WEE_TRIGGER_LEAVE_AUTOCMDS | WEE_ALLOW_PARSE_MESSAGES);\n\tif (other_buffer)\n\t    \/\/ careful: after this wp and win may be invalid!\n\t    apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);\n    }\n\n    --split_disallowed;\n#ifdef MESSAGE_QUEUE\n    if (!did_decrement)\n\t--dont_parse_messages;\n#endif\n\n    \/*\n     * If last window has a status line now and we don't want one,\n     * remove the status line.\n     *\/\n    last_status(FALSE);\n\n    \/\/ After closing the help window, try restoring the window layout from\n    \/\/ before it was opened.\n    if (help_window)\n\trestore_snapshot(SNAP_HELP_IDX, close_curwin);\n\n#ifdef FEAT_DIFF\n    \/\/ If the window had 'diff' set and now there is only one window left in\n    \/\/ the tab page with 'diff' set, and \"closeoff\" is in 'diffopt', then\n    \/\/ execute \":diffoff!\".\n    if (diffopt_closeoff() && had_diffmode && curtab == prev_curtab)\n    {\n\tint\tdiffcount = 0;\n\twin_T\t*dwin;\n\n\tFOR_ALL_WINDOWS(dwin)\n\t    if (dwin->w_p_diff)\n\t\t++diffcount;\n\tif (diffcount == 1)\n\t    do_cmdline_cmd((char_u *)\"diffoff!\");\n    }\n#endif\n\n#if defined(FEAT_GUI)\n    \/\/ When 'guioptions' includes 'L' or 'R' may have to remove scrollbars.\n    if (gui.in_use && !win_hasvertsplit())\n\tgui_init_which_components(NULL);\n#endif\n\n    redraw_all_later(NOT_VALID);\n    return OK;\n}","target":1,"code_token_length":1998,"total_token_length":2234,"max_tokens_setting":4096}
+{"idx":278254,"func":"set_indent(\n    int\t\tsize,\t\t    \/\/ measured in spaces\n    int\t\tflags)\n{\n    char_u\t*p;\n    char_u\t*newline;\n    char_u\t*oldline;\n    char_u\t*s;\n    int\t\ttodo;\n    int\t\tind_len;\t    \/\/ measured in characters\n    int\t\tline_len;\n    int\t\tdoit = FALSE;\n    int\t\tind_done = 0;\t    \/\/ measured in spaces\n#ifdef FEAT_VARTABS\n    int\t\tind_col = 0;\n#endif\n    int\t\ttab_pad;\n    int\t\tretval = FALSE;\n    int\t\torig_char_len = -1; \/\/ number of initial whitespace chars when\n\t\t\t\t    \/\/ 'et' and 'pi' are both set\n\n    \/\/ First check if there is anything to do and compute the number of\n    \/\/ characters needed for the indent.\n    todo = size;\n    ind_len = 0;\n    p = oldline = ml_get_curline();\n\n    \/\/ Calculate the buffer size for the new indent, and check to see if it\n    \/\/ isn't already set\n\n    \/\/ if 'expandtab' isn't set: use TABs; if both 'expandtab' and\n    \/\/ 'preserveindent' are set count the number of characters at the\n    \/\/ beginning of the line to be copied\n    if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi))\n    {\n\t\/\/ If 'preserveindent' is set then reuse as much as possible of\n\t\/\/ the existing indent structure for the new indent\n\tif (!(flags & SIN_INSERT) && curbuf->b_p_pi)\n\t{\n\t    ind_done = 0;\n\n\t    \/\/ count as many characters as we can use\n\t    while (todo > 0 && VIM_ISWHITE(*p))\n\t    {\n\t\tif (*p == TAB)\n\t\t{\n#ifdef FEAT_VARTABS\n\t\t    tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n#else\n\t\t    tab_pad = (int)curbuf->b_p_ts\n\t\t\t\t\t   - (ind_done % (int)curbuf->b_p_ts);\n#endif\n\t\t    \/\/ stop if this tab will overshoot the target\n\t\t    if (todo < tab_pad)\n\t\t\tbreak;\n\t\t    todo -= tab_pad;\n\t\t    ++ind_len;\n\t\t    ind_done += tab_pad;\n\t\t}\n\t\telse\n\t\t{\n\t\t    --todo;\n\t\t    ++ind_len;\n\t\t    ++ind_done;\n\t\t}\n\t\t++p;\n\t    }\n\n#ifdef FEAT_VARTABS\n\t    \/\/ These diverge from this point.\n\t    ind_col = ind_done;\n#endif\n\t    \/\/ Set initial number of whitespace chars to copy if we are\n\t    \/\/ preserving indent but expandtab is set\n\t    if (curbuf->b_p_et)\n\t\torig_char_len = ind_len;\n\n\t    \/\/ Fill to next tabstop with a tab, if possible\n#ifdef FEAT_VARTABS\n\t    tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\tcurbuf->b_p_vts_array);\n#else\n\t    tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);\n#endif\n\t    if (todo >= tab_pad && orig_char_len == -1)\n\t    {\n\t\tdoit = TRUE;\n\t\ttodo -= tab_pad;\n\t\t++ind_len;\n\t\t\/\/ ind_done += tab_pad;\n#ifdef FEAT_VARTABS\n\t\tind_col += tab_pad;\n#endif\n\t    }\n\t}\n\n\t\/\/ count tabs required for indent\n#ifdef FEAT_VARTABS\n\tfor (;;)\n\t{\n\t    tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n\t    if (todo < tab_pad)\n\t\tbreak;\n\t    if (*p != TAB)\n\t\tdoit = TRUE;\n\t    else\n\t\t++p;\n\t    todo -= tab_pad;\n\t    ++ind_len;\n\t    ind_col += tab_pad;\n\t}\n#else\n\twhile (todo >= (int)curbuf->b_p_ts)\n\t{\n\t    if (*p != TAB)\n\t\tdoit = TRUE;\n\t    else\n\t\t++p;\n\t    todo -= (int)curbuf->b_p_ts;\n\t    ++ind_len;\n\t    \/\/ ind_done += (int)curbuf->b_p_ts;\n\t}\n#endif\n    }\n    \/\/ count spaces required for indent\n    while (todo > 0)\n    {\n\tif (*p != ' ')\n\t    doit = TRUE;\n\telse\n\t    ++p;\n\t--todo;\n\t++ind_len;\n\t\/\/ ++ind_done;\n    }\n\n    \/\/ Return if the indent is OK already.\n    if (!doit && !VIM_ISWHITE(*p) && !(flags & SIN_INSERT))\n\treturn FALSE;\n\n    \/\/ Allocate memory for the new line.\n    if (flags & SIN_INSERT)\n\tp = oldline;\n    else\n\tp = skipwhite(p);\n    line_len = (int)STRLEN(p) + 1;\n\n    \/\/ If 'preserveindent' and 'expandtab' are both set keep the original\n    \/\/ characters and allocate accordingly.  We will fill the rest with spaces\n    \/\/ after the if (!curbuf->b_p_et) below.\n    if (orig_char_len != -1)\n    {\n\tnewline = alloc(orig_char_len + size - ind_done + line_len);\n\tif (newline == NULL)\n\t    return FALSE;\n\ttodo = size - ind_done;\n\tind_len = orig_char_len + todo;    \/\/ Set total length of indent in\n\t\t\t\t\t   \/\/ characters, which may have been\n\t\t\t\t\t   \/\/ undercounted until now\n\tp = oldline;\n\ts = newline;\n\twhile (orig_char_len > 0)\n\t{\n\t    *s++ = *p++;\n\t    orig_char_len--;\n\t}\n\n\t\/\/ Skip over any additional white space (useful when newindent is less\n\t\/\/ than old)\n\twhile (VIM_ISWHITE(*p))\n\t    ++p;\n\n    }\n    else\n    {\n\ttodo = size;\n\tnewline = alloc(ind_len + line_len);\n\tif (newline == NULL)\n\t    return FALSE;\n\ts = newline;\n    }\n\n    \/\/ Put the characters in the new line.\n    \/\/ if 'expandtab' isn't set: use TABs\n    if (!curbuf->b_p_et)\n    {\n\t\/\/ If 'preserveindent' is set then reuse as much as possible of\n\t\/\/ the existing indent structure for the new indent\n\tif (!(flags & SIN_INSERT) && curbuf->b_p_pi)\n\t{\n\t    p = oldline;\n\t    ind_done = 0;\n\n\t    while (todo > 0 && VIM_ISWHITE(*p))\n\t    {\n\t\tif (*p == TAB)\n\t\t{\n#ifdef FEAT_VARTABS\n\t\t    tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n#else\n\t\t    tab_pad = (int)curbuf->b_p_ts\n\t\t\t\t\t   - (ind_done % (int)curbuf->b_p_ts);\n#endif\n\t\t    \/\/ stop if this tab will overshoot the target\n\t\t    if (todo < tab_pad)\n\t\t\tbreak;\n\t\t    todo -= tab_pad;\n\t\t    ind_done += tab_pad;\n\t\t}\n\t\telse\n\t\t{\n\t\t    --todo;\n\t\t    ++ind_done;\n\t\t}\n\t\t*s++ = *p++;\n\t    }\n\n\t    \/\/ Fill to next tabstop with a tab, if possible\n#ifdef FEAT_VARTABS\n\t    tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\tcurbuf->b_p_vts_array);\n#else\n\t    tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);\n#endif\n\t    if (todo >= tab_pad)\n\t    {\n\t\t*s++ = TAB;\n\t\ttodo -= tab_pad;\n#ifdef FEAT_VARTABS\n\t\tind_done += tab_pad;\n#endif\n\t    }\n\n\t    p = skipwhite(p);\n\t}\n\n#ifdef FEAT_VARTABS\n\tfor (;;)\n\t{\n\t    tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,\n\t\t\t\t\t\t\tcurbuf->b_p_vts_array);\n\t    if (todo < tab_pad)\n\t\tbreak;\n\t    *s++ = TAB;\n\t    todo -= tab_pad;\n\t    ind_done += tab_pad;\n\t}\n#else\n\twhile (todo >= (int)curbuf->b_p_ts)\n\t{\n\t    *s++ = TAB;\n\t    todo -= (int)curbuf->b_p_ts;\n\t}\n#endif\n    }\n    while (todo > 0)\n    {\n\t*s++ = ' ';\n\t--todo;\n    }\n    mch_memmove(s, p, (size_t)line_len);\n\n    \/\/ Replace the line (unless undo fails).\n    if (!(flags & SIN_UNDO) || u_savesub(curwin->w_cursor.lnum) == OK)\n    {\n\tcolnr_T old_offset = (colnr_T)(p - oldline);\n\tcolnr_T new_offset = (colnr_T)(s - newline);\n\n\t\/\/ this may free \"newline\"\n\tml_replace(curwin->w_cursor.lnum, newline, FALSE);\n\tif (flags & SIN_CHANGED)\n\t    changed_bytes(curwin->w_cursor.lnum, 0);\n\n\t\/\/ Correct saved cursor position if it is in this line.\n\tif (saved_cursor.lnum == curwin->w_cursor.lnum)\n\t{\n\t    if (saved_cursor.col >= old_offset)\n\t\t\/\/ cursor was after the indent, adjust for the number of\n\t\t\/\/ bytes added\/removed\n\t\tsaved_cursor.col += ind_len - old_offset;\n\t    else if (saved_cursor.col >= new_offset)\n\t\t\/\/ cursor was in the indent, and is now after it, put it back\n\t\t\/\/ at the start of the indent (replacing spaces with TAB)\n\t\tsaved_cursor.col = new_offset;\n\t}\n#ifdef FEAT_PROP_POPUP\n\t{\n\t    int added = ind_len - old_offset;\n\n\t    \/\/ When increasing indent this behaves like spaces were inserted at\n\t    \/\/ the old indent, when decreasing indent it behaves like spaces\n\t    \/\/ were deleted at the new indent.\n\t    adjust_prop_columns(curwin->w_cursor.lnum,\n\t\t\t  added > 0 ? old_offset : (colnr_T)ind_len, added, 0);\n\t}\n#endif\n\tretval = TRUE;\n    }\n    else\n\tvim_free(newline);\n\n    curwin->w_cursor.col = ind_len;\n    return retval;\n}","target":0,"code_token_length":2213,"total_token_length":2449,"max_tokens_setting":4096}
+{"idx":299899,"func":"get_config_line(void)\n{\nint startoffset = 0;         \/* To first non-blank char in logical line *\/\nint len = 0;                 \/* Of logical line so far *\/\nint newlen;\nuschar *s, *ss;\nmacro_item *m;\nBOOL macro_found;\n\n\/* Loop for handling continuation lines, skipping comments, and dealing with\n.include files. *\/\n\nfor (;;)\n  {\n  if (Ufgets(big_buffer+len, big_buffer_size-len, config_file) == NULL)\n    {\n    if (config_file_stack != NULL)    \/* EOF inside .include *\/\n      {\n      (void)fclose(config_file);\n      config_file = config_file_stack->file;\n      config_filename = config_file_stack->filename;\n      config_lineno = config_file_stack->lineno;\n      config_file_stack = config_file_stack->next;\n      continue;\n      }\n\n    \/* EOF at top level *\/\n\n    if (cstate_stack_ptr >= 0)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n        \"Unexpected end of configuration file: .endif missing\");\n\n    if (len != 0) break;        \/* EOF after continuation *\/\n    next_section[0] = 0;        \/* EOF at start of logical line *\/\n    return NULL;\n    }\n\n  config_lineno++;\n  newlen = len + Ustrlen(big_buffer + len);\n\n  \/* Handle pathologically long physical lines - yes, it did happen - by\n  extending big_buffer at this point. The code also copes with very long\n  logical lines. *\/\n\n  while (newlen == big_buffer_size - 1 && big_buffer[newlen - 1] != '\\n')\n    {\n    uschar *newbuffer;\n    big_buffer_size += BIG_BUFFER_SIZE;\n    newbuffer = store_malloc(big_buffer_size);\n\n    \/* This use of strcpy is OK because we know that the string in the old\n    buffer is shorter than the new buffer. *\/\n\n    Ustrcpy(newbuffer, big_buffer);\n    store_free(big_buffer);\n    big_buffer = newbuffer;\n    if (Ufgets(big_buffer+newlen, big_buffer_size-newlen, config_file) == NULL)\n      break;\n    newlen += Ustrlen(big_buffer + newlen);\n    }\n\n  \/* Find the true start of the physical line - leading spaces are always\n  ignored. *\/\n\n  ss = big_buffer + len;\n  while (isspace(*ss)) ss++;\n\n  \/* Process the physical line for macros. If this is the start of the logical\n  line, skip over initial text at the start of the line if it starts with an\n  upper case character followed by a sequence of name characters and an equals\n  sign, because that is the definition of a new macro, and we don't do\n  replacement therein. *\/\n\n  s = ss;\n  if (len == 0 && isupper(*s))\n    {\n    while (isalnum(*s) || *s == '_') s++;\n    while (isspace(*s)) s++;\n    if (*s != '=') s = ss;          \/* Not a macro definition *\/\n    }\n\n  \/* For each defined macro, scan the line (from after XXX= if present),\n  replacing all occurrences of the macro. *\/\n\n  macro_found = FALSE;\n  for (m = macros; m != NULL; m = m->next)\n    {\n    uschar *p, *pp;\n    uschar *t = s;\n\n    while ((p = Ustrstr(t, m->name)) != NULL)\n      {\n      int moveby;\n      int namelen = Ustrlen(m->name);\n      int replen = Ustrlen(m->replacement);\n\n      \/* Expand the buffer if necessary *\/\n\n      while (newlen - namelen + replen + 1 > big_buffer_size)\n        {\n        int newsize = big_buffer_size + BIG_BUFFER_SIZE;\n        uschar *newbuffer = store_malloc(newsize);\n        memcpy(newbuffer, big_buffer, newlen + 1);\n        p = newbuffer  + (p - big_buffer);\n        s = newbuffer  + (s - big_buffer);\n        ss = newbuffer + (ss - big_buffer);\n        t = newbuffer  + (t - big_buffer);\n        big_buffer_size = newsize;\n        store_free(big_buffer);\n        big_buffer = newbuffer;\n        }\n\n      \/* Shuffle the remaining characters up or down in the buffer before\n      copying in the replacement text. Don't rescan the replacement for this\n      same macro. *\/\n\n      pp = p + namelen;\n      moveby = replen - namelen;\n      if (moveby != 0)\n        {\n        memmove(p + replen, pp, (big_buffer + newlen) - pp + 1);\n        newlen += moveby;\n        }\n      Ustrncpy(p, m->replacement, replen);\n      t = p + replen;\n      macro_found = TRUE;\n      }\n    }\n\n  \/* An empty macro replacement at the start of a line could mean that ss no\n  longer points to the first non-blank character. *\/\n\n  while (isspace(*ss)) ss++;\n\n  \/* Check for comment lines - these are physical lines. *\/\n\n  if (*ss == '#') continue;\n\n  \/* Handle conditionals, which are also applied to physical lines. Conditions\n  are of the form \".ifdef ANYTEXT\" and are treated as true if any macro\n  expansion occured on the rest of the line. A preliminary test for the leading\n  '.' saves effort on most lines. *\/\n\n  if (*ss == '.')\n    {\n    int i;\n\n    \/* Search the list of conditional directives *\/\n\n    for (i = 0; i < cond_list_size; i++)\n      {\n      int n;\n      cond_item *c = cond_list+i;\n      if (Ustrncmp(ss+1, c->name, c->namelen) != 0) continue;\n\n      \/* The following character must be white space or end of string *\/\n\n      n = ss[1 + c->namelen];\n      if (n != ' ' && n != 't' && n != '\\n' && n != 0) break;\n\n      \/* .ifdef and .ifndef push the current state onto the stack, then set\n      a new one from the table. Stack overflow is an error *\/\n\n      if (c->pushpop > 0)\n        {\n        if (cstate_stack_ptr >= CSTATE_STACK_SIZE - 1)\n          log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n            \".%s nested too deeply\", c->name);\n        cstate_stack[++cstate_stack_ptr] = cstate;\n        cstate = next_cstate[cstate][macro_found? c->action1 : c->action2];\n        }\n\n      \/* For any of the others, stack underflow is an error. The next state\n      comes either from the stack (.endif) or from the table. *\/\n\n      else\n        {\n        if (cstate_stack_ptr < 0)\n          log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n            \".%s without matching .ifdef\", c->name);\n        cstate = (c->pushpop < 0)? cstate_stack[cstate_stack_ptr--] :\n          next_cstate[cstate][macro_found? c->action1 : c->action2];\n        }\n\n      \/* Having dealt with a directive, break the loop *\/\n\n      break;\n      }\n\n    \/* If we have handled a conditional directive, continue with the next\n    physical line. Otherwise, fall through. *\/\n\n    if (i < cond_list_size) continue;\n    }\n\n  \/* If the conditional state is not 0 (actively using these lines), ignore\n  this input line. *\/\n\n  if (cstate != 0) continue;  \/* Conditional skip *\/\n\n  \/* Handle .include lines - these are also physical lines. *\/\n\n  if (Ustrncmp(ss, \".include\", 8) == 0 &&\n       (isspace(ss[8]) ||\n         (Ustrncmp(ss+8, \"_if_exists\", 10) == 0 && isspace(ss[18]))))\n    {\n    uschar *t;\n    int include_if_exists = isspace(ss[8])? 0 : 10;\n    config_file_item *save;\n    struct stat statbuf;\n\n    ss += 9 + include_if_exists;\n    while (isspace(*ss)) ss++;\n    t = ss + Ustrlen(ss);\n    while (t > ss && isspace(t[-1])) t--;\n    if (*ss == '\\\"' && t[-1] == '\\\"')\n      {\n      ss++;\n      t--;\n      }\n    *t = 0;\n\n    if (*ss != '\/')\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \".include specifies a non-\"\n        \"absolute path \\\"%s\\\"\", ss);\n\n    if (include_if_exists != 0 && (Ustat(ss, &statbuf) != 0)) continue;\n\n    save = store_get(sizeof(config_file_item));\n    save->next = config_file_stack;\n    config_file_stack = save;\n    save->file = config_file;\n    save->filename = config_filename;\n    save->lineno = config_lineno;\n\n    config_file = Ufopen(ss, \"rb\");\n    if (config_file == NULL)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"failed to open included \"\n        \"configuration file %s\", ss);\n    config_filename = string_copy(ss);\n    config_lineno = 0;\n    continue;\n    }\n\n  \/* If this is the start of the logical line, remember where the non-blank\n  data starts. Otherwise shuffle down continuation lines to remove leading\n  white space. *\/\n\n  if (len == 0)\n    startoffset = ss - big_buffer;\n  else\n    {\n    s = big_buffer + len;\n    if (ss > s)\n      {\n      memmove(s, ss, (newlen - len) -  (ss - s) + 1);\n      newlen -= ss - s;\n      }\n    }\n\n  \/* Accept the new addition to the line. Remove trailing white space. *\/\n\n  len = newlen;\n  while (len > 0 && isspace(big_buffer[len-1])) len--;\n  big_buffer[len] = 0;\n\n  \/* We are done if the line does not end in backslash and contains some data.\n  Empty logical lines are ignored. For continuations, remove the backslash and\n  go round the loop to read the continuation line. *\/\n\n  if (len > 0)\n    {\n    if (big_buffer[len-1] != '\\\\') break;   \/* End of logical line *\/\n    big_buffer[--len] = 0;                  \/* Remove backslash *\/\n    }\n  }     \/* Loop for reading multiple physical lines *\/\n\n\/* We now have a logical line. Test for the end of a configuration section (or,\nmore accurately, for the start of the next section). Place the name of the next\nsection in next_section, and return NULL. If the name given is longer than\nnext_section, truncate it. It will be unrecognized later, because all the known\nsection names do fit. Leave space for pluralizing. *\/\n\ns = big_buffer + startoffset;            \/* First non-space character *\/\nif (strncmpic(s, US\"begin \", 6) == 0)\n  {\n  s += 6;\n  while (isspace(*s)) s++;\n  if (big_buffer + len - s > sizeof(next_section) - 2)\n    s[sizeof(next_section) - 2] = 0;\n  Ustrcpy(next_section, s);\n  return NULL;\n  }\n\n\/* Return the first non-blank character. *\/\n\nreturn s;\n}","target":0,"code_token_length":2451,"total_token_length":2687,"max_tokens_setting":4096}
+{"idx":359558,"func":"bgp_open_receive (struct peer *peer, bgp_size_t size)\n{\n  int ret;\n  u_char version;\n  u_char optlen;\n  u_int16_t holdtime;\n  u_int16_t send_holdtime;\n  as_t remote_as;\n  struct peer *realpeer;\n  struct in_addr remote_id;\n  int capability;\n  u_int8_t notify_data_remote_as[2];\n  u_int8_t notify_data_remote_id[4];\n\n  realpeer = NULL;\n  \n  \/* Parse open packet. *\/\n  version = stream_getc (peer->ibuf);\n  memcpy (notify_data_remote_as, stream_pnt (peer->ibuf), 2);\n  remote_as  = stream_getw (peer->ibuf);\n  holdtime = stream_getw (peer->ibuf);\n  memcpy (notify_data_remote_id, stream_pnt (peer->ibuf), 4);\n  remote_id.s_addr = stream_get_ipv4 (peer->ibuf);\n\n  \/* Receive OPEN message log  *\/\n  if (BGP_DEBUG (normal, NORMAL))\n    zlog_debug (\"%s rcv OPEN, version %d, remote-as %d, holdtime %d, id %s\",\n\t       peer->host, version, remote_as, holdtime,\n\t       inet_ntoa (remote_id));\n\t  \n  \/* Lookup peer from Open packet. *\/\n  if (CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))\n    {\n      int as = 0;\n\n      realpeer = peer_lookup_with_open (&peer->su, remote_as, &remote_id, &as);\n\n      if (! realpeer)\n\t{\n\t  \/* Peer's source IP address is check in bgp_accept(), so this\n\t     must be AS number mismatch or remote-id configuration\n\t     mismatch. *\/\n\t  if (as)\n\t    {\n\t      if (BGP_DEBUG (normal, NORMAL))\n\t\tzlog_debug (\"%s bad OPEN, wrong router identifier %s\",\n\t\t\t    peer->host, inet_ntoa (remote_id));\n\t      bgp_notify_send_with_data (peer, BGP_NOTIFY_OPEN_ERR, \n\t\t\t\t\t BGP_NOTIFY_OPEN_BAD_BGP_IDENT,\n\t\t\t\t\t notify_data_remote_id, 4);\n\t    }\n\t  else\n\t    {\n\t      if (BGP_DEBUG (normal, NORMAL))\n\t\tzlog_debug (\"%s bad OPEN, remote AS is %d, expected %d\",\n\t\t\t    peer->host, remote_as, peer->as);\n\t      bgp_notify_send_with_data (peer, BGP_NOTIFY_OPEN_ERR,\n\t\t\t\t\t BGP_NOTIFY_OPEN_BAD_PEER_AS,\n\t\t\t\t\t notify_data_remote_as, 2);\n\t    }\n\t  return -1;\n\t}\n    }\n\n  \/* When collision is detected and this peer is closed.  Retrun\n     immidiately. *\/\n  ret = bgp_collision_detect (peer, remote_id);\n  if (ret < 0)\n    return ret;\n\n  \/* Hack part. *\/\n  if (CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))\n    {\n\tif (realpeer->status == Established\n\t    && CHECK_FLAG (realpeer->sflags, PEER_STATUS_NSF_MODE))\n\t{\n\t  realpeer->last_reset = PEER_DOWN_NSF_CLOSE_SESSION;\n\t  SET_FLAG (realpeer->sflags, PEER_STATUS_NSF_WAIT);\n\t}\n\telse if (ret == 0 && realpeer->status != Active\n\t         && realpeer->status != OpenSent\n\t\t && realpeer->status != OpenConfirm)\n\n \t{\n \t  if (BGP_DEBUG (events, EVENTS))\n\t    zlog_debug (\"%s peer status is %s close connection\",\n\t\t\trealpeer->host, LOOKUP (bgp_status_msg,\n\t\t\trealpeer->status));\n\t  bgp_notify_send (peer, BGP_NOTIFY_CEASE,\n\t\t\t   BGP_NOTIFY_CEASE_CONNECT_REJECT);\n\n \t  return -1;\n \t}\n\n      if (BGP_DEBUG (events, EVENTS))\n\tzlog_debug (\"%s [Event] Transfer temporary BGP peer to existing one\",\n\t\t   peer->host);\n\n      bgp_stop (realpeer);\n      \n      \/* Transfer file descriptor. *\/\n      realpeer->fd = peer->fd;\n      peer->fd = -1;\n\n      \/* Transfer input buffer. *\/\n      stream_free (realpeer->ibuf);\n      realpeer->ibuf = peer->ibuf;\n      realpeer->packet_size = peer->packet_size;\n      peer->ibuf = NULL;\n\n      \/* Transfer status. *\/\n      realpeer->status = peer->status;\n      bgp_stop (peer);\n      \n      \/* peer pointer change. Open packet send to neighbor. *\/\n      peer = realpeer;\n      bgp_open_send (peer);\n      if (peer->fd < 0)\n\t{\n\t  zlog_err (\"bgp_open_receive peer's fd is negative value %d\",\n\t\t    peer->fd);\n\t  return -1;\n\t}\n      BGP_READ_ON (peer->t_read, bgp_read, peer->fd);\n    }\n\n  \/* remote router-id check. *\/\n  if (remote_id.s_addr == 0\n      || ntohl (remote_id.s_addr) >= 0xe0000000\n      || ntohl (peer->local_id.s_addr) == ntohl (remote_id.s_addr))\n    {\n      if (BGP_DEBUG (normal, NORMAL))\n\tzlog_debug (\"%s bad OPEN, wrong router identifier %s\",\n\t\t   peer->host, inet_ntoa (remote_id));\n      bgp_notify_send_with_data (peer, \n\t\t\t\t BGP_NOTIFY_OPEN_ERR, \n\t\t\t\t BGP_NOTIFY_OPEN_BAD_BGP_IDENT,\n\t\t\t\t notify_data_remote_id, 4);\n      return -1;\n    }\n\n  \/* Set remote router-id *\/\n  peer->remote_id = remote_id;\n\n  \/* Peer BGP version check. *\/\n  if (version != BGP_VERSION_4)\n    {\n      u_int8_t maxver = BGP_VERSION_4;\n      if (BGP_DEBUG (normal, NORMAL))\n\tzlog_debug (\"%s bad protocol version, remote requested %d, local request %d\",\n\t\t   peer->host, version, BGP_VERSION_4);\n      bgp_notify_send_with_data (peer, \n\t\t\t\t BGP_NOTIFY_OPEN_ERR, \n\t\t\t\t BGP_NOTIFY_OPEN_UNSUP_VERSION,\n\t\t\t\t &maxver, 1);\n      return -1;\n    }\n\n  \/* Check neighbor as number. *\/\n  if (remote_as != peer->as)\n    {\n      if (BGP_DEBUG (normal, NORMAL))\n\tzlog_debug (\"%s bad OPEN, remote AS is %d, expected %d\",\n\t\t   peer->host, remote_as, peer->as);\n      bgp_notify_send_with_data (peer, \n\t\t\t\t BGP_NOTIFY_OPEN_ERR, \n\t\t\t\t BGP_NOTIFY_OPEN_BAD_PEER_AS,\n\t\t\t\t notify_data_remote_as, 2);\n      return -1;\n    }\n\n  \/* From the rfc: Upon receipt of an OPEN message, a BGP speaker MUST\n     calculate the value of the Hold Timer by using the smaller of its\n     configured Hold Time and the Hold Time received in the OPEN message.\n     The Hold Time MUST be either zero or at least three seconds.  An\n     implementation may reject connections on the basis of the Hold Time. *\/\n\n  if (holdtime < 3 && holdtime != 0)\n    {\n      bgp_notify_send (peer,\n\t\t       BGP_NOTIFY_OPEN_ERR, \n\t\t       BGP_NOTIFY_OPEN_UNACEP_HOLDTIME);\n      return -1;\n    }\n    \n  \/* From the rfc: A reasonable maximum time between KEEPALIVE messages\n     would be one third of the Hold Time interval.  KEEPALIVE messages\n     MUST NOT be sent more frequently than one per second.  An\n     implementation MAY adjust the rate at which it sends KEEPALIVE\n     messages as a function of the Hold Time interval. *\/\n\n  if (CHECK_FLAG (peer->config, PEER_CONFIG_TIMER))\n    send_holdtime = peer->holdtime;\n  else\n    send_holdtime = peer->bgp->default_holdtime;\n\n  if (holdtime < send_holdtime)\n    peer->v_holdtime = holdtime;\n  else\n    peer->v_holdtime = send_holdtime;\n\n  peer->v_keepalive = peer->v_holdtime \/ 3;\n\n  \/* Open option part parse. *\/\n  capability = 0;\n  optlen = stream_getc (peer->ibuf);\n  if (optlen != 0) \n    {\n      ret = bgp_open_option_parse (peer, optlen, &capability);\n      if (ret < 0)\n\treturn ret;\n    }\n  else\n    {\n      if (BGP_DEBUG (normal, NORMAL))\n\tzlog_debug (\"%s rcvd OPEN w\/ OPTION parameter len: 0\",\n\t\t   peer->host);\n    }\n\n  \/* Override capability. *\/\n  if (! capability || CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))\n    {\n      peer->afc_nego[AFI_IP][SAFI_UNICAST] = peer->afc[AFI_IP][SAFI_UNICAST];\n      peer->afc_nego[AFI_IP][SAFI_MULTICAST] = peer->afc[AFI_IP][SAFI_MULTICAST];\n      peer->afc_nego[AFI_IP6][SAFI_UNICAST] = peer->afc[AFI_IP6][SAFI_UNICAST];\n      peer->afc_nego[AFI_IP6][SAFI_MULTICAST] = peer->afc[AFI_IP6][SAFI_MULTICAST];\n    }\n\n  \/* Get sockname. *\/\n  bgp_getsockname (peer);\n\n  BGP_EVENT_ADD (peer, Receive_OPEN_message);\n\n  peer->packet_size = 0;\n  if (peer->ibuf)\n    stream_reset (peer->ibuf);\n\n  return 0;\n}","target":0,"code_token_length":2040,"total_token_length":2276,"max_tokens_setting":4096}
+{"idx":202892,"func":"void dostor(char *name, const int append, const int autorename)\n{\n    ULHandler ulhandler;\n    int f;\n    const char *ul_name = NULL;\n    const char *atomic_file = NULL;\n    off_t filesize = (off_t) 0U;\n    struct stat st;\n    double started = 0.0;\n    signed char overwrite = 0;\n    int overflow = 0;\n    int ret = -1;\n    off_t max_filesize = (off_t) -1;\n#ifdef QUOTAS\n    Quota quota;\n#endif\n    const char *name2 = NULL;\n\n    if (type < 1 || (type == 1 && restartat > (off_t) 1)) {\n        addreply_noformat(503, MSG_NO_ASCII_RESUME);\n        goto end;\n    }\n#ifndef ANON_CAN_RESUME\n    if (guest != 0 && anon_noupload != 0) {\n        addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);\n        goto end;\n    }\n#endif\n    if (ul_check_free_space(name, -1.0) == 0) {\n        addreply_noformat(552, MSG_NO_DISK_SPACE);\n        goto end;\n    }\n    if (checknamesanity(name, dot_write_ok) != 0) {\n        addreply(553, MSG_SANITY_FILE_FAILURE, name);\n        goto end;\n    }\n    if (autorename != 0) {\n        no_truncate = 1;\n    }\n    if (restartat > (off_t) 0 || no_truncate != 0) {\n        if ((atomic_file = get_atomic_file(name)) == NULL) {\n            addreply(553, MSG_SANITY_FILE_FAILURE, name);\n            goto end;\n        }\n        if (restartat > (off_t) 0 &&\n            rename(name, atomic_file) != 0 && errno != ENOENT) {\n            error(553, MSG_RENAME_FAILURE);\n            atomic_file = NULL;\n            goto end;\n        }\n    }\n    if (atomic_file != NULL) {\n        ul_name = atomic_file;\n    } else {\n        ul_name = name;\n    }\n    if (atomic_file == NULL &&\n        (f = open(ul_name, O_WRONLY | O_NOFOLLOW)) != -1) {\n        overwrite++;\n    } else if ((f = open(ul_name, O_CREAT | O_WRONLY | O_NOFOLLOW,\n                         (mode_t) 0777 & ~u_mask)) == -1) {\n        error(553, MSG_OPEN_FAILURE2);\n        goto end;\n    }\n    if (fstat(f, &st) < 0) {\n        (void) close(f);\n        error(553, MSG_STAT_FAILURE2);\n        goto end;\n    }\n    if (!S_ISREG(st.st_mode)) {\n        (void) close(f);\n        addreply_noformat(550, MSG_NOT_REGULAR_FILE);\n        goto end;\n    }\n    alarm(MAX_SESSION_XFER_IDLE);\n\n    \/* Anonymous users *CAN* overwrite 0-bytes files - This is the right behavior *\/\n    if (st.st_size > (off_t) 0) {\n#ifndef ANON_CAN_RESUME\n        if (guest != 0) {\n            addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);\n            (void) close(f);\n            goto end;\n        }\n#endif\n        if (append != 0) {\n            restartat = st.st_size;\n        }\n    } else {\n        restartat = (off_t) 0;\n    }\n    if (restartat > st.st_size) {\n        restartat = st.st_size;\n    }\n    if (restartat > (off_t) 0 && lseek(f, restartat, SEEK_SET) < (off_t) 0) {\n        (void) close(f);\n        error(451, \"seek\");\n        goto end;\n    }\n    if (restartat < st.st_size) {\n        if (ftruncate(f, restartat) < 0) {\n            (void) close(f);\n            error(451, \"ftruncate\");\n            goto end;\n        }\n#ifdef QUOTAS\n        if (restartat != st.st_size) {\n            (void) quota_update(NULL, 0LL,\n                                (long long) (restartat - st.st_size),\n                                &overflow);\n        }\n#endif\n    }\n#ifdef QUOTAS\n    if (quota_update("a, 0LL, 0LL, &overflow) == 0 &&\n        (overflow > 0 || quota.files >= user_quota_files ||\n         quota.size > user_quota_size ||\n         (max_filesize >= (off_t) 0 &&\n          (max_filesize = user_quota_size - quota.size) < (off_t) 0))) {\n        overflow = 1;\n        (void) close(f);\n        goto afterquota;\n    }\n#endif\n    opendata();\n    if (xferfd == -1) {\n        (void) close(f);\n        goto end;\n    }\n    doreply();\n# ifdef WITH_TLS\n    if (data_protection_level == CPL_PRIVATE) {\n        tls_init_data_session(xferfd, passive);\n    }\n# endif\n    state_needs_update = 1;\n    setprocessname(\"pure-ftpd (UPLOAD)\");\n    filesize = restartat;\n\n#ifdef FTPWHO\n    if (shm_data_cur != NULL) {\n        const size_t sl = strlen(name);\n\n        ftpwho_lock();\n        shm_data_cur->state = FTPWHO_STATE_UPLOAD;\n        shm_data_cur->download_total_size = (off_t) 0U;\n        shm_data_cur->download_current_size = (off_t) filesize;\n        shm_data_cur->restartat = restartat;\n        (void) time(&shm_data_cur->xfer_date);\n        if (sl < sizeof shm_data_cur->filename) {\n            memcpy(shm_data_cur->filename, name, sl);\n            shm_data_cur->filename[sl] = 0;\n        } else {\n            memcpy(shm_data_cur->filename,\n                   &name[sl - sizeof shm_data_cur->filename - 1U],\n                   sizeof shm_data_cur->filename);\n        }\n        ftpwho_unlock();\n    }\n#endif\n\n    \/* Here starts the real upload code *\/\n\n    started = get_usec_time();\n\n    if (ul_init(&ulhandler, clientfd, tls_cnx, xferfd, name, f, tls_data_cnx,\n                restartat, type == 1, throttling_bandwidth_ul,\n                max_filesize) == 0) {\n        ret = ul_send(&ulhandler);\n        ul_exit(&ulhandler);\n    } else {\n        ret = -1;\n    }\n    (void) close(f);\n    closedata();\n\n    \/* Here ends the real upload code *\/\n\n#ifdef SHOW_REAL_DISK_SPACE\n    if (FSTATFS(f, &statfsbuf) == 0) {\n        double space;\n\n        space = (double) STATFS_BAVAIL(statfsbuf) *\n            (double) STATFS_FRSIZE(statfsbuf);\n        if (space > 524288.0) {\n            addreply(0, MSG_SPACE_FREE_M, space \/ 1048576.0);\n        } else {\n            addreply(0, MSG_SPACE_FREE_K, space \/ 1024.0);\n        }\n    }\n#endif\n\n    uploaded += (unsigned long long) ulhandler.total_uploaded;\n    {\n        off_t atomic_file_size;\n        off_t original_file_size;\n        int files_count;\n\n        if (overwrite == 0) {\n            files_count = 1;\n        } else {\n            files_count = 0;\n        }\n        if (autorename != 0 && restartat == (off_t) 0) {\n            if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {\n                goto afterquota;\n            }\n            if (tryautorename(atomic_file, name, &name2) != 0) {\n                error(553, MSG_RENAME_FAILURE);\n                goto afterquota;\n            } else {\n#ifdef QUOTAS\n                ul_quota_update(name2 ? name2 : name, 1, atomic_file_size);\n#endif\n                atomic_file = NULL;\n            }\n        } else if (atomic_file != NULL) {\n            if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {\n                goto afterquota;\n            }\n            if ((original_file_size = get_file_size(name)) < (off_t) 0 ||\n                restartat > original_file_size) {\n                original_file_size = restartat;\n            }\n            if (rename(atomic_file, name) != 0) {\n                error(553, MSG_RENAME_FAILURE);\n                goto afterquota;\n            } else {\n#ifdef QUOTAS\n                overflow = ul_quota_update\n                    (name, files_count, atomic_file_size - original_file_size);\n#endif\n                atomic_file = NULL;\n            }\n        } else {\n#ifdef QUOTAS\n            overflow = ul_quota_update\n                (name, files_count, ulhandler.total_uploaded);\n#endif\n        }\n    }\n    afterquota:\n    if (overflow > 0) {\n        addreply(552, MSG_QUOTA_EXCEEDED, name);\n    } else {\n        if (ret == 0) {\n            addreply_noformat(226, MSG_TRANSFER_SUCCESSFUL);\n        } else {\n            addreply_noformat(451, MSG_ABORTED);\n        }\n        displayrate(MSG_UPLOADED, ulhandler.total_uploaded, started,\n                    name2 ? name2 : name, 1);\n    }\n    end:\n    restartat = (off_t) 0;\n    if (atomic_file != NULL) {\n        unlink(atomic_file);\n        atomic_file = NULL;\n    }\n}","target":1,"code_token_length":2102,"total_token_length":2338,"max_tokens_setting":4096}
+{"idx":473999,"func":"parse_enclose(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,\n\t      ScanEnv* env)\n{\n  int r, num;\n  Node *target;\n  OnigOptionType option;\n  OnigCodePoint c;\n  OnigEncoding enc = env->enc;\n\n#ifdef USE_NAMED_GROUP\n  int list_capture;\n#endif\n\n  UChar* p = *src;\n  PFETCH_READY;\n\n  *np = NULL;\n  if (PEND) return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS;\n\n  option = env->option;\n  if (PPEEK_IS('?') &&\n      IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {\n    PINC;\n    if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;\n\n    PFETCH(c);\n    switch (c) {\n    case ':':   \/* (?:...) grouping only *\/\n    group:\n      r = fetch_token(tok, &p, end, env);\n      if (r < 0) return r;\n      r = parse_subexp(np, tok, term, &p, end, env);\n      if (r < 0) return r;\n      *src = p;\n      return 1; \/* group *\/\n      break;\n\n    case '=':\n      *np = onig_node_new_anchor(ANCHOR_PREC_READ);\n      break;\n    case '!':  \/*         preceding read *\/\n      *np = onig_node_new_anchor(ANCHOR_PREC_READ_NOT);\n      break;\n    case '>':            \/* (?>...) stop backtrack *\/\n      *np = node_new_enclose(ENCLOSE_STOP_BACKTRACK);\n      break;\n\n#ifdef USE_NAMED_GROUP\n    case '\\'':\n      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {\n\tgoto named_group1;\n      }\n      else\n\treturn ONIGERR_UNDEFINED_GROUP_OPTION;\n      break;\n#endif\n\n    case '<':   \/* look behind (?<=...), (?<!...) *\/\n      PFETCH(c);\n      if (c == '=')\n\t*np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND);\n      else if (c == '!')\n\t*np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND_NOT);\n#ifdef USE_NAMED_GROUP\n      else {\n\tif (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {\n\t  UChar *name;\n\t  UChar *name_end;\n\n\t  PUNFETCH;\n\t  c = '<';\n\n\tnamed_group1:\n\t  list_capture = 0;\n\n\tnamed_group2:\n\t  name = p;\n\t  r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &num, 0);\n\t  if (r < 0) return r;\n\n\t  num = scan_env_add_mem_entry(env);\n\t  if (num < 0) return num;\n\t  if (list_capture != 0 && num >= (int )BIT_STATUS_BITS_NUM)\n\t    return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;\n\n\t  r = name_add(env->reg, name, name_end, num, env);\n\t  if (r != 0) return r;\n\t  *np = node_new_enclose_memory(env->option, 1);\n\t  CHECK_NULL_RETURN_MEMERR(*np);\n\t  NENCLOSE(*np)->regnum = num;\n\t  if (list_capture != 0)\n\t    BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);\n\t  env->num_named++;\n\t}\n\telse {\n\t  return ONIGERR_UNDEFINED_GROUP_OPTION;\n\t}\n      }\n#else\n      else {\n\treturn ONIGERR_UNDEFINED_GROUP_OPTION;\n      }\n#endif\n      break;\n\n    case '@':\n      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY)) {\n#ifdef USE_NAMED_GROUP\n\tif (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {\n\t  PFETCH(c);\n\t  if (c == '<' || c == '\\'') {\n\t    list_capture = 1;\n\t    goto named_group2; \/* (?@<name>...) *\/\n\t  }\n\t  PUNFETCH;\n\t}\n#endif\n\t*np = node_new_enclose_memory(env->option, 0);\n\tCHECK_NULL_RETURN_MEMERR(*np);\n\tnum = scan_env_add_mem_entry(env);\n\tif (num < 0) {\n\t  onig_node_free(*np);\n\t  return num;\n\t}\n\telse if (num >= (int )BIT_STATUS_BITS_NUM) {\n\t  onig_node_free(*np);\n\t  return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;\n\t}\n\tNENCLOSE(*np)->regnum = num;\n\tBIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);\n      }\n      else {\n\treturn ONIGERR_UNDEFINED_GROUP_OPTION;\n      }\n      break;\n\n#ifdef USE_POSIXLINE_OPTION\n    case 'p':\n#endif\n    case '-': case 'i': case 'm': case 's': case 'x':\n      {\n\tint neg = 0;\n\n\twhile (1) {\n\t  switch (c) {\n\t  case ':':\n\t  case ')':\n\t  break;\n\n\t  case '-':  neg = 1; break;\n\t  case 'x':  ONOFF(option, ONIG_OPTION_EXTEND,     neg); break;\n\t  case 'i':  ONOFF(option, ONIG_OPTION_IGNORECASE, neg); break;\n\t  case 's':\n\t    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {\n\t      ONOFF(option, ONIG_OPTION_MULTILINE,  neg);\n\t    }\n\t    else\n\t      return ONIGERR_UNDEFINED_GROUP_OPTION;\n\t    break;\n\n\t  case 'm':\n\t    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {\n\t      ONOFF(option, ONIG_OPTION_SINGLELINE, (neg == 0 ? 1 : 0));\n\t    }\n\t    else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) {\n\t      ONOFF(option, ONIG_OPTION_MULTILINE,  neg);\n\t    }\n\t    else\n\t      return ONIGERR_UNDEFINED_GROUP_OPTION;\n\t    break;\n#ifdef USE_POSIXLINE_OPTION\n\t  case 'p':\n\t    ONOFF(option, ONIG_OPTION_MULTILINE|ONIG_OPTION_SINGLELINE, neg);\n\t    break;\n#endif\n\t  default:\n\t    return ONIGERR_UNDEFINED_GROUP_OPTION;\n\t  }\n\n\t  if (c == ')') {\n\t    *np = node_new_option(option);\n\t    CHECK_NULL_RETURN_MEMERR(*np);\n\t    *src = p;\n\t    return 2; \/* option only *\/\n\t  }\n\t  else if (c == ':') {\n\t    OnigOptionType prev = env->option;\n\n\t    env->option     = option;\n\t    r = fetch_token(tok, &p, end, env);\n\t    if (r < 0) return r;\n\t    r = parse_subexp(&target, tok, term, &p, end, env);\n\t    env->option = prev;\n\t    if (r < 0) return r;\n\t    *np = node_new_option(option);\n\t    CHECK_NULL_RETURN_MEMERR(*np);\n\t    NENCLOSE(*np)->target = target;\n\t    *src = p;\n\t    return 0;\n\t  }\n\n\t  if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;\n\t  PFETCH(c);\n\t}\n      }\n      break;\n\n    default:\n      return ONIGERR_UNDEFINED_GROUP_OPTION;\n    }\n  }\n  else {\n    if (ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_DONT_CAPTURE_GROUP))\n      goto group;\n\n    *np = node_new_enclose_memory(env->option, 0);\n    CHECK_NULL_RETURN_MEMERR(*np);\n    num = scan_env_add_mem_entry(env);\n    if (num < 0) return num;\n    NENCLOSE(*np)->regnum = num;\n  }\n\n  CHECK_NULL_RETURN_MEMERR(*np);\n  r = fetch_token(tok, &p, end, env);\n  if (r < 0) return r;\n  r = parse_subexp(&target, tok, term, &p, end, env);\n  if (r < 0) {\n    onig_node_free(target);\n    return r;\n  }\n\n  if (NTYPE(*np) == NT_ANCHOR)\n    NANCHOR(*np)->target = target;\n  else {\n    NENCLOSE(*np)->target = target;\n    if (NENCLOSE(*np)->type == ENCLOSE_MEMORY) {\n      \/* Don't move this to previous of parse_subexp() *\/\n      r = scan_env_set_mem_node(env, NENCLOSE(*np)->regnum, *np);\n      if (r != 0) return r;\n    }\n  }\n\n  *src = p;\n  return 0;\n}","target":0,"code_token_length":1851,"total_token_length":2087,"max_tokens_setting":4096}
+{"idx":437327,"func":"optimize_nodes(Node* node, NodeOpt* opt, OptEnv* env)\n{\n  int i;\n  int r;\n  NodeOpt xo;\n  OnigEncoding enc;\n\n  r = 0;\n  enc = env->enc;\n  clear_node_opt_info(opt);\n  set_bound_node_opt_info(opt, &env->mmd);\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n    {\n      OptEnv nenv;\n      Node* nd = node;\n\n      copy_opt_env(&nenv, env);\n      do {\n        r = optimize_nodes(NODE_CAR(nd), &xo, &nenv);\n        if (r == 0) {\n          add_mml(&nenv.mmd, &xo.len);\n          concat_left_node_opt_info(enc, opt, &xo);\n        }\n      } while (r == 0 && IS_NOT_NULL(nd = NODE_CDR(nd)));\n    }\n    break;\n\n  case NODE_ALT:\n    {\n      Node* nd = node;\n\n      do {\n        r = optimize_nodes(NODE_CAR(nd), &xo, env);\n        if (r == 0) {\n          if (nd == node) copy_node_opt_info(opt, &xo);\n          else            alt_merge_node_opt_info(opt, &xo, env);\n        }\n      } while ((r == 0) && IS_NOT_NULL(nd = NODE_CDR(nd)));\n    }\n    break;\n\n  case NODE_STRING:\n    {\n      StrNode* sn = STR_(node);\n      int slen = (int )(sn->end - sn->s);\n      \/* int is_raw = NODE_STRING_IS_RAW(node); *\/\n\n      if (! NODE_STRING_IS_AMBIG(node)) {\n        concat_opt_exact_str(&opt->exb, sn->s, sn->end, enc);\n        if (slen > 0) {\n          add_char_opt_map(&opt->map, *(sn->s), enc);\n        }\n        set_mml(&opt->len, slen, slen);\n      }\n      else {\n        int max;\n\n        if (NODE_STRING_IS_DONT_GET_OPT_INFO(node)) {\n          int n = onigenc_strlen(enc, sn->s, sn->end);\n          max = ONIGENC_MBC_MAXLEN_DIST(enc) * n;\n        }\n        else {\n          concat_opt_exact_str(&opt->exb, sn->s, sn->end, enc);\n          opt->exb.ignore_case = 1;\n\n          if (slen > 0) {\n            r = add_char_amb_opt_map(&opt->map, sn->s, sn->end,\n                                     enc, env->case_fold_flag);\n            if (r != 0) break;\n          }\n\n          max = slen;\n        }\n\n        set_mml(&opt->len, slen, max);\n      }\n\n      if (opt->exb.len == slen)\n        opt->exb.reach_end = 1;\n    }\n    break;\n\n  case NODE_CCLASS:\n    {\n      int z;\n      CClassNode* cc = CCLASS_(node);\n\n      \/* no need to check ignore case. (set in setup_tree()) *\/\n\n      if (IS_NOT_NULL(cc->mbuf) || IS_NCCLASS_NOT(cc)) {\n        OnigLen min = ONIGENC_MBC_MINLEN(enc);\n        OnigLen max = ONIGENC_MBC_MAXLEN_DIST(enc);\n\n        set_mml(&opt->len, min, max);\n      }\n      else {\n        for (i = 0; i < SINGLE_BYTE_SIZE; i++) {\n          z = BITSET_AT(cc->bs, i);\n          if ((z && ! IS_NCCLASS_NOT(cc)) || (! z && IS_NCCLASS_NOT(cc))) {\n            add_char_opt_map(&opt->map, (UChar )i, enc);\n          }\n        }\n        set_mml(&opt->len, 1, 1);\n      }\n    }\n    break;\n\n  case NODE_CTYPE:\n    {\n      int min, max;\n      int range;\n\n      max = ONIGENC_MBC_MAXLEN_DIST(enc);\n\n      if (max == 1) {\n        min = 1;\n\n        switch (CTYPE_(node)->ctype) {\n        case CTYPE_ANYCHAR:\n          break;\n\n        case ONIGENC_CTYPE_WORD:\n          range = CTYPE_(node)->ascii_mode != 0 ? 128 : SINGLE_BYTE_SIZE;\n          if (CTYPE_(node)->not != 0) {\n            for (i = 0; i < range; i++) {\n              if (! ONIGENC_IS_CODE_WORD(enc, i)) {\n                add_char_opt_map(&opt->map, (UChar )i, enc);\n              }\n            }\n            for (i = range; i < SINGLE_BYTE_SIZE; i++) {\n              add_char_opt_map(&opt->map, (UChar )i, enc);\n            }\n          }\n          else {\n            for (i = 0; i < range; i++) {\n              if (ONIGENC_IS_CODE_WORD(enc, i)) {\n                add_char_opt_map(&opt->map, (UChar )i, enc);\n              }\n            }\n          }\n          break;\n        }\n      }\n      else {\n        min = ONIGENC_MBC_MINLEN(enc);\n      }\n      set_mml(&opt->len, min, max);\n    }\n    break;\n\n  case NODE_ANCHOR:\n    switch (ANCHOR_(node)->type) {\n    case ANCHOR_BEGIN_BUF:\n    case ANCHOR_BEGIN_POSITION:\n    case ANCHOR_BEGIN_LINE:\n    case ANCHOR_END_BUF:\n    case ANCHOR_SEMI_END_BUF:\n    case ANCHOR_END_LINE:\n    case ANCHOR_PREC_READ_NOT:\n    case ANCHOR_LOOK_BEHIND:\n      add_opt_anc_info(&opt->anc, ANCHOR_(node)->type);\n      break;\n\n    case ANCHOR_PREC_READ:\n      {\n        r = optimize_nodes(NODE_BODY(node), &xo, env);\n        if (r == 0) {\n          if (xo.exb.len > 0)\n            copy_opt_exact(&opt->expr, &xo.exb);\n          else if (xo.exm.len > 0)\n            copy_opt_exact(&opt->expr, &xo.exm);\n\n          opt->expr.reach_end = 0;\n\n          if (xo.map.value > 0)\n            copy_opt_map(&opt->map, &xo.map);\n        }\n      }\n      break;\n\n    case ANCHOR_LOOK_BEHIND_NOT:\n      break;\n    }\n    break;\n\n  case NODE_BACKREF:\n    if (! NODE_IS_CHECKER(node)) {\n      int* backs;\n      OnigLen min, max, tmin, tmax;\n      MemEnv* mem_env = SCANENV_MEMENV(env->scan_env);\n      BackRefNode* br = BACKREF_(node);\n\n      if (NODE_IS_RECURSION(node)) {\n        set_mml(&opt->len, 0, INFINITE_LEN);\n        break;\n      }\n      backs = BACKREFS_P(br);\n      min = tree_min_len(mem_env[backs[0]].node, env->scan_env);\n      max = tree_max_len(mem_env[backs[0]].node, env->scan_env);\n      for (i = 1; i < br->back_num; i++) {\n        tmin = tree_min_len(mem_env[backs[i]].node, env->scan_env);\n        tmax = tree_max_len(mem_env[backs[i]].node, env->scan_env);\n        if (min > tmin) min = tmin;\n        if (max < tmax) max = tmax;\n      }\n      set_mml(&opt->len, min, max);\n    }\n    break;\n\n#ifdef USE_CALL\n  case NODE_CALL:\n    if (NODE_IS_RECURSION(node))\n      set_mml(&opt->len, 0, INFINITE_LEN);\n    else {\n      OnigOptionType save = env->options;\n      env->options = ENCLOSURE_(NODE_BODY(node))->o.options;\n      r = optimize_nodes(NODE_BODY(node), opt, env);\n      env->options = save;\n    }\n    break;\n#endif\n\n  case NODE_QUANT:\n    {\n      OnigLen min, max;\n      QuantNode* qn = QUANT_(node);\n\n      r = optimize_nodes(NODE_BODY(node), &xo, env);\n      if (r != 0) break;\n\n      if (qn->lower > 0) {\n        copy_node_opt_info(opt, &xo);\n        if (xo.exb.len > 0) {\n          if (xo.exb.reach_end) {\n            for (i = 2; i <= qn->lower && ! is_full_opt_exact(&opt->exb); i++) {\n              int rc = concat_opt_exact(&opt->exb, &xo.exb, enc);\n              if (rc > 0) break;\n            }\n            if (i < qn->lower) opt->exb.reach_end = 0;\n          }\n        }\n\n        if (qn->lower != qn->upper) {\n          opt->exb.reach_end = 0;\n          opt->exm.reach_end = 0;\n        }\n        if (qn->lower > 1)\n          opt->exm.reach_end = 0;\n      }\n\n      if (IS_REPEAT_INFINITE(qn->upper)) {\n        if (env->mmd.max == 0 &&\n            NODE_IS_ANYCHAR(NODE_BODY(node)) && qn->greedy != 0) {\n          if (IS_MULTILINE(CTYPE_OPTION(NODE_QUANT_BODY(qn), env)))\n            add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF_ML);\n          else\n            add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF);\n        }\n\n        max = (xo.len.max > 0 ? INFINITE_LEN : 0);\n      }\n      else {\n        max = distance_multiply(xo.len.max, qn->upper);\n      }\n\n      min = distance_multiply(xo.len.min, qn->lower);\n      set_mml(&opt->len, min, max);\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      switch (en->type) {\n      case ENCLOSURE_OPTION:\n        {\n          OnigOptionType save = env->options;\n\n          env->options = en->o.options;\n          r = optimize_nodes(NODE_BODY(node), opt, env);\n          env->options = save;\n        }\n        break;\n\n      case ENCLOSURE_MEMORY:\n#ifdef USE_CALL\n        en->opt_count++;\n        if (en->opt_count > MAX_NODE_OPT_INFO_REF_COUNT) {\n          OnigLen min, max;\n\n          min = 0;\n          max = INFINITE_LEN;\n          if (NODE_IS_MIN_FIXED(node)) min = en->min_len;\n          if (NODE_IS_MAX_FIXED(node)) max = en->max_len;\n          set_mml(&opt->len, min, max);\n        }\n        else\n#endif\n          {\n            r = optimize_nodes(NODE_BODY(node), opt, env);\n            if (is_set_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF_MASK)) {\n              if (MEM_STATUS_AT0(env->scan_env->backrefed_mem, en->m.regnum))\n                remove_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF_MASK);\n            }\n          }\n        break;\n\n      case ENCLOSURE_STOP_BACKTRACK:\n        r = optimize_nodes(NODE_BODY(node), opt, env);\n        break;\n\n      case ENCLOSURE_IF_ELSE:\n        {\n          OptEnv nenv;\n\n          copy_opt_env(&nenv, env);\n          r = optimize_nodes(NODE_ENCLOSURE_BODY(en), &xo, &nenv);\n          if (r == 0) {\n            add_mml(&nenv.mmd, &xo.len);\n            concat_left_node_opt_info(enc, opt, &xo);\n            if (IS_NOT_NULL(en->te.Then)) {\n              r = optimize_nodes(en->te.Then, &xo, &nenv);\n              if (r == 0) {\n                concat_left_node_opt_info(enc, opt, &xo);\n              }\n            }\n\n            if (IS_NOT_NULL(en->te.Else)) {\n              r = optimize_nodes(en->te.Else, &xo, env);\n              if (r == 0)\n                alt_merge_node_opt_info(opt, &xo, env);\n            }\n          }\n        }\n        break;\n      }\n    }\n    break;\n\n  case NODE_GIMMICK:\n    break;\n\n  default:\n#ifdef ONIG_DEBUG\n    fprintf(stderr, \"optimize_nodes: undefined node type %d\\n\", NODE_TYPE(node));\n#endif\n    r = ONIGERR_TYPE_BUG;\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":2707,"total_token_length":2943,"max_tokens_setting":4096}
+{"idx":449297,"func":"nv_ident(cmdarg_T *cap)\n{\n    char_u\t*ptr = NULL;\n    char_u\t*buf;\n    unsigned\tbuflen;\n    char_u\t*newbuf;\n    char_u\t*p;\n    char_u\t*kp;\t\t\/\/ value of 'keywordprg'\n    int\t\tkp_help;\t\/\/ 'keywordprg' is \":he\"\n    int\t\tkp_ex;\t\t\/\/ 'keywordprg' starts with \":\"\n    int\t\tn = 0;\t\t\/\/ init for GCC\n    int\t\tcmdchar;\n    int\t\tg_cmd;\t\t\/\/ \"g\" command\n    int\t\ttag_cmd = FALSE;\n    char_u\t*aux_ptr;\n    int\t\tisman;\n    int\t\tisman_s;\n\n    if (cap->cmdchar == 'g')\t\/\/ \"g*\", \"g#\", \"g]\" and \"gCTRL-]\"\n    {\n\tcmdchar = cap->nchar;\n\tg_cmd = TRUE;\n    }\n    else\n    {\n\tcmdchar = cap->cmdchar;\n\tg_cmd = FALSE;\n    }\n\n    if (cmdchar == POUND)\t\/\/ the pound sign, '#' for English keyboards\n\tcmdchar = '#';\n\n    \/*\n     * The \"]\", \"CTRL-]\" and \"K\" commands accept an argument in Visual mode.\n     *\/\n    if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K')\n    {\n\tif (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL)\n\t    return;\n\tif (checkclearopq(cap->oap))\n\t    return;\n    }\n\n    if (ptr == NULL && (n = find_ident_under_cursor(&ptr,\n\t\t    (cmdchar == '*' || cmdchar == '#')\n\t\t\t\t ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0)\n    {\n\tclearop(cap->oap);\n\treturn;\n    }\n\n    \/\/ Allocate buffer to put the command in.  Inserting backslashes can\n    \/\/ double the length of the word.  p_kp \/ curbuf->b_p_kp could be added\n    \/\/ and some numbers.\n    kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp);\n    kp_help = (*kp == NUL || STRCMP(kp, \":he\") == 0\n\t\t\t\t\t\t || STRCMP(kp, \":help\") == 0);\n    if (kp_help && *skipwhite(ptr) == NUL)\n    {\n\temsg(_(e_noident));\t \/\/ found white space only\n\treturn;\n    }\n    kp_ex = (*kp == ':');\n    buflen = (unsigned)(n * 2 + 30 + STRLEN(kp));\n    buf = alloc(buflen);\n    if (buf == NULL)\n\treturn;\n    buf[0] = NUL;\n\n    switch (cmdchar)\n    {\n\tcase '*':\n\tcase '#':\n\t    \/*\n\t     * Put cursor at start of word, makes search skip the word\n\t     * under the cursor.\n\t     * Call setpcmark() first, so \"*``\" puts the cursor back where\n\t     * it was.\n\t     *\/\n\t    setpcmark();\n\t    curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline());\n\n\t    if (!g_cmd && vim_iswordp(ptr))\n\t\tSTRCPY(buf, \"\\\\<\");\n\t    no_smartcase = TRUE;\t\/\/ don't use 'smartcase' now\n\t    break;\n\n\tcase 'K':\n\t    if (kp_help)\n\t\tSTRCPY(buf, \"he! \");\n\t    else if (kp_ex)\n\t    {\n\t\tif (cap->count0 != 0)\n\t\t    vim_snprintf((char *)buf, buflen, \"%s %ld\",\n\t\t\t\t\t\t\t     kp, cap->count0);\n\t\telse\n\t\t    STRCPY(buf, kp);\n\t\tSTRCAT(buf, \" \");\n\t    }\n\t    else\n\t    {\n\t\t\/\/ An external command will probably use an argument starting\n\t\t\/\/ with \"-\" as an option.  To avoid trouble we skip the \"-\".\n\t\twhile (*ptr == '-' && n > 0)\n\t\t{\n\t\t    ++ptr;\n\t\t    --n;\n\t\t}\n\t\tif (n == 0)\n\t\t{\n\t\t    emsg(_(e_noident));\t \/\/ found dashes only\n\t\t    vim_free(buf);\n\t\t    return;\n\t\t}\n\n\t\t\/\/ When a count is given, turn it into a range.  Is this\n\t\t\/\/ really what we want?\n\t\tisman = (STRCMP(kp, \"man\") == 0);\n\t\tisman_s = (STRCMP(kp, \"man -s\") == 0);\n\t\tif (cap->count0 != 0 && !(isman || isman_s))\n\t\t    sprintf((char *)buf, \".,.+%ld\", cap->count0 - 1);\n\n\t\tSTRCAT(buf, \"! \");\n\t\tif (cap->count0 == 0 && isman_s)\n\t\t    STRCAT(buf, \"man\");\n\t\telse\n\t\t    STRCAT(buf, kp);\n\t\tSTRCAT(buf, \" \");\n\t\tif (cap->count0 != 0 && (isman || isman_s))\n\t\t{\n\t\t    sprintf((char *)buf + STRLEN(buf), \"%ld\", cap->count0);\n\t\t    STRCAT(buf, \" \");\n\t\t}\n\t    }\n\t    break;\n\n\tcase ']':\n\t    tag_cmd = TRUE;\n#ifdef FEAT_CSCOPE\n\t    if (p_cst)\n\t\tSTRCPY(buf, \"cstag \");\n\t    else\n#endif\n\t\tSTRCPY(buf, \"ts \");\n\t    break;\n\n\tdefault:\n\t    tag_cmd = TRUE;\n\t    if (curbuf->b_help)\n\t\tSTRCPY(buf, \"he! \");\n\t    else\n\t    {\n\t\tif (g_cmd)\n\t\t    STRCPY(buf, \"tj \");\n\t\telse if (cap->count0 == 0)\n\t\t    STRCPY(buf, \"ta \");\n\t\telse\n\t\t    sprintf((char *)buf, \":%ldta \", cap->count0);\n\t    }\n    }\n\n    \/*\n     * Now grab the chars in the identifier\n     *\/\n    if (cmdchar == 'K' && !kp_help)\n    {\n\tptr = vim_strnsave(ptr, n);\n\tif (kp_ex)\n\t    \/\/ Escape the argument properly for an Ex command\n\t    p = vim_strsave_fnameescape(ptr, VSE_NONE);\n\telse\n\t    \/\/ Escape the argument properly for a shell command\n\t    p = vim_strsave_shellescape(ptr, TRUE, TRUE);\n\tvim_free(ptr);\n\tif (p == NULL)\n\t{\n\t    vim_free(buf);\n\t    return;\n\t}\n\tnewbuf = vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);\n\tif (newbuf == NULL)\n\t{\n\t    vim_free(buf);\n\t    vim_free(p);\n\t    return;\n\t}\n\tbuf = newbuf;\n\tSTRCAT(buf, p);\n\tvim_free(p);\n    }\n    else\n    {\n\tif (cmdchar == '*')\n\t    aux_ptr = (char_u *)(magic_isset() ? \"\/.*~[^$\\\\\" : \"\/^$\\\\\");\n\telse if (cmdchar == '#')\n\t    aux_ptr = (char_u *)(magic_isset() ? \"\/?.*~[^$\\\\\" : \"\/?^$\\\\\");\n\telse if (tag_cmd)\n\t{\n\t    if (curbuf->b_help)\n\t\t\/\/ \":help\" handles unescaped argument\n\t\taux_ptr = (char_u *)\"\";\n\t    else\n\t\taux_ptr = (char_u *)\"\\\\|\\\"\\n[\";\n\t}\n\telse\n\t    aux_ptr = (char_u *)\"\\\\|\\\"\\n*?[\";\n\n\tp = buf + STRLEN(buf);\n\twhile (n-- > 0)\n\t{\n\t    \/\/ put a backslash before \\ and some others\n\t    if (vim_strchr(aux_ptr, *ptr) != NULL)\n\t\t*p++ = '\\\\';\n\t    \/\/ When current byte is a part of multibyte character, copy all\n\t    \/\/ bytes of that character.\n\t    if (has_mbyte)\n\t    {\n\t\tint i;\n\t\tint len = (*mb_ptr2len)(ptr) - 1;\n\n\t\tfor (i = 0; i < len && n >= 1; ++i, --n)\n\t\t    *p++ = *ptr++;\n\t    }\n\t    *p++ = *ptr++;\n\t}\n\t*p = NUL;\n    }\n\n    \/*\n     * Execute the command.\n     *\/\n    if (cmdchar == '*' || cmdchar == '#')\n    {\n\tif (!g_cmd && (has_mbyte\n\t\t    ? vim_iswordp(mb_prevptr(ml_get_curline(), ptr))\n\t\t    : vim_iswordc(ptr[-1])))\n\t    STRCAT(buf, \"\\\\>\");\n\n\t\/\/ put pattern in search history\n\tinit_history();\n\tadd_to_history(HIST_SEARCH, buf, TRUE, NUL);\n\n\t(void)normal_search(cap, cmdchar == '*' ? '\/' : '?', buf, 0, NULL);\n    }\n    else\n    {\n\tg_tag_at_cursor = TRUE;\n\tdo_cmdline_cmd(buf);\n\tg_tag_at_cursor = FALSE;\n    }\n\n    vim_free(buf);\n}","target":0,"code_token_length":1913,"total_token_length":2149,"max_tokens_setting":4096}
+{"idx":223394,"func":"static void compile_ref_matchingpath(compiler_common *common, PCRE2_SPTR cc, jump_list **backtracks, BOOL withchecks, BOOL emptyfail)\n{\nDEFINE_COMPILER;\nBOOL ref = (*cc == OP_REF || *cc == OP_REFI);\nint offset = 0;\nstruct sljit_jump *jump = NULL;\nstruct sljit_jump *partial;\nstruct sljit_jump *nopartial;\n#if defined SUPPORT_UNICODE\nstruct sljit_label *loop;\nstruct sljit_label *caseless_loop;\njump_list *no_match = NULL;\nint source_reg = COUNT_MATCH;\nint source_end_reg = ARGUMENTS;\nint char1_reg = STACK_LIMIT;\n#endif \/* SUPPORT_UNICODE *\/\n\nif (ref)\n  {\n  offset = GET2(cc, 1) << 1;\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));\n  \/* OVECTOR(1) contains the \"string begin - 1\" constant. *\/\n  if (withchecks && !common->unset_backref)\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)));\n  }\nelse\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);\n\n#if defined SUPPORT_UNICODE\nif (common->utf && *cc == OP_REFI)\n  {\n  SLJIT_ASSERT(common->iref_ptr != 0);\n\n  if (ref)\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));\n  else\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));\n\n  if (withchecks && emptyfail)\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, TMP2, 0));\n\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->iref_ptr, source_reg, 0);\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw), source_end_reg, 0);\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2, char1_reg, 0);\n\n  OP1(SLJIT_MOV, source_reg, 0, TMP1, 0);\n  OP1(SLJIT_MOV, source_end_reg, 0, TMP2, 0);\n\n  loop = LABEL();\n  jump = CMP(SLJIT_GREATER_EQUAL, source_reg, 0, source_end_reg, 0);\n  partial = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);\n\n  \/* Read original character. It must be a valid UTF character. *\/\n  OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);\n  OP1(SLJIT_MOV, STR_PTR, 0, source_reg, 0);\n\n  read_char(common, 0, READ_CHAR_MAX, NULL, READ_CHAR_UPDATE_STR_PTR | READ_CHAR_VALID_UTF);\n\n  OP1(SLJIT_MOV, source_reg, 0, STR_PTR, 0);\n  OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);\n  OP1(SLJIT_MOV, char1_reg, 0, TMP1, 0);\n\n  \/* Read second character. *\/\n  read_char(common, 0, READ_CHAR_MAX, &no_match, READ_CHAR_UPDATE_STR_PTR);\n\n  CMPTO(SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop);\n\n  OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);\n\n  add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));\n\n  OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);\n  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);\n\n  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records));\n\n  OP1(SLJIT_MOV_S32, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(ucd_record, other_case));\n  OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(ucd_record, caseset));\n  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP3, 0);\n  CMPTO(SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop);\n\n  add_jump(compiler, &no_match, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0));\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);\n  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_caseless_sets));\n\n  caseless_loop = LABEL();\n  OP1(SLJIT_MOV_U32, TMP1, 0, SLJIT_MEM1(TMP2), 0);\n  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, sizeof(uint32_t));\n  OP2U(SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_LESS, TMP1, 0, char1_reg, 0);\n  JUMPTO(SLJIT_EQUAL, loop);\n  JUMPTO(SLJIT_LESS, caseless_loop);\n\n  set_jumps(no_match, LABEL());\n  if (common->mode == PCRE2_JIT_COMPLETE)\n    JUMPHERE(partial);\n\n  OP1(SLJIT_MOV, source_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr);\n  OP1(SLJIT_MOV, source_end_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw));\n  OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2);\n  add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n\n  if (common->mode != PCRE2_JIT_COMPLETE)\n    {\n    JUMPHERE(partial);\n    OP1(SLJIT_MOV, source_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr);\n    OP1(SLJIT_MOV, source_end_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw));\n    OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2);\n\n    check_partial(common, FALSE);\n    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n    }\n\n  JUMPHERE(jump);\n  OP1(SLJIT_MOV, source_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr);\n  OP1(SLJIT_MOV, source_end_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw));\n  OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2);\n  return;\n  }\nelse\n#endif \/* SUPPORT_UNICODE *\/\n  {\n  if (ref)\n    OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP1, 0);\n  else\n    OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);\n\n  if (withchecks)\n    jump = JUMP(SLJIT_ZERO);\n\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);\n  partial = CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0);\n  if (common->mode == PCRE2_JIT_COMPLETE)\n    add_jump(compiler, backtracks, partial);\n\n  add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));\n  add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));\n\n  if (common->mode != PCRE2_JIT_COMPLETE)\n    {\n    nopartial = JUMP(SLJIT_JUMP);\n    JUMPHERE(partial);\n    \/* TMP2 -= STR_END - STR_PTR *\/\n    OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, STR_PTR, 0);\n    OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, STR_END, 0);\n    partial = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0);\n    OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0);\n    add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));\n    JUMPHERE(partial);\n    check_partial(common, FALSE);\n    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n    JUMPHERE(nopartial);\n    }\n  }\n\nif (jump != NULL)\n  {\n  if (emptyfail)\n    add_jump(compiler, backtracks, jump);\n  else\n    JUMPHERE(jump);\n  }\n}","target":0,"code_token_length":2385,"total_token_length":2621,"max_tokens_setting":4096}
+{"idx":211915,"func":"jas_image_t *jp2_decode(jas_stream_t *in, const char *optstr)\n{\n\tjp2_box_t *box;\n\tint found;\n\tjas_image_t *image;\n\tjp2_dec_t *dec;\n\tbool samedtype;\n\tint dtype;\n\tunsigned int i;\n\tjp2_cmap_t *cmapd;\n\tjp2_pclr_t *pclrd;\n\tjp2_cdef_t *cdefd;\n\tunsigned int channo;\n\tint newcmptno;\n\tint_fast32_t *lutents;\n#if 0\n\tjp2_cdefchan_t *cdefent;\n\tint cmptno;\n#endif\n\tjp2_cmapent_t *cmapent;\n\tjas_icchdr_t icchdr;\n\tjas_iccprof_t *iccprof;\n\n\tdec = 0;\n\tbox = 0;\n\timage = 0;\n\n\tJAS_DBGLOG(100, (\"jp2_decode(%p, \\\"%s\\\")\\n\", in, optstr));\n\n\tif (!(dec = jp2_dec_create())) {\n\t\tgoto error;\n\t}\n\n\t\/* Get the first box.  This should be a JP box. *\/\n\tif (!(box = jp2_box_get(in))) {\n\t\tjas_eprintf(\"error: cannot get box\\n\");\n\t\tgoto error;\n\t}\n\tif (box->type != JP2_BOX_JP) {\n\t\tjas_eprintf(\"error: expecting signature box\\n\");\n\t\tgoto error;\n\t}\n\tif (box->data.jp.magic != JP2_JP_MAGIC) {\n\t\tjas_eprintf(\"incorrect magic number\\n\");\n\t\tgoto error;\n\t}\n\tjp2_box_destroy(box);\n\tbox = 0;\n\n\t\/* Get the second box.  This should be a FTYP box. *\/\n\tif (!(box = jp2_box_get(in))) {\n\t\tgoto error;\n\t}\n\tif (box->type != JP2_BOX_FTYP) {\n\t\tjas_eprintf(\"expecting file type box\\n\");\n\t\tgoto error;\n\t}\n\tjp2_box_destroy(box);\n\tbox = 0;\n\n\t\/* Get more boxes... *\/\n\tfound = 0;\n\twhile ((box = jp2_box_get(in))) {\n\t\tif (jas_getdbglevel() >= 1) {\n\t\t\tjas_eprintf(\"got box type %s\\n\", box->info->name);\n\t\t}\n\t\tswitch (box->type) {\n\t\tcase JP2_BOX_JP2C:\n\t\t\tfound = 1;\n\t\t\tbreak;\n\t\tcase JP2_BOX_IHDR:\n\t\t\tif (!dec->ihdr) {\n\t\t\t\tdec->ihdr = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_BPCC:\n\t\t\tif (!dec->bpcc) {\n\t\t\t\tdec->bpcc = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_CDEF:\n\t\t\tif (!dec->cdef) {\n\t\t\t\tdec->cdef = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_PCLR:\n\t\t\tif (!dec->pclr) {\n\t\t\t\tdec->pclr = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_CMAP:\n\t\t\tif (!dec->cmap) {\n\t\t\t\tdec->cmap = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase JP2_BOX_COLR:\n\t\t\tif (!dec->colr) {\n\t\t\t\tdec->colr = box;\n\t\t\t\tbox = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (box) {\n\t\t\tjp2_box_destroy(box);\n\t\t\tbox = 0;\n\t\t}\n\t\tif (found) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!found) {\n\t\tjas_eprintf(\"error: no code stream found\\n\");\n\t\tgoto error;\n\t}\n\n\tif (!(dec->image = jpc_decode(in, optstr))) {\n\t\tjas_eprintf(\"error: cannot decode code stream\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* An IHDR box must be present. *\/\n\tif (!dec->ihdr) {\n\t\tjas_eprintf(\"error: missing IHDR box\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Does the number of components indicated in the IHDR box match\n\t  the value specified in the code stream? *\/\n\tif (dec->ihdr->data.ihdr.numcmpts != JAS_CAST(jas_uint,\n\t  jas_image_numcmpts(dec->image))) {\n\t\tjas_eprintf(\"warning: number of components mismatch\\n\");\n\t}\n\n\t\/* At least one component must be present. *\/\n\tif (!jas_image_numcmpts(dec->image)) {\n\t\tjas_eprintf(\"error: no components\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Determine if all components have the same data type. *\/\n\tsamedtype = true;\n\tdtype = jas_image_cmptdtype(dec->image, 0);\n\tfor (i = 1; i < JAS_CAST(jas_uint, jas_image_numcmpts(dec->image)); ++i) {\n\t\tif (jas_image_cmptdtype(dec->image, i) != dtype) {\n\t\t\tsamedtype = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* Is the component data type indicated in the IHDR box consistent\n\t  with the data in the code stream? *\/\n\tif ((samedtype && dec->ihdr->data.ihdr.bpc != JP2_DTYPETOBPC(dtype)) ||\n\t  (!samedtype && dec->ihdr->data.ihdr.bpc != JP2_IHDR_BPCNULL)) {\n\t\tjas_eprintf(\"warning: component data type mismatch\\n\");\n\t}\n\n\t\/* Is the compression type supported? *\/\n\tif (dec->ihdr->data.ihdr.comptype != JP2_IHDR_COMPTYPE) {\n\t\tjas_eprintf(\"error: unsupported compression type\\n\");\n\t\tgoto error;\n\t}\n\n\tif (dec->bpcc) {\n\t\t\/* Is the number of components indicated in the BPCC box\n\t\t  consistent with the code stream data? *\/\n\t\tif (dec->bpcc->data.bpcc.numcmpts != JAS_CAST(jas_uint, jas_image_numcmpts(\n\t\t  dec->image))) {\n\t\t\tjas_eprintf(\"warning: number of components mismatch\\n\");\n\t\t}\n\t\t\/* Is the component data type information indicated in the BPCC\n\t\t  box consistent with the code stream data? *\/\n\t\tif (!samedtype) {\n\t\t\tfor (i = 0; i < JAS_CAST(jas_uint, jas_image_numcmpts(dec->image));\n\t\t\t  ++i) {\n\t\t\t\tif (jas_image_cmptdtype(dec->image, i) !=\n\t\t\t\t  JP2_BPCTODTYPE(dec->bpcc->data.bpcc.bpcs[i])) {\n\t\t\t\t\tjas_eprintf(\"warning: component data type mismatch\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tjas_eprintf(\"warning: superfluous BPCC box\\n\");\n\t\t}\n\t}\n\n\t\/* A COLR box must be present. *\/\n\tif (!dec->colr) {\n\t\tjas_eprintf(\"error: no COLR box\\n\");\n\t\tgoto error;\n\t}\n\n\tswitch (dec->colr->data.colr.method) {\n\tcase JP2_COLR_ENUM:\n\t\tjas_image_setclrspc(dec->image, jp2_getcs(&dec->colr->data.colr));\n\t\tbreak;\n\tcase JP2_COLR_ICC:\n\t\ticcprof = jas_iccprof_createfrombuf(dec->colr->data.colr.iccp,\n\t\t  dec->colr->data.colr.iccplen);\n\t\tif (!iccprof) {\n\t\t\tjas_eprintf(\"error: failed to parse ICC profile\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tjas_iccprof_gethdr(iccprof, &icchdr);\n\t\tjas_eprintf(\"ICC Profile CS %08x\\n\", icchdr.colorspc);\n\t\tjas_image_setclrspc(dec->image, fromiccpcs(icchdr.colorspc));\n\t\tdec->image->cmprof_ = jas_cmprof_createfromiccprof(iccprof);\n\t\tassert(dec->image->cmprof_);\n\t\tjas_iccprof_destroy(iccprof);\n\t\tbreak;\n\t}\n\n\t\/* If a CMAP box is present, a PCLR box must also be present. *\/\n\tif (dec->cmap && !dec->pclr) {\n\t\tjas_eprintf(\"warning: missing PCLR box or superfluous CMAP box\\n\");\n\t\tjp2_box_destroy(dec->cmap);\n\t\tdec->cmap = 0;\n\t}\n\n\t\/* If a CMAP box is not present, a PCLR box must not be present. *\/\n\tif (!dec->cmap && dec->pclr) {\n\t\tjas_eprintf(\"warning: missing CMAP box or superfluous PCLR box\\n\");\n\t\tjp2_box_destroy(dec->pclr);\n\t\tdec->pclr = 0;\n\t}\n\n\t\/* Determine the number of channels (which is essentially the number\n\t  of components after any palette mappings have been applied). *\/\n\tdec->numchans = dec->cmap ? dec->cmap->data.cmap.numchans :\n\t  JAS_CAST(jas_uint, jas_image_numcmpts(dec->image));\n\n\t\/* Perform a basic sanity check on the CMAP box if present. *\/\n\tif (dec->cmap) {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\t\/* Is the component number reasonable? *\/\n\t\t\tif (dec->cmap->data.cmap.ents[i].cmptno >= JAS_CAST(jas_uint,\n\t\t\t  jas_image_numcmpts(dec->image))) {\n\t\t\t\tjas_eprintf(\"error: invalid component number in CMAP box\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\t\/* Is the LUT index reasonable? *\/\n\t\t\tif (dec->cmap->data.cmap.ents[i].pcol >=\n\t\t\t  dec->pclr->data.pclr.numchans) {\n\t\t\t\tjas_eprintf(\"error: invalid CMAP LUT index\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Allocate space for the channel-number to component-number LUT. *\/\n\tif (!(dec->chantocmptlut = jas_alloc2(dec->numchans,\n\t  sizeof(uint_fast16_t)))) {\n\t\tjas_eprintf(\"error: no memory\\n\");\n\t\tgoto error;\n\t}\n\n\tif (!dec->cmap) {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\tdec->chantocmptlut[i] = i;\n\t\t}\n\t} else {\n\t\tcmapd = &dec->cmap->data.cmap;\n\t\tpclrd = &dec->pclr->data.pclr;\n\t\tcdefd = &dec->cdef->data.cdef;\n\t\tfor (channo = 0; channo < cmapd->numchans; ++channo) {\n\t\t\tcmapent = &cmapd->ents[channo];\n\t\t\tif (cmapent->map == JP2_CMAP_DIRECT) {\n\t\t\t\tdec->chantocmptlut[channo] = channo;\n\t\t\t} else if (cmapent->map == JP2_CMAP_PALETTE) {\n\t\t\t\tlutents = jas_alloc2(pclrd->numlutents, sizeof(int_fast32_t));\n\t\t\t\tfor (i = 0; i < pclrd->numlutents; ++i) {\n\t\t\t\t\tlutents[i] = pclrd->lutdata[cmapent->pcol + i * pclrd->numchans];\n\t\t\t\t}\n\t\t\t\tnewcmptno = jas_image_numcmpts(dec->image);\n\t\t\t\tjas_image_depalettize(dec->image, cmapent->cmptno,\n\t\t\t\t  pclrd->numlutents, lutents,\n\t\t\t\t  JP2_BPCTODTYPE(pclrd->bpc[cmapent->pcol]), newcmptno);\n\t\t\t\tdec->chantocmptlut[channo] = newcmptno;\n\t\t\t\tjas_free(lutents);\n#if 0\n\t\t\t\tif (dec->cdef) {\n\t\t\t\t\tcdefent = jp2_cdef_lookup(cdefd, channo);\n\t\t\t\t\tif (!cdefent) {\n\t\t\t\t\t\tabort();\n\t\t\t\t\t}\n\t\t\t\tjas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_clrspc(dec->image), cdefent->type, cdefent->assoc));\n\t\t\t\t} else {\n\t\t\t\tjas_image_setcmpttype(dec->image, newcmptno, jp2_getct(jas_image_clrspc(dec->image), 0, channo + 1));\n\t\t\t\t}\n#endif\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Mark all components as being of unknown type. *\/\n\n\tfor (i = 0; i < JAS_CAST(jas_uint, jas_image_numcmpts(dec->image)); ++i) {\n\t\tjas_image_setcmpttype(dec->image, i, JAS_IMAGE_CT_UNKNOWN);\n\t}\n\n\t\/* Determine the type of each component. *\/\n\tif (dec->cdef) {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\t\/* Is the channel number reasonable? *\/\n\t\t\tif (dec->cdef->data.cdef.ents[i].channo >= dec->numchans) {\n\t\t\t\tjas_eprintf(\"error: invalid channel number in CDEF box\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\tjas_image_setcmpttype(dec->image,\n\t\t\t  dec->chantocmptlut[dec->cdef->data.cdef.ents[i].channo],\n\t\t\t  jp2_getct(jas_image_clrspc(dec->image),\n\t\t\t  dec->cdef->data.cdef.ents[i].type,\n\t\t\t  dec->cdef->data.cdef.ents[i].assoc));\n\t\t}\n\t} else {\n\t\tfor (i = 0; i < dec->numchans; ++i) {\n\t\t\tjas_image_setcmpttype(dec->image, dec->chantocmptlut[i],\n\t\t\t  jp2_getct(jas_image_clrspc(dec->image), 0, i + 1));\n\t\t}\n\t}\n\n\t\/* Delete any components that are not of interest. *\/\n\tfor (i = jas_image_numcmpts(dec->image); i > 0; --i) {\n\t\tif (jas_image_cmpttype(dec->image, i - 1) == JAS_IMAGE_CT_UNKNOWN) {\n\t\t\tjas_image_delcmpt(dec->image, i - 1);\n\t\t}\n\t}\n\n\t\/* Ensure that some components survived. *\/\n\tif (!jas_image_numcmpts(dec->image)) {\n\t\tjas_eprintf(\"error: no components\\n\");\n\t\tgoto error;\n\t}\n#if 0\njas_eprintf(\"no of components is %d\\n\", jas_image_numcmpts(dec->image));\n#endif\n\n\t\/* Prevent the image from being destroyed later. *\/\n\timage = dec->image;\n\tdec->image = 0;\n\n\tjp2_dec_destroy(dec);\n\n\treturn image;\n\nerror:\n\tif (box) {\n\t\tjp2_box_destroy(box);\n\t}\n\tif (dec) {\n\t\tjp2_dec_destroy(dec);\n\t}\n\treturn 0;\n}","target":1,"code_token_length":3253,"total_token_length":3489,"max_tokens_setting":4096}
+{"idx":257693,"func":"static int recv_rfc_6455(handler_ctx *hctx) {\n    request_st * const r = hctx->gw.r;\n    chunkqueue *cq = &r->reqbody_queue;\n    buffer *payload = hctx->frame.payload;\n    DEBUG_LOG_DEBUG(\"recv data from client (fd=%d), size=%llx\",\n                    r->con->fd, (long long)chunkqueue_length(cq));\n    for (chunk *c = cq->first; c; c = c->next) {\n        char *frame = c->mem->ptr+c->offset;\n        \/*(chunk_remaining_length() on MEM_CHUNK)*\/\n        size_t flen = (size_t)(buffer_clen(c->mem) - c->offset);\n        \/*(FILE_CHUNK not handled, but might need to add support)*\/\n        force_assert(c->type == MEM_CHUNK);\n        for (size_t i = 0; i < flen; ) {\n            switch (hctx->frame.state) {\n            case MOD_WEBSOCKET_FRAME_STATE_INIT:\n                switch (frame[i] & 0x0f) {\n                case MOD_WEBSOCKET_OPCODE_CONT:\n                    DEBUG_LOG_DEBUG(\"%s\", \"type = continue\");\n                    hctx->frame.type = hctx->frame.type_before;\n                    break;\n                case MOD_WEBSOCKET_OPCODE_TEXT:\n                    DEBUG_LOG_DEBUG(\"%s\", \"type = text\");\n                    hctx->frame.type = MOD_WEBSOCKET_FRAME_TYPE_TEXT;\n                    hctx->frame.type_before = hctx->frame.type;\n                    break;\n                case MOD_WEBSOCKET_OPCODE_BIN:\n                    DEBUG_LOG_DEBUG(\"%s\", \"type = binary\");\n                    hctx->frame.type = MOD_WEBSOCKET_FRAME_TYPE_BIN;\n                    hctx->frame.type_before = hctx->frame.type;\n                    break;\n                case MOD_WEBSOCKET_OPCODE_PING:\n                    DEBUG_LOG_DEBUG(\"%s\", \"type = ping\");\n                    hctx->frame.type = MOD_WEBSOCKET_FRAME_TYPE_PING;\n                    break;\n                case MOD_WEBSOCKET_OPCODE_PONG:\n                    DEBUG_LOG_DEBUG(\"%s\", \"type = pong\");\n                    hctx->frame.type = MOD_WEBSOCKET_FRAME_TYPE_PONG;\n                    break;\n                case MOD_WEBSOCKET_OPCODE_CLOSE:\n                    DEBUG_LOG_DEBUG(\"%s\", \"type = close\");\n                    hctx->frame.type = MOD_WEBSOCKET_FRAME_TYPE_CLOSE;\n                    return -1;\n                    break;\n                default:\n                    DEBUG_LOG_ERR(\"%s\", \"type is invalid\");\n                    return -1;\n                    break;\n                }\n                i++;\n                hctx->frame.state = MOD_WEBSOCKET_FRAME_STATE_READ_LENGTH;\n                break;\n            case MOD_WEBSOCKET_FRAME_STATE_READ_LENGTH:\n                if ((frame[i] & 0x80) != 0x80) {\n                    DEBUG_LOG_ERR(\"%s\", \"payload was not masked\");\n                    return -1;\n                }\n                hctx->frame.ctl.mask_cnt = 0;\n                hctx->frame.ctl.siz = (uint64_t)(frame[i] & 0x7f);\n                if (hctx->frame.ctl.siz == 0) {\n                    DEBUG_LOG_DEBUG(\"specified payload size=%llx\",\n                                    (unsigned long long)hctx->frame.ctl.siz);\n                    hctx->frame.state = MOD_WEBSOCKET_FRAME_STATE_READ_MASK;\n                }\n                else if (hctx->frame.ctl.siz == MOD_WEBSOCKET_FRAME_LEN16) {\n                    hctx->frame.ctl.siz = 0;\n                    hctx->frame.ctl.siz_cnt = MOD_WEBSOCKET_FRAME_LEN16_CNT;\n                    hctx->frame.state =\n                        MOD_WEBSOCKET_FRAME_STATE_READ_EX_LENGTH;\n                }\n                else if (hctx->frame.ctl.siz == MOD_WEBSOCKET_FRAME_LEN63) {\n                    hctx->frame.ctl.siz = 0;\n                    hctx->frame.ctl.siz_cnt = MOD_WEBSOCKET_FRAME_LEN63_CNT;\n                    hctx->frame.state =\n                        MOD_WEBSOCKET_FRAME_STATE_READ_EX_LENGTH;\n                }\n                else {\n                    DEBUG_LOG_DEBUG(\"specified payload size=%llx\",\n                                    (unsigned long long)hctx->frame.ctl.siz);\n                    hctx->frame.state = MOD_WEBSOCKET_FRAME_STATE_READ_MASK;\n                }\n                i++;\n                break;\n            case MOD_WEBSOCKET_FRAME_STATE_READ_EX_LENGTH:\n                hctx->frame.ctl.siz =\n                    (hctx->frame.ctl.siz << 8) + (frame[i] & 0xff);\n                hctx->frame.ctl.siz_cnt--;\n                if (hctx->frame.ctl.siz_cnt <= 0) {\n                    if (hctx->frame.type == MOD_WEBSOCKET_FRAME_TYPE_PING &&\n                        hctx->frame.ctl.siz > MOD_WEBSOCKET_BUFMAX) {\n                        DEBUG_LOG_WARN(\"frame size has been exceeded: %x\",\n                                       MOD_WEBSOCKET_BUFMAX);\n                        return -1;\n                    }\n                    DEBUG_LOG_DEBUG(\"specified payload size=%llx\",\n                                    (unsigned long long)hctx->frame.ctl.siz);\n                    hctx->frame.state = MOD_WEBSOCKET_FRAME_STATE_READ_MASK;\n                }\n                i++;\n                break;\n            case MOD_WEBSOCKET_FRAME_STATE_READ_MASK:\n                hctx->frame.ctl.mask[hctx->frame.ctl.mask_cnt] = frame[i];\n                hctx->frame.ctl.mask_cnt++;\n                if (hctx->frame.ctl.mask_cnt >= MOD_WEBSOCKET_MASK_CNT) {\n                    hctx->frame.ctl.mask_cnt = 0;\n                    if (hctx->frame.type == MOD_WEBSOCKET_FRAME_TYPE_PING &&\n                        hctx->frame.ctl.siz == 0) {\n                        mod_wstunnel_frame_send(hctx,\n                                                MOD_WEBSOCKET_FRAME_TYPE_PONG,\n                                                NULL, 0);\n                    }\n                    if (hctx->frame.ctl.siz == 0) {\n                        hctx->frame.state = MOD_WEBSOCKET_FRAME_STATE_INIT;\n                    }\n                    else {\n                        hctx->frame.state =\n                            MOD_WEBSOCKET_FRAME_STATE_READ_PAYLOAD;\n                    }\n                }\n                i++;\n                break;\n            case MOD_WEBSOCKET_FRAME_STATE_READ_PAYLOAD:\n                \/* hctx->frame.ctl.siz <= SIZE_MAX *\/\n                if (hctx->frame.ctl.siz <= flen - i) {\n                    DEBUG_LOG_DEBUG(\"read payload, size=%llx\",\n                                    (unsigned long long)hctx->frame.ctl.siz);\n                    buffer_append_string_len(payload, frame+i, (size_t)\n                                             (hctx->frame.ctl.siz & SIZE_MAX));\n                    i += (size_t)(hctx->frame.ctl.siz & SIZE_MAX);\n                    hctx->frame.ctl.siz = 0;\n                    hctx->frame.state = MOD_WEBSOCKET_FRAME_STATE_INIT;\n                    DEBUG_LOG_DEBUG(\"rest of frame size=%zx\", flen - i);\n                \/* SIZE_MAX < hctx->frame.ctl.siz *\/\n                }\n                else {\n                    DEBUG_LOG_DEBUG(\"read payload, size=%zx\", flen - i);\n                    buffer_append_string_len(payload, frame+i, flen - i);\n                    hctx->frame.ctl.siz -= flen - i;\n                    i += flen - i;\n                    DEBUG_LOG_DEBUG(\"rest of payload size=%llx\",\n                                    (unsigned long long)hctx->frame.ctl.siz);\n                }\n                switch (hctx->frame.type) {\n                case MOD_WEBSOCKET_FRAME_TYPE_TEXT:\n                case MOD_WEBSOCKET_FRAME_TYPE_BIN:\n                  {\n                    unmask_payload(hctx);\n                    chunkqueue_append_buffer(&hctx->gw.wb, payload);\n                    \/*buffer_clear(payload);*\/\/*chunkqueue_append_buffer clear*\/\n                    break;\n                  }\n                case MOD_WEBSOCKET_FRAME_TYPE_PING:\n                    if (hctx->frame.ctl.siz == 0) {\n                        unmask_payload(hctx);\n                        mod_wstunnel_frame_send(hctx,\n                          MOD_WEBSOCKET_FRAME_TYPE_PONG,\n                          payload->ptr, buffer_clen(payload));\n                        buffer_clear(payload);\n                    }\n                    break;\n                case MOD_WEBSOCKET_FRAME_TYPE_PONG:\n                    buffer_clear(payload);\n                    break;\n                case MOD_WEBSOCKET_FRAME_TYPE_CLOSE:\n                default:\n                    DEBUG_LOG_ERR(\"%s\", \"BUG: invalid frame type\");\n                    return -1;\n                }\n                break;\n            default:\n                DEBUG_LOG_ERR(\"%s\", \"BUG: invalid state\");\n                return -1;\n            }\n        }\n    }\n    \/* XXX: should add ability to handle and preserve partial frames above *\/\n    \/*(not chunkqueue_reset(); do not reset cq->bytes_in, cq->bytes_out)*\/\n    chunkqueue_mark_written(cq, chunkqueue_length(cq));\n    return 0;\n}","target":0,"code_token_length":1845,"total_token_length":2081,"max_tokens_setting":4096}
+{"idx":206210,"func":"parse_command_modifiers(\n\texarg_T\t    *eap,\n\tchar\t    **errormsg,\n\tcmdmod_T    *cmod,\n\tint\t    skip_only)\n{\n    char_u  *cmd_start = NULL;\n    char_u  *p;\n    int\t    starts_with_colon = FALSE;\n    int\t    vim9script = in_vim9script();\n    int\t    has_visual_range = FALSE;\n\n    CLEAR_POINTER(cmod);\n    cmod->cmod_flags = sticky_cmdmod_flags;\n\n    if (STRNCMP(eap->cmd, \"'<,'>\", 5) == 0)\n    {\n\t\/\/ The automatically inserted Visual area range is skipped, so that\n\t\/\/ typing \":cmdmod cmd\" in Visual mode works without having to move the\n\t\/\/ range to after the modififiers.\n\teap->cmd += 5;\n\tcmd_start = eap->cmd;\n\thas_visual_range = TRUE;\n    }\n\n    \/\/ Repeat until no more command modifiers are found.\n    for (;;)\n    {\n\twhile (*eap->cmd == ' ' || *eap->cmd == '\\t' || *eap->cmd == ':')\n\t{\n\t    if (*eap->cmd == ':')\n\t\tstarts_with_colon = TRUE;\n\t    ++eap->cmd;\n\t}\n\n\t\/\/ in ex mode, an empty line works like :+\n\tif (*eap->cmd == NUL && exmode_active\n\t\t   && (getline_equal(eap->getline, eap->cookie, getexmodeline)\n\t\t       || getline_equal(eap->getline, eap->cookie, getexline))\n\t\t\t&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)\n\t{\n\t    eap->cmd = (char_u *)\"+\";\n\t    if (!skip_only)\n\t\tex_pressedreturn = TRUE;\n\t}\n\n\t\/\/ ignore comment and empty lines\n\tif (comment_start(eap->cmd, starts_with_colon))\n\t{\n\t    \/\/ a comment ends at a NL\n\t    if (eap->nextcmd == NULL)\n\t    {\n\t\teap->nextcmd = vim_strchr(eap->cmd, '\\n');\n\t\tif (eap->nextcmd != NULL)\n\t\t    ++eap->nextcmd;\n\t    }\n\t    if (vim9script && has_cmdmod(cmod, FALSE))\n\t\t*errormsg = _(e_command_modifier_without_command);\n\t    return FAIL;\n\t}\n\tif (*eap->cmd == NUL)\n\t{\n\t    if (!skip_only)\n\t    {\n\t\tex_pressedreturn = TRUE;\n\t\tif (vim9script && has_cmdmod(cmod, FALSE))\n\t\t    *errormsg = _(e_command_modifier_without_command);\n\t    }\n\t    return FAIL;\n\t}\n\n\tp = skip_range(eap->cmd, TRUE, NULL);\n\n\t\/\/ In Vim9 script a variable can shadow a command modifier:\n\t\/\/   verbose = 123\n\t\/\/   verbose += 123\n\t\/\/   silent! verbose = func()\n\t\/\/   verbose.member = 2\n\t\/\/   verbose[expr] = 2\n\t\/\/ But not:\n\t\/\/   verbose [a, b] = list\n\tif (vim9script)\n\t{\n\t    char_u *s, *n;\n\n\t    for (s = eap->cmd; ASCII_ISALPHA(*s); ++s)\n\t\t;\n\t    n = skipwhite(s);\n\t    if (*n == '.' || *n == '=' || (*n != NUL && n[1] == '=')\n\t\t    || *s == '[')\n\t\tbreak;\n\t}\n\n\tswitch (*p)\n\t{\n\t    \/\/ When adding an entry, also modify cmd_exists().\n\t    case 'a':\tif (!checkforcmd_noparen(&eap->cmd, \"aboveleft\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_ABOVE;\n\t\t\tcontinue;\n\n\t    case 'b':\tif (checkforcmd_noparen(&eap->cmd, \"belowright\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_split |= WSP_BELOW;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_opt(&eap->cmd, \"browse\", 3, TRUE))\n\t\t\t{\n#ifdef FEAT_BROWSE_CMD\n\t\t\t    cmod->cmod_flags |= CMOD_BROWSE;\n#endif\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"botright\", 2))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_BOT;\n\t\t\tcontinue;\n\n\t    case 'c':\tif (!checkforcmd_opt(&eap->cmd, \"confirm\", 4, TRUE))\n\t\t\t    break;\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\t\t\tcmod->cmod_flags |= CMOD_CONFIRM;\n#endif\n\t\t\tcontinue;\n\n\t    case 'k':\tif (checkforcmd_noparen(&eap->cmd, \"keepmarks\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPMARKS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"keepalt\", 5))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPALT;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"keeppatterns\", 5))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPPATTERNS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"keepjumps\", 5))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_KEEPJUMPS;\n\t\t\tcontinue;\n\n\t    case 'f':\t\/\/ only accept \":filter {pat} cmd\"\n\t\t\t{\n\t\t\t    char_u  *reg_pat;\n\t\t\t    char_u  *nulp = NULL;\n\t\t\t    int\t    c = 0;\n\n\t\t\t    if (!checkforcmd_noparen(&p, \"filter\", 4)\n\t\t\t\t    || *p == NUL\n\t\t\t\t    || (ends_excmd(*p)\n#ifdef FEAT_EVAL\n\t\t\t\t\t\/\/ in \":filter #pat# cmd\" # does not\n\t\t\t\t\t\/\/ start a comment\n\t\t\t\t     && (!vim9script || VIM_ISWHITE(p[1]))\n#endif\n\t\t\t\t     ))\n\t\t\t\tbreak;\n\t\t\t    if (*p == '!')\n\t\t\t    {\n\t\t\t\tcmod->cmod_filter_force = TRUE;\n\t\t\t\tp = skipwhite(p + 1);\n\t\t\t\tif (*p == NUL || ends_excmd(*p))\n\t\t\t\t    break;\n\t\t\t    }\n#ifdef FEAT_EVAL\n\t\t\t    \/\/ Avoid that \"filter(arg)\" is recognized.\n\t\t\t    if (vim9script && !VIM_ISWHITE(p[-1]))\n\t\t\t\tbreak;\n#endif\n\t\t\t    if (skip_only)\n\t\t\t\tp = skip_vimgrep_pat(p, NULL, NULL);\n\t\t\t    else\n\t\t\t\t\/\/ NOTE: This puts a NUL after the pattern.\n\t\t\t\tp = skip_vimgrep_pat_ext(p, ®_pat, NULL,\n\t\t\t\t\t\t\t\t    &nulp, &c);\n\t\t\t    if (p == NULL || *p == NUL)\n\t\t\t\tbreak;\n\t\t\t    if (!skip_only)\n\t\t\t    {\n\t\t\t\tcmod->cmod_filter_regmatch.regprog =\n\t\t\t\t\t\tvim_regcomp(reg_pat, RE_MAGIC);\n\t\t\t\tif (cmod->cmod_filter_regmatch.regprog == NULL)\n\t\t\t\t    break;\n\t\t\t\t\/\/ restore the character overwritten by NUL\n\t\t\t\tif (nulp != NULL)\n\t\t\t\t    *nulp = c;\n\t\t\t    }\n\t\t\t    eap->cmd = p;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\t\/\/ \":hide\" and \":hide | cmd\" are not modifiers\n\t    case 'h':\tif (p != eap->cmd || !checkforcmd_noparen(&p, \"hide\", 3)\n\t\t\t\t\t       || *p == NUL || ends_excmd(*p))\n\t\t\t    break;\n\t\t\teap->cmd = p;\n\t\t\tcmod->cmod_flags |= CMOD_HIDE;\n\t\t\tcontinue;\n\n\t    case 'l':\tif (checkforcmd_noparen(&eap->cmd, \"lockmarks\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_LOCKMARKS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"legacy\", 3))\n\t\t\t{\n\t\t\t    if (ends_excmd2(p, eap->cmd))\n\t\t\t    {\n\t\t\t\t*errormsg =\n\t\t\t\t      _(e_legacy_must_be_followed_by_command);\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    cmod->cmod_flags |= CMOD_LEGACY;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"leftabove\", 5))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_ABOVE;\n\t\t\tcontinue;\n\n\t    case 'n':\tif (checkforcmd_noparen(&eap->cmd, \"noautocmd\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_NOAUTOCMD;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"noswapfile\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_NOSWAPFILE;\n\t\t\tcontinue;\n\n\t    case 'r':\tif (!checkforcmd_noparen(&eap->cmd, \"rightbelow\", 6))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_BELOW;\n\t\t\tcontinue;\n\n\t    case 's':\tif (checkforcmd_noparen(&eap->cmd, \"sandbox\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_SANDBOX;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"silent\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_SILENT;\n\t\t\tif (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1]))\n\t\t\t{\n\t\t\t    \/\/ \":silent!\", but not \"silent !cmd\"\n\t\t\t    eap->cmd = skipwhite(eap->cmd + 1);\n\t\t\t    cmod->cmod_flags |= CMOD_ERRSILENT;\n\t\t\t}\n\t\t\tcontinue;\n\n\t    case 't':\tif (checkforcmd_noparen(&p, \"tab\", 3))\n\t\t\t{\n\t\t\t    if (!skip_only)\n\t\t\t    {\n\t\t\t\tlong tabnr = get_address(eap, &eap->cmd,\n\t\t\t\t\t\t    ADDR_TABS, eap->skip,\n\t\t\t\t\t\t    skip_only, FALSE, 1);\n\t\t\t\tif (tabnr == MAXLNUM)\n\t\t\t\t    cmod->cmod_tab = tabpage_index(curtab) + 1;\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    if (tabnr < 0 || tabnr > LAST_TAB_NR)\n\t\t\t\t    {\n\t\t\t\t\t*errormsg = _(e_invalid_range);\n\t\t\t\t\treturn FAIL;\n\t\t\t\t    }\n\t\t\t\t    cmod->cmod_tab = tabnr + 1;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    eap->cmd = p;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"topleft\", 2))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_TOP;\n\t\t\tcontinue;\n\n\t    case 'u':\tif (!checkforcmd_noparen(&eap->cmd, \"unsilent\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_UNSILENT;\n\t\t\tcontinue;\n\n\t    case 'v':\tif (checkforcmd_noparen(&eap->cmd, \"vertical\", 4))\n\t\t\t{\n\t\t\t    cmod->cmod_split |= WSP_VERT;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"vim9cmd\", 4))\n\t\t\t{\n\t\t\t    if (ends_excmd2(p, eap->cmd))\n\t\t\t    {\n\t\t\t\t*errormsg =\n\t\t\t\t      _(e_vim9cmd_must_be_followed_by_command);\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    cmod->cmod_flags |= CMOD_VIM9CMD;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&p, \"verbose\", 4))\n\t\t\t    break;\n\t\t\tif (vim_isdigit(*eap->cmd))\n\t\t\t{\n\t\t\t    cmod->cmod_verbose = atoi((char *)eap->cmd);\n\t\t\t    if (cmod->cmod_verbose == 0)\n\t\t\t\tcmod->cmod_verbose = -1;\n\t\t\t}\n\t\t\telse\n\t\t\t    cmod->cmod_verbose = 1;\n\t\t\teap->cmd = p;\n\t\t\tcontinue;\n\t}\n\tbreak;\n    }\n\n    if (has_visual_range)\n    {\n\tif (eap->cmd > cmd_start)\n\t{\n\t    \/\/ Move the '<,'> range to after the modifiers and insert a colon.\n\t    \/\/ Since the modifiers have been parsed put the colon on top of the\n\t    \/\/ space: \"'<,'>mod cmd\" -> \"mod:'<,'>cmd\n\t    \/\/ Put eap->cmd after the colon.\n\t    mch_memmove(cmd_start - 5, cmd_start, eap->cmd - cmd_start);\n\t    eap->cmd -= 5;\n\t    mch_memmove(eap->cmd - 1, \":'<,'>\", 6);\n\t}\n\telse\n\t    \/\/ no modifiers, move the pointer back\n\t    eap->cmd -= 5;\n    }\n\n    return OK;\n}","target":1,"code_token_length":2815,"total_token_length":3051,"max_tokens_setting":4096}
+{"idx":196691,"func":"static GF_Err isoffin_process(GF_Filter *filter)\n{\n\tISOMReader *read = gf_filter_get_udta(filter);\n\tu32 i, count = gf_list_count(read->channels);\n\tBool is_active = GF_FALSE;\n\tBool in_is_eos = GF_FALSE;\n\tBool check_forced_end = GF_FALSE;\n\tBool has_new_data = GF_FALSE;\n\tu64 min_offset_plus_one = 0;\n\tu32 nb_forced_end=0;\n\tif (read->in_error)\n\t\treturn read->in_error;\n\n\tif (read->pid) {\n\t\tBool fetch_input = GF_TRUE;\n\n\t\t\/\/we failed at loading the init segment during a dash switch, retry\n\t\tif (!read->is_partial_download && !read->mem_load_mode && (read->moov_not_loaded==2) ) {\n\t\t\tisoffin_configure_pid(filter, read->pid, GF_FALSE);\n\t\t\tif (read->moov_not_loaded) return GF_OK;\n\t\t}\n\t\tif (read->mem_load_mode==2) {\n\t\t\tif (!read->force_fetch && read->mem_blob.size > read->mstore_size) {\n\t\t\t\tfetch_input = GF_FALSE;\n\t\t\t}\n\t\t\tread->force_fetch = GF_FALSE;\n\t\t}\n\t\twhile (fetch_input) {\n\t\t\tGF_FilterPacket *pck = gf_filter_pid_get_packet(read->pid);\n\t\t\tif (!pck) {\n\t\t\t\t\/\/we issued a seek, wait for the first packet to be received before fetching channels\n\t\t\t\t\/\/otherwise we could end up reading from the wrong cache\n\t\t\t\tif (read->wait_for_source) {\n\t\t\t\t\t\/\/something went wrong during the seek request\n\t\t\t\t\tif (gf_filter_pid_is_eos(read->pid))\n\t\t\t\t\t\treturn GF_EOS;\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tread->wait_for_source = GF_FALSE;\n\n\t\t\tif (read->mem_load_mode) {\n\t\t\t\tu32 data_size;\n\t\t\t\tconst u8 *pck_data = gf_filter_pck_get_data(pck, &data_size);\n\t\t\t\tisoffin_push_buffer(filter, read, pck_data, data_size);\n\t\t\t}\n\t\t\t\/\/we just had a switch but init seg is not completely done: input packet is only a part of the init, drop it\n\t\t\telse if (read->moov_not_loaded==2) {\n\t\t\t\tgf_filter_pid_drop_packet(read->pid);\n\t\t\t\treturn GF_OK;\n\t\t\t}\n\t\t\tgf_filter_pid_drop_packet(read->pid);\n\t\t\thas_new_data = GF_TRUE;\n\t\t\tif (read->in_error)\n\t\t\t\treturn read->in_error;\n\t\t}\n\t\tif (gf_filter_pid_is_eos(read->pid)) {\n\t\t\tread->input_loaded = GF_TRUE;\n\t\t\tin_is_eos = GF_TRUE;\n\t\t}\n\t\tif (read->input_is_stop) {\n\t\t\tread->input_loaded = GF_TRUE;\n\t\t\tin_is_eos = GF_TRUE;\n\t\t\tread->input_is_stop = GF_FALSE;\n\t\t}\n\t\tif (!read->frag_type && read->input_loaded) {\n\t\t\tin_is_eos = GF_TRUE;\n\t\t}\n        \/\/segment is invalid, wait for eos on input an send eos on all channels\n        if (read->invalid_segment) {\n            if (!in_is_eos) return GF_OK;\n            read->invalid_segment = GF_FALSE;\n\n            for (i=0; i<count; i++) {\n                ISOMChannel *ch = gf_list_get(read->channels, i);\n                if (!ch->playing) {\n                    continue;\n                }\n                if (!ch->eos_sent) {\n                    ch->eos_sent = GF_TRUE;\n                    gf_filter_pid_set_eos(ch->pid);\n                }\n            }\n            read->eos_signaled = GF_TRUE;\n            return GF_EOS;\n        }\n\t} else if (read->extern_mov) {\n\t\tin_is_eos = GF_TRUE;\n\t\tread->input_loaded = GF_TRUE;\n\t}\n\tif (read->moov_not_loaded==1) {\n\t\tif (read->mem_load_mode)\n\t\t\treturn GF_OK;\n\t\tread->moov_not_loaded = GF_FALSE;\n\t\treturn isoffin_setup(filter, read);\n\t}\n\n\tif (read->refresh_fragmented) {\n\t\tconst GF_PropertyValue *prop;\n\n\t\tif (in_is_eos) {\n\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t} else {\n\t\t\tprop = gf_filter_pid_get_property(read->pid, GF_PROP_PID_FILE_CACHED);\n\t\t\tif (prop && prop->value.boolean)\n\t\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t}\n\n\t\tif (has_new_data) {\n\t\t\tu64 bytesMissing=0;\n\t\t\tGF_Err e;\n\t\t\tconst char *new_url = NULL;\n\t\t\tprop = gf_filter_pid_get_property(read->pid, GF_PROP_PID_FILEPATH);\n\t\t\tif (prop) new_url = prop->value.string;\n\n\t\t\te = gf_isom_refresh_fragmented(read->mov, &bytesMissing, new_url);\n\n\t\t\tif (e && (e!= GF_ISOM_INCOMPLETE_FILE)) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_DASH, (\"[IsoMedia] Failed to refresh current segment: %s\\n\", gf_error_to_string(e) ));\n\t\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] Refreshing current segment at UTC \"LLU\" - \"LLU\" bytes still missing - input is EOS %d\\n\", gf_net_get_utc(), bytesMissing, in_is_eos));\n\t\t\t}\n\n\t\t\tif (!read->refresh_fragmented && (e==GF_ISOM_INCOMPLETE_FILE)) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_DASH, (\"[IsoMedia] Incomplete Segment received - \"LLU\" bytes missing but EOF found\\n\", bytesMissing ));\n\t\t\t}\n\n#ifndef GPAC_DISABLE_LOG\n\t\t\tif (gf_log_tool_level_on(GF_LOG_DASH, GF_LOG_DEBUG)) {\n\t\t\t\tfor (i=0; i<count; i++) {\n\t\t\t\t\tISOMChannel *ch = gf_list_get(read->channels, i);\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] refresh track %d fragment - cur sample %d - new sample count %d\\n\", ch->track, ch->sample_num, gf_isom_get_sample_count(ch->owner->mov, ch->track) ));\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\tisor_check_producer_ref_time(read);\n\t\t\tif (!read->frag_type)\n\t\t\t\tread->refresh_fragmented = GF_FALSE;\n\t\t}\n\t}\n\n\tfor (i=0; i<count; i++) {\n\t\tu8 *data;\n\t\tu32 nb_pck=50;\n\t\tISOMChannel *ch;\n\t\tch = gf_list_get(read->channels, i);\n\t\tif (!ch->playing) {\n\t\t\tnb_forced_end++;\n\t\t\tcontinue;\n\t\t}\n\t\t\/\/eos not sent on this channel, we are active\n\t\tif (!ch->eos_sent)\n\t\t\tis_active = GF_TRUE;\n\n\t\twhile (nb_pck) {\n\t\t\tch->sample_data_offset = 0;\n\t\t\tif (!read->full_segment_flush && gf_filter_pid_would_block(ch->pid) )\n\t\t\t\tbreak;\n\n\t\t\tif (ch->item_id) {\n\t\t\t\tisor_reader_get_sample_from_item(ch);\n\t\t\t} else {\n\t\t\t\tisor_reader_get_sample(ch);\n\t\t\t}\n\n\t\t\tif (read->stsd && (ch->last_sample_desc_index != read->stsd) && ch->sample) {\n\t\t\t\tisor_reader_release_sample(ch);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch->sample) {\n\t\t\t\tu32 sample_dur;\n\t\t\t\tu8 dep_flags;\n\t\t\t\tu8 *subs_buf;\n\t\t\t\tu32 subs_buf_size;\n\t\t\t\tGF_FilterPacket *pck;\n\t\t\t\tif (ch->needs_pid_reconfig) {\n\t\t\t\t\tisor_update_channel_config(ch);\n\t\t\t\t\tch->needs_pid_reconfig = GF_FALSE;\n\t\t\t\t}\n\n\t\t\t\t\/\/we have at least two samples, update GF_PROP_PID_HAS_SYNC if needed\n\t\t\t\tif (ch->check_has_rap && (gf_isom_get_sample_count(ch->owner->mov, ch->track)>1) && (gf_isom_has_sync_points(ch->owner->mov, ch->track)==1)) {\n\t\t\t\t\tch->check_has_rap = GF_FALSE;\n\t\t\t\t\tch->has_rap = GF_TRUE;\n\t\t\t\t\tgf_filter_pid_set_property(ch->pid, GF_PROP_PID_HAS_SYNC, &PROP_BOOL(ch->has_rap) );\n\t\t\t\t}\n\n\t\t\t\t\/\/strip param sets from payload, trigger reconfig if needed\n\t\t\t\tisor_reader_check_config(ch);\n\n\t\t\t\tif (read->nodata) {\n\t\t\t\t\tpck = gf_filter_pck_new_shared(ch->pid, NULL, ch->sample->dataLength, NULL);\n\t\t\t\t\tif (!pck) return GF_OUT_OF_MEM;\n\t\t\t\t} else {\n\t\t\t\t\tpck = gf_filter_pck_new_alloc(ch->pid, ch->sample->dataLength, &data);\n\t\t\t\t\tif (!pck) return GF_OUT_OF_MEM;\n\n\t\t\t\t\tmemcpy(data, ch->sample->data, ch->sample->dataLength);\n\t\t\t\t}\n\t\t\t\tgf_filter_pck_set_dts(pck, ch->dts);\n\t\t\t\tgf_filter_pck_set_cts(pck, ch->cts);\n\t\t\t\tif (ch->sample->IsRAP==-1) {\n\t\t\t\t\tgf_filter_pck_set_sap(pck, GF_FILTER_SAP_1);\n\t\t\t\t\tch->redundant = 1;\n\t\t\t\t} else {\n\t\t\t\t\tgf_filter_pck_set_sap(pck, (GF_FilterSAPType) ch->sample->IsRAP);\n\t\t\t\t}\n\n\t\t\t\tif (ch->sap_3)\n\t\t\t\t\tgf_filter_pck_set_sap(pck, GF_FILTER_SAP_3);\n\t\t\t\telse if (ch->sap_4_type) {\n\t\t\t\t\tgf_filter_pck_set_sap(pck, (ch->sap_4_type==GF_ISOM_SAMPLE_PREROLL) ? GF_FILTER_SAP_4_PROL : GF_FILTER_SAP_4);\n\t\t\t\t\tgf_filter_pck_set_roll_info(pck, ch->roll);\n\t\t\t\t}\n\n\t\t\t\tsample_dur = ch->au_duration;\n\t\t\t\tif (ch->sample->nb_pack)\n\t\t\t\t\tsample_dur *= ch->sample->nb_pack;\n\t\t\t\tgf_filter_pck_set_duration(pck, sample_dur);\n\t\t\t\tgf_filter_pck_set_seek_flag(pck, ch->seek_flag);\n\n\t\t\t\t\/\/for now we only signal xPS mask for non-sap\n\t\t\t\tif (ch->xps_mask && !gf_filter_pck_get_sap(pck) ) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_XPS_MASK, &PROP_UINT(ch->xps_mask) );\n\t\t\t\t}\n\n\t\t\t\tdep_flags = ch->isLeading;\n\t\t\t\tdep_flags <<= 2;\n\t\t\t\tdep_flags |= ch->dependsOn;\n\t\t\t\tdep_flags <<= 2;\n\t\t\t\tdep_flags |= ch->dependedOn;\n\t\t\t\tdep_flags <<= 2;\n\t\t\t\tdep_flags |= ch->redundant;\n\n\t\t\t\tif (dep_flags)\n\t\t\t\t\tgf_filter_pck_set_dependency_flags(pck, dep_flags);\n\n\t\t\t\tgf_filter_pck_set_crypt_flags(pck, ch->pck_encrypted ? GF_FILTER_PCK_CRYPT : 0);\n\t\t\t\tgf_filter_pck_set_seq_num(pck, ch->sample_num);\n\n\n\t\t\t\tsubs_buf = gf_isom_sample_get_subsamples_buffer(read->mov, ch->track, ch->sample_num, &subs_buf_size);\n\t\t\t\tif (subs_buf) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_SUBS, &PROP_DATA_NO_COPY(subs_buf, subs_buf_size) );\n\t\t\t\t}\n\n\t\t\t\tif (ch->sai_buffer && ch->pck_encrypted) {\n\t\t\t\t\tassert(ch->sai_buffer_size);\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_CENC_SAI, &PROP_DATA(ch->sai_buffer, ch->sai_buffer_size) );\n\t\t\t\t}\n\n\t\t\t\tif (read->sigfrag) {\n\t\t\t\t\tGF_ISOFragmentBoundaryInfo finfo;\n\t\t\t\t\tif (gf_isom_sample_is_fragment_start(read->mov, ch->track, ch->sample_num, &finfo) ) {\n\t\t\t\t\t\tu64 start=0;\n\t\t\t\t\t\tu32 traf_start = finfo.seg_start_plus_one ? 2 : 1;\n\n\t\t\t\t\t\tif (finfo.seg_start_plus_one)\n\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_CUE_START, &PROP_BOOL(GF_TRUE));\n\n\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_FRAG_START, &PROP_UINT(traf_start));\n\n\t\t\t\t\t\tstart = finfo.frag_start;\n\t\t\t\t\t\tif (finfo.seg_start_plus_one) start = finfo.seg_start_plus_one-1;\n\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_FRAG_RANGE, &PROP_FRAC64_INT(start, finfo.mdat_end));\n\t\t\t\t\t\tif (finfo.moof_template) {\n\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_MOOF_TEMPLATE, &PROP_DATA((u8 *)finfo.moof_template, finfo.moof_template_size));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (finfo.sidx_end) {\n\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_SIDX_RANGE, &PROP_FRAC64_INT(finfo.sidx_start , finfo.sidx_end));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (read->seg_name_changed) {\n\t\t\t\t\t\t\tconst GF_PropertyValue *p = gf_filter_pid_get_property(read->pid, GF_PROP_PID_URL);\n\t\t\t\t\t\t\tread->seg_name_changed = GF_FALSE;\n\t\t\t\t\t\t\tif (p && p->value.string) {\n\t\t\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PID_URL, &PROP_STRING(p->value.string));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ch->sender_ntp) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_SENDER_NTP, &PROP_LONGUINT(ch->sender_ntp));\n\t\t\t\t\tif (ch->ntp_at_server_ntp) {\n\t\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_RECEIVER_NTP, &PROP_LONGUINT(ch->ntp_at_server_ntp));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tch->eos_sent = GF_FALSE;\n\n\t\t\t\t\/\/this might not be the true end of stream\n\t\t\t\tif ((ch->streamType==GF_STREAM_AUDIO) && (ch->sample_num == gf_isom_get_sample_count(read->mov, ch->track))) {\n\t\t\t\t\tgf_filter_pck_set_property(pck, GF_PROP_PCK_END_RANGE, &PROP_BOOL(GF_TRUE));\n\t\t\t\t}\n\n\t\t\t\tgf_filter_pck_send(pck);\n\t\t\t\tisor_reader_release_sample(ch);\n\n\t\t\t\tch->last_valid_sample_data_offset = ch->sample_data_offset;\n\t\t\t\tnb_pck--;\n\t\t\t} else if (ch->last_state==GF_EOS) {\n\t\t\t\tif (ch->playing == 2) {\n\t\t\t\t\tif (in_is_eos) {\n\t\t\t\t\t\tch->playing = GF_FALSE;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnb_forced_end++;\n\t\t\t\t\t\tcheck_forced_end = GF_TRUE;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (in_is_eos && !ch->eos_sent) {\n\t\t\t\t\tvoid *tfrf;\n\t\t\t\t\tconst void *gf_isom_get_tfrf(GF_ISOFile *movie, u32 trackNumber);\n\n\t\t\t\t\tch->eos_sent = GF_TRUE;\n\t\t\t\t\tread->eos_signaled = GF_TRUE;\n\n\t\t\t\t\ttfrf = (void *) gf_isom_get_tfrf(read->mov, ch->track);\n\t\t\t\t\tif (tfrf) {\n\t\t\t\t\t\tgf_filter_pid_set_info_str(ch->pid, \"smooth_tfrf\", &PROP_POINTER(tfrf) );\n\t\t\t\t\t\tch->last_has_tfrf = GF_TRUE;\n\t\t\t\t\t} else if (ch->last_has_tfrf) {\n\t\t\t\t\t\tgf_filter_pid_set_info_str(ch->pid, \"smooth_tfrf\", NULL);\n\t\t\t\t\t\tch->last_has_tfrf = GF_FALSE;\n\t\t\t\t\t}\n\n\t\t\t\t\tgf_filter_pid_set_eos(ch->pid);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tread->force_fetch = GF_TRUE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!min_offset_plus_one || (min_offset_plus_one - 1 > ch->last_valid_sample_data_offset))\n\t\t\tmin_offset_plus_one = 1 + ch->last_valid_sample_data_offset;\n\t}\n\tif (read->mem_load_mode && min_offset_plus_one) {\n\t\tisoffin_purge_mem(read, min_offset_plus_one-1);\n\t}\n\n\t\/\/we reached end of playback due to play range request, we must send eos - however for safety reason with DASH, we first need to cancel the input\n\tif (read->pid && check_forced_end && (nb_forced_end==count)) {\n\t\t\/\/abort input\n\t\tGF_FilterEvent evt;\n\t\tGF_FEVT_INIT(evt, GF_FEVT_STOP, read->pid);\n\t\tgf_filter_pid_send_event(read->pid, &evt);\n\t}\n\n\n\tif (!is_active) {\n\t\treturn GF_EOS;\n\t}\n\t\/\/if (in_is_eos)\n\/\/\tgf_filter_ask_rt_reschedule(filter, 1);\n\treturn GF_OK;\n\n}","target":1,"code_token_length":3675,"total_token_length":3911,"max_tokens_setting":4096}
+{"idx":492680,"func":"vte_sequence_handler_decset_internal(VteTerminal *terminal,\n\t\t\t\t     int setting,\n\t\t\t\t     gboolean restore,\n\t\t\t\t     gboolean save,\n\t\t\t\t     gboolean set)\n{\n\tgboolean recognized = FALSE;\n\tgpointer p;\n\tguint i;\n\tstruct {\n\t\tint setting;\n\t\tgboolean *bvalue;\n\t\tgint *ivalue;\n\t\tgpointer *pvalue;\n\t\tgpointer fvalue;\n\t\tgpointer tvalue;\n\t\tVteTerminalSequenceHandler reset, set;\n\t} settings[] = {\n\t\t\/* 1: Application\/normal cursor keys. *\/\n\t\t{1, NULL, &terminal->pvt->cursor_mode, NULL,\n\t\t GINT_TO_POINTER(VTE_KEYMODE_NORMAL),\n\t\t GINT_TO_POINTER(VTE_KEYMODE_APPLICATION),\n\t\t NULL, NULL,},\n\t\t\/* 2: disallowed, we don't do VT52. *\/\n\t\t{2, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 3: disallowed, window size is set by user. *\/\n\t\t{3, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 4: Smooth scroll. *\/\n\t\t{4, &terminal->pvt->smooth_scroll, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 5: Reverse video. *\/\n\t\t{5, &terminal->pvt->screen->reverse_mode, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 6: Origin mode: when enabled, cursor positioning is\n\t\t * relative to the scrolling region. *\/\n\t\t{6, &terminal->pvt->screen->origin_mode, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 7: Wraparound mode. *\/\n\t\t{7, &terminal->pvt->flags.am, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 8: disallowed, keyboard repeat is set by user. *\/\n\t\t{8, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 9: Send-coords-on-click. *\/\n\t\t{9, NULL, &terminal->pvt->mouse_tracking_mode, NULL,\n\t\t GINT_TO_POINTER(0),\n\t\t GINT_TO_POINTER(MOUSE_TRACKING_SEND_XY_ON_CLICK),\n\t\t NULL, NULL,},\n\t\t\/* 12: disallowed, cursor blinks is set by user. *\/\n\t\t{12, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 18: print form feed. *\/\n\t\t\/* 19: set print extent to full screen. *\/\n\t\t\/* 25: Cursor visible. *\/\n\t\t{25, &terminal->pvt->cursor_visible, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 30\/rxvt: disallowed, scrollbar visibility is set by user. *\/\n\t\t{30, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 35\/rxvt: disallowed, fonts set by user. *\/\n\t\t{35, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 38: enter Tektronix mode. *\/\n\t\t\/* 40: disallowed, the user sizes dynamically. *\/\n\t\t{40, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 41: more(1) fix. *\/\n\t\t\/* 42: Enable NLS replacements. *\/\n\t\t{42, &terminal->pvt->nrc_mode, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 44: Margin bell. *\/\n\t\t{44, &terminal->pvt->margin_bell, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 47: Alternate screen. *\/\n\t\t{47, NULL, NULL, (gpointer) &terminal->pvt->screen,\n\t\t &terminal->pvt->normal_screen,\n\t\t &terminal->pvt->alternate_screen,\n\t\t NULL, NULL,},\n\t\t\/* 66: Keypad mode. *\/\n\t\t{66, &terminal->pvt->keypad_mode, NULL, NULL,\n\t\t GINT_TO_POINTER(VTE_KEYMODE_NORMAL),\n\t\t GINT_TO_POINTER(VTE_KEYMODE_APPLICATION),\n\t\t NULL, NULL,},\n\t\t\/* 67: disallowed, backspace key policy is set by user. *\/\n\t\t{67, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 1000: Send-coords-on-button. *\/\n\t\t{1000, NULL, &terminal->pvt->mouse_tracking_mode, NULL,\n\t\t GINT_TO_POINTER(0),\n\t\t GINT_TO_POINTER(MOUSE_TRACKING_SEND_XY_ON_BUTTON),\n\t\t NULL, NULL,},\n\t\t\/* 1001: Hilite tracking. *\/\n\t\t{1001, NULL, &terminal->pvt->mouse_tracking_mode, NULL,\n\t\t GINT_TO_POINTER(0),\n\t\t GINT_TO_POINTER(MOUSE_TRACKING_HILITE_TRACKING),\n\t\t NULL, NULL,},\n\t\t\/* 1002: Cell motion tracking. *\/\n\t\t{1002, NULL, &terminal->pvt->mouse_tracking_mode, NULL,\n\t\t GINT_TO_POINTER(0),\n\t\t GINT_TO_POINTER(MOUSE_TRACKING_CELL_MOTION_TRACKING),\n\t\t NULL, NULL,},\n\t\t\/* 1003: All motion tracking. *\/\n\t\t{1003, NULL, &terminal->pvt->mouse_tracking_mode, NULL,\n\t\t GINT_TO_POINTER(0),\n\t\t GINT_TO_POINTER(MOUSE_TRACKING_ALL_MOTION_TRACKING),\n\t\t NULL, NULL,},\n\t\t\/* 1010\/rxvt: disallowed, scroll-on-output is set by user. *\/\n\t\t{1010, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 1011\/rxvt: disallowed, scroll-on-keypress is set by user. *\/\n\t\t{1011, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 1035: disallowed, don't know what to do with it. *\/\n\t\t{1035, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 1036: Meta-sends-escape. *\/\n\t\t{1036, &terminal->pvt->meta_sends_escape, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t\t\/* 1037: disallowed, delete key policy is set by user. *\/\n\t\t{1037, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},\n\t\t\/* 1047: Use alternate screen buffer. *\/\n\t\t{1047, NULL, NULL, (gpointer) &terminal->pvt->screen,\n\t\t &terminal->pvt->normal_screen,\n\t\t &terminal->pvt->alternate_screen,\n\t\t NULL, NULL,},\n\t\t\/* 1048: Save\/restore cursor position. *\/\n\t\t{1048, NULL, NULL, NULL,\n\t\t NULL,\n\t\t NULL,\n\t\t vte_sequence_handler_rc,\n\t\t vte_sequence_handler_sc,},\n\t\t\/* 1049: Use alternate screen buffer, saving the cursor\n\t\t * position. *\/\n\t\t{1049, NULL, NULL, (gpointer) &terminal->pvt->screen,\n\t\t &terminal->pvt->normal_screen,\n\t\t &terminal->pvt->alternate_screen,\n\t\t vte_sequence_handler_rc,\n\t\t vte_sequence_handler_sc,},\n\t\t\/* 1051: Sun function key mode. *\/\n\t\t{1051, NULL, NULL, (gpointer) &terminal->pvt->sun_fkey_mode,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL},\n\t\t\/* 1052: HP function key mode. *\/\n\t\t{1052, NULL, NULL, (gpointer) &terminal->pvt->hp_fkey_mode,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL},\n\t\t\/* 1060: Legacy function key mode. *\/\n\t\t{1060, NULL, NULL, (gpointer) &terminal->pvt->legacy_fkey_mode,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL},\n\t\t\/* 1061: VT220 function key mode. *\/\n\t\t{1061, NULL, NULL, (gpointer) &terminal->pvt->vt220_fkey_mode,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL},\n\t\t\/* 2004: Bracketed paste mode. *\/\n\t\t{2004, &terminal->pvt->screen->bracketed_paste_mode, NULL, NULL,\n\t\t GINT_TO_POINTER(FALSE),\n\t\t GINT_TO_POINTER(TRUE),\n\t\t NULL, NULL,},\n\t};\n\n\t\/* Handle the setting. *\/\n\tfor (i = 0; i < G_N_ELEMENTS(settings); i++)\n\tif (settings[i].setting == setting) {\n\t\trecognized = TRUE;\n\t\t\/* Handle settings we want to ignore. *\/\n\t\tif ((settings[i].fvalue == settings[i].tvalue) &&\n\t\t    (settings[i].set == NULL) &&\n\t\t    (settings[i].reset == NULL)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Read the old setting. *\/\n\t\tif (restore) {\n\t\t\tp = g_hash_table_lookup(terminal->pvt->dec_saved,\n\t\t\t\t\t\tGINT_TO_POINTER(setting));\n\t\t\tset = (p != NULL);\n\t\t\t_vte_debug_print(VTE_DEBUG_PARSE,\n\t\t\t\t\t\"Setting %d was %s.\\n\",\n\t\t\t\t\tsetting, set ? \"set\" : \"unset\");\n\t\t}\n\t\t\/* Save the current setting. *\/\n\t\tif (save) {\n\t\t\tif (settings[i].bvalue) {\n\t\t\t\tset = *(settings[i].bvalue) != FALSE;\n\t\t\t} else\n\t\t\tif (settings[i].ivalue) {\n\t\t\t\tset = *(settings[i].ivalue) ==\n\t\t\t\t      GPOINTER_TO_INT(settings[i].tvalue);\n\t\t\t} else\n\t\t\tif (settings[i].pvalue) {\n\t\t\t\tset = *(settings[i].pvalue) ==\n\t\t\t\t      settings[i].tvalue;\n\t\t\t}\n\t\t\t_vte_debug_print(VTE_DEBUG_PARSE,\n\t\t\t\t\t\"Setting %d is %s, saving.\\n\",\n\t\t\t\t\tsetting, set ? \"set\" : \"unset\");\n\t\t\tg_hash_table_insert(terminal->pvt->dec_saved,\n\t\t\t\t\t    GINT_TO_POINTER(setting),\n\t\t\t\t\t    GINT_TO_POINTER(set));\n\t\t}\n\t\t\/* Change the current setting to match the new\/saved value. *\/\n\t\tif (!save) {\n\t\t\t_vte_debug_print(VTE_DEBUG_PARSE,\n\t\t\t\t\t\"Setting %d to %s.\\n\",\n\t\t\t\t\tsetting, set ? \"set\" : \"unset\");\n\t\t\tif (settings[i].set && set) {\n\t\t\t\tsettings[i].set (terminal, NULL);\n\t\t\t}\n\t\t\tif (settings[i].bvalue) {\n\t\t\t\t*(settings[i].bvalue) = set;\n\t\t\t} else\n\t\t\tif (settings[i].ivalue) {\n\t\t\t\t*(settings[i].ivalue) = set ?\n\t\t\t\t\tGPOINTER_TO_INT(settings[i].tvalue) :\n\t\t\t\t\tGPOINTER_TO_INT(settings[i].fvalue);\n\t\t\t} else\n\t\t\tif (settings[i].pvalue) {\n\t\t\t\t*(settings[i].pvalue) = set ?\n\t\t\t\t\tsettings[i].tvalue :\n\t\t\t\t\tsettings[i].fvalue;\n\t\t\t}\n\t\t\tif (settings[i].reset && !set) {\n\t\t\t\tsettings[i].reset (terminal, NULL);\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Do whatever's necessary when the setting changes. *\/\n\tswitch (setting) {\n\tcase 1:\n\t\t_vte_debug_print(VTE_DEBUG_KEYBOARD, set ?\n\t\t\t\t\"Entering application cursor mode.\\n\" :\n\t\t\t\t\"Leaving application cursor mode.\\n\");\n\t\tbreak;\n#if 0\t\t\/* 3: disallowed, window size is set by user. *\/\n\tcase 3:\n\t\tvte_terminal_emit_resize_window(terminal,\n\t\t\t\t\t\t(set ? 132 : 80) *\n\t\t\t\t\t\tterminal->char_width +\n\t\t\t\t\t\tterminal->pvt->inner_border.left +\n                                                terminal->pvt->inner_border.right,\n\t\t\t\t\t\tterminal->row_count *\n\t\t\t\t\t\tterminal->char_height +\n\t\t\t\t\t\tterminal->pvt->inner_border.top +\n                                                terminal->pvt->inner_border.bottom);\n\t\t\/* Request a resize and redraw. *\/\n\t\t_vte_invalidate_all(terminal);\n\t\tbreak;\n#endif\n\tcase 5:\n\t\t\/* Repaint everything in reverse mode. *\/\n\t\t_vte_invalidate_all(terminal);\n\t\tbreak;\n\tcase 6:\n\t\t\/* Reposition the cursor in its new home position. *\/\n\t\tterminal->pvt->screen->cursor_current.col = 0;\n\t\tterminal->pvt->screen->cursor_current.row =\n\t\t\tterminal->pvt->screen->insert_delta;\n\t\tbreak;\n\tcase 47:\n\tcase 1047:\n\tcase 1049:\n\t\t\/* Clear the alternate screen if we're switching\n\t\t * to it, and home the cursor. *\/\n\t\tif (set) {\n\t\t\t_vte_terminal_clear_screen (terminal);\n\t\t\t_vte_terminal_home_cursor (terminal);\n\t\t}\n\t\t\/* Reset scrollbars and repaint everything. *\/\n\t\tgtk_adjustment_set_value(terminal->adjustment,\n\t\t\t\t\t terminal->pvt->screen->scroll_delta);\n\t\tvte_terminal_set_scrollback_lines(terminal,\n\t\t\t\tterminal->pvt->scrollback_lines);\n\t\t_vte_terminal_queue_contents_changed(terminal);\n\t\t_vte_invalidate_all (terminal);\n\t\tbreak;\n\tcase 9:\n\tcase 1000:\n\tcase 1001:\n\tcase 1002:\n\tcase 1003:\n\t\t\/* Make the pointer visible. *\/\n\t\t_vte_terminal_set_pointer_visible(terminal, TRUE);\n\t\tbreak;\n\tcase 66:\n\t\t_vte_debug_print(VTE_DEBUG_KEYBOARD, set ?\n\t\t\t\t\"Entering application keypad mode.\\n\" :\n\t\t\t\t\"Leaving application keypad mode.\\n\");\n\t\tbreak;\n\tcase 1051:\n\t\t_vte_debug_print(VTE_DEBUG_KEYBOARD, set ?\n\t\t\t\t\"Entering Sun fkey mode.\\n\" :\n\t\t\t\t\"Leaving Sun fkey mode.\\n\");\n\t\tbreak;\n\tcase 1052:\n\t\t_vte_debug_print(VTE_DEBUG_KEYBOARD, set ?\n\t\t\t\t\"Entering HP fkey mode.\\n\" :\n\t\t\t\t\"Leaving HP fkey mode.\\n\");\n\t\tbreak;\n\tcase 1060:\n\t\t_vte_debug_print(VTE_DEBUG_KEYBOARD, set ?\n\t\t\t\t\"Entering Legacy fkey mode.\\n\" :\n\t\t\t\t\"Leaving Legacy fkey mode.\\n\");\n\t\tbreak;\n\tcase 1061:\n\t\t_vte_debug_print(VTE_DEBUG_KEYBOARD, set ?\n\t\t\t\t\"Entering VT220 fkey mode.\\n\" :\n\t\t\t\t\"Leaving VT220 fkey mode.\\n\");\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (!recognized) {\n\t\t_vte_debug_print (VTE_DEBUG_MISC,\n\t\t\t\t  \"DECSET\/DECRESET mode %d not recognized, ignoring.\\n\",\n\t\t\t\t  setting);\n\t}\n}","target":0,"code_token_length":3422,"total_token_length":3658,"max_tokens_setting":4096}
+{"idx":379671,"func":"static void extract_arg(RAnal *anal, RAnalFunction *fcn, RAnalOp *op, const char *reg, const char *sign, char type) {\n\tst64 ptr = 0;\n\tchar *addr, *esil_buf = NULL;\n\tconst st64 maxstackframe = 1024 * 8; \n\n\tr_return_if_fail (anal && fcn && op && reg);\n\n\tsize_t i;\n\tfor (i = 0; i < R_ARRAY_SIZE (op->src); i++) {\n\t\tif (op->src[i] && op->src[i]->reg && op->src[i]->reg->name) {\n\t\t\tif (!strcmp (reg, op->src[i]->reg->name)) {\n\t\t\t\tst64 delta = op->src[i]->delta;\n\t\t\t\tif ((delta > 0 && *sign == '+') || (delta < 0 && *sign == '-')) {\n\t\t\t\t\tptr = R_ABS (op->src[i]->delta);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!ptr) {\n\t\tconst char *op_esil = r_strbuf_get (&op->esil);\n\t\tif (!op_esil) {\n\t\t\treturn;\n\t\t}\n\t\tesil_buf = strdup (op_esil);\n\t\tif (!esil_buf) {\n\t\t\treturn;\n\t\t}\n\t\tr_strf_var (esilexpr, 64, \",%s,%s,\", reg, sign);\n\t\tchar *ptr_end = strstr (esil_buf, esilexpr);\n\t\tif (!ptr_end) {\n\t\t\tfree (esil_buf);\n\t\t\treturn;\n\t\t}\n\t\t*ptr_end = 0;\n\t\taddr = ptr_end;\n\t\twhile ((addr[0] != '0' || addr[1] != 'x') && addr >= esil_buf + 1 && *addr != ',') {\n\t\t\taddr--;\n\t\t}\n\t\tif (strncmp (addr, \"0x\", 2)) {\n\t\t\t\/\/XXX: This is a workaround for inconsistent esil\n\t\t\tif (!op->stackop && op->dst) {\n\t\t\t\tconst char *sp = r_reg_get_name (anal->reg, R_REG_NAME_SP);\n\t\t\t\tconst char *bp = r_reg_get_name (anal->reg, R_REG_NAME_BP);\n\t\t\t\tconst char *rn = op->dst->reg ? op->dst->reg->name : NULL;\n\t\t\t\tif (rn && ((bp && !strcmp (bp, rn)) || (sp && !strcmp (sp, rn)))) {\n\t\t\t\t\tif (anal->verbose) {\n\t\t\t\t\t\teprintf (\"Warning: Analysis didn't fill op->stackop for instruction that alters stack at 0x%\" PFMT64x \".\\n\", op->addr);\n\t\t\t\t\t}\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (*addr == ',') {\n\t\t\t\taddr++;\n\t\t\t}\n\t\t\tif (!op->stackop && op->type != R_ANAL_OP_TYPE_PUSH && op->type != R_ANAL_OP_TYPE_POP\n\t\t\t\t&& op->type != R_ANAL_OP_TYPE_RET && r_str_isnumber (addr)) {\n\t\t\t\tptr = (st64)r_num_get (NULL, addr);\n\t\t\t\tif (ptr && op->src[0] && ptr == op->src[0]->imm) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t} else if ((op->stackop == R_ANAL_STACK_SET) || (op->stackop == R_ANAL_STACK_GET)) {\n\t\t\t\tif (op->ptr % 4) {\n\t\t\t\t\tgoto beach;\n\t\t\t\t}\n\t\t\t\tptr = R_ABS (op->ptr);\n\t\t\t} else {\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t} else {\n\t\t\tptr = (st64)r_num_get (NULL, addr);\n\t\t}\n\t}\n\n\tif (anal->verbose && (!op->src[0] || !op->dst)) {\n\t\teprintf (\"Warning: Analysis didn't fill op->src\/dst at 0x%\" PFMT64x \".\\n\", op->addr);\n\t}\n\n\tint rw = (op->direction == R_ANAL_OP_DIR_WRITE) ? R_ANAL_VAR_ACCESS_TYPE_WRITE : R_ANAL_VAR_ACCESS_TYPE_READ;\n\tif (*sign == '+') {\n\t\tconst bool isarg = type == R_ANAL_VAR_KIND_SPV ? ptr >= fcn->stack : ptr >= fcn->bp_off;\n\t\tconst char *pfx = isarg ? ARGPREFIX : VARPREFIX;\n\t\tst64 frame_off;\n\t\tif (type == R_ANAL_VAR_KIND_SPV) {\n\t\t\tframe_off = ptr - fcn->stack;\n\t\t} else {\n\t\t\tframe_off = ptr - fcn->bp_off;\n\t\t}\n\t\tif (maxstackframe != 0 && (frame_off > maxstackframe || frame_off < -maxstackframe)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tRAnalVar *var = get_stack_var (fcn, frame_off);\n\t\tif (var) {\n\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, ptr);\n\t\t\tgoto beach;\n\t\t}\n\t\tchar *varname = NULL, *vartype = NULL;\n\t\tif (isarg) {\n\t\t\tconst char *place = fcn->cc ? r_anal_cc_arg (anal, fcn->cc, ST32_MAX) : NULL;\n\t\t\tbool stack_rev = place ? !strcmp (place, \"stack_rev\") : false;\n\t\t\tchar *fname = r_type_func_guess (anal->sdb_types, fcn->name);\n\t\t\tif (fname) {\n\t\t\t\tut64 sum_sz = 0;\n\t\t\t\tsize_t from, to, i;\n\t\t\t\tif (stack_rev) {\n\t\t\t\t\tconst size_t cnt = r_type_func_args_count (anal->sdb_types, fname);\n\t\t\t\t\tfrom = cnt ? cnt - 1 : cnt;\n\t\t\t\t\tto = fcn->cc ? r_anal_cc_max_arg (anal, fcn->cc) : 0;\n\t\t\t\t} else {\n\t\t\t\t\tfrom = fcn->cc ? r_anal_cc_max_arg (anal, fcn->cc) : 0;\n\t\t\t\t\tto = r_type_func_args_count (anal->sdb_types, fname);\n\t\t\t\t}\n\t\t\t\tconst int bytes = (fcn->bits ? fcn->bits : anal->bits) \/ 8;\n\t\t\t\tfor (i = from; stack_rev ? i >= to : i < to; stack_rev ? i-- : i++) {\n\t\t\t\t\tchar *tp = r_type_func_args_type (anal->sdb_types, fname, i);\n\t\t\t\t\tif (!tp) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (sum_sz == frame_off) {\n\t\t\t\t\t\tvartype = tp;\n\t\t\t\t\t\tvarname = strdup (r_type_func_args_name (anal->sdb_types, fname, i));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tut64 bit_sz = r_type_get_bitsize (anal->sdb_types, tp);\n\t\t\t\t\tsum_sz += bit_sz ? bit_sz \/ 8 : bytes;\n\t\t\t\t\tsum_sz = R_ROUND (sum_sz, bytes);\n\t\t\t\t\tfree (tp);\n\t\t\t\t}\n\t\t\t\tfree (fname);\n\t\t\t}\n\t\t}\n\t\tif (!varname) {\n\t\t\tif (anal->opt.varname_stack) {\n\t\t\t\tvarname = r_str_newf (\"%s_%\" PFMT64x \"h\", pfx, R_ABS (frame_off));\n\t\t\t} else {\n\t\t\t\tvarname = r_anal_function_autoname_var (fcn, type, pfx, ptr);\n\t\t\t}\n\t\t}\n\t\tif (varname) {\n#if 0\n\t\t\tif (isarg && frame_off > 48) {\n\t\t\t\tfree (varname);\n\t\t\t\tgoto beach;\n\t\t\t}\n#endif\n\t\t\tRAnalVar *var = r_anal_function_set_var (fcn, frame_off, type, vartype, anal->bits \/ 8, isarg, varname);\n\t\t\tif (var) {\n\t\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, ptr);\n\t\t\t}\n\t\t\tfree (varname);\n\t\t}\n\t\tfree (vartype);\n\t} else {\n\t\tst64 frame_off = -(ptr + fcn->bp_off);\n\t\tif (maxstackframe > 0 && (frame_off > maxstackframe || frame_off < -maxstackframe)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tRAnalVar *var = get_stack_var (fcn, frame_off);\n\t\tif (var) {\n\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, -ptr);\n\t\t\tgoto beach;\n\t\t}\n\t\tchar *varname = anal->opt.varname_stack\n\t\t\t? r_str_newf (\"%s_%\" PFMT64x \"h\", VARPREFIX, R_ABS (frame_off))\n\t\t\t: r_anal_function_autoname_var (fcn, type, VARPREFIX, -ptr);\n\t\tif (varname) {\n\t\t\tRAnalVar *var = r_anal_function_set_var (fcn, frame_off, type, NULL, anal->bits \/ 8, false, varname);\n\t\t\tif (var) {\n\t\t\t\tr_anal_var_set_access (var, reg, op->addr, rw, -ptr);\n\t\t\t}\n\t\t\tfree (varname);\n\t\t}\n\t}\nbeach:\n\tfree (esil_buf);\n}","target":0,"code_token_length":1961,"total_token_length":2197,"max_tokens_setting":4096}
+{"idx":335426,"func":"find_ex_command(\n\texarg_T *eap,\n\tint\t*full UNUSED,\n\tint\t(*lookup)(char_u *, size_t, int cmd, cctx_T *) UNUSED,\n\tcctx_T\t*cctx UNUSED)\n{\n    int\t\tlen;\n    char_u\t*p;\n    int\t\ti;\n#ifndef FEAT_EVAL\n    int\t\tvim9 = FALSE;\n#else\n    int\t\tvim9 = in_vim9script();\n\n    \/*\n     * Recognize a Vim9 script function\/method call and assignment:\n     * \"lvar = value\", \"lvar(arg)\", \"[1, 2 3]->Func()\"\n     *\/\n    p = eap->cmd;\n    if (lookup != NULL)\n    {\n\tchar_u *pskip = skip_option_env_lead(eap->cmd);\n\n\tif (vim_strchr((char_u *)\"{('[\\\"@&$\", *p) != NULL\n\t       || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)\n\t       || (p[0] == '0' && p[1] == 'z'))\n\t{\n\t    int\t    oplen;\n\t    int\t    heredoc;\n\t    char_u  *swp;\n\n\t    if (*eap->cmd == '&'\n\t\t    || *eap->cmd == '$'\n\t\t    || (eap->cmd[0] == '@'\n\t\t\t\t\t&& (valid_yank_reg(eap->cmd[1], FALSE)\n\t\t\t\t\t\t       || eap->cmd[1] == '@')))\n\t    {\n\t\tif (*eap->cmd == '&')\n\t\t{\n\t\t    p = eap->cmd + 1;\n\t\t    if (STRNCMP(\"l:\", p, 2) == 0 || STRNCMP(\"g:\", p, 2) == 0)\n\t\t\tp += 2;\n\t\t    p = to_name_end(p, FALSE);\n\t\t}\n\t\telse if (*eap->cmd == '$')\n\t\t    p = to_name_end(eap->cmd + 1, FALSE);\n\t\telse\n\t\t    p = eap->cmd + 2;\n\t\tif (ends_excmd(*skipwhite(p)))\n\t\t{\n\t\t    \/\/ \"&option <NL>\", \"$ENV <NL>\" and \"@r <NL>\" are the start\n\t\t    \/\/ of an expression.\n\t\t    eap->cmdidx = CMD_eval;\n\t\t    return eap->cmd;\n\t\t}\n\t\t\/\/ \"&option\" can be followed by \"->\" or \"=\", check below\n\t    }\n\n\t    swp = skipwhite(p);\n\n\t    if (\n\t\t\/\/ \"(...\" is an expression.\n\t\t\/\/ \"funcname(\" is always a function call.\n\t\t*p == '('\n\t\t    || (p == eap->cmd\n\t\t\t? (\n\t\t\t    \/\/ \"{...\" is a dict expression or block start.\n\t\t\t    *eap->cmd == '{'\n\t\t\t    \/\/ \"'string'->func()\" is an expression.\n\t\t\t || *eap->cmd == '\\''\n\t\t\t    \/\/ '\"string\"->func()' is an expression.\n\t\t\t || (eap->cmd[0] == '0' && eap->cmd[1] == 'z')\n\t\t\t    \/\/ '\"string\"->func()' is an expression.\n\t\t\t || *eap->cmd == '\"'\n\t\t\t    \/\/ \"g:varname\" is an expression.\n\t\t\t || eap->cmd[1] == ':'\n\t\t\t    )\n\t\t\t    \/\/ \"varname->func()\" is an expression.\n\t\t\t: (*swp == '-' && swp[1] == '>')))\n\t    {\n\t\tif (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1)))\n\t\t{\n\t\t    \/\/ \"{\" by itself is the start of a block.\n\t\t    eap->cmdidx = CMD_block;\n\t\t    return eap->cmd + 1;\n\t\t}\n\t\teap->cmdidx = CMD_eval;\n\t\treturn eap->cmd;\n\t    }\n\n\t    if ((p != eap->cmd && (\n\t\t\t    \/\/ \"varname[]\" is an expression.\n\t\t\t    *p == '['\n\t\t\t    \/\/ \"varname.key\" is an expression.\n\t\t\t || (*p == '.'\n\t\t\t\t     && (ASCII_ISALPHA(p[1]) || p[1] == '_'))))\n\t\t\t\/\/ g:[key] is an expression\n\t\t    || STRNCMP(eap->cmd, \"g:[\", 3) == 0)\n\t    {\n\t\tchar_u\t*after = eap->cmd;\n\n\t\t\/\/ When followed by \"=\" or \"+=\" then it is an assignment.\n\t\t\/\/ Skip over the whole thing, it can be:\n\t\t\/\/\tname.member = val\n\t\t\/\/\tname[a : b] = val\n\t\t\/\/\tname[idx] = val\n\t\t\/\/\tname[idx].member = val\n\t\t\/\/\tetc.\n\t\teap->cmdidx = CMD_eval;\n\t\t++emsg_silent;\n\t\tif (skip_expr(&after, NULL) == OK)\n\t\t{\n\t\t    after = skipwhite(after);\n\t\t    if (*after == '=' || (*after != NUL && after[1] == '=')\n\t\t\t\t\t || (after[0] == '.' && after[1] == '.'\n\t\t\t\t\t\t\t   && after[2] == '='))\n\t\t\teap->cmdidx = CMD_var;\n\t\t}\n\t\t--emsg_silent;\n\t\treturn eap->cmd;\n\t    }\n\n\t    \/\/ \"[...]->Method()\" is a list expression, but \"[a, b] = Func()\" is\n\t    \/\/ an assignment.\n\t    \/\/ If there is no line break inside the \"[...]\" then \"p\" is\n\t    \/\/ advanced to after the \"]\" by to_name_const_end(): check if a \"=\"\n\t    \/\/ follows.\n\t    \/\/ If \"[...]\" has a line break \"p\" still points at the \"[\" and it\n\t    \/\/ can't be an assignment.\n\t    if (*eap->cmd == '[')\n\t    {\n\t\tchar_u\t    *eq;\n\n\t\tp = to_name_const_end(eap->cmd);\n\t\tif (p == eap->cmd && *p == '[')\n\t\t{\n\t\t    int count = 0;\n\t\t    int\tsemicolon = FALSE;\n\n\t\t    p = skip_var_list(eap->cmd, TRUE, &count, &semicolon, TRUE);\n\t\t}\n\t\teq = p;\n\t\tif (eq != NULL)\n\t\t{\n\t\t    eq = skipwhite(eq);\n\t\t    if (vim_strchr((char_u *)\"+-*\/%\", *eq) != NULL)\n\t\t\t++eq;\n\t\t}\n\t\tif (p == NULL || p == eap->cmd || *eq != '=')\n\t\t{\n\t\t    eap->cmdidx = CMD_eval;\n\t\t    return eap->cmd;\n\t\t}\n\t\tif (p > eap->cmd && *eq == '=')\n\t\t{\n\t\t    eap->cmdidx = CMD_var;\n\t\t    return eap->cmd;\n\t\t}\n\t    }\n\n\t    \/\/ Recognize an assignment if we recognize the variable name:\n\t    \/\/ \"g:var = expr\"\n\t    \/\/ \"@r = expr\"\n\t    \/\/ \"&opt = expr\"\n\t    \/\/ \"var = expr\"  where \"var\" is a variable name or we are skipping\n\t    \/\/ (variable declaration might have been skipped).\n\t    \/\/ Not \"redir => var\" (when skipping).\n\t    oplen = assignment_len(skipwhite(p), &heredoc);\n\t    if (oplen > 0)\n\t    {\n\t\tif (((p - eap->cmd) > 2 && eap->cmd[1] == ':')\n\t\t\t|| *eap->cmd == '&'\n\t\t\t|| *eap->cmd == '$'\n\t\t\t|| *eap->cmd == '@'\n\t\t\t|| (eap->skip && IS_WHITE_OR_NUL(\n\t\t\t\t\t\t      *(skipwhite(p) + oplen)))\n\t\t\t|| lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK)\n\t\t{\n\t\t    eap->cmdidx = CMD_var;\n\t\t    return eap->cmd;\n\t\t}\n\t    }\n\n\t    \/\/ Recognize using a type for a w:, b:, t: or g: variable:\n\t    \/\/ \"w:varname: number = 123\".\n\t    if (eap->cmd[1] == ':' && *p == ':')\n\t    {\n\t\teap->cmdidx = CMD_eval;\n\t\treturn eap->cmd;\n\t    }\n\t}\n\n\t\/\/ \"g:\", \"s:\" and \"l:\" are always assumed to be a variable, thus start\n\t\/\/ an expression.  A global\/substitute\/list command needs to use a\n\t\/\/ longer name.\n\tif (vim_strchr((char_u *)\"gsl\", *p) != NULL && p[1] == ':')\n\t{\n\t    eap->cmdidx = CMD_eval;\n\t    return eap->cmd;\n\t}\n\n\t\/\/ If it is an ID it might be a variable with an operator on the next\n\t\/\/ line, if the variable exists it can't be an Ex command.\n\tif (p > eap->cmd && ends_excmd(*skipwhite(p))\n\t\t&& (lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK\n\t\t    || (ASCII_ISALPHA(eap->cmd[0]) && eap->cmd[1] == ':')))\n\t{\n\t    eap->cmdidx = CMD_eval;\n\t    return eap->cmd;\n\t}\n\n\t\/\/ Check for \"++nr\" and \"--nr\".\n\tif (p == eap->cmd && p[0] != NUL && p[0] == p[1]\n\t\t\t\t\t\t   && (*p == '+' || *p == '-'))\n\t{\n\t    eap->cmdidx = *p == '+' ? CMD_increment : CMD_decrement;\n\t    return eap->cmd + 2;\n\t}\n    }\n#endif\n\n    \/*\n     * Isolate the command and search for it in the command table.\n     *\/\n    p = eap->cmd;\n    if (one_letter_cmd(p, &eap->cmdidx))\n    {\n\t++p;\n    }\n    else\n    {\n\twhile (ASCII_ISALPHA(*p))\n\t    ++p;\n\t\/\/ for python 3.x support \":py3\", \":python3\", \":py3file\", etc.\n\tif (eap->cmd[0] == 'p' && eap->cmd[1] == 'y')\n\t{\n\t    while (ASCII_ISALNUM(*p))\n\t\t++p;\n\t}\n\telse if (*p == '9' && STRNCMP(\"vim9\", eap->cmd, 4) == 0)\n\t{\n\t    \/\/ include \"9\" for \"vim9*\" commands; \"vim9cmd\" and \"vim9script\".\n\t    ++p;\n\t    while (ASCII_ISALPHA(*p))\n\t\t++p;\n\t}\n\n\t\/\/ check for non-alpha command\n\tif (p == eap->cmd && vim_strchr((char_u *)\"@*!=><&~#}\", *p) != NULL)\n\t    ++p;\n\tlen = (int)(p - eap->cmd);\n\t\/\/ The \"d\" command can directly be followed by 'l' or 'p' flag, when\n\t\/\/ not in Vim9 script.\n\tif (!vim9 && *eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))\n\t{\n\t    \/\/ Check for \":dl\", \":dell\", etc. to \":deletel\": that's\n\t    \/\/ :delete with the 'l' flag.  Same for 'p'.\n\t    for (i = 0; i < len; ++i)\n\t\tif (eap->cmd[i] != ((char_u *)\"delete\")[i])\n\t\t    break;\n\t    if (i == len - 1)\n\t    {\n\t\t--len;\n\t\tif (p[-1] == 'l')\n\t\t    eap->flags |= EXFLAG_LIST;\n\t\telse\n\t\t    eap->flags |= EXFLAG_PRINT;\n\t    }\n\t}\n\n\tif (ASCII_ISLOWER(eap->cmd[0]))\n\t{\n\t    int c1 = eap->cmd[0];\n\t    int c2 = len == 1 ? NUL : eap->cmd[1];\n\n\t    if (command_count != (int)CMD_SIZE)\n\t    {\n\t\tiemsg(_(e_command_table_needs_to_be_updated_run_make_cmdidxs));\n\t\tgetout(1);\n\t    }\n\n\t    \/\/ Use a precomputed index for fast look-up in cmdnames[]\n\t    \/\/ taking into account the first 2 letters of eap->cmd.\n\t    eap->cmdidx = cmdidxs1[CharOrdLow(c1)];\n\t    if (ASCII_ISLOWER(c2))\n\t\teap->cmdidx += cmdidxs2[CharOrdLow(c1)][CharOrdLow(c2)];\n\t}\n\telse if (ASCII_ISUPPER(eap->cmd[0]))\n\t    eap->cmdidx = CMD_Next;\n\telse\n\t    eap->cmdidx = CMD_bang;\n\n\tfor ( ; (int)eap->cmdidx < (int)CMD_SIZE;\n\t\t\t       eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1))\n\t    if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd,\n\t\t\t\t\t\t\t    (size_t)len) == 0)\n\t    {\n#ifdef FEAT_EVAL\n\t\tif (full != NULL && cmdnames[eap->cmdidx].cmd_name[len] == NUL)\n\t\t    *full = TRUE;\n#endif\n\t\tbreak;\n\t    }\n\n\t\/\/ :Print and :mode are not supported in Vim9 script.\n\t\/\/ Some commands cannot be shortened in Vim9 script.\n\tif (vim9 && eap->cmdidx != CMD_SIZE)\n\t{\n\t    if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)\n\t\teap->cmdidx = CMD_SIZE;\n\t    else if ((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)\n\t\t\t  && len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))\n\t    {\n\t\tsemsg(_(e_command_cannot_be_shortened_str), eap->cmd);\n\t\teap->cmdidx = CMD_SIZE;\n\t    }\n\t}\n\n\t\/\/ Do not recognize \":*\" as the star command unless '*' is in\n\t\/\/ 'cpoptions'.\n\tif (eap->cmdidx == CMD_star && vim_strchr(p_cpo, CPO_STAR) == NULL)\n\t    p = eap->cmd;\n\n\t\/\/ Look for a user defined command as a last resort.  Let \":Print\" be\n\t\/\/ overruled by a user defined command.\n\tif ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print)\n\t\t&& *eap->cmd >= 'A' && *eap->cmd <= 'Z')\n\t{\n\t    \/\/ User defined commands may contain digits.\n\t    while (ASCII_ISALNUM(*p))\n\t\t++p;\n\t    p = find_ucmd(eap, p, full, NULL, NULL);\n\t}\n\tif (p == NULL || p == eap->cmd)\n\t    eap->cmdidx = CMD_SIZE;\n    }\n\n    \/\/ \":fina\" means \":finally\" in legacy script, for backwards compatibility.\n    if (eap->cmdidx == CMD_final && p - eap->cmd == 4 && !vim9)\n\teap->cmdidx = CMD_finally;\n\n#ifdef FEAT_EVAL\n    if (eap->cmdidx < CMD_SIZE\n\t    && vim9\n\t    && !IS_WHITE_OR_NUL(*p) && *p != '\\n' && *p != '!' && *p != '|'\n\t    && (eap->cmdidx < 0 ||\n\t\t(cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))\n    {\n\tchar_u *cmd = vim_strnsave(eap->cmd, p - eap->cmd);\n\n\tsemsg(_(e_command_str_not_followed_by_white_space_str), cmd, eap->cmd);\n\teap->cmdidx = CMD_SIZE;\n\tvim_free(cmd);\n    }\n#endif\n\n    return p;\n}","target":0,"code_token_length":3390,"total_token_length":3626,"max_tokens_setting":4096}
+{"idx":195238,"func":"setup_seccomp (FlatpakBwrap   *bwrap,\n               const char     *arch,\n               gulong          allowed_personality,\n               FlatpakRunFlags run_flags,\n               GError        **error)\n{\n  gboolean multiarch = (run_flags & FLATPAK_RUN_FLAG_MULTIARCH) != 0;\n  gboolean devel = (run_flags & FLATPAK_RUN_FLAG_DEVEL) != 0;\n\n  __attribute__((cleanup (cleanup_seccomp))) scmp_filter_ctx seccomp = NULL;\n\n  \/**** BEGIN NOTE ON CODE SHARING\n   *\n   * There are today a number of different Linux container\n   * implementations.  That will likely continue for long into the\n   * future.  But we can still try to share code, and it's important\n   * to do so because it affects what library and application writers\n   * can do, and we should support code portability between different\n   * container tools.\n   *\n   * This syscall blocklist is copied from linux-user-chroot, which was in turn\n   * clearly influenced by the Sandstorm.io blocklist.\n   *\n   * If you make any changes here, I suggest sending the changes along\n   * to other sandbox maintainers.  Using the libseccomp list is also\n   * an appropriate venue:\n   * https:\/\/groups.google.com\/forum\/#!forum\/libseccomp\n   *\n   * A non-exhaustive list of links to container tooling that might\n   * want to share this blocklist:\n   *\n   *  https:\/\/github.com\/sandstorm-io\/sandstorm\n   *    in src\/sandstorm\/supervisor.c++\n   *  https:\/\/github.com\/flatpak\/flatpak.git\n   *    in common\/flatpak-run.c\n   *  https:\/\/git.gnome.org\/browse\/linux-user-chroot\n   *    in src\/setup-seccomp.c\n   *\n   **** END NOTE ON CODE SHARING\n   *\/\n  struct\n  {\n    int                  scall;\n    struct scmp_arg_cmp *arg;\n  } syscall_blocklist[] = {\n    \/* Block dmesg *\/\n    {SCMP_SYS (syslog)},\n    \/* Useless old syscall *\/\n    {SCMP_SYS (uselib)},\n    \/* Don't allow disabling accounting *\/\n    {SCMP_SYS (acct)},\n    \/* 16-bit code is unnecessary in the sandbox, and modify_ldt is a\n       historic source of interesting information leaks. *\/\n    {SCMP_SYS (modify_ldt)},\n    \/* Don't allow reading current quota use *\/\n    {SCMP_SYS (quotactl)},\n\n    \/* Don't allow access to the kernel keyring *\/\n    {SCMP_SYS (add_key)},\n    {SCMP_SYS (keyctl)},\n    {SCMP_SYS (request_key)},\n\n    \/* Scary VM\/NUMA ops *\/\n    {SCMP_SYS (move_pages)},\n    {SCMP_SYS (mbind)},\n    {SCMP_SYS (get_mempolicy)},\n    {SCMP_SYS (set_mempolicy)},\n    {SCMP_SYS (migrate_pages)},\n\n    \/* Don't allow subnamespace setups: *\/\n    {SCMP_SYS (unshare)},\n    {SCMP_SYS (mount)},\n    {SCMP_SYS (pivot_root)},\n#if defined(__s390__) || defined(__s390x__) || defined(__CRIS__)\n    \/* Architectures with CONFIG_CLONE_BACKWARDS2: the child stack\n     * and flags arguments are reversed so the flags come second *\/\n    {SCMP_SYS (clone), &SCMP_A1 (SCMP_CMP_MASKED_EQ, CLONE_NEWUSER, CLONE_NEWUSER)},\n#else\n    \/* Normally the flags come first *\/\n    {SCMP_SYS (clone), &SCMP_A0 (SCMP_CMP_MASKED_EQ, CLONE_NEWUSER, CLONE_NEWUSER)},\n#endif\n\n    \/* Don't allow faking input to the controlling tty (CVE-2017-5226) *\/\n    {SCMP_SYS (ioctl), &SCMP_A1 (SCMP_CMP_MASKED_EQ, 0xFFFFFFFFu, (int) TIOCSTI)},\n  };\n\n  struct\n  {\n    int                  scall;\n    struct scmp_arg_cmp *arg;\n  } syscall_nondevel_blocklist[] = {\n    \/* Profiling operations; we expect these to be done by tools from outside\n     * the sandbox.  In particular perf has been the source of many CVEs.\n     *\/\n    {SCMP_SYS (perf_event_open)},\n    \/* Don't allow you to switch to bsd emulation or whatnot *\/\n    {SCMP_SYS (personality), &SCMP_A0 (SCMP_CMP_NE, allowed_personality)},\n    {SCMP_SYS (ptrace)}\n  };\n  \/* Blocklist all but unix, inet, inet6 and netlink *\/\n  struct\n  {\n    int             family;\n    FlatpakRunFlags flags_mask;\n  } socket_family_allowlist[] = {\n    \/* NOTE: Keep in numerical order *\/\n    { AF_UNSPEC, 0 },\n    { AF_LOCAL, 0 },\n    { AF_INET, 0 },\n    { AF_INET6, 0 },\n    { AF_NETLINK, 0 },\n    { AF_CAN, FLATPAK_RUN_FLAG_CANBUS },\n    { AF_BLUETOOTH, FLATPAK_RUN_FLAG_BLUETOOTH },\n  };\n  int last_allowed_family;\n  int i, r;\n  g_auto(GLnxTmpfile) seccomp_tmpf  = { 0, };\n\n  seccomp = seccomp_init (SCMP_ACT_ALLOW);\n  if (!seccomp)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Initialize seccomp failed\"));\n\n  if (arch != NULL)\n    {\n      uint32_t arch_id = 0;\n      const uint32_t *extra_arches = NULL;\n\n      if (strcmp (arch, \"i386\") == 0)\n        {\n          arch_id = SCMP_ARCH_X86;\n        }\n      else if (strcmp (arch, \"x86_64\") == 0)\n        {\n          arch_id = SCMP_ARCH_X86_64;\n          extra_arches = seccomp_x86_64_extra_arches;\n        }\n      else if (strcmp (arch, \"arm\") == 0)\n        {\n          arch_id = SCMP_ARCH_ARM;\n        }\n#ifdef SCMP_ARCH_AARCH64\n      else if (strcmp (arch, \"aarch64\") == 0)\n        {\n          arch_id = SCMP_ARCH_AARCH64;\n          extra_arches = seccomp_aarch64_extra_arches;\n        }\n#endif\n\n      \/* We only really need to handle arches on multiarch systems.\n       * If only one arch is supported the default is fine *\/\n      if (arch_id != 0)\n        {\n          \/* This *adds* the target arch, instead of replacing the\n             native one. This is not ideal, because we'd like to only\n             allow the target arch, but we can't really disallow the\n             native arch at this point, because then bubblewrap\n             couldn't continue running. *\/\n          r = seccomp_arch_add (seccomp, arch_id);\n          if (r < 0 && r != -EEXIST)\n            return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to add architecture to seccomp filter\"));\n\n          if (multiarch && extra_arches != NULL)\n            {\n              for (i = 0; extra_arches[i] != 0; i++)\n                {\n                  r = seccomp_arch_add (seccomp, extra_arches[i]);\n                  if (r < 0 && r != -EEXIST)\n                    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to add multiarch architecture to seccomp filter\"));\n                }\n            }\n        }\n    }\n\n  \/* TODO: Should we filter the kernel keyring syscalls in some way?\n   * We do want them to be used by desktop apps, but they could also perhaps\n   * leak system stuff or secrets from other apps.\n   *\/\n\n  for (i = 0; i < G_N_ELEMENTS (syscall_blocklist); i++)\n    {\n      int scall = syscall_blocklist[i].scall;\n      if (syscall_blocklist[i].arg)\n        r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (EPERM), scall, 1, *syscall_blocklist[i].arg);\n      else\n        r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (EPERM), scall, 0);\n      if (r < 0 && r == -EFAULT \/* unknown syscall *\/)\n        return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to block syscall %d\"), scall);\n    }\n\n  if (!devel)\n    {\n      for (i = 0; i < G_N_ELEMENTS (syscall_nondevel_blocklist); i++)\n        {\n          int scall = syscall_nondevel_blocklist[i].scall;\n          if (syscall_nondevel_blocklist[i].arg)\n            r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (EPERM), scall, 1, *syscall_nondevel_blocklist[i].arg);\n          else\n            r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (EPERM), scall, 0);\n\n          if (r < 0 && r == -EFAULT \/* unknown syscall *\/)\n            return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to block syscall %d\"), scall);\n        }\n    }\n\n  \/* Socket filtering doesn't work on e.g. i386, so ignore failures here\n   * However, we need to user seccomp_rule_add_exact to avoid libseccomp doing\n   * something else: https:\/\/github.com\/seccomp\/libseccomp\/issues\/8 *\/\n  last_allowed_family = -1;\n  for (i = 0; i < G_N_ELEMENTS (socket_family_allowlist); i++)\n    {\n      int family = socket_family_allowlist[i].family;\n      int disallowed;\n\n      if (socket_family_allowlist[i].flags_mask != 0 &&\n          (socket_family_allowlist[i].flags_mask & run_flags) != socket_family_allowlist[i].flags_mask)\n        continue;\n\n      for (disallowed = last_allowed_family + 1; disallowed < family; disallowed++)\n        {\n          \/* Blocklist the in-between valid families *\/\n          seccomp_rule_add_exact (seccomp, SCMP_ACT_ERRNO (EAFNOSUPPORT), SCMP_SYS (socket), 1, SCMP_A0 (SCMP_CMP_EQ, disallowed));\n        }\n      last_allowed_family = family;\n    }\n  \/* Blocklist the rest *\/\n  seccomp_rule_add_exact (seccomp, SCMP_ACT_ERRNO (EAFNOSUPPORT), SCMP_SYS (socket), 1, SCMP_A0 (SCMP_CMP_GE, last_allowed_family + 1));\n\n  if (!glnx_open_anonymous_tmpfile_full (O_RDWR | O_CLOEXEC, \"\/tmp\", &seccomp_tmpf, error))\n    return FALSE;\n\n  if (seccomp_export_bpf (seccomp, seccomp_tmpf.fd) != 0)\n    return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _(\"Failed to export bpf\"));\n\n  lseek (seccomp_tmpf.fd, 0, SEEK_SET);\n\n  flatpak_bwrap_add_args_data_fd (bwrap,\n                                  \"--seccomp\", glnx_steal_fd (&seccomp_tmpf.fd), NULL);\n\n  return TRUE;\n}","target":1,"code_token_length":2522,"total_token_length":2758,"max_tokens_setting":4096}
+{"idx":277493,"func":"MOBI_RET mobi_parse_indx(const MOBIPdbRecord *indx_record, MOBIIndx *indx, MOBITagx *tagx, MOBIOrdt *ordt) {\n    if (indx_record == NULL || indx == NULL || tagx == NULL || ordt == NULL) {\n        debug_print(\"%s\", \"index structure not initialized\\n\");\n        return MOBI_INIT_FAILED;\n    }\n    MOBI_RET ret = MOBI_SUCCESS;\n    MOBIBuffer *buf = mobi_buffer_init_null(indx_record->data, indx_record->size);\n    if (buf == NULL) {\n        debug_print(\"%s\\n\", \"Memory allocation failed\");\n        return MOBI_MALLOC_FAILED;\n    }\n    char indx_magic[5];\n    mobi_buffer_getstring(indx_magic, buf, 4); \/* 0: INDX magic *\/\n    const uint32_t header_length = mobi_buffer_get32(buf); \/* 4: header length *\/\n    if (strncmp(indx_magic, INDX_MAGIC, 4) != 0 ||\n        header_length == 0 || header_length > indx_record->size) {\n        debug_print(\"INDX wrong magic: %s or header length: %u\\n\", indx_magic, header_length);\n        mobi_buffer_free_null(buf);\n        return MOBI_DATA_CORRUPT;\n    }\n    mobi_buffer_seek(buf, 4); \/* 8: unk, usually zeroes *\/\n    const uint32_t type = mobi_buffer_get32(buf); \/* 12: 0 - normal, 2 - inflection *\/\n    mobi_buffer_seek(buf, 4); \/* 16: unk *\/\n    const uint32_t idxt_offset = mobi_buffer_get32(buf); \/* 20: IDXT offset *\/\n    const uint32_t entries_count = mobi_buffer_get32(buf); \/* 24: entries count *\/\n    if (entries_count > INDX_RECORD_MAXCNT) {\n        debug_print(\"Too many index entries (%u)\\n\", entries_count);\n        mobi_buffer_free_null(buf);\n        return MOBI_DATA_CORRUPT;\n    }\n    \/* if record contains TAGX section, read it (and ORDT) and return *\/\n    if (mobi_buffer_match_magic_offset(buf, TAGX_MAGIC, header_length) && indx->total_entries_count == 0) {\n        buf->maxlen = header_length;\n        \/* TAGX metadata *\/\n        uint32_t encoding = mobi_buffer_get32(buf); \/* 28: encoding *\/\n        if (encoding == MOBI_NOTSET) { encoding = MOBI_CP1252; }\n        mobi_buffer_seek(buf, 4); \/* 32 *\/\n        const uint32_t total_entries_count = mobi_buffer_get32(buf); \/* 36: total entries count *\/\n        if (total_entries_count > INDX_TOTAL_MAXCNT) {\n            debug_print(\"Too many total index entries (%u)\\n\", total_entries_count);\n            mobi_buffer_free_null(buf);\n            return MOBI_DATA_CORRUPT;\n        }\n        uint32_t ordt_offset = mobi_buffer_get32(buf); \/* 40: ORDT offset; currently not used *\/\n        if (ordt_offset + ORDT_RECORD_MAXCNT + 4 > indx_record->size) {\n            ordt_offset = 0;\n        }\n        uint32_t ligt_offset = mobi_buffer_get32(buf); \/* 44: LIGT offset; currently static table used instead *\/\n        uint32_t ligt_entries_count = mobi_buffer_get32(buf); \/* 48: LIGT entries count *\/\n        if (ligt_offset + 4 * ligt_entries_count + 4 > indx_record->size) {\n            ligt_offset = 0;\n            ligt_entries_count = 0;\n        }\n        const uint32_t cncx_records_count = mobi_buffer_get32(buf); \/* 52: CNCX entries count *\/\n        if (cncx_records_count > CNCX_RECORD_MAXCNT) {\n            debug_print(\"Too many CNCX records (%u)\\n\", cncx_records_count);\n            mobi_buffer_free_null(buf);\n            return MOBI_DATA_CORRUPT;\n        }\n        \/* 56: unk count *\/\n        \/* 60-148: phonetizer *\/\n        uint32_t ordt_type = 0;\n        uint32_t ordt_entries_count = 0;\n        uint32_t ordt1_offset = 0;\n        uint32_t ordt2_offset = 0;\n        uint32_t index_name_offset = 0;\n        uint32_t index_name_length = 0;\n        if (header_length >= 180) {\n            mobi_buffer_setpos(buf, 164);\n            ordt_type = mobi_buffer_get32(buf); \/* 164: ORDT type *\/\n            ordt_entries_count = mobi_buffer_get32(buf); \/* 168: ORDT entries count *\/\n            ordt1_offset = mobi_buffer_get32(buf); \/* 172: ORDT1 offset; currently not used *\/\n            ordt2_offset = mobi_buffer_get32(buf); \/* 176: ORDT2 offset *\/\n            const size_t entry_size = (ordt_type == 0) ? 1 : 2;\n            if (ordt1_offset + entry_size * ordt_entries_count > indx_record->size\n                || ordt2_offset + 2 * ordt_entries_count > indx_record->size) {\n                ordt1_offset = 0;\n                ordt2_offset = 0;\n                ordt_entries_count = 0;\n            }\n            index_name_offset = mobi_buffer_get32(buf); \/* 180: Index name offset *\/\n            index_name_length = mobi_buffer_get32(buf); \/* 184: Index name length *\/\n        }\n        buf->maxlen = indx_record->size;\n        mobi_buffer_setpos(buf, header_length);\n        ret = mobi_parse_tagx(buf, tagx);\n        if (ret != MOBI_SUCCESS) {\n            mobi_buffer_free_null(buf);\n            return ret;\n        }\n        if (ordt_entries_count > 0) {\n            \/* parse ORDT sections *\/\n            ordt->offsets_count = ordt_entries_count;\n            ordt->type = ordt_type;\n            ordt->ordt1_pos = ordt1_offset;\n            ordt->ordt2_pos = ordt2_offset;\n            ret = mobi_parse_ordt(buf, ordt);\n            debug_print(\"ORDT: %u, %u, %u, %u\\n\", ordt_type, ordt_entries_count, ordt1_offset, ordt2_offset);\n            if (ret != MOBI_SUCCESS) {\n                mobi_buffer_free_null(buf);\n                return ret;\n            }\n        }\n        if (index_name_offset > 0 && index_name_length > 0) {\n            if (index_name_length <= header_length - index_name_offset && index_name_length < INDX_NAME_SIZEMAX) {\n                mobi_buffer_setpos(buf, index_name_offset);\n                char *name = malloc(index_name_length + 1);\n                if (name == NULL) {\n                    debug_print(\"%s\", \"Memory allocation failed\\n\");\n                    mobi_buffer_free_null(buf);\n                    return MOBI_MALLOC_FAILED;\n                }\n                mobi_buffer_getstring(name, buf, index_name_length);\n                indx->orth_index_name = name;\n                debug_print(\"Orth index name: %s\\n\", name);\n            }\n        }\n        indx->encoding = encoding;\n        indx->type = type;\n        indx->entries_count = entries_count;\n        indx->total_entries_count = total_entries_count;\n        if (ligt_entries_count != 0 && !mobi_buffer_match_magic_offset(buf, LIGT_MAGIC, ligt_offset)) {\n            ligt_offset = 0;\n            ligt_entries_count = 0;\n        }\n        indx->ligt_offset = ligt_offset;\n        indx->ligt_entries_count = ligt_entries_count;\n        indx->ordt_offset = ordt_offset;\n        indx->cncx_records_count = cncx_records_count;\n    } else {\n        \/* else parse IDXT entries offsets *\/\n        if (idxt_offset == 0) {\n            debug_print(\"%s\", \"Missing IDXT offset\\n\");\n            mobi_buffer_free_null(buf);\n            return MOBI_DATA_CORRUPT;\n        }\n        if (idxt_offset + 2 * entries_count + 4 > indx_record->size ) {\n            debug_print(\"IDXT entries beyond record end%s\", \"\\n\");\n            mobi_buffer_free_null(buf);\n            return MOBI_DATA_CORRUPT;\n        }\n        mobi_buffer_setpos(buf, idxt_offset);\n        MOBIIdxt idxt;\n        uint32_t *offsets = malloc((entries_count + 1) * sizeof(uint32_t));\n        if (offsets == NULL) {\n            mobi_buffer_free_null(buf);\n            debug_print(\"%s\\n\", \"Memory allocation failed\");\n            return MOBI_MALLOC_FAILED;\n        }\n        idxt.offsets = offsets;\n        ret = mobi_parse_idxt(buf, &idxt, entries_count);\n        if (ret != MOBI_SUCCESS) {\n            debug_print(\"%s\", \"IDXT parsing failed\\n\");\n            mobi_buffer_free_null(buf);\n            free(offsets);\n            return ret;\n        }\n        \/* parse entries *\/\n        if (entries_count > 0) {\n            if (indx->entries == NULL) {\n                indx->entries = malloc(indx->total_entries_count * sizeof(MOBIIndexEntry));\n                if (indx->entries == NULL) {\n                    mobi_buffer_free_null(buf);\n                    free(offsets);\n                    debug_print(\"%s\\n\", \"Memory allocation failed\");\n                    return MOBI_MALLOC_FAILED;\n                }\n            }\n            size_t i = 0;\n            while (i < entries_count) {\n                ret = mobi_parse_index_entry(indx, idxt, tagx, ordt, buf, i++);\n                if (ret != MOBI_SUCCESS) {\n                    mobi_buffer_free_null(buf);\n                    free(offsets);\n                    return ret;\n                }\n            }\n            indx->entries_count += entries_count;\n        }\n        free(offsets);\n    }\n    mobi_buffer_free_null(buf);\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":2209,"total_token_length":2445,"max_tokens_setting":4096}
+{"idx":206676,"func":"update_topline(void)\n{\n    long\tline_count;\n    int\t\thalfheight;\n    int\t\tn;\n    linenr_T\told_topline;\n#ifdef FEAT_DIFF\n    int\t\told_topfill;\n#endif\n#ifdef FEAT_FOLDING\n    linenr_T\tlnum;\n#endif\n    int\t\tcheck_topline = FALSE;\n    int\t\tcheck_botline = FALSE;\n    long        *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;\n    int\t\tsave_so = *so_ptr;\n\n    \/\/ If there is no valid screen and when the window height is zero just use\n    \/\/ the cursor line.\n    if (!screen_valid(TRUE) || curwin->w_height == 0)\n    {\n\tcheck_cursor_lnum();\n\tcurwin->w_topline = curwin->w_cursor.lnum;\n\tcurwin->w_botline = curwin->w_topline;\n\tcurwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;\n\tcurwin->w_scbind_pos = 1;\n\treturn;\n    }\n\n    check_cursor_moved(curwin);\n    if (curwin->w_valid & VALID_TOPLINE)\n\treturn;\n\n    \/\/ When dragging with the mouse, don't scroll that quickly\n    if (mouse_dragging > 0)\n\t*so_ptr = mouse_dragging - 1;\n\n    old_topline = curwin->w_topline;\n#ifdef FEAT_DIFF\n    old_topfill = curwin->w_topfill;\n#endif\n\n    \/*\n     * If the buffer is empty, always set topline to 1.\n     *\/\n    if (BUFEMPTY())\t\t\/\/ special case - file is empty\n    {\n\tif (curwin->w_topline != 1)\n\t    redraw_later(NOT_VALID);\n\tcurwin->w_topline = 1;\n\tcurwin->w_botline = 2;\n\tcurwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;\n\tcurwin->w_scbind_pos = 1;\n    }\n\n    \/*\n     * If the cursor is above or near the top of the window, scroll the window\n     * to show the line the cursor is in, with 'scrolloff' context.\n     *\/\n    else\n    {\n\tif (curwin->w_topline > 1)\n\t{\n\t    \/\/ If the cursor is above topline, scrolling is always needed.\n\t    \/\/ If the cursor is far below topline and there is no folding,\n\t    \/\/ scrolling down is never needed.\n\t    if (curwin->w_cursor.lnum < curwin->w_topline)\n\t\tcheck_topline = TRUE;\n\t    else if (check_top_offset())\n\t\tcheck_topline = TRUE;\n\t}\n#ifdef FEAT_DIFF\n\t    \/\/ Check if there are more filler lines than allowed.\n\tif (!check_topline && curwin->w_topfill > diff_check_fill(curwin,\n\t\t\t\t\t\t\t   curwin->w_topline))\n\t    check_topline = TRUE;\n#endif\n\n\tif (check_topline)\n\t{\n\t    halfheight = curwin->w_height \/ 2 - 1;\n\t    if (halfheight < 2)\n\t\thalfheight = 2;\n\n#ifdef FEAT_FOLDING\n\t    if (hasAnyFolding(curwin))\n\t    {\n\t\t\/\/ Count the number of logical lines between the cursor and\n\t\t\/\/ topline + scrolloff (approximation of how much will be\n\t\t\/\/ scrolled).\n\t\tn = 0;\n\t\tfor (lnum = curwin->w_cursor.lnum;\n\t\t\t\t    lnum < curwin->w_topline + *so_ptr; ++lnum)\n\t\t{\n\t\t    ++n;\n\t\t    \/\/ stop at end of file or when we know we are far off\n\t\t    if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight)\n\t\t\tbreak;\n\t\t    (void)hasFolding(lnum, NULL, &lnum);\n\t\t}\n\t    }\n\t    else\n#endif\n\t\tn = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum;\n\n\t    \/\/ If we weren't very close to begin with, we scroll to put the\n\t    \/\/ cursor in the middle of the window.  Otherwise put the cursor\n\t    \/\/ near the top of the window.\n\t    if (n >= halfheight)\n\t\tscroll_cursor_halfway(FALSE);\n\t    else\n\t    {\n\t\tscroll_cursor_top(scrolljump_value(), FALSE);\n\t\tcheck_botline = TRUE;\n\t    }\n\t}\n\n\telse\n\t{\n#ifdef FEAT_FOLDING\n\t    \/\/ Make sure topline is the first line of a fold.\n\t    (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);\n#endif\n\t    check_botline = TRUE;\n\t}\n    }\n\n    \/*\n     * If the cursor is below the bottom of the window, scroll the window\n     * to put the cursor on the window.\n     * When w_botline is invalid, recompute it first, to avoid a redraw later.\n     * If w_botline was approximated, we might need a redraw later in a few\n     * cases, but we don't want to spend (a lot of) time recomputing w_botline\n     * for every small change.\n     *\/\n    if (check_botline)\n    {\n\tif (!(curwin->w_valid & VALID_BOTLINE_AP))\n\t    validate_botline();\n\n\tif (curwin->w_botline <= curbuf->b_ml.ml_line_count)\n\t{\n\t    if (curwin->w_cursor.lnum < curwin->w_botline)\n\t    {\n\t      if (((long)curwin->w_cursor.lnum\n\t\t\t\t\t     >= (long)curwin->w_botline - *so_ptr\n#ifdef FEAT_FOLDING\n\t\t\t|| hasAnyFolding(curwin)\n#endif\n\t\t\t))\n\t      {\n\t\tlineoff_T\tloff;\n\n\t\t\/\/ Cursor is (a few lines) above botline, check if there are\n\t\t\/\/ 'scrolloff' window lines below the cursor.  If not, need to\n\t\t\/\/ scroll.\n\t\tn = curwin->w_empty_rows;\n\t\tloff.lnum = curwin->w_cursor.lnum;\n#ifdef FEAT_FOLDING\n\t\t\/\/ In a fold go to its last line.\n\t\t(void)hasFolding(loff.lnum, NULL, &loff.lnum);\n#endif\n#ifdef FEAT_DIFF\n\t\tloff.fill = 0;\n\t\tn += curwin->w_filler_rows;\n#endif\n\t\tloff.height = 0;\n\t\twhile (loff.lnum < curwin->w_botline\n#ifdef FEAT_DIFF\n\t\t\t&& (loff.lnum + 1 < curwin->w_botline || loff.fill == 0)\n#endif\n\t\t\t)\n\t\t{\n\t\t    n += loff.height;\n\t\t    if (n >= *so_ptr)\n\t\t\tbreak;\n\t\t    botline_forw(&loff);\n\t\t}\n\t\tif (n >= *so_ptr)\n\t\t    \/\/ sufficient context, no need to scroll\n\t\t    check_botline = FALSE;\n\t      }\n\t      else\n\t\t  \/\/ sufficient context, no need to scroll\n\t\t  check_botline = FALSE;\n\t    }\n\t    if (check_botline)\n\t    {\n#ifdef FEAT_FOLDING\n\t\tif (hasAnyFolding(curwin))\n\t\t{\n\t\t    \/\/ Count the number of logical lines between the cursor and\n\t\t    \/\/ botline - scrolloff (approximation of how much will be\n\t\t    \/\/ scrolled).\n\t\t    line_count = 0;\n\t\t    for (lnum = curwin->w_cursor.lnum;\n\t\t\t\t   lnum >= curwin->w_botline - *so_ptr; --lnum)\n\t\t    {\n\t\t\t++line_count;\n\t\t\t\/\/ stop at end of file or when we know we are far off\n\t\t\tif (lnum <= 0 || line_count > curwin->w_height + 1)\n\t\t\t    break;\n\t\t\t(void)hasFolding(lnum, &lnum, NULL);\n\t\t    }\n\t\t}\n\t\telse\n#endif\n\t\t    line_count = curwin->w_cursor.lnum - curwin->w_botline\n\t\t\t\t\t\t\t\t   + 1 + *so_ptr;\n\t\tif (line_count <= curwin->w_height + 1)\n\t\t    scroll_cursor_bot(scrolljump_value(), FALSE);\n\t\telse\n\t\t    scroll_cursor_halfway(FALSE);\n\t    }\n\t}\n    }\n    curwin->w_valid |= VALID_TOPLINE;\n\n    \/*\n     * Need to redraw when topline changed.\n     *\/\n    if (curwin->w_topline != old_topline\n#ifdef FEAT_DIFF\n\t    || curwin->w_topfill != old_topfill\n#endif\n\t    )\n    {\n\tdollar_vcol = -1;\n\tif (curwin->w_skipcol != 0)\n\t{\n\t    curwin->w_skipcol = 0;\n\t    redraw_later(NOT_VALID);\n\t}\n\telse\n\t    redraw_later(VALID);\n\t\/\/ May need to set w_skipcol when cursor in w_topline.\n\tif (curwin->w_cursor.lnum == curwin->w_topline)\n\t    validate_cursor();\n    }\n\n    *so_ptr = save_so;\n}","target":1,"code_token_length":1916,"total_token_length":2152,"max_tokens_setting":4096}
+{"idx":217547,"func":"int64_t GmfOpenMesh(const char *FilNam, int mod, ...)\n{\n   int      KwdCod, res, *PtrVer, *PtrDim, err;\n   int64_t  MshIdx;\n   char     str[ GmfStrSiz ];\n   va_list  VarArg;\n   GmfMshSct *msh;\n\n   \/*---------------------*\/\n   \/* MESH STRUCTURE INIT *\/\n   \/*---------------------*\/\n\n   if(!(msh = calloc(1, sizeof(GmfMshSct))))\n      return(0);\n\n   MshIdx = (int64_t)msh;\n\n   \/\/ Save the current stack environment for longjmp\n   if( (err = setjmp(msh->err)) != 0)\n   {\n#ifdef GMFDEBUG\n      printf(\"libMeshb : mesh %p : error %d\\n\", msh, err);\n#endif\n      if(msh->hdl != NULL)\n         fclose(msh->hdl);\n\n      if(msh->FilDes != 0)\n#ifdef GMF_WINDOWS\n         _close(msh->FilDes);\n#else\n         close(msh->FilDes);\n#endif\n\n      free(msh);\n      return(0);\n   }\n\n   \/\/ Copy the FilNam into the structure\n   if(strlen(FilNam) + 7 >= GmfStrSiz)\n      longjmp(msh->err, -4);\n\n   strcpy(msh->FilNam, FilNam);\n\n   \/\/ Store the opening mod (read or write) and guess\n   \/\/ the filetype (binary or ascii) depending on the extension\n   msh->mod = mod;\n   msh->buf = (void *)msh->DblBuf;\n   msh->FltBuf = (void *)msh->DblBuf;\n   msh->IntBuf = (void *)msh->DblBuf;\n\n   if(strstr(msh->FilNam, \".meshb\"))\n      msh->typ |= (Bin | MshFil);\n   else if(strstr(msh->FilNam, \".mesh\"))\n      msh->typ |= (Asc | MshFil);\n   else if(strstr(msh->FilNam, \".solb\"))\n      msh->typ |= (Bin | SolFil);\n   else if(strstr(msh->FilNam, \".sol\"))\n      msh->typ |= (Asc | SolFil);\n   else\n      longjmp(msh->err, -5);\n\n   \/\/ Open the file in the required mod and initialize the mesh structure\n   if(msh->mod == GmfRead)\n   {\n\n      \/*-----------------------*\/\n      \/* OPEN FILE FOR READING *\/\n      \/*-----------------------*\/\n\n      va_start(VarArg, mod);\n      PtrVer = va_arg(VarArg, int *);\n      PtrDim = va_arg(VarArg, int *);\n      va_end(VarArg);\n\n      \/\/ Read the endian coding tag, the mesh version\n      \/\/ and the mesh dimension (mandatory kwd)\n      if(msh->typ & Bin)\n      {\n         \/\/ Create the name string and open the file\n#ifdef WITH_GMF_AIO\n         \/\/ [Bruno] added binary flag (necessary under Windows)\n         msh->FilDes = open(msh->FilNam, OPEN_READ_FLAGS, OPEN_READ_MODE);\n\n         if(msh->FilDes <= 0)\n            longjmp(msh->err, -6);\n\n         \/\/ Read the endian coding tag\n         if(read(msh->FilDes, &msh->cod, WrdSiz) != WrdSiz)\n            longjmp(msh->err, -7);\n#else\n         \/\/ [Bruno] added binary flag (necessary under Windows)\n         if(!(msh->hdl = fopen(msh->FilNam, \"rb\")))\n            longjmp(msh->err, -8);\n\n         \/\/ Read the endian coding tag\n         safe_fread(&msh->cod, WrdSiz, 1, msh->hdl, msh->err);\n#endif\n\n         \/\/ Read the mesh version and the mesh dimension (mandatory kwd)\n         if( (msh->cod != 1) && (msh->cod != 16777216) )\n            longjmp(msh->err, -9);\n\n         ScaWrd(msh, (unsigned char *)&msh->ver);\n\n         if( (msh->ver < 1) || (msh->ver > 4) )\n            longjmp(msh->err, -10);\n\n         if( (msh->ver >= 3) && (sizeof(int64_t) != 8) )\n            longjmp(msh->err, -11);\n\n         ScaWrd(msh, (unsigned char *)&KwdCod);\n\n         if(KwdCod != GmfDimension)\n            longjmp(msh->err, -12);\n\n         GetPos(msh);\n         ScaWrd(msh, (unsigned char *)&msh->dim);\n      }\n      else\n      {\n         \/\/ Create the name string and open the file\n         if(!(msh->hdl = fopen(msh->FilNam, \"rb\")))\n            longjmp(msh->err, -13);\n\n         do\n         {\n            res = fscanf(msh->hdl, \"%s\", str);\n         }while( (res != EOF) && strcmp(str, \"MeshVersionFormatted\") );\n\n         if(res == EOF)\n            longjmp(msh->err, -14);\n\n         safe_fscanf(msh->hdl, \"%d\", &msh->ver, msh->err);\n\n         if( (msh->ver < 1) || (msh->ver > 4) )\n            longjmp(msh->err, -15);\n\n         do\n         {\n            res = fscanf(msh->hdl, \"%s\", str);\n         }while( (res != EOF) && strcmp(str, \"Dimension\") );\n\n         if(res == EOF)\n            longjmp(msh->err, -16);\n\n         safe_fscanf(msh->hdl, \"%d\", &msh->dim, msh->err);\n      }\n\n      if( (msh->dim != 2) && (msh->dim != 3) )\n         longjmp(msh->err, -17);\n\n      (*PtrVer) = msh->ver;\n      (*PtrDim) = msh->dim;\n\n      \/\/ Set default real numbers size\n      if(msh->ver == 1)\n         msh->FltSiz = 32;\n      else\n         msh->FltSiz = 64;\n\n      \/*------------*\/\n      \/* KW READING *\/\n      \/*------------*\/\n\n      \/\/ Read the list of kw present in the file\n      if(!ScaKwdTab(msh))\n         return(0);\n\n      return(MshIdx);\n   }\n   else if(msh->mod == GmfWrite)\n   {\n\n      \/*-----------------------*\/\n      \/* OPEN FILE FOR WRITING *\/\n      \/*-----------------------*\/\n\n      msh->cod = 1;\n\n      \/\/ Check if the user provided a valid version number and dimension\n      va_start(VarArg, mod);\n      msh->ver = va_arg(VarArg, int);\n      msh->dim = va_arg(VarArg, int);\n      va_end(VarArg);\n\n      if( (msh->ver < 1) || (msh->ver > 4) )\n         longjmp(msh->err, -18);\n\n      if( (msh->ver >= 3) && (sizeof(int64_t) != 8) )\n         longjmp(msh->err, -19);\n\n      if( (msh->dim != 2) && (msh->dim != 3) )\n         longjmp(msh->err, -20);\n\n      \/\/ Set default real numbers size\n      if(msh->ver == 1)\n         msh->FltSiz = 32;\n      else\n         msh->FltSiz = 64;\n\n      \/\/ Create the mesh file\n      if(msh->typ & Bin) \n      {\n         \/* \n          * [Bruno] replaced previous call to creat():\n          * with a call to open(), because Windows needs the\n          * binary flag to be specified.\n          *\/\n#ifdef WITH_GMF_AIO\n         msh->FilDes = open(msh->FilNam, OPEN_WRITE_FLAGS, OPEN_WRITE_MODE);\n\n         if(msh->FilDes <= 0)\n            longjmp(msh->err, -21);\n#else\n         if(!(msh->hdl = fopen(msh->FilNam, \"wb\")))\n            longjmp(msh->err, -22);\n#endif\n      }\n      else if(!(msh->hdl = fopen(msh->FilNam, \"wb\")))\n         longjmp(msh->err, -23);\n\n\n      \/*------------*\/\n      \/* KW WRITING *\/\n      \/*------------*\/\n\n      \/\/ Write the mesh version and dimension\n      if(msh->typ & Asc)\n      {\n         fprintf(msh->hdl, \"%s %d\\n\\n\",\n               GmfKwdFmt[ GmfVersionFormatted ][0], msh->ver);\n         fprintf(msh->hdl, \"%s %d\\n\",\n               GmfKwdFmt[ GmfDimension ][0], msh->dim);\n      }\n      else\n      {\n         RecWrd(msh, (unsigned char *)&msh->cod);\n         RecWrd(msh, (unsigned char *)&msh->ver);\n         GmfSetKwd(MshIdx, GmfDimension, 0);\n         RecWrd(msh, (unsigned char *)&msh->dim);\n      }\n\n      return(MshIdx);\n   }\n   else\n   {\n      free(msh);\n      return(0);\n   }\n}","target":1,"code_token_length":2065,"total_token_length":2301,"max_tokens_setting":4096}
+{"idx":197135,"func":"ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)\n{\n\tstruct ccp_aes_engine *aes = &cmd->u.aes;\n\tstruct ccp_dm_workarea key, ctx, final_wa, tag;\n\tstruct ccp_data src, dst;\n\tstruct ccp_data aad;\n\tstruct ccp_op op;\n\tunsigned int dm_offset;\n\tunsigned int authsize;\n\tunsigned int jobid;\n\tunsigned int ilen;\n\tbool in_place = true; \/* Default value *\/\n\t__be64 *final;\n\tint ret;\n\n\tstruct scatterlist *p_inp, sg_inp[2];\n\tstruct scatterlist *p_tag, sg_tag[2];\n\tstruct scatterlist *p_outp, sg_outp[2];\n\tstruct scatterlist *p_aad;\n\n\tif (!aes->iv)\n\t\treturn -EINVAL;\n\n\tif (!((aes->key_len == AES_KEYSIZE_128) ||\n\t\t(aes->key_len == AES_KEYSIZE_192) ||\n\t\t(aes->key_len == AES_KEYSIZE_256)))\n\t\treturn -EINVAL;\n\n\tif (!aes->key) \/* Gotta have a key SGL *\/\n\t\treturn -EINVAL;\n\n\t\/* Zero defaults to 16 bytes, the maximum size *\/\n\tauthsize = aes->authsize ? aes->authsize : AES_BLOCK_SIZE;\n\tswitch (authsize) {\n\tcase 16:\n\tcase 15:\n\tcase 14:\n\tcase 13:\n\tcase 12:\n\tcase 8:\n\tcase 4:\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\t\/* First, decompose the source buffer into AAD & PT,\n\t * and the destination buffer into AAD, CT & tag, or\n\t * the input into CT & tag.\n\t * It is expected that the input and output SGs will\n\t * be valid, even if the AAD and input lengths are 0.\n\t *\/\n\tp_aad = aes->src;\n\tp_inp = scatterwalk_ffwd(sg_inp, aes->src, aes->aad_len);\n\tp_outp = scatterwalk_ffwd(sg_outp, aes->dst, aes->aad_len);\n\tif (aes->action == CCP_AES_ACTION_ENCRYPT) {\n\t\tilen = aes->src_len;\n\t\tp_tag = scatterwalk_ffwd(sg_tag, p_outp, ilen);\n\t} else {\n\t\t\/* Input length for decryption includes tag *\/\n\t\tilen = aes->src_len - authsize;\n\t\tp_tag = scatterwalk_ffwd(sg_tag, p_inp, ilen);\n\t}\n\n\tjobid = CCP_NEW_JOBID(cmd_q->ccp);\n\n\tmemset(&op, 0, sizeof(op));\n\top.cmd_q = cmd_q;\n\top.jobid = jobid;\n\top.sb_key = cmd_q->sb_key; \/* Pre-allocated *\/\n\top.sb_ctx = cmd_q->sb_ctx; \/* Pre-allocated *\/\n\top.init = 1;\n\top.u.aes.type = aes->type;\n\n\t\/* Copy the key to the LSB *\/\n\tret = ccp_init_dm_workarea(&key, cmd_q,\n\t\t\t\t   CCP_AES_CTX_SB_COUNT * CCP_SB_BYTES,\n\t\t\t\t   DMA_TO_DEVICE);\n\tif (ret)\n\t\treturn ret;\n\n\tdm_offset = CCP_SB_BYTES - aes->key_len;\n\tret = ccp_set_dm_area(&key, dm_offset, aes->key, 0, aes->key_len);\n\tif (ret)\n\t\tgoto e_key;\n\tret = ccp_copy_to_sb(cmd_q, &key, op.jobid, op.sb_key,\n\t\t\t     CCP_PASSTHRU_BYTESWAP_256BIT);\n\tif (ret) {\n\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\tgoto e_key;\n\t}\n\n\t\/* Copy the context (IV) to the LSB.\n\t * There is an assumption here that the IV is 96 bits in length, plus\n\t * a nonce of 32 bits. If no IV is present, use a zeroed buffer.\n\t *\/\n\tret = ccp_init_dm_workarea(&ctx, cmd_q,\n\t\t\t\t   CCP_AES_CTX_SB_COUNT * CCP_SB_BYTES,\n\t\t\t\t   DMA_BIDIRECTIONAL);\n\tif (ret)\n\t\tgoto e_key;\n\n\tdm_offset = CCP_AES_CTX_SB_COUNT * CCP_SB_BYTES - aes->iv_len;\n\tret = ccp_set_dm_area(&ctx, dm_offset, aes->iv, 0, aes->iv_len);\n\tif (ret)\n\t\tgoto e_ctx;\n\n\tret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx,\n\t\t\t     CCP_PASSTHRU_BYTESWAP_256BIT);\n\tif (ret) {\n\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\tgoto e_ctx;\n\t}\n\n\top.init = 1;\n\tif (aes->aad_len > 0) {\n\t\t\/* Step 1: Run a GHASH over the Additional Authenticated Data *\/\n\t\tret = ccp_init_data(&aad, cmd_q, p_aad, aes->aad_len,\n\t\t\t\t    AES_BLOCK_SIZE,\n\t\t\t\t    DMA_TO_DEVICE);\n\t\tif (ret)\n\t\t\tgoto e_ctx;\n\n\t\top.u.aes.mode = CCP_AES_MODE_GHASH;\n\t\top.u.aes.action = CCP_AES_GHASHAAD;\n\n\t\twhile (aad.sg_wa.bytes_left) {\n\t\t\tccp_prepare_data(&aad, NULL, &op, AES_BLOCK_SIZE, true);\n\n\t\t\tret = cmd_q->ccp->vdata->perform->aes(&op);\n\t\t\tif (ret) {\n\t\t\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\t\t\tgoto e_aad;\n\t\t\t}\n\n\t\t\tccp_process_data(&aad, NULL, &op);\n\t\t\top.init = 0;\n\t\t}\n\t}\n\n\top.u.aes.mode = CCP_AES_MODE_GCTR;\n\top.u.aes.action = aes->action;\n\n\tif (ilen > 0) {\n\t\t\/* Step 2: Run a GCTR over the plaintext *\/\n\t\tin_place = (sg_virt(p_inp) == sg_virt(p_outp)) ? true : false;\n\n\t\tret = ccp_init_data(&src, cmd_q, p_inp, ilen,\n\t\t\t\t    AES_BLOCK_SIZE,\n\t\t\t\t    in_place ? DMA_BIDIRECTIONAL\n\t\t\t\t\t     : DMA_TO_DEVICE);\n\t\tif (ret)\n\t\t\tgoto e_ctx;\n\n\t\tif (in_place) {\n\t\t\tdst = src;\n\t\t} else {\n\t\t\tret = ccp_init_data(&dst, cmd_q, p_outp, ilen,\n\t\t\t\t\t    AES_BLOCK_SIZE, DMA_FROM_DEVICE);\n\t\t\tif (ret)\n\t\t\t\tgoto e_src;\n\t\t}\n\n\t\top.soc = 0;\n\t\top.eom = 0;\n\t\top.init = 1;\n\t\twhile (src.sg_wa.bytes_left) {\n\t\t\tccp_prepare_data(&src, &dst, &op, AES_BLOCK_SIZE, true);\n\t\t\tif (!src.sg_wa.bytes_left) {\n\t\t\t\tunsigned int nbytes = ilen % AES_BLOCK_SIZE;\n\n\t\t\t\tif (nbytes) {\n\t\t\t\t\top.eom = 1;\n\t\t\t\t\top.u.aes.size = (nbytes * 8) - 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tret = cmd_q->ccp->vdata->perform->aes(&op);\n\t\t\tif (ret) {\n\t\t\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\t\t\tgoto e_dst;\n\t\t\t}\n\n\t\t\tccp_process_data(&src, &dst, &op);\n\t\t\top.init = 0;\n\t\t}\n\t}\n\n\t\/* Step 3: Update the IV portion of the context with the original IV *\/\n\tret = ccp_copy_from_sb(cmd_q, &ctx, op.jobid, op.sb_ctx,\n\t\t\t       CCP_PASSTHRU_BYTESWAP_256BIT);\n\tif (ret) {\n\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\tgoto e_dst;\n\t}\n\n\tret = ccp_set_dm_area(&ctx, dm_offset, aes->iv, 0, aes->iv_len);\n\tif (ret)\n\t\tgoto e_dst;\n\n\tret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx,\n\t\t\t     CCP_PASSTHRU_BYTESWAP_256BIT);\n\tif (ret) {\n\t\tcmd->engine_error = cmd_q->cmd_error;\n\t\tgoto e_dst;\n\t}\n\n\t\/* Step 4: Concatenate the lengths of the AAD and source, and\n\t * hash that 16 byte buffer.\n\t *\/\n\tret = ccp_init_dm_workarea(&final_wa, cmd_q, AES_BLOCK_SIZE,\n\t\t\t\t   DMA_BIDIRECTIONAL);\n\tif (ret)\n\t\tgoto e_dst;\n\tfinal = (__be64 *)final_wa.address;\n\tfinal[0] = cpu_to_be64(aes->aad_len * 8);\n\tfinal[1] = cpu_to_be64(ilen * 8);\n\n\tmemset(&op, 0, sizeof(op));\n\top.cmd_q = cmd_q;\n\top.jobid = jobid;\n\top.sb_key = cmd_q->sb_key; \/* Pre-allocated *\/\n\top.sb_ctx = cmd_q->sb_ctx; \/* Pre-allocated *\/\n\top.init = 1;\n\top.u.aes.type = aes->type;\n\top.u.aes.mode = CCP_AES_MODE_GHASH;\n\top.u.aes.action = CCP_AES_GHASHFINAL;\n\top.src.type = CCP_MEMTYPE_SYSTEM;\n\top.src.u.dma.address = final_wa.dma.address;\n\top.src.u.dma.length = AES_BLOCK_SIZE;\n\top.dst.type = CCP_MEMTYPE_SYSTEM;\n\top.dst.u.dma.address = final_wa.dma.address;\n\top.dst.u.dma.length = AES_BLOCK_SIZE;\n\top.eom = 1;\n\top.u.aes.size = 0;\n\tret = cmd_q->ccp->vdata->perform->aes(&op);\n\tif (ret)\n\t\tgoto e_dst;\n\n\tif (aes->action == CCP_AES_ACTION_ENCRYPT) {\n\t\t\/* Put the ciphered tag after the ciphertext. *\/\n\t\tccp_get_dm_area(&final_wa, 0, p_tag, 0, authsize);\n\t} else {\n\t\t\/* Does this ciphered tag match the input? *\/\n\t\tret = ccp_init_dm_workarea(&tag, cmd_q, authsize,\n\t\t\t\t\t   DMA_BIDIRECTIONAL);\n\t\tif (ret)\n\t\t\tgoto e_tag;\n\t\tret = ccp_set_dm_area(&tag, 0, p_tag, 0, authsize);\n\t\tif (ret)\n\t\t\tgoto e_tag;\n\n\t\tret = crypto_memneq(tag.address, final_wa.address,\n\t\t\t\t    authsize) ? -EBADMSG : 0;\n\t\tccp_dm_free(&tag);\n\t}\n\ne_tag:\n\tccp_dm_free(&final_wa);\n\ne_dst:\n\tif (ilen > 0 && !in_place)\n\t\tccp_free_data(&dst, cmd_q);\n\ne_src:\n\tif (ilen > 0)\n\t\tccp_free_data(&src, cmd_q);\n\ne_aad:\n\tif (aes->aad_len)\n\t\tccp_free_data(&aad, cmd_q);\n\ne_ctx:\n\tccp_dm_free(&ctx);\n\ne_key:\n\tccp_dm_free(&key);\n\n\treturn ret;\n}","target":1,"code_token_length":2302,"total_token_length":2538,"max_tokens_setting":4096}
+{"idx":455318,"func":"initialize_readline ()\n{\n  rl_command_func_t *func;\n  char kseq[2];\n\n  if (bash_readline_initialized)\n    return;\n\n  rl_terminal_name = get_string_value (\"TERM\");\n  rl_instream = stdin;\n  rl_outstream = stderr;\n\n  \/* Allow conditional parsing of the ~\/.inputrc file. *\/\n  rl_readline_name = \"Bash\";\n\n  \/* Add bindable names before calling rl_initialize so they may be\n     referenced in the various inputrc files. *\/\n  rl_add_defun (\"shell-expand-line\", shell_expand_line, -1);\n#ifdef BANG_HISTORY\n  rl_add_defun (\"history-expand-line\", history_expand_line, -1);\n  rl_add_defun (\"magic-space\", tcsh_magic_space, -1);\n#endif\n\n  rl_add_defun (\"shell-forward-word\", bash_forward_shellword, -1);\n  rl_add_defun (\"shell-backward-word\", bash_backward_shellword, -1);\n  rl_add_defun (\"shell-kill-word\", bash_kill_shellword, -1);\n  rl_add_defun (\"shell-backward-kill-word\", bash_backward_kill_shellword, -1);\n  rl_add_defun (\"shell-transpose-words\", bash_transpose_shellwords, -1);\n\n#ifdef ALIAS\n  rl_add_defun (\"alias-expand-line\", alias_expand_line, -1);\n#  ifdef BANG_HISTORY\n  rl_add_defun (\"history-and-alias-expand-line\", history_and_alias_expand_line, -1);\n#  endif\n#endif\n\n  \/* Backwards compatibility. *\/\n  rl_add_defun (\"insert-last-argument\", rl_yank_last_arg, -1);\n\n  rl_add_defun (\"operate-and-get-next\", operate_and_get_next, -1);\n  rl_add_defun (\"display-shell-version\", display_shell_version, -1);\n  rl_add_defun (\"edit-and-execute-command\", emacs_edit_and_execute_command, -1);\n\n#if defined (BRACE_COMPLETION)\n  rl_add_defun (\"complete-into-braces\", bash_brace_completion, -1);\n#endif\n\n#if defined (SPECIFIC_COMPLETION_FUNCTIONS)\n  rl_add_defun (\"complete-filename\", bash_complete_filename, -1);\n  rl_add_defun (\"possible-filename-completions\", bash_possible_filename_completions, -1);\n  rl_add_defun (\"complete-username\", bash_complete_username, -1);\n  rl_add_defun (\"possible-username-completions\", bash_possible_username_completions, -1);\n  rl_add_defun (\"complete-hostname\", bash_complete_hostname, -1);\n  rl_add_defun (\"possible-hostname-completions\", bash_possible_hostname_completions, -1);\n  rl_add_defun (\"complete-variable\", bash_complete_variable, -1);\n  rl_add_defun (\"possible-variable-completions\", bash_possible_variable_completions, -1);\n  rl_add_defun (\"complete-command\", bash_complete_command, -1);\n  rl_add_defun (\"possible-command-completions\", bash_possible_command_completions, -1);\n  rl_add_defun (\"glob-complete-word\", bash_glob_complete_word, -1);\n  rl_add_defun (\"glob-expand-word\", bash_glob_expand_word, -1);\n  rl_add_defun (\"glob-list-expansions\", bash_glob_list_expansions, -1);\n#endif\n\n  rl_add_defun (\"dynamic-complete-history\", dynamic_complete_history, -1);\n  rl_add_defun (\"dabbrev-expand\", bash_dabbrev_expand, -1);\n\n  \/* Bind defaults before binding our custom shell keybindings. *\/\n  if (RL_ISSTATE(RL_STATE_INITIALIZED) == 0)\n    rl_initialize ();\n\n  \/* Bind up our special shell functions. *\/\n  rl_bind_key_if_unbound_in_map (CTRL('E'), shell_expand_line, emacs_meta_keymap);\n\n#ifdef BANG_HISTORY\n  rl_bind_key_if_unbound_in_map ('^', history_expand_line, emacs_meta_keymap);\n#endif\n\n  rl_bind_key_if_unbound_in_map (CTRL ('O'), operate_and_get_next, emacs_standard_keymap);\n  rl_bind_key_if_unbound_in_map (CTRL ('V'), display_shell_version, emacs_ctlx_keymap);\n\n  \/* In Bash, the user can switch editing modes with \"set -o [vi emacs]\",\n     so it is not necessary to allow C-M-j for context switching.  Turn\n     off this occasionally confusing behaviour. *\/\n  kseq[0] = CTRL('J');\n  kseq[1] = '\\0';\n  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);\n  if (func == rl_vi_editing_mode)\n    rl_unbind_key_in_map (CTRL('J'), emacs_meta_keymap);\n  kseq[0] = CTRL('M');\n  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);\n  if (func == rl_vi_editing_mode)\n    rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap);\n#if defined (VI_MODE)\n  kseq[0] = CTRL('E');\n  func = rl_function_of_keyseq (kseq, vi_movement_keymap, (int *)NULL);\n  if (func == rl_emacs_editing_mode)\n    rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap);\n#endif\n\n#if defined (BRACE_COMPLETION)\n  rl_bind_key_if_unbound_in_map ('{', bash_brace_completion, emacs_meta_keymap); \/*}*\/\n#endif \/* BRACE_COMPLETION *\/\n\n#if defined (SPECIFIC_COMPLETION_FUNCTIONS)\n  rl_bind_key_if_unbound_in_map ('\/', bash_complete_filename, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map ('\/', bash_possible_filename_completions, emacs_ctlx_keymap);\n\n  \/* Have to jump through hoops here because there is a default binding for\n     M-~ (rl_tilde_expand) *\/\n  kseq[0] = '~';\n  kseq[1] = '\\0';\n  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);\n  if (func == 0 || func == rl_tilde_expand)\n    rl_bind_keyseq_in_map (kseq, bash_complete_username, emacs_meta_keymap);\n\n  rl_bind_key_if_unbound_in_map ('~', bash_possible_username_completions, emacs_ctlx_keymap);\n\n  rl_bind_key_if_unbound_in_map ('@', bash_complete_hostname, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map ('@', bash_possible_hostname_completions, emacs_ctlx_keymap);\n\n  rl_bind_key_if_unbound_in_map ('$', bash_complete_variable, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map ('$', bash_possible_variable_completions, emacs_ctlx_keymap);\n\n  rl_bind_key_if_unbound_in_map ('!', bash_complete_command, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map ('!', bash_possible_command_completions, emacs_ctlx_keymap);\n\n  rl_bind_key_if_unbound_in_map ('g', bash_glob_complete_word, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map ('*', bash_glob_expand_word, emacs_ctlx_keymap);\n  rl_bind_key_if_unbound_in_map ('g', bash_glob_list_expansions, emacs_ctlx_keymap);\n\n#endif \/* SPECIFIC_COMPLETION_FUNCTIONS *\/\n\n  kseq[0] = TAB;\n  kseq[1] = '\\0';\n  func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);\n  if (func == 0 || func == rl_tab_insert)\n    rl_bind_key_in_map (TAB, dynamic_complete_history, emacs_meta_keymap);\n\n  \/* Tell the completer that we want a crack first. *\/\n  rl_attempted_completion_function = attempt_shell_completion;\n\n  \/* Tell the completer that we might want to follow symbolic links or\n     do other expansion on directory names. *\/\n  set_directory_hook ();\n\n  rl_filename_rewrite_hook = bash_filename_rewrite_hook;\n\n  rl_filename_stat_hook = bash_filename_stat_hook;\n\n  \/* Tell the filename completer we want a chance to ignore some names. *\/\n  rl_ignore_some_completions_function = filename_completion_ignore;\n\n  \/* Bind C-xC-e to invoke emacs and run result as commands. *\/\n  rl_bind_key_if_unbound_in_map (CTRL ('E'), emacs_edit_and_execute_command, emacs_ctlx_keymap);\n#if defined (VI_MODE)\n  rl_bind_key_if_unbound_in_map ('v', vi_edit_and_execute_command, vi_movement_keymap);\n#  if defined (ALIAS)\n  rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);\n#  endif\n\n  rl_bind_key_in_map ('\\\\', bash_vi_complete, vi_movement_keymap);\n  rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);\n  rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);\n#endif\n\n  rl_completer_quote_characters = \"'\\\"\";\n\n  \/* This sets rl_completer_word_break_characters and rl_special_prefixes\n     to the appropriate values, depending on whether or not hostname\n     completion is enabled. *\/\n  enable_hostname_completion (perform_hostname_completion);\n\n  \/* characters that need to be quoted when appearing in filenames. *\/\n  rl_filename_quote_characters = default_filename_quote_characters;\n  set_filename_bstab (rl_filename_quote_characters);\n\n  rl_filename_quoting_function = bash_quote_filename;\n  rl_filename_dequoting_function = bash_dequote_filename;\n  rl_char_is_quoted_p = char_is_quoted;\n\n  \/* Add some default bindings for the \"shellwords\" functions, roughly\n     parallelling the default word bindings in emacs mode. *\/\n  rl_bind_key_if_unbound_in_map (CTRL('B'), bash_backward_shellword, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map (CTRL('D'), bash_kill_shellword, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map (CTRL('F'), bash_forward_shellword, emacs_meta_keymap);\n  rl_bind_key_if_unbound_in_map (CTRL('T'), bash_transpose_shellwords, emacs_meta_keymap);\n\n#if 0\n  \/* This is superfluous and makes it impossible to use tab completion in\n     vi mode even when explicitly binding it in ~\/.inputrc.  sv_strict_posix()\n     should already have called posix_readline_initialize() when\n     posixly_correct was set. *\/\n  if (posixly_correct)\n    posix_readline_initialize (1);\n#endif\n\n  bash_readline_initialized = 1;\n}","target":0,"code_token_length":2240,"total_token_length":2476,"max_tokens_setting":4096}
+{"idx":443302,"func":"eval_vars(\n    char_u\t*src,\t\t\/\/ pointer into commandline\n    char_u\t*srcstart,\t\/\/ beginning of valid memory for src\n    int\t\t*usedlen,\t\/\/ characters after src that are used\n    linenr_T\t*lnump,\t\t\/\/ line number for :e command, or NULL\n    char\t**errormsg,\t\/\/ pointer to error message\n    int\t\t*escaped,\t\/\/ return value has escaped white space (can\n\t\t\t\t\/\/ be NULL)\n    int\t\tempty_is_error)\t\/\/ empty result is considered an error\n{\n    int\t\ti;\n    char_u\t*s;\n    char_u\t*result;\n    char_u\t*resultbuf = NULL;\n    int\t\tresultlen;\n    buf_T\t*buf;\n    int\t\tvalid = VALID_HEAD + VALID_PATH;    \/\/ assume valid result\n    int\t\tspec_idx;\n    int\t\ttilde_file = FALSE;\n    int\t\tskip_mod = FALSE;\n    char_u\tstrbuf[30];\n\n    *errormsg = NULL;\n    if (escaped != NULL)\n\t*escaped = FALSE;\n\n    \/*\n     * Check if there is something to do.\n     *\/\n    spec_idx = find_cmdline_var(src, usedlen);\n    if (spec_idx < 0)\t\/\/ no match\n    {\n\t*usedlen = 1;\n\treturn NULL;\n    }\n\n    \/*\n     * Skip when preceded with a backslash \"\\%\" and \"\\#\".\n     * Note: In \"\\\\%\" the % is also not recognized!\n     *\/\n    if (src > srcstart && src[-1] == '\\\\')\n    {\n\t*usedlen = 0;\n\tSTRMOVE(src - 1, src);\t\/\/ remove backslash\n\treturn NULL;\n    }\n\n    \/*\n     * word or WORD under cursor\n     *\/\n    if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD\n\t\t\t\t\t\t     || spec_idx == SPEC_CEXPR)\n    {\n\tresultlen = find_ident_under_cursor(&result,\n\t\tspec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING)\n\t      : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL)\n\t      : FIND_STRING);\n\tif (resultlen == 0)\n\t{\n\t    *errormsg = \"\";\n\t    return NULL;\n\t}\n    }\n\n    \/*\n     * '#': Alternate file name\n     * '%': Current file name\n     *\t    File name under the cursor\n     *\t    File name for autocommand\n     *\tand following modifiers\n     *\/\n    else\n    {\n\tint off = 0;\n\n\tswitch (spec_idx)\n\t{\n\tcase SPEC_PERC:\n#ifdef FEAT_EVAL\n\t\tif (!in_vim9script() || src[1] != '%')\n#endif\n\t\t{\n\t\t    \/\/ '%': current file\n\t\t    if (curbuf->b_fname == NULL)\n\t\t    {\n\t\t\tresult = (char_u *)\"\";\n\t\t\tvalid = 0;\t    \/\/ Must have \":p:h\" to be valid\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tresult = curbuf->b_fname;\n\t\t\ttilde_file = STRCMP(result, \"~\") == 0;\n\t\t    }\n\t\t    break;\n\t\t}\n#ifdef FEAT_EVAL\n\t\t\/\/ \"%%\" alternate file\n\t\toff = 1;\n#endif\n\t\t\/\/ FALLTHROUGH\n\tcase SPEC_HASH:\t\t\/\/ '#' or \"#99\": alternate file\n\t\tif (off == 0 ? src[1] == '#' : src[2] == '%')\n\t\t{\n\t\t    \/\/ \"##\" or \"%%%\": the argument list\n\t\t    result = arg_all();\n\t\t    resultbuf = result;\n\t\t    *usedlen = off + 2;\n\t\t    if (escaped != NULL)\n\t\t\t*escaped = TRUE;\n\t\t    skip_mod = TRUE;\n\t\t    break;\n\t\t}\n\t\ts = src + off + 1;\n\t\tif (*s == '<')\t\t\/\/ \"#<99\" uses v:oldfiles\n\t\t    ++s;\n\t\ti = (int)getdigits(&s);\n\t\tif (s == src + off + 2 && src[off + 1] == '-')\n\t\t    \/\/ just a minus sign, don't skip over it\n\t\t    s--;\n\t\t*usedlen = (int)(s - src); \/\/ length of what we expand\n\n\t\tif (src[off + 1] == '<' && i != 0)\n\t\t{\n\t\t    if (*usedlen < off + 2)\n\t\t    {\n\t\t\t\/\/ Should we give an error message for #<text?\n\t\t\t*usedlen = off + 1;\n\t\t\treturn NULL;\n\t\t    }\n#ifdef FEAT_EVAL\n\t\t    result = list_find_str(get_vim_var_list(VV_OLDFILES),\n\t\t\t\t\t\t\t\t     (long)i);\n\t\t    if (result == NULL)\n\t\t    {\n\t\t\t*errormsg = \"\";\n\t\t\treturn NULL;\n\t\t    }\n#else\n\t\t    *errormsg = _(e_hashsmall_is_not_available_without_the_eval_feature);\n\t\t    return NULL;\n#endif\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (i == 0 && src[off + 1] == '<' && *usedlen > off + 1)\n\t\t\t*usedlen = off + 1;\n\t\t    buf = buflist_findnr(i);\n\t\t    if (buf == NULL)\n\t\t    {\n\t\t\t*errormsg = _(e_no_alternate_file_name_to_substitute_for_hash);\n\t\t\treturn NULL;\n\t\t    }\n\t\t    if (lnump != NULL)\n\t\t\t*lnump = ECMD_LAST;\n\t\t    if (buf->b_fname == NULL)\n\t\t    {\n\t\t\tresult = (char_u *)\"\";\n\t\t\tvalid = 0;\t    \/\/ Must have \":p:h\" to be valid\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tresult = buf->b_fname;\n\t\t\ttilde_file = STRCMP(result, \"~\") == 0;\n\t\t    }\n\t\t}\n\t\tbreak;\n\n\tcase SPEC_CFILE:\t\/\/ file name under cursor\n\t\tresult = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = \"\";\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\n\tcase SPEC_AFILE:\t\/\/ file name for autocommand\n\t\tresult = autocmd_fname;\n\t\tif (result != NULL && !autocmd_fname_full)\n\t\t{\n\t\t    \/\/ Still need to turn the fname into a full path.  It is\n\t\t    \/\/ postponed to avoid a delay when <afile> is not used.\n\t\t    autocmd_fname_full = TRUE;\n\t\t    result = FullName_save(autocmd_fname, FALSE);\n\t\t    vim_free(autocmd_fname);\n\t\t    autocmd_fname = result;\n\t\t}\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_autocommand_file_name_to_substitute_for_afile);\n\t\t    return NULL;\n\t\t}\n\t\tresult = shorten_fname1(result);\n\t\tbreak;\n\n\tcase SPEC_ABUF:\t\t\/\/ buffer number for autocommand\n\t\tif (autocmd_bufnr <= 0)\n\t\t{\n\t\t    *errormsg = _(e_no_autocommand_buffer_name_to_substitute_for_abuf);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"%d\", autocmd_bufnr);\n\t\tresult = strbuf;\n\t\tbreak;\n\n\tcase SPEC_AMATCH:\t\/\/ match name for autocommand\n\t\tresult = autocmd_match;\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_autocommand_match_name_to_substitute_for_amatch);\n\t\t    return NULL;\n\t\t}\n\t\tbreak;\n\n\tcase SPEC_SFILE:\t\/\/ file name for \":so\" command\n\t\tresult = estack_sfile(ESTACK_SFILE);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_source_file_name_to_substitute_for_sfile);\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\tcase SPEC_STACK:\t\/\/ call stack\n\t\tresult = estack_sfile(ESTACK_STACK);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_call_stack_to_substitute_for_stack);\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\tcase SPEC_SCRIPT:\t\/\/ script file name\n\t\tresult = estack_sfile(ESTACK_SCRIPT);\n\t\tif (result == NULL)\n\t\t{\n\t\t    *errormsg = _(e_no_script_file_name_to_substitute_for_script);\n\t\t    return NULL;\n\t\t}\n\t\tresultbuf = result;\t    \/\/ remember allocated string\n\t\tbreak;\n\n\tcase SPEC_SLNUM:\t\/\/ line in file for \":so\" command\n\t\tif (SOURCING_NAME == NULL || SOURCING_LNUM == 0)\n\t\t{\n\t\t    *errormsg = _(e_no_line_number_to_use_for_slnum);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"%ld\", SOURCING_LNUM);\n\t\tresult = strbuf;\n\t\tbreak;\n\n#ifdef FEAT_EVAL\n\tcase SPEC_SFLNUM:\t\/\/ line in script file\n\t\tif (current_sctx.sc_lnum + SOURCING_LNUM == 0)\n\t\t{\n\t\t    *errormsg = _(e_no_line_number_to_use_for_sflnum);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"%ld\",\n\t\t\t\t (long)(current_sctx.sc_lnum + SOURCING_LNUM));\n\t\tresult = strbuf;\n\t\tbreak;\n\n\tcase SPEC_SID:\n\t\tif (current_sctx.sc_sid <= 0)\n\t\t{\n\t\t    *errormsg = _(e_using_sid_not_in_script_context);\n\t\t    return NULL;\n\t\t}\n\t\tsprintf((char *)strbuf, \"<SNR>%d_\", current_sctx.sc_sid);\n\t\tresult = strbuf;\n\t\tbreak;\n#endif\n\n#ifdef FEAT_CLIENTSERVER\n\tcase SPEC_CLIENT:\t\/\/ Source of last submitted input\n\t\tsprintf((char *)strbuf, PRINTF_HEX_LONG_U,\n\t\t\t\t\t\t\t(long_u)clientWindow);\n\t\tresult = strbuf;\n\t\tbreak;\n#endif\n\n\tdefault:\n\t\tresult = (char_u *)\"\"; \/\/ avoid gcc warning\n\t\tbreak;\n\t}\n\n\tresultlen = (int)STRLEN(result);\t\/\/ length of new string\n\tif (src[*usedlen] == '<')\t\/\/ remove the file name extension\n\t{\n\t    ++*usedlen;\n\t    if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))\n\t\tresultlen = (int)(s - result);\n\t}\n\telse if (!skip_mod)\n\t{\n\t    valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf,\n\t\t\t\t\t\t\t\t  &resultlen);\n\t    if (result == NULL)\n\t    {\n\t\t*errormsg = \"\";\n\t\treturn NULL;\n\t    }\n\t}\n    }\n\n    if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)\n    {\n\tif (empty_is_error)\n\t{\n\t    if (valid != VALID_HEAD + VALID_PATH)\n\t\t*errormsg = _(e_empty_file_name_for_percent_or_hash_only_works_with_ph);\n\t    else\n\t\t*errormsg = _(e_evaluates_to_an_empty_string);\n\t}\n\tresult = NULL;\n    }\n    else\n\tresult = vim_strnsave(result, resultlen);\n    vim_free(resultbuf);\n    return result;\n}","target":0,"code_token_length":2410,"total_token_length":2646,"max_tokens_setting":4096}
+{"idx":201382,"func":"drill_parse_T_code(gerb_file_t *fd, drill_state_t *state,\n\t\t\tgerbv_image_t *image, ssize_t file_line)\n{\n    int tool_num;\n    gboolean done = FALSE;\n    int temp;\n    double size;\n    gerbv_drill_stats_t *stats = image->drill_stats;\n    gerbv_aperture_t *apert;\n    gchar *tmps;\n    gchar *string;\n\n    dprintf(\"---> entering %s()...\\n\", __FUNCTION__);\n\n    \/* Sneak a peek at what's hiding after the 'T'. Ugly fix for\n       broken headers from Orcad, which is crap *\/\n    temp = gerb_fgetc(fd);\n    dprintf(\"  Found a char '%s' (0x%02x) after the T\\n\",\n\t    gerbv_escape_char(temp), temp);\n    \n    \/* might be a tool tool change stop switch on\/off*\/\n    if((temp == 'C') && ((fd->ptr + 2) < fd->datalen)){\n    \tif(gerb_fgetc(fd) == 'S'){\n    \t    if (gerb_fgetc(fd) == 'T' ){\n    \t  \tfd->ptr -= 4;\n    \t  \ttmps = get_line(fd++);\n    \t  \tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_NOTE, -1,\n\t\t\t_(\"Tool change stop switch found \\\"%s\\\" \"\n\t\t\t    \"at line %ld in file \\\"%s\\\"\"),\n\t\t\ttmps, file_line, fd->filename);\n\t  \tg_free (tmps);\n\n\t  \treturn -1;\n\t    }\n\t    gerb_ungetc(fd);\n\t}\n\tgerb_ungetc(fd);\n    }\n\n    if( !(isdigit(temp) != 0 || temp == '+' || temp =='-') ) {\n\tif(temp != EOF) {\n\t    gerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t   _(\"OrCAD bug: Junk text found in place of tool definition\"));\n\t    tmps = get_line(fd);\n\t    gerbv_stats_printf(stats->error_list, GERBV_MESSAGE_WARNING, -1,\n\t\t    _(\"Junk text \\\"%s\\\" \"\n\t\t\t\"at line %ld in file \\\"%s\\\"\"),\n\t\t    tmps, file_line, fd->filename);\n\t    g_free (tmps);\n\t    gerbv_stats_printf(stats->error_list, GERBV_MESSAGE_WARNING, -1,\n\t\t\t\t  _(\"Ignoring junk text\"));\n\t}\n\treturn -1;\n    }\n    gerb_ungetc(fd);\n\n    tool_num = (int) gerb_fgetint(fd, NULL);\n    dprintf (\"  Handling tool T%d at line %ld\\n\", tool_num, file_line);\n\n    if (tool_num == 0) \n\treturn tool_num; \/* T00 is a command to unload the drill *\/\n\n    if (tool_num < TOOL_MIN || tool_num >= TOOL_MAX) {\n\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t_(\"Out of bounds drill number %d \"\n\t\t    \"at line %ld in file \\\"%s\\\"\"),\n\t\ttool_num, file_line, fd->filename);\n    }\n\n    \/* Set the current tool to the correct one *\/\n    state->current_tool = tool_num;\n    apert = image->aperture[tool_num];\n\n    \/* Check for a size definition *\/\n    temp = gerb_fgetc(fd);\n\n    \/* This bit of code looks for a tool definition by scanning for strings\n     * of form TxxC, TxxF, TxxS.  *\/\n    while (!done) {\n\tswitch((char)temp) {\n\tcase 'C':\n\t    size = read_double(fd, state->header_number_format, GERBV_OMIT_ZEROS_TRAILING, state->decimals);\n\t    dprintf (\"  Read a size of %g\\n\", size);\n\n\t    if (state->unit == GERBV_UNIT_MM) {\n\t\tsize \/= 25.4;\n\t    } else if(size >= 4.0) {\n\t\t\/* If the drill size is >= 4 inches, assume that this\n\t\t   must be wrong and that the units are mils.\n\t\t   The limit being 4 inches is because the smallest drill\n\t\t   I've ever seen used is 0,3mm(about 12mil). Half of that\n\t\t   seemed a bit too small a margin, so a third it is *\/\n\n\t\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t\t_(\"Read a drill of diameter %g inches \"\n\t\t\t    \"at line %ld in file \\\"%s\\\"\"),\n\t\t\t    size, file_line, fd->filename);\n\t\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_WARNING, -1,\n\t\t\t_(\"Assuming units are mils\"));\n\t\tsize \/= 1000.0;\n\t    }\n\n\t    if (size <= 0. || size >= 10000.) {\n\t\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t\t_(\"Unreasonable drill size %g found for drill %d \"\n\t\t\t    \"at line %ld in file \\\"%s\\\"\"),\n\t\t\t    size, tool_num, file_line, fd->filename);\n\t    } else {\n\t\tif (apert != NULL) {\n\t\t    \/* allow a redefine of a tool only if the new definition is exactly the same.\n\t\t     * This avoid lots of spurious complaints with the output of some cad\n\t\t     * tools while keeping complaints if there is a true problem\n\t\t     *\/\n\t\t    if (apert->parameter[0] != size\n\t\t    ||  apert->type != GERBV_APTYPE_CIRCLE\n\t\t    ||  apert->nuf_parameters != 1\n\t\t    ||  apert->unit != GERBV_UNIT_INCH) {\n\n\t\t\tgerbv_stats_printf(stats->error_list,\n\t\t\t\tGERBV_MESSAGE_ERROR, -1,\n\t\t\t\t_(\"Found redefinition of drill %d \"\n\t\t\t\t\"at line %ld in file \\\"%s\\\"\"),\n\t\t\t\ttool_num, file_line, fd->filename);\n\t\t    }\n\t\t} else {\n\t\t    apert = image->aperture[tool_num] =\n\t\t\t\t\t\tg_new0(gerbv_aperture_t, 1);\n\t\t    if (apert == NULL)\n\t\t\tGERB_FATAL_ERROR(\"malloc tool failed in %s()\",\n\t\t\t\t\t__FUNCTION__);\n\n\t\t    \/* There's really no way of knowing what unit the tools\n\t\t       are defined in without sneaking a peek in the rest of\n\t\t       the file first. That's done in drill_guess_format() *\/\n\t\t    apert->parameter[0] = size;\n\t\t    apert->type = GERBV_APTYPE_CIRCLE;\n\t\t    apert->nuf_parameters = 1;\n\t\t    apert->unit = GERBV_UNIT_INCH;\n\t\t}\n\t    }\n\t    \n\t    \/* Add the tool whose definition we just found into the list\n\t     * of tools for this layer used to generate statistics. *\/\n\t    stats = image->drill_stats;\n\t    string = g_strdup_printf(\"%s\", (state->unit == GERBV_UNIT_MM ? _(\"mm\") : _(\"inch\")));\n\t    drill_stats_add_to_drill_list(stats->drill_list, \n\t\t\t\t\t  tool_num, \n\t\t\t\t\t  state->unit == GERBV_UNIT_MM ? size*25.4 : size, \n\t\t\t\t\t  string);\n\t    g_free(string);\n\t    break;\n\n\tcase 'F':\n\tcase 'S' :\n\t    \/* Silently ignored. They're not important. *\/\n\t    gerb_fgetint(fd, NULL);\n\t    break;\n\n\tdefault:\n\t    \/* Stop when finding anything but what's expected\n\t       (and put it back) *\/\n\t    gerb_ungetc(fd);\n\t    done = TRUE;\n\t    break;\n\t}  \/* switch((char)temp) *\/\n\n\ttemp = gerb_fgetc(fd);\n\tif (EOF == temp) {\n\t    gerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t    _(\"Unexpected EOF encountered in header of \"\n\t\t\t\"drill file \\\"%s\\\"\"), fd->filename);\n\n\t\/* Restore new line character for processing *\/\n\tif ('\\n' == temp || '\\r' == temp)\n\t    gerb_ungetc(fd);\n\t}\n    }   \/* while(!done) *\/  \/* Done looking at tool definitions *\/\n\n    \/* Catch the tools that aren't defined.\n       This isn't strictly a good thing, but at least something is shown *\/\n    if (apert == NULL) {\n        double dia;\n\n\tapert = image->aperture[tool_num] = g_new0(gerbv_aperture_t, 1);\n\tif (apert == NULL)\n\t    GERB_FATAL_ERROR(\"malloc tool failed in %s()\", __FUNCTION__);\n\n        \/* See if we have the tool table *\/\n        dia = gerbv_get_tool_diameter(tool_num);\n        if (dia <= 0) {\n            \/*\n             * There is no tool. So go out and make some.\n             * This size calculation is, of course, totally bogus.\n             *\/\n            dia = (double)(16 + 8 * tool_num) \/ 1000;\n            \/*\n             * Oooh, this is sooo ugly. But some CAD systems seem to always\n             * use T00 at the end of the file while others that don't have\n             * tool definitions inside the file never seem to use T00 at all.\n             *\/\n            if (tool_num != 0) {\n\t\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t\t_(\"Tool %02d used without being defined \"\n\t\t\t    \"at line %ld in file \\\"%s\\\"\"),\n\t\t\ttool_num, file_line, fd->filename);\n\t\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_WARNING, -1,\n\t\t\t_(\"Setting a default size of %g\\\"\"), dia);\n            }\n\t}\n\n\tapert->type = GERBV_APTYPE_CIRCLE;\n\tapert->nuf_parameters = 1;\n\tapert->parameter[0] = dia;\n\n\t\/* Add the tool whose definition we just found into the list\n\t * of tools for this layer used to generate statistics. *\/\n\tif (tool_num != 0) {  \/* Only add non-zero tool nums.  \n\t\t\t       * Zero = unload command. *\/\n\t    stats = image->drill_stats;\n\t    string = g_strdup_printf(\"%s\", \n\t\t\t\t     (state->unit == GERBV_UNIT_MM ? _(\"mm\") : _(\"inch\")));\n\t    drill_stats_add_to_drill_list(stats->drill_list, \n\t\t\t\t\t  tool_num, \n\t\t\t\t\t  state->unit == GERBV_UNIT_MM ? dia*25.4 : dia,\n\t\t\t\t\t  string);\n\t    g_free(string);\n\t}\n    } \/* if(image->aperture[tool_num] == NULL) *\/\t\n    \n    dprintf(\"<----  ...leaving %s()\\n\", __FUNCTION__);\n\n    return tool_num;\n} \/* drill_parse_T_code() *\/","target":1,"code_token_length":2263,"total_token_length":2499,"max_tokens_setting":4096}
+{"idx":219947,"func":"int callback_glewlwyd_user_auth (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_result = NULL;\n  const char * ip_source = get_ip_source(request);\n  char * issued_for = get_client_hostname(request);\n  char * session_uid, expires[129];\n  time_t now;\n  struct tm ts;\n  \n  time(&now);\n  now += GLEWLWYD_DEFAULT_SESSION_EXPIRATION_COOKIE;\n  gmtime_r(&now, &ts);\n  strftime(expires, 128, \"%a, %d %b %Y %T %Z\", &ts);\n  if (j_param != NULL) {\n    if (json_string_length(json_object_get(j_param, \"username\"))) {\n      if (json_object_get(j_param, \"scheme_type\") == NULL || 0 == o_strcmp(json_string_value(json_object_get(j_param, \"scheme_type\")), \"password\")) {\n        if (json_string_length(json_object_get(j_param, \"password\"))) {\n          j_result = auth_check_user_credentials(config, json_string_value(json_object_get(j_param, \"username\")), json_string_value(json_object_get(j_param, \"password\")));\n          if (check_result_value(j_result, G_OK)) {\n            if ((session_uid = get_session_id(config, request)) == NULL) {\n              session_uid = generate_session_id();\n            }\n            if (user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), NULL, 1) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (1)\");\n              response->status = 500;\n            } else {\n              ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n              y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' authenticated with password\", json_string_value(json_object_get(j_param, \"username\")));\n            }\n            o_free(session_uid);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, \"scheme_type\", \"password\", NULL);\n          } else {\n            if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n              y_log_message(Y_LOG_LEVEL_WARNING, \"Security - Authorization invalid for username %s at IP Address %s\", json_string_value(json_object_get(j_param, \"username\")), ip_source);\n            }\n            response->status = 401;\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, \"scheme_type\", \"password\", NULL);\n          }\n          json_decref(j_result);\n        } else if (json_object_get(j_param, \"password\") != NULL && !json_is_string(json_object_get(j_param, \"password\"))) {\n          ulfius_set_string_body_response(response, 400, \"password must be a string\");\n        } else {\n          session_uid = get_session_id(config, request);\n          j_result = get_users_for_session(config, session_uid);\n          if (check_result_value(j_result, G_OK)) {\n            \/\/ Refresh username to set as default\n            if (user_session_update(config, u_map_get(request->map_cookie, config->session_key), u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), NULL, 0) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (3)\");\n              response->status = 500;\n            } else {\n              ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n            }\n          } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) {\n            response->status = 401;\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error get_users_for_session\");\n            response->status = 500;\n          }\n          o_free(session_uid);\n          json_decref(j_result);\n        }\n      } else {\n        if (json_string_length(json_object_get(j_param, \"scheme_type\")) && json_string_length(json_object_get(j_param, \"scheme_name\")) && json_is_object(json_object_get(j_param, \"value\"))) {\n          j_result = auth_check_user_scheme(config, json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")), json_string_value(json_object_get(j_param, \"username\")), json_object_get(j_param, \"value\"), request);\n          if (check_result_value(j_result, G_ERROR_PARAM)) {\n            ulfius_set_string_body_response(response, 400, \"bad scheme response\");\n          } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n            y_log_message(Y_LOG_LEVEL_WARNING, \"Security - Authorization invalid for username %s at IP Address %s\", json_string_value(json_object_get(j_param, \"username\")), ip_source);\n            response->status = 401;\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, \"scheme_type\", json_string_value(json_object_get(j_param, \"scheme_type\")), \"scheme_name\", json_string_value(json_object_get(j_param, \"scheme_name\")), NULL);\n          } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) {\n            response->status = 404;\n          } else if (check_result_value(j_result, G_OK)) {\n            if ((session_uid = get_session_id(config, request)) == NULL) {\n              session_uid = generate_session_id();\n            }\n            if (user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_param, \"username\")), json_string_value(json_object_get(j_param, \"scheme_name\")), 1) != G_OK) {\n              y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (4)\");\n              response->status = 500;\n            } else {\n              ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n              y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' authenticated with scheme '%s\/%s'\", json_string_value(json_object_get(j_param, \"username\")), json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")));\n            }\n            o_free(session_uid);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL);\n            glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, \"scheme_type\", json_string_value(json_object_get(j_param, \"scheme_type\")), \"scheme_name\", json_string_value(json_object_get(j_param, \"scheme_name\")), NULL);\n          } else {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error auth_check_user_scheme\");\n            response->status = 500;\n          }\n          json_decref(j_result);\n        } else {\n          ulfius_set_string_body_response(response, 400, \"scheme_type, scheme_name and value are mandatory\");\n        }\n      }\n    } else {\n      if (json_string_length(json_object_get(j_param, \"scheme_type\")) && json_string_length(json_object_get(j_param, \"scheme_name\")) && json_is_object(json_object_get(j_param, \"value\"))) {\n        j_result = auth_check_identify_scheme(config, json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")), json_object_get(j_param, \"value\"), request);\n        if (check_result_value(j_result, G_ERROR_PARAM)) {\n          ulfius_set_string_body_response(response, 400, \"bad scheme response\");\n        } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) {\n          y_log_message(Y_LOG_LEVEL_WARNING, \"Security - Authorization invalid for username <UNKNOWN> at IP Address %s\", ip_source);\n          response->status = 401;\n        } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) {\n          response->status = 404;\n        } else if (check_result_value(j_result, G_OK)) {\n          if ((session_uid = get_session_id(config, request)) == NULL) {\n            session_uid = generate_session_id();\n          }\n          if (user_session_update(config, session_uid, u_map_get_case(request->map_header, \"user-agent\"), issued_for, json_string_value(json_object_get(j_result, \"username\")), json_string_value(json_object_get(j_param, \"scheme_name\")), 1) != G_OK) {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error user_session_update (4)\");\n            response->status = 500;\n          } else {\n            ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n            y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' authenticated with scheme '%s\/%s'\", json_string_value(json_object_get(j_result, \"username\")), json_string_value(json_object_get(j_param, \"scheme_type\")), json_string_value(json_object_get(j_param, \"scheme_name\")));\n          }\n          o_free(session_uid);\n        } else {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_auth - Error auth_check_user_scheme\");\n          response->status = 500;\n        }\n        json_decref(j_result);\n      } else {\n        ulfius_set_string_body_response(response, 400, \"username is mandatory\");\n      }\n    }\n  } else {\n    ulfius_set_string_body_response(response, 400, \"Input parameters must be in JSON format\");\n  }\n  json_decref(j_param);\n  o_free(issued_for);\n\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":2335,"total_token_length":2571,"max_tokens_setting":4096}
+{"idx":425259,"func":"static Image *ReadMETAImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  Image\n    *buff,\n    *image;\n\n  MagickBooleanType\n    status;\n\n  StringInfo\n    *profile;\n\n  size_t\n    length;\n\n  void\n    *blob;\n\n  \/*\n    Open file containing binary metadata\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  image->columns=1;\n  image->rows=1;\n  if (SetImageBackgroundColor(image) == MagickFalse)\n    {\n      InheritException(exception,&image->exception);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  length=1;\n  if (LocaleNCompare(image_info->magick,\"8BIM\",4) == 0)\n    {\n      \/*\n        Read 8BIM binary metadata.\n      *\/\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      if (LocaleCompare(image_info->magick,\"8BIMTEXT\") == 0)\n        {\n          length=(size_t) parse8BIM(image, buff);\n          if (length & 1)\n            (void) WriteBlobByte(buff,0x0);\n        }\n      else if (LocaleCompare(image_info->magick,\"8BIMWTEXT\") == 0)\n        {\n          length=(size_t) parse8BIMW(image, buff);\n          if (length & 1)\n            (void) WriteBlobByte(buff,0x0);\n        }\n      else\n        CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      status=SetImageProfile(image,\"8bim\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n      if (status == MagickFalse)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    }\n  if (LocaleNCompare(image_info->magick,\"APP1\",4) == 0)\n    {\n      char\n        name[MaxTextExtent];\n\n      (void) FormatLocaleString(name,MaxTextExtent,\"APP%d\",1);\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      if (LocaleCompare(image_info->magick,\"APP1JPEG\") == 0)\n        {\n          Image\n            *iptc;\n\n          int\n            result;\n\n          if (image_info->profile == (void *) NULL)\n            {\n              blob=DetachBlob(buff->blob);\n              blob=(unsigned char *) RelinquishMagickMemory(blob);\n              buff=DestroyImage(buff);\n              ThrowReaderException(CoderError,\"NoIPTCProfileAvailable\");\n            }\n          profile=CloneStringInfo((StringInfo *) image_info->profile);\n          iptc=AcquireImage((ImageInfo *) NULL);\n          if (iptc == (Image *) NULL)\n            {\n              blob=DetachBlob(buff->blob);\n              blob=(unsigned char *) RelinquishMagickMemory(blob);\n              buff=DestroyImage(buff);\n              ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n            }\n          AttachBlob(iptc->blob,GetStringInfoDatum(profile),\n            GetStringInfoLength(profile));\n          result=jpeg_embed(image,buff,iptc);\n          blob=DetachBlob(iptc->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          iptc=DestroyImage(iptc);\n          if (result == 0)\n            ThrowReaderException(CoderError,\"JPEGEmbeddingFailed\");\n        }\n      else\n        CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      status=SetImageProfile(image,name,profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n      if (status == MagickFalse)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n    }\n  if ((LocaleCompare(image_info->magick,\"ICC\") == 0) ||\n      (LocaleCompare(image_info->magick,\"ICM\") == 0))\n    {\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) SetImageProfile(image,\"icc\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n    }\n  if (LocaleCompare(image_info->magick,\"IPTC\") == 0)\n    {\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) SetImageProfile(image,\"iptc\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n    }\n  if (LocaleCompare(image_info->magick,\"XMP\") == 0)\n    {\n      buff=AcquireImage((ImageInfo *) NULL);\n      if (buff == (Image *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char));\n      if (blob == (unsigned char *) NULL)\n        {\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      AttachBlob(buff->blob,blob,length);\n      CopyBlob(image,buff);\n      profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t)\n        GetBlobSize(buff));\n      if (profile == (StringInfo *) NULL)\n        {\n          blob=DetachBlob(buff->blob);\n          blob=(unsigned char *) RelinquishMagickMemory(blob);\n          buff=DestroyImage(buff);\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n      (void) SetImageProfile(image,\"xmp\",profile);\n      profile=DestroyStringInfo(profile);\n      blob=DetachBlob(buff->blob);\n      blob=(unsigned char *) RelinquishMagickMemory(blob);\n      buff=DestroyImage(buff);\n    }\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":2025,"total_token_length":2261,"max_tokens_setting":4096}
+{"idx":246748,"func":"static u32 parse_meta_args(char *opts, MetaActionType act_type)\n{\n\tMetaAction *meta;\n\n\tmetas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act + 1));\n\tif (!metas) return 2;\n\tmeta = &metas[nb_meta_act];\n\tnb_meta_act ++;\n\n\tmemset(meta, 0, sizeof(MetaAction));\n\tmeta->act_type = act_type;\n\tmeta->trackID = 0;\n\tmeta->root_meta = 1;\n\topen_edit = GF_TRUE;\n\n\tif (!opts) return 2;\n\n\tif (act_type == META_ACTION_ADD_IMAGE_ITEM)\n\t\thas_add_image = GF_TRUE;\n\n\twhile (1) {\n\t\tchar *next;\n\t\tchar *szSlot;\n\t\tif (!opts || !opts[0]) return 0;\n\t\tif (opts[0]==':') opts += 1;\n\n\t\tszSlot = opts;\n\t\tnext = gf_url_colon_suffix(opts);\n\t\tif (next) next[0] = 0;\n\n\t\tif (!strnicmp(szSlot, \"tk=\", 3)) {\n\t\t\tsscanf(szSlot, \"tk=%u\", &meta->trackID);\n\t\t\tmeta->root_meta = 0;\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"id=\", 3)) {\n\t\t\tmeta->item_id = atoi(szSlot+3);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"type=\", 5)) {\n\t\t\tmeta->item_type = GF_4CC(szSlot[5], szSlot[6], szSlot[7], szSlot[8]);\n\t\t}\n\t\t\/\/\"ref\" (without '=') is for data reference, \"ref=\" is for item references\n\t\telse if (!strnicmp(szSlot, \"ref=\", 4)) {\n\t\t\tchar type[5];\n\t\t\tMetaRef\t*ref;\n\t\t\tif (!meta->item_refs) {\n\t\t\t\tmeta->item_refs = gf_list_new();\n\t\t\t\tif (!meta->item_refs) return 2;\n\t\t\t}\n\t\t\tGF_SAFEALLOC(ref, MetaRef);\n\t\t\tif (!ref) return 2;\n\t\t\tsscanf(szSlot, \"ref=%4s,%u\", type, &(ref->ref_item_id));\n\t\t\tref->ref_type = GF_4CC(type[0], type[1], type[2], type[3]);\n\t\t\tgf_list_add(meta->item_refs, ref);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"name=\", 5)) {\n\t\t\tmeta->szName = gf_strdup(szSlot+5);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"path=\", 5)) {\n\t\t\tmeta->szPath = gf_strdup(szSlot+5);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"mime=\", 5)) {\n\t\t\tmeta->item_type = GF_META_ITEM_TYPE_MIME;\n\t\t\tmeta->mime_type = gf_strdup(szSlot+5);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"encoding=\", 9)) {\n\t\t\tmeta->enc_type = gf_strdup(szSlot+9);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"image-size=\", 11)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tsscanf(szSlot+11, \"%dx%d\", &meta->image_props->width, &meta->image_props->height);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"image-grid-size=\", 16)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t}\n\t\t\tsscanf(szSlot+16, \"%dx%d\", &meta->image_props->num_grid_rows, &meta->image_props->num_grid_columns);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"image-pasp=\", 11)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tsscanf(szSlot+11, \"%dx%d\", &meta->image_props->hSpacing, &meta->image_props->vSpacing);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"image-rloc=\", 11)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tsscanf(szSlot+11, \"%dx%d\", &meta->image_props->hOffset, &meta->image_props->vOffset);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"rotation=\", 9)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->angle = atoi(szSlot+9);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"mirror-axis=\", 12)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->mirror = (!strnicmp(szSlot+12, \"vertical\", 8) ? 1 : 2);\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"clap=\", 5)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tsscanf(szSlot + 5, \"%d,%d,%d,%d,%d,%d,%d,%d\", &meta->image_props->clap_wnum, &meta->image_props->clap_wden,\n\t\t\t\t\t   &meta->image_props->clap_hnum, &meta->image_props->clap_hden,\n\t\t\t\t\t   &meta->image_props->clap_honum, &meta->image_props->clap_hoden,\n\t\t\t\t\t   &meta->image_props->clap_vonum, &meta->image_props->clap_voden);\n\t\t}\n\t\telse if (!stricmp(szSlot, \"hidden\")) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->hidden = GF_TRUE;\n\t\t}\n\t\telse if (!stricmp(szSlot, \"alpha\")) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->alpha = GF_TRUE;\n\t\t}\n\t\t\/\/\"ref\" (without '=') is for data reference, \"ref=\" is for item references\n\t\telse if (!stricmp(szSlot, \"ref\")) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->use_reference = GF_TRUE;\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"time=\", 5)) {\n\t\t\tFloat s=0, e=0, step=0;\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tif (sscanf(szSlot+5, \"%f-%f\/%f\", &s, &e, &step)==3) {\n\t\t\t\tmeta->image_props->time = s;\n\t\t\t\tmeta->image_props->end_time = e;\n\t\t\t\tmeta->image_props->step_time = step;\n\t\t\t} else if (sscanf(szSlot+5, \"%f-%f\", &s, &e)==2) {\n\t\t\t\tmeta->image_props->time = s;\n\t\t\t\tmeta->image_props->end_time = e;\n\t\t\t} else if (sscanf(szSlot+5, \"%f\/%f\", &s, &step)==2) {\n\t\t\t\tmeta->image_props->time = s;\n\t\t\t\tmeta->image_props->step_time = step;\n\t\t\t} else if (sscanf(szSlot+5, \"%f\", &s)==1) {\n\t\t\t\tmeta->image_props->time = s;\n\t\t\t}\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"samp=\", 5)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->sample_num = atoi(szSlot+5);\n\t\t\tmeta->root_meta = 1;\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"group=\", 6)) {\n\t\t\tchar type[5];\n\t\t\tsscanf(szSlot, \"group=%4s,%u\", type, &meta->group_id);\n\t\t\tmeta->group_type = GF_4CC(type[0], type[1], type[2], type[3]);\n\t\t}\n\t\telse if (!stricmp(szSlot, \"split_tiles\")) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->tile_mode = TILE_ITEM_ALL_BASE;\n\t\t}\n\t\telse if (!stricmp(szSlot, \"dref\")) {\n\t\t\tmeta->use_dref = 1;\n\t\t}\n\t\telse if (!stricmp(szSlot, \"primary\")) {\n\t\t\tmeta->primary = 1;\n\t\t}\n\t\telse if (!stricmp(szSlot, \"binary\")) {\n\t\t\tif (meta->act_type==META_ACTION_SET_XML) meta->act_type=META_ACTION_SET_BINARY_XML;\n\t\t}\n\t\telse if (!strnicmp(szSlot, \"icc_path=\", 9)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tstrcpy(meta->image_props->iccPath, szSlot+9);\n\t\t}\n\t\telse if (!stricmp(szSlot, \"agrid\") || !strnicmp(szSlot, \"agrid=\", 6)) {\n\t\t\tif (!meta->image_props) {\n\t\t\t\tGF_SAFEALLOC(meta->image_props, GF_ImageItemProperties);\n\t\t\t\tif (!meta->image_props) return 2;\n\t\t\t}\n\t\t\tmeta->image_props->auto_grid = GF_TRUE;\n\t\t\tif (!strnicmp(szSlot, \"agrid=\", 6))\n\t\t\t\tmeta->image_props->auto_grid_ratio = atof(szSlot+6);\n\t\t}\n\t\telse if (!strchr(szSlot, '=')) {\n\t\t\tswitch (meta->act_type) {\n\t\t\tcase META_ACTION_SET_TYPE:\n\t\t\t\tif (!stricmp(szSlot, \"null\") || !stricmp(szSlot, \"0\")) meta->meta_4cc = 0;\n\t\t\t\telse meta->meta_4cc = GF_4CC(szSlot[0], szSlot[1], szSlot[2], szSlot[3]);\n\t\t\t\tbreak;\n\t\t\tcase META_ACTION_ADD_ITEM:\n\t\t\tcase META_ACTION_ADD_IMAGE_ITEM:\n\t\t\tcase META_ACTION_SET_XML:\n\t\t\tcase META_ACTION_DUMP_XML:\n\t\t\t\tif (!strncmp(szSlot, \"dopt\", 4) || !strncmp(szSlot, \"sopt\", 4) || !strncmp(szSlot, \"@\", 1)) {\n\t\t\t\t\tif (next) next[0]=':';\n\t\t\t\t\tnext=NULL;\n\t\t\t\t}\n\t\t\t\t\/\/cat as -add arg\n\t\t\t\tgf_dynstrcat(&meta->szPath, szSlot, \":\");\n\t\t\t\tif (!meta->szPath) return 2;\n\t\t\t\tbreak;\n\t\t\tcase META_ACTION_REM_ITEM:\n\t\t\tcase META_ACTION_SET_PRIMARY_ITEM:\n\t\t\tcase META_ACTION_DUMP_ITEM:\n\t\t\t\tmeta->item_id = atoi(szSlot);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!next) break;\n\t\topts += strlen(szSlot);\n\t\tnext[0] = ':';\n\t}\n\treturn 0;\n}","target":0,"code_token_length":2650,"total_token_length":2886,"max_tokens_setting":4096}
+{"idx":259715,"func":"static json_t * check_attestation_android_safetynet(json_t * j_params, cbor_item_t * auth_data, cbor_item_t * att_stmt, const unsigned char * client_data) {\n  json_t * j_error = json_array(), * j_return;\n  unsigned char pubkey_export[1024] = {0}, cert_export[32] = {0}, cert_export_b64[64], client_data_hash[32], * nonce_base = NULL, nonce_base_hash[32], * nonce_base_hash_b64 = NULL, * header_cert_decoded = NULL;\n  char * message = NULL, * response_token = NULL, issued_to[128] = {0}, * jwt_header = NULL;\n  size_t pubkey_export_len = 1024, cert_export_len = 32, cert_export_b64_len, issued_to_len = 128, client_data_hash_len = 32, nonce_base_hash_len = 32, nonce_base_hash_b64_len = 0, header_cert_decoded_len = 0;\n  gnutls_pubkey_t pubkey = NULL;\n  gnutls_x509_crt_t cert = NULL;\n  cbor_item_t * key, * response = NULL;\n  int i, ret;\n  jwt_t * j_response = NULL;\n  json_t * j_header_x5c = NULL, * j_cert = NULL, * j_header = NULL, * j_value = NULL;\n  gnutls_datum_t cert_dat;\n  int has_ver = 0;\n  \n  if (j_error != NULL) {\n    do {\n      \/\/ Step 1\n      if (!cbor_isa_map(att_stmt) || cbor_map_size(att_stmt) != 2) {\n        json_array_append_new(j_error, json_string(\"CBOR map value 'attStmt' invalid format\"));\n        break;\n      }\n      for (i=0; i<2; i++) {\n        key = cbor_map_handle(att_stmt)[i].key;\n        if (cbor_isa_string(key)) {\n          if (0 == o_strncmp((const char *)cbor_string_handle(key), \"ver\", MIN(o_strlen(\"ver\"), cbor_string_length(key))) && cbor_isa_string(cbor_map_handle(att_stmt)[i].value)) {\n            has_ver = 1;\n          } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"response\", MIN(o_strlen(\"response\"), cbor_string_length(key))) && cbor_isa_bytestring(cbor_map_handle(att_stmt)[i].value)) {\n            response = cbor_map_handle(att_stmt)[i].value;\n          } else {\n            message = msprintf(\"attStmt map element %d key is not valid: '%.*s'\", i, cbor_string_length(key), cbor_string_handle(key));\n            json_array_append_new(j_error, json_string(message));\n            o_free(message);\n            break;\n          }\n        } else {\n          message = msprintf(\"attStmt map element %d key is not a string\", i);\n          json_array_append_new(j_error, json_string(message));\n          o_free(message);\n          break;\n        }\n      }\n      \n      if (!has_ver) {\n        json_array_append_new(j_error, json_string(\"version invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error ver missing\");\n        break;\n      }\n\n      if (!generate_digest_raw(digest_SHA256, client_data, o_strlen((char *)client_data), client_data_hash, &client_data_hash_len)) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error generate_digest_raw client_data\");\n        break;\n      }\n      \n      if ((nonce_base = o_malloc(32 + cbor_bytestring_length(auth_data))) == NULL) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error allocating resources for nonce_base\");\n        break;\n      }\n      memcpy(nonce_base, cbor_bytestring_handle(auth_data), cbor_bytestring_length(auth_data));\n      memcpy(nonce_base+cbor_bytestring_length(auth_data), client_data_hash, client_data_hash_len);\n      \n      if (!generate_digest_raw(digest_SHA256, nonce_base, 32 + cbor_bytestring_length(auth_data), nonce_base_hash, &nonce_base_hash_len)) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error generate_digest_raw nonce_base\");\n        break;\n      }\n      \n      if ((nonce_base_hash_b64 = o_malloc(64)) == NULL) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error allocating resources for nonce_base_hash_b64\");\n        break;\n      }\n\n      if (!o_base64_encode(nonce_base_hash, 32, nonce_base_hash_b64, &nonce_base_hash_b64_len)) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error o_base64_encode for nonce_base_hash_b64\");\n        break;\n      }\n      \n      if (response == NULL) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error response missing\");\n        break;\n      }\n      \n      if ((response_token = o_strndup((const char *)cbor_bytestring_handle(response), cbor_bytestring_length(response))) == NULL) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error o_strndup for response_token\");\n        break;\n      }\n      \n      if (r_jwt_init(&j_response) != RHN_OK) {\n        json_array_append_new(j_error, json_string(\"Internal error\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error r_jwt_init\");\n        break;\n      }\n      \n      if (r_jwt_parse(j_response, response_token, 0) != RHN_OK) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error r_jwt_parse\");\n        break;\n      }\n      \n      if (o_strcmp(r_jwt_get_claim_str_value(j_response, \"nonce\"), (const char *)nonce_base_hash_b64)) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error nonce invalid\");\n        break;\n      }\n      \n      if (json_integer_value(json_object_get(j_params, \"ctsProfileMatch\")) != -1 && json_integer_value(json_object_get(j_params, \"ctsProfileMatch\")) != ((j_value = r_jwt_get_claim_json_t_value(j_response, \"ctsProfileMatch\"))==json_true()?1:0)) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error ctsProfileMatch invalid\");\n        json_decref(j_value);\n        j_value = NULL;\n        break;\n      }\n      json_decref(j_value);\n      j_value = NULL;\n      \n      if (json_integer_value(json_object_get(j_params, \"basicIntegrity\")) != -1 && json_integer_value(json_object_get(j_params, \"basicIntegrity\")) != ((j_value = r_jwt_get_claim_json_t_value(j_response, \"basicIntegrity\"))==json_true()?1:0)) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error basicIntegrity invalid\");\n        j_value = NULL;\n        break;\n      }\n      json_decref(j_value);\n      j_value = NULL;\n      \n      if (r_jwt_verify_signature(j_response, NULL, 0) != RHN_OK) {\n        json_array_append_new(j_error, json_string(\"Invalid signature\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error r_jwt_verify_signature\");\n        break;\n      }\n      \n      if ((j_header_x5c = r_jwt_get_header_json_t_value(j_response, \"x5c\")) == NULL) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error parsing x5c JSON\");\n        break;\n      }\n      \n      if (!json_is_string((j_cert = json_array_get(j_header_x5c, 0)))) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error x5c leaf not a string\");\n        break;\n      }\n      \n      if ((header_cert_decoded = o_malloc(json_string_length(j_cert))) == NULL) {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error allocating resources for header_cert_decoded\");\n        break;\n      }\n      \n      if (!o_base64_decode((const unsigned char *)json_string_value(j_cert), json_string_length(j_cert), header_cert_decoded, &header_cert_decoded_len)) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error o_base64_decode x5c leaf\");\n        break;\n      }\n      \n      if (gnutls_x509_crt_init(&cert)) {\n        json_array_append_new(j_error, json_string(\"internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error gnutls_x509_crt_init\");\n        break;\n      }\n      if (gnutls_pubkey_init(&pubkey)) {\n        json_array_append_new(j_error, json_string(\"internal error\"));\n        y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error gnutls_pubkey_init\");\n        break;\n      }\n      cert_dat.data = header_cert_decoded;\n      cert_dat.size = header_cert_decoded_len;\n      if ((ret = gnutls_x509_crt_import(cert, &cert_dat, GNUTLS_X509_FMT_DER)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error importing x509 certificate\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error gnutls_pcert_import_x509_raw: %d\", ret);\n        break;\n      }\n      if ((ret = gnutls_pubkey_import_x509(pubkey, cert, 0)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error importing x509 certificate\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error gnutls_pubkey_import_x509: %d\", ret);\n        break;\n      }\n      if ((ret = gnutls_x509_crt_get_key_id(cert, GNUTLS_KEYID_USE_SHA256, cert_export, &cert_export_len)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error exporting x509 certificate\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error gnutls_x509_crt_get_key_id: %d\", ret);\n        break;\n      }\n      if ((ret = gnutls_x509_crt_get_dn(cert, issued_to, &issued_to_len)) < 0) {\n        json_array_append_new(j_error, json_string(\"Error x509 dn\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error gnutls_x509_crt_get_dn: %d\", ret);\n        break;\n      }\n      if (o_strnstr(issued_to, SAFETYNET_ISSUED_TO, issued_to_len) == NULL) {\n        json_array_append_new(j_error, json_string(\"Error x509 dn\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - safetynet certificate issued for %.*s\", issued_to_len, issued_to);\n        break;\n      }\n      if (json_object_get(j_params, \"google-root-ca-r2\") != json_null()) {\n        if ((ret = validate_safetynet_ca_root(j_params, cert, j_header_x5c)) == G_ERROR_UNAUTHORIZED) {\n          json_array_append_new(j_error, json_string(\"Error x509 certificate chain validation\"));\n          break;\n        } else if (ret != G_OK) {\n          json_array_append_new(j_error, json_string(\"response invalid\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - safetynet certificate chain certificate validation error\");\n          break;\n        }\n      }\n      if (!o_base64_encode(cert_export, cert_export_len, cert_export_b64, &cert_export_b64_len)) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error o_base64_encode cert_export\");\n        break;\n      }\n      if ((ret = gnutls_pubkey_export(pubkey, GNUTLS_X509_FMT_PEM, pubkey_export, &pubkey_export_len)) < 0) {\n        json_array_append_new(j_error, json_string(\"response invalid\"));\n        y_log_message(Y_LOG_LEVEL_DEBUG, \"check_attestation_android_safetynet - Error gnutls_pubkey_export: %d\", ret);\n        break;\n      }\n      \n    } while (0);\n\n    if (json_array_size(j_error)) {\n      j_return = json_pack(\"{sisO}\", \"result\", G_ERROR_PARAM, \"error\", j_error);\n    } else {\n      j_return = json_pack(\"{sis{ss%}}\", \"result\", G_OK, \"data\", \"certificate\", cert_export_b64, cert_export_b64_len);\n    }\n    json_decref(j_error);\n    json_decref(j_header);\n    json_decref(j_header_x5c);\n    gnutls_pubkey_deinit(pubkey);\n    gnutls_x509_crt_deinit(cert);\n    r_jwt_free(j_response);\n    o_free(nonce_base);\n    o_free(nonce_base_hash_b64);\n    o_free(response_token);\n    o_free(header_cert_decoded);\n    o_free(jwt_header);\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"check_attestation_android_safetynet - Error allocating resources for j_error\");\n    j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n  }\n  return j_return;\n}","target":0,"code_token_length":3270,"total_token_length":3506,"max_tokens_setting":4096}
+{"idx":234153,"func":"process_cu_tu_index (struct dwarf_section *section, int do_display)\n{\n  unsigned char *phdr = section->start;\n  unsigned char *limit = phdr + section->size;\n  unsigned char *phash;\n  unsigned char *pindex;\n  unsigned char *ppool;\n  unsigned int version;\n  unsigned int ncols = 0;\n  unsigned int nused;\n  unsigned int nslots;\n  unsigned int i;\n  unsigned int j;\n  dwarf_vma signature;\n  size_t total;\n\n  \/* PR 17512: file: 002-168123-0.004.  *\/\n  if (phdr == NULL)\n    {\n      warn (_(\"Section %s is empty\\n\"), section->name);\n      return 0;\n    }\n  \/* PR 17512: file: 002-376-0.004.  *\/\n  if (section->size < 24)\n    {\n      warn (_(\"Section %s is too small to contain a CU\/TU header\\n\"),\n\t    section->name);\n      return 0;\n    }\n\n  phash = phdr;\n  SAFE_BYTE_GET_AND_INC (version, phash, 4, limit);\n  if (version >= 2)\n    SAFE_BYTE_GET_AND_INC (ncols, phash, 4, limit);\n  SAFE_BYTE_GET_AND_INC (nused, phash, 4, limit);\n  SAFE_BYTE_GET_AND_INC (nslots, phash, 4, limit);\n\n  pindex = phash + (size_t) nslots * 8;\n  ppool = pindex + (size_t) nslots * 4;\n\n  if (do_display)\n    {\n      introduce (section, false);\n\n      printf (_(\"  Version:                 %u\\n\"), version);\n      if (version >= 2)\n\tprintf (_(\"  Number of columns:       %u\\n\"), ncols);\n      printf (_(\"  Number of used entries:  %u\\n\"), nused);\n      printf (_(\"  Number of slots:         %u\\n\\n\"), nslots);\n    }\n\n  \/* PR 17531: file: 45d69832.  *\/\n  if (_mul_overflow ((size_t) nslots, 12, &total)\n      || total > (size_t) (limit - phash))\n    {\n      warn (ngettext (\"Section %s is too small for %u slot\\n\",\n\t\t      \"Section %s is too small for %u slots\\n\",\n\t\t      nslots),\n\t    section->name, nslots);\n      return 0;\n    }\n\n  if (version == 1)\n    {\n      if (!do_display)\n\tprealloc_cu_tu_list ((limit - ppool) \/ 4);\n      for (i = 0; i < nslots; i++)\n\t{\n\t  unsigned char *shndx_list;\n\t  unsigned int shndx;\n\n\t  SAFE_BYTE_GET (signature, phash, 8, limit);\n\t  if (signature != 0)\n\t    {\n\t      SAFE_BYTE_GET (j, pindex, 4, limit);\n\t      shndx_list = ppool + j * 4;\n\t      \/* PR 17531: file: 705e010d.  *\/\n\t      if (shndx_list < ppool)\n\t\t{\n\t\t  warn (_(\"Section index pool located before start of section\\n\"));\n\t\t  return 0;\n\t\t}\n\n\t      if (do_display)\n\t\tprintf (_(\"  [%3d] Signature:  0x%s  Sections: \"),\n\t\t\ti, dwarf_vmatoa (\"x\", signature));\n\t      for (;;)\n\t\t{\n\t\t  if (shndx_list >= limit)\n\t\t    {\n\t\t      warn (_(\"Section %s too small for shndx pool\\n\"),\n\t\t\t    section->name);\n\t\t      return 0;\n\t\t    }\n\t\t  SAFE_BYTE_GET (shndx, shndx_list, 4, limit);\n\t\t  if (shndx == 0)\n\t\t    break;\n\t\t  if (do_display)\n\t\t    printf (\" %d\", shndx);\n\t\t  else\n\t\t    add_shndx_to_cu_tu_entry (shndx);\n\t\t  shndx_list += 4;\n\t\t}\n\t      if (do_display)\n\t\tprintf (\"\\n\");\n\t      else\n\t\tend_cu_tu_entry ();\n\t    }\n\t  phash += 8;\n\t  pindex += 4;\n\t}\n    }\n  else if (version == 2)\n    {\n      unsigned int val;\n      unsigned int dw_sect;\n      unsigned char *ph = phash;\n      unsigned char *pi = pindex;\n      unsigned char *poffsets = ppool + (size_t) ncols * 4;\n      unsigned char *psizes = poffsets + (size_t) nused * ncols * 4;\n      bool is_tu_index;\n      struct cu_tu_set *this_set = NULL;\n      unsigned int row;\n      unsigned char *prow;\n      size_t temp;\n\n      is_tu_index = strcmp (section->name, \".debug_tu_index\") == 0;\n\n      \/* PR 17531: file: 0dd159bf.\n\t Check for integer overflow (can occur when size_t is 32-bit)\n\t with overlarge ncols or nused values.  *\/\n      if (nused == -1u\n\t  || _mul_overflow ((size_t) ncols, 4, &temp)\t  \n\t  || _mul_overflow ((size_t) nused + 1, temp, &total)\n\t  || total > (size_t) (limit - ppool))\n\t{\n\t  warn (_(\"Section %s too small for offset and size tables\\n\"),\n\t\tsection->name);\n\t  return 0;\n\t}\n      \n      if (do_display)\n\t{\n\t  printf (_(\"  Offset table\\n\"));\n\t  printf (\"  slot  %-16s  \",\n\t\t is_tu_index ? _(\"signature\") : _(\"dwo_id\"));\n\t}\n      else\n\t{\n\t  if (is_tu_index)\n\t    {\n\t      tu_count = nused;\n\t      tu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set));\n\t      this_set = tu_sets;\n\t    }\n\t  else\n\t    {\n\t      cu_count = nused;\n\t      cu_sets = xcalloc2 (nused, sizeof (struct cu_tu_set));\n\t      this_set = cu_sets;\n\t    }\n\t}\n\n      if (do_display)\n\t{\n\t  for (j = 0; j < ncols; j++)\n\t    {\n\t      unsigned char *p = ppool + j * 4;\n\t      SAFE_BYTE_GET (dw_sect, p, 4, limit);\n\t      printf (\" %8s\", get_DW_SECT_short_name (dw_sect));\n\t    }\n\t  printf (\"\\n\");\n\t}\n\n      for (i = 0; i < nslots; i++)\n\t{\n\t  SAFE_BYTE_GET (signature, ph, 8, limit);\n\n\t  SAFE_BYTE_GET (row, pi, 4, limit);\n\t  if (row != 0)\n\t    {\n\t      \/* PR 17531: file: a05f6ab3.  *\/\n\t      if (row > nused)\n\t\t{\n\t\t  warn (_(\"Row index (%u) is larger than number of used entries (%u)\\n\"),\n\t\t\trow, nused);\n\t\t  return 0;\n\t\t}\n\n\t      if (!do_display)\n\t\t{\n\t\t  size_t num_copy = sizeof (uint64_t);\n\n\t\t  memcpy (&this_set[row - 1].signature, ph, num_copy);\n\t\t}\n\n\t      prow = poffsets + (row - 1) * ncols * 4;\n\t      if (do_display)\n\t\tprintf (_(\"  [%3d] 0x%s\"),\n\t\t\ti, dwarf_vmatoa (\"x\", signature));\n\t      for (j = 0; j < ncols; j++)\n\t\t{\n\t\t  unsigned char *p = prow + j * 4;\n\t\t  SAFE_BYTE_GET (val, p, 4, limit);\n\t\t  if (do_display)\n\t\t    printf (\" %8d\", val);\n\t\t  else\n\t\t    {\n\t\t      p = ppool + j * 4;\n\t\t      SAFE_BYTE_GET (dw_sect, p, 4, limit);\n\n\t\t      \/* PR 17531: file: 10796eb3.  *\/\n\t\t      if (dw_sect >= DW_SECT_MAX)\n\t\t\twarn (_(\"Overlarge Dwarf section index detected: %u\\n\"), dw_sect);\n\t\t      else\n\t\t\tthis_set [row - 1].section_offsets [dw_sect] = val;\n\t\t    }\n\t\t}\n\n\t      if (do_display)\n\t\tprintf (\"\\n\");\n\t    }\n\t  ph += 8;\n\t  pi += 4;\n\t}\n\n      ph = phash;\n      pi = pindex;\n      if (do_display)\n\t{\n\t  printf (\"\\n\");\n\t  printf (_(\"  Size table\\n\"));\n\t  printf (\"  slot  %-16s  \",\n\t\t is_tu_index ? _(\"signature\") : _(\"dwo_id\"));\n\t}\n\n      for (j = 0; j < ncols; j++)\n\t{\n\t  unsigned char *p = ppool + j * 4;\n\t  SAFE_BYTE_GET (val, p, 4, limit);\n\t  if (do_display)\n\t    printf (\" %8s\", get_DW_SECT_short_name (val));\n\t}\n\n      if (do_display)\n\tprintf (\"\\n\");\n\n      for (i = 0; i < nslots; i++)\n\t{\n\t  SAFE_BYTE_GET (signature, ph, 8, limit);\n\n\t  SAFE_BYTE_GET (row, pi, 4, limit);\n\t  if (row != 0)\n\t    {\n\t      prow = psizes + (row - 1) * ncols * 4;\n\n\t      if (do_display)\n\t\tprintf (_(\"  [%3d] 0x%s\"),\n\t\t\ti, dwarf_vmatoa (\"x\", signature));\n\n\t      for (j = 0; j < ncols; j++)\n\t\t{\n\t\t  unsigned char *p = prow + j * 4;\n\n\t\t  \/* PR 28645: Check for overflow.  Since we do not know how\n\t\t     many populated rows there will be, we cannot just\n\t\t     perform a single check at the start of this function.  *\/\n\t\t  if (p > (limit - 4))\n\t\t    {\n\t\t      if (do_display)\n\t\t\tprintf (\"\\n\");\n\t\t      warn (_(\"Too many rows\/columns in DWARF index section %s\\n\"),\n\t\t\t    section->name);\n\t\t      return 0;\n\t\t    }\n\n\t\t  SAFE_BYTE_GET (val, p, 4, limit);\n\n\t\t  if (do_display)\n\t\t    printf (\" %8d\", val);\n\t\t  else\n\t\t    {\n\t\t      p = ppool + j * 4;\n\t\t      SAFE_BYTE_GET (dw_sect, p, 4, limit);\n\t\t      if (dw_sect >= DW_SECT_MAX)\n\t\t\twarn (_(\"Overlarge Dwarf section index detected: %u\\n\"), dw_sect);\n\t\t      else\n\t\t      this_set [row - 1].section_sizes [dw_sect] = val;\n\t\t    }\n\t\t}\n\n\t      if (do_display)\n\t\tprintf (\"\\n\");\n\t    }\n\n\t  ph += 8;\n\t  pi += 4;\n\t}\n    }\n  else if (do_display)\n    printf (_(\"  Unsupported version (%d)\\n\"), version);\n\n  if (do_display)\n      printf (\"\\n\");\n\n  return 1;\n}","target":0,"code_token_length":2423,"total_token_length":2659,"max_tokens_setting":4096}
+{"idx":432152,"func":"createRandomCursorExecutor(const CollectionPtr& coll,\n                           const boost::intrusive_ptr<ExpressionContext>& expCtx,\n                           long long sampleSize,\n                           long long numRecords,\n                           boost::optional<BucketUnpacker> bucketUnpacker) {\n    OperationContext* opCtx = expCtx->opCtx;\n\n    \/\/ Verify that we are already under a collection lock. We avoid taking locks ourselves in this\n    \/\/ function because double-locking forces any PlanExecutor we create to adopt a NO_YIELD policy.\n    invariant(opCtx->lockState()->isCollectionLockedForMode(coll->ns(), MODE_IS));\n\n    static const double kMaxSampleRatioForRandCursor = 0.05;\n    if (!expCtx->ns.isTimeseriesBucketsCollection()) {\n        if (sampleSize > numRecords * kMaxSampleRatioForRandCursor || numRecords <= 100) {\n            return std::pair{nullptr, false};\n        }\n    } else {\n        \/\/ Suppose that a time-series bucket collection is observed to contain 200 buckets, and the\n        \/\/ 'gTimeseriesBucketMaxCount' parameter is set to 1000. If all buckets are full, then the\n        \/\/ maximum possible measurment count would be 200 * 1000 = 200,000. While the\n        \/\/ 'SampleFromTimeseriesBucket' plan is more efficient when the sample size is small\n        \/\/ relative to the total number of measurements in the time-series collection, for larger\n        \/\/ sample sizes the top-k sort based sample is faster. Experiments have approximated that\n        \/\/ the tipping point is roughly when the requested sample size is greater than 1% of the\n        \/\/ maximum possible number of measurements in the collection (i.e. numBuckets *\n        \/\/ maxMeasurementsPerBucket).\n        static const double kCoefficient = 0.01;\n        if (sampleSize > kCoefficient * numRecords * gTimeseriesBucketMaxCount) {\n            return std::pair{nullptr, false};\n        }\n    }\n\n    \/\/ Attempt to get a random cursor from the RecordStore.\n    auto rsRandCursor = coll->getRecordStore()->getRandomCursor(opCtx);\n    if (!rsRandCursor) {\n        \/\/ The storage engine has no random cursor support.\n        return std::pair{nullptr, false};\n    }\n\n    \/\/ Build a MultiIteratorStage and pass it the random-sampling RecordCursor.\n    auto ws = std::make_unique<WorkingSet>();\n    std::unique_ptr<PlanStage> root =\n        std::make_unique<MultiIteratorStage>(expCtx.get(), ws.get(), coll);\n    static_cast<MultiIteratorStage*>(root.get())->addIterator(std::move(rsRandCursor));\n\n    TrialStage* trialStage = nullptr;\n\n    \/\/ Because 'numRecords' includes orphan documents, our initial decision to optimize the $sample\n    \/\/ cursor may have been mistaken. For sharded collections, build a TRIAL plan that will switch\n    \/\/ to a collection scan if the ratio of orphaned to owned documents encountered over the first\n    \/\/ 100 works() is such that we would have chosen not to optimize.\n    static const size_t kMaxPresampleSize = 100;\n    if (auto css = CollectionShardingState::get(opCtx, coll->ns());\n        css->getCollectionDescription(opCtx).isSharded() &&\n        !expCtx->ns.isTimeseriesBucketsCollection()) {\n        \/\/ The ratio of owned to orphaned documents must be at least equal to the ratio between the\n        \/\/ requested sampleSize and the maximum permitted sampleSize for the original constraints to\n        \/\/ be satisfied. For instance, if there are 200 documents and the sampleSize is 5, then at\n        \/\/ least (5 \/ (200*0.05)) = (5\/10) = 50% of those documents must be owned. If less than 5%\n        \/\/ of the documents in the collection are owned, we default to the backup plan.\n        const auto minAdvancedToWorkRatio = std::max(\n            sampleSize \/ (numRecords * kMaxSampleRatioForRandCursor), kMaxSampleRatioForRandCursor);\n        \/\/ Since the incoming operation is sharded, use the CSS to infer the filtering metadata for\n        \/\/ the collection. We get the shard ownership filter after checking to see if the collection\n        \/\/ is sharded to avoid an invariant from being fired in this call.\n        auto collectionFilter = css->getOwnershipFilter(\n            opCtx, CollectionShardingState::OrphanCleanupPolicy::kDisallowOrphanCleanup);\n        \/\/ The trial plan is SHARDING_FILTER-MULTI_ITERATOR.\n        auto randomCursorPlan = std::make_unique<ShardFilterStage>(\n            expCtx.get(), collectionFilter, ws.get(), std::move(root));\n        \/\/ The backup plan is SHARDING_FILTER-COLLSCAN.\n        std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>(\n            expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr);\n        collScanPlan = std::make_unique<ShardFilterStage>(\n            expCtx.get(), collectionFilter, ws.get(), std::move(collScanPlan));\n        \/\/ Place a TRIAL stage at the root of the plan tree, and pass it the trial and backup plans.\n        root = std::make_unique<TrialStage>(expCtx.get(),\n                                            ws.get(),\n                                            std::move(randomCursorPlan),\n                                            std::move(collScanPlan),\n                                            kMaxPresampleSize,\n                                            minAdvancedToWorkRatio);\n        trialStage = static_cast<TrialStage*>(root.get());\n    } else if (expCtx->ns.isTimeseriesBucketsCollection()) {\n        \/\/ We can't take ARHASH optimization path for a direct $sample on the system.buckets\n        \/\/ collection because data is in compressed form. If we did have a direct $sample on the\n        \/\/ system.buckets collection, then the 'bucketUnpacker' would not be set up properly. We\n        \/\/ also should bail out early if a $sample is made against a time series collection that is\n        \/\/ empty. If we don't the 'minAdvancedToWorkRatio' can be nan\/-nan depending on the\n        \/\/ architecture.\n        if (!(bucketUnpacker && numRecords)) {\n            return std::pair{nullptr, false};\n        }\n\n        \/\/ Use a 'TrialStage' to run a trial between 'SampleFromTimeseriesBucket' and\n        \/\/ 'UnpackTimeseriesBucket' with $sample left in the pipeline in-place. If the buckets are\n        \/\/ not sufficiently full, or the 'SampleFromTimeseriesBucket' plan draws too many\n        \/\/ duplicates, then we will fall back to the 'TrialStage' backup plan. This backup plan uses\n        \/\/ the top-k sort sampling approach.\n        \/\/\n        \/\/ Suppose the 'gTimeseriesBucketMaxCount' is 1000, but each bucket only contains 500\n        \/\/ documents on average. The observed trial advanced\/work ratio approximates the average\n        \/\/ bucket fullness, noted here as \"abf\". In this example, abf = 500 \/ 1000 = 0.5.\n        \/\/ Experiments have shown that the optimized 'SampleFromTimeseriesBucket' algorithm performs\n        \/\/ better than backup plan when\n        \/\/\n        \/\/     sampleSize < 0.02 * abf * numRecords * gTimeseriesBucketMaxCount\n        \/\/\n        \/\/  This inequality can be rewritten as\n        \/\/\n        \/\/     abf > sampleSize \/ (0.02 * numRecords * gTimeseriesBucketMaxCount)\n        \/\/\n        \/\/ Therefore, if the advanced\/work ratio exceeds this threshold, we will use the\n        \/\/ 'SampleFromTimeseriesBucket' plan. Note that as the sample size requested by the user\n        \/\/ becomes larger with respect to the number of buckets, we require a higher advanced\/work\n        \/\/ ratio in order to justify using 'SampleFromTimeseriesBucket'.\n        \/\/\n        \/\/ Additionally, we require the 'TrialStage' to approximate the abf as at least 0.25. When\n        \/\/ buckets are mostly empty, the 'SampleFromTimeseriesBucket' will be inefficient due to a\n        \/\/ lot of sampling \"misses\".\n        static const auto kCoefficient = 0.02;\n        static const auto kMinBucketFullness = 0.25;\n        const auto minAdvancedToWorkRatio = std::max(\n            std::min(sampleSize \/ (kCoefficient * numRecords * gTimeseriesBucketMaxCount), 1.0),\n            kMinBucketFullness);\n\n        auto arhashPlan = std::make_unique<SampleFromTimeseriesBucket>(\n            expCtx.get(),\n            ws.get(),\n            std::move(root),\n            *bucketUnpacker,\n            \/\/ By using a quantity slightly higher than 'kMaxPresampleSize', we ensure that the\n            \/\/ 'SampleFromTimeseriesBucket' stage won't fail due to too many consecutive sampling\n            \/\/ attempts during the 'TrialStage's trial period.\n            kMaxPresampleSize + 5,\n            sampleSize,\n            gTimeseriesBucketMaxCount);\n\n        std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>(\n            expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr);\n\n        auto topkSortPlan = std::make_unique<UnpackTimeseriesBucket>(\n            expCtx.get(), ws.get(), std::move(collScanPlan), *bucketUnpacker);\n\n        root = std::make_unique<TrialStage>(expCtx.get(),\n                                            ws.get(),\n                                            std::move(arhashPlan),\n                                            std::move(topkSortPlan),\n                                            kMaxPresampleSize,\n                                            minAdvancedToWorkRatio);\n        trialStage = static_cast<TrialStage*>(root.get());\n    }\n\n    auto execStatus = plan_executor_factory::make(expCtx,\n                                                  std::move(ws),\n                                                  std::move(root),\n                                                  &coll,\n                                                  opCtx->inMultiDocumentTransaction()\n                                                      ? PlanYieldPolicy::YieldPolicy::INTERRUPT_ONLY\n                                                      : PlanYieldPolicy::YieldPolicy::YIELD_AUTO,\n                                                  QueryPlannerParams::RETURN_OWNED_DATA);\n    if (!execStatus.isOK()) {\n        return execStatus.getStatus();\n    }\n\n    \/\/ For sharded collections, the root of the plan tree is a TrialStage that may have chosen\n    \/\/ either a random-sampling cursor trial plan or a COLLSCAN backup plan. We can only optimize\n    \/\/ the $sample aggregation stage if the trial plan was chosen.\n    return std::pair{std::move(execStatus.getValue()),\n                     !trialStage || !trialStage->pickedBackupPlan()};\n}","target":0,"code_token_length":2275,"total_token_length":2511,"max_tokens_setting":4096}
+{"idx":261407,"func":"void read_coding_unit(thread_context* tctx,\n                      int x0, int y0,  \/\/ position of coding unit in frame\n                      int log2CbSize,\n                      int ctDepth)\n{\n  de265_image* img = tctx->img;\n  const seq_parameter_set& sps = img->get_sps();\n  const pic_parameter_set& pps = img->get_pps();\n  slice_segment_header* shdr = tctx->shdr;\n\n  logtrace(LogSlice,\"- read_coding_unit %d;%d cbsize:%d\\n\",x0,y0,1<<log2CbSize);\n\n\n  \/\/QQprintf(\"- read_coding_unit %d;%d cbsize:%d\\n\",x0,y0,1<<log2CbSize);\n\n  img->set_log2CbSize(x0,y0, log2CbSize, true);\n\n  \/* This is only required on corrupted input streams.\n     It may happen that there are several slices in the image that overlap.\n     In this case, flags would accumulate from both slices.\n  *\/\n  img->clear_split_transform_flags(x0,y0, log2CbSize);\n\n  int nCbS = 1<<log2CbSize; \/\/ number of coding block samples\n\n  decode_quantization_parameters(tctx, x0,y0, x0, y0);\n\n\n  if (pps.transquant_bypass_enable_flag)\n    {\n      int transquant_bypass = decode_transquant_bypass_flag(tctx);\n\n      tctx->cu_transquant_bypass_flag = transquant_bypass;\n\n      if (transquant_bypass) {\n        img->set_cu_transquant_bypass(x0,y0,log2CbSize);\n      }\n    }\n  else {\n    tctx->cu_transquant_bypass_flag = 0;\n  }\n\n  uint8_t cu_skip_flag = 0;\n  if (shdr->slice_type != SLICE_TYPE_I) {\n    cu_skip_flag = decode_cu_skip_flag(tctx,x0,y0,ctDepth);\n  }\n\n  int IntraSplitFlag = 0;\n\n  enum PredMode cuPredMode;\n\n  if (cu_skip_flag) {\n    read_prediction_unit_SKIP(tctx,x0,y0,nCbS,nCbS);\n\n    img->set_PartMode(x0,y0, PART_2Nx2N); \/\/ need this for deblocking filter\n    img->set_pred_mode(x0,y0,log2CbSize, MODE_SKIP);\n    cuPredMode = MODE_SKIP;\n\n    logtrace(LogSlice,\"CU pred mode: SKIP\\n\");\n\n\n    \/\/ DECODE\n\n    int nCS_L = 1<<log2CbSize;\n    decode_prediction_unit(tctx->decctx,tctx->shdr,tctx->img,tctx->motion,\n                           x0,y0, 0,0, nCS_L, nCS_L,nCS_L, 0);\n  }\n  else \/* not skipped *\/ {\n    if (shdr->slice_type != SLICE_TYPE_I) {\n      int pred_mode_flag = decode_pred_mode_flag(tctx);\n      cuPredMode = pred_mode_flag ? MODE_INTRA : MODE_INTER;\n    }\n    else {\n      cuPredMode = MODE_INTRA;\n    }\n\n    img->set_pred_mode(x0,y0,log2CbSize, cuPredMode);\n\n    logtrace(LogSlice,\"CU pred mode: %s\\n\", cuPredMode==MODE_INTRA ? \"INTRA\" : \"INTER\");\n\n\n    enum PartMode PartMode;\n\n    if (cuPredMode != MODE_INTRA ||\n        log2CbSize == sps.Log2MinCbSizeY) {\n      PartMode = decode_part_mode(tctx, cuPredMode, log2CbSize);\n\n      if (PartMode==PART_NxN && cuPredMode==MODE_INTRA) {\n        IntraSplitFlag=1;\n      }\n    } else {\n      PartMode = PART_2Nx2N;\n    }\n\n    img->set_PartMode(x0,y0, PartMode); \/\/ needed for deblocking ?\n\n    logtrace(LogSlice, \"PartMode: %s\\n\", part_mode_name(PartMode));\n\n\n    bool pcm_flag = false;\n\n    if (cuPredMode == MODE_INTRA) {\n      if (PartMode == PART_2Nx2N && sps.pcm_enabled_flag &&\n          log2CbSize >= sps.Log2MinIpcmCbSizeY &&\n          log2CbSize <= sps.Log2MaxIpcmCbSizeY) {\n        pcm_flag = decode_CABAC_term_bit(&tctx->cabac_decoder);\n      }\n\n      if (pcm_flag) {\n        img->set_pcm_flag(x0,y0,log2CbSize);\n\n        read_pcm_samples(tctx, x0,y0, log2CbSize);\n      }\n      else {\n        int pbOffset = (PartMode == PART_NxN) ? (nCbS\/2) : nCbS;\n        int log2IntraPredSize = (PartMode == PART_NxN) ? (log2CbSize-1) : log2CbSize;\n\n        logtrace(LogSlice,\"nCbS:%d pbOffset:%d\\n\",nCbS,pbOffset);\n\n        int prev_intra_luma_pred_flag[4];\n\n        int idx=0;\n        for (int j=0;j<nCbS;j+=pbOffset)\n          for (int i=0;i<nCbS;i+=pbOffset)\n            {\n              prev_intra_luma_pred_flag[idx++] = decode_prev_intra_luma_pred_flag(tctx);\n            }\n\n        int mpm_idx[4], rem_intra_luma_pred_mode[4];\n        idx=0;\n\n        int availableA0 = check_CTB_available(img, x0,y0, x0-1,y0);\n        int availableB0 = check_CTB_available(img, x0,y0, x0,y0-1);\n\n        for (int j=0;j<nCbS;j+=pbOffset)\n          for (int i=0;i<nCbS;i+=pbOffset)\n            {\n              if (prev_intra_luma_pred_flag[idx]) {\n                mpm_idx[idx] = decode_mpm_idx(tctx);\n              }\n              else {\n                rem_intra_luma_pred_mode[idx] = decode_rem_intra_luma_pred_mode(tctx);\n              }\n\n\n              int x = x0+i;\n              int y = y0+j;\n\n              \/\/ --- find intra prediction mode ---\n\n              int IntraPredMode;\n\n              int availableA = availableA0 || (i>0); \/\/ left candidate always available for right blk\n              int availableB = availableB0 || (j>0); \/\/ top candidate always available for bottom blk\n\n\n\n              int PUidx = (x>>sps.Log2MinPUSize) + (y>>sps.Log2MinPUSize)*sps.PicWidthInMinPUs;\n\n              enum IntraPredMode candModeList[3];\n\n              fillIntraPredModeCandidates(candModeList,x,y,PUidx,\n                                          availableA, availableB, img);\n\n              for (int i=0;i<3;i++)\n                logtrace(LogSlice,\"candModeList[%d] = %d\\n\", i, candModeList[i]);\n\n              if (prev_intra_luma_pred_flag[idx]==1) {\n                IntraPredMode = candModeList[ mpm_idx[idx] ];\n              }\n              else {\n                \/\/ sort candModeList\n\n                if (candModeList[0] > candModeList[1]) {\n                  std::swap(candModeList[0],candModeList[1]);\n                }\n                if (candModeList[0] > candModeList[2]) {\n                  std::swap(candModeList[0],candModeList[2]);\n                }\n                if (candModeList[1] > candModeList[2]) {\n                  std::swap(candModeList[1],candModeList[2]);\n                }\n\n                \/\/ skip modes in the list\n                \/\/ (we have 35 modes. skipping the 3 in the list gives us 32, which can be selected by 5 bits)\n                IntraPredMode = rem_intra_luma_pred_mode[idx];\n                for (int n=0;n<=2;n++) {\n                  if (IntraPredMode >= candModeList[n]) { IntraPredMode++; }\n                }\n              }\n\n              logtrace(LogSlice,\"IntraPredMode[%d][%d] = %d (log2blk:%d)\\n\",x,y,IntraPredMode, log2IntraPredSize);\n\n              img->set_IntraPredMode(PUidx, log2IntraPredSize,\n                                     (enum IntraPredMode)IntraPredMode);\n\n              idx++;\n            }\n\n\n        \/\/ set chroma intra prediction mode\n\n        if (sps.ChromaArrayType == CHROMA_444) {\n          \/\/ chroma 4:4:4\n\n          idx = 0;\n          for (int j=0;j<nCbS;j+=pbOffset)\n            for (int i=0;i<nCbS;i+=pbOffset) {\n              int x = x0+i;\n              int y = y0+j;\n\n              int intra_chroma_pred_mode = decode_intra_chroma_pred_mode(tctx);\n              int IntraPredMode = img->get_IntraPredMode(x,y);\n\n              int IntraPredModeC = map_chroma_pred_mode(intra_chroma_pred_mode, IntraPredMode);\n\n              logtrace(LogSlice,\"IntraPredModeC[%d][%d]: %d (blksize:%d)\\n\",x,y,IntraPredModeC,\n                       1<<log2IntraPredSize);\n\n              img->set_IntraPredModeC(x,y, log2IntraPredSize,\n                                      (enum IntraPredMode)IntraPredModeC,\n                                      intra_chroma_pred_mode == 4);\n              idx++;\n            }\n        }\n        else if (sps.ChromaArrayType != CHROMA_MONO) {\n          \/\/ chroma 4:2:0 and 4:2:2\n\n          int intra_chroma_pred_mode = decode_intra_chroma_pred_mode(tctx);\n          int IntraPredMode = img->get_IntraPredMode(x0,y0);\n          logtrace(LogSlice,\"IntraPredMode: %d\\n\",IntraPredMode);\n          int IntraPredModeC = map_chroma_pred_mode(intra_chroma_pred_mode, IntraPredMode);\n\n          if (sps.ChromaArrayType == CHROMA_422) {\n            IntraPredModeC = map_chroma_422[ IntraPredModeC ];\n          }\n\n          img->set_IntraPredModeC(x0,y0, log2CbSize,\n                                  (enum IntraPredMode)IntraPredModeC,\n                                  intra_chroma_pred_mode == 4);\n        }\n      }\n    }\n    else { \/\/ INTER\n      int nCS = 1<<log2CbSize;\n\n      if (PartMode == PART_2Nx2N) {\n        read_prediction_unit(tctx,x0,y0,0,0,nCbS,nCbS,ctDepth,nCS,0);\n      }\n      else if (PartMode == PART_2NxN) {\n        read_prediction_unit(tctx,x0,y0,0,0     ,nCbS,nCbS\/2,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,0,nCbS\/2,nCbS,nCbS\/2,ctDepth,nCS,1);\n      }\n      else if (PartMode == PART_Nx2N) {\n        read_prediction_unit(tctx,x0,y0,0,0  ,   nCbS\/2,nCbS,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,nCbS\/2,0,nCbS\/2,nCbS,ctDepth,nCS,1);\n      }\n      else if (PartMode == PART_2NxnU) {\n        read_prediction_unit(tctx,x0,y0,0,0,     nCbS,nCbS\/4,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,0,nCbS\/4,nCbS,nCbS*3\/4,ctDepth,nCS,1);\n      }\n      else if (PartMode == PART_2NxnD) {\n        read_prediction_unit(tctx,x0,y0,0,0,       nCbS,nCbS*3\/4,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,0,nCbS*3\/4,nCbS,nCbS\/4,ctDepth,nCS,1);\n      }\n      else if (PartMode == PART_nLx2N) {\n        read_prediction_unit(tctx,x0,y0,0,0,     nCbS\/4,nCbS,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,nCbS\/4,0,nCbS*3\/4,nCbS,ctDepth,nCS,1);\n      }\n      else if (PartMode == PART_nRx2N) {\n        read_prediction_unit(tctx,x0,y0,0,0,       nCbS*3\/4,nCbS,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,nCbS*3\/4,0,nCbS\/4,nCbS,ctDepth,nCS,1);\n      }\n      else if (PartMode == PART_NxN) {\n        read_prediction_unit(tctx,x0,y0,0,0,          nCbS\/2,nCbS\/2,ctDepth,nCS,0);\n        read_prediction_unit(tctx,x0,y0,nCbS\/2,0,     nCbS\/2,nCbS\/2,ctDepth,nCS,1);\n        read_prediction_unit(tctx,x0,y0,0,nCbS\/2,     nCbS\/2,nCbS\/2,ctDepth,nCS,2);\n        read_prediction_unit(tctx,x0,y0,nCbS\/2,nCbS\/2,nCbS\/2,nCbS\/2,ctDepth,nCS,3);\n      }\n      else {\n        assert(0); \/\/ undefined PartMode\n      }\n    } \/\/ INTER\n\n\n    \/\/ decode residual\n\n    if (!pcm_flag) { \/\/ !pcm\n      bool rqt_root_cbf;\n\n      uint8_t merge_flag = tctx->motion.merge_flag; \/\/ !!get_merge_flag(ctx,x0,y0);\n\n      if (cuPredMode != MODE_INTRA &&\n          !(PartMode == PART_2Nx2N && merge_flag)) {\n\n        rqt_root_cbf = !!decode_rqt_root_cbf(tctx);\n      }\n      else {\n        \/* rqt_root_cbf=1 is inferred for Inter blocks with 2Nx2N, merge mode.\n           These must be some residual data, because otherwise, the CB could\n           also be coded in SKIP mode.\n         *\/\n\n        rqt_root_cbf = true;\n      }\n\n      \/\/set_rqt_root_cbf(ctx,x0,y0, log2CbSize, rqt_root_cbf);\n\n      if (rqt_root_cbf) {\n        int MaxTrafoDepth;\n\n        if (cuPredMode==MODE_INTRA) {\n          MaxTrafoDepth = sps.max_transform_hierarchy_depth_intra + IntraSplitFlag;\n        }\n        else {\n          MaxTrafoDepth = sps.max_transform_hierarchy_depth_inter;\n        }\n\n        logtrace(LogSlice,\"MaxTrafoDepth: %d\\n\",MaxTrafoDepth);\n\n        uint8_t initial_chroma_cbf = 1;\n        if (sps.ChromaArrayType == CHROMA_MONO) {\n          initial_chroma_cbf = 0;\n        }\n\n        read_transform_tree(tctx, x0,y0, x0,y0, x0,y0, log2CbSize, 0,0,\n                            MaxTrafoDepth, IntraSplitFlag, cuPredMode,\n                            initial_chroma_cbf, initial_chroma_cbf);\n      }\n    } \/\/ !pcm\n  }\n}","target":0,"code_token_length":3431,"total_token_length":3667,"max_tokens_setting":4096}
+{"idx":210206,"func":"gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)\n{\n    char *pos = inbuf;\n    char *lpos = NULL;\n    char *tline = NULL;\n    LOCAL_ARRAY(char, line, TEMP_BUF_SIZE);\n    LOCAL_ARRAY(char, tmpbuf, TEMP_BUF_SIZE);\n    char *name = NULL;\n    char *selector = NULL;\n    char *host = NULL;\n    char *port = NULL;\n    char *escaped_selector = NULL;\n    const char *icon_url = NULL;\n    char gtype;\n    StoreEntry *entry = NULL;\n\n    memset(tmpbuf, '\\0', TEMP_BUF_SIZE);\n    memset(line, '\\0', TEMP_BUF_SIZE);\n\n    entry = gopherState->entry;\n\n    if (gopherState->conversion == GopherStateData::HTML_INDEX_PAGE) {\n        char *html_url = html_quote(entry->url());\n        gopherHTMLHeader(entry, \"Gopher Index %s\", html_url);\n        storeAppendPrintf(entry,\n                          \"<p>This is a searchable Gopher index. Use the search\\n\"\n                          \"function of your browser to enter search terms.\\n\"\n                          \"<ISINDEX>\\n\");\n        gopherHTMLFooter(entry);\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n        gopherState->HTML_header_added = 1;\n\n        return;\n    }\n\n    if (gopherState->conversion == GopherStateData::HTML_CSO_PAGE) {\n        char *html_url = html_quote(entry->url());\n        gopherHTMLHeader(entry, \"CSO Search of %s\", html_url);\n        storeAppendPrintf(entry,\n                          \"<P>A CSO database usually contains a phonebook or\\n\"\n                          \"directory.  Use the search function of your browser to enter\\n\"\n                          \"search terms.<\/P><ISINDEX>\\n\");\n        gopherHTMLFooter(entry);\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n        gopherState->HTML_header_added = 1;\n\n        return;\n    }\n\n    String outbuf;\n\n    if (!gopherState->HTML_header_added) {\n        if (gopherState->conversion == GopherStateData::HTML_CSO_RESULT)\n            gopherHTMLHeader(entry, \"CSO Search Result\", NULL);\n        else\n            gopherHTMLHeader(entry, \"Gopher Menu\", NULL);\n\n        outbuf.append (\"<PRE>\");\n\n        gopherState->HTML_header_added = 1;\n\n        gopherState->HTML_pre = 1;\n    }\n\n    while (pos < inbuf + len) {\n        int llen;\n        int left = len - (pos - inbuf);\n        lpos = (char *)memchr(pos, '\\n', left);\n        if (lpos) {\n            ++lpos;             \/* Next line is after \\n *\/\n            llen = lpos - pos;\n        } else {\n            llen = left;\n        }\n        if (gopherState->len + llen >= TEMP_BUF_SIZE) {\n            debugs(10, DBG_IMPORTANT, \"GopherHTML: Buffer overflow. Lost some data on URL: \" << entry->url()  );\n            llen = TEMP_BUF_SIZE - gopherState->len - 1;\n        }\n        if (!lpos) {\n            \/* there is no complete line in inbuf *\/\n            \/* copy it to temp buffer *\/\n            \/* note: llen is adjusted above *\/\n            memcpy(gopherState->buf + gopherState->len, pos, llen);\n            gopherState->len += llen;\n            break;\n        }\n        if (gopherState->len != 0) {\n            \/* there is something left from last tx. *\/\n            memcpy(line, gopherState->buf, gopherState->len);\n            memcpy(line + gopherState->len, pos, llen);\n            llen += gopherState->len;\n            gopherState->len = 0;\n        } else {\n            memcpy(line, pos, llen);\n        }\n        line[llen + 1] = '\\0';\n        \/* move input to next line *\/\n        pos = lpos;\n\n        \/* at this point. We should have one line in buffer to process *\/\n\n        if (*line == '.') {\n            \/* skip it *\/\n            memset(line, '\\0', TEMP_BUF_SIZE);\n            continue;\n        }\n\n        switch (gopherState->conversion) {\n\n        case GopherStateData::HTML_INDEX_RESULT:\n\n        case GopherStateData::HTML_DIR: {\n            tline = line;\n            gtype = *tline;\n            ++tline;\n            name = tline;\n            selector = strchr(tline, TAB);\n\n            if (selector) {\n                *selector = '\\0';\n                ++selector;\n                host = strchr(selector, TAB);\n\n                if (host) {\n                    *host = '\\0';\n                    ++host;\n                    port = strchr(host, TAB);\n\n                    if (port) {\n                        char *junk;\n                        port[0] = ':';\n                        junk = strchr(host, TAB);\n\n                        if (junk)\n                            *junk++ = 0;    \/* Chop port *\/\n                        else {\n                            junk = strchr(host, '\\r');\n\n                            if (junk)\n                                *junk++ = 0;    \/* Chop port *\/\n                            else {\n                                junk = strchr(host, '\\n');\n\n                                if (junk)\n                                    *junk++ = 0;    \/* Chop port *\/\n                            }\n                        }\n\n                        if ((port[1] == '0') && (!port[2]))\n                            port[0] = 0;    \/* 0 means none *\/\n                    }\n\n                    \/* escape a selector here *\/\n                    escaped_selector = xstrdup(rfc1738_escape_part(selector));\n\n                    switch (gtype) {\n\n                    case GOPHER_DIRECTORY:\n                        icon_url = mimeGetIconURL(\"internal-menu\");\n                        break;\n\n                    case GOPHER_HTML:\n\n                    case GOPHER_FILE:\n                        icon_url = mimeGetIconURL(\"internal-text\");\n                        break;\n\n                    case GOPHER_INDEX:\n\n                    case GOPHER_CSO:\n                        icon_url = mimeGetIconURL(\"internal-index\");\n                        break;\n\n                    case GOPHER_IMAGE:\n\n                    case GOPHER_GIF:\n\n                    case GOPHER_PLUS_IMAGE:\n                        icon_url = mimeGetIconURL(\"internal-image\");\n                        break;\n\n                    case GOPHER_SOUND:\n\n                    case GOPHER_PLUS_SOUND:\n                        icon_url = mimeGetIconURL(\"internal-sound\");\n                        break;\n\n                    case GOPHER_PLUS_MOVIE:\n                        icon_url = mimeGetIconURL(\"internal-movie\");\n                        break;\n\n                    case GOPHER_TELNET:\n\n                    case GOPHER_3270:\n                        icon_url = mimeGetIconURL(\"internal-telnet\");\n                        break;\n\n                    case GOPHER_BIN:\n\n                    case GOPHER_MACBINHEX:\n\n                    case GOPHER_DOSBIN:\n\n                    case GOPHER_UUENCODED:\n                        icon_url = mimeGetIconURL(\"internal-binary\");\n                        break;\n\n                    case GOPHER_INFO:\n                        icon_url = NULL;\n                        break;\n\n                    default:\n                        icon_url = mimeGetIconURL(\"internal-unknown\");\n                        break;\n                    }\n\n                    memset(tmpbuf, '\\0', TEMP_BUF_SIZE);\n\n                    if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {\n                        if (strlen(escaped_selector) != 0)\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"telnet:\/\/%s@%s%s%s\/\\\">%s<\/A>\\n\",\n                                     icon_url, escaped_selector, rfc1738_escape_part(host),\n                                     *port ? \":\" : \"\", port, html_quote(name));\n                        else\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"telnet:\/\/%s%s%s\/\\\">%s<\/A>\\n\",\n                                     icon_url, rfc1738_escape_part(host), *port ? \":\" : \"\",\n                                     port, html_quote(name));\n\n                    } else if (gtype == GOPHER_INFO) {\n                        snprintf(tmpbuf, TEMP_BUF_SIZE, \"\\t%s\\n\", html_quote(name));\n                    } else {\n                        if (strncmp(selector, \"GET \/\", 5) == 0) {\n                            \/* WWW link *\/\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"http:\/\/%s\/%s\\\">%s<\/A>\\n\",\n                                     icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name));\n                        } else {\n                            \/* Standard link *\/\n                            snprintf(tmpbuf, TEMP_BUF_SIZE, \"<IMG border=\\\"0\\\" SRC=\\\"%s\\\"> <A HREF=\\\"gopher:\/\/%s\/%c%s\\\">%s<\/A>\\n\",\n                                     icon_url, host, gtype, escaped_selector, html_quote(name));\n                        }\n                    }\n\n                    safe_free(escaped_selector);\n                    outbuf.append(tmpbuf);\n                } else {\n                    memset(line, '\\0', TEMP_BUF_SIZE);\n                    continue;\n                }\n            } else {\n                memset(line, '\\0', TEMP_BUF_SIZE);\n                continue;\n            }\n\n            break;\n            }           \/* HTML_DIR, HTML_INDEX_RESULT *\/\n\n        case GopherStateData::HTML_CSO_RESULT: {\n            if (line[0] == '-') {\n                int code, recno;\n                char *s_code, *s_recno, *result;\n\n                s_code = strtok(line + 1, \":\\n\");\n                s_recno = strtok(NULL, \":\\n\");\n                result = strtok(NULL, \"\\n\");\n\n                if (!result)\n                    break;\n\n                code = atoi(s_code);\n\n                recno = atoi(s_recno);\n\n                if (code != 200)\n                    break;\n\n                if (gopherState->cso_recno != recno) {\n                    snprintf(tmpbuf, TEMP_BUF_SIZE, \"<\/PRE><HR noshade size=\\\"1px\\\"><H2>Record# %d<br><i>%s<\/i><\/H2>\\n<PRE>\", recno, html_quote(result));\n                    gopherState->cso_recno = recno;\n                } else {\n                    snprintf(tmpbuf, TEMP_BUF_SIZE, \"%s\\n\", html_quote(result));\n                }\n\n                outbuf.append(tmpbuf);\n                break;\n            } else {\n                int code;\n                char *s_code, *result;\n\n                s_code = strtok(line, \":\");\n                result = strtok(NULL, \"\\n\");\n\n                if (!result)\n                    break;\n\n                code = atoi(s_code);\n\n                switch (code) {\n\n                case 200: {\n                    \/* OK *\/\n                    \/* Do nothing here *\/\n                    break;\n                }\n\n                case 102:   \/* Number of matches *\/\n\n                case 501:   \/* No Match *\/\n\n                case 502: { \/* Too Many Matches *\/\n                    \/* Print the message the server returns *\/\n                    snprintf(tmpbuf, TEMP_BUF_SIZE, \"<\/PRE><HR noshade size=\\\"1px\\\"><H2>%s<\/H2>\\n<PRE>\", html_quote(result));\n                    outbuf.append(tmpbuf);\n                    break;\n                }\n\n                }\n            }\n\n            }           \/* HTML_CSO_RESULT *\/\n\n        default:\n            break;      \/* do nothing *\/\n\n        }           \/* switch *\/\n\n    }               \/* while loop *\/\n\n    if (outbuf.size() > 0) {\n        entry->append(outbuf.rawBuf(), outbuf.size());\n        \/* now let start sending stuff to client *\/\n        entry->flush();\n    }\n\n    outbuf.clean();\n    return;\n}","target":1,"code_token_length":2418,"total_token_length":2654,"max_tokens_setting":4096}
+{"idx":202748,"func":"static Image *ReadTGAImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  PixelInfo\n    pixel;\n\n  Quantum\n    index;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  size_t\n    base,\n    flag,\n    offset,\n    real,\n    skip;\n\n  ssize_t\n    count,\n    y;\n\n  TGAInfo\n    tga_info;\n\n  unsigned char\n    j,\n    k,\n    pixels[4],\n    runlength;\n\n  unsigned int\n    alpha_bits;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read TGA header information.\n  *\/\n  count=ReadBlob(image,1,&tga_info.id_length);\n  tga_info.colormap_type=(unsigned char) ReadBlobByte(image);\n  tga_info.image_type=(TGAImageType) ReadBlobByte(image);\n  if ((count != 1) ||\n      ((tga_info.image_type != TGAColormap) &&\n       (tga_info.image_type != TGARGB) &&\n       (tga_info.image_type != TGAMonochrome) &&\n       (tga_info.image_type != TGARLEColormap) &&\n       (tga_info.image_type != TGARLERGB) &&\n       (tga_info.image_type != TGARLEMonochrome)) ||\n      (((tga_info.image_type == TGAColormap) ||\n       (tga_info.image_type == TGARLEColormap)) &&\n       (tga_info.colormap_type == 0)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  tga_info.colormap_index=ReadBlobLSBShort(image);\n  tga_info.colormap_length=ReadBlobLSBShort(image);\n  tga_info.colormap_size=(unsigned char) ReadBlobByte(image);\n  tga_info.x_origin=ReadBlobLSBShort(image);\n  tga_info.y_origin=ReadBlobLSBShort(image);\n  tga_info.width=(unsigned short) ReadBlobLSBShort(image);\n  tga_info.height=(unsigned short) ReadBlobLSBShort(image);\n  tga_info.bits_per_pixel=(unsigned char) ReadBlobByte(image);\n  tga_info.attributes=(unsigned char) ReadBlobByte(image);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n  if ((((tga_info.bits_per_pixel <= 1) || (tga_info.bits_per_pixel >= 17)) &&\n       (tga_info.bits_per_pixel != 24) && (tga_info.bits_per_pixel != 32)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  \/*\n    Initialize image structure.\n  *\/\n  image->columns=tga_info.width;\n  image->rows=tga_info.height;\n  alpha_bits=(tga_info.attributes & 0x0FU);\n  image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) ||\n    (tga_info.colormap_size == 32) ?  BlendPixelTrait : UndefinedPixelTrait;\n  if ((tga_info.image_type != TGAColormap) &&\n      (tga_info.image_type != TGARLEColormap))\n    image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 :\n      (tga_info.bits_per_pixel <= 16) ? 5 : 8);\n  else\n    image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 :\n      (tga_info.colormap_size <= 16) ? 5 : 8);\n  if ((tga_info.image_type == TGAColormap) ||\n      (tga_info.image_type == TGAMonochrome) ||\n      (tga_info.image_type == TGARLEColormap) ||\n      (tga_info.image_type == TGARLEMonochrome))\n    image->storage_class=PseudoClass;\n  image->compression=NoCompression;\n  if ((tga_info.image_type == TGARLEColormap) ||\n      (tga_info.image_type == TGARLEMonochrome) ||\n      (tga_info.image_type == TGARLERGB))\n    image->compression=RLECompression;\n  if (image->storage_class == PseudoClass)\n    {\n      if (tga_info.colormap_type != 0)\n        image->colors=tga_info.colormap_index+tga_info.colormap_length;\n      else\n        {\n          size_t\n            one;\n\n          one=1;\n          image->colors=one << tga_info.bits_per_pixel;\n          if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n    }\n  if (tga_info.id_length != 0)\n    {\n      char\n        *comment;\n\n      size_t\n        length;\n\n      \/*\n        TGA image comment.\n      *\/\n      length=(size_t) tga_info.id_length;\n      comment=(char *) NULL;\n      if (~length >= (MagickPathExtent-1))\n        comment=(char *) AcquireQuantumMemory(length+MagickPathExtent,\n          sizeof(*comment));\n      if (comment == (char *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      count=ReadBlob(image,tga_info.id_length,(unsigned char *) comment);\n      comment[tga_info.id_length]='\\0';\n      (void) SetImageProperty(image,\"comment\",comment,exception);\n      comment=DestroyString(comment);\n    }\n  if (tga_info.attributes & (1UL << 4))\n    {\n      if (tga_info.attributes & (1UL << 5))\n        SetImageArtifact(image,\"tga:image-origin\",\"TopRight\");\n      else\n        SetImageArtifact(image,\"tga:image-origin\",\"BottomRight\");\n    }\n  else\n    {\n      if (tga_info.attributes & (1UL << 5))\n        SetImageArtifact(image,\"tga:image-origin\",\"TopLeft\");\n      else\n        SetImageArtifact(image,\"tga:image-origin\",\"BottomLeft\");\n    }\n  if (image_info->ping != MagickFalse)\n    {\n      (void) CloseBlob(image);\n      return(image);\n    }\n  status=SetImageExtent(image,image->columns,image->rows,exception);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  (void) ResetMagickMemory(&pixel,0,sizeof(pixel));\n  pixel.alpha=(MagickRealType) OpaqueAlpha;\n  if (tga_info.colormap_type != 0)\n    {\n      \/*\n        Read TGA raster colormap.\n      *\/\n      if (image->colors < tga_info.colormap_index)\n        image->colors=tga_info.colormap_index;\n      if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      for (i=0; i < (ssize_t) tga_info.colormap_index; i++)\n        image->colormap[i]=pixel;\n      for ( ; i < (ssize_t) image->colors; i++)\n      {\n        switch (tga_info.colormap_size)\n        {\n          case 8:\n          default:\n          {\n            \/*\n              Gray scale.\n            *\/\n            pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.green=pixel.red;\n            pixel.blue=pixel.red;\n            break;\n          }\n          case 15:\n          case 16:\n          {\n            QuantumAny\n              range;\n\n            \/*\n              5 bits each of red green and blue.\n            *\/\n            j=(unsigned char) ReadBlobByte(image);\n            k=(unsigned char) ReadBlobByte(image);\n            range=GetQuantumRange(5UL);\n            pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,\n              range);\n            pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*(k & 0x03)\n              << 3)+(1UL*(j & 0xe0) >> 5),range);\n            pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);\n            break;\n          }\n          case 24:\n          {\n            \/*\n              8 bits each of blue, green and red.\n            *\/\n            pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            break;\n          }\n          case 32:\n          {\n            \/*\n              8 bits each of blue, green, red, and alpha.\n            *\/\n            pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.alpha=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            break;\n          }\n        }\n        image->colormap[i]=pixel;\n      }\n    }\n  \/*\n    Convert TGA pixels to pixel packets.\n  *\/\n  base=0;\n  flag=0;\n  skip=MagickFalse;\n  real=0;\n  index=0;\n  runlength=0;\n  offset=0;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    real=offset;\n    if (((unsigned char) (tga_info.attributes & 0x20) >> 5) == 0)\n      real=image->rows-real-1;\n    q=QueueAuthenticPixels(image,0,(ssize_t) real,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      break;\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      if ((tga_info.image_type == TGARLEColormap) ||\n          (tga_info.image_type == TGARLERGB) ||\n          (tga_info.image_type == TGARLEMonochrome))\n        {\n          if (runlength != 0)\n            {\n              runlength--;\n              skip=flag != 0;\n            }\n          else\n            {\n              count=ReadBlob(image,1,&runlength);\n              if (count != 1)\n                ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n              flag=runlength & 0x80;\n              if (flag != 0)\n                runlength-=128;\n              skip=MagickFalse;\n            }\n        }\n      if (skip == MagickFalse)\n        switch (tga_info.bits_per_pixel)\n        {\n          case 8:\n          default:\n          {\n            \/*\n              Gray scale.\n            *\/\n            index=(Quantum) ReadBlobByte(image);\n            if (tga_info.colormap_type != 0)\n              pixel=image->colormap[(ssize_t) ConstrainColormapIndex(image,\n                (ssize_t) index,exception)];\n            else\n              {\n                pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n                  index);\n                pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)\n                  index);\n                pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)\n                  index);\n              }\n            break;\n          }\n          case 15:\n          case 16:\n          {\n            QuantumAny\n              range;\n\n            \/*\n              5 bits each of RGB.\n            *\/\n            if (ReadBlob(image,2,pixels) != 2)\n              ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n            j=pixels[0];\n            k=pixels[1];\n            range=GetQuantumRange(5UL);\n            pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,\n              range);\n            pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*\n              (k & 0x03) << 3)+(1UL*(j & 0xe0) >> 5),range);\n            pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);\n            if (image->alpha_trait != UndefinedPixelTrait)\n              pixel.alpha=(MagickRealType) ((k & 0x80) == 0 ? (Quantum)\n                TransparentAlpha : (Quantum) OpaqueAlpha);\n            if (image->storage_class == PseudoClass)\n              index=(Quantum) ConstrainColormapIndex(image,((ssize_t) (k << 8))+\n                j,exception);\n            break;\n          }\n          case 24:\n          {\n            \/*\n              BGR pixels.\n            *\/\n            if (ReadBlob(image,3,pixels) != 3)\n              ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n            pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);\n            pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);\n            pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);\n            break;\n          }\n          case 32:\n          {\n            \/*\n              BGRA pixels.\n            *\/\n            if (ReadBlob(image,4,pixels) != 4)\n              ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n            pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);\n            pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);\n            pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);\n            pixel.alpha=(MagickRealType) ScaleCharToQuantum(pixels[3]);\n            break;\n          }\n        }\n      if (status == MagickFalse)\n        ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n      if (image->storage_class == PseudoClass)\n        SetPixelIndex(image,index,q);\n      SetPixelRed(image,ClampToQuantum(pixel.red),q);\n      SetPixelGreen(image,ClampToQuantum(pixel.green),q);\n      SetPixelBlue(image,ClampToQuantum(pixel.blue),q);\n      if (image->alpha_trait != UndefinedPixelTrait)\n        SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);\n      q+=GetPixelChannels(image);\n    }\n    \/*\n      if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 4)\n        offset+=4;\n      else\n    *\/\n      if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 2)\n        offset+=2;\n      else\n        offset++;\n    if (offset >= image->rows)\n      {\n        base++;\n        offset=base;\n      }\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n    if (image->previous == (Image *) NULL)\n      {\n        status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n          image->rows);\n        if (status == MagickFalse)\n          break;\n      }\n  }\n  if (EOFBlob(image) != MagickFalse)\n    ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":3522,"total_token_length":3758,"max_tokens_setting":4096}
+{"idx":335417,"func":"parse_command_modifiers(\n\texarg_T\t    *eap,\n\tchar\t    **errormsg,\n\tcmdmod_T    *cmod,\n\tint\t    skip_only)\n{\n    char_u  *orig_cmd = eap->cmd;\n    char_u  *cmd_start = NULL;\n    int\t    did_plus_cmd = FALSE;\n    char_u  *p;\n    int\t    starts_with_colon = FALSE;\n    int\t    vim9script = in_vim9script();\n    int\t    has_visual_range = FALSE;\n\n    CLEAR_POINTER(cmod);\n    cmod->cmod_flags = sticky_cmdmod_flags;\n\n    if (STRNCMP(eap->cmd, \"'<,'>\", 5) == 0)\n    {\n\t\/\/ The automatically inserted Visual area range is skipped, so that\n\t\/\/ typing \":cmdmod cmd\" in Visual mode works without having to move the\n\t\/\/ range to after the modififiers.\n\teap->cmd += 5;\n\tcmd_start = eap->cmd;\n\thas_visual_range = TRUE;\n    }\n\n    \/\/ Repeat until no more command modifiers are found.\n    for (;;)\n    {\n\twhile (*eap->cmd == ' ' || *eap->cmd == '\\t' || *eap->cmd == ':')\n\t{\n\t    if (*eap->cmd == ':')\n\t\tstarts_with_colon = TRUE;\n\t    ++eap->cmd;\n\t}\n\n\t\/\/ in ex mode, an empty line works like :+\n\tif (*eap->cmd == NUL && exmode_active\n\t\t   && (getline_equal(eap->getline, eap->cookie, getexmodeline)\n\t\t       || getline_equal(eap->getline, eap->cookie, getexline))\n\t\t\t&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)\n\t{\n\t    eap->cmd = (char_u *)\"+\";\n\t    did_plus_cmd = TRUE;\n\t    if (!skip_only)\n\t\tex_pressedreturn = TRUE;\n\t}\n\n\t\/\/ ignore comment and empty lines\n\tif (comment_start(eap->cmd, starts_with_colon))\n\t{\n\t    \/\/ a comment ends at a NL\n\t    if (eap->nextcmd == NULL)\n\t    {\n\t\teap->nextcmd = vim_strchr(eap->cmd, '\\n');\n\t\tif (eap->nextcmd != NULL)\n\t\t    ++eap->nextcmd;\n\t    }\n\t    if (vim9script && has_cmdmod(cmod, FALSE))\n\t\t*errormsg = _(e_command_modifier_without_command);\n\t    return FAIL;\n\t}\n\tif (*eap->cmd == NUL)\n\t{\n\t    if (!skip_only)\n\t    {\n\t\tex_pressedreturn = TRUE;\n\t\tif (vim9script && has_cmdmod(cmod, FALSE))\n\t\t    *errormsg = _(e_command_modifier_without_command);\n\t    }\n\t    return FAIL;\n\t}\n\n\tp = skip_range(eap->cmd, TRUE, NULL);\n\n\t\/\/ In Vim9 script a variable can shadow a command modifier:\n\t\/\/   verbose = 123\n\t\/\/   verbose += 123\n\t\/\/   silent! verbose = func()\n\t\/\/   verbose.member = 2\n\t\/\/   verbose[expr] = 2\n\t\/\/ But not:\n\t\/\/   verbose [a, b] = list\n\tif (vim9script)\n\t{\n\t    char_u *s, *n;\n\n\t    for (s = eap->cmd; ASCII_ISALPHA(*s); ++s)\n\t\t;\n\t    n = skipwhite(s);\n\t    if (*n == '.' || *n == '=' || (*n != NUL && n[1] == '=')\n\t\t    || *s == '[')\n\t\tbreak;\n\t}\n\n\tswitch (*p)\n\t{\n\t    \/\/ When adding an entry, also modify cmd_exists().\n\t    case 'a':\tif (!checkforcmd_noparen(&eap->cmd, \"aboveleft\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_ABOVE;\n\t\t\tcontinue;\n\n\t    case 'b':\tif (checkforcmd_noparen(&eap->cmd, \"belowright\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_split |= WSP_BELOW;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_opt(&eap->cmd, \"browse\", 3, TRUE))\n\t\t\t{\n#ifdef FEAT_BROWSE_CMD\n\t\t\t    cmod->cmod_flags |= CMOD_BROWSE;\n#endif\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"botright\", 2))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_BOT;\n\t\t\tcontinue;\n\n\t    case 'c':\tif (!checkforcmd_opt(&eap->cmd, \"confirm\", 4, TRUE))\n\t\t\t    break;\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\t\t\tcmod->cmod_flags |= CMOD_CONFIRM;\n#endif\n\t\t\tcontinue;\n\n\t    case 'k':\tif (checkforcmd_noparen(&eap->cmd, \"keepmarks\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPMARKS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"keepalt\", 5))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPALT;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"keeppatterns\", 5))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_KEEPPATTERNS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"keepjumps\", 5))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_KEEPJUMPS;\n\t\t\tcontinue;\n\n\t    case 'f':\t\/\/ only accept \":filter {pat} cmd\"\n\t\t\t{\n\t\t\t    char_u  *reg_pat;\n\t\t\t    char_u  *nulp = NULL;\n\t\t\t    int\t    c = 0;\n\n\t\t\t    if (!checkforcmd_noparen(&p, \"filter\", 4)\n\t\t\t\t    || *p == NUL\n\t\t\t\t    || (ends_excmd(*p)\n#ifdef FEAT_EVAL\n\t\t\t\t\t\/\/ in \":filter #pat# cmd\" # does not\n\t\t\t\t\t\/\/ start a comment\n\t\t\t\t     && (!vim9script || VIM_ISWHITE(p[1]))\n#endif\n\t\t\t\t     ))\n\t\t\t\tbreak;\n\t\t\t    if (*p == '!')\n\t\t\t    {\n\t\t\t\tcmod->cmod_filter_force = TRUE;\n\t\t\t\tp = skipwhite(p + 1);\n\t\t\t\tif (*p == NUL || ends_excmd(*p))\n\t\t\t\t    break;\n\t\t\t    }\n#ifdef FEAT_EVAL\n\t\t\t    \/\/ Avoid that \"filter(arg)\" is recognized.\n\t\t\t    if (vim9script && !VIM_ISWHITE(p[-1]))\n\t\t\t\tbreak;\n#endif\n\t\t\t    if (skip_only)\n\t\t\t\tp = skip_vimgrep_pat(p, NULL, NULL);\n\t\t\t    else\n\t\t\t\t\/\/ NOTE: This puts a NUL after the pattern.\n\t\t\t\tp = skip_vimgrep_pat_ext(p, ®_pat, NULL,\n\t\t\t\t\t\t\t\t    &nulp, &c);\n\t\t\t    if (p == NULL || *p == NUL)\n\t\t\t\tbreak;\n\t\t\t    if (!skip_only)\n\t\t\t    {\n\t\t\t\tcmod->cmod_filter_regmatch.regprog =\n\t\t\t\t\t\tvim_regcomp(reg_pat, RE_MAGIC);\n\t\t\t\tif (cmod->cmod_filter_regmatch.regprog == NULL)\n\t\t\t\t    break;\n\t\t\t\t\/\/ restore the character overwritten by NUL\n\t\t\t\tif (nulp != NULL)\n\t\t\t\t    *nulp = c;\n\t\t\t    }\n\t\t\t    eap->cmd = p;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\t\/\/ \":hide\" and \":hide | cmd\" are not modifiers\n\t    case 'h':\tif (p != eap->cmd || !checkforcmd_noparen(&p, \"hide\", 3)\n\t\t\t\t\t       || *p == NUL || ends_excmd(*p))\n\t\t\t    break;\n\t\t\teap->cmd = p;\n\t\t\tcmod->cmod_flags |= CMOD_HIDE;\n\t\t\tcontinue;\n\n\t    case 'l':\tif (checkforcmd_noparen(&eap->cmd, \"lockmarks\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_LOCKMARKS;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"legacy\", 3))\n\t\t\t{\n\t\t\t    if (ends_excmd2(p, eap->cmd))\n\t\t\t    {\n\t\t\t\t*errormsg =\n\t\t\t\t      _(e_legacy_must_be_followed_by_command);\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    cmod->cmod_flags |= CMOD_LEGACY;\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"leftabove\", 5))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_ABOVE;\n\t\t\tcontinue;\n\n\t    case 'n':\tif (checkforcmd_noparen(&eap->cmd, \"noautocmd\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_NOAUTOCMD;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"noswapfile\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_NOSWAPFILE;\n\t\t\tcontinue;\n\n\t    case 'r':\tif (!checkforcmd_noparen(&eap->cmd, \"rightbelow\", 6))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_BELOW;\n\t\t\tcontinue;\n\n\t    case 's':\tif (checkforcmd_noparen(&eap->cmd, \"sandbox\", 3))\n\t\t\t{\n\t\t\t    cmod->cmod_flags |= CMOD_SANDBOX;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"silent\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_SILENT;\n\t\t\tif (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1]))\n\t\t\t{\n\t\t\t    \/\/ \":silent!\", but not \"silent !cmd\"\n\t\t\t    eap->cmd = skipwhite(eap->cmd + 1);\n\t\t\t    cmod->cmod_flags |= CMOD_ERRSILENT;\n\t\t\t}\n\t\t\tcontinue;\n\n\t    case 't':\tif (checkforcmd_noparen(&p, \"tab\", 3))\n\t\t\t{\n\t\t\t    if (!skip_only)\n\t\t\t    {\n\t\t\t\tlong tabnr = get_address(eap, &eap->cmd,\n\t\t\t\t\t\t    ADDR_TABS, eap->skip,\n\t\t\t\t\t\t    skip_only, FALSE, 1);\n\t\t\t\tif (tabnr == MAXLNUM)\n\t\t\t\t    cmod->cmod_tab = tabpage_index(curtab) + 1;\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    if (tabnr < 0 || tabnr > LAST_TAB_NR)\n\t\t\t\t    {\n\t\t\t\t\t*errormsg = _(e_invalid_range);\n\t\t\t\t\treturn FAIL;\n\t\t\t\t    }\n\t\t\t\t    cmod->cmod_tab = tabnr + 1;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    eap->cmd = p;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&eap->cmd, \"topleft\", 2))\n\t\t\t    break;\n\t\t\tcmod->cmod_split |= WSP_TOP;\n\t\t\tcontinue;\n\n\t    case 'u':\tif (!checkforcmd_noparen(&eap->cmd, \"unsilent\", 3))\n\t\t\t    break;\n\t\t\tcmod->cmod_flags |= CMOD_UNSILENT;\n\t\t\tcontinue;\n\n\t    case 'v':\tif (checkforcmd_noparen(&eap->cmd, \"vertical\", 4))\n\t\t\t{\n\t\t\t    cmod->cmod_split |= WSP_VERT;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (checkforcmd_noparen(&eap->cmd, \"vim9cmd\", 4))\n\t\t\t{\n\t\t\t    if (ends_excmd2(p, eap->cmd))\n\t\t\t    {\n\t\t\t\t*errormsg =\n\t\t\t\t      _(e_vim9cmd_must_be_followed_by_command);\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    cmod->cmod_flags |= CMOD_VIM9CMD;\n\t\t\t    continue;\n\t\t\t}\n\t\t\tif (!checkforcmd_noparen(&p, \"verbose\", 4))\n\t\t\t    break;\n\t\t\tif (vim_isdigit(*eap->cmd))\n\t\t\t{\n\t\t\t    cmod->cmod_verbose = atoi((char *)eap->cmd);\n\t\t\t    if (cmod->cmod_verbose == 0)\n\t\t\t\tcmod->cmod_verbose = -1;\n\t\t\t}\n\t\t\telse\n\t\t\t    cmod->cmod_verbose = 1;\n\t\t\teap->cmd = p;\n\t\t\tcontinue;\n\t}\n\tbreak;\n    }\n\n    if (has_visual_range)\n    {\n\tif (eap->cmd > cmd_start)\n\t{\n\t    \/\/ Move the '<,'> range to after the modifiers and insert a colon.\n\t    \/\/ Since the modifiers have been parsed put the colon on top of the\n\t    \/\/ space: \"'<,'>mod cmd\" -> \"mod:'<,'>cmd\n\t    \/\/ Put eap->cmd after the colon.\n\t    if (did_plus_cmd)\n\t    {\n\t\tsize_t len = STRLEN(cmd_start);\n\n\t\t\/\/ Special case: empty command may have been changed to \"+\":\n\t\t\/\/  \"'<,'>mod\" -> \"mod'<,'>+\n\t\tmch_memmove(orig_cmd, cmd_start, len);\n\t\tSTRCPY(orig_cmd + len, \"'<,'>+\");\n\t    }\n\t    else\n\t    {\n\t\tmch_memmove(cmd_start - 5, cmd_start, eap->cmd - cmd_start);\n\t\teap->cmd -= 5;\n\t\tmch_memmove(eap->cmd - 1, \":'<,'>\", 6);\n\t    }\n\t}\n\telse\n\t    \/\/ No modifiers, move the pointer back.\n\t    \/\/ Special case: empty command may have been changed to \"+\".\n\t    if (did_plus_cmd)\n\t\teap->cmd = (char_u *)\"'<,'>+\";\n\t    else\n\t\teap->cmd = orig_cmd;\n    }\n\n    return OK;\n}","target":0,"code_token_length":2971,"total_token_length":3207,"max_tokens_setting":4096}
+{"idx":452376,"func":"ex_retab(exarg_T *eap)\n{\n    linenr_T\tlnum;\n    int\t\tgot_tab = FALSE;\n    long\tnum_spaces = 0;\n    long\tnum_tabs;\n    long\tlen;\n    long\tcol;\n    long\tvcol;\n    long\tstart_col = 0;\t\t\/\/ For start of white-space string\n    long\tstart_vcol = 0;\t\t\/\/ For start of white-space string\n    long\told_len;\n    long\tnew_len;\n    char_u\t*ptr;\n    char_u\t*new_line = (char_u *)1; \/\/ init to non-NULL\n    int\t\tdid_undo;\t\t\/\/ called u_save for current line\n#ifdef FEAT_VARTABS\n    int\t\t*new_vts_array = NULL;\n    char_u\t*new_ts_str;\t\t\/\/ string value of tab argument\n#else\n    int\t\ttemp;\n    int\t\tnew_ts;\n#endif\n    int\t\tsave_list;\n    linenr_T\tfirst_line = 0;\t\t\/\/ first changed line\n    linenr_T\tlast_line = 0;\t\t\/\/ last changed line\n\n    save_list = curwin->w_p_list;\n    curwin->w_p_list = 0;\t    \/\/ don't want list mode here\n\n#ifdef FEAT_VARTABS\n    new_ts_str = eap->arg;\n    if (tabstop_set(eap->arg, &new_vts_array) == FAIL)\n\treturn;\n    while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')\n\t++(eap->arg);\n\n    \/\/ This ensures that either new_vts_array and new_ts_str are freshly\n    \/\/ allocated, or new_vts_array points to an existing array and new_ts_str\n    \/\/ is null.\n    if (new_vts_array == NULL)\n    {\n\tnew_vts_array = curbuf->b_p_vts_array;\n\tnew_ts_str = NULL;\n    }\n    else\n\tnew_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);\n#else\n    ptr = eap->arg;\n    new_ts = getdigits(&ptr);\n    if (new_ts < 0 && *eap->arg == '-')\n    {\n\temsg(_(e_argument_must_be_positive));\n\treturn;\n    }\n    if (new_ts < 0 || new_ts > TABSTOP_MAX)\n    {\n\tsemsg(_(e_invalid_argument_str), eap->arg);\n\treturn;\n    }\n    if (new_ts == 0)\n\tnew_ts = curbuf->b_p_ts;\n#endif\n    for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)\n    {\n\tptr = ml_get(lnum);\n\tcol = 0;\n\tvcol = 0;\n\tdid_undo = FALSE;\n\tfor (;;)\n\t{\n\t    if (VIM_ISWHITE(ptr[col]))\n\t    {\n\t\tif (!got_tab && num_spaces == 0)\n\t\t{\n\t\t    \/\/ First consecutive white-space\n\t\t    start_vcol = vcol;\n\t\t    start_col = col;\n\t\t}\n\t\tif (ptr[col] == ' ')\n\t\t    num_spaces++;\n\t\telse\n\t\t    got_tab = TRUE;\n\t    }\n\t    else\n\t    {\n\t\tif (got_tab || (eap->forceit && num_spaces > 1))\n\t\t{\n\t\t    \/\/ Retabulate this string of white-space\n\n\t\t    \/\/ len is virtual length of white string\n\t\t    len = num_spaces = vcol - start_vcol;\n\t\t    num_tabs = 0;\n\t\t    if (!curbuf->b_p_et)\n\t\t    {\n#ifdef FEAT_VARTABS\n\t\t\tint t, s;\n\n\t\t\ttabstop_fromto(start_vcol, vcol,\n\t\t\t\t\tcurbuf->b_p_ts, new_vts_array, &t, &s);\n\t\t\tnum_tabs = t;\n\t\t\tnum_spaces = s;\n#else\n\t\t\ttemp = new_ts - (start_vcol % new_ts);\n\t\t\tif (num_spaces >= temp)\n\t\t\t{\n\t\t\t    num_spaces -= temp;\n\t\t\t    num_tabs++;\n\t\t\t}\n\t\t\tnum_tabs += num_spaces \/ new_ts;\n\t\t\tnum_spaces -= (num_spaces \/ new_ts) * new_ts;\n#endif\n\t\t    }\n\t\t    if (curbuf->b_p_et || got_tab ||\n\t\t\t\t\t(num_spaces + num_tabs < len))\n\t\t    {\n\t\t\tif (did_undo == FALSE)\n\t\t\t{\n\t\t\t    did_undo = TRUE;\n\t\t\t    if (u_save((linenr_T)(lnum - 1),\n\t\t\t\t\t\t(linenr_T)(lnum + 1)) == FAIL)\n\t\t\t    {\n\t\t\t\tnew_line = NULL;\t\/\/ flag out-of-memory\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t}\n\n\t\t\t\/\/ len is actual number of white characters used\n\t\t\tlen = num_spaces + num_tabs;\n\t\t\told_len = (long)STRLEN(ptr);\n\t\t\tnew_len = old_len - col + start_col + len + 1;\n\t\t\tif (new_len <= 0 || new_len >= MAXCOL)\n\t\t\t{\n\t\t\t    emsg(_(e_resulting_text_too_long));\n\t\t\t    break;\n\t\t\t}\n\t\t\tnew_line = alloc(new_len);\n\t\t\tif (new_line == NULL)\n\t\t\t    break;\n\t\t\tif (start_col > 0)\n\t\t\t    mch_memmove(new_line, ptr, (size_t)start_col);\n\t\t\tmch_memmove(new_line + start_col + len,\n\t\t\t\t      ptr + col, (size_t)(old_len - col + 1));\n\t\t\tptr = new_line + start_col;\n\t\t\tfor (col = 0; col < len; col++)\n\t\t\t    ptr[col] = (col < num_tabs) ? '\\t' : ' ';\n\t\t\tif (ml_replace(lnum, new_line, FALSE) == OK)\n\t\t\t    \/\/ \"new_line\" may have been copied\n\t\t\t    new_line = curbuf->b_ml.ml_line_ptr;\n\t\t\tif (first_line == 0)\n\t\t\t    first_line = lnum;\n\t\t\tlast_line = lnum;\n\t\t\tptr = new_line;\n\t\t\tcol = start_col + len;\n\t\t    }\n\t\t}\n\t\tgot_tab = FALSE;\n\t\tnum_spaces = 0;\n\t    }\n\t    if (ptr[col] == NUL)\n\t\tbreak;\n\t    vcol += chartabsize(ptr + col, (colnr_T)vcol);\n\t    if (vcol >= MAXCOL)\n\t    {\n\t\temsg(_(e_resulting_text_too_long));\n\t\tbreak;\n\t    }\n\t    if (has_mbyte)\n\t\tcol += (*mb_ptr2len)(ptr + col);\n\t    else\n\t\t++col;\n\t}\n\tif (new_line == NULL)\t\t    \/\/ out of memory\n\t    break;\n\tline_breakcheck();\n    }\n    if (got_int)\n\temsg(_(e_interrupted));\n\n#ifdef FEAT_VARTABS\n    \/\/ If a single value was given then it can be considered equal to\n    \/\/ either the value of 'tabstop' or the value of 'vartabstop'.\n    if (tabstop_count(curbuf->b_p_vts_array) == 0\n\t&& tabstop_count(new_vts_array) == 1\n\t&& curbuf->b_p_ts == tabstop_first(new_vts_array))\n\t; \/\/ not changed\n    else if (tabstop_count(curbuf->b_p_vts_array) > 0\n        && tabstop_eq(curbuf->b_p_vts_array, new_vts_array))\n\t; \/\/ not changed\n    else\n\tredraw_curbuf_later(NOT_VALID);\n#else\n    if (curbuf->b_p_ts != new_ts)\n\tredraw_curbuf_later(NOT_VALID);\n#endif\n    if (first_line != 0)\n\tchanged_lines(first_line, 0, last_line + 1, 0L);\n\n    curwin->w_p_list = save_list;\t\/\/ restore 'list'\n\n#ifdef FEAT_VARTABS\n    if (new_ts_str != NULL)\t\t\/\/ set the new tabstop\n    {\n\t\/\/ If 'vartabstop' is in use or if the value given to retab has more\n\t\/\/ than one tabstop then update 'vartabstop'.\n\tint *old_vts_ary = curbuf->b_p_vts_array;\n\n\tif (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)\n\t{\n\t    set_string_option_direct((char_u *)\"vts\", -1, new_ts_str,\n\t\t\t\t\t\t\tOPT_FREE|OPT_LOCAL, 0);\n\t    curbuf->b_p_vts_array = new_vts_array;\n\t    vim_free(old_vts_ary);\n\t}\n\telse\n\t{\n\t    \/\/ 'vartabstop' wasn't in use and a single value was given to\n\t    \/\/ retab then update 'tabstop'.\n\t    curbuf->b_p_ts = tabstop_first(new_vts_array);\n\t    vim_free(new_vts_array);\n\t}\n\tvim_free(new_ts_str);\n    }\n#else\n    curbuf->b_p_ts = new_ts;\n#endif\n    coladvance(curwin->w_curswant);\n\n    u_clearline();\n}","target":0,"code_token_length":1905,"total_token_length":2141,"max_tokens_setting":4096}
+{"idx":215103,"func":"createRandomCursorExecutor(const CollectionPtr& coll,\n                           const boost::intrusive_ptr<ExpressionContext>& expCtx,\n                           long long sampleSize,\n                           long long numRecords,\n                           boost::optional<BucketUnpacker> bucketUnpacker) {\n    OperationContext* opCtx = expCtx->opCtx;\n\n    \/\/ Verify that we are already under a collection lock. We avoid taking locks ourselves in this\n    \/\/ function because double-locking forces any PlanExecutor we create to adopt a NO_YIELD policy.\n    invariant(opCtx->lockState()->isCollectionLockedForMode(coll->ns(), MODE_IS));\n\n    static const double kMaxSampleRatioForRandCursor = 0.05;\n    if (!expCtx->ns.isTimeseriesBucketsCollection()) {\n        if (sampleSize > numRecords * kMaxSampleRatioForRandCursor || numRecords <= 100) {\n            return std::pair{nullptr, false};\n        }\n    } else {\n        \/\/ Suppose that a time-series bucket collection is observed to contain 200 buckets, and the\n        \/\/ 'gTimeseriesBucketMaxCount' parameter is set to 1000. If all buckets are full, then the\n        \/\/ maximum possible measurment count would be 200 * 1000 = 200,000. While the\n        \/\/ 'SampleFromTimeseriesBucket' plan is more efficient when the sample size is small\n        \/\/ relative to the total number of measurements in the time-series collection, for larger\n        \/\/ sample sizes the top-k sort based sample is faster. Experiments have approximated that\n        \/\/ the tipping point is roughly when the requested sample size is greater than 1% of the\n        \/\/ maximum possible number of measurements in the collection (i.e. numBuckets *\n        \/\/ maxMeasurementsPerBucket).\n        static const double kCoefficient = 0.01;\n        if (sampleSize > kCoefficient * numRecords * gTimeseriesBucketMaxCount) {\n            return std::pair{nullptr, false};\n        }\n    }\n\n    \/\/ Attempt to get a random cursor from the RecordStore.\n    auto rsRandCursor = coll->getRecordStore()->getRandomCursor(opCtx);\n    if (!rsRandCursor) {\n        \/\/ The storage engine has no random cursor support.\n        return std::pair{nullptr, false};\n    }\n\n    \/\/ Build a MultiIteratorStage and pass it the random-sampling RecordCursor.\n    auto ws = std::make_unique<WorkingSet>();\n    std::unique_ptr<PlanStage> root =\n        std::make_unique<MultiIteratorStage>(expCtx.get(), ws.get(), coll);\n    static_cast<MultiIteratorStage*>(root.get())->addIterator(std::move(rsRandCursor));\n\n    \/\/ If the incoming operation is sharded, use the CSS to infer the filtering metadata for the\n    \/\/ collection, otherwise treat it as unsharded\n    auto collectionFilter =\n        CollectionShardingState::get(opCtx, coll->ns())\n            ->getOwnershipFilter(\n                opCtx, CollectionShardingState::OrphanCleanupPolicy::kDisallowOrphanCleanup);\n\n    TrialStage* trialStage = nullptr;\n\n    \/\/ Because 'numRecords' includes orphan documents, our initial decision to optimize the $sample\n    \/\/ cursor may have been mistaken. For sharded collections, build a TRIAL plan that will switch\n    \/\/ to a collection scan if the ratio of orphaned to owned documents encountered over the first\n    \/\/ 100 works() is such that we would have chosen not to optimize.\n    static const size_t kMaxPresampleSize = 100;\n    if (collectionFilter.isSharded() && !expCtx->ns.isTimeseriesBucketsCollection()) {\n        \/\/ The ratio of owned to orphaned documents must be at least equal to the ratio between the\n        \/\/ requested sampleSize and the maximum permitted sampleSize for the original constraints to\n        \/\/ be satisfied. For instance, if there are 200 documents and the sampleSize is 5, then at\n        \/\/ least (5 \/ (200*0.05)) = (5\/10) = 50% of those documents must be owned. If less than 5%\n        \/\/ of the documents in the collection are owned, we default to the backup plan.\n        const auto minAdvancedToWorkRatio = std::max(\n            sampleSize \/ (numRecords * kMaxSampleRatioForRandCursor), kMaxSampleRatioForRandCursor);\n        \/\/ The trial plan is SHARDING_FILTER-MULTI_ITERATOR.\n        auto randomCursorPlan = std::make_unique<ShardFilterStage>(\n            expCtx.get(), collectionFilter, ws.get(), std::move(root));\n        \/\/ The backup plan is SHARDING_FILTER-COLLSCAN.\n        std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>(\n            expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr);\n        collScanPlan = std::make_unique<ShardFilterStage>(\n            expCtx.get(), collectionFilter, ws.get(), std::move(collScanPlan));\n        \/\/ Place a TRIAL stage at the root of the plan tree, and pass it the trial and backup plans.\n        root = std::make_unique<TrialStage>(expCtx.get(),\n                                            ws.get(),\n                                            std::move(randomCursorPlan),\n                                            std::move(collScanPlan),\n                                            kMaxPresampleSize,\n                                            minAdvancedToWorkRatio);\n        trialStage = static_cast<TrialStage*>(root.get());\n    } else if (expCtx->ns.isTimeseriesBucketsCollection()) {\n        \/\/ Use a 'TrialStage' to run a trial between 'SampleFromTimeseriesBucket' and\n        \/\/ 'UnpackTimeseriesBucket' with $sample left in the pipeline in-place. If the buckets are\n        \/\/ not sufficiently full, or the 'SampleFromTimeseriesBucket' plan draws too many\n        \/\/ duplicates, then we will fall back to the 'TrialStage' backup plan. This backup plan uses\n        \/\/ the top-k sort sampling approach.\n        \/\/\n        \/\/ Suppose the 'gTimeseriesBucketMaxCount' is 1000, but each bucket only contains 500\n        \/\/ documents on average. The observed trial advanced\/work ratio approximates the average\n        \/\/ bucket fullness, noted here as \"abf\". In this example, abf = 500 \/ 1000 = 0.5.\n        \/\/ Experiments have shown that the optimized 'SampleFromTimeseriesBucket' algorithm performs\n        \/\/ better than backup plan when\n        \/\/\n        \/\/     sampleSize < 0.02 * abf * numRecords * gTimeseriesBucketMaxCount\n        \/\/\n        \/\/  This inequality can be rewritten as\n        \/\/\n        \/\/     abf > sampleSize \/ (0.02 * numRecords * gTimeseriesBucketMaxCount)\n        \/\/\n        \/\/ Therefore, if the advanced\/work ratio exceeds this threshold, we will use the\n        \/\/ 'SampleFromTimeseriesBucket' plan. Note that as the sample size requested by the user\n        \/\/ becomes larger with respect to the number of buckets, we require a higher advanced\/work\n        \/\/ ratio in order to justify using 'SampleFromTimeseriesBucket'.\n        \/\/\n        \/\/ Additionally, we require the 'TrialStage' to approximate the abf as at least 0.25. When\n        \/\/ buckets are mostly empty, the 'SampleFromTimeseriesBucket' will be inefficient due to a\n        \/\/ lot of sampling \"misses\".\n        static const auto kCoefficient = 0.02;\n        static const auto kMinBucketFullness = 0.25;\n        const auto minAdvancedToWorkRatio = std::max(\n            std::min(sampleSize \/ (kCoefficient * numRecords * gTimeseriesBucketMaxCount), 1.0),\n            kMinBucketFullness);\n\n        auto arhashPlan = std::make_unique<SampleFromTimeseriesBucket>(\n            expCtx.get(),\n            ws.get(),\n            std::move(root),\n            *bucketUnpacker,\n            \/\/ By using a quantity slightly higher than 'kMaxPresampleSize', we ensure that the\n            \/\/ 'SampleFromTimeseriesBucket' stage won't fail due to too many consecutive sampling\n            \/\/ attempts during the 'TrialStage's trial period.\n            kMaxPresampleSize + 5,\n            sampleSize,\n            gTimeseriesBucketMaxCount);\n\n        std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>(\n            expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr);\n\n        auto topkSortPlan = std::make_unique<UnpackTimeseriesBucket>(\n            expCtx.get(), ws.get(), std::move(collScanPlan), *bucketUnpacker);\n\n        root = std::make_unique<TrialStage>(expCtx.get(),\n                                            ws.get(),\n                                            std::move(arhashPlan),\n                                            std::move(topkSortPlan),\n                                            kMaxPresampleSize,\n                                            minAdvancedToWorkRatio);\n        trialStage = static_cast<TrialStage*>(root.get());\n    }\n\n    auto execStatus = plan_executor_factory::make(expCtx,\n                                                  std::move(ws),\n                                                  std::move(root),\n                                                  &coll,\n                                                  opCtx->inMultiDocumentTransaction()\n                                                      ? PlanYieldPolicy::YieldPolicy::INTERRUPT_ONLY\n                                                      : PlanYieldPolicy::YieldPolicy::YIELD_AUTO,\n                                                  QueryPlannerParams::RETURN_OWNED_DATA);\n    if (!execStatus.isOK()) {\n        return execStatus.getStatus();\n    }\n\n    \/\/ For sharded collections, the root of the plan tree is a TrialStage that may have chosen\n    \/\/ either a random-sampling cursor trial plan or a COLLSCAN backup plan. We can only optimize\n    \/\/ the $sample aggregation stage if the trial plan was chosen.\n    return std::pair{std::move(execStatus.getValue()),\n                     !trialStage || !trialStage->pickedBackupPlan()};\n}","target":1,"code_token_length":2103,"total_token_length":2339,"max_tokens_setting":4096}
+{"idx":338747,"func":"static Image *ReadTGAImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  PixelInfo\n    pixel;\n\n  Quantum\n    index;\n\n  register Quantum\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  size_t\n    base,\n    flag,\n    offset,\n    real,\n    skip;\n\n  ssize_t\n    count,\n    y;\n\n  TGAInfo\n    tga_info;\n\n  unsigned char\n    j,\n    k,\n    pixels[4],\n    runlength;\n\n  unsigned int\n    alpha_bits;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read TGA header information.\n  *\/\n  count=ReadBlob(image,1,&tga_info.id_length);\n  tga_info.colormap_type=(unsigned char) ReadBlobByte(image);\n  tga_info.image_type=(TGAImageType) ReadBlobByte(image);\n  if ((count != 1) ||\n      ((tga_info.image_type != TGAColormap) &&\n       (tga_info.image_type != TGARGB) &&\n       (tga_info.image_type != TGAMonochrome) &&\n       (tga_info.image_type != TGARLEColormap) &&\n       (tga_info.image_type != TGARLERGB) &&\n       (tga_info.image_type != TGARLEMonochrome)) ||\n      (((tga_info.image_type == TGAColormap) ||\n       (tga_info.image_type == TGARLEColormap)) &&\n       (tga_info.colormap_type == 0)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  tga_info.colormap_index=ReadBlobLSBShort(image);\n  tga_info.colormap_length=ReadBlobLSBShort(image);\n  tga_info.colormap_size=(unsigned char) ReadBlobByte(image);\n  tga_info.x_origin=ReadBlobLSBShort(image);\n  tga_info.y_origin=ReadBlobLSBShort(image);\n  tga_info.width=(unsigned short) ReadBlobLSBShort(image);\n  tga_info.height=(unsigned short) ReadBlobLSBShort(image);\n  tga_info.bits_per_pixel=(unsigned char) ReadBlobByte(image);\n  tga_info.attributes=(unsigned char) ReadBlobByte(image);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n  if ((((tga_info.bits_per_pixel <= 1) || (tga_info.bits_per_pixel >= 17)) &&\n       (tga_info.bits_per_pixel != 24) && (tga_info.bits_per_pixel != 32)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  \/*\n    Initialize image structure.\n  *\/\n  image->columns=tga_info.width;\n  image->rows=tga_info.height;\n  alpha_bits=(tga_info.attributes & 0x0FU);\n  image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) ||\n    (tga_info.colormap_size == 32) ?  BlendPixelTrait : UndefinedPixelTrait;\n  if ((tga_info.image_type != TGAColormap) &&\n      (tga_info.image_type != TGARLEColormap))\n    image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 :\n      (tga_info.bits_per_pixel <= 16) ? 5 : 8);\n  else\n    image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 :\n      (tga_info.colormap_size <= 16) ? 5 : 8);\n  if ((tga_info.image_type == TGAColormap) ||\n      (tga_info.image_type == TGAMonochrome) ||\n      (tga_info.image_type == TGARLEColormap) ||\n      (tga_info.image_type == TGARLEMonochrome))\n    image->storage_class=PseudoClass;\n  image->compression=NoCompression;\n  if ((tga_info.image_type == TGARLEColormap) ||\n      (tga_info.image_type == TGARLEMonochrome) ||\n      (tga_info.image_type == TGARLERGB))\n    image->compression=RLECompression;\n  if (image->storage_class == PseudoClass)\n    {\n      if (tga_info.colormap_type != 0)\n        image->colors=tga_info.colormap_index+tga_info.colormap_length;\n      else\n        {\n          size_t\n            one;\n\n          one=1;\n          image->colors=one << tga_info.bits_per_pixel;\n          if (image->colors > ((~0UL)\/sizeof(*image->colormap)))\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n          if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        }\n    }\n  if (tga_info.id_length != 0)\n    {\n      char\n        *comment;\n\n      size_t\n        length;\n\n      \/*\n        TGA image comment.\n      *\/\n      length=(size_t) tga_info.id_length;\n      comment=(char *) NULL;\n      if (~length >= (MagickPathExtent-1))\n        comment=(char *) AcquireQuantumMemory(length+MagickPathExtent,\n          sizeof(*comment));\n      if (comment == (char *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      count=ReadBlob(image,tga_info.id_length,(unsigned char *) comment);\n      comment[tga_info.id_length]='\\0';\n      (void) SetImageProperty(image,\"comment\",comment,exception);\n      comment=DestroyString(comment);\n    }\n  if (tga_info.attributes & (1UL << 4))\n    {\n      if (tga_info.attributes & (1UL << 5))\n        SetImageArtifact(image,\"tga:image-origin\",\"TopRight\");\n      else\n        SetImageArtifact(image,\"tga:image-origin\",\"BottomRight\");\n    }\n  else\n    {\n      if (tga_info.attributes & (1UL << 5))\n        SetImageArtifact(image,\"tga:image-origin\",\"TopLeft\");\n      else\n        SetImageArtifact(image,\"tga:image-origin\",\"BottomLeft\");\n    }\n  if (image_info->ping != MagickFalse)\n    {\n      (void) CloseBlob(image);\n      return(image);\n    }\n  status=SetImageExtent(image,image->columns,image->rows,exception);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  (void) ResetMagickMemory(&pixel,0,sizeof(pixel));\n  pixel.alpha=(MagickRealType) OpaqueAlpha;\n  if (tga_info.colormap_type != 0)\n    {\n      \/*\n        Read TGA raster colormap.\n      *\/\n      if (image->colors < tga_info.colormap_index)\n        image->colors=tga_info.colormap_index;\n      if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      for (i=0; i < (ssize_t) tga_info.colormap_index; i++)\n        image->colormap[i]=pixel;\n      for ( ; i < (ssize_t) image->colors; i++)\n      {\n        switch (tga_info.colormap_size)\n        {\n          case 8:\n          default:\n          {\n            \/*\n              Gray scale.\n            *\/\n            pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.green=pixel.red;\n            pixel.blue=pixel.red;\n            break;\n          }\n          case 15:\n          case 16:\n          {\n            QuantumAny\n              range;\n\n            \/*\n              5 bits each of red green and blue.\n            *\/\n            j=(unsigned char) ReadBlobByte(image);\n            k=(unsigned char) ReadBlobByte(image);\n            range=GetQuantumRange(5UL);\n            pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,\n              range);\n            pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*(k & 0x03)\n              << 3)+(1UL*(j & 0xe0) >> 5),range);\n            pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);\n            break;\n          }\n          case 24:\n          {\n            \/*\n              8 bits each of blue, green and red.\n            *\/\n            pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            break;\n          }\n          case 32:\n          {\n            \/*\n              8 bits each of blue, green, red, and alpha.\n            *\/\n            pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            pixel.alpha=(MagickRealType) ScaleCharToQuantum((unsigned char)\n              ReadBlobByte(image));\n            break;\n          }\n        }\n        image->colormap[i]=pixel;\n      }\n    }\n  \/*\n    Convert TGA pixels to pixel packets.\n  *\/\n  base=0;\n  flag=0;\n  skip=MagickFalse;\n  real=0;\n  index=0;\n  runlength=0;\n  offset=0;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    real=offset;\n    if (((unsigned char) (tga_info.attributes & 0x20) >> 5) == 0)\n      real=image->rows-real-1;\n    q=QueueAuthenticPixels(image,0,(ssize_t) real,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      break;\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      if ((tga_info.image_type == TGARLEColormap) ||\n          (tga_info.image_type == TGARLERGB) ||\n          (tga_info.image_type == TGARLEMonochrome))\n        {\n          if (runlength != 0)\n            {\n              runlength--;\n              skip=flag != 0;\n            }\n          else\n            {\n              count=ReadBlob(image,1,&runlength);\n              if (count != 1)\n                ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n              flag=runlength & 0x80;\n              if (flag != 0)\n                runlength-=128;\n              skip=MagickFalse;\n            }\n        }\n      if (skip == MagickFalse)\n        switch (tga_info.bits_per_pixel)\n        {\n          case 8:\n          default:\n          {\n            \/*\n              Gray scale.\n            *\/\n            index=(Quantum) ReadBlobByte(image);\n            if (tga_info.colormap_type != 0)\n              pixel=image->colormap[(ssize_t) ConstrainColormapIndex(image,\n                (ssize_t) index,exception)];\n            else\n              {\n                pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)\n                  index);\n                pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)\n                  index);\n                pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)\n                  index);\n              }\n            break;\n          }\n          case 15:\n          case 16:\n          {\n            QuantumAny\n              range;\n\n            \/*\n              5 bits each of RGB.\n            *\/\n            if (ReadBlob(image,2,pixels) != 2)\n              ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n            j=pixels[0];\n            k=pixels[1];\n            range=GetQuantumRange(5UL);\n            pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,\n              range);\n            pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*\n              (k & 0x03) << 3)+(1UL*(j & 0xe0) >> 5),range);\n            pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);\n            if (image->alpha_trait != UndefinedPixelTrait)\n              pixel.alpha=(MagickRealType) ((k & 0x80) == 0 ? (Quantum)\n                TransparentAlpha : (Quantum) OpaqueAlpha);\n            if (image->storage_class == PseudoClass)\n              index=(Quantum) ConstrainColormapIndex(image,((ssize_t) (k << 8))+\n                j,exception);\n            break;\n          }\n          case 24:\n          {\n            \/*\n              BGR pixels.\n            *\/\n            if (ReadBlob(image,3,pixels) != 3)\n              ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n            pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);\n            pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);\n            pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);\n            break;\n          }\n          case 32:\n          {\n            \/*\n              BGRA pixels.\n            *\/\n            if (ReadBlob(image,4,pixels) != 4)\n              ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n            pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);\n            pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);\n            pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);\n            pixel.alpha=(MagickRealType) ScaleCharToQuantum(pixels[3]);\n            break;\n          }\n        }\n      if (status == MagickFalse)\n        ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n      if (image->storage_class == PseudoClass)\n        SetPixelIndex(image,index,q);\n      SetPixelRed(image,ClampToQuantum(pixel.red),q);\n      SetPixelGreen(image,ClampToQuantum(pixel.green),q);\n      SetPixelBlue(image,ClampToQuantum(pixel.blue),q);\n      if (image->alpha_trait != UndefinedPixelTrait)\n        SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);\n      q+=GetPixelChannels(image);\n    }\n    \/*\n      if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 4)\n        offset+=4;\n      else\n    *\/\n      if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 2)\n        offset+=2;\n      else\n        offset++;\n    if (offset >= image->rows)\n      {\n        base++;\n        offset=base;\n      }\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n    if (image->previous == (Image *) NULL)\n      {\n        status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n          image->rows);\n        if (status == MagickFalse)\n          break;\n      }\n  }\n  if (EOFBlob(image) != MagickFalse)\n    ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":3556,"total_token_length":3792,"max_tokens_setting":4096}
+{"idx":474054,"func":"fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)\n{\n  int num;\n  OnigCodePoint c, c2;\n  const OnigSyntaxType* syn = env->syntax;\n  OnigEncoding enc = env->enc;\n  UChar* prev;\n  UChar* p = *src;\n  PFETCH_READY;\n\n  if (PEND) {\n    tok->type = TK_EOT;\n    return tok->type;\n  }\n\n  PFETCH(c);\n  tok->type = TK_CHAR;\n  tok->base = 0;\n  tok->u.c  = c;\n  tok->escaped = 0;\n\n  if (c == ']') {\n    tok->type = TK_CC_CLOSE;\n  }\n  else if (c == '-') {\n    tok->type = TK_CC_RANGE;\n  }\n  else if (c == MC_ESC(syn)) {\n    if (! IS_SYNTAX_BV(syn, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC))\n      goto end;\n\n    if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;\n\n    PFETCH(c);\n    tok->escaped = 1;\n    tok->u.c = c;\n    switch (c) {\n    case 'w':\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_W;\n      tok->u.prop.not   = 0;\n      break;\n    case 'W':\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_W;\n      tok->u.prop.not   = 1;\n      break;\n    case 'd':\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_D;\n      tok->u.prop.not   = 0;\n      break;\n    case 'D':\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_D;\n      tok->u.prop.not   = 1;\n      break;\n    case 's':\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_S;\n      tok->u.prop.not   = 0;\n      break;\n    case 'S':\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_S;\n      tok->u.prop.not   = 1;\n      break;\n    case 'h':\n      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;\n      tok->u.prop.not   = 0;\n      break;\n    case 'H':\n      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;\n      tok->u.prop.not   = 1;\n      break;\n\n    case 'p':\n    case 'P':\n      c2 = PPEEK;\n      if (c2 == '{' &&\n\t  IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {\n\tPINC;\n\ttok->type = TK_CHAR_PROPERTY;\n\ttok->u.prop.not = (c == 'P' ? 1 : 0);\n\n\tif (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {\n\t  PFETCH(c2);\n\t  if (c2 == '^') {\n\t    tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);\n\t  }\n\t  else\n\t    PUNFETCH;\n\t}\n      }\n      else {\n\t  onig_syntax_warn(env, \"invalid Unicode Property \\\\%c\", c);\n      }\n      break;\n\n    case 'x':\n      if (PEND) break;\n\n      prev = p;\n      if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) {\n\tPINC;\n\tnum = scan_unsigned_hexadecimal_number(&p, end, 8, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;\n\tif (!PEND) {\n          c2 = PPEEK;\n          if (ONIGENC_IS_CODE_XDIGIT(enc, c2))\n            return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;\n        }\n\n\tif (p > prev + enclen(enc, prev, end) && !PEND && (PPEEK_IS('}'))) {\n\t  PINC;\n\t  tok->type   = TK_CODE_POINT;\n\t  tok->base   = 16;\n\t  tok->u.code = (OnigCodePoint )num;\n\t}\n\telse {\n\t  \/* can't read nothing or invalid format *\/\n\t  p = prev;\n\t}\n      }\n      else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) {\n\tnum = scan_unsigned_hexadecimal_number(&p, end, 2, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_NUMBER;\n\tif (p == prev) {  \/* can't read nothing. *\/\n\t  num = 0; \/* but, it's not error *\/\n\t}\n\ttok->type = TK_RAW_BYTE;\n\ttok->base = 16;\n\ttok->u.c  = num;\n      }\n      break;\n\n    case 'u':\n      if (PEND) break;\n\n      prev = p;\n      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) {\n\tnum = scan_unsigned_hexadecimal_number(&p, end, 4, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_NUMBER;\n\tif (p == prev) {  \/* can't read nothing. *\/\n\t  num = 0; \/* but, it's not error *\/\n\t}\n\ttok->type   = TK_CODE_POINT;\n\ttok->base   = 16;\n\ttok->u.code = (OnigCodePoint )num;\n      }\n      break;\n\n    case '0':\n    case '1': case '2': case '3': case '4': case '5': case '6': case '7':\n      if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {\n\tPUNFETCH;\n\tprev = p;\n\tnum = scan_unsigned_octal_number(&p, end, 3, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_NUMBER;\n\tif (p == prev) {  \/* can't read nothing. *\/\n\t  num = 0; \/* but, it's not error *\/\n\t}\n\ttok->type = TK_RAW_BYTE;\n\ttok->base = 8;\n\ttok->u.c  = num;\n      }\n      break;\n\n    default:\n      PUNFETCH;\n      num = fetch_escaped_value(&p, end, env);\n      if (num < 0) return num;\n      if (tok->u.c != num) {\n\ttok->u.code = (OnigCodePoint )num;\n\ttok->type   = TK_CODE_POINT;\n      }\n      break;\n    }\n  }\n  else if (c == '[') {\n    if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_POSIX_BRACKET) && (PPEEK_IS(':'))) {\n      OnigCodePoint send[] = { (OnigCodePoint )':', (OnigCodePoint )']' };\n      tok->backp = p; \/* point at '[' is readed *\/\n      PINC;\n      if (str_exist_check_with_esc(send, 2, p, end,\n                                   (OnigCodePoint )']', enc, syn)) {\n\ttok->type = TK_POSIX_BRACKET_OPEN;\n      }\n      else {\n\tPUNFETCH;\n\tgoto cc_in_cc;\n      }\n    }\n    else {\n    cc_in_cc:\n      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP)) {\n\ttok->type = TK_CC_CC_OPEN;\n      }\n      else {\n\tCC_ESC_WARN(env, (UChar* )\"[\");\n      }\n    }\n  }\n  else if (c == '&') {\n    if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP) &&\n\t!PEND && (PPEEK_IS('&'))) {\n      PINC;\n      tok->type = TK_CC_AND;\n    }\n  }\n\n end:\n  *src = p;\n  return tok->type;\n}","target":0,"code_token_length":1841,"total_token_length":2077,"max_tokens_setting":4096}
+{"idx":210393,"func":"do_arg_all(\n    int\tcount,\n    int\tforceit,\t\t\/\/ hide buffers in current windows\n    int keep_tabs)\t\t\/\/ keep current tabs, for \":tab drop file\"\n{\n    int\t\ti;\n    win_T\t*wp, *wpnext;\n    char_u\t*opened;\t\/\/ Array of weight for which args are open:\n\t\t\t\t\/\/  0: not opened\n\t\t\t\t\/\/  1: opened in other tab\n\t\t\t\t\/\/  2: opened in curtab\n\t\t\t\t\/\/  3: opened in curtab and curwin\n\t\t\t\t\/\/\n    int\t\topened_len;\t\/\/ length of opened[]\n    int\t\tuse_firstwin = FALSE;\t\/\/ use first window for arglist\n    int\t\ttab_drop_empty_window = FALSE;\n    int\t\tsplit_ret = OK;\n    int\t\tp_ea_save;\n    alist_T\t*alist;\t\t\/\/ argument list to be used\n    buf_T\t*buf;\n    tabpage_T\t*tpnext;\n    int\t\thad_tab = cmdmod.cmod_tab;\n    win_T\t*old_curwin, *last_curwin;\n    tabpage_T\t*old_curtab, *last_curtab;\n    win_T\t*new_curwin = NULL;\n    tabpage_T\t*new_curtab = NULL;\n\n#ifdef FEAT_CMDWIN\n    if (cmdwin_type != 0)\n    {\n\temsg(_(e_invalid_in_cmdline_window));\n\treturn;\n    }\n#endif\n    if (ARGCOUNT <= 0)\n    {\n\t\/\/ Don't give an error message.  We don't want it when the \":all\"\n\t\/\/ command is in the .vimrc.\n\treturn;\n    }\n    setpcmark();\n\n    opened_len = ARGCOUNT;\n    opened = alloc_clear(opened_len);\n    if (opened == NULL)\n\treturn;\n\n    \/\/ Autocommands may do anything to the argument list.  Make sure it's not\n    \/\/ freed while we are working here by \"locking\" it.  We still have to\n    \/\/ watch out for its size to be changed.\n    alist = curwin->w_alist;\n    ++alist->al_refcount;\n\n    old_curwin = curwin;\n    old_curtab = curtab;\n\n# ifdef FEAT_GUI\n    need_mouse_correct = TRUE;\n# endif\n\n    \/\/ Try closing all windows that are not in the argument list.\n    \/\/ Also close windows that are not full width;\n    \/\/ When 'hidden' or \"forceit\" set the buffer becomes hidden.\n    \/\/ Windows that have a changed buffer and can't be hidden won't be closed.\n    \/\/ When the \":tab\" modifier was used do this for all tab pages.\n    if (had_tab > 0)\n\tgoto_tabpage_tp(first_tabpage, TRUE, TRUE);\n    for (;;)\n    {\n\ttpnext = curtab->tp_next;\n\tfor (wp = firstwin; wp != NULL; wp = wpnext)\n\t{\n\t    wpnext = wp->w_next;\n\t    buf = wp->w_buffer;\n\t    if (buf->b_ffname == NULL\n\t\t    || (!keep_tabs && (buf->b_nwindows > 1\n\t\t\t    || wp->w_width != Columns)))\n\t\ti = opened_len;\n\t    else\n\t    {\n\t\t\/\/ check if the buffer in this window is in the arglist\n\t\tfor (i = 0; i < opened_len; ++i)\n\t\t{\n\t\t    if (i < alist->al_ga.ga_len\n\t\t\t    && (AARGLIST(alist)[i].ae_fnum == buf->b_fnum\n\t\t\t\t|| fullpathcmp(alist_name(&AARGLIST(alist)[i]),\n\t\t\t\t\tbuf->b_ffname, TRUE, TRUE) & FPC_SAME))\n\t\t    {\n\t\t\tint weight = 1;\n\n\t\t\tif (old_curtab == curtab)\n\t\t\t{\n\t\t\t    ++weight;\n\t\t\t    if (old_curwin == wp)\n\t\t\t\t++weight;\n\t\t\t}\n\n\t\t\tif (weight > (int)opened[i])\n\t\t\t{\n\t\t\t    opened[i] = (char_u)weight;\n\t\t\t    if (i == 0)\n\t\t\t    {\n\t\t\t\tif (new_curwin != NULL)\n\t\t\t\t    new_curwin->w_arg_idx = opened_len;\n\t\t\t\tnew_curwin = wp;\n\t\t\t\tnew_curtab = curtab;\n\t\t\t    }\n\t\t\t}\n\t\t\telse if (keep_tabs)\n\t\t\t    i = opened_len;\n\n\t\t\tif (wp->w_alist != alist)\n\t\t\t{\n\t\t\t    \/\/ Use the current argument list for all windows\n\t\t\t    \/\/ containing a file from it.\n\t\t\t    alist_unlink(wp->w_alist);\n\t\t\t    wp->w_alist = alist;\n\t\t\t    ++wp->w_alist->al_refcount;\n\t\t\t}\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t    wp->w_arg_idx = i;\n\n\t    if (i == opened_len && !keep_tabs)\/\/ close this window\n\t    {\n\t\tif (buf_hide(buf) || forceit || buf->b_nwindows > 1\n\t\t\t\t\t\t\t|| !bufIsChanged(buf))\n\t\t{\n\t\t    \/\/ If the buffer was changed, and we would like to hide it,\n\t\t    \/\/ try autowriting.\n\t\t    if (!buf_hide(buf) && buf->b_nwindows <= 1\n\t\t\t\t\t\t\t && bufIsChanged(buf))\n\t\t    {\n\t\t\tbufref_T    bufref;\n\n\t\t\tset_bufref(&bufref, buf);\n\n\t\t\t(void)autowrite(buf, FALSE);\n\n\t\t\t\/\/ check if autocommands removed the window\n\t\t\tif (!win_valid(wp) || !bufref_valid(&bufref))\n\t\t\t{\n\t\t\t    wpnext = firstwin;\t\/\/ start all over...\n\t\t\t    continue;\n\t\t\t}\n\t\t    }\n\t\t    \/\/ don't close last window\n\t\t    if (ONE_WINDOW\n\t\t\t    && (first_tabpage->tp_next == NULL || !had_tab))\n\t\t\tuse_firstwin = TRUE;\n\t\t    else\n\t\t    {\n\t\t\twin_close(wp, !buf_hide(buf) && !bufIsChanged(buf));\n\n\t\t\t\/\/ check if autocommands removed the next window\n\t\t\tif (!win_valid(wpnext))\n\t\t\t    wpnext = firstwin;\t\/\/ start all over...\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n\t\/\/ Without the \":tab\" modifier only do the current tab page.\n\tif (had_tab == 0 || tpnext == NULL)\n\t    break;\n\n\t\/\/ check if autocommands removed the next tab page\n\tif (!valid_tabpage(tpnext))\n\t    tpnext = first_tabpage;\t\/\/ start all over...\n\n\tgoto_tabpage_tp(tpnext, TRUE, TRUE);\n    }\n\n    \/\/ Open a window for files in the argument list that don't have one.\n    \/\/ ARGCOUNT may change while doing this, because of autocommands.\n    if (count > opened_len || count <= 0)\n\tcount = opened_len;\n\n    \/\/ Don't execute Win\/Buf Enter\/Leave autocommands here.\n    ++autocmd_no_enter;\n    ++autocmd_no_leave;\n    last_curwin = curwin;\n    last_curtab = curtab;\n    win_enter(lastwin, FALSE);\n    \/\/ \":tab drop file\" should re-use an empty window to avoid \"--remote-tab\"\n    \/\/ leaving an empty tab page when executed locally.\n    if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1\n\t\t\t    && curbuf->b_ffname == NULL && !curbuf->b_changed)\n    {\n\tuse_firstwin = TRUE;\n\ttab_drop_empty_window = TRUE;\n    }\n\n    for (i = 0; i < count && !got_int; ++i)\n    {\n\tif (alist == &global_alist && i == global_alist.al_ga.ga_len - 1)\n\t    arg_had_last = TRUE;\n\tif (opened[i] > 0)\n\t{\n\t    \/\/ Move the already present window to below the current window\n\t    if (curwin->w_arg_idx != i)\n\t    {\n\t\tFOR_ALL_WINDOWS(wpnext)\n\t\t{\n\t\t    if (wpnext->w_arg_idx == i)\n\t\t    {\n\t\t\tif (keep_tabs)\n\t\t\t{\n\t\t\t    new_curwin = wpnext;\n\t\t\t    new_curtab = curtab;\n\t\t\t}\n\t\t\telse if (wpnext->w_frame->fr_parent\n\t\t\t\t\t\t != curwin->w_frame->fr_parent)\n\t\t\t{\n\t\t\t    emsg(_(\"E249: window layout changed unexpectedly\"));\n\t\t\t    i = count;\n\t\t\t    break;\n\t\t\t}\n\t\t\telse\n\t\t\t    win_move_after(wpnext, curwin);\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\telse if (split_ret == OK)\n\t{\n\t    \/\/ trigger events for tab drop\n\t    if (tab_drop_empty_window && i == count - 1)\n\t\t--autocmd_no_enter;\n\t    if (!use_firstwin)\t\t\/\/ split current window\n\t    {\n\t\tp_ea_save = p_ea;\n\t\tp_ea = TRUE;\t\t\/\/ use space from all windows\n\t\tsplit_ret = win_split(0, WSP_ROOM | WSP_BELOW);\n\t\tp_ea = p_ea_save;\n\t\tif (split_ret == FAIL)\n\t\t    continue;\n\t    }\n\t    else    \/\/ first window: do autocmd for leaving this buffer\n\t\t--autocmd_no_leave;\n\n\t    \/\/ edit file \"i\"\n\t    curwin->w_arg_idx = i;\n\t    if (i == 0)\n\t    {\n\t\tnew_curwin = curwin;\n\t\tnew_curtab = curtab;\n\t    }\n\t    (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL,\n\t\t      ECMD_ONE,\n\t\t      ((buf_hide(curwin->w_buffer)\n\t\t\t   || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)\n\t\t\t\t\t\t       + ECMD_OLDBUF, curwin);\n\t    if (tab_drop_empty_window && i == count - 1)\n\t\t++autocmd_no_enter;\n\t    if (use_firstwin)\n\t\t++autocmd_no_leave;\n\t    use_firstwin = FALSE;\n\t}\n\tui_breakcheck();\n\n\t\/\/ When \":tab\" was used open a new tab for a new window repeatedly.\n\tif (had_tab > 0 && tabpage_index(NULL) <= p_tpm)\n\t    cmdmod.cmod_tab = 9999;\n    }\n\n    \/\/ Remove the \"lock\" on the argument list.\n    alist_unlink(alist);\n\n    --autocmd_no_enter;\n\n    \/\/ restore last referenced tabpage's curwin\n    if (last_curtab != new_curtab)\n    {\n\tif (valid_tabpage(last_curtab))\n\t    goto_tabpage_tp(last_curtab, TRUE, TRUE);\n\tif (win_valid(last_curwin))\n\t    win_enter(last_curwin, FALSE);\n    }\n    \/\/ to window with first arg\n    if (valid_tabpage(new_curtab))\n\tgoto_tabpage_tp(new_curtab, TRUE, TRUE);\n    if (win_valid(new_curwin))\n\twin_enter(new_curwin, FALSE);\n\n    --autocmd_no_leave;\n    vim_free(opened);\n}","target":1,"code_token_length":2334,"total_token_length":2570,"max_tokens_setting":4096}
+{"idx":225562,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ There are two steps when calculating gradient for FractionalMaxPool.\n    \/\/ 1) Walk through the process of calculating fractional pooling given\n    \/\/    pooling region; however, in the process, keep track of where the max\n    \/\/    element comes from. (arg_max)\n    \/\/ 2) Populate the value of out_backprop to where arg_max indicates. If\n    \/\/    we support overlapping, it is likely to have multiple out_backprop[i]\n    \/\/    propagates back to the same arg_max value.\n    typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        ConstEigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenMatrixMap;\n    typedef Eigen::Map<Eigen::Matrix<int64, Eigen::Dynamic, Eigen::Dynamic>>\n        EigenIndexMatrixMap;\n\n    const Tensor& tensor_in = context->input(0);\n    const Tensor& tensor_out = context->input(1);\n    const Tensor& out_backprop = context->input(2);\n    const Tensor& height_seq_tensor = context->input(3);\n    const Tensor& width_seq_tensor = context->input(4);\n\n    \/\/ Just to make it similar to FractionalMaxPoolOp.\n    constexpr int tensor_in_and_out_dims = 4;\n    OP_REQUIRES(\n        context, tensor_in.dims() == tensor_in_and_out_dims,\n        errors::InvalidArgument(\"orig_input should be a tensor of rank 4, got \",\n                                tensor_in.DebugString()));\n    OP_REQUIRES(context, tensor_in.NumElements() > 0,\n                errors::InvalidArgument(\"orig_input must not be empty, got \",\n                                        tensor_in.DebugString()));\n    OP_REQUIRES(context, tensor_out.dims() == tensor_in_and_out_dims,\n                errors::InvalidArgument(\n                    \"orig_output should be a tensor of rank 4, got \",\n                    tensor_out.DebugString()));\n    OP_REQUIRES(context, tensor_out.NumElements() > 0,\n                errors::InvalidArgument(\"orig_output must not be empty, got \",\n                                        tensor_out.DebugString()));\n    std::vector<int64_t> input_size(tensor_in_and_out_dims);\n    std::vector<int64_t> output_size(tensor_in_and_out_dims);\n    for (int i = 0; i < tensor_in_and_out_dims; ++i) {\n      input_size[i] = tensor_in.dim_size(i);\n    }\n    for (int i = 0; i < tensor_in_and_out_dims; ++i) {\n      output_size[i] = tensor_out.dim_size(i);\n    }\n\n    \/\/ ---------\n    \/\/ Step 1\n    \/\/ ---------\n    Tensor tensor_out_dup;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(\n                                {1}, DataTypeToEnum<T>::v(), tensor_out.shape(),\n                                &tensor_out_dup));\n    Tensor tensor_out_arg_max;\n    OP_REQUIRES_OK(context, context->allocate_temp(DataTypeToEnum<int64_t>::v(),\n                                                   tensor_out.shape(),\n                                                   &tensor_out_arg_max));\n    \/\/ Find arg_max for each tensor_out\n    ConstEigenMatrixMap tensor_in_mat(\n        tensor_in.flat<T>().data(), input_size[3],\n        input_size[2] * input_size[1] * input_size[0]);\n    EigenMatrixMap tensor_out_dup_mat(\n        tensor_out_dup.flat<T>().data(), output_size[3],\n        output_size[2] * output_size[1] * output_size[0]);\n    EigenIndexMatrixMap tensor_out_arg_max_mat(\n        tensor_out_arg_max.flat<int64_t>().data(), output_size[3],\n        output_size[2] * output_size[1] * output_size[0]);\n\n    tensor_out_arg_max.flat<int64_t>().setConstant(kInvalidMaxPoolingIndex);\n    \/\/ Initializes the duplicate output tensor with MIN<T>.\n    tensor_out_dup.flat<T>().setConstant(Eigen::NumTraits<T>::lowest());\n\n    auto height_seq_tensor_flat = height_seq_tensor.flat<int64_t>();\n    auto width_seq_tensor_flat = width_seq_tensor.flat<int64_t>();\n\n    \/\/ Now walk through the process of fractional max pooling again.\n    \/\/ For both input and output,\n    \/\/ 0: batch\n    \/\/ 1: height \/ row\n    \/\/ 2: width \/ col\n    \/\/ 3: depth \/ channel\n    const int64_t height_max = input_size[1] - 1;\n    const int64_t width_max = input_size[2] - 1;\n    for (int64_t b = 0; b < input_size[0]; ++b) {\n      \/\/ height sequence.\n      for (int64_t hs = 0; hs < height_seq_tensor.dim_size(0) - 1; ++hs) {\n        \/\/ height start and end.\n        const int64_t height_start = height_seq_tensor_flat(hs);\n        int64_t height_end = overlapping_ ? height_seq_tensor_flat(hs + 1)\n                                          : height_seq_tensor_flat(hs + 1) - 1;\n        height_end = std::min(height_end, height_max);\n\n        \/\/ width sequence.\n        for (int64_t ws = 0; ws < width_seq_tensor.dim_size(0) - 1; ++ws) {\n          const int64_t out_index =\n              (b * output_size[1] + hs) * output_size[2] + ws;\n          \/\/ width start and end.\n          const int64_t width_start = width_seq_tensor_flat(ws);\n          int64_t width_end = overlapping_ ? width_seq_tensor_flat(ws + 1)\n                                           : width_seq_tensor_flat(ws + 1) - 1;\n          width_end = std::min(width_end, width_max);\n          for (int64_t h = height_start; h <= height_end; ++h) {\n            for (int64_t w = width_start; w <= width_end; ++w) {\n              const int64_t in_index =\n                  (b * input_size[1] + h) * input_size[2] + w;\n              \/\/ Walk through each channel (depth).\n              for (int64_t d = 0; d < input_size[3]; ++d) {\n                const T& input_ref = tensor_in_mat.coeffRef(d, in_index);\n                T& output_ref = tensor_out_dup_mat.coeffRef(d, out_index);\n                int64_t& out_arg_max_ref =\n                    tensor_out_arg_max_mat.coeffRef(d, out_index);\n                if (output_ref < input_ref ||\n                    out_arg_max_ref == kInvalidMaxPoolingIndex) {\n                  output_ref = input_ref;\n                  int input_offset = in_index * input_size[3] + d;\n                  out_arg_max_ref = input_offset;\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n\n    \/\/ Check tensor_out_dup is the same as tensor_out.\n    ConstEigenMatrixMap tensor_out_mat(\n        tensor_out.flat<T>().data(), output_size[3],\n        output_size[2] * output_size[1] * output_size[0]);\n    const int64_t num_reshaped_cols =\n        output_size[2] * output_size[1] * output_size[0];\n    for (int64_t i = 0; i < num_reshaped_cols; ++i) {\n      for (int64_t j = 0; j < output_size[3]; ++j) {\n        DCHECK_EQ(tensor_out_dup_mat(j, i), tensor_out_mat(j, i));\n      }\n    }\n\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(\n                                {0}, 0, tensor_in.shape(), &output));\n    output->flat<T>().setZero();\n\n    auto out_backprop_flat = out_backprop.flat<T>();\n    auto input_backprop_flat = output->flat<T>();\n    auto out_arg_max_flat = tensor_out_arg_max.flat<int64_t>();\n    int num_total_outputs = out_backprop_flat.size();\n    int num_total_inputs = input_backprop_flat.size();\n\n    for (int index = 0; index < num_total_outputs; ++index) {\n      int input_backprop_index = out_arg_max_flat(index);\n      \/\/ According to maxpooling_op.cc, the performance impact below is small.\n      CHECK(input_backprop_index >= 0 &&\n            input_backprop_index < num_total_inputs)\n          << \"Invalid input backprop index: \" << input_backprop_index << \", \"\n          << num_total_inputs;\n      input_backprop_flat(input_backprop_index) += out_backprop_flat(index);\n    }\n  }","target":0,"code_token_length":1836,"total_token_length":2072,"max_tokens_setting":4096}
+{"idx":447068,"func":"    void FileIo::transfer(BasicIo& src)\n    {\n        const bool wasOpen = (p_->fp_ != 0);\n        const std::string lastMode(p_->openMode_);\n\n        FileIo *fileIo = dynamic_cast<FileIo*>(&src);\n        if (fileIo) {\n            \/\/ Optimization if src is another instance of FileIo\n            fileIo->close();\n            \/\/ Check if the file can be written to, if it already exists\n            if (open(\"a+b\") != 0) {\n                \/\/ Remove the (temporary) file\n#ifdef EXV_UNICODE_PATH\n                if (fileIo->p_->wpMode_ == Impl::wpUnicode) {\n                    ::_wremove(fileIo->wpath().c_str());\n                }\n                else\n#endif\n                {\n                    ::remove(fileIo->path().c_str());\n                }\n#ifdef EXV_UNICODE_PATH\n                if (p_->wpMode_ == Impl::wpUnicode) {\n                    throw WError(10, wpath(), \"a+b\", strError().c_str());\n                }\n                else\n#endif\n                {\n                    throw Error(10, path(), \"a+b\", strError());\n                }\n            }\n            close();\n\n            bool statOk = true;\n            mode_t origStMode = 0;\n            std::string spf;\n            char* pf = 0;\n#ifdef EXV_UNICODE_PATH\n            std::wstring wspf;\n            wchar_t* wpf = 0;\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                wspf = wpath();\n                wpf = const_cast<wchar_t*>(wspf.c_str());\n            }\n            else\n#endif\n            {\n                spf = path();\n                pf = const_cast<char*>(spf.c_str());\n            }\n\n            \/\/ Get the permissions of the file, or linked-to file, on platforms which have lstat\n#ifdef EXV_HAVE_LSTAT\n\n# ifdef EXV_UNICODE_PATH\n#  error EXV_UNICODE_PATH and EXV_HAVE_LSTAT are not compatible. Stop.\n# endif\n            struct stat buf1;\n            if (::lstat(pf, &buf1) == -1) {\n                statOk = false;\n#ifndef SUPPRESS_WARNINGS\n                EXV_WARNING << Error(2, pf, strError(), \"::lstat\") << \"\\n\";\n#endif\n            }\n            origStMode = buf1.st_mode;\n            DataBuf lbuf; \/\/ So that the allocated memory is freed. Must have same scope as pf\n            \/\/ In case path() is a symlink, get the path of the linked-to file\n            if (statOk && S_ISLNK(buf1.st_mode)) {\n                lbuf.alloc(buf1.st_size + 1);\n                memset(lbuf.pData_, 0x0, lbuf.size_);\n                pf = reinterpret_cast<char*>(lbuf.pData_);\n                if (::readlink(path().c_str(), pf, lbuf.size_ - 1) == -1) {\n                    throw Error(2, path(), strError(), \"readlink\");\n                }\n                \/\/ We need the permissions of the file, not the symlink\n                if (::stat(pf, &buf1) == -1) {\n                    statOk = false;\n#ifndef SUPPRESS_WARNINGS\n                    EXV_WARNING << Error(2, pf, strError(), \"::stat\") << \"\\n\";\n#endif\n                }\n                origStMode = buf1.st_mode;\n            }\n#else \/\/ EXV_HAVE_LSTAT\n            Impl::StructStat buf1;\n            if (p_->stat(buf1) == -1) {\n                statOk = false;\n            }\n            origStMode = buf1.st_mode;\n#endif \/\/ !EXV_HAVE_LSTAT\n\n            \/\/ MSVCRT rename that does not overwrite existing files\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n#if defined(WIN32) && defined(REPLACEFILE_IGNORE_MERGE_ERRORS)\n                \/\/ Windows implementation that deals with the fact that ::rename fails\n                \/\/ if the target filename still exists, which regularly happens when\n                \/\/ that file has been opened with FILE_SHARE_DELETE by another process,\n                \/\/ like a virus scanner or disk indexer\n                \/\/ (see also http:\/\/stackoverflow.com\/a\/11023068)\n                typedef BOOL (WINAPI * ReplaceFileW_t)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);\n                HMODULE hKernel = ::GetModuleHandleA(\"kernel32.dll\");\n                if (hKernel) {\n                    ReplaceFileW_t pfcn_ReplaceFileW = (ReplaceFileW_t)GetProcAddress(hKernel, \"ReplaceFileW\");\n                    if (pfcn_ReplaceFileW) {\n                        BOOL ret = pfcn_ReplaceFileW(wpf, fileIo->wpath().c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL);\n                        if (ret == 0) {\n                            if (GetLastError() == ERROR_FILE_NOT_FOUND) {\n                                if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) {\n                                    throw WError(17, fileIo->wpath(), wpf, strError().c_str());\n                                }\n                                ::_wremove(fileIo->wpath().c_str());\n                            }\n                            else {\n                                throw WError(17, fileIo->wpath(), wpf, strError().c_str());\n                            }\n                        }\n                    }\n                    else {\n                        if (fileExists(wpf) && ::_wremove(wpf) != 0) {\n                            throw WError(2, wpf, strError().c_str(), \"::_wremove\");\n                        }\n                        if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) {\n                            throw WError(17, fileIo->wpath(), wpf, strError().c_str());\n                        }\n                        ::_wremove(fileIo->wpath().c_str());\n                    }\n                }\n#else\n                if (fileExists(wpf) && ::_wremove(wpf) != 0) {\n                    throw WError(2, wpf, strError().c_str(), \"::_wremove\");\n                }\n                if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) {\n                    throw WError(17, fileIo->wpath(), wpf, strError().c_str());\n                }\n                ::_wremove(fileIo->wpath().c_str());\n#endif\n                \/\/ Check permissions of new file\n                struct _stat buf2;\n                if (statOk && ::_wstat(wpf, &buf2) == -1) {\n                    statOk = false;\n#ifndef SUPPRESS_WARNINGS\n                    EXV_WARNING << Error(2, wpf, strError(), \"::_wstat\") << \"\\n\";\n#endif\n                }\n                if (statOk && origStMode != buf2.st_mode) {\n                    \/\/ Set original file permissions\n                    if (::_wchmod(wpf, origStMode) == -1) {\n#ifndef SUPPRESS_WARNINGS\n                        EXV_WARNING << Error(2, wpf, strError(), \"::_wchmod\") << \"\\n\";\n#endif\n                    }\n                }\n            } \/\/ if (p_->wpMode_ == Impl::wpUnicode)\n            else\n#endif \/\/ EXV_UNICODE_PATH\n            {\n#if defined(WIN32) && defined(REPLACEFILE_IGNORE_MERGE_ERRORS)\n                \/\/ Windows implementation that deals with the fact that ::rename fails\n                \/\/ if the target filename still exists, which regularly happens when\n                \/\/ that file has been opened with FILE_SHARE_DELETE by another process,\n                \/\/ like a virus scanner or disk indexer\n                \/\/ (see also http:\/\/stackoverflow.com\/a\/11023068)\n                typedef BOOL (WINAPI * ReplaceFileA_t)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);\n                HMODULE hKernel = ::GetModuleHandleA(\"kernel32.dll\");\n                if (hKernel) {\n                    ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, \"ReplaceFileA\");\n                    if (pfcn_ReplaceFileA) {\n                        BOOL ret = pfcn_ReplaceFileA(pf, fileIo->path().c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL);\n                        if (ret == 0) {\n                            if (GetLastError() == ERROR_FILE_NOT_FOUND) {\n                                if (::rename(fileIo->path().c_str(), pf) == -1) {\n                                    throw Error(17, fileIo->path(), pf, strError());\n                                }\n                                ::remove(fileIo->path().c_str());\n                            }\n                            else {\n                                throw Error(17, fileIo->path(), pf, strError());\n                            }\n                        }\n                    }\n                    else {\n                        if (fileExists(pf) && ::remove(pf) != 0) {\n                            throw Error(2, pf, strError(), \"::remove\");\n                        }\n                        if (::rename(fileIo->path().c_str(), pf) == -1) {\n                            throw Error(17, fileIo->path(), pf, strError());\n                        }\n                        ::remove(fileIo->path().c_str());\n                    }\n                }\n#else\n                if (fileExists(pf) && ::remove(pf) != 0) {\n                    throw Error(2, pf, strError(), \"::remove\");\n                }\n                if (::rename(fileIo->path().c_str(), pf) == -1) {\n                    throw Error(17, fileIo->path(), pf, strError());\n                }\n                ::remove(fileIo->path().c_str());\n#endif\n                \/\/ Check permissions of new file\n                struct stat buf2;\n                if (statOk && ::stat(pf, &buf2) == -1) {\n                    statOk = false;\n#ifndef SUPPRESS_WARNINGS\n                    EXV_WARNING << Error(2, pf, strError(), \"::stat\") << \"\\n\";\n#endif\n                }\n                if (statOk && origStMode != buf2.st_mode) {\n                    \/\/ Set original file permissions\n                    if (::chmod(pf, origStMode) == -1) {\n#ifndef SUPPRESS_WARNINGS\n                        EXV_WARNING << Error(2, pf, strError(), \"::chmod\") << \"\\n\";\n#endif\n                    }\n                }\n            }\n        } \/\/ if (fileIo)\n        else {\n            \/\/ Generic handling, reopen both to reset to start\n            if (open(\"w+b\") != 0) {\n#ifdef EXV_UNICODE_PATH\n                if (p_->wpMode_ == Impl::wpUnicode) {\n                    throw WError(10, wpath(), \"w+b\", strError().c_str());\n                }\n                else\n#endif\n                {\n                    throw Error(10, path(), \"w+b\", strError());\n                }\n            }\n            if (src.open() != 0) {\n#ifdef EXV_UNICODE_PATH\n                if (p_->wpMode_ == Impl::wpUnicode) {\n                    throw WError(9, src.wpath(), strError().c_str());\n                }\n                else\n#endif\n                {\n                    throw Error(9, src.path(), strError());\n                }\n            }\n            write(src);\n            src.close();\n        }\n\n        if (wasOpen) {\n            if (open(lastMode) != 0) {\n#ifdef EXV_UNICODE_PATH\n                if (p_->wpMode_ == Impl::wpUnicode) {\n                    throw WError(10, wpath(), lastMode.c_str(), strError().c_str());\n                }\n                else\n#endif\n                {\n                    throw Error(10, path(), lastMode, strError());\n                }\n            }\n        }\n        else close();\n\n        if (error() || src.error()) {\n#ifdef EXV_UNICODE_PATH\n            if (p_->wpMode_ == Impl::wpUnicode) {\n                throw WError(18, wpath(), strError().c_str());\n            }\n            else\n#endif\n            {\n                throw Error(18, path(), strError());\n            }\n        }\n    } \/\/ FileIo::transfer","target":0,"code_token_length":2540,"total_token_length":2776,"max_tokens_setting":4096}
+{"idx":439090,"func":"static MagickBooleanType WriteYUVImage(const ImageInfo *image_info,Image *image)\n{\n  Image\n    *chroma_image,\n    *yuv_image;\n\n  InterlaceType\n    interlace;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  register const PixelPacket\n    *p,\n    *s;\n\n  register ssize_t\n    x;\n\n  size_t\n    height,\n    imageListLength,\n    quantum,\n    width;\n\n  ssize_t\n    horizontal_factor,\n    vertical_factor,\n    y;\n\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  quantum=(size_t) (image->depth <= 8 ? 1 : 2);\n  interlace=image->interlace;\n  horizontal_factor=2;\n  vertical_factor=2;\n  if (image_info->sampling_factor != (char *) NULL)\n    {\n      GeometryInfo\n        geometry_info;\n\n      MagickStatusType\n        flags;\n\n      flags=ParseGeometry(image_info->sampling_factor,&geometry_info);\n      horizontal_factor=(ssize_t) geometry_info.rho;\n      vertical_factor=(ssize_t) geometry_info.sigma;\n      if ((flags & SigmaValue) == 0)\n        vertical_factor=horizontal_factor;\n      if ((horizontal_factor != 1) && (horizontal_factor != 2) &&\n          (vertical_factor != 1) && (vertical_factor != 2))\n        ThrowWriterException(CorruptImageError,\"UnexpectedSamplingFactor\");\n    }\n  if ((interlace == UndefinedInterlace) ||\n      ((interlace == NoInterlace) && (vertical_factor == 2)))\n    {\n      interlace=NoInterlace;    \/* CCIR 4:2:2 *\/\n      if (vertical_factor == 2)\n        interlace=PlaneInterlace; \/* CCIR 4:1:1 *\/\n    }\n  if (interlace != PartitionInterlace)\n    {\n      \/*\n        Open output image file.\n      *\/\n      status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n      if (status == MagickFalse)\n        return(status);\n    }\n  else\n    {\n      AppendImageFormat(\"Y\",image->filename);\n      status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n      if (status == MagickFalse)\n        return(status);\n    }\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    \/*\n      Sample image to an even width and height, if necessary.\n    *\/\n    image->depth=(size_t) (quantum == 1 ? 8 : 16);\n    width=image->columns+(image->columns & (horizontal_factor-1));\n    height=image->rows+(image->rows & (vertical_factor-1));\n    yuv_image=ResizeImage(image,width,height,TriangleFilter,1.0,\n      &image->exception);\n    if (yuv_image == (Image *) NULL)\n      ThrowWriterException(ResourceLimitError,image->exception.reason);\n    (void) TransformImageColorspace(yuv_image,YCbCrColorspace);\n    \/*\n      Downsample image.\n    *\/\n    chroma_image=ResizeImage(image,width\/horizontal_factor,\n      height\/vertical_factor,TriangleFilter,1.0,&image->exception);\n    if (chroma_image == (Image *) NULL)\n      ThrowWriterException(ResourceLimitError,image->exception.reason);\n    (void) TransformImageColorspace(chroma_image,YCbCrColorspace);\n    if (interlace == NoInterlace)\n      {\n        \/*\n          Write noninterlaced YUV.\n        *\/\n        for (y=0; y < (ssize_t) yuv_image->rows; y++)\n        {\n          p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1,\n            &yuv_image->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          s=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,\n            &chroma_image->exception);\n          if (s == (const PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) yuv_image->columns; x+=2)\n          {\n            if (quantum == 1)\n              {\n                (void) WriteBlobByte(image,ScaleQuantumToChar(\n                  GetPixelGreen(s)));\n                (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelRed(p)));\n                p++;\n                (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelBlue(s)));\n                (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelRed(p)));\n              }\n            else\n              {\n                (void) WriteBlobByte(image,ScaleQuantumToChar(\n                  GetPixelGreen(s)));\n                (void) WriteBlobShort(image,ScaleQuantumToShort(\n                  GetPixelRed(p)));\n                p++;\n                (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelBlue(s)));\n                (void) WriteBlobShort(image,ScaleQuantumToShort(\n                  GetPixelRed(p)));\n              }\n            p++;\n            s++;\n          }\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        yuv_image=DestroyImage(yuv_image);\n      }\n    else\n      {\n        \/*\n          Initialize Y channel.\n        *\/\n        for (y=0; y < (ssize_t) yuv_image->rows; y++)\n        {\n          p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1,\n            &yuv_image->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) yuv_image->columns; x++)\n          {\n            if (quantum == 1)\n              (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelRed(p)));\n            else\n              (void) WriteBlobShort(image,ScaleQuantumToShort(GetPixelRed(p)));\n            p++;\n          }\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        yuv_image=DestroyImage(yuv_image);\n        if (image->previous == (Image *) NULL)\n          {\n            status=SetImageProgress(image,SaveImageTag,1,3);\n            if (status == MagickFalse)\n              break;\n          }\n        \/*\n          Initialize U channel.\n        *\/\n        if (interlace == PartitionInterlace)\n          {\n            (void) CloseBlob(image);\n            AppendImageFormat(\"U\",image->filename);\n            status=OpenBlob(image_info,image,WriteBinaryBlobMode,\n              &image->exception);\n            if (status == MagickFalse)\n              return(status);\n          }\n        for (y=0; y < (ssize_t) chroma_image->rows; y++)\n        {\n          p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,\n            &chroma_image->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) chroma_image->columns; x++)\n          {\n            if (quantum == 1)\n              (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelGreen(p)));\n            else\n              (void) WriteBlobShort(image,ScaleQuantumToShort(\n                GetPixelGreen(p)));\n            p++;\n          }\n        }\n        if (image->previous == (Image *) NULL)\n          {\n            status=SetImageProgress(image,SaveImageTag,2,3);\n            if (status == MagickFalse)\n              break;\n          }\n        \/*\n          Initialize V channel.\n        *\/\n        if (interlace == PartitionInterlace)\n          {\n            (void) CloseBlob(image);\n            AppendImageFormat(\"V\",image->filename);\n            status=OpenBlob(image_info,image,WriteBinaryBlobMode,\n              &image->exception);\n            if (status == MagickFalse)\n              return(status);\n          }\n        for (y=0; y < (ssize_t) chroma_image->rows; y++)\n        {\n          p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,\n            &chroma_image->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) chroma_image->columns; x++)\n          {\n            if (quantum == 1)\n              (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelBlue(p)));\n            else\n              (void) WriteBlobShort(image,ScaleQuantumToShort(GetPixelBlue(p)));\n            p++;\n          }\n        }\n        if (image->previous == (Image *) NULL)\n          {\n            status=SetImageProgress(image,SaveImageTag,2,3);\n            if (status == MagickFalse)\n              break;\n          }\n      }\n    chroma_image=DestroyImage(chroma_image);\n    if (interlace == PartitionInterlace)\n      (void) CopyMagickString(image->filename,image_info->filename,\n        MaxTextExtent);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":2132,"total_token_length":2368,"max_tokens_setting":4096}
+{"idx":216938,"func":"bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)\n{\n  TABLE *table;\n  const char *key;\n  uint\tkey_length;\n  const char *alias= table_list->alias.str;\n  uint flags= ot_ctx->get_flags();\n  MDL_ticket *mdl_ticket;\n  TABLE_SHARE *share;\n  uint gts_flags;\n  bool from_share= false;\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n  int part_names_error=0;\n#endif\n  DBUG_ENTER(\"open_table\");\n\n  \/*\n    The table must not be opened already. The table can be pre-opened for\n    some statements if it is a temporary table.\n\n    open_temporary_table() must be used to open temporary tables.\n  *\/\n  DBUG_ASSERT(!table_list->table);\n\n  \/* an open table operation needs a lot of the stack space *\/\n  if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias))\n    DBUG_RETURN(TRUE);\n\n  if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed)\n  {\n    thd->send_kill_message();\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Check if we're trying to take a write lock in a read only transaction.\n\n    Note that we allow write locks on log tables as otherwise logging\n    to general\/slow log would be disabled in read only transactions.\n  *\/\n  if (table_list->mdl_request.is_write_lock_request() &&\n      thd->tx_read_only &&\n      !(flags & (MYSQL_LOCK_LOG_TABLE | MYSQL_OPEN_HAS_MDL_LOCK)))\n  {\n    my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0));\n    DBUG_RETURN(true);\n  }\n\n  if (!table_list->db.str)\n  {\n    my_error(ER_NO_DB_ERROR, MYF(0));\n    DBUG_RETURN(true);\n  }\n\n  key_length= get_table_def_key(table_list, &key);\n\n  \/*\n    If we're in pre-locked or LOCK TABLES mode, let's try to find the\n    requested table in the list of pre-opened and locked tables. If the\n    table is not there, return an error - we can't open not pre-opened\n    tables in pre-locked\/LOCK TABLES mode.\n    TODO: move this block into a separate function.\n  *\/\n  if (thd->locked_tables_mode &&\n      ! (flags & MYSQL_OPEN_GET_NEW_TABLE))\n  {\t\t\t\t\t\t\/\/ Using table locks\n    TABLE *best_table= 0;\n    int best_distance= INT_MIN;\n    for (table=thd->open_tables; table ; table=table->next)\n    {\n      if (table->s->table_cache_key.length == key_length &&\n\t  !memcmp(table->s->table_cache_key.str, key, key_length))\n      {\n        if (!my_strcasecmp(system_charset_info, table->alias.c_ptr(), alias) &&\n            table->query_id != thd->query_id && \/* skip tables already used *\/\n            (thd->locked_tables_mode == LTM_LOCK_TABLES ||\n             table->query_id == 0))\n        {\n          int distance= ((int) table->reginfo.lock_type -\n                         (int) table_list->lock_type);\n\n          \/*\n            Find a table that either has the exact lock type requested,\n            or has the best suitable lock. In case there is no locked\n            table that has an equal or higher lock than requested,\n            we us the closest matching lock to be able to produce an error\n            message about wrong lock mode on the table. The best_table\n            is changed if bd < 0 <= d or bd < d < 0 or 0 <= d < bd.\n\n            distance <  0 - No suitable lock found\n            distance >  0 - we have lock mode higher then we require\n            distance == 0 - we have lock mode exactly which we need\n          *\/\n          if ((best_distance < 0 && distance > best_distance) ||\n              (distance >= 0 && distance < best_distance))\n          {\n            best_distance= distance;\n            best_table= table;\n            if (best_distance == 0)\n            {\n              \/*\n                We have found a perfect match and can finish iterating\n                through open tables list. Check for table use conflict\n                between calling statement and SP\/trigger is done in\n                lock_tables().\n              *\/\n              break;\n            }\n          }\n        }\n      }\n    }\n    if (best_table)\n    {\n      table= best_table;\n      table->query_id= thd->query_id;\n      table->init(thd, table_list);\n      DBUG_PRINT(\"info\",(\"Using locked table\"));\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n      part_names_error= set_partitions_as_used(table_list, table);\n#endif\n      goto reset;\n    }\n\n    if (is_locked_view(thd, table_list))\n    {\n      if (table_list->sequence)\n      {\n        my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str);\n        DBUG_RETURN(true);\n      }\n      DBUG_RETURN(FALSE); \/\/ VIEW\n    }\n\n    \/*\n      No table in the locked tables list. In case of explicit LOCK TABLES\n      this can happen if a user did not include the table into the list.\n      In case of pre-locked mode locked tables list is generated automatically,\n      so we may only end up here if the table did not exist when\n      locked tables list was created.\n    *\/\n    if (thd->locked_tables_mode == LTM_PRELOCKED)\n      my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str);\n    else\n      my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias);\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Non pre-locked\/LOCK TABLES mode, and the table is not temporary.\n    This is the normal use case.\n  *\/\n\n  if (! (flags & MYSQL_OPEN_HAS_MDL_LOCK))\n  {\n    \/*\n      We are not under LOCK TABLES and going to acquire write-lock\/\n      modify the base table. We need to acquire protection against\n      global read lock until end of this statement in order to have\n      this statement blocked by active FLUSH TABLES WITH READ LOCK.\n\n      We don't need to acquire this protection under LOCK TABLES as\n      such protection already acquired at LOCK TABLES time and\n      not released until UNLOCK TABLES.\n\n      We don't block statements which modify only temporary tables\n      as these tables are not preserved by any form of\n      backup which uses FLUSH TABLES WITH READ LOCK.\n\n      TODO: The fact that we sometimes acquire protection against\n            GRL only when we encounter table to be write-locked\n            slightly increases probability of deadlock.\n            This problem will be solved once Alik pushes his\n            temporary table refactoring patch and we can start\n            pre-acquiring metadata locks at the beggining of\n            open_tables() call.\n    *\/\n    if (table_list->mdl_request.is_write_lock_request() &&\n        ! (flags & (MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |\n                    MYSQL_OPEN_FORCE_SHARED_MDL |\n                    MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |\n                    MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) &&\n        ! ot_ctx->has_protection_against_grl())\n    {\n      MDL_request protection_request;\n      MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);\n\n      if (thd->global_read_lock.can_acquire_protection())\n        DBUG_RETURN(TRUE);\n\n      protection_request.init(MDL_key::GLOBAL, \"\", \"\", MDL_INTENTION_EXCLUSIVE,\n                              MDL_STATEMENT);\n\n      \/*\n        Install error handler which if possible will convert deadlock error\n        into request to back-off and restart process of opening tables.\n      *\/\n      thd->push_internal_handler(&mdl_deadlock_handler);\n      bool result= thd->mdl_context.acquire_lock(&protection_request,\n                                                 ot_ctx->get_timeout());\n      thd->pop_internal_handler();\n\n      if (result)\n        DBUG_RETURN(TRUE);\n\n      ot_ctx->set_has_protection_against_grl();\n    }\n\n    if (open_table_get_mdl_lock(thd, ot_ctx, &table_list->mdl_request,\n                                flags, &mdl_ticket) ||\n        mdl_ticket == NULL)\n    {\n      DEBUG_SYNC(thd, \"before_open_table_wait_refresh\");\n      DBUG_RETURN(TRUE);\n    }\n    DEBUG_SYNC(thd, \"after_open_table_mdl_shared\");\n  }\n  else\n  {\n    \/*\n      Grab reference to the MDL lock ticket that was acquired\n      by the caller.\n    *\/\n    mdl_ticket= table_list->mdl_request.ticket;\n  }\n\n  if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS)\n  {\n    if (!ha_table_exists(thd, &table_list->db, &table_list->table_name))\n      DBUG_RETURN(FALSE);\n  }\n  else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB)\n    DBUG_RETURN(FALSE);\n\n  \/* Table exists. Let us try to open it. *\/\n\n  if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)\n    gts_flags= GTS_TABLE;\n  else if (table_list->i_s_requested_object &  OPEN_VIEW_ONLY)\n    gts_flags= GTS_VIEW;\n  else\n    gts_flags= GTS_TABLE | GTS_VIEW;\n\nretry_share:\n\n  share= tdc_acquire_share(thd, table_list, gts_flags, &table);\n\n  if (unlikely(!share))\n  {\n    \/*\n      Hide \"Table doesn't exist\" errors if the table belongs to a view.\n      The check for thd->is_error() is necessary to not push an\n      unwanted error in case the error was already silenced.\n      @todo Rework the alternative ways to deal with ER_NO_SUCH TABLE.\n    *\/\n    if (thd->is_error())\n    {\n      if (table_list->parent_l)\n      {\n        thd->clear_error();\n        my_error(ER_WRONG_MRG_TABLE, MYF(0));\n      }\n      else if (table_list->belong_to_view)\n      {\n        TABLE_LIST *view= table_list->belong_to_view;\n        thd->clear_error();\n        my_error(ER_VIEW_INVALID, MYF(0),\n                 view->view_db.str, view->view_name.str);\n      }\n    }\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Check if this TABLE_SHARE-object corresponds to a view. Note, that there is\n    no need to check TABLE_SHARE::tdc.flushed as we do for regular tables,\n    because view shares are always up to date.\n  *\/\n  if (share->is_view)\n  {\n    \/*\n      If parent_l of the table_list is non null then a merge table\n      has this view as child table, which is not supported.\n    *\/\n    if (table_list->parent_l)\n    {\n      my_error(ER_WRONG_MRG_TABLE, MYF(0));\n      goto err_lock;\n    }\n    if (table_list->sequence)\n    {\n      my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str,\n               table_list->alias.str);\n      goto err_lock;\n    }\n    \/*\n      This table is a view. Validate its metadata version: in particular,\n      that it was a view when the statement was prepared.\n    *\/\n    if (check_and_update_table_version(thd, table_list, share))\n      goto err_lock;\n\n    \/* Open view *\/\n    if (mysql_make_view(thd, share, table_list, false))\n      goto err_lock;\n\n\n    \/* TODO: Don't free this *\/\n    tdc_release_share(share);\n\n    DBUG_ASSERT(table_list->view);\n\n    DBUG_RETURN(FALSE);\n  }\n\n#ifdef WITH_WSREP\n  if (!((flags & MYSQL_OPEN_IGNORE_FLUSH) ||\n        (thd->wsrep_applier)))\n#else\n  if (!(flags & MYSQL_OPEN_IGNORE_FLUSH))\n#endif\n  {\n    if (share->tdc->flushed)\n    {\n      DBUG_PRINT(\"info\", (\"Found old share version: %lld  current: %lld\",\n                          share->tdc->version, tdc_refresh_version()));\n      \/*\n        We already have an MDL lock. But we have encountered an old\n        version of table in the table definition cache which is possible\n        when someone changes the table version directly in the cache\n        without acquiring a metadata lock (e.g. this can happen during\n        \"rolling\" FLUSH TABLE(S)).\n        Release our reference to share, wait until old version of\n        share goes away and then try to get new version of table share.\n      *\/\n      if (table)\n        tc_release_table(table);\n      else\n        tdc_release_share(share);\n\n      MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);\n      bool wait_result;\n\n      thd->push_internal_handler(&mdl_deadlock_handler);\n      wait_result= tdc_wait_for_old_version(thd, table_list->db.str,\n                                            table_list->table_name.str,\n                                            ot_ctx->get_timeout(),\n                                            mdl_ticket->get_deadlock_weight());\n      thd->pop_internal_handler();\n\n      if (wait_result)\n        DBUG_RETURN(TRUE);\n\n      goto retry_share;\n    }\n\n    if (thd->open_tables && thd->open_tables->s->tdc->flushed)\n    {\n      \/*\n        If the version changes while we're opening the tables,\n        we have to back off, close all the tables opened-so-far,\n        and try to reopen them. Note: refresh_version is currently\n        changed only during FLUSH TABLES.\n      *\/\n      if (table)\n        tc_release_table(table);\n      else\n        tdc_release_share(share);\n      (void)ot_ctx->request_backoff_action(Open_table_context::OT_REOPEN_TABLES,\n                                           NULL);\n      DBUG_RETURN(TRUE);\n    }\n  }\n\n  if (table)\n  {\n    DBUG_ASSERT(table->file != NULL);\n    MYSQL_REBIND_TABLE(table->file);\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n    part_names_error= set_partitions_as_used(table_list, table);\n#endif\n  }\n  else\n  {\n    enum open_frm_error error;\n\n    \/* make a new table *\/\n    if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))\n      goto err_lock;\n\n    error= open_table_from_share(thd, share, &table_list->alias,\n                                 HA_OPEN_KEYFILE | HA_TRY_READ_ONLY,\n                                 EXTRA_RECORD,\n                                 thd->open_options, table, FALSE,\n                                 IF_PARTITIONING(table_list->partition_names,0));\n\n    if (unlikely(error))\n    {\n      my_free(table);\n\n      if (error == OPEN_FRM_DISCOVER)\n        (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER,\n                                              table_list);\n      else if (share->crashed)\n      {\n        if (!(flags & MYSQL_OPEN_IGNORE_REPAIR))\n          (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR,\n                                                table_list);\n        else\n          table_list->crashed= 1;  \/* Mark that table was crashed *\/\n      }\n      goto err_lock;\n    }\n    if (open_table_entry_fini(thd, share, table))\n    {\n      closefrm(table);\n      my_free(table);\n      goto err_lock;\n    }\n\n    \/* Add table to the share's used tables list. *\/\n    tc_add_table(thd, table);\n    from_share= true;\n  }\n\n  table->mdl_ticket= mdl_ticket;\n  table->reginfo.lock_type=TL_READ;\t\t\/* Assume read *\/\n\n  table->init(thd, table_list);\n\n  table->next= thd->open_tables;\t\t\/* Link into simple list *\/\n  thd->set_open_tables(table);\n\n reset:\n  \/*\n    Check that there is no reference to a condition from an earlier query\n    (cf. Bug#58553). \n  *\/\n  DBUG_ASSERT(table->file->pushed_cond == NULL);\n  table_list->updatable= 1; \/\/ It is not derived table nor non-updatable VIEW\n  table_list->table= table;\n\n  if (!from_share && table->vcol_fix_expr(thd))\n    goto err_lock;\n\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n  if (unlikely(table->part_info))\n  {\n    \/* Partitions specified were incorrect.*\/\n    if (part_names_error)\n    {\n      table->file->print_error(part_names_error, MYF(0));\n      DBUG_RETURN(true);\n    }\n  }\n  else if (table_list->partition_names)\n  {\n    \/* Don't allow PARTITION () clause on a nonpartitioned table *\/\n    my_error(ER_PARTITION_CLAUSE_ON_NONPARTITIONED, MYF(0));\n    DBUG_RETURN(true);\n  }\n#endif\n  if (table_list->sequence && table->s->table_type != TABLE_TYPE_SEQUENCE)\n  {\n    my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str);\n    DBUG_RETURN(true);\n  }\n\n  DBUG_RETURN(FALSE);\n\nerr_lock:\n  tdc_release_share(share);\n\n  DBUG_PRINT(\"exit\", (\"failed\"));\n  DBUG_RETURN(TRUE);\n}","target":1,"code_token_length":3628,"total_token_length":3864,"max_tokens_setting":4096}
+{"idx":225986,"func":"\nstatic void *sgpd_parse_entry(u32 grouping_type, GF_BitStream *bs, s32 bytes_in_box, u32 entry_size, u32 *total_bytes)\n{\n\tBool null_size_ok = GF_FALSE;\n\tGF_DefaultSampleGroupDescriptionEntry *def_ptr;\n\n\tswitch (grouping_type) {\n\tcase GF_ISOM_SAMPLE_GROUP_ROLL:\n\tcase GF_ISOM_SAMPLE_GROUP_PROL:\n\t{\n\t\tGF_RollRecoveryEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_RollRecoveryEntry);\n\t\tif (!ptr) return NULL;\n\t\tptr->roll_distance = gf_bs_read_int(bs, 16);\n\t\t*total_bytes = 2;\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_RAP:\n\t{\n\t\tGF_VisualRandomAccessEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_VisualRandomAccessEntry);\n\t\tif (!ptr) return NULL;\n\t\tptr->num_leading_samples_known = gf_bs_read_int(bs, 1);\n\t\tptr->num_leading_samples = gf_bs_read_int(bs, 7);\n\t\t*total_bytes = 1;\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_SAP:\n\t{\n\t\tGF_SAPEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_SAPEntry);\n\t\tif (!ptr) return NULL;\n\t\tptr->dependent_flag = gf_bs_read_int(bs, 1);\n\t\tgf_bs_read_int(bs, 3);\n\t\tptr->SAP_type = gf_bs_read_int(bs, 4);\n\t\t*total_bytes = 1;\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_SYNC:\n\t{\n\t\tGF_SYNCEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_SYNCEntry);\n\t\tif (!ptr) return NULL;\n\t\tgf_bs_read_int(bs, 2);\n\t\tptr->NALU_type = gf_bs_read_int(bs, 6);\n\t\t*total_bytes = 1;\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_TELE:\n\t{\n\t\tGF_TemporalLevelEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_TemporalLevelEntry);\n\t\tif (!ptr) return NULL;\n\t\tptr->level_independently_decodable = gf_bs_read_int(bs, 1);\n\t\tgf_bs_read_int(bs, 7);\n\t\t*total_bytes = 1;\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_SEIG:\n\t{\n\t\tGF_CENCSampleEncryptionGroupEntry *ptr;\n\t\tif (bytes_in_box<3) return NULL;\n\t\tGF_SAFEALLOC(ptr, GF_CENCSampleEncryptionGroupEntry);\n\t\tif (!ptr) return NULL;\n\t\tBool use_mkey = gf_bs_read_int(bs, 1);\n\t\tgf_bs_read_int(bs, 7); \/\/reserved\n\t\tptr->crypt_byte_block = gf_bs_read_int(bs, 4);\n\t\tptr->skip_byte_block = gf_bs_read_int(bs, 4);\n\t\tptr->IsProtected = gf_bs_read_u8(bs);\n\t\tbytes_in_box -= 3;\n\t\tif (use_mkey) {\n\t\t\tu64 pos = gf_bs_get_position(bs);\n\t\t\tu32 i, count = gf_bs_read_u16(bs);\n\t\t\tbytes_in_box -= 2;\n\t\t\tif (bytes_in_box<0) {\n\t\t\t\tgf_free(ptr);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tfor (i=0; i<count; i++) {\n\t\t\t\tu8 ivsize = gf_bs_read_u8(bs);\n\t\t\t\tgf_bs_skip_bytes(bs, 16);\n\t\t\t\tbytes_in_box -= 17;\n\t\t\t\tif (!ivsize) {\n\t\t\t\t\t\/\/const IV\n\t\t\t\t\tivsize = gf_bs_read_u8(bs);\n\t\t\t\t\tgf_bs_skip_bytes(bs, ivsize);\n\t\t\t\t\tbytes_in_box -= 1 + ivsize;\n\t\t\t\t}\n\t\t\t\tif (bytes_in_box<0) {\n\t\t\t\t\tgf_free(ptr);\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t\tptr->key_info_size = 1 + (u32) (gf_bs_get_position(bs) - pos);\n\t\t\tptr->key_info = gf_malloc(sizeof(u8) * ptr->key_info_size);\n\t\t\tif (!ptr->key_info) {\n\t\t\t\tgf_free(ptr);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tgf_bs_seek(bs, pos);\n\t\t\tptr->key_info[0] = 1;\n\t\t\tgf_bs_read_data(bs, ptr->key_info + 1, ptr->key_info_size - 1);\n\t\t\t*total_bytes = 3 + ptr->key_info_size - 1;\n\n\t\t\tif (!gf_cenc_validate_key_info(ptr->key_info, ptr->key_info_size)) {\n\t\t\t\tgf_free(ptr->key_info);\n\t\t\t\tgf_free(ptr);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t} else {\n\t\t\tbin128 kid;\n\t\t\tu8 const_iv_size = 0;\n\t\t\tu8 iv_size = gf_bs_read_u8(bs);\n\t\t\tgf_bs_read_data(bs, kid, 16);\n\t\t\tbytes_in_box -= 17;\n\t\t\tif (bytes_in_box<0) {\n\t\t\t\tgf_free(ptr);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\t*total_bytes = 20;\n\t\t\tif ((ptr->IsProtected == 1) && !iv_size) {\n\t\t\t\tconst_iv_size = gf_bs_read_u8(bs);\n\t\t\t\tif ((const_iv_size != 8) && (const_iv_size != 16)) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] seig sample group have invalid constant_IV size\\n\"));\n\t\t\t\t\tgf_free(ptr);\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t\tptr->key_info_size = 20;\n\t\t\tif (!iv_size && ptr->IsProtected) {\n\t\t\t\tptr->key_info_size += 1 + const_iv_size;\n\t\t\t}\n\t\t\tptr->key_info = gf_malloc(sizeof(u8) * ptr->key_info_size);\n\t\t\tif (!ptr->key_info) {\n\t\t\t\tgf_free(ptr);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tptr->key_info[0] = 0;\n\t\t\tptr->key_info[1] = 0;\n\t\t\tptr->key_info[2] = 0;\n\t\t\tptr->key_info[3] = iv_size;\n\t\t\tmemcpy(ptr->key_info+4, kid, 16);\n\t\t\tif (!iv_size && ptr->IsProtected) {\n\t\t\t\tptr->key_info[20] = const_iv_size;\n\t\t\t\tgf_bs_read_data(bs, (char *)ptr->key_info+21, const_iv_size);\n\t\t\t\t*total_bytes += 1 + const_iv_size;\n\t\t\t}\n\t\t}\n\n\t\tif (!entry_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] seig sample group does not indicate entry size, deprecated in spec\\n\"));\n\t\t}\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_OINF:\n\t{\n\t\tGF_OperatingPointsInformation *ptr = gf_isom_oinf_new_entry();\n\t\tu32 s = (u32) gf_bs_get_position(bs);\n\t\tgf_isom_oinf_read_entry(ptr, bs);\n\t\t*total_bytes = (u32) gf_bs_get_position(bs) - s;\n\t\tif (!entry_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] oinf sample group does not indicate entry size, deprecated in spec\\n\"));\n\t\t}\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_LINF:\n\t{\n\t\tGF_LHVCLayerInformation *ptr = gf_isom_linf_new_entry();\n\t\tu32 s = (u32) gf_bs_get_position(bs);\n\t\tgf_isom_linf_read_entry(ptr, bs);\n\t\t*total_bytes = (u32) gf_bs_get_position(bs) - s;\n\t\tif (!entry_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] linf sample group does not indicate entry size, deprecated in spec\\n\"));\n\t\t}\n\t\treturn ptr;\n\t}\n\n\tcase GF_ISOM_SAMPLE_GROUP_TRIF:\n\t\tif (! entry_size) {\n\t\t\tu32 flags = gf_bs_peek_bits(bs, 24, 0);\n\t\t\tif (flags & 0x10000) entry_size=3;\n\t\t\telse {\n\t\t\t\tif (flags & 0x80000) entry_size=7;\n\t\t\t\telse entry_size=11;\n\t\t\t\t\/\/have dependency list\n\t\t\t\tif (flags & 0x200000) {\n\t\t\t\t\tu32 nb_entries = gf_bs_peek_bits(bs, 16, entry_size);\n\t\t\t\t\tentry_size += 2 + 2*nb_entries;\n\t\t\t\t}\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] trif sample group does not indicate entry size, deprecated in spec\\n\"));\n\t\t}\n\t\tbreak;\n\tcase GF_ISOM_SAMPLE_GROUP_NALM:\n\t\tif (! entry_size) {\n\t\t\tu64 start = gf_bs_get_position(bs);\n\t\t\tBool rle, large_size;\n\t\t\tu32 entry_count;\n\t\t\tgf_bs_read_int(bs, 6);\n\t\t\tlarge_size = gf_bs_read_int(bs, 1);\n\t\t\trle = gf_bs_read_int(bs, 1);\n\t\t\tentry_count = gf_bs_read_int(bs, large_size ? 16 : 8);\n\t\t\tgf_bs_seek(bs, start);\n\t\t\tentry_size = 1 + (large_size ? 2 : 1);\n\t\t\tentry_size += entry_count * 2;\n\t\t\tif (rle) entry_size += entry_count * (large_size ? 2 : 1);\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] nalm sample group does not indicate entry size, deprecated in spec\\n\"));\n\t\t}\n\t\tbreak;\n\n\tcase GF_ISOM_SAMPLE_GROUP_TSAS:\n\tcase GF_ISOM_SAMPLE_GROUP_STSA:\n\t\tnull_size_ok = GF_TRUE;\n\t\tbreak;\n\t\/\/TODO, add support for these ones ?\n\tcase GF_ISOM_SAMPLE_GROUP_TSCL:\n\t\tentry_size = 20;\n\t\tbreak;\n\tcase GF_ISOM_SAMPLE_GROUP_LBLI:\n\t\tentry_size = 2;\n\t\tbreak;\n\tcase GF_ISOM_SAMPLE_GROUP_SPOR:\n\t{\n\t\tu32 i;\n\t\tGF_SubpictureOrderEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_SubpictureOrderEntry);\n\t\tif (!ptr) return NULL;\n\t\tptr->subpic_id_info_flag = gf_bs_read_int(bs, 1);\n\t\tptr->num_subpic_ref_idx = gf_bs_read_int(bs, 15);\n\t\t*total_bytes = 2;\n\t\tptr->subp_track_ref_idx = gf_malloc(sizeof(u16) * ptr->num_subpic_ref_idx);\n\t\tif (!ptr->subp_track_ref_idx) {\n\t\t\tgf_free(ptr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; i<ptr->num_subpic_ref_idx; i++) {\n\t\t\tptr->subp_track_ref_idx[i] = gf_bs_read_u16(bs);\n\t\t\t*total_bytes += 2;\n\t\t}\n\t\tif (ptr->subpic_id_info_flag) {\n\t\t\tptr->spinfo.subpic_id_len_minus1 = gf_bs_read_int(bs, 4);\n\t\t\tptr->spinfo.subpic_id_bit_pos = gf_bs_read_int(bs, 12);\n\t\t\tptr->spinfo.start_code_emul_flag = gf_bs_read_int(bs, 1);\n\t\t\tptr->spinfo.pps_sps_subpic_id_flag = gf_bs_read_int(bs, 1);\n\t\t\tif (ptr->spinfo.pps_sps_subpic_id_flag) {\n\t\t\t\tptr->spinfo.xps_id = gf_bs_read_int(bs, 6);\n\t\t\t} else {\n\t\t\t\tptr->spinfo.xps_id = gf_bs_read_int(bs, 4);\n\t\t\t\tgf_bs_read_int(bs, 2);\n\t\t\t}\n\t\t\t*total_bytes += 3;\n\t\t}\n\t\treturn ptr;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_SULM:\n\t{\n\t\tu32 i;\n\t\tGF_SubpictureLayoutMapEntry *ptr;\n\t\tGF_SAFEALLOC(ptr, GF_SubpictureLayoutMapEntry);\n\t\tif (!ptr) return NULL;\n\t\tptr->groupID_info_4cc = gf_bs_read_u32(bs);\n\t\tptr->nb_entries = 1 + gf_bs_read_u16(bs);\n\t\t*total_bytes = 6;\n\t\tptr->groupIDs = gf_malloc(sizeof(u16) * ptr->nb_entries);\n\t\tif (!ptr->groupIDs) {\n\t\t\tgf_free(ptr);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\t\tptr->groupIDs[i] = gf_bs_read_u16(bs);\n\t\t\t*total_bytes += 2;\n\t\t}\n\t\treturn ptr;\n\t}\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (!entry_size && !null_size_ok) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] %s sample group does not indicate entry size and is not implemented, cannot parse!\\n\", gf_4cc_to_str( grouping_type) ));\n\t\treturn NULL;\n\t}\n\tGF_SAFEALLOC(def_ptr, GF_DefaultSampleGroupDescriptionEntry);\n\tif (!def_ptr) return NULL;\n\tif (entry_size) {\n\t\tdef_ptr->length = entry_size;\n\t\tdef_ptr->data = (u8 *) gf_malloc(sizeof(u8)*def_ptr->length);\n\t\tif (!def_ptr->data) {\n\t\t\tgf_free(def_ptr);\n\t\t\treturn NULL;\n\t\t}\n\t\tgf_bs_read_data(bs, (char *) def_ptr->data, def_ptr->length);\n\t\t*total_bytes = entry_size;\n\t}\n\treturn def_ptr;","target":0,"code_token_length":2951,"total_token_length":3187,"max_tokens_setting":4096}
+{"idx":511472,"func":"bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)\n{\n  TABLE *table;\n  const char *key;\n  uint\tkey_length;\n  const char *alias= table_list->alias.str;\n  uint flags= ot_ctx->get_flags();\n  MDL_ticket *mdl_ticket;\n  TABLE_SHARE *share;\n  uint gts_flags;\n  bool from_share= false;\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n  int part_names_error=0;\n#endif\n  DBUG_ENTER(\"open_table\");\n\n  \/*\n    The table must not be opened already. The table can be pre-opened for\n    some statements if it is a temporary table.\n\n    open_temporary_table() must be used to open temporary tables.\n  *\/\n  DBUG_ASSERT(!table_list->table);\n\n  \/* an open table operation needs a lot of the stack space *\/\n  if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias))\n    DBUG_RETURN(TRUE);\n\n  if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed)\n  {\n    thd->send_kill_message();\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Check if we're trying to take a write lock in a read only transaction.\n\n    Note that we allow write locks on log tables as otherwise logging\n    to general\/slow log would be disabled in read only transactions.\n  *\/\n  if (table_list->mdl_request.is_write_lock_request() &&\n      thd->tx_read_only &&\n      !(flags & (MYSQL_LOCK_LOG_TABLE | MYSQL_OPEN_HAS_MDL_LOCK)))\n  {\n    my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0));\n    DBUG_RETURN(true);\n  }\n\n  if (!table_list->db.str)\n  {\n    my_error(ER_NO_DB_ERROR, MYF(0));\n    DBUG_RETURN(true);\n  }\n\n  key_length= get_table_def_key(table_list, &key);\n\n  \/*\n    If we're in pre-locked or LOCK TABLES mode, let's try to find the\n    requested table in the list of pre-opened and locked tables. If the\n    table is not there, return an error - we can't open not pre-opened\n    tables in pre-locked\/LOCK TABLES mode.\n    TODO: move this block into a separate function.\n  *\/\n  if (thd->locked_tables_mode &&\n      ! (flags & MYSQL_OPEN_GET_NEW_TABLE))\n  {\t\t\t\t\t\t\/\/ Using table locks\n    TABLE *best_table= 0;\n    int best_distance= INT_MIN;\n    for (table=thd->open_tables; table ; table=table->next)\n    {\n      if (table->s->table_cache_key.length == key_length &&\n\t  !memcmp(table->s->table_cache_key.str, key, key_length))\n      {\n        if (!my_strcasecmp(system_charset_info, table->alias.c_ptr(), alias) &&\n            table->query_id != thd->query_id && \/* skip tables already used *\/\n            (thd->locked_tables_mode == LTM_LOCK_TABLES ||\n             table->query_id == 0))\n        {\n          int distance= ((int) table->reginfo.lock_type -\n                         (int) table_list->lock_type);\n\n          \/*\n            Find a table that either has the exact lock type requested,\n            or has the best suitable lock. In case there is no locked\n            table that has an equal or higher lock than requested,\n            we us the closest matching lock to be able to produce an error\n            message about wrong lock mode on the table. The best_table\n            is changed if bd < 0 <= d or bd < d < 0 or 0 <= d < bd.\n\n            distance <  0 - No suitable lock found\n            distance >  0 - we have lock mode higher then we require\n            distance == 0 - we have lock mode exactly which we need\n          *\/\n          if ((best_distance < 0 && distance > best_distance) ||\n              (distance >= 0 && distance < best_distance))\n          {\n            best_distance= distance;\n            best_table= table;\n            if (best_distance == 0)\n            {\n              \/*\n                We have found a perfect match and can finish iterating\n                through open tables list. Check for table use conflict\n                between calling statement and SP\/trigger is done in\n                lock_tables().\n              *\/\n              break;\n            }\n          }\n        }\n      }\n    }\n    if (best_table)\n    {\n      table= best_table;\n      table->query_id= thd->query_id;\n      table->init(thd, table_list);\n      DBUG_PRINT(\"info\",(\"Using locked table\"));\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n      part_names_error= set_partitions_as_used(table_list, table);\n#endif\n      goto reset;\n    }\n\n    if (is_locked_view(thd, table_list))\n    {\n      if (table_list->sequence)\n      {\n        my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str);\n        DBUG_RETURN(true);\n      }\n      DBUG_RETURN(FALSE); \/\/ VIEW\n    }\n\n    \/*\n      No table in the locked tables list. In case of explicit LOCK TABLES\n      this can happen if a user did not include the table into the list.\n      In case of pre-locked mode locked tables list is generated automatically,\n      so we may only end up here if the table did not exist when\n      locked tables list was created.\n    *\/\n    if (thd->locked_tables_mode == LTM_PRELOCKED)\n      my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str);\n    else\n      my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias);\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Non pre-locked\/LOCK TABLES mode, and the table is not temporary.\n    This is the normal use case.\n  *\/\n\n  if (! (flags & MYSQL_OPEN_HAS_MDL_LOCK))\n  {\n    \/*\n      We are not under LOCK TABLES and going to acquire write-lock\/\n      modify the base table. We need to acquire protection against\n      global read lock until end of this statement in order to have\n      this statement blocked by active FLUSH TABLES WITH READ LOCK.\n\n      We don't need to acquire this protection under LOCK TABLES as\n      such protection already acquired at LOCK TABLES time and\n      not released until UNLOCK TABLES.\n\n      We don't block statements which modify only temporary tables\n      as these tables are not preserved by any form of\n      backup which uses FLUSH TABLES WITH READ LOCK.\n\n      TODO: The fact that we sometimes acquire protection against\n            GRL only when we encounter table to be write-locked\n            slightly increases probability of deadlock.\n            This problem will be solved once Alik pushes his\n            temporary table refactoring patch and we can start\n            pre-acquiring metadata locks at the beggining of\n            open_tables() call.\n    *\/\n    if (table_list->mdl_request.is_write_lock_request() &&\n        ! (flags & (MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |\n                    MYSQL_OPEN_FORCE_SHARED_MDL |\n                    MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |\n                    MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) &&\n        ! ot_ctx->has_protection_against_grl())\n    {\n      MDL_request protection_request;\n      MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);\n\n      if (thd->global_read_lock.can_acquire_protection())\n        DBUG_RETURN(TRUE);\n\n      protection_request.init(MDL_key::GLOBAL, \"\", \"\", MDL_INTENTION_EXCLUSIVE,\n                              MDL_STATEMENT);\n\n      \/*\n        Install error handler which if possible will convert deadlock error\n        into request to back-off and restart process of opening tables.\n      *\/\n      thd->push_internal_handler(&mdl_deadlock_handler);\n      bool result= thd->mdl_context.acquire_lock(&protection_request,\n                                                 ot_ctx->get_timeout());\n      thd->pop_internal_handler();\n\n      if (result)\n        DBUG_RETURN(TRUE);\n\n      ot_ctx->set_has_protection_against_grl();\n    }\n\n    if (open_table_get_mdl_lock(thd, ot_ctx, &table_list->mdl_request,\n                                flags, &mdl_ticket) ||\n        mdl_ticket == NULL)\n    {\n      DEBUG_SYNC(thd, \"before_open_table_wait_refresh\");\n      DBUG_RETURN(TRUE);\n    }\n    DEBUG_SYNC(thd, \"after_open_table_mdl_shared\");\n  }\n  else\n  {\n    \/*\n      Grab reference to the MDL lock ticket that was acquired\n      by the caller.\n    *\/\n    mdl_ticket= table_list->mdl_request.ticket;\n  }\n\n  if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS)\n  {\n    if (!ha_table_exists(thd, &table_list->db, &table_list->table_name))\n      DBUG_RETURN(FALSE);\n  }\n  else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB)\n    DBUG_RETURN(FALSE);\n\n  \/* Table exists. Let us try to open it. *\/\n\n  if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)\n    gts_flags= GTS_TABLE;\n  else if (table_list->i_s_requested_object &  OPEN_VIEW_ONLY)\n    gts_flags= GTS_VIEW;\n  else\n    gts_flags= GTS_TABLE | GTS_VIEW;\n\nretry_share:\n\n  share= tdc_acquire_share(thd, table_list, gts_flags, &table);\n\n  if (unlikely(!share))\n  {\n    \/*\n      Hide \"Table doesn't exist\" errors if the table belongs to a view.\n      The check for thd->is_error() is necessary to not push an\n      unwanted error in case the error was already silenced.\n      @todo Rework the alternative ways to deal with ER_NO_SUCH TABLE.\n    *\/\n    if (thd->is_error())\n    {\n      if (table_list->parent_l)\n      {\n        thd->clear_error();\n        my_error(ER_WRONG_MRG_TABLE, MYF(0));\n      }\n      else if (table_list->belong_to_view)\n      {\n        TABLE_LIST *view= table_list->belong_to_view;\n        thd->clear_error();\n        my_error(ER_VIEW_INVALID, MYF(0),\n                 view->view_db.str, view->view_name.str);\n      }\n    }\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Check if this TABLE_SHARE-object corresponds to a view. Note, that there is\n    no need to check TABLE_SHARE::tdc.flushed as we do for regular tables,\n    because view shares are always up to date.\n  *\/\n  if (share->is_view)\n  {\n    \/*\n      If parent_l of the table_list is non null then a merge table\n      has this view as child table, which is not supported.\n    *\/\n    if (table_list->parent_l)\n    {\n      my_error(ER_WRONG_MRG_TABLE, MYF(0));\n      goto err_lock;\n    }\n    if (table_list->sequence)\n    {\n      my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str,\n               table_list->alias.str);\n      goto err_lock;\n    }\n    \/*\n      This table is a view. Validate its metadata version: in particular,\n      that it was a view when the statement was prepared.\n    *\/\n    if (check_and_update_table_version(thd, table_list, share))\n      goto err_lock;\n\n    \/* Open view *\/\n    if (mysql_make_view(thd, share, table_list, false))\n      goto err_lock;\n\n\n    \/* TODO: Don't free this *\/\n    tdc_release_share(share);\n\n    DBUG_ASSERT(table_list->view);\n\n    DBUG_RETURN(FALSE);\n  }\n\n#ifdef WITH_WSREP\n  if (!((flags & MYSQL_OPEN_IGNORE_FLUSH) ||\n        (thd->wsrep_applier)))\n#else\n  if (!(flags & MYSQL_OPEN_IGNORE_FLUSH))\n#endif\n  {\n    if (share->tdc->flushed)\n    {\n      DBUG_PRINT(\"info\", (\"Found old share version: %lld  current: %lld\",\n                          share->tdc->version, tdc_refresh_version()));\n      \/*\n        We already have an MDL lock. But we have encountered an old\n        version of table in the table definition cache which is possible\n        when someone changes the table version directly in the cache\n        without acquiring a metadata lock (e.g. this can happen during\n        \"rolling\" FLUSH TABLE(S)).\n        Release our reference to share, wait until old version of\n        share goes away and then try to get new version of table share.\n      *\/\n      if (table)\n        tc_release_table(table);\n      else\n        tdc_release_share(share);\n\n      MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);\n      bool wait_result;\n\n      thd->push_internal_handler(&mdl_deadlock_handler);\n      wait_result= tdc_wait_for_old_version(thd, table_list->db.str,\n                                            table_list->table_name.str,\n                                            ot_ctx->get_timeout(),\n                                            mdl_ticket->get_deadlock_weight());\n      thd->pop_internal_handler();\n\n      if (wait_result)\n        DBUG_RETURN(TRUE);\n\n      goto retry_share;\n    }\n\n    if (thd->open_tables && thd->open_tables->s->tdc->flushed)\n    {\n      \/*\n        If the version changes while we're opening the tables,\n        we have to back off, close all the tables opened-so-far,\n        and try to reopen them. Note: refresh_version is currently\n        changed only during FLUSH TABLES.\n      *\/\n      if (table)\n        tc_release_table(table);\n      else\n        tdc_release_share(share);\n      (void)ot_ctx->request_backoff_action(Open_table_context::OT_REOPEN_TABLES,\n                                           NULL);\n      DBUG_RETURN(TRUE);\n    }\n  }\n\n  if (table)\n  {\n    DBUG_ASSERT(table->file != NULL);\n    MYSQL_REBIND_TABLE(table->file);\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n    part_names_error= set_partitions_as_used(table_list, table);\n#endif\n  }\n  else\n  {\n    enum open_frm_error error;\n\n    \/* make a new table *\/\n    if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))\n      goto err_lock;\n\n    error= open_table_from_share(thd, share, &table_list->alias,\n                                 HA_OPEN_KEYFILE | HA_TRY_READ_ONLY,\n                                 EXTRA_RECORD,\n                                 thd->open_options, table, FALSE,\n                                 IF_PARTITIONING(table_list->partition_names,0));\n\n    if (unlikely(error))\n    {\n      my_free(table);\n\n      if (error == OPEN_FRM_DISCOVER)\n        (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER,\n                                              table_list);\n      else if (share->crashed)\n      {\n        if (!(flags & MYSQL_OPEN_IGNORE_REPAIR))\n          (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR,\n                                                table_list);\n        else\n          table_list->crashed= 1;  \/* Mark that table was crashed *\/\n      }\n      goto err_lock;\n    }\n    if (open_table_entry_fini(thd, share, table))\n    {\n      closefrm(table);\n      my_free(table);\n      goto err_lock;\n    }\n\n    \/* Add table to the share's used tables list. *\/\n    tc_add_table(thd, table);\n    from_share= true;\n  }\n\n  table->mdl_ticket= mdl_ticket;\n  table->reginfo.lock_type=TL_READ;\t\t\/* Assume read *\/\n\n  table->init(thd, table_list);\n\n  table->next= thd->open_tables;\t\t\/* Link into simple list *\/\n  thd->set_open_tables(table);\n\n reset:\n  \/*\n    Check that there is no reference to a condition from an earlier query\n    (cf. Bug#58553). \n  *\/\n  DBUG_ASSERT(table->file->pushed_cond == NULL);\n  table_list->updatable= 1; \/\/ It is not derived table nor non-updatable VIEW\n  table_list->table= table;\n\n  if (!from_share && table->vcol_fix_expr(thd))\n    DBUG_RETURN(true);\n\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n  if (unlikely(table->part_info))\n  {\n    \/* Partitions specified were incorrect.*\/\n    if (part_names_error)\n    {\n      table->file->print_error(part_names_error, MYF(0));\n      DBUG_RETURN(true);\n    }\n  }\n  else if (table_list->partition_names)\n  {\n    \/* Don't allow PARTITION () clause on a nonpartitioned table *\/\n    my_error(ER_PARTITION_CLAUSE_ON_NONPARTITIONED, MYF(0));\n    DBUG_RETURN(true);\n  }\n#endif\n  if (table_list->sequence && table->s->table_type != TABLE_TYPE_SEQUENCE)\n  {\n    my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str);\n    DBUG_RETURN(true);\n  }\n\n  DBUG_RETURN(FALSE);\n\nerr_lock:\n  tdc_release_share(share);\n\n  DBUG_PRINT(\"exit\", (\"failed\"));\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":3629,"total_token_length":3865,"max_tokens_setting":4096}
+{"idx":281642,"func":"void CLASS kodak_radc_load_raw()\n{\n  static const char src[] = {\n    1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8,\n    1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8,\n    2,1, 2,3, 3,0, 3,2, 3,4, 4,6, 5,5, 6,7, 6,8,\n    2,0, 2,1, 2,3, 3,2, 4,4, 5,6, 6,7, 7,5, 7,8,\n    2,1, 2,4, 3,0, 3,2, 3,3, 4,7, 5,5, 6,6, 6,8,\n    2,3, 3,1, 3,2, 3,4, 3,5, 3,6, 4,7, 5,0, 5,8,\n    2,3, 2,6, 3,0, 3,1, 4,4, 4,5, 4,7, 5,2, 5,8,\n    2,4, 2,7, 3,3, 3,6, 4,1, 4,2, 4,5, 5,0, 5,8,\n    2,6, 3,1, 3,3, 3,5, 3,7, 3,8, 4,0, 5,2, 5,4,\n    2,0, 2,1, 3,2, 3,3, 4,4, 4,5, 5,6, 5,7, 4,8,\n    1,0, 2,2, 2,-2,\n    1,-3, 1,3,\n    2,-17, 2,-5, 2,5, 2,17,\n    2,-7, 2,2, 2,9, 2,18,\n    2,-18, 2,-9, 2,-2, 2,7,\n    2,-28, 2,28, 3,-49, 3,-9, 3,9, 4,49, 5,-79, 5,79,\n    2,-1, 2,13, 2,26, 3,39, 4,-16, 5,55, 6,-37, 6,76,\n    2,-26, 2,-13, 2,1, 3,-39, 4,16, 5,-55, 6,-76, 6,37\n  };\n  ushort huff[19][256];\n  int row, col, tree, nreps, rep, step, i, c, s, r, x, y, val;\n  short last[3] = { 16,16,16 }, mul[3], buf[3][3][386];\n  static const ushort pt[] =\n    { 0,0, 1280,1344, 2320,3616, 3328,8000, 4095,16383, 65535,16383 };\n\n  for (i=2; i < 12; i+=2)\n    for (c=pt[i-2]; c <= pt[i]; c++)\n      curve[c] = (float)\n\t(c-pt[i-2]) \/ (pt[i]-pt[i-2]) * (pt[i+1]-pt[i-1]) + pt[i-1] + 0.5;\n  for (s=i=0; i < sizeof src; i+=2)\n    FORC(256 >> src[i])\n      huff[0][s++] = src[i] << 8 | (uchar) src[i+1];\n  s = kodak_cbpp == 243 ? 2 : 3;\n  FORC(256) huff[18][c] = (8-s) << 8 | c >> s << s | 1 << (s-1);\n  getbits(-1);\n  for (i=0; i < sizeof(buf)\/sizeof(short); i++)\n    buf[0][0][i] = 2048;\n  for (row=0; row < height; row+=4) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    FORC3 mul[c] = getbits(6);\n    FORC3 {\n      val = ((0x1000000\/last[c] + 0x7ff) >> 12) * mul[c];\n      s = val > 65564 ? 10:12;\n      x = ~((~0u) << (s-1));\n      val <<= 12-s;\n      for (i=0; i < sizeof(buf[0])\/sizeof(short); i++)\n\tbuf[c][0][i] = (buf[c][0][i] * val + x) >> s;\n      last[c] = mul[c];\n      for (r=0; r <= !c; r++) {\n\tbuf[c][1][width\/2] = buf[c][2][width\/2] = mul[c] << 7;\n\tfor (tree=1, col=width\/2; col > 0; ) {\n\t  if ((tree = radc_token(tree))) {\n\t    col -= 2;\n\t    if (tree == 8)\n\t      FORYX buf[c][y][x] = (uchar) radc_token(18) * mul[c];\n\t    else\n\t      FORYX buf[c][y][x] = radc_token(tree+10) * 16 + PREDICTOR;\n\t  } else\n\t    do {\n\t      nreps = (col > 2) ? radc_token(9) + 1 : 1;\n\t      for (rep=0; rep < 8 && rep < nreps && col > 0; rep++) {\n\t\tcol -= 2;\n\t\tFORYX buf[c][y][x] = PREDICTOR;\n\t\tif (rep & 1) {\n\t\t  step = radc_token(10) << 4;\n\t\t  FORYX buf[c][y][x] += step;\n\t\t}\n\t      }\n\t    } while (nreps == 9);\n\t}\n\tfor (y=0; y < 2; y++)\n\t  for (x=0; x < width\/2; x++) {\n\t    val = (buf[c][y+1][x] << 4) \/ mul[c];\n\t    if (val < 0) val = 0;\n\t    if (c) RAW(row+y*2+c-1,x*2+2-c) = val;\n\t    else   RAW(row+r*2+y,x*2+y) = val;\n\t  }\n\tmemcpy (buf[c][0]+!c, buf[c][2], sizeof buf[c][0]-2*!c);\n      }\n    }\n    for (y=row; y < row+4; y++)\n      for (x=0; x < width; x++)\n\tif ((x+y) & 1) {\n\t  r = x ? x-1 : x+1;\n\t  s = x+1 < width ? x+1 : x-1;\n\t  val = (RAW(y,x)-2048)*2 + (RAW(y,r)+RAW(y,s))\/2;\n\t  if (val < 0) val = 0;\n\t  RAW(y,x) = val;\n\t}\n  }\n  for (i=0; i < height*width; i++)\n    raw_image[i] = curve[raw_image[i]];\n  maximum = 0x3fff;\n}","target":0,"code_token_length":1832,"total_token_length":2068,"max_tokens_setting":4096}
+{"idx":432704,"func":"static void ipa_draw_text(wmfAPI * API, wmfDrawText_t * draw_text)\n{\n  double\n    angle = 0,      \/* text rotation angle *\/\n    bbox_height,    \/* bounding box height *\/\n    bbox_width,      \/* bounding box width *\/\n    pointsize = 0;    \/* pointsize to output font with desired height *\/\n\n  ExceptionInfo\n    *exception;\n\n  TypeMetric\n    metrics;\n\n  wmfD_Coord\n    BL,        \/* bottom left of bounding box *\/\n    BR,        \/* bottom right of bounding box *\/\n    TL,        \/* top left of bounding box *\/\n    TR;        \/* top right of bounding box *\/\n\n  wmfD_Coord\n    point;      \/* text placement point *\/\n\n  wmfFont\n    *font;\n\n  wmf_magick_t\n    * ddata = WMF_MAGICK_GetData(API);\n\n  point = draw_text->pt;\n\n  \/* Choose bounding box and calculate its width and height *\/\n  {\n    double dx,\n      dy;\n\n    if ( draw_text->flags)\n      {\n        TL = draw_text->TL;\n        BR = draw_text->BR;\n        TR.x = draw_text->BR.x;\n        TR.y = draw_text->TL.y;\n        BL.x = draw_text->TL.x;\n        BL.y = draw_text->BR.y;\n      }\n    else\n      {\n        TL = draw_text->bbox.TL;\n        BR = draw_text->bbox.BR;\n        TR = draw_text->bbox.TR;\n        BL = draw_text->bbox.BL;\n      }\n    dx = ((TR.x - TL.x) + (BR.x - BL.x)) \/ 2;\n    dy = ((TR.y - TL.y) + (BR.y - BL.y)) \/ 2;\n    bbox_width = hypot(dx,dy);\n    dx = ((BL.x - TL.x) + (BR.x - TR.x)) \/ 2;\n    dy = ((BL.y - TL.y) + (BR.y - TR.y)) \/ 2;\n    bbox_height = hypot(dx,dy);\n  }\n\n  font = WMF_DC_FONT(draw_text->dc);\n\n  \/* Convert font_height to equivalent pointsize *\/\n  exception=ddata->exception;\n  pointsize = util_pointsize( API, font, draw_text->str, draw_text->font_height, exception);\n\n  \/* Save graphic wand *\/\n  (void) PushDrawingWand(WmfDrawingWand);\n\n  (void) bbox_width;\n  (void) bbox_height;\n#if 0\n  printf(\"\\nipa_draw_text\\n\");\n  printf(\"Text                    = \\\"%s\\\"\\n\", draw_text->str);\n  \/* printf(\"WMF_FONT_NAME:          = \\\"%s\\\"\\n\", WMF_FONT_NAME(font)); *\/\n  printf(\"WMF_FONT_PSNAME:        = \\\"%s\\\"\\n\", WMF_FONT_PSNAME(font));\n  printf(\"Bounding box            TL=%g,%g BR=%g,%g\\n\",\n         TL.x, TL.y, BR.x, BR.y );\n  \/* printf(\"Text box                = %gx%g\\n\", bbox_width, bbox_height); *\/\n  \/* printf(\"WMF_FONT_HEIGHT         = %i\\n\", (int)WMF_FONT_HEIGHT(font)); *\/\n  printf(\"Pointsize               = %g\\n\", pointsize);\n  fflush(stdout);\n#endif\n\n  \/*\n   * Obtain font metrics if required\n   *\n   *\/\n  if ((WMF_DC_TEXTALIGN(draw_text->dc) & TA_CENTER) ||\n      (WMF_TEXT_UNDERLINE(font)) || (WMF_TEXT_STRIKEOUT(font)))\n    {\n      Image\n        *image = ddata->image;\n\n      DrawInfo\n        *draw_info;\n\n      draw_info=ddata->draw_info;\n      draw_info->font=WMF_FONT_PSNAME(font);\n      draw_info->pointsize = pointsize;\n      draw_info->text=draw_text->str;\n\n      if (GetTypeMetrics(image, draw_info, &metrics, exception) != MagickFalse)\n        {\n          \/* Center the text if it is not yet centered and should be *\/\n          if ((WMF_DC_TEXTALIGN(draw_text->dc) & TA_CENTER))\n            {\n              double\n                text_width = metrics.width * (ddata->scale_y \/ ddata->scale_x);\n\n#if defined(MAGICKCORE_WMF_DELEGATE)\n              point.x -= text_width \/ 2;\n#else\n              point.x += bbox_width \/ 2 - text_width \/ 2;\n#endif\n            }\n        }\n      draw_info->font=NULL;\n      draw_info->text=NULL;\n    }\n\n  \/* Set text background color *\/\n  if (draw_text->flags & ETO_OPAQUE)\n    {\n      \/* Draw bounding-box background color (META_EXTTEXTOUT mode) *\/\n      draw_stroke_color_string(WmfDrawingWand,\"none\");\n      draw_fill_color_rgb(API,WMF_DC_BACKGROUND(draw_text->dc));\n      DrawRectangle(WmfDrawingWand,\n                    XC(draw_text->TL.x),YC(draw_text->TL.y),\n                    XC(draw_text->BR.x),YC(draw_text->BR.y));\n      draw_fill_color_string(WmfDrawingWand,\"none\");\n    }\n  else\n    {\n      \/* Set text undercolor *\/\n      if (WMF_DC_OPAQUE(draw_text->dc))\n        {\n          wmfRGB\n            *box = WMF_DC_BACKGROUND(draw_text->dc);\n\n          PixelWand\n            *under_color;\n\n          under_color=NewPixelWand();\n          PixelSetRedQuantum(under_color,ScaleCharToQuantum(box->r));\n          PixelSetGreenQuantum(under_color,ScaleCharToQuantum(box->g));\n          PixelSetBlueQuantum(under_color,ScaleCharToQuantum(box->b));\n          PixelSetAlphaQuantum(under_color,OpaqueAlpha);\n          DrawSetTextUnderColor(WmfDrawingWand,under_color);\n          under_color=DestroyPixelWand(under_color);\n        }\n      else\n        draw_under_color_string(WmfDrawingWand,\"none\");\n    }\n\n  \/* Set text clipping (META_EXTTEXTOUT mode) *\/\n  if ( draw_text->flags & ETO_CLIPPED)\n    {\n    }\n\n  \/* Set stroke color *\/\n  draw_stroke_color_string(WmfDrawingWand,\"none\");\n\n  \/* Set fill color *\/\n  draw_fill_color_rgb(API,WMF_DC_TEXTCOLOR(draw_text->dc));\n\n  \/* Output font size *\/\n  (void) DrawSetFontSize(WmfDrawingWand,pointsize);\n\n  \/* Output Postscript font name *\/\n  (void) DrawSetFont(WmfDrawingWand, WMF_FONT_PSNAME(font));\n\n  \/* Translate coordinates so target is 0,0 *\/\n  DrawTranslate(WmfDrawingWand, XC(point.x), YC(point.y));\n\n  \/* Transform horizontal scale to draw text at 1:1 ratio *\/\n  DrawScale(WmfDrawingWand, ddata->scale_y \/ ddata->scale_x, 1.0);\n\n  \/* Apply rotation *\/\n  \/* ImageMagick's drawing rotation is clockwise from horizontal\n     while WMF drawing rotation is counterclockwise from horizontal *\/\n  angle = fabs(RadiansToDegrees(2 * MagickPI - WMF_TEXT_ANGLE(font)));\n  if (angle == 360)\n    angle = 0;\n  if (angle != 0)\n    DrawRotate(WmfDrawingWand, angle);\n\n  \/*\n   * Render text\n   *\n   *\/\n\n  \/* Output string *\/\n  DrawAnnotation(WmfDrawingWand, 0, 0, (unsigned char*)draw_text->str);\n\n  \/* Underline text the Windows way (at the bottom) *\/\n  if (WMF_TEXT_UNDERLINE(font))\n    {\n      double\n        line_height;\n\n      wmfD_Coord\n        ulBR,      \/* bottom right of underline rectangle *\/\n        ulTL;      \/* top left of underline rectangle *\/\n\n      line_height = ((double)1\/(ddata->scale_x))*metrics.underline_thickness;\n      if (metrics.underline_thickness < 1.5)\n        line_height *= 0.55;\n      ulTL.x = 0;\n      ulTL.y = fabs(metrics.descent) - line_height;\n      ulBR.x = metrics.width;\n      ulBR.y = fabs(metrics.descent);\n\n      DrawRectangle(WmfDrawingWand,\n                    XC(ulTL.x), YC(ulTL.y), XC(ulBR.x), YC(ulBR.y));\n    }\n\n  \/* Strikeout text the Windows way *\/\n  if (WMF_TEXT_STRIKEOUT(font))\n    {\n      double line_height;\n\n      wmfD_Coord\n        ulBR,      \/* bottom right of strikeout rectangle *\/\n        ulTL;      \/* top left of strikeout rectangle *\/\n\n      line_height = ((double)1\/(ddata->scale_x))*metrics.underline_thickness;\n\n      if (metrics.underline_thickness < 2.0)\n        line_height *= 0.55;\n      ulTL.x = 0;\n      ulTL.y = -(((double) metrics.ascent) \/ 2 + line_height \/ 2);\n      ulBR.x = metrics.width;\n      ulBR.y = -(((double) metrics.ascent) \/ 2 - line_height \/ 2);\n\n      DrawRectangle(WmfDrawingWand,\n                    XC(ulTL.x), YC(ulTL.y), XC(ulBR.x), YC(ulBR.y));\n\n    }\n\n  \/* Restore graphic wand *\/\n  (void) PopDrawingWand(WmfDrawingWand);\n\n#if 0\n  (void) PushDrawingWand(WmfDrawingWand);\n  draw_stroke_color_string(WmfDrawingWand,\"red\");\n  draw_fill_color_string(WmfDrawingWand,\"none\");\n  DrawRectangle(WmfDrawingWand,\n                XC(TL.x), YC(TL.y),\n                XC(BR.x), YC(BR.y));\n  draw_stroke_color_string(WmfDrawingWand,\"none\");\n  (void) PopDrawingWand(WmfDrawingWand);\n#endif\n\n}","target":0,"code_token_length":2099,"total_token_length":2335,"max_tokens_setting":4096}
+{"idx":198695,"func":"mp_sint32 LoaderS3M::load(XMFileBase& f, XModule* module)\n{\t\n\tmodule->cleanUp();\n\n\t\/\/ this will make code much easier to read\n\tTXMHeader*\t\theader = &module->header;\n\tTXMInstrument*\tinstr  = module->instr;\n\tTXMSample*\t\tsmp\t   = module->smp;\n\tTXMPattern*\t\tphead  = module->phead;\t\n\n\t\/\/ we're already out of memory here\n\tif (!phead || !instr || !smp)\n\t\treturn MP_OUT_OF_MEMORY;\n\t\n\tf.read(&header->name,1,28);\n\theader->whythis1a = f.readByte();\n\t\n\tif (f.readByte() != 16) \n\t\treturn MP_LOADER_FAILED;\t\/\/ no ST3 module\n\t\n\tf.readByte(); \/\/ skip something\n\tf.readByte(); \/\/ skip something\n\t\n\theader->ordnum = f.readWord(); \/\/ number of positions in order list (songlength)\n\t\n\tmp_ubyte* orders = new mp_ubyte[header->ordnum];\n\tif (orders == NULL) \n\t\treturn MP_OUT_OF_MEMORY;\n\t\n\theader->insnum = f.readWord(); \/\/ number of instruments\n\theader->patnum = f.readWord(); \/\/ number of patterns\t\n\t\n\tmp_sint32 flags = f.readWord(); \/\/ st3 flags\t\n\n\tmp_sint32 Cvt = f.readWord();\n\n\theader->flags = XModule::MODULE_ST3NEWINSTRUMENT | XModule::MODULE_ST3DUALCOMMANDS;\n\n\tif (Cvt == 0x1300 || (flags & 64))\n\t\theader->flags |= module->MODULE_OLDS3MVOLSLIDES;\n\t\t\n\theader->flags |= module->MODULE_ST3NOTECUT;\n\t\n\t\/*mp_uword Ffi = *\/f.readWord();\n\t\n\tf.read(header->sig,1,4);\n\t\n\theader->mainvol = module->vol64to255(f.readByte()); \/\/ initial main volume\n\t\n\theader->tempo = f.readByte(); \/\/ tempo\n\t\n\theader->speed = f.readByte(); \/\/ speed\n\t\n\tf.readByte(); \/\/ global volume? skipped...\n\t\n\tf.readByte(); \/\/ ignore GUS click removal\n\t\n\t\/*mp_ubyte dp = *\/f.readByte();\n\t\n\tf.readDword();\t\/\/ skip something\n\tf.readDword();\t\/\/ skip something\n\tf.readWord();\t\/\/ skip some more...\n\t\n\tmp_ubyte channelSettings[32];\n\tf.read(channelSettings,1,32);\n\t\n\tmp_sint32 numChannels = 0;\n\t\n\tfor (numChannels = 0; numChannels < 32; numChannels++)\n\t\tif (channelSettings[numChannels] == 255)\n\t\t\tbreak;\n\t\n\theader->channum = numChannels; \/\/ number of channels\n\t\n\tf.read(orders,1,header->ordnum);\n\t\n\tmp_sint32 j = 0, i = 0;\n\tfor (i = 0; i < header->ordnum; i++)\n\t{\n\t\tif (orders[i] == 255) \n\t\t\tbreak;\n\t\t\n\t\theader->ord[j++] = orders[i];\t\t\n\t}\n\t\n\theader->ordnum = j; \/\/ final songlength\n\t\n\tdelete[] orders;\n\t\n\tmp_uword* insParaPtrs = new mp_uword[header->insnum];\n\t\n\tif (insParaPtrs == NULL)\n\t\treturn MP_OUT_OF_MEMORY;\n\t\n\tf.readWords(insParaPtrs,header->insnum);\n\t\n\tmp_uword* patParaPtrs = new mp_uword[header->patnum];\n\t\n\tif (patParaPtrs == NULL)\n\t{\n\t\tdelete[] insParaPtrs;\n\t\treturn MP_OUT_OF_MEMORY;\n\t}\n\t\n\tf.readWords(patParaPtrs,header->patnum);\n\t\n\t\/\/for (i = 0; i < header->insnum; i++)\n\t\/\/{\n\t\/\/\tprintf(\"%x\\n\",insParaPtrs[i]*16);\n\t\/\/}\n\t\t\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\/\/ read instruments \/\/\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\tmp_uint32* samplePtrs = new mp_uint32[header->insnum];\n\tif (samplePtrs == NULL)\n\t{\n\t\tdelete[] insParaPtrs;\n\t\tdelete[] patParaPtrs;\n\t\treturn MP_OUT_OF_MEMORY;\n\t}\n\t\n\tmemset(samplePtrs,0,sizeof(mp_uint32)*header->insnum);\n\t\n\tmp_sint32 s = 0;\n\tfor (i = 0; i < header->insnum; i++)\n\t{\n\t\tmp_uint32 insOffs = insParaPtrs[i]*16;\n\n\t\tif (insOffs)\n\t\t{\n\t\t\tf.seekWithBaseOffset(insOffs);\n\t\t\n\t\t\t\/\/ We can only read that if it's a sample\n\t\t\tmp_ubyte type = f.readByte();\n\t\t\t\n\t\t\tif (type == 1)\n\t\t\t{\n\t\t\t\tf.read(smp[s].name,1,12);\t\/\/ read dos filename\n\t\t\n\t\t\t\tmp_ubyte bOffs = f.readByte();\n\t\t\t\tmp_uword wOffs = f.readWord();\n\t\t\t\t\n\t\t\t\t\/\/ stupid fileoffsets\n\t\t\t\tsamplePtrs[i] = (((mp_uint32)bOffs<<16)+(mp_uint32)wOffs)*16;\n\t\t\t\t\n\t\t\t\tsmp[s].flags = 1;\n\t\t\t\tsmp[s].pan = 0x80;\n\t\t\t\t\n\t\t\t\tsmp[s].samplen = f.readDword();\n\t\t\t\tsmp[s].loopstart = f.readDword();\n\t\t\t\tmp_sint32 looplen = ((mp_sint32)f.readDword() - (mp_sint32)smp[s].loopstart);\n\t\t\t\tif (looplen < 0) \n\t\t\t\t\tlooplen = 0;\n\t\t\t\tsmp[s].looplen = looplen;\n\t\t\t\t\n\t\t\t\tsmp[s].vol = module->vol64to255(f.readByte());\n\t\t\t\t\n\t\t\t\tf.readByte(); \/\/ skip something\n\t\t\t\t\n\t\t\t\tsmp[s].res = f.readByte() == 0x04 ? 0xAD : 0; \/\/ packing\n\t\t\t\t\n\t\t\t\tmp_ubyte flags = f.readByte();\n\t\t\t\t\n\t\t\t\t\/\/ looping\n\t\t\t\tif (flags & 1)\n\t\t\t\t{\n\t\t\t\t\tsmp[s].type = 1;\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\/\/ 16 bit sample\n\t\t\t\tif (flags & 4)\n\t\t\t\t{\n\t\t\t\t\tsmp[s].type |= 16;\n\t\t\t\t\tsmp[s].samplen >>= 1;\n\t\t\t\t\tsmp[s].loopstart >>= 1;\n\t\t\t\t\tsmp[s].looplen >>= 1;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tmp_uint32 c4spd = f.readDword();\n\t\t\t\t\n\t\t\t\tXModule::convertc4spd(c4spd,&smp[s].finetune,&smp[s].relnote);\n\n#ifdef VERBOSE\n\t\t\t\tprintf(\"%i, %i\\n\",c4spd,module->getc4spd(smp[s].relnote,smp[s].finetune));\t\t\t\t\n#endif\n\n\t\t\t\tf.readDword(); \/\/ skip something\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip two internal words\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip internal dword\n\n\t\t\t\tf.read(instr[i].name,1,28); \/\/ instrument name\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip signature\n\t\t\t\t\n\t\t\t\tif (samplePtrs[i] && smp[s].samplen)\n\t\t\t\t{\n\t\t\t\t\tinstr[i].samp=1;\n\t\t\t\t\tfor (j=0;j<120;j++) \n\t\t\t\t\t\tinstr[i].snum[j] = s;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (type == 0)\n\t\t\t{\n\t\t\t\tsamplePtrs[i] = 0;\n\t\t\t\n\t\t\t\tmp_ubyte buffer[12];\n\t\t\t\tf.read(buffer,1,12);\t\/\/ read dos filename\n\t\t\n\t\t\t\tf.readByte();\n\t\t\t\tf.readWord();\n\t\t\t\t\n\t\t\t\tf.readDword();\n\t\t\t\tf.readDword();\n\t\t\t\tf.readDword();\n\t\t\t\tf.readByte();\n\t\t\t\tf.readByte(); \/\/ skip something\n\t\t\t\tf.readByte(); \/\/ skip packing\n\t\t\t\t\n\t\t\t\tf.readByte();\n\t\t\t\t\n\t\t\t\tf.readDword();\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip something\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip two internal words\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip internal dword\n\n\t\t\t\tf.read(instr[i].name,1,28); \/\/ instrument name\n\t\t\t\t\n\t\t\t\tf.readDword(); \/\/ skip signature\t\t\t\t\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tsamplePtrs[i] = 0;\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\t\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\/\/ read patterns\t\/\/\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\tmp_ubyte* pattern = new mp_ubyte[64*32*5];\n\tif (pattern == NULL)\n\t{\n\t\tdelete[] insParaPtrs;\n\t\tdelete[] patParaPtrs;\n\t\tdelete[] samplePtrs;\n\t\treturn MP_OUT_OF_MEMORY;\n\t}\n\t\n\tmp_uint32 songMaxChannels = 1;\n\t\n\tfor (i = 0; i < header->patnum; i++)\n\t{\n\t\tfor (j = 0; j < 32*64; j++)\n\t\t{\n\t\t\tpattern[j*5] = 0xFF;\n\t\t\tpattern[j*5+1] = 0;\n\t\t\tpattern[j*5+2] = 0xFF;\n\t\t\tpattern[j*5+3] = 0xFF;\n\t\t\tpattern[j*5+4] = 0;\n\t\t}\n\t\t\n\t\tmp_uint32 patOffs = patParaPtrs[i]*16;\n\t\t\n\t\tmp_uint32 maxChannels = 1;\t\t\t\n\t\t\n\t\tif (patOffs)\n\t\t{\n\t\t\tf.seekWithBaseOffset(patOffs);\n\t\t\t\n\t\t\tmp_uint32 size = f.readWord();\n\t\t\t\n\t\t\tif (size > 2)\n\t\t\t{\n\t\t\t\tsize-=2;\n\t\t\t\t\n\t\t\t\tmp_ubyte* packed = new mp_ubyte[size+5];\n\t\t\t\tif (packed == NULL)\n\t\t\t\t{\n\t\t\t\t\tdelete[] insParaPtrs;\n\t\t\t\t\tdelete[] patParaPtrs;\n\t\t\t\t\tdelete[] samplePtrs;\n\t\t\t\t\tdelete[] pattern;\n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tmemset(packed, 0, size);\n\t\t\t\tf.read(packed, 1, size);\n\t\t\t\t\n\t\t\t\tmp_uint32 index = 0;\n\t\t\t\tmp_uint32 row = 0;\n\t\t\t\t\n\t\t\t\twhile (index<size)\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\tmp_ubyte pi = safeRead(packed, index, size);\n\t\t\t\t\t\n\t\t\t\t\tif (pi == 0) \n\t\t\t\t\t{\n\t\t\t\t\t\trow++;\n\t\t\t\t\t\t\/\/ one more safety net for incorrectly saved pattern sizes\n\t\t\t\t\t\tif (row >= 64)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint i = 0;\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\ti--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmp_uint32 chn = pi&31;\n\t\t\t\t\t\n\t\t\t\t\tif (chn>maxChannels && (pi & (32+64+128)))\n\t\t\t\t\t{\n\t\t\t\t\t\tmaxChannels = chn;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmp_ubyte* slot = pattern+(row*32*5)+chn*5;\n\t\t\t\t\t\n\t\t\t\t\tif (pi & 32)\n\t\t\t\t\t{\n\t\t\t\t\t\tslot[0] = safeRead(packed, index, size, 0xFF);\n\t\t\t\t\t\tslot[1] = safeRead(packed, index, size);\n\t\t\t\t\t}\n\t\t\t\t\tif (pi & 64)\n\t\t\t\t\t{\n\t\t\t\t\t\tslot[2] = safeRead(packed, index, size, 0xFF);\n\t\t\t\t\t}\n\t\t\t\t\tif (pi & 128)\n\t\t\t\t\t{\n\t\t\t\t\t\tslot[3] = safeRead(packed, index, size, 0xFF);\n\t\t\t\t\t\tslot[4] = safeRead(packed, index, size);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tmaxChannels++;\n\t\t\t\t\n\t\t\t\tif (maxChannels > header->channum)\n\t\t\t\t\tmaxChannels = header->channum;\n\t\t\t\t\n\t\t\t\tdelete[] packed;\n\t\t\t}\n\t\t\t\n\t\t\tif (maxChannels > songMaxChannels)\n\t\t\t\tsongMaxChannels = maxChannels;\n\t\t\t\n\t\t}\n\t\t\n\t\tconvertS3MPattern(&phead[i], pattern, maxChannels, i);\n\t\t\n\t\t\n\t}\n\t\n\tif (header->channum > songMaxChannels)\n\t\theader->channum = songMaxChannels;\n\t\n\tdelete[] pattern;\n\tdelete[] insParaPtrs;\n\tdelete[] patParaPtrs;\n\t\n\ts = 0;\n\tfor (i = 0; i < header->insnum; i++)\n\t{\n\t\tmp_uint32 smpOffs = samplePtrs[i];\n\n\t\tif (smpOffs)\n\t\t{\n\t\t\tf.seekWithBaseOffset(smpOffs);\n\t\t\t\n\t\t\tif (!smp[s].samplen)\n\t\t\t\tcontinue;\n\n\t\t\tbool adpcm = (smp[s].res == 0xAD);\n\n\t\t\tmp_sint32 result = module->loadModuleSample(f, s, \n\t\t\t\t\t\t\t\t\t\t  adpcm ? XModule::ST_PACKING_ADPCM : XModule::ST_UNSIGNED, \n\t\t\t\t\t\t\t\t\t\t  adpcm ? (XModule::ST_16BIT | XModule::ST_PACKING_ADPCM) : (XModule::ST_16BIT | XModule::ST_UNSIGNED));\n\t\t\tif (result != MP_OK)\n\t\t\t{\n\t\t\t\tdelete[] samplePtrs;\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\t\n\t\t\tif (adpcm)\n\t\t\t\t\/\/ no longer needed\n\t\t\t\tsmp[s].res = 0;\t\t\t\n\t\t\t\t\t\t\t\n\t\t\ts++;\n\t\t\t\n\t\t}\n\n\t}\n\t\n\tdelete[] samplePtrs;\n\t\n\theader->smpnum = s;\n\t\n\tstrcpy(header->tracker,\"Screamtracker 3\");\n\t\n\tmodule->setDefaultPanning();\n\t\n\tmodule->postProcessSamples();\n\t\n\treturn MP_OK;\t\n}","target":1,"code_token_length":2900,"total_token_length":3136,"max_tokens_setting":4096}
+{"idx":227010,"func":"IRC_PROTOCOL_CALLBACK(cap)\n{\n    char *ptr_caps, **caps_supported, **caps_added, **caps_removed;\n    char **caps_enabled, *pos_value, *str_name, **str_caps;\n    char str_msg_auth[512], **str_caps_enabled, **str_caps_disabled;\n    int num_caps_supported, num_caps_added, num_caps_removed;\n    int num_caps_enabled, sasl_to_do, sasl_mechanism;\n    int i, timeout, last_reply;\n\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    if (strcmp (argv[3], \"LS\") == 0)\n    {\n        if (argc > 4)\n        {\n            if (argc > 5 && (strcmp (argv[4], \"*\") == 0))\n            {\n                ptr_caps = argv_eol[5];\n                last_reply = 0;\n            }\n            else\n            {\n                ptr_caps = argv_eol[4];\n                last_reply = 1;\n            }\n\n            if (!server->checking_cap_ls)\n            {\n                weechat_hashtable_remove_all (server->cap_ls);\n                server->checking_cap_ls = 1;\n            }\n\n            if (last_reply)\n                server->checking_cap_ls = 0;\n\n            if (ptr_caps[0] == ':')\n                ptr_caps++;\n\n            caps_supported = weechat_string_split (\n                ptr_caps,\n                \" \",\n                NULL,\n                WEECHAT_STRING_SPLIT_STRIP_LEFT\n                | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                0,\n                &num_caps_supported);\n            if (caps_supported)\n            {\n                for (i = 0; i < num_caps_supported; i++)\n                {\n                    pos_value = strstr (caps_supported[i], \"=\");\n                    if (pos_value)\n                    {\n                        str_name = strndup (caps_supported[i],\n                                            pos_value - caps_supported[i]);\n                        if (str_name)\n                        {\n                            weechat_hashtable_set (server->cap_ls,\n                                                   str_name, pos_value + 1);\n                            free (str_name);\n                        }\n                    }\n                    else\n                    {\n                        weechat_hashtable_set (server->cap_ls,\n                                               caps_supported[i], NULL);\n                    }\n                }\n            }\n\n            if (last_reply)\n            {\n                str_caps = weechat_string_dyn_alloc (128);\n                weechat_hashtable_map_string (server->cap_ls,\n                                              irc_protocol_cap_print_cb,\n                                              str_caps);\n                weechat_printf_date_tags (\n                    server->buffer, date, NULL,\n                    _(\"%s%s: client capability, server supports: %s\"),\n                    weechat_prefix (\"network\"),\n                    IRC_PLUGIN_NAME,\n                    *str_caps);\n                weechat_string_dyn_free (str_caps, 1);\n            }\n\n            \/* auto-enable capabilities only when connecting to server *\/\n            if (last_reply && !server->is_connected)\n                irc_protocol_cap_sync (server, 1);\n\n            if (caps_supported)\n                weechat_string_free_split (caps_supported);\n        }\n    }\n    else if (strcmp (argv[3], \"LIST\") == 0)\n    {\n        if (argc > 4)\n        {\n            if (argc > 5 && (strcmp (argv[4], \"*\") == 0))\n            {\n                ptr_caps = argv_eol[5];\n                last_reply = 0;\n            }\n            else\n            {\n                ptr_caps = argv_eol[4];\n                last_reply = 1;\n            }\n\n            if (!server->checking_cap_list)\n            {\n                weechat_hashtable_remove_all (server->cap_list);\n                server->checking_cap_list = 1;\n            }\n\n            if (last_reply)\n                server->checking_cap_list = 0;\n\n            if (ptr_caps[0] == ':')\n                ptr_caps++;\n\n            caps_enabled = weechat_string_split (\n                ptr_caps,\n                \" \",\n                NULL,\n                WEECHAT_STRING_SPLIT_STRIP_LEFT\n                | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                0,\n                &num_caps_enabled);\n            if (caps_enabled)\n            {\n                for (i = 0; i < num_caps_enabled; i++)\n                {\n                    pos_value = strstr (caps_enabled[i], \"=\");\n                    if (pos_value)\n                    {\n                        str_name = strndup (caps_enabled[i],\n                                            pos_value - caps_enabled[i]);\n                        if (str_name)\n                        {\n                            weechat_hashtable_set (server->cap_list,\n                                                   str_name, pos_value + 1);\n                            free (str_name);\n                        }\n                    }\n                    else\n                    {\n                        weechat_hashtable_set (server->cap_list,\n                                               caps_enabled[i], NULL);\n                    }\n                }\n            }\n\n            if (last_reply)\n            {\n                str_caps = weechat_string_dyn_alloc (128);\n                weechat_hashtable_map_string (server->cap_list,\n                                              irc_protocol_cap_print_cb,\n                                              str_caps);\n                weechat_printf_date_tags (\n                    server->buffer, date, NULL,\n                    _(\"%s%s: client capability, currently enabled: %s\"),\n                    weechat_prefix (\"network\"),\n                    IRC_PLUGIN_NAME,\n                    *str_caps);\n                weechat_string_dyn_free (str_caps, 1);\n            }\n\n            if (caps_enabled)\n                weechat_string_free_split (caps_enabled);\n        }\n    }\n    else if (strcmp (argv[3], \"ACK\") == 0)\n    {\n        if (argc > 4)\n        {\n            ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];\n\n            sasl_to_do = 0;\n            str_caps_enabled = weechat_string_dyn_alloc (128);\n            str_caps_disabled = weechat_string_dyn_alloc (128);\n\n            caps_supported = weechat_string_split (\n                ptr_caps,\n                \" \",\n                NULL,\n                WEECHAT_STRING_SPLIT_STRIP_LEFT\n                | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                0,\n                &num_caps_supported);\n            if (caps_supported)\n            {\n                for (i = 0; i < num_caps_supported; i++)\n                {\n                    if (caps_supported[i][0] == '-')\n                    {\n                        if (*str_caps_disabled[0])\n                            weechat_string_dyn_concat (str_caps_disabled, \" \");\n                        weechat_string_dyn_concat (str_caps_disabled,\n                                                   caps_supported[i] + 1);\n\n                        weechat_hashtable_remove (server->cap_list,\n                                                  caps_supported[i] + 1);\n                    }\n                    else\n                    {\n                        if (*str_caps_enabled[0])\n                            weechat_string_dyn_concat (str_caps_enabled, \" \");\n                        weechat_string_dyn_concat (str_caps_enabled,\n                                                   caps_supported[i]);\n\n                        weechat_hashtable_set (server->cap_list,\n                                               caps_supported[i], NULL);\n\n                        if (strcmp (caps_supported[i], \"sasl\") == 0)\n                            sasl_to_do = 1;\n                    }\n                }\n                weechat_string_free_split (caps_supported);\n            }\n            if (*str_caps_enabled[0] && *str_caps_disabled[0])\n            {\n                weechat_printf_date_tags (\n                    server->buffer, date, NULL,\n                    _(\"%s%s: client capability, enabled: %s, disabled: %s\"),\n                    weechat_prefix (\"network\"), IRC_PLUGIN_NAME,\n                    *str_caps_enabled, *str_caps_disabled);\n            }\n            else if (*str_caps_enabled[0])\n            {\n                weechat_printf_date_tags (\n                    server->buffer, date, NULL,\n                    _(\"%s%s: client capability, enabled: %s\"),\n                    weechat_prefix (\"network\"), IRC_PLUGIN_NAME,\n                    *str_caps_enabled);\n            }\n            else if (*str_caps_disabled[0])\n            {\n                weechat_printf_date_tags (\n                    server->buffer, date, NULL,\n                    _(\"%s%s: client capability, disabled: %s\"),\n                    weechat_prefix (\"network\"), IRC_PLUGIN_NAME,\n                    *str_caps_disabled);\n            }\n            weechat_string_dyn_free (str_caps_enabled, 1);\n            weechat_string_dyn_free (str_caps_disabled, 1);\n\n            if (sasl_to_do)\n            {\n                sasl_mechanism = IRC_SERVER_OPTION_INTEGER(\n                    server, IRC_SERVER_OPTION_SASL_MECHANISM);\n                if ((sasl_mechanism >= 0)\n                    && (sasl_mechanism < IRC_NUM_SASL_MECHANISMS))\n                {\n                    snprintf (str_msg_auth, sizeof (str_msg_auth),\n                              \"AUTHENTICATE %s\",\n                              irc_sasl_mechanism_string[sasl_mechanism]);\n                    weechat_string_toupper (str_msg_auth);\n                    irc_server_sendf (server, 0, NULL, str_msg_auth);\n                    if (server->hook_timer_sasl)\n                        weechat_unhook (server->hook_timer_sasl);\n                    timeout = IRC_SERVER_OPTION_INTEGER(\n                        server, IRC_SERVER_OPTION_SASL_TIMEOUT);\n                    server->hook_timer_sasl = weechat_hook_timer (\n                        timeout * 1000,\n                        0, 1,\n                        &irc_server_timer_sasl_cb,\n                        server, NULL);\n                }\n            }\n        }\n    }\n    else if (strcmp (argv[3], \"NAK\") == 0)\n    {\n        if (argc > 4)\n        {\n            ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];\n            weechat_printf_date_tags (\n                server->buffer, date, NULL,\n                _(\"%s%s: client capability, refused: %s\"),\n                weechat_prefix (\"error\"), IRC_PLUGIN_NAME, ptr_caps);\n            if (!server->is_connected)\n                irc_server_sendf (server, 0, NULL, \"CAP END\");\n        }\n    }\n    else if (strcmp (argv[3], \"NEW\") == 0)\n    {\n        if (argc > 4)\n        {\n            ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];\n            weechat_printf_date_tags (\n                server->buffer, date, NULL,\n                _(\"%s%s: client capability, now available: %s\"),\n                weechat_prefix (\"network\"), IRC_PLUGIN_NAME, ptr_caps);\n            caps_added = weechat_string_split (\n                ptr_caps,\n                \" \",\n                NULL,\n                WEECHAT_STRING_SPLIT_STRIP_LEFT\n                | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                0,\n                &num_caps_added);\n            if (caps_added)\n            {\n                for (i = 0; i < num_caps_added; i++)\n                {\n                    pos_value = strstr (caps_added[i], \"=\");\n                    if (pos_value)\n                    {\n                        str_name = strndup (caps_added[i],\n                                            pos_value - caps_added[i]);\n                        if (str_name)\n                        {\n                            weechat_hashtable_set (server->cap_ls,\n                                                   str_name, pos_value + 1);\n                            free (str_name);\n                        }\n                    }\n                    else\n                    {\n                        weechat_hashtable_set (server->cap_ls,\n                                               caps_added[i], NULL);\n                    }\n                }\n                weechat_string_free_split (caps_added);\n            }\n\n            \/* TODO: SASL Reauthentication *\/\n            irc_protocol_cap_sync (server, 0);\n        }\n    }\n    else if (strcmp (argv[3], \"DEL\") == 0)\n    {\n        if (argc > 4)\n        {\n            ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];\n            weechat_printf_date_tags (\n                server->buffer, date, NULL,\n                _(\"%s%s: client capability, removed: %s\"),\n                weechat_prefix (\"network\"), IRC_PLUGIN_NAME, ptr_caps);\n            caps_removed = weechat_string_split (\n                ptr_caps,\n                \" \",\n                NULL,\n                WEECHAT_STRING_SPLIT_STRIP_LEFT\n                | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                0,\n                &num_caps_removed);\n            if (caps_removed)\n            {\n                for (i = 0; i < num_caps_removed; i++)\n                {\n                    weechat_hashtable_remove (server->cap_ls, caps_removed[i]);\n                    weechat_hashtable_remove (server->cap_list, caps_removed[i]);\n                }\n                weechat_string_free_split (caps_removed);\n            }\n        }\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":2722,"total_token_length":2958,"max_tokens_setting":4096}
+{"idx":431631,"func":"static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  char\n    timestamp[MagickPathExtent];\n\n  const char\n    *value;\n\n  CINInfo\n    cin;\n\n  const StringInfo\n    *profile;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  const Quantum\n    *p;\n\n  ssize_t\n    i;\n\n  size_t\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  struct tm\n    utc_time;\n\n  time_t\n    seconds;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  if (image->colorspace != LogColorspace)\n    (void) TransformImageColorspace(image,LogColorspace,exception);\n  \/*\n    Write image information.\n  *\/\n  (void) memset(&cin,0,sizeof(cin));\n  offset=0;\n  cin.file.magic=0x802A5FD7UL;\n  offset+=WriteBlobLong(image,(unsigned int) cin.file.magic);\n  cin.file.image_offset=0x800;\n  offset+=WriteBlobLong(image,(unsigned int) cin.file.image_offset);\n  cin.file.generic_length=0x400;\n  offset+=WriteBlobLong(image,(unsigned int) cin.file.generic_length);\n  cin.file.industry_length=0x400;\n  offset+=WriteBlobLong(image,(unsigned int) cin.file.industry_length);\n  cin.file.user_length=0x00;\n  profile=GetImageProfile(image,\"dpx:user.data\");\n  if (profile != (StringInfo *) NULL)\n    {\n      cin.file.user_length+=(size_t) GetStringInfoLength(profile);\n      cin.file.user_length=(((cin.file.user_length+0x2000-1)\/0x2000)*0x2000);\n    }\n  offset+=WriteBlobLong(image,(unsigned int) cin.file.user_length);\n  cin.file.file_size=4*image->columns*image->rows+0x2000;\n  offset+=WriteBlobLong(image,(unsigned int) cin.file.file_size);\n  (void) CopyMagickString(cin.file.version,\"V4.5\",sizeof(cin.file.version));\n  offset+=WriteBlob(image,sizeof(cin.file.version),(unsigned char *)\n    cin.file.version);\n  value=GetCINProperty(image_info,image,\"dpx:file.filename\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.file.filename,value,sizeof(cin.file.filename));\n  else\n    (void) CopyMagickString(cin.file.filename,image->filename,\n      sizeof(cin.file.filename));\n  offset+=WriteBlob(image,sizeof(cin.file.filename),(unsigned char *)\n    cin.file.filename);\n  seconds=GetMagickTime();\n  GetMagickUTCtime(&seconds,&utc_time);\n  (void) memset(timestamp,0,sizeof(timestamp));\n  (void) strftime(timestamp,MagickPathExtent,\"%Y:%m:%d:%H:%M:%SUTC\",&utc_time);\n  (void) memset(cin.file.create_date,0,sizeof(cin.file.create_date));\n  (void) CopyMagickString(cin.file.create_date,timestamp,11);\n  offset+=WriteBlob(image,sizeof(cin.file.create_date),(unsigned char *)\n    cin.file.create_date);\n  (void) memset(cin.file.create_time,0,sizeof(cin.file.create_time));\n  (void) CopyMagickString(cin.file.create_time,timestamp+11,11);\n  offset+=WriteBlob(image,sizeof(cin.file.create_time),(unsigned char *)\n    cin.file.create_time);\n  offset+=WriteBlob(image,sizeof(cin.file.reserve),(unsigned char *)\n    cin.file.reserve);\n  cin.image.orientation=0x00;\n  offset+=WriteBlobByte(image,cin.image.orientation);\n  cin.image.number_channels=3;\n  offset+=WriteBlobByte(image,cin.image.number_channels);\n  offset+=WriteBlob(image,sizeof(cin.image.reserve1),(unsigned char *)\n    cin.image.reserve1);\n  for (i=0; i < 8; i++)\n  {\n    cin.image.channel[i].designator[0]=0; \/* universal metric *\/\n    offset+=WriteBlobByte(image,cin.image.channel[0].designator[0]);\n    cin.image.channel[i].designator[1]=(unsigned char) (i > 3 ? 0 : i+1); \/* channel color *\/;\n    offset+=WriteBlobByte(image,cin.image.channel[1].designator[0]);\n    cin.image.channel[i].bits_per_pixel=(unsigned char) image->depth;\n    offset+=WriteBlobByte(image,cin.image.channel[0].bits_per_pixel);\n    offset+=WriteBlobByte(image,cin.image.channel[0].reserve);\n    cin.image.channel[i].pixels_per_line=image->columns;\n    offset+=WriteBlobLong(image,(unsigned int)\n      cin.image.channel[0].pixels_per_line);\n    cin.image.channel[i].lines_per_image=image->rows;\n    offset+=WriteBlobLong(image,(unsigned int)\n      cin.image.channel[0].lines_per_image);\n    cin.image.channel[i].min_data=0;\n    offset+=WriteBlobFloat(image,cin.image.channel[0].min_data);\n    cin.image.channel[i].min_quantity=0.0;\n    offset+=WriteBlobFloat(image,cin.image.channel[0].min_quantity);\n    cin.image.channel[i].max_data=(float) ((MagickOffsetType)\n      GetQuantumRange(image->depth));\n    offset+=WriteBlobFloat(image,cin.image.channel[0].max_data);\n    cin.image.channel[i].max_quantity=2.048f;\n    offset+=WriteBlobFloat(image,cin.image.channel[0].max_quantity);\n  }\n  offset+=WriteBlobFloat(image,image->chromaticity.white_point.x);\n  offset+=WriteBlobFloat(image,image->chromaticity.white_point.y);\n  offset+=WriteBlobFloat(image,image->chromaticity.red_primary.x);\n  offset+=WriteBlobFloat(image,image->chromaticity.red_primary.y);\n  offset+=WriteBlobFloat(image,image->chromaticity.green_primary.x);\n  offset+=WriteBlobFloat(image,image->chromaticity.green_primary.y);\n  offset+=WriteBlobFloat(image,image->chromaticity.blue_primary.x);\n  offset+=WriteBlobFloat(image,image->chromaticity.blue_primary.y);\n  value=GetCINProperty(image_info,image,\"dpx:image.label\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.image.label,value,sizeof(cin.image.label));\n  offset+=WriteBlob(image,sizeof(cin.image.label),(unsigned char *)\n    cin.image.label);\n  offset+=WriteBlob(image,sizeof(cin.image.reserve),(unsigned char *)\n    cin.image.reserve);\n  \/*\n    Write data format information.\n  *\/\n  cin.data_format.interleave=0; \/* pixel interleave (rgbrgbr...) *\/\n  offset+=WriteBlobByte(image,cin.data_format.interleave);\n  cin.data_format.packing=5; \/* packing ssize_tword (32bit) boundaries *\/\n  offset+=WriteBlobByte(image,cin.data_format.packing);\n  cin.data_format.sign=0; \/* unsigned data *\/\n  offset+=WriteBlobByte(image,cin.data_format.sign);\n  cin.data_format.sense=0; \/* image sense: positive image *\/\n  offset+=WriteBlobByte(image,cin.data_format.sense);\n  cin.data_format.line_pad=0;\n  offset+=WriteBlobLong(image,(unsigned int) cin.data_format.line_pad);\n  cin.data_format.channel_pad=0;\n  offset+=WriteBlobLong(image,(unsigned int) cin.data_format.channel_pad);\n  offset+=WriteBlob(image,sizeof(cin.data_format.reserve),(unsigned char *)\n    cin.data_format.reserve);\n  \/*\n    Write origination information.\n  *\/\n  cin.origination.x_offset=0UL;\n  value=GetCINProperty(image_info,image,\"dpx:origination.x_offset\",exception);\n  if (value != (const char *) NULL)\n    cin.origination.x_offset=(ssize_t) StringToLong(value);\n  offset+=WriteBlobLong(image,(unsigned int) cin.origination.x_offset);\n  cin.origination.y_offset=0UL;\n  value=GetCINProperty(image_info,image,\"dpx:origination.y_offset\",exception);\n  if (value != (const char *) NULL)\n    cin.origination.y_offset=(ssize_t) StringToLong(value);\n  offset+=WriteBlobLong(image,(unsigned int) cin.origination.y_offset);\n  value=GetCINProperty(image_info,image,\"dpx:origination.filename\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.origination.filename,value,\n      sizeof(cin.origination.filename));\n  else\n    (void) CopyMagickString(cin.origination.filename,image->filename,\n      sizeof(cin.origination.filename));\n  offset+=WriteBlob(image,sizeof(cin.origination.filename),(unsigned char *)\n    cin.origination.filename);\n  (void) memset(timestamp,0,sizeof(timestamp));\n  (void) strftime(timestamp,MagickPathExtent,\"%Y:%m:%d:%H:%M:%SUTC\",&utc_time);\n  (void) memset(cin.origination.create_date,0,\n    sizeof(cin.origination.create_date));\n  (void) CopyMagickString(cin.origination.create_date,timestamp,11);\n  offset+=WriteBlob(image,sizeof(cin.origination.create_date),(unsigned char *)\n    cin.origination.create_date);\n  (void) memset(cin.origination.create_time,0,\n     sizeof(cin.origination.create_time));\n  (void) CopyMagickString(cin.origination.create_time,timestamp+11,15);\n  offset+=WriteBlob(image,sizeof(cin.origination.create_time),(unsigned char *)\n    cin.origination.create_time);\n  value=GetCINProperty(image_info,image,\"dpx:origination.device\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.origination.device,value,\n      sizeof(cin.origination.device));\n  offset+=WriteBlob(image,sizeof(cin.origination.device),(unsigned char *)\n    cin.origination.device);\n  value=GetCINProperty(image_info,image,\"dpx:origination.model\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.origination.model,value,\n      sizeof(cin.origination.model));\n  offset+=WriteBlob(image,sizeof(cin.origination.model),(unsigned char *)\n    cin.origination.model);\n  value=GetCINProperty(image_info,image,\"dpx:origination.serial\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.origination.serial,value,\n      sizeof(cin.origination.serial));\n  offset+=WriteBlob(image,sizeof(cin.origination.serial),(unsigned char *)\n    cin.origination.serial);\n  cin.origination.x_pitch=0.0f;\n  value=GetCINProperty(image_info,image,\"dpx:origination.x_pitch\",exception);\n  if (value != (const char *) NULL)\n    cin.origination.x_pitch=StringToDouble(value,(char **) NULL);\n  offset+=WriteBlobFloat(image,cin.origination.x_pitch);\n  cin.origination.y_pitch=0.0f;\n  value=GetCINProperty(image_info,image,\"dpx:origination.y_pitch\",exception);\n  if (value != (const char *) NULL)\n    cin.origination.y_pitch=StringToDouble(value,(char **) NULL);\n  offset+=WriteBlobFloat(image,cin.origination.y_pitch);\n  cin.origination.gamma=image->gamma;\n  offset+=WriteBlobFloat(image,cin.origination.gamma);\n  offset+=WriteBlob(image,sizeof(cin.origination.reserve),(unsigned char *)\n    cin.origination.reserve);\n  \/*\n    Image film information.\n  *\/\n  cin.film.id=0;\n  value=GetCINProperty(image_info,image,\"dpx:film.id\",exception);\n  if (value != (const char *) NULL)\n    cin.film.id=(char) StringToLong(value);\n  offset+=WriteBlobByte(image,(unsigned char) cin.film.id);\n  cin.film.type=0;\n  value=GetCINProperty(image_info,image,\"dpx:film.type\",exception);\n  if (value != (const char *) NULL)\n    cin.film.type=(char) StringToLong(value);\n  offset+=WriteBlobByte(image,(unsigned char) cin.film.type);\n  cin.film.offset=0;\n  value=GetCINProperty(image_info,image,\"dpx:film.offset\",exception);\n  if (value != (const char *) NULL)\n    cin.film.offset=(char) StringToLong(value);\n  offset+=WriteBlobByte(image,(unsigned char) cin.film.offset);\n  offset+=WriteBlobByte(image,(unsigned char) cin.film.reserve1);\n  cin.film.prefix=0UL;\n  value=GetCINProperty(image_info,image,\"dpx:film.prefix\",exception);\n  if (value != (const char *) NULL)\n    cin.film.prefix=StringToUnsignedLong(value);\n  offset+=WriteBlobLong(image,(unsigned int) cin.film.prefix);\n  cin.film.count=0UL;\n  value=GetCINProperty(image_info,image,\"dpx:film.count\",exception);\n  if (value != (const char *) NULL)\n    cin.film.count=StringToUnsignedLong(value);\n  offset+=WriteBlobLong(image,(unsigned int) cin.film.count);\n  value=GetCINProperty(image_info,image,\"dpx:film.format\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.film.format,value,sizeof(cin.film.format));\n  offset+=WriteBlob(image,sizeof(cin.film.format),(unsigned char *)\n    cin.film.format);\n  cin.film.frame_position=0UL;\n  value=GetCINProperty(image_info,image,\"dpx:film.frame_position\",exception);\n  if (value != (const char *) NULL)\n    cin.film.frame_position=StringToUnsignedLong(value);\n  offset+=WriteBlobLong(image,(unsigned int) cin.film.frame_position);\n  cin.film.frame_rate=0.0f;\n  value=GetCINProperty(image_info,image,\"dpx:film.frame_rate\",exception);\n  if (value != (const char *) NULL)\n    cin.film.frame_rate=StringToDouble(value,(char **) NULL);\n  offset+=WriteBlobFloat(image,cin.film.frame_rate);\n  value=GetCINProperty(image_info,image,\"dpx:film.frame_id\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.film.frame_id,value,sizeof(cin.film.frame_id));\n  offset+=WriteBlob(image,sizeof(cin.film.frame_id),(unsigned char *)\n    cin.film.frame_id);\n  value=GetCINProperty(image_info,image,\"dpx:film.slate_info\",exception);\n  if (value != (const char *) NULL)\n    (void) CopyMagickString(cin.film.slate_info,value,\n      sizeof(cin.film.slate_info));\n  offset+=WriteBlob(image,sizeof(cin.film.slate_info),(unsigned char *)\n    cin.film.slate_info);\n  offset+=WriteBlob(image,sizeof(cin.film.reserve),(unsigned char *)\n    cin.film.reserve);\n  if (profile != (StringInfo *) NULL)\n    offset+=WriteBlob(image,GetStringInfoLength(profile),\n      GetStringInfoDatum(profile));\n  while (offset < (MagickOffsetType) cin.file.image_offset)\n    offset+=WriteBlobByte(image,0x00);\n  \/*\n    Convert pixel packets to CIN raster image.\n  *\/\n  quantum_info=AcquireQuantumInfo(image_info,image);\n  if (quantum_info == (QuantumInfo *) NULL)\n    ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n  quantum_info->quantum=32;\n  quantum_info->pack=MagickFalse;\n  quantum_type=RGBQuantum;\n  pixels=(unsigned char *) GetQuantumPixels(quantum_info);\n  length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    p=GetVirtualPixels(image,0,y,image->columns,1,exception);\n    if (p == (const Quantum *) NULL)\n      break;\n    (void) ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n      quantum_type,pixels,exception);\n    count=WriteBlob(image,length,pixels);\n    if (count != (ssize_t) length)\n      break;\n    status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n      image->rows);\n    if (status == MagickFalse)\n      break;\n  }\n  quantum_info=DestroyQuantumInfo(quantum_info);\n  (void) CloseBlob(image);\n  return(status);\n}","target":0,"code_token_length":3694,"total_token_length":3930,"max_tokens_setting":4096}
+{"idx":268104,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Checks what we're remapping and inverts the relevant remapping Tensors to\n    \/\/ be maps with key = old ID, value = new ID.\n    std::unordered_map<int64_t, int64_t> old_row_to_new_row_map;\n    std::vector<bool> row_id_present;\n    const Tensor* row_remapping_t;\n    OP_REQUIRES_OK(context, context->input(\"row_remapping\", &row_remapping_t));\n    OP_REQUIRES(\n        context, row_remapping_t->dims() == 1,\n        errors::InvalidArgument(\"The `row_remapping` tensor must be 1-D, got \"\n                                \"a tensor of shape \",\n                                row_remapping_t->shape().DebugString()));\n    const auto row_remapping = row_remapping_t->vec<int64_t>();\n    OP_REQUIRES(context, row_remapping.size() == num_rows_,\n                errors::InvalidArgument(strings::StrCat(\n                    \"Size of row_remapping is \", row_remapping.size(),\n                    \" instead of being equal to num_rows=\", num_rows_)));\n    OP_REQUIRES_OK(context, RemapVectorToMap(row_remapping, &row_id_present,\n                                             &old_row_to_new_row_map));\n\n    \/\/ Calculates the min\/max old row ID that we need to read, to save us from\n    \/\/ reading some unnecessary slices of the old tensor.\n    int64_t min_old_row = -1;\n    int64_t max_old_row = -1;\n    for (int i = 0; i < row_remapping.size(); ++i) {\n      if (min_old_row < 0 ||\n          (row_remapping(i) >= 0 && row_remapping(i) < min_old_row)) {\n        min_old_row = row_remapping(i);\n      }\n      if (max_old_row < 0 ||\n          (row_remapping(i) >= 0 && row_remapping(i) > max_old_row)) {\n        max_old_row = row_remapping(i);\n      }\n    }\n\n    \/\/ Processes the remapping for columns.\n    std::unordered_map<int64_t, int64_t> old_col_to_new_col_map;\n    std::vector<bool> col_id_present;\n    const Tensor* col_remapping_t;\n    OP_REQUIRES_OK(context, context->input(\"col_remapping\", &col_remapping_t));\n    const auto col_remapping = col_remapping_t->vec<int64_t>();\n    \/\/ Note that we always \"remap rows\", even when the row vocabulary does\n    \/\/ not change, because partitioning requires a mapping from partitioned\n    \/\/ Variables to the full checkpoints we load.\n    const bool remap_cols = col_remapping.size() > 0;\n    if (remap_cols) {\n      OP_REQUIRES(\n          context, col_remapping.size() == num_cols_,\n          errors::InvalidArgument(strings::StrCat(\n              \"Provided col_remapping, but its size is \", col_remapping.size(),\n              \" instead of being equal to num_cols=\", num_cols_)));\n      OP_REQUIRES_OK(context, RemapVectorToMap(col_remapping, &col_id_present,\n                                               &old_col_to_new_col_map));\n    } else {\n      col_id_present.clear();\n      col_id_present.resize(num_cols_, true);\n    }\n\n    \/\/ Processes the checkpoint source and the provided Tensor name.\n    const Tensor* ckpt_path_t;\n    OP_REQUIRES_OK(context, context->input(\"ckpt_path\", &ckpt_path_t));\n    OP_REQUIRES(\n        context, ckpt_path_t->NumElements() == 1,\n        errors::InvalidArgument(\"The `ckpt_path` tensor must have exactly one \"\n                                \"element, got tensor of shape \",\n                                ckpt_path_t->shape().DebugString()));\n    const string& ckpt_path = ckpt_path_t->scalar<tstring>()();\n    const Tensor* old_tensor_name_t;\n    OP_REQUIRES_OK(context,\n                   context->input(\"old_tensor_name\", &old_tensor_name_t));\n    const string& old_tensor_name = old_tensor_name_t->scalar<tstring>()();\n\n    LOG(INFO) << \"Processing checkpoint : \" << ckpt_path;\n    BundleReader reader(context->env(), ckpt_path);\n    OP_REQUIRES_OK(context, reader.status());\n\n    DataType tensor_type;\n    TensorShape tensor_shape;\n    OP_REQUIRES_OK(context, reader.LookupDtypeAndShape(\n                                old_tensor_name, &tensor_type, &tensor_shape));\n    OP_REQUIRES(context, tensor_type == DT_FLOAT,\n                errors::InvalidArgument(strings::StrCat(\n                    \"Tensor \", old_tensor_name, \" has invalid type \",\n                    DataTypeString(tensor_type), \" instead of expected type \",\n                    DataTypeString(DT_FLOAT))));\n    \/\/ This op is limited to loading Tensors of rank 2 (matrices).\n    OP_REQUIRES(\n        context, tensor_shape.dims() == 2,\n        errors::InvalidArgument(strings::StrCat(\n            \"Tensor \", old_tensor_name, \" has shape \",\n            tensor_shape.DebugString(), \" of invalid rank \",\n            tensor_shape.dims(), \" instead of expected shape of rank 2.\")));\n\n    if (!remap_cols) {\n      \/\/ TODO(weiho): Consider relaxing this restriction to allow partial column\n      \/\/ loading (even when no column remapping is specified) if there turns out\n      \/\/ to be a use case for it.\n      OP_REQUIRES(context, num_cols_ == tensor_shape.dim_size(1),\n                  errors::InvalidArgument(strings::StrCat(\n                      \"Tensor \", old_tensor_name, \" has shape \",\n                      tensor_shape.DebugString(),\n                      \", where the size of its 2nd dimension is \",\n                      tensor_shape.dim_size(1),\n                      \" instead of being equal to num_cols=\", num_cols_)));\n    }\n\n    \/\/ Uses TensorSlice to potentially load the old tensor in chunks in case\n    \/\/ memory usage is a concern.\n    std::vector<TensorSlice> tensor_slices;\n    TensorSlice slice(tensor_shape.dims());\n    if (min_old_row >= 0 && max_old_row >= 0) {\n      int64_t row_start = min_old_row;\n      \/\/ TODO(weiho): Given the list of old row IDs of interest (the keys of\n      \/\/ old_row_to_new_row_map), we could also try something smarter to\n      \/\/ find some minimal set of covering ranges for the list of old row IDs\n      \/\/ such that the size of each range is less than max_rows_in_memory_.\n      while (row_start <= max_old_row) {\n        const int64_t slice_length =\n            max_rows_in_memory_ <= 0\n                \/\/ If max_rows_in_memory_ <= 0, we just load the entire chunk.\n                ? max_old_row - row_start + 1\n                : std::min(max_rows_in_memory_, max_old_row - row_start + 1);\n        slice.set_start(0, row_start);\n        slice.set_length(0, slice_length);\n        tensor_slices.push_back(slice);\n        row_start += slice_length;\n      }\n    }\n\n    \/\/ Allocates the output matrix.\n    Tensor* output_matrix_t = nullptr;\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(\"output_matrix\",\n                                            TensorShape({num_rows_, num_cols_}),\n                                            &output_matrix_t));\n    auto output_matrix = output_matrix_t->matrix<float>();\n\n    \/\/ Iterates through tensor slices and copies over values from the old tensor\n    \/\/ to the output matrix.\n    int64_t row_index = min_old_row;\n    int64_t rows_copied = 0;\n    Tensor loaded_tensor_t;\n    for (const TensorSlice& tensor_slice : tensor_slices) {\n      LOG(INFO) << \"Loading slice \" << tensor_slice.DebugString();\n      TensorShape slice_shape;\n      OP_REQUIRES_OK(context,\n                     tensor_slice.SliceTensorShape(tensor_shape, &slice_shape));\n      \/\/ Potentially re-allocates the tensor buffer since the last slice may\n      \/\/ have fewer rows than the other slices.\n      if (loaded_tensor_t.shape() != slice_shape) {\n        loaded_tensor_t = Tensor(DT_FLOAT, slice_shape);\n      }\n      OP_REQUIRES_OK(context, reader.LookupSlice(old_tensor_name, tensor_slice,\n                                                 &loaded_tensor_t));\n\n      \/\/ Iterates through the old loaded tensor slice row-by-row.\n      for (int row = 0; row < loaded_tensor_t.dim_size(0); ++row, ++row_index) {\n        if (row_index % 500000 == min_old_row) {\n          LOG(INFO) << \"Processing old row \" << row_index;\n        }\n\n        \/\/ If the old row ID is not found in old_row_to_new_row_map, continue\n        \/\/ to the next row; otherwise, copy it to the output matrix.\n        const int64_t* new_row_ptr =\n            gtl::FindOrNull(old_row_to_new_row_map, row_index);\n        if (new_row_ptr == nullptr) {\n          continue;\n        }\n        ++rows_copied;\n        const int64_t new_row = *new_row_ptr;\n\n        \/\/ Copies over the row element-by-element, in case remapping is needed\n        \/\/ along the column axis.\n        const auto& loaded_tensor = loaded_tensor_t.matrix<float>();\n        for (int old_col = 0; old_col < loaded_tensor_t.dim_size(1);\n             ++old_col) {\n          int64_t new_col = old_col;\n          if (remap_cols) {\n            const int64_t* new_col_ptr =\n                gtl::FindOrNull(old_col_to_new_col_map, old_col);\n            if (new_col_ptr == nullptr) {\n              \/\/ Column remapping is specified, but this column is not found in\n              \/\/ old_col_to_new_col_map, so we leave it uninitialized, to be\n              \/\/ filled in with initializing_values later.\n              continue;\n            }\n            new_col = *new_col_ptr;\n          }\n\n          OP_REQUIRES(context,\n                      new_row < num_rows_ && new_col < num_cols_ &&\n                          new_row >= 0 && new_col >= 0,\n                      errors::Internal(strings::StrCat(\n                          \"new_row=\", new_row, \" and new_col=\", new_col,\n                          \" should have been less than num_rows_=\", num_rows_,\n                          \" and num_cols_=\", num_cols_,\n                          \" and non-negative. This should never have happened \"\n                          \"if the code were correct. Please file a bug.\")));\n          output_matrix(new_row, new_col) = loaded_tensor(row, old_col);\n        }\n      }\n    }\n    LOG(INFO) << \"Copied \" << rows_copied << \" rows from old matrix (with \"\n              << tensor_shape.dim_size(0) << \" rows) to new matrix (with \"\n              << num_rows_ << \" rows).\";\n\n    \/\/ At this point, there are potentially whole rows\/columns uninitialized\n    \/\/ (corresponding to the indices where row_id_present\/col_id_present are\n    \/\/ false). We fill this in cell-by-cell using row_id_present and\n    \/\/ col_id_present while dequeuing from the initializing_values vector.\n    const Tensor* initializing_values_t;\n    OP_REQUIRES_OK(\n        context, context->input(\"initializing_values\", &initializing_values_t));\n    const auto initializing_values = initializing_values_t->flat<float>();\n    int64_t initializing_values_index = 0;\n    for (int i = 0; i < num_rows_; ++i) {\n      for (int j = 0; j < num_cols_; ++j) {\n        if (row_id_present[i] && col_id_present[j]) continue;\n        OP_REQUIRES(\n            context, initializing_values_index < initializing_values.size(),\n            errors::InvalidArgument(\n                \"initializing_values contained \", initializing_values.size(),\n                \" elements, but more missing values remain.\"));\n        output_matrix(i, j) = initializing_values(initializing_values_index);\n        ++initializing_values_index;\n      }\n    }\n\n    \/\/ Checks that we used all the given initializing values.\n    OP_REQUIRES(\n        context, initializing_values_index == initializing_values.size(),\n        errors::InvalidArgument(\n            \"initializing_values contained \", initializing_values.size(),\n            \" elements, but only \", initializing_values_index,\n            \" elements were used to fill in missing values.\"));\n  }","target":0,"code_token_length":2574,"total_token_length":2810,"max_tokens_setting":4096}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..9259620d2c806bfa9a5b9dd5ac53259cc3f1a842
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e4038f80f02bcd702e7a0b902ad293dc1400579ccf9af65f9e9a1753c5c5ea13
+size 2135579
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..0d27e14b18580434e4ea47cca15bf3d24bed644b
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.jsonl
@@ -0,0 +1,50 @@
+{"idx":333086,"func":"nfa_regatom(void)\n{\n    int\t\tc;\n    int\t\tcharclass;\n    int\t\tequiclass;\n    int\t\tcollclass;\n    int\t\tgot_coll_char;\n    char_u\t*p;\n    char_u\t*endp;\n    char_u\t*old_regparse = regparse;\n    int\t\textra = 0;\n    int\t\temit_range;\n    int\t\tnegated;\n    int\t\tresult;\n    int\t\tstartc = -1;\n    int\t\tsave_prev_at_start = prev_at_start;\n\n    c = getchr();\n    switch (c)\n    {\n\tcase NUL:\n\t    EMSG_RET_FAIL(_(e_nul_found));\n\n\tcase Magic('^'):\n\t    EMIT(NFA_BOL);\n\t    break;\n\n\tcase Magic('$'):\n\t    EMIT(NFA_EOL);\n#if defined(FEAT_SYN_HL) || defined(PROTO)\n\t    had_eol = TRUE;\n#endif\n\t    break;\n\n\tcase Magic('<'):\n\t    EMIT(NFA_BOW);\n\t    break;\n\n\tcase Magic('>'):\n\t    EMIT(NFA_EOW);\n\t    break;\n\n\tcase Magic('_'):\n\t    c = no_Magic(getchr());\n\t    if (c == NUL)\n\t\tEMSG_RET_FAIL(_(e_nul_found));\n\n\t    if (c == '^')\t\/\/ \"\\_^\" is start-of-line\n\t    {\n\t\tEMIT(NFA_BOL);\n\t\tbreak;\n\t    }\n\t    if (c == '$')\t\/\/ \"\\_$\" is end-of-line\n\t    {\n\t\tEMIT(NFA_EOL);\n#if defined(FEAT_SYN_HL) || defined(PROTO)\n\t\thad_eol = TRUE;\n#endif\n\t\tbreak;\n\t    }\n\n\t    extra = NFA_ADD_NL;\n\n\t    \/\/ \"\\_[\" is collection plus newline\n\t    if (c == '[')\n\t\tgoto collection;\n\n\t\/\/ \"\\_x\" is character class plus newline\n\t\/\/ FALLTHROUGH\n\n\t\/*\n\t * Character classes.\n\t *\/\n\tcase Magic('.'):\n\tcase Magic('i'):\n\tcase Magic('I'):\n\tcase Magic('k'):\n\tcase Magic('K'):\n\tcase Magic('f'):\n\tcase Magic('F'):\n\tcase Magic('p'):\n\tcase Magic('P'):\n\tcase Magic('s'):\n\tcase Magic('S'):\n\tcase Magic('d'):\n\tcase Magic('D'):\n\tcase Magic('x'):\n\tcase Magic('X'):\n\tcase Magic('o'):\n\tcase Magic('O'):\n\tcase Magic('w'):\n\tcase Magic('W'):\n\tcase Magic('h'):\n\tcase Magic('H'):\n\tcase Magic('a'):\n\tcase Magic('A'):\n\tcase Magic('l'):\n\tcase Magic('L'):\n\tcase Magic('u'):\n\tcase Magic('U'):\n\t    p = vim_strchr(classchars, no_Magic(c));\n\t    if (p == NULL)\n\t    {\n\t\tif (extra == NFA_ADD_NL)\n\t\t{\n\t\t    semsg(_(e_ill_char_class), c);\n\t\t    rc_did_emsg = TRUE;\n\t\t    return FAIL;\n\t\t}\n\t\tsiemsg(\"INTERNAL: Unknown character class char: %d\", c);\n\t\treturn FAIL;\n\t    }\n\n\t    \/\/ When '.' is followed by a composing char ignore the dot, so that\n\t    \/\/ the composing char is matched here.\n\t    if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr()))\n\t    {\n\t\told_regparse = regparse;\n\t\tc = getchr();\n\t\tgoto nfa_do_multibyte;\n\t    }\n\t    EMIT(nfa_classcodes[p - classchars]);\n\t    if (extra == NFA_ADD_NL)\n\t    {\n\t\tEMIT(NFA_NEWL);\n\t\tEMIT(NFA_OR);\n\t\tregflags |= RF_HASNL;\n\t    }\n\t    break;\n\n\tcase Magic('n'):\n\t    if (reg_string)\n\t\t\/\/ In a string \"\\n\" matches a newline character.\n\t\tEMIT(NL);\n\t    else\n\t    {\n\t\t\/\/ In buffer text \"\\n\" matches the end of a line.\n\t\tEMIT(NFA_NEWL);\n\t\tregflags |= RF_HASNL;\n\t    }\n\t    break;\n\n\tcase Magic('('):\n\t    if (nfa_reg(REG_PAREN) == FAIL)\n\t\treturn FAIL;\t    \/\/ cascaded error\n\t    break;\n\n\tcase Magic('|'):\n\tcase Magic('&'):\n\tcase Magic(')'):\n\t    semsg(_(e_misplaced), no_Magic(c));\n\t    return FAIL;\n\n\tcase Magic('='):\n\tcase Magic('?'):\n\tcase Magic('+'):\n\tcase Magic('@'):\n\tcase Magic('*'):\n\tcase Magic('{'):\n\t    \/\/ these should follow an atom, not form an atom\n\t    semsg(_(e_misplaced), no_Magic(c));\n\t    return FAIL;\n\n\tcase Magic('~'):\n\t    {\n\t\tchar_u\t    *lp;\n\n\t\t\/\/ Previous substitute pattern.\n\t\t\/\/ Generated as \"\\%(pattern\\)\".\n\t\tif (reg_prev_sub == NULL)\n\t\t{\n\t\t    emsg(_(e_no_previous_substitute_regular_expression));\n\t\t    return FAIL;\n\t\t}\n\t\tfor (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp))\n\t\t{\n\t\t    EMIT(PTR2CHAR(lp));\n\t\t    if (lp != reg_prev_sub)\n\t\t\tEMIT(NFA_CONCAT);\n\t\t}\n\t\tEMIT(NFA_NOPEN);\n\t\tbreak;\n\t    }\n\n\tcase Magic('1'):\n\tcase Magic('2'):\n\tcase Magic('3'):\n\tcase Magic('4'):\n\tcase Magic('5'):\n\tcase Magic('6'):\n\tcase Magic('7'):\n\tcase Magic('8'):\n\tcase Magic('9'):\n\t    {\n\t\tint refnum = no_Magic(c) - '1';\n\n\t\tif (!seen_endbrace(refnum + 1))\n\t\t    return FAIL;\n\t\tEMIT(NFA_BACKREF1 + refnum);\n\t\trex.nfa_has_backref = TRUE;\n\t    }\n\t    break;\n\n\tcase Magic('z'):\n\t    c = no_Magic(getchr());\n\t    switch (c)\n\t    {\n\t\tcase 's':\n\t\t    EMIT(NFA_ZSTART);\n\t\t    if (re_mult_next(\"\\\\zs\") == FAIL)\n\t\t\treturn FAIL;\n\t\t    break;\n\t\tcase 'e':\n\t\t    EMIT(NFA_ZEND);\n\t\t    rex.nfa_has_zend = TRUE;\n\t\t    if (re_mult_next(\"\\\\ze\") == FAIL)\n\t\t\treturn FAIL;\n\t\t    break;\n#ifdef FEAT_SYN_HL\n\t\tcase '1':\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '4':\n\t\tcase '5':\n\t\tcase '6':\n\t\tcase '7':\n\t\tcase '8':\n\t\tcase '9':\n\t\t    \/\/ \\z1...\\z9\n\t\t    if ((reg_do_extmatch & REX_USE) == 0)\n\t\t\tEMSG_RET_FAIL(_(e_z1_not_allowed));\n\t\t    EMIT(NFA_ZREF1 + (no_Magic(c) - '1'));\n\t\t    \/\/ No need to set rex.nfa_has_backref, the sub-matches don't\n\t\t    \/\/ change when \\z1 .. \\z9 matches or not.\n\t\t    re_has_z = REX_USE;\n\t\t    break;\n\t\tcase '(':\n\t\t    \/\/ \\z(\n\t\t    if ((reg_do_extmatch & REX_SET) == 0)\n\t\t\tEMSG_RET_FAIL(_(e_z_not_allowed));\n\t\t    if (nfa_reg(REG_ZPAREN) == FAIL)\n\t\t\treturn FAIL;\t    \/\/ cascaded error\n\t\t    re_has_z = REX_SET;\n\t\t    break;\n#endif\n\t\tdefault:\n\t\t    semsg(_(\"E867: (NFA) Unknown operator '\\\\z%c'\"),\n\t\t\t\t\t\t\t\t no_Magic(c));\n\t\t    return FAIL;\n\t    }\n\t    break;\n\n\tcase Magic('%'):\n\t    c = no_Magic(getchr());\n\t    switch (c)\n\t    {\n\t\t\/\/ () without a back reference\n\t\tcase '(':\n\t\t    if (nfa_reg(REG_NPAREN) == FAIL)\n\t\t\treturn FAIL;\n\t\t    EMIT(NFA_NOPEN);\n\t\t    break;\n\n\t\tcase 'd':   \/\/ %d123 decimal\n\t\tcase 'o':   \/\/ %o123 octal\n\t\tcase 'x':   \/\/ %xab hex 2\n\t\tcase 'u':   \/\/ %uabcd hex 4\n\t\tcase 'U':   \/\/ %U1234abcd hex 8\n\t\t    {\n\t\t\tlong nr;\n\n\t\t\tswitch (c)\n\t\t\t{\n\t\t\t    case 'd': nr = getdecchrs(); break;\n\t\t\t    case 'o': nr = getoctchrs(); break;\n\t\t\t    case 'x': nr = gethexchrs(2); break;\n\t\t\t    case 'u': nr = gethexchrs(4); break;\n\t\t\t    case 'U': nr = gethexchrs(8); break;\n\t\t\t    default:  nr = -1; break;\n\t\t\t}\n\n\t\t\tif (nr < 0 || nr > INT_MAX)\n\t\t\t    EMSG2_RET_FAIL(\n\t\t\t       _(\"E678: Invalid character after %s%%[dxouU]\"),\n\t\t\t\t    reg_magic == MAGIC_ALL);\n\t\t\t\/\/ A NUL is stored in the text as NL\n\t\t\t\/\/ TODO: what if a composing character follows?\n\t\t\tEMIT(nr == 0 ? 0x0a : nr);\n\t\t    }\n\t\t    break;\n\n\t\t\/\/ Catch \\%^ and \\%$ regardless of where they appear in the\n\t\t\/\/ pattern -- regardless of whether or not it makes sense.\n\t\tcase '^':\n\t\t    EMIT(NFA_BOF);\n\t\t    break;\n\n\t\tcase '$':\n\t\t    EMIT(NFA_EOF);\n\t\t    break;\n\n\t\tcase '#':\n\t\t    EMIT(NFA_CURSOR);\n\t\t    break;\n\n\t\tcase 'V':\n\t\t    EMIT(NFA_VISUAL);\n\t\t    break;\n\n\t\tcase 'C':\n\t\t    EMIT(NFA_ANY_COMPOSING);\n\t\t    break;\n\n\t\tcase '[':\n\t\t    {\n\t\t\tint\t    n;\n\n\t\t\t\/\/ \\%[abc]\n\t\t\tfor (n = 0; (c = peekchr()) != ']'; ++n)\n\t\t\t{\n\t\t\t    if (c == NUL)\n\t\t\t\tEMSG2_RET_FAIL(_(e_missing_sb),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t\t\t    \/\/ recursive call!\n\t\t\t    if (nfa_regatom() == FAIL)\n\t\t\t\treturn FAIL;\n\t\t\t}\n\t\t\tgetchr();  \/\/ get the ]\n\t\t\tif (n == 0)\n\t\t\t    EMSG2_RET_FAIL(_(e_empty_sb),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t\t\tEMIT(NFA_OPT_CHARS);\n\t\t\tEMIT(n);\n\n\t\t\t\/\/ Emit as \"\\%(\\%[abc]\\)\" to be able to handle\n\t\t\t\/\/ \"\\%[abc]*\" which would cause the empty string to be\n\t\t\t\/\/ matched an unlimited number of times. NFA_NOPEN is\n\t\t\t\/\/ added only once at a position, while NFA_SPLIT is\n\t\t\t\/\/ added multiple times.  This is more efficient than\n\t\t\t\/\/ not allowing NFA_SPLIT multiple times, it is used\n\t\t\t\/\/ a lot.\n\t\t\tEMIT(NFA_NOPEN);\n\t\t\tbreak;\n\t\t    }\n\n\t\tdefault:\n\t\t    {\n\t\t\tlong_u\tn = 0;\n\t\t\tint\tcmp = c;\n\t\t\tint\tcur = FALSE;\n\n\t\t\tif (c == '<' || c == '>')\n\t\t\t    c = getchr();\n\t\t\tif (no_Magic(c) == '.')\n\t\t\t{\n\t\t\t    cur = TRUE;\n\t\t\t    c = getchr();\n\t\t\t}\n\t\t\twhile (VIM_ISDIGIT(c))\n\t\t\t{\n\t\t\t    long_u tmp;\n\n\t\t\t    if (cur)\n\t\t\t\tsemsg(_(e_regexp_number_after_dot_pos_search),\n\t\t\t\t\t\t\t\t no_Magic(c));\n\t\t\t    tmp = n * 10 + (c - '0');\n\n\t\t\t    if (tmp < n)\n\t\t\t    {\n\t\t\t\t\/\/ overflow.\n\t\t\t\temsg(_(e_value_too_large));\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    n = tmp;\n\t\t\t    c = getchr();\n\t\t\t}\n\t\t\tif (c == 'l' || c == 'c' || c == 'v')\n\t\t\t{\n\t\t\t    long_u limit = INT_MAX;\n\n\t\t\t    if (c == 'l')\n\t\t\t    {\n\t\t\t\tif (cur)\n\t\t\t\t    n = curwin->w_cursor.lnum;\n\t\t\t\t\/\/ \\%{n}l  \\%{n}<l  \\%{n}>l\n\t\t\t\tEMIT(cmp == '<' ? NFA_LNUM_LT :\n\t\t\t\t     cmp == '>' ? NFA_LNUM_GT : NFA_LNUM);\n\t\t\t\tif (save_prev_at_start)\n\t\t\t\t    at_start = TRUE;\n\t\t\t    }\n\t\t\t    else if (c == 'c')\n\t\t\t    {\n\t\t\t\tif (cur)\n\t\t\t\t{\n\t\t\t\t    n = curwin->w_cursor.col;\n\t\t\t\t    n++;\n\t\t\t\t}\n\t\t\t\t\/\/ \\%{n}c  \\%{n}<c  \\%{n}>c\n\t\t\t\tEMIT(cmp == '<' ? NFA_COL_LT :\n\t\t\t\t     cmp == '>' ? NFA_COL_GT : NFA_COL);\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\tif (cur)\n\t\t\t\t{\n\t\t\t\t    colnr_T vcol = 0;\n\n\t\t\t\t    getvvcol(curwin, &curwin->w_cursor,\n\t\t\t\t\t\t\t    NULL, NULL, &vcol);\n\t\t\t\t    n = ++vcol;\n\t\t\t\t}\n\t\t\t\t\/\/ \\%{n}v  \\%{n}<v  \\%{n}>v\n\t\t\t\tEMIT(cmp == '<' ? NFA_VCOL_LT :\n\t\t\t\t     cmp == '>' ? NFA_VCOL_GT : NFA_VCOL);\n\t\t\t\tlimit = INT_MAX \/ MB_MAXBYTES;\n\t\t\t    }\n\t\t\t    if (n >= limit)\n\t\t\t    {\n\t\t\t\temsg(_(e_value_too_large));\n\t\t\t\treturn FAIL;\n\t\t\t    }\n\t\t\t    EMIT((int)n);\n\t\t\t    break;\n\t\t\t}\n\t\t\telse if (c == '\\'' && n == 0)\n\t\t\t{\n\t\t\t    \/\/ \\%'m  \\%<'m  \\%>'m\n\t\t\t    EMIT(cmp == '<' ? NFA_MARK_LT :\n\t\t\t\t cmp == '>' ? NFA_MARK_GT : NFA_MARK);\n\t\t\t    EMIT(getchr());\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t    semsg(_(\"E867: (NFA) Unknown operator '\\\\%%%c'\"),\n\t\t\t\t\t\t\t\t no_Magic(c));\n\t\t    return FAIL;\n\t    }\n\t    break;\n\n\tcase Magic('['):\ncollection:\n\t    \/*\n\t     * [abc]  uses NFA_START_COLL - NFA_END_COLL\n\t     * [^abc] uses NFA_START_NEG_COLL - NFA_END_NEG_COLL\n\t     * Each character is produced as a regular state, using\n\t     * NFA_CONCAT to bind them together.\n\t     * Besides normal characters there can be:\n\t     * - character classes  NFA_CLASS_*\n\t     * - ranges, two characters followed by NFA_RANGE.\n\t     *\/\n\n\t    p = regparse;\n\t    endp = skip_anyof(p);\n\t    if (*endp == ']')\n\t    {\n\t\t\/*\n\t\t * Try to reverse engineer character classes. For example,\n\t\t * recognize that [0-9] stands for \\d and [A-Za-z_] for \\h,\n\t\t * and perform the necessary substitutions in the NFA.\n\t\t *\/\n\t\tresult = nfa_recognize_char_class(regparse, endp,\n\t\t\t\t\t\t\t extra == NFA_ADD_NL);\n\t\tif (result != FAIL)\n\t\t{\n\t\t    if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL)\n\t\t    {\n\t\t\tEMIT(result - NFA_ADD_NL);\n\t\t\tEMIT(NFA_NEWL);\n\t\t\tEMIT(NFA_OR);\n\t\t    }\n\t\t    else\n\t\t\tEMIT(result);\n\t\t    regparse = endp;\n\t\t    MB_PTR_ADV(regparse);\n\t\t    return OK;\n\t\t}\n\t\t\/*\n\t\t * Failed to recognize a character class. Use the simple\n\t\t * version that turns [abc] into 'a' OR 'b' OR 'c'\n\t\t *\/\n\t\tstartc = -1;\n\t\tnegated = FALSE;\n\t\tif (*regparse == '^')\t\t\t\/\/ negated range\n\t\t{\n\t\t    negated = TRUE;\n\t\t    MB_PTR_ADV(regparse);\n\t\t    EMIT(NFA_START_NEG_COLL);\n\t\t}\n\t\telse\n\t\t    EMIT(NFA_START_COLL);\n\t\tif (*regparse == '-')\n\t\t{\n\t\t    startc = '-';\n\t\t    EMIT(startc);\n\t\t    EMIT(NFA_CONCAT);\n\t\t    MB_PTR_ADV(regparse);\n\t\t}\n\t\t\/\/ Emit the OR branches for each character in the []\n\t\temit_range = FALSE;\n\t\twhile (regparse < endp)\n\t\t{\n\t\t    int\t    oldstartc = startc;\n\n\t\t    startc = -1;\n\t\t    got_coll_char = FALSE;\n\t\t    if (*regparse == '[')\n\t\t    {\n\t\t\t\/\/ Check for [: :], [= =], [. .]\n\t\t\tequiclass = collclass = 0;\n\t\t\tcharclass = get_char_class(®parse);\n\t\t\tif (charclass == CLASS_NONE)\n\t\t\t{\n\t\t\t    equiclass = get_equi_class(®parse);\n\t\t\t    if (equiclass == 0)\n\t\t\t\tcollclass = get_coll_element(®parse);\n\t\t\t}\n\n\t\t\t\/\/ Character class like [:alpha:]\n\t\t\tif (charclass != CLASS_NONE)\n\t\t\t{\n\t\t\t    switch (charclass)\n\t\t\t    {\n\t\t\t\tcase CLASS_ALNUM:\n\t\t\t\t    EMIT(NFA_CLASS_ALNUM);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_ALPHA:\n\t\t\t\t    EMIT(NFA_CLASS_ALPHA);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_BLANK:\n\t\t\t\t    EMIT(NFA_CLASS_BLANK);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_CNTRL:\n\t\t\t\t    EMIT(NFA_CLASS_CNTRL);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_DIGIT:\n\t\t\t\t    EMIT(NFA_CLASS_DIGIT);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_GRAPH:\n\t\t\t\t    EMIT(NFA_CLASS_GRAPH);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_LOWER:\n\t\t\t\t    wants_nfa = TRUE;\n\t\t\t\t    EMIT(NFA_CLASS_LOWER);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_PRINT:\n\t\t\t\t    EMIT(NFA_CLASS_PRINT);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_PUNCT:\n\t\t\t\t    EMIT(NFA_CLASS_PUNCT);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_SPACE:\n\t\t\t\t    EMIT(NFA_CLASS_SPACE);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_UPPER:\n\t\t\t\t    wants_nfa = TRUE;\n\t\t\t\t    EMIT(NFA_CLASS_UPPER);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_XDIGIT:\n\t\t\t\t    EMIT(NFA_CLASS_XDIGIT);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_TAB:\n\t\t\t\t    EMIT(NFA_CLASS_TAB);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_RETURN:\n\t\t\t\t    EMIT(NFA_CLASS_RETURN);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_BACKSPACE:\n\t\t\t\t    EMIT(NFA_CLASS_BACKSPACE);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_ESCAPE:\n\t\t\t\t    EMIT(NFA_CLASS_ESCAPE);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_IDENT:\n\t\t\t\t    EMIT(NFA_CLASS_IDENT);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_KEYWORD:\n\t\t\t\t    EMIT(NFA_CLASS_KEYWORD);\n\t\t\t\t    break;\n\t\t\t\tcase CLASS_FNAME:\n\t\t\t\t    EMIT(NFA_CLASS_FNAME);\n\t\t\t\t    break;\n\t\t\t    }\n\t\t\t    EMIT(NFA_CONCAT);\n\t\t\t    continue;\n\t\t\t}\n\t\t\t\/\/ Try equivalence class [=a=] and the like\n\t\t\tif (equiclass != 0)\n\t\t\t{\n\t\t\t    result = nfa_emit_equi_class(equiclass);\n\t\t\t    if (result == FAIL)\n\t\t\t    {\n\t\t\t\t\/\/ should never happen\n\t\t\t\tEMSG_RET_FAIL(_(\"E868: Error building NFA with equivalence class!\"));\n\t\t\t    }\n\t\t\t    continue;\n\t\t\t}\n\t\t\t\/\/ Try collating class like [. .]\n\t\t\tif (collclass != 0)\n\t\t\t{\n\t\t\t    startc = collclass;\t \/\/ allow [.a.]-x as a range\n\t\t\t    \/\/ Will emit the proper atom at the end of the\n\t\t\t    \/\/ while loop.\n\t\t\t}\n\t\t    }\n\t\t    \/\/ Try a range like 'a-x' or '\\t-z'. Also allows '-' as a\n\t\t    \/\/ start character.\n\t\t    if (*regparse == '-' && oldstartc != -1)\n\t\t    {\n\t\t\temit_range = TRUE;\n\t\t\tstartc = oldstartc;\n\t\t\tMB_PTR_ADV(regparse);\n\t\t\tcontinue;\t    \/\/ reading the end of the range\n\t\t    }\n\n\t\t    \/\/ Now handle simple and escaped characters.\n\t\t    \/\/ Only \"\\]\", \"\\^\", \"\\]\" and \"\\\\\" are special in Vi.  Vim\n\t\t    \/\/ accepts \"\\t\", \"\\e\", etc., but only when the 'l' flag in\n\t\t    \/\/ 'cpoptions' is not included.\n\t\t    \/\/ Posix doesn't recognize backslash at all.\n\t\t    if (*regparse == '\\\\'\n\t\t\t    && !reg_cpo_bsl\n\t\t\t    && regparse + 1 <= endp\n\t\t\t    && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL\n\t\t\t\t|| (!reg_cpo_lit\n\t\t\t\t    && vim_strchr(REGEXP_ABBR, regparse[1])\n\t\t\t\t\t\t\t\t      != NULL)\n\t\t\t    )\n\t\t\t)\n\t\t    {\n\t\t\tMB_PTR_ADV(regparse);\n\n\t\t\tif (*regparse == 'n')\n\t\t\t    startc = (reg_string || emit_range\n\t\t\t\t\t|| regparse[1] == '-') ? NL : NFA_NEWL;\n\t\t\telse if (*regparse == 'd'\n\t\t\t\t    || *regparse == 'o'\n\t\t\t\t    || *regparse == 'x'\n\t\t\t\t    || *regparse == 'u'\n\t\t\t\t    || *regparse == 'U'\n\t\t\t\t)\n\t\t\t    {\n\t\t\t\t\/\/ TODO(RE) This needs more testing\n\t\t\t\tstartc = coll_get_char();\n\t\t\t\tgot_coll_char = TRUE;\n\t\t\t\tMB_PTR_BACK(old_regparse, regparse);\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\t\/\/ \\r,\\t,\\e,\\b\n\t\t\t\tstartc = backslash_trans(*regparse);\n\t\t\t    }\n\t\t    }\n\n\t\t    \/\/ Normal printable char\n\t\t    if (startc == -1)\n\t\t\tstartc = PTR2CHAR(regparse);\n\n\t\t    \/\/ Previous char was '-', so this char is end of range.\n\t\t    if (emit_range)\n\t\t    {\n\t\t\tint\tendc = startc;\n\n\t\t\tstartc = oldstartc;\n\t\t\tif (startc > endc)\n\t\t\t    EMSG_RET_FAIL(_(e_reverse_range));\n\n\t\t\tif (endc > startc + 2)\n\t\t\t{\n\t\t\t    \/\/ Emit a range instead of the sequence of\n\t\t\t    \/\/ individual characters.\n\t\t\t    if (startc == 0)\n\t\t\t\t\/\/ \\x00 is translated to \\x0a, start at \\x01.\n\t\t\t\tEMIT(1);\n\t\t\t    else\n\t\t\t\t--post_ptr; \/\/ remove NFA_CONCAT\n\t\t\t    EMIT(endc);\n\t\t\t    EMIT(NFA_RANGE);\n\t\t\t    EMIT(NFA_CONCAT);\n\t\t\t}\n\t\t\telse if (has_mbyte && ((*mb_char2len)(startc) > 1\n\t\t\t\t    || (*mb_char2len)(endc) > 1))\n\t\t\t{\n\t\t\t    \/\/ Emit the characters in the range.\n\t\t\t    \/\/ \"startc\" was already emitted, so skip it.\n\t\t\t    \/\/\n\t\t\t    for (c = startc + 1; c <= endc; c++)\n\t\t\t    {\n\t\t\t\tEMIT(c);\n\t\t\t\tEMIT(NFA_CONCAT);\n\t\t\t    }\n\t\t\t}\n\t\t\telse\n\t\t\t{\n#ifdef EBCDIC\n\t\t\t    int alpha_only = FALSE;\n\n\t\t\t    \/\/ for alphabetical range skip the gaps\n\t\t\t    \/\/ 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'.\n\t\t\t    if (isalpha(startc) && isalpha(endc))\n\t\t\t\talpha_only = TRUE;\n#endif\n\t\t\t    \/\/ Emit the range. \"startc\" was already emitted, so\n\t\t\t    \/\/ skip it.\n\t\t\t    for (c = startc + 1; c <= endc; c++)\n#ifdef EBCDIC\n\t\t\t\tif (!alpha_only || isalpha(startc))\n#endif\n\t\t\t\t{\n\t\t\t\t    EMIT(c);\n\t\t\t\t    EMIT(NFA_CONCAT);\n\t\t\t\t}\n\t\t\t}\n\t\t\temit_range = FALSE;\n\t\t\tstartc = -1;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ This char (startc) is not part of a range. Just\n\t\t\t\/\/ emit it.\n\t\t\t\/\/ Normally, simply emit startc. But if we get char\n\t\t\t\/\/ code=0 from a collating char, then replace it with\n\t\t\t\/\/ 0x0a.\n\t\t\t\/\/ This is needed to completely mimic the behaviour of\n\t\t\t\/\/ the backtracking engine.\n\t\t\tif (startc == NFA_NEWL)\n\t\t\t{\n\t\t\t    \/\/ Line break can't be matched as part of the\n\t\t\t    \/\/ collection, add an OR below. But not for negated\n\t\t\t    \/\/ range.\n\t\t\t    if (!negated)\n\t\t\t\textra = NFA_ADD_NL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    if (got_coll_char == TRUE && startc == 0)\n\t\t\t\tEMIT(0x0a);\n\t\t\t    else\n\t\t\t\tEMIT(startc);\n\t\t\t    EMIT(NFA_CONCAT);\n\t\t\t}\n\t\t    }\n\n\t\t    MB_PTR_ADV(regparse);\n\t\t} \/\/ while (p < endp)\n\n\t\tMB_PTR_BACK(old_regparse, regparse);\n\t\tif (*regparse == '-')\t    \/\/ if last, '-' is just a char\n\t\t{\n\t\t    EMIT('-');\n\t\t    EMIT(NFA_CONCAT);\n\t\t}\n\n\t\t\/\/ skip the trailing ]\n\t\tregparse = endp;\n\t\tMB_PTR_ADV(regparse);\n\n\t\t\/\/ Mark end of the collection.\n\t\tif (negated == TRUE)\n\t\t    EMIT(NFA_END_NEG_COLL);\n\t\telse\n\t\t    EMIT(NFA_END_COLL);\n\n\t\t\/\/ \\_[] also matches \\n but it's not negated\n\t\tif (extra == NFA_ADD_NL)\n\t\t{\n\t\t    EMIT(reg_string ? NL : NFA_NEWL);\n\t\t    EMIT(NFA_OR);\n\t\t}\n\n\t\treturn OK;\n\t    } \/\/ if exists closing ]\n\n\t    if (reg_strict)\n\t\tEMSG_RET_FAIL(_(e_missingbracket));\n\t    \/\/ FALLTHROUGH\n\n\tdefault:\n\t    {\n\t\tint\tplen;\n\nnfa_do_multibyte:\n\t\t\/\/ plen is length of current char with composing chars\n\t\tif (enc_utf8 && ((*mb_char2len)(c)\n\t\t\t    != (plen = utfc_ptr2len(old_regparse))\n\t\t\t\t\t\t       || utf_iscomposing(c)))\n\t\t{\n\t\t    int i = 0;\n\n\t\t    \/\/ A base character plus composing characters, or just one\n\t\t    \/\/ or more composing characters.\n\t\t    \/\/ This requires creating a separate atom as if enclosing\n\t\t    \/\/ the characters in (), where NFA_COMPOSING is the ( and\n\t\t    \/\/ NFA_END_COMPOSING is the ). Note that right now we are\n\t\t    \/\/ building the postfix form, not the NFA itself;\n\t\t    \/\/ a composing char could be: a, b, c, NFA_COMPOSING\n\t\t    \/\/ where 'b' and 'c' are chars with codes > 256.\n\t\t    for (;;)\n\t\t    {\n\t\t\tEMIT(c);\n\t\t\tif (i > 0)\n\t\t\t    EMIT(NFA_CONCAT);\n\t\t\tif ((i += utf_char2len(c)) >= plen)\n\t\t\t    break;\n\t\t\tc = utf_ptr2char(old_regparse + i);\n\t\t    }\n\t\t    EMIT(NFA_COMPOSING);\n\t\t    regparse = old_regparse + plen;\n\t\t}\n\t\telse\n\t\t{\n\t\t    c = no_Magic(c);\n\t\t    EMIT(c);\n\t\t}\n\t\treturn OK;\n\t    }\n    }\n\n    return OK;\n}","target":0,"code_token_length":5647,"total_token_length":5883,"max_tokens_setting":6144}
+{"idx":474047,"func":"fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)\n{\n  int r, num;\n  OnigCodePoint c;\n  OnigEncoding enc = env->enc;\n  const OnigSyntaxType* syn = env->syntax;\n  UChar* prev;\n  UChar* p = *src;\n  PFETCH_READY;\n\n start:\n  if (PEND) {\n    tok->type = TK_EOT;\n    return tok->type;\n  }\n\n  tok->type  = TK_STRING;\n  tok->base  = 0;\n  tok->backp = p;\n\n  PFETCH(c);\n  if (IS_MC_ESC_CODE(c, syn)) {\n    if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;\n\n    tok->backp = p;\n    PFETCH(c);\n\n    tok->u.c = c;\n    tok->escaped = 1;\n    switch (c) {\n    case '*':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF)) break;\n      tok->type = TK_OP_REPEAT;\n      tok->u.repeat.lower = 0;\n      tok->u.repeat.upper = REPEAT_INFINITE;\n      goto greedy_check;\n      break;\n\n    case '+':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_PLUS_ONE_INF)) break;\n      tok->type = TK_OP_REPEAT;\n      tok->u.repeat.lower = 1;\n      tok->u.repeat.upper = REPEAT_INFINITE;\n      goto greedy_check;\n      break;\n\n    case '?':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_QMARK_ZERO_ONE)) break;\n      tok->type = TK_OP_REPEAT;\n      tok->u.repeat.lower = 0;\n      tok->u.repeat.upper = 1;\n    greedy_check:\n      if (!PEND && PPEEK_IS('?') &&\n\t  IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_NON_GREEDY)) {\n\tPFETCH(c);\n\ttok->u.repeat.greedy     = 0;\n\ttok->u.repeat.possessive = 0;\n      }\n      else {\n      possessive_check:\n\tif (!PEND && PPEEK_IS('+') &&\n\t    ((IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT) &&\n\t      tok->type != TK_INTERVAL)  ||\n\t     (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL) &&\n\t      tok->type == TK_INTERVAL))) {\n\t  PFETCH(c);\n\t  tok->u.repeat.greedy     = 1;\n\t  tok->u.repeat.possessive = 1;\n\t}\n\telse {\n\t  tok->u.repeat.greedy     = 1;\n\t  tok->u.repeat.possessive = 0;\n\t}\n      }\n      break;\n\n    case '{':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_BRACE_INTERVAL)) break;\n      r = fetch_range_quantifier(&p, end, tok, env);\n      if (r < 0) return r;  \/* error *\/\n      if (r == 0) goto greedy_check;\n      else if (r == 2) { \/* {n} *\/\n\tif (IS_SYNTAX_BV(syn, ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY))\n\t  goto possessive_check;\n\n\tgoto greedy_check;\n      }\n      \/* r == 1 : normal char *\/\n      break;\n\n    case '|':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_VBAR_ALT)) break;\n      tok->type = TK_ALT;\n      break;\n\n    case '(':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LPAREN_SUBEXP)) break;\n      tok->type = TK_SUBEXP_OPEN;\n      break;\n\n    case ')':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LPAREN_SUBEXP)) break;\n      tok->type = TK_SUBEXP_CLOSE;\n      break;\n\n    case 'w':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_W;\n      tok->u.prop.not   = 0;\n      break;\n\n    case 'W':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_W;\n      tok->u.prop.not   = 1;\n      break;\n\n    case 'b':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.anchor = ANCHOR_WORD_BOUND;\n      break;\n\n    case 'B':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.anchor = ANCHOR_NOT_WORD_BOUND;\n      break;\n\n#ifdef USE_WORD_BEGIN_END\n    case '<':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.anchor = ANCHOR_WORD_BEGIN;\n      break;\n\n    case '>':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.anchor = ANCHOR_WORD_END;\n      break;\n#endif\n\n    case 's':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_S;\n      tok->u.prop.not   = 0;\n      break;\n\n    case 'S':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_S;\n      tok->u.prop.not   = 1;\n      break;\n\n    case 'd':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_D;\n      tok->u.prop.not   = 0;\n      break;\n\n    case 'D':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_D;\n      tok->u.prop.not   = 1;\n      break;\n\n    case 'h':\n      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;\n      tok->u.prop.not   = 0;\n      break;\n\n    case 'H':\n      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;\n      tok->type = TK_CHAR_TYPE;\n      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;\n      tok->u.prop.not   = 1;\n      break;\n\n    case 'A':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;\n    begin_buf:\n      tok->type = TK_ANCHOR;\n      tok->u.subtype = ANCHOR_BEGIN_BUF;\n      break;\n\n    case 'Z':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.subtype = ANCHOR_SEMI_END_BUF;\n      break;\n\n    case 'z':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;\n    end_buf:\n      tok->type = TK_ANCHOR;\n      tok->u.subtype = ANCHOR_END_BUF;\n      break;\n\n    case 'G':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.subtype = ANCHOR_BEGIN_POSITION;\n      break;\n\n    case '`':\n      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR)) break;\n      goto begin_buf;\n      break;\n\n    case '\\'':\n      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR)) break;\n      goto end_buf;\n      break;\n\n    case 'x':\n      if (PEND) break;\n\n      prev = p;\n      if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) {\n\tPINC;\n\tnum = scan_unsigned_hexadecimal_number(&p, end, 8, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;\n\tif (!PEND) {\n          if (ONIGENC_IS_CODE_XDIGIT(enc, PPEEK))\n            return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;\n        }\n\n\tif ((p > prev + enclen(enc, prev, end)) && !PEND && PPEEK_IS('}')) {\n\t  PINC;\n\t  tok->type   = TK_CODE_POINT;\n\t  tok->u.code = (OnigCodePoint )num;\n\t}\n\telse {\n\t  \/* can't read nothing or invalid format *\/\n\t  p = prev;\n\t}\n      }\n      else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) {\n\tnum = scan_unsigned_hexadecimal_number(&p, end, 2, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_NUMBER;\n\tif (p == prev) {  \/* can't read nothing. *\/\n\t  num = 0; \/* but, it's not error *\/\n\t}\n\ttok->type = TK_RAW_BYTE;\n\ttok->base = 16;\n\ttok->u.c  = num;\n      }\n      break;\n\n    case 'u':\n      if (PEND) break;\n\n      prev = p;\n      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) {\n\tnum = scan_unsigned_hexadecimal_number(&p, end, 4, enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_NUMBER;\n\tif (p == prev) {  \/* can't read nothing. *\/\n\t  num = 0; \/* but, it's not error *\/\n\t}\n\ttok->type   = TK_CODE_POINT;\n\ttok->base   = 16;\n\ttok->u.code = (OnigCodePoint )num;\n      }\n      break;\n\n    case '1': case '2': case '3': case '4':\n    case '5': case '6': case '7': case '8': case '9':\n      PUNFETCH;\n      prev = p;\n      num = onig_scan_unsigned_number(&p, end, enc);\n      if (num < 0 || num > ONIG_MAX_BACKREF_NUM) {\n        goto skip_backref;\n      }\n\n      if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&\n\t  (num <= env->num_mem || num <= 9)) { \/* This spec. from GNU regex *\/\n\tif (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {\n\t  if (num > env->num_mem || IS_NULL(SCANENV_MEM_NODES(env)[num]))\n\t    return ONIGERR_INVALID_BACKREF;\n\t}\n\n\ttok->type = TK_BACKREF;\n\ttok->u.backref.num     = 1;\n\ttok->u.backref.ref1    = num;\n\ttok->u.backref.by_name = 0;\n#ifdef USE_BACKREF_WITH_LEVEL\n\ttok->u.backref.exist_level = 0;\n#endif\n\tbreak;\n      }\n\n    skip_backref:\n      if (c == '8' || c == '9') {\n\t\/* normal char *\/\n\tp = prev; PINC;\n\tbreak;\n      }\n\n      p = prev;\n      \/* fall through *\/\n    case '0':\n      if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {\n\tprev = p;\n\tnum = scan_unsigned_octal_number(&p, end, (c == '0' ? 2:3), enc);\n\tif (num < 0) return ONIGERR_TOO_BIG_NUMBER;\n\tif (p == prev) {  \/* can't read nothing. *\/\n\t  num = 0; \/* but, it's not error *\/\n\t}\n\ttok->type = TK_RAW_BYTE;\n\ttok->base = 8;\n\ttok->u.c  = num;\n      }\n      else if (c != '0') {\n\tPINC;\n      }\n      break;\n\n#ifdef USE_NAMED_GROUP\n    case 'k':\n      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_K_NAMED_BACKREF)) {\n\tPFETCH(c);\n\tif (c == '<' || c == '\\'') {\n\t  UChar* name_end;\n\t  int* backs;\n\t  int back_num;\n\n\t  prev = p;\n\n#ifdef USE_BACKREF_WITH_LEVEL\n\t  name_end = NULL_UCHARP; \/* no need. escape gcc warning. *\/\n\t  r = fetch_name_with_level((OnigCodePoint )c, &p, end, &name_end,\n\t\t\t\t    env, &back_num, &tok->u.backref.level);\n\t  if (r == 1) tok->u.backref.exist_level = 1;\n\t  else        tok->u.backref.exist_level = 0;\n#else\n\t  r = fetch_name(&p, end, &name_end, env, &back_num, 1);\n#endif\n\t  if (r < 0) return r;\n\n\t  if (back_num != 0) {\n\t    if (back_num < 0) {\n\t      back_num = BACKREF_REL_TO_ABS(back_num, env);\n\t      if (back_num <= 0)\n\t\treturn ONIGERR_INVALID_BACKREF;\n\t    }\n\n\t    if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {\n\t      if (back_num > env->num_mem ||\n\t\t  IS_NULL(SCANENV_MEM_NODES(env)[back_num]))\n\t\treturn ONIGERR_INVALID_BACKREF;\n\t    }\n\t    tok->type = TK_BACKREF;\n\t    tok->u.backref.by_name = 0;\n\t    tok->u.backref.num  = 1;\n\t    tok->u.backref.ref1 = back_num;\n\t  }\n\t  else {\n\t    num = onig_name_to_group_numbers(env->reg, prev, name_end, &backs);\n\t    if (num <= 0) {\n\t      onig_scan_env_set_error_string(env,\n\t\t\t     ONIGERR_UNDEFINED_NAME_REFERENCE, prev, name_end);\n\t      return ONIGERR_UNDEFINED_NAME_REFERENCE;\n\t    }\n\t    if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {\n\t      int i;\n\t      for (i = 0; i < num; i++) {\n\t\tif (backs[i] > env->num_mem ||\n\t\t    IS_NULL(SCANENV_MEM_NODES(env)[backs[i]]))\n\t\t  return ONIGERR_INVALID_BACKREF;\n\t      }\n\t    }\n\n\t    tok->type = TK_BACKREF;\n\t    tok->u.backref.by_name = 1;\n\t    if (num == 1) {\n\t      tok->u.backref.num  = 1;\n\t      tok->u.backref.ref1 = backs[0];\n\t    }\n\t    else {\n\t      tok->u.backref.num  = num;\n\t      tok->u.backref.refs = backs;\n\t    }\n\t  }\n\t}\n\telse {\n\t    PUNFETCH;\n\t    onig_syntax_warn(env, \"invalid back reference\");\n\t}\n      }\n      break;\n#endif\n\n#ifdef USE_SUBEXP_CALL\n    case 'g':\n      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_G_SUBEXP_CALL)) {\n\tPFETCH(c);\n\tif (c == '<' || c == '\\'') {\n\t  int gnum;\n\t  UChar* name_end;\n\n\t  prev = p;\n\t  r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &gnum, 1);\n\t  if (r < 0) return r;\n\n\t  tok->type = TK_CALL;\n\t  tok->u.call.name     = prev;\n\t  tok->u.call.name_end = name_end;\n\t  tok->u.call.gnum     = gnum;\n\t}\n\telse {\n\t    onig_syntax_warn(env, \"invalid subexp call\");\n\t    PUNFETCH;\n\t}\n      }\n      break;\n#endif\n\n    case 'Q':\n      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE)) {\n\ttok->type = TK_QUOTE_OPEN;\n      }\n      break;\n\n    case 'p':\n    case 'P':\n      if (PPEEK_IS('{') &&\n\t  IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {\n\tPINC;\n\ttok->type = TK_CHAR_PROPERTY;\n\ttok->u.prop.not = (c == 'P' ? 1 : 0);\n\n\tif (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {\n\t  PFETCH(c);\n\t  if (c == '^') {\n\t    tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);\n\t  }\n\t  else\n\t    PUNFETCH;\n\t}\n      }\n      else {\n\t  onig_syntax_warn(env, \"invalid Unicode Property \\\\%c\", c);\n      }\n      break;\n\n    default:\n      PUNFETCH;\n      num = fetch_escaped_value(&p, end, env);\n      if (num < 0) return num;\n      \/* set_raw: *\/\n      if (tok->u.c != num) {\n\ttok->type = TK_CODE_POINT;\n\ttok->u.code = (OnigCodePoint )num;\n      }\n      else { \/* string *\/\n\tp = tok->backp + enclen(enc, tok->backp, end);\n      }\n      break;\n    }\n  }\n  else {\n    tok->u.c = c;\n    tok->escaped = 0;\n\n#ifdef USE_VARIABLE_META_CHARS\n    if ((c != ONIG_INEFFECTIVE_META_CHAR) &&\n\tIS_SYNTAX_OP(syn, ONIG_SYN_OP_VARIABLE_META_CHARACTERS)) {\n      if (c == MC_ANYCHAR(syn))\n\tgoto any_char;\n      else if (c == MC_ANYTIME(syn))\n\tgoto anytime;\n      else if (c == MC_ZERO_OR_ONE_TIME(syn))\n\tgoto zero_or_one_time;\n      else if (c == MC_ONE_OR_MORE_TIME(syn))\n\tgoto one_or_more_time;\n      else if (c == MC_ANYCHAR_ANYTIME(syn)) {\n\ttok->type = TK_ANYCHAR_ANYTIME;\n\tgoto out;\n      }\n    }\n#endif\n\n    switch (c) {\n    case '.':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_DOT_ANYCHAR)) break;\n#ifdef USE_VARIABLE_META_CHARS\n    any_char:\n#endif\n      tok->type = TK_ANYCHAR;\n      break;\n\n    case '*':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ASTERISK_ZERO_INF)) break;\n#ifdef USE_VARIABLE_META_CHARS\n    anytime:\n#endif\n      tok->type = TK_OP_REPEAT;\n      tok->u.repeat.lower = 0;\n      tok->u.repeat.upper = REPEAT_INFINITE;\n      goto greedy_check;\n      break;\n\n    case '+':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_PLUS_ONE_INF)) break;\n#ifdef USE_VARIABLE_META_CHARS\n    one_or_more_time:\n#endif\n      tok->type = TK_OP_REPEAT;\n      tok->u.repeat.lower = 1;\n      tok->u.repeat.upper = REPEAT_INFINITE;\n      goto greedy_check;\n      break;\n\n    case '?':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_ZERO_ONE)) break;\n#ifdef USE_VARIABLE_META_CHARS\n    zero_or_one_time:\n#endif\n      tok->type = TK_OP_REPEAT;\n      tok->u.repeat.lower = 0;\n      tok->u.repeat.upper = 1;\n      goto greedy_check;\n      break;\n\n    case '{':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_BRACE_INTERVAL)) break;\n      r = fetch_range_quantifier(&p, end, tok, env);\n      if (r < 0) return r;  \/* error *\/\n      if (r == 0) goto greedy_check;\n      else if (r == 2) { \/* {n} *\/\n\tif (IS_SYNTAX_BV(syn, ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY))\n\t  goto possessive_check;\n\n\tgoto greedy_check;\n      }\n      \/* r == 1 : normal char *\/\n      break;\n\n    case '|':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_VBAR_ALT)) break;\n      tok->type = TK_ALT;\n      break;\n\n    case '(':\n      if (PPEEK_IS('?') &&\n          IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {\n        PINC;\n        if (PPEEK_IS('#')) {\n          PFETCH(c);\n          while (1) {\n            if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;\n            PFETCH(c);\n            if (c == MC_ESC(syn)) {\n              if (!PEND) PFETCH(c);\n            }\n            else {\n              if (c == ')') break;\n            }\n          }\n          goto start;\n        }\n        PUNFETCH;\n      }\n\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LPAREN_SUBEXP)) break;\n      tok->type = TK_SUBEXP_OPEN;\n      break;\n\n    case ')':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LPAREN_SUBEXP)) break;\n      tok->type = TK_SUBEXP_CLOSE;\n      break;\n\n    case '^':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LINE_ANCHOR)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.subtype = (IS_SINGLELINE(env->option)\n\t\t\t? ANCHOR_BEGIN_BUF : ANCHOR_BEGIN_LINE);\n      break;\n\n    case '$':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LINE_ANCHOR)) break;\n      tok->type = TK_ANCHOR;\n      tok->u.subtype = (IS_SINGLELINE(env->option)\n\t\t\t? ANCHOR_SEMI_END_BUF : ANCHOR_END_LINE);\n      break;\n\n    case '[':\n      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_BRACKET_CC)) break;\n      tok->type = TK_CC_OPEN;\n      break;\n\n    case ']':\n      if (*src > env->pattern)   \/* \/]...\/ is allowed. *\/\n\tCLOSE_BRACKET_WITHOUT_ESC_WARN(env, (UChar* )\"]\");\n      break;\n\n    case '#':\n      if (IS_EXTEND(env->option)) {\n\twhile (!PEND) {\n\t  PFETCH(c);\n\t  if (ONIGENC_IS_CODE_NEWLINE(enc, c))\n\t    break;\n\t}\n\tgoto start;\n\tbreak;\n      }\n      break;\n\n    case ' ': case '\\t': case '\\n': case '\\r': case '\\f':\n      if (IS_EXTEND(env->option))\n\tgoto start;\n      break;\n\n    default:\n      \/* string *\/\n      break;\n    }\n  }\n\n#ifdef USE_VARIABLE_META_CHARS\n out:\n#endif\n  *src = p;\n  return tok->type;\n}","target":0,"code_token_length":5115,"total_token_length":5351,"max_tokens_setting":6144}
+{"idx":204751,"func":"do_tag(\n    char_u\t*tag,\t\t\/\/ tag (pattern) to jump to\n    int\t\ttype,\n    int\t\tcount,\n    int\t\tforceit,\t\/\/ :ta with !\n    int\t\tverbose)\t\/\/ print \"tag not found\" message\n{\n    taggy_T\t*tagstack = curwin->w_tagstack;\n    int\t\ttagstackidx = curwin->w_tagstackidx;\n    int\t\ttagstacklen = curwin->w_tagstacklen;\n    int\t\tcur_match = 0;\n    int\t\tcur_fnum = curbuf->b_fnum;\n    int\t\toldtagstackidx = tagstackidx;\n    int\t\tprevtagstackidx = tagstackidx;\n    int\t\tprev_num_matches;\n    int\t\tnew_tag = FALSE;\n    int\t\ti;\n    int\t\tic;\n    int\t\tno_regexp = FALSE;\n    int\t\terror_cur_match = 0;\n    int\t\tsave_pos = FALSE;\n    fmark_T\tsaved_fmark;\n#ifdef FEAT_CSCOPE\n    int\t\tjumped_to_tag = FALSE;\n#endif\n    int\t\tnew_num_matches;\n    char_u\t**new_matches;\n    int\t\tuse_tagstack;\n    int\t\tskip_msg = FALSE;\n    char_u\t*buf_ffname = curbuf->b_ffname;\t    \/\/ name to use for\n\t\t\t\t\t\t    \/\/ priority computation\n    int\t\tuse_tfu = 1;\n\n    \/\/ remember the matches for the last used tag\n    static int\t\tnum_matches = 0;\n    static int\t\tmax_num_matches = 0;  \/\/ limit used for match search\n    static char_u\t**matches = NULL;\n    static int\t\tflags;\n\n#ifdef FEAT_EVAL\n    if (tfu_in_use)\n    {\n\temsg(_(e_cannot_modify_tag_stack_within_tagfunc));\n\treturn FALSE;\n    }\n#endif\n\n#ifdef EXITFREE\n    if (type == DT_FREE)\n    {\n\t\/\/ remove the list of matches\n\tFreeWild(num_matches, matches);\n# ifdef FEAT_CSCOPE\n\tcs_free_tags();\n# endif\n\tnum_matches = 0;\n\treturn FALSE;\n    }\n#endif\n\n    if (type == DT_HELP)\n    {\n\ttype = DT_TAG;\n\tno_regexp = TRUE;\n\tuse_tfu = 0;\n    }\n\n    prev_num_matches = num_matches;\n    free_string_option(nofile_fname);\n    nofile_fname = NULL;\n\n    CLEAR_POS(&saved_fmark.mark);\t\/\/ shutup gcc 4.0\n    saved_fmark.fnum = 0;\n\n    \/*\n     * Don't add a tag to the tagstack if 'tagstack' has been reset.\n     *\/\n    if ((!p_tgst && *tag != NUL))\n    {\n\tuse_tagstack = FALSE;\n\tnew_tag = TRUE;\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t{\n\t    tagstack_clear_entry(&ptag_entry);\n\t    if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)\n\t\tgoto end_do_tag;\n\t}\n#endif\n    }\n    else\n    {\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t    use_tagstack = FALSE;\n\telse\n#endif\n\t    use_tagstack = TRUE;\n\n\t\/\/ new pattern, add to the tag stack\n\tif (*tag != NUL\n\t\t&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP\n#ifdef FEAT_QUICKFIX\n\t\t    || type == DT_LTAG\n#endif\n#ifdef FEAT_CSCOPE\n\t\t    || type == DT_CSCOPE\n#endif\n\t\t    ))\n\t{\n#if defined(FEAT_QUICKFIX)\n\t    if (g_do_tagpreview != 0)\n\t    {\n\t\tif (ptag_entry.tagname != NULL\n\t\t\t&& STRCMP(ptag_entry.tagname, tag) == 0)\n\t\t{\n\t\t    \/\/ Jumping to same tag: keep the current match, so that\n\t\t    \/\/ the CursorHold autocommand example works.\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    tagstack_clear_entry(&ptag_entry);\n\t\t    if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)\n\t\t\tgoto end_do_tag;\n\t\t}\n\t    }\n\t    else\n#endif\n\t    {\n\t\t\/*\n\t\t * If the last used entry is not at the top, delete all tag\n\t\t * stack entries above it.\n\t\t *\/\n\t\twhile (tagstackidx < tagstacklen)\n\t\t    tagstack_clear_entry(&tagstack[--tagstacklen]);\n\n\t\t\/\/ if the tagstack is full: remove oldest entry\n\t\tif (++tagstacklen > TAGSTACKSIZE)\n\t\t{\n\t\t    tagstacklen = TAGSTACKSIZE;\n\t\t    tagstack_clear_entry(&tagstack[0]);\n\t\t    for (i = 1; i < tagstacklen; ++i)\n\t\t\ttagstack[i - 1] = tagstack[i];\n\t\t    --tagstackidx;\n\t\t}\n\n\t\t\/*\n\t\t * put the tag name in the tag stack\n\t\t *\/\n\t\tif ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL)\n\t\t{\n\t\t    curwin->w_tagstacklen = tagstacklen - 1;\n\t\t    goto end_do_tag;\n\t\t}\n\t\tcurwin->w_tagstacklen = tagstacklen;\n\n\t\tsave_pos = TRUE;\t\/\/ save the cursor position below\n\t    }\n\n\t    new_tag = TRUE;\n\t}\n\telse\n\t{\n\t    if (\n#if defined(FEAT_QUICKFIX)\n\t\t    g_do_tagpreview != 0 ? ptag_entry.tagname == NULL :\n#endif\n\t\t    tagstacklen == 0)\n\t    {\n\t\t\/\/ empty stack\n\t\temsg(_(e_tag_stack_empty));\n\t\tgoto end_do_tag;\n\t    }\n\n\t    if (type == DT_POP)\t\t\/\/ go to older position\n\t    {\n#ifdef FEAT_FOLDING\n\t\tint\told_KeyTyped = KeyTyped;\n#endif\n\t\tif ((tagstackidx -= count) < 0)\n\t\t{\n\t\t    emsg(_(e_at_bottom_of_tag_stack));\n\t\t    if (tagstackidx + count == 0)\n\t\t    {\n\t\t\t\/\/ We did [num]^T from the bottom of the stack\n\t\t\ttagstackidx = 0;\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    \/\/ We weren't at the bottom of the stack, so jump all the\n\t\t    \/\/ way to the bottom now.\n\t\t    tagstackidx = 0;\n\t\t}\n\t\telse if (tagstackidx >= tagstacklen)    \/\/ count == 0?\n\t\t{\n\t\t    emsg(_(e_at_top_of_tag_stack));\n\t\t    goto end_do_tag;\n\t\t}\n\n\t\t\/\/ Make a copy of the fmark, autocommands may invalidate the\n\t\t\/\/ tagstack before it's used.\n\t\tsaved_fmark = tagstack[tagstackidx].fmark;\n\t\tif (saved_fmark.fnum != curbuf->b_fnum)\n\t\t{\n\t\t    \/*\n\t\t     * Jump to other file. If this fails (e.g. because the\n\t\t     * file was changed) keep original position in tag stack.\n\t\t     *\/\n\t\t    if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum,\n\t\t\t\t\t       GETF_SETMARK, forceit) == FAIL)\n\t\t    {\n\t\t\ttagstackidx = oldtagstackidx;  \/\/ back to old posn\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    \/\/ An BufReadPost autocommand may jump to the '\" mark, but\n\t\t    \/\/ we don't what that here.\n\t\t    curwin->w_cursor.lnum = saved_fmark.mark.lnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    setpcmark();\n\t\t    curwin->w_cursor.lnum = saved_fmark.mark.lnum;\n\t\t}\n\t\tcurwin->w_cursor.col = saved_fmark.mark.col;\n\t\tcurwin->w_set_curswant = TRUE;\n\t\tcheck_cursor();\n#ifdef FEAT_FOLDING\n\t\tif ((fdo_flags & FDO_TAG) && old_KeyTyped)\n\t\t    foldOpenCursor();\n#endif\n\n\t\t\/\/ remove the old list of matches\n\t\tFreeWild(num_matches, matches);\n#ifdef FEAT_CSCOPE\n\t\tcs_free_tags();\n#endif\n\t\tnum_matches = 0;\n\t\ttag_freematch();\n\t\tgoto end_do_tag;\n\t    }\n\n\t    if (type == DT_TAG\n#if defined(FEAT_QUICKFIX)\n\t\t    || type == DT_LTAG\n#endif\n\t       )\n\t    {\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0)\n\t\t{\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    \/\/ \":tag\" (no argument): go to newer pattern\n\t\t    save_pos = TRUE;\t\/\/ save the cursor position below\n\t\t    if ((tagstackidx += count - 1) >= tagstacklen)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Beyond the last one, just give an error message and\n\t\t\t * go to the last one.  Don't store the cursor\n\t\t\t * position.\n\t\t\t *\/\n\t\t\ttagstackidx = tagstacklen - 1;\n\t\t\temsg(_(e_at_top_of_tag_stack));\n\t\t\tsave_pos = FALSE;\n\t\t    }\n\t\t    else if (tagstackidx < 0)\t\/\/ must have been count == 0\n\t\t    {\n\t\t\temsg(_(e_at_bottom_of_tag_stack));\n\t\t\ttagstackidx = 0;\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    cur_match = tagstack[tagstackidx].cur_match;\n\t\t    cur_fnum = tagstack[tagstackidx].cur_fnum;\n\t\t}\n\t\tnew_tag = TRUE;\n\t    }\n\t    else\t\t\t\t\/\/ go to other matching tag\n\t    {\n\t\t\/\/ Save index for when selection is cancelled.\n\t\tprevtagstackidx = tagstackidx;\n\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0)\n\t\t{\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    if (--tagstackidx < 0)\n\t\t\ttagstackidx = 0;\n\t\t    cur_match = tagstack[tagstackidx].cur_match;\n\t\t    cur_fnum = tagstack[tagstackidx].cur_fnum;\n\t\t}\n\t\tswitch (type)\n\t\t{\n\t\t    case DT_FIRST: cur_match = count - 1; break;\n\t\t    case DT_SELECT:\n\t\t    case DT_JUMP:\n#ifdef FEAT_CSCOPE\n\t\t    case DT_CSCOPE:\n#endif\n\t\t    case DT_LAST:  cur_match = MAXCOL - 1; break;\n\t\t    case DT_NEXT:  cur_match += count; break;\n\t\t    case DT_PREV:  cur_match -= count; break;\n\t\t}\n\t\tif (cur_match >= MAXCOL)\n\t\t    cur_match = MAXCOL - 1;\n\t\telse if (cur_match < 0)\n\t\t{\n\t\t    emsg(_(e_cannot_go_before_first_matching_tag));\n\t\t    skip_msg = TRUE;\n\t\t    cur_match = 0;\n\t\t    cur_fnum = curbuf->b_fnum;\n\t\t}\n\t    }\n\t}\n\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t{\n\t    if (type != DT_SELECT && type != DT_JUMP)\n\t    {\n\t\tptag_entry.cur_match = cur_match;\n\t\tptag_entry.cur_fnum = cur_fnum;\n\t    }\n\t}\n\telse\n#endif\n\t{\n\t    \/*\n\t     * For \":tag [arg]\" or \":tselect\" remember position before the jump.\n\t     *\/\n\t    saved_fmark = tagstack[tagstackidx].fmark;\n\t    if (save_pos)\n\t    {\n\t\ttagstack[tagstackidx].fmark.mark = curwin->w_cursor;\n\t\ttagstack[tagstackidx].fmark.fnum = curbuf->b_fnum;\n\t    }\n\n\t    \/\/ Curwin will change in the call to jumpto_tag() if \":stag\" was\n\t    \/\/ used or an autocommand jumps to another window; store value of\n\t    \/\/ tagstackidx now.\n\t    curwin->w_tagstackidx = tagstackidx;\n\t    if (type != DT_SELECT && type != DT_JUMP)\n\t    {\n\t\tcurwin->w_tagstack[tagstackidx].cur_match = cur_match;\n\t\tcurwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum;\n\t    }\n\t}\n    }\n\n    \/\/ When not using the current buffer get the name of buffer \"cur_fnum\".\n    \/\/ Makes sure that the tag order doesn't change when using a remembered\n    \/\/ position for \"cur_match\".\n    if (cur_fnum != curbuf->b_fnum)\n    {\n\tbuf_T *buf = buflist_findnr(cur_fnum);\n\n\tif (buf != NULL)\n\t    buf_ffname = buf->b_ffname;\n    }\n\n    \/*\n     * Repeat searching for tags, when a file has not been found.\n     *\/\n    for (;;)\n    {\n\tint\tother_name;\n\tchar_u\t*name;\n\n\t\/*\n\t * When desired match not found yet, try to find it (and others).\n\t *\/\n\tif (use_tagstack)\n\t    name = tagstack[tagstackidx].tagname;\n#if defined(FEAT_QUICKFIX)\n\telse if (g_do_tagpreview != 0)\n\t    name = ptag_entry.tagname;\n#endif\n\telse\n\t    name = tag;\n\tother_name = (tagmatchname == NULL || STRCMP(tagmatchname, name) != 0);\n\tif (new_tag\n\t\t|| (cur_match >= num_matches && max_num_matches != MAXCOL)\n\t\t|| other_name)\n\t{\n\t    if (other_name)\n\t    {\n\t\tvim_free(tagmatchname);\n\t\ttagmatchname = vim_strsave(name);\n\t    }\n\n\t    if (type == DT_SELECT || type == DT_JUMP\n#if defined(FEAT_QUICKFIX)\n\t\t|| type == DT_LTAG\n#endif\n\t\t)\n\t\tcur_match = MAXCOL - 1;\n\t    if (type == DT_TAG)\n\t\tmax_num_matches = MAXCOL;\n\t    else\n\t\tmax_num_matches = cur_match + 1;\n\n\t    \/\/ when the argument starts with '\/', use it as a regexp\n\t    if (!no_regexp && *name == '\/')\n\t    {\n\t\tflags = TAG_REGEXP;\n\t\t++name;\n\t    }\n\t    else\n\t\tflags = TAG_NOIC;\n\n#ifdef FEAT_CSCOPE\n\t    if (type == DT_CSCOPE)\n\t\tflags = TAG_CSCOPE;\n#endif\n\t    if (verbose)\n\t\tflags |= TAG_VERBOSE;\n\n\t    if (!use_tfu)\n\t\tflags |= TAG_NO_TAGFUNC;\n\n\t    if (find_tags(name, &new_num_matches, &new_matches, flags,\n\t\t\t\t\t    max_num_matches, buf_ffname) == OK\n\t\t    && new_num_matches < max_num_matches)\n\t\tmax_num_matches = MAXCOL; \/\/ If less than max_num_matches\n\t\t\t\t\t  \/\/ found: all matches found.\n\n\t    \/\/ If there already were some matches for the same name, move them\n\t    \/\/ to the start.  Avoids that the order changes when using\n\t    \/\/ \":tnext\" and jumping to another file.\n\t    if (!new_tag && !other_name)\n\t    {\n\t\tint\t    j, k;\n\t\tint\t    idx = 0;\n\t\ttagptrs_T   tagp, tagp2;\n\n\t\t\/\/ Find the position of each old match in the new list.  Need\n\t\t\/\/ to use parse_match() to find the tag line.\n\t\tfor (j = 0; j < num_matches; ++j)\n\t\t{\n\t\t    parse_match(matches[j], &tagp);\n\t\t    for (i = idx; i < new_num_matches; ++i)\n\t\t    {\n\t\t\tparse_match(new_matches[i], &tagp2);\n\t\t\tif (STRCMP(tagp.tagname, tagp2.tagname) == 0)\n\t\t\t{\n\t\t\t    char_u *p = new_matches[i];\n\t\t\t    for (k = i; k > idx; --k)\n\t\t\t\tnew_matches[k] = new_matches[k - 1];\n\t\t\t    new_matches[idx++] = p;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    FreeWild(num_matches, matches);\n\t    num_matches = new_num_matches;\n\t    matches = new_matches;\n\t}\n\n\tif (num_matches <= 0)\n\t{\n\t    if (verbose)\n\t\tsemsg(_(e_tag_not_found_str), name);\n#if defined(FEAT_QUICKFIX)\n\t    g_do_tagpreview = 0;\n#endif\n\t}\n\telse\n\t{\n\t    int ask_for_selection = FALSE;\n\n#ifdef FEAT_CSCOPE\n\t    if (type == DT_CSCOPE && num_matches > 1)\n\t    {\n\t\tcs_print_tags();\n\t\task_for_selection = TRUE;\n\t    }\n\t    else\n#endif\n\t    if (type == DT_TAG && *tag != NUL)\n\t\t\/\/ If a count is supplied to the \":tag <name>\" command, then\n\t\t\/\/ jump to count'th matching tag.\n\t\tcur_match = count > 0 ? count - 1 : 0;\n\t    else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1))\n\t    {\n\t\tprint_tag_list(new_tag, use_tagstack, num_matches, matches);\n\t\task_for_selection = TRUE;\n\t    }\n#if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)\n\t    else if (type == DT_LTAG)\n\t    {\n\t\tif (add_llist_tags(tag, num_matches, matches) == FAIL)\n\t\t    goto end_do_tag;\n\t\tcur_match = 0;\t\t\/\/ Jump to the first tag\n\t    }\n#endif\n\n\t    if (ask_for_selection == TRUE)\n\t    {\n\t\t\/*\n\t\t * Ask to select a tag from the list.\n\t\t *\/\n\t\ti = prompt_for_number(NULL);\n\t\tif (i <= 0 || i > num_matches || got_int)\n\t\t{\n\t\t    \/\/ no valid choice: don't change anything\n\t\t    if (use_tagstack)\n\t\t    {\n\t\t\ttagstack[tagstackidx].fmark = saved_fmark;\n\t\t\ttagstackidx = prevtagstackidx;\n\t\t    }\n#ifdef FEAT_CSCOPE\n\t\t    cs_free_tags();\n\t\t    jumped_to_tag = TRUE;\n#endif\n\t\t    break;\n\t\t}\n\t\tcur_match = i - 1;\n\t    }\n\n\t    if (cur_match >= num_matches)\n\t    {\n\t\t\/\/ Avoid giving this error when a file wasn't found and we're\n\t\t\/\/ looking for a match in another file, which wasn't found.\n\t\t\/\/ There will be an emsg(\"file doesn't exist\") below then.\n\t\tif ((type == DT_NEXT || type == DT_FIRST)\n\t\t\t\t\t\t      && nofile_fname == NULL)\n\t\t{\n\t\t    if (num_matches == 1)\n\t\t\temsg(_(e_there_is_only_one_matching_tag));\n\t\t    else\n\t\t\temsg(_(e_cannot_go_beyond_last_matching_tag));\n\t\t    skip_msg = TRUE;\n\t\t}\n\t\tcur_match = num_matches - 1;\n\t    }\n\t    if (use_tagstack)\n\t    {\n\t\ttagptrs_T   tagp;\n\n\t\ttagstack[tagstackidx].cur_match = cur_match;\n\t\ttagstack[tagstackidx].cur_fnum = cur_fnum;\n\n\t\t\/\/ store user-provided data originating from tagfunc\n\t\tif (use_tfu && parse_match(matches[cur_match], &tagp) == OK\n\t\t\t&& tagp.user_data)\n\t\t{\n\t\t    VIM_CLEAR(tagstack[tagstackidx].user_data);\n\t\t    tagstack[tagstackidx].user_data = vim_strnsave(\n\t\t\t  tagp.user_data, tagp.user_data_end - tagp.user_data);\n\t\t}\n\n\t\t++tagstackidx;\n\t    }\n#if defined(FEAT_QUICKFIX)\n\t    else if (g_do_tagpreview != 0)\n\t    {\n\t\tptag_entry.cur_match = cur_match;\n\t\tptag_entry.cur_fnum = cur_fnum;\n\t    }\n#endif\n\n\t    \/*\n\t     * Only when going to try the next match, report that the previous\n\t     * file didn't exist.  Otherwise an emsg() is given below.\n\t     *\/\n\t    if (nofile_fname != NULL && error_cur_match != cur_match)\n\t\tsmsg(_(\"File \\\"%s\\\" does not exist\"), nofile_fname);\n\n\n\t    ic = (matches[cur_match][0] & MT_IC_OFF);\n\t    if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP\n#ifdef FEAT_CSCOPE\n\t\t&& type != DT_CSCOPE\n#endif\n\t\t&& (num_matches > 1 || ic)\n\t\t&& !skip_msg)\n\t    {\n\t\t\/\/ Give an indication of the number of matching tags\n\t\tsprintf((char *)IObuff, _(\"tag %d of %d%s\"),\n\t\t\t\tcur_match + 1,\n\t\t\t\tnum_matches,\n\t\t\t\tmax_num_matches != MAXCOL ? _(\" or more\") : \"\");\n\t\tif (ic)\n\t\t    STRCAT(IObuff, _(\"  Using tag with different case!\"));\n\t\tif ((num_matches > prev_num_matches || new_tag)\n\t\t\t\t\t\t\t   && num_matches > 1)\n\t\t{\n\t\t    if (ic)\n\t\t\tmsg_attr((char *)IObuff, HL_ATTR(HLF_W));\n\t\t    else\n\t\t\tmsg((char *)IObuff);\n\t\t    msg_scroll = TRUE;\t\/\/ don't overwrite this message\n\t\t}\n\t\telse\n\t\t    give_warning(IObuff, ic);\n\t\tif (ic && !msg_scrolled && msg_silent == 0)\n\t\t{\n\t\t    out_flush();\n\t\t    ui_delay(1007L, TRUE);\n\t\t}\n\t    }\n\n#if defined(FEAT_EVAL)\n\t    \/\/ Let the SwapExists event know what tag we are jumping to.\n\t    vim_snprintf((char *)IObuff, IOSIZE, \":ta %s\\r\", name);\n\t    set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);\n#endif\n\n\t    \/*\n\t     * Jump to the desired match.\n\t     *\/\n\t    i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE);\n\n#if defined(FEAT_EVAL)\n\t    set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);\n#endif\n\n\t    if (i == NOTAGFILE)\n\t    {\n\t\t\/\/ File not found: try again with another matching tag\n\t\tif ((type == DT_PREV && cur_match > 0)\n\t\t\t|| ((type == DT_TAG || type == DT_NEXT\n\t\t\t\t\t\t\t  || type == DT_FIRST)\n\t\t\t    && (max_num_matches != MAXCOL\n\t\t\t\t\t     || cur_match < num_matches - 1)))\n\t\t{\n\t\t    error_cur_match = cur_match;\n\t\t    if (use_tagstack)\n\t\t\t--tagstackidx;\n\t\t    if (type == DT_PREV)\n\t\t\t--cur_match;\n\t\t    else\n\t\t    {\n\t\t\ttype = DT_NEXT;\n\t\t\t++cur_match;\n\t\t    }\n\t\t    continue;\n\t\t}\n\t\tsemsg(_(e_file_str_does_not_exist), nofile_fname);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ We may have jumped to another window, check that\n\t\t\/\/ tagstackidx is still valid.\n\t\tif (use_tagstack && tagstackidx > curwin->w_tagstacklen)\n\t\t    tagstackidx = curwin->w_tagstackidx;\n#ifdef FEAT_CSCOPE\n\t\tjumped_to_tag = TRUE;\n#endif\n\t    }\n\t}\n\tbreak;\n    }\n\nend_do_tag:\n    \/\/ Only store the new index when using the tagstack and it's valid.\n    if (use_tagstack && tagstackidx <= curwin->w_tagstacklen)\n\tcurwin->w_tagstackidx = tagstackidx;\n    postponed_split = 0;\t\/\/ don't split next time\n# ifdef FEAT_QUICKFIX\n    g_do_tagpreview = 0;\t\/\/ don't do tag preview next time\n# endif\n\n#ifdef FEAT_CSCOPE\n    return jumped_to_tag;\n#else\n    return FALSE;\n#endif\n}","target":1,"code_token_length":5052,"total_token_length":5288,"max_tokens_setting":6144}
+{"idx":206670,"func":"negotiate_handshake_newstyle_options (void)\n{\n  GET_CONN;\n  struct nbd_new_option new_option;\n  size_t nr_options;\n  bool list_seen = false;\n  uint64_t version;\n  uint32_t option;\n  uint32_t optlen;\n  struct nbd_export_name_option_reply handshake_finish;\n  const char *optname;\n  uint64_t exportsize;\n  struct backend *b;\n\n  for (nr_options = MAX_NR_OPTIONS; nr_options > 0; --nr_options) {\n    CLEANUP_FREE char *data = NULL;\n\n    if (conn_recv_full (&new_option, sizeof new_option,\n                        \"reading option: conn->recv: %m\") == -1)\n      return -1;\n\n    version = be64toh (new_option.version);\n    if (version != NBD_NEW_VERSION) {\n      nbdkit_error (\"unknown option version %\" PRIx64\n                    \", expecting %\" PRIx64,\n                    version, NBD_NEW_VERSION);\n      return -1;\n    }\n\n    \/* There is a maximum option length we will accept, regardless\n     * of the option type.\n     *\/\n    optlen = be32toh (new_option.optlen);\n    if (optlen > MAX_REQUEST_SIZE) {\n      nbdkit_error (\"client option data too long (%\" PRIu32 \")\", optlen);\n      return -1;\n    }\n    data = malloc (optlen + 1); \/* Allowing a trailing NUL helps some uses *\/\n    if (data == NULL) {\n      nbdkit_error (\"malloc: %m\");\n      return -1;\n    }\n\n    option = be32toh (new_option.option);\n    optname = name_of_nbd_opt (option);\n\n    \/* If the client lacks fixed newstyle support, it should only send\n     * NBD_OPT_EXPORT_NAME.\n     *\/\n    if (!(conn->cflags & NBD_FLAG_FIXED_NEWSTYLE) &&\n        option != NBD_OPT_EXPORT_NAME) {\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID))\n        return -1;\n      continue;\n    }\n\n    \/* In --tls=require \/ FORCEDTLS mode the only options allowed\n     * before TLS negotiation are NBD_OPT_ABORT and NBD_OPT_STARTTLS.\n     *\/\n    if (tls == 2 && !conn->using_tls &&\n        !(option == NBD_OPT_ABORT || option == NBD_OPT_STARTTLS)) {\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_TLS_REQD))\n        return -1;\n      continue;\n    }\n\n    switch (option) {\n    case NBD_OPT_EXPORT_NAME:\n      if (conn_recv_full (data, optlen,\n                          \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n        return -1;\n      if (check_export_name (option, data, optlen, optlen) == -1)\n        return -1;\n\n      \/* We have to finish the handshake by sending handshake_finish.\n       * On failure, we have to disconnect.\n       *\/\n      if (finish_newstyle_options (&exportsize, data, optlen) == -1)\n        return -1;\n\n      memset (&handshake_finish, 0, sizeof handshake_finish);\n      handshake_finish.exportsize = htobe64 (exportsize);\n      handshake_finish.eflags = htobe16 (conn->eflags);\n\n      if (conn->send (&handshake_finish,\n                      (conn->cflags & NBD_FLAG_NO_ZEROES)\n                      ? offsetof (struct nbd_export_name_option_reply, zeroes)\n                      : sizeof handshake_finish, 0) == -1) {\n        nbdkit_error (\"write: %s: %m\", optname);\n        return -1;\n      }\n      break;\n\n    case NBD_OPT_ABORT:\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n      debug (\"client sent %s to abort the connection\",\n             name_of_nbd_opt (option));\n      return -1;\n\n    case NBD_OPT_LIST:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      if (list_seen) {\n        debug (\"newstyle negotiation: %s: export list already advertised\",\n               name_of_nbd_opt (option));\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)\n          return -1;\n        continue;\n      }\n      else {\n        \/* Send back the exportname list. *\/\n        debug (\"newstyle negotiation: %s: advertising exports\",\n               name_of_nbd_opt (option));\n        if (send_newstyle_option_reply_exportnames (option, &nr_options) == -1)\n          return -1;\n        list_seen = true;\n      }\n      break;\n\n    case NBD_OPT_STARTTLS:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      if (tls == 0) {           \/* --tls=off (NOTLS mode). *\/\n#ifdef HAVE_GNUTLS\n#define NO_TLS_REPLY NBD_REP_ERR_POLICY\n#else\n#define NO_TLS_REPLY NBD_REP_ERR_UNSUP\n#endif\n        if (send_newstyle_option_reply (option, NO_TLS_REPLY) == -1)\n          return -1;\n      }\n      else \/* --tls=on or --tls=require *\/ {\n        \/* We can't upgrade to TLS twice on the same connection. *\/\n        if (conn->using_tls) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)\n            return -1;\n          continue;\n        }\n\n        \/* We have to send the (unencrypted) reply before starting\n         * the handshake.\n         *\/\n        if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n          return -1;\n\n        \/* Upgrade the connection to TLS.  Also performs access control. *\/\n        if (crypto_negotiate_tls (conn->sockin, conn->sockout) == -1)\n          return -1;\n        conn->using_tls = true;\n        debug (\"using TLS on this connection\");\n        \/* Wipe out any cached state. *\/\n        conn->structured_replies = false;\n        for_each_backend (b) {\n          free (conn->default_exportname[b->i]);\n          conn->default_exportname[b->i] = NULL;\n        }\n      }\n      break;\n\n    case NBD_OPT_INFO:\n    case NBD_OPT_GO:\n      if (conn_recv_full (data, optlen, \"read: %s: %m\", optname) == -1)\n        return -1;\n\n      if (optlen < 6) { \/* 32 bit export length + 16 bit nr info *\/\n        debug (\"newstyle negotiation: %s option length < 6\", optname);\n\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        continue;\n      }\n\n      {\n        uint32_t exportnamelen;\n        uint16_t nrinfos;\n        uint16_t info;\n        size_t i;\n\n        \/* Validate the name length and number of INFO requests. *\/\n        memcpy (&exportnamelen, &data[0], 4);\n        exportnamelen = be32toh (exportnamelen);\n        if (exportnamelen > optlen-6 \/* NB optlen >= 6, see above *\/) {\n          debug (\"newstyle negotiation: %s: export name too long\", optname);\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n        memcpy (&nrinfos, &data[exportnamelen+4], 2);\n        nrinfos = be16toh (nrinfos);\n        if (optlen != 4 + exportnamelen + 2 + 2*nrinfos) {\n          debug (\"newstyle negotiation: %s: \"\n                 \"number of information requests incorrect\", optname);\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* As with NBD_OPT_EXPORT_NAME we print the export name and\n         * save it in the connection.  If an earlier\n         * NBD_OPT_SET_META_CONTEXT used an export name, it must match\n         * or else we drop the support for that context.\n         *\/\n        if (check_export_name (option, &data[4], exportnamelen,\n                               optlen - 6) == -1) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* The spec is confusing, but it is required that we send back\n         * NBD_INFO_EXPORT, even if the client did not request it!\n         * qemu client in particular does not request this, but will\n         * fail if we don't send it.  Note that if .open fails, but we\n         * succeed at .close, then we merely return an error to the\n         * client and let them try another NBD_OPT, rather than\n         * disconnecting.\n         *\/\n        if (finish_newstyle_options (&exportsize,\n                                     &data[4], exportnamelen) == -1) {\n          if (conn->top_context) {\n            if (backend_finalize (conn->top_context) == -1)\n              return -1;\n            backend_close (conn->top_context);\n            conn->top_context = NULL;\n          }\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_UNKNOWN) == -1)\n            return -1;\n          continue;\n        }\n\n        if (send_newstyle_option_reply_info_export (option,\n                                                    NBD_REP_INFO,\n                                                    NBD_INFO_EXPORT,\n                                                    exportsize) == -1)\n          return -1;\n\n        \/* For now we send NBD_INFO_NAME and NBD_INFO_DESCRIPTION if\n         * requested, and ignore all other info requests (including\n         * NBD_INFO_EXPORT if it was requested, because we replied\n         * already above).\n         *\/\n        for (i = 0; i < nrinfos; ++i) {\n          memcpy (&info, &data[4 + exportnamelen + 2 + i*2], 2);\n          info = be16toh (info);\n          switch (info) {\n          case NBD_INFO_EXPORT: \/* ignore - reply sent above *\/ break;\n          case NBD_INFO_NAME:\n            {\n              const char *name = &data[4];\n              size_t namelen = exportnamelen;\n\n              if (exportnamelen == 0) {\n                name = backend_default_export (top, read_only);\n                if (!name) {\n                  debug (\"newstyle negotiation: %s: \"\n                         \"NBD_INFO_NAME: no name to send\", optname);\n                  break;\n                }\n                namelen = -1;\n              }\n              if (send_newstyle_option_reply_info_str (option,\n                                                       NBD_REP_INFO,\n                                                       NBD_INFO_NAME,\n                                                       name, namelen) == -1)\n                return -1;\n            }\n            break;\n          case NBD_INFO_DESCRIPTION:\n            {\n              const char *desc = backend_export_description (conn->top_context);\n\n              if (!desc) {\n                debug (\"newstyle negotiation: %s: \"\n                       \"NBD_INFO_DESCRIPTION: no description to send\",\n                       optname);\n                break;\n              }\n              if (send_newstyle_option_reply_info_str (option,\n                                                       NBD_REP_INFO,\n                                                       NBD_INFO_DESCRIPTION,\n                                                       desc, -1) == -1)\n                return -1;\n            }\n            break;\n          default:\n            debug (\"newstyle negotiation: %s: \"\n                   \"ignoring NBD_INFO_* request %u (%s)\",\n                   optname, (unsigned) info, name_of_nbd_info (info));\n            break;\n          }\n        }\n      }\n\n      \/* Unlike NBD_OPT_EXPORT_NAME, NBD_OPT_GO sends back an ACK\n       * or ERROR packet.  If this was NBD_OPT_LIST, call .close.\n       *\/\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n\n      if (option == NBD_OPT_INFO) {\n        if (backend_finalize (conn->top_context) == -1)\n          return -1;\n        backend_close (conn->top_context);\n        conn->top_context = NULL;\n      }\n\n      break;\n\n    case NBD_OPT_STRUCTURED_REPLY:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      debug (\"newstyle negotiation: %s: client requested structured replies\",\n             name_of_nbd_opt (option));\n\n      if (no_sr) {\n        \/* Must fail with ERR_UNSUP for qemu 4.2 to remain happy;\n         * but failing with ERR_POLICY would have been nicer.\n         *\/\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_UNSUP) == -1)\n          return -1;\n        debug (\"newstyle negotiation: %s: structured replies are disabled\",\n               name_of_nbd_opt (option));\n        break;\n      }\n\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n\n      conn->structured_replies = true;\n      break;\n\n    case NBD_OPT_LIST_META_CONTEXT:\n    case NBD_OPT_SET_META_CONTEXT:\n      {\n        uint32_t opt_index;\n        uint32_t exportnamelen;\n        uint32_t nr_queries;\n        uint32_t querylen;\n        const char *what;\n\n        if (conn_recv_full (data, optlen, \"read: %s: %m\", optname) == -1)\n          return -1;\n\n        \/* Note that we support base:allocation whether or not the plugin\n         * supports can_extents.\n         *\/\n        if (!conn->structured_replies) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* Minimum length of the option payload is:\n         *   32 bit export name length followed by empty export name\n         * + 32 bit number of queries followed by no queries\n         * = 8 bytes.\n         *\/\n        what = \"optlen < 8\";\n        if (optlen < 8) {\n        opt_meta_invalid_option_len:\n          debug (\"newstyle negotiation: %s: invalid option length: %s\",\n                 optname, what);\n\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        memcpy (&exportnamelen, &data[0], 4);\n        exportnamelen = be32toh (exportnamelen);\n        what = \"validating export name\";\n        if (check_export_name (option, &data[4], exportnamelen,\n                               optlen - 8) == -1)\n          goto opt_meta_invalid_option_len;\n\n        \/* Remember the export name: the NBD spec says that if the client\n         * later uses NBD_OPT_GO on a different export, then the context\n         * returned here is not usable.\n         *\/\n        if (option == NBD_OPT_SET_META_CONTEXT) {\n          conn->exportname_from_set_meta_context =\n            strndup (&data[4], exportnamelen);\n          if (conn->exportname_from_set_meta_context == NULL) {\n            nbdkit_error (\"malloc: %m\");\n            return -1;\n          }\n        }\n\n        opt_index = 4 + exportnamelen;\n\n        \/* Read the number of queries. *\/\n        what = \"reading number of queries\";\n        if (opt_index+4 > optlen)\n          goto opt_meta_invalid_option_len;\n        memcpy (&nr_queries, &data[opt_index], 4);\n        nr_queries = be32toh (nr_queries);\n        opt_index += 4;\n\n        \/* for LIST: nr_queries == 0 means return all meta contexts\n         * for SET: nr_queries == 0 means reset all contexts\n         *\/\n        debug (\"newstyle negotiation: %s: %s count: %d\", optname,\n               option == NBD_OPT_LIST_META_CONTEXT ? \"query\" : \"set\",\n               nr_queries);\n        if (option == NBD_OPT_SET_META_CONTEXT)\n          conn->meta_context_base_allocation = false;\n        if (nr_queries == 0) {\n          if (option == NBD_OPT_LIST_META_CONTEXT) {\n            if (send_newstyle_option_reply_meta_context (option,\n                                                         NBD_REP_META_CONTEXT,\n                                                         0, \"base:allocation\")\n                == -1)\n              return -1;\n          }\n\n          if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n            return -1;\n        }\n        else {\n          \/* Read and answer each query. *\/\n          while (nr_queries > 0) {\n            what = \"reading query string length\";\n            if (opt_index+4 > optlen)\n              goto opt_meta_invalid_option_len;\n            memcpy (&querylen, &data[opt_index], 4);\n            querylen = be32toh (querylen);\n            opt_index += 4;\n            what = \"reading query string\";\n            if (check_string (option, &data[opt_index], querylen,\n                              optlen - opt_index, \"meta context query\") == -1)\n              goto opt_meta_invalid_option_len;\n\n            debug (\"newstyle negotiation: %s: %s %.*s\",\n                   optname,\n                   option == NBD_OPT_LIST_META_CONTEXT ? \"query\" : \"set\",\n                   (int) querylen, &data[opt_index]);\n\n            \/* For LIST, \"base:\" returns all supported contexts in the\n             * base namespace.  We only support \"base:allocation\".\n             *\/\n            if (option == NBD_OPT_LIST_META_CONTEXT &&\n                querylen == 5 &&\n                strncmp (&data[opt_index], \"base:\", 5) == 0) {\n              if (send_newstyle_option_reply_meta_context\n                  (option, NBD_REP_META_CONTEXT,\n                   0, \"base:allocation\") == -1)\n                return -1;\n            }\n            \/* \"base:allocation\" requested by name. *\/\n            else if (querylen == 15 &&\n                     strncmp (&data[opt_index], \"base:allocation\", 15) == 0) {\n              if (send_newstyle_option_reply_meta_context\n                  (option, NBD_REP_META_CONTEXT,\n                   option == NBD_OPT_SET_META_CONTEXT\n                   ? base_allocation_id : 0,\n                   \"base:allocation\") == -1)\n                return -1;\n              if (option == NBD_OPT_SET_META_CONTEXT)\n                conn->meta_context_base_allocation = true;\n            }\n            \/* Every other query must be ignored. *\/\n\n            opt_index += querylen;\n            nr_queries--;\n          }\n          if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n            return -1;\n        }\n        debug (\"newstyle negotiation: %s: reply complete\", optname);\n      }\n      break;\n\n    default:\n      \/* Unknown option. *\/\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_UNSUP) == -1)\n        return -1;\n      if (conn_recv_full (data, optlen,\n                          \"reading unknown option data: conn->recv: %m\") == -1)\n        return -1;\n    }\n\n    \/* Note, since it's not very clear from the protocol doc, that the\n     * client must send NBD_OPT_EXPORT_NAME or NBD_OPT_GO last, and\n     * that ends option negotiation.\n     *\/\n    if (option == NBD_OPT_EXPORT_NAME || option == NBD_OPT_GO)\n      break;\n  }\n\n  if (nr_options == 0) {\n    nbdkit_error (\"client spent too much time negotiating without selecting \"\n                  \"an export\");\n    return -1;\n  }\n\n  \/* In --tls=require \/ FORCEDTLS mode, we must have upgraded to TLS\n   * by the time we finish option negotiation.  If not, give up.\n   *\/\n  if (tls == 2 && !conn->using_tls) {\n    nbdkit_error (\"non-TLS client tried to connect in --tls=require mode\");\n    return -1;\n  }\n\n  return 0;\n}","target":1,"code_token_length":4551,"total_token_length":4787,"max_tokens_setting":6144}
+{"idx":428227,"func":"static CURLcode create_conn(struct SessionHandle *data,\n                            struct connectdata **in_connect,\n                            bool *async)\n{\n  CURLcode result = CURLE_OK;\n  struct connectdata *conn;\n  struct connectdata *conn_temp = NULL;\n  size_t urllen;\n  char *user = NULL;\n  char *passwd = NULL;\n  char *options = NULL;\n  bool reuse;\n  char *proxy = NULL;\n  bool prot_missing = FALSE;\n  bool no_connections_available = FALSE;\n  bool force_reuse = FALSE;\n  size_t max_host_connections = Curl_multi_max_host_connections(data->multi);\n  size_t max_total_connections = Curl_multi_max_total_connections(data->multi);\n\n  *async = FALSE;\n\n  \/*************************************************************\n   * Check input data\n   *************************************************************\/\n\n  if(!data->change.url) {\n    result = CURLE_URL_MALFORMAT;\n    goto out;\n  }\n\n  \/* First, split up the current URL in parts so that we can use the\n     parts for checking against the already present connections. In order\n     to not have to modify everything at once, we allocate a temporary\n     connection data struct and fill in for comparison purposes. *\/\n  conn = allocate_conn(data);\n\n  if(!conn) {\n    result = CURLE_OUT_OF_MEMORY;\n    goto out;\n  }\n\n  \/* We must set the return variable as soon as possible, so that our\n     parent can cleanup any possible allocs we may have done before\n     any failure *\/\n  *in_connect = conn;\n\n  \/* This initing continues below, see the comment \"Continue connectdata\n   * initialization here\" *\/\n\n  \/***********************************************************\n   * We need to allocate memory to store the path in. We get the size of the\n   * full URL to be sure, and we need to make it at least 256 bytes since\n   * other parts of the code will rely on this fact\n   ***********************************************************\/\n#define LEAST_PATH_ALLOC 256\n  urllen=strlen(data->change.url);\n  if(urllen < LEAST_PATH_ALLOC)\n    urllen=LEAST_PATH_ALLOC;\n\n  \/*\n   * We malloc() the buffers below urllen+2 to make room for 2 possibilities:\n   * 1 - an extra terminating zero\n   * 2 - an extra slash (in case a syntax like \"www.host.com?moo\" is used)\n   *\/\n\n  Curl_safefree(data->state.pathbuffer);\n  data->state.path = NULL;\n\n  data->state.pathbuffer = malloc(urllen+2);\n  if(NULL == data->state.pathbuffer) {\n    result = CURLE_OUT_OF_MEMORY; \/* really bad error *\/\n    goto out;\n  }\n  data->state.path = data->state.pathbuffer;\n\n  conn->host.rawalloc = malloc(urllen+2);\n  if(NULL == conn->host.rawalloc) {\n    Curl_safefree(data->state.pathbuffer);\n    data->state.path = NULL;\n    result = CURLE_OUT_OF_MEMORY;\n    goto out;\n  }\n\n  conn->host.name = conn->host.rawalloc;\n  conn->host.name[0] = 0;\n\n  user = strdup(\"\");\n  passwd = strdup(\"\");\n  options = strdup(\"\");\n  if(!user || !passwd || !options) {\n    result = CURLE_OUT_OF_MEMORY;\n    goto out;\n  }\n\n  result = parseurlandfillconn(data, conn, &prot_missing, &user, &passwd,\n                               &options);\n  if(result)\n    goto out;\n\n  \/*************************************************************\n   * No protocol part in URL was used, add it!\n   *************************************************************\/\n  if(prot_missing) {\n    \/* We're guessing prefixes here and if we're told to use a proxy or if\n       we're gonna follow a Location: later or... then we need the protocol\n       part added so that we have a valid URL. *\/\n    char *reurl;\n\n    reurl = aprintf(\"%s:\/\/%s\", conn->handler->scheme, data->change.url);\n\n    if(!reurl) {\n      result = CURLE_OUT_OF_MEMORY;\n      goto out;\n    }\n\n    if(data->change.url_alloc) {\n      Curl_safefree(data->change.url);\n      data->change.url_alloc = FALSE;\n    }\n\n    data->change.url = reurl;\n    data->change.url_alloc = TRUE; \/* free this later *\/\n  }\n\n  \/*************************************************************\n   * If the protocol can't handle url query strings, then cut\n   * off the unhandable part\n   *************************************************************\/\n  if((conn->given->flags&PROTOPT_NOURLQUERY)) {\n    char *path_q_sep = strchr(conn->data->state.path, '?');\n    if(path_q_sep) {\n      \/* according to rfc3986, allow the query (?foo=bar)\n         also on protocols that can't handle it.\n\n         cut the string-part after '?'\n      *\/\n\n      \/* terminate the string *\/\n      path_q_sep[0] = 0;\n    }\n  }\n\n  if(data->set.str[STRING_BEARER]) {\n    conn->xoauth2_bearer = strdup(data->set.str[STRING_BEARER]);\n    if(!conn->xoauth2_bearer) {\n      result = CURLE_OUT_OF_MEMORY;\n      goto out;\n    }\n  }\n\n#ifndef CURL_DISABLE_PROXY\n  \/*************************************************************\n   * Extract the user and password from the authentication string\n   *************************************************************\/\n  if(conn->bits.proxy_user_passwd) {\n    result = parse_proxy_auth(data, conn);\n    if(result)\n      goto out;\n  }\n\n  \/*************************************************************\n   * Detect what (if any) proxy to use\n   *************************************************************\/\n  if(data->set.str[STRING_PROXY]) {\n    proxy = strdup(data->set.str[STRING_PROXY]);\n    \/* if global proxy is set, this is it *\/\n    if(NULL == proxy) {\n      failf(data, \"memory shortage\");\n      result = CURLE_OUT_OF_MEMORY;\n      goto out;\n    }\n  }\n\n  if(data->set.str[STRING_NOPROXY] &&\n     check_noproxy(conn->host.name, data->set.str[STRING_NOPROXY])) {\n    if(proxy) {\n      free(proxy);  \/* proxy is in exception list *\/\n      proxy = NULL;\n    }\n  }\n  else if(!proxy)\n    proxy = detect_proxy(conn);\n\n#ifdef USE_UNIX_SOCKETS\n  if(proxy && data->set.str[STRING_UNIX_SOCKET_PATH]) {\n    free(proxy);  \/* Unix domain sockets cannot be proxied, so disable it *\/\n    proxy = NULL;\n  }\n#endif\n\n  if(proxy && (!*proxy || (conn->handler->flags & PROTOPT_NONETWORK))) {\n    free(proxy);  \/* Don't bother with an empty proxy string or if the\n                     protocol doesn't work with network *\/\n    proxy = NULL;\n  }\n\n  \/***********************************************************************\n   * If this is supposed to use a proxy, we need to figure out the proxy host\n   * name, proxy type and port number, so that we can re-use an existing\n   * connection that may exist registered to the same proxy host.\n   ***********************************************************************\/\n  if(proxy) {\n    result = parse_proxy(data, conn, proxy);\n\n    Curl_safefree(proxy); \/* parse_proxy copies the proxy string *\/\n\n    if(result)\n      goto out;\n\n    if((conn->proxytype == CURLPROXY_HTTP) ||\n       (conn->proxytype == CURLPROXY_HTTP_1_0)) {\n#ifdef CURL_DISABLE_HTTP\n      \/* asking for a HTTP proxy is a bit funny when HTTP is disabled... *\/\n      result = CURLE_UNSUPPORTED_PROTOCOL;\n      goto out;\n#else\n      \/* force this connection's protocol to become HTTP if not already\n         compatible - if it isn't tunneling through *\/\n      if(!(conn->handler->protocol & PROTO_FAMILY_HTTP) &&\n         !conn->bits.tunnel_proxy)\n        conn->handler = &Curl_handler_http;\n\n      conn->bits.httpproxy = TRUE;\n#endif\n    }\n    else\n      conn->bits.httpproxy = FALSE; \/* not a HTTP proxy *\/\n    conn->bits.proxy = TRUE;\n  }\n  else {\n    \/* we aren't using the proxy after all... *\/\n    conn->bits.proxy = FALSE;\n    conn->bits.httpproxy = FALSE;\n    conn->bits.proxy_user_passwd = FALSE;\n    conn->bits.tunnel_proxy = FALSE;\n  }\n\n#endif \/* CURL_DISABLE_PROXY *\/\n\n  \/*************************************************************\n   * If the protocol is using SSL and HTTP proxy is used, we set\n   * the tunnel_proxy bit.\n   *************************************************************\/\n  if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy)\n    conn->bits.tunnel_proxy = TRUE;\n\n  \/*************************************************************\n   * Figure out the remote port number and fix it in the URL\n   *************************************************************\/\n  result = parse_remote_port(data, conn);\n  if(result)\n    goto out;\n\n  \/* Check for overridden login details and set them accordingly so they\n     they are known when protocol->setup_connection is called! *\/\n  result = override_login(data, conn, &user, &passwd, &options);\n  if(result)\n    goto out;\n  result = set_login(conn, user, passwd, options);\n  if(result)\n    goto out;\n\n  \/*************************************************************\n   * Setup internals depending on protocol. Needs to be done after\n   * we figured out what\/if proxy to use.\n   *************************************************************\/\n  result = setup_connection_internals(conn);\n  if(result)\n    goto out;\n\n  conn->recv[FIRSTSOCKET] = Curl_recv_plain;\n  conn->send[FIRSTSOCKET] = Curl_send_plain;\n  conn->recv[SECONDARYSOCKET] = Curl_recv_plain;\n  conn->send[SECONDARYSOCKET] = Curl_send_plain;\n\n  \/***********************************************************************\n   * file: is a special case in that it doesn't need a network connection\n   ***********************************************************************\/\n#ifndef CURL_DISABLE_FILE\n  if(conn->handler->flags & PROTOPT_NONETWORK) {\n    bool done;\n    \/* this is supposed to be the connect function so we better at least check\n       that the file is present here! *\/\n    DEBUGASSERT(conn->handler->connect_it);\n    result = conn->handler->connect_it(conn, &done);\n\n    \/* Setup a \"faked\" transfer that'll do nothing *\/\n    if(!result) {\n      conn->data = data;\n      conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; \/* we are \"connected *\/\n\n      ConnectionStore(data, conn);\n\n      \/*\n       * Setup whatever necessary for a resumed transfer\n       *\/\n      result = setup_range(data);\n      if(result) {\n        DEBUGASSERT(conn->handler->done);\n        \/* we ignore the return code for the protocol-specific DONE *\/\n        (void)conn->handler->done(conn, result, FALSE);\n        goto out;\n      }\n\n      Curl_setup_transfer(conn, -1, -1, FALSE, NULL, \/* no download *\/\n                          -1, NULL); \/* no upload *\/\n    }\n\n    \/* since we skip do_init() *\/\n    do_init(conn);\n\n    goto out;\n  }\n#endif\n\n  \/* Get a cloned copy of the SSL config situation stored in the\n     connection struct. But to get this going nicely, we must first make\n     sure that the strings in the master copy are pointing to the correct\n     strings in the session handle strings array!\n\n     Keep in mind that the pointers in the master copy are pointing to strings\n     that will be freed as part of the SessionHandle struct, but all cloned\n     copies will be separately allocated.\n  *\/\n  data->set.ssl.CApath = data->set.str[STRING_SSL_CAPATH];\n  data->set.ssl.CAfile = data->set.str[STRING_SSL_CAFILE];\n  data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE];\n  data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT];\n  data->set.ssl.random_file = data->set.str[STRING_SSL_RANDOM_FILE];\n  data->set.ssl.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];\n  data->set.ssl.cipher_list = data->set.str[STRING_SSL_CIPHER_LIST];\n#ifdef USE_TLS_SRP\n  data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME];\n  data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD];\n#endif\n\n  if(!Curl_clone_ssl_config(&data->set.ssl, &conn->ssl_config)) {\n    result = CURLE_OUT_OF_MEMORY;\n    goto out;\n  }\n\n  prune_dead_connections(data);\n\n  \/*************************************************************\n   * Check the current list of connections to see if we can\n   * re-use an already existing one or if we have to create a\n   * new one.\n   *************************************************************\/\n\n  \/* reuse_fresh is TRUE if we are told to use a new connection by force, but\n     we only acknowledge this option if this is not a re-used connection\n     already (which happens due to follow-location or during a HTTP\n     authentication phase). *\/\n  if(data->set.reuse_fresh && !data->state.this_is_a_follow)\n    reuse = FALSE;\n  else\n    reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse);\n\n  \/* If we found a reusable connection, we may still want to\n     open a new connection if we are pipelining. *\/\n  if(reuse && !force_reuse && IsPipeliningPossible(data, conn_temp)) {\n    size_t pipelen = conn_temp->send_pipe->size + conn_temp->recv_pipe->size;\n    if(pipelen > 0) {\n      infof(data, \"Found connection %ld, with requests in the pipe (%zu)\\n\",\n            conn_temp->connection_id, pipelen);\n\n      if(conn_temp->bundle->num_connections < max_host_connections &&\n         data->state.conn_cache->num_connections < max_total_connections) {\n        \/* We want a new connection anyway *\/\n        reuse = FALSE;\n\n        infof(data, \"We can reuse, but we want a new connection anyway\\n\");\n      }\n    }\n  }\n\n  if(reuse) {\n    \/*\n     * We already have a connection for this, we got the former connection\n     * in the conn_temp variable and thus we need to cleanup the one we\n     * just allocated before we can move along and use the previously\n     * existing one.\n     *\/\n    conn_temp->inuse = TRUE; \/* mark this as being in use so that no other\n                                handle in a multi stack may nick it *\/\n    reuse_conn(conn, conn_temp);\n    free(conn);          \/* we don't need this anymore *\/\n    conn = conn_temp;\n    *in_connect = conn;\n\n    \/* set a pointer to the hostname we display *\/\n    fix_hostname(data, conn, &conn->host);\n\n    infof(data, \"Re-using existing connection! (#%ld) with host %s\\n\",\n          conn->connection_id,\n          conn->proxy.name?conn->proxy.dispname:conn->host.dispname);\n  }\n  else {\n    \/* We have decided that we want a new connection. However, we may not\n       be able to do that if we have reached the limit of how many\n       connections we are allowed to open. *\/\n    struct connectbundle *bundle;\n\n    bundle = Curl_conncache_find_bundle(data->state.conn_cache,\n                                        conn->host.name);\n    if(max_host_connections > 0 && bundle &&\n       (bundle->num_connections >= max_host_connections)) {\n      struct connectdata *conn_candidate;\n\n      \/* The bundle is full. Let's see if we can kill a connection. *\/\n      conn_candidate = find_oldest_idle_connection_in_bundle(data, bundle);\n\n      if(conn_candidate) {\n        \/* Set the connection's owner correctly, then kill it *\/\n        conn_candidate->data = data;\n        (void)Curl_disconnect(conn_candidate, \/* dead_connection *\/ FALSE);\n      }\n      else\n        no_connections_available = TRUE;\n    }\n\n    if(max_total_connections > 0 &&\n       (data->state.conn_cache->num_connections >= max_total_connections)) {\n      struct connectdata *conn_candidate;\n\n      \/* The cache is full. Let's see if we can kill a connection. *\/\n      conn_candidate = find_oldest_idle_connection(data);\n\n      if(conn_candidate) {\n        \/* Set the connection's owner correctly, then kill it *\/\n        conn_candidate->data = data;\n        (void)Curl_disconnect(conn_candidate, \/* dead_connection *\/ FALSE);\n      }\n      else\n        no_connections_available = TRUE;\n    }\n\n\n    if(no_connections_available) {\n      infof(data, \"No connections available.\\n\");\n\n      conn_free(conn);\n      *in_connect = NULL;\n\n      result = CURLE_NO_CONNECTION_AVAILABLE;\n      goto out;\n    }\n    else {\n      \/*\n       * This is a brand new connection, so let's store it in the connection\n       * cache of ours!\n       *\/\n      ConnectionStore(data, conn);\n    }\n\n#if defined(USE_NTLM)\n    \/* If NTLM is requested in a part of this connection, make sure we don't\n       assume the state is fine as this is a fresh connection and NTLM is\n       connection based. *\/\n    if((data->state.authhost.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&\n       data->state.authhost.done) {\n      infof(data, \"NTLM picked AND auth done set, clear picked!\\n\");\n      data->state.authhost.picked = CURLAUTH_NONE;\n    }\n\n    if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&\n       data->state.authproxy.done) {\n      infof(data, \"NTLM-proxy picked AND auth done set, clear picked!\\n\");\n      data->state.authproxy.picked = CURLAUTH_NONE;\n    }\n#endif\n  }\n\n  \/* Mark the connection as used *\/\n  conn->inuse = TRUE;\n\n  \/* Setup and init stuff before DO starts, in preparing for the transfer. *\/\n  do_init(conn);\n\n  \/*\n   * Setup whatever necessary for a resumed transfer\n   *\/\n  result = setup_range(data);\n  if(result)\n    goto out;\n\n  \/* Continue connectdata initialization here. *\/\n\n  \/*\n   * Inherit the proper values from the urldata struct AFTER we have arranged\n   * the persistent connection stuff\n   *\/\n  conn->fread_func = data->set.fread_func;\n  conn->fread_in = data->set.in;\n  conn->seek_func = data->set.seek_func;\n  conn->seek_client = data->set.seek_client;\n\n  \/*************************************************************\n   * Resolve the address of the server or proxy\n   *************************************************************\/\n  result = resolve_server(data, conn, async);\n\n  out:\n\n  Curl_safefree(options);\n  Curl_safefree(passwd);\n  Curl_safefree(user);\n  Curl_safefree(proxy);\n  return result;\n}","target":0,"code_token_length":4000,"total_token_length":4236,"max_tokens_setting":6144}
+{"idx":264411,"func":"Curl_cookie_add(struct Curl_easy *data,\n                \/*\n                 * The 'data' pointer here may be NULL at times, and thus\n                 * must only be used very carefully for things that can deal\n                 * with data being NULL. Such as infof() and similar\n                 *\/\n                struct CookieInfo *c,\n                bool httpheader, \/* TRUE if HTTP header-style line *\/\n                bool noexpire, \/* if TRUE, skip remove_expired() *\/\n                char *lineptr,   \/* first character of the line *\/\n                const char *domain, \/* default domain *\/\n                const char *path,   \/* full path used when this cookie is set,\n                                       used to get default path for the cookie\n                                       unless set *\/\n                bool secure)  \/* TRUE if connection is over secure origin *\/\n{\n  struct Cookie *clist;\n  struct Cookie *co;\n  struct Cookie *lastc = NULL;\n  struct Cookie *replace_co = NULL;\n  struct Cookie *replace_clist = NULL;\n  time_t now = time(NULL);\n  bool replace_old = FALSE;\n  bool badcookie = FALSE; \/* cookies are good by default. mmmmm yummy *\/\n  size_t myhash;\n\n#ifdef CURL_DISABLE_VERBOSE_STRINGS\n  (void)data;\n#endif\n\n  DEBUGASSERT(MAX_SET_COOKIE_AMOUNT <= 255); \/* counter is an unsigned char *\/\n  if(data->req.setcookies >= MAX_SET_COOKIE_AMOUNT)\n    return NULL;\n\n  \/* First, alloc and init a new struct for it *\/\n  co = calloc(1, sizeof(struct Cookie));\n  if(!co)\n    return NULL; \/* bail out if we're this low on memory *\/\n\n  if(httpheader) {\n    \/* This line was read off a HTTP-header *\/\n    char name[MAX_NAME];\n    char what[MAX_NAME];\n    const char *ptr;\n    const char *semiptr;\n\n    size_t linelength = strlen(lineptr);\n    if(linelength > MAX_COOKIE_LINE) {\n      \/* discard overly long lines at once *\/\n      free(co);\n      return NULL;\n    }\n\n    semiptr = strchr(lineptr, ';'); \/* first, find a semicolon *\/\n\n    while(*lineptr && ISBLANK(*lineptr))\n      lineptr++;\n\n    ptr = lineptr;\n    do {\n      \/* we have a <what>=<this> pair or a stand-alone word here *\/\n      name[0] = what[0] = 0; \/* init the buffers *\/\n      if(1 <= sscanf(ptr, \"%\" MAX_NAME_TXT \"[^;\\r\\n=] =%\"\n                     MAX_NAME_TXT \"[^;\\r\\n]\",\n                     name, what)) {\n        \/*\n         * Use strstore() below to properly deal with received cookie\n         * headers that have the same string property set more than once,\n         * and then we use the last one.\n         *\/\n        const char *whatptr;\n        bool done = FALSE;\n        bool sep;\n        size_t len = strlen(what);\n        size_t nlen = strlen(name);\n        const char *endofn = &ptr[ nlen ];\n\n        \/*\n         * Check for too long individual name or contents, or too long\n         * combination of name + contents. Chrome and Firefox support 4095 or\n         * 4096 bytes combo\n         *\/\n        if(nlen >= (MAX_NAME-1) || len >= (MAX_NAME-1) ||\n           ((nlen + len) > MAX_NAME)) {\n          freecookie(co);\n          infof(data, \"oversized cookie dropped, name\/val %zu + %zu bytes\",\n                nlen, len);\n          return NULL;\n        }\n\n        \/* name ends with a '=' ? *\/\n        sep = (*endofn == '=')?TRUE:FALSE;\n\n        if(nlen) {\n          endofn--; \/* move to the last character *\/\n          if(ISBLANK(*endofn)) {\n            \/* skip trailing spaces in name *\/\n            while(*endofn && ISBLANK(*endofn) && nlen) {\n              endofn--;\n              nlen--;\n            }\n            name[nlen] = 0; \/* new end of name *\/\n          }\n        }\n\n        \/* Strip off trailing whitespace from the 'what' *\/\n        while(len && ISBLANK(what[len-1])) {\n          what[len-1] = 0;\n          len--;\n        }\n\n        \/* Skip leading whitespace from the 'what' *\/\n        whatptr = what;\n        while(*whatptr && ISBLANK(*whatptr))\n          whatptr++;\n\n        \/*\n         * Check if we have a reserved prefix set before anything else, as we\n         * otherwise have to test for the prefix in both the cookie name and\n         * \"the rest\". Prefixes must start with '__' and end with a '-', so\n         * only test for names where that can possibly be true.\n         *\/\n        if(nlen > 3 && name[0] == '_' && name[1] == '_') {\n          if(!strncmp(\"__Secure-\", name, 9))\n            co->prefix |= COOKIE_PREFIX__SECURE;\n          else if(!strncmp(\"__Host-\", name, 7))\n            co->prefix |= COOKIE_PREFIX__HOST;\n        }\n\n        if(!co->name) {\n          \/* The very first name\/value pair is the actual cookie name *\/\n          if(!sep) {\n            \/* Bad name\/value pair. *\/\n            badcookie = TRUE;\n            break;\n          }\n          co->name = strdup(name);\n          co->value = strdup(whatptr);\n          done = TRUE;\n          if(!co->name || !co->value) {\n            badcookie = TRUE;\n            break;\n          }\n          if(invalid_octets(whatptr) || invalid_octets(name)) {\n            infof(data, \"invalid octets in name\/value, cookie dropped\");\n            badcookie = TRUE;\n            break;\n          }\n        }\n        else if(!len) {\n          \/*\n           * this was a \"<name>=\" with no content, and we must allow\n           * 'secure' and 'httponly' specified this weirdly\n           *\/\n          done = TRUE;\n          \/*\n           * secure cookies are only allowed to be set when the connection is\n           * using a secure protocol, or when the cookie is being set by\n           * reading from file\n           *\/\n          if(strcasecompare(\"secure\", name)) {\n            if(secure || !c->running) {\n              co->secure = TRUE;\n            }\n            else {\n              badcookie = TRUE;\n              break;\n            }\n          }\n          else if(strcasecompare(\"httponly\", name))\n            co->httponly = TRUE;\n          else if(sep)\n            \/* there was a '=' so we're not done parsing this field *\/\n            done = FALSE;\n        }\n        if(done)\n          ;\n        else if(strcasecompare(\"path\", name)) {\n          strstore(&co->path, whatptr);\n          if(!co->path) {\n            badcookie = TRUE; \/* out of memory bad *\/\n            break;\n          }\n          free(co->spath); \/* if this is set again *\/\n          co->spath = sanitize_cookie_path(co->path);\n          if(!co->spath) {\n            badcookie = TRUE; \/* out of memory bad *\/\n            break;\n          }\n        }\n        else if(strcasecompare(\"domain\", name) && whatptr[0]) {\n          bool is_ip;\n\n          \/*\n           * Now, we make sure that our host is within the given domain, or\n           * the given domain is not valid and thus cannot be set.\n           *\/\n\n          if('.' == whatptr[0])\n            whatptr++; \/* ignore preceding dot *\/\n\n#ifndef USE_LIBPSL\n          \/*\n           * Without PSL we don't know when the incoming cookie is set on a\n           * TLD or otherwise \"protected\" suffix. To reduce risk, we require a\n           * dot OR the exact host name being \"localhost\".\n           *\/\n          if(bad_domain(whatptr))\n            domain = \":\";\n#endif\n\n          is_ip = Curl_host_is_ipnum(domain ? domain : whatptr);\n\n          if(!domain\n             || (is_ip && !strcmp(whatptr, domain))\n             || (!is_ip && tailmatch(whatptr, domain))) {\n            strstore(&co->domain, whatptr);\n            if(!co->domain) {\n              badcookie = TRUE;\n              break;\n            }\n            if(!is_ip)\n              co->tailmatch = TRUE; \/* we always do that if the domain name was\n                                       given *\/\n          }\n          else {\n            \/*\n             * We did not get a tailmatch and then the attempted set domain is\n             * not a domain to which the current host belongs. Mark as bad.\n             *\/\n            badcookie = TRUE;\n            infof(data, \"skipped cookie with bad tailmatch domain: %s\",\n                  whatptr);\n          }\n        }\n        else if(strcasecompare(\"version\", name)) {\n          strstore(&co->version, whatptr);\n          if(!co->version) {\n            badcookie = TRUE;\n            break;\n          }\n        }\n        else if(strcasecompare(\"max-age\", name)) {\n          \/*\n           * Defined in RFC2109:\n           *\n           * Optional.  The Max-Age attribute defines the lifetime of the\n           * cookie, in seconds.  The delta-seconds value is a decimal non-\n           * negative integer.  After delta-seconds seconds elapse, the\n           * client should discard the cookie.  A value of zero means the\n           * cookie should be discarded immediately.\n           *\/\n          strstore(&co->maxage, whatptr);\n          if(!co->maxage) {\n            badcookie = TRUE;\n            break;\n          }\n        }\n        else if(strcasecompare(\"expires\", name)) {\n          strstore(&co->expirestr, whatptr);\n          if(!co->expirestr) {\n            badcookie = TRUE;\n            break;\n          }\n        }\n\n        \/*\n         * Else, this is the second (or more) name we don't know about!\n         *\/\n      }\n      else {\n        \/* this is an \"illegal\" <what>=<this> pair *\/\n      }\n\n      if(!semiptr || !*semiptr) {\n        \/* we already know there are no more cookies *\/\n        semiptr = NULL;\n        continue;\n      }\n\n      ptr = semiptr + 1;\n      while(*ptr && ISBLANK(*ptr))\n        ptr++;\n      semiptr = strchr(ptr, ';'); \/* now, find the next semicolon *\/\n\n      if(!semiptr && *ptr)\n        \/*\n         * There are no more semicolons, but there's a final name=value pair\n         * coming up\n         *\/\n        semiptr = strchr(ptr, '\\0');\n    } while(semiptr);\n\n    if(co->maxage) {\n      CURLofft offt;\n      offt = curlx_strtoofft((*co->maxage == '\\\"')?\n                             &co->maxage[1]:&co->maxage[0], NULL, 10,\n                             &co->expires);\n      if(offt == CURL_OFFT_FLOW)\n        \/* overflow, used max value *\/\n        co->expires = CURL_OFF_T_MAX;\n      else if(!offt) {\n        if(!co->expires)\n          \/* already expired *\/\n          co->expires = 1;\n        else if(CURL_OFF_T_MAX - now < co->expires)\n          \/* would overflow *\/\n          co->expires = CURL_OFF_T_MAX;\n        else\n          co->expires += now;\n      }\n    }\n    else if(co->expirestr) {\n      \/*\n       * Note that if the date couldn't get parsed for whatever reason, the\n       * cookie will be treated as a session cookie\n       *\/\n      co->expires = Curl_getdate_capped(co->expirestr);\n\n      \/*\n       * Session cookies have expires set to 0 so if we get that back from the\n       * date parser let's add a second to make it a non-session cookie\n       *\/\n      if(co->expires == 0)\n        co->expires = 1;\n      else if(co->expires < 0)\n        co->expires = 0;\n    }\n\n    if(!badcookie && !co->domain) {\n      if(domain) {\n        \/* no domain was given in the header line, set the default *\/\n        co->domain = strdup(domain);\n        if(!co->domain)\n          badcookie = TRUE;\n      }\n    }\n\n    if(!badcookie && !co->path && path) {\n      \/*\n       * No path was given in the header line, set the default.  Note that the\n       * passed-in path to this function MAY have a '?' and following part that\n       * MUST NOT be stored as part of the path.\n       *\/\n      char *queryp = strchr(path, '?');\n\n      \/*\n       * queryp is where the interesting part of the path ends, so now we\n       * want to the find the last\n       *\/\n      char *endslash;\n      if(!queryp)\n        endslash = strrchr(path, '\/');\n      else\n        endslash = memrchr(path, '\/', (queryp - path));\n      if(endslash) {\n        size_t pathlen = (endslash-path + 1); \/* include end slash *\/\n        co->path = malloc(pathlen + 1); \/* one extra for the zero byte *\/\n        if(co->path) {\n          memcpy(co->path, path, pathlen);\n          co->path[pathlen] = 0; \/* null-terminate *\/\n          co->spath = sanitize_cookie_path(co->path);\n          if(!co->spath)\n            badcookie = TRUE; \/* out of memory bad *\/\n        }\n        else\n          badcookie = TRUE;\n      }\n    }\n\n    \/*\n     * If we didn't get a cookie name, or a bad one, the this is an illegal\n     * line so bail out.\n     *\/\n    if(badcookie || !co->name) {\n      freecookie(co);\n      return NULL;\n    }\n    data->req.setcookies++;\n  }\n  else {\n    \/*\n     * This line is NOT a HTTP header style line, we do offer support for\n     * reading the odd netscape cookies-file format here\n     *\/\n    char *ptr;\n    char *firstptr;\n    char *tok_buf = NULL;\n    int fields;\n\n    \/*\n     * IE introduced HTTP-only cookies to prevent XSS attacks. Cookies marked\n     * with httpOnly after the domain name are not accessible from javascripts,\n     * but since curl does not operate at javascript level, we include them\n     * anyway. In Firefox's cookie files, these lines are preceded with\n     * #HttpOnly_ and then everything is as usual, so we skip 10 characters of\n     * the line..\n     *\/\n    if(strncmp(lineptr, \"#HttpOnly_\", 10) == 0) {\n      lineptr += 10;\n      co->httponly = TRUE;\n    }\n\n    if(lineptr[0]=='#') {\n      \/* don't even try the comments *\/\n      free(co);\n      return NULL;\n    }\n    \/* strip off the possible end-of-line characters *\/\n    ptr = strchr(lineptr, '\\r');\n    if(ptr)\n      *ptr = 0; \/* clear it *\/\n    ptr = strchr(lineptr, '\\n');\n    if(ptr)\n      *ptr = 0; \/* clear it *\/\n\n    firstptr = strtok_r(lineptr, \"\\t\", &tok_buf); \/* tokenize it on the TAB *\/\n\n    \/*\n     * Now loop through the fields and init the struct we already have\n     * allocated\n     *\/\n    for(ptr = firstptr, fields = 0; ptr && !badcookie;\n        ptr = strtok_r(NULL, \"\\t\", &tok_buf), fields++) {\n      switch(fields) {\n      case 0:\n        if(ptr[0]=='.') \/* skip preceding dots *\/\n          ptr++;\n        co->domain = strdup(ptr);\n        if(!co->domain)\n          badcookie = TRUE;\n        break;\n      case 1:\n        \/*\n         * flag: A TRUE\/FALSE value indicating if all machines within a given\n         * domain can access the variable. Set TRUE when the cookie says\n         * .domain.com and to false when the domain is complete www.domain.com\n         *\/\n        co->tailmatch = strcasecompare(ptr, \"TRUE\")?TRUE:FALSE;\n        break;\n      case 2:\n        \/* The file format allows the path field to remain not filled in *\/\n        if(strcmp(\"TRUE\", ptr) && strcmp(\"FALSE\", ptr)) {\n          \/* only if the path doesn't look like a boolean option! *\/\n          co->path = strdup(ptr);\n          if(!co->path)\n            badcookie = TRUE;\n          else {\n            co->spath = sanitize_cookie_path(co->path);\n            if(!co->spath) {\n              badcookie = TRUE; \/* out of memory bad *\/\n            }\n          }\n          break;\n        }\n        \/* this doesn't look like a path, make one up! *\/\n        co->path = strdup(\"\/\");\n        if(!co->path)\n          badcookie = TRUE;\n        co->spath = strdup(\"\/\");\n        if(!co->spath)\n          badcookie = TRUE;\n        fields++; \/* add a field and fall down to secure *\/\n        \/* FALLTHROUGH *\/\n      case 3:\n        co->secure = FALSE;\n        if(strcasecompare(ptr, \"TRUE\")) {\n          if(secure || c->running)\n            co->secure = TRUE;\n          else\n            badcookie = TRUE;\n        }\n        break;\n      case 4:\n        if(curlx_strtoofft(ptr, NULL, 10, &co->expires))\n          badcookie = TRUE;\n        break;\n      case 5:\n        co->name = strdup(ptr);\n        if(!co->name)\n          badcookie = TRUE;\n        else {\n          \/* For Netscape file format cookies we check prefix on the name *\/\n          if(strncasecompare(\"__Secure-\", co->name, 9))\n            co->prefix |= COOKIE_PREFIX__SECURE;\n          else if(strncasecompare(\"__Host-\", co->name, 7))\n            co->prefix |= COOKIE_PREFIX__HOST;\n        }\n        break;\n      case 6:\n        co->value = strdup(ptr);\n        if(!co->value)\n          badcookie = TRUE;\n        break;\n      }\n    }\n    if(6 == fields) {\n      \/* we got a cookie with blank contents, fix it *\/\n      co->value = strdup(\"\");\n      if(!co->value)\n        badcookie = TRUE;\n      else\n        fields++;\n    }\n\n    if(!badcookie && (7 != fields))\n      \/* we did not find the sufficient number of fields *\/\n      badcookie = TRUE;\n\n    if(badcookie) {\n      freecookie(co);\n      return NULL;\n    }\n\n  }\n\n  if(co->prefix & COOKIE_PREFIX__SECURE) {\n    \/* The __Secure- prefix only requires that the cookie be set secure *\/\n    if(!co->secure) {\n      freecookie(co);\n      return NULL;\n    }\n  }\n  if(co->prefix & COOKIE_PREFIX__HOST) {\n    \/*\n     * The __Host- prefix requires the cookie to be secure, have a \"\/\" path\n     * and not have a domain set.\n     *\/\n    if(co->secure && co->path && strcmp(co->path, \"\/\") == 0 && !co->tailmatch)\n      ;\n    else {\n      freecookie(co);\n      return NULL;\n    }\n  }\n\n  if(!c->running &&    \/* read from a file *\/\n     c->newsession &&  \/* clean session cookies *\/\n     !co->expires) {   \/* this is a session cookie since it doesn't expire! *\/\n    freecookie(co);\n    return NULL;\n  }\n\n  co->livecookie = c->running;\n  co->creationtime = ++c->lastct;\n\n  \/*\n   * Now we have parsed the incoming line, we must now check if this supersedes\n   * an already existing cookie, which it may if the previous have the same\n   * domain and path as this.\n   *\/\n\n  \/* at first, remove expired cookies *\/\n  if(!noexpire)\n    remove_expired(c);\n\n#ifdef USE_LIBPSL\n  \/*\n   * Check if the domain is a Public Suffix and if yes, ignore the cookie. We\n   * must also check that the data handle isn't NULL since the psl code will\n   * dereference it.\n   *\/\n  if(data && (domain && co->domain && !Curl_host_is_ipnum(co->domain))) {\n    const psl_ctx_t *psl = Curl_psl_use(data);\n    int acceptable;\n\n    if(psl) {\n      acceptable = psl_is_cookie_domain_acceptable(psl, domain, co->domain);\n      Curl_psl_release(data);\n    }\n    else\n      acceptable = !bad_domain(domain);\n\n    if(!acceptable) {\n      infof(data, \"cookie '%s' dropped, domain '%s' must not \"\n                  \"set cookies for '%s'\", co->name, domain, co->domain);\n      freecookie(co);\n      return NULL;\n    }\n  }\n#endif\n\n  \/* A non-secure cookie may not overlay an existing secure cookie. *\/\n  myhash = cookiehash(co->domain);\n  clist = c->cookies[myhash];\n  while(clist) {\n    if(strcasecompare(clist->name, co->name)) {\n      \/* the names are identical *\/\n      bool matching_domains = FALSE;\n\n      if(clist->domain && co->domain) {\n        if(strcasecompare(clist->domain, co->domain))\n          \/* The domains are identical *\/\n          matching_domains = TRUE;\n      }\n      else if(!clist->domain && !co->domain)\n        matching_domains = TRUE;\n\n      if(matching_domains && \/* the domains were identical *\/\n         clist->spath && co->spath && \/* both have paths *\/\n         clist->secure && !co->secure && !secure) {\n        size_t cllen;\n        const char *sep;\n\n        \/*\n         * A non-secure cookie may not overlay an existing secure cookie.\n         * For an existing cookie \"a\" with path \"\/login\", refuse a new\n         * cookie \"a\" with for example path \"\/login\/en\", while the path\n         * \"\/loginhelper\" is ok.\n         *\/\n\n        sep = strchr(clist->spath + 1, '\/');\n\n        if(sep)\n          cllen = sep - clist->spath;\n        else\n          cllen = strlen(clist->spath);\n\n        if(strncasecompare(clist->spath, co->spath, cllen)) {\n          infof(data, \"cookie '%s' for domain '%s' dropped, would \"\n                \"overlay an existing cookie\", co->name, co->domain);\n          freecookie(co);\n          return NULL;\n        }\n      }\n    }\n\n    if(!replace_co && strcasecompare(clist->name, co->name)) {\n      \/* the names are identical *\/\n\n      if(clist->domain && co->domain) {\n        if(strcasecompare(clist->domain, co->domain) &&\n          (clist->tailmatch == co->tailmatch))\n          \/* The domains are identical *\/\n          replace_old = TRUE;\n      }\n      else if(!clist->domain && !co->domain)\n        replace_old = TRUE;\n\n      if(replace_old) {\n        \/* the domains were identical *\/\n\n        if(clist->spath && co->spath) {\n          if(strcasecompare(clist->spath, co->spath))\n            replace_old = TRUE;\n          else\n            replace_old = FALSE;\n        }\n        else if(!clist->spath && !co->spath)\n          replace_old = TRUE;\n        else\n          replace_old = FALSE;\n\n      }\n\n      if(replace_old && !co->livecookie && clist->livecookie) {\n        \/*\n         * Both cookies matched fine, except that the already present cookie is\n         * \"live\", which means it was set from a header, while the new one was\n         * read from a file and thus isn't \"live\". \"live\" cookies are preferred\n         * so the new cookie is freed.\n         *\/\n        freecookie(co);\n        return NULL;\n      }\n      if(replace_old) {\n        replace_co = co;\n        replace_clist = clist;\n      }\n    }\n    lastc = clist;\n    clist = clist->next;\n  }\n  if(replace_co) {\n    co = replace_co;\n    clist = replace_clist;\n    co->next = clist->next; \/* get the next-pointer first *\/\n\n    \/* when replacing, creationtime is kept from old *\/\n    co->creationtime = clist->creationtime;\n\n    \/* then free all the old pointers *\/\n    free(clist->name);\n    free(clist->value);\n    free(clist->domain);\n    free(clist->path);\n    free(clist->spath);\n    free(clist->expirestr);\n    free(clist->version);\n    free(clist->maxage);\n\n    *clist = *co;  \/* then store all the new data *\/\n\n    free(co);   \/* free the newly allocated memory *\/\n    co = clist;\n  }\n\n  if(c->running)\n    \/* Only show this when NOT reading the cookies from a file *\/\n    infof(data, \"%s cookie %s=\\\"%s\\\" for domain %s, path %s, \"\n          \"expire %\" CURL_FORMAT_CURL_OFF_T,\n          replace_old?\"Replaced\":\"Added\", co->name, co->value,\n          co->domain, co->path, co->expires);\n\n  if(!replace_old) {\n    \/* then make the last item point on this new one *\/\n    if(lastc)\n      lastc->next = co;\n    else\n      c->cookies[myhash] = co;\n    c->numcookies++; \/* one more cookie in the jar *\/\n  }\n\n  \/*\n   * Now that we've added a new cookie to the jar, update the expiration\n   * tracker in case it is the next one to expire.\n   *\/\n  if(co->expires && (co->expires < c->next_expiration))\n    c->next_expiration = co->expires;\n\n  return co;\n}","target":0,"code_token_length":5523,"total_token_length":5759,"max_tokens_setting":6144}
+{"idx":211785,"func":"static jpc_enc_cp_t *cp_create(const char *optstr, jas_image_t *image)\n{\n\tjpc_enc_cp_t *cp;\n\tjas_tvparser_t *tvp;\n\tint ret;\n\tint numilyrrates;\n\tdouble *ilyrrates;\n\tint i;\n\tint tagid;\n\tjpc_enc_tcp_t *tcp;\n\tjpc_enc_tccp_t *tccp;\n\tjpc_enc_ccp_t *ccp;\n\tuint_fast16_t rlvlno;\n\tuint_fast16_t prcwidthexpn;\n\tuint_fast16_t prcheightexpn;\n\tbool enablemct;\n\tuint_fast32_t jp2overhead;\n\tuint_fast16_t lyrno;\n\tuint_fast32_t hsteplcm;\n\tuint_fast32_t vsteplcm;\n\tbool mctvalid;\n\n\ttvp = 0;\n\tcp = 0;\n\tilyrrates = 0;\n\tnumilyrrates = 0;\n\n\tif (!(cp = jas_malloc(sizeof(jpc_enc_cp_t)))) {\n\t\tgoto error;\n\t}\n\n\tprcwidthexpn = 15;\n\tprcheightexpn = 15;\n\tenablemct = true;\n\tjp2overhead = 0;\n\n\tcp->ccps = 0;\n\tcp->debug = 0;\n\tcp->imgareatlx = UINT_FAST32_MAX;\n\tcp->imgareatly = UINT_FAST32_MAX;\n\tcp->refgrdwidth = 0;\n\tcp->refgrdheight = 0;\n\tcp->tilegrdoffx = UINT_FAST32_MAX;\n\tcp->tilegrdoffy = UINT_FAST32_MAX;\n\tcp->tilewidth = 0;\n\tcp->tileheight = 0;\n\tcp->numcmpts = jas_image_numcmpts(image);\n\n\thsteplcm = 1;\n\tvsteplcm = 1;\n\tfor (unsigned cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) {\n\t\tif (jas_image_cmptbrx(image, cmptno) + jas_image_cmpthstep(image, cmptno) <=\n\t\t  jas_image_brx(image) || jas_image_cmptbry(image, cmptno) +\n\t\t  jas_image_cmptvstep(image, cmptno) <= jas_image_bry(image)) {\n\t\t\tjas_eprintf(\"unsupported image type\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\t\/* Note: We ought to be calculating the LCMs here.  Fix some day. *\/\n\t\thsteplcm *= jas_image_cmpthstep(image, cmptno);\n\t\tvsteplcm *= jas_image_cmptvstep(image, cmptno);\n\t}\n\n\tif (!(cp->ccps = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_ccp_t)))) {\n\t\tgoto error;\n\t}\n\tunsigned cmptno;\n\tfor (cmptno = 0, ccp = cp->ccps; cmptno < cp->numcmpts; ++cmptno,\n\t  ++ccp) {\n\t\tccp->sampgrdstepx = jas_image_cmpthstep(image, cmptno);\n\t\tccp->sampgrdstepy = jas_image_cmptvstep(image, cmptno);\n\t\t\/* XXX - this isn't quite correct for more general image *\/\n\t\tccp->sampgrdsubstepx = 0;\n\t\tccp->sampgrdsubstepx = 0;\n\t\tccp->prec = jas_image_cmptprec(image, cmptno);\n\t\tccp->sgnd = jas_image_cmptsgnd(image, cmptno);\n\t\tccp->numstepsizes = 0;\n\t\tmemset(ccp->stepsizes, 0, sizeof(ccp->stepsizes));\n\t}\n\n\tcp->rawsize = jas_image_rawsize(image);\n\tif (cp->rawsize == 0) {\n\t\t\/* prevent division by zero in cp_create() *\/\n\t\tgoto error;\n\t}\n\tcp->totalsize = UINT_FAST32_MAX;\n\n\ttcp = &cp->tcp;\n\ttcp->csty = 0;\n\ttcp->intmode = true;\n\ttcp->prg = JPC_COD_LRCPPRG;\n\ttcp->numlyrs = 1;\n\ttcp->ilyrrates = 0;\n\n\ttccp = &cp->tccp;\n\ttccp->csty = 0;\n\ttccp->maxrlvls = 6;\n\ttccp->cblkwidthexpn = 6;\n\ttccp->cblkheightexpn = 6;\n\ttccp->cblksty = 0;\n\ttccp->numgbits = 2;\n\n\tif (!(tvp = jas_tvparser_create(optstr ? optstr : \"\"))) {\n\t\tgoto error;\n\t}\n\n\twhile (!(ret = jas_tvparser_next(tvp))) {\n\t\tswitch (jas_taginfo_nonull(jas_taginfos_lookup(encopts,\n\t\t  jas_tvparser_gettag(tvp)))->id) {\n\t\tcase OPT_DEBUG:\n\t\t\tcp->debug = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_IMGAREAOFFX:\n\t\t\tcp->imgareatlx = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_IMGAREAOFFY:\n\t\t\tcp->imgareatly = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_TILEGRDOFFX:\n\t\t\tcp->tilegrdoffx = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_TILEGRDOFFY:\n\t\t\tcp->tilegrdoffy = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_TILEWIDTH:\n\t\t\tcp->tilewidth = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_TILEHEIGHT:\n\t\t\tcp->tileheight = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_PRCWIDTH:\n\t\t\tprcwidthexpn = jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));\n\t\t\tbreak;\n\t\tcase OPT_PRCHEIGHT:\n\t\t\tprcheightexpn = jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));\n\t\t\tbreak;\n\t\tcase OPT_CBLKWIDTH:\n\t\t\ttccp->cblkwidthexpn =\n\t\t\t  jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));\n\t\t\tbreak;\n\t\tcase OPT_CBLKHEIGHT:\n\t\t\ttccp->cblkheightexpn =\n\t\t\t  jpc_floorlog2(atoi(jas_tvparser_getval(tvp)));\n\t\t\tbreak;\n\t\tcase OPT_MODE:\n\t\t\tif ((tagid = jas_taginfo_nonull(jas_taginfos_lookup(modetab,\n\t\t\t  jas_tvparser_getval(tvp)))->id) < 0) {\n\t\t\t\tjas_eprintf(\"ignoring invalid mode %s\\n\",\n\t\t\t\t  jas_tvparser_getval(tvp));\n\t\t\t} else {\n\t\t\t\ttcp->intmode = (tagid == MODE_INT);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase OPT_PRG:\n\t\t\tif ((tagid = jas_taginfo_nonull(jas_taginfos_lookup(prgordtab,\n\t\t\t  jas_tvparser_getval(tvp)))->id) < 0) {\n\t\t\t\tjas_eprintf(\"ignoring invalid progression order %s\\n\",\n\t\t\t\t  jas_tvparser_getval(tvp));\n\t\t\t} else {\n\t\t\t\ttcp->prg = tagid;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase OPT_NOMCT:\n\t\t\tenablemct = false;\n\t\t\tbreak;\n\t\tcase OPT_MAXRLVLS:\n\t\t\ttccp->maxrlvls = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_SOP:\n\t\t\tcp->tcp.csty |= JPC_COD_SOP;\n\t\t\tbreak;\n\t\tcase OPT_EPH:\n\t\t\tcp->tcp.csty |= JPC_COD_EPH;\n\t\t\tbreak;\n\t\tcase OPT_LAZY:\n\t\t\ttccp->cblksty |= JPC_COX_LAZY;\n\t\t\tbreak;\n\t\tcase OPT_TERMALL:\n\t\t\ttccp->cblksty |= JPC_COX_TERMALL;\n\t\t\tbreak;\n\t\tcase OPT_SEGSYM:\n\t\t\ttccp->cblksty |= JPC_COX_SEGSYM;\n\t\t\tbreak;\n\t\tcase OPT_VCAUSAL:\n\t\t\ttccp->cblksty |= JPC_COX_VSC;\n\t\t\tbreak;\n\t\tcase OPT_RESET:\n\t\t\ttccp->cblksty |= JPC_COX_RESET;\n\t\t\tbreak;\n\t\tcase OPT_PTERM:\n\t\t\ttccp->cblksty |= JPC_COX_PTERM;\n\t\t\tbreak;\n\t\tcase OPT_NUMGBITS:\n\t\t\tcp->tccp.numgbits = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tcase OPT_RATE:\n\t\t\tif (ratestrtosize(jas_tvparser_getval(tvp), cp->rawsize,\n\t\t\t  &cp->totalsize)) {\n\t\t\t\tjas_eprintf(\"ignoring bad rate specifier %s\\n\",\n\t\t\t\t  jas_tvparser_getval(tvp));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase OPT_ILYRRATES:\n\t\t\tif (jpc_atoaf(jas_tvparser_getval(tvp), &numilyrrates,\n\t\t\t  &ilyrrates)) {\n\t\t\t\tjas_eprintf(\"warning: invalid intermediate layer rates specifier ignored (%s)\\n\",\n\t\t\t\t  jas_tvparser_getval(tvp));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase OPT_JP2OVERHEAD:\n\t\t\tjp2overhead = atoi(jas_tvparser_getval(tvp));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tjas_eprintf(\"warning: ignoring invalid option %s\\n\",\n\t\t\t jas_tvparser_gettag(tvp));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tjas_tvparser_destroy(tvp);\n\ttvp = 0;\n\n\tif (cp->totalsize != UINT_FAST32_MAX) {\n\t\tcp->totalsize = (cp->totalsize > jp2overhead) ?\n\t\t  (cp->totalsize - jp2overhead) : 0;\n\t}\n\n\tif (cp->imgareatlx == UINT_FAST32_MAX) {\n\t\tcp->imgareatlx = 0;\n\t} else {\n\t\tif (hsteplcm != 1) {\n\t\t\tjas_eprintf(\"warning: overriding imgareatlx value\\n\");\n\t\t}\n\t\tcp->imgareatlx *= hsteplcm;\n\t}\n\tif (cp->imgareatly == UINT_FAST32_MAX) {\n\t\tcp->imgareatly = 0;\n\t} else {\n\t\tif (vsteplcm != 1) {\n\t\t\tjas_eprintf(\"warning: overriding imgareatly value\\n\");\n\t\t}\n\t\tcp->imgareatly *= vsteplcm;\n\t}\n\tcp->refgrdwidth = cp->imgareatlx + jas_image_width(image);\n\tcp->refgrdheight = cp->imgareatly + jas_image_height(image);\n\tif (cp->tilegrdoffx == UINT_FAST32_MAX) {\n\t\tcp->tilegrdoffx = cp->imgareatlx;\n\t}\n\tif (cp->tilegrdoffy == UINT_FAST32_MAX) {\n\t\tcp->tilegrdoffy = cp->imgareatly;\n\t}\n\tif (!cp->tilewidth) {\n\t\tcp->tilewidth = cp->refgrdwidth - cp->tilegrdoffx;\n\t}\n\tif (!cp->tileheight) {\n\t\tcp->tileheight = cp->refgrdheight - cp->tilegrdoffy;\n\t}\n\n\tif (cp->numcmpts == 3) {\n\t\tmctvalid = true;\n\t\tfor (cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) {\n\t\t\tif (jas_image_cmptprec(image, cmptno) != jas_image_cmptprec(image, 0) ||\n\t\t\t  jas_image_cmptsgnd(image, cmptno) != jas_image_cmptsgnd(image, 0) ||\n\t\t\t  jas_image_cmptwidth(image, cmptno) != jas_image_cmptwidth(image, 0) ||\n\t\t\t  jas_image_cmptheight(image, cmptno) != jas_image_cmptheight(image, 0)) {\n\t\t\t\tmctvalid = false;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tmctvalid = false;\n\t}\n\tif (mctvalid && enablemct && jas_clrspc_fam(jas_image_clrspc(image)) != JAS_CLRSPC_FAM_RGB) {\n\t\tjas_eprintf(\"warning: color space apparently not RGB\\n\");\n\t}\n\tif (mctvalid && enablemct && jas_clrspc_fam(jas_image_clrspc(image)) == JAS_CLRSPC_FAM_RGB) {\n\t\ttcp->mctid = (tcp->intmode) ? (JPC_MCT_RCT) : (JPC_MCT_ICT);\n\t} else {\n\t\ttcp->mctid = JPC_MCT_NONE;\n\t}\n\ttccp->qmfbid = (tcp->intmode) ? (JPC_COX_RFT) : (JPC_COX_INS);\n\n\tfor (rlvlno = 0; rlvlno < tccp->maxrlvls; ++rlvlno) {\n\t\ttccp->prcwidthexpns[rlvlno] = prcwidthexpn;\n\t\ttccp->prcheightexpns[rlvlno] = prcheightexpn;\n\t}\n\tif (prcwidthexpn != 15 || prcheightexpn != 15) {\n\t\ttccp->csty |= JPC_COX_PRT;\n\t}\n\n\t\/* Ensure that the tile width and height is valid. *\/\n\tif (!cp->tilewidth) {\n\t\tjas_eprintf(\"invalid tile width %lu\\n\", (unsigned long)\n\t\t  cp->tilewidth);\n\t\tgoto error;\n\t}\n\tif (!cp->tileheight) {\n\t\tjas_eprintf(\"invalid tile height %lu\\n\", (unsigned long)\n\t\t  cp->tileheight);\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the tile grid offset is valid. *\/\n\tif (cp->tilegrdoffx > cp->imgareatlx ||\n\t  cp->tilegrdoffy > cp->imgareatly ||\n\t  cp->tilegrdoffx + cp->tilewidth < cp->imgareatlx ||\n\t  cp->tilegrdoffy + cp->tileheight < cp->imgareatly) {\n\t\tjas_eprintf(\"invalid tile grid offset (%lu, %lu)\\n\",\n\t\t  (unsigned long) cp->tilegrdoffx, (unsigned long)\n\t\t  cp->tilegrdoffy);\n\t\tgoto error;\n\t}\n\n\tcp->numhtiles = JPC_CEILDIV(cp->refgrdwidth - cp->tilegrdoffx,\n\t  cp->tilewidth);\n\tcp->numvtiles = JPC_CEILDIV(cp->refgrdheight - cp->tilegrdoffy,\n\t  cp->tileheight);\n\tcp->numtiles = cp->numhtiles * cp->numvtiles;\n\n\tif (ilyrrates && numilyrrates > 0) {\n\t\ttcp->numlyrs = numilyrrates + 1;\n\t\tif (!(tcp->ilyrrates = jas_alloc2((tcp->numlyrs - 1),\n\t\t  sizeof(jpc_fix_t)))) {\n\t\t\tgoto error;\n\t\t}\n\t\tfor (i = 0; i < JAS_CAST(int, tcp->numlyrs - 1); ++i) {\n\t\t\ttcp->ilyrrates[i] = jpc_dbltofix(ilyrrates[i]);\n\t\t}\n\t}\n\n\t\/* Ensure that the integer mode is used in the case of lossless\n\t  coding. *\/\n\tif (cp->totalsize == UINT_FAST32_MAX && (!cp->tcp.intmode)) {\n\t\tjas_eprintf(\"cannot use real mode for lossless coding\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the precinct width is valid. *\/\n\tif (prcwidthexpn > 15) {\n\t\tjas_eprintf(\"invalid precinct width\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the precinct height is valid. *\/\n\tif (prcheightexpn > 15) {\n\t\tjas_eprintf(\"invalid precinct height\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the code block width is valid. *\/\n\tif (cp->tccp.cblkwidthexpn < 2 || cp->tccp.cblkwidthexpn > 12) {\n\t\tjas_eprintf(\"invalid code block width %d\\n\",\n\t\t  JPC_POW2(cp->tccp.cblkwidthexpn));\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the code block height is valid. *\/\n\tif (cp->tccp.cblkheightexpn < 2 || cp->tccp.cblkheightexpn > 12) {\n\t\tjas_eprintf(\"invalid code block height %d\\n\",\n\t\t  JPC_POW2(cp->tccp.cblkheightexpn));\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the code block size is not too large. *\/\n\tif (cp->tccp.cblkwidthexpn + cp->tccp.cblkheightexpn > 12) {\n\t\tjas_eprintf(\"code block size too large\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the number of layers is valid. *\/\n\tif (cp->tcp.numlyrs > 16384) {\n\t\tjas_eprintf(\"too many layers\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* There must be at least one resolution level. *\/\n\tif (cp->tccp.maxrlvls < 1) {\n\t\tjas_eprintf(\"must be at least one resolution level\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the number of guard bits is valid. *\/\n\tif (cp->tccp.numgbits > 8) {\n\t\tjas_eprintf(\"invalid number of guard bits\\n\");\n\t\tgoto error;\n\t}\n\n\t\/* Ensure that the rate is within the legal range. *\/\n\tif (cp->totalsize != UINT_FAST32_MAX && cp->totalsize > cp->rawsize) {\n\t\tjas_eprintf(\"warning: specified rate is unreasonably large (%lu > %lu)\\n\", (unsigned long) cp->totalsize, (unsigned long) cp->rawsize);\n\t}\n\n\t\/* Ensure that the intermediate layer rates are valid. *\/\n\tif (tcp->numlyrs > 1) {\n\t\t\/* The intermediate layers rates must increase monotonically. *\/\n\t\tfor (lyrno = 0; lyrno + 2 < tcp->numlyrs; ++lyrno) {\n\t\t\tif (tcp->ilyrrates[lyrno] >= tcp->ilyrrates[lyrno + 1]) {\n\t\t\t\tjas_eprintf(\"intermediate layer rates must increase monotonically\\n\");\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t\t\/* The intermediate layer rates must be less than the overall rate. *\/\n\t\tif (cp->totalsize != UINT_FAST32_MAX) {\n\t\t\tfor (lyrno = 0; lyrno < tcp->numlyrs - 1; ++lyrno) {\n\t\t\t\tif (jpc_fixtodbl(tcp->ilyrrates[lyrno]) > ((double) cp->totalsize)\n\t\t\t\t  \/ cp->rawsize) {\n\t\t\t\t\tjas_eprintf(\"warning: intermediate layer rates must be less than overall rate\\n\");\n\t\t\t\t\tgoto error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (ilyrrates) {\n\t\tjas_free(ilyrrates);\n\t}\n\n\treturn cp;\n\nerror:\n\n\tif (ilyrrates) {\n\t\tjas_free(ilyrrates);\n\t}\n\tif (tvp) {\n\t\tjas_tvparser_destroy(tvp);\n\t}\n\tif (cp) {\n\t\tjpc_enc_cp_destroy(cp);\n\t}\n\treturn 0;\n}","target":1,"code_token_length":4270,"total_token_length":4506,"max_tokens_setting":6144}
+{"idx":270358,"func":"parser_parse_for_statement_start (parser_context_t *context_p) \/**< context *\/\n{\n  parser_loop_statement_t loop;\n\n  JERRY_ASSERT (context_p->token.type == LEXER_KEYW_FOR);\n  lexer_next_token (context_p);\n\n#if JERRY_ESNEXT\n  bool is_for_await = false;\n\n  if (context_p->token.type == LEXER_KEYW_AWAIT)\n  {\n    if (JERRY_UNLIKELY (context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))\n    {\n      parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);\n    }\n    lexer_next_token (context_p);\n    is_for_await = true;\n  }\n#endif \/* JERRY_ESNEXT *\/\n\n  if (context_p->token.type != LEXER_LEFT_PAREN)\n  {\n#if JERRY_ESNEXT\n    if (context_p->token.type == LEXER_LITERAL\n        && context_p->token.keyword_type == LEXER_KEYW_AWAIT\n        && !(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))\n    {\n      parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_ASYNC);\n    }\n#endif \/* JERRY_ESNEXT *\/\n    parser_raise_error (context_p, PARSER_ERR_LEFT_PAREN_EXPECTED);\n  }\n\n  if (context_p->next_scanner_info_p->source_p == context_p->source_p)\n  {\n    parser_for_in_of_statement_t for_in_of_statement;\n    scanner_location_t start_location, end_location;\n\n#if JERRY_ESNEXT\n    JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN\n                  || context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_OF);\n\n    bool is_for_in = (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);\n    end_location = ((scanner_location_info_t *) context_p->next_scanner_info_p)->location;\n\n    scanner_release_next (context_p, sizeof (scanner_location_info_t));\n\n    scanner_get_location (&start_location, context_p);\n    lexer_next_token (context_p);\n\n    uint8_t token_type = LEXER_EOS;\n    bool has_context = false;\n\n    if (context_p->token.type == LEXER_KEYW_VAR\n        || context_p->token.type == LEXER_KEYW_LET\n        || context_p->token.type == LEXER_KEYW_CONST)\n    {\n      token_type = context_p->token.type;\n      has_context = context_p->next_scanner_info_p->source_p == context_p->source_p;\n      JERRY_ASSERT (!has_context || context_p->next_scanner_info_p->type == SCANNER_TYPE_BLOCK);\n      scanner_get_location (&start_location, context_p);\n\n      \/* TODO: remove this after the pre-scanner supports strict mode detection. *\/\n      if (context_p->next_scanner_info_p->source_p == context_p->source_p\n          && context_p->next_scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION)\n      {\n        scanner_release_next (context_p, sizeof (scanner_info_t));\n      }\n    }\n    else if (context_p->token.type == LEXER_LITERAL && lexer_token_is_let (context_p))\n    {\n      if (context_p->next_scanner_info_p->source_p == context_p->source_p\n          && context_p->next_scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION)\n      {\n        scanner_release_next (context_p, sizeof (scanner_info_t));\n      }\n      else\n      {\n        token_type = LEXER_KEYW_LET;\n        has_context = (context_p->next_scanner_info_p->source_p == context_p->source_p);\n        scanner_get_location (&start_location, context_p);\n      }\n    }\n\n    if (has_context)\n    {\n      has_context = parser_push_block_context (context_p, true);\n    }\n\n    scanner_set_location (context_p, &end_location);\n#else \/* !JERRY_ESNEXT *\/\n    JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR_IN);\n\n    bool is_for_in = true;\n    scanner_get_location (&start_location, context_p);\n\n    scanner_set_location (context_p, &((scanner_location_info_t *) context_p->next_scanner_info_p)->location);\n    scanner_release_next (context_p, sizeof (scanner_location_info_t));\n#endif \/* JERRY_ESNEXT *\/\n\n    \/* The length of both 'in' and 'of' is two. *\/\n    const uint8_t *source_end_p = context_p->source_p - 2;\n\n    scanner_seek (context_p);\n\n#if JERRY_ESNEXT\n    if (is_for_in && is_for_await)\n    {\n      context_p->token.line = context_p->line;\n      context_p->token.column = context_p->column - 2;\n      parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_OF);\n    }\n#endif \/* JERRY_ESNEXT *\/\n\n    lexer_next_token (context_p);\n    int options = is_for_in ? PARSE_EXPR : PARSE_EXPR_LEFT_HAND_SIDE;\n    parser_parse_expression (context_p, options);\n\n    if (context_p->token.type != LEXER_RIGHT_PAREN)\n    {\n      parser_raise_error (context_p, PARSER_ERR_RIGHT_PAREN_EXPECTED);\n    }\n\n#ifndef JERRY_NDEBUG\n    PARSER_PLUS_EQUAL_U16 (context_p->context_stack_depth,\n                           is_for_in ? PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION\n                                     : PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION);\n#endif \/* !JERRY_NDEBUG *\/\n\n    cbc_ext_opcode_t init_opcode = CBC_EXT_FOR_IN_INIT;\n\n#if JERRY_ESNEXT\n    if (!is_for_in)\n    {\n      init_opcode = is_for_await ? CBC_EXT_FOR_AWAIT_OF_INIT : CBC_EXT_FOR_OF_INIT;\n    }\n#endif \/* JERRY_ESNEXT *\/\n\n    parser_emit_cbc_ext_forward_branch (context_p, init_opcode, &for_in_of_statement.branch);\n\n    JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);\n    for_in_of_statement.start_offset = context_p->byte_code_size;\n\n#if JERRY_ESNEXT\n    if (has_context)\n    {\n      parser_emit_cbc_ext (context_p, CBC_EXT_CLONE_CONTEXT);\n    }\n#endif \/* JERRY_ESNEXT *\/\n\n    \/* The expression parser must not read the 'in' or 'of' tokens. *\/\n    scanner_get_location (&end_location, context_p);\n    scanner_set_location (context_p, &start_location);\n\n    const uint8_t *original_source_end_p = context_p->source_end_p;\n    context_p->source_end_p = source_end_p;\n    scanner_seek (context_p);\n\n#if JERRY_ESNEXT\n    if (token_type == LEXER_EOS)\n    {\n      lexer_next_token (context_p);\n\n      if (context_p->token.type == LEXER_LEFT_SQUARE || context_p->token.type == LEXER_LEFT_BRACE)\n      {\n        token_type = context_p->token.type;\n      }\n    }\n#else \/* !JERRY_ESNEXT *\/\n    lexer_next_token (context_p);\n\n    uint8_t token_type = context_p->token.type;\n#endif \/* JERRY_ESNEXT *\/\n\n    switch (token_type)\n    {\n#if JERRY_ESNEXT\n      case LEXER_KEYW_LET:\n      case LEXER_KEYW_CONST:\n#endif \/* JERRY_ESNEXT *\/\n      case LEXER_KEYW_VAR:\n      {\n#if JERRY_ESNEXT\n        if (lexer_check_next_characters (context_p, LIT_CHAR_LEFT_SQUARE, LIT_CHAR_LEFT_BRACE))\n        {\n          parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT\n                                                    : CBC_EXT_FOR_OF_GET_NEXT);\n\n          parser_pattern_flags_t flags = (PARSER_PATTERN_BINDING | PARSER_PATTERN_TARGET_ON_STACK);\n\n          if (context_p->next_scanner_info_p->source_p == (context_p->source_p + 1))\n          {\n            if (context_p->next_scanner_info_p->type == SCANNER_TYPE_INITIALIZER)\n            {\n              scanner_release_next (context_p, sizeof (scanner_location_info_t));\n            }\n            else\n            {\n              JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS);\n              if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)\n              {\n                flags |= PARSER_PATTERN_HAS_REST_ELEMENT;\n              }\n\n              scanner_release_next (context_p, sizeof (scanner_info_t));\n            }\n          }\n\n          if (token_type == LEXER_KEYW_LET)\n          {\n            flags |= PARSER_PATTERN_LET;\n          }\n          else if (token_type == LEXER_KEYW_CONST)\n          {\n            flags |= PARSER_PATTERN_CONST;\n          }\n\n          parser_parse_initializer_by_next_char (context_p, flags);\n          break;\n        }\n#endif \/* JERRY_ESNEXT *\/\n\n        lexer_expect_identifier (context_p, LEXER_IDENT_LITERAL);\n\n#if JERRY_ESNEXT\n        if (context_p->token.keyword_type == LEXER_KEYW_LET\n            && token_type != LEXER_KEYW_VAR)\n        {\n          parser_raise_error (context_p, PARSER_ERR_LEXICAL_LET_BINDING);\n        }\n#endif \/* JERRY_ESNEXT *\/\n\n        JERRY_ASSERT (context_p->token.type == LEXER_LITERAL\n                      && context_p->token.lit_location.type == LEXER_IDENT_LITERAL);\n\n        uint16_t literal_index = context_p->lit_object.index;\n        lexer_next_token (context_p);\n\n        if (context_p->token.type == LEXER_ASSIGN)\n        {\n#if JERRY_ESNEXT\n          if ((context_p->status_flags & PARSER_IS_STRICT) || !is_for_in)\n          {\n            parser_raise_error (context_p, PARSER_ERR_FOR_IN_OF_DECLARATION);\n          }\n#endif \/* JERRY_ESNEXT *\/\n          parser_branch_t branch;\n\n          \/* Initialiser is never executed. *\/\n          parser_emit_cbc_forward_branch (context_p, CBC_JUMP_FORWARD, &branch);\n          lexer_next_token (context_p);\n          parser_parse_expression_statement (context_p, PARSE_EXPR_NO_COMMA);\n          parser_set_branch_to_current_position (context_p, &branch);\n        }\n\n        parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT\n                                                  : CBC_EXT_FOR_OF_GET_NEXT);\n#if JERRY_ESNEXT\n#ifndef JERRY_NDEBUG\n        if (literal_index < PARSER_REGISTER_START\n            && has_context\n            && !scanner_literal_is_created (context_p, literal_index))\n        {\n          context_p->global_status_flags |= ECMA_PARSE_INTERNAL_FOR_IN_OFF_CONTEXT_ERROR;\n        }\n#endif \/* !JERRY_NDEBUG *\/\n\n        uint16_t opcode = (has_context ? CBC_ASSIGN_LET_CONST : CBC_ASSIGN_SET_IDENT);\n        parser_emit_cbc_literal (context_p, opcode, literal_index);\n#else \/* !JERRY_ESNEXT *\/\n        parser_emit_cbc_literal (context_p, CBC_ASSIGN_SET_IDENT, literal_index);\n#endif \/* JERRY_ESNEXT *\/\n        break;\n      }\n#if JERRY_ESNEXT\n      case LEXER_LEFT_BRACE:\n      case LEXER_LEFT_SQUARE:\n      {\n        if (context_p->next_scanner_info_p->source_p == context_p->source_p\n            && context_p->next_scanner_info_p->type == SCANNER_TYPE_LITERAL_FLAGS\n            && (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_DESTRUCTURING_FOR))\n        {\n          parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT\n                                                    : CBC_EXT_FOR_OF_GET_NEXT);\n\n          uint32_t flags = PARSER_PATTERN_TARGET_ON_STACK;\n\n          if (context_p->next_scanner_info_p->u8_arg & SCANNER_LITERAL_OBJECT_HAS_REST)\n          {\n            flags |= PARSER_PATTERN_HAS_REST_ELEMENT;\n          }\n\n          scanner_release_next (context_p, sizeof (scanner_info_t));\n          parser_parse_initializer (context_p, flags);\n          \/* Pop the value returned by GET_NEXT. *\/\n          parser_emit_cbc (context_p, CBC_POP);\n          break;\n        }\n        \/* FALLTHRU *\/\n      }\n#endif \/* JERRY_ESNEXT *\/\n      default:\n      {\n        uint16_t opcode;\n\n        parser_parse_expression (context_p, PARSE_EXPR_LEFT_HAND_SIDE);\n\n        opcode = context_p->last_cbc_opcode;\n\n        \/* The CBC_EXT_FOR_IN_CREATE_CONTEXT flushed the opcode combiner. *\/\n        JERRY_ASSERT (opcode != CBC_PUSH_TWO_LITERALS\n                      && opcode != CBC_PUSH_THREE_LITERALS);\n\n        opcode = parser_check_left_hand_side_expression (context_p, opcode);\n\n        parser_emit_cbc_ext (context_p, is_for_in ? CBC_EXT_FOR_IN_GET_NEXT\n                                                  : CBC_EXT_FOR_OF_GET_NEXT);\n        parser_flush_cbc (context_p);\n\n        context_p->last_cbc_opcode = opcode;\n        break;\n      }\n    }\n\n    if (context_p->token.type != LEXER_EOS)\n    {\n#if JERRY_ESNEXT\n      parser_raise_error (context_p, is_for_in ? PARSER_ERR_IN_EXPECTED : PARSER_ERR_OF_EXPECTED);\n#else \/* !JERRY_ESNEXT *\/\n      parser_raise_error (context_p, PARSER_ERR_IN_EXPECTED);\n#endif \/* JERRY_ESNEXT *\/\n    }\n\n    parser_flush_cbc (context_p);\n    scanner_set_location (context_p, &end_location);\n    context_p->source_end_p = original_source_end_p;\n    lexer_next_token (context_p);\n\n    loop.branch_list_p = NULL;\n\n    parser_stack_push (context_p, &for_in_of_statement, sizeof (parser_for_in_of_statement_t));\n    parser_stack_push (context_p, &loop, sizeof (parser_loop_statement_t));\n\n    uint8_t for_type = PARSER_STATEMENT_FOR_IN;\n\n#if JERRY_ESNEXT\n    if (!is_for_in)\n    {\n      for_type = is_for_await ? PARSER_STATEMENT_FOR_AWAIT_OF : PARSER_STATEMENT_FOR_OF;\n    }\n#endif \/* JERRY_ESNEXT *\/\n\n    parser_stack_push_uint8 (context_p, for_type);\n    parser_stack_iterator_init (context_p, &context_p->last_statement);\n    return;\n  }\n\n  lexer_next_token (context_p);\n\n  if (context_p->token.type != LEXER_SEMICOLON)\n  {\n#if JERRY_ESNEXT\n    const uint8_t *source_p = context_p->source_p;\n#endif \/* JERRY_ESNEXT *\/\n\n    switch (context_p->token.type)\n    {\n#if JERRY_ESNEXT\n      case LEXER_LITERAL:\n      {\n        if (!lexer_token_is_let (context_p))\n        {\n          parser_parse_expression_statement (context_p, PARSE_EXPR);\n          break;\n        }\n\n        \/* FALLTHRU *\/\n      }\n      case LEXER_KEYW_LET:\n      {\n        if (context_p->next_scanner_info_p->source_p == context_p->source_p\n            && context_p->next_scanner_info_p->type != SCANNER_TYPE_BLOCK)\n        {\n          if (context_p->next_scanner_info_p->type == SCANNER_TYPE_LET_EXPRESSION)\n          {\n            scanner_release_next (context_p, sizeof (scanner_info_t));\n          }\n\n          parser_parse_expression_statement (context_p, PARSE_EXPR);\n          break;\n        }\n\n        context_p->token.type = LEXER_KEYW_LET;\n\n        \/* FALLTHRU *\/\n      }\n      case LEXER_KEYW_CONST:\n      {\n        if (context_p->next_scanner_info_p->source_p == source_p)\n        {\n          parser_push_block_context (context_p, true);\n        }\n        \/* FALLTHRU *\/\n      }\n#endif \/* JERRY_ESNEXT *\/\n      case LEXER_KEYW_VAR:\n      {\n        parser_parse_var_statement (context_p);\n        break;\n      }\n      default:\n      {\n        parser_parse_expression_statement (context_p, PARSE_EXPR);\n        break;\n      }\n    }\n\n    if (context_p->token.type != LEXER_SEMICOLON)\n    {\n      parser_raise_error (context_p, PARSER_ERR_SEMICOLON_EXPECTED);\n    }\n  }\n\n#if JERRY_ESNEXT\n  if (is_for_await)\n  {\n    parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_OF);\n  }\n#endif \/* JERRY_ESNEXT *\/\n\n  JERRY_ASSERT (context_p->next_scanner_info_p->source_p != context_p->source_p\n                || context_p->next_scanner_info_p->type == SCANNER_TYPE_FOR);\n\n  if (context_p->next_scanner_info_p->source_p != context_p->source_p\n      || ((scanner_for_info_t *) context_p->next_scanner_info_p)->end_location.source_p == NULL)\n  {\n    if (context_p->next_scanner_info_p->source_p == context_p->source_p)\n    {\n      \/* Even though the scanning is failed, there might be valid statements\n       * inside the for statement which depend on scanner info blocks. *\/\n      scanner_release_next (context_p, sizeof (scanner_for_info_t));\n    }\n\n    \/* The prescanner couldn't find the second semicolon or the closing paranthesis. *\/\n    lexer_next_token (context_p);\n    parser_parse_expression (context_p, PARSE_EXPR);\n\n    if (context_p->token.type != LEXER_SEMICOLON)\n    {\n      parser_raise_error (context_p, PARSER_ERR_SEMICOLON_EXPECTED);\n    }\n\n    lexer_next_token (context_p);\n    parser_parse_expression_statement (context_p, PARSE_EXPR);\n\n    JERRY_ASSERT (context_p->token.type != LEXER_RIGHT_PAREN);\n    parser_raise_error (context_p, PARSER_ERR_RIGHT_PAREN_EXPECTED);\n  }\n\n  parser_for_statement_t for_statement;\n  scanner_for_info_t *for_info_p = (scanner_for_info_t *) context_p->next_scanner_info_p;\n\n  parser_emit_cbc_forward_branch (context_p, CBC_JUMP_FORWARD, &for_statement.branch);\n\n  JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);\n\n  for_statement.start_offset = context_p->byte_code_size;\n  scanner_get_location (&for_statement.condition_location, context_p);\n  for_statement.expression_location = for_info_p->expression_location;\n\n  scanner_set_location (context_p, &for_info_p->end_location);\n  scanner_release_next (context_p, sizeof (scanner_for_info_t));\n  scanner_seek (context_p);\n  lexer_next_token (context_p);\n\n  loop.branch_list_p = NULL;\n\n  parser_stack_push (context_p, &for_statement, sizeof (parser_for_statement_t));\n  parser_stack_push (context_p, &loop, sizeof (parser_loop_statement_t));\n  parser_stack_push_uint8 (context_p, PARSER_STATEMENT_FOR);\n  parser_stack_iterator_init (context_p, &context_p->last_statement);\n} \/* parser_parse_for_statement_start *\/","target":0,"code_token_length":3979,"total_token_length":4215,"max_tokens_setting":6144}
+{"idx":223417,"func":"static PCRE2_SPTR compile_simple_assertion_matchingpath(compiler_common *common, PCRE2_UCHAR type, PCRE2_SPTR cc, jump_list **backtracks)\n{\nDEFINE_COMPILER;\nint length;\nstruct sljit_jump *jump[4];\n#ifdef SUPPORT_UNICODE\nstruct sljit_label *label;\n#endif \/* SUPPORT_UNICODE *\/\n\nswitch(type)\n  {\n  case OP_SOD:\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));\n    }\n  else\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin));\n  add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, TMP1, 0));\n  return cc;\n\n  case OP_SOM:\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));\n    }\n  else\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, str));\n  add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, TMP1, 0));\n  return cc;\n\n  case OP_NOT_WORD_BOUNDARY:\n  case OP_WORD_BOUNDARY:\n  add_jump(compiler, &common->wordboundary, JUMP(SLJIT_FAST_CALL));\n#ifdef SUPPORT_UNICODE\n  if (common->invalid_utf)\n    {\n    add_jump(compiler, backtracks, CMP((type == OP_NOT_WORD_BOUNDARY) ? SLJIT_NOT_EQUAL : SLJIT_SIG_LESS_EQUAL, TMP2, 0, SLJIT_IMM, 0));\n    return cc;\n    }\n#endif \/* SUPPORT_UNICODE *\/\n  sljit_set_current_flags(compiler, SLJIT_SET_Z);\n  add_jump(compiler, backtracks, JUMP(type == OP_NOT_WORD_BOUNDARY ? SLJIT_NOT_ZERO : SLJIT_ZERO));\n  return cc;\n\n  case OP_EODN:\n  \/* Requires rather complex checks. *\/\n  jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);\n  if (common->nltype == NLTYPE_FIXED && common->newline > 255)\n    {\n    OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    if (common->mode == PCRE2_JIT_COMPLETE)\n      add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_END, 0));\n    else\n      {\n      jump[1] = CMP(SLJIT_EQUAL, TMP2, 0, STR_END, 0);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP2, 0, STR_END, 0);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_NOT_EQUAL);\n      add_jump(compiler, backtracks, JUMP(SLJIT_NOT_EQUAL));\n      check_partial(common, TRUE);\n      add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n      JUMPHERE(jump[1]);\n      }\n    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));\n    }\n  else if (common->nltype == NLTYPE_FIXED)\n    {\n    OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_END, 0));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline));\n    }\n  else\n    {\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    jump[1] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);\n    OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));\n    OP2U(SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_GREATER, TMP2, 0, STR_END, 0);\n    jump[2] = JUMP(SLJIT_GREATER);\n    add_jump(compiler, backtracks, JUMP(SLJIT_NOT_EQUAL) \/* LESS *\/);\n    \/* Equal. *\/\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));\n    jump[3] = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);\n    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n\n    JUMPHERE(jump[1]);\n    if (common->nltype == NLTYPE_ANYCRLF)\n      {\n      OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n      add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, STR_END, 0));\n      add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL));\n      }\n    else\n      {\n      OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);\n      read_char(common, common->nlmin, common->nlmax, backtracks, READ_CHAR_UPDATE_STR_PTR);\n      add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, STR_END, 0));\n      add_jump(compiler, &common->anynewline, JUMP(SLJIT_FAST_CALL));\n      sljit_set_current_flags(compiler, SLJIT_SET_Z);\n      add_jump(compiler, backtracks, JUMP(SLJIT_ZERO));\n      OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);\n      }\n    JUMPHERE(jump[2]);\n    JUMPHERE(jump[3]);\n    }\n  JUMPHERE(jump[0]);\n  if (common->mode != PCRE2_JIT_COMPLETE)\n    check_partial(common, TRUE);\n  return cc;\n\n  case OP_EOD:\n  add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0));\n  if (common->mode != PCRE2_JIT_COMPLETE)\n    check_partial(common, TRUE);\n  return cc;\n\n  case OP_DOLL:\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL);\n    }\n  else\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL);\n  add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));\n\n  if (!common->endonly)\n    compile_simple_assertion_matchingpath(common, OP_EODN, cc, backtracks);\n  else\n    {\n    add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0));\n    check_partial(common, FALSE);\n    }\n  return cc;\n\n  case OP_DOLLM:\n  jump[1] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL);\n    }\n  else\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL);\n  add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));\n  check_partial(common, FALSE);\n  jump[0] = JUMP(SLJIT_JUMP);\n  JUMPHERE(jump[1]);\n\n  if (common->nltype == NLTYPE_FIXED && common->newline > 255)\n    {\n    OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    if (common->mode == PCRE2_JIT_COMPLETE)\n      add_jump(compiler, backtracks, CMP(SLJIT_GREATER, TMP2, 0, STR_END, 0));\n    else\n      {\n      jump[1] = CMP(SLJIT_LESS_EQUAL, TMP2, 0, STR_END, 0);\n      \/* STR_PTR = STR_END - IN_UCHARS(1) *\/\n      add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));\n      check_partial(common, TRUE);\n      add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n      JUMPHERE(jump[1]);\n      }\n\n    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));\n    }\n  else\n    {\n    peek_char(common, common->nlmax, TMP3, 0, NULL);\n    check_newlinechar(common, common->nltype, backtracks, FALSE);\n    }\n  JUMPHERE(jump[0]);\n  return cc;\n\n  case OP_CIRC:\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin));\n    add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0));\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL);\n    add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));\n    }\n  else\n    {\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin));\n    add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0));\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL);\n    add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));\n    }\n  return cc;\n\n  case OP_CIRCM:\n  \/* TMP2 might be used by peek_char_back. *\/\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));\n    jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP2, 0);\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL);\n    }\n  else\n    {\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin));\n    jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP2, 0);\n    OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL);\n    }\n  add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));\n  jump[0] = JUMP(SLJIT_JUMP);\n  JUMPHERE(jump[1]);\n\n  if (!common->alt_circumflex)\n    add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n\n  if (common->nltype == NLTYPE_FIXED && common->newline > 255)\n    {\n    OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));\n    add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, TMP2, 0));\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));\n    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));\n    }\n  else\n    {\n    peek_char_back(common, common->nlmax, backtracks);\n    check_newlinechar(common, common->nltype, backtracks, FALSE);\n    }\n  JUMPHERE(jump[0]);\n  return cc;\n\n  case OP_REVERSE:\n  length = GET(cc, 0);\n  if (length == 0)\n    return cc + LINK_SIZE;\n  if (HAS_VIRTUAL_REGISTERS)\n    {\n    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));\n    }\n  else\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin));\n#ifdef SUPPORT_UNICODE\n  if (common->utf)\n    {\n    OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, length);\n    label = LABEL();\n    add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0));\n    move_back(common, backtracks, FALSE);\n    OP2(SLJIT_SUB | SLJIT_SET_Z, TMP3, 0, TMP3, 0, SLJIT_IMM, 1);\n    JUMPTO(SLJIT_NOT_ZERO, label);\n    }\n  else\n#endif\n    {\n    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length));\n    add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, TMP2, 0));\n    }\n  check_start_used_ptr(common);\n  return cc + LINK_SIZE;\n  }\nSLJIT_UNREACHABLE();\nreturn cc;\n}","target":0,"code_token_length":4003,"total_token_length":4239,"max_tokens_setting":6144}
+{"idx":195063,"func":"GF_Err mpgviddmx_process(GF_Filter *filter)\n{\n\tGF_MPGVidDmxCtx *ctx = gf_filter_get_udta(filter);\n\tGF_FilterPacket *pck, *dst_pck;\n\tu64 byte_offset;\n\ts64 vosh_start = -1;\n\ts64 vosh_end = -1;\n\tGF_Err e;\n\tchar *data;\n\tu8 *start;\n\tu32 pck_size;\n\ts32 remain;\n\n\t\/\/always reparse duration\n\tif (!ctx->duration.num)\n\t\tmpgviddmx_check_dur(filter, ctx);\n\n\tpck = gf_filter_pid_get_packet(ctx->ipid);\n\tif (!pck) {\n\t\tif (gf_filter_pid_is_eos(ctx->ipid)) {\n\t\t\tmpgviddmx_enqueue_or_dispatch(ctx, NULL, GF_TRUE, GF_TRUE);\n\t\t\tif (ctx->opid)\n\t\t\t\tgf_filter_pid_set_eos(ctx->opid);\n\t\t\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\t\t\tctx->src_pck = NULL;\n\t\t\treturn GF_EOS;\n\t\t}\n\t\treturn GF_OK;\n\t}\n\n\tdata = (char *) gf_filter_pck_get_data(pck, &pck_size);\n\tbyte_offset = gf_filter_pck_get_byte_offset(pck);\n\n\tstart = data;\n\tremain = pck_size;\n\n\t\/\/input pid sets some timescale - we flushed pending data , update cts\n\tif (!ctx->resume_from && ctx->timescale) {\n\t\tu64 ts = gf_filter_pck_get_cts(pck);\n\t\tif (ts != GF_FILTER_NO_TS) {\n\t\t\tif (!ctx->cts || !ctx->recompute_cts)\n\t\t\t\tctx->cts = ts;\n\t\t}\n\t\tts = gf_filter_pck_get_dts(pck);\n\t\tif (ts != GF_FILTER_NO_TS) {\n\t\t\tif (!ctx->dts || !ctx->recompute_cts)\n\t\t\t\tctx->dts = ts;\n\n\t\t\tif (!ctx->prev_dts) ctx->prev_dts = ts;\n\t\t\telse if (ctx->prev_dts != ts) {\n\t\t\t\tu64 diff = ts;\n\t\t\t\tdiff -= ctx->prev_dts;\n\t\t\t\tif (!ctx->cur_fps.den) ctx->cur_fps.den = (u32) diff;\n\t\t\t\telse if (ctx->cur_fps.den > diff)\n\t\t\t\t\tctx->cur_fps.den = (u32) diff;\n\t\t\t}\n\t\t}\n\t\tgf_filter_pck_get_framing(pck, &ctx->input_is_au_start, &ctx->input_is_au_end);\n\t\t\/\/this will force CTS recomput of each frame\n\t\tif (ctx->recompute_cts) ctx->input_is_au_start = GF_FALSE;\n\t\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\t\tctx->src_pck = pck;\n\t\tgf_filter_pck_ref_props(&ctx->src_pck);\n\t}\n\n\t\/\/we stored some data to find the complete vosh, aggregate this packet with current one\n\tif (!ctx->resume_from && ctx->hdr_store_size) {\n\t\tif (ctx->hdr_store_alloc < ctx->hdr_store_size + pck_size) {\n\t\t\tctx->hdr_store_alloc = ctx->hdr_store_size + pck_size;\n\t\t\tctx->hdr_store = gf_realloc(ctx->hdr_store, sizeof(char)*ctx->hdr_store_alloc);\n\t\t}\n\t\tmemcpy(ctx->hdr_store + ctx->hdr_store_size, data, sizeof(char)*pck_size);\n\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\tif (byte_offset >= ctx->hdr_store_size)\n\t\t\t\tbyte_offset -= ctx->hdr_store_size;\n\t\t\telse\n\t\t\t\tbyte_offset = GF_FILTER_NO_BO;\n\t\t}\n\t\tctx->hdr_store_size += pck_size;\n\t\tstart = data = ctx->hdr_store;\n\t\tremain = pck_size = ctx->hdr_store_size;\n\t}\n\n\tif (ctx->resume_from) {\n\t\tif (gf_filter_pid_would_block(ctx->opid))\n\t\t\treturn GF_OK;\n\n\t\t\/\/resume from data copied internally\n\t\tif (ctx->hdr_store_size) {\n\t\t\tassert(ctx->resume_from <= ctx->hdr_store_size);\n\t\t\tstart = data = ctx->hdr_store + ctx->resume_from;\n\t\t\tremain = pck_size = ctx->hdr_store_size - ctx->resume_from;\n\t\t} else {\n\t\t\tassert(remain >= (s32) ctx->resume_from);\n\t\t\tstart += ctx->resume_from;\n\t\t\tremain -= ctx->resume_from;\n\t\t}\n\t\tctx->resume_from = 0;\n\t}\n\n\tif (!ctx->bs) {\n\t\tctx->bs = gf_bs_new(start, remain, GF_BITSTREAM_READ);\n\t} else {\n\t\tgf_bs_reassign_buffer(ctx->bs, start, remain);\n\t}\n\tif (!ctx->vparser) {\n\t\tctx->vparser = gf_m4v_parser_bs_new(ctx->bs, ctx->is_mpg12);\n\t}\n\n\n\twhile (remain) {\n\t\tBool full_frame;\n\t\tu8 *pck_data;\n\t\ts32 current;\n\t\tu8 sc_type, forced_sc_type=0;\n\t\tBool sc_type_forced = GF_FALSE;\n\t\tBool skip_pck = GF_FALSE;\n\t\tu8 ftype;\n\t\tu32 tinc;\n\t\tu64 size=0;\n\t\tu64 fstart;\n\t\tBool is_coded;\n\t\tu32 bytes_from_store = 0;\n\t\tu32 hdr_offset = 0;\n\t\tBool copy_last_bytes = GF_FALSE;\n\n\t\t\/\/not enough bytes to parse start code\n\t\tif (remain<5) {\n\t\t\tmemcpy(ctx->hdr_store, start, remain);\n\t\t\tctx->bytes_in_header = remain;\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = -1;\n\n\t\t\/\/we have some potential bytes of a start code in the store, copy some more bytes and check if valid start code.\n\t\t\/\/if not, dispatch these bytes as continuation of the data\n\t\tif (ctx->bytes_in_header) {\n\n\t\t\tmemcpy(ctx->hdr_store + ctx->bytes_in_header, start, 8 - ctx->bytes_in_header);\n\t\t\tcurrent = mpgviddmx_next_start_code(ctx->hdr_store, 8);\n\n\t\t\t\/\/no start code in stored buffer\n\t\t\tif ((current<0) || (current >= (s32) ctx->bytes_in_header) )  {\n\t\t\t\tif (ctx->opid) {\n\t\t\t\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid, ctx->bytes_in_header, &pck_data);\n\t\t\t\t\tif (!dst_pck) return GF_OUT_OF_MEM;\n\n\t\t\t\t\tif (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);\n\t\t\t\t\tgf_filter_pck_set_cts(dst_pck, GF_FILTER_NO_TS);\n\t\t\t\t\tgf_filter_pck_set_dts(dst_pck, GF_FILTER_NO_TS);\n\t\t\t\t\tmemcpy(pck_data, ctx->hdr_store, ctx->bytes_in_header);\n\t\t\t\t\tgf_filter_pck_set_framing(dst_pck, GF_FALSE, GF_FALSE);\n\n\t\t\t\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\t\t\t\tgf_filter_pck_set_byte_offset(dst_pck, byte_offset - ctx->bytes_in_header);\n\t\t\t\t\t}\n\n\t\t\t\t\tmpgviddmx_enqueue_or_dispatch(ctx, dst_pck, GF_FALSE, GF_FALSE);\n\t\t\t\t}\n\n\t\t\t\tif (current<0) current = -1;\n\t\t\t\telse current -= ctx->bytes_in_header;\n\t\t\t\tctx->bytes_in_header = 0;\n\t\t\t} else {\n\t\t\t\t\/\/we have a valid start code, check which byte in our store or in the packet payload is the start code type\n\t\t\t\t\/\/and remember its location to reinit the parser from there\n\t\t\t\thdr_offset = 4 - ctx->bytes_in_header + current;\n\t\t\t\t\/\/bytes still to dispatch\n\t\t\t\tbytes_from_store = ctx->bytes_in_header;\n\t\t\t\tctx->bytes_in_header = 0;\n\t\t\t\tif (!hdr_offset) {\n\t\t\t\t\tforced_sc_type = ctx->hdr_store[current+3];\n\t\t\t\t} else {\n\t\t\t\t\tforced_sc_type = start[hdr_offset-1];\n\t\t\t\t}\n\t\t\t\tsc_type_forced = GF_TRUE;\n\t\t\t}\n\t\t}\n\t\t\/\/no starcode in store, look for startcode in packet\n\t\tif (current == -1) {\n\t\t\t\/\/locate next start code\n\t\t\tcurrent = mpgviddmx_next_start_code(start, remain);\n\t\t\t\/\/no start code, dispatch the block\n\t\t\tif (current<0) {\n\t\t\t\tu8 b3, b2, b1;\n\t\t\t\tif (! ctx->frame_started) {\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"[MPGVid] no start code in block and no frame started, discarding data\\n\" ));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsize = remain;\n\t\t\t\tb3 = start[remain-3];\n\t\t\t\tb2 = start[remain-2];\n\t\t\t\tb1 = start[remain-1];\n\t\t\t\t\/\/we may have a startcode at the end of the packet, store it and don't dispatch the last 3 bytes !\n\t\t\t\tif (!b1 || !b2 || !b3) {\n\t\t\t\t\tcopy_last_bytes = GF_TRUE;\n\t\t\t\t\tassert(size >= 3);\n\t\t\t\t\tsize -= 3;\n\t\t\t\t\tctx->bytes_in_header = 3;\n\t\t\t\t}\n\n\t\t\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid, (u32) size, &pck_data);\n\t\t\t\tif (!dst_pck) return GF_OUT_OF_MEM;\n\n\t\t\t\tif (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);\n\t\t\t\tmemcpy(pck_data, start, (size_t) size);\n\t\t\t\tgf_filter_pck_set_framing(dst_pck, GF_FALSE, GF_FALSE);\n\t\t\t\tgf_filter_pck_set_cts(dst_pck, GF_FILTER_NO_TS);\n\t\t\t\tgf_filter_pck_set_dts(dst_pck, GF_FILTER_NO_TS);\n\n\t\t\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\t\t\tgf_filter_pck_set_byte_offset(dst_pck, byte_offset);\n\t\t\t\t}\n\n\t\t\t\tmpgviddmx_enqueue_or_dispatch(ctx, dst_pck, GF_FALSE, GF_FALSE);\n\t\t\t\tif (copy_last_bytes) {\n\t\t\t\t\tmemcpy(ctx->hdr_store, start+remain-3, 3);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tassert(current>=0);\n\n\t\t\/\/if we are in the middle of parsing the vosh, skip over bytes remaining from previous obj not parsed\n\t\tif ((vosh_start>=0) && current) {\n\t\t\tassert(remain>=current);\n\t\t\tstart += current;\n\t\t\tremain -= current;\n\t\t\tcurrent = 0;\n\t\t}\n\t\t\/\/also skip if no output pid\n\t\tif (!ctx->opid && current) {\n\t\t\tassert(remain>=current);\n\t\t\tstart += current;\n\t\t\tremain -= current;\n\t\t\tcurrent = 0;\n\t\t}\n\t\t\/\/dispatch remaining bytes\n\t\tif (current>0) {\n\t\t\t\/\/flush remaining\n\t\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid, current, &pck_data);\n\t\t\tif (!dst_pck) return GF_OUT_OF_MEM;\n\n\t\t\tif (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);\n\t\t\tgf_filter_pck_set_cts(dst_pck, GF_FILTER_NO_TS);\n\t\t\tgf_filter_pck_set_dts(dst_pck, GF_FILTER_NO_TS);\n\t\t\tgf_filter_pck_set_framing(dst_pck, GF_FALSE, GF_TRUE);\n\t\t\t\/\/bytes were partly in store, partly in packet\n\t\t\tif (bytes_from_store) {\n\t\t\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\t\t\tgf_filter_pck_set_byte_offset(dst_pck, byte_offset - bytes_from_store);\n\t\t\t\t}\n\t\t\t\tassert(bytes_from_store>=(u32) current);\n\t\t\t\tbytes_from_store -= current;\n\t\t\t\tmemcpy(pck_data, ctx->hdr_store, current);\n\t\t\t} else {\n\t\t\t\t\/\/bytes were only in packet\n\t\t\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\t\t\tgf_filter_pck_set_byte_offset(dst_pck, byte_offset);\n\t\t\t\t}\n\t\t\t\tmemcpy(pck_data, start, current);\n\t\t\t\tassert(remain>=current);\n\t\t\t\tstart += current;\n\t\t\t\tremain -= current;\n\t\t\t\tcurrent = 0;\n\t\t\t}\n\t\t\tgf_filter_pck_set_carousel_version(dst_pck, 1);\n\n\t\t\tmpgviddmx_enqueue_or_dispatch(ctx, dst_pck, GF_FALSE, GF_FALSE);\n\t\t}\n\n\t\t\/\/parse headers\n\n\t\t\/\/we have a start code loaded, eg the data packet does not have a full start code at the beginning\n\t\tif (sc_type_forced) {\n\t\t\tgf_bs_reassign_buffer(ctx->bs, start + hdr_offset, remain - hdr_offset);\n\t\t\tsc_type = forced_sc_type;\n\t\t} else {\n\t\t\tgf_bs_reassign_buffer(ctx->bs, start, remain);\n\t\t\tgf_bs_read_int(ctx->bs, 24);\n\t\t\tsc_type = gf_bs_read_int(ctx->bs, 8);\n\t\t}\n\n\t\tif (ctx->is_mpg12) {\n\t\t\tswitch (sc_type) {\n\t\t\tcase M2V_SEQ_START_CODE:\n\t\t\tcase M2V_EXT_START_CODE:\n\t\t\t\tgf_bs_reassign_buffer(ctx->bs, start, remain);\n\t\t\t\te = gf_m4v_parse_config(ctx->vparser, &ctx->dsi);\n\t\t\t\t\/\/not enough data, accumulate until we can parse the full header\n\t\t\t\tif (e==GF_EOS) {\n\t\t\t\t\tif (vosh_start<0) vosh_start = 0;\n\t\t\t\t\tif (data == ctx->hdr_store) {\n\t\t\t\t\t\tmemmove(ctx->hdr_store, start, remain);\n\t\t\t\t\t\tctx->hdr_store_size = remain;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (ctx->hdr_store_alloc < ctx->hdr_store_size + pck_size - vosh_start) {\n\t\t\t\t\t\t\tctx->hdr_store_alloc = (u32) (ctx->hdr_store_size + pck_size - vosh_start);\n\t\t\t\t\t\t\tctx->hdr_store = gf_realloc(ctx->hdr_store, sizeof(char)*ctx->hdr_store_alloc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(ctx->hdr_store + ctx->hdr_store_size, data + vosh_start, (size_t) (pck_size - vosh_start) );\n\t\t\t\t\t\tctx->hdr_store_size += pck_size - (u32) vosh_start;\n\t\t\t\t\t}\n\t\t\t\t\tgf_filter_pid_drop_packet(ctx->ipid);\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t} else if (e != GF_OK) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (\"[MPGVid] Failed to parse VOS header: %s\\n\", gf_error_to_string(e) ));\n\t\t\t\t} else {\n\t\t\t\t\tmpgviddmx_check_pid(filter, ctx, 0, NULL);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase M2V_PIC_START_CODE:\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t} else {\n\t\t\tu8 PL;\n\t\t\tswitch (sc_type) {\n\t\t\tcase M4V_VOS_START_CODE:\n\t\t\t\tctx->dsi.VideoPL = (u8) gf_bs_read_u8(ctx->bs);\n\t\t\t\tvosh_start = start - (u8 *)data;\n\t\t\t\tskip_pck = GF_TRUE;\n\t\t\t\tassert(remain>=5);\n\t\t\t\tstart += 5;\n\t\t\t\tremain -= 5;\n\t\t\t\tbreak;\n\t\t\tcase M4V_VOL_START_CODE:\n\t\t\t\tgf_bs_reassign_buffer(ctx->bs, start, remain);\n\t\t\t\tPL = ctx->dsi.VideoPL;\n\t\t\t\te = gf_m4v_parse_config(ctx->vparser, &ctx->dsi);\n\t\t\t\tctx->dsi.VideoPL = PL;\n\t\t\t\t\/\/not enough data, accumulate until we can parse the full header\n\t\t\t\tif (e==GF_EOS) {\n\t\t\t\t\tif (vosh_start<0) vosh_start = 0;\n\t\t\t\t\tif (data == ctx->hdr_store) {\n\t\t\t\t\t\tmemmove(ctx->hdr_store, start, remain);\n\t\t\t\t\t\tctx->hdr_store_size = remain;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (ctx->hdr_store_alloc < ctx->hdr_store_size + pck_size - vosh_start) {\n\t\t\t\t\t\t\tctx->hdr_store_alloc = (u32) (ctx->hdr_store_size + pck_size - (u32) vosh_start);\n\t\t\t\t\t\t\tctx->hdr_store = gf_realloc(ctx->hdr_store, sizeof(char)*ctx->hdr_store_alloc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(ctx->hdr_store + ctx->hdr_store_size, data + vosh_start, (size_t) (pck_size - vosh_start) );\n\t\t\t\t\t\tctx->hdr_store_size += pck_size - (u32) vosh_start;\n\t\t\t\t\t}\n\t\t\t\t\tgf_filter_pid_drop_packet(ctx->ipid);\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t} else if (e != GF_OK) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, (\"[MPGVid] Failed to parse VOS header: %s\\n\", gf_error_to_string(e) ));\n\t\t\t\t} else {\n\t\t\t\t\tu32 obj_size = (u32) gf_m4v_get_object_start(ctx->vparser);\n\t\t\t\t\tif (vosh_start<0) vosh_start = 0;\n\t\t\t\t\tvosh_end = start - (u8 *)data + obj_size;\n\t\t\t\t\tvosh_end -= vosh_start;\n\t\t\t\t\tmpgviddmx_check_pid(filter, ctx,(u32)  vosh_end, data+vosh_start);\n\t\t\t\t\tskip_pck = GF_TRUE;\n\t\t\t\t\tassert(remain>=(s32) obj_size);\n\t\t\t\t\tstart += obj_size;\n\t\t\t\t\tremain -= obj_size;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase M4V_VOP_START_CODE:\n\t\t\tcase M4V_GOV_START_CODE:\n\t\t\t\tbreak;\n\n\t\t\tcase M4V_VO_START_CODE:\n\t\t\tcase M4V_VISOBJ_START_CODE:\n\t\t\tdefault:\n\t\t\t\tif (vosh_start>=0) {\n\t\t\t\t\tskip_pck = GF_TRUE;\n\t\t\t\t\tassert(remain>=4);\n\t\t\t\t\tstart += 4;\n\t\t\t\t\tremain -= 4;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (skip_pck) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!ctx->opid) {\n\t\t\tassert(remain>=4);\n\t\t\tstart += 4;\n\t\t\tremain -= 4;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!ctx->is_playing) {\n\t\t\tctx->resume_from = (u32) ((char *)start -  (char *)data);\n\t\t\treturn GF_OK;\n\t\t}\n\t\t\/\/at this point, we no longer reaggregate packets\n\t\tctx->hdr_store_size = 0;\n\n\t\tif (ctx->in_seek) {\n\t\t\tu64 nb_frames_at_seek = (u64) (ctx->start_range * ctx->cur_fps.num);\n\t\t\tif (ctx->cts + ctx->cur_fps.den >= nb_frames_at_seek) {\n\t\t\t\t\/\/u32 samples_to_discard = (ctx->cts + ctx->dts_inc) - nb_samples_at_seek;\n\t\t\t\tctx->in_seek = GF_FALSE;\n\t\t\t}\n\t\t}\n\t\t\/\/may happen that after all our checks, only 4 bytes are left, continue to store these 4 bytes\n\t\tif (remain<5)\n\t\t\tcontinue;\n\n\t\t\/\/good to go\n\t\tgf_m4v_parser_reset(ctx->vparser, sc_type_forced ? forced_sc_type + 1 : 0);\n\t\tsize = 0;\n\t\te = gf_m4v_parse_frame(ctx->vparser, &ctx->dsi, &ftype, &tinc, &size, &fstart, &is_coded);\n\t\t\/\/true if we strip VO and VISOBJ assert(!fstart);\n\n\t\t\/\/we skipped bytes already in store + end of start code present in packet, so the size of the first object\n\t\t\/\/needs adjustement\n\t\tif (bytes_from_store) {\n\t\t\tsize += bytes_from_store + hdr_offset;\n\t\t}\n\n\t\tif ((e == GF_EOS) && !ctx->input_is_au_end) {\n\t\t\tu8 b3 = start[remain-3];\n\t\t\tu8 b2 = start[remain-2];\n\t\t\tu8 b1 = start[remain-1];\n\n\t\t\t\/\/we may have a startcode at the end of the packet, store it and don't dispatch the last 3 bytes !\n\t\t\tif (!b1 || !b2 || !b3) {\n\t\t\t\tcopy_last_bytes = GF_TRUE;\n\t\t\t\tassert(size >= 3);\n\t\t\t\tsize -= 3;\n\t\t\t\tctx->bytes_in_header = 3;\n\t\t\t}\n\t\t\tfull_frame = GF_FALSE;\n\t\t} else {\n\t\t\tfull_frame = GF_TRUE;\n\t\t}\n\n\t\tif (!is_coded) {\n\t\t\t\/*if prev is B and we're parsing a packed bitstream discard n-vop*\/\n\t\t\tif (ctx->forced_packed && ctx->b_frames) {\n\t\t\t\tctx->is_packed = GF_TRUE;\n\t\t\t\tassert(remain>=size);\n\t\t\t\tstart += size;\n\t\t\t\tremain -= (s32) size;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/*policy is to import at variable frame rate, skip*\/\n\t\t\tif (ctx->vfr) {\n\t\t\t\tctx->is_vfr = GF_TRUE;\n\t\t\t\tmpgviddmx_update_time(ctx);\n\t\t\t\tassert(remain>=size);\n\t\t\t\tstart += size;\n\t\t\t\tremain -= (s32) size;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/*policy is to keep non coded frame (constant frame rate), add*\/\n\t\t}\n\n\t\tif (ftype==2) {\n\t\t\t\/\/count number of B-frames since last ref\n\t\t\tctx->b_frames++;\n\t\t\tctx->nb_b++;\n\t\t} else {\n\t\t\t\/\/flush all pending packets\n\t\t\tmpgviddmx_enqueue_or_dispatch(ctx, NULL, GF_TRUE, GF_FALSE);\n\t\t\t\/\/remeber the CTS of the last ref\n\t\t\tctx->last_ref_cts = ctx->cts;\n\t\t\tif (ctx->max_b < ctx->b_frames) ctx->max_b = ctx->b_frames;\n\t\t\t\n\t\t\tctx->b_frames = 0;\n\t\t\tif (ftype)\n\t\t\t\tctx->nb_p++;\n\t\t\telse\n\t\t\t\tctx->nb_i++;\n\t\t}\n\t\tctx->nb_frames++;\n\n\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid, (u32) size, &pck_data);\n\t\tif (!dst_pck) return GF_OUT_OF_MEM;\n\n\t\tif (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);\n\t\t\/\/bytes come from both our store and the data packet\n\t\tif (bytes_from_store) {\n\t\t\tmemcpy(pck_data, ctx->hdr_store+current, bytes_from_store);\n\t\t\tassert(size >= bytes_from_store);\n\t\t\tsize -= bytes_from_store;\n\t\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\t\tgf_filter_pck_set_byte_offset(dst_pck, byte_offset - bytes_from_store);\n\t\t\t}\n\t\t\tmemcpy(pck_data + bytes_from_store, start, (size_t) size);\n\t\t} else {\n\t\t\t\/\/bytes only come the data packet\n\t\t\tmemcpy(pck_data, start, (size_t) size);\n\t\t\tif (byte_offset != GF_FILTER_NO_BO) {\n\t\t\t\tgf_filter_pck_set_byte_offset(dst_pck, byte_offset + start - (u8 *) data);\n\t\t\t}\n\t\t}\n\t\tassert(pck_data[0] == 0);\n\t\tassert(pck_data[1] == 0);\n\t\tassert(pck_data[2] == 0x01);\n\n\t\tgf_filter_pck_set_framing(dst_pck, GF_TRUE, (full_frame || ctx->input_is_au_end) ? GF_TRUE : GF_FALSE);\n\t\tgf_filter_pck_set_cts(dst_pck, ctx->cts);\n\t\tgf_filter_pck_set_dts(dst_pck, ctx->dts);\n\t\tif (ctx->input_is_au_start) {\n\t\t\tctx->input_is_au_start = GF_FALSE;\n\t\t} else {\n\t\t\t\/\/we use the carousel flag temporarly to indicate the cts must be recomputed\n\t\t\tgf_filter_pck_set_carousel_version(dst_pck, 1);\n\t\t}\n\t\tgf_filter_pck_set_sap(dst_pck, ftype ? GF_FILTER_SAP_NONE : GF_FILTER_SAP_1);\n\t\tgf_filter_pck_set_duration(dst_pck, ctx->cur_fps.den);\n\t\tif (ctx->in_seek) gf_filter_pck_set_seek_flag(dst_pck, GF_TRUE);\n\t\tctx->frame_started = GF_TRUE;\n\n\t\tmpgviddmx_enqueue_or_dispatch(ctx, dst_pck, GF_FALSE, GF_FALSE);\n\n\t\tmpgviddmx_update_time(ctx);\n\n\t\tif (!full_frame) {\n\t\t\tif (copy_last_bytes) {\n\t\t\t\tmemcpy(ctx->hdr_store, start+remain-3, 3);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tassert(remain>=size);\n\t\tstart += size;\n\t\tremain -= (s32) size;\n\t}\n\tgf_filter_pid_drop_packet(ctx->ipid);\n\n\treturn GF_OK;\n}","target":1,"code_token_length":5374,"total_token_length":5610,"max_tokens_setting":6144}
+{"idx":333037,"func":"post2nfa(int *postfix, int *end, int nfa_calc_size)\n{\n    int\t\t*p;\n    int\t\tmopen;\n    int\t\tmclose;\n    Frag_T\t*stack = NULL;\n    Frag_T\t*stackp = NULL;\n    Frag_T\t*stack_end = NULL;\n    Frag_T\te1;\n    Frag_T\te2;\n    Frag_T\te;\n    nfa_state_T\t*s;\n    nfa_state_T\t*s1;\n    nfa_state_T\t*matchstate;\n    nfa_state_T\t*ret = NULL;\n\n    if (postfix == NULL)\n\treturn NULL;\n\n#define PUSH(s)\t    st_push((s), &stackp, stack_end)\n#define POP()\t    st_pop(&stackp, stack);\t\t\\\n\t\t    if (stackp < stack)\t\t\t\\\n\t\t    {\t\t\t\t\t\\\n\t\t\tst_error(postfix, end, p);\t\\\n\t\t\tvim_free(stack);\t\t\\\n\t\t\treturn NULL;\t\t\t\\\n\t\t    }\n\n    if (nfa_calc_size == FALSE)\n    {\n\t\/\/ Allocate space for the stack. Max states on the stack: \"nstate\".\n\tstack = ALLOC_MULT(Frag_T, nstate + 1);\n\tif (stack == NULL)\n\t    return NULL;\n\tstackp = stack;\n\tstack_end = stack + (nstate + 1);\n    }\n\n    for (p = postfix; p < end; ++p)\n    {\n\tswitch (*p)\n\t{\n\tcase NFA_CONCAT:\n\t    \/\/ Concatenation.\n\t    \/\/ Pay attention: this operator does not exist in the r.e. itself\n\t    \/\/ (it is implicit, really).  It is added when r.e. is translated\n\t    \/\/ to postfix form in re2post().\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\t\/\/ nstate += 0;\n\t\tbreak;\n\t    }\n\t    e2 = POP();\n\t    e1 = POP();\n\t    patch(e1.out, e2.start);\n\t    PUSH(frag(e1.start, e2.out));\n\t    break;\n\n\tcase NFA_OR:\n\t    \/\/ Alternation\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    e2 = POP();\n\t    e1 = POP();\n\t    s = alloc_state(NFA_SPLIT, e1.start, e2.start);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    PUSH(frag(s, append(e1.out, e2.out)));\n\t    break;\n\n\tcase NFA_STAR:\n\t    \/\/ Zero or more, prefer more\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    e = POP();\n\t    s = alloc_state(NFA_SPLIT, e.start, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    patch(e.out, s);\n\t    PUSH(frag(s, list1(&s->out1)));\n\t    break;\n\n\tcase NFA_STAR_NONGREEDY:\n\t    \/\/ Zero or more, prefer zero\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    e = POP();\n\t    s = alloc_state(NFA_SPLIT, NULL, e.start);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    patch(e.out, s);\n\t    PUSH(frag(s, list1(&s->out)));\n\t    break;\n\n\tcase NFA_QUEST:\n\t    \/\/ one or zero atoms=> greedy match\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    e = POP();\n\t    s = alloc_state(NFA_SPLIT, e.start, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    PUSH(frag(s, append(e.out, list1(&s->out1))));\n\t    break;\n\n\tcase NFA_QUEST_NONGREEDY:\n\t    \/\/ zero or one atoms => non-greedy match\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    e = POP();\n\t    s = alloc_state(NFA_SPLIT, NULL, e.start);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    PUSH(frag(s, append(e.out, list1(&s->out))));\n\t    break;\n\n\tcase NFA_END_COLL:\n\tcase NFA_END_NEG_COLL:\n\t    \/\/ On the stack is the sequence starting with NFA_START_COLL or\n\t    \/\/ NFA_START_NEG_COLL and all possible characters. Patch it to\n\t    \/\/ add the output to the start.\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    e = POP();\n\t    s = alloc_state(NFA_END_COLL, NULL, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    patch(e.out, s);\n\t    e.start->out1 = s;\n\t    PUSH(frag(e.start, list1(&s->out)));\n\t    break;\n\n\tcase NFA_RANGE:\n\t    \/\/ Before this are two characters, the low and high end of a\n\t    \/\/ range.  Turn them into two states with MIN and MAX.\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\t\/\/ nstate += 0;\n\t\tbreak;\n\t    }\n\t    e2 = POP();\n\t    e1 = POP();\n\t    e2.start->val = e2.start->c;\n\t    e2.start->c = NFA_RANGE_MAX;\n\t    e1.start->val = e1.start->c;\n\t    e1.start->c = NFA_RANGE_MIN;\n\t    patch(e1.out, e2.start);\n\t    PUSH(frag(e1.start, e2.out));\n\t    break;\n\n\tcase NFA_EMPTY:\n\t    \/\/ 0-length, used in a repetition with max\/min count of 0\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    s = alloc_state(NFA_EMPTY, NULL, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    PUSH(frag(s, list1(&s->out)));\n\t    break;\n\n\tcase NFA_OPT_CHARS:\n\t  {\n\t    int    n;\n\n\t    \/\/ \\%[abc] implemented as:\n\t    \/\/    NFA_SPLIT\n\t    \/\/    +-CHAR(a)\n\t    \/\/    | +-NFA_SPLIT\n\t    \/\/    |   +-CHAR(b)\n\t    \/\/    |   | +-NFA_SPLIT\n\t    \/\/    |   |   +-CHAR(c)\n\t    \/\/    |   |   | +-next\n\t    \/\/    |   |   +- next\n\t    \/\/    |   +- next\n\t    \/\/    +- next\n\t    n = *++p; \/\/ get number of characters\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate += n;\n\t\tbreak;\n\t    }\n\t    s = NULL; \/\/ avoid compiler warning\n\t    e1.out = NULL; \/\/ stores list with out1's\n\t    s1 = NULL; \/\/ previous NFA_SPLIT to connect to\n\t    while (n-- > 0)\n\t    {\n\t\te = POP(); \/\/ get character\n\t\ts = alloc_state(NFA_SPLIT, e.start, NULL);\n\t\tif (s == NULL)\n\t\t    goto theend;\n\t\tif (e1.out == NULL)\n\t\t    e1 = e;\n\t\tpatch(e.out, s1);\n\t\tappend(e1.out, list1(&s->out1));\n\t\ts1 = s;\n\t    }\n\t    PUSH(frag(s, e1.out));\n\t    break;\n\t  }\n\n\tcase NFA_PREV_ATOM_NO_WIDTH:\n\tcase NFA_PREV_ATOM_NO_WIDTH_NEG:\n\tcase NFA_PREV_ATOM_JUST_BEFORE:\n\tcase NFA_PREV_ATOM_JUST_BEFORE_NEG:\n\tcase NFA_PREV_ATOM_LIKE_PATTERN:\n\t  {\n\t    int before = (*p == NFA_PREV_ATOM_JUST_BEFORE\n\t\t\t\t      || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG);\n\t    int pattern = (*p == NFA_PREV_ATOM_LIKE_PATTERN);\n\t    int start_state;\n\t    int end_state;\n\t    int n = 0;\n\t    nfa_state_T *zend;\n\t    nfa_state_T *skip;\n\n\t    switch (*p)\n\t    {\n\t\tcase NFA_PREV_ATOM_NO_WIDTH:\n\t\t    start_state = NFA_START_INVISIBLE;\n\t\t    end_state = NFA_END_INVISIBLE;\n\t\t    break;\n\t\tcase NFA_PREV_ATOM_NO_WIDTH_NEG:\n\t\t    start_state = NFA_START_INVISIBLE_NEG;\n\t\t    end_state = NFA_END_INVISIBLE_NEG;\n\t\t    break;\n\t\tcase NFA_PREV_ATOM_JUST_BEFORE:\n\t\t    start_state = NFA_START_INVISIBLE_BEFORE;\n\t\t    end_state = NFA_END_INVISIBLE;\n\t\t    break;\n\t\tcase NFA_PREV_ATOM_JUST_BEFORE_NEG:\n\t\t    start_state = NFA_START_INVISIBLE_BEFORE_NEG;\n\t\t    end_state = NFA_END_INVISIBLE_NEG;\n\t\t    break;\n\t\tdefault: \/\/ NFA_PREV_ATOM_LIKE_PATTERN:\n\t\t    start_state = NFA_START_PATTERN;\n\t\t    end_state = NFA_END_PATTERN;\n\t\t    break;\n\t    }\n\n\t    if (before)\n\t\tn = *++p; \/\/ get the count\n\n\t    \/\/ The \\@= operator: match the preceding atom with zero width.\n\t    \/\/ The \\@! operator: no match for the preceding atom.\n\t    \/\/ The \\@<= operator: match for the preceding atom.\n\t    \/\/ The \\@<! operator: no match for the preceding atom.\n\t    \/\/ Surrounds the preceding atom with START_INVISIBLE and\n\t    \/\/ END_INVISIBLE, similarly to MOPEN.\n\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate += pattern ? 4 : 2;\n\t\tbreak;\n\t    }\n\t    e = POP();\n\t    s1 = alloc_state(end_state, NULL, NULL);\n\t    if (s1 == NULL)\n\t\tgoto theend;\n\n\t    s = alloc_state(start_state, e.start, s1);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    if (pattern)\n\t    {\n\t\t\/\/ NFA_ZEND -> NFA_END_PATTERN -> NFA_SKIP -> what follows.\n\t\tskip = alloc_state(NFA_SKIP, NULL, NULL);\n\t\tif (skip == NULL)\n\t\t    goto theend;\n\t\tzend = alloc_state(NFA_ZEND, s1, NULL);\n\t\tif (zend == NULL)\n\t\t    goto theend;\n\t\ts1->out= skip;\n\t\tpatch(e.out, zend);\n\t\tPUSH(frag(s, list1(&skip->out)));\n\t    }\n\t    else\n\t    {\n\t\tpatch(e.out, s1);\n\t\tPUSH(frag(s, list1(&s1->out)));\n\t\tif (before)\n\t\t{\n\t\t    if (n <= 0)\n\t\t\t\/\/ See if we can guess the maximum width, it avoids a\n\t\t\t\/\/ lot of pointless tries.\n\t\t\tn = nfa_max_width(e.start, 0);\n\t\t    s->val = n; \/\/ store the count\n\t\t}\n\t    }\n\t    break;\n\t  }\n\n\tcase NFA_COMPOSING:\t\/\/ char with composing char\n#if 0\n\t    \/\/ TODO\n\t    if (regflags & RF_ICOMBINE)\n\t    {\n\t\t\/\/ use the base character only\n\t    }\n#endif\n\t    \/\/ FALLTHROUGH\n\n\tcase NFA_MOPEN:\t\/\/ \\( \\) Submatch\n\tcase NFA_MOPEN1:\n\tcase NFA_MOPEN2:\n\tcase NFA_MOPEN3:\n\tcase NFA_MOPEN4:\n\tcase NFA_MOPEN5:\n\tcase NFA_MOPEN6:\n\tcase NFA_MOPEN7:\n\tcase NFA_MOPEN8:\n\tcase NFA_MOPEN9:\n#ifdef FEAT_SYN_HL\n\tcase NFA_ZOPEN:\t\/\/ \\z( \\) Submatch\n\tcase NFA_ZOPEN1:\n\tcase NFA_ZOPEN2:\n\tcase NFA_ZOPEN3:\n\tcase NFA_ZOPEN4:\n\tcase NFA_ZOPEN5:\n\tcase NFA_ZOPEN6:\n\tcase NFA_ZOPEN7:\n\tcase NFA_ZOPEN8:\n\tcase NFA_ZOPEN9:\n#endif\n\tcase NFA_NOPEN:\t\/\/ \\%( \\) \"Invisible Submatch\"\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate += 2;\n\t\tbreak;\n\t    }\n\n\t    mopen = *p;\n\t    switch (*p)\n\t    {\n\t\tcase NFA_NOPEN: mclose = NFA_NCLOSE; break;\n#ifdef FEAT_SYN_HL\n\t\tcase NFA_ZOPEN: mclose = NFA_ZCLOSE; break;\n\t\tcase NFA_ZOPEN1: mclose = NFA_ZCLOSE1; break;\n\t\tcase NFA_ZOPEN2: mclose = NFA_ZCLOSE2; break;\n\t\tcase NFA_ZOPEN3: mclose = NFA_ZCLOSE3; break;\n\t\tcase NFA_ZOPEN4: mclose = NFA_ZCLOSE4; break;\n\t\tcase NFA_ZOPEN5: mclose = NFA_ZCLOSE5; break;\n\t\tcase NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break;\n\t\tcase NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break;\n\t\tcase NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break;\n\t\tcase NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break;\n#endif\n\t\tcase NFA_COMPOSING: mclose = NFA_END_COMPOSING; break;\n\t\tdefault:\n\t\t    \/\/ NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9\n\t\t    mclose = *p + NSUBEXP;\n\t\t    break;\n\t    }\n\n\t    \/\/ Allow \"NFA_MOPEN\" as a valid postfix representation for\n\t    \/\/ the empty regexp \"\". In this case, the NFA will be\n\t    \/\/ NFA_MOPEN -> NFA_MCLOSE. Note that this also allows\n\t    \/\/ empty groups of parenthesis, and empty mbyte chars\n\t    if (stackp == stack)\n\t    {\n\t\ts = alloc_state(mopen, NULL, NULL);\n\t\tif (s == NULL)\n\t\t    goto theend;\n\t\ts1 = alloc_state(mclose, NULL, NULL);\n\t\tif (s1 == NULL)\n\t\t    goto theend;\n\t\tpatch(list1(&s->out), s1);\n\t\tPUSH(frag(s, list1(&s1->out)));\n\t\tbreak;\n\t    }\n\n\t    \/\/ At least one node was emitted before NFA_MOPEN, so\n\t    \/\/ at least one node will be between NFA_MOPEN and NFA_MCLOSE\n\t    e = POP();\n\t    s = alloc_state(mopen, e.start, NULL);   \/\/ `('\n\t    if (s == NULL)\n\t\tgoto theend;\n\n\t    s1 = alloc_state(mclose, NULL, NULL);   \/\/ `)'\n\t    if (s1 == NULL)\n\t\tgoto theend;\n\t    patch(e.out, s1);\n\n\t    if (mopen == NFA_COMPOSING)\n\t\t\/\/ COMPOSING->out1 = END_COMPOSING\n\t\tpatch(list1(&s->out1), s1);\n\n\t    PUSH(frag(s, list1(&s1->out)));\n\t    break;\n\n\tcase NFA_BACKREF1:\n\tcase NFA_BACKREF2:\n\tcase NFA_BACKREF3:\n\tcase NFA_BACKREF4:\n\tcase NFA_BACKREF5:\n\tcase NFA_BACKREF6:\n\tcase NFA_BACKREF7:\n\tcase NFA_BACKREF8:\n\tcase NFA_BACKREF9:\n#ifdef FEAT_SYN_HL\n\tcase NFA_ZREF1:\n\tcase NFA_ZREF2:\n\tcase NFA_ZREF3:\n\tcase NFA_ZREF4:\n\tcase NFA_ZREF5:\n\tcase NFA_ZREF6:\n\tcase NFA_ZREF7:\n\tcase NFA_ZREF8:\n\tcase NFA_ZREF9:\n#endif\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate += 2;\n\t\tbreak;\n\t    }\n\t    s = alloc_state(*p, NULL, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    s1 = alloc_state(NFA_SKIP, NULL, NULL);\n\t    if (s1 == NULL)\n\t\tgoto theend;\n\t    patch(list1(&s->out), s1);\n\t    PUSH(frag(s, list1(&s1->out)));\n\t    break;\n\n\tcase NFA_LNUM:\n\tcase NFA_LNUM_GT:\n\tcase NFA_LNUM_LT:\n\tcase NFA_VCOL:\n\tcase NFA_VCOL_GT:\n\tcase NFA_VCOL_LT:\n\tcase NFA_COL:\n\tcase NFA_COL_GT:\n\tcase NFA_COL_LT:\n\tcase NFA_MARK:\n\tcase NFA_MARK_GT:\n\tcase NFA_MARK_LT:\n\t  {\n\t    int n = *++p; \/\/ lnum, col or mark name\n\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate += 1;\n\t\tbreak;\n\t    }\n\t    s = alloc_state(p[-1], NULL, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    s->val = n;\n\t    PUSH(frag(s, list1(&s->out)));\n\t    break;\n\t  }\n\n\tcase NFA_ZSTART:\n\tcase NFA_ZEND:\n\tdefault:\n\t    \/\/ Operands\n\t    if (nfa_calc_size == TRUE)\n\t    {\n\t\tnstate++;\n\t\tbreak;\n\t    }\n\t    s = alloc_state(*p, NULL, NULL);\n\t    if (s == NULL)\n\t\tgoto theend;\n\t    PUSH(frag(s, list1(&s->out)));\n\t    break;\n\n\t} \/\/ switch(*p)\n\n    } \/\/ for(p = postfix; *p; ++p)\n\n    if (nfa_calc_size == TRUE)\n    {\n\tnstate++;\n\tgoto theend;\t\/\/ Return value when counting size is ignored anyway\n    }\n\n    e = POP();\n    if (stackp != stack)\n    {\n\tvim_free(stack);\n\tEMSG_RET_NULL(_(\"E875: (NFA regexp) (While converting from postfix to NFA), too many states left on stack\"));\n    }\n\n    if (istate >= nstate)\n    {\n\tvim_free(stack);\n\tEMSG_RET_NULL(_(\"E876: (NFA regexp) Not enough space to store the whole NFA \"));\n    }\n\n    matchstate = &state_ptr[istate++]; \/\/ the match state\n    matchstate->c = NFA_MATCH;\n    matchstate->out = matchstate->out1 = NULL;\n    matchstate->id = 0;\n\n    patch(e.out, matchstate);\n    ret = e.start;\n\ntheend:\n    vim_free(stack);\n    return ret;\n\n#undef POP1\n#undef PUSH1\n#undef POP2\n#undef PUSH2\n#undef POP\n#undef PUSH\n}","target":0,"code_token_length":3877,"total_token_length":4113,"max_tokens_setting":6144}
+{"idx":210378,"func":"xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,\n                  const xmlChar **URI, int *tlen) {\n    const xmlChar *localname;\n    const xmlChar *prefix;\n    const xmlChar *attname;\n    const xmlChar *aprefix;\n    const xmlChar *nsname;\n    xmlChar *attvalue;\n    const xmlChar **atts = ctxt->atts;\n    int maxatts = ctxt->maxatts;\n    int nratts, nbatts, nbdef;\n    int i, j, nbNs, attval, oldline, oldcol, inputNr;\n    const xmlChar *base;\n    unsigned long cur;\n    int nsNr = ctxt->nsNr;\n\n    if (RAW != '<') return(NULL);\n    NEXT1;\n\n    \/*\n     * NOTE: it is crucial with the SAX2 API to never call SHRINK beyond that\n     *       point since the attribute values may be stored as pointers to\n     *       the buffer and calling SHRINK would destroy them !\n     *       The Shrinking is only possible once the full set of attribute\n     *       callbacks have been done.\n     *\/\nreparse:\n    SHRINK;\n    base = ctxt->input->base;\n    cur = ctxt->input->cur - ctxt->input->base;\n    inputNr = ctxt->inputNr;\n    oldline = ctxt->input->line;\n    oldcol = ctxt->input->col;\n    nbatts = 0;\n    nratts = 0;\n    nbdef = 0;\n    nbNs = 0;\n    attval = 0;\n    \/* Forget any namespaces added during an earlier parse of this element. *\/\n    ctxt->nsNr = nsNr;\n\n    localname = xmlParseQName(ctxt, &prefix);\n    if (localname == NULL) {\n\txmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,\n\t\t       \"StartTag: invalid element name\\n\");\n        return(NULL);\n    }\n    *tlen = ctxt->input->cur - ctxt->input->base - cur;\n\n    \/*\n     * Now parse the attributes, it ends up with the ending\n     *\n     * (S Attribute)* S?\n     *\/\n    SKIP_BLANKS;\n    GROW;\n    if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n        goto base_changed;\n\n    while (((RAW != '>') &&\n\t   ((RAW != '\/') || (NXT(1) != '>')) &&\n\t   (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {\n\tconst xmlChar *q = CUR_PTR;\n\tunsigned int cons = ctxt->input->consumed;\n\tint len = -1, alloc = 0;\n\n\tattname = xmlParseAttribute2(ctxt, prefix, localname,\n\t                             &aprefix, &attvalue, &len, &alloc);\n\tif ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) {\n\t    if ((attvalue != NULL) && (alloc != 0))\n\t        xmlFree(attvalue);\n\t    attvalue = NULL;\n\t    goto base_changed;\n\t}\n        if ((attname != NULL) && (attvalue != NULL)) {\n\t    if (len < 0) len = xmlStrlen(attvalue);\n            if ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {\n\t        const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);\n\t\txmlURIPtr uri;\n\n                if (URL == NULL) {\n\t\t    xmlErrMemory(ctxt, \"dictionary allocation failure\");\n\t\t    if ((attvalue != NULL) && (alloc != 0))\n\t\t\txmlFree(attvalue);\n\t\t    return(NULL);\n\t\t}\n                if (*URL != 0) {\n\t\t    uri = xmlParseURI((const char *) URL);\n\t\t    if (uri == NULL) {\n\t\t\txmlNsErr(ctxt, XML_WAR_NS_URI,\n\t\t\t         \"xmlns: '%s' is not a valid URI\\n\",\n\t\t\t\t\t   URL, NULL, NULL);\n\t\t    } else {\n\t\t\tif (uri->scheme == NULL) {\n\t\t\t    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,\n\t\t\t\t      \"xmlns: URI %s is not absolute\\n\",\n\t\t\t\t      URL, NULL, NULL);\n\t\t\t}\n\t\t\txmlFreeURI(uri);\n\t\t    }\n\t\t    if (URL == ctxt->str_xml_ns) {\n\t\t\tif (attname != ctxt->str_xml) {\n\t\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t \"xml namespace URI cannot be the default namespace\\n\",\n\t\t\t\t     NULL, NULL, NULL);\n\t\t\t}\n\t\t\tgoto skip_default_ns;\n\t\t    }\n\t\t    if ((len == 29) &&\n\t\t\t(xmlStrEqual(URL,\n\t\t\t\t BAD_CAST \"http:\/\/www.w3.org\/2000\/xmlns\/\"))) {\n\t\t\txmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t     \"reuse of the xmlns namespace name is forbidden\\n\",\n\t\t\t\t NULL, NULL, NULL);\n\t\t\tgoto skip_default_ns;\n\t\t    }\n\t\t}\n\t\t\/*\n\t\t * check that it's not a defined namespace\n\t\t *\/\n\t\tfor (j = 1;j <= nbNs;j++)\n\t\t    if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)\n\t\t\tbreak;\n\t\tif (j <= nbNs)\n\t\t    xmlErrAttributeDup(ctxt, NULL, attname);\n\t\telse\n\t\t    if (nsPush(ctxt, NULL, URL) > 0) nbNs++;\nskip_default_ns:\n\t\tif (alloc != 0) xmlFree(attvalue);\n\t\tif ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n\t\t    break;\n\t\tif (!IS_BLANK_CH(RAW)) {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n\t\t\t\t   \"attributes construct error\\n\");\n\t\t    break;\n\t\t}\n\t\tSKIP_BLANKS;\n\t\tcontinue;\n\t    }\n            if (aprefix == ctxt->str_xmlns) {\n\t        const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);\n\t\txmlURIPtr uri;\n\n                if (attname == ctxt->str_xml) {\n\t\t    if (URL != ctxt->str_xml_ns) {\n\t\t        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t         \"xml namespace prefix mapped to wrong URI\\n\",\n\t\t\t         NULL, NULL, NULL);\n\t\t    }\n\t\t    \/*\n\t\t     * Do not keep a namespace definition node\n\t\t     *\/\n\t\t    goto skip_ns;\n\t\t}\n                if (URL == ctxt->str_xml_ns) {\n\t\t    if (attname != ctxt->str_xml) {\n\t\t        xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t         \"xml namespace URI mapped to wrong prefix\\n\",\n\t\t\t         NULL, NULL, NULL);\n\t\t    }\n\t\t    goto skip_ns;\n\t\t}\n                if (attname == ctxt->str_xmlns) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t     \"redefinition of the xmlns prefix is forbidden\\n\",\n\t\t\t     NULL, NULL, NULL);\n\t\t    goto skip_ns;\n\t\t}\n\t\tif ((len == 29) &&\n\t\t    (xmlStrEqual(URL,\n\t\t                 BAD_CAST \"http:\/\/www.w3.org\/2000\/xmlns\/\"))) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t\t     \"reuse of the xmlns namespace name is forbidden\\n\",\n\t\t\t     NULL, NULL, NULL);\n\t\t    goto skip_ns;\n\t\t}\n\t\tif ((URL == NULL) || (URL[0] == 0)) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,\n\t\t             \"xmlns:%s: Empty XML namespace is not allowed\\n\",\n\t\t\t          attname, NULL, NULL);\n\t\t    goto skip_ns;\n\t\t} else {\n\t\t    uri = xmlParseURI((const char *) URL);\n\t\t    if (uri == NULL) {\n\t\t\txmlNsErr(ctxt, XML_WAR_NS_URI,\n\t\t\t     \"xmlns:%s: '%s' is not a valid URI\\n\",\n\t\t\t\t\t   attname, URL, NULL);\n\t\t    } else {\n\t\t\tif ((ctxt->pedantic) && (uri->scheme == NULL)) {\n\t\t\t    xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,\n\t\t\t\t      \"xmlns:%s: URI %s is not absolute\\n\",\n\t\t\t\t      attname, URL, NULL);\n\t\t\t}\n\t\t\txmlFreeURI(uri);\n\t\t    }\n\t\t}\n\n\t\t\/*\n\t\t * check that it's not a defined namespace\n\t\t *\/\n\t\tfor (j = 1;j <= nbNs;j++)\n\t\t    if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)\n\t\t\tbreak;\n\t\tif (j <= nbNs)\n\t\t    xmlErrAttributeDup(ctxt, aprefix, attname);\n\t\telse\n\t\t    if (nsPush(ctxt, attname, URL) > 0) nbNs++;\nskip_ns:\n\t\tif (alloc != 0) xmlFree(attvalue);\n\t\tif ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n\t\t    break;\n\t\tif (!IS_BLANK_CH(RAW)) {\n\t\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n\t\t\t\t   \"attributes construct error\\n\");\n\t\t    break;\n\t\t}\n\t\tSKIP_BLANKS;\n\t\tif ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n\t\t    goto base_changed;\n\t\tcontinue;\n\t    }\n\n\t    \/*\n\t     * Add the pair to atts\n\t     *\/\n\t    if ((atts == NULL) || (nbatts + 5 > maxatts)) {\n\t        if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {\n\t\t    if (attvalue[len] == 0)\n\t\t\txmlFree(attvalue);\n\t\t    goto failed;\n\t\t}\n\t        maxatts = ctxt->maxatts;\n\t\tatts = ctxt->atts;\n\t    }\n\t    ctxt->attallocs[nratts++] = alloc;\n\t    atts[nbatts++] = attname;\n\t    atts[nbatts++] = aprefix;\n\t    atts[nbatts++] = NULL; \/* the URI will be fetched later *\/\n\t    atts[nbatts++] = attvalue;\n\t    attvalue += len;\n\t    atts[nbatts++] = attvalue;\n\t    \/*\n\t     * tag if some deallocation is needed\n\t     *\/\n\t    if (alloc != 0) attval = 1;\n\t} else {\n\t    if ((attvalue != NULL) && (attvalue[len] == 0))\n\t\txmlFree(attvalue);\n\t}\n\nfailed:\n\n\tGROW\n        if (ctxt->instate == XML_PARSER_EOF)\n            break;\n\tif ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n\t    goto base_changed;\n\tif ((RAW == '>') || (((RAW == '\/') && (NXT(1) == '>'))))\n\t    break;\n\tif (!IS_BLANK_CH(RAW)) {\n\t    xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,\n\t\t\t   \"attributes construct error\\n\");\n\t    break;\n\t}\n\tSKIP_BLANKS;\n        if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&\n            (attname == NULL) && (attvalue == NULL)) {\n\t    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,\n\t         \"xmlParseStartTag: problem parsing attributes\\n\");\n\t    break;\n\t}\n        GROW;\n\tif ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))\n\t    goto base_changed;\n    }\n\n    \/*\n     * The attributes defaulting\n     *\/\n    if (ctxt->attsDefault != NULL) {\n        xmlDefAttrsPtr defaults;\n\n\tdefaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix);\n\tif (defaults != NULL) {\n\t    for (i = 0;i < defaults->nbAttrs;i++) {\n\t        attname = defaults->values[5 * i];\n\t\taprefix = defaults->values[5 * i + 1];\n\n                \/*\n\t\t * special work for namespaces defaulted defs\n\t\t *\/\n\t\tif ((attname == ctxt->str_xmlns) && (aprefix == NULL)) {\n\t\t    \/*\n\t\t     * check that it's not a defined namespace\n\t\t     *\/\n\t\t    for (j = 1;j <= nbNs;j++)\n\t\t        if (ctxt->nsTab[ctxt->nsNr - 2 * j] == NULL)\n\t\t\t    break;\n\t            if (j <= nbNs) continue;\n\n\t\t    nsname = xmlGetNamespace(ctxt, NULL);\n\t\t    if (nsname != defaults->values[5 * i + 2]) {\n\t\t\tif (nsPush(ctxt, NULL,\n\t\t\t           defaults->values[5 * i + 2]) > 0)\n\t\t\t    nbNs++;\n\t\t    }\n\t\t} else if (aprefix == ctxt->str_xmlns) {\n\t\t    \/*\n\t\t     * check that it's not a defined namespace\n\t\t     *\/\n\t\t    for (j = 1;j <= nbNs;j++)\n\t\t        if (ctxt->nsTab[ctxt->nsNr - 2 * j] == attname)\n\t\t\t    break;\n\t            if (j <= nbNs) continue;\n\n\t\t    nsname = xmlGetNamespace(ctxt, attname);\n\t\t    if (nsname != defaults->values[2]) {\n\t\t\tif (nsPush(ctxt, attname,\n\t\t\t           defaults->values[5 * i + 2]) > 0)\n\t\t\t    nbNs++;\n\t\t    }\n\t\t} else {\n\t\t    \/*\n\t\t     * check that it's not a defined attribute\n\t\t     *\/\n\t\t    for (j = 0;j < nbatts;j+=5) {\n\t\t\tif ((attname == atts[j]) && (aprefix == atts[j+1]))\n\t\t\t    break;\n\t\t    }\n\t\t    if (j < nbatts) continue;\n\n\t\t    if ((atts == NULL) || (nbatts + 5 > maxatts)) {\n\t\t\tif (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {\n\t\t\t    return(NULL);\n\t\t\t}\n\t\t\tmaxatts = ctxt->maxatts;\n\t\t\tatts = ctxt->atts;\n\t\t    }\n\t\t    atts[nbatts++] = attname;\n\t\t    atts[nbatts++] = aprefix;\n\t\t    if (aprefix == NULL)\n\t\t\tatts[nbatts++] = NULL;\n\t\t    else\n\t\t        atts[nbatts++] = xmlGetNamespace(ctxt, aprefix);\n\t\t    atts[nbatts++] = defaults->values[5 * i + 2];\n\t\t    atts[nbatts++] = defaults->values[5 * i + 3];\n\t\t    if ((ctxt->standalone == 1) &&\n\t\t        (defaults->values[5 * i + 4] != NULL)) {\n\t\t\txmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED,\n\t  \"standalone: attribute %s on %s defaulted from external subset\\n\",\n\t                                 attname, localname);\n\t\t    }\n\t\t    nbdef++;\n\t\t}\n\t    }\n\t}\n    }\n\n    \/*\n     * The attributes checkings\n     *\/\n    for (i = 0; i < nbatts;i += 5) {\n        \/*\n\t* The default namespace does not apply to attribute names.\n\t*\/\n\tif (atts[i + 1] != NULL) {\n\t    nsname = xmlGetNamespace(ctxt, atts[i + 1]);\n\t    if (nsname == NULL) {\n\t\txmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,\n\t\t    \"Namespace prefix %s for %s on %s is not defined\\n\",\n\t\t    atts[i + 1], atts[i], localname);\n\t    }\n\t    atts[i + 2] = nsname;\n\t} else\n\t    nsname = NULL;\n\t\/*\n\t * [ WFC: Unique Att Spec ]\n\t * No attribute name may appear more than once in the same\n\t * start-tag or empty-element tag.\n\t * As extended by the Namespace in XML REC.\n\t *\/\n        for (j = 0; j < i;j += 5) {\n\t    if (atts[i] == atts[j]) {\n\t        if (atts[i+1] == atts[j+1]) {\n\t\t    xmlErrAttributeDup(ctxt, atts[i+1], atts[i]);\n\t\t    break;\n\t\t}\n\t\tif ((nsname != NULL) && (atts[j + 2] == nsname)) {\n\t\t    xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,\n\t\t\t     \"Namespaced Attribute %s in '%s' redefined\\n\",\n\t\t\t     atts[i], nsname, NULL);\n\t\t    break;\n\t\t}\n\t    }\n\t}\n    }\n\n    nsname = xmlGetNamespace(ctxt, prefix);\n    if ((prefix != NULL) && (nsname == NULL)) {\n\txmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,\n\t         \"Namespace prefix %s on %s is not defined\\n\",\n\t\t prefix, localname, NULL);\n    }\n    *pref = prefix;\n    *URI = nsname;\n\n    \/*\n     * SAX: Start of Element !\n     *\/\n    if ((ctxt->sax != NULL) && (ctxt->sax->startElementNs != NULL) &&\n\t(!ctxt->disableSAX)) {\n\tif (nbNs > 0)\n\t    ctxt->sax->startElementNs(ctxt->userData, localname, prefix,\n\t\t\t  nsname, nbNs, &ctxt->nsTab[ctxt->nsNr - 2 * nbNs],\n\t\t\t  nbatts \/ 5, nbdef, atts);\n\telse\n\t    ctxt->sax->startElementNs(ctxt->userData, localname, prefix,\n\t                  nsname, 0, NULL, nbatts \/ 5, nbdef, atts);\n    }\n\n    \/*\n     * Free up attribute allocated strings if needed\n     *\/\n    if (attval != 0) {\n\tfor (i = 3,j = 0; j < nratts;i += 5,j++)\n\t    if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))\n\t        xmlFree((xmlChar *) atts[i]);\n    }\n\n    return(localname);\n\nbase_changed:\n    \/*\n     * the attribute strings are valid iif the base didn't changed\n     *\/\n    if (attval != 0) {\n\tfor (i = 3,j = 0; j < nratts;i += 5,j++)\n\t    if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))\n\t        xmlFree((xmlChar *) atts[i]);\n    }\n\n    \/*\n     * We can't switch from one entity to another in the middle\n     * of a start tag\n     *\/\n    if (inputNr != ctxt->inputNr) {\n        xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,\n\t\t    \"Start tag doesn't start and stop in the same entity\\n\");\n\treturn(NULL);\n    }\n\n    ctxt->input->cur = ctxt->input->base + cur;\n    ctxt->input->line = oldline;\n    ctxt->input->col = oldcol;\n    if (ctxt->wellFormed == 1) {\n\tgoto reparse;\n    }\n    return(NULL);\n}","target":1,"code_token_length":3996,"total_token_length":4232,"max_tokens_setting":6144}
+{"idx":212433,"func":"do_tag(\n    char_u\t*tag,\t\t\/\/ tag (pattern) to jump to\n    int\t\ttype,\n    int\t\tcount,\n    int\t\tforceit,\t\/\/ :ta with !\n    int\t\tverbose)\t\/\/ print \"tag not found\" message\n{\n    taggy_T\t*tagstack = curwin->w_tagstack;\n    int\t\ttagstackidx = curwin->w_tagstackidx;\n    int\t\ttagstacklen = curwin->w_tagstacklen;\n    int\t\tcur_match = 0;\n    int\t\tcur_fnum = curbuf->b_fnum;\n    int\t\toldtagstackidx = tagstackidx;\n    int\t\tprevtagstackidx = tagstackidx;\n    int\t\tprev_num_matches;\n    int\t\tnew_tag = FALSE;\n    int\t\ti;\n    int\t\tic;\n    int\t\tno_regexp = FALSE;\n    int\t\terror_cur_match = 0;\n    int\t\tsave_pos = FALSE;\n    fmark_T\tsaved_fmark;\n#ifdef FEAT_CSCOPE\n    int\t\tjumped_to_tag = FALSE;\n#endif\n    int\t\tnew_num_matches;\n    char_u\t**new_matches;\n    int\t\tuse_tagstack;\n    int\t\tskip_msg = FALSE;\n    char_u\t*buf_ffname = curbuf->b_ffname;\t    \/\/ name to use for\n\t\t\t\t\t\t    \/\/ priority computation\n    int\t\tuse_tfu = 1;\n    char_u\t*tofree = NULL;\n\n    \/\/ remember the matches for the last used tag\n    static int\t\tnum_matches = 0;\n    static int\t\tmax_num_matches = 0;  \/\/ limit used for match search\n    static char_u\t**matches = NULL;\n    static int\t\tflags;\n\n#ifdef FEAT_EVAL\n    if (tfu_in_use)\n    {\n\temsg(_(e_cannot_modify_tag_stack_within_tagfunc));\n\treturn FALSE;\n    }\n#endif\n\n#ifdef EXITFREE\n    if (type == DT_FREE)\n    {\n\t\/\/ remove the list of matches\n\tFreeWild(num_matches, matches);\n# ifdef FEAT_CSCOPE\n\tcs_free_tags();\n# endif\n\tnum_matches = 0;\n\treturn FALSE;\n    }\n#endif\n\n    if (type == DT_HELP)\n    {\n\ttype = DT_TAG;\n\tno_regexp = TRUE;\n\tuse_tfu = 0;\n    }\n\n    prev_num_matches = num_matches;\n    free_string_option(nofile_fname);\n    nofile_fname = NULL;\n\n    CLEAR_POS(&saved_fmark.mark);\t\/\/ shutup gcc 4.0\n    saved_fmark.fnum = 0;\n\n    \/*\n     * Don't add a tag to the tagstack if 'tagstack' has been reset.\n     *\/\n    if ((!p_tgst && *tag != NUL))\n    {\n\tuse_tagstack = FALSE;\n\tnew_tag = TRUE;\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t{\n\t    tagstack_clear_entry(&ptag_entry);\n\t    if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)\n\t\tgoto end_do_tag;\n\t}\n#endif\n    }\n    else\n    {\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t    use_tagstack = FALSE;\n\telse\n#endif\n\t    use_tagstack = TRUE;\n\n\t\/\/ new pattern, add to the tag stack\n\tif (*tag != NUL\n\t\t&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP\n#ifdef FEAT_QUICKFIX\n\t\t    || type == DT_LTAG\n#endif\n#ifdef FEAT_CSCOPE\n\t\t    || type == DT_CSCOPE\n#endif\n\t\t    ))\n\t{\n#if defined(FEAT_QUICKFIX)\n\t    if (g_do_tagpreview != 0)\n\t    {\n\t\tif (ptag_entry.tagname != NULL\n\t\t\t&& STRCMP(ptag_entry.tagname, tag) == 0)\n\t\t{\n\t\t    \/\/ Jumping to same tag: keep the current match, so that\n\t\t    \/\/ the CursorHold autocommand example works.\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    tagstack_clear_entry(&ptag_entry);\n\t\t    if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)\n\t\t\tgoto end_do_tag;\n\t\t}\n\t    }\n\t    else\n#endif\n\t    {\n\t\t\/*\n\t\t * If the last used entry is not at the top, delete all tag\n\t\t * stack entries above it.\n\t\t *\/\n\t\twhile (tagstackidx < tagstacklen)\n\t\t    tagstack_clear_entry(&tagstack[--tagstacklen]);\n\n\t\t\/\/ if the tagstack is full: remove oldest entry\n\t\tif (++tagstacklen > TAGSTACKSIZE)\n\t\t{\n\t\t    tagstacklen = TAGSTACKSIZE;\n\t\t    tagstack_clear_entry(&tagstack[0]);\n\t\t    for (i = 1; i < tagstacklen; ++i)\n\t\t\ttagstack[i - 1] = tagstack[i];\n\t\t    --tagstackidx;\n\t\t}\n\n\t\t\/*\n\t\t * put the tag name in the tag stack\n\t\t *\/\n\t\tif ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL)\n\t\t{\n\t\t    curwin->w_tagstacklen = tagstacklen - 1;\n\t\t    goto end_do_tag;\n\t\t}\n\t\tcurwin->w_tagstacklen = tagstacklen;\n\n\t\tsave_pos = TRUE;\t\/\/ save the cursor position below\n\t    }\n\n\t    new_tag = TRUE;\n\t}\n\telse\n\t{\n\t    if (\n#if defined(FEAT_QUICKFIX)\n\t\t    g_do_tagpreview != 0 ? ptag_entry.tagname == NULL :\n#endif\n\t\t    tagstacklen == 0)\n\t    {\n\t\t\/\/ empty stack\n\t\temsg(_(e_tag_stack_empty));\n\t\tgoto end_do_tag;\n\t    }\n\n\t    if (type == DT_POP)\t\t\/\/ go to older position\n\t    {\n#ifdef FEAT_FOLDING\n\t\tint\told_KeyTyped = KeyTyped;\n#endif\n\t\tif ((tagstackidx -= count) < 0)\n\t\t{\n\t\t    emsg(_(e_at_bottom_of_tag_stack));\n\t\t    if (tagstackidx + count == 0)\n\t\t    {\n\t\t\t\/\/ We did [num]^T from the bottom of the stack\n\t\t\ttagstackidx = 0;\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    \/\/ We weren't at the bottom of the stack, so jump all the\n\t\t    \/\/ way to the bottom now.\n\t\t    tagstackidx = 0;\n\t\t}\n\t\telse if (tagstackidx >= tagstacklen)    \/\/ count == 0?\n\t\t{\n\t\t    emsg(_(e_at_top_of_tag_stack));\n\t\t    goto end_do_tag;\n\t\t}\n\n\t\t\/\/ Make a copy of the fmark, autocommands may invalidate the\n\t\t\/\/ tagstack before it's used.\n\t\tsaved_fmark = tagstack[tagstackidx].fmark;\n\t\tif (saved_fmark.fnum != curbuf->b_fnum)\n\t\t{\n\t\t    \/*\n\t\t     * Jump to other file. If this fails (e.g. because the\n\t\t     * file was changed) keep original position in tag stack.\n\t\t     *\/\n\t\t    if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum,\n\t\t\t\t\t       GETF_SETMARK, forceit) == FAIL)\n\t\t    {\n\t\t\ttagstackidx = oldtagstackidx;  \/\/ back to old posn\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    \/\/ An BufReadPost autocommand may jump to the '\" mark, but\n\t\t    \/\/ we don't what that here.\n\t\t    curwin->w_cursor.lnum = saved_fmark.mark.lnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    setpcmark();\n\t\t    curwin->w_cursor.lnum = saved_fmark.mark.lnum;\n\t\t}\n\t\tcurwin->w_cursor.col = saved_fmark.mark.col;\n\t\tcurwin->w_set_curswant = TRUE;\n\t\tcheck_cursor();\n#ifdef FEAT_FOLDING\n\t\tif ((fdo_flags & FDO_TAG) && old_KeyTyped)\n\t\t    foldOpenCursor();\n#endif\n\n\t\t\/\/ remove the old list of matches\n\t\tFreeWild(num_matches, matches);\n#ifdef FEAT_CSCOPE\n\t\tcs_free_tags();\n#endif\n\t\tnum_matches = 0;\n\t\ttag_freematch();\n\t\tgoto end_do_tag;\n\t    }\n\n\t    if (type == DT_TAG\n#if defined(FEAT_QUICKFIX)\n\t\t    || type == DT_LTAG\n#endif\n\t       )\n\t    {\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0)\n\t\t{\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    \/\/ \":tag\" (no argument): go to newer pattern\n\t\t    save_pos = TRUE;\t\/\/ save the cursor position below\n\t\t    if ((tagstackidx += count - 1) >= tagstacklen)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Beyond the last one, just give an error message and\n\t\t\t * go to the last one.  Don't store the cursor\n\t\t\t * position.\n\t\t\t *\/\n\t\t\ttagstackidx = tagstacklen - 1;\n\t\t\temsg(_(e_at_top_of_tag_stack));\n\t\t\tsave_pos = FALSE;\n\t\t    }\n\t\t    else if (tagstackidx < 0)\t\/\/ must have been count == 0\n\t\t    {\n\t\t\temsg(_(e_at_bottom_of_tag_stack));\n\t\t\ttagstackidx = 0;\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    cur_match = tagstack[tagstackidx].cur_match;\n\t\t    cur_fnum = tagstack[tagstackidx].cur_fnum;\n\t\t}\n\t\tnew_tag = TRUE;\n\t    }\n\t    else\t\t\t\t\/\/ go to other matching tag\n\t    {\n\t\t\/\/ Save index for when selection is cancelled.\n\t\tprevtagstackidx = tagstackidx;\n\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0)\n\t\t{\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    if (--tagstackidx < 0)\n\t\t\ttagstackidx = 0;\n\t\t    cur_match = tagstack[tagstackidx].cur_match;\n\t\t    cur_fnum = tagstack[tagstackidx].cur_fnum;\n\t\t}\n\t\tswitch (type)\n\t\t{\n\t\t    case DT_FIRST: cur_match = count - 1; break;\n\t\t    case DT_SELECT:\n\t\t    case DT_JUMP:\n#ifdef FEAT_CSCOPE\n\t\t    case DT_CSCOPE:\n#endif\n\t\t    case DT_LAST:  cur_match = MAXCOL - 1; break;\n\t\t    case DT_NEXT:  cur_match += count; break;\n\t\t    case DT_PREV:  cur_match -= count; break;\n\t\t}\n\t\tif (cur_match >= MAXCOL)\n\t\t    cur_match = MAXCOL - 1;\n\t\telse if (cur_match < 0)\n\t\t{\n\t\t    emsg(_(e_cannot_go_before_first_matching_tag));\n\t\t    skip_msg = TRUE;\n\t\t    cur_match = 0;\n\t\t    cur_fnum = curbuf->b_fnum;\n\t\t}\n\t    }\n\t}\n\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t{\n\t    if (type != DT_SELECT && type != DT_JUMP)\n\t    {\n\t\tptag_entry.cur_match = cur_match;\n\t\tptag_entry.cur_fnum = cur_fnum;\n\t    }\n\t}\n\telse\n#endif\n\t{\n\t    \/*\n\t     * For \":tag [arg]\" or \":tselect\" remember position before the jump.\n\t     *\/\n\t    saved_fmark = tagstack[tagstackidx].fmark;\n\t    if (save_pos)\n\t    {\n\t\ttagstack[tagstackidx].fmark.mark = curwin->w_cursor;\n\t\ttagstack[tagstackidx].fmark.fnum = curbuf->b_fnum;\n\t    }\n\n\t    \/\/ Curwin will change in the call to jumpto_tag() if \":stag\" was\n\t    \/\/ used or an autocommand jumps to another window; store value of\n\t    \/\/ tagstackidx now.\n\t    curwin->w_tagstackidx = tagstackidx;\n\t    if (type != DT_SELECT && type != DT_JUMP)\n\t    {\n\t\tcurwin->w_tagstack[tagstackidx].cur_match = cur_match;\n\t\tcurwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum;\n\t    }\n\t}\n    }\n\n    \/\/ When not using the current buffer get the name of buffer \"cur_fnum\".\n    \/\/ Makes sure that the tag order doesn't change when using a remembered\n    \/\/ position for \"cur_match\".\n    if (cur_fnum != curbuf->b_fnum)\n    {\n\tbuf_T *buf = buflist_findnr(cur_fnum);\n\n\tif (buf != NULL)\n\t    buf_ffname = buf->b_ffname;\n    }\n\n    \/*\n     * Repeat searching for tags, when a file has not been found.\n     *\/\n    for (;;)\n    {\n\tint\tother_name;\n\tchar_u\t*name;\n\n\t\/*\n\t * When desired match not found yet, try to find it (and others).\n\t *\/\n\tif (use_tagstack)\n\t{\n\t    \/\/ make a copy, the tagstack may change in 'tagfunc'\n\t    name = vim_strsave(tagstack[tagstackidx].tagname);\n\t    vim_free(tofree);\n\t    tofree = name;\n\t}\n#if defined(FEAT_QUICKFIX)\n\telse if (g_do_tagpreview != 0)\n\t    name = ptag_entry.tagname;\n#endif\n\telse\n\t    name = tag;\n\tother_name = (tagmatchname == NULL || STRCMP(tagmatchname, name) != 0);\n\tif (new_tag\n\t\t|| (cur_match >= num_matches && max_num_matches != MAXCOL)\n\t\t|| other_name)\n\t{\n\t    if (other_name)\n\t    {\n\t\tvim_free(tagmatchname);\n\t\ttagmatchname = vim_strsave(name);\n\t    }\n\n\t    if (type == DT_SELECT || type == DT_JUMP\n#if defined(FEAT_QUICKFIX)\n\t\t|| type == DT_LTAG\n#endif\n\t\t)\n\t\tcur_match = MAXCOL - 1;\n\t    if (type == DT_TAG)\n\t\tmax_num_matches = MAXCOL;\n\t    else\n\t\tmax_num_matches = cur_match + 1;\n\n\t    \/\/ when the argument starts with '\/', use it as a regexp\n\t    if (!no_regexp && *name == '\/')\n\t    {\n\t\tflags = TAG_REGEXP;\n\t\t++name;\n\t    }\n\t    else\n\t\tflags = TAG_NOIC;\n\n#ifdef FEAT_CSCOPE\n\t    if (type == DT_CSCOPE)\n\t\tflags = TAG_CSCOPE;\n#endif\n\t    if (verbose)\n\t\tflags |= TAG_VERBOSE;\n\n\t    if (!use_tfu)\n\t\tflags |= TAG_NO_TAGFUNC;\n\n\t    if (find_tags(name, &new_num_matches, &new_matches, flags,\n\t\t\t\t\t    max_num_matches, buf_ffname) == OK\n\t\t    && new_num_matches < max_num_matches)\n\t\tmax_num_matches = MAXCOL; \/\/ If less than max_num_matches\n\t\t\t\t\t  \/\/ found: all matches found.\n\n\t    \/\/ If there already were some matches for the same name, move them\n\t    \/\/ to the start.  Avoids that the order changes when using\n\t    \/\/ \":tnext\" and jumping to another file.\n\t    if (!new_tag && !other_name)\n\t    {\n\t\tint\t    j, k;\n\t\tint\t    idx = 0;\n\t\ttagptrs_T   tagp, tagp2;\n\n\t\t\/\/ Find the position of each old match in the new list.  Need\n\t\t\/\/ to use parse_match() to find the tag line.\n\t\tfor (j = 0; j < num_matches; ++j)\n\t\t{\n\t\t    parse_match(matches[j], &tagp);\n\t\t    for (i = idx; i < new_num_matches; ++i)\n\t\t    {\n\t\t\tparse_match(new_matches[i], &tagp2);\n\t\t\tif (STRCMP(tagp.tagname, tagp2.tagname) == 0)\n\t\t\t{\n\t\t\t    char_u *p = new_matches[i];\n\t\t\t    for (k = i; k > idx; --k)\n\t\t\t\tnew_matches[k] = new_matches[k - 1];\n\t\t\t    new_matches[idx++] = p;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    FreeWild(num_matches, matches);\n\t    num_matches = new_num_matches;\n\t    matches = new_matches;\n\t}\n\n\tif (num_matches <= 0)\n\t{\n\t    if (verbose)\n\t\tsemsg(_(e_tag_not_found_str), name);\n#if defined(FEAT_QUICKFIX)\n\t    g_do_tagpreview = 0;\n#endif\n\t}\n\telse\n\t{\n\t    int ask_for_selection = FALSE;\n\n#ifdef FEAT_CSCOPE\n\t    if (type == DT_CSCOPE && num_matches > 1)\n\t    {\n\t\tcs_print_tags();\n\t\task_for_selection = TRUE;\n\t    }\n\t    else\n#endif\n\t    if (type == DT_TAG && *tag != NUL)\n\t\t\/\/ If a count is supplied to the \":tag <name>\" command, then\n\t\t\/\/ jump to count'th matching tag.\n\t\tcur_match = count > 0 ? count - 1 : 0;\n\t    else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1))\n\t    {\n\t\tprint_tag_list(new_tag, use_tagstack, num_matches, matches);\n\t\task_for_selection = TRUE;\n\t    }\n#if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)\n\t    else if (type == DT_LTAG)\n\t    {\n\t\tif (add_llist_tags(tag, num_matches, matches) == FAIL)\n\t\t    goto end_do_tag;\n\t\tcur_match = 0;\t\t\/\/ Jump to the first tag\n\t    }\n#endif\n\n\t    if (ask_for_selection == TRUE)\n\t    {\n\t\t\/*\n\t\t * Ask to select a tag from the list.\n\t\t *\/\n\t\ti = prompt_for_number(NULL);\n\t\tif (i <= 0 || i > num_matches || got_int)\n\t\t{\n\t\t    \/\/ no valid choice: don't change anything\n\t\t    if (use_tagstack)\n\t\t    {\n\t\t\ttagstack[tagstackidx].fmark = saved_fmark;\n\t\t\ttagstackidx = prevtagstackidx;\n\t\t    }\n#ifdef FEAT_CSCOPE\n\t\t    cs_free_tags();\n\t\t    jumped_to_tag = TRUE;\n#endif\n\t\t    break;\n\t\t}\n\t\tcur_match = i - 1;\n\t    }\n\n\t    if (cur_match >= num_matches)\n\t    {\n\t\t\/\/ Avoid giving this error when a file wasn't found and we're\n\t\t\/\/ looking for a match in another file, which wasn't found.\n\t\t\/\/ There will be an emsg(\"file doesn't exist\") below then.\n\t\tif ((type == DT_NEXT || type == DT_FIRST)\n\t\t\t\t\t\t      && nofile_fname == NULL)\n\t\t{\n\t\t    if (num_matches == 1)\n\t\t\temsg(_(e_there_is_only_one_matching_tag));\n\t\t    else\n\t\t\temsg(_(e_cannot_go_beyond_last_matching_tag));\n\t\t    skip_msg = TRUE;\n\t\t}\n\t\tcur_match = num_matches - 1;\n\t    }\n\t    if (use_tagstack)\n\t    {\n\t\ttagptrs_T   tagp;\n\n\t\ttagstack[tagstackidx].cur_match = cur_match;\n\t\ttagstack[tagstackidx].cur_fnum = cur_fnum;\n\n\t\t\/\/ store user-provided data originating from tagfunc\n\t\tif (use_tfu && parse_match(matches[cur_match], &tagp) == OK\n\t\t\t&& tagp.user_data)\n\t\t{\n\t\t    VIM_CLEAR(tagstack[tagstackidx].user_data);\n\t\t    tagstack[tagstackidx].user_data = vim_strnsave(\n\t\t\t  tagp.user_data, tagp.user_data_end - tagp.user_data);\n\t\t}\n\n\t\t++tagstackidx;\n\t    }\n#if defined(FEAT_QUICKFIX)\n\t    else if (g_do_tagpreview != 0)\n\t    {\n\t\tptag_entry.cur_match = cur_match;\n\t\tptag_entry.cur_fnum = cur_fnum;\n\t    }\n#endif\n\n\t    \/*\n\t     * Only when going to try the next match, report that the previous\n\t     * file didn't exist.  Otherwise an emsg() is given below.\n\t     *\/\n\t    if (nofile_fname != NULL && error_cur_match != cur_match)\n\t\tsmsg(_(\"File \\\"%s\\\" does not exist\"), nofile_fname);\n\n\n\t    ic = (matches[cur_match][0] & MT_IC_OFF);\n\t    if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP\n#ifdef FEAT_CSCOPE\n\t\t&& type != DT_CSCOPE\n#endif\n\t\t&& (num_matches > 1 || ic)\n\t\t&& !skip_msg)\n\t    {\n\t\t\/\/ Give an indication of the number of matching tags\n\t\tsprintf((char *)IObuff, _(\"tag %d of %d%s\"),\n\t\t\t\tcur_match + 1,\n\t\t\t\tnum_matches,\n\t\t\t\tmax_num_matches != MAXCOL ? _(\" or more\") : \"\");\n\t\tif (ic)\n\t\t    STRCAT(IObuff, _(\"  Using tag with different case!\"));\n\t\tif ((num_matches > prev_num_matches || new_tag)\n\t\t\t\t\t\t\t   && num_matches > 1)\n\t\t{\n\t\t    if (ic)\n\t\t\tmsg_attr((char *)IObuff, HL_ATTR(HLF_W));\n\t\t    else\n\t\t\tmsg((char *)IObuff);\n\t\t    msg_scroll = TRUE;\t\/\/ don't overwrite this message\n\t\t}\n\t\telse\n\t\t    give_warning(IObuff, ic);\n\t\tif (ic && !msg_scrolled && msg_silent == 0)\n\t\t{\n\t\t    out_flush();\n\t\t    ui_delay(1007L, TRUE);\n\t\t}\n\t    }\n\n#if defined(FEAT_EVAL)\n\t    \/\/ Let the SwapExists event know what tag we are jumping to.\n\t    vim_snprintf((char *)IObuff, IOSIZE, \":ta %s\\r\", name);\n\t    set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);\n#endif\n\n\t    \/*\n\t     * Jump to the desired match.\n\t     *\/\n\t    i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE);\n\n#if defined(FEAT_EVAL)\n\t    set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);\n#endif\n\n\t    if (i == NOTAGFILE)\n\t    {\n\t\t\/\/ File not found: try again with another matching tag\n\t\tif ((type == DT_PREV && cur_match > 0)\n\t\t\t|| ((type == DT_TAG || type == DT_NEXT\n\t\t\t\t\t\t\t  || type == DT_FIRST)\n\t\t\t    && (max_num_matches != MAXCOL\n\t\t\t\t\t     || cur_match < num_matches - 1)))\n\t\t{\n\t\t    error_cur_match = cur_match;\n\t\t    if (use_tagstack)\n\t\t\t--tagstackidx;\n\t\t    if (type == DT_PREV)\n\t\t\t--cur_match;\n\t\t    else\n\t\t    {\n\t\t\ttype = DT_NEXT;\n\t\t\t++cur_match;\n\t\t    }\n\t\t    continue;\n\t\t}\n\t\tsemsg(_(e_file_str_does_not_exist), nofile_fname);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ We may have jumped to another window, check that\n\t\t\/\/ tagstackidx is still valid.\n\t\tif (use_tagstack && tagstackidx > curwin->w_tagstacklen)\n\t\t    tagstackidx = curwin->w_tagstackidx;\n#ifdef FEAT_CSCOPE\n\t\tjumped_to_tag = TRUE;\n#endif\n\t    }\n\t}\n\tbreak;\n    }\n\nend_do_tag:\n    \/\/ Only store the new index when using the tagstack and it's valid.\n    if (use_tagstack && tagstackidx <= curwin->w_tagstacklen)\n\tcurwin->w_tagstackidx = tagstackidx;\n    postponed_split = 0;\t\/\/ don't split next time\n# ifdef FEAT_QUICKFIX\n    g_do_tagpreview = 0;\t\/\/ don't do tag preview next time\n# endif\n\n    vim_free(tofree);\n#ifdef FEAT_CSCOPE\n    return jumped_to_tag;\n#else\n    return FALSE;\n#endif\n}","target":1,"code_token_length":5103,"total_token_length":5339,"max_tokens_setting":6144}
+{"idx":384677,"func":"negotiate_handshake_newstyle_options (void)\n{\n  GET_CONN;\n  struct nbd_new_option new_option;\n  size_t nr_options;\n  bool list_seen = false;\n  uint64_t version;\n  uint32_t option;\n  uint32_t optlen;\n  struct nbd_export_name_option_reply handshake_finish;\n  const char *optname;\n  uint64_t exportsize;\n  struct backend *b;\n\n  for (nr_options = MAX_NR_OPTIONS; nr_options > 0; --nr_options) {\n    CLEANUP_FREE char *data = NULL;\n\n    if (conn_recv_full (&new_option, sizeof new_option,\n                        \"reading option: conn->recv: %m\") == -1)\n      return -1;\n\n    version = be64toh (new_option.version);\n    if (version != NBD_NEW_VERSION) {\n      nbdkit_error (\"unknown option version %\" PRIx64\n                    \", expecting %\" PRIx64,\n                    version, NBD_NEW_VERSION);\n      return -1;\n    }\n\n    \/* There is a maximum option length we will accept, regardless\n     * of the option type.\n     *\/\n    optlen = be32toh (new_option.optlen);\n    if (optlen > MAX_REQUEST_SIZE) {\n      nbdkit_error (\"client option data too long (%\" PRIu32 \")\", optlen);\n      return -1;\n    }\n    data = malloc (optlen + 1); \/* Allowing a trailing NUL helps some uses *\/\n    if (data == NULL) {\n      nbdkit_error (\"malloc: %m\");\n      return -1;\n    }\n\n    option = be32toh (new_option.option);\n    optname = name_of_nbd_opt (option);\n\n    \/* If the client lacks fixed newstyle support, it should only send\n     * NBD_OPT_EXPORT_NAME.\n     *\/\n    if (!(conn->cflags & NBD_FLAG_FIXED_NEWSTYLE) &&\n        option != NBD_OPT_EXPORT_NAME) {\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID))\n        return -1;\n      continue;\n    }\n\n    \/* In --tls=require \/ FORCEDTLS mode the only options allowed\n     * before TLS negotiation are NBD_OPT_ABORT and NBD_OPT_STARTTLS.\n     *\/\n    if (tls == 2 && !conn->using_tls &&\n        !(option == NBD_OPT_ABORT || option == NBD_OPT_STARTTLS)) {\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_TLS_REQD))\n        return -1;\n      continue;\n    }\n\n    switch (option) {\n    case NBD_OPT_EXPORT_NAME:\n      if (conn_recv_full (data, optlen,\n                          \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n        return -1;\n      if (check_export_name (option, data, optlen, optlen) == -1)\n        return -1;\n\n      \/* We have to finish the handshake by sending handshake_finish.\n       * On failure, we have to disconnect.\n       *\/\n      if (finish_newstyle_options (&exportsize, data, optlen) == -1)\n        return -1;\n\n      memset (&handshake_finish, 0, sizeof handshake_finish);\n      handshake_finish.exportsize = htobe64 (exportsize);\n      handshake_finish.eflags = htobe16 (conn->eflags);\n\n      if (conn->send (&handshake_finish,\n                      (conn->cflags & NBD_FLAG_NO_ZEROES)\n                      ? offsetof (struct nbd_export_name_option_reply, zeroes)\n                      : sizeof handshake_finish, 0) == -1) {\n        nbdkit_error (\"write: %s: %m\", optname);\n        return -1;\n      }\n      break;\n\n    case NBD_OPT_ABORT:\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n      debug (\"client sent %s to abort the connection\",\n             name_of_nbd_opt (option));\n      return -1;\n\n    case NBD_OPT_LIST:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      if (list_seen) {\n        debug (\"newstyle negotiation: %s: export list already advertised\",\n               name_of_nbd_opt (option));\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)\n          return -1;\n        continue;\n      }\n      else {\n        \/* Send back the exportname list. *\/\n        debug (\"newstyle negotiation: %s: advertising exports\",\n               name_of_nbd_opt (option));\n        if (send_newstyle_option_reply_exportnames (option, &nr_options) == -1)\n          return -1;\n        list_seen = true;\n      }\n      break;\n\n    case NBD_OPT_STARTTLS:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      if (tls == 0) {           \/* --tls=off (NOTLS mode). *\/\n#ifdef HAVE_GNUTLS\n#define NO_TLS_REPLY NBD_REP_ERR_POLICY\n#else\n#define NO_TLS_REPLY NBD_REP_ERR_UNSUP\n#endif\n        if (send_newstyle_option_reply (option, NO_TLS_REPLY) == -1)\n          return -1;\n      }\n      else \/* --tls=on or --tls=require *\/ {\n        \/* We can't upgrade to TLS twice on the same connection. *\/\n        if (conn->using_tls) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)\n            return -1;\n          continue;\n        }\n\n        \/* We have to send the (unencrypted) reply before starting\n         * the handshake.\n         *\/\n        if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n          return -1;\n\n        \/* Upgrade the connection to TLS.  Also performs access control. *\/\n        if (crypto_negotiate_tls (conn->sockin, conn->sockout) == -1)\n          return -1;\n        conn->using_tls = true;\n        debug (\"using TLS on this connection\");\n        \/* Wipe out any cached state. *\/\n        conn->structured_replies = false;\n        free (conn->exportname_from_set_meta_context);\n        conn->exportname_from_set_meta_context = NULL;\n        conn->meta_context_base_allocation = false;\n        for_each_backend (b) {\n          free (conn->default_exportname[b->i]);\n          conn->default_exportname[b->i] = NULL;\n        }\n      }\n      break;\n\n    case NBD_OPT_INFO:\n    case NBD_OPT_GO:\n      if (conn_recv_full (data, optlen, \"read: %s: %m\", optname) == -1)\n        return -1;\n\n      if (optlen < 6) { \/* 32 bit export length + 16 bit nr info *\/\n        debug (\"newstyle negotiation: %s option length < 6\", optname);\n\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        continue;\n      }\n\n      {\n        uint32_t exportnamelen;\n        uint16_t nrinfos;\n        uint16_t info;\n        size_t i;\n\n        \/* Validate the name length and number of INFO requests. *\/\n        memcpy (&exportnamelen, &data[0], 4);\n        exportnamelen = be32toh (exportnamelen);\n        if (exportnamelen > optlen-6 \/* NB optlen >= 6, see above *\/) {\n          debug (\"newstyle negotiation: %s: export name too long\", optname);\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n        memcpy (&nrinfos, &data[exportnamelen+4], 2);\n        nrinfos = be16toh (nrinfos);\n        if (optlen != 4 + exportnamelen + 2 + 2*nrinfos) {\n          debug (\"newstyle negotiation: %s: \"\n                 \"number of information requests incorrect\", optname);\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* As with NBD_OPT_EXPORT_NAME we print the export name and\n         * save it in the connection.  If an earlier\n         * NBD_OPT_SET_META_CONTEXT used an export name, it must match\n         * or else we drop the support for that context.\n         *\/\n        if (check_export_name (option, &data[4], exportnamelen,\n                               optlen - 6) == -1) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* The spec is confusing, but it is required that we send back\n         * NBD_INFO_EXPORT, even if the client did not request it!\n         * qemu client in particular does not request this, but will\n         * fail if we don't send it.  Note that if .open fails, but we\n         * succeed at .close, then we merely return an error to the\n         * client and let them try another NBD_OPT, rather than\n         * disconnecting.\n         *\/\n        if (finish_newstyle_options (&exportsize,\n                                     &data[4], exportnamelen) == -1) {\n          if (conn->top_context) {\n            if (backend_finalize (conn->top_context) == -1)\n              return -1;\n            backend_close (conn->top_context);\n            conn->top_context = NULL;\n          }\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_UNKNOWN) == -1)\n            return -1;\n          continue;\n        }\n\n        if (send_newstyle_option_reply_info_export (option,\n                                                    NBD_REP_INFO,\n                                                    NBD_INFO_EXPORT,\n                                                    exportsize) == -1)\n          return -1;\n\n        \/* For now we send NBD_INFO_NAME and NBD_INFO_DESCRIPTION if\n         * requested, and ignore all other info requests (including\n         * NBD_INFO_EXPORT if it was requested, because we replied\n         * already above).\n         *\/\n        for (i = 0; i < nrinfos; ++i) {\n          memcpy (&info, &data[4 + exportnamelen + 2 + i*2], 2);\n          info = be16toh (info);\n          switch (info) {\n          case NBD_INFO_EXPORT: \/* ignore - reply sent above *\/ break;\n          case NBD_INFO_NAME:\n            {\n              const char *name = &data[4];\n              size_t namelen = exportnamelen;\n\n              if (exportnamelen == 0) {\n                name = backend_default_export (top, read_only);\n                if (!name) {\n                  debug (\"newstyle negotiation: %s: \"\n                         \"NBD_INFO_NAME: no name to send\", optname);\n                  break;\n                }\n                namelen = -1;\n              }\n              if (send_newstyle_option_reply_info_str (option,\n                                                       NBD_REP_INFO,\n                                                       NBD_INFO_NAME,\n                                                       name, namelen) == -1)\n                return -1;\n            }\n            break;\n          case NBD_INFO_DESCRIPTION:\n            {\n              const char *desc = backend_export_description (conn->top_context);\n\n              if (!desc) {\n                debug (\"newstyle negotiation: %s: \"\n                       \"NBD_INFO_DESCRIPTION: no description to send\",\n                       optname);\n                break;\n              }\n              if (send_newstyle_option_reply_info_str (option,\n                                                       NBD_REP_INFO,\n                                                       NBD_INFO_DESCRIPTION,\n                                                       desc, -1) == -1)\n                return -1;\n            }\n            break;\n          default:\n            debug (\"newstyle negotiation: %s: \"\n                   \"ignoring NBD_INFO_* request %u (%s)\",\n                   optname, (unsigned) info, name_of_nbd_info (info));\n            break;\n          }\n        }\n      }\n\n      \/* Unlike NBD_OPT_EXPORT_NAME, NBD_OPT_GO sends back an ACK\n       * or ERROR packet.  If this was NBD_OPT_LIST, call .close.\n       *\/\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n\n      if (option == NBD_OPT_INFO) {\n        if (backend_finalize (conn->top_context) == -1)\n          return -1;\n        backend_close (conn->top_context);\n        conn->top_context = NULL;\n      }\n\n      break;\n\n    case NBD_OPT_STRUCTURED_REPLY:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      debug (\"newstyle negotiation: %s: client requested structured replies\",\n             name_of_nbd_opt (option));\n\n      if (no_sr) {\n        \/* Must fail with ERR_UNSUP for qemu 4.2 to remain happy;\n         * but failing with ERR_POLICY would have been nicer.\n         *\/\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_UNSUP) == -1)\n          return -1;\n        debug (\"newstyle negotiation: %s: structured replies are disabled\",\n               name_of_nbd_opt (option));\n        break;\n      }\n\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n\n      conn->structured_replies = true;\n      break;\n\n    case NBD_OPT_LIST_META_CONTEXT:\n    case NBD_OPT_SET_META_CONTEXT:\n      {\n        uint32_t opt_index;\n        uint32_t exportnamelen;\n        uint32_t nr_queries;\n        uint32_t querylen;\n        const char *what;\n\n        if (conn_recv_full (data, optlen, \"read: %s: %m\", optname) == -1)\n          return -1;\n\n        \/* Note that we support base:allocation whether or not the plugin\n         * supports can_extents.\n         *\/\n        if (!conn->structured_replies) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* Minimum length of the option payload is:\n         *   32 bit export name length followed by empty export name\n         * + 32 bit number of queries followed by no queries\n         * = 8 bytes.\n         *\/\n        what = \"optlen < 8\";\n        if (optlen < 8) {\n        opt_meta_invalid_option_len:\n          debug (\"newstyle negotiation: %s: invalid option length: %s\",\n                 optname, what);\n\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        memcpy (&exportnamelen, &data[0], 4);\n        exportnamelen = be32toh (exportnamelen);\n        what = \"validating export name\";\n        if (check_export_name (option, &data[4], exportnamelen,\n                               optlen - 8) == -1)\n          goto opt_meta_invalid_option_len;\n\n        \/* Remember the export name: the NBD spec says that if the client\n         * later uses NBD_OPT_GO on a different export, then the context\n         * returned here is not usable.\n         *\/\n        if (option == NBD_OPT_SET_META_CONTEXT) {\n          conn->exportname_from_set_meta_context =\n            strndup (&data[4], exportnamelen);\n          if (conn->exportname_from_set_meta_context == NULL) {\n            nbdkit_error (\"malloc: %m\");\n            return -1;\n          }\n        }\n\n        opt_index = 4 + exportnamelen;\n\n        \/* Read the number of queries. *\/\n        what = \"reading number of queries\";\n        if (opt_index+4 > optlen)\n          goto opt_meta_invalid_option_len;\n        memcpy (&nr_queries, &data[opt_index], 4);\n        nr_queries = be32toh (nr_queries);\n        opt_index += 4;\n\n        \/* for LIST: nr_queries == 0 means return all meta contexts\n         * for SET: nr_queries == 0 means reset all contexts\n         *\/\n        debug (\"newstyle negotiation: %s: %s count: %d\", optname,\n               option == NBD_OPT_LIST_META_CONTEXT ? \"query\" : \"set\",\n               nr_queries);\n        if (option == NBD_OPT_SET_META_CONTEXT)\n          conn->meta_context_base_allocation = false;\n        if (nr_queries == 0) {\n          if (option == NBD_OPT_LIST_META_CONTEXT) {\n            if (send_newstyle_option_reply_meta_context (option,\n                                                         NBD_REP_META_CONTEXT,\n                                                         0, \"base:allocation\")\n                == -1)\n              return -1;\n          }\n\n          if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n            return -1;\n        }\n        else {\n          \/* Read and answer each query. *\/\n          while (nr_queries > 0) {\n            what = \"reading query string length\";\n            if (opt_index+4 > optlen)\n              goto opt_meta_invalid_option_len;\n            memcpy (&querylen, &data[opt_index], 4);\n            querylen = be32toh (querylen);\n            opt_index += 4;\n            what = \"reading query string\";\n            if (check_string (option, &data[opt_index], querylen,\n                              optlen - opt_index, \"meta context query\") == -1)\n              goto opt_meta_invalid_option_len;\n\n            debug (\"newstyle negotiation: %s: %s %.*s\",\n                   optname,\n                   option == NBD_OPT_LIST_META_CONTEXT ? \"query\" : \"set\",\n                   (int) querylen, &data[opt_index]);\n\n            \/* For LIST, \"base:\" returns all supported contexts in the\n             * base namespace.  We only support \"base:allocation\".\n             *\/\n            if (option == NBD_OPT_LIST_META_CONTEXT &&\n                querylen == 5 &&\n                strncmp (&data[opt_index], \"base:\", 5) == 0) {\n              if (send_newstyle_option_reply_meta_context\n                  (option, NBD_REP_META_CONTEXT,\n                   0, \"base:allocation\") == -1)\n                return -1;\n            }\n            \/* \"base:allocation\" requested by name. *\/\n            else if (querylen == 15 &&\n                     strncmp (&data[opt_index], \"base:allocation\", 15) == 0) {\n              if (send_newstyle_option_reply_meta_context\n                  (option, NBD_REP_META_CONTEXT,\n                   option == NBD_OPT_SET_META_CONTEXT\n                   ? base_allocation_id : 0,\n                   \"base:allocation\") == -1)\n                return -1;\n              if (option == NBD_OPT_SET_META_CONTEXT)\n                conn->meta_context_base_allocation = true;\n            }\n            \/* Every other query must be ignored. *\/\n\n            opt_index += querylen;\n            nr_queries--;\n          }\n          if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n            return -1;\n        }\n        debug (\"newstyle negotiation: %s: reply complete\", optname);\n      }\n      break;\n\n    default:\n      \/* Unknown option. *\/\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_UNSUP) == -1)\n        return -1;\n      if (conn_recv_full (data, optlen,\n                          \"reading unknown option data: conn->recv: %m\") == -1)\n        return -1;\n    }\n\n    \/* Note, since it's not very clear from the protocol doc, that the\n     * client must send NBD_OPT_EXPORT_NAME or NBD_OPT_GO last, and\n     * that ends option negotiation.\n     *\/\n    if (option == NBD_OPT_EXPORT_NAME || option == NBD_OPT_GO)\n      break;\n  }\n\n  if (nr_options == 0) {\n    nbdkit_error (\"client spent too much time negotiating without selecting \"\n                  \"an export\");\n    return -1;\n  }\n\n  \/* In --tls=require \/ FORCEDTLS mode, we must have upgraded to TLS\n   * by the time we finish option negotiation.  If not, give up.\n   *\/\n  if (tls == 2 && !conn->using_tls) {\n    nbdkit_error (\"non-TLS client tried to connect in --tls=require mode\");\n    return -1;\n  }\n\n  return 0;\n}","target":0,"code_token_length":4585,"total_token_length":4821,"max_tokens_setting":6144}
+{"idx":231690,"func":"void onServerReadDataFromOpen(\n    QuicServerConnectionState& conn,\n    ServerEvents::ReadData& readData) {\n  CHECK_EQ(conn.state, ServerState::Open);\n  \/\/ Don't bother parsing if the data is empty.\n  if (!readData.networkData.data ||\n      readData.networkData.data->computeChainDataLength() == 0) {\n    return;\n  }\n  if (!conn.readCodec) {\n    \/\/ First packet from the peer\n    folly::io::Cursor cursor(readData.networkData.data.get());\n    auto initialByte = cursor.readBE<uint8_t>();\n    auto parsedLongHeader = parseLongHeaderInvariant(initialByte, cursor);\n    if (!parsedLongHeader) {\n      VLOG(4) << \"Could not parse initial packet header\";\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(\n            0,\n            QuicTransportStatsCallback::toString(\n                PacketDropReason::PARSE_ERROR));\n      }\n      QUIC_STATS(\n          conn.statsCallback, onPacketDropped, PacketDropReason::PARSE_ERROR);\n      return;\n    }\n    QuicVersion version = parsedLongHeader->invariant.version;\n    if (version == QuicVersion::VERSION_NEGOTIATION) {\n      VLOG(4) << \"Server droppiong VN packet\";\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(\n            0,\n            QuicTransportStatsCallback::toString(\n                PacketDropReason::INVALID_PACKET));\n      }\n      QUIC_STATS(\n          conn.statsCallback,\n          onPacketDropped,\n          PacketDropReason::INVALID_PACKET);\n      return;\n    }\n\n    const auto& clientConnectionId = parsedLongHeader->invariant.srcConnId;\n    const auto& initialDestinationConnectionId =\n        parsedLongHeader->invariant.dstConnId;\n\n    if (initialDestinationConnectionId.size() < kDefaultConnectionIdSize) {\n      VLOG(4) << \"Initial connectionid too small\";\n      if (conn.qLogger) {\n        conn.qLogger->addPacketDrop(\n            0,\n            QuicTransportStatsCallback::toString(\n                PacketDropReason::INITIAL_CONNID_SMALL));\n      }\n      QUIC_STATS(\n          conn.statsCallback,\n          onPacketDropped,\n          PacketDropReason::INITIAL_CONNID_SMALL);\n      return;\n    }\n\n    CHECK(conn.connIdAlgo) << \"ConnectionIdAlgo is not set.\";\n    CHECK(!conn.serverConnectionId.has_value());\n    \/\/ serverConnIdParams must be set by the QuicServerTransport\n    CHECK(conn.serverConnIdParams);\n\n    auto newServerConnIdData = conn.createAndAddNewSelfConnId();\n    CHECK(newServerConnIdData.has_value());\n    conn.serverConnectionId = newServerConnIdData->connId;\n\n    QUIC_STATS(conn.statsCallback, onStatelessReset);\n    conn.serverHandshakeLayer->accept(\n        std::make_shared<ServerTransportParametersExtension>(\n            version,\n            conn.transportSettings.advertisedInitialConnectionWindowSize,\n            conn.transportSettings.advertisedInitialBidiLocalStreamWindowSize,\n            conn.transportSettings.advertisedInitialBidiRemoteStreamWindowSize,\n            conn.transportSettings.advertisedInitialUniStreamWindowSize,\n            conn.transportSettings.advertisedInitialMaxStreamsBidi,\n            conn.transportSettings.advertisedInitialMaxStreamsUni,\n            conn.transportSettings.idleTimeout,\n            conn.transportSettings.ackDelayExponent,\n            conn.transportSettings.maxRecvPacketSize,\n            conn.transportSettings.partialReliabilityEnabled,\n            *newServerConnIdData->token,\n            conn.serverConnectionId.value(),\n            initialDestinationConnectionId));\n    conn.transportParametersEncoded = true;\n    const CryptoFactory& cryptoFactory =\n        conn.serverHandshakeLayer->getCryptoFactory();\n    conn.readCodec = std::make_unique<QuicReadCodec>(QuicNodeType::Server);\n    conn.readCodec->setInitialReadCipher(cryptoFactory.getClientInitialCipher(\n        initialDestinationConnectionId, version));\n    conn.readCodec->setClientConnectionId(clientConnectionId);\n    conn.readCodec->setServerConnectionId(*conn.serverConnectionId);\n    if (conn.qLogger) {\n      conn.qLogger->setScid(conn.serverConnectionId);\n      conn.qLogger->setDcid(initialDestinationConnectionId);\n    }\n    conn.readCodec->setCodecParameters(\n        CodecParameters(conn.peerAckDelayExponent, version));\n    conn.initialWriteCipher = cryptoFactory.getServerInitialCipher(\n        initialDestinationConnectionId, version);\n\n    conn.readCodec->setInitialHeaderCipher(\n        cryptoFactory.makeClientInitialHeaderCipher(\n            initialDestinationConnectionId, version));\n    conn.initialHeaderCipher = cryptoFactory.makeServerInitialHeaderCipher(\n        initialDestinationConnectionId, version);\n    conn.peerAddress = conn.originalPeerAddress;\n  }\n  BufQueue udpData;\n  udpData.append(std::move(readData.networkData.data));\n  for (uint16_t processedPackets = 0;\n       !udpData.empty() && processedPackets < kMaxNumCoalescedPackets;\n       processedPackets++) {\n    size_t dataSize = udpData.chainLength();\n    auto parsedPacket = conn.readCodec->parsePacket(udpData, conn.ackStates);\n    size_t packetSize = dataSize - udpData.chainLength();\n\n    switch (parsedPacket.type()) {\n      case CodecResult::Type::CIPHER_UNAVAILABLE: {\n        handleCipherUnavailable(\n            parsedPacket.cipherUnavailable(), conn, packetSize, readData);\n        break;\n      }\n      case CodecResult::Type::RETRY: {\n        VLOG(10) << \"drop because the server is not supposed to \"\n                 << \"receive a retry \" << conn;\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(packetSize, kRetry);\n        }\n        QUIC_TRACE(packet_drop, conn, \"retry\");\n        break;\n      }\n      case CodecResult::Type::STATELESS_RESET: {\n        VLOG(10) << \"drop because reset \" << conn;\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(packetSize, kReset);\n        }\n        QUIC_TRACE(packet_drop, conn, \"reset\");\n        break;\n      }\n      case CodecResult::Type::NOTHING: {\n        VLOG(10) << \"drop cipher unavailable, no data \" << conn;\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(packetSize, kCipherUnavailable);\n        }\n        QUIC_TRACE(packet_drop, conn, \"cipher_unavailable\");\n        break;\n      }\n      case CodecResult::Type::REGULAR_PACKET:\n        break;\n    }\n\n    RegularQuicPacket* regularOptional = parsedPacket.regularPacket();\n    if (!regularOptional) {\n      \/\/ We were unable to parse the packet, drop for now. All the drop reasons\n      \/\/ should have already been logged into QLogger and QuicTrace inside the\n      \/\/ previous switch-case block. We just need to update QUIC_STATS here.\n      VLOG(10) << \"Not able to parse QUIC packet \" << conn;\n      QUIC_STATS(\n          conn.statsCallback, onPacketDropped, PacketDropReason::PARSE_ERROR);\n      continue;\n    }\n\n    auto protectionLevel = regularOptional->header.getProtectionType();\n    auto encryptionLevel = protectionTypeToEncryptionLevel(protectionLevel);\n\n    auto packetNum = regularOptional->header.getPacketSequenceNum();\n    auto packetNumberSpace = regularOptional->header.getPacketNumberSpace();\n\n    \/\/ TODO: enforce constraints on other protection levels.\n    auto& regularPacket = *regularOptional;\n\n    bool isProtectedPacket = protectionLevel == ProtectionType::ZeroRtt ||\n        protectionLevel == ProtectionType::KeyPhaseZero ||\n        protectionLevel == ProtectionType::KeyPhaseOne;\n\n    if (!isProtectedPacket) {\n      for (auto& quicFrame : regularPacket.frames) {\n        auto isPadding = quicFrame.asPaddingFrame();\n        auto isAck = quicFrame.asReadAckFrame();\n        auto isClose = quicFrame.asConnectionCloseFrame();\n        auto isCrypto = quicFrame.asReadCryptoFrame();\n        auto isPing = quicFrame.asPingFrame();\n        \/\/ TODO: add path challenge and response\n        if (!isPadding && !isAck && !isClose && !isCrypto && !isPing) {\n          QUIC_STATS(\n              conn.statsCallback,\n              onPacketDropped,\n              PacketDropReason::PROTOCOL_VIOLATION);\n          if (conn.qLogger) {\n            conn.qLogger->addPacketDrop(\n                packetSize,\n                QuicTransportStatsCallback::toString(\n                    PacketDropReason::PROTOCOL_VIOLATION));\n          }\n          throw QuicTransportException(\n              \"Invalid frame\", TransportErrorCode::PROTOCOL_VIOLATION);\n        }\n      }\n    }\n\n    CHECK(conn.clientConnectionId);\n    if (conn.qLogger) {\n      conn.qLogger->addPacket(regularPacket, packetSize);\n    }\n    \/\/ We assume that the higher layer takes care of validating that the version\n    \/\/ is supported.\n    if (!conn.version) {\n      LongHeader* longHeader = regularPacket.header.asLong();\n      if (!longHeader) {\n        throw QuicTransportException(\n            \"Invalid packet type\", TransportErrorCode::PROTOCOL_VIOLATION);\n      }\n      conn.version = longHeader->getVersion();\n      if (conn.version == QuicVersion::MVFST_EXPERIMENTAL) {\n        setExperimentalSettings(conn);\n      }\n    }\n\n    if (conn.peerAddress != readData.peer) {\n      if (encryptionLevel != EncryptionLevel::AppData) {\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(\n              packetSize,\n              QuicTransportStatsCallback::toString(\n                  PacketDropReason::PEER_ADDRESS_CHANGE));\n        }\n        QUIC_STATS(\n            conn.statsCallback,\n            onPacketDropped,\n            PacketDropReason::PEER_ADDRESS_CHANGE);\n        throw QuicTransportException(\n            \"Migration not allowed during handshake\",\n            TransportErrorCode::INVALID_MIGRATION);\n      }\n\n      if (conn.transportSettings.disableMigration) {\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(\n              packetSize,\n              QuicTransportStatsCallback::toString(\n                  PacketDropReason::PEER_ADDRESS_CHANGE));\n        }\n        QUIC_STATS(\n            conn.statsCallback,\n            onPacketDropped,\n            PacketDropReason::PEER_ADDRESS_CHANGE);\n        throw QuicTransportException(\n            \"Migration disabled\", TransportErrorCode::INVALID_MIGRATION);\n      }\n    }\n\n    auto& ackState = getAckState(conn, packetNumberSpace);\n    bool outOfOrder = updateLargestReceivedPacketNum(\n        ackState, packetNum, readData.networkData.receiveTimePoint);\n    if (outOfOrder) {\n      QUIC_STATS(conn.statsCallback, onOutOfOrderPacketReceived);\n    }\n    DCHECK(hasReceivedPackets(conn));\n\n    bool pktHasRetransmittableData = false;\n    bool pktHasCryptoData = false;\n    bool isNonProbingPacket = false;\n    bool handshakeConfirmedThisLoop = false;\n\n    \/\/ TODO: possibly drop the packet here, but rolling back state of\n    \/\/ what we've already processed is difficult.\n    for (auto& quicFrame : regularPacket.frames) {\n      switch (quicFrame.type()) {\n        case QuicFrame::Type::ReadAckFrame: {\n          VLOG(10) << \"Server received ack frame packet=\" << packetNum << \" \"\n                   << conn;\n          isNonProbingPacket = true;\n          ReadAckFrame& ackFrame = *quicFrame.asReadAckFrame();\n          processAckFrame(\n              conn,\n              packetNumberSpace,\n              ackFrame,\n              [&](const OutstandingPacket& packet,\n                  const QuicWriteFrame& packetFrame,\n                  const ReadAckFrame&) {\n                switch (packetFrame.type()) {\n                  case QuicWriteFrame::Type::WriteStreamFrame: {\n                    const WriteStreamFrame& frame =\n                        *packetFrame.asWriteStreamFrame();\n                    VLOG(4)\n                        << \"Server received ack for stream=\" << frame.streamId\n                        << \" offset=\" << frame.offset << \" fin=\" << frame.fin\n                        << \" len=\" << frame.len << \" \" << conn;\n                    auto ackedStream =\n                        conn.streamManager->getStream(frame.streamId);\n                    if (ackedStream) {\n                      sendAckSMHandler(*ackedStream, frame);\n                    }\n                    break;\n                  }\n                  case QuicWriteFrame::Type::WriteCryptoFrame: {\n                    const WriteCryptoFrame& frame =\n                        *packetFrame.asWriteCryptoFrame();\n                    auto cryptoStream =\n                        getCryptoStream(*conn.cryptoState, encryptionLevel);\n                    processCryptoStreamAck(\n                        *cryptoStream, frame.offset, frame.len);\n                    break;\n                  }\n                  case QuicWriteFrame::Type::RstStreamFrame: {\n                    const RstStreamFrame& frame =\n                        *packetFrame.asRstStreamFrame();\n                    VLOG(4) << \"Server received ack for reset stream=\"\n                            << frame.streamId << \" \" << conn;\n                    auto stream = conn.streamManager->getStream(frame.streamId);\n                    if (stream) {\n                      sendRstAckSMHandler(*stream);\n                    }\n                    break;\n                  }\n                  case QuicWriteFrame::Type::WriteAckFrame: {\n                    const WriteAckFrame& frame = *packetFrame.asWriteAckFrame();\n                    DCHECK(!frame.ackBlocks.empty());\n                    VLOG(4) << \"Server received ack for largestAcked=\"\n                            << frame.ackBlocks.front().end << \" \" << conn;\n                    commonAckVisitorForAckFrame(ackState, frame);\n                    break;\n                  }\n                  case QuicWriteFrame::Type::PingFrame:\n                    if (!packet.metadata.isD6DProbe) {\n                      conn.pendingEvents.cancelPingTimeout = true;\n                    }\n                    return;\n                  case QuicWriteFrame::Type::QuicSimpleFrame: {\n                    const QuicSimpleFrame& frame =\n                        *packetFrame.asQuicSimpleFrame();\n                    \/\/ ACK of HandshakeDone is a server-specific behavior.\n                    if (frame.asHandshakeDoneFrame() &&\n                        conn.version != QuicVersion::MVFST_D24) {\n                      \/\/ Call handshakeConfirmed outside of the packet\n                      \/\/ processing loop to avoid a re-entrancy.\n                      handshakeConfirmedThisLoop = true;\n                    }\n                    break;\n                  }\n                  default: {\n                    break;\n                  }\n                }\n              },\n              markPacketLoss,\n              readData.networkData.receiveTimePoint);\n          break;\n        }\n        case QuicFrame::Type::RstStreamFrame: {\n          RstStreamFrame& frame = *quicFrame.asRstStreamFrame();\n          VLOG(10) << \"Server received reset stream=\" << frame.streamId << \" \"\n                   << conn;\n          pktHasRetransmittableData = true;\n          isNonProbingPacket = true;\n          auto stream = conn.streamManager->getStream(frame.streamId);\n          if (!stream) {\n            break;\n          }\n          receiveRstStreamSMHandler(*stream, frame);\n          break;\n        }\n        case QuicFrame::Type::ReadCryptoFrame: {\n          pktHasRetransmittableData = true;\n          pktHasCryptoData = true;\n          isNonProbingPacket = true;\n          ReadCryptoFrame& cryptoFrame = *quicFrame.asReadCryptoFrame();\n          VLOG(10) << \"Server received crypto data offset=\"\n                   << cryptoFrame.offset\n                   << \" len=\" << cryptoFrame.data->computeChainDataLength()\n                   << \" currentReadOffset=\"\n                   << getCryptoStream(*conn.cryptoState, encryptionLevel)\n                          ->currentReadOffset\n                   << \" \" << conn;\n          appendDataToReadBuffer(\n              *getCryptoStream(*conn.cryptoState, encryptionLevel),\n              StreamBuffer(\n                  std::move(cryptoFrame.data), cryptoFrame.offset, false));\n          break;\n        }\n        case QuicFrame::Type::ReadStreamFrame: {\n          ReadStreamFrame& frame = *quicFrame.asReadStreamFrame();\n          VLOG(10) << \"Server received stream data for stream=\"\n                   << frame.streamId << \", offset=\" << frame.offset\n                   << \" len=\" << frame.data->computeChainDataLength()\n                   << \" fin=\" << frame.fin << \" \" << conn;\n          pktHasRetransmittableData = true;\n          isNonProbingPacket = true;\n          auto stream = conn.streamManager->getStream(frame.streamId);\n          \/\/ Ignore data from closed streams that we don't have the\n          \/\/ state for any more.\n          if (stream) {\n            receiveReadStreamFrameSMHandler(*stream, std::move(frame));\n          }\n          break;\n        }\n        case QuicFrame::Type::MaxDataFrame: {\n          MaxDataFrame& connWindowUpdate = *quicFrame.asMaxDataFrame();\n          VLOG(10) << \"Server received max data offset=\"\n                   << connWindowUpdate.maximumData << \" \" << conn;\n          pktHasRetransmittableData = true;\n          isNonProbingPacket = true;\n          handleConnWindowUpdate(conn, connWindowUpdate, packetNum);\n          break;\n        }\n        case QuicFrame::Type::MaxStreamDataFrame: {\n          MaxStreamDataFrame& streamWindowUpdate =\n              *quicFrame.asMaxStreamDataFrame();\n          VLOG(10) << \"Server received max stream data stream=\"\n                   << streamWindowUpdate.streamId\n                   << \" offset=\" << streamWindowUpdate.maximumData << \" \"\n                   << conn;\n          if (isReceivingStream(conn.nodeType, streamWindowUpdate.streamId)) {\n            throw QuicTransportException(\n                \"Received MaxStreamDataFrame for receiving stream.\",\n                TransportErrorCode::STREAM_STATE_ERROR);\n          }\n          pktHasRetransmittableData = true;\n          isNonProbingPacket = true;\n          auto stream =\n              conn.streamManager->getStream(streamWindowUpdate.streamId);\n          if (stream) {\n            handleStreamWindowUpdate(\n                *stream, streamWindowUpdate.maximumData, packetNum);\n          }\n          break;\n        }\n        case QuicFrame::Type::DataBlockedFrame: {\n          VLOG(10) << \"Server received blocked \" << conn;\n          pktHasRetransmittableData = true;\n          isNonProbingPacket = true;\n          handleConnBlocked(conn);\n          break;\n        }\n        case QuicFrame::Type::StreamDataBlockedFrame: {\n          StreamDataBlockedFrame& blocked =\n              *quicFrame.asStreamDataBlockedFrame();\n          VLOG(10) << \"Server received blocked stream=\" << blocked.streamId\n                   << \" \" << conn;\n          pktHasRetransmittableData = true;\n          isNonProbingPacket = true;\n          auto stream = conn.streamManager->getStream(blocked.streamId);\n          if (stream) {\n            handleStreamBlocked(*stream);\n          }\n          break;\n        }\n        case QuicFrame::Type::StreamsBlockedFrame: {\n          StreamsBlockedFrame& blocked = *quicFrame.asStreamsBlockedFrame();\n          \/\/ peer wishes to open a stream, but is unable to due to the maximum\n          \/\/ stream limit set by us\n          \/\/ TODO implement the handler\n          isNonProbingPacket = true;\n          VLOG(10) << \"Server received streams blocked limit=\"\n                   << blocked.streamLimit << \", \" << conn;\n          break;\n        }\n        case QuicFrame::Type::ConnectionCloseFrame: {\n          isNonProbingPacket = true;\n          ConnectionCloseFrame& connFrame = *quicFrame.asConnectionCloseFrame();\n          auto errMsg = folly::to<std::string>(\n              \"Server closed by peer reason=\", connFrame.reasonPhrase);\n          VLOG(4) << errMsg << \" \" << conn;\n          \/\/ we want to deliver app callbacks with the peer supplied error,\n          \/\/ but send a NO_ERROR to the peer.\n          QUIC_TRACE(recvd_close, conn, errMsg.c_str());\n          if (conn.qLogger) {\n            conn.qLogger->addTransportStateUpdate(getPeerClose(errMsg));\n          }\n          conn.peerConnectionError = std::make_pair(\n              QuicErrorCode(connFrame.errorCode), std::move(errMsg));\n          if (getSendConnFlowControlBytesWire(conn) == 0 &&\n              conn.flowControlState.sumCurStreamBufferLen) {\n            VLOG(2) << \"Client gives up a flow control blocked connection\";\n          }\n          throw QuicTransportException(\n              \"Peer closed\", TransportErrorCode::NO_ERROR);\n          break;\n        }\n        case QuicFrame::Type::PingFrame:\n          isNonProbingPacket = true;\n          \/\/ Ping isn't retransmittable data. But we would like to ack them\n          \/\/ early.\n          pktHasRetransmittableData = true;\n          break;\n        case QuicFrame::Type::PaddingFrame:\n          break;\n        case QuicFrame::Type::QuicSimpleFrame: {\n          pktHasRetransmittableData = true;\n          QuicSimpleFrame& simpleFrame = *quicFrame.asQuicSimpleFrame();\n          isNonProbingPacket |= updateSimpleFrameOnPacketReceived(\n              conn, simpleFrame, packetNum, readData.peer != conn.peerAddress);\n          break;\n        }\n        default: {\n          break;\n        }\n      }\n    }\n\n    if (handshakeConfirmedThisLoop) {\n      handshakeConfirmed(conn);\n    }\n\n    \/\/ Update writable limit before processing the handshake data. This is so\n    \/\/ that if we haven't decided whether or not to validate the peer, we won't\n    \/\/ increase the limit.\n    updateWritableByteLimitOnRecvPacket(conn);\n\n    if (conn.peerAddress != readData.peer) {\n      \/\/ TODO use new conn id, make sure the other endpoint has new conn id\n      if (isNonProbingPacket) {\n        if (packetNum == ackState.largestReceivedPacketNum) {\n          ShortHeader* shortHeader = regularPacket.header.asShort();\n          bool intentionalMigration = false;\n          if (shortHeader &&\n              shortHeader->getConnectionId() != conn.serverConnectionId) {\n            intentionalMigration = true;\n          }\n          onConnectionMigration(conn, readData.peer, intentionalMigration);\n        }\n      } else {\n        \/\/ Server will need to response with PathResponse to the new address\n        \/\/ while not updating peerAddress to new address\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(\n              packetSize,\n              QuicTransportStatsCallback::toString(\n                  PacketDropReason::PEER_ADDRESS_CHANGE));\n        }\n        QUIC_STATS(\n            conn.statsCallback,\n            onPacketDropped,\n            PacketDropReason::PEER_ADDRESS_CHANGE);\n        throw QuicTransportException(\n            \"Probing not supported yet\", TransportErrorCode::INVALID_MIGRATION);\n      }\n    }\n\n    \/\/ Try reading bytes off of crypto, and performing a handshake.\n    auto data = readDataFromCryptoStream(\n        *getCryptoStream(*conn.cryptoState, encryptionLevel));\n    if (data) {\n      conn.serverHandshakeLayer->doHandshake(std::move(data), encryptionLevel);\n\n      try {\n        updateHandshakeState(conn);\n      } catch (...) {\n        if (conn.qLogger) {\n          conn.qLogger->addPacketDrop(\n              packetSize,\n              QuicTransportStatsCallback::toString(\n                  PacketDropReason::TRANSPORT_PARAMETER_ERROR));\n        }\n        QUIC_STATS(\n            conn.statsCallback,\n            onPacketDropped,\n            QuicTransportStatsCallback::PacketDropReason::\n                TRANSPORT_PARAMETER_ERROR);\n        throw;\n      }\n    }\n    updateAckSendStateOnRecvPacket(\n        conn,\n        ackState,\n        outOfOrder,\n        pktHasRetransmittableData,\n        pktHasCryptoData);\n    if (encryptionLevel == EncryptionLevel::Handshake &&\n        conn.version != QuicVersion::MVFST_D24 && conn.initialWriteCipher) {\n      conn.initialWriteCipher.reset();\n      conn.initialHeaderCipher.reset();\n      conn.readCodec->setInitialReadCipher(nullptr);\n      conn.readCodec->setInitialHeaderCipher(nullptr);\n      implicitAckCryptoStream(conn, EncryptionLevel::Initial);\n    }\n    QUIC_STATS(conn.statsCallback, onPacketProcessed);\n  }\n  VLOG_IF(4, !udpData.empty())\n      << \"Leaving \" << udpData.chainLength()\n      << \" bytes unprocessed after attempting to process \"\n      << kMaxNumCoalescedPackets << \" packets.\";\n}","target":0,"code_token_length":5102,"total_token_length":5338,"max_tokens_setting":6144}
+{"idx":269941,"func":"static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  Image *image, *image2=NULL,\n   *rotated_image;\n  register Quantum *q;\n\n  unsigned int status;\n  MATHeader MATLAB_HDR;\n  size_t size;  \n  size_t CellType;\n  QuantumInfo *quantum_info;\n  ImageInfo *clone_info;\n  int i;\n  ssize_t ldblk;\n  unsigned char *BImgBuff = NULL;\n  double MinVal, MaxVal;\n  unsigned z, z2;\n  unsigned Frames;\n  int logging;\n  int sample_size;\n  MagickOffsetType filepos=0x80;\n  BlobInfo *blob;\n  size_t one;\n  \n  unsigned int (*ReadBlobXXXLong)(Image *image);\n  unsigned short (*ReadBlobXXXShort)(Image *image);\n  void (*ReadBlobDoublesXXX)(Image * image, size_t len, double *data);\n  void (*ReadBlobFloatsXXX)(Image * image, size_t len, float *data);\n\n\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  logging = LogMagickEvent(CoderEvent,GetMagickModule(),\"enter\"); \n\n  \/*\n     Open image file.\n   *\/\n  image = AcquireImage(image_info,exception);\n\n  status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n     Read MATLAB image.\n   *\/\n  clone_info=CloneImageInfo(image_info);\n  if(ReadBlob(image,124,(unsigned char *) &MATLAB_HDR.identific) != 124)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  MATLAB_HDR.Version = ReadBlobLSBShort(image);\n  if(ReadBlob(image,2,(unsigned char *) &MATLAB_HDR.EndianIndicator) != 2)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n\n  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\"  Endian %c%c\",\n        MATLAB_HDR.EndianIndicator[0],MATLAB_HDR.EndianIndicator[1]);\n  if (!strncmp(MATLAB_HDR.EndianIndicator, \"IM\", 2))\n  {\n    ReadBlobXXXLong = ReadBlobLSBLong;\n    ReadBlobXXXShort = ReadBlobLSBShort;\n    ReadBlobDoublesXXX = ReadBlobDoublesLSB;\n    ReadBlobFloatsXXX = ReadBlobFloatsLSB;\n    image->endian = LSBEndian;\n  } \n  else if (!strncmp(MATLAB_HDR.EndianIndicator, \"MI\", 2))\n  {\n    ReadBlobXXXLong = ReadBlobMSBLong;\n    ReadBlobXXXShort = ReadBlobMSBShort;\n    ReadBlobDoublesXXX = ReadBlobDoublesMSB;\n    ReadBlobFloatsXXX = ReadBlobFloatsMSB;\n    image->endian = MSBEndian;\n  }\n  else \n    goto MATLAB_KO;    \/* unsupported endian *\/\n\n  if (strncmp(MATLAB_HDR.identific, \"MATLAB\", 6))\nMATLAB_KO: ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n\n  filepos = TellBlob(image);\n  while(!EOFBlob(image)) \/* object parser loop *\/\n  {\n    Frames = 1;\n    (void) SeekBlob(image,filepos,SEEK_SET);\n    \/* printf(\"pos=%X\\n\",TellBlob(image)); *\/\n\n    MATLAB_HDR.DataType = ReadBlobXXXLong(image);\n    if(EOFBlob(image)) break;\n    MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image);\n    if(EOFBlob(image)) break;\n    filepos += MATLAB_HDR.ObjectSize + 4 + 4;\n\n    image2 = image;\n#if defined(MAGICKCORE_ZLIB_DELEGATE)\n    if(MATLAB_HDR.DataType == miCOMPRESSED)\n    {\n      image2 = DecompressBlock(image,MATLAB_HDR.ObjectSize,clone_info,exception);\n      if(image2==NULL) continue;\n      MATLAB_HDR.DataType = ReadBlobXXXLong(image2); \/* replace compressed object type. *\/\n    }\n#endif    \n\n    if(MATLAB_HDR.DataType!=miMATRIX) continue;  \/* skip another objects. *\/\n \n    MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2);\n    MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2);  \n\n    MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2);\n    MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF;\n    MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF;  \n\n    MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2);\n    if(image!=image2)\n      MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);  \/* ??? don't understand why ?? *\/\n    MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);\n    MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2);\n    MATLAB_HDR.SizeX = ReadBlobXXXLong(image2);\n    MATLAB_HDR.SizeY = ReadBlobXXXLong(image2);  \n   \n\n    switch(MATLAB_HDR.DimFlag)\n    {     \n      case  8: z2=z=1; break;      \/* 2D matrix*\/\n      case 12: z2=z = ReadBlobXXXLong(image2);  \/* 3D matrix RGB*\/\n           (void) ReadBlobXXXLong(image2);\n         if(z!=3) ThrowReaderException(CoderError, \"MultidimensionalMatricesAreNotSupported\");\n         break;\n      case 16: z2=z = ReadBlobXXXLong(image2);  \/* 4D matrix animation *\/\n         if(z!=3 && z!=1)\n            ThrowReaderException(CoderError, \"MultidimensionalMatricesAreNotSupported\");\n           Frames = ReadBlobXXXLong(image2);\n         break;\n      default: ThrowReaderException(CoderError, \"MultidimensionalMatricesAreNotSupported\");\n    }  \n\n    MATLAB_HDR.Flag1 = ReadBlobXXXShort(image2);\n    MATLAB_HDR.NameFlag = ReadBlobXXXShort(image2);\n\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"MATLAB_HDR.StructureClass %d\",MATLAB_HDR.StructureClass);\n    if (MATLAB_HDR.StructureClass != mxCHAR_CLASS && \n        MATLAB_HDR.StructureClass != mxSINGLE_CLASS &&    \/* float + complex float *\/\n        MATLAB_HDR.StructureClass != mxDOUBLE_CLASS &&    \/* double + complex double *\/\n        MATLAB_HDR.StructureClass != mxINT8_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT8_CLASS &&    \/* uint8 + uint8 3D *\/\n        MATLAB_HDR.StructureClass != mxINT16_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT16_CLASS &&    \/* uint16 + uint16 3D *\/\n        MATLAB_HDR.StructureClass != mxINT32_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT32_CLASS &&    \/* uint32 + uint32 3D *\/\n        MATLAB_HDR.StructureClass != mxINT64_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT64_CLASS)    \/* uint64 + uint64 3D *\/\n      ThrowReaderException(CoderError,\"UnsupportedCellTypeInTheMatrix\");\n\n    switch (MATLAB_HDR.NameFlag)\n    {\n      case 0:\n        size = ReadBlobXXXLong(image2);  \/* Object name string size *\/\n        size = 4 * (ssize_t) ((size + 3 + 1) \/ 4);\n        (void) SeekBlob(image2, size, SEEK_CUR);\n        break;\n      case 1:\n      case 2:\n      case 3:\n      case 4:\n        (void) ReadBlob(image2, 4, (unsigned char *) &size); \/* Object name string *\/\n        break;\n      default:\n        goto MATLAB_KO;\n    }\n\n    CellType = ReadBlobXXXLong(image2);    \/* Additional object type *\/\n    if (logging)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"MATLAB_HDR.CellType: %.20g\",(double) CellType);\n  \n    (void) ReadBlob(image2, 4, (unsigned char *) &size);     \/* data size *\/\n\n    NEXT_FRAME:\n    switch (CellType)\n    {\n      case miINT8:\n      case miUINT8:\n        sample_size = 8;\n        if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL) \n          image->depth = 1;\n        else\n          image->depth = 8;         \/* Byte type cell *\/\n        ldblk = (ssize_t) MATLAB_HDR.SizeX;      \n        break;\n      case miINT16:\n      case miUINT16:\n        sample_size = 16;\n        image->depth = 16;        \/* Word type cell *\/\n        ldblk = (ssize_t) (2 * MATLAB_HDR.SizeX);\n        break;\n      case miINT32:\n      case miUINT32:\n        sample_size = 32;\n        image->depth = 32;        \/* Dword type cell *\/\n        ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);      \n        break;\n      case miINT64:\n      case miUINT64:\n        sample_size = 64;\n        image->depth = 64;        \/* Qword type cell *\/\n        ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);      \n        break;   \n      case miSINGLE:\n        sample_size = 32;\n        image->depth = 32;        \/* double type cell *\/\n        (void) SetImageOption(clone_info,\"quantum:format\",\"floating-point\");\n        if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)\n  {              \/* complex float type cell *\/\n  }\n        ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);\n        break;\n      case miDOUBLE:\n        sample_size = 64; \n        image->depth = 64;        \/* double type cell *\/\n        (void) SetImageOption(clone_info,\"quantum:format\",\"floating-point\");\nDisableMSCWarning(4127)\n        if (sizeof(double) != 8)\nRestoreMSCWarning\n          ThrowReaderException(CoderError, \"IncompatibleSizeOfDouble\");\n        if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)\n  {                         \/* complex double type cell *\/        \n  }\n        ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);\n        break;\n      default:\n        ThrowReaderException(CoderError, \"UnsupportedCellTypeInTheMatrix\");\n    }\n    (void) sample_size;\n    image->columns = MATLAB_HDR.SizeX;\n    image->rows = MATLAB_HDR.SizeY;    \n    quantum_info=AcquireQuantumInfo(clone_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    one=1;\n    image->colors = one << image->depth;\n    if (image->columns == 0 || image->rows == 0)\n      goto MATLAB_KO;\n    \/* Image is gray when no complex flag is set and 2D Matrix *\/\n    if ((MATLAB_HDR.DimFlag == 8) &&\n        ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))\n      {\n        image->type=GrayscaleType;\n        SetImageColorspace(image,GRAYColorspace,exception);\n      }\n\n\n    \/*\n      If ping is true, then only set image size and colors without\n      reading any image data.\n    *\/\n    if (image_info->ping)\n    {\n      size_t temp = image->columns;\n      image->columns = image->rows;\n      image->rows = temp;\n      goto done_reading; \/* !!!!!! BAD  !!!! *\/\n    }  \n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      return(DestroyImageList(image));\n\n  \/* ----- Load raster data ----- *\/\n    BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(double));    \/* Ldblk was set in the check phase *\/\n    if (BImgBuff == NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n\n    MinVal = 0;\n    MaxVal = 0;\n    if (CellType==miDOUBLE || CellType==miSINGLE)        \/* Find Min and Max Values for floats *\/\n    {\n      CalcMinMax(image2, image_info->endian,  MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &quantum_info->minimum, &quantum_info->maximum);\n    }\n\n    \/* Main loop for reading all scanlines *\/\n    if(z==1) z=0; \/* read grey scanlines *\/\n    \/* else read color scanlines *\/\n    do\n    {\n      for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)\n      {\n        q=GetAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception);\n        if (q == (Quantum *) NULL)\n  {\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  MAT set image pixels returns unexpected NULL on a row %u.\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n    goto done_reading;    \/* Skip image rotation, when cannot set image pixels    *\/\n  }\n        if(ReadBlob(image2,ldblk,(unsigned char *)BImgBuff) != (ssize_t) ldblk)\n  {\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n             \"  MAT cannot read scanrow %u from a file.\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n    goto ExitLoop;\n  }\n        if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL))\n        {\n          FixLogical((unsigned char *)BImgBuff,ldblk);\n          if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0)\n    {\nImportQuantumPixelsFailed:\n      if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  MAT failed to ImportQuantumPixels for a row %u\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n      break;\n    }\n        }\n        else\n        {\n          if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0)\n      goto ImportQuantumPixelsFailed;\n\n\n          if (z<=1 &&       \/* fix only during a last pass z==0 || z==1 *\/\n          (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64))\n      FixSignedValues(image,q,MATLAB_HDR.SizeX);\n        }\n\n        if (!SyncAuthenticPixels(image,exception))\n  {\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  MAT failed to sync image pixels for a row %u\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n    goto ExitLoop;\n  }\n      }\n    } while(z-- >= 2);\n    quantum_info=DestroyQuantumInfo(quantum_info);\nExitLoop:\n\n\n    \/* Read complex part of numbers here *\/\n    if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)\n    {        \/* Find Min and Max Values for complex parts of floats *\/\n      CellType = ReadBlobXXXLong(image2);    \/* Additional object type *\/\n      i = ReadBlobXXXLong(image2);           \/* size of a complex part - toss away*\/\n\n      if (CellType==miDOUBLE || CellType==miSINGLE)\n      {\n        CalcMinMax(image2,  image_info->endian, MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &MinVal, &MaxVal);      \n      }\n\n      if (CellType==miDOUBLE)\n        for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)\n  {\n          ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff);\n          InsertComplexDoubleRow(image, (double *)BImgBuff, i, MinVal, MaxVal,\n            exception);\n  }\n\n      if (CellType==miSINGLE)\n        for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)\n  {\n          ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff);\n          InsertComplexFloatRow(image,(float *)BImgBuff,i,MinVal,MaxVal,\n            exception);\n  }    \n    }\n\n      \/* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! *\/\n    if ((MATLAB_HDR.DimFlag == 8) &&\n        ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))\n      image->type=GrayscaleType;\n    if (image->depth == 1)\n      image->type=BilevelType;\n\n    if(image2==image)\n        image2 = NULL;    \/* Remove shadow copy to an image before rotation. *\/\n\n      \/*  Rotate image. *\/\n    rotated_image = RotateImage(image, 90.0, exception);\n    if (rotated_image != (Image *) NULL)\n    {\n        \/* Remove page offsets added by RotateImage *\/\n      rotated_image->page.x=0;\n      rotated_image->page.y=0;\n\n      blob = rotated_image->blob;\n      rotated_image->blob = image->blob;\n      rotated_image->colors = image->colors;\n      image->blob = blob;\n      AppendImageToList(&image,rotated_image);      \n      DeleteImageFromList(&image);      \n    }\n\ndone_reading:\n\n    if(image2!=NULL)\n      if(image2!=image)\n      {\n        DeleteImageFromList(&image2); \n  if(clone_info)\n  {\n          if(clone_info->file)\n    {\n            fclose(clone_info->file);\n            clone_info->file = NULL;\n            (void) remove_utf8(clone_info->filename);\n    }\n        }    \n      }\n\n      \/* Allocate next image structure. *\/    \n    AcquireNextImage(image_info,image,exception);\n    if (image->next == (Image *) NULL) break;                \n    image=SyncNextImageInList(image);\n    image->columns=image->rows=0;\n    image->colors=0;    \n\n      \/* row scan buffer is no longer needed *\/\n    RelinquishMagickMemory(BImgBuff);\n    BImgBuff = NULL;\n\n    if(--Frames>0)\n    {\n      z = z2;\n      if(image2==NULL) image2 = image;\n      goto NEXT_FRAME;\n    }\n    if ((image2!=NULL) && (image2!=image))   \/* Does shadow temporary decompressed image exist? *\/\n      {\n\/*  CloseBlob(image2); *\/\n        DeleteImageFromList(&image2);\n        if(clone_info)\n        {\n          if(clone_info->file)\n          {\n            fclose(clone_info->file);\n            clone_info->file = NULL;\n            (void) remove_utf8(clone_info->filename);\n          }\n        }\n        }\n  }\n\n  clone_info=DestroyImageInfo(clone_info);\n  RelinquishMagickMemory(BImgBuff);\n  CloseBlob(image);\n\n\n  {\n    Image *p;    \n    ssize_t scene=0;\n    \n    \/*\n      Rewind list, removing any empty images while rewinding.\n    *\/\n    p=image;\n    image=NULL;\n    while (p != (Image *) NULL)\n      {\n        Image *tmp=p;\n        if ((p->rows == 0) || (p->columns == 0)) {\n          p=p->previous;\n          DeleteImageFromList(&tmp);\n        } else {\n          image=p;\n          p=p->previous;\n        }\n      }\n    \n    \/*\n      Fix scene numbers\n    *\/\n    for (p=image; p != (Image *) NULL; p=p->next)\n      p->scene=scene++;\n  }\n\n  if(clone_info != NULL)  \/* cleanup garbage file from compression *\/\n  {\n    if(clone_info->file)\n    {\n      fclose(clone_info->file);\n      clone_info->file = NULL;\n      (void) remove_utf8(clone_info->filename);\n    }\n    DestroyImageInfo(clone_info);\n    clone_info = NULL;\n  }\n  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\"return\");\n  if(image==NULL)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  return (image);\n}","target":0,"code_token_length":4465,"total_token_length":4701,"max_tokens_setting":6144}
+{"idx":234243,"func":"process_debug_info (struct dwarf_section * section,\n\t\t    void *file,\n\t\t    enum dwarf_section_display_enum abbrev_sec,\n\t\t    bool do_loc,\n\t\t    bool do_types)\n{\n  unsigned char *start = section->start;\n  unsigned char *end = start + section->size;\n  unsigned char *section_begin;\n  unsigned int unit;\n  unsigned int num_units = 0;\n\n  \/* First scan the section to get the number of comp units.\n     Length sanity checks are done here.  *\/\n  for (section_begin = start, num_units = 0; section_begin < end;\n       num_units ++)\n    {\n      dwarf_vma length;\n\n      \/* Read the first 4 bytes.  For a 32-bit DWARF section, this\n\t will be the length.  For a 64-bit DWARF section, it'll be\n\t the escape code 0xffffffff followed by an 8 byte length.  *\/\n      SAFE_BYTE_GET_AND_INC (length, section_begin, 4, end);\n\n      if (length == 0xffffffff)\n\tSAFE_BYTE_GET_AND_INC (length, section_begin, 8, end);\n      else if (length >= 0xfffffff0 && length < 0xffffffff)\n\t{\n\t  warn (_(\"Reserved length value (0x%s) found in section %s\\n\"),\n\t\tdwarf_vmatoa (\"x\", length), section->name);\n\t  return false;\n\t}\n\n      \/* Negative values are illegal, they may even cause infinite\n\t looping.  This can happen if we can't accurately apply\n\t relocations to an object file, or if the file is corrupt.  *\/\n      if (length > (size_t) (end - section_begin))\n\t{\n\t  warn (_(\"Corrupt unit length (got 0x%s expected at most 0x%s) in section %s\\n\"),\n\t\tdwarf_vmatoa (\"x\", length),\n\t\tdwarf_vmatoa (\"x\", end - section_begin),\n\t\tsection->name);\n\t  return false;\n\t}\n      section_begin += length;\n    }\n\n  if (num_units == 0)\n    {\n      error (_(\"No comp units in %s section ?\\n\"), section->name);\n      return false;\n    }\n\n  if ((do_loc || do_debug_loc || do_debug_ranges || do_debug_info)\n      && num_debug_info_entries == 0\n      && ! do_types)\n    {\n\n      \/* Then allocate an array to hold the information.  *\/\n      debug_information = (debug_info *) cmalloc (num_units,\n\t\t\t\t\t\t  sizeof (* debug_information));\n      if (debug_information == NULL)\n\t{\n\t  error (_(\"Not enough memory for a debug info array of %u entries\\n\"),\n\t\t num_units);\n\t  alloc_num_debug_info_entries = num_debug_info_entries = 0;\n\t  return false;\n\t}\n\n      \/* PR 17531: file: 92ca3797.\n\t We cannot rely upon the debug_information array being initialised\n\t before it is used.  A corrupt file could easily contain references\n\t to a unit for which information has not been made available.  So\n\t we ensure that the array is zeroed here.  *\/\n      memset (debug_information, 0, num_units * sizeof (*debug_information));\n\n      alloc_num_debug_info_entries = num_units;\n    }\n\n  if (!do_loc)\n    {\n      load_debug_section_with_follow (str, file);\n      load_debug_section_with_follow (line_str, file);\n      load_debug_section_with_follow (str_dwo, file);\n      load_debug_section_with_follow (str_index, file);\n      load_debug_section_with_follow (str_index_dwo, file);\n      load_debug_section_with_follow (debug_addr, file);\n    }\n\n  load_debug_section_with_follow (abbrev_sec, file);\n  load_debug_section_with_follow (loclists, file);\n  load_debug_section_with_follow (rnglists, file);\n  \n  if (debug_displays [abbrev_sec].section.start == NULL)\n    {\n      warn (_(\"Unable to locate %s section!\\n\"),\n\t    debug_displays [abbrev_sec].section.uncompressed_name);\n      return false;\n    }\n\n  if (!do_loc && dwarf_start_die == 0)\n    introduce (section, false);\n\n  free_all_abbrevs ();\n  free (cu_abbrev_map);\n  cu_abbrev_map = NULL;\n  next_free_abbrev_map_entry = 0;\n\n  \/* In order to be able to resolve DW_FORM_ref_attr forms we need\n     to load *all* of the abbrevs for all CUs in this .debug_info\n     section.  This does effectively mean that we (partially) read\n     every CU header twice.  *\/\n  for (section_begin = start; start < end;)\n    {\n      DWARF2_Internal_CompUnit  compunit;\n      unsigned char *           hdrptr;\n      dwarf_vma                 abbrev_base;\n      size_t                    abbrev_size;\n      dwarf_vma                 cu_offset;\n      unsigned int              offset_size;\n      struct cu_tu_set *        this_set;\n      abbrev_list *             list;\n      unsigned char *end_cu;\n\n      hdrptr = start;\n      cu_offset = start - section_begin;\n\n      SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end);\n\n      if (compunit.cu_length == 0xffffffff)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end);\n\t  offset_size = 8;\n\t}\n      else\n\toffset_size = 4;\n      end_cu = hdrptr + compunit.cu_length;\n\n      SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end_cu);\n\n      this_set = find_cu_tu_set_v2 (cu_offset, do_types);\n\n      if (compunit.cu_version < 5)\n\t{\n\t  compunit.cu_unit_type = DW_UT_compile;\n\t  \/* Initialize it due to a false compiler warning.  *\/\n\t  compunit.cu_pointer_size = -1;\n\t}\n      else\n\t{\n\t  SAFE_BYTE_GET_AND_INC (compunit.cu_unit_type, hdrptr, 1, end_cu);\n\t  do_types = (compunit.cu_unit_type == DW_UT_type);\n\n\t  SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end_cu);\n\t}\n\n      SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size,\n\t\t\t     end_cu);\n\n      if (compunit.cu_unit_type == DW_UT_split_compile\n\t  || compunit.cu_unit_type == DW_UT_skeleton)\n\t{\n\t  uint64_t dwo_id;\n\t  SAFE_BYTE_GET_AND_INC (dwo_id, hdrptr, 8, end_cu);\n\t}\n\n      if (this_set == NULL)\n\t{\n\t  abbrev_base = 0;\n\t  abbrev_size = debug_displays [abbrev_sec].section.size;\n\t}\n      else\n\t{\n\t  abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];\n\t  abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];\n\t}\n\n      list = find_abbrev_list_by_abbrev_offset (abbrev_base,\n\t\t\t\t\t\tcompunit.cu_abbrev_offset);\n      if (list == NULL)\n\t{\n\t  unsigned char *  next;\n\n\t  list = new_abbrev_list (abbrev_base,\n\t\t\t\t  compunit.cu_abbrev_offset);\n\t  next = process_abbrev_set (&debug_displays[abbrev_sec].section,\n\t\t\t\t     abbrev_base, abbrev_size,\n\t\t\t\t     compunit.cu_abbrev_offset, list);\n\t  list->start_of_next_abbrevs = next;\n\t}\n\n      start = end_cu;\n      record_abbrev_list_for_cu (cu_offset, start - section_begin, list);\n    }\n\n  for (start = section_begin, unit = 0; start < end; unit++)\n    {\n      DWARF2_Internal_CompUnit compunit;\n      unsigned char *hdrptr;\n      unsigned char *tags;\n      int level, last_level, saved_level;\n      dwarf_vma cu_offset;\n      unsigned int offset_size;\n      dwarf_vma signature = 0;\n      dwarf_vma type_offset = 0;\n      struct cu_tu_set *this_set;\n      dwarf_vma abbrev_base;\n      size_t abbrev_size;\n      abbrev_list * list = NULL;\n      unsigned char *end_cu;\n\n      hdrptr = start;\n      cu_offset = start - section_begin;\n\n      SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end);\n\n      if (compunit.cu_length == 0xffffffff)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end);\n\t  offset_size = 8;\n\t}\n      else\n\toffset_size = 4;\n      end_cu = hdrptr + compunit.cu_length;\n\n      SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end_cu);\n\n      this_set = find_cu_tu_set_v2 (cu_offset, do_types);\n\n      if (compunit.cu_version < 5)\n\t{\n\t  compunit.cu_unit_type = DW_UT_compile;\n\t  \/* Initialize it due to a false compiler warning.  *\/\n\t  compunit.cu_pointer_size = -1;\n\t}\n      else\n\t{\n\t  SAFE_BYTE_GET_AND_INC (compunit.cu_unit_type, hdrptr, 1, end_cu);\n\t  do_types = (compunit.cu_unit_type == DW_UT_type);\n\n\t  SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end_cu);\n\t}\n\n      SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end_cu);\n\n      if (this_set == NULL)\n\t{\n\t  abbrev_base = 0;\n\t  abbrev_size = debug_displays [abbrev_sec].section.size;\n\t}\n      else\n\t{\n\t  abbrev_base = this_set->section_offsets [DW_SECT_ABBREV];\n\t  abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];\n\t}\n\n      if (compunit.cu_version < 5)\n\tSAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end_cu);\n\n      bool do_dwo_id = false;\n      uint64_t dwo_id = 0;\n      if (compunit.cu_unit_type == DW_UT_split_compile\n\t  || compunit.cu_unit_type == DW_UT_skeleton)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (dwo_id, hdrptr, 8, end_cu);\n\t  do_dwo_id = true;\n\t}\n\n      \/* PR 17512: file: 001-108546-0.001:0.1.  *\/\n      if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8)\n\t{\n\t  warn (_(\"Invalid pointer size (%d) in compunit header, using %d instead\\n\"),\n\t\tcompunit.cu_pointer_size, offset_size);\n\t  compunit.cu_pointer_size = offset_size;\n\t}\n\n      if (do_types)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (signature, hdrptr, 8, end_cu);\n\t  SAFE_BYTE_GET_AND_INC (type_offset, hdrptr, offset_size, end_cu);\n\t}\n\n      if (dwarf_start_die >= (size_t) (end_cu - section_begin))\n\t{\n\t  start = end_cu;\n\t  continue;\n\t}\n\n      if ((do_loc || do_debug_loc || do_debug_ranges || do_debug_info)\n\t  && num_debug_info_entries == 0\n\t  && alloc_num_debug_info_entries > unit\n\t  && ! do_types)\n\t{\n\t  debug_information [unit].cu_offset = cu_offset;\n\t  debug_information [unit].pointer_size\n\t    = compunit.cu_pointer_size;\n\t  debug_information [unit].offset_size = offset_size;\n\t  debug_information [unit].dwarf_version = compunit.cu_version;\n\t  debug_information [unit].base_address = 0;\n\t  debug_information [unit].addr_base = DEBUG_INFO_UNAVAILABLE;\n\t  debug_information [unit].ranges_base = DEBUG_INFO_UNAVAILABLE;\n\t  debug_information [unit].loc_offsets = NULL;\n\t  debug_information [unit].have_frame_base = NULL;\n\t  debug_information [unit].max_loc_offsets = 0;\n\t  debug_information [unit].num_loc_offsets = 0;\n\t  debug_information [unit].loclists_base = 0;\n\t  debug_information [unit].range_lists = NULL;\n\t  debug_information [unit].max_range_lists= 0;\n\t  debug_information [unit].num_range_lists = 0;\n\t  debug_information [unit].rnglists_base = 0;\n\t  debug_information [unit].str_offsets_base = 0;\n\t}\n\n      if (!do_loc && dwarf_start_die == 0)\n\t{\n\t  printf (_(\"  Compilation Unit @ offset 0x%s:\\n\"),\n\t\t  dwarf_vmatoa (\"x\", cu_offset));\n\t  printf (_(\"   Length:        0x%s (%s)\\n\"),\n\t\t  dwarf_vmatoa (\"x\", compunit.cu_length),\n\t\t  offset_size == 8 ? \"64-bit\" : \"32-bit\");\n\t  printf (_(\"   Version:       %d\\n\"), compunit.cu_version);\n\t  if (compunit.cu_version >= 5)\n\t    {\n\t      const char *name = get_DW_UT_name (compunit.cu_unit_type);\n\n\t      printf (_(\"   Unit Type:     %s (%x)\\n\"),\n\t\t      name ? name : \"???\",\n\t\t      compunit.cu_unit_type);\n\t    }\n\t  printf (_(\"   Abbrev Offset: 0x%s\\n\"),\n\t\t  dwarf_vmatoa (\"x\", compunit.cu_abbrev_offset));\n\t  printf (_(\"   Pointer Size:  %d\\n\"), compunit.cu_pointer_size);\n\t  if (do_types)\n\t    {\n\t      printf (_(\"   Signature:     0x%s\\n\"),\n\t\t      dwarf_vmatoa (\"x\", signature));\n\t      printf (_(\"   Type Offset:   0x%s\\n\"),\n\t\t      dwarf_vmatoa (\"x\", type_offset));\n\t    }\n\t  if (do_dwo_id)\n\t    printf (_(\"   DWO ID:        0x%s\\n\"), dwarf_vmatoa (\"x\", dwo_id));\n\t  if (this_set != NULL)\n\t    {\n\t      dwarf_vma *offsets = this_set->section_offsets;\n\t      size_t *sizes = this_set->section_sizes;\n\n\t      printf (_(\"   Section contributions:\\n\"));\n\t      printf (_(\"    .debug_abbrev.dwo:       0x%s  0x%s\\n\"),\n\t\t      dwarf_vmatoa (\"x\", offsets [DW_SECT_ABBREV]),\n\t\t      dwarf_vmatoa (\"x\", sizes [DW_SECT_ABBREV]));\n\t      printf (_(\"    .debug_line.dwo:         0x%s  0x%s\\n\"),\n\t\t      dwarf_vmatoa (\"x\", offsets [DW_SECT_LINE]),\n\t\t      dwarf_vmatoa (\"x\", sizes [DW_SECT_LINE]));\n\t      printf (_(\"    .debug_loc.dwo:          0x%s  0x%s\\n\"),\n\t\t      dwarf_vmatoa (\"x\", offsets [DW_SECT_LOC]),\n\t\t      dwarf_vmatoa (\"x\", sizes [DW_SECT_LOC]));\n\t      printf (_(\"    .debug_str_offsets.dwo:  0x%s  0x%s\\n\"),\n\t\t      dwarf_vmatoa (\"x\", offsets [DW_SECT_STR_OFFSETS]),\n\t\t      dwarf_vmatoa (\"x\", sizes [DW_SECT_STR_OFFSETS]));\n\t    }\n\t}\n\n      tags = hdrptr;\n      start = end_cu;\n\n      if (compunit.cu_version < 2 || compunit.cu_version > 5)\n\t{\n\t  warn (_(\"CU at offset %s contains corrupt or \"\n\t\t  \"unsupported version number: %d.\\n\"),\n\t\tdwarf_vmatoa (\"x\", cu_offset), compunit.cu_version);\n\t  continue;\n\t}\n\n      if (compunit.cu_unit_type != DW_UT_compile\n\t  && compunit.cu_unit_type != DW_UT_partial\n\t  && compunit.cu_unit_type != DW_UT_type\n\t  && compunit.cu_unit_type != DW_UT_split_compile\n\t  && compunit.cu_unit_type != DW_UT_skeleton)\n\t{\n\t  warn (_(\"CU at offset %s contains corrupt or \"\n\t\t  \"unsupported unit type: %d.\\n\"),\n\t\tdwarf_vmatoa (\"x\", cu_offset), compunit.cu_unit_type);\n\t  continue;\n\t}\n\n      \/* Process the abbrevs used by this compilation unit.  *\/\n      list = find_abbrev_list_by_abbrev_offset (abbrev_base,\n\t\t\t\t\t\tcompunit.cu_abbrev_offset);\n      if (list == NULL)\n\t{\n\t  unsigned char *next;\n\n\t  list = new_abbrev_list (abbrev_base,\n\t\t\t\t  compunit.cu_abbrev_offset);\n\t  next = process_abbrev_set (&debug_displays[abbrev_sec].section,\n\t\t\t\t     abbrev_base, abbrev_size,\n\t\t\t\t     compunit.cu_abbrev_offset, list);\n\t  list->start_of_next_abbrevs = next;\n\t}\n\n      level = 0;\n      last_level = level;\n      saved_level = -1;\n      while (tags < start)\n\t{\n\t  unsigned long abbrev_number;\n\t  unsigned long die_offset;\n\t  abbrev_entry *entry;\n\t  abbrev_attr *attr;\n\t  int do_printing = 1;\n\n\t  die_offset = tags - section_begin;\n\n\t  READ_ULEB (abbrev_number, tags, start);\n\n\t  \/* A null DIE marks the end of a list of siblings or it may also be\n\t     a section padding.  *\/\n\t  if (abbrev_number == 0)\n\t    {\n\t      \/* Check if it can be a section padding for the last CU.  *\/\n\t      if (level == 0 && start == end)\n\t\t{\n\t\t  unsigned char *chk;\n\n\t\t  for (chk = tags; chk < start; chk++)\n\t\t    if (*chk != 0)\n\t\t      break;\n\t\t  if (chk == start)\n\t\t    break;\n\t\t}\n\n\t      if (!do_loc && die_offset >= dwarf_start_die\n\t\t  && (dwarf_cutoff_level == -1\n\t\t      || level < dwarf_cutoff_level))\n\t\tprintf (_(\" <%d><%lx>: Abbrev Number: 0\\n\"),\n\t\t\tlevel, die_offset);\n\n\t      --level;\n\t      if (level < 0)\n\t\t{\n\t\t  static unsigned num_bogus_warns = 0;\n\n\t\t  if (num_bogus_warns < 3)\n\t\t    {\n\t\t      warn (_(\"Bogus end-of-siblings marker detected at offset %lx in %s section\\n\"),\n\t\t\t    die_offset, section->name);\n\t\t      num_bogus_warns ++;\n\t\t      if (num_bogus_warns == 3)\n\t\t\twarn (_(\"Further warnings about bogus end-of-sibling markers suppressed\\n\"));\n\t\t    }\n\t\t}\n\t      if (dwarf_start_die != 0 && level < saved_level)\n\t\treturn true;\n\t      continue;\n\t    }\n\n\t  if (!do_loc)\n\t    {\n\t      if (dwarf_start_die != 0 && die_offset < dwarf_start_die)\n\t\tdo_printing = 0;\n\t      else\n\t\t{\n\t\t  if (dwarf_start_die != 0 && die_offset == dwarf_start_die)\n\t\t    saved_level = level;\n\t\t  do_printing = (dwarf_cutoff_level == -1\n\t\t\t\t || level < dwarf_cutoff_level);\n\t\t  if (do_printing)\n\t\t    printf (_(\" <%d><%lx>: Abbrev Number: %lu\"),\n\t\t\t    level, die_offset, abbrev_number);\n\t\t  else if (dwarf_cutoff_level == -1\n\t\t\t   || last_level < dwarf_cutoff_level)\n\t\t    printf (_(\" <%d><%lx>: ...\\n\"), level, die_offset);\n\t\t  last_level = level;\n\t\t}\n\t    }\n\n\t  \/* Scan through the abbreviation list until we reach the\n\t     correct entry.  *\/\n\t  if (list == NULL)\n\t    continue;\n\n\t  for (entry = list->first_abbrev; entry != NULL; entry = entry->next)\n\t    if (entry->number == abbrev_number)\n\t      break;\n\n\t  if (entry == NULL)\n\t    {\n\t      if (!do_loc && do_printing)\n\t\t{\n\t\t  printf (\"\\n\");\n\t\t  fflush (stdout);\n\t\t}\n\t      warn (_(\"DIE at offset 0x%lx refers to abbreviation number %lu which does not exist\\n\"),\n\t\t    die_offset, abbrev_number);\n\t      return false;\n\t    }\n\n\t  if (!do_loc && do_printing)\n\t    printf (\" (%s)\\n\", get_TAG_name (entry->tag));\n\n\t  switch (entry->tag)\n\t    {\n\t    default:\n\t      need_base_address = 0;\n\t      break;\n\t    case DW_TAG_compile_unit:\n\t      need_base_address = 1;\t\n\t      need_dwo_info = do_loc;\n\t      break;\n\t    case DW_TAG_entry_point:\n\t    case DW_TAG_subprogram:\n\t      need_base_address = 0;\n\t      \/* Assuming that there is no DW_AT_frame_base.  *\/\n\t      have_frame_base = 0;\n\t      break;\n\t    }\n\n\t  debug_info *debug_info_p =\n\t    (debug_information && unit < alloc_num_debug_info_entries)\n\t    ? debug_information + unit : NULL;\n\n\t  assert (!debug_info_p\n\t\t  || (debug_info_p->num_loc_offsets\n\t\t      == debug_info_p->num_loc_views));\n\n\t  for (attr = entry->first_attr;\n\t       attr && attr->attribute;\n\t       attr = attr->next)\n\t    {\n\t      if (! do_loc && do_printing)\n\t\t\/* Show the offset from where the tag was extracted.  *\/\n\t\tprintf (\"    <%lx>\", (unsigned long)(tags - section_begin));\n\t      tags = read_and_display_attr (attr->attribute,\n\t\t\t\t\t    attr->form,\n\t\t\t\t\t    attr->implicit_const,\n\t\t\t\t\t    section_begin,\n\t\t\t\t\t    tags,\n\t\t\t\t\t    start,\n\t\t\t\t\t    cu_offset,\n\t\t\t\t\t    compunit.cu_pointer_size,\n\t\t\t\t\t    offset_size,\n\t\t\t\t\t    compunit.cu_version,\n\t\t\t\t\t    debug_info_p,\n\t\t\t\t\t    do_loc || ! do_printing,\n\t\t\t\t\t    section,\n\t\t\t\t\t    this_set,\n\t\t\t\t\t    level);\n\t    }\n\n\t  \/* If a locview attribute appears before a location one,\n\t     make sure we don't associate it with an earlier\n\t     loclist. *\/\n\t  if (debug_info_p)\n\t    switch (debug_info_p->num_loc_offsets - debug_info_p->num_loc_views)\n\t      {\n\t      case 1:\n\t\tdebug_info_p->loc_views [debug_info_p->num_loc_views] = vm1;\n\t\tdebug_info_p->num_loc_views++;\n\t\tassert (debug_info_p->num_loc_views\n\t\t\t== debug_info_p->num_loc_offsets);\n\t\tbreak;\n\n\t      case 0:\n\t\tbreak;\n\n\t      case -1:\n\t\twarn(_(\"DIE has locviews without loclist\\n\"));\n\t\tdebug_info_p->num_loc_views--;\n\t\tbreak;\n\n\t      default:\n\t\tassert (0);\n\t    }\n\n\t  if (entry->children)\n\t    ++level;\n\t}\n    }\n\n  \/* Set num_debug_info_entries here so that it can be used to check if\n     we need to process .debug_loc and .debug_ranges sections.  *\/\n  if ((do_loc || do_debug_loc || do_debug_ranges || do_debug_info)\n      && num_debug_info_entries == 0\n      && ! do_types)\n    {\n      if (num_units > alloc_num_debug_info_entries)\n\tnum_debug_info_entries = alloc_num_debug_info_entries;\n      else\n\tnum_debug_info_entries = num_units;\n    }\n\n  if (!do_loc)\n    printf (\"\\n\");\n\n  return true;\n}","target":0,"code_token_length":4947,"total_token_length":5183,"max_tokens_setting":6144}
+{"idx":459400,"func":"do_tag(\n    char_u\t*tag,\t\t\/\/ tag (pattern) to jump to\n    int\t\ttype,\n    int\t\tcount,\n    int\t\tforceit,\t\/\/ :ta with !\n    int\t\tverbose)\t\/\/ print \"tag not found\" message\n{\n    taggy_T\t*tagstack = curwin->w_tagstack;\n    int\t\ttagstackidx = curwin->w_tagstackidx;\n    int\t\ttagstacklen = curwin->w_tagstacklen;\n    int\t\tcur_match = 0;\n    int\t\tcur_fnum = curbuf->b_fnum;\n    int\t\toldtagstackidx = tagstackidx;\n    int\t\tprevtagstackidx = tagstackidx;\n    int\t\tprev_num_matches;\n    int\t\tnew_tag = FALSE;\n    int\t\ti;\n    int\t\tic;\n    int\t\tno_regexp = FALSE;\n    int\t\terror_cur_match = 0;\n    int\t\tsave_pos = FALSE;\n    fmark_T\tsaved_fmark;\n#ifdef FEAT_CSCOPE\n    int\t\tjumped_to_tag = FALSE;\n#endif\n    int\t\tnew_num_matches;\n    char_u\t**new_matches;\n    int\t\tuse_tagstack;\n    int\t\tskip_msg = FALSE;\n    char_u\t*buf_ffname = curbuf->b_ffname;\t    \/\/ name to use for\n\t\t\t\t\t\t    \/\/ priority computation\n    int\t\tuse_tfu = 1;\n    char_u\t*tofree = NULL;\n\n    \/\/ remember the matches for the last used tag\n    static int\t\tnum_matches = 0;\n    static int\t\tmax_num_matches = 0;  \/\/ limit used for match search\n    static char_u\t**matches = NULL;\n    static int\t\tflags;\n\n#ifdef FEAT_EVAL\n    if (tfu_in_use)\n    {\n\temsg(_(e_cannot_modify_tag_stack_within_tagfunc));\n\treturn FALSE;\n    }\n#endif\n\n#ifdef EXITFREE\n    if (type == DT_FREE)\n    {\n\t\/\/ remove the list of matches\n\tFreeWild(num_matches, matches);\n# ifdef FEAT_CSCOPE\n\tcs_free_tags();\n# endif\n\tnum_matches = 0;\n\treturn FALSE;\n    }\n#endif\n\n    if (type == DT_HELP)\n    {\n\ttype = DT_TAG;\n\tno_regexp = TRUE;\n\tuse_tfu = 0;\n    }\n\n    prev_num_matches = num_matches;\n    free_string_option(nofile_fname);\n    nofile_fname = NULL;\n\n    CLEAR_POS(&saved_fmark.mark);\t\/\/ shutup gcc 4.0\n    saved_fmark.fnum = 0;\n\n    \/*\n     * Don't add a tag to the tagstack if 'tagstack' has been reset.\n     *\/\n    if ((!p_tgst && *tag != NUL))\n    {\n\tuse_tagstack = FALSE;\n\tnew_tag = TRUE;\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t{\n\t    tagstack_clear_entry(&ptag_entry);\n\t    if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)\n\t\tgoto end_do_tag;\n\t}\n#endif\n    }\n    else\n    {\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t    use_tagstack = FALSE;\n\telse\n#endif\n\t    use_tagstack = TRUE;\n\n\t\/\/ new pattern, add to the tag stack\n\tif (*tag != NUL\n\t\t&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP\n#ifdef FEAT_QUICKFIX\n\t\t    || type == DT_LTAG\n#endif\n#ifdef FEAT_CSCOPE\n\t\t    || type == DT_CSCOPE\n#endif\n\t\t    ))\n\t{\n#if defined(FEAT_QUICKFIX)\n\t    if (g_do_tagpreview != 0)\n\t    {\n\t\tif (ptag_entry.tagname != NULL\n\t\t\t&& STRCMP(ptag_entry.tagname, tag) == 0)\n\t\t{\n\t\t    \/\/ Jumping to same tag: keep the current match, so that\n\t\t    \/\/ the CursorHold autocommand example works.\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    tagstack_clear_entry(&ptag_entry);\n\t\t    if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)\n\t\t\tgoto end_do_tag;\n\t\t}\n\t    }\n\t    else\n#endif\n\t    {\n\t\t\/*\n\t\t * If the last used entry is not at the top, delete all tag\n\t\t * stack entries above it.\n\t\t *\/\n\t\twhile (tagstackidx < tagstacklen)\n\t\t    tagstack_clear_entry(&tagstack[--tagstacklen]);\n\n\t\t\/\/ if the tagstack is full: remove oldest entry\n\t\tif (++tagstacklen > TAGSTACKSIZE)\n\t\t{\n\t\t    tagstacklen = TAGSTACKSIZE;\n\t\t    tagstack_clear_entry(&tagstack[0]);\n\t\t    for (i = 1; i < tagstacklen; ++i)\n\t\t\ttagstack[i - 1] = tagstack[i];\n\t\t    --tagstackidx;\n\t\t}\n\n\t\t\/*\n\t\t * put the tag name in the tag stack\n\t\t *\/\n\t\tif ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL)\n\t\t{\n\t\t    curwin->w_tagstacklen = tagstacklen - 1;\n\t\t    goto end_do_tag;\n\t\t}\n\t\tcurwin->w_tagstacklen = tagstacklen;\n\n\t\tsave_pos = TRUE;\t\/\/ save the cursor position below\n\t    }\n\n\t    new_tag = TRUE;\n\t}\n\telse\n\t{\n\t    if (\n#if defined(FEAT_QUICKFIX)\n\t\t    g_do_tagpreview != 0 ? ptag_entry.tagname == NULL :\n#endif\n\t\t    tagstacklen == 0)\n\t    {\n\t\t\/\/ empty stack\n\t\temsg(_(e_tag_stack_empty));\n\t\tgoto end_do_tag;\n\t    }\n\n\t    if (type == DT_POP)\t\t\/\/ go to older position\n\t    {\n#ifdef FEAT_FOLDING\n\t\tint\told_KeyTyped = KeyTyped;\n#endif\n\t\tif ((tagstackidx -= count) < 0)\n\t\t{\n\t\t    emsg(_(e_at_bottom_of_tag_stack));\n\t\t    if (tagstackidx + count == 0)\n\t\t    {\n\t\t\t\/\/ We did [num]^T from the bottom of the stack\n\t\t\ttagstackidx = 0;\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    \/\/ We weren't at the bottom of the stack, so jump all the\n\t\t    \/\/ way to the bottom now.\n\t\t    tagstackidx = 0;\n\t\t}\n\t\telse if (tagstackidx >= tagstacklen)    \/\/ count == 0?\n\t\t{\n\t\t    emsg(_(e_at_top_of_tag_stack));\n\t\t    goto end_do_tag;\n\t\t}\n\n\t\t\/\/ Make a copy of the fmark, autocommands may invalidate the\n\t\t\/\/ tagstack before it's used.\n\t\tsaved_fmark = tagstack[tagstackidx].fmark;\n\t\tif (saved_fmark.fnum != curbuf->b_fnum)\n\t\t{\n\t\t    \/*\n\t\t     * Jump to other file. If this fails (e.g. because the\n\t\t     * file was changed) keep original position in tag stack.\n\t\t     *\/\n\t\t    if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum,\n\t\t\t\t\t       GETF_SETMARK, forceit) == FAIL)\n\t\t    {\n\t\t\ttagstackidx = oldtagstackidx;  \/\/ back to old posn\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    \/\/ An BufReadPost autocommand may jump to the '\" mark, but\n\t\t    \/\/ we don't what that here.\n\t\t    curwin->w_cursor.lnum = saved_fmark.mark.lnum;\n\t\t}\n\t\telse\n\t\t{\n\t\t    setpcmark();\n\t\t    curwin->w_cursor.lnum = saved_fmark.mark.lnum;\n\t\t}\n\t\tcurwin->w_cursor.col = saved_fmark.mark.col;\n\t\tcurwin->w_set_curswant = TRUE;\n\t\tcheck_cursor();\n#ifdef FEAT_FOLDING\n\t\tif ((fdo_flags & FDO_TAG) && old_KeyTyped)\n\t\t    foldOpenCursor();\n#endif\n\n\t\t\/\/ remove the old list of matches\n\t\tFreeWild(num_matches, matches);\n#ifdef FEAT_CSCOPE\n\t\tcs_free_tags();\n#endif\n\t\tnum_matches = 0;\n\t\ttag_freematch();\n\t\tgoto end_do_tag;\n\t    }\n\n\t    if (type == DT_TAG\n#if defined(FEAT_QUICKFIX)\n\t\t    || type == DT_LTAG\n#endif\n\t       )\n\t    {\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0)\n\t\t{\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    \/\/ \":tag\" (no argument): go to newer pattern\n\t\t    save_pos = TRUE;\t\/\/ save the cursor position below\n\t\t    if ((tagstackidx += count - 1) >= tagstacklen)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Beyond the last one, just give an error message and\n\t\t\t * go to the last one.  Don't store the cursor\n\t\t\t * position.\n\t\t\t *\/\n\t\t\ttagstackidx = tagstacklen - 1;\n\t\t\temsg(_(e_at_top_of_tag_stack));\n\t\t\tsave_pos = FALSE;\n\t\t    }\n\t\t    else if (tagstackidx < 0)\t\/\/ must have been count == 0\n\t\t    {\n\t\t\temsg(_(e_at_bottom_of_tag_stack));\n\t\t\ttagstackidx = 0;\n\t\t\tgoto end_do_tag;\n\t\t    }\n\t\t    cur_match = tagstack[tagstackidx].cur_match;\n\t\t    cur_fnum = tagstack[tagstackidx].cur_fnum;\n\t\t}\n\t\tnew_tag = TRUE;\n\t    }\n\t    else\t\t\t\t\/\/ go to other matching tag\n\t    {\n\t\t\/\/ Save index for when selection is cancelled.\n\t\tprevtagstackidx = tagstackidx;\n\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0)\n\t\t{\n\t\t    cur_match = ptag_entry.cur_match;\n\t\t    cur_fnum = ptag_entry.cur_fnum;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    if (--tagstackidx < 0)\n\t\t\ttagstackidx = 0;\n\t\t    cur_match = tagstack[tagstackidx].cur_match;\n\t\t    cur_fnum = tagstack[tagstackidx].cur_fnum;\n\t\t}\n\t\tswitch (type)\n\t\t{\n\t\t    case DT_FIRST: cur_match = count - 1; break;\n\t\t    case DT_SELECT:\n\t\t    case DT_JUMP:\n#ifdef FEAT_CSCOPE\n\t\t    case DT_CSCOPE:\n#endif\n\t\t    case DT_LAST:  cur_match = MAXCOL - 1; break;\n\t\t    case DT_NEXT:  cur_match += count; break;\n\t\t    case DT_PREV:  cur_match -= count; break;\n\t\t}\n\t\tif (cur_match >= MAXCOL)\n\t\t    cur_match = MAXCOL - 1;\n\t\telse if (cur_match < 0)\n\t\t{\n\t\t    emsg(_(e_cannot_go_before_first_matching_tag));\n\t\t    skip_msg = TRUE;\n\t\t    cur_match = 0;\n\t\t    cur_fnum = curbuf->b_fnum;\n\t\t}\n\t    }\n\t}\n\n#if defined(FEAT_QUICKFIX)\n\tif (g_do_tagpreview != 0)\n\t{\n\t    if (type != DT_SELECT && type != DT_JUMP)\n\t    {\n\t\tptag_entry.cur_match = cur_match;\n\t\tptag_entry.cur_fnum = cur_fnum;\n\t    }\n\t}\n\telse\n#endif\n\t{\n\t    \/*\n\t     * For \":tag [arg]\" or \":tselect\" remember position before the jump.\n\t     *\/\n\t    saved_fmark = tagstack[tagstackidx].fmark;\n\t    if (save_pos)\n\t    {\n\t\ttagstack[tagstackidx].fmark.mark = curwin->w_cursor;\n\t\ttagstack[tagstackidx].fmark.fnum = curbuf->b_fnum;\n\t    }\n\n\t    \/\/ Curwin will change in the call to jumpto_tag() if \":stag\" was\n\t    \/\/ used or an autocommand jumps to another window; store value of\n\t    \/\/ tagstackidx now.\n\t    curwin->w_tagstackidx = tagstackidx;\n\t    if (type != DT_SELECT && type != DT_JUMP)\n\t    {\n\t\tcurwin->w_tagstack[tagstackidx].cur_match = cur_match;\n\t\tcurwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum;\n\t    }\n\t}\n    }\n\n    \/\/ When not using the current buffer get the name of buffer \"cur_fnum\".\n    \/\/ Makes sure that the tag order doesn't change when using a remembered\n    \/\/ position for \"cur_match\".\n    if (cur_fnum != curbuf->b_fnum)\n    {\n\tbuf_T *buf = buflist_findnr(cur_fnum);\n\n\tif (buf != NULL)\n\t    buf_ffname = buf->b_ffname;\n    }\n\n    \/*\n     * Repeat searching for tags, when a file has not been found.\n     *\/\n    for (;;)\n    {\n\tint\tother_name;\n\tchar_u\t*name;\n\n\t\/*\n\t * When desired match not found yet, try to find it (and others).\n\t *\/\n\tif (use_tagstack)\n\t{\n\t    \/\/ make a copy, the tagstack may change in 'tagfunc'\n\t    name = vim_strsave(tagstack[tagstackidx].tagname);\n\t    vim_free(tofree);\n\t    tofree = name;\n\t}\n#if defined(FEAT_QUICKFIX)\n\telse if (g_do_tagpreview != 0)\n\t    name = ptag_entry.tagname;\n#endif\n\telse\n\t    name = tag;\n\tother_name = (tagmatchname == NULL || STRCMP(tagmatchname, name) != 0);\n\tif (new_tag\n\t\t|| (cur_match >= num_matches && max_num_matches != MAXCOL)\n\t\t|| other_name)\n\t{\n\t    if (other_name)\n\t    {\n\t\tvim_free(tagmatchname);\n\t\ttagmatchname = vim_strsave(name);\n\t    }\n\n\t    if (type == DT_SELECT || type == DT_JUMP\n#if defined(FEAT_QUICKFIX)\n\t\t|| type == DT_LTAG\n#endif\n\t\t)\n\t\tcur_match = MAXCOL - 1;\n\t    if (type == DT_TAG)\n\t\tmax_num_matches = MAXCOL;\n\t    else\n\t\tmax_num_matches = cur_match + 1;\n\n\t    \/\/ when the argument starts with '\/', use it as a regexp\n\t    if (!no_regexp && *name == '\/')\n\t    {\n\t\tflags = TAG_REGEXP;\n\t\t++name;\n\t    }\n\t    else\n\t\tflags = TAG_NOIC;\n\n#ifdef FEAT_CSCOPE\n\t    if (type == DT_CSCOPE)\n\t\tflags = TAG_CSCOPE;\n#endif\n\t    if (verbose)\n\t\tflags |= TAG_VERBOSE;\n\n\t    if (!use_tfu)\n\t\tflags |= TAG_NO_TAGFUNC;\n\n\t    if (find_tags(name, &new_num_matches, &new_matches, flags,\n\t\t\t\t\t    max_num_matches, buf_ffname) == OK\n\t\t    && new_num_matches < max_num_matches)\n\t\tmax_num_matches = MAXCOL; \/\/ If less than max_num_matches\n\t\t\t\t\t  \/\/ found: all matches found.\n\n\t    \/\/ A tag function may do anything, which may cause various\n\t    \/\/ information to become invalid.  At least check for the tagstack\n\t    \/\/ to still be the same.\n\t    if (tagstack != curwin->w_tagstack)\n\t    {\n\t\temsg(_(e_window_unexpectedly_close_while_searching_for_tags));\n\t\tFreeWild(new_num_matches, new_matches);\n\t\tbreak;\n\t    }\n\n\t    \/\/ If there already were some matches for the same name, move them\n\t    \/\/ to the start.  Avoids that the order changes when using\n\t    \/\/ \":tnext\" and jumping to another file.\n\t    if (!new_tag && !other_name)\n\t    {\n\t\tint\t    j, k;\n\t\tint\t    idx = 0;\n\t\ttagptrs_T   tagp, tagp2;\n\n\t\t\/\/ Find the position of each old match in the new list.  Need\n\t\t\/\/ to use parse_match() to find the tag line.\n\t\tfor (j = 0; j < num_matches; ++j)\n\t\t{\n\t\t    parse_match(matches[j], &tagp);\n\t\t    for (i = idx; i < new_num_matches; ++i)\n\t\t    {\n\t\t\tparse_match(new_matches[i], &tagp2);\n\t\t\tif (STRCMP(tagp.tagname, tagp2.tagname) == 0)\n\t\t\t{\n\t\t\t    char_u *p = new_matches[i];\n\t\t\t    for (k = i; k > idx; --k)\n\t\t\t\tnew_matches[k] = new_matches[k - 1];\n\t\t\t    new_matches[idx++] = p;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    FreeWild(num_matches, matches);\n\t    num_matches = new_num_matches;\n\t    matches = new_matches;\n\t}\n\n\tif (num_matches <= 0)\n\t{\n\t    if (verbose)\n\t\tsemsg(_(e_tag_not_found_str), name);\n#if defined(FEAT_QUICKFIX)\n\t    g_do_tagpreview = 0;\n#endif\n\t}\n\telse\n\t{\n\t    int ask_for_selection = FALSE;\n\n#ifdef FEAT_CSCOPE\n\t    if (type == DT_CSCOPE && num_matches > 1)\n\t    {\n\t\tcs_print_tags();\n\t\task_for_selection = TRUE;\n\t    }\n\t    else\n#endif\n\t    if (type == DT_TAG && *tag != NUL)\n\t\t\/\/ If a count is supplied to the \":tag <name>\" command, then\n\t\t\/\/ jump to count'th matching tag.\n\t\tcur_match = count > 0 ? count - 1 : 0;\n\t    else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1))\n\t    {\n\t\tprint_tag_list(new_tag, use_tagstack, num_matches, matches);\n\t\task_for_selection = TRUE;\n\t    }\n#if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)\n\t    else if (type == DT_LTAG)\n\t    {\n\t\tif (add_llist_tags(tag, num_matches, matches) == FAIL)\n\t\t    goto end_do_tag;\n\t\tcur_match = 0;\t\t\/\/ Jump to the first tag\n\t    }\n#endif\n\n\t    if (ask_for_selection == TRUE)\n\t    {\n\t\t\/*\n\t\t * Ask to select a tag from the list.\n\t\t *\/\n\t\ti = prompt_for_number(NULL);\n\t\tif (i <= 0 || i > num_matches || got_int)\n\t\t{\n\t\t    \/\/ no valid choice: don't change anything\n\t\t    if (use_tagstack)\n\t\t    {\n\t\t\ttagstack[tagstackidx].fmark = saved_fmark;\n\t\t\ttagstackidx = prevtagstackidx;\n\t\t    }\n#ifdef FEAT_CSCOPE\n\t\t    cs_free_tags();\n\t\t    jumped_to_tag = TRUE;\n#endif\n\t\t    break;\n\t\t}\n\t\tcur_match = i - 1;\n\t    }\n\n\t    if (cur_match >= num_matches)\n\t    {\n\t\t\/\/ Avoid giving this error when a file wasn't found and we're\n\t\t\/\/ looking for a match in another file, which wasn't found.\n\t\t\/\/ There will be an emsg(\"file doesn't exist\") below then.\n\t\tif ((type == DT_NEXT || type == DT_FIRST)\n\t\t\t\t\t\t      && nofile_fname == NULL)\n\t\t{\n\t\t    if (num_matches == 1)\n\t\t\temsg(_(e_there_is_only_one_matching_tag));\n\t\t    else\n\t\t\temsg(_(e_cannot_go_beyond_last_matching_tag));\n\t\t    skip_msg = TRUE;\n\t\t}\n\t\tcur_match = num_matches - 1;\n\t    }\n\t    if (use_tagstack)\n\t    {\n\t\ttagptrs_T   tagp;\n\n\t\ttagstack[tagstackidx].cur_match = cur_match;\n\t\ttagstack[tagstackidx].cur_fnum = cur_fnum;\n\n\t\t\/\/ store user-provided data originating from tagfunc\n\t\tif (use_tfu && parse_match(matches[cur_match], &tagp) == OK\n\t\t\t&& tagp.user_data)\n\t\t{\n\t\t    VIM_CLEAR(tagstack[tagstackidx].user_data);\n\t\t    tagstack[tagstackidx].user_data = vim_strnsave(\n\t\t\t  tagp.user_data, tagp.user_data_end - tagp.user_data);\n\t\t}\n\n\t\t++tagstackidx;\n\t    }\n#if defined(FEAT_QUICKFIX)\n\t    else if (g_do_tagpreview != 0)\n\t    {\n\t\tptag_entry.cur_match = cur_match;\n\t\tptag_entry.cur_fnum = cur_fnum;\n\t    }\n#endif\n\n\t    \/*\n\t     * Only when going to try the next match, report that the previous\n\t     * file didn't exist.  Otherwise an emsg() is given below.\n\t     *\/\n\t    if (nofile_fname != NULL && error_cur_match != cur_match)\n\t\tsmsg(_(\"File \\\"%s\\\" does not exist\"), nofile_fname);\n\n\n\t    ic = (matches[cur_match][0] & MT_IC_OFF);\n\t    if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP\n#ifdef FEAT_CSCOPE\n\t\t&& type != DT_CSCOPE\n#endif\n\t\t&& (num_matches > 1 || ic)\n\t\t&& !skip_msg)\n\t    {\n\t\t\/\/ Give an indication of the number of matching tags\n\t\tsprintf((char *)IObuff, _(\"tag %d of %d%s\"),\n\t\t\t\tcur_match + 1,\n\t\t\t\tnum_matches,\n\t\t\t\tmax_num_matches != MAXCOL ? _(\" or more\") : \"\");\n\t\tif (ic)\n\t\t    STRCAT(IObuff, _(\"  Using tag with different case!\"));\n\t\tif ((num_matches > prev_num_matches || new_tag)\n\t\t\t\t\t\t\t   && num_matches > 1)\n\t\t{\n\t\t    if (ic)\n\t\t\tmsg_attr((char *)IObuff, HL_ATTR(HLF_W));\n\t\t    else\n\t\t\tmsg((char *)IObuff);\n\t\t    msg_scroll = TRUE;\t\/\/ don't overwrite this message\n\t\t}\n\t\telse\n\t\t    give_warning(IObuff, ic);\n\t\tif (ic && !msg_scrolled && msg_silent == 0)\n\t\t{\n\t\t    out_flush();\n\t\t    ui_delay(1007L, TRUE);\n\t\t}\n\t    }\n\n#if defined(FEAT_EVAL)\n\t    \/\/ Let the SwapExists event know what tag we are jumping to.\n\t    vim_snprintf((char *)IObuff, IOSIZE, \":ta %s\\r\", name);\n\t    set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);\n#endif\n\n\t    \/*\n\t     * Jump to the desired match.\n\t     *\/\n\t    i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE);\n\n#if defined(FEAT_EVAL)\n\t    set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);\n#endif\n\n\t    if (i == NOTAGFILE)\n\t    {\n\t\t\/\/ File not found: try again with another matching tag\n\t\tif ((type == DT_PREV && cur_match > 0)\n\t\t\t|| ((type == DT_TAG || type == DT_NEXT\n\t\t\t\t\t\t\t  || type == DT_FIRST)\n\t\t\t    && (max_num_matches != MAXCOL\n\t\t\t\t\t     || cur_match < num_matches - 1)))\n\t\t{\n\t\t    error_cur_match = cur_match;\n\t\t    if (use_tagstack)\n\t\t\t--tagstackidx;\n\t\t    if (type == DT_PREV)\n\t\t\t--cur_match;\n\t\t    else\n\t\t    {\n\t\t\ttype = DT_NEXT;\n\t\t\t++cur_match;\n\t\t    }\n\t\t    continue;\n\t\t}\n\t\tsemsg(_(e_file_str_does_not_exist), nofile_fname);\n\t    }\n\t    else\n\t    {\n\t\t\/\/ We may have jumped to another window, check that\n\t\t\/\/ tagstackidx is still valid.\n\t\tif (use_tagstack && tagstackidx > curwin->w_tagstacklen)\n\t\t    tagstackidx = curwin->w_tagstackidx;\n#ifdef FEAT_CSCOPE\n\t\tjumped_to_tag = TRUE;\n#endif\n\t    }\n\t}\n\tbreak;\n    }\n\nend_do_tag:\n    \/\/ Only store the new index when using the tagstack and it's valid.\n    if (use_tagstack && tagstackidx <= curwin->w_tagstacklen)\n\tcurwin->w_tagstackidx = tagstackidx;\n    postponed_split = 0;\t\/\/ don't split next time\n# ifdef FEAT_QUICKFIX\n    g_do_tagpreview = 0;\t\/\/ don't do tag preview next time\n# endif\n\n    vim_free(tofree);\n#ifdef FEAT_CSCOPE\n    return jumped_to_tag;\n#else\n    return FALSE;\n#endif\n}","target":0,"code_token_length":5189,"total_token_length":5425,"max_tokens_setting":6144}
+{"idx":238761,"func":"findmatchlimit(\n    oparg_T\t*oap,\n    int\t\tinitc,\n    int\t\tflags,\n    int\t\tmaxtravel)\n{\n    static pos_T pos;\t\t\t\/\/ current search position\n    int\t\tfindc = 0;\t\t\/\/ matching brace\n    int\t\tc;\n    int\t\tcount = 0;\t\t\/\/ cumulative number of braces\n    int\t\tbackwards = FALSE;\t\/\/ init for gcc\n    int\t\traw_string = FALSE;\t\/\/ search for raw string\n    int\t\tinquote = FALSE;\t\/\/ TRUE when inside quotes\n    char_u\t*linep;\t\t\t\/\/ pointer to current line\n    char_u\t*ptr;\n    int\t\tdo_quotes;\t\t\/\/ check for quotes in current line\n    int\t\tat_start;\t\t\/\/ do_quotes value at start position\n    int\t\thash_dir = 0;\t\t\/\/ Direction searched for # things\n    int\t\tcomment_dir = 0;\t\/\/ Direction searched for comments\n    pos_T\tmatch_pos;\t\t\/\/ Where last slash-star was found\n    int\t\tstart_in_quotes;\t\/\/ start position is in quotes\n    int\t\ttraveled = 0;\t\t\/\/ how far we've searched so far\n    int\t\tignore_cend = FALSE;    \/\/ ignore comment end\n    int\t\tcpo_match;\t\t\/\/ vi compatible matching\n    int\t\tcpo_bsl;\t\t\/\/ don't recognize backslashes\n    int\t\tmatch_escaped = 0;\t\/\/ search for escaped match\n    int\t\tdir;\t\t\t\/\/ Direction to search\n    int\t\tcomment_col = MAXCOL;   \/\/ start of \/ \/ comment\n    int\t\tlispcomm = FALSE;\t\/\/ inside of Lisp-style comment\n    int\t\tlisp = curbuf->b_p_lisp; \/\/ engage Lisp-specific hacks ;)\n\n    pos = curwin->w_cursor;\n    pos.coladd = 0;\n    linep = ml_get(pos.lnum);\n\n    cpo_match = (vim_strchr(p_cpo, CPO_MATCH) != NULL);\n    cpo_bsl = (vim_strchr(p_cpo, CPO_MATCHBSL) != NULL);\n\n    \/\/ Direction to search when initc is '\/', '*' or '#'\n    if (flags & FM_BACKWARD)\n\tdir = BACKWARD;\n    else if (flags & FM_FORWARD)\n\tdir = FORWARD;\n    else\n\tdir = 0;\n\n    \/*\n     * if initc given, look in the table for the matching character\n     * '\/' and '*' are special cases: look for start or end of comment.\n     * When '\/' is used, we ignore running backwards into an star-slash, for\n     * \"[*\" command, we just want to find any comment.\n     *\/\n    if (initc == '\/' || initc == '*' || initc == 'R')\n    {\n\tcomment_dir = dir;\n\tif (initc == '\/')\n\t    ignore_cend = TRUE;\n\tbackwards = (dir == FORWARD) ? FALSE : TRUE;\n\traw_string = (initc == 'R');\n\tinitc = NUL;\n    }\n    else if (initc != '#' && initc != NUL)\n    {\n\tfind_mps_values(&initc, &findc, &backwards, TRUE);\n\tif (dir)\n\t    backwards = (dir == FORWARD) ? FALSE : TRUE;\n\tif (findc == NUL)\n\t    return NULL;\n    }\n    else\n    {\n\t\/*\n\t * Either initc is '#', or no initc was given and we need to look\n\t * under the cursor.\n\t *\/\n\tif (initc == '#')\n\t{\n\t    hash_dir = dir;\n\t}\n\telse\n\t{\n\t    \/*\n\t     * initc was not given, must look for something to match under\n\t     * or near the cursor.\n\t     * Only check for special things when 'cpo' doesn't have '%'.\n\t     *\/\n\t    if (!cpo_match)\n\t    {\n\t\t\/\/ Are we before or at #if, #else etc.?\n\t\tptr = skipwhite(linep);\n\t\tif (*ptr == '#' && pos.col <= (colnr_T)(ptr - linep))\n\t\t{\n\t\t    ptr = skipwhite(ptr + 1);\n\t\t    if (   STRNCMP(ptr, \"if\", 2) == 0\n\t\t\t|| STRNCMP(ptr, \"endif\", 5) == 0\n\t\t\t|| STRNCMP(ptr, \"el\", 2) == 0)\n\t\t\thash_dir = 1;\n\t\t}\n\n\t\t\/\/ Are we on a comment?\n\t\telse if (linep[pos.col] == '\/')\n\t\t{\n\t\t    if (linep[pos.col + 1] == '*')\n\t\t    {\n\t\t\tcomment_dir = FORWARD;\n\t\t\tbackwards = FALSE;\n\t\t\tpos.col++;\n\t\t    }\n\t\t    else if (pos.col > 0 && linep[pos.col - 1] == '*')\n\t\t    {\n\t\t\tcomment_dir = BACKWARD;\n\t\t\tbackwards = TRUE;\n\t\t\tpos.col--;\n\t\t    }\n\t\t}\n\t\telse if (linep[pos.col] == '*')\n\t\t{\n\t\t    if (linep[pos.col + 1] == '\/')\n\t\t    {\n\t\t\tcomment_dir = BACKWARD;\n\t\t\tbackwards = TRUE;\n\t\t    }\n\t\t    else if (pos.col > 0 && linep[pos.col - 1] == '\/')\n\t\t    {\n\t\t\tcomment_dir = FORWARD;\n\t\t\tbackwards = FALSE;\n\t\t    }\n\t\t}\n\t    }\n\n\t    \/*\n\t     * If we are not on a comment or the # at the start of a line, then\n\t     * look for brace anywhere on this line after the cursor.\n\t     *\/\n\t    if (!hash_dir && !comment_dir)\n\t    {\n\t\t\/*\n\t\t * Find the brace under or after the cursor.\n\t\t * If beyond the end of the line, use the last character in\n\t\t * the line.\n\t\t *\/\n\t\tif (linep[pos.col] == NUL && pos.col)\n\t\t    --pos.col;\n\t\tfor (;;)\n\t\t{\n\t\t    initc = PTR2CHAR(linep + pos.col);\n\t\t    if (initc == NUL)\n\t\t\tbreak;\n\n\t\t    find_mps_values(&initc, &findc, &backwards, FALSE);\n\t\t    if (findc)\n\t\t\tbreak;\n\t\t    pos.col += mb_ptr2len(linep + pos.col);\n\t\t}\n\t\tif (!findc)\n\t\t{\n\t\t    \/\/ no brace in the line, maybe use \"  #if\" then\n\t\t    if (!cpo_match && *skipwhite(linep) == '#')\n\t\t\thash_dir = 1;\n\t\t    else\n\t\t\treturn NULL;\n\t\t}\n\t\telse if (!cpo_bsl)\n\t\t{\n\t\t    int col, bslcnt = 0;\n\n\t\t    \/\/ Set \"match_escaped\" if there are an odd number of\n\t\t    \/\/ backslashes.\n\t\t    for (col = pos.col; check_prevcol(linep, col, '\\\\', &col);)\n\t\t\tbslcnt++;\n\t\t    match_escaped = (bslcnt & 1);\n\t\t}\n\t    }\n\t}\n\tif (hash_dir)\n\t{\n\t    \/*\n\t     * Look for matching #if, #else, #elif, or #endif\n\t     *\/\n\t    if (oap != NULL)\n\t\toap->motion_type = MLINE;   \/\/ Linewise for this case only\n\t    if (initc != '#')\n\t    {\n\t\tptr = skipwhite(skipwhite(linep) + 1);\n\t\tif (STRNCMP(ptr, \"if\", 2) == 0 || STRNCMP(ptr, \"el\", 2) == 0)\n\t\t    hash_dir = 1;\n\t\telse if (STRNCMP(ptr, \"endif\", 5) == 0)\n\t\t    hash_dir = -1;\n\t\telse\n\t\t    return NULL;\n\t    }\n\t    pos.col = 0;\n\t    while (!got_int)\n\t    {\n\t\tif (hash_dir > 0)\n\t\t{\n\t\t    if (pos.lnum == curbuf->b_ml.ml_line_count)\n\t\t\tbreak;\n\t\t}\n\t\telse if (pos.lnum == 1)\n\t\t    break;\n\t\tpos.lnum += hash_dir;\n\t\tlinep = ml_get(pos.lnum);\n\t\tline_breakcheck();\t\/\/ check for CTRL-C typed\n\t\tptr = skipwhite(linep);\n\t\tif (*ptr != '#')\n\t\t    continue;\n\t\tpos.col = (colnr_T) (ptr - linep);\n\t\tptr = skipwhite(ptr + 1);\n\t\tif (hash_dir > 0)\n\t\t{\n\t\t    if (STRNCMP(ptr, \"if\", 2) == 0)\n\t\t\tcount++;\n\t\t    else if (STRNCMP(ptr, \"el\", 2) == 0)\n\t\t    {\n\t\t\tif (count == 0)\n\t\t\t    return &pos;\n\t\t    }\n\t\t    else if (STRNCMP(ptr, \"endif\", 5) == 0)\n\t\t    {\n\t\t\tif (count == 0)\n\t\t\t    return &pos;\n\t\t\tcount--;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    if (STRNCMP(ptr, \"if\", 2) == 0)\n\t\t    {\n\t\t\tif (count == 0)\n\t\t\t    return &pos;\n\t\t\tcount--;\n\t\t    }\n\t\t    else if (initc == '#' && STRNCMP(ptr, \"el\", 2) == 0)\n\t\t    {\n\t\t\tif (count == 0)\n\t\t\t    return &pos;\n\t\t    }\n\t\t    else if (STRNCMP(ptr, \"endif\", 5) == 0)\n\t\t\tcount++;\n\t\t}\n\t    }\n\t    return NULL;\n\t}\n    }\n\n#ifdef FEAT_RIGHTLEFT\n    \/\/ This is just guessing: when 'rightleft' is set, search for a matching\n    \/\/ paren\/brace in the other direction.\n    if (curwin->w_p_rl && vim_strchr((char_u *)\"()[]{}<>\", initc) != NULL)\n\tbackwards = !backwards;\n#endif\n\n    do_quotes = -1;\n    start_in_quotes = MAYBE;\n    CLEAR_POS(&match_pos);\n\n    \/\/ backward search: Check if this line contains a single-line comment\n    if ((backwards && comment_dir) || lisp)\n\tcomment_col = check_linecomment(linep);\n    if (lisp && comment_col != MAXCOL && pos.col > (colnr_T)comment_col)\n\tlispcomm = TRUE;    \/\/ find match inside this comment\n\n    while (!got_int)\n    {\n\t\/*\n\t * Go to the next position, forward or backward. We could use\n\t * inc() and dec() here, but that is much slower\n\t *\/\n\tif (backwards)\n\t{\n\t    \/\/ char to match is inside of comment, don't search outside\n\t    if (lispcomm && pos.col < (colnr_T)comment_col)\n\t\tbreak;\n\t    if (pos.col == 0)\t\t\/\/ at start of line, go to prev. one\n\t    {\n\t\tif (pos.lnum == 1)\t\/\/ start of file\n\t\t    break;\n\t\t--pos.lnum;\n\n\t\tif (maxtravel > 0 && ++traveled > maxtravel)\n\t\t    break;\n\n\t\tlinep = ml_get(pos.lnum);\n\t\tpos.col = (colnr_T)STRLEN(linep); \/\/ pos.col on trailing NUL\n\t\tdo_quotes = -1;\n\t\tline_breakcheck();\n\n\t\t\/\/ Check if this line contains a single-line comment\n\t\tif (comment_dir || lisp)\n\t\t    comment_col = check_linecomment(linep);\n\t\t\/\/ skip comment\n\t\tif (lisp && comment_col != MAXCOL)\n\t\t    pos.col = comment_col;\n\t    }\n\t    else\n\t    {\n\t\t--pos.col;\n\t\tif (has_mbyte)\n\t\t    pos.col -= (*mb_head_off)(linep, linep + pos.col);\n\t    }\n\t}\n\telse\t\t\t\t\/\/ forward search\n\t{\n\t    if (linep[pos.col] == NUL\n\t\t    \/\/ at end of line, go to next one\n\t\t    \/\/ For lisp don't search for match in comment\n\t\t    || (lisp && comment_col != MAXCOL\n\t\t\t\t\t   && pos.col == (colnr_T)comment_col))\n\t    {\n\t\tif (pos.lnum == curbuf->b_ml.ml_line_count  \/\/ end of file\n\t\t\t\/\/ line is exhausted and comment with it,\n\t\t\t\/\/ don't search for match in code\n\t\t\t || lispcomm)\n\t\t    break;\n\t\t++pos.lnum;\n\n\t\tif (maxtravel && traveled++ > maxtravel)\n\t\t    break;\n\n\t\tlinep = ml_get(pos.lnum);\n\t\tpos.col = 0;\n\t\tdo_quotes = -1;\n\t\tline_breakcheck();\n\t\tif (lisp)   \/\/ find comment pos in new line\n\t\t    comment_col = check_linecomment(linep);\n\t    }\n\t    else\n\t    {\n\t\tif (has_mbyte)\n\t\t    pos.col += (*mb_ptr2len)(linep + pos.col);\n\t\telse\n\t\t    ++pos.col;\n\t    }\n\t}\n\n\t\/*\n\t * If FM_BLOCKSTOP given, stop at a '{' or '}' in column 0.\n\t *\/\n\tif (pos.col == 0 && (flags & FM_BLOCKSTOP)\n\t\t\t\t       && (linep[0] == '{' || linep[0] == '}'))\n\t{\n\t    if (linep[0] == findc && count == 0)\t\/\/ match!\n\t\treturn &pos;\n\t    break;\t\t\t\t\t\/\/ out of scope\n\t}\n\n\tif (comment_dir)\n\t{\n\t    \/\/ Note: comments do not nest, and we ignore quotes in them\n\t    \/\/ TODO: ignore comment brackets inside strings\n\t    if (comment_dir == FORWARD)\n\t    {\n\t\tif (linep[pos.col] == '*' && linep[pos.col + 1] == '\/')\n\t\t{\n\t\t    pos.col++;\n\t\t    return &pos;\n\t\t}\n\t    }\n\t    else    \/\/ Searching backwards\n\t    {\n\t\t\/*\n\t\t * A comment may contain \/ * or \/ \/, it may also start or end\n\t\t * with \/ * \/.\tIgnore a \/ * after \/ \/ and after *.\n\t\t *\/\n\t\tif (pos.col == 0)\n\t\t    continue;\n\t\telse if (raw_string)\n\t\t{\n\t\t    if (linep[pos.col - 1] == 'R'\n\t\t\t&& linep[pos.col] == '\"'\n\t\t\t&& vim_strchr(linep + pos.col + 1, '(') != NULL)\n\t\t    {\n\t\t\t\/\/ Possible start of raw string. Now that we have the\n\t\t\t\/\/ delimiter we can check if it ends before where we\n\t\t\t\/\/ started searching, or before the previously found\n\t\t\t\/\/ raw string start.\n\t\t\tif (!find_rawstring_end(linep, &pos,\n\t\t\t\t  count > 0 ? &match_pos : &curwin->w_cursor))\n\t\t\t{\n\t\t\t    count++;\n\t\t\t    match_pos = pos;\n\t\t\t    match_pos.col--;\n\t\t\t}\n\t\t\tlinep = ml_get(pos.lnum); \/\/ may have been released\n\t\t    }\n\t\t}\n\t\telse if (  linep[pos.col - 1] == '\/'\n\t\t\t&& linep[pos.col] == '*'\n\t\t\t&& (pos.col == 1 || linep[pos.col - 2] != '*')\n\t\t\t&& (int)pos.col < comment_col)\n\t\t{\n\t\t    count++;\n\t\t    match_pos = pos;\n\t\t    match_pos.col--;\n\t\t}\n\t\telse if (linep[pos.col - 1] == '*' && linep[pos.col] == '\/')\n\t\t{\n\t\t    if (count > 0)\n\t\t\tpos = match_pos;\n\t\t    else if (pos.col > 1 && linep[pos.col - 2] == '\/'\n\t\t\t\t\t       && (int)pos.col <= comment_col)\n\t\t\tpos.col -= 2;\n\t\t    else if (ignore_cend)\n\t\t\tcontinue;\n\t\t    else\n\t\t\treturn NULL;\n\t\t    return &pos;\n\t\t}\n\t    }\n\t    continue;\n\t}\n\n\t\/*\n\t * If smart matching ('cpoptions' does not contain '%'), braces inside\n\t * of quotes are ignored, but only if there is an even number of\n\t * quotes in the line.\n\t *\/\n\tif (cpo_match)\n\t    do_quotes = 0;\n\telse if (do_quotes == -1)\n\t{\n\t    \/*\n\t     * Count the number of quotes in the line, skipping \\\" and '\"'.\n\t     * Watch out for \"\\\\\".\n\t     *\/\n\t    at_start = do_quotes;\n\t    for (ptr = linep; *ptr; ++ptr)\n\t    {\n\t\tif (ptr == linep + pos.col + backwards)\n\t\t    at_start = (do_quotes & 1);\n\t\tif (*ptr == '\"'\n\t\t\t&& (ptr == linep || ptr[-1] != '\\'' || ptr[1] != '\\''))\n\t\t    ++do_quotes;\n\t\tif (*ptr == '\\\\' && ptr[1] != NUL)\n\t\t    ++ptr;\n\t    }\n\t    do_quotes &= 1;\t    \/\/ result is 1 with even number of quotes\n\n\t    \/*\n\t     * If we find an uneven count, check current line and previous\n\t     * one for a '\\' at the end.\n\t     *\/\n\t    if (!do_quotes)\n\t    {\n\t\tinquote = FALSE;\n\t\tif (ptr[-1] == '\\\\')\n\t\t{\n\t\t    do_quotes = 1;\n\t\t    if (start_in_quotes == MAYBE)\n\t\t    {\n\t\t\t\/\/ Do we need to use at_start here?\n\t\t\tinquote = TRUE;\n\t\t\tstart_in_quotes = TRUE;\n\t\t    }\n\t\t    else if (backwards)\n\t\t\tinquote = TRUE;\n\t\t}\n\t\tif (pos.lnum > 1)\n\t\t{\n\t\t    ptr = ml_get(pos.lnum - 1);\n\t\t    if (*ptr && *(ptr + STRLEN(ptr) - 1) == '\\\\')\n\t\t    {\n\t\t\tdo_quotes = 1;\n\t\t\tif (start_in_quotes == MAYBE)\n\t\t\t{\n\t\t\t    inquote = at_start;\n\t\t\t    if (inquote)\n\t\t\t\tstart_in_quotes = TRUE;\n\t\t\t}\n\t\t\telse if (!backwards)\n\t\t\t    inquote = TRUE;\n\t\t    }\n\n\t\t    \/\/ ml_get() only keeps one line, need to get linep again\n\t\t    linep = ml_get(pos.lnum);\n\t\t}\n\t    }\n\t}\n\tif (start_in_quotes == MAYBE)\n\t    start_in_quotes = FALSE;\n\n\t\/*\n\t * If 'smartmatch' is set:\n\t *   Things inside quotes are ignored by setting 'inquote'.  If we\n\t *   find a quote without a preceding '\\' invert 'inquote'.  At the\n\t *   end of a line not ending in '\\' we reset 'inquote'.\n\t *\n\t *   In lines with an uneven number of quotes (without preceding '\\')\n\t *   we do not know which part to ignore. Therefore we only set\n\t *   inquote if the number of quotes in a line is even, unless this\n\t *   line or the previous one ends in a '\\'.  Complicated, isn't it?\n\t *\/\n\tc = PTR2CHAR(linep + pos.col);\n\tswitch (c)\n\t{\n\tcase NUL:\n\t    \/\/ at end of line without trailing backslash, reset inquote\n\t    if (pos.col == 0 || linep[pos.col - 1] != '\\\\')\n\t    {\n\t\tinquote = FALSE;\n\t\tstart_in_quotes = FALSE;\n\t    }\n\t    break;\n\n\tcase '\"':\n\t    \/\/ a quote that is preceded with an odd number of backslashes is\n\t    \/\/ ignored\n\t    if (do_quotes)\n\t    {\n\t\tint col;\n\n\t\tfor (col = pos.col - 1; col >= 0; --col)\n\t\t    if (linep[col] != '\\\\')\n\t\t\tbreak;\n\t\tif ((((int)pos.col - 1 - col) & 1) == 0)\n\t\t{\n\t\t    inquote = !inquote;\n\t\t    start_in_quotes = FALSE;\n\t\t}\n\t    }\n\t    break;\n\n\t\/*\n\t * If smart matching ('cpoptions' does not contain '%'):\n\t *   Skip things in single quotes: 'x' or '\\x'.  Be careful for single\n\t *   single quotes, eg jon's.  Things like '\\233' or '\\x3f' are not\n\t *   skipped, there is never a brace in them.\n\t *   Ignore this when finding matches for `'.\n\t *\/\n\tcase '\\'':\n\t    if (!cpo_match && initc != '\\'' && findc != '\\'')\n\t    {\n\t\tif (backwards)\n\t\t{\n\t\t    if (pos.col > 1)\n\t\t    {\n\t\t\tif (linep[pos.col - 2] == '\\'')\n\t\t\t{\n\t\t\t    pos.col -= 2;\n\t\t\t    break;\n\t\t\t}\n\t\t\telse if (linep[pos.col - 2] == '\\\\'\n\t\t\t\t  && pos.col > 2 && linep[pos.col - 3] == '\\'')\n\t\t\t{\n\t\t\t    pos.col -= 3;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse if (linep[pos.col + 1])\t\/\/ forward search\n\t\t{\n\t\t    if (linep[pos.col + 1] == '\\\\'\n\t\t\t   && linep[pos.col + 2] && linep[pos.col + 3] == '\\'')\n\t\t    {\n\t\t\tpos.col += 3;\n\t\t\tbreak;\n\t\t    }\n\t\t    else if (linep[pos.col + 2] == '\\'')\n\t\t    {\n\t\t\tpos.col += 2;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tdefault:\n\t    \/*\n\t     * For Lisp skip over backslashed (), {} and [].\n\t     * (actually, we skip #\\( et al)\n\t     *\/\n\t    if (curbuf->b_p_lisp\n\t\t    && vim_strchr((char_u *)\"(){}[]\", c) != NULL\n\t\t    && pos.col > 1\n\t\t    && check_prevcol(linep, pos.col, '\\\\', NULL)\n\t\t    && check_prevcol(linep, pos.col - 1, '#', NULL))\n\t\tbreak;\n\n\t    \/\/ Check for match outside of quotes, and inside of\n\t    \/\/ quotes when the start is also inside of quotes.\n\t    if ((!inquote || start_in_quotes == TRUE)\n\t\t    && (c == initc || c == findc))\n\t    {\n\t\tint\tcol, bslcnt = 0;\n\n\t\tif (!cpo_bsl)\n\t\t{\n\t\t    for (col = pos.col; check_prevcol(linep, col, '\\\\', &col);)\n\t\t\tbslcnt++;\n\t\t}\n\t\t\/\/ Only accept a match when 'M' is in 'cpo' or when escaping\n\t\t\/\/ is what we expect.\n\t\tif (cpo_bsl || (bslcnt & 1) == match_escaped)\n\t\t{\n\t\t    if (c == initc)\n\t\t\tcount++;\n\t\t    else\n\t\t    {\n\t\t\tif (count == 0)\n\t\t\t    return &pos;\n\t\t\tcount--;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n\n    if (comment_dir == BACKWARD && count > 0)\n    {\n\tpos = match_pos;\n\treturn &pos;\n    }\n    return (pos_T *)NULL;\t\/\/ never found it\n}","target":0,"code_token_length":4814,"total_token_length":5050,"max_tokens_setting":6144}
+{"idx":326087,"func":"regatom(int *flagp)\n{\n    char_u\t    *ret;\n    int\t\t    flags;\n    int\t\t    c;\n    char_u\t    *p;\n    int\t\t    extra = 0;\n    int\t\t    save_prev_at_start = prev_at_start;\n\n    *flagp = WORST;\t\t\/\/ Tentatively.\n\n    c = getchr();\n    switch (c)\n    {\n      case Magic('^'):\n\tret = regnode(BOL);\n\tbreak;\n\n      case Magic('$'):\n\tret = regnode(EOL);\n#if defined(FEAT_SYN_HL) || defined(PROTO)\n\thad_eol = TRUE;\n#endif\n\tbreak;\n\n      case Magic('<'):\n\tret = regnode(BOW);\n\tbreak;\n\n      case Magic('>'):\n\tret = regnode(EOW);\n\tbreak;\n\n      case Magic('_'):\n\tc = no_Magic(getchr());\n\tif (c == '^')\t\t\/\/ \"\\_^\" is start-of-line\n\t{\n\t    ret = regnode(BOL);\n\t    break;\n\t}\n\tif (c == '$')\t\t\/\/ \"\\_$\" is end-of-line\n\t{\n\t    ret = regnode(EOL);\n#if defined(FEAT_SYN_HL) || defined(PROTO)\n\t    had_eol = TRUE;\n#endif\n\t    break;\n\t}\n\n\textra = ADD_NL;\n\t*flagp |= HASNL;\n\n\t\/\/ \"\\_[\" is character range plus newline\n\tif (c == '[')\n\t    goto collection;\n\n\t\/\/ \"\\_x\" is character class plus newline\n\t\/\/ FALLTHROUGH\n\n\t\/\/ Character classes.\n      case Magic('.'):\n      case Magic('i'):\n      case Magic('I'):\n      case Magic('k'):\n      case Magic('K'):\n      case Magic('f'):\n      case Magic('F'):\n      case Magic('p'):\n      case Magic('P'):\n      case Magic('s'):\n      case Magic('S'):\n      case Magic('d'):\n      case Magic('D'):\n      case Magic('x'):\n      case Magic('X'):\n      case Magic('o'):\n      case Magic('O'):\n      case Magic('w'):\n      case Magic('W'):\n      case Magic('h'):\n      case Magic('H'):\n      case Magic('a'):\n      case Magic('A'):\n      case Magic('l'):\n      case Magic('L'):\n      case Magic('u'):\n      case Magic('U'):\n\tp = vim_strchr(classchars, no_Magic(c));\n\tif (p == NULL)\n\t    EMSG_RET_NULL(_(e_invalid_use_of_underscore));\n\n\t\/\/ When '.' is followed by a composing char ignore the dot, so that\n\t\/\/ the composing char is matched here.\n\tif (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr()))\n\t{\n\t    c = getchr();\n\t    goto do_multibyte;\n\t}\n\tret = regnode(classcodes[p - classchars] + extra);\n\t*flagp |= HASWIDTH | SIMPLE;\n\tbreak;\n\n      case Magic('n'):\n\tif (reg_string)\n\t{\n\t    \/\/ In a string \"\\n\" matches a newline character.\n\t    ret = regnode(EXACTLY);\n\t    regc(NL);\n\t    regc(NUL);\n\t    *flagp |= HASWIDTH | SIMPLE;\n\t}\n\telse\n\t{\n\t    \/\/ In buffer text \"\\n\" matches the end of a line.\n\t    ret = regnode(NEWL);\n\t    *flagp |= HASWIDTH | HASNL;\n\t}\n\tbreak;\n\n      case Magic('('):\n\tif (one_exactly)\n\t    EMSG_ONE_RET_NULL;\n\tret = reg(REG_PAREN, &flags);\n\tif (ret == NULL)\n\t    return NULL;\n\t*flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);\n\tbreak;\n\n      case NUL:\n      case Magic('|'):\n      case Magic('&'):\n      case Magic(')'):\n\tif (one_exactly)\n\t    EMSG_ONE_RET_NULL;\n\t\/\/ Supposed to be caught earlier.\n\tIEMSG_RET_NULL(_(e_internal_error_in_regexp));\n\t\/\/ NOTREACHED\n\n      case Magic('='):\n      case Magic('?'):\n      case Magic('+'):\n      case Magic('@'):\n      case Magic('{'):\n      case Magic('*'):\n\tc = no_Magic(c);\n\tEMSG3_RET_NULL(_(e_str_chr_follows_nothing),\n\t\t(c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL), c);\n\t\/\/ NOTREACHED\n\n      case Magic('~'):\t\t\/\/ previous substitute pattern\n\t    if (reg_prev_sub != NULL)\n\t    {\n\t\tchar_u\t    *lp;\n\n\t\tret = regnode(EXACTLY);\n\t\tlp = reg_prev_sub;\n\t\twhile (*lp != NUL)\n\t\t    regc(*lp++);\n\t\tregc(NUL);\n\t\tif (*reg_prev_sub != NUL)\n\t\t{\n\t\t    *flagp |= HASWIDTH;\n\t\t    if ((lp - reg_prev_sub) == 1)\n\t\t\t*flagp |= SIMPLE;\n\t\t}\n\t    }\n\t    else\n\t\tEMSG_RET_NULL(_(e_no_previous_substitute_regular_expression));\n\t    break;\n\n      case Magic('1'):\n      case Magic('2'):\n      case Magic('3'):\n      case Magic('4'):\n      case Magic('5'):\n      case Magic('6'):\n      case Magic('7'):\n      case Magic('8'):\n      case Magic('9'):\n\t    {\n\t\tint\t\t    refnum;\n\n\t\trefnum = c - Magic('0');\n\t\tif (!seen_endbrace(refnum))\n\t\t    return NULL;\n\t\tret = regnode(BACKREF + refnum);\n\t    }\n\t    break;\n\n      case Magic('z'):\n\t{\n\t    c = no_Magic(getchr());\n\t    switch (c)\n\t    {\n#ifdef FEAT_SYN_HL\n\t\tcase '(': if ((reg_do_extmatch & REX_SET) == 0)\n\t\t\t      EMSG_RET_NULL(_(e_z_not_allowed_here));\n\t\t\t  if (one_exactly)\n\t\t\t      EMSG_ONE_RET_NULL;\n\t\t\t  ret = reg(REG_ZPAREN, &flags);\n\t\t\t  if (ret == NULL)\n\t\t\t      return NULL;\n\t\t\t  *flagp |= flags & (HASWIDTH|SPSTART|HASNL|HASLOOKBH);\n\t\t\t  re_has_z = REX_SET;\n\t\t\t  break;\n\n\t\tcase '1':\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '4':\n\t\tcase '5':\n\t\tcase '6':\n\t\tcase '7':\n\t\tcase '8':\n\t\tcase '9': if ((reg_do_extmatch & REX_USE) == 0)\n\t\t\t      EMSG_RET_NULL(_(e_z1_z9_not_allowed_here));\n\t\t\t  ret = regnode(ZREF + c - '0');\n\t\t\t  re_has_z = REX_USE;\n\t\t\t  break;\n#endif\n\n\t\tcase 's': ret = regnode(MOPEN + 0);\n\t\t\t  if (re_mult_next(\"\\\\zs\") == FAIL)\n\t\t\t      return NULL;\n\t\t\t  break;\n\n\t\tcase 'e': ret = regnode(MCLOSE + 0);\n\t\t\t  if (re_mult_next(\"\\\\ze\") == FAIL)\n\t\t\t      return NULL;\n\t\t\t  break;\n\n\t\tdefault:  EMSG_RET_NULL(_(e_invalid_character_after_bsl_z));\n\t    }\n\t}\n\tbreak;\n\n      case Magic('%'):\n\t{\n\t    c = no_Magic(getchr());\n\t    switch (c)\n\t    {\n\t\t\/\/ () without a back reference\n\t\tcase '(':\n\t\t    if (one_exactly)\n\t\t\tEMSG_ONE_RET_NULL;\n\t\t    ret = reg(REG_NPAREN, &flags);\n\t\t    if (ret == NULL)\n\t\t\treturn NULL;\n\t\t    *flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);\n\t\t    break;\n\n\t\t\/\/ Catch \\%^ and \\%$ regardless of where they appear in the\n\t\t\/\/ pattern -- regardless of whether or not it makes sense.\n\t\tcase '^':\n\t\t    ret = regnode(RE_BOF);\n\t\t    break;\n\n\t\tcase '$':\n\t\t    ret = regnode(RE_EOF);\n\t\t    break;\n\n\t\tcase '#':\n\t\t    ret = regnode(CURSOR);\n\t\t    break;\n\n\t\tcase 'V':\n\t\t    ret = regnode(RE_VISUAL);\n\t\t    break;\n\n\t\tcase 'C':\n\t\t    ret = regnode(RE_COMPOSING);\n\t\t    break;\n\n\t\t\/\/ \\%[abc]: Emit as a list of branches, all ending at the last\n\t\t\/\/ branch which matches nothing.\n\t\tcase '[':\n\t\t\t  if (one_exactly)\t\/\/ doesn't nest\n\t\t\t      EMSG_ONE_RET_NULL;\n\t\t\t  {\n\t\t\t      char_u\t*lastbranch;\n\t\t\t      char_u\t*lastnode = NULL;\n\t\t\t      char_u\t*br;\n\n\t\t\t      ret = NULL;\n\t\t\t      while ((c = getchr()) != ']')\n\t\t\t      {\n\t\t\t\t  if (c == NUL)\n\t\t\t\t      EMSG2_RET_NULL(_(e_missing_sb_after_str),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t\t\t\t  br = regnode(BRANCH);\n\t\t\t\t  if (ret == NULL)\n\t\t\t\t      ret = br;\n\t\t\t\t  else\n\t\t\t\t  {\n\t\t\t\t      regtail(lastnode, br);\n\t\t\t\t      if (reg_toolong)\n\t\t\t\t\t  return NULL;\n\t\t\t\t  }\n\n\t\t\t\t  ungetchr();\n\t\t\t\t  one_exactly = TRUE;\n\t\t\t\t  lastnode = regatom(flagp);\n\t\t\t\t  one_exactly = FALSE;\n\t\t\t\t  if (lastnode == NULL)\n\t\t\t\t      return NULL;\n\t\t\t      }\n\t\t\t      if (ret == NULL)\n\t\t\t\t  EMSG2_RET_NULL(_(e_empty_str_brackets),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t\t\t      lastbranch = regnode(BRANCH);\n\t\t\t      br = regnode(NOTHING);\n\t\t\t      if (ret != JUST_CALC_SIZE)\n\t\t\t      {\n\t\t\t\t  regtail(lastnode, br);\n\t\t\t\t  regtail(lastbranch, br);\n\t\t\t\t  \/\/ connect all branches to the NOTHING\n\t\t\t\t  \/\/ branch at the end\n\t\t\t\t  for (br = ret; br != lastnode; )\n\t\t\t\t  {\n\t\t\t\t      if (OP(br) == BRANCH)\n\t\t\t\t      {\n\t\t\t\t\t  regtail(br, lastbranch);\n\t\t\t\t\t  if (reg_toolong)\n\t\t\t\t\t      return NULL;\n\t\t\t\t\t  br = OPERAND(br);\n\t\t\t\t      }\n\t\t\t\t      else\n\t\t\t\t\t  br = regnext(br);\n\t\t\t\t  }\n\t\t\t      }\n\t\t\t      *flagp &= ~(HASWIDTH | SIMPLE);\n\t\t\t      break;\n\t\t\t  }\n\n\t\tcase 'd':   \/\/ %d123 decimal\n\t\tcase 'o':   \/\/ %o123 octal\n\t\tcase 'x':   \/\/ %xab hex 2\n\t\tcase 'u':   \/\/ %uabcd hex 4\n\t\tcase 'U':   \/\/ %U1234abcd hex 8\n\t\t\t  {\n\t\t\t      long i;\n\n\t\t\t      switch (c)\n\t\t\t      {\n\t\t\t\t  case 'd': i = getdecchrs(); break;\n\t\t\t\t  case 'o': i = getoctchrs(); break;\n\t\t\t\t  case 'x': i = gethexchrs(2); break;\n\t\t\t\t  case 'u': i = gethexchrs(4); break;\n\t\t\t\t  case 'U': i = gethexchrs(8); break;\n\t\t\t\t  default:  i = -1; break;\n\t\t\t      }\n\n\t\t\t      if (i < 0 || i > INT_MAX)\n\t\t\t\t  EMSG2_RET_NULL(\n\t\t\t\t\t    _(e_invalid_character_after_str_2),\n\t\t\t\t\t\t       reg_magic == MAGIC_ALL);\n\t\t\t      if (use_multibytecode(i))\n\t\t\t\t  ret = regnode(MULTIBYTECODE);\n\t\t\t      else\n\t\t\t\t  ret = regnode(EXACTLY);\n\t\t\t      if (i == 0)\n\t\t\t\t  regc(0x0a);\n\t\t\t      else\n\t\t\t\t  regmbc(i);\n\t\t\t      regc(NUL);\n\t\t\t      *flagp |= HASWIDTH;\n\t\t\t      break;\n\t\t\t  }\n\n\t\tdefault:\n\t\t\t  if (VIM_ISDIGIT(c) || c == '<' || c == '>'\n\t\t\t\t\t\t|| c == '\\'' || c == '.')\n\t\t\t  {\n\t\t\t      long_u\tn = 0;\n\t\t\t      int\tcmp;\n\t\t\t      int\tcur = FALSE;\n\n\t\t\t      cmp = c;\n\t\t\t      if (cmp == '<' || cmp == '>')\n\t\t\t\t  c = getchr();\n\t\t\t      if (no_Magic(c) == '.')\n\t\t\t      {\n\t\t\t\t  cur = TRUE;\n\t\t\t\t  c = getchr();\n\t\t\t      }\n\t\t\t      while (VIM_ISDIGIT(c))\n\t\t\t      {\n\t\t\t\t  n = n * 10 + (c - '0');\n\t\t\t\t  c = getchr();\n\t\t\t      }\n\t\t\t      if (c == '\\'' && n == 0)\n\t\t\t      {\n\t\t\t\t  \/\/ \"\\%'m\", \"\\%<'m\" and \"\\%>'m\": Mark\n\t\t\t\t  c = getchr();\n\t\t\t\t  ret = regnode(RE_MARK);\n\t\t\t\t  if (ret == JUST_CALC_SIZE)\n\t\t\t\t      regsize += 2;\n\t\t\t\t  else\n\t\t\t\t  {\n\t\t\t\t      *regcode++ = c;\n\t\t\t\t      *regcode++ = cmp;\n\t\t\t\t  }\n\t\t\t\t  break;\n\t\t\t      }\n\t\t\t      else if (c == 'l' || c == 'c' || c == 'v')\n\t\t\t      {\n\t\t\t\t  if (cur && n)\n\t\t\t\t  {\n\t\t\t\t    semsg(_(e_regexp_number_after_dot_pos_search), no_Magic(c));\n\t\t\t\t    rc_did_emsg = TRUE;\n\t\t\t\t    return NULL;\n\t\t\t\t  }\n\t\t\t\t  if (c == 'l')\n\t\t\t\t  {\n\t\t\t\t      if (cur)\n\t\t\t\t\t  n = curwin->w_cursor.lnum;\n\t\t\t\t      ret = regnode(RE_LNUM);\n\t\t\t\t      if (save_prev_at_start)\n\t\t\t\t\t  at_start = TRUE;\n\t\t\t\t  }\n\t\t\t\t  else if (c == 'c')\n\t\t\t\t  {\n\t\t\t\t      if (cur)\n\t\t\t\t      {\n\t\t\t\t\t  n = curwin->w_cursor.col;\n\t\t\t\t\t  n++;\n\t\t\t\t      }\n\t\t\t\t      ret = regnode(RE_COL);\n\t\t\t\t  }\n\t\t\t\t  else\n\t\t\t\t  {\n\t\t\t\t      if (cur)\n\t\t\t\t      {\n\t\t\t\t\t  colnr_T vcol = 0;\n\n\t\t\t\t\t  getvvcol(curwin, &curwin->w_cursor,\n\t\t\t\t\t\t\t    NULL, NULL, &vcol);\n\t\t\t\t\t  ++vcol;\n\t\t\t\t\t  n = vcol;\n\t\t\t\t      }\n\t\t\t\t      ret = regnode(RE_VCOL);\n\t\t\t\t  }\n\t\t\t\t  if (ret == JUST_CALC_SIZE)\n\t\t\t\t      regsize += 5;\n\t\t\t\t  else\n\t\t\t\t  {\n\t\t\t\t      \/\/ put the number and the optional\n\t\t\t\t      \/\/ comparator after the opcode\n\t\t\t\t      regcode = re_put_long(regcode, n);\n\t\t\t\t      *regcode++ = cmp;\n\t\t\t\t  }\n\t\t\t\t  break;\n\t\t\t      }\n\t\t\t  }\n\n\t\t\t  EMSG2_RET_NULL(_(e_invalid_character_after_str),\n\t\t\t\t\t\t      reg_magic == MAGIC_ALL);\n\t    }\n\t}\n\tbreak;\n\n      case Magic('['):\ncollection:\n\t{\n\t    char_u\t*lp;\n\n\t    \/\/ If there is no matching ']', we assume the '[' is a normal\n\t    \/\/ character.  This makes 'incsearch' and \":help [\" work.\n\t    lp = skip_anyof(regparse);\n\t    if (*lp == ']')\t\/\/ there is a matching ']'\n\t    {\n\t\tint\tstartc = -1;\t\/\/ > 0 when next '-' is a range\n\t\tint\tendc;\n\n\t\t\/\/ In a character class, different parsing rules apply.\n\t\t\/\/ Not even \\ is special anymore, nothing is.\n\t\tif (*regparse == '^')\t    \/\/ Complement of range.\n\t\t{\n\t\t    ret = regnode(ANYBUT + extra);\n\t\t    regparse++;\n\t\t}\n\t\telse\n\t\t    ret = regnode(ANYOF + extra);\n\n\t\t\/\/ At the start ']' and '-' mean the literal character.\n\t\tif (*regparse == ']' || *regparse == '-')\n\t\t{\n\t\t    startc = *regparse;\n\t\t    regc(*regparse++);\n\t\t}\n\n\t\twhile (*regparse != NUL && *regparse != ']')\n\t\t{\n\t\t    if (*regparse == '-')\n\t\t    {\n\t\t\t++regparse;\n\t\t\t\/\/ The '-' is not used for a range at the end and\n\t\t\t\/\/ after or before a '\\n'.\n\t\t\tif (*regparse == ']' || *regparse == NUL\n\t\t\t\t|| startc == -1\n\t\t\t\t|| (regparse[0] == '\\\\' && regparse[1] == 'n'))\n\t\t\t{\n\t\t\t    regc('-');\n\t\t\t    startc = '-';\t\/\/ [--x] is a range\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Also accept \"a-[.z.]\"\n\t\t\t    endc = 0;\n\t\t\t    if (*regparse == '[')\n\t\t\t\tendc = get_coll_element(®parse);\n\t\t\t    if (endc == 0)\n\t\t\t    {\n\t\t\t\tif (has_mbyte)\n\t\t\t\t    endc = mb_ptr2char_adv(®parse);\n\t\t\t\telse\n\t\t\t\t    endc = *regparse++;\n\t\t\t    }\n\n\t\t\t    \/\/ Handle \\o40, \\x20 and \\u20AC style sequences\n\t\t\t    if (endc == '\\\\' && !reg_cpo_lit && !reg_cpo_bsl)\n\t\t\t\tendc = coll_get_char();\n\n\t\t\t    if (startc > endc)\n\t\t\t\tEMSG_RET_NULL(_(e_reverse_range_in_character_class));\n\t\t\t    if (has_mbyte && ((*mb_char2len)(startc) > 1\n\t\t\t\t\t\t || (*mb_char2len)(endc) > 1))\n\t\t\t    {\n\t\t\t\t\/\/ Limit to a range of 256 chars.\n\t\t\t\tif (endc > startc + 256)\n\t\t\t\t    EMSG_RET_NULL(_(e_range_too_large_in_character_class));\n\t\t\t\twhile (++startc <= endc)\n\t\t\t\t    regmbc(startc);\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\twhile (++startc <= endc)\n\t\t\t\t    regc(startc);\n\t\t\t    }\n\t\t\t    startc = -1;\n\t\t\t}\n\t\t    }\n\t\t    \/\/ Only \"\\]\", \"\\^\", \"\\]\" and \"\\\\\" are special in Vi.  Vim\n\t\t    \/\/ accepts \"\\t\", \"\\e\", etc., but only when the 'l' flag in\n\t\t    \/\/ 'cpoptions' is not included.\n\t\t    \/\/ Posix doesn't recognize backslash at all.\n\t\t    else if (*regparse == '\\\\'\n\t\t\t    && !reg_cpo_bsl\n\t\t\t    && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL\n\t\t\t\t|| (!reg_cpo_lit\n\t\t\t\t    && vim_strchr(REGEXP_ABBR,\n\t\t\t\t\t\t       regparse[1]) != NULL)))\n\t\t    {\n\t\t\tregparse++;\n\t\t\tif (*regparse == 'n')\n\t\t\t{\n\t\t\t    \/\/ '\\n' in range: also match NL\n\t\t\t    if (ret != JUST_CALC_SIZE)\n\t\t\t    {\n\t\t\t\t\/\/ Using \\n inside [^] does not change what\n\t\t\t\t\/\/ matches. \"[^\\n]\" is the same as \".\".\n\t\t\t\tif (*ret == ANYOF)\n\t\t\t\t{\n\t\t\t\t    *ret = ANYOF + ADD_NL;\n\t\t\t\t    *flagp |= HASNL;\n\t\t\t\t}\n\t\t\t\t\/\/ else: must have had a \\n already\n\t\t\t    }\n\t\t\t    regparse++;\n\t\t\t    startc = -1;\n\t\t\t}\n\t\t\telse if (*regparse == 'd'\n\t\t\t\t|| *regparse == 'o'\n\t\t\t\t|| *regparse == 'x'\n\t\t\t\t|| *regparse == 'u'\n\t\t\t\t|| *regparse == 'U')\n\t\t\t{\n\t\t\t    startc = coll_get_char();\n\t\t\t    if (startc == 0)\n\t\t\t\tregc(0x0a);\n\t\t\t    else\n\t\t\t\tregmbc(startc);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    startc = backslash_trans(*regparse++);\n\t\t\t    regc(startc);\n\t\t\t}\n\t\t    }\n\t\t    else if (*regparse == '[')\n\t\t    {\n\t\t\tint c_class;\n\t\t\tint cu;\n\n\t\t\tc_class = get_char_class(®parse);\n\t\t\tstartc = -1;\n\t\t\t\/\/ Characters assumed to be 8 bits!\n\t\t\tswitch (c_class)\n\t\t\t{\n\t\t\t    case CLASS_NONE:\n\t\t\t\tc_class = get_equi_class(®parse);\n\t\t\t\tif (c_class != 0)\n\t\t\t\t{\n\t\t\t\t    \/\/ produce equivalence class\n\t\t\t\t    reg_equi_class(c_class);\n\t\t\t\t}\n\t\t\t\telse if ((c_class =\n\t\t\t\t\t    get_coll_element(®parse)) != 0)\n\t\t\t\t{\n\t\t\t\t    \/\/ produce a collating element\n\t\t\t\t    regmbc(c_class);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t    \/\/ literal '[', allow [[-x] as a range\n\t\t\t\t    startc = *regparse++;\n\t\t\t\t    regc(startc);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t    case CLASS_ALNUM:\n\t\t\t\tfor (cu = 1; cu < 128; cu++)\n\t\t\t\t    if (isalnum(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_ALPHA:\n\t\t\t\tfor (cu = 1; cu < 128; cu++)\n\t\t\t\t    if (isalpha(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_BLANK:\n\t\t\t\tregc(' ');\n\t\t\t\tregc('\\t');\n\t\t\t\tbreak;\n\t\t\t    case CLASS_CNTRL:\n\t\t\t\tfor (cu = 1; cu <= 127; cu++)\n\t\t\t\t    if (iscntrl(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_DIGIT:\n\t\t\t\tfor (cu = 1; cu <= 127; cu++)\n\t\t\t\t    if (VIM_ISDIGIT(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_GRAPH:\n\t\t\t\tfor (cu = 1; cu <= 127; cu++)\n\t\t\t\t    if (isgraph(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_LOWER:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (MB_ISLOWER(cu) && cu != 170\n\t\t\t\t\t\t\t\t && cu != 186)\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_PRINT:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (vim_isprintc(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_PUNCT:\n\t\t\t\tfor (cu = 1; cu < 128; cu++)\n\t\t\t\t    if (ispunct(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_SPACE:\n\t\t\t\tfor (cu = 9; cu <= 13; cu++)\n\t\t\t\t    regc(cu);\n\t\t\t\tregc(' ');\n\t\t\t\tbreak;\n\t\t\t    case CLASS_UPPER:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (MB_ISUPPER(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_XDIGIT:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (vim_isxdigit(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_TAB:\n\t\t\t\tregc('\\t');\n\t\t\t\tbreak;\n\t\t\t    case CLASS_RETURN:\n\t\t\t\tregc('\\r');\n\t\t\t\tbreak;\n\t\t\t    case CLASS_BACKSPACE:\n\t\t\t\tregc('\\b');\n\t\t\t\tbreak;\n\t\t\t    case CLASS_ESCAPE:\n\t\t\t\tregc('\\033');\n\t\t\t\tbreak;\n\t\t\t    case CLASS_IDENT:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (vim_isIDc(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_KEYWORD:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (reg_iswordc(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t    case CLASS_FNAME:\n\t\t\t\tfor (cu = 1; cu <= 255; cu++)\n\t\t\t\t    if (vim_isfilec(cu))\n\t\t\t\t\tregmbc(cu);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t{\n\t\t\t    int\tlen;\n\n\t\t\t    \/\/ produce a multibyte character, including any\n\t\t\t    \/\/ following composing characters\n\t\t\t    startc = mb_ptr2char(regparse);\n\t\t\t    len = (*mb_ptr2len)(regparse);\n\t\t\t    if (enc_utf8 && utf_char2len(startc) != len)\n\t\t\t\tstartc = -1;\t\/\/ composing chars\n\t\t\t    while (--len >= 0)\n\t\t\t\tregc(*regparse++);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    startc = *regparse++;\n\t\t\t    regc(startc);\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tregc(NUL);\n\t\tprevchr_len = 1;\t\/\/ last char was the ']'\n\t\tif (*regparse != ']')\n\t\t    EMSG_RET_NULL(_(e_too_many_brackets));  \/\/ Cannot happen?\n\t\tskipchr();\t    \/\/ let's be friends with the lexer again\n\t\t*flagp |= HASWIDTH | SIMPLE;\n\t\tbreak;\n\t    }\n\t    else if (reg_strict)\n\t\tEMSG2_RET_NULL(_(e_missing_rsb_after_str_lsb),\n\t\t\t\t\t\t\treg_magic > MAGIC_OFF);\n\t}\n\t\/\/ FALLTHROUGH\n\n      default:\n\t{\n\t    int\t\tlen;\n\n\t    \/\/ A multi-byte character is handled as a separate atom if it's\n\t    \/\/ before a multi and when it's a composing char.\n\t    if (use_multibytecode(c))\n\t    {\ndo_multibyte:\n\t\tret = regnode(MULTIBYTECODE);\n\t\tregmbc(c);\n\t\t*flagp |= HASWIDTH | SIMPLE;\n\t\tbreak;\n\t    }\n\n\t    ret = regnode(EXACTLY);\n\n\t    \/\/ Append characters as long as:\n\t    \/\/ - there is no following multi, we then need the character in\n\t    \/\/   front of it as a single character operand\n\t    \/\/ - not running into a Magic character\n\t    \/\/ - \"one_exactly\" is not set\n\t    \/\/ But always emit at least one character.  Might be a Multi,\n\t    \/\/ e.g., a \"[\" without matching \"]\".\n\t    for (len = 0; c != NUL && (len == 0\n\t\t\t|| (re_multi_type(peekchr()) == NOT_MULTI\n\t\t\t    && !one_exactly\n\t\t\t    && !is_Magic(c))); ++len)\n\t    {\n\t\tc = no_Magic(c);\n\t\tif (has_mbyte)\n\t\t{\n\t\t    regmbc(c);\n\t\t    if (enc_utf8)\n\t\t    {\n\t\t\tint\tl;\n\n\t\t\t\/\/ Need to get composing character too.\n\t\t\tfor (;;)\n\t\t\t{\n\t\t\t    l = utf_ptr2len(regparse);\n\t\t\t    if (!UTF_COMPOSINGLIKE(regparse, regparse + l))\n\t\t\t\tbreak;\n\t\t\t    regmbc(utf_ptr2char(regparse));\n\t\t\t    skipchr();\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    regc(c);\n\t\tc = getchr();\n\t    }\n\t    ungetchr();\n\n\t    regc(NUL);\n\t    *flagp |= HASWIDTH;\n\t    if (len == 1)\n\t\t*flagp |= SIMPLE;\n\t}\n\tbreak;\n    }\n\n    return ret;\n}","target":0,"code_token_length":5482,"total_token_length":5718,"max_tokens_setting":6144}
+{"idx":211506,"func":"int ZEXPORT inflate(strm, flush)\nz_streamp strm;\nint flush;\n{\n    struct inflate_state FAR *state;\n    z_const unsigned char FAR *next;    \/* next input *\/\n    unsigned char FAR *put;     \/* next output *\/\n    unsigned have, left;        \/* available input and output *\/\n    unsigned long hold;         \/* bit buffer *\/\n    unsigned bits;              \/* bits in bit buffer *\/\n    unsigned in, out;           \/* save starting available input and output *\/\n    unsigned copy;              \/* number of stored or match bytes to copy *\/\n    unsigned char FAR *from;    \/* where to copy match bytes from *\/\n    code here;                  \/* current decoding table entry *\/\n    code last;                  \/* parent table entry *\/\n    unsigned len;               \/* length to copy for repeats, bits to drop *\/\n    int ret;                    \/* return code *\/\n#ifdef GUNZIP\n    unsigned char hbuf[4];      \/* buffer for gzip header crc calculation *\/\n#endif\n    static const unsigned short order[19] = \/* permutation of code lengths *\/\n        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||\n        (strm->next_in == Z_NULL && strm->avail_in != 0))\n        return Z_STREAM_ERROR;\n\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->mode == TYPE) state->mode = TYPEDO;      \/* skip check *\/\n    LOAD();\n    in = have;\n    out = left;\n    ret = Z_OK;\n    for (;;)\n        switch (state->mode) {\n        case HEAD:\n            if (state->wrap == 0) {\n                state->mode = TYPEDO;\n                break;\n            }\n            NEEDBITS(16);\n#ifdef GUNZIP\n            if ((state->wrap & 2) && hold == 0x8b1f) {  \/* gzip header *\/\n                if (state->wbits == 0)\n                    state->wbits = 15;\n                state->check = crc32(0L, Z_NULL, 0);\n                CRC2(state->check, hold);\n                INITBITS();\n                state->mode = FLAGS;\n                break;\n            }\n            if (state->head != Z_NULL)\n                state->head->done = -1;\n            if (!(state->wrap & 1) ||   \/* check if zlib header allowed *\/\n#else\n            if (\n#endif\n                ((BITS(8) << 8) + (hold >> 8)) % 31) {\n                strm->msg = (char *)\"incorrect header check\";\n                state->mode = BAD;\n                break;\n            }\n            if (BITS(4) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            DROPBITS(4);\n            len = BITS(4) + 8;\n            if (state->wbits == 0)\n                state->wbits = len;\n            if (len > 15 || len > state->wbits) {\n                strm->msg = (char *)\"invalid window size\";\n                state->mode = BAD;\n                break;\n            }\n            state->dmax = 1U << len;\n            state->flags = 0;               \/* indicate zlib header *\/\n            Tracev((stderr, \"inflate:   zlib header ok\\n\"));\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = hold & 0x200 ? DICTID : TYPE;\n            INITBITS();\n            break;\n#ifdef GUNZIP\n        case FLAGS:\n            NEEDBITS(16);\n            state->flags = (int)(hold);\n            if ((state->flags & 0xff) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->flags & 0xe000) {\n                strm->msg = (char *)\"unknown header flags set\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->head != Z_NULL)\n                state->head->text = (int)((hold >> 8) & 1);\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC2(state->check, hold);\n            INITBITS();\n            state->mode = TIME;\n                \/* fallthrough *\/\n        case TIME:\n            NEEDBITS(32);\n            if (state->head != Z_NULL)\n                state->head->time = hold;\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC4(state->check, hold);\n            INITBITS();\n            state->mode = OS;\n                \/* fallthrough *\/\n        case OS:\n            NEEDBITS(16);\n            if (state->head != Z_NULL) {\n                state->head->xflags = (int)(hold & 0xff);\n                state->head->os = (int)(hold >> 8);\n            }\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC2(state->check, hold);\n            INITBITS();\n            state->mode = EXLEN;\n                \/* fallthrough *\/\n        case EXLEN:\n            if (state->flags & 0x0400) {\n                NEEDBITS(16);\n                state->length = (unsigned)(hold);\n                if (state->head != Z_NULL)\n                    state->head->extra_len = (unsigned)hold;\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    CRC2(state->check, hold);\n                INITBITS();\n            }\n            else if (state->head != Z_NULL)\n                state->head->extra = Z_NULL;\n            state->mode = EXTRA;\n                \/* fallthrough *\/\n        case EXTRA:\n            if (state->flags & 0x0400) {\n                copy = state->length;\n                if (copy > have) copy = have;\n                if (copy) {\n                    if (state->head != Z_NULL &&\n                        state->head->extra != Z_NULL) {\n                        len = state->head->extra_len - state->length;\n                        zmemcpy(state->head->extra + len, next,\n                                len + copy > state->head->extra_max ?\n                                state->head->extra_max - len : copy);\n                    }\n                    if ((state->flags & 0x0200) && (state->wrap & 4))\n                        state->check = crc32(state->check, next, copy);\n                    have -= copy;\n                    next += copy;\n                    state->length -= copy;\n                }\n                if (state->length) goto inf_leave;\n            }\n            state->length = 0;\n            state->mode = NAME;\n                \/* fallthrough *\/\n        case NAME:\n            if (state->flags & 0x0800) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->name != Z_NULL &&\n                            state->length < state->head->name_max)\n                        state->head->name[state->length++] = (Bytef)len;\n                } while (len && copy < have);\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->name = Z_NULL;\n            state->length = 0;\n            state->mode = COMMENT;\n                \/* fallthrough *\/\n        case COMMENT:\n            if (state->flags & 0x1000) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->comment != Z_NULL &&\n                            state->length < state->head->comm_max)\n                        state->head->comment[state->length++] = (Bytef)len;\n                } while (len && copy < have);\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->comment = Z_NULL;\n            state->mode = HCRC;\n                \/* fallthrough *\/\n        case HCRC:\n            if (state->flags & 0x0200) {\n                NEEDBITS(16);\n                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {\n                    strm->msg = (char *)\"header crc mismatch\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n            }\n            if (state->head != Z_NULL) {\n                state->head->hcrc = (int)((state->flags >> 9) & 1);\n                state->head->done = 1;\n            }\n            strm->adler = state->check = crc32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n            break;\n#endif\n        case DICTID:\n            NEEDBITS(32);\n            strm->adler = state->check = ZSWAP32(hold);\n            INITBITS();\n            state->mode = DICT;\n                \/* fallthrough *\/\n        case DICT:\n            if (state->havedict == 0) {\n                RESTORE();\n                return Z_NEED_DICT;\n            }\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n                \/* fallthrough *\/\n        case TYPE:\n            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;\n                \/* fallthrough *\/\n        case TYPEDO:\n            if (state->last) {\n                BYTEBITS();\n                state->mode = CHECK;\n                break;\n            }\n            NEEDBITS(3);\n            state->last = BITS(1);\n            DROPBITS(1);\n            switch (BITS(2)) {\n            case 0:                             \/* stored block *\/\n                Tracev((stderr, \"inflate:     stored block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = STORED;\n                break;\n            case 1:                             \/* fixed block *\/\n                fixedtables(state);\n                Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = LEN_;             \/* decode codes *\/\n                if (flush == Z_TREES) {\n                    DROPBITS(2);\n                    goto inf_leave;\n                }\n                break;\n            case 2:                             \/* dynamic block *\/\n                Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = TABLE;\n                break;\n            case 3:\n                strm->msg = (char *)\"invalid block type\";\n                state->mode = BAD;\n            }\n            DROPBITS(2);\n            break;\n        case STORED:\n            BYTEBITS();                         \/* go to byte boundary *\/\n            NEEDBITS(32);\n            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {\n                strm->msg = (char *)\"invalid stored block lengths\";\n                state->mode = BAD;\n                break;\n            }\n            state->length = (unsigned)hold & 0xffff;\n            Tracev((stderr, \"inflate:       stored length %u\\n\",\n                    state->length));\n            INITBITS();\n            state->mode = COPY_;\n            if (flush == Z_TREES) goto inf_leave;\n                \/* fallthrough *\/\n        case COPY_:\n            state->mode = COPY;\n                \/* fallthrough *\/\n        case COPY:\n            copy = state->length;\n            if (copy) {\n                if (copy > have) copy = have;\n                if (copy > left) copy = left;\n                if (copy == 0) goto inf_leave;\n                zmemcpy(put, next, copy);\n                have -= copy;\n                next += copy;\n                left -= copy;\n                put += copy;\n                state->length -= copy;\n                break;\n            }\n            Tracev((stderr, \"inflate:       stored end\\n\"));\n            state->mode = TYPE;\n            break;\n        case TABLE:\n            NEEDBITS(14);\n            state->nlen = BITS(5) + 257;\n            DROPBITS(5);\n            state->ndist = BITS(5) + 1;\n            DROPBITS(5);\n            state->ncode = BITS(4) + 4;\n            DROPBITS(4);\n#ifndef PKZIP_BUG_WORKAROUND\n            if (state->nlen > 286 || state->ndist > 30) {\n                strm->msg = (char *)\"too many length or distance symbols\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n            state->have = 0;\n            state->mode = LENLENS;\n                \/* fallthrough *\/\n        case LENLENS:\n            while (state->have < state->ncode) {\n                NEEDBITS(3);\n                state->lens[order[state->have++]] = (unsigned short)BITS(3);\n                DROPBITS(3);\n            }\n            while (state->have < 19)\n                state->lens[order[state->have++]] = 0;\n            state->next = state->codes;\n            state->lencode = (const code FAR *)(state->next);\n            state->lenbits = 7;\n            ret = inflate_table(CODES, state->lens, 19, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid code lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n            state->have = 0;\n            state->mode = CODELENS;\n                \/* fallthrough *\/\n        case CODELENS:\n            while (state->have < state->nlen + state->ndist) {\n                for (;;) {\n                    here = state->lencode[BITS(state->lenbits)];\n                    if ((unsigned)(here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                if (here.val < 16) {\n                    DROPBITS(here.bits);\n                    state->lens[state->have++] = here.val;\n                }\n                else {\n                    if (here.val == 16) {\n                        NEEDBITS(here.bits + 2);\n                        DROPBITS(here.bits);\n                        if (state->have == 0) {\n                            strm->msg = (char *)\"invalid bit length repeat\";\n                            state->mode = BAD;\n                            break;\n                        }\n                        len = state->lens[state->have - 1];\n                        copy = 3 + BITS(2);\n                        DROPBITS(2);\n                    }\n                    else if (here.val == 17) {\n                        NEEDBITS(here.bits + 3);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 3 + BITS(3);\n                        DROPBITS(3);\n                    }\n                    else {\n                        NEEDBITS(here.bits + 7);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 11 + BITS(7);\n                        DROPBITS(7);\n                    }\n                    if (state->have + copy > state->nlen + state->ndist) {\n                        strm->msg = (char *)\"invalid bit length repeat\";\n                        state->mode = BAD;\n                        break;\n                    }\n                    while (copy--)\n                        state->lens[state->have++] = (unsigned short)len;\n                }\n            }\n\n            \/* handle error breaks in while *\/\n            if (state->mode == BAD) break;\n\n            \/* check for end-of-block code (better have one) *\/\n            if (state->lens[256] == 0) {\n                strm->msg = (char *)\"invalid code -- missing end-of-block\";\n                state->mode = BAD;\n                break;\n            }\n\n            \/* build code tables -- note: do not change the lenbits or distbits\n               values here (9 and 6) without reading the comments in inftrees.h\n               concerning the ENOUGH constants, which depend on those values *\/\n            state->next = state->codes;\n            state->lencode = (const code FAR *)(state->next);\n            state->lenbits = 9;\n            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid literal\/lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            state->distcode = (const code FAR *)(state->next);\n            state->distbits = 6;\n            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,\n                            &(state->next), &(state->distbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid distances set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       codes ok\\n\"));\n            state->mode = LEN_;\n            if (flush == Z_TREES) goto inf_leave;\n                \/* fallthrough *\/\n        case LEN_:\n            state->mode = LEN;\n                \/* fallthrough *\/\n        case LEN:\n            if (have >= 6 && left >= 258) {\n                RESTORE();\n                inflate_fast(strm, out);\n                LOAD();\n                if (state->mode == TYPE)\n                    state->back = -1;\n                break;\n            }\n            state->back = 0;\n            for (;;) {\n                here = state->lencode[BITS(state->lenbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if (here.op && (here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->lencode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            state->length = (unsigned)here.val;\n            if ((int)(here.op) == 0) {\n                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                        \"inflate:         literal '%c'\\n\" :\n                        \"inflate:         literal 0x%02x\\n\", here.val));\n                state->mode = LIT;\n                break;\n            }\n            if (here.op & 32) {\n                Tracevv((stderr, \"inflate:         end of block\\n\"));\n                state->back = -1;\n                state->mode = TYPE;\n                break;\n            }\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid literal\/length code\";\n                state->mode = BAD;\n                break;\n            }\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = LENEXT;\n                \/* fallthrough *\/\n        case LENEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->length += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", state->length));\n            state->was = state->length;\n            state->mode = DIST;\n                \/* fallthrough *\/\n        case DIST:\n            for (;;) {\n                here = state->distcode[BITS(state->distbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if ((here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->distcode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n            state->offset = (unsigned)here.val;\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = DISTEXT;\n                \/* fallthrough *\/\n        case DISTEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->offset += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n#ifdef INFLATE_STRICT\n            if (state->offset > state->dmax) {\n                strm->msg = (char *)\"invalid distance too far back\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracevv((stderr, \"inflate:         distance %u\\n\", state->offset));\n            state->mode = MATCH;\n                \/* fallthrough *\/\n        case MATCH:\n            if (left == 0) goto inf_leave;\n            copy = out - left;\n            if (state->offset > copy) {         \/* copy from window *\/\n                copy = state->offset - copy;\n                if (copy > state->whave) {\n                    if (state->sane) {\n                        strm->msg = (char *)\"invalid distance too far back\";\n                        state->mode = BAD;\n                        break;\n                    }\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n                    Trace((stderr, \"inflate.c too far\\n\"));\n                    copy -= state->whave;\n                    if (copy > state->length) copy = state->length;\n                    if (copy > left) copy = left;\n                    left -= copy;\n                    state->length -= copy;\n                    do {\n                        *put++ = 0;\n                    } while (--copy);\n                    if (state->length == 0) state->mode = LEN;\n                    break;\n#endif\n                }\n                if (copy > state->wnext) {\n                    copy -= state->wnext;\n                    from = state->window + (state->wsize - copy);\n                }\n                else\n                    from = state->window + (state->wnext - copy);\n                if (copy > state->length) copy = state->length;\n            }\n            else {                              \/* copy from output *\/\n                from = put - state->offset;\n                copy = state->length;\n            }\n            if (copy > left) copy = left;\n            left -= copy;\n            state->length -= copy;\n            do {\n                *put++ = *from++;\n            } while (--copy);\n            if (state->length == 0) state->mode = LEN;\n            break;\n        case LIT:\n            if (left == 0) goto inf_leave;\n            *put++ = (unsigned char)(state->length);\n            left--;\n            state->mode = LEN;\n            break;\n        case CHECK:\n            if (state->wrap) {\n                NEEDBITS(32);\n                out -= left;\n                strm->total_out += out;\n                state->total += out;\n                if ((state->wrap & 4) && out)\n                    strm->adler = state->check =\n                        UPDATE_CHECK(state->check, put - out, out);\n                out = left;\n                if ((state->wrap & 4) && (\n#ifdef GUNZIP\n                     state->flags ? hold :\n#endif\n                     ZSWAP32(hold)) != state->check) {\n                    strm->msg = (char *)\"incorrect data check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   check matches trailer\\n\"));\n            }\n#ifdef GUNZIP\n            state->mode = LENGTH;\n                \/* fallthrough *\/\n        case LENGTH:\n            if (state->wrap && state->flags) {\n                NEEDBITS(32);\n                if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {\n                    strm->msg = (char *)\"incorrect length check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   length matches trailer\\n\"));\n            }\n#endif\n            state->mode = DONE;\n                \/* fallthrough *\/\n        case DONE:\n            ret = Z_STREAM_END;\n            goto inf_leave;\n        case BAD:\n            ret = Z_DATA_ERROR;\n            goto inf_leave;\n        case MEM:\n            return Z_MEM_ERROR;\n        case SYNC:\n                \/* fallthrough *\/\n        default:\n            return Z_STREAM_ERROR;\n        }\n\n    \/*\n       Return from inflate(), updating the total counts and the check value.\n       If there was no progress during the inflate() call, return a buffer\n       error.  Call updatewindow() to create and\/or update the window state.\n       Note: a memory error from inflate() is non-recoverable.\n     *\/\n  inf_leave:\n    RESTORE();\n    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&\n            (state->mode < CHECK || flush != Z_FINISH)))\n        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {\n            state->mode = MEM;\n            return Z_MEM_ERROR;\n        }\n    in -= strm->avail_in;\n    out -= strm->avail_out;\n    strm->total_in += in;\n    strm->total_out += out;\n    state->total += out;\n    if ((state->wrap & 4) && out)\n        strm->adler = state->check =\n            UPDATE_CHECK(state->check, strm->next_out - out, out);\n    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +\n                      (state->mode == TYPE ? 128 : 0) +\n                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);\n    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)\n        ret = Z_BUF_ERROR;\n    return ret;\n}","target":1,"code_token_length":5863,"total_token_length":6099,"max_tokens_setting":6144}
+{"idx":338128,"func":"bool WasmBinaryBuilder::maybeVisitSIMDBinary(Expression*& out, uint32_t code) {\n  Binary* curr;\n  switch (code) {\n    case BinaryConsts::I8x16Eq:\n      curr = allocator.alloc<Binary>();\n      curr->op = EqVecI8x16;\n      break;\n    case BinaryConsts::I8x16Ne:\n      curr = allocator.alloc<Binary>();\n      curr->op = NeVecI8x16;\n      break;\n    case BinaryConsts::I8x16LtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtSVecI8x16;\n      break;\n    case BinaryConsts::I8x16LtU:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtUVecI8x16;\n      break;\n    case BinaryConsts::I8x16GtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtSVecI8x16;\n      break;\n    case BinaryConsts::I8x16GtU:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtUVecI8x16;\n      break;\n    case BinaryConsts::I8x16LeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeSVecI8x16;\n      break;\n    case BinaryConsts::I8x16LeU:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeUVecI8x16;\n      break;\n    case BinaryConsts::I8x16GeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeSVecI8x16;\n      break;\n    case BinaryConsts::I8x16GeU:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeUVecI8x16;\n      break;\n    case BinaryConsts::I16x8Eq:\n      curr = allocator.alloc<Binary>();\n      curr->op = EqVecI16x8;\n      break;\n    case BinaryConsts::I16x8Ne:\n      curr = allocator.alloc<Binary>();\n      curr->op = NeVecI16x8;\n      break;\n    case BinaryConsts::I16x8LtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtSVecI16x8;\n      break;\n    case BinaryConsts::I16x8LtU:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtUVecI16x8;\n      break;\n    case BinaryConsts::I16x8GtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtSVecI16x8;\n      break;\n    case BinaryConsts::I16x8GtU:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtUVecI16x8;\n      break;\n    case BinaryConsts::I16x8LeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeSVecI16x8;\n      break;\n    case BinaryConsts::I16x8LeU:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeUVecI16x8;\n      break;\n    case BinaryConsts::I16x8GeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeSVecI16x8;\n      break;\n    case BinaryConsts::I16x8GeU:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeUVecI16x8;\n      break;\n    case BinaryConsts::I32x4Eq:\n      curr = allocator.alloc<Binary>();\n      curr->op = EqVecI32x4;\n      break;\n    case BinaryConsts::I32x4Ne:\n      curr = allocator.alloc<Binary>();\n      curr->op = NeVecI32x4;\n      break;\n    case BinaryConsts::I32x4LtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtSVecI32x4;\n      break;\n    case BinaryConsts::I32x4LtU:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtUVecI32x4;\n      break;\n    case BinaryConsts::I32x4GtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtSVecI32x4;\n      break;\n    case BinaryConsts::I32x4GtU:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtUVecI32x4;\n      break;\n    case BinaryConsts::I32x4LeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeSVecI32x4;\n      break;\n    case BinaryConsts::I32x4LeU:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeUVecI32x4;\n      break;\n    case BinaryConsts::I32x4GeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeSVecI32x4;\n      break;\n    case BinaryConsts::I32x4GeU:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeUVecI32x4;\n      break;\n    case BinaryConsts::I64x2Eq:\n      curr = allocator.alloc<Binary>();\n      curr->op = EqVecI64x2;\n      break;\n    case BinaryConsts::I64x2Ne:\n      curr = allocator.alloc<Binary>();\n      curr->op = NeVecI64x2;\n      break;\n    case BinaryConsts::I64x2LtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtSVecI64x2;\n      break;\n    case BinaryConsts::I64x2GtS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtSVecI64x2;\n      break;\n    case BinaryConsts::I64x2LeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeSVecI64x2;\n      break;\n    case BinaryConsts::I64x2GeS:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeSVecI64x2;\n      break;\n    case BinaryConsts::F32x4Eq:\n      curr = allocator.alloc<Binary>();\n      curr->op = EqVecF32x4;\n      break;\n    case BinaryConsts::F32x4Ne:\n      curr = allocator.alloc<Binary>();\n      curr->op = NeVecF32x4;\n      break;\n    case BinaryConsts::F32x4Lt:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtVecF32x4;\n      break;\n    case BinaryConsts::F32x4Gt:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtVecF32x4;\n      break;\n    case BinaryConsts::F32x4Le:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeVecF32x4;\n      break;\n    case BinaryConsts::F32x4Ge:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeVecF32x4;\n      break;\n    case BinaryConsts::F64x2Eq:\n      curr = allocator.alloc<Binary>();\n      curr->op = EqVecF64x2;\n      break;\n    case BinaryConsts::F64x2Ne:\n      curr = allocator.alloc<Binary>();\n      curr->op = NeVecF64x2;\n      break;\n    case BinaryConsts::F64x2Lt:\n      curr = allocator.alloc<Binary>();\n      curr->op = LtVecF64x2;\n      break;\n    case BinaryConsts::F64x2Gt:\n      curr = allocator.alloc<Binary>();\n      curr->op = GtVecF64x2;\n      break;\n    case BinaryConsts::F64x2Le:\n      curr = allocator.alloc<Binary>();\n      curr->op = LeVecF64x2;\n      break;\n    case BinaryConsts::F64x2Ge:\n      curr = allocator.alloc<Binary>();\n      curr->op = GeVecF64x2;\n      break;\n    case BinaryConsts::V128And:\n      curr = allocator.alloc<Binary>();\n      curr->op = AndVec128;\n      break;\n    case BinaryConsts::V128Or:\n      curr = allocator.alloc<Binary>();\n      curr->op = OrVec128;\n      break;\n    case BinaryConsts::V128Xor:\n      curr = allocator.alloc<Binary>();\n      curr->op = XorVec128;\n      break;\n    case BinaryConsts::V128Andnot:\n      curr = allocator.alloc<Binary>();\n      curr->op = AndNotVec128;\n      break;\n    case BinaryConsts::I8x16Add:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddVecI8x16;\n      break;\n    case BinaryConsts::I8x16AddSatS:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddSatSVecI8x16;\n      break;\n    case BinaryConsts::I8x16AddSatU:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddSatUVecI8x16;\n      break;\n    case BinaryConsts::I8x16Sub:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubVecI8x16;\n      break;\n    case BinaryConsts::I8x16SubSatS:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubSatSVecI8x16;\n      break;\n    case BinaryConsts::I8x16SubSatU:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubSatUVecI8x16;\n      break;\n    case BinaryConsts::I8x16MinS:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinSVecI8x16;\n      break;\n    case BinaryConsts::I8x16MinU:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinUVecI8x16;\n      break;\n    case BinaryConsts::I8x16MaxS:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxSVecI8x16;\n      break;\n    case BinaryConsts::I8x16MaxU:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxUVecI8x16;\n      break;\n    case BinaryConsts::I8x16AvgrU:\n      curr = allocator.alloc<Binary>();\n      curr->op = AvgrUVecI8x16;\n      break;\n    case BinaryConsts::I16x8Add:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddVecI16x8;\n      break;\n    case BinaryConsts::I16x8AddSatS:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddSatSVecI16x8;\n      break;\n    case BinaryConsts::I16x8AddSatU:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddSatUVecI16x8;\n      break;\n    case BinaryConsts::I16x8Sub:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubVecI16x8;\n      break;\n    case BinaryConsts::I16x8SubSatS:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubSatSVecI16x8;\n      break;\n    case BinaryConsts::I16x8SubSatU:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubSatUVecI16x8;\n      break;\n    case BinaryConsts::I16x8Mul:\n      curr = allocator.alloc<Binary>();\n      curr->op = MulVecI16x8;\n      break;\n    case BinaryConsts::I16x8MinS:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinSVecI16x8;\n      break;\n    case BinaryConsts::I16x8MinU:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinUVecI16x8;\n      break;\n    case BinaryConsts::I16x8MaxS:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxSVecI16x8;\n      break;\n    case BinaryConsts::I16x8MaxU:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxUVecI16x8;\n      break;\n    case BinaryConsts::I16x8AvgrU:\n      curr = allocator.alloc<Binary>();\n      curr->op = AvgrUVecI16x8;\n      break;\n    case BinaryConsts::I16x8Q15mulrSatS:\n      curr = allocator.alloc<Binary>();\n      curr->op = Q15MulrSatSVecI16x8;\n      break;\n    case BinaryConsts::I16x8ExtmulLowI8x16S:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulLowSVecI16x8;\n      break;\n    case BinaryConsts::I16x8ExtmulHighI8x16S:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulHighSVecI16x8;\n      break;\n    case BinaryConsts::I16x8ExtmulLowI8x16U:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulLowUVecI16x8;\n      break;\n    case BinaryConsts::I16x8ExtmulHighI8x16U:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulHighUVecI16x8;\n      break;\n    case BinaryConsts::I32x4Add:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddVecI32x4;\n      break;\n    case BinaryConsts::I32x4Sub:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubVecI32x4;\n      break;\n    case BinaryConsts::I32x4Mul:\n      curr = allocator.alloc<Binary>();\n      curr->op = MulVecI32x4;\n      break;\n    case BinaryConsts::I32x4MinS:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinSVecI32x4;\n      break;\n    case BinaryConsts::I32x4MinU:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinUVecI32x4;\n      break;\n    case BinaryConsts::I32x4MaxS:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxSVecI32x4;\n      break;\n    case BinaryConsts::I32x4MaxU:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxUVecI32x4;\n      break;\n    case BinaryConsts::I32x4DotI16x8S:\n      curr = allocator.alloc<Binary>();\n      curr->op = DotSVecI16x8ToVecI32x4;\n      break;\n    case BinaryConsts::I32x4ExtmulLowI16x8S:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulLowSVecI32x4;\n      break;\n    case BinaryConsts::I32x4ExtmulHighI16x8S:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulHighSVecI32x4;\n      break;\n    case BinaryConsts::I32x4ExtmulLowI16x8U:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulLowUVecI32x4;\n      break;\n    case BinaryConsts::I32x4ExtmulHighI16x8U:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulHighUVecI32x4;\n      break;\n    case BinaryConsts::I64x2Add:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddVecI64x2;\n      break;\n    case BinaryConsts::I64x2Sub:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubVecI64x2;\n      break;\n    case BinaryConsts::I64x2Mul:\n      curr = allocator.alloc<Binary>();\n      curr->op = MulVecI64x2;\n      break;\n    case BinaryConsts::I64x2ExtmulLowI32x4S:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulLowSVecI64x2;\n      break;\n    case BinaryConsts::I64x2ExtmulHighI32x4S:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulHighSVecI64x2;\n      break;\n    case BinaryConsts::I64x2ExtmulLowI32x4U:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulLowUVecI64x2;\n      break;\n    case BinaryConsts::I64x2ExtmulHighI32x4U:\n      curr = allocator.alloc<Binary>();\n      curr->op = ExtMulHighUVecI64x2;\n      break;\n    case BinaryConsts::F32x4Add:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddVecF32x4;\n      break;\n    case BinaryConsts::F32x4Sub:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubVecF32x4;\n      break;\n    case BinaryConsts::F32x4Mul:\n      curr = allocator.alloc<Binary>();\n      curr->op = MulVecF32x4;\n      break;\n    case BinaryConsts::F32x4Div:\n      curr = allocator.alloc<Binary>();\n      curr->op = DivVecF32x4;\n      break;\n    case BinaryConsts::F32x4Min:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinVecF32x4;\n      break;\n    case BinaryConsts::F32x4Max:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxVecF32x4;\n      break;\n    case BinaryConsts::F32x4Pmin:\n      curr = allocator.alloc<Binary>();\n      curr->op = PMinVecF32x4;\n      break;\n    case BinaryConsts::F32x4Pmax:\n      curr = allocator.alloc<Binary>();\n      curr->op = PMaxVecF32x4;\n      break;\n    case BinaryConsts::F64x2Add:\n      curr = allocator.alloc<Binary>();\n      curr->op = AddVecF64x2;\n      break;\n    case BinaryConsts::F64x2Sub:\n      curr = allocator.alloc<Binary>();\n      curr->op = SubVecF64x2;\n      break;\n    case BinaryConsts::F64x2Mul:\n      curr = allocator.alloc<Binary>();\n      curr->op = MulVecF64x2;\n      break;\n    case BinaryConsts::F64x2Div:\n      curr = allocator.alloc<Binary>();\n      curr->op = DivVecF64x2;\n      break;\n    case BinaryConsts::F64x2Min:\n      curr = allocator.alloc<Binary>();\n      curr->op = MinVecF64x2;\n      break;\n    case BinaryConsts::F64x2Max:\n      curr = allocator.alloc<Binary>();\n      curr->op = MaxVecF64x2;\n      break;\n    case BinaryConsts::F64x2Pmin:\n      curr = allocator.alloc<Binary>();\n      curr->op = PMinVecF64x2;\n      break;\n    case BinaryConsts::F64x2Pmax:\n      curr = allocator.alloc<Binary>();\n      curr->op = PMaxVecF64x2;\n      break;\n    case BinaryConsts::I8x16NarrowI16x8S:\n      curr = allocator.alloc<Binary>();\n      curr->op = NarrowSVecI16x8ToVecI8x16;\n      break;\n    case BinaryConsts::I8x16NarrowI16x8U:\n      curr = allocator.alloc<Binary>();\n      curr->op = NarrowUVecI16x8ToVecI8x16;\n      break;\n    case BinaryConsts::I16x8NarrowI32x4S:\n      curr = allocator.alloc<Binary>();\n      curr->op = NarrowSVecI32x4ToVecI16x8;\n      break;\n    case BinaryConsts::I16x8NarrowI32x4U:\n      curr = allocator.alloc<Binary>();\n      curr->op = NarrowUVecI32x4ToVecI16x8;\n      break;\n    case BinaryConsts::I8x16Swizzle:\n      curr = allocator.alloc<Binary>();\n      curr->op = SwizzleVec8x16;\n      break;\n    case BinaryConsts::I8x16RelaxedSwizzle:\n      curr = allocator.alloc<Binary>();\n      curr->op = RelaxedSwizzleVec8x16;\n      break;\n    case BinaryConsts::F32x4RelaxedMin:\n      curr = allocator.alloc<Binary>();\n      curr->op = RelaxedMinVecF32x4;\n      break;\n    case BinaryConsts::F32x4RelaxedMax:\n      curr = allocator.alloc<Binary>();\n      curr->op = RelaxedMaxVecF32x4;\n      break;\n    case BinaryConsts::F64x2RelaxedMin:\n      curr = allocator.alloc<Binary>();\n      curr->op = RelaxedMinVecF64x2;\n      break;\n    case BinaryConsts::F64x2RelaxedMax:\n      curr = allocator.alloc<Binary>();\n      curr->op = RelaxedMaxVecF64x2;\n      break;\n    default:\n      return false;\n  }\n  BYN_TRACE(\"zz node: Binary\\n\");\n  curr->right = popNonVoidExpression();\n  curr->left = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":5091,"total_token_length":5327,"max_tokens_setting":6144}
+{"idx":238808,"func":"searchit(\n    win_T\t*win,\t\t\/\/ window to search in; can be NULL for a\n\t\t\t\t\/\/ buffer without a window!\n    buf_T\t*buf,\n    pos_T\t*pos,\n    pos_T\t*end_pos,\t\/\/ set to end of the match, unless NULL\n    int\t\tdir,\n    char_u\t*pat,\n    long\tcount,\n    int\t\toptions,\n    int\t\tpat_use,\t\/\/ which pattern to use when \"pat\" is empty\n    searchit_arg_T *extra_arg)\t\/\/ optional extra arguments, can be NULL\n{\n    int\t\tfound;\n    linenr_T\tlnum;\t\t\/\/ no init to shut up Apollo cc\n    colnr_T\tcol;\n    regmmatch_T\tregmatch;\n    char_u\t*ptr;\n    colnr_T\tmatchcol;\n    lpos_T\tendpos;\n    lpos_T\tmatchpos;\n    int\t\tloop;\n    pos_T\tstart_pos;\n    int\t\tat_first_line;\n    int\t\textra_col;\n    int\t\tstart_char_len;\n    int\t\tmatch_ok;\n    long\tnmatched;\n    int\t\tsubmatch = 0;\n    int\t\tfirst_match = TRUE;\n    int\t\tcalled_emsg_before = called_emsg;\n#ifdef FEAT_SEARCH_EXTRA\n    int\t\tbreak_loop = FALSE;\n#endif\n    linenr_T\tstop_lnum = 0;\t\/\/ stop after this line number when != 0\n#ifdef FEAT_RELTIME\n    proftime_T\t*tm = NULL;\t\/\/ timeout limit or NULL\n    int\t\t*timed_out = NULL;  \/\/ set when timed out or NULL\n#endif\n\n    if (extra_arg != NULL)\n    {\n\tstop_lnum = extra_arg->sa_stop_lnum;\n#ifdef FEAT_RELTIME\n\ttm = extra_arg->sa_tm;\n\ttimed_out = &extra_arg->sa_timed_out;\n#endif\n    }\n\n    if (search_regcomp(pat, RE_SEARCH, pat_use,\n\t\t   (options & (SEARCH_HIS + SEARCH_KEEP)), ®match) == FAIL)\n    {\n\tif ((options & SEARCH_MSG) && !rc_did_emsg)\n\t    semsg(_(e_invalid_search_string_str), mr_pattern);\n\treturn FAIL;\n    }\n\n    \/*\n     * find the string\n     *\/\n    do\t\/\/ loop for count\n    {\n\t\/\/ When not accepting a match at the start position set \"extra_col\" to\n\t\/\/ a non-zero value.  Don't do that when starting at MAXCOL, since\n\t\/\/ MAXCOL + 1 is zero.\n\tif (pos->col == MAXCOL)\n\t    start_char_len = 0;\n\t\/\/ Watch out for the \"col\" being MAXCOL - 2, used in a closed fold.\n\telse if (has_mbyte\n\t\t    && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count\n\t\t\t\t\t\t    && pos->col < MAXCOL - 2)\n\t{\n\t    ptr = ml_get_buf(buf, pos->lnum, FALSE);\n\t    if ((int)STRLEN(ptr) <= pos->col)\n\t\tstart_char_len = 1;\n\t    else\n\t\tstart_char_len = (*mb_ptr2len)(ptr + pos->col);\n\t}\n\telse\n\t    start_char_len = 1;\n\tif (dir == FORWARD)\n\t{\n\t    if (options & SEARCH_START)\n\t\textra_col = 0;\n\t    else\n\t\textra_col = start_char_len;\n\t}\n\telse\n\t{\n\t    if (options & SEARCH_START)\n\t\textra_col = start_char_len;\n\t    else\n\t\textra_col = 0;\n\t}\n\n\tstart_pos = *pos;\t\/\/ remember start pos for detecting no match\n\tfound = 0;\t\t\/\/ default: not found\n\tat_first_line = TRUE;\t\/\/ default: start in first line\n\tif (pos->lnum == 0)\t\/\/ correct lnum for when starting in line 0\n\t{\n\t    pos->lnum = 1;\n\t    pos->col = 0;\n\t    at_first_line = FALSE;  \/\/ not in first line now\n\t}\n\n\t\/*\n\t * Start searching in current line, unless searching backwards and\n\t * we're in column 0.\n\t * If we are searching backwards, in column 0, and not including the\n\t * current position, gain some efficiency by skipping back a line.\n\t * Otherwise begin the search in the current line.\n\t *\/\n\tif (dir == BACKWARD && start_pos.col == 0\n\t\t\t\t\t     && (options & SEARCH_START) == 0)\n\t{\n\t    lnum = pos->lnum - 1;\n\t    at_first_line = FALSE;\n\t}\n\telse\n\t    lnum = pos->lnum;\n\n\tfor (loop = 0; loop <= 1; ++loop)   \/\/ loop twice if 'wrapscan' set\n\t{\n\t    for ( ; lnum > 0 && lnum <= buf->b_ml.ml_line_count;\n\t\t\t\t\t   lnum += dir, at_first_line = FALSE)\n\t    {\n\t\t\/\/ Stop after checking \"stop_lnum\", if it's set.\n\t\tif (stop_lnum != 0 && (dir == FORWARD\n\t\t\t\t       ? lnum > stop_lnum : lnum < stop_lnum))\n\t\t    break;\n#ifdef FEAT_RELTIME\n\t\t\/\/ Stop after passing the \"tm\" time limit.\n\t\tif (tm != NULL && profile_passed_limit(tm))\n\t\t    break;\n#endif\n\n\t\t\/*\n\t\t * Look for a match somewhere in line \"lnum\".\n\t\t *\/\n\t\tcol = at_first_line && (options & SEARCH_COL) ? pos->col\n\t\t\t\t\t\t\t\t : (colnr_T)0;\n\t\tnmatched = vim_regexec_multi(®match, win, buf,\n\t\t\t\t\t     lnum, col,\n#ifdef FEAT_RELTIME\n\t\t\t\t\t     tm, timed_out\n#else\n\t\t\t\t\t     NULL, NULL\n#endif\n\t\t\t\t\t\t      );\n\t\t\/\/ vim_regexec_multi() may clear \"regprog\"\n\t\tif (regmatch.regprog == NULL)\n\t\t    break;\n\t\t\/\/ Abort searching on an error (e.g., out of stack).\n\t\tif (called_emsg > called_emsg_before\n#ifdef FEAT_RELTIME\n\t\t\t|| (timed_out != NULL && *timed_out)\n#endif\n\t\t\t)\n\t\t    break;\n\t\tif (nmatched > 0)\n\t\t{\n\t\t    \/\/ match may actually be in another line when using \\zs\n\t\t    matchpos = regmatch.startpos[0];\n\t\t    endpos = regmatch.endpos[0];\n#ifdef FEAT_EVAL\n\t\t    submatch = first_submatch(®match);\n#endif\n\t\t    \/\/ \"lnum\" may be past end of buffer for \"\\n\\zs\".\n\t\t    if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)\n\t\t\tptr = (char_u *)\"\";\n\t\t    else\n\t\t\tptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);\n\n\t\t    \/*\n\t\t     * Forward search in the first line: match should be after\n\t\t     * the start position. If not, continue at the end of the\n\t\t     * match (this is vi compatible) or on the next char.\n\t\t     *\/\n\t\t    if (dir == FORWARD && at_first_line)\n\t\t    {\n\t\t\tmatch_ok = TRUE;\n\t\t\t\/*\n\t\t\t * When the match starts in a next line it's certainly\n\t\t\t * past the start position.\n\t\t\t * When match lands on a NUL the cursor will be put\n\t\t\t * one back afterwards, compare with that position,\n\t\t\t * otherwise \"\/$\" will get stuck on end of line.\n\t\t\t *\/\n\t\t\twhile (matchpos.lnum == 0\n\t\t\t\t&& ((options & SEARCH_END) && first_match\n\t\t\t\t    ?  (nmatched == 1\n\t\t\t\t\t&& (int)endpos.col - 1\n\t\t\t\t\t     < (int)start_pos.col + extra_col)\n\t\t\t\t    : ((int)matchpos.col\n\t\t\t\t\t\t  - (ptr[matchpos.col] == NUL)\n\t\t\t\t\t    < (int)start_pos.col + extra_col)))\n\t\t\t{\n\t\t\t    \/*\n\t\t\t     * If vi-compatible searching, continue at the end\n\t\t\t     * of the match, otherwise continue one position\n\t\t\t     * forward.\n\t\t\t     *\/\n\t\t\t    if (vim_strchr(p_cpo, CPO_SEARCH) != NULL)\n\t\t\t    {\n\t\t\t\tif (nmatched > 1)\n\t\t\t\t{\n\t\t\t\t    \/\/ end is in next line, thus no match in\n\t\t\t\t    \/\/ this line\n\t\t\t\t    match_ok = FALSE;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t\tmatchcol = endpos.col;\n\t\t\t\t\/\/ for empty match: advance one char\n\t\t\t\tif (matchcol == matchpos.col\n\t\t\t\t\t\t      && ptr[matchcol] != NUL)\n\t\t\t\t{\n\t\t\t\t    if (has_mbyte)\n\t\t\t\t\tmatchcol +=\n\t\t\t\t\t  (*mb_ptr2len)(ptr + matchcol);\n\t\t\t\t    else\n\t\t\t\t\t++matchcol;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\tmatchcol = matchpos.col;\n\t\t\t\tif (ptr[matchcol] != NUL)\n\t\t\t\t{\n\t\t\t\t    if (has_mbyte)\n\t\t\t\t\tmatchcol += (*mb_ptr2len)(ptr\n\t\t\t\t\t\t\t\t  + matchcol);\n\t\t\t\t    else\n\t\t\t\t\t++matchcol;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    if (matchcol == 0 && (options & SEARCH_START))\n\t\t\t\tbreak;\n\t\t\t    if (ptr[matchcol] == NUL\n\t\t\t\t    || (nmatched = vim_regexec_multi(®match,\n\t\t\t\t\t      win, buf, lnum + matchpos.lnum,\n\t\t\t\t\t      matchcol,\n#ifdef FEAT_RELTIME\n\t\t\t\t\t      tm, timed_out\n#else\n\t\t\t\t\t      NULL, NULL\n#endif\n\t\t\t\t\t      )) == 0)\n\t\t\t    {\n\t\t\t\tmatch_ok = FALSE;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t    \/\/ vim_regexec_multi() may clear \"regprog\"\n\t\t\t    if (regmatch.regprog == NULL)\n\t\t\t\tbreak;\n\t\t\t    matchpos = regmatch.startpos[0];\n\t\t\t    endpos = regmatch.endpos[0];\n# ifdef FEAT_EVAL\n\t\t\t    submatch = first_submatch(®match);\n# endif\n\n\t\t\t    \/\/ Need to get the line pointer again, a\n\t\t\t    \/\/ multi-line search may have made it invalid.\n\t\t\t    ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);\n\t\t\t}\n\t\t\tif (!match_ok)\n\t\t\t    continue;\n\t\t    }\n\t\t    if (dir == BACKWARD)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Now, if there are multiple matches on this line,\n\t\t\t * we have to get the last one. Or the last one before\n\t\t\t * the cursor, if we're on that line.\n\t\t\t * When putting the new cursor at the end, compare\n\t\t\t * relative to the end of the match.\n\t\t\t *\/\n\t\t\tmatch_ok = FALSE;\n\t\t\tfor (;;)\n\t\t\t{\n\t\t\t    \/\/ Remember a position that is before the start\n\t\t\t    \/\/ position, we use it if it's the last match in\n\t\t\t    \/\/ the line.  Always accept a position after\n\t\t\t    \/\/ wrapping around.\n\t\t\t    if (loop\n\t\t\t\t|| ((options & SEARCH_END)\n\t\t\t\t    ? (lnum + regmatch.endpos[0].lnum\n\t\t\t\t\t\t\t      < start_pos.lnum\n\t\t\t\t\t|| (lnum + regmatch.endpos[0].lnum\n\t\t\t\t\t\t\t     == start_pos.lnum\n\t\t\t\t\t     && (int)regmatch.endpos[0].col - 1\n\t\t\t\t\t\t\t< (int)start_pos.col\n\t\t\t\t\t\t\t\t+ extra_col))\n\t\t\t\t    : (lnum + regmatch.startpos[0].lnum\n\t\t\t\t\t\t\t      < start_pos.lnum\n\t\t\t\t\t|| (lnum + regmatch.startpos[0].lnum\n\t\t\t\t\t\t\t     == start_pos.lnum\n\t\t\t\t\t     && (int)regmatch.startpos[0].col\n\t\t\t\t\t\t      < (int)start_pos.col\n\t\t\t\t\t\t\t      + extra_col))))\n\t\t\t    {\n\t\t\t\tmatch_ok = TRUE;\n\t\t\t\tmatchpos = regmatch.startpos[0];\n\t\t\t\tendpos = regmatch.endpos[0];\n# ifdef FEAT_EVAL\n\t\t\t\tsubmatch = first_submatch(®match);\n# endif\n\t\t\t    }\n\t\t\t    else\n\t\t\t\tbreak;\n\n\t\t\t    \/*\n\t\t\t     * We found a valid match, now check if there is\n\t\t\t     * another one after it.\n\t\t\t     * If vi-compatible searching, continue at the end\n\t\t\t     * of the match, otherwise continue one position\n\t\t\t     * forward.\n\t\t\t     *\/\n\t\t\t    if (vim_strchr(p_cpo, CPO_SEARCH) != NULL)\n\t\t\t    {\n\t\t\t\tif (nmatched > 1)\n\t\t\t\t    break;\n\t\t\t\tmatchcol = endpos.col;\n\t\t\t\t\/\/ for empty match: advance one char\n\t\t\t\tif (matchcol == matchpos.col\n\t\t\t\t\t\t      && ptr[matchcol] != NUL)\n\t\t\t\t{\n\t\t\t\t    if (has_mbyte)\n\t\t\t\t\tmatchcol +=\n\t\t\t\t\t  (*mb_ptr2len)(ptr + matchcol);\n\t\t\t\t    else\n\t\t\t\t\t++matchcol;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    else\n\t\t\t    {\n\t\t\t\t\/\/ Stop when the match is in a next line.\n\t\t\t\tif (matchpos.lnum > 0)\n\t\t\t\t    break;\n\t\t\t\tmatchcol = matchpos.col;\n\t\t\t\tif (ptr[matchcol] != NUL)\n\t\t\t\t{\n\t\t\t\t    if (has_mbyte)\n\t\t\t\t\tmatchcol +=\n\t\t\t\t\t  (*mb_ptr2len)(ptr + matchcol);\n\t\t\t\t    else\n\t\t\t\t\t++matchcol;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t    if (ptr[matchcol] == NUL\n\t\t\t\t    || (nmatched = vim_regexec_multi(®match,\n\t\t\t\t\t      win, buf, lnum + matchpos.lnum,\n\t\t\t\t\t      matchcol,\n#ifdef FEAT_RELTIME\n\t\t\t\t\t      tm, timed_out\n#else\n\t\t\t\t\t      NULL, NULL\n#endif\n\t\t\t\t\t    )) == 0)\n\t\t\t    {\n#ifdef FEAT_RELTIME\n\t\t\t\t\/\/ If the search timed out, we did find a match\n\t\t\t\t\/\/ but it might be the wrong one, so that's not\n\t\t\t\t\/\/ OK.\n\t\t\t\tif (timed_out != NULL && *timed_out)\n\t\t\t\t    match_ok = FALSE;\n#endif\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t    \/\/ vim_regexec_multi() may clear \"regprog\"\n\t\t\t    if (regmatch.regprog == NULL)\n\t\t\t\tbreak;\n\n\t\t\t    \/\/ Need to get the line pointer again, a\n\t\t\t    \/\/ multi-line search may have made it invalid.\n\t\t\t    ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * If there is only a match after the cursor, skip\n\t\t\t * this match.\n\t\t\t *\/\n\t\t\tif (!match_ok)\n\t\t\t    continue;\n\t\t    }\n\n\t\t    \/\/ With the SEARCH_END option move to the last character\n\t\t    \/\/ of the match.  Don't do it for an empty match, end\n\t\t    \/\/ should be same as start then.\n\t\t    if ((options & SEARCH_END) && !(options & SEARCH_NOOF)\n\t\t\t    && !(matchpos.lnum == endpos.lnum\n\t\t\t\t&& matchpos.col == endpos.col))\n\t\t    {\n\t\t\t\/\/ For a match in the first column, set the position\n\t\t\t\/\/ on the NUL in the previous line.\n\t\t\tpos->lnum = lnum + endpos.lnum;\n\t\t\tpos->col = endpos.col;\n\t\t\tif (endpos.col == 0)\n\t\t\t{\n\t\t\t    if (pos->lnum > 1)  \/\/ just in case\n\t\t\t    {\n\t\t\t\t--pos->lnum;\n\t\t\t\tpos->col = (colnr_T)STRLEN(ml_get_buf(buf,\n\t\t\t\t\t\t\t   pos->lnum, FALSE));\n\t\t\t    }\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    --pos->col;\n\t\t\t    if (has_mbyte\n\t\t\t\t    && pos->lnum <= buf->b_ml.ml_line_count)\n\t\t\t    {\n\t\t\t\tptr = ml_get_buf(buf, pos->lnum, FALSE);\n\t\t\t\tpos->col -= (*mb_head_off)(ptr, ptr + pos->col);\n\t\t\t    }\n\t\t\t}\n\t\t\tif (end_pos != NULL)\n\t\t\t{\n\t\t\t    end_pos->lnum = lnum + matchpos.lnum;\n\t\t\t    end_pos->col = matchpos.col;\n\t\t\t}\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tpos->lnum = lnum + matchpos.lnum;\n\t\t\tpos->col = matchpos.col;\n\t\t\tif (end_pos != NULL)\n\t\t\t{\n\t\t\t    end_pos->lnum = lnum + endpos.lnum;\n\t\t\t    end_pos->col = endpos.col;\n\t\t\t}\n\t\t    }\n\t\t    pos->coladd = 0;\n\t\t    if (end_pos != NULL)\n\t\t\tend_pos->coladd = 0;\n\t\t    found = 1;\n\t\t    first_match = FALSE;\n\n\t\t    \/\/ Set variables used for 'incsearch' highlighting.\n\t\t    search_match_lines = endpos.lnum - matchpos.lnum;\n\t\t    search_match_endcol = endpos.col;\n\t\t    break;\n\t\t}\n\t\tline_breakcheck();\t\/\/ stop if ctrl-C typed\n\t\tif (got_int)\n\t\t    break;\n\n#ifdef FEAT_SEARCH_EXTRA\n\t\t\/\/ Cancel searching if a character was typed.  Used for\n\t\t\/\/ 'incsearch'.  Don't check too often, that would slowdown\n\t\t\/\/ searching too much.\n\t\tif ((options & SEARCH_PEEK)\n\t\t\t&& ((lnum - pos->lnum) & 0x3f) == 0\n\t\t\t&& char_avail())\n\t\t{\n\t\t    break_loop = TRUE;\n\t\t    break;\n\t\t}\n#endif\n\n\t\tif (loop && lnum == start_pos.lnum)\n\t\t    break;\t    \/\/ if second loop, stop where started\n\t    }\n\t    at_first_line = FALSE;\n\n\t    \/\/ vim_regexec_multi() may clear \"regprog\"\n\t    if (regmatch.regprog == NULL)\n\t\tbreak;\n\n\t    \/*\n\t     * Stop the search if wrapscan isn't set, \"stop_lnum\" is\n\t     * specified, after an interrupt, after a match and after looping\n\t     * twice.\n\t     *\/\n\t    if (!p_ws || stop_lnum != 0 || got_int\n\t\t\t\t\t    || called_emsg > called_emsg_before\n#ifdef FEAT_RELTIME\n\t\t\t\t|| (timed_out != NULL && *timed_out)\n#endif\n#ifdef FEAT_SEARCH_EXTRA\n\t\t\t\t|| break_loop\n#endif\n\t\t\t\t|| found || loop)\n\t\tbreak;\n\n\t    \/*\n\t     * If 'wrapscan' is set we continue at the other end of the file.\n\t     * If 'shortmess' does not contain 's', we give a message.\n\t     * This message is also remembered in keep_msg for when the screen\n\t     * is redrawn. The keep_msg is cleared whenever another message is\n\t     * written.\n\t     *\/\n\t    if (dir == BACKWARD)    \/\/ start second loop at the other end\n\t\tlnum = buf->b_ml.ml_line_count;\n\t    else\n\t\tlnum = 1;\n\t    if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))\n\t\tgive_warning((char_u *)_(dir == BACKWARD\n\t\t\t\t\t  ? top_bot_msg : bot_top_msg), TRUE);\n\t    if (extra_arg != NULL)\n\t\textra_arg->sa_wrapped = TRUE;\n\t}\n\tif (got_int || called_emsg > called_emsg_before\n#ifdef FEAT_RELTIME\n\t\t|| (timed_out != NULL && *timed_out)\n#endif\n#ifdef FEAT_SEARCH_EXTRA\n\t\t|| break_loop\n#endif\n\t\t)\n\t    break;\n    }\n    while (--count > 0 && found);   \/\/ stop after count matches or no match\n\n    vim_regfree(regmatch.regprog);\n\n    if (!found)\t\t    \/\/ did not find it\n    {\n\tif (got_int)\n\t    emsg(_(e_interrupted));\n\telse if ((options & SEARCH_MSG) == SEARCH_MSG)\n\t{\n\t    if (p_ws)\n\t\tsemsg(_(e_pattern_not_found_str), mr_pattern);\n\t    else if (lnum == 0)\n\t\tsemsg(_(e_search_hit_top_without_match_for_str), mr_pattern);\n\t    else\n\t\tsemsg(_(e_search_hit_bottom_without_match_for_str), mr_pattern);\n\t}\n\treturn FAIL;\n    }\n\n    \/\/ A pattern like \"\\n\\zs\" may go past the last line.\n    if (pos->lnum > buf->b_ml.ml_line_count)\n    {\n\tpos->lnum = buf->b_ml.ml_line_count;\n\tpos->col = (int)STRLEN(ml_get_buf(buf, pos->lnum, FALSE));\n\tif (pos->col > 0)\n\t    --pos->col;\n    }\n\n    return submatch + 1;\n}","target":0,"code_token_length":4262,"total_token_length":4498,"max_tokens_setting":6144}
+{"idx":513258,"func":"test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,\n\t\t\tbool no_changes, const key_map *map)\n{\n  int ref_key;\n  uint UNINIT_VAR(ref_key_parts);\n  int order_direction= 0;\n  uint used_key_parts= 0;\n  TABLE *table=tab->table;\n  SQL_SELECT *select=tab->select;\n  key_map usable_keys;\n  QUICK_SELECT_I *save_quick= select ? select->quick : 0;\n  Item *orig_cond= 0;\n  bool orig_cond_saved= false;\n  int best_key= -1;\n  bool changed_key= false;\n  DBUG_ENTER(\"test_if_skip_sort_order\");\n\n  \/* Check that we are always called with first non-const table *\/\n  DBUG_ASSERT(tab == tab->join->join_tab + tab->join->const_tables);\n\n  \/*\n    Keys disabled by ALTER TABLE ... DISABLE KEYS should have already\n    been taken into account.\n  *\/\n  usable_keys= *map;\n  \n  \/* Find indexes that cover all ORDER\/GROUP BY fields *\/\n  for (ORDER *tmp_order=order; tmp_order ; tmp_order=tmp_order->next)\n  {\n    Item *item= (*tmp_order->item)->real_item();\n    if (item->type() != Item::FIELD_ITEM)\n    {\n      usable_keys.clear_all();\n      DBUG_RETURN(0);\n    }\n\n    \/*\n      Take multiple-equalities into account. Suppose we have\n        ORDER BY col1, col10\n      and there are\n         multiple-equal(col1, col2, col3),\n         multiple-equal(col10, col11).\n\n      Then, \n      - when item=col1, we find the set of indexes that cover one of {col1,\n        col2, col3}\n      - when item=col10, we find the set of indexes that cover one of {col10,\n        col11}\n\n      And we compute an intersection of these sets to find set of indexes that\n      cover all ORDER BY components.\n    *\/\n    key_map col_keys;\n    compute_part_of_sort_key_for_equals(tab->join, table, (Item_field*)item,\n                                        &col_keys);\n    usable_keys.intersect(col_keys);\n    if (usable_keys.is_clear_all())\n      goto use_filesort;                        \/\/ No usable keys\n  }\n\n  ref_key= -1;\n  \/* Test if constant range in WHERE *\/\n  if (tab->ref.key >= 0 && tab->ref.key_parts)\n  {\n    ref_key=\t   tab->ref.key;\n    ref_key_parts= tab->ref.key_parts;\n    \/* \n      todo: why does JT_REF_OR_NULL mean filesort? We could find another index\n      that satisfies the ordering. I would just set ref_key=MAX_KEY here...\n    *\/\n    if (tab->type == JT_REF_OR_NULL || tab->type == JT_FT)\n      goto use_filesort;\n  }\n  else if (select && select->quick)\t\t\/\/ Range found by opt_range\n  {\n    int quick_type= select->quick->get_type();\n    \/* \n      assume results are not ordered when index merge is used \n      TODO: sergeyp: Results of all index merge selects actually are ordered \n      by clustered PK values.\n    *\/\n  \n    if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||\n        quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||\n        quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION || \n        quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT)\n    {\n      \/*\n        we set ref_key=MAX_KEY instead of -1, because test_if_cheaper ordering\n        assumes that \"ref_key==-1\" means doing full index scan. \n        (This is not very straightforward and we got into this situation for \n         historical reasons. Should be fixed at some point).\n      *\/\n      ref_key= MAX_KEY;\n    }\n    else\n    {\n      ref_key= select->quick->index;\n      ref_key_parts= select->quick->used_key_parts;\n    }\n  }\n\n  if (ref_key >= 0 && ref_key != MAX_KEY)\n  {\n    \/* Current access method uses index ref_key with ref_key_parts parts *\/\n    if (!usable_keys.is_set(ref_key))\n    {\n      \/* However, ref_key doesn't match the needed ordering *\/\n      uint new_ref_key;\n\n      \/*\n\tIf using index only read, only consider other possible index only\n\tkeys\n      *\/\n      if (table->covering_keys.is_set(ref_key))\n\tusable_keys.intersect(table->covering_keys);\n      if (tab->pre_idx_push_select_cond)\n      {\n        orig_cond= tab->set_cond(tab->pre_idx_push_select_cond);\n        orig_cond_saved= true;\n      }\n\n      if ((new_ref_key= test_if_subkey(order, table, ref_key, ref_key_parts,\n\t\t\t\t       &usable_keys)) < MAX_KEY)\n      {\n        \/*\n          Index new_ref_key \n          - produces the required ordering, \n          - also has the same columns as ref_key for #ref_key_parts (this\n            means we will read the same number of rows as with ref_key).\n        *\/\n\n        \/*\n          If new_ref_key allows to construct a quick select which uses more key\n          parts than ref(new_ref_key) would, do that.\n\n          Otherwise, construct a ref access (todo: it's not clear what is the\n          win in using ref access when we could use quick select also?)\n        *\/\n        if ((table->quick_keys.is_set(new_ref_key) && \n             table->quick_key_parts[new_ref_key] > ref_key_parts) ||\n             !(tab->ref.key >= 0))\n\t{\n          \/*\n            The range optimizer constructed QUICK_RANGE for ref_key, and\n            we want to use instead new_ref_key as the index. We can't\n            just change the index of the quick select, because this may\n            result in an inconsistent QUICK_SELECT object. Below we\n            create a new QUICK_SELECT from scratch so that all its\n            parameters are set correctly by the range optimizer.\n           *\/\n          key_map new_ref_key_map;\n          COND *save_cond;\n          bool res;\n          new_ref_key_map.clear_all();  \/\/ Force the creation of quick select\n          new_ref_key_map.set_bit(new_ref_key); \/\/ only for new_ref_key.\n\n          \/* Reset quick;  This will be restored in 'use_filesort' if needed *\/\n          select->quick= 0;\n          save_cond= select->cond;\n          if (select->pre_idx_push_select_cond)\n            select->cond= select->pre_idx_push_select_cond;\n          res= select->test_quick_select(tab->join->thd, new_ref_key_map, 0,\n                                         (tab->join->select_options &\n                                          OPTION_FOUND_ROWS) ?\n                                         HA_POS_ERROR :\n                                         tab->join->unit->select_limit_cnt,TRUE,\n                                         TRUE, FALSE) <= 0;\n          if (res)\n          {\n            select->cond= save_cond;\n            goto use_filesort;\n          }\n          DBUG_ASSERT(tab->select->quick);\n          tab->type= JT_ALL;\n          tab->ref.key= -1;\n          tab->ref.key_parts= 0;\n          tab->use_quick= 1;\n          best_key= new_ref_key;\n          \/*\n            We don't restore select->cond as we want to use the\n            original condition as index condition pushdown is not\n            active for the new index.\n            todo: why not perform index condition pushdown for the new index?\n          *\/\n\t}\n        else\n\t{\n          \/*\n            We'll use ref access method on key new_ref_key. In general case \n            the index search tuple for new_ref_key will be different (e.g.\n            when one index is defined as (part1, part2, ...) and another as\n            (part1, part2(N), ...) and the WHERE clause contains \n            \"part1 = const1 AND part2=const2\". \n            So we build tab->ref from scratch here.\n          *\/\n          KEYUSE *keyuse= tab->keyuse;\n          while (keyuse->key != new_ref_key && keyuse->table == tab->table)\n            keyuse++;\n          if (create_ref_for_key(tab->join, tab, keyuse, FALSE,\n                                 (tab->join->const_table_map |\n                                  OUTER_REF_TABLE_BIT)))\n            goto use_filesort;\n\n          pick_table_access_method(tab);\n\t}\n\n        ref_key= new_ref_key;\n        changed_key= true;\n     }\n    }\n    \/* Check if we get the rows in requested sorted order by using the key *\/\n    if (usable_keys.is_set(ref_key) &&\n        (order_direction= test_if_order_by_key(tab->join, order,table,ref_key,\n\t\t\t\t\t       &used_key_parts)))\n      goto check_reverse_order;\n  }\n  {\n    uint UNINIT_VAR(best_key_parts);\n    uint saved_best_key_parts= 0;\n    int best_key_direction= 0;\n    JOIN *join= tab->join;\n    ha_rows table_records= table->stat_records();\n\n    test_if_cheaper_ordering(tab, order, table, usable_keys,\n                             ref_key, select_limit,\n                             &best_key, &best_key_direction,\n                             &select_limit, &best_key_parts,\n                             &saved_best_key_parts);\n\n    \/*\n      filesort() and join cache are usually faster than reading in \n      index order and not using join cache, except in case that chosen\n      index is clustered key.\n    *\/\n    if (best_key < 0 ||\n        ((select_limit >= table_records) &&\n         (tab->type == JT_ALL &&\n         tab->join->table_count > tab->join->const_tables + 1) &&\n         !(table->file->index_flags(best_key, 0, 1) & HA_CLUSTERED_INDEX)))\n      goto use_filesort;\n\n    if (select && \/\/ psergey:  why doesn't this use a quick?\n        table->quick_keys.is_set(best_key) && best_key != ref_key)\n    {\n      key_map tmp_map;\n      tmp_map.clear_all();       \/\/ Force the creation of quick select\n      tmp_map.set_bit(best_key); \/\/ only best_key.\n      select->quick= 0;\n\n      bool cond_saved= false;\n      Item *saved_cond;\n\n      \/*\n        Index Condition Pushdown may have removed parts of the condition for\n        this table. Temporarily put them back because we want the whole\n        condition for the range analysis.\n      *\/\n      if (select->pre_idx_push_select_cond)\n      {\n        saved_cond= select->cond;\n        select->cond= select->pre_idx_push_select_cond;\n        cond_saved= true;\n      }\n\n      select->test_quick_select(join->thd, tmp_map, 0,\n                                join->select_options & OPTION_FOUND_ROWS ?\n                                HA_POS_ERROR :\n                                join->unit->select_limit_cnt,\n                                TRUE, FALSE, FALSE);\n\n      if (cond_saved)\n        select->cond= saved_cond;\n    }\n    order_direction= best_key_direction;\n    \/*\n      saved_best_key_parts is actual number of used keyparts found by the\n      test_if_order_by_key function. It could differ from keyinfo->user_defined_key_parts,\n      thus we have to restore it in case of desc order as it affects\n      QUICK_SELECT_DESC behaviour.\n    *\/\n    used_key_parts= (order_direction == -1) ?\n      saved_best_key_parts :  best_key_parts;\n    changed_key= true;\n  }\n\ncheck_reverse_order:                  \n  DBUG_ASSERT(order_direction != 0);\n\n  if (order_direction == -1)\t\t\/\/ If ORDER BY ... DESC\n  {\n    int quick_type;\n    if (select && select->quick)\n    {\n      \/*\n\tDon't reverse the sort order, if it's already done.\n        (In some cases test_if_order_by_key() can be called multiple times\n      *\/\n      if (select->quick->reverse_sorted())\n        goto skipped_filesort;\n\n      quick_type= select->quick->get_type();\n      if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||\n          quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||\n          quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||\n          quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||\n          quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)\n      {\n        tab->limit= 0;\n        goto use_filesort;               \/\/ Use filesort\n      }\n    }\n  }\n\n  \/*\n    Update query plan with access pattern for doing ordered access\n    according to what we have decided above.\n  *\/\n  if (!no_changes) \/\/ We are allowed to update QEP\n  {\n    if (best_key >= 0)\n    {\n      bool quick_created= \n        (select && select->quick && select->quick!=save_quick);\n\n      \/* \n         If ref_key used index tree reading only ('Using index' in EXPLAIN),\n         and best_key doesn't, then revert the decision.\n      *\/\n      if (table->covering_keys.is_set(best_key))\n        table->file->ha_start_keyread(best_key);\n      else\n        table->file->ha_end_keyread();\n\n      if (!quick_created)\n      {\n        if (select)                  \/\/ Throw any existing quick select\n          select->quick= 0;          \/\/ Cleanup either reset to save_quick,\n                                     \/\/ or 'delete save_quick'\n        tab->index= best_key;\n        tab->read_first_record= order_direction > 0 ?\n                                join_read_first:join_read_last;\n        tab->type=JT_NEXT;           \/\/ Read with index_first(), index_next()\n\n        if (tab->pre_idx_push_select_cond)\n        {\n          tab->set_cond(tab->pre_idx_push_select_cond);\n          \/*\n            orig_cond is a part of pre_idx_push_cond,\n            no need to restore it.\n          *\/\n          orig_cond= 0;\n          orig_cond_saved= false;\n        }\n\n        table->file->ha_index_or_rnd_end();\n        if (tab->join->select_options & SELECT_DESCRIBE)\n        {\n          tab->ref.key= -1;\n          tab->ref.key_parts= 0;\n          if (select_limit < table->stat_records())\n            tab->limit= select_limit;\n          table->file->ha_end_keyread();\n        }\n      }\n      else if (tab->type != JT_ALL || tab->select->quick)\n      {\n        \/*\n          We're about to use a quick access to the table.\n          We need to change the access method so as the quick access\n          method is actually used.\n        *\/\n        DBUG_ASSERT(tab->select->quick);\n        tab->type=JT_ALL;\n        tab->use_quick=1;\n        tab->ref.key= -1;\n        tab->ref.key_parts=0;\t\t\/\/ Don't use ref key.\n        tab->read_first_record= join_init_read_record;\n        if (tab->is_using_loose_index_scan())\n          tab->join->tmp_table_param.precomputed_group_by= TRUE;\n\n        \/*\n          Restore the original condition as changes done by pushdown\n          condition are not relevant anymore\n        *\/\n        if (tab->select && tab->select->pre_idx_push_select_cond)\n\t{\n          tab->set_cond(tab->select->pre_idx_push_select_cond);\n           tab->table->file->cancel_pushed_idx_cond();\n        }\n        \/*\n          TODO: update the number of records in join->best_positions[tablenr]\n        *\/\n      }\n    } \/\/ best_key >= 0\n\n    if (order_direction == -1)\t\t\/\/ If ORDER BY ... DESC\n    {\n      if (select && select->quick)\n      {\n        \/* ORDER BY range_key DESC *\/\n        QUICK_SELECT_I *tmp= select->quick->make_reverse(used_key_parts);\n        if (!tmp)\n        {\n          tab->limit= 0;\n          goto use_filesort;           \/\/ Reverse sort failed -> filesort\n        }\n        \/*\n          Cancel Pushed Index Condition, as it doesn't work for reverse scans.\n        *\/\n        if (tab->select && tab->select->pre_idx_push_select_cond)\n\t{\n          tab->set_cond(tab->select->pre_idx_push_select_cond);\n           tab->table->file->cancel_pushed_idx_cond();\n        }\n        if (select->quick == save_quick)\n          save_quick= 0;                \/\/ make_reverse() consumed it\n        select->set_quick(tmp);\n        \/* Cancel \"Range checked for each record\" *\/\n        if (tab->use_quick == 2)\n        {\n          tab->use_quick= 1;\n          tab->read_first_record= join_init_read_record;\n        }\n      }\n      else if (tab->type != JT_NEXT && tab->type != JT_REF_OR_NULL &&\n               tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)\n      {\n        \/*\n          SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC\n\n          Use a traversal function that starts by reading the last row\n          with key part (A) and then traverse the index backwards.\n        *\/\n        tab->read_first_record= join_read_last_key;\n        tab->read_record.read_record= join_read_prev_same;\n        \/* Cancel \"Range checked for each record\" *\/\n        if (tab->use_quick == 2)\n        {\n          tab->use_quick= 1;\n          tab->read_first_record= join_init_read_record;\n        }\n        \/*\n          Cancel Pushed Index Condition, as it doesn't work for reverse scans.\n        *\/\n        if (tab->select && tab->select->pre_idx_push_select_cond)\n\t{\n          tab->set_cond(tab->select->pre_idx_push_select_cond);\n           tab->table->file->cancel_pushed_idx_cond();\n        }\n      }\n    }\n    else if (select && select->quick)\n    {\n      \/* Cancel \"Range checked for each record\" *\/\n      if (tab->use_quick == 2)\n      {\n        tab->use_quick= 1;\n        tab->read_first_record= join_init_read_record;\n      }\n      select->quick->need_sorted_output();\n    }\n\n    tab->read_record.unlock_row= (tab->type == JT_EQ_REF) ?\n                                 join_read_key_unlock_row : rr_unlock_row;\n\n  } \/\/ QEP has been modified\n\n  \/*\n    Cleanup:\n    We may have both a 'select->quick' and 'save_quick' (original)\n    at this point. Delete the one that we wan't use.\n  *\/\n\nskipped_filesort:\n  \/\/ Keep current (ordered) select->quick \n  if (select && save_quick != select->quick)\n  {\n    delete save_quick;\n    save_quick= NULL;\n  }\n  if (orig_cond_saved && !changed_key)\n    tab->set_cond(orig_cond);\n  if (!no_changes && changed_key && table->file->pushed_idx_cond)\n    table->file->cancel_pushed_idx_cond();\n\n  DBUG_RETURN(1);\n\nuse_filesort:\n  \/\/ Restore original save_quick\n  if (select && select->quick != save_quick)\n  {\n    delete select->quick;\n    select->quick= save_quick;\n  }\n  if (orig_cond_saved)\n    tab->set_cond(orig_cond);\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":4057,"total_token_length":4293,"max_tokens_setting":6144}
+{"idx":204438,"func":"WandPrivate void CLINoImageOperator(MagickCLI *cli_wand,\n  const char *option,const char *arg1n,const char *arg2n)\n{\n  const char    \/* percent escaped versions of the args *\/\n    *arg1,\n    *arg2;\n\n#define _image_info     (cli_wand->wand.image_info)\n#define _images         (cli_wand->wand.images)\n#define _exception      (cli_wand->wand.exception)\n#define _process_flags  (cli_wand->process_flags)\n#define _option_type    ((CommandOptionFlags) cli_wand->command->flags)\n#define IfNormalOp      (*option=='-')\n#define IfPlusOp        (*option!='-')\n\n  assert(cli_wand != (MagickCLI *) NULL);\n  assert(cli_wand->signature == MagickWandSignature);\n  assert(cli_wand->wand.signature == MagickWandSignature);\n\n  if (cli_wand->wand.debug != MagickFalse)\n    (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),\n      \"- NoImage Operator: %s \\\"%s\\\" \\\"%s\\\"\", option,\n      arg1n != (char *) NULL ? arg1n : \"\",\n      arg2n != (char *) NULL ? arg2n : \"\");\n\n  arg1 = arg1n;\n  arg2 = arg2n;\n\n  \/* Interpret Percent Escapes in Arguments - using first image *\/\n  if ( (((_process_flags & ProcessInterpretProperities) != 0 )\n        || ((_option_type & AlwaysInterpretArgsFlag) != 0)\n       )  && ((_option_type & NeverInterpretArgsFlag) == 0) ) {\n    \/* Interpret Percent escapes in argument 1 *\/\n    if (arg1n != (char *) NULL) {\n      arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);\n      if (arg1 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg1=arg1n;  \/* use the given argument as is *\/\n      }\n    }\n    if (arg2n != (char *) NULL) {\n      arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n      if (arg2 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg2=arg2n;  \/* use the given argument as is *\/\n      }\n    }\n  }\n#undef _process_flags\n#undef _option_type\n\n  do {  \/* break to exit code *\/\n    \/*\n      No-op options  (ignore these)\n    *\/\n    if (LocaleCompare(\"noop\",option+1) == 0)   \/* zero argument *\/\n      break;\n    if (LocaleCompare(\"sans\",option+1) == 0)   \/* one argument *\/\n      break;\n    if (LocaleCompare(\"sans0\",option+1) == 0)  \/* zero argument *\/\n      break;\n    if (LocaleCompare(\"sans1\",option+1) == 0)  \/* one argument *\/\n      break;\n    if (LocaleCompare(\"sans2\",option+1) == 0)  \/* two arguments *\/\n      break;\n    \/*\n      Image Reading\n    *\/\n    if ( ( LocaleCompare(\"read\",option+1) == 0 ) ||\n      ( LocaleCompare(\"--\",option) == 0 ) ) {\n      \/* Do Glob filename Expansion for 'arg1' then read all images.\n      *\n      * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring\n      * (but attaching to the filenames in the generated argument list) any\n      * [...] read modifiers that may be present.\n      *\n      * For example: It will expand '*.gif[20x20]' into a list such as\n      * 'abc.gif[20x20]',  'foobar.gif[20x20]',  'xyzzy.gif[20x20]'\n      *\n      * NOTE: In IMv6 this was done globally across all images. This\n      * meant you could include IM options in '@filename' lists, but you\n      * could not include comments.   Doing it only for image read makes\n      * it far more secure.\n      *\n      * Note: arguments do not have percent escapes expanded for security\n      * reasons.\n      *\/\n      int      argc;\n      char     **argv;\n      ssize_t  i;\n\n      argc = 1;\n      argv = (char **) &arg1;\n\n      \/* Expand 'glob' expressions in the given filename.\n        Expansion handles any 'coder:' prefix, or read modifiers attached\n        to the filename, including them in the resulting expanded list.\n      *\/\n      if (ExpandFilenames(&argc,&argv) == MagickFalse)\n        CLIWandExceptArgBreak(ResourceLimitError,\"MemoryAllocationFailed\",\n            option,GetExceptionMessage(errno));\n\n      \/* loop over expanded filename list, and read then all in *\/\n      for (i=0; i < (ssize_t) argc; i++) {\n        Image *\n          new_images;\n        if (_image_info->ping != MagickFalse)\n          new_images=PingImages(_image_info,argv[i],_exception);\n        else\n          new_images=ReadImages(_image_info,argv[i],_exception);\n        AppendImageToList(&_images, new_images);\n        argv[i]=DestroyString(argv[i]);\n      }\n      argv=(char **) RelinquishMagickMemory(argv);\n      break;\n    }\n    \/*\n      Image Writing\n      Note: Writing a empty image list is valid in specific cases\n    *\/\n    if (LocaleCompare(\"write\",option+1) == 0) {\n      \/* Note: arguments do not have percent escapes expanded *\/\n      char\n        key[MagickPathExtent];\n\n      Image\n        *write_images;\n\n      ImageInfo\n        *write_info;\n\n      \/* Need images, unless a \"null:\" output coder is used *\/\n      if ( _images == (Image *) NULL ) {\n        if ( LocaleCompare(arg1,\"null:\") == 0 )\n          break;\n        CLIWandExceptArgBreak(OptionError,\"NoImagesForWrite\",option,arg1);\n      }\n\n      (void) FormatLocaleString(key,MagickPathExtent,\"cache:%s\",arg1);\n      (void) DeleteImageRegistry(key);\n      write_images=CloneImageList(_images,_exception);\n      write_info=CloneImageInfo(_image_info);\n      (void) WriteImages(write_info,write_images,arg1,_exception);\n      write_info=DestroyImageInfo(write_info);\n      write_images=DestroyImageList(write_images);\n      break;\n    }\n    \/*\n      Parenthesis and Brace operations\n    *\/\n    if (LocaleCompare(\"(\",option) == 0) {\n      \/* stack 'push' images *\/\n      Stack\n        *node;\n\n      size_t\n        size;\n\n      size=0;\n      node=cli_wand->image_list_stack;\n      for ( ; node != (Stack *) NULL; node=node->next)\n        size++;\n      if ( size >= MAX_STACK_DEPTH )\n        CLIWandExceptionBreak(OptionError,\"ParenthesisNestedTooDeeply\",option);\n      node=(Stack *) AcquireMagickMemory(sizeof(*node));\n      if (node == (Stack *) NULL)\n        CLIWandExceptionBreak(ResourceLimitFatalError,\n            \"MemoryAllocationFailed\",option);\n      node->data = (void *)cli_wand->wand.images;\n      node->next = cli_wand->image_list_stack;\n      cli_wand->image_list_stack = node;\n      cli_wand->wand.images = NewImageList();\n\n      \/* handle respect-parenthesis *\/\n      if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,\n                    \"respect-parenthesis\")) != MagickFalse)\n        option=\"{\"; \/* fall-thru so as to push image settings too *\/\n      else\n        break;\n      \/* fall thru to operation *\/\n    }\n    if (LocaleCompare(\"{\",option) == 0) {\n      \/* stack 'push' of image_info settings *\/\n      Stack\n        *node;\n\n      size_t\n        size;\n\n      size=0;\n      node=cli_wand->image_info_stack;\n      for ( ; node != (Stack *) NULL; node=node->next)\n        size++;\n      if ( size >= MAX_STACK_DEPTH )\n        CLIWandExceptionBreak(OptionError,\"CurlyBracesNestedTooDeeply\",option);\n      node=(Stack *) AcquireMagickMemory(sizeof(*node));\n      if (node == (Stack *) NULL)\n        CLIWandExceptionBreak(ResourceLimitFatalError,\n            \"MemoryAllocationFailed\",option);\n\n      node->data = (void *)cli_wand->wand.image_info;\n      node->next = cli_wand->image_info_stack;\n\n      cli_wand->image_info_stack = node;\n      cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);\n      if (cli_wand->wand.image_info == (ImageInfo *) NULL) {\n        CLIWandException(ResourceLimitFatalError,\"MemoryAllocationFailed\",\n            option);\n        cli_wand->wand.image_info = (ImageInfo *)node->data;\n        node = (Stack *)RelinquishMagickMemory(node);\n        break;\n      }\n\n      break;\n    }\n    if (LocaleCompare(\")\",option) == 0) {\n      \/* pop images from stack *\/\n      Stack\n        *node;\n\n      node = (Stack *)cli_wand->image_list_stack;\n      if ( node == (Stack *) NULL)\n        CLIWandExceptionBreak(OptionError,\"UnbalancedParenthesis\",option);\n      cli_wand->image_list_stack = node->next;\n\n      AppendImageToList((Image **)&node->data,cli_wand->wand.images);\n      cli_wand->wand.images= (Image *)node->data;\n      node = (Stack *)RelinquishMagickMemory(node);\n\n      \/* handle respect-parenthesis - of the previous 'pushed' settings *\/\n      node = cli_wand->image_info_stack;\n      if ( node != (Stack *) NULL)\n        {\n          if (IsStringTrue(GetImageOption(\n                cli_wand->wand.image_info,\"respect-parenthesis\")) != MagickFalse)\n            option=\"}\"; \/* fall-thru so as to pop image settings too *\/\n          else\n            break;\n        }\n      else\n        break;\n      \/* fall thru to next if *\/\n    }\n    if (LocaleCompare(\"}\",option) == 0) {\n      \/* pop image_info settings from stack *\/\n      Stack\n        *node;\n\n      node = (Stack *)cli_wand->image_info_stack;\n      if ( node == (Stack *) NULL)\n        CLIWandExceptionBreak(OptionError,\"UnbalancedCurlyBraces\",option);\n      cli_wand->image_info_stack = node->next;\n\n      (void) DestroyImageInfo(cli_wand->wand.image_info);\n      cli_wand->wand.image_info = (ImageInfo *)node->data;\n      node = (Stack *)RelinquishMagickMemory(node);\n\n      GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);\n      cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);\n      cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);\n\n      break;\n    }\n      if (LocaleCompare(\"print\",option+1) == 0)\n        {\n          (void) FormatLocaleFile(stdout,\"%s\",arg1);\n          break;\n        }\n    if (LocaleCompare(\"set\",option+1) == 0)\n      {\n        \/* Settings are applied to each image in memory in turn (if any).\n           While a option: only need to be applied once globally.\n\n           NOTE: rguments have not been automatically percent expaneded\n        *\/\n\n        \/* escape the 'key' once only, using first image. *\/\n        arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);\n        if (arg1 == (char *) NULL)\n          CLIWandExceptionBreak(OptionWarning,\"InterpretPropertyFailure\",\n                option);\n\n        if (LocaleNCompare(arg1,\"registry:\",9) == 0)\n          {\n            if (IfPlusOp)\n              {\n                (void) DeleteImageRegistry(arg1+9);\n                arg1=DestroyString((char *)arg1);\n                break;\n              }\n            arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n            if (arg2 == (char *) NULL) {\n              arg1=DestroyString((char *)arg1);\n              CLIWandExceptionBreak(OptionWarning,\"InterpretPropertyFailure\",\n                    option);\n            }\n            (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);\n            arg1=DestroyString((char *)arg1);\n            arg2=DestroyString((char *)arg2);\n            break;\n          }\n        if (LocaleNCompare(arg1,\"option:\",7) == 0)\n          {\n            \/* delete equivelent artifact from all images (if any) *\/\n            if (_images != (Image *) NULL)\n              {\n                MagickResetIterator(&cli_wand->wand);\n                while (MagickNextImage(&cli_wand->wand) != MagickFalse)\n                  (void) DeleteImageArtifact(_images,arg1+7);\n                MagickResetIterator(&cli_wand->wand);\n              }\n            \/* now set\/delete the global option as needed *\/\n            \/* FUTURE: make escapes in a global 'option:' delayed *\/\n            arg2=(char *) NULL;\n            if (IfNormalOp)\n              {\n                arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n                if (arg2 == (char *) NULL)\n                  CLIWandExceptionBreak(OptionWarning,\n                       \"InterpretPropertyFailure\",option);\n              }\n            (void) SetImageOption(_image_info,arg1+7,arg2);\n            arg1=DestroyString((char *)arg1);\n            arg2=DestroyString((char *)arg2);\n            break;\n          }\n        \/* Set Artifacts\/Properties\/Attributes all images (required) *\/\n        if ( _images == (Image *) NULL )\n          CLIWandExceptArgBreak(OptionWarning,\"NoImageForProperty\",option,arg1);\n\n        MagickResetIterator(&cli_wand->wand);\n        while (MagickNextImage(&cli_wand->wand) != MagickFalse)\n          {\n            arg2=(char *) NULL;\n            if (IfNormalOp)\n              {\n                arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n                if (arg2 == (char *) NULL)\n                  CLIWandExceptionBreak(OptionWarning,\n                       \"InterpretPropertyFailure\",option);\n              }\n            if (LocaleNCompare(arg1,\"artifact:\",9) == 0)\n              (void) SetImageArtifact(_images,arg1+9,arg2);\n            else if (LocaleNCompare(arg1,\"property:\",9) == 0)\n              (void) SetImageProperty(_images,arg1+9,arg2,_exception);\n            else\n              (void) SetImageProperty(_images,arg1,arg2,_exception);\n            arg2=DestroyString((char *)arg2);\n          }\n        MagickResetIterator(&cli_wand->wand);\n        arg1=DestroyString((char *)arg1);\n        break;\n     }\n    if (LocaleCompare(\"clone\",option+1) == 0) {\n        Image\n          *new_images;\n\n        if (*option == '+')\n          arg1=AcquireString(\"-1\");\n        if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)\n          CLIWandExceptionBreak(OptionError,\"InvalidArgument\",option);\n        if ( cli_wand->image_list_stack == (Stack *) NULL)\n          CLIWandExceptionBreak(OptionError,\"UnableToCloneImage\",option);\n        new_images = (Image *)cli_wand->image_list_stack->data;\n        if (new_images == (Image *) NULL)\n          CLIWandExceptionBreak(OptionError,\"UnableToCloneImage\",option);\n        new_images=CloneImages(new_images,arg1,_exception);\n        if (new_images == (Image *) NULL)\n          CLIWandExceptionBreak(OptionError,\"NoSuchImage\",option);\n        AppendImageToList(&_images,new_images);\n        break;\n      }\n    \/*\n       Informational Operations.\n\n       Note that these do not require either a cli-wand or images!\n       Though currently a cli-wand much be provided regardless.\n    *\/\n    if (LocaleCompare(\"version\",option+1) == 0)\n      {\n        ListMagickVersion(stdout);\n        break;\n      }\n    if (LocaleCompare(\"list\",option+1) == 0) {\n      \/*\n         FUTURE: This 'switch' should really be part of MagickCore\n      *\/\n      ssize_t\n        list;\n\n      list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);\n      if ( list < 0 ) {\n        CLIWandExceptionArg(OptionError,\"UnrecognizedListType\",option,arg1);\n        break;\n      }\n      switch (list)\n      {\n        case MagickCoderOptions:\n        {\n          (void) ListCoderInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickColorOptions:\n        {\n          (void) ListColorInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickConfigureOptions:\n        {\n          (void) ListConfigureInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickDelegateOptions:\n        {\n          (void) ListDelegateInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickFontOptions:\n        {\n          (void) ListTypeInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickFormatOptions:\n          (void) ListMagickInfo((FILE *) NULL,_exception);\n          break;\n        case MagickLocaleOptions:\n          (void) ListLocaleInfo((FILE *) NULL,_exception);\n          break;\n        case MagickLogOptions:\n          (void) ListLogInfo((FILE *) NULL,_exception);\n          break;\n        case MagickMagicOptions:\n          (void) ListMagicInfo((FILE *) NULL,_exception);\n          break;\n        case MagickMimeOptions:\n          (void) ListMimeInfo((FILE *) NULL,_exception);\n          break;\n        case MagickModuleOptions:\n          (void) ListModuleInfo((FILE *) NULL,_exception);\n          break;\n        case MagickPolicyOptions:\n          (void) ListPolicyInfo((FILE *) NULL,_exception);\n          break;\n        case MagickResourceOptions:\n          (void) ListMagickResourceInfo((FILE *) NULL,_exception);\n          break;\n        case MagickThresholdOptions:\n          (void) ListThresholdMaps((FILE *) NULL,_exception);\n          break;\n        default:\n          (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,\n            _exception);\n          break;\n      }\n      break;\n    }\n\n    CLIWandException(OptionError,\"UnrecognizedOption\",option);\n\nDisableMSCWarning(4127)\n  } while (0);  \/* break to exit code. *\/\nRestoreMSCWarning\n\n  \/* clean up percent escape interpreted strings *\/\n  if (arg1 != arg1n )\n    arg1=DestroyString((char *)arg1);\n  if (arg2 != arg2n )\n    arg2=DestroyString((char *)arg2);\n\n#undef _image_info\n#undef _images\n#undef _exception\n#undef IfNormalOp\n#undef IfPlusOp\n}","target":1,"code_token_length":4109,"total_token_length":4345,"max_tokens_setting":6144}
+{"idx":439148,"func":"static MagickBooleanType WriteICONImage(const ImageInfo *image_info,\n  Image *image)\n{\n  const char\n    *option;\n\n  IconFile\n    icon_file;\n\n  IconInfo\n    icon_info;\n\n  Image\n    *images,\n    *next;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    scene;\n\n  register const IndexPacket\n    *indexes;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *q;\n\n  size_t\n    bytes_per_line,\n    imageListLength,\n    scanline_pad;\n\n  ssize_t\n    y;\n\n  unsigned char\n    bit,\n    byte,\n    *pixels;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  images=(Image *) NULL;\n  option=GetImageOption(image_info,\"icon:auto-resize\");\n  if (option != (const char *) NULL)\n    {\n      images=AutoResizeImage(image,option,&scene,&image->exception);\n      if (images == (Image *) NULL)\n        ThrowWriterException(ImageError,\"InvalidDimensions\");\n    }\n  else\n    {\n      scene=0;\n      next=image;\n      do\n      {\n        if ((image->columns > 256L) || (image->rows > 256L))\n          ThrowWriterException(ImageError,\"WidthOrHeightExceedsLimit\");\n        scene++;\n        next=SyncNextImageInList(next);\n      } while ((next != (Image *) NULL) && (image_info->adjoin != \n          MagickFalse));\n    }\n  \/*\n    Dump out a ICON header template to be properly initialized later.\n  *\/\n  (void) WriteBlobLSBShort(image,0);\n  (void) WriteBlobLSBShort(image,1);\n  (void) WriteBlobLSBShort(image,(unsigned char) scene);\n  (void) memset(&icon_file,0,sizeof(icon_file));\n  (void) memset(&icon_info,0,sizeof(icon_info));\n  scene=0;\n  next=(images != (Image *) NULL) ? images : image;\n  do\n  {\n    (void) WriteBlobByte(image,icon_file.directory[scene].width);\n    (void) WriteBlobByte(image,icon_file.directory[scene].height);\n    (void) WriteBlobByte(image,icon_file.directory[scene].colors);\n    (void) WriteBlobByte(image,icon_file.directory[scene].reserved);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].size);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].offset);\n    scene++;\n    next=SyncNextImageInList(next);\n  } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));\n  scene=0;\n  next=(images != (Image *) NULL) ? images : image;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    if ((next->columns > 255L) && (next->rows > 255L) &&\n        ((next->compression == UndefinedCompression) ||\n        (next->compression == ZipCompression)))\n      {\n        Image\n          *write_image;\n\n        ImageInfo\n          *write_info;\n\n        size_t\n          length;\n\n        unsigned char\n          *png;\n\n        write_image=CloneImage(next,0,0,MagickTrue,&image->exception);\n        if (write_image == (Image *) NULL)\n          {\n            images=DestroyImageList(images);\n            return(MagickFalse);\n          }\n        write_info=CloneImageInfo(image_info);\n        (void) CopyMagickString(write_info->magick,\"PNG\",MagickPathExtent);\n        length=0;\n\n        \/* Don't write any ancillary chunks except for gAMA *\/\n        (void) SetImageArtifact(write_image,\"png:include-chunk\",\"none,gama\");\n\n        \/* Only write PNG32 formatted PNG (32-bit RGBA), 8 bits per channel *\/\n        (void) SetImageArtifact(write_image,\"png:format\",\"png32\");\n\n        png=(unsigned char *) ImageToBlob(write_info,write_image,&length,\n          &image->exception);\n        write_image=DestroyImageList(write_image);\n        write_info=DestroyImageInfo(write_info);\n        if (png == (unsigned char *) NULL)\n          {\n            images=DestroyImageList(images);\n            return(MagickFalse);\n          }\n        icon_file.directory[scene].width=0;\n        icon_file.directory[scene].height=0;\n        icon_file.directory[scene].colors=0;\n        icon_file.directory[scene].reserved=0;\n        icon_file.directory[scene].planes=1;\n        icon_file.directory[scene].bits_per_pixel=32;\n        icon_file.directory[scene].size=(size_t) length;\n        icon_file.directory[scene].offset=(size_t) TellBlob(image);\n        (void) WriteBlob(image,(size_t) length,png);\n        png=(unsigned char *) RelinquishMagickMemory(png);\n      }\n    else\n      {\n        \/*\n          Initialize ICON raster file header.\n        *\/\n        (void) TransformImageColorspace(image,sRGBColorspace);\n        icon_info.file_size=14+12+28;\n        icon_info.offset_bits=icon_info.file_size;\n        icon_info.compression=BI_RGB;\n        if ((next->storage_class != DirectClass) && (next->colors > 256))\n          (void) SetImageStorageClass(next,DirectClass);\n        if (next->storage_class == DirectClass)\n          {\n            \/*\n              Full color ICON raster.\n            *\/\n            icon_info.number_colors=0;\n            icon_info.bits_per_pixel=32;\n            icon_info.compression=(size_t) BI_RGB;\n          }\n        else\n          {\n            size_t\n              one;\n\n            \/*\n              Colormapped ICON raster.\n            *\/\n            icon_info.bits_per_pixel=8;\n            if (next->colors <= 256)\n              icon_info.bits_per_pixel=8;\n            if (next->colors <= 16)\n              icon_info.bits_per_pixel=4;\n            if (next->colors <= 2)\n              icon_info.bits_per_pixel=1;\n            one=1;\n            icon_info.number_colors=one << icon_info.bits_per_pixel;\n            if (icon_info.number_colors < next->colors)\n              {\n                (void) SetImageStorageClass(next,DirectClass);\n                icon_info.number_colors=0;\n                icon_info.bits_per_pixel=(unsigned short) 24;\n                icon_info.compression=(size_t) BI_RGB;\n              }\n            else\n              {\n                size_t\n                  one;\n\n                one=1;\n                icon_info.file_size+=3*(one << icon_info.bits_per_pixel);\n                icon_info.offset_bits+=3*(one << icon_info.bits_per_pixel);\n                icon_info.file_size+=(one << icon_info.bits_per_pixel);\n                icon_info.offset_bits+=(one << icon_info.bits_per_pixel);\n              }\n          }\n        bytes_per_line=(((next->columns*icon_info.bits_per_pixel)+31) &\n          ~31) >> 3;\n        icon_info.ba_offset=0;\n        icon_info.width=(ssize_t) next->columns;\n        icon_info.height=(ssize_t) next->rows;\n        icon_info.planes=1;\n        icon_info.image_size=bytes_per_line*next->rows;\n        icon_info.size=40;\n        icon_info.size+=(4*icon_info.number_colors);\n        icon_info.size+=icon_info.image_size;\n        icon_info.size+=(((icon_info.width+31) & ~31) >> 3)*icon_info.height;\n        icon_info.file_size+=icon_info.image_size;\n        icon_info.x_pixels=0;\n        icon_info.y_pixels=0;\n        switch (next->units)\n        {\n          case UndefinedResolution:\n          case PixelsPerInchResolution:\n          {\n            icon_info.x_pixels=(size_t) (100.0*next->x_resolution\/2.54);\n            icon_info.y_pixels=(size_t) (100.0*next->y_resolution\/2.54);\n            break;\n          }\n          case PixelsPerCentimeterResolution:\n          {\n            icon_info.x_pixels=(size_t) (100.0*next->x_resolution);\n            icon_info.y_pixels=(size_t) (100.0*next->y_resolution);\n            break;\n          }\n        }\n        icon_info.colors_important=icon_info.number_colors;\n        \/*\n          Convert MIFF to ICON raster pixels.\n        *\/\n        pixels=(unsigned char *) AcquireQuantumMemory((size_t)\n          icon_info.image_size,sizeof(*pixels));\n        if (pixels == (unsigned char *) NULL)\n          {\n            images=DestroyImageList(images);\n            ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n        (void) memset(pixels,0,(size_t) icon_info.image_size);\n        switch (icon_info.bits_per_pixel)\n        {\n          case 1:\n          {\n            size_t\n              bit,\n              byte;\n\n            \/*\n              Convert PseudoClass image to a ICON monochrome image.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              indexes=GetVirtualIndexQueue(next);\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              bit=0;\n              byte=0;\n              for (x=0; x < (ssize_t) next->columns; x++)\n              {\n                byte<<=1;\n                byte|=GetPixelIndex(indexes+x) != 0 ? 0x01 : 0x00;\n                bit++;\n                if (bit == 8)\n                  {\n                    *q++=(unsigned char) byte;\n                    bit=0;\n                    byte=0;\n                  }\n               }\n              if (bit != 0)\n                *q++=(unsigned char) (byte << (8-bit));\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n          case 4:\n          {\n            size_t\n              nibble,\n              byte;\n\n            \/*\n              Convert PseudoClass image to a ICON monochrome image.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              indexes=GetVirtualIndexQueue(next);\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              nibble=0;\n              byte=0;\n              for (x=0; x < (ssize_t) next->columns; x++)\n              {\n                byte<<=4;\n                byte|=((size_t) GetPixelIndex(indexes+x) & 0x0f);\n                nibble++;\n                if (nibble == 2)\n                  {\n                    *q++=(unsigned char) byte;\n                    nibble=0;\n                    byte=0;\n                  }\n               }\n              if (nibble != 0)\n                *q++=(unsigned char) (byte << 4);\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n          case 8:\n          {\n            \/*\n              Convert PseudoClass packet to ICON pixel.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              indexes=GetVirtualIndexQueue(next);\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) next->columns; x++)\n                *q++=(unsigned char) GetPixelIndex(indexes+x);\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n          case 24:\n          case 32:\n          {\n            \/*\n              Convert DirectClass packet to ICON BGR888 or BGRA8888 pixel.\n            *\/\n            for (y=0; y < (ssize_t) next->rows; y++)\n            {\n              p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n              if (p == (const PixelPacket *) NULL)\n                break;\n              q=pixels+(next->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) next->columns; x++)\n              {\n                *q++=ScaleQuantumToChar(GetPixelBlue(p));\n                *q++=ScaleQuantumToChar(GetPixelGreen(p));\n                *q++=ScaleQuantumToChar(GetPixelRed(p));\n                if (next->matte == MagickFalse)\n                  *q++=ScaleQuantumToChar(QuantumRange);\n                else\n                  *q++=ScaleQuantumToChar(GetPixelAlpha(p));\n                p++;\n              }\n              if (icon_info.bits_per_pixel == 24)\n                for (x=3L*(ssize_t) next->columns; x < (ssize_t) bytes_per_line; x++)\n                  *q++=0x00;\n              if (next->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(next,SaveImageTag,y,next->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n            break;\n          }\n        }\n        \/*\n          Write 40-byte version 3+ bitmap header.\n        *\/\n        icon_file.directory[scene].width=(unsigned char) icon_info.width;\n        icon_file.directory[scene].height=(unsigned char) icon_info.height;\n        icon_file.directory[scene].colors=(unsigned char)\n          icon_info.number_colors;\n        icon_file.directory[scene].reserved=0;\n        icon_file.directory[scene].planes=icon_info.planes;\n        icon_file.directory[scene].bits_per_pixel=icon_info.bits_per_pixel;\n        icon_file.directory[scene].size=icon_info.size;\n        icon_file.directory[scene].offset=(size_t) TellBlob(image);\n        (void) WriteBlobLSBLong(image,(unsigned int) 40);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.width);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.height*2);\n        (void) WriteBlobLSBShort(image,icon_info.planes);\n        (void) WriteBlobLSBShort(image,icon_info.bits_per_pixel);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.compression);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.image_size);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.x_pixels);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.y_pixels);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.number_colors);\n        (void) WriteBlobLSBLong(image,(unsigned int) icon_info.colors_important);\n        if (next->storage_class == PseudoClass)\n          {\n            unsigned char\n              *icon_colormap;\n\n            \/*\n              Dump colormap to file.\n            *\/\n            icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n              (1UL << icon_info.bits_per_pixel),4UL*sizeof(*icon_colormap));\n            if (icon_colormap == (unsigned char *) NULL)\n              {\n                images=DestroyImageList(images);\n                ThrowWriterException(ResourceLimitError,\n                  \"MemoryAllocationFailed\");\n              }\n            q=icon_colormap;\n            for (i=0; i < (ssize_t) next->colors; i++)\n            {\n              *q++=ScaleQuantumToChar(next->colormap[i].blue);\n              *q++=ScaleQuantumToChar(next->colormap[i].green);\n              *q++=ScaleQuantumToChar(next->colormap[i].red);\n              *q++=(unsigned char) 0x0;\n            }\n            for ( ; i < (ssize_t) (1UL << icon_info.bits_per_pixel); i++)\n            {\n              *q++=(unsigned char) 0x00;\n              *q++=(unsigned char) 0x00;\n              *q++=(unsigned char) 0x00;\n              *q++=(unsigned char) 0x00;\n            }\n            (void) WriteBlob(image,(size_t) (4UL*(1UL <<\n              icon_info.bits_per_pixel)),icon_colormap);\n            icon_colormap=(unsigned char *) RelinquishMagickMemory(\n              icon_colormap);\n          }\n        (void) WriteBlob(image,(size_t) icon_info.image_size,pixels);\n        pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n        \/*\n          Write matte mask.\n        *\/\n        scanline_pad=(((next->columns+31) & ~31)-next->columns) >> 3;\n        for (y=((ssize_t) next->rows - 1); y >= 0; y--)\n        {\n          p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);\n          if (p == (const PixelPacket *) NULL)\n            break;\n          bit=0;\n          byte=0;\n          for (x=0; x < (ssize_t) next->columns; x++)\n          {\n            byte<<=1;\n            if ((next->matte != MagickFalse) &&\n                (GetPixelOpacity(p) == (Quantum) TransparentOpacity))\n              byte|=0x01;\n            bit++;\n            if (bit == 8)\n              {\n                (void) WriteBlobByte(image,(unsigned char) byte);\n                bit=0;\n                byte=0;\n              }\n            p++;\n          }\n          if (bit != 0)\n            (void) WriteBlobByte(image,(unsigned char) (byte << (8-bit)));\n          for (i=0; i < (ssize_t) scanline_pad; i++)\n            (void) WriteBlobByte(image,(unsigned char) 0);\n        }\n      }\n    if (GetNextImageInList(next) == (Image *) NULL)\n      break;\n    status=SetImageProgress(next,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n    next=SyncNextImageInList(next);\n  } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));\n  offset=SeekBlob(image,0,SEEK_SET);\n  (void) offset;\n  (void) WriteBlobLSBShort(image,0);\n  (void) WriteBlobLSBShort(image,1);\n  (void) WriteBlobLSBShort(image,(unsigned short) (scene+1));\n  scene=0;\n  next=(images != (Image *) NULL) ? images : image;\n  do\n  {\n    (void) WriteBlobByte(image,icon_file.directory[scene].width);\n    (void) WriteBlobByte(image,icon_file.directory[scene].height);\n    (void) WriteBlobByte(image,icon_file.directory[scene].colors);\n    (void) WriteBlobByte(image,icon_file.directory[scene].reserved);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].planes);\n    (void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].size);\n    (void) WriteBlobLSBLong(image,(unsigned int)\n      icon_file.directory[scene].offset);\n    scene++;\n    next=SyncNextImageInList(next);\n  } while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));\n  (void) CloseBlob(image);\n  images=DestroyImageList(images);\n  return(MagickTrue);\n}","target":0,"code_token_length":4498,"total_token_length":4734,"max_tokens_setting":6144}
+{"idx":513334,"func":"best_access_path(JOIN      *join,\n                 JOIN_TAB  *s,\n                 table_map remaining_tables,\n                 const POSITION *join_positions,\n                 uint      idx,\n                 bool      disable_jbuf,\n                 double    record_count,\n                 POSITION *pos,\n                 POSITION *loose_scan_pos)\n{\n  THD *thd= join->thd;\n  uint use_cond_selectivity= thd->variables.optimizer_use_condition_selectivity;\n  KEYUSE *best_key=         0;\n  uint best_max_key_part=   0;\n  my_bool found_constraint= 0;\n  double best=              DBL_MAX;\n  double best_time=         DBL_MAX;\n  double records=           DBL_MAX;\n  table_map best_ref_depends_map= 0;\n  double tmp;\n  ha_rows rec;\n  bool best_uses_jbuf= FALSE;\n  MY_BITMAP *eq_join_set= &s->table->eq_join_set;\n  KEYUSE *hj_start_key= 0;\n\n  disable_jbuf= disable_jbuf || idx == join->const_tables;  \n\n  Loose_scan_opt loose_scan_opt;\n  DBUG_ENTER(\"best_access_path\");\n  \n  bitmap_clear_all(eq_join_set);\n\n  loose_scan_opt.init(join, s, remaining_tables);\n  \n  if (s->keyuse)\n  {                                            \/* Use key if possible *\/\n    KEYUSE *keyuse;\n    KEYUSE *start_key=0;\n    TABLE *table= s->table;\n    double best_records= DBL_MAX;\n    uint max_key_part=0;\n\n    \/* Test how we can use keys *\/\n    rec= s->records\/MATCHING_ROWS_IN_OTHER_TABLE;  \/\/ Assumed records\/key\n    for (keyuse=s->keyuse ; keyuse->table == table ;)\n    {\n      KEY *keyinfo;\n      ulong key_flags;\n      uint key_parts;\n      key_part_map found_part= 0;\n      table_map found_ref= 0;\n      uint key= keyuse->key;\n      bool ft_key=  (keyuse->keypart == FT_KEYPART);\n      \/* Bitmap of keyparts where the ref access is over 'keypart=const': *\/\n      key_part_map const_part= 0;\n      \/* The or-null keypart in ref-or-null access: *\/\n      key_part_map ref_or_null_part= 0;\n      if (is_hash_join_key_no(key))\n      {\n        \/* \n          Hash join as any join employing join buffer can be used to join\n          only those tables that are joined after the first non const table\n\t*\/  \n        if (!(remaining_tables & keyuse->used_tables) &&\n            idx > join->const_tables)\n        {\n          if (!hj_start_key)\n            hj_start_key= keyuse;\n          bitmap_set_bit(eq_join_set, keyuse->keypart);\n        }\n        keyuse++;\n        continue;\n      }\n\n      keyinfo= table->key_info+key;\n      key_parts= table->actual_n_key_parts(keyinfo);\n      key_flags= table->actual_key_flags(keyinfo);\n\n      \/* Calculate how many key segments of the current key we can use *\/\n      start_key= keyuse;\n\n      loose_scan_opt.next_ref_key();\n      DBUG_PRINT(\"info\", (\"Considering ref access on key %s\",\n                          keyuse->table->key_info[keyuse->key].name));\n\n      do \/* For each keypart *\/\n      {\n        uint keypart= keyuse->keypart;\n        table_map best_part_found_ref= 0;\n        double best_prev_record_reads= DBL_MAX;\n        \n        do \/* For each way to access the keypart *\/\n        {\n          \/*\n            if 1. expression doesn't refer to forward tables\n               2. we won't get two ref-or-null's\n          *\/\n          if (!(remaining_tables & keyuse->used_tables) &&\n              s->access_from_tables_is_allowed(keyuse->used_tables,\n                                               join->sjm_lookup_tables) &&\n              !(ref_or_null_part && (keyuse->optimize &\n                                     KEY_OPTIMIZE_REF_OR_NULL)))\n          {\n            found_part|= keyuse->keypart_map;\n            if (!(keyuse->used_tables & ~join->const_table_map))\n              const_part|= keyuse->keypart_map;\n\n            double tmp2= prev_record_reads(join_positions, idx,\n                                           (found_ref | keyuse->used_tables));\n            if (tmp2 < best_prev_record_reads)\n            {\n              best_part_found_ref= keyuse->used_tables & ~join->const_table_map;\n              best_prev_record_reads= tmp2;\n            }\n            if (rec > keyuse->ref_table_rows)\n              rec= keyuse->ref_table_rows;\n\t    \/*\n\t      If there is one 'key_column IS NULL' expression, we can\n\t      use this ref_or_null optimisation of this field\n\t    *\/\n            if (keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL)\n              ref_or_null_part |= keyuse->keypart_map;\n          }\n          loose_scan_opt.add_keyuse(remaining_tables, keyuse);\n          keyuse++;\n        } while (keyuse->table == table && keyuse->key == key &&\n                 keyuse->keypart == keypart);\n\tfound_ref|= best_part_found_ref;\n      } while (keyuse->table == table && keyuse->key == key);\n\n      \/*\n        Assume that that each key matches a proportional part of table.\n      *\/\n      if (!found_part && !ft_key && !loose_scan_opt.have_a_case())\n        continue;                               \/\/ Nothing usable found\n\n      if (rec < MATCHING_ROWS_IN_OTHER_TABLE)\n        rec= MATCHING_ROWS_IN_OTHER_TABLE;      \/\/ Fix for small tables\n\n      \/*\n        ft-keys require special treatment\n      *\/\n      if (ft_key)\n      {\n        \/*\n          Really, there should be records=0.0 (yes!)\n          but 1.0 would be probably safer\n        *\/\n        tmp= prev_record_reads(join_positions, idx, found_ref);\n        records= 1.0;\n      }\n      else\n      {\n        found_constraint= MY_TEST(found_part);\n        loose_scan_opt.check_ref_access_part1(s, key, start_key, found_part);\n\n        \/* Check if we found full key *\/\n        if (found_part == PREV_BITS(uint, key_parts) &&\n            !ref_or_null_part)\n        {                                         \/* use eq key *\/\n          max_key_part= (uint) ~0;\n          if ((key_flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME ||\n              MY_TEST(key_flags & HA_EXT_NOSAME))\n          {\n            tmp = prev_record_reads(join_positions, idx, found_ref);\n            records=1.0;\n          }\n          else\n          {\n            if (!found_ref)\n            {                                     \/* We found a const key *\/\n              \/*\n                ReuseRangeEstimateForRef-1:\n                We get here if we've found a ref(const) (c_i are constants):\n                  \"(keypart1=c1) AND ... AND (keypartN=cN)\"   [ref_const_cond]\n                \n                If range optimizer was able to construct a \"range\" \n                access on this index, then its condition \"quick_cond\" was\n                eqivalent to ref_const_cond (*), and we can re-use E(#rows)\n                from the range optimizer.\n                \n                Proof of (*): By properties of range and ref optimizers \n                quick_cond will be equal or tighther than ref_const_cond. \n                ref_const_cond already covers \"smallest\" possible interval - \n                a singlepoint interval over all keyparts. Therefore, \n                quick_cond is equivalent to ref_const_cond (if it was an \n                empty interval we wouldn't have got here).\n              *\/\n              if (table->quick_keys.is_set(key))\n                records= (double) table->quick_rows[key];\n              else\n              {\n                \/* quick_range couldn't use key! *\/\n                records= (double) s->records\/rec;\n              }\n            }\n            else\n            {\n              if (!(records= keyinfo->actual_rec_per_key(key_parts-1)))\n              {                                   \/* Prefer longer keys *\/\n                records=\n                  ((double) s->records \/ (double) rec *\n                   (1.0 +\n                    ((double) (table->s->max_key_length-keyinfo->key_length) \/\n                     (double) table->s->max_key_length)));\n                if (records < 2.0)\n                  records=2.0;               \/* Can't be as good as a unique *\/\n              }\n              \/*\n                ReuseRangeEstimateForRef-2:  We get here if we could not reuse\n                E(#rows) from range optimizer. Make another try:\n                \n                If range optimizer produced E(#rows) for a prefix of the ref\n                access we're considering, and that E(#rows) is lower then our\n                current estimate, make an adjustment. The criteria of when we\n                can make an adjustment is a special case of the criteria used\n                in ReuseRangeEstimateForRef-3.\n              *\/\n              if (table->quick_keys.is_set(key) &&\n                  (const_part &\n                    (((key_part_map)1 << table->quick_key_parts[key])-1)) ==\n                  (((key_part_map)1 << table->quick_key_parts[key])-1) &&\n                  table->quick_n_ranges[key] == 1 &&\n                  records > (double) table->quick_rows[key])\n              {\n                records= (double) table->quick_rows[key];\n              }\n            }\n            \/* Limit the number of matched rows *\/\n            tmp= records;\n            set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);\n            if (table->covering_keys.is_set(key))\n              tmp= table->file->keyread_time(key, 1, (ha_rows) tmp);\n            else\n              tmp= table->file->read_time(key, 1,\n                                          (ha_rows) MY_MIN(tmp,s->worst_seeks));\n            tmp= COST_MULT(tmp, record_count);\n          }\n        }\n        else\n        {\n          \/*\n            Use as much key-parts as possible and a uniq key is better\n            than a not unique key\n            Set tmp to (previous record count) * (records \/ combination)\n          *\/\n          if ((found_part & 1) &&\n              (!(table->file->index_flags(key, 0, 0) & HA_ONLY_WHOLE_INDEX) ||\n               found_part == PREV_BITS(uint,keyinfo->user_defined_key_parts)))\n          {\n            max_key_part= max_part_bit(found_part);\n            \/*\n              ReuseRangeEstimateForRef-3:\n              We're now considering a ref[or_null] access via\n              (t.keypart1=e1 AND ... AND t.keypartK=eK) [ OR  \n              (same-as-above but with one cond replaced \n               with \"t.keypart_i IS NULL\")]  (**)\n              \n              Try re-using E(#rows) from \"range\" optimizer:\n              We can do so if \"range\" optimizer used the same intervals as\n              in (**). The intervals used by range optimizer may be not \n              available at this point (as \"range\" access might have choosen to\n              create quick select over another index), so we can't compare\n              them to (**). We'll make indirect judgements instead.\n              The sufficient conditions for re-use are:\n              (C1) All e_i in (**) are constants, i.e. found_ref==FALSE. (if\n                   this is not satisfied we have no way to know which ranges\n                   will be actually scanned by 'ref' until we execute the \n                   join)\n              (C2) max #key parts in 'range' access == K == max_key_part (this\n                   is apparently a necessary requirement)\n\n              We also have a property that \"range optimizer produces equal or \n              tighter set of scan intervals than ref(const) optimizer\". Each\n              of the intervals in (**) are \"tightest possible\" intervals when \n              one limits itself to using keyparts 1..K (which we do in #2).              \n              From here it follows that range access used either one, or\n              both of the (I1) and (I2) intervals:\n              \n               (t.keypart1=c1 AND ... AND t.keypartK=eK)  (I1) \n               (same-as-above but with one cond replaced  \n                with \"t.keypart_i IS NULL\")               (I2)\n\n              The remaining part is to exclude the situation where range\n              optimizer used one interval while we're considering\n              ref-or-null and looking for estimate for two intervals. This\n              is done by last limitation:\n\n              (C3) \"range optimizer used (have ref_or_null?2:1) intervals\"\n            *\/\n            if (table->quick_keys.is_set(key) && !found_ref &&          \/\/(C1)\n                table->quick_key_parts[key] == max_key_part &&          \/\/(C2)\n                table->quick_n_ranges[key] == 1 + MY_TEST(ref_or_null_part)) \/\/(C3)\n            {\n              tmp= records= (double) table->quick_rows[key];\n            }\n            else\n            {\n              \/* Check if we have statistic about the distribution *\/\n              if ((records= keyinfo->actual_rec_per_key(max_key_part-1)))\n              {\n                \/* \n                  Fix for the case where the index statistics is too\n                  optimistic: If \n                  (1) We're considering ref(const) and there is quick select\n                      on the same index, \n                  (2) and that quick select uses more keyparts (i.e. it will\n                      scan equal\/smaller interval then this ref(const))\n                  (3) and E(#rows) for quick select is higher then our\n                      estimate,\n                  Then \n                    We'll use E(#rows) from quick select.\n\n                  Q: Why do we choose to use 'ref'? Won't quick select be\n                  cheaper in some cases ?\n                  TODO: figure this out and adjust the plan choice if needed.\n                *\/\n                if (!found_ref && table->quick_keys.is_set(key) &&    \/\/ (1)\n                    table->quick_key_parts[key] > max_key_part &&     \/\/ (2)\n                    records < (double)table->quick_rows[key])         \/\/ (3)\n                  records= (double)table->quick_rows[key];\n\n                tmp= records;\n              }\n              else\n              {\n                \/*\n                  Assume that the first key part matches 1% of the file\n                  and that the whole key matches 10 (duplicates) or 1\n                  (unique) records.\n                  Assume also that more key matches proportionally more\n                  records\n                  This gives the formula:\n                  records = (x * (b-a) + a*c-b)\/(c-1)\n\n                  b = records matched by whole key\n                  a = records matched by first key part (1% of all records?)\n                  c = number of key parts in key\n                  x = used key parts (1 <= x <= c)\n                *\/\n                double rec_per_key;\n                if (!(rec_per_key=(double)\n                      keyinfo->rec_per_key[keyinfo->user_defined_key_parts-1]))\n                  rec_per_key=(double) s->records\/rec+1;\n\n                if (!s->records)\n                  tmp = 0;\n                else if (rec_per_key\/(double) s->records >= 0.01)\n                  tmp = rec_per_key;\n                else\n                {\n                  double a=s->records*0.01;\n                  if (keyinfo->user_defined_key_parts > 1)\n                    tmp= (max_key_part * (rec_per_key - a) +\n                          a*keyinfo->user_defined_key_parts - rec_per_key)\/\n                         (keyinfo->user_defined_key_parts-1);\n                  else\n                    tmp= a;\n                  set_if_bigger(tmp,1.0);\n                }\n                records = (ulong) tmp;\n              }\n\n              if (ref_or_null_part)\n              {\n                \/* We need to do two key searches to find key *\/\n                tmp *= 2.0;\n                records *= 2.0;\n              }\n\n              \/*\n                ReuseRangeEstimateForRef-4:  We get here if we could not reuse\n                E(#rows) from range optimizer. Make another try:\n                \n                If range optimizer produced E(#rows) for a prefix of the ref \n                access we're considering, and that E(#rows) is lower then our\n                current estimate, make the adjustment.\n\n                The decision whether we can re-use the estimate from the range\n                optimizer is the same as in ReuseRangeEstimateForRef-3,\n                applied to first table->quick_key_parts[key] key parts.\n              *\/\n              if (table->quick_keys.is_set(key) &&\n                  table->quick_key_parts[key] <= max_key_part &&\n                  const_part &\n                    ((key_part_map)1 << table->quick_key_parts[key]) &&\n                  table->quick_n_ranges[key] == 1 + MY_TEST(ref_or_null_part &\n                                                            const_part) &&\n                  records > (double) table->quick_rows[key])\n              {\n                tmp= records= (double) table->quick_rows[key];\n              }\n            }\n\n            \/* Limit the number of matched rows *\/\n            set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);\n            if (table->covering_keys.is_set(key))\n              tmp= table->file->keyread_time(key, 1, (ha_rows) tmp);\n            else\n              tmp= table->file->read_time(key, 1,\n                                          (ha_rows) MY_MIN(tmp,s->worst_seeks));\n            tmp= COST_MULT(tmp, record_count);\n          }\n          else\n            tmp= best_time;                     \/\/ Do nothing\n        }\n\n        tmp= COST_ADD(tmp, s->startup_cost);\n        loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp,\n                                              found_ref);\n      } \/* not ft_key *\/\n      if (tmp + 0.0001 < best_time - records\/(double) TIME_FOR_COMPARE)\n      {\n        best_time= COST_ADD(tmp, records\/(double) TIME_FOR_COMPARE);\n        best= tmp;\n        best_records= records;\n        best_key= start_key;\n        best_max_key_part= max_key_part;\n        best_ref_depends_map= found_ref;\n      }\n    } \/* for each key *\/\n    records= best_records;\n  }\n\n  \/* \n    If there is no key to access the table, but there is an equi-join\n    predicate connecting the table with the privious tables then we\n    consider the possibility of using hash join.\n    We need also to check that:\n    (1) s is inner table of semi-join -> join cache is allowed for semijoins\n    (2) s is inner table of outer join -> join cache is allowed for outer joins\n  *\/  \n  if (idx > join->const_tables && best_key == 0 &&\n      (join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT) &&\n      join->max_allowed_join_cache_level > 2 &&\n     !bitmap_is_clear_all(eq_join_set) &&  !disable_jbuf &&\n      (!s->emb_sj_nest ||                     \n       join->allowed_semijoin_with_cache) &&    \/\/ (1)\n      (!(s->table->map & join->outer_join) ||\n       join->allowed_outer_join_with_cache))    \/\/ (2)\n  {\n    double join_sel= 0.1;\n    \/* Estimate the cost of  the hash join access to the table *\/\n    double rnd_records= matching_candidates_in_table(s, found_constraint,\n                                                     use_cond_selectivity);\n\n    tmp= s->quick ? s->quick->read_time : s->scan_time();\n    double cmp_time= (s->records - rnd_records)\/(double) TIME_FOR_COMPARE;\n    tmp= COST_ADD(tmp, cmp_time);\n\n    \/* We read the table as many times as join buffer becomes full. *\/\n\n    double refills= (1.0 + floor((double) cache_record_length(join,idx) *\n                           record_count \/\n\t\t\t   (double) thd->variables.join_buff_size));\n    tmp= COST_MULT(tmp, refills);\n    best_time= COST_ADD(tmp,\n                        COST_MULT((record_count*join_sel) \/ TIME_FOR_COMPARE,\n                                  rnd_records));\n    best= tmp;\n    records= rnd_records;\n    best_key= hj_start_key;\n    best_ref_depends_map= 0;\n    best_uses_jbuf= TRUE;\n   }\n\n  \/*\n    Don't test table scan if it can't be better.\n    Prefer key lookup if we would use the same key for scanning.\n\n    Don't do a table scan on InnoDB tables, if we can read the used\n    parts of the row from any of the used index.\n    This is because table scans uses index and we would not win\n    anything by using a table scan.\n\n    A word for word translation of the below if-statement in sergefp's\n    understanding: we check if we should use table scan if:\n    (1) The found 'ref' access produces more records than a table scan\n        (or index scan, or quick select), or 'ref' is more expensive than\n        any of them.\n    (2) This doesn't hold: the best way to perform table scan is to to perform\n        'range' access using index IDX, and the best way to perform 'ref' \n        access is to use the same index IDX, with the same or more key parts.\n        (note: it is not clear how this rule is\/should be extended to \n        index_merge quick selects). Also if we have a hash join we prefer that\n        over a table scan\n    (3) See above note about InnoDB.\n    (4) NOT (\"FORCE INDEX(...)\" is used for table and there is 'ref' access\n             path, but there is no quick select)\n        If the condition in the above brackets holds, then the only possible\n        \"table scan\" access method is ALL\/index (there is no quick select).\n        Since we have a 'ref' access path, and FORCE INDEX instructs us to\n        choose it over ALL\/index, there is no need to consider a full table\n        scan.\n    (5) Non-flattenable semi-joins: don't consider doing a scan of temporary\n        table if we had an option to make lookups into it. In real-world cases,\n        lookups are cheaper than full scans, but when the table is small, they\n        can be [considered to be] more expensive, which causes lookups not to \n        be used for cases with small datasets, which is annoying.\n  *\/\n  if ((records >= s->found_records || best > s->read_time) &&            \/\/ (1)\n      !(best_key && best_key->key == MAX_KEY) &&                         \/\/ (2)\n      !(s->quick && best_key && s->quick->index == best_key->key &&      \/\/ (2)\n        best_max_key_part >= s->table->quick_key_parts[best_key->key]) &&\/\/ (2)\n      !((s->table->file->ha_table_flags() & HA_TABLE_SCAN_ON_INDEX) &&   \/\/ (3)\n        ! s->table->covering_keys.is_clear_all() && best_key && !s->quick) &&\/\/ (3)\n      !(s->table->force_index && best_key && !s->quick) &&               \/\/ (4)\n      !(best_key && s->table->pos_in_table_list->jtbm_subselect))        \/\/ (5)\n  {                                             \/\/ Check full join\n    double rnd_records= matching_candidates_in_table(s, found_constraint,\n                                                      use_cond_selectivity);\n\n    \/*\n      Range optimizer never proposes a RANGE if it isn't better\n      than FULL: so if RANGE is present, it's always preferred to FULL.\n      Here we estimate its cost.\n    *\/\n\n    if (s->quick)\n    {\n      \/*\n        For each record we:\n        - read record range through 'quick'\n        - skip rows which does not satisfy WHERE constraints\n        TODO: \n        We take into account possible use of join cache for ALL\/index\n        access (see first else-branch below), but we don't take it into \n        account here for range\/index_merge access. Find out why this is so.\n      *\/\n      double cmp_time= (s->found_records - rnd_records)\/(double) TIME_FOR_COMPARE;\n      tmp= COST_MULT(record_count,\n                     COST_ADD(s->quick->read_time, cmp_time));\n\n      loose_scan_opt.check_range_access(join, idx, s->quick);\n    }\n    else\n    {\n      \/* Estimate cost of reading table. *\/\n      if (s->table->force_index && !best_key) \/\/ index scan\n        tmp= s->table->file->read_time(s->ref.key, 1, s->records);\n      else \/\/ table scan\n        tmp= s->scan_time();\n\n      if ((s->table->map & join->outer_join) || disable_jbuf)     \/\/ Can't use join cache\n      {\n        \/*\n          For each record we have to:\n          - read the whole table record \n          - skip rows which does not satisfy join condition\n        *\/\n        double cmp_time= (s->records - rnd_records)\/(double) TIME_FOR_COMPARE;\n        tmp= COST_MULT(record_count, COST_ADD(tmp,cmp_time));\n      }\n      else\n      {\n        double refills= (1.0 + floor((double) cache_record_length(join,idx) *\n                        (record_count \/\n                         (double) thd->variables.join_buff_size)));\n        tmp= COST_MULT(tmp, refills);\n        \/* \n            We don't make full cartesian product between rows in the scanned\n           table and existing records because we skip all rows from the\n           scanned table, which does not satisfy join condition when \n           we read the table (see flush_cached_records for details). Here we\n           take into account cost to read and skip these records.\n        *\/\n        double cmp_time= (s->records - rnd_records)\/(double) TIME_FOR_COMPARE;\n        tmp= COST_ADD(tmp, cmp_time);\n      }\n    }\n\n    tmp += s->startup_cost;\n    \/*\n      We estimate the cost of evaluating WHERE clause for found records\n      as record_count * rnd_records \/ TIME_FOR_COMPARE. This cost plus\n      tmp give us total cost of using TABLE SCAN\n    *\/\n    if (best == DBL_MAX ||\n        COST_ADD(tmp, record_count\/(double) TIME_FOR_COMPARE*rnd_records) <\n         (best_key->is_for_hash_join() ? best_time :\n          COST_ADD(best, record_count\/(double) TIME_FOR_COMPARE*records)))\n    {\n      \/*\n        If the table has a range (s->quick is set) make_join_select()\n        will ensure that this will be used\n      *\/\n      best= tmp;\n      records= rnd_records;\n      best_key= 0;\n      \/* range\/index_merge\/ALL\/index access method are \"independent\", so: *\/\n      best_ref_depends_map= 0;\n      best_uses_jbuf= MY_TEST(!disable_jbuf && !((s->table->map &\n                                                  join->outer_join)));\n    }\n  }\n\n  \/* Update the cost information for the current partial plan *\/\n  pos->records_read= records;\n  pos->read_time=    best;\n  pos->key=          best_key;\n  pos->table=        s;\n  pos->ref_depend_map= best_ref_depends_map;\n  pos->loosescan_picker.loosescan_key= MAX_KEY;\n  pos->use_join_buffer= best_uses_jbuf;\n   \n  loose_scan_opt.save_to_position(s, loose_scan_pos);\n\n  if (!best_key &&\n      idx == join->const_tables &&\n      s->table == join->sort_by_table &&\n      join->unit->select_limit_cnt >= records)\n    join->sort_by_table= (TABLE*) 1;  \/\/ Must use temporary table\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":5882,"total_token_length":6118,"max_tokens_setting":6144}
+{"idx":252298,"func":"size_t SaveEXRImageToMemory(const EXRImage *exr_image,\n                            const EXRHeader *exr_header,\n                            unsigned char **memory_out, const char **err) {\n  if (exr_image == NULL || memory_out == NULL ||\n      exr_header->compression_type < 0) {\n    tinyexr::SetErrorMessage(\"Invalid argument for SaveEXRImageToMemory\", err);\n    return 0;\n  }\n\n#if !TINYEXR_USE_PIZ\n  if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {\n    tinyexr::SetErrorMessage(\"PIZ compression is not supported in this build\",\n                             err);\n    return 0;\n  }\n#endif\n\n#if !TINYEXR_USE_ZFP\n  if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {\n    tinyexr::SetErrorMessage(\"ZFP compression is not supported in this build\",\n                             err);\n    return 0;\n  }\n#endif\n\n#if TINYEXR_USE_ZFP\n  for (size_t i = 0; i < static_cast<size_t>(exr_header->num_channels); i++) {\n    if (exr_header->requested_pixel_types[i] != TINYEXR_PIXELTYPE_FLOAT) {\n      tinyexr::SetErrorMessage(\"Pixel type must be FLOAT for ZFP compression\",\n                               err);\n      return 0;\n    }\n  }\n#endif\n\n  std::vector<unsigned char> memory;\n\n  \/\/ Header\n  {\n    const char header[] = {0x76, 0x2f, 0x31, 0x01};\n    memory.insert(memory.end(), header, header + 4);\n  }\n\n  \/\/ Version, scanline.\n  {\n    char marker[] = {2, 0, 0, 0};\n    \/* @todo\n    if (exr_header->tiled) {\n      marker[1] |= 0x2;\n    }\n    if (exr_header->long_name) {\n      marker[1] |= 0x4;\n    }\n    if (exr_header->non_image) {\n      marker[1] |= 0x8;\n    }\n    if (exr_header->multipart) {\n      marker[1] |= 0x10;\n    }\n    *\/\n    memory.insert(memory.end(), marker, marker + 4);\n  }\n\n  int num_scanlines = 1;\n  if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) {\n    num_scanlines = 16;\n  } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {\n    num_scanlines = 32;\n  } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {\n    num_scanlines = 16;\n  }\n\n  \/\/ Write attributes.\n  std::vector<tinyexr::ChannelInfo> channels;\n  {\n    std::vector<unsigned char> data;\n\n    for (int c = 0; c < exr_header->num_channels; c++) {\n      tinyexr::ChannelInfo info;\n      info.p_linear = 0;\n      info.pixel_type = exr_header->requested_pixel_types[c];\n      info.x_sampling = 1;\n      info.y_sampling = 1;\n      info.name = std::string(exr_header->channels[c].name);\n      channels.push_back(info);\n    }\n\n    tinyexr::WriteChannelInfo(data, channels);\n\n    tinyexr::WriteAttributeToMemory(&memory, \"channels\", \"chlist\", &data.at(0),\n                                    static_cast<int>(data.size()));\n  }\n\n  {\n    int comp = exr_header->compression_type;\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&comp));\n    tinyexr::WriteAttributeToMemory(\n        &memory, \"compression\", \"compression\",\n        reinterpret_cast<const unsigned char *>(&comp), 1);\n  }\n\n  {\n    int data[4] = {0, 0, exr_image->width - 1, exr_image->height - 1};\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&data[0]));\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&data[1]));\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&data[2]));\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&data[3]));\n    tinyexr::WriteAttributeToMemory(\n        &memory, \"dataWindow\", \"box2i\",\n        reinterpret_cast<const unsigned char *>(data), sizeof(int) * 4);\n    tinyexr::WriteAttributeToMemory(\n        &memory, \"displayWindow\", \"box2i\",\n        reinterpret_cast<const unsigned char *>(data), sizeof(int) * 4);\n  }\n\n  {\n    unsigned char line_order = 0;  \/\/ @fixme { read line_order from EXRHeader }\n    tinyexr::WriteAttributeToMemory(&memory, \"lineOrder\", \"lineOrder\",\n                                    &line_order, 1);\n  }\n\n  {\n    float aspectRatio = 1.0f;\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&aspectRatio));\n    tinyexr::WriteAttributeToMemory(\n        &memory, \"pixelAspectRatio\", \"float\",\n        reinterpret_cast<const unsigned char *>(&aspectRatio), sizeof(float));\n  }\n\n  {\n    float center[2] = {0.0f, 0.0f};\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(¢er[0]));\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(¢er[1]));\n    tinyexr::WriteAttributeToMemory(\n        &memory, \"screenWindowCenter\", \"v2f\",\n        reinterpret_cast<const unsigned char *>(center), 2 * sizeof(float));\n  }\n\n  {\n    float w = static_cast<float>(exr_image->width);\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&w));\n    tinyexr::WriteAttributeToMemory(&memory, \"screenWindowWidth\", \"float\",\n                                    reinterpret_cast<const unsigned char *>(&w),\n                                    sizeof(float));\n  }\n\n  \/\/ Custom attributes\n  if (exr_header->num_custom_attributes > 0) {\n    for (int i = 0; i < exr_header->num_custom_attributes; i++) {\n      tinyexr::WriteAttributeToMemory(\n          &memory, exr_header->custom_attributes[i].name,\n          exr_header->custom_attributes[i].type,\n          reinterpret_cast<const unsigned char *>(\n              exr_header->custom_attributes[i].value),\n          exr_header->custom_attributes[i].size);\n    }\n  }\n\n  {  \/\/ end of header\n    unsigned char e = 0;\n    memory.push_back(e);\n  }\n\n  int num_blocks = exr_image->height \/ num_scanlines;\n  if (num_blocks * num_scanlines < exr_image->height) {\n    num_blocks++;\n  }\n\n  std::vector<tinyexr::tinyexr_uint64> offsets(static_cast<size_t>(num_blocks));\n\n  size_t headerSize = memory.size();\n  tinyexr::tinyexr_uint64 offset =\n      headerSize +\n      static_cast<size_t>(num_blocks) *\n          sizeof(\n              tinyexr::tinyexr_int64);  \/\/ sizeof(header) + sizeof(offsetTable)\n\n  std::vector<std::vector<unsigned char> > data_list(\n      static_cast<size_t>(num_blocks));\n  std::vector<size_t> channel_offset_list(\n      static_cast<size_t>(exr_header->num_channels));\n\n  int pixel_data_size = 0;\n  size_t channel_offset = 0;\n  for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) {\n    channel_offset_list[c] = channel_offset;\n    if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n      pixel_data_size += sizeof(unsigned short);\n      channel_offset += sizeof(unsigned short);\n    } else if (exr_header->requested_pixel_types[c] ==\n               TINYEXR_PIXELTYPE_FLOAT) {\n      pixel_data_size += sizeof(float);\n      channel_offset += sizeof(float);\n    } else if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT) {\n      pixel_data_size += sizeof(unsigned int);\n      channel_offset += sizeof(unsigned int);\n    } else {\n      assert(0);\n    }\n  }\n\n#if TINYEXR_USE_ZFP\n  tinyexr::ZFPCompressionParam zfp_compression_param;\n\n  \/\/ Use ZFP compression parameter from custom attributes(if such a parameter\n  \/\/ exists)\n  {\n    bool ret = tinyexr::FindZFPCompressionParam(\n        &zfp_compression_param, exr_header->custom_attributes,\n        exr_header->num_custom_attributes);\n\n    if (!ret) {\n      \/\/ Use predefined compression parameter.\n      zfp_compression_param.type = 0;\n      zfp_compression_param.rate = 2;\n    }\n  }\n#endif\n\n\/\/ Use signed int since some OpenMP compiler doesn't allow unsigned type for\n\/\/ `parallel for`\n#ifdef _OPENMP\n#pragma omp parallel for\n#endif\n  for (int i = 0; i < num_blocks; i++) {\n    size_t ii = static_cast<size_t>(i);\n    int start_y = num_scanlines * i;\n    int endY = (std::min)(num_scanlines * (i + 1), exr_image->height);\n    int h = endY - start_y;\n\n    std::vector<unsigned char> buf(\n        static_cast<size_t>(exr_image->width * h * pixel_data_size));\n\n    for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) {\n      if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n        if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) {\n          for (int y = 0; y < h; y++) {\n            \/\/ Assume increasing Y\n            float *line_ptr = reinterpret_cast<float *>(&buf.at(\n                static_cast<size_t>(pixel_data_size * y * exr_image->width) +\n                channel_offset_list[c] *\n                    static_cast<size_t>(exr_image->width)));\n            for (int x = 0; x < exr_image->width; x++) {\n              tinyexr::FP16 h16;\n              h16.u = reinterpret_cast<unsigned short **>(\n                  exr_image->images)[c][(y + start_y) * exr_image->width + x];\n\n              tinyexr::FP32 f32 = half_to_float(h16);\n\n              tinyexr::swap4(reinterpret_cast<unsigned int *>(&f32.f));\n\n              \/\/ line_ptr[x] = f32.f;\n              tinyexr::cpy4(line_ptr + x, &(f32.f));\n            }\n          }\n        } else if (exr_header->requested_pixel_types[c] ==\n                   TINYEXR_PIXELTYPE_HALF) {\n          for (int y = 0; y < h; y++) {\n            \/\/ Assume increasing Y\n            unsigned short *line_ptr = reinterpret_cast<unsigned short *>(\n                &buf.at(static_cast<size_t>(pixel_data_size * y *\n                                            exr_image->width) +\n                        channel_offset_list[c] *\n                            static_cast<size_t>(exr_image->width)));\n            for (int x = 0; x < exr_image->width; x++) {\n              unsigned short val = reinterpret_cast<unsigned short **>(\n                  exr_image->images)[c][(y + start_y) * exr_image->width + x];\n\n              tinyexr::swap2(&val);\n\n              \/\/ line_ptr[x] = val;\n              tinyexr::cpy2(line_ptr + x, &val);\n            }\n          }\n        } else {\n          assert(0);\n        }\n\n      } else if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) {\n        if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {\n          for (int y = 0; y < h; y++) {\n            \/\/ Assume increasing Y\n            unsigned short *line_ptr = reinterpret_cast<unsigned short *>(\n                &buf.at(static_cast<size_t>(pixel_data_size * y *\n                                            exr_image->width) +\n                        channel_offset_list[c] *\n                            static_cast<size_t>(exr_image->width)));\n            for (int x = 0; x < exr_image->width; x++) {\n              tinyexr::FP32 f32;\n              f32.f = reinterpret_cast<float **>(\n                  exr_image->images)[c][(y + start_y) * exr_image->width + x];\n\n              tinyexr::FP16 h16;\n              h16 = float_to_half_full(f32);\n\n              tinyexr::swap2(reinterpret_cast<unsigned short *>(&h16.u));\n\n              \/\/ line_ptr[x] = h16.u;\n              tinyexr::cpy2(line_ptr + x, &(h16.u));\n            }\n          }\n        } else if (exr_header->requested_pixel_types[c] ==\n                   TINYEXR_PIXELTYPE_FLOAT) {\n          for (int y = 0; y < h; y++) {\n            \/\/ Assume increasing Y\n            float *line_ptr = reinterpret_cast<float *>(&buf.at(\n                static_cast<size_t>(pixel_data_size * y * exr_image->width) +\n                channel_offset_list[c] *\n                    static_cast<size_t>(exr_image->width)));\n            for (int x = 0; x < exr_image->width; x++) {\n              float val = reinterpret_cast<float **>(\n                  exr_image->images)[c][(y + start_y) * exr_image->width + x];\n\n              tinyexr::swap4(reinterpret_cast<unsigned int *>(&val));\n\n              \/\/ line_ptr[x] = val;\n              tinyexr::cpy4(line_ptr + x, &val);\n            }\n          }\n        } else {\n          assert(0);\n        }\n      } else if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_UINT) {\n        for (int y = 0; y < h; y++) {\n          \/\/ Assume increasing Y\n          unsigned int *line_ptr = reinterpret_cast<unsigned int *>(&buf.at(\n              static_cast<size_t>(pixel_data_size * y * exr_image->width) +\n              channel_offset_list[c] * static_cast<size_t>(exr_image->width)));\n          for (int x = 0; x < exr_image->width; x++) {\n            unsigned int val = reinterpret_cast<unsigned int **>(\n                exr_image->images)[c][(y + start_y) * exr_image->width + x];\n\n            tinyexr::swap4(&val);\n\n            \/\/ line_ptr[x] = val;\n            tinyexr::cpy4(line_ptr + x, &val);\n          }\n        }\n      }\n    }\n\n    if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_NONE) {\n      \/\/ 4 byte: scan line\n      \/\/ 4 byte: data size\n      \/\/ ~     : pixel data(uncompressed)\n      std::vector<unsigned char> header(8);\n      unsigned int data_len = static_cast<unsigned int>(buf.size());\n      memcpy(&header.at(0), &start_y, sizeof(int));\n      memcpy(&header.at(4), &data_len, sizeof(unsigned int));\n\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0)));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4)));\n\n      data_list[ii].insert(data_list[ii].end(), header.begin(), header.end());\n      data_list[ii].insert(data_list[ii].end(), buf.begin(),\n                           buf.begin() + data_len);\n\n    } else if ((exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) ||\n               (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) {\n#if TINYEXR_USE_MINIZ\n      std::vector<unsigned char> block(tinyexr::miniz::mz_compressBound(\n          static_cast<unsigned long>(buf.size())));\n#else\n      std::vector<unsigned char> block(\n          compressBound(static_cast<uLong>(buf.size())));\n#endif\n      tinyexr::tinyexr_uint64 outSize = block.size();\n\n      tinyexr::CompressZip(&block.at(0), outSize,\n                           reinterpret_cast<const unsigned char *>(&buf.at(0)),\n                           static_cast<unsigned long>(buf.size()));\n\n      \/\/ 4 byte: scan line\n      \/\/ 4 byte: data size\n      \/\/ ~     : pixel data(compressed)\n      std::vector<unsigned char> header(8);\n      unsigned int data_len = static_cast<unsigned int>(outSize);  \/\/ truncate\n      memcpy(&header.at(0), &start_y, sizeof(int));\n      memcpy(&header.at(4), &data_len, sizeof(unsigned int));\n\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0)));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4)));\n\n      data_list[ii].insert(data_list[ii].end(), header.begin(), header.end());\n      data_list[ii].insert(data_list[ii].end(), block.begin(),\n                           block.begin() + data_len);\n\n    } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_RLE) {\n      \/\/ (buf.size() * 3) \/ 2 would be enough.\n      std::vector<unsigned char> block((buf.size() * 3) \/ 2);\n\n      tinyexr::tinyexr_uint64 outSize = block.size();\n\n      tinyexr::CompressRle(&block.at(0), outSize,\n                           reinterpret_cast<const unsigned char *>(&buf.at(0)),\n                           static_cast<unsigned long>(buf.size()));\n\n      \/\/ 4 byte: scan line\n      \/\/ 4 byte: data size\n      \/\/ ~     : pixel data(compressed)\n      std::vector<unsigned char> header(8);\n      unsigned int data_len = static_cast<unsigned int>(outSize);  \/\/ truncate\n      memcpy(&header.at(0), &start_y, sizeof(int));\n      memcpy(&header.at(4), &data_len, sizeof(unsigned int));\n\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0)));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4)));\n\n      data_list[ii].insert(data_list[ii].end(), header.begin(), header.end());\n      data_list[ii].insert(data_list[ii].end(), block.begin(),\n                           block.begin() + data_len);\n\n    } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {\n#if TINYEXR_USE_PIZ\n      unsigned int bufLen =\n          8192 + static_cast<unsigned int>(\n                     2 * static_cast<unsigned int>(\n                             buf.size()));  \/\/ @fixme { compute good bound. }\n      std::vector<unsigned char> block(bufLen);\n      unsigned int outSize = static_cast<unsigned int>(block.size());\n\n      CompressPiz(&block.at(0), &outSize,\n                  reinterpret_cast<const unsigned char *>(&buf.at(0)),\n                  buf.size(), channels, exr_image->width, h);\n\n      \/\/ 4 byte: scan line\n      \/\/ 4 byte: data size\n      \/\/ ~     : pixel data(compressed)\n      std::vector<unsigned char> header(8);\n      unsigned int data_len = outSize;\n      memcpy(&header.at(0), &start_y, sizeof(int));\n      memcpy(&header.at(4), &data_len, sizeof(unsigned int));\n\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0)));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4)));\n\n      data_list[ii].insert(data_list[ii].end(), header.begin(), header.end());\n      data_list[ii].insert(data_list[ii].end(), block.begin(),\n                           block.begin() + data_len);\n\n#else\n      assert(0);\n#endif\n    } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {\n#if TINYEXR_USE_ZFP\n      std::vector<unsigned char> block;\n      unsigned int outSize;\n\n      tinyexr::CompressZfp(\n          &block, &outSize, reinterpret_cast<const float *>(&buf.at(0)),\n          exr_image->width, h, exr_header->num_channels, zfp_compression_param);\n\n      \/\/ 4 byte: scan line\n      \/\/ 4 byte: data size\n      \/\/ ~     : pixel data(compressed)\n      std::vector<unsigned char> header(8);\n      unsigned int data_len = outSize;\n      memcpy(&header.at(0), &start_y, sizeof(int));\n      memcpy(&header.at(4), &data_len, sizeof(unsigned int));\n\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(0)));\n      tinyexr::swap4(reinterpret_cast<unsigned int *>(&header.at(4)));\n\n      data_list[ii].insert(data_list[ii].end(), header.begin(), header.end());\n      data_list[ii].insert(data_list[ii].end(), block.begin(),\n                           block.begin() + data_len);\n\n#else\n      assert(0);\n#endif\n    } else {\n      assert(0);\n    }\n  }  \/\/ omp parallel\n\n  for (size_t i = 0; i < static_cast<size_t>(num_blocks); i++) {\n    offsets[i] = offset;\n    tinyexr::swap8(reinterpret_cast<tinyexr::tinyexr_uint64 *>(&offsets[i]));\n    offset += data_list[i].size();\n  }\n\n  size_t totalSize = static_cast<size_t>(offset);\n  {\n    memory.insert(\n        memory.end(), reinterpret_cast<unsigned char *>(&offsets.at(0)),\n        reinterpret_cast<unsigned char *>(&offsets.at(0)) +\n            sizeof(tinyexr::tinyexr_uint64) * static_cast<size_t>(num_blocks));\n  }\n\n  if (memory.size() == 0) {\n    tinyexr::SetErrorMessage(\"Output memory size is zero\", err);\n    return 0;\n  }\n\n  (*memory_out) = static_cast<unsigned char *>(malloc(totalSize));\n  memcpy((*memory_out), &memory.at(0), memory.size());\n  unsigned char *memory_ptr = *memory_out + memory.size();\n\n  for (size_t i = 0; i < static_cast<size_t>(num_blocks); i++) {\n    memcpy(memory_ptr, &data_list[i].at(0), data_list[i].size());\n    memory_ptr += data_list[i].size();\n  }\n\n  return totalSize;  \/\/ OK\n}","target":0,"code_token_length":4877,"total_token_length":5113,"max_tokens_setting":6144}
+{"idx":232329,"func":"static GF_Err gf_isom_parse_movie_boxes_internal(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode)\n{\n\tGF_Box *a;\n\tu64 totSize, mdat_end=0;\n\tGF_Err e = GF_OK;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\tif (mov->single_moof_mode && mov->single_moof_state == 2) {\n\t\treturn e;\n\t}\n\n\t\/*restart from where we stopped last*\/\n\ttotSize = mov->current_top_box_start;\n\tif (mov->bytes_removed) {\n\t\tassert(totSize >= mov->bytes_removed);\n\t\ttotSize -= mov->bytes_removed;\n\t}\n\tgf_bs_seek(mov->movieFileMap->bs, totSize);\n#endif\n\n\n\t\/*while we have some data, parse our boxes*\/\n\twhile (gf_bs_available(mov->movieFileMap->bs)) {\n\t\t*bytesMissing = 0;\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\tmov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] Parsing a top-level box at position %d\\n\", mov->current_top_box_start));\n#endif\n\n\t\te = gf_isom_parse_root_box(&a, mov->movieFileMap->bs, boxType, bytesMissing, progressive_mode);\n\n\t\tif (e >= 0) {\n\t\t\t\/\/safety check, should never happen\n\t\t\tif (!a) return GF_ISOM_INVALID_FILE;\n\t\t} else if (e == GF_ISOM_INCOMPLETE_FILE) {\n\t\t\t\/*our mdat is uncomplete, only valid for READ ONLY files...*\/\n\t\t\tif (mov->openMode != GF_ISOM_OPEN_READ) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Incomplete MDAT while file is not read-only\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tif ((mov->openMode == GF_ISOM_OPEN_READ) && !progressive_mode) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Incomplete file while reading for dump - aborting parsing\\n\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn e;\n\t\t} else {\n\t\t\treturn e;\n\t\t}\n\n\t\tswitch (a->type) {\n\t\t\/*MOOV box*\/\n\t\tcase GF_ISOM_BOX_TYPE_MOOV:\n\t\t\tif (mov->moov) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate MOOV detected!\\n\"));\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->moov = (GF_MovieBox *)a;\n\t\t\tmov->original_moov_offset = mov->current_top_box_start;\n\t\t\t\/*set our pointer to the movie*\/\n\t\t\tmov->moov->mov = mov;\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (mov->moov->mvex) mov->moov->mvex->mov = mov;\n\n#ifdef GF_ENABLE_CTRN\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\tgf_isom_setup_traf_inheritance(mov);\n\t\t\t}\n#endif\n\n#endif\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\n\t\t\ttotSize += a->size;\n\n            if (!mov->moov->mvhd) {\n                GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MovieHeaderBox\\n\"));\n                return GF_ISOM_INVALID_FILE;\n            }\n\n            if (mov->meta) {\n\t\t\t\tgf_isom_meta_restore_items_ref(mov, mov->meta);\n\t\t\t}\n\n\t\t\t\/\/dump senc info in dump mode\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\tu32 k;\n\t\t\t\tfor (k=0; k<gf_list_count(mov->moov->trackList); k++) {\n\t\t\t\t\tGF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k);\n\n\t\t\t\t\tif (trak->sample_encryption) {\n\t\t\t\t\t\te = senc_Parse(mov->movieFileMap->bs, trak, NULL, trak->sample_encryption);\n\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tu32 k;\n\t\t\t\tfor (k=0; k<gf_list_count(mov->moov->trackList); k++) {\n\t\t\t\t\tGF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k);\n\t\t\t\t\tif (trak->Media->information->sampleTable->sampleGroups) {\n\t\t\t\t\t\tconvert_compact_sample_groups(trak->Media->information->sampleTable->child_boxes, trak->Media->information->sampleTable->sampleGroups);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n            if (mdat_end && mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) {\n                gf_isom_push_mdat_end(mov, mdat_end);\n                mdat_end=0;\n            }\n\t\t\tbreak;\n\n\t\t\/*META box*\/\n\t\tcase GF_ISOM_BOX_TYPE_META:\n\t\t\tif (mov->meta) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate META detected!\\n\"));\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->meta = (GF_MetaBox *)a;\n\t\t\tmov->original_meta_offset = mov->current_top_box_start;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\ttotSize += a->size;\n\t\t\tgf_isom_meta_restore_items_ref(mov, mov->meta);\n\t\t\tbreak;\n\n\t\t\/*we only keep the MDAT in READ for dump purposes*\/\n\t\tcase GF_ISOM_BOX_TYPE_MDAT:\n\t\t\tif (!mov->first_data_toplevel_offset) {\n\t\t\t\tmov->first_data_toplevel_offset = mov->current_top_box_start;\n\t\t\t\tmov->first_data_toplevel_size = a->size;\n\t\t\t}\n\t\t\ttotSize += a->size;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (mov->emsgs) {\n\t\t\t\tgf_isom_box_array_del(mov->emsgs);\n\t\t\t\tmov->emsgs = NULL;\n\t\t\t}\n#endif\n\n\t\t\tif (mov->openMode == GF_ISOM_OPEN_READ) {\n\t\t\t\tif (!mov->mdat) {\n\t\t\t\t\tmov->mdat = (GF_MediaDataBox *) a;\n\t\t\t\t\te = gf_list_add(mov->TopBoxes, mov->mdat);\n\t\t\t\t\tif (e) {\n\t\t\t\t\t\treturn e;\n\t\t\t\t\t}\n\t\t\t\t}\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\t\telse if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) gf_list_add(mov->TopBoxes, a);\n#endif\n\t\t\t\telse gf_isom_box_del(a); \/\/in other modes we don't care\n\n\n\t\t\t\tif (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) {\n                    mdat_end = gf_bs_get_position(mov->movieFileMap->bs);\n                    if (mov->moov) {\n                        gf_isom_push_mdat_end(mov, mdat_end);\n                        mdat_end=0;\n                    }\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/*if we don't have any MDAT yet, create one (edit-write mode)\n\t\t\tWe only work with one mdat, but we're puting it at the place\n\t\t\tof the first mdat found when opening a file for editing*\/\n\t\t\telse if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tmov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT);\n\t\t\t\tif (!mov->mdat) return GF_OUT_OF_MEM;\n\t\t\t\te = gf_list_add(mov->TopBoxes, mov->mdat);\n\t\t\t\tif (e) {\n\t\t\t\t\treturn e;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_FTYP:\n\t\t\t\/*ONE AND ONLY ONE FTYP*\/\n\t\t\tif (mov->brand) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'ftyp' detected!\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->brand = (GF_FileTypeBox *)a;\n\t\t\ttotSize += a->size;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\t\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_OTYP:\n\t\t\t\/*ONE AND ONLY ONE FTYP*\/\n\t\t\tif (mov->otyp) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'otyp' detected!\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\tmov->otyp = (GF_Box *)a;\n\t\t\t\ttotSize += a->size;\n\t\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\t\tif (e) return e;\n\t\t\t} else {\n\t\t\t\tGF_FileTypeBox *brand = (GF_FileTypeBox *) gf_isom_box_find_child(a->child_boxes, GF_ISOM_BOX_TYPE_FTYP);\n\t\t\t\tif (brand) {\n\t\t\t\t\ts32 pos;\n\t\t\t\t\tgf_list_del_item(a->child_boxes, brand);\n\t\t\t\t\tpos = gf_list_del_item(mov->TopBoxes, mov->brand);\n\t\t\t\t\tgf_isom_box_del((GF_Box *) mov->brand);\n\t\t\t\t\tmov->brand = brand;\n\t\t\t\t\tif (pos<0) pos=0;\n\t\t\t\t\tgf_list_insert(mov->TopBoxes, brand, pos);\n\t\t\t\t}\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_PDIN:\n\t\t\t\/*ONE AND ONLY ONE PDIN*\/\n\t\t\tif (mov->pdin) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'pdin'' detected!\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->pdin = (GF_ProgressiveDownloadBox *) a;\n\t\t\ttotSize += a->size;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\t\t\tbreak;\n\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\tcase GF_ISOM_BOX_TYPE_STYP:\n\t\t{\n\t\t\tu32 brand = ((GF_FileTypeBox *)a)->majorBrand;\n\t\t\tswitch (brand) {\n\t\t\tcase GF_ISOM_BRAND_SISX:\n\t\t\tcase GF_ISOM_BRAND_RISX:\n\t\t\tcase GF_ISOM_BRAND_SSSS:\n\t\t\t\tmov->is_index_segment = GF_TRUE;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\/*fall-through*\/\n\n\t\tcase GF_ISOM_BOX_TYPE_SIDX:\n\t\tcase GF_ISOM_BOX_TYPE_SSIX:\n\t\t\tif (mov->moov && !mov->first_data_toplevel_offset) {\n\t\t\t\tmov->first_data_toplevel_offset = mov->current_top_box_start;\n\t\t\t\tmov->first_data_toplevel_size = a->size;\n\t\t\t}\n\t\t\ttotSize += a->size;\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\t\tif (e) return e;\n\t\t\t} else if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)  && (mov->openMode!=GF_ISOM_OPEN_KEEP_FRAGMENTS)\n\t\t\t) {\n\t\t\t\tif (a->type==GF_ISOM_BOX_TYPE_SIDX) {\n\t\t\t\t\tif (mov->root_sidx) gf_isom_box_del( (GF_Box *) mov->root_sidx);\n\t\t\t\t\tmov->root_sidx = (GF_SegmentIndexBox *) a;\n\t\t\t\t\tmov->sidx_start_offset = mov->current_top_box_start;\n\t\t\t\t\tmov->sidx_end_offset = gf_bs_get_position(mov->movieFileMap->bs);\n\n\t\t\t\t}\n\t\t\t\telse if (a->type==GF_ISOM_BOX_TYPE_STYP) {\n\t\t\t\t\tmov->styp_start_offset = mov->current_top_box_start;\n\n\t\t\t\t\tif (mov->seg_styp) gf_isom_box_del(mov->seg_styp);\n\t\t\t\t\tmov->seg_styp = a;\n\t\t\t\t} else if (a->type==GF_ISOM_BOX_TYPE_SSIX) {\n\t\t\t\t\tif (mov->seg_ssix) gf_isom_box_del(mov->seg_ssix);\n\t\t\t\t\tmov->seg_ssix = a;\n\t\t\t\t} else {\n\t\t\t\t\tgf_isom_box_del(a);\n\t\t\t\t}\n\t\t\t\tgf_isom_push_mdat_end(mov, mov->current_top_box_start);\n\t\t\t} else if (!mov->NextMoofNumber && (a->type==GF_ISOM_BOX_TYPE_SIDX)) {\n\t\t\t\tif (mov->main_sidx) gf_isom_box_del( (GF_Box *) mov->main_sidx);\n\t\t\t\tmov->main_sidx = (GF_SegmentIndexBox *) a;\n\t\t\t\tmov->main_sidx_end_pos = mov->current_top_box_start + a->size;\n\t\t\t} else {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_MOOF:\n\t\t\t\/\/no support for inplace rewrite for fragmented files\n\t\t\tgf_isom_disable_inplace_rewrite(mov);\n\t\t\tif (!mov->moov) {\n\t\t\t\tGF_LOG(mov->moof ? GF_LOG_DEBUG : GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Movie fragment but no moov (yet) - possibly broken parsing!\\n\"));\n\t\t\t}\n\t\t\tif (mov->single_moof_mode) {\n\t\t\t\tmov->single_moof_state++;\n\t\t\t\tif (mov->single_moof_state > 1) {\n\t\t\t\t\tgf_isom_box_del(a);\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t}\n\t\t\t}\n\t\t\t((GF_MovieFragmentBox *)a)->mov = mov;\n\n\t\t\ttotSize += a->size;\n\t\t\tmov->moof = (GF_MovieFragmentBox *) a;\n\n\t\t\t\/*some smooth streaming streams contain a SDTP under the TRAF: this is incorrect, convert it*\/\n\t\t\tFixTrackID(mov);\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\tFixSDTPInTRAF(mov->moof);\n\t\t\t} else {\n\t\t\t\tu32 k;\n\t\t\t\tfor (k=0; k<gf_list_count(mov->moof->TrackList); k++) {\n\t\t\t\t\tGF_TrackFragmentBox *traf = (GF_TrackFragmentBox *)gf_list_get(mov->moof->TrackList, k);\n\t\t\t\t\tif (traf->sampleGroups) {\n\t\t\t\t\t\tconvert_compact_sample_groups(traf->child_boxes, traf->sampleGroups);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/*read & debug: store at root level*\/\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\tu32 k;\n\t\t\t\tgf_list_add(mov->TopBoxes, a);\n\t\t\t\t\/*also update pointers to trex for debug*\/\n\t\t\t\tif (mov->moov) {\n\t\t\t\t\tfor (k=0; k<gf_list_count(mov->moof->TrackList); k++) {\n\t\t\t\t\t\tGF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k);\n\t\t\t\t\t\tif (traf->tfhd && mov->moov->mvex && mov->moov->mvex->TrackExList) {\n\t\t\t\t\t\t\tGF_TrackBox *trak = gf_isom_get_track_from_id(mov->moov, traf->tfhd->trackID);\n\t\t\t\t\t\t\tu32 j=0;\n\t\t\t\t\t\t\twhile ((traf->trex = (GF_TrackExtendsBox*)gf_list_enum(mov->moov->mvex->TrackExList, &j))) {\n\t\t\t\t\t\t\t\tif (traf->trex->trackID == traf->tfhd->trackID) {\n\t\t\t\t\t\t\t\t\tif (!traf->trex->track) traf->trex->track = trak;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttraf->trex = NULL;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/\/we should only parse senc\/psec when no saiz\/saio is present, otherwise we fetch the info directly\n\t\t\t\t\t\tif (traf->trex && traf->tfhd && traf->trex->track && traf->sample_encryption) {\n\t\t\t\t\t\t\tGF_TrackBox *trak = GetTrackbyID(mov->moov, traf->tfhd->trackID);\n\t\t\t\t\t\t\tif (trak) {\n\t\t\t\t\t\t\t\ttrak->current_traf_stsd_idx = traf->tfhd->sample_desc_index ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index;\n\t\t\t\t\t\t\t\te = senc_Parse(mov->movieFileMap->bs, trak, traf, traf->sample_encryption);\n\t\t\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\t\t\ttrak->current_traf_stsd_idx = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (k=0; k<gf_list_count(mov->moof->TrackList); k++) {\n\t\t\t\t\t\tGF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k);\n\t\t\t\t\t\tif (traf->sample_encryption) {\n\t\t\t\t\t\t\te = senc_Parse(mov->movieFileMap->bs, NULL, traf, traf->sample_encryption);\n\t\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t} else if (mov->openMode==GF_ISOM_OPEN_KEEP_FRAGMENTS) {\n\t\t\t\tmov->NextMoofNumber = mov->moof->mfhd->sequence_number+1;\n\t\t\t\tmov->moof = NULL;\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t} else {\n\t\t\t\t\/*merge all info*\/\n\t\t\t\te = MergeFragment((GF_MovieFragmentBox *)a, mov);\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\n\t\t\t\/\/done with moov\n\t\t\tif (mov->root_sidx) {\n\t\t\t\tgf_isom_box_del((GF_Box *) mov->root_sidx);\n\t\t\t\tmov->root_sidx = NULL;\n\t\t\t}\n\t\t\tif (mov->root_ssix) {\n\t\t\t\tgf_isom_box_del(mov->seg_ssix);\n\t\t\t\tmov->root_ssix = NULL;\n\t\t\t}\n\t\t\tif (mov->seg_styp) {\n\t\t\t\tgf_isom_box_del(mov->seg_styp);\n\t\t\t\tmov->seg_styp = NULL;\n\t\t\t}\n\t\t\tmov->sidx_start_offset = 0;\n\t\t\tmov->sidx_end_offset = 0;\n\t\t\tmov->styp_start_offset = 0;\n\t\t\tbreak;\n#endif\n\t\tcase GF_ISOM_BOX_TYPE_UNKNOWN:\n\t\t{\n\t\t\tGF_UnknownBox *box = (GF_UnknownBox*)a;\n\t\t\tif (box->original_4cc == GF_ISOM_BOX_TYPE_JP) {\n\t\t\t\tu8 *c = (u8 *) box->data;\n\t\t\t\tif ((box->dataSize==4) && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A))\n\t\t\t\t\tmov->is_jp2 = 1;\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t} else {\n\t\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_PRFT:\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (!(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\t\/\/keep the last one read\n\t\t\t\tif (mov->last_producer_ref_time)\n\t\t\t\t\tgf_isom_box_del(a);\n\t\t\t\telse\n\t\t\t\t\tmov->last_producer_ref_time = (GF_ProducerReferenceTimeBox *)a;\n\t\t\t\tbreak;\n\t\t\t}\n#endif\n\t\t\/\/fallthrough\n\t\tcase GF_ISOM_BOX_TYPE_EMSG:\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\tif (!mov->emsgs) mov->emsgs = gf_list_new();\n\t\t\t\tgf_list_add(mov->emsgs, a);\n\t\t\t\tbreak;\n\t\t\t}\n#endif\n\t\tcase GF_ISOM_BOX_TYPE_MFRA:\n\t\tcase GF_ISOM_BOX_TYPE_MFRO:\n\t\t\t\/\/only keep for dump mode, otherwise we ignore these boxes and we don't want to carry them over in non-fragmented file\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\ttotSize += a->size;\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tbreak;\n\t\t\t}\n\t\tdefault:\n\t\t\ttotSize += a->size;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\t\t\tbreak;\n\t\t}\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\/*remember where we left, in case we append an entire number of movie fragments*\/\n\t\tmov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed;\n#endif\n\t}\n\n\t\/*we need at least moov or meta*\/\n\tif (!mov->moov && !mov->meta\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t        && !mov->moof && !mov->is_index_segment\n#endif\n\t   ) {\n\t\treturn GF_ISOM_INCOMPLETE_FILE;\n\t}\n\t\/*we MUST have movie header*\/\n\tif (!gf_opts_get_bool(\"core\", \"no-check\")) {\n\t\tif (mov->moov && !mov->moov->mvhd) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MVHD in MOOV!\\n\"));\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\n\t\t\/*we MUST have meta handler*\/\n\t\tif (mov->meta && !mov->meta->handler) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing handler in META!\\n\"));\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t}\n\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\n\tif (mov->moov) {\n\t\t\/*set the default interleaving time*\/\n\t\tmov->interleavingTime = mov->moov->mvhd->timeScale;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\/*in edit mode with successfully loaded fragments, delete all fragment signaling since\n\t\tfile is no longer fragmented*\/\n\t\tif ((mov->openMode > GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS) && mov->moov->mvex) {\n\t\t\tgf_isom_box_del_parent(&mov->moov->child_boxes, (GF_Box *)mov->moov->mvex);\n\t\t\tmov->moov->mvex = NULL;\n\t\t}\n#endif\n\n\t}\n\n\t\/\/create a default mdat if none was found\n\tif (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) {\n\t\tmov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT);\n\t\tif (!mov->mdat) return GF_OUT_OF_MEM;\n\t\te = gf_list_add(mov->TopBoxes, mov->mdat);\n\t\tif (e) return e;\n\t}\n#endif \/*GPAC_DISABLE_ISOM_WRITE*\/\n\n\treturn GF_OK;\n}","target":0,"code_token_length":5202,"total_token_length":5438,"max_tokens_setting":6144}
+{"idx":223416,"func":"static PCRE2_SPTR compile_iterator_matchingpath(compiler_common *common, PCRE2_SPTR cc, backtrack_common *parent)\n{\nDEFINE_COMPILER;\nbacktrack_common *backtrack;\nPCRE2_UCHAR opcode;\nPCRE2_UCHAR type;\nsljit_u32 max = 0, exact;\nsljit_s32 early_fail_ptr = PRIVATE_DATA(cc + 1);\nsljit_s32 early_fail_type;\nBOOL charpos_enabled;\nPCRE2_UCHAR charpos_char;\nunsigned int charpos_othercasebit;\nPCRE2_SPTR end;\njump_list *no_match = NULL;\njump_list *no_char1_match = NULL;\nstruct sljit_jump *jump = NULL;\nstruct sljit_label *label;\nint private_data_ptr = PRIVATE_DATA(cc);\nint base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_SP);\nint offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;\nint offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);\nint tmp_base, tmp_offset;\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\nBOOL use_tmp;\n#endif\n\nPUSH_BACKTRACK(sizeof(char_iterator_backtrack), cc, NULL);\n\nearly_fail_type = (early_fail_ptr & 0x7);\nearly_fail_ptr >>= 3;\n\n\/* During recursion, these optimizations are disabled. *\/\nif (common->early_fail_start_ptr == 0 && common->fast_forward_bc_ptr == NULL)\n  {\n  early_fail_ptr = 0;\n  early_fail_type = type_skip;\n  }\n\nSLJIT_ASSERT(common->fast_forward_bc_ptr != NULL || early_fail_ptr == 0\n  || (early_fail_ptr >= common->early_fail_start_ptr && early_fail_ptr <= common->early_fail_end_ptr));\n\nif (early_fail_type == type_fail)\n  add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), early_fail_ptr));\n\ncc = get_iterator_parameters(common, cc, &opcode, &type, &max, &exact, &end);\n\nif (type != OP_EXTUNI)\n  {\n  tmp_base = TMP3;\n  tmp_offset = 0;\n  }\nelse\n  {\n  tmp_base = SLJIT_MEM1(SLJIT_SP);\n  tmp_offset = POSSESSIVE0;\n  }\n\n\/* Handle fixed part first. *\/\nif (exact > 1)\n  {\n  SLJIT_ASSERT(early_fail_ptr == 0);\n\n  if (common->mode == PCRE2_JIT_COMPLETE\n#ifdef SUPPORT_UNICODE\n      && !common->utf\n#endif\n      && type != OP_ANYNL && type != OP_EXTUNI)\n    {\n    OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(exact));\n    add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER, TMP1, 0, STR_END, 0));\n    OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, exact);\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, FALSE);\n    OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n    JUMPTO(SLJIT_NOT_ZERO, label);\n    }\n  else\n    {\n    OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, exact);\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, TRUE);\n    OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n    JUMPTO(SLJIT_NOT_ZERO, label);\n    }\n  }\nelse if (exact == 1)\n  {\n  compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, TRUE);\n\n  if (early_fail_type == type_fail_range)\n    {\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), early_fail_ptr);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), early_fail_ptr + (int)sizeof(sljit_sw));\n    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, TMP2, 0);\n    OP2(SLJIT_SUB, TMP2, 0, STR_PTR, 0, TMP2, 0);\n    add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_LESS_EQUAL, TMP2, 0, TMP1, 0));\n\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr + (int)sizeof(sljit_sw), STR_PTR, 0);\n    }\n  }\n\nswitch(opcode)\n  {\n  case OP_STAR:\n  case OP_UPTO:\n  SLJIT_ASSERT(early_fail_ptr == 0 || opcode == OP_STAR);\n\n  if (type == OP_ANYNL || type == OP_EXTUNI)\n    {\n    SLJIT_ASSERT(private_data_ptr == 0);\n    SLJIT_ASSERT(early_fail_ptr == 0);\n\n    allocate_stack(common, 2);\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);\n\n    if (opcode == OP_UPTO)\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, SLJIT_IMM, max);\n\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &BACKTRACK_AS(char_iterator_backtrack)->u.backtracks, TRUE);\n    if (opcode == OP_UPTO)\n      {\n      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0);\n      OP2(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);\n      jump = JUMP(SLJIT_ZERO);\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, TMP1, 0);\n      }\n\n    \/* We cannot use TMP3 because of allocate_stack. *\/\n    allocate_stack(common, 1);\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);\n    JUMPTO(SLJIT_JUMP, label);\n    if (jump != NULL)\n      JUMPHERE(jump);\n    BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n    break;\n    }\n#ifdef SUPPORT_UNICODE\n  else if (type == OP_ALLANY && !common->invalid_utf)\n#else\n  else if (type == OP_ALLANY)\n#endif\n    {\n    if (opcode == OP_STAR)\n      {\n      if (private_data_ptr == 0)\n        allocate_stack(common, 2);\n\n      OP1(SLJIT_MOV, base, offset0, STR_END, 0);\n      OP1(SLJIT_MOV, base, offset1, STR_PTR, 0);\n\n      OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0);\n      process_partial_match(common);\n\n      if (early_fail_ptr != 0)\n        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_END, 0);\n      BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n      break;\n      }\n#ifdef SUPPORT_UNICODE\n    else if (!common->utf)\n#else\n    else\n#endif\n      {\n      if (private_data_ptr == 0)\n        allocate_stack(common, 2);\n\n      OP1(SLJIT_MOV, base, offset1, STR_PTR, 0);\n      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(max));\n\n      if (common->mode == PCRE2_JIT_COMPLETE)\n        {\n        OP2U(SLJIT_SUB | SLJIT_SET_GREATER, STR_PTR, 0, STR_END, 0);\n        CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0);\n        }\n      else\n        {\n        jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, STR_END, 0);\n        process_partial_match(common);\n        JUMPHERE(jump);\n        }\n\n      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n\n      if (early_fail_ptr != 0)\n        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n      BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n      break;\n      }\n    }\n\n  charpos_enabled = FALSE;\n  charpos_char = 0;\n  charpos_othercasebit = 0;\n\n  if ((type != OP_CHAR && type != OP_CHARI) && (*end == OP_CHAR || *end == OP_CHARI))\n    {\n#ifdef SUPPORT_UNICODE\n    charpos_enabled = !common->utf || !HAS_EXTRALEN(end[1]);\n#else\n    charpos_enabled = TRUE;\n#endif\n    if (charpos_enabled && *end == OP_CHARI && char_has_othercase(common, end + 1))\n      {\n      charpos_othercasebit = char_get_othercase_bit(common, end + 1);\n      if (charpos_othercasebit == 0)\n        charpos_enabled = FALSE;\n      }\n\n    if (charpos_enabled)\n      {\n      charpos_char = end[1];\n      \/* Consume the OP_CHAR opcode. *\/\n      end += 2;\n#if PCRE2_CODE_UNIT_WIDTH == 8\n      SLJIT_ASSERT((charpos_othercasebit >> 8) == 0);\n#elif PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32\n      SLJIT_ASSERT((charpos_othercasebit >> 9) == 0);\n      if ((charpos_othercasebit & 0x100) != 0)\n        charpos_othercasebit = (charpos_othercasebit & 0xff) << 8;\n#endif\n      if (charpos_othercasebit != 0)\n        charpos_char |= charpos_othercasebit;\n\n      BACKTRACK_AS(char_iterator_backtrack)->u.charpos.enabled = TRUE;\n      BACKTRACK_AS(char_iterator_backtrack)->u.charpos.chr = charpos_char;\n      BACKTRACK_AS(char_iterator_backtrack)->u.charpos.othercasebit = charpos_othercasebit;\n      }\n    }\n\n  if (charpos_enabled)\n    {\n    if (opcode == OP_UPTO)\n      OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max + 1);\n\n    \/* Search the first instance of charpos_char. *\/\n    jump = JUMP(SLJIT_JUMP);\n    label = LABEL();\n    if (opcode == OP_UPTO)\n      {\n      OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n      add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_ZERO));\n      }\n    compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, FALSE);\n    if (early_fail_ptr != 0)\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n    JUMPHERE(jump);\n\n    detect_partial_match(common, &backtrack->topbacktracks);\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    if (charpos_othercasebit != 0)\n      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit);\n    CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label);\n\n    if (private_data_ptr == 0)\n      allocate_stack(common, 2);\n    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n    OP1(SLJIT_MOV, base, offset1, STR_PTR, 0);\n\n    if (opcode == OP_UPTO)\n      {\n      OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n      add_jump(compiler, &no_match, JUMP(SLJIT_ZERO));\n      }\n\n    \/* Search the last instance of charpos_char. *\/\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &no_match, FALSE);\n    if (early_fail_ptr != 0)\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n    detect_partial_match(common, &no_match);\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));\n    if (charpos_othercasebit != 0)\n      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit);\n\n    if (opcode == OP_STAR)\n      {\n      CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label);\n      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n      JUMPTO(SLJIT_JUMP, label);\n      }\n    else\n      {\n      jump = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char);\n      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n      JUMPHERE(jump);\n      OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n      JUMPTO(SLJIT_NOT_ZERO, label);\n      }\n\n    set_jumps(no_match, LABEL());\n    OP2(SLJIT_ADD, STR_PTR, 0, base, offset0, SLJIT_IMM, IN_UCHARS(1));\n    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n    }\n  else\n    {\n    if (private_data_ptr == 0)\n      allocate_stack(common, 2);\n\n    OP1(SLJIT_MOV, base, offset1, STR_PTR, 0);\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\n    use_tmp = (!HAS_VIRTUAL_REGISTERS && opcode == OP_STAR);\n    SLJIT_ASSERT(!use_tmp || tmp_base == TMP3);\n\n    if (common->utf)\n      OP1(SLJIT_MOV, use_tmp ? TMP3 : base, use_tmp ? 0 : offset0, STR_PTR, 0);\n#endif\n    if (opcode == OP_UPTO)\n      OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max);\n\n    detect_partial_match(common, &no_match);\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE);\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\n    if (common->utf)\n      OP1(SLJIT_MOV, use_tmp ? TMP3 : base, use_tmp ? 0 : offset0, STR_PTR, 0);\n#endif\n\n    if (opcode == OP_UPTO)\n      {\n      OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n      add_jump(compiler, &no_match, JUMP(SLJIT_ZERO));\n      }\n\n    detect_partial_match_to(common, label);\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n    set_jumps(no_char1_match, LABEL());\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\n    if (common->utf)\n      {\n      set_jumps(no_match, LABEL());\n      if (use_tmp)\n        {\n        OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);\n        OP1(SLJIT_MOV, base, offset0, TMP3, 0);\n        }\n      else\n        OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);\n      }\n    else\n#endif\n      {\n      OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n      set_jumps(no_match, LABEL());\n      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n      }\n\n    if (early_fail_ptr != 0)\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n    }\n\n  BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n  break;\n\n  case OP_MINSTAR:\n  if (private_data_ptr == 0)\n    allocate_stack(common, 1);\n  OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n  BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n  if (early_fail_ptr != 0)\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n  break;\n\n  case OP_MINUPTO:\n  SLJIT_ASSERT(early_fail_ptr == 0);\n  if (private_data_ptr == 0)\n    allocate_stack(common, 2);\n  OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n  OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, max + 1);\n  BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n  break;\n\n  case OP_QUERY:\n  case OP_MINQUERY:\n  SLJIT_ASSERT(early_fail_ptr == 0);\n  if (private_data_ptr == 0)\n    allocate_stack(common, 1);\n  OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);\n  if (opcode == OP_QUERY)\n    compile_char1_matchingpath(common, type, cc, &BACKTRACK_AS(char_iterator_backtrack)->u.backtracks, TRUE);\n  BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL();\n  break;\n\n  case OP_EXACT:\n  break;\n\n  case OP_POSSTAR:\n#if defined SUPPORT_UNICODE\n  if (type == OP_ALLANY && !common->invalid_utf)\n#else\n  if (type == OP_ALLANY)\n#endif\n    {\n    OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0);\n    process_partial_match(common);\n    if (early_fail_ptr != 0)\n      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_END, 0);\n    break;\n    }\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\n  if (common->utf)\n    {\n    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);\n    detect_partial_match(common, &no_match);\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &no_match, FALSE);\n    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);\n    detect_partial_match_to(common, label);\n\n    set_jumps(no_match, LABEL());\n    OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);\n    if (early_fail_ptr != 0)\n      {\n      if (!HAS_VIRTUAL_REGISTERS && tmp_base == TMP3)\n        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, TMP3, 0);\n      else\n        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n      }\n    break;\n    }\n#endif\n\n  detect_partial_match(common, &no_match);\n  label = LABEL();\n  compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE);\n  detect_partial_match_to(common, label);\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n  set_jumps(no_char1_match, LABEL());\n  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  set_jumps(no_match, LABEL());\n  if (early_fail_ptr != 0)\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), early_fail_ptr, STR_PTR, 0);\n  break;\n\n  case OP_POSUPTO:\n  SLJIT_ASSERT(early_fail_ptr == 0);\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32\n  if (common->utf)\n    {\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, STR_PTR, 0);\n    OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max);\n\n    detect_partial_match(common, &no_match);\n    label = LABEL();\n    compile_char1_matchingpath(common, type, cc, &no_match, FALSE);\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, STR_PTR, 0);\n    OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n    add_jump(compiler, &no_match, JUMP(SLJIT_ZERO));\n    detect_partial_match_to(common, label);\n\n    set_jumps(no_match, LABEL());\n    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1);\n    break;\n    }\n#endif\n\n  if (type == OP_ALLANY)\n    {\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(max));\n\n    if (common->mode == PCRE2_JIT_COMPLETE)\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER, STR_PTR, 0, STR_END, 0);\n      CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0);\n      }\n    else\n      {\n      jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, STR_END, 0);\n      process_partial_match(common);\n      JUMPHERE(jump);\n      }\n    break;\n    }\n\n  OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max);\n\n  detect_partial_match(common, &no_match);\n  label = LABEL();\n  compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE);\n  OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);\n  add_jump(compiler, &no_match, JUMP(SLJIT_ZERO));\n  detect_partial_match_to(common, label);\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n  set_jumps(no_char1_match, LABEL());\n  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  set_jumps(no_match, LABEL());\n  break;\n\n  case OP_POSQUERY:\n  SLJIT_ASSERT(early_fail_ptr == 0);\n  OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);\n  compile_char1_matchingpath(common, type, cc, &no_match, TRUE);\n  OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);\n  set_jumps(no_match, LABEL());\n  OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);\n  break;\n\n  default:\n  SLJIT_UNREACHABLE();\n  break;\n  }\n\ncount_match(common);\nreturn end;\n}","target":0,"code_token_length":5529,"total_token_length":5765,"max_tokens_setting":6144}
+{"idx":195742,"func":"static GF_Err gf_isom_parse_movie_boxes_internal(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode)\n{\n\tGF_Box *a;\n\tu64 totSize, mdat_end=0;\n\tGF_Err e = GF_OK;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\tif (mov->single_moof_mode && mov->single_moof_state == 2) {\n\t\treturn e;\n\t}\n\n\t\/*restart from where we stopped last*\/\n\ttotSize = mov->current_top_box_start;\n\tif (mov->bytes_removed) {\n\t\tassert(totSize >= mov->bytes_removed);\n\t\ttotSize -= mov->bytes_removed;\n\t}\n\tgf_bs_seek(mov->movieFileMap->bs, totSize);\n#endif\n\n\n\t\/*while we have some data, parse our boxes*\/\n\twhile (gf_bs_available(mov->movieFileMap->bs)) {\n\t\t*bytesMissing = 0;\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\tmov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] Parsing a top-level box at position %d\\n\", mov->current_top_box_start));\n#endif\n\n\t\te = gf_isom_parse_root_box(&a, mov->movieFileMap->bs, boxType, bytesMissing, progressive_mode);\n\n\t\tif (e >= 0) {\n\n\t\t} else if (e == GF_ISOM_INCOMPLETE_FILE) {\n\t\t\t\/*our mdat is uncomplete, only valid for READ ONLY files...*\/\n\t\t\tif (mov->openMode != GF_ISOM_OPEN_READ) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Incomplete MDAT while file is not read-only\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tif ((mov->openMode == GF_ISOM_OPEN_READ) && !progressive_mode) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Incomplete file while reading for dump - aborting parsing\\n\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn e;\n\t\t} else {\n\t\t\treturn e;\n\t\t}\n\n\t\tswitch (a->type) {\n\t\t\/*MOOV box*\/\n\t\tcase GF_ISOM_BOX_TYPE_MOOV:\n\t\t\tif (mov->moov) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate MOOV detected!\\n\"));\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->moov = (GF_MovieBox *)a;\n\t\t\tmov->original_moov_offset = mov->current_top_box_start;\n\t\t\t\/*set our pointer to the movie*\/\n\t\t\tmov->moov->mov = mov;\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (mov->moov->mvex) mov->moov->mvex->mov = mov;\n\n#ifdef GF_ENABLE_CTRN\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\tgf_isom_setup_traf_inheritance(mov);\n\t\t\t}\n#endif\n\n#endif\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\n\t\t\ttotSize += a->size;\n\n            if (!mov->moov->mvhd) {\n                GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MovieHeaderBox\\n\"));\n                return GF_ISOM_INVALID_FILE;\n            }\n\n            if (mov->meta) {\n\t\t\t\tgf_isom_meta_restore_items_ref(mov, mov->meta);\n\t\t\t}\n\n\t\t\t\/\/dump senc info in dump mode\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\tu32 k;\n\t\t\t\tfor (k=0; k<gf_list_count(mov->moov->trackList); k++) {\n\t\t\t\t\tGF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k);\n\n\t\t\t\t\tif (trak->sample_encryption) {\n\t\t\t\t\t\te = senc_Parse(mov->movieFileMap->bs, trak, NULL, trak->sample_encryption);\n\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tu32 k;\n\t\t\t\tfor (k=0; k<gf_list_count(mov->moov->trackList); k++) {\n\t\t\t\t\tGF_TrackBox *trak = (GF_TrackBox *)gf_list_get(mov->moov->trackList, k);\n\t\t\t\t\tif (trak->Media->information->sampleTable->sampleGroups) {\n\t\t\t\t\t\tconvert_compact_sample_groups(trak->Media->information->sampleTable->child_boxes, trak->Media->information->sampleTable->sampleGroups);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n            if (mdat_end && mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) {\n                gf_isom_push_mdat_end(mov, mdat_end);\n                mdat_end=0;\n            }\n\t\t\tbreak;\n\n\t\t\/*META box*\/\n\t\tcase GF_ISOM_BOX_TYPE_META:\n\t\t\tif (mov->meta) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate META detected!\\n\"));\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->meta = (GF_MetaBox *)a;\n\t\t\tmov->original_meta_offset = mov->current_top_box_start;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\ttotSize += a->size;\n\t\t\tgf_isom_meta_restore_items_ref(mov, mov->meta);\n\t\t\tbreak;\n\n\t\t\/*we only keep the MDAT in READ for dump purposes*\/\n\t\tcase GF_ISOM_BOX_TYPE_MDAT:\n\t\t\tif (!mov->first_data_toplevel_offset) {\n\t\t\t\tmov->first_data_toplevel_offset = mov->current_top_box_start;\n\t\t\t\tmov->first_data_toplevel_size = a->size;\n\t\t\t}\n\t\t\ttotSize += a->size;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (mov->emsgs) {\n\t\t\t\tgf_isom_box_array_del(mov->emsgs);\n\t\t\t\tmov->emsgs = NULL;\n\t\t\t}\n#endif\n\n\t\t\tif (mov->openMode == GF_ISOM_OPEN_READ) {\n\t\t\t\tif (!mov->mdat) {\n\t\t\t\t\tmov->mdat = (GF_MediaDataBox *) a;\n\t\t\t\t\te = gf_list_add(mov->TopBoxes, mov->mdat);\n\t\t\t\t\tif (e) {\n\t\t\t\t\t\treturn e;\n\t\t\t\t\t}\n\t\t\t\t}\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\t\telse if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) gf_list_add(mov->TopBoxes, a);\n#endif\n\t\t\t\telse gf_isom_box_del(a); \/\/in other modes we don't care\n\n\n\t\t\t\tif (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) ) {\n                    mdat_end = gf_bs_get_position(mov->movieFileMap->bs);\n                    if (mov->moov) {\n                        gf_isom_push_mdat_end(mov, mdat_end);\n                        mdat_end=0;\n                    }\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/*if we don't have any MDAT yet, create one (edit-write mode)\n\t\t\tWe only work with one mdat, but we're puting it at the place\n\t\t\tof the first mdat found when opening a file for editing*\/\n\t\t\telse if (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tmov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT);\n\t\t\t\tif (!mov->mdat) return GF_OUT_OF_MEM;\n\t\t\t\te = gf_list_add(mov->TopBoxes, mov->mdat);\n\t\t\t\tif (e) {\n\t\t\t\t\treturn e;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_FTYP:\n\t\t\t\/*ONE AND ONLY ONE FTYP*\/\n\t\t\tif (mov->brand) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'ftyp' detected!\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->brand = (GF_FileTypeBox *)a;\n\t\t\ttotSize += a->size;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\t\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_OTYP:\n\t\t\t\/*ONE AND ONLY ONE FTYP*\/\n\t\t\tif (mov->otyp) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'otyp' detected!\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\tmov->otyp = (GF_Box *)a;\n\t\t\t\ttotSize += a->size;\n\t\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\t\tif (e) return e;\n\t\t\t} else {\n\t\t\t\tGF_FileTypeBox *brand = (GF_FileTypeBox *) gf_isom_box_find_child(a->child_boxes, GF_ISOM_BOX_TYPE_FTYP);\n\t\t\t\tif (brand) {\n\t\t\t\t\ts32 pos;\n\t\t\t\t\tgf_list_del_item(a->child_boxes, brand);\n\t\t\t\t\tpos = gf_list_del_item(mov->TopBoxes, mov->brand);\n\t\t\t\t\tgf_isom_box_del((GF_Box *) mov->brand);\n\t\t\t\t\tmov->brand = brand;\n\t\t\t\t\tif (pos<0) pos=0;\n\t\t\t\t\tgf_list_insert(mov->TopBoxes, brand, pos);\n\t\t\t\t}\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_PDIN:\n\t\t\t\/*ONE AND ONLY ONE PDIN*\/\n\t\t\tif (mov->pdin) {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Duplicate 'pdin'' detected!\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\tmov->pdin = (GF_ProgressiveDownloadBox *) a;\n\t\t\ttotSize += a->size;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\t\t\tbreak;\n\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\tcase GF_ISOM_BOX_TYPE_STYP:\n\t\t{\n\t\t\tu32 brand = ((GF_FileTypeBox *)a)->majorBrand;\n\t\t\tswitch (brand) {\n\t\t\tcase GF_ISOM_BRAND_SISX:\n\t\t\tcase GF_ISOM_BRAND_RISX:\n\t\t\tcase GF_ISOM_BRAND_SSSS:\n\t\t\t\tmov->is_index_segment = GF_TRUE;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\/*fall-through*\/\n\n\t\tcase GF_ISOM_BOX_TYPE_SIDX:\n\t\tcase GF_ISOM_BOX_TYPE_SSIX:\n\t\t\tif (mov->moov && !mov->first_data_toplevel_offset) {\n\t\t\t\tmov->first_data_toplevel_offset = mov->current_top_box_start;\n\t\t\t\tmov->first_data_toplevel_size = a->size;\n\t\t\t}\n\t\t\ttotSize += a->size;\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\t\tif (e) return e;\n\t\t\t} else if (mov->signal_frag_bounds && !(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)  && (mov->openMode!=GF_ISOM_OPEN_KEEP_FRAGMENTS)\n\t\t\t) {\n\t\t\t\tif (a->type==GF_ISOM_BOX_TYPE_SIDX) {\n\t\t\t\t\tif (mov->root_sidx) gf_isom_box_del( (GF_Box *) mov->root_sidx);\n\t\t\t\t\tmov->root_sidx = (GF_SegmentIndexBox *) a;\n\t\t\t\t\tmov->sidx_start_offset = mov->current_top_box_start;\n\t\t\t\t\tmov->sidx_end_offset = gf_bs_get_position(mov->movieFileMap->bs);\n\n\t\t\t\t}\n\t\t\t\telse if (a->type==GF_ISOM_BOX_TYPE_STYP) {\n\t\t\t\t\tmov->styp_start_offset = mov->current_top_box_start;\n\n\t\t\t\t\tif (mov->seg_styp) gf_isom_box_del(mov->seg_styp);\n\t\t\t\t\tmov->seg_styp = a;\n\t\t\t\t} else if (a->type==GF_ISOM_BOX_TYPE_SSIX) {\n\t\t\t\t\tif (mov->seg_ssix) gf_isom_box_del(mov->seg_ssix);\n\t\t\t\t\tmov->seg_ssix = a;\n\t\t\t\t} else {\n\t\t\t\t\tgf_isom_box_del(a);\n\t\t\t\t}\n\t\t\t\tgf_isom_push_mdat_end(mov, mov->current_top_box_start);\n\t\t\t} else if (!mov->NextMoofNumber && (a->type==GF_ISOM_BOX_TYPE_SIDX)) {\n\t\t\t\tif (mov->main_sidx) gf_isom_box_del( (GF_Box *) mov->main_sidx);\n\t\t\t\tmov->main_sidx = (GF_SegmentIndexBox *) a;\n\t\t\t\tmov->main_sidx_end_pos = mov->current_top_box_start + a->size;\n\t\t\t} else {\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_MOOF:\n\t\t\t\/\/no support for inplace rewrite for fragmented files\n\t\t\tgf_isom_disable_inplace_rewrite(mov);\n\t\t\tif (!mov->moov) {\n\t\t\t\tGF_LOG(mov->moof ? GF_LOG_DEBUG : GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Movie fragment but no moov (yet) - possibly broken parsing!\\n\"));\n\t\t\t}\n\t\t\tif (mov->single_moof_mode) {\n\t\t\t\tmov->single_moof_state++;\n\t\t\t\tif (mov->single_moof_state > 1) {\n\t\t\t\t\tgf_isom_box_del(a);\n\t\t\t\t\treturn GF_OK;\n\t\t\t\t}\n\t\t\t}\n\t\t\t((GF_MovieFragmentBox *)a)->mov = mov;\n\n\t\t\ttotSize += a->size;\n\t\t\tmov->moof = (GF_MovieFragmentBox *) a;\n\n\t\t\t\/*some smooth streaming streams contain a SDTP under the TRAF: this is incorrect, convert it*\/\n\t\t\tFixTrackID(mov);\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\tFixSDTPInTRAF(mov->moof);\n\t\t\t} else {\n\t\t\t\tu32 k;\n\t\t\t\tfor (k=0; k<gf_list_count(mov->moof->TrackList); k++) {\n\t\t\t\t\tGF_TrackFragmentBox *traf = (GF_TrackFragmentBox *)gf_list_get(mov->moof->TrackList, k);\n\t\t\t\t\tif (traf->sampleGroups) {\n\t\t\t\t\t\tconvert_compact_sample_groups(traf->child_boxes, traf->sampleGroups);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\/*read & debug: store at root level*\/\n\t\t\tif (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) {\n\t\t\t\tu32 k;\n\t\t\t\tgf_list_add(mov->TopBoxes, a);\n\t\t\t\t\/*also update pointers to trex for debug*\/\n\t\t\t\tif (mov->moov) {\n\t\t\t\t\tfor (k=0; k<gf_list_count(mov->moof->TrackList); k++) {\n\t\t\t\t\t\tGF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k);\n\t\t\t\t\t\tif (traf->tfhd && mov->moov->mvex && mov->moov->mvex->TrackExList) {\n\t\t\t\t\t\t\tGF_TrackBox *trak = gf_isom_get_track_from_id(mov->moov, traf->tfhd->trackID);\n\t\t\t\t\t\t\tu32 j=0;\n\t\t\t\t\t\t\twhile ((traf->trex = (GF_TrackExtendsBox*)gf_list_enum(mov->moov->mvex->TrackExList, &j))) {\n\t\t\t\t\t\t\t\tif (traf->trex->trackID == traf->tfhd->trackID) {\n\t\t\t\t\t\t\t\t\tif (!traf->trex->track) traf->trex->track = trak;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttraf->trex = NULL;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/\/we should only parse senc\/psec when no saiz\/saio is present, otherwise we fetch the info directly\n\t\t\t\t\t\tif (traf->trex && traf->tfhd && traf->trex->track && traf->sample_encryption) {\n\t\t\t\t\t\t\tGF_TrackBox *trak = GetTrackbyID(mov->moov, traf->tfhd->trackID);\n\t\t\t\t\t\t\tif (trak) {\n\t\t\t\t\t\t\t\ttrak->current_traf_stsd_idx = traf->tfhd->sample_desc_index ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index;\n\t\t\t\t\t\t\t\te = senc_Parse(mov->movieFileMap->bs, trak, traf, traf->sample_encryption);\n\t\t\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\t\t\ttrak->current_traf_stsd_idx = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (k=0; k<gf_list_count(mov->moof->TrackList); k++) {\n\t\t\t\t\t\tGF_TrackFragmentBox *traf = gf_list_get(mov->moof->TrackList, k);\n\t\t\t\t\t\tif (traf->sample_encryption) {\n\t\t\t\t\t\t\te = senc_Parse(mov->movieFileMap->bs, NULL, traf, traf->sample_encryption);\n\t\t\t\t\t\t\tif (e) return e;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t} else if (mov->openMode==GF_ISOM_OPEN_KEEP_FRAGMENTS) {\n\t\t\t\tmov->NextMoofNumber = mov->moof->mfhd->sequence_number+1;\n\t\t\t\tmov->moof = NULL;\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t} else {\n\t\t\t\t\/*merge all info*\/\n\t\t\t\te = MergeFragment((GF_MovieFragmentBox *)a, mov);\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\n\t\t\t\/\/done with moov\n\t\t\tif (mov->root_sidx) {\n\t\t\t\tgf_isom_box_del((GF_Box *) mov->root_sidx);\n\t\t\t\tmov->root_sidx = NULL;\n\t\t\t}\n\t\t\tif (mov->root_ssix) {\n\t\t\t\tgf_isom_box_del(mov->seg_ssix);\n\t\t\t\tmov->root_ssix = NULL;\n\t\t\t}\n\t\t\tif (mov->seg_styp) {\n\t\t\t\tgf_isom_box_del(mov->seg_styp);\n\t\t\t\tmov->seg_styp = NULL;\n\t\t\t}\n\t\t\tmov->sidx_start_offset = 0;\n\t\t\tmov->sidx_end_offset = 0;\n\t\t\tmov->styp_start_offset = 0;\n\t\t\tbreak;\n#endif\n\t\tcase GF_ISOM_BOX_TYPE_UNKNOWN:\n\t\t{\n\t\t\tGF_UnknownBox *box = (GF_UnknownBox*)a;\n\t\t\tif (box->original_4cc == GF_ISOM_BOX_TYPE_JP) {\n\t\t\t\tu8 *c = (u8 *) box->data;\n\t\t\t\tif ((box->dataSize==4) && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A))\n\t\t\t\t\tmov->is_jp2 = 1;\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t} else {\n\t\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\t\tcase GF_ISOM_BOX_TYPE_PRFT:\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (!(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\t\/\/keep the last one read\n\t\t\t\tif (mov->last_producer_ref_time)\n\t\t\t\t\tgf_isom_box_del(a);\n\t\t\t\telse\n\t\t\t\t\tmov->last_producer_ref_time = (GF_ProducerReferenceTimeBox *)a;\n\t\t\t\tbreak;\n\t\t\t}\n#endif\n\t\t\/\/fallthrough\n\t\tcase GF_ISOM_BOX_TYPE_EMSG:\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\tif (!mov->emsgs) mov->emsgs = gf_list_new();\n\t\t\t\tgf_list_add(mov->emsgs, a);\n\t\t\t\tbreak;\n\t\t\t}\n#endif\n\t\tcase GF_ISOM_BOX_TYPE_MFRA:\n\t\tcase GF_ISOM_BOX_TYPE_MFRO:\n\t\t\t\/\/only keep for dump mode, otherwise we ignore these boxes and we don't want to carry them over in non-fragmented file\n\t\t\tif (! (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) {\n\t\t\t\ttotSize += a->size;\n\t\t\t\tgf_isom_box_del(a);\n\t\t\t\tbreak;\n\t\t\t}\n\t\tdefault:\n\t\t\ttotSize += a->size;\n\t\t\te = gf_list_add(mov->TopBoxes, a);\n\t\t\tif (e) return e;\n\t\t\tbreak;\n\t\t}\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\/*remember where we left, in case we append an entire number of movie fragments*\/\n\t\tmov->current_top_box_start = gf_bs_get_position(mov->movieFileMap->bs) + mov->bytes_removed;\n#endif\n\t}\n\n\t\/*we need at least moov or meta*\/\n\tif (!mov->moov && !mov->meta\n#ifndef GPAC_DISABLE_ISOM_FRAGMENTS\n\t        && !mov->moof && !mov->is_index_segment\n#endif\n\t   ) {\n\t\treturn GF_ISOM_INCOMPLETE_FILE;\n\t}\n\t\/*we MUST have movie header*\/\n\tif (!gf_opts_get_bool(\"core\", \"no-check\")) {\n\t\tif (mov->moov && !mov->moov->mvhd) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MVHD in MOOV!\\n\"));\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\n\t\t\/*we MUST have meta handler*\/\n\t\tif (mov->meta && !mov->meta->handler) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing handler in META!\\n\"));\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t}\n\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\n\tif (mov->moov) {\n\t\t\/*set the default interleaving time*\/\n\t\tmov->interleavingTime = mov->moov->mvhd->timeScale;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\t\t\/*in edit mode with successfully loaded fragments, delete all fragment signaling since\n\t\tfile is no longer fragmented*\/\n\t\tif ((mov->openMode > GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS) && mov->moov->mvex) {\n\t\t\tgf_isom_box_del_parent(&mov->moov->child_boxes, (GF_Box *)mov->moov->mvex);\n\t\t\tmov->moov->mvex = NULL;\n\t\t}\n#endif\n\n\t}\n\n\t\/\/create a default mdat if none was found\n\tif (!mov->mdat && (mov->openMode != GF_ISOM_OPEN_READ) && (mov->openMode != GF_ISOM_OPEN_KEEP_FRAGMENTS)) {\n\t\tmov->mdat = (GF_MediaDataBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MDAT);\n\t\tif (!mov->mdat) return GF_OUT_OF_MEM;\n\t\te = gf_list_add(mov->TopBoxes, mov->mdat);\n\t\tif (e) return e;\n\t}\n#endif \/*GPAC_DISABLE_ISOM_WRITE*\/\n\n\treturn GF_OK;\n}","target":1,"code_token_length":5179,"total_token_length":5415,"max_tokens_setting":6144}
+{"idx":208505,"func":"networkstatus_parse_vote_from_string(const char *s, const char **eos_out,\n                                     networkstatus_type_t ns_type)\n{\n  smartlist_t *tokens = smartlist_create();\n  smartlist_t *rs_tokens = NULL, *footer_tokens = NULL;\n  networkstatus_voter_info_t *voter = NULL;\n  networkstatus_t *ns = NULL;\n  digests_t ns_digests;\n  const char *cert, *end_of_header, *end_of_footer, *s_dup = s;\n  directory_token_t *tok;\n  int ok;\n  struct in_addr in;\n  int i, inorder, n_signatures = 0;\n  memarea_t *area = NULL, *rs_area = NULL;\n  consensus_flavor_t flav = FLAV_NS;\n\n  tor_assert(s);\n\n  if (eos_out)\n    *eos_out = NULL;\n\n  if (router_get_networkstatus_v3_hashes(s, &ns_digests)) {\n    log_warn(LD_DIR, \"Unable to compute digest of network-status\");\n    goto err;\n  }\n\n  area = memarea_new();\n  end_of_header = find_start_of_next_routerstatus(s);\n  if (tokenize_string(area, s, end_of_header, tokens,\n                      (ns_type == NS_TYPE_CONSENSUS) ?\n                      networkstatus_consensus_token_table :\n                      networkstatus_token_table, 0)) {\n    log_warn(LD_DIR, \"Error tokenizing network-status vote header\");\n    goto err;\n  }\n\n  ns = tor_malloc_zero(sizeof(networkstatus_t));\n  memcpy(&ns->digests, &ns_digests, sizeof(ns_digests));\n\n  tok = find_by_keyword(tokens, K_NETWORK_STATUS_VERSION);\n  tor_assert(tok);\n  if (tok->n_args > 1) {\n    int flavor = networkstatus_parse_flavor_name(tok->args[1]);\n    if (flavor < 0) {\n      log_warn(LD_DIR, \"Can't parse document with unknown flavor %s\",\n               escaped(tok->args[2]));\n      goto err;\n    }\n    ns->flavor = flav = flavor;\n  }\n  if (flav != FLAV_NS && ns_type != NS_TYPE_CONSENSUS) {\n    log_warn(LD_DIR, \"Flavor found on non-consensus networkstatus.\");\n    goto err;\n  }\n\n  if (ns_type != NS_TYPE_CONSENSUS) {\n    const char *end_of_cert = NULL;\n    if (!(cert = strstr(s, \"\\ndir-key-certificate-version\")))\n      goto err;\n    ++cert;\n    ns->cert = authority_cert_parse_from_string(cert, &end_of_cert);\n    if (!ns->cert || !end_of_cert || end_of_cert > end_of_header)\n      goto err;\n  }\n\n  tok = find_by_keyword(tokens, K_VOTE_STATUS);\n  tor_assert(tok->n_args);\n  if (!strcmp(tok->args[0], \"vote\")) {\n    ns->type = NS_TYPE_VOTE;\n  } else if (!strcmp(tok->args[0], \"consensus\")) {\n    ns->type = NS_TYPE_CONSENSUS;\n  } else if (!strcmp(tok->args[0], \"opinion\")) {\n    ns->type = NS_TYPE_OPINION;\n  } else {\n    log_warn(LD_DIR, \"Unrecognized vote status %s in network-status\",\n             escaped(tok->args[0]));\n    goto err;\n  }\n  if (ns_type != ns->type) {\n    log_warn(LD_DIR, \"Got the wrong kind of v3 networkstatus.\");\n    goto err;\n  }\n\n  if (ns->type == NS_TYPE_VOTE || ns->type == NS_TYPE_OPINION) {\n    tok = find_by_keyword(tokens, K_PUBLISHED);\n    if (parse_iso_time(tok->args[0], &ns->published))\n      goto err;\n\n    ns->supported_methods = smartlist_create();\n    tok = find_opt_by_keyword(tokens, K_CONSENSUS_METHODS);\n    if (tok) {\n      for (i=0; i < tok->n_args; ++i)\n        smartlist_add(ns->supported_methods, tor_strdup(tok->args[i]));\n    } else {\n      smartlist_add(ns->supported_methods, tor_strdup(\"1\"));\n    }\n  } else {\n    tok = find_opt_by_keyword(tokens, K_CONSENSUS_METHOD);\n    if (tok) {\n      ns->consensus_method = (int)tor_parse_long(tok->args[0], 10, 1, INT_MAX,\n                                                 &ok, NULL);\n      if (!ok)\n        goto err;\n    } else {\n      ns->consensus_method = 1;\n    }\n  }\n\n  tok = find_by_keyword(tokens, K_VALID_AFTER);\n  if (parse_iso_time(tok->args[0], &ns->valid_after))\n    goto err;\n\n  tok = find_by_keyword(tokens, K_FRESH_UNTIL);\n  if (parse_iso_time(tok->args[0], &ns->fresh_until))\n    goto err;\n\n  tok = find_by_keyword(tokens, K_VALID_UNTIL);\n  if (parse_iso_time(tok->args[0], &ns->valid_until))\n    goto err;\n\n  tok = find_by_keyword(tokens, K_VOTING_DELAY);\n  tor_assert(tok->n_args >= 2);\n  ns->vote_seconds =\n    (int) tor_parse_long(tok->args[0], 10, 0, INT_MAX, &ok, NULL);\n  if (!ok)\n    goto err;\n  ns->dist_seconds =\n    (int) tor_parse_long(tok->args[1], 10, 0, INT_MAX, &ok, NULL);\n  if (!ok)\n    goto err;\n  if (ns->valid_after + MIN_VOTE_INTERVAL > ns->fresh_until) {\n    log_warn(LD_DIR, \"Vote\/consensus freshness interval is too short\");\n    goto err;\n  }\n  if (ns->valid_after + MIN_VOTE_INTERVAL*2 > ns->valid_until) {\n    log_warn(LD_DIR, \"Vote\/consensus liveness interval is too short\");\n    goto err;\n  }\n  if (ns->vote_seconds < MIN_VOTE_SECONDS) {\n    log_warn(LD_DIR, \"Vote seconds is too short\");\n    goto err;\n  }\n  if (ns->dist_seconds < MIN_DIST_SECONDS) {\n    log_warn(LD_DIR, \"Dist seconds is too short\");\n    goto err;\n  }\n\n  if ((tok = find_opt_by_keyword(tokens, K_CLIENT_VERSIONS))) {\n    ns->client_versions = tor_strdup(tok->args[0]);\n  }\n  if ((tok = find_opt_by_keyword(tokens, K_SERVER_VERSIONS))) {\n    ns->server_versions = tor_strdup(tok->args[0]);\n  }\n\n  tok = find_by_keyword(tokens, K_KNOWN_FLAGS);\n  ns->known_flags = smartlist_create();\n  inorder = 1;\n  for (i = 0; i < tok->n_args; ++i) {\n    smartlist_add(ns->known_flags, tor_strdup(tok->args[i]));\n    if (i>0 && strcmp(tok->args[i-1], tok->args[i])>= 0) {\n      log_warn(LD_DIR, \"%s >= %s\", tok->args[i-1], tok->args[i]);\n      inorder = 0;\n    }\n  }\n  if (!inorder) {\n    log_warn(LD_DIR, \"known-flags not in order\");\n    goto err;\n  }\n\n  tok = find_opt_by_keyword(tokens, K_PARAMS);\n  if (tok) {\n    inorder = 1;\n    ns->net_params = smartlist_create();\n    for (i = 0; i < tok->n_args; ++i) {\n      int ok=0;\n      char *eq = strchr(tok->args[i], '=');\n      if (!eq) {\n        log_warn(LD_DIR, \"Bad element '%s' in params\", escaped(tok->args[i]));\n        goto err;\n      }\n      tor_parse_long(eq+1, 10, INT32_MIN, INT32_MAX, &ok, NULL);\n      if (!ok) {\n        log_warn(LD_DIR, \"Bad element '%s' in params\", escaped(tok->args[i]));\n        goto err;\n      }\n      if (i > 0 && strcmp(tok->args[i-1], tok->args[i]) >= 0) {\n        log_warn(LD_DIR, \"%s >= %s\", tok->args[i-1], tok->args[i]);\n        inorder = 0;\n      }\n      smartlist_add(ns->net_params, tor_strdup(tok->args[i]));\n    }\n    if (!inorder) {\n      log_warn(LD_DIR, \"params not in order\");\n      goto err;\n    }\n  }\n\n  ns->voters = smartlist_create();\n\n  SMARTLIST_FOREACH_BEGIN(tokens, directory_token_t *, _tok) {\n    tok = _tok;\n    if (tok->tp == K_DIR_SOURCE) {\n      tor_assert(tok->n_args >= 6);\n\n      if (voter)\n        smartlist_add(ns->voters, voter);\n      voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t));\n      voter->sigs = smartlist_create();\n      if (ns->type != NS_TYPE_CONSENSUS)\n        memcpy(voter->vote_digest, ns_digests.d[DIGEST_SHA1], DIGEST_LEN);\n\n      voter->nickname = tor_strdup(tok->args[0]);\n      if (strlen(tok->args[1]) != HEX_DIGEST_LEN ||\n          base16_decode(voter->identity_digest, sizeof(voter->identity_digest),\n                        tok->args[1], HEX_DIGEST_LEN) < 0) {\n        log_warn(LD_DIR, \"Error decoding identity digest %s in \"\n                 \"network-status vote.\", escaped(tok->args[1]));\n        goto err;\n      }\n      if (ns->type != NS_TYPE_CONSENSUS &&\n          tor_memneq(ns->cert->cache_info.identity_digest,\n                 voter->identity_digest, DIGEST_LEN)) {\n        log_warn(LD_DIR,\"Mismatch between identities in certificate and vote\");\n        goto err;\n      }\n      voter->address = tor_strdup(tok->args[2]);\n      if (!tor_inet_aton(tok->args[3], &in)) {\n        log_warn(LD_DIR, \"Error decoding IP address %s in network-status.\",\n                 escaped(tok->args[3]));\n        goto err;\n      }\n      voter->addr = ntohl(in.s_addr);\n      voter->dir_port = (uint16_t)\n        tor_parse_long(tok->args[4], 10, 0, 65535, &ok, NULL);\n      if (!ok)\n        goto err;\n      voter->or_port = (uint16_t)\n        tor_parse_long(tok->args[5], 10, 0, 65535, &ok, NULL);\n      if (!ok)\n        goto err;\n    } else if (tok->tp == K_CONTACT) {\n      if (!voter || voter->contact) {\n        log_warn(LD_DIR, \"contact element is out of place.\");\n        goto err;\n      }\n      voter->contact = tor_strdup(tok->args[0]);\n    } else if (tok->tp == K_VOTE_DIGEST) {\n      tor_assert(ns->type == NS_TYPE_CONSENSUS);\n      tor_assert(tok->n_args >= 1);\n      if (!voter || ! tor_digest_is_zero(voter->vote_digest)) {\n        log_warn(LD_DIR, \"vote-digest element is out of place.\");\n        goto err;\n      }\n      if (strlen(tok->args[0]) != HEX_DIGEST_LEN ||\n        base16_decode(voter->vote_digest, sizeof(voter->vote_digest),\n                      tok->args[0], HEX_DIGEST_LEN) < 0) {\n        log_warn(LD_DIR, \"Error decoding vote digest %s in \"\n                 \"network-status consensus.\", escaped(tok->args[0]));\n        goto err;\n      }\n    }\n  } SMARTLIST_FOREACH_END(_tok);\n  if (voter) {\n    smartlist_add(ns->voters, voter);\n    voter = NULL;\n  }\n  if (smartlist_len(ns->voters) == 0) {\n    log_warn(LD_DIR, \"Missing dir-source elements in a vote networkstatus.\");\n    goto err;\n  } else if (ns->type != NS_TYPE_CONSENSUS && smartlist_len(ns->voters) != 1) {\n    log_warn(LD_DIR, \"Too many dir-source elements in a vote networkstatus.\");\n    goto err;\n  }\n\n  if (ns->type != NS_TYPE_CONSENSUS &&\n      (tok = find_opt_by_keyword(tokens, K_LEGACY_DIR_KEY))) {\n    int bad = 1;\n    if (strlen(tok->args[0]) == HEX_DIGEST_LEN) {\n      networkstatus_voter_info_t *voter = smartlist_get(ns->voters, 0);\n      if (base16_decode(voter->legacy_id_digest, DIGEST_LEN,\n                        tok->args[0], HEX_DIGEST_LEN)<0)\n        bad = 1;\n      else\n        bad = 0;\n    }\n    if (bad) {\n      log_warn(LD_DIR, \"Invalid legacy key digest %s on vote.\",\n               escaped(tok->args[0]));\n    }\n  }\n\n  \/* Parse routerstatus lines. *\/\n  rs_tokens = smartlist_create();\n  rs_area = memarea_new();\n  s = end_of_header;\n  ns->routerstatus_list = smartlist_create();\n\n  while (!strcmpstart(s, \"r \")) {\n    if (ns->type != NS_TYPE_CONSENSUS) {\n      vote_routerstatus_t *rs = tor_malloc_zero(sizeof(vote_routerstatus_t));\n      if (routerstatus_parse_entry_from_string(rs_area, &s, rs_tokens, ns,\n                                               rs, 0, 0))\n        smartlist_add(ns->routerstatus_list, rs);\n      else {\n        tor_free(rs->version);\n        tor_free(rs);\n      }\n    } else {\n      routerstatus_t *rs;\n      if ((rs = routerstatus_parse_entry_from_string(rs_area, &s, rs_tokens,\n                                                     NULL, NULL,\n                                                     ns->consensus_method,\n                                                     flav)))\n        smartlist_add(ns->routerstatus_list, rs);\n    }\n  }\n  for (i = 1; i < smartlist_len(ns->routerstatus_list); ++i) {\n    routerstatus_t *rs1, *rs2;\n    if (ns->type != NS_TYPE_CONSENSUS) {\n      vote_routerstatus_t *a = smartlist_get(ns->routerstatus_list, i-1);\n      vote_routerstatus_t *b = smartlist_get(ns->routerstatus_list, i);\n      rs1 = &a->status; rs2 = &b->status;\n    } else {\n      rs1 = smartlist_get(ns->routerstatus_list, i-1);\n      rs2 = smartlist_get(ns->routerstatus_list, i);\n    }\n    if (fast_memcmp(rs1->identity_digest, rs2->identity_digest, DIGEST_LEN)\n        >= 0) {\n      log_warn(LD_DIR, \"Vote networkstatus entries not sorted by identity \"\n               \"digest\");\n      goto err;\n    }\n  }\n\n  \/* Parse footer; check signature. *\/\n  footer_tokens = smartlist_create();\n  if ((end_of_footer = strstr(s, \"\\nnetwork-status-version \")))\n    ++end_of_footer;\n  else\n    end_of_footer = s + strlen(s);\n  if (tokenize_string(area,s, end_of_footer, footer_tokens,\n                      networkstatus_vote_footer_token_table, 0)) {\n    log_warn(LD_DIR, \"Error tokenizing network-status vote footer.\");\n    goto err;\n  }\n\n  {\n    int found_sig = 0;\n    SMARTLIST_FOREACH_BEGIN(footer_tokens, directory_token_t *, _tok) {\n      tok = _tok;\n      if (tok->tp == K_DIRECTORY_SIGNATURE)\n        found_sig = 1;\n      else if (found_sig) {\n        log_warn(LD_DIR, \"Extraneous token after first directory-signature\");\n        goto err;\n      }\n    } SMARTLIST_FOREACH_END(_tok);\n  }\n\n  if ((tok = find_opt_by_keyword(footer_tokens, K_DIRECTORY_FOOTER))) {\n    if (tok != smartlist_get(footer_tokens, 0)) {\n      log_warn(LD_DIR, \"Misplaced directory-footer token\");\n      goto err;\n    }\n  }\n\n  tok = find_opt_by_keyword(footer_tokens, K_BW_WEIGHTS);\n  if (tok) {\n    ns->weight_params = smartlist_create();\n    for (i = 0; i < tok->n_args; ++i) {\n      int ok=0;\n      char *eq = strchr(tok->args[i], '=');\n      if (!eq) {\n        log_warn(LD_DIR, \"Bad element '%s' in weight params\",\n                 escaped(tok->args[i]));\n        goto err;\n      }\n      tor_parse_long(eq+1, 10, INT32_MIN, INT32_MAX, &ok, NULL);\n      if (!ok) {\n        log_warn(LD_DIR, \"Bad element '%s' in params\", escaped(tok->args[i]));\n        goto err;\n      }\n      smartlist_add(ns->weight_params, tor_strdup(tok->args[i]));\n    }\n  }\n\n  SMARTLIST_FOREACH_BEGIN(footer_tokens, directory_token_t *, _tok) {\n    char declared_identity[DIGEST_LEN];\n    networkstatus_voter_info_t *v;\n    document_signature_t *sig;\n    const char *id_hexdigest = NULL;\n    const char *sk_hexdigest = NULL;\n    digest_algorithm_t alg = DIGEST_SHA1;\n    tok = _tok;\n    if (tok->tp != K_DIRECTORY_SIGNATURE)\n      continue;\n    tor_assert(tok->n_args >= 2);\n    if (tok->n_args == 2) {\n      id_hexdigest = tok->args[0];\n      sk_hexdigest = tok->args[1];\n    } else {\n      const char *algname = tok->args[0];\n      int a;\n      id_hexdigest = tok->args[1];\n      sk_hexdigest = tok->args[2];\n      a = crypto_digest_algorithm_parse_name(algname);\n      if (a<0) {\n        log_warn(LD_DIR, \"Unknown digest algorithm %s; skipping\",\n                 escaped(algname));\n        continue;\n      }\n      alg = a;\n    }\n\n    if (!tok->object_type ||\n        strcmp(tok->object_type, \"SIGNATURE\") ||\n        tok->object_size < 128 || tok->object_size > 512) {\n      log_warn(LD_DIR, \"Bad object type or length on directory-signature\");\n      goto err;\n    }\n\n    if (strlen(id_hexdigest) != HEX_DIGEST_LEN ||\n        base16_decode(declared_identity, sizeof(declared_identity),\n                      id_hexdigest, HEX_DIGEST_LEN) < 0) {\n      log_warn(LD_DIR, \"Error decoding declared identity %s in \"\n               \"network-status vote.\", escaped(id_hexdigest));\n      goto err;\n    }\n    if (!(v = networkstatus_get_voter_by_id(ns, declared_identity))) {\n      log_warn(LD_DIR, \"ID on signature on network-status vote does not match \"\n               \"any declared directory source.\");\n      goto err;\n    }\n    sig = tor_malloc_zero(sizeof(document_signature_t));\n    memcpy(sig->identity_digest, v->identity_digest, DIGEST_LEN);\n    sig->alg = alg;\n    if (strlen(sk_hexdigest) != HEX_DIGEST_LEN ||\n        base16_decode(sig->signing_key_digest, sizeof(sig->signing_key_digest),\n                      sk_hexdigest, HEX_DIGEST_LEN) < 0) {\n      log_warn(LD_DIR, \"Error decoding declared signing key digest %s in \"\n               \"network-status vote.\", escaped(sk_hexdigest));\n      tor_free(sig);\n      goto err;\n    }\n\n    if (ns->type != NS_TYPE_CONSENSUS) {\n      if (tor_memneq(declared_identity, ns->cert->cache_info.identity_digest,\n                 DIGEST_LEN)) {\n        log_warn(LD_DIR, \"Digest mismatch between declared and actual on \"\n                 \"network-status vote.\");\n        tor_free(sig);\n        goto err;\n      }\n    }\n\n    if (voter_get_sig_by_algorithm(v, sig->alg)) {\n      \/* We already parsed a vote with this algorithm from this voter. Use the\n         first one. *\/\n      log_fn(LOG_PROTOCOL_WARN, LD_DIR, \"We received a networkstatus \"\n             \"that contains two votes from the same voter with the same \"\n             \"algorithm. Ignoring the second vote.\");\n      tor_free(sig);\n      continue;\n    }\n\n    if (ns->type != NS_TYPE_CONSENSUS) {\n      if (check_signature_token(ns_digests.d[DIGEST_SHA1], DIGEST_LEN,\n                                tok, ns->cert->signing_key, 0,\n                                \"network-status vote\")) {\n        tor_free(sig);\n        goto err;\n      }\n      sig->good_signature = 1;\n    } else {\n      if (tok->object_size >= INT_MAX || tok->object_size >= SIZE_T_CEILING) {\n        tor_free(sig);\n        goto err;\n      }\n      sig->signature = tor_memdup(tok->object_body, tok->object_size);\n      sig->signature_len = (int) tok->object_size;\n    }\n    smartlist_add(v->sigs, sig);\n\n    ++n_signatures;\n  } SMARTLIST_FOREACH_END(_tok);\n\n  if (! n_signatures) {\n    log_warn(LD_DIR, \"No signatures on networkstatus vote.\");\n    goto err;\n  } else if (ns->type == NS_TYPE_VOTE && n_signatures != 1) {\n    log_warn(LD_DIR, \"Received more than one signature on a \"\n             \"network-status vote.\");\n    goto err;\n  }\n\n  if (eos_out)\n    *eos_out = end_of_footer;\n\n  goto done;\n err:\n  dump_desc(s_dup, \"v3 networkstatus\");\n  networkstatus_vote_free(ns);\n  ns = NULL;\n done:\n  if (tokens) {\n    SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));\n    smartlist_free(tokens);\n  }\n  if (voter) {\n    if (voter->sigs) {\n      SMARTLIST_FOREACH(voter->sigs, document_signature_t *, sig,\n                        document_signature_free(sig));\n      smartlist_free(voter->sigs);\n    }\n    tor_free(voter->nickname);\n    tor_free(voter->address);\n    tor_free(voter->contact);\n    tor_free(voter);\n  }\n  if (rs_tokens) {\n    SMARTLIST_FOREACH(rs_tokens, directory_token_t *, t, token_clear(t));\n    smartlist_free(rs_tokens);\n  }\n  if (footer_tokens) {\n    SMARTLIST_FOREACH(footer_tokens, directory_token_t *, t, token_clear(t));\n    smartlist_free(footer_tokens);\n  }\n  if (area) {\n    DUMP_AREA(area, \"v3 networkstatus\");\n    memarea_drop_all(area);\n  }\n  if (rs_area)\n    memarea_drop_all(rs_area);\n\n  return ns;\n}","target":1,"code_token_length":4889,"total_token_length":5125,"max_tokens_setting":6144}
+{"idx":343227,"func":"int pureftpd_start(int argc, char *argv[], const char *home_directory_)\n{\n#ifndef NO_GETOPT_LONG\n    int option_index = 0;\n#endif\n    int fodder;\n    int bypass_ipv6 = 0;\n    struct passwd *pw;\n\n    (void) home_directory_;\n#ifdef NON_ROOT_FTP\n    home_directory = home_directory_;\n#endif\n    client_init_reply_buf();\n\n#ifdef HAVE_GETPAGESIZE\n    page_size = (size_t) getpagesize();\n#elif defined(_SC_PAGESIZE)\n    page_size = (size_t) sysconf(_SC_PAGESIZE);\n#elif defined(_SC_PAGE_SIZE)\n    page_size = (size_t) sysconf(_SC_PAGE_SIZE);\n#else\n    page_size = (size_t) 4096U;\n#endif\n\n#ifdef HAVE_SETLOCALE\n# ifdef LC_MESSAGES\n    (void) setlocale(LC_MESSAGES, MESSAGES_LOCALE);\n# endif\n# ifdef LC_CTYPE\n    (void) setlocale(LC_CTYPE, \"C\");\n# endif\n# ifdef LC_COLLATE\n    (void) setlocale(LC_COLLATE, \"C\");\n# endif\n#endif\n\n    init_tz();\n    (void) strerror(ENOENT);\n\n#ifndef SAVE_DESCRIPTORS\n    openlog(\"pure-ftpd\", LOG_NDELAY | log_pid, DEFAULT_FACILITY);\n#endif\n\n#ifdef USE_CAPABILITIES\n    set_initial_caps();\n#endif\n    set_signals();\n\n    loggedin = 0;\n\n#ifdef BANNER_ENVIRON\n# ifdef COOKIE\n    {\n        const char *a;\n\n        if ((a = getenv(\"BANNER\")) != NULL && *a != 0) {\n            fortunes_file = strdup(a);\n        }\n    }\n# endif\n#endif\n\n#ifndef MINIMAL\n    if (argc == 2 && *argv[1] != '-' &&\n        sc_build_command_line_from_file(argv[1], NULL, simpleconf_options,\n                                        (sizeof simpleconf_options) \/\n                                        (sizeof simpleconf_options[0]),\n                                        argv[0], &argc, &argv) != 0) {\n        die(421, LOG_ERR, MSG_CONF_ERR);\n    }\n#endif\n\n    while ((fodder =\n#ifndef NO_GETOPT_LONG\n            getopt_long(argc, argv, GETOPT_OPTIONS, long_options, &option_index)\n#else\n            getopt(argc, argv, GETOPT_OPTIONS)\n#endif\n            ) != -1) {\n        switch (fodder) {\n        case 's': {\n            if ((pw = getpwnam(\"ftp\")) != NULL ||\n                (pw = getpwnam(\"_ftp\")) != NULL) {\n                warez = pw->pw_uid;\n            } else {\n                logfile(LOG_ERR, MSG_NO_FTP_ACCOUNT);\n            }\n            break;\n        }\n        case '0': {\n            no_truncate = 1;\n            break;\n        }\n        case '4': {\n            bypass_ipv6 = 1;\n            break;\n        }\n        case '6': {\n            no_ipv4 = 1;\n            break;\n        }\n        case '1': {\n            log_pid = LOG_PID;\n            break;\n        }\n#ifndef NO_STANDALONE\n        case 'S': {\n            char *struck;\n\n            if ((struck = strchr(optarg, ',')) != NULL) {\n                *struck = 0;\n                if (*optarg != 0) {\n                    if (standalone_ip == NULL &&\n                        (standalone_ip = strdup(optarg)) == NULL) {\n                        die_mem();\n                    }\n                }\n                *struck = ',';\n                if (struck[1] != 0) {\n                    if ((standalone_port = strdup(struck + 1)) == NULL) {\n                        die_mem();\n                    }\n                }\n            } else {\n                if ((standalone_port = strdup(optarg)) == NULL) {\n                    die_mem();\n                }\n            }\n            break;\n        }\n#endif\n        case 'D': {\n            force_ls_a = 1;\n            break;\n        }\n#ifdef THROTTLING\n        case 't':\n        case 'T': {\n            char *struck;\n            const char *tr_bw_ul = NULL;\n            const char *tr_bw_dl = NULL;\n\n            if ((struck = strchr(optarg, ':')) != NULL) {\n                *struck = 0;\n                if (*optarg != 0) {\n                    tr_bw_ul = optarg;\n                }\n                if (struck[1] != 0) {\n                    tr_bw_dl = &struck[1];\n                }\n            } else {\n                tr_bw_ul = tr_bw_dl = optarg;\n            }\n            if ((tr_bw_ul == NULL || *tr_bw_ul == 0) &&\n                (tr_bw_dl == NULL || *tr_bw_dl == 0)) {\n                bad_bw:\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_THROTTLING \": %s\" , optarg);\n            }\n            if (tr_bw_dl != NULL) {\n                if ((throttling_bandwidth_dl =\n                     strtoul(tr_bw_dl, NULL, 0) * 1024UL) == 0UL) {\n                    goto bad_bw;\n                }\n            }\n            if (tr_bw_ul != NULL) {\n                if ((throttling_bandwidth_ul =\n                     strtoul(tr_bw_ul, NULL, 0) * 1024UL) == 0UL) {\n                    goto bad_bw;\n                }\n            }\n            throttling_delay = 1000000 \/\n                (throttling_bandwidth_dl | throttling_bandwidth_ul);\n            if (fodder == 't') {\n                throttling = 1;\n            } else {\n                throttling = 2;\n            }\n            break;\n        }\n#endif\n        case 'a': {\n            const char *nptr;\n            char *endptr;\n\n            nptr = optarg;\n            endptr = NULL;\n            chroot_trustedgid = strtoul(nptr, &endptr, 0);\n            if (!nptr || !*nptr || !endptr || *endptr) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_TRUSTED_GID \": %s\" , optarg);\n            }\n            userchroot = 1;\n            break;\n        }\n        case 'x': {\n            dot_write_ok = 0;\n            break;\n        }\n        case 'X': {\n            dot_write_ok = dot_read_ok = 0;\n            break;\n        }\n        case 'z': {\n            dot_read_anon_ok = 1;\n            break;\n        }\n        case 'Z': {\n            be_customer_proof = 1;\n            break;\n        }\n        case 'A': {\n            userchroot = 2;\n            break;\n        }\n        case 'w': {\n            allowfxp = 1;\n            break;\n        }\n        case 'W': {\n            allowfxp = 2;\n            break;\n        }\n        case 'd': {\n            if (logging < 2) {\n                logging++;\n            }\n            break;\n        }\n        case 'b': {\n            broken_client_compat = 1;\n            break;\n        }\n        case 'c': {\n            const char *nptr;\n            char *endptr;\n\n            nptr = optarg;\n            endptr = NULL;\n            maxusers = (unsigned int) strtoul(nptr, &endptr, 0);\n            if (!nptr || !*nptr || !endptr || *endptr || !maxusers) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_USER_LIMIT \": %s\" , optarg);\n            }\n            break;\n        }\n#ifndef NO_STANDALONE\n        case 'B': {\n            daemonize = 1;\n            break;\n        }\n        case 'C': {\n            const char *nptr;\n            char *endptr;\n\n            nptr = optarg;\n            endptr = NULL;\n            maxip = (unsigned int) strtoul(nptr, &endptr, 0);\n            if (!nptr || !*nptr || !endptr || *endptr || !maxip) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_USER_LIMIT \": %s\" , optarg);\n            }\n            break;\n        }\n#endif\n#ifdef PER_USER_LIMITS\n        case 'y': {\n            int ret;\n\n            ret = sscanf(optarg, \"%u:%u\", &per_user_max, &per_anon_max);\n            if (ret != 2) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_USER_LIMIT \": %s\" , optarg);\n            }\n            break;\n        }\n#endif\n#ifdef WITH_TLS\n        case '2': {\n            char *struck;\n            char *key_file_;\n\n            if ((struck = strchr(optarg, ',')) != NULL) {\n                *struck = 0;\n                key_file_ = struck + 1;\n            } else {\n                key_file_ = optarg;\n            }\n            if (*optarg == 0 || *key_file_ == 0) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": TLS\");\n            }\n            if ((cert_file = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            if ((key_file = strdup(key_file_)) == NULL) {\n                die_mem();\n            }\n            break;\n        }\n        case '3':\n            tls_extcert_parse(optarg);\n            use_extcert++;\n            break;\n        case 'Y': {\n            if ((enforce_tls_auth = atoi(optarg)) < 0 || enforce_tls_auth > 3) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": TLS\");\n            }\n            break;\n        }\n        case 'J': {\n            while (*optarg == '-') {\n                if (strncmp(optarg, \"-S:\", sizeof \"-S:\" - (size_t) 1U) == 0) {\n                    optarg += sizeof \"-S:\" - (size_t) 1U;\n                } else if (strncmp(optarg, \"-C:\", sizeof \"-C:\" - (size_t) 1U) == 0) {\n                    optarg += sizeof \"-C:\" - (size_t) 1U;\n                    ssl_verify_client_cert = 1;\n                }\n            }\n            if ((tlsciphersuite = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            break;\n        }\n#endif\n        case 'e': {\n            anon_only = 1;\n            break;\n        }\n        case 'E': {\n            anon_only = -1;\n            break;\n        }\n#ifdef COOKIE\n        case 'F': {\n# ifdef BANNER_ENVIRON\n            free(fortunes_file);\n# endif\n            fortunes_file = strdup(optarg);\n            break;\n        }\n#endif\n        case 'f': {\n            int n = 0;\n\n            if (strcasecmp(optarg, \"none\") == 0) {\n                no_syslog = 1;\n                break;\n            }\n            while (facilitynames[n].c_name &&\n                   strcasecmp(facilitynames[n].c_name, optarg) != 0) {\n                n++;\n            }\n            if (facilitynames[n].c_name) {\n                syslog_facility = facilitynames[n].c_val;\n            } else {\n                logfile(LOG_ERR,\n                        MSG_CONF_ERR \": \" MSG_ILLEGAL_FACILITY \": %s\", optarg);\n            }\n            break;\n        }\n        case 'l': {\n            const Authentication *auth_list_pnt = auth_list;\n            const char *opt = optarg;\n            Authentications *new_auth;\n            size_t auth_name_len;\n\n            for (;;) {\n                auth_name_len = strlen(auth_list_pnt->name);\n                if (strncasecmp(opt, auth_list_pnt->name,\n                                auth_name_len) == 0) {\n                    char *file = NULL;\n\n                    opt += auth_name_len;\n                    if (*opt == ':') {\n                        opt++;\n                        if (*opt != 0) {\n                            if ((file = strdup(opt)) == NULL) {\n                                die_mem();\n                            }\n                        }\n                    }\n                    if (auth_list_pnt->parse != NULL) {\n                        auth_list_pnt->parse(file);\n                    }\n                    if ((new_auth = malloc(sizeof *new_auth)) == NULL) {\n                        die_mem();\n                    }\n                    new_auth->auth = auth_list_pnt;\n                    new_auth->conf_file = file;\n                    new_auth->next = NULL;\n                    if (last_authentications == NULL) {\n                        first_authentications = new_auth;\n                    } else {\n                        last_authentications->next = new_auth;\n                    }\n                    last_authentications = new_auth;\n\n                    break;\n                }\n                auth_list_pnt++;\n                if (auth_list_pnt->name == NULL) {\n                    die(421, LOG_ERR, MSG_AUTH_UNKNOWN \": %s\", opt);\n                }\n            }\n\n            break;\n        }\n        case 'm': {\n            const char *nptr;\n            char *endptr;\n\n            nptr = optarg;\n            endptr = NULL;\n            maxload = strtod(nptr, &endptr);\n            if (!nptr || !*nptr || !endptr || *endptr || maxload <= 0.0) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \"\n                    MSG_ILLEGAL_LOAD_LIMIT \": %s\" , optarg);\n            }\n            break;\n        }\n        case 'M': {\n            allow_anon_mkdir = 1;\n            break;\n        }\n        case 'N': {\n            disallow_passive = 1;\n            break;\n        }\n#if defined(WITH_UPLOAD_SCRIPT)\n        case 'o': {\n            do_upload_script = 1;\n            break;\n        }\n#endif\n#ifdef WITH_ALTLOG\n        case 'O': {\n            char *optarg_copy;\n            char *delpoint;\n\n            if ((optarg_copy = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            if ((delpoint = strchr(optarg_copy, ALTLOG_DELIMITER)) == NULL) {\n                altlog_format = ALTLOG_DEFAULT;\n                delpoint = optarg_copy;\n            } else {\n                const AltLogPrefixes *altlogprefixes_pnt = altlogprefixes;\n\n                *delpoint++ = 0;\n                do {\n                    if (strcasecmp(optarg_copy,\n                                   altlogprefixes_pnt->prefix) == 0) {\n                        altlog_format = altlogprefixes_pnt->format;\n                        break;\n                    }\n                    altlogprefixes_pnt++;\n                } while (altlogprefixes_pnt->prefix != NULL);\n                if (altlog_format == ALTLOG_NONE) {\n                    die(421, LOG_ERR,\n                        MSG_CONF_ERR \": \" MSG_UNKNOWN_ALTLOG \": %s\",\n                        optarg_copy);\n                }\n            }\n            if (*delpoint != '\/') {\n                die(421, LOG_ERR,\n                    MSG_CONF_ERR \": \" MSG_SANITY_FILE_FAILURE,\n                    delpoint);\n            }\n            if (altlog_filename == NULL &&\n                (altlog_filename = strdup(delpoint)) == NULL) {\n                die_mem();\n            }\n            (void) free(optarg_copy);\n            break;\n        }\n#endif\n        case 'p': {\n            int ret;\n\n            ret = sscanf(optarg, \"%u:%u\", &firstport, &lastport);\n            if (ret != 2 ||\n                firstport < 1024U || lastport > 65535U\n                || lastport < firstport) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_PORTS_RANGE \": %s\" , optarg);\n            }\n            break;\n        }\n        case 'L': {\n            int ret;\n\n            ret = sscanf(optarg, \"%u:%u\", &max_ls_files, &max_ls_depth);\n            if (ret != 2 ||\n                max_ls_files < 1U || max_ls_depth < 1U) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_LS_LIMITS \": %s\" , optarg);\n            }\n            break;\n        }\n#ifdef QUOTAS\n        case 'n': {\n            int ret;\n\n            ret = sscanf(optarg, \"%llu:%llu\",\n                         &user_quota_files, &user_quota_size);\n            if (ret != 2) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_QUOTA \": %s\" , optarg);\n            }\n            user_quota_size *= (1024ULL * 1024ULL);\n            break;\n        }\n#endif\n        case 'P': {\n            if (force_passive_ip_s == NULL &&\n                (force_passive_ip_s = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            break;\n        }\n#ifdef RATIOS\n        case 'q':\n        case 'Q': {\n            int ret;\n\n            ret = sscanf(optarg, \"%u:%u\", &ratio_upload, &ratio_download);\n            if (ret != 2 ||\n                ratio_upload < 1U || ratio_download < 1U) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_RATIO \": %s\" , optarg);\n            }\n            if (fodder == 'Q') {\n                ratio_for_non_anon = 1;\n            }\n            break;\n        }\n#endif\n        case 'r': {\n            autorename = 1;\n            break;\n        }\n        case 'R': {\n            nochmod = 1;\n            break;\n        }\n        case 'K': {\n            keepallfiles = 1;\n            break;\n        }\n#ifndef NO_STANDALONE\n        case 'g': {\n            if ((pid_file = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            break;\n        }\n#endif\n        case 'G': {\n            disallow_rename = 1;\n            break;\n        }\n        case 'H': {\n            resolve_hostnames = 0;\n            break;\n        }\n        case 'I': {\n            const char *nptr;\n            char *endptr;\n\n            nptr = optarg;\n            endptr = NULL;\n            idletime = strtoul(nptr, &endptr, 0) * 60UL;\n            if (idletime <= 0) {\n                idletime = DEFAULT_IDLE;\n            }\n            break;\n        }\n        case 'i': {\n            anon_noupload = 1;\n            break;\n        }\n        case 'j': {\n            create_home = 1;\n            break;\n        }\n        case 'k': {\n            const char *nptr;\n            char *endptr;\n\n            nptr = optarg;\n            endptr = NULL;\n            maxdiskusagepct = 1.0 - (strtod(nptr, &endptr) \/ 100.0);\n            if (maxdiskusagepct >= 1.0 || maxdiskusagepct < 0.0) {\n                maxdiskusagepct = 0.0;\n            }\n            break;\n        }\n        case 'u': {\n            const char *nptr;\n            char *endptr;\n            long tmp;\n\n            nptr = optarg;\n            endptr = NULL;\n            tmp = strtol(nptr, &endptr, 10);\n            if (!nptr || !*nptr || !endptr || *endptr || tmp < 0) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_UID_LIMIT \": %s\" , optarg);\n            }\n            useruid = (uid_t) tmp;\n            break;\n        }\n        case 'U': {\n            char *optarg_copy;\n            char *struck;\n            const char *tr_umask = NULL;\n            const char *tr_umask_d = NULL;\n\n            if ((optarg_copy = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            if ((struck = strchr(optarg_copy, ':')) != NULL) {\n                *struck = 0;\n                if (*optarg_copy != 0) {\n                    tr_umask = optarg_copy;\n                }\n                if (struck[1] != 0) {\n                    tr_umask_d = &struck[1];\n                }\n            } else {\n                tr_umask = tr_umask_d = optarg_copy;\n            }\n            if ((tr_umask == NULL || *tr_umask == 0) &&\n                (tr_umask_d == NULL || *tr_umask_d == 0)) {\n                bad_umask:\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_UMASK \": %s\",\n                    optarg_copy);\n            }\n            if (tr_umask != NULL) {\n                if ((u_mask =\n                     strtoul(tr_umask, NULL, 8)) > 0777) {\n                    goto bad_umask;\n                }\n            }\n            if (tr_umask_d != NULL) {\n                if ((u_mask_d =\n                     strtoul(tr_umask_d, NULL, 8)) > 0777) {\n                    goto bad_umask;\n                }\n            }\n            (void) free(optarg_copy);\n            break;\n        }\n#ifdef WITH_VIRTUAL_HOSTS\n        case 'V': {\n            if (trustedip == NULL &&\n                (trustedip = malloc(sizeof *trustedip)) == NULL) {\n                die_mem();\n            }\n            if (generic_aton(optarg, trustedip) != 0) {\n                die(421, LOG_ERR, MSG_CONF_ERR \": \" MSG_ILLEGAL_TRUSTED_IP);\n            }\n            break;\n        }\n#endif\n#ifdef WITH_BONJOUR\n        case 'v': {\n            char *rdvname;\n            char *end;\n\n            if ((rdvname = strdup(optarg)) == NULL) {\n                die_mem();\n            }\n            doregistration(rdvname, strtoul(standalone_port, &end, 10));\n            break;\n        }\n#endif\n        case 'h': {\n#ifndef NON_ROOT_FTP\n            if (geteuid() == (uid_t) 0)\n#endif\n            {\n                puts(PACKAGE \" v\" VERSION VERSION_PRIVSEP \"\\n\");\n            }\n#ifndef NO_GETOPT_LONG\n            {\n                const struct option *options = long_options;\n\n                do {\n                    printf(\"-%c\\t--%s\\t%s\\n\", options->val, options->name,\n                           options->has_arg ? \"<opt>\" : \"\");\n                    options++;\n                } while (options->name != NULL);\n            }\n#endif\n            exit(EXIT_SUCCESS);\n        }\n        default:\n            die(421, LOG_ERR, MSG_ILLEGAL_OPTION);\n        }\n    }\n    if (optind < argc) {\n        die(421, LOG_ERR, MSG_INVALID_ARGUMENT, argv[optind]);\n    }\n    if (first_authentications == NULL) {\n        if ((first_authentications =\n             malloc(sizeof *first_authentications)) == NULL) {\n            die_mem();\n        }\n        first_authentications->auth = DEFAULT_AUTHENTICATION;\n        first_authentications->conf_file = NULL;\n        first_authentications->next = NULL;\n    }\n#ifndef NO_STANDALONE\n    dodaemonize();\n#endif\n#ifndef SAVE_DESCRIPTORS\n    if (no_syslog == 0 && (log_pid || syslog_facility != DEFAULT_FACILITY)) {\n        closelog();\n        openlog(\"pure-ftpd\", LOG_NDELAY | log_pid, syslog_facility);\n    }\n#endif\n    (void) umask((mode_t) 0);\n    clearargs(argc, argv);\n    idletime_noop = (double) idletime * 2.0;\n    if (firstport) {\n        unsigned int portmax;\n\n        portmax = (lastport - firstport + 1) \/ 2;\n        if (!maxusers || maxusers > portmax) {\n            maxusers = portmax;    \/* ... so we don't run out of ports *\/\n        }\n    }\n    if (bypass_ipv6 == 0) {\n        check_ipv6_support();\n    }\n#if defined(WITH_UPLOAD_SCRIPT)\n    if (do_upload_script != 0) {\n        upload_pipe_open();\n    }\n#endif\n#ifdef WITH_DIRALIASES\n    if (init_aliases() != 0) {\n        logfile(LOG_ERR, MSG_ALIASES_BROKEN_FILE);\n    }\n#endif\n#ifdef WITH_TLS\n    if (enforce_tls_auth > 0) {\n        (void) tls_init_library();\n    }\n#endif\n#if !defined(NO_STANDALONE) && !defined(NO_INETD)\n    if (check_standalone() != 0) {\n        standalone_server();\n    } else {\n        doit();\n    }\n#elif !defined(NO_STANDALONE) && defined(NO_INETD)\n    standalone_server();\n#elif defined(NO_STANDALONE) && !defined(NO_INETD)\n    doit();\n#else\n# error Configuration error\n#endif\n\n#ifdef WITH_UPLOAD_SCRIPT\n    upload_pipe_close();\n#endif\n    {\n        Authentications *auth_scan = first_authentications;\n        Authentications *previous;\n\n        while (auth_scan != NULL) {\n            if (auth_scan->auth->exit != NULL) {\n                auth_scan->auth->exit();\n            }\n            free(auth_scan->conf_file);\n            previous = auth_scan;\n            auth_scan = auth_scan->next;\n            free(previous);\n        }\n    }\n    first_authentications = last_authentications = NULL;\n    free(trustedip);\n#ifndef NO_STANDALONE\n    iptrack_free();\n    unlink(pid_file);\n#endif\n    closelog();\n#ifdef WITH_TLS\n    tls_free_library();\n    tls_extcert_exit();\n    free((void *) client_sni_name);\n#endif\n    alt_arc4random_close();\n\n    _EXIT(EXIT_SUCCESS);\n\n    return 0;\n}","target":0,"code_token_length":5438,"total_token_length":5674,"max_tokens_setting":6144}
+{"idx":210252,"func":"static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define MonoColorType  1\n#define RGBColorType  3\n\n  char\n    property[MagickPathExtent];\n\n  CINInfo\n    cin;\n\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  ssize_t\n    i;\n\n  Quantum\n    *q;\n\n  size_t\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    magick[4],\n    *pixels;\n\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    File information.\n  *\/\n  offset=0;\n  count=ReadBlob(image,4,magick);\n  offset+=count;\n  if ((count != 4) ||\n      ((LocaleNCompare((char *) magick,\"\\200\\052\\137\\327\",4) != 0)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  memset(&cin,0,sizeof(cin));\n  image->endian=(magick[0] == 0x80) && (magick[1] == 0x2a) &&\n    (magick[2] == 0x5f) && (magick[3] == 0xd7) ? MSBEndian : LSBEndian;\n  cin.file.image_offset=ReadBlobLong(image);\n  offset+=4;\n  cin.file.generic_length=ReadBlobLong(image);\n  offset+=4;\n  cin.file.industry_length=ReadBlobLong(image);\n  offset+=4;\n  cin.file.user_length=ReadBlobLong(image);\n  offset+=4;\n  cin.file.file_size=ReadBlobLong(image);\n  offset+=4;\n  offset+=ReadBlob(image,sizeof(cin.file.version),(unsigned char *)\n    cin.file.version);\n  (void) CopyMagickString(property,cin.file.version,sizeof(cin.file.version));\n  (void) SetImageProperty(image,\"dpx:file.version\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.file.filename),(unsigned char *)\n    cin.file.filename);\n  (void) CopyMagickString(property,cin.file.filename,sizeof(cin.file.filename));\n  (void) SetImageProperty(image,\"dpx:file.filename\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.file.create_date),(unsigned char *)\n    cin.file.create_date);\n  (void) CopyMagickString(property,cin.file.create_date,\n    sizeof(cin.file.create_date));\n  (void) SetImageProperty(image,\"dpx:file.create_date\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.file.create_time),(unsigned char *)\n    cin.file.create_time);\n  (void) CopyMagickString(property,cin.file.create_time,\n    sizeof(cin.file.create_time));\n  (void) SetImageProperty(image,\"dpx:file.create_time\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.file.reserve),(unsigned char *)\n    cin.file.reserve);\n  \/*\n    Image information.\n  *\/\n  cin.image.orientation=(unsigned char) ReadBlobByte(image);\n  offset++;\n  if (cin.image.orientation != (unsigned char) (~0))\n    (void) FormatImageProperty(image,\"dpx:image.orientation\",\"%d\",\n      cin.image.orientation);\n  switch (cin.image.orientation)\n  {\n    default:\n    case 0: image->orientation=TopLeftOrientation; break;\n    case 1: image->orientation=TopRightOrientation; break;\n    case 2: image->orientation=BottomLeftOrientation; break;\n    case 3: image->orientation=BottomRightOrientation; break;\n    case 4: image->orientation=LeftTopOrientation; break;\n    case 5: image->orientation=RightTopOrientation; break;\n    case 6: image->orientation=LeftBottomOrientation; break;\n    case 7: image->orientation=RightBottomOrientation; break;\n  }\n  cin.image.number_channels=(unsigned char) ReadBlobByte(image);\n  offset++;\n  offset+=ReadBlob(image,sizeof(cin.image.reserve1),(unsigned char *)\n    cin.image.reserve1);\n  for (i=0; i < 8; i++)\n  {\n    cin.image.channel[i].designator[0]=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].designator[1]=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].bits_per_pixel=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].reserve=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].pixels_per_line=ReadBlobLong(image);\n    offset+=4;\n    cin.image.channel[i].lines_per_image=ReadBlobLong(image);\n    offset+=4;\n    cin.image.channel[i].min_data=ReadBlobFloat(image);\n    offset+=4;\n    cin.image.channel[i].min_quantity=ReadBlobFloat(image);\n    offset+=4;\n    cin.image.channel[i].max_data=ReadBlobFloat(image);\n    offset+=4;\n    cin.image.channel[i].max_quantity=ReadBlobFloat(image);\n    offset+=4;\n  }\n  cin.image.white_point[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.white_point[0]) != MagickFalse)\n    image->chromaticity.white_point.x=cin.image.white_point[0];\n  cin.image.white_point[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.white_point[1]) != MagickFalse)\n    image->chromaticity.white_point.y=cin.image.white_point[1];\n  cin.image.red_primary_chromaticity[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.red_primary_chromaticity[0]) != MagickFalse)\n    image->chromaticity.red_primary.x=cin.image.red_primary_chromaticity[0];\n  cin.image.red_primary_chromaticity[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.red_primary_chromaticity[1]) != MagickFalse)\n    image->chromaticity.red_primary.y=cin.image.red_primary_chromaticity[1];\n  cin.image.green_primary_chromaticity[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.green_primary_chromaticity[0]) != MagickFalse)\n    image->chromaticity.red_primary.x=cin.image.green_primary_chromaticity[0];\n  cin.image.green_primary_chromaticity[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.green_primary_chromaticity[1]) != MagickFalse)\n    image->chromaticity.green_primary.y=cin.image.green_primary_chromaticity[1];\n  cin.image.blue_primary_chromaticity[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.blue_primary_chromaticity[0]) != MagickFalse)\n    image->chromaticity.blue_primary.x=cin.image.blue_primary_chromaticity[0];\n  cin.image.blue_primary_chromaticity[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.blue_primary_chromaticity[1]) != MagickFalse)\n    image->chromaticity.blue_primary.y=cin.image.blue_primary_chromaticity[1];\n  offset+=ReadBlob(image,sizeof(cin.image.label),(unsigned char *)\n    cin.image.label);\n  (void) CopyMagickString(property,cin.image.label,sizeof(cin.image.label));\n  (void) SetImageProperty(image,\"dpx:image.label\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.image.reserve),(unsigned char *)\n    cin.image.reserve);\n  \/*\n    Image data format information.\n  *\/\n  cin.data_format.interleave=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.packing=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.sign=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.sense=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.line_pad=ReadBlobLong(image);\n  offset+=4;\n  cin.data_format.channel_pad=ReadBlobLong(image);\n  offset+=4;\n  offset+=ReadBlob(image,sizeof(cin.data_format.reserve),(unsigned char *)\n    cin.data_format.reserve);\n  \/*\n    Image origination information.\n  *\/\n  cin.origination.x_offset=ReadBlobSignedLong(image);\n  offset+=4;\n  if ((size_t) cin.origination.x_offset != ~0UL)\n    (void) FormatImageProperty(image,\"dpx:origination.x_offset\",\"%.20g\",\n      (double) cin.origination.x_offset);\n  cin.origination.y_offset=(ssize_t) ReadBlobLong(image);\n  offset+=4;\n  if ((size_t) cin.origination.y_offset != ~0UL)\n    (void) FormatImageProperty(image,\"dpx:origination.y_offset\",\"%.20g\",\n      (double) cin.origination.y_offset);\n  offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *)\n    cin.origination.filename);\n  (void) CopyMagickString(property,cin.origination.filename,\n    sizeof(cin.origination.filename));\n  (void) SetImageProperty(image,\"dpx:origination.filename\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.origination.create_date),(unsigned char *)\n    cin.origination.create_date);\n  (void) CopyMagickString(property,cin.origination.create_date,\n    sizeof(cin.origination.create_date));\n  (void) SetImageProperty(image,\"dpx:origination.create_date\",property,\n    exception);\n  offset+=ReadBlob(image,sizeof(cin.origination.create_time),(unsigned char *)\n    cin.origination.create_time);\n  (void) CopyMagickString(property,cin.origination.create_time,\n    sizeof(cin.origination.create_time));\n  (void) SetImageProperty(image,\"dpx:origination.create_time\",property,\n    exception);\n  offset+=ReadBlob(image,sizeof(cin.origination.device),(unsigned char *)\n    cin.origination.device);\n  (void) CopyMagickString(property,cin.origination.device,\n    sizeof(cin.origination.device));\n  (void) SetImageProperty(image,\"dpx:origination.device\",property,exception);\n  offset+=ReadBlob(image,sizeof(cin.origination.model),(unsigned char *)\n    cin.origination.model);\n  (void) CopyMagickString(property,cin.origination.model,\n    sizeof(cin.origination.model));\n  (void) SetImageProperty(image,\"dpx:origination.model\",property,exception);\n  (void) memset(cin.origination.serial,0, \n    sizeof(cin.origination.serial));\n  offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *)\n    cin.origination.serial);\n  (void) CopyMagickString(property,cin.origination.serial,\n    sizeof(cin.origination.serial));\n  (void) SetImageProperty(image,\"dpx:origination.serial\",property,exception);\n  cin.origination.x_pitch=ReadBlobFloat(image);\n  offset+=4;\n  cin.origination.y_pitch=ReadBlobFloat(image);\n  offset+=4;\n  cin.origination.gamma=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.origination.gamma) != MagickFalse)\n    image->gamma=cin.origination.gamma;\n  offset+=ReadBlob(image,sizeof(cin.origination.reserve),(unsigned char *)\n    cin.origination.reserve);\n  if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0))\n    {\n      int\n        c;\n\n      \/*\n        Image film information.\n      *\/\n      cin.film.id=ReadBlobByte(image);\n      offset++;\n      c=cin.film.id;\n      if (c != ~0)\n        (void) FormatImageProperty(image,\"dpx:film.id\",\"%d\",cin.film.id);\n      cin.film.type=ReadBlobByte(image);\n      offset++;\n      c=cin.film.type;\n      if (c != ~0)\n        (void) FormatImageProperty(image,\"dpx:film.type\",\"%d\",cin.film.type);\n      cin.film.offset=ReadBlobByte(image);\n      offset++;\n      c=cin.film.offset;\n      if (c != ~0)\n        (void) FormatImageProperty(image,\"dpx:film.offset\",\"%d\",\n          cin.film.offset);\n      cin.film.reserve1=ReadBlobByte(image);\n      offset++;\n      cin.film.prefix=ReadBlobLong(image);\n      offset+=4;\n      if (cin.film.prefix != ~0UL)\n        (void) FormatImageProperty(image,\"dpx:film.prefix\",\"%.20g\",(double)\n          cin.film.prefix);\n      cin.film.count=ReadBlobLong(image);\n      offset+=4;\n      offset+=ReadBlob(image,sizeof(cin.film.format),(unsigned char *)\n        cin.film.format);\n      (void) CopyMagickString(property,cin.film.format,sizeof(cin.film.format));\n      (void) SetImageProperty(image,\"dpx:film.format\",property,exception);\n      cin.film.frame_position=ReadBlobLong(image);\n      offset+=4;\n      if (cin.film.frame_position != ~0UL)\n        (void) FormatImageProperty(image,\"dpx:film.frame_position\",\"%.20g\",\n          (double) cin.film.frame_position);\n      cin.film.frame_rate=ReadBlobFloat(image);\n      offset+=4;\n      if (IsFloatDefined(cin.film.frame_rate) != MagickFalse)\n        (void) FormatImageProperty(image,\"dpx:film.frame_rate\",\"%g\",\n          cin.film.frame_rate);\n      offset+=ReadBlob(image,sizeof(cin.film.frame_id),(unsigned char *)\n        cin.film.frame_id);\n      (void) CopyMagickString(property,cin.film.frame_id,\n        sizeof(cin.film.frame_id));\n      (void) SetImageProperty(image,\"dpx:film.frame_id\",property,exception);\n      offset+=ReadBlob(image,sizeof(cin.film.slate_info),(unsigned char *)\n        cin.film.slate_info);\n      (void) CopyMagickString(property,cin.film.slate_info,\n        sizeof(cin.film.slate_info));\n      (void) SetImageProperty(image,\"dpx:film.slate_info\",property,exception);\n      offset+=ReadBlob(image,sizeof(cin.film.reserve),(unsigned char *)\n        cin.film.reserve);\n    }\n  if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0))\n    {\n      StringInfo\n        *profile;\n\n      \/*\n        User defined data.\n      *\/\n      if (cin.file.user_length > GetBlobSize(image))\n        ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n      profile=BlobToStringInfo((const unsigned char *) NULL,\n        cin.file.user_length);\n      if (profile == (StringInfo *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      offset+=ReadBlob(image,GetStringInfoLength(profile),\n        GetStringInfoDatum(profile));\n      (void) SetImageProfile(image,\"dpx:user.data\",profile,exception);\n      profile=DestroyStringInfo(profile);\n    }\n  image->depth=cin.image.channel[0].bits_per_pixel;\n  image->columns=cin.image.channel[0].pixels_per_line;\n  image->rows=cin.image.channel[0].lines_per_image;\n  if (image_info->ping != MagickFalse)\n    {\n      (void) CloseBlob(image);\n      return(image);\n    }\n  if (((MagickSizeType) image->columns*image->rows\/8) > GetBlobSize(image))\n    ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n  for ( ; offset < (MagickOffsetType) cin.file.image_offset; offset++)\n  {\n    int\n      c;\n\n    c=ReadBlobByte(image);\n    if (c == EOF)\n      break;\n  }\n  if (offset < (MagickOffsetType) cin.file.image_offset)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  status=SetImageExtent(image,image->columns,image->rows,exception);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  (void) SetImageBackgroundColor(image,exception);\n  \/*\n    Convert CIN raster image to pixel packets.\n  *\/\n  quantum_info=AcquireQuantumInfo(image_info,image);\n  if (quantum_info == (QuantumInfo *) NULL)\n    ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n  SetQuantumQuantum(quantum_info,32);\n  SetQuantumPack(quantum_info,MagickFalse);\n  quantum_type=RGBQuantum;\n  length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue);\n  if (cin.image.number_channels == 1)\n    {\n      quantum_type=GrayQuantum;\n      length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue);\n    }\n  status=SetQuantumPad(image,quantum_info,0);\n  pixels=GetQuantumPixels(quantum_info);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    const void\n      *stream;\n\n    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      break;\n    stream=ReadBlobStream(image,length,pixels,&count);\n    if ((size_t) count != length)\n      break;\n    (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n      quantum_type,(unsigned char *) stream,exception);\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n    if (image->previous == (Image *) NULL)\n      {\n        status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n          image->rows);\n        if (status == MagickFalse)\n          break;\n      }\n  }\n  SetQuantumImageType(image,quantum_type);\n  quantum_info=DestroyQuantumInfo(quantum_info);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  SetImageColorspace(image,LogColorspace,exception);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":4045,"total_token_length":4281,"max_tokens_setting":6144}
+{"idx":198161,"func":"static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  Image *image, *image2=NULL,\n   *rotated_image;\n  register Quantum *q;\n\n  unsigned int status;\n  MATHeader MATLAB_HDR;\n  size_t size;  \n  size_t CellType;\n  QuantumInfo *quantum_info;\n  ImageInfo *clone_info;\n  int i;\n  ssize_t ldblk;\n  unsigned char *BImgBuff = NULL;\n  double MinVal, MaxVal;\n  unsigned z, z2;\n  unsigned Frames;\n  int logging;\n  int sample_size;\n  MagickOffsetType filepos=0x80;\n  BlobInfo *blob;\n  size_t one;\n  \n  unsigned int (*ReadBlobXXXLong)(Image *image);\n  unsigned short (*ReadBlobXXXShort)(Image *image);\n  void (*ReadBlobDoublesXXX)(Image * image, size_t len, double *data);\n  void (*ReadBlobFloatsXXX)(Image * image, size_t len, float *data);\n\n\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  logging = LogMagickEvent(CoderEvent,GetMagickModule(),\"enter\"); \n\n  \/*\n     Open image file.\n   *\/\n  image = AcquireImage(image_info,exception);\n\n  status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n     Read MATLAB image.\n   *\/\n  clone_info=CloneImageInfo(image_info);\n  if(ReadBlob(image,124,(unsigned char *) &MATLAB_HDR.identific) != 124)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  MATLAB_HDR.Version = ReadBlobLSBShort(image);\n  if(ReadBlob(image,2,(unsigned char *) &MATLAB_HDR.EndianIndicator) != 2)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n\n  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\"  Endian %c%c\",\n        MATLAB_HDR.EndianIndicator[0],MATLAB_HDR.EndianIndicator[1]);\n  if (!strncmp(MATLAB_HDR.EndianIndicator, \"IM\", 2))\n  {\n    ReadBlobXXXLong = ReadBlobLSBLong;\n    ReadBlobXXXShort = ReadBlobLSBShort;\n    ReadBlobDoublesXXX = ReadBlobDoublesLSB;\n    ReadBlobFloatsXXX = ReadBlobFloatsLSB;\n    image->endian = LSBEndian;\n  } \n  else if (!strncmp(MATLAB_HDR.EndianIndicator, \"MI\", 2))\n  {\n    ReadBlobXXXLong = ReadBlobMSBLong;\n    ReadBlobXXXShort = ReadBlobMSBShort;\n    ReadBlobDoublesXXX = ReadBlobDoublesMSB;\n    ReadBlobFloatsXXX = ReadBlobFloatsMSB;\n    image->endian = MSBEndian;\n  }\n  else \n    goto MATLAB_KO;    \/* unsupported endian *\/\n\n  if (strncmp(MATLAB_HDR.identific, \"MATLAB\", 6))\nMATLAB_KO: ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n\n  filepos = TellBlob(image);\n  while(!EOFBlob(image)) \/* object parser loop *\/\n  {\n    Frames = 1;\n    (void) SeekBlob(image,filepos,SEEK_SET);\n    \/* printf(\"pos=%X\\n\",TellBlob(image)); *\/\n\n    MATLAB_HDR.DataType = ReadBlobXXXLong(image);\n    if(EOFBlob(image)) break;\n    MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image);\n    if(EOFBlob(image)) break;\n    filepos += MATLAB_HDR.ObjectSize + 4 + 4;\n\n    image2 = image;\n#if defined(MAGICKCORE_ZLIB_DELEGATE)\n    if(MATLAB_HDR.DataType == miCOMPRESSED)\n    {\n      image2 = DecompressBlock(image,MATLAB_HDR.ObjectSize,clone_info,exception);\n      if(image2==NULL) continue;\n      MATLAB_HDR.DataType = ReadBlobXXXLong(image2); \/* replace compressed object type. *\/\n    }\n#endif    \n\n    if(MATLAB_HDR.DataType!=miMATRIX) continue;  \/* skip another objects. *\/\n \n    MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2);\n    MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2);  \n\n    MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2);\n    MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF;\n    MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF;  \n\n    MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2);\n    if(image!=image2)\n      MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);  \/* ??? don't understand why ?? *\/\n    MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);\n    MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2);\n    MATLAB_HDR.SizeX = ReadBlobXXXLong(image2);\n    MATLAB_HDR.SizeY = ReadBlobXXXLong(image2);  \n   \n\n    switch(MATLAB_HDR.DimFlag)\n    {     \n      case  8: z2=z=1; break;      \/* 2D matrix*\/\n      case 12: z2=z = ReadBlobXXXLong(image2);  \/* 3D matrix RGB*\/\n           (void) ReadBlobXXXLong(image2);\n         if(z!=3) ThrowReaderException(CoderError, \"MultidimensionalMatricesAreNotSupported\");\n         break;\n      case 16: z2=z = ReadBlobXXXLong(image2);  \/* 4D matrix animation *\/\n         if(z!=3 && z!=1)\n            ThrowReaderException(CoderError, \"MultidimensionalMatricesAreNotSupported\");\n           Frames = ReadBlobXXXLong(image2);\n         break;\n      default: ThrowReaderException(CoderError, \"MultidimensionalMatricesAreNotSupported\");\n    }  \n\n    MATLAB_HDR.Flag1 = ReadBlobXXXShort(image2);\n    MATLAB_HDR.NameFlag = ReadBlobXXXShort(image2);\n\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"MATLAB_HDR.StructureClass %d\",MATLAB_HDR.StructureClass);\n    if (MATLAB_HDR.StructureClass != mxCHAR_CLASS && \n        MATLAB_HDR.StructureClass != mxSINGLE_CLASS &&    \/* float + complex float *\/\n        MATLAB_HDR.StructureClass != mxDOUBLE_CLASS &&    \/* double + complex double *\/\n        MATLAB_HDR.StructureClass != mxINT8_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT8_CLASS &&    \/* uint8 + uint8 3D *\/\n        MATLAB_HDR.StructureClass != mxINT16_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT16_CLASS &&    \/* uint16 + uint16 3D *\/\n        MATLAB_HDR.StructureClass != mxINT32_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT32_CLASS &&    \/* uint32 + uint32 3D *\/\n        MATLAB_HDR.StructureClass != mxINT64_CLASS &&\n        MATLAB_HDR.StructureClass != mxUINT64_CLASS)    \/* uint64 + uint64 3D *\/\n      ThrowReaderException(CoderError,\"UnsupportedCellTypeInTheMatrix\");\n\n    switch (MATLAB_HDR.NameFlag)\n    {\n      case 0:\n        size = ReadBlobXXXLong(image2);  \/* Object name string size *\/\n        size = 4 * (ssize_t) ((size + 3 + 1) \/ 4);\n        (void) SeekBlob(image2, size, SEEK_CUR);\n        break;\n      case 1:\n      case 2:\n      case 3:\n      case 4:\n        (void) ReadBlob(image2, 4, (unsigned char *) &size); \/* Object name string *\/\n        break;\n      default:\n        goto MATLAB_KO;\n    }\n\n    CellType = ReadBlobXXXLong(image2);    \/* Additional object type *\/\n    if (logging)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n        \"MATLAB_HDR.CellType: %.20g\",(double) CellType);\n  \n    (void) ReadBlob(image2, 4, (unsigned char *) &size);     \/* data size *\/\n\n    NEXT_FRAME:\n    switch (CellType)\n    {\n      case miINT8:\n      case miUINT8:\n        sample_size = 8;\n        if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL) \n          image->depth = 1;\n        else\n          image->depth = 8;         \/* Byte type cell *\/\n        ldblk = (ssize_t) MATLAB_HDR.SizeX;      \n        break;\n      case miINT16:\n      case miUINT16:\n        sample_size = 16;\n        image->depth = 16;        \/* Word type cell *\/\n        ldblk = (ssize_t) (2 * MATLAB_HDR.SizeX);\n        break;\n      case miINT32:\n      case miUINT32:\n        sample_size = 32;\n        image->depth = 32;        \/* Dword type cell *\/\n        ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);      \n        break;\n      case miINT64:\n      case miUINT64:\n        sample_size = 64;\n        image->depth = 64;        \/* Qword type cell *\/\n        ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);      \n        break;   \n      case miSINGLE:\n        sample_size = 32;\n        image->depth = 32;        \/* double type cell *\/\n        (void) SetImageOption(clone_info,\"quantum:format\",\"floating-point\");\n        if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)\n  {              \/* complex float type cell *\/\n  }\n        ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);\n        break;\n      case miDOUBLE:\n        sample_size = 64; \n        image->depth = 64;        \/* double type cell *\/\n        (void) SetImageOption(clone_info,\"quantum:format\",\"floating-point\");\nDisableMSCWarning(4127)\n        if (sizeof(double) != 8)\nRestoreMSCWarning\n          ThrowReaderException(CoderError, \"IncompatibleSizeOfDouble\");\n        if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)\n  {                         \/* complex double type cell *\/        \n  }\n        ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);\n        break;\n      default:\n        ThrowReaderException(CoderError, \"UnsupportedCellTypeInTheMatrix\");\n    }\n    (void) sample_size;\n    image->columns = MATLAB_HDR.SizeX;\n    image->rows = MATLAB_HDR.SizeY;    \n    quantum_info=AcquireQuantumInfo(clone_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n    one=1;\n    image->colors = one << image->depth;\n    if (image->columns == 0 || image->rows == 0)\n      goto MATLAB_KO;\n    \/* Image is gray when no complex flag is set and 2D Matrix *\/\n    if ((MATLAB_HDR.DimFlag == 8) &&\n        ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))\n      {\n        image->type=GrayscaleType;\n        SetImageColorspace(image,GRAYColorspace,exception);\n      }\n\n\n    \/*\n      If ping is true, then only set image size and colors without\n      reading any image data.\n    *\/\n    if (image_info->ping)\n    {\n      size_t temp = image->columns;\n      image->columns = image->rows;\n      image->rows = temp;\n      goto done_reading; \/* !!!!!! BAD  !!!! *\/\n    }  \n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      return(DestroyImageList(image));\n\n  \/* ----- Load raster data ----- *\/\n    BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(double));    \/* Ldblk was set in the check phase *\/\n    if (BImgBuff == NULL)\n      ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n\n    MinVal = 0;\n    MaxVal = 0;\n    if (CellType==miDOUBLE || CellType==miSINGLE)        \/* Find Min and Max Values for floats *\/\n    {\n      CalcMinMax(image2, image_info->endian,  MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &quantum_info->minimum, &quantum_info->maximum);\n    }\n\n    \/* Main loop for reading all scanlines *\/\n    if(z==1) z=0; \/* read grey scanlines *\/\n    \/* else read color scanlines *\/\n    do\n    {\n      for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)\n      {\n        q=GetAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception);\n        if (q == (Quantum *) NULL)\n  {\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  MAT set image pixels returns unexpected NULL on a row %u.\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n    goto done_reading;    \/* Skip image rotation, when cannot set image pixels    *\/\n  }\n        if(ReadBlob(image2,ldblk,(unsigned char *)BImgBuff) != (ssize_t) ldblk)\n  {\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n             \"  MAT cannot read scanrow %u from a file.\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n    goto ExitLoop;\n  }\n        if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL))\n        {\n          FixLogical((unsigned char *)BImgBuff,ldblk);\n          if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0)\n    {\nImportQuantumPixelsFailed:\n      if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  MAT failed to ImportQuantumPixels for a row %u\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n      break;\n    }\n        }\n        else\n        {\n          if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0)\n      goto ImportQuantumPixelsFailed;\n\n\n          if (z<=1 &&       \/* fix only during a last pass z==0 || z==1 *\/\n          (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64))\n      FixSignedValues(image,q,MATLAB_HDR.SizeX);\n        }\n\n        if (!SyncAuthenticPixels(image,exception))\n  {\n    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  MAT failed to sync image pixels for a row %u\", (unsigned)(MATLAB_HDR.SizeY-i-1));\n    goto ExitLoop;\n  }\n      }\n    } while(z-- >= 2);\nExitLoop:\n\n\n    \/* Read complex part of numbers here *\/\n    if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)\n    {        \/* Find Min and Max Values for complex parts of floats *\/\n      CellType = ReadBlobXXXLong(image2);    \/* Additional object type *\/\n      i = ReadBlobXXXLong(image2);           \/* size of a complex part - toss away*\/\n\n      if (CellType==miDOUBLE || CellType==miSINGLE)\n      {\n        CalcMinMax(image2,  image_info->endian, MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &MinVal, &MaxVal);      \n      }\n\n      if (CellType==miDOUBLE)\n        for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)\n  {\n          ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff);\n          InsertComplexDoubleRow(image, (double *)BImgBuff, i, MinVal, MaxVal,\n            exception);\n  }\n\n      if (CellType==miSINGLE)\n        for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)\n  {\n          ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff);\n          InsertComplexFloatRow(image,(float *)BImgBuff,i,MinVal,MaxVal,\n            exception);\n  }    \n    }\n\n      \/* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! *\/\n    if ((MATLAB_HDR.DimFlag == 8) &&\n        ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))\n      image->type=GrayscaleType;\n    if (image->depth == 1)\n      image->type=BilevelType;\n\n    if(image2==image)\n        image2 = NULL;    \/* Remove shadow copy to an image before rotation. *\/\n\n      \/*  Rotate image. *\/\n    rotated_image = RotateImage(image, 90.0, exception);\n    if (rotated_image != (Image *) NULL)\n    {\n        \/* Remove page offsets added by RotateImage *\/\n      rotated_image->page.x=0;\n      rotated_image->page.y=0;\n\n      blob = rotated_image->blob;\n      rotated_image->blob = image->blob;\n      rotated_image->colors = image->colors;\n      image->blob = blob;\n      AppendImageToList(&image,rotated_image);      \n      DeleteImageFromList(&image);      \n    }\n\ndone_reading:\n\n    if(image2!=NULL)\n      if(image2!=image)\n      {\n        DeleteImageFromList(&image2); \n  if(clone_info)\n  {\n          if(clone_info->file)\n    {\n            fclose(clone_info->file);\n            clone_info->file = NULL;\n            (void) remove_utf8(clone_info->filename);\n    }\n        }    \n      }\n\n      \/* Allocate next image structure. *\/    \n    AcquireNextImage(image_info,image,exception);\n    if (image->next == (Image *) NULL) break;                \n    image=SyncNextImageInList(image);\n    image->columns=image->rows=0;\n    image->colors=0;    \n\n      \/* row scan buffer is no longer needed *\/\n    RelinquishMagickMemory(BImgBuff);\n    BImgBuff = NULL;\n\n    if(--Frames>0)\n    {\n      z = z2;\n      if(image2==NULL) image2 = image;\n      goto NEXT_FRAME;\n    }\n    if ((image2!=NULL) && (image2!=image))   \/* Does shadow temporary decompressed image exist? *\/\n      {\n\/*  CloseBlob(image2); *\/\n        DeleteImageFromList(&image2);\n        if(clone_info)\n        {\n          if(clone_info->file)\n          {\n            fclose(clone_info->file);\n            clone_info->file = NULL;\n            (void) remove_utf8(clone_info->filename);\n          }\n        }\n        }\n  }\n\n  clone_info=DestroyImageInfo(clone_info);\n  RelinquishMagickMemory(BImgBuff);\n  CloseBlob(image);\n\n\n  {\n    Image *p;    \n    ssize_t scene=0;\n    \n    \/*\n      Rewind list, removing any empty images while rewinding.\n    *\/\n    p=image;\n    image=NULL;\n    while (p != (Image *) NULL)\n      {\n        Image *tmp=p;\n        if ((p->rows == 0) || (p->columns == 0)) {\n          p=p->previous;\n          DeleteImageFromList(&tmp);\n        } else {\n          image=p;\n          p=p->previous;\n        }\n      }\n    \n    \/*\n      Fix scene numbers\n    *\/\n    for (p=image; p != (Image *) NULL; p=p->next)\n      p->scene=scene++;\n  }\n\n  if(clone_info != NULL)  \/* cleanup garbage file from compression *\/\n  {\n    if(clone_info->file)\n    {\n      fclose(clone_info->file);\n      clone_info->file = NULL;\n      (void) remove_utf8(clone_info->filename);\n    }\n    DestroyImageInfo(clone_info);\n    clone_info = NULL;\n  }\n  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),\"return\");\n  if(image==NULL)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  return (image);\n}","target":1,"code_token_length":4452,"total_token_length":4688,"max_tokens_setting":6144}
+{"idx":211594,"func":"static Image *ReadWPGImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n  typedef struct\n  {\n    size_t FileId;\n    MagickOffsetType DataOffset;\n    unsigned int ProductType;\n    unsigned int FileType;\n    unsigned char MajorVersion;\n    unsigned char MinorVersion;\n    unsigned int EncryptKey;\n    unsigned int Reserved;\n  } WPGHeader;\n\n  typedef struct\n  {\n    unsigned char RecType;\n    size_t RecordLength;\n  } WPGRecord;\n\n  typedef struct\n  {\n    unsigned char Class;\n    unsigned char RecType;\n    size_t Extension;\n    size_t RecordLength;\n  } WPG2Record;\n\n  typedef struct\n  {\n    unsigned  HorizontalUnits;\n    unsigned  VerticalUnits;\n    unsigned char PosSizePrecision;\n  } WPG2Start;\n\n  typedef struct\n  {\n    unsigned int Width;\n    unsigned int Height;\n    unsigned int Depth;\n    unsigned int HorzRes;\n    unsigned int VertRes;\n  } WPGBitmapType1;\n\n  typedef struct\n  {\n    unsigned int Width;\n    unsigned int Height;\n    unsigned char Depth;\n    unsigned char Compression;\n  } WPG2BitmapType1;\n\n  typedef struct\n  {\n    unsigned int RotAngle;\n    unsigned int LowLeftX;\n    unsigned int LowLeftY;\n    unsigned int UpRightX;\n    unsigned int UpRightY;\n    unsigned int Width;\n    unsigned int Height;\n    unsigned int Depth;\n    unsigned int HorzRes;\n    unsigned int VertRes;\n  } WPGBitmapType2;\n\n  typedef struct\n  {\n    unsigned int StartIndex;\n    unsigned int NumOfEntries;\n  } WPGColorMapRec;\n\n  \/*\n  typedef struct {\n    size_t PS_unknown1;\n    unsigned int PS_unknown2;\n    unsigned int PS_unknown3;\n  } WPGPSl1Record;  \n  *\/\n\n  Image\n    *image;\n\n  unsigned int\n    status;\n\n  WPGHeader\n    Header;\n\n  WPGRecord\n    Rec;\n\n  WPG2Record\n    Rec2;\n\n  WPG2Start StartWPG;\n\n  WPGBitmapType1\n    BitmapHeader1;\n\n  WPG2BitmapType1\n    Bitmap2Header1;\n\n  WPGBitmapType2\n    BitmapHeader2;\n\n  WPGColorMapRec\n    WPG_Palette;\n\n  int\n    i,\n    bpp,\n    WPG2Flags;\n\n  ssize_t\n    ldblk;\n\n  size_t\n    one;\n\n  unsigned char\n    *BImgBuff;\n\n  tCTM CTM;         \/*current transform matrix*\/\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  one=1;\n  image=AcquireImage(image_info,exception);\n  image->depth=8;\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read WPG image.\n  *\/\n  Header.FileId=ReadBlobLSBLong(image);\n  Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image);\n  Header.ProductType=ReadBlobLSBShort(image);\n  Header.FileType=ReadBlobLSBShort(image);\n  Header.MajorVersion=ReadBlobByte(image);\n  Header.MinorVersion=ReadBlobByte(image);\n  Header.EncryptKey=ReadBlobLSBShort(image);\n  Header.Reserved=ReadBlobLSBShort(image);\n\n  if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  if (Header.EncryptKey!=0)\n    ThrowReaderException(CoderError,\"EncryptedWPGImageFileNotSupported\");\n\n  image->columns = 1;\n  image->rows = 1;\n  image->colors = 0;\n  bpp=0;\n  BitmapHeader2.RotAngle=0;\n  Rec2.RecordLength=0;\n\n  switch(Header.FileType)\n    {\n    case 1:     \/* WPG level 1 *\/\n      while(!EOFBlob(image)) \/* object parser loop *\/\n        {\n          (void) SeekBlob(image,Header.DataOffset,SEEK_SET);\n          if(EOFBlob(image))\n            break;\n\n          Rec.RecType=(i=ReadBlobByte(image));\n          if(i==EOF)\n            break;\n          Rd_WP_DWORD(image,&Rec.RecordLength);\n          if (Rec.RecordLength > GetBlobSize(image))\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n          if(EOFBlob(image))\n            break;\n\n          Header.DataOffset=TellBlob(image)+Rec.RecordLength;\n\n          switch(Rec.RecType)\n            {\n            case 0x0B: \/* bitmap type 1 *\/\n              BitmapHeader1.Width=ReadBlobLSBShort(image);\n              BitmapHeader1.Height=ReadBlobLSBShort(image);\n              if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0))\n                ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n              BitmapHeader1.Depth=ReadBlobLSBShort(image);\n              BitmapHeader1.HorzRes=ReadBlobLSBShort(image);\n              BitmapHeader1.VertRes=ReadBlobLSBShort(image);\n\n              if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes)\n                {\n                  image->units=PixelsPerCentimeterResolution;\n                  image->resolution.x=BitmapHeader1.HorzRes\/470.0;\n                  image->resolution.y=BitmapHeader1.VertRes\/470.0;\n                }\n              image->columns=BitmapHeader1.Width;\n              image->rows=BitmapHeader1.Height;\n              bpp=BitmapHeader1.Depth;\n\n              goto UnpackRaster;\n\n            case 0x0E:  \/*Color palette *\/\n              WPG_Palette.StartIndex=ReadBlobLSBShort(image);\n              WPG_Palette.NumOfEntries=ReadBlobLSBShort(image);\n              if ((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) >\n                  (Rec2.RecordLength-2-2) \/ 3)\n                ThrowReaderException(CorruptImageError,\"InvalidColormapIndex\");\n              image->colors=WPG_Palette.NumOfEntries;\n              if (!AcquireImageColormap(image,image->colors,exception))\n                goto NoMemory;\n              for (i=WPG_Palette.StartIndex;\n                   i < (int)WPG_Palette.NumOfEntries; i++)\n                {\n                  image->colormap[i].red=ScaleCharToQuantum((unsigned char)\n                    ReadBlobByte(image));\n                  image->colormap[i].green=ScaleCharToQuantum((unsigned char)\n                    ReadBlobByte(image));\n                  image->colormap[i].blue=ScaleCharToQuantum((unsigned char)\n                    ReadBlobByte(image));\n                }\n              break;\n     \n            case 0x11:  \/* Start PS l1 *\/\n              if(Rec.RecordLength > 8)\n                image=ExtractPostscript(image,image_info,\n                  TellBlob(image)+8,   \/* skip PS header in the wpg *\/\n                  (ssize_t) Rec.RecordLength-8,exception);\n              break;     \n\n            case 0x14:  \/* bitmap type 2 *\/\n              BitmapHeader2.RotAngle=ReadBlobLSBShort(image);\n              BitmapHeader2.LowLeftX=ReadBlobLSBShort(image);\n              BitmapHeader2.LowLeftY=ReadBlobLSBShort(image);\n              BitmapHeader2.UpRightX=ReadBlobLSBShort(image);\n              BitmapHeader2.UpRightY=ReadBlobLSBShort(image);\n              BitmapHeader2.Width=ReadBlobLSBShort(image);\n              BitmapHeader2.Height=ReadBlobLSBShort(image);\n              if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0))\n                ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n              BitmapHeader2.Depth=ReadBlobLSBShort(image);\n              BitmapHeader2.HorzRes=ReadBlobLSBShort(image);\n              BitmapHeader2.VertRes=ReadBlobLSBShort(image);\n\n              image->units=PixelsPerCentimeterResolution;\n              image->page.width=(unsigned int)\n                ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)\/470.0);\n              image->page.height=(unsigned int)\n                ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)\/470.0);\n              image->page.x=(int) (BitmapHeader2.LowLeftX\/470.0);\n              image->page.y=(int) (BitmapHeader2.LowLeftX\/470.0);\n              if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes)\n                {\n                  image->resolution.x=BitmapHeader2.HorzRes\/470.0;\n                  image->resolution.y=BitmapHeader2.VertRes\/470.0;\n                }\n              image->columns=BitmapHeader2.Width;\n              image->rows=BitmapHeader2.Height;\n              bpp=BitmapHeader2.Depth;\n\n            UnpackRaster:      \n              status=SetImageExtent(image,image->columns,image->rows,exception);\n              if (status == MagickFalse)\n                break;\n              if ((image->colors == 0) && (bpp != 24))\n                {\n                  image->colors=one << bpp;\n                  if (!AcquireImageColormap(image,image->colors,exception))\n                    {\n                    NoMemory:\n                      ThrowReaderException(ResourceLimitError,\n                        \"MemoryAllocationFailed\");\n                    }\n                  \/* printf(\"Load default colormap \\n\"); *\/\n                  for (i=0; (i < (int) image->colors) && (i < 256); i++)\n                    {               \n                      image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red);\n                      image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green);\n                      image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue);\n                    }\n                }\n              else\n                {\n                  if (bpp < 24)\n                    if ( (image->colors < (one << bpp)) && (bpp != 24) )\n                      image->colormap=(PixelInfo *) ResizeQuantumMemory(\n                        image->colormap,(size_t) (one << bpp),\n                        sizeof(*image->colormap));\n                }\n          \n              if (bpp == 1)\n                {\n                  if(image->colormap[0].red==0 &&\n                     image->colormap[0].green==0 &&\n                     image->colormap[0].blue==0 &&\n                     image->colormap[1].red==0 &&\n                     image->colormap[1].green==0 &&\n                     image->colormap[1].blue==0)\n                    {  \/* fix crippled monochrome palette *\/\n                      image->colormap[1].red =\n                        image->colormap[1].green =\n                        image->colormap[1].blue = QuantumRange;\n                    }\n                }      \n\n              if(UnpackWPGRaster(image,bpp,exception) < 0)\n                \/* The raster cannot be unpacked *\/\n                {\n                DecompressionFailed:\n                  ThrowReaderException(CoderError,\"UnableToDecompressImage\");\n                    }\n\n              if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping)\n                {  \n                  \/* flop command *\/\n                  if(BitmapHeader2.RotAngle & 0x8000)\n                    {\n                      Image\n                        *flop_image;\n\n                      flop_image = FlopImage(image, exception);\n                      if (flop_image != (Image *) NULL) {\n                        DuplicateBlob(flop_image,image);\n                        ReplaceImageInList(&image,flop_image);\n                      }\n                    }\n                  \/* flip command *\/\n                  if(BitmapHeader2.RotAngle & 0x2000)\n                    {\n                      Image\n                        *flip_image;\n\n                      flip_image = FlipImage(image, exception);\n                      if (flip_image != (Image *) NULL) {\n                        DuplicateBlob(flip_image,image);\n                        ReplaceImageInList(&image,flip_image);\n                      }\n                    }\n                  \/* rotate command *\/\n                  if(BitmapHeader2.RotAngle & 0x0FFF)\n                    {\n                      Image\n                        *rotate_image;\n\n                      rotate_image=RotateImage(image,(BitmapHeader2.RotAngle &\n                        0x0FFF), exception);\n                      if (rotate_image != (Image *) NULL) {\n                        DuplicateBlob(rotate_image,image);\n                        ReplaceImageInList(&image,rotate_image);\n                      }\n                    }\n                }\n\n              \/* Allocate next image structure. *\/\n              AcquireNextImage(image_info,image,exception);\n              image->depth=8;\n              if (image->next == (Image *) NULL)\n                goto Finish;\n              image=SyncNextImageInList(image);\n              image->columns=image->rows=1;\n              image->colors=0;\n              break;\n\n            case 0x1B:  \/* Postscript l2 *\/\n              if(Rec.RecordLength>0x3C)\n                image=ExtractPostscript(image,image_info,\n                  TellBlob(image)+0x3C,   \/* skip PS l2 header in the wpg *\/\n                  (ssize_t) Rec.RecordLength-0x3C,exception);\n              break;\n            }\n        }\n      break;\n\n    case 2:  \/* WPG level 2 *\/\n      (void) memset(CTM,0,sizeof(CTM));\n      StartWPG.PosSizePrecision = 0;\n      while(!EOFBlob(image)) \/* object parser loop *\/\n        {\n          (void) SeekBlob(image,Header.DataOffset,SEEK_SET);\n          if(EOFBlob(image))\n            break;\n\n          Rec2.Class=(i=ReadBlobByte(image));\n          if(i==EOF)\n            break;\n          Rec2.RecType=(i=ReadBlobByte(image));\n          if(i==EOF)\n            break;\n          Rd_WP_DWORD(image,&Rec2.Extension);\n          Rd_WP_DWORD(image,&Rec2.RecordLength);\n          if(EOFBlob(image))\n            break;\n\n          Header.DataOffset=TellBlob(image)+Rec2.RecordLength;\n\n          switch(Rec2.RecType)\n            {\n      case 1:\n              StartWPG.HorizontalUnits=ReadBlobLSBShort(image);\n              StartWPG.VerticalUnits=ReadBlobLSBShort(image);\n              StartWPG.PosSizePrecision=ReadBlobByte(image);\n              break;\n            case 0x0C:    \/* Color palette *\/\n              WPG_Palette.StartIndex=ReadBlobLSBShort(image);\n              WPG_Palette.NumOfEntries=ReadBlobLSBShort(image);\n              if ((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) >\n                  (Rec2.RecordLength-2-2) \/ 3)\n                ThrowReaderException(CorruptImageError,\"InvalidColormapIndex\");\n              image->colors=WPG_Palette.NumOfEntries;\n              if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n                ThrowReaderException(ResourceLimitError,\n                  \"MemoryAllocationFailed\");\n              for (i=WPG_Palette.StartIndex;\n                   i < (int)WPG_Palette.NumOfEntries; i++)\n                {\n                  image->colormap[i].red=ScaleCharToQuantum((char)\n                    ReadBlobByte(image));\n                  image->colormap[i].green=ScaleCharToQuantum((char)\n                    ReadBlobByte(image));\n                  image->colormap[i].blue=ScaleCharToQuantum((char)\n                    ReadBlobByte(image));\n                  (void) ReadBlobByte(image);   \/*Opacity??*\/\n                }\n              break;\n            case 0x0E:\n              Bitmap2Header1.Width=ReadBlobLSBShort(image);\n              Bitmap2Header1.Height=ReadBlobLSBShort(image);\n              if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0))\n                ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n              Bitmap2Header1.Depth=ReadBlobByte(image);\n              Bitmap2Header1.Compression=ReadBlobByte(image);\n\n              if(Bitmap2Header1.Compression > 1)\n                continue; \/*Unknown compression method *\/\n              switch(Bitmap2Header1.Depth)\n                {\n                case 1:\n                  bpp=1;\n                  break;\n                case 2:\n                  bpp=2;\n                  break;\n                case 3:\n                  bpp=4;\n                  break;\n                case 4:\n                  bpp=8;\n                  break;\n                case 8:\n                  bpp=24;\n                  break;\n                default:\n                  continue;  \/*Ignore raster with unknown depth*\/\n                }\n              image->columns=Bitmap2Header1.Width;\n              image->rows=Bitmap2Header1.Height;\n              status=SetImageExtent(image,image->columns,image->rows,exception);\n              if (status == MagickFalse)\n                break;\n              if ((image->colors == 0) && (bpp != 24))\n                {\n                  image->colors=one << bpp;\n                  if (!AcquireImageColormap(image,image->colors,exception))\n                    goto NoMemory;\n                }\n              else\n                {\n                  if(bpp < 24)\n                    if( image->colors<(one << bpp) && bpp!=24 )\n                      image->colormap=(PixelInfo *) ResizeQuantumMemory(\n                       image->colormap,(size_t) (one << bpp),\n                       sizeof(*image->colormap));\n                }\n\n\n              switch(Bitmap2Header1.Compression)\n                {\n                case 0:    \/*Uncompressed raster*\/\n                  {\n                    ldblk=(ssize_t) ((bpp*image->columns+7)\/8);\n                    BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t)\n                      ldblk+1,sizeof(*BImgBuff));\n                    if (BImgBuff == (unsigned char *) NULL)\n                      goto NoMemory;\n\n                    for(i=0; i< (ssize_t) image->rows; i++)\n                      {\n                        (void) ReadBlob(image,ldblk,BImgBuff);\n                        InsertRow(image,BImgBuff,i,bpp,exception);\n                      }\n\n                    if(BImgBuff)\n                      BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);\n                    break;\n                  }\n                case 1:    \/*RLE for WPG2 *\/\n                  {\n                    if( UnpackWPG2Raster(image,bpp,exception) < 0)\n                      goto DecompressionFailed;\n                    break;\n                  }   \n                }\n\n              if(CTM[0][0]<0 && !image_info->ping)\n                {    \/*?? RotAngle=360-RotAngle;*\/\n                  Image\n                    *flop_image;\n\n                  flop_image = FlopImage(image, exception);\n                  if (flop_image != (Image *) NULL) {\n                    DuplicateBlob(flop_image,image);\n                    ReplaceImageInList(&image,flop_image);\n                  }\n                  \/* Try to change CTM according to Flip - I am not sure, must be checked.\n                     Tx(0,0)=-1;      Tx(1,0)=0;   Tx(2,0)=0;\n                     Tx(0,1)= 0;      Tx(1,1)=1;   Tx(2,1)=0;\n                     Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll);\n                     Tx(1,2)=0;   Tx(2,2)=1; *\/\n                }\n              if(CTM[1][1]<0 && !image_info->ping)\n                {    \/*?? RotAngle=360-RotAngle;*\/\n                  Image\n                    *flip_image;\n\n                   flip_image = FlipImage(image, exception);\n                   if (flip_image != (Image *) NULL) {\n                     DuplicateBlob(flip_image,image);\n                     ReplaceImageInList(&image,flip_image);\n                    }\n                  \/* Try to change CTM according to Flip - I am not sure, must be checked.\n                     float_matrix Tx(3,3);\n                     Tx(0,0)= 1;   Tx(1,0)= 0;   Tx(2,0)=0;\n                     Tx(0,1)= 0;   Tx(1,1)=-1;   Tx(2,1)=0;\n                     Tx(0,2)= 0;   Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll);\n                     Tx(2,2)=1; *\/\n              }\n\n\n              \/* Allocate next image structure. *\/\n              AcquireNextImage(image_info,image,exception);\n              image->depth=8;\n              if (image->next == (Image *) NULL)\n                goto Finish;\n              image=SyncNextImageInList(image);\n              image->columns=image->rows=1;\n              image->colors=0;\n              break;\n\n            case 0x12:  \/* Postscript WPG2*\/\n        i=ReadBlobLSBShort(image);\n              if(Rec2.RecordLength > (unsigned int) i)\n                image=ExtractPostscript(image,image_info,\n                  TellBlob(image)+i,    \/*skip PS header in the wpg2*\/\n                  (ssize_t) (Rec2.RecordLength-i-2),exception);\n              break;\n\n      case 0x1B:          \/*bitmap rectangle*\/\n              WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM);\n              (void) WPG2Flags;\n              break;\n            }\n        }\n\n      break;\n\n    default:\n      {\n         ThrowReaderException(CoderError,\"DataEncodingSchemeIsNotSupported\");\n      }\n   }\n\n Finish:\n  (void) CloseBlob(image);\n\n  {\n    Image\n      *p;\n\n    ssize_t\n      scene=0;\n\n    \/*\n      Rewind list, removing any empty images while rewinding.\n    *\/\n    p=image;\n    image=NULL;\n    while (p != (Image *) NULL)\n      {\n        Image *tmp=p;\n        if ((p->rows == 0) || (p->columns == 0)) {\n          p=p->previous;\n          DeleteImageFromList(&tmp);\n        } else {\n          image=p;\n          p=p->previous;\n        }\n      }\n    \/*\n      Fix scene numbers.\n    *\/\n    for (p=image; p != (Image *) NULL; p=p->next)\n      p->scene=(size_t) scene++;\n  }\n  if (image == (Image *) NULL)\n    ThrowReaderException(CorruptImageError,\n      \"ImageFileDoesNotContainAnyImageData\");\n  return(image);\n}","target":1,"code_token_length":4801,"total_token_length":5037,"max_tokens_setting":6144}
+{"idx":196328,"func":"find_pattern_in_path(\n    char_u\t*ptr,\t\t\/\/ pointer to search pattern\n    int\t\tdir UNUSED,\t\/\/ direction of expansion\n    int\t\tlen,\t\t\/\/ length of search pattern\n    int\t\twhole,\t\t\/\/ match whole words only\n    int\t\tskip_comments,\t\/\/ don't match inside comments\n    int\t\ttype,\t\t\/\/ Type of search; are we looking for a type?\n\t\t\t\t\/\/ a macro?\n    long\tcount,\n    int\t\taction,\t\t\/\/ What to do when we find it\n    linenr_T\tstart_lnum,\t\/\/ first line to start searching\n    linenr_T\tend_lnum)\t\/\/ last line for searching\n{\n    SearchedFile *files;\t\t\/\/ Stack of included files\n    SearchedFile *bigger;\t\t\/\/ When we need more space\n    int\t\tmax_path_depth = 50;\n    long\tmatch_count = 1;\n\n    char_u\t*pat;\n    char_u\t*new_fname;\n    char_u\t*curr_fname = curbuf->b_fname;\n    char_u\t*prev_fname = NULL;\n    linenr_T\tlnum;\n    int\t\tdepth;\n    int\t\tdepth_displayed;\t\/\/ For type==CHECK_PATH\n    int\t\told_files;\n    int\t\talready_searched;\n    char_u\t*file_line;\n    char_u\t*line;\n    char_u\t*p;\n    char_u\tsave_char;\n    int\t\tdefine_matched;\n    regmatch_T\tregmatch;\n    regmatch_T\tincl_regmatch;\n    regmatch_T\tdef_regmatch;\n    int\t\tmatched = FALSE;\n    int\t\tdid_show = FALSE;\n    int\t\tfound = FALSE;\n    int\t\ti;\n    char_u\t*already = NULL;\n    char_u\t*startp = NULL;\n    char_u\t*inc_opt = NULL;\n#if defined(FEAT_QUICKFIX)\n    win_T\t*curwin_save = NULL;\n#endif\n\n    regmatch.regprog = NULL;\n    incl_regmatch.regprog = NULL;\n    def_regmatch.regprog = NULL;\n\n    file_line = alloc(LSIZE);\n    if (file_line == NULL)\n\treturn;\n\n    if (type != CHECK_PATH && type != FIND_DEFINE\n\t    \/\/ when CONT_SOL is set compare \"ptr\" with the beginning of the\n\t    \/\/ line is faster than quote_meta\/regcomp\/regexec \"ptr\" -- Acevedo\n\t    && !compl_status_sol())\n    {\n\tpat = alloc(len + 5);\n\tif (pat == NULL)\n\t    goto fpip_end;\n\tsprintf((char *)pat, whole ? \"\\\\<%.*s\\\\>\" : \"%.*s\", len, ptr);\n\t\/\/ ignore case according to p_ic, p_scs and pat\n\tregmatch.rm_ic = ignorecase(pat);\n\tregmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);\n\tvim_free(pat);\n\tif (regmatch.regprog == NULL)\n\t    goto fpip_end;\n    }\n    inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc;\n    if (*inc_opt != NUL)\n    {\n\tincl_regmatch.regprog = vim_regcomp(inc_opt,\n\t\t\t\t\t\t magic_isset() ? RE_MAGIC : 0);\n\tif (incl_regmatch.regprog == NULL)\n\t    goto fpip_end;\n\tincl_regmatch.rm_ic = FALSE;\t\/\/ don't ignore case in incl. pat.\n    }\n    if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL))\n    {\n\tdef_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL\n\t\t\t   ? p_def : curbuf->b_p_def,\n\t\t\t\t\t\t magic_isset() ? RE_MAGIC : 0);\n\tif (def_regmatch.regprog == NULL)\n\t    goto fpip_end;\n\tdef_regmatch.rm_ic = FALSE;\t\/\/ don't ignore case in define pat.\n    }\n    files = lalloc_clear(max_path_depth * sizeof(SearchedFile), TRUE);\n    if (files == NULL)\n\tgoto fpip_end;\n    old_files = max_path_depth;\n    depth = depth_displayed = -1;\n\n    lnum = start_lnum;\n    if (end_lnum > curbuf->b_ml.ml_line_count)\n\tend_lnum = curbuf->b_ml.ml_line_count;\n    if (lnum > end_lnum)\t\t\/\/ do at least one line\n\tlnum = end_lnum;\n    line = ml_get(lnum);\n\n    for (;;)\n    {\n\tif (incl_regmatch.regprog != NULL\n\t\t&& vim_regexec(&incl_regmatch, line, (colnr_T)0))\n\t{\n\t    char_u *p_fname = (curr_fname == curbuf->b_fname)\n\t\t\t\t\t      ? curbuf->b_ffname : curr_fname;\n\n\t    if (inc_opt != NULL && strstr((char *)inc_opt, \"\\\\zs\") != NULL)\n\t\t\/\/ Use text from '\\zs' to '\\ze' (or end) of 'include'.\n\t\tnew_fname = find_file_name_in_path(incl_regmatch.startp[0],\n\t\t       (int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]),\n\t\t\t\t FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname);\n\t    else\n\t\t\/\/ Use text after match with 'include'.\n\t\tnew_fname = file_name_in_line(incl_regmatch.endp[0], 0,\n\t\t\t     FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL);\n\t    already_searched = FALSE;\n\t    if (new_fname != NULL)\n\t    {\n\t\t\/\/ Check whether we have already searched in this file\n\t\tfor (i = 0;; i++)\n\t\t{\n\t\t    if (i == depth + 1)\n\t\t\ti = old_files;\n\t\t    if (i == max_path_depth)\n\t\t\tbreak;\n\t\t    if (fullpathcmp(new_fname, files[i].name, TRUE, TRUE)\n\t\t\t\t\t\t\t\t    & FPC_SAME)\n\t\t    {\n\t\t\tif (type != CHECK_PATH\n\t\t\t\t&& action == ACTION_SHOW_ALL\n\t\t\t\t&& files[i].matched)\n\t\t\t{\n\t\t\t    msg_putchar('\\n');\t    \/\/ cursor below last one\n\t\t\t    if (!got_int)\t    \/\/ don't display if 'q'\n\t\t\t\t\t\t    \/\/ typed at \"--more--\"\n\t\t\t\t\t\t    \/\/ message\n\t\t\t    {\n\t\t\t\tmsg_home_replace_hl(new_fname);\n\t\t\t\tmsg_puts(_(\" (includes previously listed match)\"));\n\t\t\t\tprev_fname = NULL;\n\t\t\t    }\n\t\t\t}\n\t\t\tVIM_CLEAR(new_fname);\n\t\t\talready_searched = TRUE;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\n\t    if (type == CHECK_PATH && (action == ACTION_SHOW_ALL\n\t\t\t\t || (new_fname == NULL && !already_searched)))\n\t    {\n\t\tif (did_show)\n\t\t    msg_putchar('\\n');\t    \/\/ cursor below last one\n\t\telse\n\t\t{\n\t\t    gotocmdline(TRUE);\t    \/\/ cursor at status line\n\t\t    msg_puts_title(_(\"--- Included files \"));\n\t\t    if (action != ACTION_SHOW_ALL)\n\t\t\tmsg_puts_title(_(\"not found \"));\n\t\t    msg_puts_title(_(\"in path ---\\n\"));\n\t\t}\n\t\tdid_show = TRUE;\n\t\twhile (depth_displayed < depth && !got_int)\n\t\t{\n\t\t    ++depth_displayed;\n\t\t    for (i = 0; i < depth_displayed; i++)\n\t\t\tmsg_puts(\"  \");\n\t\t    msg_home_replace(files[depth_displayed].name);\n\t\t    msg_puts(\" -->\\n\");\n\t\t}\n\t\tif (!got_int)\t\t    \/\/ don't display if 'q' typed\n\t\t\t\t\t    \/\/ for \"--more--\" message\n\t\t{\n\t\t    for (i = 0; i <= depth_displayed; i++)\n\t\t\tmsg_puts(\"  \");\n\t\t    if (new_fname != NULL)\n\t\t    {\n\t\t\t\/\/ using \"new_fname\" is more reliable, e.g., when\n\t\t\t\/\/ 'includeexpr' is set.\n\t\t\tmsg_outtrans_attr(new_fname, HL_ATTR(HLF_D));\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/*\n\t\t\t * Isolate the file name.\n\t\t\t * Include the surrounding \"\" or <> if present.\n\t\t\t *\/\n\t\t\tif (inc_opt != NULL\n\t\t\t\t   && strstr((char *)inc_opt, \"\\\\zs\") != NULL)\n\t\t\t{\n\t\t\t    \/\/ pattern contains \\zs, use the match\n\t\t\t    p = incl_regmatch.startp[0];\n\t\t\t    i = (int)(incl_regmatch.endp[0]\n\t\t\t\t\t\t   - incl_regmatch.startp[0]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ find the file name after the end of the match\n\t\t\t    for (p = incl_regmatch.endp[0];\n\t\t\t\t\t\t  *p && !vim_isfilec(*p); p++)\n\t\t\t\t;\n\t\t\t    for (i = 0; vim_isfilec(p[i]); i++)\n\t\t\t\t;\n\t\t\t}\n\n\t\t\tif (i == 0)\n\t\t\t{\n\t\t\t    \/\/ Nothing found, use the rest of the line.\n\t\t\t    p = incl_regmatch.endp[0];\n\t\t\t    i = (int)STRLEN(p);\n\t\t\t}\n\t\t\t\/\/ Avoid checking before the start of the line, can\n\t\t\t\/\/ happen if \\zs appears in the regexp.\n\t\t\telse if (p > line)\n\t\t\t{\n\t\t\t    if (p[-1] == '\"' || p[-1] == '<')\n\t\t\t    {\n\t\t\t\t--p;\n\t\t\t\t++i;\n\t\t\t    }\n\t\t\t    if (p[i] == '\"' || p[i] == '>')\n\t\t\t\t++i;\n\t\t\t}\n\t\t\tsave_char = p[i];\n\t\t\tp[i] = NUL;\n\t\t\tmsg_outtrans_attr(p, HL_ATTR(HLF_D));\n\t\t\tp[i] = save_char;\n\t\t    }\n\n\t\t    if (new_fname == NULL && action == ACTION_SHOW_ALL)\n\t\t    {\n\t\t\tif (already_searched)\n\t\t\t    msg_puts(_(\"  (Already listed)\"));\n\t\t\telse\n\t\t\t    msg_puts(_(\"  NOT FOUND\"));\n\t\t    }\n\t\t}\n\t\tout_flush();\t    \/\/ output each line directly\n\t    }\n\n\t    if (new_fname != NULL)\n\t    {\n\t\t\/\/ Push the new file onto the file stack\n\t\tif (depth + 1 == old_files)\n\t\t{\n\t\t    bigger = ALLOC_MULT(SearchedFile, max_path_depth * 2);\n\t\t    if (bigger != NULL)\n\t\t    {\n\t\t\tfor (i = 0; i <= depth; i++)\n\t\t\t    bigger[i] = files[i];\n\t\t\tfor (i = depth + 1; i < old_files + max_path_depth; i++)\n\t\t\t{\n\t\t\t    bigger[i].fp = NULL;\n\t\t\t    bigger[i].name = NULL;\n\t\t\t    bigger[i].lnum = 0;\n\t\t\t    bigger[i].matched = FALSE;\n\t\t\t}\n\t\t\tfor (i = old_files; i < max_path_depth; i++)\n\t\t\t    bigger[i + max_path_depth] = files[i];\n\t\t\told_files += max_path_depth;\n\t\t\tmax_path_depth *= 2;\n\t\t\tvim_free(files);\n\t\t\tfiles = bigger;\n\t\t    }\n\t\t}\n\t\tif ((files[depth + 1].fp = mch_fopen((char *)new_fname, \"r\"))\n\t\t\t\t\t\t\t\t    == NULL)\n\t\t    vim_free(new_fname);\n\t\telse\n\t\t{\n\t\t    if (++depth == old_files)\n\t\t    {\n\t\t\t\/*\n\t\t\t * lalloc() for 'bigger' must have failed above.  We\n\t\t\t * will forget one of our already visited files now.\n\t\t\t *\/\n\t\t\tvim_free(files[old_files].name);\n\t\t\t++old_files;\n\t\t    }\n\t\t    files[depth].name = curr_fname = new_fname;\n\t\t    files[depth].lnum = 0;\n\t\t    files[depth].matched = FALSE;\n\t\t    if (action == ACTION_EXPAND)\n\t\t    {\n\t\t\tmsg_hist_off = TRUE;\t\/\/ reset in msg_trunc_attr()\n\t\t\tvim_snprintf((char*)IObuff, IOSIZE,\n\t\t\t\t_(\"Scanning included file: %s\"),\n\t\t\t\t(char *)new_fname);\n\t\t\tmsg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R));\n\t\t    }\n\t\t    else if (p_verbose >= 5)\n\t\t    {\n\t\t\tverbose_enter();\n\t\t\tsmsg(_(\"Searching included file %s\"),\n\t\t\t\t\t\t\t   (char *)new_fname);\n\t\t\tverbose_leave();\n\t\t    }\n\n\t\t}\n\t    }\n\t}\n\telse\n\t{\n\t    \/*\n\t     * Check if the line is a define (type == FIND_DEFINE)\n\t     *\/\n\t    p = line;\nsearch_line:\n\t    define_matched = FALSE;\n\t    if (def_regmatch.regprog != NULL\n\t\t\t      && vim_regexec(&def_regmatch, line, (colnr_T)0))\n\t    {\n\t\t\/*\n\t\t * Pattern must be first identifier after 'define', so skip\n\t\t * to that position before checking for match of pattern.  Also\n\t\t * don't let it match beyond the end of this identifier.\n\t\t *\/\n\t\tp = def_regmatch.endp[0];\n\t\twhile (*p && !vim_iswordc(*p))\n\t\t    p++;\n\t\tdefine_matched = TRUE;\n\t    }\n\n\t    \/*\n\t     * Look for a match.  Don't do this if we are looking for a\n\t     * define and this line didn't match define_prog above.\n\t     *\/\n\t    if (def_regmatch.regprog == NULL || define_matched)\n\t    {\n\t\tif (define_matched || compl_status_sol())\n\t\t{\n\t\t    \/\/ compare the first \"len\" chars from \"ptr\"\n\t\t    startp = skipwhite(p);\n\t\t    if (p_ic)\n\t\t\tmatched = !MB_STRNICMP(startp, ptr, len);\n\t\t    else\n\t\t\tmatched = !STRNCMP(startp, ptr, len);\n\t\t    if (matched && define_matched && whole\n\t\t\t\t\t\t  && vim_iswordc(startp[len]))\n\t\t\tmatched = FALSE;\n\t\t}\n\t\telse if (regmatch.regprog != NULL\n\t\t\t && vim_regexec(®match, line, (colnr_T)(p - line)))\n\t\t{\n\t\t    matched = TRUE;\n\t\t    startp = regmatch.startp[0];\n\t\t    \/*\n\t\t     * Check if the line is not a comment line (unless we are\n\t\t     * looking for a define).  A line starting with \"# define\"\n\t\t     * is not considered to be a comment line.\n\t\t     *\/\n\t\t    if (!define_matched && skip_comments)\n\t\t    {\n\t\t\tif ((*line != '#' ||\n\t\t\t\tSTRNCMP(skipwhite(line + 1), \"define\", 6) != 0)\n\t\t\t\t&& get_leader_len(line, NULL, FALSE, TRUE))\n\t\t\t    matched = FALSE;\n\n\t\t\t\/*\n\t\t\t * Also check for a \"\/ *\" or \"\/ \/\" before the match.\n\t\t\t * Skips lines like \"int backwards;  \/ * normal index\n\t\t\t * * \/\" when looking for \"normal\".\n\t\t\t * Note: Doesn't skip \"\/ *\" in comments.\n\t\t\t *\/\n\t\t\tp = skipwhite(line);\n\t\t\tif (matched\n\t\t\t\t|| (p[0] == '\/' && p[1] == '*') || p[0] == '*')\n\t\t\t    for (p = line; *p && p < startp; ++p)\n\t\t\t    {\n\t\t\t\tif (matched\n\t\t\t\t\t&& p[0] == '\/'\n\t\t\t\t\t&& (p[1] == '*' || p[1] == '\/'))\n\t\t\t\t{\n\t\t\t\t    matched = FALSE;\n\t\t\t\t    \/\/ After \"\/\/\" all text is comment\n\t\t\t\t    if (p[1] == '\/')\n\t\t\t\t\tbreak;\n\t\t\t\t    ++p;\n\t\t\t\t}\n\t\t\t\telse if (!matched && p[0] == '*' && p[1] == '\/')\n\t\t\t\t{\n\t\t\t\t    \/\/ Can find match after \"* \/\".\n\t\t\t\t    matched = TRUE;\n\t\t\t\t    ++p;\n\t\t\t\t}\n\t\t\t    }\n\t\t    }\n\t\t}\n\t    }\n\t}\n\tif (matched)\n\t{\n\t    if (action == ACTION_EXPAND)\n\t    {\n\t\tint\tcont_s_ipos = FALSE;\n\t\tint\tadd_r;\n\t\tchar_u\t*aux;\n\n\t\tif (depth == -1 && lnum == curwin->w_cursor.lnum)\n\t\t    break;\n\t\tfound = TRUE;\n\t\taux = p = startp;\n\t\tif (compl_status_adding())\n\t\t{\n\t\t    p += ins_compl_len();\n\t\t    if (vim_iswordp(p))\n\t\t\tgoto exit_matched;\n\t\t    p = find_word_start(p);\n\t\t}\n\t\tp = find_word_end(p);\n\t\ti = (int)(p - aux);\n\n\t\tif (compl_status_adding() && i == ins_compl_len())\n\t\t{\n\t\t    \/\/ IOSIZE > compl_length, so the STRNCPY works\n\t\t    STRNCPY(IObuff, aux, i);\n\n\t\t    \/\/ Get the next line: when \"depth\" < 0  from the current\n\t\t    \/\/ buffer, otherwise from the included file.  Jump to\n\t\t    \/\/ exit_matched when past the last line.\n\t\t    if (depth < 0)\n\t\t    {\n\t\t\tif (lnum >= end_lnum)\n\t\t\t    goto exit_matched;\n\t\t\tline = ml_get(++lnum);\n\t\t    }\n\t\t    else if (vim_fgets(line = file_line,\n\t\t\t\t\t\t      LSIZE, files[depth].fp))\n\t\t\tgoto exit_matched;\n\n\t\t    \/\/ we read a line, set \"already\" to check this \"line\" later\n\t\t    \/\/ if depth >= 0 we'll increase files[depth].lnum far\n\t\t    \/\/ below  -- Acevedo\n\t\t    already = aux = p = skipwhite(line);\n\t\t    p = find_word_start(p);\n\t\t    p = find_word_end(p);\n\t\t    if (p > aux)\n\t\t    {\n\t\t\tif (*aux != ')' && IObuff[i-1] != TAB)\n\t\t\t{\n\t\t\t    if (IObuff[i-1] != ' ')\n\t\t\t\tIObuff[i++] = ' ';\n\t\t\t    \/\/ IObuf =~ \"\\(\\k\\|\\i\\).* \", thus i >= 2\n\t\t\t    if (p_js\n\t\t\t\t&& (IObuff[i-2] == '.'\n\t\t\t\t    || (vim_strchr(p_cpo, CPO_JOINSP) == NULL\n\t\t\t\t\t&& (IObuff[i-2] == '?'\n\t\t\t\t\t    || IObuff[i-2] == '!'))))\n\t\t\t\tIObuff[i++] = ' ';\n\t\t\t}\n\t\t\t\/\/ copy as much as possible of the new word\n\t\t\tif (p - aux >= IOSIZE - i)\n\t\t\t    p = aux + IOSIZE - i - 1;\n\t\t\tSTRNCPY(IObuff + i, aux, p - aux);\n\t\t\ti += (int)(p - aux);\n\t\t\tcont_s_ipos = TRUE;\n\t\t    }\n\t\t    IObuff[i] = NUL;\n\t\t    aux = IObuff;\n\n\t\t    if (i == ins_compl_len())\n\t\t\tgoto exit_matched;\n\t\t}\n\n\t\tadd_r = ins_compl_add_infercase(aux, i, p_ic,\n\t\t\tcurr_fname == curbuf->b_fname ? NULL : curr_fname,\n\t\t\tdir, cont_s_ipos);\n\t\tif (add_r == OK)\n\t\t    \/\/ if dir was BACKWARD then honor it just once\n\t\t    dir = FORWARD;\n\t\telse if (add_r == FAIL)\n\t\t    break;\n\t    }\n\t    else if (action == ACTION_SHOW_ALL)\n\t    {\n\t\tfound = TRUE;\n\t\tif (!did_show)\n\t\t    gotocmdline(TRUE);\t\t\/\/ cursor at status line\n\t\tif (curr_fname != prev_fname)\n\t\t{\n\t\t    if (did_show)\n\t\t\tmsg_putchar('\\n');\t\/\/ cursor below last one\n\t\t    if (!got_int)\t\t\/\/ don't display if 'q' typed\n\t\t\t\t\t\t\/\/ at \"--more--\" message\n\t\t\tmsg_home_replace_hl(curr_fname);\n\t\t    prev_fname = curr_fname;\n\t\t}\n\t\tdid_show = TRUE;\n\t\tif (!got_int)\n\t\t    show_pat_in_path(line, type, TRUE, action,\n\t\t\t    (depth == -1) ? NULL : files[depth].fp,\n\t\t\t    (depth == -1) ? &lnum : &files[depth].lnum,\n\t\t\t    match_count++);\n\n\t\t\/\/ Set matched flag for this file and all the ones that\n\t\t\/\/ include it\n\t\tfor (i = 0; i <= depth; ++i)\n\t\t    files[i].matched = TRUE;\n\t    }\n\t    else if (--count <= 0)\n\t    {\n\t\tfound = TRUE;\n\t\tif (depth == -1 && lnum == curwin->w_cursor.lnum\n#if defined(FEAT_QUICKFIX)\n\t\t\t\t\t\t      && g_do_tagpreview == 0\n#endif\n\t\t\t\t\t\t      )\n\t\t    emsg(_(e_match_is_on_current_line));\n\t\telse if (action == ACTION_SHOW)\n\t\t{\n\t\t    show_pat_in_path(line, type, did_show, action,\n\t\t\t(depth == -1) ? NULL : files[depth].fp,\n\t\t\t(depth == -1) ? &lnum : &files[depth].lnum, 1L);\n\t\t    did_show = TRUE;\n\t\t}\n\t\telse\n\t\t{\n#ifdef FEAT_GUI\n\t\t    need_mouse_correct = TRUE;\n#endif\n#if defined(FEAT_QUICKFIX)\n\t\t    \/\/ \":psearch\" uses the preview window\n\t\t    if (g_do_tagpreview != 0)\n\t\t    {\n\t\t\tcurwin_save = curwin;\n\t\t\tprepare_tagpreview(TRUE, TRUE, FALSE);\n\t\t    }\n#endif\n\t\t    if (action == ACTION_SPLIT)\n\t\t    {\n\t\t\tif (win_split(0, 0) == FAIL)\n\t\t\t    break;\n\t\t\tRESET_BINDING(curwin);\n\t\t    }\n\t\t    if (depth == -1)\n\t\t    {\n\t\t\t\/\/ match in current file\n#if defined(FEAT_QUICKFIX)\n\t\t\tif (g_do_tagpreview != 0)\n\t\t\t{\n\t\t\t    if (!win_valid(curwin_save))\n\t\t\t\tbreak;\n\t\t\t    if (!GETFILE_SUCCESS(getfile(\n\t\t\t\t\t   curwin_save->w_buffer->b_fnum, NULL,\n\t\t\t\t\t\t     NULL, TRUE, lnum, FALSE)))\n\t\t\t\tbreak;\t\/\/ failed to jump to file\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\t    setpcmark();\n\t\t\tcurwin->w_cursor.lnum = lnum;\n\t\t\tcheck_cursor();\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tif (!GETFILE_SUCCESS(getfile(\n\t\t\t\t\t0, files[depth].name, NULL, TRUE,\n\t\t\t\t\t\t    files[depth].lnum, FALSE)))\n\t\t\t    break;\t\/\/ failed to jump to file\n\t\t\t\/\/ autocommands may have changed the lnum, we don't\n\t\t\t\/\/ want that here\n\t\t\tcurwin->w_cursor.lnum = files[depth].lnum;\n\t\t    }\n\t\t}\n\t\tif (action != ACTION_SHOW)\n\t\t{\n\t\t    curwin->w_cursor.col = (colnr_T)(startp - line);\n\t\t    curwin->w_set_curswant = TRUE;\n\t\t}\n\n#if defined(FEAT_QUICKFIX)\n\t\tif (g_do_tagpreview != 0\n\t\t\t   && curwin != curwin_save && win_valid(curwin_save))\n\t\t{\n\t\t    \/\/ Return cursor to where we were\n\t\t    validate_cursor();\n\t\t    redraw_later(VALID);\n\t\t    win_enter(curwin_save, TRUE);\n\t\t}\n# ifdef FEAT_PROP_POPUP\n\t\telse if (WIN_IS_POPUP(curwin))\n\t\t    \/\/ can't keep focus in popup window\n\t\t    win_enter(firstwin, TRUE);\n# endif\n#endif\n\t\tbreak;\n\t    }\nexit_matched:\n\t    matched = FALSE;\n\t    \/\/ look for other matches in the rest of the line if we\n\t    \/\/ are not at the end of it already\n\t    if (def_regmatch.regprog == NULL\n\t\t    && action == ACTION_EXPAND\n\t\t    && !compl_status_sol()\n\t\t    && *startp != NUL\n\t\t    && *(p = startp + mb_ptr2len(startp)) != NUL)\n\t\tgoto search_line;\n\t}\n\tline_breakcheck();\n\tif (action == ACTION_EXPAND)\n\t    ins_compl_check_keys(30, FALSE);\n\tif (got_int || ins_compl_interrupted())\n\t    break;\n\n\t\/*\n\t * Read the next line.  When reading an included file and encountering\n\t * end-of-file, close the file and continue in the file that included\n\t * it.\n\t *\/\n\twhile (depth >= 0 && !already\n\t\t&& vim_fgets(line = file_line, LSIZE, files[depth].fp))\n\t{\n\t    fclose(files[depth].fp);\n\t    --old_files;\n\t    files[old_files].name = files[depth].name;\n\t    files[old_files].matched = files[depth].matched;\n\t    --depth;\n\t    curr_fname = (depth == -1) ? curbuf->b_fname\n\t\t\t\t       : files[depth].name;\n\t    if (depth < depth_displayed)\n\t\tdepth_displayed = depth;\n\t}\n\tif (depth >= 0)\t\t\/\/ we could read the line\n\t{\n\t    files[depth].lnum++;\n\t    \/\/ Remove any CR and LF from the line.\n\t    i = (int)STRLEN(line);\n\t    if (i > 0 && line[i - 1] == '\\n')\n\t\tline[--i] = NUL;\n\t    if (i > 0 && line[i - 1] == '\\r')\n\t\tline[--i] = NUL;\n\t}\n\telse if (!already)\n\t{\n\t    if (++lnum > end_lnum)\n\t\tbreak;\n\t    line = ml_get(lnum);\n\t}\n\talready = NULL;\n    }\n    \/\/ End of big for (;;) loop.\n\n    \/\/ Close any files that are still open.\n    for (i = 0; i <= depth; i++)\n    {\n\tfclose(files[i].fp);\n\tvim_free(files[i].name);\n    }\n    for (i = old_files; i < max_path_depth; i++)\n\tvim_free(files[i].name);\n    vim_free(files);\n\n    if (type == CHECK_PATH)\n    {\n\tif (!did_show)\n\t{\n\t    if (action != ACTION_SHOW_ALL)\n\t\tmsg(_(\"All included files were found\"));\n\t    else\n\t\tmsg(_(\"No included files\"));\n\t}\n    }\n    else if (!found && action != ACTION_EXPAND)\n    {\n\tif (got_int || ins_compl_interrupted())\n\t    emsg(_(e_interrupted));\n\telse if (type == FIND_DEFINE)\n\t    emsg(_(e_couldnt_find_definition));\n\telse\n\t    emsg(_(e_couldnt_find_pattern));\n    }\n    if (action == ACTION_SHOW || action == ACTION_SHOW_ALL)\n\tmsg_end();\n\nfpip_end:\n    vim_free(file_line);\n    vim_regfree(regmatch.regprog);\n    vim_regfree(incl_regmatch.regprog);\n    vim_regfree(def_regmatch.regprog);\n}","target":1,"code_token_length":5564,"total_token_length":5800,"max_tokens_setting":6144}
+{"idx":227031,"func":"irc_protocol_recv_command (struct t_irc_server *server,\n                           const char *irc_message,\n                           const char *msg_command,\n                           const char *msg_channel)\n{\n    int i, cmd_found, return_code, argc, decode_color, keep_trailing_spaces;\n    int message_ignored, flags;\n    char *message_colors_decoded, *pos_space, *tags;\n    struct t_irc_channel *ptr_channel;\n    t_irc_recv_func *cmd_recv_func;\n    const char *cmd_name, *ptr_msg_after_tags;\n    time_t date;\n    const char *nick1, *address1, *host1;\n    char *nick, *address, *address_color, *host, *host_no_color, *host_color;\n    char **argv, **argv_eol;\n    struct t_hashtable *hash_tags;\n    struct t_irc_protocol_msg irc_protocol_messages[] =\n        { { \"account\", \/* account (cap account-notify) *\/ 1, 0, &irc_protocol_cb_account },\n          { \"authenticate\", \/* authenticate *\/ 1, 0, &irc_protocol_cb_authenticate },\n          { \"away\", \/* away (cap away-notify) *\/ 1, 0, &irc_protocol_cb_away },\n          { \"cap\", \/* client capability *\/ 1, 0, &irc_protocol_cb_cap },\n          { \"chghost\", \/* user\/host change (cap chghost) *\/ 1, 0, &irc_protocol_cb_chghost },\n          { \"error\", \/* error received from IRC server *\/ 1, 0, &irc_protocol_cb_error },\n          { \"invite\", \/* invite a nick on a channel *\/ 1, 0, &irc_protocol_cb_invite },\n          { \"join\", \/* join a channel *\/ 1, 0, &irc_protocol_cb_join },\n          { \"kick\", \/* forcibly remove a user from a channel *\/ 1, 1, &irc_protocol_cb_kick },\n          { \"kill\", \/* close client-server connection *\/ 1, 1, &irc_protocol_cb_kill },\n          { \"mode\", \/* change channel or user mode *\/ 1, 0, &irc_protocol_cb_mode },\n          { \"nick\", \/* change current nickname *\/ 1, 0, &irc_protocol_cb_nick },\n          { \"notice\", \/* send notice message to user *\/ 1, 1, &irc_protocol_cb_notice },\n          { \"part\", \/* leave a channel *\/ 1, 1, &irc_protocol_cb_part },\n          { \"ping\", \/* ping server *\/ 1, 0, &irc_protocol_cb_ping },\n          { \"pong\", \/* answer to a ping message *\/ 1, 0, &irc_protocol_cb_pong },\n          { \"privmsg\", \/* message received *\/ 1, 1, &irc_protocol_cb_privmsg },\n          { \"quit\", \/* close all connections and quit *\/ 1, 1, &irc_protocol_cb_quit },\n          { \"topic\", \/* get\/set channel topic *\/ 0, 1, &irc_protocol_cb_topic },\n          { \"wallops\", \/* send a message to all currently connected users who have \"\n                          \"set the 'w' user mode \"\n                          \"for themselves *\/ 1, 1, &irc_protocol_cb_wallops },\n          { \"001\", \/* a server message *\/ 1, 0, &irc_protocol_cb_001 },\n          { \"005\", \/* a server message *\/ 1, 0, &irc_protocol_cb_005 },\n          { \"008\", \/* server notice mask *\/ 1, 0, &irc_protocol_cb_008 },\n          { \"221\", \/* user mode string *\/ 1, 0, &irc_protocol_cb_221 },\n          { \"223\", \/* whois (charset is) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"264\", \/* whois (is using encrypted connection) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"275\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"276\", \/* whois (has client certificate fingerprint) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"301\", \/* away message *\/ 1, 1, &irc_protocol_cb_301 },\n          { \"303\", \/* ison *\/ 1, 0, &irc_protocol_cb_303 },\n          { \"305\", \/* unaway *\/ 1, 0, &irc_protocol_cb_305 },\n          { \"306\", \/* now away *\/ 1, 0, &irc_protocol_cb_306 },\n          { \"307\", \/* whois (registered nick) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"310\", \/* whois (help mode) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"311\", \/* whois (user) *\/ 1, 0, &irc_protocol_cb_311 },\n          { \"312\", \/* whois (server) *\/ 1, 0, &irc_protocol_cb_312 },\n          { \"313\", \/* whois (operator) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"314\", \/* whowas *\/ 1, 0, &irc_protocol_cb_314 },\n          { \"315\", \/* end of \/who list *\/ 1, 0, &irc_protocol_cb_315 },\n          { \"317\", \/* whois (idle) *\/ 1, 0, &irc_protocol_cb_317 },\n          { \"318\", \/* whois (end) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"319\", \/* whois (channels) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"320\", \/* whois (identified user) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"321\", \/* \/list start *\/ 1, 0, &irc_protocol_cb_321 },\n          { \"322\", \/* channel (for \/list) *\/ 1, 0, &irc_protocol_cb_322 },\n          { \"323\", \/* end of \/list *\/ 1, 0, &irc_protocol_cb_323 },\n          { \"324\", \/* channel mode *\/ 1, 0, &irc_protocol_cb_324 },\n          { \"326\", \/* whois (has oper privs) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"327\", \/* whois (host) *\/ 1, 0, &irc_protocol_cb_327 },\n          { \"328\", \/* channel url *\/ 1, 0, &irc_protocol_cb_328 },\n          { \"329\", \/* channel creation date *\/ 1, 0, &irc_protocol_cb_329 },\n          { \"330\", \/* is logged in as *\/ 1, 0, &irc_protocol_cb_330_343 },\n          { \"331\", \/* no topic for channel *\/ 1, 0, &irc_protocol_cb_331 },\n          { \"332\", \/* topic of channel *\/ 0, 1, &irc_protocol_cb_332 },\n          { \"333\", \/* infos about topic (nick and date changed) *\/ 1, 0, &irc_protocol_cb_333 },\n          { \"335\", \/* is a bot on *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"338\", \/* whois (host) *\/ 1, 0, &irc_protocol_cb_338 },\n          { \"341\", \/* inviting *\/ 1, 0, &irc_protocol_cb_341 },\n          { \"343\", \/* is opered as *\/ 1, 0, &irc_protocol_cb_330_343 },\n          { \"344\", \/* channel reop *\/ 1, 0, &irc_protocol_cb_344 },\n          { \"345\", \/* end of channel reop list *\/ 1, 0, &irc_protocol_cb_345 },\n          { \"346\", \/* invite list *\/ 1, 0, &irc_protocol_cb_346 },\n          { \"347\", \/* end of invite list *\/ 1, 0, &irc_protocol_cb_347 },\n          { \"348\", \/* channel exception list *\/ 1, 0, &irc_protocol_cb_348 },\n          { \"349\", \/* end of channel exception list *\/ 1, 0, &irc_protocol_cb_349 },\n          { \"351\", \/* server version *\/ 1, 0, &irc_protocol_cb_351 },\n          { \"352\", \/* who *\/ 1, 0, &irc_protocol_cb_352 },\n          { \"353\", \/* list of nicks on channel *\/ 1, 0, &irc_protocol_cb_353 },\n          { \"354\", \/* whox *\/ 1, 0, &irc_protocol_cb_354 },\n          { \"366\", \/* end of \/names list *\/ 1, 0, &irc_protocol_cb_366 },\n          { \"367\", \/* banlist *\/ 1, 0, &irc_protocol_cb_367 },\n          { \"368\", \/* end of banlist *\/ 1, 0, &irc_protocol_cb_368 },\n          { \"369\", \/* whowas (end) *\/ 1, 0, &irc_protocol_cb_whowas_nick_msg },\n          { \"378\", \/* whois (connecting from) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"379\", \/* whois (using modes) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"401\", \/* no such nick\/channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"402\", \/* no such server *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"403\", \/* no such channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"404\", \/* cannot send to channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"405\", \/* too many channels *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"406\", \/* was no such nick *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"407\", \/* was no such nick *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"409\", \/* no origin *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"410\", \/* no services *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"411\", \/* no recipient *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"412\", \/* no text to send *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"413\", \/* no toplevel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"414\", \/* wilcard in toplevel domain *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"421\", \/* unknown command *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"422\", \/* MOTD is missing *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"423\", \/* no administrative info *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"424\", \/* file error *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"431\", \/* no nickname given *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"432\", \/* erroneous nickname *\/ 1, 0, &irc_protocol_cb_432 },\n          { \"433\", \/* nickname already in use *\/ 1, 0, &irc_protocol_cb_433 },\n          { \"436\", \/* nickname collision *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"437\", \/* nick\/channel unavailable *\/ 1, 0, &irc_protocol_cb_437 },\n          { \"438\", \/* not authorized to change nickname *\/ 1, 0, &irc_protocol_cb_438 },\n          { \"441\", \/* user not in channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"442\", \/* not on channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"443\", \/* user already on channel *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"444\", \/* user not logged in *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"445\", \/* summon has been disabled *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"446\", \/* users has been disabled *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"451\", \/* you are not registered *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"461\", \/* not enough parameters *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"462\", \/* you may not register *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"463\", \/* your host isn't among the privileged *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"464\", \/* password incorrect *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"465\", \/* you are banned from this server *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"467\", \/* channel key already set *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"470\", \/* forwarding to another channel *\/ 1, 0, &irc_protocol_cb_470 },\n          { \"471\", \/* channel is already full *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"472\", \/* unknown mode char to me *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"473\", \/* cannot join channel (invite only) *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"474\", \/* cannot join channel (banned from channel) *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"475\", \/* cannot join channel (bad channel key) *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"476\", \/* bad channel mask *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"477\", \/* channel doesn't support modes *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"481\", \/* you're not an IRC operator *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"482\", \/* you're not channel operator *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"483\", \/* you can't kill a server! *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"484\", \/* your connection is restricted! *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"485\", \/* user is immune from kick\/deop *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"487\", \/* network split *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"491\", \/* no O-lines for your host *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"501\", \/* unknown mode flag *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"502\", \/* can't change mode for other users *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"671\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_whois_nick_msg },\n          { \"728\", \/* quietlist *\/ 1, 0, &irc_protocol_cb_728 },\n          { \"729\", \/* end of quietlist *\/ 1, 0, &irc_protocol_cb_729 },\n          { \"730\", \/* monitored nicks online *\/ 1, 0, &irc_protocol_cb_730 },\n          { \"731\", \/* monitored nicks offline *\/ 1, 0, &irc_protocol_cb_731 },\n          { \"732\", \/* list of monitored nicks *\/ 1, 0, &irc_protocol_cb_732 },\n          { \"733\", \/* end of monitor list *\/ 1, 0, &irc_protocol_cb_733 },\n          { \"734\", \/* monitor list is full *\/ 1, 0, &irc_protocol_cb_734 },\n          { \"900\", \/* logged in as (SASL) *\/ 1, 0, &irc_protocol_cb_900 },\n          { \"901\", \/* you are now logged in *\/ 1, 0, &irc_protocol_cb_901 },\n          { \"902\", \/* SASL authentication failed (account locked\/held) *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"903\", \/* SASL authentication successful *\/ 1, 0, &irc_protocol_cb_sasl_end_ok },\n          { \"904\", \/* SASL authentication failed *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"905\", \/* SASL message too long *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"906\", \/* SASL authentication aborted *\/ 1, 0, &irc_protocol_cb_sasl_end_fail },\n          { \"907\", \/* You have already completed SASL authentication *\/ 1, 0, &irc_protocol_cb_sasl_end_ok },\n          { \"936\", \/* censored word *\/ 1, 0, &irc_protocol_cb_generic_error },\n          { \"973\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_server_mode_reason },\n          { \"974\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_server_mode_reason },\n          { \"975\", \/* whois (secure connection) *\/ 1, 0, &irc_protocol_cb_server_mode_reason },\n          { NULL, 0, 0, NULL }\n        };\n\n    if (!msg_command)\n        return;\n\n    message_colors_decoded = NULL;\n    argv = NULL;\n    argv_eol = NULL;\n    hash_tags = NULL;\n    date = 0;\n\n    ptr_msg_after_tags = irc_message;\n\n    \/* get tags as hashtable *\/\n    if (irc_message && (irc_message[0] == '@'))\n    {\n        pos_space = strchr (irc_message, ' ');\n        if (pos_space)\n        {\n            tags = weechat_strndup (irc_message + 1,\n                                    pos_space - (irc_message + 1));\n            if (tags)\n            {\n                hash_tags = irc_protocol_get_message_tags (tags);\n                if (hash_tags)\n                {\n                    date = irc_protocol_parse_time (\n                        weechat_hashtable_get (hash_tags, \"time\"));\n                }\n                free (tags);\n            }\n            ptr_msg_after_tags = pos_space;\n            while (ptr_msg_after_tags[0] == ' ')\n            {\n                ptr_msg_after_tags++;\n            }\n        }\n        else\n            ptr_msg_after_tags = NULL;\n    }\n\n    \/* get nick\/host\/address from IRC message *\/\n    nick1 = NULL;\n    address1 = NULL;\n    host1 = NULL;\n    if (ptr_msg_after_tags && (ptr_msg_after_tags[0] == ':'))\n    {\n        nick1 = irc_message_get_nick_from_host (ptr_msg_after_tags);\n        address1 = irc_message_get_address_from_host (ptr_msg_after_tags);\n        host1 = ptr_msg_after_tags + 1;\n    }\n    nick = (nick1) ? strdup (nick1) : NULL;\n    address = (address1) ? strdup (address1) : NULL;\n    address_color = (address) ?\n        irc_color_decode (\n            address,\n            weechat_config_boolean (irc_config_network_colors_receive)) :\n        NULL;\n    host = (host1) ? strdup (host1) : NULL;\n    if (host)\n    {\n        pos_space = strchr (host, ' ');\n        if (pos_space)\n            pos_space[0] = '\\0';\n    }\n    host_no_color = (host) ? irc_color_decode (host, 0) : NULL;\n    host_color = (host) ?\n        irc_color_decode (\n            host,\n            weechat_config_boolean (irc_config_network_colors_receive)) :\n        NULL;\n\n    \/* check if message is ignored or not *\/\n    ptr_channel = NULL;\n    if (msg_channel)\n        ptr_channel = irc_channel_search (server, msg_channel);\n    message_ignored = irc_ignore_check (\n        server,\n        (ptr_channel) ? ptr_channel->name : msg_channel,\n        nick, host_no_color);\n\n    \/* send signal with received command, even if command is ignored *\/\n    irc_server_send_signal (server, \"irc_raw_in\", msg_command,\n                            irc_message, NULL);\n\n    \/* send signal with received command, only if message is not ignored *\/\n    if (!message_ignored)\n    {\n        irc_server_send_signal (server, \"irc_in\", msg_command,\n                                irc_message, NULL);\n    }\n\n    \/* look for IRC command *\/\n    cmd_found = -1;\n    for (i = 0; irc_protocol_messages[i].name; i++)\n    {\n        if (weechat_strcasecmp (irc_protocol_messages[i].name,\n                                msg_command) == 0)\n        {\n            cmd_found = i;\n            break;\n        }\n    }\n\n    \/* command not found *\/\n    if (cmd_found < 0)\n    {\n        \/* for numeric commands, we use default recv function *\/\n        if (irc_protocol_is_numeric_command (msg_command))\n        {\n            cmd_name = msg_command;\n            decode_color = 1;\n            keep_trailing_spaces = 0;\n            cmd_recv_func = irc_protocol_cb_numeric;\n        }\n        else\n        {\n            weechat_printf (server->buffer,\n                            _(\"%s%s: command \\\"%s\\\" not found:\"),\n                            weechat_prefix (\"error\"), IRC_PLUGIN_NAME,\n                            msg_command);\n            weechat_printf (server->buffer,\n                            \"%s%s\",\n                            weechat_prefix (\"error\"), irc_message);\n            goto end;\n        }\n    }\n    else\n    {\n        cmd_name = irc_protocol_messages[cmd_found].name;\n        decode_color = irc_protocol_messages[cmd_found].decode_color;\n        keep_trailing_spaces = irc_protocol_messages[cmd_found].keep_trailing_spaces;\n        cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;\n    }\n\n    if (cmd_recv_func != NULL)\n    {\n        if (ptr_msg_after_tags)\n        {\n            if (decode_color)\n            {\n                message_colors_decoded = irc_color_decode (\n                    ptr_msg_after_tags,\n                    weechat_config_boolean (irc_config_network_colors_receive));\n            }\n            else\n            {\n                message_colors_decoded = strdup (ptr_msg_after_tags);\n            }\n        }\n        else\n            message_colors_decoded = NULL;\n        argv = weechat_string_split (message_colors_decoded, \" \", NULL,\n                                     WEECHAT_STRING_SPLIT_STRIP_LEFT\n                                     | WEECHAT_STRING_SPLIT_STRIP_RIGHT\n                                     | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,\n                                     0, &argc);\n        flags = WEECHAT_STRING_SPLIT_STRIP_LEFT\n            | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS\n            | WEECHAT_STRING_SPLIT_KEEP_EOL;\n        if (keep_trailing_spaces)\n            flags |= WEECHAT_STRING_SPLIT_STRIP_RIGHT;\n        argv_eol = weechat_string_split (message_colors_decoded, \" \", NULL,\n                                         flags, 0, NULL);\n\n        return_code = (int) (cmd_recv_func) (server,\n                                             date, nick, address_color,\n                                             host_color, cmd_name,\n                                             message_ignored, argc, argv,\n                                             argv_eol);\n\n        if (return_code == WEECHAT_RC_ERROR)\n        {\n            weechat_printf (server->buffer,\n                            _(\"%s%s: failed to parse command \\\"%s\\\" (please \"\n                              \"report to developers):\"),\n                            weechat_prefix (\"error\"), IRC_PLUGIN_NAME,\n                            msg_command);\n            weechat_printf (server->buffer,\n                            \"%s%s\",\n                            weechat_prefix (\"error\"), irc_message);\n        }\n\n        \/* send signal with received command (if message is not ignored) *\/\n        if (!message_ignored)\n        {\n            irc_server_send_signal (server, \"irc_in2\", msg_command,\n                                    irc_message, NULL);\n        }\n    }\n\n    \/* send signal with received command, even if command is ignored *\/\n    irc_server_send_signal (server, \"irc_raw_in2\", msg_command,\n                            irc_message, NULL);\n\nend:\n    if (nick)\n        free (nick);\n    if (address)\n        free (address);\n    if (address_color)\n        free (address_color);\n    if (host)\n        free (host);\n    if (host_no_color)\n        free (host_no_color);\n    if (host_color)\n        free (host_color);\n    if (message_colors_decoded)\n        free (message_colors_decoded);\n    if (argv)\n        weechat_string_free_split (argv);\n    if (argv_eol)\n        weechat_string_free_split (argv_eol);\n    if (hash_tags)\n        weechat_hashtable_free (hash_tags);\n}","target":0,"code_token_length":5780,"total_token_length":6016,"max_tokens_setting":6144}
+{"idx":252318,"func":"tinfl_status tinfl_decompress(tinfl_decompressor *r,\n                              const mz_uint8 *pIn_buf_next,\n                              size_t *pIn_buf_size, mz_uint8 *pOut_buf_start,\n                              mz_uint8 *pOut_buf_next, size_t *pOut_buf_size,\n                              const mz_uint32 decomp_flags) {\n  static const int s_length_base[31] = {\n      3,  4,  5,  6,  7,  8,  9,  10,  11,  13,  15,  17,  19,  23, 27, 31,\n      35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0,  0};\n  static const int s_length_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,\n                                         1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,\n                                         4, 4, 5, 5, 5, 5, 0, 0, 0};\n  static const int s_dist_base[32] = {\n      1,    2,    3,    4,    5,    7,     9,     13,    17,  25,   33,\n      49,   65,   97,   129,  193,  257,   385,   513,   769, 1025, 1537,\n      2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0,   0};\n  static const int s_dist_extra[32] = {0, 0, 0,  0,  1,  1,  2,  2,  3,  3,\n                                       4, 4, 5,  5,  6,  6,  7,  7,  8,  8,\n                                       9, 9, 10, 10, 11, 11, 12, 12, 13, 13};\n  static const mz_uint8 s_length_dezigzag[19] = {\n      16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n  static const int s_min_table_sizes[3] = {257, 1, 4};\n\n  tinfl_status status = TINFL_STATUS_FAILED;\n  mz_uint32 num_bits, dist, counter, num_extra;\n  tinfl_bit_buf_t bit_buf;\n  const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end =\n                                                  pIn_buf_next + *pIn_buf_size;\n  mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end =\n                                              pOut_buf_next + *pOut_buf_size;\n  size_t out_buf_size_mask =\n             (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)\n                 ? (size_t)-1\n                 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1,\n         dist_from_out_buf_start;\n\n  \/\/ Ensure the output buffer's size is a power of 2, unless the output buffer\n  \/\/ is large enough to hold the entire output file (in which case it doesn't\n  \/\/ matter).\n  if (((out_buf_size_mask + 1) & out_buf_size_mask) ||\n      (pOut_buf_next < pOut_buf_start)) {\n    *pIn_buf_size = *pOut_buf_size = 0;\n    return TINFL_STATUS_BAD_PARAM;\n  }\n\n  num_bits = r->m_num_bits;\n  bit_buf = r->m_bit_buf;\n  dist = r->m_dist;\n  counter = r->m_counter;\n  num_extra = r->m_num_extra;\n  dist_from_out_buf_start = r->m_dist_from_out_buf_start;\n  TINFL_CR_BEGIN\n\n  bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0;\n  r->m_z_adler32 = r->m_check_adler32 = 1;\n  if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) {\n    TINFL_GET_BYTE(1, r->m_zhdr0);\n    TINFL_GET_BYTE(2, r->m_zhdr1);\n    counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) ||\n               (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8));\n    if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))\n      counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) ||\n                  ((out_buf_size_mask + 1) <\n                   (size_t)(1ULL << (8U + (r->m_zhdr0 >> 4)))));\n    if (counter) {\n      TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED);\n    }\n  }\n\n  do {\n    TINFL_GET_BITS(3, r->m_final, 3);\n    r->m_type = r->m_final >> 1;\n    if (r->m_type == 0) {\n      TINFL_SKIP_BITS(5, num_bits & 7);\n      for (counter = 0; counter < 4; ++counter) {\n        if (num_bits)\n          TINFL_GET_BITS(6, r->m_raw_header[counter], 8);\n        else\n          TINFL_GET_BYTE(7, r->m_raw_header[counter]);\n      }\n      if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) !=\n          (mz_uint)(0xFFFF ^\n                    (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) {\n        TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED);\n      }\n      while ((counter) && (num_bits)) {\n        TINFL_GET_BITS(51, dist, 8);\n        while (pOut_buf_cur >= pOut_buf_end) {\n          TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT);\n        }\n        *pOut_buf_cur++ = (mz_uint8)dist;\n        counter--;\n      }\n      while (counter) {\n        size_t n;\n        while (pOut_buf_cur >= pOut_buf_end) {\n          TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT);\n        }\n        while (pIn_buf_cur >= pIn_buf_end) {\n          if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) {\n            TINFL_CR_RETURN(38, TINFL_STATUS_NEEDS_MORE_INPUT);\n          } else {\n            TINFL_CR_RETURN_FOREVER(40, TINFL_STATUS_FAILED);\n          }\n        }\n        n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur),\n                          (size_t)(pIn_buf_end - pIn_buf_cur)),\n                   counter);\n        TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n);\n        pIn_buf_cur += n;\n        pOut_buf_cur += n;\n        counter -= (mz_uint)n;\n      }\n    } else if (r->m_type == 3) {\n      TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED);\n    } else {\n      if (r->m_type == 1) {\n        mz_uint8 *p = r->m_tables[0].m_code_size;\n        mz_uint i;\n        r->m_table_sizes[0] = 288;\n        r->m_table_sizes[1] = 32;\n        TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);\n        for (i = 0; i <= 143; ++i) *p++ = 8;\n        for (; i <= 255; ++i) *p++ = 9;\n        for (; i <= 279; ++i) *p++ = 7;\n        for (; i <= 287; ++i) *p++ = 8;\n      } else {\n        for (counter = 0; counter < 3; counter++) {\n          TINFL_GET_BITS(11, r->m_table_sizes[counter], \"\\05\\05\\04\"[counter]);\n          r->m_table_sizes[counter] += s_min_table_sizes[counter];\n        }\n        MZ_CLEAR_OBJ(r->m_tables[2].m_code_size);\n        for (counter = 0; counter < r->m_table_sizes[2]; counter++) {\n          mz_uint s;\n          TINFL_GET_BITS(14, s, 3);\n          r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s;\n        }\n        r->m_table_sizes[2] = 19;\n      }\n      for (; (int)r->m_type >= 0; r->m_type--) {\n        int tree_next, tree_cur;\n        tinfl_huff_table *pTable;\n        mz_uint i, j, used_syms, total, sym_index, next_code[17],\n            total_syms[16];\n        pTable = &r->m_tables[r->m_type];\n        MZ_CLEAR_OBJ(total_syms);\n        MZ_CLEAR_OBJ(pTable->m_look_up);\n        MZ_CLEAR_OBJ(pTable->m_tree);\n        for (i = 0; i < r->m_table_sizes[r->m_type]; ++i)\n          total_syms[pTable->m_code_size[i]]++;\n        used_syms = 0, total = 0;\n        next_code[0] = next_code[1] = 0;\n        for (i = 1; i <= 15; ++i) {\n          used_syms += total_syms[i];\n          next_code[i + 1] = (total = ((total + total_syms[i]) << 1));\n        }\n        if ((65536 != total) && (used_syms > 1)) {\n          TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED);\n        }\n        for (tree_next = -1, sym_index = 0;\n             sym_index < r->m_table_sizes[r->m_type]; ++sym_index) {\n          mz_uint rev_code = 0, l, cur_code,\n                  code_size = pTable->m_code_size[sym_index];\n          if (!code_size) continue;\n          cur_code = next_code[code_size]++;\n          for (l = code_size; l > 0; l--, cur_code >>= 1)\n            rev_code = (rev_code << 1) | (cur_code & 1);\n          if (code_size <= TINFL_FAST_LOOKUP_BITS) {\n            mz_int16 k = (mz_int16)((code_size << 9) | sym_index);\n            while (rev_code < TINFL_FAST_LOOKUP_SIZE) {\n              pTable->m_look_up[rev_code] = k;\n              rev_code += (1 << code_size);\n            }\n            continue;\n          }\n          if (0 ==\n              (tree_cur = pTable->m_look_up[rev_code &\n                                            (TINFL_FAST_LOOKUP_SIZE - 1)])) {\n            pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] =\n                (mz_int16)tree_next;\n            tree_cur = tree_next;\n            tree_next -= 2;\n          }\n          rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1);\n          for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) {\n            tree_cur -= ((rev_code >>= 1) & 1);\n            if (!pTable->m_tree[-tree_cur - 1]) {\n              pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next;\n              tree_cur = tree_next;\n              tree_next -= 2;\n            } else\n              tree_cur = pTable->m_tree[-tree_cur - 1];\n          }\n          tree_cur -= ((rev_code >>= 1) & 1);\n          pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index;\n        }\n        if (r->m_type == 2) {\n          for (counter = 0;\n               counter < (r->m_table_sizes[0] + r->m_table_sizes[1]);) {\n            mz_uint s;\n            TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]);\n            if (dist < 16) {\n              r->m_len_codes[counter++] = (mz_uint8)dist;\n              continue;\n            }\n            if ((dist == 16) && (!counter)) {\n              TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED);\n            }\n            num_extra = \"\\02\\03\\07\"[dist - 16];\n            TINFL_GET_BITS(18, s, num_extra);\n            s += \"\\03\\03\\013\"[dist - 16];\n            TINFL_MEMSET(r->m_len_codes + counter,\n                         (dist == 16) ? r->m_len_codes[counter - 1] : 0, s);\n            counter += s;\n          }\n          if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) {\n            TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED);\n          }\n          TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes,\n                       r->m_table_sizes[0]);\n          TINFL_MEMCPY(r->m_tables[1].m_code_size,\n                       r->m_len_codes + r->m_table_sizes[0],\n                       r->m_table_sizes[1]);\n        }\n      }\n      for (;;) {\n        mz_uint8 *pSrc;\n        for (;;) {\n          if (((pIn_buf_end - pIn_buf_cur) < 4) ||\n              ((pOut_buf_end - pOut_buf_cur) < 2)) {\n            TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]);\n            if (counter >= 256) break;\n            while (pOut_buf_cur >= pOut_buf_end) {\n              TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT);\n            }\n            *pOut_buf_cur++ = (mz_uint8)counter;\n          } else {\n            int sym2;\n            mz_uint code_len;\n#if TINFL_USE_64BIT_BITBUF\n            if (num_bits < 30) {\n              bit_buf |=\n                  (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits);\n              pIn_buf_cur += 4;\n              num_bits += 32;\n            }\n#else\n            if (num_bits < 15) {\n              bit_buf |=\n                  (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits);\n              pIn_buf_cur += 2;\n              num_bits += 16;\n            }\n#endif\n            if ((sym2 =\n                     r->m_tables[0]\n                         .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >=\n                0)\n              code_len = sym2 >> 9;\n            else {\n              code_len = TINFL_FAST_LOOKUP_BITS;\n              do {\n                sym2 = r->m_tables[0]\n                           .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];\n              } while (sym2 < 0);\n            }\n            counter = sym2;\n            bit_buf >>= code_len;\n            num_bits -= code_len;\n            if (counter & 256) break;\n\n#if !TINFL_USE_64BIT_BITBUF\n            if (num_bits < 15) {\n              bit_buf |=\n                  (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits);\n              pIn_buf_cur += 2;\n              num_bits += 16;\n            }\n#endif\n            if ((sym2 =\n                     r->m_tables[0]\n                         .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >=\n                0)\n              code_len = sym2 >> 9;\n            else {\n              code_len = TINFL_FAST_LOOKUP_BITS;\n              do {\n                sym2 = r->m_tables[0]\n                           .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];\n              } while (sym2 < 0);\n            }\n            bit_buf >>= code_len;\n            num_bits -= code_len;\n\n            pOut_buf_cur[0] = (mz_uint8)counter;\n            if (sym2 & 256) {\n              pOut_buf_cur++;\n              counter = sym2;\n              break;\n            }\n            pOut_buf_cur[1] = (mz_uint8)sym2;\n            pOut_buf_cur += 2;\n          }\n        }\n        if ((counter &= 511) == 256) break;\n\n        num_extra = s_length_extra[counter - 257];\n        counter = s_length_base[counter - 257];\n        if (num_extra) {\n          mz_uint extra_bits;\n          TINFL_GET_BITS(25, extra_bits, num_extra);\n          counter += extra_bits;\n        }\n\n        TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]);\n        num_extra = s_dist_extra[dist];\n        dist = s_dist_base[dist];\n        if (num_extra) {\n          mz_uint extra_bits;\n          TINFL_GET_BITS(27, extra_bits, num_extra);\n          dist += extra_bits;\n        }\n\n        dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;\n        if ((dist > dist_from_out_buf_start) &&\n            (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) {\n          TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED);\n        }\n\n        pSrc = pOut_buf_start +\n               ((dist_from_out_buf_start - dist) & out_buf_size_mask);\n\n        if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) {\n          while (counter--) {\n            while (pOut_buf_cur >= pOut_buf_end) {\n              TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT);\n            }\n            *pOut_buf_cur++ =\n                pOut_buf_start[(dist_from_out_buf_start++ - dist) &\n                               out_buf_size_mask];\n          }\n          continue;\n        }\n#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES\n        else if ((counter >= 9) && (counter <= dist)) {\n          const mz_uint8 *pSrc_end = pSrc + (counter & ~7);\n          do {\n            ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0];\n            ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1];\n            pOut_buf_cur += 8;\n          } while ((pSrc += 8) < pSrc_end);\n          if ((counter &= 7) < 3) {\n            if (counter) {\n              pOut_buf_cur[0] = pSrc[0];\n              if (counter > 1) pOut_buf_cur[1] = pSrc[1];\n              pOut_buf_cur += counter;\n            }\n            continue;\n          }\n        }\n#endif\n        do {\n          pOut_buf_cur[0] = pSrc[0];\n          pOut_buf_cur[1] = pSrc[1];\n          pOut_buf_cur[2] = pSrc[2];\n          pOut_buf_cur += 3;\n          pSrc += 3;\n        } while ((int)(counter -= 3) > 2);\n        if ((int)counter > 0) {\n          pOut_buf_cur[0] = pSrc[0];\n          if ((int)counter > 1) pOut_buf_cur[1] = pSrc[1];\n          pOut_buf_cur += counter;\n        }\n      }\n    }\n  } while (!(r->m_final & 1));\n  if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) {\n    TINFL_SKIP_BITS(32, num_bits & 7);\n    for (counter = 0; counter < 4; ++counter) {\n      mz_uint s;\n      if (num_bits)\n        TINFL_GET_BITS(41, s, 8);\n      else\n        TINFL_GET_BYTE(42, s);\n      r->m_z_adler32 = (r->m_z_adler32 << 8) | s;\n    }\n  }\n  TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE);\n  TINFL_CR_FINISH\n\ncommon_exit:\n  r->m_num_bits = num_bits;\n  r->m_bit_buf = bit_buf;\n  r->m_dist = dist;\n  r->m_counter = counter;\n  r->m_num_extra = num_extra;\n  r->m_dist_from_out_buf_start = dist_from_out_buf_start;\n  *pIn_buf_size = pIn_buf_cur - pIn_buf_next;\n  *pOut_buf_size = pOut_buf_cur - pOut_buf_next;\n  if ((decomp_flags &\n       (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) &&\n      (status >= 0)) {\n    const mz_uint8 *ptr = pOut_buf_next;\n    size_t buf_len = *pOut_buf_size;\n    mz_uint32 i, s1 = r->m_check_adler32 & 0xffff,\n                 s2 = r->m_check_adler32 >> 16;\n    size_t block_len = buf_len % 5552;\n    while (buf_len) {\n      for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {\n        s1 += ptr[0], s2 += s1;\n        s1 += ptr[1], s2 += s1;\n        s1 += ptr[2], s2 += s1;\n        s1 += ptr[3], s2 += s1;\n        s1 += ptr[4], s2 += s1;\n        s1 += ptr[5], s2 += s1;\n        s1 += ptr[6], s2 += s1;\n        s1 += ptr[7], s2 += s1;\n      }\n      for (; i < block_len; ++i) s1 += *ptr++, s2 += s1;\n      s1 %= 65521U, s2 %= 65521U;\n      buf_len -= block_len;\n      block_len = 5552;\n    }\n    r->m_check_adler32 = (s2 << 16) + s1;\n    if ((status == TINFL_STATUS_DONE) &&\n        (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) &&\n        (r->m_check_adler32 != r->m_z_adler32))\n      status = TINFL_STATUS_ADLER32_MISMATCH;\n  }\n  return status;\n}","target":0,"code_token_length":5395,"total_token_length":5631,"max_tokens_setting":6144}
+{"idx":201451,"func":"static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define MonoColorType  1\n#define RGBColorType  3\n\n  char\n    property[MaxTextExtent];\n\n  CINInfo\n    cin;\n\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  ssize_t\n    i;\n\n  PixelPacket\n    *q;\n\n  size_t\n    extent,\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    magick[4],\n    *pixels;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    File information.\n  *\/\n  offset=0;\n  count=ReadBlob(image,4,magick);\n  offset+=count;\n  if ((count != 4) ||\n      ((LocaleNCompare((char *) magick,\"\\200\\052\\137\\327\",4) != 0)))\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  memset(&cin,0,sizeof(cin));\n  image->endian=(magick[0] == 0x80) && (magick[1] == 0x2a) &&\n    (magick[2] == 0x5f) && (magick[3] == 0xd7) ? MSBEndian : LSBEndian;\n  cin.file.image_offset=ReadBlobLong(image);\n  offset+=4;\n  cin.file.generic_length=ReadBlobLong(image);\n  offset+=4;\n  cin.file.industry_length=ReadBlobLong(image);\n  offset+=4;\n  cin.file.user_length=ReadBlobLong(image);\n  offset+=4;\n  cin.file.file_size=ReadBlobLong(image);\n  offset+=4;\n  offset+=ReadBlob(image,sizeof(cin.file.version),(unsigned char *)\n    cin.file.version);\n  (void) CopyMagickString(property,cin.file.version,sizeof(cin.file.version));\n  (void) SetImageProperty(image,\"dpx:file.version\",property);\n  offset+=ReadBlob(image,sizeof(cin.file.filename),(unsigned char *)\n    cin.file.filename);\n  (void) CopyMagickString(property,cin.file.filename,sizeof(cin.file.filename));\n  (void) SetImageProperty(image,\"dpx:file.filename\",property);\n  offset+=ReadBlob(image,sizeof(cin.file.create_date),(unsigned char *)\n    cin.file.create_date);\n  (void) CopyMagickString(property,cin.file.create_date,\n    sizeof(cin.file.create_date));\n  (void) SetImageProperty(image,\"dpx:file.create_date\",property);\n  offset+=ReadBlob(image,sizeof(cin.file.create_time),(unsigned char *)\n    cin.file.create_time);\n  (void) CopyMagickString(property,cin.file.create_time,\n     sizeof(cin.file.create_time));\n  (void) SetImageProperty(image,\"dpx:file.create_time\",property);\n  offset+=ReadBlob(image,sizeof(cin.file.reserve),(unsigned char *)\n    cin.file.reserve);\n  \/*\n    Image information.\n  *\/\n  cin.image.orientation=(unsigned char) ReadBlobByte(image);\n  offset++;\n  if (cin.image.orientation != (unsigned char) (~0))\n    (void) FormatImageProperty(image,\"dpx:image.orientation\",\"%d\",\n      cin.image.orientation);\n  switch (cin.image.orientation)\n  {\n    default:\n    case 0: image->orientation=TopLeftOrientation; break;\n    case 1: image->orientation=TopRightOrientation; break;\n    case 2: image->orientation=BottomLeftOrientation; break;\n    case 3: image->orientation=BottomRightOrientation; break;\n    case 4: image->orientation=LeftTopOrientation; break;\n    case 5: image->orientation=RightTopOrientation; break;\n    case 6: image->orientation=LeftBottomOrientation; break;\n    case 7: image->orientation=RightBottomOrientation; break;\n  }\n  cin.image.number_channels=(unsigned char) ReadBlobByte(image);\n  offset++;\n  offset+=ReadBlob(image,sizeof(cin.image.reserve1),(unsigned char *)\n    cin.image.reserve1);\n  for (i=0; i < 8; i++)\n  {\n    cin.image.channel[i].designator[0]=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].designator[1]=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].bits_per_pixel=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].reserve=(unsigned char) ReadBlobByte(image);\n    offset++;\n    cin.image.channel[i].pixels_per_line=ReadBlobLong(image);\n    offset+=4;\n    cin.image.channel[i].lines_per_image=ReadBlobLong(image);\n    offset+=4;\n    cin.image.channel[i].min_data=ReadBlobFloat(image);\n    offset+=4;\n    cin.image.channel[i].min_quantity=ReadBlobFloat(image);\n    offset+=4;\n    cin.image.channel[i].max_data=ReadBlobFloat(image);\n    offset+=4;\n    cin.image.channel[i].max_quantity=ReadBlobFloat(image);\n    offset+=4;\n  }\n  cin.image.white_point[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.white_point[0]) != MagickFalse)\n    image->chromaticity.white_point.x=cin.image.white_point[0];\n  cin.image.white_point[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.white_point[1]) != MagickFalse)\n    image->chromaticity.white_point.y=cin.image.white_point[1];\n  cin.image.red_primary_chromaticity[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.red_primary_chromaticity[0]) != MagickFalse)\n    image->chromaticity.red_primary.x=cin.image.red_primary_chromaticity[0];\n  cin.image.red_primary_chromaticity[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.red_primary_chromaticity[1]) != MagickFalse)\n    image->chromaticity.red_primary.y=cin.image.red_primary_chromaticity[1];\n  cin.image.green_primary_chromaticity[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.green_primary_chromaticity[0]) != MagickFalse)\n    image->chromaticity.red_primary.x=cin.image.green_primary_chromaticity[0];\n  cin.image.green_primary_chromaticity[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.green_primary_chromaticity[1]) != MagickFalse)\n    image->chromaticity.green_primary.y=cin.image.green_primary_chromaticity[1];\n  cin.image.blue_primary_chromaticity[0]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.blue_primary_chromaticity[0]) != MagickFalse)\n    image->chromaticity.blue_primary.x=cin.image.blue_primary_chromaticity[0];\n  cin.image.blue_primary_chromaticity[1]=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.image.blue_primary_chromaticity[1]) != MagickFalse)\n    image->chromaticity.blue_primary.y=cin.image.blue_primary_chromaticity[1];\n  offset+=ReadBlob(image,sizeof(cin.image.label),(unsigned char *)\n    cin.image.label);\n  (void) CopyMagickString(property,cin.image.label,sizeof(cin.image.label));\n  (void) SetImageProperty(image,\"dpx:image.label\",property);\n  offset+=ReadBlob(image,sizeof(cin.image.reserve),(unsigned char *)\n    cin.image.reserve);\n  \/*\n    Image data format information.\n  *\/\n  cin.data_format.interleave=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.packing=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.sign=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.sense=(unsigned char) ReadBlobByte(image);\n  offset++;\n  cin.data_format.line_pad=ReadBlobLong(image);\n  offset+=4;\n  cin.data_format.channel_pad=ReadBlobLong(image);\n  offset+=4;\n  offset+=ReadBlob(image,sizeof(cin.data_format.reserve),(unsigned char *)\n    cin.data_format.reserve);\n  \/*\n    Image origination information.\n  *\/\n  cin.origination.x_offset=ReadBlobSignedLong(image);\n  offset+=4;\n  if ((size_t) cin.origination.x_offset != ~0UL)\n    (void) FormatImageProperty(image,\"dpx:origination.x_offset\",\"%.20g\",\n      (double) cin.origination.x_offset);\n  cin.origination.y_offset=(ssize_t) ReadBlobLong(image);\n  offset+=4;\n  if ((size_t) cin.origination.y_offset != ~0UL)\n    (void) FormatImageProperty(image,\"dpx:origination.y_offset\",\"%.20g\",\n      (double) cin.origination.y_offset);\n  offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *)\n    cin.origination.filename);\n  (void) CopyMagickString(property,cin.origination.filename,\n    sizeof(cin.origination.filename));\n  (void) SetImageProperty(image,\"dpx:origination.filename\",property);\n  offset+=ReadBlob(image,sizeof(cin.origination.create_date),(unsigned char *)\n    cin.origination.create_date);\n  (void) CopyMagickString(property,cin.origination.create_date,\n    sizeof(cin.origination.create_date));\n  (void) SetImageProperty(image,\"dpx:origination.create_date\",property);\n  offset+=ReadBlob(image,sizeof(cin.origination.create_time),(unsigned char *)\n    cin.origination.create_time);\n  (void) CopyMagickString(property,cin.origination.create_time,\n    sizeof(cin.origination.create_time));\n  (void) SetImageProperty(image,\"dpx:origination.create_time\",property);\n  offset+=ReadBlob(image,sizeof(cin.origination.device),(unsigned char *)\n    cin.origination.device);\n  (void) CopyMagickString(property,cin.origination.device,\n    sizeof(cin.origination.device));\n  (void) SetImageProperty(image,\"dpx:origination.device\",property);\n  offset+=ReadBlob(image,sizeof(cin.origination.model),(unsigned char *)\n    cin.origination.model);\n  (void) CopyMagickString(property,cin.origination.model,\n    sizeof(cin.origination.model));\n  (void) SetImageProperty(image,\"dpx:origination.model\",property);\n  (void) memset(cin.origination.serial,0,\n    sizeof(cin.origination.serial));\n  offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *)\n    cin.origination.serial);\n  (void) CopyMagickString(property,cin.origination.serial,\n    sizeof(cin.origination.serial));\n  (void) SetImageProperty(image,\"dpx:origination.serial\",property);\n  cin.origination.x_pitch=ReadBlobFloat(image);\n  offset+=4;\n  cin.origination.y_pitch=ReadBlobFloat(image);\n  offset+=4;\n  cin.origination.gamma=ReadBlobFloat(image);\n  offset+=4;\n  if (IsFloatDefined(cin.origination.gamma) != MagickFalse)\n    image->gamma=cin.origination.gamma;\n  offset+=ReadBlob(image,sizeof(cin.origination.reserve),(unsigned char *)\n    cin.origination.reserve);\n  if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0))\n    {\n      int\n        c;\n\n      \/*\n        Image film information.\n      *\/\n      cin.film.id=ReadBlobByte(image);\n      offset++;\n      c=cin.film.id;\n      if (c != ~0)\n        (void) FormatImageProperty(image,\"dpx:film.id\",\"%d\",cin.film.id);\n      cin.film.type=ReadBlobByte(image);\n      offset++;\n      c=cin.film.type;\n      if (c != ~0)\n        (void) FormatImageProperty(image,\"dpx:film.type\",\"%d\",cin.film.type);\n      cin.film.offset=ReadBlobByte(image);\n      offset++;\n      c=cin.film.offset;\n      if (c != ~0)\n        (void) FormatImageProperty(image,\"dpx:film.offset\",\"%d\",\n          cin.film.offset);\n      cin.film.reserve1=ReadBlobByte(image);\n      offset++;\n      cin.film.prefix=ReadBlobLong(image);\n      offset+=4;\n      if (cin.film.prefix != ~0UL)\n        (void) FormatImageProperty(image,\"dpx:film.prefix\",\"%.20g\",(double)\n          cin.film.prefix);\n      cin.film.count=ReadBlobLong(image);\n      offset+=4;\n      offset+=ReadBlob(image,sizeof(cin.film.format),(unsigned char *)\n        cin.film.format);\n      (void) CopyMagickString(property,cin.film.format,\n        sizeof(cin.film.format));\n      (void) SetImageProperty(image,\"dpx:film.format\",property);\n      cin.film.frame_position=ReadBlobLong(image);\n      offset+=4;\n      if (cin.film.frame_position != ~0UL)\n        (void) FormatImageProperty(image,\"dpx:film.frame_position\",\"%.20g\",\n          (double) cin.film.frame_position);\n      cin.film.frame_rate=ReadBlobFloat(image);\n      offset+=4;\n      if (IsFloatDefined(cin.film.frame_rate) != MagickFalse)\n        (void) FormatImageProperty(image,\"dpx:film.frame_rate\",\"%g\",\n          cin.film.frame_rate);\n      offset+=ReadBlob(image,sizeof(cin.film.frame_id),(unsigned char *)\n        cin.film.frame_id);\n      (void) CopyMagickString(property,cin.film.frame_id,\n        sizeof(cin.film.frame_id));\n      (void) SetImageProperty(image,\"dpx:film.frame_id\",property);\n      offset+=ReadBlob(image,sizeof(cin.film.slate_info),(unsigned char *)\n        cin.film.slate_info);\n      (void) CopyMagickString(property,cin.film.slate_info,\n        sizeof(cin.film.slate_info));\n      (void) SetImageProperty(image,\"dpx:film.slate_info\",property);\n      offset+=ReadBlob(image,sizeof(cin.film.reserve),(unsigned char *)\n        cin.film.reserve);\n    }\n  if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0))\n    {\n      StringInfo\n        *profile;\n\n      \/*\n        User defined data.\n      *\/\n      if (cin.file.user_length > GetBlobSize(image))\n        ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n      profile=BlobToStringInfo((const void *) NULL,cin.file.user_length);\n      if (profile == (StringInfo *) NULL)\n        ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n      offset+=ReadBlob(image,GetStringInfoLength(profile),\n        GetStringInfoDatum(profile));\n      (void) SetImageProfile(image,\"dpx:user.data\",profile);\n      profile=DestroyStringInfo(profile);\n    }\n  image->depth=cin.image.channel[0].bits_per_pixel;\n  image->columns=cin.image.channel[0].pixels_per_line;\n  image->rows=cin.image.channel[0].lines_per_image;\n  if (image_info->ping != MagickFalse)\n    {\n      (void) CloseBlob(image);\n      return(image);\n    }\n  if (((MagickSizeType) image->columns*image->rows\/8) > GetBlobSize(image))\n    ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n  for ( ; offset < (MagickOffsetType) cin.file.image_offset; offset++)\n  {\n    int\n      c;\n\n    c=ReadBlobByte(image);\n    if (c == EOF)\n      break;\n  }\n  if (offset < (MagickOffsetType) cin.file.image_offset)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  status=SetImageExtent(image,image->columns,image->rows);\n  if (status == MagickFalse)\n    {\n      InheritException(exception,&image->exception);\n      return(DestroyImageList(image));\n    }\n  (void) SetImageBackgroundColor(image);\n  \/*\n    Convert CIN raster image to pixel packets.\n  *\/\n  quantum_info=AcquireQuantumInfo(image_info,image);\n  if (quantum_info == (QuantumInfo *) NULL)\n    ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n  SetQuantumQuantum(quantum_info,32);\n  SetQuantumPack(quantum_info,MagickFalse);\n  quantum_type=RGBQuantum;\n  extent=GetQuantumExtent(image,quantum_info,quantum_type);\n  (void) extent;\n  length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue);\n  if (cin.image.number_channels == 1)\n    {\n      quantum_type=GrayQuantum;\n      length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue);\n    }\n  status=SetQuantumPad(image,quantum_info,0);\n  pixels=GetQuantumPixels(quantum_info);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    const void\n      *stream;\n\n    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n    if (q == (PixelPacket *) NULL)\n      break;\n    stream=ReadBlobStream(image,length,pixels,&count);\n    if (count != (ssize_t) length)\n      break;\n    (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n      quantum_type,(unsigned char *) stream,exception);\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      break;\n    if (image->previous == (Image *) NULL)\n      {\n        status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n          image->rows);\n        if (status == MagickFalse)\n          break;\n      }\n  }\n  SetQuantumImageType(image,quantum_type);\n  quantum_info=DestroyQuantumInfo(quantum_info);\n  if (EOFBlob(image) != MagickFalse)\n    ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n      image->filename);\n  SetImageColorspace(image,LogColorspace);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":4045,"total_token_length":4281,"max_tokens_setting":6144}
+{"idx":414933,"func":"\nstatic int\nxmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,\n                           xmlXPathStepOpPtr op,\n\t\t\t   xmlNodePtr * first, xmlNodePtr * last,\n\t\t\t   int toBool)\n{\n\n#define XP_TEST_HIT \\\n    if (hasAxisRange != 0) { \\\n\tif (++pos == maxPos) { \\\n\t    if (addNode(seq, cur) < 0) \\\n\t        ctxt->error = XPATH_MEMORY_ERROR; \\\n\t    goto axis_range_end; } \\\n    } else { \\\n\tif (addNode(seq, cur) < 0) \\\n\t    ctxt->error = XPATH_MEMORY_ERROR; \\\n\tif (breakOnFirstHit) goto first_hit; }\n\n#define XP_TEST_HIT_NS \\\n    if (hasAxisRange != 0) { \\\n\tif (++pos == maxPos) { \\\n\t    hasNsNodes = 1; \\\n\t    if (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \\\n\t        ctxt->error = XPATH_MEMORY_ERROR; \\\n\tgoto axis_range_end; } \\\n    } else { \\\n\thasNsNodes = 1; \\\n\tif (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \\\n\t    ctxt->error = XPATH_MEMORY_ERROR; \\\n\tif (breakOnFirstHit) goto first_hit; }\n\n    xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value;\n    xmlXPathTestVal test = (xmlXPathTestVal) op->value2;\n    xmlXPathTypeVal type = (xmlXPathTypeVal) op->value3;\n    const xmlChar *prefix = op->value4;\n    const xmlChar *name = op->value5;\n    const xmlChar *URI = NULL;\n\n#ifdef DEBUG_STEP\n    int nbMatches = 0, prevMatches = 0;\n#endif\n    int total = 0, hasNsNodes = 0;\n    \/* The popped object holding the context nodes *\/\n    xmlXPathObjectPtr obj;\n    \/* The set of context nodes for the node tests *\/\n    xmlNodeSetPtr contextSeq;\n    int contextIdx;\n    xmlNodePtr contextNode;\n    \/* The final resulting node set wrt to all context nodes *\/\n    xmlNodeSetPtr outSeq;\n    \/*\n    * The temporary resulting node set wrt 1 context node.\n    * Used to feed predicate evaluation.\n    *\/\n    xmlNodeSetPtr seq;\n    xmlNodePtr cur;\n    \/* First predicate operator *\/\n    xmlXPathStepOpPtr predOp;\n    int maxPos; \/* The requested position() (when a \"[n]\" predicate) *\/\n    int hasPredicateRange, hasAxisRange, pos, size, newSize;\n    int breakOnFirstHit;\n\n    xmlXPathTraversalFunction next = NULL;\n    int (*addNode) (xmlNodeSetPtr, xmlNodePtr);\n    xmlXPathNodeSetMergeFunction mergeAndClear;\n    xmlNodePtr oldContextNode;\n    xmlXPathContextPtr xpctxt = ctxt->context;\n\n\n    CHECK_TYPE0(XPATH_NODESET);\n    obj = valuePop(ctxt);\n    \/*\n    * Setup namespaces.\n    *\/\n    if (prefix != NULL) {\n        URI = xmlXPathNsLookup(xpctxt, prefix);\n        if (URI == NULL) {\n\t    xmlXPathReleaseObject(xpctxt, obj);\n            XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR);\n\t}\n    }\n    \/*\n    * Setup axis.\n    *\n    * MAYBE FUTURE TODO: merging optimizations:\n    * - If the nodes to be traversed wrt to the initial nodes and\n    *   the current axis cannot overlap, then we could avoid searching\n    *   for duplicates during the merge.\n    *   But the question is how\/when to evaluate if they cannot overlap.\n    *   Example: if we know that for two initial nodes, the one is\n    *   not in the ancestor-or-self axis of the other, then we could safely\n    *   avoid a duplicate-aware merge, if the axis to be traversed is e.g.\n    *   the descendant-or-self axis.\n    *\/\n    mergeAndClear = xmlXPathNodeSetMergeAndClear;\n    switch (axis) {\n        case AXIS_ANCESTOR:\n            first = NULL;\n            next = xmlXPathNextAncestor;\n            break;\n        case AXIS_ANCESTOR_OR_SELF:\n            first = NULL;\n            next = xmlXPathNextAncestorOrSelf;\n            break;\n        case AXIS_ATTRIBUTE:\n            first = NULL;\n\t    last = NULL;\n            next = xmlXPathNextAttribute;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n        case AXIS_CHILD:\n\t    last = NULL;\n\t    if (((test == NODE_TEST_NAME) || (test == NODE_TEST_ALL)) &&\n\t\t(type == NODE_TYPE_NODE))\n\t    {\n\t\t\/*\n\t\t* Optimization if an element node type is 'element'.\n\t\t*\/\n\t\tnext = xmlXPathNextChildElement;\n\t    } else\n\t\tnext = xmlXPathNextChild;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n        case AXIS_DESCENDANT:\n\t    last = NULL;\n            next = xmlXPathNextDescendant;\n            break;\n        case AXIS_DESCENDANT_OR_SELF:\n\t    last = NULL;\n            next = xmlXPathNextDescendantOrSelf;\n            break;\n        case AXIS_FOLLOWING:\n\t    last = NULL;\n            next = xmlXPathNextFollowing;\n            break;\n        case AXIS_FOLLOWING_SIBLING:\n\t    last = NULL;\n            next = xmlXPathNextFollowingSibling;\n            break;\n        case AXIS_NAMESPACE:\n            first = NULL;\n\t    last = NULL;\n            next = (xmlXPathTraversalFunction) xmlXPathNextNamespace;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n        case AXIS_PARENT:\n            first = NULL;\n            next = xmlXPathNextParent;\n            break;\n        case AXIS_PRECEDING:\n            first = NULL;\n            next = xmlXPathNextPrecedingInternal;\n            break;\n        case AXIS_PRECEDING_SIBLING:\n            first = NULL;\n            next = xmlXPathNextPrecedingSibling;\n            break;\n        case AXIS_SELF:\n            first = NULL;\n\t    last = NULL;\n            next = xmlXPathNextSelf;\n\t    mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;\n            break;\n    }\n\n#ifdef DEBUG_STEP\n    xmlXPathDebugDumpStepAxis(op,\n\t(obj->nodesetval != NULL) ? obj->nodesetval->nodeNr : 0);\n#endif\n\n    if (next == NULL) {\n\txmlXPathReleaseObject(xpctxt, obj);\n        return(0);\n    }\n    contextSeq = obj->nodesetval;\n    if ((contextSeq == NULL) || (contextSeq->nodeNr <= 0)) {\n\txmlXPathReleaseObject(xpctxt, obj);\n        valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));\n        return(0);\n    }\n    \/*\n    * Predicate optimization ---------------------------------------------\n    * If this step has a last predicate, which contains a position(),\n    * then we'll optimize (although not exactly \"position()\", but only\n    * the  short-hand form, i.e., \"[n]\".\n    *\n    * Example - expression \"\/foo[parent::bar][1]\":\n    *\n    * COLLECT 'child' 'name' 'node' foo    -- op (we are here)\n    *   ROOT                               -- op->ch1\n    *   PREDICATE                          -- op->ch2 (predOp)\n    *     PREDICATE                          -- predOp->ch1 = [parent::bar]\n    *       SORT\n    *         COLLECT  'parent' 'name' 'node' bar\n    *           NODE\n    *     ELEM Object is a number : 1        -- predOp->ch2 = [1]\n    *\n    *\/\n    maxPos = 0;\n    predOp = NULL;\n    hasPredicateRange = 0;\n    hasAxisRange = 0;\n    if (op->ch2 != -1) {\n\t\/*\n\t* There's at least one predicate. 16 == XPATH_OP_PREDICATE\n\t*\/\n\tpredOp = &ctxt->comp->steps[op->ch2];\n\tif (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) {\n\t    if (predOp->ch1 != -1) {\n\t\t\/*\n\t\t* Use the next inner predicate operator.\n\t\t*\/\n\t\tpredOp = &ctxt->comp->steps[predOp->ch1];\n\t\thasPredicateRange = 1;\n\t    } else {\n\t\t\/*\n\t\t* There's no other predicate than the [n] predicate.\n\t\t*\/\n\t\tpredOp = NULL;\n\t\thasAxisRange = 1;\n\t    }\n\t}\n    }\n    breakOnFirstHit = ((toBool) && (predOp == NULL)) ? 1 : 0;\n    \/*\n    * Axis traversal -----------------------------------------------------\n    *\/\n    \/*\n     * 2.3 Node Tests\n     *  - For the attribute axis, the principal node type is attribute.\n     *  - For the namespace axis, the principal node type is namespace.\n     *  - For other axes, the principal node type is element.\n     *\n     * A node test * is true for any node of the\n     * principal node type. For example, child::* will\n     * select all element children of the context node\n     *\/\n    oldContextNode = xpctxt->node;\n    addNode = xmlXPathNodeSetAddUnique;\n    outSeq = NULL;\n    seq = NULL;\n    contextNode = NULL;\n    contextIdx = 0;\n\n\n    while (((contextIdx < contextSeq->nodeNr) || (contextNode != NULL)) &&\n           (ctxt->error == XPATH_EXPRESSION_OK)) {\n\txpctxt->node = contextSeq->nodeTab[contextIdx++];\n\n\tif (seq == NULL) {\n\t    seq = xmlXPathNodeSetCreate(NULL);\n\t    if (seq == NULL) {\n\t\ttotal = 0;\n\t\tgoto error;\n\t    }\n\t}\n\t\/*\n\t* Traverse the axis and test the nodes.\n\t*\/\n\tpos = 0;\n\tcur = NULL;\n\thasNsNodes = 0;\n        do {\n            cur = next(ctxt, cur);\n            if (cur == NULL)\n                break;\n\n\t    \/*\n\t    * QUESTION TODO: What does the \"first\" and \"last\" stuff do?\n\t    *\/\n            if ((first != NULL) && (*first != NULL)) {\n\t\tif (*first == cur)\n\t\t    break;\n\t\tif (((total % 256) == 0) &&\n#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON\n\t\t    (xmlXPathCmpNodesExt(*first, cur) >= 0))\n#else\n\t\t    (xmlXPathCmpNodes(*first, cur) >= 0))\n#endif\n\t\t{\n\t\t    break;\n\t\t}\n\t    }\n\t    if ((last != NULL) && (*last != NULL)) {\n\t\tif (*last == cur)\n\t\t    break;\n\t\tif (((total % 256) == 0) &&\n#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON\n\t\t    (xmlXPathCmpNodesExt(cur, *last) >= 0))\n#else\n\t\t    (xmlXPathCmpNodes(cur, *last) >= 0))\n#endif\n\t\t{\n\t\t    break;\n\t\t}\n\t    }\n\n            total++;\n\n#ifdef DEBUG_STEP\n            xmlGenericError(xmlGenericErrorContext, \" %s\", cur->name);\n#endif\n\n\t    switch (test) {\n                case NODE_TEST_NONE:\n\t\t    total = 0;\n                    STRANGE\n\t\t    goto error;\n                case NODE_TEST_TYPE:\n\t\t    \/*\n\t\t    * TODO: Don't we need to use\n\t\t    *  xmlXPathNodeSetAddNs() for namespace nodes here?\n\t\t    *  Surprisingly, some c14n tests fail, if we do this.\n\t\t    *\/\n\t\t    if (type == NODE_TYPE_NODE) {\n\t\t\tswitch (cur->type) {\n\t\t\t    case XML_DOCUMENT_NODE:\n\t\t\t    case XML_HTML_DOCUMENT_NODE:\n#ifdef LIBXML_DOCB_ENABLED\n\t\t\t    case XML_DOCB_DOCUMENT_NODE:\n#endif\n\t\t\t    case XML_ELEMENT_NODE:\n\t\t\t    case XML_ATTRIBUTE_NODE:\n\t\t\t    case XML_PI_NODE:\n\t\t\t    case XML_COMMENT_NODE:\n\t\t\t    case XML_CDATA_SECTION_NODE:\n\t\t\t    case XML_TEXT_NODE:\n\t\t\t    case XML_NAMESPACE_DECL:\n\t\t\t\tXP_TEST_HIT\n\t\t\t\tbreak;\n\t\t\t    default:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t    } else if (cur->type == type) {\n\t\t\tif (cur->type == XML_NAMESPACE_DECL)\n\t\t\t    XP_TEST_HIT_NS\n\t\t\telse\n\t\t\t    XP_TEST_HIT\n\t\t    } else if ((type == NODE_TYPE_TEXT) &&\n\t\t\t (cur->type == XML_CDATA_SECTION_NODE))\n\t\t    {\n\t\t\tXP_TEST_HIT\n\t\t    }\n\t\t    break;\n                case NODE_TEST_PI:\n                    if ((cur->type == XML_PI_NODE) &&\n                        ((name == NULL) || xmlStrEqual(name, cur->name)))\n\t\t    {\n\t\t\tXP_TEST_HIT\n                    }\n                    break;\n                case NODE_TEST_ALL:\n                    if (axis == AXIS_ATTRIBUTE) {\n                        if (cur->type == XML_ATTRIBUTE_NODE)\n\t\t\t{\n                            if (prefix == NULL)\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n                            } else if ((cur->ns != NULL) &&\n\t\t\t\t(xmlStrEqual(URI, cur->ns->href)))\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n                            }\n                        }\n                    } else if (axis == AXIS_NAMESPACE) {\n                        if (cur->type == XML_NAMESPACE_DECL)\n\t\t\t{\n\t\t\t    XP_TEST_HIT_NS\n                        }\n                    } else {\n                        if (cur->type == XML_ELEMENT_NODE) {\n                            if (prefix == NULL)\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n\n                            } else if ((cur->ns != NULL) &&\n\t\t\t\t(xmlStrEqual(URI, cur->ns->href)))\n\t\t\t    {\n\t\t\t\tXP_TEST_HIT\n                            }\n                        }\n                    }\n                    break;\n                case NODE_TEST_NS:{\n                        TODO;\n                        break;\n                    }\n                case NODE_TEST_NAME:\n                    if (axis == AXIS_ATTRIBUTE) {\n                        if (cur->type != XML_ATTRIBUTE_NODE)\n\t\t\t    break;\n\t\t    } else if (axis == AXIS_NAMESPACE) {\n                        if (cur->type != XML_NAMESPACE_DECL)\n\t\t\t    break;\n\t\t    } else {\n\t\t        if (cur->type != XML_ELEMENT_NODE)\n\t\t\t    break;\n\t\t    }\n                    switch (cur->type) {\n                        case XML_ELEMENT_NODE:\n                            if (xmlStrEqual(name, cur->name)) {\n                                if (prefix == NULL) {\n                                    if (cur->ns == NULL)\n\t\t\t\t    {\n\t\t\t\t\tXP_TEST_HIT\n                                    }\n                                } else {\n                                    if ((cur->ns != NULL) &&\n                                        (xmlStrEqual(URI, cur->ns->href)))\n\t\t\t\t    {\n\t\t\t\t\tXP_TEST_HIT\n                                    }\n                                }\n                            }\n                            break;\n                        case XML_ATTRIBUTE_NODE:{\n                                xmlAttrPtr attr = (xmlAttrPtr) cur;\n\n                                if (xmlStrEqual(name, attr->name)) {\n                                    if (prefix == NULL) {\n                                        if ((attr->ns == NULL) ||\n                                            (attr->ns->prefix == NULL))\n\t\t\t\t\t{\n\t\t\t\t\t    XP_TEST_HIT\n                                        }\n                                    } else {\n                                        if ((attr->ns != NULL) &&\n                                            (xmlStrEqual(URI,\n\t\t\t\t\t      attr->ns->href)))\n\t\t\t\t\t{\n\t\t\t\t\t    XP_TEST_HIT\n                                        }\n                                    }\n                                }\n                                break;\n                            }\n                        case XML_NAMESPACE_DECL:\n                            if (cur->type == XML_NAMESPACE_DECL) {\n                                xmlNsPtr ns = (xmlNsPtr) cur;\n\n                                if ((ns->prefix != NULL) && (name != NULL)\n                                    && (xmlStrEqual(ns->prefix, name)))\n\t\t\t\t{\n\t\t\t\t    XP_TEST_HIT_NS\n                                }\n                            }\n                            break;\n                        default:\n                            break;\n                    }\n                    break;\n\t    } \/* switch(test) *\/\n        } while ((cur != NULL) && (ctxt->error == XPATH_EXPRESSION_OK));\n\n\tgoto apply_predicates;\n\naxis_range_end: \/* ----------------------------------------------------- *\/\n\t\/*\n\t* We have a \"\/foo[n]\", and position() = n was reached.\n\t* Note that we can have as well \"\/foo\/::parent::foo[1]\", so\n\t* a duplicate-aware merge is still needed.\n\t* Merge with the result.\n\t*\/\n\tif (outSeq == NULL) {\n\t    outSeq = seq;\n\t    seq = NULL;\n\t} else\n\t    outSeq = mergeAndClear(outSeq, seq, 0);\n\t\/*\n\t* Break if only a true\/false result was requested.\n\t*\/\n\tif (toBool)\n\t    break;\n\tcontinue;\n\nfirst_hit: \/* ---------------------------------------------------------- *\/\n\t\/*\n\t* Break if only a true\/false result was requested and\n\t* no predicates existed and a node test succeeded.\n\t*\/\n\tif (outSeq == NULL) {\n\t    outSeq = seq;\n\t    seq = NULL;\n\t} else\n\t    outSeq = mergeAndClear(outSeq, seq, 0);\n\tbreak;\n\n#ifdef DEBUG_STEP\n\tif (seq != NULL)\n\t    nbMatches += seq->nodeNr;\n#endif\n\napply_predicates: \/* --------------------------------------------------- *\/\n        if (ctxt->error != XPATH_EXPRESSION_OK)\n\t    goto error;\n\n        \/*\n\t* Apply predicates.\n\t*\/\n        if ((predOp != NULL) && (seq->nodeNr > 0)) {\n\t    \/*\n\t    * E.g. when we have a \"\/foo[some expression][n]\".\n\t    *\/\n\t    \/*\n\t    * QUESTION TODO: The old predicate evaluation took into\n\t    *  account location-sets.\n\t    *  (E.g. ctxt->value->type == XPATH_LOCATIONSET)\n\t    *  Do we expect such a set here?\n\t    *  All what I learned now from the evaluation semantics\n\t    *  does not indicate that a location-set will be processed\n\t    *  here, so this looks OK.\n\t    *\/\n\t    \/*\n\t    * Iterate over all predicates, starting with the outermost\n\t    * predicate.\n\t    * TODO: Problem: we cannot execute the inner predicates first\n\t    *  since we cannot go back *up* the operator tree!\n\t    *  Options we have:\n\t    *  1) Use of recursive functions (like is it currently done\n\t    *     via xmlXPathCompOpEval())\n\t    *  2) Add a predicate evaluation information stack to the\n\t    *     context struct\n\t    *  3) Change the way the operators are linked; we need a\n\t    *     \"parent\" field on xmlXPathStepOp\n\t    *\n\t    * For the moment, I'll try to solve this with a recursive\n\t    * function: xmlXPathCompOpEvalPredicate().\n\t    *\/\n\t    size = seq->nodeNr;\n\t    if (hasPredicateRange != 0)\n\t\tnewSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,\n\t\t    predOp, seq, size, maxPos, maxPos, hasNsNodes);\n\t    else\n\t\tnewSize = xmlXPathCompOpEvalPredicate(ctxt,\n\t\t    predOp, seq, size, hasNsNodes);\n\n\t    if (ctxt->error != XPATH_EXPRESSION_OK) {\n\t\ttotal = 0;\n\t\tgoto error;\n\t    }\n\t    \/*\n\t    * Add the filtered set of nodes to the result node set.\n\t    *\/\n\t    if (newSize == 0) {\n\t\t\/*\n\t\t* The predicates filtered all nodes out.\n\t\t*\/\n\t\txmlXPathNodeSetClear(seq, hasNsNodes);\n\t    } else if (seq->nodeNr > 0) {\n\t\t\/*\n\t\t* Add to result set.\n\t\t*\/\n\t\tif (outSeq == NULL) {\n\t\t    if (size != newSize) {\n\t\t\t\/*\n\t\t\t* We need to merge and clear here, since\n\t\t\t* the sequence will contained NULLed entries.\n\t\t\t*\/\n\t\t\toutSeq = mergeAndClear(NULL, seq, 1);\n\t\t    } else {\n\t\t\toutSeq = seq;\n\t\t\tseq = NULL;\n\t\t    }\n\t\t} else\n\t\t    outSeq = mergeAndClear(outSeq, seq,\n\t\t\t(size != newSize) ? 1: 0);\n\t\t\/*\n\t\t* Break if only a true\/false result was requested.\n\t\t*\/\n\t\tif (toBool)\n\t\t    break;\n\t    }\n        } else if (seq->nodeNr > 0) {\n\t    \/*\n\t    * Add to result set.\n\t    *\/\n\t    if (outSeq == NULL) {\n\t\toutSeq = seq;\n\t\tseq = NULL;\n\t    } else {\n\t\toutSeq = mergeAndClear(outSeq, seq, 0);\n\t    }\n\t}\n    }\n\nerror:\n    if ((obj->boolval) && (obj->user != NULL)) {\n\t\/*\n\t* QUESTION TODO: What does this do and why?\n\t* TODO: Do we have to do this also for the \"error\"\n\t* cleanup further down?\n\t*\/\n\tctxt->value->boolval = 1;\n\tctxt->value->user = obj->user;\n\tobj->user = NULL;\n\tobj->boolval = 0;\n    }\n    xmlXPathReleaseObject(xpctxt, obj);\n\n    \/*\n    * Ensure we return at least an emtpy set.\n    *\/\n    if (outSeq == NULL) {\n\tif ((seq != NULL) && (seq->nodeNr == 0))\n\t    outSeq = seq;\n\telse\n\t    outSeq = xmlXPathNodeSetCreate(NULL);\n        \/* XXX what if xmlXPathNodeSetCreate returned NULL here? *\/\n    }\n    if ((seq != NULL) && (seq != outSeq)) {\n\t xmlXPathFreeNodeSet(seq);\n    }\n    \/*\n    * Hand over the result. Better to push the set also in\n    * case of errors.\n    *\/\n    valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq));\n    \/*\n    * Reset the context node.\n    *\/\n    xpctxt->node = oldContextNode;\n\n#ifdef DEBUG_STEP\n    xmlGenericError(xmlGenericErrorContext,\n\t\"\\nExamined %d nodes, found %d nodes at that step\\n\",\n\ttotal, nbMatches);\n#endif\n","target":0,"code_token_length":4610,"total_token_length":4846,"max_tokens_setting":6144}
+{"idx":208411,"func":"check_termcode(\n    int\t\tmax_offset,\n    char_u\t*buf,\n    int\t\tbufsize,\n    int\t\t*buflen)\n{\n    char_u\t*tp;\n    char_u\t*p;\n    int\t\tslen = 0;\t\/\/ init for GCC\n    int\t\tmodslen;\n    int\t\tlen;\n    int\t\tretval = 0;\n    int\t\toffset;\n    char_u\tkey_name[2];\n    int\t\tmodifiers;\n    char_u\t*modifiers_start = NULL;\n    int\t\tkey;\n    int\t\tnew_slen;   \/\/ Length of what will replace the termcode\n    char_u\tstring[MAX_KEY_CODE_LEN + 1];\n    int\t\ti, j;\n    int\t\tidx = 0;\n    int\t\tcpo_koffset;\n\n    cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL);\n\n    \/*\n     * Speed up the checks for terminal codes by gathering all first bytes\n     * used in termleader[].  Often this is just a single <Esc>.\n     *\/\n    if (need_gather)\n\tgather_termleader();\n\n    \/*\n     * Check at several positions in typebuf.tb_buf[], to catch something like\n     * \"x<Up>\" that can be mapped. Stop at max_offset, because characters\n     * after that cannot be used for mapping, and with @r commands\n     * typebuf.tb_buf[] can become very long.\n     * This is used often, KEEP IT FAST!\n     *\/\n    for (offset = 0; offset < max_offset; ++offset)\n    {\n\tif (buf == NULL)\n\t{\n\t    if (offset >= typebuf.tb_len)\n\t\tbreak;\n\t    tp = typebuf.tb_buf + typebuf.tb_off + offset;\n\t    len = typebuf.tb_len - offset;\t\/\/ length of the input\n\t}\n\telse\n\t{\n\t    if (offset >= *buflen)\n\t\tbreak;\n\t    tp = buf + offset;\n\t    len = *buflen - offset;\n\t}\n\n\t\/*\n\t * Don't check characters after K_SPECIAL, those are already\n\t * translated terminal chars (avoid translating ~@^Hx).\n\t *\/\n\tif (*tp == K_SPECIAL)\n\t{\n\t    offset += 2;\t\/\/ there are always 2 extra characters\n\t    continue;\n\t}\n\n\t\/*\n\t * Skip this position if the character does not appear as the first\n\t * character in term_strings. This speeds up a lot, since most\n\t * termcodes start with the same character (ESC or CSI).\n\t *\/\n\ti = *tp;\n\tfor (p = termleader; *p && *p != i; ++p)\n\t    ;\n\tif (*p == NUL)\n\t    continue;\n\n\t\/*\n\t * Skip this position if p_ek is not set and tp[0] is an ESC and we\n\t * are in Insert mode.\n\t *\/\n\tif (*tp == ESC && !p_ek && (State & MODE_INSERT))\n\t    continue;\n\n\tkey_name[0] = NUL;\t\/\/ no key name found yet\n\tkey_name[1] = NUL;\t\/\/ no key name found yet\n\tmodifiers = 0;\t\t\/\/ no modifiers yet\n\n#ifdef FEAT_GUI\n\tif (gui.in_use)\n\t{\n\t    \/*\n\t     * GUI special key codes are all of the form [CSI xx].\n\t     *\/\n\t    if (*tp == CSI)\t    \/\/ Special key from GUI\n\t    {\n\t\tif (len < 3)\n\t\t    return -1;\t    \/\/ Shouldn't happen\n\t\tslen = 3;\n\t\tkey_name[0] = tp[1];\n\t\tkey_name[1] = tp[2];\n\t    }\n\t}\n\telse\n#endif \/\/ FEAT_GUI\n\t{\n\t    int  mouse_index_found = -1;\n\n\t    for (idx = 0; idx < tc_len; ++idx)\n\t    {\n\t\t\/*\n\t\t * Ignore the entry if we are not at the start of\n\t\t * typebuf.tb_buf[]\n\t\t * and there are not enough characters to make a match.\n\t\t * But only when the 'K' flag is in 'cpoptions'.\n\t\t *\/\n\t\tslen = termcodes[idx].len;\n\t\tmodifiers_start = NULL;\n\t\tif (cpo_koffset && offset && len < slen)\n\t\t    continue;\n\t\tif (STRNCMP(termcodes[idx].code, tp,\n\t\t\t\t     (size_t)(slen > len ? len : slen)) == 0)\n\t\t{\n\t\t    int\t    looks_like_mouse_start = FALSE;\n\n\t\t    if (len < slen)\t\t\/\/ got a partial sequence\n\t\t\treturn -1;\t\t\/\/ need to get more chars\n\n\t\t    \/*\n\t\t     * When found a keypad key, check if there is another key\n\t\t     * that matches and use that one.  This makes <Home> to be\n\t\t     * found instead of <kHome> when they produce the same\n\t\t     * key code.\n\t\t     *\/\n\t\t    if (termcodes[idx].name[0] == 'K'\n\t\t\t\t       && VIM_ISDIGIT(termcodes[idx].name[1]))\n\t\t    {\n\t\t\tfor (j = idx + 1; j < tc_len; ++j)\n\t\t\t    if (termcodes[j].len == slen &&\n\t\t\t\t    STRNCMP(termcodes[idx].code,\n\t\t\t\t\t    termcodes[j].code, slen) == 0)\n\t\t\t    {\n\t\t\t\tidx = j;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t    }\n\n\t\t    if (slen == 2 && len > 2\n\t\t\t    && termcodes[idx].code[0] == ESC\n\t\t\t    && termcodes[idx].code[1] == '[')\n\t\t    {\n\t\t\t\/\/ The mouse termcode \"ESC [\" is also the prefix of\n\t\t\t\/\/ \"ESC [ I\" (focus gained) and other keys.  Check some\n\t\t\t\/\/ more bytes to find out.\n\t\t\tif (!isdigit(tp[2]))\n\t\t\t{\n\t\t\t    \/\/ ESC [ without number following: Only use it when\n\t\t\t    \/\/ there is no other match.\n\t\t\t    looks_like_mouse_start = TRUE;\n\t\t\t}\n\t\t\telse if (termcodes[idx].name[0] == KS_DEC_MOUSE)\n\t\t\t{\n\t\t\t    char_u  *nr = tp + 2;\n\t\t\t    int\t    count = 0;\n\n\t\t\t    \/\/ If a digit is following it could be a key with\n\t\t\t    \/\/ modifier, e.g., ESC [ 1;2P.  Can be confused\n\t\t\t    \/\/ with DEC_MOUSE, which requires four numbers\n\t\t\t    \/\/ following.  If not then it can't be a DEC_MOUSE\n\t\t\t    \/\/ code.\n\t\t\t    for (;;)\n\t\t\t    {\n\t\t\t\t++count;\n\t\t\t\t(void)getdigits(&nr);\n\t\t\t\tif (nr >= tp + len)\n\t\t\t\t    return -1;\t\/\/ partial sequence\n\t\t\t\tif (*nr != ';')\n\t\t\t\t    break;\n\t\t\t\t++nr;\n\t\t\t\tif (nr >= tp + len)\n\t\t\t\t    return -1;\t\/\/ partial sequence\n\t\t\t    }\n\t\t\t    if (count < 4)\n\t\t\t\tcontinue;\t\/\/ no match\n\t\t\t}\n\t\t    }\n\t\t    if (looks_like_mouse_start)\n\t\t    {\n\t\t\t\/\/ Only use it when there is no other match.\n\t\t\tif (mouse_index_found < 0)\n\t\t\t    mouse_index_found = idx;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tkey_name[0] = termcodes[idx].name[0];\n\t\t\tkey_name[1] = termcodes[idx].name[1];\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\n\t\t\/*\n\t\t * Check for code with modifier, like xterm uses:\n\t\t * <Esc>[123;*X  (modslen == slen - 3)\n\t\t * <Esc>[@;*X    (matches <Esc>[X and <Esc>[1;9X )\n\t\t * Also <Esc>O*X and <M-O>*X (modslen == slen - 2).\n\t\t * When there is a modifier the * matches a number.\n\t\t * When there is no modifier the ;* or * is omitted.\n\t\t *\/\n\t\tif (termcodes[idx].modlen > 0 && mouse_index_found < 0)\n\t\t{\n\t\t    int at_code;\n\n\t\t    modslen = termcodes[idx].modlen;\n\t\t    if (cpo_koffset && offset && len < modslen)\n\t\t\tcontinue;\n\t\t    at_code = termcodes[idx].code[modslen] == '@';\n\t\t    if (STRNCMP(termcodes[idx].code, tp,\n\t\t\t\t(size_t)(modslen > len ? len : modslen)) == 0)\n\t\t    {\n\t\t\tint\t    n;\n\n\t\t\tif (len <= modslen)\t\/\/ got a partial sequence\n\t\t\t    return -1;\t\t\/\/ need to get more chars\n\n\t\t\tif (tp[modslen] == termcodes[idx].code[slen - 1])\n\t\t\t    \/\/ no modifiers\n\t\t\t    slen = modslen + 1;\n\t\t\telse if (tp[modslen] != ';' && modslen == slen - 3)\n\t\t\t    \/\/ no match for \"code;*X\" with \"code;\"\n\t\t\t    continue;\n\t\t\telse if (at_code && tp[modslen] != '1')\n\t\t\t    \/\/ no match for \"<Esc>[@\" with \"<Esc>[1\"\n\t\t\t    continue;\n\t\t\telse\n\t\t\t{\n\t\t\t    \/\/ Skip over the digits, the final char must\n\t\t\t    \/\/ follow. URXVT can use a negative value, thus\n\t\t\t    \/\/ also accept '-'.\n\t\t\t    for (j = slen - 2; j < len && (isdigit(tp[j])\n\t\t\t\t       || tp[j] == '-' || tp[j] == ';'); ++j)\n\t\t\t\t;\n\t\t\t    ++j;\n\t\t\t    if (len < j)\t\/\/ got a partial sequence\n\t\t\t\treturn -1;\t\/\/ need to get more chars\n\t\t\t    if (tp[j - 1] != termcodes[idx].code[slen - 1])\n\t\t\t\tcontinue;\t\/\/ no match\n\n\t\t\t    modifiers_start = tp + slen - 2;\n\n\t\t\t    \/\/ Match!  Convert modifier bits.\n\t\t\t    n = atoi((char *)modifiers_start);\n\t\t\t    modifiers |= decode_modifiers(n);\n\n\t\t\t    slen = j;\n\t\t\t}\n\t\t\tkey_name[0] = termcodes[idx].name[0];\n\t\t\tkey_name[1] = termcodes[idx].name[1];\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t    if (idx == tc_len && mouse_index_found >= 0)\n\t    {\n\t\tkey_name[0] = termcodes[mouse_index_found].name[0];\n\t\tkey_name[1] = termcodes[mouse_index_found].name[1];\n\t    }\n\t}\n\n#ifdef FEAT_TERMRESPONSE\n\tif (key_name[0] == NUL\n\t    \/\/ Mouse codes of DEC and pterm start with <ESC>[.  When\n\t    \/\/ detecting the start of these mouse codes they might as well be\n\t    \/\/ another key code or terminal response.\n# ifdef FEAT_MOUSE_DEC\n\t    || key_name[0] == KS_DEC_MOUSE\n# endif\n# ifdef FEAT_MOUSE_PTERM\n\t    || key_name[0] == KS_PTERM_MOUSE\n# endif\n\t   )\n\t{\n\t    char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1;\n\n\t    \/*\n\t     * Check for responses from the terminal starting with {lead}:\n\t     * \"<Esc>[\" or CSI followed by [0-9>?]\n\t     *\n\t     * - Xterm version string: {lead}>{x};{vers};{y}c\n\t     *   Also eat other possible responses to t_RV, rxvt returns\n\t     *   \"{lead}?1;2c\".\n\t     *\n\t     * - Cursor position report: {lead}{row};{col}R\n\t     *   The final byte must be 'R'. It is used for checking the\n\t     *   ambiguous-width character state.\n\t     *\n\t     * - window position reply: {lead}3;{x};{y}t\n\t     *\n\t     * - key with modifiers when modifyOtherKeys is enabled:\n\t     *\t    {lead}27;{modifier};{key}~\n\t     *\t    {lead}{key};{modifier}u\n\t     *\/\n\t    if (((tp[0] == ESC && len >= 3 && tp[1] == '[')\n\t\t\t    || (tp[0] == CSI && len >= 2))\n\t\t    && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?'))\n\t    {\n\t\tint resp = handle_csi(tp, len, argp, offset, buf,\n\t\t\t\t\t     bufsize, buflen, key_name, &slen);\n\t\tif (resp != 0)\n\t\t{\n# ifdef DEBUG_TERMRESPONSE\n\t\t    if (resp == -1)\n\t\t\tLOG_TR((\"Not enough characters for CSI sequence\"));\n# endif\n\t\t    return resp;\n\t\t}\n\t    }\n\n\t    \/\/ Check for fore\/background color response from the terminal,\n\t    \/\/ starting} with <Esc>] or OSC\n\t    else if ((*T_RBG != NUL || *T_RFG != NUL)\n\t\t\t&& ((tp[0] == ESC && len >= 2 && tp[1] == ']')\n\t\t\t    || tp[0] == OSC))\n\t    {\n\t\tif (handle_osc(tp, argp, len, key_name, &slen) == FAIL)\n\t\t    return -1;\n\t    }\n\n\t    \/\/ Check for key code response from xterm,\n\t    \/\/ starting with <Esc>P or DCS\n\t    else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT)\n\t\t    && ((tp[0] == ESC && len >= 2 && tp[1] == 'P')\n\t\t\t|| tp[0] == DCS))\n\t    {\n\t\tif (handle_dcs(tp, argp, len, key_name, &slen) == FAIL)\n\t\t    return -1;\n\t    }\n\t}\n#endif\n\n\tif (key_name[0] == NUL)\n\t    continue;\t    \/\/ No match at this position, try next one\n\n\t\/\/ We only get here when we have a complete termcode match\n\n#ifdef FEAT_GUI\n\t\/*\n\t * Only in the GUI: Fetch the pointer coordinates of the scroll event\n\t * so that we know which window to scroll later.\n\t *\/\n\tif (gui.in_use\n\t\t&& key_name[0] == (int)KS_EXTRA\n\t\t&& (key_name[1] == (int)KE_X1MOUSE\n\t\t    || key_name[1] == (int)KE_X2MOUSE\n\t\t    || key_name[1] == (int)KE_MOUSEMOVE_XY\n\t\t    || key_name[1] == (int)KE_MOUSELEFT\n\t\t    || key_name[1] == (int)KE_MOUSERIGHT\n\t\t    || key_name[1] == (int)KE_MOUSEDOWN\n\t\t    || key_name[1] == (int)KE_MOUSEUP))\n\t{\n\t    char_u\tbytes[6];\n\t    int\t\tnum_bytes = get_bytes_from_buf(tp + slen, bytes, 4);\n\n\t    if (num_bytes == -1)\t\/\/ not enough coordinates\n\t\treturn -1;\n\t    mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1;\n\t    mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1;\n\t    slen += num_bytes;\n\t    \/\/ equal to K_MOUSEMOVE\n\t    if (key_name[1] == (int)KE_MOUSEMOVE_XY)\n\t\tkey_name[1] = (int)KE_MOUSEMOVE;\n\t}\n\telse\n#endif\n\t\/*\n\t * If it is a mouse click, get the coordinates.\n\t *\/\n\tif (key_name[0] == KS_MOUSE\n#ifdef FEAT_MOUSE_GPM\n\t\t|| key_name[0] == KS_GPM_MOUSE\n#endif\n#ifdef FEAT_MOUSE_JSB\n\t\t|| key_name[0] == KS_JSBTERM_MOUSE\n#endif\n#ifdef FEAT_MOUSE_NET\n\t\t|| key_name[0] == KS_NETTERM_MOUSE\n#endif\n#ifdef FEAT_MOUSE_DEC\n\t\t|| key_name[0] == KS_DEC_MOUSE\n#endif\n#ifdef FEAT_MOUSE_PTERM\n\t\t|| key_name[0] == KS_PTERM_MOUSE\n#endif\n#ifdef FEAT_MOUSE_URXVT\n\t\t|| key_name[0] == KS_URXVT_MOUSE\n#endif\n\t\t|| key_name[0] == KS_SGR_MOUSE\n\t\t|| key_name[0] == KS_SGR_MOUSE_RELEASE)\n\t{\n\t    if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx,\n\t\t\t\t\t\t\t     &modifiers) == -1)\n\t\treturn -1;\n\t}\n\n#ifdef FEAT_GUI\n\t\/*\n\t * If using the GUI, then we get menu and scrollbar events.\n\t *\n\t * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by\n\t * four bytes which are to be taken as a pointer to the vimmenu_T\n\t * structure.\n\t *\n\t * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where \"nr\"\n\t * is one byte with the tab index.\n\t *\n\t * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed\n\t * by one byte representing the scrollbar number, and then four bytes\n\t * representing a long_u which is the new value of the scrollbar.\n\t *\n\t * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR,\n\t * KE_FILLER followed by four bytes representing a long_u which is the\n\t * new value of the scrollbar.\n\t *\/\n# ifdef FEAT_MENU\n\telse if (key_name[0] == (int)KS_MENU)\n\t{\n\t    long_u\tval;\n\t    int\t\tnum_bytes = get_long_from_buf(tp + slen, &val);\n\n\t    if (num_bytes == -1)\n\t\treturn -1;\n\t    current_menu = (vimmenu_T *)val;\n\t    slen += num_bytes;\n\n\t    \/\/ The menu may have been deleted right after it was used, check\n\t    \/\/ for that.\n\t    if (check_menu_pointer(root_menu, current_menu) == FAIL)\n\t    {\n\t\tkey_name[0] = KS_EXTRA;\n\t\tkey_name[1] = (int)KE_IGNORE;\n\t    }\n\t}\n# endif\n# ifdef FEAT_GUI_TABLINE\n\telse if (key_name[0] == (int)KS_TABLINE)\n\t{\n\t    \/\/ Selecting tabline tab or using its menu.\n\t    char_u\tbytes[6];\n\t    int\t\tnum_bytes = get_bytes_from_buf(tp + slen, bytes, 1);\n\n\t    if (num_bytes == -1)\n\t\treturn -1;\n\t    current_tab = (int)bytes[0];\n\t    if (current_tab == 255)\t\/\/ -1 in a byte gives 255\n\t\tcurrent_tab = -1;\n\t    slen += num_bytes;\n\t}\n\telse if (key_name[0] == (int)KS_TABMENU)\n\t{\n\t    \/\/ Selecting tabline tab or using its menu.\n\t    char_u\tbytes[6];\n\t    int\t\tnum_bytes = get_bytes_from_buf(tp + slen, bytes, 2);\n\n\t    if (num_bytes == -1)\n\t\treturn -1;\n\t    current_tab = (int)bytes[0];\n\t    current_tabmenu = (int)bytes[1];\n\t    slen += num_bytes;\n\t}\n# endif\n# ifndef USE_ON_FLY_SCROLL\n\telse if (key_name[0] == (int)KS_VER_SCROLLBAR)\n\t{\n\t    long_u\tval;\n\t    char_u\tbytes[6];\n\t    int\t\tnum_bytes;\n\n\t    \/\/ Get the last scrollbar event in the queue of the same type\n\t    j = 0;\n\t    for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR\n\t\t\t\t\t\t     && tp[j + 2] != NUL; ++i)\n\t    {\n\t\tj += 3;\n\t\tnum_bytes = get_bytes_from_buf(tp + j, bytes, 1);\n\t\tif (num_bytes == -1)\n\t\t    break;\n\t\tif (i == 0)\n\t\t    current_scrollbar = (int)bytes[0];\n\t\telse if (current_scrollbar != (int)bytes[0])\n\t\t    break;\n\t\tj += num_bytes;\n\t\tnum_bytes = get_long_from_buf(tp + j, &val);\n\t\tif (num_bytes == -1)\n\t\t    break;\n\t\tscrollbar_value = val;\n\t\tj += num_bytes;\n\t\tslen = j;\n\t    }\n\t    if (i == 0)\t\t\/\/ not enough characters to make one\n\t\treturn -1;\n\t}\n\telse if (key_name[0] == (int)KS_HOR_SCROLLBAR)\n\t{\n\t    long_u\tval;\n\t    int\t\tnum_bytes;\n\n\t    \/\/ Get the last horiz. scrollbar event in the queue\n\t    j = 0;\n\t    for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR\n\t\t\t\t\t\t     && tp[j + 2] != NUL; ++i)\n\t    {\n\t\tj += 3;\n\t\tnum_bytes = get_long_from_buf(tp + j, &val);\n\t\tif (num_bytes == -1)\n\t\t    break;\n\t\tscrollbar_value = val;\n\t\tj += num_bytes;\n\t\tslen = j;\n\t    }\n\t    if (i == 0)\t\t\/\/ not enough characters to make one\n\t\treturn -1;\n\t}\n# endif \/\/ !USE_ON_FLY_SCROLL\n#endif \/\/ FEAT_GUI\n\n#if (defined(UNIX) || defined(VMS))\n\t\/*\n\t * Handle FocusIn\/FocusOut event sequences reported by XTerm.\n\t * (CSI I\/CSI O)\n\t *\/\n\tif (key_name[0] == KS_EXTRA\n# ifdef FEAT_GUI\n\t\t&& !gui.in_use\n# endif\n\t    )\n\t{\n\t    if (key_name[1] == KE_FOCUSGAINED)\n\t    {\n\t\tif (!focus_state)\n\t\t{\n\t\t    ui_focus_change(TRUE);\n\t\t    did_cursorhold = TRUE;\n\t\t    focus_state = TRUE;\n\t\t}\n\t\tkey_name[1] = (int)KE_IGNORE;\n\t    }\n\t    else if (key_name[1] == KE_FOCUSLOST)\n\t    {\n\t\tif (focus_state)\n\t\t{\n\t\t    ui_focus_change(FALSE);\n\t\t    did_cursorhold = TRUE;\n\t\t    focus_state = FALSE;\n\t\t}\n\t\tkey_name[1] = (int)KE_IGNORE;\n\t    }\n\t}\n#endif\n\n\t\/*\n\t * Change <xHome> to <Home>, <xUp> to <Up>, etc.\n\t *\/\n\tkey = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1]));\n\n\t\/*\n\t * Add any modifier codes to our string.\n\t *\/\n\tnew_slen = modifiers2keycode(modifiers, &key, string);\n\n\t\/\/ Finally, add the special key code to our string\n\tkey_name[0] = KEY2TERMCAP0(key);\n\tkey_name[1] = KEY2TERMCAP1(key);\n\tif (key_name[0] == KS_KEY)\n\t{\n\t    \/\/ from \":set <M-b>=xx\"\n\t    if (has_mbyte)\n\t\tnew_slen += (*mb_char2bytes)(key_name[1], string + new_slen);\n\t    else\n\t\tstring[new_slen++] = key_name[1];\n\t}\n\telse if (new_slen == 0 && key_name[0] == KS_EXTRA\n\t\t\t\t\t\t  && key_name[1] == KE_IGNORE)\n\t{\n\t    \/\/ Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED\n\t    \/\/ to indicate what happened.\n\t    retval = KEYLEN_REMOVED;\n\t}\n\telse\n\t{\n\t    string[new_slen++] = K_SPECIAL;\n\t    string[new_slen++] = key_name[0];\n\t    string[new_slen++] = key_name[1];\n\t}\n\tif (put_string_in_typebuf(offset, slen, string, new_slen,\n\t\t\t\t\t\t buf, bufsize, buflen) == FAIL)\n\t    return -1;\n\treturn retval == 0 ? (len + new_slen - slen + offset) : retval;\n    }\n\n#ifdef FEAT_TERMRESPONSE\n    LOG_TR((\"normal character\"));\n#endif\n\n    return 0;\t\t\t    \/\/ no match found\n}","target":1,"code_token_length":5106,"total_token_length":5342,"max_tokens_setting":6144}
+{"idx":207762,"func":"negotiate_handshake_newstyle_options (void)\n{\n  GET_CONN;\n  struct nbd_new_option new_option;\n  size_t nr_options;\n  bool list_seen = false;\n  uint64_t version;\n  uint32_t option;\n  uint32_t optlen;\n  struct nbd_export_name_option_reply handshake_finish;\n  const char *optname;\n  uint64_t exportsize;\n  struct backend *b;\n\n  for (nr_options = MAX_NR_OPTIONS; nr_options > 0; --nr_options) {\n    CLEANUP_FREE char *data = NULL;\n\n    if (conn_recv_full (&new_option, sizeof new_option,\n                        \"reading option: conn->recv: %m\") == -1)\n      return -1;\n\n    version = be64toh (new_option.version);\n    if (version != NBD_NEW_VERSION) {\n      nbdkit_error (\"unknown option version %\" PRIx64\n                    \", expecting %\" PRIx64,\n                    version, NBD_NEW_VERSION);\n      return -1;\n    }\n\n    \/* There is a maximum option length we will accept, regardless\n     * of the option type.\n     *\/\n    optlen = be32toh (new_option.optlen);\n    if (optlen > MAX_REQUEST_SIZE) {\n      nbdkit_error (\"client option data too long (%\" PRIu32 \")\", optlen);\n      return -1;\n    }\n    data = malloc (optlen + 1); \/* Allowing a trailing NUL helps some uses *\/\n    if (data == NULL) {\n      nbdkit_error (\"malloc: %m\");\n      return -1;\n    }\n\n    option = be32toh (new_option.option);\n    optname = name_of_nbd_opt (option);\n\n    \/* If the client lacks fixed newstyle support, it should only send\n     * NBD_OPT_EXPORT_NAME.\n     *\/\n    if (!(conn->cflags & NBD_FLAG_FIXED_NEWSTYLE) &&\n        option != NBD_OPT_EXPORT_NAME) {\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID))\n        return -1;\n      continue;\n    }\n\n    \/* In --tls=require \/ FORCEDTLS mode the only options allowed\n     * before TLS negotiation are NBD_OPT_ABORT and NBD_OPT_STARTTLS.\n     *\/\n    if (tls == 2 && !conn->using_tls &&\n        !(option == NBD_OPT_ABORT || option == NBD_OPT_STARTTLS)) {\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_TLS_REQD))\n        return -1;\n      continue;\n    }\n\n    switch (option) {\n    case NBD_OPT_EXPORT_NAME:\n      if (conn_recv_full (data, optlen,\n                          \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n        return -1;\n      if (check_export_name (option, data, optlen, optlen) == -1)\n        return -1;\n\n      \/* We have to finish the handshake by sending handshake_finish.\n       * On failure, we have to disconnect.\n       *\/\n      if (finish_newstyle_options (&exportsize, data, optlen) == -1)\n        return -1;\n\n      memset (&handshake_finish, 0, sizeof handshake_finish);\n      handshake_finish.exportsize = htobe64 (exportsize);\n      handshake_finish.eflags = htobe16 (conn->eflags);\n\n      if (conn->send (&handshake_finish,\n                      (conn->cflags & NBD_FLAG_NO_ZEROES)\n                      ? offsetof (struct nbd_export_name_option_reply, zeroes)\n                      : sizeof handshake_finish, 0) == -1) {\n        nbdkit_error (\"write: %s: %m\", optname);\n        return -1;\n      }\n      break;\n\n    case NBD_OPT_ABORT:\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n      debug (\"client sent %s to abort the connection\",\n             name_of_nbd_opt (option));\n      return -1;\n\n    case NBD_OPT_LIST:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      if (list_seen) {\n        debug (\"newstyle negotiation: %s: export list already advertised\",\n               name_of_nbd_opt (option));\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)\n          return -1;\n        continue;\n      }\n      else {\n        \/* Send back the exportname list. *\/\n        debug (\"newstyle negotiation: %s: advertising exports\",\n               name_of_nbd_opt (option));\n        if (send_newstyle_option_reply_exportnames (option, &nr_options) == -1)\n          return -1;\n        list_seen = true;\n      }\n      break;\n\n    case NBD_OPT_STARTTLS:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      if (tls == 0) {           \/* --tls=off (NOTLS mode). *\/\n#ifdef HAVE_GNUTLS\n#define NO_TLS_REPLY NBD_REP_ERR_POLICY\n#else\n#define NO_TLS_REPLY NBD_REP_ERR_UNSUP\n#endif\n        if (send_newstyle_option_reply (option, NO_TLS_REPLY) == -1)\n          return -1;\n      }\n      else \/* --tls=on or --tls=require *\/ {\n        \/* We can't upgrade to TLS twice on the same connection. *\/\n        if (conn->using_tls) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)\n            return -1;\n          continue;\n        }\n\n        \/* We have to send the (unencrypted) reply before starting\n         * the handshake.\n         *\/\n        if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n          return -1;\n\n        \/* Upgrade the connection to TLS.  Also performs access control. *\/\n        if (crypto_negotiate_tls (conn->sockin, conn->sockout) == -1)\n          return -1;\n        conn->using_tls = true;\n        debug (\"using TLS on this connection\");\n        \/* Wipe out any cached default export name. *\/\n        for_each_backend (b) {\n          free (conn->default_exportname[b->i]);\n          conn->default_exportname[b->i] = NULL;\n        }\n      }\n      break;\n\n    case NBD_OPT_INFO:\n    case NBD_OPT_GO:\n      if (conn_recv_full (data, optlen, \"read: %s: %m\", optname) == -1)\n        return -1;\n\n      if (optlen < 6) { \/* 32 bit export length + 16 bit nr info *\/\n        debug (\"newstyle negotiation: %s option length < 6\", optname);\n\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        continue;\n      }\n\n      {\n        uint32_t exportnamelen;\n        uint16_t nrinfos;\n        uint16_t info;\n        size_t i;\n\n        \/* Validate the name length and number of INFO requests. *\/\n        memcpy (&exportnamelen, &data[0], 4);\n        exportnamelen = be32toh (exportnamelen);\n        if (exportnamelen > optlen-6 \/* NB optlen >= 6, see above *\/) {\n          debug (\"newstyle negotiation: %s: export name too long\", optname);\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n        memcpy (&nrinfos, &data[exportnamelen+4], 2);\n        nrinfos = be16toh (nrinfos);\n        if (optlen != 4 + exportnamelen + 2 + 2*nrinfos) {\n          debug (\"newstyle negotiation: %s: \"\n                 \"number of information requests incorrect\", optname);\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* As with NBD_OPT_EXPORT_NAME we print the export name and\n         * save it in the connection.  If an earlier\n         * NBD_OPT_SET_META_CONTEXT used an export name, it must match\n         * or else we drop the support for that context.\n         *\/\n        if (check_export_name (option, &data[4], exportnamelen,\n                               optlen - 6) == -1) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* The spec is confusing, but it is required that we send back\n         * NBD_INFO_EXPORT, even if the client did not request it!\n         * qemu client in particular does not request this, but will\n         * fail if we don't send it.  Note that if .open fails, but we\n         * succeed at .close, then we merely return an error to the\n         * client and let them try another NBD_OPT, rather than\n         * disconnecting.\n         *\/\n        if (finish_newstyle_options (&exportsize,\n                                     &data[4], exportnamelen) == -1) {\n          if (conn->top_context) {\n            if (backend_finalize (conn->top_context) == -1)\n              return -1;\n            backend_close (conn->top_context);\n            conn->top_context = NULL;\n          }\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_UNKNOWN) == -1)\n            return -1;\n          continue;\n        }\n\n        if (send_newstyle_option_reply_info_export (option,\n                                                    NBD_REP_INFO,\n                                                    NBD_INFO_EXPORT,\n                                                    exportsize) == -1)\n          return -1;\n\n        \/* For now we send NBD_INFO_NAME and NBD_INFO_DESCRIPTION if\n         * requested, and ignore all other info requests (including\n         * NBD_INFO_EXPORT if it was requested, because we replied\n         * already above).\n         *\/\n        for (i = 0; i < nrinfos; ++i) {\n          memcpy (&info, &data[4 + exportnamelen + 2 + i*2], 2);\n          info = be16toh (info);\n          switch (info) {\n          case NBD_INFO_EXPORT: \/* ignore - reply sent above *\/ break;\n          case NBD_INFO_NAME:\n            {\n              const char *name = &data[4];\n              size_t namelen = exportnamelen;\n\n              if (exportnamelen == 0) {\n                name = backend_default_export (top, read_only);\n                if (!name) {\n                  debug (\"newstyle negotiation: %s: \"\n                         \"NBD_INFO_NAME: no name to send\", optname);\n                  break;\n                }\n                namelen = -1;\n              }\n              if (send_newstyle_option_reply_info_str (option,\n                                                       NBD_REP_INFO,\n                                                       NBD_INFO_NAME,\n                                                       name, namelen) == -1)\n                return -1;\n            }\n            break;\n          case NBD_INFO_DESCRIPTION:\n            {\n              const char *desc = backend_export_description (conn->top_context);\n\n              if (!desc) {\n                debug (\"newstyle negotiation: %s: \"\n                       \"NBD_INFO_DESCRIPTION: no description to send\",\n                       optname);\n                break;\n              }\n              if (send_newstyle_option_reply_info_str (option,\n                                                       NBD_REP_INFO,\n                                                       NBD_INFO_DESCRIPTION,\n                                                       desc, -1) == -1)\n                return -1;\n            }\n            break;\n          default:\n            debug (\"newstyle negotiation: %s: \"\n                   \"ignoring NBD_INFO_* request %u (%s)\",\n                   optname, (unsigned) info, name_of_nbd_info (info));\n            break;\n          }\n        }\n      }\n\n      \/* Unlike NBD_OPT_EXPORT_NAME, NBD_OPT_GO sends back an ACK\n       * or ERROR packet.  If this was NBD_OPT_LIST, call .close.\n       *\/\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n\n      if (option == NBD_OPT_INFO) {\n        if (backend_finalize (conn->top_context) == -1)\n          return -1;\n        backend_close (conn->top_context);\n        conn->top_context = NULL;\n      }\n\n      break;\n\n    case NBD_OPT_STRUCTURED_REPLY:\n      if (optlen != 0) {\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n            == -1)\n          return -1;\n        if (conn_recv_full (data, optlen,\n                            \"read: %s: %m\", name_of_nbd_opt (option)) == -1)\n          return -1;\n        continue;\n      }\n\n      debug (\"newstyle negotiation: %s: client requested structured replies\",\n             name_of_nbd_opt (option));\n\n      if (no_sr) {\n        \/* Must fail with ERR_UNSUP for qemu 4.2 to remain happy;\n         * but failing with ERR_POLICY would have been nicer.\n         *\/\n        if (send_newstyle_option_reply (option, NBD_REP_ERR_UNSUP) == -1)\n          return -1;\n        debug (\"newstyle negotiation: %s: structured replies are disabled\",\n               name_of_nbd_opt (option));\n        break;\n      }\n\n      if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n        return -1;\n\n      conn->structured_replies = true;\n      break;\n\n    case NBD_OPT_LIST_META_CONTEXT:\n    case NBD_OPT_SET_META_CONTEXT:\n      {\n        uint32_t opt_index;\n        uint32_t exportnamelen;\n        uint32_t nr_queries;\n        uint32_t querylen;\n        const char *what;\n\n        if (conn_recv_full (data, optlen, \"read: %s: %m\", optname) == -1)\n          return -1;\n\n        \/* Note that we support base:allocation whether or not the plugin\n         * supports can_extents.\n         *\/\n        if (!conn->structured_replies) {\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        \/* Minimum length of the option payload is:\n         *   32 bit export name length followed by empty export name\n         * + 32 bit number of queries followed by no queries\n         * = 8 bytes.\n         *\/\n        what = \"optlen < 8\";\n        if (optlen < 8) {\n        opt_meta_invalid_option_len:\n          debug (\"newstyle negotiation: %s: invalid option length: %s\",\n                 optname, what);\n\n          if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID)\n              == -1)\n            return -1;\n          continue;\n        }\n\n        memcpy (&exportnamelen, &data[0], 4);\n        exportnamelen = be32toh (exportnamelen);\n        what = \"validating export name\";\n        if (check_export_name (option, &data[4], exportnamelen,\n                               optlen - 8) == -1)\n          goto opt_meta_invalid_option_len;\n\n        \/* Remember the export name: the NBD spec says that if the client\n         * later uses NBD_OPT_GO on a different export, then the context\n         * returned here is not usable.\n         *\/\n        if (option == NBD_OPT_SET_META_CONTEXT) {\n          conn->exportname_from_set_meta_context =\n            strndup (&data[4], exportnamelen);\n          if (conn->exportname_from_set_meta_context == NULL) {\n            nbdkit_error (\"malloc: %m\");\n            return -1;\n          }\n        }\n\n        opt_index = 4 + exportnamelen;\n\n        \/* Read the number of queries. *\/\n        what = \"reading number of queries\";\n        if (opt_index+4 > optlen)\n          goto opt_meta_invalid_option_len;\n        memcpy (&nr_queries, &data[opt_index], 4);\n        nr_queries = be32toh (nr_queries);\n        opt_index += 4;\n\n        \/* for LIST: nr_queries == 0 means return all meta contexts\n         * for SET: nr_queries == 0 means reset all contexts\n         *\/\n        debug (\"newstyle negotiation: %s: %s count: %d\", optname,\n               option == NBD_OPT_LIST_META_CONTEXT ? \"query\" : \"set\",\n               nr_queries);\n        if (option == NBD_OPT_SET_META_CONTEXT)\n          conn->meta_context_base_allocation = false;\n        if (nr_queries == 0) {\n          if (option == NBD_OPT_LIST_META_CONTEXT) {\n            if (send_newstyle_option_reply_meta_context (option,\n                                                         NBD_REP_META_CONTEXT,\n                                                         0, \"base:allocation\")\n                == -1)\n              return -1;\n          }\n\n          if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n            return -1;\n        }\n        else {\n          \/* Read and answer each query. *\/\n          while (nr_queries > 0) {\n            what = \"reading query string length\";\n            if (opt_index+4 > optlen)\n              goto opt_meta_invalid_option_len;\n            memcpy (&querylen, &data[opt_index], 4);\n            querylen = be32toh (querylen);\n            opt_index += 4;\n            what = \"reading query string\";\n            if (check_string (option, &data[opt_index], querylen,\n                              optlen - opt_index, \"meta context query\") == -1)\n              goto opt_meta_invalid_option_len;\n\n            debug (\"newstyle negotiation: %s: %s %.*s\",\n                   optname,\n                   option == NBD_OPT_LIST_META_CONTEXT ? \"query\" : \"set\",\n                   (int) querylen, &data[opt_index]);\n\n            \/* For LIST, \"base:\" returns all supported contexts in the\n             * base namespace.  We only support \"base:allocation\".\n             *\/\n            if (option == NBD_OPT_LIST_META_CONTEXT &&\n                querylen == 5 &&\n                strncmp (&data[opt_index], \"base:\", 5) == 0) {\n              if (send_newstyle_option_reply_meta_context\n                  (option, NBD_REP_META_CONTEXT,\n                   0, \"base:allocation\") == -1)\n                return -1;\n            }\n            \/* \"base:allocation\" requested by name. *\/\n            else if (querylen == 15 &&\n                     strncmp (&data[opt_index], \"base:allocation\", 15) == 0) {\n              if (send_newstyle_option_reply_meta_context\n                  (option, NBD_REP_META_CONTEXT,\n                   option == NBD_OPT_SET_META_CONTEXT\n                   ? base_allocation_id : 0,\n                   \"base:allocation\") == -1)\n                return -1;\n              if (option == NBD_OPT_SET_META_CONTEXT)\n                conn->meta_context_base_allocation = true;\n            }\n            \/* Every other query must be ignored. *\/\n\n            opt_index += querylen;\n            nr_queries--;\n          }\n          if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)\n            return -1;\n        }\n        debug (\"newstyle negotiation: %s: reply complete\", optname);\n      }\n      break;\n\n    default:\n      \/* Unknown option. *\/\n      if (send_newstyle_option_reply (option, NBD_REP_ERR_UNSUP) == -1)\n        return -1;\n      if (conn_recv_full (data, optlen,\n                          \"reading unknown option data: conn->recv: %m\") == -1)\n        return -1;\n    }\n\n    \/* Note, since it's not very clear from the protocol doc, that the\n     * client must send NBD_OPT_EXPORT_NAME or NBD_OPT_GO last, and\n     * that ends option negotiation.\n     *\/\n    if (option == NBD_OPT_EXPORT_NAME || option == NBD_OPT_GO)\n      break;\n  }\n\n  if (nr_options == 0) {\n    nbdkit_error (\"client spent too much time negotiating without selecting \"\n                  \"an export\");\n    return -1;\n  }\n\n  \/* In --tls=require \/ FORCEDTLS mode, we must have upgraded to TLS\n   * by the time we finish option negotiation.  If not, give up.\n   *\/\n  if (tls == 2 && !conn->using_tls) {\n    nbdkit_error (\"non-TLS client tried to connect in --tls=require mode\");\n    return -1;\n  }\n\n  return 0;\n}","target":1,"code_token_length":4544,"total_token_length":4780,"max_tokens_setting":6144}
+{"idx":223392,"func":"static PCRE2_SPTR compile_char1_matchingpath(compiler_common *common, PCRE2_UCHAR type, PCRE2_SPTR cc, jump_list **backtracks, BOOL check_str_ptr)\n{\nDEFINE_COMPILER;\nint length;\nunsigned int c, oc, bit;\ncompare_context context;\nstruct sljit_jump *jump[3];\njump_list *end_list;\n#ifdef SUPPORT_UNICODE\nPCRE2_UCHAR propdata[5];\n#endif \/* SUPPORT_UNICODE *\/\n\nswitch(type)\n  {\n  case OP_NOT_DIGIT:\n  case OP_DIGIT:\n  \/* Digits are usually 0-9, so it is worth to optimize them. *\/\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\n  if (common->utf && is_char7_bitset((const sljit_u8*)common->ctypes - cbit_length + cbit_digit, FALSE))\n    read_char7_type(common, backtracks, type == OP_NOT_DIGIT);\n  else\n#endif\n    read_char8_type(common, backtracks, type == OP_NOT_DIGIT);\n    \/* Flip the starting bit in the negative case. *\/\n  OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, ctype_digit);\n  add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_ZERO : SLJIT_NOT_ZERO));\n  return cc;\n\n  case OP_NOT_WHITESPACE:\n  case OP_WHITESPACE:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\n  if (common->utf && is_char7_bitset((const sljit_u8*)common->ctypes - cbit_length + cbit_space, FALSE))\n    read_char7_type(common, backtracks, type == OP_NOT_WHITESPACE);\n  else\n#endif\n    read_char8_type(common, backtracks, type == OP_NOT_WHITESPACE);\n  OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, ctype_space);\n  add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_ZERO : SLJIT_NOT_ZERO));\n  return cc;\n\n  case OP_NOT_WORDCHAR:\n  case OP_WORDCHAR:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\n  if (common->utf && is_char7_bitset((const sljit_u8*)common->ctypes - cbit_length + cbit_word, FALSE))\n    read_char7_type(common, backtracks, type == OP_NOT_WORDCHAR);\n  else\n#endif\n    read_char8_type(common, backtracks, type == OP_NOT_WORDCHAR);\n  OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, ctype_word);\n  add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_ZERO : SLJIT_NOT_ZERO));\n  return cc;\n\n  case OP_ANY:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n  read_char(common, common->nlmin, common->nlmax, backtracks, READ_CHAR_UPDATE_STR_PTR);\n  if (common->nltype == NLTYPE_FIXED && common->newline > 255)\n    {\n    jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);\n    end_list = NULL;\n    if (common->mode != PCRE2_JIT_PARTIAL_HARD)\n      add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n    else\n      check_str_end(common, &end_list);\n\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff));\n    set_jumps(end_list, LABEL());\n    JUMPHERE(jump[0]);\n    }\n  else\n    check_newlinechar(common, common->nltype, backtracks, TRUE);\n  return cc;\n\n  case OP_ALLANY:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n#ifdef SUPPORT_UNICODE\n  if (common->utf)\n    {\n    if (common->invalid_utf)\n      {\n      read_char(common, 0, READ_CHAR_MAX, backtracks, READ_CHAR_UPDATE_STR_PTR);\n      return cc;\n      }\n\n#if PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16\n    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n#if PCRE2_CODE_UNIT_WIDTH == 8\n    jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);\n#elif PCRE2_CODE_UNIT_WIDTH == 16\n    jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800);\n    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);\n    OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0xd800);\n    OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_EQUAL);\n    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 8 *\/\n    JUMPHERE(jump[0]);\n    return cc;\n#endif \/* PCRE2_CODE_UNIT_WIDTH == [8|16] *\/\n    }\n#endif \/* SUPPORT_UNICODE *\/\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  return cc;\n\n  case OP_ANYBYTE:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  return cc;\n\n#ifdef SUPPORT_UNICODE\n  case OP_NOTPROP:\n  case OP_PROP:\n  propdata[0] = XCL_HASPROP;\n  propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP;\n  propdata[2] = cc[0];\n  propdata[3] = cc[1];\n  propdata[4] = XCL_END;\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n  compile_xclass_matchingpath(common, propdata, backtracks);\n  return cc + 2;\n#endif\n\n  case OP_ANYNL:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n  read_char(common, common->bsr_nlmin, common->bsr_nlmax, NULL, 0);\n  jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);\n  \/* We don't need to handle soft partial matching case. *\/\n  end_list = NULL;\n  if (common->mode != PCRE2_JIT_PARTIAL_HARD)\n    add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n  else\n    check_str_end(common, &end_list);\n  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);\n  jump[1] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);\n  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n  jump[2] = JUMP(SLJIT_JUMP);\n  JUMPHERE(jump[0]);\n  check_newlinechar(common, common->bsr_nltype, backtracks, FALSE);\n  set_jumps(end_list, LABEL());\n  JUMPHERE(jump[1]);\n  JUMPHERE(jump[2]);\n  return cc;\n\n  case OP_NOT_HSPACE:\n  case OP_HSPACE:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n\n  if (type == OP_NOT_HSPACE)\n    read_char(common, 0x9, 0x3000, backtracks, READ_CHAR_UPDATE_STR_PTR);\n  else\n    read_char(common, 0x9, 0x3000, NULL, 0);\n\n  add_jump(compiler, &common->hspace, JUMP(SLJIT_FAST_CALL));\n  sljit_set_current_flags(compiler, SLJIT_SET_Z);\n  add_jump(compiler, backtracks, JUMP(type == OP_NOT_HSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO));\n  return cc;\n\n  case OP_NOT_VSPACE:\n  case OP_VSPACE:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n\n  if (type == OP_NOT_VSPACE)\n    read_char(common, 0xa, 0x2029, backtracks, READ_CHAR_UPDATE_STR_PTR);\n  else\n    read_char(common, 0xa, 0x2029, NULL, 0);\n\n  add_jump(compiler, &common->vspace, JUMP(SLJIT_FAST_CALL));\n  sljit_set_current_flags(compiler, SLJIT_SET_Z);\n  add_jump(compiler, backtracks, JUMP(type == OP_NOT_VSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO));\n  return cc;\n\n#ifdef SUPPORT_UNICODE\n  case OP_EXTUNI:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n\n  SLJIT_ASSERT(TMP1 == SLJIT_R0 && STR_PTR == SLJIT_R1);\n  OP1(SLJIT_MOV, SLJIT_R0, 0, ARGUMENTS, 0);\n\n#if PCRE2_CODE_UNIT_WIDTH != 32\n  sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_ARGS2(W, W, W), SLJIT_IMM,\n    common->utf ? (common->invalid_utf ? SLJIT_FUNC_ADDR(do_extuni_utf_invalid) : SLJIT_FUNC_ADDR(do_extuni_utf)) : SLJIT_FUNC_ADDR(do_extuni_no_utf));\n  if (common->invalid_utf)\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));\n#else\n  sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_ARGS2(W, W, W), SLJIT_IMM,\n    common->invalid_utf ? SLJIT_FUNC_ADDR(do_extuni_utf_invalid) : SLJIT_FUNC_ADDR(do_extuni_no_utf));\n  if (!common->utf || common->invalid_utf)\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));\n#endif\n\n  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0);\n\n  if (common->mode == PCRE2_JIT_PARTIAL_HARD)\n    {\n    jump[0] = CMP(SLJIT_LESS, SLJIT_RETURN_REG, 0, STR_END, 0);\n    \/* Since we successfully read a char above, partial matching must occure. *\/\n    check_partial(common, TRUE);\n    JUMPHERE(jump[0]);\n    }\n  return cc;\n#endif\n\n  case OP_CHAR:\n  case OP_CHARI:\n  length = 1;\n#ifdef SUPPORT_UNICODE\n  if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);\n#endif\n\n  if (check_str_ptr && common->mode != PCRE2_JIT_COMPLETE)\n    detect_partial_match(common, backtracks);\n\n  if (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0)\n    {\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length));\n    if (length > 1 || (check_str_ptr && common->mode == PCRE2_JIT_COMPLETE))\n      add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0));\n\n    context.length = IN_UCHARS(length);\n    context.sourcereg = -1;\n#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED\n    context.ucharptr = 0;\n#endif\n    return byte_sequence_compare(common, type == OP_CHARI, cc, &context, backtracks);\n    }\n\n#ifdef SUPPORT_UNICODE\n  if (common->utf)\n    {\n    GETCHAR(c, cc);\n    }\n  else\n#endif\n    c = *cc;\n\n  SLJIT_ASSERT(type == OP_CHARI && char_has_othercase(common, cc));\n\n  if (check_str_ptr && common->mode == PCRE2_JIT_COMPLETE)\n    add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n\n  oc = char_othercase(common, c);\n  read_char(common, c < oc ? c : oc, c > oc ? c : oc, NULL, 0);\n\n  SLJIT_ASSERT(!is_powerof2(c ^ oc));\n\n  if (sljit_has_cpu_feature(SLJIT_HAS_CMOV))\n    {\n    OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, oc);\n    CMOV(SLJIT_EQUAL, TMP1, SLJIT_IMM, c);\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c));\n    }\n  else\n    {\n    jump[0] = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c);\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, oc));\n    JUMPHERE(jump[0]);\n    }\n  return cc + length;\n\n  case OP_NOT:\n  case OP_NOTI:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n\n  length = 1;\n#ifdef SUPPORT_UNICODE\n  if (common->utf)\n    {\n#if PCRE2_CODE_UNIT_WIDTH == 8\n    c = *cc;\n    if (c < 128 && !common->invalid_utf)\n      {\n      OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);\n      if (type == OP_NOT || !char_has_othercase(common, cc))\n        add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c));\n      else\n        {\n        \/* Since UTF8 code page is fixed, we know that c is in [a-z] or [A-Z] range. *\/\n        OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x20);\n        add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, c | 0x20));\n        }\n      \/* Skip the variable-length character. *\/\n      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n      jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);\n      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);\n      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);\n      JUMPHERE(jump[0]);\n      return cc + 1;\n      }\n    else\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 8 *\/\n      {\n      GETCHARLEN(c, cc, length);\n      }\n    }\n  else\n#endif \/* SUPPORT_UNICODE *\/\n    c = *cc;\n\n  if (type == OP_NOT || !char_has_othercase(common, cc))\n    {\n    read_char(common, c, c, backtracks, READ_CHAR_UPDATE_STR_PTR);\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c));\n    }\n  else\n    {\n    oc = char_othercase(common, c);\n    read_char(common, c < oc ? c : oc, c > oc ? c : oc, backtracks, READ_CHAR_UPDATE_STR_PTR);\n    bit = c ^ oc;\n    if (is_powerof2(bit))\n      {\n      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));\n      }\n    else\n      {\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c));\n      add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, oc));\n      }\n    }\n  return cc + length;\n\n  case OP_CLASS:\n  case OP_NCLASS:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\n  bit = (common->utf && is_char7_bitset((const sljit_u8 *)cc, type == OP_NCLASS)) ? 127 : 255;\n  if (type == OP_NCLASS)\n    read_char(common, 0, bit, backtracks, READ_CHAR_UPDATE_STR_PTR);\n  else\n    read_char(common, 0, bit, NULL, 0);\n#else\n  if (type == OP_NCLASS)\n    read_char(common, 0, 255, backtracks, READ_CHAR_UPDATE_STR_PTR);\n  else\n    read_char(common, 0, 255, NULL, 0);\n#endif\n\n  if (optimize_class(common, (const sljit_u8 *)cc, type == OP_NCLASS, FALSE, backtracks))\n    return cc + 32 \/ sizeof(PCRE2_UCHAR);\n\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\n  jump[0] = NULL;\n  if (common->utf)\n    {\n    jump[0] = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, bit);\n    if (type == OP_CLASS)\n      {\n      add_jump(compiler, backtracks, jump[0]);\n      jump[0] = NULL;\n      }\n    }\n#elif PCRE2_CODE_UNIT_WIDTH != 8\n  jump[0] = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);\n  if (type == OP_CLASS)\n    {\n    add_jump(compiler, backtracks, jump[0]);\n    jump[0] = NULL;\n    }\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 *\/\n\n  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);\n  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);\n  OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);\n  OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);\n  OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);\n  add_jump(compiler, backtracks, JUMP(SLJIT_ZERO));\n\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8\n  if (jump[0] != NULL)\n    JUMPHERE(jump[0]);\n#endif\n  return cc + 32 \/ sizeof(PCRE2_UCHAR);\n\n#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32\n  case OP_XCLASS:\n  if (check_str_ptr)\n    detect_partial_match(common, backtracks);\n  compile_xclass_matchingpath(common, cc + LINK_SIZE, backtracks);\n  return cc + GET(cc, 0) - 1;\n#endif\n  }\nSLJIT_UNREACHABLE();\nreturn cc;\n}","target":0,"code_token_length":4756,"total_token_length":4992,"max_tokens_setting":6144}
+{"idx":462099,"func":"static MagickBooleanType WriteGIFImage(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  int\n    c;\n\n  ImageInfo\n    *write_info;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  RectangleInfo\n    page;\n\n  register ssize_t\n    i;\n\n  register unsigned char\n    *q;\n\n  size_t\n    bits_per_pixel,\n    delay,\n    imageListLength,\n    length,\n    one;\n\n  ssize_t\n    j,\n    opacity;\n\n  unsigned char\n    *colormap,\n    *global_colormap;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    return(status);\n  \/*\n    Allocate colormap.\n  *\/\n  global_colormap=(unsigned char *) AcquireQuantumMemory(768UL,\n    sizeof(*global_colormap));\n  colormap=(unsigned char *) AcquireQuantumMemory(768UL,sizeof(*colormap));\n  if ((global_colormap == (unsigned char *) NULL) ||\n      (colormap == (unsigned char *) NULL))\n    {\n      if (global_colormap != (unsigned char *) NULL)\n        global_colormap=(unsigned char *) RelinquishMagickMemory(\n          global_colormap);\n      if (colormap != (unsigned char *) NULL)\n        colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    }\n  for (i=0; i < 768; i++)\n    colormap[i]=(unsigned char) 0;\n  \/*\n    Write GIF header.\n  *\/\n  write_info=CloneImageInfo(image_info);\n  if (LocaleCompare(write_info->magick,\"GIF87\") != 0)\n    (void) WriteBlob(image,6,(unsigned char *) \"GIF89a\");\n  else\n    {\n      (void) WriteBlob(image,6,(unsigned char *) \"GIF87a\");\n      write_info->adjoin=MagickFalse;\n    }\n  \/*\n    Determine image bounding box.\n  *\/\n  page.width=image->columns;\n  if (image->page.width > page.width)\n    page.width=image->page.width;\n  page.height=image->rows;\n  if (image->page.height > page.height)\n    page.height=image->page.height;\n  page.x=image->page.x;\n  page.y=image->page.y;\n  (void) WriteBlobLSBShort(image,(unsigned short) page.width);\n  (void) WriteBlobLSBShort(image,(unsigned short) page.height);\n  \/*\n    Write images to file.\n  *\/\n  if ((write_info->adjoin != MagickFalse) &&\n      (GetNextImageInList(image) != (Image *) NULL))\n    write_info->interlace=NoInterlace;\n  scene=0;\n  one=1;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    (void) TransformImageColorspace(image,sRGBColorspace,exception);\n    opacity=(-1);\n    if (IsImageOpaque(image,exception) != MagickFalse)\n      {\n        if ((image->storage_class == DirectClass) || (image->colors > 256))\n          (void) SetImageType(image,PaletteType,exception);\n      }\n    else\n      {\n        double\n          alpha,\n          beta;\n\n        \/*\n          Identify transparent colormap index.\n        *\/\n        if ((image->storage_class == DirectClass) || (image->colors > 256))\n          (void) SetImageType(image,PaletteBilevelAlphaType,exception);\n        for (i=0; i < (ssize_t) image->colors; i++)\n          if (image->colormap[i].alpha != OpaqueAlpha)\n            {\n              if (opacity < 0)\n                {\n                  opacity=i;\n                  continue;\n                }\n              alpha=fabs(image->colormap[i].alpha-TransparentAlpha);\n              beta=fabs(image->colormap[opacity].alpha-TransparentAlpha);\n              if (alpha < beta)\n                opacity=i;\n            }\n        if (opacity == -1)\n          {\n            (void) SetImageType(image,PaletteBilevelAlphaType,exception);\n            for (i=0; i < (ssize_t) image->colors; i++)\n              if (image->colormap[i].alpha != OpaqueAlpha)\n                {\n                  if (opacity < 0)\n                    {\n                      opacity=i;\n                      continue;\n                    }\n                  alpha=fabs(image->colormap[i].alpha-TransparentAlpha);\n                  beta=fabs(image->colormap[opacity].alpha-TransparentAlpha);\n                  if (alpha < beta)\n                    opacity=i;\n                }\n          }\n        if (opacity >= 0)\n          {\n            image->colormap[opacity].red=image->transparent_color.red;\n            image->colormap[opacity].green=image->transparent_color.green;\n            image->colormap[opacity].blue=image->transparent_color.blue;\n          }\n      }\n    if ((image->storage_class == DirectClass) || (image->colors > 256))\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    for (bits_per_pixel=1; bits_per_pixel < 8; bits_per_pixel++)\n      if ((one << bits_per_pixel) >= image->colors)\n        break;\n    q=colormap;\n    for (i=0; i < (ssize_t) image->colors; i++)\n    {\n      *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].red));\n      *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].green));\n      *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].blue));\n    }\n    for ( ; i < (ssize_t) (one << bits_per_pixel); i++)\n    {\n      *q++=(unsigned char) 0x0;\n      *q++=(unsigned char) 0x0;\n      *q++=(unsigned char) 0x0;\n    }\n    if ((GetPreviousImageInList(image) == (Image *) NULL) ||\n        (write_info->adjoin == MagickFalse))\n      {\n        \/*\n          Write global colormap.\n        *\/\n        c=0x80;\n        c|=(8-1) << 4;  \/* color resolution *\/\n        c|=(bits_per_pixel-1);   \/* size of global colormap *\/\n        (void) WriteBlobByte(image,(unsigned char) c);\n        for (j=0; j < (ssize_t) image->colors; j++)\n          if (IsPixelInfoEquivalent(&image->background_color,image->colormap+j))\n            break;\n        (void) WriteBlobByte(image,(unsigned char)\n          (j == (ssize_t) image->colors ? 0 : j));  \/* background color *\/\n        (void) WriteBlobByte(image,(unsigned char) 0x00);  \/* reserved *\/\n        length=(size_t) (3*(one << bits_per_pixel));\n        (void) WriteBlob(image,length,colormap);\n        for (j=0; j < 768; j++)\n          global_colormap[j]=colormap[j];\n      }\n    if (LocaleCompare(write_info->magick,\"GIF87\") != 0)\n      {\n        const char\n          *value;\n\n        \/*\n          Write graphics control extension.\n        *\/\n        (void) WriteBlobByte(image,(unsigned char) 0x21);\n        (void) WriteBlobByte(image,(unsigned char) 0xf9);\n        (void) WriteBlobByte(image,(unsigned char) 0x04);\n        c=image->dispose << 2;\n        if (opacity >= 0)\n          c|=0x01;\n        (void) WriteBlobByte(image,(unsigned char) c);\n        delay=(size_t) (100*image->delay\/MagickMax((size_t)\n          image->ticks_per_second,1));\n        (void) WriteBlobLSBShort(image,(unsigned short) delay);\n        (void) WriteBlobByte(image,(unsigned char) (opacity >= 0 ? opacity :\n          0));\n        (void) WriteBlobByte(image,(unsigned char) 0x00);\n        value=GetImageProperty(image,\"comment\",exception);\n        if (value != (const char *) NULL)\n          {\n            register const char\n              *p;\n\n            size_t\n              count;\n\n            \/*\n              Write comment extension.\n            *\/\n            (void) WriteBlobByte(image,(unsigned char) 0x21);\n            (void) WriteBlobByte(image,(unsigned char) 0xfe);\n            for (p=value; *p != '\\0'; )\n            {\n              count=MagickMin(strlen(p),255);\n              (void) WriteBlobByte(image,(unsigned char) count);\n              for (i=0; i < (ssize_t) count; i++)\n                (void) WriteBlobByte(image,(unsigned char) *p++);\n            }\n            (void) WriteBlobByte(image,(unsigned char) 0x00);\n          }\n        if ((GetPreviousImageInList(image) == (Image *) NULL) &&\n            (GetNextImageInList(image) != (Image *) NULL) &&\n            (image->iterations != 1))\n          {\n            \/*\n              Write Netscape Loop extension.\n            *\/\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n               \"  Writing GIF Extension %s\",\"NETSCAPE2.0\");\n            (void) WriteBlobByte(image,(unsigned char) 0x21);\n            (void) WriteBlobByte(image,(unsigned char) 0xff);\n            (void) WriteBlobByte(image,(unsigned char) 0x0b);\n            (void) WriteBlob(image,11,(unsigned char *) \"NETSCAPE2.0\");\n            (void) WriteBlobByte(image,(unsigned char) 0x03);\n            (void) WriteBlobByte(image,(unsigned char) 0x01);\n            (void) WriteBlobLSBShort(image,(unsigned short) (image->iterations ?\n              image->iterations-1 : 0));\n            (void) WriteBlobByte(image,(unsigned char) 0x00);\n          }\n        if ((image->gamma != 1.0f\/2.2f))\n          {\n            char\n              attributes[MagickPathExtent];\n\n            ssize_t\n              count;\n\n            \/*\n              Write ImageMagick extension.\n            *\/\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n               \"  Writing GIF Extension %s\",\"ImageMagick\");\n            (void) WriteBlobByte(image,(unsigned char) 0x21);\n            (void) WriteBlobByte(image,(unsigned char) 0xff);\n            (void) WriteBlobByte(image,(unsigned char) 0x0b);\n            (void) WriteBlob(image,11,(unsigned char *) \"ImageMagick\");\n            count=FormatLocaleString(attributes,MagickPathExtent,\"gamma=%g\",\n              image->gamma);\n            (void) WriteBlobByte(image,(unsigned char) count);\n            (void) WriteBlob(image,(size_t) count,(unsigned char *) attributes);\n            (void) WriteBlobByte(image,(unsigned char) 0x00);\n          }\n        ResetImageProfileIterator(image);\n        for ( ; ; )\n        {\n          char\n            *name;\n\n          const StringInfo\n            *profile;\n\n          name=GetNextImageProfile(image);\n          if (name == (const char *) NULL)\n            break;\n          profile=GetImageProfile(image,name);\n          if (profile != (StringInfo *) NULL)\n          {\n            if ((LocaleCompare(name,\"ICC\") == 0) ||\n                (LocaleCompare(name,\"ICM\") == 0) ||\n                (LocaleCompare(name,\"IPTC\") == 0) ||\n                (LocaleCompare(name,\"8BIM\") == 0) ||\n                (LocaleNCompare(name,\"gif:\",4) == 0))\n            {\n               ssize_t\n                 offset;\n\n               unsigned char\n                 *datum;\n\n               datum=GetStringInfoDatum(profile);\n               length=GetStringInfoLength(profile);\n               (void) WriteBlobByte(image,(unsigned char) 0x21);\n               (void) WriteBlobByte(image,(unsigned char) 0xff);\n               (void) WriteBlobByte(image,(unsigned char) 0x0b);\n               if ((LocaleCompare(name,\"ICC\") == 0) ||\n                   (LocaleCompare(name,\"ICM\") == 0))\n                 {\n                   \/*\n                     Write ICC extension.\n                   *\/\n                   (void) WriteBlob(image,11,(unsigned char *) \"ICCRGBG1012\");\n                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                     \"  Writing GIF Extension %s\",\"ICCRGBG1012\");\n                 }\n               else\n                 if ((LocaleCompare(name,\"IPTC\") == 0))\n                   {\n                     \/*\n                       Write IPTC extension.\n                     *\/\n                     (void) WriteBlob(image,11,(unsigned char *) \"MGKIPTC0000\");\n                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                       \"  Writing GIF Extension %s\",\"MGKIPTC0000\");\n                   }\n                 else\n                   if ((LocaleCompare(name,\"8BIM\") == 0))\n                     {\n                       \/*\n                         Write 8BIM extension.\n                       *\/\n                        (void) WriteBlob(image,11,(unsigned char *)\n                          \"MGK8BIM0000\");\n                        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                          \"  Writing GIF Extension %s\",\"MGK8BIM0000\");\n                     }\n                   else\n                     {\n                       char\n                         extension[MagickPathExtent];\n\n                       \/*\n                         Write generic extension.\n                       *\/\n                       (void) CopyMagickString(extension,name+4,\n                         sizeof(extension));\n                       (void) WriteBlob(image,11,(unsigned char *) extension);\n                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                         \"  Writing GIF Extension %s\",name);\n                     }\n               offset=0;\n               while ((ssize_t) length > offset)\n               {\n                 size_t\n                   block_length;\n\n                 if ((length-offset) < 255)\n                   block_length=length-offset;\n                 else\n                   block_length=255;\n                 (void) WriteBlobByte(image,(unsigned char) block_length);\n                 (void) WriteBlob(image,(size_t) block_length,datum+offset);\n                 offset+=(ssize_t) block_length;\n               }\n               (void) WriteBlobByte(image,(unsigned char) 0x00);\n            }\n          }\n        }\n      }\n    (void) WriteBlobByte(image,',');  \/* image separator *\/\n    \/*\n      Write the image header.\n    *\/\n    page.x=image->page.x;\n    page.y=image->page.y;\n    if ((image->page.width != 0) && (image->page.height != 0))\n      page=image->page;\n    (void) WriteBlobLSBShort(image,(unsigned short) (page.x < 0 ? 0 : page.x));\n    (void) WriteBlobLSBShort(image,(unsigned short) (page.y < 0 ? 0 : page.y));\n    (void) WriteBlobLSBShort(image,(unsigned short) image->columns);\n    (void) WriteBlobLSBShort(image,(unsigned short) image->rows);\n    c=0x00;\n    if (write_info->interlace != NoInterlace)\n      c|=0x40;  \/* pixel data is interlaced *\/\n    for (j=0; j < (ssize_t) (3*image->colors); j++)\n      if (colormap[j] != global_colormap[j])\n        break;\n    if (j == (ssize_t) (3*image->colors))\n      (void) WriteBlobByte(image,(unsigned char) c);\n    else\n      {\n        c|=0x80;\n        c|=(bits_per_pixel-1);   \/* size of local colormap *\/\n        (void) WriteBlobByte(image,(unsigned char) c);\n        length=(size_t) (3*(one << bits_per_pixel));\n        (void) WriteBlob(image,length,colormap);\n      }\n    \/*\n      Write the image data.\n    *\/\n    c=(int) MagickMax(bits_per_pixel,2);\n    (void) WriteBlobByte(image,(unsigned char) c);\n    status=EncodeImage(write_info,image,(size_t) MagickMax(bits_per_pixel,2)+1,\n      exception);\n    if (status == MagickFalse)\n      {\n        global_colormap=(unsigned char *) RelinquishMagickMemory(\n          global_colormap);\n        colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n        write_info=DestroyImageInfo(write_info);\n        ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n      }\n    (void) WriteBlobByte(image,(unsigned char) 0x00);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    scene++;\n    status=SetImageProgress(image,SaveImagesTag,scene,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (write_info->adjoin != MagickFalse);\n  (void) WriteBlobByte(image,';'); \/* terminator *\/\n  global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap);\n  colormap=(unsigned char *) RelinquishMagickMemory(colormap);\n  write_info=DestroyImageInfo(write_info);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":3865,"total_token_length":4101,"max_tokens_setting":6144}
+{"idx":208680,"func":"R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {\n\tbool cfg_anal_strings = r_config_get_i (core->config, \"anal.strings\");\n\tbool emu_lazy = r_config_get_i (core->config, \"emu.lazy\");\n\tbool gp_fixed = r_config_get_i (core->config, \"anal.gpfixed\");\n\tRAnalEsil *ESIL = core->anal->esil;\n\tut64 refptr = 0LL;\n\tconst char *pcname;\n\tRAnalOp op = R_EMPTY;\n\tut8 *buf = NULL;\n\tbool end_address_set = false;\n\tint iend;\n\tint minopsize = 4; \/\/ XXX this depends on asm->mininstrsize\n\tbool archIsArm = false;\n\tut64 addr = core->offset;\n\tut64 start = addr;\n\tut64 end = 0LL;\n\tut64 cur;\n\tif (esil_anal_stop || r_cons_is_breaked ()) {\n\t\t\/\/ faster ^C\n\t\treturn;\n\t}\n\n\tmycore = core;\n\tif (!strcmp (str, \"?\")) {\n\t\teprintf (\"Usage: aae[f] [len] [addr] - analyze refs in function, section or len bytes with esil\\n\");\n\t\teprintf (\"  aae $SS @ $S             - analyze the whole section\\n\");\n\t\teprintf (\"  aae $SS str.Hello @ $S   - find references for str.Hellow\\n\");\n\t\teprintf (\"  aaef                     - analyze functions discovered with esil\\n\");\n\t\treturn;\n\t}\n#define CHECKREF(x) ((refptr && (x) == refptr) || !refptr)\n\tif (target) {\n\t\tconst char *expr = r_str_trim_head_ro (target);\n\t\tif (*expr) {\n\t\t\trefptr = ntarget = r_num_math (core->num, expr);\n\t\t\tif (!refptr) {\n\t\t\t\tntarget = refptr = addr;\n\t\t\t}\n\t\t} else {\n\t\t\tntarget = UT64_MAX;\n\t\t\trefptr = 0LL;\n\t\t}\n\t} else {\n\t\tntarget = UT64_MAX;\n\t\trefptr = 0LL;\n\t}\n\tRAnalFunction *fcn = NULL;\n\tif (!strcmp (str, \"f\")) {\n\t\tfcn = r_anal_get_fcn_in (core->anal, core->offset, 0);\n\t\tif (fcn) {\n\t\t\tstart = r_anal_function_min_addr (fcn);\n\t\t\taddr = fcn->addr;\n\t\t\tend = r_anal_function_max_addr (fcn);\n\t\t\tend_address_set = true;\n\t\t}\n\t}\n\n\tif (!end_address_set) {\n\t\tif (str[0] == ' ') {\n\t\t\tend = addr + r_num_math (core->num, str + 1);\n\t\t} else {\n\t\t\tRIOMap *map = r_io_map_get_at (core->io, addr);\n\t\t\tif (map) {\n\t\t\t\tend = r_io_map_end (map);\n\t\t\t} else {\n\t\t\t\tend = addr + core->blocksize;\n\t\t\t}\n\t\t}\n\t}\n\n\tiend = end - start;\n\tif (iend < 0) {\n\t\treturn;\n\t}\n\tif (iend > MAX_SCAN_SIZE) {\n\t\teprintf (\"Warning: Not going to analyze 0x%08\"PFMT64x\" bytes.\\n\", (ut64)iend);\n\t\treturn;\n\t}\n\tbuf = malloc ((size_t)iend + 2);\n\tif (!buf) {\n\t\tperror (\"malloc\");\n\t\treturn;\n\t}\n\tesilbreak_last_read = UT64_MAX;\n\tr_io_read_at (core->io, start, buf, iend + 1);\n\tif (!ESIL) {\n\t\tr_core_cmd0 (core, \"aei\");\n\t\tESIL = core->anal->esil;\n\t\tif (!ESIL) {\n\t\t\teprintf (\"ESIL not initialized\\n\");\n\t\t\treturn;\n\t\t}\n\t\tr_core_cmd0 (core, \"aeim\");\n\t\tESIL = core->anal->esil;\n\t}\n\tconst char *spname = r_reg_get_name (core->anal->reg, R_REG_NAME_SP);\n\tif (!spname) {\n\t\teprintf (\"Error: No =SP defined in the reg profile.\\n\");\n\t\treturn;\n\t}\n\tEsilBreakCtx ctx = {\n\t\t&op,\n\t\tfcn,\n\t\tspname,\n\t\tr_reg_getv (core->anal->reg, spname)\n\t};\n\tESIL->cb.hook_reg_write = &esilbreak_reg_write;\n\t\/\/this is necessary for the hook to read the id of analop\n\tESIL->user = &ctx;\n\tESIL->cb.hook_mem_read = &esilbreak_mem_read;\n\tESIL->cb.hook_mem_write = &esilbreak_mem_write;\n\n\tif (fcn && fcn->reg_save_area) {\n\t\tr_reg_setv (core->anal->reg, ctx.spname, ctx.initial_sp - fcn->reg_save_area);\n\t}\n\t\/\/eprintf (\"Analyzing ESIL refs from 0x%\"PFMT64x\" - 0x%\"PFMT64x\"\\n\", addr, end);\n\t\/\/ TODO: backup\/restore register state before\/after analysis\n\tpcname = r_reg_get_name (core->anal->reg, R_REG_NAME_PC);\n\tif (!pcname || !*pcname) {\n\t\teprintf (\"Cannot find program counter register in the current profile.\\n\");\n\t\treturn;\n\t}\n\tesil_anal_stop = false;\n\tr_cons_break_push (cccb, core);\n\n\tint arch = -1;\n\tif (!strcmp (core->anal->cur->arch, \"arm\")) {\n\t\tswitch (core->anal->cur->bits) {\n\t\tcase 64: arch = R2_ARCH_ARM64; break;\n\t\tcase 32: arch = R2_ARCH_ARM32; break;\n\t\tcase 16: arch = R2_ARCH_THUMB; break;\n\t\t}\n\t\tarchIsArm = true;\n\t}\n\n\tut64 gp = r_config_get_i (core->config, \"anal.gp\");\n\tconst char *gp_reg = NULL;\n\tif (!strcmp (core->anal->cur->arch, \"mips\")) {\n\t\tgp_reg = \"gp\";\n\t\tarch = R2_ARCH_MIPS;\n\t}\n\n\tconst char *sn = r_reg_get_name (core->anal->reg, R_REG_NAME_SN);\n\tif (!sn) {\n\t\teprintf (\"Warning: No SN reg alias for current architecture.\\n\");\n\t}\n\tr_reg_arena_push (core->anal->reg);\n\n\tIterCtx ictx = { start, end, fcn, NULL };\n\tsize_t i = addr - start;\n\tsize_t i_old = 0;\n\tdo {\n\t\tif (esil_anal_stop || r_cons_is_breaked ()) {\n\t\t\tbreak;\n\t\t}\n\t\tcur = start + i;\n\t\tif (!r_io_is_valid_offset (core->io, cur, 0)) {\n\t\t\tbreak;\n\t\t}\n#if 0\n\t\t\/\/ disabled because it causes some tests to fail\n\t\t{\n\t\t\tRPVector *list = r_meta_get_all_in (core->anal, cur, R_META_TYPE_ANY);\n\t\t\tvoid **it;\n\t\t\tr_pvector_foreach (list, it) {\n\t\t\t\tRIntervalNode *node = *it;\n\t\t\t\tRAnalMetaItem *meta = node->data;\n\t\t\t\tswitch (meta->type) {\n\t\t\t\tcase R_META_TYPE_DATA:\n\t\t\t\tcase R_META_TYPE_STRING:\n\t\t\t\tcase R_META_TYPE_FORMAT:\n#if 0\n\t\t\t\t\t{\n\t\t\t\t\t\tint msz = r_meta_get_size (core->anal, meta->type);\n\t\t\t\t\t\ti += (msz > 0)? msz: minopsize;\n\t\t\t\t\t}\n\t\t\t\t\tr_pvector_free (list);\n\t\t\t\t\tgoto loopback;\n#elif 0\n\t\t\t\t\t{\n\t\t\t\t\t\tint msz = r_meta_get_size (core->anal, meta->type);\n\t\t\t\t\t\ti += (msz > 0)? msz: minopsize;\n\t\t\t\t\t\ti--;\n\t\t\t\t\t}\n#else\n\t\t\t\t\ti += 4;\n\t\t\t\t\tgoto repeat;\n#endif\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tr_pvector_free (list);\n\t\t}\n#endif\n\n\t\t\/* realign address if needed *\/\n\t\tr_core_seek_arch_bits (core, cur);\n\t\tint opalign = core->anal->pcalign;\n\t\tif (opalign > 0) {\n\t\t\tcur -= (cur % opalign);\n\t\t}\n\n\t\tr_anal_op_fini (&op);\n\t\tr_asm_set_pc (core->rasm, cur);\n\t\ti_old = i;\n#if 1\n\t\tif (i > iend) {\n\t\t\tgoto repeat;\n\t\t}\n#endif\n\t\tif (!r_anal_op (core->anal, &op, cur, buf + i, iend - i, R_ANAL_OP_MASK_ESIL | R_ANAL_OP_MASK_VAL | R_ANAL_OP_MASK_HINT)) {\n\t\t\ti += minopsize - 1; \/\/   XXX dupe in op.size below\n\t\t}\n\t\tif (op.type == R_ANAL_OP_TYPE_ILL || op.type == R_ANAL_OP_TYPE_UNK) {\n\t\t\t\/\/ i += 2\n\t\t\tr_anal_op_fini (&op);\n\t\t\tgoto repeat;\n\t\t}\n\t\t\/\/we need to check again i because buf+i may goes beyond its boundaries\n\t\t\/\/because of i+= minopsize - 1\n\t\tif (op.size < 1) {\n\t\t\ti += minopsize - 1;\n\t\t\tgoto repeat;\n\t\t}\n\t\tif (emu_lazy) {\n\t\t\tif (op.type & R_ANAL_OP_TYPE_REP) {\n\t\t\t\ti += op.size - 1;\n\t\t\t\tgoto repeat;\n\t\t\t}\n\t\t\tswitch (op.type & R_ANAL_OP_TYPE_MASK) {\n\t\t\tcase R_ANAL_OP_TYPE_JMP:\n\t\t\tcase R_ANAL_OP_TYPE_CJMP:\n\t\t\tcase R_ANAL_OP_TYPE_CALL:\n\t\t\tcase R_ANAL_OP_TYPE_RET:\n\t\t\tcase R_ANAL_OP_TYPE_ILL:\n\t\t\tcase R_ANAL_OP_TYPE_NOP:\n\t\t\tcase R_ANAL_OP_TYPE_UJMP:\n\t\t\tcase R_ANAL_OP_TYPE_IO:\n\t\t\tcase R_ANAL_OP_TYPE_LEAVE:\n\t\t\tcase R_ANAL_OP_TYPE_CRYPTO:\n\t\t\tcase R_ANAL_OP_TYPE_CPL:\n\t\t\tcase R_ANAL_OP_TYPE_SYNC:\n\t\t\tcase R_ANAL_OP_TYPE_SWI:\n\t\t\tcase R_ANAL_OP_TYPE_CMP:\n\t\t\tcase R_ANAL_OP_TYPE_ACMP:\n\t\t\tcase R_ANAL_OP_TYPE_NULL:\n\t\t\tcase R_ANAL_OP_TYPE_CSWI:\n\t\t\tcase R_ANAL_OP_TYPE_TRAP:\n\t\t\t\ti += op.size - 1;\n\t\t\t\tgoto repeat;\n\t\t\t\/\/  those require write support\n\t\t\tcase R_ANAL_OP_TYPE_PUSH:\n\t\t\tcase R_ANAL_OP_TYPE_POP:\n\t\t\t\ti += op.size - 1;\n\t\t\t\tgoto repeat;\n\t\t\t}\n\t\t}\n\t\tif (sn && op.type == R_ANAL_OP_TYPE_SWI) {\n\t\t\tr_strf_buffer (64);\n\t\t\tr_flag_space_set (core->flags, R_FLAGS_FS_SYSCALLS);\n\t\t\tint snv = (arch == R2_ARCH_THUMB)? op.val: (int)r_reg_getv (core->anal->reg, sn);\n\t\t\tRSyscallItem *si = r_syscall_get (core->anal->syscall, snv, -1);\n\t\t\tif (si) {\n\t\t\t\/\/\teprintf (\"0x%08\"PFMT64x\" SYSCALL %-4d %s\\n\", cur, snv, si->name);\n\t\t\t\tr_flag_set_next (core->flags, r_strf (\"syscall.%s\", si->name), cur, 1);\n\t\t\t} else {\n\t\t\t\t\/\/todo were doing less filtering up top because we can't match against 80 on all platforms\n\t\t\t\t\/\/ might get too many of this path now..\n\t\t\t\/\/\teprintf (\"0x%08\"PFMT64x\" SYSCALL %d\\n\", cur, snv);\n\t\t\t\tr_flag_set_next (core->flags, r_strf (\"syscall.%d\", snv), cur, 1);\n\t\t\t}\n\t\t\tr_flag_space_set (core->flags, NULL);\n\t\t\tr_syscall_item_free (si);\n\t\t}\n\t\tconst char *esilstr = R_STRBUF_SAFEGET (&op.esil);\n\t\ti += op.size - 1;\n\t\tif (R_STR_ISEMPTY (esilstr)) {\n\t\t\tgoto repeat;\n\t\t}\n\t\tr_anal_esil_set_pc (ESIL, cur);\n\t\tr_reg_setv (core->anal->reg, pcname, cur + op.size);\n\t\tif (gp_fixed && gp_reg) {\n\t\t\tr_reg_setv (core->anal->reg, gp_reg, gp);\n\t\t}\n\t\t(void)r_anal_esil_parse (ESIL, esilstr);\n\t\t\/\/ looks like ^C is handled by esil_parse !!!!\n\t\t\/\/r_anal_esil_dumpstack (ESIL);\n\t\t\/\/r_anal_esil_stack_free (ESIL);\n\t\tswitch (op.type) {\n\t\tcase R_ANAL_OP_TYPE_LEA:\n\t\t\t\/\/ arm64\n\t\t\tif (core->anal->cur && arch == R2_ARCH_ARM64) {\n\t\t\t\tif (CHECKREF (ESIL->cur)) {\n\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, ESIL->cur, R_ANAL_REF_TYPE_STRING);\n\t\t\t\t}\n\t\t\t} else if ((target && op.ptr == ntarget) || !target) {\n\t\t\t\tif (CHECKREF (ESIL->cur)) {\n\t\t\t\t\tif (op.ptr && r_io_is_valid_offset (core->io, op.ptr, !core->anal->opt.noncode)) {\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, op.ptr, R_ANAL_REF_TYPE_STRING);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, ESIL->cur, R_ANAL_REF_TYPE_STRING);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cfg_anal_strings) {\n\t\t\t\tadd_string_ref (core, op.addr, op.ptr);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_ANAL_OP_TYPE_ADD:\n\t\t\t\/* TODO: test if this is valid for other archs too *\/\n\t\t\tif (core->anal->cur && archIsArm) {\n\t\t\t\t\/* This code is known to work on Thumb, ARM and ARM64 *\/\n\t\t\t\tut64 dst = ESIL->cur;\n\t\t\t\tif ((target && dst == ntarget) || !target) {\n\t\t\t\t\tif (CHECKREF (dst)) {\n\t\t\t\t\t\tint type = core_type_by_addr (core, dst); \/\/ R_ANAL_REF_TYPE_DATA;\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, type);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (cfg_anal_strings) {\n\t\t\t\t\tadd_string_ref (core, op.addr, dst);\n\t\t\t\t}\n\t\t\t} else if ((core->anal->bits == 32 && core->anal->cur && arch == R2_ARCH_MIPS)) {\n\t\t\t\tut64 dst = ESIL->cur;\n\t\t\t\tif (!op.src[0] || !op.src[0]->reg || !op.src[0]->reg->name) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!strcmp (op.src[0]->reg->name, \"sp\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!strcmp (op.src[0]->reg->name, \"zero\")) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif ((target && dst == ntarget) || !target) {\n\t\t\t\t\tif (dst > 0xffff && op.src[1] && (dst & 0xffff) == (op.src[1]->imm & 0xffff) && myvalid (mycore->io, dst)) {\n\t\t\t\t\t\tRFlagItem *f;\n\t\t\t\t\t\tchar *str;\n\t\t\t\t\t\tif (CHECKREF (dst) || CHECKREF (cur)) {\n\t\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, R_ANAL_REF_TYPE_DATA);\n\t\t\t\t\t\t\tif (cfg_anal_strings) {\n\t\t\t\t\t\t\t\tadd_string_ref (core, op.addr, dst);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((f = r_core_flag_get_by_spaces (core->flags, dst))) {\n\t\t\t\t\t\t\t\tr_meta_set_string (core->anal, R_META_TYPE_COMMENT, cur, f->name);\n\t\t\t\t\t\t\t} else if ((str = is_string_at (mycore, dst, NULL))) {\n\t\t\t\t\t\t\t\tchar *str2 = r_str_newf (\"esilref: '%s'\", str);\n\t\t\t\t\t\t\t\t\/\/ HACK avoid format string inside string used later as format\n\t\t\t\t\t\t\t\t\/\/ string crashes disasm inside agf under some conditions.\n\t\t\t\t\t\t\t\t\/\/ https:\/\/github.com\/radareorg\/radare2\/issues\/6937\n\t\t\t\t\t\t\t\tr_str_replace_char (str2, '%', '&');\n\t\t\t\t\t\t\t\tr_meta_set_string (core->anal, R_META_TYPE_COMMENT, cur, str2);\n\t\t\t\t\t\t\t\tfree (str2);\n\t\t\t\t\t\t\t\tfree (str);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_ANAL_OP_TYPE_LOAD:\n\t\t\t{\n\t\t\t\tut64 dst = esilbreak_last_read;\n\t\t\t\tif (dst != UT64_MAX && CHECKREF (dst)) {\n\t\t\t\t\tif (myvalid (mycore->io, dst)) {\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, R_ANAL_REF_TYPE_DATA);\n\t\t\t\t\t\tif (cfg_anal_strings) {\n\t\t\t\t\t\t\tadd_string_ref (core, op.addr, dst);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdst = esilbreak_last_data;\n\t\t\t\tif (dst != UT64_MAX && CHECKREF (dst)) {\n\t\t\t\t\tif (myvalid (mycore->io, dst)) {\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, R_ANAL_REF_TYPE_DATA);\n\t\t\t\t\t\tif (cfg_anal_strings) {\n\t\t\t\t\t\t\tadd_string_ref (core, op.addr, dst);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_ANAL_OP_TYPE_JMP:\n\t\t\t{\n\t\t\t\tut64 dst = op.jump;\n\t\t\t\tif (CHECKREF (dst)) {\n\t\t\t\t\tif (myvalid (core->io, dst)) {\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, R_ANAL_REF_TYPE_CODE);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_ANAL_OP_TYPE_CALL:\n\t\t\t{\n\t\t\t\tut64 dst = op.jump;\n\t\t\t\tif (CHECKREF (dst)) {\n\t\t\t\t\tif (myvalid (core->io, dst)) {\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, R_ANAL_REF_TYPE_CALL);\n\t\t\t\t\t}\n\t\t\t\t\tESIL->old = cur + op.size;\n\t\t\t\t\tgetpcfromstack (core, ESIL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_ANAL_OP_TYPE_UJMP:\n\t\tcase R_ANAL_OP_TYPE_UCALL:\n\t\tcase R_ANAL_OP_TYPE_ICALL:\n\t\tcase R_ANAL_OP_TYPE_RCALL:\n\t\tcase R_ANAL_OP_TYPE_IRCALL:\n\t\tcase R_ANAL_OP_TYPE_MJMP:\n\t\t\t{\n\t\t\t\tut64 dst = core->anal->esil->jump_target;\n\t\t\t\tif (dst == 0 || dst == UT64_MAX) {\n\t\t\t\t\tdst = r_reg_getv (core->anal->reg, pcname);\n\t\t\t\t}\n\t\t\t\tif (CHECKREF (dst)) {\n\t\t\t\t\tif (myvalid (core->io, dst)) {\n\t\t\t\t\t\tRAnalRefType ref =\n\t\t\t\t\t\t\t(op.type & R_ANAL_OP_TYPE_MASK) == R_ANAL_OP_TYPE_UCALL\n\t\t\t\t\t\t\t? R_ANAL_REF_TYPE_CALL\n\t\t\t\t\t\t\t: R_ANAL_REF_TYPE_CODE;\n\t\t\t\t\t\tr_anal_xrefs_set (core->anal, cur, dst, ref);\n\t\t\t\t\t\tr_core_anal_fcn (core, dst, UT64_MAX, R_ANAL_REF_TYPE_NULL, 1);\n\/\/ analyze function here\n#if 0\n\t\t\t\t\t\tif (op.type == R_ANAL_OP_TYPE_UCALL || op.type == R_ANAL_OP_TYPE_RCALL) {\n\t\t\t\t\t\t\teprintf (\"0x%08\"PFMT64x\"  RCALL TO %llx\\n\", cur, dst);\n\t\t\t\t\t\t}\n#endif\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tr_anal_esil_stack_free (ESIL);\nrepeat:\n\t\tif (!r_anal_get_block_at (core->anal, cur)) {\n\t\t\tsize_t fcn_i;\n\t\t\tfor (fcn_i = i_old + 1; fcn_i <= i; fcn_i++) {\n\t\t\t\tif (r_anal_get_function_at (core->anal, start + fcn_i)) {\n\t\t\t\t\ti = fcn_i - 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (i >= iend) {\n\t\t\tbreak;\n\t\t}\n\t} while (get_next_i (&ictx, &i));\n\tr_list_free (ictx.bbl);\n\tr_list_free (ictx.path);\n\tr_list_free (ictx.switch_path);\n\tfree (buf);\n\tESIL->cb.hook_mem_read = NULL;\n\tESIL->cb.hook_mem_write = NULL;\n\tESIL->cb.hook_reg_write = NULL;\n\tESIL->user = NULL;\n\tr_anal_op_fini (&op);\n\tr_cons_break_pop ();\n\t\/\/ restore register\n\tr_reg_arena_pop (core->anal->reg);\n}","target":1,"code_token_length":4538,"total_token_length":4774,"max_tokens_setting":6144}
+{"idx":448912,"func":"int ZEXPORT inflate(strm, flush)\nz_streamp strm;\nint flush;\n{\n    struct inflate_state FAR *state;\n    z_const unsigned char FAR *next;    \/* next input *\/\n    unsigned char FAR *put;     \/* next output *\/\n    unsigned have, left;        \/* available input and output *\/\n    unsigned long hold;         \/* bit buffer *\/\n    unsigned bits;              \/* bits in bit buffer *\/\n    unsigned in, out;           \/* save starting available input and output *\/\n    unsigned copy;              \/* number of stored or match bytes to copy *\/\n    unsigned char FAR *from;    \/* where to copy match bytes from *\/\n    code here;                  \/* current decoding table entry *\/\n    code last;                  \/* parent table entry *\/\n    unsigned len;               \/* length to copy for repeats, bits to drop *\/\n    int ret;                    \/* return code *\/\n#ifdef GUNZIP\n    unsigned char hbuf[4];      \/* buffer for gzip header crc calculation *\/\n#endif\n    static const unsigned short order[19] = \/* permutation of code lengths *\/\n        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||\n        (strm->next_in == Z_NULL && strm->avail_in != 0))\n        return Z_STREAM_ERROR;\n\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->mode == TYPE) state->mode = TYPEDO;      \/* skip check *\/\n    LOAD();\n    in = have;\n    out = left;\n    ret = Z_OK;\n    for (;;)\n        switch (state->mode) {\n        case HEAD:\n            if (state->wrap == 0) {\n                state->mode = TYPEDO;\n                break;\n            }\n            NEEDBITS(16);\n#ifdef GUNZIP\n            if ((state->wrap & 2) && hold == 0x8b1f) {  \/* gzip header *\/\n                if (state->wbits == 0)\n                    state->wbits = 15;\n                state->check = crc32(0L, Z_NULL, 0);\n                CRC2(state->check, hold);\n                INITBITS();\n                state->mode = FLAGS;\n                break;\n            }\n            if (state->head != Z_NULL)\n                state->head->done = -1;\n            if (!(state->wrap & 1) ||   \/* check if zlib header allowed *\/\n#else\n            if (\n#endif\n                ((BITS(8) << 8) + (hold >> 8)) % 31) {\n                strm->msg = (char *)\"incorrect header check\";\n                state->mode = BAD;\n                break;\n            }\n            if (BITS(4) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            DROPBITS(4);\n            len = BITS(4) + 8;\n            if (state->wbits == 0)\n                state->wbits = len;\n            if (len > 15 || len > state->wbits) {\n                strm->msg = (char *)\"invalid window size\";\n                state->mode = BAD;\n                break;\n            }\n            state->dmax = 1U << len;\n            state->flags = 0;               \/* indicate zlib header *\/\n            Tracev((stderr, \"inflate:   zlib header ok\\n\"));\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = hold & 0x200 ? DICTID : TYPE;\n            INITBITS();\n            break;\n#ifdef GUNZIP\n        case FLAGS:\n            NEEDBITS(16);\n            state->flags = (int)(hold);\n            if ((state->flags & 0xff) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->flags & 0xe000) {\n                strm->msg = (char *)\"unknown header flags set\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->head != Z_NULL)\n                state->head->text = (int)((hold >> 8) & 1);\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC2(state->check, hold);\n            INITBITS();\n            state->mode = TIME;\n                \/* fallthrough *\/\n        case TIME:\n            NEEDBITS(32);\n            if (state->head != Z_NULL)\n                state->head->time = hold;\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC4(state->check, hold);\n            INITBITS();\n            state->mode = OS;\n                \/* fallthrough *\/\n        case OS:\n            NEEDBITS(16);\n            if (state->head != Z_NULL) {\n                state->head->xflags = (int)(hold & 0xff);\n                state->head->os = (int)(hold >> 8);\n            }\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC2(state->check, hold);\n            INITBITS();\n            state->mode = EXLEN;\n                \/* fallthrough *\/\n        case EXLEN:\n            if (state->flags & 0x0400) {\n                NEEDBITS(16);\n                state->length = (unsigned)(hold);\n                if (state->head != Z_NULL)\n                    state->head->extra_len = (unsigned)hold;\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    CRC2(state->check, hold);\n                INITBITS();\n            }\n            else if (state->head != Z_NULL)\n                state->head->extra = Z_NULL;\n            state->mode = EXTRA;\n                \/* fallthrough *\/\n        case EXTRA:\n            if (state->flags & 0x0400) {\n                copy = state->length;\n                if (copy > have) copy = have;\n                if (copy) {\n                    len = state->head->extra_len - state->length;\n                    if (state->head != Z_NULL &&\n                        state->head->extra != Z_NULL &&\n                        len < state->head->extra_max) {\n                        zmemcpy(state->head->extra + len, next,\n                                len + copy > state->head->extra_max ?\n                                state->head->extra_max - len : copy);\n                    }\n                    if ((state->flags & 0x0200) && (state->wrap & 4))\n                        state->check = crc32(state->check, next, copy);\n                    have -= copy;\n                    next += copy;\n                    state->length -= copy;\n                }\n                if (state->length) goto inf_leave;\n            }\n            state->length = 0;\n            state->mode = NAME;\n                \/* fallthrough *\/\n        case NAME:\n            if (state->flags & 0x0800) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->name != Z_NULL &&\n                            state->length < state->head->name_max)\n                        state->head->name[state->length++] = (Bytef)len;\n                } while (len && copy < have);\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->name = Z_NULL;\n            state->length = 0;\n            state->mode = COMMENT;\n                \/* fallthrough *\/\n        case COMMENT:\n            if (state->flags & 0x1000) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->comment != Z_NULL &&\n                            state->length < state->head->comm_max)\n                        state->head->comment[state->length++] = (Bytef)len;\n                } while (len && copy < have);\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->comment = Z_NULL;\n            state->mode = HCRC;\n                \/* fallthrough *\/\n        case HCRC:\n            if (state->flags & 0x0200) {\n                NEEDBITS(16);\n                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {\n                    strm->msg = (char *)\"header crc mismatch\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n            }\n            if (state->head != Z_NULL) {\n                state->head->hcrc = (int)((state->flags >> 9) & 1);\n                state->head->done = 1;\n            }\n            strm->adler = state->check = crc32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n            break;\n#endif\n        case DICTID:\n            NEEDBITS(32);\n            strm->adler = state->check = ZSWAP32(hold);\n            INITBITS();\n            state->mode = DICT;\n                \/* fallthrough *\/\n        case DICT:\n            if (state->havedict == 0) {\n                RESTORE();\n                return Z_NEED_DICT;\n            }\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n                \/* fallthrough *\/\n        case TYPE:\n            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;\n                \/* fallthrough *\/\n        case TYPEDO:\n            if (state->last) {\n                BYTEBITS();\n                state->mode = CHECK;\n                break;\n            }\n            NEEDBITS(3);\n            state->last = BITS(1);\n            DROPBITS(1);\n            switch (BITS(2)) {\n            case 0:                             \/* stored block *\/\n                Tracev((stderr, \"inflate:     stored block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = STORED;\n                break;\n            case 1:                             \/* fixed block *\/\n                fixedtables(state);\n                Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = LEN_;             \/* decode codes *\/\n                if (flush == Z_TREES) {\n                    DROPBITS(2);\n                    goto inf_leave;\n                }\n                break;\n            case 2:                             \/* dynamic block *\/\n                Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = TABLE;\n                break;\n            case 3:\n                strm->msg = (char *)\"invalid block type\";\n                state->mode = BAD;\n            }\n            DROPBITS(2);\n            break;\n        case STORED:\n            BYTEBITS();                         \/* go to byte boundary *\/\n            NEEDBITS(32);\n            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {\n                strm->msg = (char *)\"invalid stored block lengths\";\n                state->mode = BAD;\n                break;\n            }\n            state->length = (unsigned)hold & 0xffff;\n            Tracev((stderr, \"inflate:       stored length %u\\n\",\n                    state->length));\n            INITBITS();\n            state->mode = COPY_;\n            if (flush == Z_TREES) goto inf_leave;\n                \/* fallthrough *\/\n        case COPY_:\n            state->mode = COPY;\n                \/* fallthrough *\/\n        case COPY:\n            copy = state->length;\n            if (copy) {\n                if (copy > have) copy = have;\n                if (copy > left) copy = left;\n                if (copy == 0) goto inf_leave;\n                zmemcpy(put, next, copy);\n                have -= copy;\n                next += copy;\n                left -= copy;\n                put += copy;\n                state->length -= copy;\n                break;\n            }\n            Tracev((stderr, \"inflate:       stored end\\n\"));\n            state->mode = TYPE;\n            break;\n        case TABLE:\n            NEEDBITS(14);\n            state->nlen = BITS(5) + 257;\n            DROPBITS(5);\n            state->ndist = BITS(5) + 1;\n            DROPBITS(5);\n            state->ncode = BITS(4) + 4;\n            DROPBITS(4);\n#ifndef PKZIP_BUG_WORKAROUND\n            if (state->nlen > 286 || state->ndist > 30) {\n                strm->msg = (char *)\"too many length or distance symbols\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n            state->have = 0;\n            state->mode = LENLENS;\n                \/* fallthrough *\/\n        case LENLENS:\n            while (state->have < state->ncode) {\n                NEEDBITS(3);\n                state->lens[order[state->have++]] = (unsigned short)BITS(3);\n                DROPBITS(3);\n            }\n            while (state->have < 19)\n                state->lens[order[state->have++]] = 0;\n            state->next = state->codes;\n            state->lencode = (const code FAR *)(state->next);\n            state->lenbits = 7;\n            ret = inflate_table(CODES, state->lens, 19, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid code lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n            state->have = 0;\n            state->mode = CODELENS;\n                \/* fallthrough *\/\n        case CODELENS:\n            while (state->have < state->nlen + state->ndist) {\n                for (;;) {\n                    here = state->lencode[BITS(state->lenbits)];\n                    if ((unsigned)(here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                if (here.val < 16) {\n                    DROPBITS(here.bits);\n                    state->lens[state->have++] = here.val;\n                }\n                else {\n                    if (here.val == 16) {\n                        NEEDBITS(here.bits + 2);\n                        DROPBITS(here.bits);\n                        if (state->have == 0) {\n                            strm->msg = (char *)\"invalid bit length repeat\";\n                            state->mode = BAD;\n                            break;\n                        }\n                        len = state->lens[state->have - 1];\n                        copy = 3 + BITS(2);\n                        DROPBITS(2);\n                    }\n                    else if (here.val == 17) {\n                        NEEDBITS(here.bits + 3);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 3 + BITS(3);\n                        DROPBITS(3);\n                    }\n                    else {\n                        NEEDBITS(here.bits + 7);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 11 + BITS(7);\n                        DROPBITS(7);\n                    }\n                    if (state->have + copy > state->nlen + state->ndist) {\n                        strm->msg = (char *)\"invalid bit length repeat\";\n                        state->mode = BAD;\n                        break;\n                    }\n                    while (copy--)\n                        state->lens[state->have++] = (unsigned short)len;\n                }\n            }\n\n            \/* handle error breaks in while *\/\n            if (state->mode == BAD) break;\n\n            \/* check for end-of-block code (better have one) *\/\n            if (state->lens[256] == 0) {\n                strm->msg = (char *)\"invalid code -- missing end-of-block\";\n                state->mode = BAD;\n                break;\n            }\n\n            \/* build code tables -- note: do not change the lenbits or distbits\n               values here (9 and 6) without reading the comments in inftrees.h\n               concerning the ENOUGH constants, which depend on those values *\/\n            state->next = state->codes;\n            state->lencode = (const code FAR *)(state->next);\n            state->lenbits = 9;\n            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid literal\/lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            state->distcode = (const code FAR *)(state->next);\n            state->distbits = 6;\n            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,\n                            &(state->next), &(state->distbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid distances set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       codes ok\\n\"));\n            state->mode = LEN_;\n            if (flush == Z_TREES) goto inf_leave;\n                \/* fallthrough *\/\n        case LEN_:\n            state->mode = LEN;\n                \/* fallthrough *\/\n        case LEN:\n            if (have >= 6 && left >= 258) {\n                RESTORE();\n                inflate_fast(strm, out);\n                LOAD();\n                if (state->mode == TYPE)\n                    state->back = -1;\n                break;\n            }\n            state->back = 0;\n            for (;;) {\n                here = state->lencode[BITS(state->lenbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if (here.op && (here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->lencode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            state->length = (unsigned)here.val;\n            if ((int)(here.op) == 0) {\n                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                        \"inflate:         literal '%c'\\n\" :\n                        \"inflate:         literal 0x%02x\\n\", here.val));\n                state->mode = LIT;\n                break;\n            }\n            if (here.op & 32) {\n                Tracevv((stderr, \"inflate:         end of block\\n\"));\n                state->back = -1;\n                state->mode = TYPE;\n                break;\n            }\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid literal\/length code\";\n                state->mode = BAD;\n                break;\n            }\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = LENEXT;\n                \/* fallthrough *\/\n        case LENEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->length += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", state->length));\n            state->was = state->length;\n            state->mode = DIST;\n                \/* fallthrough *\/\n        case DIST:\n            for (;;) {\n                here = state->distcode[BITS(state->distbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if ((here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->distcode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n            state->offset = (unsigned)here.val;\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = DISTEXT;\n                \/* fallthrough *\/\n        case DISTEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->offset += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n#ifdef INFLATE_STRICT\n            if (state->offset > state->dmax) {\n                strm->msg = (char *)\"invalid distance too far back\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracevv((stderr, \"inflate:         distance %u\\n\", state->offset));\n            state->mode = MATCH;\n                \/* fallthrough *\/\n        case MATCH:\n            if (left == 0) goto inf_leave;\n            copy = out - left;\n            if (state->offset > copy) {         \/* copy from window *\/\n                copy = state->offset - copy;\n                if (copy > state->whave) {\n                    if (state->sane) {\n                        strm->msg = (char *)\"invalid distance too far back\";\n                        state->mode = BAD;\n                        break;\n                    }\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n                    Trace((stderr, \"inflate.c too far\\n\"));\n                    copy -= state->whave;\n                    if (copy > state->length) copy = state->length;\n                    if (copy > left) copy = left;\n                    left -= copy;\n                    state->length -= copy;\n                    do {\n                        *put++ = 0;\n                    } while (--copy);\n                    if (state->length == 0) state->mode = LEN;\n                    break;\n#endif\n                }\n                if (copy > state->wnext) {\n                    copy -= state->wnext;\n                    from = state->window + (state->wsize - copy);\n                }\n                else\n                    from = state->window + (state->wnext - copy);\n                if (copy > state->length) copy = state->length;\n            }\n            else {                              \/* copy from output *\/\n                from = put - state->offset;\n                copy = state->length;\n            }\n            if (copy > left) copy = left;\n            left -= copy;\n            state->length -= copy;\n            do {\n                *put++ = *from++;\n            } while (--copy);\n            if (state->length == 0) state->mode = LEN;\n            break;\n        case LIT:\n            if (left == 0) goto inf_leave;\n            *put++ = (unsigned char)(state->length);\n            left--;\n            state->mode = LEN;\n            break;\n        case CHECK:\n            if (state->wrap) {\n                NEEDBITS(32);\n                out -= left;\n                strm->total_out += out;\n                state->total += out;\n                if ((state->wrap & 4) && out)\n                    strm->adler = state->check =\n                        UPDATE_CHECK(state->check, put - out, out);\n                out = left;\n                if ((state->wrap & 4) && (\n#ifdef GUNZIP\n                     state->flags ? hold :\n#endif\n                     ZSWAP32(hold)) != state->check) {\n                    strm->msg = (char *)\"incorrect data check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   check matches trailer\\n\"));\n            }\n#ifdef GUNZIP\n            state->mode = LENGTH;\n                \/* fallthrough *\/\n        case LENGTH:\n            if (state->wrap && state->flags) {\n                NEEDBITS(32);\n                if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {\n                    strm->msg = (char *)\"incorrect length check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   length matches trailer\\n\"));\n            }\n#endif\n            state->mode = DONE;\n                \/* fallthrough *\/\n        case DONE:\n            ret = Z_STREAM_END;\n            goto inf_leave;\n        case BAD:\n            ret = Z_DATA_ERROR;\n            goto inf_leave;\n        case MEM:\n            return Z_MEM_ERROR;\n        case SYNC:\n                \/* fallthrough *\/\n        default:\n            return Z_STREAM_ERROR;\n        }\n\n    \/*\n       Return from inflate(), updating the total counts and the check value.\n       If there was no progress during the inflate() call, return a buffer\n       error.  Call updatewindow() to create and\/or update the window state.\n       Note: a memory error from inflate() is non-recoverable.\n     *\/\n  inf_leave:\n    RESTORE();\n    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&\n            (state->mode < CHECK || flush != Z_FINISH)))\n        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {\n            state->mode = MEM;\n            return Z_MEM_ERROR;\n        }\n    in -= strm->avail_in;\n    out -= strm->avail_out;\n    strm->total_in += in;\n    strm->total_out += out;\n    state->total += out;\n    if ((state->wrap & 4) && out)\n        strm->adler = state->check =\n            UPDATE_CHECK(state->check, strm->next_out - out, out);\n    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +\n                      (state->mode == TYPE ? 128 : 0) +\n                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);\n    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)\n        ret = Z_BUF_ERROR;\n    return ret;\n}","target":0,"code_token_length":5873,"total_token_length":6109,"max_tokens_setting":6144}
+{"idx":359843,"func":"WandPrivate void CLINoImageOperator(MagickCLI *cli_wand,\n  const char *option,const char *arg1n,const char *arg2n)\n{\n  const char    \/* percent escaped versions of the args *\/\n    *arg1,\n    *arg2;\n\n#define _image_info     (cli_wand->wand.image_info)\n#define _images         (cli_wand->wand.images)\n#define _exception      (cli_wand->wand.exception)\n#define _process_flags  (cli_wand->process_flags)\n#define _option_type    ((CommandOptionFlags) cli_wand->command->flags)\n#define IfNormalOp      (*option=='-')\n#define IfPlusOp        (*option!='-')\n\n  assert(cli_wand != (MagickCLI *) NULL);\n  assert(cli_wand->signature == MagickWandSignature);\n  assert(cli_wand->wand.signature == MagickWandSignature);\n\n  if (cli_wand->wand.debug != MagickFalse)\n    (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),\n      \"- NoImage Operator: %s \\\"%s\\\" \\\"%s\\\"\", option,\n      arg1n != (char *) NULL ? arg1n : \"\",\n      arg2n != (char *) NULL ? arg2n : \"\");\n\n  arg1 = arg1n;\n  arg2 = arg2n;\n\n  \/* Interpret Percent Escapes in Arguments - using first image *\/\n  if ( (((_process_flags & ProcessInterpretProperities) != 0 )\n        || ((_option_type & AlwaysInterpretArgsFlag) != 0)\n       )  && ((_option_type & NeverInterpretArgsFlag) == 0) ) {\n    \/* Interpret Percent escapes in argument 1 *\/\n    if (arg1n != (char *) NULL) {\n      arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);\n      if (arg1 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg1=arg1n;  \/* use the given argument as is *\/\n      }\n    }\n    if (arg2n != (char *) NULL) {\n      arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n      if (arg2 == (char *) NULL) {\n        CLIWandException(OptionWarning,\"InterpretPropertyFailure\",option);\n        arg2=arg2n;  \/* use the given argument as is *\/\n      }\n    }\n  }\n#undef _process_flags\n#undef _option_type\n\n  do {  \/* break to exit code *\/\n    \/*\n      No-op options  (ignore these)\n    *\/\n    if (LocaleCompare(\"noop\",option+1) == 0)   \/* zero argument *\/\n      break;\n    if (LocaleCompare(\"sans\",option+1) == 0)   \/* one argument *\/\n      break;\n    if (LocaleCompare(\"sans0\",option+1) == 0)  \/* zero argument *\/\n      break;\n    if (LocaleCompare(\"sans1\",option+1) == 0)  \/* one argument *\/\n      break;\n    if (LocaleCompare(\"sans2\",option+1) == 0)  \/* two arguments *\/\n      break;\n    \/*\n      Image Reading\n    *\/\n    if ( ( LocaleCompare(\"read\",option+1) == 0 ) ||\n      ( LocaleCompare(\"--\",option) == 0 ) ) {\n      \/* Do Glob filename Expansion for 'arg1' then read all images.\n      *\n      * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring\n      * (but attaching to the filenames in the generated argument list) any\n      * [...] read modifiers that may be present.\n      *\n      * For example: It will expand '*.gif[20x20]' into a list such as\n      * 'abc.gif[20x20]',  'foobar.gif[20x20]',  'xyzzy.gif[20x20]'\n      *\n      * NOTE: In IMv6 this was done globally across all images. This\n      * meant you could include IM options in '@filename' lists, but you\n      * could not include comments.   Doing it only for image read makes\n      * it far more secure.\n      *\n      * Note: arguments do not have percent escapes expanded for security\n      * reasons.\n      *\/\n      int      argc;\n      char     **argv;\n      ssize_t  i;\n\n      argc = 1;\n      argv = (char **) &arg1;\n\n      \/* Expand 'glob' expressions in the given filename.\n        Expansion handles any 'coder:' prefix, or read modifiers attached\n        to the filename, including them in the resulting expanded list.\n      *\/\n      if (ExpandFilenames(&argc,&argv) == MagickFalse)\n        CLIWandExceptArgBreak(ResourceLimitError,\"MemoryAllocationFailed\",\n            option,GetExceptionMessage(errno));\n\n      \/* loop over expanded filename list, and read then all in *\/\n      for (i=0; i < (ssize_t) argc; i++) {\n        Image *\n          new_images;\n        if (_image_info->ping != MagickFalse)\n          new_images=PingImages(_image_info,argv[i],_exception);\n        else\n          new_images=ReadImages(_image_info,argv[i],_exception);\n        AppendImageToList(&_images, new_images);\n        argv[i]=DestroyString(argv[i]);\n      }\n      argv=(char **) RelinquishMagickMemory(argv);\n      break;\n    }\n    \/*\n      Image Writing\n      Note: Writing a empty image list is valid in specific cases\n    *\/\n    if (LocaleCompare(\"write\",option+1) == 0) {\n      \/* Note: arguments do not have percent escapes expanded *\/\n      char\n        key[MagickPathExtent];\n\n      Image\n        *write_images;\n\n      ImageInfo\n        *write_info;\n\n      \/* Need images, unless a \"null:\" output coder is used *\/\n      if ( _images == (Image *) NULL ) {\n        if ( LocaleCompare(arg1,\"null:\") == 0 )\n          break;\n        CLIWandExceptArgBreak(OptionError,\"NoImagesForWrite\",option,arg1);\n      }\n\n      (void) FormatLocaleString(key,MagickPathExtent,\"cache:%s\",arg1);\n      (void) DeleteImageRegistry(key);\n      write_images=CloneImageList(_images,_exception);\n      write_info=CloneImageInfo(_image_info);\n      if (write_images != (Image *) NULL)\n        (void) WriteImages(write_info,write_images,arg1,_exception);\n      write_info=DestroyImageInfo(write_info);\n      write_images=DestroyImageList(write_images);\n      break;\n    }\n    \/*\n      Parenthesis and Brace operations\n    *\/\n    if (LocaleCompare(\"(\",option) == 0) {\n      \/* stack 'push' images *\/\n      Stack\n        *node;\n\n      size_t\n        size;\n\n      size=0;\n      node=cli_wand->image_list_stack;\n      for ( ; node != (Stack *) NULL; node=node->next)\n        size++;\n      if ( size >= MAX_STACK_DEPTH )\n        CLIWandExceptionBreak(OptionError,\"ParenthesisNestedTooDeeply\",option);\n      node=(Stack *) AcquireMagickMemory(sizeof(*node));\n      if (node == (Stack *) NULL)\n        CLIWandExceptionBreak(ResourceLimitFatalError,\n            \"MemoryAllocationFailed\",option);\n      node->data = (void *)cli_wand->wand.images;\n      node->next = cli_wand->image_list_stack;\n      cli_wand->image_list_stack = node;\n      cli_wand->wand.images = NewImageList();\n\n      \/* handle respect-parenthesis *\/\n      if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,\n                    \"respect-parenthesis\")) != MagickFalse)\n        option=\"{\"; \/* fall-thru so as to push image settings too *\/\n      else\n        break;\n      \/* fall thru to operation *\/\n    }\n    if (LocaleCompare(\"{\",option) == 0) {\n      \/* stack 'push' of image_info settings *\/\n      Stack\n        *node;\n\n      size_t\n        size;\n\n      size=0;\n      node=cli_wand->image_info_stack;\n      for ( ; node != (Stack *) NULL; node=node->next)\n        size++;\n      if ( size >= MAX_STACK_DEPTH )\n        CLIWandExceptionBreak(OptionError,\"CurlyBracesNestedTooDeeply\",option);\n      node=(Stack *) AcquireMagickMemory(sizeof(*node));\n      if (node == (Stack *) NULL)\n        CLIWandExceptionBreak(ResourceLimitFatalError,\n            \"MemoryAllocationFailed\",option);\n\n      node->data = (void *)cli_wand->wand.image_info;\n      node->next = cli_wand->image_info_stack;\n\n      cli_wand->image_info_stack = node;\n      cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);\n      if (cli_wand->wand.image_info == (ImageInfo *) NULL) {\n        CLIWandException(ResourceLimitFatalError,\"MemoryAllocationFailed\",\n            option);\n        cli_wand->wand.image_info = (ImageInfo *)node->data;\n        node = (Stack *)RelinquishMagickMemory(node);\n        break;\n      }\n\n      break;\n    }\n    if (LocaleCompare(\")\",option) == 0) {\n      \/* pop images from stack *\/\n      Stack\n        *node;\n\n      node = (Stack *)cli_wand->image_list_stack;\n      if ( node == (Stack *) NULL)\n        CLIWandExceptionBreak(OptionError,\"UnbalancedParenthesis\",option);\n      cli_wand->image_list_stack = node->next;\n\n      AppendImageToList((Image **)&node->data,cli_wand->wand.images);\n      cli_wand->wand.images= (Image *)node->data;\n      node = (Stack *)RelinquishMagickMemory(node);\n\n      \/* handle respect-parenthesis - of the previous 'pushed' settings *\/\n      node = cli_wand->image_info_stack;\n      if ( node != (Stack *) NULL)\n        {\n          if (IsStringTrue(GetImageOption(\n                cli_wand->wand.image_info,\"respect-parenthesis\")) != MagickFalse)\n            option=\"}\"; \/* fall-thru so as to pop image settings too *\/\n          else\n            break;\n        }\n      else\n        break;\n      \/* fall thru to next if *\/\n    }\n    if (LocaleCompare(\"}\",option) == 0) {\n      \/* pop image_info settings from stack *\/\n      Stack\n        *node;\n\n      node = (Stack *)cli_wand->image_info_stack;\n      if ( node == (Stack *) NULL)\n        CLIWandExceptionBreak(OptionError,\"UnbalancedCurlyBraces\",option);\n      cli_wand->image_info_stack = node->next;\n\n      (void) DestroyImageInfo(cli_wand->wand.image_info);\n      cli_wand->wand.image_info = (ImageInfo *)node->data;\n      node = (Stack *)RelinquishMagickMemory(node);\n\n      GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);\n      cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);\n      cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);\n\n      break;\n    }\n      if (LocaleCompare(\"print\",option+1) == 0)\n        {\n          (void) FormatLocaleFile(stdout,\"%s\",arg1);\n          break;\n        }\n    if (LocaleCompare(\"set\",option+1) == 0)\n      {\n        \/* Settings are applied to each image in memory in turn (if any).\n           While a option: only need to be applied once globally.\n\n           NOTE: rguments have not been automatically percent expaneded\n        *\/\n\n        \/* escape the 'key' once only, using first image. *\/\n        arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);\n        if (arg1 == (char *) NULL)\n          CLIWandExceptionBreak(OptionWarning,\"InterpretPropertyFailure\",\n                option);\n\n        if (LocaleNCompare(arg1,\"registry:\",9) == 0)\n          {\n            if (IfPlusOp)\n              {\n                (void) DeleteImageRegistry(arg1+9);\n                arg1=DestroyString((char *)arg1);\n                break;\n              }\n            arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n            if (arg2 == (char *) NULL) {\n              arg1=DestroyString((char *)arg1);\n              CLIWandExceptionBreak(OptionWarning,\"InterpretPropertyFailure\",\n                    option);\n            }\n            (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);\n            arg1=DestroyString((char *)arg1);\n            arg2=DestroyString((char *)arg2);\n            break;\n          }\n        if (LocaleNCompare(arg1,\"option:\",7) == 0)\n          {\n            \/* delete equivelent artifact from all images (if any) *\/\n            if (_images != (Image *) NULL)\n              {\n                MagickResetIterator(&cli_wand->wand);\n                while (MagickNextImage(&cli_wand->wand) != MagickFalse)\n                  (void) DeleteImageArtifact(_images,arg1+7);\n                MagickResetIterator(&cli_wand->wand);\n              }\n            \/* now set\/delete the global option as needed *\/\n            \/* FUTURE: make escapes in a global 'option:' delayed *\/\n            arg2=(char *) NULL;\n            if (IfNormalOp)\n              {\n                arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n                if (arg2 == (char *) NULL)\n                  CLIWandExceptionBreak(OptionWarning,\n                       \"InterpretPropertyFailure\",option);\n              }\n            (void) SetImageOption(_image_info,arg1+7,arg2);\n            arg1=DestroyString((char *)arg1);\n            arg2=DestroyString((char *)arg2);\n            break;\n          }\n        \/* Set Artifacts\/Properties\/Attributes all images (required) *\/\n        if ( _images == (Image *) NULL )\n          CLIWandExceptArgBreak(OptionWarning,\"NoImageForProperty\",option,arg1);\n\n        MagickResetIterator(&cli_wand->wand);\n        while (MagickNextImage(&cli_wand->wand) != MagickFalse)\n          {\n            arg2=(char *) NULL;\n            if (IfNormalOp)\n              {\n                arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);\n                if (arg2 == (char *) NULL)\n                  CLIWandExceptionBreak(OptionWarning,\n                       \"InterpretPropertyFailure\",option);\n              }\n            if (LocaleNCompare(arg1,\"artifact:\",9) == 0)\n              (void) SetImageArtifact(_images,arg1+9,arg2);\n            else if (LocaleNCompare(arg1,\"property:\",9) == 0)\n              (void) SetImageProperty(_images,arg1+9,arg2,_exception);\n            else\n              (void) SetImageProperty(_images,arg1,arg2,_exception);\n            arg2=DestroyString((char *)arg2);\n          }\n        MagickResetIterator(&cli_wand->wand);\n        arg1=DestroyString((char *)arg1);\n        break;\n     }\n    if (LocaleCompare(\"clone\",option+1) == 0) {\n        Image\n          *new_images;\n\n        if (*option == '+')\n          arg1=AcquireString(\"-1\");\n        if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)\n          CLIWandExceptionBreak(OptionError,\"InvalidArgument\",option);\n        if ( cli_wand->image_list_stack == (Stack *) NULL)\n          CLIWandExceptionBreak(OptionError,\"UnableToCloneImage\",option);\n        new_images = (Image *)cli_wand->image_list_stack->data;\n        if (new_images == (Image *) NULL)\n          CLIWandExceptionBreak(OptionError,\"UnableToCloneImage\",option);\n        new_images=CloneImages(new_images,arg1,_exception);\n        if (new_images == (Image *) NULL)\n          CLIWandExceptionBreak(OptionError,\"NoSuchImage\",option);\n        AppendImageToList(&_images,new_images);\n        break;\n      }\n    \/*\n       Informational Operations.\n\n       Note that these do not require either a cli-wand or images!\n       Though currently a cli-wand much be provided regardless.\n    *\/\n    if (LocaleCompare(\"version\",option+1) == 0)\n      {\n        ListMagickVersion(stdout);\n        break;\n      }\n    if (LocaleCompare(\"list\",option+1) == 0) {\n      \/*\n         FUTURE: This 'switch' should really be part of MagickCore\n      *\/\n      ssize_t\n        list;\n\n      list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);\n      if ( list < 0 ) {\n        CLIWandExceptionArg(OptionError,\"UnrecognizedListType\",option,arg1);\n        break;\n      }\n      switch (list)\n      {\n        case MagickCoderOptions:\n        {\n          (void) ListCoderInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickColorOptions:\n        {\n          (void) ListColorInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickConfigureOptions:\n        {\n          (void) ListConfigureInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickDelegateOptions:\n        {\n          (void) ListDelegateInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickFontOptions:\n        {\n          (void) ListTypeInfo((FILE *) NULL,_exception);\n          break;\n        }\n        case MagickFormatOptions:\n          (void) ListMagickInfo((FILE *) NULL,_exception);\n          break;\n        case MagickLocaleOptions:\n          (void) ListLocaleInfo((FILE *) NULL,_exception);\n          break;\n        case MagickLogOptions:\n          (void) ListLogInfo((FILE *) NULL,_exception);\n          break;\n        case MagickMagicOptions:\n          (void) ListMagicInfo((FILE *) NULL,_exception);\n          break;\n        case MagickMimeOptions:\n          (void) ListMimeInfo((FILE *) NULL,_exception);\n          break;\n        case MagickModuleOptions:\n          (void) ListModuleInfo((FILE *) NULL,_exception);\n          break;\n        case MagickPolicyOptions:\n          (void) ListPolicyInfo((FILE *) NULL,_exception);\n          break;\n        case MagickResourceOptions:\n          (void) ListMagickResourceInfo((FILE *) NULL,_exception);\n          break;\n        case MagickThresholdOptions:\n          (void) ListThresholdMaps((FILE *) NULL,_exception);\n          break;\n        default:\n          (void) ListCommandOptions((FILE *) NULL,(CommandOption) list,\n            _exception);\n          break;\n      }\n      break;\n    }\n\n    CLIWandException(OptionError,\"UnrecognizedOption\",option);\n\nDisableMSCWarning(4127)\n  } while (0);  \/* break to exit code. *\/\nRestoreMSCWarning\n\n  \/* clean up percent escape interpreted strings *\/\n  if (arg1 != arg1n )\n    arg1=DestroyString((char *)arg1);\n  if (arg2 != arg2n )\n    arg2=DestroyString((char *)arg2);\n\n#undef _image_info\n#undef _images\n#undef _exception\n#undef IfNormalOp\n#undef IfPlusOp\n}","target":0,"code_token_length":4120,"total_token_length":4356,"max_tokens_setting":6144}
+{"idx":445927,"func":"fr_window_construct (FrWindow *window)\n{\n\tGtkWidget          *toolbar;\n\tGtkWidget          *list_scrolled_window;\n\tGtkWidget          *location_box;\n\tGtkStatusbar       *statusbar;\n\tGtkWidget          *statusbar_box;\n\tGtkWidget          *filter_box;\n\tGtkWidget          *tree_scrolled_window;\n\tGtkTreeSelection   *selection;\n\tGtkActionGroup     *actions;\n\tGtkAction          *action;\n\tGtkAction          *other_actions_action;\n\tGtkUIManager       *ui;\n\tGtkSizeGroup       *toolbar_size_group;\n\tGError             *error = NULL;\n\tconst char * const *schemas;\n\n\t\/* Create the settings objects *\/\n\n\twindow->priv->settings_listing = g_settings_new (FILE_ROLLER_SCHEMA_LISTING);\n\twindow->priv->settings_ui = g_settings_new (FILE_ROLLER_SCHEMA_UI);\n\twindow->priv->settings_general = g_settings_new (FILE_ROLLER_SCHEMA_GENERAL);\n\twindow->priv->settings_dialogs = g_settings_new (FILE_ROLLER_SCHEMA_DIALOGS);\n\n\t\/* Only use the nautilus schema if it's installed *\/\n\tfor (schemas = g_settings_list_schemas ();\n\t     *schemas != NULL;\n\t     schemas++)\n\t{\n\t\tif (g_strcmp0 (*schemas, NAUTILUS_SCHEMA) == 0) {\n\t\t\twindow->priv->settings_nautilus = g_settings_new (NAUTILUS_SCHEMA);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* Create the application. *\/\n\n\twindow->priv->layout = gtk_grid_new ();\n\tgtk_container_add (GTK_CONTAINER (window), window->priv->layout);\n\tgtk_widget_show (window->priv->layout);\n\n\tgtk_window_set_title (GTK_WINDOW (window), _(\"Archive Manager\"));\n\tgtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE);\n\n\tg_signal_connect (G_OBJECT (window),\n\t\t\t  \"delete_event\",\n\t\t\t  G_CALLBACK (fr_window_delete_event_cb),\n\t\t\t  window);\n\n\tg_signal_connect (G_OBJECT (window),\n\t\t\t  \"show\",\n\t\t\t  G_CALLBACK (fr_window_show_cb),\n\t\t\t  window);\n\n\twindow->priv->theme_changed_handler_id =\n\t\tg_signal_connect (gtk_icon_theme_get_default (),\n\t\t\t\t  \"changed\",\n\t\t\t\t  G_CALLBACK (theme_changed_cb),\n\t\t\t\t  window);\n\n\tgtk_window_set_default_size (GTK_WINDOW (window),\n\t\t\t\t     g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH),\n\t\t\t\t     g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT));\n\n\tgtk_drag_dest_set (GTK_WIDGET (window),\n\t\t\t   GTK_DEST_DEFAULT_ALL,\n\t\t\t   target_table, G_N_ELEMENTS (target_table),\n\t\t\t   GDK_ACTION_COPY);\n\n\tg_signal_connect (G_OBJECT (window),\n\t\t\t  \"drag_data_received\",\n\t\t\t  G_CALLBACK (fr_window_drag_data_received),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window),\n\t\t\t  \"drag_motion\",\n\t\t\t  G_CALLBACK (fr_window_drag_motion),\n\t\t\t  window);\n\n\tg_signal_connect (G_OBJECT (window),\n\t\t\t  \"key_press_event\",\n\t\t\t  G_CALLBACK (key_press_cb),\n\t\t\t  window);\n\n\t\/* Initialize Data. *\/\n\n\twindow->priv->list_mode = window->priv->last_list_mode = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE);\n\tg_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH, (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT));\n\n\twindow->priv->history = NULL;\n\twindow->priv->history_current = NULL;\n\n\twindow->priv->action = FR_ACTION_NONE;\n\n\twindow->priv->open_default_dir = g_object_ref (_g_file_get_home ());\n\twindow->priv->add_default_dir = NULL;\n\twindow->priv->extract_default_dir = g_object_ref (_g_file_get_home ());\n\n\twindow->priv->give_focus_to_the_list = FALSE;\n\n\twindow->priv->activity_ref = 0;\n\twindow->priv->activity_timeout_handle = 0;\n\n\twindow->priv->update_timeout_handle = 0;\n\n\twindow->priv->archive_present = FALSE;\n\twindow->priv->archive_new = FALSE;\n\twindow->priv->reload_archive = FALSE;\n\twindow->priv->archive_file = NULL;\n\n\twindow->priv->drag_destination_folder = NULL;\n\twindow->priv->drag_base_dir = NULL;\n\twindow->priv->drag_error = NULL;\n\twindow->priv->drag_file_list = NULL;\n\n\twindow->priv->batch_mode = FALSE;\n\twindow->priv->batch_action_list = NULL;\n\twindow->priv->batch_action = NULL;\n\twindow->priv->extract_interact_use_default_dir = FALSE;\n\n\twindow->priv->password = NULL;\n\twindow->priv->compression = g_settings_get_enum (window->priv->settings_general, PREF_GENERAL_COMPRESSION_LEVEL);\n\twindow->priv->encrypt_header = g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_ENCRYPT_HEADER);\n\twindow->priv->volume_size = 0;\n\n\twindow->priv->stoppable = TRUE;\n\n\twindow->priv->batch_adding_one_file = FALSE;\n\n\twindow->priv->path_clicked = NULL;\n\n\twindow->priv->current_view_length = 0;\n\n\twindow->priv->current_batch_action.type = FR_BATCH_ACTION_NONE;\n\twindow->priv->current_batch_action.data = NULL;\n\twindow->priv->current_batch_action.free_func = NULL;\n\n\twindow->priv->pd_last_archive = NULL;\n\twindow->priv->pd_last_message = NULL;\n\twindow->priv->pd_last_fraction = 0.0;\n\n\t\/* Create the widgets. *\/\n\n\t\/* * File list. *\/\n\n\twindow->priv->list_store = fr_list_model_new (NUMBER_OF_COLUMNS,\n\t\t\t\t\t\t      G_TYPE_POINTER,\n\t\t\t\t\t\t      GDK_TYPE_PIXBUF,\n\t\t\t\t\t\t      G_TYPE_STRING,\n\t\t\t\t\t\t      GDK_TYPE_PIXBUF,\n\t\t\t\t\t\t      G_TYPE_STRING,\n\t\t\t\t\t\t      G_TYPE_STRING,\n\t\t\t\t\t\t      G_TYPE_STRING,\n\t\t\t\t\t\t      G_TYPE_STRING);\n\tg_object_set_data (G_OBJECT (window->priv->list_store), \"FrWindow\", window);\n\twindow->priv->list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->list_store));\n\n\tgtk_tree_view_set_rules_hint (GTK_TREE_VIEW (window->priv->list_view), TRUE);\n\tadd_file_list_columns (window, GTK_TREE_VIEW (window->priv->list_view));\n\tgtk_tree_view_set_enable_search (GTK_TREE_VIEW (window->priv->list_view),\n\t\t\t\t\t TRUE);\n\tgtk_tree_view_set_search_column (GTK_TREE_VIEW (window->priv->list_view),\n\t\t\t\t\t COLUMN_NAME);\n\n\tgtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t FR_WINDOW_SORT_BY_NAME, name_column_sort_func,\n\t\t\t\t\t NULL, NULL);\n\tgtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t FR_WINDOW_SORT_BY_SIZE, size_column_sort_func,\n\t\t\t\t\t NULL, NULL);\n\tgtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t FR_WINDOW_SORT_BY_TYPE, type_column_sort_func,\n\t\t\t\t\t NULL, NULL);\n\tgtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t FR_WINDOW_SORT_BY_TIME, time_column_sort_func,\n\t\t\t\t\t NULL, NULL);\n\tgtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t FR_WINDOW_SORT_BY_PATH, path_column_sort_func,\n\t\t\t\t\t NULL, NULL);\n\n\tselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view));\n\tgtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);\n\n\tg_signal_connect (selection,\n\t\t\t  \"changed\",\n\t\t\t  G_CALLBACK (selection_changed_cb),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"row_activated\",\n\t\t\t  G_CALLBACK (row_activated_cb),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"button_press_event\",\n\t\t\t  G_CALLBACK (file_button_press_cb),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"button_release_event\",\n\t\t\t  G_CALLBACK (file_button_release_cb),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"motion_notify_event\",\n\t\t\t  G_CALLBACK (file_motion_notify_callback),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"leave_notify_event\",\n\t\t\t  G_CALLBACK (file_leave_notify_callback),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"drag_begin\",\n\t\t\t  G_CALLBACK (file_list_drag_begin),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->list_view),\n\t\t\t  \"drag_end\",\n\t\t\t  G_CALLBACK (file_list_drag_end),\n\t\t\t  window);\n\tegg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (window->priv->list_view));\n\n\tlist_scrolled_window = gtk_scrolled_window_new (NULL, NULL);\n\tgtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_scrolled_window),\n\t\t\t\t\tGTK_POLICY_AUTOMATIC,\n\t\t\t\t\tGTK_POLICY_AUTOMATIC);\n\tgtk_container_add (GTK_CONTAINER (list_scrolled_window), window->priv->list_view);\n\n\t\/* filter bar *\/\n\n\twindow->priv->filter_bar = filter_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);\n\tg_object_set (window->priv->filter_bar,\n\t\t      \"halign\", GTK_ALIGN_CENTER,\n\t\t      \"margin-left\", 6,\n\t\t      \"border-width\", 3,\n\t\t      NULL);\n\tfr_window_attach (FR_WINDOW (window), window->priv->filter_bar, FR_WINDOW_AREA_FILTERBAR);\n\n\t\/* * filter entry *\/\n\n\twindow->priv->filter_entry = GTK_WIDGET (gtk_entry_new ());\n\tgtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->filter_entry),\n\t\t\t\t\t   GTK_ENTRY_ICON_SECONDARY,\n\t\t\t\t\t   \"edit-find-symbolic\");\n\tgtk_entry_set_icon_activatable (GTK_ENTRY (window->priv->filter_entry),\n\t\t\t\t\tGTK_ENTRY_ICON_SECONDARY,\n\t\t\t\t\tFALSE);\n\tgtk_entry_set_width_chars (GTK_ENTRY (window->priv->filter_entry), 40);\n\tgtk_box_pack_start (GTK_BOX (filter_box),\n\t\t\t    window->priv->filter_entry, FALSE, FALSE, 6);\n\n\tg_signal_connect (G_OBJECT (window->priv->filter_entry),\n\t\t\t  \"activate\",\n\t\t\t  G_CALLBACK (filter_entry_activate_cb),\n\t\t\t  window);\n\n\tgtk_widget_show_all (filter_box);\n\n\t\/* tree view *\/\n\n\twindow->priv->tree_store = gtk_tree_store_new (TREE_NUMBER_OF_COLUMNS,\n\t\t\t\t\t\t       G_TYPE_STRING,\n\t\t\t\t\t\t       GDK_TYPE_PIXBUF,\n\t\t\t\t\t\t       G_TYPE_STRING,\n\t\t\t\t\t\t       PANGO_TYPE_WEIGHT);\n\twindow->priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->tree_store));\n\tgtk_tree_view_set_headers_visible (GTK_TREE_VIEW (window->priv->tree_view), FALSE);\n\tadd_dir_tree_columns (window, GTK_TREE_VIEW (window->priv->tree_view));\n\n\tg_signal_connect (G_OBJECT (window->priv->tree_view),\n\t\t\t  \"button_press_event\",\n\t\t\t  G_CALLBACK (dir_tree_button_press_cb),\n\t\t\t  window);\n\n\tselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view));\n\tg_signal_connect (selection,\n\t\t\t  \"changed\",\n\t\t\t  G_CALLBACK (dir_tree_selection_changed_cb),\n\t\t\t  window);\n\n\tg_signal_connect (G_OBJECT (window->priv->tree_view),\n\t\t\t  \"drag_begin\",\n\t\t\t  G_CALLBACK (file_list_drag_begin),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->tree_view),\n\t\t\t  \"drag_end\",\n\t\t\t  G_CALLBACK (file_list_drag_end),\n\t\t\t  window);\n\tg_signal_connect (G_OBJECT (window->priv->tree_view),\n\t\t\t  \"drag_data_get\",\n\t\t\t  G_CALLBACK (fr_window_folder_tree_drag_data_get),\n\t\t\t  window);\n\tgtk_drag_source_set (window->priv->tree_view,\n\t\t\t     GDK_BUTTON1_MASK,\n\t\t\t     folder_tree_targets, G_N_ELEMENTS (folder_tree_targets),\n\t\t\t     GDK_ACTION_COPY);\n\n\ttree_scrolled_window = gtk_scrolled_window_new (NULL, NULL);\n\tgtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tree_scrolled_window),\n\t\t\t\t\tGTK_POLICY_AUTOMATIC,\n\t\t\t\t\tGTK_POLICY_AUTOMATIC);\n\tgtk_container_add (GTK_CONTAINER (tree_scrolled_window), window->priv->tree_view);\n\n\t\/* side pane *\/\n\n\twindow->priv->sidepane = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);\n\tgtk_box_pack_start (GTK_BOX (window->priv->sidepane), tree_scrolled_window, TRUE, TRUE, 0);\n\n\t\/* main content *\/\n\n\twindow->priv->paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);\n\tgtk_paned_pack1 (GTK_PANED (window->priv->paned), window->priv->sidepane, FALSE, TRUE);\n\tgtk_paned_pack2 (GTK_PANED (window->priv->paned), list_scrolled_window, TRUE, TRUE);\n\tgtk_paned_set_position (GTK_PANED (window->priv->paned), g_settings_get_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH));\n\n\tfr_window_attach (FR_WINDOW (window), window->priv->paned, FR_WINDOW_AREA_CONTENTS);\n\tgtk_widget_show_all (window->priv->paned);\n\n\t\/* Build the menu and the toolbar. *\/\n\n\tui = gtk_ui_manager_new ();\n\n\twindow->priv->actions = actions = gtk_action_group_new (\"Actions\");\n\n\t\/* open recent menu item action  *\/\n\n\taction = g_object_new (GTK_TYPE_RECENT_ACTION,\n\t\t\t       \"name\", \"OpenRecent\",\n\t\t\t       \/* Translators: this is the label for the \"open recent file\" sub-menu. *\/\n\t\t\t       \"label\", _(\"Open _Recent\"),\n\t\t\t       \"tooltip\", _(\"Open a recently used archive\"),\n\t\t\t       \"stock-id\", GTK_STOCK_OPEN,\n\t\t\t       NULL);\n\tfr_window_init_recent_chooser (window, GTK_RECENT_CHOOSER (action));\n\tgtk_action_group_add_action (actions, action);\n\tg_object_unref (action);\n\n\t\/* open recent toolbar item action  *\/\n\n\taction = g_object_new (GTK_TYPE_RECENT_ACTION,\n\t\t\t       \"name\", \"OpenRecent_Toolbar\",\n\t\t\t       \"label\", _(\"Open\"),\n\t\t\t       \"tooltip\", _(\"Open a recently used archive\"),\n\t\t\t       \"stock-id\", GTK_STOCK_OPEN,\n\t\t\t       \"is-important\", TRUE,\n\t\t\t       NULL);\n\tfr_window_init_recent_chooser (window, GTK_RECENT_CHOOSER (action));\n\tg_signal_connect (action,\n\t\t\t  \"activate\",\n\t\t\t  G_CALLBACK (activate_action_open),\n\t\t\t  window);\n\tgtk_action_group_add_action (actions, action);\n\tg_object_unref (action);\n\n\t\/* menu actions *\/\n\n\tother_actions_action = action = g_object_new (GTH_TYPE_TOGGLE_MENU_ACTION,\n\t\t\t       \"name\", \"OtherActions\",\n\t\t\t       \"label\", _(\"_Other Actions\"),\n\t\t\t       \"tooltip\", _(\"Other actions\"),\n\t\t\t       \"menu-halign\", GTK_ALIGN_CENTER,\n\t\t\t       \"show-arrow\", TRUE,\n\t\t\t       NULL);\n\tgtk_action_group_add_action (actions, action);\n\n\t\/* other actions *\/\n\n\tgtk_action_group_set_translation_domain (actions, NULL);\n\tgtk_action_group_add_actions (actions,\n\t\t\t\t      action_entries,\n\t\t\t\t      n_action_entries,\n\t\t\t\t      window);\n\tgtk_action_group_add_toggle_actions (actions,\n\t\t\t\t\t     action_toggle_entries,\n\t\t\t\t\t     n_action_toggle_entries,\n\t\t\t\t\t     window);\n\tgtk_action_group_add_radio_actions (actions,\n\t\t\t\t\t    view_as_entries,\n\t\t\t\t\t    n_view_as_entries,\n\t\t\t\t\t    window->priv->list_mode,\n\t\t\t\t\t    G_CALLBACK (view_as_radio_action),\n\t\t\t\t\t    window);\n\n\tg_signal_connect (ui, \"connect_proxy\",\n\t\t\t  G_CALLBACK (connect_proxy_cb), window);\n\tg_signal_connect (ui, \"disconnect_proxy\",\n\t\t\t  G_CALLBACK (disconnect_proxy_cb), window);\n\n\tgtk_ui_manager_insert_action_group (ui, actions, 0);\n\tgtk_window_add_accel_group (GTK_WINDOW (window),\n\t\t\t\t    gtk_ui_manager_get_accel_group (ui));\n\n\t\/* Add a hidden short cut Ctrl-Q for power users *\/\n\tgtk_accel_group_connect (gtk_ui_manager_get_accel_group (ui),\n\t\t\t\t GDK_KEY_q, GDK_CONTROL_MASK, 0,\n\t\t\t\t g_cclosure_new_swap (G_CALLBACK (fr_window_close), window, NULL));\n\n\tif (! gtk_ui_manager_add_ui_from_resource (ui, \"\/org\/gnome\/FileRoller\/ui\/menus-toolbars.ui\", &error)) {\n\t\tg_message (\"building menus failed: %s\", error->message);\n\t\tg_error_free (error);\n\t}\n\n\tg_object_set (other_actions_action, \"menu\", gtk_ui_manager_get_widget (ui, \"\/OtherActionsMenu\"), NULL);\n\tg_object_unref (other_actions_action);\n\n\twindow->priv->toolbar = toolbar = gtk_ui_manager_get_widget (ui, \"\/ToolBar\");\n\tgtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);\n\tgtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR);\n\tset_action_important (ui, \"\/ToolBar\/Extract_Toolbar\");\n\tset_action_important (ui, \"\/ToolBar\/Add_Toolbar\");\n\n\t\/* location bar *\/\n\n\twindow->priv->location_bar = gtk_ui_manager_get_widget (ui, \"\/LocationBar\");\n\tgtk_toolbar_set_show_arrow (GTK_TOOLBAR (window->priv->location_bar), FALSE);\n\tgtk_toolbar_set_style (GTK_TOOLBAR (window->priv->location_bar), GTK_TOOLBAR_BOTH_HORIZ);\n\tgtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar), GTK_STYLE_CLASS_TOOLBAR);\n\tset_action_important (ui, \"\/LocationBar\/GoBack\");\n\n\t\/* current location *\/\n\n\tlocation_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);\n\t\/* Translators: after the colon there is a folder name. *\/\n\twindow->priv->location_label = gtk_label_new_with_mnemonic (_(\"_Location:\"));\n\tgtk_box_pack_start (GTK_BOX (location_box),\n\t\t\t    window->priv->location_label, FALSE, FALSE, 5);\n\n\twindow->priv->location_entry = gtk_entry_new ();\n\tgtk_entry_set_icon_from_stock (GTK_ENTRY (window->priv->location_entry),\n\t\t\t\t       GTK_ENTRY_ICON_PRIMARY,\n\t\t\t\t       GTK_STOCK_DIRECTORY);\n\n\tgtk_box_pack_start (GTK_BOX (location_box),\n\t\t\t    window->priv->location_entry, TRUE, TRUE, 5);\n\n\tg_signal_connect (G_OBJECT (window->priv->location_entry),\n\t\t\t  \"key_press_event\",\n\t\t\t  G_CALLBACK (location_entry_key_press_event_cb),\n\t\t\t  window);\n\n\t{\n\t\tGtkToolItem *tool_item;\n\n\t\ttool_item = gtk_separator_tool_item_new ();\n\t\tgtk_widget_show_all (GTK_WIDGET (tool_item));\n\t\tgtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar), tool_item, -1);\n\n\t\ttool_item = gtk_tool_item_new ();\n\t\tgtk_tool_item_set_expand (tool_item, TRUE);\n\t\tgtk_container_add (GTK_CONTAINER (tool_item), location_box);\n\t\tgtk_widget_show_all (GTK_WIDGET (tool_item));\n\t\tgtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar), tool_item, -1);\n\t}\n\n\tfr_window_attach (FR_WINDOW (window), window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR);\n\tif (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)\n\t\tgtk_widget_hide (window->priv->location_bar);\n\telse\n\t\tgtk_widget_show (window->priv->location_bar);\n\n\t\/**\/\n\n\tfr_window_attach (FR_WINDOW (window), window->priv->toolbar, FR_WINDOW_AREA_TOOLBAR);\n\tgtk_widget_show (toolbar);\n\n\twindow->priv->file_popup_menu = gtk_ui_manager_get_widget (ui, \"\/FilePopupMenu\");\n\twindow->priv->folder_popup_menu = gtk_ui_manager_get_widget (ui, \"\/FolderPopupMenu\");\n\twindow->priv->sidebar_folder_popup_menu = gtk_ui_manager_get_widget (ui, \"\/SidebarFolderPopupMenu\");\n\n\t\/* Create the statusbar. *\/\n\n\twindow->priv->statusbar = gtk_statusbar_new ();\n\twindow->priv->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), \"help_message\");\n\twindow->priv->list_info_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), \"list_info\");\n\twindow->priv->progress_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), \"progress\");\n\n\tstatusbar = GTK_STATUSBAR (window->priv->statusbar);\n\tstatusbar_box = gtk_statusbar_get_message_area (statusbar);\n\tgtk_box_set_homogeneous (GTK_BOX (statusbar_box), FALSE);\n\tgtk_box_set_spacing (GTK_BOX (statusbar_box), 4);\n\tgtk_box_set_child_packing (GTK_BOX (statusbar_box), gtk_statusbar_get_message_area (statusbar), TRUE, TRUE, 0, GTK_PACK_START );\n\n\twindow->priv->progress_bar = gtk_progress_bar_new ();\n\tgtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->progress_bar), ACTIVITY_PULSE_STEP);\n\tgtk_widget_set_size_request (window->priv->progress_bar, -1, PROGRESS_BAR_HEIGHT);\n\t{\n\t\tGtkWidget *vbox;\n\n\t\tvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);\n\t\tgtk_box_pack_start (GTK_BOX (statusbar_box), vbox, FALSE, FALSE, 0);\n\t\tgtk_box_pack_start (GTK_BOX (vbox), window->priv->progress_bar, TRUE, TRUE, 1);\n\t\tgtk_widget_show (vbox);\n\t}\n\tgtk_widget_show (statusbar_box);\n\n\tfr_window_attach (FR_WINDOW (window), window->priv->statusbar, FR_WINDOW_AREA_STATUSBAR);\n\tif (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR))\n\t\tgtk_widget_show (window->priv->statusbar);\n\telse\n\t\tgtk_widget_hide (window->priv->statusbar);\n\n\t\/**\/\n\n\ttoolbar_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);\n\tgtk_size_group_add_widget (toolbar_size_group, window->priv->location_bar);\n\tgtk_size_group_add_widget (toolbar_size_group, window->priv->filter_bar);\n\n\t\/**\/\n\n\tfr_window_update_title (window);\n\tfr_window_update_sensitivity (window);\n\tfr_window_update_current_location (window);\n\tfr_window_update_columns_visibility (window);\n\n\t\/* Add notification callbacks. *\/\n\n\tg_signal_connect (window->priv->settings_ui,\n\t\t\t  \"changed::\" PREF_UI_HISTORY_LEN,\n\t\t\t  G_CALLBACK (pref_history_len_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_ui,\n\t\t\t  \"changed::\" PREF_UI_VIEW_STATUSBAR,\n\t\t\t  G_CALLBACK (pref_view_statusbar_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_ui,\n\t\t\t  \"changed::\" PREF_UI_VIEW_FOLDERS,\n\t\t\t  G_CALLBACK (pref_view_folders_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_listing,\n\t\t\t  \"changed::\" PREF_LISTING_SHOW_TYPE,\n\t\t\t  G_CALLBACK (pref_show_field_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_listing,\n\t\t\t  \"changed::\" PREF_LISTING_SHOW_SIZE,\n\t\t\t  G_CALLBACK (pref_show_field_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_listing,\n\t\t\t  \"changed::\" PREF_LISTING_SHOW_TIME,\n\t\t\t  G_CALLBACK (pref_show_field_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_listing,\n\t\t\t  \"changed::\" PREF_LISTING_SHOW_PATH,\n\t\t\t  G_CALLBACK (pref_show_field_changed),\n\t\t\t  window);\n\tg_signal_connect (window->priv->settings_listing,\n\t\t\t  \"changed::\" PREF_LISTING_LIST_MODE,\n\t\t\t  G_CALLBACK (pref_list_mode_changed),\n\t\t\t  window);\n\n\tif (window->priv->settings_nautilus)\n\t\tg_signal_connect (window->priv->settings_nautilus,\n\t\t\t\t  \"changed::\" NAUTILUS_CLICK_POLICY,\n\t\t\t\t  G_CALLBACK (pref_click_policy_changed),\n\t\t\t\t  window);\n\n\t\/* Give focus to the list. *\/\n\n\tgtk_widget_grab_focus (window->priv->list_view);\n}","target":0,"code_token_length":4838,"total_token_length":5074,"max_tokens_setting":6144}
+{"idx":265056,"func":"putpromptchar(int doprint, int endchar, zattr *txtchangep)\n{\n    char *ss, *hostnam;\n    int t0, arg, test, sep, j, numjobs, len;\n    zattr atr;\n    struct tm *tm;\n    struct timespec ts;\n    time_t timet;\n    Nameddir nd;\n\n    for (; *bv->fm && *bv->fm != endchar; bv->fm++) {\n\targ = 0;\n\tif (*bv->fm == '%' && isset(PROMPTPERCENT)) {\n\t    int minus = 0;\n\t    bv->fm++;\n\t    if (*bv->fm == '-') {\n\t\tminus = 1;\n\t\tbv->fm++;\n\t    }\n\t    if (idigit(*bv->fm)) {\n\t\targ = zstrtol(bv->fm, &bv->fm, 10);\n\t\tif (minus)\n\t\t    arg *= -1;\n\t    } else if (minus)\n\t\targ = -1;\n\t    if (*bv->fm == '(') {\n\t\tint tc, otruncwidth;\n\n\t\tif (idigit(*++bv->fm)) {\n\t\t    arg = zstrtol(bv->fm, &bv->fm, 10);\n\t\t} else if (arg < 0) {\n\t\t    \/* negative numbers don't make sense here *\/\n\t\t    arg *= -1;\n\t\t}\n\t\ttest = 0;\n\t\tss = pwd;\n\t\tswitch (tc = *bv->fm) {\n\t\tcase 'c':\n\t\tcase '.':\n\t\tcase '~':\n\t\t    if ((nd = finddir(ss))) {\n\t\t\targ--;\n\t\t\tss += strlen(nd->dir);\n\t\t    } \/*FALLTHROUGH*\/\n\t\tcase '\/':\n\t\tcase 'C':\n\t\t    \/* `\/' gives 0, `\/any' gives 1, etc. *\/\n\t\t    if (*ss && *ss++ == '\/' && *ss)\n\t\t\targ--;\n\t\t    for (; *ss; ss++)\n\t\t\tif (*ss == '\/')\n\t\t\t    arg--;\n\t\t    if (arg <= 0)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 't':\n\t\tcase 'T':\n\t\tcase 'd':\n\t\tcase 'D':\n\t\tcase 'w':\n\t\t    timet = time(NULL);\n\t\t    tm = localtime(&timet);\n\t\t    switch (tc) {\n\t\t    case 't':\n\t\t\ttest = (arg == tm->tm_min);\n\t\t\tbreak;\n\t\t    case 'T':\n\t\t\ttest = (arg == tm->tm_hour);\n\t\t\tbreak;\n\t\t    case 'd':\n\t\t\ttest = (arg == tm->tm_mday);\n\t\t\tbreak;\n\t\t    case 'D':\n\t\t\ttest = (arg == tm->tm_mon);\n\t\t\tbreak;\n\t\t    case 'w':\n\t\t\ttest = (arg == tm->tm_wday);\n\t\t\tbreak;\n\t\t    }\n\t\t    break;\n\t\tcase '?':\n\t\t    if (lastval == arg)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase '#':\n\t\t    if (geteuid() == (uid_t)arg)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 'g':\n\t\t    if (getegid() == (gid_t)arg)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 'j':\n\t\t    for (numjobs = 0, j = 1; j <= maxjob; j++)\n\t\t\tif (jobtab[j].stat && jobtab[j].procs &&\n\t\t    \t    !(jobtab[j].stat & STAT_NOPRINT)) numjobs++;\n\t\t    if (numjobs >= arg)\n\t\t    \ttest = 1;\n\t\t    break;\n\t\tcase 'l':\n\t\t    *bv->bp = '\\0';\n\t\t    countprompt(bv->bufline, &t0, 0, 0);\n\t\t    if (minus)\n\t\t\tt0 = zterm_columns - t0;\n\t\t    if (t0 >= arg)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 'e':\n\t\t    {\n\t\t\tFuncstack fsptr = funcstack;\n\t\t\ttest = arg;\n\t\t\twhile (fsptr && test > 0) {\n\t\t\t    test--;\n\t\t\t    fsptr = fsptr->prev;\n\t\t\t}\n\t\t\ttest = !test;\n\t\t    }\n\t\t    break;\n\t\tcase 'L':\n\t\t    if (shlvl >= arg)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 'S':\n\t\t    if (time(NULL) - shtimer.tv_sec >= arg)\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 'v':\n\t\t    if (arrlen_ge(psvar, arg))\n\t\t\ttest = 1;\n\t\t    break;\n\t\tcase 'V':\n\t\t    if (psvar && *psvar && arrlen_ge(psvar, arg)) {\n\t\t\tif (*psvar[(arg ? arg : 1) - 1])\n\t\t\t    test = 1;\n\t\t    }\n\t\t    break;\n\t\tcase '_':\n\t\t    test = (cmdsp >= arg);\n\t\t    break;\n\t\tcase '!':\n\t\t    test = privasserted();\n\t\t    break;\n\t\tdefault:\n\t\t    test = -1;\n\t\t    break;\n\t\t}\n\t\tif (!*bv->fm || !(sep = *++bv->fm))\n\t\t    return 0;\n\t\tbv->fm++;\n\t\t\/* Don't do the current truncation until we get back *\/\n\t\totruncwidth = bv->truncwidth;\n\t\tbv->truncwidth = 0;\n\t\tif (!putpromptchar(test == 1 && doprint, sep,\n\t\t\t\t   txtchangep) || !*++bv->fm ||\n\t\t    !putpromptchar(test == 0 && doprint, ')',\n\t\t\t\t   txtchangep)) {\n\t\t    bv->truncwidth = otruncwidth;\n\t\t    return 0;\n\t\t}\n\t\tbv->truncwidth = otruncwidth;\n\t\tcontinue;\n\t    }\n\t    if (!doprint)\n\t\tswitch(*bv->fm) {\n\t\t  case '[':\n\t\t    while(idigit(*++bv->fm));\n\t\t    while(*++bv->fm != ']');\n\t\t    continue;\n\t\t  case '<':\n\t\t    while(*++bv->fm != '<');\n\t\t    continue;\n\t\t  case '>':\n\t\t    while(*++bv->fm != '>');\n\t\t    continue;\n\t\t  case 'D':\n\t\t    if(bv->fm[1]=='{')\n\t\t\twhile(*++bv->fm != '}');\n\t\t    continue;\n\t\t  default:\n\t\t    continue;\n\t\t}\n\t    switch (*bv->fm) {\n\t    case '~':\n\t\tpromptpath(pwd, arg, 1);\n\t\tbreak;\n\t    case 'd':\n\t    case '\/':\n\t\tpromptpath(pwd, arg, 0);\n\t\tbreak;\n\t    case 'c':\n\t    case '.':\n\t\tpromptpath(pwd, arg ? arg : 1, 1);\n\t\tbreak;\n\t    case 'C':\n\t\tpromptpath(pwd, arg ? arg : 1, 0);\n\t\tbreak;\n\t    case 'N':\n\t\tpromptpath(scriptname ? scriptname : argzero, arg, 0);\n\t\tbreak;\n\t    case 'h':\n\t    case '!':\n\t\taddbufspc(DIGBUFSIZE);\n\t\tconvbase(bv->bp, curhist, 10);\n\t\tbv->bp += strlen(bv->bp);\n\t\tbreak;\n\t    case 'j':\n\t\tfor (numjobs = 0, j = 1; j <= maxjob; j++)\n\t\t    if (jobtab[j].stat && jobtab[j].procs &&\n\t\t    \t!(jobtab[j].stat & STAT_NOPRINT)) numjobs++;\n\t\taddbufspc(DIGBUFSIZE);\n\t\tsprintf(bv->bp, \"%d\", numjobs);\n\t\tbv->bp += strlen(bv->bp);\n\t\tbreak;\n\t    case 'M':\n\t\tqueue_signals();\n\t\tif ((hostnam = getsparam(\"HOST\")))\n\t\t    stradd(hostnam);\n\t\tunqueue_signals();\n\t\tbreak;\n\t    case 'm':\n\t\tif (!arg)\n\t\t    arg++;\n\t\tqueue_signals();\n\t\tif (!(hostnam = getsparam(\"HOST\"))) {\n\t\t    unqueue_signals();\n\t\t    break;\n\t\t}\n\t\tif (arg < 0) {\n\t\t    for (ss = hostnam + strlen(hostnam); ss > hostnam; ss--)\n\t\t\tif (ss[-1] == '.' && !++arg)\n\t\t\t    break;\n\t\t    stradd(ss);\n\t\t} else {\n\t\t    for (ss = hostnam; *ss; ss++)\n\t\t\tif (*ss == '.' && !--arg)\n\t\t\t    break;\n\t\t    stradd(*ss ? dupstrpfx(hostnam, ss - hostnam) : hostnam);\n\t\t}\n\t\tunqueue_signals();\n\t\tbreak;\n\t    case 'S':\n\t\ttxtchangeset(txtchangep, TXTSTANDOUT, TXTNOSTANDOUT);\n\t\ttxtset(TXTSTANDOUT);\n\t\ttsetcap(TCSTANDOUTBEG, TSC_PROMPT);\n\t\tbreak;\n\t    case 's':\n\t\ttxtchangeset(txtchangep, TXTNOSTANDOUT, TXTSTANDOUT);\n\t\ttxtunset(TXTSTANDOUT);\n\t\ttsetcap(TCSTANDOUTEND, TSC_PROMPT|TSC_DIRTY);\n\t\tbreak;\n\t    case 'B':\n\t\ttxtchangeset(txtchangep, TXTBOLDFACE, TXTNOBOLDFACE);\n\t\ttxtset(TXTBOLDFACE);\n\t\ttsetcap(TCBOLDFACEBEG, TSC_PROMPT|TSC_DIRTY);\n\t\tbreak;\n\t    case 'b':\n\t\ttxtchangeset(txtchangep, TXTNOBOLDFACE, TXTBOLDFACE);\n\t\ttxtunset(TXTBOLDFACE);\n\t\ttsetcap(TCALLATTRSOFF, TSC_PROMPT|TSC_DIRTY);\n\t\tbreak;\n\t    case 'U':\n\t\ttxtchangeset(txtchangep, TXTUNDERLINE, TXTNOUNDERLINE);\n\t\ttxtset(TXTUNDERLINE);\n\t\ttsetcap(TCUNDERLINEBEG, TSC_PROMPT);\n\t\tbreak;\n\t    case 'u':\n\t\ttxtchangeset(txtchangep, TXTNOUNDERLINE, TXTUNDERLINE);\n\t\ttxtunset(TXTUNDERLINE);\n\t\ttsetcap(TCUNDERLINEEND, TSC_PROMPT|TSC_DIRTY);\n\t\tbreak;\n\t    case 'F':\n\t\tatr = parsecolorchar(arg, 1);\n\t\tif (!(atr & (TXT_ERROR | TXTNOFGCOLOUR))) {\n\t\t    txtchangeset(txtchangep, atr & TXT_ATTR_FG_ON_MASK,\n\t\t\t\t TXTNOFGCOLOUR | TXT_ATTR_FG_COL_MASK);\n\t\t    txtunset(TXT_ATTR_FG_COL_MASK);\n\t\t    txtset(atr & TXT_ATTR_FG_ON_MASK);\n\t\t    set_colour_attribute(atr, COL_SEQ_FG, TSC_PROMPT);\n\t\t    break;\n\t\t}\n\t\t\/* else FALLTHROUGH *\/\n\t    case 'f':\n\t\ttxtchangeset(txtchangep, TXTNOFGCOLOUR, TXT_ATTR_FG_ON_MASK);\n\t\ttxtunset(TXT_ATTR_FG_ON_MASK);\n\t\tset_colour_attribute(TXTNOFGCOLOUR, COL_SEQ_FG, TSC_PROMPT);\n\t\tbreak;\n\t    case 'K':\n\t\tatr = parsecolorchar(arg, 0);\n\t\tif (!(atr & (TXT_ERROR | TXTNOBGCOLOUR))) {\n\t\t    txtchangeset(txtchangep, atr & TXT_ATTR_BG_ON_MASK,\n\t\t\t\t TXTNOBGCOLOUR | TXT_ATTR_BG_COL_MASK);\n\t\t    txtunset(TXT_ATTR_BG_COL_MASK);\n\t\t    txtset(atr & TXT_ATTR_BG_ON_MASK);\n\t\t    set_colour_attribute(atr, COL_SEQ_BG, TSC_PROMPT);\n\t\t    break;\n\t\t}\n\t\t\/* else FALLTHROUGH *\/\n\t    case 'k':\n\t\ttxtchangeset(txtchangep, TXTNOBGCOLOUR, TXT_ATTR_BG_ON_MASK);\n\t\ttxtunset(TXT_ATTR_BG_ON_MASK);\n\t\tset_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, TSC_PROMPT);\n\t\tbreak;\n\t    case '[':\n\t\tif (idigit(*++bv->fm))\n\t\t    arg = zstrtol(bv->fm, &bv->fm, 10);\n\t\tif (!prompttrunc(arg, ']', doprint, endchar, txtchangep))\n\t\t    return *bv->fm;\n\t\tbreak;\n\t    case '<':\n\t    case '>':\n\t\t\/* Test (minus) here so -0 means \"at the right margin\" *\/\n\t\tif (minus) {\n\t\t    *bv->bp = '\\0';\n\t\t    countprompt(bv->bufline, &t0, 0, 0);\n\t\t    arg = zterm_columns - t0 + arg;\n\t\t    if (arg <= 0)\n\t\t\targ = 1;\n\t\t}\n\t\tif (!prompttrunc(arg, *bv->fm, doprint, endchar, txtchangep))\n\t\t    return *bv->fm;\n\t\tbreak;\n\t    case '{': \/*}*\/\n\t\tif (!bv->dontcount++) {\n\t\t    addbufspc(1);\n\t\t    *bv->bp++ = Inpar;\n\t\t}\n\t\tif (arg <= 0)\n\t\t    break;\n\t\t\/* else *\/\n\t\t\/* FALLTHROUGH *\/\n\t    case 'G':\n\t\tif (arg > 0) {\n\t\t    addbufspc(arg);\n\t\t    while (arg--)\n\t\t\t*bv->bp++ = Nularg;\n\t\t} else {\n\t\t    addbufspc(1);\n\t\t    *bv->bp++ = Nularg;\n\t\t}\n\t\tbreak;\n\t    case \/*{*\/ '}':\n\t\tif (bv->trunccount && bv->trunccount >= bv->dontcount)\n\t\t    return *bv->fm;\n\t\tif (bv->dontcount && !--bv->dontcount) {\n\t\t    addbufspc(1);\n\t\t    *bv->bp++ = Outpar;\n\t\t}\n\t\tbreak;\n\t    case 't':\n\t    case '@':\n\t    case 'T':\n\t    case '*':\n\t    case 'w':\n\t    case 'W':\n\t    case 'D':\n\t\t{\n\t\t    char *tmfmt, *dd, *tmbuf = NULL;\n\n\t\t    switch (*bv->fm) {\n\t\t    case 'T':\n\t\t\ttmfmt = \"%K:%M\";\n\t\t\tbreak;\n\t\t    case '*':\n\t\t\ttmfmt = \"%K:%M:%S\";\n\t\t\tbreak;\n\t\t    case 'w':\n\t\t\ttmfmt = \"%a %f\";\n\t\t\tbreak;\n\t\t    case 'W':\n\t\t\ttmfmt = \"%m\/%d\/%y\";\n\t\t\tbreak;\n\t\t    case 'D':\n\t\t\tif (bv->fm[1] == '{' \/*}*\/) {\n\t\t\t    for (ss = bv->fm + 2; *ss && *ss != \/*{*\/ '}'; ss++)\n\t\t\t\tif(*ss == '\\\\' && ss[1])\n\t\t\t\t    ss++;\n\t\t\t    dd = tmfmt = tmbuf = zalloc(ss - bv->fm);\n\t\t\t    for (ss = bv->fm + 2; *ss && *ss != \/*{*\/ '}';\n\t\t\t\t ss++) {\n\t\t\t\tif(*ss == '\\\\' && ss[1])\n\t\t\t\t    ss++;\n\t\t\t\t*dd++ = *ss;\n\t\t\t    }\n\t\t\t    *dd = 0;\n\t\t\t    bv->fm = ss - !*ss;\n\t\t\t    if (!*tmfmt) {\n\t\t\t\tfree(tmbuf);\n\t\t\t\tcontinue;\n\t\t\t    }\n\t\t\t} else\n\t\t\t    tmfmt = \"%y-%m-%d\";\n\t\t\tbreak;\n\t\t    default:\n\t\t\ttmfmt = \"%l:%M%p\";\n\t\t\tbreak;\n\t\t    }\n\t\t    zgettime(&ts);\n\t\t    tm = localtime(&ts.tv_sec);\n\t\t    \/*\n\t\t     * Hack because strftime won't say how\n\t\t     * much space it actually needs.  Try to add it\n\t\t     * a few times until it works.  Some formats don't\n\t\t     * actually have a length, so we could go on for\n\t\t     * ever.\n\t\t     *\/\n\t\t    for(j = 0, t0 = strlen(tmfmt)*8; j < 3; j++, t0*=2) {\n\t\t\taddbufspc(t0);\n\t\t\tif ((len = ztrftime(bv->bp, t0, tmfmt, tm, ts.tv_nsec))\n\t\t\t    >= 0)\n\t\t\t    break;\n\t\t    }\n\t\t    \/* There is enough room for this because addbufspc(t0)\n\t\t     * allocates room for t0 * 2 bytes. *\/\n\t\t    if (len >= 0)\n\t\t\tmetafy(bv->bp, len, META_NOALLOC);\n\t\t    bv->bp += strlen(bv->bp);\n\t\t    zsfree(tmbuf);\n\t\t    break;\n\t\t}\n\t    case 'n':\n\t\tstradd(get_username());\n\t\tbreak;\n\t    case 'l':\n\t\tif (*ttystrname) {\n                   ss = (strncmp(ttystrname, \"\/dev\/tty\", 8) ?\n                           ttystrname + 5 : ttystrname + 8);\n\t\t    stradd(ss);\n\t\t} else\n\t\t    stradd(\"()\");\n\t\tbreak;\n\t    case 'y':\n\t\tif (*ttystrname) {\n\t\t    ss = (strncmp(ttystrname, \"\/dev\/\", 5) ?\n\t\t\t    ttystrname : ttystrname + 5);\n\t\t    stradd(ss);\n\t\t} else\n\t\t    stradd(\"()\");\n\t\tbreak;\n\t    case 'L':\n\t\taddbufspc(DIGBUFSIZE);\n#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)\n\t\tsprintf(bv->bp, \"%lld\", shlvl);\n#else\n\t\tsprintf(bv->bp, \"%ld\", (long)shlvl);\n#endif\n\t\tbv->bp += strlen(bv->bp);\n\t\tbreak;\n\t    case '?':\n\t\taddbufspc(DIGBUFSIZE);\n#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)\n\t\tsprintf(bv->bp, \"%lld\", lastval);\n#else\n\t\tsprintf(bv->bp, \"%ld\", (long)lastval);\n#endif\n\t\tbv->bp += strlen(bv->bp);\n\t\tbreak;\n\t    case '%':\n\t    case ')':\n\t\taddbufspc(1);\n\t\t*bv->bp++ = *bv->fm;\n\t\tbreak;\n\t    case '#':\n\t\taddbufspc(1);\n\t\t*bv->bp++ = privasserted() ? '#' : '%';\n\t\tbreak;\n\t    case 'v':\n\t\tif (!arg)\n\t\t    arg = 1;\n\t\telse if (arg < 0)\n\t\t    arg += arrlen(psvar) + 1;\n\t\tif (arg > 0 && arrlen_ge(psvar, arg))\n\t\t    stradd(psvar[arg - 1]);\n\t\tbreak;\n\t    case 'E':\n                tsetcap(TCCLEAREOL, TSC_PROMPT);\n\t\tbreak;\n\t    case '^':\n\t\tif (cmdsp) {\n\t\t    if (arg >= 0) {\n\t\t\tif (arg > cmdsp || arg == 0)\n\t\t\t    arg = cmdsp;\n\t\t\tfor (t0 = cmdsp - 1; arg--; t0--) {\n\t\t\t    stradd(cmdnames[cmdstack[t0]]);\n\t\t\t    if (arg) {\n\t\t\t\taddbufspc(1);\n\t\t\t\t*bv->bp++=' ';\n\t\t\t    }\n\t\t\t}\n\t\t    } else {\n\t\t\targ = -arg;\n\t\t\tif (arg > cmdsp)\n\t\t\t    arg = cmdsp;\n\t\t\tfor (t0 = arg - 1; arg--; t0--) {\n\t\t\t    stradd(cmdnames[cmdstack[t0]]);\n\t\t\t    if (arg) {\n\t\t\t\taddbufspc(1);\n\t\t\t\t*bv->bp++=' ';\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tbreak;\n\t    case '_':\n\t\tif (cmdsp) {\n\t\t    if (arg >= 0) {\n\t\t\tif (arg > cmdsp || arg == 0)\n\t\t\t    arg = cmdsp;\n\t\t\tfor (t0 = cmdsp - arg; arg--; t0++) {\n\t\t\t    stradd(cmdnames[cmdstack[t0]]);\n\t\t\t    if (arg) {\n\t\t\t\taddbufspc(1);\n\t\t\t\t*bv->bp++=' ';\n\t\t\t    }\n\t\t\t}\n\t\t    } else {\n\t\t\targ = -arg;\n\t\t\tif (arg > cmdsp)\n\t\t\t    arg = cmdsp;\n\t\t\tfor (t0 = 0; arg--; t0++) {\n\t\t\t    stradd(cmdnames[cmdstack[t0]]);\n\t\t\t    if (arg) {\n\t\t\t\taddbufspc(1);\n\t\t\t\t*bv->bp++=' ';\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tbreak;\n\t    case 'r':\n\t\tif(bv->rstring)\n\t\t    stradd(bv->rstring);\n\t\tbreak;\n\t    case 'R':\n\t\tif(bv->Rstring)\n\t\t    stradd(bv->Rstring);\n\t\tbreak;\n\t    case 'e':\n\t    {\n\t\tint depth = 0;\n\t\tFuncstack fsptr = funcstack;\n\t\twhile (fsptr) {\n\t\t    depth++;\n\t\t    fsptr = fsptr->prev;\n\t\t}\n\t\taddbufspc(DIGBUFSIZE);\n\t\tsprintf(bv->bp, \"%d\", depth);\n\t\tbv->bp += strlen(bv->bp);\n\t\tbreak;\n\t    }\n\t    case 'I':\n\t\tif (funcstack && funcstack->tp != FS_SOURCE &&\n\t\t    !IN_EVAL_TRAP()) {\n\t\t    \/*\n\t\t     * We're in a function or an eval with\n\t\t     * EVALLINENO.  Calculate the line number in\n\t\t     * the file.\n\t\t     *\/\n\t\t    zlong flineno = lineno + funcstack->flineno;\n\t\t    \/* take account of eval line nos. starting at 1 *\/\n\t\t    if (funcstack->tp == FS_EVAL)\n\t\t\tlineno--;\n\t\t    addbufspc(DIGBUFSIZE);\n#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)\n\t\t    sprintf(bv->bp, \"%lld\", flineno);\n#else\n\t\t    sprintf(bv->bp, \"%ld\", (long)flineno);\n#endif\n\t\t    bv->bp += strlen(bv->bp);\n\t\t    break;\n\t\t}\n\t\t\/* else we're in a file and lineno is already correct *\/\n\t\t\/* FALLTHROUGH *\/\n\t    case 'i':\n\t\taddbufspc(DIGBUFSIZE);\n#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)\n\t\tsprintf(bv->bp, \"%lld\", lineno);\n#else\n\t\tsprintf(bv->bp, \"%ld\", (long)lineno);\n#endif\n\t\tbv->bp += strlen(bv->bp);\n\t\tbreak;\n\t    case 'x':\n\t\tif (funcstack && funcstack->tp != FS_SOURCE &&\n\t\t    !IN_EVAL_TRAP())\n\t\t    promptpath(funcstack->filename ? funcstack->filename : \"\",\n\t\t\t       arg, 0);\n\t\telse\n\t\t    promptpath(scriptfilename ? scriptfilename : argzero,\n\t\t\t       arg, 0);\n\t\tbreak;\n\t    case '\\0':\n\t\treturn 0;\n\t    case Meta:\n\t\tbv->fm++;\n\t\tbreak;\n\t    }\n\t} else if(*bv->fm == '!' && isset(PROMPTBANG)) {\n\t    if(doprint) {\n\t\tif(bv->fm[1] == '!') {\n\t\t    bv->fm++;\n\t\t    addbufspc(1);\n\t\t    pputc('!');\n\t\t} else {\n\t\t    addbufspc(DIGBUFSIZE);\n\t\t    convbase(bv->bp, curhist, 10);\n\t\t    bv->bp += strlen(bv->bp);\n\t\t}\n\t    }\n\t} else {\n\t    char c = *bv->fm == Meta ? *++bv->fm ^ 32 : *bv->fm;\n\n\t    if (doprint) {\n\t\taddbufspc(1);\n\t\tpputc(c);\n\t    }\n\t}\n    }\n\n    return *bv->fm;\n}","target":0,"code_token_length":4901,"total_token_length":5137,"max_tokens_setting":6144}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..8a1d2805af0e240bb14c2d21ad4881311454f4f5
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5a15cf483ea6c54b7b27e3ad889070d637b1feb8b65030884fb00187a08aeb35
+size 873216
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..71ca59d25467a9c50fd8e1d93fef4ba0516e54c8
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.jsonl
@@ -0,0 +1,2129 @@
+{"idx":211563,"func":"n_start_visual_mode(int c)\n{\n#ifdef FEAT_CONCEAL\n    int cursor_line_was_concealed = curwin->w_p_cole > 0\n\t\t\t\t\t\t&& conceal_cursor_line(curwin);\n#endif\n\n    VIsual_mode = c;\n    VIsual_active = TRUE;\n    VIsual_reselect = TRUE;\n    trigger_modechanged();\n\n    \/\/ Corner case: the 0 position in a tab may change when going into\n    \/\/ virtualedit.  Recalculate curwin->w_cursor to avoid bad highlighting.\n    if (c == Ctrl_V && (get_ve_flags() & VE_BLOCK) && gchar_cursor() == TAB)\n    {\n\tvalidate_virtcol();\n\tcoladvance(curwin->w_virtcol);\n    }\n    VIsual = curwin->w_cursor;\n\n#ifdef FEAT_FOLDING\n    foldAdjustVisual();\n#endif\n\n    setmouse();\n#ifdef FEAT_CONCEAL\n    \/\/ Check if redraw is needed after changing the state.\n    conceal_check_cursor_line(cursor_line_was_concealed);\n#endif\n\n    if (p_smd && msg_silent == 0)\n\tredraw_cmdline = TRUE;\t\/\/ show visual mode later\n#ifdef FEAT_CLIPBOARD\n    \/\/ Make sure the clipboard gets updated.  Needed because start and\n    \/\/ end may still be the same, and the selection needs to be owned\n    clip_star.vmode = NUL;\n#endif\n\n    \/\/ Only need to redraw this line, unless still need to redraw an old\n    \/\/ Visual area (when 'lazyredraw' is set).\n    if (curwin->w_redr_type < INVERTED)\n    {\n\tcurwin->w_old_cursor_lnum = curwin->w_cursor.lnum;\n\tcurwin->w_old_visual_lnum = curwin->w_cursor.lnum;\n    }\n}","target":1,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":450409,"func":"static int vnc_update_client(VncState *vs, int has_dirty)\n{\n    VncDisplay *vd = vs->vd;\n    VncJob *job;\n    int y;\n    int height, width;\n    int n = 0;\n\n    if (vs->disconnecting) {\n        vnc_disconnect_finish(vs);\n        return 0;\n    }\n\n    vs->has_dirty += has_dirty;\n    if (!vnc_should_update(vs)) {\n        return 0;\n    }\n\n    if (!vs->has_dirty && vs->update != VNC_STATE_UPDATE_FORCE) {\n        return 0;\n    }\n\n    \/*\n     * Send screen updates to the vnc client using the server\n     * surface and server dirty map.  guest surface updates\n     * happening in parallel don't disturb us, the next pass will\n     * send them to the client.\n     *\/\n    job = vnc_job_new(vs);\n\n    height = pixman_image_get_height(vd->server);\n    width = pixman_image_get_width(vd->server);\n\n    y = 0;\n    for (;;) {\n        int x, h;\n        unsigned long x2;\n        unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,\n                                             height * VNC_DIRTY_BPL(vs),\n                                             y * VNC_DIRTY_BPL(vs));\n        if (offset == height * VNC_DIRTY_BPL(vs)) {\n            \/* no more dirty bits *\/\n            break;\n        }\n        y = offset \/ VNC_DIRTY_BPL(vs);\n        x = offset % VNC_DIRTY_BPL(vs);\n        x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],\n                                VNC_DIRTY_BPL(vs), x);\n        bitmap_clear(vs->dirty[y], x, x2 - x);\n        h = find_and_clear_dirty_height(vs, y, x, x2, height);\n        x2 = MIN(x2, width \/ VNC_DIRTY_PIXELS_PER_BIT);\n        if (x2 > x) {\n            n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,\n                                  (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);\n        }\n        if (!x && x2 == width \/ VNC_DIRTY_PIXELS_PER_BIT) {\n            y += h;\n            if (y == height) {\n                break;\n            }\n        }\n    }\n\n    vs->job_update = vs->update;\n    vs->update = VNC_STATE_UPDATE_NONE;\n    vnc_job_push(job);\n    vs->has_dirty = 0;\n    return n;\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":328848,"func":"R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaClassesAttribute *icattr;\n\tRBinJavaCPTypeObj *obj;\n\tut32 i = 0;\n\tut64 offset = 0, curpos;\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\toffset += 6;\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR;\n\tattr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free);\n\tfor (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (offset + 8 > sz) {\n\t\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\t\tbreak;\n\t\t}\n\t\ticattr = R_NEW0 (RBinJavaClassesAttribute);\n\t\tif (!icattr) {\n\t\t\tbreak;\n\t\t}\n\t\ticattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags);\n\t\ticattr->file_offset = curpos;\n\t\ticattr->size = 8;\n\n\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx);\n\t\tif (!obj) {\n\t\t\teprintf (\"BINCPLIS IS HULL %d\\n\", icattr->inner_name_idx);\n\t\t}\n\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\tif (!icattr->name) {\n\t\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx);\n\t\t\tif (!obj) {\n\t\t\t\teprintf (\"BINCPLIST IS NULL %d\\n\", icattr->inner_class_info_idx);\n\t\t\t}\n\t\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\t\tif (!icattr->name) {\n\t\t\t\ticattr->name = r_str_dup (NULL, \"NULL\");\n\t\t\t\teprintf (\"r_bin_java_inner_classes_attr: Unable to find the name for %d index.\\n\", icattr->inner_name_idx);\n\t\t\t\tfree (icattr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tIFDBG eprintf (\"r_bin_java_inner_classes_attr: Inner class name %d is %s.\\n\", icattr->inner_name_idx, icattr->name);\n\t\tr_list_append (attr->info.inner_classes_attr.classes, (void *) icattr);\n\t}\n\tattr->size = offset;\n\t\/\/ IFDBG r_bin_java_print_inner_classes_attr_summary(attr);\n\treturn attr;\n}","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":264250,"func":"static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)\n{\n    char buf[1024];\n    VncShareMode mode;\n    int size;\n\n    mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;\n    switch (vs->vd->share_policy) {\n    case VNC_SHARE_POLICY_IGNORE:\n        \/*\n         * Ignore the shared flag.  Nothing to do here.\n         *\n         * Doesn't conform to the rfb spec but is traditional qemu\n         * behavior, thus left here as option for compatibility\n         * reasons.\n         *\/\n        break;\n    case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:\n        \/*\n         * Policy: Allow clients ask for exclusive access.\n         *\n         * Implementation: When a client asks for exclusive access,\n         * disconnect all others. Shared connects are allowed as long\n         * as no exclusive connection exists.\n         *\n         * This is how the rfb spec suggests to handle the shared flag.\n         *\/\n        if (mode == VNC_SHARE_MODE_EXCLUSIVE) {\n            VncState *client;\n            QTAILQ_FOREACH(client, &vs->vd->clients, next) {\n                if (vs == client) {\n                    continue;\n                }\n                if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&\n                    client->share_mode != VNC_SHARE_MODE_SHARED) {\n                    continue;\n                }\n                vnc_disconnect_start(client);\n            }\n        }\n        if (mode == VNC_SHARE_MODE_SHARED) {\n            if (vs->vd->num_exclusive > 0) {\n                vnc_disconnect_start(vs);\n                return 0;\n            }\n        }\n        break;\n    case VNC_SHARE_POLICY_FORCE_SHARED:\n        \/*\n         * Policy: Shared connects only.\n         * Implementation: Disallow clients asking for exclusive access.\n         *\n         * Useful for shared desktop sessions where you don't want\n         * someone forgetting to say -shared when running the vnc\n         * client disconnect everybody else.\n         *\/\n        if (mode == VNC_SHARE_MODE_EXCLUSIVE) {\n            vnc_disconnect_start(vs);\n            return 0;\n        }\n        break;\n    }\n    vnc_set_share_mode(vs, mode);\n\n    vs->client_width = surface_width(vs->vd->ds);\n    vs->client_height = surface_height(vs->vd->ds);\n    vnc_write_u16(vs, vs->client_width);\n    vnc_write_u16(vs, vs->client_height);\n\n    pixel_format_message(vs);\n\n    if (qemu_name)\n        size = snprintf(buf, sizeof(buf), \"QEMU (%s)\", qemu_name);\n    else\n        size = snprintf(buf, sizeof(buf), \"QEMU\");\n\n    vnc_write_u32(vs, size);\n    vnc_write(vs, buf, size);\n    vnc_flush(vs);\n\n    vnc_client_cache_auth(vs);\n    vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED);\n\n    vnc_read_when(vs, protocol_client_msg, 1);\n\n    return 0;\n}","target":0,"code_token_length":638,"total_token_length":874,"max_tokens_setting":1024}
+{"idx":415211,"func":"cmd_genkey (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  char *keyno;\n  int force;\n  const char *s;\n  time_t timestamp;\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  force = has_option (line, \"--force\");\n\n  if ((s=has_option_name (line, \"--timestamp\")))\n    {\n      if (*s != '=')\n        return set_error (GPG_ERR_ASS_PARAMETER, \"missing value for option\");\n      timestamp = isotime2epoch (s+1);\n      if (timestamp < 1)\n        return set_error (GPG_ERR_ASS_PARAMETER, \"invalid time value\");\n    }\n  else\n    timestamp = 0;\n\n\n  line = skip_options (line);\n  if (!*line)\n    return set_error (GPG_ERR_ASS_PARAMETER, \"no key number given\");\n  keyno = line;\n  while (*line && !spacep (line))\n    line++;\n  *line = 0;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  if (!ctrl->app_ctx)\n    return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);\n\n  keyno = xtrystrdup (keyno);\n  if (!keyno)\n    return out_of_core ();\n  rc = app_genkey (ctrl->app_ctx, ctrl, keyno, force? 1:0,\n                   timestamp, pin_cb, ctx);\n  xfree (keyno);\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":206781,"func":"int udf_expand_file_adinicb(struct inode *inode)\n{\n\tstruct page *page;\n\tchar *kaddr;\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\tint err;\n\n\tWARN_ON_ONCE(!inode_is_locked(inode));\n\tif (!iinfo->i_lenAlloc) {\n\t\tif (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))\n\t\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;\n\t\telse\n\t\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;\n\t\t\/* from now on we have normal address_space methods *\/\n\t\tinode->i_data.a_ops = &udf_aops;\n\t\tup_write(&iinfo->i_data_sem);\n\t\tmark_inode_dirty(inode);\n\t\treturn 0;\n\t}\n\t\/*\n\t * Release i_data_sem so that we can lock a page - page lock ranks\n\t * above i_data_sem. i_mutex still protects us against file changes.\n\t *\/\n\tup_write(&iinfo->i_data_sem);\n\n\tpage = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);\n\tif (!page)\n\t\treturn -ENOMEM;\n\n\tif (!PageUptodate(page)) {\n\t\tkaddr = kmap_atomic(page);\n\t\tmemset(kaddr + iinfo->i_lenAlloc, 0x00,\n\t\t       PAGE_SIZE - iinfo->i_lenAlloc);\n\t\tmemcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr,\n\t\t\tiinfo->i_lenAlloc);\n\t\tflush_dcache_page(page);\n\t\tSetPageUptodate(page);\n\t\tkunmap_atomic(kaddr);\n\t}\n\tdown_write(&iinfo->i_data_sem);\n\tmemset(iinfo->i_data + iinfo->i_lenEAttr, 0x00,\n\t       iinfo->i_lenAlloc);\n\tiinfo->i_lenAlloc = 0;\n\tif (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;\n\telse\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;\n\t\/* from now on we have normal address_space methods *\/\n\tinode->i_data.a_ops = &udf_aops;\n\tset_page_dirty(page);\n\tunlock_page(page);\n\tup_write(&iinfo->i_data_sem);\n\terr = filemap_fdatawrite(inode->i_mapping);\n\tif (err) {\n\t\t\/* Restore everything back so that we don't lose data... *\/\n\t\tlock_page(page);\n\t\tdown_write(&iinfo->i_data_sem);\n\t\tkaddr = kmap_atomic(page);\n\t\tmemcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, inode->i_size);\n\t\tkunmap_atomic(kaddr);\n\t\tunlock_page(page);\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;\n\t\tinode->i_data.a_ops = &udf_adinicb_aops;\n\t\tup_write(&iinfo->i_data_sem);\n\t}\n\tput_page(page);\n\tmark_inode_dirty(inode);\n\n\treturn err;\n}","target":1,"code_token_length":645,"total_token_length":881,"max_tokens_setting":1024}
+{"idx":484792,"func":"static void xennet_alloc_rx_buffers(struct netfront_queue *queue)\n{\n\tRING_IDX req_prod = queue->rx.req_prod_pvt;\n\tint notify;\n\tint err = 0;\n\n\tif (unlikely(!netif_carrier_ok(queue->info->netdev)))\n\t\treturn;\n\n\tfor (req_prod = queue->rx.req_prod_pvt;\n\t     req_prod - queue->rx.rsp_cons < NET_RX_RING_SIZE;\n\t     req_prod++) {\n\t\tstruct sk_buff *skb;\n\t\tunsigned short id;\n\t\tgrant_ref_t ref;\n\t\tstruct page *page;\n\t\tstruct xen_netif_rx_request *req;\n\n\t\tskb = xennet_alloc_one_rx_buffer(queue);\n\t\tif (!skb) {\n\t\t\terr = -ENOMEM;\n\t\t\tbreak;\n\t\t}\n\n\t\tid = xennet_rxidx(req_prod);\n\n\t\tBUG_ON(queue->rx_skbs[id]);\n\t\tqueue->rx_skbs[id] = skb;\n\n\t\tref = gnttab_claim_grant_reference(&queue->gref_rx_head);\n\t\tWARN_ON_ONCE(IS_ERR_VALUE((unsigned long)(int)ref));\n\t\tqueue->grant_rx_ref[id] = ref;\n\n\t\tpage = skb_frag_page(&skb_shinfo(skb)->frags[0]);\n\n\t\treq = RING_GET_REQUEST(&queue->rx, req_prod);\n\t\tgnttab_page_grant_foreign_access_ref_one(ref,\n\t\t\t\t\t\t\t queue->info->xbdev->otherend_id,\n\t\t\t\t\t\t\t page,\n\t\t\t\t\t\t\t 0);\n\t\treq->id = id;\n\t\treq->gref = ref;\n\t}\n\n\tqueue->rx.req_prod_pvt = req_prod;\n\n\t\/* Try again later if there are not enough requests or skb allocation\n\t * failed.\n\t * Enough requests is quantified as the sum of newly created slots and\n\t * the unconsumed slots at the backend.\n\t *\/\n\tif (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN ||\n\t    unlikely(err)) {\n\t\tmod_timer(&queue->rx_refill_timer, jiffies + (HZ\/10));\n\t\treturn;\n\t}\n\n\tRING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->rx, notify);\n\tif (notify)\n\t\tnotify_remote_via_irq(queue->rx_irq);\n}","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":343153,"func":"static void esp_output_done(struct crypto_async_request *base, int err)\n{\n\tstruct sk_buff *skb = base->data;\n\tstruct xfrm_offload *xo = xfrm_offload(skb);\n\tvoid *tmp;\n\tstruct xfrm_state *x;\n\n\tif (xo && (xo->flags & XFRM_DEV_RESUME)) {\n\t\tstruct sec_path *sp = skb_sec_path(skb);\n\n\t\tx = sp->xvec[sp->len - 1];\n\t} else {\n\t\tx = skb_dst(skb)->xfrm;\n\t}\n\n\ttmp = ESP_SKB_CB(skb)->tmp;\n\tesp_ssg_unref(x, tmp);\n\tkfree(tmp);\n\n\tif (xo && (xo->flags & XFRM_DEV_RESUME)) {\n\t\tif (err) {\n\t\t\tXFRM_INC_STATS(xs_net(x), LINUX_MIB_XFRMOUTSTATEPROTOERROR);\n\t\t\tkfree_skb(skb);\n\t\t\treturn;\n\t\t}\n\n\t\tskb_push(skb, skb->data - skb_mac_header(skb));\n\t\tsecpath_reset(skb);\n\t\txfrm_dev_resume(skb);\n\t} else {\n\t\tif (!err &&\n\t\t    x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)\n\t\t\tesp_output_tail_tcp(x, skb);\n\t\telse\n\t\t\txfrm_output_resume(skb->sk, skb, err);\n\t}\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":317254,"func":"static int selinux_kernfs_init_security(struct kernfs_node *kn_dir,\n\t\t\t\t\tstruct kernfs_node *kn)\n{\n\tconst struct task_security_struct *tsec = selinux_cred(current_cred());\n\tu32 parent_sid, newsid, clen;\n\tint rc;\n\tchar *context;\n\n\trc = kernfs_xattr_get(kn_dir, XATTR_NAME_SELINUX, NULL, 0);\n\tif (rc == -ENODATA)\n\t\treturn 0;\n\telse if (rc < 0)\n\t\treturn rc;\n\n\tclen = (u32)rc;\n\tcontext = kmalloc(clen, GFP_KERNEL);\n\tif (!context)\n\t\treturn -ENOMEM;\n\n\trc = kernfs_xattr_get(kn_dir, XATTR_NAME_SELINUX, context, clen);\n\tif (rc < 0) {\n\t\tkfree(context);\n\t\treturn rc;\n\t}\n\n\trc = security_context_to_sid(&selinux_state, context, clen, &parent_sid,\n\t\t\t\t     GFP_KERNEL);\n\tkfree(context);\n\tif (rc)\n\t\treturn rc;\n\n\tif (tsec->create_sid) {\n\t\tnewsid = tsec->create_sid;\n\t} else {\n\t\tu16 secclass = inode_mode_to_security_class(kn->mode);\n\t\tstruct qstr q;\n\n\t\tq.name = kn->name;\n\t\tq.hash_len = hashlen_string(kn_dir, kn->name);\n\n\t\trc = security_transition_sid(&selinux_state, tsec->sid,\n\t\t\t\t\t     parent_sid, secclass, &q,\n\t\t\t\t\t     &newsid);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\trc = security_sid_to_context_force(&selinux_state, newsid,\n\t\t\t\t\t   &context, &clen);\n\tif (rc)\n\t\treturn rc;\n\n\trc = kernfs_xattr_set(kn, XATTR_NAME_SELINUX, context, clen,\n\t\t\t      XATTR_CREATE);\n\tkfree(context);\n\treturn rc;\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":202677,"func":"static int parallels_open(BlockDriverState *bs, QDict *options, int flags,\n                          Error **errp)\n{\n    BDRVParallelsState *s = bs->opaque;\n    int i;\n    struct parallels_header ph;\n    int ret;\n\n    bs->read_only = 1; \/\/ no write support yet\n\n    ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph));\n    if (ret < 0) {\n        goto fail;\n    }\n\n    if (memcmp(ph.magic, HEADER_MAGIC, 16) ||\n        (le32_to_cpu(ph.version) != HEADER_VERSION)) {\n        error_setg(errp, \"Image not in Parallels format\");\n        ret = -EINVAL;\n        goto fail;\n    }\n\n    bs->total_sectors = le32_to_cpu(ph.nb_sectors);\n\n    s->tracks = le32_to_cpu(ph.tracks);\n\n    s->catalog_size = le32_to_cpu(ph.catalog_entries);\n    if (s->catalog_size > INT_MAX \/ 4) {\n        error_setg(errp, \"Catalog too large\");\n        ret = -EFBIG;\n        goto fail;\n    }\n    s->catalog_bitmap = g_malloc(s->catalog_size * 4);\n\n    ret = bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4);\n    if (ret < 0) {\n        goto fail;\n    }\n\n    for (i = 0; i < s->catalog_size; i++)\n\tle32_to_cpus(&s->catalog_bitmap[i]);\n\n    qemu_co_mutex_init(&s->lock);\n    return 0;\n\nfail:\n    g_free(s->catalog_bitmap);\n    return ret;\n}","target":1,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":273908,"func":"static void handle_MDTM(ctrl_t *ctrl, char *file)\n{\n\tstruct stat st;\n\tstruct tm *tm;\n\tchar *path, *ptr;\n\tchar *mtime = NULL;\n\tchar buf[80];\n\n\t\/* Request to set mtime, ncftp does this *\/\n\tptr = strchr(file, ' ');\n\tif (ptr) {\n\t\t*ptr++ = 0;\n\t\tmtime = file;\n\t\tfile  = ptr;\n\t}\n\n\tpath = compose_abspath(ctrl, file);\n\tif (!path || stat(path, &st) || !S_ISREG(st.st_mode)) {\n\t\tsend_msg(ctrl->sd, \"550 Not a regular file.\\r\\n\");\n\t\treturn;\n\t}\n\n\tif (mtime) {\n\t\tstruct timespec times[2] = {\n\t\t\t{ 0, UTIME_OMIT },\n\t\t\t{ 0, 0 }\n\t\t};\n\t\tstruct tm tm;\n\t\tint rc;\n\n\t\tif (!strptime(mtime, \"%Y%m%d%H%M%S\", &tm)) {\n\t\tfail:\n\t\t\tsend_msg(ctrl->sd, \"550 Invalid time format\\r\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\ttimes[1].tv_sec = mktime(&tm);\n\t\trc = utimensat(0, path, times, 0);\n\t\tif (rc) {\n\t\t\tERR(errno, \"Failed setting MTIME %s of %s\", mtime, file);\n\t\t\tgoto fail;\n\t\t}\n\t\t(void)stat(path, &st);\n\t}\n\n\ttm = gmtime(&st.st_mtime);\n\tstrftime(buf, sizeof(buf), \"213 %Y%m%d%H%M%S\\r\\n\", tm);\n\n\tsend_msg(ctrl->sd, buf);\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":225486,"func":"bool MutableGraphView::RemoveRegularFaninInternal(NodeDef* node,\n                                                  const OutputPort& fanin) {\n  auto remove_input = [this, node](const OutputPort& fanin_port,\n                                   int node_input_port, bool update_max_port) {\n    InputPort input(node, node_input_port);\n\n    absl::flat_hash_set<InputPort>* fanouts_set = &fanouts()[fanin_port];\n    fanouts_set->erase(input);\n    if (update_max_port) {\n      UpdateMaxRegularOutputPortForRemovedFanin(fanin_port, *fanouts_set);\n    }\n    return fanouts_set;\n  };\n\n  auto mutable_inputs = node->mutable_input();\n  bool modified = false;\n  const int num_regular_fanins =\n      NumFanins(*node, \/*include_controlling_nodes=*\/false);\n  int i;\n  int curr_pos = 0;\n  for (i = 0; i < num_regular_fanins; ++i) {\n    TensorId tensor_id = ParseTensorName(node->input(i));\n    if (tensor_id.node() == fanin.node->name() &&\n        tensor_id.index() == fanin.port_id) {\n      remove_input(fanin, i, \/*update_max_port=*\/true);\n      modified = true;\n    } else if (modified) {\n      \/\/ Regular inputs will need to have their ports updated.\n      OutputPort fanin_port(nodes()[tensor_id.node()], tensor_id.index());\n      auto fanouts_set = remove_input(fanin_port, i, \/*update_max_port=*\/false);\n      fanouts_set->insert({node, curr_pos});\n      \/\/ Shift inputs to be retained.\n      mutable_inputs->SwapElements(i, curr_pos);\n      ++curr_pos;\n    } else {\n      \/\/ Skip inputs to be retained until first modification.\n      ++curr_pos;\n    }\n  }\n\n  if (modified) {\n    const int last_regular_input_port = curr_pos - 1;\n    if (last_regular_input_port < 0) {\n      max_regular_input_port().erase(node);\n    } else {\n      max_regular_input_port()[node] = last_regular_input_port;\n    }\n    if (curr_pos < i) {\n      \/\/ Remove fanins from node inputs.\n      mutable_inputs->DeleteSubrange(curr_pos, i - curr_pos);\n    }\n  }\n\n  return modified;\n}","target":0,"code_token_length":486,"total_token_length":722,"max_tokens_setting":1024}
+{"idx":318108,"func":"static int rsi_usb_init_rx(struct rsi_hw *adapter)\n{\n\tstruct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;\n\tstruct rx_usb_ctrl_block *rx_cb;\n\tu8 idx, num_rx_cb;\n\n\tnum_rx_cb = (adapter->priv->coex_mode > 1 ? 2 : 1);\n\n\tfor (idx = 0; idx < num_rx_cb; idx++) {\n\t\trx_cb = &dev->rx_cb[idx];\n\n\t\trx_cb->rx_urb = usb_alloc_urb(0, GFP_KERNEL);\n\t\tif (!rx_cb->rx_urb) {\n\t\t\trsi_dbg(ERR_ZONE, \"Failed alloc rx urb[%d]\\n\", idx);\n\t\t\tgoto err;\n\t\t}\n\t\trx_cb->ep_num = idx + 1;\n\t\trx_cb->data = (void *)dev;\n\t}\n\tskb_queue_head_init(&dev->rx_q);\n\trsi_init_event(&dev->rx_thread.event);\n\tif (rsi_create_kthread(adapter->priv, &dev->rx_thread,\n\t\t\t       rsi_usb_rx_thread, \"RX-Thread\")) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Unable to init rx thrd\\n\", __func__);\n\t\tgoto err;\n\t}\n\n\treturn 0;\n\nerr:\n\tusb_free_urb(dev->rx_cb[0].rx_urb);\n\tif (adapter->priv->coex_mode > 1)\n\t\tusb_free_urb(dev->rx_cb[1].rx_urb);\n\n\treturn -1;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":275522,"func":"njs_vm_handle_events(njs_vm_t *vm)\n{\n    njs_int_t         ret;\n    njs_str_t         str;\n    njs_value_t       string;\n    njs_event_t       *ev;\n    njs_queue_t       *promise_events, *posted_events;\n    njs_queue_link_t  *link;\n\n    promise_events = &vm->promise_events;\n    posted_events = &vm->posted_events;\n\n    do {\n        for ( ;; ) {\n            link = njs_queue_first(promise_events);\n\n            if (link == njs_queue_tail(promise_events)) {\n                break;\n            }\n\n            ev = njs_queue_link_data(link, njs_event_t, link);\n\n            njs_queue_remove(&ev->link);\n\n            ret = njs_vm_call(vm, ev->function, ev->args, ev->nargs);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return ret;\n            }\n        }\n\n        if (njs_vm_unhandled_rejection(vm)) {\n            ret = njs_value_to_string(vm, &string,\n                                      &vm->promise_reason->start[0]);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            njs_string_get(&string, &str);\n            njs_vm_error(vm, \"unhandled promise rejection: %V\", &str);\n\n            njs_mp_free(vm->mem_pool, vm->promise_reason);\n            vm->promise_reason = NULL;\n\n            return NJS_ERROR;\n        }\n\n        for ( ;; ) {\n            link = njs_queue_first(posted_events);\n\n            if (link == njs_queue_tail(posted_events)) {\n                break;\n            }\n\n            ev = njs_queue_link_data(link, njs_event_t, link);\n\n            if (ev->once) {\n                njs_del_event(vm, ev, NJS_EVENT_RELEASE | NJS_EVENT_DELETE);\n\n            } else {\n                ev->posted = 0;\n                njs_queue_remove(&ev->link);\n            }\n\n            ret = njs_vm_call(vm, ev->function, ev->args, ev->nargs);\n\n            if (ret == NJS_ERROR) {\n                return ret;\n            }\n        }\n\n    } while (!njs_queue_is_empty(promise_events));\n\n    return njs_vm_pending(vm) ? NJS_AGAIN : NJS_OK;\n}","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":196705,"func":"Status ValidateInputs(const Tensor *a_indices, const Tensor *a_values,\n                      const Tensor *a_shape, const Tensor *b) {\n  if (!TensorShapeUtils::IsMatrix(a_indices->shape())) {\n    return errors::InvalidArgument(\n        \"Input a_indices should be a matrix but received shape: \",\n        a_indices->shape().DebugString());\n  }\n  if (!TensorShapeUtils::IsVector(a_values->shape()) ||\n      !TensorShapeUtils::IsVector(a_shape->shape())) {\n    return errors::InvalidArgument(\n        \"Inputs a_values and a_shape should be vectors \"\n        \"but received shapes: \",\n        a_values->shape().DebugString(), \" and \",\n        a_shape->shape().DebugString());\n  }\n  if (a_shape->NumElements() != b->dims()) {\n    return errors::InvalidArgument(\n        \"Two operands have different ranks; received: \", a_shape->NumElements(),\n        \" and \", b->dims());\n  }\n  const auto a_shape_flat = a_shape->flat<Index>();\n  for (int i = 0; i < b->dims(); ++i) {\n    if (a_shape_flat(i) != b->dim_size(i)) {\n      return errors::InvalidArgument(\n          \"Dimension \", i,\n          \" does not equal (no broadcasting is supported): sparse side \",\n          a_shape_flat(i), \" vs dense side \", b->dim_size(i));\n    }\n  }\n  return Status::OK();\n}","target":1,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":437326,"func":"disable_noname_group_capture(Node** root, regex_t* reg, ScanEnv* env)\n{\n  int r, i, pos, counter;\n  MemStatusType loc;\n  GroupNumRemap* map;\n\n  map = (GroupNumRemap* )xalloca(sizeof(GroupNumRemap) * (env->num_mem + 1));\n  CHECK_NULL_RETURN_MEMERR(map);\n  for (i = 1; i <= env->num_mem; i++) {\n    map[i].new_val = 0;\n  }\n  counter = 0;\n  r = noname_disable_map(root, map, &counter);\n  if (r != 0) return r;\n\n  r = renumber_by_map(*root, map);\n  if (r != 0) return r;\n\n  for (i = 1, pos = 1; i <= env->num_mem; i++) {\n    if (map[i].new_val > 0) {\n      SCANENV_MEMENV(env)[pos] = SCANENV_MEMENV(env)[i];\n      pos++;\n    }\n  }\n\n  loc = env->capture_history;\n  MEM_STATUS_CLEAR(env->capture_history);\n  for (i = 1; i <= ONIG_MAX_CAPTURE_HISTORY_GROUP; i++) {\n    if (MEM_STATUS_AT(loc, i)) {\n      MEM_STATUS_ON_SIMPLE(env->capture_history, map[i].new_val);\n    }\n  }\n\n  env->num_mem = env->num_named;\n  reg->num_mem = env->num_named;\n\n  return onig_renumber_name_table(reg, map);\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":270380,"func":"static bool ok_inflater_zlib_header(ok_inflater *inflater) {\n    if (!ok_inflater_load_bits(inflater, 16)) {\n        return false;\n    } else {\n        uint32_t compression_method = ok_inflater_read_bits(inflater, 4);\n        uint32_t compression_info = ok_inflater_read_bits(inflater, 4);\n        uint32_t flag_check = ok_inflater_read_bits(inflater, 5);\n        uint32_t flag_dict = ok_inflater_read_bits(inflater, 1);\n        uint32_t flag_compression_level = ok_inflater_read_bits(inflater, 2);\n\n        uint32_t bits = ((compression_info << 12) | (compression_method << 8) |\n                         (flag_compression_level << 6) | (flag_dict << 5) | flag_check);\n        if (bits % 31 != 0) {\n            ok_inflater_error(inflater, \"Invalid zlib header\");\n            return false;\n        }\n        if (compression_method != 8) {\n            ok_inflater_error(inflater, \"Invalid inflater compression method\");\n            return false;\n        }\n        if (compression_info > 7) {\n            ok_inflater_error(inflater, \"Invalid window size\");\n            return false;\n        }\n        if (flag_dict) {\n            ok_inflater_error(inflater, \"Needs external dictionary\");\n            return false;\n        }\n\n        inflater->state = OK_INFLATER_STATE_READY_FOR_NEXT_BLOCK;\n        return true;\n    }\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":223386,"func":"static SLJIT_INLINE void match_once_common(compiler_common *common, PCRE2_UCHAR ket, int framesize, int private_data_ptr, BOOL has_alternatives, BOOL needs_control_head)\n{\nDEFINE_COMPILER;\nint stacksize;\n\nif (framesize < 0)\n  {\n  if (framesize == no_frame)\n    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);\n  else\n    {\n    stacksize = needs_control_head ? 1 : 0;\n    if (ket != OP_KET || has_alternatives)\n      stacksize++;\n\n    if (stacksize > 0)\n      free_stack(common, stacksize);\n    }\n\n  if (needs_control_head)\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), (ket != OP_KET || has_alternatives) ? STACK(-2) : STACK(-1));\n\n  \/* TMP2 which is set here used by OP_KETRMAX below. *\/\n  if (ket == OP_KETRMAX)\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(-1));\n  else if (ket == OP_KETRMIN)\n    {\n    \/* Move the STR_PTR to the private_data_ptr. *\/\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_MEM1(STACK_TOP), STACK(-1));\n    }\n  }\nelse\n  {\n  stacksize = (ket != OP_KET || has_alternatives) ? 2 : 1;\n  OP2(SLJIT_SUB, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, (framesize + stacksize) * sizeof(sljit_sw));\n  if (needs_control_head)\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(-1));\n\n  if (ket == OP_KETRMAX)\n    {\n    \/* TMP2 which is set here used by OP_KETRMAX below. *\/\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0));\n    }\n  }\nif (needs_control_head)\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, TMP1, 0);\n}","target":0,"code_token_length":542,"total_token_length":778,"max_tokens_setting":1024}
+{"idx":247588,"func":"TEST_P(SslSocketTest, TicketSessionResumptionDifferentServerCertIntermediateCA) {\n  const std::string server_ctx_yaml1 = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n)EOF\";\n\n  const std::string server_ctx_yaml2 = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_chain.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_key.pem\"\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  testTicketSessionResumption(server_ctx_yaml1, {}, server_ctx_yaml2, {}, client_ctx_yaml, false,\n                              GetParam());\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":455430,"func":"xfs_inode_free_eofblocks(\n\tstruct xfs_inode\t*ip,\n\tint\t\t\tflags,\n\tvoid\t\t\t*args)\n{\n\tint ret = 0;\n\tstruct xfs_eofblocks *eofb = args;\n\tint match;\n\n\tif (!xfs_can_free_eofblocks(ip, false)) {\n\t\t\/* inode could be preallocated or append-only *\/\n\t\ttrace_xfs_inode_free_eofblocks_invalid(ip);\n\t\txfs_inode_clear_eofblocks_tag(ip);\n\t\treturn 0;\n\t}\n\n\t\/*\n\t * If the mapping is dirty the operation can block and wait for some\n\t * time. Unless we are waiting, skip it.\n\t *\/\n\tif (!(flags & SYNC_WAIT) &&\n\t    mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY))\n\t\treturn 0;\n\n\tif (eofb) {\n\t\tif (eofb->eof_flags & XFS_EOF_FLAGS_UNION)\n\t\t\tmatch = xfs_inode_match_id_union(ip, eofb);\n\t\telse\n\t\t\tmatch = xfs_inode_match_id(ip, eofb);\n\t\tif (!match)\n\t\t\treturn 0;\n\n\t\t\/* skip the inode if the file size is too small *\/\n\t\tif (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&\n\t\t    XFS_ISIZE(ip) < eofb->eof_min_file_size)\n\t\t\treturn 0;\n\t}\n\n\t\/*\n\t * If the caller is waiting, return -EAGAIN to keep the background\n\t * scanner moving and revisit the inode in a subsequent pass.\n\t *\/\n\tif (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {\n\t\tif (flags & SYNC_WAIT)\n\t\t\tret = -EAGAIN;\n\t\treturn ret;\n\t}\n\tret = xfs_free_eofblocks(ip);\n\txfs_iunlock(ip, XFS_IOLOCK_EXCL);\n\n\treturn ret;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":339728,"func":"static Bigint * diff(Bigint *a, Bigint *b)\n{\n\tBigint *c;\n\tint i, wa, wb;\n\tLong borrow, y; \/* We need signed shifts here. *\/\n\tULong *xa, *xae, *xb, *xbe, *xc;\n#ifdef Pack_32\n\tLong z;\n#endif\n\n\ti = cmp(a,b);\n\tif (!i) {\n\t\tc = Balloc(0);\n\t\tc->wds = 1;\n\t\tc->x[0] = 0;\n\t\treturn c;\n\t}\n\tif (i < 0) {\n\t\tc = a;\n\t\ta = b;\n\t\tb = c;\n\t\ti = 1;\n\t} else {\n\t\ti = 0;\n\t}\n\tc = Balloc(a->k);\n\tc->sign = i;\n\twa = a->wds;\n\txa = a->x;\n\txae = xa + wa;\n\twb = b->wds;\n\txb = b->x;\n\txbe = xb + wb;\n\txc = c->x;\n\tborrow = 0;\n#ifdef Pack_32\n\tdo {\n\t\ty = (*xa & 0xffff) - (*xb & 0xffff) + borrow;\n\t\tborrow = y >> 16;\n\t\tSign_Extend(borrow, y);\n\t\tz = (*xa++ >> 16) - (*xb++ >> 16) + borrow;\n\t\tborrow = z >> 16;\n\t\tSign_Extend(borrow, z);\n\t\tStoreinc(xc, z, y);\n\t} while(xb < xbe);\n\twhile(xa < xae) {\n\t\ty = (*xa & 0xffff) + borrow;\n\t\tborrow = y >> 16;\n\t\tSign_Extend(borrow, y);\n\t\tz = (*xa++ >> 16) + borrow;\n\t\tborrow = z >> 16;\n\t\tSign_Extend(borrow, z);\n\t\tStoreinc(xc, z, y);\n\t}\n#else\n\tdo {\n\t\ty = *xa++ - *xb++ + borrow;\n\t\tborrow = y >> 16;\n\t\tSign_Extend(borrow, y);\n\t\t*xc++ = y & 0xffff;\n\t} while(xb < xbe);\n\twhile(xa < xae) {\n\t\ty = *xa++ + borrow;\n\t\tborrow = y >> 16;\n\t\tSign_Extend(borrow, y);\n\t\t*xc++ = y & 0xffff;\n\t}\n#endif\n\twhile(!*--xc) {\n\t\twa--;\n\t}\n\tc->wds = wa;\n\treturn c;\n}","target":0,"code_token_length":564,"total_token_length":800,"max_tokens_setting":1024}
+{"idx":253641,"func":"move_smb2_ea_to_cifs(char *dst, size_t dst_size,\n\t\t     struct smb2_file_full_ea_info *src, size_t src_size,\n\t\t     const unsigned char *ea_name)\n{\n\tint rc = 0;\n\tunsigned int ea_name_len = ea_name ? strlen(ea_name) : 0;\n\tchar *name, *value;\n\tsize_t buf_size = dst_size;\n\tsize_t name_len, value_len, user_name_len;\n\n\twhile (src_size > 0) {\n\t\tname = &src->ea_data[0];\n\t\tname_len = (size_t)src->ea_name_length;\n\t\tvalue = &src->ea_data[src->ea_name_length + 1];\n\t\tvalue_len = (size_t)le16_to_cpu(src->ea_value_length);\n\n\t\tif (name_len == 0)\n\t\t\tbreak;\n\n\t\tif (src_size < 8 + name_len + 1 + value_len) {\n\t\t\tcifs_dbg(FYI, \"EA entry goes beyond length of list\\n\");\n\t\t\trc = -EIO;\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (ea_name) {\n\t\t\tif (ea_name_len == name_len &&\n\t\t\t    memcmp(ea_name, name, name_len) == 0) {\n\t\t\t\trc = value_len;\n\t\t\t\tif (dst_size == 0)\n\t\t\t\t\tgoto out;\n\t\t\t\tif (dst_size < value_len) {\n\t\t\t\t\trc = -ERANGE;\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t\tmemcpy(dst, value, value_len);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t} else {\n\t\t\t\/* 'user.' plus a terminating null *\/\n\t\t\tuser_name_len = 5 + 1 + name_len;\n\n\t\t\tif (buf_size == 0) {\n\t\t\t\t\/* skip copy - calc size only *\/\n\t\t\t\trc += user_name_len;\n\t\t\t} else if (dst_size >= user_name_len) {\n\t\t\t\tdst_size -= user_name_len;\n\t\t\t\tmemcpy(dst, \"user.\", 5);\n\t\t\t\tdst += 5;\n\t\t\t\tmemcpy(dst, src->ea_data, name_len);\n\t\t\t\tdst += name_len;\n\t\t\t\t*dst = 0;\n\t\t\t\t++dst;\n\t\t\t\trc += user_name_len;\n\t\t\t} else {\n\t\t\t\t\/* stop before overrun buffer *\/\n\t\t\t\trc = -ERANGE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!src->next_entry_offset)\n\t\t\tbreak;\n\n\t\tif (src_size < le32_to_cpu(src->next_entry_offset)) {\n\t\t\t\/* stop before overrun buffer *\/\n\t\t\trc = -ERANGE;\n\t\t\tbreak;\n\t\t}\n\t\tsrc_size -= le32_to_cpu(src->next_entry_offset);\n\t\tsrc = (void *)((char *)src +\n\t\t\t       le32_to_cpu(src->next_entry_offset));\n\t}\n\n\t\/* didn't find the named attribute *\/\n\tif (ea_name)\n\t\trc = -ENODATA;\n\nout:\n\treturn (ssize_t)rc;\n}","target":0,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":234811,"func":"static void update_balance_args(struct btrfs_balance_control *bctl)\n{\n\t\/*\n\t * Turn on soft mode for chunk types that were being converted.\n\t *\/\n\tif (bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT)\n\t\tbctl->data.flags |= BTRFS_BALANCE_ARGS_SOFT;\n\tif (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT)\n\t\tbctl->sys.flags |= BTRFS_BALANCE_ARGS_SOFT;\n\tif (bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT)\n\t\tbctl->meta.flags |= BTRFS_BALANCE_ARGS_SOFT;\n\n\t\/*\n\t * Turn on usage filter if is not already used.  The idea is\n\t * that chunks that we have already balanced should be\n\t * reasonably full.  Don't do it for chunks that are being\n\t * converted - that will keep us from relocating unconverted\n\t * (albeit full) chunks.\n\t *\/\n\tif (!(bctl->data.flags & BTRFS_BALANCE_ARGS_USAGE) &&\n\t    !(bctl->data.flags & BTRFS_BALANCE_ARGS_USAGE_RANGE) &&\n\t    !(bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT)) {\n\t\tbctl->data.flags |= BTRFS_BALANCE_ARGS_USAGE;\n\t\tbctl->data.usage = 90;\n\t}\n\tif (!(bctl->sys.flags & BTRFS_BALANCE_ARGS_USAGE) &&\n\t    !(bctl->sys.flags & BTRFS_BALANCE_ARGS_USAGE_RANGE) &&\n\t    !(bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT)) {\n\t\tbctl->sys.flags |= BTRFS_BALANCE_ARGS_USAGE;\n\t\tbctl->sys.usage = 90;\n\t}\n\tif (!(bctl->meta.flags & BTRFS_BALANCE_ARGS_USAGE) &&\n\t    !(bctl->meta.flags & BTRFS_BALANCE_ARGS_USAGE_RANGE) &&\n\t    !(bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT)) {\n\t\tbctl->meta.flags |= BTRFS_BALANCE_ARGS_USAGE;\n\t\tbctl->meta.usage = 90;\n\t}\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":338051,"func":"void WasmBinaryBuilder::readElementSegments() {\n  BYN_TRACE(\"== readElementSegments\\n\");\n  auto numSegments = getU32LEB();\n  if (numSegments >= Table::kMaxSize) {\n    throwError(\"Too many segments\");\n  }\n  for (size_t i = 0; i < numSegments; i++) {\n    auto flags = getU32LEB();\n    bool isPassive = (flags & BinaryConsts::IsPassive) != 0;\n    bool hasTableIdx = !isPassive && ((flags & BinaryConsts::HasIndex) != 0);\n    bool isDeclarative =\n      isPassive && ((flags & BinaryConsts::IsDeclarative) != 0);\n    bool usesExpressions = (flags & BinaryConsts::UsesExpressions) != 0;\n\n    if (isDeclarative) {\n      \/\/ Declared segments are needed in wasm text and binary, but not in\n      \/\/ Binaryen IR; skip over the segment\n      auto type = getU32LEB();\n      WASM_UNUSED(type);\n      auto num = getU32LEB();\n      for (Index i = 0; i < num; i++) {\n        getU32LEB();\n      }\n      continue;\n    }\n\n    auto segment = std::make_unique<ElementSegment>();\n    segment->setName(Name::fromInt(i), false);\n\n    if (!isPassive) {\n      Index tableIdx = 0;\n      if (hasTableIdx) {\n        tableIdx = getU32LEB();\n      }\n\n      Table* table = nullptr;\n      auto numTableImports = tableImports.size();\n      if (tableIdx < numTableImports) {\n        table = tableImports[tableIdx];\n      } else if (tableIdx - numTableImports < tables.size()) {\n        table = tables[tableIdx - numTableImports].get();\n      }\n      if (!table) {\n        throwError(\"Table index out of range.\");\n      }\n\n      segment->table = table->name;\n      segment->offset = readExpression();\n    }\n\n    if (isPassive || hasTableIdx) {\n      if (usesExpressions) {\n        segment->type = getType();\n        if (!segment->type.isFunction()) {\n          throwError(\"Invalid type for a usesExpressions element segment\");\n        }\n      } else {\n        auto elemKind = getU32LEB();\n        if (elemKind != 0x0) {\n          throwError(\"Invalid kind (!= funcref(0)) since !usesExpressions.\");\n        }\n      }\n    }\n\n    auto& segmentData = segment->data;\n    auto size = getU32LEB();\n    if (usesExpressions) {\n      for (Index j = 0; j < size; j++) {\n        segmentData.push_back(readExpression());\n      }\n    } else {\n      for (Index j = 0; j < size; j++) {\n        Index index = getU32LEB();\n        auto sig = getTypeByFunctionIndex(index);\n        \/\/ Use a placeholder name for now\n        auto* refFunc = Builder(wasm).makeRefFunc(Name::fromInt(index), sig);\n        functionRefs[index].push_back(refFunc);\n        segmentData.push_back(refFunc);\n      }\n    }\n\n    elementSegments.push_back(std::move(segment));\n  }\n}","target":0,"code_token_length":699,"total_token_length":935,"max_tokens_setting":1024}
+{"idx":369423,"func":"\nstatic __cold void io_ring_exit_work(struct work_struct *work)\n{\n\tstruct io_ring_ctx *ctx = container_of(work, struct io_ring_ctx, exit_work);\n\tunsigned long timeout = jiffies + HZ * 60 * 5;\n\tunsigned long interval = HZ \/ 20;\n\tstruct io_tctx_exit exit;\n\tstruct io_tctx_node *node;\n\tint ret;\n\n\t\/*\n\t * If we're doing polled IO and end up having requests being\n\t * submitted async (out-of-line), then completions can come in while\n\t * we're waiting for refs to drop. We need to reap these manually,\n\t * as nobody else will be looking for them.\n\t *\/\n\tdo {\n\t\tio_uring_try_cancel_requests(ctx, NULL, true);\n\t\tif (ctx->sq_data) {\n\t\t\tstruct io_sq_data *sqd = ctx->sq_data;\n\t\t\tstruct task_struct *tsk;\n\n\t\t\tio_sq_thread_park(sqd);\n\t\t\ttsk = sqd->thread;\n\t\t\tif (tsk && tsk->io_uring && tsk->io_uring->io_wq)\n\t\t\t\tio_wq_cancel_cb(tsk->io_uring->io_wq,\n\t\t\t\t\t\tio_cancel_ctx_cb, ctx, true);\n\t\t\tio_sq_thread_unpark(sqd);\n\t\t}\n\n\t\tio_req_caches_free(ctx);\n\n\t\tif (WARN_ON_ONCE(time_after(jiffies, timeout))) {\n\t\t\t\/* there is little hope left, don't run it too often *\/\n\t\t\tinterval = HZ * 60;\n\t\t}\n\t} while (!wait_for_completion_timeout(&ctx->ref_comp, interval));\n\n\tinit_completion(&exit.completion);\n\tinit_task_work(&exit.task_work, io_tctx_exit_cb);\n\texit.ctx = ctx;\n\t\/*\n\t * Some may use context even when all refs and requests have been put,\n\t * and they are free to do so while still holding uring_lock or\n\t * completion_lock, see io_req_task_submit(). Apart from other work,\n\t * this lock\/unlock section also waits them to finish.\n\t *\/\n\tmutex_lock(&ctx->uring_lock);\n\twhile (!list_empty(&ctx->tctx_list)) {\n\t\tWARN_ON_ONCE(time_after(jiffies, timeout));\n\n\t\tnode = list_first_entry(&ctx->tctx_list, struct io_tctx_node,\n\t\t\t\t\tctx_node);\n\t\t\/* don't spin on a single task if cancellation failed *\/\n\t\tlist_rotate_left(&ctx->tctx_list);\n\t\tret = task_work_add(node->task, &exit.task_work, TWA_SIGNAL);\n\t\tif (WARN_ON_ONCE(ret))\n\t\t\tcontinue;\n\n\t\tmutex_unlock(&ctx->uring_lock);\n\t\twait_for_completion(&exit.completion);\n\t\tmutex_lock(&ctx->uring_lock);\n\t}\n\tmutex_unlock(&ctx->uring_lock);\n\tspin_lock(&ctx->completion_lock);\n\tspin_unlock(&ctx->completion_lock);\n\n\tio_ring_ctx_free(ctx);","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":230128,"func":"int user_auth_scheme_module_validate(struct config_module * config, const struct _u_request * http_request, const char * username, json_t * j_scheme_data, void * cls) {\n  UNUSED(http_request);\n  int ret, res;\n  json_t * j_user_id, * j_assertion;\n\n  j_user_id = get_user_id_from_username(config, (json_t *)cls, username, 0);\n  if (check_result_value(j_user_id, G_OK)) {\n    j_assertion = get_assertion_from_session(config, (json_t *)cls, username, json_string_value(json_object_get(j_scheme_data, \"session\")), 0);\n    if (check_result_value(j_assertion, G_OK)) {\n      if ((res = check_assertion(config, (json_t *)cls, username, j_scheme_data, json_object_get(j_assertion, \"assertion\"))) == G_OK) {\n        ret = G_OK;\n      } else if (res == G_ERROR_UNAUTHORIZED) {\n        ret = G_ERROR_UNAUTHORIZED;\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_validate webauthn - Error check_assertion\");\n        ret = G_ERROR;\n      }\n    } else if (check_result_value(j_assertion, G_ERROR_NOT_FOUND)) {\n      ret = G_ERROR_UNAUTHORIZED;\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_register webauthn - Error get_credential\");\n      ret = G_ERROR;\n    }\n    json_decref(j_assertion);\n  } else if (check_result_value(j_user_id, G_ERROR_NOT_FOUND)) {\n    ret = G_ERROR_UNAUTHORIZED;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"user_auth_scheme_module_validate webauthn - Error get_user_id_from_username\");\n    ret = G_ERROR;\n  }\n  json_decref(j_user_id);\n\n  return ret;\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":238780,"func":"find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos)\n{\n    char_u\t*p;\n    char_u\t*delim_copy;\n    size_t\tdelim_len;\n    linenr_T\tlnum;\n    int\t\tfound = FALSE;\n\n    for (p = linep + startpos->col + 1; *p && *p != '('; ++p)\n\t;\n    delim_len = (p - linep) - startpos->col - 1;\n    delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len);\n    if (delim_copy == NULL)\n\treturn FALSE;\n    for (lnum = startpos->lnum; lnum <= endpos->lnum; ++lnum)\n    {\n\tchar_u *line = ml_get(lnum);\n\n\tfor (p = line + (lnum == startpos->lnum\n\t\t\t\t\t    ? startpos->col + 1 : 0); *p; ++p)\n\t{\n\t    if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col)\n\t\tbreak;\n\t    if (*p == ')' && STRNCMP(delim_copy, p + 1, delim_len) == 0\n\t\t\t  && p[delim_len + 1] == '\"')\n\t    {\n\t\tfound = TRUE;\n\t\tbreak;\n\t    }\n\t}\n\tif (found)\n\t    break;\n    }\n    vim_free(delim_copy);\n    return found;\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":257689,"func":"TRIGGER_FUNC(mod_wstunnel_handle_trigger) {\n    const plugin_data * const p = p_d;\n    const unix_time64_t cur_ts = log_monotonic_secs + 1;\n\n    gw_handle_trigger(srv, p_d);\n\n    for (connection *con = srv->conns; con; con = con->next) {\n        request_st * const r = &con->request;\n        handler_ctx *hctx = r->plugin_ctx[p->id];\n        if (NULL == hctx || r->handler_module != p->self)\n            continue;\n\n        if (hctx->gw.state != GW_STATE_WRITE && hctx->gw.state != GW_STATE_READ)\n            continue;\n\n        if (cur_ts - con->read_idle_ts > r->conf.max_read_idle) {\n            DEBUG_LOG_INFO(\"timeout client (fd=%d)\", con->fd);\n            mod_wstunnel_frame_send(hctx,MOD_WEBSOCKET_FRAME_TYPE_CLOSE,NULL,0);\n            gw_handle_request_reset(r, p_d);\n            joblist_append(con);\n            \/* avoid server.c closing connection with error due to max_read_idle\n             * (might instead run joblist after plugins_call_handle_trigger())*\/\n            con->read_idle_ts = cur_ts;\n            continue;\n        }\n\n        if (0 != hctx->hybivers\n            && hctx->conf.ping_interval > 0\n            && (int32_t)hctx->conf.ping_interval + hctx->ping_ts < cur_ts) {\n            hctx->ping_ts = cur_ts;\n            mod_wstunnel_frame_send(hctx, MOD_WEBSOCKET_FRAME_TYPE_PING, CONST_STR_LEN(\"ping\"));\n            joblist_append(con);\n            continue;\n        }\n    }\n\n    return HANDLER_GO_ON;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":255035,"func":"static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)\n{\n    ADTSContext *adts = s->priv_data;\n    AVCodecParameters *par = s->streams[0]->codecpar;\n    AVIOContext *pb = s->pb;\n    uint8_t buf[ADTS_HEADER_SIZE];\n\n    if (!pkt->size)\n        return 0;\n    if (!par->extradata_size) {\n        uint8_t *side_data;\n        size_t side_data_size;\n        int ret;\n\n        side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,\n                                            &side_data_size);\n        if (side_data_size) {\n            ret = adts_decode_extradata(s, adts, side_data, side_data_size);\n            if (ret < 0)\n                return ret;\n            ret = ff_alloc_extradata(par, side_data_size);\n            if (ret < 0)\n                return ret;\n            memcpy(par->extradata, side_data, side_data_size);\n        }\n    }\n    if (adts->write_adts) {\n        int err = adts_write_frame_header(adts, buf, pkt->size,\n                                             adts->pce_size);\n        if (err < 0)\n            return err;\n        avio_write(pb, buf, ADTS_HEADER_SIZE);\n        if (adts->pce_size) {\n            avio_write(pb, adts->pce_data, adts->pce_size);\n            adts->pce_size = 0;\n        }\n    }\n    avio_write(pb, pkt->data, pkt->size);\n\n    return 0;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":293504,"func":"ins_compl_add_tv(typval_T *tv, int dir, int fast)\n{\n    char_u\t*word;\n    int\t\tdup = FALSE;\n    int\t\tempty = FALSE;\n    int\t\tflags = fast ? CP_FAST : 0;\n    char_u\t*(cptext[CPT_COUNT]);\n    typval_T\tuser_data;\n    int\t\tstatus;\n\n    user_data.v_type = VAR_UNKNOWN;\n    if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)\n    {\n\tword = dict_get_string(tv->vval.v_dict, (char_u *)\"word\", FALSE);\n\tcptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict,\n\t\t\t\t\t\t     (char_u *)\"abbr\", FALSE);\n\tcptext[CPT_MENU] = dict_get_string(tv->vval.v_dict,\n\t\t\t\t\t\t     (char_u *)\"menu\", FALSE);\n\tcptext[CPT_KIND] = dict_get_string(tv->vval.v_dict,\n\t\t\t\t\t\t     (char_u *)\"kind\", FALSE);\n\tcptext[CPT_INFO] = dict_get_string(tv->vval.v_dict,\n\t\t\t\t\t\t     (char_u *)\"info\", FALSE);\n\tdict_get_tv(tv->vval.v_dict, (char_u *)\"user_data\", &user_data);\n\tif (dict_get_string(tv->vval.v_dict, (char_u *)\"icase\", FALSE) != NULL\n\t\t\t&& dict_get_number(tv->vval.v_dict, (char_u *)\"icase\"))\n\t    flags |= CP_ICASE;\n\tif (dict_get_string(tv->vval.v_dict, (char_u *)\"dup\", FALSE) != NULL)\n\t    dup = dict_get_number(tv->vval.v_dict, (char_u *)\"dup\");\n\tif (dict_get_string(tv->vval.v_dict, (char_u *)\"empty\", FALSE) != NULL)\n\t    empty = dict_get_number(tv->vval.v_dict, (char_u *)\"empty\");\n\tif (dict_get_string(tv->vval.v_dict, (char_u *)\"equal\", FALSE) != NULL\n\t\t\t&& dict_get_number(tv->vval.v_dict, (char_u *)\"equal\"))\n\t    flags |= CP_EQUAL;\n    }\n    else\n    {\n\tword = tv_get_string_chk(tv);\n\tCLEAR_FIELD(cptext);\n    }\n    if (word == NULL || (!empty && *word == NUL))\n    {\n\tclear_tv(&user_data);\n\treturn FAIL;\n    }\n    status = ins_compl_add(word, -1, NULL, cptext, &user_data, dir, flags, dup);\n    if (status != OK)\n\tclear_tv(&user_data);\n    return status;\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":345222,"func":"static int con_unify_unimap(struct vc_data *conp, struct uni_pagedir *p)\n{\n\tint i, j, k;\n\tstruct uni_pagedir *q;\n\t\n\tfor (i = 0; i < MAX_NR_CONSOLES; i++) {\n\t\tif (!vc_cons_allocated(i))\n\t\t\tcontinue;\n\t\tq = *vc_cons[i].d->vc_uni_pagedir_loc;\n\t\tif (!q || q == p || q->sum != p->sum)\n\t\t\tcontinue;\n\t\tfor (j = 0; j < 32; j++) {\n\t\t\tu16 **p1, **q1;\n\t\t\tp1 = p->uni_pgdir[j]; q1 = q->uni_pgdir[j];\n\t\t\tif (!p1 && !q1)\n\t\t\t\tcontinue;\n\t\t\tif (!p1 || !q1)\n\t\t\t\tbreak;\n\t\t\tfor (k = 0; k < 32; k++) {\n\t\t\t\tif (!p1[k] && !q1[k])\n\t\t\t\t\tcontinue;\n\t\t\t\tif (!p1[k] || !q1[k])\n\t\t\t\t\tbreak;\n\t\t\t\tif (memcmp(p1[k], q1[k], 64*sizeof(u16)))\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (k < 32)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == 32) {\n\t\t\tq->refcount++;\n\t\t\t*conp->vc_uni_pagedir_loc = q;\n\t\t\tcon_release_unimap(p);\n\t\t\tkfree(p);\n\t\t\treturn 1;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":335416,"func":"expand_sfile(char_u *arg)\n{\n    char\t*errormsg;\n    int\t\tlen;\n    char_u\t*result;\n    char_u\t*newres;\n    char_u\t*repl;\n    int\t\tsrclen;\n    char_u\t*p;\n\n    result = vim_strsave(arg);\n    if (result == NULL)\n\treturn NULL;\n\n    for (p = result; *p; )\n    {\n\tif (STRNCMP(p, \"<sfile>\", 7) != 0)\n\t    ++p;\n\telse\n\t{\n\t    \/\/ replace \"<sfile>\" with the sourced file name, and do \":\" stuff\n\t    repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL, TRUE);\n\t    if (errormsg != NULL)\n\t    {\n\t\tif (*errormsg)\n\t\t    emsg(errormsg);\n\t\tvim_free(result);\n\t\treturn NULL;\n\t    }\n\t    if (repl == NULL)\t\t\/\/ no match (cannot happen)\n\t    {\n\t\tp += srclen;\n\t\tcontinue;\n\t    }\n\t    len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1;\n\t    newres = alloc(len);\n\t    if (newres == NULL)\n\t    {\n\t\tvim_free(repl);\n\t\tvim_free(result);\n\t\treturn NULL;\n\t    }\n\t    mch_memmove(newres, result, (size_t)(p - result));\n\t    STRCPY(newres + (p - result), repl);\n\t    len = (int)STRLEN(newres);\n\t    STRCAT(newres, p + srclen);\n\t    vim_free(repl);\n\t    vim_free(result);\n\t    result = newres;\n\t    p = newres + len;\t\t\/\/ continue after the match\n\t}\n    }\n\n    return result;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":346465,"func":"get_new_scriptitem(int *error)\n{\n    static scid_T   last_current_SID = 0;\n    int\t\t    sid = ++last_current_SID;\n    scriptitem_T    *si = NULL;\n\n    if (ga_grow(&script_items, (int)(sid - script_items.ga_len)) == FAIL)\n    {\n\t*error = FAIL;\n\treturn sid;\n    }\n    while (script_items.ga_len < sid)\n    {\n\tsi = ALLOC_CLEAR_ONE(scriptitem_T);\n\tif (si == NULL)\n\t{\n\t    *error = FAIL;\n\t    return sid;\n\t}\n\t++script_items.ga_len;\n\tSCRIPT_ITEM(script_items.ga_len) = si;\n\tsi->sn_name = NULL;\n\tsi->sn_version = 1;\n\n\t\/\/ Allocate the local script variables to use for this script.\n\tnew_script_vars(script_items.ga_len);\n\tga_init2(&si->sn_var_vals, sizeof(svar_T), 10);\n\thash_init(&si->sn_all_vars.dv_hashtab);\n\tga_init2(&si->sn_imports, sizeof(imported_T), 10);\n\tga_init2(&si->sn_type_list, sizeof(type_T), 10);\n# ifdef FEAT_PROFILE\n\tsi->sn_prof_on = FALSE;\n# endif\n    }\n\n    \/\/ \"si\" can't be NULL, check only to avoid a compiler warning\n    if (si != NULL)\n\t\/\/ Used to check script variable index is still valid.\n\tsi->sn_script_seq = current_sctx.sc_seq;\n\n    return sid;\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":264236,"func":"static int vnc_update_client(VncState *vs, int has_dirty, bool sync)\n{\n    if (vs->need_update && vs->csock != -1) {\n        VncDisplay *vd = vs->vd;\n        VncJob *job;\n        int y;\n        int height, width;\n        int n = 0;\n\n        if (vs->output.offset && !vs->audio_cap && !vs->force_update)\n            \/* kernel send buffers are full -> drop frames to throttle *\/\n            return 0;\n\n        if (!has_dirty && !vs->audio_cap && !vs->force_update)\n            return 0;\n\n        \/*\n         * Send screen updates to the vnc client using the server\n         * surface and server dirty map.  guest surface updates\n         * happening in parallel don't disturb us, the next pass will\n         * send them to the client.\n         *\/\n        job = vnc_job_new(vs);\n\n        height = MIN(pixman_image_get_height(vd->server), vs->client_height);\n        width = MIN(pixman_image_get_width(vd->server), vs->client_width);\n\n        y = 0;\n        for (;;) {\n            int x, h;\n            unsigned long x2;\n            unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,\n                                                 height * VNC_DIRTY_BPL(vs),\n                                                 y * VNC_DIRTY_BPL(vs));\n            if (offset == height * VNC_DIRTY_BPL(vs)) {\n                \/* no more dirty bits *\/\n                break;\n            }\n            y = offset \/ VNC_DIRTY_BPL(vs);\n            x = offset % VNC_DIRTY_BPL(vs);\n            x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],\n                                    VNC_DIRTY_BPL(vs), x);\n            bitmap_clear(vs->dirty[y], x, x2 - x);\n            h = find_and_clear_dirty_height(vs, y, x, x2, height);\n            x2 = MIN(x2, width \/ VNC_DIRTY_PIXELS_PER_BIT);\n            if (x2 > x) {\n                n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,\n                                      (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);\n            }\n        }\n\n        vnc_job_push(job);\n        if (sync) {\n            vnc_jobs_join(vs);\n        }\n        vs->force_update = 0;\n        return n;\n    }\n\n    if (vs->csock == -1) {\n        vnc_disconnect_finish(vs);\n    } else if (sync) {\n        vnc_jobs_join(vs);\n    }\n\n    return 0;\n}","target":0,"code_token_length":567,"total_token_length":803,"max_tokens_setting":1024}
+{"idx":436161,"func":"\nstatic int __io_sqe_files_update(struct io_ring_ctx *ctx,\n\t\t\t\t struct io_uring_rsrc_update2 *up,\n\t\t\t\t unsigned nr_args)\n{\n\tu64 __user *tags = u64_to_user_ptr(up->tags);\n\t__s32 __user *fds = u64_to_user_ptr(up->data);\n\tstruct io_rsrc_data *data = ctx->file_data;\n\tstruct io_fixed_file *file_slot;\n\tstruct file *file;\n\tint fd, i, err = 0;\n\tunsigned int done;\n\tbool needs_switch = false;\n\n\tif (!ctx->file_data)\n\t\treturn -ENXIO;\n\tif (up->offset + nr_args > ctx->nr_user_files)\n\t\treturn -EINVAL;\n\n\tfor (done = 0; done < nr_args; done++) {\n\t\tu64 tag = 0;\n\n\t\tif ((tags && copy_from_user(&tag, &tags[done], sizeof(tag))) ||\n\t\t    copy_from_user(&fd, &fds[done], sizeof(fd))) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\tif ((fd == IORING_REGISTER_FILES_SKIP || fd == -1) && tag) {\n\t\t\terr = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\tif (fd == IORING_REGISTER_FILES_SKIP)\n\t\t\tcontinue;\n\n\t\ti = array_index_nospec(up->offset + done, ctx->nr_user_files);\n\t\tfile_slot = io_fixed_file_slot(&ctx->file_table, i);\n\n\t\tif (file_slot->file_ptr) {\n\t\t\tfile = (struct file *)(file_slot->file_ptr & FFS_MASK);\n\t\t\terr = io_queue_rsrc_removal(data, up->offset + done,\n\t\t\t\t\t\t    ctx->rsrc_node, file);\n\t\t\tif (err)\n\t\t\t\tbreak;\n\t\t\tfile_slot->file_ptr = 0;\n\t\t\tneeds_switch = true;\n\t\t}\n\t\tif (fd != -1) {\n\t\t\tfile = fget(fd);\n\t\t\tif (!file) {\n\t\t\t\terr = -EBADF;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\/*\n\t\t\t * Don't allow io_uring instances to be registered. If\n\t\t\t * UNIX isn't enabled, then this causes a reference\n\t\t\t * cycle and this instance can never get freed. If UNIX\n\t\t\t * is enabled we'll handle it just fine, but there's\n\t\t\t * still no point in allowing a ring fd as it doesn't\n\t\t\t * support regular read\/write anyway.\n\t\t\t *\/\n\t\t\tif (file->f_op == &io_uring_fops) {\n\t\t\t\tfput(file);\n\t\t\t\terr = -EBADF;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t*io_get_tag_slot(data, up->offset + done) = tag;\n\t\t\tio_fixed_file_set(file_slot, file);\n\t\t\terr = io_sqe_file_register(ctx, file, i);\n\t\t\tif (err) {\n\t\t\t\tfile_slot->file_ptr = 0;\n\t\t\t\tfput(file);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (needs_switch)\n\t\tio_rsrc_node_switch(ctx, data);\n\treturn done ? done : err;","target":0,"code_token_length":640,"total_token_length":876,"max_tokens_setting":1024}
+{"idx":365761,"func":"static int sixpack_ioctl(struct tty_struct *tty, unsigned int cmd,\n\t\tunsigned long arg)\n{\n\tstruct sixpack *sp = sp_get(tty);\n\tstruct net_device *dev;\n\tunsigned int tmp, err;\n\n\tif (!sp)\n\t\treturn -ENXIO;\n\tdev = sp->dev;\n\n\tswitch(cmd) {\n\tcase SIOCGIFNAME:\n\t\terr = copy_to_user((void __user *) arg, dev->name,\n\t\t                   strlen(dev->name) + 1) ? -EFAULT : 0;\n\t\tbreak;\n\n\tcase SIOCGIFENCAP:\n\t\terr = put_user(0, (int __user *) arg);\n\t\tbreak;\n\n\tcase SIOCSIFENCAP:\n\t\tif (get_user(tmp, (int __user *) arg)) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tsp->mode = tmp;\n\t\tdev->addr_len        = AX25_ADDR_LEN;\n\t\tdev->hard_header_len = AX25_KISS_HEADER_LEN +\n\t\t                       AX25_MAX_HEADER_LEN + 3;\n\t\tdev->type            = ARPHRD_AX25;\n\n\t\terr = 0;\n\t\tbreak;\n\n\tcase SIOCSIFHWADDR: {\n\t\t\tchar addr[AX25_ADDR_LEN];\n\n\t\t\tif (copy_from_user(&addr,\n\t\t\t\t\t   (void __user *)arg, AX25_ADDR_LEN)) {\n\t\t\t\terr = -EFAULT;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tnetif_tx_lock_bh(dev);\n\t\t\t__dev_addr_set(dev, &addr, AX25_ADDR_LEN);\n\t\t\tnetif_tx_unlock_bh(dev);\n\t\t\terr = 0;\n\t\t\tbreak;\n\t\t}\n\tdefault:\n\t\terr = tty_mode_ioctl(tty, cmd, arg);\n\t}\n\n\tsp_put(sp);\n\n\treturn err;\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":344739,"func":"parse_absolute_time(const char *s, uint64_t *tp)\n{\n\tstruct tm tm;\n\ttime_t tt;\n\tchar buf[32], *fmt;\n\n\t*tp = 0;\n\n\t\/*\n\t * POSIX strptime says \"The application shall ensure that there\n\t * is white-space or other non-alphanumeric characters between\n\t * any two conversion specifications\" so arrange things this way.\n\t *\/\n\tswitch (strlen(s)) {\n\tcase 8: \/* YYYYMMDD *\/\n\t\tfmt = \"%Y-%m-%d\";\n\t\tsnprintf(buf, sizeof(buf), \"%.4s-%.2s-%.2s\", s, s + 4, s + 6);\n\t\tbreak;\n\tcase 12: \/* YYYYMMDDHHMM *\/\n\t\tfmt = \"%Y-%m-%dT%H:%M\";\n\t\tsnprintf(buf, sizeof(buf), \"%.4s-%.2s-%.2sT%.2s:%.2s\",\n\t\t    s, s + 4, s + 6, s + 8, s + 10);\n\t\tbreak;\n\tcase 14: \/* YYYYMMDDHHMMSS *\/\n\t\tfmt = \"%Y-%m-%dT%H:%M:%S\";\n\t\tsnprintf(buf, sizeof(buf), \"%.4s-%.2s-%.2sT%.2s:%.2s:%.2s\",\n\t\t    s, s + 4, s + 6, s + 8, s + 10, s + 12);\n\t\tbreak;\n\tdefault:\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\t}\n\n\tmemset(&tm, 0, sizeof(tm));\n\tif (strptime(buf, fmt, &tm) == NULL)\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\tif ((tt = mktime(&tm)) < 0)\n\t\treturn SSH_ERR_INVALID_FORMAT;\n\t\/* success *\/\n\t*tp = (uint64_t)tt;\n\treturn 0;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":252394,"func":"static mz_bool mz_zip_writer_create_central_dir_header(\n    mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size,\n    mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size,\n    mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method,\n    mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,\n    mz_uint64 local_header_ofs, mz_uint32 ext_attributes) {\n  (void)pZip;\n  memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs);\n  return MZ_TRUE;\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":273886,"func":"static void do_PORT(ctrl_t *ctrl, int pending)\n{\n\tif (!ctrl->data_address[0]) {\n\t\t\/* Check if previous command was PASV *\/\n\t\tif (ctrl->data_sd == -1 && ctrl->data_listen_sd == -1) {\n\t\t\tif (pending == 1 && ctrl->d_num == -1)\n\t\t\t\tdo_MLST(ctrl);\n\t\t\treturn;\n\t\t}\n\n\t\tctrl->pending = pending;\n\t\treturn;\n\t}\n\n\tif (open_data_connection(ctrl)) {\n\t\tdo_abort(ctrl);\n\t\tsend_msg(ctrl->sd, \"425 TCP connection cannot be established.\\r\\n\");\n\t\treturn;\n\t}\n\n\tif (pending != 1 || ctrl->list_mode != 2)\n\t\tsend_msg(ctrl->sd, \"150 Data connection opened; transfer starting.\\r\\n\");\n\n\tswitch (pending) {\n\tcase 3:\n\t\tuev_io_init(ctrl->ctx, &ctrl->data_watcher, do_STOR, ctrl, ctrl->data_sd, UEV_READ);\n\t\tbreak;\n\n\tcase 2:\n\t\tuev_io_init(ctrl->ctx, &ctrl->data_watcher, do_RETR, ctrl, ctrl->data_sd, UEV_WRITE);\n\t\tbreak;\n\n\tcase 1:\n\t\tuev_io_init(ctrl->ctx, &ctrl->data_watcher, do_LIST, ctrl, ctrl->data_sd, UEV_WRITE);\n\t\tbreak;\n\t}\n\n\tctrl->pending = 0;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":196698,"func":"void SparseFillEmptyRowsOpImpl(OpKernelContext* context,\n                               AsyncOpKernel::DoneCallback done = nullptr) {\n  \/\/ Note that setting this empty lambda as the default parameter value directly\n  \/\/ can cause strange compiler\/linker errors, so we do it like this instead.\n  if (!done) {\n    done = [] {};\n  }\n\n  const int kIndicesInput = 0;\n  const int kValuesInput = 1;\n  const int kDenseShapeInput = 2;\n  const int kDefaultValueInput = 3;\n\n  const Tensor& indices_t = context->input(kIndicesInput);\n  const Tensor& values_t = context->input(kValuesInput);\n  const Tensor& dense_shape_t = context->input(kDenseShapeInput);\n  const Tensor& default_value_t = context->input(kDefaultValueInput);\n\n  OP_REQUIRES_ASYNC(\n      context, TensorShapeUtils::IsVector(dense_shape_t.shape()),\n      errors::InvalidArgument(\"dense_shape must be a vector, saw: \",\n                              dense_shape_t.shape().DebugString()),\n      done);\n  OP_REQUIRES_ASYNC(context, TensorShapeUtils::IsMatrix(indices_t.shape()),\n                    errors::InvalidArgument(\"indices must be a matrix, saw: \",\n                                            indices_t.shape().DebugString()),\n                    done);\n  OP_REQUIRES_ASYNC(context, TensorShapeUtils::IsVector(values_t.shape()),\n                    errors::InvalidArgument(\"values must be a vector, saw: \",\n                                            values_t.shape().DebugString()),\n                    done);\n  OP_REQUIRES_ASYNC(\n      context, TensorShapeUtils::IsScalar(default_value_t.shape()),\n      errors::InvalidArgument(\"default_value must be a scalar, saw: \",\n                              default_value_t.shape().DebugString()),\n      done);\n  \/\/ TODO(ebrevdo): add shape checks between values, indices,\n  \/\/ Also add check that dense rank > 0.\n  OP_REQUIRES_ASYNC(context, dense_shape_t.NumElements() != 0,\n                    errors::InvalidArgument(\"Dense shape cannot be empty.\"),\n                    done);\n\n  using FunctorType = functor::SparseFillEmptyRows<Device, T, Tindex>;\n  OP_REQUIRES_OK_ASYNC(context,\n                       FunctorType()(context, default_value_t, indices_t,\n                                     values_t, dense_shape_t, done),\n                       done);\n}","target":1,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":369293,"func":"static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter)\n{\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tstruct file *file = req->file;\n\tssize_t ret = 0;\n\tloff_t *ppos;\n\n\t\/*\n\t * Don't support polled IO through this interface, and we can't\n\t * support non-blocking either. For the latter, this just causes\n\t * the kiocb to be handled from an async context.\n\t *\/\n\tif (kiocb->ki_flags & IOCB_HIPRI)\n\t\treturn -EOPNOTSUPP;\n\tif ((kiocb->ki_flags & IOCB_NOWAIT) &&\n\t    !(kiocb->ki_filp->f_flags & O_NONBLOCK))\n\t\treturn -EAGAIN;\n\n\tppos = io_kiocb_ppos(kiocb);\n\n\twhile (iov_iter_count(iter)) {\n\t\tstruct iovec iovec;\n\t\tssize_t nr;\n\n\t\tif (!iov_iter_is_bvec(iter)) {\n\t\t\tiovec = iov_iter_iovec(iter);\n\t\t} else {\n\t\t\tiovec.iov_base = u64_to_user_ptr(req->rw.addr);\n\t\t\tiovec.iov_len = req->rw.len;\n\t\t}\n\n\t\tif (rw == READ) {\n\t\t\tnr = file->f_op->read(file, iovec.iov_base,\n\t\t\t\t\t      iovec.iov_len, ppos);\n\t\t} else {\n\t\t\tnr = file->f_op->write(file, iovec.iov_base,\n\t\t\t\t\t       iovec.iov_len, ppos);\n\t\t}\n\n\t\tif (nr < 0) {\n\t\t\tif (!ret)\n\t\t\t\tret = nr;\n\t\t\tbreak;\n\t\t}\n\t\tret += nr;\n\t\tif (!iov_iter_is_bvec(iter)) {\n\t\t\tiov_iter_advance(iter, nr);\n\t\t} else {\n\t\t\treq->rw.addr += nr;\n\t\t\treq->rw.len -= nr;\n\t\t\tif (!req->rw.len)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (nr != iovec.iov_len)\n\t\t\tbreak;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":232340,"func":"GF_Err GetNextMediaTime(GF_TrackBox *trak, u64 movieTime, u64 *OutMovieTime)\n{\n\tu32 i;\n\tu64 time;\n\tGF_EdtsEntry *ent;\n\n\t*OutMovieTime = 0;\n\tif (! trak->editBox || !trak->editBox->editList) return GF_BAD_PARAM;\n\n\ttime = 0;\n\tent = NULL;\n\ti=0;\n\twhile ((ent = (GF_EdtsEntry *)gf_list_enum(trak->editBox->editList->entryList, &i))) {\n\t\tif (gf_timestamp_greater_or_equal(time, trak->moov->mvhd->timeScale, movieTime, trak->Media->mediaHeader->timeScale)) {\n\t\t\t\/*skip empty edits*\/\n\t\t\tif (ent->mediaTime >= 0) {\n\t\t\t\t*OutMovieTime = time * trak->Media->mediaHeader->timeScale \/ trak->moov->mvhd->timeScale;\n\t\t\t\tif (*OutMovieTime>0) *OutMovieTime -= 1;\n\t\t\t\treturn GF_OK;\n\t\t\t}\n\t\t}\n\t\ttime += ent->segmentDuration;\n\t}\n\t\/\/request for a bigger time that what we can give: return the last sample (undefined behavior...)\n\t*OutMovieTime = trak->moov->mvhd->duration;\n\treturn GF_EOS;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":336608,"func":"static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)\n{\n    RedChannel *channel;\n    RedClient *client = NULL;\n    SpiceLinkMess *link_mess;\n    RedsMigTargetClient *mig_client;\n\n    link_mess = link->link_mess;\n    if (reds->main_channel) {\n        client = reds->main_channel->get_client_by_link_id(link_mess->connection_id);\n    }\n\n    \/\/ TODO: MC: broke migration (at least for the dont-drop-connection kind).\n    \/\/ On migration we should get a connection_id to expect (must be a security measure)\n    \/\/ where do we store it? on reds, but should be a list (MC).\n    if (!client) {\n        reds_send_link_result(link, SPICE_LINK_ERR_BAD_CONNECTION_ID);\n        return;\n    }\n\n    \/\/ TODO: MC: be less lenient. Tally connections from same connection_id (by same client).\n    if (!(channel = reds_find_channel(reds, link_mess->channel_type,\n                                      link_mess->channel_id))) {\n        reds_send_link_result(link, SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE);\n        return;\n    }\n\n    reds_send_link_result(link, SPICE_LINK_ERR_OK);\n    reds_info_new_channel(link, link_mess->connection_id);\n\n    mig_client = reds_mig_target_client_find(reds, client);\n    \/*\n     * In semi-seamless migration, we activate the channels only\n     * after migration is completed. Since, the session starts almost from\n     * scratch we don't mind if we skip some messages in between the src session end and\n     * dst session start.\n     * In seamless migration, in order to keep the continuousness of the session, and\n     * in order not to lose any data, we activate the target channels before\n     * migration completes, as soon as we receive SPICE_MSGC_MAIN_MIGRATE_DST_DO_SEAMLESS.\n     * If a channel connects before receiving SPICE_MSGC_MAIN_MIGRATE_DST_DO_SEAMLESS,\n     * reds_on_migrate_dst_set_seamless will take care of activating it *\/\n    if (client->during_migrate_at_target() && !reds->dst_do_seamless_migrate) {\n        spice_assert(mig_client);\n        reds_mig_target_client_add_pending_link(mig_client, link_mess, link->stream);\n        link->link_mess = NULL;\n    } else {\n        spice_assert(!mig_client);\n        reds_channel_do_link(channel, client, link_mess, link->stream);\n    }\n    link->stream = NULL;\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":400106,"func":"PortForwardSourceResponse PortForwardHandler::createSource(\n    const PortForwardSourceRequest& pfsr, string* sourceName, uid_t userid,\n    gid_t groupid) {\n  try {\n    if (pfsr.has_source() && sourceName) {\n      throw runtime_error(\n          \"Do not set a source when forwarding named pipes with environment \"\n          \"variables\");\n    }\n    SocketEndpoint source;\n    if (pfsr.has_source()) {\n      source = pfsr.source();\n      if (source.has_name()) {\n        throw runtime_error(\n            \"Named socket tunneling is only allowed with temporary filenames.\");\n      }\n    } else {\n      \/\/ Make a random file to forward the pipe\n      string sourcePattern =\n          GetTempDirectory() + string(\"et_forward_sock_XXXXXX\");\n      string sourceDirectory = string(mkdtemp(&sourcePattern[0]));\n      FATAL_FAIL(::chmod(sourceDirectory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR));\n      FATAL_FAIL(::chown(sourceDirectory.c_str(), userid, groupid));\n      string sourcePath = string(sourceDirectory) + \"\/sock\";\n\n      source.set_name(sourcePath);\n      if (sourceName == nullptr) {\n        STFATAL\n            << \"Tried to create a pipe but without a place to put the name!\";\n      }\n      *sourceName = sourcePath;\n      LOG(INFO) << \"Creating pipe at \" << sourcePath;\n    }\n    if (pfsr.source().has_port()) {\n      if (sourceName != nullptr) {\n        STFATAL << \"Tried to create a port forward but with a place to put \"\n                   \"the name!\";\n      }\n      auto handler = shared_ptr<ForwardSourceHandler>(new ForwardSourceHandler(\n          networkSocketHandler, source, pfsr.destination()));\n      sourceHandlers.push_back(handler);\n      return PortForwardSourceResponse();\n    } else {\n      if (userid < 0 || groupid < 0) {\n        STFATAL\n            << \"Tried to create a unix socket forward with no userid\/groupid\";\n      }\n      auto handler = shared_ptr<ForwardSourceHandler>(new ForwardSourceHandler(\n          pipeSocketHandler, source, pfsr.destination()));\n      FATAL_FAIL(::chmod(source.name().c_str(), S_IRUSR | S_IWUSR | S_IXUSR));\n      FATAL_FAIL(::chown(source.name().c_str(), userid, groupid));\n      sourceHandlers.push_back(handler);\n      return PortForwardSourceResponse();\n    }\n  } catch (const std::runtime_error& ex) {\n    PortForwardSourceResponse pfsr;\n    pfsr.set_error(ex.what());\n    return pfsr;\n  }\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":254712,"func":"njs_typed_array_of(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    double             num;\n    uint32_t           length, i;\n    njs_int_t          ret;\n    njs_value_t        *this;\n    njs_value_t        argument;\n    njs_typed_array_t  *array;\n\n    this = njs_argument(args, 0);\n\n    if (njs_slow_path(!njs_is_constructor(this))) {\n        njs_type_error(vm, \"%s is not a constructor\",\n                       njs_type_string(this->type));\n        return NJS_ERROR;\n    }\n\n    length = nargs - 1;\n\n    njs_set_number(&argument, length);\n    ret = njs_typed_array_create(vm, this, &argument, 1, &vm->retval);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(&vm->retval);\n\n    for (i = 0; i < length; i++) {\n        ret = njs_value_to_number(vm, njs_argument(args, i + 1), &num);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NJS_ERROR;\n        }\n\n        njs_typed_array_prop_set(vm, array, i, num);\n    }\n\n    njs_set_typed_array(&vm->retval, array);\n\n    return NJS_OK;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":202888,"func":"int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)\n{\n\tu8 *tail;\n\tint nfrags;\n\tint esph_offset;\n\tstruct page *page;\n\tstruct sk_buff *trailer;\n\tint tailen = esp->tailen;\n\n\t\/* this is non-NULL only with TCP\/UDP Encapsulation *\/\n\tif (x->encap) {\n\t\tint err = esp_output_encap(x, skb, esp);\n\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\tif (!skb_cloned(skb)) {\n\t\tif (tailen <= skb_tailroom(skb)) {\n\t\t\tnfrags = 1;\n\t\t\ttrailer = skb;\n\t\t\ttail = skb_tail_pointer(trailer);\n\n\t\t\tgoto skip_cow;\n\t\t} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)\n\t\t\t   && !skb_has_frag_list(skb)) {\n\t\t\tint allocsize;\n\t\t\tstruct sock *sk = skb->sk;\n\t\t\tstruct page_frag *pfrag = &x->xfrag;\n\n\t\t\tesp->inplace = false;\n\n\t\t\tallocsize = ALIGN(tailen, L1_CACHE_BYTES);\n\n\t\t\tspin_lock_bh(&x->lock);\n\n\t\t\tif (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {\n\t\t\t\tspin_unlock_bh(&x->lock);\n\t\t\t\tgoto cow;\n\t\t\t}\n\n\t\t\tpage = pfrag->page;\n\t\t\tget_page(page);\n\n\t\t\ttail = page_address(page) + pfrag->offset;\n\n\t\t\tesp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);\n\n\t\t\tnfrags = skb_shinfo(skb)->nr_frags;\n\n\t\t\t__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,\n\t\t\t\t\t     tailen);\n\t\t\tskb_shinfo(skb)->nr_frags = ++nfrags;\n\n\t\t\tpfrag->offset = pfrag->offset + allocsize;\n\n\t\t\tspin_unlock_bh(&x->lock);\n\n\t\t\tnfrags++;\n\n\t\t\tskb->len += tailen;\n\t\t\tskb->data_len += tailen;\n\t\t\tskb->truesize += tailen;\n\t\t\tif (sk && sk_fullsock(sk))\n\t\t\t\trefcount_add(tailen, &sk->sk_wmem_alloc);\n\n\t\t\tgoto out;\n\t\t}\n\t}\n\ncow:\n\tesph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);\n\n\tnfrags = skb_cow_data(skb, tailen, &trailer);\n\tif (nfrags < 0)\n\t\tgoto out;\n\ttail = skb_tail_pointer(trailer);\n\tesp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);\n\nskip_cow:\n\tesp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);\n\tpskb_put(skb, trailer, tailen);\n\nout:\n\treturn nfrags;\n}","target":1,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":215921,"func":"bmexec_trans (kwset_t kwset, char const *text, size_t size)\n{\n  unsigned char const *d1;\n  char const *ep, *sp, *tp;\n  int d;\n  int len = kwset->mind;\n  char const *trans = kwset->trans;\n\n  if (len == 0)\n    return 0;\n  if (len > size)\n    return -1;\n  if (len == 1)\n    {\n      tp = memchr_kwset (text, size, kwset);\n      return tp ? tp - text : -1;\n    }\n\n  d1 = kwset->delta;\n  sp = kwset->target + len;\n  tp = text + len;\n  char gc1 = kwset->gc1;\n  char gc2 = kwset->gc2;\n\n  \/* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). *\/\n  if (size > 12 * len)\n    \/* 11 is not a bug, the initial offset happens only once. *\/\n    for (ep = text + size - 11 * len; tp <= ep; )\n      {\n        char const *tp0 = tp;\n        d = d1[U(tp[-1])], tp += d;\n        d = d1[U(tp[-1])], tp += d;\n        if (d != 0)\n          {\n            d = d1[U(tp[-1])], tp += d;\n            d = d1[U(tp[-1])], tp += d;\n            d = d1[U(tp[-1])], tp += d;\n            if (d != 0)\n              {\n                d = d1[U(tp[-1])], tp += d;\n                d = d1[U(tp[-1])], tp += d;\n                d = d1[U(tp[-1])], tp += d;\n                if (d != 0)\n                  {\n                    d = d1[U(tp[-1])], tp += d;\n                    d = d1[U(tp[-1])], tp += d;\n\n                    \/* As a heuristic, prefer memchr to seeking by\n                       delta1 when the latter doesn't advance much.  *\/\n                    int advance_heuristic = 16 * sizeof (long);\n                    if (advance_heuristic <= tp - tp0)\n                      goto big_advance;\n                    tp--;\n                    tp = memchr_kwset (tp, text + size - tp, kwset);\n                    if (! tp)\n                      return -1;\n                    tp++;\n                  }\n              }\n          }\n        if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, d1, kwset))\n          return tp - text;\n      big_advance:;\n      }\n\n  \/* Now we have only a few characters left to search.  We\n     carefully avoid ever producing an out-of-bounds pointer. *\/\n  ep = text + size;\n  d = d1[U(tp[-1])];\n  while (d <= ep - tp)\n    {\n      d = d1[U((tp += d)[-1])];\n      if (d != 0)\n        continue;\n      if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, NULL, kwset))\n        return tp - text;\n    }\n\n  return -1;\n}","target":1,"code_token_length":712,"total_token_length":948,"max_tokens_setting":1024}
+{"idx":336685,"func":"static void reds_handle_read_header_done(void *opaque)\n{\n    RedLinkInfo *link = (RedLinkInfo *)opaque;\n    SpiceLinkHeader *header = &link->link_header;\n\n    header->major_version = GUINT32_FROM_LE(header->major_version);\n    header->minor_version = GUINT32_FROM_LE(header->minor_version);\n    header->size = GUINT32_FROM_LE(header->size);\n\n    if (header->major_version != SPICE_VERSION_MAJOR) {\n        if (header->major_version > 0) {\n            reds_send_link_error(link, SPICE_LINK_ERR_VERSION_MISMATCH);\n        }\n\n        spice_warning(\"version mismatch\");\n        reds_link_free(link);\n        return;\n    }\n\n    \/* the check for 4096 is to avoid clients to cause arbitrary big memory allocations *\/\n    if (header->size < sizeof(SpiceLinkMess) || header->size > 4096) {\n        reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);\n        spice_warning(\"bad size %u\", header->size);\n        reds_link_free(link);\n        return;\n    }\n\n    link->link_mess = (SpiceLinkMess*) g_malloc(header->size);\n\n    red_stream_async_read(link->stream,\n                          (uint8_t *)link->link_mess,\n                          header->size,\n                          reds_handle_read_link_done,\n                          link);\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":505651,"func":"smtp_command_parse_finish_data(struct smtp_command_parser *parser)\n{\n\tconst unsigned char *data;\n\tsize_t size;\n\tint ret;\n\n\tparser->error_code = SMTP_COMMAND_PARSE_ERROR_NONE;\n\tparser->error = NULL;\n\n\tif (parser->data == NULL)\n\t\treturn 1;\n\tif (parser->data->eof) {\n\t\ti_stream_unref(&parser->data);\n\t\treturn 1;\n\t}\n\n\twhile ((ret = i_stream_read_data(parser->data, &data, &size, 0)) > 0)\n\t\ti_stream_skip(parser->data, size);\n\tif (ret == 0 || parser->data->stream_errno != 0) {\n\t\tswitch (parser->data->stream_errno) {\n\t\tcase 0:\n\t\t\treturn 0;\n\t\tcase EIO:\n\t\t\tsmtp_command_parser_error(parser,\n\t\t\t\tSMTP_COMMAND_PARSE_ERROR_BROKEN_COMMAND,\n\t\t\t\t\"Invalid command data\");\n\t\t\tbreak;\n\t\tcase EMSGSIZE:\n\t\t\tsmtp_command_parser_error(parser,\n\t\t\t\tSMTP_COMMAND_PARSE_ERROR_DATA_TOO_LARGE,\n\t\t\t\t\"Command data too large\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tsmtp_command_parser_error(parser,\n\t\t\t\tSMTP_COMMAND_PARSE_ERROR_BROKEN_STREAM,\n\t\t\t\t\"Stream error while skipping command data: \"\n\t\t\t\t\"%s\", i_stream_get_error(parser->data));\n\t\t}\n\t\treturn -1;\n\t}\n\ti_stream_unref(&parser->data);\n\treturn 1;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":235654,"func":"PJ_DEF(void) pj_dns_packet_dup(pj_pool_t *pool,\n\t\t\t       const pj_dns_parsed_packet*p,\n\t\t\t       unsigned options,\n\t\t\t       pj_dns_parsed_packet **p_dst)\n{\n    pj_dns_parsed_packet *dst;\n    unsigned nametable_count = 0;\n#if PJ_DNS_MAX_NAMES_IN_NAMETABLE\n    pj_str_t nametable[PJ_DNS_MAX_NAMES_IN_NAMETABLE];\n#else\n    pj_str_t *nametable = NULL;\n#endif\n    unsigned i;\n\n    PJ_ASSERT_ON_FAIL(pool && p && p_dst, return);\n\n    \/* Create packet and copy header *\/\n    *p_dst = dst = PJ_POOL_ZALLOC_T(pool, pj_dns_parsed_packet);\n    pj_memcpy(&dst->hdr, &p->hdr, sizeof(p->hdr));\n\n    \/* Initialize section counts in the target packet to zero.\n     * If memory allocation fails during copying process, the target packet\n     * should have a correct section counts.\n     *\/\n    dst->hdr.qdcount = 0;\n    dst->hdr.anscount = 0;\n    dst->hdr.nscount = 0;\n    dst->hdr.arcount = 0;\n\t\n\n    \/* Copy query section *\/\n    if (p->hdr.qdcount && (options & PJ_DNS_NO_QD)==0) {\n\tdst->q = (pj_dns_parsed_query*)\n\t\t pj_pool_alloc(pool, p->hdr.qdcount * \n\t\t\t\t     sizeof(pj_dns_parsed_query));\n\tfor (i=0; i<p->hdr.qdcount; ++i) {\n\t    copy_query(pool, &dst->q[i], &p->q[i], \n\t\t       &nametable_count, nametable);\n\t    ++dst->hdr.qdcount;\n\t}\n    }\n\n    \/* Copy answer section *\/\n    if (p->hdr.anscount && (options & PJ_DNS_NO_ANS)==0) {\n\tdst->ans = (pj_dns_parsed_rr*)\n\t\t   pj_pool_alloc(pool, p->hdr.anscount * \n\t\t\t\t       sizeof(pj_dns_parsed_rr));\n\tfor (i=0; i<p->hdr.anscount; ++i) {\n\t    copy_rr(pool, &dst->ans[i], &p->ans[i],\n\t\t    &nametable_count, nametable);\n\t    ++dst->hdr.anscount;\n\t}\n    }\n\n    \/* Copy NS section *\/\n    if (p->hdr.nscount && (options & PJ_DNS_NO_NS)==0) {\n\tdst->ns = (pj_dns_parsed_rr*)\n\t\t  pj_pool_alloc(pool, p->hdr.nscount * \n\t\t\t\t      sizeof(pj_dns_parsed_rr));\n\tfor (i=0; i<p->hdr.nscount; ++i) {\n\t    copy_rr(pool, &dst->ns[i], &p->ns[i],\n\t\t    &nametable_count, nametable);\n\t    ++dst->hdr.nscount;\n\t}\n    }\n\n    \/* Copy additional info section *\/\n    if (p->hdr.arcount && (options & PJ_DNS_NO_AR)==0) {\n\tdst->arr = (pj_dns_parsed_rr*)\n\t\t   pj_pool_alloc(pool, p->hdr.arcount * \n\t\t\t\t       sizeof(pj_dns_parsed_rr));\n\tfor (i=0; i<p->hdr.arcount; ++i) {\n\t    copy_rr(pool, &dst->arr[i], &p->arr[i],\n\t\t    &nametable_count, nametable);\n\t    ++dst->hdr.arcount;\n\t}\n    }\n}","target":0,"code_token_length":705,"total_token_length":941,"max_tokens_setting":1024}
+{"idx":261769,"func":"njs_function_frame_save(njs_vm_t *vm, njs_frame_t *frame, u_char *pc)\n{\n    size_t              value_count, n;\n    njs_value_t         *start, *end, *p, **new, *value, **local;\n    njs_function_t      *function;\n    njs_native_frame_t  *active, *native;\n\n    *frame = *vm->active_frame;\n\n    frame->previous_active_frame = NULL;\n\n    native = &frame->native;\n    native->size = 0;\n    native->free = NULL;\n    native->free_size = 0;\n\n    active = &vm->active_frame->native;\n    value_count = njs_function_frame_value_count(active);\n\n    function = active->function;\n\n    new = (njs_value_t **) ((u_char *) native + NJS_FRAME_SIZE);\n    value = (njs_value_t *) (new + value_count\n                             + function->u.lambda->temp);\n\n\n    native->arguments = value;\n    native->arguments_offset = value + (function->args_offset - 1);\n    native->local = new + njs_function_frame_args_count(active);\n    native->temp = new + value_count;\n    native->pc = pc;\n\n    start = njs_function_frame_values(active, &end);\n    p = native->arguments;\n\n    while (start < end) {\n        *p = *start++;\n        *new++ = p++;\n    }\n\n    \/* Move all arguments. *\/\n\n    p = native->arguments;\n    local = native->local + function->args_offset;\n\n    for (n = 0; n < function->args_count; n++) {\n        if (!njs_is_valid(p)) {\n            njs_set_undefined(p);\n        }\n\n        *local++ = p++;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":508329,"func":"fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,\n            bool ignore_errors, bool use_value)\n{\n  List_iterator_fast<Item> v(values);\n  List<TABLE> tbl_list;\n  Item *value;\n  Field *field;\n  bool abort_on_warning_saved= thd->abort_on_warning;\n  uint autoinc_index= table->next_number_field\n                        ? table->next_number_field->field_index\n                        : ~0U;\n  DBUG_ENTER(\"fill_record\");\n\n  if (!*ptr)\n  {\n    \/* No fields to update, quite strange!*\/\n    DBUG_RETURN(0);\n  }\n\n  \/*\n    On INSERT or UPDATE fields are checked to be from the same table,\n    thus we safely can take table from the first field.\n  *\/\n  DBUG_ASSERT((*ptr)->table == table);\n\n  \/*\n    Reset the table->auto_increment_field_not_null as it is valid for\n    only one row.\n  *\/\n  table->auto_increment_field_not_null= FALSE;\n  while ((field = *ptr++) && ! thd->is_error())\n  {\n    \/* Ensure that all fields are from the same table *\/\n    DBUG_ASSERT(field->table == table);\n\n    value=v++;\n    if (field->field_index == autoinc_index)\n      table->auto_increment_field_not_null= TRUE;\n    if (field->vcol_info &&\n        !value->vcol_assignment_allowed_value() &&\n        table->s->table_category != TABLE_CATEGORY_TEMPORARY)\n    {\n      push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,\n                          ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,\n                          ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),\n                          field->field_name, table->s->table_name.str);\n    }\n\n    if (use_value)\n      value->save_val(field);\n    else\n      if (value->save_in_field(field, 0) < 0)\n        goto err;\n    field->set_has_explicit_value();\n  }\n  \/* Update virtual fields *\/\n  thd->abort_on_warning= FALSE;\n  if (table->vfield &&\n      table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_WRITE))\n    goto err;\n  thd->abort_on_warning= abort_on_warning_saved;\n  DBUG_RETURN(thd->is_error());\n\nerr:\n  thd->abort_on_warning= abort_on_warning_saved;\n  table->auto_increment_field_not_null= FALSE;\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":524,"total_token_length":760,"max_tokens_setting":1024}
+{"idx":229344,"func":"Status EagerKernelExecute(\n    EagerContext* ctx, const absl::InlinedVector<TensorHandle*, 4>& op_inputs,\n    const absl::optional<EagerFunctionParams>& eager_func_params,\n    const core::RefCountPtr<KernelAndDevice>& kernel,\n    GraphCollector* graph_collector, CancellationManager* cancellation_manager,\n    absl::Span<TensorHandle*> retvals,\n    const absl::optional<ManagedStackTrace>& stack_trace) {\n  profiler::TraceMe activity(\"EagerKernelExecute\",\n                             profiler::TraceMeLevel::kInfo);\n  std::vector<EagerKernelRet> outputs(1);\n\n  ExecuteNodeArgs inputs(op_inputs.size());\n  TF_RETURN_IF_ERROR(inputs.Init(ctx, op_inputs, kernel));\n  \/\/ TODO(apassos) figure out how to record stats for ops which are a part of\n  \/\/ functions.\n  \/\/ TODO(b\/111859745): When we support recovering from kernel\/device errors, we\n  \/\/ would need to call XlaDevice::EnsureDeviceContextOk() before using an XLA\n  \/\/ device. We don't call it now because it is an unneeded overhead (it\n  \/\/ acquires a lock) and we can't recover from errors anyway.\n  ScopedStepContainer* container = ctx->StepContainer();\n  CoordinationServiceAgent* coord_agent = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n  if (ctx->GetDistributedManager() != nullptr)\n    coord_agent = ctx->GetDistributedManager()->GetCoordinationServiceAgent();\n#endif  \/\/ !IS_MOBILE_PLATFORM\n  TF_RETURN_IF_ERROR(kernel->Run(container, inputs, &outputs,\n                                 cancellation_manager, eager_func_params,\n                                 stack_trace, coord_agent));\n  if (graph_collector != nullptr) {\n    CollectGraphs(ctx);\n  }\n\n  if (TF_PREDICT_FALSE(retvals.size() != outputs.size())) {\n    return errors::Internal(\n        \"EagerKernelExecute returns a list of \", outputs.size(),\n        \" tensors but \", retvals.size(),\n        \" is expected. This should never \"\n        \"happen. Please file a bug with the TensorFlow team.\");\n  }\n  return GetKernelOutputs(&outputs, retvals.size(), retvals.data(), ctx,\n                          kernel.get(), eager_func_params);\n}","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":294618,"func":"c_valid_nth_kday_p(int y, int m, int n, int k, double sg,\n\t\t   int *rm, int *rn, int *rk, int *rjd, int *ns)\n{\n    int ns2, ry2, rm2, rn2, rk2;\n\n    if (k < 0)\n\tk += 7;\n    if (n < 0) {\n\tint t, ny, nm, rjd2;\n\n\tt = y * 12 + m;\n\tny = DIV(t, 12);\n\tnm = MOD(t, 12) + 1;\n\n\tc_nth_kday_to_jd(ny, nm, 1, k, sg, &rjd2, &ns2);\n\tc_jd_to_nth_kday(rjd2 + n * 7, sg, &ry2, &rm2, &rn2, &rk2);\n\tif (ry2 != y || rm2 != m)\n\t    return 0;\n\tn = rn2;\n    }\n    c_nth_kday_to_jd(y, m, n, k, sg, rjd, ns);\n    c_jd_to_nth_kday(*rjd, sg, &ry2, rm, rn, rk);\n    if (y != ry2 || m != *rm || n != *rn || k != *rk)\n\treturn 0;\n    return 1;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":210866,"func":"SProcXkbSelectEvents(ClientPtr client)\n{\n    REQUEST(xkbSelectEventsReq);\n\n    swaps(&stuff->length);\n    REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq);\n    swaps(&stuff->deviceSpec);\n    swaps(&stuff->affectWhich);\n    swaps(&stuff->clear);\n    swaps(&stuff->selectAll);\n    swaps(&stuff->affectMap);\n    swaps(&stuff->map);\n    if ((stuff->affectWhich & (~XkbMapNotifyMask)) != 0) {\n        union {\n            BOOL *b;\n            CARD8 *c8;\n            CARD16 *c16;\n            CARD32 *c32;\n        } from;\n        register unsigned bit, ndx, maskLeft, dataLeft, size;\n\n        from.c8 = (CARD8 *) &stuff[1];\n        dataLeft = (stuff->length * 4) - SIZEOF(xkbSelectEventsReq);\n        maskLeft = (stuff->affectWhich & (~XkbMapNotifyMask));\n        for (ndx = 0, bit = 1; (maskLeft != 0); ndx++, bit <<= 1) {\n            if (((bit & maskLeft) == 0) || (ndx == XkbMapNotify))\n                continue;\n            maskLeft &= ~bit;\n            if ((stuff->selectAll & bit) || (stuff->clear & bit))\n                continue;\n            switch (ndx) {\n            case XkbNewKeyboardNotify:\n            case XkbStateNotify:\n            case XkbNamesNotify:\n            case XkbAccessXNotify:\n            case XkbExtensionDeviceNotify:\n                size = 2;\n                break;\n            case XkbControlsNotify:\n            case XkbIndicatorStateNotify:\n            case XkbIndicatorMapNotify:\n                size = 4;\n                break;\n            case XkbBellNotify:\n            case XkbActionMessage:\n            case XkbCompatMapNotify:\n                size = 1;\n                break;\n            default:\n                client->errorValue = _XkbErrCode2(0x1, bit);\n                return BadValue;\n            }\n            if (dataLeft < (size * 2))\n                return BadLength;\n            if (size == 2) {\n                swaps(&from.c16[0]);\n                swaps(&from.c16[1]);\n            }\n            else if (size == 4) {\n                swapl(&from.c32[0]);\n                swapl(&from.c32[1]);\n            }\n            else {\n                size = 2;\n            }\n            from.c8 += (size * 2);\n            dataLeft -= (size * 2);\n        }\n        if (dataLeft > 2) {\n            ErrorF(\"[xkb] Extra data (%d bytes) after SelectEvents\\n\",\n                   dataLeft);\n            return BadLength;\n        }\n    }\n    return ProcXkbSelectEvents(client);\n}","target":1,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":291788,"func":"static int rtrs_clt_rdma_cm_handler(struct rdma_cm_id *cm_id,\n\t\t\t\t     struct rdma_cm_event *ev)\n{\n\tstruct rtrs_clt_con *con = cm_id->context;\n\tstruct rtrs_path *s = con->c.path;\n\tstruct rtrs_clt_path *clt_path = to_clt_path(s);\n\tint cm_err = 0;\n\n\tswitch (ev->event) {\n\tcase RDMA_CM_EVENT_ADDR_RESOLVED:\n\t\tcm_err = rtrs_rdma_addr_resolved(con);\n\t\tbreak;\n\tcase RDMA_CM_EVENT_ROUTE_RESOLVED:\n\t\tcm_err = rtrs_rdma_route_resolved(con);\n\t\tbreak;\n\tcase RDMA_CM_EVENT_ESTABLISHED:\n\t\tcm_err = rtrs_rdma_conn_established(con, ev);\n\t\tif (!cm_err) {\n\t\t\t\/*\n\t\t\t * Report success and wake up. Here we abuse state_wq,\n\t\t\t * i.e. wake up without state change, but we set cm_err.\n\t\t\t *\/\n\t\t\tflag_success_on_conn(con);\n\t\t\twake_up(&clt_path->state_wq);\n\t\t\treturn 0;\n\t\t}\n\t\tbreak;\n\tcase RDMA_CM_EVENT_REJECTED:\n\t\tcm_err = rtrs_rdma_conn_rejected(con, ev);\n\t\tbreak;\n\tcase RDMA_CM_EVENT_DISCONNECTED:\n\t\t\/* No message for disconnecting *\/\n\t\tcm_err = -ECONNRESET;\n\t\tbreak;\n\tcase RDMA_CM_EVENT_CONNECT_ERROR:\n\tcase RDMA_CM_EVENT_UNREACHABLE:\n\tcase RDMA_CM_EVENT_ADDR_CHANGE:\n\tcase RDMA_CM_EVENT_TIMEWAIT_EXIT:\n\t\trtrs_wrn(s, \"CM error (CM event: %s, err: %d)\\n\",\n\t\t\t rdma_event_msg(ev->event), ev->status);\n\t\tcm_err = -ECONNRESET;\n\t\tbreak;\n\tcase RDMA_CM_EVENT_ADDR_ERROR:\n\tcase RDMA_CM_EVENT_ROUTE_ERROR:\n\t\trtrs_wrn(s, \"CM error (CM event: %s, err: %d)\\n\",\n\t\t\t rdma_event_msg(ev->event), ev->status);\n\t\tcm_err = -EHOSTUNREACH;\n\t\tbreak;\n\tcase RDMA_CM_EVENT_DEVICE_REMOVAL:\n\t\t\/*\n\t\t * Device removal is a special case.  Queue close and return 0.\n\t\t *\/\n\t\trtrs_clt_close_conns(clt_path, false);\n\t\treturn 0;\n\tdefault:\n\t\trtrs_err(s, \"Unexpected RDMA CM error (CM event: %s, err: %d)\\n\",\n\t\t\t rdma_event_msg(ev->event), ev->status);\n\t\tcm_err = -ECONNRESET;\n\t\tbreak;\n\t}\n\n\tif (cm_err) {\n\t\t\/*\n\t\t * cm error makes sense only on connection establishing,\n\t\t * in other cases we rely on normal procedure of reconnecting.\n\t\t *\/\n\t\tflag_error_on_conn(con, cm_err);\n\t\trtrs_rdma_error_recovery(con);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":612,"total_token_length":848,"max_tokens_setting":1024}
+{"idx":450830,"func":"int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host,\n\t\t\t\tu8 event, struct sk_buff *skb)\n{\n\tint r = 0;\n\tstruct device *dev = &hdev->ndev->dev;\n\tstruct nfc_evt_transaction *transaction;\n\n\tpr_debug(\"connectivity gate event: %x\\n\", event);\n\n\tswitch (event) {\n\tcase ST21NFCA_EVT_CONNECTIVITY:\n\t\tr = nfc_se_connectivity(hdev->ndev, host);\n\tbreak;\n\tcase ST21NFCA_EVT_TRANSACTION:\n\t\t\/*\n\t\t * According to specification etsi 102 622\n\t\t * 11.2.2.4 EVT_TRANSACTION Table 52\n\t\t * Description\tTag\tLength\n\t\t * AID\t\t81\t5 to 16\n\t\t * PARAMETERS\t82\t0 to 255\n\t\t *\/\n\t\tif (skb->len < NFC_MIN_AID_LENGTH + 2 &&\n\t\t    skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)\n\t\t\treturn -EPROTO;\n\n\t\ttransaction = devm_kzalloc(dev, skb->len - 2, GFP_KERNEL);\n\t\tif (!transaction)\n\t\t\treturn -ENOMEM;\n\n\t\ttransaction->aid_len = skb->data[1];\n\n\t\t\/* Checking if the length of the AID is valid *\/\n\t\tif (transaction->aid_len > sizeof(transaction->aid))\n\t\t\treturn -EINVAL;\n\n\t\tmemcpy(transaction->aid, &skb->data[2],\n\t\t       transaction->aid_len);\n\n\t\t\/* Check next byte is PARAMETERS tag (82) *\/\n\t\tif (skb->data[transaction->aid_len + 2] !=\n\t\t    NFC_EVT_TRANSACTION_PARAMS_TAG)\n\t\t\treturn -EPROTO;\n\n\t\ttransaction->params_len = skb->data[transaction->aid_len + 3];\n\n\t\t\/* Total size is allocated (skb->len - 2) minus fixed array members *\/\n\t\tif (transaction->params_len > ((skb->len - 2) - sizeof(struct nfc_evt_transaction)))\n\t\t\treturn -EINVAL;\n\n\t\tmemcpy(transaction->params, skb->data +\n\t\t       transaction->aid_len + 4, transaction->params_len);\n\n\t\tr = nfc_se_transaction(hdev->ndev, host, transaction);\n\tbreak;\n\tdefault:\n\t\tnfc_err(&hdev->ndev->dev, \"Unexpected event on connectivity gate\\n\");\n\t\treturn 1;\n\t}\n\tkfree_skb(skb);\n\treturn r;\n}","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":450422,"func":"void vnc_write(VncState *vs, const void *data, size_t len)\n{\n    assert(vs->magic == VNC_MAGIC);\n    if (vs->disconnecting) {\n        return;\n    }\n    \/* Protection against malicious client\/guest to prevent our output\n     * buffer growing without bound if client stops reading data. This\n     * should rarely trigger, because we have earlier throttling code\n     * which stops issuing framebuffer updates and drops audio data\n     * if the throttle_output_offset value is exceeded. So we only reach\n     * this higher level if a huge number of pseudo-encodings get\n     * triggered while data can't be sent on the socket.\n     *\n     * NB throttle_output_offset can be zero during early protocol\n     * handshake, or from the job thread's VncState clone\n     *\/\n    if (vs->throttle_output_offset != 0 &&\n        (vs->output.offset \/ VNC_THROTTLE_OUTPUT_LIMIT_SCALE) >\n        vs->throttle_output_offset) {\n        trace_vnc_client_output_limit(vs, vs->ioc, vs->output.offset,\n                                      vs->throttle_output_offset);\n        vnc_disconnect_start(vs);\n        return;\n    }\n    buffer_reserve(&vs->output, len);\n\n    if (vs->ioc != NULL && buffer_empty(&vs->output)) {\n        if (vs->ioc_tag) {\n            g_source_remove(vs->ioc_tag);\n        }\n        vs->ioc_tag = qio_channel_add_watch(\n            vs->ioc, G_IO_IN | G_IO_OUT, vnc_client_io, vs, NULL);\n    }\n\n    buffer_append(&vs->output, data, len);\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":300807,"func":"int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,\n\t\t\t   struct tipc_sock *tsk, u32 sk_filter_state,\n\t\t\t   u64 (*tipc_diag_gen_cookie)(struct sock *sk))\n{\n\tstruct sock *sk = &tsk->sk;\n\tstruct nlattr *attrs;\n\tstruct nlattr *stat;\n\n\t\/*filter response w.r.t sk_state*\/\n\tif (!(sk_filter_state & (1 << sk->sk_state)))\n\t\treturn 0;\n\n\tattrs = nla_nest_start_noflag(skb, TIPC_NLA_SOCK);\n\tif (!attrs)\n\t\tgoto msg_cancel;\n\n\tif (__tipc_nl_add_sk_info(skb, tsk))\n\t\tgoto attr_msg_cancel;\n\n\tif (nla_put_u32(skb, TIPC_NLA_SOCK_TYPE, (u32)sk->sk_type) ||\n\t    nla_put_u32(skb, TIPC_NLA_SOCK_TIPC_STATE, (u32)sk->sk_state) ||\n\t    nla_put_u32(skb, TIPC_NLA_SOCK_INO, sock_i_ino(sk)) ||\n\t    nla_put_u32(skb, TIPC_NLA_SOCK_UID,\n\t\t\tfrom_kuid_munged(sk_user_ns(NETLINK_CB(cb->skb).sk),\n\t\t\t\t\t sock_i_uid(sk))) ||\n\t    nla_put_u64_64bit(skb, TIPC_NLA_SOCK_COOKIE,\n\t\t\t      tipc_diag_gen_cookie(sk),\n\t\t\t      TIPC_NLA_SOCK_PAD))\n\t\tgoto attr_msg_cancel;\n\n\tstat = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_STAT);\n\tif (!stat)\n\t\tgoto attr_msg_cancel;\n\n\tif (nla_put_u32(skb, TIPC_NLA_SOCK_STAT_RCVQ,\n\t\t\tskb_queue_len(&sk->sk_receive_queue)) ||\n\t    nla_put_u32(skb, TIPC_NLA_SOCK_STAT_SENDQ,\n\t\t\tskb_queue_len(&sk->sk_write_queue)) ||\n\t    nla_put_u32(skb, TIPC_NLA_SOCK_STAT_DROP,\n\t\t\tatomic_read(&sk->sk_drops)))\n\t\tgoto stat_msg_cancel;\n\n\tif (tsk->cong_link_cnt &&\n\t    nla_put_flag(skb, TIPC_NLA_SOCK_STAT_LINK_CONG))\n\t\tgoto stat_msg_cancel;\n\n\tif (tsk_conn_cong(tsk) &&\n\t    nla_put_flag(skb, TIPC_NLA_SOCK_STAT_CONN_CONG))\n\t\tgoto stat_msg_cancel;\n\n\tnla_nest_end(skb, stat);\n\n\tif (tsk->group)\n\t\tif (tipc_group_fill_sock_diag(tsk->group, skb))\n\t\t\tgoto stat_msg_cancel;\n\n\tnla_nest_end(skb, attrs);\n\n\treturn 0;\n\nstat_msg_cancel:\n\tnla_nest_cancel(skb, stat);\nattr_msg_cancel:\n\tnla_nest_cancel(skb, attrs);\nmsg_cancel:\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":218856,"func":"Status ImmutableExecutorState::BuildControlFlowInfo(const Graph* g,\n                                                    ControlFlowInfo* cf_info) {\n  const int num_nodes = g->num_node_ids();\n  cf_info->frame_names.resize(num_nodes);\n  std::vector<Node*> parent_nodes;\n  parent_nodes.resize(num_nodes);\n  std::vector<bool> visited;\n  visited.resize(num_nodes);\n\n  string frame_name;\n  std::deque<Node*> ready;\n\n  \/\/ Initialize with the root nodes.\n  for (Node* n : g->nodes()) {\n    if (n->in_edges().empty()) {\n      visited[n->id()] = true;\n      cf_info->unique_frame_names.insert(frame_name);\n      ready.push_back(n);\n    }\n  }\n\n  while (!ready.empty()) {\n    Node* curr_node = ready.front();\n    int curr_id = curr_node->id();\n    ready.pop_front();\n\n    Node* parent = nullptr;\n    if (IsEnter(curr_node)) {\n      \/\/ Enter a child frame.\n      TF_RETURN_IF_ERROR(\n          GetNodeAttr(curr_node->attrs(), \"frame_name\", &frame_name));\n      parent = curr_node;\n    } else if (IsExit(curr_node)) {\n      \/\/ Exit to the parent frame.\n      parent = parent_nodes[curr_id];\n      if (!parent) {\n        return errors::InvalidArgument(\n            \"Invalid Exit op: Cannot find a corresponding Enter op.\");\n      }\n      frame_name = cf_info->frame_names[parent->id()];\n      parent = parent_nodes[parent->id()];\n    } else {\n      parent = parent_nodes[curr_id];\n      frame_name = cf_info->frame_names[curr_id];\n    }\n\n    for (const Edge* out_edge : curr_node->out_edges()) {\n      Node* out = out_edge->dst();\n      if (IsSink(out)) continue;\n      const int out_id = out->id();\n\n      \/\/ Add to ready queue if not visited.\n      bool is_visited = visited[out_id];\n      if (!is_visited) {\n        ready.push_back(out);\n        visited[out_id] = true;\n\n        \/\/ Process the node 'out'.\n        cf_info->frame_names[out_id] = frame_name;\n        parent_nodes[out_id] = parent;\n        cf_info->unique_frame_names.insert(frame_name);\n      }\n    }\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":405372,"func":"static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,\n\t\t\t\t\t\t     const struct flowi *fl,\n\t\t\t\t\t\t     u16 family, u8 dir,\n\t\t\t\t\t\t     u32 if_id)\n{\n\tstruct xfrm_pol_inexact_candidates cand;\n\tconst xfrm_address_t *daddr, *saddr;\n\tstruct xfrm_pol_inexact_bin *bin;\n\tstruct xfrm_policy *pol, *ret;\n\tstruct hlist_head *chain;\n\tunsigned int sequence;\n\tint err;\n\n\tdaddr = xfrm_flowi_daddr(fl, family);\n\tsaddr = xfrm_flowi_saddr(fl, family);\n\tif (unlikely(!daddr || !saddr))\n\t\treturn NULL;\n\n\trcu_read_lock();\n retry:\n\tdo {\n\t\tsequence = read_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation);\n\t\tchain = policy_hash_direct(net, daddr, saddr, family, dir);\n\t} while (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence));\n\n\tret = NULL;\n\thlist_for_each_entry_rcu(pol, chain, bydst) {\n\t\terr = xfrm_policy_match(pol, fl, type, family, dir, if_id);\n\t\tif (err) {\n\t\t\tif (err == -ESRCH)\n\t\t\t\tcontinue;\n\t\t\telse {\n\t\t\t\tret = ERR_PTR(err);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t} else {\n\t\t\tret = pol;\n\t\t\tbreak;\n\t\t}\n\t}\n\tbin = xfrm_policy_inexact_lookup_rcu(net, type, family, dir, if_id);\n\tif (!bin || !xfrm_policy_find_inexact_candidates(&cand, bin, saddr,\n\t\t\t\t\t\t\t daddr))\n\t\tgoto skip_inexact;\n\n\tpol = xfrm_policy_eval_candidates(&cand, ret, fl, type,\n\t\t\t\t\t  family, dir, if_id);\n\tif (pol) {\n\t\tret = pol;\n\t\tif (IS_ERR(pol))\n\t\t\tgoto fail;\n\t}\n\nskip_inexact:\n\tif (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence))\n\t\tgoto retry;\n\n\tif (ret && !xfrm_pol_hold_rcu(ret))\n\t\tgoto retry;\nfail:\n\trcu_read_unlock();\n\n\treturn ret;\n}","target":0,"code_token_length":462,"total_token_length":698,"max_tokens_setting":1024}
+{"idx":275948,"func":"uECC_VLI_API void uECC_vli_mmod(uECC_word_t *result,\n                                uECC_word_t *product,\n                                const uECC_word_t *mod,\n                                wordcount_t num_words) {\n    uECC_word_t mod_multiple[2 * uECC_MAX_WORDS];\n    uECC_word_t tmp[2 * uECC_MAX_WORDS];\n    uECC_word_t *v[2] = {tmp, product};\n    uECC_word_t index;\n\n    \/* Shift mod so its highest set bit is at the maximum position. *\/\n    bitcount_t shift = (num_words * 2 * uECC_WORD_BITS) - uECC_vli_numBits(mod, num_words);\n    wordcount_t word_shift = shift \/ uECC_WORD_BITS;\n    wordcount_t bit_shift = shift % uECC_WORD_BITS;\n    uECC_word_t carry = 0;\n    uECC_vli_clear(mod_multiple, word_shift);\n    if (bit_shift > 0) {\n        for(index = 0; index < (uECC_word_t)num_words; ++index) {\n            mod_multiple[word_shift + index] = (mod[index] << bit_shift) | carry;\n            carry = mod[index] >> (uECC_WORD_BITS - bit_shift);\n        }\n    } else {\n        uECC_vli_set(mod_multiple + word_shift, mod, num_words);\n    }\n\n    for (index = 1; shift >= 0; --shift) {\n        uECC_word_t borrow = 0;\n        wordcount_t i;\n        for (i = 0; i < num_words * 2; ++i) {\n            uECC_word_t diff = v[index][i] - mod_multiple[i] - borrow;\n            if (diff != v[index][i]) {\n                borrow = (diff > v[index][i]);\n            }\n            v[1 - index][i] = diff;\n        }\n        index = !(index ^ borrow); \/* Swap the index if there was no borrow *\/\n        uECC_vli_rshift1(mod_multiple, num_words);\n        mod_multiple[num_words - 1] |= mod_multiple[num_words] << (uECC_WORD_BITS - 1);\n        uECC_vli_rshift1(mod_multiple + num_words, num_words);\n    }\n    uECC_vli_set(result, v[index], num_words);\n}","target":0,"code_token_length":513,"total_token_length":749,"max_tokens_setting":1024}
+{"idx":313135,"func":"testPathRelativePrepare(void)\n{\n    size_t i;\n\n    for (i = 0; i < G_N_ELEMENTS(backingchain); i++) {\n        backingchain[i].type = VIR_STORAGE_TYPE_FILE;\n        if (i < G_N_ELEMENTS(backingchain) - 1)\n            backingchain[i].backingStore = &backingchain[i + 1];\n        else\n            backingchain[i].backingStore = NULL;\n\n        backingchain[i].relPath = NULL;\n    }\n\n    \/* normal relative backing chain *\/\n    backingchain[0].path = (char *) \"\/path\/to\/some\/img\";\n\n    backingchain[1].path = (char *) \"\/path\/to\/some\/asdf\";\n    backingchain[1].relPath = (char *) \"asdf\";\n\n    backingchain[2].path = (char *) \"\/path\/to\/some\/test\";\n    backingchain[2].relPath = (char *) \"test\";\n\n    backingchain[3].path = (char *) \"\/path\/to\/some\/blah\";\n    backingchain[3].relPath = (char *) \"blah\";\n\n    \/* ovirt's backing chain *\/\n    backingchain[4].path = (char *) \"\/path\/to\/volume\/image1\";\n\n    backingchain[5].path = (char *) \"\/path\/to\/volume\/image2\";\n    backingchain[5].relPath = (char *) \"..\/volume\/image2\";\n\n    backingchain[6].path = (char *) \"\/path\/to\/volume\/image3\";\n    backingchain[6].relPath = (char *) \"..\/volume\/image3\";\n\n    backingchain[7].path = (char *) \"\/path\/to\/volume\/image4\";\n    backingchain[7].relPath = (char *) \"..\/volume\/image4\";\n\n    \/* some arbitrarily crazy backing chains *\/\n    backingchain[8].path = (char *) \"\/crazy\/base\/image\";\n\n    backingchain[9].path = (char *) \"\/crazy\/base\/directory\/stuff\/volumes\/garbage\/image2\";\n    backingchain[9].relPath = (char *) \"directory\/stuff\/volumes\/garbage\/image2\";\n\n    backingchain[10].path = (char *) \"\/crazy\/base\/directory\/image3\";\n    backingchain[10].relPath = (char *) \"..\/..\/..\/image3\";\n\n    backingchain[11].path = (char *) \"\/crazy\/base\/blah\/image4\";\n    backingchain[11].relPath = (char *) \"..\/blah\/image4\";\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":301439,"func":"static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,\n\t\tenum timestamp_set_resolution *p_ts_res)\n{\n\tconnection_struct *conn = handle->conn;\n\tuint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;\n\tstruct smb_filename *smb_fname_cpath = NULL;\n\tstruct vfs_statvfs_struct statbuf;\n\tint ret;\n\n\tZERO_STRUCT(statbuf);\n\tret = sys_statvfs(conn->connectpath, &statbuf);\n\tif (ret == 0) {\n\t\tcaps = statbuf.FsCapabilities;\n\t}\n\n\t*p_ts_res = TIMESTAMP_SET_SECONDS;\n\n\t\/* Work out what timestamp resolution we can\n\t * use when setting a timestamp. *\/\n\n\tsmb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath,\n\t\t\t\t\t      NULL, NULL);\n\tif (smb_fname_cpath == NULL) {\n\t\treturn caps;\n\t}\n\n\tret = SMB_VFS_STAT(conn, smb_fname_cpath);\n\tif (ret == -1) {\n\t\tTALLOC_FREE(smb_fname_cpath);\n\t\treturn caps;\n\t}\n\n\tif (smb_fname_cpath->st.st_ex_mtime.tv_nsec ||\n\t\t\tsmb_fname_cpath->st.st_ex_atime.tv_nsec ||\n\t\t\tsmb_fname_cpath->st.st_ex_ctime.tv_nsec) {\n\t\t\/* If any of the normal UNIX directory timestamps\n\t\t * have a non-zero tv_nsec component assume\n\t\t * we might be able to set sub-second timestamps.\n\t\t * See what filetime set primitives we have.\n\t\t *\/\n#if defined(HAVE_UTIMENSAT)\n\t\t*p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;\n#elif defined(HAVE_UTIMES)\n\t\t\/* utimes allows msec timestamps to be set. *\/\n\t\t*p_ts_res = TIMESTAMP_SET_MSEC;\n#elif defined(HAVE_UTIME)\n\t\t\/* utime only allows sec timestamps to be set. *\/\n\t\t*p_ts_res = TIMESTAMP_SET_SECONDS;\n#endif\n\n\t\tDEBUG(10,(\"vfswrap_fs_capabilities: timestamp \"\n\t\t\t\"resolution of %s \"\n\t\t\t\"available on share %s, directory %s\\n\",\n\t\t\t*p_ts_res == TIMESTAMP_SET_MSEC ? \"msec\" : \"sec\",\n\t\t\tlp_servicename(talloc_tos(), conn->params->service),\n\t\t\tconn->connectpath ));\n\t}\n\tTALLOC_FREE(smb_fname_cpath);\n\treturn caps;\n}","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":261938,"func":"njs_string_bytes_from_array_like(njs_vm_t *vm, njs_value_t *value)\n{\n    u_char              *p;\n    int64_t             length;\n    uint32_t            u32;\n    njs_int_t           ret;\n    njs_array_t         *array;\n    njs_value_t         *octet, index, prop;\n    njs_array_buffer_t  *buffer;\n\n    array = NULL;\n    buffer = NULL;\n\n    switch (value->type) {\n    case NJS_ARRAY:\n        array = njs_array(value);\n        length = array->length;\n        break;\n\n    case NJS_ARRAY_BUFFER:\n    case NJS_TYPED_ARRAY:\n\n        if (njs_is_typed_array(value)) {\n            buffer = njs_typed_array(value)->buffer;\n\n        } else {\n            buffer = njs_array_buffer(value);\n        }\n\n        length = buffer->size;\n        break;\n\n    default:\n        ret = njs_object_length(vm, value, &length);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n    }\n\n    p = njs_string_alloc(vm, &vm->retval, length, 0);\n    if (njs_slow_path(p == NULL)) {\n        return NJS_ERROR;\n    }\n\n    if (array != NULL) {\n        octet = array->start;\n\n        while (length != 0) {\n            ret = njs_value_to_uint32(vm, octet, &u32);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            *p++ = (u_char) u32;\n            octet++;\n            length--;\n        }\n\n    } else if (buffer != NULL) {\n        memcpy(p, buffer->u.u8, length);\n\n    } else {\n        p += length - 1;\n\n        while (length != 0) {\n            njs_set_number(&index, length - 1);\n\n            ret = njs_value_property(vm, value, &index, &prop);\n            if (njs_slow_path(ret == NJS_ERROR)) {\n                return ret;\n            }\n\n            ret = njs_value_to_uint32(vm, &prop, &u32);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            *p-- = (u_char) u32;\n            length--;\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":314498,"func":"static void parse_origin(pj_scanner *scanner, pjmedia_sdp_session *ses,\n\t\t\t volatile parse_context *ctx)\n{\n    pj_str_t str;\n\n    ctx->last_error = PJMEDIA_SDP_EINORIGIN;\n\n    \/* check equal sign *\/\n    if (*(scanner->curptr+1) != '=') {\n\ton_scanner_error(scanner);\n\treturn;\n    }\n\n    \/* o= *\/\n    pj_scan_advance_n(scanner, 2, SKIP_WS);\n\n    \/* username. *\/\n    pj_scan_get_until_ch(scanner, ' ', &ses->origin.user);\n    pj_scan_get_char(scanner);\n\n    \/* id *\/\n    pj_scan_get_until_ch(scanner, ' ', &str);\n    ses->origin.id = pj_strtoul(&str);\n    pj_scan_get_char(scanner);\n\n    \/* version *\/\n    pj_scan_get_until_ch(scanner, ' ', &str);\n    ses->origin.version = pj_strtoul(&str);\n    pj_scan_get_char(scanner);\n\n    \/* network-type *\/\n    pj_scan_get_until_ch(scanner, ' ', &ses->origin.net_type);\n    pj_scan_get_char(scanner);\n\n    \/* addr-type *\/\n    pj_scan_get_until_ch(scanner, ' ', &ses->origin.addr_type);\n    pj_scan_get_char(scanner);\n\n    \/* address *\/\n    pj_scan_get_until_chr(scanner, \" \\t\\r\\n\", &ses->origin.addr);\n\n    \/* We've got what we're looking for, skip anything until newline *\/\n    pj_scan_skip_line(scanner);\n\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":389758,"func":"jas_image_t *converttosrgb(jas_image_t *inimage)\n{\n\tjas_image_t *outimage;\n\tjas_cmpixmap_t inpixmap;\n\tjas_cmpixmap_t outpixmap;\n\tjas_cmcmptfmt_t incmptfmts[16];\n\tjas_cmcmptfmt_t outcmptfmts[16];\n\n\toutprof = jas_cmprof_createfromclrspc(JAS_CLRSPC_SRGB);\n\tassert(outprof);\n\txform = jas_cmxform_create(jas_image_cmprof(inimage), outprof, 0, JAS_CMXFORM_FWD, JAS_CMXFORM_INTENT_PER, JAS_CMXFORM_OPTM_SPEED);\n\tassert(xform);\n\n\tinpixmap.numcmpts = jas_image_numcmpts(oldimage);\n\toutpixmap.numcmpts = 3;\n\tfor (i = 0; i < inpixmap.numcmpts; ++i) {\n\t\tinpixmap.cmptfmts[i] = &incmptfmts[i];\n\t}\n\tfor (i = 0; i < outpixmap.numcmpts; ++i)\n\t\toutpixmap.cmptfmts[i] = &outcmptfmts[i];\n\tif (jas_cmxform_apply(xform, &inpixmap, &outpixmap))\n\t\tabort();\n\n\tjas_xform_destroy(xform);\n\tjas_cmprof_destroy(outprof);\n\treturn 0;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":224292,"func":"gopherMimeCreate(GopherStateData * gopherState)\n{\n    StoreEntry *entry = gopherState->entry;\n    const char *mime_type = NULL;\n    const char *mime_enc = NULL;\n\n    switch (gopherState->type_id) {\n\n    case GOPHER_DIRECTORY:\n\n    case GOPHER_INDEX:\n\n    case GOPHER_HTML:\n\n    case GOPHER_WWW:\n\n    case GOPHER_CSO:\n        mime_type = \"text\/html\";\n        break;\n\n    case GOPHER_GIF:\n\n    case GOPHER_IMAGE:\n\n    case GOPHER_PLUS_IMAGE:\n        mime_type = \"image\/gif\";\n        break;\n\n    case GOPHER_SOUND:\n\n    case GOPHER_PLUS_SOUND:\n        mime_type = \"audio\/basic\";\n        break;\n\n    case GOPHER_PLUS_MOVIE:\n        mime_type = \"video\/mpeg\";\n        break;\n\n    case GOPHER_MACBINHEX:\n\n    case GOPHER_DOSBIN:\n\n    case GOPHER_UUENCODED:\n\n    case GOPHER_BIN:\n        \/* Rightnow We have no idea what it is. *\/\n        mime_enc = mimeGetContentEncoding(gopherState->request);\n        mime_type = mimeGetContentType(gopherState->request);\n        if (!mime_type)\n            mime_type = def_gopher_bin;\n        break;\n\n    case GOPHER_FILE:\n\n    default:\n        mime_enc = mimeGetContentEncoding(gopherState->request);\n        mime_type = mimeGetContentType(gopherState->request);\n        if (!mime_type)\n            mime_type = def_gopher_text;\n        break;\n    }\n\n    assert(entry->isEmpty());\n\n    HttpReply *reply = new HttpReply;\n    entry->buffer();\n    reply->setHeaders(Http::scOkay, \"Gatewaying\", mime_type, -1, -1, -2);\n    if (mime_enc)\n        reply->header.putStr(Http::HdrType::CONTENT_ENCODING, mime_enc);\n\n    entry->replaceHttpReply(reply);\n    gopherState->reply_ = reply;\n}","target":0,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":195800,"func":"void fmtutil_macbitmap_read_pixmap_only_fields(deark *c, dbuf *f, struct fmtutil_macbitmap_info *bi,\n\ti64 pos)\n{\n\ti64 pixmap_version;\n\ti64 pack_size;\n\ti64 plane_bytes;\n\ti64 n;\n\n\tde_dbg(c, \"additional PixMap header fields, at %d\", (int)pos);\n\tde_dbg_indent(c, 1);\n\n\tpixmap_version = dbuf_getu16be(f, pos+0);\n\tde_dbg(c, \"pixmap version: %d\", (int)pixmap_version);\n\n\tbi->packing_type = dbuf_getu16be(f, pos+2);\n\tde_dbg(c, \"packing type: %d\", (int)bi->packing_type);\n\n\tpack_size = dbuf_getu32be(f, pos+4);\n\tde_dbg(c, \"pixel data length: %d\", (int)pack_size);\n\n\tbi->hdpi = pict_read_fixed(f, pos+8);\n\tbi->vdpi = pict_read_fixed(f, pos+12);\n\tde_dbg(c, \"dpi: %.2f\"DE_CHAR_TIMES\"%.2f\", bi->hdpi, bi->vdpi);\n\n\tbi->pixeltype = dbuf_getu16be(f, pos+16);\n\tbi->pixelsize = dbuf_getu16be(f, pos+18);\n\tbi->cmpcount = dbuf_getu16be(f, pos+20);\n\tbi->cmpsize = dbuf_getu16be(f, pos+22);\n\tde_dbg(c, \"pixel type=%d, bits\/pixel=%d, components\/pixel=%d, bits\/comp=%d\",\n\t\t(int)bi->pixeltype, (int)bi->pixelsize, (int)bi->cmpcount, (int)bi->cmpsize);\n\n\tbi->pdwidth = (bi->rowbytes*8)\/bi->pixelsize;\n\tif(bi->pdwidth < bi->npwidth) {\n\t\tbi->pdwidth = bi->npwidth;\n\t}\n\n\tplane_bytes = dbuf_getu32be(f, pos+24);\n\tde_dbg(c, \"plane bytes: %d\", (int)plane_bytes);\n\n\tbi->pmTable = (u32)dbuf_getu32be(f, pos+28);\n\tde_dbg(c, \"pmTable: 0x%08x\", (unsigned int)bi->pmTable);\n\n\tn = dbuf_getu32be(f, pos+32);\n\tde_dbg(c, \"pmReserved: 0x%08x\", (unsigned int)n);\n\n\tde_dbg_indent(c, -1);\n}","target":1,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":221162,"func":"GF_Err gf_odf_avc_cfg_write_bs(GF_AVCConfig *cfg, GF_BitStream *bs)\n{\n\tu32 i, count;\n\n\tif (!cfg) return GF_BAD_PARAM;\n\n\tcount = gf_list_count(cfg->sequenceParameterSets);\n\n\tif (!cfg->write_annex_b) {\n\t\tgf_bs_write_int(bs, cfg->configurationVersion, 8);\n\t\tgf_bs_write_int(bs, cfg->AVCProfileIndication , 8);\n\t\tgf_bs_write_int(bs, cfg->profile_compatibility, 8);\n\t\tgf_bs_write_int(bs, cfg->AVCLevelIndication, 8);\n\t\tgf_bs_write_int(bs, 0x3F, 6);\n\t\tgf_bs_write_int(bs, cfg->nal_unit_size - 1, 2);\n\t\tgf_bs_write_int(bs, 0x7, 3);\n\t\tgf_bs_write_int(bs, count, 5);\n\t}\n\tfor (i=0; i<count; i++) {\n\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(cfg->sequenceParameterSets, i);\n\t\tif (!cfg->write_annex_b) {\n\t\t\tgf_bs_write_u16(bs, sl->size);\n\t\t} else {\n\t\t\tgf_bs_write_u32(bs, 1);\n\t\t}\n\t\tgf_bs_write_data(bs, sl->data, sl->size);\n\t}\n\tcount = gf_list_count(cfg->pictureParameterSets);\n\tif (!cfg->write_annex_b) {\n\t\tgf_bs_write_int(bs, count, 8);\n\t}\n\tfor (i=0; i<count; i++) {\n\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(cfg->pictureParameterSets, i);\n\t\tif (!cfg->write_annex_b) {\n\t\t\tgf_bs_write_u16(bs, sl->size);\n\t\t} else {\n\t\t\tgf_bs_write_u32(bs, 1);\n\t\t}\n\t\tgf_bs_write_data(bs, sl->data, sl->size);\n\t}\n\tif (gf_avc_is_rext_profile(cfg->AVCProfileIndication)) {\n\t\tif (!cfg->write_annex_b) {\n\t\t\tgf_bs_write_int(bs, 0xFF, 6);\n\t\t\tgf_bs_write_int(bs, cfg->chroma_format, 2);\n\t\t\tgf_bs_write_int(bs, 0xFF, 5);\n\t\t\tgf_bs_write_int(bs, cfg->luma_bit_depth - 8, 3);\n\t\t\tgf_bs_write_int(bs, 0xFF, 5);\n\t\t\tgf_bs_write_int(bs, cfg->chroma_bit_depth - 8, 3);\n\t\t}\n\t\tcount = cfg->sequenceParameterSetExtensions ? gf_list_count(cfg->sequenceParameterSetExtensions) : 0;\n\t\tif (!cfg->write_annex_b) {\n\t\t\tgf_bs_write_u8(bs, count);\n\t\t}\n\t\tfor (i=0; i<count; i++) {\n\t\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *) gf_list_get(cfg->sequenceParameterSetExtensions, i);\n\t\t\tif (!cfg->write_annex_b) {\n\t\t\t\tgf_bs_write_u16(bs, sl->size);\n\t\t\t} else {\n\t\t\t\tgf_bs_write_u32(bs, 1);\n\t\t\t}\n\t\t\tgf_bs_write_data(bs, sl->data, sl->size);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":317128,"func":"static int selinux_sb_remount(struct super_block *sb, void *mnt_opts)\n{\n\tstruct selinux_mnt_opts *opts = mnt_opts;\n\tstruct superblock_security_struct *sbsec = selinux_superblock(sb);\n\tu32 sid;\n\tint rc;\n\n\tif (!(sbsec->flags & SE_SBINITIALIZED))\n\t\treturn 0;\n\n\tif (!opts)\n\t\treturn 0;\n\n\tif (opts->fscontext) {\n\t\trc = parse_sid(sb, opts->fscontext, &sid);\n\t\tif (rc)\n\t\t\treturn rc;\n\t\tif (bad_option(sbsec, FSCONTEXT_MNT, sbsec->sid, sid))\n\t\t\tgoto out_bad_option;\n\t}\n\tif (opts->context) {\n\t\trc = parse_sid(sb, opts->context, &sid);\n\t\tif (rc)\n\t\t\treturn rc;\n\t\tif (bad_option(sbsec, CONTEXT_MNT, sbsec->mntpoint_sid, sid))\n\t\t\tgoto out_bad_option;\n\t}\n\tif (opts->rootcontext) {\n\t\tstruct inode_security_struct *root_isec;\n\t\troot_isec = backing_inode_security(sb->s_root);\n\t\trc = parse_sid(sb, opts->rootcontext, &sid);\n\t\tif (rc)\n\t\t\treturn rc;\n\t\tif (bad_option(sbsec, ROOTCONTEXT_MNT, root_isec->sid, sid))\n\t\t\tgoto out_bad_option;\n\t}\n\tif (opts->defcontext) {\n\t\trc = parse_sid(sb, opts->defcontext, &sid);\n\t\tif (rc)\n\t\t\treturn rc;\n\t\tif (bad_option(sbsec, DEFCONTEXT_MNT, sbsec->def_sid, sid))\n\t\t\tgoto out_bad_option;\n\t}\n\treturn 0;\n\nout_bad_option:\n\tpr_warn(\"SELinux: unable to change security options \"\n\t       \"during remount (dev %s, type=%s)\\n\", sb->s_id,\n\t       sb->s_type->name);\n\treturn -EINVAL;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":509576,"func":"int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type)\n{\n  TRN *trn;\n  if (file->s->base.born_transactional)\n  {\n    trn= THD_TRN;\n    DBUG_ASSERT(trn); \/\/ this may be called only after external_lock()\n    DBUG_ASSERT(trnman_has_locked_tables(trn));\n    DBUG_ASSERT(lock_type != TL_UNLOCK);\n    DBUG_ASSERT(file->trn == trn);\n\n    \/*\n      As external_lock() was already called, don't increment locked_tables.\n      Note that we call the function below possibly several times when\n      statement starts (once per table). This is ok as long as that function\n      does cheap operations. Otherwise, we will need to do it only on first\n      call to start_stmt().\n    *\/\n    trnman_new_statement(trn);\n\n#ifdef EXTRA_DEBUG\n    if (!(trnman_get_flags(trn) & TRN_STATE_INFO_LOGGED) &&\n        trnman_get_flags(trn) & TRN_STATE_TABLES_CAN_CHANGE)\n    {\n      trnman_set_flags(trn, trnman_get_flags(trn) | TRN_STATE_INFO_LOGGED);\n      (void) translog_log_debug_info(trn, LOGREC_DEBUG_INFO_QUERY,\n                                     (uchar*) thd->query(),\n                                     thd->query_length());\n    }\n#endif\n  }\n  return 0;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":292218,"func":"inbound_cap_ack (server *serv, char *nick, char *extensions,\n\t\t\t\t\t  const message_tags_data *tags_data)\n{\n\tEMIT_SIGNAL_TIMESTAMP (XP_TE_CAPACK, serv->server_session, nick, extensions,\n\t\t\t\t\t\t\t\t  NULL, NULL, 0, tags_data->timestamp);\n\n\tif (strstr (extensions, \"identify-msg\") != NULL)\n\t{\n\t\tserv->have_idmsg = TRUE;\n\t}\n\n\tif (strstr (extensions, \"multi-prefix\") != NULL)\n\t{\n\t\tserv->have_namesx = TRUE;\n\t}\n\n\tif (strstr (extensions, \"away-notify\") != NULL)\n\t{\n\t\tserv->have_awaynotify = TRUE;\n\t}\n\n\tif (strstr (extensions, \"account-notify\") != NULL)\n\t{\n\t\tserv->have_accnotify = TRUE;\n\t}\n\t\t\t\t\t\n\tif (strstr (extensions, \"extended-join\") != NULL)\n\t{\n\t\tserv->have_extjoin = TRUE;\n\t}\n\n\tif (strstr (extensions, \"userhost-in-names\") != NULL)\n\t{\n\t\tserv->have_uhnames = TRUE;\n\t}\n\n\tif (strstr (extensions, \"server-time\") != NULL)\n\t{\n\t\tserv->have_server_time = TRUE;\n\t}\n\n\tif (strstr (extensions, \"sasl\") != NULL)\n\t{\n\t\tserv->have_sasl = TRUE;\n\t\tserv->sent_saslauth = FALSE;\n\n#ifdef USE_OPENSSL\n\t\tif (serv->loginmethod == LOGIN_SASLEXTERNAL)\n\t\t{\n\t\t\tserv->sasl_mech = MECH_EXTERNAL;\n\t\t\ttcp_send_len (serv, \"AUTHENTICATE EXTERNAL\\r\\n\", 23);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\/* default to most secure, it will fallback if not supported *\/\n\t\t\tserv->sasl_mech = MECH_AES;\n\t\t\ttcp_send_len (serv, \"AUTHENTICATE DH-AES\\r\\n\", 21);\n\t\t}\n#else\n\t\tserv->sasl_mech = MECH_PLAIN;\n\t\ttcp_send_len (serv, \"AUTHENTICATE PLAIN\\r\\n\", 20);\n#endif\n\t}\n}","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":391670,"func":"NTSTATUS smbd_calculate_access_mask(connection_struct *conn,\n\t\t\t\t    const struct smb_filename *smb_fname,\n\t\t\t\t    bool use_privs,\n\t\t\t\t    uint32_t access_mask,\n\t\t\t\t    uint32_t *access_mask_out)\n{\n\tNTSTATUS status;\n\tuint32_t orig_access_mask = access_mask;\n\tuint32_t rejected_share_access;\n\n\t\/*\n\t * Convert GENERIC bits to specific bits.\n\t *\/\n\n\tse_map_generic(&access_mask, &file_generic_mapping);\n\n\t\/* Calculate MAXIMUM_ALLOWED_ACCESS if requested. *\/\n\tif (access_mask & MAXIMUM_ALLOWED_ACCESS) {\n\n\t\tstatus = smbd_calculate_maximum_allowed_access(\n\t\t\tconn, smb_fname, use_privs, &access_mask);\n\n\t\tif (!NT_STATUS_IS_OK(status)) {\n\t\t\treturn status;\n\t\t}\n\n\t\taccess_mask &= conn->share_access;\n\t}\n\n\trejected_share_access = access_mask & ~(conn->share_access);\n\n\tif (rejected_share_access) {\n\t\tDEBUG(10, (\"smbd_calculate_access_mask: Access denied on \"\n\t\t\t\"file %s: rejected by share access mask[0x%08X] \"\n\t\t\t\"orig[0x%08X] mapped[0x%08X] reject[0x%08X]\\n\",\n\t\t\tsmb_fname_str_dbg(smb_fname),\n\t\t\tconn->share_access,\n\t\t\torig_access_mask, access_mask,\n\t\t\trejected_share_access));\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\n\t*access_mask_out = access_mask;\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":233838,"func":"int fmtutil_macbitmap_read_colortable(deark *c, dbuf *f,\n\tstruct fmtutil_macbitmap_info *bi, i64 pos, i64 *bytes_used)\n{\n\ti64 ct_id;\n\tu32 ct_flags;\n\ti64 ct_size;\n\ti64 k, z;\n\tu32 s[4];\n\tu8 cr, cg, cb;\n\tu32 clr;\n\tchar tmps[64];\n\n\t*bytes_used = 0;\n\tde_dbg(c, \"color table at %\"I64_FMT, pos);\n\tde_dbg_indent(c, 1);\n\n\tct_id = dbuf_getu32be(f, pos);\n\tct_flags = (u32)dbuf_getu16be(f, pos+4); \/\/ a.k.a. transIndex\n\tct_size = dbuf_getu16be(f, pos+6);\n\tbi->num_pal_entries = ct_size+1;\n\tde_dbg(c, \"color table id=0x%08x, flags=0x%04x, colors=%d\", (unsigned int)ct_id,\n\t\t(unsigned int)ct_flags, (int)bi->num_pal_entries);\n\n\tfor(k=0; k<bi->num_pal_entries; k++) {\n\t\tfor(z=0; z<4; z++) {\n\t\t\ts[z] = (u32)dbuf_getu16be(f, pos+8+8*k+2*z);\n\t\t}\n\t\tcr = (u8)(s[1]>>8);\n\t\tcg = (u8)(s[2]>>8);\n\t\tcb = (u8)(s[3]>>8);\n\t\tclr = DE_MAKE_RGB(cr,cg,cb);\n\t\tde_snprintf(tmps, sizeof(tmps), \"(%5d,%5d,%5d,idx=%3d) \"DE_CHAR_RIGHTARROW\" \",\n\t\t\t(int)s[1], (int)s[2], (int)s[3], (int)s[0]);\n\t\tde_dbg_pal_entry2(c, k, clr, tmps, NULL, NULL);\n\n\t\t\/\/ Some files don't have the palette indices set. Most PICT decoders ignore\n\t\t\/\/ the indices if the \"device\" flag of ct_flags is set, and that seems to\n\t\t\/\/ work (though it's not clearly documented).\n\t\tif(ct_flags & 0x8000U) {\n\t\t\ts[0] = (u32)k;\n\t\t}\n\n\t\tif(s[0]<=255) {\n\t\t\tbi->pal[s[0]] = clr;\n\t\t}\n\t}\n\n\tde_dbg_indent(c, -1);\n\t*bytes_used = 8 + 8*bi->num_pal_entries;\n\treturn 1;\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":275527,"func":"njs_vm_bind(njs_vm_t *vm, const njs_str_t *var_name, const njs_value_t *value,\n    njs_bool_t shared)\n{\n    njs_int_t           ret;\n    njs_object_t        *global;\n    njs_lvlhsh_t        *hash;\n    njs_object_prop_t   *prop;\n    njs_lvlhsh_query_t  lhq;\n\n    prop = njs_object_prop_alloc(vm, &njs_value_undefined, value, 1);\n    if (njs_slow_path(prop == NULL)) {\n        return NJS_ERROR;\n    }\n\n    ret = njs_string_new(vm, &prop->name, var_name->start, var_name->length, 0);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    lhq.value = prop;\n    lhq.key = *var_name;\n    lhq.key_hash = njs_djb_hash(lhq.key.start, lhq.key.length);\n    lhq.replace = 1;\n    lhq.pool = vm->mem_pool;\n    lhq.proto = &njs_object_hash_proto;\n\n    global = &vm->global_object;\n    hash = shared ? &global->shared_hash : &global->hash;\n\n    ret = njs_lvlhsh_insert(hash, &lhq);\n    if (njs_slow_path(ret != NJS_OK)) {\n        njs_internal_error(vm, \"lvlhsh insert failed\");\n        return ret;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":463200,"func":"static void annotation_get_fromdb(annotate_state_t *state,\n                                  struct annotate_entry_list *entry)\n{\n    const char *mboxname = (state->mailbox ? state->mailbox->name : \"\");\n    state->found = 0;\n\n    annotatemore_findall(mboxname, state->uid, entry->name, 0, &rw_cb, state, 0);\n\n    if (state->found != state->attribs &&\n        (!strchr(entry->name, '%') && !strchr(entry->name, '*'))) {\n        \/* some results not found for an explicitly specified entry,\n         * make sure we emit explicit NILs *\/\n        struct buf empty = BUF_INITIALIZER;\n        if (!(state->found & (ATTRIB_VALUE_PRIV|ATTRIB_SIZE_PRIV)) &&\n            (state->attribs & (ATTRIB_VALUE_PRIV|ATTRIB_SIZE_PRIV))) {\n            \/* store up value.priv and\/or size.priv *\/\n            output_entryatt(state, entry->name, state->userid, &empty);\n        }\n        if (!(state->found & (ATTRIB_VALUE_SHARED|ATTRIB_SIZE_SHARED)) &&\n            (state->attribs & (ATTRIB_VALUE_SHARED|ATTRIB_SIZE_SHARED))) {\n            \/* store up value.shared and\/or size.shared *\/\n            output_entryatt(state, entry->name, \"\", &empty);\n        }\n        \/* flush any stored attribute-value pairs *\/\n        flush_entryatt(state);\n    }\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":430396,"func":"static int __ip_tun_to_nlattr(struct sk_buff *skb,\n\t\t\t      const struct ip_tunnel_key *output,\n\t\t\t      const void *tun_opts, int swkey_tun_opts_len,\n\t\t\t      unsigned short tun_proto, u8 mode)\n{\n\tif (output->tun_flags & TUNNEL_KEY &&\n\t    nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id,\n\t\t\t OVS_TUNNEL_KEY_ATTR_PAD))\n\t\treturn -EMSGSIZE;\n\n\tif (mode & IP_TUNNEL_INFO_BRIDGE)\n\t\treturn nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE)\n\t\t       ? -EMSGSIZE : 0;\n\n\tswitch (tun_proto) {\n\tcase AF_INET:\n\t\tif (output->u.ipv4.src &&\n\t\t    nla_put_in_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC,\n\t\t\t\t    output->u.ipv4.src))\n\t\t\treturn -EMSGSIZE;\n\t\tif (output->u.ipv4.dst &&\n\t\t    nla_put_in_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST,\n\t\t\t\t    output->u.ipv4.dst))\n\t\t\treturn -EMSGSIZE;\n\t\tbreak;\n\tcase AF_INET6:\n\t\tif (!ipv6_addr_any(&output->u.ipv6.src) &&\n\t\t    nla_put_in6_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV6_SRC,\n\t\t\t\t     &output->u.ipv6.src))\n\t\t\treturn -EMSGSIZE;\n\t\tif (!ipv6_addr_any(&output->u.ipv6.dst) &&\n\t\t    nla_put_in6_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV6_DST,\n\t\t\t\t     &output->u.ipv6.dst))\n\t\t\treturn -EMSGSIZE;\n\t\tbreak;\n\t}\n\tif (output->tos &&\n\t    nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->tos))\n\t\treturn -EMSGSIZE;\n\tif (nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TTL, output->ttl))\n\t\treturn -EMSGSIZE;\n\tif ((output->tun_flags & TUNNEL_DONT_FRAGMENT) &&\n\t    nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT))\n\t\treturn -EMSGSIZE;\n\tif ((output->tun_flags & TUNNEL_CSUM) &&\n\t    nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_CSUM))\n\t\treturn -EMSGSIZE;\n\tif (output->tp_src &&\n\t    nla_put_be16(skb, OVS_TUNNEL_KEY_ATTR_TP_SRC, output->tp_src))\n\t\treturn -EMSGSIZE;\n\tif (output->tp_dst &&\n\t    nla_put_be16(skb, OVS_TUNNEL_KEY_ATTR_TP_DST, output->tp_dst))\n\t\treturn -EMSGSIZE;\n\tif ((output->tun_flags & TUNNEL_OAM) &&\n\t    nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_OAM))\n\t\treturn -EMSGSIZE;\n\tif (swkey_tun_opts_len) {\n\t\tif (output->tun_flags & TUNNEL_GENEVE_OPT &&\n\t\t    nla_put(skb, OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS,\n\t\t\t    swkey_tun_opts_len, tun_opts))\n\t\t\treturn -EMSGSIZE;\n\t\telse if (output->tun_flags & TUNNEL_VXLAN_OPT &&\n\t\t\t vxlan_opt_to_nlattr(skb, tun_opts, swkey_tun_opts_len))\n\t\t\treturn -EMSGSIZE;\n\t\telse if (output->tun_flags & TUNNEL_ERSPAN_OPT &&\n\t\t\t nla_put(skb, OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS,\n\t\t\t\t swkey_tun_opts_len, tun_opts))\n\t\t\treturn -EMSGSIZE;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":777,"total_token_length":1013,"max_tokens_setting":1024}
+{"idx":513368,"func":"calc_group_buffer(JOIN *join,ORDER *group)\n{\n  uint key_length=0, parts=0, null_parts=0;\n\n  if (group)\n    join->group= 1;\n  for (; group ; group=group->next)\n  {\n    Item *group_item= *group->item;\n    Field *field= group_item->get_tmp_table_field();\n    if (field)\n    {\n      enum_field_types type;\n      if ((type= field->type()) == MYSQL_TYPE_BLOB)\n\tkey_length+=MAX_BLOB_WIDTH;\t\t\/\/ Can't be used as a key\n      else if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_VAR_STRING)\n        key_length+= field->field_length + HA_KEY_BLOB_LENGTH;\n      else if (type == MYSQL_TYPE_BIT)\n      {\n        \/* Bit is usually stored as a longlong key for group fields *\/\n        key_length+= 8;                         \/\/ Big enough\n      }\n      else\n\tkey_length+= field->pack_length();\n    }\n    else\n    { \n      switch (group_item->cmp_type()) {\n      case REAL_RESULT:\n        key_length+= sizeof(double);\n        break;\n      case INT_RESULT:\n        key_length+= sizeof(longlong);\n        break;\n      case DECIMAL_RESULT:\n        key_length+= my_decimal_get_binary_size(group_item->max_length - \n                                                (group_item->decimals ? 1 : 0),\n                                                group_item->decimals);\n        break;\n      case TIME_RESULT:\n      {\n        \/*\n          As items represented as DATE\/TIME fields in the group buffer\n          have STRING_RESULT result type, we increase the length \n          by 8 as maximum pack length of such fields.\n        *\/\n        key_length+= 8;\n        break;\n      }\n      case STRING_RESULT:\n      {\n        enum enum_field_types type= group_item->field_type();\n        if (type == MYSQL_TYPE_BLOB)\n          key_length+= MAX_BLOB_WIDTH;\t\t\/\/ Can't be used as a key\n        else\n        {\n          \/*\n            Group strings are taken as varstrings and require an length field.\n            A field is not yet created by create_tmp_field()\n            and the sizes should match up.\n          *\/\n          key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;\n        }\n        break;\n      }\n      default:\n        \/* This case should never be choosen *\/\n        DBUG_ASSERT(0);\n        my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));\n      }\n    }\n    parts++;\n    if (group_item->maybe_null)\n      null_parts++;\n  }\n  join->tmp_table_param.group_length=key_length+null_parts;\n  join->tmp_table_param.group_parts=parts;\n  join->tmp_table_param.group_null_parts=null_parts;\n}","target":0,"code_token_length":580,"total_token_length":816,"max_tokens_setting":1024}
+{"idx":446401,"func":"RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzList *symbols, SetU *hash) {\n\tRzDyldLocSym *locsym = cache->locsym;\n\tif (!locsym) {\n\t\treturn;\n\t}\n\n\tif (bin->nlist_start_index >= locsym->nlists_count ||\n\t\tbin->nlist_start_index + bin->nlist_count > locsym->nlists_count) {\n\t\tRZ_LOG_ERROR(\"dyldcache: malformed local symbol entry\\n\");\n\t\treturn;\n\t}\n\n\tut64 nlists_size = sizeof(struct MACH0_(nlist)) * bin->nlist_count;\n\tstruct MACH0_(nlist) *nlists = RZ_NEWS0(struct MACH0_(nlist), bin->nlist_count);\n\tif (!nlists) {\n\t\treturn;\n\t}\n\tut64 nlists_offset = locsym->local_symbols_offset + locsym->nlists_offset +\n\t\tbin->nlist_start_index * sizeof(struct MACH0_(nlist));\n\tif (rz_buf_fread_at(cache->buf, nlists_offset, (ut8 *)nlists, \"iccsl\", bin->nlist_count) != nlists_size) {\n\t\tfree(nlists);\n\t\treturn;\n\t}\n\n\tut32 j;\n\tfor (j = 0; j != bin->nlist_count; j++) {\n\t\tstruct MACH0_(nlist) *nlist = &nlists[j];\n\t\tif (set_u_contains(hash, (ut64)nlist->n_value)) {\n\t\t\tcontinue;\n\t\t}\n\t\tset_u_add(hash, (ut64)nlist->n_value);\n\t\tif (nlist->n_strx >= locsym->strings_size) {\n\t\t\tcontinue;\n\t\t}\n\t\tRzBinSymbol *sym = RZ_NEW0(RzBinSymbol);\n\t\tif (!sym) {\n\t\t\tbreak;\n\t\t}\n\t\tsym->type = \"LOCAL\";\n\t\tsym->vaddr = nlist->n_value;\n\t\tut64 slide = rz_dyldcache_get_slide(cache);\n\t\tsym->paddr = va2pa(nlist->n_value, cache->n_maps, cache->maps, cache->buf, slide, NULL, NULL);\n\n\t\tchar *symstr = rz_buf_get_string(cache->buf, locsym->local_symbols_offset + locsym->strings_offset + nlist->n_strx);\n\t\tif (symstr) {\n\t\t\tsym->name = symstr;\n\t\t} else {\n\t\t\tstatic ut32 k = 0;\n\t\t\tsym->name = rz_str_newf(\"unk_local%d\", k++);\n\t\t}\n\n\t\trz_list_append(symbols, sym);\n\t}\n\n\tfree(nlists);\n}","target":0,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":384770,"func":"f_screenpos(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    dict_T\t*dict;\n    win_T\t*wp;\n    pos_T\tpos;\n    int\t\trow = 0;\n    int\t\tscol = 0, ccol = 0, ecol = 0;\n\n    if (rettv_dict_alloc(rettv) != OK)\n\treturn;\n    dict = rettv->vval.v_dict;\n\n    if (in_vim9script()\n\t    && (check_for_number_arg(argvars, 0) == FAIL\n\t\t|| check_for_number_arg(argvars, 1) == FAIL\n\t\t|| check_for_number_arg(argvars, 2) == FAIL))\n\treturn;\n\n    wp = find_win_by_nr_or_id(&argvars[0]);\n    if (wp == NULL)\n\treturn;\n\n    pos.lnum = tv_get_number(&argvars[1]);\n    pos.col = tv_get_number(&argvars[2]) - 1;\n    pos.coladd = 0;\n    textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol);\n\n    dict_add_number(dict, \"row\", row);\n    dict_add_number(dict, \"col\", scol);\n    dict_add_number(dict, \"curscol\", ccol);\n    dict_add_number(dict, \"endcol\", ecol);\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":281621,"func":"void CLASS stretch()\n{\n  ushort newdim, (*img)[4], *pix0, *pix1;\n  int row, col, c;\n  double rc, frac;\n\n  if (pixel_aspect == 1) return;\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_STRETCH,0,2);\n#endif\n#ifdef DCRAW_VERBOSE\n  if (verbose) fprintf (stderr,_(\"Stretching the image...\\n\"));\n#endif\n  if (pixel_aspect < 1) {\n    newdim = height \/ pixel_aspect + 0.5;\n    img = (ushort (*)[4]) calloc (width, newdim*sizeof *img);\n    merror (img, \"stretch()\");\n    for (rc=row=0; row < newdim; row++, rc+=pixel_aspect) {\n      frac = rc - (c = rc);\n      pix0 = pix1 = image[c*width];\n      if (c+1 < height) pix1 += width*4;\n      for (col=0; col < width; col++, pix0+=4, pix1+=4)\n\tFORCC img[row*width+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;\n    }\n    height = newdim;\n  } else {\n    newdim = width * pixel_aspect + 0.5;\n    img = (ushort (*)[4]) calloc (height, newdim*sizeof *img);\n    merror (img, \"stretch()\");\n    for (rc=col=0; col < newdim; col++, rc+=1\/pixel_aspect) {\n      frac = rc - (c = rc);\n      pix0 = pix1 = image[c];\n      if (c+1 < width) pix1 += 4;\n      for (row=0; row < height; row++, pix0+=width*4, pix1+=width*4)\n\tFORCC img[row*newdim+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;\n    }\n    width = newdim;\n  }\n  free (image);\n  image = img;\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_STRETCH,1,2);\n#endif\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":246709,"func":"u32 parse_split(char *arg_val, u32 opt)\n{\n\tswitch (opt) {\n\tcase 0:\/\/-split\n\t\tsplit_duration = atof(arg_val);\n\t\tif (split_duration < 0) split_duration = 0;\n\t\tsplit_size = 0;\n\t\tbreak;\n\tcase 1: \/\/-split-rap, -splitr\n\t\tsplit_duration = -1;\n\t\tsplit_size = -1;\n\t\tbreak;\n\tcase 2: \/\/-split-size, -splits\n\t\tsplit_size = (u32)atoi(arg_val);\n\t\tsplit_duration = 0;\n\t\tbreak;\n\tcase 3: \/\/-split-chunk, -splitx\n\tcase 4: \/\/-splitz\n\tcase 5: \/\/-splitg\n\tcase 6: \/\/-splitf\n\t\tadjust_split_end = opt-3;\n\t\tif (!strstr(arg_val, \":\") && !strstr(arg_val, \"-\")) {\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Chunk extraction usage: \\\"-split* start:end\\\" expressed in seconds\\n\"));\n\t\t\treturn 2;\n\t\t}\n\t\tif (strstr(arg_val, \"end\")) {\n\t\t\tif (strstr(arg_val, \"end-\")) {\n\t\t\t\tDouble dur_end=0;\n\t\t\t\tsscanf(arg_val, \"%lf:end-%lf\", &split_start, &dur_end);\n\t\t\t\tsplit_duration = -2 - dur_end;\n\t\t\t} else {\n\t\t\t\tsscanf(arg_val, \"%lf:end\", &split_start);\n\t\t\t\tsplit_duration = -2;\n\t\t\t}\n\t\t} else {\n\t\t\tsplit_range_str = arg_val;\n\t\t}\n\t\tsplit_size = 0;\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":450426,"func":"static int send_sub_rect(VncState *vs, int x, int y, int w, int h)\n{\n    uint32_t bg = 0, fg = 0;\n    int colors;\n    int ret = 0;\n#ifdef CONFIG_VNC_JPEG\n    bool force_jpeg = false;\n    bool allow_jpeg = true;\n#endif\n\n    if (!color_count_palette) {\n        color_count_palette = g_malloc(sizeof(VncPalette));\n        vnc_tight_cleanup_notifier.notify = vnc_tight_cleanup;\n        qemu_thread_atexit_add(&vnc_tight_cleanup_notifier);\n    }\n\n    vnc_framebuffer_update(vs, x, y, w, h, vs->tight->type);\n\n    vnc_tight_start(vs);\n    vnc_raw_send_framebuffer_update(vs, x, y, w, h);\n    vnc_tight_stop(vs);\n\n#ifdef CONFIG_VNC_JPEG\n    if (!vs->vd->non_adaptive && vs->tight->quality != (uint8_t)-1) {\n        double freq = vnc_update_freq(vs, x, y, w, h);\n\n        if (freq < tight_jpeg_conf[vs->tight->quality].jpeg_freq_min) {\n            allow_jpeg = false;\n        }\n        if (freq >= tight_jpeg_conf[vs->tight->quality].jpeg_freq_threshold) {\n            force_jpeg = true;\n            vnc_sent_lossy_rect(vs, x, y, w, h);\n        }\n    }\n#endif\n\n    colors = tight_fill_palette(vs, x, y, w * h, &bg, &fg, color_count_palette);\n\n#ifdef CONFIG_VNC_JPEG\n    if (allow_jpeg && vs->tight->quality != (uint8_t)-1) {\n        ret = send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors,\n                                 color_count_palette, force_jpeg);\n    } else {\n        ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors,\n                                   color_count_palette);\n    }\n#else\n    ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors,\n                               color_count_palette);\n#endif\n\n    return ret;\n}","target":0,"code_token_length":473,"total_token_length":709,"max_tokens_setting":1024}
+{"idx":276442,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Looks up the resource.\n    core::RefCountPtr<BoostedTreesEnsembleResource> tree_ensemble_resource;\n    OP_REQUIRES_OK(context, LookupResource(context, HandleFromInput(context, 0),\n                                           &tree_ensemble_resource));\n    tf_shared_lock l(*tree_ensemble_resource->get_mutex());\n\n    \/\/ Sets the outputs.\n    const int num_trees = tree_ensemble_resource->num_trees();\n    const int num_finalized_trees =\n        (num_trees <= 0 ||\n         tree_ensemble_resource->IsTreeFinalized(num_trees - 1))\n            ? num_trees\n            : num_trees - 1;\n    const int num_attempted_layers =\n        tree_ensemble_resource->GetNumLayersAttempted();\n\n    \/\/ growing_metadata\n    Tensor* output_stamp_token_t = nullptr;\n    Tensor* output_num_trees_t = nullptr;\n    Tensor* output_num_finalized_trees_t = nullptr;\n    Tensor* output_num_attempted_layers_t = nullptr;\n    Tensor* output_last_layer_nodes_range_t = nullptr;\n\n    OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape(),\n                                                     &output_stamp_token_t));\n    OP_REQUIRES_OK(context, context->allocate_output(1, TensorShape(),\n                                                     &output_num_trees_t));\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(2, TensorShape(),\n                                            &output_num_finalized_trees_t));\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(3, TensorShape(),\n                                            &output_num_attempted_layers_t));\n    OP_REQUIRES_OK(context, context->allocate_output(\n                                4, {2}, &output_last_layer_nodes_range_t));\n\n    output_stamp_token_t->scalar<int64>()() = tree_ensemble_resource->stamp();\n    output_num_trees_t->scalar<int32>()() = num_trees;\n    output_num_finalized_trees_t->scalar<int32>()() = num_finalized_trees;\n    output_num_attempted_layers_t->scalar<int32>()() = num_attempted_layers;\n\n    int32_t range_start;\n    int32_t range_end;\n    tree_ensemble_resource->GetLastLayerNodesRange(&range_start, &range_end);\n\n    output_last_layer_nodes_range_t->vec<int32>()(0) = range_start;\n    \/\/ For a completely empty ensemble, this will be 0. To make it a valid range\n    \/\/ we add this max cond.\n    output_last_layer_nodes_range_t->vec<int32>()(1) = std::max(1, range_end);\n  }","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":436091,"func":"\nstatic int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,\n\t\t\t const struct io_uring_sqe *sqe)\n{\n\tstruct io_submit_link *link = &ctx->submit_state.link;\n\tint ret;\n\n\tret = io_init_req(ctx, req, sqe);\n\tif (unlikely(ret)) {\nfail_req:\n\t\tif (link->head) {\n\t\t\t\/* fail even hard links since we don't submit *\/\n\t\t\treq_set_fail(link->head);\n\t\t\tio_req_complete_failed(link->head, -ECANCELED);\n\t\t\tlink->head = NULL;\n\t\t}\n\t\tio_req_complete_failed(req, ret);\n\t\treturn ret;\n\t}\n\n\tret = io_req_prep(req, sqe);\n\tif (unlikely(ret))\n\t\tgoto fail_req;\n\n\t\/* don't need @sqe from now on *\/\n\ttrace_io_uring_submit_sqe(ctx, req, req->opcode, req->user_data,\n\t\t\t\t  req->flags, true,\n\t\t\t\t  ctx->flags & IORING_SETUP_SQPOLL);\n\n\t\/*\n\t * If we already have a head request, queue this one for async\n\t * submittal once the head completes. If we don't have a head but\n\t * IOSQE_IO_LINK is set in the sqe, start a new head. This one will be\n\t * submitted sync once the chain is complete. If none of those\n\t * conditions are true (normal request), then just queue it.\n\t *\/\n\tif (link->head) {\n\t\tstruct io_kiocb *head = link->head;\n\n\t\tret = io_req_prep_async(req);\n\t\tif (unlikely(ret))\n\t\t\tgoto fail_req;\n\t\ttrace_io_uring_link(ctx, req, head);\n\t\tlink->last->link = req;\n\t\tlink->last = req;\n\n\t\t\/* last request of a link, enqueue the link *\/\n\t\tif (!(req->flags & (REQ_F_LINK | REQ_F_HARDLINK))) {\n\t\t\tlink->head = NULL;\n\t\t\tio_queue_sqe(head);\n\t\t}\n\t} else {\n\t\tif (req->flags & (REQ_F_LINK | REQ_F_HARDLINK)) {\n\t\t\tlink->head = req;\n\t\t\tlink->last = req;\n\t\t} else {\n\t\t\tio_queue_sqe(req);\n\t\t}\n\t}\n\n\treturn 0;","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":516250,"func":"static void virtio_net_reset(VirtIODevice *vdev)\n{\n    VirtIONet *n = VIRTIO_NET(vdev);\n    int i;\n\n    \/* Reset back to compatibility mode *\/\n    n->promisc = 1;\n    n->allmulti = 0;\n    n->alluni = 0;\n    n->nomulti = 0;\n    n->nouni = 0;\n    n->nobcast = 0;\n    \/* multiqueue is disabled by default *\/\n    n->curr_queues = 1;\n    timer_del(n->announce_timer.tm);\n    n->announce_timer.round = 0;\n    n->status &= ~VIRTIO_NET_S_ANNOUNCE;\n\n    \/* Flush any MAC and VLAN filter table state *\/\n    n->mac_table.in_use = 0;\n    n->mac_table.first_multi = 0;\n    n->mac_table.multi_overflow = 0;\n    n->mac_table.uni_overflow = 0;\n    memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);\n    memcpy(&n->mac[0], &n->nic->conf->macaddr, sizeof(n->mac));\n    qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);\n    memset(n->vlans, 0, MAX_VLAN >> 3);\n\n    \/* Flush any async TX *\/\n    for (i = 0;  i < n->max_queues; i++) {\n        NetClientState *nc = qemu_get_subqueue(n->nic, i);\n\n        if (nc->peer) {\n            qemu_flush_or_purge_queued_packets(nc->peer, true);\n            assert(!virtio_net_get_subqueue(nc)->async_tx.elem);\n        }\n    }\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":261188,"func":"int MqttClient_Ping_ex(MqttClient *client, MqttPing* ping)\n{\n    int rc, len;\n\n    \/* Validate required arguments *\/\n    if (client == NULL || ping == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    if (ping->stat == MQTT_MSG_BEGIN) {\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n\n        \/* Encode the subscribe packet *\/\n        rc = MqttEncode_Ping(client->tx_buf, client->tx_buf_len, ping);\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d\",\n            rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_PING_REQ),\n            MQTT_PACKET_TYPE_PING_REQ, 0, 0);\n    #endif\n        if (rc <= 0) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            return rc;\n        }\n        len = rc;\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        rc = wm_SemLock(&client->lockClient);\n        if (rc == 0) {\n            \/* inform other threads of expected response *\/\n            rc = MqttClient_RespList_Add(client, MQTT_PACKET_TYPE_PING_RESP, 0,\n                &ping->pendResp, ping);\n            wm_SemUnlock(&client->lockClient);\n        }\n        if (rc != 0) {\n            wm_SemUnlock(&client->lockSend);\n            return rc; \/* Error locking client *\/\n        }\n    #endif\n\n        \/* Send ping req packet *\/\n        rc = MqttPacket_Write(client, client->tx_buf, len);\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n        if (rc != len) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (wm_SemLock(&client->lockClient) == 0) {\n                MqttClient_RespList_Remove(client, &ping->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n        #endif\n            return rc;\n        }\n\n        ping->stat = MQTT_MSG_WAIT;\n    }\n\n    \/* Wait for ping resp packet *\/\n    rc = MqttClient_WaitType(client, ping, MQTT_PACKET_TYPE_PING_RESP, 0,\n        client->cmd_timeout_ms);\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &ping->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n    \/* reset state *\/\n    ping->stat = MQTT_MSG_BEGIN;\n\n    return rc;\n}","target":0,"code_token_length":668,"total_token_length":904,"max_tokens_setting":1024}
+{"idx":312571,"func":"qf_parse_get_fields(\n\tchar_u\t\t*linebuf,\n\tint\t\tlinelen,\n\tefm_T\t\t*fmt_ptr,\n\tqffields_T\t*fields,\n\tint\t\tqf_multiline,\n\tint\t\tqf_multiscan,\n\tchar_u\t\t**tail)\n{\n    regmatch_T\tregmatch;\n    int\t\tstatus = QF_FAIL;\n    int\t\tr;\n\n    if (qf_multiscan &&\n\t\tvim_strchr((char_u *)\"OPQ\", fmt_ptr->prefix) == NULL)\n\treturn QF_FAIL;\n\n    fields->namebuf[0] = NUL;\n    fields->module[0] = NUL;\n    fields->pattern[0] = NUL;\n    if (!qf_multiscan)\n\tfields->errmsg[0] = NUL;\n    fields->lnum = 0;\n    fields->end_lnum = 0;\n    fields->col = 0;\n    fields->end_col = 0;\n    fields->use_viscol = FALSE;\n    fields->enr = -1;\n    fields->type = 0;\n    *tail = NULL;\n\n    \/\/ Always ignore case when looking for a matching error.\n    regmatch.rm_ic = TRUE;\n    regmatch.regprog = fmt_ptr->prog;\n    r = vim_regexec(®match, linebuf, (colnr_T)0);\n    fmt_ptr->prog = regmatch.regprog;\n    if (r)\n\tstatus = qf_parse_match(linebuf, linelen, fmt_ptr, ®match,\n\t\tfields, qf_multiline, qf_multiscan, tail);\n\n    return status;\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":488392,"func":"static __init int vdso_fixup_features(struct lib32_elfinfo *v32,\n\t\t\t\t      struct lib64_elfinfo *v64)\n{\n\tvoid *start32;\n\tunsigned long size32;\n\n#ifdef CONFIG_PPC64\n\tvoid *start64;\n\tunsigned long size64;\n\n\tstart64 = find_section64(v64->hdr, \"__ftr_fixup\", &size64);\n\tif (start64)\n\t\tdo_feature_fixups(cur_cpu_spec->cpu_features,\n\t\t\t\t  start64, start64 + size64);\n\n\tstart64 = find_section64(v64->hdr, \"__fw_ftr_fixup\", &size64);\n\tif (start64)\n\t\tdo_feature_fixups(powerpc_firmware_features,\n\t\t\t\t  start64, start64 + size64);\n#endif \/* CONFIG_PPC64 *\/\n\n\tstart32 = find_section32(v32->hdr, \"__ftr_fixup\", &size32);\n\tif (start32)\n\t\tdo_feature_fixups(cur_cpu_spec->cpu_features,\n\t\t\t\t  start32, start32 + size32);\n\n#ifdef CONFIG_PPC64\n\tstart32 = find_section32(v32->hdr, \"__fw_ftr_fixup\", &size32);\n\tif (start32)\n\t\tdo_feature_fixups(powerpc_firmware_features,\n\t\t\t\t  start32, start32 + size32);\n#endif \/* CONFIG_PPC64 *\/\n\n\treturn 0;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":344252,"func":"static int forprep (lua_State *L, StkId ra) {\n  TValue *pinit = s2v(ra);\n  TValue *plimit = s2v(ra + 1);\n  TValue *pstep = s2v(ra + 2);\n  if (ttisinteger(pinit) && ttisinteger(pstep)) { \/* integer loop? *\/\n    lua_Integer init = ivalue(pinit);\n    lua_Integer step = ivalue(pstep);\n    lua_Integer limit;\n    if (step == 0)\n      luaG_runerror(L, \"'for' step is zero\");\n    setivalue(s2v(ra + 3), init);  \/* control variable *\/\n    if (forlimit(L, init, plimit, &limit, step))\n      return 1;  \/* skip the loop *\/\n    else {  \/* prepare loop counter *\/\n      lua_Unsigned count;\n      if (step > 0) {  \/* ascending loop? *\/\n        count = l_castS2U(limit) - l_castS2U(init);\n        if (step != 1)  \/* avoid division in the too common case *\/\n          count \/= l_castS2U(step);\n      }\n      else {  \/* step < 0; descending loop *\/\n        count = l_castS2U(init) - l_castS2U(limit);\n        \/* 'step+1' avoids negating 'mininteger' *\/\n        count \/= l_castS2U(-(step + 1)) + 1u;\n      }\n      \/* store the counter in place of the limit (which won't be\n         needed anymore) *\/\n      setivalue(plimit, l_castU2S(count));\n    }\n  }\n  else {  \/* try making all values floats *\/\n    lua_Number init; lua_Number limit; lua_Number step;\n    if (l_unlikely(!tonumber(plimit, &limit)))\n      luaG_forerror(L, plimit, \"limit\");\n    if (l_unlikely(!tonumber(pstep, &step)))\n      luaG_forerror(L, pstep, \"step\");\n    if (l_unlikely(!tonumber(pinit, &init)))\n      luaG_forerror(L, pinit, \"initial value\");\n    if (step == 0)\n      luaG_runerror(L, \"'for' step is zero\");\n    if (luai_numlt(0, step) ? luai_numlt(limit, init)\n                            : luai_numlt(init, limit))\n      return 1;  \/* skip the loop *\/\n    else {\n      \/* make sure internal values are all floats *\/\n      setfltvalue(plimit, limit);\n      setfltvalue(pstep, step);\n      setfltvalue(s2v(ra), init);  \/* internal index *\/\n      setfltvalue(s2v(ra + 3), init);  \/* control variable *\/\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":203614,"func":"pxa3xx_gcu_write(struct file *file, const char *buff,\n\t\t size_t count, loff_t *offp)\n{\n\tint ret;\n\tunsigned long flags;\n\tstruct pxa3xx_gcu_batch\t*buffer;\n\tstruct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);\n\n\tint words = count \/ 4;\n\n\t\/* Does not need to be atomic. There's a lock in user space,\n\t * but anyhow, this is just for statistics. *\/\n\tpriv->shared->num_writes++;\n\tpriv->shared->num_words += words;\n\n\t\/* Last word reserved for batch buffer end command *\/\n\tif (words >= PXA3XX_GCU_BATCH_WORDS)\n\t\treturn -E2BIG;\n\n\t\/* Wait for a free buffer *\/\n\tif (!priv->free) {\n\t\tret = pxa3xx_gcu_wait_free(priv);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\n\t\/*\n\t * Get buffer from free list\n\t *\/\n\tspin_lock_irqsave(&priv->spinlock, flags);\n\tbuffer = priv->free;\n\tpriv->free = buffer->next;\n\tspin_unlock_irqrestore(&priv->spinlock, flags);\n\n\n\t\/* Copy data from user into buffer *\/\n\tret = copy_from_user(buffer->ptr, buff, words * 4);\n\tif (ret) {\n\t\tspin_lock_irqsave(&priv->spinlock, flags);\n\t\tbuffer->next = priv->free;\n\t\tpriv->free = buffer;\n\t\tspin_unlock_irqrestore(&priv->spinlock, flags);\n\t\treturn -EFAULT;\n\t}\n\n\tbuffer->length = words;\n\n\t\/* Append batch buffer end command *\/\n\tbuffer->ptr[words] = 0x01000000;\n\n\t\/*\n\t * Add buffer to ready list\n\t *\/\n\tspin_lock_irqsave(&priv->spinlock, flags);\n\n\tbuffer->next = NULL;\n\n\tif (priv->ready) {\n\t\tBUG_ON(priv->ready_last == NULL);\n\n\t\tpriv->ready_last->next = buffer;\n\t} else\n\t\tpriv->ready = buffer;\n\n\tpriv->ready_last = buffer;\n\n\tif (!priv->shared->hw_running)\n\t\trun_ready(priv);\n\n\tspin_unlock_irqrestore(&priv->spinlock, flags);\n\n\treturn words * 4;\n}","target":1,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":276923,"func":"static int do_i2c_show_bus(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t\t   char *const argv[])\n{\n\tif (argc == 1) {\n\t\t\/* show all busses *\/\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tstruct udevice *bus;\n\t\tstruct uclass *uc;\n\t\tint ret;\n\n\t\tret = uclass_get(UCLASS_I2C, &uc);\n\t\tif (ret)\n\t\t\treturn CMD_RET_FAILURE;\n\t\tuclass_foreach_dev(bus, uc)\n\t\t\tshow_bus(bus);\n#else\n\t\tint i;\n\n\t\tfor (i = 0; i < CONFIG_SYS_NUM_I2C_BUSES; i++) {\n\t\t\tprintf(\"Bus %d:\\t%s\", i, I2C_ADAP_NR(i)->name);\n#ifndef CONFIG_SYS_I2C_DIRECT_BUS\n\t\t\tint j;\n\n\t\t\tfor (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {\n\t\t\t\tif (i2c_bus[i].next_hop[j].chip == 0)\n\t\t\t\t\tbreak;\n\t\t\t\tprintf(\"->%s@0x%2x:%d\",\n\t\t\t\t       i2c_bus[i].next_hop[j].mux.name,\n\t\t\t\t       i2c_bus[i].next_hop[j].chip,\n\t\t\t\t       i2c_bus[i].next_hop[j].channel);\n\t\t\t}\n#endif\n\t\t\tprintf(\"\\n\");\n\t\t}\n#endif\n\t} else {\n\t\tint i;\n\n\t\t\/* show specific bus *\/\n\t\ti = dectoul(argv[1], NULL);\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tstruct udevice *bus;\n\t\tint ret;\n\n\t\tret = uclass_get_device_by_seq(UCLASS_I2C, i, &bus);\n\t\tif (ret) {\n\t\t\tprintf(\"Invalid bus %d: err=%d\\n\", i, ret);\n\t\t\treturn CMD_RET_FAILURE;\n\t\t}\n\t\tshow_bus(bus);\n#else\n\t\tif (i >= CONFIG_SYS_NUM_I2C_BUSES) {\n\t\t\tprintf(\"Invalid bus %d\\n\", i);\n\t\t\treturn -1;\n\t\t}\n\t\tprintf(\"Bus %d:\\t%s\", i, I2C_ADAP_NR(i)->name);\n#ifndef CONFIG_SYS_I2C_DIRECT_BUS\n\t\t\tint j;\n\t\t\tfor (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {\n\t\t\t\tif (i2c_bus[i].next_hop[j].chip == 0)\n\t\t\t\t\tbreak;\n\t\t\t\tprintf(\"->%s@0x%2x:%d\",\n\t\t\t\t       i2c_bus[i].next_hop[j].mux.name,\n\t\t\t\t       i2c_bus[i].next_hop[j].chip,\n\t\t\t\t       i2c_bus[i].next_hop[j].channel);\n\t\t\t}\n#endif\n\t\tprintf(\"\\n\");\n#endif\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":226958,"func":"IRC_PROTOCOL_CALLBACK(327)\n{\n    char *pos_realname;\n    struct t_gui_buffer *ptr_buffer;\n\n    IRC_PROTOCOL_MIN_ARGS(6);\n\n    pos_realname = (argc > 6) ?\n        ((argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]) : NULL;\n\n    ptr_buffer = irc_msgbuffer_get_target_buffer (server, argv[3],\n                                                  command, \"whois\", NULL);\n\n    if (pos_realname && pos_realname[0])\n    {\n        weechat_printf_date_tags (\n            ptr_buffer,\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s %s %s(%s%s%s)\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_HOST,\n            argv[4],\n            argv[5],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            pos_realname,\n            IRC_COLOR_CHAT_DELIMITERS);\n    }\n    else\n    {\n        weechat_printf_date_tags (\n            ptr_buffer,\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s %s\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_CHAT_HOST,\n            argv[4],\n            argv[5]);\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":508865,"func":"ha_rows st_select_lex::get_limit()\n{\n  ulonglong val= HA_POS_ERROR;\n\n  if (select_limit)\n  {\n    \/*\n      fix_fields() has not been called for select_limit. That's due to the\n      historical reasons -- this item could be only of type Item_int, and\n      Item_int does not require fix_fields(). Thus, fix_fields() was never\n      called for select_limit.\n\n      Some time ago, Item_splocal was also allowed for LIMIT \/ OFFSET clauses.\n      However, the fix_fields() behavior was not updated, which led to a crash\n      in some cases.\n\n      There is no single place where to call fix_fields() for LIMIT \/ OFFSET\n      items during the fix-fields-phase. Thus, for the sake of readability,\n      it was decided to do it here, on the evaluation phase (which is a\n      violation of design, but we chose the lesser of two evils).\n\n      We can call fix_fields() here, because select_limit can be of two\n      types only: Item_int and Item_splocal. Item_int::fix_fields() is trivial,\n      and Item_splocal::fix_fields() (or rather Item_sp_variable::fix_fields())\n      has the following properties:\n        1) it does not affect other items;\n        2) it does not fail.\n\n      Nevertheless DBUG_ASSERT was added to catch future changes in\n      fix_fields() implementation. Also added runtime check against a result\n      of fix_fields() in order to handle error condition in non-debug build.\n    *\/\n    bool fix_fields_successful= true;\n    if (!select_limit->fixed)\n    {\n      fix_fields_successful= !select_limit->fix_fields(master_unit()->thd,\n                                                       NULL);\n\n      DBUG_ASSERT(fix_fields_successful);\n    }\n    val= fix_fields_successful ? select_limit->val_uint() : HA_POS_ERROR;\n  }\n\n  return (ha_rows)val;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":401533,"func":"u64 get_next_timer_interrupt(unsigned long basej, u64 basem)\n{\n\tstruct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);\n\tu64 expires = KTIME_MAX;\n\tunsigned long nextevt;\n\tbool is_max_delta;\n\n\t\/*\n\t * Pretend that there is no timer pending if the cpu is offline.\n\t * Possible pending timers will be migrated later to an active cpu.\n\t *\/\n\tif (cpu_is_offline(smp_processor_id()))\n\t\treturn expires;\n\n\traw_spin_lock(&base->lock);\n\tnextevt = __next_timer_interrupt(base);\n\tis_max_delta = (nextevt == base->clk + NEXT_TIMER_MAX_DELTA);\n\tbase->next_expiry = nextevt;\n\t\/*\n\t * We have a fresh next event. Check whether we can forward the\n\t * base. We can only do that when @basej is past base->clk\n\t * otherwise we might rewind base->clk.\n\t *\/\n\tif (time_after(basej, base->clk)) {\n\t\tif (time_after(nextevt, basej))\n\t\t\tbase->clk = basej;\n\t\telse if (time_after(nextevt, base->clk))\n\t\t\tbase->clk = nextevt;\n\t}\n\n\tif (time_before_eq(nextevt, basej)) {\n\t\texpires = basem;\n\t\tbase->is_idle = false;\n\t} else {\n\t\tif (!is_max_delta)\n\t\t\texpires = basem + (u64)(nextevt - basej) * TICK_NSEC;\n\t\t\/*\n\t\t * If we expect to sleep more than a tick, mark the base idle.\n\t\t * Also the tick is stopped so any added timer must forward\n\t\t * the base clk itself to keep granularity small. This idle\n\t\t * logic is only maintained for the BASE_STD base, deferrable\n\t\t * timers may still see large granularity skew (by design).\n\t\t *\/\n\t\tif ((expires - basem) > TICK_NSEC) {\n\t\t\tbase->must_forward_clk = true;\n\t\t\tbase->is_idle = true;\n\t\t}\n\t}\n\traw_spin_unlock(&base->lock);\n\n\treturn cmp_next_hrtimer_event(basem, expires);\n}","target":0,"code_token_length":446,"total_token_length":682,"max_tokens_setting":1024}
+{"idx":369418,"func":" *\/\nstatic int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,\n\t\t\t  const sigset_t __user *sig, size_t sigsz,\n\t\t\t  struct __kernel_timespec __user *uts)\n{\n\tstruct io_wait_queue iowq;\n\tstruct io_rings *rings = ctx->rings;\n\tktime_t timeout = KTIME_MAX;\n\tint ret;\n\n\tdo {\n\t\tio_cqring_overflow_flush(ctx);\n\t\tif (io_cqring_events(ctx) >= min_events)\n\t\t\treturn 0;\n\t\tif (!io_run_task_work())\n\t\t\tbreak;\n\t} while (1);\n\n\tif (sig) {\n#ifdef CONFIG_COMPAT\n\t\tif (in_compat_syscall())\n\t\t\tret = set_compat_user_sigmask((const compat_sigset_t __user *)sig,\n\t\t\t\t\t\t      sigsz);\n\t\telse\n#endif\n\t\t\tret = set_user_sigmask(sig, sigsz);\n\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tif (uts) {\n\t\tstruct timespec64 ts;\n\n\t\tif (get_timespec64(&ts, uts))\n\t\t\treturn -EFAULT;\n\t\ttimeout = ktime_add_ns(timespec64_to_ktime(ts), ktime_get_ns());\n\t}\n\n\tinit_waitqueue_func_entry(&iowq.wq, io_wake_function);\n\tiowq.wq.private = current;\n\tINIT_LIST_HEAD(&iowq.wq.entry);\n\tiowq.ctx = ctx;\n\tiowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);\n\tiowq.cq_tail = READ_ONCE(ctx->rings->cq.head) + min_events;\n\n\ttrace_io_uring_cqring_wait(ctx, min_events);\n\tdo {\n\t\t\/* if we can't even flush overflow, don't wait for more *\/\n\t\tif (!io_cqring_overflow_flush(ctx)) {\n\t\t\tret = -EBUSY;\n\t\t\tbreak;\n\t\t}\n\t\tprepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq,\n\t\t\t\t\t\tTASK_INTERRUPTIBLE);\n\t\tret = io_cqring_wait_schedule(ctx, &iowq, timeout);\n\t\tfinish_wait(&ctx->cq_wait, &iowq.wq);\n\t\tcond_resched();\n\t} while (ret > 0);\n\n\trestore_saved_sigmask_unless(ret == -EINTR);\n\n\treturn READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0;","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":357668,"func":"bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)\n{\n    SQObjectPtr temp;\n    bool belongs_to_static_table = sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE || bstatic;\n    if(_locked && !belongs_to_static_table)\n        return false; \/\/the class already has an instance so cannot be modified\n    if(_members->Get(key,temp) && _isfield(temp)) \/\/overrides the default value\n    {\n        _defaultvalues[_member_idx(temp)].val = val;\n        return true;\n    }\n\tif (_members->CountUsed() >= MEMBER_MAX_COUNT) {\n\t\treturn false;\n\t}\n    if(belongs_to_static_table) {\n        SQInteger mmidx;\n        if((sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE) &&\n            (mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {\n            _metamethods[mmidx] = val;\n        }\n        else {\n            SQObjectPtr theval = val;\n            if(_base && sq_type(val) == OT_CLOSURE) {\n                theval = _closure(val)->Clone();\n                _closure(theval)->_base = _base;\n                __ObjAddRef(_base); \/\/ref for the closure\n            }\n            if(sq_type(temp) == OT_NULL) {\n                bool isconstructor;\n                SQVM::IsEqual(ss->_constructoridx, key, isconstructor);\n                if(isconstructor) {\n                    _constructoridx = (SQInteger)_methods.size();\n                }\n                SQClassMember m;\n                m.val = theval;\n                _members->NewSlot(key,SQObjectPtr(_make_method_idx(_methods.size())));\n                _methods.push_back(m);\n            }\n            else {\n                _methods[_member_idx(temp)].val = theval;\n            }\n        }\n        return true;\n    }\n    SQClassMember m;\n    m.val = val;\n    _members->NewSlot(key,SQObjectPtr(_make_field_idx(_defaultvalues.size())));\n    _defaultvalues.push_back(m);\n    return true;\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":380957,"func":"ins_eol(int c)\n{\n    int\t    i;\n\n    if (echeck_abbr(c + ABBR_OFF))\n\treturn OK;\n    if (stop_arrow() == FAIL)\n\treturn FAIL;\n    undisplay_dollar();\n\n    \/*\n     * Strange Vi behaviour: In Replace mode, typing a NL will not delete the\n     * character under the cursor.  Only push a NUL on the replace stack,\n     * nothing to put back when the NL is deleted.\n     *\/\n    if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))\n\treplace_push(NUL);\n\n    \/*\n     * In MODE_VREPLACE state, a NL replaces the rest of the line, and starts\n     * replacing the next line, so we push all of the characters left on the\n     * line onto the replace stack.  This is not done here though, it is done\n     * in open_line().\n     *\/\n\n    \/\/ Put cursor on NUL if on the last char and coladd is 1 (happens after\n    \/\/ CTRL-O).\n    if (virtual_active() && curwin->w_cursor.coladd > 0)\n\tcoladvance(getviscol());\n\n#ifdef FEAT_RIGHTLEFT\n    \/\/ NL in reverse insert will always start in the end of\n    \/\/ current line.\n    if (revins_on)\n\tcurwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());\n#endif\n\n    AppendToRedobuff(NL_STR);\n    i = open_line(FORWARD,\n\t    has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent,\n\t    NULL);\n    old_indent = 0;\n    can_cindent = TRUE;\n#ifdef FEAT_FOLDING\n    \/\/ When inserting a line the cursor line must never be in a closed fold.\n    foldOpenCursor();\n#endif\n\n    return i;\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":196620,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& input = context->input(0);\n    const TensorShape& input_shape = input.shape();\n    const int32_t input_dims = input_shape.dims();\n\n    const Tensor& segment_id = context->input(1);\n    const TensorShape& segment_id_shape = segment_id.shape();\n    const int32_t segment_dims = segment_id_shape.dims();\n\n    const Tensor& num_segments_tensor = context->input(2);\n    OP_REQUIRES(context, num_segments_tensor.NumElements() != 0,\n                errors::InvalidArgument(\"Number of segments cannot be empty.\"));\n    auto num_segments = num_segments_tensor.scalar<NUM_SEGMENTS_TYPE>()();\n\n    OP_REQUIRES(context, num_segments > 0,\n                errors::InvalidArgument(\"Number of segments must be positive\"));\n    OP_REQUIRES(context, segment_dims != 0,\n                errors::InvalidArgument(\"Segment_id cannot have rank 0\"));\n\n    OP_REQUIRES(\n        context, segment_dims <= input_dims,\n        errors::OutOfRange(\"Invalid segment_id rank \", segment_dims,\n                           \" for input with \", input_dims, \" dimension(s)\"));\n    for (auto i = 0; i < segment_dims; i++) {\n      OP_REQUIRES(\n          context, segment_id_shape.dim_size(i) == input_shape.dim_size(i),\n          errors::InvalidArgument(\n              \"Segment dimension is \", segment_id_shape.dim_size(i),\n              \" while input dimension is \", input_dims, \" in rank \", i));\n    }\n\n    \/\/ Making output tensor.\n    Tensor* output_tensor = nullptr;\n    TensorShape output_shape =\n        GetOutputShape(input_shape, segment_id_shape, num_segments);\n    OP_REQUIRES_OK(context, context->allocate_output(\"output\", output_shape,\n                                                     &output_tensor));\n\n    \/\/ Preparating flat tensors.\n    auto output_flat = output_tensor->flat<tstring>();\n    auto flat_segment_id = segment_id.flat<INDICES_TYPE>();\n    auto flat_input = input.flat<tstring>();\n\n    for (int i = 0; i < flat_segment_id.size(); i++) {\n      OP_REQUIRES(\n          context,\n          ((flat_segment_id(i) < num_segments) && (flat_segment_id(i) >= 0)),\n          errors::InvalidArgument(\n              \"segment_ids are not allowed to exceed num_segments or\"\n              \" to have negative values.\"));\n    }\n\n    int64_t big_stride;\n    int64_t small_stride;\n    std::tie(big_stride, small_stride) =\n        GetStrides<INDICES_TYPE>(input_shape, segment_id_shape);\n    auto relative_offset_set =\n        GetFlattenedRelativeOffsets<INDICES_TYPE>(small_stride, big_stride);\n    for (auto start_offset = 0; start_offset < big_stride; start_offset++) {\n      for (auto i = 0; i < relative_offset_set.size(); i++) {\n        auto output_index = start_offset + flat_segment_id(i) * big_stride;\n        auto offset = start_offset + relative_offset_set[i];\n        if (output_flat(output_index).length() != 0)\n          output_flat(output_index).append(separator_.c_str());\n        output_flat(output_index).append(flat_input(offset));\n      }\n    }\n  }","target":1,"code_token_length":672,"total_token_length":908,"max_tokens_setting":1024}
+{"idx":292136,"func":"void LinkResolver::throw_abstract_method_error(const methodHandle& resolved_method,\n                                               const methodHandle& selected_method,\n                                               Klass *recv_klass, TRAPS) {\n  Klass *resolved_klass = resolved_method->method_holder();\n  ResourceMark rm(THREAD);\n  stringStream ss;\n\n  if (recv_klass != NULL) {\n    ss.print(\"Receiver class %s does not define or inherit an \"\n             \"implementation of the\",\n             recv_klass->external_name());\n  } else {\n    ss.print(\"Missing implementation of\");\n  }\n\n  assert(resolved_method.not_null(), \"Sanity\");\n  ss.print(\" resolved method '%s%s\",\n           resolved_method->is_abstract() ? \"abstract \" : \"\",\n           resolved_method->is_private()  ? \"private \"  : \"\");\n  resolved_method->signature()->print_as_signature_external_return_type(&ss);\n  ss.print(\" %s(\", resolved_method->name()->as_C_string());\n  resolved_method->signature()->print_as_signature_external_parameters(&ss);\n  ss.print(\")' of %s %s.\",\n           resolved_klass->external_kind(),\n           resolved_klass->external_name());\n\n  if (selected_method.not_null() && !(resolved_method == selected_method)) {\n    ss.print(\" Selected method is '%s%s\",\n             selected_method->is_abstract() ? \"abstract \" : \"\",\n             selected_method->is_private()  ? \"private \"  : \"\");\n    selected_method->print_external_name(&ss);\n    ss.print(\"'.\");\n  }\n\n  THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":195629,"func":"Status GetDeviceForInput(const EagerOperation& op, const EagerContext& ctx,\n                         TensorHandle* tensor_handle, Device** result) {\n  Device* cpu_device = ctx.HostCPU();\n  string device_name;\n  if (tensor_handle->Type() != TensorHandle::LOCAL) {\n    Device* device = tensor_handle->device();\n    device_name = device != nullptr ? device->name() : cpu_device->name();\n    *result = (device == nullptr ? cpu_device : device);\n  } else if (tensor_handle->dtype == DT_RESOURCE) {\n    \/\/ Use the resource's actual device because it is the device that will\n    \/\/ influence partitioning the multi-device function.\n    const Tensor* tensor;\n    \/\/ TODO(fishx): Avoid blocking here.\n    TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor));\n    const ResourceHandle& handle = tensor->flat<ResourceHandle>()(0);\n    device_name = handle.device();\n\n    Device* input_device;\n    TF_RETURN_IF_ERROR(\n        ctx.FindDeviceFromName(device_name.c_str(), &input_device));\n    *result = input_device;\n  } else {\n    Device* device = tensor_handle->device();\n    const bool is_tpu = device != nullptr && device->device_type() == \"TPU\";\n    \/\/ int32 return values can be placed on TPUs.\n    const bool use_host_memory =\n        is_tpu ? MTypeFromDTypeIntsOnDevice(tensor_handle->dtype)\n               : MTypeFromDType(tensor_handle->dtype);\n    if (use_host_memory) {\n      *result = cpu_device;\n    } else {\n      \/\/ Eager ops executing as functions should have their preferred inputs set\n      \/\/ to the op's device. This allows us to avoid expensive D2H copies if a\n      \/\/ mirror of the tensor already exists on the op's device.\n      if (!op.is_function() && device != nullptr && device != cpu_device) {\n        device = absl::get<Device*>(op.Device());\n      }\n      *result = (device == nullptr ? cpu_device : device);\n    }\n  }\n  return Status::OK();\n}","target":1,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":436081,"func":"static int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_async_msghdr iomsg, *kmsg;\n\tstruct socket *sock;\n\tstruct io_buffer *kbuf;\n\tunsigned flags;\n\tint min_ret = 0;\n\tint ret, cflags = 0;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tkmsg = req->async_data;\n\tif (!kmsg) {\n\t\tret = io_recvmsg_copy_hdr(req, &iomsg);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tkmsg = &iomsg;\n\t}\n\n\tif (req->flags & REQ_F_BUFFER_SELECT) {\n\t\tkbuf = io_recv_buffer_select(req, !force_nonblock);\n\t\tif (IS_ERR(kbuf))\n\t\t\treturn PTR_ERR(kbuf);\n\t\tkmsg->fast_iov[0].iov_base = u64_to_user_ptr(kbuf->addr);\n\t\tkmsg->fast_iov[0].iov_len = req->sr_msg.len;\n\t\tiov_iter_init(&kmsg->msg.msg_iter, READ, kmsg->fast_iov,\n\t\t\t\t1, req->sr_msg.len);\n\t}\n\n\tflags = req->sr_msg.msg_flags;\n\tif (force_nonblock)\n\t\tflags |= MSG_DONTWAIT;\n\tif (flags & MSG_WAITALL)\n\t\tmin_ret = iov_iter_count(&kmsg->msg.msg_iter);\n\n\tret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.umsg,\n\t\t\t\t\tkmsg->uaddr, flags);\n\tif (force_nonblock && ret == -EAGAIN)\n\t\treturn io_setup_async_msg(req, kmsg);\n\tif (ret == -ERESTARTSYS)\n\t\tret = -EINTR;\n\n\tif (req->flags & REQ_F_BUFFER_SELECTED)\n\t\tcflags = io_put_recv_kbuf(req);\n\t\/* fast path, check for non-NULL to avoid function call *\/\n\tif (kmsg->free_iov)\n\t\tkfree(kmsg->free_iov);\n\treq->flags &= ~REQ_F_NEED_CLEANUP;\n\tif (ret < min_ret || ((flags & MSG_WAITALL) && (kmsg->msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))))\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, cflags);\n\treturn 0;\n}","target":0,"code_token_length":509,"total_token_length":745,"max_tokens_setting":1024}
+{"idx":213513,"func":"static inline void ConvertLuvToXYZ(const double L,const double u,const double v,\n  double *X,double *Y,double *Z)\n{\n  assert(X != (double *) NULL);\n  assert(Y != (double *) NULL);\n  assert(Z != (double *) NULL);\n  if (L > (CIEK*CIEEpsilon))\n    *Y=(double) pow((L+16.0)\/116.0,3.0);\n  else\n    *Y=L\/CIEK;\n  *X=((*Y*((39.0*L\/(v+13.0*L*(9.0*D65Y\/(D65X+15.0*D65Y+3.0*D65Z))))-5.0))+\n    5.0*(*Y))\/((((52.0*L\/(u+13.0*L*(4.0*D65X\/(D65X+15.0*D65Y+3.0*D65Z))))-1.0)\/\n    3.0)-(-1.0\/3.0));\n  *Z=(*X*(((52.0*L\/(u+13.0*L*(4.0*D65X\/(D65X+15.0*D65Y+3.0*D65Z))))-1.0)\/3.0))-\n    5.0*(*Y);\n}","target":1,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":481265,"func":"static inline int mlx5_fpga_conn_rts_qp(struct mlx5_fpga_conn *conn)\n{\n\tstruct mlx5_fpga_device *fdev = conn->fdev;\n\tstruct mlx5_core_dev *mdev = fdev->mdev;\n\tu32 *qpc = NULL;\n\tu32 opt_mask;\n\tint err;\n\n\tmlx5_fpga_dbg(conn->fdev, \"QP RTS\\n\");\n\n\tqpc = kzalloc(MLX5_ST_SZ_BYTES(qpc), GFP_KERNEL);\n\tif (!qpc) {\n\t\terr = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tMLX5_SET(qpc, qpc, log_ack_req_freq, 8);\n\tMLX5_SET(qpc, qpc, min_rnr_nak, 0x12);\n\tMLX5_SET(qpc, qpc, primary_address_path.ack_timeout, 0x12); \/* ~1.07s *\/\n\tMLX5_SET(qpc, qpc, next_send_psn,\n\t\t MLX5_GET(fpga_qpc, conn->fpga_qpc, next_rcv_psn));\n\tMLX5_SET(qpc, qpc, retry_count, 7);\n\tMLX5_SET(qpc, qpc, rnr_retry, 7); \/* Infinite retry if RNR NACK *\/\n\n\topt_mask = MLX5_QP_OPTPAR_RNR_TIMEOUT;\n\terr = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_RTR2RTS_QP, opt_mask, qpc,\n\t\t\t\t  &conn->qp.mqp);\n\tif (err) {\n\t\tmlx5_fpga_warn(fdev, \"qp_modify RST2INIT failed: %d\\n\", err);\n\t\tgoto out;\n\t}\n\nout:\n\tkfree(qpc);\n\treturn err;\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":194996,"func":"Status GetInitOp(const string& export_dir, const MetaGraphDef& meta_graph_def,\n                 string* init_op_name) {\n  const auto& sig_def_map = meta_graph_def.signature_def();\n  const auto& init_op_sig_it =\n      meta_graph_def.signature_def().find(kSavedModelInitOpSignatureKey);\n  if (init_op_sig_it != sig_def_map.end()) {\n    *init_op_name = init_op_sig_it->second.outputs()\n                        .find(kSavedModelInitOpSignatureKey)\n                        ->second.name();\n    return Status::OK();\n  }\n\n  const auto& collection_def_map = meta_graph_def.collection_def();\n  string init_op_collection_key;\n  if (collection_def_map.find(kSavedModelMainOpKey) !=\n      collection_def_map.end()) {\n    init_op_collection_key = kSavedModelMainOpKey;\n  } else {\n    init_op_collection_key = kSavedModelLegacyInitOpKey;\n  }\n\n  const auto init_op_it = collection_def_map.find(init_op_collection_key);\n  if (init_op_it != collection_def_map.end()) {\n    if (init_op_it->second.node_list().value_size() != 1) {\n      return errors::FailedPrecondition(\n          strings::StrCat(\"Expected exactly one main op in : \", export_dir));\n    }\n    *init_op_name = init_op_it->second.node_list().value(0);\n  }\n  return Status::OK();\n}","target":1,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":90861,"func":"void QuotaManagerTest::GetUsage_WithModifyTestBody(const StorageType type) {\n  const MockOriginData data[] = {\n    { \"http:\/\/foo.com\/\",   type,  10 },\n    { \"http:\/\/foo.com:1\/\", type,  20 },\n  };\n  MockStorageClient* client = CreateClient(data, ARRAYSIZE_UNSAFE(data));\n  RegisterClient(client);\n\n  GetUsageAndQuota(GURL(\"http:\/\/foo.com\/\"), type);\n  MessageLoop::current()->RunAllPending();\n  EXPECT_EQ(kQuotaStatusOk, status());\n  EXPECT_EQ(10 + 20, usage());\n\n  client->ModifyOriginAndNotify(GURL(\"http:\/\/foo.com\/\"), type, 30);\n  client->ModifyOriginAndNotify(GURL(\"http:\/\/foo.com:1\/\"), type, -5);\n  client->AddOriginAndNotify(GURL(\"https:\/\/foo.com\/\"), type, 1);\n\n  GetUsageAndQuota(GURL(\"http:\/\/foo.com\/\"), type);\n  MessageLoop::current()->RunAllPending();\n  EXPECT_EQ(kQuotaStatusOk, status());\n  EXPECT_EQ(10 + 20 + 30 - 5 + 1, usage());\n  int foo_usage = usage();\n\n  client->AddOriginAndNotify(GURL(\"http:\/\/bar.com\/\"), type, 40);\n  GetUsageAndQuota(GURL(\"http:\/\/bar.com\/\"), type);\n  MessageLoop::current()->RunAllPending();\n  EXPECT_EQ(kQuotaStatusOk, status());\n  EXPECT_EQ(40, usage());\n\n  GetGlobalUsage(type);\n  MessageLoop::current()->RunAllPending();\n  EXPECT_EQ(foo_usage + 40, usage());\n  EXPECT_EQ(0, unlimited_usage());\n}\n","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":244200,"func":"GF_Err chnl_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s;\n\n\tISOM_DECREASE_SIZE(s, 1)\n\tptr->layout.stream_structure = gf_bs_read_u8(bs);\n\tif (ptr->layout.stream_structure & 1) {\n\t\tISOM_DECREASE_SIZE(s, 1)\n\t\tptr->layout.definedLayout = gf_bs_read_u8(bs);\n\t\tif (ptr->layout.definedLayout) {\n\t\t\tu32 remain = (u32) ptr->size;\n\t\t\tif (ptr->layout.stream_structure & 2) remain--;\n\t\t\tptr->layout.channels_count = 0;\n\t\t\twhile (remain) {\n\t\t\t\tISOM_DECREASE_SIZE(s, 1)\n\t\t\t\tptr->layout.layouts[ptr->layout.channels_count].position = gf_bs_read_u8(bs);\n\t\t\t\tremain--;\n\t\t\t\tif (ptr->layout.layouts[ptr->layout.channels_count].position == 126) {\n\t\t\t\t\tISOM_DECREASE_SIZE(s, 3)\n\t\t\t\t\tptr->layout.layouts[ptr->layout.channels_count].azimuth = gf_bs_read_int(bs, 16);\n\t\t\t\t\tptr->layout.layouts[ptr->layout.channels_count].elevation = gf_bs_read_int(bs, 8);\n\t\t\t\t\tremain-=3;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(s, 8)\n\t\t\tptr->layout.omittedChannelsMap = gf_bs_read_u64(bs);\n\t\t}\n\t}\n\tif (ptr->layout.stream_structure & 2) {\n\t\tISOM_DECREASE_SIZE(s, 1)\n\t\tptr->layout.object_count = gf_bs_read_u8(bs);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":369222,"func":"static int io_accept(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_accept *accept = &req->accept;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\tunsigned int file_flags = force_nonblock ? O_NONBLOCK : 0;\n\tbool fixed = !!accept->file_slot;\n\tstruct file *file;\n\tint ret, fd;\n\n\tif (!fixed) {\n\t\tfd = __get_unused_fd_flags(accept->flags, accept->nofile);\n\t\tif (unlikely(fd < 0))\n\t\t\treturn fd;\n\t}\n\tfile = do_accept(req->file, file_flags, accept->addr, accept->addr_len,\n\t\t\t accept->flags);\n\tif (IS_ERR(file)) {\n\t\tif (!fixed)\n\t\t\tput_unused_fd(fd);\n\t\tret = PTR_ERR(file);\n\t\tif (ret == -EAGAIN && force_nonblock)\n\t\t\treturn -EAGAIN;\n\t\tif (ret == -ERESTARTSYS)\n\t\t\tret = -EINTR;\n\t\treq_set_fail(req);\n\t} else if (!fixed) {\n\t\tfd_install(fd, file);\n\t\tret = fd;\n\t} else {\n\t\tret = io_install_fixed_file(req, file, issue_flags,\n\t\t\t\t\t    accept->file_slot - 1);\n\t}\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":309973,"func":"check_sgr(TERMTYPE2 *tp, char *zero, int num, char *cap, const char *name)\n{\n    char *test;\n\n    _nc_tparm_err = 0;\n    test = TIPARM_9(set_attributes,\n\t\t    num == 1,\n\t\t    num == 2,\n\t\t    num == 3,\n\t\t    num == 4,\n\t\t    num == 5,\n\t\t    num == 6,\n\t\t    num == 7,\n\t\t    num == 8,\n\t\t    num == 9);\n    if (test != 0) {\n\tif (PRESENT(cap)) {\n\t    if (!similar_sgr(num, test, cap)) {\n\t\t_nc_warning(\"%s differs from sgr(%d)\\n\\t%s=%s\\n\\tsgr(%d)=%s\",\n\t\t\t    name, num,\n\t\t\t    name, _nc_visbuf2(1, cap),\n\t\t\t    num, _nc_visbuf2(2, test));\n\t    }\n\t} else if (_nc_capcmp(test, zero)) {\n\t    _nc_warning(\"sgr(%d) present, but not %s\", num, name);\n\t}\n    } else if (PRESENT(cap)) {\n\t_nc_warning(\"sgr(%d) missing, but %s present\", num, name);\n    }\n    if (_nc_tparm_err)\n\t_nc_warning(\"stack error in sgr(%d) string\", num);\n    return test;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":383378,"func":"int gdImageNegate(gdImagePtr src)\n{\n\tint x, y;\n\tint r,g,b,a;\n\tint new_pxl, pxl;\n\ttypedef int (*FuncPtr)(gdImagePtr, int, int);\n\tFuncPtr f;\n\n\tif (src==NULL) {\n\t\treturn 0;\n\t}\n    \n\tf = GET_PIXEL_FUNCTION(src);\n\n\tfor (y=0; y<src->sy; ++y) {\n\t\tfor (x=0; x<src->sx; ++x) {\n\t\t\tpxl = f (src, x, y);\n\t\t\tr = gdImageRed(src, pxl);\n\t\t\tg = gdImageGreen(src, pxl);\n\t\t\tb = gdImageBlue(src, pxl);\n\t\t\ta = gdImageAlpha(src, pxl);\n\t\t\t\n\t\t\tnew_pxl = gdImageColorAllocateAlpha(src, 255-r, 255-g, 255-b, a);\n\t\t\tif (new_pxl == -1) {\n\t\t\t\tnew_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a);\n\t\t\t}\n\t\t\tif ((y >= 0) && (y < src->sy)) {\n\t\t\t\tgdImageSetPixel (src, x, y, new_pxl);\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":339711,"func":"(Bigint *a, int *e)\n#endif\n{\n\tULong *xa, *xa0, w, y, z;\n\tint k;\n\t_double d;\n#ifdef VAX\n\tULong d0, d1;\n#else\n#define d0 word0(d)\n#define d1 word1(d)\n#endif\n\n\txa0 = a->x;\n\txa = xa0 + a->wds;\n\ty = *--xa;\n#ifdef DEBUG\n\tif (!y) Bug(\"zero y in b2d\");\n#endif\n\tk = hi0bits(y);\n\t*e = 32 - k;\n#ifdef Pack_32\n\tif (k < Ebits) {\n\t\td0 = Exp_1 | y >> (Ebits - k);\n\t\tw = xa > xa0 ? *--xa : 0;\n\t\td1 = y << ((32-Ebits) + k) | w >> (Ebits - k);\n\t\tgoto ret_d;\n\t}\n\tz = xa > xa0 ? *--xa : 0;\n\tif (k -= Ebits) {\n\t\td0 = Exp_1 | y << k | z >> (32 - k);\n\t\ty = xa > xa0 ? *--xa : 0;\n\t\td1 = z << k | y >> (32 - k);\n\t}\n\telse {\n\t\td0 = Exp_1 | y;\n\t\td1 = z;\n\t}\n#else\n\tif (k < Ebits + 16) {\n\t\tz = xa > xa0 ? *--xa : 0;\n\t\td0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;\n\t\tw = xa > xa0 ? *--xa : 0;\n\t\ty = xa > xa0 ? *--xa : 0;\n\t\td1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;\n\t\tgoto ret_d;\n\t}\n\tz = xa > xa0 ? *--xa : 0;\n\tw = xa > xa0 ? *--xa : 0;\n\tk -= Ebits + 16;\n\td0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;\n\ty = xa > xa0 ? *--xa : 0;\n\td1 = w << k + 16 | y << k;\n#endif\nret_d:\n#ifdef VAX\n\tword0(d) = d0 >> 16 | d0 << 16;\n\tword1(d) = d1 >> 16 | d1 << 16;\n#else\n#undef d0\n#undef d1\n#endif\n\treturn value(d);\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":346435,"func":"script_autoload(\n    char_u\t*name,\n    int\t\treload)\t    \/\/ load script again when already loaded\n{\n    char_u\t*p;\n    char_u\t*scriptname, *tofree;\n    int\t\tret = FALSE;\n    int\t\ti;\n    int\t\tret_sid;\n\n    \/\/ If the name starts with \"<SNR>123_\" then \"123\" is the script ID.\n    if (name[0] == K_SPECIAL && name[1] == KS_EXTRA && name[2] == KE_SNR)\n    {\n\tp = name + 3;\n\tret_sid = (int)getdigits(&p);\n\tif (*p == '_' && SCRIPT_ID_VALID(ret_sid))\n\t{\n\t    may_load_script(ret_sid, &ret);\n\t    return ret;\n\t}\n    }\n\n    \/\/ If there is no '#' after name[0] there is no package name.\n    p = vim_strchr(name, AUTOLOAD_CHAR);\n    if (p == NULL || p == name)\n\treturn FALSE;\n\n    tofree = scriptname = autoload_name(name);\n    if (scriptname == NULL)\n\treturn FALSE;\n\n    \/\/ Find the name in the list of previously loaded package names.  Skip\n    \/\/ \"autoload\/\", it's always the same.\n    for (i = 0; i < ga_loaded.ga_len; ++i)\n\tif (STRCMP(((char_u **)ga_loaded.ga_data)[i] + 9, scriptname + 9) == 0)\n\t    break;\n    if (!reload && i < ga_loaded.ga_len)\n\tret = FALSE;\t    \/\/ was loaded already\n    else\n    {\n\t\/\/ Remember the name if it wasn't loaded already.\n\tif (i == ga_loaded.ga_len && ga_grow(&ga_loaded, 1) == OK)\n\t{\n\t    ((char_u **)ga_loaded.ga_data)[ga_loaded.ga_len++] = scriptname;\n\t    tofree = NULL;\n\t}\n\n\t\/\/ Try loading the package from $VIMRUNTIME\/autoload\/<name>.vim\n\t\/\/ Use \"ret_sid\" to avoid loading the same script again.\n\tif (source_in_path(p_rtp, scriptname, DIP_START, &ret_sid) == OK)\n\t    ret = TRUE;\n    }\n\n    vim_free(tofree);\n    return ret;\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":207071,"func":"DeepTiledInputFile::initialize ()\n{\n    if (_data->partNumber == -1)\n        if (_data->header.type() != DEEPTILE)\n            throw IEX_NAMESPACE::ArgExc (\"Expected a deep tiled file but the file is not deep tiled.\");\n   if(_data->header.version()!=1)\n   {\n       THROW(IEX_NAMESPACE::ArgExc, \"Version \" << _data->header.version() << \" not supported for deeptiled images in this version of the library\");\n   }\n        \n    _data->header.sanityCheck (true);\n\n    \/\/\n    \/\/ before allocating memory for tile offsets, confirm file is large enough\n    \/\/ to contain tile offset table\n    \/\/ (for multipart files, the chunk offset table has already been read)\n    \/\/\n    if (!isMultiPart(_data->version))\n    {\n        _data->validateStreamSize();\n    }\n\n\n    _data->tileDesc = _data->header.tileDescription();\n    _data->lineOrder = _data->header.lineOrder();\n\n    \/\/\n    \/\/ Save the dataWindow information\n    \/\/\n\n    const Box2i &dataWindow = _data->header.dataWindow();\n    _data->minX = dataWindow.min.x;\n    _data->maxX = dataWindow.max.x;\n    _data->minY = dataWindow.min.y;\n    _data->maxY = dataWindow.max.y;\n\n    \/\/\n    \/\/ Precompute level and tile information to speed up utility functions\n    \/\/\n\n    precalculateTileInfo (_data->tileDesc,\n                          _data->minX, _data->maxX,\n                          _data->minY, _data->maxY,\n                          _data->numXTiles, _data->numYTiles,\n                          _data->numXLevels, _data->numYLevels);\n\n    \/\/\n    \/\/ Create all the TileBuffers and allocate their internal buffers\n    \/\/\n\n    _data->tileOffsets = TileOffsets (_data->tileDesc.mode,\n                                      _data->numXLevels,\n                                      _data->numYLevels,\n                                      _data->numXTiles,\n                                      _data->numYTiles);\n\n    for (size_t i = 0; i < _data->tileBuffers.size(); i++)\n        _data->tileBuffers[i] = new TileBuffer ();\n\n    _data->maxSampleCountTableSize = _data->tileDesc.ySize *\n                                     _data->tileDesc.xSize *\n                                     sizeof(int);\n\n    _data->sampleCountTableBuffer.resizeErase(_data->maxSampleCountTableSize);\n\n    _data->sampleCountTableComp = newCompressor(_data->header.compression(),\n                                                _data->maxSampleCountTableSize,\n                                                _data->header);\n                                                \n                                                \n    const ChannelList & c=_data->header.channels();\n    _data->combinedSampleSize=0;\n    for(ChannelList::ConstIterator i=c.begin();i!=c.end();i++)\n    {\n        switch( i.channel().type )\n        {\n            case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF  :\n                _data->combinedSampleSize+=Xdr::size<half>();\n                break;\n            case OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT :\n                _data->combinedSampleSize+=Xdr::size<float>();\n                break;\n            case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT  :\n                _data->combinedSampleSize+=Xdr::size<unsigned int>();\n                break;\n            default :\n                THROW(IEX_NAMESPACE::ArgExc, \"Bad type for channel \" << i.name() << \" initializing deepscanline reader\");\n        }\n    }\n                                                  \n}","target":1,"code_token_length":740,"total_token_length":976,"max_tokens_setting":1024}
+{"idx":270397,"func":"static bool ok_inflater_compressed_block(ok_inflater *inflater) {\n    const bool is_fixed = inflater->state == OK_INFLATER_STATE_READING_FIXED_COMPRESSED_BLOCK;\n    const ok_inflater_huffman_tree *literal_tree =\n        (is_fixed ? inflater->fixed_literal_huffman : inflater->literal_huffman);\n    const ok_inflater_huffman_tree *distance_tree =\n        (is_fixed ? inflater->fixed_distance_huffman : inflater->distance_huffman);\n\n    \/\/ decode literal\/length value from input stream\n\n    size_t max_write = ok_inflater_can_write_total(inflater);\n    const uint16_t *tree_lookup_table = literal_tree->lookup_table;\n    const unsigned int tree_bits = literal_tree->bits;\n    while (max_write > 0) {\n        int value = ok_inflater_decode_literal(inflater, tree_lookup_table, tree_bits);\n        if (value < 0) {\n            \/\/ Needs input\n            return false;\n        } else if (value < 256) {\n            ok_inflater_write_byte(inflater, (uint8_t)value);\n            max_write--;\n        } else if (value == 256) {\n            inflater->state = OK_INFLATER_STATE_READY_FOR_NEXT_BLOCK;\n            return true;\n        } else if (value < 286) {\n            inflater->huffman_code = value - 257;\n            inflater->state_count = -1;\n            inflater->state_distance = -1;\n            if (ok_inflater_distance_with_tree(inflater, distance_tree)) {\n                max_write = ok_inflater_can_write_total(inflater);\n            } else {\n                if (is_fixed) {\n                    inflater->state = OK_INFLATER_STATE_READING_FIXED_DISTANCE;\n                } else {\n                    inflater->state = OK_INFLATER_STATE_READING_DYNAMIC_DISTANCE;\n                }\n                return false;\n            }\n        } else {\n            ok_inflater_error(inflater, \"Invalid inflater literal\");\n            return false;\n        }\n    }\n    \/\/ Output buffer full\n    return false;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":488399,"func":"copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,\n\t\tpte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma,\n\t\tunsigned long addr, int *rss)\n{\n\tunsigned long vm_flags = vma->vm_flags;\n\tpte_t pte = *src_pte;\n\tstruct page *page;\n\n\t\/* pte contains position in swap or file, so copy. *\/\n\tif (unlikely(!pte_present(pte))) {\n\t\tif (!pte_file(pte)) {\n\t\t\tswp_entry_t entry = pte_to_swp_entry(pte);\n\n\t\t\tswap_duplicate(entry);\n\t\t\t\/* make sure dst_mm is on swapoff's mmlist. *\/\n\t\t\tif (unlikely(list_empty(&dst_mm->mmlist))) {\n\t\t\t\tspin_lock(&mmlist_lock);\n\t\t\t\tif (list_empty(&dst_mm->mmlist))\n\t\t\t\t\tlist_add(&dst_mm->mmlist,\n\t\t\t\t\t\t &src_mm->mmlist);\n\t\t\t\tspin_unlock(&mmlist_lock);\n\t\t\t}\n\t\t\tif (is_write_migration_entry(entry) &&\n\t\t\t\t\tis_cow_mapping(vm_flags)) {\n\t\t\t\t\/*\n\t\t\t\t * COW mappings require pages in both parent\n\t\t\t\t * and child to be set to read.\n\t\t\t\t *\/\n\t\t\t\tmake_migration_entry_read(&entry);\n\t\t\t\tpte = swp_entry_to_pte(entry);\n\t\t\t\tset_pte_at(src_mm, addr, src_pte, pte);\n\t\t\t}\n\t\t}\n\t\tgoto out_set_pte;\n\t}\n\n\t\/*\n\t * If it's a COW mapping, write protect it both\n\t * in the parent and the child\n\t *\/\n\tif (is_cow_mapping(vm_flags)) {\n\t\tptep_set_wrprotect(src_mm, addr, src_pte);\n\t\tpte = pte_wrprotect(pte);\n\t}\n\n\t\/*\n\t * If it's a shared mapping, mark it clean in\n\t * the child\n\t *\/\n\tif (vm_flags & VM_SHARED)\n\t\tpte = pte_mkclean(pte);\n\tpte = pte_mkold(pte);\n\n\tpage = vm_normal_page(vma, addr, pte);\n\tif (page) {\n\t\tget_page(page);\n\t\tpage_dup_rmap(page, vma, addr);\n\t\trss[!!PageAnon(page)]++;\n\t}\n\nout_set_pte:\n\tset_pte_at(dst_mm, addr, dst_pte, pte);\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":522335,"func":"static int64_t GetFilSiz(GmfMshSct *msh)\n{\n   int64_t CurPos, EndPos = 0;\n\n   if(msh->typ & Bin)\n   {\n#ifdef WITH_GMF_AIO\n      CurPos = lseek(msh->FilDes, 0, 1);\n      EndPos = lseek(msh->FilDes, 0, 2);\n      lseek(msh->FilDes, (off_t)CurPos, 0);\n#else\n      CurPos = MYFTELL(msh->hdl);\n\n      if(MYFSEEK(msh->hdl, 0, SEEK_END) != 0)\n         longjmp(msh->err, -32);\n\n      EndPos = MYFTELL(msh->hdl);\n\n      if(MYFSEEK(msh->hdl, (off_t)CurPos, SEEK_SET) != 0)\n         longjmp(msh->err, -33);\n#endif\n   }\n   else\n   {\n      CurPos = MYFTELL(msh->hdl);\n\n      if(MYFSEEK(msh->hdl, 0, SEEK_END) != 0)\n         longjmp(msh->err, -34);\n\n      EndPos = MYFTELL(msh->hdl);\n\n      if(MYFSEEK(msh->hdl, (off_t)CurPos, SEEK_SET) != 0)\n         longjmp(msh->err, -35);\n   }\n\n   return(EndPos);\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":226325,"func":"\nGF_Err trun_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n#ifdef GF_ENABLE_CTRN\n\tif (ptr->use_ctrn)\n\t\treturn ctrn_box_write(s, bs);\n#endif\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->sample_count);\n\n\t\/\/The rest depends on the flags\n\tif (ptr->flags & GF_ISOM_TRUN_DATA_OFFSET) {\n\t\tgf_bs_write_u32(bs, ptr->data_offset);\n\t}\n\tif (ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) {\n\t\tgf_bs_write_u32(bs, ptr->first_sample_flags);\n\t}\n\n\tif (ptr->flags & (GF_ISOM_TRUN_DURATION | GF_ISOM_TRUN_SIZE | GF_ISOM_TRUN_FLAGS | GF_ISOM_TRUN_CTS_OFFSET) )  {\n\t\tfor (i=0; i<ptr->nb_samples; i++) {\n\t\t\tGF_TrunEntry *p = &ptr->samples[i];\n\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_DURATION) {\n\t\t\t\tgf_bs_write_u32(bs, p->Duration);\n\t\t\t}\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_SIZE) {\n\t\t\t\tgf_bs_write_u32(bs, p->size);\n\t\t\t}\n\t\t\t\/\/SHOULDN'T BE USED IF GF_ISOM_TRUN_FIRST_FLAG IS DEFINED\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_FLAGS) {\n\t\t\t\tgf_bs_write_u32(bs, p->flags);\n\t\t\t}\n\t\t\tif (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) {\n\t\t\t\tif (ptr->version==0) {\n\t\t\t\t\tgf_bs_write_u32(bs, p->CTS_Offset);\n\t\t\t\t} else {\n\t\t\t\t\tgf_bs_write_u32(bs, (u32) p->CTS_Offset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (ptr->sample_order) {\n\t\tu32 nb_bits = 8;\n\t\tif (ptr->sample_count>0xFFFFFF) nb_bits = 32;\n\t\telse if (ptr->sample_count>0xFFFF) nb_bits = 24;\n\t\telse if (ptr->sample_count>0xFF) nb_bits = 16;\n\n\t\tfor (i=0; i<ptr->sample_count; i++) {\n\t\t\tgf_bs_write_int(bs, ptr->sample_order[i], nb_bits);\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":249979,"func":"static GF_Err WriteMoovAndMeta(GF_ISOFile *movie, GF_List *writers, GF_BitStream *bs)\n{\n\tu32 i;\n\tTrackWriter *writer;\n\tGF_Err e;\n\tGF_Box *stco;\n\tGF_SampleToChunkBox *stsc;\n\n\tif (movie->meta) {\n\t\t\/\/write the moov box...\n\t\te = gf_isom_box_size((GF_Box *)movie->meta);\n\t\tif (e) return e;\n\t\te = gf_isom_box_write((GF_Box *)movie->meta, bs);\n\t\tif (e) return e;\n\t}\n\n\tif (movie->moov) {\n\t\tBool prevent_dispatch = GF_FALSE;\n\t\t\/\/switch all our tables\n\t\ti=0;\n\t\twhile ((writer = (TrackWriter*)gf_list_enum(writers, &i))) {\n\t\t\t\/\/don't delete them !!!\n\t\t\tstsc = writer->stbl->SampleToChunk;\n\t\t\tstco = writer->stbl->ChunkOffset;\n\t\t\ts32 stsc_pos = gf_list_del_item(writer->stbl->child_boxes, stsc);\n\t\t\ts32 stco_pos = gf_list_del_item(writer->stbl->child_boxes, stco);\n\t\t\twriter->stbl->SampleToChunk = writer->stsc;\n\t\t\twriter->stbl->ChunkOffset = writer->stco;\n\t\t\tgf_list_insert(writer->stbl->child_boxes, writer->stsc, stsc_pos);\n\t\t\tgf_list_insert(writer->stbl->child_boxes, writer->stco, stco_pos);\n\t\t\twriter->stco = stco;\n\t\t\twriter->stsc = stsc;\n\t\t\tif (writer->prevent_dispatch)\n\t\t\t\tprevent_dispatch = GF_TRUE;\n\t\t}\n\t\tif (prevent_dispatch) {\n\t\t\tgf_bs_prevent_dispatch(bs, GF_TRUE);\n\t\t}\n\t\t\/\/write the moov box...\n\t\te = gf_isom_box_size((GF_Box *)movie->moov);\n\t\tif (e) return e;\n\n\t\tif ((movie->compress_mode==GF_ISO_COMP_ALL) || (movie->compress_mode==GF_ISO_COMP_MOOV)) {\n\t\t\te = gf_isom_write_compressed_box(movie, (GF_Box *) movie->moov, GF_4CC('!', 'm', 'o', 'v'), bs, NULL);\n\t\t} else {\n\t\t\te = gf_isom_box_write((GF_Box *)movie->moov, bs);\n\t\t}\n\n\t\tif (prevent_dispatch) {\n\t\t\tgf_bs_prevent_dispatch(bs, GF_FALSE);\n\t\t}\n\n\t\t\/\/and re-switch our table. We have to do it that way because it is\n\t\t\/\/needed when the moov is written first\n\t\ti=0;\n\t\twhile ((writer = (TrackWriter*)gf_list_enum(writers, &i))) {\n\t\t\t\/\/don't delete them !!!\n\t\t\tstsc = writer->stsc;\n\t\t\tstco = writer->stco;\n\t\t\twriter->stsc = writer->stbl->SampleToChunk;\n\t\t\twriter->stco = writer->stbl->ChunkOffset;\n\t\t\ts32 stsc_pos = gf_list_del_item(writer->stbl->child_boxes, writer->stsc);\n\t\t\ts32 stco_pos = gf_list_del_item(writer->stbl->child_boxes, writer->stco);\n\n\t\t\twriter->stbl->SampleToChunk = stsc;\n\t\t\twriter->stbl->ChunkOffset = stco;\n\t\t\tgf_list_insert(writer->stbl->child_boxes, stsc, stsc_pos);\n\t\t\tgf_list_insert(writer->stbl->child_boxes, stco, stco_pos);\n\t\t}\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":786,"total_token_length":1022,"max_tokens_setting":1024}
+{"idx":415206,"func":"cmd_getinfo (assuan_context_t ctx, char *line)\n{\n  int rc = 0;\n\n  if (!strcmp (line, \"version\"))\n    {\n      const char *s = VERSION;\n      rc = assuan_send_data (ctx, s, strlen (s));\n    }\n  else if (!strcmp (line, \"pid\"))\n    {\n      char numbuf[50];\n\n      snprintf (numbuf, sizeof numbuf, \"%lu\", (unsigned long)getpid ());\n      rc = assuan_send_data (ctx, numbuf, strlen (numbuf));\n    }\n  else if (!strcmp (line, \"socket_name\"))\n    {\n      const char *s = scd_get_socket_name ();\n\n      if (s)\n        rc = assuan_send_data (ctx, s, strlen (s));\n      else\n        rc = gpg_error (GPG_ERR_NO_DATA);\n    }\n  else if (!strcmp (line, \"status\"))\n    {\n      ctrl_t ctrl = assuan_get_pointer (ctx);\n      int vrdr = ctrl->server_local->vreader_idx;\n      char flag = 'r';\n\n      if (!ctrl->server_local->card_removed && vrdr != -1)\n\t{\n\t  struct vreader_s *vr;\n\n\t  if (!(vrdr >= 0 && vrdr < DIM(vreader_table)))\n\t    BUG ();\n\n\t  vr = &vreader_table[vrdr];\n\t  if (vr->valid && vr->any && (vr->status & 1))\n\t    flag = 'u';\n\t}\n      rc = assuan_send_data (ctx, &flag, 1);\n    }\n  else if (!strcmp (line, \"reader_list\"))\n    {\n#ifdef HAVE_LIBUSB\n      char *s = ccid_get_reader_list ();\n#else\n      char *s = NULL;\n#endif\n\n      if (s)\n        rc = assuan_send_data (ctx, s, strlen (s));\n      else\n        rc = gpg_error (GPG_ERR_NO_DATA);\n      xfree (s);\n    }\n  else if (!strcmp (line, \"deny_admin\"))\n    rc = opt.allow_admin? gpg_error (GPG_ERR_GENERAL) : 0;\n  else if (!strcmp (line, \"app_list\"))\n    {\n      char *s = get_supported_applications ();\n      if (s)\n        rc = assuan_send_data (ctx, s, strlen (s));\n      else\n        rc = 0;\n      xfree (s);\n    }\n  else\n    rc = set_error (GPG_ERR_ASS_PARAMETER, \"unknown value for WHAT\");\n  return rc;\n}","target":0,"code_token_length":540,"total_token_length":776,"max_tokens_setting":1024}
+{"idx":274712,"func":"check_align_files_possibility (gerbv_selection_info_t *sel_info)\n{\n\tgerbv_fileinfo_t **f = mainProject->file;\n\tGtkMenuItem **menu_items = (GtkMenuItem **) screen.win.curEditAlingItem;\n\tgerbv_selection_item_t si[2];\n\tint id[2] = {-1, -1};\n\tint i;\n\n\t\/* If has two objects, then can do files aligning *\/\n\tif (selection_length (sel_info) == 2) {\n\t\tsi[0] = selection_get_item_by_index(sel_info, 0);\n\t\tsi[1] = selection_get_item_by_index(sel_info, 1);\n\n\t\tfor (i = 0; i <= mainProject->last_loaded; i++) {\n\t\t\tif (f[i]->image == si[0].image)\n\t\t\t\tid[0] = i;\n\t\t\t\t\t\t\n\t\t\tif (f[i]->image == si[1].image)\n\t\t\t\tid[1] = i;\n\t\t}\n\n\t\t\/* Can align if on different files *\/\n\t\tif (id[0]*id[1] >= 0 && id[0] != id[1]) {\n\t\t\tgchar *str;\n\n\/* TODO: add color boxes for layers as hint *\/\n\n\t\t\t\/* Update align menu items *\/\n\t\t\tstr = g_strdup_printf (_(\"#_%i %s  >  #%i %s\"),\n\t\t\t\t\tid[0]+1, f[id[0]]->name,\n\t\t\t\t\tid[1]+1, f[id[1]]->name);\n\t\t\tgtk_menu_item_set_label (menu_items[0], str);\n\t\t\tg_free (str);\n\n\t\t\tstr = g_strdup_printf (_(\"#_%i %s  >  #%i %s\"),\n\t\t\t\t\tid[1]+1, f[id[1]]->name,\n\t\t\t\t\tid[0]+1, f[id[0]]->name);\n\t\t\tgtk_menu_item_set_label (menu_items[1], str);\n\t\t\tg_free (str);\n\n\t\t\tgtk_widget_set_sensitive (\n\t\t\t\tscreen.win.curEditAlingMenuItem, TRUE);\n\n\t\t\treturn TRUE;\n\t\t}\n\t}\n\n\t\/* Can't align, disable align menu *\/\n\tgtk_widget_set_sensitive (screen.win.curEditAlingMenuItem, FALSE);\n\tgtk_menu_item_set_label (menu_items[0], \"\");\n\tgtk_menu_item_set_label (menu_items[1], \"\");\n\n\treturn FALSE;\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":243004,"func":"int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> parse change cipher spec\" ) );\n\n    if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 )\n    {\n        MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_read_record\", ret );\n        return( ret );\n    }\n\n    if( ssl->in_msgtype != MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad change cipher spec message\" ) );\n        mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n                                        MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );\n        return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );\n    }\n\n    \/* CCS records are only accepted if they have length 1 and content '1',\n     * so we don't need to check this here. *\/\n\n    \/*\n     * Switch to our negotiated transform and session parameters for inbound\n     * data.\n     *\/\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"switching to new transform spec for inbound data\" ) );\n    ssl->transform_in = ssl->transform_negotiate;\n    ssl->session_in = ssl->session_negotiate;\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n    {\n#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)\n        mbedtls_ssl_dtls_replay_reset( ssl );\n#endif\n\n        \/* Increment epoch *\/\n        if( ++ssl->in_epoch == 0 )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"DTLS epoch would wrap\" ) );\n            \/* This is highly unlikely to happen for legitimate reasons, so\n               treat it as an attack and don't send an alert. *\/\n            return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING );\n        }\n    }\n    else\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n    memset( ssl->in_ctr, 0, 8 );\n\n    mbedtls_ssl_update_in_pointers( ssl );\n\n#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)\n    if( mbedtls_ssl_hw_record_activate != NULL )\n    {\n        if( ( ret = mbedtls_ssl_hw_record_activate( ssl, MBEDTLS_SSL_CHANNEL_INBOUND ) ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_hw_record_activate\", ret );\n            mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n                                            MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );\n            return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );\n        }\n    }\n#endif\n\n    ssl->state++;\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= parse change cipher spec\" ) );\n\n    return( 0 );\n}","target":0,"code_token_length":618,"total_token_length":854,"max_tokens_setting":1024}
+{"idx":225724,"func":"GF_Err stsz_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\t\/\/in both versions this is still valid\n\tif (ptr->type == GF_ISOM_BOX_TYPE_STSZ) {\n\t\tgf_bs_write_u32(bs, ptr->sampleSize);\n\t} else {\n\t\tgf_bs_write_u24(bs, 0);\n\t\tgf_bs_write_u8(bs, ptr->sampleSize);\n\t}\n\tgf_bs_write_u32(bs, ptr->sampleCount);\n\n\tif (ptr->type == GF_ISOM_BOX_TYPE_STSZ) {\n\t\tif (! ptr->sampleSize) {\n\t\t\tfor (i = 0; i < ptr->sampleCount; i++) {\n\t\t\t\tgf_bs_write_u32(bs, ptr->sizes ? ptr->sizes[i] : 0);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (i = 0; i < ptr->sampleCount; ) {\n\t\t\tswitch (ptr->sampleSize) {\n\t\t\tcase 4:\n\t\t\t\tgf_bs_write_int(bs, ptr->sizes[i], 4);\n\t\t\t\tif (i+1 < ptr->sampleCount) {\n\t\t\t\t\tgf_bs_write_int(bs, ptr->sizes[i+1], 4);\n\t\t\t\t} else {\n\t\t\t\t\t\/\/0 padding in odd sample count\n\t\t\t\t\tgf_bs_write_int(bs, 0, 4);\n\t\t\t\t}\n\t\t\t\ti += 2;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tgf_bs_write_int(bs, ptr->sizes[i], ptr->sampleSize);\n\t\t\t\ti += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":336807,"func":"lprn_is_black(gx_device_printer * pdev, int r, int h, int bx)\n{\n    gx_device_lprn *const lprn = (gx_device_lprn *) pdev;\n\n    int bh = lprn->nBh;\n    int bpl = gdev_mem_bytes_per_scan_line(pdev);\n    int x, y, y0;\n    byte *p;\n    int maxY = lprn->BlockLine \/ lprn->nBh * lprn->nBh;\n\n    y0 = (r + h - bh) % maxY;\n    for (y = 0; y < bh; y++) {\n        p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw];\n        for (x = 0; x < lprn->nBw; x++) {\n            \/* bpl isn't necessarily a multiple of lprn->nBw, so\n            we need to explicitly stop after the last byte in this\n            line to avoid accessing either the next line's data or\n            going off the end of our buffer completely. This avoids\n            https:\/\/bugs.ghostscript.com\/show_bug.cgi?id=701785. *\/\n            if (bx * lprn->nBw + x >= bpl)  break;\n            if (p[x] != 0)\n                return 1;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":513071,"func":"bool Arg_comparator::set_cmp_func_int()\n{\n  THD *thd= current_thd;\n  func= is_owner_equal_func() ? &Arg_comparator::compare_e_int :\n                                &Arg_comparator::compare_int_signed;\n  if ((*a)->field_type() == MYSQL_TYPE_YEAR &&\n      (*b)->field_type() == MYSQL_TYPE_YEAR)\n  {\n    func= is_owner_equal_func() ? &Arg_comparator::compare_e_datetime :\n                                  &Arg_comparator::compare_datetime;\n  }\n  else if (func == &Arg_comparator::compare_int_signed)\n  {\n    if ((*a)->unsigned_flag)\n      func= (((*b)->unsigned_flag)?\n             &Arg_comparator::compare_int_unsigned :\n             &Arg_comparator::compare_int_unsigned_signed);\n    else if ((*b)->unsigned_flag)\n      func= &Arg_comparator::compare_int_signed_unsigned;\n  }\n  else if (func== &Arg_comparator::compare_e_int)\n  {\n    if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)\n      func= &Arg_comparator::compare_e_int_diff_signedness;\n  }\n  a= cache_converted_constant(thd, a, &a_cache, compare_type_handler());\n  b= cache_converted_constant(thd, b, &b_cache, compare_type_handler());\n  return false;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":522336,"func":"char *GmfReadByteFlow(int64_t MshIdx, int *NmbByt)\n{\n   int         cod, *WrdTab;\n   size_t      i, NmbWrd;\n   GmfMshSct   *msh = (GmfMshSct *)MshIdx;\n\n   \/\/ Read and allocate the number of 4-byte words in the byteflow\n   if(!(NmbWrd = GmfStatKwd(MshIdx, GmfByteFlow)))\n      return(NULL);\n\n   if(!(WrdTab = malloc(NmbWrd * WrdSiz)))\n      return(NULL);\n\n   \/\/ Disable the endianess conversion\n   cod = msh->cod;\n   msh->cod = 1;\n\n   \/\/ Read the exact number of bytes in the byteflow\n   GmfGotoKwd(MshIdx, GmfByteFlow);\n   GmfGetLin(MshIdx, GmfByteFlow, NmbByt);\n\n   \/\/ Read the byteflow as 4-byte blocks\n   for(i=0;i<NmbWrd;i++)\n      GmfGetLin(MshIdx, GmfByteFlow, &WrdTab[i]);\n\n   \/\/ Enable endianess convertion\n   msh->cod = cod;\n\n   return((char *)WrdTab);\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":245146,"func":"Status ModelWeights::Initialize(OpKernelContext* const context) {\n  OpInputList sparse_indices_inputs;\n  TF_RETURN_IF_ERROR(\n      context->input_list(\"sparse_indices\", &sparse_indices_inputs));\n  OpInputList sparse_weights_inputs;\n  TF_RETURN_IF_ERROR(\n      context->input_list(\"sparse_weights\", &sparse_weights_inputs));\n  if (sparse_indices_inputs.size() != sparse_weights_inputs.size())\n    return errors::InvalidArgument(\n        \"sparse_indices and sparse_weights must have the same length, got \",\n        sparse_indices_inputs.size(), \" and \", sparse_weights_inputs.size());\n  OpInputList dense_weights_inputs;\n  TF_RETURN_IF_ERROR(\n      context->input_list(\"dense_weights\", &dense_weights_inputs));\n\n  OpOutputList sparse_weights_outputs;\n  TF_RETURN_IF_ERROR(context->output_list(\"out_delta_sparse_weights\",\n                                          &sparse_weights_outputs));\n  if (sparse_weights_outputs.size() != sparse_weights_inputs.size())\n    return errors::InvalidArgument(\n        \"out_delta_sparse_weights and sparse_weights must have the same \"\n        \"length, got \",\n        sparse_weights_outputs.size(), \" and \", sparse_weights_inputs.size());\n\n  OpOutputList dense_weights_outputs;\n  TF_RETURN_IF_ERROR(\n      context->output_list(\"out_delta_dense_weights\", &dense_weights_outputs));\n  if (dense_weights_outputs.size() != dense_weights_inputs.size())\n    return errors::InvalidArgument(\n        \"out_delta_dense_weights and dense_weights must have the same length, \"\n        \"got \",\n        dense_weights_outputs.size(), \" and \", dense_weights_inputs.size());\n\n  for (int i = 0; i < sparse_weights_inputs.size(); ++i) {\n    Tensor* delta_t;\n    TF_RETURN_IF_ERROR(sparse_weights_outputs.allocate(\n        i, sparse_weights_inputs[i].shape(), &delta_t));\n    \/\/ Convert the input vector to a row matrix in internal representation.\n    auto deltas = delta_t->shaped<float, 2>({1, delta_t->NumElements()});\n    deltas.setZero();\n    sparse_weights_.emplace_back(FeatureWeightsSparseStorage{\n        sparse_indices_inputs[i].flat<int64>(),\n        sparse_weights_inputs[i].shaped<float, 2>(\n            {1, sparse_weights_inputs[i].NumElements()}),\n        deltas});\n  }\n\n  \/\/ Reads in the weights, and allocates and initializes the delta weights.\n  const auto initialize_weights =\n      [&](const OpInputList& weight_inputs, OpOutputList* const weight_outputs,\n          std::vector<FeatureWeightsDenseStorage>* const feature_weights) {\n        for (int i = 0; i < weight_inputs.size(); ++i) {\n          Tensor* delta_t;\n          TF_RETURN_IF_ERROR(\n              weight_outputs->allocate(i, weight_inputs[i].shape(), &delta_t));\n          \/\/ Convert the input vector to a row matrix in internal\n          \/\/ representation.\n          auto deltas = delta_t->shaped<float, 2>({1, delta_t->NumElements()});\n          deltas.setZero();\n          feature_weights->emplace_back(FeatureWeightsDenseStorage{\n              weight_inputs[i].shaped<float, 2>(\n                  {1, weight_inputs[i].NumElements()}),\n              deltas});\n        }\n        return Status::OK();\n      };\n\n  return initialize_weights(dense_weights_inputs, &dense_weights_outputs,\n                            &dense_weights_);\n}","target":0,"code_token_length":680,"total_token_length":916,"max_tokens_setting":1024}
+{"idx":387803,"func":"void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {\n  Klass::collect_statistics(sz);\n\n  sz->_inst_size  = wordSize * size_helper();\n  sz->_vtab_bytes = wordSize * vtable_length();\n  sz->_itab_bytes = wordSize * itable_length();\n  sz->_nonstatic_oopmap_bytes = wordSize * nonstatic_oop_map_size();\n\n  int n = 0;\n  n += (sz->_methods_array_bytes         = sz->count_array(methods()));\n  n += (sz->_method_ordering_bytes       = sz->count_array(method_ordering()));\n  n += (sz->_local_interfaces_bytes      = sz->count_array(local_interfaces()));\n  n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));\n  n += (sz->_fields_bytes                = sz->count_array(fields()));\n  n += (sz->_inner_classes_bytes         = sz->count_array(inner_classes()));\n  n += (sz->_nest_members_bytes          = sz->count_array(nest_members()));\n  sz->_ro_bytes += n;\n\n  const ConstantPool* cp = constants();\n  if (cp) {\n    cp->collect_statistics(sz);\n  }\n\n  const Annotations* anno = annotations();\n  if (anno) {\n    anno->collect_statistics(sz);\n  }\n\n  const Array<Method*>* methods_array = methods();\n  if (methods()) {\n    for (int i = 0; i < methods_array->length(); i++) {\n      Method* method = methods_array->at(i);\n      if (method) {\n        sz->_method_count ++;\n        method->collect_statistics(sz);\n      }\n    }\n  }\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":235655,"func":"static void copy_rr(pj_pool_t *pool, pj_dns_parsed_rr *dst,\n\t\t    const pj_dns_parsed_rr *src,\n\t\t    unsigned *nametable_count,\n\t\t    pj_str_t nametable[])\n{\n    pj_memcpy(dst, src, sizeof(*src));\n    apply_name_table(nametable_count, nametable, &src->name, pool, &dst->name);\n\n    if (src->data) {\n\tdst->data = pj_pool_alloc(pool, src->rdlength);\n\tpj_memcpy(dst->data, src->data, src->rdlength);\n    }\n\n    if (src->type == PJ_DNS_TYPE_SRV) {\n\tapply_name_table(nametable_count, nametable, &src->rdata.srv.target, \n\t\t\t pool, &dst->rdata.srv.target);\n    } else if (src->type == PJ_DNS_TYPE_A) {\n\tdst->rdata.a.ip_addr.s_addr =  src->rdata.a.ip_addr.s_addr;\n    } else if (src->type == PJ_DNS_TYPE_AAAA) {\n\tpj_memcpy(&dst->rdata.aaaa.ip_addr, &src->rdata.aaaa.ip_addr,\n\t\t  sizeof(pj_in6_addr));\n    } else if (src->type == PJ_DNS_TYPE_CNAME) {\n\tpj_strdup(pool, &dst->rdata.cname.name, &src->rdata.cname.name);\n    } else if (src->type == PJ_DNS_TYPE_NS) {\n\tpj_strdup(pool, &dst->rdata.ns.name, &src->rdata.ns.name);\n    } else if (src->type == PJ_DNS_TYPE_PTR) {\n\tpj_strdup(pool, &dst->rdata.ptr.name, &src->rdata.ptr.name);\n    }\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":338235,"func":"void WasmBinaryBuilder::visitBlock(Block* curr) {\n  BYN_TRACE(\"zz node: Block\\n\");\n  startControlFlow(curr);\n  \/\/ special-case Block and de-recurse nested blocks in their first position, as\n  \/\/ that is a common pattern that can be very highly nested.\n  std::vector<Block*> stack;\n  while (1) {\n    curr->type = getType();\n    curr->name = getNextLabel();\n    breakStack.push_back({curr->name, curr->type});\n    stack.push_back(curr);\n    if (more() && input[pos] == BinaryConsts::Block) {\n      \/\/ a recursion\n      readNextDebugLocation();\n      curr = allocator.alloc<Block>();\n      startControlFlow(curr);\n      pos++;\n      if (debugLocation.size()) {\n        requireFunctionContext(\"block-debugLocation\");\n        currFunction->debugLocations[curr] = *debugLocation.begin();\n      }\n      continue;\n    } else {\n      \/\/ end of recursion\n      break;\n    }\n  }\n  Block* last = nullptr;\n  while (stack.size() > 0) {\n    curr = stack.back();\n    stack.pop_back();\n    \/\/ everything after this, that is left when we see the marker, is ours\n    size_t start = expressionStack.size();\n    if (last) {\n      \/\/ the previous block is our first-position element\n      pushExpression(last);\n    }\n    last = curr;\n    processExpressions();\n    size_t end = expressionStack.size();\n    if (end < start) {\n      throwError(\"block cannot pop from outside\");\n    }\n    pushBlockElements(curr, curr->type, start);\n    curr->finalize(curr->type,\n                   breakTargetNames.find(curr->name) != breakTargetNames.end()\n                     ? Block::HasBreak\n                     : Block::NoBreak);\n    breakStack.pop_back();\n    breakTargetNames.erase(curr->name);\n  }\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":442817,"func":"static void free_config_fields(struct Configurable *config)\n{\n  if(config->random_file)\n    free(config->random_file);\n  if(config->egd_file)\n    free(config->egd_file);\n  if(config->trace_dump)\n    free(config->trace_dump);\n  if(config->cipher_list)\n    free(config->cipher_list);\n  if(config->userpwd)\n    free(config->userpwd);\n  if(config->postfields)\n    free(config->postfields);\n  if(config->proxy)\n    free(config->proxy);\n  if(config->proxyuserpwd)\n    free(config->proxyuserpwd);\n  if(config->cookie)\n    free(config->cookie);\n  if(config->cookiefile)\n    free(config->cookiefile);\n  if(config->krb4level)\n    free(config->krb4level);\n  if(config->headerfile)\n    free(config->headerfile);\n  if(config->ftpport)\n    free(config->ftpport);\n  if(config->range)\n    free(config->range);\n  if(config->customrequest)\n    free(config->customrequest);\n  if(config->writeout)\n    free(config->writeout);\n  if(config->httppost)\n    curl_formfree(config->httppost);\n  if (config->cert)\n    free(config->cert);\n  if(config->cacert)\n    free(config->cacert);\n  if (config->cert_type)\n    free(config->cert_type);\n  if(config->capath)\n    free(config->capath);\n  if(config->cookiejar)\n    free(config->cookiejar);\n  if(config->ftp_account)\n    free(config->ftp_account);\n  if(config->ftp_alternative_to_user)\n    free(config->ftp_alternative_to_user);\n  if(config->iface)\n    free(config->iface);\n  if(config->socksproxy)\n    free(config->socksproxy);\n  if(config->libcurl)\n    free(config->libcurl);\n  if (config->key_passwd)\n    free(config->key_passwd);\n  if (config->key)\n    free(config->key);\n  if (config->key_type)\n    free(config->key_type);\n  if (config->pubkey)\n    free(config->pubkey);\n  if (config->referer)\n    free(config->referer);\n\n  curl_slist_free_all(config->quote); \/* checks for config->quote == NULL *\/\n  curl_slist_free_all(config->prequote);\n  curl_slist_free_all(config->postquote);\n  curl_slist_free_all(config->headers);\n  curl_slist_free_all(config->telnet_options);\n}","target":0,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":217176,"func":"static void do_viewlog(HttpRequest req, HttpResponse res) {\n        if (is_readonly(req)) {\n                send_error(req, res, SC_FORBIDDEN, \"You do not have sufficient privileges to access this page\");\n                return;\n        }\n        do_head(res, \"_viewlog\", \"View log\", 100);\n        if ((Run.flags & Run_Log) && ! (Run.flags & Run_UseSyslog)) {\n                FILE *f = fopen(Run.files.log, \"r\");\n                if (f) {\n                        size_t n;\n                        char buf[512];\n                        StringBuffer_append(res->outputbuffer, \"<br><p><form><textarea cols=120 rows=30 readonly>\");\n                        while ((n = fread(buf, sizeof(char), sizeof(buf) - 1, f)) > 0) {\n                                buf[n] = 0;\n                                StringBuffer_append(res->outputbuffer, \"%s\", buf);\n                        }\n                        fclose(f);\n                        StringBuffer_append(res->outputbuffer, \"<\/textarea><\/form>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer, \"Error opening logfile: %s\", STRERROR);\n                }\n        } else {\n                StringBuffer_append(res->outputbuffer,\n                                    \"<b>Cannot view logfile:<\/b><br>\");\n                if (! (Run.flags & Run_Log))\n                        StringBuffer_append(res->outputbuffer, \"Monit was started without logging\");\n                else\n                        StringBuffer_append(res->outputbuffer, \"Monit uses syslog\");\n        }\n        do_foot(res);\n}","target":1,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":208115,"func":"static int xemaclite_of_probe(struct platform_device *ofdev)\n{\n\tstruct resource *res;\n\tstruct net_device *ndev = NULL;\n\tstruct net_local *lp = NULL;\n\tstruct device *dev = &ofdev->dev;\n\n\tint rc = 0;\n\n\tdev_info(dev, \"Device Tree Probing\\n\");\n\n\t\/* Create an ethernet device instance *\/\n\tndev = alloc_etherdev(sizeof(struct net_local));\n\tif (!ndev)\n\t\treturn -ENOMEM;\n\n\tdev_set_drvdata(dev, ndev);\n\tSET_NETDEV_DEV(ndev, &ofdev->dev);\n\n\tlp = netdev_priv(ndev);\n\tlp->ndev = ndev;\n\n\t\/* Get IRQ for the device *\/\n\tres = platform_get_resource(ofdev, IORESOURCE_IRQ, 0);\n\tif (!res) {\n\t\tdev_err(dev, \"no IRQ found\\n\");\n\t\trc = -ENXIO;\n\t\tgoto error;\n\t}\n\n\tndev->irq = res->start;\n\n\tres = platform_get_resource(ofdev, IORESOURCE_MEM, 0);\n\tlp->base_addr = devm_ioremap_resource(&ofdev->dev, res);\n\tif (IS_ERR(lp->base_addr)) {\n\t\trc = PTR_ERR(lp->base_addr);\n\t\tgoto error;\n\t}\n\n\tndev->mem_start = res->start;\n\tndev->mem_end = res->end;\n\n\tspin_lock_init(&lp->reset_lock);\n\tlp->next_tx_buf_to_use = 0x0;\n\tlp->next_rx_buf_to_use = 0x0;\n\tlp->tx_ping_pong = get_bool(ofdev, \"xlnx,tx-ping-pong\");\n\tlp->rx_ping_pong = get_bool(ofdev, \"xlnx,rx-ping-pong\");\n\n\trc = of_get_mac_address(ofdev->dev.of_node, ndev->dev_addr);\n\tif (rc) {\n\t\tdev_warn(dev, \"No MAC address found, using random\\n\");\n\t\teth_hw_addr_random(ndev);\n\t}\n\n\t\/* Clear the Tx CSR's in case this is a restart *\/\n\txemaclite_writel(0, lp->base_addr + XEL_TSR_OFFSET);\n\txemaclite_writel(0, lp->base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);\n\n\t\/* Set the MAC address in the EmacLite device *\/\n\txemaclite_update_address(lp, ndev->dev_addr);\n\n\tlp->phy_node = of_parse_phandle(ofdev->dev.of_node, \"phy-handle\", 0);\n\txemaclite_mdio_setup(lp, &ofdev->dev);\n\n\tdev_info(dev, \"MAC address is now %pM\\n\", ndev->dev_addr);\n\n\tndev->netdev_ops = &xemaclite_netdev_ops;\n\tndev->ethtool_ops = &xemaclite_ethtool_ops;\n\tndev->flags &= ~IFF_MULTICAST;\n\tndev->watchdog_timeo = TX_TIMEOUT;\n\n\t\/* Finally, register the device *\/\n\trc = register_netdev(ndev);\n\tif (rc) {\n\t\tdev_err(dev,\n\t\t\t\"Cannot register network device, aborting\\n\");\n\t\tgoto error;\n\t}\n\n\tdev_info(dev,\n\t\t \"Xilinx EmacLite at 0x%08lX mapped to 0x%08lX, irq=%d\\n\",\n\t\t (unsigned long __force)ndev->mem_start,\n\t\t (unsigned long __force)lp->base_addr, ndev->irq);\n\treturn 0;\n\nerror:\n\tfree_netdev(ndev);\n\treturn rc;\n}","target":1,"code_token_length":741,"total_token_length":977,"max_tokens_setting":1024}
+{"idx":212144,"func":"MOBI_RET mobi_parse_huffdic(const MOBIData *m, MOBIHuffCdic *huffcdic) {\n    MOBI_RET ret;\n    const size_t offset = mobi_get_kf8offset(m);\n    if (m->mh == NULL || m->mh->huff_rec_index == NULL || m->mh->huff_rec_count == NULL) {\n        debug_print(\"%s\", \"HUFF\/CDIC records metadata not found in MOBI header\\n\");\n        return MOBI_DATA_CORRUPT;\n    }\n    const size_t huff_rec_index = *m->mh->huff_rec_index + offset;\n    const size_t huff_rec_count = *m->mh->huff_rec_count;\n    if (huff_rec_count > HUFF_RECORD_MAXCNT) {\n        debug_print(\"Too many HUFF record (%zu)\\n\", huff_rec_count);\n        return MOBI_DATA_CORRUPT;\n    }\n    const MOBIPdbRecord *curr = mobi_get_record_by_seqnumber(m, huff_rec_index);\n    if (curr == NULL || huff_rec_count < 2) {\n        debug_print(\"%s\", \"HUFF\/CDIC record not found\\n\");\n        return MOBI_DATA_CORRUPT;\n    }\n    if (curr->size < HUFF_RECORD_MINSIZE) {\n        debug_print(\"HUFF record too short (%zu b)\\n\", curr->size);\n        return MOBI_DATA_CORRUPT;\n    }\n    ret = mobi_parse_huff(huffcdic, curr);\n    if (ret != MOBI_SUCCESS) {\n        debug_print(\"%s\", \"HUFF parsing failed\\n\");\n        return ret;\n    }\n    curr = curr->next;\n    \/* allocate memory for symbols data in each CDIC record *\/\n    huffcdic->symbols = malloc((huff_rec_count - 1) * sizeof(*huffcdic->symbols));\n    if (huffcdic->symbols == NULL) {\n        debug_print(\"%s\\n\", \"Memory allocation failed\");\n        return MOBI_MALLOC_FAILED;\n    }\n    \/* get following CDIC records *\/\n    size_t i = 0;\n    while (i < huff_rec_count - 1) {\n        if (curr == NULL) {\n            debug_print(\"%s\\n\", \"CDIC record not found\");\n            return MOBI_DATA_CORRUPT;\n        }\n        ret = mobi_parse_cdic(huffcdic, curr, i++);\n        if (ret != MOBI_SUCCESS) {\n            debug_print(\"%s\", \"CDIC parsing failed\\n\");\n            return ret;\n        }\n        curr = curr->next;\n    }\n    return MOBI_SUCCESS;\n}","target":1,"code_token_length":564,"total_token_length":800,"max_tokens_setting":1024}
+{"idx":310301,"func":"dirserv_get_routerdesc_fingerprints(smartlist_t *fps_out, const char *key,\n                                    const char **msg, int for_unencrypted_conn,\n                                    int is_extrainfo)\n{\n  int by_id = 1;\n  *msg = NULL;\n\n  if (!strcmp(key, \"all\")) {\n    routerlist_t *rl = router_get_routerlist();\n    SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,\n                      smartlist_add(fps_out,\n                      tor_memdup(r->cache_info.identity_digest, DIGEST_LEN)));\n    \/* Treat \"all\" requests as if they were unencrypted *\/\n    for_unencrypted_conn = 1;\n  } else if (!strcmp(key, \"authority\")) {\n    routerinfo_t *ri = router_get_my_routerinfo();\n    if (ri)\n      smartlist_add(fps_out,\n                    tor_memdup(ri->cache_info.identity_digest, DIGEST_LEN));\n  } else if (!strcmpstart(key, \"d\/\")) {\n    by_id = 0;\n    key += strlen(\"d\/\");\n    dir_split_resource_into_fingerprints(key, fps_out, NULL,\n                                         DSR_HEX|DSR_SORT_UNIQ);\n  } else if (!strcmpstart(key, \"fp\/\")) {\n    key += strlen(\"fp\/\");\n    dir_split_resource_into_fingerprints(key, fps_out, NULL,\n                                         DSR_HEX|DSR_SORT_UNIQ);\n  } else {\n    *msg = \"Key not recognized\";\n    return -1;\n  }\n\n  if (for_unencrypted_conn) {\n    \/* Remove anything that insists it not be sent unencrypted. *\/\n    SMARTLIST_FOREACH(fps_out, char *, cp, {\n        signed_descriptor_t *sd;\n        if (by_id)\n          sd = get_signed_descriptor_by_fp(cp,is_extrainfo,0);\n        else if (is_extrainfo)\n          sd = extrainfo_get_by_descriptor_digest(cp);\n        else\n          sd = router_get_by_descriptor_digest(cp);\n        if (sd && !sd->send_unencrypted) {\n          tor_free(cp);\n          SMARTLIST_DEL_CURRENT(fps_out, cp);\n        }\n      });\n  }\n\n  if (!smartlist_len(fps_out)) {\n    *msg = \"Servers unavailable\";\n    return -1;\n  }\n  return 0;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":242648,"func":"GF_Err isoffin_configure_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_remove)\n{\n\tconst GF_PropertyValue *prop;\n\tISOMReader *read = gf_filter_get_udta(filter);\n\n\tif (is_remove) {\n\t\tisoffin_disconnect(read);\n\t\treturn GF_OK;\n\t}\n\t\/\/check if we  have a file path; if not, this is a pure stream of boxes (no local file cache)\n\tprop = gf_filter_pid_get_property(pid, GF_PROP_PID_FILEPATH);\n\tif (!prop || !prop->value.string) {\n\t\tif (!read->mem_load_mode)\n\t\t\tread->mem_load_mode = 1;\n\t\tif (!read->pid) read->pid = pid;\n\t\tread->input_loaded = GF_FALSE;\n\t\treturn GF_OK;\n\t}\n\n\tif (read->pid && prop->value.string) {\n\t\tconst char *next_url = prop->value.string;\n\t\tu64 sr, er;\n\t\tu32 crc = gf_crc_32(next_url, (u32) strlen(next_url) );\n\n\t\tsr = er = 0;\n\t\tprop = gf_filter_pid_get_property(read->pid, GF_PROP_PID_FILE_RANGE);\n\t\tif (prop) {\n\t\t\tsr = prop->value.lfrac.num;\n\t\t\ter = prop->value.lfrac.den;\n\t\t}\n\n\t\t\/\/if eos is signaled, don't check for crc since we might have the same blob address (same alloc)\n\t\tif (!read->eos_signaled && (read->src_crc == crc) && (read->start_range==sr) && (read->end_range==er)) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, (\"[IsoMedia] same URL crc and range for %s, skipping reconfigure\\n\", next_url));\n\t\t\treturn GF_OK;\n\t\t}\n\t\tread->src_crc = crc;\n\t\tread->start_range = sr;\n\t\tread->end_range = er;\n\t\tread->input_loaded = GF_FALSE;\n\t\tread->eos_signaled = GF_FALSE;\n\t\t\n\t\t\/\/we need to reconfigure\n\t\treturn isoffin_reconfigure(filter, read, next_url);\n\t}\n\n\tread->pid = pid;\n\tprop = gf_filter_pid_get_property(pid, GF_PROP_PID_FILE_CACHED);\n\tif (prop && prop->value.boolean) {\n\t\tGF_FilterEvent evt;\n\t\tread->input_loaded = GF_TRUE;\n\t\tGF_FEVT_INIT(evt, GF_FEVT_PLAY_HINT, pid);\n\t\tevt.play.full_file_only=1;\n\t\tgf_filter_pid_send_event(pid, &evt);\n\t}\n\treturn isoffin_setup(filter, read);\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":197142,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& input = ctx->input(0);\n    const Tensor& input_min_range = ctx->input(1);\n    const Tensor& input_max_range = ctx->input(2);\n\n    int num_slices = 1;\n    if (axis_ > -1) {\n      num_slices = input.dim_size(axis_);\n    }\n\n    const TensorShape& minmax_shape = ctx->input(1).shape();\n    Tensor* output = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(0, input.shape(), &output));\n\n    Tensor* output_min_tensor = nullptr;\n    Tensor* output_max_tensor = nullptr;\n\n    if (num_slices == 1) {\n      OP_REQUIRES_OK(ctx, ctx->allocate_output(1, {}, &output_min_tensor));\n      OP_REQUIRES_OK(ctx, ctx->allocate_output(2, {}, &output_max_tensor));\n      const float min_range = input_min_range.template flat<float>()(0);\n      const float max_range = input_max_range.template flat<float>()(0);\n      QuantizeTensor(ctx, input, min_range, max_range, output,\n                     output_min_tensor, output_max_tensor);\n      return;\n    }\n\n    OP_REQUIRES(ctx, mode_ != QUANTIZE_MODE_MIN_FIRST,\n                errors::Unimplemented(\"MIN_FIRST mode is not implemented for \"\n                                      \"Quantize with axis != -1.\"));\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(1, minmax_shape, &output_min_tensor));\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(2, minmax_shape, &output_max_tensor));\n\n    auto input_tensor =\n        input.template flat_inner_outer_dims<float, 3>(axis_ - 1);\n    int64_t pre_dim = 1, post_dim = 1;\n    for (int i = 0; i < axis_; ++i) {\n      pre_dim *= output->dim_size(i);\n    }\n    for (int i = axis_ + 1; i < output->dims(); ++i) {\n      post_dim *= output->dim_size(i);\n    }\n    auto output_tensor = output->template bit_casted_shaped<T, 3>(\n        {pre_dim, num_slices, post_dim});\n    auto min_ranges = input_min_range.template vec<float>();\n    auto max_ranges = input_max_range.template vec<float>();\n    for (int i = 0; i < num_slices; ++i) {\n      QuantizeSlice(ctx->eigen_device<Device>(), ctx,\n                    input_tensor.template chip<1>(i), min_ranges(i),\n                    max_ranges(i), output_tensor.template chip<1>(i),\n                    &output_min_tensor->flat<float>()(i),\n                    &output_max_tensor->flat<float>()(i));\n    }\n  }","target":1,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":262084,"func":"static void AddRangeStats(const int start_instance, const int end_instance,\n                          const int start_feature_dim,\n                          const int end_feature_dim,\n                          StatsPartitionMap* stats_map,\n                          const TTypes<float>::ConstMatrix& gradients,\n                          const TTypes<float>::ConstMatrix& hessians,\n                          const TTypes<int32>::ConstVec& node_ids,\n                          const int32_t feature_dims, const int32_t bucket_id,\n                          const int32_t logits_dims, const int32_t stats_dims) {\n  DCHECK_LE(start_instance, end_instance);\n  if (start_instance == end_instance) {\n    DCHECK_LT(start_feature_dim, end_feature_dim);\n  }\n  for (int32_t instance = start_instance; instance <= end_instance;\n       ++instance) {\n    const int32_t start_f_dim =\n        (instance == start_instance) ? start_feature_dim + 1 : 0;\n    const int32_t end_f_dim =\n        (instance == end_instance) ? end_feature_dim : feature_dims;\n    for (int32_t f_dim = start_f_dim; f_dim < end_f_dim; ++f_dim) {\n      AddInstanceStatsToMap(instance, f_dim, bucket_id, logits_dims, stats_dims,\n                            stats_map, gradients, hessians, node_ids);\n    }\n  }\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":312560,"func":"efmpat_to_regpat(\n\tchar_u\t*efmpat,\n\tchar_u\t*regpat,\n\tefm_T\t*efminfo,\n\tint\tidx,\n\tint\tround)\n{\n    char_u\t*srcptr;\n\n    if (efminfo->addr[idx])\n    {\n\t\/\/ Each errorformat pattern can occur only once\n\tsemsg(_(e_too_many_chr_in_format_string), *efmpat);\n\treturn NULL;\n    }\n    if ((idx && idx < FMT_PATTERN_R\n\t\t&& vim_strchr((char_u *)\"DXOPQ\", efminfo->prefix) != NULL)\n\t    || (idx == FMT_PATTERN_R\n\t\t&& vim_strchr((char_u *)\"OPQ\", efminfo->prefix) == NULL))\n    {\n\tsemsg(_(e_unexpected_chr_in_format_str), *efmpat);\n\treturn NULL;\n    }\n    efminfo->addr[idx] = (char_u)++round;\n    *regpat++ = '\\\\';\n    *regpat++ = '(';\n#ifdef BACKSLASH_IN_FILENAME\n    if (*efmpat == 'f')\n    {\n\t\/\/ Also match \"c:\" in the file name, even when\n\t\/\/ checking for a colon next: \"%f:\".\n\t\/\/ \"\\%(\\a:\\)\\=\"\n\tSTRCPY(regpat, \"\\\\%(\\\\a:\\\\)\\\\=\");\n\tregpat += 10;\n    }\n#endif\n    if (*efmpat == 'f' && efmpat[1] != NUL)\n    {\n\tif (efmpat[1] != '\\\\' && efmpat[1] != '%')\n\t{\n\t    \/\/ A file name may contain spaces, but this isn't\n\t    \/\/ in \"\\f\".  For \"%f:%l:%m\" there may be a \":\" in\n\t    \/\/ the file name.  Use \".\\{-1,}x\" instead (x is\n\t    \/\/ the next character), the requirement that :999:\n\t    \/\/ follows should work.\n\t    STRCPY(regpat, \".\\\\{-1,}\");\n\t    regpat += 7;\n\t}\n\telse\n\t{\n\t    \/\/ File name followed by '\\\\' or '%': include as\n\t    \/\/ many file name chars as possible.\n\t    STRCPY(regpat, \"\\\\f\\\\+\");\n\t    regpat += 4;\n\t}\n    }\n    else\n    {\n\tsrcptr = (char_u *)fmt_pat[idx].pattern;\n\twhile ((*regpat = *srcptr++) != NUL)\n\t    ++regpat;\n    }\n    *regpat++ = '\\\\';\n    *regpat++ = ')';\n\n    return regpat;\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":264668,"func":"static GF_Err BM_ParseMultipleIndexedReplace(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)\n{\n\tu32 ID, ind, field_ind, NumBits, lenpos, lennum, count;\n\tGF_Node *node;\n\tGF_Err e;\n\tGF_Command *com;\n\tGF_CommandField *inf;\n\tGF_FieldInfo field;\n\n\tID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits);\n\tnode = gf_sg_find_node(codec->current_graph, ID);\n\tif (!node) return GF_NON_COMPLIANT_BITSTREAM;\n\tNumBits = gf_get_bit_size(gf_node_get_num_fields_in_mode(node, GF_SG_FIELD_CODING_IN)-1);\n\tind = gf_bs_read_int(bs, NumBits);\n\te = gf_bifs_get_field_index(node, ind, GF_SG_FIELD_CODING_IN, &field_ind);\n\tif (e) return e;\n\te = gf_node_get_field(node, field_ind, &field);\n\tif (gf_sg_vrml_is_sf_field(field.fieldType)) return GF_NON_COMPLIANT_BITSTREAM;\n\n\tlenpos = gf_bs_read_int(bs, 5);\n\tlennum = gf_bs_read_int(bs, 5);\n\tcount = gf_bs_read_int(bs, lennum);\n\n\tcom = gf_sg_command_new(codec->current_graph, GF_SG_MULTIPLE_INDEXED_REPLACE);\n\tBM_SetCommandNode(com, node);\n\tfield.fieldType = gf_sg_vrml_get_sf_type(field.fieldType);\n\n\twhile (count) {\n\t\tinf = gf_sg_command_field_new(com);\n\t\tinf->pos = gf_bs_read_int(bs, lenpos);\n\t\tinf->fieldIndex = field.fieldIndex;\n\t\tinf->fieldType = field.fieldType;\n\n\t\tif (field.fieldType==GF_SG_VRML_SFNODE) {\n\t\t\tinf->new_node = gf_bifs_dec_node(codec, bs, field.NDTtype);\n\t\t\tif (codec->LastError) goto err;\n\t\t\tinf->field_ptr = &inf->new_node;\n\t\t\tgf_node_register(inf->new_node, NULL);\n\t\t} else {\n\t\t\tfield.far_ptr = inf->field_ptr = gf_sg_vrml_field_pointer_new(inf->fieldType);\n\t\t\te = gf_bifs_dec_sf_field(codec, bs, node, &field, GF_TRUE);\n\t\t\tif (e) goto err;\n\t\t}\n\t\tcount--;\n\t}\nerr:\n\tif (e) gf_sg_command_del(com);\n\telse gf_list_add(com_list, com);\n\treturn e;\n}","target":0,"code_token_length":536,"total_token_length":772,"max_tokens_setting":1024}
+{"idx":244238,"func":"GF_Err sidx_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_SegmentIndexBox *ptr = (GF_SegmentIndexBox*) s;\n\n\tISOM_DECREASE_SIZE(ptr, 8);\n\tptr->reference_ID = gf_bs_read_u32(bs);\n\tptr->timescale = gf_bs_read_u32(bs);\n\n\tif (ptr->version==0) {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->earliest_presentation_time = gf_bs_read_u32(bs);\n\t\tptr->first_offset = gf_bs_read_u32(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 16);\n\t\tptr->earliest_presentation_time = gf_bs_read_u64(bs);\n\t\tptr->first_offset = gf_bs_read_u64(bs);\n\t}\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tgf_bs_read_u16(bs); \/* reserved *\/\n\tptr->nb_refs = gf_bs_read_u16(bs);\n\n\tptr->refs = gf_malloc(sizeof(GF_SIDXReference)*ptr->nb_refs);\n\tif (!ptr->refs) return GF_OUT_OF_MEM;\n\tfor (i=0; i<ptr->nb_refs; i++) {\n\t\tptr->refs[i].reference_type = gf_bs_read_int(bs, 1);\n\t\tptr->refs[i].reference_size = gf_bs_read_int(bs, 31);\n\t\tptr->refs[i].subsegment_duration = gf_bs_read_u32(bs);\n\t\tptr->refs[i].starts_with_SAP = gf_bs_read_int(bs, 1);\n\t\tptr->refs[i].SAP_type = gf_bs_read_int(bs, 3);\n\t\tptr->refs[i].SAP_delta_time = gf_bs_read_int(bs, 28);\n\n\t\tISOM_DECREASE_SIZE(ptr, 12);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":349891,"func":"int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,\n\t\t\t\t   u8 *mac)\n{\n\tu32 mac_addr[2];\n\tu32 efuse_addr;\n\tint err = 0;\n\tu32 h = 0U;\n\tu32 l = 0U;\n\n\tif (!aq_hw_read_reg(self, HW_ATL_UCP_0X370_REG)) {\n\t\tunsigned int ucp_0x370 = 0;\n\t\tunsigned int rnd = 0;\n\n\t\tget_random_bytes(&rnd, sizeof(unsigned int));\n\n\t\tucp_0x370 = 0x02020202 | (0xFEFEFEFE & rnd);\n\t\taq_hw_write_reg(self, HW_ATL_UCP_0X370_REG, ucp_0x370);\n\t}\n\n\tefuse_addr = aq_hw_read_reg(self, 0x00000374U);\n\n\terr = hw_atl_utils_fw_downld_dwords(self, efuse_addr + (40U * 4U),\n\t\t\t\t\t    mac_addr, ARRAY_SIZE(mac_addr));\n\tif (err < 0) {\n\t\tmac_addr[0] = 0U;\n\t\tmac_addr[1] = 0U;\n\t\terr = 0;\n\t} else {\n\t\tmac_addr[0] = __swab32(mac_addr[0]);\n\t\tmac_addr[1] = __swab32(mac_addr[1]);\n\t}\n\n\tether_addr_copy(mac, (u8 *)mac_addr);\n\n\tif ((mac[0] & 0x01U) || ((mac[0] | mac[1] | mac[2]) == 0x00U)) {\n\t\t\/* chip revision *\/\n\t\tl = 0xE3000000U |\n\t\t    (0xFFFFU & aq_hw_read_reg(self, HW_ATL_UCP_0X370_REG)) |\n\t\t    (0x00 << 16);\n\t\th = 0x8001300EU;\n\n\t\tmac[5] = (u8)(0xFFU & l);\n\t\tl >>= 8;\n\t\tmac[4] = (u8)(0xFFU & l);\n\t\tl >>= 8;\n\t\tmac[3] = (u8)(0xFFU & l);\n\t\tl >>= 8;\n\t\tmac[2] = (u8)(0xFFU & l);\n\t\tmac[1] = (u8)(0xFFU & h);\n\t\th >>= 8;\n\t\tmac[0] = (u8)(0xFFU & h);\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":356685,"func":"template <class T> T* Statement::Bind(const Napi::CallbackInfo& info, int start, int last) {\n    Napi::Env env = info.Env();\n    Napi::HandleScope scope(env);\n\n    if (last < 0) last = info.Length();\n    Napi::Function callback;\n    if (last > start && info[last - 1].IsFunction()) {\n        callback = info[last - 1].As<Napi::Function>();\n        last--;\n    }\n\n    T* baton = new T(this, callback);\n\n    if (start < last) {\n        if (info[start].IsArray()) {\n            Napi::Array array = info[start].As<Napi::Array>();\n            int length = array.Length();\n            \/\/ Note: bind parameters start with 1.\n            for (int i = 0, pos = 1; i < length; i++, pos++) {\n                baton->parameters.push_back(BindParameter((array).Get(i), pos));\n            }\n        }\n        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), \"RegExp\") || OtherInstanceOf(info[start].As<Object>(), \"Date\") || info[start].IsBuffer()) {\n            \/\/ Parameters directly in array.\n            \/\/ Note: bind parameters start with 1.\n            for (int i = start, pos = 1; i < last; i++, pos++) {\n                baton->parameters.push_back(BindParameter(info[i], pos));\n            }\n        }\n        else if (info[start].IsObject()) {\n            Napi::Object object = info[start].As<Napi::Object>();\n            Napi::Array array = object.GetPropertyNames();\n            int length = array.Length();\n            for (int i = 0; i < length; i++) {\n                Napi::Value name = (array).Get(i);\n                Napi::Number num = name.ToNumber();\n\n                if (num.Int32Value() == num.DoubleValue()) {\n                    baton->parameters.push_back(\n                        BindParameter((object).Get(name), num.Int32Value()));\n                }\n                else {\n                    baton->parameters.push_back(BindParameter((object).Get(name),\n                        name.As<Napi::String>().Utf8Value().c_str()));\n                }\n            }\n        }\n        else {\n            return NULL;\n        }\n    }\n\n    return baton;\n}","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":224193,"func":"gen_values(codegen_scope *s, node *t, int val, int limit)\n{\n  int n = 0;\n  int first = 1;\n  int slimit = GEN_VAL_STACK_MAX;\n\n  if (limit == 0) limit = GEN_LIT_ARY_MAX;\n  if (cursp() >= slimit) slimit = INT16_MAX;\n\n  if (!val) {\n    while (t) {\n      codegen(s, t->car, NOVAL);\n      n++;\n      t = t->cdr;\n    }\n    return n;\n  }\n\n  while (t) {\n    int is_splat = nint(t->car->car) == NODE_SPLAT;\n\n    if (is_splat || cursp() >= slimit) { \/* flush stack *\/\n      pop_n(n);\n      if (first) {\n        if (n == 0) {\n          genop_1(s, OP_LOADNIL, cursp());\n        }\n        else {\n          genop_2(s, OP_ARRAY, cursp(), n);\n        }\n        push();\n        first = 0;\n        limit = GEN_LIT_ARY_MAX;\n      }\n      else if (n > 0) {\n        pop();\n        genop_2(s, OP_ARYPUSH, cursp(), n);\n        push();\n      }\n      n = 0;\n    }\n    codegen(s, t->car, val);\n    if (is_splat) {\n      pop(); pop();\n      genop_1(s, OP_ARYCAT, cursp());\n      push();\n    }\n    else {\n      n++;\n    }\n    t = t->cdr;\n  }\n  if (!first) {\n    pop();\n    if (n > 0) {\n      pop_n(n);\n      genop_2(s, OP_ARYPUSH, cursp(), n);\n    }\n    return -1;                  \/* variable length *\/\n  }\n  else if (n > limit) {\n    pop_n(n);\n    genop_2(s, OP_ARRAY, cursp(), n);\n    return -1;\n  }\n  return n;\n}","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":359295,"func":"DEFUN (neighbor_set_peer_group,\n       neighbor_set_peer_group_cmd,\n       NEIGHBOR_CMD \"peer-group WORD\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR\n       \"Member of the peer-group\\n\"\n       \"peer-group name\\n\")\n{\n  int ret;\n  as_t as;\n  union sockunion su;\n  struct bgp *bgp;\n  struct peer_group *group;\n\n  bgp = vty->index;\n\n  ret = str2sockunion (argv[0], &su);\n  if (ret < 0)\n    {\n      vty_out (vty, \"%% Malformed address: %s%s\", argv[0], VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  group = peer_group_lookup (bgp, argv[1]);\n  if (! group)\n    {\n      vty_out (vty, \"%% Configure the peer-group first%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  if (peer_address_self_check (&su))\n    {\n      vty_out (vty, \"%% Can not configure the local system as neighbor%s\",\n\t       VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty), \n\t\t\t bgp_node_safi (vty), &as);\n\n  if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)\n    {\n      vty_out (vty, \"%% Peer with AS %d cannot be in this peer-group, members must be all internal or all external%s\", as, VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":390592,"func":"ProcXkbSetDebuggingFlags(ClientPtr client)\n{\nCARD32 \t\t\t\tnewFlags,newCtrls,extraLength;\nxkbSetDebuggingFlagsReply \trep;\nint rc;\n\n    REQUEST(xkbSetDebuggingFlagsReq);\n    REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq);\n\n    rc = XaceHook(XACE_SERVER_ACCESS, client, DixDebugAccess);\n    if (rc != Success)\n\treturn rc;\n\n    newFlags=  xkbDebugFlags&(~stuff->affectFlags);\n    newFlags|= (stuff->flags&stuff->affectFlags);\n    newCtrls=  xkbDebugCtrls&(~stuff->affectCtrls);\n    newCtrls|= (stuff->ctrls&stuff->affectCtrls);\n    if (xkbDebugFlags || newFlags || stuff->msgLength) {\n\tErrorF(\"[xkb] XkbDebug: Setting debug flags to 0x%lx\\n\",(long)newFlags);\n\tif (newCtrls!=xkbDebugCtrls)\n\t    ErrorF(\"[xkb] XkbDebug: Setting debug controls to 0x%lx\\n\",(long)newCtrls);\n    }\n    extraLength= (stuff->length<<2)-sz_xkbSetDebuggingFlagsReq;\n    if (stuff->msgLength>0) {\n\tchar *msg;\n\tif (extraLength<XkbPaddedSize(stuff->msgLength)) {\n\t    ErrorF(\"[xkb] XkbDebug: msgLength= %d, length= %ld (should be %d)\\n\",\n\t\t\tstuff->msgLength,(long)extraLength,\n\t\t\tXkbPaddedSize(stuff->msgLength));\n\t    return BadLength;\n\t}\n\tmsg= (char *)&stuff[1];\n\tif (msg[stuff->msgLength-1]!='\\0') {\n\t    ErrorF(\"[xkb] XkbDebug: message not null-terminated\\n\");\n\t    return BadValue;\n\t}\n\tErrorF(\"[xkb] XkbDebug: %s\\n\",msg);\n    }\n    xkbDebugFlags = newFlags;\n    xkbDebugCtrls = newCtrls;\n\n    XkbDisableLockActions= (xkbDebugCtrls&XkbDF_DisableLocks);\n\n    rep.type= X_Reply;\n    rep.length = 0;\n    rep.sequenceNumber = client->sequence;\n    rep.currentFlags = newFlags;\n    rep.currentCtrls = newCtrls;\n    rep.supportedFlags = ~0;\n    rep.supportedCtrls = ~0;\n    if ( client->swapped ) {\n\tregister int n;\n\tswaps(&rep.sequenceNumber, n);\n\tswapl(&rep.currentFlags, n);\n\tswapl(&rep.currentCtrls, n);\n\tswapl(&rep.supportedFlags, n);\n\tswapl(&rep.supportedCtrls, n);\n    }\n    WriteToClient(client,SIZEOF(xkbSetDebuggingFlagsReply), (char *)&rep);\n    return client->noClientException;\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":484791,"func":"static int xennet_create_page_pool(struct netfront_queue *queue)\n{\n\tint err;\n\tstruct page_pool_params pp_params = {\n\t\t.order = 0,\n\t\t.flags = 0,\n\t\t.pool_size = NET_RX_RING_SIZE,\n\t\t.nid = NUMA_NO_NODE,\n\t\t.dev = &queue->info->netdev->dev,\n\t\t.offset = XDP_PACKET_HEADROOM,\n\t\t.max_len = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM,\n\t};\n\n\tqueue->page_pool = page_pool_create(&pp_params);\n\tif (IS_ERR(queue->page_pool)) {\n\t\terr = PTR_ERR(queue->page_pool);\n\t\tqueue->page_pool = NULL;\n\t\treturn err;\n\t}\n\n\terr = xdp_rxq_info_reg(&queue->xdp_rxq, queue->info->netdev,\n\t\t\t       queue->id, 0);\n\tif (err) {\n\t\tnetdev_err(queue->info->netdev, \"xdp_rxq_info_reg failed\\n\");\n\t\tgoto err_free_pp;\n\t}\n\n\terr = xdp_rxq_info_reg_mem_model(&queue->xdp_rxq,\n\t\t\t\t\t MEM_TYPE_PAGE_POOL, queue->page_pool);\n\tif (err) {\n\t\tnetdev_err(queue->info->netdev, \"xdp_rxq_info_reg_mem_model failed\\n\");\n\t\tgoto err_unregister_rxq;\n\t}\n\treturn 0;\n\nerr_unregister_rxq:\n\txdp_rxq_info_unreg(&queue->xdp_rxq);\nerr_free_pp:\n\tpage_pool_destroy(queue->page_pool);\n\tqueue->page_pool = NULL;\n\treturn err;\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":372872,"func":"static void irda_connect_confirm(void *instance, void *sap,\n\t\t\t\t struct qos_info *qos,\n\t\t\t\t __u32 max_sdu_size, __u8 max_header_size,\n\t\t\t\t struct sk_buff *skb)\n{\n\tstruct irda_sock *self;\n\tstruct sock *sk;\n\n\tself = instance;\n\n\tIRDA_DEBUG(2, \"%s(%p)\\n\", __func__, self);\n\n\tsk = instance;\n\tif (sk == NULL) {\n\t\tdev_kfree_skb(skb);\n\t\treturn;\n\t}\n\n\tdev_kfree_skb(skb);\n\t\/\/ Should be ??? skb_queue_tail(&sk->sk_receive_queue, skb);\n\n\t\/* How much header space do we need to reserve *\/\n\tself->max_header_size = max_header_size;\n\n\t\/* IrTTP max SDU size in transmit direction *\/\n\tself->max_sdu_size_tx = max_sdu_size;\n\n\t\/* Find out what the largest chunk of data that we can transmit is *\/\n\tswitch (sk->sk_type) {\n\tcase SOCK_STREAM:\n\t\tif (max_sdu_size != 0) {\n\t\t\tIRDA_ERROR(\"%s: max_sdu_size must be 0\\n\",\n\t\t\t\t   __func__);\n\t\t\treturn;\n\t\t}\n\t\tself->max_data_size = irttp_get_max_seg_size(self->tsap);\n\t\tbreak;\n\tcase SOCK_SEQPACKET:\n\t\tif (max_sdu_size == 0) {\n\t\t\tIRDA_ERROR(\"%s: max_sdu_size cannot be 0\\n\",\n\t\t\t\t   __func__);\n\t\t\treturn;\n\t\t}\n\t\tself->max_data_size = max_sdu_size;\n\t\tbreak;\n\tdefault:\n\t\tself->max_data_size = irttp_get_max_seg_size(self->tsap);\n\t}\n\n\tIRDA_DEBUG(2, \"%s(), max_data_size=%d\\n\", __func__,\n\t\t   self->max_data_size);\n\n\tmemcpy(&self->qos_tx, qos, sizeof(struct qos_info));\n\n\t\/* We are now connected! *\/\n\tsk->sk_state = TCP_ESTABLISHED;\n\tsk->sk_state_change(sk);\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":446423,"func":"static void populate_cache_headers(RzDyldCache *cache) {\n\tcache->n_hdr = 0;\n\tRzList *hdrs = rz_list_newf(NULL);\n\tif (!hdrs) {\n\t\treturn;\n\t}\n\n\tcache_hdr_t *h;\n\tut64 offsets[MAX_N_HDR];\n\tut64 offset = 0;\n\tdo {\n\t\toffsets[cache->n_hdr] = offset;\n\t\th = read_cache_header(cache->buf, offset);\n\t\tif (!h) {\n\t\t\tbreak;\n\t\t}\n\t\trz_list_append(hdrs, h);\n\n\t\tut64 size = h->codeSignatureOffset + h->codeSignatureSize;\n\n#define SHIFT_MAYBE(x) \\\n\tif (x) { \\\n\t\tx += offset; \\\n\t}\n\n\t\tSHIFT_MAYBE(h->mappingOffset);\n\t\tSHIFT_MAYBE(h->imagesOffset);\n\t\tSHIFT_MAYBE(h->codeSignatureOffset);\n\t\tSHIFT_MAYBE(h->slideInfoOffset);\n\t\tSHIFT_MAYBE(h->localSymbolsOffset);\n\t\tSHIFT_MAYBE(h->branchPoolsOffset);\n\t\tSHIFT_MAYBE(h->imagesTextOffset);\n\n\t\toffset += size;\n\t\tcache->n_hdr++;\n\t} while (cache->n_hdr < MAX_N_HDR);\n\n\tif (!cache->n_hdr) {\n\t\tgoto beach;\n\t}\n\n\tcache->hdr = RZ_NEWS0(cache_hdr_t, cache->n_hdr);\n\tif (!cache->hdr) {\n\t\tcache->n_hdr = 0;\n\t\tgoto beach;\n\t}\n\n\tcache->hdr_offset = RZ_NEWS0(ut64, cache->n_hdr);\n\tif (!cache->hdr_offset) {\n\t\tcache->n_hdr = 0;\n\t\tRZ_FREE(cache->hdr);\n\t\tgoto beach;\n\t}\n\n\tmemcpy(cache->hdr_offset, offsets, cache->n_hdr * sizeof(ut64));\n\n\tut32 i = 0;\n\tRzListIter *iter;\n\tcache_hdr_t *item;\n\trz_list_foreach (hdrs, iter, item) {\n\t\tif (i >= cache->n_hdr) {\n\t\t\tbreak;\n\t\t}\n\t\tmemcpy(&cache->hdr[i++], item, sizeof(cache_hdr_t));\n\t}\n\nbeach:\n\trz_list_free(hdrs);\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":432158,"func":"auto buildProjectionForPushdown(const DepsTracker& deps,\n                                Pipeline* pipeline,\n                                bool allowExpressions) {\n    auto&& sources = pipeline->getSources();\n\n    \/\/ Short-circuit if the pipeline is empty: there is no projection and nothing to push down.\n    if (sources.empty()) {\n        return BSONObj();\n    }\n\n    if (const auto projStage =\n            exact_pointer_cast<DocumentSourceSingleDocumentTransformation*>(sources.front().get());\n        projStage) {\n        if (projStage->getType() == TransformerInterface::TransformerType::kInclusionProjection) {\n            auto projObj =\n                projStage->getTransformer().serializeTransformation(boost::none).toBson();\n            auto projAst = projection_ast::parse(projStage->getContext(),\n                                                 projObj,\n                                                 ProjectionPolicies::aggregateProjectionPolicies());\n            if (!projAst.hasExpressions() || allowExpressions) {\n                \/\/ If there is an inclusion projection at the front of the pipeline, we have case 1.\n                sources.pop_front();\n                return projObj;\n            }\n        }\n    }\n\n    \/\/ Depending of whether there is a finite dependency set, either return a projection\n    \/\/ representing this dependency set, or an empty BSON, meaning no projection push down will\n    \/\/ happen. This covers cases 2 and 3.\n    if (deps.getNeedsAnyMetadata())\n        return BSONObj();\n    return deps.toProjectionWithoutMetadata();\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":383373,"func":"gdImageBrushApply (gdImagePtr im, int x, int y)\n{\n\tint lx, ly;\n\tint hy, hx;\n\tint x1, y1, x2, y2;\n\tint srcx, srcy;\n\n\tif (!im->brush) {\n\t\treturn;\n\t}\n\n\thy = gdImageSY (im->brush) \/ 2;\n\ty1 = y - hy;\n\ty2 = y1 + gdImageSY (im->brush);\n\thx = gdImageSX (im->brush) \/ 2;\n\tx1 = x - hx;\n\tx2 = x1 + gdImageSX (im->brush);\n\tsrcy = 0;\n\t\n\tif (im->trueColor) {\n\t\tfor (ly = y1; (ly < y2); ly++) {\n\t\t\tsrcx = 0;\n\t\t\tfor (lx = x1; (lx < x2); lx++) {\n\t\t\t\tint p;\n\t\t\t\tp = gdImageGetTrueColorPixel (im->brush, srcx, srcy);\n\t\t\t\t\/* 2.0.9, Thomas Winzig: apply simple full transparency *\/\n\t\t\t\tif (p != gdImageGetTransparent (im->brush)) {\n\t\t\t\t\tgdImageSetPixel (im, lx, ly, p);\n\t\t\t\t}      \n\t\t\t\tsrcx++;\n\t\t\t}\n\t\t\tsrcy++;\n\t\t}\n\t} else {\n\t\tfor (ly = y1; (ly < y2); ly++) {\n\t\t\tsrcx = 0;\n\t\t\tfor (lx = x1; (lx < x2); lx++) {\n\t\t\t\tint p;\n\t\t\t\tp = gdImageGetPixel (im->brush, srcx, srcy);\n\t\t\t\t\/* Allow for non-square brushes! *\/\n\t\t\t\tif (p != gdImageGetTransparent (im->brush)) {\n\t\t\t\t\t\/* Truecolor brush. Very slow on a palette destination. *\/\n\t\t\t\t\tif (im->brush->trueColor) {\n\t\t\t\t\t\tgdImageSetPixel(im, lx, ly, gdImageColorResolveAlpha(im, gdTrueColorGetRed(p), \n\t\t\t\t\t\t\t\t\t\t\t\t\t gdTrueColorGetGreen(p), \n\t\t\t\t\t\t\t\t\t\t\t\t\t gdTrueColorGetBlue(p),\n\t\t\t\t\t\t\t\t\t\t\t\t\t gdTrueColorGetAlpha(p)));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgdImageSetPixel(im, lx, ly, im->brushColorMap[p]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsrcx++;\n\t\t\t}\n\t\t\tsrcy++;\n\t\t}\n\t}\n}","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":508894,"func":"init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex)\n{\n  TABLE_LIST *table_list;\n  Table_ident *table_ident;\n  SELECT_LEX *select_lex= &lex->select_lex;\n  Name_resolution_context *context= &select_lex->context;\n  \/*\n    We will call the parser to create a part_info struct based on the\n    partition string stored in the frm file.\n    We will use a local lex object for this purpose. However we also\n    need to set the Name_resolution_object for this lex object. We\n    do this by using add_table_to_list where we add the table that\n    we're working with to the Name_resolution_context.\n  *\/\n  thd->lex= lex;\n  lex_start(thd);\n  context->init();\n  if ((!(table_ident= new Table_ident(thd,\n                                      table->s->table_name,\n                                      table->s->db, TRUE))) ||\n      (!(table_list= select_lex->add_table_to_list(thd,\n                                                   table_ident,\n                                                   NULL,\n                                                   0))))\n    return TRUE;\n  context->resolve_in_table_list_only(table_list);\n  lex->use_only_table_context= TRUE;\n  lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VCOL_EXPR;\n  select_lex->cur_pos_in_select_list= UNDEF_POS;\n  table->map= 1; \/\/To ensure correct calculation of const item\n  table_list->table= table;\n  table_list->cacheable_table= false;\n  return FALSE;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":430448,"func":"size_t ovs_key_attr_size(void)\n{\n\t\/* Whenever adding new OVS_KEY_ FIELDS, we should consider\n\t * updating this function.\n\t *\/\n\tBUILD_BUG_ON(OVS_KEY_ATTR_MAX != 32);\n\n\treturn    nla_total_size(4)   \/* OVS_KEY_ATTR_PRIORITY *\/\n\t\t+ nla_total_size(0)   \/* OVS_KEY_ATTR_TUNNEL *\/\n\t\t  + ovs_tun_key_attr_size()\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_IN_PORT *\/\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_SKB_MARK *\/\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_DP_HASH *\/\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_RECIRC_ID *\/\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_CT_STATE *\/\n\t\t+ nla_total_size(2)   \/* OVS_KEY_ATTR_CT_ZONE *\/\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_CT_MARK *\/\n\t\t+ nla_total_size(16)  \/* OVS_KEY_ATTR_CT_LABELS *\/\n\t\t+ nla_total_size(40)  \/* OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6 *\/\n\t\t+ nla_total_size(0)   \/* OVS_KEY_ATTR_NSH *\/\n\t\t  + ovs_nsh_key_attr_size()\n\t\t+ nla_total_size(12)  \/* OVS_KEY_ATTR_ETHERNET *\/\n\t\t+ nla_total_size(2)   \/* OVS_KEY_ATTR_ETHERTYPE *\/\n\t\t+ nla_total_size(4)   \/* OVS_KEY_ATTR_VLAN *\/\n\t\t+ nla_total_size(0)   \/* OVS_KEY_ATTR_ENCAP *\/\n\t\t+ nla_total_size(2)   \/* OVS_KEY_ATTR_ETHERTYPE *\/\n\t\t+ nla_total_size(40)  \/* OVS_KEY_ATTR_IPV6 *\/\n\t\t+ nla_total_size(2)   \/* OVS_KEY_ATTR_ICMPV6 *\/\n\t\t+ nla_total_size(28)  \/* OVS_KEY_ATTR_ND *\/\n\t\t+ nla_total_size(2);  \/* OVS_KEY_ATTR_IPV6_EXTHDRS *\/\n}","target":0,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":195234,"func":"  Status BuildInputArgIndex(const OpDef::ArgDef& arg_def, AttrSlice attr_values,\n                            const FunctionDef::ArgAttrs* arg_attrs,\n                            bool ints_on_device,\n                            int64_t resource_arg_unique_id) {\n    bool is_type_list;\n    DataTypeVector dtypes;\n    TF_RETURN_IF_ERROR(\n        ArgNumType(attr_values, arg_def, &is_type_list, &dtypes));\n    if (dtypes.size() < size_t{1}) {\n      return errors::Internal(\"Expected a list of at least one dtype\");\n    }\n    int arg_index = result_.nodes.size();\n    TF_RETURN_IF_ERROR(\n        AddItem(arg_def.name(), {true, arg_index, 0, is_type_list, dtypes}));\n    \/\/ Creates dtypes.size() nodes in the graph.\n    for (size_t i = 0; i < dtypes.size(); ++i) {\n      TF_RETURN_IF_ERROR(AddItem(strings::StrCat(arg_def.name(), \":\", i),\n                                 {true, arg_index, 0, false, {dtypes[i]}}));\n      DCHECK_EQ(arg_index, result_.nodes.size());\n      string name = arg_def.name();\n      if (dtypes.size() > 1) {\n        strings::StrAppend(&name, \"_\", i);\n      }\n      NodeDef* gnode = AddNode(name);\n      if (ints_on_device && dtypes[i] == DataType::DT_INT32) {\n        gnode->set_op(FunctionLibraryDefinition::kDeviceArgOp);\n      } else {\n        gnode->set_op(FunctionLibraryDefinition::kArgOp);\n      }\n      DataType dtype = arg_def.is_ref() ? MakeRefType(dtypes[i]) : dtypes[i];\n      AddAttr(\"T\", dtype, gnode);\n      AddAttr(\"index\", arg_index, gnode);\n      if (resource_arg_unique_id >= 0) {\n        AddAttr(\"_resource_arg_unique_id\", resource_arg_unique_id, gnode);\n      }\n      if (arg_attrs) {\n        for (const auto& arg_attr : arg_attrs->attr()) {\n          AddAttr(arg_attr.first, arg_attr.second, gnode->mutable_attr());\n        }\n      }\n      result_.arg_types.push_back(dtypes[i]);\n      ++arg_index;\n    }\n    return Status::OK();\n  }","target":1,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":439173,"func":"static MagickBooleanType WriteAAIImage(const ImageInfo *image_info,Image *image)\n{\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  register const PixelPacket\n    *magick_restrict p;\n\n  register ssize_t\n    x;\n\n  register unsigned char\n    *magick_restrict q;\n\n  size_t\n    imageListLength;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    \/*\n      Write AAI header.\n    *\/\n    (void) TransformImageColorspace(image,sRGBColorspace);\n    (void) WriteBlobLSBLong(image,(unsigned int) image->columns);\n    (void) WriteBlobLSBLong(image,(unsigned int) image->rows);\n    \/*\n      Allocate memory for pixels.\n    *\/\n    pixels=(unsigned char *) AcquireQuantumMemory(image->columns,\n      4*sizeof(*pixels));\n    if (pixels == (unsigned char *) NULL)\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    \/*\n      Convert MIFF to AAI raster pixels.\n    *\/\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n      if (p == (PixelPacket *) NULL)\n        break;\n      q=pixels;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        *q++=ScaleQuantumToChar(GetPixelBlue(p));\n        *q++=ScaleQuantumToChar(GetPixelGreen(p));\n        *q++=ScaleQuantumToChar(GetPixelRed(p));\n        *q=ScaleQuantumToChar((Quantum) (QuantumRange-(image->matte !=\n          MagickFalse ? GetPixelOpacity(p) : OpaqueOpacity)));\n        if (*q == 255)\n          *q=254;\n        p++;\n        q++;\n      }\n      count=WriteBlob(image,(size_t) (q-pixels),pixels);\n      if (count != (ssize_t) (q-pixels))\n        break;\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":740,"total_token_length":976,"max_tokens_setting":1024}
+{"idx":424948,"func":"static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,\n\t\t\t\t   const struct fw_img *fw, bool run_in_rfkill)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tbool hw_rfkill;\n\tint ret;\n\n\t\/* This may fail if AMT took ownership of the device *\/\n\tif (iwl_pcie_prepare_card_hw(trans)) {\n\t\tIWL_WARN(trans, \"Exit HW not ready\\n\");\n\t\tret = -EIO;\n\t\tgoto out;\n\t}\n\n\tiwl_enable_rfkill_int(trans);\n\n\tiwl_write32(trans, CSR_INT, 0xFFFFFFFF);\n\n\t\/*\n\t * We enabled the RF-Kill interrupt and the handler may very\n\t * well be running. Disable the interrupts to make sure no other\n\t * interrupt can be fired.\n\t *\/\n\tiwl_disable_interrupts(trans);\n\n\t\/* Make sure it finished running *\/\n\tiwl_pcie_synchronize_irqs(trans);\n\n\tmutex_lock(&trans_pcie->mutex);\n\n\t\/* If platform's RF_KILL switch is NOT set to KILL *\/\n\thw_rfkill = iwl_pcie_check_hw_rf_kill(trans);\n\tif (hw_rfkill && !run_in_rfkill) {\n\t\tret = -ERFKILL;\n\t\tgoto out;\n\t}\n\n\t\/* Someone called stop_device, don't try to start_fw *\/\n\tif (trans_pcie->is_down) {\n\t\tIWL_WARN(trans,\n\t\t\t \"Can't start_fw since the HW hasn't been started\\n\");\n\t\tret = -EIO;\n\t\tgoto out;\n\t}\n\n\t\/* make sure rfkill handshake bits are cleared *\/\n\tiwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);\n\tiwl_write32(trans, CSR_UCODE_DRV_GP1_CLR,\n\t\t    CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);\n\n\t\/* clear (again), then enable host interrupts *\/\n\tiwl_write32(trans, CSR_INT, 0xFFFFFFFF);\n\n\tret = iwl_pcie_nic_init(trans);\n\tif (ret) {\n\t\tIWL_ERR(trans, \"Unable to init nic\\n\");\n\t\tgoto out;\n\t}\n\n\t\/*\n\t * Now, we load the firmware and don't want to be interrupted, even\n\t * by the RF-Kill interrupt (hence mask all the interrupt besides the\n\t * FH_TX interrupt which is needed to load the firmware). If the\n\t * RF-Kill switch is toggled, we will find out after having loaded\n\t * the firmware and return the proper value to the caller.\n\t *\/\n\tiwl_enable_fw_load_int(trans);\n\n\t\/* really make sure rfkill handshake bits are cleared *\/\n\tiwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);\n\tiwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);\n\n\t\/* Load the given image to the HW *\/\n\tif (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_8000)\n\t\tret = iwl_pcie_load_given_ucode_8000(trans, fw);\n\telse\n\t\tret = iwl_pcie_load_given_ucode(trans, fw);\n\n\t\/* re-check RF-Kill state since we may have missed the interrupt *\/\n\thw_rfkill = iwl_pcie_check_hw_rf_kill(trans);\n\tif (hw_rfkill && !run_in_rfkill)\n\t\tret = -ERFKILL;\n\nout:\n\tmutex_unlock(&trans_pcie->mutex);\n\treturn ret;\n}","target":0,"code_token_length":733,"total_token_length":969,"max_tokens_setting":1024}
+{"idx":492687,"func":"vte_sequence_handler_insert_lines (VteTerminal *terminal, GValueArray *params)\n{\n\tGValue *value;\n\tVteScreen *screen;\n\tlong param, end, row;\n\tint i;\n\tscreen = terminal->pvt->screen;\n\t\/* The default is one. *\/\n\tparam = 1;\n\t\/* Extract any parameters. *\/\n\tif ((params != NULL) && (params->n_values > 0)) {\n\t\tvalue = g_value_array_get_nth(params, 0);\n\t\tif (G_VALUE_HOLDS_LONG(value)) {\n\t\t\tparam = g_value_get_long(value);\n\t\t}\n\t}\n\t\/* Find the region we're messing with. *\/\n\trow = screen->cursor_current.row;\n\tif (screen->scrolling_restricted) {\n\t\tend = screen->insert_delta + screen->scrolling_region.end;\n\t} else {\n\t\tend = screen->insert_delta + terminal->row_count - 1;\n\t}\n\t\/* Insert the new lines at the cursor. *\/\n\tfor (i = 0; i < param; i++) {\n\t\t\/* Clear a line off the end of the region and add one to the\n\t\t * top of the region. *\/\n\t\t_vte_terminal_ring_remove (terminal, end);\n\t\t_vte_terminal_ring_insert (terminal, row, TRUE);\n\t}\n\t\/* Update the display. *\/\n\t_vte_terminal_scroll_region(terminal, row, end - row + 1, param);\n\t\/* Adjust the scrollbars if necessary. *\/\n\t_vte_terminal_adjust_adjustments(terminal);\n\t\/* We've modified the display.  Make a note of it. *\/\n\tterminal->pvt->text_inserted_flag = TRUE;\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":242586,"func":"EFI_STATUS verify_image(void *data, unsigned int datasize,\n\t\t\tEFI_LOADED_IMAGE *li,\n\t\t\tPE_COFF_LOADER_IMAGE_CONTEXT *context)\n{\n\tEFI_STATUS efi_status;\n\tUINT8 sha1hash[SHA1_DIGEST_SIZE];\n\tUINT8 sha256hash[SHA256_DIGEST_SIZE];\n\n\t\/*\n\t * The binary header contains relevant context and section pointers\n\t *\/\n\tefi_status = read_header(data, datasize, context);\n\tif (EFI_ERROR(efi_status)) {\n\t\tperror(L\"Failed to read header: %r\\n\", efi_status);\n\t\treturn efi_status;\n\t}\n\n\t\/*\n\t * Perform the image verification before we start copying data around\n\t * in order to load it.\n\t *\/\n\tif (secure_mode()) {\n\t\tefi_status = verify_buffer(data, datasize,\n\t\t\t\t\t   context, sha256hash, sha1hash);\n\t\tif (EFI_ERROR(efi_status)) {\n\t\t\tif (verbose)\n\t\t\t\tconsole_print(L\"Verification failed: %r\\n\", efi_status);\n\t\t\telse\n\t\t\t\tconsole_error(L\"Verification failed\", efi_status);\n\t\t\treturn efi_status;\n\t\t} else if (verbose)\n\t\t\tconsole_print(L\"Verification succeeded\\n\");\n\t}\n\n\t\/*\n\t * Calculate the hash for the TPM measurement.\n\t * XXX: We're computing these twice in secure boot mode when the\n\t *  buffers already contain the previously computed hashes. Also,\n\t *  this is only useful for the TPM1.2 case. We should try to fix\n\t *  this in a follow-up.\n\t *\/\n\tefi_status = generate_hash(data, datasize, context, sha256hash,\n\t\t\t\t   sha1hash);\n\tif (EFI_ERROR(efi_status))\n\t\treturn efi_status;\n\n\t\/* Measure the binary into the TPM *\/\n#ifdef REQUIRE_TPM\n\tefi_status =\n#endif\n\ttpm_log_pe((EFI_PHYSICAL_ADDRESS)(UINTN)data, datasize,\n\t\t   (EFI_PHYSICAL_ADDRESS)(UINTN)context->ImageAddress,\n\t\t   li->FilePath, sha1hash, 4);\n#ifdef REQUIRE_TPM\n\tif (efi_status != EFI_SUCCESS) {\n\t\treturn efi_status;\n\t}\n#endif\n\n\treturn EFI_SUCCESS;\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":256434,"func":"static pj_status_t add_sdp_attr_rtcp_fb( pj_pool_t *pool,\n\t\t\t\t\t const char *pt,\n\t\t\t\t\t const pjmedia_rtcp_fb_cap *cap,\n\t\t\t\t\t pjmedia_sdp_media *m)\n{\n    pjmedia_sdp_attr *a;\n    char tmp[128];\n    pj_str_t val;\n    pj_str_t type_name = {0};\n\n    if (cap->type < PJMEDIA_RTCP_FB_OTHER)\n\tpj_cstr(&type_name, rtcp_fb_type_name[cap->type].name);\n    else if (cap->type == PJMEDIA_RTCP_FB_OTHER)\n\ttype_name = cap->type_name;\n\n    if (type_name.slen == 0)\n\treturn PJ_EINVAL;\n\n    \/* Generate RTCP FB param *\/\n    if (cap->param.slen) {\n\tpj_ansi_snprintf(tmp, sizeof(tmp), \"%s %.*s %.*s\", pt,\n\t\t\t (int)type_name.slen, type_name.ptr,\n\t\t\t (int)cap->param.slen, cap->param.ptr);\n    } else {\n\tpj_ansi_snprintf(tmp, sizeof(tmp), \"%s %.*s\", pt,\n\t\t\t (int)type_name.slen, type_name.ptr);\n    }\n    pj_strset2(&val, tmp);\n\n    \/* Generate and add SDP attribute a=rtcp-fb *\/\n    a = pjmedia_sdp_attr_create(pool, \"rtcp-fb\", &val);\n    m->attr[m->attr_count++] = a;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":300750,"func":"static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk,\n\t\t\t       struct msghdr *m, struct tipc_member *mb,\n\t\t\t       u32 dnode, u32 dport, int dlen)\n{\n\tu16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group);\n\tstruct tipc_mc_method *method = &tsk->mc_method;\n\tint blks = tsk_blocks(GROUP_H_SIZE + dlen);\n\tstruct tipc_msg *hdr = &tsk->phdr;\n\tstruct sk_buff_head pkts;\n\tint mtu, rc;\n\n\t\/* Complete message header *\/\n\tmsg_set_type(hdr, TIPC_GRP_UCAST_MSG);\n\tmsg_set_hdr_sz(hdr, GROUP_H_SIZE);\n\tmsg_set_destport(hdr, dport);\n\tmsg_set_destnode(hdr, dnode);\n\tmsg_set_grp_bc_seqno(hdr, bc_snd_nxt);\n\n\t\/* Build message as chain of buffers *\/\n\t__skb_queue_head_init(&pkts);\n\tmtu = tipc_node_get_mtu(net, dnode, tsk->portid, false);\n\trc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts);\n\tif (unlikely(rc != dlen))\n\t\treturn rc;\n\n\t\/* Send message *\/\n\trc = tipc_node_xmit(net, &pkts, dnode, tsk->portid);\n\tif (unlikely(rc == -ELINKCONG)) {\n\t\ttipc_dest_push(&tsk->cong_links, dnode, 0);\n\t\ttsk->cong_link_cnt++;\n\t}\n\n\t\/* Update send window *\/\n\ttipc_group_update_member(mb, blks);\n\n\t\/* A broadcast sent within next EXPIRE period must follow same path *\/\n\tmethod->rcast = true;\n\tmethod->mandatory = true;\n\treturn dlen;\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":410714,"func":"static int packet_do_bind(struct sock *sk, const char *name, int ifindex,\n\t\t\t  __be16 proto)\n{\n\tstruct packet_sock *po = pkt_sk(sk);\n\tstruct net_device *dev_curr;\n\t__be16 proto_curr;\n\tbool need_rehook;\n\tstruct net_device *dev = NULL;\n\tint ret = 0;\n\tbool unlisted = false;\n\n\tlock_sock(sk);\n\tspin_lock(&po->bind_lock);\n\trcu_read_lock();\n\n\tif (po->fanout) {\n\t\tret = -EINVAL;\n\t\tgoto out_unlock;\n\t}\n\n\tif (name) {\n\t\tdev = dev_get_by_name_rcu(sock_net(sk), name);\n\t\tif (!dev) {\n\t\t\tret = -ENODEV;\n\t\t\tgoto out_unlock;\n\t\t}\n\t} else if (ifindex) {\n\t\tdev = dev_get_by_index_rcu(sock_net(sk), ifindex);\n\t\tif (!dev) {\n\t\t\tret = -ENODEV;\n\t\t\tgoto out_unlock;\n\t\t}\n\t}\n\n\tdev_hold(dev);\n\n\tproto_curr = po->prot_hook.type;\n\tdev_curr = po->prot_hook.dev;\n\n\tneed_rehook = proto_curr != proto || dev_curr != dev;\n\n\tif (need_rehook) {\n\t\tif (po->running) {\n\t\t\trcu_read_unlock();\n\t\t\t\/* prevents packet_notifier() from calling\n\t\t\t * register_prot_hook()\n\t\t\t *\/\n\t\t\tWRITE_ONCE(po->num, 0);\n\t\t\t__unregister_prot_hook(sk, true);\n\t\t\trcu_read_lock();\n\t\t\tdev_curr = po->prot_hook.dev;\n\t\t\tif (dev)\n\t\t\t\tunlisted = !dev_get_by_index_rcu(sock_net(sk),\n\t\t\t\t\t\t\t\t dev->ifindex);\n\t\t}\n\n\t\tBUG_ON(po->running);\n\t\tWRITE_ONCE(po->num, proto);\n\t\tpo->prot_hook.type = proto;\n\n\t\tif (unlikely(unlisted)) {\n\t\t\tdev_put(dev);\n\t\t\tpo->prot_hook.dev = NULL;\n\t\t\tWRITE_ONCE(po->ifindex, -1);\n\t\t\tpacket_cached_dev_reset(po);\n\t\t} else {\n\t\t\tpo->prot_hook.dev = dev;\n\t\t\tWRITE_ONCE(po->ifindex, dev ? dev->ifindex : 0);\n\t\t\tpacket_cached_dev_assign(po, dev);\n\t\t}\n\t}\n\tdev_put(dev_curr);\n\n\tif (proto == 0 || !need_rehook)\n\t\tgoto out_unlock;\n\n\tif (!unlisted && (!dev || (dev->flags & IFF_UP))) {\n\t\tregister_prot_hook(sk);\n\t} else {\n\t\tsk->sk_err = ENETDOWN;\n\t\tif (!sock_flag(sk, SOCK_DEAD))\n\t\t\tsk_error_report(sk);\n\t}\n\nout_unlock:\n\trcu_read_unlock();\n\tspin_unlock(&po->bind_lock);\n\trelease_sock(sk);\n\treturn ret;\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":513237,"func":"static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,\n                             bool *changed)\n{\n  if (expr->argument_count())\n  {\n    Name_resolution_context *context= &thd->lex->current_select->context;\n    Item **arg,**arg_end;\n    bool arg_changed= FALSE;\n    for (arg= expr->arguments(),\n         arg_end= expr->arguments() + expr->argument_count();\n         arg != arg_end; arg++)\n    {\n      Item *item= *arg;\n      if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM)\n      {\n        ORDER *group_tmp;\n        for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next)\n        {\n          if (item->eq(*group_tmp->item,0))\n          {\n            Item *new_item;\n            if (!(new_item= new (thd->mem_root) Item_ref(thd, context, group_tmp->item, 0,\n                                         item->name)))\n              return 1;                                 \/\/ fatal_error is set\n            thd->change_item_tree(arg, new_item);\n            arg_changed= TRUE;\n          }\n        }\n      }\n      else if (item->type() == Item::FUNC_ITEM)\n      {\n        if (change_group_ref(thd, (Item_func *) item, group_list, &arg_changed))\n          return 1;\n      }\n    }\n    if (arg_changed)\n    {\n      expr->maybe_null= 1;\n      expr->in_rollup= 1;\n      *changed= TRUE;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":233872,"func":" *\/\nstatic void php_wddx_add_var(wddx_packet *packet, zval *name_var)\n{\n\tzval *val;\n\tHashTable *target_hash;\n\n\tif (Z_TYPE_P(name_var) == IS_STRING) {\n\t\tzend_array *symbol_table = zend_rebuild_symbol_table();\n\t\tif ((val = zend_hash_find(symbol_table, Z_STR_P(name_var))) != NULL) {\n\t\t\tif (Z_TYPE_P(val) == IS_INDIRECT) {\n\t\t\t\tval = Z_INDIRECT_P(val);\n\t\t\t}\n\t\t\tphp_wddx_serialize_var(packet, val, Z_STR_P(name_var));\n\t\t}\n\t} else if (Z_TYPE_P(name_var) == IS_ARRAY || Z_TYPE_P(name_var) == IS_OBJECT)\t{\n\t\tint is_array = Z_TYPE_P(name_var) == IS_ARRAY;\n\n\t\ttarget_hash = HASH_OF(name_var);\n\n\t\tif (is_array && target_hash->u.v.nApplyCount > 1) {\n\t\t\tphp_error_docref(NULL, E_WARNING, \"recursion detected\");\n\t\t\treturn;\n\t\t}\n\n\t\tif (Z_IMMUTABLE_P(name_var)) {\n\t\t\tZEND_HASH_FOREACH_VAL(target_hash, val) {\n\t\t\t\tphp_wddx_add_var(packet, val);\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t} else {\n\t\t\tZEND_HASH_FOREACH_VAL(target_hash, val) {\n\t\t\t\tif (is_array) {\n\t\t\t\t\ttarget_hash->u.v.nApplyCount++;\n\t\t\t\t}\n\n\t\t\t\tZVAL_DEREF(val);\n\t\t\t\tphp_wddx_add_var(packet, val);\n\n\t\t\t\tif (is_array) {\n\t\t\t\t\ttarget_hash->u.v.nApplyCount--;\n\t\t\t\t}\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t}\n\t}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":231035,"func":"    BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex )\r\n    {\r\n        BaseType_t xReturn;\r\n        Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r\n\r\n        configASSERT( pxMutex );\r\n\r\n        \/* If this is the task that holds the mutex then xMutexHolder will not\r\n         * change outside of this task.  If this task does not hold the mutex then\r\n         * pxMutexHolder can never coincidentally equal the tasks handle, and as\r\n         * this is the only condition we are interested in it does not matter if\r\n         * pxMutexHolder is accessed simultaneously by another task.  Therefore no\r\n         * mutual exclusion is required to test the pxMutexHolder variable. *\/\r\n        if( pxMutex->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle() )\r\n        {\r\n            traceGIVE_MUTEX_RECURSIVE( pxMutex );\r\n\r\n            \/* uxRecursiveCallCount cannot be zero if xMutexHolder is equal to\r\n             * the task handle, therefore no underflow check is required.  Also,\r\n             * uxRecursiveCallCount is only modified by the mutex holder, and as\r\n             * there can only be one, no mutual exclusion is required to modify the\r\n             * uxRecursiveCallCount member. *\/\r\n            ( pxMutex->u.xSemaphore.uxRecursiveCallCount )--;\r\n\r\n            \/* Has the recursive call count unwound to 0? *\/\r\n            if( pxMutex->u.xSemaphore.uxRecursiveCallCount == ( UBaseType_t ) 0 )\r\n            {\r\n                \/* Return the mutex.  This will automatically unblock any other\r\n                 * task that might be waiting to access the mutex. *\/\r\n                ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n\r\n            xReturn = pdPASS;\r\n        }\r\n        else\r\n        {\r\n            \/* The mutex cannot be given because the calling task is not the\r\n             * holder. *\/\r\n            xReturn = pdFAIL;\r\n\r\n            traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex );\r\n        }\r\n\r\n        return xReturn;\r\n    }\r","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":219950,"func":"int callback_glewlwyd_check_admin_session_or_api_key (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  char * session_uid = NULL;\n  json_t * j_user;\n  int ret, res;\n  const char * api_key = u_map_get_case(request->map_header, GLEWLWYD_API_KEY_HEADER_KEY), * ip_source = get_ip_source(request);\n  \n  if (NULL != api_key && 0 == o_strncmp(GLEWLWYD_API_KEY_HEADER_PREFIX, api_key, o_strlen(GLEWLWYD_API_KEY_HEADER_PREFIX))) {\n    if ((res = verify_api_key(config, api_key + o_strlen(GLEWLWYD_API_KEY_HEADER_PREFIX))) == G_OK) {\n      if (ulfius_set_response_shared_data(response, json_pack(\"{so}\", \"username\", json_null()), (void (*)(void *))&json_decref) != U_OK) {\n        ret = U_CALLBACK_ERROR;\n      } else {\n        ret = U_CALLBACK_IGNORE;\n      }\n    } else if (res == G_ERROR_UNAUTHORIZED) {\n      y_log_message(Y_LOG_LEVEL_WARNING, \"Security - API key invalid at IP Address %s\", ip_source);\n      ret = U_CALLBACK_UNAUTHORIZED;\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_check_admin_session_or_api_key - Error verify_api_key\");\n      ret = U_CALLBACK_ERROR;\n    }\n  } else if ((session_uid = get_session_id(config, request)) != NULL) {\n    j_user = get_current_user_for_session(config, session_uid);\n    if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, \"user\"), \"enabled\") == json_true()) {\n      if ((res = is_scope_list_valid_for_session(config, config->admin_scope, session_uid)) == G_OK) {\n        if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, \"user\")), (void (*)(void *))&json_decref) != U_OK) {\n          ret = U_CALLBACK_ERROR;\n        } else {\n          ret = U_CALLBACK_IGNORE;\n        }\n      } else {\n        if (res == G_ERROR) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_check_admin_session_or_api_key - Error is_scope_list_valid_for_session\");\n        }\n        ret = U_CALLBACK_UNAUTHORIZED;\n      }\n    } else {\n      ret = U_CALLBACK_UNAUTHORIZED;\n    }\n    json_decref(j_user);\n    o_free(session_uid);\n  } else {\n    ret = U_CALLBACK_UNAUTHORIZED;\n  }\n  return ret;\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":513199,"func":"static bool finalize_install(THD *thd, TABLE *table, const LEX_STRING *name,\n                             int *argc, char **argv)\n{\n  struct st_plugin_int *tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN);\n  int error;\n  DBUG_ASSERT(tmp);\n  mysql_mutex_assert_owner(&LOCK_plugin); \/\/ because of tmp->state\n\n  if (tmp->state != PLUGIN_IS_UNINITIALIZED)\n  {\n    \/* already installed *\/\n    return 0;\n  }\n  else\n  {\n    if (plugin_initialize(thd->mem_root, tmp, argc, argv, false))\n    {\n      report_error(REPORT_TO_USER, ER_CANT_INITIALIZE_UDF, name->str,\n                   \"Plugin initialization function failed.\");\n      tmp->state= PLUGIN_IS_DELETED;\n      return 1;\n    }\n  }\n  if (tmp->state == PLUGIN_IS_DISABLED)\n  {\n    if (global_system_variables.log_warnings)\n      push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,\n                          ER_CANT_INITIALIZE_UDF,\n                          ER_THD(thd, ER_CANT_INITIALIZE_UDF),\n                          name->str, \"Plugin is disabled\");\n  }\n\n  \/*\n    We do not replicate the INSTALL PLUGIN statement. Disable binlogging\n    of the insert into the plugin table, so that it is not replicated in\n    row based mode.\n  *\/\n  tmp_disable_binlog(thd);\n  table->use_all_columns();\n  restore_record(table, s->default_values);\n  table->field[0]->store(name->str, name->length, system_charset_info);\n  table->field[1]->store(tmp->plugin_dl->dl.str, tmp->plugin_dl->dl.length,\n                         files_charset_info);\n  error= table->file->ha_write_row(table->record[0]);\n  reenable_binlog(thd);\n  if (error)\n  {\n    table->file->print_error(error, MYF(0));\n    tmp->state= PLUGIN_IS_DELETED;\n    return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":281638,"func":"void CLASS foveon_load_camf()\n{\n  unsigned type, wide, high, i, j, row, col, diff;\n  ushort huff[258], vpred[2][2] = {{512,512},{512,512}}, hpred[2];\n\n  fseek (ifp, meta_offset, SEEK_SET);\n  type = get4();  get4();  get4();\n  wide = get4();\n  high = get4();\n  if (type == 2) {\n    fread (meta_data, 1, meta_length, ifp);\n    for (i=0; i < meta_length; i++) {\n      high = (high * 1597 + 51749) % 244944;\n      wide = high * (INT64) 301593171 >> 24;\n      meta_data[i] ^= ((((high << 8) - wide) >> 1) + wide) >> 17;\n    }\n  } else if (type == 4) {\n    free (meta_data);\n    meta_data = (char *) malloc (meta_length = wide*high*3\/2);\n    merror (meta_data, \"foveon_load_camf()\");\n    foveon_huff (huff);\n    get4();\n    getbits(-1);\n    for (j=row=0; row < high; row++) {\n      for (col=0; col < wide; col++) {\n\tdiff = ljpeg_diff(huff);\n\tif (col < 2) hpred[col] = vpred[row & 1][col] += diff;\n\telse         hpred[col & 1] += diff;\n\tif (col & 1) {\n\t  meta_data[j++] = hpred[0] >> 4;\n\t  meta_data[j++] = hpred[0] << 4 | hpred[1] >> 8;\n\t  meta_data[j++] = hpred[1];\n\t}\n      }\n    }\n  } \n#ifdef DCRAW_VERBOSE\n   else\n    fprintf (stderr,_(\"%s has unknown CAMF type %d.\\n\"), ifname, type);\n#endif\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":430458,"func":"size_t ovs_tun_key_attr_size(void)\n{\n\t\/* Whenever adding new OVS_TUNNEL_KEY_ FIELDS, we should consider\n\t * updating this function.\n\t *\/\n\treturn    nla_total_size_64bit(8) \/* OVS_TUNNEL_KEY_ATTR_ID *\/\n\t\t+ nla_total_size(16)   \/* OVS_TUNNEL_KEY_ATTR_IPV[46]_SRC *\/\n\t\t+ nla_total_size(16)   \/* OVS_TUNNEL_KEY_ATTR_IPV[46]_DST *\/\n\t\t+ nla_total_size(1)    \/* OVS_TUNNEL_KEY_ATTR_TOS *\/\n\t\t+ nla_total_size(1)    \/* OVS_TUNNEL_KEY_ATTR_TTL *\/\n\t\t+ nla_total_size(0)    \/* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT *\/\n\t\t+ nla_total_size(0)    \/* OVS_TUNNEL_KEY_ATTR_CSUM *\/\n\t\t+ nla_total_size(0)    \/* OVS_TUNNEL_KEY_ATTR_OAM *\/\n\t\t+ nla_total_size(256)  \/* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS *\/\n\t\t\/* OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS and\n\t\t * OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS is mutually exclusive with\n\t\t * OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS and covered by it.\n\t\t *\/\n\t\t+ nla_total_size(2)    \/* OVS_TUNNEL_KEY_ATTR_TP_SRC *\/\n\t\t+ nla_total_size(2);   \/* OVS_TUNNEL_KEY_ATTR_TP_DST *\/\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":343159,"func":"static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)\n{\n\tint alen;\n\tint blksize;\n\tstruct ip_esp_hdr *esph;\n\tstruct crypto_aead *aead;\n\tstruct esp_info esp;\n\n\tesp.inplace = true;\n\n\tesp.proto = *skb_mac_header(skb);\n\t*skb_mac_header(skb) = IPPROTO_ESP;\n\n\t\/* skb is pure payload to encrypt *\/\n\n\taead = x->data;\n\talen = crypto_aead_authsize(aead);\n\n\tesp.tfclen = 0;\n\tif (x->tfcpad) {\n\t\tstruct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);\n\t\tu32 padto;\n\n\t\tpadto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached));\n\t\tif (skb->len < padto)\n\t\t\tesp.tfclen = padto - skb->len;\n\t}\n\tblksize = ALIGN(crypto_aead_blocksize(aead), 4);\n\tesp.clen = ALIGN(skb->len + 2 + esp.tfclen, blksize);\n\tesp.plen = esp.clen - skb->len - esp.tfclen;\n\tesp.tailen = esp.tfclen + esp.plen + alen;\n\n\tesp.esph = ip_esp_hdr(skb);\n\n\tesp.nfrags = esp6_output_head(x, skb, &esp);\n\tif (esp.nfrags < 0)\n\t\treturn esp.nfrags;\n\n\tesph = esp.esph;\n\tesph->spi = x->id.spi;\n\n\tesph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);\n\tesp.seqno = cpu_to_be64(XFRM_SKB_CB(skb)->seq.output.low +\n\t\t\t    ((u64)XFRM_SKB_CB(skb)->seq.output.hi << 32));\n\n\tskb_push(skb, -skb_network_offset(skb));\n\n\treturn esp6_output_tail(x, skb, &esp);\n}","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":329931,"func":"_cairo_image_spans_and_zero (void *abstract_renderer,\n\t\t\t     int y, int height,\n\t\t\t     const cairo_half_open_span_t *spans,\n\t\t\t     unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n    uint8_t *mask;\n    int len;\n\n    mask = r->u.mask.data;\n    if (y > r->u.mask.extents.y) {\n\tlen = (y - r->u.mask.extents.y) * r->u.mask.stride;\n\tmemset (mask, 0, len);\n\tmask += len;\n    }\n\n    r->u.mask.extents.y = y + height;\n    r->u.mask.data = mask + height * r->u.mask.stride;\n    if (num_spans == 0) {\n\tmemset (mask, 0, height * r->u.mask.stride);\n    } else {\n\tuint8_t *row = mask;\n\n\tif (spans[0].x != r->u.mask.extents.x) {\n\t    len = spans[0].x - r->u.mask.extents.x;\n\t    memset (row, 0, len);\n\t    row += len;\n\t}\n\n\tdo {\n\t    len = spans[1].x - spans[0].x;\n\t    *row++ = r->opacity * spans[0].coverage;\n\t    if (len > 1) {\n\t\tmemset (row, row[-1], --len);\n\t\trow += len;\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n\n\tif (spans[0].x != r->u.mask.extents.x + r->u.mask.extents.width) {\n\t    len = r->u.mask.extents.x + r->u.mask.extents.width - spans[0].x;\n\t    memset (row, 0, len);\n\t}\n\n\trow = mask;\n\twhile (--height) {\n\t    mask += r->u.mask.stride;\n\t    memcpy (mask, row, r->u.mask.extents.width);\n\t}\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":210161,"func":"gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor)\n{\n\tconst int angle_rounded = (int)floor(angle * 100);\n\n\tif (bgcolor < 0 || bgcolor >= gdMaxColors) {\n\t\treturn NULL;\n\t}\n\n\t\/* impact perf a bit, but not that much. Implementation for palette\n\t   images can be done at a later point.\n\t*\/\n\tif (src->trueColor == 0) {\n\t\tif (bgcolor >= 0) {\n\t\t\tbgcolor =  gdTrueColorAlpha(src->red[bgcolor], src->green[bgcolor], src->blue[bgcolor], src->alpha[bgcolor]);\n\t\t}\n\t\tgdImagePaletteToTrueColor(src);\n\t}\n\n\t\/* no interpolation needed here *\/\n\tswitch (angle_rounded) {\n\t\tcase 9000:\n\t\t\treturn gdImageRotate90(src, 0);\n\t\tcase 18000:\n\t\t\treturn gdImageRotate180(src, 0);\n\t\tcase 27000:\n\t\t\treturn gdImageRotate270(src, 0);\n\t}\n\n\tif (src == NULL || src->interpolation_id < 1 || src->interpolation_id > GD_METHOD_COUNT) {\n\t\treturn NULL;\n\t}\n\n\tswitch (src->interpolation_id) {\n\t\tcase GD_NEAREST_NEIGHBOUR:\n\t\t\treturn gdImageRotateNearestNeighbour(src, angle, bgcolor);\n\t\t\tbreak;\n\n\t\tcase GD_BILINEAR_FIXED:\n\t\t\treturn gdImageRotateBilinear(src, angle, bgcolor);\n\t\t\tbreak;\n\n\t\tcase GD_BICUBIC_FIXED:\n\t\t\treturn gdImageRotateBicubicFixed(src, angle, bgcolor);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\treturn gdImageRotateGeneric(src, angle, bgcolor);\n\t}\n\treturn NULL;\n}","target":1,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":247642,"func":"TEST_P(SslSocketTest, OverrideRequestedServerName) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  client.set_sni(\"lyft.com\");\n\n  Network::TransportSocketOptionsConstSharedPtr transport_socket_options(\n      new Network::TransportSocketOptionsImpl(\"example.com\"));\n\n  TestUtilOptionsV2 test_options(listener, client, true, GetParam());\n  testUtilV2(test_options.setExpectedRequestedServerName(\"example.com\")\n                 .setTransportSocketOptions(transport_socket_options));\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":267848,"func":"vm_op_set_value (ecma_value_t base, \/**< base object *\/\n                 ecma_value_t property, \/**< property name *\/\n                 ecma_value_t value, \/**< ecma value *\/\n                 bool is_strict) \/**< strict mode *\/\n{\n  ecma_value_t result = ECMA_VALUE_EMPTY;\n  ecma_object_t *object_p;\n  ecma_string_t *property_p;\n\n  if (JERRY_UNLIKELY (!ecma_is_value_object (base)))\n  {\n    if (JERRY_UNLIKELY (ecma_is_value_null (base) || ecma_is_value_undefined (base)))\n    {\n#if JERRY_ERROR_MESSAGES\n      result = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE,\n                                                      \"Cannot set property '%' of %\",\n                                                      property,\n                                                      base);\n#else \/* !JERRY_ERROR_MESSAGES *\/\n      result = ecma_raise_type_error (NULL);\n#endif \/* JERRY_ERROR_MESSAGES *\/\n      ecma_free_value (property);\n      return result;\n    }\n\n    if (JERRY_UNLIKELY (!ecma_is_value_prop_name (property)))\n    {\n      property_p = ecma_op_to_string (property);\n      ecma_fast_free_value (property);\n\n      if (JERRY_UNLIKELY (property_p == NULL))\n      {\n        ecma_free_value (base);\n        return ECMA_VALUE_ERROR;\n      }\n    }\n    else\n    {\n      property_p = ecma_get_prop_name_from_value (property);\n    }\n\n    ecma_value_t object = ecma_op_to_object (base);\n    JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (object));\n\n    object_p = ecma_get_object_from_value (object);\n    ecma_op_ordinary_object_prevent_extensions (object_p);\n\n    result = ecma_op_object_put_with_receiver (object_p,\n                                               property_p,\n                                               value,\n                                               base,\n                                               is_strict);\n\n    ecma_free_value (base);\n  }\n  else\n  {\n    object_p = ecma_get_object_from_value (base);\n\n    if (JERRY_UNLIKELY (!ecma_is_value_prop_name (property)))\n    {\n      property_p = ecma_op_to_string (property);\n      ecma_fast_free_value (property);\n\n      if (JERRY_UNLIKELY (property_p == NULL))\n      {\n        ecma_deref_object (object_p);\n        return ECMA_VALUE_ERROR;\n      }\n    }\n    else\n    {\n      property_p = ecma_get_prop_name_from_value (property);\n    }\n\n    if (!ecma_is_lexical_environment (object_p))\n    {\n      result = ecma_op_object_put_with_receiver (object_p,\n                                                 property_p,\n                                                 value,\n                                                 base,\n                                                 is_strict);\n    }\n    else\n    {\n      result = ecma_op_set_mutable_binding (object_p,\n                                            property_p,\n                                            value,\n                                            is_strict);\n    }\n  }\n\n  ecma_deref_object (object_p);\n  ecma_deref_ecma_string (property_p);\n  return result;\n} \/* vm_op_set_value *\/","target":0,"code_token_length":620,"total_token_length":856,"max_tokens_setting":1024}
+{"idx":238811,"func":"find_mps_values(\n    int\t    *initc,\n    int\t    *findc,\n    int\t    *backwards,\n    int\t    switchit)\n{\n    char_u\t*ptr;\n\n    ptr = curbuf->b_p_mps;\n    while (*ptr != NUL)\n    {\n\tif (has_mbyte)\n\t{\n\t    char_u *prev;\n\n\t    if (mb_ptr2char(ptr) == *initc)\n\t    {\n\t\tif (switchit)\n\t\t{\n\t\t    *findc = *initc;\n\t\t    *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);\n\t\t    *backwards = TRUE;\n\t\t}\n\t\telse\n\t\t{\n\t\t    *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);\n\t\t    *backwards = FALSE;\n\t\t}\n\t\treturn;\n\t    }\n\t    prev = ptr;\n\t    ptr += mb_ptr2len(ptr) + 1;\n\t    if (mb_ptr2char(ptr) == *initc)\n\t    {\n\t\tif (switchit)\n\t\t{\n\t\t    *findc = *initc;\n\t\t    *initc = mb_ptr2char(prev);\n\t\t    *backwards = FALSE;\n\t\t}\n\t\telse\n\t\t{\n\t\t    *findc = mb_ptr2char(prev);\n\t\t    *backwards = TRUE;\n\t\t}\n\t\treturn;\n\t    }\n\t    ptr += mb_ptr2len(ptr);\n\t}\n\telse\n\t{\n\t    if (*ptr == *initc)\n\t    {\n\t\tif (switchit)\n\t\t{\n\t\t    *backwards = TRUE;\n\t\t    *findc = *initc;\n\t\t    *initc = ptr[2];\n\t\t}\n\t\telse\n\t\t{\n\t\t    *backwards = FALSE;\n\t\t    *findc = ptr[2];\n\t\t}\n\t\treturn;\n\t    }\n\t    ptr += 2;\n\t    if (*ptr == *initc)\n\t    {\n\t\tif (switchit)\n\t\t{\n\t\t    *backwards = FALSE;\n\t\t    *findc = *initc;\n\t\t    *initc = ptr[-2];\n\t\t}\n\t\telse\n\t\t{\n\t\t    *backwards = TRUE;\n\t\t    *findc =  ptr[-2];\n\t\t}\n\t\treturn;\n\t    }\n\t    ++ptr;\n\t}\n\tif (*ptr == ',')\n\t    ++ptr;\n    }\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":261216,"func":"int MqttClient_Auth(MqttClient *client, MqttAuth* auth)\n{\n    int rc, len;\n\n    \/* Validate required arguments *\/\n    if (client == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    if (auth->stat == MQTT_MSG_BEGIN) {\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n\n        \/* Encode the authentication packet *\/\n        rc = MqttEncode_Auth(client->tx_buf, client->tx_buf_len, auth);\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d\",\n            rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_AUTH),\n            MQTT_PACKET_TYPE_AUTH, 0, 0);\n    #endif\n        if (rc <= 0) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            return rc;\n        }\n        len = rc;\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        rc = wm_SemLock(&client->lockClient);\n        if (rc == 0) {\n            \/* inform other threads of expected response *\/\n            rc = MqttClient_RespList_Add(client, MQTT_PACKET_TYPE_AUTH, 0,\n                &auth->pendResp, auth);\n            wm_SemUnlock(&client->lockClient);\n        }\n        if (rc != 0) {\n            wm_SemUnlock(&client->lockSend);\n            return rc; \/* Error locking client *\/\n        }\n    #endif\n\n        \/* Send authentication packet *\/\n        rc = MqttPacket_Write(client, client->tx_buf, len);\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n        if (rc != len) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (wm_SemLock(&client->lockClient) == 0) {\n                MqttClient_RespList_Remove(client, &auth->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n        #endif\n            return rc;\n        }\n\n        auth->stat = MQTT_MSG_WAIT;\n    }\n\n    \/* Wait for auth packet *\/\n    rc = MqttClient_WaitType(client, auth, MQTT_PACKET_TYPE_AUTH, 0,\n        client->cmd_timeout_ms);\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &auth->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n    \/* reset state *\/\n    auth->stat = MQTT_MSG_BEGIN;\n\n    return rc;\n}","target":0,"code_token_length":653,"total_token_length":889,"max_tokens_setting":1024}
+{"idx":442961,"func":"redraw_after_callback(int call_update_screen, int do_message)\n{\n    ++redrawing_for_callback;\n\n    if (State == HITRETURN || State == ASKMORE || State == SETWSIZE\n\t    || State == EXTERNCMD || State == CONFIRM || exmode_active)\n    {\n\tif (do_message)\n\t    repeat_message();\n    }\n    else if (State & CMDLINE)\n    {\n\t\/\/ Don't redraw when in prompt_for_number().\n\tif (cmdline_row > 0)\n\t{\n\t    \/\/ Redrawing only works when the screen didn't scroll. Don't clear\n\t    \/\/ wildmenu entries.\n\t    if (msg_scrolled == 0\n#ifdef FEAT_WILDMENU\n\t\t    && wild_menu_showing == 0\n#endif\n\t\t    && call_update_screen)\n\t\tupdate_screen(0);\n\n\t    \/\/ Redraw in the same position, so that the user can continue\n\t    \/\/ editing the command.\n\t    redrawcmdline_ex(FALSE);\n\t}\n    }\n    else if (State & (NORMAL | INSERT | TERMINAL))\n    {\n\t\/\/ keep the command line if possible\n\tupdate_screen(VALID_NO_UPDATE);\n\tsetcursor();\n\n\tif (msg_scrolled == 0)\n\t{\n\t    \/\/ don't want a hit-enter prompt when something else is displayed\n\t    msg_didany = FALSE;\n\t    need_wait_return = FALSE;\n\t}\n    }\n    cursor_on();\n#ifdef FEAT_GUI\n    if (gui.in_use && !gui_mch_is_blink_off())\n\t\/\/ Don't update the cursor when it is blinking and off to avoid\n\t\/\/ flicker.\n\tout_flush_cursor(FALSE, FALSE);\n    else\n#endif\n\tout_flush();\n\n    --redrawing_for_callback;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":256389,"func":"int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,\n\t\t\tstruct rq_map_data *map_data,\n\t\t\tconst struct iov_iter *iter, gfp_t gfp_mask)\n{\n\tbool copy = false;\n\tunsigned long align = q->dma_pad_mask | queue_dma_alignment(q);\n\tstruct bio *bio = NULL;\n\tstruct iov_iter i;\n\tint ret = -EINVAL;\n\n\tif (!iter_is_iovec(iter))\n\t\tgoto fail;\n\n\tif (map_data)\n\t\tcopy = true;\n\telse if (blk_queue_may_bounce(q))\n\t\tcopy = true;\n\telse if (iov_iter_alignment(iter) & align)\n\t\tcopy = true;\n\telse if (queue_virt_boundary(q))\n\t\tcopy = queue_virt_boundary(q) & iov_iter_gap_alignment(iter);\n\n\ti = *iter;\n\tdo {\n\t\tif (copy)\n\t\t\tret = bio_copy_user_iov(rq, map_data, &i, gfp_mask);\n\t\telse\n\t\t\tret = bio_map_user_iov(rq, &i, gfp_mask);\n\t\tif (ret)\n\t\t\tgoto unmap_rq;\n\t\tif (!bio)\n\t\t\tbio = rq->bio;\n\t} while (iov_iter_count(&i));\n\n\treturn 0;\n\nunmap_rq:\n\tblk_rq_unmap_user(bio);\nfail:\n\trq->bio = NULL;\n\treturn ret;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":328981,"func":"R_API RBinJavaAttrInfo *r_bin_java_read_next_attr(RBinJavaObj *bin, const ut64 offset, const ut8 *buf, const ut64 buf_len) {\n\tconst ut8 *a_buf = offset + buf;\n\tut8 attr_idx_len = 6;\n\tif (offset + 6 > buf_len) {\n\t\teprintf (\"[X] r_bin_java: Error unable to parse remainder of classfile in Attribute offset \"\n\t\t\t\"(0x%\"PFMT64x \") > len  of remaining bytes (0x%\"PFMT64x \").\\n\", offset, buf_len);\n\t\treturn NULL;\n\t}\n\t\/\/ ut16 attr_idx, ut32 length of attr.\n\tut32 sz = R_BIN_JAVA_UINT (a_buf, 2) + attr_idx_len; \/\/ r_bin_java_read_int (bin, buf_offset+2) + attr_idx_len;\n\tif (sz + offset > buf_len) {\n\t\teprintf (\"[X] r_bin_java: Error unable to parse remainder of classfile in Attribute len \"\n\t\t\t\"(0x%x) + offset (0x%\"PFMT64x \") exceeds length of buffer (0x%\"PFMT64x \").\\n\",\n\t\t\tsz, offset, buf_len);\n\t\treturn NULL;\n\t}\n\t\/\/ when reading the attr bytes, need to also\n\t\/\/ include the initial 6 bytes, which\n\t\/\/ are not included in the attribute length\n\t\/\/ ,\n\t\/\/ sz, buf_offset, buf_offset+sz);\n\tut8 *buffer = r_bin_java_get_attr_buf (bin, sz, offset, buf, buf_len);\n\tRBinJavaAttrInfo *attr = NULL;\n\t\/\/ printf (\"%d %d %d\\n\", sz, buf_len, offset);\n\tif (offset < buf_len) {\n\t\tattr = r_bin_java_read_next_attr_from_buffer (bin, buffer, buf_len - offset, offset);\n\t\tfree (buffer);\n\t\tif (!attr) {\n\t\t\treturn NULL;\n\t\t}\n\t\tattr->size = sz;\n\t} else {\n\t\tfree (buffer);\n\t\teprintf (\"IS OOB\\n\");\n\t}\n\treturn attr;\n}","target":0,"code_token_length":459,"total_token_length":695,"max_tokens_setting":1024}
+{"idx":463184,"func":"static int find_desc_store(annotate_state_t *state,\n                           const char *name,\n                           const annotate_entrydesc_t **descp)\n{\n    int scope = state->which;\n    const ptrarray_t *descs;\n    const annotate_entrydesc_t *db_entry;\n    annotate_entrydesc_t *desc;\n    int i;\n\n    if (scope == ANNOTATION_SCOPE_SERVER) {\n        descs = &server_entries;\n        db_entry = &server_db_entry;\n    }\n    else if (scope == ANNOTATION_SCOPE_MAILBOX) {\n        descs = &mailbox_entries;\n        db_entry = &mailbox_db_entry;\n    }\n    else if (scope == ANNOTATION_SCOPE_MESSAGE) {\n        descs = &message_entries;\n        db_entry = &message_db_entry;\n    }\n    else {\n        syslog(LOG_ERR, \"IOERROR: unknown scope in find_desc_store %d\", scope);\n        return IMAP_INTERNAL;\n    }\n\n    \/* check for DAV annotations *\/\n    if (state->mailbox && (state->mailbox->mbtype & MBTYPES_DAV) &&\n        !strncmp(name, DAV_ANNOT_NS, strlen(DAV_ANNOT_NS))) {\n        *descp = db_entry;\n        return 0;\n    }\n\n    \/* check known IMAP annotations *\/\n    for (i = 0 ; i < descs->count ; i++) {\n        desc = descs->data[i];\n        if (strcmp(name, desc->name))\n            continue;\n        if (!desc->set) {\n            \/* read-only annotation *\/\n            return IMAP_PERMISSION_DENIED;\n        }\n        *descp = desc;\n        return 0;\n    }\n\n    \/* unknown annotation *\/\n    if (!config_getswitch(IMAPOPT_ANNOTATION_ALLOW_UNDEFINED))\n        return IMAP_PERMISSION_DENIED;\n\n    \/* check for \/flags and \/vendor\/cmu *\/\n    if (scope == ANNOTATION_SCOPE_MESSAGE &&\n        !strncmp(name, \"\/flags\/\", 7))\n        return IMAP_PERMISSION_DENIED;\n\n    if (!strncmp(name, IMAP_ANNOT_NS, strlen(IMAP_ANNOT_NS)))\n        return IMAP_PERMISSION_DENIED;\n\n    *descp = db_entry;\n    return 0;\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":233826,"func":"int fmtutil_find_zip_eocd(deark *c, dbuf *f, i64 *foundpos)\n{\n\tu32 sig;\n\tu8 *buf = NULL;\n\tint retval = 0;\n\ti64 buf_offset;\n\ti64 buf_size;\n\ti64 i;\n\n\t*foundpos = 0;\n\tif(f->len < 22) goto done;\n\n\t\/\/ End-of-central-dir record usually starts 22 bytes from EOF. Try that first.\n\tsig = (u32)dbuf_getu32le(f, f->len - 22);\n\tif(sig == 0x06054b50U) {\n\t\t*foundpos = f->len - 22;\n\t\tretval = 1;\n\t\tgoto done;\n\t}\n\n\t\/\/ Search for the signature.\n\t\/\/ The end-of-central-directory record could theoretically appear anywhere\n\t\/\/ in the file. We'll follow Info-Zip\/UnZip's lead and search the last 66000\n\t\/\/ bytes.\n#define MAX_ZIP_EOCD_SEARCH 66000\n\tbuf_size = f->len;\n\tif(buf_size > MAX_ZIP_EOCD_SEARCH) buf_size = MAX_ZIP_EOCD_SEARCH;\n\n\tbuf = de_malloc(c, buf_size);\n\tbuf_offset = f->len - buf_size;\n\tdbuf_read(f, buf, buf_offset, buf_size);\n\n\tfor(i=buf_size-22; i>=0; i--) {\n\t\tif(buf[i]=='P' && buf[i+1]=='K' && buf[i+2]==5 && buf[i+3]==6) {\n\t\t\t*foundpos = buf_offset + i;\n\t\t\tretval = 1;\n\t\t\tgoto done;\n\t\t}\n\t}\n\ndone:\n\tde_free(c, buf);\n\treturn retval;\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":293945,"func":"ins_try_si(int c)\n{\n    pos_T\t*pos, old_pos;\n    char_u\t*ptr;\n    int\t\ti;\n    int\t\ttemp;\n\n    \/\/ do some very smart indenting when entering '{' or '}'\n    if (((did_si || can_si_back) && c == '{') || (can_si && c == '}'))\n    {\n\t\/\/ for '}' set indent equal to indent of line containing matching '{'\n\tif (c == '}' && (pos = findmatch(NULL, '{')) != NULL)\n\t{\n\t    old_pos = curwin->w_cursor;\n\t    \/\/ If the matching '{' has a ')' immediately before it (ignoring\n\t    \/\/ white-space), then line up with the start of the line\n\t    \/\/ containing the matching '(' if there is one.  This handles the\n\t    \/\/ case where an \"if (..\\n..) {\" statement continues over multiple\n\t    \/\/ lines -- webb\n\t    ptr = ml_get(pos->lnum);\n\t    i = pos->col;\n\t    if (i > 0)\t\t\/\/ skip blanks before '{'\n\t\twhile (--i > 0 && VIM_ISWHITE(ptr[i]))\n\t\t    ;\n\t    curwin->w_cursor.lnum = pos->lnum;\n\t    curwin->w_cursor.col = i;\n\t    if (ptr[i] == ')' && (pos = findmatch(NULL, '(')) != NULL)\n\t\tcurwin->w_cursor = *pos;\n\t    i = get_indent();\n\t    curwin->w_cursor = old_pos;\n\t    if (State & VREPLACE_FLAG)\n\t\tchange_indent(INDENT_SET, i, FALSE, NUL, TRUE);\n\t    else\n\t\t(void)set_indent(i, SIN_CHANGED);\n\t}\n\telse if (curwin->w_cursor.col > 0)\n\t{\n\t    \/\/ when inserting '{' after \"O\" reduce indent, but not\n\t    \/\/ more than indent of previous line\n\t    temp = TRUE;\n\t    if (c == '{' && can_si_back && curwin->w_cursor.lnum > 1)\n\t    {\n\t\told_pos = curwin->w_cursor;\n\t\ti = get_indent();\n\t\twhile (curwin->w_cursor.lnum > 1)\n\t\t{\n\t\t    ptr = skipwhite(ml_get(--(curwin->w_cursor.lnum)));\n\n\t\t    \/\/ ignore empty lines and lines starting with '#'.\n\t\t    if (*ptr != '#' && *ptr != NUL)\n\t\t\tbreak;\n\t\t}\n\t\tif (get_indent() >= i)\n\t\t    temp = FALSE;\n\t\tcurwin->w_cursor = old_pos;\n\t    }\n\t    if (temp)\n\t\tshift_line(TRUE, FALSE, 1, TRUE);\n\t}\n    }\n\n    \/\/ set indent of '#' always to 0\n    if (curwin->w_cursor.col > 0 && can_si && c == '#')\n    {\n\t\/\/ remember current indent for next line\n\told_indent = get_indent();\n\t(void)set_indent(0, SIN_CHANGED);\n    }\n\n    \/\/ Adjust ai_col, the char at this position can be deleted.\n    if (ai_col > curwin->w_cursor.col)\n\tai_col = curwin->w_cursor.col;\n}","target":0,"code_token_length":656,"total_token_length":892,"max_tokens_setting":1024}
+{"idx":513319,"func":"fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,\n               Ref_ptr_array ref_pointer_array)\n{\n  Item_outer_ref *ref;\n\n  \/*\n    Mark the references from  the inner_refs_list that are occurred in\n    the group by expressions. Those references will contain direct\n    references to the referred fields. The markers are set in \n    the found_in_group_by field of the references from the list.\n  *\/\n  List_iterator_fast <Item_outer_ref> ref_it(select->inner_refs_list);\n  for (ORDER *group= select->join->group_list; group;  group= group->next)\n  {\n    (*group->item)->walk(&Item::check_inner_refs_processor, TRUE, &ref_it);\n  } \n    \n  while ((ref= ref_it++))\n  {\n    bool direct_ref= false;\n    Item *item= ref->outer_ref;\n    Item **item_ref= ref->ref;\n    Item_ref *new_ref;\n    \/*\n      TODO: this field item already might be present in the select list.\n      In this case instead of adding new field item we could use an\n      existing one. The change will lead to less operations for copying fields,\n      smaller temporary tables and less data passed through filesort.\n    *\/\n    if (!ref_pointer_array.is_null() && !ref->found_in_select_list)\n    {\n      int el= all_fields.elements;\n      ref_pointer_array[el]= item;\n      \/* Add the field item to the select list of the current select. *\/\n      all_fields.push_front(item, thd->mem_root);\n      \/*\n        If it's needed reset each Item_ref item that refers this field with\n        a new reference taken from ref_pointer_array.\n      *\/\n      item_ref= &ref_pointer_array[el];\n    }\n\n    if (ref->in_sum_func)\n    {\n      Item_sum *sum_func;\n      if (ref->in_sum_func->nest_level > select->nest_level)\n        direct_ref= TRUE;\n      else\n      {\n        for (sum_func= ref->in_sum_func; sum_func &&\n             sum_func->aggr_level >= select->nest_level;\n             sum_func= sum_func->in_sum_func)\n        {\n          if (sum_func->aggr_level == select->nest_level)\n          {\n            direct_ref= TRUE;\n            break;\n          }\n        }\n      }\n    }\n    else if (ref->found_in_group_by)\n      direct_ref= TRUE;\n\n    new_ref= direct_ref ?\n              new (thd->mem_root) Item_direct_ref(thd, ref->context, item_ref, ref->table_name,\n                          ref->field_name, ref->alias_name_used) :\n              new (thd->mem_root) Item_ref(thd, ref->context, item_ref, ref->table_name,\n                          ref->field_name, ref->alias_name_used);\n    if (!new_ref)\n      return TRUE;\n    ref->outer_ref= new_ref;\n    ref->ref= &ref->outer_ref;\n\n    if (!ref->fixed && ref->fix_fields(thd, 0))\n      return TRUE;\n    thd->lex->used_tables|= item->used_tables();\n    thd->lex->current_select->select_list_tables|= item->used_tables();\n  }\n  return false;\n}","target":0,"code_token_length":691,"total_token_length":927,"max_tokens_setting":1024}
+{"idx":253548,"func":"static loff_t smb3_llseek(struct file *file, struct cifs_tcon *tcon, loff_t offset, int whence)\n{\n\tstruct cifsFileInfo *wrcfile, *cfile = file->private_data;\n\tstruct cifsInodeInfo *cifsi;\n\tstruct inode *inode;\n\tint rc = 0;\n\tstruct file_allocated_range_buffer in_data, *out_data = NULL;\n\tu32 out_data_len;\n\tunsigned int xid;\n\n\tif (whence != SEEK_HOLE && whence != SEEK_DATA)\n\t\treturn generic_file_llseek(file, offset, whence);\n\n\tinode = d_inode(cfile->dentry);\n\tcifsi = CIFS_I(inode);\n\n\tif (offset < 0 || offset >= i_size_read(inode))\n\t\treturn -ENXIO;\n\n\txid = get_xid();\n\t\/*\n\t * We need to be sure that all dirty pages are written as they\n\t * might fill holes on the server.\n\t * Note that we also MUST flush any written pages since at least\n\t * some servers (Windows2016) will not reflect recent writes in\n\t * QUERY_ALLOCATED_RANGES until SMB2_flush is called.\n\t *\/\n\twrcfile = find_writable_file(cifsi, FIND_WR_ANY);\n\tif (wrcfile) {\n\t\tfilemap_write_and_wait(inode->i_mapping);\n\t\tsmb2_flush_file(xid, tcon, &wrcfile->fid);\n\t\tcifsFileInfo_put(wrcfile);\n\t}\n\n\tif (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) {\n\t\tif (whence == SEEK_HOLE)\n\t\t\toffset = i_size_read(inode);\n\t\tgoto lseek_exit;\n\t}\n\n\tin_data.file_offset = cpu_to_le64(offset);\n\tin_data.length = cpu_to_le64(i_size_read(inode));\n\n\trc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,\n\t\t\tcfile->fid.volatile_fid,\n\t\t\tFSCTL_QUERY_ALLOCATED_RANGES, true,\n\t\t\t(char *)&in_data, sizeof(in_data),\n\t\t\tsizeof(struct file_allocated_range_buffer),\n\t\t\t(char **)&out_data, &out_data_len);\n\tif (rc == -E2BIG)\n\t\trc = 0;\n\tif (rc)\n\t\tgoto lseek_exit;\n\n\tif (whence == SEEK_HOLE && out_data_len == 0)\n\t\tgoto lseek_exit;\n\n\tif (whence == SEEK_DATA && out_data_len == 0) {\n\t\trc = -ENXIO;\n\t\tgoto lseek_exit;\n\t}\n\n\tif (out_data_len < sizeof(struct file_allocated_range_buffer)) {\n\t\trc = -EINVAL;\n\t\tgoto lseek_exit;\n\t}\n\tif (whence == SEEK_DATA) {\n\t\toffset = le64_to_cpu(out_data->file_offset);\n\t\tgoto lseek_exit;\n\t}\n\tif (offset < le64_to_cpu(out_data->file_offset))\n\t\tgoto lseek_exit;\n\n\toffset = le64_to_cpu(out_data->file_offset) + le64_to_cpu(out_data->length);\n\n lseek_exit:\n\tfree_xid(xid);\n\tkfree(out_data);\n\tif (!rc)\n\t\treturn vfs_setpos(file, offset, inode->i_sb->s_maxbytes);\n\telse\n\t\treturn rc;\n}","target":0,"code_token_length":676,"total_token_length":912,"max_tokens_setting":1024}
+{"idx":253723,"func":"static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst,\n\t\t\t     struct ccp_op *op, unsigned int block_size,\n\t\t\t     bool blocksize_op)\n{\n\tunsigned int sg_src_len, sg_dst_len, op_len;\n\n\t\/* The CCP can only DMA from\/to one address each per operation. This\n\t * requires that we find the smallest DMA area between the source\n\t * and destination. The resulting len values will always be <= UINT_MAX\n\t * because the dma length is an unsigned int.\n\t *\/\n\tsg_src_len = sg_dma_len(src->sg_wa.dma_sg) - src->sg_wa.sg_used;\n\tsg_src_len = min_t(u64, src->sg_wa.bytes_left, sg_src_len);\n\n\tif (dst) {\n\t\tsg_dst_len = sg_dma_len(dst->sg_wa.dma_sg) - dst->sg_wa.sg_used;\n\t\tsg_dst_len = min_t(u64, src->sg_wa.bytes_left, sg_dst_len);\n\t\top_len = min(sg_src_len, sg_dst_len);\n\t} else {\n\t\top_len = sg_src_len;\n\t}\n\n\t\/* The data operation length will be at least block_size in length\n\t * or the smaller of available sg room remaining for the source or\n\t * the destination\n\t *\/\n\top_len = max(op_len, block_size);\n\n\t\/* Unless we have to buffer data, there's no reason to wait *\/\n\top->soc = 0;\n\n\tif (sg_src_len < block_size) {\n\t\t\/* Not enough data in the sg element, so it\n\t\t * needs to be buffered into a blocksize chunk\n\t\t *\/\n\t\tint cp_len = ccp_fill_queue_buf(src);\n\n\t\top->soc = 1;\n\t\top->src.u.dma.address = src->dm_wa.dma.address;\n\t\top->src.u.dma.offset = 0;\n\t\top->src.u.dma.length = (blocksize_op) ? block_size : cp_len;\n\t} else {\n\t\t\/* Enough data in the sg element, but we need to\n\t\t * adjust for any previously copied data\n\t\t *\/\n\t\top->src.u.dma.address = sg_dma_address(src->sg_wa.dma_sg);\n\t\top->src.u.dma.offset = src->sg_wa.sg_used;\n\t\top->src.u.dma.length = op_len & ~(block_size - 1);\n\n\t\tccp_update_sg_workarea(&src->sg_wa, op->src.u.dma.length);\n\t}\n\n\tif (dst) {\n\t\tif (sg_dst_len < block_size) {\n\t\t\t\/* Not enough room in the sg element or we're on the\n\t\t\t * last piece of data (when using padding), so the\n\t\t\t * output needs to be buffered into a blocksize chunk\n\t\t\t *\/\n\t\t\top->soc = 1;\n\t\t\top->dst.u.dma.address = dst->dm_wa.dma.address;\n\t\t\top->dst.u.dma.offset = 0;\n\t\t\top->dst.u.dma.length = op->src.u.dma.length;\n\t\t} else {\n\t\t\t\/* Enough room in the sg element, but we need to\n\t\t\t * adjust for any previously used area\n\t\t\t *\/\n\t\t\top->dst.u.dma.address = sg_dma_address(dst->sg_wa.dma_sg);\n\t\t\top->dst.u.dma.offset = dst->sg_wa.sg_used;\n\t\t\top->dst.u.dma.length = op->src.u.dma.length;\n\t\t}\n\t}\n}","target":0,"code_token_length":739,"total_token_length":975,"max_tokens_setting":1024}
+{"idx":267922,"func":"void ogs_nas_5gs_imsi_to_bcd(\n    ogs_nas_5gs_mobile_identity_t *mobile_identity, char *imsi_bcd)\n{\n    ogs_nas_5gs_mobile_identity_suci_t *mobile_identity_suci = NULL;\n    ogs_plmn_id_t plmn_id;\n    char tmp[OGS_MAX_IMSI_BCD_LEN+1];\n    char *p, *last;\n\n    ogs_assert(mobile_identity);\n    ogs_assert(imsi_bcd);\n\n    p = imsi_bcd;\n    last = imsi_bcd + OGS_MAX_IMSI_BCD_LEN + 1;\n\n    mobile_identity_suci =\n        (ogs_nas_5gs_mobile_identity_suci_t *)mobile_identity->buffer;\n    ogs_assert(mobile_identity_suci);\n\n    ogs_nas_to_plmn_id(&plmn_id, &mobile_identity_suci->nas_plmn_id);\n    if (ogs_plmn_id_mnc_len(&plmn_id) == 2)\n        p = ogs_slprintf(p, last, \"%03d%02d\",\n                ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));\n    else \n        p = ogs_slprintf(p, last, \"%03d%03d\",\n                ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));\n\n    ogs_assert(mobile_identity->length > 8);\n    ogs_buffer_to_bcd(mobile_identity_suci->scheme_output,\n            mobile_identity->length - 8, tmp);\n    p = ogs_slprintf(p, last, \"%s\", tmp);\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":231740,"func":"bool validateAndUpdateSourceToken(\n    QuicServerConnectionState& conn,\n    std::vector<folly::IPAddress> sourceAddresses) {\n  DCHECK(conn.peerAddress.isInitialized());\n  bool foundMatch = false;\n  for (int ii = sourceAddresses.size() - 1; ii >= 0; --ii) {\n    \/\/ TODO T33014230 subnet matching\n    if (conn.peerAddress.getIPAddress() == sourceAddresses[ii]) {\n      foundMatch = true;\n      \/\/ If peer address is found in the token, move the element to the end\n      \/\/ of vector to increase its favorability.\n      sourceAddresses.erase(sourceAddresses.begin() + ii);\n      sourceAddresses.push_back(conn.peerAddress.getIPAddress());\n    }\n  }\n  conn.sourceTokenMatching = foundMatch;\n  bool acceptZeroRtt = foundMatch;\n  if (!foundMatch) {\n    \/\/ Add peer address to token for next resumption\n    if (sourceAddresses.size() >= kMaxNumTokenSourceAddresses) {\n      sourceAddresses.erase(sourceAddresses.begin());\n    }\n    sourceAddresses.push_back(conn.peerAddress.getIPAddress());\n\n    switch (conn.transportSettings.zeroRttSourceTokenMatchingPolicy) {\n      case ZeroRttSourceTokenMatchingPolicy::REJECT_IF_NO_EXACT_MATCH:\n        acceptZeroRtt = false;\n        break;\n      case ZeroRttSourceTokenMatchingPolicy::LIMIT_IF_NO_EXACT_MATCH:\n        acceptZeroRtt = true;\n        conn.writableBytesLimit =\n            conn.transportSettings.limitedCwndInMss * conn.udpSendPacketLen;\n        break;\n    }\n  }\n  \/\/ Save the source token so that it can be written to client via NST later\n  conn.tokenSourceAddresses = std::move(sourceAddresses);\n\n  return acceptZeroRtt;\n}","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":482496,"func":"lou_free(void) {\n\tTranslationTableChainEntry *currentEntry;\n\tTranslationTableChainEntry *previousEntry;\n\tlou_logEnd();\n\tif (translationTableChain != NULL) {\n\t\tcurrentEntry = translationTableChain;\n\t\twhile (currentEntry) {\n\t\t\tfreeTranslationTable(currentEntry->table);\n\t\t\tpreviousEntry = currentEntry;\n\t\t\tcurrentEntry = currentEntry->next;\n\t\t\tfree(previousEntry);\n\t\t}\n\t\ttranslationTableChain = NULL;\n\t}\n\tif (typebuf != NULL) free(typebuf);\n\ttypebuf = NULL;\n\tif (wordBuffer != NULL) free(wordBuffer);\n\twordBuffer = NULL;\n\tif (emphasisBuffer != NULL) free(emphasisBuffer);\n\temphasisBuffer = NULL;\n\tsizeTypebuf = 0;\n\tif (destSpacing != NULL) free(destSpacing);\n\tdestSpacing = NULL;\n\tsizeDestSpacing = 0;\n\t{\n\t\tint k;\n\t\tfor (k = 0; k < MAXPASSBUF; k++) {\n\t\t\tif (passbuf[k] != NULL) free(passbuf[k]);\n\t\t\tpassbuf[k] = NULL;\n\t\t\tsizePassbuf[k] = 0;\n\t\t}\n\t}\n\tif (posMapping1 != NULL) free(posMapping1);\n\tposMapping1 = NULL;\n\tsizePosMapping1 = 0;\n\tif (posMapping2 != NULL) free(posMapping2);\n\tposMapping2 = NULL;\n\tsizePosMapping2 = 0;\n\tif (posMapping3 != NULL) free(posMapping3);\n\tposMapping3 = NULL;\n\tsizePosMapping3 = 0;\n\topcodeLengths[0] = 0;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":204534,"func":"stl_remove_degenerate(stl_file *stl, int facet) {\n  int edge1;\n  int edge2;\n  int edge3;\n  int neighbor1;\n  int neighbor2;\n  int neighbor3;\n  int vnot1;\n  int vnot2;\n  int vnot3;\n\n  if (stl->error) return;\n\n  if(   !memcmp(&stl->facet_start[facet].vertex[0],\n                &stl->facet_start[facet].vertex[1], sizeof(stl_vertex))\n        && !memcmp(&stl->facet_start[facet].vertex[1],\n                   &stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) {\n    \/* all 3 vertices are equal.  Just remove the facet.  I don't think*\/\n    \/* this is really possible, but just in case... *\/\n    printf(\"removing a facet in stl_remove_degenerate\\n\");\n\n    stl_remove_facet(stl, facet);\n    return;\n  }\n\n  if(!memcmp(&stl->facet_start[facet].vertex[0],\n             &stl->facet_start[facet].vertex[1], sizeof(stl_vertex))) {\n    edge1 = 1;\n    edge2 = 2;\n    edge3 = 0;\n  } else if(!memcmp(&stl->facet_start[facet].vertex[1],\n                    &stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) {\n    edge1 = 0;\n    edge2 = 2;\n    edge3 = 1;\n  } else if(!memcmp(&stl->facet_start[facet].vertex[2],\n                    &stl->facet_start[facet].vertex[0], sizeof(stl_vertex))) {\n    edge1 = 0;\n    edge2 = 1;\n    edge3 = 2;\n  } else {\n    \/* No degenerate. Function shouldn't have been called. *\/\n    return;\n  }\n  neighbor1 = stl->neighbors_start[facet].neighbor[edge1];\n  neighbor2 = stl->neighbors_start[facet].neighbor[edge2];\n\n  if(neighbor1 == -1) {\n    stl_update_connects_remove_1(stl, neighbor2);\n  }\n  if(neighbor2 == -1) {\n    stl_update_connects_remove_1(stl, neighbor1);\n  }\n\n\n  neighbor3 = stl->neighbors_start[facet].neighbor[edge3];\n  vnot1 = stl->neighbors_start[facet].which_vertex_not[edge1];\n  vnot2 = stl->neighbors_start[facet].which_vertex_not[edge2];\n  vnot3 = stl->neighbors_start[facet].which_vertex_not[edge3];\n\n  if(neighbor1 != -1){\n    stl->neighbors_start[neighbor1].neighbor[(vnot1 + 1) % 3] = neighbor2;\n    stl->neighbors_start[neighbor1].which_vertex_not[(vnot1 + 1) % 3] = vnot2;\n  }\n  if(neighbor2 != -1){\n    stl->neighbors_start[neighbor2].neighbor[(vnot2 + 1) % 3] = neighbor1;\n    stl->neighbors_start[neighbor2].which_vertex_not[(vnot2 + 1) % 3] = vnot1;\n  }\n\n  stl_remove_facet(stl, facet);\n\n  if(neighbor3 != -1) {\n    stl_update_connects_remove_1(stl, neighbor3);\n    stl->neighbors_start[neighbor3].neighbor[(vnot3 + 1) % 3] = -1;\n  }\n}","target":1,"code_token_length":776,"total_token_length":1012,"max_tokens_setting":1024}
+{"idx":241070,"func":"static int format_peers(char **pdata, unsigned int *len)\n{\n\tstruct booth_site *s;\n\tchar *data, *cp;\n\tchar time_str[64];\n\tint i, alloc;\n\n\t*pdata = NULL;\n\t*len = 0;\n\n\talloc = booth_conf->site_count * (BOOTH_NAME_LEN + 256);\n\tdata = malloc(alloc);\n\tif (!data)\n\t\treturn -ENOMEM;\n\n\tcp = data;\n\tforeach_node(i, s) {\n\t\tif (s == local)\n\t\t\tcontinue;\n\t\tstrftime(time_str, sizeof(time_str), \"%F %T\",\n\t\t\tlocaltime(&s->last_recv));\n\t\tcp += snprintf(cp,\n\t\t\t\talloc - (cp - data),\n\t\t\t\t\"%-12s %s, last recv: %s\\n\",\n\t\t\t\ttype_to_string(s->type),\n\t\t\t\ts->addr_string,\n\t\t\t\ttime_str);\n\t\tcp += snprintf(cp,\n\t\t\t\talloc - (cp - data),\n\t\t\t\t\"\\tSent pkts:%u error:%u resends:%u\\n\",\n\t\t\t\ts->sent_cnt,\n\t\t\t\ts->sent_err_cnt,\n\t\t\t\ts->resend_cnt);\n\t\tcp += snprintf(cp,\n\t\t\t\talloc - (cp - data),\n\t\t\t\t\"\\tRecv pkts:%u error:%u authfail:%u invalid:%u\\n\\n\",\n\t\t\t\ts->recv_cnt,\n\t\t\t\ts->recv_err_cnt,\n\t\t\t\ts->sec_cnt,\n\t\t\t\ts->invalid_cnt);\n\t\tif (alloc - (cp - data) <= 0) {\n\t\t\tfree(data);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\n\t*pdata = data;\n\t*len = cp - data;\n\n\treturn 0;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":233814,"func":"const char *fmtutil_get_windows_charset_name(u8 cs)\n{\n\tstruct csname_struct { u8 id; const char *name; };\n\tstatic const struct csname_struct csname_arr[] = {\n\t\t{0x00, \"ANSI\"},\n\t\t{0x01, \"default\"},\n\t\t{0x02, \"symbol\"},\n\t\t{0x4d, \"Mac\"},\n\t\t{0x80, \"Shift-JIS\"},\n\t\t{0x81, \"Hangul\"},\n\t\t{0x82, \"Johab\"},\n\t\t{0x86, \"GB2312\"},\n\t\t{0x88, \"BIG5\"},\n\t\t{0xa1, \"Greek\"},\n\t\t{0xa2, \"Turkish\"},\n\t\t{0xa3, \"Vietnamese\"},\n\t\t{0xb1, \"Hebrew\"},\n\t\t{0xb2, \"Arabic\"},\n\t\t{0xba, \"Baltic\"},\n\t\t{0xcc, \"Russian\"},\n\t\t{0xde, \"Thai\"},\n\t\t{0xee, \"Eastern Europe\"},\n\t\t{0xff, \"OEM\"}\n\t};\n\tsize_t i;\n\n\tfor(i=0; i<DE_ARRAYCOUNT(csname_arr); i++) {\n\t\tif(cs==csname_arr[i].id) return csname_arr[i].name;\n\t}\n\treturn \"?\";\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":206665,"func":"static void parse_relocation_info(struct MACH0_(obj_t) *bin, RSkipList *relocs, ut32 offset, ut32 num) {\n\tif (!num || !offset || (st32)num < 0) {\n\t\treturn;\n\t}\n\n\tut64 total_size = num * sizeof (struct relocation_info);\n\tif (offset > bin->size) {\n\t\treturn;\n\t}\n\tif (total_size > bin->size) {\n\t\ttotal_size = bin->size - offset;\n\t\tnum = total_size \/= sizeof (struct relocation_info);\n\t}\n\tstruct relocation_info *info = calloc (num, sizeof (struct relocation_info));\n\tif (!info) {\n\t\treturn;\n\t}\n\n\tif (r_buf_read_at (bin->b, offset, (ut8 *) info, total_size) < total_size) {\n\t\tfree (info);\n\t\treturn;\n\t}\n\n\tsize_t i;\n\tfor (i = 0; i < num; i++) {\n\t\tstruct relocation_info a_info = info[i];\n\t\tut32 sym_num = a_info.r_symbolnum;\n\t\tif (sym_num > bin->nsymtab) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tut32 stridx = bin->symtab[sym_num].n_strx;\n\t\tchar *sym_name = get_name (bin, stridx, false);\n\t\tif (!sym_name) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tstruct reloc_t *reloc = R_NEW0 (struct reloc_t);\n\t\tif (!reloc) {\n\t\t\tfree (info);\n\t\t\tfree (sym_name);\n\t\t\treturn;\n\t\t}\n\n\t\treloc->addr = offset_to_vaddr (bin, a_info.r_address);\n\t\treloc->offset = a_info.r_address;\n\t\treloc->ord = sym_num;\n\t\treloc->type = a_info.r_type; \/\/ enum RelocationInfoType\n\t\treloc->external = a_info.r_extern;\n\t\treloc->pc_relative = a_info.r_pcrel;\n\t\treloc->size = a_info.r_length;\n\t\tr_str_ncpy (reloc->name, sym_name, sizeof (reloc->name) - 1);\n\t\tr_skiplist_insert (relocs, reloc);\n\t\tfree (sym_name);\n\t}\n\tfree (info);\n}","target":1,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":514317,"func":"bool unsafe_key_update(List<TABLE_LIST> leaves, table_map tables_for_update)\n{\n  List_iterator_fast<TABLE_LIST> it(leaves), it2(leaves);\n  TABLE_LIST *tl, *tl2;\n\n  while ((tl= it++))\n  {\n    if (!tl->is_jtbm() && (tl->table->map & tables_for_update))\n    {\n      TABLE *table1= tl->table;\n      bool primkey_clustered= (table1->file->primary_key_is_clustered() &&\n                               table1->s->primary_key != MAX_KEY);\n\n      bool table_partitioned= false;\n#ifdef WITH_PARTITION_STORAGE_ENGINE\n      table_partitioned= (table1->part_info != NULL);\n#endif\n\n      if (!table_partitioned && !primkey_clustered)\n        continue;\n\n      it2.rewind();\n      while ((tl2= it2++))\n      {\n        if (tl2->is_jtbm())\n          continue;\n        \/*\n          Look at \"next\" tables only since all previous tables have\n          already been checked\n        *\/\n        TABLE *table2= tl2->table;\n        if (tl2 != tl &&\n            table2->map & tables_for_update && table1->s == table2->s)\n        {\n          \/\/ A table is updated through two aliases\n          if (table_partitioned &&\n              (partition_key_modified(table1, table1->write_set) ||\n               partition_key_modified(table2, table2->write_set)))\n          {\n            \/\/ Partitioned key is updated\n            my_error(ER_MULTI_UPDATE_KEY_CONFLICT, MYF(0),\n                     tl->top_table()->alias.str,\n                     tl2->top_table()->alias.str);\n            return true;\n          }\n\n          if (primkey_clustered)\n          {\n            \/\/ The primary key can cover multiple columns\n            KEY key_info= table1->key_info[table1->s->primary_key];\n            KEY_PART_INFO *key_part= key_info.key_part;\n            KEY_PART_INFO *key_part_end= key_part + key_info.user_defined_key_parts;\n\n            for (;key_part != key_part_end; ++key_part)\n            {\n              if (bitmap_is_set(table1->write_set, key_part->fieldnr-1) ||\n                  bitmap_is_set(table2->write_set, key_part->fieldnr-1))\n              {\n                \/\/ Clustered primary key is updated\n                my_error(ER_MULTI_UPDATE_KEY_CONFLICT, MYF(0),\n                         tl->top_table()->alias.str,\n                         tl2->top_table()->alias.str);\n                return true;\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n  return false;\n}","target":0,"code_token_length":553,"total_token_length":789,"max_tokens_setting":1024}
+{"idx":498619,"func":"read_line (FILE         *fp,\n           guchar       *row,\n           guchar       *buf,\n           tga_info     *info,\n           gint          bpp,\n           const guchar *convert_cmap)\n{\n  if (info->imageCompression == TGA_COMP_RLE)\n    {\n      rle_read (fp, buf, info);\n    }\n  else\n    {\n      fread (buf, info->bytes, info->width, fp);\n    }\n\n  if (info->flipHoriz)\n    {\n      flip_line (buf, info);\n    }\n\n  if (info->imageType == TGA_TYPE_COLOR)\n    {\n      if (info->bpp == 16 || info->bpp == 15)\n        {\n          upsample (row, buf, info->width, info->bytes, info->alphaBits);\n        }\n      else\n        {\n          bgr2rgb (row, buf, info->width, info->bytes, info->alphaBits);\n        }\n    }\n  else if (convert_cmap)\n    {\n      gboolean has_alpha = (info->alphaBits > 0);\n\n      apply_colormap (row, buf, info->width, convert_cmap, has_alpha,\n                      info->colorMapIndex);\n    }\n  else if (info->imageType == TGA_TYPE_MAPPED)\n    {\n      g_assert(bpp == 1);\n\n      apply_index (row, buf, info->width, info->colorMapIndex);\n    }\n  else\n    {\n      memcpy (row, buf, info->width * bpp);\n    }\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":439150,"func":"ModuleExport size_t RegisterICONImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=SetMagickInfo(\"CUR\");\n  entry->decoder=(DecodeImageHandler *) ReadICONImage;\n  entry->encoder=(EncodeImageHandler *) WriteICONImage;\n  entry->adjoin=MagickFalse;\n  entry->seekable_stream=MagickTrue;\n  entry->description=ConstantString(\"Microsoft icon\");\n  entry->module=ConstantString(\"ICON\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"ICO\");\n  entry->decoder=(DecodeImageHandler *) ReadICONImage;\n  entry->encoder=(EncodeImageHandler *) WriteICONImage;\n  entry->adjoin=MagickTrue;\n  entry->seekable_stream=MagickTrue;\n  entry->description=ConstantString(\"Microsoft icon\");\n  entry->module=ConstantString(\"ICON\");\n  (void) RegisterMagickInfo(entry);\n  entry=SetMagickInfo(\"ICON\");\n  entry->decoder=(DecodeImageHandler *) ReadICONImage;\n  entry->encoder=(EncodeImageHandler *) WriteICONImage;\n  entry->adjoin=MagickFalse;\n  entry->seekable_stream=MagickTrue;\n  entry->description=ConstantString(\"Microsoft icon\");\n  entry->module=ConstantString(\"ICON\");\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":413582,"func":"static void add_single_addr_xrefs(RCore *core, ut64 addr, RGraph *graph) {\n\tr_return_if_fail (graph);\n\tRFlagItem *f = r_flag_get_at (core->flags, addr, false);\n\tchar *me = (f && f->offset == addr)\n\t\t? r_str_new (f->name)\n\t\t: r_str_newf (\"0x%\" PFMT64x, addr);\n\n\tRGraphNode *curr_node = r_graph_add_node_info (graph, me, NULL, addr);\n\tR_FREE (me);\n\tif (!curr_node) {\n\t\treturn;\n\t}\n\tRListIter *iter;\n\tRAnalRef *ref;\n\tRList *list = r_anal_xrefs_get (core->anal, addr);\n\tr_list_foreach (list, iter, ref) {\n\t\tRFlagItem *item = r_flag_get_i (core->flags, ref->addr);\n\t\tchar *src = item? r_str_new (item->name): r_str_newf (\"0x%08\" PFMT64x, ref->addr);\n\t\tRGraphNode *reference_from = r_graph_add_node_info (graph, src, NULL, ref->addr);\n\t\tfree (src);\n\t\tr_graph_add_edge (graph, reference_from, curr_node);\n\t}\n\tr_list_free (list);\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":202392,"func":"static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, unsigned int windows_size)\n{\n\tunsigned int u = 0;\n\tLineContribType *res;\n\tint overflow_error = 0;\n\n\tres = (LineContribType *) gdMalloc(sizeof(LineContribType));\n\tif (!res) {\n\t\treturn NULL;\n\t}\n\tres->WindowSize = windows_size;\n\tres->LineLength = line_length;\n\tif (overflow2(line_length, sizeof(ContributionType))) {\n\t\tgdFree(res);\n\t\treturn NULL;\n\t}\n\tres->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));\n\tif (res->ContribRow == NULL) {\n\t\tgdFree(res);\n\t\treturn NULL;\n\t}\n\tfor (u = 0 ; u < line_length ; u++) {\n\t\tif (overflow2(windows_size, sizeof(double))) {\n\t\t\toverflow_error = 1;\n\t\t} else {\n\t\t\tres->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));\n\t\t}\n\t\tif (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {\n\t\t\tu--;\n\t\t\twhile (u >= 0) {\n\t\t\t\tgdFree(res->ContribRow[u].Weights);\n\t\t\t\tu--;\n\t\t\t}\n\t\t\treturn NULL;\n\t\t}\n\t}\n\treturn res;\n}","target":1,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":282885,"func":"int rsi_band_check(struct rsi_common *common,\n\t\t   struct ieee80211_channel *curchan)\n{\n\tstruct rsi_hw *adapter = common->priv;\n\tstruct ieee80211_hw *hw = adapter->hw;\n\tu8 prev_bw = common->channel_width;\n\tu8 prev_ep = common->endpoint;\n\tint status = 0;\n\n\tif (common->band != curchan->band) {\n\t\tcommon->rf_reset = 1;\n\t\tcommon->band = curchan->band;\n\t}\n\n\tif ((hw->conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) ||\n\t    (hw->conf.chandef.width == NL80211_CHAN_WIDTH_20))\n\t\tcommon->channel_width = BW_20MHZ;\n\telse\n\t\tcommon->channel_width = BW_40MHZ;\n\n\tif (common->band == NL80211_BAND_2GHZ) {\n\t\tif (common->channel_width)\n\t\t\tcommon->endpoint = EP_2GHZ_40MHZ;\n\t\telse\n\t\t\tcommon->endpoint = EP_2GHZ_20MHZ;\n\t} else {\n\t\tif (common->channel_width)\n\t\t\tcommon->endpoint = EP_5GHZ_40MHZ;\n\t\telse\n\t\t\tcommon->endpoint = EP_5GHZ_20MHZ;\n\t}\n\n\tif (common->endpoint != prev_ep) {\n\t\tstatus = rsi_program_bb_rf(common);\n\t\tif (status)\n\t\t\treturn status;\n\t}\n\n\tif (common->channel_width != prev_bw) {\n\t\tif (adapter->device_model == RSI_DEV_9116)\n\t\t\tstatus = rsi_load_9116_bootup_params(common);\n\t\telse\n\t\t\tstatus = rsi_load_bootup_params(common);\n\t\tif (status)\n\t\t\treturn status;\n\n\t\tstatus = rsi_load_radio_caps(common);\n\t\tif (status)\n\t\t\treturn status;\n\t}\n\n\treturn status;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":430469,"func":"gopherSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int xerrno, void *data)\n{\n    GopherStateData *gopherState = (GopherStateData *) data;\n    StoreEntry *entry = gopherState->entry;\n    debugs(10, 5, HERE << conn << \" size: \" << size << \" errflag: \" << errflag);\n\n    if (size > 0) {\n        fd_bytes(conn->fd, size, FD_WRITE);\n        statCounter.server.all.kbytes_out += size;\n        statCounter.server.other.kbytes_out += size;\n    }\n\n    if (!entry->isAccepting()) {\n        debugs(10, 3, \"terminating due to bad \" << *entry);\n        \/\/ TODO: Do not abuse connection for triggering cleanup.\n        gopherState->serverConn->close();\n        return;\n    }\n\n    if (errflag) {\n        ErrorState *err;\n        err = new ErrorState(ERR_WRITE_ERROR, Http::scServiceUnavailable, gopherState->fwd->request);\n        err->xerrno = xerrno;\n        err->port = gopherState->fwd->request->url.port();\n        err->url = xstrdup(entry->url());\n        gopherState->fwd->fail(err);\n        gopherState->serverConn->close();\n        return;\n    }\n\n    \/*\n     * OK. We successfully reach remote site.  Start MIME typing\n     * stuff.  Do it anyway even though request is not HTML type.\n     *\/\n    entry->buffer();\n\n    gopherMimeCreate(gopherState);\n\n    switch (gopherState->type_id) {\n\n    case GOPHER_DIRECTORY:\n        \/* we got to convert it first *\/\n        gopherState->conversion = GopherStateData::HTML_DIR;\n        gopherState->HTML_header_added = 0;\n        break;\n\n    case GOPHER_INDEX:\n        \/* we got to convert it first *\/\n        gopherState->conversion = GopherStateData::HTML_INDEX_RESULT;\n        gopherState->HTML_header_added = 0;\n        break;\n\n    case GOPHER_CSO:\n        \/* we got to convert it first *\/\n        gopherState->conversion = GopherStateData::HTML_CSO_RESULT;\n        gopherState->cso_recno = 0;\n        gopherState->HTML_header_added = 0;\n        break;\n\n    default:\n        gopherState->conversion = GopherStateData::NORMAL;\n        entry->flush();\n    }\n\n    \/* Schedule read reply. *\/\n    AsyncCall::Pointer call =  commCbCall(5,5, \"gopherReadReply\",\n                                          CommIoCbPtrFun(gopherReadReply, gopherState));\n    entry->delayAwareRead(conn, gopherState->replybuf, BUFSIZ, call);\n}","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":223461,"func":"static SLJIT_INLINE PCRE2_SPTR set_then_offsets(compiler_common *common, PCRE2_SPTR cc, sljit_u8 *current_offset)\n{\nPCRE2_SPTR end = bracketend(cc);\nBOOL has_alternatives = cc[GET(cc, 1)] == OP_ALT;\n\n\/* Assert captures then. *\/\nif (*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NA)\n  current_offset = NULL;\n\/* Conditional block does not. *\/\nif (*cc == OP_COND || *cc == OP_SCOND)\n  has_alternatives = FALSE;\n\ncc = next_opcode(common, cc);\nif (has_alternatives)\n  current_offset = common->then_offsets + (cc - common->start);\n\nwhile (cc < end)\n  {\n  if ((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NA) || (*cc >= OP_ONCE && *cc <= OP_SCOND))\n    cc = set_then_offsets(common, cc, current_offset);\n  else\n    {\n    if (*cc == OP_ALT && has_alternatives)\n      current_offset = common->then_offsets + (cc + 1 + LINK_SIZE - common->start);\n    if (*cc >= OP_THEN && *cc <= OP_THEN_ARG && current_offset != NULL)\n      *current_offset = 1;\n    cc = next_opcode(common, cc);\n    }\n  }\n\nreturn end;\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":309848,"func":"PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch)\n{\n    if (!auto_right_margin) {\n\t\/* we can put the char directly *\/\n\tPutAttrChar(NCURSES_SP_ARGx ch);\n    } else if (enter_am_mode && exit_am_mode) {\n\t\/* we can suppress automargin *\/\n\tNCURSES_PUTP2(\"exit_am_mode\", exit_am_mode);\n\n\tPutAttrChar(NCURSES_SP_ARGx ch);\n\tSP_PARM->_curscol--;\n\tposition_check(NCURSES_SP_ARGx\n\t\t       SP_PARM->_cursrow,\n\t\t       SP_PARM->_curscol,\n\t\t       \"exit_am_mode\");\n\n\tNCURSES_PUTP2(\"enter_am_mode\", enter_am_mode);\n    } else if ((enter_insert_mode && exit_insert_mode)\n\t       || insert_character || parm_ich) {\n\tGoTo(NCURSES_SP_ARGx\n\t     screen_lines(SP_PARM) - 1,\n\t     screen_columns(SP_PARM) - 2);\n\tPutAttrChar(NCURSES_SP_ARGx ch);\n\tGoTo(NCURSES_SP_ARGx\n\t     screen_lines(SP_PARM) - 1,\n\t     screen_columns(SP_PARM) - 2);\n\tInsStr(NCURSES_SP_ARGx\n\t       NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text +\n\t       screen_columns(SP_PARM) - 2, 1);\n    }\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":220463,"func":"Status BuildXlaCompilationCache(DeviceBase* device, FunctionLibraryRuntime* flr,\n                                const XlaPlatformInfo& platform_info,\n                                XlaCompilationCache** cache) {\n  if (platform_info.xla_device_metadata()) {\n    *cache = new XlaCompilationCache(\n        platform_info.xla_device_metadata()->client(),\n        platform_info.xla_device_metadata()->jit_device_type());\n    return Status::OK();\n  }\n\n  auto platform =\n      se::MultiPlatformManager::PlatformWithId(platform_info.platform_id());\n  if (!platform.ok()) {\n    return platform.status();\n  }\n\n  StatusOr<xla::Compiler*> compiler_for_platform =\n      xla::Compiler::GetForPlatform(platform.ValueOrDie());\n  if (!compiler_for_platform.ok()) {\n    \/\/ In some rare cases (usually in unit tests with very small clusters) we\n    \/\/ may end up transforming an XLA cluster with at least one GPU operation\n    \/\/ (which would normally force the cluster to be compiled using XLA:GPU)\n    \/\/ into an XLA cluster with no GPU operations (i.e. containing only CPU\n    \/\/ operations).  Such a cluster can fail compilation (in way that\n    \/\/ MarkForCompilation could not have detected) if the CPU JIT is not linked\n    \/\/ in.\n    \/\/\n    \/\/ So bail out of _XlaCompile in this case, and let the executor handle the\n    \/\/ situation for us.\n    const Status& status = compiler_for_platform.status();\n    if (status.code() == error::NOT_FOUND) {\n      return errors::Unimplemented(\"Could not find compiler for platform \",\n                                   platform.ValueOrDie()->Name(), \": \",\n                                   status.ToString());\n    }\n  }\n\n  xla::LocalClientOptions client_options;\n  client_options.set_platform(platform.ValueOrDie());\n  client_options.set_intra_op_parallelism_threads(\n      device->tensorflow_cpu_worker_threads()->num_threads);\n\n  if (flr->config_proto()) {\n    string allowed_gpus =\n        flr->config_proto()->gpu_options().visible_device_list();\n    TF_ASSIGN_OR_RETURN(absl::optional<std::set<int>> gpu_ids,\n                        ParseVisibleDeviceList(allowed_gpus));\n    client_options.set_allowed_devices(gpu_ids);\n  }\n\n  auto client = xla::ClientLibrary::GetOrCreateLocalClient(client_options);\n  if (!client.ok()) {\n    return client.status();\n  }\n  const XlaOpRegistry::DeviceRegistration* registration;\n  if (!XlaOpRegistry::GetCompilationDevice(platform_info.device_type().type(),\n                                           ®istration)) {\n    return errors::InvalidArgument(\"No JIT device registered for \",\n                                   platform_info.device_type().type());\n  }\n  *cache = new XlaCompilationCache(\n      client.ValueOrDie(), DeviceType(registration->compilation_device_name));\n  return Status::OK();\n}","target":0,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":264657,"func":"static GF_Err BM_ParseGlobalQuantizer(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)\n{\n\tGF_Node *node;\n\tGF_Command *com;\n\tGF_CommandField *inf;\n\tnode = gf_bifs_dec_node(codec, bs, NDT_SFWorldNode);\n\tif (!node) return GF_NON_COMPLIANT_BITSTREAM;\n\n\t\/*reset global QP*\/\n\tif (codec->scenegraph->global_qp) {\n\t\tgf_node_unregister(codec->scenegraph->global_qp, NULL);\n\t}\n\tcodec->ActiveQP = NULL;\n\tcodec->scenegraph->global_qp = NULL;\n\n\tif (gf_node_get_tag(node) != TAG_MPEG4_QuantizationParameter) {\n\t\t\/\/if node was just created (num_instances == 0), unregister\n\t\t\/\/otherwise (USE node) don't do anything\n\t\tif (!node->sgprivate->num_instances) {\n\t\t\tnode->sgprivate->num_instances = 1;\n\t\t\tgf_node_unregister(node, NULL);\n\t\t}\n\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t}\n\n\t\/*register global QP*\/\n\tcodec->ActiveQP = (M_QuantizationParameter *) node;\n\tcodec->ActiveQP->isLocal = 0;\n\tcodec->scenegraph->global_qp = node;\n\n\t\/*register TWICE: once for the command, and for the scenegraph globalQP*\/\n\tgf_node_unregister(node, NULL);\n\tgf_node_unregister(node, NULL);\n\n\tcom = gf_sg_command_new(codec->current_graph, GF_SG_GLOBAL_QUANTIZER);\n\tinf = gf_sg_command_field_new(com);\n\tinf->new_node = node;\n\tinf->field_ptr = &inf->new_node;\n\tinf->fieldType = GF_SG_VRML_SFNODE;\n\tgf_list_add(com_list, com);\n\treturn GF_OK;\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":233815,"func":"void fmtutil_handle_id3(deark *c, dbuf *f, struct de_id3info *id3i,\n\tunsigned int flags)\n{\n\ti64 id3v1pos = 0;\n\tint look_for_id3v1;\n\n\tde_zeromem(id3i, sizeof(struct de_id3info));\n\tid3i->main_start = 0;\n\tid3i->main_end = f->len;\n\n\tid3i->has_id3v2 = !dbuf_memcmp(f, 0, \"ID3\", 3);\n\tif(id3i->has_id3v2) {\n\t\tde_module_params id3v2mparams;\n\n\t\tde_dbg(c, \"ID3v2 data at %d\", 0);\n\t\tde_dbg_indent(c, 1);\n\t\tde_zeromem(&id3v2mparams, sizeof(de_module_params));\n\t\tid3v2mparams.in_params.codes = \"I\";\n\t\tde_run_module_by_id_on_slice(c, \"id3\", &id3v2mparams, f, 0, f->len);\n\t\tde_dbg_indent(c, -1);\n\t\tid3i->main_start += id3v2mparams.out_params.int64_1;\n\t}\n\n\tlook_for_id3v1 = 1;\n\tif(look_for_id3v1) {\n\t\tid3v1pos = f->len-128;\n\t\tif(!dbuf_memcmp(f, id3v1pos, \"TAG\", 3)) {\n\t\t\tid3i->has_id3v1 = 1;\n\t\t}\n\t}\n\n\tif(id3i->has_id3v1) {\n\t\tde_module_params id3v1mparams;\n\n\t\tde_dbg(c, \"ID3v1 data at %\"I64_FMT, id3v1pos);\n\t\tde_dbg_indent(c, 1);\n\t\tde_zeromem(&id3v1mparams, sizeof(de_module_params));\n\t\tid3v1mparams.in_params.codes = \"1\";\n\t\tde_run_module_by_id_on_slice(c, \"id3\", &id3v1mparams, f, id3v1pos, 128);\n\t\tde_dbg_indent(c, -1);\n\t\tid3i->main_end = id3v1pos;\n\t}\n}","target":0,"code_token_length":487,"total_token_length":723,"max_tokens_setting":1024}
+{"idx":353171,"func":"SplashPath SplashOutputDev::convertPath(GfxState *state, GfxPath *path,\n\t\t\t\t\t bool dropEmptySubpaths) {\n  SplashPath sPath;\n  GfxSubpath *subpath;\n  int n, i, j;\n\n  n = dropEmptySubpaths ? 1 : 0;\n  for (i = 0; i < path->getNumSubpaths(); ++i) {\n    subpath = path->getSubpath(i);\n    if (subpath->getNumPoints() > n) {\n      sPath.reserve(subpath->getNumPoints() + 1);\n      sPath.moveTo((SplashCoord)subpath->getX(0),\n\t\t    (SplashCoord)subpath->getY(0));\n      j = 1;\n      while (j < subpath->getNumPoints()) {\n\tif (subpath->getCurve(j)) {\n\t  sPath.curveTo((SplashCoord)subpath->getX(j),\n\t\t\t (SplashCoord)subpath->getY(j),\n\t\t\t (SplashCoord)subpath->getX(j+1),\n\t\t\t (SplashCoord)subpath->getY(j+1),\n\t\t\t (SplashCoord)subpath->getX(j+2),\n\t\t\t (SplashCoord)subpath->getY(j+2));\n\t  j += 3;\n\t} else {\n\t  sPath.lineTo((SplashCoord)subpath->getX(j),\n\t\t\t(SplashCoord)subpath->getY(j));\n\t  ++j;\n\t}\n      }\n      if (subpath->isClosed()) {\n\tsPath.close();\n      }\n    }\n  }\n  return sPath;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":402659,"func":"set_up_outpe(context *ctx, int fd, Pe *inpe, Pe **outpe)\n{\n\tsize_t size;\n\tchar *addr;\n\n\taddr = pe_rawfile(inpe, &size);\n\n\toff_t offset = lseek(fd, 0, SEEK_SET);\n\tif (offset < 0) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not read output file: %m\");\n\t\treturn -1;\n\t}\n\n\tint rc = ftruncate(fd, size);\n\tif (rc < 0) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not extend output file: %m\");\n\t\treturn -1;\n\t}\n\trc = write(fd, addr, size);\n\tif (rc < 0) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not write to output file: %m\");\n\t\treturn -1;\n\t}\n\n\t*outpe = pe_begin(fd, PE_C_RDWR_MMAP, NULL);\n\tif (!*outpe)\n\t\t*outpe = pe_begin(fd, PE_C_RDWR, NULL);\n\tif (!*outpe) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not set up output: %s\",\n\t\t\tpe_errmsg(pe_errno()));\n\t\treturn -1;\n\t}\n\n\tpe_clearcert(*outpe);\n\treturn 0;\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":312509,"func":"vgr_process_args(\n\texarg_T\t\t*eap,\n\tvgr_args_T\t*args)\n{\n    char_u\t*p;\n\n    vim_memset(args, 0, sizeof(*args));\n\n    args->regmatch.regprog = NULL;\n    args->qf_title = vim_strsave(qf_cmdtitle(*eap->cmdlinep));\n\n    if (eap->addr_count > 0)\n\targs->tomatch = eap->line2;\n    else\n\targs->tomatch = MAXLNUM;\n\n    \/\/ Get the search pattern: either white-separated or enclosed in \/\/\n    p = skip_vimgrep_pat(eap->arg, &args->spat, &args->flags);\n    if (p == NULL)\n    {\n\temsg(_(e_invalid_search_pattern_or_delimiter));\n\treturn FAIL;\n    }\n\n    vgr_init_regmatch(&args->regmatch, args->spat);\n    if (args->regmatch.regprog == NULL)\n\treturn FAIL;\n\n    p = skipwhite(p);\n    if (*p == NUL)\n    {\n\temsg(_(e_file_name_missing_or_invalid_pattern));\n\treturn FAIL;\n    }\n\n    \/\/ Parse the list of arguments, wildcards have already been expanded.\n    if ((get_arglist_exp(p, &args->fcount, &args->fnames, TRUE) == FAIL) ||\n\targs->fcount == 0)\n    {\n\temsg(_(e_no_match));\n\treturn FAIL;\n    }\n\n    return OK;\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":265444,"func":"static int sqfs_read_inode_table(unsigned char **inode_table)\n{\n\tstruct squashfs_super_block *sblk = ctxt.sblk;\n\tu64 start, n_blks, table_offset, table_size;\n\tint j, ret = 0, metablks_count;\n\tunsigned char *src_table, *itb;\n\tu32 src_len, dest_offset = 0;\n\tunsigned long dest_len = 0;\n\tbool compressed;\n\n\ttable_size = get_unaligned_le64(&sblk->directory_table_start) -\n\t\tget_unaligned_le64(&sblk->inode_table_start);\n\tstart = get_unaligned_le64(&sblk->inode_table_start) \/\n\t\tctxt.cur_dev->blksz;\n\tn_blks = sqfs_calc_n_blks(sblk->inode_table_start,\n\t\t\t\t  sblk->directory_table_start, &table_offset);\n\n\t\/* Allocate a proper sized buffer (itb) to store the inode table *\/\n\titb = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);\n\tif (!itb)\n\t\treturn -ENOMEM;\n\n\tif (sqfs_disk_read(start, n_blks, itb) < 0) {\n\t\tret = -EINVAL;\n\t\tgoto free_itb;\n\t}\n\n\t\/* Parse inode table (metadata block) header *\/\n\tret = sqfs_read_metablock(itb, table_offset, &compressed, &src_len);\n\tif (ret) {\n\t\tret = -EINVAL;\n\t\tgoto free_itb;\n\t}\n\n\t\/* Calculate size to store the whole decompressed table *\/\n\tmetablks_count = sqfs_count_metablks(itb, table_offset, table_size);\n\tif (metablks_count < 1) {\n\t\tret = -EINVAL;\n\t\tgoto free_itb;\n\t}\n\n\t*inode_table = malloc(metablks_count * SQFS_METADATA_BLOCK_SIZE);\n\tif (!*inode_table) {\n\t\tret = -ENOMEM;\n\t\tprintf(\"Error: failed to allocate squashfs inode_table of size %i, increasing CONFIG_SYS_MALLOC_LEN could help\\n\",\n\t\t       metablks_count * SQFS_METADATA_BLOCK_SIZE);\n\t\tgoto free_itb;\n\t}\n\n\tsrc_table = itb + table_offset + SQFS_HEADER_SIZE;\n\n\t\/* Extract compressed Inode table *\/\n\tfor (j = 0; j < metablks_count; j++) {\n\t\tsqfs_read_metablock(itb, table_offset, &compressed, &src_len);\n\t\tif (compressed) {\n\t\t\tdest_len = SQFS_METADATA_BLOCK_SIZE;\n\t\t\tret = sqfs_decompress(&ctxt, *inode_table +\n\t\t\t\t\t      dest_offset, &dest_len,\n\t\t\t\t\t      src_table, src_len);\n\t\t\tif (ret) {\n\t\t\t\tfree(*inode_table);\n\t\t\t\t*inode_table = NULL;\n\t\t\t\tgoto free_itb;\n\t\t\t}\n\n\t\t\tdest_offset += dest_len;\n\t\t} else {\n\t\t\tmemcpy(*inode_table + (j * SQFS_METADATA_BLOCK_SIZE),\n\t\t\t       src_table, src_len);\n\t\t}\n\n\t\t\/*\n\t\t * Offsets to the decompression destination, to the metadata\n\t\t * buffer 'itb' and to the decompression source, respectively.\n\t\t *\/\n\n\t\ttable_offset += src_len + SQFS_HEADER_SIZE;\n\t\tsrc_table += src_len + SQFS_HEADER_SIZE;\n\t}\n\nfree_itb:\n\tfree(itb);\n\n\treturn ret;\n}","target":0,"code_token_length":684,"total_token_length":920,"max_tokens_setting":1024}
+{"idx":314481,"func":"static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)\n{\n\tunion kvm_mmu_page_role mmu_role = vcpu->arch.mmu->mmu_role.base;\n\tint i;\n\tbool host_writable;\n\tgpa_t first_pte_gpa;\n\tbool flush = false;\n\n\t\/*\n\t * Ignore various flags when verifying that it's safe to sync a shadow\n\t * page using the current MMU context.\n\t *\n\t *  - level: not part of the overall MMU role and will never match as the MMU's\n\t *           level tracks the root level\n\t *  - access: updated based on the new guest PTE\n\t *  - quadrant: not part of the overall MMU role (similar to level)\n\t *\/\n\tconst union kvm_mmu_page_role sync_role_ign = {\n\t\t.level = 0xf,\n\t\t.access = 0x7,\n\t\t.quadrant = 0x3,\n\t};\n\n\t\/*\n\t * Direct pages can never be unsync, and KVM should never attempt to\n\t * sync a shadow page for a different MMU context, e.g. if the role\n\t * differs then the memslot lookup (SMM vs. non-SMM) will be bogus, the\n\t * reserved bits checks will be wrong, etc...\n\t *\/\n\tif (WARN_ON_ONCE(sp->role.direct ||\n\t\t\t (sp->role.word ^ mmu_role.word) & ~sync_role_ign.word))\n\t\treturn -1;\n\n\tfirst_pte_gpa = FNAME(get_level1_sp_gpa)(sp);\n\n\tfor (i = 0; i < PT64_ENT_PER_PAGE; i++) {\n\t\tu64 *sptep, spte;\n\t\tstruct kvm_memory_slot *slot;\n\t\tunsigned pte_access;\n\t\tpt_element_t gpte;\n\t\tgpa_t pte_gpa;\n\t\tgfn_t gfn;\n\n\t\tif (!sp->spt[i])\n\t\t\tcontinue;\n\n\t\tpte_gpa = first_pte_gpa + i * sizeof(pt_element_t);\n\n\t\tif (kvm_vcpu_read_guest_atomic(vcpu, pte_gpa, &gpte,\n\t\t\t\t\t       sizeof(pt_element_t)))\n\t\t\treturn -1;\n\n\t\tif (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) {\n\t\t\tflush = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tgfn = gpte_to_gfn(gpte);\n\t\tpte_access = sp->role.access;\n\t\tpte_access &= FNAME(gpte_access)(gpte);\n\t\tFNAME(protect_clean_gpte)(vcpu->arch.mmu, &pte_access, gpte);\n\n\t\tif (sync_mmio_spte(vcpu, &sp->spt[i], gfn, pte_access))\n\t\t\tcontinue;\n\n\t\tif (gfn != sp->gfns[i]) {\n\t\t\tdrop_spte(vcpu->kvm, &sp->spt[i]);\n\t\t\tflush = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tsptep = &sp->spt[i];\n\t\tspte = *sptep;\n\t\thost_writable = spte & shadow_host_writable_mask;\n\t\tslot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);\n\t\tmake_spte(vcpu, sp, slot, pte_access, gfn,\n\t\t\t  spte_to_pfn(spte), spte, true, false,\n\t\t\t  host_writable, &spte);\n\n\t\tflush |= mmu_spte_update(sptep, spte);\n\t}\n\n\treturn flush;\n}","target":0,"code_token_length":756,"total_token_length":992,"max_tokens_setting":1024}
+{"idx":225040,"func":"conninfo_uri_parse_params(char *params,\n\t\t\t\t\t\t  PQconninfoOption *connOptions,\n\t\t\t\t\t\t  PQExpBuffer errorMessage)\n{\n\twhile (*params)\n\t{\n\t\tchar\t   *keyword = params;\n\t\tchar\t   *value = NULL;\n\t\tchar\t   *p = params;\n\t\tbool\t\tmalloced = false;\n\t\tint\t\t\toldmsglen;\n\n\t\t\/*\n\t\t * Scan the params string for '=' and '&', marking the end of keyword\n\t\t * and value respectively.\n\t\t *\/\n\t\tfor (;;)\n\t\t{\n\t\t\tif (*p == '=')\n\t\t\t{\n\t\t\t\t\/* Was there '=' already? *\/\n\t\t\t\tif (value != NULL)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"extra key\/value separator \\\"=\\\" in URI query parameter: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t\t  keyword);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t\/* Cut off keyword, advance to value *\/\n\t\t\t\t*p++ = '\\0';\n\t\t\t\tvalue = p;\n\t\t\t}\n\t\t\telse if (*p == '&' || *p == '\\0')\n\t\t\t{\n\t\t\t\t\/*\n\t\t\t\t * If not at the end, cut off value and advance; leave p\n\t\t\t\t * pointing to start of the next parameter, if any.\n\t\t\t\t *\/\n\t\t\t\tif (*p != '\\0')\n\t\t\t\t\t*p++ = '\\0';\n\t\t\t\t\/* Was there '=' at all? *\/\n\t\t\t\tif (value == NULL)\n\t\t\t\t{\n\t\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"missing key\/value separator \\\"=\\\" in URI query parameter: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t\t  keyword);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t\/* Got keyword and value, go process them. *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t\t++p;\t\t\t\/* Advance over all other bytes. *\/\n\t\t}\n\n\t\tkeyword = conninfo_uri_decode(keyword, errorMessage);\n\t\tif (keyword == NULL)\n\t\t{\n\t\t\t\/* conninfo_uri_decode already set an error message *\/\n\t\t\treturn false;\n\t\t}\n\t\tvalue = conninfo_uri_decode(value, errorMessage);\n\t\tif (value == NULL)\n\t\t{\n\t\t\t\/* conninfo_uri_decode already set an error message *\/\n\t\t\tfree(keyword);\n\t\t\treturn false;\n\t\t}\n\t\tmalloced = true;\n\n\t\t\/*\n\t\t * Special keyword handling for improved JDBC compatibility.\n\t\t *\/\n\t\tif (strcmp(keyword, \"ssl\") == 0 &&\n\t\t\tstrcmp(value, \"true\") == 0)\n\t\t{\n\t\t\tfree(keyword);\n\t\t\tfree(value);\n\t\t\tmalloced = false;\n\n\t\t\tkeyword = \"sslmode\";\n\t\t\tvalue = \"require\";\n\t\t}\n\n\t\t\/*\n\t\t * Store the value if the corresponding option exists; ignore\n\t\t * otherwise.  At this point both keyword and value are not\n\t\t * URI-encoded.\n\t\t *\/\n\t\toldmsglen = errorMessage->len;\n\t\tif (!conninfo_storeval(connOptions, keyword, value,\n\t\t\t\t\t\t\t   errorMessage, true, false))\n\t\t{\n\t\t\t\/* Insert generic message if conninfo_storeval didn't give one. *\/\n\t\t\tif (errorMessage->len == oldmsglen)\n\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"invalid URI query parameter: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t  keyword);\n\t\t\t\/* And fail. *\/\n\t\t\tif (malloced)\n\t\t\t{\n\t\t\t\tfree(keyword);\n\t\t\t\tfree(value);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (malloced)\n\t\t{\n\t\t\tfree(keyword);\n\t\t\tfree(value);\n\t\t}\n\n\t\t\/* Proceed to next key=value pair, if any *\/\n\t\tparams = p;\n\t}\n\n\treturn true;\n}","target":0,"code_token_length":743,"total_token_length":979,"max_tokens_setting":1024}
+{"idx":455313,"func":"shell_glob_filename (pathname)\n     const char *pathname;\n{\n#if defined (USE_POSIX_GLOB_LIBRARY)\n  register int i;\n  char *temp, **results;\n  glob_t filenames;\n  int glob_flags;\n\n  temp = quote_string_for_globbing (pathname, QGLOB_FILENAME);\n\n  filenames.gl_offs = 0;\n\n#  if defined (GLOB_PERIOD)\n  glob_flags = glob_dot_filenames ? GLOB_PERIOD : 0;\n#  else\n  glob_flags = 0;\n#  endif \/* !GLOB_PERIOD *\/\n\n  glob_flags |= (GLOB_ERR | GLOB_DOOFFS);\n\n  i = glob (temp, glob_flags, (posix_glob_errfunc_t *)NULL, &filenames);\n\n  free (temp);\n\n  if (i == GLOB_NOSPACE || i == GLOB_ABORTED)\n    return ((char **)NULL);\n  else if (i == GLOB_NOMATCH)\n    filenames.gl_pathv = (char **)NULL;\n  else if (i != 0)\t\t\/* other error codes not in POSIX.2 *\/\n    filenames.gl_pathv = (char **)NULL;\n\n  results = filenames.gl_pathv;\n\n  if (results && ((GLOB_FAILED (results)) == 0))\n    {\n      if (should_ignore_glob_matches ())\n\tignore_glob_matches (results);\n      if (results && results[0])\n\tstrvec_sort (results);\n      else\n\t{\n\t  FREE (results);\n\t  results = (char **)NULL;\n\t}\n    }\n\n  return (results);\n\n#else \/* !USE_POSIX_GLOB_LIBRARY *\/\n\n  char *temp, **results;\n  int gflags, quoted_pattern;\n\n  noglob_dot_filenames = glob_dot_filenames == 0;\n\n  temp = quote_string_for_globbing (pathname, QGLOB_FILENAME);\n  quoted_pattern = STREQ (pathname, temp) == 0;\n  gflags = glob_star ? GX_GLOBSTAR : 0;\n  results = glob_filename (temp, gflags);\n  free (temp);\n\n  if (results && ((GLOB_FAILED (results)) == 0))\n    {\n      if (should_ignore_glob_matches ())\n\tignore_glob_matches (results);\n      if (results && results[0])\n\tstrvec_sort (results);\n      else\n\t{\n\t  FREE (results);\n\t  results = (char **)&glob_error_return;\n\t}\n    }\n\n  return (results);\n#endif \/* !USE_POSIX_GLOB_LIBRARY *\/\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":285157,"func":"RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {\n\tif (!bin->entry_table) {\n\t\treturn NULL;\n\t}\n\tRList *entries = r_list_newf (free);\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_bin_ne_get_segments (bin);\n\tif (!segments) {\n\t\tr_list_free (entries);\n\t\treturn NULL;\n\t}\n\tif (bin->ne_header->csEntryPoint) {\n\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\tif (!entry) {\n\t\t\tr_list_free (entries);\n\t\t\treturn NULL;\n\t\t}\n\t\tentry->bits = 16;\n\t\tut32 entry_cs = bin->ne_header->csEntryPoint;\n\t\tRBinSection *s = r_list_get_n (segments, entry_cs - 1);\n\t\tentry->paddr = bin->ne_header->ipEntryPoint + (s? s->paddr: 0);\n\n\t\tr_list_append (entries, entry);\n\t}\n\tint off = 0;\n\tsize_t tableat = bin->header_offset + bin->ne_header->EntryTableOffset;\n\twhile (off < bin->ne_header->EntryTableLength) {\n\t\tif (tableat + off >= r_buf_size (bin->buf)) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 bundle_length = *(ut8 *)(bin->entry_table + off);\n\t\tif (!bundle_length) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tut8 bundle_type = *(ut8 *)(bin->entry_table + off);\n\t\toff++;\n\t\tint i;\n\t\tfor (i = 0; i < bundle_length; i++) {\n\t\t\tif (tableat + off + 4 >= r_buf_size (bin->buf)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\t\tif (!entry) {\n\t\t\t\tr_list_free (entries);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\toff++;\n\t\t\tif (!bundle_type) { \/\/ Skip\n\t\t\t\toff--;\n\t\t\t\tfree (entry);\n\t\t\t\tbreak;\n\t\t\t} else if (bundle_type == 0xff) { \/\/ moveable\n\t\t\t\toff += 2;\n\t\t\t\tut8 segnum = *(bin->entry_table + off);\n\t\t\t\toff++;\n\t\t\t\tif (off > bin->ne_header->EntryTableLength) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tut16 segoff = r_read_le16 (bin->entry_table + off);\n\t\t\t\tif (segnum > 0 && segnum < bin->ne_header->SegCount) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;\n\t\t\t\t}\n\t\t\t} else { \/\/ Fixed\n\t\t\t\tif (off + 2 >= bin->ne_header->EntryTableLength) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tut16 delta = r_read_le16 (bin->entry_table + off);\n\t\t\t\tif (bundle_type < bin->ne_header->SegCount) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset\n\t\t\t\t\t\t* bin->alignment + delta;\n\t\t\t\t}\n\t\t\t}\n\t\t\toff += 2;\n\t\t\tr_list_append (entries, entry);\n\t\t}\n\t}\n\tr_list_free (segments);\n\tbin->entries = entries;\n\treturn entries;\n}","target":0,"code_token_length":724,"total_token_length":960,"max_tokens_setting":1024}
+{"idx":261956,"func":"njs_string_prototype_includes(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    int64_t            index, length, search_length;\n    njs_int_t          ret;\n    njs_value_t        *value;\n    const u_char       *p, *end;\n    const njs_value_t  *retval;\n    njs_string_prop_t  string, search;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    retval = &njs_value_true;\n\n    if (nargs > 1) {\n        value = njs_argument(args, 1);\n\n        if (njs_slow_path(!njs_is_string(value))) {\n            ret = njs_value_to_string(vm, value, value);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n        }\n\n        search_length = njs_string_prop(&search, value);\n\n        if (nargs > 2) {\n            value = njs_argument(args, 2);\n\n            if (njs_slow_path(!njs_is_number(value))) {\n                ret = njs_value_to_integer(vm, value, &index);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    return ret;\n                }\n\n            } else {\n                index = njs_number_to_integer(njs_number(value));\n            }\n\n            if (index < 0) {\n                index = 0;\n            }\n\n        } else {\n            index = 0;\n        }\n\n        if (search_length == 0) {\n            goto done;\n        }\n\n        length = njs_string_prop(&string, &args[0]);\n\n        if (length - index >= search_length) {\n            end = string.start + string.size;\n\n            if (string.size == (size_t) length) {\n                \/* Byte or ASCII string. *\/\n                p = string.start + index;\n\n            } else {\n                \/* UTF-8 string. *\/\n                p = njs_string_offset(string.start, end, index);\n            }\n\n            end -= search.size - 1;\n\n            while (p < end) {\n                if (memcmp(p, search.start, search.size) == 0) {\n                    goto done;\n                }\n\n                p++;\n            }\n        }\n    }\n\n    retval = &njs_value_false;\n\ndone:\n\n    vm->retval = *retval;\n\n    return NJS_OK;\n}","target":0,"code_token_length":531,"total_token_length":767,"max_tokens_setting":1024}
+{"idx":418791,"func":"mouse_comp_pos(\n    win_T\t*win,\n    int\t\t*rowp,\n    int\t\t*colp,\n    linenr_T\t*lnump,\n    int\t\t*plines_cache)\n{\n    int\t\tcol = *colp;\n    int\t\trow = *rowp;\n    linenr_T\tlnum;\n    int\t\tretval = FALSE;\n    int\t\toff;\n    int\t\tcount;\n\n#ifdef FEAT_RIGHTLEFT\n    if (win->w_p_rl)\n\tcol = win->w_width - 1 - col;\n#endif\n\n    lnum = win->w_topline;\n\n    while (row > 0)\n    {\n\tint cache_idx = lnum - win->w_topline;\n\n\t\/\/ Only \"Rows\" lines are cached, with folding we'll run out of entries\n\t\/\/ and use the slow way.\n\tif (plines_cache != NULL && cache_idx < Rows\n\t\t\t\t\t\t&& plines_cache[cache_idx] > 0)\n\t    count = plines_cache[cache_idx];\n\telse\n\t{\n#ifdef FEAT_DIFF\n\t    \/\/ Don't include filler lines in \"count\"\n\t    if (win->w_p_diff\n# ifdef FEAT_FOLDING\n\t\t    && !hasFoldingWin(win, lnum, NULL, NULL, TRUE, NULL)\n# endif\n\t\t    )\n\t    {\n\t\tif (lnum == win->w_topline)\n\t\t    row -= win->w_topfill;\n\t\telse\n\t\t    row -= diff_check_fill(win, lnum);\n\t\tcount = plines_win_nofill(win, lnum, TRUE);\n\t    }\n\t    else\n#endif\n\t\tcount = plines_win(win, lnum, TRUE);\n\t    if (plines_cache != NULL && cache_idx < Rows)\n\t\tplines_cache[cache_idx] = count;\n\t}\n\tif (count > row)\n\t    break;\t\/\/ Position is in this buffer line.\n#ifdef FEAT_FOLDING\n\t(void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL);\n#endif\n\tif (lnum == win->w_buffer->b_ml.ml_line_count)\n\t{\n\t    retval = TRUE;\n\t    break;\t\t\/\/ past end of file\n\t}\n\trow -= count;\n\t++lnum;\n    }\n\n    if (!retval)\n    {\n\t\/\/ Compute the column without wrapping.\n\toff = win_col_off(win) - win_col_off2(win);\n\tif (col < off)\n\t    col = off;\n\tcol += row * (win->w_width - off);\n\t\/\/ add skip column (for long wrapping line)\n\tcol += win->w_skipcol;\n    }\n\n    if (!win->w_p_wrap)\n\tcol += win->w_leftcol;\n\n    \/\/ skip line number and fold column in front of the line\n    col -= win_col_off(win);\n    if (col <= 0)\n    {\n#ifdef FEAT_NETBEANS_INTG\n\t\/\/ if mouse is clicked on the gutter, then inform the netbeans server\n\tif (*colp < win_col_off(win))\n\t    netbeans_gutter_click(lnum);\n#endif\n\tcol = 0;\n    }\n\n    *colp = col;\n    *rowp = row;\n    *lnump = lnum;\n    return retval;\n}","target":0,"code_token_length":678,"total_token_length":914,"max_tokens_setting":1024}
+{"idx":247524,"func":"TEST_P(SslSocketTest, TestConnectionFailsOnMultipleCertificatesNonePassOcspPolicy) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/revoked_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/revoked_key.pem\"\n      ocsp_staple:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/revoked_ocsp_resp.der\"\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/ecdsa_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/ecdsa_key.pem\"\n      ocsp_staple:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/ecdsa_ocsp_resp.der\"\n  ocsp_staple_policy: must_staple\n  )EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites:\n      - ECDHE-ECDSA-AES128-GCM-SHA256\n      - TLS_RSA_WITH_AES_128_GCM_SHA256\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.ocsp_staple_failed\").enableOcspStapling());\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":292190,"func":"inbound_user_info (session *sess, char *chan, char *user, char *host,\n\t\t\t\t\t\t char *servname, char *nick, char *realname,\n\t\t\t\t\t\t char *account, unsigned int away,\n\t\t\t\t\t\t const message_tags_data *tags_data)\n{\n\tserver *serv = sess->server;\n\tsession *who_sess;\n\tGSList *list;\n\tchar *uhost = NULL;\n\n\tif (user && host)\n\t{\n\t\tuhost = g_strdup_printf (\"%s@%s\", user, host);\n\t}\n\n\tif (chan)\n\t{\n\t\twho_sess = find_channel (serv, chan);\n\t\tif (who_sess)\n\t\t\tuserlist_add_hostname (who_sess, nick, uhost, realname, servname, account, away);\n\t\telse\n\t\t{\n\t\t\tif (serv->doing_dns && nick && host)\n\t\t\t\tdo_dns (sess, nick, host, tags_data);\n\t\t}\n\t}\n\telse\n\t{\n\t\t\/* came from WHOIS, not channel specific *\/\n\t\tfor (list = sess_list; list; list = list->next)\n\t\t{\n\t\t\tsess = list->data;\n\t\t\tif (sess->type == SESS_CHANNEL && sess->server == serv)\n\t\t\t{\n\t\t\t\tuserlist_add_hostname (sess, nick, uhost, realname, servname, account, away);\n\t\t\t}\n\t\t}\n\t}\n\n\tg_free (uhost);\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":458916,"func":"cin_is_cpp_namespace(char_u *s)\n{\n    char_u\t*p;\n    int\t\thas_name = FALSE;\n    int\t\thas_name_start = FALSE;\n\n    s = cin_skipcomment(s);\n    if (STRNCMP(s, \"namespace\", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9])))\n    {\n\tp = cin_skipcomment(skipwhite(s + 9));\n\twhile (*p != NUL)\n\t{\n\t    if (VIM_ISWHITE(*p))\n\t    {\n\t\thas_name = TRUE; \/\/ found end of a name\n\t\tp = cin_skipcomment(skipwhite(p));\n\t    }\n\t    else if (*p == '{')\n\t    {\n\t\tbreak;\n\t    }\n\t    else if (vim_iswordc(*p))\n\t    {\n\t\thas_name_start = TRUE;\n\t\tif (has_name)\n\t\t    return FALSE; \/\/ word character after skipping past name\n\t\t++p;\n\t    }\n\t    else if (p[0] == ':' && p[1] == ':' && vim_iswordc(p[2]))\n\t    {\n\t\tif (!has_name_start || has_name)\n\t\t    return FALSE;\n\t\t\/\/ C++ 17 nested namespace\n\t\tp += 3;\n\t    }\n\t    else\n\t    {\n\t\treturn FALSE;\n\t    }\n\t}\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":489167,"func":"sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep,\n\t\t\t\t      const struct sctp_association *asoc,\n\t\t\t\t      const sctp_subtype_t type, void *arg,\n\t\t\t\t      sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sctp_ulpevent *ev;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Verify that the chunk length for the COOKIE-ACK is OK.\n\t * If we don't do this, any bundled chunks may be junked.\n\t *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\t\/* Reset init error count upon receipt of COOKIE-ACK,\n\t * to avoid problems with the managemement of this\n\t * counter in stale cookie situations when a transition back\n\t * from the COOKIE-ECHOED state to the COOKIE-WAIT\n\t * state is performed.\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL());\n\n\t\/* RFC 2960 5.1 Normal Establishment of an Association\n\t *\n\t * E) Upon reception of the COOKIE ACK, endpoint \"A\" will move\n\t * from the COOKIE-ECHOED state to the ESTABLISHED state,\n\t * stopping the T1-cookie timer.\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,\n\t\t\tSCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));\n\tsctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,\n\t\t\tSCTP_STATE(SCTP_STATE_ESTABLISHED));\n\tSCTP_INC_STATS(SCTP_MIB_CURRESTAB);\n\tSCTP_INC_STATS(SCTP_MIB_ACTIVEESTABS);\n\tsctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());\n\tif (asoc->autoclose)\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,\n\t\t\t\tSCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));\n\n\t\/* It may also notify its ULP about the successful\n\t * establishment of the association with a Communication Up\n\t * notification (see Section 10).\n\t *\/\n\tev = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_COMM_UP,\n\t\t\t\t\t     0, asoc->c.sinit_num_ostreams,\n\t\t\t\t\t     asoc->c.sinit_max_instreams,\n\t\t\t\t\t     NULL, GFP_ATOMIC);\n\n\tif (!ev)\n\t\tgoto nomem;\n\n\tsctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));\n\n\t\/* Sockets API Draft Section 5.3.1.6\n\t * When a peer sends a Adaptation Layer Indication parameter , SCTP\n\t * delivers this notification to inform the application that of the\n\t * peers requested adaptation layer.\n\t *\/\n\tif (asoc->peer.adaptation_ind) {\n\t\tev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC);\n\t\tif (!ev)\n\t\t\tgoto nomem;\n\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,\n\t\t\t\tSCTP_ULPEVENT(ev));\n\t}\n\n\treturn SCTP_DISPOSITION_CONSUME;\nnomem:\n\treturn SCTP_DISPOSITION_NOMEM;\n}","target":0,"code_token_length":722,"total_token_length":958,"max_tokens_setting":1024}
+{"idx":212871,"func":"std::string controller::bookmark(\n\t\tconst std::string& url,\n\t\tconst std::string& title,\n\t\tconst std::string& description,\n\t\tconst std::string& feed_title)\n{\n\tstd::string bookmark_cmd = cfg.get_configvalue(\"bookmark-cmd\");\n\tbool is_interactive = cfg.get_configvalue_as_bool(\"bookmark-interactive\");\n\tif (bookmark_cmd.length() > 0) {\n\t\tstd::string cmdline = strprintf::fmt(\"%s '%s' %s %s %s\",\n\t\t                                       bookmark_cmd,\n\t\t                                       utils::replace_all(url,\"'\", \"%27\"),\n\t\t                                       quote_empty(stfl::quote(title)),\n\t\t                                       quote_empty(stfl::quote(description)),\n\t\t                                       quote_empty(stfl::quote(feed_title)));\n\n\t\tLOG(level::DEBUG, \"controller::bookmark: cmd = %s\", cmdline);\n\n\t\tif (is_interactive) {\n\t\t\tv->push_empty_formaction();\n\t\t\tstfl::reset();\n\t\t\tutils::run_interactively(cmdline, \"controller::bookmark\");\n\t\t\tv->pop_current_formaction();\n\t\t\treturn \"\";\n\t\t} else {\n\t\t\tchar * my_argv[4];\n\t\t\tmy_argv[0] = const_cast<char *>(\"\/bin\/sh\");\n\t\t\tmy_argv[1] = const_cast<char *>(\"-c\");\n\t\t\tmy_argv[2] = const_cast<char *>(cmdline.c_str());\n\t\t\tmy_argv[3] = nullptr;\n\t\t\treturn utils::run_program(my_argv, \"\");\n\t\t}\n\t} else {\n\t\treturn _(\"bookmarking support is not configured. Please set the configuration variable `bookmark-cmd' accordingly.\");\n\t}\n}","target":1,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":220828,"func":"inline void NdArrayDescsForElementwiseBroadcast(const Dims<N>& input0_dims,\n                                                const Dims<N>& input1_dims,\n                                                NdArrayDesc<N>* desc0_out,\n                                                NdArrayDesc<N>* desc1_out) {\n  TFLITE_DCHECK(desc0_out != nullptr);\n  TFLITE_DCHECK(desc1_out != nullptr);\n\n  \/\/ Copy dims to desc.\n  for (int i = 0; i < N; ++i) {\n    desc0_out->extents[i] = input0_dims.sizes[i];\n    desc0_out->strides[i] = input0_dims.strides[i];\n    desc1_out->extents[i] = input1_dims.sizes[i];\n    desc1_out->strides[i] = input1_dims.strides[i];\n  }\n\n  \/\/ Walk over each dimension. If the extents are equal do nothing.\n  \/\/ Otherwise, set the desc with extent 1 to have extent equal to the other and\n  \/\/ stride 0.\n  for (int i = 0; i < N; ++i) {\n    const int extent0 = ArraySize(input0_dims, i);\n    const int extent1 = ArraySize(input1_dims, i);\n    if (extent0 != extent1) {\n      if (extent0 == 1) {\n        desc0_out->strides[i] = 0;\n        desc0_out->extents[i] = extent1;\n      } else {\n        TFLITE_DCHECK_EQ(extent1, 1);\n        desc1_out->strides[i] = 0;\n        desc1_out->extents[i] = extent0;\n      }\n    }\n  }\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":345140,"func":"run_ready(struct pxa3xx_gcu_priv *priv)\n{\n\tunsigned int num = 0;\n\tstruct pxa3xx_gcu_shared *shared = priv->shared;\n\tstruct pxa3xx_gcu_batch\t*ready = priv->ready;\n\n\tQDUMP(\"Start\");\n\n\tBUG_ON(!ready);\n\n\tshared->buffer[num++] = 0x05000000;\n\n\twhile (ready) {\n\t\tshared->buffer[num++] = 0x00000001;\n\t\tshared->buffer[num++] = ready->phys;\n\t\tready = ready->next;\n\t}\n\n\tshared->buffer[num++] = 0x05000000;\n\tpriv->running = priv->ready;\n\tpriv->ready = priv->ready_last = NULL;\n\tgc_writel(priv, REG_GCRBLR, 0);\n\tshared->hw_running = 1;\n\n\t\/* ring base address *\/\n\tgc_writel(priv, REG_GCRBBR, shared->buffer_phys);\n\n\t\/* ring tail address *\/\n\tgc_writel(priv, REG_GCRBTR, shared->buffer_phys + num * 4);\n\n\t\/* ring length *\/\n\tgc_writel(priv, REG_GCRBLR, ((num + 63) & ~63) * 4);\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":219965,"func":"int callback_glewlwyd_add_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) {\n  struct config_elements * config = (struct config_elements *)client_data;\n  json_t * j_module, * j_module_valid, * j_result;\n  \n  j_module = ulfius_get_json_body_request(request, NULL);\n  if (j_module != NULL) {\n    j_module_valid = is_client_module_valid(config, j_module, 1);\n    if (check_result_value(j_module_valid, G_OK)) {\n      j_result = add_client_module(config, j_module);\n      if (check_result_value(j_result, G_ERROR_PARAM)) {\n        if (json_object_get(j_result, \"error\") != NULL) {\n          ulfius_set_json_body_response(response, 400, json_object_get(j_result, \"error\"));\n        } else {\n          response->status = 400;\n        }\n      } else if (!check_result_value(j_result, G_OK)) {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_add_client_module - Error add_client_module\");\n        response->status = 500;\n      } else {\n        y_log_message(Y_LOG_LEVEL_INFO, \"Event - Client backend module '%s' added (%s)\", json_string_value(json_object_get(j_module, \"name\")), json_string_value(json_object_get(j_module, \"module\")));\n      }\n      json_decref(j_result);\n    } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) {\n      if (json_object_get(j_module_valid, \"error\") != NULL) {\n        ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, \"error\"));\n      } else {\n        response->status = 400;\n      }\n    } else if (!check_result_value(j_module_valid, G_OK)) {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_add_client_module - Error is_client_module_valid\");\n      response->status = 500;\n    }\n    json_decref(j_module_valid);\n  } else {\n    response->status = 400;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":310292,"func":"dirserv_set_router_is_running(routerinfo_t *router, time_t now)\n{\n  \/*XXXX023 This function is a mess.  Separate out the part that calculates\n    whether it's reachable and the part that tells rephist that the router was\n    unreachable.\n   *\/\n  int answer;\n\n  if (router_is_me(router)) {\n    \/* We always know if we are down ourselves. *\/\n    answer = ! we_are_hibernating();\n  } else if (router->is_hibernating &&\n             (router->cache_info.published_on +\n              HIBERNATION_PUBLICATION_SKEW) > router->last_reachable) {\n    \/* A hibernating router is down unless we (somehow) had contact with it\n     * since it declared itself to be hibernating. *\/\n    answer = 0;\n  } else if (get_options()->AssumeReachable) {\n    \/* If AssumeReachable, everybody is up unless they say they are down! *\/\n    answer = 1;\n  } else {\n    \/* Otherwise, a router counts as up if we found it reachable in the last\n       REACHABLE_TIMEOUT seconds. *\/\n    answer = (now < router->last_reachable + REACHABLE_TIMEOUT);\n  }\n\n  if (!answer && running_long_enough_to_decide_unreachable()) {\n    \/* Not considered reachable. tell rephist about that.\n\n       Because we launch a reachability test for each router every\n       REACHABILITY_TEST_CYCLE_PERIOD seconds, then the router has probably\n       been down since at least that time after we last successfully reached\n       it.\n     *\/\n    time_t when = now;\n    if (router->last_reachable &&\n        router->last_reachable + REACHABILITY_TEST_CYCLE_PERIOD < now)\n      when = router->last_reachable + REACHABILITY_TEST_CYCLE_PERIOD;\n    rep_hist_note_router_unreachable(router->cache_info.identity_digest, when);\n  }\n\n  router->is_running = answer;\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":333045,"func":"check_char_class(int class, int c)\n{\n    switch (class)\n    {\n\tcase NFA_CLASS_ALNUM:\n\t    if (c >= 1 && c < 128 && isalnum(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_ALPHA:\n\t    if (c >= 1 && c < 128 && isalpha(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_BLANK:\n\t    if (c == ' ' || c == '\\t')\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_CNTRL:\n\t    if (c >= 1 && c <= 127 && iscntrl(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_DIGIT:\n\t    if (VIM_ISDIGIT(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_GRAPH:\n\t    if (c >= 1 && c <= 127 && isgraph(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_LOWER:\n\t    if (MB_ISLOWER(c) && c != 170 && c != 186)\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_PRINT:\n\t    if (vim_isprintc(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_PUNCT:\n\t    if (c >= 1 && c < 128 && ispunct(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_SPACE:\n\t    if ((c >= 9 && c <= 13) || (c == ' '))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_UPPER:\n\t    if (MB_ISUPPER(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_XDIGIT:\n\t    if (vim_isxdigit(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_TAB:\n\t    if (c == '\\t')\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_RETURN:\n\t    if (c == '\\r')\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_BACKSPACE:\n\t    if (c == '\\b')\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_ESCAPE:\n\t    if (c == '\\033')\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_IDENT:\n\t    if (vim_isIDc(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_KEYWORD:\n\t    if (reg_iswordc(c))\n\t\treturn OK;\n\t    break;\n\tcase NFA_CLASS_FNAME:\n\t    if (vim_isfilec(c))\n\t\treturn OK;\n\t    break;\n\n\tdefault:\n\t    \/\/ should not be here :P\n\t    siemsg(_(e_ill_char_class), class);\n\t    return FAIL;\n    }\n    return FAIL;\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":364768,"func":"findtags_state_init(\n    findtags_state_T\t*st,\n    char_u\t\t*pat,\n    int\t\t\tflags,\n    int\t\t\tmincount)\n{\n    int\t\tmtt;\n\n    st->tag_fname = alloc(MAXPATHL + 1);\n    st->fp = NULL;\n    st->orgpat = ALLOC_ONE(pat_T);\n    st->orgpat->pat = pat;\n    st->orgpat->len = (int)STRLEN(pat);\n    st->orgpat->regmatch.regprog = NULL;\n    st->flags = flags;\n    st->tag_file_sorted = NUL;\n    st->help_only = (flags & TAG_HELP);\n    st->get_searchpat = FALSE;\n#ifdef FEAT_MULTI_LANG\n    st->help_lang[0] = NUL;\n    st->help_pri = 0;\n    st->help_lang_find = NULL;\n    st->is_txt = FALSE;\n#endif\n    st->did_open = FALSE;\n    st->mincount = mincount;\n    st->lbuf_size = LSIZE;\n    st->lbuf = alloc(st->lbuf_size);\n#ifdef FEAT_EMACS_TAGS\n    st->ebuf = alloc(LSIZE);\n#endif\n    st->match_count = 0;\n    st->stop_searching = FALSE;\n\n    for (mtt = 0; mtt < MT_COUNT; ++mtt)\n    {\n\tga_init2(&st->ga_match[mtt], sizeof(char_u *), 100);\n\thash_init(&st->ht_match[mtt]);\n    }\n\n    \/\/ check for out of memory situation\n    if (st->tag_fname == NULL\n\t    || st->lbuf == NULL\n#ifdef FEAT_EMACS_TAGS\n\t    || st->ebuf == NULL\n#endif\n       )\n\treturn FAIL;\n\n    return OK;\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":402642,"func":"cms_context_fini(cms_context *cms)\n{\n\tif (cms->cert) {\n\t\tCERT_DestroyCertificate(cms->cert);\n\t\tcms->cert = NULL;\n\t}\n\n\tswitch (cms->pwdata.source) {\n\tcase PW_SOURCE_INVALID:\n\tcase PW_PROMPT:\n\tcase PW_DEVICE:\n\tcase PW_FROMFILEDB:\n\tcase PW_FROMENV:\n\tcase PW_SOURCE_MAX:\n\t\tbreak;\n\tcase PW_DATABASE:\n\t\txfree(cms->pwdata.data);\n\t\tbreak;\n\tcase PW_PLAINTEXT:\n\t\tmemset(cms->pwdata.data, 0, strlen(cms->pwdata.data));\n\t\txfree(cms->pwdata.data);\n\t\tbreak;\n\t}\n\tcms->pwdata.source = PW_SOURCE_INVALID;\n\tcms->pwdata.orig_source = PW_SOURCE_INVALID;\n\n\tif (cms->privkey) {\n\t\tfree(cms->privkey);\n\t\tcms->privkey = NULL;\n\t}\n\n\n\t\/* These were freed when the arena was destroyed *\/\n\tif (cms->tokenname)\n\t\tcms->tokenname = NULL;\n\tif (cms->certname)\n\t\tcms->certname = NULL;\n\n\tif (cms->newsig.data) {\n\t\tfree_poison(cms->newsig.data, cms->newsig.len);\n\t\tfree(cms->newsig.data);\n\t\tmemset(&cms->newsig, '\\0', sizeof (cms->newsig));\n\t}\n\n\tcms->selected_digest = -1;\n\n\tif (cms->ci_digest) {\n\t\tfree_poison(cms->ci_digest->data, cms->ci_digest->len);\n\t\t\/* XXX sure seems like we should be freeing it here, but\n\t\t * that's segfaulting, and we know it'll get cleaned up with\n\t\t * PORT_FreeArena a couple of lines down.\n\t\t *\/\n\t\tcms->ci_digest = NULL;\n\t}\n\n\tteardown_digests(cms);\n\n\tif (cms->raw_signed_attrs) {\n\t\tfree_poison(cms->raw_signed_attrs->data,\n\t\t\t\tcms->raw_signed_attrs->len);\n\t\t\/* XXX sure seems like we should be freeing it here, but\n\t\t * that's segfaulting, and we know it'll get cleaned up with\n\t\t * PORT_FreeArena a couple of lines down.\n\t\t *\/\n\t\tcms->raw_signed_attrs = NULL;\n\t}\n\n\tif (cms->raw_signature) {\n\t\tfree_poison(cms->raw_signature->data,\n\t\t\t\tcms->raw_signature->len);\n\t\t\/* XXX sure seems like we should be freeing it here, but\n\t\t * that's segfaulting, and we know it'll get cleaned up with\n\t\t * PORT_FreeArena a couple of lines down.\n\t\t *\/\n\t\tcms->raw_signature = NULL;\n\t}\n\n\tfor (int i = 0; i < cms->num_signatures; i++) {\n\t\tfree(cms->signatures[i]->data);\n\t\tfree(cms->signatures[i]);\n\t}\n\n\txfree(cms->signatures);\n\tcms->num_signatures = 0;\n\n\tif (cms->authbuf) {\n\t\txfree(cms->authbuf);\n\t\tcms->authbuf_len = 0;\n\t}\n\n\tPORT_FreeArena(cms->arena, PR_TRUE);\n\tmemset(cms, '\\0', sizeof(*cms));\n\txfree(cms);\n}","target":0,"code_token_length":688,"total_token_length":924,"max_tokens_setting":1024}
+{"idx":257712,"func":"handler_t mod_wstunnel_handshake_create_response(handler_ctx *hctx) {\n    request_st * const r = hctx->gw.r;\n  #ifdef _MOD_WEBSOCKET_SPEC_RFC_6455_\n    if (hctx->hybivers >= 8) {\n        DEBUG_LOG_DEBUG(\"%s\", \"send handshake response\");\n        if (0 != create_response_rfc_6455(hctx)) {\n            r->http_status = 400; \/* Bad Request *\/\n            return HANDLER_ERROR;\n        }\n        return HANDLER_GO_ON;\n    }\n  #endif \/* _MOD_WEBSOCKET_SPEC_RFC_6455_ *\/\n\n  #ifdef _MOD_WEBSOCKET_SPEC_IETF_00_\n    if (hctx->hybivers == 0 && r->http_version == HTTP_VERSION_1_1) {\n      #ifdef _MOD_WEBSOCKET_SPEC_IETF_00_\n        \/* 8 bytes should have been sent with request\n         * for draft-ietf-hybi-thewebsocketprotocol-00 *\/\n        chunkqueue *cq = &r->reqbody_queue;\n        if (chunkqueue_length(cq) < 8)\n            return HANDLER_WAIT_FOR_EVENT;\n      #endif \/* _MOD_WEBSOCKET_SPEC_IETF_00_ *\/\n\n        DEBUG_LOG_DEBUG(\"%s\", \"send handshake response\");\n        if (0 != create_response_ietf_00(hctx)) {\n            r->http_status = 400; \/* Bad Request *\/\n            return HANDLER_ERROR;\n        }\n        return HANDLER_GO_ON;\n    }\n  #endif \/* _MOD_WEBSOCKET_SPEC_IETF_00_ *\/\n\n    DEBUG_LOG_ERR(\"%s\", \"not supported WebSocket Version\");\n    r->http_status = 503; \/* Service Unavailable *\/\n    return HANDLER_ERROR;\n}","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":261408,"func":"bool initialize_CABAC_at_slice_segment_start(thread_context* tctx)\n{\n  de265_image* img = tctx->img;\n  const pic_parameter_set& pps = img->get_pps();\n  const seq_parameter_set& sps = img->get_sps();\n  slice_segment_header* shdr = tctx->shdr;\n\n  if (shdr->dependent_slice_segment_flag) {\n    int prevCtb = pps.CtbAddrTStoRS[ pps.CtbAddrRStoTS[shdr->slice_segment_address] -1 ];\n\n    int sliceIdx = img->get_SliceHeaderIndex_atIndex(prevCtb);\n    if (sliceIdx >= img->slices.size()) {\n      return false;\n    }\n    slice_segment_header* prevCtbHdr = img->slices[ sliceIdx ];\n\n    if (pps.is_tile_start_CTB(shdr->slice_segment_address % sps.PicWidthInCtbsY,\n                              shdr->slice_segment_address \/ sps.PicWidthInCtbsY\n                              )) {\n      initialize_CABAC_models(tctx);\n    }\n    else {\n      \/\/ wait for previous slice to finish decoding\n\n      \/\/printf(\"wait for previous slice to finish decoding\\n\");\n\n\n      slice_unit* prevSliceSegment = tctx->imgunit->get_prev_slice_segment(tctx->sliceunit);\n      \/\/assert(prevSliceSegment);\n      if (prevSliceSegment==NULL) {\n        return false;\n      }\n\n      prevSliceSegment->finished_threads.wait_for_progress(prevSliceSegment->nThreads);\n\n\n      \/*\n      printf(\"wait for %d,%d (init)\\n\",\n             prevCtb \/ sps->PicWidthInCtbsY,\n             prevCtb % sps->PicWidthInCtbsY);\n      tctx->img->wait_for_progress(tctx->task, prevCtb, CTB_PROGRESS_PREFILTER);\n      *\/\n\n      if (!prevCtbHdr->ctx_model_storage_defined) {\n        return false;\n      }\n\n      tctx->ctx_model = prevCtbHdr->ctx_model_storage;\n      prevCtbHdr->ctx_model_storage.release();\n    }\n  }\n  else {\n    initialize_CABAC_models(tctx);\n  }\n\n  return true;\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":221152,"func":"GF_Err gf_odf_av1_cfg_write_bs(GF_AV1Config *cfg, GF_BitStream *bs)\n{\n\tu32 i = 0;\n\tgf_bs_write_int(bs, cfg->marker, 1); assert(cfg->marker == 1);\n\tgf_bs_write_int(bs, cfg->version, 7); assert(cfg->version == 1);\n\tgf_bs_write_int(bs, cfg->seq_profile, 3);\n\tgf_bs_write_int(bs, cfg->seq_level_idx_0, 5);\n\tgf_bs_write_int(bs, cfg->seq_tier_0, 1);\n\tgf_bs_write_int(bs, cfg->high_bitdepth, 1);\n\tgf_bs_write_int(bs, cfg->twelve_bit, 1);\n\tgf_bs_write_int(bs, cfg->monochrome, 1);\n\tgf_bs_write_int(bs, cfg->chroma_subsampling_x, 1);\n\tgf_bs_write_int(bs, cfg->chroma_subsampling_y, 1);\n\tgf_bs_write_int(bs, cfg->chroma_sample_position, 2);\n\tgf_bs_write_int(bs, 0, 3); \/*reserved*\/\n\tgf_bs_write_int(bs, cfg->initial_presentation_delay_present, 1);\n\tgf_bs_write_int(bs, cfg->initial_presentation_delay_minus_one, 4); \/*TODO: compute initial_presentation_delay_minus_one*\/\n\tfor (i = 0; i < gf_list_count(cfg->obu_array); ++i) {\n\t\tGF_AV1_OBUArrayEntry *a = gf_list_get(cfg->obu_array, i);\n\t\tgf_bs_write_data(bs, a->obu, (u32)a->obu_length); \/\/TODO: we are supposed to omit the size on the last OBU...\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":238566,"func":"static int check_attach_btf_id(struct bpf_verifier_env *env)\n{\n\tstruct bpf_prog *prog = env->prog;\n\tstruct bpf_prog *tgt_prog = prog->aux->dst_prog;\n\tstruct bpf_attach_target_info tgt_info = {};\n\tu32 btf_id = prog->aux->attach_btf_id;\n\tstruct bpf_trampoline *tr;\n\tint ret;\n\tu64 key;\n\n\tif (prog->type == BPF_PROG_TYPE_SYSCALL) {\n\t\tif (prog->aux->sleepable)\n\t\t\t\/* attach_btf_id checked to be zero already *\/\n\t\t\treturn 0;\n\t\tverbose(env, \"Syscall programs can only be sleepable\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (prog->aux->sleepable && prog->type != BPF_PROG_TYPE_TRACING &&\n\t    prog->type != BPF_PROG_TYPE_LSM) {\n\t\tverbose(env, \"Only fentry\/fexit\/fmod_ret and lsm programs can be sleepable\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (prog->type == BPF_PROG_TYPE_STRUCT_OPS)\n\t\treturn check_struct_ops_btf_id(env);\n\n\tif (prog->type != BPF_PROG_TYPE_TRACING &&\n\t    prog->type != BPF_PROG_TYPE_LSM &&\n\t    prog->type != BPF_PROG_TYPE_EXT)\n\t\treturn 0;\n\n\tret = bpf_check_attach_target(&env->log, prog, tgt_prog, btf_id, &tgt_info);\n\tif (ret)\n\t\treturn ret;\n\n\tif (tgt_prog && prog->type == BPF_PROG_TYPE_EXT) {\n\t\t\/* to make freplace equivalent to their targets, they need to\n\t\t * inherit env->ops and expected_attach_type for the rest of the\n\t\t * verification\n\t\t *\/\n\t\tenv->ops = bpf_verifier_ops[tgt_prog->type];\n\t\tprog->expected_attach_type = tgt_prog->expected_attach_type;\n\t}\n\n\t\/* store info about the attachment target that will be used later *\/\n\tprog->aux->attach_func_proto = tgt_info.tgt_type;\n\tprog->aux->attach_func_name = tgt_info.tgt_name;\n\n\tif (tgt_prog) {\n\t\tprog->aux->saved_dst_prog_type = tgt_prog->type;\n\t\tprog->aux->saved_dst_attach_type = tgt_prog->expected_attach_type;\n\t}\n\n\tif (prog->expected_attach_type == BPF_TRACE_RAW_TP) {\n\t\tprog->aux->attach_btf_trace = true;\n\t\treturn 0;\n\t} else if (prog->expected_attach_type == BPF_TRACE_ITER) {\n\t\tif (!bpf_iter_prog_supported(prog))\n\t\t\treturn -EINVAL;\n\t\treturn 0;\n\t}\n\n\tif (prog->type == BPF_PROG_TYPE_LSM) {\n\t\tret = bpf_lsm_verify_prog(&env->log, prog);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t} else if (prog->type == BPF_PROG_TYPE_TRACING &&\n\t\t   btf_id_set_contains(&btf_id_deny, btf_id)) {\n\t\treturn -EINVAL;\n\t}\n\n\tkey = bpf_trampoline_compute_key(tgt_prog, prog->aux->attach_btf, btf_id);\n\ttr = bpf_trampoline_get(key, &tgt_info);\n\tif (!tr)\n\t\treturn -ENOMEM;\n\n\tprog->aux->dst_trampoline = tr;\n\treturn 0;\n}","target":0,"code_token_length":708,"total_token_length":944,"max_tokens_setting":1024}
+{"idx":234227,"func":"display_debug_macinfo (struct dwarf_section *section,\n\t\t       void *file ATTRIBUTE_UNUSED)\n{\n  unsigned char *start = section->start;\n  unsigned char *end = start + section->size;\n  unsigned char *curr = start;\n  enum dwarf_macinfo_record_type op;\n\n  introduce (section, false);\n\n  while (curr < end)\n    {\n      unsigned int lineno;\n      const unsigned char *string;\n\n      op = (enum dwarf_macinfo_record_type) *curr;\n      curr++;\n\n      switch (op)\n\t{\n\tcase DW_MACINFO_start_file:\n\t  {\n\t    unsigned int filenum;\n\n\t    READ_ULEB (lineno, curr, end);\n\t    READ_ULEB (filenum, curr, end);\n\t    printf (_(\" DW_MACINFO_start_file - lineno: %d filenum: %d\\n\"),\n\t\t    lineno, filenum);\n\t  }\n\t  break;\n\n\tcase DW_MACINFO_end_file:\n\t  printf (_(\" DW_MACINFO_end_file\\n\"));\n\t  break;\n\n\tcase DW_MACINFO_define:\n\t  READ_ULEB (lineno, curr, end);\n\t  string = curr;\n\t  curr += strnlen ((char *) string, end - string);\n\t  printf (_(\" DW_MACINFO_define - lineno : %d macro : %*s\\n\"),\n\t\t  lineno, (int) (curr - string), string);\n\t  if (curr < end)\n\t    curr++;\n\t  break;\n\n\tcase DW_MACINFO_undef:\n\t  READ_ULEB (lineno, curr, end);\n\t  string = curr;\n\t  curr += strnlen ((char *) string, end - string);\n\t  printf (_(\" DW_MACINFO_undef - lineno : %d macro : %*s\\n\"),\n\t\t  lineno, (int) (curr - string), string);\n\t  if (curr < end)\n\t    curr++;\n\t  break;\n\n\tcase DW_MACINFO_vendor_ext:\n\t  {\n\t    unsigned int constant;\n\n\t    READ_ULEB (constant, curr, end);\n\t    string = curr;\n\t    curr += strnlen ((char *) string, end - string);\n\t    printf (_(\" DW_MACINFO_vendor_ext - constant : %d string : %*s\\n\"),\n\t\t    constant, (int) (curr - string), string);\n\t    if (curr < end)\n\t      curr++;\n\t  }\n\t  break;\n\t}\n    }\n\n  return 1;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":430420,"func":"static int validate_vlan_from_nlattrs(const struct sw_flow_match *match,\n\t\t\t\t      u64 key_attrs, bool inner,\n\t\t\t\t      const struct nlattr **a, bool log)\n{\n\t__be16 tci = 0;\n\n\tif (!((key_attrs & (1 << OVS_KEY_ATTR_ETHERNET)) &&\n\t      (key_attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) &&\n\t       eth_type_vlan(nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE])))) {\n\t\t\/* Not a VLAN. *\/\n\t\treturn 0;\n\t}\n\n\tif (!((key_attrs & (1 << OVS_KEY_ATTR_VLAN)) &&\n\t      (key_attrs & (1 << OVS_KEY_ATTR_ENCAP)))) {\n\t\tOVS_NLERR(log, \"Invalid %s frame\", (inner) ? \"C-VLAN\" : \"VLAN\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (a[OVS_KEY_ATTR_VLAN])\n\t\ttci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);\n\n\tif (!(tci & htons(VLAN_CFI_MASK))) {\n\t\tif (tci) {\n\t\t\tOVS_NLERR(log, \"%s TCI does not have VLAN_CFI_MASK bit set.\",\n\t\t\t\t  (inner) ? \"C-VLAN\" : \"VLAN\");\n\t\t\treturn -EINVAL;\n\t\t} else if (nla_len(a[OVS_KEY_ATTR_ENCAP])) {\n\t\t\t\/* Corner case for truncated VLAN header. *\/\n\t\t\tOVS_NLERR(log, \"Truncated %s header has non-zero encap attribute.\",\n\t\t\t\t  (inner) ? \"C-VLAN\" : \"VLAN\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":437007,"func":"static int mcba_usb_start(struct mcba_priv *priv)\n{\n\tstruct net_device *netdev = priv->netdev;\n\tint err, i;\n\n\tmcba_init_ctx(priv);\n\n\tfor (i = 0; i < MCBA_MAX_RX_URBS; i++) {\n\t\tstruct urb *urb = NULL;\n\t\tu8 *buf;\n\t\tdma_addr_t buf_dma;\n\n\t\t\/* create a URB, and a buffer for it *\/\n\t\turb = usb_alloc_urb(0, GFP_KERNEL);\n\t\tif (!urb) {\n\t\t\terr = -ENOMEM;\n\t\t\tbreak;\n\t\t}\n\n\t\tbuf = usb_alloc_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE,\n\t\t\t\t\t GFP_KERNEL, &buf_dma);\n\t\tif (!buf) {\n\t\t\tnetdev_err(netdev, \"No memory left for USB buffer\\n\");\n\t\t\tusb_free_urb(urb);\n\t\t\terr = -ENOMEM;\n\t\t\tbreak;\n\t\t}\n\n\t\turb->transfer_dma = buf_dma;\n\n\t\tusb_fill_bulk_urb(urb, priv->udev,\n\t\t\t\t  usb_rcvbulkpipe(priv->udev, MCBA_USB_EP_IN),\n\t\t\t\t  buf, MCBA_USB_RX_BUFF_SIZE,\n\t\t\t\t  mcba_usb_read_bulk_callback, priv);\n\t\turb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;\n\t\tusb_anchor_urb(urb, &priv->rx_submitted);\n\n\t\terr = usb_submit_urb(urb, GFP_KERNEL);\n\t\tif (err) {\n\t\t\tusb_unanchor_urb(urb);\n\t\t\tusb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE,\n\t\t\t\t\t  buf, buf_dma);\n\t\t\tusb_free_urb(urb);\n\t\t\tbreak;\n\t\t}\n\n\t\tpriv->rxbuf[i] = buf;\n\t\tpriv->rxbuf_dma[i] = buf_dma;\n\n\t\t\/* Drop reference, USB core will take care of freeing it *\/\n\t\tusb_free_urb(urb);\n\t}\n\n\t\/* Did we submit any URBs *\/\n\tif (i == 0) {\n\t\tnetdev_warn(netdev, \"couldn't setup read URBs\\n\");\n\t\treturn err;\n\t}\n\n\t\/* Warn if we've couldn't transmit all the URBs *\/\n\tif (i < MCBA_MAX_RX_URBS)\n\t\tnetdev_warn(netdev, \"rx performance may be slow\\n\");\n\n\tmcba_usb_xmit_read_fw_ver(priv, MCBA_VER_REQ_USB);\n\tmcba_usb_xmit_read_fw_ver(priv, MCBA_VER_REQ_CAN);\n\n\treturn err;\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":343283,"func":"static int _dlmap_read(DLHandler * const dlhandler)\n{\n    ssize_t readnb;\n\n    if (dlhandler->dlmap_size > dlhandler->sizeof_map) {\n        abort();\n    }\n    if (dlhandler->dlmap_size <= (size_t) 0U) {\n        return 0;\n    }\n    if (dlhandler->dlmap_pos != dlhandler->dlmap_fdpos) {\n        do {\n            if (lseek(dlhandler->f, dlhandler->dlmap_pos,\n                      SEEK_SET) == (off_t) -1) {\n                dlhandler->dlmap_fdpos = (off_t) -1;\n                return -1;\n            }\n            dlhandler->dlmap_fdpos = dlhandler->dlmap_pos;\n            readnb = read(dlhandler->f, dlhandler->map, dlhandler->dlmap_size);\n        } while (readnb == (ssize_t) -1 && errno == EINTR);\n    } else {\n        do {\n            readnb = read(dlhandler->f, dlhandler->map, dlhandler->dlmap_size);\n        } while (readnb == (ssize_t) -1 && errno == EINTR);\n    }\n    if (readnb <= (ssize_t) 0) {\n        dlhandler->dlmap_fdpos = (off_t) -1;\n        return -1;\n    }\n    if (readnb != (ssize_t) dlhandler->dlmap_size) {\n        dlhandler->dlmap_fdpos = (off_t) -1;\n    } else {\n        dlhandler->dlmap_fdpos += (off_t) readnb;\n    }\n    return 0;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":339718,"func":"static Bigint *lshift(Bigint *b, int k)\n{\n\tint i, k1, n, n1;\n\tBigint *b1;\n\tULong *x, *x1, *xe, z;\n\n#ifdef Pack_32\n\tn = k >> 5;\n#else\n\tn = k >> 4;\n#endif\n\tk1 = b->k;\n\tn1 = n + b->wds + 1;\n\tfor(i = b->maxwds; n1 > i; i <<= 1) {\n\t\tk1++;\n\t}\n\tb1 = Balloc(k1);\n\tx1 = b1->x;\n\tfor(i = 0; i < n; i++) {\n\t\t*x1++ = 0;\n\t}\n\tx = b->x;\n\txe = x + b->wds;\n#ifdef Pack_32\n\tif (k &= 0x1f) {\n\t\tk1 = 32 - k;\n\t\tz = 0;\n\t\tdo {\n\t\t\t*x1++ = *x << k | z;\n\t\t\tz = *x++ >> k1;\n\t\t}\n\t\twhile(x < xe);\n\t\tif ((*x1 = z)) {\n\t\t\t++n1;\n\t\t}\n\t}\n#else\n\tif (k &= 0xf) {\n\t\tk1 = 16 - k;\n\t\tz = 0;\n\t\tdo {\n\t\t\t*x1++ = *x << k  & 0xffff | z;\n\t\t\tz = *x++ >> k1;\n\t\t}\n\t\twhile(x < xe);\n\t\tif (*x1 = z) {\n\t\t\t++n1;\n\t\t}\n\t}\n#endif\n\telse do\n\t\t*x1++ = *x++;\n\twhile(x < xe);\n\tb1->wds = n1 - 1;\n\tBfree(b);\n\treturn b1;\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":281144,"func":"static void xfrm_audit_common_policyinfo(struct xfrm_policy *xp,\n\t\t\t\t\t struct audit_buffer *audit_buf)\n{\n\tstruct xfrm_sec_ctx *ctx = xp->security;\n\tstruct xfrm_selector *sel = &xp->selector;\n\n\tif (ctx)\n\t\taudit_log_format(audit_buf, \" sec_alg=%u sec_doi=%u sec_obj=%s\",\n\t\t\t\t ctx->ctx_alg, ctx->ctx_doi, ctx->ctx_str);\n\n\tswitch (sel->family) {\n\tcase AF_INET:\n\t\taudit_log_format(audit_buf, \" src=%pI4\", &sel->saddr.a4);\n\t\tif (sel->prefixlen_s != 32)\n\t\t\taudit_log_format(audit_buf, \" src_prefixlen=%d\",\n\t\t\t\t\t sel->prefixlen_s);\n\t\taudit_log_format(audit_buf, \" dst=%pI4\", &sel->daddr.a4);\n\t\tif (sel->prefixlen_d != 32)\n\t\t\taudit_log_format(audit_buf, \" dst_prefixlen=%d\",\n\t\t\t\t\t sel->prefixlen_d);\n\t\tbreak;\n\tcase AF_INET6:\n\t\taudit_log_format(audit_buf, \" src=%pI6\", sel->saddr.a6);\n\t\tif (sel->prefixlen_s != 128)\n\t\t\taudit_log_format(audit_buf, \" src_prefixlen=%d\",\n\t\t\t\t\t sel->prefixlen_s);\n\t\taudit_log_format(audit_buf, \" dst=%pI6\", sel->daddr.a6);\n\t\tif (sel->prefixlen_d != 128)\n\t\t\taudit_log_format(audit_buf, \" dst_prefixlen=%d\",\n\t\t\t\t\t sel->prefixlen_d);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":326921,"func":"static u32 vidtv_s302m_write_frame(struct vidtv_encoder *e,\n\t\t\t\t   u16 sample)\n{\n\tstruct vidtv_s302m_ctx *ctx = e->ctx;\n\tstruct vidtv_s302m_frame_16 f = {};\n\tu32 nbytes = 0;\n\n\t\/* from ffmpeg: see s302enc.c *\/\n\n\tu8 vucf = ctx->frame_index == 0 ? 0x10 : 0;\n\n\tf.data[0] = sample & 0xFF;\n\tf.data[1] = (sample & 0xFF00) >>  8;\n\tf.data[2] = ((sample & 0x0F)  <<  4) | vucf;\n\tf.data[3] = (sample & 0x0FF0) >>  4;\n\tf.data[4] = (sample & 0xF000) >> 12;\n\n\tf.data[0] = reverse[f.data[0]];\n\tf.data[1] = reverse[f.data[1]];\n\tf.data[2] = reverse[f.data[2]];\n\tf.data[3] = reverse[f.data[3]];\n\tf.data[4] = reverse[f.data[4]];\n\n\tnbytes += vidtv_memcpy(e->encoder_buf,\n\t\t\t       e->encoder_buf_offset,\n\t\t\t       VIDTV_S302M_BUF_SZ,\n\t\t\t       &f,\n\t\t\t       sizeof(f));\n\n\te->encoder_buf_offset += nbytes;\n\n\tctx->frame_index++;\n\tif (ctx->frame_index >= S302M_BLOCK_SZ)\n\t\tctx->frame_index = 0;\n\n\treturn nbytes;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":253532,"func":"static int smb3_fiemap(struct cifs_tcon *tcon,\n\t\t       struct cifsFileInfo *cfile,\n\t\t       struct fiemap_extent_info *fei, u64 start, u64 len)\n{\n\tunsigned int xid;\n\tstruct file_allocated_range_buffer in_data, *out_data;\n\tu32 out_data_len;\n\tint i, num, rc, flags, last_blob;\n\tu64 next;\n\n\trc = fiemap_prep(d_inode(cfile->dentry), fei, start, &len, 0);\n\tif (rc)\n\t\treturn rc;\n\n\txid = get_xid();\n again:\n\tin_data.file_offset = cpu_to_le64(start);\n\tin_data.length = cpu_to_le64(len);\n\n\trc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,\n\t\t\tcfile->fid.volatile_fid,\n\t\t\tFSCTL_QUERY_ALLOCATED_RANGES, true,\n\t\t\t(char *)&in_data, sizeof(in_data),\n\t\t\t1024 * sizeof(struct file_allocated_range_buffer),\n\t\t\t(char **)&out_data, &out_data_len);\n\tif (rc == -E2BIG) {\n\t\tlast_blob = 0;\n\t\trc = 0;\n\t} else\n\t\tlast_blob = 1;\n\tif (rc)\n\t\tgoto out;\n\n\tif (out_data_len && out_data_len < sizeof(struct file_allocated_range_buffer)) {\n\t\trc = -EINVAL;\n\t\tgoto out;\n\t}\n\tif (out_data_len % sizeof(struct file_allocated_range_buffer)) {\n\t\trc = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tnum = out_data_len \/ sizeof(struct file_allocated_range_buffer);\n\tfor (i = 0; i < num; i++) {\n\t\tflags = 0;\n\t\tif (i == num - 1 && last_blob)\n\t\t\tflags |= FIEMAP_EXTENT_LAST;\n\n\t\trc = fiemap_fill_next_extent(fei,\n\t\t\t\tle64_to_cpu(out_data[i].file_offset),\n\t\t\t\tle64_to_cpu(out_data[i].file_offset),\n\t\t\t\tle64_to_cpu(out_data[i].length),\n\t\t\t\tflags);\n\t\tif (rc < 0)\n\t\t\tgoto out;\n\t\tif (rc == 1) {\n\t\t\trc = 0;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tif (!last_blob) {\n\t\tnext = le64_to_cpu(out_data[num - 1].file_offset) +\n\t\t  le64_to_cpu(out_data[num - 1].length);\n\t\tlen = len - (next - start);\n\t\tstart = next;\n\t\tgoto again;\n\t}\n\n out:\n\tfree_xid(xid);\n\tkfree(out_data);\n\treturn rc;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":248755,"func":"static void remove_expired(struct CookieInfo *cookies)\n{\n  struct Cookie *co, *nx;\n  curl_off_t now = (curl_off_t)time(NULL);\n  unsigned int i;\n\n  \/*\n   * If the earliest expiration timestamp in the jar is in the future we can\n   * skip scanning the whole jar and instead exit early as there won't be any\n   * cookies to evict.  If we need to evict however, reset the next_expiration\n   * counter in order to track the next one. In case the recorded first\n   * expiration is the max offset, then perform the safe fallback of checking\n   * all cookies.\n   *\/\n  if(now < cookies->next_expiration &&\n      cookies->next_expiration != CURL_OFF_T_MAX)\n    return;\n  else\n    cookies->next_expiration = CURL_OFF_T_MAX;\n\n  for(i = 0; i < COOKIE_HASH_SIZE; i++) {\n    struct Cookie *pv = NULL;\n    co = cookies->cookies[i];\n    while(co) {\n      nx = co->next;\n      if(co->expires && co->expires < now) {\n        if(!pv) {\n          cookies->cookies[i] = co->next;\n        }\n        else {\n          pv->next = co->next;\n        }\n        cookies->numcookies--;\n        freecookie(co);\n      }\n      else {\n        \/*\n         * If this cookie has an expiration timestamp earlier than what we've\n         * seen so far then record it for the next round of expirations.\n         *\/\n        if(co->expires && co->expires < cookies->next_expiration)\n          cookies->next_expiration = co->expires;\n        pv = co;\n      }\n      co = nx;\n    }\n  }\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":274720,"func":"callbacks_display_object_properties_clicked (GtkButton *button, gpointer user_data)\n{\n\tgint index = callbacks_get_selected_row_index ();\n\tguint i;\n\n\tif (index < 0 || selection_length (&screen.selectionInfo) == 0) {\n\t\tinterface_show_alert_dialog(_(\"No object is currently selected\"),\n\t\t\t_(\"Objects must be selected using the pointer tool \"\n\t\t\t\"before you can view the object properties.\"),\n\t\t\tFALSE, NULL);\n\t\treturn;\n\t}\n\t\n\tfor (i = 0; i < selection_length (&screen.selectionInfo); i++){\n\t\tgerbv_selection_item_t sItem =\n\t\t\tselection_get_item_by_index (&screen.selectionInfo, i);\n\n\t\tgerbv_net_t *net = sItem.net;\n\t\tgerbv_image_t *image = sItem.image;\n\n\t\tif (net->interpolation == GERBV_INTERPOLATION_PAREA_START) {\n\t\t\t\/* Spacing for a pretty display *\/\n\t\t\tif (i != 0)\n\t\t\t\tg_message (\" \");\n\n\t\t\tg_message (_(\"Object type: Polygon\"));\n\t\t\tparea_report (net, image, mainProject);\n\t\t\tnet_layer_file_report (net, image, mainProject);\n\t\t} else {\n\t\t\tswitch (net->aperture_state) {\n\n\t\t\tcase GERBV_APERTURE_STATE_ON:\n\t\t\tcase GERBV_APERTURE_STATE_FLASH:\n\t\t\t\t\/* Spacing for a pretty display *\/\n\t\t\t\tif (i != 0)\n\t\t\t\t\tg_message (\" \");\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\taperture_state_report (net, image, mainProject);\n\t\t}\n\t}\n\t\/* Use separator for different report requests *\/\n\tg_message (\"---------------------------------------\");\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":247540,"func":"void configureServerAndExpiredClientCertificate(\n    envoy::config::listener::v3::Listener& listener,\n    envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext& client,\n    const OptionalServerConfig& server_config) {\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"));\n\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  if (server_config.trusted_ca.has_value()) {\n    server_validation_ctx->mutable_trusted_ca()->set_filename(\n        TestEnvironment::substitute(server_config.trusted_ca.value()));\n  } else {\n    server_validation_ctx->mutable_trusted_ca()->set_filename(TestEnvironment::substitute(\n        \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"));\n  }\n  if (server_config.allow_expired_cert.has_value()) {\n    server_validation_ctx->set_allow_expired_certificate(server_config.allow_expired_cert.value());\n  }\n  if (server_config.cert_hash.has_value()) {\n    server_validation_ctx->add_verify_certificate_hash(server_config.cert_hash.value());\n  }\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/expired_san_uri_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/expired_san_uri_key.pem\"));\n}","target":0,"code_token_length":514,"total_token_length":750,"max_tokens_setting":1024}
+{"idx":230624,"func":"void derive_combined_bipredictive_merging_candidates(const base_context* ctx,\n                                                     const slice_segment_header* shdr,\n                                                     PBMotion* inout_mergeCandList,\n                                                     int* inout_numMergeCand,\n                                                     int maxCandidates)\n{\n  if (*inout_numMergeCand>1 && *inout_numMergeCand < maxCandidates) {\n    int numOrigMergeCand = *inout_numMergeCand;\n\n    int numInputMergeCand = *inout_numMergeCand;\n    int combIdx = 0;\n    uint8_t combStop = false;\n\n    while (!combStop) {\n      int l0CandIdx = table_8_19[0][combIdx];\n      int l1CandIdx = table_8_19[1][combIdx];\n\n      if (l0CandIdx >= numInputMergeCand ||\n          l1CandIdx >= numInputMergeCand) {\n        assert(false); \/\/ bitstream error -> TODO: conceal error\n      }\n\n      PBMotion& l0Cand = inout_mergeCandList[l0CandIdx];\n      PBMotion& l1Cand = inout_mergeCandList[l1CandIdx];\n\n      logtrace(LogMotion,\"add bipredictive merging candidate (combIdx:%d)\\n\",combIdx);\n      logtrace(LogMotion,\"l0Cand:\\n\"); logmvcand(l0Cand);\n      logtrace(LogMotion,\"l1Cand:\\n\"); logmvcand(l1Cand);\n\n      const de265_image* img0 = l0Cand.predFlag[0] ? ctx->get_image(shdr->RefPicList[0][l0Cand.refIdx[0]]) : NULL;\n      const de265_image* img1 = l1Cand.predFlag[1] ? ctx->get_image(shdr->RefPicList[1][l1Cand.refIdx[1]]) : NULL;\n\n      if (l0Cand.predFlag[0] && !img0) {\n        return; \/\/ TODO error\n      }\n\n      if (l1Cand.predFlag[1] && !img1) {\n        return; \/\/ TODO error\n      }\n\n      if (l0Cand.predFlag[0] && l1Cand.predFlag[1] &&\n          (img0->PicOrderCntVal != img1->PicOrderCntVal     ||\n           l0Cand.mv[0].x != l1Cand.mv[1].x ||\n           l0Cand.mv[0].y != l1Cand.mv[1].y)) {\n        PBMotion& p = inout_mergeCandList[ *inout_numMergeCand ];\n        p.refIdx[0] = l0Cand.refIdx[0];\n        p.refIdx[1] = l1Cand.refIdx[1];\n        p.predFlag[0] = l0Cand.predFlag[0];\n        p.predFlag[1] = l1Cand.predFlag[1];\n        p.mv[0] = l0Cand.mv[0];\n        p.mv[1] = l1Cand.mv[1];\n        (*inout_numMergeCand)++;\n\n        logtrace(LogMotion,\"result:\\n\");\n        logmvcand(p);\n      }\n\n      combIdx++;\n      if (combIdx == numOrigMergeCand*(numOrigMergeCand-1) ||\n          *inout_numMergeCand == maxCandidates) {\n        combStop = true;\n      }\n    }\n  }\n}","target":0,"code_token_length":760,"total_token_length":996,"max_tokens_setting":1024}
+{"idx":513148,"func":"static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc,\n                                     uint state_mask= PLUGIN_IS_READY |\n                                                      PLUGIN_IS_UNINITIALIZED |\n                                                      PLUGIN_IS_DELETED)\n{\n  st_plugin_int *pi= plugin_ref_to_int(rc);\n  DBUG_ENTER(\"intern_plugin_lock\");\n\n  mysql_mutex_assert_owner(&LOCK_plugin);\n\n  if (pi->state & state_mask)\n  {\n    plugin_ref plugin;\n#ifdef DBUG_OFF\n    \/*\n      In optimized builds we don't do reference counting for built-in\n      (plugin->plugin_dl == 0) plugins.\n    *\/\n    if (!pi->plugin_dl)\n      DBUG_RETURN(pi);\n\n    plugin= pi;\n#else\n    \/*\n      For debugging, we do an additional malloc which allows the\n      memory manager and\/or valgrind to track locked references and\n      double unlocks to aid resolving reference counting problems.\n    *\/\n    if (!(plugin= (plugin_ref) my_malloc(sizeof(pi), MYF(MY_WME))))\n      DBUG_RETURN(NULL);\n\n    *plugin= pi;\n#endif\n    pi->ref_count++;\n    DBUG_PRINT(\"lock\",(\"thd: %p  plugin: \\\"%s\\\" LOCK ref_count: %d\",\n                       current_thd, pi->name.str, pi->ref_count));\n\n    if (lex)\n      insert_dynamic(&lex->plugins, (uchar*)&plugin);\n    DBUG_RETURN(plugin);\n  }\n  DBUG_RETURN(NULL);\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":196276,"func":"lsquic_qeh_settings (struct qpack_enc_hdl *qeh, unsigned max_table_size,\n             unsigned dyn_table_size, unsigned max_risked_streams, int server)\n{\n    enum lsqpack_enc_opts enc_opts;\n\n    assert(qeh->qeh_flags & QEH_INITIALIZED);\n\n    if (qeh->qeh_flags & QEH_HAVE_SETTINGS)\n    {\n        LSQ_WARN(\"settings already set\");\n        return -1;\n    }\n\n    enc_opts = LSQPACK_ENC_OPT_STAGE_2\n             | (server ? LSQPACK_ENC_OPT_SERVER : 0);\n    qeh->qeh_tsu_sz = sizeof(qeh->qeh_tsu_buf);\n    if (0 != lsqpack_enc_init(&qeh->qeh_encoder, (void *) qeh->qeh_conn,\n                max_table_size, dyn_table_size, max_risked_streams, enc_opts,\n                qeh->qeh_tsu_buf, &qeh->qeh_tsu_sz))\n    {\n        LSQ_INFO(\"could not initialize QPACK encoder\");\n        return -1;\n    }\n    LSQ_DEBUG(\"%zu-byte post-init TSU\", qeh->qeh_tsu_sz);\n    qeh->qeh_flags |= QEH_HAVE_SETTINGS;\n    qeh->qeh_max_prefix_size =\n                        lsqpack_enc_header_block_prefix_size(&qeh->qeh_encoder);\n    LSQ_DEBUG(\"have settings: max table size=%u; dyn table size=%u; max risked \"\n        \"streams=%u\", max_table_size, dyn_table_size, max_risked_streams);\n    if (qeh->qeh_enc_sm_out)\n        qeh_begin_out(qeh);\n    return 0;\n}","target":1,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":299891,"func":"readconf_find_option(void *p)\n{\nint i;\nrouter_instance *r;\ntransport_instance *t;\n\nfor (i = 0; i < optionlist_config_size; i++)\n  if (p == optionlist_config[i].value) return US optionlist_config[i].name;\n\nfor (r = routers; r != NULL; r = r->next)\n  {\n  router_info *ri = r->info;\n  for (i = 0; i < ri->options_count[0]; i++)\n    {\n    if ((ri->options[i].type & opt_mask) != opt_stringptr) continue;\n    if (p == (char *)(r->options_block) + (long int)(ri->options[i].value))\n      return US ri->options[i].name;\n    }\n  }\n\nfor (t = transports; t != NULL; t = t->next)\n  {\n  transport_info *ti = t->info;\n  for (i = 0; i < ti->options_count[0]; i++)\n    {\n    if ((ti->options[i].type & opt_mask) != opt_stringptr) continue;\n    if (p == (char *)(t->options_block) + (long int)(ti->options[i].value))\n      return US ti->options[i].name;\n    }\n  }\n\nreturn US\"\";\n}","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":249982,"func":"GF_Err gf_isom_write_compressed_box(GF_ISOFile *mov, GF_Box *root_box, u32 repl_type, GF_BitStream *bs, u32 *box_csize)\n{\n#ifdef GPAC_DISABLE_ZLIB\n\treturn GF_NOT_SUPPORTED;\n#else\n\tGF_Err e;\n\tGF_BitStream *comp_bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\te = gf_isom_box_write(root_box, comp_bs);\n\n\tif (!e) {\n\t\tu8 *box_data;\n\t\tu32 box_size, comp_size;\n\n\t\tif (box_csize)\n\t\t\t*box_csize = (u32) root_box->size;\n\n\t\tgf_bs_get_content(comp_bs, &box_data, &box_size);\n\t\tgf_gz_compress_payload_ex(&box_data, box_size, &comp_size, 8, GF_TRUE, NULL);\n\t\tif (mov->force_compress || (comp_size + COMP_BOX_COST_BYTES < box_size)) {\n\t\t\tif (bs) {\n\t\t\t\tgf_bs_write_u32(bs, comp_size+8);\n\t\t\t\tgf_bs_write_u32(bs, repl_type);\n\t\t\t\tgf_bs_write_data(bs, box_data, comp_size);\n\t\t\t}\n\t\t\tif (box_csize)\n\t\t\t\t*box_csize = comp_size + COMP_BOX_COST_BYTES;\n\t\t} else if (bs) {\n\t\t\tgf_bs_write_data(bs, box_data, box_size);\n\t\t}\n\t\tgf_free(box_data);\n\t}\n\tgf_bs_del(comp_bs);\n\treturn e;\n#endif \/*GPAC_DISABLE_ZLIB*\/\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":270767,"func":"static int check_passwd(unsigned char *passwd, size_t length)\n{\n\tstruct digest *d = NULL;\n\tunsigned char *passwd1_sum;\n\tunsigned char *passwd2_sum;\n\tint ret = 0;\n\tint hash_len;\n\n\tif (IS_ENABLED(CONFIG_PASSWD_CRYPTO_PBKDF2)) {\n\t\thash_len = PBKDF2_LENGTH;\n\t} else {\n\t\td = digest_alloc(PASSWD_SUM);\n\t\tif (!d) {\n\t\t\tpr_err(\"No such digest: %s\\n\",\n\t\t\t       PASSWD_SUM ? PASSWD_SUM : \"NULL\");\n\t\t\treturn -ENOENT;\n\t\t}\n\n\t\thash_len = digest_length(d);\n\t}\n\n\tpasswd1_sum = calloc(hash_len * 2, sizeof(unsigned char));\n\tif (!passwd1_sum)\n\t\treturn -ENOMEM;\n\n\tpasswd2_sum = passwd1_sum + hash_len;\n\n\tif (is_passwd_env_enable())\n\t\tret = read_env_passwd(passwd2_sum, hash_len);\n\telse if (is_passwd_default_enable())\n\t\tret = read_default_passwd(passwd2_sum, hash_len);\n\telse\n\t\tret = -EINVAL;\n\n\tif (ret < 0)\n\t\tgoto err;\n\n\tif (IS_ENABLED(CONFIG_PASSWD_CRYPTO_PBKDF2)) {\n\t\tchar *key = passwd2_sum + PBKDF2_SALT_LEN;\n\t\tchar *salt = passwd2_sum;\n\t\tint keylen = PBKDF2_LENGTH - PBKDF2_SALT_LEN;\n\n\t\tret = pkcs5_pbkdf2_hmac_sha1(passwd, length, salt,\n\t\t\tPBKDF2_SALT_LEN, PBKDF2_COUNT, keylen, passwd1_sum);\n\t\tif (ret)\n\t\t\tgoto err;\n\n\t\tif (!crypto_memneq(passwd1_sum, key, keylen))\n\t\t\tret = 1;\n\t} else {\n\t\tret = digest_digest(d, passwd, length, passwd1_sum);\n\n\t\tif (ret)\n\t\t\tgoto err;\n\n\t\tif (!crypto_memneq(passwd1_sum, passwd2_sum, hash_len))\n\t\t\tret = 1;\n\t}\n\nerr:\n\tfree(passwd1_sum);\n\tdigest_free(d);\n\n\treturn ret;\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":238823,"func":"cmdline_search_stat(\n    int\t\tdirc,\n    pos_T\t*pos,\n    pos_T\t*cursor_pos,\n    int\t\tshow_top_bot_msg,\n    char_u\t*msgbuf,\n    int\t\trecompute,\n    int\t\tmaxcount,\n    long\ttimeout)\n{\n    searchstat_T stat;\n\n    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,\n\t\t\t\t\t\t\t\t      timeout);\n    if (stat.cur > 0)\n    {\n\tchar\tt[SEARCH_STAT_BUF_LEN];\n\tsize_t\tlen;\n\n#ifdef FEAT_RIGHTLEFT\n\tif (curwin->w_p_rl && *curwin->w_p_rlc == 's')\n\t{\n\t    if (stat.incomplete == 1)\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[?\/??]\");\n\t    else if (stat.cnt > maxcount && stat.cur > maxcount)\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[>%d\/>%d]\",\n\t\t\t\t\t\t\t   maxcount, maxcount);\n\t    else if (stat.cnt > maxcount)\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[>%d\/%d]\",\n\t\t\t\t\t\t\t   maxcount, stat.cur);\n\t    else\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[%d\/%d]\",\n\t\t\t\t\t\t\t   stat.cnt, stat.cur);\n\t}\n\telse\n#endif\n\t{\n\t    if (stat.incomplete == 1)\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[?\/??]\");\n\t    else if (stat.cnt > maxcount && stat.cur > maxcount)\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[>%d\/>%d]\",\n\t\t\t\t\t\t\t   maxcount, maxcount);\n\t    else if (stat.cnt > maxcount)\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[%d\/>%d]\",\n\t\t\t\t\t\t\t   stat.cur, maxcount);\n\t    else\n\t\tvim_snprintf(t, SEARCH_STAT_BUF_LEN, \"[%d\/%d]\",\n\t\t\t\t\t\t\t   stat.cur, stat.cnt);\n\t}\n\n\tlen = STRLEN(t);\n\tif (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN)\n\t{\n\t    mch_memmove(t + 2, t, len);\n\t    t[0] = 'W';\n\t    t[1] = ' ';\n\t    len += 2;\n\t}\n\n\tmch_memmove(msgbuf + STRLEN(msgbuf) - len, t, len);\n\tif (dirc == '?' && stat.cur == maxcount + 1)\n\t    stat.cur = -1;\n\n\t\/\/ keep the message even after redraw, but don't put in history\n\tmsg_hist_off = TRUE;\n\tgive_warning(msgbuf, FALSE);\n\tmsg_hist_off = FALSE;\n    }\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":413680,"func":"static char *is_string_at(RCore *core, ut64 addr, int *olen) {\n\tut8 rstr[128] = {0};\n\tint ret = 0, len = 0;\n\tut8 *str = calloc (256, 1);\n\tif (!str) {\n\t\tif (olen) {\n\t\t\t*olen = 0;\n\t\t}\n\t\treturn NULL;\n\t}\n\tr_io_read_at (core->io, addr, str, 255);\n\n\tstr[255] = 0;\n\tif (is_string (str, 256, &len)) {\n\t\tif (olen) {\n\t\t\t*olen = len;\n\t\t}\n\t\treturn (char*) str;\n\t}\n\n\tut64 *cstr = (ut64*)str;\n\tut64 lowptr = cstr[0];\n\tif (lowptr >> 32) { \/\/ must be pa mode only\n\t\tlowptr &= UT32_MAX;\n\t}\n\t\/\/ cstring\n\tif (cstr[0] == 0 && cstr[1] < 0x1000) {\n\t\tut64 ptr = cstr[2];\n\t\tif (ptr >> 32) { \/\/ must be pa mode only\n\t\t\tptr &= UT32_MAX;\n\t\t}\n\t\tif (ptr) {\n\t\t\tr_io_read_at (core->io, ptr, rstr, sizeof (rstr));\n\t\t\trstr[127] = 0;\n\t\t\tret = is_string (rstr, 128, &len);\n\t\t\tif (ret) {\n\t\t\t\tstrcpy ((char*) str, (char*) rstr);\n\t\t\t\tif (olen) {\n\t\t\t\t\t*olen = len;\n\t\t\t\t}\n\t\t\t\treturn (char*) str;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t\/\/ pstring\n\t\tr_io_read_at (core->io, lowptr, rstr, sizeof (rstr));\n\t\trstr[127] = 0;\n\t\tret = is_string (rstr, sizeof (rstr), &len);\n\t\tif (ret) {\n\t\t\tstrcpy ((char*) str, (char*) rstr);\n\t\t\tif (olen) {\n\t\t\t\t*olen = len;\n\t\t\t}\n\t\t\treturn (char*) str;\n\t\t}\n\t}\n\t\/\/ check if current section have no exec bit\n\tif (len < 1) {\n\t\tret = 0;\n\t\tfree (str);\n\t\tlen = -1;\n\t} else if (olen) {\n\t\t*olen = len;\n\t}\n\t\/\/ NOTE: coverity says that ret is always 0 here, so str is dead code\n\treturn ret? (char *)str: NULL;\n}","target":0,"code_token_length":580,"total_token_length":816,"max_tokens_setting":1024}
+{"idx":436128,"func":"\nstatic int io_sq_thread(void *data)\n{\n\tstruct io_sq_data *sqd = data;\n\tstruct io_ring_ctx *ctx;\n\tunsigned long timeout = 0;\n\tchar buf[TASK_COMM_LEN];\n\tDEFINE_WAIT(wait);\n\n\tsnprintf(buf, sizeof(buf), \"iou-sqp-%d\", sqd->task_pid);\n\tset_task_comm(current, buf);\n\n\tif (sqd->sq_cpu != -1)\n\t\tset_cpus_allowed_ptr(current, cpumask_of(sqd->sq_cpu));\n\telse\n\t\tset_cpus_allowed_ptr(current, cpu_online_mask);\n\tcurrent->flags |= PF_NO_SETAFFINITY;\n\n\tmutex_lock(&sqd->lock);\n\twhile (1) {\n\t\tbool cap_entries, sqt_spin = false;\n\n\t\tif (io_sqd_events_pending(sqd) || signal_pending(current)) {\n\t\t\tif (io_sqd_handle_event(sqd))\n\t\t\t\tbreak;\n\t\t\ttimeout = jiffies + sqd->sq_thread_idle;\n\t\t}\n\n\t\tcap_entries = !list_is_singular(&sqd->ctx_list);\n\t\tlist_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {\n\t\t\tint ret = __io_sq_thread(ctx, cap_entries);\n\n\t\t\tif (!sqt_spin && (ret > 0 || !list_empty(&ctx->iopoll_list)))\n\t\t\t\tsqt_spin = true;\n\t\t}\n\t\tif (io_run_task_work())\n\t\t\tsqt_spin = true;\n\n\t\tif (sqt_spin || !time_after(jiffies, timeout)) {\n\t\t\tcond_resched();\n\t\t\tif (sqt_spin)\n\t\t\t\ttimeout = jiffies + sqd->sq_thread_idle;\n\t\t\tcontinue;\n\t\t}\n\n\t\tprepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE);\n\t\tif (!io_sqd_events_pending(sqd) && !current->task_works) {\n\t\t\tbool needs_sched = true;\n\n\t\t\tlist_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {\n\t\t\t\tio_ring_set_wakeup_flag(ctx);\n\n\t\t\t\tif ((ctx->flags & IORING_SETUP_IOPOLL) &&\n\t\t\t\t    !list_empty_careful(&ctx->iopoll_list)) {\n\t\t\t\t\tneeds_sched = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (io_sqring_entries(ctx)) {\n\t\t\t\t\tneeds_sched = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (needs_sched) {\n\t\t\t\tmutex_unlock(&sqd->lock);\n\t\t\t\tschedule();\n\t\t\t\tmutex_lock(&sqd->lock);\n\t\t\t}\n\t\t\tlist_for_each_entry(ctx, &sqd->ctx_list, sqd_list)\n\t\t\t\tio_ring_clear_wakeup_flag(ctx);\n\t\t}\n\n\t\tfinish_wait(&sqd->wait, &wait);\n\t\ttimeout = jiffies + sqd->sq_thread_idle;\n\t}\n\n\tio_uring_cancel_generic(true, sqd);\n\tsqd->thread = NULL;\n\tlist_for_each_entry(ctx, &sqd->ctx_list, sqd_list)\n\t\tio_ring_set_wakeup_flag(ctx);\n\tio_run_task_work();\n\tmutex_unlock(&sqd->lock);\n\n\tcomplete(&sqd->exited);\n\tdo_exit(0);","target":0,"code_token_length":645,"total_token_length":881,"max_tokens_setting":1024}
+{"idx":301475,"func":"soundfold_find(slang_T *slang, char_u *word)\n{\n    idx_T\tarridx = 0;\n    int\t\tlen;\n    int\t\twlen = 0;\n    int\t\tc;\n    char_u\t*ptr = word;\n    char_u\t*byts;\n    idx_T\t*idxs;\n    int\t\twordnr = 0;\n\n    byts = slang->sl_sbyts;\n    idxs = slang->sl_sidxs;\n\n    for (;;)\n    {\n\t\/\/ First byte is the number of possible bytes.\n\tlen = byts[arridx++];\n\n\t\/\/ If the first possible byte is a zero the word could end here.\n\t\/\/ If the word ends we found the word.  If not skip the NUL bytes.\n\tc = ptr[wlen];\n\tif (byts[arridx] == NUL)\n\t{\n\t    if (c == NUL)\n\t\tbreak;\n\n\t    \/\/ Skip over the zeros, there can be several.\n\t    while (len > 0 && byts[arridx] == NUL)\n\t    {\n\t\t++arridx;\n\t\t--len;\n\t    }\n\t    if (len == 0)\n\t\treturn -1;    \/\/ no children, word should have ended here\n\t    ++wordnr;\n\t}\n\n\t\/\/ If the word ends we didn't find it.\n\tif (c == NUL)\n\t    return -1;\n\n\t\/\/ Perform a binary search in the list of accepted bytes.\n\tif (c == TAB)\t    \/\/ <Tab> is handled like <Space>\n\t    c = ' ';\n\twhile (byts[arridx] < c)\n\t{\n\t    \/\/ The word count is in the first idxs[] entry of the child.\n\t    wordnr += idxs[idxs[arridx]];\n\t    ++arridx;\n\t    if (--len == 0)\t\/\/ end of the bytes, didn't find it\n\t\treturn -1;\n\t}\n\tif (byts[arridx] != c)\t\/\/ didn't find the byte\n\t    return -1;\n\n\t\/\/ Continue at the child (if there is one).\n\tarridx = idxs[arridx];\n\t++wlen;\n\n\t\/\/ One space in the good word may stand for several spaces in the\n\t\/\/ checked word.\n\tif (c == ' ')\n\t    while (ptr[wlen] == ' ' || ptr[wlen] == TAB)\n\t\t++wlen;\n    }\n\n    return wordnr;\n}","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":219931,"func":"Status ConstantFolding::EvaluateOneFoldable(const NodeDef& node,\n                                            std::vector<NodeDef>* outputs,\n                                            bool* result_too_large) {\n  TensorVector inputs;\n  TensorVector output_tensors;\n  auto inputs_cleanup = gtl::MakeCleanup([&inputs, &output_tensors] {\n    for (const auto& input : inputs) {\n      delete input.tensor;\n    }\n    for (const auto& output : output_tensors) {\n      if (output.tensor) {\n        delete output.tensor;\n      }\n    }\n  });\n\n  size_t total_inputs_size = 0;\n  for (const auto& input : node.input()) {\n    const TensorId input_tensor = ParseTensorName(input);\n    if (input_tensor.index() < 0) {\n      \/\/ Control dependency\n      break;\n    }\n    const NodeDef* input_node = node_map_->GetNode(input);\n    if (!IsReallyConstant(*input_node)) {\n      return Status(error::INVALID_ARGUMENT,\n                    strings::StrCat(\"Can't fold \", node.name(), \", its \", input,\n                                    \" isn't constant\"));\n    }\n    TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, \"value\"));\n    const TensorProto& raw_val = input_node->attr().at(\"value\").tensor();\n    if (raw_val.dtype() == DT_INVALID) {\n      return Status(\n          error::INVALID_ARGUMENT,\n          strings::StrCat(\"A tensor in the input node, with TensorId of \",\n                          input_tensor.ToString(),\n                          \" has a dtype of DT_INVALID.\"));\n    }\n    if (IsRefType(raw_val.dtype())) {\n      return errors::InvalidArgument(\n          \"Not allowed to construct a tensor with reference dtype, got \",\n          DataTypeString(raw_val.dtype()));\n    }\n    Tensor* value = new Tensor(raw_val.dtype(), raw_val.tensor_shape());\n    if (!value->FromProto(raw_val)) {\n      delete (value);\n      return errors::InvalidArgument(\"Unable to make Tensor from proto for \",\n                                     node.name(), \" with shape \",\n                                     raw_val.tensor_shape().DebugString());\n    }\n    inputs.emplace_back(value);\n    total_inputs_size += value->TotalBytes();\n  }\n\n  TF_RETURN_IF_ERROR(EvaluateNode(node, inputs, &output_tensors));\n  if (output_tensors.empty()) {\n    return Status(error::INVALID_ARGUMENT, \"Expected at least one output.\");\n  }\n\n  outputs->resize(output_tensors.size());\n  for (size_t i = 0; i < output_tensors.size(); i++) {\n    string node_name = OptimizedNodeName(node, \"-folded\");\n    if (output_tensors.size() > 1) {\n      node_name = strings::StrCat(node_name, \"-\", i);\n    }\n    if (output_tensors[i].tensor) {\n      Status s = CreateNodeDef(node_name, output_tensors[i], &outputs->at(i),\n                               total_inputs_size);\n      if (!s.ok()) {\n        *result_too_large = true;\n        return s;\n      }\n    } else {\n      \/\/ Create an empty NodeDef to identify dead outputs (e.g. the output of a\n      \/\/ switch that's not selected by the switch predicate).\n      outputs->at(i) = NodeDef();\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":667,"total_token_length":903,"max_tokens_setting":1024}
+{"idx":300772,"func":"static int tipc_sk_anc_data_recv(struct msghdr *m, struct sk_buff *skb,\n\t\t\t\t struct tipc_sock *tsk)\n{\n\tstruct tipc_msg *hdr;\n\tu32 data[3] = {0,};\n\tbool has_addr;\n\tint dlen, rc;\n\n\tif (likely(m->msg_controllen == 0))\n\t\treturn 0;\n\n\thdr = buf_msg(skb);\n\tdlen = msg_data_sz(hdr);\n\n\t\/* Capture errored message object, if any *\/\n\tif (msg_errcode(hdr)) {\n\t\tif (skb_linearize(skb))\n\t\t\treturn -ENOMEM;\n\t\thdr = buf_msg(skb);\n\t\tdata[0] = msg_errcode(hdr);\n\t\tdata[1] = dlen;\n\t\trc = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, data);\n\t\tif (rc || !dlen)\n\t\t\treturn rc;\n\t\trc = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, dlen, msg_data(hdr));\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\t\/* Capture TIPC_SERVICE_ADDR\/RANGE destination address, if any *\/\n\tswitch (msg_type(hdr)) {\n\tcase TIPC_NAMED_MSG:\n\t\thas_addr = true;\n\t\tdata[0] = msg_nametype(hdr);\n\t\tdata[1] = msg_namelower(hdr);\n\t\tdata[2] = data[1];\n\t\tbreak;\n\tcase TIPC_MCAST_MSG:\n\t\thas_addr = true;\n\t\tdata[0] = msg_nametype(hdr);\n\t\tdata[1] = msg_namelower(hdr);\n\t\tdata[2] = msg_nameupper(hdr);\n\t\tbreak;\n\tcase TIPC_CONN_MSG:\n\t\thas_addr = !!tsk->conn_addrtype;\n\t\tdata[0] = msg_nametype(&tsk->phdr);\n\t\tdata[1] = msg_nameinst(&tsk->phdr);\n\t\tdata[2] = data[1];\n\t\tbreak;\n\tdefault:\n\t\thas_addr = false;\n\t}\n\tif (!has_addr)\n\t\treturn 0;\n\treturn put_cmsg(m, SOL_TIPC, TIPC_DESTNAME, 12, data);\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":222862,"func":"  void CreateInputTensors(NodeContext* c,\n                          std::vector<Tensor>* input_tensor_vector,\n                          TensorVector* inputs) {\n    InferenceContext* ic = c->inference_context.get();\n    for (int i = 0; i < ic->num_inputs(); i++) {\n      if (ic->input_tensor(i)) {\n        input_tensor_vector->at(i) = *ic->input_tensor(i);\n        inputs->emplace_back(&input_tensor_vector->at(i));\n        \/\/ Note that we don't check c->input_tensor_protos[i], as UpdateNode()\n        \/\/ already converted it to ic->input_tensor(i);\n      } else {\n        \/\/ Create Tensor from input_tensors_as_shapes, and then emplace it\n        \/\/ back to inputs.\n        \/\/ Note that input_tensors_as_shapes is scalar or vector.\n        const ShapeHandle& shape_handle = ic->input_tensors_as_shapes()[i];\n        const DataType& data_type = c->input_types[i];\n        int32_t rank = ic->Rank(shape_handle);\n        if (rank < 1) {\n          input_tensor_vector->at(i) = Tensor(data_type, {});\n        } else {\n          input_tensor_vector->at(i) = Tensor(data_type, {rank});\n        }\n        auto* tensor = &input_tensor_vector->at(i);\n        if (data_type == DT_INT32) {\n          auto flat = tensor->flat<int32>();\n          for (int j = 0; j < rank; j++) {\n            int32_t dim = ic->Value(ic->Dim(shape_handle, j));\n            flat(j) = dim;\n          }\n        } else {\n          auto flat = tensor->flat<int64_t>();\n          for (int j = 0; j < rank; j++) {\n            int64_t dim = ic->Value(ic->Dim(shape_handle, j));\n            flat(j) = dim;\n          }\n        }\n        inputs->emplace_back(tensor);\n      }\n    }\n  }","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":450377,"func":"static void vnc_dpy_switch(DisplayChangeListener *dcl,\n                           DisplaySurface *surface)\n{\n    static const char placeholder_msg[] =\n        \"Display output is not active.\";\n    static DisplaySurface *placeholder;\n    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);\n    bool pageflip = vnc_check_pageflip(vd->ds, surface);\n    VncState *vs;\n\n    if (surface == NULL) {\n        if (placeholder == NULL) {\n            placeholder = qemu_create_message_surface(640, 480, placeholder_msg);\n        }\n        surface = placeholder;\n    }\n\n    vnc_abort_display_jobs(vd);\n    vd->ds = surface;\n\n    \/* guest surface *\/\n    qemu_pixman_image_unref(vd->guest.fb);\n    vd->guest.fb = pixman_image_ref(surface->image);\n    vd->guest.format = surface->format;\n\n    if (pageflip) {\n        vnc_set_area_dirty(vd->guest.dirty, vd, 0, 0,\n                           surface_width(surface),\n                           surface_height(surface));\n        return;\n    }\n\n    \/* server surface *\/\n    vnc_update_server_surface(vd);\n\n    QTAILQ_FOREACH(vs, &vd->clients, next) {\n        vnc_colordepth(vs);\n        vnc_desktop_resize(vs);\n        if (vs->vd->cursor) {\n            vnc_cursor_define(vs);\n        }\n        memset(vs->dirty, 0x00, sizeof(vs->dirty));\n        vnc_set_area_dirty(vs->dirty, vd, 0, 0,\n                           vnc_width(vd),\n                           vnc_height(vd));\n        vnc_update_throttle_offset(vs);\n    }\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":328941,"func":"R_API RBinJavaAttrInfo *r_bin_java_rtvp_annotations_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0;\n\tRBinJavaAttrInfo *attr = NULL;\n\tut64 offset = 0;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tRBinJavaAnnotationsArray *annotation_array;\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_RUNTIME_VISIBLE_PARAMETER_ANNOTATION_ATTR;\n\t\tattr->info.rtvp_annotations_attr.num_parameters = buffer[offset];\n\t\toffset += 1;\n\t\tattr->info.rtvp_annotations_attr.parameter_annotations = r_list_newf (r_bin_java_annotation_array_free);\n\t\tfor (i = 0; i < attr->info.rtvp_annotations_attr.num_parameters; i++) {\n\t\t\tif (offset > sz) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tannotation_array = r_bin_java_annotation_array_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\t\tif (annotation_array) {\n\t\t\t\toffset += annotation_array->size;\n\t\t\t}\n\t\t\tr_list_append (attr->info.rtvp_annotations_attr.parameter_annotations, (void *) annotation_array);\n\t\t}\n\t\tattr->size = offset;\n\t}\n\treturn attr;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":462421,"func":"addEPollSock(epolld_type_t typ, void *ptr, int sock, epolld_t **pEpd)\n{\n\tDEFiRet;\n\tepolld_t *epd = NULL;\n\n\tCHKmalloc(epd = calloc(1, sizeof(epolld_t)));\n\tepd->typ = typ;\n\tepd->ptr = ptr;\n\tepd->sock = sock;\n\t*pEpd = epd;\n\tepd->ev.events = EPOLLIN|EPOLLET|EPOLLONESHOT;\n\tepd->ev.data.ptr = (void*) epd;\n\n\tif(epoll_ctl(epollfd, EPOLL_CTL_ADD, sock, &(epd->ev)) != 0) {\n\t\tchar errStr[1024];\n\t\tint eno = errno;\n\t\terrmsg.LogError(0, RS_RET_EPOLL_CTL_FAILED, \"os error (%d) during epoll ADD: %s\",\n\t\t\t        eno, rs_strerror_r(eno, errStr, sizeof(errStr)));\n\t\tABORT_FINALIZE(RS_RET_EPOLL_CTL_FAILED);\n\t}\n\n\tDBGPRINTF(\"imptcp: added socket %d to epoll[%d] set\\n\", sock, epollfd);\n\nfinalize_it:\n\tif(iRet != RS_RET_OK) {\n\t\tif (epd != NULL) {\n\t\t\terrmsg.LogError(0, RS_RET_INTERNAL_ERROR, \"error: could not initialize mutex for ptcp \"\n\t\t\t\"connection for socket: %d\", sock);\n\t\t}\n\t\tfree(epd);\n\t}\n\tRETiRet;\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":390575,"func":"SendDeviceLedInfo(\tXkbSrvLedInfoPtr\tsli,\n\t\t\tClientPtr\t\tclient)\n{\nxkbDeviceLedsWireDesc\twire;\nint\t\t\tlength;\n\n    length= 0;\n    wire.ledClass= \t\tsli->class;\n    wire.ledID= \t\tsli->id;\n    wire.namesPresent= \t\tsli->namesPresent;\n    wire.mapsPresent=   \tsli->mapsPresent;\n    wire.physIndicators= \tsli->physIndicators;\n    wire.state=\t\t\tsli->effectiveState;\n    if (client->swapped) {\n\tregister int n;\n\tswaps(&wire.ledClass,n);\n\tswaps(&wire.ledID,n);\n\tswapl(&wire.namesPresent,n);\n\tswapl(&wire.mapsPresent,n);\n\tswapl(&wire.physIndicators,n);\n\tswapl(&wire.state,n);\n    }\n    WriteToClient(client,SIZEOF(xkbDeviceLedsWireDesc),(char *)&wire);\n    length+= SIZEOF(xkbDeviceLedsWireDesc);\n    if (sli->namesPresent|sli->mapsPresent) {\n\tregister unsigned i,bit;\n\tif (sli->namesPresent) {\n\t    CARD32\tawire;\n\t    for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {\n\t\tif (sli->namesPresent&bit) {\n\t\t    awire= (CARD32)sli->names[i];\n\t\t    if (client->swapped) {\n\t\t\tregister int n;\n\t\t\tswapl(&awire,n);\n\t\t    }\n\t\t    WriteToClient(client,4,(char *)&awire);\n\t\t    length+= 4;\n\t\t}\n\t    }\n\t}\n\tif (sli->mapsPresent) {\n\t    for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {\n\t\txkbIndicatorMapWireDesc\tiwire;\n\t\tif (sli->mapsPresent&bit) {\n\t\t    iwire.flags= \tsli->maps[i].flags;\n\t\t    iwire.whichGroups=\tsli->maps[i].which_groups;\n\t\t    iwire.groups=\tsli->maps[i].groups;\n\t\t    iwire.whichMods=\tsli->maps[i].which_mods;\n\t\t    iwire.mods=\t\tsli->maps[i].mods.mask;\n\t\t    iwire.realMods=\tsli->maps[i].mods.real_mods;\n\t\t    iwire.virtualMods=\tsli->maps[i].mods.vmods;\n\t\t    iwire.ctrls= \tsli->maps[i].ctrls;\n\t\t    if (client->swapped) {\n\t\t\tregister int n;\n\t\t\tswaps(&iwire.virtualMods,n);\n\t\t\tswapl(&iwire.ctrls,n);\n\t\t    }\n\t\t    WriteToClient(client,SIZEOF(xkbIndicatorMapWireDesc),\n\t\t\t\t\t\t\t\t(char *)&iwire);\n\t\t    length+= SIZEOF(xkbIndicatorMapWireDesc);\n\t\t}\n\t    }\n\t}\n    }\n    return length;\n}","target":0,"code_token_length":615,"total_token_length":851,"max_tokens_setting":1024}
+{"idx":274693,"func":"callbacks_drawingarea_configure_event (GtkWidget *widget, GdkEventConfigure *event)\n{\n\tGdkDrawable *drawable = widget->window;\n\t\n\tgdk_drawable_get_size (drawable, &screenRenderInfo.displayWidth, &screenRenderInfo.displayHeight);\n\n\t\/* set this up if cairo is compiled, since we may need to switch over to\n\t   using the surface at any time *\/\n\tint x_off=0, y_off=0;\n\t\n\tif (GDK_IS_WINDOW(widget->window)) {\n\t      \/* query the window's backbuffer if it has one *\/\n\t\tGdkWindow *window = GDK_WINDOW(widget->window);\n\t      gdk_window_get_internal_paint_info (window, &drawable, &x_off, &y_off);\n\t}\n\tif (screen.windowSurface)\n\t\tcairo_surface_destroy ((cairo_surface_t *)\n\t\t\tscreen.windowSurface);\n\n#if defined(WIN32) || defined(QUARTZ)\n\tcairo_t *cairoTarget = gdk_cairo_create (GDK_WINDOW(widget->window));\n\t\n\tscreen.windowSurface = cairo_get_target (cairoTarget);\n\t\/* increase surface reference by one so it isn't freed when the cairo_t\n\t   is destroyed next *\/\n\tscreen.windowSurface = cairo_surface_reference (screen.windowSurface);\n\tcairo_destroy (cairoTarget);\n#else\n\tGdkVisual *visual = gdk_drawable_get_visual (drawable);\n\tscreen.windowSurface = (gpointer) cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable),\n                                          GDK_DRAWABLE_XID (drawable),\n                                          GDK_VISUAL_XVISUAL (visual),\n                                          screenRenderInfo.displayWidth,\n                                          screenRenderInfo.displayHeight);\n#endif\n\t\/* if this is the first time, go ahead and call autoscale even if we don't\n\t   have a model loaded *\/\n\tif ((screenRenderInfo.scaleFactorX < 0.001)||(screenRenderInfo.scaleFactorY < 0.001)) {\n\t\tgerbv_render_zoom_to_fit_display (mainProject, &screenRenderInfo);\n\t}\n\trender_refresh_rendered_image_on_screen();\n\treturn TRUE;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":373526,"func":"ipf_is_valid_v6_frag(struct ipf *ipf, struct dp_packet *pkt)\n{\n    const struct eth_header *l2 = dp_packet_eth(pkt);\n    const struct  ovs_16aligned_ip6_hdr *l3 = dp_packet_l3(pkt);\n    const char *l4 = dp_packet_l4(pkt);\n\n    if (OVS_UNLIKELY(!l2 || !l3 || !l4)) {\n        goto invalid_pkt;\n    }\n\n    size_t l3_size = dp_packet_l3_size(pkt);\n    size_t l3_hdr_size = sizeof *l3;\n\n    if (OVS_UNLIKELY(l3_size < l3_hdr_size)) {\n        goto invalid_pkt;\n    }\n\n    uint8_t nw_frag = 0;\n    uint8_t nw_proto = l3->ip6_nxt;\n    const void *data = l3 + 1;\n    size_t datasize = l3_size - l3_hdr_size;\n    const struct ovs_16aligned_ip6_frag *frag_hdr = NULL;\n    if (!parse_ipv6_ext_hdrs(&data, &datasize, &nw_proto, &nw_frag,\n                             &frag_hdr) || !nw_frag || !frag_hdr) {\n        return false;\n    }\n\n    int pl = ntohs(l3->ip6_plen);\n    if (OVS_UNLIKELY(pl + l3_hdr_size != l3_size)) {\n        goto invalid_pkt;\n    }\n\n    ovs_be16 ip6f_offlg = frag_hdr->ip6f_offlg;\n    if (OVS_UNLIKELY(!ipf_is_v6_frag(ip6f_offlg))) {\n        return false;\n    }\n\n    uint32_t min_v6_frag_size_;\n    atomic_read_relaxed(&ipf->min_v6_frag_size, &min_v6_frag_size_);\n    bool lf = ipf_is_last_v6_frag(ip6f_offlg);\n\n    if (OVS_UNLIKELY(!lf && dp_packet_l3_size(pkt) < min_v6_frag_size_)) {\n        ipf_count(ipf, true, IPF_NFRAGS_TOO_SMALL);\n        goto invalid_pkt;\n    }\n\n    return true;\n\ninvalid_pkt:\n    pkt->md.ct_state = CS_INVALID;\n    return false;\n\n}","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":513306,"func":"bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)\n{\n  tmp_having->update_used_tables();\n  table_map used_tables= tab->table->map | OUTER_REF_TABLE_BIT;\n\n  \/* If tmp table is not used then consider conditions of const table also *\/\n  if (!need_tmp)\n    used_tables|= const_table_map;\n\n  DBUG_ENTER(\"JOIN::add_having_as_table_cond\");\n\n  Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables,\n                                             (table_map) 0, false,\n                                             false, false);\n  if (sort_table_cond)\n  {\n    if (!tab->select)\n    {\n      if (!(tab->select= new SQL_SELECT))\n        DBUG_RETURN(true);\n      tab->select->head= tab->table;\n    }\n    if (!tab->select->cond)\n      tab->select->cond= sort_table_cond;\n    else\n    {\n      if (!(tab->select->cond=\n\t      new (thd->mem_root) Item_cond_and(thd,\n                                                tab->select->cond,\n                                                sort_table_cond)))\n        DBUG_RETURN(true);\n    }\n    if (tab->pre_idx_push_select_cond)\n    {\n      if (sort_table_cond->type() == Item::COND_ITEM)\n        sort_table_cond= sort_table_cond->copy_andor_structure(thd);\n      if (!(tab->pre_idx_push_select_cond=\n              new (thd->mem_root) Item_cond_and(thd,\n                                                tab->pre_idx_push_select_cond,\n                                                sort_table_cond)))\n        DBUG_RETURN(true);\n    }\n    if (tab->select->cond && !tab->select->cond->fixed)\n      tab->select->cond->fix_fields(thd, 0);\n    if (tab->pre_idx_push_select_cond && !tab->pre_idx_push_select_cond->fixed)\n      tab->pre_idx_push_select_cond->fix_fields(thd, 0);\n    tab->select->pre_idx_push_select_cond= tab->pre_idx_push_select_cond;\n    tab->set_select_cond(tab->select->cond, __LINE__);\n    tab->select_cond->top_level_item();\n    DBUG_EXECUTE(\"where\",print_where(tab->select->cond,\n\t\t\t\t     \"select and having\",\n                                     QT_ORDINARY););\n\n    having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0,\n                                ~used_tables, false, false, false);\n    DBUG_EXECUTE(\"where\",\n                 print_where(having, \"having after sort\", QT_ORDINARY););\n  }\n\n  DBUG_RETURN(false);\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":390623,"func":"SetKeySyms(\tClientPtr\t\tclient,\n\t\tXkbDescPtr\t\txkb,\n\t\txkbSetMapReq *\t\treq,\n\t\txkbSymMapWireDesc *\twire,\n\t\tXkbChangesPtr \t\tchanges,\n\t\tDeviceIntPtr\t\tdev)\n{\nregister unsigned \ti,s;\nXkbSymMapPtr\t\toldMap;\nKeySym *\t\tnewSyms;\nKeySym *\t\tpSyms;\nunsigned\t\tfirst,last;\n\n    oldMap = &xkb->map->key_sym_map[req->firstKeySym];\n    for (i=0;i<req->nKeySyms;i++,oldMap++) {\n\tpSyms = (KeySym *)&wire[1];\n\tif (wire->nSyms>0) {\n\t    newSyms = XkbResizeKeySyms(xkb,i+req->firstKeySym,wire->nSyms);\n\t    for (s=0;s<wire->nSyms;s++) {\n\t\tnewSyms[s]= pSyms[s];\n\t    }\n\t    if (client->swapped) {\n\t\tint n;\n\t\tfor (s=0;s<wire->nSyms;s++) {\n\t\t    swapl(&newSyms[s],n);\n\t\t}\n\t    }\n\t}\n\toldMap->kt_index[0] = wire->ktIndex[0];\n\toldMap->kt_index[1] = wire->ktIndex[1];\n\toldMap->kt_index[2] = wire->ktIndex[2];\n\toldMap->kt_index[3] = wire->ktIndex[3];\n\toldMap->group_info = wire->groupInfo;\n\toldMap->width = wire->width;\n\twire= (xkbSymMapWireDesc *)&pSyms[wire->nSyms];\n    }\n    first= req->firstKeySym;\n    last= first+req->nKeySyms-1;\n    if (changes->map.changed&XkbKeySymsMask) {\n\tint oldLast= (changes->map.first_key_sym+changes->map.num_key_syms-1);\n\tif (changes->map.first_key_sym<first)\n\t    first= changes->map.first_key_sym;\n\tif (oldLast>last)\n\t    last= oldLast;\n    }\n    changes->map.changed|= XkbKeySymsMask;\n    changes->map.first_key_sym = first;\n    changes->map.num_key_syms = (last-first+1);\n\n    s= 0;\n    for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {\n\tif (XkbKeyNumGroups(xkb,i)>s)\n\t    s= XkbKeyNumGroups(xkb,i);\n    }\n    if (s!=xkb->ctrls->num_groups) {\n\txkbControlsNotify\tcn;\n\tXkbControlsRec\t\told;\n\tcn.keycode= 0;\n\tcn.eventType= 0;\n\tcn.requestMajor= XkbReqCode;\n\tcn.requestMinor= X_kbSetMap;\n\told= *xkb->ctrls;\n\txkb->ctrls->num_groups= s;\n\tif (XkbComputeControlsNotify(dev,&old,xkb->ctrls,&cn,False))\n\t    XkbSendControlsNotify(dev,&cn);\n    }\n    return (char *)wire;\n}","target":0,"code_token_length":679,"total_token_length":915,"max_tokens_setting":1024}
+{"idx":274700,"func":"callbacks_align_files_from_sel_clicked (\n\t\tGtkMenuItem *menu_item, gpointer user_data)\n{\n\tgerbv_fileinfo_t *fi[2];\n\tgerbv_selection_item_t item[2];\n\tgerbv_net_t *net;\n\tgerbv_selection_info_t *sel_info = &screen.selectionInfo;\n\tint align_second_to_first = GPOINTER_TO_INT(user_data);\n\tgdouble x[2], y[2];\n\tint i;\n\n\tif (selection_length (sel_info) != 2)\n\t\treturn;\n\n\titem[0] = selection_get_item_by_index(sel_info, 0);\n\titem[1] = selection_get_item_by_index(sel_info, 1);\n\n\tfi[0] = gerbv_get_fileinfo_for_image (item[0].image, mainProject);\n\tfi[1] = gerbv_get_fileinfo_for_image (item[1].image, mainProject);\n\n\tif (fi[0] == NULL || fi[1] == NULL || fi[0] == fi[1])\n\t\treturn;\n\n\t\/* Calculate aligning coords *\/\n\tfor (i = 0; i < 2; i++) {\n\t\tnet = item[i].net;\n\n\t\tswitch (net->aperture_state) {\n\t\tcase GERBV_APERTURE_STATE_FLASH:\n\t\t\tx[i] = net->stop_x;\n\t\t\ty[i] = net->stop_y;\n\t\t\tbreak;\n\t\tcase GERBV_APERTURE_STATE_ON:\n\t\t\tswitch (net->interpolation) {\n\t\t\tcase GERBV_INTERPOLATION_LINEARx1:\n\t\t\tcase GERBV_INTERPOLATION_LINEARx10:\n\t\t\tcase GERBV_INTERPOLATION_LINEARx01:\n\t\t\tcase GERBV_INTERPOLATION_LINEARx001:\n\t\t\t\tx[i] = (net->stop_x + net->start_x)\/2;\n\t\t\t\ty[i] = (net->stop_y + net->start_y)\/2;\n\t\t\t\tbreak;\n\t\t\tcase GERBV_INTERPOLATION_CW_CIRCULAR:\n\t\t\tcase GERBV_INTERPOLATION_CCW_CIRCULAR:\n\t\t\t\tx[i] = net->cirseg->cp_x;\n\t\t\t\ty[i] = net->cirseg->cp_y;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tGERB_COMPILE_ERROR (_(\"Can't align by this \"\n\t\t\t\t\t\t\t\"type of object\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tGERB_COMPILE_ERROR (_(\"Can't align by this \"\n\t\t\t\t\t\t\"type of object\"));\n\t\t\treturn;\n\t\t}\n\n\t\tgerbv_transform_coord_for_image(x + i, y + i,\n\t\t\t\titem[i].image, mainProject);\n\t}\n\n\tif (align_second_to_first) {\n\t\tfi[1]->transform.translateX += x[0] - x[1];\n\t\tfi[1]->transform.translateY += y[0] - y[1];\n\t} else {\n\t\tfi[0]->transform.translateX += x[1] - x[0];\n\t\tfi[0]->transform.translateY += y[1] - y[0];\n\t}\n\n\trender_refresh_rendered_image_on_screen ();\n\tcallbacks_update_layer_tree ();\n}","target":0,"code_token_length":632,"total_token_length":868,"max_tokens_setting":1024}
+{"idx":310141,"func":"line_capability(const char *name)\n{\n    bool result = FALSE;\n    static const char *table[] =\n    {\n\t\"csr\",\t\t\t\/* change_scroll_region          *\/\n\t\"clear\",\t\t\/* clear_screen                  *\/\n\t\"ed\",\t\t\t\/* clr_eos                       *\/\n\t\"cwin\",\t\t\t\/* create_window                 *\/\n\t\"cup\",\t\t\t\/* cursor_address                *\/\n\t\"cud1\",\t\t\t\/* cursor_down                   *\/\n\t\"home\",\t\t\t\/* cursor_home                   *\/\n\t\"mrcup\",\t\t\/* cursor_mem_address            *\/\n\t\"ll\",\t\t\t\/* cursor_to_ll                  *\/\n\t\"cuu1\",\t\t\t\/* cursor_up                     *\/\n\t\"dl1\",\t\t\t\/* delete_line                   *\/\n\t\"hd\",\t\t\t\/* down_half_line                *\/\n\t\"flash\",\t\t\/* flash_screen                  *\/\n\t\"ff\",\t\t\t\/* form_feed                     *\/\n\t\"il1\",\t\t\t\/* insert_line                   *\/\n\t\"nel\",\t\t\t\/* newline                       *\/\n\t\"dl\",\t\t\t\/* parm_delete_line              *\/\n\t\"cud\",\t\t\t\/* parm_down_cursor              *\/\n\t\"indn\",\t\t\t\/* parm_index                    *\/\n\t\"il\",\t\t\t\/* parm_insert_line              *\/\n\t\"rin\",\t\t\t\/* parm_rindex                   *\/\n\t\"cuu\",\t\t\t\/* parm_up_cursor                *\/\n\t\"mc0\",\t\t\t\/* print_screen                  *\/\n\t\"vpa\",\t\t\t\/* row_address                   *\/\n\t\"ind\",\t\t\t\/* scroll_forward                *\/\n\t\"ri\",\t\t\t\/* scroll_reverse                *\/\n\t\"hu\",\t\t\t\/* up_half_line                  *\/\n    };\n    size_t n;\n    for (n = 0; n < SIZEOF(table); ++n) {\n\tif (!strcmp(name, table[n])) {\n\t    result = TRUE;\n\t    break;\n\t}\n    }\n    return result;\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":411929,"func":"need_referral(krb5_context context, krb5_kdc_configuration *config,\n\t      const KDCOptions * const options, krb5_principal server,\n\t      krb5_realm **realms)\n{\n    const char *name;\n\n    if(!options->canonicalize && server->name.name_type != KRB5_NT_SRV_INST)\n\treturn FALSE;\n\n    if (server->name.name_string.len == 1)\n\tname = server->name.name_string.val[0];\n    else if (server->name.name_string.len == 3) {\n\t\/*\n\t  This is used to give referrals for the\n\t  E3514235-4B06-11D1-AB04-00C04FC2DCD2\/NTDSGUID\/DNSDOMAIN\n\t  SPN form, which is used for inter-domain communication in AD\n\t *\/\n\tname = server->name.name_string.val[2];\n\tkdc_log(context, config, 4, \"Giving 3 part referral for %s\", name);\n\t*realms = malloc(sizeof(char *)*2);\n\tif (*realms == NULL) {\n\t    krb5_set_error_message(context, ENOMEM, N_(\"malloc: out of memory\", \"\"));\n\t    return FALSE;\n\t}\n\t(*realms)[0] = strdup(name);\n\t(*realms)[1] = NULL;\n\treturn TRUE;\n    } else if (server->name.name_string.len > 1)\n\tname = server->name.name_string.val[1];\n    else\n\treturn FALSE;\n\n    kdc_log(context, config, 5, \"Searching referral for %s\", name);\n\n    return _krb5_get_host_realm_int(context, name, FALSE, realms) == 0;\n}","target":0,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":233839,"func":"int fmtutil_default_box_handler(deark *c, struct de_boxesctx *bctx)\n{\n\tstruct de_boxdata *curbox = bctx->curbox;\n\n\tif(curbox->is_uuid) {\n\t\tif(!de_memcmp(curbox->uuid, \"\\xb1\\x4b\\xf8\\xbd\\x08\\x3d\\x4b\\x43\\xa5\\xae\\x8c\\xd7\\xd5\\xa6\\xce\\x03\", 16)) {\n\t\t\tde_dbg(c, \"GeoTIFF data at %\"I64_FMT\", len=%\"I64_FMT, curbox->payload_pos, curbox->payload_len);\n\t\t\tdbuf_create_file_from_slice(bctx->f, curbox->payload_pos, curbox->payload_len, \"geo.tif\", NULL, DE_CREATEFLAG_IS_AUX);\n\t\t}\n\t\telse if(!de_memcmp(curbox->uuid, \"\\xbe\\x7a\\xcf\\xcb\\x97\\xa9\\x42\\xe8\\x9c\\x71\\x99\\x94\\x91\\xe3\\xaf\\xac\", 16)) {\n\t\t\tde_dbg(c, \"XMP data at %\"I64_FMT\", len=%\"I64_FMT, curbox->payload_pos, curbox->payload_len);\n\t\t\tdbuf_create_file_from_slice(bctx->f, curbox->payload_pos, curbox->payload_len, \"xmp\", NULL, DE_CREATEFLAG_IS_AUX);\n\t\t}\n\t\telse if(!de_memcmp(curbox->uuid, \"\\x2c\\x4c\\x01\\x00\\x85\\x04\\x40\\xb9\\xa0\\x3e\\x56\\x21\\x48\\xd6\\xdf\\xeb\", 16)) {\n\t\t\tde_dbg(c, \"Photoshop resources at %\"I64_FMT\", len=%\"I64_FMT, curbox->payload_pos, curbox->payload_len);\n\t\t\tde_dbg_indent(c, 1);\n\t\t\tfmtutil_handle_photoshop_rsrc(c, bctx->f, curbox->payload_pos, curbox->payload_len, 0x0);\n\t\t\tde_dbg_indent(c, -1);\n\t\t}\n\t\telse if(!de_memcmp(curbox->uuid, \"\\x05\\x37\\xcd\\xab\\x9d\\x0c\\x44\\x31\\xa7\\x2a\\xfa\\x56\\x1f\\x2a\\x11\\x3e\", 16) ||\n\t\t\t!de_memcmp(curbox->uuid, \"JpgTiffExif->JP2\", 16))\n\t\t{\n\t\t\tde_dbg(c, \"Exif data at %\"I64_FMT\", len=%\"I64_FMT, curbox->payload_pos, curbox->payload_len);\n\t\t\tde_dbg_indent(c, 1);\n\t\t\tfmtutil_handle_exif(c, curbox->payload_pos, curbox->payload_len);\n\t\t\tde_dbg_indent(c, -1);\n\t\t}\n\t}\n\treturn 1;\n}","target":0,"code_token_length":635,"total_token_length":871,"max_tokens_setting":1024}
+{"idx":256172,"func":"ALWAYS_INLINE void MulAdd3Way(const Packet a1, const Packet a2, const Packet a3,\n                              const bfloat16** binp1, const bfloat16** binp2,\n                              const bfloat16** binp3, float** out) {\n  auto inp1 = reinterpret_cast<const float*>(*binp1);\n  auto inp2 = reinterpret_cast<const float*>(*binp2);\n  auto inp3 = reinterpret_cast<const float*>(*binp3);\n  auto c1 = LOAD(*out);\n  auto c2 = LOAD(*out + kNumOperands);\n  const auto b1 = LOAD(inp1);\n  EXPAND_BFLOAT_L(b1, b1_0);\n  EXPAND_BFLOAT_U(b1, b1_1);\n  *binp1 += 2 * kNumOperands;\n  const auto b2 = LOAD(inp2);\n  EXPAND_BFLOAT_L(b2, b2_0);\n  EXPAND_BFLOAT_U(b2, b2_1);\n  *binp2 += 2 * kNumOperands;\n  const auto b3 = LOAD(inp3);\n  EXPAND_BFLOAT_L(b3, b3_0);\n  EXPAND_BFLOAT_U(b3, b3_1);\n  *binp3 += 2 * kNumOperands;\n  FMA(a1, b1_0, c1, c1);\n  FMA(a1, b1_1, c2, c2);\n  FMA(a2, b2_0, c1, c1);\n  FMA(a2, b2_1, c2, c2);\n  FMA(a3, b3_0, c1, c1);\n  FMA(a3, b3_1, c2, c2);\n  STORE(*out, c1);\n  STORE(*out + kNumOperands, c2);\n  *out += 2 * kNumOperands;\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":220174,"func":"const Edge* Graph::AddEdge(Node* source, int x, Node* dest, int y) {\n  TF_DCHECK_OK(IsValidNode(source)) << source->DebugString();\n  TF_DCHECK_OK(IsValidNode(dest)) << dest->DebugString();\n\n  \/\/ source\/sink must only be linked via control slots, and\n  \/\/ control slots must only be linked to control slots.\n  if (source == source_node() || dest == sink_node() || x == kControlSlot ||\n      y == kControlSlot) {\n    DCHECK_EQ(x, kControlSlot) << source->DebugString();\n    DCHECK_EQ(y, kControlSlot) << dest->DebugString();\n  }\n\n  Edge* e = nullptr;\n  if (free_edges_.empty()) {\n    e = new (arena_.Alloc(sizeof(Edge))) Edge;  \/\/ placement new\n  } else {\n    e = free_edges_.back();\n    free_edges_.pop_back();\n  }\n  e->id_ = edges_.size();\n  e->src_ = source;\n  e->dst_ = dest;\n  e->src_output_ = x;\n  e->dst_input_ = y;\n  CHECK(source->out_edges_.insert(e).second);\n  CHECK(dest->in_edges_.insert(e).second);\n  edges_.push_back(e);\n  ++num_edges_;\n\n  if (!e->IsControlEdge()) {\n    if (dest->in_edges_.size() >= dest->props_->input_types.size()) {\n      \/\/ Note: this only produces consistent results at graph construction,\n      \/\/ and only when all incoming edges are up-to-date.\n      \/\/ If the graph is subsequently modified, or if the node is added before\n      \/\/ any of its upstream nodes, this type information would change as well.\n      \/\/ In general, graph transformations should run shole-graph type inference\n      \/\/ when done, and should not rely on types being fully up to date\n      \/\/ after each AddNode.\n      \/\/ TODO(mdan): Should we even run type inference here any more?\n      dest->RunForwardTypeInference();\n    }\n  }\n\n  return e;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":273919,"func":"static void list(ctrl_t *ctrl, char *arg, int mode)\n{\n\tchar *path;\n\n\tif (string_valid(arg)) {\n\t\tchar *ptr, *quot;\n\n\t\t\/* Check if client sends ls arguments ... *\/\n\t\tptr = arg;\n\t\twhile (*ptr) {\n\t\t\tif (isspace(*ptr))\n\t\t\t\tptr++;\n\n\t\t\tif (*ptr == '-') {\n\t\t\t\twhile (*ptr && !isspace(*ptr))\n\t\t\t\t\tptr++;\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Strip any \"\" from \"<arg>\" *\/\n\t\twhile ((quot = strchr(ptr, '\"'))) {\n\t\t\tchar *ptr2;\n\n\t\t\tptr2 = strchr("[1], '\"');\n\t\t\tif (ptr2) {\n\t\t\t\tmemmove(ptr2, &ptr2[1], strlen(ptr2));\n\t\t\t\tmemmove(quot, "[1], strlen(quot));\n\t\t\t}\n\t\t}\n\t\targ = ptr;\n\t}\n\n\tif (mode >= 2)\n\t\tpath = compose_abspath(ctrl, arg);\n\telse\n\t\tpath = compose_path(ctrl, arg);\n\tif (!path) {\n\t\tsend_msg(ctrl->sd, \"550 No such file or directory.\\r\\n\");\n\t\treturn;\n\t}\n\n\tctrl->list_mode = mode;\n\tctrl->file = strdup(arg ? arg : \"\");\n\tctrl->i = 0;\n\tctrl->d_num = scandir(path, &ctrl->d, NULL, alphasort);\n\tif (ctrl->d_num == -1) {\n\t\tsend_msg(ctrl->sd, \"550 No such file or directory.\\r\\n\");\n\t\tDBG(\"Failed reading directory '%s': %s\", path, strerror(errno));\n\t\treturn;\n\t}\n\n\tDBG(\"Reading directory %s ... %d number of entries\", path, ctrl->d_num);\n\tif (ctrl->data_sd > -1) {\n\t\tsend_msg(ctrl->sd, \"125 Data connection already open; transfer starting.\\r\\n\");\n\t\tuev_io_init(ctrl->ctx, &ctrl->data_watcher, do_LIST, ctrl, ctrl->data_sd, UEV_WRITE);\n\t\treturn;\n\t}\n\n\tdo_PORT(ctrl, 1);\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":208076,"func":"RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {\n\tRList *entries = r_list_newf (free);\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_bin_ne_get_segments (bin);\n\tif (!segments) {\n\t\tr_list_free (entries);\n\t\treturn NULL;\n\t}\n\tif (bin->ne_header->csEntryPoint) {\n\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\tif (!entry) {\n\t\t\tr_list_free (entries);\n\t\t\treturn NULL;\n\t\t}\n\t\tentry->bits = 16;\n\t\tut32 entry_cs = bin->ne_header->csEntryPoint;\n\t\tRBinSection *s = r_list_get_n (segments, entry_cs - 1);\n\t\tentry->paddr = bin->ne_header->ipEntryPoint + (s? s->paddr: 0);\n\n\t\tr_list_append (entries, entry);\n\t}\n\tint off = 0;\n\tsize_t tableat = bin->header_offset + bin->ne_header->EntryTableOffset;\n\twhile (off < bin->ne_header->EntryTableLength) {\n\t\tif (tableat + off >= r_buf_size (bin->buf)) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 bundle_length = *(ut8 *)(bin->entry_table + off);\n\t\tif (!bundle_length) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tut8 bundle_type = *(ut8 *)(bin->entry_table + off);\n\t\toff++;\n\t\tint i;\n\t\tfor (i = 0; i < bundle_length; i++) {\n\t\t\tif (tableat + off + 4 >= r_buf_size (bin->buf)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\t\tif (!entry) {\n\t\t\t\tr_list_free (entries);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\toff++;\n\t\t\tif (!bundle_type) { \/\/ Skip\n\t\t\t\toff--;\n\t\t\t\tfree (entry);\n\t\t\t\tbreak;\n\t\t\t} else if (bundle_type == 0xff) { \/\/ moveable\n\t\t\t\toff += 2;\n\t\t\t\tut8 segnum = *(bin->entry_table + off);\n\t\t\t\toff++;\n\t\t\t\tut16 segoff = *(ut16 *)(bin->entry_table + off);\n\t\t\t\tif (segnum > 0) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;\n\t\t\t\t}\n\t\t\t} else { \/\/ Fixed\n\t\t\t\tif (bundle_type < bin->ne_header->SegCount) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset\n\t\t\t\t\t\t* bin->alignment + *(ut16 *)(bin->entry_table + off);\n\t\t\t\t}\n\t\t\t}\n\t\t\toff += 2;\n\t\t\tr_list_append (entries, entry);\n\t\t}\n\t}\n\tr_list_free (segments);\n\tbin->entries = entries;\n\treturn entries;\n}","target":1,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":502732,"func":"void SSL_SESSION_free(SSL_SESSION *ss)\n{\n    int i;\n\n    if (ss == NULL)\n        return;\n\n    i = CRYPTO_add(&ss->references, -1, CRYPTO_LOCK_SSL_SESSION);\n#ifdef REF_PRINT\n    REF_PRINT(\"SSL_SESSION\", ss);\n#endif\n    if (i > 0)\n        return;\n#ifdef REF_CHECK\n    if (i < 0) {\n        fprintf(stderr, \"SSL_SESSION_free, bad reference count\\n\");\n        abort();                \/* ok *\/\n    }\n#endif\n\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);\n\n    OPENSSL_cleanse(ss->key_arg, sizeof ss->key_arg);\n    OPENSSL_cleanse(ss->master_key, sizeof ss->master_key);\n    OPENSSL_cleanse(ss->session_id, sizeof ss->session_id);\n    if (ss->sess_cert != NULL)\n        ssl_sess_cert_free(ss->sess_cert);\n    if (ss->peer != NULL)\n        X509_free(ss->peer);\n    if (ss->ciphers != NULL)\n        sk_SSL_CIPHER_free(ss->ciphers);\n#ifndef OPENSSL_NO_TLSEXT\n    if (ss->tlsext_hostname != NULL)\n        OPENSSL_free(ss->tlsext_hostname);\n    if (ss->tlsext_tick != NULL)\n        OPENSSL_free(ss->tlsext_tick);\n# ifndef OPENSSL_NO_EC\n    ss->tlsext_ecpointformatlist_length = 0;\n    if (ss->tlsext_ecpointformatlist != NULL)\n        OPENSSL_free(ss->tlsext_ecpointformatlist);\n    ss->tlsext_ellipticcurvelist_length = 0;\n    if (ss->tlsext_ellipticcurvelist != NULL)\n        OPENSSL_free(ss->tlsext_ellipticcurvelist);\n# endif                         \/* OPENSSL_NO_EC *\/\n#endif\n#ifndef OPENSSL_NO_PSK\n    if (ss->psk_identity_hint != NULL)\n        OPENSSL_free(ss->psk_identity_hint);\n    if (ss->psk_identity != NULL)\n        OPENSSL_free(ss->psk_identity);\n#endif\n#ifndef OPENSSL_NO_SRP\n    if (ss->srp_username != NULL)\n        OPENSSL_free(ss->srp_username);\n#endif\n    OPENSSL_cleanse(ss, sizeof(*ss));\n    OPENSSL_free(ss);\n}","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":455335,"func":"setup_ignore_patterns (ivp)\n     struct ignorevar *ivp;\n{\n  int numitems, maxitems, ptr;\n  char *colon_bit, *this_ignoreval;\n  struct ign *p;\n\n  this_ignoreval = get_string_value (ivp->varname);\n\n  \/* If nothing has changed then just exit now. *\/\n  if ((this_ignoreval && ivp->last_ignoreval && STREQ (this_ignoreval, ivp->last_ignoreval)) ||\n      (!this_ignoreval && !ivp->last_ignoreval))\n    return;\n\n  \/* Oops.  The ignore variable has changed.  Re-parse it. *\/\n  ivp->num_ignores = 0;\n\n  if (ivp->ignores)\n    {\n      for (p = ivp->ignores; p->val; p++)\n\tfree(p->val);\n      free (ivp->ignores);\n      ivp->ignores = (struct ign *)NULL;\n    }\n\n  if (ivp->last_ignoreval)\n    {\n      free (ivp->last_ignoreval);\n      ivp->last_ignoreval = (char *)NULL;\n    }\n\n  if (this_ignoreval == 0 || *this_ignoreval == '\\0')\n    return;\n\n  ivp->last_ignoreval = savestring (this_ignoreval);\n\n  numitems = maxitems = ptr = 0;\n\n#if 0\n  while (colon_bit = extract_colon_unit (this_ignoreval, &ptr))\n#else\n  while (colon_bit = split_ignorespec (this_ignoreval, &ptr))\n#endif\n    {\n      if (numitems + 1 >= maxitems)\n\t{\n\t  maxitems += 10;\n\t  ivp->ignores = (struct ign *)xrealloc (ivp->ignores, maxitems * sizeof (struct ign));\n\t}\n      ivp->ignores[numitems].val = colon_bit;\n      ivp->ignores[numitems].len = strlen (colon_bit);\n      ivp->ignores[numitems].flags = 0;\n      if (ivp->item_func)\n\t(*ivp->item_func) (&ivp->ignores[numitems]);\n      numitems++;\n    }\n  ivp->ignores[numitems].val = (char *)NULL;\n  ivp->num_ignores = numitems;\n}","target":0,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":238806,"func":"pat_has_uppercase(char_u *pat)\n{\n    char_u *p = pat;\n    magic_T magic_val = MAGIC_ON;\n\n    \/\/ get the magicness of the pattern\n    (void)skip_regexp_ex(pat, NUL, magic_isset(), NULL, NULL, &magic_val);\n\n    while (*p != NUL)\n    {\n\tint\t\tl;\n\n\tif (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)\n\t{\n\t    if (enc_utf8 && utf_isupper(utf_ptr2char(p)))\n\t\treturn TRUE;\n\t    p += l;\n\t}\n\telse if (*p == '\\\\' && magic_val <= MAGIC_ON)\n\t{\n\t    if (p[1] == '_' && p[2] != NUL)  \/\/ skip \"\\_X\"\n\t\tp += 3;\n\t    else if (p[1] == '%' && p[2] != NUL)  \/\/ skip \"\\%X\"\n\t\tp += 3;\n\t    else if (p[1] != NUL)  \/\/ skip \"\\X\"\n\t\tp += 2;\n\t    else\n\t\tp += 1;\n\t}\n\telse if ((*p == '%' || *p == '_') && magic_val == MAGIC_ALL)\n\t{\n\t    if (p[1] != NUL)  \/\/ skip \"_X\" and %X\n\t\tp += 2;\n\t    else\n\t\tp++;\n\t}\n\telse if (MB_ISUPPER(*p))\n\t    return TRUE;\n\telse\n\t    ++p;\n    }\n    return FALSE;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":517444,"func":"static void do_home_filesystem(HttpResponse res) {\n        char buf[STRLEN];\n        boolean_t on = true;\n        boolean_t header = true;\n\n        for (Service_T s = servicelist_conf; s; s = s->next_conf) {\n                if (s->type != Service_Filesystem)\n                        continue;\n                if (header) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<table id='header-row'>\"\n                                            \"<tr>\"\n                                            \"<th class='left first'>Filesystem<\/th>\"\n                                            \"<th class='left'>Status<\/th>\"\n                                            \"<th class='right'>Space usage<\/th>\"\n                                            \"<th class='right'>Inodes usage<\/th>\"\n                                            \"<th class='right column'>Read<\/th>\"\n                                            \"<th class='right column'>Write<\/th>\"\n                                            \"<\/tr>\");\n                        header = false;\n                }\n                StringBuffer_append(res->outputbuffer,\n                                    \"<tr %s>\"\n                                    \"<td class='left'><a href='%s'>%s<\/a><\/td>\"\n                                    \"<td class='left'>%s<\/td>\",\n                                    on ? \"class='stripe'\" : \"\",\n                                    s->name, s->name,\n                                    get_service_status(HTML, s, buf, sizeof(buf)));\n                if (! Util_hasServiceStatus(s)) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<td class='right'>- [-]<\/td>\"\n                                            \"<td class='right'>- [-]<\/td>\"\n                                            \"<td class='right column'>- [-]<\/td>\"\n                                            \"<td class='right column'>- [-]<\/td>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<td class='right column%s'>%.1f%% [%s]<\/td>\",\n                                            (s->error & Event_Resource) ? \" red-text\" : \"\",\n                                            s->inf.filesystem->space_percent,\n                                            s->inf.filesystem->f_bsize > 0 ? Fmt_bytes2str(s->inf.filesystem->f_blocksused * s->inf.filesystem->f_bsize, buf) : \"0 MB\");\n                        if (s->inf.filesystem->f_files > 0) {\n                                StringBuffer_append(res->outputbuffer,\n                                                    \"<td class='right column%s'>%.1f%% [%lld objects]<\/td>\",\n                                                    (s->error & Event_Resource) ? \" red-text\" : \"\",\n                                                    s->inf.filesystem->inode_percent,\n                                                    s->inf.filesystem->f_filesused);\n                        } else {\n                                StringBuffer_append(res->outputbuffer,\n                                                    \"<td class='right column'>not supported by filesystem<\/td>\");\n                        }\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<td class='right column%s'>%s\/s<\/td>\"\n                                            \"<td class='right column%s'>%s\/s<\/td>\",\n                                            (s->error & Event_Resource) ? \" red-text\" : \"\",\n                                            Fmt_bytes2str(Statistics_deltaNormalize(&(s->inf.filesystem->read.bytes)), (char[10]){}),\n                                            (s->error & Event_Resource) ? \" red-text\" : \"\",\n                                            Fmt_bytes2str(Statistics_deltaNormalize(&(s->inf.filesystem->write.bytes)), (char[10]){}));\n                }\n                StringBuffer_append(res->outputbuffer, \"<\/tr>\");\n                on = ! on;\n        }\n        if (! header)\n                StringBuffer_append(res->outputbuffer, \"<\/table>\");\n}","target":0,"code_token_length":700,"total_token_length":936,"max_tokens_setting":1024}
+{"idx":307865,"func":"ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter)\n  : _ciEnv_arena(mtCompiler) {\n  VM_ENTRY_MARK;\n\n  \/\/ Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.\n  thread->set_env(this);\n  assert(ciEnv::current() == this, \"sanity\");\n\n  _oop_recorder = NULL;\n  _debug_info = NULL;\n  _dependencies = NULL;\n  _failure_reason = NULL;\n  _compilable = MethodCompilable;\n  _break_at_compile = false;\n  _compiler_data = NULL;\n#ifndef PRODUCT\n  assert(!firstEnv, \"not initialized properly\");\n#endif \/* !PRODUCT *\/\n\n  _system_dictionary_modification_counter = system_dictionary_modification_counter;\n  _num_inlined_bytecodes = 0;\n  assert(task == NULL || thread->task() == task, \"sanity\");\n  _task = task;\n  _log = NULL;\n\n  \/\/ Temporary buffer for creating symbols and such.\n  _name_buffer = NULL;\n  _name_buffer_len = 0;\n\n  _arena   = &_ciEnv_arena;\n  _factory = new (_arena) ciObjectFactory(_arena, 128);\n\n  \/\/ Preload commonly referenced system ciObjects.\n\n  \/\/ During VM initialization, these instances have not yet been created.\n  \/\/ Assertions ensure that these instances are not accessed before\n  \/\/ their initialization.\n\n  assert(Universe::is_fully_initialized(), \"should be complete\");\n\n  oop o = Universe::null_ptr_exception_instance();\n  assert(o != NULL, \"should have been initialized\");\n  _NullPointerException_instance = get_object(o)->as_instance();\n  o = Universe::arithmetic_exception_instance();\n  assert(o != NULL, \"should have been initialized\");\n  _ArithmeticException_instance = get_object(o)->as_instance();\n\n  _ArrayIndexOutOfBoundsException_instance = NULL;\n  _ArrayStoreException_instance = NULL;\n  _ClassCastException_instance = NULL;\n  _the_null_string = NULL;\n  _the_min_jint_string = NULL;\n\n  _jvmti_can_hotswap_or_post_breakpoint = false;\n  _jvmti_can_access_local_variables = false;\n  _jvmti_can_post_on_exceptions = false;\n  _jvmti_can_pop_frame = false;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":352951,"func":"csnNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tstruct berval\tcnt, sid, mod;\n\tchar\t\t*ptr;\n\tber_len_t\ti;\n\n\tassert( val != NULL );\n\tassert( normalized != NULL );\n\n\tassert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) != 0 );\n\n\tif ( BER_BVISEMPTY( val ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( val->bv_len == STRLENOF( \"YYYYmmddHHMMSSZ#SSSSSS#ID#ssssss\" ) ) {\n\t\t\/* Openldap <= 2.3 *\/\n\n\t\treturn csnNormalize23( usage, syntax, mr, val, normalized, ctx );\n\t}\n\n\tif ( val->bv_len == STRLENOF( \"YYYYmmddHH:MM:SSZ#0xSSSS#I#ssss\" ) ) {\n\t\t\/* Openldap 2.1 *\/\n\n\t\treturn csnNormalize21( usage, syntax, mr, val, normalized, ctx );\n\t}\n\n\tif ( val->bv_len != STRLENOF( \"YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tptr = ber_bvchr( val, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( ptr - val->bv_val != STRLENOF( \"YYYYmmddHHMMSS.uuuuuuZ\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tcnt.bv_val = ptr + 1;\n\tcnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val );\n\n\tptr = ber_bvchr( &cnt, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( ptr - cnt.bv_val != STRLENOF( \"000000\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tsid.bv_val = ptr + 1;\n\tsid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val );\n\t\t\n\tptr = ber_bvchr( &sid, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tsid.bv_len = ptr - sid.bv_val;\n\tif ( sid.bv_len != STRLENOF( \"000\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tmod.bv_val = ptr + 1;\n\tmod.bv_len = val->bv_len - ( mod.bv_val - val->bv_val );\n\n\tif ( mod.bv_len != STRLENOF( \"000000\" ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tber_dupbv_x( normalized, val, ctx );\n\n\tfor ( i = STRLENOF( \"YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#\" );\n\t\ti < normalized->bv_len; i++ )\n\t{\n\t\t\/* assume it's already validated that's all hex digits *\/\n\t\tnormalized->bv_val[ i ] = TOLOWER( normalized->bv_val[ i ] );\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":309987,"func":"main(int argc, char **argv)\n{\n    char *term;\n    int errret;\n    bool cmdline = TRUE;\n    int c;\n    char buf[BUFSIZ];\n    int result = 0;\n    int fd;\n    TTY tty_settings;\n    bool opt_x = FALSE;\t\t\/* clear scrollback if possible *\/\n    bool is_alias;\n    bool need_tty;\n\n    prg_name = check_aliases(_nc_rootname(argv[0]), TRUE);\n\n    term = getenv(\"TERM\");\n\n    while ((c = getopt(argc, argv, \"ST:Vx\")) != -1) {\n\tswitch (c) {\n\tcase 'S':\n\t    cmdline = FALSE;\n\t    break;\n\tcase 'T':\n\t    use_env(FALSE);\n\t    use_tioctl(TRUE);\n\t    term = optarg;\n\t    break;\n\tcase 'V':\n\t    puts(curses_version());\n\t    ExitProgram(EXIT_SUCCESS);\n\tcase 'x':\t\t\/* do not try to clear scrollback *\/\n\t    opt_x = TRUE;\n\t    break;\n\tdefault:\n\t    usage();\n\t    \/* NOTREACHED *\/\n\t}\n    }\n\n    is_alias = (is_clear || is_reset || is_init);\n    need_tty = ((is_reset || is_init) ||\n\t\t(optind < argc &&\n\t\t (!strcmp(argv[optind], \"reset\") ||\n\t\t  !strcmp(argv[optind], \"init\"))));\n\n    \/*\n     * Modify the argument list to omit the options we processed.\n     *\/\n    if (is_alias) {\n\tif (optind-- < argc) {\n\t    argc -= optind;\n\t    argv += optind;\n\t}\n\targv[0] = prg_name;\n    } else {\n\targc -= optind;\n\targv += optind;\n    }\n\n    if (term == 0 || *term == '\\0')\n\tquit(ErrUsage, \"No value for $TERM and no -T specified\");\n\n    fd = save_tty_settings(&tty_settings, need_tty);\n\n    if (setupterm(term, fd, &errret) != OK && errret <= 0)\n\tquit(ErrTermType, \"unknown terminal \\\"%s\\\"\", term);\n\n    if (cmdline) {\n\tif ((argc <= 0) && !is_alias)\n\t    usage();\n\tExitProgram(tput_cmd(fd, &tty_settings, opt_x, argc, argv));\n    }\n\n    while (fgets(buf, sizeof(buf), stdin) != 0) {\n\tchar *argvec[16];\t\/* command, 9 parms, null, & slop *\/\n\tint argnum = 0;\n\tchar *cp;\n\n\t\/* crack the argument list into a dope vector *\/\n\tfor (cp = buf; *cp; cp++) {\n\t    if (isspace(UChar(*cp))) {\n\t\t*cp = '\\0';\n\t    } else if (cp == buf || cp[-1] == 0) {\n\t\targvec[argnum++] = cp;\n\t\tif (argnum >= (int) SIZEOF(argvec) - 1)\n\t\t    break;\n\t    }\n\t}\n\targvec[argnum] = 0;\n\n\tif (argnum != 0\n\t    && tput_cmd(fd, &tty_settings, opt_x, argnum, argvec) != 0) {\n\t    if (result == 0)\n\t\tresult = ErrSystem(0);\t\/* will return value >4 *\/\n\t    ++result;\n\t}\n    }\n\n    ExitProgram(result);\n}","target":0,"code_token_length":702,"total_token_length":938,"max_tokens_setting":1024}
+{"idx":312382,"func":"ex_cc(exarg_T *eap)\n{\n    qf_info_T\t*qi;\n    int\t\terrornr;\n\n    if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL)\n\treturn;\n\n    if (eap->addr_count > 0)\n\terrornr = (int)eap->line2;\n    else\n    {\n\tswitch (eap->cmdidx)\n\t{\n\t    case CMD_cc: case CMD_ll:\n\t\terrornr = 0;\n\t\tbreak;\n\t    case CMD_crewind: case CMD_lrewind: case CMD_cfirst:\n\t    case CMD_lfirst:\n\t\terrornr = 1;\n\t\tbreak;\n\t    default:\n\t\terrornr = 32767;\n\t}\n    }\n\n    \/\/ For cdo and ldo commands, jump to the nth valid error.\n    \/\/ For cfdo and lfdo commands, jump to the nth valid file entry.\n    if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo\n\t    || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)\n\terrornr = qf_get_nth_valid_entry(qf_get_curlist(qi),\n\t\teap->addr_count > 0 ? (int)eap->line1 : 1,\n\t\teap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo);\n\n    qf_jump(qi, 0, errornr, eap->forceit);\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":413640,"func":"static bool esilbreak_mem_read(RAnalEsil *esil, ut64 addr, ut8 *buf, int len) {\n\tut8 str[128];\n\tif (addr != UT64_MAX) {\n\t\tesilbreak_last_read = addr;\n\t}\n\thandle_var_stack_access (esil, addr, R_ANAL_VAR_ACCESS_TYPE_READ, len);\n\tif (myvalid (mycore->io, addr) && r_io_read_at (mycore->io, addr, (ut8*)buf, len)) {\n\t\tut64 refptr;\n\t\tbool trace = true;\n\t\tswitch (len) {\n\t\tcase 2:\n\t\t\tesilbreak_last_data = refptr = (ut64)r_read_ble16 (buf, esil->anal->big_endian);\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tesilbreak_last_data = refptr = (ut64)r_read_ble32 (buf, esil->anal->big_endian);\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tesilbreak_last_data = refptr = r_read_ble64 (buf, esil->anal->big_endian);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttrace = false;\n\t\t\tr_io_read_at (mycore->io, addr, (ut8*)buf, len);\n\t\t\tbreak;\n\t\t}\n\t\t\/\/ TODO incorrect\n\t\tbool validRef = false;\n\t\tif (trace && myvalid (mycore->io, refptr)) {\n\t\t\tif (ntarget == UT64_MAX || ntarget == refptr) {\n\t\t\t\tstr[0] = 0;\n\t\t\t\tif (r_io_read_at (mycore->io, refptr, str, sizeof (str)) < 1) {\n\t\t\t\t\t\/\/eprintf (\"Invalid read\\n\");\n\t\t\t\t\tstr[0] = 0;\n\t\t\t\t\tvalidRef = false;\n\t\t\t\t} else {\n\t\t\t\t\tr_anal_xrefs_set (mycore->anal, esil->address, refptr, R_ANAL_REF_TYPE_DATA);\n\t\t\t\t\tstr[sizeof (str) - 1] = 0;\n\t\t\t\t\tadd_string_ref (mycore, esil->address, refptr);\n\t\t\t\t\tesilbreak_last_data = UT64_MAX;\n\t\t\t\t\tvalidRef = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/** resolve ptr *\/\n\t\tif (ntarget == UT64_MAX || ntarget == addr || (ntarget == UT64_MAX && !validRef)) {\n\t\t\tr_anal_xrefs_set (mycore->anal, esil->address, addr, R_ANAL_REF_TYPE_DATA);\n\t\t}\n\t}\n\treturn false; \/\/ fallback\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":273896,"func":"static int open_data_connection(ctrl_t *ctrl)\n{\n\tsocklen_t len = sizeof(struct sockaddr);\n\tstruct sockaddr_in sin;\n\n\t\/* Previous PORT command from client *\/\n\tif (ctrl->data_address[0]) {\n\t\tint rc;\n\n\t\tctrl->data_sd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);\n\t\tif (-1 == ctrl->data_sd) {\n\t\t\tERR(errno, \"Failed creating data socket\");\n\t\t\treturn -1;\n\t\t}\n\n\t\tmemset(&sin, 0, sizeof(sin));\n\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = htons(ctrl->data_port);\n\t\tinet_aton(ctrl->data_address, &(sin.sin_addr));\n\n\t\trc = connect(ctrl->data_sd, (struct sockaddr *)&sin, len);\n\t\tif (rc == -1 && EINPROGRESS != errno) {\n\t\t\tERR(errno, \"Failed connecting data socket to client\");\n\t\t\tclose(ctrl->data_sd);\n\t\t\tctrl->data_sd = -1;\n\n\t\t\treturn -1;\n\t\t}\n\n\t\tDBG(\"Connected successfully to client's previously requested address:PORT %s:%d\",\n\t\t    ctrl->data_address, ctrl->data_port);\n\t\treturn 0;\n\t}\n\n\t\/* Previous PASV command, accept connect from client *\/\n\tif (ctrl->data_listen_sd > 0) {\n\t\tconst int const_int_1 = 1;\n\t\tint retries = 3;\n\t\tchar client_ip[100];\n\n\tretry:\n\t\tctrl->data_sd = accept(ctrl->data_listen_sd, (struct sockaddr *)&sin, &len);\n\t\tif (-1 == ctrl->data_sd) {\n\t\t\tif (EAGAIN == errno && --retries) {\n\t\t\t\tsleep(1);\n\t\t\t\tgoto retry;\n\t\t\t}\n\n\t\t\tERR(errno, \"Failed accepting connection from client\");\n\t\t\treturn -1;\n\t\t}\n\n\t\tsetsockopt(ctrl->data_sd, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));\n\t\tset_nonblock(ctrl->data_sd);\n\n\t\tinet_ntop(AF_INET, &(sin.sin_addr), client_ip, INET_ADDRSTRLEN);\n\t\tDBG(\"Client PASV data connection from %s:%d\", client_ip, ntohs(sin.sin_port));\n\n\t\tclose(ctrl->data_listen_sd);\n\t\tctrl->data_listen_sd = -1;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":328878,"func":"R_API void r_bin_java_get_fm_type_definition_json(RBinJavaObj *bin, RBinJavaField *fm_type, PJ *pj, int is_method) {\n\tr_return_if_fail (bin && fm_type && pj);\n\n\tut64 addr = UT64_MAX;\n\tchar *prototype = NULL, *fq_name = NULL;\n\tbool is_native = ((fm_type->flags & R_BIN_JAVA_METHOD_ACC_NATIVE) != 0);\n\tbool is_static = ((fm_type->flags & R_BIN_JAVA_METHOD_ACC_STATIC) != 0);\n\tbool is_synthetic = ((fm_type->flags & R_BIN_JAVA_METHOD_ACC_SYNTHETIC) != 0);\n\tbool is_private = ((fm_type->flags & R_BIN_JAVA_METHOD_ACC_PRIVATE) != 0);\n\tbool is_public = ((fm_type->flags & R_BIN_JAVA_METHOD_ACC_PUBLIC) != 0);\n\tbool is_protected = ((fm_type->flags & R_BIN_JAVA_METHOD_ACC_PROTECTED) != 0);\n\tbool is_super = ((fm_type->flags & R_BIN_JAVA_CLASS_ACC_SUPER) != 0);\n\n\tpj_o (pj);\n\tpj_ki (pj, \"access_flags\", fm_type->flags);\n\tpj_ki (pj, \"is_method\", is_method);\n\tpj_ki (pj, \"is_native\", is_native);\n\tpj_ki (pj, \"is_synthetic\", is_synthetic);\n\tpj_ki (pj, \"is_private\", is_private);\n\tpj_ki (pj, \"is_public\", is_public);\n\tpj_ki (pj, \"is_static\", is_static);\n\tpj_ki (pj, \"is_protected\", is_protected);\n\tpj_ki (pj, \"is_super\", is_super);\n\n\taddr = r_bin_java_get_method_code_offset (fm_type);\n\tif (addr == 0) {\n\t\taddr = fm_type->file_offset;\n\t}\n\taddr += bin->loadaddr;\n\n\tpj_ki (pj, \"addr\", addr);\n\tpj_ki (pj, \"offset\", fm_type->file_offset + bin->loadaddr);\n\tpj_ks (pj, \"class_name\", fm_type->class_name);\n\tpj_ks (pj, \"signature\", fm_type->descriptor);\n\tpj_ks (pj, \"name\", fm_type->name);\n\n\tif (is_method) {\n\t\tfq_name = r_bin_java_create_method_fq_str (fm_type->class_name, fm_type->name, fm_type->descriptor);\n\t} else {\n\t\tfq_name = r_bin_java_create_field_fq_str (fm_type->class_name, fm_type->name, fm_type->descriptor);\n\t}\n\tpj_ks (pj, \"fq_name\", fq_name);\n\tfree (fq_name);\n\n\tprototype = r_bin_java_unmangle (fm_type->flags_str, fm_type->name, fm_type->descriptor);\n\tpj_ks (pj, \"prototype\", prototype);\n\tfree (prototype);\n\n\tpj_end (pj);\n}","target":0,"code_token_length":627,"total_token_length":863,"max_tokens_setting":1024}
+{"idx":238557,"func":"static int __check_mem_access(struct bpf_verifier_env *env, int regno,\n\t\t\t      int off, int size, u32 mem_size,\n\t\t\t      bool zero_size_allowed)\n{\n\tbool size_ok = size > 0 || (size == 0 && zero_size_allowed);\n\tstruct bpf_reg_state *reg;\n\n\tif (off >= 0 && size_ok && (u64)off + size <= mem_size)\n\t\treturn 0;\n\n\treg = &cur_regs(env)[regno];\n\tswitch (reg->type) {\n\tcase PTR_TO_MAP_KEY:\n\t\tverbose(env, \"invalid access to map key, key_size=%d off=%d size=%d\\n\",\n\t\t\tmem_size, off, size);\n\t\tbreak;\n\tcase PTR_TO_MAP_VALUE:\n\t\tverbose(env, \"invalid access to map value, value_size=%d off=%d size=%d\\n\",\n\t\t\tmem_size, off, size);\n\t\tbreak;\n\tcase PTR_TO_PACKET:\n\tcase PTR_TO_PACKET_META:\n\tcase PTR_TO_PACKET_END:\n\t\tverbose(env, \"invalid access to packet, off=%d size=%d, R%d(id=%d,off=%d,r=%d)\\n\",\n\t\t\toff, size, regno, reg->id, off, mem_size);\n\t\tbreak;\n\tcase PTR_TO_MEM:\n\tdefault:\n\t\tverbose(env, \"invalid access to memory, mem_size=%u off=%d size=%d\\n\",\n\t\t\tmem_size, off, size);\n\t}\n\n\treturn -EACCES;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":359524,"func":"peer_remote_as_vty (struct vty *vty, const char *peer_str, \n                    const char *as_str, afi_t afi, safi_t safi)\n{\n  int ret;\n  struct bgp *bgp;\n  as_t as;\n  union sockunion su;\n\n  bgp = vty->index;\n\n  \/* Get AS number.  *\/\n  VTY_GET_INTEGER_RANGE (\"AS\", as, as_str, 1, 65535);\n\n  \/* If peer is peer group, call proper function.  *\/\n  ret = str2sockunion (peer_str, &su);\n  if (ret < 0)\n    {\n      ret = peer_group_remote_as (bgp, peer_str, &as);\n      if (ret < 0)\n\t{\n\t  vty_out (vty, \"%% Create the peer-group first%s\", VTY_NEWLINE);\n\t  return CMD_WARNING;\n\t}\n      return CMD_SUCCESS;\n    }\n\n  if (peer_address_self_check (&su))\n    {\n      vty_out (vty, \"%% Can not configure the local system as neighbor%s\",\n\t       VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  ret = peer_remote_as (bgp, &su, &as, afi, safi);\n\n  \/* This peer belongs to peer group.  *\/\n  switch (ret)\n    {\n    case BGP_ERR_PEER_GROUP_MEMBER:\n      vty_out (vty, \"%% Peer-group AS %d. Cannot configure remote-as for member%s\", as, VTY_NEWLINE);\n      return CMD_WARNING;\n    case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:\n      vty_out (vty, \"%% The AS# can not be changed from %d to %s, peer-group members must be all internal or all external%s\", as, as_str, VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":207520,"func":"static const ut8 *parse_die(const ut8 *buf, const ut8 *buf_end, RzBinDwarfDebugInfo *info, RzBinDwarfAbbrevDecl *abbrev,\n\tRzBinDwarfCompUnitHdr *hdr, RzBinDwarfDie *die, const ut8 *debug_str, size_t debug_str_len, bool big_endian) {\n\tsize_t i;\n\tconst char *comp_dir = NULL;\n\tut64 line_info_offset = UT64_MAX;\n\tfor (i = 0; i < abbrev->count - 1; i++) {\n\t\tmemset(&die->attr_values[i], 0, sizeof(die->attr_values[i]));\n\n\t\tbuf = parse_attr_value(buf, buf_end - buf, &abbrev->defs[i],\n\t\t\t&die->attr_values[i], hdr, debug_str, debug_str_len, big_endian);\n\n\t\tRzBinDwarfAttrValue *attribute = &die->attr_values[i];\n\n\t\tif (attribute->attr_name == DW_AT_comp_dir && (attribute->attr_form == DW_FORM_strp || attribute->attr_form == DW_FORM_string) && attribute->string.content) {\n\t\t\tcomp_dir = attribute->string.content;\n\t\t}\n\t\tif (attribute->attr_name == DW_AT_stmt_list) {\n\t\t\tif (attribute->kind == DW_AT_KIND_CONSTANT) {\n\t\t\t\tline_info_offset = attribute->uconstant;\n\t\t\t} else if (attribute->kind == DW_AT_KIND_REFERENCE) {\n\t\t\t\tline_info_offset = attribute->reference;\n\t\t\t}\n\t\t}\n\t\tdie->count++;\n\t}\n\n\t\/\/ If this is a compilation unit dir attribute, we want to cache it so the line info parsing\n\t\/\/ which will need this info can quickly look it up.\n\tif (comp_dir && line_info_offset != UT64_MAX) {\n\t\tchar *name = strdup(comp_dir);\n\t\tif (name) {\n\t\t\tif (!ht_up_insert(info->line_info_offset_comp_dir, line_info_offset, name)) {\n\t\t\t\tfree(name);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buf;\n}","target":1,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":238602,"func":"static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)\n{\n\tstruct bpf_insn_aux_data *aux = cur_aux(env);\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tstruct bpf_reg_state *dst_reg;\n\tstruct bpf_map *map;\n\tint err;\n\n\tif (BPF_SIZE(insn->code) != BPF_DW) {\n\t\tverbose(env, \"invalid BPF_LD_IMM insn\\n\");\n\t\treturn -EINVAL;\n\t}\n\tif (insn->off != 0) {\n\t\tverbose(env, \"BPF_LD_IMM64 uses reserved fields\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\terr = check_reg_arg(env, insn->dst_reg, DST_OP);\n\tif (err)\n\t\treturn err;\n\n\tdst_reg = ®s[insn->dst_reg];\n\tif (insn->src_reg == 0) {\n\t\tu64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;\n\n\t\tdst_reg->type = SCALAR_VALUE;\n\t\t__mark_reg_known(®s[insn->dst_reg], imm);\n\t\treturn 0;\n\t}\n\n\t\/* All special src_reg cases are listed below. From this point onwards\n\t * we either succeed and assign a corresponding dst_reg->type after\n\t * zeroing the offset, or fail and reject the program.\n\t *\/\n\tmark_reg_known_zero(env, regs, insn->dst_reg);\n\n\tif (insn->src_reg == BPF_PSEUDO_BTF_ID) {\n\t\tdst_reg->type = aux->btf_var.reg_type;\n\t\tswitch (base_type(dst_reg->type)) {\n\t\tcase PTR_TO_MEM:\n\t\t\tdst_reg->mem_size = aux->btf_var.mem_size;\n\t\t\tbreak;\n\t\tcase PTR_TO_BTF_ID:\n\t\tcase PTR_TO_PERCPU_BTF_ID:\n\t\t\tdst_reg->btf = aux->btf_var.btf;\n\t\t\tdst_reg->btf_id = aux->btf_var.btf_id;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\t\treturn -EFAULT;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tif (insn->src_reg == BPF_PSEUDO_FUNC) {\n\t\tstruct bpf_prog_aux *aux = env->prog->aux;\n\t\tu32 subprogno = find_subprog(env,\n\t\t\t\t\t     env->insn_idx + insn->imm + 1);\n\n\t\tif (!aux->func_info) {\n\t\t\tverbose(env, \"missing btf func_info\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (aux->func_info_aux[subprogno].linkage != BTF_FUNC_STATIC) {\n\t\t\tverbose(env, \"callback function not static\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tdst_reg->type = PTR_TO_FUNC;\n\t\tdst_reg->subprogno = subprogno;\n\t\treturn 0;\n\t}\n\n\tmap = env->used_maps[aux->map_index];\n\tdst_reg->map_ptr = map;\n\n\tif (insn->src_reg == BPF_PSEUDO_MAP_VALUE ||\n\t    insn->src_reg == BPF_PSEUDO_MAP_IDX_VALUE) {\n\t\tdst_reg->type = PTR_TO_MAP_VALUE;\n\t\tdst_reg->off = aux->map_off;\n\t\tif (map_value_has_spin_lock(map))\n\t\t\tdst_reg->id = ++env->id_gen;\n\t} else if (insn->src_reg == BPF_PSEUDO_MAP_FD ||\n\t\t   insn->src_reg == BPF_PSEUDO_MAP_IDX) {\n\t\tdst_reg->type = CONST_PTR_TO_MAP;\n\t} else {\n\t\tverbose(env, \"bpf verifier is misconfigured\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":785,"total_token_length":1021,"max_tokens_setting":1024}
+{"idx":390531,"func":"ProcXkbGetControls(ClientPtr client)\n{\n    xkbGetControlsReply rep;\n    XkbControlsPtr\txkb;\n    DeviceIntPtr \tdev;\n    register int \tn;\n\n    REQUEST(xkbGetControlsReq);\n    REQUEST_SIZE_MATCH(xkbGetControlsReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);\n    \n    xkb = dev->key->xkbInfo->desc->ctrls;\n    rep.type = X_Reply;\n    rep.length = (SIZEOF(xkbGetControlsReply)-\n\t\t  SIZEOF(xGenericReply)) >> 2;\n    rep.sequenceNumber = client->sequence;\n    rep.deviceID = ((DeviceIntPtr)dev)->id;\n    rep.numGroups = xkb->num_groups;\n    rep.groupsWrap = xkb->groups_wrap;\n    rep.internalMods = xkb->internal.mask;\n    rep.ignoreLockMods = xkb->ignore_lock.mask;\n    rep.internalRealMods = xkb->internal.real_mods;\n    rep.ignoreLockRealMods = xkb->ignore_lock.real_mods;\n    rep.internalVMods = xkb->internal.vmods;\n    rep.ignoreLockVMods = xkb->ignore_lock.vmods;\n    rep.enabledCtrls = xkb->enabled_ctrls;\n    rep.repeatDelay = xkb->repeat_delay;\n    rep.repeatInterval = xkb->repeat_interval;\n    rep.slowKeysDelay = xkb->slow_keys_delay;\n    rep.debounceDelay = xkb->debounce_delay;\n    rep.mkDelay = xkb->mk_delay;\n    rep.mkInterval = xkb->mk_interval;\n    rep.mkTimeToMax = xkb->mk_time_to_max;\n    rep.mkMaxSpeed = xkb->mk_max_speed;\n    rep.mkCurve = xkb->mk_curve;\n    rep.mkDfltBtn = xkb->mk_dflt_btn;\n    rep.axTimeout = xkb->ax_timeout;\n    rep.axtCtrlsMask = xkb->axt_ctrls_mask;\n    rep.axtCtrlsValues = xkb->axt_ctrls_values;\n    rep.axtOptsMask = xkb->axt_opts_mask;\n    rep.axtOptsValues = xkb->axt_opts_values;\n    rep.axOptions = xkb->ax_options;\n    memcpy(rep.perKeyRepeat,xkb->per_key_repeat,XkbPerKeyBitArraySize);\n    if (client->swapped) {\n    \tswaps(&rep.sequenceNumber, n);\n\tswapl(&rep.length,n);\n\tswaps(&rep.internalVMods, n);\n\tswaps(&rep.ignoreLockVMods, n);\n\tswapl(&rep.enabledCtrls, n);\n\tswaps(&rep.repeatDelay, n);\n\tswaps(&rep.repeatInterval, n);\n\tswaps(&rep.slowKeysDelay, n);\n\tswaps(&rep.debounceDelay, n);\n\tswaps(&rep.mkDelay, n);\n\tswaps(&rep.mkInterval, n);\n\tswaps(&rep.mkTimeToMax, n);\n\tswaps(&rep.mkMaxSpeed, n);\n\tswaps(&rep.mkCurve, n);\n\tswaps(&rep.axTimeout, n);\n\tswapl(&rep.axtCtrlsMask, n);\n\tswapl(&rep.axtCtrlsValues, n);\n\tswaps(&rep.axtOptsMask, n);\n\tswaps(&rep.axtOptsValues, n);\n\tswaps(&rep.axOptions, n);\n    }\n    WriteToClient(client, SIZEOF(xkbGetControlsReply), (char *)&rep);\n    return(client->noClientException);\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":343144,"func":"int esp_input_done2(struct sk_buff *skb, int err)\n{\n\tconst struct iphdr *iph;\n\tstruct xfrm_state *x = xfrm_input_state(skb);\n\tstruct xfrm_offload *xo = xfrm_offload(skb);\n\tstruct crypto_aead *aead = x->data;\n\tint hlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead);\n\tint ihl;\n\n\tif (!xo || !(xo->flags & CRYPTO_DONE))\n\t\tkfree(ESP_SKB_CB(skb)->tmp);\n\n\tif (unlikely(err))\n\t\tgoto out;\n\n\terr = esp_remove_trailer(skb);\n\tif (unlikely(err < 0))\n\t\tgoto out;\n\n\tiph = ip_hdr(skb);\n\tihl = iph->ihl * 4;\n\n\tif (x->encap) {\n\t\tstruct xfrm_encap_tmpl *encap = x->encap;\n\t\tstruct tcphdr *th = (void *)(skb_network_header(skb) + ihl);\n\t\tstruct udphdr *uh = (void *)(skb_network_header(skb) + ihl);\n\t\t__be16 source;\n\n\t\tswitch (x->encap->encap_type) {\n\t\tcase TCP_ENCAP_ESPINTCP:\n\t\t\tsource = th->source;\n\t\t\tbreak;\n\t\tcase UDP_ENCAP_ESPINUDP:\n\t\tcase UDP_ENCAP_ESPINUDP_NON_IKE:\n\t\t\tsource = uh->source;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tWARN_ON_ONCE(1);\n\t\t\terr = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/*\n\t\t * 1) if the NAT-T peer's IP or port changed then\n\t\t *    advertize the change to the keying daemon.\n\t\t *    This is an inbound SA, so just compare\n\t\t *    SRC ports.\n\t\t *\/\n\t\tif (iph->saddr != x->props.saddr.a4 ||\n\t\t    source != encap->encap_sport) {\n\t\t\txfrm_address_t ipaddr;\n\n\t\t\tipaddr.a4 = iph->saddr;\n\t\t\tkm_new_mapping(x, &ipaddr, source);\n\n\t\t\t\/* XXX: perhaps add an extra\n\t\t\t * policy check here, to see\n\t\t\t * if we should allow or\n\t\t\t * reject a packet from a\n\t\t\t * different source\n\t\t\t * address\/port.\n\t\t\t *\/\n\t\t}\n\n\t\t\/*\n\t\t * 2) ignore UDP\/TCP checksums in case\n\t\t *    of NAT-T in Transport Mode, or\n\t\t *    perform other post-processing fixes\n\t\t *    as per draft-ietf-ipsec-udp-encaps-06,\n\t\t *    section 3.1.2\n\t\t *\/\n\t\tif (x->props.mode == XFRM_MODE_TRANSPORT)\n\t\t\tskb->ip_summed = CHECKSUM_UNNECESSARY;\n\t}\n\n\tskb_pull_rcsum(skb, hlen);\n\tif (x->props.mode == XFRM_MODE_TUNNEL)\n\t\tskb_reset_transport_header(skb);\n\telse\n\t\tskb_set_transport_header(skb, -ihl);\n\n\t\/* RFC4303: Drop dummy packets without any error *\/\n\tif (err == IPPROTO_NONE)\n\t\terr = -EINVAL;\n\nout:\n\treturn err;\n}","target":0,"code_token_length":666,"total_token_length":902,"max_tokens_setting":1024}
+{"idx":387853,"func":"void InstanceKlass::add_previous_version(InstanceKlass* scratch_class,\n                                         int emcp_method_count) {\n  assert(Thread::current()->is_VM_thread(),\n         \"only VMThread can add previous versions\");\n\n  ResourceMark rm;\n  log_trace(redefine, class, iklass, add)\n    (\"adding previous version ref for %s, EMCP_cnt=%d\", scratch_class->external_name(), emcp_method_count);\n\n  \/\/ Clean out old previous versions for this class\n  purge_previous_version_list();\n\n  \/\/ Mark newly obsolete methods in remaining previous versions.  An EMCP method from\n  \/\/ a previous redefinition may be made obsolete by this redefinition.\n  Array<Method*>* old_methods = scratch_class->methods();\n  mark_newly_obsolete_methods(old_methods, emcp_method_count);\n\n  \/\/ If the constant pool for this previous version of the class\n  \/\/ is not marked as being on the stack, then none of the methods\n  \/\/ in this previous version of the class are on the stack so\n  \/\/ we don't need to add this as a previous version.\n  ConstantPool* cp_ref = scratch_class->constants();\n  if (!cp_ref->on_stack()) {\n    log_trace(redefine, class, iklass, add)(\"scratch class not added; no methods are running\");\n    \/\/ For debugging purposes.\n    scratch_class->set_is_scratch_class();\n    scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class);\n    return;\n  }\n\n  if (emcp_method_count != 0) {\n    \/\/ At least one method is still running, check for EMCP methods\n    for (int i = 0; i < old_methods->length(); i++) {\n      Method* old_method = old_methods->at(i);\n      if (!old_method->is_obsolete() && old_method->on_stack()) {\n        \/\/ if EMCP method (not obsolete) is on the stack, mark as EMCP so that\n        \/\/ we can add breakpoints for it.\n\n        \/\/ We set the method->on_stack bit during safepoints for class redefinition\n        \/\/ and use this bit to set the is_running_emcp bit.\n        \/\/ After the safepoint, the on_stack bit is cleared and the running emcp\n        \/\/ method may exit.   If so, we would set a breakpoint in a method that\n        \/\/ is never reached, but this won't be noticeable to the programmer.\n        old_method->set_running_emcp(true);\n        log_trace(redefine, class, iklass, add)\n          (\"EMCP method %s is on_stack \" INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method));\n      } else if (!old_method->is_obsolete()) {\n        log_trace(redefine, class, iklass, add)\n          (\"EMCP method %s is NOT on_stack \" INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method));\n      }\n    }\n  }\n\n  \/\/ Add previous version if any methods are still running.\n  \/\/ Set has_previous_version flag for processing during class unloading.\n  _has_previous_versions = true;\n  log_trace(redefine, class, iklass, add) (\"scratch class added; one of its methods is on_stack.\");\n  assert(scratch_class->previous_versions() == NULL, \"shouldn't have a previous version\");\n  scratch_class->link_previous_versions(previous_versions());\n  link_previous_versions(scratch_class);\n} \/\/ end add_previous_version()","target":0,"code_token_length":734,"total_token_length":970,"max_tokens_setting":1024}
+{"idx":462425,"func":"DataRcvdUncompressed(ptcpsess_t *pThis, char *pData, size_t iLen, struct syslogTime *stTime, time_t ttGenTime)\n{\n\tmulti_submit_t multiSub;\n\tsmsg_t *pMsgs[CONF_NUM_MULTISUB];\n\tchar *pEnd;\n\tunsigned nMsgs = 0;\n\tDEFiRet;\n\n\tassert(pData != NULL);\n\tassert(iLen > 0);\n\n\tif(ttGenTime == 0)\n\t\tdatetime.getCurrTime(stTime, &ttGenTime, TIME_IN_LOCALTIME);\n\tmultiSub.ppMsgs = pMsgs;\n\tmultiSub.maxElem = CONF_NUM_MULTISUB;\n\tmultiSub.nElem = 0;\n\n\t \/* We now copy the message to the session buffer. *\/\n\tpEnd = pData + iLen; \/* this is one off, which is intensional *\/\n\n\twhile(pData < pEnd) {\n\t\tCHKiRet(processDataRcvd(pThis, &pData, pEnd - pData, stTime, ttGenTime, &multiSub, &nMsgs));\n\t\tpData++;\n\t}\n\n\tiRet = multiSubmitFlush(&multiSub);\n\n\tif(glblSenderKeepTrack)\n\t\tstatsRecordSender(propGetSzStr(pThis->peerName), nMsgs, ttGenTime);\n\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":225498,"func":"bool MutableGraphView::AddFaninInternal(NodeDef* node,\n                                        const OutputPort& fanin) {\n  int num_regular_fanins =\n      NumFanins(*node, \/*include_controlling_nodes=*\/false);\n  bool input_is_control = IsOutputPortControlling(fanin);\n  bool can_dedup_control_with_regular_input =\n      CanDedupControlWithRegularInput(*this, *fanin.node);\n  \/\/ Don't add duplicate control dependencies.\n  if (input_is_control) {\n    const int start =\n        can_dedup_control_with_regular_input ? 0 : num_regular_fanins;\n    for (int i = start; i < node->input_size(); ++i) {\n      if (ParseTensorName(node->input(i)).node() == fanin.node->name()) {\n        return false;\n      }\n    }\n  }\n\n  InputPort input;\n  input.node = node;\n  input.port_id = input_is_control ? Graph::kControlSlot : num_regular_fanins;\n\n  node->add_input(TensorIdToString({fanin.node->name(), fanin.port_id}));\n  if (!input_is_control) {\n    const int last_node_input = node->input_size() - 1;\n    \/\/ If there are control dependencies in node, move newly inserted fanin to\n    \/\/ be before such control dependencies.\n    if (num_regular_fanins < last_node_input) {\n      node->mutable_input()->SwapElements(last_node_input, num_regular_fanins);\n    }\n  }\n\n  fanouts()[fanin].insert(input);\n  if (max_regular_output_port()[fanin.node] < fanin.port_id) {\n    max_regular_output_port()[fanin.node] = fanin.port_id;\n  }\n\n  \/\/ Update max input port and dedup control dependencies.\n  if (!input_is_control) {\n    max_regular_input_port()[node] = num_regular_fanins;\n    if (can_dedup_control_with_regular_input) {\n      RemoveControllingFaninInternal(node, fanin.node);\n    }\n  }\n\n  return true;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":445931,"func":"fr_window_folder_tree_drag_data_get (GtkWidget        *widget,\n\t\t\t\t     GdkDragContext   *context,\n\t\t\t\t     GtkSelectionData *selection_data,\n\t\t\t\t     guint             info,\n\t\t\t\t     guint             time,\n\t\t\t\t     gpointer          user_data)\n{\n\tFrWindow *window = user_data;\n\tGList    *file_list;\n\tchar     *uri;\n\tGFile    *destination;\n\tGFile    *destination_folder;\n\n\tdebug (DEBUG_INFO, \"::DragDataGet -->\\n\");\n\n\tif (window->priv->activity_ref > 0)\n\t\treturn FALSE;\n\n\tfile_list = fr_window_get_folder_tree_selection (window, TRUE, NULL);\n\tif (file_list == NULL)\n\t\treturn FALSE;\n\n\tif (gtk_selection_data_get_target (selection_data) == XFR_ATOM) {\n\t\tFrClipboardData *tmp;\n\t\tchar            *data;\n\n\t\ttmp = fr_clipboard_data_new ();\n\t\ttmp->files = file_list;\n\t\ttmp->op = FR_CLIPBOARD_OP_COPY;\n\t\ttmp->base_dir = g_strdup (fr_window_get_current_location (window));\n\n\t\tdata = get_selection_data_from_clipboard_data (window, tmp);\n\t\tgtk_selection_data_set (selection_data, XFR_ATOM, 8, (guchar *) data, strlen (data));\n\n\t\tfr_clipboard_data_unref (tmp);\n\t\tg_free (data);\n\n\t\treturn TRUE;\n\t}\n\n\tif (! nautilus_xds_dnd_is_valid_xds_context (context))\n\t\treturn FALSE;\n\n\turi  = get_xds_atom_value (context);\n\tg_return_val_if_fail (uri != NULL, FALSE);\n\n\tdestination = g_file_new_for_uri (uri);\n\tdestination_folder = g_file_get_parent (destination);\n\n\tg_object_unref (destination);\n\n\t\/* check whether the extraction can be performed in the destination\n\t * folder *\/\n\n\tg_clear_error (&window->priv->drag_error);\n\n\tif (! _g_file_check_permissions (destination_folder, R_OK | W_OK)) {\n\t\tchar *display_name;\n\n\t\tdisplay_name = _g_file_get_display_basename (destination_folder);\n\t\twindow->priv->drag_error = g_error_new (FR_ERROR, 0, _(\"You don't have the right permissions to extract archives in the folder \\\"%s\\\"\"), display_name);\n\n\t\tg_free (display_name);\n\t}\n\n\tif (window->priv->drag_error == NULL) {\n\t\t_g_object_unref (window->priv->drag_destination_folder);\n\t\tg_free (window->priv->drag_base_dir);\n\t\t_g_string_list_free (window->priv->drag_file_list);\n\t\twindow->priv->drag_destination_folder = g_object_ref (destination_folder);\n\t\twindow->priv->drag_base_dir = fr_window_get_selected_folder_in_tree_view (window);\n\t\twindow->priv->drag_file_list = file_list;\n\t}\n\n\tg_object_unref (destination_folder);\n\n\t\/* sends back the response *\/\n\n\tgtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL) ? \"S\" : \"E\"), 1);\n\n\tdebug (DEBUG_INFO, \"::DragDataGet <--\\n\");\n\n\treturn TRUE;\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":477975,"func":"void simplestring_addn(simplestring* target, const char* source, size_t add_len) {\n   size_t newsize = target->size, incr = 0;\n   if(target && source) {\n      if(!target->str) {\n         simplestring_init_str(target);\n      }\n\n      if((SIZE_MAX - add_len) < target->len || (SIZE_MAX - add_len - 1) < target->len) {\n    \t  \/* check for overflows, if there's a potential overflow do nothing *\/\n    \t  return;\n      }\n\n      if(target->len + add_len + 1 > target->size) {\n         \/* newsize is current length + new length *\/\n         newsize = target->len + add_len + 1;\n         incr = target->size * 2;\n\n         \/* align to SIMPLESTRING_INCR increments *\/\n         if (incr) {\n            newsize = newsize - (newsize % incr) + incr;\n         }\n         if(newsize < (target->len + add_len + 1)) {\n        \t \/* some kind of overflow happened *\/\n        \t return;\n         }\n         target->str = (char*)realloc(target->str, newsize);\n\n         target->size = target->str ? newsize : 0;\n      }\n\n      if(target->str) {\n         if(add_len) {\n            memcpy(target->str + target->len, source, add_len);\n         }\n         target->len += add_len;\n         target->str[target->len] = 0; \/* null terminate *\/\n      }\n   }\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":294418,"func":"cmp_dd(VALUE self, VALUE other)\n{\n    get_d2(self, other);\n\n    {\n\tVALUE a_nth, b_nth,\n\t    a_sf, b_sf;\n\tint a_jd, b_jd,\n\t    a_df, b_df;\n\n\tm_canonicalize_jd(self, adat);\n\tm_canonicalize_jd(other, bdat);\n\ta_nth = m_nth(adat);\n\tb_nth = m_nth(bdat);\n\tif (f_eqeq_p(a_nth, b_nth)) {\n\t    a_jd = m_jd(adat);\n\t    b_jd = m_jd(bdat);\n\t    if (a_jd == b_jd) {\n\t\ta_df = m_df(adat);\n\t\tb_df = m_df(bdat);\n\t\tif (a_df == b_df) {\n\t\t    a_sf = m_sf(adat);\n\t\t    b_sf = m_sf(bdat);\n\t\t    if (f_eqeq_p(a_sf, b_sf)) {\n\t\t\treturn INT2FIX(0);\n\t\t    }\n\t\t    else if (f_lt_p(a_sf, b_sf)) {\n\t\t\treturn INT2FIX(-1);\n\t\t    }\n\t\t    else {\n\t\t\treturn INT2FIX(1);\n\t\t    }\n\t\t}\n\t\telse if (a_df < b_df) {\n\t\t    return INT2FIX(-1);\n\t\t}\n\t\telse {\n\t\t    return INT2FIX(1);\n\t\t}\n\t    }\n\t    else if (a_jd < b_jd) {\n\t\treturn INT2FIX(-1);\n\t    }\n\t    else {\n\t\treturn INT2FIX(1);\n\t    }\n\t}\n\telse if (f_lt_p(a_nth, b_nth)) {\n\t    return INT2FIX(-1);\n\t}\n\telse {\n\t    return INT2FIX(1);\n\t}\n    }\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":445965,"func":"fr_window_history_add (FrWindow   *window,\n\t\t       const char *path)\n{\n\tif ((window->priv->history_current == NULL) || (g_strcmp0 (path, window->priv->history_current->data) != 0)) {\n\t\tGList *scan;\n\t\tGList *new_current = NULL;\n\n                \/* search the path in the history *\/\n                for (scan = window->priv->history_current; scan; scan = scan->next) {\n                        char *path_in_history = scan->data;\n\n                        if (g_strcmp0 (path, path_in_history) == 0) {\n                        \tnew_current = scan;\n                        \tbreak;\n                        }\n                }\n\n                if (new_current != NULL) {\n                \twindow->priv->history_current = new_current;\n                }\n                else {\n\t\t\t\/* remove all the paths after the current position *\/\n\t\t\tfor (scan = window->priv->history; scan && (scan != window->priv->history_current); \/* void *\/) {\n\t\t\t\tGList *next = scan->next;\n\n\t\t\t\twindow->priv->history = g_list_remove_link (window->priv->history, scan);\n\t\t\t\t_g_string_list_free (scan);\n\n\t\t\t\tscan = next;\n\t\t\t}\n\n\t\t\twindow->priv->history = g_list_prepend (window->priv->history, g_strdup (path));\n\t\t\twindow->priv->history_current = window->priv->history;\n                }\n\t}\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":436115,"func":"static int io_openat2(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct open_flags op;\n\tstruct file *file;\n\tbool nonblock_set;\n\tbool resolve_nonblock;\n\tint ret;\n\n\tret = build_open_flags(&req->open.how, &op);\n\tif (ret)\n\t\tgoto err;\n\tnonblock_set = op.open_flag & O_NONBLOCK;\n\tresolve_nonblock = req->open.how.resolve & RESOLVE_CACHED;\n\tif (issue_flags & IO_URING_F_NONBLOCK) {\n\t\t\/*\n\t\t * Don't bother trying for O_TRUNC, O_CREAT, or O_TMPFILE open,\n\t\t * it'll always -EAGAIN\n\t\t *\/\n\t\tif (req->open.how.flags & (O_TRUNC | O_CREAT | O_TMPFILE))\n\t\t\treturn -EAGAIN;\n\t\top.lookup_flags |= LOOKUP_CACHED;\n\t\top.open_flag |= O_NONBLOCK;\n\t}\n\n\tret = __get_unused_fd_flags(req->open.how.flags, req->open.nofile);\n\tif (ret < 0)\n\t\tgoto err;\n\n\tfile = do_filp_open(req->open.dfd, req->open.filename, &op);\n\tif (IS_ERR(file)) {\n\t\t\/*\n\t\t * We could hang on to this 'fd' on retrying, but seems like\n\t\t * marginal gain for something that is now known to be a slower\n\t\t * path. So just put it, and we'll get a new one when we retry.\n\t\t *\/\n\t\tput_unused_fd(ret);\n\n\t\tret = PTR_ERR(file);\n\t\t\/* only retry if RESOLVE_CACHED wasn't already set by application *\/\n\t\tif (ret == -EAGAIN &&\n\t\t    (!resolve_nonblock && (issue_flags & IO_URING_F_NONBLOCK)))\n\t\t\treturn -EAGAIN;\n\t\tgoto err;\n\t}\n\n\tif ((issue_flags & IO_URING_F_NONBLOCK) && !nonblock_set)\n\t\tfile->f_flags &= ~O_NONBLOCK;\n\tfsnotify_open(file);\n\tfd_install(ret, file);\nerr:\n\tputname(req->open.filename);\n\treq->flags &= ~REQ_F_NEED_CLEANUP;\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":256420,"func":"PJ_DEF(void) pjmedia_rtcp_rx_rtcp( pjmedia_rtcp_session *sess,\n\t\t\t\t   const void *pkt,\n\t\t\t\t   pj_size_t size)\n{\n    pj_uint8_t *p, *p_end;\n\n    p = (pj_uint8_t*)pkt;\n    p_end = p + size;\n    while (p < p_end) {\n\tpjmedia_rtcp_common *common;\n\tunsigned len;\n\n\tif (p + sizeof(pjmedia_rtcp_common) > p_end) {\n\t    TRACE_((sess->name, \"Receiving truncated RTCP packet (1)\"));\n\t    break;\n\t}\n\tcommon = (pjmedia_rtcp_common*)p;\n\n\tlen = (pj_ntohs((pj_uint16_t)common->length)+1) * 4;\n\tif (p + len > p_end) {\n\t    TRACE_((sess->name, \"Receiving truncated RTCP packet (2)\"));\n\t    break;\n\t}\n\n\tswitch(common->pt) {\n\tcase RTCP_SR:\n\tcase RTCP_RR:\n\tcase RTCP_XR:\n\t    parse_rtcp_report(sess, p, len);\n\t    break;\n\tcase RTCP_SDES:\n\t    parse_rtcp_sdes(sess, p, len);\n\t    break;\n\tcase RTCP_BYE:\n\t    parse_rtcp_bye(sess, p, len);\n\t    break;\n\tcase RTCP_RTPFB:\n\tcase RTCP_PSFB:\n\t    parse_rtcp_fb(sess, p, len);\n\t    break;\n\tdefault:\n\t    \/* Ignore unknown RTCP *\/\n\t    TRACE_((sess->name, \"Received unknown RTCP packet type=%d\",\n\t\t    common->pt));\n\t    break;\n\t}\n\n\tp += len;\n    }\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":220398,"func":"join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)\n{\n  mrb_int i;\n  mrb_value result, val, tmp;\n\n  \/* check recursive *\/\n  for (i=0; i<RARRAY_LEN(list); i++) {\n    if (mrb_obj_equal(mrb, ary, RARRAY_PTR(list)[i])) {\n      mrb_raise(mrb, E_ARGUMENT_ERROR, \"recursive array join\");\n    }\n  }\n\n  mrb_ary_push(mrb, list, ary);\n\n  result = mrb_str_new_capa(mrb, 64);\n\n  for (i=0; i<RARRAY_LEN(ary); i++) {\n    if (i > 0 && !mrb_nil_p(sep)) {\n      mrb_str_cat_str(mrb, result, sep);\n    }\n\n    val = RARRAY_PTR(ary)[i];\n    switch (mrb_type(val)) {\n    case MRB_TT_ARRAY:\n    ary_join:\n      val = join_ary(mrb, val, sep, list);\n      \/* fall through *\/\n\n    case MRB_TT_STRING:\n    str_join:\n      mrb_str_cat_str(mrb, result, val);\n      break;\n\n    default:\n      if (!mrb_immediate_p(val)) {\n        tmp = mrb_check_string_type(mrb, val);\n        if (!mrb_nil_p(tmp)) {\n          val = tmp;\n          goto str_join;\n        }\n        tmp = mrb_check_array_type(mrb, val);\n        if (!mrb_nil_p(tmp)) {\n          val = tmp;\n          goto ary_join;\n        }\n      }\n      val = mrb_obj_as_string(mrb, val);\n      goto str_join;\n    }\n  }\n\n  mrb_ary_pop(mrb, list);\n\n  return result;\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":247527,"func":"TEST_P(SslSocketTest, FailedClientCertificateHashAndSpkiVerificationNoClientCertificate) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  server_validation_ctx->mutable_trusted_ca()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"));\n  server_validation_ctx->add_verify_certificate_hash(\n      \"0000000000000000000000000000000000000000000000000000000000000000\");\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_URI_CERT_SPKI);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n\n  TestUtilOptionsV2 test_options(listener, client, false, GetParam());\n  testUtilV2(test_options.setExpectedServerStats(\"ssl.fail_verify_no_cert\")\n                 .setExpectedTransportFailureReasonContains(\"SSLV3_ALERT_HANDSHAKE_FAILURE\"));\n\n  \/\/ Fails even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":359567,"func":"DEFUN (bgp_redistribute_ipv6_metric_rmap,\n       bgp_redistribute_ipv6_metric_rmap_cmd,\n       \"redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD\",\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPFv3)\\n\"\n       \"Routing Information Protocol (RIPng)\\n\"\n       \"Static routes\\n\"\n       \"Metric for redistributed routes\\n\"\n       \"Default metric\\n\"\n       \"Route map reference\\n\"\n       \"Pointer to route-map entries\\n\")\n{\n  int type;\n  u_int32_t metric;\n\n  type = bgp_str2route_type (AFI_IP6, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n  VTY_GET_INTEGER (\"metric\", metric, argv[1]);\n\n  bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);\n  bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);\n  return bgp_redistribute_set (vty->index, AFI_IP6, type);\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":238647,"func":"static bool stacksafe(struct bpf_verifier_env *env, struct bpf_func_state *old,\n\t\t      struct bpf_func_state *cur, struct bpf_id_pair *idmap)\n{\n\tint i, spi;\n\n\t\/* walk slots of the explored stack and ignore any additional\n\t * slots in the current stack, since explored(safe) state\n\t * didn't use them\n\t *\/\n\tfor (i = 0; i < old->allocated_stack; i++) {\n\t\tspi = i \/ BPF_REG_SIZE;\n\n\t\tif (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ)) {\n\t\t\ti += BPF_REG_SIZE - 1;\n\t\t\t\/* explored state didn't use this *\/\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_INVALID)\n\t\t\tcontinue;\n\n\t\t\/* explored stack has more populated slots than current stack\n\t\t * and these slots were used\n\t\t *\/\n\t\tif (i >= cur->allocated_stack)\n\t\t\treturn false;\n\n\t\t\/* if old state was safe with misc data in the stack\n\t\t * it will be safe with zero-initialized stack.\n\t\t * The opposite is not true\n\t\t *\/\n\t\tif (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_MISC &&\n\t\t    cur->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_ZERO)\n\t\t\tcontinue;\n\t\tif (old->stack[spi].slot_type[i % BPF_REG_SIZE] !=\n\t\t    cur->stack[spi].slot_type[i % BPF_REG_SIZE])\n\t\t\t\/* Ex: old explored (safe) state has STACK_SPILL in\n\t\t\t * this stack slot, but current has STACK_MISC ->\n\t\t\t * this verifier states are not equivalent,\n\t\t\t * return false to continue verification of this path\n\t\t\t *\/\n\t\t\treturn false;\n\t\tif (i % BPF_REG_SIZE != BPF_REG_SIZE - 1)\n\t\t\tcontinue;\n\t\tif (!is_spilled_reg(&old->stack[spi]))\n\t\t\tcontinue;\n\t\tif (!regsafe(env, &old->stack[spi].spilled_ptr,\n\t\t\t     &cur->stack[spi].spilled_ptr, idmap))\n\t\t\t\/* when explored and current stack slot are both storing\n\t\t\t * spilled registers, check that stored pointers types\n\t\t\t * are the same as well.\n\t\t\t * Ex: explored safe path could have stored\n\t\t\t * (bpf_reg_state) {.type = PTR_TO_STACK, .off = -8}\n\t\t\t * but current path has stored:\n\t\t\t * (bpf_reg_state) {.type = PTR_TO_STACK, .off = -16}\n\t\t\t * such verifier states are not equivalent.\n\t\t\t * return false to continue verification of this path\n\t\t\t *\/\n\t\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":587,"total_token_length":823,"max_tokens_setting":1024}
+{"idx":459192,"func":"int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,\n\t\t      struct tcf_block_ext_info *ei,\n\t\t      struct netlink_ext_ack *extack)\n{\n\tstruct net *net = qdisc_net(q);\n\tstruct tcf_block *block = NULL;\n\tint err;\n\n\tif (ei->block_index)\n\t\t\/* block_index not 0 means the shared block is requested *\/\n\t\tblock = tcf_block_refcnt_get(net, ei->block_index);\n\n\tif (!block) {\n\t\tblock = tcf_block_create(net, q, ei->block_index, extack);\n\t\tif (IS_ERR(block))\n\t\t\treturn PTR_ERR(block);\n\t\tif (tcf_block_shared(block)) {\n\t\t\terr = tcf_block_insert(block, net, extack);\n\t\t\tif (err)\n\t\t\t\tgoto err_block_insert;\n\t\t}\n\t}\n\n\terr = tcf_block_owner_add(block, q, ei->binder_type);\n\tif (err)\n\t\tgoto err_block_owner_add;\n\n\ttcf_block_owner_netif_keep_dst(block, q, ei->binder_type);\n\n\terr = tcf_chain0_head_change_cb_add(block, ei, extack);\n\tif (err)\n\t\tgoto err_chain0_head_change_cb_add;\n\n\terr = tcf_block_offload_bind(block, q, ei, extack);\n\tif (err)\n\t\tgoto err_block_offload_bind;\n\n\t*p_block = block;\n\treturn 0;\n\nerr_block_offload_bind:\n\ttcf_chain0_head_change_cb_del(block, ei);\nerr_chain0_head_change_cb_add:\n\ttcf_block_owner_del(block, q, ei->binder_type);\nerr_block_owner_add:\nerr_block_insert:\n\ttcf_block_refcnt_put(block, true);\n\treturn err;\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":264684,"func":"lexer_compare_identifier_to_chars (const uint8_t *left_p, \/**< left identifier *\/\n                                   const uint8_t *right_p, \/**< right identifier string *\/\n                                   size_t size) \/**< byte size of the two identifiers *\/\n{\n  uint8_t utf8_buf[6];\n\n  do\n  {\n    if (*left_p == *right_p)\n    {\n      left_p++;\n      right_p++;\n      size--;\n      continue;\n    }\n\n    size_t escape_size;\n\n    if (*left_p == LIT_CHAR_BACKSLASH)\n    {\n      left_p += 2;\n      lit_code_point_t code_point = lexer_unchecked_hex_to_character (&left_p);\n\n      escape_size = lit_code_point_to_cesu8_bytes (utf8_buf, code_point);\n    }\n    else if (*left_p >= LIT_UTF8_4_BYTE_MARKER)\n    {\n      lit_four_byte_utf8_char_to_cesu8 (utf8_buf, left_p);\n      escape_size = 3 * 2;\n      left_p += 4;\n    }\n    else\n    {\n      return false;\n    }\n\n    size -= escape_size;\n\n    uint8_t *utf8_p = utf8_buf;\n    do\n    {\n      if (*right_p++ != *utf8_p++)\n      {\n        return false;\n      }\n    } while (--escape_size > 0);\n  } while (size > 0);\n\n  return true;\n} \/* lexer_compare_identifier_to_chars *\/","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":343281,"func":"static int fortune(void)\n{\n    int fd;\n    char *buf;\n    char *bufpnt;\n    char *bufend;\n    struct stat st;\n    off_t gl;\n    char *fortunepnt;\n    char fortune[2048];\n\n    if (fortunes_file == NULL || *fortunes_file == 0) {\n        return 0;\n    }\n    if ((fd = open(fortunes_file, O_RDONLY)) == -1) {\n        logfile(LOG_ERR, MSG_OPEN_FAILURE, fortunes_file);\n        return -1;\n    }\n    if (fstat(fd, &st) < 0 ||\n        (((S_IRUSR | S_IRGRP | S_IROTH) & st.st_mode) !=\n         (S_IRUSR | S_IRGRP | S_IROTH)) ||\n        !(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) || st.st_size < 2 ||\n        (buf = mmap(NULL, (size_t) st.st_size,\n                PROT_READ, MAP_FILE | MAP_SHARED, fd,\n                (off_t) 0)) == (void *) MAP_FAILED) {\n        (void) close(fd);\n        logfile(LOG_ERR, MSG_OPEN_FAILURE, fortunes_file);\n        return -1;\n    }\n# ifdef HAVE_RANDOM\n    gl = (off_t) (random() % (st.st_size - 1U));\n# else\n    gl = (off_t) (rand() % (st.st_size - 1U));\n# endif\n    bufpnt = buf + gl;\n    bufend = buf + st.st_size;\n    while (bufpnt != buf) {\n        if (bufpnt[0] == '\\n') {\n            if (&bufpnt[-1] != buf && bufpnt[-1] == '%') {\n                if (&bufpnt[-2] != buf && bufpnt[-2] == '\\n') {\n                    break;\n                }\n            }\n        }\n        bufpnt--;\n    }\n    if (bufpnt != buf) {\n        while (bufpnt != bufend && *bufpnt == '\\n') {\n            bufpnt++;\n        }\n    }\n    fortunepnt = fortune;\n    while (*bufpnt != 0 && bufpnt != bufend &&\n           fortunepnt != &fortune[sizeof fortune - 1U]) {\n        if (bufpnt[0] == '\\n') {\n            if (&bufpnt[1] != bufend && bufpnt[1] == '%') {\n                if (&bufpnt[2] != bufend && bufpnt[2] == '\\n') {\n                    break;\n                }\n            }\n        }\n        *fortunepnt++ = *bufpnt++;\n    }\n    if (fortunepnt == fortune) {\n        goto bye;\n    }\n    do {\n        fortunepnt--;\n    } while (fortunepnt != fortune && (*fortunepnt == '\\n' ||\n                                       isspace((unsigned char) *fortunepnt)));\n    fortunepnt[1] = 0;\n    fortunepnt = fortune;\n    while (*fortunepnt == '\\n') {\n        fortunepnt++;\n    }\n    if (*fortunepnt == 0) {\n        goto bye;\n    }\n    addreply(220, \"%s\", fortunepnt);\n    bye:\n    (void) munmap(buf, st.st_size);\n    (void) close(fd);\n\n    return 1;\n}","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":398517,"func":"static size_t parse_opcodes(const ut8 *obuf,\n\tsize_t len, const RzBinDwarfLineHeader *hdr, RzVector *ops_out,\n\tRzBinDwarfSMRegisters *regs, RZ_NULLABLE RzBinSourceLineInfoBuilder *bob, RZ_NULLABLE RzBinDwarfDebugInfo *info,\n\tRZ_NULLABLE RzBinDwarfLineFileCache fnc, bool big_endian, ut8 target_addr_size) {\n\tconst ut8 *buf, *buf_end;\n\tut8 opcode;\n\n\tif (!obuf || !len) {\n\t\treturn 0;\n\t}\n\tbuf = obuf;\n\tbuf_end = obuf + len;\n\n\twhile (buf < buf_end) {\n\t\topcode = *buf++;\n\t\tRzBinDwarfLineOp op = { 0 };\n\t\tif (!opcode) {\n\t\t\tbuf = parse_ext_opcode(&op, hdr, buf, (buf_end - buf), big_endian, target_addr_size);\n\t\t} else if (opcode >= hdr->opcode_base) {\n\t\t\t\/\/ special opcode without args, no further parsing needed\n\t\t\top.type = RZ_BIN_DWARF_LINE_OP_TYPE_SPEC;\n\t\t\top.opcode = opcode;\n\t\t} else {\n\t\t\tbuf = parse_std_opcode(&op, hdr, buf, (buf_end - buf), opcode, big_endian);\n\t\t}\n\t\tif (!buf) {\n\t\t\tbreak;\n\t\t}\n\t\tif (bob) {\n\t\t\trz_bin_dwarf_line_op_run(hdr, regs, &op, bob, info, fnc);\n\t\t}\n\t\tif (ops_out) {\n\t\t\trz_vector_push(ops_out, &op);\n\t\t} else {\n\t\t\trz_bin_dwarf_line_op_fini(&op);\n\t\t}\n\t}\n\tif (!buf) {\n\t\treturn 0;\n\t}\n\treturn (size_t)(buf - obuf); \/\/ number of bytes we've moved by\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":455425,"func":"xfs_inode_alloc(\n\tstruct xfs_mount\t*mp,\n\txfs_ino_t\t\tino)\n{\n\tstruct xfs_inode\t*ip;\n\n\t\/*\n\t * if this didn't occur in transactions, we could use\n\t * KM_MAYFAIL and return NULL here on ENOMEM. Set the\n\t * code up to do this anyway.\n\t *\/\n\tip = kmem_zone_alloc(xfs_inode_zone, KM_SLEEP);\n\tif (!ip)\n\t\treturn NULL;\n\tif (inode_init_always(mp->m_super, VFS_I(ip))) {\n\t\tkmem_zone_free(xfs_inode_zone, ip);\n\t\treturn NULL;\n\t}\n\n\t\/* VFS doesn't initialise i_mode! *\/\n\tVFS_I(ip)->i_mode = 0;\n\n\tXFS_STATS_INC(mp, vn_active);\n\tASSERT(atomic_read(&ip->i_pincount) == 0);\n\tASSERT(!xfs_isiflocked(ip));\n\tASSERT(ip->i_ino == 0);\n\n\t\/* initialise the xfs inode *\/\n\tip->i_ino = ino;\n\tip->i_mount = mp;\n\tmemset(&ip->i_imap, 0, sizeof(struct xfs_imap));\n\tip->i_afp = NULL;\n\tip->i_cowfp = NULL;\n\tip->i_cnextents = 0;\n\tip->i_cformat = XFS_DINODE_FMT_EXTENTS;\n\tmemset(&ip->i_df, 0, sizeof(xfs_ifork_t));\n\tip->i_flags = 0;\n\tip->i_delayed_blks = 0;\n\tmemset(&ip->i_d, 0, sizeof(ip->i_d));\n\n\treturn ip;\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":261397,"func":"void read_coding_quadtree(thread_context* tctx,\n                          int x0, int y0,\n                          int log2CbSize,\n                          int ctDepth)\n{\n  logtrace(LogSlice,\"- read_coding_quadtree %d;%d cbsize:%d depth:%d POC:%d\\n\",x0,y0,1<<log2CbSize,ctDepth,tctx->img->PicOrderCntVal);\n\n  de265_image* img = tctx->img;\n  const seq_parameter_set& sps = img->get_sps();\n  const pic_parameter_set& pps = img->get_pps();\n\n  int split_flag;\n\n  \/\/ We only send a split flag if CU is larger than minimum size and\n  \/\/ completely contained within the image area.\n  \/\/ If it is partly outside the image area and not at minimum size,\n  \/\/ it is split. If already at minimum size, it is not split further.\n  if (x0+(1<<log2CbSize) <= sps.pic_width_in_luma_samples &&\n      y0+(1<<log2CbSize) <= sps.pic_height_in_luma_samples &&\n      log2CbSize > sps.Log2MinCbSizeY) {\n    split_flag = decode_split_cu_flag(tctx, x0,y0, ctDepth);\n  } else {\n    if (log2CbSize > sps.Log2MinCbSizeY) { split_flag=1; }\n    else                                  { split_flag=0; }\n  }\n\n\n  if (pps.cu_qp_delta_enabled_flag &&\n      log2CbSize >= pps.Log2MinCuQpDeltaSize)\n    {\n      tctx->IsCuQpDeltaCoded = 0;\n      tctx->CuQpDelta = 0;\n    }\n  else\n    {\n      \/\/ shdr->CuQpDelta = 0; \/\/ TODO check: is this the right place to set to default value ?\n    }\n\n\n  if (tctx->shdr->cu_chroma_qp_offset_enabled_flag &&\n      log2CbSize >= pps.Log2MinCuChromaQpOffsetSize) {\n    tctx->IsCuChromaQpOffsetCoded = 0;\n  }\n\n  if (split_flag) {\n    int x1 = x0 + (1<<(log2CbSize-1));\n    int y1 = y0 + (1<<(log2CbSize-1));\n\n    read_coding_quadtree(tctx,x0,y0, log2CbSize-1, ctDepth+1);\n\n    if (x1<sps.pic_width_in_luma_samples)\n      read_coding_quadtree(tctx,x1,y0, log2CbSize-1, ctDepth+1);\n\n    if (y1<sps.pic_height_in_luma_samples)\n      read_coding_quadtree(tctx,x0,y1, log2CbSize-1, ctDepth+1);\n\n    if (x1<sps.pic_width_in_luma_samples &&\n        y1<sps.pic_height_in_luma_samples)\n      read_coding_quadtree(tctx,x1,y1, log2CbSize-1, ctDepth+1);\n  }\n  else {\n    \/\/ set ctDepth of this CU\n\n    img->set_ctDepth(x0,y0, log2CbSize, ctDepth);\n\n    read_coding_unit(tctx, x0,y0, log2CbSize, ctDepth);\n  }\n\n  logtrace(LogSlice,\"-\\n\");\n}","target":0,"code_token_length":729,"total_token_length":965,"max_tokens_setting":1024}
+{"idx":405378,"func":"xfrm_policy_inexact_alloc_chain(struct xfrm_pol_inexact_bin *bin,\n\t\t\t\tstruct xfrm_policy *policy, u8 dir)\n{\n\tstruct xfrm_pol_inexact_node *n;\n\tstruct net *net;\n\n\tnet = xp_net(policy);\n\tlockdep_assert_held(&net->xfrm.xfrm_policy_lock);\n\n\tif (xfrm_policy_inexact_insert_use_any_list(policy))\n\t\treturn &bin->hhead;\n\n\tif (xfrm_pol_inexact_addr_use_any_list(&policy->selector.daddr,\n\t\t\t\t\t       policy->family,\n\t\t\t\t\t       policy->selector.prefixlen_d)) {\n\t\twrite_seqcount_begin(&bin->count);\n\t\tn = xfrm_policy_inexact_insert_node(net,\n\t\t\t\t\t\t    &bin->root_s,\n\t\t\t\t\t\t    &policy->selector.saddr,\n\t\t\t\t\t\t    policy->family,\n\t\t\t\t\t\t    policy->selector.prefixlen_s,\n\t\t\t\t\t\t    dir);\n\t\twrite_seqcount_end(&bin->count);\n\t\tif (!n)\n\t\t\treturn NULL;\n\n\t\treturn &n->hhead;\n\t}\n\n\t\/* daddr is fixed *\/\n\twrite_seqcount_begin(&bin->count);\n\tn = xfrm_policy_inexact_insert_node(net,\n\t\t\t\t\t    &bin->root_d,\n\t\t\t\t\t    &policy->selector.daddr,\n\t\t\t\t\t    policy->family,\n\t\t\t\t\t    policy->selector.prefixlen_d, dir);\n\twrite_seqcount_end(&bin->count);\n\tif (!n)\n\t\treturn NULL;\n\n\t\/* saddr is wildcard *\/\n\tif (xfrm_pol_inexact_addr_use_any_list(&policy->selector.saddr,\n\t\t\t\t\t       policy->family,\n\t\t\t\t\t       policy->selector.prefixlen_s))\n\t\treturn &n->hhead;\n\n\twrite_seqcount_begin(&bin->count);\n\tn = xfrm_policy_inexact_insert_node(net,\n\t\t\t\t\t    &n->root,\n\t\t\t\t\t    &policy->selector.saddr,\n\t\t\t\t\t    policy->family,\n\t\t\t\t\t    policy->selector.prefixlen_s, dir);\n\twrite_seqcount_end(&bin->count);\n\tif (!n)\n\t\treturn NULL;\n\n\treturn &n->hhead;\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":215312,"func":"asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)\n{\n\tstruct rlimit new_rlim, *old_rlim;\n\tunsigned long it_prof_secs;\n\tint retval;\n\n\tif (resource >= RLIM_NLIMITS)\n\t\treturn -EINVAL;\n\tif (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))\n\t\treturn -EFAULT;\n\tif (new_rlim.rlim_cur > new_rlim.rlim_max)\n\t\treturn -EINVAL;\n\told_rlim = current->signal->rlim + resource;\n\tif ((new_rlim.rlim_max > old_rlim->rlim_max) &&\n\t    !capable(CAP_SYS_RESOURCE))\n\t\treturn -EPERM;\n\tif (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)\n\t\treturn -EPERM;\n\n\tretval = security_task_setrlimit(resource, &new_rlim);\n\tif (retval)\n\t\treturn retval;\n\n\ttask_lock(current->group_leader);\n\t*old_rlim = new_rlim;\n\ttask_unlock(current->group_leader);\n\n\tif (resource != RLIMIT_CPU)\n\t\tgoto out;\n\n\t\/*\n\t * RLIMIT_CPU handling.   Note that the kernel fails to return an error\n\t * code if it rejected the user's attempt to set RLIMIT_CPU.  This is a\n\t * very long-standing error, and fixing it now risks breakage of\n\t * applications, so we live with it\n\t *\/\n\tif (new_rlim.rlim_cur == RLIM_INFINITY)\n\t\tgoto out;\n\n\tit_prof_secs = cputime_to_secs(current->signal->it_prof_expires);\n\tif (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {\n\t\tunsigned long rlim_cur = new_rlim.rlim_cur;\n\t\tcputime_t cputime;\n\n\t\tif (rlim_cur == 0) {\n\t\t\t\/*\n\t\t\t * The caller is asking for an immediate RLIMIT_CPU\n\t\t\t * expiry.  But we use the zero value to mean \"it was\n\t\t\t * never set\".  So let's cheat and make it one second\n\t\t\t * instead\n\t\t\t *\/\n\t\t\trlim_cur = 1;\n\t\t}\n\t\tcputime = secs_to_cputime(rlim_cur);\n\t\tread_lock(&tasklist_lock);\n\t\tspin_lock_irq(¤t->sighand->siglock);\n\t\tset_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);\n\t\tspin_unlock_irq(¤t->sighand->siglock);\n\t\tread_unlock(&tasklist_lock);\n\t}\nout:\n\treturn 0;\n}","target":1,"code_token_length":544,"total_token_length":780,"max_tokens_setting":1024}
+{"idx":317021,"func":"static int selinux_inode_permission(struct inode *inode, int mask)\n{\n\tconst struct cred *cred = current_cred();\n\tu32 perms;\n\tbool from_access;\n\tbool no_block = mask & MAY_NOT_BLOCK;\n\tstruct inode_security_struct *isec;\n\tu32 sid;\n\tstruct av_decision avd;\n\tint rc, rc2;\n\tu32 audited, denied;\n\n\tfrom_access = mask & MAY_ACCESS;\n\tmask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND);\n\n\t\/* No permission to check.  Existence test. *\/\n\tif (!mask)\n\t\treturn 0;\n\n\tvalidate_creds(cred);\n\n\tif (unlikely(IS_PRIVATE(inode)))\n\t\treturn 0;\n\n\tperms = file_mask_to_av(inode->i_mode, mask);\n\n\tsid = cred_sid(cred);\n\tisec = inode_security_rcu(inode, no_block);\n\tif (IS_ERR(isec))\n\t\treturn PTR_ERR(isec);\n\n\trc = avc_has_perm_noaudit(&selinux_state,\n\t\t\t\t  sid, isec->sid, isec->sclass, perms, 0,\n\t\t\t\t  &avd);\n\taudited = avc_audit_required(perms, &avd, rc,\n\t\t\t\t     from_access ? FILE__AUDIT_ACCESS : 0,\n\t\t\t\t     &denied);\n\tif (likely(!audited))\n\t\treturn rc;\n\n\trc2 = audit_inode_permission(inode, perms, audited, denied, rc);\n\tif (rc2)\n\t\treturn rc2;\n\treturn rc;\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":307848,"func":"ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) {\n  ASSERT_IN_VM;\n\n  \/\/ Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.\n  CompilerThread* current_thread = CompilerThread::current();\n  assert(current_thread->env() == NULL, \"must be\");\n  current_thread->set_env(this);\n  assert(ciEnv::current() == this, \"sanity\");\n\n  _oop_recorder = NULL;\n  _debug_info = NULL;\n  _dependencies = NULL;\n  _failure_reason = NULL;\n  _compilable = MethodCompilable_never;\n  _break_at_compile = false;\n  _compiler_data = NULL;\n#ifndef PRODUCT\n  assert(firstEnv, \"must be first\");\n  firstEnv = false;\n#endif \/* !PRODUCT *\/\n\n  _system_dictionary_modification_counter = 0;\n  _num_inlined_bytecodes = 0;\n  _task = NULL;\n  _log = NULL;\n\n  \/\/ Temporary buffer for creating symbols and such.\n  _name_buffer = NULL;\n  _name_buffer_len = 0;\n\n  _arena   = arena;\n  _factory = new (_arena) ciObjectFactory(_arena, 128);\n\n  \/\/ Preload commonly referenced system ciObjects.\n\n  \/\/ During VM initialization, these instances have not yet been created.\n  \/\/ Assertions ensure that these instances are not accessed before\n  \/\/ their initialization.\n\n  assert(Universe::is_fully_initialized(), \"must be\");\n\n  _NullPointerException_instance = NULL;\n  _ArithmeticException_instance = NULL;\n  _ArrayIndexOutOfBoundsException_instance = NULL;\n  _ArrayStoreException_instance = NULL;\n  _ClassCastException_instance = NULL;\n  _the_null_string = NULL;\n  _the_min_jint_string = NULL;\n\n  _jvmti_can_hotswap_or_post_breakpoint = false;\n  _jvmti_can_access_local_variables = false;\n  _jvmti_can_post_on_exceptions = false;\n  _jvmti_can_pop_frame = false;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":259171,"func":"static int build_open_gop_key_points(AVStream *st)\n{\n    int k;\n    int sample_id = 0;\n    uint32_t cra_index;\n    MOVStreamContext *sc = st->priv_data;\n\n    if (st->codecpar->codec_id != AV_CODEC_ID_HEVC || !sc->sync_group_count)\n        return 0;\n\n    \/* Build an unrolled index of the samples *\/\n    sc->sample_offsets_count = 0;\n    for (uint32_t i = 0; i < sc->ctts_count; i++) {\n        if (sc->ctts_data[i].count > INT_MAX - sc->sample_offsets_count)\n            return AVERROR(ENOMEM);\n        sc->sample_offsets_count += sc->ctts_data[i].count;\n    }\n    av_freep(&sc->sample_offsets);\n    sc->sample_offsets = av_calloc(sc->sample_offsets_count, sizeof(*sc->sample_offsets));\n    if (!sc->sample_offsets)\n        return AVERROR(ENOMEM);\n    k = 0;\n    for (uint32_t i = 0; i < sc->ctts_count; i++)\n        for (int j = 0; j < sc->ctts_data[i].count; j++)\n             sc->sample_offsets[k++] = sc->ctts_data[i].duration;\n\n    \/* The following HEVC NAL type reveal the use of open GOP sync points\n     * (TODO: BLA types may also be concerned) *\/\n    cra_index = get_sgpd_sync_index(sc, HEVC_NAL_CRA_NUT); \/* Clean Random Access *\/\n    if (!cra_index)\n        return 0;\n\n    \/* Build a list of open-GOP key samples *\/\n    sc->open_key_samples_count = 0;\n    for (uint32_t i = 0; i < sc->sync_group_count; i++)\n        if (sc->sync_group[i].index == cra_index) {\n            if (sc->sync_group[i].count > INT_MAX - sc->open_key_samples_count)\n                return AVERROR(ENOMEM);\n            sc->open_key_samples_count += sc->sync_group[i].count;\n        }\n    av_freep(&sc->open_key_samples);\n    sc->open_key_samples = av_calloc(sc->open_key_samples_count, sizeof(*sc->open_key_samples));\n    if (!sc->open_key_samples)\n        return AVERROR(ENOMEM);\n    k = 0;\n    for (uint32_t i = 0; i < sc->sync_group_count; i++) {\n        const MOVSbgp *sg = &sc->sync_group[i];\n        if (sg->index == cra_index)\n            for (uint32_t j = 0; j < sg->count; j++)\n                sc->open_key_samples[k++] = sample_id;\n        if (sg->count > INT_MAX - sample_id)\n            return AVERROR_PATCHWELCOME;\n        sample_id += sg->count;\n    }\n\n    \/* Identify the minimal time step between samples *\/\n    sc->min_sample_duration = UINT_MAX;\n    for (uint32_t i = 0; i < sc->stts_count; i++)\n        sc->min_sample_duration = FFMIN(sc->min_sample_duration, sc->stts_data[i].duration);\n\n    return 0;\n}","target":0,"code_token_length":697,"total_token_length":933,"max_tokens_setting":1024}
+{"idx":390630,"func":"ProcXkbListComponents(ClientPtr client)\n{\n    DeviceIntPtr \t\tdev;\n    xkbListComponentsReply \trep;\n    unsigned\t\t\tlen;\n    int\t\t\t\tstatus;\n    unsigned char *\t\tstr;\n    XkbSrvListInfoRec\t\tlist;\n\n    REQUEST(xkbListComponentsReq);\n    REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);\n\n    status= Success;\n    str= (unsigned char *)&stuff[1];\n    bzero(&list,sizeof(XkbSrvListInfoRec));\n    list.maxRtrn= stuff->maxNames;\n    list.pattern[_XkbListKeymaps]= GetComponentSpec(&str,False,&status);\n    list.pattern[_XkbListKeycodes]= GetComponentSpec(&str,False,&status);\n    list.pattern[_XkbListTypes]= GetComponentSpec(&str,False,&status);\n    list.pattern[_XkbListCompat]= GetComponentSpec(&str,False,&status);\n    list.pattern[_XkbListSymbols]= GetComponentSpec(&str,False,&status);\n    list.pattern[_XkbListGeometry]= GetComponentSpec(&str,False,&status);\n    if (status!=Success)\n\treturn status;\n    len= str-((unsigned char *)stuff);\n    if ((XkbPaddedSize(len)\/4)!=stuff->length)\n\treturn BadLength;\n    if ((status=XkbDDXList(dev,&list,client))!=Success) {\n\tif (list.pool) {\n\t    _XkbFree(list.pool);\n\t    list.pool= NULL;\n\t}\n\treturn status;\n    }\n    bzero(&rep,sizeof(xkbListComponentsReply));\n    rep.type= X_Reply;\n    rep.deviceID = dev->id;\n    rep.sequenceNumber = client->sequence;\n    rep.length = XkbPaddedSize(list.nPool)\/4;\n    rep.nKeymaps = list.nFound[_XkbListKeymaps];\n    rep.nKeycodes = list.nFound[_XkbListKeycodes];\n    rep.nTypes = list.nFound[_XkbListTypes];\n    rep.nCompatMaps = list.nFound[_XkbListCompat];\n    rep.nSymbols = list.nFound[_XkbListSymbols];\n    rep.nGeometries = list.nFound[_XkbListGeometry];\n    rep.extra=\t0;\n    if (list.nTotal>list.maxRtrn)\n\trep.extra = (list.nTotal-list.maxRtrn);\n    if (client->swapped) {\n\tregister int n;\n\tswaps(&rep.sequenceNumber,n);\n\tswapl(&rep.length,n);\n\tswaps(&rep.nKeymaps,n);\n\tswaps(&rep.nKeycodes,n);\n\tswaps(&rep.nTypes,n);\n\tswaps(&rep.nCompatMaps,n);\n\tswaps(&rep.nSymbols,n);\n\tswaps(&rep.nGeometries,n);\n\tswaps(&rep.extra,n);\n    }\n    WriteToClient(client,SIZEOF(xkbListComponentsReply),(char *)&rep);\n    if (list.nPool && list.pool) {\n\tWriteToClient(client,XkbPaddedSize(list.nPool), (char *)list.pool);\n\t_XkbFree(list.pool);\n\tlist.pool= NULL;\n    }\n    return client->noClientException;\n}","target":0,"code_token_length":682,"total_token_length":918,"max_tokens_setting":1024}
+{"idx":254893,"func":"intrusive_ptr<DocumentSource> DocumentSourceGroup::createFromBson(\n    BSONElement elem, const intrusive_ptr<ExpressionContext>& pExpCtx) {\n    uassert(15947, \"a group's fields must be specified in an object\", elem.type() == Object);\n\n    intrusive_ptr<DocumentSourceGroup> pGroup(new DocumentSourceGroup(pExpCtx));\n\n    BSONObj groupObj(elem.Obj());\n    BSONObjIterator groupIterator(groupObj);\n    VariablesParseState vps = pExpCtx->variablesParseState;\n    while (groupIterator.more()) {\n        BSONElement groupField(groupIterator.next());\n        StringData pFieldName = groupField.fieldNameStringData();\n        if (pFieldName == \"_id\") {\n            uassert(\n                15948, \"a group's _id may only be specified once\", pGroup->_idExpressions.empty());\n            pGroup->setIdExpression(parseIdExpression(pExpCtx, groupField, vps));\n            invariant(!pGroup->_idExpressions.empty());\n        } else if (pFieldName == \"$doingMerge\") {\n            massert(17030, \"$doingMerge should be true if present\", groupField.Bool());\n\n            pGroup->setDoingMerge(true);\n        } else {\n            \/\/ Any other field will be treated as an accumulator specification.\n            pGroup->addAccumulator(\n                AccumulationStatement::parseAccumulationStatement(pExpCtx, groupField, vps));\n        }\n    }\n\n    uassert(15955, \"a group specification must include an _id\", !pGroup->_idExpressions.empty());\n    return pGroup;\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":390549,"func":"_XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char* values)\n{\n    XkbSrvInfoPtr       xkbi;\n    XkbDescPtr          xkb;\n    int                 error;\n    int                 nTypes = 0, nActions;\n    CARD8               mapWidths[XkbMaxLegalKeyCode + 1];\n    CARD16              symsPerKey[XkbMaxLegalKeyCode + 1];\n\n    xkbi= dev->key->xkbInfo;\n    xkb = xkbi->desc;\n\n    if ((xkb->min_key_code != req->minKeyCode)||\n        (xkb->max_key_code != req->maxKeyCode)) {\n\tif (client->vMajor!=1) { \/* pre 1.0 versions of Xlib have a bug *\/\n\t    req->minKeyCode= xkb->min_key_code;\n\t    req->maxKeyCode= xkb->max_key_code;\n\t}\n\telse {\n\t    if (!XkbIsLegalKeycode(req->minKeyCode)) {\n\t\tclient->errorValue = _XkbErrCode3(2, req->minKeyCode, req->maxKeyCode);\n\t\treturn BadValue;\n\t    }\n\t    if (req->minKeyCode > req->maxKeyCode) {\n\t\tclient->errorValue = _XkbErrCode3(3, req->minKeyCode, req->maxKeyCode);\n\t\treturn BadMatch;\n\t    }\n\t}\n    }\n\n    if ((req->present & XkbKeyTypesMask) &&\n\t(!CheckKeyTypes(client,xkb,req,(xkbKeyTypeWireDesc **)&values,\n\t\t\t\t\t\t&nTypes,mapWidths))) {\n\tclient->errorValue = nTypes;\n\treturn BadValue;\n    }\n    if ((req->present & XkbKeySymsMask) &&\n\t(!CheckKeySyms(client,xkb,req,nTypes,mapWidths,symsPerKey,\n\t\t\t\t\t(xkbSymMapWireDesc **)&values,&error))) {\n\tclient->errorValue = error;\n\treturn BadValue;\n    }\n\n    if ((req->present & XkbKeyActionsMask) &&\n\t(!CheckKeyActions(xkb,req,nTypes,mapWidths,symsPerKey,\n\t\t\t\t\t\t(CARD8 **)&values,&nActions))) {\n\tclient->errorValue = nActions;\n\treturn BadValue;\n    }\n\n    if ((req->present & XkbKeyBehaviorsMask) &&\n\t(!CheckKeyBehaviors(xkb,req,(xkbBehaviorWireDesc**)&values,&error))) {\n\tclient->errorValue = error;\n\treturn BadValue;\n    }\n\n    if ((req->present & XkbVirtualModsMask) &&\n\t(!CheckVirtualMods(xkb,req,(CARD8 **)&values,&error))) {\n\tclient->errorValue= error;\n\treturn BadValue;\n    }\n    if ((req->present&XkbExplicitComponentsMask) &&\n\t(!CheckKeyExplicit(xkb,req,(CARD8 **)&values,&error))) {\n\tclient->errorValue= error;\n\treturn BadValue;\n    }\n    if ((req->present&XkbModifierMapMask) &&\n\t(!CheckModifierMap(xkb,req,(CARD8 **)&values,&error))) {\n\tclient->errorValue= error;\n\treturn BadValue;\n    }\n    if ((req->present&XkbVirtualModMapMask) &&\n\t(!CheckVirtualModMap(xkb,req,(xkbVModMapWireDesc **)&values,&error))) {\n\tclient->errorValue= error;\n\treturn BadValue;\n    }\n\n    if (((values-((char *)req))\/4)!= req->length) {\n\tErrorF(\"[xkb] Internal error! Bad length in XkbSetMap (after check)\\n\");\n\tclient->errorValue = values-((char *)&req[1]);\n\treturn BadLength;\n    }\n\n    return Success;\n}","target":0,"code_token_length":783,"total_token_length":1019,"max_tokens_setting":1024}
+{"idx":256441,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_rpsi(\n\t\t\t\t\tconst void *buf,\n\t\t\t\t\tpj_size_t length,\n\t\t\t\t\tpjmedia_rtcp_fb_rpsi *rpsi)\n{\n    pjmedia_rtcp_fb_common *hdr = (pjmedia_rtcp_fb_common*) buf;\n    pj_uint8_t *p;\n    pj_uint8_t padlen;\n    pj_size_t rpsi_len;\n\n    PJ_ASSERT_RETURN(buf && rpsi, PJ_EINVAL);\n    PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_fb_common), PJ_ETOOSMALL);\n\n    \/* RPSI uses pt==RTCP_PSFB and FMT==3 *\/\n    if (hdr->rtcp_common.pt != RTCP_PSFB || hdr->rtcp_common.count != 3)\n\treturn PJ_ENOTFOUND;\n\n    if (hdr->rtcp_common.length < 3) {    \n        PJ_PERROR(3, (THIS_FILE, PJ_ETOOSMALL,\n                      \"Failed parsing FB RPSI, invalid header length\"));\n\treturn PJ_ETOOSMALL;\n    }\n\n    rpsi_len = (pj_ntohs((pj_uint16_t)hdr->rtcp_common.length)-2) * 4;\n    if (length < rpsi_len + 12)\n\treturn PJ_ETOOSMALL;\n\n    p = (pj_uint8_t*)hdr + sizeof(*hdr);\n    padlen = *p++;\n\n    if (padlen >= 32) {\n        PJ_PERROR(3, (THIS_FILE, PJ_ETOOBIG,\n                      \"Failed parsing FB RPSI, invalid RPSI padding len\"));\n\treturn PJ_ETOOBIG;\n    }\n\n    if ((rpsi_len * 8) < (unsigned)(16 + padlen)) {\n        PJ_PERROR(3, (THIS_FILE, PJ_ETOOSMALL,\n                      \"Failed parsing FB RPSI, invalid RPSI bit len\"));\n\treturn PJ_ETOOSMALL;\n    }\n\n    rpsi->pt = (*p++ & 0x7F);\n    rpsi->rpsi_bit_len = rpsi_len*8 - 16 - padlen;\n    pj_strset(&rpsi->rpsi, (char*)p, (rpsi->rpsi_bit_len + 7)\/8);\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":405693,"func":"static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,\n\t\t\t\t    unsigned length)\n{\n\tu32 align_buffer;\n\tu32 *to_u32_ptr;\n\tu16 *from_u16_ptr, *to_u16_ptr;\n\n\tto_u32_ptr = dest_ptr;\n\tfrom_u16_ptr = src_ptr;\n\talign_buffer = 0;\n\n\tfor (; length > 3; length -= 4) {\n\t\tto_u16_ptr = (u16 *)&align_buffer;\n\t\t*to_u16_ptr++ = *from_u16_ptr++;\n\t\t*to_u16_ptr++ = *from_u16_ptr++;\n\n\t\t\/* This barrier resolves occasional issues seen around\n\t\t * cases where the data is not properly flushed out\n\t\t * from the processor store buffers to the destination\n\t\t * memory locations.\n\t\t *\/\n\t\twmb();\n\n\t\t\/* Output a word *\/\n\t\t*to_u32_ptr++ = align_buffer;\n\t}\n\tif (length) {\n\t\tu8 *from_u8_ptr, *to_u8_ptr;\n\n\t\t\/* Set up to output the remaining data *\/\n\t\talign_buffer = 0;\n\t\tto_u8_ptr = (u8 *)&align_buffer;\n\t\tfrom_u8_ptr = (u8 *)from_u16_ptr;\n\n\t\t\/* Output the remaining data *\/\n\t\tfor (; length > 0; length--)\n\t\t\t*to_u8_ptr++ = *from_u8_ptr++;\n\n\t\t\/* This barrier resolves occasional issues seen around\n\t\t * cases where the data is not properly flushed out\n\t\t * from the processor store buffers to the destination\n\t\t * memory locations.\n\t\t *\/\n\t\twmb();\n\t\t*to_u32_ptr = align_buffer;\n\t}\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":328915,"func":"R_API ut64 r_bin_java_parse_methods(RBinJavaObj *bin, const ut64 offset, const ut8 *buf, const ut64 len) {\n\tint i = 0;\n\tut64 adv = 0;\n\tRBinJavaField *method;\n\tconst ut8 *fm_buf = buf + offset;\n\tr_list_free (bin->methods_list);\n\tbin->methods_list = r_list_newf (r_bin_java_fmtype_free);\n\n\tif (offset + 2 >= len) {\n\t\treturn 0LL;\n\t}\n\tbin->methods_offset = offset;\n\tbin->methods_count = R_BIN_JAVA_USHORT (fm_buf, 0);\n\tadv += 2;\n\tIFDBG eprintf (\"Methods count: %d 0x%\"PFMT64x \"\\n\", bin->methods_count, bin->methods_offset);\n\tbin->main = NULL;\n\tbin->entrypoint = NULL;\n\tbin->main_code_attr = NULL;\n\tbin->entrypoint_code_attr = NULL;\n\tfor (i = 0; i < bin->methods_count; i++, bin->method_idx++) {\n\t\tmethod = r_bin_java_read_next_method (bin, offset + adv, buf, len);\n\t\tif (method) {\n\t\t\tadv += method->size;\n\t\t\tr_list_append (bin->methods_list, method);\n\t\t}\n\t\t\/\/ Update Main, Init, or Class Init\n\t\tif (method && !strcmp ((const char *) method->name, \"main\")) {\n\t\t\tbin->main = method;\n\t\t\t\/\/ get main code attr\n\t\t\tbin->main_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0);\n\t\t} else if (method && (!strcmp ((const char *) method->name, \"<init>\") || !strcmp ((const char *) method->name, \"init\")))   {\n\t\t\tIFDBG eprintf (\"Found an init function.\\n\");\n\t\t\tbin->entrypoint = method;\n\t\t\tbin->entrypoint_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0);\n\t\t} else if (method && (!strcmp ((const char *) method->name, \"<cinit>\") || !strcmp ((const char *) method->name, \"cinit\")))   {\n\t\t\tbin->cf2.this_class_entrypoint = method;\n\t\t\tbin->cf2.this_class_entrypoint_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0);\n\t\t}\n\t\tif (adv + offset > len) {\n\t\t\teprintf (\"[X] r_bin_java: Error unable to parse remainder of classfile after Method: %d.\\n\", i);\n\t\t\tbreak;\n\t\t}\n\t\tIFDBG r_bin_java_print_field_summary(method);\n\t}\n\tbin->methods_size = adv;\n\treturn adv;\n}","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":343287,"func":"static int _dlmap_remap(DLHandler * const dlhandler)\n{\n    size_t min_dlmap_size;\n    off_t remaining;\n\n    if (dlhandler->map_data != NULL) {\n        if (dlhandler->cur_pos >= dlhandler->dlmap_pos &&\n            dlhandler->cur_pos + dlhandler->chunk_size <=\n            dlhandler->dlmap_pos + (off_t) dlhandler->dlmap_size) {\n            if (dlhandler->cur_pos < dlhandler->dlmap_pos ||\n                dlhandler->cur_pos - dlhandler->dlmap_pos >\n                (off_t) dlhandler->dlmap_size) {\n                addreply_noformat(451, \"remap\");\n                return -1;\n            }\n            dlhandler->map_data =\n                dlhandler->map + dlhandler->cur_pos - dlhandler->dlmap_pos;\n            return 0;\n        }\n    }\n    if (dlhandler->file_size - dlhandler->cur_pos < dlhandler->chunk_size) {\n        dlhandler->chunk_size = dlhandler->file_size - dlhandler->cur_pos;\n    }\n    if (dlhandler->chunk_size <= 0) {\n        return 1;\n    }\n    dlhandler->dlmap_pos = dlhandler->cur_pos;\n    min_dlmap_size = dlhandler->chunk_size;\n    if (dlhandler->dlmap_size < min_dlmap_size) {\n        dlhandler->dlmap_size = min_dlmap_size;\n    }\n    dlhandler->dlmap_size = (dlhandler->dlmap_size + page_size - (size_t) 1U) &\n        ~(page_size - (size_t) 1U);\n    if (dlhandler->dlmap_size < page_size) {\n        dlhandler->dlmap_size = page_size;\n    }\n    remaining = dlhandler->file_size - dlhandler->dlmap_pos;\n    if ((off_t) dlhandler->dlmap_size > remaining) {\n        dlhandler->dlmap_size = (off_t) remaining;\n    }\n    if (_dlmap_read(dlhandler) != 0) {\n        error(451, MSG_DATA_READ_FAILED);\n        return -1;\n    }\n    dlhandler->map_data = dlhandler->map;\n\n    return 0;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":252353,"func":"static void CompressZip(unsigned char *dst,\n                        tinyexr::tinyexr_uint64 &compressedSize,\n                        const unsigned char *src, unsigned long src_size) {\n  std::vector<unsigned char> tmpBuf(src_size);\n\n  \/\/\n  \/\/ Apply EXR-specific? postprocess. Grabbed from OpenEXR's\n  \/\/ ImfZipCompressor.cpp\n  \/\/\n\n  \/\/\n  \/\/ Reorder the pixel data.\n  \/\/\n\n  const char *srcPtr = reinterpret_cast<const char *>(src);\n\n  {\n    char *t1 = reinterpret_cast<char *>(&tmpBuf.at(0));\n    char *t2 = reinterpret_cast<char *>(&tmpBuf.at(0)) + (src_size + 1) \/ 2;\n    const char *stop = srcPtr + src_size;\n\n    for (;;) {\n      if (srcPtr < stop)\n        *(t1++) = *(srcPtr++);\n      else\n        break;\n\n      if (srcPtr < stop)\n        *(t2++) = *(srcPtr++);\n      else\n        break;\n    }\n  }\n\n  \/\/\n  \/\/ Predictor.\n  \/\/\n\n  {\n    unsigned char *t = &tmpBuf.at(0) + 1;\n    unsigned char *stop = &tmpBuf.at(0) + src_size;\n    int p = t[-1];\n\n    while (t < stop) {\n      int d = int(t[0]) - p + (128 + 256);\n      p = t[0];\n      t[0] = static_cast<unsigned char>(d);\n      ++t;\n    }\n  }\n\n#if TINYEXR_USE_MINIZ\n  \/\/\n  \/\/ Compress the data using miniz\n  \/\/\n\n  miniz::mz_ulong outSize = miniz::mz_compressBound(src_size);\n  int ret = miniz::mz_compress(\n      dst, &outSize, static_cast<const unsigned char *>(&tmpBuf.at(0)),\n      src_size);\n  assert(ret == miniz::MZ_OK);\n  (void)ret;\n\n  compressedSize = outSize;\n#else\n  uLong outSize = compressBound(static_cast<uLong>(src_size));\n  int ret = compress(dst, &outSize, static_cast<const Bytef *>(&tmpBuf.at(0)),\n                     src_size);\n  assert(ret == Z_OK);\n\n  compressedSize = outSize;\n#endif\n\n  \/\/ Use uncompressed data when compressed data is larger than uncompressed.\n  \/\/ (Issue 40)\n  if (compressedSize >= src_size) {\n    compressedSize = src_size;\n    memcpy(dst, src, src_size);\n  }\n}","target":0,"code_token_length":546,"total_token_length":782,"max_tokens_setting":1024}
+{"idx":309871,"func":"_nc_cookie_init(SCREEN *sp)\n{\n    bool support_cookies = USE_XMC_SUPPORT;\n    TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) (sp->_term);\n\n    if (sp == 0 || !ENSURE_TINFO(sp))\n\treturn;\n\n#if USE_XMC_SUPPORT\n    \/*\n     * If we have no magic-cookie support compiled-in, or if it is suppressed\n     * in the environment, reset the support-flag.\n     *\/\n    if (magic_cookie_glitch >= 0) {\n\tif (getenv(\"NCURSES_NO_MAGIC_COOKIE\") != 0) {\n\t    support_cookies = FALSE;\n\t}\n    }\n#endif\n\n    if (!support_cookies && magic_cookie_glitch >= 0) {\n\tT((\"will disable attributes to work w\/o magic cookies\"));\n    }\n\n    if (magic_cookie_glitch > 0) {\t\/* tvi, wyse *\/\n\n\tsp->_xmc_triggers = sp->_ok_attributes & XMC_CONFLICT;\n#if 0\n\t\/*\n\t * We \"should\" treat colors as an attribute.  The wyse350 (and its\n\t * clones) appear to be the only ones that have both colors and magic\n\t * cookies.\n\t *\/\n\tif (has_colors()) {\n\t    sp->_xmc_triggers |= A_COLOR;\n\t}\n#endif\n\tsp->_xmc_suppress = sp->_xmc_triggers & (chtype) ~(A_BOLD);\n\n\tT((\"magic cookie attributes %s\", _traceattr(sp->_xmc_suppress)));\n\t\/*\n\t * Supporting line-drawing may be possible.  But make the regular\n\t * video attributes work first.\n\t *\/\n\tacs_chars = ABSENT_STRING;\n\tena_acs = ABSENT_STRING;\n\tenter_alt_charset_mode = ABSENT_STRING;\n\texit_alt_charset_mode = ABSENT_STRING;\n#if USE_XMC_SUPPORT\n\t\/*\n\t * To keep the cookie support simple, suppress all of the optimization\n\t * hooks except for clear_screen and the cursor addressing.\n\t *\/\n\tif (support_cookies) {\n\t    clr_eol = ABSENT_STRING;\n\t    clr_eos = ABSENT_STRING;\n\t    set_attributes = ABSENT_STRING;\n\t}\n#endif\n    } else if (magic_cookie_glitch == 0) {\t\/* hpterm *\/\n    }\n\n    \/*\n     * If magic cookies are not supported, cancel the strings that set\n     * video attributes.\n     *\/\n    if (!support_cookies && magic_cookie_glitch >= 0) {\n\tmagic_cookie_glitch = ABSENT_NUMERIC;\n\tset_attributes = ABSENT_STRING;\n\tenter_blink_mode = ABSENT_STRING;\n\tenter_bold_mode = ABSENT_STRING;\n\tenter_dim_mode = ABSENT_STRING;\n\tenter_reverse_mode = ABSENT_STRING;\n\tenter_standout_mode = ABSENT_STRING;\n\tenter_underline_mode = ABSENT_STRING;\n    }\n\n    \/* initialize normal acs before wide, since we use mapping in the latter *\/\n#if !USE_WIDEC_SUPPORT\n    if (_nc_unicode_locale() && _nc_locale_breaks_acs(sp->_term)) {\n\tacs_chars = NULL;\n\tena_acs = NULL;\n\tenter_alt_charset_mode = NULL;\n\texit_alt_charset_mode = NULL;\n\tset_attributes = NULL;\n    }\n#endif\n}","target":0,"code_token_length":672,"total_token_length":908,"max_tokens_setting":1024}
+{"idx":273059,"func":"net_evhttp_bind(struct evhttp *evhttp, short unsigned port, const char *log_service_name)\n{\n  const char *bind_address;\n  bool v6_enabled;\n  int ret;\n\n  bind_address = cfg_getstr(cfg_getsec(cfg, \"general\"), \"bind_address\");\n  if (bind_address)\n    evhttp_bind_socket(evhttp, bind_address, port);\n\n  \/\/ For Linux, we could just do evhttp_bind_socket() for \"::\", and both the\n  \/\/ ipv4 and v6 port would be bound. However, for bsd it seems it is necessary\n  \/\/ to do like below.\n  v6_enabled = cfg_getbool(cfg_getsec(cfg, \"general\"), \"ipv6\");\n  if (v6_enabled)\n    {\n      ret = evhttp_bind_socket(evhttp, \"::\", port);\n      if (ret < 0)\n\t{\n\t  DPRINTF(E_LOG, L_MISC, \"Could not bind service '%s' to port %d with IPv6, falling back to IPv4\\n\", log_service_name, port);\n\t  v6_enabled = 0;\n\t}\n    }\n\n  ret = evhttp_bind_socket(evhttp, \"0.0.0.0\", port);\n  if (ret < 0)\n    {\n      if (!v6_enabled)\n\treturn -1;\n\n#ifndef __linux__\n      DPRINTF(E_LOG, L_MISC, \"Could not bind service '%s' to port %d with IPv4, listening on IPv6 only\\n\", log_service_name, port);\n#endif\n    }\n\n  return 0;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":459401,"func":"get_tags(list_T *list, char_u *pat, char_u *buf_fname)\n{\n    int\t\tnum_matches, i, ret;\n    char_u\t**matches, *p;\n    char_u\t*full_fname;\n    dict_T\t*dict;\n    tagptrs_T\ttp;\n    long\tis_static;\n\n    ret = find_tags(pat, &num_matches, &matches,\n\t\t\t\tTAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname);\n    if (ret == OK && num_matches > 0)\n    {\n\tfor (i = 0; i < num_matches; ++i)\n\t{\n\t    if (parse_match(matches[i], &tp) == FAIL)\n\t    {\n\t\tvim_free(matches[i]);\n\t\tcontinue;\n\t    }\n\n\t    is_static = test_for_static(&tp);\n\n\t    \/\/ Skip pseudo-tag lines.\n\t    if (STRNCMP(tp.tagname, \"!_TAG_\", 6) == 0)\n\t    {\n\t\tvim_free(matches[i]);\n\t\tcontinue;\n\t    }\n\n\t    if ((dict = dict_alloc()) == NULL)\n\t    {\n\t\tret = FAIL;\n\t\tvim_free(matches[i]);\n\t\tbreak;\n\t    }\n\t    if (list_append_dict(list, dict) == FAIL)\n\t\tret = FAIL;\n\n\t    full_fname = tag_full_fname(&tp);\n\t    if (add_tag_field(dict, \"name\", tp.tagname, tp.tagname_end) == FAIL\n\t\t    || add_tag_field(dict, \"filename\", full_fname,\n\t\t\t\t\t\t\t NULL) == FAIL\n\t\t    || add_tag_field(dict, \"cmd\", tp.command,\n\t\t\t\t\t\t       tp.command_end) == FAIL\n\t\t    || add_tag_field(dict, \"kind\", tp.tagkind,\n\t\t\t\t\t\t      tp.tagkind_end) == FAIL\n\t\t    || dict_add_number(dict, \"static\", is_static) == FAIL)\n\t\tret = FAIL;\n\n\t    vim_free(full_fname);\n\n\t    if (tp.command_end != NULL)\n\t    {\n\t\tfor (p = tp.command_end + 3;\n\t\t\t  *p != NUL && *p != '\\n' && *p != '\\r'; MB_PTR_ADV(p))\n\t\t{\n\t\t    if (p == tp.tagkind || (p + 5 == tp.tagkind\n\t\t\t\t\t      && STRNCMP(p, \"kind:\", 5) == 0))\n\t\t\t\/\/ skip \"kind:<kind>\" and \"<kind>\"\n\t\t\tp = tp.tagkind_end - 1;\n\t\t    else if (STRNCMP(p, \"file:\", 5) == 0)\n\t\t\t\/\/ skip \"file:\" (static tag)\n\t\t\tp += 4;\n\t\t    else if (!VIM_ISWHITE(*p))\n\t\t    {\n\t\t\tchar_u\t*s, *n;\n\t\t\tint\tlen;\n\n\t\t\t\/\/ Add extra field as a dict entry.  Fields are\n\t\t\t\/\/ separated by Tabs.\n\t\t\tn = p;\n\t\t\twhile (*p != NUL && *p >= ' ' && *p < 127 && *p != ':')\n\t\t\t    ++p;\n\t\t\tlen = (int)(p - n);\n\t\t\tif (*p == ':' && len > 0)\n\t\t\t{\n\t\t\t    s = ++p;\n\t\t\t    while (*p != NUL && *p >= ' ')\n\t\t\t\t++p;\n\t\t\t    n[len] = NUL;\n\t\t\t    if (add_tag_field(dict, (char *)n, s, p) == FAIL)\n\t\t\t\tret = FAIL;\n\t\t\t    n[len] = ':';\n\t\t\t}\n\t\t\telse\n\t\t\t    \/\/ Skip field without colon.\n\t\t\t    while (*p != NUL && *p >= ' ')\n\t\t\t\t++p;\n\t\t\tif (*p == NUL)\n\t\t\t    break;\n\t\t    }\n\t\t}\n\t    }\n\n\t    vim_free(matches[i]);\n\t}\n\tvim_free(matches);\n    }\n    return ret;\n}","target":0,"code_token_length":773,"total_token_length":1009,"max_tokens_setting":1024}
+{"idx":437284,"func":"compile_length_enclosure_node(EnclosureNode* node, regex_t* reg)\n{\n  int len;\n  int tlen;\n\n  if (node->type == ENCLOSURE_OPTION)\n    return compile_length_option_node(node, reg);\n\n  if (NODE_ENCLOSURE_BODY(node)) {\n    tlen = compile_length_tree(NODE_ENCLOSURE_BODY(node), reg);\n    if (tlen < 0) return tlen;\n  }\n  else\n    tlen = 0;\n\n  switch (node->type) {\n  case ENCLOSURE_MEMORY:\n#ifdef USE_CALL\n\n    if (node->m.regnum == 0 && NODE_IS_CALLED(node)) {\n      len = tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN;\n      return len;\n    }\n\n    if (NODE_IS_CALLED(node)) {\n      len = SIZE_OP_MEMORY_START_PUSH + tlen\n        + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN;\n      if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum))\n        len += (NODE_IS_RECURSION(node)\n                ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH);\n      else\n        len += (NODE_IS_RECURSION(node)\n                ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END);\n    }\n    else if (NODE_IS_RECURSION(node)) {\n      len = SIZE_OP_MEMORY_START_PUSH;\n      len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)\n                     ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_REC);\n    }\n    else\n#endif\n    {\n      if (MEM_STATUS_AT0(reg->bt_mem_start, node->m.regnum))\n        len = SIZE_OP_MEMORY_START_PUSH;\n      else\n        len = SIZE_OP_MEMORY_START;\n\n      len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)\n                     ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END);\n    }\n    break;\n\n  case ENCLOSURE_STOP_BACKTRACK:\n    if (NODE_IS_STOP_BT_SIMPLE_REPEAT(node)) {\n      int v;\n      QuantNode* qn;\n\n      qn = QUANT_(NODE_ENCLOSURE_BODY(node));\n      tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg);\n      if (tlen < 0) return tlen;\n\n      v = onig_positive_int_multiply(qn->lower, tlen);\n      if (v < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;\n      len = v + SIZE_OP_PUSH + tlen + SIZE_OP_POP_OUT + SIZE_OP_JUMP;\n    }\n    else {\n      len = SIZE_OP_ATOMIC_START + tlen + SIZE_OP_ATOMIC_END;\n    }\n    break;\n\n  case ENCLOSURE_IF_ELSE:\n    {\n      Node* cond = NODE_ENCLOSURE_BODY(node);\n      Node* Then = node->te.Then;\n      Node* Else = node->te.Else;\n\n      len = compile_length_tree(cond, reg);\n      if (len < 0) return len;\n      len += SIZE_OP_PUSH;\n      len += SIZE_OP_ATOMIC_START + SIZE_OP_ATOMIC_END;\n\n      if (IS_NOT_NULL(Then)) {\n        tlen = compile_length_tree(Then, reg);\n        if (tlen < 0) return tlen;\n        len += tlen;\n      }\n\n      if (IS_NOT_NULL(Else)) {\n        len += SIZE_OP_JUMP;\n        tlen = compile_length_tree(Else, reg);\n        if (tlen < 0) return tlen;\n        len += tlen;\n      }\n    }\n    break;\n\n  default:\n    return ONIGERR_TYPE_BUG;\n    break;\n  }\n\n  return len;\n}","target":0,"code_token_length":785,"total_token_length":1021,"max_tokens_setting":1024}
+{"idx":229345,"func":"Status CreateUnshapedOutput(\n    const KernelAndDevice& kernel, const int output_num, Device* output_device,\n    const DataType& output_dtype,\n    const absl::optional<EagerFunctionParams>& eager_func_params,\n    EagerContext* ctx, TensorHandle** output) {\n#if defined(IS_MOBILE_PLATFORM)\n  return errors::Unimplemented(\n      \"Remote outputs are not available on mobile devices.\");\n#else  \/\/ !IS_MOBILE_PLATFORM\n  int64_t op_id;\n  if (eager_func_params.has_value()) {\n    op_id = eager_func_params.value().op_id;\n  } else {\n    return errors::InvalidArgument(\n        \"Unable to find a remote op id for a remote output of \", kernel.name());\n  }\n  string remote_task;\n  if (!DeviceNameUtils::GetTaskName(output_device->parsed_name(),\n                                    &remote_task)) {\n    return errors::InvalidArgument(\n        \"Unable to find remote task corresponding to device \",\n        output_device->name());\n  }\n  if (ctx->RemoteMgr()->IsMaster()) {\n    *output = TensorHandle::CreateUnshapedRemoteHandle(\n        op_id, output_num, remote_task, output_dtype, output_device, ctx);\n  } else {\n    *output = TensorHandle::CreateLazyRemoteHandle(op_id, output_num,\n                                                   output_dtype, output_device,\n                                                   \/*is_ready=*\/false, ctx);\n  }\n  return Status::OK();\n#endif  \/\/ !IS_MOBILE_PLATFORM\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":506699,"func":"static int run_cert(X509 *crt, const char *nameincert,\n                     const struct set_name_fn *fn)\n{\n    const char *const *pname = names;\n    int failed = 0;\n\n    for (; *pname != NULL; ++pname) {\n        int samename = strcasecmp(nameincert, *pname) == 0;\n        size_t namelen = strlen(*pname);\n        char *name = OPENSSL_malloc(namelen + 1);\n        int match, ret;\n\n        memcpy(name, *pname, namelen + 1);\n\n        match = -1;\n        if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen, 0, NULL),\n                         0)) {\n            failed = 1;\n        } else if (fn->host) {\n            if (ret == 1 && !samename)\n                match = 1;\n            if (ret == 0 && samename)\n                match = 0;\n        } else if (ret == 1)\n            match = 1;\n        if (!TEST_true(check_message(fn, \"host\", nameincert, match, *pname)))\n            failed = 1;\n\n        match = -1;\n        if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen,\n                                               X509_CHECK_FLAG_NO_WILDCARDS,\n                                               NULL), 0)) {\n            failed = 1;\n        } else if (fn->host) {\n            if (ret == 1 && !samename)\n                match = 1;\n            if (ret == 0 && samename)\n                match = 0;\n        } else if (ret == 1)\n            match = 1;\n        if (!TEST_true(check_message(fn, \"host-no-wildcards\",\n                                     nameincert, match, *pname)))\n            failed = 1;\n\n        match = -1;\n        ret = X509_check_email(crt, name, namelen, 0);\n        if (fn->email) {\n            if (ret && !samename)\n                match = 1;\n            if (!ret && samename && strchr(nameincert, '@') != NULL)\n                match = 0;\n        } else if (ret)\n            match = 1;\n        if (!TEST_true(check_message(fn, \"email\", nameincert, match, *pname)))\n            failed = 1;\n        OPENSSL_free(name);\n    }\n\n    return failed == 0;\n}","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":391669,"func":"static NTSTATUS open_mode_check(connection_struct *conn,\n\t\t\t\tstruct share_mode_lock *lck,\n\t\t\t\tuint32 access_mask,\n\t\t\t\tuint32 share_access)\n{\n\tint i;\n\n\tif(lck->data->num_share_modes == 0) {\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tif (is_stat_open(access_mask)) {\n\t\t\/* Stat open that doesn't trigger oplock breaks or share mode\n\t\t * checks... ! JRA. *\/\n\t\treturn NT_STATUS_OK;\n\t}\n\n\t\/*\n\t * Check if the share modes will give us access.\n\t *\/\n\n#if defined(DEVELOPER)\n\tfor(i = 0; i < lck->data->num_share_modes; i++) {\n\t\tvalidate_my_share_entries(conn->sconn, i,\n\t\t\t\t\t  &lck->data->share_modes[i]);\n\t}\n#endif\n\n\t\/* Now we check the share modes, after any oplock breaks. *\/\n\tfor(i = 0; i < lck->data->num_share_modes; i++) {\n\n\t\tif (!is_valid_share_mode_entry(&lck->data->share_modes[i])) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* someone else has a share lock on it, check to see if we can\n\t\t * too *\/\n\t\tif (share_conflict(&lck->data->share_modes[i],\n\t\t\t\t   access_mask, share_access)) {\n\n\t\t\tif (share_mode_stale_pid(lck->data, i)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\treturn NT_STATUS_SHARING_VIOLATION;\n\t\t}\n\t}\n\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":234233,"func":"fetch_indexed_string (dwarf_vma           idx,\n\t\t      struct cu_tu_set *  this_set,\n\t\t      dwarf_vma           offset_size,\n\t\t      bool                dwo,\n\t\t      dwarf_vma           str_offsets_base)\n{\n  enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str;\n  enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index;\n  struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section;\n  struct dwarf_section *str_section = &debug_displays [str_sec_idx].section;\n  dwarf_vma index_offset;\n  dwarf_vma str_offset;\n  const char * ret;\n\n  if (index_section->start == NULL)\n    return (dwo ? _(\"<no .debug_str_offsets.dwo section>\")\n\t\t: _(\"<no .debug_str_offsets section>\"));\n\n  if (str_section->start == NULL)\n    return (dwo ? _(\"<no .debug_str.dwo section>\")\n\t\t: _(\"<no .debug_str section>\"));\n\n  index_offset = idx * offset_size;\n\n  if (this_set != NULL)\n    index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS];\n\n  index_offset += str_offsets_base;\n\n  if (index_offset + offset_size > index_section->size)\n    {\n      warn (_(\"string index of %s converts to an offset of 0x%s which is too big for section %s\"),\n\t    dwarf_vmatoa (\"d\", idx),\n\t    dwarf_vmatoa (\"x\", index_offset),\n\t    str_section->name);\n\n      return _(\"<string index too big>\");\n    }\n\n  \/* FIXME: If we are being paranoid then we should also check to see if\n     IDX references an entry beyond the end of the string table pointed to\n     by STR_OFFSETS_BASE.  (Since there can be more than one string table\n     in a DWARF string section).  *\/\n\n  str_offset = byte_get (index_section->start + index_offset, offset_size);\n\n  str_offset -= str_section->address;\n  if (str_offset >= str_section->size)\n    {\n      warn (_(\"indirect offset too big: 0x%s\\n\"),\n\t    dwarf_vmatoa (\"x\", str_offset));\n      return _(\"<indirect index offset is too big>\");\n    }\n\n  ret = (const char *) str_section->start + str_offset;\n\n  \/* Unfortunately we cannot rely upon str_section ending with a NUL byte.\n     Since our caller is expecting to receive a well formed C string we test\n     for the lack of a terminating byte here.  *\/\n  if (strnlen (ret, str_section->size - str_offset)\n      == str_section->size - str_offset)\n    return _(\"<no NUL byte at end of section>\");\n\n  return ret;\n}","target":0,"code_token_length":594,"total_token_length":830,"max_tokens_setting":1024}
+{"idx":261229,"func":"int MqttClient_Unsubscribe(MqttClient *client, MqttUnsubscribe *unsubscribe)\n{\n    int rc, len;\n\n    \/* Validate required arguments *\/\n    if (client == NULL || unsubscribe == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n#ifdef WOLFMQTT_V5\n    \/* Use specified protocol version if set *\/\n    unsubscribe->protocol_level = client->protocol_level;\n#endif\n\n    if (unsubscribe->stat == MQTT_MSG_BEGIN) {\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n\n        \/* Encode the subscribe packet *\/\n        rc = MqttEncode_Unsubscribe(client->tx_buf, client->tx_buf_len,\n            unsubscribe);\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d\",\n            rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_UNSUBSCRIBE),\n            MQTT_PACKET_TYPE_UNSUBSCRIBE, unsubscribe->packet_id, 0);\n    #endif\n        if (rc <= 0) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            return rc;\n        }\n        len = rc;\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        rc = wm_SemLock(&client->lockClient);\n        if (rc == 0) {\n            \/* inform other threads of expected response *\/\n            rc = MqttClient_RespList_Add(client,\n                MQTT_PACKET_TYPE_UNSUBSCRIBE_ACK, unsubscribe->packet_id,\n                &unsubscribe->pendResp, &unsubscribe->ack);\n            wm_SemUnlock(&client->lockClient);\n        }\n        if (rc != 0) {\n            wm_SemUnlock(&client->lockSend); \/* Error locking client *\/\n            return rc;\n        }\n    #endif\n\n        \/* Send unsubscribe packet *\/\n        rc = MqttPacket_Write(client, client->tx_buf, len);\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n        if (rc != len) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (wm_SemLock(&client->lockClient) == 0) {\n                MqttClient_RespList_Remove(client, &unsubscribe->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n        #endif\n            return rc;\n        }\n\n        unsubscribe->stat = MQTT_MSG_WAIT;\n    }\n\n    \/* Wait for unsubscribe ack packet *\/\n    rc = MqttClient_WaitType(client, &unsubscribe->ack,\n        MQTT_PACKET_TYPE_UNSUBSCRIBE_ACK, unsubscribe->packet_id,\n        client->cmd_timeout_ms);\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &unsubscribe->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n#ifdef WOLFMQTT_V5\n    if (unsubscribe->ack.props != NULL) {\n        \/* Release the allocated properties *\/\n        MqttClient_PropsFree(unsubscribe->ack.props);\n    }\n#endif\n\n    \/* reset state *\/\n    unsubscribe->stat = MQTT_MSG_BEGIN;\n\n    return rc;\n}","target":0,"code_token_length":759,"total_token_length":995,"max_tokens_setting":1024}
+{"idx":261414,"func":"static int decode_split_cu_flag(thread_context* tctx,\n\t\t\t\tint x0, int y0, int ctDepth)\n{\n  \/\/ check if neighbors are available\n\n  int availableL = check_CTB_available(tctx->img, x0,y0, x0-1,y0);\n  int availableA = check_CTB_available(tctx->img, x0,y0, x0,y0-1);\n\n  int condL = 0;\n  int condA = 0;\n\n  if (availableL && tctx->img->get_ctDepth(x0-1,y0) > ctDepth) condL=1;\n  if (availableA && tctx->img->get_ctDepth(x0,y0-1) > ctDepth) condA=1;\n\n  int contextOffset = condL + condA;\n  int context = contextOffset;\n\n  \/\/ decode bit\n\n  logtrace(LogSlice,\"# split_cu_flag context=%d R=%x\\n\", context, tctx->cabac_decoder.range);\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_SPLIT_CU_FLAG + context]);\n\n  logtrace(LogSlice,\"> split_cu_flag R=%x, ctx=%d, bit=%d\\n\", tctx->cabac_decoder.range,context,bit);\n\n  logtrace(LogSymbols,\"$1 split_cu_flag=%d\\n\",bit);\n\n  return bit;\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":230455,"func":"uip_nd6_rs_output(void)\n{\n  UIP_IP_BUF->vtc = 0x60;\n  UIP_IP_BUF->tcflow = 0;\n  UIP_IP_BUF->flow = 0;\n  UIP_IP_BUF->proto = UIP_PROTO_ICMP6;\n  UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;\n  uip_create_linklocal_allrouters_mcast(&UIP_IP_BUF->destipaddr);\n  uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);\n  UIP_ICMP_BUF->type = ICMP6_RS;\n  UIP_ICMP_BUF->icode = 0;\n\n  if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {\n    UIP_IP_BUF->len[1] = UIP_ICMPH_LEN + UIP_ND6_RS_LEN;\n    uip_len = uip_l3_icmp_hdr_len + UIP_ND6_RS_LEN;\n  } else {\n    uip_len = uip_l3_icmp_hdr_len + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN;\n    uipbuf_set_len_field(UIP_IP_BUF, UIP_ICMPH_LEN + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN);\n\n    create_llao(&uip_buf[uip_l3_icmp_hdr_len + UIP_ND6_RS_LEN],\n                UIP_ND6_OPT_SLLAO);\n  }\n\n  UIP_ICMP_BUF->icmpchksum = 0;\n  UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();\n\n  UIP_STAT(++uip_stat.nd6.sent);\n  LOG_INFO(\"Sending RS to \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);\n  LOG_INFO_(\" from \");\n  LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);\n  LOG_INFO_(\"\\n\");\n  return;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":220850,"func":"inline LutOutT lut_lookup_with_interpolation(int16_t value,\n                                             const LutOutT* lut) {\n  static_assert(std::is_same<LutOutT, int8_t>::value ||\n                    std::is_same<LutOutT, int16_t>::value,\n                \"Only LUTs with int8 or int16 outputs are supported.\");\n  \/\/ 512 base values, lut[513] is only used to calculate the slope\n  const uint16_t index = static_cast<uint16_t>(256 + (value >> 7));\n  assert(index < 512 && \"LUT index out of range.\");\n  const int16_t offset = value & 0x7f;\n\n  \/\/ Base and slope are Q0.x\n  const LutOutT base = lut[index];\n  const LutOutT slope = lut[index + 1] - lut[index];\n\n  \/\/ Q0.x * Q0.7 = Q0.(x + 7)\n  \/\/ Round and convert from Q0.(x + 7) to Q0.x\n  const int delta = (slope * offset + 64) >> 7;\n\n  \/\/ Q0.15 + Q0.15\n  return static_cast<LutOutT>(base + delta);\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":384211,"func":"static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,\n\t\t\t   const struct nlattr *attr)\n{\n\tstruct nlattr *nla[NFTA_SET_ELEM_MAX + 1];\n\tstruct nft_set_ext_tmpl tmpl;\n\tstruct nft_set_elem elem;\n\tstruct nft_set_ext *ext;\n\tstruct nft_trans *trans;\n\tu32 flags = 0;\n\tint err;\n\n\terr = nla_parse_nested_deprecated(nla, NFTA_SET_ELEM_MAX, attr,\n\t\t\t\t\t  nft_set_elem_policy, NULL);\n\tif (err < 0)\n\t\treturn err;\n\n\terr = nft_setelem_parse_flags(set, nla[NFTA_SET_ELEM_FLAGS], &flags);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (!nla[NFTA_SET_ELEM_KEY] && !(flags & NFT_SET_ELEM_CATCHALL))\n\t\treturn -EINVAL;\n\n\tif (!nft_setelem_valid_key_end(set, nla, flags))\n\t\treturn -EINVAL;\n\n\tnft_set_ext_prepare(&tmpl);\n\n\tif (flags != 0) {\n\t\terr = nft_set_ext_add(&tmpl, NFT_SET_EXT_FLAGS);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\tif (nla[NFTA_SET_ELEM_KEY]) {\n\t\terr = nft_setelem_parse_key(ctx, set, &elem.key.val,\n\t\t\t\t\t    nla[NFTA_SET_ELEM_KEY]);\n\t\tif (err < 0)\n\t\t\treturn err;\n\n\t\terr = nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY, set->klen);\n\t\tif (err < 0)\n\t\t\tgoto fail_elem;\n\t}\n\n\tif (nla[NFTA_SET_ELEM_KEY_END]) {\n\t\terr = nft_setelem_parse_key(ctx, set, &elem.key_end.val,\n\t\t\t\t\t    nla[NFTA_SET_ELEM_KEY_END]);\n\t\tif (err < 0)\n\t\t\tgoto fail_elem;\n\n\t\terr = nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY_END, set->klen);\n\t\tif (err < 0)\n\t\t\tgoto fail_elem_key_end;\n\t}\n\n\terr = -ENOMEM;\n\telem.priv = nft_set_elem_init(set, &tmpl, elem.key.val.data,\n\t\t\t\t      elem.key_end.val.data, NULL, 0, 0,\n\t\t\t\t      GFP_KERNEL_ACCOUNT);\n\tif (IS_ERR(elem.priv)) {\n\t\terr = PTR_ERR(elem.priv);\n\t\tgoto fail_elem_key_end;\n\t}\n\n\text = nft_set_elem_ext(set, elem.priv);\n\tif (flags)\n\t\t*nft_set_ext_flags(ext) = flags;\n\n\ttrans = nft_trans_elem_alloc(ctx, NFT_MSG_DELSETELEM, set);\n\tif (trans == NULL)\n\t\tgoto fail_trans;\n\n\terr = nft_setelem_deactivate(ctx->net, set, &elem, flags);\n\tif (err < 0)\n\t\tgoto fail_ops;\n\n\tnft_setelem_data_deactivate(ctx->net, set, &elem);\n\n\tnft_trans_elem(trans) = elem;\n\tnft_trans_commit_list_add_tail(ctx->net, trans);\n\treturn 0;\n\nfail_ops:\n\tkfree(trans);\nfail_trans:\n\tkfree(elem.priv);\nfail_elem_key_end:\n\tnft_data_release(&elem.key_end.val, NFT_DATA_VALUE);\nfail_elem:\n\tnft_data_release(&elem.key.val, NFT_DATA_VALUE);\n\treturn err;\n}","target":0,"code_token_length":689,"total_token_length":925,"max_tokens_setting":1024}
+{"idx":274698,"func":"callbacks_quit_activate                       (GtkMenuItem     *menuitem,\n                                        gpointer         user_data)\n{\n  gboolean layers_dirty = FALSE;\n  gint idx;\n\n  for (idx = 0; idx<=mainProject->last_loaded; idx++) {\n    if (mainProject->file[idx] == NULL) break;\n    layers_dirty = layers_dirty || mainProject->file[idx]->layer_dirty;\n  }\n\n  if (layers_dirty &&\n      !interface_get_alert_dialog_response(\n\t\t_(\"Do you want to close all open layers and quit the program?\"),\n\t\t_(\"Quitting the program will cause any unsaved changes \"\n\t\t\"to be lost.\"),\n\t\tFALSE, NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL)) {\n    return TRUE; \/\/ stop propagation of the delete_event.\n\t\/\/ this would destroy the gui but not return from the gtk event loop.\n  }\n\n  \/* Save background color *\/\n  if (screen.settings && !screen.background_is_from_project) {\n    guint clr;\n    GdkColor *bg = &mainProject->background;\n\n    clr = bg->red\/257<<16 | bg->green\/257<<8 | bg->blue\/257;\n    g_settings_set_uint (screen.settings, \"background-color\", clr);\n  }\n\n  \/* Save main window size and postion *\/\n  if (screen.settings) {\n    GtkWindow *win = GTK_WINDOW(screen.win.topLevelWindow);\n    gint32 xy[2];\n    GVariant *var;\n    gboolean is_max;\n\n    is_max = FALSE != (GDK_WINDOW_STATE_MAXIMIZED & gdk_window_get_state (\n\t\t\t    gtk_widget_get_window (GTK_WIDGET(win))));\n    g_settings_set_boolean (screen.settings, \"window-maximized\", is_max);\n\n    if (!is_max) {\n      gtk_window_get_size (win, (gint *)xy, (gint *)(xy+1));\n      var = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32, xy, 2,\n\t\t      sizeof (xy[0]));\n      g_settings_set_value (screen.settings, \"window-size\", var);\n\n      gtk_window_get_position (win, (gint *)xy, (gint *)(xy+1));\n      var = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32, xy, 2,\n\t\t      sizeof (xy[0]));\n      g_settings_set_value (screen.settings, \"window-position\", var);\n    }\n  }\n\n  gerbv_unload_all_layers (mainProject);\n  gtk_main_quit();\n\n  return FALSE;\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":247690,"func":"TEST_P(SslSocketTest, RsaPrivateKeyProviderAsyncDecryptCompleteFailure) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key_provider:\n        provider_name: test\n        typed_config:\n          \"@type\": type.googleapis.com\/google.protobuf.Struct\n          value:\n            private_key_file: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n            expected_operation: decrypt\n            async_method_error: true\n            mode: rsa\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      crl:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.crl\"\n)EOF\";\n  const std::string failing_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites:\n      - TLS_RSA_WITH_AES_128_GCM_SHA256\n)EOF\";\n\n  TestUtilOptions failing_test_options(failing_client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(failing_test_options.setPrivateKeyMethodExpected(true)\n               .setExpectedServerCloseEvent(Network::ConnectionEvent::LocalClose)\n               .setExpectedServerStats(\"ssl.connection_error\")\n               .setExpectedTransportFailureReasonContains(\"system library\")\n               .setNotExpectedClientStats(\"ssl.connection_error\"));\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":329879,"func":"_fill32_spans (void *abstract_renderer, int y, int h,\n\t       const cairo_half_open_span_t *spans, unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (likely(h == 1)) {\n\tdo {\n\t    if (spans[0].coverage) {\n\t\tint len = spans[1].x - spans[0].x;\n\t\tif (len > 32) {\n\t\t    pixman_fill ((uint32_t *)r->u.fill.data, r->u.fill.stride \/ sizeof(uint32_t), r->bpp,\n\t\t\t\t spans[0].x, y, len, 1, r->u.fill.pixel);\n\t\t} else {\n\t\t    uint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*y + spans[0].x*4);\n\t\t    while (len-- > 0)\n\t\t\t*d++ = r->u.fill.pixel;\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    } else {\n\tdo {\n\t    if (spans[0].coverage) {\n\t\tif (spans[1].x - spans[0].x > 16) {\n\t\t    pixman_fill ((uint32_t *)r->u.fill.data, r->u.fill.stride \/ sizeof(uint32_t), r->bpp,\n\t\t\t\t spans[0].x, y, spans[1].x - spans[0].x, h,\n\t\t\t\t r->u.fill.pixel);\n\t\t} else {\n\t\t    int yy = y, hh = h;\n\t\t    do {\n\t\t\tint len = spans[1].x - spans[0].x;\n\t\t\tuint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*yy + spans[0].x*4);\n\t\t\twhile (len-- > 0)\n\t\t\t    *d++ = r->u.fill.pixel;\n\t\t\tyy++;\n\t\t    } while (--hh);\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":402596,"func":"handle_is_token_unlocked(context *ctx, struct pollfd *pollfd, socklen_t size)\n{\n\tstruct msghdr msg;\n\tstruct iovec iov;\n\tssize_t n;\n\n\tint rc = cms_context_alloc(&ctx->cms);\n\tif (rc < 0) {\n\t\tsend_response(ctx, ctx->backup_cms, pollfd, rc);\n\t\treturn;\n\t}\n\n\tsteal_from_cms(ctx->backup_cms, ctx->cms);\n\n\tchar *buffer = malloc(size);\n\tif (!buffer) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unable to allocate memory: %m\");\n\t\texit(1);\n\t}\n\n\tmemset(&msg, '\\0', sizeof(msg));\n\n\tiov.iov_base = buffer;\n\tiov.iov_len = size;\n\tmsg.msg_iov = &iov;\n\tmsg.msg_iovlen = 1;\n\n\tn = recvmsg(pollfd->fd, &msg, MSG_WAITALL);\n\n\tpesignd_string *tn = (pesignd_string *)buffer;\n\tif (n < (long long)sizeof(tn->size)) {\nmalformed:\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unlock-token: invalid data\");\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"possible exploit attempt. closing.\");\n\t\tclose(pollfd->fd);\n\t\treturn;\n\t}\n\tn -= sizeof(tn->size);\n\tif ((size_t)n < tn->size)\n\t\tgoto malformed;\n\tn -= tn->size;\n\n\tif (tn->value[tn->size - 1] != '\\0')\n\t\tgoto malformed;\n\n\tif (n != 0)\n\t\tgoto malformed;\n\n\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\"querying token \\\"%s\\\"\", tn->value);\n\n\tchar *key = (char *)tn->value;\n\tchar *tokenname;\n\n\ttokenname = bsearch(&key, ctx->tokennames, ctx->ntokennames,\n\t\t\t\tsizeof (char *), cmpstringp);\n\tsend_response(ctx, ctx->cms, pollfd, tokenname == NULL ? 1 : 0);\n\n\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\t\"token \\\"%s\\\" is %sunlocked\", tn->value,\n\t\t\ttokenname == NULL ? \"not \" : \"\");\n\n\tfree(buffer);\n\n\thide_stolen_goods_from_cms(ctx->cms, ctx->backup_cms);\n\tcms_context_fini(ctx->cms);\n}","target":0,"code_token_length":531,"total_token_length":767,"max_tokens_setting":1024}
+{"idx":267845,"func":"vm_construct_literal_object (vm_frame_ctx_t *frame_ctx_p, \/**< frame context *\/\n                             ecma_value_t lit_value) \/**< literal *\/\n{\n  ecma_compiled_code_t *bytecode_p;\n\n#if JERRY_SNAPSHOT_EXEC\n  if (JERRY_LIKELY (!(frame_ctx_p->shared_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)))\n  {\n#endif \/* JERRY_SNAPSHOT_EXEC *\/\n    bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,\n                                                  lit_value);\n#if JERRY_SNAPSHOT_EXEC\n  }\n  else\n  {\n    uint8_t *byte_p = ((uint8_t *) frame_ctx_p->shared_p->bytecode_header_p) + lit_value;\n    bytecode_p = (ecma_compiled_code_t *) byte_p;\n  }\n#endif \/* JERRY_SNAPSHOT_EXEC *\/\n\n#if JERRY_BUILTIN_REGEXP\n  if (JERRY_UNLIKELY (!CBC_IS_FUNCTION (bytecode_p->status_flags)))\n  {\n    ecma_object_t *regexp_obj_p = ecma_op_regexp_alloc (NULL);\n\n    if (JERRY_UNLIKELY (regexp_obj_p == NULL))\n    {\n      return ECMA_VALUE_ERROR;\n    }\n\n    return ecma_op_create_regexp_from_bytecode (regexp_obj_p, (re_compiled_code_t *) bytecode_p);\n  }\n#else \/* !JERRY_BUILTIN_REGEXP *\/\n  JERRY_ASSERT (CBC_IS_FUNCTION (bytecode_p->status_flags));\n#endif \/* JERRY_BUILTIN_REGEXP *\/\n\n  ecma_object_t *func_obj_p;\n\n#if JERRY_ESNEXT\n  if (JERRY_UNLIKELY (CBC_FUNCTION_IS_ARROW (bytecode_p->status_flags)))\n  {\n    func_obj_p = ecma_op_create_arrow_function_object (frame_ctx_p->lex_env_p,\n                                                       bytecode_p,\n                                                       frame_ctx_p->this_binding);\n  }\n  else\n  {\n    func_obj_p = ecma_op_create_any_function_object (frame_ctx_p->lex_env_p, bytecode_p);\n  }\n#else \/* !JERRY_ESNEXT *\/\n  func_obj_p = ecma_op_create_simple_function_object (frame_ctx_p->lex_env_p, bytecode_p);\n#endif \/* JERRY_ESNEXT *\/\n\n  return ecma_make_object_value (func_obj_p);\n} \/* vm_construct_literal_object *\/","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":272350,"func":"generate_ava(cms_context *cms, SECItem *der, CERTAVA *certava)\n{\n\tava ava;\n\n\tSECOidData *oid;\n\n\tvoid *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);\n\tif (arena == NULL)\n\t\tcnreterr(-1, cms, \"could not create arena\");\n\n\tvoid *real_arena = cms->arena;\n\tcms->arena = arena;\n\n\toid = SECOID_FindOID(&certava->type);\n\tif (!oid) {\n\t\tsave_port_err() {\n\t\t\tPORT_FreeArena(arena, PR_TRUE);\n\t\t}\n\t\tcms->arena = real_arena;\n\t\tcnreterr(-1, cms, \"could not find OID\");\n\t}\n\n\tint rc = generate_object_id(cms, &ava.type, oid->offset);\n\tif (rc < 0) {\n\t\tPORT_FreeArena(arena, PR_TRUE);\n\t\tcms->arena = real_arena;\n\t\treturn -1;\n\t}\n\n\tmemcpy(&ava.value, &certava->value, sizeof (ava.value));\n\n\tvoid *ret;\n\tSECItem tmp;\n\tret = SEC_ASN1EncodeItem(arena, &tmp, &ava, AVATemplate);\n\tif (ret == NULL) {\n\t\tsave_port_err() {\n\t\t\tPORT_FreeArena(arena, PR_TRUE);\n\t\t}\n\t\tcms->arena = real_arena;\n\t\tcnreterr(-1, cms, \"could not encode AVA\");\n\t}\n\n\tder->type = tmp.type;\n\tder->len = tmp.len;\n\tder->data = PORT_ArenaAlloc(real_arena, tmp.len);\n\tif (!der->data) {\n\t\tsave_port_err() {\n\t\t\tPORT_FreeArena(arena, PR_TRUE);\n\t\t}\n\t\tcms->arena = real_arena;\n\t\tcnreterr(-1, cms, \"could not allocate AVA\");\n\t}\n\tmemcpy(der->data, tmp.data, tmp.len);\n\tPORT_FreeArena(arena, PR_TRUE);\n\tcms->arena = real_arena;\n\n\treturn 0;\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":404720,"func":"static struct fdtable * alloc_fdtable(unsigned int nr)\n{\n\tstruct fdtable *fdt;\n\tvoid *data;\n\n\t\/*\n\t * Figure out how many fds we actually want to support in this fdtable.\n\t * Allocation steps are keyed to the size of the fdarray, since it\n\t * grows far faster than any of the other dynamic data. We try to fit\n\t * the fdarray into comfortable page-tuned chunks: starting at 1024B\n\t * and growing in powers of two from there on.\n\t *\/\n\tnr \/= (1024 \/ sizeof(struct file *));\n\tnr = roundup_pow_of_two(nr + 1);\n\tnr *= (1024 \/ sizeof(struct file *));\n\t\/*\n\t * Note that this can drive nr *below* what we had passed if sysctl_nr_open\n\t * had been set lower between the check in expand_files() and here.  Deal\n\t * with that in caller, it's cheaper that way.\n\t *\n\t * We make sure that nr remains a multiple of BITS_PER_LONG - otherwise\n\t * bitmaps handling below becomes unpleasant, to put it mildly...\n\t *\/\n\tif (unlikely(nr > sysctl_nr_open))\n\t\tnr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1;\n\n\tfdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT);\n\tif (!fdt)\n\t\tgoto out;\n\tfdt->max_fds = nr;\n\tdata = kvmalloc_array(nr, sizeof(struct file *), GFP_KERNEL_ACCOUNT);\n\tif (!data)\n\t\tgoto out_fdt;\n\tfdt->fd = data;\n\n\tdata = kvmalloc(max_t(size_t,\n\t\t\t\t 2 * nr \/ BITS_PER_BYTE + BITBIT_SIZE(nr), L1_CACHE_BYTES),\n\t\t\t\t GFP_KERNEL_ACCOUNT);\n\tif (!data)\n\t\tgoto out_arr;\n\tfdt->open_fds = data;\n\tdata += nr \/ BITS_PER_BYTE;\n\tfdt->close_on_exec = data;\n\tdata += nr \/ BITS_PER_BYTE;\n\tfdt->full_fds_bits = data;\n\n\treturn fdt;\n\nout_arr:\n\tkvfree(fdt->fd);\nout_fdt:\n\tkfree(fdt);\nout:\n\treturn NULL;\n}","target":0,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":223090,"func":"static size_t PCLPackbitsCompressImage(const size_t length,\n  const unsigned char *pixels,unsigned char *compress_pixels)\n{\n  int\n    count;\n\n  ssize_t\n    x;\n\n  unsigned char\n    *q;\n\n  ssize_t\n    j;\n\n  unsigned char\n    packbits[128];\n\n  \/*\n    Compress pixels with Packbits encoding.\n  *\/\n  q=compress_pixels;\n  for (x=(ssize_t) length; x != 0; )\n  {\n    switch (x)\n    {\n      case 1:\n      {\n        x--;\n        *q++=0;\n        *q++=(*pixels);\n        break;\n      }\n      case 2:\n      {\n        x-=2;\n        *q++=1;\n        *q++=(*pixels);\n        *q++=pixels[1];\n        break;\n      }\n      case 3:\n      {\n        x-=3;\n        if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))\n          {\n            *q++=(unsigned char) ((256-3)+1);\n            *q++=(*pixels);\n            break;\n          }\n        *q++=2;\n        *q++=(*pixels);\n        *q++=pixels[1];\n        *q++=pixels[2];\n        break;\n      }\n      default:\n      {\n        if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))\n          {\n            \/*\n              Packed run.\n            *\/\n            count=3;\n            while (((ssize_t) count < x) && (*pixels == *(pixels+count)))\n            {\n              count++;\n              if (count >= 127)\n                break;\n            }\n            x-=count;\n            *q++=(unsigned char) ((256-count)+1);\n            *q++=(*pixels);\n            pixels+=count;\n            break;\n          }\n        \/*\n          Literal run.\n        *\/\n        count=0;\n        while ((*(pixels+count) != *(pixels+count+1)) ||\n               (*(pixels+count+1) != *(pixels+count+2)))\n        {\n          packbits[count+1]=pixels[count];\n          count++;\n          if (((ssize_t) count >= (x-3)) || (count >= 127))\n            break;\n        }\n        x-=count;\n        *packbits=(unsigned char) (count-1);\n        for (j=0; j <= (ssize_t) count; j++)\n          *q++=packbits[j];\n        pixels+=count;\n        break;\n      }\n    }\n  }\n  *q++=128; \/* EOD marker *\/\n  return((size_t) (q-compress_pixels));\n}","target":0,"code_token_length":581,"total_token_length":817,"max_tokens_setting":1024}
+{"idx":454756,"func":"static void ismt_mstr_reg_dump(struct ismt_priv *priv)\n{\n\tstruct device *dev = &priv->pci_dev->dev;\n\n\tdev_dbg(dev, \"Dump of the iSMT Master Registers\\n\");\n\tdev_dbg(dev, \"  MDBA..... : (0x%p)=0x%016llX\\n\",\n\t\tpriv->smba + ISMT_MSTR_MDBA,\n\t\t(long long unsigned int)readq(priv->smba + ISMT_MSTR_MDBA));\n\tdev_dbg(dev, \"  MCTRL.... : (0x%p)=0x%X\\n\",\n\t\tpriv->smba + ISMT_MSTR_MCTRL,\n\t\treadl(priv->smba + ISMT_MSTR_MCTRL));\n\tdev_dbg(dev, \"  MSTS..... : (0x%p)=0x%X\\n\",\n\t\tpriv->smba + ISMT_MSTR_MSTS,\n\t\treadl(priv->smba + ISMT_MSTR_MSTS));\n\tdev_dbg(dev, \"  MDS...... : (0x%p)=0x%X\\n\",\n\t\tpriv->smba + ISMT_MSTR_MDS,\n\t\treadl(priv->smba + ISMT_MSTR_MDS));\n\tdev_dbg(dev, \"  RPOLICY.. : (0x%p)=0x%X\\n\",\n\t\tpriv->smba + ISMT_MSTR_RPOLICY,\n\t\treadl(priv->smba + ISMT_MSTR_RPOLICY));\n\tdev_dbg(dev, \"  SPGT..... : (0x%p)=0x%X\\n\",\n\t\tpriv->smba + ISMT_SPGT,\n\t\treadl(priv->smba + ISMT_SPGT));\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":195067,"func":"StatusOr<FullTypeDef> SpecializeType(const AttrSlice& attrs,\n                                     const OpDef& op_def) {\n  FullTypeDef ft;\n  ft.set_type_id(TFT_PRODUCT);\n\n  for (int i = 0; i < op_def.output_arg_size(); i++) {\n    auto* t = ft.add_args();\n\n    *t = op_def.output_arg(i).experimental_full_type();\n\n    \/\/ Resolve dependent types. The convention for op registrations is to use\n    \/\/ attributes as type variables.\n    \/\/ See https:\/\/www.tensorflow.org\/guide\/create_op#type_polymorphism.\n    \/\/ Once the op signature can be defined entirely in FullType, this\n    \/\/ convention can be deprecated.\n    \/\/\n    \/\/ Note: While this code performs some basic verifications, it generally\n    \/\/ assumes consistent op defs and attributes. If more complete\n    \/\/ verifications are needed, they should be done by separately, and in a\n    \/\/ way that can be reused for type inference.\n    for (int j = 0; j < t->args_size(); j++) {\n      auto* arg = t->mutable_args(i);\n      if (arg->type_id() == TFT_VAR) {\n        const auto* attr = attrs.Find(arg->s());\n        DCHECK(attr != nullptr);\n        if (attr->value_case() == AttrValue::kList) {\n          const auto& attr_list = attr->list();\n          arg->set_type_id(TFT_PRODUCT);\n          for (int i = 0; i < attr_list.type_size(); i++) {\n            map_dtype_to_tensor(attr_list.type(i), arg->add_args());\n          }\n\n        } else if (attr->value_case() == AttrValue::kType) {\n          map_dtype_to_tensor(attr->type(), arg);\n\n        } else {\n          return Status(error::UNIMPLEMENTED,\n                        absl::StrCat(\"unknown attribute type\",\n                                     attrs.DebugString(), \" key=\", arg->s()));\n        }\n\n        arg->clear_s();\n      }\n    }\n  }\n\n  return ft;\n}","target":1,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":244041,"func":"GF_Err saio_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_SampleAuxiliaryInfoOffsetBox *ptr = (GF_SampleAuxiliaryInfoOffsetBox *)s;\n\n\tif (ptr->flags & 1) {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->aux_info_type = gf_bs_read_u32(bs);\n\t\tptr->aux_info_type_parameter = gf_bs_read_u32(bs);\n\t}\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->entry_count = gf_bs_read_u32(bs);\n\n\tif (ptr->entry_count) {\n\t\tu32 i;\n\t\tif (ptr->size \/ (ptr->version == 0 ? 4 : 8) < ptr->entry_count || (u64)ptr->entry_count > (u64)SIZE_MAX\/sizeof(u64))\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\tptr->offsets = gf_malloc(sizeof(u64)*ptr->entry_count);\n\t\tif (!ptr->offsets)\n\t\t\treturn GF_OUT_OF_MEM;\n\t\tptr->entry_alloc = ptr->entry_count;\n\t\tif (ptr->version==0) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 4*ptr->entry_count);\n\t\t\tfor (i=0; i<ptr->entry_count; i++)\n\t\t\t\tptr->offsets[i] = gf_bs_read_u32(bs);\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(ptr, 8*ptr->entry_count);\n\t\t\tfor (i=0; i<ptr->entry_count; i++)\n\t\t\t\tptr->offsets[i] = gf_bs_read_u64(bs);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":329938,"func":"composite_traps (void\t\t\t*_dst,\n\t\t cairo_operator_t\top,\n\t\t cairo_surface_t\t*abstract_src,\n\t\t int\t\t\tsrc_x,\n\t\t int\t\t\tsrc_y,\n\t\t int\t\t\tdst_x,\n\t\t int\t\t\tdst_y,\n\t\t const cairo_rectangle_int_t *extents,\n\t\t cairo_antialias_t\tantialias,\n\t\t cairo_traps_t\t\t*traps)\n{\n    cairo_image_surface_t *dst = (cairo_image_surface_t *) _dst;\n    cairo_image_source_t *src = (cairo_image_source_t *) abstract_src;\n    cairo_int_status_t status;\n    pixman_image_t *mask;\n    pixman_format_code_t format;\n\n    TRACE ((stderr, \"%s\\n\", __FUNCTION__));\n\n    \/* pixman doesn't eliminate self-intersecting trapezoids\/edges *\/\n    status = _cairo_bentley_ottmann_tessellate_traps (traps,\n\t\t\t\t\t\t      CAIRO_FILL_RULE_WINDING);\n    if (status != CAIRO_INT_STATUS_SUCCESS)\n\t    return status;\n\n    \/* Special case adding trapezoids onto a mask surface; we want to avoid\n     * creating an intermediate temporary mask unnecessarily.\n     *\n     * We make the assumption here that the portion of the trapezoids\n     * contained within the surface is bounded by [dst_x,dst_y,width,height];\n     * the Cairo core code passes bounds based on the trapezoid extents.\n     *\/\n    format = antialias == CAIRO_ANTIALIAS_NONE ? PIXMAN_a1 : PIXMAN_a8;\n    if (dst->pixman_format == format &&\n\t(abstract_src == NULL ||\n\t (op == CAIRO_OPERATOR_ADD && src->is_opaque_solid)))\n    {\n\t_pixman_image_add_traps (dst->pixman_image, dst_x, dst_y, traps);\n\treturn CAIRO_STATUS_SUCCESS;\n    }\n\n    mask = pixman_image_create_bits (format,\n\t\t\t\t     extents->width, extents->height,\n\t\t\t\t     NULL, 0);\n    if (unlikely (mask == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n    _pixman_image_add_traps (mask, extents->x, extents->y, traps);\n    pixman_image_composite32 (_pixman_operator (op),\n                              src->pixman_image, mask, dst->pixman_image,\n                              extents->x + src_x, extents->y + src_y,\n                              0, 0,\n                              extents->x - dst_x, extents->y - dst_y,\n                              extents->width, extents->height);\n\n    pixman_image_unref (mask);\n\n    return  CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":473835,"func":"st_copy(st_table *old_table)\n{\n    st_table *new_table;\n    st_table_entry *ptr, *entry, *prev, **tail;\n    st_index_t num_bins = old_table->num_bins;\n    st_index_t hash_val;\n\n    new_table = alloc(st_table);\n    if (new_table == 0) {\n\treturn 0;\n    }\n\n    *new_table = *old_table;\n    new_table->bins = (st_table_entry**)\n\tCalloc((unsigned)num_bins, sizeof(st_table_entry*));\n\n    if (new_table->bins == 0) {\n\tfree(new_table);\n\treturn 0;\n    }\n\n    if (old_table->entries_packed) {\n        memcpy(new_table->bins, old_table->bins, sizeof(struct st_table_entry *) * old_table->num_bins);\n        return new_table;\n    }\n\n    if ((ptr = old_table->head) != 0) {\n\tprev = 0;\n\ttail = &new_table->head;\n\tdo {\n\t    entry = alloc(st_table_entry);\n\t    if (entry == 0) {\n\t\tst_free_table(new_table);\n\t\treturn 0;\n\t    }\n\t    *entry = *ptr;\n\t    hash_val = entry->hash % num_bins;\n\t    entry->next = new_table->bins[hash_val];\n\t    new_table->bins[hash_val] = entry;\n\t    entry->back = prev;\n\t    *tail = prev = entry;\n\t    tail = &entry->fore;\n\t} while ((ptr = ptr->fore) != 0);\n\tnew_table->tail = prev;\n    }\n\n    return new_table;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":326631,"func":"set_times(struct archive_write_disk *a,\n    int fd, int mode, const char *name,\n    time_t atime, long atime_nanos,\n    time_t birthtime, long birthtime_nanos,\n    time_t mtime, long mtime_nanos,\n    time_t cctime, long ctime_nanos)\n{\n\t\/* Note: set_time doesn't use libarchive return conventions!\n\t * It uses syscall conventions.  So 0 here instead of ARCHIVE_OK. *\/\n\tint r1 = 0, r2 = 0;\n\n#ifdef F_SETTIMES\n\t \/*\n\t * on Tru64 try own fcntl first which can restore even the\n\t * ctime, fall back to default code path below if it fails\n\t * or if we are not running as root\n\t *\/\n\tif (a->user_uid == 0 &&\n\t    set_time_tru64(fd, mode, name,\n\t\t\t   atime, atime_nanos, mtime,\n\t\t\t   mtime_nanos, cctime, ctime_nanos) == 0) {\n\t\treturn (ARCHIVE_OK);\n\t}\n#else \/* Tru64 *\/\n\t(void)cctime; \/* UNUSED *\/\n\t(void)ctime_nanos; \/* UNUSED *\/\n#endif \/* Tru64 *\/\n\n#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME\n\t\/*\n\t * If you have struct stat.st_birthtime, we assume BSD\n\t * birthtime semantics, in which {f,l,}utimes() updates\n\t * birthtime to earliest mtime.  So we set the time twice,\n\t * first using the birthtime, then using the mtime.  If\n\t * birthtime == mtime, this isn't necessary, so we skip it.\n\t * If birthtime > mtime, then this won't work, so we skip it.\n\t *\/\n\tif (birthtime < mtime\n\t    || (birthtime == mtime && birthtime_nanos < mtime_nanos))\n\t\tr1 = set_time(fd, mode, name,\n\t\t\t      atime, atime_nanos,\n\t\t\t      birthtime, birthtime_nanos);\n#else\n\t(void)birthtime; \/* UNUSED *\/\n\t(void)birthtime_nanos; \/* UNUSED *\/\n#endif\n\tr2 = set_time(fd, mode, name,\n\t\t      atime, atime_nanos,\n\t\t      mtime, mtime_nanos);\n\tif (r1 != 0 || r2 != 0) {\n\t\tarchive_set_error(&a->archive, errno,\n\t\t\t\t  \"Can't restore time\");\n\t\treturn (ARCHIVE_WARN);\n\t}\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":261949,"func":"njs_string_prototype_substring(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    int64_t            start, end, length;\n    njs_int_t          ret;\n    njs_value_t        *value;\n    njs_slice_prop_t   slice;\n    njs_string_prop_t  string;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = njs_string_prop(&string, njs_argument(args, 0));\n\n    slice.string_length = length;\n    start = 0;\n\n    if (nargs > 1) {\n        value = njs_argument(args, 1);\n\n        if (njs_slow_path(!njs_is_number(value))) {\n            ret = njs_value_to_integer(vm, value, &start);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n        } else {\n            start = njs_number_to_integer(njs_number(value));\n        }\n\n        if (start < 0) {\n            start = 0;\n\n        } else if (start > length) {\n            start = length;\n        }\n\n        end = length;\n\n        if (nargs > 2) {\n            value = njs_arg(args, nargs, 2);\n\n            if (njs_slow_path(!njs_is_number(value))) {\n                ret = njs_value_to_integer(vm, value, &end);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    return ret;\n                }\n\n            } else {\n                end = njs_number_to_integer(njs_number(value));\n            }\n\n            if (end < 0) {\n                end = 0;\n\n            } else if (end >= length) {\n                end = length;\n            }\n        }\n\n        length = end - start;\n\n        if (length < 0) {\n            length = -length;\n            start = end;\n        }\n    }\n\n    slice.start = start;\n    slice.length = length;\n\n    return njs_string_slice(vm, &vm->retval, &string, &slice);\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":517454,"func":"static void do_home_program(HttpResponse res) {\n        char buf[STRLEN];\n        boolean_t on = true;\n        boolean_t header = true;\n\n        for (Service_T s = servicelist_conf; s; s = s->next_conf) {\n                if (s->type != Service_Program)\n                        continue;\n                if (header) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<table id='header-row'>\"\n                                            \"<tr>\"\n                                            \"<th class='left' class='first'>Program<\/th>\"\n                                            \"<th class='left'>Status<\/th>\"\n                                            \"<th class='left'>Output<\/th>\"\n                                            \"<th class='right'>Last started<\/th>\"\n                                            \"<th class='right'>Exit value<\/th>\"\n                                            \"<\/tr>\");\n                        header = false;\n                }\n                StringBuffer_append(res->outputbuffer,\n                                    \"<tr %s>\"\n                                    \"<td class='left'><a href='%s'>%s<\/a><\/td>\"\n                                    \"<td class='left'>%s<\/td>\",\n                                    on ? \"class='stripe'\" : \"\",\n                                    s->name, s->name,\n                                    get_service_status(HTML, s, buf, sizeof(buf)));\n                if (! Util_hasServiceStatus(s)) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='left'>-<\/td>\");\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                } else {\n                        if (s->program->started) {\n                                StringBuffer_append(res->outputbuffer, \"<td class='left short'>\");\n                                if (StringBuffer_length(s->program->lastOutput)) {\n                                        \/\/ Print first line only (escape HTML characters if any)\n                                        const char *output = StringBuffer_toString(s->program->lastOutput);\n                                        for (int i = 0; output[i]; i++) {\n                                                if (output[i] == '<')\n                                                        StringBuffer_append(res->outputbuffer, \"<\");\n                                                else if (output[i] == '>')\n                                                        StringBuffer_append(res->outputbuffer, \">\");\n                                                else if (output[i] == '&')\n                                                        StringBuffer_append(res->outputbuffer, \"&\");\n                                                else if (output[i] == '\\r' || output[i] == '\\n')\n                                                        break;\n                                                else\n                                                        StringBuffer_append(res->outputbuffer, \"%c\", output[i]);\n                                        }\n                                } else {\n                                        StringBuffer_append(res->outputbuffer, \"no output\");\n                                }\n                                StringBuffer_append(res->outputbuffer, \"<\/td>\");\n                                StringBuffer_append(res->outputbuffer, \"<td class='right'>%s<\/td>\", Time_fmt((char[32]){}, 32, \"%d %b %Y %H:%M:%S\", s->program->started));\n                                StringBuffer_append(res->outputbuffer, \"<td class='right'>%d<\/td>\", s->program->exitStatus);\n                        } else {\n                                StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                                StringBuffer_append(res->outputbuffer, \"<td class='right'>Not yet started<\/td>\");\n                                StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                        }\n                }\n                StringBuffer_append(res->outputbuffer, \"<\/tr>\");\n                on = ! on;\n        }\n        if (! header)\n                StringBuffer_append(res->outputbuffer, \"<\/table>\");\n\n}","target":0,"code_token_length":699,"total_token_length":935,"max_tokens_setting":1024}
+{"idx":301503,"func":"spell_suggest_list(\n    garray_T\t*gap,\n    char_u\t*word,\n    int\t\tmaxcount,\t\/\/ maximum nr of suggestions\n    int\t\tneed_cap,\t\/\/ 'spellcapcheck' matched\n    int\t\tinteractive)\n{\n    suginfo_T\tsug;\n    int\t\ti;\n    suggest_T\t*stp;\n    char_u\t*wcopy;\n\n    spell_find_suggest(word, 0, &sug, maxcount, FALSE, need_cap, interactive);\n\n    \/\/ Make room in \"gap\".\n    ga_init2(gap, sizeof(char_u *), sug.su_ga.ga_len + 1);\n    if (ga_grow(gap, sug.su_ga.ga_len) == OK)\n    {\n\tfor (i = 0; i < sug.su_ga.ga_len; ++i)\n\t{\n\t    stp = &SUG(sug.su_ga, i);\n\n\t    \/\/ The suggested word may replace only part of \"word\", add the not\n\t    \/\/ replaced part.\n\t    wcopy = alloc(stp->st_wordlen\n\t\t      + (unsigned)STRLEN(sug.su_badptr + stp->st_orglen) + 1);\n\t    if (wcopy == NULL)\n\t\tbreak;\n\t    STRCPY(wcopy, stp->st_word);\n\t    STRCPY(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen);\n\t    ((char_u **)gap->ga_data)[gap->ga_len++] = wcopy;\n\t}\n    }\n\n    spell_find_cleanup(&sug);\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":508373,"func":"find_field_in_view(THD *thd, TABLE_LIST *table_list,\n                   const char *name, uint length,\n                   const char *item_name, Item **ref,\n                   bool register_tree_change)\n{\n  DBUG_ENTER(\"find_field_in_view\");\n  DBUG_PRINT(\"enter\",\n             (\"view: '%s', field name: '%s', item name: '%s', ref %p\",\n              table_list->alias, name, item_name, ref));\n  Field_iterator_view field_it;\n  field_it.set(table_list);\n  Query_arena *arena= 0, backup;  \n\n  for (; !field_it.end_of_fields(); field_it.next())\n  {\n    if (!my_strcasecmp(system_charset_info, field_it.name(), name))\n    {\n      \/\/ in PS use own arena or data will be freed after prepare\n      if (register_tree_change &&\n          thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())\n        arena= thd->activate_stmt_arena_if_needed(&backup);\n      \/*\n        create_item() may, or may not create a new Item, depending on\n        the column reference. See create_view_field() for details.\n      *\/\n      Item *item= field_it.create_item(thd);\n      if (arena)\n        thd->restore_active_arena(arena, &backup);\n      \n      if (!item)\n        DBUG_RETURN(0);\n      if (!ref)\n        DBUG_RETURN((Field*) view_ref_found);\n      \/*\n       *ref != NULL means that *ref contains the item that we need to\n       replace. If the item was aliased by the user, set the alias to\n       the replacing item.\n       We need to set alias on both ref itself and on ref real item.\n      *\/\n      if (*ref && !(*ref)->is_autogenerated_name)\n      {\n        if (register_tree_change)\n\t{\n          item->set_name_for_rollback(thd, (*ref)->name, \n                                      (*ref)->name_length,\n                                      system_charset_info);\n          item->real_item()->set_name_for_rollback(thd, (*ref)->name,\n                                                   (*ref)->name_length,\n                                                   system_charset_info);\n        }\n        else\n\t{\n          item->set_name(thd, (*ref)->name, (*ref)->name_length,\n                         system_charset_info);\n          item->real_item()->set_name(thd, (*ref)->name, (*ref)->name_length,\n                                      system_charset_info);\n        }\n      }\n      if (register_tree_change)\n        thd->change_item_tree(ref, item);\n      else\n        *ref= item;\n      DBUG_RETURN((Field*) view_ref_found);\n    }\n  }\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":500687,"func":"static sftp_status_message parse_status_msg(sftp_message msg){\n  sftp_status_message status;\n\n  if (msg->packet_type != SSH_FXP_STATUS) {\n    ssh_set_error(msg->sftp->session, SSH_FATAL,\n        \"Not a ssh_fxp_status message passed in!\");\n    return NULL;\n  }\n\n  status = malloc(sizeof(struct sftp_status_message_struct));\n  if (status == NULL) {\n    ssh_set_error_oom(msg->sftp->session);\n    return NULL;\n  }\n  ZERO_STRUCTP(status);\n\n  status->id = msg->id;\n  if (buffer_get_u32(msg->payload,&status->status) != 4){\n    SAFE_FREE(status);\n    ssh_set_error(msg->sftp->session, SSH_FATAL,\n        \"Invalid SSH_FXP_STATUS message\");\n    return NULL;\n  }\n  status->error = buffer_get_ssh_string(msg->payload);\n  status->lang = buffer_get_ssh_string(msg->payload);\n  if(status->error == NULL || status->lang == NULL){\n    if(msg->sftp->version >=3){\n      \/* These are mandatory from version 3 *\/\n      ssh_string_free(status->error);\n    \/* status->lang never get allocated if something failed *\/\n      SAFE_FREE(status);\n      ssh_set_error(msg->sftp->session, SSH_FATAL,\n        \"Invalid SSH_FXP_STATUS message\");\n      return NULL;\n    }\n  }\n\n  status->status = ntohl(status->status);\n  if(status->error)\n    status->errormsg = ssh_string_to_char(status->error);\n  else\n    status->errormsg = strdup(\"No error message in packet\");\n  if(status->lang)\n    status->langmsg = ssh_string_to_char(status->lang);\n  else\n    status->langmsg = strdup(\"\");\n  if (status->errormsg == NULL || status->langmsg == NULL) {\n    ssh_set_error_oom(msg->sftp->session);\n    status_msg_free(status);\n    return NULL;\n  }\n\n  return status;\n}","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":437317,"func":"check_type_tree(Node* node, int type_mask, int enclosure_mask, int anchor_mask)\n{\n  NodeType type;\n  int r = 0;\n\n  type = NODE_TYPE(node);\n  if ((NODE_TYPE2BIT(type) & type_mask) == 0)\n    return 1;\n\n  switch (type) {\n  case NODE_LIST:\n  case NODE_ALT:\n    do {\n      r = check_type_tree(NODE_CAR(node), type_mask, enclosure_mask,\n                          anchor_mask);\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_QUANT:\n    r = check_type_tree(NODE_BODY(node), type_mask, enclosure_mask, anchor_mask);\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n      if (((1<<en->type) & enclosure_mask) == 0)\n        return 1;\n\n      r = check_type_tree(NODE_BODY(node), type_mask, enclosure_mask, anchor_mask);\n      if (r == 0 && en->type == ENCLOSURE_IF_ELSE) {\n        if (IS_NOT_NULL(en->te.Then)) {\n          r = check_type_tree(en->te.Then, type_mask, enclosure_mask, anchor_mask);\n          if (r != 0) break;\n        }\n        if (IS_NOT_NULL(en->te.Else)) {\n          r = check_type_tree(en->te.Else, type_mask, enclosure_mask, anchor_mask);\n        }\n      }\n    }\n    break;\n\n  case NODE_ANCHOR:\n    type = ANCHOR_(node)->type;\n    if ((type & anchor_mask) == 0)\n      return 1;\n\n    if (IS_NOT_NULL(NODE_BODY(node)))\n      r = check_type_tree(NODE_BODY(node), type_mask, enclosure_mask, anchor_mask);\n    break;\n\n  case NODE_GIMMICK:\n  default:\n    break;\n  }\n  return r;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":225489,"func":"Status MutableGraphView::UpdateAllRegularFaninsToControlling(\n    absl::string_view node_name) {\n  auto error_status = [node_name](absl::string_view msg) {\n    string params = absl::Substitute(\"node_name='$0'\", node_name);\n    return MutationError(\"UpdateAllRegularFaninsToControlling\", params, msg);\n  };\n\n  NodeDef* node = GetNode(node_name);\n  TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));\n\n  const int num_regular_fanins =\n      NumFanins(*node, \/*include_controlling_nodes=*\/false);\n  std::vector<OutputPort> regular_fanins;\n  regular_fanins.reserve(num_regular_fanins);\n  std::vector<NodeDef*> controlling_fanins;\n  controlling_fanins.reserve(num_regular_fanins);\n\n  \/\/ Get all regular fanins and derive controlling fanins.\n  for (int i = 0; i < num_regular_fanins; ++i) {\n    TensorId tensor_id = ParseTensorName(node->input(i));\n    OutputPort fanin_port(nodes()[tensor_id.node()], tensor_id.index());\n\n    string error_msg = \"\";\n    NodeDef* control_node =\n        GetControllingFaninToAdd(node_name, fanin_port, &error_msg);\n    if (!error_msg.empty()) {\n      return error_status(error_msg);\n    }\n\n    regular_fanins.push_back(fanin_port);\n    controlling_fanins.push_back(control_node);\n  }\n\n  \/\/ Replace regular fanins with controlling fanins and dedup.\n  int pos = 0;\n  InputPort input_port(node, Graph::kControlSlot);\n  absl::flat_hash_set<absl::string_view> controls;\n  for (int i = 0; i < num_regular_fanins; ++i) {\n    OutputPort fanin_port = regular_fanins[i];\n    NodeDef* control = controlling_fanins[i];\n    if (control == nullptr) {\n      control = GetOrCreateIdentityConsumingSwitch(fanin_port);\n    }\n    fanouts()[fanin_port].erase({node, i});\n    if (controls.contains(control->name())) {\n      continue;\n    }\n    controls.insert(control->name());\n    node->set_input(pos, AsControlDependency(control->name()));\n    fanouts()[{control, Graph::kControlSlot}].insert(input_port);\n    ++pos;\n  }\n\n  \/\/ Shift existing controlling fanins and dedup.\n  for (int i = num_regular_fanins; i < node->input_size(); ++i) {\n    TensorId tensor_id = ParseTensorName(node->input(i));\n    if (controls.contains(tensor_id.node())) {\n      continue;\n    }\n    controls.insert(tensor_id.node());\n    node->mutable_input()->SwapElements(pos, i);\n    ++pos;\n  }\n\n  \/\/ Remove duplicate controls and leftover regular fanins.\n  node->mutable_input()->DeleteSubrange(pos, node->input_size() - pos);\n  max_regular_input_port().erase(node);\n\n  return Status::OK();\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":198452,"func":"void ComparisonQuantized(const TfLiteTensor* input1, const TfLiteTensor* input2,\n                         TfLiteTensor* output, bool requires_broadcast) {\n  if (input1->type == kTfLiteUInt8 || input1->type == kTfLiteInt8) {\n    auto input1_offset = -input1->params.zero_point;\n    auto input2_offset = -input2->params.zero_point;\n    const int left_shift = 8;\n\n    int32 input1_multiplier;\n    int input1_shift;\n    QuantizeMultiplierSmallerThanOneExp(input1->params.scale,\n                                        &input1_multiplier, &input1_shift);\n    int32 input2_multiplier;\n    int input2_shift;\n    QuantizeMultiplierSmallerThanOneExp(input2->params.scale,\n                                        &input2_multiplier, &input2_shift);\n\n    ComparisonParams op_params;\n    op_params.left_shift = left_shift;\n    op_params.input1_offset = input1_offset;\n    op_params.input1_multiplier = input1_multiplier;\n    op_params.input1_shift = input1_shift;\n    op_params.input2_offset = input2_offset;\n    op_params.input2_multiplier = input2_multiplier;\n    op_params.input2_shift = input2_shift;\n    if (requires_broadcast) {\n      reference_ops::BroadcastComparison4DSlowWithScaling<input_dtype, opname>(\n          op_params, GetTensorShape(input1), GetTensorData<input_dtype>(input1),\n          GetTensorShape(input2), GetTensorData<input_dtype>(input2),\n          GetTensorShape(output), GetTensorData<bool>(output));\n    } else {\n      reference_ops::ComparisonWithScaling<input_dtype, opname>(\n          op_params, GetTensorShape(input1), GetTensorData<input_dtype>(input1),\n          GetTensorShape(input2), GetTensorData<input_dtype>(input2),\n          GetTensorShape(output), GetTensorData<bool>(output));\n    }\n  }\n}","target":1,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":254728,"func":"njs_typed_array_prototype_reverse(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    double              *f64;\n    uint8_t             *u8;\n    int64_t             i, length;\n    uint16_t            *u16;\n    uint32_t            *u32;\n    njs_value_t         *this;\n    njs_typed_array_t   *array;\n    njs_array_buffer_t  *buffer;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_typed_array(this))) {\n        njs_type_error(vm, \"this is not a typed array\");\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(this);\n    length = njs_typed_array_length(array);\n\n    buffer = njs_typed_array_writable(vm, array);\n    if (njs_slow_path(buffer == NULL)) {\n        return NJS_ERROR;\n    }\n\n    switch (array->type) {\n    case NJS_OBJ_TYPE_UINT8_ARRAY:\n    case NJS_OBJ_TYPE_UINT8_CLAMPED_ARRAY:\n    case NJS_OBJ_TYPE_INT8_ARRAY:\n        u8 = &buffer->u.u8[array->offset];\n\n        for (i = 0; i < length \/ 2; i++) {\n            njs_swap_u8(&u8[i], &u8[length - i - 1], 0);\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_INT16_ARRAY:\n    case NJS_OBJ_TYPE_UINT16_ARRAY:\n        u16 = &buffer->u.u16[array->offset];\n\n        for (i = 0; i < length \/ 2; i++) {\n            njs_swap_u16(&u16[i], &u16[length - i - 1], 0);\n        }\n\n        break;\n\n    case NJS_OBJ_TYPE_INT32_ARRAY:\n    case NJS_OBJ_TYPE_UINT32_ARRAY:\n    case NJS_OBJ_TYPE_FLOAT32_ARRAY:\n        u32 = &buffer->u.u32[array->offset];\n\n        for (i = 0; i < length \/ 2; i++) {\n            njs_swap_u32(&u32[i], &u32[length - i - 1], 0);\n        }\n\n        break;\n\n    default:\n\n        \/* NJS_OBJ_TYPE_FLOAT64_ARRAY. *\/\n\n        f64 = &buffer->u.f64[array->offset];\n\n        for (i = 0; i < length \/ 2; i++) {\n            njs_swap_u64(&f64[i], &f64[length - i - 1], 0);\n        }\n    }\n\n    njs_set_typed_array(&vm->retval, array);\n\n    return NJS_OK;\n}","target":0,"code_token_length":610,"total_token_length":846,"max_tokens_setting":1024}
+{"idx":220452,"func":"  static bool Run(OpKernelContext* ctx, const Tensor& input,\n                  const Tensor& filter, int batch, int input_rows,\n                  int input_cols, int in_depth, int filter_rows,\n                  int filter_cols, int pad_rows, int pad_cols, int out_rows,\n                  int out_cols, int out_depth, int dilation_rows,\n                  int dilation_cols, int stride_rows, int stride_cols,\n                  Tensor* output, TensorFormat data_format) {\n    if (data_format != FORMAT_NHWC || dilation_rows != 1 ||\n        dilation_cols != 1 ||\n        !CanUseDeepConv2D(stride_rows, stride_cols, filter_rows, filter_cols,\n                          in_depth, out_depth, out_rows, out_cols)) {\n      return false;\n    }\n\n    Conv2DArgs args;\n    args.batch = batch;\n    args.in_rows = input_rows;\n    args.in_cols = input_cols;\n    args.in_depth = in_depth;\n    args.filter_rows = filter_rows;\n    args.filter_cols = filter_cols;\n    args.pad_rows = pad_rows;\n    args.pad_cols = pad_cols;\n    args.out_rows = out_rows;\n    args.out_cols = out_cols;\n    args.out_depth = out_depth;\n\n    auto input_ptr = input.template flat<float>().data();\n    auto filter_ptr = filter.template flat<float>().data();\n    auto output_ptr = output->template flat<float>().data();\n\n    functor::DeepConv2D<CPUDevice, float>()(ctx, args, input_ptr, filter_ptr,\n                                            output_ptr);\n    return true;\n  }","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":455177,"func":"MOBI_RET mobi_parse_huffdic(const MOBIData *m, MOBIHuffCdic *huffcdic) {\n    MOBI_RET ret;\n    const size_t offset = mobi_get_kf8offset(m);\n    if (m->mh == NULL || m->mh->huff_rec_index == NULL || m->mh->huff_rec_count == NULL) {\n        debug_print(\"%s\", \"HUFF\/CDIC records metadata not found in MOBI header\\n\");\n        return MOBI_DATA_CORRUPT;\n    }\n    const size_t huff_rec_index = *m->mh->huff_rec_index + offset;\n    const size_t huff_rec_count = *m->mh->huff_rec_count;\n    if (huff_rec_count > HUFF_RECORD_MAXCNT) {\n        debug_print(\"Too many HUFF record (%zu)\\n\", huff_rec_count);\n        return MOBI_DATA_CORRUPT;\n    }\n    const MOBIPdbRecord *curr = mobi_get_record_by_seqnumber(m, huff_rec_index);\n    if (curr == NULL || huff_rec_count < 2) {\n        debug_print(\"%s\", \"HUFF\/CDIC record not found\\n\");\n        return MOBI_DATA_CORRUPT;\n    }\n    if (curr->size < HUFF_RECORD_MINSIZE) {\n        debug_print(\"HUFF record too short (%zu b)\\n\", curr->size);\n        return MOBI_DATA_CORRUPT;\n    }\n    ret = mobi_parse_huff(huffcdic, curr);\n    if (ret != MOBI_SUCCESS) {\n        debug_print(\"%s\", \"HUFF parsing failed\\n\");\n        return ret;\n    }\n    curr = curr->next;\n    \/* allocate memory for symbols data in each CDIC record *\/\n    huffcdic->symbols = malloc((huff_rec_count - 1) * sizeof(*huffcdic->symbols));\n    if (huffcdic->symbols == NULL) {\n        debug_print(\"%s\\n\", \"Memory allocation failed\");\n        return MOBI_MALLOC_FAILED;\n    }\n    \/* get following CDIC records *\/\n    size_t i = 0;\n    while (i < huff_rec_count - 1) {\n        if (curr == NULL) {\n            debug_print(\"%s\\n\", \"CDIC record not found\");\n            return MOBI_DATA_CORRUPT;\n        }\n        ret = mobi_parse_cdic(huffcdic, curr, i++);\n        if (ret != MOBI_SUCCESS) {\n            debug_print(\"%s\", \"CDIC parsing failed\\n\");\n            return ret;\n        }\n        curr = curr->next;\n    }\n    if (huffcdic->index_count != huffcdic->index_read) {\n        debug_print(\"CDIC: wrong read index count: %zu, total: %zu\\n\", huffcdic->index_read, huffcdic->index_count);\n        return MOBI_DATA_CORRUPT;\n    }\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":632,"total_token_length":868,"max_tokens_setting":1024}
+{"idx":262021,"func":"ServiceProtoHandleSessionRequest(ServiceConnection *conn,\n                                 ProtoRequest *req)\n{\n   VGAuthError err;\n   gchar *packet;\n   gchar *pipeName = NULL;\n\n   \/*\n    * Do any argument checking.  For now, the version number must\n    * match.\n    *\/\n\n   if (req->reqData.sessionReq.version != atoi(VGAUTH_PROTOCOL_VERSION)) {\n      err = VGAUTH_E_VERSION_MISMATCH;\n      Warning(\"%s: version mismatch.  Client is %d, want %d\\n\",\n              __FUNCTION__, req->reqData.sessionReq.version,\n              atoi(VGAUTH_PROTOCOL_VERSION));\n      packet = Proto_MakeErrorReply(conn, req, err,\n                                    \"sessionRequest failed; version mismatch\");\n      goto send_err;\n   }\n\n   err = ServiceStartUserConnection(req->reqData.sessionReq.userName,\n                                    &pipeName);\n   if (err != VGAUTH_E_OK) {\n      packet = Proto_MakeErrorReply(conn, req, err, \"sessionRequest failed\");\n   } else {\n      packet = g_markup_printf_escaped(VGAUTH_SESSION_REPLY_FORMAT,\n                                       req->sequenceNumber,\n                                       pipeName);\n   }\n\nsend_err:\n   err = ServiceNetworkWriteData(conn, strlen(packet), packet);\n   if (err != VGAUTH_E_OK) {\n      Warning(\"%s: failed to send SessionReq reply\\n\", __FUNCTION__);\n   }\n\n   g_free(pipeName);\n   g_free(packet);\n\n   return err;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":498084,"func":"void cgit_diff_link(const char *name, const char *title, const char *class,\n\t\t    const char *head, const char *new_rev, const char *old_rev,\n\t\t    const char *path)\n{\n\tchar *delim;\n\n\tdelim = repolink(title, class, \"diff\", head, path);\n\tif (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {\n\t\thtml(delim);\n\t\thtml(\"id=\");\n\t\thtml_url_arg(new_rev);\n\t\tdelim = \"&\";\n\t}\n\tif (old_rev) {\n\t\thtml(delim);\n\t\thtml(\"id2=\");\n\t\thtml_url_arg(old_rev);\n\t\tdelim = \"&\";\n\t}\n\tif (ctx.qry.difftype) {\n\t\thtml(delim);\n\t\thtmlf(\"dt=%d\", ctx.qry.difftype);\n\t\tdelim = \"&\";\n\t}\n\tif (ctx.qry.context > 0 && ctx.qry.context != 3) {\n\t\thtml(delim);\n\t\thtml(\"context=\");\n\t\thtmlf(\"%d\", ctx.qry.context);\n\t\tdelim = \"&\";\n\t}\n\tif (ctx.qry.ignorews) {\n\t\thtml(delim);\n\t\thtml(\"ignorews=1\");\n\t\tdelim = \"&\";\n\t}\n\tif (ctx.qry.follow) {\n\t\thtml(delim);\n\t\thtml(\"follow=1\");\n\t}\n\thtml(\"'>\");\n\thtml_txt(name);\n\thtml(\"<\/a>\");\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":430399,"func":"static bool actions_may_change_flow(const struct nlattr *actions)\n{\n\tstruct nlattr *nla;\n\tint rem;\n\n\tnla_for_each_nested(nla, actions, rem) {\n\t\tu16 action = nla_type(nla);\n\n\t\tswitch (action) {\n\t\tcase OVS_ACTION_ATTR_OUTPUT:\n\t\tcase OVS_ACTION_ATTR_RECIRC:\n\t\tcase OVS_ACTION_ATTR_TRUNC:\n\t\tcase OVS_ACTION_ATTR_USERSPACE:\n\t\t\tbreak;\n\n\t\tcase OVS_ACTION_ATTR_CT:\n\t\tcase OVS_ACTION_ATTR_CT_CLEAR:\n\t\tcase OVS_ACTION_ATTR_HASH:\n\t\tcase OVS_ACTION_ATTR_POP_ETH:\n\t\tcase OVS_ACTION_ATTR_POP_MPLS:\n\t\tcase OVS_ACTION_ATTR_POP_NSH:\n\t\tcase OVS_ACTION_ATTR_POP_VLAN:\n\t\tcase OVS_ACTION_ATTR_PUSH_ETH:\n\t\tcase OVS_ACTION_ATTR_PUSH_MPLS:\n\t\tcase OVS_ACTION_ATTR_PUSH_NSH:\n\t\tcase OVS_ACTION_ATTR_PUSH_VLAN:\n\t\tcase OVS_ACTION_ATTR_SAMPLE:\n\t\tcase OVS_ACTION_ATTR_SET:\n\t\tcase OVS_ACTION_ATTR_SET_MASKED:\n\t\tcase OVS_ACTION_ATTR_METER:\n\t\tcase OVS_ACTION_ATTR_CHECK_PKT_LEN:\n\t\tcase OVS_ACTION_ATTR_ADD_MPLS:\n\t\tcase OVS_ACTION_ATTR_DEC_TTL:\n\t\tdefault:\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":498628,"func":"query (void)\n{\n  static const GimpParamDef load_args[] =\n  {\n    { GIMP_PDB_INT32,  \"run-mode\",     \"The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }\" },\n    { GIMP_PDB_STRING, \"filename\",     \"The name of the file to load\" },\n    { GIMP_PDB_STRING, \"raw-filename\", \"The name entered\"             }\n  };\n\n  static const GimpParamDef load_return_vals[] =\n  {\n    { GIMP_PDB_IMAGE, \"image\", \"Output image\" }\n  };\n\n  static const GimpParamDef save_args[] =\n  {\n    { GIMP_PDB_INT32,    \"run-mode\",     \"The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }\" },\n    { GIMP_PDB_IMAGE,    \"image\",        \"Input image\"                  },\n    { GIMP_PDB_DRAWABLE, \"drawable\",     \"Drawable to export\"           },\n    { GIMP_PDB_STRING,   \"filename\",     \"The name of the file to export the image in\" },\n    { GIMP_PDB_STRING,   \"raw-filename\", \"The name of the file to export the image in\" },\n    { GIMP_PDB_INT32,    \"rle\",          \"Use RLE compression\"          },\n    { GIMP_PDB_INT32,    \"origin\",       \"Image origin (0 = top-left, 1 = bottom-left)\"}\n  } ;\n\n  gimp_install_procedure (LOAD_PROC,\n                          \"Loads files of Targa file format\",\n                          \"FIXME: write help for tga_load\",\n                          \"Raphael FRANCOIS, Gordon Matzigkeit\",\n                          \"Raphael FRANCOIS, Gordon Matzigkeit\",\n                          \"1997,2000,2007\",\n                          N_(\"TarGA image\"),\n                          NULL,\n                          GIMP_PLUGIN,\n                          G_N_ELEMENTS (load_args),\n                          G_N_ELEMENTS (load_return_vals),\n                          load_args, load_return_vals);\n\n  gimp_register_file_handler_mime (LOAD_PROC, \"image\/x-tga\");\n  gimp_register_magic_load_handler (LOAD_PROC,\n                                    \"tga,vda,icb,vst\",\n                                    \"\",\n                                    \"-18&,string,TRUEVISION-XFILE.,-1,byte,0\");\n\n  gimp_install_procedure (SAVE_PROC,\n                          \"exports files in the Targa file format\",\n                          \"FIXME: write help for tga_save\",\n                          \"Raphael FRANCOIS, Gordon Matzigkeit\",\n                          \"Raphael FRANCOIS, Gordon Matzigkeit\",\n                          \"1997,2000\",\n                          N_(\"TarGA image\"),\n                          \"RGB*, GRAY*, INDEXED*\",\n                          GIMP_PLUGIN,\n                          G_N_ELEMENTS (save_args), 0,\n                          save_args, NULL);\n\n  gimp_register_file_handler_mime (SAVE_PROC, \"image\/x-tga\");\n  gimp_register_save_handler (SAVE_PROC, \"tga\", \"\");\n}","target":0,"code_token_length":657,"total_token_length":893,"max_tokens_setting":1024}
+{"idx":221179,"func":"GF_Err gf_odf_get_laser_config(GF_DefaultDescriptor *dsi, GF_LASERConfig *cfg)\n{\n\tu32 to_skip;\n\tGF_BitStream *bs;\n\n\tif (!cfg) return GF_BAD_PARAM;\n\tmemset(cfg, 0, sizeof(GF_LASERConfig));\n\n\tif (!dsi || !dsi->data || !dsi->dataLength) return GF_BAD_PARAM;\n\tbs = gf_bs_new(dsi->data, dsi->dataLength, GF_BITSTREAM_READ);\n\tmemset(cfg, 0, sizeof(GF_LASERConfig));\n\tcfg->tag = GF_ODF_LASER_CFG_TAG;\n\tcfg->profile = gf_bs_read_int(bs, 8);\n\tcfg->level = gf_bs_read_int(bs, 8);\n\t\/*cfg->reserved = *\/gf_bs_read_int(bs, 3);\n\tcfg->pointsCodec = gf_bs_read_int(bs, 2);\n\tcfg->pathComponents = gf_bs_read_int(bs, 4);\n\tcfg->fullRequestHost = gf_bs_read_int(bs, 1);\n\tif (gf_bs_read_int(bs, 1)) cfg->time_resolution = gf_bs_read_int(bs, 16);\n\telse cfg->time_resolution = 1000;\n\tcfg->colorComponentBits = 1 + gf_bs_read_int(bs, 4);\n\tcfg->resolution = gf_bs_read_int(bs, 4);\n\tif (cfg->resolution>7) cfg->resolution -= 16;\n\tcfg->coord_bits = gf_bs_read_int(bs, 5);\n\tcfg->scale_bits_minus_coord_bits = gf_bs_read_int(bs, 4);\n\tcfg->newSceneIndicator = gf_bs_read_int(bs, 1);\n\t\/*reserved2*\/ gf_bs_read_int(bs, 3);\n\tcfg->extensionIDBits = gf_bs_read_int(bs, 4);\n\t\/*hasExtConfig - we just ignore it*\/\n\tif (gf_bs_read_int(bs, 1)) {\n\t\tto_skip = gf_bs_read_vluimsbf5(bs);\n\t\twhile (to_skip) {\n\t\t\tgf_bs_read_int(bs, 8);\n\t\t\tto_skip--;\n\t\t}\n\t}\n\t\/*hasExtension - we just ignore it*\/\n\tif (gf_bs_read_int(bs, 1)) {\n\t\tto_skip = gf_bs_read_vluimsbf5(bs);\n\t\twhile (to_skip) {\n\t\t\tgf_bs_read_int(bs, 8);\n\t\t\tto_skip--;\n\t\t}\n\t}\n\tgf_bs_del(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":199841,"func":"static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadaddr, Sdb *sdb) {\n\tRBuffer *fbuf = r_buf_ref (buf);\n\tstruct MACH0_(opts_t) opts;\n\tMACH0_(opts_set_default) (&opts, bf);\n\tstruct MACH0_(obj_t) *main_mach0 = MACH0_(new_buf) (fbuf, &opts);\n\tif (!main_mach0) {\n\t\treturn false;\n\t}\n\n\tRRebaseInfo *rebase_info = r_rebase_info_new_from_mach0 (fbuf, main_mach0);\n\tRKernelCacheObj *obj = NULL;\n\n\tRPrelinkRange *prelink_range = get_prelink_info_range_from_mach0 (main_mach0);\n\tif (!prelink_range) {\n\t\tgoto beach;\n\t}\n\n\tobj = R_NEW0 (RKernelCacheObj);\n\tif (!obj) {\n\t\tR_FREE (prelink_range);\n\t\tgoto beach;\n\t}\n\n\tRCFValueDict *prelink_info = NULL;\n\tif (main_mach0->hdr.filetype != MH_FILESET && prelink_range->range.size) {\n\t\tprelink_info = r_cf_value_dict_parse (fbuf, prelink_range->range.offset,\n\t\t\t\tprelink_range->range.size, R_CF_OPTION_SKIP_NSDATA);\n\t\tif (!prelink_info) {\n\t\t\tR_FREE (prelink_range);\n\t\t\tR_FREE (obj);\n\t\t\tgoto beach;\n\t\t}\n\t}\n\n\tif (!pending_bin_files) {\n\t\tpending_bin_files = r_list_new ();\n\t\tif (!pending_bin_files) {\n\t\t\tR_FREE (prelink_range);\n\t\t\tR_FREE (obj);\n\t\t\tR_FREE (prelink_info);\n\t\t\tgoto beach;\n\t\t}\n\t}\n\n\tobj->mach0 = main_mach0;\n\tobj->rebase_info = rebase_info;\n\tobj->prelink_info = prelink_info;\n\tobj->cache_buf = fbuf;\n\tobj->pa2va_exec = prelink_range->pa2va_exec;\n\tobj->pa2va_data = prelink_range->pa2va_data;\n\n\tR_FREE (prelink_range);\n\n\t*bin_obj = obj;\n\n\tr_list_push (pending_bin_files, bf);\n\n\tif (rebase_info || main_mach0->chained_starts) {\n\t\tRIO *io = bf->rbin->iob.io;\n\t\tswizzle_io_read (obj, io);\n\t}\n\n\treturn true;\n\nbeach:\n\tr_buf_free (fbuf);\n\tobj->cache_buf = NULL;\n\tMACH0_(mach0_free) (main_mach0);\n\treturn false;\n}","target":1,"code_token_length":547,"total_token_length":783,"max_tokens_setting":1024}
+{"idx":218785,"func":"static MagickBooleanType ReadPSDChannelPixels(Image *image,\n  const size_t channels,const ssize_t row,const ssize_t type,\n  const unsigned char *pixels,ExceptionInfo *exception)\n{\n  Quantum\n    pixel;\n\n  const unsigned char\n    *p;\n\n  IndexPacket\n    *indexes;\n\n  PixelPacket\n    *q;\n\n  ssize_t\n    x;\n\n  size_t\n    packet_size;\n\n  unsigned short\n    nibble;\n\n  p=pixels;\n  q=GetAuthenticPixels(image,0,row,image->columns,1,exception);\n  if (q == (PixelPacket *) NULL)\n    return MagickFalse;\n  indexes=GetAuthenticIndexQueue(image);\n  packet_size=GetPSDPacketSize(image);\n  for (x=0; x < (ssize_t) image->columns; x++)\n  {\n    if (packet_size == 1)\n      pixel=ScaleCharToQuantum(*p++);\n    else\n      if (packet_size == 2)\n        {\n          p=PushShortPixel(MSBEndian,p,&nibble);\n          pixel=ScaleShortToQuantum(nibble);\n        }\n      else\n        {\n          MagickFloatType\n            nibble;\n\n          p=PushFloatPixel(MSBEndian,p,&nibble);\n          pixel=ClampToQuantum((MagickRealType)QuantumRange*nibble);\n        }\n    if (image->depth > 1)\n      {\n        SetPSDPixel(image,channels,type,packet_size,pixel,q,indexes,x);\n        q++;\n      }\n    else\n      {\n        ssize_t\n          bit,\n          number_bits;\n\n        number_bits=(ssize_t) image->columns-x;\n        if (number_bits > 8)\n          number_bits=8;\n        for (bit=0; bit < number_bits; bit++)\n        {\n          SetPSDPixel(image,channels,type,packet_size,\n            (((unsigned char) ((ssize_t) pixel)) & (0x01 << (7-bit))) != 0 ? 0 :\n            QuantumRange,q++,indexes,x++);\n        }\n        if (x != (ssize_t) image->columns)\n          x--;\n        continue;\n      }\n  }\n  return(SyncAuthenticPixels(image,exception));\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":450820,"func":"prefix_array (const char *dirname, char **array, size_t n)\n{\n  size_t i;\n  size_t dirlen = strlen (dirname);\n  char dirsep_char = '\/';\n\n  if (dirlen == 1 && dirname[0] == '\/')\n    \/* DIRNAME is just \"\/\", so normal prepending would get us \"\/\/foo\".\n       We want \"\/foo\" instead, so don't prepend any chars from DIRNAME.  *\/\n    dirlen = 0;\n\n#if defined __MSDOS__ || defined WINDOWS32\n  if (dirlen > 1)\n    {\n      if (dirname[dirlen - 1] == '\/' && dirname[dirlen - 2] == ':')\n        \/* DIRNAME is \"d:\/\".  Don't prepend the slash from DIRNAME.  *\/\n        --dirlen;\n      else if (dirname[dirlen - 1] == ':')\n        {\n          \/* DIRNAME is \"d:\".  Use ':' instead of '\/'.  *\/\n          --dirlen;\n          dirsep_char = ':';\n        }\n    }\n#endif\n\n  for (i = 0; i < n; ++i)\n    {\n      size_t eltlen = strlen (array[i]) + 1;\n      char *new = malloc (dirlen + 1 + eltlen);\n      if (new == NULL)\n        {\n          while (i > 0)\n            free (array[--i]);\n          return 1;\n        }\n\n      {\n        char *endp = mempcpy (new, dirname, dirlen);\n        *endp++ = dirsep_char;\n        mempcpy (endp, array[i], eltlen);\n      }\n      free (array[i]);\n      array[i] = new;\n    }\n\n  return 0;\n}","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":248751,"func":"static int cookie_sort(const void *p1, const void *p2)\n{\n  struct Cookie *c1 = *(struct Cookie **)p1;\n  struct Cookie *c2 = *(struct Cookie **)p2;\n  size_t l1, l2;\n\n  \/* 1 - compare cookie path lengths *\/\n  l1 = c1->path ? strlen(c1->path) : 0;\n  l2 = c2->path ? strlen(c2->path) : 0;\n\n  if(l1 != l2)\n    return (l2 > l1) ? 1 : -1 ; \/* avoid size_t <=> int conversions *\/\n\n  \/* 2 - compare cookie domain lengths *\/\n  l1 = c1->domain ? strlen(c1->domain) : 0;\n  l2 = c2->domain ? strlen(c2->domain) : 0;\n\n  if(l1 != l2)\n    return (l2 > l1) ? 1 : -1 ;  \/* avoid size_t <=> int conversions *\/\n\n  \/* 3 - compare cookie name lengths *\/\n  l1 = c1->name ? strlen(c1->name) : 0;\n  l2 = c2->name ? strlen(c2->name) : 0;\n\n  if(l1 != l2)\n    return (l2 > l1) ? 1 : -1;\n\n  \/* 4 - compare cookie creation time *\/\n  return (c2->creationtime > c1->creationtime) ? 1 : -1;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":476094,"func":"static int config_buf(struct usb_configuration *config,\n\t\tenum usb_device_speed speed, void *buf, u8 type)\n{\n\tstruct usb_config_descriptor\t*c = buf;\n\tvoid\t\t\t\t*next = buf + USB_DT_CONFIG_SIZE;\n\tint\t\t\t\tlen;\n\tstruct usb_function\t\t*f;\n\tint\t\t\t\tstatus;\n\n\tlen = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE;\n\t\/* write the config descriptor *\/\n\tc = buf;\n\tc->bLength = USB_DT_CONFIG_SIZE;\n\tc->bDescriptorType = type;\n\t\/* wTotalLength is written later *\/\n\tc->bNumInterfaces = config->next_interface_id;\n\tc->bConfigurationValue = config->bConfigurationValue;\n\tc->iConfiguration = config->iConfiguration;\n\tc->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;\n\tc->bMaxPower = encode_bMaxPower(speed, config);\n\n\t\/* There may be e.g. OTG descriptors *\/\n\tif (config->descriptors) {\n\t\tstatus = usb_descriptor_fillbuf(next, len,\n\t\t\t\tconfig->descriptors);\n\t\tif (status < 0)\n\t\t\treturn status;\n\t\tlen -= status;\n\t\tnext += status;\n\t}\n\n\t\/* add each function's descriptors *\/\n\tlist_for_each_entry(f, &config->functions, list) {\n\t\tstruct usb_descriptor_header **descriptors;\n\n\t\tdescriptors = function_descriptors(f, speed);\n\t\tif (!descriptors)\n\t\t\tcontinue;\n\t\tstatus = usb_descriptor_fillbuf(next, len,\n\t\t\t(const struct usb_descriptor_header **) descriptors);\n\t\tif (status < 0)\n\t\t\treturn status;\n\t\tlen -= status;\n\t\tnext += status;\n\t}\n\n\tlen = next - buf;\n\tc->wTotalLength = cpu_to_le16(len);\n\treturn len;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":281664,"func":"void CLASS parse_riff()\n{\n  unsigned i, size, end;\n  char tag[4], date[64], month[64];\n  static const char mon[12][4] =\n  { \"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\" };\n  struct tm t;\n\n  order = 0x4949;\n  fread (tag, 4, 1, ifp);\n  size = get4();\n#ifdef LIBRAW_LIBRARY_BUILD\n  if((int)size<0) \n    throw LIBRAW_EXCEPTION_IO_EOF;\n#endif\n  end = ftell(ifp) + size;\n  if (!memcmp(tag,\"RIFF\",4) || !memcmp(tag,\"LIST\",4)) {\n    get4();\n    while (ftell(ifp)+7 < end)\n      parse_riff();\n  } else if (!memcmp(tag,\"nctg\",4)) {\n    while (ftell(ifp)+7 < end) {\n      i = get2();\n      size = get2();\n      if ((i+1) >> 1 == 10 && size == 20)\n\tget_timestamp(0);\n      else fseek (ifp, size, SEEK_CUR);\n    }\n  } else if (!memcmp(tag,\"IDIT\",4) && size < 64) {\n    fread (date, 64, 1, ifp);\n    date[size] = 0;\n    memset (&t, 0, sizeof t);\n    if (sscanf (date, \"%*s %s %d %d:%d:%d %d\", month, &t.tm_mday,\n\t&t.tm_hour, &t.tm_min, &t.tm_sec, &t.tm_year) == 6) {\n      for (i=0; i < 12 && strcasecmp(mon[i],month); i++);\n      t.tm_mon = i;\n      t.tm_year -= 1900;\n      if (mktime(&t) > 0)\n\ttimestamp = mktime(&t);\n    }\n  } else\n    fseek (ifp, size, SEEK_CUR);\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":139244,"func":"void OverlayWindowViews::SetUpViews() {\n  gfx::Rect larger_window_bounds = GetBounds();\n  larger_window_bounds.Inset(-1, -1);\n  window_background_view_->SetSize(larger_window_bounds.size());\n  window_background_view_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);\n  GetWindowBackgroundLayer()->SetColor(SK_ColorBLACK);\n\n  controls_scrim_view_->SetSize(GetBounds().size());\n  controls_scrim_view_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);\n  GetControlsScrimLayer()->SetColor(gfx::kGoogleGrey900);\n  GetControlsScrimLayer()->SetOpacity(0.43f);\n\n  controls_parent_view_->SetPaintToLayer(ui::LAYER_TEXTURED);\n  controls_parent_view_->SetSize(GetBounds().size());\n  controls_parent_view_->layer()->SetFillsBoundsOpaquely(false);\n  controls_parent_view_->set_owned_by_client();\n\n  close_controls_view_->SetPaintToLayer(ui::LAYER_TEXTURED);\n  close_controls_view_->layer()->SetFillsBoundsOpaquely(false);\n  close_controls_view_->set_owned_by_client();\n\n  video_view_->SetPaintToLayer(ui::LAYER_TEXTURED);\n\n  play_pause_controls_view_->SetImageAlignment(\n      views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE);\n  play_pause_controls_view_->SetToggled(controller_->IsPlayerActive());\n  play_pause_controls_view_->set_owned_by_client();\n\n#if defined(OS_CHROMEOS)\n  resize_handle_view_->SetPaintToLayer(ui::LAYER_TEXTURED);\n  resize_handle_view_->layer()->SetFillsBoundsOpaquely(false);\n  resize_handle_view_->set_owned_by_client();\n#endif\n\n  play_pause_controls_view_->SetFocusForPlatform();  \/\/ Make button focusable.\n  const base::string16 play_pause_accessible_button_label(\n      l10n_util::GetStringUTF16(\n          IDS_PICTURE_IN_PICTURE_PLAY_PAUSE_CONTROL_ACCESSIBLE_TEXT));\n  play_pause_controls_view_->SetAccessibleName(\n      play_pause_accessible_button_label);\n  const base::string16 play_button_label(\n      l10n_util::GetStringUTF16(IDS_PICTURE_IN_PICTURE_PLAY_CONTROL_TEXT));\n  play_pause_controls_view_->SetTooltipText(play_button_label);\n  const base::string16 pause_button_label(\n      l10n_util::GetStringUTF16(IDS_PICTURE_IN_PICTURE_PAUSE_CONTROL_TEXT));\n  play_pause_controls_view_->SetToggledTooltipText(pause_button_label);\n  play_pause_controls_view_->SetInstallFocusRingOnFocus(true);\n\n  controls_parent_view_->AddChildView(play_pause_controls_view_.get());\n  GetContentsView()->AddChildView(controls_scrim_view_.get());\n  GetContentsView()->AddChildView(controls_parent_view_.get());\n  GetContentsView()->AddChildView(close_controls_view_.get());\n#if defined(OS_CHROMEOS)\n  GetContentsView()->AddChildView(resize_handle_view_.get());\n#endif\n\n  UpdatePlayPauseControlsSize();\n  UpdateControlsVisibility(false);\n}\n","target":0,"code_token_length":629,"total_token_length":865,"max_tokens_setting":1024}
+{"idx":225496,"func":"Status MutableGraphView::AddControllingFanin(absl::string_view node_name,\n                                             const TensorId& fanin) {\n  auto error_status = [node_name, fanin](absl::string_view msg) {\n    string params = absl::Substitute(\"node_name='$0', fanin='$1'\", node_name,\n                                     fanin.ToString());\n    return MutationError(\"AddControllingFanin\", params, msg);\n  };\n\n  TF_RETURN_IF_ERROR(CheckFaninIsValid(fanin, error_status));\n  TF_RETURN_IF_ERROR(CheckAddingFaninToSelf(node_name, fanin, error_status));\n  NodeDef* node = GetNode(node_name);\n  TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));\n  NodeDef* fanin_node = GetNode(fanin.node());\n  TF_RETURN_IF_ERROR(CheckNodeExists(fanin.node(), fanin_node, error_status));\n\n  OutputPort fanin_port(fanin_node, fanin.index());\n\n  string error_msg = \"\";\n  NodeDef* control_node = GetControllingFaninToAdd(\n      node_name, {fanin_node, fanin.index()}, &error_msg);\n  if (!error_msg.empty()) {\n    return error_status(error_msg);\n  }\n  if (control_node == nullptr) {\n    control_node = GetOrCreateIdentityConsumingSwitch(fanin_port);\n  }\n  AddFaninInternal(node, {control_node, Graph::kControlSlot});\n\n  return Status::OK();\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":216945,"func":"bool Item_equal::create_pushable_equalities(THD *thd,\n                                            List<Item> *equalities,\n                                            Pushdown_checker checker,\n                                            uchar *arg,\n                                            bool clone_const)\n{\n  Item *item;\n  Item *left_item= NULL;\n  Item *right_item = get_const();\n  Item_equal_fields_iterator it(*this);\n\n  while ((item=it++))\n  {\n    left_item= item;\n    if (checker && !((item->*checker) (arg)))\n      continue;\n    break;\n  }\n\n  if (!left_item)\n    return false;\n\n  if (right_item)\n  {\n    Item_func_eq *eq= 0;\n    Item *left_item_clone= left_item->build_clone(thd);\n    Item *right_item_clone= !clone_const ?\n                            right_item : right_item->build_clone(thd);\n    if (!left_item_clone || !right_item_clone)\n      return true;\n    eq= new (thd->mem_root) Item_func_eq(thd,\n                                         left_item_clone,\n                                         right_item_clone);\n    if (!eq ||  equalities->push_back(eq, thd->mem_root))\n      return true;\n    if (!clone_const)\n      right_item->set_extraction_flag(IMMUTABLE_FL);\n  }\n\n  while ((item=it++))\n  {\n    if (checker && !((item->*checker) (arg)))\n      continue;\n    Item_func_eq *eq= 0;\n    Item *left_item_clone= left_item->build_clone(thd);\n    Item *right_item_clone= item->build_clone(thd);\n    if (!(left_item_clone && right_item_clone))\n      return true;\n    left_item_clone->set_item_equal(NULL);\n    right_item_clone->set_item_equal(NULL);\n    eq= new (thd->mem_root) Item_func_eq(thd,\n                                         right_item_clone,\n                                         left_item_clone);\n    if (!eq || equalities->push_back(eq, thd->mem_root))\n      return true;\n  }\n  return false;\n}","target":1,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":139210,"func":"gfx::Rect OverlayWindowViews::CalculateAndUpdateWindowBounds() {\n  gfx::Rect work_area =\n      display::Screen::GetScreen()\n          ->GetDisplayNearestWindow(\n              controller_->GetInitiatorWebContents()->GetTopLevelNativeWindow())\n          .work_area();\n\n  max_size_ = gfx::Size(work_area.width() \/ 2, work_area.height() \/ 2);\n\n  min_size_ = kMinWindowSize;\n\n  gfx::Size window_size = window_bounds_.size();\n  if (!has_been_shown_) {\n    window_size = gfx::Size(work_area.width() \/ 5, work_area.height() \/ 5);\n    window_size.set_width(std::min(\n        max_size_.width(), std::max(min_size_.width(), window_size.width())));\n    window_size.set_height(\n        std::min(max_size_.height(),\n                 std::max(min_size_.height(), window_size.height())));\n  }\n\n  if (!window_size.IsEmpty() && !natural_size_.IsEmpty()) {\n    float aspect_ratio = (float)natural_size_.width() \/ natural_size_.height();\n\n    gfx::Rect window_rect(GetBounds().origin(), window_size);\n    views::WindowResizeUtils::SizeRectToAspectRatio(\n        views::HitTest::kBottomRight, aspect_ratio, min_size_, max_size_,\n        &window_rect);\n    window_size.SetSize(window_rect.width(), window_rect.height());\n\n    UpdateLayerBoundsWithLetterboxing(window_size);\n  }\n\n  gfx::Point origin = window_bounds_.origin();\n\n  int window_diff_width = work_area.right() - window_size.width();\n  int window_diff_height = work_area.bottom() - window_size.height();\n\n  int buffer = (window_diff_width + window_diff_height) \/ 2 * 0.02;\n\n  gfx::Point default_origin =\n      gfx::Point(window_diff_width - buffer, window_diff_height - buffer);\n\n  if (has_been_shown_) {\n    origin.SetToMin(default_origin);\n  } else {\n    origin = default_origin;\n  }\n\n  window_bounds_ = gfx::Rect(origin, window_size);\n  return window_bounds_;\n}\n","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":293762,"func":"static void sections_from_mach0(RList *ret, struct MACH0_(obj_t) *mach0, RBinFile *bf, ut64 paddr, char *prefix, RKernelCacheObj *obj) {\n\tstruct section_t *sections = NULL;\n\tif (!(sections = MACH0_(get_sections) (mach0))) {\n\t\treturn;\n\t}\n\tint i;\n\tfor (i = 0; !sections[i].last; i++) {\n\t\tRBinSection *ptr;\n\t\tif (!(ptr = R_NEW0 (RBinSection))) {\n\t\t\tbreak;\n\t\t}\n\t\tif (prefix) {\n\t\t\tptr->name = r_str_newf (\"%s.%s\", prefix, (char*)sections[i].name);\n\t\t} else {\n\t\t\tptr->name = r_str_newf (\"%s\", (char*)sections[i].name);\n\t\t}\n\t\tif (strstr (ptr->name, \"la_symbol_ptr\")) {\n\t\t\tint len = sections[i].size \/ 8;\n\t\t\tptr->format = r_str_newf (\"Cd %d[%d]\", 8, len);\n\t\t}\n\t\thandle_data_sections (ptr);\n\t\tptr->size = sections[i].size;\n\t\tptr->vsize = sections[i].vsize;\n\t\tptr->paddr = sections[i].offset + bf->o->boffset + paddr;\n\t\tptr->vaddr = K_PPTR (sections[i].addr);\n\t\tif (!ptr->vaddr) {\n\t\t\tptr->vaddr = ptr->paddr;\n\t\t}\n\t\tptr->perm = sections[i].perm;\n\t\tif (!ptr->perm && strstr (sections[i].name, \"__TEXT_EXEC.__text\")) {\n\t\t\tptr->perm = 1 | 4;\n\t\t}\n\t\tr_list_append (ret, ptr);\n\t}\n\tfree (sections);\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":246457,"func":"static bool consume_encoded_name_new(RBuffer *b, ut64 bound, ut32 *len_out, char **str_out) {\n\tut32 len;\n\tchar *orig = NULL;\n\tif (!consume_str_new (b, bound, &len, &orig)) {\n\t\treturn false;\n\t}\n\n\t\/\/ room for even every character getting encoded\n\tsize_t maxsize = (len * 4) + 2;\n\tchar *sout = malloc (maxsize);\n\tif (!sout) {\n\t\tfree (orig);\n\t\treturn false;\n\t}\n\n\tsize_t i, oi = 0;\n\tfor (i = 0; i < len && oi + 6 < maxsize; i++) {\n\t\tif (WASM_IS_OK (orig, i, len)) {\n\t\t\tsout[oi++] = orig[i];\n\t\t} else {\n\t\t\tint res = snprintf (sout + oi, maxsize - oi, \"_%02x_\", orig[i]);\n\t\t\toi += res;\n\t\t}\n\t}\n\tif (oi >= maxsize) {\n\t\tsout[maxsize - 1] = '\\0';\n\t} else {\n\t\tsout[oi++] = '\\0';\n\t}\n\tfree (orig);\n\n\tchar *tmp = realloc (sout, oi);\n\tif (!tmp) {\n\t\tfree (sout);\n\t\tfree (tmp);\n\t\treturn false;\n\t}\n\t*str_out = tmp;\n\tif (len_out) {\n\t\t*len_out = len;\n\t}\n\treturn true;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":436084,"func":"\nstatic int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,\n\t\t       const struct io_uring_sqe *sqe)\n{\n\tstruct io_submit_state *state;\n\tunsigned int sqe_flags;\n\tint personality, ret = 0;\n\n\treq->opcode = READ_ONCE(sqe->opcode);\n\t\/* same numerical values with corresponding REQ_F_*, safe to copy *\/\n\treq->flags = sqe_flags = READ_ONCE(sqe->flags);\n\treq->user_data = READ_ONCE(sqe->user_data);\n\treq->file = NULL;\n\treq->fixed_rsrc_refs = NULL;\n\t\/* one is dropped after submission, the other at completion *\/\n\tatomic_set(&req->refs, 2);\n\treq->task = current;\n\n\t\/* enforce forwards compatibility on users *\/\n\tif (unlikely(sqe_flags & ~SQE_VALID_FLAGS))\n\t\treturn -EINVAL;\n\tif (unlikely(req->opcode >= IORING_OP_LAST))\n\t\treturn -EINVAL;\n\tif (!io_check_restriction(ctx, req, sqe_flags))\n\t\treturn -EACCES;\n\n\tif ((sqe_flags & IOSQE_BUFFER_SELECT) &&\n\t    !io_op_defs[req->opcode].buffer_select)\n\t\treturn -EOPNOTSUPP;\n\tif (unlikely(sqe_flags & IOSQE_IO_DRAIN))\n\t\tctx->drain_active = true;\n\n\tpersonality = READ_ONCE(sqe->personality);\n\tif (personality) {\n\t\treq->creds = xa_load(&ctx->personalities, personality);\n\t\tif (!req->creds)\n\t\t\treturn -EINVAL;\n\t\tget_cred(req->creds);\n\t\treq->flags |= REQ_F_CREDS;\n\t}\n\tstate = &ctx->submit_state;\n\n\t\/*\n\t * Plug now if we have more than 1 IO left after this, and the target\n\t * is potentially a read\/write to block based storage.\n\t *\/\n\tif (!state->plug_started && state->ios_left > 1 &&\n\t    io_op_defs[req->opcode].plug) {\n\t\tblk_start_plug(&state->plug);\n\t\tstate->plug_started = true;\n\t}\n\n\tif (io_op_defs[req->opcode].needs_file) {\n\t\tbool fixed = req->flags & REQ_F_FIXED_FILE;\n\n\t\treq->file = io_file_get(state, req, READ_ONCE(sqe->fd), fixed);\n\t\tif (unlikely(!req->file))\n\t\t\tret = -EBADF;\n\t}\n\n\tstate->ios_left--;\n\treturn ret;","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":246667,"func":"GF_Err afrt_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tunsigned int i;\n\tGF_AdobeFragmentRunTableBox *ptr = (GF_AdobeFragmentRunTableBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 5)\n\tptr->timescale = gf_bs_read_u32(bs);\n\n\tptr->quality_entry_count = gf_bs_read_u8(bs);\n\tif (ptr->size < ptr->quality_entry_count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tfor (i=0; i<ptr->quality_entry_count; i++) {\n\t\tint j=0;\n\t\tu32 tmp_strsize=(u32)ptr->size-8;\n\t\tchar *tmp_str = (char*) gf_malloc(tmp_strsize);\n\t\tif (!tmp_str) return GF_OUT_OF_MEM;\n\t\twhile (tmp_strsize) {\n\t\t\ttmp_str[j] = gf_bs_read_u8(bs);\n\t\t\ttmp_strsize--;\n\t\t\tif (!tmp_str[j])\n\t\t\t\tbreak;\n\t\t\tj++;\n\t\t}\n\t\tISOM_DECREASE_SIZE(ptr, j)\n\t\tgf_list_insert(ptr->quality_segment_url_modifiers, tmp_str, i);\n\t}\n\n\tptr->fragment_run_entry_count = gf_bs_read_u32(bs);\n\tif (ptr->size \/ 16 < ptr->fragment_run_entry_count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\tfor (i=0; i<ptr->fragment_run_entry_count; i++) {\n\t\tGF_AdobeFragmentRunEntry *fre = gf_malloc(sizeof(GF_AdobeFragmentRunEntry));\n\t\tif (!fre) return GF_OUT_OF_MEM;\n\t\tISOM_DECREASE_SIZE(ptr, 16)\n\t\tfre->first_fragment = gf_bs_read_u32(bs);\n\t\tfre->first_fragment_timestamp = gf_bs_read_u64(bs);\n\t\tfre->fragment_duration = gf_bs_read_u32(bs);\n\t\tif (!fre->fragment_duration) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 1)\n\t\t\tfre->discontinuity_indicator = gf_bs_read_u8(bs);\n\t\t}\n\t\tgf_list_insert(ptr->fragment_run_entry_table, fre, i);\n\t}\n\n\treturn GF_OK;\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":231735,"func":"TEST_F(QuicServerTransportTest, RecvPathChallenge) {\n  auto& conn = server->getNonConstConn();\n\n  \/\/ Add additional peer id so PathResponse completes.\n  conn.peerConnectionIds.emplace_back(ConnectionId({1, 2, 3, 4}), 1);\n\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero, *conn.serverConnectionId, 10);\n  RegularQuicPacketBuilder builder(\n      conn.udpSendPacketLen, std::move(header), 0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  PathChallengeFrame pathChallenge(123);\n  ASSERT_TRUE(builder.canBuildPacket());\n  writeSimpleFrame(QuicSimpleFrame(pathChallenge), builder);\n\n  auto packet = std::move(builder).buildPacket();\n\n  EXPECT_TRUE(conn.pendingEvents.frames.empty());\n  deliverData(packetToBuf(packet), false);\n  EXPECT_EQ(conn.pendingEvents.frames.size(), 2);\n  \/\/ The RetireConnectionId frame will be enqueued before the PathResponse.\n  auto retireFrame = conn.pendingEvents.frames[0].asRetireConnectionIdFrame();\n  EXPECT_EQ(retireFrame->sequenceNumber, 0);\n\n  PathResponseFrame& pathResponse =\n      *conn.pendingEvents.frames[1].asPathResponseFrame();\n  EXPECT_EQ(pathResponse.pathData, pathChallenge.pathData);\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":489144,"func":"sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep,\n\t\t\t\t     const struct sctp_association *asoc,\n\t\t\t\t     const sctp_subtype_t type,\n\t\t\t\t     void *arg,\n\t\t\t\t     sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *unk_chunk = arg;\n\tstruct sctp_chunk *err_chunk;\n\tsctp_chunkhdr_t *hdr;\n\n\tSCTP_DEBUG_PRINTK(\"Processing the unknown chunk id %d.\\n\", type.chunk);\n\n\tif (!sctp_vtag_verify(unk_chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the chunk has a valid length.\n\t * Since we don't know the chunk type, we use a general\n\t * chunkhdr structure to make a comparison.\n\t *\/\n\tif (!sctp_chunk_length_valid(unk_chunk, sizeof(sctp_chunkhdr_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\tswitch (type.chunk & SCTP_CID_ACTION_MASK) {\n\tcase SCTP_CID_ACTION_DISCARD:\n\t\t\/* Discard the packet.  *\/\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\t\tbreak;\n\tcase SCTP_CID_ACTION_DISCARD_ERR:\n\t\t\/* Generate an ERROR chunk as response. *\/\n\t\thdr = unk_chunk->chunk_hdr;\n\t\terr_chunk = sctp_make_op_error(asoc, unk_chunk,\n\t\t\t\t\t       SCTP_ERROR_UNKNOWN_CHUNK, hdr,\n\t\t\t\t\t       WORD_ROUND(ntohs(hdr->length)));\n\t\tif (err_chunk) {\n\t\t\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY,\n\t\t\t\t\tSCTP_CHUNK(err_chunk));\n\t\t}\n\n\t\t\/* Discard the packet.  *\/\n\t\tsctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\t\treturn SCTP_DISPOSITION_CONSUME;\n\t\tbreak;\n\tcase SCTP_CID_ACTION_SKIP:\n\t\t\/* Skip the chunk.  *\/\n\t\treturn SCTP_DISPOSITION_DISCARD;\n\t\tbreak;\n\tcase SCTP_CID_ACTION_SKIP_ERR:\n\t\t\/* Generate an ERROR chunk as response. *\/\n\t\thdr = unk_chunk->chunk_hdr;\n\t\terr_chunk = sctp_make_op_error(asoc, unk_chunk,\n\t\t\t\t\t       SCTP_ERROR_UNKNOWN_CHUNK, hdr,\n\t\t\t\t\t       WORD_ROUND(ntohs(hdr->length)));\n\t\tif (err_chunk) {\n\t\t\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY,\n\t\t\t\t\tSCTP_CHUNK(err_chunk));\n\t\t}\n\t\t\/* Skip the chunk.  *\/\n\t\treturn SCTP_DISPOSITION_CONSUME;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn SCTP_DISPOSITION_DISCARD;\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":242989,"func":"static int ssl_compress_buf( mbedtls_ssl_context *ssl )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n    unsigned char *msg_post = ssl->out_msg;\n    ptrdiff_t bytes_written = ssl->out_msg - ssl->out_buf;\n    size_t len_pre = ssl->out_msglen;\n    unsigned char *msg_pre = ssl->compress_buf;\n#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)\n    size_t out_buf_len = ssl->out_buf_len;\n#else\n    size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN;\n#endif\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> compress buf\" ) );\n\n    if( len_pre == 0 )\n        return( 0 );\n\n    memcpy( msg_pre, ssl->out_msg, len_pre );\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"before compression: msglen = %\" MBEDTLS_PRINTF_SIZET \", \",\n                   ssl->out_msglen ) );\n\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"before compression: output payload\",\n                   ssl->out_msg, ssl->out_msglen );\n\n    ssl->transform_out->ctx_deflate.next_in = msg_pre;\n    ssl->transform_out->ctx_deflate.avail_in = len_pre;\n    ssl->transform_out->ctx_deflate.next_out = msg_post;\n    ssl->transform_out->ctx_deflate.avail_out = out_buf_len - bytes_written;\n\n    ret = deflate( &ssl->transform_out->ctx_deflate, Z_SYNC_FLUSH );\n    if( ret != Z_OK )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"failed to perform compression (%d)\", ret ) );\n        return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED );\n    }\n\n    ssl->out_msglen = out_buf_len -\n                      ssl->transform_out->ctx_deflate.avail_out - bytes_written;\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"after compression: msglen = %\" MBEDTLS_PRINTF_SIZET \", \",\n                   ssl->out_msglen ) );\n\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"after compression: output payload\",\n                   ssl->out_msg, ssl->out_msglen );\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= compress buf\" ) );\n\n    return( 0 );\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":240298,"func":"stuff_yank(int regname, char_u *p)\n{\n    char_u\t*lp;\n    char_u\t**pp;\n\n    \/\/ check for read-only register\n    if (regname != 0 && !valid_yank_reg(regname, TRUE))\n    {\n\tvim_free(p);\n\treturn FAIL;\n    }\n    if (regname == '_')\t\t    \/\/ black hole: don't do anything\n    {\n\tvim_free(p);\n\treturn OK;\n    }\n    get_yank_register(regname, TRUE);\n    if (y_append && y_current->y_array != NULL)\n    {\n\tpp = &(y_current->y_array[y_current->y_size - 1]);\n\tlp = alloc(STRLEN(*pp) + STRLEN(p) + 1);\n\tif (lp == NULL)\n\t{\n\t    vim_free(p);\n\t    return FAIL;\n\t}\n\tSTRCPY(lp, *pp);\n\tSTRCAT(lp, p);\n\tvim_free(p);\n\tvim_free(*pp);\n\t*pp = lp;\n    }\n    else\n    {\n\tfree_yank_all();\n\tif ((y_current->y_array = ALLOC_ONE(char_u *)) == NULL)\n\t{\n\t    vim_free(p);\n\t    return FAIL;\n\t}\n\ty_current->y_array[0] = p;\n\ty_current->y_size = 1;\n\ty_current->y_type = MCHAR;  \/\/ used to be MLINE, why?\n#ifdef FEAT_VIMINFO\n\ty_current->y_time_set = vim_time();\n#endif\n    }\n    return OK;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":233852,"func":"void fmtutil_handle_exif2(deark *c, i64 pos, i64 len,\n\tu32 *returned_flags, u32 *orientation, u32 *exifversion)\n{\n\tint user_opt;\n\tde_module_params *mparams = NULL;\n\n\tif(returned_flags) {\n\t\t*returned_flags = 0;\n\t}\n\n\tuser_opt = de_get_ext_option_bool(c, \"extractexif\", -1);\n\tif(user_opt==1 || (c->extract_level>=2 && user_opt!=0)) {\n\t\t\/\/ Writing raw Exif data isn't very useful, but do so if requested.\n\t\tdbuf_create_file_from_slice(c->infile, pos, len, \"exif.tif\", NULL, DE_CREATEFLAG_IS_AUX);\n\n\t\t\/\/ Caller will have to reprocess the Exif file to extract anything from it.\n\t\treturn;\n\t}\n\n\tmparams = de_malloc(c, sizeof(de_module_params));\n\tmparams->in_params.codes = \"E\";\n\n\tde_run_module_by_id_on_slice(c, \"tiff\", mparams, c->infile, pos, len);\n\tif(returned_flags) {\n\t\t\/\/ FIXME: It's an unfortunate bug that returned_flags does not work if\n\t\t\/\/ extract_level>=2, but for now there's no reasonable way to fix it.\n\t\t\/\/ We have to process -- not extract -- the Exif chunk if we want to\n\t\t\/\/ know what's in it.\n\t\t*returned_flags = mparams->out_params.flags;\n\t\tif((mparams->out_params.flags & 0x20) && orientation) {\n\t\t\t*orientation = mparams->out_params.uint1;\n\t\t}\n\n\t\tif((mparams->out_params.flags & 0x40) && exifversion) {\n\t\t\t*exifversion = mparams->out_params.uint2;\n\t\t}\n\t}\n\n\tde_free(c, mparams);\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":384683,"func":"send_newstyle_option_reply_meta_context (uint32_t option, uint32_t reply,\n                                         uint32_t context_id,\n                                         const char *name)\n{\n  GET_CONN;\n  struct nbd_fixed_new_option_reply fixed_new_option_reply;\n  struct nbd_fixed_new_option_reply_meta_context context;\n  const size_t namelen = strlen (name);\n\n  debug (\"newstyle negotiation: %s: replying with %s id %d\",\n         name_of_nbd_opt (option), name, context_id);\n  fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC);\n  fixed_new_option_reply.option = htobe32 (option);\n  fixed_new_option_reply.reply = htobe32 (reply);\n  fixed_new_option_reply.replylen = htobe32 (sizeof context + namelen);\n  context.context_id = htobe32 (context_id);\n\n  if (conn->send (&fixed_new_option_reply,\n                  sizeof fixed_new_option_reply, SEND_MORE) == -1 ||\n      conn->send (&context, sizeof context, SEND_MORE) == -1 ||\n      conn->send (name, namelen, 0) == -1) {\n    nbdkit_error (\"write: %s: %m\", name_of_nbd_opt (option));\n    return -1;\n  }\n\n  return 0;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":254903,"func":"DocumentSourceGroup::rewriteGroupAsTransformOnFirstDocument() const {\n    if (_idExpressions.size() != 1) {\n        \/\/ This transformation is only intended for $group stages that group on a single field.\n        return nullptr;\n    }\n\n    auto fieldPathExpr = dynamic_cast<ExpressionFieldPath*>(_idExpressions.front().get());\n    if (!fieldPathExpr || !fieldPathExpr->isRootFieldPath()) {\n        return nullptr;\n    }\n\n    const auto fieldPath = fieldPathExpr->getFieldPath();\n    if (fieldPath.getPathLength() == 1) {\n        \/\/ The path is $$CURRENT or $$ROOT. This isn't really a sensible value to group by (since\n        \/\/ each document has a unique _id, it will just return the entire collection). We only\n        \/\/ apply the rewrite when grouping by a single field, so we cannot apply it in this case,\n        \/\/ where we are grouping by the entire document.\n        invariant(fieldPath.getFieldName(0) == \"CURRENT\" || fieldPath.getFieldName(0) == \"ROOT\");\n        return nullptr;\n    }\n\n    const auto groupId = fieldPath.tail().fullPath();\n\n    \/\/ We can't do this transformation if there are any non-$first accumulators.\n    for (auto&& accumulator : _accumulatedFields) {\n        if (AccumulatorDocumentsNeeded::kFirstDocument !=\n            accumulator.makeAccumulator()->documentsNeeded()) {\n            return nullptr;\n        }\n    }\n\n    std::vector<std::pair<std::string, boost::intrusive_ptr<Expression>>> fields;\n\n    boost::intrusive_ptr<Expression> idField;\n    \/\/ The _id field can be specified either as a fieldpath (ex. _id: \"$a\") or as a singleton\n    \/\/ object (ex. _id: {v: \"$a\"}).\n    if (_idFieldNames.empty()) {\n        idField = ExpressionFieldPath::create(pExpCtx.get(), groupId);\n    } else {\n        invariant(_idFieldNames.size() == 1);\n        idField = ExpressionObject::create(pExpCtx.get(),\n                                           {{_idFieldNames.front(), _idExpressions.front()}});\n    }\n    fields.push_back(std::make_pair(\"_id\", idField));\n\n    for (auto&& accumulator : _accumulatedFields) {\n        fields.push_back(std::make_pair(accumulator.fieldName, accumulator.expr.argument));\n\n        \/\/ Since we don't attempt this transformation for non-$first accumulators,\n        \/\/ the initializer should always be trivial.\n    }\n\n    return GroupFromFirstDocumentTransformation::create(pExpCtx, groupId, std::move(fields));\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":455293,"func":"finddirs (pat, sdir, flags, ep, np)\n     char *pat;\n     char *sdir;\n     int flags;\n     struct globval **ep;\n     int *np;\n{\n  char **r, *n;\n  int ndirs;\n  struct globval *ret, *e, *g;\n\n\/*itrace(\"finddirs: pat = `%s' sdir = `%s' flags = 0x%x\", pat, sdir, flags);*\/\n  e = ret = 0;\n  r = glob_vector (pat, sdir, flags);\n  if (r == 0 || r[0] == 0)\n    {\n      if (np)\n\t*np = 0;\n      if (ep)\n        *ep = 0;\n      if (r && r != &glob_error_return)\n\tfree (r);\n      return (struct globval *)0;\n    }\n  for (ndirs = 0; r[ndirs] != 0; ndirs++)\n    {\n      g = (struct globval *) malloc (sizeof (struct globval));\n      if (g == 0)\n\t{\n\t  while (ret)\t\t\/* free list built so far *\/\n\t    {\n\t      g = ret->next;\n\t      free (ret);\n\t      ret = g;\n\t    }\n\n\t  free (r);\n\t  if (np)\n\t    *np = 0;\n\t  if (ep)\n\t    *ep = 0;\n\t  return (&finddirs_error_return);\n\t}\n      if (e == 0)\n\te = g;\n\n      g->next = ret;\n      ret = g;\n\n      g->name = r[ndirs];\n    }\n\n  free (r);\n  if (ep)\n    *ep = e;\n  if (np)\n    *np = ndirs;\n\n  return ret;\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":294438,"func":"test_unit_v2v_iter2(VALUE (* conv1)(VALUE),\n\t\t    VALUE (* conv2)(VALUE))\n{\n    if (!test_unit_v2v(INT2FIX(0), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2FIX(1), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2FIX(2), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2FIX(3), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2FIX(11), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2FIX(65535), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2FIX(1073741823), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(INT2NUM(1073741824), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(rb_rational_new2(INT2FIX(0), INT2FIX(1)), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(rb_rational_new2(INT2FIX(1), INT2FIX(1)), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(rb_rational_new2(INT2FIX(1), INT2FIX(2)), conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v(rb_rational_new2(INT2FIX(2), INT2FIX(3)), conv1, conv2))\n\treturn 0;\n    return 1;\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":259084,"func":"  Status run(BundleReader* reader) {\n    TensorShape restored_full_shape;\n    TF_RETURN_IF_ERROR(\n        reader->LookupTensorShape(tensor_name, &restored_full_shape));\n\n    VLOG(1) << \"Restoring tensor \" << idx << \" : \" << tensor_name << \" : \"\n            << restored_full_shape.num_elements();\n    Tensor* restored_tensor;\n    if (shape_and_slice.empty()) {\n      \/\/ Lookup the full tensor.\n      TF_RETURN_IF_ERROR(\n          context->allocate_output(idx, restored_full_shape, &restored_tensor));\n      TF_RETURN_IF_ERROR(reader->Lookup(tensor_name, restored_tensor));\n    } else {\n      \/\/ Lookup the slice.\n      TensorShape parsed_full_shape;\n      TensorSlice parsed_slice;\n      TensorShape parsed_slice_shape;\n\n      TF_RETURN_IF_ERROR(\n          checkpoint::ParseShapeAndSlice(shape_and_slice, &parsed_full_shape,\n                                         &parsed_slice, &parsed_slice_shape));\n\n      if (!restored_full_shape.IsSameSize(parsed_full_shape)) {\n        return errors::InvalidArgument(\n            \"tensor_name = \", tensor_name, \"; shape in shape_and_slice spec \",\n            parsed_full_shape.DebugString(),\n            \" does not match the shape stored in checkpoint: \",\n            restored_full_shape.DebugString());\n      }\n      TF_RETURN_IF_ERROR(\n          context->allocate_output(idx, parsed_slice_shape, &restored_tensor));\n      TF_RETURN_IF_ERROR(\n          reader->LookupSlice(tensor_name, parsed_slice, restored_tensor));\n    }\n    if (VLOG_IS_ON(5)) {\n      if (restored_tensor->dtype() == DT_FLOAT) {\n        const float* t_data = restored_tensor->flat<float>().data();\n        float min = std::numeric_limits<float>::infinity();\n        float max = -std::numeric_limits<float>::infinity();\n        double avg = 0.0;\n        for (int i = 0; i < restored_tensor->NumElements(); ++i) {\n          if (t_data[i] < min) min = t_data[i];\n          if (t_data[i] > max) max = t_data[i];\n          avg += t_data[i];\n        }\n        VLOG(5) << \" min \" << min << \" max \" << max << \" avg \"\n                << avg \/ restored_tensor->NumElements() << \" total elts \"\n                << restored_tensor->NumElements();\n      }\n    }\n    VLOG(1) << \"Done restoring tensor \" << idx << \" : \" << tensor_name << \" : \"\n            << restored_full_shape.num_elements();\n    return Status::OK();\n  }","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":384876,"func":"expand_backtick(\n    garray_T\t*gap,\n    char_u\t*pat,\n    int\t\tflags)\t\/\/ EW_* flags\n{\n    char_u\t*p;\n    char_u\t*cmd;\n    char_u\t*buffer;\n    int\t\tcnt = 0;\n    int\t\ti;\n\n    \/\/ Create the command: lop off the backticks.\n    cmd = vim_strnsave(pat + 1, STRLEN(pat) - 2);\n    if (cmd == NULL)\n\treturn -1;\n\n#ifdef FEAT_EVAL\n    if (*cmd == '=')\t    \/\/ `={expr}`: Expand expression\n\tbuffer = eval_to_string(cmd + 1, TRUE);\n    else\n#endif\n\tbuffer = get_cmd_output(cmd, NULL,\n\t\t\t\t(flags & EW_SILENT) ? SHELL_SILENT : 0, NULL);\n    vim_free(cmd);\n    if (buffer == NULL)\n\treturn -1;\n\n    cmd = buffer;\n    while (*cmd != NUL)\n    {\n\tcmd = skipwhite(cmd);\t\t\/\/ skip over white space\n\tp = cmd;\n\twhile (*p != NUL && *p != '\\r' && *p != '\\n') \/\/ skip over entry\n\t    ++p;\n\t\/\/ add an entry if it is not empty\n\tif (p > cmd)\n\t{\n\t    i = *p;\n\t    *p = NUL;\n\t    addfile(gap, cmd, flags);\n\t    *p = i;\n\t    ++cnt;\n\t}\n\tcmd = p;\n\twhile (*cmd != NUL && (*cmd == '\\r' || *cmd == '\\n'))\n\t    ++cmd;\n    }\n\n    vim_free(buffer);\n    return cnt;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":509525,"func":"static int mark_recovery_start(const char* log_dir)\n{\n  int res;\n  DBUG_ENTER(\"mark_recovery_start\");\n  if (!(maria_recover_options & HA_RECOVER_ANY))\n    ma_message_no_user(ME_WARNING, \"Please consider using option\"\n                       \" --aria-recover-options[=...] to automatically check and\"\n                       \" repair tables when logs are removed by option\"\n                       \" --aria-force-start-after-recovery-failures=#\");\n  if (recovery_failures >= force_start_after_recovery_failures)\n  {\n    \/*\n      Remove logs which cause the problem; keep control file which has\n      critical info like uuid, max_trid (removing control file may make\n      correct tables look corrupted!).\n    *\/\n    char msg[100];\n    res= translog_walk_filenames(log_dir, &translog_callback_delete_all);\n    my_snprintf(msg, sizeof(msg),\n                \"%s logs after %u consecutive failures of\"\n                \" recovery from logs\",\n                (res ? \"failed to remove some\" : \"removed all\"),\n                recovery_failures);\n    ma_message_no_user((res ? 0 : ME_WARNING), msg);\n  }\n  else\n    res= ma_control_file_write_and_force(last_checkpoint_lsn, last_logno,\n                                         max_trid_in_control_file,\n                                         recovery_failures + 1);\n  DBUG_RETURN(res);\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":274717,"func":"void callbacks_update_scrollbar_limits (void){\n\tgerbv_render_info_t tempRenderInfo = {0, 0, 0, 0,\n\t\tGERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY,\n\t\tscreenRenderInfo.displayWidth,\n\t\tscreenRenderInfo.displayHeight};\n\n\tGtkAdjustment *hAdjust = (GtkAdjustment *)screen.win.hAdjustment;\n\tGtkAdjustment *vAdjust = (GtkAdjustment *)screen.win.vAdjustment;\n\tgerbv_render_zoom_to_fit_display (mainProject, &tempRenderInfo);\n\thAdjust->lower = tempRenderInfo.lowerLeftX;\n\thAdjust->page_increment = hAdjust->page_size;\n\thAdjust->step_increment = hAdjust->page_size \/ 10.0;\n\tvAdjust->lower = tempRenderInfo.lowerLeftY;\n\tvAdjust->page_increment = vAdjust->page_size;\n\tvAdjust->step_increment = vAdjust->page_size \/ 10.0;\n\thAdjust->upper = tempRenderInfo.lowerLeftX + (tempRenderInfo.displayWidth \/ tempRenderInfo.scaleFactorX);\n\thAdjust->page_size = screenRenderInfo.displayWidth \/ screenRenderInfo.scaleFactorX;\n\tvAdjust->upper = tempRenderInfo.lowerLeftY + (tempRenderInfo.displayHeight \/ tempRenderInfo.scaleFactorY);\n\tvAdjust->page_size = screenRenderInfo.displayHeight \/ screenRenderInfo.scaleFactorY;\n\tcallbacks_update_scrollbar_positions ();\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":488362,"func":"void unmap_mapping_range(struct address_space *mapping,\n\t\tloff_t const holebegin, loff_t const holelen, int even_cows)\n{\n\tstruct zap_details details;\n\tpgoff_t hba = holebegin >> PAGE_SHIFT;\n\tpgoff_t hlen = (holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;\n\n\t\/* Check for overflow. *\/\n\tif (sizeof(holelen) > sizeof(hlen)) {\n\t\tlong long holeend =\n\t\t\t(holebegin + holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;\n\t\tif (holeend & ~(long long)ULONG_MAX)\n\t\t\thlen = ULONG_MAX - hba + 1;\n\t}\n\n\tdetails.check_mapping = even_cows? NULL: mapping;\n\tdetails.nonlinear_vma = NULL;\n\tdetails.first_index = hba;\n\tdetails.last_index = hba + hlen - 1;\n\tif (details.last_index < details.first_index)\n\t\tdetails.last_index = ULONG_MAX;\n\tdetails.i_mmap_lock = &mapping->i_mmap_lock;\n\n\tspin_lock(&mapping->i_mmap_lock);\n\n\t\/* Protect against endless unmapping loops *\/\n\tmapping->truncate_count++;\n\tif (unlikely(is_restart_addr(mapping->truncate_count))) {\n\t\tif (mapping->truncate_count == 0)\n\t\t\treset_vma_truncate_counts(mapping);\n\t\tmapping->truncate_count++;\n\t}\n\tdetails.truncate_count = mapping->truncate_count;\n\n\tif (unlikely(!prio_tree_empty(&mapping->i_mmap)))\n\t\tunmap_mapping_range_tree(&mapping->i_mmap, &details);\n\tif (unlikely(!list_empty(&mapping->i_mmap_nonlinear)))\n\t\tunmap_mapping_range_list(&mapping->i_mmap_nonlinear, &details);\n\tspin_unlock(&mapping->i_mmap_lock);\n}","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":312459,"func":"qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)\n{\n    dictitem_T\t*di;\n    int\t\tretval = FAIL;\n    int\t\tqf_idx;\n    int\t\tnewlist = FALSE;\n    qf_list_T\t*qfl;\n\n    if (action == ' ' || qf_stack_empty(qi))\n\tnewlist = TRUE;\n\n    qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist);\n    if (qf_idx == INVALID_QFIDX)\t\/\/ List not found\n\treturn FAIL;\n\n    if (newlist)\n    {\n\tqi->qf_curlist = qf_idx;\n\tqf_new_list(qi, title);\n\tqf_idx = qi->qf_curlist;\n    }\n\n    qfl = qf_get_list(qi, qf_idx);\n    if ((di = dict_find(what, (char_u *)\"title\", -1)) != NULL)\n\tretval = qf_setprop_title(qi, qf_idx, what, di);\n    if ((di = dict_find(what, (char_u *)\"items\", -1)) != NULL)\n\tretval = qf_setprop_items(qi, qf_idx, di, action);\n    if ((di = dict_find(what, (char_u *)\"lines\", -1)) != NULL)\n\tretval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action);\n    if ((di = dict_find(what, (char_u *)\"context\", -1)) != NULL)\n\tretval = qf_setprop_context(qfl, di);\n    if ((di = dict_find(what, (char_u *)\"idx\", -1)) != NULL)\n\tretval = qf_setprop_curidx(qi, qfl, di);\n    if ((di = dict_find(what, (char_u *)\"quickfixtextfunc\", -1)) != NULL)\n\tretval = qf_setprop_qftf(qi, qfl, di);\n\n    if (newlist || retval == OK)\n\tqf_list_changed(qfl);\n    if (newlist)\n\tqf_update_buffer(qi, NULL);\n\n    return retval;\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":214339,"func":"int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)\n{\n\tstruct rtas_token_definition *d;\n\tstruct rtas_args args;\n\trtas_arg_t *orig_rets;\n\tgpa_t args_phys;\n\tint rc;\n\n\t\/*\n\t * r4 contains the guest physical address of the RTAS args\n\t * Mask off the top 4 bits since this is a guest real address\n\t *\/\n\targs_phys = kvmppc_get_gpr(vcpu, 4) & KVM_PAM;\n\n\tvcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);\n\trc = kvm_read_guest(vcpu->kvm, args_phys, &args, sizeof(args));\n\tsrcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);\n\tif (rc)\n\t\tgoto fail;\n\n\t\/*\n\t * args->rets is a pointer into args->args. Now that we've\n\t * copied args we need to fix it up to point into our copy,\n\t * not the guest args. We also need to save the original\n\t * value so we can restore it on the way out.\n\t *\/\n\torig_rets = args.rets;\n\targs.rets = &args.args[be32_to_cpu(args.nargs)];\n\n\tmutex_lock(&vcpu->kvm->arch.rtas_token_lock);\n\n\trc = -ENOENT;\n\tlist_for_each_entry(d, &vcpu->kvm->arch.rtas_tokens, list) {\n\t\tif (d->token == be32_to_cpu(args.token)) {\n\t\t\td->handler->handler(vcpu, &args);\n\t\t\trc = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tmutex_unlock(&vcpu->kvm->arch.rtas_token_lock);\n\n\tif (rc == 0) {\n\t\targs.rets = orig_rets;\n\t\trc = kvm_write_guest(vcpu->kvm, args_phys, &args, sizeof(args));\n\t\tif (rc)\n\t\t\tgoto fail;\n\t}\n\n\treturn rc;\n\nfail:\n\t\/*\n\t * We only get here if the guest has called RTAS with a bogus\n\t * args pointer. That means we can't get to the args, and so we\n\t * can't fail the RTAS call. So fail right out to userspace,\n\t * which should kill the guest.\n\t *\/\n\treturn rc;\n}","target":1,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":226076,"func":"\nGF_Err fdpa_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_FDpacketBox *ptr = (GF_FDpacketBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 3);\n\tptr->info.sender_current_time_present = gf_bs_read_int(bs, 1);\n\tptr->info.expected_residual_time_present = gf_bs_read_int(bs, 1);\n\tptr->info.session_close_bit = gf_bs_read_int(bs, 1);\n\tptr->info.object_close_bit = gf_bs_read_int(bs, 1);\n\tgf_bs_read_int(bs, 4);\n\tptr->info.transport_object_identifier = gf_bs_read_u16(bs);\n\tISOM_DECREASE_SIZE(ptr, 2);\n\tptr->header_ext_count = gf_bs_read_u16(bs);\n\tif (ptr->size \/ 2 < ptr->header_ext_count) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of entries %d in fdpa\\n\", ptr->header_ext_count));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tGF_SAFE_ALLOC_N(ptr->headers, ptr->header_ext_count, GF_LCTheaderExtension);\n\tif (!ptr->headers) return GF_OUT_OF_MEM;\n\n\tfor (i=0; i<ptr->header_ext_count; i++) {\n\t\tptr->headers[i].header_extension_type = gf_bs_read_u8(bs);\n\t\tISOM_DECREASE_SIZE(ptr, 1);\n\n\t\tif (ptr->headers[i].header_extension_type > 127) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 3);\n\t\t\tgf_bs_read_data(bs, (char *) ptr->headers[i].content, 3);\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(ptr, 1);\n\t\t\tptr->headers[i].data_length = gf_bs_read_u8(bs);\n\t\t\tif (ptr->headers[i].data_length) {\n\t\t\t\tptr->headers[i].data_length = 4*ptr->headers[i].data_length - 2;\n\t\t\t\tif (ptr->size < sizeof(char) * ptr->headers[i].data_length)\n\t\t\t\t    return GF_ISOM_INVALID_FILE;\n\t\t\t\tptr->headers[i].data = gf_malloc(sizeof(char) * ptr->headers[i].data_length);\n\t\t\t\tif (!ptr->headers[i].data) return GF_OUT_OF_MEM;\n\n\t\t\t\tISOM_DECREASE_SIZE(ptr, ptr->headers[i].data_length);\n\t\t\t\tgf_bs_read_data(bs, ptr->headers[i].data, ptr->headers[i].data_length);\n\t\t\t}\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":546,"total_token_length":782,"max_tokens_setting":1024}
+{"idx":225444,"func":"static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)\n{\n\tenum v4l2_buf_type type;\n\tint index;\n\tstruct v4l2_loopback_device *dev;\n\tstruct v4l2_loopback_opener *opener;\n\n\tMARK();\n\n\ttype = b->type;\n\tindex = b->index;\n\tdev = v4l2loopback_getdevice(file);\n\topener = fh_to_opener(fh);\n\n\tif ((b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&\n\t    (b->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)) {\n\t\treturn -EINVAL;\n\t}\n\tif (b->index > max_buffers)\n\t\treturn -EINVAL;\n\n\tif (opener->timeout_image_io)\n\t\t*b = dev->timeout_image_buffer.buffer;\n\telse\n\t\t*b = dev->buffers[b->index % dev->used_buffers].buffer;\n\n\tb->type = type;\n\tb->index = index;\n\tdprintkrw(\"buffer type: %d (of %d with size=%ld)\\n\", b->memory,\n\t\t  dev->buffers_number, dev->buffer_size);\n\n\t\/*  Hopefully fix 'DQBUF return bad index if queue bigger then 2 for capture'\n            https:\/\/github.com\/umlaeute\/v4l2loopback\/issues\/60 *\/\n\tb->flags &= ~V4L2_BUF_FLAG_DONE;\n\tb->flags |= V4L2_BUF_FLAG_QUEUED;\n\n\treturn 0;\n}","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":405327,"func":"decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)\n{\n\tconst struct iphdr *iph = ip_hdr(skb);\n\tint ihl = iph->ihl;\n\tu8 *xprth = skb_network_header(skb) + ihl * 4;\n\tstruct flowi4 *fl4 = &fl->u.ip4;\n\tint oif = 0;\n\n\tif (skb_dst(skb) && skb_dst(skb)->dev)\n\t\toif = skb_dst(skb)->dev->ifindex;\n\n\tmemset(fl4, 0, sizeof(struct flowi4));\n\tfl4->flowi4_mark = skb->mark;\n\tfl4->flowi4_oif = reverse ? skb->skb_iif : oif;\n\n\tfl4->flowi4_proto = iph->protocol;\n\tfl4->daddr = reverse ? iph->saddr : iph->daddr;\n\tfl4->saddr = reverse ? iph->daddr : iph->saddr;\n\tfl4->flowi4_tos = iph->tos & ~INET_ECN_MASK;\n\n\tif (!ip_is_fragment(iph)) {\n\t\tswitch (iph->protocol) {\n\t\tcase IPPROTO_UDP:\n\t\tcase IPPROTO_UDPLITE:\n\t\tcase IPPROTO_TCP:\n\t\tcase IPPROTO_SCTP:\n\t\tcase IPPROTO_DCCP:\n\t\t\tif (xprth + 4 < skb->data ||\n\t\t\t    pskb_may_pull(skb, xprth + 4 - skb->data)) {\n\t\t\t\t__be16 *ports;\n\n\t\t\t\txprth = skb_network_header(skb) + ihl * 4;\n\t\t\t\tports = (__be16 *)xprth;\n\n\t\t\t\tfl4->fl4_sport = ports[!!reverse];\n\t\t\t\tfl4->fl4_dport = ports[!reverse];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase IPPROTO_ICMP:\n\t\t\tif (xprth + 2 < skb->data ||\n\t\t\t    pskb_may_pull(skb, xprth + 2 - skb->data)) {\n\t\t\t\tu8 *icmp;\n\n\t\t\t\txprth = skb_network_header(skb) + ihl * 4;\n\t\t\t\ticmp = xprth;\n\n\t\t\t\tfl4->fl4_icmp_type = icmp[0];\n\t\t\t\tfl4->fl4_icmp_code = icmp[1];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase IPPROTO_GRE:\n\t\t\tif (xprth + 12 < skb->data ||\n\t\t\t    pskb_may_pull(skb, xprth + 12 - skb->data)) {\n\t\t\t\t__be16 *greflags;\n\t\t\t\t__be32 *gre_hdr;\n\n\t\t\t\txprth = skb_network_header(skb) + ihl * 4;\n\t\t\t\tgreflags = (__be16 *)xprth;\n\t\t\t\tgre_hdr = (__be32 *)xprth;\n\n\t\t\t\tif (greflags[0] & GRE_KEY) {\n\t\t\t\t\tif (greflags[0] & GRE_CSUM)\n\t\t\t\t\t\tgre_hdr++;\n\t\t\t\t\tfl4->fl4_gre_key = gre_hdr[1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n}","target":0,"code_token_length":672,"total_token_length":908,"max_tokens_setting":1024}
+{"idx":512392,"func":"bool Item_func_interval::fix_length_and_dec()\n{\n  uint rows= row->cols();\n  \n  use_decimal_comparison= ((row->element_index(0)->result_type() ==\n                            DECIMAL_RESULT) ||\n                           (row->element_index(0)->result_type() ==\n                            INT_RESULT));\n  if (rows > 8)\n  {\n    bool not_null_consts= TRUE;\n\n    for (uint i= 1; not_null_consts && i < rows; i++)\n    {\n      Item *el= row->element_index(i);\n      not_null_consts&= el->const_item() && !el->is_null();\n    }\n\n    if (not_null_consts)\n    {\n      intervals= (interval_range*) current_thd->alloc(sizeof(interval_range) *\n                                                         (rows - 1));\n      if (!intervals)\n        return TRUE;\n\n      if (use_decimal_comparison)\n      {\n        for (uint i= 1; i < rows; i++)\n        {\n          Item *el= row->element_index(i);\n          interval_range *range= intervals + (i-1);\n          if ((el->result_type() == DECIMAL_RESULT) ||\n              (el->result_type() == INT_RESULT))\n          {\n            range->type= DECIMAL_RESULT;\n            range->dec.init();\n            my_decimal *dec= el->val_decimal(&range->dec);\n            if (dec != &range->dec)\n            {\n              range->dec= *dec;\n            }\n          }\n          else\n          {\n            range->type= REAL_RESULT;\n            range->dbl= el->val_real();\n          }\n        }\n      }\n      else\n      {\n        for (uint i= 1; i < rows; i++)\n        {\n          intervals[i-1].dbl= row->element_index(i)->val_real();\n        }\n      }\n    }\n  }\n  maybe_null= 0;\n  max_length= 2;\n  used_tables_and_const_cache_join(row);\n  not_null_tables_cache= row->not_null_tables();\n  join_with_sum_func(row);\n  with_param= with_param || row->with_param;\n  with_field= with_field || row->with_field;\n  return FALSE;\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":229175,"func":"static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,\n                                 VirtIODevice *vdev)\n{\n    VirtIOSerialPortClass *vsc;\n\n    assert(port);\n    assert(virtio_queue_ready(vq));\n\n    vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n\n    while (!port->throttled) {\n        unsigned int i;\n\n        \/* Pop an elem only if we haven't left off a previous one mid-way *\/\n        if (!port->elem.out_num) {\n            if (!virtqueue_pop(vq, &port->elem)) {\n                break;\n            }\n            port->iov_idx = 0;\n            port->iov_offset = 0;\n        }\n\n        for (i = port->iov_idx; i < port->elem.out_num; i++) {\n            size_t buf_size;\n            ssize_t ret;\n\n            buf_size = port->elem.out_sg[i].iov_len - port->iov_offset;\n            ret = vsc->have_data(port,\n                                  port->elem.out_sg[i].iov_base\n                                  + port->iov_offset,\n                                  buf_size);\n            if (port->throttled) {\n                port->iov_idx = i;\n                if (ret > 0) {\n                    port->iov_offset += ret;\n                }\n                break;\n            }\n            port->iov_offset = 0;\n        }\n        if (port->throttled) {\n            break;\n        }\n        virtqueue_push(vq, &port->elem, 0);\n        port->elem.out_num = 0;\n    }\n    virtio_notify(vdev, vq);\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":267972,"func":"static void get_strings_range(RBinFile *bf, RList *list, int min, int raw, ut64 from, ut64 to, RBinSection *section) {\n\tr_return_if_fail (bf && bf->buf);\n\n\tRBinPlugin *plugin = r_bin_file_cur_plugin (bf);\n\n\tif (!raw && (!plugin || !plugin->info)) {\n\t\treturn;\n\t}\n\tif (!min) {\n\t\tmin = plugin? plugin->minstrlen: 4;\n\t}\n\t\/* Some plugins return zero, fix it up *\/\n\tif (min < 0) {\n\t\treturn;\n\t}\n\tif (!min) {\n\t\tmin = 4;\n\t}\n\t{\n\t\tRIO *io = bf->rbin->iob.io;\n\t\tRCoreBind *cb = &io->coreb;\n\t\tif (cb && cb->cfgGet) {\n\t\t\tconst bool cfg_debug = cb->cfgGet (cb->core, \"cfg.debug\");\n\t\t\tif (!cfg_debug) {\n\t\t\t\tif (!to || to > r_buf_size (bf->buf)) {\n\t\t\t\t\tto = r_buf_size (bf->buf);\n\t\t\t\t}\n\t\t\t\tif (!to) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (raw != 2) {\n\t\tut64 size = to - from;\n\t\t\/\/ in case of dump ignore here\n\t\tif (bf->rbin->maxstrbuf && size && size > bf->rbin->maxstrbuf) {\n\t\t\tif (bf->rbin->verbose) {\n\t\t\t\tR_LOG_WARN (\"bin_strings buffer is too big (0x%08\" PFMT64x \"). Use -zzz or set bin.maxstrbuf (RABIN2_MAXSTRBUF) in r2 (rabin2)\", size);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\tint type;\n\tconst char *enc = bf->rbin->strenc;\n\tif (!enc) {\n\t\ttype = R_STRING_TYPE_DETECT;\n\t} else if (!strcmp (enc, \"latin1\")) {\n\t\ttype = R_STRING_TYPE_ASCII;\n\t} else if (!strcmp (enc, \"utf8\")) {\n\t\ttype = R_STRING_TYPE_UTF8;\n\t} else if (!strcmp (enc, \"utf16le\")) {\n\t\ttype = R_STRING_TYPE_WIDE;\n\t} else if (!strcmp (enc, \"utf32le\")) {\n\t\ttype = R_STRING_TYPE_WIDE32;\n\t} else { \/\/ TODO utf16be, utf32be\n\t\teprintf (\"ERROR: encoding %s not supported\\n\", enc);\n\t\treturn;\n\t}\n\tstring_scan_range (list, bf, min, from, to, type, raw, section);\n}","target":0,"code_token_length":569,"total_token_length":805,"max_tokens_setting":1024}
+{"idx":445879,"func":"save_as_archive_dialog_response_cb (GtkDialog *dialog,\n\t\t\t\t    int        response,\n\t\t\t\t    gpointer   user_data)\n{\n\tFrWindow   *window = user_data;\n\tGFile      *file;\n\tconst char *mime_type;\n\tconst char *password;\n\tgboolean    encrypt_header;\n\tint         volume_size;\n\tGSettings  *settings;\n\n\tif ((response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT)) {\n\t\tgtk_widget_destroy (GTK_WIDGET (dialog));\n\t\t_archive_operation_cancelled (window, FR_ACTION_CREATING_ARCHIVE);\n\t\treturn;\n\t}\n\n\tif (response != GTK_RESPONSE_OK)\n\t\treturn;\n\n\tfile = fr_new_archive_dialog_get_file (FR_NEW_ARCHIVE_DIALOG (dialog), &mime_type);\n\tif (file == NULL)\n\t\treturn;\n\n\tpassword = fr_new_archive_dialog_get_password (FR_NEW_ARCHIVE_DIALOG (dialog));\n\tencrypt_header = fr_new_archive_dialog_get_encrypt_header (FR_NEW_ARCHIVE_DIALOG (dialog));\n\tvolume_size = fr_new_archive_dialog_get_volume_size (FR_NEW_ARCHIVE_DIALOG (dialog));\n\n\tsettings = g_settings_new (FILE_ROLLER_SCHEMA_NEW);\n\tg_settings_set_int (settings, PREF_NEW_VOLUME_SIZE, volume_size);\n\tg_object_unref (settings);\n\n\tfr_window_archive_save_as (window, file, mime_type, password, encrypt_header, volume_size);\n\n\tgtk_widget_destroy (GTK_WIDGET (dialog));\n\tg_object_unref (file);\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":312429,"func":"ex_make(exarg_T *eap)\n{\n    char_u\t*fname;\n    char_u\t*cmd;\n    char_u\t*enc = NULL;\n    win_T\t*wp = NULL;\n    qf_info_T\t*qi = &ql_info;\n    int\t\tres;\n    char_u\t*au_name = NULL;\n    int_u\tsave_qfid;\n    char_u\t*errorformat = p_efm;\n    int\t\tnewlist = TRUE;\n\n    \/\/ Redirect \":grep\" to \":vimgrep\" if 'grepprg' is \"internal\".\n    if (grep_internal(eap->cmdidx))\n    {\n\tex_vimgrep(eap);\n\treturn;\n    }\n\n    au_name = make_get_auname(eap->cmdidx);\n    if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,\n\t\t\t\t\t       curbuf->b_fname, TRUE, curbuf))\n    {\n#ifdef FEAT_EVAL\n\tif (aborting())\n\t    return;\n#endif\n    }\n    enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;\n\n    if (is_loclist_cmd(eap->cmdidx))\n\twp = curwin;\n\n    autowrite_all();\n    fname = get_mef_name();\n    if (fname == NULL)\n\treturn;\n    mch_remove(fname);\t    \/\/ in case it's not unique\n\n    cmd = make_get_fullcmd(eap->arg, fname);\n    if (cmd == NULL)\n    {\n\tvim_free(fname);\n\treturn;\n    }\n\n    \/\/ let the shell know if we are redirecting output or not\n    do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);\n\n#ifdef AMIGA\n    out_flush();\n\t\t\/\/ read window status report and redraw before message\n    (void)char_avail();\n#endif\n\n    incr_quickfix_busy();\n\n    if (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake)\n\terrorformat = p_gefm;\n    if (eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd)\n\tnewlist = FALSE;\n\n    res = qf_init(wp, fname, errorformat, newlist, qf_cmdtitle(*eap->cmdlinep),\n\t\t\t\t\t\t\t\t\tenc);\n    if (wp != NULL)\n    {\n\tqi = GET_LOC_LIST(wp);\n\tif (qi == NULL)\n\t    goto cleanup;\n    }\n    if (res >= 0)\n\tqf_list_changed(qf_get_curlist(qi));\n\n    \/\/ Remember the current quickfix list identifier, so that we can\n    \/\/ check for autocommands changing the current quickfix list.\n    save_qfid = qf_get_curlist(qi)->qf_id;\n    if (au_name != NULL)\n\tapply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,\n\t\t\t\t\t       curbuf->b_fname, TRUE, curbuf);\n    if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid))\n\t\/\/ display the first error\n\tqf_jump_first(qi, save_qfid, FALSE);\n\ncleanup:\n    decr_quickfix_busy();\n    mch_remove(fname);\n    vim_free(fname);\n    vim_free(cmd);\n}","target":0,"code_token_length":694,"total_token_length":930,"max_tokens_setting":1024}
+{"idx":412137,"func":"dnsc_parse_certs(struct dnsc_env *env, struct config_file *cfg)\n{\n\tstruct config_strlist *head, *head2;\n\tsize_t signed_cert_id;\n\tsize_t rotated_cert_id;\n\tchar *nm;\n\n\tenv->signed_certs_count = 0U;\n\tenv->rotated_certs_count = 0U;\n\tfor (head = cfg->dnscrypt_provider_cert; head; head = head->next) {\n\t\tenv->signed_certs_count++;\n\t}\n\tfor (head = cfg->dnscrypt_provider_cert_rotated; head; head = head->next) {\n\t\tenv->rotated_certs_count++;\n\t}\n\tenv->signed_certs = sodium_allocarray(env->signed_certs_count,\n\t\t\t\t\t\t\t\t\t\t  sizeof *env->signed_certs);\n\n\tenv->rotated_certs = sodium_allocarray(env->rotated_certs_count,\n\t\t\t\t\t\t\t\t\t\t  sizeof env->signed_certs);\n\tsigned_cert_id = 0U;\n\trotated_cert_id = 0U;\n\tfor(head = cfg->dnscrypt_provider_cert; head; head = head->next, signed_cert_id++) {\n\t\tnm = dnsc_chroot_path(cfg, head->str);\n\t\tif(dnsc_read_from_file(\n\t\t\t\tnm,\n\t\t\t\t(char *)(env->signed_certs + signed_cert_id),\n\t\t\t\tsizeof(struct SignedCert)) != 0) {\n\t\t\tfatal_exit(\"dnsc_parse_certs: failed to load %s: %s\", head->str, strerror(errno));\n\t\t}\n\t\tfor(head2 = cfg->dnscrypt_provider_cert_rotated; head2; head2 = head2->next) {\n\t\t\tif(strcmp(head->str, head2->str) == 0) {\n\t\t\t\t*(env->rotated_certs + rotated_cert_id) = env->signed_certs + signed_cert_id;\n\t\t\t\trotated_cert_id++;\n\t\t\t\tverbose(VERB_OPS, \"Cert %s is rotated and will not be distributed via DNS\", head->str);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tverbose(VERB_OPS, \"Loaded cert %s\", head->str);\n\t}\n\treturn signed_cert_id;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":197593,"func":"njs_function_frame_save(njs_vm_t *vm, njs_frame_t *frame, u_char *pc)\n{\n    size_t              value_count, n;\n    njs_value_t         *start, *end, *p, **new, *value, **local;\n    njs_function_t      *function;\n    njs_native_frame_t  *active, *native;\n\n    *frame = *vm->active_frame;\n    frame->previous_active_frame = NULL;\n\n    native = &frame->native;\n\n    active = &vm->active_frame->native;\n    value_count = njs_function_frame_value_count(active);\n\n    function = active->function;\n\n    new = (njs_value_t **) ((u_char *) native + NJS_FRAME_SIZE);\n    value = (njs_value_t *) (new + value_count\n                             + function->u.lambda->temp);\n\n\n    native->arguments = value;\n    native->arguments_offset = value + (function->args_offset - 1);\n    native->local = new + njs_function_frame_args_count(active);\n    native->temp = new + value_count;\n    native->pc = pc;\n\n    start = njs_function_frame_values(active, &end);\n    p = native->arguments;\n\n    while (start < end) {\n        *p = *start++;\n        *new++ = p++;\n    }\n\n    \/* Move all arguments. *\/\n\n    p = native->arguments;\n    local = native->local + function->args_offset;\n\n    for (n = 0; n < function->args_count; n++) {\n        if (!njs_is_valid(p)) {\n            njs_set_undefined(p);\n        }\n\n        *local++ = p++;\n    }\n\n    return NJS_OK;\n}","target":1,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":259605,"func":"void HierarchicalBitmapRequester::PrepareForDecoding(void)\n{\n#if ACCUSOFT_CODE\n\n  UBYTE i;\n\n  BuildCommon();\n\n  if (m_ppDecodingMCU == NULL) {\n    m_ppDecodingMCU = (struct Line **)m_pEnviron->AllocMem(sizeof(struct Line *) * m_ucCount*8);\n    memset(m_ppDecodingMCU,0,sizeof(struct Line *) * m_ucCount * 8);\n  }\n\n  if (m_ppUpsampler == NULL) {\n    m_ppUpsampler = (class UpsamplerBase **)m_pEnviron->AllocMem(sizeof(class UpsamplerBase *) * m_ucCount);\n    memset(m_ppUpsampler,0,sizeof(class Upsampler *) * m_ucCount);\n\n    for(i = 0;i < m_ucCount;i++) {\n      class Component *comp = m_pFrame->ComponentOf(i);\n      UBYTE sx = comp->SubXOf();\n      UBYTE sy = comp->SubYOf();\n\n      if (m_pLargestScale) {\n        class Frame *frame = m_pLargestScale->FrameOf();\n        while(frame) {\n          if (frame->ComponentOf(i)->SubXOf() != sx || frame->ComponentOf(i)->SubYOf() != sy)\n            JPG_THROW(MALFORMED_STREAM,\"HierarchicalBitmapRequester::PrepareForDecoding\",\n                      \"component subsampling is inconsistent across hierarchical levels\");\n          frame = frame->NextOf();\n        }\n      }\n\n      if (sx > 1 || sy > 1) {\n        m_ppUpsampler[i] = UpsamplerBase::CreateUpsampler(m_pEnviron,sx,sy,\n                                                          m_ulPixelWidth,m_ulPixelHeight,\n                                                          m_pFrame->TablesOf()->isChromaCentered());\n        m_bSubsampling   = true;\n      }\n    }\n  }\n\n  if (m_pLargestScale)\n    m_pLargestScale->PrepareForDecoding();\n#endif\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":255935,"func":"Status ShapeRefiner::InferShapesForFunction(\n    const FunctionDef* function_def, AttrSlice attributes,\n    ExtendedInferenceContext* outer_context) {\n  const Graph* graph;\n  auto it = functions_.find(function_def);\n  if (it != functions_.end()) {\n    graph = it->second.get();\n  } else {\n    InstantiationResult result;\n    TF_RETURN_IF_ERROR(InstantiateFunction(\n        *function_def, attributes,\n        [this](const string& op, const OpDef** sig) {\n          return this->function_library_->LookUpOpDef(op, sig);\n        },\n        &result));\n\n    Graph* new_graph = new Graph(function_library_);\n    GraphConstructorOptions options;\n    options.allow_internal_ops = true;\n    TF_RETURN_IF_ERROR(\n        ConvertNodeDefsToGraph(options, result.nodes, new_graph));\n    functions_[function_def].reset(new_graph);\n    graph = new_graph;\n  }\n\n  std::unordered_set<const Node*> function_nodes;\n  Status inference_status = Status::OK();\n  {\n    auto node_shape_inference_lambda = [this, &outer_context, &function_nodes,\n                                        &inference_status](const Node* node) {\n      if (!inference_status.ok()) return;\n      inference_status =\n          InferShapesForFunctionSubNode(node, outer_context->get_context());\n      function_nodes.insert(node);\n    };\n\n    \/\/ Calls inference lambda for each node after visiting all predecessors.\n    \/\/ Ensures that we are adding nodes to ShapeRefiner in the topological\n    \/\/ order.\n    ReverseDFS(*graph, {}, node_shape_inference_lambda);\n  }\n\n  \/\/ Delete the contexts created for the functions nodes to save memory.\n  for (const Node* node : function_nodes) {\n    node_to_context_.erase(node);\n  }\n\n  return inference_status;\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":259281,"func":"static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryptionIndex *encryption_index)\n{\n    AVEncryptionInfo **sample, **encrypted_samples;\n    int64_t prev_pos;\n    size_t sample_count, sample_info_size, i;\n    int ret = 0;\n    unsigned int alloc_size = 0;\n\n    if (encryption_index->nb_encrypted_samples)\n        return 0;\n    sample_count = encryption_index->auxiliary_info_sample_count;\n    if (encryption_index->auxiliary_offsets_count != 1) {\n        av_log(c->fc, AV_LOG_ERROR, \"Multiple auxiliary info chunks are not supported\\n\");\n        return AVERROR_PATCHWELCOME;\n    }\n    if (sample_count >= INT_MAX \/ sizeof(*encrypted_samples))\n        return AVERROR(ENOMEM);\n\n    prev_pos = avio_tell(pb);\n    if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) ||\n        avio_seek(pb, encryption_index->auxiliary_offsets[0], SEEK_SET) != encryption_index->auxiliary_offsets[0]) {\n        av_log(c->fc, AV_LOG_INFO, \"Failed to seek for auxiliary info, will only parse senc atoms for encryption info\\n\");\n        goto finish;\n    }\n\n    for (i = 0; i < sample_count && !pb->eof_reached; i++) {\n        unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count);\n        encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size,\n                                            min_samples * sizeof(*encrypted_samples));\n        if (!encrypted_samples) {\n            ret = AVERROR(ENOMEM);\n            goto finish;\n        }\n        encryption_index->encrypted_samples = encrypted_samples;\n\n        sample = &encryption_index->encrypted_samples[i];\n        sample_info_size = encryption_index->auxiliary_info_default_size\n                               ? encryption_index->auxiliary_info_default_size\n                               : encryption_index->auxiliary_info_sizes[i];\n\n        ret = mov_read_sample_encryption_info(c, pb, sc, sample, sample_info_size > sc->cenc.per_sample_iv_size);\n        if (ret < 0)\n            goto finish;\n    }\n    if (pb->eof_reached) {\n        av_log(c->fc, AV_LOG_ERROR, \"Hit EOF while reading auxiliary info\\n\");\n        ret = AVERROR_INVALIDDATA;\n    } else {\n        encryption_index->nb_encrypted_samples = sample_count;\n    }\n\nfinish:\n    avio_seek(pb, prev_pos, SEEK_SET);\n    if (ret < 0) {\n        for (; i > 0; i--) {\n            av_encryption_info_free(encryption_index->encrypted_samples[i - 1]);\n        }\n        av_freep(&encryption_index->encrypted_samples);\n    }\n    return ret;\n}","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":225772,"func":"\nGF_Err leva_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_LevelAssignmentBox *ptr = (GF_LevelAssignmentBox*)s;\n\n\tISOM_DECREASE_SIZE(ptr, 1)\n\tptr->level_count = gf_bs_read_u8(bs);\n\t\/\/each level is at least 5 bytes\n\tif (ptr->size \/ 5 < ptr->level_count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tGF_SAFE_ALLOC_N(ptr->levels, ptr->level_count, GF_LevelAssignment);\n\tif (!ptr->levels) return GF_OUT_OF_MEM;\n\n\tfor (i = 0; i < ptr->level_count; i++) {\n\t\tGF_LevelAssignment *level = &ptr->levels[i];\n\t\tu8 tmp;\n\t\tif (!level || ptr->size < 5) return GF_BAD_PARAM;\n\t\tISOM_DECREASE_SIZE(ptr, 5)\n\n\t\tlevel->track_id = gf_bs_read_u32(bs);\n\t\ttmp = gf_bs_read_u8(bs);\n\t\tlevel->padding_flag = tmp >> 7;\n\t\tlevel->type = tmp & 0x7F;\n\t\tif (level->type == 0) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\tlevel->grouping_type = gf_bs_read_u32(bs);\n\t\t}\n\t\telse if (level->type == 1) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\tlevel->grouping_type = gf_bs_read_u32(bs);\n\t\t\tlevel->grouping_type_parameter = gf_bs_read_u32(bs);\n\t\t}\n\t\telse if (level->type == 4) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\tlevel->sub_track_id = gf_bs_read_u32(bs);\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":432188,"func":"void *address_space_map(AddressSpace *as,\n                        hwaddr addr,\n                        hwaddr *plen,\n                        bool is_write,\n                        MemTxAttrs attrs)\n{\n    hwaddr len = *plen;\n    hwaddr l, xlat;\n    MemoryRegion *mr;\n    void *ptr;\n    FlatView *fv;\n    struct uc_struct *uc = as->uc;\n\n    if (len == 0) {\n        return NULL;\n    }\n\n    l = len;\n    fv = address_space_to_flatview(as);\n    mr = flatview_translate(uc, fv, addr, &xlat, &l, is_write, attrs);\n\n    if (!memory_access_is_direct(mr, is_write)) {\n        \/* Avoid unbounded allocations *\/\n        l = MIN(l, TARGET_PAGE_SIZE);\n        mr->uc->bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, l);\n        mr->uc->bounce.addr = addr;\n        mr->uc->bounce.len = l;\n\n        mr->uc->bounce.mr = mr;\n        if (!is_write) {\n            flatview_read(as->uc, fv, addr, MEMTXATTRS_UNSPECIFIED,\n                               mr->uc->bounce.buffer, l);\n        }\n\n        *plen = l;\n        return mr->uc->bounce.buffer;\n    }\n\n\n    *plen = flatview_extend_translation(as->uc, fv, addr, len, mr, xlat,\n                                        l, is_write, attrs);\n    ptr = qemu_ram_ptr_length(as->uc, mr->ram_block, xlat, plen, true);\n\n    return ptr;\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":222554,"func":"string Canonicalize(const string& funcname, AttrSlice attrs,\n                    const FunctionLibraryRuntime::InstantiateOptions& options) {\n  absl::InlinedVector<AttrKeyAndValue, 8> entries;\n  entries.reserve(attrs.size() + static_cast<int>(!options.target.empty()) +\n                  options.input_devices.size());\n  for (const auto& p : attrs) {\n    if (p.first != kExecutorAttr) {\n      entries.push_back(AttrKeyAndValue(\n          p.first, -1, Print(p.second, \/*hash_string_attrs=*\/true)));\n    }\n  }\n  if (!options.target.empty()) {\n    entries.push_back(AttrKeyAndValue(\"_target\", -1, options.target,\n                                      AttrKeyAndValue::kCEscape));\n  }\n  for (int i = 0; i < options.input_devices.size(); ++i) {\n    entries.push_back(AttrKeyAndValue(\"_input_dev\", i, options.input_devices[i],\n                                      AttrKeyAndValue::kCEscape));\n  }\n  for (int i = 0; i < options.output_devices.size(); ++i) {\n    entries.push_back(AttrKeyAndValue(\"_output_dev\", i,\n                                      options.output_devices[i],\n                                      AttrKeyAndValue::kCEscape));\n  }\n  for (const auto& iter : options.input_resource_dtypes_and_shapes) {\n    entries.push_back(AttrKeyAndValue(\"_input_resource_dtype\", iter.first,\n                                      DataTypeString(iter.second.dtype)));\n    entries.push_back(AttrKeyAndValue(\"_input_resource_shape\", iter.first,\n                                      iter.second.shape.DebugString(),\n                                      AttrKeyAndValue::kCEscape));\n  }\n  if (options.lib_def) {\n    entries.push_back(AttrKeyAndValue(\n        \"_lib_def\", -1,\n        absl::StrCat(\"\", reinterpret_cast<uintptr_t>(options.lib_def))));\n  }\n  if (!options.state_handle.empty()) {\n    entries.push_back(\n        AttrKeyAndValue(\"_state_handle\", -1, options.state_handle));\n  }\n  string executor_type = FunctionLibraryRuntime::ExecutorType(options, attrs);\n  if (!executor_type.empty()) {\n    entries.push_back(AttrKeyAndValue(kExecutorAttr, -1, executor_type));\n  }\n  if (options.config_proto.ByteSize() > 0) {\n    string config_proto_serialized;\n    SerializeToStringDeterministic(options.config_proto,\n                                   &config_proto_serialized);\n    entries.push_back(AttrKeyAndValue(\"_config_proto\", -1,\n                                      config_proto_serialized,\n                                      AttrKeyAndValue::kCEscape));\n  }\n  std::sort(entries.begin(), entries.end());\n  string result = strings::StrCat(funcname, \"[\");\n  bool first = true;\n  for (const auto& entry : entries) {\n    entry.AppendTo(first, &result);\n    first = false;\n  }\n  result += \"]\";\n  return result;\n}","target":0,"code_token_length":595,"total_token_length":831,"max_tokens_setting":1024}
+{"idx":353149,"func":"static void clipColor(int rIn, int gIn, int bIn,\n\t\t      unsigned char *rOut, unsigned char *gOut, unsigned char *bOut) {\n  int lum, rgbMin, rgbMax;\n\n  lum = getLum(rIn, gIn, bIn);\n  rgbMin = rgbMax = rIn;\n  if (gIn < rgbMin) {\n    rgbMin = gIn;\n  } else if (gIn > rgbMax) {\n    rgbMax = gIn;\n  }\n  if (bIn < rgbMin) {\n    rgbMin = bIn;\n  } else if (bIn > rgbMax) {\n    rgbMax = bIn;\n  }\n  if (rgbMin < 0) {\n    *rOut = (unsigned char)(lum + ((rIn - lum) * lum) \/ (lum - rgbMin));\n    *gOut = (unsigned char)(lum + ((gIn - lum) * lum) \/ (lum - rgbMin));\n    *bOut = (unsigned char)(lum + ((bIn - lum) * lum) \/ (lum - rgbMin));\n  } else if (rgbMax > 255) {\n    *rOut = (unsigned char)(lum + ((rIn - lum) * (255 - lum)) \/ (rgbMax - lum));\n    *gOut = (unsigned char)(lum + ((gIn - lum) * (255 - lum)) \/ (rgbMax - lum));\n    *bOut = (unsigned char)(lum + ((bIn - lum) * (255 - lum)) \/ (rgbMax - lum));\n  } else {\n    *rOut = rIn;\n    *gOut = gIn;\n    *bOut = bIn;\n  }\n}","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":409410,"func":"parse_builtin_tcap(char_u *term)\n{\n    struct builtin_term\t    *p;\n    char_u\t\t    name[2];\n    int\t\t\t    term_8bit;\n\n    p = find_builtin_term(term);\n    term_8bit = term_is_8bit(term);\n\n    \/\/ Do not parse if builtin term not found\n    if (p->bt_string == NULL)\n\treturn;\n\n    for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p)\n    {\n\tif ((int)p->bt_entry >= 0)\t\/\/ KS_xx entry\n\t{\n\t    \/\/ Only set the value if it wasn't set yet.\n\t    if (term_strings[p->bt_entry] == NULL\n\t\t\t\t || term_strings[p->bt_entry] == empty_option)\n\t    {\n#ifdef FEAT_EVAL\n\t\tint opt_idx = -1;\n#endif\n\t\t\/\/ 8bit terminal: use CSI instead of <Esc>[\n\t\tif (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0)\n\t\t{\n\t\t    char_u  *s, *t;\n\n\t\t    s = vim_strsave((char_u *)p->bt_string);\n\t\t    if (s != NULL)\n\t\t    {\n\t\t\tfor (t = s; *t; ++t)\n\t\t\t    if (term_7to8bit(t))\n\t\t\t    {\n\t\t\t\t*t = term_7to8bit(t);\n\t\t\t\tSTRMOVE(t + 1, t + 2);\n\t\t\t    }\n\t\t\tterm_strings[p->bt_entry] = s;\n#ifdef FEAT_EVAL\n\t\t\topt_idx =\n#endif\n\t\t\t\t  set_term_option_alloced(\n\t\t\t\t\t\t   &term_strings[p->bt_entry]);\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    term_strings[p->bt_entry] = (char_u *)p->bt_string;\n#ifdef FEAT_EVAL\n\t\t    opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]);\n#endif\n\t\t}\n#ifdef FEAT_EVAL\n\t\tset_term_option_sctx_idx(NULL, opt_idx);\n#endif\n\t    }\n\t}\n\telse\n\t{\n\t    name[0] = KEY2TERMCAP0((int)p->bt_entry);\n\t    name[1] = KEY2TERMCAP1((int)p->bt_entry);\n\t    if (find_termcode(name) == NULL)\n\t\tadd_termcode(name, (char_u *)p->bt_string, term_8bit);\n\t}\n    }\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":452251,"func":"static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params TSRMLS_DC)\n{\n\n\tint parsize;\n\tzval **value;\n\tchar *xpath_expr, *string_key = NULL;\n\tulong num_key;\n\tchar **params = NULL;\n\tint i = 0;\n\n\tparsize = (2 * zend_hash_num_elements(parht) + 1) * sizeof(char *);\n\tparams = (char **)safe_emalloc((2 * zend_hash_num_elements(parht) + 1), sizeof(char *), 0);\n\tmemset((char *)params, 0, parsize);\n\n\tfor (zend_hash_internal_pointer_reset(parht);\n\t\tzend_hash_get_current_data(parht, (void **)&value) == SUCCESS;\n\t\tzend_hash_move_forward(parht)) {\n\n\t\tif (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Invalid argument or parameter array\");\n\t\t\tefree(params);\n\t\t\treturn NULL;\n\t\t} else {\n\t\t\tif (Z_TYPE_PP(value) != IS_STRING) {\n\t\t\t\tSEPARATE_ZVAL(value);\n\t\t\t\tconvert_to_string(*value);\n\t\t\t}\n\n\t\t\tif (!xpath_params) {\n\t\t\t\txpath_expr = php_xsl_xslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC);\n\t\t\t} else {\n\t\t\t\txpath_expr = estrndup(Z_STRVAL_PP(value), Z_STRLEN_PP(value));\n\t\t\t}\n\t\t\tif (xpath_expr) {\n\t\t\t\tparams[i++] = string_key;\n\t\t\t\tparams[i++] = xpath_expr;\n\t\t\t} else {\n\t\t\t\tefree(string_key);\n\t\t\t}\n\t\t}\n\t}\n\n\tparams[i++] = NULL;\n\n\treturn params;\n}","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":455354,"func":"wdequote_pathname (pathname)\n     char *pathname;\n{\n  mbstate_t ps;\n  size_t len, n;\n  wchar_t *wpathname;\n  int i, j;\n  wchar_t *orig_wpathname;\n\n  if (mbsmbchar (pathname) == 0)\n    {\n      udequote_pathname (pathname);\n      return;\n    }\n\n  len = strlen (pathname);\n  \/* Convert the strings into wide characters.  *\/\n  n = xdupmbstowcs (&wpathname, NULL, pathname);\n  if (n == (size_t) -1)\n    {\n      \/* Something wrong.  Fall back to single-byte *\/\n      udequote_pathname (pathname);\n      return;\n    }\n  orig_wpathname = wpathname;\n\n  for (i = j = 0; wpathname && wpathname[i]; )\n    {\n      if (wpathname[i] == L'\\\\')\n\ti++;\n\n      wpathname[j++] = wpathname[i++];\n\n      if (wpathname[i - 1] == L'\\0')\n\tbreak;\n    }\n  if (wpathname)\n    wpathname[j] = L'\\0';\n\n  \/* Convert the wide character string into unibyte character set. *\/\n  memset (&ps, '\\0', sizeof(mbstate_t));\n  n = wcsrtombs(pathname, (const wchar_t **)&wpathname, len, &ps);\n  pathname[len] = '\\0';\n\n  \/* Can't just free wpathname here; wcsrtombs changes it in many cases. *\/\n  free (orig_wpathname);\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":254898,"func":"shared_ptr<Sorter<Value, Value>::Iterator> DocumentSourceGroup::spill() {\n    _usedDisk = true;\n    vector<const GroupsMap::value_type*> ptrs;  \/\/ using pointers to speed sorting\n    ptrs.reserve(_groups->size());\n    for (GroupsMap::const_iterator it = _groups->begin(), end = _groups->end(); it != end; ++it) {\n        ptrs.push_back(&*it);\n    }\n\n    stable_sort(ptrs.begin(), ptrs.end(), SpillSTLComparator(pExpCtx->getValueComparator()));\n\n    SortedFileWriter<Value, Value> writer(SortOptions().TempDir(pExpCtx->tempDir), _file);\n    switch (_accumulatedFields.size()) {  \/\/ same as ptrs[i]->second.size() for all i.\n        case 0:                           \/\/ no values, essentially a distinct\n            for (size_t i = 0; i < ptrs.size(); i++) {\n                writer.addAlreadySorted(ptrs[i]->first, Value());\n            }\n            break;\n\n        case 1:  \/\/ just one value, use optimized serialization as single Value\n            for (size_t i = 0; i < ptrs.size(); i++) {\n                writer.addAlreadySorted(ptrs[i]->first,\n                                        ptrs[i]->second[0]->getValue(\/*toBeMerged=*\/true));\n            }\n            break;\n\n        default:  \/\/ multiple values, serialize as array-typed Value\n            for (size_t i = 0; i < ptrs.size(); i++) {\n                vector<Value> accums;\n                for (size_t j = 0; j < ptrs[i]->second.size(); j++) {\n                    accums.push_back(ptrs[i]->second[j]->getValue(\/*toBeMerged=*\/true));\n                }\n                writer.addAlreadySorted(ptrs[i]->first, Value(std::move(accums)));\n            }\n            break;\n    }\n\n    _groups->clear();\n\n    Sorter<Value, Value>::Iterator* iteratorPtr = writer.done();\n    return shared_ptr<Sorter<Value, Value>::Iterator>(iteratorPtr);\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":424908,"func":"static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num,\n\t\t\t    const struct fw_desc *section)\n{\n\tu8 *v_addr;\n\tdma_addr_t p_addr;\n\tu32 offset, chunk_sz = min_t(u32, FH_MEM_TB_MAX_LENGTH, section->len);\n\tint ret = 0;\n\n\tIWL_DEBUG_FW(trans, \"[%d] uCode section being loaded...\\n\",\n\t\t     section_num);\n\n\tv_addr = dma_alloc_coherent(trans->dev, chunk_sz, &p_addr,\n\t\t\t\t    GFP_KERNEL | __GFP_NOWARN);\n\tif (!v_addr) {\n\t\tIWL_DEBUG_INFO(trans, \"Falling back to small chunks of DMA\\n\");\n\t\tchunk_sz = PAGE_SIZE;\n\t\tv_addr = dma_alloc_coherent(trans->dev, chunk_sz,\n\t\t\t\t\t    &p_addr, GFP_KERNEL);\n\t\tif (!v_addr)\n\t\t\treturn -ENOMEM;\n\t}\n\n\tfor (offset = 0; offset < section->len; offset += chunk_sz) {\n\t\tu32 copy_size, dst_addr;\n\t\tbool extended_addr = false;\n\n\t\tcopy_size = min_t(u32, chunk_sz, section->len - offset);\n\t\tdst_addr = section->offset + offset;\n\n\t\tif (dst_addr >= IWL_FW_MEM_EXTENDED_START &&\n\t\t    dst_addr <= IWL_FW_MEM_EXTENDED_END)\n\t\t\textended_addr = true;\n\n\t\tif (extended_addr)\n\t\t\tiwl_set_bits_prph(trans, LMPM_CHICK,\n\t\t\t\t\t  LMPM_CHICK_EXTENDED_ADDR_SPACE);\n\n\t\tmemcpy(v_addr, (u8 *)section->data + offset, copy_size);\n\t\tret = iwl_pcie_load_firmware_chunk(trans, dst_addr, p_addr,\n\t\t\t\t\t\t   copy_size);\n\n\t\tif (extended_addr)\n\t\t\tiwl_clear_bits_prph(trans, LMPM_CHICK,\n\t\t\t\t\t    LMPM_CHICK_EXTENDED_ADDR_SPACE);\n\n\t\tif (ret) {\n\t\t\tIWL_ERR(trans,\n\t\t\t\t\"Could not load the [%d] uCode section\\n\",\n\t\t\t\tsection_num);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tdma_free_coherent(trans->dev, chunk_sz, v_addr, p_addr);\n\treturn ret;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":197185,"func":"static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const uint8_t *buf, int size)\n{\n    GetBitContext gb;\n    PutBitContext pb;\n    MPEG4AudioConfig m4ac;\n    int off;\n\n    init_get_bits(&gb, buf, size * 8);\n    off = avpriv_mpeg4audio_get_config2(&m4ac, buf, size, 1, s);\n    if (off < 0)\n        return off;\n    skip_bits_long(&gb, off);\n    adts->objecttype        = m4ac.object_type - 1;\n    adts->sample_rate_index = m4ac.sampling_index;\n    adts->channel_conf      = m4ac.chan_config;\n\n    if (adts->objecttype > 3U) {\n        av_log(s, AV_LOG_ERROR, \"MPEG-4 AOT %d is not allowed in ADTS\\n\", adts->objecttype+1);\n        return AVERROR_INVALIDDATA;\n    }\n    if (adts->sample_rate_index == 15) {\n        av_log(s, AV_LOG_ERROR, \"Escape sample rate index illegal in ADTS\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n    if (get_bits(&gb, 1)) {\n        av_log(s, AV_LOG_ERROR, \"960\/120 MDCT window is not allowed in ADTS\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n    if (get_bits(&gb, 1)) {\n        av_log(s, AV_LOG_ERROR, \"Scalable configurations are not allowed in ADTS\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n    if (get_bits(&gb, 1)) {\n        av_log(s, AV_LOG_ERROR, \"Extension flag is not allowed in ADTS\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n    if (!adts->channel_conf) {\n        init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);\n\n        put_bits(&pb, 3, 5); \/\/ID_PCE\n        adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) \/ 8;\n        flush_put_bits(&pb);\n    }\n\n    adts->write_adts = 1;\n\n    return 0;\n}","target":1,"code_token_length":500,"total_token_length":736,"max_tokens_setting":1024}
+{"idx":246445,"func":"static RPVector *parse_sub_section_vec(RBinWasmObj *bin, RBinWasmSection *sec) {\n\tRPVector **cache = NULL;\n\tRPVectorFree pfree = (RPVectorFree)free;\n\tParseEntryFcn parser;\n\tswitch (sec->id) {\n\tcase R_BIN_WASM_SECTION_TYPE:\n\t\tparser = (ParseEntryFcn)parse_type_entry;\n\t\tpfree = (RPVectorFree)free_type_entry;\n\t\tcache = &bin->g_types;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_IMPORT:\n\t\tparser = (ParseEntryFcn)parse_import_entry;\n\t\tpfree = (RPVectorFree)free_import_entry;\n\t\tcache = &bin->g_imports;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_FUNCTION:\n\t\tparser = (ParseEntryFcn)parse_function_entry;\n\t\tcache = &bin->g_funcs;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_TABLE:\n\t\tparser = (ParseEntryFcn)parse_table_entry;\n\t\tcache = &bin->g_tables;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_MEMORY:\n\t\tparser = (ParseEntryFcn)parse_memory_entry;\n\t\tcache = &bin->g_memories;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_GLOBAL:\n\t\tparser = (ParseEntryFcn)parse_global_entry;\n\t\tcache = &bin->g_globals;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_EXPORT:\n\t\tparser = (ParseEntryFcn)parse_export_entry;\n\t\tpfree = (RPVectorFree)free_export_entry;\n\t\tcache = &bin->g_exports;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_ELEMENT:\n\t\tparser = (ParseEntryFcn)parse_element_entry;\n\t\tcache = &bin->g_elements;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_CODE:\n\t\tparser = (ParseEntryFcn)parse_code_entry;\n\t\tpfree = (RPVectorFree)free_code_entry;\n\t\tcache = &bin->g_codes;\n\t\tbreak;\n\tcase R_BIN_WASM_SECTION_DATA:\n\t\tparser = (ParseEntryFcn)parse_data_entry;\n\t\tcache = &bin->g_datas;\n\t\tbreak;\n\tdefault:\n\t\treturn NULL;\n\t}\n\n\tRBuffer *buf = bin->buf;\n\tut64 offset = sec->payload_data;\n\tut64 len = sec->payload_len;\n\tut64 bound = offset + len - 1;\n\n\tif (bound >= r_buf_size (buf)) {\n\t\tr_warn_if_reached (); \/\/ section parsing should prevent this\n\t\teprintf (\"[wasm] End of %s section data is beyond file end\\n\", sec->name);\n\t\treturn NULL;\n\t}\n\tif (r_buf_seek (buf, offset, R_BUF_SET) != offset) {\n\t\treturn NULL;\n\t}\n\n\t*cache = parse_vec (bin, bound, parser, pfree);\n\treturn *cache;\n}","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":463118,"func":"static int annotate_state_set_scope(annotate_state_t *state,\n                                    const mbentry_t *mbentry,\n                                    struct mailbox *mailbox,\n                                    unsigned int uid)\n{\n    int r = 0;\n    annotate_db_t *oldd = NULL;\n    int oldwhich = state->which;\n\n    init_internal();\n\n    \/* Carefully preserve the reference on the old DB just in case it\n     * turns out to be the same as the new DB, so we avoid the overhead\n     * of an unnecessary cyrusdb_open\/close pair. *\/\n    oldd = state->d;\n    state->d = NULL;\n\n    annotate_state_unset_scope(state);\n\n    if (mbentry) {\n        assert(!mailbox);\n        assert(!uid);\n        if (!mbentry->server) {\n            \/* local mailbox *\/\n            r = mailbox_open_iwl(mbentry->name, &mailbox);\n            if (r)\n                goto out;\n            state->ourmailbox = mailbox;\n        }\n        state->mbentry = mbentry;\n        state->which = ANNOTATION_SCOPE_MAILBOX;\n    }\n\n    else if (uid) {\n        assert(mailbox);\n        state->which = ANNOTATION_SCOPE_MESSAGE;\n    }\n    else if (mailbox) {\n        assert(!uid);\n        state->which = ANNOTATION_SCOPE_MAILBOX;\n    }\n    else {\n        assert(!mailbox);\n        assert(!uid);\n        state->which = ANNOTATION_SCOPE_SERVER;\n    }\n    assert(oldwhich == ANNOTATION_SCOPE_UNKNOWN ||\n           oldwhich == state->which);\n    state->mailbox = mailbox;\n    state->uid = uid;\n\n    r = _annotate_getdb(mailbox ? mailbox->name : NULL, uid,\n                        CYRUSDB_CREATE, &state->d);\n\nout:\n    annotate_putdb(&oldd);\n    return r;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":317331,"func":"static int inode_doinit_use_xattr(struct inode *inode, struct dentry *dentry,\n\t\t\t\t  u32 def_sid, u32 *sid)\n{\n#define INITCONTEXTLEN 255\n\tchar *context;\n\tunsigned int len;\n\tint rc;\n\n\tlen = INITCONTEXTLEN;\n\tcontext = kmalloc(len + 1, GFP_NOFS);\n\tif (!context)\n\t\treturn -ENOMEM;\n\n\tcontext[len] = '\\0';\n\trc = __vfs_getxattr(dentry, inode, XATTR_NAME_SELINUX, context, len);\n\tif (rc == -ERANGE) {\n\t\tkfree(context);\n\n\t\t\/* Need a larger buffer.  Query for the right size. *\/\n\t\trc = __vfs_getxattr(dentry, inode, XATTR_NAME_SELINUX, NULL, 0);\n\t\tif (rc < 0)\n\t\t\treturn rc;\n\n\t\tlen = rc;\n\t\tcontext = kmalloc(len + 1, GFP_NOFS);\n\t\tif (!context)\n\t\t\treturn -ENOMEM;\n\n\t\tcontext[len] = '\\0';\n\t\trc = __vfs_getxattr(dentry, inode, XATTR_NAME_SELINUX,\n\t\t\t\t    context, len);\n\t}\n\tif (rc < 0) {\n\t\tkfree(context);\n\t\tif (rc != -ENODATA) {\n\t\t\tpr_warn(\"SELinux: %s:  getxattr returned %d for dev=%s ino=%ld\\n\",\n\t\t\t\t__func__, -rc, inode->i_sb->s_id, inode->i_ino);\n\t\t\treturn rc;\n\t\t}\n\t\t*sid = def_sid;\n\t\treturn 0;\n\t}\n\n\trc = security_context_to_sid_default(&selinux_state, context, rc, sid,\n\t\t\t\t\t     def_sid, GFP_NOFS);\n\tif (rc) {\n\t\tchar *dev = inode->i_sb->s_id;\n\t\tunsigned long ino = inode->i_ino;\n\n\t\tif (rc == -EINVAL) {\n\t\t\tpr_notice_ratelimited(\"SELinux: inode=%lu on dev=%s was found to have an invalid context=%s.  This indicates you may need to relabel the inode or the filesystem in question.\\n\",\n\t\t\t\t\t      ino, dev, context);\n\t\t} else {\n\t\t\tpr_warn(\"SELinux: %s:  context_to_sid(%s) returned %d for dev=%s ino=%ld\\n\",\n\t\t\t\t__func__, context, -rc, dev, ino);\n\t\t}\n\t}\n\tkfree(context);\n\treturn 0;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":255768,"func":"init_lockup_state(lookup_state_t *state,\n                  node_t *root,\n                  const char *path)\n{\n  apr_size_t len = strlen(path);\n  if (   (len > state->parent_path->len)\n      && state->parent_path->len\n      && (path[state->parent_path->len] == '\/')\n      && !memcmp(path, state->parent_path->data, state->parent_path->len))\n    {\n      \/* The PARENT_PATH of the previous lookup is actually a parent path\n       * of PATH.  The CURRENT node list already matches the parent path\n       * and we only have to set the correct rights info. *\/\n      state->rights = state->parent_rights;\n\n      \/* Tell the caller where to proceed. *\/\n      return path + state->parent_path->len;\n    }\n\n  \/* Start lookup at ROOT for the full PATH. *\/\n  state->rights = root->rights;\n  state->parent_rights = root->rights;\n\n  apr_array_clear(state->next);\n  apr_array_clear(state->current);\n  APR_ARRAY_PUSH(state->current, node_t *) = root;\n\n  \/* Var-segment rules match empty segments as well *\/\n  if (root->pattern_sub_nodes && root->pattern_sub_nodes->any_var)\n   {\n      node_t *node = root->pattern_sub_nodes->any_var;\n\n      \/* This is non-recursive due to ACL normalization. *\/\n      combine_access(&state->rights, &node->rights);\n      combine_right_limits(&state->rights, &node->rights);\n      APR_ARRAY_PUSH(state->current, node_t *) = node;\n   }\n\n  svn_stringbuf_setempty(state->parent_path);\n  svn_stringbuf_setempty(state->scratch_pad);\n\n  return path;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":366242,"func":"int finish_automount(struct vfsmount *m, struct path *path)\n{\n\tstruct dentry *dentry = path->dentry;\n\tstruct mountpoint *mp;\n\tstruct mount *mnt;\n\tint err;\n\n\tif (!m)\n\t\treturn 0;\n\tif (IS_ERR(m))\n\t\treturn PTR_ERR(m);\n\n\tmnt = real_mount(m);\n\t\/* The new mount record should have at least 2 refs to prevent it being\n\t * expired before we get a chance to add it\n\t *\/\n\tBUG_ON(mnt_get_count(mnt) < 2);\n\n\tif (m->mnt_sb == path->mnt->mnt_sb &&\n\t    m->mnt_root == dentry) {\n\t\terr = -ELOOP;\n\t\tgoto discard;\n\t}\n\n\t\/*\n\t * we don't want to use lock_mount() - in this case finding something\n\t * that overmounts our mountpoint to be means \"quitely drop what we've\n\t * got\", not \"try to mount it on top\".\n\t *\/\n\tinode_lock(dentry->d_inode);\n\tnamespace_lock();\n\tif (unlikely(cant_mount(dentry))) {\n\t\terr = -ENOENT;\n\t\tgoto discard_locked;\n\t}\n\trcu_read_lock();\n\tif (unlikely(__lookup_mnt(path->mnt, dentry))) {\n\t\trcu_read_unlock();\n\t\terr = 0;\n\t\tgoto discard_locked;\n\t}\n\trcu_read_unlock();\n\tmp = get_mountpoint(dentry);\n\tif (IS_ERR(mp)) {\n\t\terr = PTR_ERR(mp);\n\t\tgoto discard_locked;\n\t}\n\n\terr = do_add_mount(mnt, mp, path, path->mnt->mnt_flags | MNT_SHRINKABLE);\n\tunlock_mount(mp);\n\tif (unlikely(err))\n\t\tgoto discard;\n\tmntput(m);\n\treturn 0;\n\ndiscard_locked:\n\tnamespace_unlock();\n\tinode_unlock(dentry->d_inode);\ndiscard:\n\t\/* remove m from any expiration list it may be on *\/\n\tif (!list_empty(&mnt->mnt_expire)) {\n\t\tnamespace_lock();\n\t\tlist_del_init(&mnt->mnt_expire);\n\t\tnamespace_unlock();\n\t}\n\tmntput(m);\n\tmntput(m);\n\treturn err;\n}","target":0,"code_token_length":443,"total_token_length":679,"max_tokens_setting":1024}
+{"idx":326629,"func":"set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,\n    mode_t mode, unsigned long set, unsigned long clear)\n{\n\tint\t\t ret;\n\tint\t\t myfd = fd;\n\tint newflags, oldflags;\n\t\/*\n\t * Linux has no define for the flags that are only settable by\n\t * the root user.  This code may seem a little complex, but\n\t * there seem to be some Linux systems that lack these\n\t * defines. (?)  The code below degrades reasonably gracefully\n\t * if sf_mask is incomplete.\n\t *\/\n\tconst int sf_mask = 0\n#if defined(FS_IMMUTABLE_FL)\n\t    | FS_IMMUTABLE_FL\n#elif defined(EXT2_IMMUTABLE_FL)\n\t    | EXT2_IMMUTABLE_FL\n#endif\n#if defined(FS_APPEND_FL)\n\t    | FS_APPEND_FL\n#elif defined(EXT2_APPEND_FL)\n\t    | EXT2_APPEND_FL\n#endif\n#if defined(FS_JOURNAL_DATA_FL)\n\t    | FS_JOURNAL_DATA_FL\n#endif\n\t;\n\n\tif (set == 0 && clear == 0)\n\t\treturn (ARCHIVE_OK);\n\t\/* Only regular files and dirs can have flags. *\/\n\tif (!S_ISREG(mode) && !S_ISDIR(mode))\n\t\treturn (ARCHIVE_OK);\n\n\t\/* If we weren't given an fd, open it ourselves. *\/\n\tif (myfd < 0) {\n\t\tmyfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY |\n\t\t    O_CLOEXEC | O_NOFOLLOW);\n\t\t__archive_ensure_cloexec_flag(myfd);\n\t}\n\tif (myfd < 0)\n\t\treturn (ARCHIVE_OK);\n\n\t\/*\n\t * XXX As above, this would be way simpler if we didn't have\n\t * to read the current flags from disk. XXX\n\t *\/\n\tret = ARCHIVE_OK;\n\n\t\/* Read the current file flags. *\/\n\tif (ioctl(myfd,\n#ifdef FS_IOC_GETFLAGS\n\t    FS_IOC_GETFLAGS,\n#else\n\t    EXT2_IOC_GETFLAGS,\n#endif\n\t    &oldflags) < 0)\n\t\tgoto fail;\n\n\t\/* Try setting the flags as given. *\/\n\tnewflags = (oldflags & ~clear) | set;\n\tif (ioctl(myfd,\n#ifdef FS_IOC_SETFLAGS\n\t    FS_IOC_SETFLAGS,\n#else\n\t    EXT2_IOC_SETFLAGS,\n#endif\n\t    &newflags) >= 0)\n\t\tgoto cleanup;\n\tif (errno != EPERM)\n\t\tgoto fail;\n\n\t\/* If we couldn't set all the flags, try again with a subset. *\/\n\tnewflags &= ~sf_mask;\n\toldflags &= sf_mask;\n\tnewflags |= oldflags;\n\tif (ioctl(myfd,\n#ifdef FS_IOC_SETFLAGS\n\t    FS_IOC_SETFLAGS,\n#else\n\t    EXT2_IOC_SETFLAGS,\n#endif\n\t    &newflags) >= 0)\n\t\tgoto cleanup;\n\n\t\/* We couldn't set the flags, so report the failure. *\/\nfail:\n\tarchive_set_error(&a->archive, errno,\n\t    \"Failed to set file flags\");\n\tret = ARCHIVE_WARN;\ncleanup:\n\tif (fd < 0)\n\t\tclose(myfd);\n\treturn (ret);\n}","target":0,"code_token_length":661,"total_token_length":897,"max_tokens_setting":1024}
+{"idx":227004,"func":"IRC_PROTOCOL_CALLBACK(729)\n{\n    char *pos_args;\n    struct t_irc_channel *ptr_channel;\n    struct t_gui_buffer *ptr_buffer;\n    struct t_irc_modelist *ptr_modelist;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    pos_args = (argc > 5) ?\n        ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL;\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n    ptr_buffer = (ptr_channel && ptr_channel->nicks) ?\n        ptr_channel->buffer : server->buffer;\n    ptr_modelist = irc_modelist_search (ptr_channel, argv[4][0]);\n    if (ptr_modelist)\n    {\n        if (ptr_modelist->state != IRC_MODELIST_STATE_RECEIVING)\n        {\n            \/*\n             * remove all items if no quiet was received before\n             * the end of quiet list\n             *\/\n            irc_modelist_item_free_all (ptr_modelist);\n        }\n        ptr_modelist->state = IRC_MODELIST_STATE_RECEIVED;\n    }\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (\n            server, NULL, command, \"quietlist\", ptr_buffer),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s[%s%s%s]%s%s%s\",\n        weechat_prefix (\"network\"),\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_CHAT_CHANNEL,\n        argv[3],\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_RESET,\n        (pos_args) ? \" \" : \"\",\n        (pos_args) ? pos_args : \"\");\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":238649,"func":"static void __reg32_deduce_bounds(struct bpf_reg_state *reg)\n{\n\t\/* Learn sign from signed bounds.\n\t * If we cannot cross the sign boundary, then signed and unsigned bounds\n\t * are the same, so combine.  This works even in the negative case, e.g.\n\t * -3 s<= x s<= -1 implies 0xf...fd u<= x u<= 0xf...ff.\n\t *\/\n\tif (reg->s32_min_value >= 0 || reg->s32_max_value < 0) {\n\t\treg->s32_min_value = reg->u32_min_value =\n\t\t\tmax_t(u32, reg->s32_min_value, reg->u32_min_value);\n\t\treg->s32_max_value = reg->u32_max_value =\n\t\t\tmin_t(u32, reg->s32_max_value, reg->u32_max_value);\n\t\treturn;\n\t}\n\t\/* Learn sign from unsigned bounds.  Signed bounds cross the sign\n\t * boundary, so we must be careful.\n\t *\/\n\tif ((s32)reg->u32_max_value >= 0) {\n\t\t\/* Positive.  We can't learn anything from the smin, but smax\n\t\t * is positive, hence safe.\n\t\t *\/\n\t\treg->s32_min_value = reg->u32_min_value;\n\t\treg->s32_max_value = reg->u32_max_value =\n\t\t\tmin_t(u32, reg->s32_max_value, reg->u32_max_value);\n\t} else if ((s32)reg->u32_min_value < 0) {\n\t\t\/* Negative.  We can't learn anything from the smax, but smin\n\t\t * is negative, hence safe.\n\t\t *\/\n\t\treg->s32_min_value = reg->u32_min_value =\n\t\t\tmax_t(u32, reg->s32_min_value, reg->u32_min_value);\n\t\treg->s32_max_value = reg->u32_max_value;\n\t}\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":352991,"func":"generalizedTimeNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tint parts[9], rc;\n\tunsigned int len;\n\tstruct berval fraction;\n\n\trc = check_time_syntax(val, 0, parts, &fraction);\n\tif (rc != LDAP_SUCCESS) {\n\t\treturn rc;\n\t}\n\n\tlen = STRLENOF(\"YYYYmmddHHMMSSZ\") + fraction.bv_len;\n\tnormalized->bv_val = slap_sl_malloc( len + 1, ctx );\n\tif ( BER_BVISNULL( normalized ) ) {\n\t\treturn LBER_ERROR_MEMORY;\n\t}\n\n\tsprintf( normalized->bv_val, \"%02d%02d%02d%02d%02d%02d%02d\",\n\t\tparts[0], parts[1], parts[2] + 1, parts[3] + 1,\n\t\tparts[4], parts[5], parts[6] );\n\tif ( !BER_BVISEMPTY( &fraction ) ) {\n\t\tmemcpy( normalized->bv_val + STRLENOF(\"YYYYmmddHHMMSSZ\")-1,\n\t\t\tfraction.bv_val, fraction.bv_len );\n\t\tnormalized->bv_val[STRLENOF(\"YYYYmmddHHMMSSZ\")-1] = '.';\n\t}\n\tstrcpy( normalized->bv_val + len-1, \"Z\" );\n\tnormalized->bv_len = len;\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":232830,"func":"  void Compute(OpKernelContext* const context) override {\n    \/\/ Read float features list;\n    OpInputList float_features_list;\n    OP_REQUIRES_OK(\n        context, context->input_list(kFloatFeaturesName, &float_features_list));\n    OpInputList bucket_boundaries_list;\n    OP_REQUIRES_OK(context, context->input_list(kBucketBoundariesName,\n                                                &bucket_boundaries_list));\n    OP_REQUIRES(context,\n                tensorflow::TensorShapeUtils::IsVector(\n                    bucket_boundaries_list[0].shape()),\n                errors::InvalidArgument(\n                    strings::Printf(\"Buckets should be flat vectors.\")));\n    OpOutputList buckets_list;\n    OP_REQUIRES_OK(context, context->output_list(kBucketsName, &buckets_list));\n\n    auto do_quantile_get_quantiles = [&](const int64_t begin,\n                                         const int64_t end) {\n      \/\/ Iterating over all resources\n      for (int64_t feature_idx = begin; feature_idx < end; feature_idx++) {\n        const Tensor& values_tensor = float_features_list[feature_idx];\n        const int64_t num_values = values_tensor.dim_size(0);\n\n        Tensor* output_t = nullptr;\n        OP_REQUIRES_OK(context,\n                       buckets_list.allocate(\n                           feature_idx, TensorShape({num_values}), &output_t));\n        auto output = output_t->flat<int32>();\n\n        const std::vector<float>& bucket_boundaries_vector =\n            GetBuckets(feature_idx, bucket_boundaries_list);\n        auto flat_values = values_tensor.flat<float>();\n        const auto& iter_begin = bucket_boundaries_vector.begin();\n        const auto& iter_end = bucket_boundaries_vector.end();\n        for (int64_t instance = 0; instance < num_values; instance++) {\n          if (iter_begin == iter_end) {\n            output(instance) = 0;\n            continue;\n          }\n          const float value = flat_values(instance);\n          auto bucket_iter = std::lower_bound(iter_begin, iter_end, value);\n          if (bucket_iter == iter_end) {\n            --bucket_iter;\n          }\n          const int32_t bucket = static_cast<int32>(bucket_iter - iter_begin);\n          \/\/ Bucket id.\n          output(instance) = bucket;\n        }\n      }\n    };\n\n    \/\/ TODO(tanzheny): comment on the magic number.\n    const int64_t kCostPerUnit = 500 * num_features_;\n    const DeviceBase::CpuWorkerThreads& worker_threads =\n        *context->device()->tensorflow_cpu_worker_threads();\n    Shard(worker_threads.num_threads, worker_threads.workers, num_features_,\n          kCostPerUnit, do_quantile_get_quantiles);\n  }","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":269325,"func":"ReduceDetails SparseTensorReduceHelper(const SparseTensor &sp,\n                                       gtl::ArraySlice<int32> axes_slice,\n                                       bool keep_dims) {\n  ReduceDetails reduction;\n\n  std::vector<int32> reduction_axes(axes_slice.begin(), axes_slice.end());\n  int ndims = sp.dims();\n  for (int64_t i = 0; i < reduction_axes.size(); ++i) {\n    reduction_axes[i] = (reduction_axes[i] + ndims) % ndims;\n  }\n  std::sort(reduction_axes.begin(), reduction_axes.end());\n\n  \/\/ (0) Calculate the grouping dimensions:\n  \/\/ group_by_dims == {0, .., NDIMS-1} \\ reduction_axes.\n  std::vector<int64> perm(ndims);\n  std::iota(perm.begin(), perm.end(), 0);\n\n  \/\/ Requires perm and reduction_axes_ be sorted; group_by_dims will be\n  \/\/ sorted as well.\n  std::set_difference(\n      perm.begin(), perm.end(), reduction_axes.begin(), reduction_axes.end(),\n      std::inserter(reduction.group_by_dims, reduction.group_by_dims.begin()));\n\n  \/\/ Now append the rest of the axes (the complement of group_by_dims_);\n  \/\/ result is used by Reorder().\n  reduction.reorder_dims = reduction.group_by_dims;\n  std::set_difference(perm.begin(), perm.end(), reduction.group_by_dims.begin(),\n                      reduction.group_by_dims.end(),\n                      std::back_inserter(reduction.reorder_dims));\n\n  \/\/ (1) Calculate the shape after reduction.\n  auto sp_shape = sp.shape();\n  std::vector<int64> out_dim_sizes;\n  if (keep_dims) {\n    out_dim_sizes.reserve(ndims);\n    auto beg = reduction.group_by_dims.begin();\n    auto end = reduction.group_by_dims.end();\n    for (int d = 0; d < ndims; ++d) {\n      if (std::find(beg, end, d) == end) {\n        out_dim_sizes.push_back(1);  \/\/ A reduced axis.\n      } else {\n        out_dim_sizes.push_back(sp_shape[d]);\n      }\n    }\n  } else {\n    out_dim_sizes = sp.PickDims(reduction.group_by_dims);\n  }\n\n  reduction.reduced_shape = TensorShape(out_dim_sizes);\n  return reduction;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":240609,"func":"Status CopyVariable(int output_idx, OpKernelContext* ctx, const Tensor* t) {\n  Tensor* output;\n  Notification n;\n  Status status;\n  AllocatorAttributes attr;\n  if (t->dtype() == DT_VARIANT) {\n    attr.set_on_host(true);\n  }\n  TF_RETURN_IF_ERROR(\n      ctx->allocate_output(output_idx, t->shape(), &output, attr));\n  if (t->dtype() == DT_VARIANT) {\n    output->flat<Variant>() = t->flat<Variant>();\n  } else if (ctx->op_device_context() != nullptr) {\n    \/\/ TODO(apassos): remove the down_cast by just returning Device* from\n    \/\/ OpKernelContext\n    Device* device = down_cast<Device*>(ctx->device());\n    ctx->op_device_context()->CopyTensorInSameDevice(\n        t, device, output, [&n, &status](const Status& s) {\n          status = s;\n          n.Notify();\n        });\n    n.WaitForNotification();\n    return status;\n  } else {\n    switch (t->dtype()) {\n#define HANDLER(type)                       \\\n  case DataTypeToEnum<type>::value:         \\\n    output->flat<type>() = t->flat<type>(); \\\n    break;\n      TF_CALL_ALL_TYPES(HANDLER);\n#undef HANDLER\n      default:\n        return errors::Internal(\"Unsupported dtype\", t->dtype());\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":314759,"func":"cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,\n    const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,\n    const cdf_dir_t *dir)\n{\n\tsize_t i, j;\n\tcdf_directory_t *d;\n\tchar name[__arraycount(d->d_name)];\n\tcdf_stream_t scn;\n\tstruct timeval ts;\n\n\tstatic const char *types[] = { \"empty\", \"user storage\",\n\t    \"user stream\", \"lockbytes\", \"property\", \"root storage\" };\n\n\tfor (i = 0; i < dir->dir_len; i++) {\n\t\td = &dir->dir_tab[i];\n\t\tfor (j = 0; j < sizeof(name); j++)\n\t\t\tname[j] = (char)CDF_TOLE2(d->d_name[j]);\n\t\t(void)fprintf(stderr, \"Directory %\" SIZE_T_FORMAT \"u: %s\\n\",\n\t\t    i, name);\n\t\tif (d->d_type < __arraycount(types))\n\t\t\t(void)fprintf(stderr, \"Type: %s\\n\", types[d->d_type]);\n\t\telse\n\t\t\t(void)fprintf(stderr, \"Type: %d\\n\", d->d_type);\n\t\t(void)fprintf(stderr, \"Color: %s\\n\",\n\t\t    d->d_color ? \"black\" : \"red\");\n\t\t(void)fprintf(stderr, \"Left child: %d\\n\", d->d_left_child);\n\t\t(void)fprintf(stderr, \"Right child: %d\\n\", d->d_right_child);\n\t\t(void)fprintf(stderr, \"Flags: 0x%x\\n\", d->d_flags);\n\t\tcdf_timestamp_to_timespec(&ts, d->d_created);\n\t\t(void)fprintf(stderr, \"Created %s\", cdf_ctime(&ts.tv_sec));\n\t\tcdf_timestamp_to_timespec(&ts, d->d_modified);\n\t\t(void)fprintf(stderr, \"Modified %s\", cdf_ctime(&ts.tv_sec));\n\t\t(void)fprintf(stderr, \"Stream %d\\n\", d->d_stream_first_sector);\n\t\t(void)fprintf(stderr, \"Size %d\\n\", d->d_size);\n\t\tswitch (d->d_type) {\n\t\tcase CDF_DIR_TYPE_USER_STORAGE:\n\t\t\t(void)fprintf(stderr, \"Storage: %d\\n\", d->d_storage);\n\t\t\tbreak;\n\t\tcase CDF_DIR_TYPE_USER_STREAM:\n\t\t\tif (sst == NULL)\n\t\t\t\tbreak;\n\t\t\tif (cdf_read_sector_chain(info, h, sat, ssat, sst,\n\t\t\t    d->d_stream_first_sector, d->d_size, &scn) == -1) {\n\t\t\t\twarn(\"Can't read stream for %s at %d len %d\",\n\t\t\t\t    name, d->d_stream_first_sector, d->d_size);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcdf_dump_stream(h, &scn);\n\t\t\tfree(scn.sst_tab);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t}\n}","target":0,"code_token_length":633,"total_token_length":869,"max_tokens_setting":1024}
+{"idx":512603,"func":"bool Item_equal::fix_fields(THD *thd, Item **ref)\n{ \n  DBUG_ASSERT(fixed == 0);\n  Item_equal_fields_iterator it(*this);\n  Item *item;\n  Field *first_equal_field= NULL;\n  Field *last_equal_field= NULL;\n  Field *prev_equal_field= NULL;\n  not_null_tables_cache= used_tables_cache= 0;\n  const_item_cache= 0;\n  while ((item= it++))\n  {\n    table_map tmp_table_map;\n    used_tables_cache|= item->used_tables();\n    tmp_table_map= item->not_null_tables();\n    not_null_tables_cache|= tmp_table_map;\n    DBUG_ASSERT(!item->with_sum_func() && !item->with_subquery());\n    if (item->maybe_null)\n      maybe_null= 1;\n    if (!item->get_item_equal())\n      item->set_item_equal(this);\n    if (link_equal_fields && item->real_item()->type() == FIELD_ITEM)\n    {\n      last_equal_field= ((Item_field *) (item->real_item()))->field;\n      if (!prev_equal_field)\n        first_equal_field= last_equal_field;\n      else\n        prev_equal_field->next_equal_field= last_equal_field;\n      prev_equal_field= last_equal_field;         \n    }\n  }\n  if (prev_equal_field && last_equal_field != first_equal_field)\n    last_equal_field->next_equal_field= first_equal_field;\n  if (fix_length_and_dec())\n    return TRUE;\n  fixed= 1;\n  return FALSE;\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":301470,"func":"badword_captype(char_u *word, char_u *end)\n{\n    int\t\tflags = captype(word, end);\n    int\t\tc;\n    int\t\tl, u;\n    int\t\tfirst;\n    char_u\t*p;\n\n    if (flags & WF_KEEPCAP)\n    {\n\t\/\/ Count the number of UPPER and lower case letters.\n\tl = u = 0;\n\tfirst = FALSE;\n\tfor (p = word; p < end; MB_PTR_ADV(p))\n\t{\n\t    c = PTR2CHAR(p);\n\t    if (SPELL_ISUPPER(c))\n\t    {\n\t\t++u;\n\t\tif (p == word)\n\t\t    first = TRUE;\n\t    }\n\t    else\n\t\t++l;\n\t}\n\n\t\/\/ If there are more UPPER than lower case letters suggest an\n\t\/\/ ALLCAP word.  Otherwise, if the first letter is UPPER then\n\t\/\/ suggest ONECAP.  Exception: \"ALl\" most likely should be \"All\",\n\t\/\/ require three upper case letters.\n\tif (u > l && u > 2)\n\t    flags |= WF_ALLCAP;\n\telse if (first)\n\t    flags |= WF_ONECAP;\n\n\tif (u >= 2 && l >= 2)\t\/\/ maCARONI maCAroni\n\t    flags |= WF_MIXCAP;\n    }\n    return flags;\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":231674,"func":"TEST_F(\n    QuicUnencryptedServerTransportTest,\n    IncreaseLimitAfterReceivingNewPacket) {\n  auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);\n  server->getNonConstConn().qLogger = qLogger;\n  getFakeHandshakeLayer()->allowZeroRttKeys();\n  server->getNonConstConn().transportSettings.zeroRttSourceTokenMatchingPolicy =\n      ZeroRttSourceTokenMatchingPolicy::LIMIT_IF_NO_EXACT_MATCH;\n\n  auto originalUdpSize = server->getConn().udpSendPacketLen;\n  setupClientReadCodec();\n\n  recvClientHello();\n  EXPECT_EQ(\n      *server->getNonConstConn().writableBytesLimit,\n      server->getConn().transportSettings.limitedCwndInMss * originalUdpSize);\n\n  recvClientHello();\n\n  \/\/ in tests the udp packet length changes\n  auto expectedLen =\n      server->getConn().transportSettings.limitedCwndInMss * originalUdpSize +\n      server->getConn().transportSettings.limitedCwndInMss *\n          server->getConn().udpSendPacketLen;\n  EXPECT_NE(originalUdpSize, server->getConn().udpSendPacketLen);\n  EXPECT_EQ(*server->getNonConstConn().writableBytesLimit, expectedLen);\n  std::vector<int> indices =\n      getQLogEventIndices(QLogEventType::TransportStateUpdate, qLogger);\n  EXPECT_EQ(indices.size(), 3);\n  std::array<::std::string, 3> updateArray = {\n      kDerivedZeroRttReadCipher, kDerivedOneRttWriteCipher, kTransportReady};\n  for (int i = 0; i < 3; ++i) {\n    auto tmp = std::move(qLogger->logs[indices[i]]);\n    auto event = dynamic_cast<QLogTransportStateUpdateEvent*>(tmp.get());\n    EXPECT_EQ(event->update, updateArray[i]);\n  }\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":274768,"func":"LCN ntfs_attr_vcn_to_lcn(ntfs_attr *na, const VCN vcn)\n{\n\tLCN lcn;\n\tBOOL is_retry = FALSE;\n\n\tif (!na || !NAttrNonResident(na) || vcn < 0)\n\t\treturn (LCN)LCN_EINVAL;\n\n\tntfs_log_trace(\"Entering for inode 0x%llx, attr 0x%x.\\n\", (unsigned long\n\t\t\tlong)na->ni->mft_no, le32_to_cpu(na->type));\nretry:\n\t\/* Convert vcn to lcn. If that fails map the runlist and retry once. *\/\n\tlcn = ntfs_rl_vcn_to_lcn(na->rl, vcn);\n\tif (lcn >= 0)\n\t\treturn lcn;\n\tif (!is_retry && !ntfs_attr_map_runlist(na, vcn)) {\n\t\tis_retry = TRUE;\n\t\tgoto retry;\n\t}\n\t\/*\n\t * If the attempt to map the runlist failed, or we are getting\n\t * LCN_RL_NOT_MAPPED despite having mapped the attribute extent\n\t * successfully, something is really badly wrong...\n\t *\/\n\tif (!is_retry || lcn == (LCN)LCN_RL_NOT_MAPPED)\n\t\treturn (LCN)LCN_EIO;\n\t\/* lcn contains the appropriate error code. *\/\n\treturn lcn;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":195293,"func":"gen_hash(codegen_scope *s, node *tree, int val, int limit)\n{\n  int slimit = GEN_VAL_STACK_MAX;\n  if (cursp() >= GEN_LIT_ARY_MAX) slimit = INT16_MAX;\n  int len = 0;\n  mrb_bool update = FALSE;\n\n  while (tree) {\n    if (nint(tree->car->car->car) == NODE_KW_REST_ARGS) {\n      if (len > 0) {\n        pop_n(len*2);\n        if (!update) {\n          genop_2(s, OP_HASH, cursp(), len);\n        }\n        else {\n          pop();\n          genop_2(s, OP_HASHADD, cursp(), len);\n        }\n        push();\n      }\n      codegen(s, tree->car->cdr, val);\n      if (len > 0 || update) {\n        pop(); pop();\n        genop_1(s, OP_HASHCAT, cursp());\n        push();\n      }\n      update = TRUE;\n      len = 0;\n    }\n    else {\n      codegen(s, tree->car->car, val);\n      codegen(s, tree->car->cdr, val);\n      len++;\n    }\n    tree = tree->cdr;\n    if (val && cursp() >= slimit) {\n      pop_n(len*2);\n      if (!update) {\n        genop_2(s, OP_HASH, cursp(), len);\n      }\n      else {\n        pop();\n        genop_2(s, OP_HASHADD, cursp(), len);\n      }\n      push();\n      update = TRUE;\n      len = 0;\n    }\n  }\n  if (update) {\n    if (val && len > 0) {\n      pop_n(len*2+1);\n      genop_2(s, OP_HASHADD, cursp(), len);\n      push();\n    }\n    return -1;                  \/* variable length *\/\n  }\n  return len;\n}","target":1,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":195216,"func":"  Status BuildInputArgIndex(const OpDef::ArgDef& arg_def, AttrSlice attr_values,\n                            const FunctionDef::ArgAttrs* arg_attrs,\n                            bool ints_on_device,\n                            int64_t resource_arg_unique_id) {\n    bool is_type_list;\n    DataTypeVector dtypes;\n    TF_RETURN_IF_ERROR(\n        ArgNumType(attr_values, arg_def, &is_type_list, &dtypes));\n    CHECK_GE(dtypes.size(), size_t{1});\n    int arg_index = result_.nodes.size();\n    TF_RETURN_IF_ERROR(\n        AddItem(arg_def.name(), {true, arg_index, 0, is_type_list, dtypes}));\n    \/\/ Creates dtypes.size() nodes in the graph.\n    for (size_t i = 0; i < dtypes.size(); ++i) {\n      TF_RETURN_IF_ERROR(AddItem(strings::StrCat(arg_def.name(), \":\", i),\n                                 {true, arg_index, 0, false, {dtypes[i]}}));\n      DCHECK_EQ(arg_index, result_.nodes.size());\n      string name = arg_def.name();\n      if (dtypes.size() > 1) {\n        strings::StrAppend(&name, \"_\", i);\n      }\n      NodeDef* gnode = AddNode(name);\n      if (ints_on_device && dtypes[i] == DataType::DT_INT32) {\n        gnode->set_op(FunctionLibraryDefinition::kDeviceArgOp);\n      } else {\n        gnode->set_op(FunctionLibraryDefinition::kArgOp);\n      }\n      DataType dtype = arg_def.is_ref() ? MakeRefType(dtypes[i]) : dtypes[i];\n      AddAttr(\"T\", dtype, gnode);\n      AddAttr(\"index\", arg_index, gnode);\n      if (resource_arg_unique_id >= 0) {\n        AddAttr(\"_resource_arg_unique_id\", resource_arg_unique_id, gnode);\n      }\n      if (arg_attrs) {\n        for (const auto& arg_attr : arg_attrs->attr()) {\n          AddAttr(arg_attr.first, arg_attr.second, gnode->mutable_attr());\n        }\n      }\n      result_.arg_types.push_back(dtypes[i]);\n      ++arg_index;\n    }\n    return Status::OK();\n  }","target":1,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":246716,"func":"static void PrintSplitUsage()\n{\n\tu32 i=0;\n\tgf_sys_format_help(helpout, help_flags, \"  \\n\"\n\t\t\"# File splitting\\n\"\n\t\t\"MP4Box can split input files by size, duration or extract a given part of the file to new IsoMedia file(s).\\n\"\n\t\t\"This requires that at most one track in the input file has non random-access points (typically one video track at most).\\n\"\n\t\t\"Splitting will ignore all MPEG-4 Systems tracks and hint tracks, but will try to split private media tracks.\\n\"\n\t\t\"The input file must have enough random access points in order to be split. If this is not the case, you will have to re-encode the content.\\n\"\n\t\t\"You can add media to a file and split it in the same pass. In this case, the destination file (the one which would be obtained without splitting) will not be stored.\\n\"\n\t\t\"  \\n\"\n\t\t\"Time ranges are specified as follows:\\n\"\n\t\t\"- `S-E`: `S` start and `E` end times, formatted as `HH:MM:SS.ms`, `MM:SS.ms` or time in seconds (int, double, fraction)\\n\"\n\t\t\"- `S:E`: `S` start time and `E` end times in seconds (int, double, fraction)\\n\"\n\t\t\"- `S:end` or `S:end-N`: `S` start time in seconds (int, double), `N` number of seconds (int, double) before the end\\n\"\n\t\t\"  \\n\"\n\t\t\"MP4Box splitting runs a filter session using the `reframer` filter as follows:\\n\"\n\t\t\"- `splitrange` option of the reframer is always set\\n\"\n\t\t\"- source is demuxed with `alltk` option set\\n\"\n\t\t\"- start and end ranges are passed to `xs` and `xe` options of the reframer\\n\"\n\t\t\"- for `-splitz`, options `xadjust` and `xround=after` are enforced\\n\"\n\t\t\"- for `-splitg`, options `xadjust` and `xround=before` are enforced\\n\"\n\t\t\"- for `-splitf`, option `xround=seek` is enforced and `propbe_ref`set if not specified at prompt\\n\"\n\t\t\"- for `-splitx`, option `xround=closest` and `propbe_ref` are enforced if not specified at prompt\\n\"\n\t\t\"  \\n\"\n\t\t\"The output file(s) storage mode can be specified using -flat, -newfs, -inter and -frag\\n\"\n\t\t\"  \\n\"\n\t);\n\n\ti=0;\n\twhile (m4b_split_args[i].name) {\n\t\tGF_GPACArg *arg = (GF_GPACArg *) &m4b_split_args[i];\n\t\ti++;\n\t\tgf_sys_print_arg(helpout, help_flags, arg, \"mp4box-split\");\n\t}\n\n}","target":0,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":466110,"func":"static int task_switch_16(struct x86_emulate_ctxt *ctxt,\n\t\t\t  u16 tss_selector, u16 old_tss_sel,\n\t\t\t  ulong old_tss_base, struct desc_struct *new_desc)\n{\n\tstruct x86_emulate_ops *ops = ctxt->ops;\n\tstruct tss_segment_16 tss_seg;\n\tint ret;\n\tu32 new_tss_base = get_desc_base(new_desc);\n\n\tret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,\n\t\t\t    &ctxt->exception);\n\tif (ret != X86EMUL_CONTINUE)\n\t\t\/* FIXME: need to provide precise fault address *\/\n\t\treturn ret;\n\n\tsave_state_to_tss16(ctxt, &tss_seg);\n\n\tret = ops->write_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,\n\t\t\t     &ctxt->exception);\n\tif (ret != X86EMUL_CONTINUE)\n\t\t\/* FIXME: need to provide precise fault address *\/\n\t\treturn ret;\n\n\tret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg,\n\t\t\t    &ctxt->exception);\n\tif (ret != X86EMUL_CONTINUE)\n\t\t\/* FIXME: need to provide precise fault address *\/\n\t\treturn ret;\n\n\tif (old_tss_sel != 0xffff) {\n\t\ttss_seg.prev_task_link = old_tss_sel;\n\n\t\tret = ops->write_std(ctxt, new_tss_base,\n\t\t\t\t     &tss_seg.prev_task_link,\n\t\t\t\t     sizeof tss_seg.prev_task_link,\n\t\t\t\t     &ctxt->exception);\n\t\tif (ret != X86EMUL_CONTINUE)\n\t\t\t\/* FIXME: need to provide precise fault address *\/\n\t\t\treturn ret;\n\t}\n\n\treturn load_state_from_tss16(ctxt, &tss_seg);\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":513341,"func":"mysql_select(THD *thd,\n\t     TABLE_LIST *tables, uint wild_num, List<Item> &fields,\n\t     COND *conds, uint og_num,  ORDER *order, ORDER *group,\n\t     Item *having, ORDER *proc_param, ulonglong select_options,\n\t     select_result *result, SELECT_LEX_UNIT *unit,\n\t     SELECT_LEX *select_lex)\n{\n  int err= 0;\n  bool free_join= 1;\n  DBUG_ENTER(\"mysql_select\");\n\n  select_lex->context.resolve_in_select_list= TRUE;\n  JOIN *join;\n  if (select_lex->join != 0)\n  {\n    join= select_lex->join;\n    \/*\n      is it single SELECT in derived table, called in derived table\n      creation\n    *\/\n    if (select_lex->linkage != DERIVED_TABLE_TYPE ||\n\t(select_options & SELECT_DESCRIBE))\n    {\n      if (select_lex->linkage != GLOBAL_OPTIONS_TYPE)\n      {\n        \/*\n          Original join tabs might be overwritten at first\n          subselect execution. So we need to restore them.\n        *\/\n        Item_subselect *subselect= select_lex->master_unit()->item;\n        if (subselect && subselect->is_uncacheable() && join->reinit())\n          DBUG_RETURN(TRUE);\n      }\n      else\n      {\n        if ((err= join->prepare( tables, wild_num,\n                                conds, og_num, order, false, group, having,\n                                proc_param, select_lex, unit)))\n\t{\n\t  goto err;\n\t}\n      }\n    }\n    free_join= 0;\n    join->select_options= select_options;\n  }\n  else\n  {\n    if (thd->lex->describe)\n      select_options|= SELECT_DESCRIBE;\n\n    \/*\n      When in EXPLAIN, delay deleting the joins so that they are still\n      available when we're producing EXPLAIN EXTENDED warning text.\n    *\/\n    if (select_options & SELECT_DESCRIBE)\n      free_join= 0;\n\n    if (!(join= new (thd->mem_root) JOIN(thd, fields, select_options, result)))\n\tDBUG_RETURN(TRUE);\n    THD_STAGE_INFO(thd, stage_init);\n    thd->lex->used_tables=0;\n    if ((err= join->prepare(tables, wild_num,\n                            conds, og_num, order, false, group, having, proc_param,\n                            select_lex, unit)))\n    {\n      goto err;\n    }\n  }\n\n  if ((err= join->optimize()))\n  {\n    goto err;\t\t\t\t\t\/\/ 1\n  }\n\n  if (thd->lex->describe & DESCRIBE_EXTENDED)\n  {\n    join->conds_history= join->conds;\n    join->having_history= (join->having?join->having:join->tmp_having);\n  }\n\n  if (thd->is_error())\n    goto err;\n\n  join->exec();\n\n  if (thd->lex->describe & DESCRIBE_EXTENDED)\n  {\n    select_lex->where= join->conds_history;\n    select_lex->having= join->having_history;\n  }\n\nerr:\n  if (free_join)\n  {\n    THD_STAGE_INFO(thd, stage_end);\n    err|= select_lex->cleanup();\n    DBUG_RETURN(err || thd->is_error());\n  }\n  DBUG_RETURN(join->error ? join->error: err);\n}","target":0,"code_token_length":710,"total_token_length":946,"max_tokens_setting":1024}
+{"idx":463476,"func":"static int ax25_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tax25_cb *ax25;\n\tax25_dev *ax25_dev;\n\n\tif (sk == NULL)\n\t\treturn 0;\n\n\tsock_hold(sk);\n\tlock_sock(sk);\n\tsock_orphan(sk);\n\tax25 = sk_to_ax25(sk);\n\tax25_dev = ax25->ax25_dev;\n\n\tif (sk->sk_type == SOCK_SEQPACKET) {\n\t\tswitch (ax25->state) {\n\t\tcase AX25_STATE_0:\n\t\t\trelease_sock(sk);\n\t\t\tax25_disconnect(ax25, 0);\n\t\t\tlock_sock(sk);\n\t\t\tax25_destroy_socket(ax25);\n\t\t\tbreak;\n\n\t\tcase AX25_STATE_1:\n\t\tcase AX25_STATE_2:\n\t\t\tax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);\n\t\t\trelease_sock(sk);\n\t\t\tax25_disconnect(ax25, 0);\n\t\t\tlock_sock(sk);\n\t\t\tif (!sock_flag(ax25->sk, SOCK_DESTROY))\n\t\t\t\tax25_destroy_socket(ax25);\n\t\t\tbreak;\n\n\t\tcase AX25_STATE_3:\n\t\tcase AX25_STATE_4:\n\t\t\tax25_clear_queues(ax25);\n\t\t\tax25->n2count = 0;\n\n\t\t\tswitch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {\n\t\t\tcase AX25_PROTO_STD_SIMPLEX:\n\t\t\tcase AX25_PROTO_STD_DUPLEX:\n\t\t\t\tax25_send_control(ax25,\n\t\t\t\t\t\t  AX25_DISC,\n\t\t\t\t\t\t  AX25_POLLON,\n\t\t\t\t\t\t  AX25_COMMAND);\n\t\t\t\tax25_stop_t2timer(ax25);\n\t\t\t\tax25_stop_t3timer(ax25);\n\t\t\t\tax25_stop_idletimer(ax25);\n\t\t\t\tbreak;\n#ifdef CONFIG_AX25_DAMA_SLAVE\n\t\t\tcase AX25_PROTO_DAMA_SLAVE:\n\t\t\t\tax25_stop_t3timer(ax25);\n\t\t\t\tax25_stop_idletimer(ax25);\n\t\t\t\tbreak;\n#endif\n\t\t\t}\n\t\t\tax25_calculate_t1(ax25);\n\t\t\tax25_start_t1timer(ax25);\n\t\t\tax25->state = AX25_STATE_2;\n\t\t\tsk->sk_state                = TCP_CLOSE;\n\t\t\tsk->sk_shutdown            |= SEND_SHUTDOWN;\n\t\t\tsk->sk_state_change(sk);\n\t\t\tsock_set_flag(sk, SOCK_DESTROY);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t} else {\n\t\tsk->sk_state     = TCP_CLOSE;\n\t\tsk->sk_shutdown |= SEND_SHUTDOWN;\n\t\tsk->sk_state_change(sk);\n\t\tax25_destroy_socket(ax25);\n\t}\n\tif (ax25_dev) {\n\t\tdel_timer_sync(&ax25->timer);\n\t\tdel_timer_sync(&ax25->t1timer);\n\t\tdel_timer_sync(&ax25->t2timer);\n\t\tdel_timer_sync(&ax25->t3timer);\n\t\tdel_timer_sync(&ax25->idletimer);\n\t\tdev_put_track(ax25_dev->dev, &ax25_dev->dev_tracker);\n\t\tax25_dev_put(ax25_dev);\n\t}\n\n\tsock->sk   = NULL;\n\trelease_sock(sk);\n\tsock_put(sk);\n\n\treturn 0;\n}","target":0,"code_token_length":717,"total_token_length":953,"max_tokens_setting":1024}
+{"idx":473915,"func":"add_code_range_to_buf0(BBuf** pbuf, ScanEnv* env, OnigCodePoint from, OnigCodePoint to,\n\tint checkdup)\n{\n  int r, inc_n, pos;\n  int low, high, bound, x;\n  OnigCodePoint n, *data;\n  BBuf* bbuf;\n\n  if (from > to) {\n    n = from; from = to; to = n;\n  }\n\n  if (IS_NULL(*pbuf)) {\n    r = new_code_range(pbuf);\n    if (r) return r;\n    bbuf = *pbuf;\n    n = 0;\n  }\n  else {\n    bbuf = *pbuf;\n    GET_CODE_POINT(n, bbuf->p);\n  }\n  data = (OnigCodePoint* )(bbuf->p);\n  data++;\n\n  for (low = 0, bound = n; low < bound; ) {\n    x = (low + bound) >> 1;\n    if (from > data[x*2 + 1])\n      low = x + 1;\n    else\n      bound = x;\n  }\n\n  for (high = low, bound = n; high < bound; ) {\n    x = (high + bound) >> 1;\n    if (to >= data[x*2] - 1)\n      high = x + 1;\n    else\n      bound = x;\n  }\n\n  inc_n = low + 1 - high;\n  if (n + inc_n > ONIG_MAX_MULTI_BYTE_RANGES_NUM)\n    return ONIGERR_TOO_MANY_MULTI_BYTE_RANGES;\n\n  if (inc_n != 1) {\n    if (checkdup && to >= data[low*2]) CC_DUP_WARN(env);\n    if (from > data[low*2])\n      from = data[low*2];\n    if (to < data[(high - 1)*2 + 1])\n      to = data[(high - 1)*2 + 1];\n  }\n\n  if (inc_n != 0 && (OnigCodePoint )high < n) {\n    int from_pos = SIZE_CODE_POINT * (1 + high * 2);\n    int to_pos   = SIZE_CODE_POINT * (1 + (low + 1) * 2);\n    int size = (n - high) * 2 * SIZE_CODE_POINT;\n\n    if (inc_n > 0) {\n      BBUF_MOVE_RIGHT(bbuf, from_pos, to_pos, size);\n    }\n    else {\n      BBUF_MOVE_LEFT_REDUCE(bbuf, from_pos, to_pos);\n    }\n  }\n\n  pos = SIZE_CODE_POINT * (1 + low * 2);\n  BBUF_ENSURE_SIZE(bbuf, pos + SIZE_CODE_POINT * 2);\n  BBUF_WRITE_CODE_POINT(bbuf, pos, from);\n  BBUF_WRITE_CODE_POINT(bbuf, pos + SIZE_CODE_POINT, to);\n  n += inc_n;\n  BBUF_WRITE_CODE_POINT(bbuf, 0, n);\n\n  return 0;\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":413334,"func":"zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC)\n{\n\tzval tmp_member;\n\tzval *retval;\n\tphp_snmp_object *obj;\n\tphp_snmp_prop_handler *hnd;\n\tint ret;\n\n\tret = FAILURE;\n\tobj = (php_snmp_object *)zend_objects_get_address(object TSRMLS_CC);\n\n\tif (Z_TYPE_P(member) != IS_STRING) {\n\t\ttmp_member = *member;\n\t\tzval_copy_ctor(&tmp_member);\n\t\tconvert_to_string(&tmp_member);\n\t\tmember = &tmp_member;\n\t}\n\n\tret = zend_hash_find(&php_snmp_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);\n\n\tif (ret == SUCCESS && hnd->read_func) {\n\t\tret = hnd->read_func(obj, &retval TSRMLS_CC);\n\t\tif (ret == SUCCESS) {\n\t\t\t\/* ensure we're creating a temporary variable *\/\n\t\t\tZ_SET_REFCOUNT_P(retval, 0);\n\t\t} else {\n\t\t\tretval = EG(uninitialized_zval_ptr);\n\t\t}\n\t} else {\n\t\tzend_object_handlers * std_hnd = zend_get_std_object_handlers();\n\t\tretval = std_hnd->read_property(object, member, type, key TSRMLS_CC);\n\t}\n\n\tif (member == &tmp_member) {\n\t\tzval_dtor(member);\n\t}\n\treturn(retval);\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":413860,"func":"void LinkResolver::resolve_dynamic_call(CallInfo& result,\n                                        BootstrapInfo& bootstrap_specifier,\n                                        TRAPS) {\n  \/\/ JSR 292:  this must resolve to an implicitly generated method\n  \/\/ such as MH.linkToCallSite(*...) or some other call-site shape.\n  \/\/ The appendix argument is likely to be a freshly-created CallSite.\n  \/\/ It may also be a MethodHandle from an unwrapped ConstantCallSite,\n  \/\/ or any other reference.  The resolved_method as well as the appendix\n  \/\/ are both recorded together via CallInfo::set_handle.\n  SystemDictionary::invoke_bootstrap_method(bootstrap_specifier, THREAD);\n  Exceptions::wrap_dynamic_exception(\/* is_indy *\/ true, THREAD);\n\n  if (HAS_PENDING_EXCEPTION) {\n    if (!PENDING_EXCEPTION->is_a(vmClasses::LinkageError_klass())) {\n      \/\/ Let any random low-level IE or SOE or OOME just bleed through.\n      \/\/ Basically we pretend that the bootstrap method was never called,\n      \/\/ if it fails this way:  We neither record a successful linkage,\n      \/\/ nor do we memorize a LE for posterity.\n      return;\n    }\n    \/\/ JVMS 5.4.3 says: If an attempt by the Java Virtual Machine to resolve\n    \/\/ a symbolic reference fails because an error is thrown that is an\n    \/\/ instance of LinkageError (or a subclass), then subsequent attempts to\n    \/\/ resolve the reference always fail with the same error that was thrown\n    \/\/ as a result of the initial resolution attempt.\n     bool recorded_res_status = bootstrap_specifier.save_and_throw_indy_exc(CHECK);\n     if (!recorded_res_status) {\n       \/\/ Another thread got here just before we did.  So, either use the method\n       \/\/ that it resolved or throw the LinkageError exception that it threw.\n       bool is_done = bootstrap_specifier.resolve_previously_linked_invokedynamic(result, CHECK);\n       if (is_done) return;\n     }\n     assert(bootstrap_specifier.invokedynamic_cp_cache_entry()->indy_resolution_failed(),\n            \"Resolution failure flag wasn't set\");\n  }\n\n  bootstrap_specifier.resolve_newly_linked_invokedynamic(result, CHECK);\n  \/\/ Exceptions::wrap_dynamic_exception not used because\n  \/\/ set_handle doesn't throw linkage errors\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":365630,"func":"_asn1_type_set_config (asn1_node node)\n{\n  asn1_node p, p2;\n  int move;\n\n  if (node == NULL)\n    return ASN1_ELEMENT_NOT_FOUND;\n\n  p = node;\n  move = DOWN;\n\n  while (!((p == node) && (move == UP)))\n    {\n      if (move != UP)\n\t{\n\t  if (type_field (p->type) == ASN1_ETYPE_SET)\n\t    {\n\t      p2 = p->down;\n\t      while (p2)\n\t\t{\n\t\t  if (type_field (p2->type) != ASN1_ETYPE_TAG)\n\t\t    p2->type |= CONST_SET | CONST_NOT_USED;\n\t\t  p2 = p2->right;\n\t\t}\n\t    }\n\t  move = DOWN;\n\t}\n      else\n\tmove = RIGHT;\n\n      if (move == DOWN)\n\t{\n\t  if (p->down)\n\t    p = p->down;\n\t  else\n\t    move = RIGHT;\n\t}\n\n      if (p == node)\n\t{\n\t  move = UP;\n\t  continue;\n\t}\n\n      if (move == RIGHT)\n\t{\n\t  if (p->right)\n\t    p = p->right;\n\t  else\n\t    move = UP;\n\t}\n      if (move == UP)\n\tp = _asn1_get_up (p);\n    }\n\n  return ASN1_SUCCESS;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":439144,"func":"static MagickBooleanType WriteMTVImage(const ImageInfo *image_info,Image *image)\n{\n  char\n    buffer[MaxTextExtent];\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  register const PixelPacket\n    *p;\n\n  register ssize_t\n    x;\n\n  register unsigned char\n    *q;\n\n  size_t\n    imageListLength;\n\n  ssize_t\n    y;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    \/*\n      Allocate memory for pixels.\n    *\/\n    (void) TransformImageColorspace(image,sRGBColorspace);\n    pixels=(unsigned char *) AcquireQuantumMemory(image->columns,\n      3UL*sizeof(*pixels));\n    if (pixels == (unsigned char *) NULL)\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    \/*\n      Initialize raster file header.\n    *\/\n    (void) FormatLocaleString(buffer,MaxTextExtent,\"%.20g %.20g\\n\",(double)\n      image->columns,(double) image->rows);\n    (void) WriteBlobString(image,buffer);\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n      if (p == (const PixelPacket *) NULL)\n        break;\n      q=pixels;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        *q++=ScaleQuantumToChar(GetPixelRed(p));\n        *q++=ScaleQuantumToChar(GetPixelGreen(p));\n        *q++=ScaleQuantumToChar(GetPixelBlue(p));\n        p++;\n      }\n      (void) WriteBlob(image,(size_t) (q-pixels),pixels);\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n                image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene,imageListLength);\n    if (status == MagickFalse)\n      break;\n    scene++;\n  } while (image_info->adjoin != MagickFalse);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":668,"total_token_length":904,"max_tokens_setting":1024}
+{"idx":206736,"func":"ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)\n{\n\tphp_stream\t*tmpstream = NULL;\n\tdatabuf_t\t*data = NULL;\n\tchar\t\t*ptr;\n\tint\t\tch, lastch;\n\tint\t\tsize, rcvd;\n\tint\t\tlines;\n\tchar\t\t**ret = NULL;\n\tchar\t\t**entry;\n\tchar\t\t*text;\n\n\n\tif ((tmpstream = php_stream_fopen_tmpfile()) == NULL) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unable to create temporary file.  Check permissions in temporary files directory.\");\n\t\treturn NULL;\n\t}\n\n\tif (!ftp_type(ftp, FTPTYPE_ASCII)) {\n\t\tgoto bail;\n\t}\n\n\tif ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {\n\t\tgoto bail;\n\t}\n\tftp->data = data;\t\n\n\tif (!ftp_putcmd(ftp, cmd, path)) {\n\t\tgoto bail;\n\t}\n\tif (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125 && ftp->resp != 226)) {\n\t\tgoto bail;\n\t}\n\n\t\/* some servers don't open a ftp-data connection if the directory is empty *\/\n\tif (ftp->resp == 226) {\n\t\tftp->data = data_close(ftp, data);\n\t\tphp_stream_close(tmpstream);\n\t\treturn ecalloc(1, sizeof(char*));\n\t}\n\n\t\/* pull data buffer into tmpfile *\/\n\tif ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) {\n\t\tgoto bail;\n\t}\n\tsize = 0;\n\tlines = 0;\n\tlastch = 0;\n\twhile ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) {\n\t\tif (rcvd == -1) {\n\t\t\tgoto bail;\n\t\t}\n\n\t\tphp_stream_write(tmpstream, data->buf, rcvd);\n\n\t\tsize += rcvd;\n\t\tfor (ptr = data->buf; rcvd; rcvd--, ptr++) {\n\t\t\tif (*ptr == '\\n' && lastch == '\\r') {\n\t\t\t\tlines++;\n\t\t\t} else {\n\t\t\t\tsize++;\n\t\t\t}\n\t\t\tlastch = *ptr;\n\t\t}\n\t}\n\n\tftp->data = data_close(ftp, data);\n\n\tphp_stream_rewind(tmpstream);\n\n\tret = safe_emalloc((lines + 1), sizeof(char*), size * sizeof(char*));\n\n\tentry = ret;\n\ttext = (char*) (ret + lines + 1);\n\t*entry = text;\n\tlastch = 0;\n\twhile ((ch = php_stream_getc(tmpstream)) != EOF) {\n\t\tif (ch == '\\n' && lastch == '\\r') {\n\t\t\t*(text - 1) = 0;\n\t\t\t*++entry = text;\n\t\t} else {\n\t\t\t*text++ = ch;\n\t\t}\n\t\tlastch = ch;\n\t}\n\t*entry = NULL;\n\n\tphp_stream_close(tmpstream);\n\n\tif (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {\n\t\tefree(ret);\n\t\treturn NULL;\n\t}\n\n\treturn ret;\nbail:\n\tftp->data = data_close(ftp, data);\n\tphp_stream_close(tmpstream);\n\tif (ret)\n\t\tefree(ret);\n\treturn NULL;\n}","target":1,"code_token_length":718,"total_token_length":954,"max_tokens_setting":1024}
+{"idx":242967,"func":"static int ssl_buffer_future_record( mbedtls_ssl_context *ssl,\n                                     mbedtls_record const *rec )\n{\n    mbedtls_ssl_handshake_params * const hs = ssl->handshake;\n\n    \/* Don't buffer future records outside handshakes. *\/\n    if( hs == NULL )\n        return( 0 );\n\n    \/* Only buffer handshake records (we are only interested\n     * in Finished messages). *\/\n    if( rec->type != MBEDTLS_SSL_MSG_HANDSHAKE )\n        return( 0 );\n\n    \/* Don't buffer more than one future epoch record. *\/\n    if( hs->buffering.future_record.data != NULL )\n        return( 0 );\n\n    \/* Don't buffer record if there's not enough buffering space remaining. *\/\n    if( rec->buf_len > ( MBEDTLS_SSL_DTLS_MAX_BUFFERING -\n                         hs->buffering.total_bytes_buffered ) )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Buffering of future epoch record of size %\" MBEDTLS_PRINTF_SIZET\n                                    \" would exceed the compile-time limit %\" MBEDTLS_PRINTF_SIZET\n                                    \" (already %\" MBEDTLS_PRINTF_SIZET\n                                    \" bytes buffered) -- ignore\\n\",\n                        rec->buf_len, (size_t) MBEDTLS_SSL_DTLS_MAX_BUFFERING,\n                        hs->buffering.total_bytes_buffered ) );\n        return( 0 );\n    }\n\n    \/* Buffer record *\/\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Buffer record from epoch %u\",\n                                ssl->in_epoch + 1U ) );\n    MBEDTLS_SSL_DEBUG_BUF( 3, \"Buffered record\", rec->buf, rec->buf_len );\n\n    \/* ssl_parse_record_header() only considers records\n     * of the next epoch as candidates for buffering. *\/\n    hs->buffering.future_record.epoch = ssl->in_epoch + 1;\n    hs->buffering.future_record.len   = rec->buf_len;\n\n    hs->buffering.future_record.data =\n        mbedtls_calloc( 1, hs->buffering.future_record.len );\n    if( hs->buffering.future_record.data == NULL )\n    {\n        \/* If we run out of RAM trying to buffer a\n         * record from the next epoch, just ignore. *\/\n        return( 0 );\n    }\n\n    memcpy( hs->buffering.future_record.data, rec->buf, rec->buf_len );\n\n    hs->buffering.total_bytes_buffered += rec->buf_len;\n    return( 0 );\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":277489,"func":"MOBI_RET mobi_decode_infl(unsigned char *decoded, int *decoded_size, const unsigned char *rule) {\n    int pos = *decoded_size;\n    char mod = 'i';\n    char dir = '<';\n    char olddir;\n    unsigned char c;\n    while ((c = *rule++)) {\n        if (c <= 4) {\n            mod = (c <= 2) ? 'i' : 'd'; \/* insert, delete *\/\n            olddir = dir;\n            dir = (c & 2) ? '<' : '>'; \/* left, right *\/\n            if (olddir != dir && olddir) {\n                pos = (c & 2) ? *decoded_size : 0;\n            }\n        }\n        else if (c > 10 && c < 20) {\n            if (dir == '>') {\n                pos = *decoded_size;\n            }\n            pos -= c - 10;\n            dir = 0;\n        }\n        else {\n            if (mod == 'i') {\n                const unsigned char *s = decoded + pos;\n                unsigned char *d = decoded + pos + 1;\n                const int l = *decoded_size - pos;\n                if (pos < 0 || l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {\n                    debug_print(\"Out of buffer in %s at pos: %i\\n\", decoded, pos);\n                    return MOBI_DATA_CORRUPT;\n                }\n                memmove(d, s, (size_t) l);\n                decoded[pos] = c;\n                (*decoded_size)++;\n                if (dir == '>') { pos++; }\n            } else {\n                if (dir == '<') { pos--; }\n                const unsigned char *s = decoded + pos + 1;\n                unsigned char *d = decoded + pos;\n                const int l = *decoded_size - pos;\n                if (pos < 0 || l < 0 || s + l > decoded + INDX_INFLBUF_SIZEMAX) {\n                    debug_print(\"Out of buffer in %s at pos: %i\\n\", decoded, pos);\n                    return MOBI_DATA_CORRUPT;\n                }\n                if (decoded[pos] != c) {\n                    debug_print(\"Character mismatch in %s at pos: %i (%c != %c)\\n\", decoded, pos, decoded[pos], c);\n                    return MOBI_DATA_CORRUPT;\n                }\n                memmove(d, s, (size_t) l);\n                (*decoded_size)--;\n            }\n        }\n    }\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":521483,"func":"void ZipFile::init()\r\n{\r\n    std::unique_ptr<InputStream> toDelete;\r\n    InputStream* in = inputStream;\r\n\r\n    if (inputSource != nullptr)\r\n    {\r\n        in = inputSource->createInputStream();\r\n        toDelete.reset (in);\r\n    }\r\n\r\n    if (in != nullptr)\r\n    {\r\n        int numEntries = 0;\r\n        auto centralDirectoryPos = findCentralDirectoryFileHeader (*in, numEntries);\r\n\r\n        if (centralDirectoryPos >= 0 && centralDirectoryPos < in->getTotalLength())\r\n        {\r\n            auto size = (size_t) (in->getTotalLength() - centralDirectoryPos);\r\n\r\n            in->setPosition (centralDirectoryPos);\r\n            MemoryBlock headerData;\r\n\r\n            if (in->readIntoMemoryBlock (headerData, (ssize_t) size) == size)\r\n            {\r\n                size_t pos = 0;\r\n\r\n                for (int i = 0; i < numEntries; ++i)\r\n                {\r\n                    if (pos + 46 > size)\r\n                        break;\r\n\r\n                    auto* buffer = static_cast<const char*> (headerData.getData()) + pos;\r\n                    auto fileNameLen = readUnalignedLittleEndianShort (buffer + 28u);\r\n\r\n                    if (pos + 46 + fileNameLen > size)\r\n                        break;\r\n\r\n                    entries.add (new ZipEntryHolder (buffer, fileNameLen));\r\n\r\n                    pos += 46u + fileNameLen\r\n                            + readUnalignedLittleEndianShort (buffer + 30u)\r\n                            + readUnalignedLittleEndianShort (buffer + 32u);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":386592,"func":"void DL_Dxf::test() {\n    char* buf1;\n    char* buf2;\n    char* buf3;\n    char* buf4;\n    char* buf5;\n    char* buf6;\n\n    buf1 = new char[10];\n    buf2 = new char[10];\n    buf3 = new char[10];\n    buf4 = new char[10];\n    buf5 = new char[10];\n    buf6 = new char[10];\n\n    strcpy(buf1, \"  10\\n\");\n    strcpy(buf2, \"10\");\n    strcpy(buf3, \"10\\n\");\n    strcpy(buf4, \"  10 \\n\");\n    strcpy(buf5, \"  10 \\r\");\n    strcpy(buf6, \"\\t10 \\n\");\n\n    std::cout << \"1 buf1: '\" << buf1 << \"'\\n\";\n    stripWhiteSpace(&buf1);\n    std::cout << \"2 buf1: '\" << buf1 << \"'\\n\";\n    \/\/assert(!strcmp(buf1, \"10\"));\n\n    std::cout << \"1 buf2: '\" << buf2 << \"'\\n\";\n    stripWhiteSpace(&buf2);\n    std::cout << \"2 buf2: '\" << buf2 << \"'\\n\";\n\n    std::cout << \"1 buf3: '\" << buf3 << \"'\\n\";\n    stripWhiteSpace(&buf3);\n    std::cout << \"2 buf3: '\" << buf3 << \"'\\n\";\n\n    std::cout << \"1 buf4: '\" << buf4 << \"'\\n\";\n    stripWhiteSpace(&buf4);\n    std::cout << \"2 buf4: '\" << buf4 << \"'\\n\";\n\n    std::cout << \"1 buf5: '\" << buf5 << \"'\\n\";\n    stripWhiteSpace(&buf5);\n    std::cout << \"2 buf5: '\" << buf5 << \"'\\n\";\n\n    std::cout << \"1 buf6: '\" << buf6 << \"'\\n\";\n    stripWhiteSpace(&buf6);\n    std::cout << \"2 buf6: '\" << buf6 << \"'\\n\";\n\n}","target":0,"code_token_length":456,"total_token_length":692,"max_tokens_setting":1024}
+{"idx":297210,"func":"static int exif_scan_FILE_header(image_info_type *ImageInfo TSRMLS_DC)\n{\n\tunsigned char file_header[8];\n\tint ret = FALSE;\n\n\tImageInfo->FileType = IMAGE_FILETYPE_UNKNOWN;\n\n\tif (ImageInfo->FileSize >= 2) {\n\t\tphp_stream_seek(ImageInfo->infile, 0, SEEK_SET);\n\t\tif (php_stream_read(ImageInfo->infile, (char*)file_header, 2) != 2) {\n\t\t\treturn FALSE;\n\t\t}\n\t\tif ((file_header[0]==0xff) && (file_header[1]==M_SOI)) {\n\t\t\tImageInfo->FileType = IMAGE_FILETYPE_JPEG;\n\t\t\tif (exif_scan_JPEG_header(ImageInfo TSRMLS_CC)) {\n\t\t\t\tret = TRUE;\n\t\t\t} else {\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Invalid JPEG file\");\n\t\t\t}\n\t\t} else if (ImageInfo->FileSize >= 8) {\n\t\t\tif (php_stream_read(ImageInfo->infile, (char*)(file_header+2), 6) != 6) {\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t\tif (!memcmp(file_header, \"II\\x2A\\x00\", 4)) {\n\t\t\t\tImageInfo->FileType = IMAGE_FILETYPE_TIFF_II;\n\t\t\t\tImageInfo->motorola_intel = 0;\n#ifdef EXIF_DEBUG\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"File has TIFF\/II format\");\n#endif\n\t\t\t\tImageInfo->sections_found |= FOUND_IFD0;\n\t\t\t\tif (exif_process_IFD_in_TIFF(ImageInfo,\n\t\t\t\t\t\t\t\t\t\t\t php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel),\n\t\t\t\t\t\t\t\t\t\t\t SECTION_IFD0 TSRMLS_CC)) {\n\t\t\t\t\tret = TRUE;\n\t\t\t\t} else {\n\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Invalid TIFF file\");\n\t\t\t\t}\n\t\t\t} else if (!memcmp(file_header, \"MM\\x00\\x2a\", 4)) {\n\t\t\t\tImageInfo->FileType = IMAGE_FILETYPE_TIFF_MM;\n\t\t\t\tImageInfo->motorola_intel = 1;\n#ifdef EXIF_DEBUG\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"File has TIFF\/MM format\");\n#endif\n\t\t\t\tImageInfo->sections_found |= FOUND_IFD0;\n\t\t\t\tif (exif_process_IFD_in_TIFF(ImageInfo,\n\t\t\t\t\t\t\t\t\t\t\t php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel),\n\t\t\t\t\t\t\t\t\t\t\t SECTION_IFD0 TSRMLS_CC)) {\n\t\t\t\t\tret = TRUE;\n\t\t\t\t} else {\n\t\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Invalid TIFF file\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"File not supported\");\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t}\n\t} else {\n\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"File too small (%d)\", ImageInfo->FileSize);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":656,"total_token_length":892,"max_tokens_setting":1024}
+{"idx":196587,"func":"  void DoCompute(OpKernelContext* c) {\n    core::RefCountPtr<Var> v;\n    OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n    Tensor* params = v->tensor();\n    const Tensor& indices = c->input(1);\n    const Tensor& updates = c->input(2);\n\n    \/\/ Check that rank(updates.shape) = rank(indices.shape + params.shape[1:])\n    OP_REQUIRES(c,\n                updates.dims() == 0 ||\n                    updates.dims() == indices.dims() + params->dims() - 1,\n                errors::InvalidArgument(\n                    \"Must have updates.shape = indices.shape + \"\n                    \"params.shape[1:] or updates.shape = [], got \",\n                    \"updates.shape \", updates.shape().DebugString(),\n                    \", indices.shape \", indices.shape().DebugString(),\n                    \", params.shape \", params->shape().DebugString()));\n\n    \/\/ Check that we have enough index space\n    const int64_t N_big = indices.NumElements();\n    OP_REQUIRES(\n        c, N_big <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"indices has too many elements for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", N_big, \" > \",\n                                std::numeric_limits<Index>::max()));\n    const Index N = static_cast<Index>(N_big);\n    OP_REQUIRES(\n        c, params->dim_size(0) <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"params.shape[0] too large for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", params->dim_size(0), \" > \",\n                                std::numeric_limits<Index>::max()));\n\n    if (N > 0) {\n      auto indices_flat = indices.flat<Index>();\n      auto params_flat = params->flat_outer_dims<T>();\n      if (TensorShapeUtils::IsScalar(updates.shape())) {\n        const auto update = updates.scalar<T>();\n\n        functor::ScatterScalarFunctor<Device, T, Index, op> functor;\n        const Index bad_i = functor(c, c->template eigen_device<Device>(),\n                                    params_flat, update, indices_flat);\n        OP_REQUIRES(c, bad_i < 0,\n                    errors::InvalidArgument(\n                        \"indices\", SliceDebugString(indices.shape(), bad_i),\n                        \" = \", indices_flat(bad_i), \" is not in [0, \",\n                        params->dim_size(0), \")\"));\n      } else {\n        int64_t num_updates = updates.NumElements();\n        OP_REQUIRES(\n            c, TensorShapeUtils::StartsWith(updates.shape(), indices.shape()),\n            errors::InvalidArgument(\n                \"The shape of indices (\", indices.shape().DebugString(),\n                \") must be a prefix of the shape of updates (\",\n                updates.shape().DebugString(), \")\"));\n        auto updates_flat = updates.shaped<T, 2>({N, num_updates \/ N});\n\n        functor::ScatterFunctor<Device, T, Index, op> functor;\n        const Index bad_i = functor(c, c->template eigen_device<Device>(),\n                                    params_flat, updates_flat, indices_flat);\n        OP_REQUIRES(c, bad_i < 0,\n                    errors::InvalidArgument(\n                        \"indices\", SliceDebugString(indices.shape(), bad_i),\n                        \" = \", indices_flat(bad_i), \" is not in [0, \",\n                        params->dim_size(0), \")\"));\n      }\n    }\n  }","target":1,"code_token_length":738,"total_token_length":974,"max_tokens_setting":1024}
+{"idx":328854,"func":"R_API RBinJavaAttrInfo *r_bin_java_exceptions_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0, offset = 0;\n\tut64 size;\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (!attr) {\n\t\treturn attr;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_LINE_NUMBER_TABLE_ATTR;\n\tattr->info.exceptions_attr.number_of_exceptions = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tsize = sizeof (ut16) * attr->info.exceptions_attr.number_of_exceptions;\n\tif (size < attr->info.exceptions_attr.number_of_exceptions) {\n\t\tfree (attr);\n\t\treturn NULL;\n\t}\n\tattr->info.exceptions_attr.exception_idx_table = (ut16 *) malloc (size);\n\tif (!attr->info.exceptions_attr.exception_idx_table) {\n\t\tfree (attr);\n\t\treturn NULL;\n\t}\n\tfor (i = 0; i < attr->info.exceptions_attr.number_of_exceptions; i++) {\n\t\tif (offset + 2 > sz) {\n\t\t\tbreak;\n\t\t}\n\t\tattr->info.exceptions_attr.exception_idx_table[i] = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t}\n\tattr->size = offset;\n\t\/\/ IFDBG r_bin_java_print_exceptions_attr_summary(attr);\n\treturn attr;\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":216949,"func":"Field *create_tmp_field_from_field(THD *thd, Field *org_field,\n                                   const char *name, TABLE *table,\n                                   Item_field *item)\n{\n  Field *new_field;\n\n  new_field= org_field->make_new_field(thd->mem_root, table,\n                                       table == org_field->table);\n  if (new_field)\n  {\n    new_field->init(table);\n    new_field->orig_table= org_field->orig_table;\n    if (item)\n      item->result_field= new_field;\n    else\n      new_field->field_name= name;\n    new_field->flags|= (org_field->flags & NO_DEFAULT_VALUE_FLAG);\n    if (org_field->maybe_null() || (item && item->maybe_null))\n      new_field->flags&= ~NOT_NULL_FLAG;\t\/\/ Because of outer join\n    if (org_field->type() == MYSQL_TYPE_VAR_STRING ||\n        org_field->type() == MYSQL_TYPE_VARCHAR)\n      table->s->db_create_options|= HA_OPTION_PACK_RECORD;\n    else if (org_field->type() == FIELD_TYPE_DOUBLE)\n      ((Field_double *) new_field)->not_fixed= TRUE;\n    new_field->vcol_info= 0;\n    new_field->cond_selectivity= 1.0;\n    new_field->next_equal_field= NULL;\n    new_field->option_list= NULL;\n    new_field->option_struct= NULL;\n  }\n  return new_field;\n}","target":1,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":220009,"func":"int callback_glewlwyd_user_get_profile (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_session;\n  char * session_uid, expires[129];\n  time_t now;\n  struct tm ts;\n  \n  time(&now);\n  now += GLEWLWYD_DEFAULT_SESSION_EXPIRATION_COOKIE;\n  gmtime_r(&now, &ts);\n  strftime(expires, 128, \"%a, %d %b %Y %T %Z\", &ts);\n  if (!o_strlen(u_map_get(request->map_url, \"username\"))) {\n    session_uid = get_session_id(config, request);\n    if (session_uid != NULL && o_strlen(session_uid)) {\n      j_session = get_users_for_session(config, session_uid);\n      if (check_result_value(j_session, G_OK)) {\n        ulfius_set_json_body_response(response, 200, json_object_get(j_session, \"session\"));\n        ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, \"\/\", config->cookie_secure, 0);\n      } else if (check_result_value(j_session, G_ERROR_NOT_FOUND)) {\n        response->status = 401;\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_get_session - Error get_current_user_for_session\");\n        response->status = 500;\n      }\n      json_decref(j_session);\n    } else {\n      response->status = 401;\n    }\n    o_free(session_uid);\n  } else {\n    \/\/ Can't impersonate this endpoint\n    response->status = 400;\n  }\n  \n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":412190,"func":"cmdline_insert_reg(int *gotesc UNUSED)\n{\n    int\t\ti;\n    int\t\tc;\n    int\t\tsave_new_cmdpos = new_cmdpos;\n\n#ifdef USE_ON_FLY_SCROLL\n    dont_scroll = TRUE;\t\/\/ disallow scrolling here\n#endif\n    putcmdline('\"', TRUE);\n    ++no_mapping;\n    ++allow_keys;\n    i = c = plain_vgetc();\t\/\/ CTRL-R <char>\n    if (i == Ctrl_O)\n\ti = Ctrl_R;\t\t\/\/ CTRL-R CTRL-O == CTRL-R CTRL-R\n    if (i == Ctrl_R)\n\tc = plain_vgetc();\t\/\/ CTRL-R CTRL-R <char>\n    extra_char = NUL;\n    --no_mapping;\n    --allow_keys;\n#ifdef FEAT_EVAL\n    \/*\n     * Insert the result of an expression.\n     *\/\n    new_cmdpos = -1;\n    if (c == '=')\n    {\n\tif (ccline.cmdfirstc == '='  \/\/ can't do this recursively\n\t\t|| cmdline_star > 0) \/\/ or when typing a password\n\t{\n\t    beep_flush();\n\t    c = ESC;\n\t}\n\telse\n\t    c = get_expr_register();\n    }\n#endif\n    if (c != ESC)\t    \/\/ use ESC to cancel inserting register\n    {\n\tcmdline_paste(c, i == Ctrl_R, FALSE);\n\n#ifdef FEAT_EVAL\n\t\/\/ When there was a serious error abort getting the\n\t\/\/ command line.\n\tif (aborting())\n\t{\n\t    *gotesc = TRUE;  \/\/ will free ccline.cmdbuff after\n\t    \/\/ putting it in history\n\t    return GOTO_NORMAL_MODE;\n\t}\n#endif\n\tKeyTyped = FALSE;\t\/\/ Don't do p_wc completion.\n#ifdef FEAT_EVAL\n\tif (new_cmdpos >= 0)\n\t{\n\t    \/\/ set_cmdline_pos() was used\n\t    if (new_cmdpos > ccline.cmdlen)\n\t\tccline.cmdpos = ccline.cmdlen;\n\t    else\n\t\tccline.cmdpos = new_cmdpos;\n\t}\n#endif\n    }\n    new_cmdpos = save_new_cmdpos;\n\n    \/\/ remove the double quote\n    redrawcmd();\n\n    \/\/ The text has been stuffed, the command line didn't change yet.\n    return CMDLINE_NOT_CHANGED;\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":432198,"func":"static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iommu_mr,\n                                                         hwaddr *xlat,\n                                                         hwaddr *plen_out,\n                                                         hwaddr *page_mask_out,\n                                                         bool is_write,\n                                                         bool is_mmio,\n                                                         AddressSpace **target_as,\n                                                         MemTxAttrs attrs)\n{\n    MemoryRegionSection *section;\n    hwaddr page_mask = (hwaddr)-1;\n    MemoryRegion *mr = MEMORY_REGION(iommu_mr);\n\n    do {\n        hwaddr addr = *xlat;\n        IOMMUMemoryRegionClass *imrc = memory_region_get_iommu_class_nocheck(iommu_mr);\n        int iommu_idx = 0;\n        IOMMUTLBEntry iotlb;\n\n        if (imrc->attrs_to_index) {\n            iommu_idx = imrc->attrs_to_index(iommu_mr, attrs);\n        }\n\n        iotlb = imrc->translate(iommu_mr, addr, is_write ?\n                                IOMMU_WO : IOMMU_RO, iommu_idx);\n\n        if (!(iotlb.perm & (1 << is_write))) {\n            goto unassigned;\n        }\n\n        addr = ((iotlb.translated_addr & ~iotlb.addr_mask)\n                | (addr & iotlb.addr_mask));\n        page_mask &= iotlb.addr_mask;\n        *plen_out = MIN(*plen_out, (addr | iotlb.addr_mask) - addr + 1);\n        *target_as = iotlb.target_as;\n\n        section = address_space_translate_internal(\n                address_space_to_dispatch(iotlb.target_as), addr, xlat,\n                plen_out, is_mmio);\n\n        iommu_mr = memory_region_get_iommu(section->mr);\n    } while (unlikely(iommu_mr));\n\n    if (page_mask_out) {\n        *page_mask_out = page_mask;\n    }\n    return *section;\n\nunassigned:\n    return (MemoryRegionSection) { .mr = &(mr->uc->io_mem_unassigned) };\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":364734,"func":"expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)\n{\n    char_u\t*p;\n    char_u\t*retval;\n    char_u\t*expanded_fname = NULL;\n    expand_T\txpc;\n\n    \/*\n     * Expand file name (for environment variables) when needed.\n     *\/\n    if (expand && mch_has_wildcard(fname))\n    {\n\tExpandInit(&xpc);\n\txpc.xp_context = EXPAND_FILES;\n\texpanded_fname = ExpandOne(&xpc, fname, NULL,\n\t\t\t    WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);\n\tif (expanded_fname != NULL)\n\t    fname = expanded_fname;\n    }\n\n    if ((p_tr || curbuf->b_help)\n\t    && !vim_isAbsName(fname)\n\t    && (p = gettail(tag_fname)) != tag_fname)\n    {\n\tretval = alloc(MAXPATHL);\n\tif (retval != NULL)\n\t{\n\t    STRCPY(retval, tag_fname);\n\t    vim_strncpy(retval + (p - tag_fname), fname,\n\t\t\t\t\t      MAXPATHL - (p - tag_fname) - 1);\n\t    \/*\n\t     * Translate names like \"src\/a\/..\/b\/file.c\" into \"src\/b\/file.c\".\n\t     *\/\n\t    simplify_filename(retval);\n\t}\n    }\n    else\n\tretval = vim_strsave(fname);\n\n    vim_free(expanded_fname);\n\n    return retval;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":463139,"func":"EXPORTED int annotatemore_findall(const char *mboxname, \/* internal *\/\n                         unsigned int uid,\n                         const char *entry,\n                         modseq_t since_modseq,\n                         annotatemore_find_proc_t proc,\n                         void *rock,\n                         int flags)\n{\n    char key[MAX_MAILBOX_PATH+1], *p;\n    size_t keylen;\n    int r;\n    struct find_rock frock;\n\n    init_internal();\n\n    assert(mboxname);\n    assert(entry);\n    frock.mglob = glob_init(mboxname, '.');\n    frock.eglob = glob_init(entry, '\/');\n    frock.uid = uid;\n    frock.proc = proc;\n    frock.rock = rock;\n    frock.since_modseq = since_modseq;\n    frock.flags = flags;\n    r = _annotate_getdb(mboxname, uid, 0, &frock.d);\n    if (r) {\n        if (r == CYRUSDB_NOTFOUND)\n            r = 0;\n        goto out;\n    }\n\n    \/* Find fixed-string pattern prefix *\/\n    keylen = make_key(mboxname, uid,\n                      entry, NULL, key, sizeof(key));\n\n    for (p = key; keylen; p++, keylen--) {\n        if (*p == '*' || *p == '%') break;\n    }\n    keylen = p - key;\n\n    r = cyrusdb_foreach(frock.d->db, key, keylen, &find_p, &find_cb,\n                        &frock, tid(frock.d));\n\nout:\n    glob_free(&frock.mglob);\n    glob_free(&frock.eglob);\n    annotate_putdb(&frock.d);\n\n    return r;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":338032,"func":"void WasmBinaryWriter::finishSection(int32_t start) {\n  \/\/ section size does not include the reserved bytes of the size field itself\n  int32_t size = o.size() - start - MaxLEB32Bytes;\n  auto sizeFieldSize = o.writeAt(start, U32LEB(size));\n  \/\/ We can move things back if the actual LEB for the size doesn't use the\n  \/\/ maximum 5 bytes. In that case we need to adjust offsets after we move\n  \/\/ things backwards.\n  auto adjustmentForLEBShrinking = MaxLEB32Bytes - sizeFieldSize;\n  if (adjustmentForLEBShrinking) {\n    \/\/ we can save some room, nice\n    assert(sizeFieldSize < MaxLEB32Bytes);\n    std::move(&o[start] + MaxLEB32Bytes,\n              &o[start] + MaxLEB32Bytes + size,\n              &o[start] + sizeFieldSize);\n    o.resize(o.size() - adjustmentForLEBShrinking);\n    if (sourceMap) {\n      for (auto i = sourceMapLocationsSizeAtSectionStart;\n           i < sourceMapLocations.size();\n           ++i) {\n        sourceMapLocations[i].first -= adjustmentForLEBShrinking;\n      }\n    }\n  }\n\n  if (binaryLocationsSizeAtSectionStart != binaryLocations.expressions.size()) {\n    \/\/ We added the binary locations, adjust them: they must be relative\n    \/\/ to the code section.\n    assert(binaryLocationsSizeAtSectionStart == 0);\n    \/\/ The section type byte is right before the LEB for the size; we want\n    \/\/ offsets that are relative to the body, which is after that section type\n    \/\/ byte and the the size LEB.\n    auto body = start + sizeFieldSize;\n    \/\/ Offsets are relative to the body of the code section: after the\n    \/\/ section type byte and the size.\n    \/\/ Everything was moved by the adjustment, track that. After this,\n    \/\/ we are at the right absolute address.\n    \/\/ We are relative to the section start.\n    auto totalAdjustment = adjustmentForLEBShrinking + body;\n    for (auto& [_, locations] : binaryLocations.expressions) {\n      locations.start -= totalAdjustment;\n      locations.end -= totalAdjustment;\n    }\n    for (auto& [_, locations] : binaryLocations.functions) {\n      locations.start -= totalAdjustment;\n      locations.declarations -= totalAdjustment;\n      locations.end -= totalAdjustment;\n    }\n    for (auto& [_, locations] : binaryLocations.delimiters) {\n      for (auto& item : locations) {\n        item -= totalAdjustment;\n      }\n    }\n  }\n}","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":198350,"func":"net_bind(short unsigned *port, int type, const char *log_service_name)\n{\n  struct addrinfo hints = { 0 };\n  struct addrinfo *servinfo;\n  struct addrinfo *ptr;\n  const char *cfgaddr;\n  char addr[INET6_ADDRSTRLEN];\n  char strport[8];\n  int yes = 1;\n  int no = 0;\n  int fd;\n  int ret;\n\n  cfgaddr = cfg_getstr(cfg_getsec(cfg, \"general\"), \"bind_address\");\n\n  hints.ai_socktype = (type & (SOCK_STREAM | SOCK_DGRAM)); \/\/ filter since type can be SOCK_STREAM | SOCK_NONBLOCK\n  hints.ai_family = (cfg_getbool(cfg_getsec(cfg, \"general\"), \"ipv6\")) ? AF_INET6 : AF_INET;\n  hints.ai_flags = cfgaddr ? 0 : AI_PASSIVE;\n\n  snprintf(strport, sizeof(strport), \"%hu\", *port);\n  ret = getaddrinfo(cfgaddr, strport, &hints, &servinfo);\n  if (ret < 0)\n    {\n      DPRINTF(E_LOG, L_MISC, \"Failure creating '%s' service, could not resolve '%s' (port %s): %s\\n\", log_service_name, cfgaddr ? cfgaddr : \"(ANY)\", strport, gai_strerror(ret));\n      return -1;\n    }\n\n  for (ptr = servinfo, fd = -1; ptr != NULL; ptr = ptr->ai_next)\n    {\n      if (fd >= 0)\n\tclose(fd);\n\n      fd = socket(ptr->ai_family, type | SOCK_CLOEXEC, ptr->ai_protocol);\n      if (fd < 0)\n\tcontinue;\n\n      \/\/ TODO libevent sets this, we do the same?\n      ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));\n      if (ret < 0)\n\tcontinue;\n\n      ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));\n      if (ret < 0)\n\tcontinue;\n\n      if (ptr->ai_family == AF_INET6)\n\t{\n\t  \/\/ We want to be sure the service is dual stack\n\t  ret = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no));\n\t  if (ret < 0)\n\t    continue;\n\t}\n\n      ret = bind(fd, ptr->ai_addr, ptr->ai_addrlen);\n      if (ret < 0)\n\tcontinue;\n\n      break;\n    }\n\n  freeaddrinfo(servinfo);\n\n  if (!ptr)\n    {\n      DPRINTF(E_LOG, L_MISC, \"Could not create service '%s' with address %s, port %hu: %s\\n\", log_service_name, cfgaddr ? cfgaddr : \"(ANY)\", *port, strerror(errno));\n      goto error;\n    }\n\n  \/\/ Get the port that was assigned\n  ret = getsockname(fd, ptr->ai_addr, &ptr->ai_addrlen);\n  if (ret < 0)\n    {\n      DPRINTF(E_LOG, L_MISC, \"Could not find address of service '%s': %s\\n\", log_service_name, strerror(errno));\n      goto error;\n    }\n\n  net_port_get(port, (union net_sockaddr *)ptr->ai_addr);\n  net_address_get(addr, sizeof(addr), (union net_sockaddr *)ptr->ai_addr);\n\n  DPRINTF(E_DBG, L_MISC, \"Service '%s' bound to %s, port %hu, socket %d\\n\", log_service_name, addr, *port, fd);\n\n  return fd;\n\n error:\n  close(fd);\n  return -1;\n}","target":1,"code_token_length":761,"total_token_length":997,"max_tokens_setting":1024}
+{"idx":339715,"func":"static Bigint * mult(Bigint *a, Bigint *b)\n{\n\tBigint *c;\n\tint k, wa, wb, wc;\n\tULong carry, y, z;\n\tULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;\n#ifdef Pack_32\n\tULong z2;\n#endif\n\n\tif (a->wds < b->wds) {\n\t\tc = a;\n\t\ta = b;\n\t\tb = c;\n\t}\n\tk = a->k;\n\twa = a->wds;\n\twb = b->wds;\n\twc = wa + wb;\n\tif (wc > a->maxwds) {\n\t\tk++;\n\t}\n\tc = Balloc(k);\n\tfor(x = c->x, xa = x + wc; x < xa; x++) {\n\t\t*x = 0;\n\t}\n\txa = a->x;\n\txae = xa + wa;\n\txb = b->x;\n\txbe = xb + wb;\n\txc0 = c->x;\n#ifdef Pack_32\n\tfor(; xb < xbe; xb++, xc0++) {\n\t\tif ((y = *xb & 0xffff)) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tdo {\n\t\t\t\tz = (*x & 0xffff) * y + (*xc & 0xffff) + carry;\n\t\t\t\tcarry = z >> 16;\n\t\t\t\tz2 = (*x++ >> 16) * y + (*xc >> 16) + carry;\n\t\t\t\tcarry = z2 >> 16;\n\t\t\t\tStoreinc(xc, z2, z);\n\t\t\t}\n\t\t\twhile(x < xae);\n\t\t\t*xc = carry;\n\t\t}\n\t\tif ((y = *xb >> 16)) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tz2 = *xc;\n\t\t\tdo {\n\t\t\t\tz = (*x & 0xffff) * y + (*xc >> 16) + carry;\n\t\t\t\tcarry = z >> 16;\n\t\t\t\tStoreinc(xc, z, z2);\n\t\t\t\tz2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;\n\t\t\t\tcarry = z2 >> 16;\n\t\t\t}\n\t\t\twhile(x < xae);\n\t\t\t*xc = z2;\n\t\t}\n\t}\n#else\n\tfor(; xb < xbe; xc0++) {\n\t\tif (y = *xb++) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tdo {\n\t\t\t\tz = *x++ * y + *xc + carry;\n\t\t\t\tcarry = z >> 16;\n\t\t\t\t*xc++ = z & 0xffff;\n\t\t\t}\n\t\t\twhile(x < xae);\n\t\t\t*xc = carry;\n\t\t}\n\t}\n#endif\n\tfor(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;\n\tc->wds = wc;\n\treturn c;\n}","target":0,"code_token_length":671,"total_token_length":907,"max_tokens_setting":1024}
+{"idx":252441,"func":"int mz_deflate(mz_streamp pStream, int flush) {\n  size_t in_bytes, out_bytes;\n  mz_ulong orig_total_in, orig_total_out;\n  int mz_status = MZ_OK;\n\n  if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) ||\n      (!pStream->next_out))\n    return MZ_STREAM_ERROR;\n  if (!pStream->avail_out) return MZ_BUF_ERROR;\n\n  if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH;\n\n  if (((tdefl_compressor *)pStream->state)->m_prev_return_status ==\n      TDEFL_STATUS_DONE)\n    return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR;\n\n  orig_total_in = pStream->total_in;\n  orig_total_out = pStream->total_out;\n  for (;;) {\n    tdefl_status defl_status;\n    in_bytes = pStream->avail_in;\n    out_bytes = pStream->avail_out;\n\n    defl_status = tdefl_compress((tdefl_compressor *)pStream->state,\n                                 pStream->next_in, &in_bytes, pStream->next_out,\n                                 &out_bytes, (tdefl_flush)flush);\n    pStream->next_in += (mz_uint)in_bytes;\n    pStream->avail_in -= (mz_uint)in_bytes;\n    pStream->total_in += (mz_uint)in_bytes;\n    pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state);\n\n    pStream->next_out += (mz_uint)out_bytes;\n    pStream->avail_out -= (mz_uint)out_bytes;\n    pStream->total_out += (mz_uint)out_bytes;\n\n    if (defl_status < 0) {\n      mz_status = MZ_STREAM_ERROR;\n      break;\n    } else if (defl_status == TDEFL_STATUS_DONE) {\n      mz_status = MZ_STREAM_END;\n      break;\n    } else if (!pStream->avail_out)\n      break;\n    else if ((!pStream->avail_in) && (flush != MZ_FINISH)) {\n      if ((flush) || (pStream->total_in != orig_total_in) ||\n          (pStream->total_out != orig_total_out))\n        break;\n      return MZ_BUF_ERROR;  \/\/ Can't make forward progress without some input.\n    }\n  }\n  return mz_status;\n}","target":0,"code_token_length":536,"total_token_length":772,"max_tokens_setting":1024}
+{"idx":231639,"func":"TEST_F(QuicServerTransportTest, ReceiveConnectionClose) {\n  auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);\n  server->getNonConstConn().qLogger = qLogger;\n\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  std::string errMsg = \"Stand clear of the closing doors, please\";\n  ConnectionCloseFrame connClose(\n      QuicErrorCode(TransportErrorCode::NO_ERROR), errMsg);\n  writeFrame(std::move(connClose), builder);\n  auto packet = std::move(builder).buildPacket();\n  EXPECT_CALL(connCallback, onConnectionEnd());\n  deliverDataWithoutErrorCheck(packetToBuf(packet));\n  \/\/ Now the transport should be closed\n  EXPECT_EQ(\n      server->getConn().localConnectionError->first,\n      QuicErrorCode(TransportErrorCode::NO_ERROR));\n  EXPECT_EQ(\n      server->getConn().peerConnectionError->first,\n      QuicErrorCode(TransportErrorCode::NO_ERROR));\n  auto closedMsg =\n      folly::to<std::string>(\"Server closed by peer reason=\", errMsg);\n  EXPECT_EQ(server->getConn().peerConnectionError->second, closedMsg);\n  EXPECT_TRUE(server->isClosed());\n  EXPECT_TRUE(verifyFramePresent(\n      serverWrites,\n      *makeClientEncryptedCodec(),\n      QuicFrame::Type::ConnectionCloseFrame));\n  checkTransportStateUpdate(qLogger, std::move(closedMsg));\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":253725,"func":"static unsigned int ccp_queue_buf(struct ccp_data *data, unsigned int from)\n{\n\tstruct ccp_sg_workarea *sg_wa = &data->sg_wa;\n\tstruct ccp_dm_workarea *dm_wa = &data->dm_wa;\n\tunsigned int buf_count, nbytes;\n\n\t\/* Clear the buffer if setting it *\/\n\tif (!from)\n\t\tmemset(dm_wa->address, 0, dm_wa->length);\n\n\tif (!sg_wa->sg)\n\t\treturn 0;\n\n\t\/* Perform the copy operation\n\t *   nbytes will always be <= UINT_MAX because dm_wa->length is\n\t *   an unsigned int\n\t *\/\n\tnbytes = min_t(u64, sg_wa->bytes_left, dm_wa->length);\n\tscatterwalk_map_and_copy(dm_wa->address, sg_wa->sg, sg_wa->sg_used,\n\t\t\t\t nbytes, from);\n\n\t\/* Update the structures and generate the count *\/\n\tbuf_count = 0;\n\twhile (sg_wa->bytes_left && (buf_count < dm_wa->length)) {\n\t\tnbytes = min(sg_dma_len(sg_wa->dma_sg) - sg_wa->sg_used,\n\t\t\t     dm_wa->length - buf_count);\n\t\tnbytes = min_t(u64, sg_wa->bytes_left, nbytes);\n\n\t\tbuf_count += nbytes;\n\t\tccp_update_sg_workarea(sg_wa, nbytes);\n\t}\n\n\treturn buf_count;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":221505,"func":"add_tzdata_args (FlatpakBwrap *bwrap,\n                 GFile *runtime_files)\n{\n  g_autofree char *raw_timezone = flatpak_get_timezone ();\n  g_autofree char *timezone_content = g_strdup_printf (\"%s\\n\", raw_timezone);\n  g_autofree char *localtime_content = g_strconcat (\"..\/usr\/share\/zoneinfo\/\", raw_timezone, NULL);\n  g_autoptr(GFile) runtime_zoneinfo = NULL;\n\n  if (runtime_files)\n    runtime_zoneinfo = g_file_resolve_relative_path (runtime_files, \"share\/zoneinfo\");\n\n  \/* Check for runtime \/usr\/share\/zoneinfo *\/\n  if (runtime_zoneinfo != NULL && g_file_query_exists (runtime_zoneinfo, NULL))\n    {\n      \/* Check for host \/usr\/share\/zoneinfo *\/\n      if (g_file_test (\"\/usr\/share\/zoneinfo\", G_FILE_TEST_IS_DIR))\n        {\n          \/* Here we assume the host timezone file exist in the host data *\/\n          flatpak_bwrap_add_args (bwrap,\n                                  \"--ro-bind\", \"\/usr\/share\/zoneinfo\", \"\/usr\/share\/zoneinfo\",\n                                  \"--symlink\", localtime_content, \"\/etc\/localtime\",\n                                  NULL);\n        }\n      else\n        {\n          g_autoptr(GFile) runtime_tzfile = g_file_resolve_relative_path (runtime_zoneinfo, raw_timezone);\n\n          \/* Check if host timezone file exist in the runtime tzdata *\/\n          if (g_file_query_exists (runtime_tzfile, NULL))\n            flatpak_bwrap_add_args (bwrap,\n                                    \"--symlink\", localtime_content, \"\/etc\/localtime\",\n                                    NULL);\n        }\n    }\n\n  flatpak_bwrap_add_args_data (bwrap, \"timezone\",\n                               timezone_content, -1, \"\/etc\/timezone\",\n                               NULL);\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":219980,"func":"int callback_glewlwyd_user_get_session_list (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_session_list;\n  size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE;\n  long int l_converted = 0;\n  char * endptr = NULL, * sort = NULL;\n  \n  if (u_map_get(request->map_url, \"offset\") != NULL) {\n    l_converted = strtol(u_map_get(request->map_url, \"offset\"), &endptr, 10);\n    if (!(*endptr) && l_converted > 0) {\n      offset = (size_t)l_converted;\n    }\n  }\n  if (u_map_get(request->map_url, \"limit\") != NULL) {\n    l_converted = strtol(u_map_get(request->map_url, \"limit\"), &endptr, 10);\n    if (!(*endptr) && l_converted > 0) {\n      limit = (size_t)l_converted;\n    }\n  }\n  if (0 == o_strcmp(u_map_get(request->map_url, \"sort\"), \"session_hash\") || 0 == o_strcmp(u_map_get(request->map_url, \"sort\"), \"user_agent\") || 0 == o_strcmp(u_map_get(request->map_url, \"sort\"), \"issued_for\") || 0 == o_strcmp(u_map_get(request->map_url, \"sort\"), \"expiration\") || 0 == o_strcmp(u_map_get(request->map_url, \"sort\"), \"last_login\") || 0 == o_strcmp(u_map_get(request->map_url, \"sort\"), \"enabled\")) {\n    sort = msprintf(\"gpgr_%s%s\", u_map_get(request->map_url, \"sort\"), (u_map_get_case(request->map_url, \"desc\")!=NULL?\" DESC\":\" ASC\"));\n  }\n  j_session_list = get_user_session_list(config, json_string_value(json_object_get((json_t *)response->shared_data, \"username\")), u_map_get(request->map_url, \"pattern\"), offset, limit, sort);\n  if (check_result_value(j_session_list, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_session_list, \"session\"));\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_get_session_list - Error get_user_session_list\");\n    response->status = 500;\n  }\n  json_decref(j_session_list);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":522325,"func":"static void RecBlk(GmfMshSct *msh, const void *blk, int siz)\n{\n   \/\/ Copy this line-block into the main mesh buffer\n   if(siz)\n   {\n      memcpy(&msh->blk[ msh->pos ], blk, (size_t)(siz * WrdSiz));\n      msh->pos += siz * WrdSiz;\n   }\n\n   \/\/ When the buffer is full or this procedure is APIF77ed with a 0 size,\n   \/\/ flush the cache on disk\n\n   if( (msh->pos > BufSiz) || (!siz && msh->pos) )\n   {\n#ifdef GMF_WINDOWS\n      \/*\n       *   [Bruno] TODO: check that msh->pos is smaller\n       * than 4G (fits in 32 bits).\n       *   Note: for now, when trying to write more than 4Gb, it will\n       * trigger an error (longjmp).\n       *   As far as I understand:\n       *   Given that this function just flushes the cache, and given that\n       * the cache size is 10000 words, this is much much smaller than 4Gb\n       * so there is probably no problem.\n       *\/\n#ifdef WITH_GMF_AIO\n      if(write(msh->FilDes, msh->blk, (int)msh->pos) != (ssize_t)msh->pos)\n#else      \n      if(fwrite(msh->blk, 1, (size_t)msh->pos, msh->hdl) != msh->pos)\n#endif      \n         longjmp(msh->err, -30);\n#else      \n#ifdef WITH_GMF_AIO\n      if(write(msh->FilDes, msh->blk, msh->pos) != (ssize_t)msh->pos)\n#else      \n      if(fwrite(msh->blk, 1, msh->pos, msh->hdl) != msh->pos)\n#endif      \n         longjmp(msh->err, -31);\n#endif      \n      msh->pos = 0;\n   }\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":489210,"func":"static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct inode *inode)\n{\n\tif (S_ISDIR(inode->i_mode)) {\n\t\tstruct hfsplus_cat_folder *folder;\n\n\t\tfolder = &entry->folder;\n\t\tmemset(folder, 0, sizeof(*folder));\n\t\tfolder->type = cpu_to_be16(HFSPLUS_FOLDER);\n\t\tfolder->id = cpu_to_be32(inode->i_ino);\n\t\tHFSPLUS_I(inode).create_date =\n\t\t\tfolder->create_date =\n\t\t\tfolder->content_mod_date =\n\t\t\tfolder->attribute_mod_date =\n\t\t\tfolder->access_date = hfsp_now2mt();\n\t\thfsplus_set_perms(inode, &folder->permissions);\n\t\tif (inode == HFSPLUS_SB(inode->i_sb).hidden_dir)\n\t\t\t\/* invisible and namelocked *\/\n\t\t\tfolder->user_info.frFlags = cpu_to_be16(0x5000);\n\t\treturn sizeof(*folder);\n\t} else {\n\t\tstruct hfsplus_cat_file *file;\n\n\t\tfile = &entry->file;\n\t\tmemset(file, 0, sizeof(*file));\n\t\tfile->type = cpu_to_be16(HFSPLUS_FILE);\n\t\tfile->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS);\n\t\tfile->id = cpu_to_be32(cnid);\n\t\tHFSPLUS_I(inode).create_date =\n\t\t\tfile->create_date =\n\t\t\tfile->content_mod_date =\n\t\t\tfile->attribute_mod_date =\n\t\t\tfile->access_date = hfsp_now2mt();\n\t\tif (cnid == inode->i_ino) {\n\t\t\thfsplus_set_perms(inode, &file->permissions);\n\t\t\tif (S_ISLNK(inode->i_mode)) {\n\t\t\t\tfile->user_info.fdType = cpu_to_be32(HFSP_SYMLINK_TYPE);\n\t\t\t\tfile->user_info.fdCreator = cpu_to_be32(HFSP_SYMLINK_CREATOR);\n\t\t\t} else {\n\t\t\t\tfile->user_info.fdType = cpu_to_be32(HFSPLUS_SB(inode->i_sb).type);\n\t\t\t\tfile->user_info.fdCreator = cpu_to_be32(HFSPLUS_SB(inode->i_sb).creator);\n\t\t\t}\n\t\t\tif ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE)\n\t\t\t\tfile->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);\n\t\t} else {\n\t\t\tfile->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE);\n\t\t\tfile->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR);\n\t\t\tfile->user_info.fdFlags = cpu_to_be16(0x100);\n\t\t\tfile->create_date = HFSPLUS_I(HFSPLUS_SB(inode->i_sb).hidden_dir).create_date;\n\t\t\tfile->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev);\n\t\t}\n\t\treturn sizeof(*file);\n\t}\n}","target":0,"code_token_length":638,"total_token_length":874,"max_tokens_setting":1024}
+{"idx":269489,"func":"static void TIFFReadPhotoshopLayers(const ImageInfo *image_info,Image *image,\n  ExceptionInfo *exception)\n{\n  const char\n    *option;\n\n  const StringInfo\n    *profile;\n\n  CustomStreamInfo\n    *custom_stream;\n\n  Image\n    *layers;\n\n  ImageInfo\n    *clone_info;\n\n  PhotoshopProfile\n    photoshop_profile;\n\n  PSDInfo\n    info;\n\n  ssize_t\n    i;\n\n  if (GetImageListLength(image) != 1)\n    return;\n  if ((image_info->number_scenes == 1) && (image_info->scene == 0))\n    return;\n  option=GetImageOption(image_info,\"tiff:ignore-layers\");\n  if (option != (const char * ) NULL)\n    return;\n  profile=GetImageProfile(image,\"tiff:37724\");\n  if (profile == (const StringInfo *) NULL)\n    return;\n  for (i=0; i < (ssize_t) profile->length-8; i++)\n  {\n    if (LocaleNCompare((const char *) (profile->datum+i),\n        image->endian == MSBEndian ? \"8BIM\" : \"MIB8\",4) != 0)\n      continue;\n    i+=4;\n    if ((LocaleNCompare((const char *) (profile->datum+i),\n         image->endian == MSBEndian ? \"Layr\" : \"ryaL\",4) == 0) ||\n        (LocaleNCompare((const char *) (profile->datum+i),\n         image->endian == MSBEndian ? \"LMsk\" : \"ksML\",4) == 0) ||\n        (LocaleNCompare((const char *) (profile->datum+i),\n         image->endian == MSBEndian ? \"Lr16\" : \"61rL\",4) == 0) ||\n        (LocaleNCompare((const char *) (profile->datum+i),\n         image->endian == MSBEndian ? \"Lr32\" : \"23rL\",4) == 0))\n      break;\n  }\n  i+=4;\n  if (i >= (ssize_t) (profile->length-8))\n    return;\n  photoshop_profile.data=(StringInfo *) profile;\n  photoshop_profile.length=profile->length;\n  custom_stream=TIFFAcquireCustomStreamForReading(&photoshop_profile,exception);\n  if (custom_stream == (CustomStreamInfo *) NULL)\n    return;\n  layers=CloneImage(image,0,0,MagickTrue,exception);\n  if (layers == (Image *) NULL)\n    {\n      custom_stream=DestroyCustomStreamInfo(custom_stream);\n      return;\n    }\n  (void) DeleteImageProfile(layers,\"tiff:37724\");\n  AttachCustomStream(layers->blob,custom_stream);\n  SeekBlob(layers,(MagickOffsetType) i,SEEK_SET);\n  InitPSDInfo(layers,&info);\n  clone_info=CloneImageInfo(image_info);\n  clone_info->number_scenes=0;\n  (void) ReadPSDLayers(layers,clone_info,&info,exception);\n  clone_info=DestroyImageInfo(clone_info);\n  DeleteImageFromList(&layers);\n  if (layers != (Image *) NULL)\n    {\n      SetImageArtifact(image,\"tiff:has-layers\",\"true\");\n      AppendImageToList(&image,layers);\n      while (layers != (Image *) NULL)\n      {\n        SetImageArtifact(layers,\"tiff:has-layers\",\"true\");\n        DetachBlob(layers->blob);\n        layers=GetNextImageInList(layers);\n      }\n    }\n  custom_stream=DestroyCustomStreamInfo(custom_stream);\n}","target":0,"code_token_length":777,"total_token_length":1013,"max_tokens_setting":1024}
+{"idx":376347,"func":"gpg_ctx_op_wait (struct _GpgCtx *gpg)\n{\n#ifndef G_OS_WIN32\n\tsigset_t mask, omask;\n\tpid_t retval;\n\tgint status;\n\n\tif (!gpg->exited) {\n\t\tsigemptyset (&mask);\n\t\tsigaddset (&mask, SIGALRM);\n\t\tsigprocmask (SIG_BLOCK, &mask, &omask);\n\t\talarm (1);\n\t\tretval = waitpid (gpg->pid, &status, 0);\n\t\talarm (0);\n\t\tsigprocmask (SIG_SETMASK, &omask, NULL);\n\n\t\tif (retval == (pid_t) -1 && errno == EINTR) {\n\t\t\t\/* The child is hanging: send a friendly reminder. *\/\n\t\t\tkill (gpg->pid, SIGTERM);\n\t\t\tsleep (1);\n\t\t\tretval = waitpid (gpg->pid, &status, WNOHANG);\n\t\t\tif (retval == (pid_t) 0) {\n\t\t\t\t\/* Still hanging; use brute force. *\/\n\t\t\t\tkill (gpg->pid, SIGKILL);\n\t\t\t\tsleep (1);\n\t\t\t\tretval = waitpid (gpg->pid, &status, WNOHANG);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tstatus = gpg->exit_status;\n\t\tretval = gpg->pid;\n\t}\n\n\tif (retval != (pid_t) -1 && WIFEXITED (status))\n\t\treturn WEXITSTATUS (status);\n\telse\n\t\treturn -1;\n#else\n\treturn -1;\n#endif\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":349882,"func":"static int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,\n\t\t\t\t      enum hal_atl_utils_fw_state_e state)\n{\n\tu32 val = aq_hw_read_reg(self, HW_ATL_MPI_CONTROL_ADR);\n\tstruct hw_atl_utils_mbox_header mbox;\n\tu32 transaction_id = 0;\n\tint err = 0;\n\n\tif (state == MPI_RESET) {\n\t\thw_atl_utils_mpi_read_mbox(self, &mbox);\n\n\t\ttransaction_id = mbox.transaction_id;\n\n\t\terr = readx_poll_timeout_atomic(hw_atl_utils_get_mpi_mbox_tid,\n\t\t\t\t\t\tself, mbox.transaction_id,\n\t\t\t\t\t\ttransaction_id !=\n\t\t\t\t\t\tmbox.transaction_id,\n\t\t\t\t\t\t1000U, 100000U);\n\t\tif (err < 0)\n\t\t\tgoto err_exit;\n\t}\n\t\/* On interface DEINIT we disable DW (raise bit)\n\t * Otherwise enable DW (clear bit)\n\t *\/\n\tif (state == MPI_DEINIT || state == MPI_POWER)\n\t\tval |= HW_ATL_MPI_DIRTY_WAKE_MSK;\n\telse\n\t\tval &= ~HW_ATL_MPI_DIRTY_WAKE_MSK;\n\n\t\/* Set new state bits *\/\n\tval = val & ~HW_ATL_MPI_STATE_MSK;\n\tval |= state & HW_ATL_MPI_STATE_MSK;\n\n\taq_hw_write_reg(self, HW_ATL_MPI_CONTROL_ADR, val);\n\nerr_exit:\n\treturn err;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":387762,"func":"int InstanceKlass::find_method_index(const Array<Method*>* methods,\n                                     const Symbol* name,\n                                     const Symbol* signature,\n                                     OverpassLookupMode overpass_mode,\n                                     StaticLookupMode static_mode,\n                                     PrivateLookupMode private_mode) {\n  const bool skipping_overpass = (overpass_mode == skip_overpass);\n  const bool skipping_static = (static_mode == skip_static);\n  const bool skipping_private = (private_mode == skip_private);\n  const int hit = binary_search(methods, name);\n  if (hit != -1) {\n    const Method* const m = methods->at(hit);\n\n    \/\/ Do linear search to find matching signature.  First, quick check\n    \/\/ for common case, ignoring overpasses if requested.\n    if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) {\n      return hit;\n    }\n\n    \/\/ search downwards through overloaded methods\n    int i;\n    for (i = hit - 1; i >= 0; --i) {\n        const Method* const m = methods->at(i);\n        assert(m->is_method(), \"must be method\");\n        if (m->name() != name) {\n          break;\n        }\n        if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) {\n          return i;\n        }\n    }\n    \/\/ search upwards\n    for (i = hit + 1; i < methods->length(); ++i) {\n        const Method* const m = methods->at(i);\n        assert(m->is_method(), \"must be method\");\n        if (m->name() != name) {\n          break;\n        }\n        if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) {\n          return i;\n        }\n    }\n    \/\/ not found\n#ifdef ASSERT\n    const int index = (skipping_overpass || skipping_static || skipping_private) ? -1 :\n      linear_search(methods, name, signature);\n    assert(-1 == index, \"binary search should have found entry %d\", index);\n#endif\n  }\n  return -1;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":267842,"func":"vm_run_global (const ecma_compiled_code_t *bytecode_p, \/**< pointer to bytecode to run *\/\n               ecma_object_t *function_object_p) \/**< function object if available *\/\n{\n#if JERRY_BUILTIN_REALMS\n  ecma_object_t *global_obj_p = (ecma_object_t *) ecma_op_function_get_realm (bytecode_p);\n#else \/* !JERRY_BUILTIN_REALMS *\/\n  ecma_object_t *global_obj_p = ecma_builtin_get_global ();\n#endif \/* JERRY_BUILTIN_REALMS *\/\n\n#if JERRY_ESNEXT\n  if (bytecode_p->status_flags & CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED)\n  {\n    ecma_create_global_lexical_block (global_obj_p);\n  }\n#endif \/* JERRY_ESNEXT *\/\n\n  ecma_object_t *const global_scope_p = ecma_get_global_scope (global_obj_p);\n\n  vm_frame_ctx_shared_t shared;\n  shared.bytecode_header_p = bytecode_p;\n  shared.function_object_p = function_object_p;\n  shared.status_flags = 0;\n\n#if JERRY_BUILTIN_REALMS\n  ecma_value_t this_binding = ((ecma_global_object_t *) global_obj_p)->this_binding;\n\n  ecma_global_object_t *saved_global_object_p = JERRY_CONTEXT (global_object_p);\n  JERRY_CONTEXT (global_object_p) = (ecma_global_object_t *) global_obj_p;\n#else \/* !JERRY_BUILTIN_REALMS *\/\n  ecma_value_t this_binding = ecma_make_object_value (global_obj_p);\n#endif \/* JERRY_BUILTIN_REALMS *\/\n\n  ecma_value_t result = vm_run (&shared, this_binding, global_scope_p);\n\n#if JERRY_BUILTIN_REALMS\n  JERRY_CONTEXT (global_object_p) = saved_global_object_p;\n#endif \/* JERRY_BUILTIN_REALMS *\/\n\n  return result;\n} \/* vm_run_global *\/","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":390578,"func":"SetVirtualModMap(\tXkbSrvInfoPtr\t\txkbi,\n\t\t\txkbSetMapReq *\t\treq,\n\t\t\txkbVModMapWireDesc *\twire,\n\t\t\tXkbChangesPtr \t\tchanges)\n{\nregister unsigned\ti,first,last;\nXkbServerMapPtr\t\tsrv = xkbi->desc->server;\n\n    first= req->firstVModMapKey;\n    last=  req->firstVModMapKey+req->nVModMapKeys-1;\n    bzero(&srv->vmodmap[first],req->nVModMapKeys*sizeof(unsigned short));\n    for (i=0;i<req->totalVModMapKeys;i++,wire++) {\n\tsrv->vmodmap[wire->key]= wire->vmods;\n    }\n    if (first>0) {\n\tif (changes->map.changed&XkbVirtualModMapMask) {\n\t    int oldLast;\n\t    oldLast= changes->map.first_vmodmap_key+\n\t\t\t\t\tchanges->map.num_vmodmap_keys-1;\n\t    if (changes->map.first_vmodmap_key<first)\n\t\tfirst= changes->map.first_vmodmap_key;\n\t    if (oldLast>last)\n\t\tlast= oldLast;\n\t}\n\tchanges->map.first_vmodmap_key= first;\n\tchanges->map.num_vmodmap_keys= (last-first)+1;\n    }\n    return (char *)wire;\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":459090,"func":"static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,\n\t\t\t\t  struct tcf_block_ext_info *ei,\n\t\t\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct net_device *dev = q->dev_queue->dev;\n\tint err;\n\n\tdown_write(&block->cb_lock);\n\n\t\/* If tc offload feature is disabled and the block we try to bind\n\t * to already has some offloaded filters, forbid to bind.\n\t *\/\n\tif (dev->netdev_ops->ndo_setup_tc &&\n\t    !tc_can_offload(dev) &&\n\t    tcf_block_offload_in_use(block)) {\n\t\tNL_SET_ERR_MSG(extack, \"Bind to offloaded block failed as dev has offload disabled\");\n\t\terr = -EOPNOTSUPP;\n\t\tgoto err_unlock;\n\t}\n\n\terr = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_BIND, extack);\n\tif (err == -EOPNOTSUPP)\n\t\tgoto no_offload_dev_inc;\n\tif (err)\n\t\tgoto err_unlock;\n\n\tup_write(&block->cb_lock);\n\treturn 0;\n\nno_offload_dev_inc:\n\tif (tcf_block_offload_in_use(block))\n\t\tgoto err_unlock;\n\n\terr = 0;\n\tblock->nooffloaddevcnt++;\nerr_unlock:\n\tup_write(&block->cb_lock);\n\treturn err;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":402631,"func":"SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)\n{\n\tcms_context *cms = (cms_context *)arg;\n\tint fd;\n\tchar *file = NULL;\n\tchar *token_name = slot ? PK11_GetTokenName(slot) : NULL;\n\tstruct token_pass *phrases = NULL;\n\tsize_t nphrases = 0;\n\tchar *phrase = NULL;\n\tchar *start;\n\tchar *ret = NULL;\n\tchar *path;\n\n\tingress();\n\tdprintf(\"token_name: %s\", token_name);\n\tpath = cms->pwdata.data;\n\n\tif (!path || retry)\n\t\tgoto err;\n\n\tphrases = calloc(1, sizeof(struct token_pass));\n\tif (!phrases)\n\t\tgoto err;\n\n\tfd = open(path, O_RDONLY|O_CLOEXEC);\n\tif (fd < 0) {\n\t\tgoto err_phrases;\n\t} else {\n\t\tsize_t file_len = 0;\n\t\tint rc;\n\t\trc = read_file(fd, &file, &file_len);\n\t\tset_errno_guard();\n\t\tclose(fd);\n\n\t\tif (rc < 0 || file_len < 1)\n\t\t\tgoto err_file;\n\t\tfile[file_len-1] = '\\0';\n\t\tdprintf(\"file_len:%zd\", file_len);\n\t\tdprintf(\"file:\\\"%s\\\"\", file);\n\n\t\tunbreak_line_continuations(file, file_len);\n\t}\n\n\tstart = file;\n\twhile (start && start[0]) {\n\t\tsize_t span;\n\t\tstruct token_pass *new_phrases;\n\t\tint rc;\n\t\tchar c;\n\n\t\tnew_phrases = reallocarray(phrases, nphrases + 1, sizeof(struct token_pass));\n\t\tif (!new_phrases)\n\t\t\tgoto err_phrases;\n\t\tphrases = new_phrases;\n\t\tmemset(&new_phrases[nphrases], 0, sizeof(struct token_pass));\n\n\t\tspan = strspn(start, whitespace_and_eol_chars);\n\t\tdprintf(\"whitespace span is %zd\", span);\n\t\tstart += span;\n\t\tspan = strcspn(start, eol_chars);\n\t\tdprintf(\"non-whitespace span is %zd\", span);\n\n\t\tc = start[span];\n\t\tstart[span] = '\\0';\n\t\tdprintf(\"file:\\\"%s\\\"\", file);\n\t\trc = parse_pwfile_line(start, &phrases[nphrases++]);\n\t\tdprintf(\"parse_pwfile_line returned %d\", rc);\n\t\tif (rc < 0)\n\t\t\tgoto err_phrases;\n\n\t\tif (c != '\\0')\n\t\t\tspan++;\n\t\tstart += span;\n\t\tdprintf(\"start is file[%ld] == '\\\\x%02hhx'\", start - file, start[0]);\n\t}\n\n\tqsort(phrases, nphrases, sizeof(struct token_pass), token_pass_cmp);\n\tcms->pwdata.source = PW_DATABASE;\n\txfree(cms->pwdata.data);\n\tcms->pwdata.pwdb.phrases = phrases;\n\tcms->pwdata.pwdb.nphrases = nphrases;\n\n\tfor (size_t i = 0; i < nphrases; i++) {\n\t\tif (phrases[i].token == NULL || phrases[i].token[0] == '\\0'\n\t\t    || (token_name && !strcmp(token_name, phrases[i].token))) {\n\t\t\tphrase = phrases[i].pass;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (phrase) {\n\t\tret = PORT_Strdup(phrase);\n\t\tif (!ret)\n\t\t\terrno = ENOMEM;\n\t}\n\nerr_file:\n\txfree(file);\nerr_phrases:\n\txfree(phrases);\nerr:\n\tdprintf(\"ret:\\\"%s\\\"\", ret ? ret : \"(null)\");\n\tegress();\n\treturn ret;\n}","target":0,"code_token_length":777,"total_token_length":1013,"max_tokens_setting":1024}
+{"idx":231691,"func":"TEST_F(QuicServerTransportTest, ReceiveConnectionCloseTwice) {\n  auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);\n  server->getNonConstConn().qLogger = qLogger;\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  std::string errMsg = \"Mind the gap\";\n  ConnectionCloseFrame connClose(\n      QuicErrorCode(TransportErrorCode::NO_ERROR), errMsg);\n  writeFrame(std::move(connClose), builder);\n  auto packet = std::move(builder).buildPacket();\n  EXPECT_CALL(connCallback, onConnectionEnd());\n  deliverDataWithoutErrorCheck(packetToBuf(packet));\n  \/\/ Now the transport should be closed\n  EXPECT_EQ(\n      QuicErrorCode(TransportErrorCode::NO_ERROR),\n      server->getConn().localConnectionError->first);\n  EXPECT_EQ(\n      server->getConn().peerConnectionError->first,\n      QuicErrorCode(TransportErrorCode::NO_ERROR));\n  auto closedMsg =\n      folly::to<std::string>(\"Server closed by peer reason=\", errMsg);\n  EXPECT_EQ(server->getConn().peerConnectionError->second, closedMsg);\n  EXPECT_TRUE(server->isClosed());\n  EXPECT_TRUE(verifyFramePresent(\n      serverWrites,\n      *makeClientEncryptedCodec(),\n      QuicFrame::Type::ConnectionCloseFrame));\n  serverWrites.clear();\n  deliverDataWithoutErrorCheck(packetToBuf(packet));\n  EXPECT_FALSE(verifyFramePresent(\n      serverWrites,\n      *makeClientEncryptedCodec(),\n      QuicFrame::Type::ConnectionCloseFrame));\n  std::vector<int> indices =\n      getQLogEventIndices(QLogEventType::PacketDrop, qLogger);\n  EXPECT_EQ(indices.size(), 1);\n  auto tmp = std::move(qLogger->logs[indices[0]]);\n  auto event = dynamic_cast<QLogPacketDropEvent*>(tmp.get());\n  EXPECT_EQ(event->packetSize, 29);\n  EXPECT_EQ(\n      event->dropReason,\n      QuicTransportStatsCallback::toString(\n          PacketDropReason::SERVER_STATE_CLOSED));\n}","target":0,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":409497,"func":"term_cursor_mode(int forced)\n{\n    static int showing_mode = -1;\n    char_u *p;\n\n    \/\/ Only do something when redrawing the screen and we can restore the\n    \/\/ mode.\n    if (!full_screen || *T_CEI == NUL)\n    {\n# ifdef FEAT_TERMRESPONSE\n\tif (forced && initial_cursor_shape > 0)\n\t    \/\/ Restore to initial values.\n\t    term_cursor_shape(initial_cursor_shape, initial_cursor_blink);\n# endif\n\treturn;\n    }\n\n    if ((State & MODE_REPLACE) == MODE_REPLACE)\n    {\n\tif (forced || showing_mode != MODE_REPLACE)\n\t{\n\t    if (*T_CSR != NUL)\n\t\tp = T_CSR;\t\/\/ Replace mode cursor\n\t    else\n\t\tp = T_CSI;\t\/\/ fall back to Insert mode cursor\n\t    if (*p != NUL)\n\t    {\n\t\tout_str(p);\n\t\tshowing_mode = MODE_REPLACE;\n\t    }\n\t}\n    }\n    else if (State & MODE_INSERT)\n    {\n\tif ((forced || showing_mode != MODE_INSERT) && *T_CSI != NUL)\n\t{\n\t    out_str(T_CSI);\t    \/\/ Insert mode cursor\n\t    showing_mode = MODE_INSERT;\n\t}\n    }\n    else if (forced || showing_mode != MODE_NORMAL)\n    {\n\tout_str(T_CEI);\t\t    \/\/ non-Insert mode cursor\n\tshowing_mode = MODE_NORMAL;\n    }\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":254723,"func":"njs_typed_array_from(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    double             num;\n    int64_t            length, i;\n    njs_int_t          ret;\n    njs_value_t        *this, *source, *mapfn;\n    njs_value_t        arguments[3], retval;\n    njs_function_t     *function;\n    njs_typed_array_t  *array;\n\n    this = njs_argument(args, 0);\n\n    if (njs_slow_path(!njs_is_constructor(this))) {\n        njs_type_error(vm, \"%s is not a constructor\",\n                       njs_type_string(this->type));\n        return NJS_ERROR;\n    }\n\n    mapfn = njs_arg(args, nargs, 2);\n\n    if (njs_slow_path(!njs_is_function_or_undefined(mapfn))) {\n        njs_type_error(vm, \"\\\"mapfn\\\" argument is not callable\");\n        return NJS_ERROR;\n    }\n\n    function = NULL;\n    if (njs_is_function(mapfn)) {\n        function = njs_function(mapfn);\n    }\n\n    source = njs_arg(args, nargs, 1);\n\n    ret = njs_value_to_object(vm, source);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_object_length(vm, source, &length);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    njs_set_number(&arguments[0], length);\n    ret = njs_typed_array_create(vm, this, arguments, 1, &vm->retval);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(&vm->retval);\n    arguments[0] = *njs_arg(args, nargs, 3);\n\n    for (i = 0; i < length; i++) {\n        ret = njs_value_property_i64(vm, source, i, &retval);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return NJS_ERROR;\n        }\n\n        if (function != NULL) {\n            arguments[1] = retval;\n            njs_set_number(&arguments[2], i);\n            ret = njs_function_apply(vm, function, arguments, 3, &retval);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return NJS_ERROR;\n            }\n        }\n\n        ret = njs_value_to_number(vm, &retval, &num);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NJS_ERROR;\n        }\n\n        njs_typed_array_prop_set(vm, array, i, num);\n    }\n\n    njs_set_typed_array(&vm->retval, array);\n\n    return NJS_OK;\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":242616,"func":"  Status Put(Tuple* tuple) {\n    std::unique_lock<std::mutex> lock(mu_);\n\n    std::size_t tuple_bytes = GetTupleBytes(*tuple);\n\n    \/\/ Sanity check so that we don't block for ever below\n    if (memory_limit_ > 0 && tuple_bytes > memory_limit_) {\n      return Status(\n          errors::ResourceExhausted(\"Attempted to insert \"\n                                    \"tensors with combined size of '\",\n                                    tuple_bytes,\n                                    \"' bytes into \"\n                                    \"Staging Area with a memory limit of '\",\n                                    memory_limit_, \"'.\"));\n    }\n\n    \/\/ If buffer capacity is bounded wait until elements have been removed\n    if (IsBounded()) {\n      full_cond_var_.wait(lock, [tuple_bytes, this]() {\n        \/\/ If there's a memory limit, check if there's space for insertion\n        bool memory_limit_valid =\n            memory_limit_ > 0 ? !WouldExceedMemoryLimit(tuple_bytes) : true;\n        \/\/ If we're configured for capacity check if there's space for insertion\n        bool capacity_valid = capacity_ > 0 ? !IsCapacityFull() : true;\n\n        \/\/ Stop waiting upon success for both conditions\n        return capacity_valid && memory_limit_valid;\n      });\n    }\n\n    \/\/ Update bytes in the Staging Area\n    current_bytes_ += tuple_bytes;\n\n    \/\/ Store tuple\n    buf_.push_back(std::move(*tuple));\n\n    lock.unlock();\n    \/\/ Notify all removers. Removers\n    \/\/ may be peeking at a specific element or waiting\n    \/\/ for the element at the front of the deque.\n    \/\/ As we don't know the appropriate one to wake up\n    \/\/ we should wake them all.\n    non_empty_cond_var_.notify_all();\n\n    return Status::OK();\n  }","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":453040,"func":"static void nft_fwd_neigh_eval(const struct nft_expr *expr,\n\t\t\t      struct nft_regs *regs,\n\t\t\t      const struct nft_pktinfo *pkt)\n{\n\tstruct nft_fwd_neigh *priv = nft_expr_priv(expr);\n\tvoid *addr = ®s->data[priv->sreg_addr];\n\tint oif = regs->data[priv->sreg_dev];\n\tunsigned int verdict = NF_STOLEN;\n\tstruct sk_buff *skb = pkt->skb;\n\tstruct net_device *dev;\n\tint neigh_table;\n\n\tswitch (priv->nfproto) {\n\tcase NFPROTO_IPV4: {\n\t\tstruct iphdr *iph;\n\n\t\tif (skb->protocol != htons(ETH_P_IP)) {\n\t\t\tverdict = NFT_BREAK;\n\t\t\tgoto out;\n\t\t}\n\t\tif (skb_try_make_writable(skb, sizeof(*iph))) {\n\t\t\tverdict = NF_DROP;\n\t\t\tgoto out;\n\t\t}\n\t\tiph = ip_hdr(skb);\n\t\tip_decrease_ttl(iph);\n\t\tneigh_table = NEIGH_ARP_TABLE;\n\t\tbreak;\n\t\t}\n\tcase NFPROTO_IPV6: {\n\t\tstruct ipv6hdr *ip6h;\n\n\t\tif (skb->protocol != htons(ETH_P_IPV6)) {\n\t\t\tverdict = NFT_BREAK;\n\t\t\tgoto out;\n\t\t}\n\t\tif (skb_try_make_writable(skb, sizeof(*ip6h))) {\n\t\t\tverdict = NF_DROP;\n\t\t\tgoto out;\n\t\t}\n\t\tip6h = ipv6_hdr(skb);\n\t\tip6h->hop_limit--;\n\t\tneigh_table = NEIGH_ND_TABLE;\n\t\tbreak;\n\t\t}\n\tdefault:\n\t\tverdict = NFT_BREAK;\n\t\tgoto out;\n\t}\n\n\tdev = dev_get_by_index_rcu(nft_net(pkt), oif);\n\tif (dev == NULL)\n\t\treturn;\n\n\tskb->dev = dev;\n\tskb->tstamp = 0;\n\tneigh_xmit(neigh_table, dev, addr, skb);\nout:\n\tregs->verdict.code = verdict;\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":202304,"func":"find_match_text(colnr_T startcol, int regstart, char_u *match_text)\n{\n    colnr_T col = startcol;\n    int\t    c1, c2;\n    int\t    len1, len2;\n    int\t    match;\n\n    for (;;)\n    {\n\tmatch = TRUE;\n\tlen2 = MB_CHAR2LEN(regstart); \/\/ skip regstart\n\tfor (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1))\n\t{\n\t    c1 = PTR2CHAR(match_text + len1);\n\t    c2 = PTR2CHAR(rex.line + col + len2);\n\t    if (c1 != c2 && (!rex.reg_ic || MB_CASEFOLD(c1) != MB_CASEFOLD(c2)))\n\t    {\n\t\tmatch = FALSE;\n\t\tbreak;\n\t    }\n\t    len2 += MB_CHAR2LEN(c2);\n\t}\n\tif (match\n\t\t\/\/ check that no composing char follows\n\t\t&& !(enc_utf8\n\t\t\t  && utf_iscomposing(PTR2CHAR(rex.line + col + len2))))\n\t{\n\t    cleanup_subexpr();\n\t    if (REG_MULTI)\n\t    {\n\t\trex.reg_startpos[0].lnum = rex.lnum;\n\t\trex.reg_startpos[0].col = col;\n\t\trex.reg_endpos[0].lnum = rex.lnum;\n\t\trex.reg_endpos[0].col = col + len2;\n\t    }\n\t    else\n\t    {\n\t\trex.reg_startp[0] = rex.line + col;\n\t\trex.reg_endp[0] = rex.line + col + len2;\n\t    }\n\t    return 1L;\n\t}\n\n\t\/\/ Try finding regstart after the current match.\n\tcol += MB_CHAR2LEN(regstart); \/\/ skip regstart\n\tif (skip_to_start(regstart, &col) == FAIL)\n\t    break;\n    }\n    return 0L;\n}","target":1,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":437297,"func":"compile_length_quantifier_node(QuantNode* qn, regex_t* reg)\n{\n  int len, mod_tlen;\n  int infinite = IS_REPEAT_INFINITE(qn->upper);\n  enum QuantBodyEmpty empty_info = qn->body_empty_info;\n  int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg);\n\n  if (tlen < 0) return tlen;\n  if (tlen == 0) return 0;\n\n  \/* anychar repeat *\/\n  if (is_anychar_infinite_greedy(qn)) {\n    if (qn->lower <= 1 ||\n        int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0) {\n      if (IS_NOT_NULL(qn->next_head_exact))\n        return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower;\n      else\n        return SIZE_OP_ANYCHAR_STAR + tlen * qn->lower;\n    }\n  }\n\n  if (empty_info == QUANT_BODY_IS_NOT_EMPTY)\n    mod_tlen = tlen;\n  else\n    mod_tlen = tlen + (SIZE_OP_EMPTY_CHECK_START + SIZE_OP_EMPTY_CHECK_END);\n\n  if (infinite &&\n      (qn->lower <= 1 ||\n       int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) {\n    if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {\n      len = SIZE_OP_JUMP;\n    }\n    else {\n      len = tlen * qn->lower;\n    }\n\n    if (qn->greedy) {\n      if (IS_NOT_NULL(qn->head_exact))\n        len += SIZE_OP_PUSH_OR_JUMP_EXACT1 + mod_tlen + SIZE_OP_JUMP;\n      else if (IS_NOT_NULL(qn->next_head_exact))\n        len += SIZE_OP_PUSH_IF_PEEK_NEXT + mod_tlen + SIZE_OP_JUMP;\n      else\n        len += SIZE_OP_PUSH + mod_tlen + SIZE_OP_JUMP;\n    }\n    else\n      len += SIZE_OP_JUMP + mod_tlen + SIZE_OP_PUSH;\n  }\n  else if (qn->upper == 0 && qn->is_refered != 0) { \/* \/(?<n>..){0}\/ *\/\n    len = SIZE_OP_JUMP + tlen;\n  }\n  else if (!infinite && qn->greedy &&\n           (qn->upper == 1 ||\n            int_multiply_cmp(tlen + SIZE_OP_PUSH, qn->upper,\n                             QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) {\n    len = tlen * qn->lower;\n    len += (SIZE_OP_PUSH + tlen) * (qn->upper - qn->lower);\n  }\n  else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { \/* '??' *\/\n    len = SIZE_OP_PUSH + SIZE_OP_JUMP + tlen;\n  }\n  else {\n    len = SIZE_OP_REPEAT_INC\n        + mod_tlen + SIZE_OPCODE + SIZE_RELADDR + SIZE_MEMNUM;\n  }\n\n  return len;\n}","target":0,"code_token_length":669,"total_token_length":905,"max_tokens_setting":1024}
+{"idx":274728,"func":"callbacks_drawingarea_button_release_event (GtkWidget *widget, GdkEventButton *event)\n{\n\tgint index;\n\n\tif (event->type != GDK_BUTTON_RELEASE)\n\t\treturn TRUE;\n\n\tswitch (screen.state) {\n\tcase IN_MOVE:\n\t\tscreen.off_x = 0;\n\t\tscreen.off_y = 0;\n\t\trender_refresh_rendered_image_on_screen ();\n\t\tcallbacks_switch_to_normal_tool_cursor (screen.tool);\n\t\tbreak;\n\n\tcase IN_ZOOM_OUTLINE:\n\t\tif ((event->state & GDK_SHIFT_MASK) != 0) {\n\t\t\trender_zoom_display (ZOOM_OUT_CMOUSE, 0,\n\t\t\t\t\tevent->x, event->y);\n\t\t}\n\t\t\/* if the user just clicks without dragging, then simply\n\t\t   zoom in a preset amount *\/\n\t\telse if ((abs(screen.start_x - event->x) < 4) &&\n\t\t\t\t(abs(screen.start_y - event->y) < 4)) {\n\t\t\trender_zoom_display (ZOOM_IN_CMOUSE, 0,\n\t\t\t\t\tevent->x, event->y);\n\t\t} else {\n\t\t\trender_calculate_zoom_from_outline (widget, event);\n\t\t}\n\t\tcallbacks_switch_to_normal_tool_cursor (screen.tool);\n\t\tbreak;\n\n\tcase IN_SELECTION_DRAG:\n\t\t\/* selection will only work with cairo, so do nothing if it's\n\t\t   not compiled *\/\n\t\tindex = callbacks_get_selected_row_index ();\n\n\t\tif ((index >= 0) && mainProject->file[index]->isVisible) {\n\t\t\tenum selection_action sel_action = SELECTION_REPLACE;\n\t\t\t\n\t\t\tif (event->state & GDK_SHIFT_MASK)\n\t\t\t\tsel_action = SELECTION_ADD;\n\t\t\telse if (event->state & GDK_CONTROL_MASK)\n\t\t\t\tsel_action = SELECTION_TOGGLE;\n\n\t\t\t\/* determine if this was just a click or a box drag *\/\n\t\t\tif ((fabs((double)(screen.last_x - screen.start_x)) < 5)\n\t\t\t && (fabs((double)(screen.last_y - screen.start_y)) < 5)) {\n\t\t\t\trender_fill_selection_buffer_from_mouse_click (\n\t\t\t\t\t\tevent->x, event->y, index,\n\t\t\t\t\t\tsel_action);\n\t\t\t} else {\n\t\t\t\trender_fill_selection_buffer_from_mouse_drag (\n\t\t\t\t\t\tevent->x, event->y,\n\t\t\t\t\t\tscreen.start_x, screen.start_y,\n\t\t\t\t\t\tindex, sel_action);\n\t\t\t}\n\n\t\t\t\/* Check if anything was selected *\/\n\t\t\tupdate_selected_object_message (TRUE);\n\n\t\t\tcheck_align_files_possibility (&screen.selectionInfo);\n\t\t} else {\n\t\t\trender_refresh_rendered_image_on_screen ();\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tscreen.state = NORMAL;\n\n\treturn TRUE;\n} \/* button_release_event *\/","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":213528,"func":"int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)\n{\n\tstruct cgroup_fs_context *ctx = cgroup_fc2context(fc);\n\tstruct cgroup_subsys *ss;\n\tstruct fs_parse_result result;\n\tint opt, i;\n\n\topt = fs_parse(fc, cgroup1_fs_parameters, param, &result);\n\tif (opt == -ENOPARAM) {\n\t\tif (strcmp(param->key, \"source\") == 0) {\n\t\t\tif (fc->source)\n\t\t\t\treturn invalf(fc, \"Multiple sources not supported\");\n\t\t\tfc->source = param->string;\n\t\t\tparam->string = NULL;\n\t\t\treturn 0;\n\t\t}\n\t\tfor_each_subsys(ss, i) {\n\t\t\tif (strcmp(param->key, ss->legacy_name))\n\t\t\t\tcontinue;\n\t\t\tif (!cgroup_ssid_enabled(i) || cgroup1_ssid_disabled(i))\n\t\t\t\treturn invalfc(fc, \"Disabled controller '%s'\",\n\t\t\t\t\t       param->key);\n\t\t\tctx->subsys_mask |= (1 << i);\n\t\t\treturn 0;\n\t\t}\n\t\treturn invalfc(fc, \"Unknown subsys name '%s'\", param->key);\n\t}\n\tif (opt < 0)\n\t\treturn opt;\n\n\tswitch (opt) {\n\tcase Opt_none:\n\t\t\/* Explicitly have no subsystems *\/\n\t\tctx->none = true;\n\t\tbreak;\n\tcase Opt_all:\n\t\tctx->all_ss = true;\n\t\tbreak;\n\tcase Opt_noprefix:\n\t\tctx->flags |= CGRP_ROOT_NOPREFIX;\n\t\tbreak;\n\tcase Opt_clone_children:\n\t\tctx->cpuset_clone_children = true;\n\t\tbreak;\n\tcase Opt_cpuset_v2_mode:\n\t\tctx->flags |= CGRP_ROOT_CPUSET_V2_MODE;\n\t\tbreak;\n\tcase Opt_xattr:\n\t\tctx->flags |= CGRP_ROOT_XATTR;\n\t\tbreak;\n\tcase Opt_release_agent:\n\t\t\/* Specifying two release agents is forbidden *\/\n\t\tif (ctx->release_agent)\n\t\t\treturn invalfc(fc, \"release_agent respecified\");\n\t\tctx->release_agent = param->string;\n\t\tparam->string = NULL;\n\t\tbreak;\n\tcase Opt_name:\n\t\t\/* blocked by boot param? *\/\n\t\tif (cgroup_no_v1_named)\n\t\t\treturn -ENOENT;\n\t\t\/* Can't specify an empty name *\/\n\t\tif (!param->size)\n\t\t\treturn invalfc(fc, \"Empty name\");\n\t\tif (param->size > MAX_CGROUP_ROOT_NAMELEN - 1)\n\t\t\treturn invalfc(fc, \"Name too long\");\n\t\t\/* Must match [\\w.-]+ *\/\n\t\tfor (i = 0; i < param->size; i++) {\n\t\t\tchar c = param->string[i];\n\t\t\tif (isalnum(c))\n\t\t\t\tcontinue;\n\t\t\tif ((c == '.') || (c == '-') || (c == '_'))\n\t\t\t\tcontinue;\n\t\t\treturn invalfc(fc, \"Invalid name\");\n\t\t}\n\t\t\/* Specifying two names is forbidden *\/\n\t\tif (ctx->name)\n\t\t\treturn invalfc(fc, \"name respecified\");\n\t\tctx->name = param->string;\n\t\tparam->string = NULL;\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":1,"code_token_length":652,"total_token_length":888,"max_tokens_setting":1024}
+{"idx":333503,"func":"static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, unsigned int windows_size)\n{\n\tunsigned int u = 0;\n\tLineContribType *res;\n\tint overflow_error = 0;\n\n\tres = (LineContribType *) gdMalloc(sizeof(LineContribType));\n\tif (!res) {\n\t\treturn NULL;\n\t}\n\tres->WindowSize = windows_size;\n\tres->LineLength = line_length;\n\tif (overflow2(line_length, sizeof(ContributionType))) {\n\t\tgdFree(res);\n\t\treturn NULL;\n\t}\n\tres->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));\n\tif (res->ContribRow == NULL) {\n\t\tgdFree(res);\n\t\treturn NULL;\n\t}\n\tfor (u = 0 ; u < line_length ; u++) {\n\t\tif (overflow2(windows_size, sizeof(double))) {\n\t\t\toverflow_error = 1;\n\t\t} else {\n\t\t\tres->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));\n\t\t}\n\t\tif (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {\n\t\t\tunsigned int i;\n\t\t\tu--;\n\t\t\tfor (i=0;i<=u;i++) {\n\t\t\t\tgdFree(res->ContribRow[i].Weights);\n\t\t\t}\n\t\t\tgdFree(res);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\treturn res;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":244065,"func":"GF_Err chnl_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u8(bs, ptr->layout.stream_structure);\n\tif (ptr->layout.stream_structure & 1) {\n\t\tgf_bs_write_u8(bs, ptr->layout.definedLayout);\n\t\tif (ptr->layout.definedLayout==0) {\n\t\t\tu32 i;\n\t\t\tfor (i=0; i<ptr->layout.channels_count; i++) {\n\t\t\t\tgf_bs_write_u8(bs, ptr->layout.layouts[i].position);\n\t\t\t\tif (ptr->layout.layouts[i].position==126) {\n\t\t\t\t\tgf_bs_write_int(bs, ptr->layout.layouts[i].azimuth, 16);\n\t\t\t\t\tgf_bs_write_int(bs, ptr->layout.layouts[i].elevation, 8);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tgf_bs_write_u64(bs, ptr->layout.omittedChannelsMap);\n\t\t}\n\t}\n\tif (ptr->layout.stream_structure & 2) {\n\t\tgf_bs_write_u8(bs, ptr->layout.object_count);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":498918,"func":"pax_decode_header (struct tar_sparse_file *file)\n{\n  if (file->stat_info->sparse_major > 0)\n    {\n      uintmax_t u;\n      char nbuf[UINTMAX_STRSIZE_BOUND];\n      union block *blk;\n      char *p;\n      size_t i;\n      off_t start;\n      \n#define COPY_BUF(b,buf,src) do                                     \\\n {                                                                 \\\n   char *endp = b->buffer + BLOCKSIZE;                             \\\n   char *dst = buf;                                                \\\n   do                                                              \\\n     {                                                             \\\n       if (dst == buf + UINTMAX_STRSIZE_BOUND -1)                  \\\n         {                                                         \\\n           ERROR ((0, 0, _(\"%s: numeric overflow in sparse archive member\"), \\\n\t          file->stat_info->orig_file_name));               \\\n           return false;                                           \\\n         }                                                         \\\n       if (src == endp)                                            \\\n\t {                                                         \\\n\t   set_next_block_after (b);                               \\\n           b = find_next_block ();                                 \\\n           if (!b)                                                 \\\n             FATAL_ERROR ((0, 0, _(\"Unexpected EOF in archive\"))); \\\n           src = b->buffer;                                        \\\n\t   endp = b->buffer + BLOCKSIZE;                           \\\n\t }                                                         \\\n       *dst = *src++;                                              \\\n     }                                                             \\\n   while (*dst++ != '\\n');                                         \\\n   dst[-1] = 0;                                                    \\\n } while (0)\n\n      start = current_block_ordinal ();\n      set_next_block_after (current_header);\n      blk = find_next_block ();\n      if (!blk)\n        FATAL_ERROR ((0, 0, _(\"Unexpected EOF in archive\")));\n      p = blk->buffer;\n      COPY_BUF (blk,nbuf,p);\n      if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))\n\t{\n\t  ERROR ((0, 0, _(\"%s: malformed sparse archive member\"),\n\t\t  file->stat_info->orig_file_name));\n\t  return false;\n\t}\n      file->stat_info->sparse_map_size = u;\n      file->stat_info->sparse_map = xcalloc (file->stat_info->sparse_map_size,\n\t\t\t\t\t     sizeof (*file->stat_info->sparse_map));\n      file->stat_info->sparse_map_avail = 0;\n      for (i = 0; i < file->stat_info->sparse_map_size; i++)\n\t{\n\t  struct sp_array sp;\n\n\t  COPY_BUF (blk,nbuf,p);\n\t  if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t)))\n\t    {\n\t      ERROR ((0, 0, _(\"%s: malformed sparse archive member\"),\n\t\t      file->stat_info->orig_file_name));\n\t      return false;\n\t    }\n\t  sp.offset = u;\n\t  COPY_BUF (blk,nbuf,p);\n\t  if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t)))\n\t    {\n\t      ERROR ((0, 0, _(\"%s: malformed sparse archive member\"),\n\t\t      file->stat_info->orig_file_name));\n\t      return false;\n\t    }\n\t  sp.numbytes = u;\n\t  sparse_add_map (file->stat_info, &sp);\n\t}\n      set_next_block_after (blk);\n\n      file->dumped_size += BLOCKSIZE * (current_block_ordinal () - start);\n    }\n\n  return true;\n}","target":0,"code_token_length":683,"total_token_length":919,"max_tokens_setting":1024}
+{"idx":255031,"func":"static int adts_write_frame_header(ADTSContext *ctx,\n                                   uint8_t *buf, int size, int pce_size)\n{\n    PutBitContext pb;\n\n    unsigned full_frame_size = (unsigned)ADTS_HEADER_SIZE + size + pce_size;\n    if (full_frame_size > ADTS_MAX_FRAME_BYTES) {\n        av_log(NULL, AV_LOG_ERROR, \"ADTS frame size too large: %u (max %d)\\n\",\n               full_frame_size, ADTS_MAX_FRAME_BYTES);\n        return AVERROR_INVALIDDATA;\n    }\n\n    init_put_bits(&pb, buf, ADTS_HEADER_SIZE);\n\n    \/* adts_fixed_header *\/\n    put_bits(&pb, 12, 0xfff);   \/* syncword *\/\n    put_bits(&pb, 1, ctx->mpeg_id); \/* ID *\/\n    put_bits(&pb, 2, 0);        \/* layer *\/\n    put_bits(&pb, 1, 1);        \/* protection_absent *\/\n    put_bits(&pb, 2, ctx->objecttype); \/* profile_objecttype *\/\n    put_bits(&pb, 4, ctx->sample_rate_index);\n    put_bits(&pb, 1, 0);        \/* private_bit *\/\n    put_bits(&pb, 3, ctx->channel_conf); \/* channel_configuration *\/\n    put_bits(&pb, 1, 0);        \/* original_copy *\/\n    put_bits(&pb, 1, 0);        \/* home *\/\n\n    \/* adts_variable_header *\/\n    put_bits(&pb, 1, 0);        \/* copyright_identification_bit *\/\n    put_bits(&pb, 1, 0);        \/* copyright_identification_start *\/\n    put_bits(&pb, 13, full_frame_size); \/* aac_frame_length *\/\n    put_bits(&pb, 11, 0x7ff);   \/* adts_buffer_fullness *\/\n    put_bits(&pb, 2, 0);        \/* number_of_raw_data_blocks_in_frame *\/\n\n    flush_put_bits(&pb);\n\n    return 0;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":231715,"func":"void onConnectionMigration(\n    QuicServerConnectionState& conn,\n    const folly::SocketAddress& newPeerAddress,\n    bool isIntentional) {\n  if (conn.migrationState.numMigrations >= kMaxNumMigrationsAllowed) {\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(\n          0,\n          QuicTransportStatsCallback::toString(\n              PacketDropReason::PEER_ADDRESS_CHANGE));\n    }\n    QUIC_STATS(\n        conn.statsCallback,\n        onPacketDropped,\n        PacketDropReason::PEER_ADDRESS_CHANGE);\n    throw QuicTransportException(\n        \"Too many migrations\", TransportErrorCode::INVALID_MIGRATION);\n  }\n  ++conn.migrationState.numMigrations;\n\n  bool hasPendingPathChallenge = conn.pendingEvents.pathChallenge.has_value();\n  \/\/ Clear any pending path challenge frame that is not sent\n  conn.pendingEvents.pathChallenge = folly::none;\n\n  auto& previousPeerAddresses = conn.migrationState.previousPeerAddresses;\n  auto it = std::find(\n      previousPeerAddresses.begin(),\n      previousPeerAddresses.end(),\n      newPeerAddress);\n  if (it == previousPeerAddresses.end()) {\n    \/\/ Send new path challenge\n    uint64_t pathData;\n    folly::Random::secureRandom(&pathData, sizeof(pathData));\n    conn.pendingEvents.pathChallenge = PathChallengeFrame(pathData);\n\n    \/\/ If we are already in the middle of a migration reset\n    \/\/ the available bytes in the rate-limited window, but keep the\n    \/\/ window.\n    conn.pathValidationLimiter =\n        std::make_unique<PendingPathRateLimiter>(conn.udpSendPacketLen);\n  } else {\n    previousPeerAddresses.erase(it);\n  }\n\n  \/\/ At this point, path validation scheduled, writable bytes limit set\n  \/\/ However if this is NAT rebinding, keep congestion state unchanged\n  bool isNATRebinding = maybeNATRebinding(newPeerAddress, conn.peerAddress);\n\n  \/\/ Cancel current path validation if any\n  if (hasPendingPathChallenge || conn.outstandingPathValidation) {\n    conn.pendingEvents.schedulePathValidationTimeout = false;\n    conn.outstandingPathValidation = folly::none;\n\n    \/\/ Only change congestion & rtt state if not NAT rebinding\n    if (!isNATRebinding) {\n      recoverOrResetCongestionAndRttState(conn, newPeerAddress);\n    }\n  } else {\n    \/\/ Only add validated addresses to previousPeerAddresses\n    conn.migrationState.previousPeerAddresses.push_back(conn.peerAddress);\n\n    \/\/ Only change congestion & rtt state if not NAT rebinding\n    if (!isNATRebinding) {\n      \/\/ Current peer address is validated,\n      \/\/ remember its congestion state and rtt stats\n      CongestionAndRttState state = moveCurrentCongestionAndRttState(conn);\n      recoverOrResetCongestionAndRttState(conn, newPeerAddress);\n      conn.migrationState.lastCongestionAndRtt = std::move(state);\n    }\n  }\n\n  if (conn.qLogger) {\n    conn.qLogger->addConnectionMigrationUpdate(isIntentional);\n  }\n  conn.peerAddress = newPeerAddress;\n}","target":0,"code_token_length":661,"total_token_length":897,"max_tokens_setting":1024}
+{"idx":200934,"func":"testBackingParse(const void *args)\n{\n    const struct testBackingParseData *data = args;\n    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;\n    g_autofree char *xml = NULL;\n    g_autoptr(virStorageSource) src = NULL;\n    int rc;\n    int erc = data->rv;\n\n    \/* expect failure return code with NULL expected data *\/\n    if (!data->expect)\n        erc = -1;\n\n    if ((rc = virStorageSourceNewFromBackingAbsolute(data->backing, &src)) != erc) {\n        fprintf(stderr, \"expected return value '%d' actual '%d'\\n\", erc, rc);\n        return -1;\n    }\n\n    if (!src)\n        return 0;\n\n    if (src && !data->expect) {\n        fprintf(stderr, \"parsing of backing store string '%s' should \"\n                        \"have failed\\n\", data->backing);\n        return -1;\n    }\n\n    if (virDomainDiskSourceFormat(&buf, src, \"source\", 0, false, 0, true, NULL) < 0 ||\n        !(xml = virBufferContentAndReset(&buf))) {\n        fprintf(stderr, \"failed to format disk source xml\\n\");\n        return -1;\n    }\n\n    if (STRNEQ(xml, data->expect)) {\n        fprintf(stderr, \"\\n backing store string '%s'\\n\"\n                        \"expected storage source xml:\\n%s\\n\"\n                        \"actual storage source xml:\\n%s\\n\",\n                        data->backing, data->expect, xml);\n        return -1;\n    }\n\n    return 0;\n}","target":1,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":259224,"func":"static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n    unsigned int i, entries, ctts_count = 0;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n    sc = st->priv_data;\n\n    avio_r8(pb); \/* version *\/\n    avio_rb24(pb); \/* flags *\/\n    entries = avio_rb32(pb);\n\n    av_log(c->fc, AV_LOG_TRACE, \"track[%u].ctts.entries = %u\\n\", c->fc->nb_streams - 1, entries);\n\n    if (!entries)\n        return 0;\n    if (entries >= UINT_MAX \/ sizeof(*sc->ctts_data))\n        return AVERROR_INVALIDDATA;\n    av_freep(&sc->ctts_data);\n    sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, entries * sizeof(*sc->ctts_data));\n    if (!sc->ctts_data)\n        return AVERROR(ENOMEM);\n\n    for (i = 0; i < entries && !pb->eof_reached; i++) {\n        int count    = avio_rb32(pb);\n        int duration = avio_rb32(pb);\n\n        if (count <= 0) {\n            av_log(c->fc, AV_LOG_TRACE,\n                   \"ignoring CTTS entry with count=%d duration=%d\\n\",\n                   count, duration);\n            continue;\n        }\n\n        add_ctts_entry(&sc->ctts_data, &ctts_count, &sc->ctts_allocated_size,\n                       count, duration);\n\n        av_log(c->fc, AV_LOG_TRACE, \"count=%d, duration=%d\\n\",\n                count, duration);\n\n        if (FFNABS(duration) < -(1<<28) && i+2<entries) {\n            av_log(c->fc, AV_LOG_WARNING, \"CTTS invalid\\n\");\n            av_freep(&sc->ctts_data);\n            sc->ctts_count = 0;\n            return 0;\n        }\n\n        if (i+2<entries)\n            mov_update_dts_shift(sc, duration, c->fc);\n    }\n\n    sc->ctts_count = ctts_count;\n\n    if (pb->eof_reached) {\n        av_log(c->fc, AV_LOG_WARNING, \"reached eof, corrupted CTTS atom\\n\");\n        return AVERROR_EOF;\n    }\n\n    av_log(c->fc, AV_LOG_TRACE, \"dts shift %d\\n\", sc->dts_shift);\n\n    return 0;\n}","target":0,"code_token_length":573,"total_token_length":809,"max_tokens_setting":1024}
+{"idx":424905,"func":"static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,\n\t\t\t\t    enum iwl_d3_status *status,\n\t\t\t\t    bool test,  bool reset)\n{\n\tstruct iwl_trans_pcie *trans_pcie =  IWL_TRANS_GET_PCIE_TRANS(trans);\n\tu32 val;\n\tint ret;\n\n\tif (test) {\n\t\tiwl_enable_interrupts(trans);\n\t\t*status = IWL_D3_STATUS_ALIVE;\n\t\tgoto out;\n\t}\n\n\tiwl_set_bit(trans, CSR_GP_CNTRL,\n\t\t    BIT(trans->trans_cfg->csr->flag_mac_access_req));\n\n\tret = iwl_finish_nic_init(trans, trans->trans_cfg);\n\tif (ret)\n\t\treturn ret;\n\n\t\/*\n\t * Reconfigure IVAR table in case of MSIX or reset ict table in\n\t * MSI mode since HW reset erased it.\n\t * Also enables interrupts - none will happen as\n\t * the device doesn't know we're waking it up, only when\n\t * the opmode actually tells it after this call.\n\t *\/\n\tiwl_pcie_conf_msix_hw(trans_pcie);\n\tif (!trans_pcie->msix_enabled)\n\t\tiwl_pcie_reset_ict(trans);\n\tiwl_enable_interrupts(trans);\n\n\tiwl_pcie_set_pwr(trans, false);\n\n\tif (!reset) {\n\t\tiwl_clear_bit(trans, CSR_GP_CNTRL,\n\t\t\t      BIT(trans->trans_cfg->csr->flag_mac_access_req));\n\t} else {\n\t\tiwl_trans_pcie_tx_reset(trans);\n\n\t\tret = iwl_pcie_rx_init(trans);\n\t\tif (ret) {\n\t\t\tIWL_ERR(trans,\n\t\t\t\t\"Failed to resume the device (RX reset)\\n\");\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\tIWL_DEBUG_POWER(trans, \"WFPM value upon resume = 0x%08X\\n\",\n\t\t\tiwl_read_umac_prph(trans, WFPM_GP2));\n\n\tval = iwl_read32(trans, CSR_RESET);\n\tif (val & CSR_RESET_REG_FLAG_NEVO_RESET)\n\t\t*status = IWL_D3_STATUS_RESET;\n\telse\n\t\t*status = IWL_D3_STATUS_ALIVE;\n\nout:\n\tif (*status == IWL_D3_STATUS_ALIVE &&\n\t    trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {\n\t\ttrans_pcie->sx_complete = false;\n\t\tiwl_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6,\n\t\t\t\t    UREG_DOORBELL_TO_ISR6_RESUME);\n\n\t\tret = wait_event_timeout(trans_pcie->sx_waitq,\n\t\t\t\t\t trans_pcie->sx_complete, 2 * HZ);\n\t\t\/*\n\t\t * Invalidate it toward next suspend.\n\t\t *\/\n\t\ttrans_pcie->sx_complete = false;\n\n\t\tif (!ret) {\n\t\t\tIWL_ERR(trans, \"Timeout exiting D3\\n\");\n\t\t\treturn -ETIMEDOUT;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":277480,"func":"size_t mobi_trie_get_inflgroups(char **infl_strings, MOBITrie * const root, const char *string) {\n    \/* travers trie and get values for each substring *\/\n    if (root == NULL) {\n        return MOBI_PARAM_ERR;\n    }\n    size_t count = 0;\n    size_t length = strlen(string);\n    MOBITrie *node = root;\n    while (node && length > 0) {\n        char **values = NULL;\n        size_t values_count = 0;\n        node = mobi_trie_get_next(&values, &values_count, node, string[length - 1]);\n        length--;\n        for (size_t j = 0; j < values_count; j++) {\n            if (count == INDX_INFLSTRINGS_MAX) {\n                debug_print(\"Inflection strings array too small (%d)\\n\", INDX_INFLSTRINGS_MAX);\n                break;\n            }\n            char infl_string[INDX_LABEL_SIZEMAX + 1];\n            const size_t suffix_length = strlen(values[j]);\n            if (length + suffix_length > INDX_LABEL_SIZEMAX) {\n                debug_print(\"Label too long (%zu + %zu)\\n\", length, suffix_length);\n                continue;\n            }\n            memcpy(infl_string, string, length);\n            memcpy(infl_string + length, values[j], suffix_length);\n            infl_string[length + suffix_length] = '\\0';\n            infl_strings[count++] = strdup(infl_string);\n        }\n    }\n    return count;\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":482503,"func":"allocateSpaceInTranslationTable(const FileInfo *file, TranslationTableOffset *offset,\n\t\tint size, TranslationTableHeader **table) {\n\t\/* allocate memory for table and expand previously allocated memory if necessary *\/\n\tint spaceNeeded = ((size + OFFSETSIZE - 1) \/ OFFSETSIZE) * OFFSETSIZE;\n\tTranslationTableOffset newTableSize = (*table)->bytesUsed + spaceNeeded;\n\tTranslationTableOffset tableSize = (*table)->tableSize;\n\tif (newTableSize > tableSize) {\n\t\tTranslationTableHeader *newTable;\n\t\tnewTableSize += (newTableSize \/ OFFSETSIZE);\n\t\tnewTable = realloc(*table, newTableSize);\n\t\tif (!newTable) {\n\t\t\tcompileError(file, \"Not enough memory for translation table.\");\n\t\t\t_lou_outOfMemory();\n\t\t}\n\t\tmemset(((unsigned char *)newTable) + tableSize, 0, newTableSize - tableSize);\n\t\t\/* update references to the old table *\/\n\t\t{\n\t\t\tTranslationTableChainEntry *entry;\n\t\t\tfor (entry = translationTableChain; entry != NULL; entry = entry->next)\n\t\t\t\tif (entry->table == *table)\n\t\t\t\t\tentry->table = (TranslationTableHeader *)newTable;\n\t\t}\n\t\tnewTable->tableSize = newTableSize;\n\t\t*table = newTable;\n\t}\n\tif (offset != NULL) {\n\t\t*offset = ((*table)->bytesUsed - sizeof(**table)) \/ OFFSETSIZE;\n\t\t(*table)->bytesUsed += spaceNeeded;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":335422,"func":"ex_behave(exarg_T *eap)\n{\n    if (STRCMP(eap->arg, \"mswin\") == 0)\n    {\n\tset_option_value_give_err((char_u *)\"selection\",\n\t\t\t\t\t\t 0L, (char_u *)\"exclusive\", 0);\n\tset_option_value_give_err((char_u *)\"selectmode\",\n\t\t\t\t\t\t 0L, (char_u *)\"mouse,key\", 0);\n\tset_option_value_give_err((char_u *)\"mousemodel\",\n\t\t\t\t\t\t     0L, (char_u *)\"popup\", 0);\n\tset_option_value_give_err((char_u *)\"keymodel\",\n\t\t\t\t\t  0L, (char_u *)\"startsel,stopsel\", 0);\n    }\n    else if (STRCMP(eap->arg, \"xterm\") == 0)\n    {\n\tset_option_value_give_err((char_u *)\"selection\",\n\t\t\t\t\t\t 0L, (char_u *)\"inclusive\", 0);\n\tset_option_value_give_err((char_u *)\"selectmode\", 0L, (char_u *)\"\", 0);\n\tset_option_value_give_err((char_u *)\"mousemodel\",\n\t\t\t\t\t\t    0L, (char_u *)\"extend\", 0);\n\tset_option_value_give_err((char_u *)\"keymodel\", 0L, (char_u *)\"\", 0);\n    }\n    else\n\tsemsg(_(e_invalid_argument_str), eap->arg);\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":272342,"func":"find_slot_for_token(cms_context *cms, PK11SlotInfo **slot)\n{\n\tif (!cms->tokenname) {\n\t\tcms->log(cms, LOG_ERR, \"no token name specified\");\n\t\treturn -1;\n\t}\n\n\tchar *tokenname = resolve_token_name(cms->tokenname);\n\n\tdprintf(\"setting password function to %s\", cms->func ? \"cms->func\" : \"SECU_GetModulePassword\");\n\tPK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);\n\n\tPK11SlotList *slots = NULL;\n\tslots = PK11_GetAllTokens(CKM_RSA_PKCS, PR_FALSE, PR_TRUE, cms);\n\tif (!slots)\n\t\tcnreterr(-1, cms, \"could not get pk11 token list\");\n\n\tPK11SlotListElement *psle = NULL;\n\tpsle = PK11_GetFirstSafe(slots);\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tcnreterr(-1, cms, \"could not get pk11 safe\");\n\t}\n\n\twhile (psle) {\n\t\tif (!strcmp(tokenname, PK11_GetTokenName(psle->slot)))\n\t\t\tbreak;\n\n\t\tpsle = PK11_GetNextSafe(slots, psle, PR_FALSE);\n\t}\n\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tnssreterr(-1, \"Could not find token \\\"%s\\\"\", tokenname);\n\t}\n\n\tSECStatus status;\n\tif (PK11_NeedLogin(psle->slot) && !PK11_IsLoggedIn(psle->slot, cms)) {\n\t\tstatus = PK11_Authenticate(psle->slot, PR_TRUE, cms);\n\t\tif (status != SECSuccess) {\n\t\t\tsave_port_err() {\n\t\t\t\tint err = PORT_GetError();\n\t\t\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\t\t\tPK11_FreeSlotList(slots);\n\t\t\t\tcms->log(cms, LOG_ERR,\n\t\t\t\t\t \"authentication failed for token \\\"%s\\\": %s\",\n\t\t\t\t\t tokenname, PORT_ErrorToString(err));\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n\t*slot = psle->slot;\n\n\tPK11_DestroySlotListElement(slots, &psle);\n\tPK11_FreeSlotList(slots);\n\treturn 0;\n}","target":0,"code_token_length":527,"total_token_length":763,"max_tokens_setting":1024}
+{"idx":252361,"func":"static FP16 float_to_half_full(FP32 f) {\n  FP16 o = {0};\n\n  \/\/ Based on ISPC reference code (with minor modifications)\n  if (f.s.Exponent == 0)  \/\/ Signed zero\/denormal (which will underflow)\n    o.s.Exponent = 0;\n  else if (f.s.Exponent == 255)  \/\/ Inf or NaN (all exponent bits set)\n  {\n    o.s.Exponent = 31;\n    o.s.Mantissa = f.s.Mantissa ? 0x200 : 0;  \/\/ NaN->qNaN and Inf->Inf\n  } else                                      \/\/ Normalized number\n  {\n    \/\/ Exponent unbias the single, then bias the halfp\n    int newexp = f.s.Exponent - 127 + 15;\n    if (newexp >= 31)  \/\/ Overflow, return signed infinity\n      o.s.Exponent = 31;\n    else if (newexp <= 0)  \/\/ Underflow\n    {\n      if ((14 - newexp) <= 24)  \/\/ Mantissa might be non-zero\n      {\n        unsigned int mant = f.s.Mantissa | 0x800000;  \/\/ Hidden 1 bit\n        o.s.Mantissa = mant >> (14 - newexp);\n        if ((mant >> (13 - newexp)) & 1)  \/\/ Check for rounding\n          o.u++;  \/\/ Round, might overflow into exp bit, but this is OK\n      }\n    } else {\n      o.s.Exponent = static_cast<unsigned int>(newexp);\n      o.s.Mantissa = f.s.Mantissa >> 13;\n      if (f.s.Mantissa & 0x1000)  \/\/ Check for rounding\n        o.u++;                    \/\/ Round, might overflow to inf, this is OK\n    }\n  }\n\n  o.s.Sign = f.s.Sign;\n  return o;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":336805,"func":"lprn_get_params(gx_device * dev, gs_param_list * plist)\n{\n    gx_device_lprn *const lprn = (gx_device_lprn *) dev;\n    int code = gdev_prn_get_params(dev, plist);\n    int ncode;\n\n    if (code < 0)\n        return code;\n\n    if ((ncode = param_write_bool(plist, \"ManualFeed\", &lprn->ManualFeed)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_bool(plist, \"NegativePrint\", &lprn->NegativePrint)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_bool(plist, \"Tumble\", &lprn->Tumble)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_bool(plist, \"RITOff\", &lprn->RITOff)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_int(plist, \"BlockLine\", &lprn->BlockLine)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_int(plist, \"BlockWidth\", &lprn->nBw)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_int(plist, \"BlockHeight\", &lprn->nBh)) < 0)\n        code = ncode;\n\n    if ((ncode = param_write_bool(plist, \"ShowBubble\", &lprn->ShowBubble)) < 0)\n        code = ncode;\n\n    return code;\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":238578,"func":"static int check_cfg(struct bpf_verifier_env *env)\n{\n\tint insn_cnt = env->prog->len;\n\tint *insn_stack, *insn_state;\n\tint ret = 0;\n\tint i;\n\n\tinsn_state = env->cfg.insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL);\n\tif (!insn_state)\n\t\treturn -ENOMEM;\n\n\tinsn_stack = env->cfg.insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL);\n\tif (!insn_stack) {\n\t\tkvfree(insn_state);\n\t\treturn -ENOMEM;\n\t}\n\n\tinsn_state[0] = DISCOVERED; \/* mark 1st insn as discovered *\/\n\tinsn_stack[0] = 0; \/* 0 is the first instruction *\/\n\tenv->cfg.cur_stack = 1;\n\n\twhile (env->cfg.cur_stack > 0) {\n\t\tint t = insn_stack[env->cfg.cur_stack - 1];\n\n\t\tret = visit_insn(t, insn_cnt, env);\n\t\tswitch (ret) {\n\t\tcase DONE_EXPLORING:\n\t\t\tinsn_state[t] = EXPLORED;\n\t\t\tenv->cfg.cur_stack--;\n\t\t\tbreak;\n\t\tcase KEEP_EXPLORING:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (ret > 0) {\n\t\t\t\tverbose(env, \"visit_insn internal bug\\n\");\n\t\t\t\tret = -EFAULT;\n\t\t\t}\n\t\t\tgoto err_free;\n\t\t}\n\t}\n\n\tif (env->cfg.cur_stack < 0) {\n\t\tverbose(env, \"pop stack internal bug\\n\");\n\t\tret = -EFAULT;\n\t\tgoto err_free;\n\t}\n\n\tfor (i = 0; i < insn_cnt; i++) {\n\t\tif (insn_state[i] != EXPLORED) {\n\t\t\tverbose(env, \"unreachable insn %d\\n\", i);\n\t\t\tret = -EINVAL;\n\t\t\tgoto err_free;\n\t\t}\n\t}\n\tret = 0; \/* cfg looks good *\/\n\nerr_free:\n\tkvfree(insn_state);\n\tkvfree(insn_stack);\n\tenv->cfg.insn_state = env->cfg.insn_stack = NULL;\n\treturn ret;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":276956,"func":"PackedAudioWriter::WriteSample(AP4_Sample&            sample,\n                               AP4_DataBuffer&        sample_data,\n                               AP4_SampleDescription* sample_description,\n                               AP4_ByteStream&        output)\n{\n    AP4_AudioSampleDescription* audio_desc = AP4_DYNAMIC_CAST(AP4_AudioSampleDescription, sample_description);\n    if (audio_desc == NULL) {\n        return AP4_ERROR_INVALID_FORMAT;\n    }\n    if (sample_description->GetFormat() == AP4_SAMPLE_FORMAT_MP4A) {\n        AP4_MpegAudioSampleDescription* mpeg_audio_desc = AP4_DYNAMIC_CAST(AP4_MpegAudioSampleDescription, sample_description);\n\n        if (mpeg_audio_desc == NULL) return AP4_ERROR_NOT_SUPPORTED;\n        if (mpeg_audio_desc->GetMpeg4AudioObjectType() != AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC   &&\n            mpeg_audio_desc->GetMpeg4AudioObjectType() != AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN &&\n            mpeg_audio_desc->GetMpeg4AudioObjectType() != AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR      &&\n            mpeg_audio_desc->GetMpeg4AudioObjectType() != AP4_MPEG4_AUDIO_OBJECT_TYPE_PS) {\n            return AP4_ERROR_NOT_SUPPORTED;\n        }\n\n        unsigned int sample_rate   = mpeg_audio_desc->GetSampleRate();\n        unsigned int channel_count = mpeg_audio_desc->GetChannelCount();\n        const AP4_DataBuffer& dsi  = mpeg_audio_desc->GetDecoderInfo();\n        if (dsi.GetDataSize()) {\n            AP4_Mp4AudioDecoderConfig dec_config;\n            AP4_Result result = dec_config.Parse(dsi.GetData(), dsi.GetDataSize());\n            if (AP4_SUCCEEDED(result)) {\n                sample_rate = dec_config.m_SamplingFrequency;\n                channel_count = dec_config.m_ChannelCount;\n            }\n        }\n        unsigned int sampling_frequency_index = GetSamplingFrequencyIndex(sample_rate);\n        unsigned int channel_configuration    = channel_count;\n\n        WriteAdtsHeader(output, sample.GetSize(), sampling_frequency_index, channel_configuration);\n    } else if (sample_description->GetFormat() == AP4_SAMPLE_FORMAT_AC_4) {\n        WriteAc4Header(output, sample.GetSize());\n    }\n    return output.Write(sample_data.GetData(), sample_data.GetDataSize());\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":195692,"func":"    QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,\r\n                                       const UBaseType_t uxItemSize,\r\n                                       const uint8_t ucQueueType )\r\n    {\r\n        Queue_t * pxNewQueue;\r\n        size_t xQueueSizeInBytes;\r\n        uint8_t * pucQueueStorage;\r\n\r\n        configASSERT( uxQueueLength > ( UBaseType_t ) 0 );\r\n\r\n        \/* Allocate enough space to hold the maximum number of items that\r\n         * can be in the queue at any time.  It is valid for uxItemSize to be\r\n         * zero in the case the queue is used as a semaphore. *\/\r\n        xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); \/*lint !e961 MISRA exception as the casts are only redundant for some ports. *\/\r\n\r\n        \/* Check for multiplication overflow. *\/\r\n        configASSERT( ( uxItemSize == 0 ) || ( uxQueueLength == ( xQueueSizeInBytes \/ uxItemSize ) ) );\r\n\r\n        \/* Allocate the queue and storage area.  Justification for MISRA\r\n         * deviation as follows:  pvPortMalloc() always ensures returned memory\r\n         * blocks are aligned per the requirements of the MCU stack.  In this case\r\n         * pvPortMalloc() must return a pointer that is guaranteed to meet the\r\n         * alignment requirements of the Queue_t structure - which in this case\r\n         * is an int8_t *.  Therefore, whenever the stack alignment requirements\r\n         * are greater than or equal to the pointer to char requirements the cast\r\n         * is safe.  In other cases alignment requirements are not strict (one or\r\n         * two bytes). *\/\r\n        pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); \/*lint !e9087 !e9079 see comment above. *\/\r\n\r\n        if( pxNewQueue != NULL )\r\n        {\r\n            \/* Jump past the queue structure to find the location of the queue\r\n             * storage area. *\/\r\n            pucQueueStorage = ( uint8_t * ) pxNewQueue;\r\n            pucQueueStorage += sizeof( Queue_t ); \/*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. *\/\r\n\r\n            #if ( configSUPPORT_STATIC_ALLOCATION == 1 )\r\n                {\r\n                    \/* Queues can be created either statically or dynamically, so\r\n                     * note this task was created dynamically in case it is later\r\n                     * deleted. *\/\r\n                    pxNewQueue->ucStaticallyAllocated = pdFALSE;\r\n                }\r\n            #endif \/* configSUPPORT_STATIC_ALLOCATION *\/\r\n\r\n            prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue );\r\n        }\r\n        else\r\n        {\r\n            traceQUEUE_CREATE_FAILED( ucQueueType );\r\n            mtCOVERAGE_TEST_MARKER();\r\n        }\r\n\r\n        return pxNewQueue;\r\n    }\r","target":1,"code_token_length":619,"total_token_length":855,"max_tokens_setting":1024}
+{"idx":230299,"func":"njs_array_length_set(njs_vm_t *vm, njs_value_t *value,\n    njs_object_prop_t *prev, njs_value_t *setval)\n{\n    double        num, idx;\n    int64_t       prev_length;\n    uint32_t      i, length;\n    njs_int_t     ret;\n    njs_array_t   *array, *keys;\n\n    array = njs_object_proto_lookup(njs_object(value), NJS_ARRAY, njs_array_t);\n    if (njs_slow_path(array == NULL)) {\n        return NJS_DECLINED;\n    }\n\n    ret = njs_value_to_number(vm, setval, &num);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = (uint32_t) njs_number_to_length(num);\n    if ((double) length != num) {\n        njs_range_error(vm, \"Invalid array length\");\n        return NJS_ERROR;\n    }\n\n    ret = njs_value_to_length(vm, &prev->value, &prev_length);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    keys = NULL;\n\n    if (length < prev_length) {\n        keys = njs_array_indices(vm, value);\n        if (njs_slow_path(keys == NULL)) {\n            return NJS_ERROR;\n        }\n\n        if (keys->length != 0) {\n            i = keys->length - 1;\n\n            do {\n                idx = njs_string_to_index(&keys->start[i]);\n                if (idx >= length) {\n                    ret = njs_value_property_delete(vm, value, &keys->start[i],\n                                                    NULL);\n                    if (njs_slow_path(ret == NJS_ERROR)) {\n                        goto done;\n                    }\n                }\n            } while (i-- != 0);\n        }\n    }\n\n    ret = njs_array_length_redefine(vm, value, length);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = NJS_OK;\n\ndone:\n\n    if (keys != NULL) {\n        njs_array_destroy(vm, keys);\n    }\n\n    return ret;\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":337801,"func":"struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,\n\t\t\t\t       struct sctp_chunk *asconf)\n{\n\tunion sctp_addr_param *addr_param;\n\tstruct sctp_addip_chunk *addip;\n\tstruct sctp_chunk *asconf_ack;\n\tbool all_param_pass = true;\n\tstruct sctp_addiphdr *hdr;\n\tint length = 0, chunk_len;\n\tunion sctp_params param;\n\t__be16 err_code;\n\t__u32 serial;\n\n\taddip = (struct sctp_addip_chunk *)asconf->chunk_hdr;\n\tchunk_len = ntohs(asconf->chunk_hdr->length) -\n\t\t    sizeof(struct sctp_chunkhdr);\n\thdr = (struct sctp_addiphdr *)asconf->skb->data;\n\tserial = ntohl(hdr->serial);\n\n\t\/* Skip the addiphdr and store a pointer to address parameter.  *\/\n\tlength = sizeof(*hdr);\n\taddr_param = (union sctp_addr_param *)(asconf->skb->data + length);\n\tchunk_len -= length;\n\n\t\/* Skip the address parameter and store a pointer to the first\n\t * asconf parameter.\n\t *\/\n\tlength = ntohs(addr_param->p.length);\n\tchunk_len -= length;\n\n\t\/* create an ASCONF_ACK chunk.\n\t * Based on the definitions of parameters, we know that the size of\n\t * ASCONF_ACK parameters are less than or equal to the fourfold of ASCONF\n\t * parameters.\n\t *\/\n\tasconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 4);\n\tif (!asconf_ack)\n\t\tgoto done;\n\n\t\/* Process the TLVs contained within the ASCONF chunk. *\/\n\tsctp_walk_params(param, addip, addip_hdr.params) {\n\t\t\/* Skip preceeding address parameters. *\/\n\t\tif (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||\n\t\t    param.p->type == SCTP_PARAM_IPV6_ADDRESS)\n\t\t\tcontinue;\n\n\t\terr_code = sctp_process_asconf_param(asoc, asconf,\n\t\t\t\t\t\t     param.addip);\n\t\t\/* ADDIP 4.1 A7)\n\t\t * If an error response is received for a TLV parameter,\n\t\t * all TLVs with no response before the failed TLV are\n\t\t * considered successful if not reported.  All TLVs after\n\t\t * the failed response are considered unsuccessful unless\n\t\t * a specific success indication is present for the parameter.\n\t\t *\/\n\t\tif (err_code != SCTP_ERROR_NO_ERROR)\n\t\t\tall_param_pass = false;\n\t\tif (!all_param_pass)\n\t\t\tsctp_add_asconf_response(asconf_ack, param.addip->crr_id,\n\t\t\t\t\t\t err_code, param.addip);\n\n\t\t\/* ADDIP 4.3 D11) When an endpoint receiving an ASCONF to add\n\t\t * an IP address sends an 'Out of Resource' in its response, it\n\t\t * MUST also fail any subsequent add or delete requests bundled\n\t\t * in the ASCONF.\n\t\t *\/\n\t\tif (err_code == SCTP_ERROR_RSRC_LOW)\n\t\t\tgoto done;\n\t}\ndone:\n\tasoc->peer.addip_serial++;\n\n\t\/* If we are sending a new ASCONF_ACK hold a reference to it in assoc\n\t * after freeing the reference to old asconf ack if any.\n\t *\/\n\tif (asconf_ack) {\n\t\tsctp_chunk_hold(asconf_ack);\n\t\tlist_add_tail(&asconf_ack->transmitted_list,\n\t\t\t      &asoc->asconf_ack_list);\n\t}\n\n\treturn asconf_ack;\n}","target":0,"code_token_length":740,"total_token_length":976,"max_tokens_setting":1024}
+{"idx":219920,"func":"const char *gf_isom_get_payt_info(GF_ISOFile *the_file, u32 trackNumber, u32 index, u32 *payID)\n{\n\tu32 i, count;\n\tGF_TrackBox *trak;\n\tGF_UserDataMap *map;\n\tGF_HintInfoBox *hinf;\n\tGF_PAYTBox *payt;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !index) return NULL;\n\n\tif (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return NULL;\n\tmap = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HINF, NULL);\n\tif (!map) return NULL;\n\tif (gf_list_count(map->boxes) != 1) return NULL;\n\n\thinf = (GF_HintInfoBox *)gf_list_get(map->boxes, 0);\n\tcount = 0;\n\ti = 0;\n\twhile ((payt = (GF_PAYTBox*)gf_list_enum(hinf->child_boxes, &i))) {\n\t\tif (payt->type == GF_ISOM_BOX_TYPE_PAYT) {\n\t\t\tcount++;\n\t\t\tif (count == index) {\n\t\t\t\tif (payID) *payID=payt->payloadCode;\n\t\t\t\treturn payt->payloadString;\n\t\t\t}\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":333055,"func":"nfa_get_reganch(nfa_state_T *start, int depth)\n{\n    nfa_state_T *p = start;\n\n    if (depth > 4)\n\treturn 0;\n\n    while (p != NULL)\n    {\n\tswitch (p->c)\n\t{\n\t    case NFA_BOL:\n\t    case NFA_BOF:\n\t\treturn 1; \/\/ yes!\n\n\t    case NFA_ZSTART:\n\t    case NFA_ZEND:\n\t    case NFA_CURSOR:\n\t    case NFA_VISUAL:\n\n\t    case NFA_MOPEN:\n\t    case NFA_MOPEN1:\n\t    case NFA_MOPEN2:\n\t    case NFA_MOPEN3:\n\t    case NFA_MOPEN4:\n\t    case NFA_MOPEN5:\n\t    case NFA_MOPEN6:\n\t    case NFA_MOPEN7:\n\t    case NFA_MOPEN8:\n\t    case NFA_MOPEN9:\n\t    case NFA_NOPEN:\n#ifdef FEAT_SYN_HL\n\t    case NFA_ZOPEN:\n\t    case NFA_ZOPEN1:\n\t    case NFA_ZOPEN2:\n\t    case NFA_ZOPEN3:\n\t    case NFA_ZOPEN4:\n\t    case NFA_ZOPEN5:\n\t    case NFA_ZOPEN6:\n\t    case NFA_ZOPEN7:\n\t    case NFA_ZOPEN8:\n\t    case NFA_ZOPEN9:\n#endif\n\t\tp = p->out;\n\t\tbreak;\n\n\t    case NFA_SPLIT:\n\t\treturn nfa_get_reganch(p->out, depth + 1)\n\t\t\t\t       && nfa_get_reganch(p->out1, depth + 1);\n\n\t    default:\n\t\treturn 0; \/\/ noooo\n\t}\n    }\n    return 0;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":224987,"func":"pqDropConnection(PGconn *conn, bool flushInput)\n{\n\t\/* Drop any SSL state *\/\n\tpqsecure_close(conn);\n\n\t\/* Close the socket itself *\/\n\tif (conn->sock != PGINVALID_SOCKET)\n\t\tclosesocket(conn->sock);\n\tconn->sock = PGINVALID_SOCKET;\n\n\t\/* Optionally discard any unread data *\/\n\tif (flushInput)\n\t\tconn->inStart = conn->inCursor = conn->inEnd = 0;\n\n\t\/* Always discard any unsent data *\/\n\tconn->outCount = 0;\n\n\t\/* Free authentication\/encryption state *\/\n#ifdef ENABLE_GSS\n\t{\n\t\tOM_uint32\tmin_s;\n\n\t\tif (conn->gcred != GSS_C_NO_CREDENTIAL)\n\t\t{\n\t\t\tgss_release_cred(&min_s, &conn->gcred);\n\t\t\tconn->gcred = GSS_C_NO_CREDENTIAL;\n\t\t}\n\t\tif (conn->gctx)\n\t\t\tgss_delete_sec_context(&min_s, &conn->gctx, GSS_C_NO_BUFFER);\n\t\tif (conn->gtarg_nam)\n\t\t\tgss_release_name(&min_s, &conn->gtarg_nam);\n\t\tif (conn->gss_SendBuffer)\n\t\t{\n\t\t\tfree(conn->gss_SendBuffer);\n\t\t\tconn->gss_SendBuffer = NULL;\n\t\t}\n\t\tif (conn->gss_RecvBuffer)\n\t\t{\n\t\t\tfree(conn->gss_RecvBuffer);\n\t\t\tconn->gss_RecvBuffer = NULL;\n\t\t}\n\t\tif (conn->gss_ResultBuffer)\n\t\t{\n\t\t\tfree(conn->gss_ResultBuffer);\n\t\t\tconn->gss_ResultBuffer = NULL;\n\t\t}\n\t\tconn->gssenc = false;\n\t}\n#endif\n#ifdef ENABLE_SSPI\n\tif (conn->sspitarget)\n\t{\n\t\tfree(conn->sspitarget);\n\t\tconn->sspitarget = NULL;\n\t}\n\tif (conn->sspicred)\n\t{\n\t\tFreeCredentialsHandle(conn->sspicred);\n\t\tfree(conn->sspicred);\n\t\tconn->sspicred = NULL;\n\t}\n\tif (conn->sspictx)\n\t{\n\t\tDeleteSecurityContext(conn->sspictx);\n\t\tfree(conn->sspictx);\n\t\tconn->sspictx = NULL;\n\t}\n\tconn->usesspi = 0;\n#endif\n\tif (conn->sasl_state)\n\t{\n\t\tconn->sasl->free(conn->sasl_state);\n\t\tconn->sasl_state = NULL;\n\t}\n}","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":369344,"func":"static int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_async_msghdr iomsg, *kmsg;\n\tstruct io_sr_msg *sr = &req->sr_msg;\n\tstruct socket *sock;\n\tstruct io_buffer *kbuf;\n\tunsigned flags;\n\tint ret, min_ret = 0;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tif (req_has_async_data(req)) {\n\t\tkmsg = req->async_data;\n\t} else {\n\t\tret = io_recvmsg_copy_hdr(req, &iomsg);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tkmsg = &iomsg;\n\t}\n\n\tif (req->flags & REQ_F_BUFFER_SELECT) {\n\t\tkbuf = io_recv_buffer_select(req, issue_flags);\n\t\tif (IS_ERR(kbuf))\n\t\t\treturn PTR_ERR(kbuf);\n\t\tkmsg->fast_iov[0].iov_base = u64_to_user_ptr(kbuf->addr);\n\t\tkmsg->fast_iov[0].iov_len = req->sr_msg.len;\n\t\tiov_iter_init(&kmsg->msg.msg_iter, READ, kmsg->fast_iov,\n\t\t\t\t1, req->sr_msg.len);\n\t}\n\n\tflags = req->sr_msg.msg_flags;\n\tif (force_nonblock)\n\t\tflags |= MSG_DONTWAIT;\n\tif (flags & MSG_WAITALL)\n\t\tmin_ret = iov_iter_count(&kmsg->msg.msg_iter);\n\n\tret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.umsg,\n\t\t\t\t\tkmsg->uaddr, flags);\n\tif (ret < min_ret) {\n\t\tif (ret == -EAGAIN && force_nonblock)\n\t\t\treturn io_setup_async_msg(req, kmsg);\n\t\tif (ret == -ERESTARTSYS)\n\t\t\tret = -EINTR;\n\t\tif (ret > 0 && io_net_retry(sock, flags)) {\n\t\t\tsr->done_io += ret;\n\t\t\treq->flags |= REQ_F_PARTIAL_IO;\n\t\t\treturn io_setup_async_msg(req, kmsg);\n\t\t}\n\t\treq_set_fail(req);\n\t} else if ((flags & MSG_WAITALL) && (kmsg->msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) {\n\t\treq_set_fail(req);\n\t}\n\n\t\/* fast path, check for non-NULL to avoid function call *\/\n\tif (kmsg->free_iov)\n\t\tkfree(kmsg->free_iov);\n\treq->flags &= ~REQ_F_NEED_CLEANUP;\n\tif (ret >= 0)\n\t\tret += sr->done_io;\n\telse if (sr->done_io)\n\t\tret = sr->done_io;\n\t__io_req_complete(req, issue_flags, ret, io_put_kbuf(req, issue_flags));\n\treturn 0;\n}","target":0,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":393510,"func":"static SQInteger thread_wakeup(HSQUIRRELVM v)\n{\n    SQObjectPtr o = stack_get(v,1);\n    if(sq_type(o) == OT_THREAD) {\n        SQVM *thread = _thread(o);\n        SQInteger state = sq_getvmstate(thread);\n        if(state != SQ_VMSTATE_SUSPENDED) {\n            switch(state) {\n                case SQ_VMSTATE_IDLE:\n                    return sq_throwerror(v,_SC(\"cannot wakeup a idle thread\"));\n                break;\n                case SQ_VMSTATE_RUNNING:\n                    return sq_throwerror(v,_SC(\"cannot wakeup a running thread\"));\n                break;\n            }\n        }\n\n        SQInteger wakeupret = sq_gettop(v)>1?SQTrue:SQFalse;\n        if(wakeupret) {\n            sq_move(thread,v,2);\n        }\n        if(SQ_SUCCEEDED(sq_wakeupvm(thread,wakeupret,SQTrue,SQTrue,SQFalse))) {\n            sq_move(v,thread,-1);\n            sq_pop(thread,1); \/\/pop retval\n            if(sq_getvmstate(thread) == SQ_VMSTATE_IDLE) {\n                sq_settop(thread,1); \/\/pop roottable\n            }\n            return 1;\n        }\n        sq_settop(thread,1);\n        v->_lasterror = thread->_lasterror;\n        return SQ_ERROR;\n    }\n    return sq_throwerror(v,_SC(\"wrong parameter\"));\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":238796,"func":"fuzzy_match(\n\tchar_u\t\t*str,\n\tchar_u\t\t*pat_arg,\n\tint\t\tmatchseq,\n\tint\t\t*outScore,\n\tint_u\t\t*matches,\n\tint\t\tmaxMatches)\n{\n    int\t\trecursionCount = 0;\n    int\t\tlen = MB_CHARLEN(str);\n    char_u\t*save_pat;\n    char_u\t*pat;\n    char_u\t*p;\n    int\t\tcomplete = FALSE;\n    int\t\tscore = 0;\n    int\t\tnumMatches = 0;\n    int\t\tmatchCount;\n\n    *outScore = 0;\n\n    save_pat = vim_strsave(pat_arg);\n    if (save_pat == NULL)\n\treturn FALSE;\n    pat = save_pat;\n    p = pat;\n\n    \/\/ Try matching each word in 'pat_arg' in 'str'\n    while (TRUE)\n    {\n\tif (matchseq)\n\t    complete = TRUE;\n\telse\n\t{\n\t    \/\/ Extract one word from the pattern (separated by space)\n\t    p = skipwhite(p);\n\t    if (*p == NUL)\n\t\tbreak;\n\t    pat = p;\n\t    while (*p != NUL && !VIM_ISWHITE(PTR2CHAR(p)))\n\t    {\n\t\tif (has_mbyte)\n\t\t    MB_PTR_ADV(p);\n\t\telse\n\t\t    ++p;\n\t    }\n\t    if (*p == NUL)\t\t\/\/ processed all the words\n\t\tcomplete = TRUE;\n\t    *p = NUL;\n\t}\n\n\tscore = 0;\n\trecursionCount = 0;\n\tmatchCount = fuzzy_match_recursive(pat, str, 0, &score, str, len, NULL,\n\t\t\t\tmatches + numMatches, maxMatches - numMatches,\n\t\t\t\t0, &recursionCount);\n\tif (matchCount == 0)\n\t{\n\t    numMatches = 0;\n\t    break;\n\t}\n\n\t\/\/ Accumulate the match score and the number of matches\n\t*outScore += score;\n\tnumMatches += matchCount;\n\n\tif (complete)\n\t    break;\n\n\t\/\/ try matching the next word\n\t++p;\n    }\n\n    vim_free(save_pat);\n    return numMatches != 0;\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":361307,"func":"stl_add_facet(stl_file *stl, stl_facet *new_facet) {\n  if (stl->error) return;\n\n  stl->stats.facets_added += 1;\n  if(stl->stats.facets_malloced < stl->stats.number_of_facets + 1) {\n    stl->facet_start = (stl_facet*)realloc(stl->facet_start,\n                                           (sizeof(stl_facet) * (stl->stats.facets_malloced + 256)));\n    if(stl->facet_start == NULL) perror(\"stl_add_facet\");\n    stl->neighbors_start = (stl_neighbors*)realloc(stl->neighbors_start,\n                           (sizeof(stl_neighbors) * (stl->stats.facets_malloced + 256)));\n    if(stl->neighbors_start == NULL) perror(\"stl_add_facet\");\n    stl->stats.facets_malloced += 256;\n  }\n  stl->facet_start[stl->stats.number_of_facets] = *new_facet;\n\n  \/* note that the normal vector is not set here, just initialized to 0 *\/\n  stl->facet_start[stl->stats.number_of_facets].normal.x = 0.0;\n  stl->facet_start[stl->stats.number_of_facets].normal.y = 0.0;\n  stl->facet_start[stl->stats.number_of_facets].normal.z = 0.0;\n\n  stl->neighbors_start[stl->stats.number_of_facets].neighbor[0] = -1;\n  stl->neighbors_start[stl->stats.number_of_facets].neighbor[1] = -1;\n  stl->neighbors_start[stl->stats.number_of_facets].neighbor[2] = -1;\n  stl->stats.number_of_facets += 1;\n}","target":0,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":247679,"func":"TEST_P(SslSocketTest, TicketSessionResumptionDifferentMatchSAN) {\n  const std::string server_ctx_yaml1 = R\"EOF(\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      match_subject_alt_names:\n        - exact: \"spiffe:\/\/lyft.com\/test-team\"\n)EOF\";\n\n  const std::string server_ctx_yaml2 = R\"EOF(\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      match_subject_alt_names:\n        - prefix: \"spiffe:\/\/lyft.com\/test-team\"\n\")EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n)EOF\";\n\n  testTicketSessionResumption(server_ctx_yaml1, {}, server_ctx_yaml1, {}, client_ctx_yaml, true,\n                              GetParam());\n  testTicketSessionResumption(server_ctx_yaml1, {}, server_ctx_yaml2, {}, client_ctx_yaml, false,\n                              GetParam());\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":264712,"func":"void AddNodeToConstantGraph(\n    Node* n, std::unordered_map<Node*, std::vector<Node*>>* node_map,\n    Graph* constant_graph) {\n  std::vector<Node*>& added = (*node_map)[n];\n  added.push_back(constant_graph->CopyNode(n));\n  for (const Edge* in_edge : n->in_edges()) {\n    \/\/ Don't copy control edges to the constant graph.\n    if (!in_edge->IsControlEdge()) {\n      Node* in = in_edge->src();\n      auto it = node_map->find(in);\n      CHECK(it != node_map->end())\n          << n->DebugString() << \" <-\" << in->DebugString();\n      if (it->second.size() == 1) {\n        constant_graph->AddEdge(it->second[0], in_edge->src_output(), added[0],\n                                in_edge->dst_input());\n      } else {\n        \/\/ The original source node had multiple outputs and was replaced by a\n        \/\/ vector of constants, so the edge comes from the 0th output of the kth\n        \/\/ added constant, rather than the kth output of the added node as in\n        \/\/ the standard case above.\n        constant_graph->AddEdge(it->second[in_edge->src_output()], 0, added[0],\n                                in_edge->dst_input());\n      }\n    }\n  }\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":247543,"func":"Envoy::Ssl::ClientValidationStatus DefaultCertValidator::verifyCertificate(\n    X509* cert, const std::vector<std::string>& verify_san_list,\n    const std::vector<SanMatcherPtr>& subject_alt_name_matchers) {\n  Envoy::Ssl::ClientValidationStatus validated = Envoy::Ssl::ClientValidationStatus::NotValidated;\n\n  if (!verify_san_list.empty()) {\n    if (!verifySubjectAltName(cert, verify_san_list)) {\n      stats_.fail_verify_san_.inc();\n      return Envoy::Ssl::ClientValidationStatus::Failed;\n    }\n    validated = Envoy::Ssl::ClientValidationStatus::Validated;\n  }\n\n  if (!subject_alt_name_matchers.empty()) {\n    if (!matchSubjectAltName(cert, subject_alt_name_matchers)) {\n      stats_.fail_verify_san_.inc();\n      return Envoy::Ssl::ClientValidationStatus::Failed;\n    }\n    validated = Envoy::Ssl::ClientValidationStatus::Validated;\n  }\n\n  if (!verify_certificate_hash_list_.empty() || !verify_certificate_spki_list_.empty()) {\n    const bool valid_certificate_hash =\n        !verify_certificate_hash_list_.empty() &&\n        verifyCertificateHashList(cert, verify_certificate_hash_list_);\n    const bool valid_certificate_spki =\n        !verify_certificate_spki_list_.empty() &&\n        verifyCertificateSpkiList(cert, verify_certificate_spki_list_);\n\n    if (!valid_certificate_hash && !valid_certificate_spki) {\n      stats_.fail_verify_cert_hash_.inc();\n      return Envoy::Ssl::ClientValidationStatus::Failed;\n    }\n\n    validated = Envoy::Ssl::ClientValidationStatus::Validated;\n  }\n\n  return validated;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":208430,"func":"static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,\n\t\tsize_t count, loff_t *ppos)\n{\n\tstruct hid_debug_list *list = file->private_data;\n\tint ret = 0, len;\n\tDECLARE_WAITQUEUE(wait, current);\n\n\tmutex_lock(&list->read_mutex);\n\twhile (ret == 0) {\n\t\tif (list->head == list->tail) {\n\t\t\tadd_wait_queue(&list->hdev->debug_wait, &wait);\n\t\t\tset_current_state(TASK_INTERRUPTIBLE);\n\n\t\t\twhile (list->head == list->tail) {\n\t\t\t\tif (file->f_flags & O_NONBLOCK) {\n\t\t\t\t\tret = -EAGAIN;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (signal_pending(current)) {\n\t\t\t\t\tret = -ERESTARTSYS;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (!list->hdev || !list->hdev->debug) {\n\t\t\t\t\tret = -EIO;\n\t\t\t\t\tset_current_state(TASK_RUNNING);\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\n\t\t\t\t\/* allow O_NONBLOCK from other threads *\/\n\t\t\t\tmutex_unlock(&list->read_mutex);\n\t\t\t\tschedule();\n\t\t\t\tmutex_lock(&list->read_mutex);\n\t\t\t\tset_current_state(TASK_INTERRUPTIBLE);\n\t\t\t}\n\n\t\t\tset_current_state(TASK_RUNNING);\n\t\t\tremove_wait_queue(&list->hdev->debug_wait, &wait);\n\t\t}\n\n\t\tif (ret)\n\t\t\tgoto out;\n\n\t\t\/* pass the ringbuffer contents to userspace *\/\ncopy_rest:\n\t\tif (list->tail == list->head)\n\t\t\tgoto out;\n\t\tif (list->tail > list->head) {\n\t\t\tlen = list->tail - list->head;\n\n\t\t\tif (copy_to_user(buffer + ret, &list->hid_debug_buf[list->head], len)) {\n\t\t\t\tret = -EFAULT;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tret += len;\n\t\t\tlist->head += len;\n\t\t} else {\n\t\t\tlen = HID_DEBUG_BUFSIZE - list->head;\n\n\t\t\tif (copy_to_user(buffer, &list->hid_debug_buf[list->head], len)) {\n\t\t\t\tret = -EFAULT;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tlist->head = 0;\n\t\t\tret += len;\n\t\t\tgoto copy_rest;\n\t\t}\n\n\t}\nout:\n\tmutex_unlock(&list->read_mutex);\n\treturn ret;\n}","target":1,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":427230,"func":"static void forbody (LexState *ls, int base, int line, int nvars, int isgen) {\n  \/* forbody -> DO block *\/\n  static const OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP};\n  static const OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP};\n  BlockCnt bl;\n  FuncState *fs = ls->fs;\n  int prep, endfor;\n  checknext(ls, TK_DO);\n  prep = luaK_codeABx(fs, forprep[isgen], base, 0);\n  enterblock(fs, &bl, 0);  \/* scope for declared variables *\/\n  adjustlocalvars(ls, nvars);\n  luaK_reserveregs(fs, nvars);\n  block(ls);\n  leaveblock(fs);  \/* end of scope for declared variables *\/\n  fixforjump(fs, prep, luaK_getlabel(fs), 0);\n  if (isgen) {  \/* generic for? *\/\n    luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars);\n    luaK_fixline(fs, line);\n  }\n  endfor = luaK_codeABx(fs, forloop[isgen], base, 0);\n  fixforjump(fs, endfor, prep + 1, 1);\n  luaK_fixline(fs, line);\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":221489,"func":"flatpak_run_setup_usr_links (FlatpakBwrap *bwrap,\n                             GFile        *runtime_files,\n                             const char   *sysroot)\n{\n  int i;\n\n  if (runtime_files == NULL)\n    return;\n\n  for (i = 0; flatpak_abs_usrmerged_dirs[i] != NULL; i++)\n    {\n      const char *subdir = flatpak_abs_usrmerged_dirs[i];\n      g_autoptr(GFile) runtime_subdir = NULL;\n\n      g_assert (subdir[0] == '\/');\n      \/* Skip the '\/' when using as a subdirectory of the runtime *\/\n      runtime_subdir = g_file_get_child (runtime_files, subdir + 1);\n\n      if (g_file_query_exists (runtime_subdir, NULL))\n        {\n          g_autofree char *link = g_strconcat (\"usr\", subdir, NULL);\n          g_autofree char *create = NULL;\n\n          if (sysroot != NULL)\n            create = g_strconcat (sysroot, subdir, NULL);\n          else\n            create = g_strdup (subdir);\n\n          flatpak_bwrap_add_args (bwrap,\n                                  \"--symlink\", link, create,\n                                  NULL);\n        }\n      else\n        {\n          g_debug (\"%s does not exist\",\n                   flatpak_file_get_path_cached (runtime_subdir));\n        }\n    }\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":279948,"func":"ex_copy(linenr_T line1, linenr_T line2, linenr_T n)\n{\n    linenr_T\tcount;\n    char_u\t*p;\n\n    count = line2 - line1 + 1;\n    if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)\n    {\n\tcurbuf->b_op_start.lnum = n + 1;\n\tcurbuf->b_op_end.lnum = n + count;\n\tcurbuf->b_op_start.col = curbuf->b_op_end.col = 0;\n    }\n\n    \/*\n     * there are three situations:\n     * 1. destination is above line1\n     * 2. destination is between line1 and line2\n     * 3. destination is below line2\n     *\n     * n = destination (when starting)\n     * curwin->w_cursor.lnum = destination (while copying)\n     * line1 = start of source (while copying)\n     * line2 = end of source (while copying)\n     *\/\n    if (u_save(n, n + 1) == FAIL)\n\treturn;\n\n    curwin->w_cursor.lnum = n;\n    while (line1 <= line2)\n    {\n\t\/\/ need to use vim_strsave() because the line will be unlocked within\n\t\/\/ ml_append()\n\tp = vim_strsave(ml_get(line1));\n\tif (p != NULL)\n\t{\n\t    ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE);\n\t    vim_free(p);\n\t}\n\t\/\/ situation 2: skip already copied lines\n\tif (line1 == n)\n\t    line1 = curwin->w_cursor.lnum;\n\t++line1;\n\tif (curwin->w_cursor.lnum < line1)\n\t    ++line1;\n\tif (curwin->w_cursor.lnum < line2)\n\t    ++line2;\n\t++curwin->w_cursor.lnum;\n    }\n\n    appended_lines_mark(n, count);\n    if (VIsual_active)\n\tcheck_pos(curbuf, &VIsual);\n\n    msgmore((long)count);\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":252410,"func":"int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName,\n                              const char *pComment, mz_uint flags) {\n  mz_uint file_index;\n  size_t name_len, comment_len;\n  if ((!pZip) || (!pZip->m_pState) || (!pName) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return -1;\n  if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) &&\n      (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size))\n    return mz_zip_reader_locate_file_binary_search(pZip, pName);\n  name_len = strlen(pName);\n  if (name_len > 0xFFFF) return -1;\n  comment_len = pComment ? strlen(pComment) : 0;\n  if (comment_len > 0xFFFF) return -1;\n  for (file_index = 0; file_index < pZip->m_total_files; file_index++) {\n    const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(\n        &pZip->m_pState->m_central_dir, mz_uint8,\n        MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32,\n                             file_index));\n    mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n    const char *pFilename =\n        (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;\n    if (filename_len < name_len) continue;\n    if (comment_len) {\n      mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS),\n              file_comment_len =\n                  MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);\n      const char *pFile_comment = pFilename + filename_len + file_extra_len;\n      if ((file_comment_len != comment_len) ||\n          (!mz_zip_reader_string_equal(pComment, pFile_comment,\n                                       file_comment_len, flags)))\n        continue;\n    }\n    if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) {\n      int ofs = filename_len - 1;\n      do {\n        if ((pFilename[ofs] == '\/') || (pFilename[ofs] == '\\\\') ||\n            (pFilename[ofs] == ':'))\n          break;\n      } while (--ofs >= 0);\n      ofs++;\n      pFilename += ofs;\n      filename_len -= ofs;\n    }\n    if ((filename_len == name_len) &&\n        (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags)))\n      return file_index;\n  }\n  return -1;\n}","target":0,"code_token_length":608,"total_token_length":844,"max_tokens_setting":1024}
+{"idx":349249,"func":"static int read_fragment_table(long long *table_start)\n{\n\t\/*\n\t * Note on overflow limits:\n\t * Size of SBlk.s.fragments is 2^32 (unsigned int)\n\t * Max size of bytes is 2^32*16 or 2^36\n\t * Max indexes is (2^32*16)\/8K or 2^23\n\t * Max length is ((2^32*16)\/8K)*8 or 2^26 or 64M\n\t *\/\n\tint res, i;\n\tlong long bytes = SQUASHFS_FRAGMENT_BYTES_3((long long) sBlk.s.fragments);\n\tint indexes = SQUASHFS_FRAGMENT_INDEXES_3((long long) sBlk.s.fragments);\n\tint length = SQUASHFS_FRAGMENT_INDEX_BYTES_3((long long) sBlk.s.fragments);\n\tlong long *fragment_table_index;\n\n\t\/*\n\t * The size of the index table (length bytes) should match the\n\t * table start and end points\n\t *\/\n\tif(length != (*table_start - sBlk.s.fragment_table_start)) {\n\t\tERROR(\"read_fragment_table: Bad fragment count in super block\\n\");\n\t\treturn FALSE;\n\t}\n\n\tTRACE(\"read_fragment_table: %d fragments, reading %d fragment indexes \"\n\t\t\"from 0x%llx\\n\", sBlk.s.fragments, indexes,\n\t\tsBlk.s.fragment_table_start);\n\n\tfragment_table_index = alloc_index_table(indexes);\n\tfragment_table = malloc(bytes);\n\tif(fragment_table == NULL)\n\t\tEXIT_UNSQUASH(\"read_fragment_table: failed to allocate \"\n\t\t\t\"fragment table\\n\");\n\n\tif(swap) {\n\t\tlong long *sfragment_table_index = salloc_index_table(indexes);\n\n\t\tres = read_fs_bytes(fd, sBlk.s.fragment_table_start,\n\t\t\tlength, sfragment_table_index);\n\t\tif(res == FALSE) {\n\t\t\tERROR(\"read_fragment_table: failed to read fragment \"\n\t\t\t\t\"table index\\n\");       \n\t\t\treturn FALSE;\n\t\t}\n\t\tSQUASHFS_SWAP_FRAGMENT_INDEXES_3(fragment_table_index,\n\t\t\tsfragment_table_index, indexes);\n\t} else {\n\t\tres = read_fs_bytes(fd, sBlk.s.fragment_table_start,\n\t\t\tlength, fragment_table_index);\n\t\tif(res == FALSE) {\n\t\t\tERROR(\"read_fragment_table: failed to read fragment \"\n\t\t\t\t\"table index\\n\");       \n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\tfor(i = 0; i < indexes; i++) {\n\t\tint expected = (i + 1) != indexes ? SQUASHFS_METADATA_SIZE :\n\t\t\t\t\tbytes & (SQUASHFS_METADATA_SIZE - 1);\n\t\tint length = read_block(fd, fragment_table_index[i], NULL,\n\t\t\texpected, ((char *) fragment_table) + ((long long) i *\n\t\t\tSQUASHFS_METADATA_SIZE));\n\t\tTRACE(\"Read fragment table block %d, from 0x%llx, length %d\\n\",\n\t\t\ti, fragment_table_index[i], length);\n\t\tif(length == FALSE) {\n\t\t\tERROR(\"read_fragment_table: failed to read fragment \"\n\t\t\t\t\"table block\\n\");       \n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\tif(swap) {\n\t\tsquashfs_fragment_entry_3 sfragment;\n\t\tfor(i = 0; i < sBlk.s.fragments; i++) {\n\t\t\tSQUASHFS_SWAP_FRAGMENT_ENTRY_3((&sfragment),\n\t\t\t\t(&fragment_table[i]));\n\t\t\tmemcpy((char *) &fragment_table[i], (char *) &sfragment,\n\t\t\t\tsizeof(squashfs_fragment_entry_3));\n\t\t}\n\t}\n\n\t*table_start = fragment_table_index[0];\n\treturn TRUE;\n}","target":0,"code_token_length":773,"total_token_length":1009,"max_tokens_setting":1024}
+{"idx":446091,"func":"static int hulusb_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel)\n{\n\tint rc;\n\tint rssi_base_val;\n\n\tstruct atusb *lp = hw->priv;\n\n\tif (channel == 0)\n\t\trc = atusb_write_subreg(lp, SR_SUB_MODE, 0);\n\telse\n\t\trc = atusb_write_subreg(lp, SR_SUB_MODE, 1);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tif (page == 0) {\n\t\trc = atusb_write_subreg(lp, SR_BPSK_QPSK, 0);\n\t\trssi_base_val = -100;\n\t} else {\n\t\trc = atusb_write_subreg(lp, SR_BPSK_QPSK, 1);\n\t\trssi_base_val = -98;\n\t}\n\tif (rc < 0)\n\t\treturn rc;\n\n\trc = hulusb_set_cca_ed_level(lp, rssi_base_val);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t\/* This sets the symbol_duration according frequency on the 212.\n\t * TODO move this handling while set channel and page in cfg802154.\n\t * We can do that, this timings are according 802.15.4 standard.\n\t * If we do that in cfg802154, this is a more generic calculation.\n\t *\n\t * This should also protected from ifs_timer. Means cancel timer and\n\t * init with a new value. For now, this is okay.\n\t *\/\n\tif (channel == 0) {\n\t\tif (page == 0) {\n\t\t\t\/* SUB:0 and BPSK:0 -> BPSK-20 *\/\n\t\t\tlp->hw->phy->symbol_duration = 50;\n\t\t} else {\n\t\t\t\/* SUB:1 and BPSK:0 -> BPSK-40 *\/\n\t\t\tlp->hw->phy->symbol_duration = 25;\n\t\t}\n\t} else {\n\t\tif (page == 0)\n\t\t\t\/* SUB:0 and BPSK:1 -> OQPSK-100\/200\/400 *\/\n\t\t\tlp->hw->phy->symbol_duration = 40;\n\t\telse\n\t\t\t\/* SUB:1 and BPSK:1 -> OQPSK-250\/500\/1000 *\/\n\t\t\tlp->hw->phy->symbol_duration = 16;\n\t}\n\n\tlp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *\n\t\t\t\t   lp->hw->phy->symbol_duration;\n\tlp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *\n\t\t\t\t   lp->hw->phy->symbol_duration;\n\n\treturn atusb_write_subreg(lp, SR_CHANNEL, channel);\n}","target":0,"code_token_length":606,"total_token_length":842,"max_tokens_setting":1024}
+{"idx":279902,"func":"ex_oldfiles(exarg_T *eap UNUSED)\n{\n    list_T\t*l = get_vim_var_list(VV_OLDFILES);\n    listitem_T\t*li;\n    int\t\tnr = 0;\n    char_u\t*fname;\n\n    if (l == NULL)\n\tmsg(_(\"No old files\"));\n    else\n    {\n\tmsg_start();\n\tmsg_scroll = TRUE;\n\tfor (li = l->lv_first; li != NULL && !got_int; li = li->li_next)\n\t{\n\t    ++nr;\n\t    fname = tv_get_string(&li->li_tv);\n\t    if (!message_filtered(fname))\n\t    {\n\t\tmsg_outnum((long)nr);\n\t\tmsg_puts(\": \");\n\t\tmsg_outtrans(fname);\n\t\tmsg_clr_eos();\n\t\tmsg_putchar('\\n');\n\t\tout_flush();\t    \/\/ output one line at a time\n\t\tui_breakcheck();\n\t    }\n\t}\n\n\t\/\/ Assume \"got_int\" was set to truncate the listing.\n\tgot_int = FALSE;\n\n# ifdef FEAT_BROWSE_CMD\n\tif (cmdmod.cmod_flags & CMOD_BROWSE)\n\t{\n\t    quit_more = FALSE;\n\t    nr = prompt_for_number(FALSE);\n\t    msg_starthere();\n\t    if (nr > 0)\n\t    {\n\t\tchar_u *p = list_find_str(get_vim_var_list(VV_OLDFILES),\n\t\t\t\t\t\t\t\t    (long)nr);\n\n\t\tif (p != NULL)\n\t\t{\n\t\t    p = expand_env_save(p);\n\t\t    eap->arg = p;\n\t\t    eap->cmdidx = CMD_edit;\n\t\t    cmdmod.cmod_flags &= ~CMOD_BROWSE;\n\t\t    do_exedit(eap, NULL);\n\t\t    vim_free(p);\n\t\t}\n\t    }\n\t}\n# endif\n    }\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":242965,"func":"int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl )\n{\n    size_t transform_expansion = 0;\n    const mbedtls_ssl_transform *transform = ssl->transform_out;\n    unsigned block_size;\n\n    size_t out_hdr_len = mbedtls_ssl_out_hdr_len( ssl );\n\n    if( transform == NULL )\n        return( (int) out_hdr_len );\n\n#if defined(MBEDTLS_ZLIB_SUPPORT)\n    if( ssl->session_out->compression != MBEDTLS_SSL_COMPRESS_NULL )\n        return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );\n#endif\n\n    switch( mbedtls_cipher_get_cipher_mode( &transform->cipher_ctx_enc ) )\n    {\n        case MBEDTLS_MODE_GCM:\n        case MBEDTLS_MODE_CCM:\n        case MBEDTLS_MODE_CHACHAPOLY:\n        case MBEDTLS_MODE_STREAM:\n            transform_expansion = transform->minlen;\n            break;\n\n        case MBEDTLS_MODE_CBC:\n\n            block_size = mbedtls_cipher_get_block_size(\n                &transform->cipher_ctx_enc );\n\n            \/* Expansion due to the addition of the MAC. *\/\n            transform_expansion += transform->maclen;\n\n            \/* Expansion due to the addition of CBC padding;\n             * Theoretically up to 256 bytes, but we never use\n             * more than the block size of the underlying cipher. *\/\n            transform_expansion += block_size;\n\n            \/* For TLS 1.1 or higher, an explicit IV is added\n             * after the record header. *\/\n#if defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2)\n            if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 )\n                transform_expansion += block_size;\n#endif \/* MBEDTLS_SSL_PROTO_TLS1_1 || MBEDTLS_SSL_PROTO_TLS1_2 *\/\n\n            break;\n\n        default:\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"should never happen\" ) );\n            return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n    }\n\n#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)\n    if( transform->out_cid_len != 0 )\n        transform_expansion += MBEDTLS_SSL_MAX_CID_EXPANSION;\n#endif \/* MBEDTLS_SSL_DTLS_CONNECTION_ID *\/\n\n    return( (int)( out_hdr_len + transform_expansion ) );\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":437384,"func":"recursive_call_check(Node* node)\n{\n  int r;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n  case NODE_ALT:\n    r = 0;\n    do {\n      r |= recursive_call_check(NODE_CAR(node));\n    } while (IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_ANCHOR:\n    if (! ANCHOR_HAS_BODY(ANCHOR_(node))) {\n      r = 0;\n      break;\n    }\n    \/* fall *\/\n  case NODE_QUANT:\n    r = recursive_call_check(NODE_BODY(node));\n    break;\n\n  case NODE_CALL:\n    r = recursive_call_check(NODE_BODY(node));\n    if (r != 0) {\n      if (NODE_IS_MARK1(NODE_BODY(node)))\n        NODE_STATUS_ADD(node, RECURSION);\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      if (en->type == ENCLOSURE_MEMORY) {\n        if (NODE_IS_MARK2(node))\n          return 0;\n        else if (NODE_IS_MARK1(node))\n          return 1; \/* recursion *\/\n        else {\n          NODE_STATUS_ADD(node, MARK2);\n          r = recursive_call_check(NODE_BODY(node));\n          NODE_STATUS_REMOVE(node, MARK2);\n        }\n      }\n      else if (en->type == ENCLOSURE_IF_ELSE) {\n        r = 0;\n        if (IS_NOT_NULL(en->te.Then)) {\n          r |= recursive_call_check(en->te.Then);\n        }\n        if (IS_NOT_NULL(en->te.Else)) {\n          r |= recursive_call_check(en->te.Else);\n        }\n        r |= recursive_call_check(NODE_BODY(node));\n      }\n      else {\n        r = recursive_call_check(NODE_BODY(node));\n      }\n    }\n    break;\n\n  default:\n    r = 0;\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":198239,"func":"static int check_passwd(unsigned char *passwd, size_t length)\n{\n\tstruct digest *d = NULL;\n\tunsigned char *passwd1_sum;\n\tunsigned char *passwd2_sum;\n\tint ret = 0;\n\tint hash_len;\n\n\tif (IS_ENABLED(CONFIG_PASSWD_CRYPTO_PBKDF2)) {\n\t\thash_len = PBKDF2_LENGTH;\n\t} else {\n\t\td = digest_alloc(PASSWD_SUM);\n\t\tif (!d) {\n\t\t\tpr_err(\"No such digest: %s\\n\",\n\t\t\t       PASSWD_SUM ? PASSWD_SUM : \"NULL\");\n\t\t\treturn -ENOENT;\n\t\t}\n\n\t\thash_len = digest_length(d);\n\t}\n\n\tpasswd1_sum = calloc(hash_len * 2, sizeof(unsigned char));\n\tif (!passwd1_sum)\n\t\treturn -ENOMEM;\n\n\tpasswd2_sum = passwd1_sum + hash_len;\n\n\tif (is_passwd_env_enable())\n\t\tret = read_env_passwd(passwd2_sum, hash_len);\n\telse if (is_passwd_default_enable())\n\t\tret = read_default_passwd(passwd2_sum, hash_len);\n\telse\n\t\tret = -EINVAL;\n\n\tif (ret < 0)\n\t\tgoto err;\n\n\tif (IS_ENABLED(CONFIG_PASSWD_CRYPTO_PBKDF2)) {\n\t\tchar *key = passwd2_sum + PBKDF2_SALT_LEN;\n\t\tchar *salt = passwd2_sum;\n\t\tint keylen = PBKDF2_LENGTH - PBKDF2_SALT_LEN;\n\n\t\tret = pkcs5_pbkdf2_hmac_sha1(passwd, length, salt,\n\t\t\tPBKDF2_SALT_LEN, PBKDF2_COUNT, keylen, passwd1_sum);\n\t\tif (ret)\n\t\t\tgoto err;\n\n\t\tif (strncmp(passwd1_sum, key, keylen) == 0)\n\t\t\tret = 1;\n\t} else {\n\t\tret = digest_digest(d, passwd, length, passwd1_sum);\n\n\t\tif (ret)\n\t\t\tgoto err;\n\n\t\tif (strncmp(passwd1_sum, passwd2_sum, hash_len) == 0)\n\t\t\tret = 1;\n\t}\n\nerr:\n\tfree(passwd1_sum);\n\tdigest_free(d);\n\n\treturn ret;\n}","target":1,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":353209,"func":"T3FontCache::T3FontCache(const Ref *fontIDA, double m11A, double m12A,\n\t\t\t double m21A, double m22A,\n\t\t\t int glyphXA, int glyphYA, int glyphWA, int glyphHA,\n\t\t\t bool validBBoxA, bool aa) {\n\n  fontID = *fontIDA;\n  m11 = m11A;\n  m12 = m12A;\n  m21 = m21A;\n  m22 = m22A;\n  glyphX = glyphXA;\n  glyphY = glyphYA;\n  glyphW = glyphWA;\n  glyphH = glyphHA;\n  validBBox = validBBoxA;\n  \/\/ sanity check for excessively large glyphs (which most likely\n  \/\/ indicate an incorrect BBox)\n  if (glyphW > INT_MAX \/ glyphH || glyphW <= 0 || glyphH <= 0 || glyphW * glyphH > 100000) {\n    glyphW = glyphH = 100;\n    validBBox = false;\n  }\n  if (aa) {\n    glyphSize = glyphW * glyphH;\n  } else {\n    glyphSize = ((glyphW + 7) >> 3) * glyphH;\n  }\n  cacheAssoc = type3FontCacheAssoc;\n  for (cacheSets = type3FontCacheMaxSets;\n       cacheSets > 1 &&\n\t cacheSets * cacheAssoc * glyphSize > type3FontCacheSize;\n       cacheSets >>= 1) ;\n  if (glyphSize < 10485760 \/ cacheAssoc \/ cacheSets) {\n    cacheData = (unsigned char *)gmallocn_checkoverflow(cacheSets * cacheAssoc, glyphSize);\n  } else {\n    error(errSyntaxWarning, -1, \"Not creating cacheData for T3FontCache, it asked for too much memory.\\n\"\n              \"       This could teoretically result in wrong rendering,\\n\"\n              \"       but most probably the document is bogus.\\n\"\n              \"       Please report a bug if you think the rendering may be wrong because of this.\");\n    cacheData = nullptr;\n  }\n  if (cacheData != nullptr)\n  {\n    cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc,\n\t\t\t\t\t sizeof(T3FontCacheTag));\n    for (int i = 0; i < cacheSets * cacheAssoc; ++i) {\n      cacheTags[i].mru = i & (cacheAssoc - 1);\n    }\n  }\n  else\n  {\n    cacheTags = nullptr;\n  }\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":256416,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_nack(\n\t\t\t\t\tpjmedia_rtcp_session *session,\n\t\t\t\t\tvoid *buf,\n\t\t\t\t\tpj_size_t *length,\n\t\t\t\t\tunsigned nack_cnt,\n\t\t\t\t\tconst pjmedia_rtcp_fb_nack nack[])\n{\n    pjmedia_rtcp_fb_common *hdr;\n    pj_uint8_t *p;\n    unsigned len, i;\n\n    PJ_ASSERT_RETURN(session && buf && length && nack_cnt && nack, PJ_EINVAL);\n\n    len = (3 + nack_cnt) * 4;\n    if (len > *length)\n\treturn PJ_ETOOSMALL;\n\n    \/* Build RTCP-FB NACK header *\/\n    hdr = (pjmedia_rtcp_fb_common*)buf;\n    pj_memcpy(hdr, &session->rtcp_fb_com, sizeof(*hdr));\n    hdr->rtcp_common.pt = RTCP_RTPFB;\n    hdr->rtcp_common.count = 1; \/* FMT = 1 *\/\n    hdr->rtcp_common.length = pj_htons((pj_uint16_t)(len\/4 - 1));\n\n    \/* Build RTCP-FB NACK FCI *\/\n    p = (pj_uint8_t*)hdr + sizeof(*hdr);\n    for (i = 0; i < nack_cnt; ++i) {\n\tpj_uint16_t val;\n\tval = pj_htons((pj_uint16_t)nack[i].pid);\n\tpj_memcpy(p, &val, 2);\n\tval = pj_htons(nack[i].blp);\n\tpj_memcpy(p+2, &val, 2);\n\tp += 4;\n    }\n\n    \/* Finally *\/\n    *length = len;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":405350,"func":"static struct xfrm_dst *xfrm_bundle_lookup(struct net *net,\n\t\t\t\t\t   const struct flowi *fl,\n\t\t\t\t\t   u16 family, u8 dir,\n\t\t\t\t\t   struct xfrm_flo *xflo, u32 if_id)\n{\n\tstruct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];\n\tint num_pols = 0, num_xfrms = 0, err;\n\tstruct xfrm_dst *xdst;\n\n\t\/* Resolve policies to use if we couldn't get them from\n\t * previous cache entry *\/\n\tnum_pols = 1;\n\tpols[0] = xfrm_policy_lookup(net, fl, family, dir, if_id);\n\terr = xfrm_expand_policies(fl, family, pols,\n\t\t\t\t\t   &num_pols, &num_xfrms);\n\tif (err < 0)\n\t\tgoto inc_error;\n\tif (num_pols == 0)\n\t\treturn NULL;\n\tif (num_xfrms <= 0)\n\t\tgoto make_dummy_bundle;\n\n\txdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,\n\t\t\t\t\t      xflo->dst_orig);\n\tif (IS_ERR(xdst)) {\n\t\terr = PTR_ERR(xdst);\n\t\tif (err == -EREMOTE) {\n\t\t\txfrm_pols_put(pols, num_pols);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (err != -EAGAIN)\n\t\t\tgoto error;\n\t\tgoto make_dummy_bundle;\n\t} else if (xdst == NULL) {\n\t\tnum_xfrms = 0;\n\t\tgoto make_dummy_bundle;\n\t}\n\n\treturn xdst;\n\nmake_dummy_bundle:\n\t\/* We found policies, but there's no bundles to instantiate:\n\t * either because the policy blocks, has no transformations or\n\t * we could not build template (no xfrm_states).*\/\n\txdst = xfrm_create_dummy_bundle(net, xflo, fl, num_xfrms, family);\n\tif (IS_ERR(xdst)) {\n\t\txfrm_pols_put(pols, num_pols);\n\t\treturn ERR_CAST(xdst);\n\t}\n\txdst->num_pols = num_pols;\n\txdst->num_xfrms = num_xfrms;\n\tmemcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols);\n\n\treturn xdst;\n\ninc_error:\n\tXFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);\nerror:\n\txfrm_pols_put(pols, num_pols);\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":507764,"func":"ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group,\n                                            ECPKPARAMETERS *params)\n{\n    int ok = 1, tmp;\n    ECPKPARAMETERS *ret = params;\n\n    if (ret == NULL) {\n        if ((ret = ECPKPARAMETERS_new()) == NULL) {\n            ECerr(EC_F_EC_GROUP_GET_ECPKPARAMETERS, ERR_R_MALLOC_FAILURE);\n            return NULL;\n        }\n    } else {\n        if (ret->type == ECPKPARAMETERS_TYPE_NAMED)\n            ASN1_OBJECT_free(ret->value.named_curve);\n        else if (ret->type == ECPKPARAMETERS_TYPE_EXPLICIT\n                 && ret->value.parameters != NULL)\n            ECPARAMETERS_free(ret->value.parameters);\n    }\n\n    if (EC_GROUP_get_asn1_flag(group)) {\n        \/*\n         * use the asn1 OID to describe the elliptic curve parameters\n         *\/\n        tmp = EC_GROUP_get_curve_name(group);\n        if (tmp) {\n            ASN1_OBJECT *asn1obj = OBJ_nid2obj(tmp);\n\n            if (asn1obj == NULL || OBJ_length(asn1obj) == 0) {\n                ASN1_OBJECT_free(asn1obj);\n                ECerr(EC_F_EC_GROUP_GET_ECPKPARAMETERS, EC_R_MISSING_OID);\n                ok = 0;\n            } else {\n                ret->type = ECPKPARAMETERS_TYPE_NAMED;\n                ret->value.named_curve = asn1obj;\n            }\n        } else\n            \/* we don't know the nid => ERROR *\/\n            ok = 0;\n    } else {\n        \/* use the ECPARAMETERS structure *\/\n        ret->type = ECPKPARAMETERS_TYPE_EXPLICIT;\n        if ((ret->value.parameters =\n             EC_GROUP_get_ecparameters(group, NULL)) == NULL)\n            ok = 0;\n    }\n\n    if (!ok) {\n        ECPKPARAMETERS_free(ret);\n        return NULL;\n    }\n    return ret;\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":310267,"func":"generate_runningrouters(void)\n{\n  char *s=NULL;\n  char digest[DIGEST_LEN];\n  char published[ISO_TIME_LEN+1];\n  size_t len;\n  crypto_pk_env_t *private_key = get_server_identity_key();\n  char *identity_pkey; \/* Identity key, DER64-encoded. *\/\n  size_t identity_pkey_len;\n\n  if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,\n                                           &identity_pkey_len)<0) {\n    log_warn(LD_BUG,\"write identity_pkey to string failed!\");\n    goto err;\n  }\n  format_iso_time(published, time(NULL));\n\n  len = 2048;\n  s = tor_malloc_zero(len);\n  tor_snprintf(s, len,\n               \"network-status\\n\"\n               \"published %s\\n\"\n               \"router-status %s\\n\"\n               \"dir-signing-key\\n%s\"\n               \"directory-signature %s\\n\",\n               published, \"\", identity_pkey,\n               get_options()->Nickname);\n  tor_free(identity_pkey);\n  if (router_get_runningrouters_hash(s,digest)) {\n    log_warn(LD_BUG,\"couldn't compute digest\");\n    goto err;\n  }\n  note_crypto_pk_op(SIGN_DIR);\n  if (router_append_dirobj_signature(s, len, digest, DIGEST_LEN,\n                                     private_key)<0)\n    goto err;\n\n  set_cached_dir(&the_runningrouters, s, time(NULL));\n  runningrouters_is_dirty = 0;\n\n  return &the_runningrouters;\n err:\n  tor_free(s);\n  return NULL;\n}","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":383307,"func":"gdImageCreateTrueColor (int sx, int sy)\n{\n  int i;\n  gdImagePtr im;\n  im = (gdImage *) gdMalloc (sizeof (gdImage));\n  memset (im, 0, sizeof (gdImage));\n  im->tpixels = (int **) gdMalloc (sizeof (int *) * sy);\n  im->polyInts = 0;\n  im->polyAllocated = 0;\n  im->brush = 0;\n  im->tile = 0;\n  im->style = 0;\n  for (i = 0; (i < sy); i++)\n    {\n      im->tpixels[i] = (int *) gdCalloc (\n\t\t\t\t\t  sx, sizeof (int));\n    }\n  im->sx = sx;\n  im->sy = sy;\n  im->transparent = (-1);\n  im->interlace = 0;\n  im->trueColor = 1;\n  \/* 2.0.2: alpha blending is now on by default, and saving of alpha is\n    off by default. This allows font antialiasing to work as expected\n    on the first try in JPEGs -- quite important -- and also allows\n    for smaller PNGs when saving of alpha channel is not really\n    desired, which it usually isn't! *\/\n  im->saveAlphaFlag = 0;\n  im->alphaBlendingFlag = 1;\n  im->thick = 1;\n  return im;\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":326600,"func":"cleanup_pathname_win(char *path)\n{\n\twchar_t wc;\n\tchar *p;\n\tsize_t alen, l;\n\tint mb, complete, utf8;\n\n\talen = 0;\n\tmb = 0;\n\tcomplete = 1;\n\tutf8 = (strcmp(nl_langinfo(CODESET), \"UTF-8\") == 0)? 1: 0;\n\tfor (p = path; *p != '\\0'; p++) {\n\t\t++alen;\n\t\tif (*p == '\\\\') {\n\t\t\t\/* If previous byte is smaller than 128,\n\t\t\t * this is not second byte of multibyte characters,\n\t\t\t * so we can replace '\\' with '\/'. *\/\n\t\t\tif (utf8 || !mb)\n\t\t\t\t*p = '\/';\n\t\t\telse\n\t\t\t\tcomplete = 0;\/* uncompleted. *\/\n\t\t} else if (*(unsigned char *)p > 127)\n\t\t\tmb = 1;\n\t\telse\n\t\t\tmb = 0;\n\t\t\/* Rewrite the path name if its next character is unusable. *\/\n\t\tif (*p == ':' || *p == '*' || *p == '?' || *p == '\"' ||\n\t\t    *p == '<' || *p == '>' || *p == '|')\n\t\t\t*p = '_';\n\t}\n\tif (complete)\n\t\treturn;\n\n\t\/*\n\t * Convert path separator in wide-character.\n\t *\/\n\tp = path;\n\twhile (*p != '\\0' && alen) {\n\t\tl = mbtowc(&wc, p, alen);\n\t\tif (l == (size_t)-1) {\n\t\t\twhile (*p != '\\0') {\n\t\t\t\tif (*p == '\\\\')\n\t\t\t\t\t*p = '\/';\n\t\t\t\t++p;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (l == 1 && wc == L'\\\\')\n\t\t\t*p = '\/';\n\t\tp += l;\n\t\talen -= l;\n\t}\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":336137,"func":"static int ip6gre_newlink(struct net *src_net, struct net_device *dev,\n\tstruct nlattr *tb[], struct nlattr *data[])\n{\n\tstruct ip6_tnl *nt;\n\tstruct net *net = dev_net(dev);\n\tstruct ip6gre_net *ign = net_generic(net, ip6gre_net_id);\n\tstruct ip_tunnel_encap ipencap;\n\tint err;\n\n\tnt = netdev_priv(dev);\n\n\tif (ip6gre_netlink_encap_parms(data, &ipencap)) {\n\t\tint err = ip6_tnl_encap_setup(nt, &ipencap);\n\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\tip6gre_netlink_parms(data, &nt->parms);\n\n\tif (ip6gre_tunnel_find(net, &nt->parms, dev->type))\n\t\treturn -EEXIST;\n\n\tif (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])\n\t\teth_hw_addr_random(dev);\n\n\tnt->dev = dev;\n\tnt->net = dev_net(dev);\n\tip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);\n\n\tdev->features\t\t|= GRE6_FEATURES;\n\tdev->hw_features\t|= GRE6_FEATURES;\n\n\tif (!(nt->parms.o_flags & TUNNEL_SEQ)) {\n\t\t\/* TCP offload with GRE SEQ is not supported, nor\n\t\t * can we support 2 levels of outer headers requiring\n\t\t * an update.\n\t\t *\/\n\t\tif (!(nt->parms.o_flags & TUNNEL_CSUM) ||\n\t\t    (nt->encap.type == TUNNEL_ENCAP_NONE)) {\n\t\t\tdev->features    |= NETIF_F_GSO_SOFTWARE;\n\t\t\tdev->hw_features |= NETIF_F_GSO_SOFTWARE;\n\t\t}\n\n\t\t\/* Can use a lockless transmit, unless we generate\n\t\t * output sequences\n\t\t *\/\n\t\tdev->features |= NETIF_F_LLTX;\n\t}\n\n\terr = register_netdevice(dev);\n\tif (err)\n\t\tgoto out;\n\n\tdev_hold(dev);\n\tip6gre_tunnel_link(ign, nt);\n\nout:\n\treturn err;\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":216701,"func":"static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit(\n    TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize,\n    void** value, uint64 maxcount)\n{\n\tint typesize;\n\tuint32 datasize;\n\tvoid* data;\n        uint64 target_count64;\n\ttypesize=TIFFDataWidth(direntry->tdir_type);\n\n        target_count64 = (direntry->tdir_count > maxcount) ?\n                maxcount : direntry->tdir_count;\n\n\tif ((target_count64==0)||(typesize==0))\n\t{\n\t\t*value=0;\n\t\treturn(TIFFReadDirEntryErrOk);\n\t}\n        (void) desttypesize;\n\n        \/* \n         * As a sanity check, make sure we have no more than a 2GB tag array \n         * in either the current data type or the dest data type.  This also\n         * avoids problems with overflow of tmsize_t on 32bit systems.\n         *\/\n\tif ((uint64)(2147483647\/typesize)<target_count64)\n\t\treturn(TIFFReadDirEntryErrSizesan);\n\tif ((uint64)(2147483647\/desttypesize)<target_count64)\n\t\treturn(TIFFReadDirEntryErrSizesan);\n\n\t*count=(uint32)target_count64;\n\tdatasize=(*count)*typesize;\n\tassert((tmsize_t)datasize>0);\n\tdata=_TIFFCheckMalloc(tif, *count, typesize, \"ReadDirEntryArray\");\n\tif (data==0)\n\t\treturn(TIFFReadDirEntryErrAlloc);\n\tif (!(tif->tif_flags&TIFF_BIGTIFF))\n\t{\n\t\tif (datasize<=4)\n\t\t\t_TIFFmemcpy(data,&direntry->tdir_offset,datasize);\n\t\telse\n\t\t{\n\t\t\tenum TIFFReadDirEntryErr err;\n\t\t\tuint32 offset = direntry->tdir_offset.toff_long;\n\t\t\tif (tif->tif_flags&TIFF_SWAB)\n\t\t\t\tTIFFSwabLong(&offset);\n\t\t\terr=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);\n\t\t\tif (err!=TIFFReadDirEntryErrOk)\n\t\t\t{\n\t\t\t\t_TIFFfree(data);\n\t\t\t\treturn(err);\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (datasize<=8)\n\t\t\t_TIFFmemcpy(data,&direntry->tdir_offset,datasize);\n\t\telse\n\t\t{\n\t\t\tenum TIFFReadDirEntryErr err;\n\t\t\tuint64 offset = direntry->tdir_offset.toff_long8;\n\t\t\tif (tif->tif_flags&TIFF_SWAB)\n\t\t\t\tTIFFSwabLong8(&offset);\n\t\t\terr=TIFFReadDirEntryData(tif,offset,(tmsize_t)datasize,data);\n\t\t\tif (err!=TIFFReadDirEntryErrOk)\n\t\t\t{\n\t\t\t\t_TIFFfree(data);\n\t\t\t\treturn(err);\n\t\t\t}\n\t\t}\n\t}\n\t*value=data;\n\treturn(TIFFReadDirEntryErrOk);\n}","target":1,"code_token_length":688,"total_token_length":924,"max_tokens_setting":1024}
+{"idx":477295,"func":"static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)\n{\n\tstruct tipc_ehdr *ehdr = (struct tipc_ehdr *)skb_network_header(skb);\n\tstruct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx;\n\tstruct tipc_msg *hdr = buf_msg(skb);\n\tu32 self = tipc_own_addr(rx->net);\n\tu8 cur, new;\n\tunsigned long delay;\n\n\t\/* Update RX 'key_master' flag according to peer, also mark \"legacy\" if\n\t * a peer has no master key.\n\t *\/\n\trx->key_master = ehdr->master_key;\n\tif (!rx->key_master)\n\t\ttx->legacy_user = 1;\n\n\t\/* For later cases, apply only if message is destined to this node *\/\n\tif (!ehdr->destined || msg_short(hdr) || msg_destnode(hdr) != self)\n\t\treturn;\n\n\t\/* Case 1: Peer has no keys, let's make master key take over *\/\n\tif (ehdr->rx_nokey) {\n\t\t\/* Set or extend grace period *\/\n\t\ttx->timer2 = jiffies;\n\t\t\/* Schedule key distributing for the peer if not yet *\/\n\t\tif (tx->key.keys &&\n\t\t    !atomic_cmpxchg(&rx->key_distr, 0, KEY_DISTR_SCHED)) {\n\t\t\tget_random_bytes(&delay, 2);\n\t\t\tdelay %= 5;\n\t\t\tdelay = msecs_to_jiffies(500 * ++delay);\n\t\t\tif (queue_delayed_work(tx->wq, &rx->work, delay))\n\t\t\t\ttipc_node_get(rx->node);\n\t\t}\n\t} else {\n\t\t\/* Cancel a pending key distributing if any *\/\n\t\tatomic_xchg(&rx->key_distr, 0);\n\t}\n\n\t\/* Case 2: Peer RX active key has changed, let's update own TX users *\/\n\tcur = atomic_read(&rx->peer_rx_active);\n\tnew = ehdr->rx_key_active;\n\tif (tx->key.keys &&\n\t    cur != new &&\n\t    atomic_cmpxchg(&rx->peer_rx_active, cur, new) == cur) {\n\t\tif (new)\n\t\t\ttipc_aead_users_inc(tx->aead[new], INT_MAX);\n\t\tif (cur)\n\t\t\ttipc_aead_users_dec(tx->aead[cur], 0);\n\n\t\tatomic64_set(&rx->sndnxt, 0);\n\t\t\/* Mark the point TX key users changed *\/\n\t\ttx->timer1 = jiffies;\n\n\t\tpr_debug(\"%s: key users changed %d-- %d++, peer %s\\n\",\n\t\t\t tx->name, cur, new, rx->name);\n\t}\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":415186,"func":"cmd_readkey (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  unsigned char *cert = NULL;\n  size_t ncert, n;\n  ksba_cert_t kc = NULL;\n  ksba_sexp_t p;\n  unsigned char *pk;\n  size_t pklen;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  line = xstrdup (line); \/* Need a copy of the line. *\/\n  \/* If the application supports the READKEY function we use that.\n     Otherwise we use the old way by extracting it from the\n     certificate.  *\/\n  rc = app_readkey (ctrl->app_ctx, line, &pk, &pklen);\n  if (!rc)\n    { \/* Yeah, got that key - send it back.  *\/\n      rc = assuan_send_data (ctx, pk, pklen);\n      xfree (pk);\n      xfree (line);\n      line = NULL;\n      goto leave;\n    }\n\n  if (gpg_err_code (rc) != GPG_ERR_UNSUPPORTED_OPERATION)\n    log_error (\"app_readkey failed: %s\\n\", gpg_strerror (rc));\n  else\n    {\n      rc = app_readcert (ctrl->app_ctx, line, &cert, &ncert);\n      if (rc)\n        log_error (\"app_readcert failed: %s\\n\", gpg_strerror (rc));\n    }\n  xfree (line);\n  line = NULL;\n  if (rc)\n    goto leave;\n\n  rc = ksba_cert_new (&kc);\n  if (rc)\n    goto leave;\n\n  rc = ksba_cert_init_from_mem (kc, cert, ncert);\n  if (rc)\n    {\n      log_error (\"failed to parse the certificate: %s\\n\", gpg_strerror (rc));\n      goto leave;\n    }\n\n  p = ksba_cert_get_public_key (kc);\n  if (!p)\n    {\n      rc = gpg_error (GPG_ERR_NO_PUBKEY);\n      goto leave;\n    }\n\n  n = gcry_sexp_canon_len (p, 0, NULL, NULL);\n  rc = assuan_send_data (ctx, p, n);\n  xfree (p);\n\n\n leave:\n  ksba_cert_release (kc);\n  xfree (cert);\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":390586,"func":"SetKeyBehaviors(\tXkbSrvInfoPtr\t xkbi,\n    \t\t\txkbSetMapReq\t*req,\n    \t\t\txkbBehaviorWireDesc\t*wire,\n    \t\t\tXkbChangesPtr\t changes)\n{\nregister unsigned i;\nint maxRG = -1;\nXkbDescPtr       xkb = xkbi->desc;\nXkbServerMapPtr\t server = xkb->server;\nunsigned\t first,last;\n\n    first= req->firstKeyBehavior;\n    last= req->firstKeyBehavior+req->nKeyBehaviors-1;\n    bzero(&server->behaviors[first],req->nKeyBehaviors*sizeof(XkbBehavior));\n    for (i=0;i<req->totalKeyBehaviors;i++) {\n\tif ((server->behaviors[wire->key].type&XkbKB_Permanent)==0) {\n\t    server->behaviors[wire->key].type= wire->type;\n\t    server->behaviors[wire->key].data= wire->data;\n\t    if ((wire->type==XkbKB_RadioGroup)&&(((int)wire->data)>maxRG))\n\t\tmaxRG= wire->data + 1;\n\t}\n\twire++;\n    }\n\n    if (maxRG>(int)xkbi->nRadioGroups) {\n        int sz = maxRG*sizeof(XkbRadioGroupRec);\n        if (xkbi->radioGroups)\n             xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz);\n        else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz);\n        if (xkbi->radioGroups) {\n             if (xkbi->nRadioGroups)\n                bzero(&xkbi->radioGroups[xkbi->nRadioGroups],\n                        (maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec));\n             xkbi->nRadioGroups= maxRG;\n        }\n        else xkbi->nRadioGroups= 0;\n        \/* should compute members here *\/\n    }\n    if (changes->map.changed&XkbKeyBehaviorsMask) {\n\tunsigned oldLast;\n\toldLast= changes->map.first_key_behavior+\n\t\t\t\t\tchanges->map.num_key_behaviors-1;\n        if (changes->map.first_key_behavior<req->firstKeyBehavior)\n             first= changes->map.first_key_behavior;\n        if (oldLast>last)\n            last= oldLast;\n    }\n    changes->map.changed|= XkbKeyBehaviorsMask;\n    changes->map.first_key_behavior = first;\n    changes->map.num_key_behaviors = (last-first+1);\n    return (char *)wire;\n}","target":0,"code_token_length":566,"total_token_length":802,"max_tokens_setting":1024}
+{"idx":238535,"func":"static void adjust_insn_aux_data(struct bpf_verifier_env *env,\n\t\t\t\t struct bpf_insn_aux_data *new_data,\n\t\t\t\t struct bpf_prog *new_prog, u32 off, u32 cnt)\n{\n\tstruct bpf_insn_aux_data *old_data = env->insn_aux_data;\n\tstruct bpf_insn *insn = new_prog->insnsi;\n\tu32 old_seen = old_data[off].seen;\n\tu32 prog_len;\n\tint i;\n\n\t\/* aux info at OFF always needs adjustment, no matter fast path\n\t * (cnt == 1) is taken or not. There is no guarantee INSN at OFF is the\n\t * original insn at old prog.\n\t *\/\n\told_data[off].zext_dst = insn_has_def32(env, insn + off + cnt - 1);\n\n\tif (cnt == 1)\n\t\treturn;\n\tprog_len = new_prog->len;\n\n\tmemcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off);\n\tmemcpy(new_data + off + cnt - 1, old_data + off,\n\t       sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));\n\tfor (i = off; i < off + cnt - 1; i++) {\n\t\t\/* Expand insni[off]'s seen count to the patched range. *\/\n\t\tnew_data[i].seen = old_seen;\n\t\tnew_data[i].zext_dst = insn_has_def32(env, insn + i);\n\t}\n\tenv->insn_aux_data = new_data;\n\tvfree(old_data);\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":412147,"func":"respip_set_apply_cfg(struct respip_set* set, char* const* tagname, int num_tags,\n\tstruct config_strbytelist* respip_tags,\n\tstruct config_str2list* respip_actions,\n\tstruct config_str2list* respip_data)\n{\n\tstruct config_strbytelist* p;\n\tstruct config_str2list* pa;\n\tstruct config_str2list* pd;\n\n\tset->tagname = tagname;\n\tset->num_tags = num_tags;\n\n\tp = respip_tags;\n\twhile(p) {\n\t\tstruct config_strbytelist* np = p->next;\n\n\t\tlog_assert(p->str && p->str2);\n\t\tif(!respip_tag_cfg(set, p->str, p->str2, p->str2len)) {\n\t\t\tconfig_del_strbytelist(p);\n\t\t\treturn 0;\n\t\t}\n\t\tfree(p->str);\n\t\tfree(p->str2);\n\t\tfree(p);\n\t\tp = np;\n\t}\n\n\tpa = respip_actions;\n\twhile(pa) {\n\t\tstruct config_str2list* np = pa->next;\n\t\tlog_assert(pa->str && pa->str2);\n\t\tif(!respip_action_cfg(set, pa->str, pa->str2)) {\n\t\t\tconfig_deldblstrlist(pa);\n\t\t\treturn 0;\n\t\t}\n\t\tfree(pa->str);\n\t\tfree(pa->str2);\n\t\tfree(pa);\n\t\tpa = np;\n\t}\n\n\tpd = respip_data;\n\twhile(pd) {\n\t\tstruct config_str2list* np = pd->next;\n\t\tlog_assert(pd->str && pd->str2);\n\t\tif(!respip_data_cfg(set, pd->str, pd->str2)) {\n\t\t\tconfig_deldblstrlist(pd);\n\t\t\treturn 0;\n\t\t}\n\t\tfree(pd->str);\n\t\tfree(pd->str2);\n\t\tfree(pd);\n\t\tpd = np;\n\t}\n\taddr_tree_init_parents(&set->ip_tree);\n\n\treturn 1;\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":245723,"func":"static void relay_connection (struct conn_s *connptr)\n{\n        int ret;\n        ssize_t bytes_received;\n\n        for (;;) {\n                pollfd_struct fds[2] = {0};\n                fds[0].fd = connptr->client_fd;\n                fds[1].fd = connptr->server_fd;\n\n                if (buffer_size (connptr->sbuffer) > 0)\n                        fds[0].events |= MYPOLL_WRITE;\n                if (buffer_size (connptr->cbuffer) > 0)\n                        fds[1].events |= MYPOLL_WRITE;\n                if (buffer_size (connptr->sbuffer) < MAXBUFFSIZE)\n                        fds[1].events |= MYPOLL_READ;\n                if (buffer_size (connptr->cbuffer) < MAXBUFFSIZE)\n                        fds[0].events |= MYPOLL_READ;\n\n                ret = mypoll(fds, 2, config->idletimeout);\n\n                if (ret == 0) {\n                        log_message (LOG_INFO,\n                                     \"Idle Timeout (after \" SELECT_OR_POLL \")\");\n                                return;\n                } else if (ret < 0) {\n                        log_message (LOG_ERR,\n                                     \"relay_connection: \" SELECT_OR_POLL \"() error \\\"%s\\\". \"\n                                     \"Closing connection (client_fd:%d, server_fd:%d)\",\n                                     strerror (errno), connptr->client_fd,\n                                     connptr->server_fd);\n                        return;\n                }\n\n                if (fds[1].revents & MYPOLL_READ) {\n                        bytes_received =\n                            read_buffer (connptr->server_fd, connptr->sbuffer);\n                        if (bytes_received < 0)\n                                break;\n\n                        connptr->content_length.server -= bytes_received;\n                        if (connptr->content_length.server == 0)\n                                break;\n                }\n                if ((fds[0].revents & MYPOLL_READ)\n                    && read_buffer (connptr->client_fd, connptr->cbuffer) < 0) {\n                        break;\n                }\n                if ((fds[1].revents & MYPOLL_WRITE)\n                    && write_buffer (connptr->server_fd, connptr->cbuffer) < 0) {\n                        break;\n                }\n                if ((fds[0].revents & MYPOLL_WRITE)\n                    && write_buffer (connptr->client_fd, connptr->sbuffer) < 0) {\n                        break;\n                }\n        }\n\n        while (buffer_size (connptr->sbuffer) > 0) {\n                if (write_buffer (connptr->client_fd, connptr->sbuffer) < 0)\n                        break;\n        }\n        shutdown (connptr->client_fd, SHUT_WR);\n\n        \/*\n         * Try to send any remaining data to the server if we can.\n         *\/\n        ret = socket_blocking (connptr->server_fd);\n        if (ret != 0) {\n                log_message(LOG_ERR,\n                            \"Failed to set server socket to blocking: %s\",\n                            strerror(errno));\n                return;\n        }\n\n        while (buffer_size (connptr->cbuffer) > 0) {\n                if (write_buffer (connptr->server_fd, connptr->cbuffer) < 0)\n                        break;\n        }\n\n        return;\n}","target":0,"code_token_length":677,"total_token_length":913,"max_tokens_setting":1024}
+{"idx":359352,"func":"DEFUN (bgp_redistribute_ipv4_rmap_metric,\n       bgp_redistribute_ipv4_rmap_metric_cmd,\n       \"redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>\",\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPF)\\n\"\n       \"Routing Information Protocol (RIP)\\n\"\n       \"Static routes\\n\"\n       \"Route map reference\\n\"\n       \"Pointer to route-map entries\\n\"\n       \"Metric for redistributed routes\\n\"\n       \"Default metric\\n\")\n{\n  int type;\n  u_int32_t metric;\n\n  type = bgp_str2route_type (AFI_IP, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n  VTY_GET_INTEGER (\"metric\", metric, argv[2]);\n\n  bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);\n  bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);\n  return bgp_redistribute_set (vty->index, AFI_IP, type);\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":242984,"func":"static int ssl_buffer_make_space( mbedtls_ssl_context *ssl,\n                                  size_t desired )\n{\n    int offset;\n    mbedtls_ssl_handshake_params * const hs = ssl->handshake;\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Attempt to free buffered messages to have %u bytes available\",\n                                (unsigned) desired ) );\n\n    \/* Get rid of future records epoch first, if such exist. *\/\n    ssl_free_buffered_record( ssl );\n\n    \/* Check if we have enough space available now. *\/\n    if( desired <= ( MBEDTLS_SSL_DTLS_MAX_BUFFERING -\n                     hs->buffering.total_bytes_buffered ) )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Enough space available after freeing future epoch record\" ) );\n        return( 0 );\n    }\n\n    \/* We don't have enough space to buffer the next expected handshake\n     * message. Remove buffers used for future messages to gain space,\n     * starting with the most distant one. *\/\n    for( offset = MBEDTLS_SSL_MAX_BUFFERED_HS - 1;\n         offset >= 0; offset-- )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Free buffering slot %d to make space for reassembly of next handshake message\",\n                                    offset ) );\n\n        ssl_buffering_free_slot( ssl, (uint8_t) offset );\n\n        \/* Check if we have enough space available now. *\/\n        if( desired <= ( MBEDTLS_SSL_DTLS_MAX_BUFFERING -\n                         hs->buffering.total_bytes_buffered ) )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 2, ( \"Enough space available after freeing buffered HS messages\" ) );\n            return( 0 );\n        }\n    }\n\n    return( -1 );\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":513269,"func":"bool JOIN::rollup_init()\n{\n  uint i,j;\n  Item **ref_array;\n\n  tmp_table_param.quick_group= 0;\t\/\/ Can't create groups in tmp table\n  rollup.state= ROLLUP::STATE_INITED;\n\n  \/*\n    Create pointers to the different sum function groups\n    These are updated by rollup_make_fields()\n  *\/\n  tmp_table_param.group_parts= send_group_parts;\n\n  Item_null_result **null_items=\n    static_cast<Item_null_result**>(thd->alloc(sizeof(Item*)*send_group_parts));\n\n  rollup.null_items= Item_null_array(null_items, send_group_parts);\n  rollup.ref_pointer_arrays=\n    static_cast<Ref_ptr_array*>\n    (thd->alloc((sizeof(Ref_ptr_array) +\n                 all_fields.elements * sizeof(Item*)) * send_group_parts));\n  rollup.fields=\n    static_cast<List<Item>*>(thd->alloc(sizeof(List<Item>) * send_group_parts));\n\n  if (!null_items || !rollup.ref_pointer_arrays || !rollup.fields)\n    return true;\n\n  ref_array= (Item**) (rollup.ref_pointer_arrays+send_group_parts);\n\n\n  \/*\n    Prepare space for field list for the different levels\n    These will be filled up in rollup_make_fields()\n  *\/\n  for (i= 0 ; i < send_group_parts ; i++)\n  {\n    rollup.null_items[i]= new (thd->mem_root) Item_null_result(thd);\n    List<Item> *rollup_fields= &rollup.fields[i];\n    rollup_fields->empty();\n    rollup.ref_pointer_arrays[i]= Ref_ptr_array(ref_array, all_fields.elements);\n    ref_array+= all_fields.elements;\n  }\n  for (i= 0 ; i < send_group_parts; i++)\n  {\n    for (j=0 ; j < fields_list.elements ; j++)\n      rollup.fields[i].push_back(rollup.null_items[i], thd->mem_root);\n  }\n  List_iterator<Item> it(all_fields);\n  Item *item;\n  while ((item= it++))\n  {\n    ORDER *group_tmp;\n    bool found_in_group= 0;\n\n    for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next)\n    {\n      if (*group_tmp->item == item)\n      {\n        item->maybe_null= 1;\n        item->in_rollup= 1;\n        found_in_group= 1;\n        break;\n      }\n    }\n    if (item->type() == Item::FUNC_ITEM && !found_in_group)\n    {\n      bool changed= FALSE;\n      if (change_group_ref(thd, (Item_func *) item, group_list, &changed))\n        return 1;\n      \/*\n        We have to prevent creation of a field in a temporary table for\n        an expression that contains GROUP BY attributes.\n        Marking the expression item as 'with_sum_func' will ensure this.\n      *\/ \n      if (changed)\n        item->with_sum_func= 1;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":640,"total_token_length":876,"max_tokens_setting":1024}
+{"idx":369100,"func":"\nstatic int io_poll_update_prep(struct io_kiocb *req,\n\t\t\t       const struct io_uring_sqe *sqe)\n{\n\tstruct io_poll_update *upd = &req->poll_update;\n\tu32 flags;\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->buf_index || sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\tflags = READ_ONCE(sqe->len);\n\tif (flags & ~(IORING_POLL_UPDATE_EVENTS | IORING_POLL_UPDATE_USER_DATA |\n\t\t      IORING_POLL_ADD_MULTI))\n\t\treturn -EINVAL;\n\t\/* meaningless without update *\/\n\tif (flags == IORING_POLL_ADD_MULTI)\n\t\treturn -EINVAL;\n\n\tupd->old_user_data = READ_ONCE(sqe->addr);\n\tupd->update_events = flags & IORING_POLL_UPDATE_EVENTS;\n\tupd->update_user_data = flags & IORING_POLL_UPDATE_USER_DATA;\n\n\tupd->new_user_data = READ_ONCE(sqe->off);\n\tif (!upd->update_user_data && upd->new_user_data)\n\t\treturn -EINVAL;\n\tif (upd->update_events)\n\t\tupd->events = io_poll_parse_events(sqe, flags);\n\telse if (sqe->poll32_events)\n\t\treturn -EINVAL;\n\n\treturn 0;","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":387818,"func":"void InstanceKlass::adjust_default_methods(InstanceKlass* holder, bool* trace_name_printed) {\n  \/\/ search the default_methods for uses of either obsolete or EMCP methods\n  if (default_methods() != NULL) {\n    for (int index = 0; index < default_methods()->length(); index ++) {\n      Method* old_method = default_methods()->at(index);\n      if (old_method == NULL || old_method->method_holder() != holder || !old_method->is_old()) {\n        continue; \/\/ skip uninteresting entries\n      }\n      assert(!old_method->is_deleted(), \"default methods may not be deleted\");\n\n      Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());\n\n      assert(new_method != NULL, \"method_with_idnum() should not be NULL\");\n      assert(old_method != new_method, \"sanity check\");\n\n      default_methods()->at_put(index, new_method);\n      if (log_is_enabled(Info, redefine, class, update)) {\n        ResourceMark rm;\n        if (!(*trace_name_printed)) {\n          log_info(redefine, class, update)\n            (\"adjust: klassname=%s default methods from name=%s\",\n             external_name(), old_method->method_holder()->external_name());\n          *trace_name_printed = true;\n        }\n        log_debug(redefine, class, update, vtables)\n          (\"default method update: %s(%s) \",\n           new_method->name()->as_C_string(), new_method->signature()->as_C_string());\n      }\n    }\n  }\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":437316,"func":"set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)\n{\n  int r;\n  NodeOpt opt;\n  OptEnv env;\n\n  env.enc            = reg->enc;\n  env.options        = reg->options;\n  env.case_fold_flag = reg->case_fold_flag;\n  env.scan_env       = scan_env;\n  clear_mml(&env.mmd);\n\n  r = optimize_nodes(node, &opt, &env);\n  if (r != 0) return r;\n\n  reg->anchor = opt.anc.left & (ANCHOR_BEGIN_BUF |\n        ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_INF | ANCHOR_ANYCHAR_INF_ML |\n        ANCHOR_LOOK_BEHIND);\n\n  if ((opt.anc.left & (ANCHOR_LOOK_BEHIND | ANCHOR_PREC_READ_NOT)) != 0)\n    reg->anchor &= ~ANCHOR_ANYCHAR_INF_ML;\n\n  reg->anchor |= opt.anc.right & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF |\n       ANCHOR_PREC_READ_NOT);\n\n  if (reg->anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)) {\n    reg->anchor_dmin = opt.len.min;\n    reg->anchor_dmax = opt.len.max;\n  }\n\n  if (opt.exb.len > 0 || opt.exm.len > 0) {\n    select_opt_exact(reg->enc, &opt.exb, &opt.exm);\n    if (opt.map.value > 0 && comp_opt_exact_or_map(&opt.exb, &opt.map) > 0) {\n      goto set_map;\n    }\n    else {\n      r = set_optimize_exact(reg, &opt.exb);\n      set_sub_anchor(reg, &opt.exb.anc);\n    }\n  }\n  else if (opt.map.value > 0) {\n  set_map:\n    set_optimize_map(reg, &opt.map);\n    set_sub_anchor(reg, &opt.map.anc);\n  }\n  else {\n    reg->sub_anchor |= opt.anc.left & ANCHOR_BEGIN_LINE;\n    if (opt.len.max == 0)\n      reg->sub_anchor |= opt.anc.right & ANCHOR_END_LINE;\n  }\n\n#if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH)\n  print_optimize_info(stderr, reg);\n#endif\n  return r;\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":242927,"func":"  void Compute(OpKernelContext *ctx) override {\n    const Tensor *a_indices_t, *a_values_t, *a_shape_t, *b;\n    OP_REQUIRES_OK(ctx, ctx->input(\"a_indices\", &a_indices_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"a_values\", &a_values_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"a_shape\", &a_shape_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"b\", &b));\n    OP_REQUIRES_OK(\n        ctx, ValidateInputs<Index>(a_indices_t, a_values_t, a_shape_t, b));\n\n    Tensor *out_t;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(0, b->shape(), &out_t));\n\n    const int ndims = static_cast<int>(a_indices_t->dim_size(1));\n    const auto a_indices_mat = a_indices_t->flat_inner_dims<Index>();\n    const auto a_values_flat = a_values_t->flat<T>();\n\n    switch (ndims) {\n#define NDIMS_CASE(N)                                                     \\\n  case N: {                                                               \\\n    auto out_tensor = out_t->tensor<T, N>();                              \\\n    out_tensor.device(ctx->eigen_device<Device>()) = b->tensor<T, N>();   \\\n    const Index result =                                                  \\\n        functor::ScatterNdFunctor<Device, T, Index, N,                    \\\n                                  scatter_op::UpdateOp::ADD>()(           \\\n            ctx->eigen_device<Device>(), a_indices_mat, a_values_flat,    \\\n            out_tensor);                                                  \\\n    OP_REQUIRES(                                                          \\\n        ctx, result == -1,                                                \\\n        errors::InvalidArgument(                                          \\\n            \"Sparse tensor has some invalid index on dimension \", result, \\\n            \"; dense tensor shape: \", b->shape().DebugString()));         \\\n  } break;\n\n      NDIMS_CASE(1);\n      NDIMS_CASE(2);\n      NDIMS_CASE(3);\n      NDIMS_CASE(4);\n      NDIMS_CASE(5);\n      default:\n        OP_REQUIRES(\n            ctx, false,\n            errors::InvalidArgument(\"Only tensors with ranks between 1 and 5 \"\n                                    \"are currently supported.  Tensor rank: \",\n                                    ndims));\n#undef NDIMS_CASE\n    }\n  }","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":245148,"func":"Status Examples::SampleAdaptiveProbabilities(\n    const int num_loss_partitions, const Regularizations& regularization,\n    const ModelWeights& model_weights,\n    const TTypes<float>::Matrix example_state_data,\n    const std::unique_ptr<DualLossUpdater>& loss_updater,\n    const int num_weight_vectors) {\n  if (num_weight_vectors != 1) {\n    return errors::InvalidArgument(\n        \"Adaptive SDCA only works with binary SDCA, \"\n        \"where num_weight_vectors should be 1.\");\n  }\n  \/\/ Compute the probabilities\n  for (int example_id = 0; example_id < num_examples(); ++example_id) {\n    const Example& example = examples_[example_id];\n    const double example_weight = example.example_weight();\n    float label = example.example_label();\n    const Status conversion_status = loss_updater->ConvertLabel(&label);\n    const ExampleStatistics example_statistics =\n        example.ComputeWxAndWeightedExampleNorm(num_loss_partitions,\n                                                model_weights, regularization,\n                                                num_weight_vectors);\n    const double kappa = example_state_data(example_id, 0) +\n                         loss_updater->PrimalLossDerivative(\n                             example_statistics.wx[0], label, 1.0);\n    probabilities_[example_id] = example_weight *\n                                 sqrt(examples_[example_id].squared_norm_ +\n                                      regularization.symmetric_l2() *\n                                          loss_updater->SmoothnessConstant()) *\n                                 std::abs(kappa);\n  }\n\n  \/\/ Sample the index\n  random::DistributionSampler sampler(probabilities_);\n  GuardedPhiloxRandom generator;\n  generator.Init(0, 0);\n  auto local_gen = generator.ReserveSamples32(num_examples());\n  random::SimplePhilox random(&local_gen);\n  std::random_device rd;\n  std::mt19937 gen(rd());\n  std::uniform_real_distribution<> dis(0, 1);\n\n  \/\/ We use a decay of 10: the probability of an example is divided by 10\n  \/\/ once that example is picked. A good approximation of that is to only\n  \/\/ keep a picked example with probability (1 \/ 10) ^ k where k is the\n  \/\/ number of times we already picked that example. We add a num_retries\n  \/\/ to avoid taking too long to sample. We then fill the sampled_index with\n  \/\/ unseen examples sorted by probabilities.\n  int id = 0;\n  int num_retries = 0;\n  while (id < num_examples() && num_retries < num_examples()) {\n    int picked_id = sampler.Sample(&random);\n    if (dis(gen) > MathUtil::IPow(0.1, sampled_count_[picked_id])) {\n      num_retries++;\n      continue;\n    }\n    sampled_count_[picked_id]++;\n    sampled_index_[id++] = picked_id;\n  }\n\n  std::vector<std::pair<int, float>> examples_not_seen;\n  examples_not_seen.reserve(num_examples());\n  for (int i = 0; i < num_examples(); ++i) {\n    if (sampled_count_[i] == 0)\n      examples_not_seen.emplace_back(sampled_index_[i], probabilities_[i]);\n  }\n  std::sort(\n      examples_not_seen.begin(), examples_not_seen.end(),\n      [](const std::pair<int, float>& lhs, const std::pair<int, float>& rhs) {\n        return lhs.second > rhs.second;\n      });\n  for (int i = id; i < num_examples(); ++i) {\n    sampled_count_[i] = examples_not_seen[i - id].first;\n  }\n  return Status::OK();\n}","target":0,"code_token_length":756,"total_token_length":992,"max_tokens_setting":1024}
+{"idx":344264,"func":"int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {\n  const TValue *tm;\n  if (ttypetag(t1) != ttypetag(t2)) {  \/* not the same variant? *\/\n    if (ttype(t1) != ttype(t2) || ttype(t1) != LUA_TNUMBER)\n      return 0;  \/* only numbers can be equal with different variants *\/\n    else {  \/* two numbers with different variants *\/\n      \/* One of them is an integer. If the other does not have an\n         integer value, they cannot be equal; otherwise, compare their\n         integer values. *\/\n      lua_Integer i1, i2;\n      return (luaV_tointegerns(t1, &i1, F2Ieq) &&\n              luaV_tointegerns(t2, &i2, F2Ieq) &&\n              i1 == i2);\n    }\n  }\n  \/* values have same type and same variant *\/\n  switch (ttypetag(t1)) {\n    case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE: return 1;\n    case LUA_VNUMINT: return (ivalue(t1) == ivalue(t2));\n    case LUA_VNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2));\n    case LUA_VLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);\n    case LUA_VLCF: return fvalue(t1) == fvalue(t2);\n    case LUA_VSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2));\n    case LUA_VLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2));\n    case LUA_VUSERDATA: {\n      if (uvalue(t1) == uvalue(t2)) return 1;\n      else if (L == NULL) return 0;\n      tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);\n      if (tm == NULL)\n        tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);\n      break;  \/* will try TM *\/\n    }\n    case LUA_VTABLE: {\n      if (hvalue(t1) == hvalue(t2)) return 1;\n      else if (L == NULL) return 0;\n      tm = fasttm(L, hvalue(t1)->metatable, TM_EQ);\n      if (tm == NULL)\n        tm = fasttm(L, hvalue(t2)->metatable, TM_EQ);\n      break;  \/* will try TM *\/\n    }\n    default:\n      return gcvalue(t1) == gcvalue(t2);\n  }\n  if (tm == NULL)  \/* no TM? *\/\n    return 0;  \/* objects are different *\/\n  else {\n    luaT_callTMres(L, tm, t1, t2, L->top);  \/* call TM *\/\n    return !l_isfalse(s2v(L->top));\n  }\n}","target":0,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":282879,"func":"static int rsi_send_common_dev_params(struct rsi_common *common)\n{\n\tstruct sk_buff *skb;\n\tu16 frame_len;\n\tstruct rsi_config_vals *dev_cfgs;\n\n\tframe_len = sizeof(struct rsi_config_vals);\n\n\trsi_dbg(MGMT_TX_ZONE, \"Sending common device config params\\n\");\n\tskb = dev_alloc_skb(frame_len);\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Unable to allocate skb\\n\", __func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, frame_len);\n\n\tdev_cfgs = (struct rsi_config_vals *)skb->data;\n\tmemset(dev_cfgs, 0, (sizeof(struct rsi_config_vals)));\n\n\trsi_set_len_qno(&dev_cfgs->len_qno, (frame_len - FRAME_DESC_SZ),\n\t\t\tRSI_COEX_Q);\n\tdev_cfgs->pkt_type = COMMON_DEV_CONFIG;\n\n\tdev_cfgs->lp_ps_handshake = common->lp_ps_handshake_mode;\n\tdev_cfgs->ulp_ps_handshake = common->ulp_ps_handshake_mode;\n\n\tdev_cfgs->unused_ulp_gpio = RSI_UNUSED_ULP_GPIO_BITMAP;\n\tdev_cfgs->unused_soc_gpio_bitmap =\n\t\t\t\tcpu_to_le32(RSI_UNUSED_SOC_GPIO_BITMAP);\n\n\tdev_cfgs->opermode = common->oper_mode;\n\tdev_cfgs->wlan_rf_pwr_mode = common->wlan_rf_power_mode;\n\tdev_cfgs->driver_mode = common->driver_mode;\n\tdev_cfgs->region_code = NL80211_DFS_FCC;\n\tdev_cfgs->antenna_sel_val = common->obm_ant_sel_val;\n\n\tskb_put(skb, frame_len);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":225507,"func":"void SwapRegularFanoutsAndMaxPortValues(FanoutsMap* fanouts,\n                                        MaxOutputPortsMap* max_output_ports,\n                                        NodeDef* from_node, NodeDef* to_node) {\n  auto from_max_port = max_output_ports->find(from_node);\n  auto to_max_port = max_output_ports->find(to_node);\n  bool from_exists = from_max_port != max_output_ports->end();\n  bool to_exists = to_max_port != max_output_ports->end();\n\n  auto forward_fanouts = [fanouts](NodeDef* from, NodeDef* to, int start,\n                                   int end) {\n    for (int i = start; i <= end; ++i) {\n      MutableGraphView::OutputPort from_port(from, i);\n      auto from_fanouts = fanouts->find(from_port);\n      if (from_fanouts != fanouts->end()) {\n        MutableGraphView::OutputPort to_port(to, i);\n        fanouts->emplace(to_port, std::move(from_fanouts->second));\n        fanouts->erase(from_port);\n      }\n    }\n  };\n\n  if (from_exists && to_exists) {\n    const int from = from_max_port->second;\n    const int to = to_max_port->second;\n    const int shared = std::min(from, to);\n    for (int i = 0; i <= shared; ++i) {\n      MutableGraphView::OutputPort from_port(from_node, i);\n      auto from_fanouts = fanouts->find(from_port);\n      MutableGraphView::OutputPort to_port(to_node, i);\n      auto to_fanouts = fanouts->find(to_port);\n      SwapFanoutsMapValues(fanouts, from_port, from_fanouts, to_port,\n                           to_fanouts);\n    }\n    if (to > from) {\n      forward_fanouts(to_node, from_node, shared + 1, to);\n    } else if (from > to) {\n      forward_fanouts(from_node, to_node, shared + 1, from);\n    }\n\n    std::swap(from_max_port->second, to_max_port->second);\n  } else if (from_exists) {\n    forward_fanouts(from_node, to_node, 0, from_max_port->second);\n\n    max_output_ports->emplace(to_node, from_max_port->second);\n    max_output_ports->erase(from_node);\n  } else if (to_exists) {\n    forward_fanouts(to_node, from_node, 0, to_max_port->second);\n\n    max_output_ports->emplace(from_node, to_max_port->second);\n    max_output_ports->erase(to_node);\n  }\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":310254,"func":"_compare_routerinfo_by_ip_and_bw(const void **a, const void **b)\n{\n  routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)b;\n  int first_is_auth, second_is_auth;\n  uint32_t bw_first, bw_second;\n\n  \/* we return -1 if first should appear before second... that is,\n   * if first is a better router. *\/\n  if (first->addr < second->addr)\n    return -1;\n  else if (first->addr > second->addr)\n    return 1;\n\n  \/* Potentially, this next bit could cause k n lg n memcmp calls.  But in\n   * reality, we will almost never get here, since addresses will usually be\n   * different. *\/\n\n  first_is_auth =\n    router_digest_is_trusted_dir(first->cache_info.identity_digest);\n  second_is_auth =\n    router_digest_is_trusted_dir(second->cache_info.identity_digest);\n\n  if (first_is_auth && !second_is_auth)\n    return -1;\n  else if (!first_is_auth && second_is_auth)\n    return 1;\n\n  else if (first->is_running && !second->is_running)\n    return -1;\n  else if (!first->is_running && second->is_running)\n    return 1;\n\n  bw_first = router_get_advertised_bandwidth(first);\n  bw_second = router_get_advertised_bandwidth(second);\n\n  if (bw_first > bw_second)\n     return -1;\n  else if (bw_first < bw_second)\n    return 1;\n\n  \/* They're equal! Compare by identity digest, so there's a\n   * deterministic order and we avoid flapping. *\/\n  return fast_memcmp(first->cache_info.identity_digest,\n                     second->cache_info.identity_digest,\n                     DIGEST_LEN);\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":462411,"func":"createInstance(instanceConf_t **pinst)\n{\n\tinstanceConf_t *inst;\n\tDEFiRet;\n\tCHKmalloc(inst = MALLOC(sizeof(instanceConf_t)));\n\tinst->next = NULL;\n\n\tinst->pszBindPort = NULL;\n\tinst->pszBindAddr = NULL;\n\tinst->pszBindPath = NULL;\n\tinst->fileUID = -1;\n\tinst->fileGID = -1;\n\tinst->fCreateMode = 0644;\n\tinst->bFailOnPerms = 1;\n\tinst->bUnlink = 0;\n\tinst->pszBindRuleset = NULL;\n\tinst->pszInputName = NULL;\n\tinst->bSuppOctetFram = 1;\n\tinst->bSPFramingFix = 0;\n\tinst->bKeepAlive = 0;\n\tinst->iKeepAliveIntvl = 0;\n\tinst->iKeepAliveProbes = 0;\n\tinst->iKeepAliveTime = 0;\n\tinst->bEmitMsgOnClose = 0;\n\tinst->dfltTZ = NULL;\n\tinst->iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;\n\tinst->pBindRuleset = NULL;\n\tinst->ratelimitBurst = 10000; \/* arbitrary high limit *\/\n\tinst->ratelimitInterval = 0; \/* off *\/\n\tinst->compressionMode = COMPRESS_SINGLE_MSG;\n\n\t\/* node created, let's add to config *\/\n\tif(loadModConf->tail == NULL) {\n\t\tloadModConf->tail = loadModConf->root = inst;\n\t} else {\n\t\tloadModConf->tail->next = inst;\n\t\tloadModConf->tail = inst;\n\t}\n\n\t*pinst = inst;\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":221408,"func":"static int svm_check_nested_events(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tbool block_nested_events =\n\t\tkvm_event_needs_reinjection(vcpu) || svm->nested.nested_run_pending;\n\tstruct kvm_lapic *apic = vcpu->arch.apic;\n\n\tif (lapic_in_kernel(vcpu) &&\n\t    test_bit(KVM_APIC_INIT, &apic->pending_events)) {\n\t\tif (block_nested_events)\n\t\t\treturn -EBUSY;\n\t\tif (!nested_exit_on_init(svm))\n\t\t\treturn 0;\n\t\tnested_svm_simple_vmexit(svm, SVM_EXIT_INIT);\n\t\treturn 0;\n\t}\n\n\tif (vcpu->arch.exception.pending) {\n\t\t\/*\n\t\t * Only a pending nested run can block a pending exception.\n\t\t * Otherwise an injected NMI\/interrupt should either be\n\t\t * lost or delivered to the nested hypervisor in the EXITINTINFO\n\t\t * vmcb field, while delivering the pending exception.\n\t\t *\/\n\t\tif (svm->nested.nested_run_pending)\n                        return -EBUSY;\n\t\tif (!nested_exit_on_exception(svm))\n\t\t\treturn 0;\n\t\tnested_svm_inject_exception_vmexit(svm);\n\t\treturn 0;\n\t}\n\n\tif (vcpu->arch.smi_pending && !svm_smi_blocked(vcpu)) {\n\t\tif (block_nested_events)\n\t\t\treturn -EBUSY;\n\t\tif (!nested_exit_on_smi(svm))\n\t\t\treturn 0;\n\t\tnested_svm_simple_vmexit(svm, SVM_EXIT_SMI);\n\t\treturn 0;\n\t}\n\n\tif (vcpu->arch.nmi_pending && !svm_nmi_blocked(vcpu)) {\n\t\tif (block_nested_events)\n\t\t\treturn -EBUSY;\n\t\tif (!nested_exit_on_nmi(svm))\n\t\t\treturn 0;\n\t\tnested_svm_simple_vmexit(svm, SVM_EXIT_NMI);\n\t\treturn 0;\n\t}\n\n\tif (kvm_cpu_has_interrupt(vcpu) && !svm_interrupt_blocked(vcpu)) {\n\t\tif (block_nested_events)\n\t\t\treturn -EBUSY;\n\t\tif (!nested_exit_on_intr(svm))\n\t\t\treturn 0;\n\t\ttrace_kvm_nested_intr_vmexit(svm->vmcb->save.rip);\n\t\tnested_svm_simple_vmexit(svm, SVM_EXIT_INTR);\n\t\treturn 0;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":294680,"func":"rt__valid_date_frags_p(VALUE hash, VALUE sg)\n{\n    {\n\tVALUE vjd;\n\n\tif (!NIL_P(vjd = ref_hash(\"jd\"))) {\n\t    VALUE jd = rt__valid_jd_p(vjd, sg);\n\t    if (!NIL_P(jd))\n\t\treturn jd;\n\t}\n    }\n\n    {\n\tVALUE year, yday;\n\n\tif (!NIL_P(yday = ref_hash(\"yday\")) &&\n\t    !NIL_P(year = ref_hash(\"year\"))) {\n\t    VALUE jd = rt__valid_ordinal_p(year, yday, sg);\n\t    if (!NIL_P(jd))\n\t\treturn jd;\n\t}\n    }\n\n    {\n\tVALUE year, mon, mday;\n\n\tif (!NIL_P(mday = ref_hash(\"mday\")) &&\n\t    !NIL_P(mon = ref_hash(\"mon\")) &&\n\t    !NIL_P(year = ref_hash(\"year\"))) {\n\t    VALUE jd = rt__valid_civil_p(year, mon, mday, sg);\n\t    if (!NIL_P(jd))\n\t\treturn jd;\n\t}\n    }\n\n    {\n\tVALUE year, week, wday;\n\n\twday = ref_hash(\"cwday\");\n\tif (NIL_P(wday)) {\n\t    wday = ref_hash(\"wday\");\n\t    if (!NIL_P(wday))\n\t\tif (f_zero_p(wday))\n\t\t    wday = INT2FIX(7);\n\t}\n\n\tif (!NIL_P(wday) &&\n\t    !NIL_P(week = ref_hash(\"cweek\")) &&\n\t    !NIL_P(year = ref_hash(\"cwyear\"))) {\n\t    VALUE jd = rt__valid_commercial_p(year, week, wday, sg);\n\t    if (!NIL_P(jd))\n\t\treturn jd;\n\t}\n    }\n\n    {\n\tVALUE year, week, wday;\n\n\twday = ref_hash(\"wday\");\n\tif (NIL_P(wday)) {\n\t    wday = ref_hash(\"cwday\");\n\t    if (!NIL_P(wday))\n\t\tif (f_eqeq_p(wday, INT2FIX(7)))\n\t\t    wday = INT2FIX(0);\n\t}\n\n\tif (!NIL_P(wday) &&\n\t    !NIL_P(week = ref_hash(\"wnum0\")) &&\n\t    !NIL_P(year = ref_hash(\"year\"))) {\n\t    VALUE jd = rt__valid_weeknum_p(year, week, wday, INT2FIX(0), sg);\n\t    if (!NIL_P(jd))\n\t\treturn jd;\n\t}\n    }\n\n    {\n\tVALUE year, week, wday;\n\n\twday = ref_hash(\"wday\");\n\tif (NIL_P(wday))\n\t    wday = ref_hash(\"cwday\");\n\tif (!NIL_P(wday))\n\t    wday = f_mod(f_sub(wday, INT2FIX(1)),\n\t\t\t INT2FIX(7));\n\n\tif (!NIL_P(wday) &&\n\t    !NIL_P(week = ref_hash(\"wnum1\")) &&\n\t    !NIL_P(year = ref_hash(\"year\"))) {\n\t    VALUE jd = rt__valid_weeknum_p(year, week, wday, INT2FIX(1), sg);\n\t    if (!NIL_P(jd))\n\t\treturn jd;\n\t}\n    }\n    return Qnil;\n}","target":0,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":273926,"func":"static void do_STOR(uev_t *w, void *arg, int events)\n{\n\tctrl_t *ctrl = (ctrl_t *)arg;\n\tstruct timeval tv;\n\tssize_t bytes;\n\tsize_t num;\n\tchar buf[BUFFER_SIZE];\n\n\tif (UEV_ERROR == events || UEV_HUP == events) {\n\t\tDBG(\"error on data_sd ...\");\n\t\tuev_io_start(w);\n\t\treturn;\n\t}\n\n\tif (!ctrl->fp) {\n\t\tDBG(\"no fp for STOR, bailing.\");\n\t\treturn;\n\t}\n\n\t\/* Reset inactivity timer. *\/\n\tuev_timer_set(&ctrl->timeout_watcher, INACTIVITY_TIMER, 0);\n\n\tbytes = recv(ctrl->data_sd, buf, sizeof(buf), 0);\n\tif (bytes < 0) {\n\t\tif (ECONNRESET == errno)\n\t\t\tDBG(\"Connection reset by client.\");\n\t\telse\n\t\t\tERR(errno, \"Failed receiving file %s from client\", ctrl->file);\n\t\tdo_abort(ctrl);\n\t\tsend_msg(ctrl->sd, \"426 TCP connection was established but then broken!\\r\\n\");\n\t\treturn;\n\t}\n\tif (bytes == 0) {\n\t\tINFO(\"User %s at %s uploaded file %s\", ctrl->name, ctrl->clientaddr, ctrl->file);\n\t\tdo_abort(ctrl);\n\t\tsend_msg(ctrl->sd, \"226 Transfer complete.\\r\\n\");\n\t\treturn;\n\t}\n\n\tgettimeofday(&tv, NULL);\n\tif (tv.tv_sec - ctrl->tv.tv_sec > 3) {\n\t\tDBG(\"Receiving %zd bytes of %s from %s ...\", bytes, ctrl->file, ctrl->clientaddr);\n\t\tctrl->tv.tv_sec = tv.tv_sec;\n\t}\n\n\tnum = fwrite(buf, 1, bytes, ctrl->fp);\n\tif ((size_t)bytes != num)\n\t\tERR(errno, \"552 Disk full.\");\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":353021,"func":"bitStringValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tber_len_t i;\n\n\t\/* very unforgiving validation, requires no normalization\n\t * before simplistic matching\n\t *\/\n\tif( in->bv_len < 3 ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* RFC 4517 Section 3.3.2 Bit String:\n\t *\tBitString    = SQUOTE *binary-digit SQUOTE \"B\"\n\t *\tbinary-digit = \"0\" \/ \"1\"\n\t *\n\t * where SQUOTE [RFC4512] is\n\t *\tSQUOTE  = %x27 ; single quote (\"'\")\n\t *\n\t * Example: '0101111101'B\n\t *\/\n\t\n\tif( in->bv_val[0] != '\\'' ||\n\t\tin->bv_val[in->bv_len - 2] != '\\'' ||\n\t\tin->bv_val[in->bv_len - 1] != 'B' )\n\t{\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tfor( i = in->bv_len - 3; i > 0; i-- ) {\n\t\tif( in->bv_val[i] != '0' && in->bv_val[i] != '1' ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":482489,"func":"compileGrouping(FileInfo *file, int noback, int nofor, TranslationTableHeader **table,\n\t\tDisplayTableHeader **displayTable) {\n\tint k;\n\tCharsString name;\n\tCharsString groupChars;\n\tCharsString groupDots;\n\tCharsString dotsParsed;\n\tif (!getToken(file, &name, \"name operand\")) return 0;\n\tif (!getRuleCharsText(file, &groupChars)) return 0;\n\tif (!getToken(file, &groupDots, \"dots operand\")) return 0;\n\tfor (k = 0; k < groupDots.length && groupDots.chars[k] != ','; k++)\n\t\t;\n\tif (k == groupDots.length) {\n\t\tcompileError(file, \"Dots operand must consist of two cells separated by a comma\");\n\t\treturn 0;\n\t}\n\tgroupDots.chars[k] = '-';\n\tif (!parseDots(file, &dotsParsed, &groupDots)) return 0;\n\tif (groupChars.length != 2 || dotsParsed.length != 2) {\n\t\tcompileError(file,\n\t\t\t\t\"two Unicode characters and two cells separated by a comma are needed.\");\n\t\treturn 0;\n\t}\n\tif (table) {\n\t\tTranslationTableOffset ruleOffset;\n\t\tTranslationTableCharacter *charsDotsPtr;\n\t\tcharsDotsPtr = putChar(file, groupChars.chars[0], table, NULL);\n\t\tcharsDotsPtr->attributes |= CTC_Math;\n\t\tcharsDotsPtr = putChar(file, groupChars.chars[1], table, NULL);\n\t\tcharsDotsPtr->attributes |= CTC_Math;\n\t\tcharsDotsPtr = putDots(file, dotsParsed.chars[0], table);\n\t\tcharsDotsPtr->attributes |= CTC_Math;\n\t\tcharsDotsPtr = putDots(file, dotsParsed.chars[1], table);\n\t\tcharsDotsPtr->attributes |= CTC_Math;\n\t\tif (!addRule(file, CTO_Grouping, &groupChars, &dotsParsed, 0, 0, &ruleOffset,\n\t\t\t\t\tNULL, noback, nofor, table))\n\t\t\treturn 0;\n\t\tif (!addRuleName(file, &name, ruleOffset, *table)) return 0;\n\t}\n\tif (displayTable) {\n\t\tputCharDotsMapping(file, groupChars.chars[0], dotsParsed.chars[0], displayTable);\n\t\tputCharDotsMapping(file, groupChars.chars[1], dotsParsed.chars[1], displayTable);\n\t}\n\tif (table) {\n\t\twidechar endChar;\n\t\twidechar endDots;\n\t\tendChar = groupChars.chars[1];\n\t\tendDots = dotsParsed.chars[1];\n\t\tgroupChars.length = dotsParsed.length = 1;\n\t\tif (!addRule(file, CTO_Math, &groupChars, &dotsParsed, 0, 0, NULL, NULL, noback,\n\t\t\t\t\tnofor, table))\n\t\t\treturn 0;\n\t\tgroupChars.chars[0] = endChar;\n\t\tdotsParsed.chars[0] = endDots;\n\t\tif (!addRule(file, CTO_Math, &groupChars, &dotsParsed, 0, 0, NULL, NULL, noback,\n\t\t\t\t\tnofor, table))\n\t\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":707,"total_token_length":943,"max_tokens_setting":1024}
+{"idx":226980,"func":"IRC_PROTOCOL_CALLBACK(368)\n{\n    char *pos_args;\n    struct t_irc_channel *ptr_channel;\n    struct t_gui_buffer *ptr_buffer;\n    struct t_irc_modelist *ptr_modelist;\n\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    pos_args = (argc > 4) ?\n        ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL;\n\n    ptr_channel = irc_channel_search (server, argv[3]);\n    ptr_buffer = (ptr_channel && ptr_channel->nicks) ?\n        ptr_channel->buffer : server->buffer;\n    ptr_modelist = irc_modelist_search (ptr_channel, 'b');\n    if (ptr_modelist)\n    {\n        if (ptr_modelist->state != IRC_MODELIST_STATE_RECEIVING)\n        {\n            \/*\n             * remove all items if no ban was received before\n             * the end of ban list\n             *\/\n            irc_modelist_item_free_all (ptr_modelist);\n        }\n        ptr_modelist->state = IRC_MODELIST_STATE_RECEIVED;\n    }\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (\n            server, NULL, command, \"banlist\", ptr_buffer),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s[%s%s%s]%s%s%s\",\n        weechat_prefix (\"network\"),\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_CHAT_CHANNEL,\n        argv[3],\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_RESET,\n        (pos_args) ? \" \" : \"\",\n        (pos_args) ? pos_args : \"\");\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":225482,"func":"Status MutableGraphView::AddRegularFaninByPort(absl::string_view node_name,\n                                               int port,\n                                               const TensorId& fanin) {\n  auto error_status = [node_name, port, fanin](absl::string_view msg) {\n    string params = absl::Substitute(\"node_name='$0', port=$1, fanin='$2'\",\n                                     node_name, port, fanin.ToString());\n    return MutationError(\"AddRegularFaninByPort\", params, msg);\n  };\n\n  TF_RETURN_IF_ERROR(CheckFaninIsRegular(fanin, error_status));\n  TF_RETURN_IF_ERROR(CheckAddingFaninToSelf(node_name, fanin, error_status));\n  NodeDef* node = GetNode(node_name);\n  TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));\n  const int num_regular_fanins =\n      NumFanins(*node, \/*include_controlling_nodes=*\/false);\n  TF_RETURN_IF_ERROR(\n      CheckPortRange(port, \/*min=*\/0, num_regular_fanins, error_status));\n  NodeDef* fanin_node = GetNode(fanin.node());\n  TF_RETURN_IF_ERROR(CheckNodeExists(fanin.node(), fanin_node, error_status));\n\n  const int last_node_input = node->input_size();\n  node->add_input(TensorIdToString(fanin));\n  node->mutable_input()->SwapElements(num_regular_fanins, last_node_input);\n  for (int i = num_regular_fanins - 1; i >= port; --i) {\n    TensorId tensor_id = ParseTensorName(node->input(i));\n    OutputPort fanin_port(nodes()[tensor_id.node()], tensor_id.index());\n    absl::flat_hash_set<InputPort>* fanouts_set = &fanouts()[fanin_port];\n    fanouts_set->erase({node, i});\n    fanouts_set->insert({node, i + 1});\n    node->mutable_input()->SwapElements(i, i + 1);\n  }\n\n  OutputPort fanin_port(fanin_node, fanin.index());\n  fanouts()[fanin_port].insert({node, port});\n  UpdateMaxRegularOutputPortForAddedFanin(fanin_port);\n\n  max_regular_input_port()[node] = num_regular_fanins;\n  if (CanDedupControlWithRegularInput(*this, *fanin_node)) {\n    RemoveControllingFaninInternal(node, fanin_node);\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":211700,"func":"int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host,\n\t\t\t\tu8 event, struct sk_buff *skb)\n{\n\tint r = 0;\n\tstruct device *dev = &hdev->ndev->dev;\n\tstruct nfc_evt_transaction *transaction;\n\n\tpr_debug(\"connectivity gate event: %x\\n\", event);\n\n\tswitch (event) {\n\tcase ST21NFCA_EVT_CONNECTIVITY:\n\t\tr = nfc_se_connectivity(hdev->ndev, host);\n\tbreak;\n\tcase ST21NFCA_EVT_TRANSACTION:\n\t\t\/*\n\t\t * According to specification etsi 102 622\n\t\t * 11.2.2.4 EVT_TRANSACTION Table 52\n\t\t * Description\tTag\tLength\n\t\t * AID\t\t81\t5 to 16\n\t\t * PARAMETERS\t82\t0 to 255\n\t\t *\/\n\t\tif (skb->len < NFC_MIN_AID_LENGTH + 2 &&\n\t\t    skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)\n\t\t\treturn -EPROTO;\n\n\t\ttransaction = devm_kzalloc(dev, skb->len - 2, GFP_KERNEL);\n\t\tif (!transaction)\n\t\t\treturn -ENOMEM;\n\n\t\ttransaction->aid_len = skb->data[1];\n\t\tmemcpy(transaction->aid, &skb->data[2],\n\t\t       transaction->aid_len);\n\n\t\t\/* Check next byte is PARAMETERS tag (82) *\/\n\t\tif (skb->data[transaction->aid_len + 2] !=\n\t\t    NFC_EVT_TRANSACTION_PARAMS_TAG)\n\t\t\treturn -EPROTO;\n\n\t\ttransaction->params_len = skb->data[transaction->aid_len + 3];\n\t\tmemcpy(transaction->params, skb->data +\n\t\t       transaction->aid_len + 4, transaction->params_len);\n\n\t\tr = nfc_se_transaction(hdev->ndev, host, transaction);\n\tbreak;\n\tdefault:\n\t\tnfc_err(&hdev->ndev->dev, \"Unexpected event on connectivity gate\\n\");\n\t\treturn 1;\n\t}\n\tkfree_skb(skb);\n\treturn r;\n}","target":1,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":468357,"func":"g_socket_client_enumerator_callback (GObject      *object,\n\t\t\t\t     GAsyncResult *result,\n\t\t\t\t     gpointer      user_data)\n{\n  GSocketClientAsyncConnectData *data = user_data;\n  GSocketAddress *address = NULL;\n  GSocket *socket;\n  ConnectionAttempt *attempt;\n  GError *error = NULL;\n\n  if (task_completed_or_cancelled (data->task))\n    {\n      g_object_unref (data->task);\n      return;\n    }\n\n  address = g_socket_address_enumerator_next_finish (data->enumerator,\n\t\t\t\t\t\t     result, &error);\n  if (address == NULL)\n    {\n      if (data->connection_attempts)\n        {\n          g_object_unref (data->task);\n          return;\n        }\n\n      g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL);\n      if (!error)\n\t{\n\t  if (data->last_error)\n\t    {\n\t      error = data->last_error;\n\t      data->last_error = NULL;\n\t    }\n\t  else\n\t    {\n\t      g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,\n\t\t\t\t   _(\"Unknown error on connect\"));\n\t    }\n\t}\n      g_task_return_error (data->task, error);\n      g_object_unref (data->task);\n      return;\n    }\n\n  g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_RESOLVED,\n\t\t\t      data->connectable, NULL);\n\n  if (G_IS_PROXY_ADDRESS (address) &&\n      data->client->priv->enable_proxy)\n    data->proxy_addr = g_object_ref (G_PROXY_ADDRESS (address));\n\n  g_clear_error (&data->last_error);\n\n  socket = create_socket (data->client, address, &data->last_error);\n  if (socket == NULL)\n    {\n      g_object_unref (address);\n      enumerator_next_async (data, FALSE);\n      return;\n    }\n\n  attempt = connection_attempt_new ();\n  attempt->data = data;\n  attempt->socket = socket;\n  attempt->address = address;\n  attempt->cancellable = g_cancellable_new ();\n  attempt->connection = (GIOStream *)g_socket_connection_factory_create_connection (socket);\n  attempt->timeout_source = g_timeout_source_new (HAPPY_EYEBALLS_CONNECTION_ATTEMPT_TIMEOUT_MS);\n  g_source_set_callback (attempt->timeout_source, on_connection_attempt_timeout, attempt, NULL);\n  g_source_attach (attempt->timeout_source, g_main_context_get_thread_default ());\n  data->connection_attempts = g_slist_append (data->connection_attempts, attempt);\n\n  if (g_task_get_cancellable (data->task))\n    g_cancellable_connect (g_task_get_cancellable (data->task), G_CALLBACK (on_connection_cancelled),\n                           g_object_ref (attempt->cancellable), g_object_unref);\n\n  g_socket_connection_set_cached_remote_address ((GSocketConnection *)attempt->connection, address);\n  g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_CONNECTING, data->connectable, attempt->connection);\n  g_socket_connection_connect_async (G_SOCKET_CONNECTION (attempt->connection),\n\t\t\t\t     address,\n\t\t\t\t     attempt->cancellable,\n\t\t\t\t     g_socket_client_connected_callback, connection_attempt_ref (attempt));\n}","target":0,"code_token_length":661,"total_token_length":897,"max_tokens_setting":1024}
+{"idx":390625,"func":"CheckSetDeviceIndicators(\tchar *\t\twire,\n\t\t\t\tDeviceIntPtr\tdev,\n\t\t\t\tint\t\tnum,\n\t\t\t\tint *\t\tstatus_rtrn,\n\t\t\t\tClientPtr\tclient)\n{\nxkbDeviceLedsWireDesc *\tledWire;\nint\t\t\ti;\nXkbSrvLedInfoPtr \tsli;\n\n    ledWire= (xkbDeviceLedsWireDesc *)wire;\n    for (i=0;i<num;i++) {\n\tif (client->swapped) {\n\t   register int n;\n\t   swaps(&ledWire->ledClass,n);\n\t   swaps(&ledWire->ledID,n);\n\t   swapl(&ledWire->namesPresent,n);\n\t   swapl(&ledWire->mapsPresent,n);\n\t   swapl(&ledWire->physIndicators,n);\n\t}\n\n        sli= XkbFindSrvLedInfo(dev,ledWire->ledClass,ledWire->ledID,\n\t\t\t\t\t\t\tXkbXI_IndicatorsMask);\n\tif (sli!=NULL) {\n\t    register int n;\n\t    register unsigned bit;\n\t    int nMaps,nNames;\n\t    CARD32 *atomWire;\n\t    xkbIndicatorMapWireDesc *mapWire;\n\n\t    nMaps= nNames= 0;\n\t    for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {\n\t\tif (ledWire->namesPresent&bit)\n\t\t    nNames++;\n\t\tif (ledWire->mapsPresent&bit)\n\t\t    nMaps++;\n\t    }\n\t    atomWire= (CARD32 *)&ledWire[1];\n\t    if (nNames>0) {\n\t\tfor (n=0;n<nNames;n++) {\n\t\t    if (client->swapped) {\n\t\t\tregister int t;\n\t\t\tswapl(atomWire,t);\n\t\t    }\n\t\t    CHK_ATOM_OR_NONE3(((Atom)(*atomWire)),client->errorValue,\n\t\t\t\t\t\t\t*status_rtrn,NULL);\n\t\t    atomWire++;\n\t\t}\n\t    }\n\t    mapWire= (xkbIndicatorMapWireDesc *)atomWire;\n\t    if (nMaps>0) {\n\t\tfor (n=0;n<nMaps;n++) {\n\t\t    if (client->swapped) {\n\t\t\tregister int t;\n\t\t\tswaps(&mapWire->virtualMods,t);\n\t\t\tswapl(&mapWire->ctrls,t);\n\t\t    }\n\t\t    CHK_MASK_LEGAL3(0x21,mapWire->whichGroups,\n\t\t\t\t\t\tXkbIM_UseAnyGroup,\n\t\t\t\t\t\tclient->errorValue,\n\t\t\t\t\t\t*status_rtrn,NULL);\n\t\t    CHK_MASK_LEGAL3(0x22,mapWire->whichMods,XkbIM_UseAnyMods,\n\t\t\t\t\t\tclient->errorValue,\n\t\t\t\t\t\t*status_rtrn,NULL);\n\t\t    mapWire++;\n\t\t}\n\t    }\n\t    ledWire= (xkbDeviceLedsWireDesc *)mapWire;\n\t}\n\telse {\n\t    \/* SHOULD NEVER HAPPEN *\/\n\t    return (char *)ledWire;\n\t}\n    }\n    return (char *)ledWire;\n}","target":0,"code_token_length":608,"total_token_length":844,"max_tokens_setting":1024}
+{"idx":221464,"func":"start_dbus_proxy (FlatpakBwrap *app_bwrap,\n                  FlatpakBwrap *proxy_arg_bwrap,\n                  const char   *app_info_path,\n                  GError      **error)\n{\n  char x = 'x';\n  const char *proxy;\n  g_autofree char *commandline = NULL;\n  g_autoptr(FlatpakBwrap) proxy_bwrap = NULL;\n  int sync_fds[2] = {-1, -1};\n  int proxy_start_index;\n\n  proxy_bwrap = flatpak_bwrap_new (NULL);\n\n  if (!add_bwrap_wrapper (proxy_bwrap, app_info_path, error))\n    return FALSE;\n\n  proxy = g_getenv (\"FLATPAK_DBUSPROXY\");\n  if (proxy == NULL)\n    proxy = DBUSPROXY;\n\n  flatpak_bwrap_add_arg (proxy_bwrap, proxy);\n\n  proxy_start_index = proxy_bwrap->argv->len;\n\n  if (pipe2 (sync_fds, O_CLOEXEC) < 0)\n    {\n      g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errno),\n                           _(\"Unable to create sync pipe\"));\n      return FALSE;\n    }\n\n  \/* read end goes to app *\/\n  flatpak_bwrap_add_args_data_fd (app_bwrap, \"--sync-fd\", sync_fds[0], NULL);\n\n  \/* write end goes to proxy *\/\n  flatpak_bwrap_add_fd (proxy_bwrap, sync_fds[1]);\n  flatpak_bwrap_add_arg_printf (proxy_bwrap, \"--fd=%d\", sync_fds[1]);\n\n  \/* Note: This steals the fds from proxy_arg_bwrap *\/\n  flatpak_bwrap_append_bwrap (proxy_bwrap, proxy_arg_bwrap);\n\n  if (!flatpak_bwrap_bundle_args (proxy_bwrap, proxy_start_index, -1, TRUE, error))\n    return FALSE;\n\n  flatpak_bwrap_finish (proxy_bwrap);\n\n  commandline = flatpak_quote_argv ((const char **) proxy_bwrap->argv->pdata, -1);\n  g_debug (\"Running '%s'\", commandline);\n\n  \/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_fds_workaround *\/\n  if (!g_spawn_async (NULL,\n                      (char **) proxy_bwrap->argv->pdata,\n                      NULL,\n                      G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN,\n                      flatpak_bwrap_child_setup_cb, proxy_bwrap->fds,\n                      NULL, error))\n    return FALSE;\n\n  \/* The write end can be closed now, otherwise the read below will hang of xdg-dbus-proxy\n     fails to start. *\/\n  g_clear_pointer (&proxy_bwrap, flatpak_bwrap_free);\n\n  \/* Sync with proxy, i.e. wait until its listening on the sockets *\/\n  if (read (sync_fds[0], &x, 1) != 1)\n    {\n      g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errno),\n                           _(\"Failed to sync with dbus proxy\"));\n      return FALSE;\n    }\n\n  return TRUE;\n}","target":0,"code_token_length":652,"total_token_length":888,"max_tokens_setting":1024}
+{"idx":317303,"func":"static unsigned int selinux_ip_forward(struct sk_buff *skb,\n\t\t\t\t       const struct net_device *indev,\n\t\t\t\t       u16 family)\n{\n\tint err;\n\tchar *addrp;\n\tu32 peer_sid;\n\tstruct common_audit_data ad;\n\tstruct lsm_network_audit net = {0,};\n\tu8 secmark_active;\n\tu8 netlbl_active;\n\tu8 peerlbl_active;\n\n\tif (!selinux_policycap_netpeer())\n\t\treturn NF_ACCEPT;\n\n\tsecmark_active = selinux_secmark_enabled();\n\tnetlbl_active = netlbl_enabled();\n\tpeerlbl_active = selinux_peerlbl_enabled();\n\tif (!secmark_active && !peerlbl_active)\n\t\treturn NF_ACCEPT;\n\n\tif (selinux_skb_peerlbl_sid(skb, family, &peer_sid) != 0)\n\t\treturn NF_DROP;\n\n\tad.type = LSM_AUDIT_DATA_NET;\n\tad.u.net = &net;\n\tad.u.net->netif = indev->ifindex;\n\tad.u.net->family = family;\n\tif (selinux_parse_skb(skb, &ad, &addrp, 1, NULL) != 0)\n\t\treturn NF_DROP;\n\n\tif (peerlbl_active) {\n\t\terr = selinux_inet_sys_rcv_skb(dev_net(indev), indev->ifindex,\n\t\t\t\t\t       addrp, family, peer_sid, &ad);\n\t\tif (err) {\n\t\t\tselinux_netlbl_err(skb, family, err, 1);\n\t\t\treturn NF_DROP;\n\t\t}\n\t}\n\n\tif (secmark_active)\n\t\tif (avc_has_perm(&selinux_state,\n\t\t\t\t peer_sid, skb->secmark,\n\t\t\t\t SECCLASS_PACKET, PACKET__FORWARD_IN, &ad))\n\t\t\treturn NF_DROP;\n\n\tif (netlbl_active)\n\t\t\/* we do this in the FORWARD path and not the POST_ROUTING\n\t\t * path because we want to make sure we apply the necessary\n\t\t * labeling before IPsec is applied so we can leverage AH\n\t\t * protection *\/\n\t\tif (selinux_netlbl_skbuff_setsid(skb, family, peer_sid) != 0)\n\t\t\treturn NF_DROP;\n\n\treturn NF_ACCEPT;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":326914,"func":"*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args)\n{\n\tu32 priv_sz = sizeof(struct vidtv_s302m_ctx);\n\tstruct vidtv_s302m_ctx *ctx;\n\tstruct vidtv_encoder *e;\n\n\te = kzalloc(sizeof(*e), GFP_KERNEL);\n\tif (!e)\n\t\treturn NULL;\n\n\te->id = S302M;\n\n\tif (args.name)\n\t\te->name = kstrdup(args.name, GFP_KERNEL);\n\n\te->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ);\n\tif (!e->encoder_buf)\n\t\tgoto out_kfree_e;\n\n\te->encoder_buf_sz = VIDTV_S302M_BUF_SZ;\n\te->encoder_buf_offset = 0;\n\n\te->sample_count = 0;\n\n\te->src_buf = (args.src_buf) ? args.src_buf : NULL;\n\te->src_buf_sz = (args.src_buf) ? args.src_buf_sz : 0;\n\te->src_buf_offset = 0;\n\n\te->is_video_encoder = false;\n\n\tctx = kzalloc(priv_sz, GFP_KERNEL);\n\tif (!ctx)\n\t\tgoto out_kfree_buf;\n\n\te->ctx = ctx;\n\tctx->last_duration = 0;\n\n\te->encode = vidtv_s302m_encode;\n\te->clear = vidtv_s302m_clear;\n\n\te->es_pid = cpu_to_be16(args.es_pid);\n\te->stream_id = cpu_to_be16(PES_PRIVATE_STREAM_1);\n\n\te->sync = args.sync;\n\te->sampling_rate_hz = S302M_SAMPLING_RATE_HZ;\n\n\te->last_sample_cb = args.last_sample_cb;\n\n\te->destroy = vidtv_s302m_encoder_destroy;\n\n\tif (args.head) {\n\t\twhile (args.head->next)\n\t\t\targs.head = args.head->next;\n\n\t\targs.head->next = e;\n\t}\n\n\te->next = NULL;\n\n\treturn e;\n\nout_kfree_buf:\n\tkfree(e->encoder_buf);\n\nout_kfree_e:\n\tkfree(e->name);\n\tkfree(e);\n\treturn NULL;\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":218803,"func":"static MagickBooleanType ReadPSDChannelRaw(Image *image,const size_t channels,\n  const ssize_t type,ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  size_t\n    row_size;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n       \"      layer data is RAW\");\n\n  row_size=GetPSDRowSize(image);\n  pixels=(unsigned char *) AcquireQuantumMemory(row_size,sizeof(*pixels));\n  if (pixels == (unsigned char *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  (void) memset(pixels,0,row_size*sizeof(*pixels));\n  status=MagickTrue;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    status=MagickFalse;\n\n    count=ReadBlob(image,row_size,pixels);\n    if (count != (ssize_t) row_size)\n      {\n        status=MagickFalse;\n        break;\n      }\n\n    status=ReadPSDChannelPixels(image,channels,y,type,pixels,exception);\n    if (status == MagickFalse)\n      break;\n  }\n\n  pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n  return(status);\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":281628,"func":"void CLASS sony_arw_load_raw()\n{\n  ushort huff[32768];\n  static const ushort tab[18] =\n  { 0xf11,0xf10,0xe0f,0xd0e,0xc0d,0xb0c,0xa0b,0x90a,0x809,\n    0x708,0x607,0x506,0x405,0x304,0x303,0x300,0x202,0x201 };\n  int i, c, n, col, row, len, diff, sum=0;\n\n  for (n=i=0; i < 18; i++)\n    FORC(32768 >> (tab[i] >> 8)) huff[n++] = tab[i];\n  getbits(-1);\n  for (col = raw_width; col--; )\n  {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    for (row=0; row < raw_height+1; row+=2) {\n      if (row == raw_height) row = 1;\n      len = getbithuff(15,huff);\n      diff = getbits(len);\n      if ((diff & (1 << (len-1))) == 0)\n\tdiff -= (1 << len) - 1;\n      if ((sum += diff) >> 12) derror();\n      if (row < height) RAW(row,col) = sum;\n    }\n  }\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":231777,"func":"TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterHalfCloseRemote) {\n  server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 3;\n  std::array<std::string, 4> words = {\n      \"Hey Bob, this is Alice, for real.\",\n      \"What message did I send you last time?\",\n      \"You don't sound like Alice\",\n      \"You are a liar!\",\n  };\n\n  StreamId streamId = 0x00;\n  auto stream = server->getNonConstConn().streamManager->getStream(streamId);\n  stream->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false);\n  stream->readBuffer.emplace_back(\n      IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false);\n  stream->retransmissionBuffer.emplace(\n      std::piecewise_construct,\n      std::forward_as_tuple(0),\n      std::forward_as_tuple(std::make_unique<StreamBuffer>(\n          IOBuf::copyBuffer(words.at(2)), 0, false)));\n  stream->writeBuffer.append(IOBuf::copyBuffer(words.at(3)));\n  stream->currentWriteOffset = words.at(2).length() + words.at(3).length();\n  stream->currentReadOffset = words.at(0).length() + words.at(1).length();\n\n  server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 5;\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n\n  StopSendingFrame stopSendingFrame(\n      streamId, GenericApplicationErrorCode::UNKNOWN);\n  ASSERT_TRUE(builder.canBuildPacket());\n  auto dataLen = writeStreamFrameHeader(\n      builder,\n      0x00,\n      stream->currentReadOffset,\n      0,\n      10,\n      true,\n      folly::none \/* skipLenHint *\/);\n  ASSERT_TRUE(dataLen.has_value());\n  ASSERT_EQ(*dataLen, 0);\n  writeFrame(QuicSimpleFrame(stopSendingFrame), builder);\n  auto packet = std::move(builder).buildPacket();\n  EXPECT_CALL(\n      connCallback,\n      onStopSending(streamId, GenericApplicationErrorCode::UNKNOWN));\n  deliverData(packetToBuf(packet));\n}","target":0,"code_token_length":533,"total_token_length":769,"max_tokens_setting":1024}
+{"idx":200976,"func":"get_visual_text(\n    cmdarg_T\t*cap,\n    char_u\t**pp,\t    \/\/ return: start of selected text\n    int\t\t*lenp)\t    \/\/ return: length of selected text\n{\n    if (VIsual_mode != 'V')\n\tunadjust_for_sel();\n    if (VIsual.lnum != curwin->w_cursor.lnum)\n    {\n\tif (cap != NULL)\n\t    clearopbeep(cap->oap);\n\treturn FAIL;\n    }\n    if (VIsual_mode == 'V')\n    {\n\t*pp = ml_get_curline();\n\t*lenp = (int)STRLEN(*pp);\n    }\n    else\n    {\n\tif (LT_POS(curwin->w_cursor, VIsual))\n\t{\n\t    *pp = ml_get_pos(&curwin->w_cursor);\n\t    *lenp = VIsual.col - curwin->w_cursor.col + 1;\n\t}\n\telse\n\t{\n\t    *pp = ml_get_pos(&VIsual);\n\t    *lenp = curwin->w_cursor.col - VIsual.col + 1;\n\t}\n\tif (**pp == NUL)\n\t    *lenp = 0;\n\tif (has_mbyte && *lenp > 0)\n\t    \/\/ Correct the length to include all bytes of the last character.\n\t    *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;\n    }\n    reset_VIsual_and_resel();\n    return OK;\n}","target":1,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":195261,"func":"Node* Graph::AddNode(NodeDef node_def, Status* status) {\n  const OpRegistrationData* op_reg_data;\n  status->Update(ops_.LookUp(node_def.op(), &op_reg_data));\n  if (!status->ok()) return nullptr;\n\n  DataTypeVector inputs;\n  DataTypeVector outputs;\n  status->Update(\n      InOutTypesForNode(node_def, op_reg_data->op_def, &inputs, &outputs));\n  if (!status->ok()) {\n    *status = AttachDef(*status, node_def);\n    return nullptr;\n  }\n\n  Node::NodeClass node_class = op_reg_data->is_function_op\n                                   ? Node::NC_FUNCTION_OP\n                                   : Node::GetNodeClassForOp(node_def.op());\n\n  if (op_reg_data->type_ctor != nullptr) {\n    VLOG(3) << \"AddNode: found type constructor for \" << node_def.name();\n    const auto ctor_type =\n        full_type::SpecializeType(AttrSlice(node_def), op_reg_data->op_def);\n    const FullTypeDef ctor_typedef = ctor_type.ValueOrDie();\n    if (ctor_typedef.type_id() != TFT_UNSET) {\n      *(node_def.mutable_experimental_type()) = ctor_typedef;\n    }\n  } else {\n    VLOG(3) << \"AddNode: no type constructor for \" << node_def.name();\n  }\n\n  Node* node = AllocateNode(std::make_shared<NodeProperties>(\n                                &op_reg_data->op_def, std::move(node_def),\n                                inputs, outputs, op_reg_data->fwd_type_fn),\n                            nullptr, node_class);\n  return node;\n}","target":1,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":508916,"func":"bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)\n{\n\n  if (!((options & SELECT_DISTINCT) && !group_list.elements))\n    hidden_bit_fields= 0;\n\n  \/\/ find_order_in_list() may need some extra space, so multiply by two.\n  order_group_num*= 2;\n\n  \/*\n    We have to create array in prepared statement memory if it is a\n    prepared statement\n  *\/\n  Query_arena *arena= thd->stmt_arena;\n  const size_t n_elems= (n_sum_items +\n                       n_child_sum_items +\n                       item_list.elements +\n                       select_n_reserved +\n                       select_n_having_items +\n                       select_n_where_fields +\n                       order_group_num +\n                       hidden_bit_fields +\n                       fields_in_window_functions) * (size_t) 5;\n  DBUG_ASSERT(n_elems % 5 == 0);\n  if (!ref_pointer_array.is_null())\n  {\n    \/*\n      We need to take 'n_sum_items' into account when allocating the array,\n      and this may actually increase during the optimization phase due to\n      MIN\/MAX rewrite in Item_in_subselect::single_value_transformer.\n      In the usual case we can reuse the array from the prepare phase.\n      If we need a bigger array, we must allocate a new one.\n     *\/\n    if (ref_pointer_array.size() >= n_elems)\n      return false;\n   }\n  Item **array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));\n  if (array != NULL)\n    ref_pointer_array= Ref_ptr_array(array, n_elems);\n\n  return array == NULL;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":337808,"func":"static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,\n\t\t\t\t\t   __u8 type, __u8 flags, int paylen,\n\t\t\t\t\t   gfp_t gfp)\n{\n\tstruct sctp_chunkhdr *chunk_hdr;\n\tstruct sctp_chunk *retval;\n\tstruct sk_buff *skb;\n\tstruct sock *sk;\n\tint chunklen;\n\n\tchunklen = SCTP_PAD4(sizeof(*chunk_hdr) + paylen);\n\tif (chunklen > SCTP_MAX_CHUNK_LEN)\n\t\tgoto nodata;\n\n\t\/* No need to allocate LL here, as this is only a chunk. *\/\n\tskb = alloc_skb(chunklen, gfp);\n\tif (!skb)\n\t\tgoto nodata;\n\n\t\/* Make room for the chunk header.  *\/\n\tchunk_hdr = (struct sctp_chunkhdr *)skb_put(skb, sizeof(*chunk_hdr));\n\tchunk_hdr->type\t  = type;\n\tchunk_hdr->flags  = flags;\n\tchunk_hdr->length = htons(sizeof(*chunk_hdr));\n\n\tsk = asoc ? asoc->base.sk : NULL;\n\tretval = sctp_chunkify(skb, asoc, sk, gfp);\n\tif (!retval) {\n\t\tkfree_skb(skb);\n\t\tgoto nodata;\n\t}\n\n\tretval->chunk_hdr = chunk_hdr;\n\tretval->chunk_end = ((__u8 *)chunk_hdr) + sizeof(*chunk_hdr);\n\n\t\/* Determine if the chunk needs to be authenticated *\/\n\tif (sctp_auth_send_cid(type, asoc))\n\t\tretval->auth = 1;\n\n\treturn retval;\nnodata:\n\treturn NULL;\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":230305,"func":"njs_array_prototype_push(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    int64_t      length;\n    njs_int_t    ret;\n    njs_uint_t   i;\n    njs_array_t  *array;\n    njs_value_t  *this;\n\n    length = 0;\n    this = njs_argument(args, 0);\n\n    ret = njs_value_to_object(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_is_fast_array(this)) {\n        array = njs_array(this);\n\n        if (nargs != 0) {\n            ret = njs_array_expand(vm, array, 0, nargs);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            for (i = 1; i < nargs; i++) {\n                \/* GC: njs_retain(&args[i]); *\/\n                array->start[array->length++] = args[i];\n            }\n        }\n\n        njs_set_number(&vm->retval, array->length);\n\n        return NJS_OK;\n    }\n\n    ret = njs_object_length(vm, this, &length);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    if (njs_slow_path((length + nargs - 1) > NJS_MAX_LENGTH)) {\n        njs_type_error(vm, \"Invalid length\");\n        return NJS_ERROR;\n    }\n\n    for (i = 1; i < nargs; i++) {\n        ret = njs_value_property_i64_set(vm, this, length++, &args[i]);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n    }\n\n    ret = njs_object_length_set(vm, this, length);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return ret;\n    }\n\n    njs_set_number(&vm->retval, length);\n\n    return NJS_OK;\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":332379,"func":"swapchar(int op_type, pos_T *pos)\n{\n    int\t    c;\n    int\t    nc;\n\n    c = gchar_pos(pos);\n\n    \/\/ Only do rot13 encoding for ASCII characters.\n    if (c >= 0x80 && op_type == OP_ROT13)\n\treturn FALSE;\n\n    if (op_type == OP_UPPER && c == 0xdf\n\t\t      && (enc_latin1like || STRCMP(p_enc, \"iso-8859-2\") == 0))\n    {\n\tpos_T   sp = curwin->w_cursor;\n\n\t\/\/ Special handling of German sharp s: change to \"SS\".\n\tcurwin->w_cursor = *pos;\n\tdel_char(FALSE);\n\tins_char('S');\n\tins_char('S');\n\tcurwin->w_cursor = sp;\n\tinc(pos);\n    }\n\n    if (enc_dbcs != 0 && c >= 0x100)\t\/\/ No lower\/uppercase letter\n\treturn FALSE;\n    nc = c;\n    if (MB_ISLOWER(c))\n    {\n\tif (op_type == OP_ROT13)\n\t    nc = ROT13(c, 'a');\n\telse if (op_type != OP_LOWER)\n\t    nc = MB_TOUPPER(c);\n    }\n    else if (MB_ISUPPER(c))\n    {\n\tif (op_type == OP_ROT13)\n\t    nc = ROT13(c, 'A');\n\telse if (op_type != OP_UPPER)\n\t    nc = MB_TOLOWER(c);\n    }\n    if (nc != c)\n    {\n\tif (enc_utf8 && (c >= 0x80 || nc >= 0x80))\n\t{\n\t    pos_T   sp = curwin->w_cursor;\n\n\t    curwin->w_cursor = *pos;\n\t    \/\/ don't use del_char(), it also removes composing chars\n\t    del_bytes(utf_ptr2len(ml_get_cursor()), FALSE, FALSE);\n\t    ins_char(nc);\n\t    curwin->w_cursor = sp;\n\t}\n\telse\n\t    PBYTE(*pos, nc);\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":300761,"func":"static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags,\n\t\t       bool kern)\n{\n\tstruct sock *new_sk, *sk = sock->sk;\n\tstruct tipc_sock *new_tsock;\n\tstruct msghdr m = {NULL,};\n\tstruct tipc_msg *msg;\n\tstruct sk_buff *buf;\n\tlong timeo;\n\tint res;\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state != TIPC_LISTEN) {\n\t\tres = -EINVAL;\n\t\tgoto exit;\n\t}\n\ttimeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);\n\tres = tipc_wait_for_accept(sock, timeo);\n\tif (res)\n\t\tgoto exit;\n\n\tbuf = skb_peek(&sk->sk_receive_queue);\n\n\tres = tipc_sk_create(sock_net(sock->sk), new_sock, 0, kern);\n\tif (res)\n\t\tgoto exit;\n\tsecurity_sk_clone(sock->sk, new_sock->sk);\n\n\tnew_sk = new_sock->sk;\n\tnew_tsock = tipc_sk(new_sk);\n\tmsg = buf_msg(buf);\n\n\t\/* we lock on new_sk; but lockdep sees the lock on sk *\/\n\tlock_sock_nested(new_sk, SINGLE_DEPTH_NESTING);\n\n\t\/*\n\t * Reject any stray messages received by new socket\n\t * before the socket lock was taken (very, very unlikely)\n\t *\/\n\ttsk_rej_rx_queue(new_sk, TIPC_ERR_NO_PORT);\n\n\t\/* Connect new socket to it's peer *\/\n\ttipc_sk_finish_conn(new_tsock, msg_origport(msg), msg_orignode(msg));\n\n\ttsk_set_importance(new_sk, msg_importance(msg));\n\tif (msg_named(msg)) {\n\t\tnew_tsock->conn_addrtype = TIPC_SERVICE_ADDR;\n\t\tmsg_set_nametype(&new_tsock->phdr, msg_nametype(msg));\n\t\tmsg_set_nameinst(&new_tsock->phdr, msg_nameinst(msg));\n\t}\n\n\t\/*\n\t * Respond to 'SYN-' by discarding it & returning 'ACK'.\n\t * Respond to 'SYN+' by queuing it on new socket & returning 'ACK'.\n\t *\/\n\tif (!msg_data_sz(msg)) {\n\t\ttsk_advance_rx_queue(sk);\n\t} else {\n\t\t__skb_dequeue(&sk->sk_receive_queue);\n\t\t__skb_queue_head(&new_sk->sk_receive_queue, buf);\n\t\tskb_set_owner_r(buf, new_sk);\n\t}\n\t__tipc_sendstream(new_sock, &m, 0);\n\trelease_sock(new_sk);\nexit:\n\trelease_sock(sk);\n\treturn res;\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":312409,"func":"parse_efm_option(char_u *efm)\n{\n    efm_T\t*fmt_ptr = NULL;\n    efm_T\t*fmt_first = NULL;\n    efm_T\t*fmt_last = NULL;\n    char_u\t*fmtstr = NULL;\n    int\t\tlen;\n    int\t\tsz;\n\n    \/\/ Each part of the format string is copied and modified from errorformat\n    \/\/ to regex prog.  Only a few % characters are allowed.\n\n    \/\/ Get some space to modify the format string into.\n    sz = efm_regpat_bufsz(efm);\n    if ((fmtstr = alloc_id(sz, aid_qf_efm_fmtstr)) == NULL)\n\tgoto parse_efm_error;\n\n    while (efm[0] != NUL)\n    {\n\t\/\/ Allocate a new eformat structure and put it at the end of the list\n\tfmt_ptr = ALLOC_CLEAR_ONE_ID(efm_T, aid_qf_efm_fmtpart);\n\tif (fmt_ptr == NULL)\n\t    goto parse_efm_error;\n\tif (fmt_first == NULL)\t    \/\/ first one\n\t    fmt_first = fmt_ptr;\n\telse\n\t    fmt_last->next = fmt_ptr;\n\tfmt_last = fmt_ptr;\n\n\t\/\/ Isolate one part in the 'errorformat' option\n\tlen = efm_option_part_len(efm);\n\n\tif (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL)\n\t    goto parse_efm_error;\n\tif ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL)\n\t    goto parse_efm_error;\n\t\/\/ Advance to next part\n\tefm = skip_to_option_part(efm + len);\t\/\/ skip comma and spaces\n    }\n\n    if (fmt_first == NULL)\t\/\/ nothing found\n\temsg(_(e_errorformat_contains_no_pattern));\n\n    goto parse_efm_end;\n\nparse_efm_error:\n    free_efm_list(&fmt_first);\n\nparse_efm_end:\n    vim_free(fmtstr);\n\n    return fmt_first;\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":259254,"func":"static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    if (c->fc->nb_streams >= 1) {\n        AVStream *const  st = c->fc->streams[c->fc->nb_streams - 1];\n        FFStream *const sti = ffstream(st);\n        AVCodecParameters *par = st->codecpar;\n\n        if (par->codec_tag == MKTAG('A', 'V', 'i', 'n') &&\n            par->codec_id == AV_CODEC_ID_H264 &&\n            atom.size > 11) {\n            int cid;\n            avio_skip(pb, 10);\n            cid = avio_rb16(pb);\n            \/* For AVID AVCI50, force width of 1440 to be able to select the correct SPS and PPS *\/\n            if (cid == 0xd4d || cid == 0xd4e)\n                par->width = 1440;\n            return 0;\n        } else if ((par->codec_tag == MKTAG('A', 'V', 'd', '1') ||\n                    par->codec_tag == MKTAG('A', 'V', 'j', '2') ||\n                    par->codec_tag == MKTAG('A', 'V', 'd', 'n')) &&\n                   atom.size >= 24) {\n            int num, den;\n            avio_skip(pb, 12);\n            num = avio_rb32(pb);\n            den = avio_rb32(pb);\n            if (num <= 0 || den <= 0)\n                return 0;\n            switch (avio_rb32(pb)) {\n            case 2:\n                if (den >= INT_MAX \/ 2)\n                    return 0;\n                den *= 2;\n            case 1:\n                sti->display_aspect_ratio = (AVRational){ num, den };\n            default:\n                return 0;\n            }\n        }\n    }\n\n    return mov_read_avid(c, pb, atom);\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":237824,"func":"static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)\n{\n    data_t *data;\n    uint8_t *b;\n    int row;\n    int16_t temp_raw; \/\/ temperature as read from the data packet\n    float temp_c;     \/\/ temperature in C\n    int battery_ok;   \/\/ the battery status: 1 is good, 0 is low\n    int sensor_id;    \/\/ the sensor ID - basically a random number that gets reset whenever the battery is removed\n\n    row = bitbuffer_find_repeated_row(bitbuffer, 3, 32); \/\/ expected are 6 rows\n    if (row < 0)\n        return DECODE_ABORT_EARLY;\n\n    if (bitbuffer->bits_per_row[row] > 33)\n        return DECODE_ABORT_LENGTH;\n\n    b = bitbuffer->bb[row];\n\n    if (b[4] != 0)\n        return DECODE_FAIL_SANITY;\n\n    \/\/ reject all blank messages\n    if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0)\n        return DECODE_FAIL_SANITY;\n\n    \/\/ calculate the checksum and only continue if we have a matching checksum\n    uint8_t chk = lfsr_digest8(b, 3, 0x98, 0xf1);\n    if (chk != b[3])\n        return DECODE_FAIL_MIC;\n\n    \/\/ Processing the temperature:\n    \/\/ Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2\n    \/\/ upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)\n    sensor_id  = b[0];\n    battery_ok = (b[1] & 0x80) >> 7;\n    temp_raw   = (int16_t)((b[1] << 12) | (b[2] << 4));\n    temp_raw   = temp_raw >> 4;\n    temp_c     = temp_raw * 0.1f;\n\n    \/* clang-format off *\/\n    data = data_make(\n            \"model\",            \"\",             DATA_STRING, \"Acurite-606TX\",\n            \"id\",               \"\",             DATA_INT, sensor_id,\n            \"battery_ok\",       \"Battery\",      DATA_INT,    battery_ok,\n            \"temperature_C\",    \"Temperature\",  DATA_FORMAT, \"%.1f C\", DATA_DOUBLE, temp_c,\n            \"mic\",              \"Integrity\",    DATA_STRING, \"CHECKSUM\",\n            NULL);\n    \/* clang-format on *\/\n\n    decoder_output_data(decoder, data);\n    return 1;\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":384201,"func":"static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,\n\t\t\t    struct nft_data_desc *desc, const struct nlattr *nla)\n{\n\tu8 genmask = nft_genmask_next(ctx->net);\n\tstruct nlattr *tb[NFTA_VERDICT_MAX + 1];\n\tstruct nft_chain *chain;\n\tint err;\n\n\terr = nla_parse_nested_deprecated(tb, NFTA_VERDICT_MAX, nla,\n\t\t\t\t\t  nft_verdict_policy, NULL);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (!tb[NFTA_VERDICT_CODE])\n\t\treturn -EINVAL;\n\tdata->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));\n\n\tswitch (data->verdict.code) {\n\tdefault:\n\t\tswitch (data->verdict.code & NF_VERDICT_MASK) {\n\t\tcase NF_ACCEPT:\n\t\tcase NF_DROP:\n\t\tcase NF_QUEUE:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tfallthrough;\n\tcase NFT_CONTINUE:\n\tcase NFT_BREAK:\n\tcase NFT_RETURN:\n\t\tbreak;\n\tcase NFT_JUMP:\n\tcase NFT_GOTO:\n\t\tif (tb[NFTA_VERDICT_CHAIN]) {\n\t\t\tchain = nft_chain_lookup(ctx->net, ctx->table,\n\t\t\t\t\t\t tb[NFTA_VERDICT_CHAIN],\n\t\t\t\t\t\t genmask);\n\t\t} else if (tb[NFTA_VERDICT_CHAIN_ID]) {\n\t\t\tchain = nft_chain_lookup_byid(ctx->net, ctx->table,\n\t\t\t\t\t\t      tb[NFTA_VERDICT_CHAIN_ID]);\n\t\t\tif (IS_ERR(chain))\n\t\t\t\treturn PTR_ERR(chain);\n\t\t} else {\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (IS_ERR(chain))\n\t\t\treturn PTR_ERR(chain);\n\t\tif (nft_is_base_chain(chain))\n\t\t\treturn -EOPNOTSUPP;\n\t\tif (nft_chain_is_bound(chain))\n\t\t\treturn -EINVAL;\n\t\tif (desc->flags & NFT_DATA_DESC_SETELEM &&\n\t\t    chain->flags & NFT_CHAIN_BINDING)\n\t\t\treturn -EINVAL;\n\n\t\tchain->use++;\n\t\tdata->verdict.chain = chain;\n\t\tbreak;\n\t}\n\n\tdesc->len = sizeof(data->verdict);\n\n\treturn 0;\n}","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":390616,"func":"_XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,\n                       xkbSetDeviceInfoReq *stuff)\n{\n    unsigned                    change;\n    char                       *wire;\n    xkbExtensionDeviceNotify    ed;\n\n    bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));\n    ed.deviceID=\tdev->id;\n    wire= (char *)&stuff[1];\n    if (change&XkbXI_ButtonActionsMask) {\n\tint\t\t\tnBtns,sz,i;\n\tXkbAction *\t\tacts;\n\tDeviceIntPtr\t\tkbd;\n\n\tnBtns= dev->button->numButtons;\n\tacts= dev->button->xkb_acts;\n\tif (acts==NULL) {\n\t    acts= _XkbTypedCalloc(nBtns,XkbAction);\n\t    if (!acts)\n\t\treturn BadAlloc;\n\t    dev->button->xkb_acts= acts;\n\t}\n\tsz= stuff->nBtns*SIZEOF(xkbActionWireDesc);\n\tmemcpy((char *)&acts[stuff->firstBtn],(char *)wire,sz);\n\twire+= sz;\n\ted.reason|=\tXkbXI_ButtonActionsMask;\n\ted.firstBtn=\tstuff->firstBtn;\n\ted.nBtns=\tstuff->nBtns;\n\n\tif (dev->key)\tkbd= dev;\n\telse\t\tkbd= inputInfo.keyboard;\n\tacts= &dev->button->xkb_acts[stuff->firstBtn];\n\tfor (i=0;i<stuff->nBtns;i++,acts++) {\n\t    if (acts->type!=XkbSA_NoAction)\n\t\tXkbSetActionKeyMods(kbd->key->xkbInfo->desc,acts,0);\n\t}\n    }\n    if (stuff->change&XkbXI_IndicatorsMask) {\n\tint status= Success;\n\twire= SetDeviceIndicators(wire,dev,change,stuff->nDeviceLedFBs,\n\t\t\t\t\t\t\t&status,client,&ed);\n\tif (status!=Success)\n\t    return status;\n    }\n    if ((stuff->change)&&(ed.reason))\n\tXkbSendExtensionDeviceNotify(dev,client,&ed);\n    return Success;\n}","target":0,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":463074,"func":"static void sungem_mmio_rxdma_write(void *opaque, hwaddr addr, uint64_t val,\n                                    unsigned size)\n{\n    SunGEMState *s = opaque;\n\n    if (!(addr <= 0x28) && !(addr >= 0x100 && addr <= 0x120)) {\n        qemu_log_mask(LOG_GUEST_ERROR,\n                      \"Write to unknown RXDMA register 0x%\"HWADDR_PRIx\"\\n\",\n                      addr);\n        return;\n    }\n\n    trace_sungem_mmio_rxdma_write(addr, val);\n\n    \/* Pre-write filter *\/\n    switch (addr) {\n    \/* Read only registers *\/\n    case RXDMA_DONE:\n    case RXDMA_PCNT:\n    case RXDMA_SMACHINE:\n    case RXDMA_DPLOW:\n    case RXDMA_DPHI:\n    case RXDMA_FSZ:\n    case RXDMA_FTAG:\n        return; \/* No actual write *\/\n    }\n\n    s->rxdmaregs[addr >> 2] = val;\n\n    \/* Post write action *\/\n    switch (addr) {\n    case RXDMA_KICK:\n        trace_sungem_rx_kick(val);\n        break;\n    case RXDMA_CFG:\n        sungem_update_masks(s);\n        if ((s->macregs[MAC_RXCFG >> 2] & MAC_RXCFG_ENAB) != 0 &&\n            (s->rxdmaregs[RXDMA_CFG >> 2] & RXDMA_CFG_ENABLE) != 0) {\n            qemu_flush_queued_packets(qemu_get_queue(s->nic));\n        }\n        break;\n    }\n}","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":244150,"func":"GF_Err sgpd_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 entry_count;\n\tGF_SampleGroupDescriptionBox *p = (GF_SampleGroupDescriptionBox *)s;\n\n\tISOM_DECREASE_SIZE(p, 8);\n\tp->grouping_type = gf_bs_read_u32(bs);\n\n\tif (p->version>=1) {\n\t\tISOM_DECREASE_SIZE(p, 4);\n\t\tp->default_length = gf_bs_read_u32(bs);\n\t}\n\tif (p->version>=2) {\n\t\tISOM_DECREASE_SIZE(p, 4);\n\t\tp->default_description_index = gf_bs_read_u32(bs);\n\t}\n\tentry_count = gf_bs_read_u32(bs);\n\n\tif (entry_count>p->size)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\twhile (entry_count) {\n\t\tvoid *ptr;\n\t\tu32 parsed_bytes=0;\n\t\tu32 size = p->default_length;\n\t\tif ((p->version>=1) && !size) {\n\t\t\tsize = gf_bs_read_u32(bs);\n\t\t\tISOM_DECREASE_SIZE(p, 4);\n\t\t}\n\t\tptr = sgpd_parse_entry(p->grouping_type, bs, (s32) p->size, size, &parsed_bytes);\n\t\t\/\/don't return an error, just stop parsing so that we skip over the sgpd box\n\t\tif (!ptr) return GF_OK;\n\t\tgf_list_add(p->group_descriptions, ptr);\n\n\t\tISOM_DECREASE_SIZE(p, parsed_bytes);\n\t\tentry_count--;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":402660,"func":"sign_kmod(context *ctx, int infd, int outfd, int attached)\n{\n\tunsigned char *map;\n\tstruct stat statbuf;\n\tssize_t sig_len;\n\tint rc;\n\n\trc = fstat(infd, &statbuf);\n\tif (rc != 0) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not stat input file: %m\");\n\t\treturn rc;\n\t}\n\n\tmap = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, infd, 0);\n\tif (map == MAP_FAILED) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"could not map input file: %m\");\n\t\treturn -1;\n\n\t}\n\n\trc = kmod_generate_digest(ctx->cms, map, statbuf.st_size);\n\tif (rc < 0)\n\t\tgoto out;\n\n\tif (attached) {\n\t\trc = write_file(outfd, map, statbuf.st_size);\n\t\tif (rc) {\n\t\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\t\"could not write module data: %m\");\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tsig_len = kmod_write_signature(ctx->cms, outfd);\n\tif (sig_len < 0) {\n\t\trc = sig_len;\n\t\tgoto out;\n\t}\n\n\trc = kmod_write_sig_info(ctx->cms, outfd, sig_len);\n\nout:\n\tmunmap(map, statbuf.st_size);\n\treturn rc;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":219967,"func":"int callback_glewlwyd_check_admin_session_delegate (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  char * session_uid;\n  json_t * j_user, * j_delegate;\n  int ret;\n  \n  if ((session_uid = get_session_id(config, request)) != NULL) {\n    j_user = get_current_user_for_session(config, session_uid);\n    if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, \"user\"), \"enabled\") == json_true()) {\n      if (is_scope_list_valid_for_session(config, config->admin_scope, session_uid) == G_OK) {\n        j_delegate = get_user(config, u_map_get(request->map_url, \"username\"), NULL);\n        if (check_result_value(j_delegate, G_OK)) {\n          if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_delegate, \"user\")), (void (*)(void *))&json_decref) != U_OK) {\n            ret = U_CALLBACK_ERROR;\n          } else {\n            ret = U_CALLBACK_IGNORE;\n          }\n        } else {\n          ret = U_CALLBACK_UNAUTHORIZED;\n        }\n        json_decref(j_delegate);\n      } else {\n        ret = U_CALLBACK_UNAUTHORIZED;\n      }\n    } else {\n      ret = U_CALLBACK_UNAUTHORIZED;\n    }\n    json_decref(j_user);\n  } else {\n    ret = U_CALLBACK_UNAUTHORIZED;\n  }\n  o_free(session_uid);\n  return ret;\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":500645,"func":"char *sftp_canonicalize_path(sftp_session sftp, const char *path) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  ssh_string name = NULL;\n  ssh_string pathstr;\n  ssh_buffer buffer;\n  char *cname;\n  uint32_t ignored;\n  uint32_t id;\n\n  if (sftp == NULL)\n    return NULL;\n  if (path == NULL) {\n    ssh_set_error_invalid(sftp->session, __FUNCTION__);\n    return NULL;\n  }\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return NULL;\n  }\n\n  pathstr = ssh_string_from_char(path);\n  if (pathstr == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return NULL;\n  }\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, pathstr) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    ssh_string_free(pathstr);\n    return NULL;\n  }\n  if (sftp_packet_write(sftp, SSH_FXP_REALPATH, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(pathstr);\n    return NULL;\n  }\n  ssh_buffer_free(buffer);\n  ssh_string_free(pathstr);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      return NULL;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  if (msg->packet_type == SSH_FXP_NAME) {\n    \/* we don't care about \"count\" *\/\n    buffer_get_u32(msg->payload, &ignored);\n    \/* we only care about the file name string *\/\n    name = buffer_get_ssh_string(msg->payload);\n    sftp_message_free(msg);\n    if (name == NULL) {\n      \/* TODO: error message? *\/\n      return NULL;\n    }\n    cname = ssh_string_to_char(name);\n    ssh_string_free(name);\n    if (cname == NULL) {\n      ssh_set_error_oom(sftp->session);\n    }\n    return cname;\n  } else if (msg->packet_type == SSH_FXP_STATUS) { \/* bad response (error) *\/\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return NULL;\n    }\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n  } else { \/* this shouldn't happen *\/\n    ssh_set_error(sftp->session, SSH_FATAL,\n        \"Received message %d when attempting to set stats\", msg->packet_type);\n    sftp_message_free(msg);\n  }\n\n  return NULL;\n}","target":0,"code_token_length":625,"total_token_length":861,"max_tokens_setting":1024}
+{"idx":282881,"func":"static int rsi_load_bootup_params(struct rsi_common *common)\n{\n\tstruct sk_buff *skb;\n\tstruct rsi_boot_params *boot_params;\n\n\trsi_dbg(MGMT_TX_ZONE, \"%s: Sending boot params frame\\n\", __func__);\n\tskb = dev_alloc_skb(sizeof(struct rsi_boot_params));\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, sizeof(struct rsi_boot_params));\n\tboot_params = (struct rsi_boot_params *)skb->data;\n\n\trsi_dbg(MGMT_TX_ZONE, \"%s:\\n\", __func__);\n\n\tif (common->channel_width == BW_40MHZ) {\n\t\tmemcpy(&boot_params->bootup_params,\n\t\t       &boot_params_40,\n\t\t       sizeof(struct bootup_params));\n\t\trsi_dbg(MGMT_TX_ZONE, \"%s: Packet 40MHZ <=== %d\\n\", __func__,\n\t\t\tUMAC_CLK_40BW);\n\t\tboot_params->desc_word[7] = cpu_to_le16(UMAC_CLK_40BW);\n\t} else {\n\t\tmemcpy(&boot_params->bootup_params,\n\t\t       &boot_params_20,\n\t\t       sizeof(struct bootup_params));\n\t\tif (boot_params_20.valid != cpu_to_le32(VALID_20)) {\n\t\t\tboot_params->desc_word[7] = cpu_to_le16(UMAC_CLK_20BW);\n\t\t\trsi_dbg(MGMT_TX_ZONE,\n\t\t\t\t\"%s: Packet 20MHZ <=== %d\\n\", __func__,\n\t\t\t\tUMAC_CLK_20BW);\n\t\t} else {\n\t\t\tboot_params->desc_word[7] = cpu_to_le16(UMAC_CLK_40MHZ);\n\t\t\trsi_dbg(MGMT_TX_ZONE,\n\t\t\t\t\"%s: Packet 20MHZ <=== %d\\n\", __func__,\n\t\t\t\tUMAC_CLK_40MHZ);\n\t\t}\n\t}\n\n\t\/**\n\t * Bit{0:11} indicates length of the Packet\n\t * Bit{12:15} indicates host queue number\n\t *\/\n\tboot_params->desc_word[0] = cpu_to_le16(sizeof(struct bootup_params) |\n\t\t\t\t    (RSI_WIFI_MGMT_Q << 12));\n\tboot_params->desc_word[1] = cpu_to_le16(BOOTUP_PARAMS_REQUEST);\n\n\tskb_put(skb, sizeof(struct rsi_boot_params));\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":488366,"func":"struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,\n\t\t\t\tpte_t pte)\n{\n\tunsigned long pfn;\n\n\tif (HAVE_PTE_SPECIAL) {\n\t\tif (likely(!pte_special(pte))) {\n\t\t\tVM_BUG_ON(!pfn_valid(pte_pfn(pte)));\n\t\t\treturn pte_page(pte);\n\t\t}\n\t\tVM_BUG_ON(!(vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)));\n\t\treturn NULL;\n\t}\n\n\t\/* !HAVE_PTE_SPECIAL case follows: *\/\n\n\tpfn = pte_pfn(pte);\n\n\tif (unlikely(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))) {\n\t\tif (vma->vm_flags & VM_MIXEDMAP) {\n\t\t\tif (!pfn_valid(pfn))\n\t\t\t\treturn NULL;\n\t\t\tgoto out;\n\t\t} else {\n\t\t\tunsigned long off;\n\t\t\toff = (addr - vma->vm_start) >> PAGE_SHIFT;\n\t\t\tif (pfn == vma->vm_pgoff + off)\n\t\t\t\treturn NULL;\n\t\t\tif (!is_cow_mapping(vma->vm_flags))\n\t\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tVM_BUG_ON(!pfn_valid(pfn));\n\n\t\/*\n\t * NOTE! We still have PageReserved() pages in the page tables.\n\t *\n\t * eg. VDSO mappings can cause them to exist.\n\t *\/\nout:\n\treturn pfn_to_page(pfn);\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":345201,"func":"int con_set_default_unimap(struct vc_data *vc)\n{\n\tint i, j, err = 0, err1;\n\tu16 *q;\n\tstruct uni_pagedir *p;\n\n\tif (dflt) {\n\t\tp = *vc->vc_uni_pagedir_loc;\n\t\tif (p == dflt)\n\t\t\treturn 0;\n\n\t\tdflt->refcount++;\n\t\t*vc->vc_uni_pagedir_loc = dflt;\n\t\tif (p && !--p->refcount) {\n\t\t\tcon_release_unimap(p);\n\t\t\tkfree(p);\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t\/* The default font is always 256 characters *\/\n\n\terr = con_do_clear_unimap(vc);\n\tif (err)\n\t\treturn err;\n    \n\tp = *vc->vc_uni_pagedir_loc;\n\tq = dfont_unitable;\n\t\n\tfor (i = 0; i < 256; i++)\n\t\tfor (j = dfont_unicount[i]; j; j--) {\n\t\t\terr1 = con_insert_unipair(p, *(q++), i);\n\t\t\tif (err1)\n\t\t\t\terr = err1;\n\t\t}\n\t\t\t\n\tif (con_unify_unimap(vc, p)) {\n\t\tdflt = *vc->vc_uni_pagedir_loc;\n\t\treturn err;\n\t}\n\n\tfor (i = 0; i <= 3; i++)\n\t\tset_inverse_transl(vc, p, i);\t\/* Update all inverse translations *\/\n\tset_inverse_trans_unicode(vc, p);\n\tdflt = p;\n\treturn err;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":489158,"func":"struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,\n\t\t\t    const struct sctp_association *asoc,\n\t\t\t    struct sock *sk)\n{\n\tstruct sctp_chunk *retval;\n\n\tretval = kmem_cache_zalloc(sctp_chunk_cachep, GFP_ATOMIC);\n\n\tif (!retval)\n\t\tgoto nodata;\n\n\tif (!sk) {\n\t\tSCTP_DEBUG_PRINTK(\"chunkifying skb %p w\/o an sk\\n\", skb);\n\t}\n\n\tINIT_LIST_HEAD(&retval->list);\n\tretval->skb\t\t= skb;\n\tretval->asoc\t\t= (struct sctp_association *)asoc;\n\tretval->resent  \t= 0;\n\tretval->has_tsn\t\t= 0;\n\tretval->has_ssn         = 0;\n\tretval->rtt_in_progress\t= 0;\n\tretval->sent_at\t\t= 0;\n\tretval->singleton\t= 1;\n\tretval->end_of_packet\t= 0;\n\tretval->ecn_ce_done\t= 0;\n\tretval->pdiscard\t= 0;\n\n\t\/* sctpimpguide-05.txt Section 2.8.2\n\t * M1) Each time a new DATA chunk is transmitted\n\t * set the 'TSN.Missing.Report' count for that TSN to 0. The\n\t * 'TSN.Missing.Report' count will be used to determine missing chunks\n\t * and when to fast retransmit.\n\t *\/\n\tretval->tsn_missing_report = 0;\n\tretval->tsn_gap_acked = 0;\n\tretval->fast_retransmit = 0;\n\n\t\/* If this is a fragmented message, track all fragments\n\t * of the message (for SEND_FAILED).\n\t *\/\n\tretval->msg = NULL;\n\n\t\/* Polish the bead hole.  *\/\n\tINIT_LIST_HEAD(&retval->transmitted_list);\n\tINIT_LIST_HEAD(&retval->frag_list);\n\tSCTP_DBG_OBJCNT_INC(chunk);\n\tatomic_set(&retval->refcnt, 1);\n\nnodata:\n\treturn retval;\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":219044,"func":"Status ConstantFolding::SimplifyNode(NodeDef* node, GraphDef* optimized_graph,\n                                     GraphProperties* properties) {\n  bool graph_modified_cached = graph_modified_;\n  graph_modified_ = false;\n\n  bool use_shape_info = properties->has_properties();\n  RETURN_IF_MODIFIED(RemoveSplitOrSplitV(*properties, optimized_graph, node));\n  RETURN_IF_ERROR_OR_MODIFIED(RemoveShuffleOrTranspose(\n      *properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_MODIFIED(\n      RemoveRandomShuffle(*properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_ERROR_OR_MODIFIED(\n      RemoveReverse(*properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_ERROR_OR_MODIFIED(\n      SimplifySlice(*properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_ERROR_OR_MODIFIED(\n      SimplifyStridedSlice(*properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_ERROR_OR_MODIFIED(\n      SimplifyTile(*properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_ERROR_OR_MODIFIED(\n      SimplifyPad(*properties, use_shape_info, optimized_graph, node));\n  RETURN_IF_MODIFIED(\n      SimplifySqueeze(*properties, use_shape_info, optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(SimplifyPack(optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(MoveConstantsPastEnter(optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(SimplifySwitch(optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      SimplifyReduction(optimized_graph, *properties, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      SimplifyReshape(*properties, use_shape_info, node));\n  RETURN_IF_ERROR_OR_MODIFIED(SimplifyArithmeticOperations(\n      *properties, use_shape_info, optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(ReduceDivToReciprocalMul(optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      ConstantPushDown(properties, optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      MulConvPushDown(optimized_graph, node, *properties));\n  SET_AND_RETURN_IF_MODIFIED(PartialConstPropThroughIdentityN(node));\n  SET_AND_RETURN_IF_MODIFIED(\n      PartialAssocOpConstFolding(optimized_graph, properties, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      MergeConcat(use_shape_info, properties, optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      PartialConcatConstFolding(optimized_graph, properties, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      ConstantPushDownBiasAdd(properties, optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(SimplifyCase(optimized_graph, node));\n  SET_AND_RETURN_IF_MODIFIED(\n      SimplifySelect(*properties, optimized_graph, node));\n  RETURN_IF_MODIFIED(\n      RemoveRedundantVariableUpdates(properties, optimized_graph, node));\n\n  graph_modified_ = graph_modified_cached;\n  return Status::OK();\n}","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":270110,"func":"TfLiteStatus CalculateShapeForBroadcast(TfLiteContext* context,\n                                        const TfLiteTensor* input1,\n                                        const TfLiteTensor* input2,\n                                        TfLiteIntArray** output_shape) {\n  const int dims1 = NumDimensions(input1);\n  const int dims2 = NumDimensions(input2);\n  const int out_dims = std::max(dims1, dims2);\n\n  std::unique_ptr<TfLiteIntArray, void (*)(TfLiteIntArray*)> shape(\n      TfLiteIntArrayCreate(out_dims), TfLiteIntArrayFree);\n  for (int i = 0; i < out_dims; ++i) {\n    const int d1 = i >= dims1 ? 1 : SizeOfDimension(input1, dims1 - i - 1);\n    const int d2 = i >= dims2 ? 1 : SizeOfDimension(input2, dims2 - i - 1);\n    if (!(d1 == d2 || d1 == 1 || d2 == 1)) {\n      context->ReportError(context,\n                           \"Given shapes, %s and %s, are not broadcastable.\",\n                           GetShapeDebugString(input1->dims).c_str(),\n                           GetShapeDebugString(input2->dims).c_str());\n      return kTfLiteError;\n    }\n\n    if (d1 == 0 || d2 == 0) {\n      shape->data[out_dims - i - 1] = 0;\n    } else {\n      shape->data[out_dims - i - 1] = std::max(d1, d2);\n    }\n  }\n  *output_shape = shape.release();\n  return kTfLiteOk;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":238390,"func":"njs_function_native_frame(njs_vm_t *vm, njs_function_t *function,\n    const njs_value_t *this, const njs_value_t *args, njs_uint_t nargs,\n    njs_bool_t ctor)\n{\n    size_t              size;\n    njs_uint_t          n;\n    njs_value_t         *value, *bound;\n    njs_native_frame_t  *frame;\n\n    size = NJS_NATIVE_FRAME_SIZE\n           + (function->args_offset + nargs) * sizeof(njs_value_t);\n\n    frame = njs_function_frame_alloc(vm, size);\n    if (njs_slow_path(frame == NULL)) {\n        return NJS_ERROR;\n    }\n\n    frame->function = function;\n    frame->nargs = function->args_offset + nargs;\n    frame->ctor = ctor;\n    frame->native = 1;\n    frame->pc = NULL;\n\n    value = (njs_value_t *) ((u_char *) frame + NJS_NATIVE_FRAME_SIZE);\n\n    frame->arguments = value;\n    frame->arguments_offset = value + function->args_offset;\n\n    bound = function->bound;\n\n    if (bound == NULL) {\n        \/* GC: njs_retain(this); *\/\n        *value++ = *this;\n\n    } else {\n        n = function->args_offset;\n\n        do {\n            \/* GC: njs_retain(bound); *\/\n            *value++ = *bound++;\n            n--;\n        } while (n != 0);\n    }\n\n    if (args != NULL) {\n        memcpy(value, args, nargs * sizeof(njs_value_t));\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":217556,"func":"MagickExport MagickBooleanType CloneImageProperties(Image *image,\n  const Image *clone_image)\n{\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  assert(clone_image != (const Image *) NULL);\n  assert(clone_image->signature == MagickCoreSignature);\n  if (clone_image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      clone_image->filename);\n  (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);\n  (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,\n    MaxTextExtent);\n  image->compression=clone_image->compression;\n  image->quality=clone_image->quality;\n  image->depth=clone_image->depth;\n  image->background_color=clone_image->background_color;\n  image->border_color=clone_image->border_color;\n  image->matte_color=clone_image->matte_color;\n  image->transparent_color=clone_image->transparent_color;\n  image->gamma=clone_image->gamma;\n  image->chromaticity=clone_image->chromaticity;\n  image->rendering_intent=clone_image->rendering_intent;\n  image->black_point_compensation=clone_image->black_point_compensation;\n  image->units=clone_image->units;\n  image->montage=(char *) NULL;\n  image->directory=(char *) NULL;\n  (void) CloneString(&image->geometry,clone_image->geometry);\n  image->offset=clone_image->offset;\n  image->x_resolution=clone_image->x_resolution;\n  image->y_resolution=clone_image->y_resolution;\n  image->page=clone_image->page;\n  image->tile_offset=clone_image->tile_offset;\n  image->extract_info=clone_image->extract_info;\n  image->bias=clone_image->bias;\n  image->filter=clone_image->filter;\n  image->blur=clone_image->blur;\n  image->fuzz=clone_image->fuzz;\n  image->intensity=clone_image->intensity;\n  image->interlace=clone_image->interlace;\n  image->interpolate=clone_image->interpolate;\n  image->endian=clone_image->endian;\n  image->gravity=clone_image->gravity;\n  image->compose=clone_image->compose;\n  image->orientation=clone_image->orientation;\n  image->scene=clone_image->scene;\n  image->dispose=clone_image->dispose;\n  image->delay=clone_image->delay;\n  image->ticks_per_second=clone_image->ticks_per_second;\n  image->iterations=clone_image->iterations;\n  image->total_colors=clone_image->total_colors;\n  image->taint=clone_image->taint;\n  image->progress_monitor=clone_image->progress_monitor;\n  image->client_data=clone_image->client_data;\n  image->start_loop=clone_image->start_loop;\n  image->error=clone_image->error;\n  image->signature=clone_image->signature;\n  if (clone_image->properties != (void *) NULL)\n    {\n      if (image->properties != (void *) NULL)\n        DestroyImageProperties(image);\n      image->properties=CloneSplayTree((SplayTreeInfo *)\n        clone_image->properties,(void *(*)(void *)) ConstantString,\n        (void *(*)(void *)) ConstantString);\n    }\n  return(MagickTrue);\n}","target":0,"code_token_length":763,"total_token_length":999,"max_tokens_setting":1024}
+{"idx":286731,"func":"SWTPM_NVRAM_StoreData_Intern(const unsigned char *data,\n                             uint32_t length,\n                             uint32_t tpm_number,\n                             const char *name,\n                             TPM_BOOL encrypt         \/* encrypt if key is set *\/)\n{\n    TPM_RESULT    rc = 0;\n    unsigned char *filedata = NULL;\n    uint32_t      filedata_length = 0;\n    tlv_data      td[3];\n    size_t        td_len = 0;\n    uint16_t      flags = 0;\n    const char    *backend_uri = NULL;\n\n    TPM_DEBUG(\" SWTPM_NVRAM_StoreData: To name %s\\n\", name);\n\n    if (rc == 0) {\n        if (encrypt && SWTPM_NVRAM_Has_FileKey()) {\n            td_len = 3;\n            rc = SWTPM_NVRAM_EncryptData(&filekey, &td[0], &td_len,\n                                         TAG_ENCRYPTED_DATA, data, length,\n                                         TAG_IVEC_ENCRYPTED_DATA);\n            if (rc) {\n                logprintf(STDERR_FILENO,\n                          \"SWTPM_NVRAM_EncryptData failed: 0x%02x\\n\", rc);\n            } else {\n                TPM_DEBUG(\"  SWTPM_NVRAM_StoreData: Encrypted %u bytes before \"\n                          \"write, will write %u bytes\\n\", length,\n                          td[0].tlv.length);\n            }\n            flags |= BLOB_FLAG_ENCRYPTED;\n            if (SWTPM_NVRAM_FileKey_Size() == SWTPM_AES256_BLOCK_SIZE)\n                flags |= BLOB_FLAG_ENCRYPTED_256BIT_KEY;\n        } else {\n            td_len = 1;\n            td[0] = TLV_DATA_CONST(TAG_DATA, length, data);\n        }\n    }\n\n    if (rc == 0)\n        rc = tlv_data_append(&filedata, &filedata_length, td, td_len);\n\n    if (rc == 0)\n        rc = SWTPM_NVRAM_PrependHeader(&filedata, &filedata_length, flags);\n\n    if (rc == 0) {\n        backend_uri = tpmstate_get_backend_uri();\n        rc = g_nvram_backend_ops->store(filedata, filedata_length, tpm_number, name,\n                                        backend_uri);\n    }\n\n    tlv_data_free(td, td_len);\n    free(filedata);\n\n    TPM_DEBUG(\" SWTPM_NVRAM_StoreData: rc=%d\\n\", rc);\n\n    return rc;\n}","target":0,"code_token_length":540,"total_token_length":776,"max_tokens_setting":1024}
+{"idx":310315,"func":"add_fingerprint_to_dir(const char *nickname, const char *fp,\n                       authdir_config_t *list)\n{\n  char *fingerprint;\n  char d[DIGEST_LEN];\n  router_status_t *status;\n  tor_assert(nickname);\n  tor_assert(fp);\n  tor_assert(list);\n\n  fingerprint = tor_strdup(fp);\n  tor_strstrip(fingerprint, \" \");\n  if (base16_decode(d, DIGEST_LEN, fingerprint, strlen(fingerprint))) {\n    log_warn(LD_DIRSERV, \"Couldn't decode fingerprint \\\"%s\\\"\",\n             escaped(fp));\n    tor_free(fingerprint);\n    return 0;\n  }\n\n  if (!strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME)) {\n    log_warn(LD_DIRSERV, \"Tried to add a mapping for reserved nickname %s\",\n             UNNAMED_ROUTER_NICKNAME);\n    tor_free(fingerprint);\n    return 0;\n  }\n\n  status = digestmap_get(list->status_by_digest, d);\n  if (!status) {\n    status = tor_malloc_zero(sizeof(router_status_t));\n    digestmap_set(list->status_by_digest, d, status);\n  }\n\n  if (nickname[0] != '!') {\n    char *old_fp = strmap_get_lc(list->fp_by_name, nickname);\n    if (old_fp && !strcasecmp(fingerprint, old_fp)) {\n      tor_free(fingerprint);\n    } else {\n      tor_free(old_fp);\n      strmap_set_lc(list->fp_by_name, nickname, fingerprint);\n    }\n    status->status |= FP_NAMED;\n    strlcpy(status->nickname, nickname, sizeof(status->nickname));\n  } else {\n    tor_free(fingerprint);\n    if (!strcasecmp(nickname, \"!reject\")) {\n      status->status |= FP_REJECT;\n    } else if (!strcasecmp(nickname, \"!invalid\")) {\n      status->status |= FP_INVALID;\n    } else if (!strcasecmp(nickname, \"!baddir\")) {\n      status->status |= FP_BADDIR;\n    } else if (!strcasecmp(nickname, \"!badexit\")) {\n      status->status |= FP_BADEXIT;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":390555,"func":"XkbComputeGetGeometryReplySize(\tXkbGeometryPtr\t\tgeom,\n\t\t\t\txkbGetGeometryReply *\trep,\n\t\t\t\tAtom\t\t\tname)\n{\nint\tlen;\n\n    if (geom!=NULL) {\n\tlen= XkbSizeCountedString(geom->label_font);\n\tlen+= XkbSizeGeomProperties(geom);\n\tlen+= XkbSizeGeomColors(geom);\n\tlen+= XkbSizeGeomShapes(geom);\n\tlen+= XkbSizeGeomSections(geom);\n\tlen+= XkbSizeGeomDoodads(geom->num_doodads,geom->doodads);\n\tlen+= XkbSizeGeomKeyAliases(geom);\n\trep->length= len\/4;\n\trep->found= True;\n\trep->name= geom->name;\n\trep->widthMM= geom->width_mm;\n\trep->heightMM= geom->height_mm;\n\trep->nProperties= geom->num_properties;\n\trep->nColors= geom->num_colors;\n\trep->nShapes= geom->num_shapes;\n\trep->nSections= geom->num_sections;\n\trep->nDoodads= geom->num_doodads;\n\trep->nKeyAliases= geom->num_key_aliases;\n\trep->baseColorNdx= XkbGeomColorIndex(geom,geom->base_color);\n\trep->labelColorNdx= XkbGeomColorIndex(geom,geom->label_color);\n    }\n    else {\n\trep->length= 0;\n\trep->found= False;\n\trep->name= name;\n\trep->widthMM= rep->heightMM= 0;\n\trep->nProperties= rep->nColors= rep->nShapes= 0;\n\trep->nSections= rep->nDoodads= 0;\n\trep->nKeyAliases= 0;\n\trep->labelColorNdx= rep->baseColorNdx= 0;\n    }\n    return Success;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":389705,"func":"clear_tv(typval_T *varp)\n{\n    if (varp != NULL)\n    {\n\tswitch (varp->v_type)\n\t{\n\t    case VAR_FUNC:\n\t\tfunc_unref(varp->vval.v_string);\n\t\t\/\/ FALLTHROUGH\n\t    case VAR_STRING:\n\t\tVIM_CLEAR(varp->vval.v_string);\n\t\tbreak;\n\t    case VAR_PARTIAL:\n\t\tpartial_unref(varp->vval.v_partial);\n\t\tvarp->vval.v_partial = NULL;\n\t\tbreak;\n\t    case VAR_BLOB:\n\t\tblob_unref(varp->vval.v_blob);\n\t\tvarp->vval.v_blob = NULL;\n\t\tbreak;\n\t    case VAR_LIST:\n\t\tlist_unref(varp->vval.v_list);\n\t\tvarp->vval.v_list = NULL;\n\t\tbreak;\n\t    case VAR_DICT:\n\t\tdict_unref(varp->vval.v_dict);\n\t\tvarp->vval.v_dict = NULL;\n\t\tbreak;\n\t    case VAR_NUMBER:\n\t    case VAR_BOOL:\n\t    case VAR_SPECIAL:\n\t\tvarp->vval.v_number = 0;\n\t\tbreak;\n\t    case VAR_FLOAT:\n#ifdef FEAT_FLOAT\n\t\tvarp->vval.v_float = 0.0;\n\t\tbreak;\n#endif\n\t    case VAR_JOB:\n#ifdef FEAT_JOB_CHANNEL\n\t\tjob_unref(varp->vval.v_job);\n\t\tvarp->vval.v_job = NULL;\n#endif\n\t\tbreak;\n\t    case VAR_CHANNEL:\n#ifdef FEAT_JOB_CHANNEL\n\t\tchannel_unref(varp->vval.v_channel);\n\t\tvarp->vval.v_channel = NULL;\n#endif\n\t\tbreak;\n\t    case VAR_INSTR:\n\t\tVIM_CLEAR(varp->vval.v_instr);\n\t\tbreak;\n\t    case VAR_UNKNOWN:\n\t    case VAR_ANY:\n\t    case VAR_VOID:\n\t\tbreak;\n\t}\n\tvarp->v_lock = 0;\n    }\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":217459,"func":"Result ZipFile::uncompressEntry (int index, const File& targetDirectory, bool shouldOverwriteFiles)\r\n{\r\n    auto* zei = entries.getUnchecked (index);\r\n\r\n   #if JUCE_WINDOWS\r\n    auto entryPath = zei->entry.filename;\r\n   #else\r\n    auto entryPath = zei->entry.filename.replaceCharacter ('\\\\', '\/');\r\n   #endif\r\n\r\n    if (entryPath.isEmpty())\r\n        return Result::ok();\r\n\r\n    auto targetFile = targetDirectory.getChildFile (entryPath);\r\n\r\n    if (entryPath.endsWithChar ('\/') || entryPath.endsWithChar ('\\\\'))\r\n        return targetFile.createDirectory(); \/\/ (entry is a directory, not a file)\r\n\r\n    std::unique_ptr<InputStream> in (createStreamForEntry (index));\r\n\r\n    if (in == nullptr)\r\n        return Result::fail (\"Failed to open the zip file for reading\");\r\n\r\n    if (targetFile.exists())\r\n    {\r\n        if (! shouldOverwriteFiles)\r\n            return Result::ok();\r\n\r\n        if (! targetFile.deleteFile())\r\n            return Result::fail (\"Failed to write to target file: \" + targetFile.getFullPathName());\r\n    }\r\n\r\n    if (! targetFile.getParentDirectory().createDirectory())\r\n        return Result::fail (\"Failed to create target folder: \" + targetFile.getParentDirectory().getFullPathName());\r\n\r\n    if (zei->entry.isSymbolicLink)\r\n    {\r\n        String originalFilePath (in->readEntireStreamAsString()\r\n                                    .replaceCharacter (L'\/', File::getSeparatorChar()));\r\n\r\n        if (! File::createSymbolicLink (targetFile, originalFilePath, true))\r\n            return Result::fail (\"Failed to create symbolic link: \" + originalFilePath);\r\n    }\r\n    else\r\n    {\r\n        FileOutputStream out (targetFile);\r\n\r\n        if (out.failedToOpen())\r\n            return Result::fail (\"Failed to write to target file: \" + targetFile.getFullPathName());\r\n\r\n        out << *in;\r\n    }\r\n\r\n    targetFile.setCreationTime (zei->entry.fileTime);\r\n    targetFile.setLastModificationTime (zei->entry.fileTime);\r\n    targetFile.setLastAccessTime (zei->entry.fileTime);\r\n\r\n    return Result::ok();\r\n}\r","target":1,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":512796,"func":"bool Item_func_like::turboBM_matches(const char* text, int text_len) const\n{\n  int bcShift;\n  int turboShift;\n  int shift = pattern_len;\n  int j     = 0;\n  int u     = 0;\n  CHARSET_INFO\t*cs= cmp_collation.collation;\n\n  const int plm1=  pattern_len - 1;\n  const int tlmpl= text_len - pattern_len;\n\n  \/* Searching *\/\n  if (!cs->sort_order)\n  {\n    while (j <= tlmpl)\n    {\n      int i= plm1;\n      while (i >= 0 && pattern[i] == text[i + j])\n      {\n\ti--;\n\tif (i == plm1 - shift)\n\t  i-= u;\n      }\n      if (i < 0)\n\treturn 1;\n\n      const int v= plm1 - i;\n      turboShift = u - v;\n      bcShift    = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;\n      shift      = MY_MAX(turboShift, bcShift);\n      shift      = MY_MAX(shift, bmGs[i]);\n      if (shift == bmGs[i])\n\tu = MY_MIN(pattern_len - shift, v);\n      else\n      {\n\tif (turboShift < bcShift)\n\t  shift = MY_MAX(shift, u + 1);\n\tu = 0;\n      }\n      j+= shift;\n    }\n    return 0;\n  }\n  else\n  {\n    while (j <= tlmpl)\n    {\n      int i= plm1;\n      while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))\n      {\n\ti--;\n\tif (i == plm1 - shift)\n\t  i-= u;\n      }\n      if (i < 0)\n\treturn 1;\n\n      const int v= plm1 - i;\n      turboShift = u - v;\n      bcShift    = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;\n      shift      = MY_MAX(turboShift, bcShift);\n      shift      = MY_MAX(shift, bmGs[i]);\n      if (shift == bmGs[i])\n\tu = MY_MIN(pattern_len - shift, v);\n      else\n      {\n\tif (turboShift < bcShift)\n\t  shift = MY_MAX(shift, u + 1);\n\tu = 0;\n      }\n      j+= shift;\n    }\n    return 0;\n  }\n}","target":0,"code_token_length":536,"total_token_length":772,"max_tokens_setting":1024}
+{"idx":508804,"func":"void st_select_lex::init_query()\n{\n  st_select_lex_node::init_query();\n  table_list.empty();\n  top_join_list.empty();\n  join_list= &top_join_list;\n  embedding= 0;\n  leaf_tables_prep.empty();\n  leaf_tables.empty();\n  item_list.empty();\n  min_max_opt_list.empty();\n  join= 0;\n  having= prep_having= where= prep_where= 0;\n  cond_pushed_into_where= cond_pushed_into_having= 0;\n  olap= UNSPECIFIED_OLAP_TYPE;\n  having_fix_field= 0;\n  having_fix_field_for_pushed_cond= 0;\n  context.select_lex= this;\n  context.init();\n  \/*\n    Add the name resolution context of the current (sub)query to the\n    stack of contexts for the whole query.\n    TODO:\n    push_context may return an error if there is no memory for a new\n    element in the stack, however this method has no return value,\n    thus push_context should be moved to a place where query\n    initialization is checked for failure.\n  *\/\n  parent_lex->push_context(&context, parent_lex->thd->mem_root);\n  cond_count= between_count= with_wild= 0;\n  max_equal_elems= 0;\n  ref_pointer_array.reset();\n  select_n_where_fields= 0;\n  select_n_reserved= 0;\n  select_n_having_items= 0;\n  n_sum_items= 0;\n  n_child_sum_items= 0;\n  hidden_bit_fields= 0;\n  fields_in_window_functions= 0;\n  subquery_in_having= explicit_limit= 0;\n  is_item_list_lookup= 0;\n  changed_elements= 0;\n  first_natural_join_processing= 1;\n  first_cond_optimization= 1;\n  parsing_place= NO_MATTER;\n  exclude_from_table_unique_test= no_wrap_view_item= FALSE;\n  nest_level= 0;\n  link_next= 0;\n  prep_leaf_list_state= UNINIT;\n  have_merged_subqueries= FALSE;\n  bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used));\n  select_list_tables= 0;\n  m_non_agg_field_used= false;\n  m_agg_func_used= false;\n  window_specs.empty();\n  window_funcs.empty();\n}","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":241047,"func":"static int read_authkey()\n{\n\tint fd;\n\n\tbooth_conf->authkey[0] = '\\0';\n\tfd = open(booth_conf->authfile, O_RDONLY);\n\tif (fd < 0) {\n\t\tlog_error(\"cannot open %s: %s\",\n\t\t\tbooth_conf->authfile, strerror(errno));\n\t\treturn -1;\n\t}\n\tif (fstat(fd, &booth_conf->authstat) < 0) {\n\t\tlog_error(\"cannot stat authentication file %s (%d): %s\",\n\t\t\tbooth_conf->authfile, fd, strerror(errno));\n\t\tclose(fd);\n\t\treturn -1;\n\t}\n\tif (booth_conf->authstat.st_mode & (S_IRGRP | S_IROTH)) {\n\t\tlog_error(\"%s: file shall not be readable for anyone but the owner\",\n\t\t\tbooth_conf->authfile);\n\t\tclose(fd);\n\t\treturn -1;\n\t}\n\tbooth_conf->authkey_len = read(fd, booth_conf->authkey, BOOTH_MAX_KEY_LEN);\n\tclose(fd);\n\ttrim_key();\n\tlog_debug(\"read key of size %d in authfile %s\",\n\t\tbooth_conf->authkey_len, booth_conf->authfile);\n\t\/* make sure that the key is of minimum length *\/\n\treturn (booth_conf->authkey_len >= BOOTH_MIN_KEY_LEN) ? 0 : -1;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":198692,"func":"int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,\n\t\t struct xfrm_migrate *m, int num_migrate,\n\t\t struct xfrm_kmaddress *k, struct net *net,\n\t\t struct xfrm_encap_tmpl *encap)\n{\n\tint i, err, nx_cur = 0, nx_new = 0;\n\tstruct xfrm_policy *pol = NULL;\n\tstruct xfrm_state *x, *xc;\n\tstruct xfrm_state *x_cur[XFRM_MAX_DEPTH];\n\tstruct xfrm_state *x_new[XFRM_MAX_DEPTH];\n\tstruct xfrm_migrate *mp;\n\n\tif ((err = xfrm_migrate_check(m, num_migrate)) < 0)\n\t\tgoto out;\n\n\t\/* Stage 1 - find policy *\/\n\tif ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) {\n\t\terr = -ENOENT;\n\t\tgoto out;\n\t}\n\n\t\/* Stage 2 - find and update state(s) *\/\n\tfor (i = 0, mp = m; i < num_migrate; i++, mp++) {\n\t\tif ((x = xfrm_migrate_state_find(mp, net))) {\n\t\t\tx_cur[nx_cur] = x;\n\t\t\tnx_cur++;\n\t\t\txc = xfrm_state_migrate(x, mp, encap);\n\t\t\tif (xc) {\n\t\t\t\tx_new[nx_new] = xc;\n\t\t\t\tnx_new++;\n\t\t\t} else {\n\t\t\t\terr = -ENODATA;\n\t\t\t\tgoto restore_state;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Stage 3 - update policy *\/\n\tif ((err = xfrm_policy_migrate(pol, m, num_migrate)) < 0)\n\t\tgoto restore_state;\n\n\t\/* Stage 4 - delete old state(s) *\/\n\tif (nx_cur) {\n\t\txfrm_states_put(x_cur, nx_cur);\n\t\txfrm_states_delete(x_cur, nx_cur);\n\t}\n\n\t\/* Stage 5 - announce *\/\n\tkm_migrate(sel, dir, type, m, num_migrate, k, encap);\n\n\txfrm_pol_put(pol);\n\n\treturn 0;\nout:\n\treturn err;\n\nrestore_state:\n\tif (pol)\n\t\txfrm_pol_put(pol);\n\tif (nx_cur)\n\t\txfrm_states_put(x_cur, nx_cur);\n\tif (nx_new)\n\t\txfrm_states_delete(x_new, nx_new);\n\n\treturn err;\n}","target":1,"code_token_length":499,"total_token_length":735,"max_tokens_setting":1024}
+{"idx":247756,"func":"Integer RWFunction::ApplyFunction(const Integer &in) const\n{\n\tDoQuickSanityCheck();\n\n\tInteger out = in.Squared()%m_n;\n\tconst word r = 12;\n\t\/\/ this code was written to handle both r = 6 and r = 12,\n\t\/\/ but now only r = 12 is used in P1363\n\tconst word r2 = r\/2;\n\tconst word r3a = (16 + 5 - r) % 16;\t\/\/ n%16 could be 5 or 13\n\tconst word r3b = (16 + 13 - r) % 16;\n\tconst word r4 = (8 + 5 - r\/2) % 8;\t\/\/ n%8 == 5\n\tswitch (out % 16)\n\t{\n\tcase r:\n\t\tbreak;\n\tcase r2:\n\tcase r2+8:\n\t\tout <<= 1;\n\t\tbreak;\n\tcase r3a:\n\tcase r3b:\n\t\tout.Negate();\n\t\tout += m_n;\n\t\tbreak;\n\tcase r4:\n\tcase r4+8:\n\t\tout.Negate();\n\t\tout += m_n;\n\t\tout <<= 1;\n\t\tbreak;\n\tdefault:\n\t\tout = Integer::Zero();\n\t}\n\treturn out;\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":369245,"func":"\nstatic int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,\n\t\t\t\t  struct io_mapped_ubuf **pimu,\n\t\t\t\t  struct page **last_hpage)\n{\n\tstruct io_mapped_ubuf *imu = NULL;\n\tstruct vm_area_struct **vmas = NULL;\n\tstruct page **pages = NULL;\n\tunsigned long off, start, end, ubuf;\n\tsize_t size;\n\tint ret, pret, nr_pages, i;\n\n\tif (!iov->iov_base) {\n\t\t*pimu = ctx->dummy_ubuf;\n\t\treturn 0;\n\t}\n\n\tubuf = (unsigned long) iov->iov_base;\n\tend = (ubuf + iov->iov_len + PAGE_SIZE - 1) >> PAGE_SHIFT;\n\tstart = ubuf >> PAGE_SHIFT;\n\tnr_pages = end - start;\n\n\t*pimu = NULL;\n\tret = -ENOMEM;\n\n\tpages = kvmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);\n\tif (!pages)\n\t\tgoto done;\n\n\tvmas = kvmalloc_array(nr_pages, sizeof(struct vm_area_struct *),\n\t\t\t      GFP_KERNEL);\n\tif (!vmas)\n\t\tgoto done;\n\n\timu = kvmalloc(struct_size(imu, bvec, nr_pages), GFP_KERNEL);\n\tif (!imu)\n\t\tgoto done;\n\n\tret = 0;\n\tmmap_read_lock(current->mm);\n\tpret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM,\n\t\t\t      pages, vmas);\n\tif (pret == nr_pages) {\n\t\t\/* don't support file backed memory *\/\n\t\tfor (i = 0; i < nr_pages; i++) {\n\t\t\tstruct vm_area_struct *vma = vmas[i];\n\n\t\t\tif (vma_is_shmem(vma))\n\t\t\t\tcontinue;\n\t\t\tif (vma->vm_file &&\n\t\t\t    !is_file_hugepages(vma->vm_file)) {\n\t\t\t\tret = -EOPNOTSUPP;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tret = pret < 0 ? pret : -EFAULT;\n\t}\n\tmmap_read_unlock(current->mm);\n\tif (ret) {\n\t\t\/*\n\t\t * if we did partial map, or found file backed vmas,\n\t\t * release any pages we did get\n\t\t *\/\n\t\tif (pret > 0)\n\t\t\tunpin_user_pages(pages, pret);\n\t\tgoto done;\n\t}\n\n\tret = io_buffer_account_pin(ctx, pages, pret, imu, last_hpage);\n\tif (ret) {\n\t\tunpin_user_pages(pages, pret);\n\t\tgoto done;\n\t}\n\n\toff = ubuf & ~PAGE_MASK;\n\tsize = iov->iov_len;\n\tfor (i = 0; i < nr_pages; i++) {\n\t\tsize_t vec_len;\n\n\t\tvec_len = min_t(size_t, size, PAGE_SIZE - off);\n\t\timu->bvec[i].bv_page = pages[i];\n\t\timu->bvec[i].bv_len = vec_len;\n\t\timu->bvec[i].bv_offset = off;\n\t\toff = 0;\n\t\tsize -= vec_len;\n\t}\n\t\/* store original address for later verification *\/\n\timu->ubuf = ubuf;\n\timu->ubuf_end = ubuf + iov->iov_len;\n\timu->nr_bvecs = nr_pages;\n\t*pimu = imu;\n\tret = 0;\ndone:\n\tif (ret)\n\t\tkvfree(imu);\n\tkvfree(pages);\n\tkvfree(vmas);\n\treturn ret;","target":0,"code_token_length":718,"total_token_length":954,"max_tokens_setting":1024}
+{"idx":236145,"func":"GF_Err gppc_box_size(GF_Box *s)\n{\n\tGF_3GPPConfigBox *ptr = (GF_3GPPConfigBox *)s;\n\n\ts->size += 5;\n\tif (!ptr->cfg.type) {\n\t\tswitch (ptr->type) {\n\t\tcase GF_ISOM_BOX_TYPE_D263:\n\t\t\tptr->cfg.type = GF_ISOM_SUBTYPE_3GP_H263;\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_DAMR:\n\t\t\tptr->cfg.type = GF_ISOM_SUBTYPE_3GP_AMR;\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_DEVC:\n\t\t\tptr->cfg.type = GF_ISOM_SUBTYPE_3GP_EVRC;\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_DQCP:\n\t\t\tptr->cfg.type = GF_ISOM_SUBTYPE_3GP_QCELP;\n\t\t\tbreak;\n\t\tcase GF_ISOM_BOX_TYPE_DSMV:\n\t\t\tptr->cfg.type = GF_ISOM_SUBTYPE_3GP_SMV;\n\t\t\tbreak;\n\t\t}\n\t}\n\tswitch (ptr->cfg.type) {\n\tcase GF_ISOM_SUBTYPE_3GP_H263:\n\t\ts->size += 2;\n\t\tbreak;\n\tcase GF_ISOM_SUBTYPE_3GP_AMR:\n\tcase GF_ISOM_SUBTYPE_3GP_AMR_WB:\n\t\ts->size += 4;\n\t\tbreak;\n\tcase GF_ISOM_SUBTYPE_3GP_EVRC:\n\tcase GF_ISOM_SUBTYPE_3GP_QCELP:\n\tcase GF_ISOM_SUBTYPE_3GP_SMV:\n\t\ts->size += 1;\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":513360,"func":"create_distinct_group(THD *thd, Ref_ptr_array ref_pointer_array,\n                      ORDER *order_list, List<Item> &fields,\n                      List<Item> &all_fields,\n\t\t      bool *all_order_by_fields_used)\n{\n  List_iterator<Item> li(fields);\n  Item *item;\n  Ref_ptr_array orig_ref_pointer_array= ref_pointer_array;\n  ORDER *order,*group,**prev;\n  uint idx= 0;\n\n  *all_order_by_fields_used= 1;\n  while ((item=li++))\n    item->marker=0;\t\t\t\/* Marker that field is not used *\/\n\n  prev= &group;  group=0;\n  for (order=order_list ; order; order=order->next)\n  {\n    if (order->in_field_list)\n    {\n      ORDER *ord=(ORDER*) thd->memdup((char*) order,sizeof(ORDER));\n      if (!ord)\n\treturn 0;\n      *prev=ord;\n      prev= &ord->next;\n      (*ord->item)->marker=1;\n    }\n    else\n      *all_order_by_fields_used= 0;\n  }\n\n  li.rewind();\n  while ((item=li++))\n  {\n    if (!item->const_item() && !item->with_sum_func && !item->marker)\n    {\n      \/* \n        Don't put duplicate columns from the SELECT list into the \n        GROUP BY list.\n      *\/\n      ORDER *ord_iter;\n      for (ord_iter= group; ord_iter; ord_iter= ord_iter->next)\n        if ((*ord_iter->item)->eq(item, 1))\n          goto next_item;\n      \n      ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));\n      if (!ord)\n\treturn 0;\n\n      if (item->type() == Item::FIELD_ITEM &&\n          item->field_type() == MYSQL_TYPE_BIT)\n      {\n        \/*\n          Because HEAP tables can't index BIT fields we need to use an\n          additional hidden field for grouping because later it will be\n          converted to a LONG field. Original field will remain of the\n          BIT type and will be returned [el]client.\n        *\/\n        Item_field *new_item= new (thd->mem_root) Item_field(thd, (Item_field*)item);\n        int el= all_fields.elements;\n        orig_ref_pointer_array[el]= new_item;\n        all_fields.push_front(new_item, thd->mem_root);\n        ord->item=&orig_ref_pointer_array[el]; \n     }\n      else\n      {\n        \/*\n          We have here only field_list (not all_field_list), so we can use\n          simple indexing of ref_pointer_array (order in the array and in the\n          list are same)\n        *\/\n        ord->item= &ref_pointer_array[idx];\n      }\n      ord->direction= ORDER::ORDER_ASC;\n      *prev=ord;\n      prev= &ord->next;\n    }\nnext_item:\n    idx++;\n  }\n  *prev=0;\n  return group;\n}","target":0,"code_token_length":630,"total_token_length":866,"max_tokens_setting":1024}
+{"idx":202719,"func":"struct sctp_chunk *sctp_make_strreset_req(\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\t__u16 stream_num, __be16 *stream_list,\n\t\t\t\t\tbool out, bool in)\n{\n\t__u16 stream_len = stream_num * sizeof(__u16);\n\tstruct sctp_strreset_outreq outreq;\n\tstruct sctp_strreset_inreq inreq;\n\tstruct sctp_chunk *retval;\n\t__u16 outlen, inlen;\n\n\toutlen = (sizeof(outreq) + stream_len) * out;\n\tinlen = (sizeof(inreq) + stream_len) * in;\n\n\tretval = sctp_make_reconf(asoc, outlen + inlen);\n\tif (!retval)\n\t\treturn NULL;\n\n\tif (outlen) {\n\t\toutreq.param_hdr.type = SCTP_PARAM_RESET_OUT_REQUEST;\n\t\toutreq.param_hdr.length = htons(outlen);\n\t\toutreq.request_seq = htonl(asoc->strreset_outseq);\n\t\toutreq.response_seq = htonl(asoc->strreset_inseq - 1);\n\t\toutreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);\n\n\t\tsctp_addto_chunk(retval, sizeof(outreq), &outreq);\n\n\t\tif (stream_len)\n\t\t\tsctp_addto_chunk(retval, stream_len, stream_list);\n\t}\n\n\tif (inlen) {\n\t\tinreq.param_hdr.type = SCTP_PARAM_RESET_IN_REQUEST;\n\t\tinreq.param_hdr.length = htons(inlen);\n\t\tinreq.request_seq = htonl(asoc->strreset_outseq + out);\n\n\t\tsctp_addto_chunk(retval, sizeof(inreq), &inreq);\n\n\t\tif (stream_len)\n\t\t\tsctp_addto_chunk(retval, stream_len, stream_list);\n\t}\n\n\treturn retval;\n}","target":1,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":440885,"func":"LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,\n                   va_list msg_args, const char *hdr_format, va_list hdr_args)\n{\n    const char *type_str;\n    char buf[1024];\n    const size_t size = sizeof(buf);\n    Bool newline;\n    size_t len = 0;\n    int (*vprintf_func)(char *, int, const char* _X_RESTRICT_KYWD f, va_list args)\n            _X_ATTRIBUTE_PRINTF(3, 0);\n    int (*printf_func)(char *, int, const char* _X_RESTRICT_KYWD f, ...)\n            _X_ATTRIBUTE_PRINTF(3, 4);\n\n    type_str = LogMessageTypeVerbString(type, verb);\n    if (!type_str)\n        return;\n\n    if (inSignalContext) {\n        vprintf_func = vpnprintf;\n        printf_func = pnprintf;\n    } else {\n        vprintf_func = Xvscnprintf;\n        printf_func = Xscnprintf;\n    }\n\n    \/* if type_str is not \"\", prepend it and ' ', to message *\/\n    if (type_str[0] != '\\0')\n        len += printf_func(&buf[len], size - len, \"%s \", type_str);\n\n    if (hdr_format && size - len > 1)\n        len += vprintf_func(&buf[len], size - len, hdr_format, hdr_args);\n\n    if (msg_format && size - len > 1)\n        len += vprintf_func(&buf[len], size - len, msg_format, msg_args);\n\n    \/* Force '\\n' at end of truncated line *\/\n    if (size - len == 1)\n        buf[len - 1] = '\\n';\n\n    newline = (buf[len - 1] == '\\n');\n    LogSWrite(verb, buf, len, newline);\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":343158,"func":"int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)\n{\n\tu8 *tail;\n\tint nfrags;\n\tint esph_offset;\n\tstruct page *page;\n\tstruct sk_buff *trailer;\n\tint tailen = esp->tailen;\n\tunsigned int allocsz;\n\n\tif (x->encap) {\n\t\tint err = esp6_output_encap(x, skb, esp);\n\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\tallocsz = ALIGN(skb->data_len + tailen, L1_CACHE_BYTES);\n\tif (allocsz > ESP_SKB_FRAG_MAXSIZE)\n\t\tgoto cow;\n\n\tif (!skb_cloned(skb)) {\n\t\tif (tailen <= skb_tailroom(skb)) {\n\t\t\tnfrags = 1;\n\t\t\ttrailer = skb;\n\t\t\ttail = skb_tail_pointer(trailer);\n\n\t\t\tgoto skip_cow;\n\t\t} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)\n\t\t\t   && !skb_has_frag_list(skb)) {\n\t\t\tint allocsize;\n\t\t\tstruct sock *sk = skb->sk;\n\t\t\tstruct page_frag *pfrag = &x->xfrag;\n\n\t\t\tesp->inplace = false;\n\n\t\t\tallocsize = ALIGN(tailen, L1_CACHE_BYTES);\n\n\t\t\tspin_lock_bh(&x->lock);\n\n\t\t\tif (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {\n\t\t\t\tspin_unlock_bh(&x->lock);\n\t\t\t\tgoto cow;\n\t\t\t}\n\n\t\t\tpage = pfrag->page;\n\t\t\tget_page(page);\n\n\t\t\ttail = page_address(page) + pfrag->offset;\n\n\t\t\tesp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);\n\n\t\t\tnfrags = skb_shinfo(skb)->nr_frags;\n\n\t\t\t__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,\n\t\t\t\t\t     tailen);\n\t\t\tskb_shinfo(skb)->nr_frags = ++nfrags;\n\n\t\t\tpfrag->offset = pfrag->offset + allocsize;\n\n\t\t\tspin_unlock_bh(&x->lock);\n\n\t\t\tnfrags++;\n\n\t\t\tskb->len += tailen;\n\t\t\tskb->data_len += tailen;\n\t\t\tskb->truesize += tailen;\n\t\t\tif (sk && sk_fullsock(sk))\n\t\t\t\trefcount_add(tailen, &sk->sk_wmem_alloc);\n\n\t\t\tgoto out;\n\t\t}\n\t}\n\ncow:\n\tesph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);\n\n\tnfrags = skb_cow_data(skb, tailen, &trailer);\n\tif (nfrags < 0)\n\t\tgoto out;\n\ttail = skb_tail_pointer(trailer);\n\tesp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);\n\nskip_cow:\n\tesp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);\n\tpskb_put(skb, trailer, tailen);\n\nout:\n\treturn nfrags;\n}","target":0,"code_token_length":644,"total_token_length":880,"max_tokens_setting":1024}
+{"idx":462430,"func":"enqueueIoWork(epolld_t *epd, int dispatchInlineIfQueueFull) {\n\tio_req_t *n;\n\tint dispatchInline;\n\tDEFiRet;\n\t\n\tCHKmalloc(n = malloc(sizeof(io_req_t)));\n\tn->epd = epd;\n\t\n\tint inlineDispatchThreshold = DFLT_inlineDispatchThreshold * runModConf->wrkrMax;\n\tdispatchInline = 0;\n\t\n\tpthread_mutex_lock(&io_q.mut);\n\tif (dispatchInlineIfQueueFull && io_q.sz > inlineDispatchThreshold) {\n\t\tdispatchInline = 1;\n\t} else {\n\t\tSTAILQ_INSERT_TAIL(&io_q.q, n, link);\n\t\tio_q.sz++;\n\t\tSTATSCOUNTER_INC(io_q.ctrEnq, io_q.mutCtrEnq);\n\t\tSTATSCOUNTER_SETMAX_NOMUT(io_q.ctrMaxSz, io_q.sz);\n\t\tpthread_cond_signal(&io_q.wakeup_worker);\n\t}\n\tpthread_mutex_unlock(&io_q.mut);\n\n\tif (dispatchInline == 1) {\n\t\tfree(n);\n\t\tprocessWorkItem(epd);\n\t}\nfinalize_it:\n\tif (iRet != RS_RET_OK) {\n\t\tif (n == NULL) {\n\t\t\terrmsg.LogError(0, iRet, \"imptcp: couldn't allocate memory to enqueue io-request - ignored\");\n\t\t}\n\t}\n\tRETiRet;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":337779,"func":"static void sctp_asconf_param_success(struct sctp_association *asoc,\n\t\t\t\t      struct sctp_addip_param *asconf_param)\n{\n\tstruct sctp_bind_addr *bp = &asoc->base.bind_addr;\n\tunion sctp_addr_param *addr_param;\n\tstruct sctp_sockaddr_entry *saddr;\n\tstruct sctp_transport *transport;\n\tunion sctp_addr\taddr;\n\tstruct sctp_af *af;\n\n\taddr_param = (void *)asconf_param + sizeof(*asconf_param);\n\n\t\/* We have checked the packet before, so we do not check again.\t*\/\n\taf = sctp_get_af_specific(param_type2af(addr_param->p.type));\n\tif (!af->from_addr_param(&addr, addr_param, htons(bp->port), 0))\n\t\treturn;\n\n\tswitch (asconf_param->param_hdr.type) {\n\tcase SCTP_PARAM_ADD_IP:\n\t\t\/* This is always done in BH context with a socket lock\n\t\t * held, so the list can not change.\n\t\t *\/\n\t\tlocal_bh_disable();\n\t\tlist_for_each_entry(saddr, &bp->address_list, list) {\n\t\t\tif (sctp_cmp_addr_exact(&saddr->a, &addr))\n\t\t\t\tsaddr->state = SCTP_ADDR_SRC;\n\t\t}\n\t\tlocal_bh_enable();\n\t\tlist_for_each_entry(transport, &asoc->peer.transport_addr_list,\n\t\t\t\ttransports) {\n\t\t\tsctp_transport_dst_release(transport);\n\t\t}\n\t\tbreak;\n\tcase SCTP_PARAM_DEL_IP:\n\t\tlocal_bh_disable();\n\t\tsctp_del_bind_addr(bp, &addr);\n\t\tif (asoc->asconf_addr_del_pending != NULL &&\n\t\t    sctp_cmp_addr_exact(asoc->asconf_addr_del_pending, &addr)) {\n\t\t\tkfree(asoc->asconf_addr_del_pending);\n\t\t\tasoc->asconf_addr_del_pending = NULL;\n\t\t}\n\t\tlocal_bh_enable();\n\t\tlist_for_each_entry(transport, &asoc->peer.transport_addr_list,\n\t\t\t\ttransports) {\n\t\t\tsctp_transport_dst_release(transport);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":270109,"func":"TfLiteStatus GetQuantizedConvolutionMultipler(TfLiteContext* context,\n                                              const TfLiteTensor* input,\n                                              const TfLiteTensor* filter,\n                                              const TfLiteTensor* bias,\n                                              TfLiteTensor* output,\n                                              double* multiplier) {\n  const double input_product_scale = static_cast<double>(input->params.scale) *\n                                     static_cast<double>(filter->params.scale);\n  \/\/ The following conditions must be guaranteed by the training pipeline.\n  if (bias) {\n    const double bias_scale = static_cast<double>(bias->params.scale);\n    \/\/ Here we're making sure the input_product_scale & bias_scale are about the\n    \/\/ same. Since we have:\n    \/\/ (output - output_zp) * output_scale =\n    \/\/ input_product_scale * input_product + bias * bias_scale ---- (0)\n    \/\/\n    \/\/ (0) equals:\n    \/\/ (input_product + bias) * input_product_scale ----- (1)\n    \/\/           +\n    \/\/ bias * (bias_scale - input_product_scale)   ------ (2)\n    \/\/\n    \/\/ For the real kernel computation, we're doing (1), so we really need to\n    \/\/ make sure (2) has minimum impact on the output, so:\n    \/\/ bias * (bias_scale - input_product_scale) \/ output_scale should be\n    \/\/ a small number for an integer.\n    \/\/ Since normally bias should be within a small range.\n    \/\/ We should expect (bias_scale - input_product_scale) \/ output_scale to\n    \/\/ be a small number like 0.02.\n    const double scale_diff = std::abs(input_product_scale - bias_scale);\n    const double output_scale = static_cast<double>(output->params.scale);\n\n    TF_LITE_ENSURE(context, scale_diff \/ output_scale <= 0.02);\n  }\n  return GetQuantizedConvolutionMultipler(context, input, filter, output,\n                                          multiplier);\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":389715,"func":"func_equal(\n    typval_T *tv1,\n    typval_T *tv2,\n    int\t     ic)\t    \/\/ ignore case\n{\n    char_u\t*s1, *s2;\n    dict_T\t*d1, *d2;\n    int\t\ta1, a2;\n    int\t\ti;\n\n    \/\/ empty and NULL function name considered the same\n    s1 = tv1->v_type == VAR_FUNC ? tv1->vval.v_string\n\t\t\t\t\t   : partial_name(tv1->vval.v_partial);\n    if (s1 != NULL && *s1 == NUL)\n\ts1 = NULL;\n    s2 = tv2->v_type == VAR_FUNC ? tv2->vval.v_string\n\t\t\t\t\t   : partial_name(tv2->vval.v_partial);\n    if (s2 != NULL && *s2 == NUL)\n\ts2 = NULL;\n    if (s1 == NULL || s2 == NULL)\n    {\n\tif (s1 != s2)\n\t    return FALSE;\n    }\n    else if (STRCMP(s1, s2) != 0)\n\treturn FALSE;\n\n    \/\/ empty dict and NULL dict is different\n    d1 = tv1->v_type == VAR_FUNC ? NULL : tv1->vval.v_partial->pt_dict;\n    d2 = tv2->v_type == VAR_FUNC ? NULL : tv2->vval.v_partial->pt_dict;\n    if (d1 == NULL || d2 == NULL)\n    {\n\tif (d1 != d2)\n\t    return FALSE;\n    }\n    else if (!dict_equal(d1, d2, ic, TRUE))\n\treturn FALSE;\n\n    \/\/ empty list and no list considered the same\n    a1 = tv1->v_type == VAR_FUNC ? 0 : tv1->vval.v_partial->pt_argc;\n    a2 = tv2->v_type == VAR_FUNC ? 0 : tv2->vval.v_partial->pt_argc;\n    if (a1 != a2)\n\treturn FALSE;\n    for (i = 0; i < a1; ++i)\n\tif (!tv_equal(tv1->vval.v_partial->pt_argv + i,\n\t\t      tv2->vval.v_partial->pt_argv + i, ic, TRUE))\n\t    return FALSE;\n\n    return TRUE;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":216202,"func":"int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  sftp_attributes errno_attr = NULL;\n  struct sftp_attributes_struct attr;\n  ssh_buffer buffer;\n  ssh_string path;\n  uint32_t id;\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return -1;\n  }\n\n  path = ssh_string_from_char(directory);\n  if (path == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return -1;\n  }\n\n  ZERO_STRUCT(attr);\n  attr.permissions = mode;\n  attr.flags = SSH_FILEXFER_ATTR_PERMISSIONS;\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, path) < 0 ||\n      buffer_add_attributes(buffer, &attr) < 0 ||\n      sftp_packet_write(sftp, SSH_FXP_MKDIR, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(path);\n  }\n  ssh_buffer_free(buffer);\n  ssh_string_free(path);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      return -1;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  \/* By specification, this command only returns SSH_FXP_STATUS *\/\n  if (msg->packet_type == SSH_FXP_STATUS) {\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return -1;\n    }\n    sftp_set_error(sftp, status->status);\n    switch (status->status) {\n      case SSH_FX_FAILURE:\n        \/*\n         * mkdir always returns a failure, even if the path already exists.\n         * To be POSIX conform and to be able to map it to EEXIST a stat\n         * call is needed here.\n         *\/\n        errno_attr = sftp_lstat(sftp, directory);\n        if (errno_attr != NULL) {\n          SAFE_FREE(errno_attr);\n          sftp_set_error(sftp, SSH_FX_FILE_ALREADY_EXISTS);\n        }\n        break;\n      case SSH_FX_OK:\n        status_msg_free(status);\n        return 0;\n        break;\n      default:\n        break;\n    }\n    \/*\n     * The status should be SSH_FX_OK if the command was successful, if it\n     * didn't, then there was an error\n     *\/\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n    return -1;\n  } else {\n    ssh_set_error(sftp->session, SSH_FATAL,\n        \"Received message %d when attempting to make directory\",\n        msg->packet_type);\n    sftp_message_free(msg);\n  }\n\n  return -1;\n}","target":1,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":430395,"func":"static int validate_and_copy_set_tun(const struct nlattr *attr,\n\t\t\t\t     struct sw_flow_actions **sfa, bool log)\n{\n\tstruct sw_flow_match match;\n\tstruct sw_flow_key key;\n\tstruct metadata_dst *tun_dst;\n\tstruct ip_tunnel_info *tun_info;\n\tstruct ovs_tunnel_info *ovs_tun;\n\tstruct nlattr *a;\n\tint err = 0, start, opts_type;\n\t__be16 dst_opt_type;\n\n\tdst_opt_type = 0;\n\tovs_match_init(&match, &key, true, NULL);\n\topts_type = ip_tun_from_nlattr(nla_data(attr), &match, false, log);\n\tif (opts_type < 0)\n\t\treturn opts_type;\n\n\tif (key.tun_opts_len) {\n\t\tswitch (opts_type) {\n\t\tcase OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS:\n\t\t\terr = validate_geneve_opts(&key);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t\tdst_opt_type = TUNNEL_GENEVE_OPT;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS:\n\t\t\tdst_opt_type = TUNNEL_VXLAN_OPT;\n\t\t\tbreak;\n\t\tcase OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS:\n\t\t\tdst_opt_type = TUNNEL_ERSPAN_OPT;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tstart = add_nested_action_start(sfa, OVS_ACTION_ATTR_SET, log);\n\tif (start < 0)\n\t\treturn start;\n\n\ttun_dst = metadata_dst_alloc(key.tun_opts_len, METADATA_IP_TUNNEL,\n\t\t\t\t     GFP_KERNEL);\n\n\tif (!tun_dst)\n\t\treturn -ENOMEM;\n\n\terr = dst_cache_init(&tun_dst->u.tun_info.dst_cache, GFP_KERNEL);\n\tif (err) {\n\t\tdst_release((struct dst_entry *)tun_dst);\n\t\treturn err;\n\t}\n\n\ta = __add_action(sfa, OVS_KEY_ATTR_TUNNEL_INFO, NULL,\n\t\t\t sizeof(*ovs_tun), log);\n\tif (IS_ERR(a)) {\n\t\tdst_release((struct dst_entry *)tun_dst);\n\t\treturn PTR_ERR(a);\n\t}\n\n\tovs_tun = nla_data(a);\n\tovs_tun->tun_dst = tun_dst;\n\n\ttun_info = &tun_dst->u.tun_info;\n\ttun_info->mode = IP_TUNNEL_INFO_TX;\n\tif (key.tun_proto == AF_INET6)\n\t\ttun_info->mode |= IP_TUNNEL_INFO_IPV6;\n\telse if (key.tun_proto == AF_INET && key.tun_key.u.ipv4.dst == 0)\n\t\ttun_info->mode |= IP_TUNNEL_INFO_BRIDGE;\n\ttun_info->key = key.tun_key;\n\n\t\/* We need to store the options in the action itself since\n\t * everything else will go away after flow setup. We can append\n\t * it to tun_info and then point there.\n\t *\/\n\tip_tunnel_info_opts_set(tun_info,\n\t\t\t\tTUN_METADATA_OPTS(&key, key.tun_opts_len),\n\t\t\t\tkey.tun_opts_len, dst_opt_type);\n\tadd_nested_action_end(*sfa, start);\n\n\treturn err;\n}","target":0,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":508340,"func":"static my_bool list_open_tables_callback(TDC_element *element,\n                                         list_open_tables_arg *arg)\n{\n  char *db= (char*) element->m_key;\n  char *table_name= (char*) element->m_key + strlen((char*) element->m_key) + 1;\n\n  if (arg->db && my_strcasecmp(system_charset_info, arg->db, db))\n    return FALSE;\n  if (arg->wild && wild_compare(table_name, arg->wild, 0))\n    return FALSE;\n\n  \/* Check if user has SELECT privilege for any column in the table *\/\n  arg->table_list.db= db;\n  arg->table_list.table_name= table_name;\n  arg->table_list.grant.privilege= 0;\n\n  if (check_table_access(arg->thd, SELECT_ACL, &arg->table_list, TRUE, 1, TRUE))\n    return FALSE;\n\n  if (!(*arg->start_list= (OPEN_TABLE_LIST *) arg->thd->alloc(\n                    sizeof(**arg->start_list) + element->m_key_length)))\n    return TRUE;\n\n  strmov((*arg->start_list)->table=\n         strmov(((*arg->start_list)->db= (char*) ((*arg->start_list) + 1)),\n                db) + 1, table_name);\n  (*arg->start_list)->in_use= 0;\n\n  mysql_mutex_lock(&element->LOCK_table_share);\n  All_share_tables_list::Iterator it(element->all_tables);\n  TABLE *table;\n  while ((table= it++))\n    if (table->in_use)\n      ++(*arg->start_list)->in_use;\n  mysql_mutex_unlock(&element->LOCK_table_share);\n  (*arg->start_list)->locked= 0;                   \/* Obsolete. *\/\n  arg->start_list= &(*arg->start_list)->next;\n  *arg->start_list= 0;\n  return FALSE;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":310260,"func":"dirserv_thinks_router_is_unreliable(time_t now,\n                                    routerinfo_t *router,\n                                    int need_uptime, int need_capacity)\n{\n  if (need_uptime) {\n    if (!enough_mtbf_info) {\n      \/* XXX023 Once most authorities are on v3, we should change the rule from\n       * \"use uptime if we don't have mtbf data\" to \"don't advertise Stable on\n       * v3 if we don't have enough mtbf data.\"  Or maybe not, since if we ever\n       * hit a point where we need to reset a lot of authorities at once,\n       * none of them would be in a position to declare Stable.\n       *\/\n      long uptime = real_uptime(router, now);\n      if ((unsigned)uptime < stable_uptime &&\n          (unsigned)uptime < UPTIME_TO_GUARANTEE_STABLE)\n        return 1;\n    } else {\n      double mtbf =\n        rep_hist_get_stability(router->cache_info.identity_digest, now);\n      if (mtbf < stable_mtbf &&\n          mtbf < MTBF_TO_GUARANTEE_STABLE)\n        return 1;\n    }\n  }\n  if (need_capacity) {\n    uint32_t bw = router_get_advertised_bandwidth(router);\n    if (bw < fast_bandwidth)\n      return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":210527,"func":"static netdev_tx_t mcba_usb_start_xmit(struct sk_buff *skb,\n\t\t\t\t       struct net_device *netdev)\n{\n\tstruct mcba_priv *priv = netdev_priv(netdev);\n\tstruct can_frame *cf = (struct can_frame *)skb->data;\n\tstruct mcba_usb_ctx *ctx = NULL;\n\tstruct net_device_stats *stats = &priv->netdev->stats;\n\tu16 sid;\n\tint err;\n\tstruct mcba_usb_msg_can usb_msg = {\n\t\t.cmd_id = MBCA_CMD_TRANSMIT_MESSAGE_EV\n\t};\n\n\tif (can_dropped_invalid_skb(netdev, skb))\n\t\treturn NETDEV_TX_OK;\n\n\tctx = mcba_usb_get_free_ctx(priv, cf);\n\tif (!ctx)\n\t\treturn NETDEV_TX_BUSY;\n\n\tif (cf->can_id & CAN_EFF_FLAG) {\n\t\t\/* SIDH    | SIDL                 | EIDH   | EIDL\n\t\t * 28 - 21 | 20 19 18 x x x 17 16 | 15 - 8 | 7 - 0\n\t\t *\/\n\t\tsid = MCBA_SIDL_EXID_MASK;\n\t\t\/* store 28-18 bits *\/\n\t\tsid |= (cf->can_id & 0x1ffc0000) >> 13;\n\t\t\/* store 17-16 bits *\/\n\t\tsid |= (cf->can_id & 0x30000) >> 16;\n\t\tput_unaligned_be16(sid, &usb_msg.sid);\n\n\t\t\/* store 15-0 bits *\/\n\t\tput_unaligned_be16(cf->can_id & 0xffff, &usb_msg.eid);\n\t} else {\n\t\t\/* SIDH   | SIDL\n\t\t * 10 - 3 | 2 1 0 x x x x x\n\t\t *\/\n\t\tput_unaligned_be16((cf->can_id & CAN_SFF_MASK) << 5,\n\t\t\t\t   &usb_msg.sid);\n\t\tusb_msg.eid = 0;\n\t}\n\n\tusb_msg.dlc = cf->len;\n\n\tmemcpy(usb_msg.data, cf->data, usb_msg.dlc);\n\n\tif (cf->can_id & CAN_RTR_FLAG)\n\t\tusb_msg.dlc |= MCBA_DLC_RTR_MASK;\n\n\tcan_put_echo_skb(skb, priv->netdev, ctx->ndx, 0);\n\n\terr = mcba_usb_xmit(priv, (struct mcba_usb_msg *)&usb_msg, ctx);\n\tif (err)\n\t\tgoto xmit_failed;\n\n\treturn NETDEV_TX_OK;\n\nxmit_failed:\n\tcan_free_echo_skb(priv->netdev, ctx->ndx, NULL);\n\tmcba_usb_free_ctx(ctx);\n\tdev_kfree_skb(skb);\n\tstats->tx_dropped++;\n\n\treturn NETDEV_TX_OK;\n}","target":1,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":247599,"func":"TEST_P(SslSocketTest, ClientCertificateHashAndSpkiVerification) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  server_validation_ctx->mutable_trusted_ca()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"));\n  server_validation_ctx->add_verify_certificate_hash(\n      \"0000000000000000000000000000000000000000000000000000000000000000\");\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_DNS_CERT_SPKI);\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_URI_CERT_SPKI);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"));\n\n  TestUtilOptionsV2 test_options(listener, client, true, GetParam());\n  testUtilV2(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedServerCertDigest(TEST_SAN_DNS_CERT_256_HASH));\n\n  \/\/ Works even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":227000,"func":"IRC_PROTOCOL_CALLBACK(330_343)\n{\n    struct t_irc_channel *ptr_channel;\n    struct t_gui_buffer *ptr_buffer;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    if (argc >= 6)\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, argv[3], command, \"whois\", NULL),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s %s%s\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],\n            irc_nick_color_for_msg (server, 1, NULL, argv[4]),\n            argv[4]);\n    }\n    else\n    {\n        ptr_channel = (irc_channel_is_channel (server, argv[3])) ?\n            irc_channel_search (server, argv[3]) : NULL;\n        ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (\n                server, argv[3], command, \"whois\", ptr_buffer),\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s[%s%s%s] %s%s\",\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n            argv[3],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]);\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":247518,"func":"TEST_P(SslSocketTest, SignatureAlgorithms) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n\n  server_validation_ctx->mutable_trusted_ca()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"));\n  \/\/ Server ECDSA certificate.\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_ecdsa_p256_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_ecdsa_p256_key.pem\"));\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  \/\/ Client RSA certificate.\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"));\n\n  \/\/ Connection using defaults (client & server) succeeds.\n  TestUtilOptionsV2 algorithm_test_options(listener, client, true, GetParam());\n  algorithm_test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n      .setExpectedServerStats(\"ssl.sigalgs.rsa_pss_rsae_sha256\")\n      .setExpectedClientStats(\"ssl.sigalgs.ecdsa_secp256r1_sha256\");\n  testUtilV2(algorithm_test_options);\n\n  \/\/ Connection using defaults (client & server) succeeds, even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(algorithm_test_options);\n  client.set_allow_renegotiation(false);\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":261195,"func":"static void MqttClient_RespList_Remove(MqttClient *client, MqttPendResp *rmResp)\n{\n    MqttPendResp *tmpResp;\n\n    if (client == NULL)\n        return;\n\n#ifdef WOLFMQTT_DEBUG_CLIENT\n    PRINTF(\"PendResp Remove: %p\", rmResp);\n#endif\n\n    \/* Find the response entry *\/\n    for (tmpResp = client->firstPendResp;\n         tmpResp != NULL;\n         tmpResp = tmpResp->next)\n    {\n        if (tmpResp == rmResp) {\n            break;\n        }\n    }\n    if (tmpResp) {\n        \/* Fix up the first and last pointers *\/\n        if (client->firstPendResp == tmpResp) {\n            client->firstPendResp = tmpResp->next;\n        }\n        if (client->lastPendResp == tmpResp) {\n            client->lastPendResp = tmpResp->prev;\n        }\n\n        \/* Remove the entry from the list *\/\n        if (tmpResp->next != NULL) {\n            tmpResp->next->prev = tmpResp->prev;\n        }\n        if (tmpResp->prev != NULL) {\n            tmpResp->prev->next = tmpResp->next;\n        }\n    }\n#ifdef WOLFMQTT_DEBUG_CLIENT\n    else {\n        PRINTF(\"\\tPendResp Remove Failed\");\n    }\n#endif\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":326637,"func":"set_time(int fd, int mode, const char *name,\n    time_t atime, long atime_nsec,\n    time_t mtime, long mtime_nsec)\n{\n\t\/* Select the best implementation for this platform. *\/\n#if defined(HAVE_UTIMENSAT) && defined(HAVE_FUTIMENS)\n\t\/*\n\t * utimensat() and futimens() are defined in\n\t * POSIX.1-2008. They support ns resolution and setting times\n\t * on fds and symlinks.\n\t *\/\n\tstruct timespec ts[2];\n\t(void)mode; \/* UNUSED *\/\n\tts[0].tv_sec = atime;\n\tts[0].tv_nsec = atime_nsec;\n\tts[1].tv_sec = mtime;\n\tts[1].tv_nsec = mtime_nsec;\n\tif (fd >= 0)\n\t\treturn futimens(fd, ts);\n\treturn utimensat(AT_FDCWD, name, ts, AT_SYMLINK_NOFOLLOW);\n\n#elif HAVE_UTIMES\n\t\/*\n\t * The utimes()-family functions support \u00b5s-resolution and\n\t * setting times fds and symlinks.  utimes() is documented as\n\t * LEGACY by POSIX, futimes() and lutimes() are not described\n\t * in POSIX.\n\t *\/\n\tstruct timeval times[2];\n\n\ttimes[0].tv_sec = atime;\n\ttimes[0].tv_usec = atime_nsec \/ 1000;\n\ttimes[1].tv_sec = mtime;\n\ttimes[1].tv_usec = mtime_nsec \/ 1000;\n\n#ifdef HAVE_FUTIMES\n\tif (fd >= 0)\n\t\treturn (futimes(fd, times));\n#else\n\t(void)fd; \/* UNUSED *\/\n#endif\n#ifdef HAVE_LUTIMES\n\t(void)mode; \/* UNUSED *\/\n\treturn (lutimes(name, times));\n#else\n\tif (S_ISLNK(mode))\n\t\treturn (0);\n\treturn (utimes(name, times));\n#endif\n\n#elif defined(HAVE_UTIME)\n\t\/*\n\t * utime() is POSIX-standard but only supports 1s resolution and\n\t * does not support fds or symlinks.\n\t *\/\n\tstruct utimbuf times;\n\t(void)fd; \/* UNUSED *\/\n\t(void)name; \/* UNUSED *\/\n\t(void)atime_nsec; \/* UNUSED *\/\n\t(void)mtime_nsec; \/* UNUSED *\/\n\ttimes.actime = atime;\n\ttimes.modtime = mtime;\n\tif (S_ISLNK(mode))\n\t\treturn (ARCHIVE_OK);\n\treturn (utime(name, ×));\n\n#else\n\t\/*\n\t * We don't know how to set the time on this platform.\n\t *\/\n\t(void)fd; \/* UNUSED *\/\n\t(void)mode; \/* UNUSED *\/\n\t(void)name; \/* UNUSED *\/\n\t(void)atime_nsec; \/* UNUSED *\/\n\t(void)mtime_nsec; \/* UNUSED *\/\n\treturn (ARCHIVE_WARN);\n#endif\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":221419,"func":"static void copy_vmcb_control_area(struct vmcb_control_area *dst,\n\t\t\t\t   struct vmcb_control_area *from)\n{\n\tunsigned int i;\n\n\tfor (i = 0; i < MAX_INTERCEPT; i++)\n\t\tdst->intercepts[i] = from->intercepts[i];\n\n\tdst->iopm_base_pa         = from->iopm_base_pa;\n\tdst->msrpm_base_pa        = from->msrpm_base_pa;\n\tdst->tsc_offset           = from->tsc_offset;\n\t\/* asid not copied, it is handled manually for svm->vmcb.  *\/\n\tdst->tlb_ctl              = from->tlb_ctl;\n\tdst->int_ctl              = from->int_ctl;\n\tdst->int_vector           = from->int_vector;\n\tdst->int_state            = from->int_state;\n\tdst->exit_code            = from->exit_code;\n\tdst->exit_code_hi         = from->exit_code_hi;\n\tdst->exit_info_1          = from->exit_info_1;\n\tdst->exit_info_2          = from->exit_info_2;\n\tdst->exit_int_info        = from->exit_int_info;\n\tdst->exit_int_info_err    = from->exit_int_info_err;\n\tdst->nested_ctl           = from->nested_ctl;\n\tdst->event_inj            = from->event_inj;\n\tdst->event_inj_err        = from->event_inj_err;\n\tdst->nested_cr3           = from->nested_cr3;\n\tdst->virt_ext              = from->virt_ext;\n\tdst->pause_filter_count   = from->pause_filter_count;\n\tdst->pause_filter_thresh  = from->pause_filter_thresh;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":326124,"func":"regdump(char_u *pattern, bt_regprog_T *r)\n{\n    char_u  *s;\n    int\t    op = EXACTLY;\t\/\/ Arbitrary non-END op.\n    char_u  *next;\n    char_u  *end = NULL;\n    FILE    *f;\n\n#ifdef BT_REGEXP_LOG\n    f = fopen(\"bt_regexp_log.log\", \"a\");\n#else\n    f = stdout;\n#endif\n    if (f == NULL)\n\treturn;\n    fprintf(f, \"-------------------------------------\\n\\r\\nregcomp(%s):\\r\\n\", pattern);\n\n    s = r->program + 1;\n    \/\/ Loop until we find the END that isn't before a referred next (an END\n    \/\/ can also appear in a NOMATCH operand).\n    while (op != END || s <= end)\n    {\n\top = OP(s);\n\tfprintf(f, \"%2d%s\", (int)(s - r->program), regprop(s)); \/\/ Where, what.\n\tnext = regnext(s);\n\tif (next == NULL)\t\/\/ Next ptr.\n\t    fprintf(f, \"(0)\");\n\telse\n\t    fprintf(f, \"(%d)\", (int)((s - r->program) + (next - s)));\n\tif (end < next)\n\t    end = next;\n\tif (op == BRACE_LIMITS)\n\t{\n\t    \/\/ Two ints\n\t    fprintf(f, \" minval %ld, maxval %ld\", OPERAND_MIN(s), OPERAND_MAX(s));\n\t    s += 8;\n\t}\n\telse if (op == BEHIND || op == NOBEHIND)\n\t{\n\t    \/\/ one int\n\t    fprintf(f, \" count %ld\", OPERAND_MIN(s));\n\t    s += 4;\n\t}\n\telse if (op == RE_LNUM || op == RE_COL || op == RE_VCOL)\n\t{\n\t    \/\/ one int plus comparator\n\t    fprintf(f, \" count %ld\", OPERAND_MIN(s));\n\t    s += 5;\n\t}\n\ts += 3;\n\tif (op == ANYOF || op == ANYOF + ADD_NL\n\t\t|| op == ANYBUT || op == ANYBUT + ADD_NL\n\t\t|| op == EXACTLY)\n\t{\n\t    \/\/ Literal string, where present.\n\t    fprintf(f, \"\\nxxxxxxxxx\\n\");\n\t    while (*s != NUL)\n\t\tfprintf(f, \"%c\", *s++);\n\t    fprintf(f, \"\\nxxxxxxxxx\\n\");\n\t    s++;\n\t}\n\tfprintf(f, \"\\r\\n\");\n    }\n\n    \/\/ Header fields of interest.\n    if (r->regstart != NUL)\n\tfprintf(f, \"start `%s' 0x%x; \", r->regstart < 256\n\t\t? (char *)transchar(r->regstart)\n\t\t: \"multibyte\", r->regstart);\n    if (r->reganch)\n\tfprintf(f, \"anchored; \");\n    if (r->regmust != NULL)\n\tfprintf(f, \"must have \\\"%s\\\"\", r->regmust);\n    fprintf(f, \"\\r\\n\");\n\n#ifdef BT_REGEXP_LOG\n    fclose(f);\n#endif\n}","target":0,"code_token_length":648,"total_token_length":884,"max_tokens_setting":1024}
+{"idx":414925,"func":"xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {\n    int i;\n\n    if ((cur == NULL) || (val == NULL)) return(-1);\n\n    \/* @@ with_ns to check whether namespace nodes should be looked at @@ *\/\n    \/*\n     * prevent duplcates\n     *\/\n    for (i = 0;i < cur->nodeNr;i++)\n        if (cur->nodeTab[i] == val) return(0);\n\n    \/*\n     * grow the nodeTab if needed\n     *\/\n    if (cur->nodeMax == 0) {\n        cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *\n\t\t\t\t\t     sizeof(xmlNodePtr));\n\tif (cur->nodeTab == NULL) {\n\t    xmlXPathErrMemory(NULL, \"growing nodeset\\n\");\n\t    return(-1);\n\t}\n\tmemset(cur->nodeTab, 0 ,\n\t       XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));\n        cur->nodeMax = XML_NODESET_DEFAULT;\n    } else if (cur->nodeNr == cur->nodeMax) {\n        xmlNodePtr *temp;\n\n        if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH) {\n            xmlXPathErrMemory(NULL, \"growing nodeset hit limit\\n\");\n            return(-1);\n        }\n\ttemp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *\n\t\t\t\t      sizeof(xmlNodePtr));\n\tif (temp == NULL) {\n\t    xmlXPathErrMemory(NULL, \"growing nodeset\\n\");\n\t    return(-1);\n\t}\n        cur->nodeMax *= 2;\n\tcur->nodeTab = temp;\n    }\n    if (val->type == XML_NAMESPACE_DECL) {\n\txmlNsPtr ns = (xmlNsPtr) val;\n\n\tcur->nodeTab[cur->nodeNr++] =\n\t    xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);\n    } else\n\tcur->nodeTab[cur->nodeNr++] = val;\n    return(0);\n}","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":353012,"func":"uniqueMemberIndexer(\n\tslap_mask_t use,\n\tslap_mask_t flags,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *prefix,\n\tBerVarray values,\n\tBerVarray *keysp,\n\tvoid *ctx )\n{\n\tBerVarray dnvalues;\n\tint rc;\n\tint i;\n\tfor( i=0; !BER_BVISNULL( &values[i] ); i++ ) {\n\t\t\/* just count them *\/                 \n\t}\n\tassert( i > 0 );\n\n\tdnvalues = slap_sl_malloc( sizeof( struct berval ) * (i+1), ctx );\n\n\tfor( i=0; !BER_BVISNULL( &values[i] ); i++ ) {\n\t\tstruct berval assertedDN = values[i];\n\t\tstruct berval assertedUID = BER_BVNULL;\n\n\t\tif ( !BER_BVISEMPTY( &assertedDN ) ) {\n\t\t\tassertedUID.bv_val = strrchr( assertedDN.bv_val, '#' );\n\t\t\tif ( !BER_BVISNULL( &assertedUID ) ) {\n\t\t\t\tassertedUID.bv_val++;\n\t\t\t\tassertedUID.bv_len = assertedDN.bv_len\n\t\t\t\t\t- ( assertedUID.bv_val - assertedDN.bv_val );\n\t\n\t\t\t\tif ( bitStringValidate( NULL, &assertedUID ) == LDAP_SUCCESS ) {\n\t\t\t\t\tassertedDN.bv_len -= assertedUID.bv_len + 1;\n\n\t\t\t\t} else {\n\t\t\t\t\tBER_BVZERO( &assertedUID );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdnvalues[i] = assertedDN;\n\t}\n\tBER_BVZERO( &dnvalues[i] );\n\n\trc = octetStringIndexer( use, flags, syntax, mr, prefix,\n\t\tdnvalues, keysp, ctx );\n\n\tslap_sl_free( dnvalues, ctx );\n\treturn rc;\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":513312,"func":"static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse, \n                                   bool skip_unprefixed_keyparts)\n{\n  KEYUSE key_end, *prev, *save_pos, *use;\n  uint found_eq_constant, i;\n\n  DBUG_ASSERT(keyuse->elements);\n\n  my_qsort(keyuse->buffer, keyuse->elements, sizeof(KEYUSE),\n           (qsort_cmp) sort_keyuse);\n\n  bzero((char*) &key_end, sizeof(key_end));    \/* Add for easy testing *\/\n  if (insert_dynamic(keyuse, (uchar*) &key_end))\n    return TRUE;\n\n  if (optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_WITH_KEYS))\n    generate_derived_keys(keyuse);\n\n  use= save_pos= dynamic_element(keyuse,0,KEYUSE*);\n  prev= &key_end;\n  found_eq_constant= 0;\n  for (i=0 ; i < keyuse->elements-1 ; i++,use++)\n  {\n    if (!use->is_for_hash_join())\n    {\n      if (!(use->used_tables & ~OUTER_REF_TABLE_BIT) && \n          use->optimize != KEY_OPTIMIZE_REF_OR_NULL)\n        use->table->const_key_parts[use->key]|= use->keypart_map;\n      if (use->keypart != FT_KEYPART)\n      {\n        if (use->key == prev->key && use->table == prev->table)\n        {\n          if ((prev->keypart+1 < use->keypart && skip_unprefixed_keyparts) ||\n              (prev->keypart == use->keypart && found_eq_constant))\n            continue;\t\t\t\t\/* remove *\/\n        }\n        else if (use->keypart != 0 && skip_unprefixed_keyparts)\n          continue; \/* remove - first found must be 0 *\/\n      }\n\n      prev= use;\n      found_eq_constant= !use->used_tables;\n      use->table->reginfo.join_tab->checked_keys.set_bit(use->key);\n    }\n    \/*\n      Old gcc used a memcpy(), which is undefined if save_pos==use:\n      http:\/\/gcc.gnu.org\/bugzilla\/show_bug.cgi?id=19410\n      http:\/\/gcc.gnu.org\/bugzilla\/show_bug.cgi?id=39480\n      This also disables a valgrind warning, so better to have the test.\n    *\/\n    if (save_pos != use)\n      *save_pos= *use;\n    \/* Save ptr to first use *\/\n    if (!use->table->reginfo.join_tab->keyuse)\n      use->table->reginfo.join_tab->keyuse= save_pos;\n    save_pos++;\n  }\n  i= (uint) (save_pos-(KEYUSE*) keyuse->buffer);\n  (void) set_dynamic(keyuse,(uchar*) &key_end,i);\n  keyuse->elements= i;\n\n  return FALSE;\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":221166,"func":"GF_Err gf_odf_tx3g_write(GF_TextSampleDescriptor *a, u8 **outData, u32 *outSize)\n{\n\tu32 j;\n\tvoid gpp_write_rgba(GF_BitStream *bs, u32 col);\n\tvoid gpp_write_box(GF_BitStream *bs, GF_BoxRecord *rec);\n\tvoid gpp_write_style(GF_BitStream *bs, GF_StyleRecord *rec);\n\tGF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\n\tgf_bs_write_u8(bs, a->horiz_justif);\n\tgf_bs_write_u8(bs, a->vert_justif);\n\tgpp_write_rgba(bs, a->back_color);\n\tgpp_write_box(bs, &a->default_pos);\n\tgpp_write_style(bs, &a->default_style);\n\n\tgf_bs_write_u16(bs, a->font_count);\n\tfor (j=0; j<a->font_count; j++) {\n\t\tgf_bs_write_u16(bs, a->fonts[j].fontID);\n\t\tif (a->fonts[j].fontName) {\n\t\t\tu32 len = (u32) strlen(a->fonts[j].fontName);\n\t\t\tgf_bs_write_u8(bs, len);\n\t\t\tgf_bs_write_data(bs, a->fonts[j].fontName, len);\n\t\t} else {\n\t\t\tgf_bs_write_u8(bs, 0);\n\t\t}\n\t}\n\tgf_bs_get_content(bs, outData, outSize);\n\tgf_bs_del(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":512858,"func":"Item* Item_equal::get_first(JOIN_TAB *context, Item *field_item)\n{\n  Item_equal_fields_iterator it(*this);\n  Item *item;\n  if (!field_item)\n    return (it++);\n  Field *field= ((Item_field *) (field_item->real_item()))->field;\n\n  \/*\n    Of all equal fields, return the first one we can use. Normally, this is the\n    field which belongs to the table that is the first in the join order.\n\n    There is one exception to this: When semi-join materialization strategy is\n    used, and the given field belongs to a table within the semi-join nest, we\n    must pick the first field in the semi-join nest.\n\n    Example: suppose we have a join order:\n\n       ot1 ot2  SJ-Mat(it1  it2  it3)  ot3\n\n    and equality ot2.col = it1.col = it2.col\n    If we're looking for best substitute for 'it2.col', we should pick it1.col\n    and not ot2.col.\n    \n    eliminate_item_equal() also has code that deals with equality substitution\n    in presence of SJM nests.\n  *\/\n\n  TABLE_LIST *emb_nest;\n  if (context != NO_PARTICULAR_TAB)\n    emb_nest= context->emb_sj_nest;\n  else\n    emb_nest= field->table->pos_in_table_list->embedding;\n\n  if (emb_nest && emb_nest->sj_mat_info && emb_nest->sj_mat_info->is_used)\n  {\n    \/*\n      It's a field from an materialized semi-join. We can substitute it for\n       - a constant item \n       - a field from the same semi-join\n       Find the first of such items:\n    *\/\n    while ((item= it++))\n    {\n      if (item->const_item() || \n          it.get_curr_field()->table->pos_in_table_list->embedding == emb_nest)\n      {\n        \/*\n          If we found given field then return NULL to avoid unnecessary\n          substitution.\n        *\/\n        return (item != field_item) ? item : NULL;\n      }\n    }\n  }\n  else\n  {\n    \/*\n      The field is not in SJ-Materialization nest. We must return the first\n      field in the join order. The field may be inside a semi-join nest, i.e \n      a join order may look like this:\n\n          SJ-Mat(it1  it2)  ot1  ot2\n\n      where we're looking what to substitute ot2.col for. In this case we must \n      still return it1.col, here's a proof why:\n\n      First let's note that either it1.col or it2.col participates in \n      subquery's IN-equality. It can't be otherwise, because materialization is\n      only applicable to uncorrelated subqueries, so the only way we could\n      infer \"it1.col=ot1.col\" is from the IN-equality. Ok, so IN-eqality has \n      it1.col or it2.col on its inner side. it1.col is first such item in the\n      join order, so it's not possible for SJ-Mat to be\n      SJ-Materialization-lookup, it is SJ-Materialization-Scan. The scan part\n      of this strategy will unpack value of it1.col=it2.col into it1.col\n      (that's the first equal item inside the subquery), and we'll be able to\n      get it from there. qed.\n    *\/\n\n    return equal_items.head();\n  }\n  \/\/ Shouldn't get here.\n  DBUG_ASSERT(0);\n  return NULL;\n}","target":0,"code_token_length":781,"total_token_length":1017,"max_tokens_setting":1024}
+{"idx":383310,"func":"gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a)\n{\n  int c;\n  int ct = -1;\n  int op = -1;\n  long rd, gd, bd, ad, dist;\n  long mindist = 4 * 255 * 255;\t\/* init to max poss dist *\/\n  if (im->trueColor)\n    {\n      return gdTrueColorAlpha (r, g, b, a);\n    }\n\n  for (c = 0; c < im->colorsTotal; c++)\n    {\n      if (im->open[c])\n\t{\n\t  op = c;\t\t\/* Save open slot *\/\n\t  continue;\t\t\/* Color not in use *\/\n\t}\n      if (c == im->transparent)\n        {\n          \/* don't ever resolve to the color that has\n           * been designated as the transparent color *\/\n          continue;\n\t}\n      rd = (long) (im->red[c] - r);\n      gd = (long) (im->green[c] - g);\n      bd = (long) (im->blue[c] - b);\n      ad = (long) (im->alpha[c] - a);\n      dist = rd * rd + gd * gd + bd * bd + ad * ad;\n      if (dist < mindist)\n\t{\n\t  if (dist == 0)\n\t    {\n\t      return c;\t\t\/* Return exact match color *\/\n\t    }\n\t  mindist = dist;\n\t  ct = c;\n\t}\n    }\n  \/* no exact match.  We now know closest, but first try to allocate exact *\/\n  if (op == -1)\n    {\n      op = im->colorsTotal;\n      if (op == gdMaxColors)\n\t{\t\t\t\/* No room for more colors *\/\n\t  return ct;\t\t\/* Return closest available color *\/\n\t}\n      im->colorsTotal++;\n    }\n  im->red[op] = r;\n  im->green[op] = g;\n  im->blue[op] = b;\n  im->alpha[op] = a;\n  im->open[op] = 0;\n  return op;\t\t\t\/* Return newly allocated color *\/\n}","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":212955,"func":"static int ax25_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tax25_cb *ax25;\n\tax25_dev *ax25_dev;\n\n\tif (sk == NULL)\n\t\treturn 0;\n\n\tsock_hold(sk);\n\tlock_sock(sk);\n\tsock_orphan(sk);\n\tax25 = sk_to_ax25(sk);\n\tax25_dev = ax25->ax25_dev;\n\n\tif (sk->sk_type == SOCK_SEQPACKET) {\n\t\tswitch (ax25->state) {\n\t\tcase AX25_STATE_0:\n\t\t\trelease_sock(sk);\n\t\t\tax25_disconnect(ax25, 0);\n\t\t\tlock_sock(sk);\n\t\t\tax25_destroy_socket(ax25);\n\t\t\tbreak;\n\n\t\tcase AX25_STATE_1:\n\t\tcase AX25_STATE_2:\n\t\t\tax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);\n\t\t\trelease_sock(sk);\n\t\t\tax25_disconnect(ax25, 0);\n\t\t\tlock_sock(sk);\n\t\t\tif (!sock_flag(ax25->sk, SOCK_DESTROY))\n\t\t\t\tax25_destroy_socket(ax25);\n\t\t\tbreak;\n\n\t\tcase AX25_STATE_3:\n\t\tcase AX25_STATE_4:\n\t\t\tax25_clear_queues(ax25);\n\t\t\tax25->n2count = 0;\n\n\t\t\tswitch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {\n\t\t\tcase AX25_PROTO_STD_SIMPLEX:\n\t\t\tcase AX25_PROTO_STD_DUPLEX:\n\t\t\t\tax25_send_control(ax25,\n\t\t\t\t\t\t  AX25_DISC,\n\t\t\t\t\t\t  AX25_POLLON,\n\t\t\t\t\t\t  AX25_COMMAND);\n\t\t\t\tax25_stop_t2timer(ax25);\n\t\t\t\tax25_stop_t3timer(ax25);\n\t\t\t\tax25_stop_idletimer(ax25);\n\t\t\t\tbreak;\n#ifdef CONFIG_AX25_DAMA_SLAVE\n\t\t\tcase AX25_PROTO_DAMA_SLAVE:\n\t\t\t\tax25_stop_t3timer(ax25);\n\t\t\t\tax25_stop_idletimer(ax25);\n\t\t\t\tbreak;\n#endif\n\t\t\t}\n\t\t\tax25_calculate_t1(ax25);\n\t\t\tax25_start_t1timer(ax25);\n\t\t\tax25->state = AX25_STATE_2;\n\t\t\tsk->sk_state                = TCP_CLOSE;\n\t\t\tsk->sk_shutdown            |= SEND_SHUTDOWN;\n\t\t\tsk->sk_state_change(sk);\n\t\t\tsock_set_flag(sk, SOCK_DESTROY);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t} else {\n\t\tsk->sk_state     = TCP_CLOSE;\n\t\tsk->sk_shutdown |= SEND_SHUTDOWN;\n\t\tsk->sk_state_change(sk);\n\t\tax25_destroy_socket(ax25);\n\t}\n\tif (ax25_dev) {\n\t\tdev_put_track(ax25_dev->dev, &ax25_dev->dev_tracker);\n\t\tax25_dev_put(ax25_dev);\n\t}\n\n\tsock->sk   = NULL;\n\trelease_sock(sk);\n\tsock_put(sk);\n\n\treturn 0;\n}","target":1,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":459120,"func":"static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct nlattr *tca[TCA_MAX + 1];\n\tstruct Qdisc *q = NULL;\n\tstruct tcf_block *block;\n\tstruct tcmsg *tcm = nlmsg_data(cb->nlh);\n\tstruct tcf_chain *chain;\n\tlong index_start;\n\tlong index;\n\tint err;\n\n\tif (nlmsg_len(cb->nlh) < sizeof(*tcm))\n\t\treturn skb->len;\n\n\terr = nlmsg_parse_deprecated(cb->nlh, sizeof(*tcm), tca, TCA_MAX,\n\t\t\t\t     rtm_tca_policy, cb->extack);\n\tif (err)\n\t\treturn err;\n\n\tif (tcm->tcm_ifindex == TCM_IFINDEX_MAGIC_BLOCK) {\n\t\tblock = tcf_block_refcnt_get(net, tcm->tcm_block_index);\n\t\tif (!block)\n\t\t\tgoto out;\n\t} else {\n\t\tconst struct Qdisc_class_ops *cops;\n\t\tstruct net_device *dev;\n\t\tunsigned long cl = 0;\n\n\t\tdev = __dev_get_by_index(net, tcm->tcm_ifindex);\n\t\tif (!dev)\n\t\t\treturn skb->len;\n\n\t\tif (!tcm->tcm_parent)\n\t\t\tq = dev->qdisc;\n\t\telse\n\t\t\tq = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent));\n\n\t\tif (!q)\n\t\t\tgoto out;\n\t\tcops = q->ops->cl_ops;\n\t\tif (!cops)\n\t\t\tgoto out;\n\t\tif (!cops->tcf_block)\n\t\t\tgoto out;\n\t\tif (TC_H_MIN(tcm->tcm_parent)) {\n\t\t\tcl = cops->find(q, tcm->tcm_parent);\n\t\t\tif (cl == 0)\n\t\t\t\tgoto out;\n\t\t}\n\t\tblock = cops->tcf_block(q, cl, NULL);\n\t\tif (!block)\n\t\t\tgoto out;\n\t\tif (tcf_block_shared(block))\n\t\t\tq = NULL;\n\t}\n\n\tindex_start = cb->args[0];\n\tindex = 0;\n\n\tmutex_lock(&block->lock);\n\tlist_for_each_entry(chain, &block->chain_list, list) {\n\t\tif ((tca[TCA_CHAIN] &&\n\t\t     nla_get_u32(tca[TCA_CHAIN]) != chain->index))\n\t\t\tcontinue;\n\t\tif (index < index_start) {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (tcf_chain_held_by_acts_only(chain))\n\t\t\tcontinue;\n\t\terr = tc_chain_fill_node(chain->tmplt_ops, chain->tmplt_priv,\n\t\t\t\t\t chain->index, net, skb, block,\n\t\t\t\t\t NETLINK_CB(cb->skb).portid,\n\t\t\t\t\t cb->nlh->nlmsg_seq, NLM_F_MULTI,\n\t\t\t\t\t RTM_NEWCHAIN);\n\t\tif (err <= 0)\n\t\t\tbreak;\n\t\tindex++;\n\t}\n\tmutex_unlock(&block->lock);\n\n\tif (tcm->tcm_ifindex == TCM_IFINDEX_MAGIC_BLOCK)\n\t\ttcf_block_refcnt_put(block, true);\n\tcb->args[0] = index;\n\nout:\n\t\/* If we did no progress, the error (EMSGSIZE) is real *\/\n\tif (skb->len == 0 && err)\n\t\treturn err;\n\treturn skb->len;\n}","target":0,"code_token_length":693,"total_token_length":929,"max_tokens_setting":1024}
+{"idx":238385,"func":"njs_function_name_set(njs_vm_t *vm, njs_function_t *function,\n    njs_value_t *name, const char *prefix)\n{\n    u_char              *p;\n    size_t              len, symbol;\n    njs_int_t           ret;\n    njs_value_t         value;\n    njs_string_prop_t   string;\n    njs_object_prop_t   *prop;\n    njs_lvlhsh_query_t  lhq;\n\n    prop = njs_object_prop_alloc(vm, &njs_string_name, name, 0);\n    if (njs_slow_path(prop == NULL)) {\n        return NJS_ERROR;\n    }\n\n    symbol = 0;\n\n    if (njs_is_symbol(&prop->value)) {\n        symbol = 2;\n        prop->value = *njs_symbol_description(&prop->value);\n    }\n\n    if (prefix != NULL || symbol != 0) {\n        value = prop->value;\n        (void) njs_string_prop(&string, &value);\n\n        len = (prefix != NULL) ? njs_strlen(prefix) + 1: 0;\n        p = njs_string_alloc(vm, &prop->value, string.size + len + symbol,\n                             string.length + len + symbol);\n        if (njs_slow_path(p == NULL)) {\n            return NJS_ERROR;\n        }\n\n        if (len != 0) {\n            p = njs_cpymem(p, prefix, len - 1);\n            *p++ = ' ';\n        }\n\n        if (symbol != 0) {\n            *p++ = '[';\n        }\n\n        p = njs_cpymem(p, string.start, string.size);\n\n        if (symbol != 0) {\n            *p++ = ']';\n        }\n    }\n\n    prop->configurable = 1;\n\n    lhq.key_hash = NJS_NAME_HASH;\n    lhq.key = njs_str_value(\"name\");\n    lhq.replace = 0;\n    lhq.value = prop;\n    lhq.proto = &njs_object_hash_proto;\n    lhq.pool = vm->mem_pool;\n\n    ret = njs_lvlhsh_insert(&function->object.hash, &lhq);\n    if (njs_slow_path(ret != NJS_OK)) {\n        njs_internal_error(vm, \"lvlhsh insert failed\");\n        return NJS_ERROR;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":502,"total_token_length":738,"max_tokens_setting":1024}
+{"idx":411901,"func":"router_parse_addr_policy_item_from_string(const char *s, int assume_action)\n{\n  directory_token_t *tok = NULL;\n  const char *cp, *eos;\n  \/* Longest possible policy is \"accept ffff:ffff:..255\/ffff:...255:0-65535\".\n   * But note that there can be an arbitrary amount of space between the\n   * accept and the address:mask\/port element. *\/\n  char line[TOR_ADDR_BUF_LEN*2 + 32];\n  addr_policy_t *r;\n  memarea_t *area = NULL;\n\n  s = eat_whitespace(s);\n  if ((*s == '*' || TOR_ISDIGIT(*s)) && assume_action >= 0) {\n    if (tor_snprintf(line, sizeof(line), \"%s %s\",\n               assume_action == ADDR_POLICY_ACCEPT?\"accept\":\"reject\", s)<0) {\n      log_warn(LD_DIR, \"Policy %s is too long.\", escaped(s));\n      return NULL;\n    }\n    cp = line;\n    tor_strlower(line);\n  } else { \/* assume an already well-formed address policy line *\/\n    cp = s;\n  }\n\n  eos = cp + strlen(cp);\n  area = memarea_new();\n  tok = get_next_token(area, &cp, eos, routerdesc_token_table);\n  if (tok->tp == _ERR) {\n    log_warn(LD_DIR, \"Error reading address policy: %s\", tok->error);\n    goto err;\n  }\n  if (tok->tp != K_ACCEPT && tok->tp != K_ACCEPT6 &&\n      tok->tp != K_REJECT && tok->tp != K_REJECT6) {\n    log_warn(LD_DIR, \"Expected 'accept' or 'reject'.\");\n    goto err;\n  }\n\n  r = router_parse_addr_policy(tok);\n  goto done;\n err:\n  r = NULL;\n done:\n  token_clear(tok);\n  if (area) {\n    DUMP_AREA(area, \"policy item\");\n    memarea_drop_all(area);\n  }\n  return r;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":312422,"func":"qf_guess_filepath(qf_list_T *qfl, char_u *filename)\n{\n    struct dir_stack_T     *ds_ptr;\n    struct dir_stack_T     *ds_tmp;\n    char_u\t\t   *fullname;\n\n    \/\/ no dirs on the stack - there's nothing we can do\n    if (qfl->qf_dir_stack == NULL)\n\treturn NULL;\n\n    ds_ptr = qfl->qf_dir_stack->next;\n    fullname = NULL;\n    while (ds_ptr)\n    {\n\tvim_free(fullname);\n\tfullname = concat_fnames(ds_ptr->dirname, filename, TRUE);\n\n\t\/\/ If concat_fnames failed, just go on. The worst thing that can happen\n\t\/\/ is that we delete the entire stack.\n\tif ((fullname != NULL) && (mch_getperm(fullname) >= 0))\n\t    break;\n\n\tds_ptr = ds_ptr->next;\n    }\n\n    vim_free(fullname);\n\n    \/\/ clean up all dirs we already left\n    while (qfl->qf_dir_stack->next != ds_ptr)\n    {\n\tds_tmp = qfl->qf_dir_stack->next;\n\tqfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next;\n\tvim_free(ds_tmp->dirname);\n\tvim_free(ds_tmp);\n    }\n\n    return ds_ptr == NULL ? NULL : ds_ptr->dirname;\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":389681,"func":"tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)\n{\n    switch (varp->v_type)\n    {\n\tcase VAR_NUMBER:\n\t    if (strict)\n\t    {\n\t\temsg(_(e_using_number_as_string));\n\t\tbreak;\n\t    }\n\t    vim_snprintf((char *)buf, NUMBUFLEN, \"%lld\",\n\t\t\t\t\t    (varnumber_T)varp->vval.v_number);\n\t    return buf;\n\tcase VAR_FUNC:\n\tcase VAR_PARTIAL:\n\t    emsg(_(e_using_funcref_as_string));\n\t    break;\n\tcase VAR_LIST:\n\t    emsg(_(e_using_list_as_string));\n\t    break;\n\tcase VAR_DICT:\n\t    emsg(_(e_using_dictionary_as_string));\n\t    break;\n\tcase VAR_FLOAT:\n#ifdef FEAT_FLOAT\n\t    if (strict)\n\t    {\n\t\temsg(_(e_using_float_as_string));\n\t\tbreak;\n\t    }\n\t    vim_snprintf((char *)buf, NUMBUFLEN, \"%g\", varp->vval.v_float);\n\t    return buf;\n#endif\n\tcase VAR_STRING:\n\t    if (varp->vval.v_string != NULL)\n\t\treturn varp->vval.v_string;\n\t    return (char_u *)\"\";\n\tcase VAR_BOOL:\n\tcase VAR_SPECIAL:\n\t    STRCPY(buf, get_var_special_name(varp->vval.v_number));\n\t    return buf;\n\tcase VAR_BLOB:\n\t    emsg(_(e_using_blob_as_string));\n\t    break;\n\tcase VAR_JOB:\n#ifdef FEAT_JOB_CHANNEL\n\t    if (in_vim9script())\n\t    {\n\t\tsemsg(_(e_using_invalid_value_as_string_str), \"job\");\n\t\tbreak;\n\t    }\n\t    return job_to_string_buf(varp, buf);\n#endif\n\t    break;\n\tcase VAR_CHANNEL:\n#ifdef FEAT_JOB_CHANNEL\n\t    if (in_vim9script())\n\t    {\n\t\tsemsg(_(e_using_invalid_value_as_string_str), \"channel\");\n\t\tbreak;\n\t    }\n\t    return channel_to_string_buf(varp, buf);\n#endif\n\t    break;\n\tcase VAR_VOID:\n\t    emsg(_(e_cannot_use_void_value));\n\t    break;\n\tcase VAR_UNKNOWN:\n\tcase VAR_ANY:\n\tcase VAR_INSTR:\n\t    semsg(_(e_using_invalid_value_as_string_str),\n\t\t\t\t\t\t  vartype_name(varp->v_type));\n\t    break;\n    }\n    return NULL;\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":265541,"func":"int mempool_create(size_t pool_item_size, size_t pool_initial_size,\n                   size_t pool_expansion_size, size_t pool_max_threshold_size,\n                   func_log_callback_type log_callback_func, int flags,\n                   MemoryPoolHandle *handle) {\n  int rc;\n  int bufs_to_allocate;\n  struct mempool *pool = NULL;\n\n  \/* pool_max_threshold_size == 0 is possible when\n     func_mem_available_callback_type is used. *\/\n  if (pool_item_size == 0 || pool_expansion_size == 0 || handle == NULL) {\n    return S3_MEMPOOL_INVALID_ARG;\n  }\n\n  \/* Minimum size of the pool's buffer will be sizeof pointer *\/\n  if (pool_item_size < sizeof(struct memory_pool_element)) {\n    pool_item_size = sizeof(struct memory_pool_element);\n  }\n\n  *handle = NULL;\n\n  pool = (struct mempool *)calloc(1, sizeof(struct mempool));\n  if (pool == NULL) {\n    return S3_MEMPOOL_ERROR;\n  }\n\n  pool->flags |= flags;\n  pool->mempool_item_size = pool_item_size;\n  if (flags & CREATE_ALIGNED_MEMORY) {\n    pool->alignment = MEMORY_ALIGNMENT;\n  }\n\n  if ((pool->flags & ENABLE_LOCKING) != 0) {\n    rc = pthread_mutex_init(&pool->lock, NULL);\n    if (rc != 0) {\n      free(pool);\n      return S3_MEMPOOL_ERROR;\n    }\n  }\n\n  *handle = (MemoryPoolHandle)pool;\n\n  pool->log_callback_func = log_callback_func;\n  pool->expandable_size = pool_expansion_size;\n  pool->max_memory_threshold = pool_max_threshold_size;\n  \/* Figure out the size of free list to be preallocated from given initial pool\n   * size *\/\n  bufs_to_allocate = pool_initial_size \/ pool_item_size;\n\n  \/* Allocate the free list *\/\n  if (bufs_to_allocate > 0) {\n    rc = freelist_allocate(pool, bufs_to_allocate);\n    if (rc != 0) {\n      goto fail;\n    }\n  }\n  return 0;\n\nfail:\n  mempool_destroy(handle);\n  *handle = NULL;\n  return S3_MEMPOOL_ERROR;\n}","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":310136,"func":"decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro)\n{\n    bool result;\n    int button = 0;\n    int wheel = (intro & 96) == 96;\n\n    eventp->bstate = 0;\n\n    if (intro >= 96) {\n\tif (intro >= 160) {\n\t    button = (int) (intro - 152);\t\/* buttons 8-11 *\/\n\t} else if (intro >= 96) {\n\t    button = (int) (intro - 92);\t\/* buttons 4-7 *\/\n\t}\n    } else {\n\tbutton = (intro & 3);\n    }\n\n    if (button > MAX_BUTTONS) {\n\teventp->bstate = REPORT_MOUSE_POSITION;\n    } else if (!handle_wheel(sp, eventp, (int) intro, wheel)) {\n\n\t\/*\n\t * Release events aren't reported for individual buttons, just for\n\t * the button set as a whole.  However, because there are normally\n\t * no mouse events under xterm that intervene between press and\n\t * release, we can infer the button actually released by looking at\n\t * the previous event.\n\t *\/\n\tif (sp->_mouse_bstate & BUTTON_PRESSED) {\n\t    int b;\n\n\t    eventp->bstate = BUTTON_RELEASED;\n\t    for (b = 1; b <= MAX_BUTTONS; ++b) {\n\t\tif (!(sp->_mouse_bstate & MASK_PRESS(b)))\n\t\t    eventp->bstate &= ~MASK_RELEASE(b);\n\t    }\n\t    sp->_mouse_bstate = 0;\n\t} else {\n\t    \/*\n\t     * xterm will return a stream of release-events to let the\n\t     * application know where the mouse is going, if private mode\n\t     * 1002 or 1003 is enabled.\n\t     *\/\n\t    eventp->bstate = REPORT_MOUSE_POSITION;\n\t}\n    }\n\n    if (intro & 4) {\n\teventp->bstate |= BUTTON_SHIFT;\n    }\n    if (intro & 8) {\n\teventp->bstate |= BUTTON_ALT;\n    }\n    if (intro & 16) {\n\teventp->bstate |= BUTTON_CTRL;\n    }\n    result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;\n    return result;\n}","target":0,"code_token_length":496,"total_token_length":732,"max_tokens_setting":1024}
+{"idx":506429,"func":"rpa_check_message(const unsigned char *data, const unsigned char *end,\n\t\t  const char **error)\n{\n\tconst unsigned char *p = data;\n\tunsigned int len = 0;\n\n\tif (p + 2 > end) {\n\t\t*error = \"message too short\";\n\t\treturn NULL;\n\t}\n\n\tif (*p++ != ASN1_APPLICATION) {\n\t\t*error = \"invalid data type\";\n\t\treturn NULL;\n\t}\n\n\tif ((*p & 0x80) != 0) {\n\t\tunsigned int nbytes = *p++ & 0x7f;\n\n\t\twhile (nbytes-- > 0) {\n\t\t\tif (p >= end) {\n\t\t\t\t*error = \"invalid structure length\";\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tlen = (len << 8) | *p++;\n\t\t}\n\t} else\n\t\tlen = *p++;\n\n\tif ((size_t)(end - p) != len) {\n\t\t*error = \"structure length disagrees with data size\";\n\t\treturn NULL;\n\t}\n\n\tif (p + sizeof(rpa_oid) > end) {\n\t\t*error = \"not enough space for object id\";\n\t\treturn NULL;\n\t}\n\n\tif (memcmp(p, rpa_oid, sizeof(rpa_oid)) != 0) {\n\t\t*error = \"invalid object id\";\n\t\treturn NULL;\n\t}\n\n\treturn p + sizeof(rpa_oid);\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":517456,"func":"static void do_home_net(HttpResponse res) {\n        char buf[STRLEN];\n        boolean_t on = true;\n        boolean_t header = true;\n\n        for (Service_T s = servicelist_conf; s; s = s->next_conf) {\n                if (s->type != Service_Net)\n                        continue;\n                if (header) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<table id='header-row'>\"\n                                            \"<tr>\"\n                                            \"<th class='left first'>Net<\/th>\"\n                                            \"<th class='left'>Status<\/th>\"\n                                            \"<th class='right'>Upload<\/th>\"\n                                            \"<th class='right'>Download<\/th>\"\n                                            \"<\/tr>\");\n                        header = false;\n                }\n                StringBuffer_append(res->outputbuffer,\n                                    \"<tr %s>\"\n                                    \"<td class='left'><a href='%s'>%s<\/a><\/td>\"\n                                    \"<td class='left'>%s<\/td>\",\n                                    on ? \"class='stripe'\" : \"\",\n                                    s->name, s->name,\n                                    get_service_status(HTML, s, buf, sizeof(buf)));\n                if (! Util_hasServiceStatus(s) || Link_getState(s->inf.net->stats) != 1) {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%s/s<\/td>\", Fmt_bytes2str(Link_getBytesOutPerSecond(s->inf.net->stats), buf));\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%s/s<\/td>\", Fmt_bytes2str(Link_getBytesInPerSecond(s->inf.net->stats), buf));\n                }\n                StringBuffer_append(res->outputbuffer, \"<\/tr>\");\n                on = ! on;\n        }\n        if (! header)\n                StringBuffer_append(res->outputbuffer, \"<\/table>\");\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":218798,"func":"static void XDrawBeveledButton(Display *display,const XWindowInfo *window_info,\n  const XWidgetInfo *button_info)\n{\n  int\n    x,\n    y;\n\n  unsigned int\n    width;\n\n  XFontStruct\n    *font_info;\n\n  XRectangle\n    crop_info;\n\n  \/*\n    Draw matte.\n  *\/\n  XDrawBevel(display,window_info,button_info);\n  XSetMatteColor(display,window_info,button_info->raised);\n  (void) XFillRectangle(display,window_info->id,window_info->widget_context,\n    button_info->x,button_info->y,button_info->width,button_info->height);\n  x=button_info->x-button_info->bevel_width-1;\n  y=button_info->y-button_info->bevel_width-1;\n  (void) XSetForeground(display,window_info->widget_context,\n    window_info->pixel_info->trough_color.pixel);\n  if (button_info->raised || (window_info->depth == 1))\n    (void) XDrawRectangle(display,window_info->id,window_info->widget_context,\n      x,y,button_info->width+(button_info->bevel_width << 1)+1,\n      button_info->height+(button_info->bevel_width << 1)+1);\n  if (button_info->text == (char *) NULL)\n    return;\n  \/*\n    Set cropping region.\n  *\/\n  crop_info.width=(unsigned short) button_info->width;\n  crop_info.height=(unsigned short) button_info->height;\n  crop_info.x=button_info->x;\n  crop_info.y=button_info->y;\n  \/*\n    Draw text.\n  *\/\n  font_info=window_info->font_info;\n  width=WidgetTextWidth(font_info,button_info->text);\n  x=button_info->x+(QuantumMargin >> 1);\n  if (button_info->center)\n    x=button_info->x+(button_info->width >> 1)-(width >> 1);\n  y=button_info->y+((button_info->height-\n    (font_info->ascent+font_info->descent)) >> 1)+font_info->ascent;\n  if ((int) button_info->width == (QuantumMargin >> 1))\n    {\n      \/*\n        Option button-- write label to right of button.\n      *\/\n      XSetTextColor(display,window_info,MagickTrue);\n      x=button_info->x+button_info->width+button_info->bevel_width+\n        (QuantumMargin >> 1);\n      (void) XDrawString(display,window_info->id,window_info->widget_context,\n        x,y,button_info->text,Extent(button_info->text));\n      return;\n    }\n  (void) XSetClipRectangles(display,window_info->widget_context,0,0,&crop_info,\n    1,Unsorted);\n  XSetTextColor(display,window_info,button_info->raised);\n  (void) XDrawString(display,window_info->id,window_info->widget_context,x,y,\n    button_info->text,Extent(button_info->text));\n  (void) XSetClipMask(display,window_info->widget_context,None);\n  if (button_info->raised == MagickFalse)\n    XDelay(display,SuspendTime << 2);\n}","target":0,"code_token_length":696,"total_token_length":932,"max_tokens_setting":1024}
+{"idx":247743,"func":"TEST_P(SslSocketTest, TicketSessionResumptionDifferentServerNames) {\n  const std::string server_ctx_yaml1 = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n)EOF\";\n\n  const std::string server_ctx_yaml2 = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n)EOF\";\n\n  std::vector<std::string> server_names1 = {\"server1.example.com\"};\n\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  testTicketSessionResumption(server_ctx_yaml1, server_names1, server_ctx_yaml2, {},\n                              client_ctx_yaml, false, GetParam());\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":240290,"func":"get_yank_register(int regname, int writing)\n{\n    int\t    i;\n    int\t    ret = FALSE;\n\n    y_append = FALSE;\n    if ((regname == 0 || regname == '\"') && !writing && y_previous != NULL)\n    {\n\ty_current = y_previous;\n\treturn ret;\n    }\n    i = regname;\n    if (VIM_ISDIGIT(i))\n\ti -= '0';\n    else if (ASCII_ISLOWER(i))\n\ti = CharOrdLow(i) + 10;\n    else if (ASCII_ISUPPER(i))\n    {\n\ti = CharOrdUp(i) + 10;\n\ty_append = TRUE;\n    }\n    else if (regname == '-')\n\ti = DELETION_REGISTER;\n#ifdef FEAT_CLIPBOARD\n    \/\/ When selection is not available, use register 0 instead of '*'\n    else if (clip_star.available && regname == '*')\n    {\n\ti = STAR_REGISTER;\n\tret = TRUE;\n    }\n    \/\/ When clipboard is not available, use register 0 instead of '+'\n    else if (clip_plus.available && regname == '+')\n    {\n\ti = PLUS_REGISTER;\n\tret = TRUE;\n    }\n#endif\n#ifdef FEAT_DND\n    else if (!writing && regname == '~')\n\ti = TILDE_REGISTER;\n#endif\n    else\t\t\/\/ not 0-9, a-z, A-Z or '-': use register 0\n\ti = 0;\n    y_current = &(y_regs[i]);\n    if (writing)\t\/\/ remember the register we write into for do_put()\n\ty_previous = y_current;\n    return ret;\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":282855,"func":"int rsi_send_aggregation_params_frame(struct rsi_common *common,\n\t\t\t\t      u16 tid,\n\t\t\t\t      u16 ssn,\n\t\t\t\t      u8 buf_size,\n\t\t\t\t      u8 event,\n\t\t\t\t      u8 sta_id)\n{\n\tstruct sk_buff *skb = NULL;\n\tstruct rsi_aggr_params *aggr_params;\n\tu16 frame_len = sizeof(struct rsi_aggr_params);\n\n\tskb = dev_alloc_skb(frame_len);\n\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, frame_len);\n\taggr_params = (struct rsi_aggr_params *)skb->data;\n\n\trsi_dbg(MGMT_TX_ZONE, \"%s: Sending AMPDU indication frame\\n\", __func__);\n\n\trsi_set_len_qno(&aggr_params->desc_dword0.len_qno, 0, RSI_WIFI_MGMT_Q);\n\taggr_params->desc_dword0.frame_type = AMPDU_IND;\n\n\taggr_params->aggr_params = tid & RSI_AGGR_PARAMS_TID_MASK;\n\taggr_params->peer_id = sta_id;\n\tif (event == STA_TX_ADDBA_DONE) {\n\t\taggr_params->seq_start = cpu_to_le16(ssn);\n\t\taggr_params->baw_size = cpu_to_le16(buf_size);\n\t\taggr_params->aggr_params |= RSI_AGGR_PARAMS_START;\n\t} else if (event == STA_RX_ADDBA_DONE) {\n\t\taggr_params->seq_start = cpu_to_le16(ssn);\n\t\taggr_params->aggr_params |= (RSI_AGGR_PARAMS_START |\n\t\t\t\t\t     RSI_AGGR_PARAMS_RX_AGGR);\n\t} else if (event == STA_RX_DELBA) {\n\t\taggr_params->aggr_params |= RSI_AGGR_PARAMS_RX_AGGR;\n\t}\n\n\tskb_put(skb, frame_len);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":338136,"func":"bool WasmBinaryBuilder::maybeVisitTruncSat(Expression*& out, uint32_t code) {\n  Unary* curr;\n  switch (code) {\n    case BinaryConsts::I32STruncSatF32:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatSFloat32ToInt32;\n      break;\n    case BinaryConsts::I32UTruncSatF32:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatUFloat32ToInt32;\n      break;\n    case BinaryConsts::I32STruncSatF64:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatSFloat64ToInt32;\n      break;\n    case BinaryConsts::I32UTruncSatF64:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatUFloat64ToInt32;\n      break;\n    case BinaryConsts::I64STruncSatF32:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatSFloat32ToInt64;\n      break;\n    case BinaryConsts::I64UTruncSatF32:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatUFloat32ToInt64;\n      break;\n    case BinaryConsts::I64STruncSatF64:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatSFloat64ToInt64;\n      break;\n    case BinaryConsts::I64UTruncSatF64:\n      curr = allocator.alloc<Unary>();\n      curr->op = TruncSatUFloat64ToInt64;\n      break;\n    default:\n      return false;\n  }\n  BYN_TRACE(\"zz node: Unary (nontrapping float-to-int)\\n\");\n  curr->value = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":264697,"func":"lexer_check_numbers (parser_context_t *context_p, \/**< context *\/\n                     const uint8_t **source_p, \/**< source_pointer *\/\n                     const uint8_t *source_end_p, \/**< end of the source *\/\n                     const ecma_char_t digit_max, \/**< maximum of the number range *\/\n                     const bool is_legacy) \/**< is legacy octal number  *\/\n{\n#if !JERRY_ESNEXT\n  JERRY_UNUSED (context_p);\n  JERRY_UNUSED (is_legacy);\n#endif \/* !JERRY_ESNEXT *\/\n  while (true)\n  {\n    while (*source_p < source_end_p && *source_p[0] >= LIT_CHAR_0 && *source_p[0] <= digit_max)\n    {\n      *source_p += 1;\n    }\n#if JERRY_ESNEXT\n    if (*source_p != source_end_p && *source_p[0] == LIT_CHAR_UNDERSCORE)\n    {\n      *source_p += 1;\n      if (is_legacy || *source_p == source_end_p || *source_p[0] == LIT_CHAR_UNDERSCORE || *source_p[0] > digit_max\n          || *source_p[0] < LIT_CHAR_0)\n      {\n        parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);\n      }\n      continue;\n    }\n#endif \/* JERRY_ESNEXT *\/\n\n    break;\n  }\n} \/* lexer_check_numbers *\/","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":328891,"func":"R_API char *r_bin_java_print_float_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *value = malloc (size);\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%f\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tR_BIN_JAVA_FLOAT (obj->info.cp_float.bytes.raw, 0));\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size);\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%f\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\t\t\tR_BIN_JAVA_FLOAT (obj->info.cp_float.bytes.raw, 0));\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":391637,"func":"static void defer_open(struct share_mode_lock *lck,\n\t\t       struct timeval request_time,\n\t\t       struct timeval timeout,\n\t\t       struct smb_request *req,\n\t\t       struct deferred_open_record *state)\n{\n\tDEBUG(10,(\"defer_open_sharing_error: time [%u.%06u] adding deferred \"\n\t\t  \"open entry for mid %llu\\n\",\n\t\t  (unsigned int)request_time.tv_sec,\n\t\t  (unsigned int)request_time.tv_usec,\n\t\t  (unsigned long long)req->mid));\n\n\tif (!push_deferred_open_message_smb(req, request_time, timeout,\n\t\t\t\t       state->id, (char *)state, sizeof(*state))) {\n\t\tTALLOC_FREE(lck);\n\t\texit_server(\"push_deferred_open_message_smb failed\");\n\t}\n\tif (lck) {\n\t\tstruct defer_open_state *watch_state;\n\t\tstruct tevent_req *watch_req;\n\t\tbool ret;\n\n\t\twatch_state = talloc(req->sconn, struct defer_open_state);\n\t\tif (watch_state == NULL) {\n\t\t\texit_server(\"talloc failed\");\n\t\t}\n\t\twatch_state->sconn = req->sconn;\n\t\twatch_state->mid = req->mid;\n\n\t\tDEBUG(10, (\"defering mid %llu\\n\",\n\t\t\t   (unsigned long long)req->mid));\n\n\t\twatch_req = dbwrap_record_watch_send(\n\t\t\twatch_state, req->sconn->ev_ctx, lck->data->record,\n\t\t\treq->sconn->msg_ctx);\n\t\tif (watch_req == NULL) {\n\t\t\texit_server(\"Could not watch share mode record\");\n\t\t}\n\t\ttevent_req_set_callback(watch_req, defer_open_done,\n\t\t\t\t\twatch_state);\n\n\t\tret = tevent_req_set_endtime(\n\t\t\twatch_req, req->sconn->ev_ctx,\n\t\t\ttimeval_sum(&request_time, &timeout));\n\t\tSMB_ASSERT(ret);\n\t}\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":233820,"func":"static int decode_atari_image_paletted(deark *c, struct atari_img_decode_data *adata)\n{\n\ti64 i, j;\n\ti64 plane;\n\ti64 rowspan;\n\tu8 b;\n\tu32 v;\n\ti64 planespan;\n\ti64 ncolors;\n\n\tplanespan = 2*((adata->w+15)\/16);\n\trowspan = planespan*adata->bpp;\n\tif(adata->ncolors>0)\n\t\tncolors = adata->ncolors;\n\telse\n\t\tncolors = ((i64)1)<<adata->bpp;\n\n\tfor(j=0; j<adata->h; j++) {\n\t\tfor(i=0; i<adata->w; i++) {\n\t\t\tv = 0;\n\n\t\t\tfor(plane=0; plane<adata->bpp; plane++) {\n\t\t\t\tif(adata->was_compressed==0) {\n\t\t\t\t\t\/\/ TODO: Simplify this.\n\t\t\t\t\tif(adata->bpp==1) {\n\t\t\t\t\t\tb = de_get_bits_symbol(adata->unc_pixels, 1, j*rowspan, i);\n\t\t\t\t\t}\n\t\t\t\t\telse if(adata->bpp==2) {\n\t\t\t\t\t\tb = de_get_bits_symbol(adata->unc_pixels, 1,\n\t\t\t\t\t\t\tj*rowspan + 2*plane + (i\/16)*2, i);\n\t\t\t\t\t}\n\t\t\t\t\telse if(adata->bpp==4) {\n\t\t\t\t\t\tb = de_get_bits_symbol(adata->unc_pixels, 1,\n\t\t\t\t\t\t\tj*rowspan + 2*plane + (i\/2-(i\/2)%16)+8*((i%32)\/16), i%16);\n\t\t\t\t\t}\n\t\t\t\t\telse if(adata->bpp==8) {\n\t\t\t\t\t\tb = de_get_bits_symbol(adata->unc_pixels, 1,\n\t\t\t\t\t\t\tj*rowspan + 2*plane + (i-i%16), i%16);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tb = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tb = de_get_bits_symbol(adata->unc_pixels, 1, j*rowspan + plane*planespan, i);\n\t\t\t\t}\n\t\t\t\tif(b) v |= 1<<plane;\n\t\t\t}\n\n\t\t\tif(adata->is_spectrum512) {\n\t\t\t\tv = spectrum512_FindIndex(i, v);\n\t\t\t\tif(j>0) {\n\t\t\t\t\tv += (unsigned int)(48*(j));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(v>=(unsigned int)ncolors) v=(unsigned int)(ncolors-1);\n\n\t\t\tde_bitmap_setpixel_rgb(adata->img, i, j, adata->pal[v]);\n\t\t}\n\t}\n\treturn 1;\n}","target":0,"code_token_length":577,"total_token_length":813,"max_tokens_setting":1024}
+{"idx":462432,"func":"static rsRetVal startupUXSrv(ptcpsrv_t *pSrv) {\n\tDEFiRet;\n\tint sock;\n\tint sockflags;\n\tstruct sockaddr_un local;\n\n\tuchar *path = pSrv->path == NULL ? UCHAR_CONSTANT(\"\") : pSrv->path;\n\tDBGPRINTF(\"imptcp: creating listen unix socket at %s\\n\", path);\n\n\tsock = socket(AF_UNIX, SOCK_STREAM, 0);\n\tif(sock < 0) {\n\t\terrmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, \"imptcp: error creating unix socket\");\n\t\tABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);\n\t}\n\n\tlocal.sun_family = AF_UNIX;\n\tstrncpy(local.sun_path, (char*) path, sizeof(local.sun_path));\n\tif (pSrv->bUnlink) {\n\t\tunlink(local.sun_path);\n\t}\n\n\t\/* We use non-blocking IO! *\/\n\tif ((sockflags = fcntl(sock, F_GETFL)) != -1) {\n\t\tsockflags |= O_NONBLOCK;\n\t\t\/* SETFL could fail too, so get it caught by the subsequent error check. *\/\n\t\tsockflags = fcntl(sock, F_SETFL, sockflags);\n\t}\n\n\tif (sockflags == -1) {\n\t\terrmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, \"imptcp: error setting fcntl(O_NONBLOCK) on unix socket\");\n\t\tABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);\n\t}\n\n\tif (bind(sock, (struct sockaddr *)&local, SUN_LEN(&local)) < 0) {\n\t\terrmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, \"imptcp: error while binding unix socket\");\n\t\tABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);\n\t}\n\n\tif (listen(sock, 5) < 0) {\n\t\terrmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, \"imptcp: unix socket listen error\");\n\t\tABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);\n\t}\n\n\tif(chown(local.sun_path, pSrv->fileUID, pSrv->fileGID) != 0) {\n\t\tif(pSrv->bFailOnPerms) {\n\t\t\terrmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, \"imptcp: unix socket chown error\");\n\t\t\tABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);\n\t\t}\n\t}\n\n\tif(chmod(local.sun_path, pSrv->fCreateMode) != 0) {\n\t\tif(pSrv->bFailOnPerms) {\n\t\t\terrmsg.LogError(errno, RS_RET_ERR_CRE_AFUX, \"imptcp: unix socket chmod error\");\n\t\t\tABORT_FINALIZE(RS_RET_ERR_CRE_AFUX);\n\t\t}\n\t}\n\n\tCHKiRet(addLstn(pSrv, sock, 0));\n\nfinalize_it:\n\tif (iRet != RS_RET_OK) {\n\t\tif (sock != -1) {\n\t\t\tclose(sock);\n\t\t}\n\t}\n\n\tRETiRet;\n}","target":0,"code_token_length":626,"total_token_length":862,"max_tokens_setting":1024}
+{"idx":402591,"func":"generate_name(cms_context *cms, SECItem *der, CERTName *certname)\n{\n\tvoid *marka = PORT_ArenaMark(cms->arena);\n\tCERTRDN **rdns = certname->rdns;\n\tCERTRDN *rdn;\n\n\tint num_items = 0;\n\tint rc = 0;\n\n\twhile (rdns && (rdn = *rdns++) != NULL) {\n\t\tCERTAVA **avas = rdn->avas;\n\t\tCERTAVA *ava;\n\t\twhile (avas && (ava = *avas++) != NULL)\n\t\t\tnum_items++;\n\t}\n\n\tif (num_items == 0) {\n\t\tPORT_ArenaRelease(cms->arena, marka);\n\t\tcmsreterr(-1, cms, \"No name items to encode\");\n\t}\n\n\tSECItem items[num_items];\n\n\tint i = 0;\n\trdns = certname->rdns;\n\twhile (rdns && (rdn = *rdns++) != NULL) {\n\t\tCERTAVA **avas = rdn->avas;\n\t\tCERTAVA *ava;\n\t\twhile (avas && (ava = *avas++) != NULL) {\n\t\t\tSECItem avader;\n\t\t\trc = generate_ava(cms, &avader, ava);\n\t\t\tif (rc < 0) {\n\t\t\t\tPORT_ArenaRelease(cms->arena, marka);\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tSECItem *list[2] = {\n\t\t\t\t&avader,\n\t\t\t\tNULL,\n\t\t\t};\n\t\t\trc = wrap_in_set(cms, &items[i], list);\n\t\t\tif (rc < 0) {\n\t\t\t\tPORT_ArenaRelease(cms->arena, marka);\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\twrap_in_seq(cms, der, &items[0], num_items);\n\tPORT_ArenaUnmark(cms->arena, marka);\n\n\treturn 0;\n}","target":0,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":484782,"func":"static int setup_netfront(struct xenbus_device *dev,\n\t\t\tstruct netfront_queue *queue, unsigned int feature_split_evtchn)\n{\n\tstruct xen_netif_tx_sring *txs;\n\tstruct xen_netif_rx_sring *rxs;\n\tint err;\n\n\tqueue->tx_ring_ref = INVALID_GRANT_REF;\n\tqueue->rx_ring_ref = INVALID_GRANT_REF;\n\tqueue->rx.sring = NULL;\n\tqueue->tx.sring = NULL;\n\n\terr = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&txs,\n\t\t\t\t1, &queue->tx_ring_ref);\n\tif (err)\n\t\tgoto fail;\n\n\tXEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE);\n\n\terr = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&rxs,\n\t\t\t\t1, &queue->rx_ring_ref);\n\tif (err)\n\t\tgoto fail;\n\n\tXEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE);\n\n\tif (feature_split_evtchn)\n\t\terr = setup_netfront_split(queue);\n\t\/* setup single event channel if\n\t *  a) feature-split-event-channels == 0\n\t *  b) feature-split-event-channels == 1 but failed to setup\n\t *\/\n\tif (!feature_split_evtchn || err)\n\t\terr = setup_netfront_single(queue);\n\n\tif (err)\n\t\tgoto fail;\n\n\treturn 0;\n\n fail:\n\txenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref);\n\txenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref);\n\n\treturn err;\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":231789,"func":"TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterReset) {\n  server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 3;\n  std::array<std::string, 4> words = {\n      \"Hey Bob, this is Alice, for real.\",\n      \"What message did I send you last time?\",\n      \"You don't sound like Alice\",\n      \"You are a liar!\",\n  };\n\n  StreamId streamId1 = 0x00;\n  StreamId streamId2 = 0x04;\n  auto stream1 = server->getNonConstConn().streamManager->getStream(streamId1);\n  stream1->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false);\n  stream1->readBuffer.emplace_back(\n      IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false);\n  stream1->retransmissionBuffer.emplace(\n      std::piecewise_construct,\n      std::forward_as_tuple(0),\n      std::forward_as_tuple(std::make_unique<StreamBuffer>(\n          IOBuf::copyBuffer(words.at(2)), 0, false)));\n  stream1->writeBuffer.append(IOBuf::copyBuffer(words.at(3)));\n  stream1->currentWriteOffset = words.at(2).length() + words.at(3).length();\n  stream1->currentReadOffset = words.at(0).length() + words.at(1).length();\n  auto stream2 = server->getNonConstConn().streamManager->getStream(streamId2);\n  stream2->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false);\n  stream2->readBuffer.emplace_back(\n      IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false);\n  stream2->retransmissionBuffer.emplace(\n      std::piecewise_construct,\n      std::forward_as_tuple(0),\n      std::forward_as_tuple(std::make_unique<StreamBuffer>(\n          IOBuf::copyBuffer(words.at(2)), 0, false)));\n  stream2->writeBuffer.append(IOBuf::copyBuffer(words.at(3)));\n  stream2->currentWriteOffset = words.at(2).length() + words.at(3).length();\n  stream2->currentReadOffset = words.at(0).length() + words.at(1).length();\n\n  server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 5;\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n\n  StopSendingFrame stopSendingFrame1(\n      streamId1, GenericApplicationErrorCode::UNKNOWN);\n  StopSendingFrame stopSendingFrame2(\n      streamId2, GenericApplicationErrorCode::UNKNOWN);\n  ASSERT_TRUE(builder.canBuildPacket());\n  writeFrame(QuicSimpleFrame(stopSendingFrame1), builder);\n  writeFrame(QuicSimpleFrame(stopSendingFrame2), builder);\n  auto packet = std::move(builder).buildPacket();\n  EXPECT_CALL(\n      connCallback, onStopSending(_, GenericApplicationErrorCode::UNKNOWN))\n      .WillOnce(Invoke([&](StreamId \/*sid*\/, ApplicationErrorCode \/*e*\/) {\n        server->close(folly::none);\n      }));\n  EXPECT_THROW(deliverData(packetToBuf(packet)), std::runtime_error);\n}","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":486830,"func":"static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)\n{\n    CadenceGEMState *s;\n    uint32_t retval;\n    s = (CadenceGEMState *)opaque;\n\n    offset >>= 2;\n    retval = s->regs[offset];\n\n    DB_PRINT(\"offset: 0x%04x read: 0x%08x\\n\", (unsigned)offset*4, retval);\n\n    switch (offset) {\n    case GEM_ISR:\n        DB_PRINT(\"lowering irqs on ISR read\\n\");\n        \/* The interrupts get updated at the end of the function. *\/\n        break;\n    case GEM_PHYMNTNC:\n        if (retval & GEM_PHYMNTNC_OP_R) {\n            uint32_t phy_addr, reg_num;\n\n            phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;\n            if (phy_addr == s->phy_addr) {\n                reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;\n                retval &= 0xFFFF0000;\n                retval |= gem_phy_read(s, reg_num);\n            } else {\n                retval |= 0xFFFF; \/* No device at this address *\/\n            }\n        }\n        break;\n    }\n\n    \/* Squash read to clear bits *\/\n    s->regs[offset] &= ~(s->regs_rtc[offset]);\n\n    \/* Do not provide write only bits *\/\n    retval &= ~(s->regs_wo[offset]);\n\n    DB_PRINT(\"0x%08x\\n\", retval);\n    gem_update_int_status(s);\n    return retval;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":411918,"func":"tor_version_parse(const char *s, tor_version_t *out)\n{\n  char *eos=NULL;\n  const char *cp=NULL;\n  \/* Format is:\n   *   \"Tor \" ? NUM dot NUM dot NUM [ ( pre | rc | dot ) NUM [ - tag ] ]\n   *\/\n  tor_assert(s);\n  tor_assert(out);\n\n  memset(out, 0, sizeof(tor_version_t));\n\n  if (!strcasecmpstart(s, \"Tor \"))\n    s += 4;\n\n  \/* Get major. *\/\n  out->major = (int)strtol(s,&eos,10);\n  if (!eos || eos==s || *eos != '.') return -1;\n  cp = eos+1;\n\n  \/* Get minor *\/\n  out->minor = (int) strtol(cp,&eos,10);\n  if (!eos || eos==cp || *eos != '.') return -1;\n  cp = eos+1;\n\n  \/* Get micro *\/\n  out->micro = (int) strtol(cp,&eos,10);\n  if (!eos || eos==cp) return -1;\n  if (!*eos) {\n    out->status = VER_RELEASE;\n    out->patchlevel = 0;\n    return 0;\n  }\n  cp = eos;\n\n  \/* Get status *\/\n  if (*cp == '.') {\n    out->status = VER_RELEASE;\n    ++cp;\n  } else if (0==strncmp(cp, \"pre\", 3)) {\n    out->status = VER_PRE;\n    cp += 3;\n  } else if (0==strncmp(cp, \"rc\", 2)) {\n    out->status = VER_RC;\n    cp += 2;\n  } else {\n    return -1;\n  }\n\n  \/* Get patchlevel *\/\n  out->patchlevel = (int) strtol(cp,&eos,10);\n  if (!eos || eos==cp) return -1;\n  cp = eos;\n\n  \/* Get status tag. *\/\n  if (*cp == '-' || *cp == '.')\n    ++cp;\n  eos = (char*) find_whitespace(cp);\n  if (eos-cp >= (int)sizeof(out->status_tag))\n    strlcpy(out->status_tag, cp, sizeof(out->status_tag));\n  else {\n    memcpy(out->status_tag, cp, eos-cp);\n    out->status_tag[eos-cp] = 0;\n  }\n  cp = eat_whitespace(eos);\n\n  if (!strcmpstart(cp, \"(r\")) {\n    cp += 2;\n    out->svn_revision = (int) strtol(cp,&eos,10);\n  } else if (!strcmpstart(cp, \"(git-\")) {\n    char *close_paren = strchr(cp, ')');\n    int hexlen;\n    char digest[DIGEST_LEN];\n    if (! close_paren)\n      return -1;\n    cp += 5;\n    if (close_paren-cp > HEX_DIGEST_LEN)\n      return -1;\n    hexlen = (int)(close_paren-cp);\n    memset(digest, 0, sizeof(digest));\n    if ( hexlen == 0 || (hexlen % 2) == 1)\n      return -1;\n    if (base16_decode(digest, hexlen\/2, cp, hexlen))\n      return -1;\n    memcpy(out->git_tag, digest, hexlen\/2);\n    out->git_tag_len = hexlen\/2;\n  }\n\n  return 0;\n}","target":0,"code_token_length":724,"total_token_length":960,"max_tokens_setting":1024}
+{"idx":301427,"func":"static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void *data,\n\t\t\tsize_t n, off_t offset)\n{\n\tssize_t result;\n\n#if defined(HAVE_PREAD) || defined(HAVE_PREAD64)\n\tSTART_PROFILE_BYTES(syscall_pread, n);\n\tresult = sys_pread(fsp->fh->fd, data, n, offset);\n\tEND_PROFILE(syscall_pread);\n\n\tif (result == -1 && errno == ESPIPE) {\n\t\t\/* Maintain the fiction that pipes can be seeked (sought?) on. *\/\n\t\tresult = SMB_VFS_READ(fsp, data, n);\n\t\tfsp->fh->pos = 0;\n\t}\n\n#else \/* HAVE_PREAD *\/\n\toff_t   curr;\n\tint lerrno;\n\n\tcurr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);\n\tif (curr == -1 && errno == ESPIPE) {\n\t\t\/* Maintain the fiction that pipes can be seeked (sought?) on. *\/\n\t\tresult = SMB_VFS_READ(fsp, data, n);\n\t\tfsp->fh->pos = 0;\n\t\treturn result;\n\t}\n\n\tif (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {\n\t\treturn -1;\n\t}\n\n\terrno = 0;\n\tresult = SMB_VFS_READ(fsp, data, n);\n\tlerrno = errno;\n\n\tSMB_VFS_LSEEK(fsp, curr, SEEK_SET);\n\terrno = lerrno;\n\n#endif \/* HAVE_PREAD *\/\n\n\treturn result;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":424927,"func":"static ssize_t iwl_dbgfs_monitor_data_read(struct file *file,\n\t\t\t\t\t   char __user *user_buf,\n\t\t\t\t\t   size_t count, loff_t *ppos)\n{\n\tstruct iwl_trans *trans = file->private_data;\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tvoid *cpu_addr = (void *)trans->dbg.fw_mon[0].block, *curr_buf;\n\tstruct cont_rec *data = &trans_pcie->fw_mon_data;\n\tu32 write_ptr_addr, wrap_cnt_addr, write_ptr, wrap_cnt;\n\tssize_t size, bytes_copied = 0;\n\tbool b_full;\n\n\tif (trans->dbg.dest_tlv) {\n\t\twrite_ptr_addr =\n\t\t\tle32_to_cpu(trans->dbg.dest_tlv->write_ptr_reg);\n\t\twrap_cnt_addr = le32_to_cpu(trans->dbg.dest_tlv->wrap_count);\n\t} else {\n\t\twrite_ptr_addr = MON_BUFF_WRPTR;\n\t\twrap_cnt_addr = MON_BUFF_CYCLE_CNT;\n\t}\n\n\tif (unlikely(!trans->dbg.rec_on))\n\t\treturn 0;\n\n\tmutex_lock(&data->mutex);\n\tif (data->state ==\n\t    IWL_FW_MON_DBGFS_STATE_DISABLED) {\n\t\tmutex_unlock(&data->mutex);\n\t\treturn 0;\n\t}\n\n\t\/* write_ptr position in bytes rather then DW *\/\n\twrite_ptr = iwl_read_prph(trans, write_ptr_addr) * sizeof(u32);\n\twrap_cnt = iwl_read_prph(trans, wrap_cnt_addr);\n\n\tif (data->prev_wrap_cnt == wrap_cnt) {\n\t\tsize = write_ptr - data->prev_wr_ptr;\n\t\tcurr_buf = cpu_addr + data->prev_wr_ptr;\n\t\tb_full = iwl_write_to_user_buf(user_buf, count,\n\t\t\t\t\t       curr_buf, &size,\n\t\t\t\t\t       &bytes_copied);\n\t\tdata->prev_wr_ptr += size;\n\n\t} else if (data->prev_wrap_cnt == wrap_cnt - 1 &&\n\t\t   write_ptr < data->prev_wr_ptr) {\n\t\tsize = trans->dbg.fw_mon[0].size - data->prev_wr_ptr;\n\t\tcurr_buf = cpu_addr + data->prev_wr_ptr;\n\t\tb_full = iwl_write_to_user_buf(user_buf, count,\n\t\t\t\t\t       curr_buf, &size,\n\t\t\t\t\t       &bytes_copied);\n\t\tdata->prev_wr_ptr += size;\n\n\t\tif (!b_full) {\n\t\t\tsize = write_ptr;\n\t\t\tb_full = iwl_write_to_user_buf(user_buf, count,\n\t\t\t\t\t\t       cpu_addr, &size,\n\t\t\t\t\t\t       &bytes_copied);\n\t\t\tdata->prev_wr_ptr = size;\n\t\t\tdata->prev_wrap_cnt++;\n\t\t}\n\t} else {\n\t\tif (data->prev_wrap_cnt == wrap_cnt - 1 &&\n\t\t    write_ptr > data->prev_wr_ptr)\n\t\t\tIWL_WARN(trans,\n\t\t\t\t \"write pointer passed previous write pointer, start copying from the beginning\\n\");\n\t\telse if (!unlikely(data->prev_wrap_cnt == 0 &&\n\t\t\t\t   data->prev_wr_ptr == 0))\n\t\t\tIWL_WARN(trans,\n\t\t\t\t \"monitor data is out of sync, start copying from the beginning\\n\");\n\n\t\tsize = write_ptr;\n\t\tb_full = iwl_write_to_user_buf(user_buf, count,\n\t\t\t\t\t       cpu_addr, &size,\n\t\t\t\t\t       &bytes_copied);\n\t\tdata->prev_wr_ptr = size;\n\t\tdata->prev_wrap_cnt = wrap_cnt;\n\t}\n\n\tmutex_unlock(&data->mutex);\n\n\treturn bytes_copied;\n}","target":0,"code_token_length":725,"total_token_length":961,"max_tokens_setting":1024}
+{"idx":246742,"func":"static u64 do_size_top_boxes(char *inName, char *compress_top_boxes, u32 mode)\n{\n\tFILE *in;\n\tu64 top_size = 0;\n\tBool do_all = GF_FALSE;\n\tGF_BitStream *bs_in;\n\tif (!compress_top_boxes) return GF_BAD_PARAM;\n\tif (!strcmp(compress_top_boxes, \"all\") || !strcmp(compress_top_boxes, \"*\") || !strcmp(compress_top_boxes, \"@\"))\n\t\tdo_all = GF_TRUE;\n\n\tin = gf_fopen(inName, \"rb\");\n\tif (!in) return GF_URL_ERROR;\n\tbs_in = gf_bs_from_file(in, GF_BITSTREAM_READ);\n\twhile (gf_bs_available(bs_in)) {\n\t\tconst char *stype;\n\t\tu32 hdr_size = 8;\n\t\tu64 lsize = gf_bs_read_u32(bs_in);\n\t\tu32 type = gf_bs_read_u32(bs_in);\n\n\t\tif (lsize==1) {\n\t\t\tlsize = gf_bs_read_u64(bs_in);\n\t\t\thdr_size = 16;\n\t\t} else if (lsize==0) {\n\t\t\tlsize = gf_bs_available(bs_in) + 8;\n\t\t}\n\t\tstype = gf_4cc_to_str(type);\n\t\tif (do_all || strstr(compress_top_boxes, stype)) {\n\t\t\t\/\/only count boxes\n\t\t\tif (mode==2) {\n\t\t\t\ttop_size += 1;\n\t\t\t} else {\n\t\t\t\ttop_size += lsize;\n\t\t\t}\n\t\t}\n\t\tgf_bs_skip_bytes(bs_in, lsize - hdr_size);\n\t}\n\tgf_bs_del(bs_in);\n\tgf_fclose(in);\n\treturn top_size;\n\n}","target":0,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":437405,"func":"vhost_user_set_vring_num(struct virtio_net **pdev,\n\t\t\tstruct VhostUserMsg *msg,\n\t\t\tint main_fd __rte_unused)\n{\n\tstruct virtio_net *dev = *pdev;\n\tstruct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];\n\n\tvq->size = msg->payload.state.num;\n\n\t\/* VIRTIO 1.0, 2.4 Virtqueues says:\n\t *\n\t *   Queue Size value is always a power of 2. The maximum Queue Size\n\t *   value is 32768.\n\t *\/\n\tif ((vq->size & (vq->size - 1)) || vq->size > 32768) {\n\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\"invalid virtqueue size %u\\n\", vq->size);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tif (dev->dequeue_zero_copy) {\n\t\tvq->nr_zmbuf = 0;\n\t\tvq->last_zmbuf_idx = 0;\n\t\tvq->zmbuf_size = vq->size;\n\t\tvq->zmbufs = rte_zmalloc(NULL, vq->zmbuf_size *\n\t\t\t\t\t sizeof(struct zcopy_mbuf), 0);\n\t\tif (vq->zmbufs == NULL) {\n\t\t\tRTE_LOG(WARNING, VHOST_CONFIG,\n\t\t\t\t\"failed to allocate mem for zero copy; \"\n\t\t\t\t\"zero copy is force disabled\\n\");\n\t\t\tdev->dequeue_zero_copy = 0;\n\t\t}\n\t\tTAILQ_INIT(&vq->zmbuf_list);\n\t}\n\n\tif (vq_is_packed(dev)) {\n\t\tvq->shadow_used_packed = rte_malloc(NULL,\n\t\t\t\tvq->size *\n\t\t\t\tsizeof(struct vring_used_elem_packed),\n\t\t\t\tRTE_CACHE_LINE_SIZE);\n\t\tif (!vq->shadow_used_packed) {\n\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\n\t} else {\n\t\tvq->shadow_used_split = rte_malloc(NULL,\n\t\t\t\tvq->size * sizeof(struct vring_used_elem),\n\t\t\t\tRTE_CACHE_LINE_SIZE);\n\t\tif (!vq->shadow_used_split) {\n\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\t}\n\n\tvq->batch_copy_elems = rte_malloc(NULL,\n\t\t\t\tvq->size * sizeof(struct batch_copy_elem),\n\t\t\t\tRTE_CACHE_LINE_SIZE);\n\tif (!vq->batch_copy_elems) {\n\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\"failed to allocate memory for batching copy.\\n\");\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\treturn RTE_VHOST_MSG_RESULT_OK;\n}","target":0,"code_token_length":605,"total_token_length":841,"max_tokens_setting":1024}
+{"idx":252351,"func":"mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) {\n  if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))\n    return MZ_FALSE;\n\n  if (pZip->m_file_offset_alignment) {\n    \/\/ Ensure user specified file offset alignment is a power of 2.\n    if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1))\n      return MZ_FALSE;\n  }\n\n  if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func;\n  if (!pZip->m_pFree) pZip->m_pFree = def_free_func;\n  if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func;\n\n  pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;\n  pZip->m_archive_size = existing_size;\n  pZip->m_central_directory_file_ofs = 0;\n  pZip->m_total_files = 0;\n\n  if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(\n                   pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))\n    return MZ_FALSE;\n  memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir,\n                                sizeof(mz_uint8));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets,\n                                sizeof(mz_uint32));\n  MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets,\n                                sizeof(mz_uint32));\n  return MZ_TRUE;\n}","target":0,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":238638,"func":"static int check_ptr_to_btf_access(struct bpf_verifier_env *env,\n\t\t\t\t   struct bpf_reg_state *regs,\n\t\t\t\t   int regno, int off, int size,\n\t\t\t\t   enum bpf_access_type atype,\n\t\t\t\t   int value_regno)\n{\n\tstruct bpf_reg_state *reg = regs + regno;\n\tconst struct btf_type *t = btf_type_by_id(reg->btf, reg->btf_id);\n\tconst char *tname = btf_name_by_offset(reg->btf, t->name_off);\n\tu32 btf_id;\n\tint ret;\n\n\tif (off < 0) {\n\t\tverbose(env,\n\t\t\t\"R%d is ptr_%s invalid negative access: off=%d\\n\",\n\t\t\tregno, tname, off);\n\t\treturn -EACCES;\n\t}\n\tif (!tnum_is_const(reg->var_off) || reg->var_off.value) {\n\t\tchar tn_buf[48];\n\n\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\tverbose(env,\n\t\t\t\"R%d is ptr_%s invalid variable offset: off=%d, var_off=%s\\n\",\n\t\t\tregno, tname, off, tn_buf);\n\t\treturn -EACCES;\n\t}\n\n\tif (env->ops->btf_struct_access) {\n\t\tret = env->ops->btf_struct_access(&env->log, reg->btf, t,\n\t\t\t\t\t\t  off, size, atype, &btf_id);\n\t} else {\n\t\tif (atype != BPF_READ) {\n\t\t\tverbose(env, \"only read is supported\\n\");\n\t\t\treturn -EACCES;\n\t\t}\n\n\t\tret = btf_struct_access(&env->log, reg->btf, t, off, size,\n\t\t\t\t\tatype, &btf_id);\n\t}\n\n\tif (ret < 0)\n\t\treturn ret;\n\n\tif (atype == BPF_READ && value_regno >= 0)\n\t\tmark_btf_ld_reg(env, regs, value_regno, ret, reg->btf, btf_id);\n\n\treturn 0;\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":292167,"func":"void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,\n                                                  const methodHandle& resolved_method,\n                                                  Klass* resolved_klass,\n                                                  Handle recv,\n                                                  Klass* recv_klass,\n                                                  bool check_null_and_abstract,\n                                                  TRAPS) {\n\n  \/\/ setup default return values\n  int vtable_index = Method::invalid_vtable_index;\n  methodHandle selected_method;\n\n  \/\/ runtime method resolution\n  if (check_null_and_abstract && recv.is_null()) { \/\/ check if receiver exists\n    THROW(vmSymbols::java_lang_NullPointerException());\n  }\n\n  \/\/ Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s\n  \/\/ has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since\n  \/\/ a missing receiver might result in a bogus lookup.\n  assert(resolved_method->method_holder()->is_linked(), \"must be linked\");\n\n  \/\/ do lookup based on receiver klass using the vtable index\n  if (resolved_method->method_holder()->is_interface()) { \/\/ default or miranda method\n    vtable_index = vtable_index_of_interface_method(resolved_klass, resolved_method);\n    assert(vtable_index >= 0 , \"we should have valid vtable index at this point\");\n\n    selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));\n  } else {\n    \/\/ at this point we are sure that resolved_method is virtual and not\n    \/\/ a default or miranda method; therefore, it must have a valid vtable index.\n    assert(!resolved_method->has_itable_index(), \"\");\n    vtable_index = resolved_method->vtable_index();\n    \/\/ We could get a negative vtable_index of nonvirtual_vtable_index for private\n    \/\/ methods, or for final methods. Private methods never appear in the vtable\n    \/\/ and never override other methods. As an optimization, final methods are\n    \/\/ never put in the vtable, unless they override an existing method.\n    \/\/ So if we do get nonvirtual_vtable_index, it means the selected method is the\n    \/\/ resolved method, and it can never be changed by an override.\n    if (vtable_index == Method::nonvirtual_vtable_index) {\n      assert(resolved_method->can_be_statically_bound(), \"cannot override this method\");\n      selected_method = resolved_method;\n    } else {\n      selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index));\n    }\n  }\n\n  \/\/ check if method exists\n  if (selected_method.is_null()) {\n    throw_abstract_method_error(resolved_method, recv_klass, CHECK);\n  }\n\n  \/\/ check if abstract\n  if (check_null_and_abstract && selected_method->is_abstract()) {\n    \/\/ Pass arguments for generating a verbose error message.\n    throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK);\n  }\n\n  if (log_develop_is_enabled(Trace, vtables)) {\n    trace_method_resolution(\"invokevirtual selected method: receiver-class:\",\n                            recv_klass, resolved_klass, selected_method,\n                            false, vtable_index);\n  }\n  \/\/ setup result\n  result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK);\n}","target":0,"code_token_length":690,"total_token_length":926,"max_tokens_setting":1024}
+{"idx":247729,"func":"TEST_P(SslSocketTest, TestTransportSocketCallback) {\n  \/\/ Make MockTransportSocketCallbacks.\n  Network::MockIoHandle io_handle;\n  NiceMock<Network::MockTransportSocketCallbacks> callbacks;\n  ON_CALL(callbacks, ioHandle()).WillByDefault(ReturnRef(io_handle));\n\n  \/\/ Make SslSocket.\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext> factory_context;\n  Stats::TestUtil::TestStore stats_store;\n  ON_CALL(factory_context, stats()).WillByDefault(ReturnRef(stats_store));\n  NiceMock<LocalInfo::MockLocalInfo> local_info;\n  ON_CALL(factory_context, localInfo()).WillByDefault(ReturnRef(local_info));\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context;\n  auto client_cfg = std::make_unique<ClientContextConfigImpl>(tls_context, factory_context);\n\n  ContextManagerImpl manager(time_system_);\n  ClientSslSocketFactory client_ssl_socket_factory(std::move(client_cfg), manager, stats_store);\n\n  Network::TransportSocketPtr transport_socket =\n      client_ssl_socket_factory.createTransportSocket(nullptr);\n\n  SslSocket* ssl_socket = dynamic_cast<SslSocket*>(transport_socket.get());\n\n  \/\/ If no transport socket callbacks have been set, this method should return nullptr.\n  EXPECT_EQ(ssl_socket->transportSocketCallbacks(), nullptr);\n\n  \/\/ Otherwise, it should return a pointer to the set callbacks object.\n  ssl_socket->setTransportSocketCallbacks(callbacks);\n  EXPECT_EQ(ssl_socket->transportSocketCallbacks(), &callbacks);\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":259156,"func":"static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    MOVFragment *frag = &c->fragment;\n    AVStream *st = NULL;\n    MOVStreamContext *sc;\n    int version, i;\n    MOVFragmentStreamInfo * frag_stream_info;\n    int64_t base_media_decode_time;\n\n    for (i = 0; i < c->fc->nb_streams; i++) {\n        if (c->fc->streams[i]->id == frag->track_id) {\n            st = c->fc->streams[i];\n            break;\n        }\n    }\n    if (!st) {\n        av_log(c->fc, AV_LOG_WARNING, \"could not find corresponding track id %u\\n\", frag->track_id);\n        return 0;\n    }\n    sc = st->priv_data;\n    if (sc->pseudo_stream_id + 1 != frag->stsd_id && sc->pseudo_stream_id != -1)\n        return 0;\n    version = avio_r8(pb);\n    avio_rb24(pb); \/* flags *\/\n    if (version) {\n        base_media_decode_time = avio_rb64(pb);\n    } else {\n        base_media_decode_time = avio_rb32(pb);\n    }\n\n    frag_stream_info = get_current_frag_stream_info(&c->frag_index);\n    if (frag_stream_info)\n        frag_stream_info->tfdt_dts = base_media_decode_time;\n    sc->track_end = base_media_decode_time;\n\n    return 0;\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":432251,"func":"static void test_mem_protect_map_ptr(void)\n{\n    uc_engine *uc;\n    uint64_t val = 0x114514;\n    uint8_t *data1 = NULL;\n    uint8_t *data2 = NULL;\n    uint64_t mem;\n\n    data1 = calloc(sizeof(*data1), 0x4000);\n    data2 = calloc(sizeof(*data2), 0x2000);\n\n    OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));\n\n    OK(uc_mem_map_ptr(uc, 0x4000, 0x4000, UC_PROT_ALL, data1));\n    OK(uc_mem_unmap(uc, 0x6000, 0x2000));\n    OK(uc_mem_map_ptr(uc, 0x6000, 0x2000, UC_PROT_ALL, data2));\n\n    OK(uc_mem_write(uc, 0x6004, &val, 8));\n    OK(uc_mem_protect(uc, 0x6000, 0x1000, UC_PROT_READ));\n    OK(uc_mem_read(uc, 0x6004, (void *)&mem, 8));\n\n    TEST_CHECK(val == mem);\n\n    OK(uc_close(uc));\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":241043,"func":"int main(int argc, char *argv[], char *envp[])\n{\n\tint rv;\n\tconst char *cp;\n#ifdef LOGGING_LIBQB\n\tenum qb_log_target_slot i;\n#endif\n\n\tinit_set_proc_title(argc, argv, envp);\n\tget_time(&start_time);\n\n\tmemset(&cl, 0, sizeof(cl));\n\tstrncpy(cl.configfile,\n\t\t\tBOOTH_DEFAULT_CONF, BOOTH_PATH_LEN - 1);\n\tcl.lockfile[0] = 0;\n\tdebug_level = 0;\n\n\n\tcp = ((cp = strstr(argv[0], ATTR_PROG)) && !strcmp(cp, ATTR_PROG)\n\t\t? ATTR_PROG\n\t\t: \"booth\");\n#ifndef LOGGING_LIBQB\n\tcl_log_set_entity(cp);\n#else\n\tqb_log_init(cp, LOG_USER, LOG_DEBUG);  \/* prio driven by debug_level *\/\n\tfor (i = QB_LOG_TARGET_START; i < QB_LOG_TARGET_MAX; i++) {\n\t\tif (i == QB_LOG_SYSLOG || i == QB_LOG_BLACKBOX)\n\t\t\tcontinue;\n\t\tqb_log_format_set(i, \"%t %H %N: [%P]: %p: %b\");\n\t}\n\t(void) qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,\n\t                         QB_LOG_FILTER_FILE, \"*\", LOG_DEBUG);\n#endif\n\tcl_log_enable_stderr(TRUE);\n\tcl_log_set_facility(0);\n\n\trv = read_arguments(argc, argv);\n\tif (rv < 0)\n\t\tgoto out;\n\n\n\tswitch (cl.type) {\n\tcase STATUS:\n\t\trv = do_status(cl.type);\n\t\tbreak;\n\n\tcase ARBITRATOR:\n\tcase DAEMON:\n\tcase SITE:\n\t\trv = do_server(cl.type);\n\t\tbreak;\n\n\tcase CLIENT:\n\t\trv = do_client();\n\t\tbreak;\n\n\tcase GEOSTORE:\n\t\trv = do_attr();\n\t\tbreak;\n\t}\n\nout:\n#ifdef LOGGING_LIBQB\n\tqb_log_fini();\n#endif\n\t\/* Normalize values. 0x100 would be seen as \"OK\" by waitpid(). *\/\n\treturn (rv >= 0 && rv < 0x70) ? rv : 1;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":270776,"func":"int password(unsigned char *passwd, size_t length, int flags, int timeout)\n{\n\tunsigned char *buf = passwd;\n\tint pos = 0;\n\tunsigned char ch;\n\tuint64_t start;\n\n\tif (!passwd)\n\t\treturn -EINVAL;\n\n\tstart = get_time_ns();\n\n\tdo {\n\t\tif (tstc()) {\n\t\t\tch = getchar();\n\n\t\t\tswitch (ch) {\n\t\t\tcase '\\r':\n\t\t\tcase '\\n':\n\t\t\t\t*buf = '\\0';\n\t\t\t\tputs(\"\\r\\n\");\n\t\t\t\treturn pos;\n\t\t\tcase '\\0':\n\t\t\tcase '\\t':\n\t\t\t\tcontinue;\n\t\t\tcase CTL_CH('c'):\n\t\t\t\tpasswd[0] = '\\0';\n\t\t\t\tputs(\"\\r\\n\");\n\t\t\t\treturn -EINTR;\n\t\t\tcase CTL_CH('h'):\n\t\t\tcase BB_KEY_DEL7:\n\t\t\tcase BB_KEY_DEL:\n\t\t\t\tif (pos > 0) {\n\t\t\t\t\tif (flags & STAR)\n\t\t\t\t\t\tputs(\"\\b \\b\");\n\n\t\t\t\t\t*buf = '\\0';\n\t\t\t\t\tbuf--;\n\t\t\t\t\tpos--;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\tdefault:\n\t\t\t\tif (pos < length - 1) {\n\t\t\t\t\tif (flags & STAR)\n\t\t\t\t\t\tputchar('*');\n\t\t\t\t\telse if (flags & CLEAR)\n\t\t\t\t\t\tputchar(ch);\n\n\t\t\t\t\t*buf = ch;\n\t\t\t\t\tbuf++;\n\t\t\t\t\tpos++;\n\t\t\t\t} else {\n\t\t\t\t\tif (flags & STAR)\n\t\t\t\t\t\tputchar('\\a');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} while (!is_timeout(start, timeout * SECOND) || timeout == 0);\n\n\treturn -ETIMEDOUT;\n}","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":213589,"func":"process_button(struct parsed_tag *tag)\n{\n    Str tmp = NULL;\n    char *p, *q, *r, *qq = \"\";\n    int qlen, v;\n\n    if (cur_form_id < 0) {\n       char *s = \"<form_int method=internal action=none>\";\n       tmp = process_form(parse_tag(&s, TRUE));\n    }\n    if (tmp == NULL)\n       tmp = Strnew();\n\n    p = \"submit\";\n    parsedtag_get_value(tag, ATTR_TYPE, &p);\n    q = NULL;\n    parsedtag_get_value(tag, ATTR_VALUE, &q);\n    r = \"\";\n    parsedtag_get_value(tag, ATTR_NAME, &r);\n\n    v = formtype(p);\n    if (v == FORM_UNKNOWN)\n       return NULL;\n\n    if (!q) {\n       switch (v) {\n       case FORM_INPUT_SUBMIT:\n       case FORM_INPUT_BUTTON:\n           q = \"SUBMIT\";\n           break;\n       case FORM_INPUT_RESET:\n           q = \"RESET\";\n           break;\n       }\n    }\n    if (q) {\n       qq = html_quote(q);\n       qlen = strlen(q);\n    }\n\n    \/*    Strcat_charp(tmp, \"<pre_int>\"); *\/\n    Strcat(tmp, Sprintf(\"<input_alt hseq=\\\"%d\\\" fid=\\\"%d\\\" type=\\\"%s\\\" \"\n                       \"name=\\\"%s\\\" value=\\\"%s\\\">\",\n                       cur_hseq++, cur_form_id, html_quote(p),\n                       html_quote(r), qq));\n    return tmp;\n}","target":1,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":301369,"func":"static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,\n\t\t\t\t       struct files_struct *fsp,\n\t\t\t\t       const SMB_STRUCT_STAT *sbuf)\n{\n\tuint64_t result;\n\n\tSTART_PROFILE(syscall_get_alloc_size);\n\n\tif(S_ISDIR(sbuf->st_ex_mode)) {\n\t\tresult = 0;\n\t\tgoto out;\n\t}\n\n#if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)\n\t\/* The type of st_blocksize is blkcnt_t which *MUST* be\n\t   signed (according to POSIX) and can be less than 64-bits.\n\t   Ensure when we're converting to 64 bits wide we don't\n\t   sign extend. *\/\n#if defined(SIZEOF_BLKCNT_T_8)\n\tresult = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_ex_blocks;\n#elif defined(SIZEOF_BLKCNT_T_4)\n\t{\n\t\tuint64_t bs = ((uint64_t)sbuf->st_ex_blocks) & 0xFFFFFFFFLL;\n\t\tresult = (uint64_t)STAT_ST_BLOCKSIZE * bs;\n\t}\n#else\n#error SIZEOF_BLKCNT_T_NOT_A_SUPPORTED_VALUE\n#endif\n#else\n\tresult = get_file_size_stat(sbuf);\n#endif\n\n\tif (fsp && fsp->initial_allocation_size)\n\t\tresult = MAX(result,fsp->initial_allocation_size);\n\n\tresult = smb_roundup(handle->conn, result);\n\n out:\n\tEND_PROFILE(syscall_get_alloc_size);\n\treturn result;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":390533,"func":"XkbWriteGeomOverlay(char *wire,XkbOverlayPtr ol,Bool swap)\n{\nregister int\t\tr;\nXkbOverlayRowPtr\trow;\nxkbOverlayWireDesc *\tolWire;\n\n   olWire= (xkbOverlayWireDesc *)wire;\n   olWire->name= ol->name;\n   olWire->nRows= ol->num_rows;\n   if (swap) {\n\tregister int n;\n\tswapl(&olWire->name,n);\n   }\n   wire= (char *)&olWire[1];\n   for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {\n   \tunsigned int\t\tk;\n\tXkbOverlayKeyPtr\tkey;\n\txkbOverlayRowWireDesc *\trowWire;\n\trowWire= (xkbOverlayRowWireDesc *)wire;\n\trowWire->rowUnder= row->row_under;\n\trowWire->nKeys= row->num_keys;\n\twire= (char *)&rowWire[1];\n\tfor (k=0,key=row->keys;k<row->num_keys;k++,key++) {\n\t    xkbOverlayKeyWireDesc *\tkeyWire;\n\t    keyWire= (xkbOverlayKeyWireDesc *)wire;\n\t    memcpy(keyWire->over,key->over.name,XkbKeyNameLength);\n\t    memcpy(keyWire->under,key->under.name,XkbKeyNameLength);\n\t    wire= (char *)&keyWire[1];\n\t}\n   }\n   return wire;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":336588,"func":"static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)\n{\n    spice_debug(\"starting %s\", VERSION);\n\n    if (core_interface->base.major_version != SPICE_INTERFACE_CORE_MAJOR) {\n        spice_warning(\"bad core interface version\");\n        goto err;\n    }\n    reds->core = core_interface_adapter;\n    reds->core.public_interface = core_interface;\n    reds->agent_dev = red::make_shared<RedCharDeviceVDIPort>(reds);\n    reds_update_agent_properties(reds);\n    reds->main_dispatcher = red::make_shared<MainDispatcher>(reds);\n    reds->mig_target_clients = NULL;\n    reds->vm_running = TRUE; \/* for backward compatibility *\/\n\n    if (!(reds->mig_timer = reds->core.timer_new(migrate_timeout, reds))) {\n        spice_error(\"migration timer create failed\");\n    }\n    \/* Note that this will not actually send the mm_time to the client because\n     * the main channel is not connected yet. This would have been redundant\n     * with the RED_PIPE_ITEM_TYPE_MAIN_INIT message anyway.\n     *\/\n    reds_enable_mm_time(reds);\n\n    if (reds_init_net(reds) < 0) {\n        spice_warning(\"Failed to open SPICE sockets\");\n        goto err;\n    }\n    if (reds->secure_listen_socket != -1) {\n        if (reds_init_ssl(reds) < 0) {\n            goto err;\n        }\n    }\n#if HAVE_SASL\n    int saslerr;\n    if ((saslerr = sasl_server_init(NULL, reds->config->sasl_appname ?\n                                    reds->config->sasl_appname : \"spice\")) != SASL_OK) {\n        spice_error(\"Failed to initialize SASL auth %s\",\n                  sasl_errstring(saslerr, NULL, NULL));\n        goto err;\n    }\n#endif\n\n    reds->main_channel = main_channel_new(reds);\n    reds->inputs_channel = inputs_channel_new(reds);\n\n    reds->mouse_mode = SPICE_MOUSE_MODE_SERVER;\n\n    spice_buffer_free(&reds->client_monitors_config);\n\n    reds->allow_multiple_clients = getenv(SPICE_DEBUG_ALLOW_MC_ENV) != NULL;\n    if (reds->allow_multiple_clients) {\n        spice_warning(\"spice: allowing multiple client connections\");\n    }\n    pthread_mutex_lock(&global_reds_lock);\n    servers = g_list_prepend(servers, reds);\n    pthread_mutex_unlock(&global_reds_lock);\n    return 0;\n\nerr:\n    reds_cleanup_net(reds);\n    return -1;\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":300791,"func":"static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,\n\t\t\t\t   int dlen, long timeout)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;\n\tint blks = tsk_blocks(GROUP_H_SIZE + dlen);\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct net *net = sock_net(sk);\n\tstruct tipc_member *mb = NULL;\n\tu32 node, port;\n\tint rc;\n\n\tnode = ua->sk.node;\n\tport = ua->sk.ref;\n\tif (!port && !node)\n\t\treturn -EHOSTUNREACH;\n\n\t\/* Block or return if destination link or member is congested *\/\n\trc = tipc_wait_for_cond(sock, &timeout,\n\t\t\t\t!tipc_dest_find(&tsk->cong_links, node, 0) &&\n\t\t\t\ttsk->group &&\n\t\t\t\t!tipc_group_cong(tsk->group, node, port, blks,\n\t\t\t\t\t\t &mb));\n\tif (unlikely(rc))\n\t\treturn rc;\n\n\tif (unlikely(!mb))\n\t\treturn -EHOSTUNREACH;\n\n\trc = tipc_send_group_msg(net, tsk, m, mb, node, port, dlen);\n\n\treturn rc ? rc : dlen;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":473973,"func":"onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,\n                           UChar* pat, UChar* pat_end, const UChar *fmt, va_list args)\n{\n  size_t need;\n  int n, len;\n  UChar *p, *s, *bp;\n  UChar bs[6];\n\n  n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args);\n\n  need = (pat_end - pat) * 4 + 4;\n\n  if (n + need < (size_t)bufsize) {\n    strcat((char* )buf, \": \/\");\n    s = buf + onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, buf);\n\n    p = pat;\n    while (p < pat_end) {\n      if (*p == '\\\\') {\n\t*s++ = *p++;\n\tlen = enclen(enc, p, pat_end);\n\twhile (len-- > 0) *s++ = *p++;\n      }\n      else if (*p == '\/') {\n\t*s++ = (unsigned char )'\\\\';\n\t*s++ = *p++;\n      }\n      else if (ONIGENC_IS_MBC_HEAD(enc, p, pat_end)) {\n        len = enclen(enc, p, pat_end);\n        if (ONIGENC_MBC_MINLEN(enc) == 1) {\n          while (len-- > 0) *s++ = *p++;\n        }\n        else { \/* for UTF16 *\/\n          int blen;\n\n          while (len-- > 0) {\n            sprint_byte_with_x((char* )bs, (unsigned int )(*p++));\n            blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);\n            bp = bs;\n            while (blen-- > 0) *s++ = *bp++;\n          }\n        }\n      }\n      else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&\n\t       !ONIGENC_IS_CODE_SPACE(enc, *p)) {\n\tsprint_byte_with_x((char* )bs, (unsigned int )(*p++));\n\tlen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);\n        bp = bs;\n\twhile (len-- > 0) *s++ = *bp++;\n      }\n      else {\n\t*s++ = *p++;\n      }\n    }\n\n    *s++ = '\/';\n    *s   = '\\0';\n  }\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":489154,"func":"sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\t\tvoid *arg,\n\t\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\n\tif (!sctp_vtag_verify_either(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the ABORT chunk has a valid length.\n\t * Since this is an ABORT chunk, we have to discard it\n\t * because of the following text:\n\t * RFC 2960, Section 3.3.7\n\t *    If an endpoint receives an ABORT with a format error or for an\n\t *    association that doesn't exist, it MUST silently discard it.\n\t * Becasue the length is \"invalid\", we can't really discard just\n\t * as we do not know its true length.  So, to be safe, discard the\n\t * packet.\n\t *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t)))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* ADD-IP: Special case for ABORT chunks\n\t * F4)  One special consideration is that ABORT Chunks arriving\n\t * destined to the IP address being deleted MUST be\n\t * ignored (see Section 5.3.1 for further details).\n\t *\/\n\tif (SCTP_ADDR_DEL ==\n\t\t    sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))\n\t\treturn sctp_sf_discard_chunk(ep, asoc, type, arg, commands);\n\n\treturn __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands);\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":437363,"func":"setup_call(Node* node, ScanEnv* env, int state)\n{\n  int r;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n  case NODE_ALT:\n    do {\n      r = setup_call(NODE_CAR(node), env, state);\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_QUANT:\n    if (QUANT_(node)->upper == 0)\n      state |= IN_ZERO_REPEAT;\n\n    r = setup_call(NODE_BODY(node), env, state);\n    break;\n\n  case NODE_ANCHOR:\n    if (ANCHOR_HAS_BODY(ANCHOR_(node)))\n      r = setup_call(NODE_BODY(node), env, state);\n    else\n      r = 0;\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      if (en->type == ENCLOSURE_MEMORY) {\n        if ((state & IN_ZERO_REPEAT) != 0) {\n          NODE_STATUS_ADD(node, IN_ZERO_REPEAT);\n          ENCLOSURE_(node)->m.entry_count--;\n        }\n        r = setup_call(NODE_BODY(node), env, state);\n      }\n      else if (en->type == ENCLOSURE_IF_ELSE) {\n        r = setup_call(NODE_BODY(node), env, state);\n        if (r != 0) return r;\n        if (IS_NOT_NULL(en->te.Then)) {\n          r = setup_call(en->te.Then, env, state);\n          if (r != 0) return r;\n        }\n        if (IS_NOT_NULL(en->te.Else))\n          r = setup_call(en->te.Else, env, state);\n      }\n      else\n        r = setup_call(NODE_BODY(node), env, state);\n    }\n    break;\n\n  case NODE_CALL:\n    if ((state & IN_ZERO_REPEAT) != 0) {\n      NODE_STATUS_ADD(node, IN_ZERO_REPEAT);\n      CALL_(node)->entry_count--;\n    }\n\n    r = setup_call_node_call(CALL_(node), env, state);\n    break;\n\n  default:\n    r = 0;\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":462301,"func":"status_symbol_sets(stream * s, pcl_state_t * pcs, pcl_data_storage_t storage)\n{\n    gs_const_string key;\n    void *value;\n    pl_dict_enum_t denum;\n    ushort *idlist;\n    int nid;\n\n    if (storage == 0)\n        return 0;               \/* no \"currently selected\" symbol set *\/\n\n    \/* Note carefully the meaning of this status inquiry.  First,\n     * we return only symbol sets applicable to unbound fonts.  Second,\n     * the \"storage\" value refers to the location of fonts. *\/\n\n    \/* total up built-in symbol sets, downloaded ones *\/\n    nid = pl_dict_length(&pcs->soft_symbol_sets, false) +\n        pl_dict_length(&pcs->built_in_symbol_sets, false);\n    idlist = (ushort *) gs_alloc_bytes(pcs->memory, nid * sizeof(ushort),\n                                       \"status_symbol_sets(idlist)\");\n    if (idlist == NULL)\n        return e_Memory;\n    nid = 0;\n\n    \/* For each symbol set,\n     *   for each font in appropriate storage,\n     *     if the font supports that symbol set, list the symbol set\n     *     and break (because we only need to find one such font). *\/\n\n    \/* NOTE: Temporarily chain soft, built-in symbol sets.  DON'T\n     * exit this section without unchaining them. *\/\n    pl_dict_set_parent(&pcs->soft_symbol_sets, &pcs->built_in_symbol_sets);\n    pl_dict_enum_begin(&pcs->soft_symbol_sets, &denum);\n    while (pl_dict_enum_next(&denum, &key, &value)) {\n        pcl_symbol_set_t *ssp = (pcl_symbol_set_t *) value;\n        pl_glyph_vocabulary_t gx;\n\n        for (gx = plgv_MSL; gx < plgv_next; gx++)\n            if (ssp->maps[gx] != NULL &&\n                status_check_symbol_set(pcs, ssp->maps[gx], storage)) {\n                nid = status_add_symbol_id(idlist, nid,\n                                           (ssp->maps[gx]->id[0] << 8) +\n                                           ssp->maps[gx]->id[1]);\n                break;          \/* one will suffice *\/\n            }\n    }\n    pl_dict_set_parent(&pcs->soft_symbol_sets, NULL);\n    \/* Symbol sets are back to normal. *\/\n\n    status_print_idlist(s, idlist, nid, \"IDLIST\");\n    gs_free_object(pcs->memory, (void *)idlist, \"status_symbol_sets(idlist)\");\n    return 0;\n}","target":0,"code_token_length":536,"total_token_length":772,"max_tokens_setting":1024}
+{"idx":231045,"func":"BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,\r\n                              void * const pvBuffer )\r\n{\r\n    BaseType_t xReturn;\r\n    UBaseType_t uxSavedInterruptStatus;\r\n    int8_t * pcOriginalReadPosition;\r\n    Queue_t * const pxQueue = xQueue;\r\n\r\n    configASSERT( pxQueue );\r\n    configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r\n    configASSERT( pxQueue->uxItemSize != 0 ); \/* Can't peek a semaphore. *\/\r\n\r\n    \/* RTOS ports that support interrupt nesting have the concept of a maximum\r\n     * system call (or maximum API call) interrupt priority.  Interrupts that are\r\n     * above the maximum system call priority are kept permanently enabled, even\r\n     * when the RTOS kernel is in a critical section, but cannot make any calls to\r\n     * FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r\n     * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r\n     * failure if a FreeRTOS API function is called from an interrupt that has been\r\n     * assigned a priority above the configured maximum system call priority.\r\n     * Only FreeRTOS functions that end in FromISR can be called from interrupts\r\n     * that have been assigned a priority at or (logically) below the maximum\r\n     * system call interrupt priority.  FreeRTOS maintains a separate interrupt\r\n     * safe API to ensure interrupt entry is as fast and as simple as possible.\r\n     * More information (albeit Cortex-M specific) is provided on the following\r\n     * link: https:\/\/www.FreeRTOS.org\/RTOS-Cortex-M3-M4.html *\/\r\n    portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r\n\r\n    uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r\n    {\r\n        \/* Cannot block in an ISR, so check there is data available. *\/\r\n        if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r\n        {\r\n            traceQUEUE_PEEK_FROM_ISR( pxQueue );\r\n\r\n            \/* Remember the read position so it can be reset as nothing is\r\n             * actually being removed from the queue. *\/\r\n            pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom;\r\n            prvCopyDataFromQueue( pxQueue, pvBuffer );\r\n            pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition;\r\n\r\n            xReturn = pdPASS;\r\n        }\r\n        else\r\n        {\r\n            xReturn = pdFAIL;\r\n            traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );\r\n        }\r\n    }\r\n    portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r\n\r\n    return xReturn;\r\n}\r","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":517433,"func":"static char *get_service_status(Output_Type type, Service_T s, char *buf, int buflen) {\n        ASSERT(s);\n        ASSERT(buf);\n        if (s->monitor == Monitor_Not || s->monitor & Monitor_Init) {\n                get_monitoring_status(type, s, buf, buflen);\n        } else if (s->error == 0) {\n                snprintf(buf, buflen, type == HTML ? \"<span class='green-text'>OK<\/span>\" : Color_lightGreen(\"OK\"));\n        } else {\n                \/\/ In the case that the service has actualy some failure, the error bitmap will be non zero\n                char *p = buf;\n                EventTable_T *et = Event_Table;\n                while ((*et).id) {\n                        if (s->error & (*et).id) {\n                                if (p > buf)\n                                        p += snprintf(p, buflen - (p - buf), \" | \");\n                                if (s->error_hint & (*et).id) {\n                                        if (type == HTML)\n                                                p += snprintf(p, buflen - (p - buf), \"<span class='orange-text'>%s<\/span>\", (*et).description_changed);\n                                        else\n                                                p += snprintf(p, buflen - (p - buf), Color_lightYellow(\"%s\", (*et).description_changed));\n                                } else {\n                                        if (type == HTML)\n                                                p += snprintf(p, buflen - (p - buf), \"<span class='red-text'>%s<\/span>\", (*et).description_failed);\n                                        else\n                                                p += snprintf(p, buflen - (p - buf), Color_lightRed(\"%s\", (*et).description_failed));\n                                }\n                        }\n                        et++;\n                }\n        }\n        if (s->doaction)\n                snprintf(buf + strlen(buf), buflen - strlen(buf) - 1, \" - %s pending\", actionnames[s->doaction]);\n        return buf;\n}","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":259288,"func":"static int64_t get_frag_time(AVFormatContext *s, AVStream *dst_st,\n                             MOVFragmentIndex *frag_index, int index)\n{\n    MOVFragmentStreamInfo * frag_stream_info;\n    MOVStreamContext *sc = dst_st->priv_data;\n    int64_t timestamp;\n    int i, j;\n\n    \/\/ If the stream is referenced by any sidx, limit the search\n    \/\/ to fragments that referenced this stream in the sidx\n    if (sc->has_sidx) {\n        frag_stream_info = get_frag_stream_info(frag_index, index, dst_st->id);\n        if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)\n            return frag_stream_info->sidx_pts;\n        if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE)\n            return frag_stream_info->first_tfra_pts;\n        return frag_stream_info->sidx_pts;\n    }\n\n    for (i = 0; i < frag_index->item[index].nb_stream_info; i++) {\n        AVStream *frag_stream = NULL;\n        frag_stream_info = &frag_index->item[index].stream_info[i];\n        for (j = 0; j < s->nb_streams; j++)\n            if (s->streams[j]->id == frag_stream_info->id)\n                frag_stream = s->streams[j];\n        if (!frag_stream) {\n            av_log(s, AV_LOG_WARNING, \"No stream matching sidx ID found.\\n\");\n            continue;\n        }\n        timestamp = get_stream_info_time(frag_stream_info);\n        if (timestamp != AV_NOPTS_VALUE)\n            return av_rescale_q(timestamp, frag_stream->time_base, dst_st->time_base);\n    }\n    return AV_NOPTS_VALUE;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":198198,"func":"  void DoCompute(OpKernelContext* c) {\n    core::RefCountPtr<Var> v;\n    OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n    Tensor* params = v->tensor();\n    const Tensor& indices = c->input(1);\n    const Tensor& updates = c->input(2);\n\n    \/\/ Check that rank(updates.shape) = rank(indices.shape + params.shape[1:])\n    OP_REQUIRES(c,\n                updates.dims() == 0 ||\n                    updates.dims() == indices.dims() + params->dims() - 1,\n                errors::InvalidArgument(\n                    \"Must have updates.shape = indices.shape + \"\n                    \"params.shape[1:] or updates.shape = [], got \",\n                    \"updates.shape \", updates.shape().DebugString(),\n                    \", indices.shape \", indices.shape().DebugString(),\n                    \", params.shape \", params->shape().DebugString()));\n\n    \/\/ Check that we have enough index space\n    const int64_t N_big = indices.NumElements();\n    OP_REQUIRES(\n        c, N_big <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"indices has too many elements for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", N_big, \" > \",\n                                std::numeric_limits<Index>::max()));\n    const Index N = static_cast<Index>(N_big);\n    OP_REQUIRES(\n        c, params->dim_size(0) <= std::numeric_limits<Index>::max(),\n        errors::InvalidArgument(\"params.shape[0] too large for \",\n                                DataTypeString(DataTypeToEnum<Index>::v()),\n                                \" indexing: \", params->dim_size(0), \" > \",\n                                std::numeric_limits<Index>::max()));\n\n    if (N > 0) {\n      auto indices_flat = indices.flat<Index>();\n      auto params_flat = params->flat_outer_dims<T>();\n      if (TensorShapeUtils::IsScalar(updates.shape())) {\n        const auto update = updates.scalar<T>();\n\n        functor::ScatterScalarFunctor<Device, T, Index, op> functor;\n        const Index bad_i = functor(c, c->template eigen_device<Device>(),\n                                    params_flat, update, indices_flat);\n        OP_REQUIRES(c, bad_i < 0,\n                    errors::InvalidArgument(\n                        \"indices\", SliceDebugString(indices.shape(), bad_i),\n                        \" = \", indices_flat(bad_i), \" is not in [0, \",\n                        params->dim_size(0), \")\"));\n      } else {\n        int64_t num_updates = updates.NumElements();\n        OP_REQUIRES(c, num_updates % N == 0,\n                    errors::InvalidArgument(\n                        \"shape of indices (\", indices.shape().DebugString(),\n                        \") is not compatible with the shape of updates (\",\n                        updates.shape().DebugString(), \")\"));\n        auto updates_flat = updates.shaped<T, 2>({N, num_updates \/ N});\n\n        functor::ScatterFunctor<Device, T, Index, op> functor;\n        const Index bad_i = functor(c, c->template eigen_device<Device>(),\n                                    params_flat, updates_flat, indices_flat);\n        OP_REQUIRES(c, bad_i < 0,\n                    errors::InvalidArgument(\n                        \"indices\", SliceDebugString(indices.shape(), bad_i),\n                        \" = \", indices_flat(bad_i), \" is not in [0, \",\n                        params->dim_size(0), \")\"));\n      }\n    }\n  }","target":1,"code_token_length":729,"total_token_length":965,"max_tokens_setting":1024}
+{"idx":374046,"func":"static SymbolsMetadata parseMetadata(RBuffer *buf, int off) {\n\tSymbolsMetadata sm = { 0 };\n\tut8 b[0x100] = { 0 };\n\t(void)r_buf_read_at (buf, off, b, sizeof (b));\n\tsm.addr = off;\n\tsm.cputype = r_read_le32 (b);\n\tsm.arch = typeString (sm.cputype, &sm.bits);\n\t\/\/  eprintf (\"0x%08x  cputype  0x%x -> %s\\n\", 0x40, sm.cputype, typeString (sm.cputype));\n\t\/\/ bits = (strstr (typeString (sm.cputype, &sm.bits), \"64\"))? 64: 32;\n\tsm.subtype = r_read_le32 (b + 4);\n\tsm.cpu = subtypeString (sm.subtype);\n\t\/\/  eprintf (\"0x%08x  subtype  0x%x -> %s\\n\", 0x44, sm.subtype, subtypeString (sm.subtype));\n\tsm.n_segments = r_read_le32 (b + 8);\n\t\/\/ int count = r_read_le32 (b + 0x48);\n\tsm.namelen = r_read_le32 (b + 0xc);\n\t\/\/ eprintf (\"0x%08x  count    %d\\n\", 0x48, count);\n\t\/\/ eprintf (\"0x%08x  strlen   %d\\n\", 0x4c, sm.namelen);\n\t\/\/ eprintf (\"0x%08x  filename %s\\n\", 0x50, b + 16);\n\tint delta = 16;\n\t\/\/sm.segments = parseSegments (buf, off + sm.namelen + delta, sm.n_segments);\n\tsm.size = (sm.n_segments * 32) + sm.namelen + delta;\n\n\t\/\/ hack to detect format\n\tut32 nm, nm2, nm3;\n\tr_buf_read_at (buf, off + sm.size, (ut8 *)&nm, sizeof (nm));\n\tr_buf_read_at (buf, off + sm.size + 4, (ut8 *)&nm2, sizeof (nm2));\n\tr_buf_read_at (buf, off + sm.size + 8, (ut8 *)&nm3, sizeof (nm3));\n\t\/\/ eprintf (\"0x%x next %x %x %x\\n\", off + sm.size, nm, nm2, nm3);\n\tif (r_read_le32 (&nm3) != 0xa1b22b1a) {\n\t\tsm.size -= 8;\n\t\t\/\/\t\tis64 = true;\n\t}\n\treturn sm;\n}","target":0,"code_token_length":589,"total_token_length":825,"max_tokens_setting":1024}
+{"idx":522334,"func":"int GmfWriteByteFlow(int64_t MshIdx, char *BytTab, int NmbByt)\n{\n   int i, PadWrd = 0, *WrdTab = (int *)BytTab, NmbWrd = NmbByt \/ WrdSiz;\n\n   \/\/ Add an extra padding word at the end if needed\n   if(NmbByt > NmbWrd * 4)\n      PadWrd = 1;\n\n   \/\/ Create the keyword with the number of words, not bytes\n   if(!GmfSetKwd(MshIdx, GmfByteFlow, NmbWrd + PadWrd))\n      return(0);\n\n   \/\/ Reacord the exact number of bytes\n   GmfSetLin(MshIdx, GmfByteFlow, NmbByt);\n\n   \/\/ Write the byteflow as 4-byte words, missing up to 3 endding bytes\n   for(i=0;i<NmbWrd;i++)\n      GmfSetLin(MshIdx, GmfByteFlow, WrdTab[i]);\n\n   \/\/ Write the extra 1,2 or 3 ending bytes\n   if(PadWrd)\n   {\n      PadWrd = 0;\n\n      \/\/ Copy the last bytes in an integer\n      for(i=0; i<NmbByt - NmbWrd * 4; i++)\n         PadWrd |= BytTab[ NmbWrd * 4 + i ] << (i*8);\n\n      \/\/ And write it as the last line\n      GmfSetLin(MshIdx, GmfByteFlow, PadWrd);\n   }\n\n   return(1);\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":409503,"func":"term_color(char_u *s, int n)\n{\n    char\tbuf[20];\n    int\t\ti = *s == CSI ? 1 : 2;\n\t\t\/\/ index in s[] just after <Esc>[ or CSI\n\n    \/\/ Special handling of 16 colors, because termcap can't handle it\n    \/\/ Also accept \"\\e[3%dm\" for TERMINFO, it is sometimes used\n    \/\/ Also accept CSI instead of <Esc>[\n    if (n >= 8 && t_colors >= 16\n\t      && ((s[0] == ESC && s[1] == '[')\n#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)\n\t\t  || (s[0] == ESC && s[1] == '|')\n#endif\n\t\t  || (s[0] == CSI && (i = 1) == 1))\n\t      && s[i] != NUL\n\t      && (STRCMP(s + i + 1, \"%p1%dm\") == 0\n\t\t  || STRCMP(s + i + 1, \"%dm\") == 0)\n\t      && (s[i] == '3' || s[i] == '4'))\n    {\n#ifdef TERMINFO\n\tchar *format = \"%s%s%%p1%%dm\";\n#else\n\tchar *format = \"%s%s%%dm\";\n#endif\n\tchar *lead = i == 2 ? (\n#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)\n\t\t    s[1] == '|' ? \"\\033|\" :\n#endif\n\t\t    \"\\033[\") : \"\\233\";\n\tchar *tail = s[i] == '3' ? (n >= 16 ? \"38;5;\" : \"9\")\n\t\t\t\t : (n >= 16 ? \"48;5;\" : \"10\");\n\n\tsprintf(buf, format, lead, tail);\n\tOUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8));\n    }\n    else\n\tOUT_STR(tgoto((char *)s, 0, n));\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":195954,"func":"static pj_status_t parse_query(pj_dns_parsed_query *q, pj_pool_t *pool,\n\t\t\t       const pj_uint8_t *pkt, const pj_uint8_t *start,\n\t\t\t       const pj_uint8_t *max, int *parsed_len)\n{\n    const pj_uint8_t *p = start;\n    int name_len, name_part_len;\n    pj_status_t status;\n\n    \/* Get the length of the name *\/\n    status = get_name_len(0, pkt, start, max, &name_part_len, &name_len);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    \/* Allocate memory for the name *\/\n    q->name.ptr = (char*) pj_pool_alloc(pool, name_len+4);\n    q->name.slen = 0;\n\n    \/* Get the name *\/\n    status = get_name(0, pkt, start, max, &q->name);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    p = (start + name_part_len);\n\n    \/* Get the type *\/\n    pj_memcpy(&q->type, p, 2);\n    q->type = pj_ntohs(q->type);\n    p += 2;\n\n    \/* Get the class *\/\n    pj_memcpy(&q->dnsclass, p, 2);\n    q->dnsclass = pj_ntohs(q->dnsclass);\n    p += 2;\n\n    *parsed_len = (int)(p - start);\n\n    return PJ_SUCCESS;\n}","target":1,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":489139,"func":"static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,\n\t\t\t\t       const struct sctp_association *asoc,\n\t\t\t\t       struct sctp_chunk *init,\n\t\t\t\t       sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_transport *new_addr, *addr;\n\tint found;\n\n\t\/* Implementor's Guide - Sectin 5.2.2\n\t * ...\n\t * Before responding the endpoint MUST check to see if the\n\t * unexpected INIT adds new addresses to the association. If new\n\t * addresses are added to the association, the endpoint MUST respond\n\t * with an ABORT..\n\t *\/\n\n\t\/* Search through all current addresses and make sure\n\t * we aren't adding any new ones.\n\t *\/\n\tnew_addr = NULL;\n\tfound = 0;\n\n\tlist_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list,\n\t\t\ttransports) {\n\t\tfound = 0;\n\t\tlist_for_each_entry(addr, &asoc->peer.transport_addr_list,\n\t\t\t\ttransports) {\n\t\t\tif (sctp_cmp_addr_exact(&new_addr->ipaddr,\n\t\t\t\t\t\t&addr->ipaddr)) {\n\t\t\t\tfound = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!found)\n\t\t\tbreak;\n\t}\n\n\t\/* If a new address was added, ABORT the sender. *\/\n\tif (!found && new_addr) {\n\t\tsctp_sf_send_restart_abort(&new_addr->ipaddr, init, commands);\n\t}\n\n\t\/* Return success if all addresses were found. *\/\n\treturn found;\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":216767,"func":"static int smtp_command_parse_parameters(struct smtp_command_parser *parser)\n{\n\tconst unsigned char *p, *mp;\n\tuoff_t max_size = (parser->auth_response ?\n\t\tparser->limits.max_auth_size :\n\t\tparser->limits.max_parameters_size);\n\n\t\/* We assume parameters to match textstr (HT, SP, Printable US-ASCII).\n\t   For command parameters, we also accept valid UTF-8 characters.\n\t *\/\n\tp = parser->cur + parser->state.poff;\n\twhile (p < parser->end) {\n\t\tunichar_t ch;\n\t\tint nch = 1;\n\n\t\tif (parser->auth_response)\n\t\t\tch = *p;\n\t\telse {\n\t\t\tnch = uni_utf8_get_char_n(p, (size_t)(p - parser->end),\n\t\t\t\t\t\t  &ch);\n\t\t}\n\t\tif (nch < 0) {\n\t\t\tsmtp_command_parser_error(parser,\n\t\t\t\tSMTP_COMMAND_PARSE_ERROR_BAD_COMMAND,\n\t\t\t\t\"Invalid UTF-8 character in command parameters\");\n\t\t\treturn -1;\n\t\t}\n\t\tif ((parser->auth_response || (ch & 0x80) == 0x00) &&\n\t\t    !smtp_char_is_textstr((unsigned char)ch))\n\t\t\tbreak;\n\t\tp += nch;\n\t}\n\tif (max_size > 0 && (uoff_t)(p - parser->cur) > max_size) {\n\t\tsmtp_command_parser_error(parser,\n\t\t\tSMTP_COMMAND_PARSE_ERROR_LINE_TOO_LONG,\n\t\t\t\"%s line is too long\",\n\t\t\t(parser->auth_response ?\n\t\t\t\t\"AUTH response\" : \"Command\"));\n\t\treturn -1;\n\t}\n\tparser->state.poff = p - parser->cur;\n\tif (p == parser->end)\n\t\treturn 0;\n\n\t\/* In the interest of improved interoperability, SMTP receivers SHOULD\n\t   tolerate trailing white space before the terminating <CRLF>.\n\n\t   WSP =  SP \/ HTAB ; white space\n\n\t   --> Trim the end of the buffer\n\t *\/\n\tmp = p;\n\tif (mp > parser->cur) {\n\t\twhile (mp > parser->cur && (*(mp-1) == ' ' || *(mp-1) == '\\t'))\n\t\t\tmp--;\n\t}\n\n\tif (!parser->auth_response && mp > parser->cur && *parser->cur == ' ') {\n\t\tsmtp_command_parser_error(parser,\n\t\t\tSMTP_COMMAND_PARSE_ERROR_BAD_COMMAND,\n\t\t\t\"Duplicate space after command name\");\n\t\treturn -1;\n\t}\n\n\tparser->state.cmd_params = i_strdup_until(parser->cur, mp);\n\tparser->cur = p;\n\tparser->state.poff = 0;\n\treturn 1;\n}","target":1,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":508306,"func":"void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,\n                             const MDL_savepoint &start_of_statement_svp)\n{\n  TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();\n  TABLE_LIST *tmp;\n\n  \/*\n    If table list consists only from tables from prelocking set, table list\n    for new attempt should be empty, so we have to update list's root pointer.\n  *\/\n  if (first_not_own_table == *tables)\n    *tables= 0;\n  thd->lex->chop_off_not_own_tables();\n  \/* Reset MDL tickets for procedures\/functions *\/\n  for (Sroutine_hash_entry *rt=\n         (Sroutine_hash_entry*)thd->lex->sroutines_list.first;\n       rt; rt= rt->next)\n    rt->mdl_request.ticket= NULL;\n  sp_remove_not_own_routines(thd->lex);\n  for (tmp= *tables; tmp; tmp= tmp->next_global)\n  {\n    tmp->table= 0;\n    tmp->mdl_request.ticket= NULL;\n    \/* We have to cleanup translation tables of views. *\/\n    tmp->cleanup_items();\n  }\n  \/*\n    No need to commit\/rollback the statement transaction: it's\n    either not started or we're filling in an INFORMATION_SCHEMA\n    table on the fly, and thus mustn't manipulate with the\n    transaction of the enclosing statement.\n  *\/\n  DBUG_ASSERT(thd->transaction.stmt.is_empty() ||\n              (thd->state_flags & Open_tables_state::BACKUPS_AVAIL));\n  close_thread_tables(thd);\n  thd->mdl_context.rollback_to_savepoint(start_of_statement_svp);\n}","target":0,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":242964,"func":"int mbedtls_ssl_check_record( mbedtls_ssl_context const *ssl,\n                              unsigned char *buf,\n                              size_t buflen )\n{\n    int ret = 0;\n    MBEDTLS_SSL_DEBUG_MSG( 1, ( \"=> mbedtls_ssl_check_record\" ) );\n    MBEDTLS_SSL_DEBUG_BUF( 3, \"record buffer\", buf, buflen );\n\n    \/* We don't support record checking in TLS because\n     * (a) there doesn't seem to be a usecase for it, and\n     * (b) In SSLv3 and TLS 1.0, CBC record decryption has state\n     *     and we'd need to backup the transform here.\n     *\/\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM )\n    {\n        ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;\n        goto exit;\n    }\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    else\n    {\n        mbedtls_record rec;\n\n        ret = ssl_parse_record_header( ssl, buf, buflen, &rec );\n        if( ret != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 3, \"ssl_parse_record_header\", ret );\n            goto exit;\n        }\n\n        if( ssl->transform_in != NULL )\n        {\n            ret = mbedtls_ssl_decrypt_buf( ssl, ssl->transform_in, &rec );\n            if( ret != 0 )\n            {\n                MBEDTLS_SSL_DEBUG_RET( 3, \"mbedtls_ssl_decrypt_buf\", ret );\n                goto exit;\n            }\n        }\n    }\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\nexit:\n    \/* On success, we have decrypted the buffer in-place, so make\n     * sure we don't leak any plaintext data. *\/\n    mbedtls_platform_zeroize( buf, buflen );\n\n    \/* For the purpose of this API, treat messages with unexpected CID\n     * as well as such from future epochs as unexpected. *\/\n    if( ret == MBEDTLS_ERR_SSL_UNEXPECTED_CID ||\n        ret == MBEDTLS_ERR_SSL_EARLY_MESSAGE )\n    {\n        ret = MBEDTLS_ERR_SSL_UNEXPECTED_RECORD;\n    }\n\n    MBEDTLS_SSL_DEBUG_MSG( 1, ( \"<= mbedtls_ssl_check_record\" ) );\n    return( ret );\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":292170,"func":"void LinkResolver::check_method_accessability(Klass* ref_klass,\n                                              Klass* resolved_klass,\n                                              Klass* sel_klass,\n                                              const methodHandle& sel_method,\n                                              TRAPS) {\n\n  AccessFlags flags = sel_method->access_flags();\n\n  \/\/ Special case:  arrays always override \"clone\". JVMS 2.15.\n  \/\/ If the resolved klass is an array class, and the declaring class\n  \/\/ is java.lang.Object and the method is \"clone\", set the flags\n  \/\/ to public.\n  \/\/\n  \/\/ We'll check for the method name first, as that's most likely\n  \/\/ to be false (so we'll short-circuit out of these tests).\n  if (sel_method->name() == vmSymbols::clone_name() &&\n      sel_klass == SystemDictionary::Object_klass() &&\n      resolved_klass->is_array_klass()) {\n    \/\/ We need to change \"protected\" to \"public\".\n    assert(flags.is_protected(), \"clone not protected?\");\n    jint new_flags = flags.as_int();\n    new_flags = new_flags & (~JVM_ACC_PROTECTED);\n    new_flags = new_flags | JVM_ACC_PUBLIC;\n    flags.set_flags(new_flags);\n  }\n\/\/  assert(extra_arg_result_or_null != NULL, \"must be able to return extra argument\");\n\n  bool can_access = Reflection::verify_member_access(ref_klass,\n                                                     resolved_klass,\n                                                     sel_klass,\n                                                     flags,\n                                                     true, false, CHECK);\n  \/\/ Any existing exceptions that may have been thrown, for example LinkageErrors\n  \/\/ from nest-host resolution, have been allowed to propagate.\n  if (!can_access) {\n    ResourceMark rm(THREAD);\n    bool same_module = (sel_klass->module() == ref_klass->module());\n    Exceptions::fthrow(\n      THREAD_AND_LOCATION,\n      vmSymbols::java_lang_IllegalAccessError(),\n      \"class %s tried to access %s%s%smethod '%s' (%s%s%s)\",\n      ref_klass->external_name(),\n      sel_method->is_abstract()  ? \"abstract \"  : \"\",\n      sel_method->is_protected() ? \"protected \" : \"\",\n      sel_method->is_private()   ? \"private \"   : \"\",\n      sel_method->external_name(),\n      (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),\n      (same_module) ? \"\" : \"; \",\n      (same_module) ? \"\" : sel_klass->class_in_module_of_loader()\n    );\n    return;\n  }\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":225495,"func":"Status MutableGraphView::SwapRegularFaninsByPorts(absl::string_view node_name,\n                                                  int from_port, int to_port) {\n  auto error_status = [node_name, from_port, to_port](absl::string_view msg) {\n    string params = absl::Substitute(\"node_name='$0', from_port=$1, to_port=$2\",\n                                     node_name, from_port, to_port);\n    return MutationError(\"SwapRegularFaninsByPorts\", params, msg);\n  };\n\n  NodeDef* node = GetNode(node_name);\n  TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));\n  const int last_regular_fanin_port =\n      gtl::FindWithDefault(max_regular_input_port(), node, -1);\n  TF_RETURN_IF_ERROR(CheckPortRange(from_port, \/*min=*\/0,\n                                    last_regular_fanin_port, error_status));\n  TF_RETURN_IF_ERROR(CheckPortRange(to_port, \/*min=*\/0, last_regular_fanin_port,\n                                    error_status));\n\n  if (from_port == to_port) {\n    return Status::OK();\n  }\n  TensorId from_fanin = ParseTensorName(node->input(from_port));\n  TensorId to_fanin = ParseTensorName(node->input(to_port));\n  if (from_fanin == to_fanin) {\n    return Status::OK();\n  }\n\n  InputPort from_input(node, from_port);\n  InputPort to_input(node, to_port);\n  NodeDef* from_fanin_node = GetNode(from_fanin.node());\n  absl::flat_hash_set<InputPort>* from_fanouts =\n      &fanouts()[{from_fanin_node, from_fanin.index()}];\n  from_fanouts->erase(from_input);\n  from_fanouts->insert(to_input);\n  NodeDef* to_fanin_node = GetNode(to_fanin.node());\n  absl::flat_hash_set<InputPort>* to_fanouts =\n      &fanouts()[{to_fanin_node, to_fanin.index()}];\n  to_fanouts->erase(to_input);\n  to_fanouts->insert(from_input);\n\n  node->mutable_input()->SwapElements(from_port, to_port);\n\n  return Status::OK();\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":244321,"func":"GF_Err saio_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_SampleAuxiliaryInfoOffsetBox *ptr = (GF_SampleAuxiliaryInfoOffsetBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tif (ptr->flags & 1) {\n\t\tgf_bs_write_u32(bs, ptr->aux_info_type);\n\t\tgf_bs_write_u32(bs, ptr->aux_info_type_parameter);\n\t}\n\n\n\tgf_bs_write_u32(bs, ptr->entry_count);\n\tif (ptr->entry_count) {\n\t\tu32 i;\n\t\tif (ptr->sai_data) {\n\t\t\tif (ptr->sai_data->sai_offset) {\n\t\t\t\tif (ptr->version==0) {\n\t\t\t\t\tgf_bs_write_u32(bs, (u32) ptr->sai_data->sai_offset);\n\t\t\t\t} else {\n\t\t\t\t\tgf_bs_write_u64(bs, ptr->sai_data->sai_offset);\n\t\t\t\t}\n\t\t\t\treturn GF_OK;\n\t\t\t}\n\t\t\tptr->sai_data->saio_box = ptr;\n\t\t}\n\n\t\t\/\/store position in bitstream before writing data - offsets can be NULL if a single offset is rewritten later on (cf senc_box_write)\n\t\tptr->offset_first_offset_field = gf_bs_get_position(bs);\n\t\tif (ptr->version==0) {\n\t\t\tif (!ptr->offsets) {\n\t\t\t\tgf_bs_write_u32(bs, 0);\n\t\t\t} else {\n\t\t\t\tfor (i=0; i<ptr->entry_count; i++)\n\t\t\t\t\tgf_bs_write_u32(bs, (u32) ptr->offsets[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tif (!ptr->offsets) {\n\t\t\t\tgf_bs_write_u64(bs, 0);\n\t\t\t} else {\n\t\t\t\tfor (i=0; i<ptr->entry_count; i++)\n\t\t\t\t\tgf_bs_write_u64(bs, ptr->offsets[i]);\n\t\t\t}\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":460,"total_token_length":696,"max_tokens_setting":1024}
+{"idx":299910,"func":"readconf_one_rewrite(uschar *p, int *existflags, BOOL isglobal)\n{\nrewrite_rule *next = store_get(sizeof(rewrite_rule));\n\nnext->next = NULL;\nnext->key = string_dequote(&p);\n\nwhile (isspace(*p)) p++;\nif (*p == 0)\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"missing rewrite replacement string\");\n\nnext->flags = 0;\nnext->replacement = string_dequote(&p);\n\nwhile (*p != 0) switch (*p++)\n  {\n  case ' ': case '\\t': break;\n\n  case 'q': next->flags |= rewrite_quit; break;\n  case 'w': next->flags |= rewrite_whole; break;\n\n  case 'h': next->flags |= rewrite_all_headers; break;\n  case 's': next->flags |= rewrite_sender; break;\n  case 'f': next->flags |= rewrite_from; break;\n  case 't': next->flags |= rewrite_to;   break;\n  case 'c': next->flags |= rewrite_cc;   break;\n  case 'b': next->flags |= rewrite_bcc;  break;\n  case 'r': next->flags |= rewrite_replyto; break;\n\n  case 'E': next->flags |= rewrite_all_envelope; break;\n  case 'F': next->flags |= rewrite_envfrom; break;\n  case 'T': next->flags |= rewrite_envto; break;\n\n  case 'Q': next->flags |= rewrite_qualify; break;\n  case 'R': next->flags |= rewrite_repeat; break;\n\n  case 'S':\n  next->flags |= rewrite_smtp;\n  if (next->key[0] != '^' && Ustrncmp(next->key, \"\\\\N^\", 3) != 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"rewrite rule has the S flag but is not a regular expression\");\n  break;\n\n  default:\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"unknown rewrite flag character '%c' \"\n    \"(could be missing quotes round replacement item)\", p[-1]);\n  break;\n  }\n\n\/* If no action flags are set, set all the \"normal\" rewrites. *\/\n\nif ((next->flags & (rewrite_all | rewrite_smtp)) == 0)\n  next->flags |= isglobal? rewrite_all : rewrite_all_headers;\n\n\/* Remember which exist, for optimization, and return the rule *\/\n\n*existflags |= next->flags;\nreturn next;\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":198004,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ boxes: [batch_size, num_anchors, q, 4]\n    const Tensor& boxes = context->input(0);\n    \/\/ scores: [batch_size, num_anchors, num_classes]\n    const Tensor& scores = context->input(1);\n    OP_REQUIRES(\n        context, (boxes.dim_size(0) == scores.dim_size(0)),\n        errors::InvalidArgument(\"boxes and scores must have same batch size\"));\n\n    \/\/ max_output_size: scalar\n    const Tensor& max_output_size = context->input(2);\n    OP_REQUIRES(\n        context, TensorShapeUtils::IsScalar(max_output_size.shape()),\n        errors::InvalidArgument(\"max_size_per_class must be 0-D, got shape \",\n                                max_output_size.shape().DebugString()));\n    const int max_size_per_class = max_output_size.scalar<int>()();\n    \/\/ max_total_size: scalar\n    const Tensor& max_total_size = context->input(3);\n    OP_REQUIRES(\n        context, TensorShapeUtils::IsScalar(max_total_size.shape()),\n        errors::InvalidArgument(\"max_total_size must be 0-D, got shape \",\n                                max_total_size.shape().DebugString()));\n    const int max_total_size_per_batch = max_total_size.scalar<int>()();\n    OP_REQUIRES(context, max_total_size_per_batch > 0,\n                errors::InvalidArgument(\"max_total_size must be > 0\"));\n    \/\/ Throw warning when `max_total_size` is too large as it may cause OOM.\n    if (max_total_size_per_batch > pow(10, 6)) {\n      LOG(WARNING) << \"Detected a large value for `max_total_size`. This may \"\n                   << \"cause OOM error. (max_total_size: \"\n                   << max_total_size.scalar<int>()() << \")\";\n    }\n    \/\/ iou_threshold: scalar\n    const Tensor& iou_threshold = context->input(4);\n    OP_REQUIRES(context, TensorShapeUtils::IsScalar(iou_threshold.shape()),\n                errors::InvalidArgument(\"iou_threshold must be 0-D, got shape \",\n                                        iou_threshold.shape().DebugString()));\n    const float iou_threshold_val = iou_threshold.scalar<float>()();\n\n    \/\/ score_threshold: scalar\n    const Tensor& score_threshold = context->input(5);\n    OP_REQUIRES(\n        context, TensorShapeUtils::IsScalar(score_threshold.shape()),\n        errors::InvalidArgument(\"score_threshold must be 0-D, got shape \",\n                                score_threshold.shape().DebugString()));\n    const float score_threshold_val = score_threshold.scalar<float>()();\n\n    OP_REQUIRES(context, iou_threshold_val >= 0 && iou_threshold_val <= 1,\n                errors::InvalidArgument(\"iou_threshold must be in [0, 1]\"));\n    int num_boxes = 0;\n    const int num_classes = scores.dim_size(2);\n    ParseAndCheckCombinedNMSBoxSizes(context, boxes, &num_boxes, num_classes);\n    CheckCombinedNMSScoreSizes(context, num_boxes, scores);\n\n    if (!context->status().ok()) {\n      return;\n    }\n    BatchedNonMaxSuppressionOp(context, boxes, scores, num_boxes,\n                               max_size_per_class, max_total_size_per_batch,\n                               score_threshold_val, iou_threshold_val,\n                               pad_per_class_, clip_boxes_);\n  }","target":1,"code_token_length":702,"total_token_length":938,"max_tokens_setting":1024}
+{"idx":337848,"func":"struct sctp_chunk *sctp_make_strreset_req(\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\t__u16 stream_num, __be16 *stream_list,\n\t\t\t\t\tbool out, bool in)\n{\n\t__u16 stream_len = stream_num * sizeof(__u16);\n\tstruct sctp_strreset_outreq outreq;\n\tstruct sctp_strreset_inreq inreq;\n\tstruct sctp_chunk *retval;\n\t__u16 outlen, inlen;\n\n\toutlen = (sizeof(outreq) + stream_len) * out;\n\tinlen = (sizeof(inreq) + stream_len) * in;\n\n\tretval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen));\n\tif (!retval)\n\t\treturn NULL;\n\n\tif (outlen) {\n\t\toutreq.param_hdr.type = SCTP_PARAM_RESET_OUT_REQUEST;\n\t\toutreq.param_hdr.length = htons(outlen);\n\t\toutreq.request_seq = htonl(asoc->strreset_outseq);\n\t\toutreq.response_seq = htonl(asoc->strreset_inseq - 1);\n\t\toutreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);\n\n\t\tsctp_addto_chunk(retval, sizeof(outreq), &outreq);\n\n\t\tif (stream_len)\n\t\t\tsctp_addto_chunk(retval, stream_len, stream_list);\n\t}\n\n\tif (inlen) {\n\t\tinreq.param_hdr.type = SCTP_PARAM_RESET_IN_REQUEST;\n\t\tinreq.param_hdr.length = htons(inlen);\n\t\tinreq.request_seq = htonl(asoc->strreset_outseq + out);\n\n\t\tsctp_addto_chunk(retval, sizeof(inreq), &inreq);\n\n\t\tif (stream_len)\n\t\t\tsctp_addto_chunk(retval, stream_len, stream_list);\n\t}\n\n\treturn retval;\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":338147,"func":"bool WasmBinaryBuilder::maybeVisitSIMDShift(Expression*& out, uint32_t code) {\n  SIMDShift* curr;\n  switch (code) {\n    case BinaryConsts::I8x16Shl:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShlVecI8x16;\n      break;\n    case BinaryConsts::I8x16ShrS:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrSVecI8x16;\n      break;\n    case BinaryConsts::I8x16ShrU:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrUVecI8x16;\n      break;\n    case BinaryConsts::I16x8Shl:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShlVecI16x8;\n      break;\n    case BinaryConsts::I16x8ShrS:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrSVecI16x8;\n      break;\n    case BinaryConsts::I16x8ShrU:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrUVecI16x8;\n      break;\n    case BinaryConsts::I32x4Shl:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShlVecI32x4;\n      break;\n    case BinaryConsts::I32x4ShrS:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrSVecI32x4;\n      break;\n    case BinaryConsts::I32x4ShrU:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrUVecI32x4;\n      break;\n    case BinaryConsts::I64x2Shl:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShlVecI64x2;\n      break;\n    case BinaryConsts::I64x2ShrS:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrSVecI64x2;\n      break;\n    case BinaryConsts::I64x2ShrU:\n      curr = allocator.alloc<SIMDShift>();\n      curr->op = ShrUVecI64x2;\n      break;\n    default:\n      return false;\n  }\n  curr->shift = popNonVoidExpression();\n  curr->vec = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":226144,"func":"\nGF_Err trak_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_TrackBox *ptr = (GF_TrackBox *)s;\n\te = gf_isom_box_array_read(s, bs);\n\tif (e) return e;\n\te = gf_isom_check_sample_desc(ptr);\n\tif (e) return e;\n\n\tif (!ptr->Header) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing TrackHeaderBox\\n\"));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tif (!ptr->Media) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing MediaBox\\n\"));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tif (!ptr->Media->information || !ptr->Media->information->sampleTable) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid MediaBox\\n\"));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tif (!ptr->Media->information->sampleTable->SampleSize || (ptr->Media->information->sampleTable->SampleSize->sampleCount==0)) {\n\t\tif (ptr->Header->initial_duration) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] Track with no samples but duration defined, ignoring duration\\n\"));\n\t\t\tptr->Header->initial_duration = 0;\n\t\t}\n\t}\n\n\tfor (i=0; i<gf_list_count(ptr->Media->information->sampleTable->child_boxes); i++) {\n\t\tGF_Box *a = gf_list_get(ptr->Media->information->sampleTable->child_boxes, i);\n\t\tif ((a->type ==GF_ISOM_BOX_TYPE_UUID) && (((GF_UUIDBox *)a)->internal_4cc == GF_ISOM_BOX_UUID_PSEC)) {\n\t\t\tptr->sample_encryption = (struct __sample_encryption_box *) a;\n\t\t\tbreak;\n\t\t}\n\t\telse if (a->type == GF_ISOM_BOX_TYPE_SENC) {\n\t\t\tptr->sample_encryption = (struct __sample_encryption_box *)a;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn e;","target":0,"code_token_length":460,"total_token_length":696,"max_tokens_setting":1024}
+{"idx":211103,"func":"_fr_window_ask_overwrite_dialog (OverwriteData *odata)\n{\n\tif ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL)) {\n\t\tconst char *base_name;\n\t\tGFile      *destination;\n\n\t\tbase_name = _g_path_get_relative_basename ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths);\n\t\tdestination = g_file_get_child (odata->edata->destination, base_name);\n\t\tg_file_query_info_async (destination,\n\t\t\t\t\t G_FILE_ATTRIBUTE_STANDARD_TYPE \",\" G_FILE_ATTRIBUTE_STANDARD_NAME \",\" G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,\n\t\t\t\t\t G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,\n\t\t\t\t\t G_PRIORITY_DEFAULT,\n\t\t\t\t\t odata->window->priv->cancellable,\n\t\t\t\t\t query_info_ready_for_overwrite_dialog_cb,\n\t\t\t\t\t odata);\n\n\t\tg_object_unref (destination);\n\n\t\treturn;\n\t}\n\n\tif (odata->edata->file_list != NULL) {\n\t\t\/* speed optimization: passing NULL when extracting all the\n\t\t * files is faster if the command supports the\n\t\t * propCanExtractAll property. *\/\n\t\tif (odata->extract_all) {\n\t\t\t_g_string_list_free (odata->edata->file_list);\n\t\t\todata->edata->file_list = NULL;\n\t\t}\n\t\todata->edata->overwrite = FR_OVERWRITE_YES;\n\t\t_fr_window_archive_extract_from_edata (odata->window, odata->edata);\n\t}\n\telse {\n\t\tGtkWidget *d;\n\n\t\td = _gtk_message_dialog_new (GTK_WINDOW (odata->window),\n\t\t\t\t\t     0,\n\t\t\t\t\t     GTK_STOCK_DIALOG_WARNING,\n\t\t\t\t\t     _(\"Extraction not performed\"),\n\t\t\t\t\t     NULL,\n\t\t\t\t\t     GTK_STOCK_OK, GTK_RESPONSE_OK,\n\t\t\t\t\t     NULL);\n\t\tgtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK);\n\t\tfr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window), _(\"Extraction not performed\"));\n\n\t\tfr_window_stop_batch (odata->window);\n\t}\n\n\tg_free (odata);\n}","target":1,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":196611,"func":"static int setup_config(int type)\n{\n\tint rv;\n\n\trv = read_config(cl.configfile, type);\n\tif (rv < 0)\n\t\tgoto out;\n\n\tif (is_auth_req()) {\n\t\trv = read_authkey();\n\t\tif (rv < 0)\n\t\t\tgoto out;\n#if HAVE_LIBGCRYPT\n\t\tif (!gcry_check_version(NULL)) {\n\t\t\tlog_error(\"gcry_check_version\");\n\t\t\trv = -ENOENT;\n\t\t\tgoto out;\n\t\t}\n\t\tgcry_control(GCRYCTL_DISABLE_SECMEM, 0);\n\t\tgcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);\n#endif\n\t}\n\n\t\/* Set \"local\" pointer, ignoring errors. *\/\n\tif (cl.type == DAEMON && cl.site[0]) {\n\t\tif (!find_site_by_name(cl.site, &local, 1)) {\n\t\t\tlog_error(\"Cannot find \\\"%s\\\" in the configuration.\",\n\t\t\t\t\tcl.site);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tlocal->local = 1;\n\t} else\n\t\tfind_myself(NULL, type == CLIENT || type == GEOSTORE);\n\n\n\trv = check_config(type);\n\tif (rv < 0)\n\t\tgoto out;\n\n\n\t\/* Per default the PID file name is derived from the\n\t * configuration name. *\/\n\tif (!cl.lockfile[0]) {\n\t\tsnprintf(cl.lockfile, sizeof(cl.lockfile)-1,\n\t\t\t\t\"%s\/%s.pid\", BOOTH_RUN_DIR, booth_conf->name);\n\t}\n\nout:\n\treturn rv;\n}","target":1,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":253575,"func":"static int smb3_simple_fallocate_write_range(unsigned int xid,\n\t\t\t\t\t     struct cifs_tcon *tcon,\n\t\t\t\t\t     struct cifsFileInfo *cfile,\n\t\t\t\t\t     loff_t off, loff_t len,\n\t\t\t\t\t     char *buf)\n{\n\tstruct cifs_io_parms io_parms = {0};\n\tint nbytes;\n\tint rc = 0;\n\tstruct kvec iov[2];\n\n\tio_parms.netfid = cfile->fid.netfid;\n\tio_parms.pid = current->tgid;\n\tio_parms.tcon = tcon;\n\tio_parms.persistent_fid = cfile->fid.persistent_fid;\n\tio_parms.volatile_fid = cfile->fid.volatile_fid;\n\n\twhile (len) {\n\t\tio_parms.offset = off;\n\t\tio_parms.length = len;\n\t\tif (io_parms.length > SMB2_MAX_BUFFER_SIZE)\n\t\t\tio_parms.length = SMB2_MAX_BUFFER_SIZE;\n\t\t\/* iov[0] is reserved for smb header *\/\n\t\tiov[1].iov_base = buf;\n\t\tiov[1].iov_len = io_parms.length;\n\t\trc = SMB2_write(xid, &io_parms, &nbytes, iov, 1);\n\t\tif (rc)\n\t\t\tbreak;\n\t\tif (nbytes > len)\n\t\t\treturn -EINVAL;\n\t\tbuf += nbytes;\n\t\toff += nbytes;\n\t\tlen -= nbytes;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":234770,"func":"static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,\n\t\t\tstruct btrfs_device *device, fmode_t flags,\n\t\t\tvoid *holder)\n{\n\tstruct request_queue *q;\n\tstruct block_device *bdev;\n\tstruct btrfs_super_block *disk_super;\n\tu64 devid;\n\tint ret;\n\n\tif (device->bdev)\n\t\treturn -EINVAL;\n\tif (!device->name)\n\t\treturn -EINVAL;\n\n\tret = btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1,\n\t\t\t\t    &bdev, &disk_super);\n\tif (ret)\n\t\treturn ret;\n\n\tdevid = btrfs_stack_device_id(&disk_super->dev_item);\n\tif (devid != device->devid)\n\t\tgoto error_free_page;\n\n\tif (memcmp(device->uuid, disk_super->dev_item.uuid, BTRFS_UUID_SIZE))\n\t\tgoto error_free_page;\n\n\tdevice->generation = btrfs_super_generation(disk_super);\n\n\tif (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_SEEDING) {\n\t\tif (btrfs_super_incompat_flags(disk_super) &\n\t\t    BTRFS_FEATURE_INCOMPAT_METADATA_UUID) {\n\t\t\tpr_err(\n\t\t\"BTRFS: Invalid seeding and uuid-changed device detected\\n\");\n\t\t\tgoto error_free_page;\n\t\t}\n\n\t\tclear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);\n\t\tfs_devices->seeding = true;\n\t} else {\n\t\tif (bdev_read_only(bdev))\n\t\t\tclear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);\n\t\telse\n\t\t\tset_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);\n\t}\n\n\tq = bdev_get_queue(bdev);\n\tif (!blk_queue_nonrot(q))\n\t\tfs_devices->rotating = true;\n\n\tdevice->bdev = bdev;\n\tclear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);\n\tdevice->mode = flags;\n\n\tfs_devices->open_devices++;\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&\n\t    device->devid != BTRFS_DEV_REPLACE_DEVID) {\n\t\tfs_devices->rw_devices++;\n\t\tlist_add_tail(&device->dev_alloc_list, &fs_devices->alloc_list);\n\t}\n\tbtrfs_release_disk_super(disk_super);\n\n\treturn 0;\n\nerror_free_page:\n\tbtrfs_release_disk_super(disk_super);\n\tblkdev_put(bdev, flags);\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":436130,"func":"static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,\n\t\t\tlong min)\n{\n\tstruct io_kiocb *req, *tmp;\n\tLIST_HEAD(done);\n\tbool spin;\n\tint ret;\n\n\t\/*\n\t * Only spin for completions if we don't have multiple devices hanging\n\t * off our complete list, and we're under the requested amount.\n\t *\/\n\tspin = !ctx->poll_multi_queue && *nr_events < min;\n\n\tret = 0;\n\tlist_for_each_entry_safe(req, tmp, &ctx->iopoll_list, inflight_entry) {\n\t\tstruct kiocb *kiocb = &req->rw.kiocb;\n\n\t\t\/*\n\t\t * Move completed and retryable entries to our local lists.\n\t\t * If we find a request that requires polling, break out\n\t\t * and complete those lists first, if we have entries there.\n\t\t *\/\n\t\tif (READ_ONCE(req->iopoll_completed)) {\n\t\t\tlist_move_tail(&req->inflight_entry, &done);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!list_empty(&done))\n\t\t\tbreak;\n\n\t\tret = kiocb->ki_filp->f_op->iopoll(kiocb, spin);\n\t\tif (ret < 0)\n\t\t\tbreak;\n\n\t\t\/* iopoll may have completed current req *\/\n\t\tif (READ_ONCE(req->iopoll_completed))\n\t\t\tlist_move_tail(&req->inflight_entry, &done);\n\n\t\tif (ret && spin)\n\t\t\tspin = false;\n\t\tret = 0;\n\t}\n\n\tif (!list_empty(&done))\n\t\tio_iopoll_complete(ctx, nr_events, &done);\n\n\treturn ret;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":329921,"func":"_cairo_image_traps_compositor_get (void)\n{\n    static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;\n    static cairo_traps_compositor_t compositor;\n\n    if (_cairo_atomic_init_once_enter(&once)) {\n\t_cairo_traps_compositor_init(&compositor,\n\t\t\t\t     &__cairo_no_compositor);\n\tcompositor.acquire = acquire;\n\tcompositor.release = release;\n\tcompositor.set_clip_region = set_clip_region;\n\tcompositor.pattern_to_surface = _cairo_image_source_create_for_pattern;\n\tcompositor.draw_image_boxes = draw_image_boxes;\n\t\/\/compositor.copy_boxes = copy_boxes;\n\tcompositor.fill_boxes = fill_boxes;\n\tcompositor.check_composite = check_composite;\n\tcompositor.composite = composite;\n\tcompositor.lerp = lerp;\n\t\/\/compositor.check_composite_boxes = check_composite_boxes;\n\tcompositor.composite_boxes = composite_boxes;\n\t\/\/compositor.check_composite_traps = check_composite_traps;\n\tcompositor.composite_traps = composite_traps;\n\t\/\/compositor.check_composite_tristrip = check_composite_traps;\n#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0)\n\tcompositor.composite_tristrip = composite_tristrip;\n#endif\n\tcompositor.check_composite_glyphs = check_composite_glyphs;\n\tcompositor.composite_glyphs = composite_glyphs;\n\n\t_cairo_atomic_init_once_leave(&once);\n    }\n\n    return &compositor.base;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":218970,"func":"Status ConstantFolding::RemoveShuffleOrTranspose(\n    const GraphProperties& properties, bool use_shape_info,\n    GraphDef* optimized_graph, NodeDef* node) {\n  if (!use_shape_info || !(IsShuffle(*node) || IsTranspose(*node)))\n    return Status::OK();\n  Tensor permutation_tensor;\n  if (GetTensorFromConstNode(node->input(1), &permutation_tensor) &&\n      properties.HasInputProperties(node->name())) {\n    const auto& shape = properties.GetInputProperties(node->name())[0].shape();\n    std::vector<int> permutation;\n    for (int j = 0; j < permutation_tensor.NumElements(); ++j) {\n      if (permutation_tensor.dtype() == DT_INT64) {\n        permutation.push_back(permutation_tensor.vec<int64_t>()(j));\n      } else {\n        permutation.push_back(permutation_tensor.vec<int>()(j));\n      }\n    }\n    int permutation_size = permutation.size();\n    if (permutation_size != shape.dim_size()) {\n      \/\/ Number of elements in perm should be same as dim_size. Skip if not.\n      return Status::OK();\n    }\n    \/\/ The node is replaceable iff\n    \/\/ dim_size == 0 || all dims have size 1 ||\n    \/\/ all dims with > 1 size are not permuted.\n    bool replaceable = true;\n    for (int j = 0; replaceable && j < shape.dim_size(); ++j) {\n      replaceable &= shape.dim(j).size() == 1 || j == permutation[j];\n    }\n    if (replaceable) {\n      ReplaceOperationWithIdentity(0, properties, node, optimized_graph);\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":484768,"func":"static bool xennet_tx_buf_gc(struct netfront_queue *queue)\n{\n\tRING_IDX cons, prod;\n\tunsigned short id;\n\tstruct sk_buff *skb;\n\tbool more_to_do;\n\tbool work_done = false;\n\tconst struct device *dev = &queue->info->netdev->dev;\n\n\tBUG_ON(!netif_carrier_ok(queue->info->netdev));\n\n\tdo {\n\t\tprod = queue->tx.sring->rsp_prod;\n\t\tif (RING_RESPONSE_PROD_OVERFLOW(&queue->tx, prod)) {\n\t\t\tdev_alert(dev, \"Illegal number of responses %u\\n\",\n\t\t\t\t  prod - queue->tx.rsp_cons);\n\t\t\tgoto err;\n\t\t}\n\t\trmb(); \/* Ensure we see responses up to 'rp'. *\/\n\n\t\tfor (cons = queue->tx.rsp_cons; cons != prod; cons++) {\n\t\t\tstruct xen_netif_tx_response txrsp;\n\n\t\t\twork_done = true;\n\n\t\t\tRING_COPY_RESPONSE(&queue->tx, cons, &txrsp);\n\t\t\tif (txrsp.status == XEN_NETIF_RSP_NULL)\n\t\t\t\tcontinue;\n\n\t\t\tid = txrsp.id;\n\t\t\tif (id >= RING_SIZE(&queue->tx)) {\n\t\t\t\tdev_alert(dev,\n\t\t\t\t\t  \"Response has incorrect id (%u)\\n\",\n\t\t\t\t\t  id);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tif (queue->tx_link[id] != TX_PENDING) {\n\t\t\t\tdev_alert(dev,\n\t\t\t\t\t  \"Response for inactive request\\n\");\n\t\t\t\tgoto err;\n\t\t\t}\n\n\t\t\tqueue->tx_link[id] = TX_LINK_NONE;\n\t\t\tskb = queue->tx_skbs[id];\n\t\t\tqueue->tx_skbs[id] = NULL;\n\t\t\tif (unlikely(!gnttab_end_foreign_access_ref(\n\t\t\t\tqueue->grant_tx_ref[id]))) {\n\t\t\t\tdev_alert(dev,\n\t\t\t\t\t  \"Grant still in use by backend domain\\n\");\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tgnttab_release_grant_reference(\n\t\t\t\t&queue->gref_tx_head, queue->grant_tx_ref[id]);\n\t\t\tqueue->grant_tx_ref[id] = INVALID_GRANT_REF;\n\t\t\tqueue->grant_tx_page[id] = NULL;\n\t\t\tadd_id_to_list(&queue->tx_skb_freelist, queue->tx_link, id);\n\t\t\tdev_kfree_skb_irq(skb);\n\t\t}\n\n\t\tqueue->tx.rsp_cons = prod;\n\n\t\tRING_FINAL_CHECK_FOR_RESPONSES(&queue->tx, more_to_do);\n\t} while (more_to_do);\n\n\txennet_maybe_wake_tx(queue);\n\n\treturn work_done;\n\n err:\n\tqueue->info->broken = true;\n\tdev_alert(dev, \"Disabled for further use\\n\");\n\n\treturn work_done;\n}","target":0,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":336594,"func":"void reds_send_device_display_info(RedsState *reds)\n{\n    if (!reds->agent_dev->priv->agent_attached) {\n        return;\n    }\n    if (!reds->agent_dev->priv->agent_supports_graphics_device_info) {\n        return;\n    }\n\n    g_debug(\"Sending device display info to the agent:\");\n\n    SpiceMarshaller *m = spice_marshaller_new();\n    reds_marshall_device_display_info(reds, m);\n\n    RedCharDeviceWriteBuffer *char_dev_buf = vdagent_new_write_buffer(reds->agent_dev.get(),\n                                         VD_AGENT_GRAPHICS_DEVICE_INFO,\n                                         spice_marshaller_get_total_size(m),\n                                         true);\n\n    if (!char_dev_buf) {\n        spice_marshaller_destroy(m);\n        reds->pending_device_display_info_message = true;\n        return;\n    }\n\n    VDInternalBuf *internal_buf = (VDInternalBuf *)char_dev_buf->buf;\n\n    int free_info;\n    size_t len_info;\n    uint8_t *info = spice_marshaller_linearize(m, 0, &len_info, &free_info);\n    memcpy(&internal_buf->u.graphics_device_info, info, len_info);\n    if (free_info) {\n        free(info);\n    }\n    spice_marshaller_destroy(m);\n\n    reds->pending_device_display_info_message = false;\n\n    reds->agent_dev->write_buffer_add(char_dev_buf);\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":355652,"func":"eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)\n{\n    char_u\t*p;\n    int\t\tgetnext;\n\n    \/*\n     * Get the first variable.\n     *\/\n    if (eval4(arg, rettv, evalarg) == FAIL)\n\treturn FAIL;\n\n    \/*\n     * Handle the \"&&\" operator.\n     *\/\n    p = eval_next_non_blank(*arg, evalarg, &getnext);\n    if (p[0] == '&' && p[1] == '&')\n    {\n\tevalarg_T   *evalarg_used = evalarg;\n\tevalarg_T   local_evalarg;\n\tint\t    orig_flags;\n\tint\t    evaluate;\n\tlong\t    result = TRUE;\n\ttypval_T    var2;\n\tint\t    error = FALSE;\n\tint\t    vim9script = in_vim9script();\n\n\tif (evalarg == NULL)\n\t{\n\t    init_evalarg(&local_evalarg);\n\t    evalarg_used = &local_evalarg;\n\t}\n\torig_flags = evalarg_used->eval_flags;\n\tevaluate = orig_flags & EVAL_EVALUATE;\n\tif (evaluate)\n\t{\n\t    if (vim9script)\n\t\tresult = tv_get_bool_chk(rettv, &error);\n\t    else if (tv_get_number_chk(rettv, &error) == 0)\n\t\tresult = FALSE;\n\t    clear_tv(rettv);\n\t    if (error)\n\t\treturn FAIL;\n\t}\n\n\t\/*\n\t * Repeat until there is no following \"&&\".\n\t *\/\n\twhile (p[0] == '&' && p[1] == '&')\n\t{\n\t    if (getnext)\n\t\t*arg = eval_next_line(evalarg_used);\n\t    else\n\t    {\n\t\tif (evaluate && vim9script && !VIM_ISWHITE(p[-1]))\n\t\t{\n\t\t    error_white_both(p, 2);\n\t\t    clear_tv(rettv);\n\t\t    return FAIL;\n\t\t}\n\t\t*arg = p;\n\t    }\n\n\t    \/*\n\t     * Get the second variable.\n\t     *\/\n\t    if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))\n\t    {\n\t\terror_white_both(*arg, 2);\n\t\tclear_tv(rettv);\n\t\treturn FAIL;\n\t    }\n\t    *arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);\n\t    evalarg_used->eval_flags = result ? orig_flags\n\t\t\t\t\t\t : orig_flags & ~EVAL_EVALUATE;\n\t    CLEAR_FIELD(var2);\n\t    if (eval4(arg, &var2, evalarg_used) == FAIL)\n\t\treturn FAIL;\n\n\t    \/*\n\t     * Compute the result.\n\t     *\/\n\t    if (evaluate && result)\n\t    {\n\t\tif (vim9script)\n\t\t    result = tv_get_bool_chk(&var2, &error);\n\t\telse if (tv_get_number_chk(&var2, &error) == 0)\n\t\t    result = FALSE;\n\t\tclear_tv(&var2);\n\t\tif (error)\n\t\t    return FAIL;\n\t    }\n\t    if (evaluate)\n\t    {\n\t\tif (vim9script)\n\t\t{\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = result ? VVAL_TRUE : VVAL_FALSE;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rettv->v_type = VAR_NUMBER;\n\t\t    rettv->vval.v_number = result;\n\t\t}\n\t    }\n\n\t    p = eval_next_non_blank(*arg, evalarg_used, &getnext);\n\t}\n\n\tif (evalarg == NULL)\n\t    clear_evalarg(&local_evalarg, NULL);\n\telse\n\t    evalarg->eval_flags = orig_flags;\n    }\n\n    return OK;\n}","target":0,"code_token_length":749,"total_token_length":985,"max_tokens_setting":1024}
+{"idx":282984,"func":"static ptrdiff_t finderrfunc(lua_State *L)\n{\n  cTValue *frame = L->base-1, *bot = tvref(L->stack);\n  void *cf = L->cframe;\n  while (frame > bot && cf) {\n    while (cframe_nres(cframe_raw(cf)) < 0) {  \/* cframe without frame? *\/\n      if (frame >= restorestack(L, -cframe_nres(cf)))\n\tbreak;\n      if (cframe_errfunc(cf) >= 0)  \/* Error handler not inherited (-1)? *\/\n\treturn cframe_errfunc(cf);\n      cf = cframe_prev(cf);  \/* Else unwind cframe and continue searching. *\/\n      if (cf == NULL)\n\treturn 0;\n    }\n    switch (frame_typep(frame)) {\n    case FRAME_LUA:\n    case FRAME_LUAP:\n      frame = frame_prevl(frame);\n      break;\n    case FRAME_C:\n      cf = cframe_prev(cf);\n      \/* fallthrough *\/\n    case FRAME_VARG:\n      frame = frame_prevd(frame);\n      break;\n    case FRAME_CONT:\n#if LJ_HASFFI\n      if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK)\n\tcf = cframe_prev(cf);\n#endif\n      frame = frame_prevd(frame);\n      break;\n    case FRAME_CP:\n      if (cframe_canyield(cf)) return 0;\n      if (cframe_errfunc(cf) >= 0)\n\treturn cframe_errfunc(cf);\n      cf = cframe_prev(cf);\n      frame = frame_prevd(frame);\n      break;\n    case FRAME_PCALL:\n    case FRAME_PCALLH:\n      if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue)))  \/* xpcall? *\/\n\treturn savestack(L, frame-1);  \/* Point to xpcall's errorfunc. *\/\n      return 0;\n    default:\n      lua_assert(0);\n      return 0;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":445987,"func":"_fr_window_notify_creation_complete (FrWindow *window)\n{\n\tchar               *basename;\n\tchar               *message;\n\tNotifyNotification *notification;\n\tgboolean            notification_supports_actions;\n\tGList              *caps;\n\tNotifyData         *notify_data;\n\n\tbasename = _g_file_get_display_basename (window->priv->saving_file);\n\t\/* Translators: %s is a filename *\/\n\tmessage = g_strdup_printf (_(\"\\\"%s\\\" created successfully\"), basename);\n\tnotification = notify_notification_new (window->priv->batch_title, message, \"file-roller\");\n\tnotify_notification_set_hint_string (notification, \"desktop-entry\", \"file-roller\");\n\n\tnotify_data = g_new0 (NotifyData, 1);\n\tnotify_data->window = window;\n\tnotify_data->window_closed = FALSE;\n\tg_signal_connect (notification,\n\t\t\t  \"closed\",\n\t\t\t  G_CALLBACK (notification_closed_cb),\n\t\t\t  notify_data);\n\n\tnotification_supports_actions = FALSE;\n\tcaps = notify_get_server_caps ();\n\tif (caps != NULL) {\n\t\tnotification_supports_actions = g_list_find_custom (caps, \"actions\", (GCompareFunc) strcmp) != NULL;\n\t\t_g_string_list_free (caps);\n\t}\n\n\tif (notification_supports_actions) {\n\t\tnotify_notification_add_action (notification,\n\t\t\t\t\t\t\"document-open-symbolic\",\n\t\t\t\t\t\t_(\"Open\"),\n\t\t\t\t\t\tnotify_action_open_archive_cb,\n\t\t\t\t\t\tnotify_data,\n\t\t\t\t\t\tNULL);\n\t\t\/*notify_notification_set_hint (notification,\n\t\t\t\t\t      \"action-icons\",\n\t\t\t\t\t      g_variant_new_boolean (TRUE));*\/\n\t}\n\n\tnotify_notification_show (notification, NULL);\n\tg_free (message);\n\tg_free (basename);\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":226239,"func":"GF_Err traf_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_TrackFragmentBox *ptr = (GF_TrackFragmentBox *) s;\n\n\t\/\/Header first\n\tgf_isom_check_position(s, (GF_Box *)ptr->tfhd, &pos);\n\tgf_isom_check_position_list(s, ptr->sub_samples, &pos);\n\n\tgf_isom_check_position(s, (GF_Box *)ptr->tfdt, &pos);\n\n\t\/\/cmaf-like\n\tif (ptr->truns_first) {\n\t\tgf_isom_check_position_list(s, ptr->TrackRuns, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sai_sizes, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sai_offsets, &pos);\n\t\t\/\/senc MUST be after saio in GPAC, as senc writing uses info from saio writing\n\t\tgf_isom_check_position(s, (GF_Box *)ptr->sample_encryption, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sampleGroupsDescription, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sampleGroups, &pos);\n\t\t\/\/subsamples will be last\n\t} else {\n\t\tgf_isom_check_position_list(s, ptr->sampleGroupsDescription, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sampleGroups, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sai_sizes, &pos);\n\t\tgf_isom_check_position_list(s, ptr->sai_offsets, &pos);\n\t\tgf_isom_check_position(s, (GF_Box *)ptr->sample_encryption, &pos);\n\t\tgf_isom_check_position_list(s, ptr->TrackRuns, &pos);\n\t}\n\n\t\/\/when sdtp is present (smooth-like) write it after the trun box\n\tgf_isom_check_position(s, (GF_Box *)ptr->sdtp, &pos);\n\n\t\/\/tfxd should be last ...\n\tif (ptr->tfxd)\n\t\tgf_isom_check_position(s, (GF_Box *)ptr->tfxd, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":402662,"func":"generate_spc_signer_info(cms_context *cms, SpcSignerInfo *sip)\n{\n\tif (!sip)\n\t\treturn -1;\n\n\tSpcSignerInfo si;\n\tmemset(&si, '\\0', sizeof (si));\n\n\tif (SEC_ASN1EncodeInteger(cms->arena, &si.CMSVersion, 1) == NULL) {\n\t\tcms->log(cms, LOG_ERR, \"could not encode CMSVersion: %s\",\n\t\t\tPORT_ErrorToString(PORT_GetError()));\n\t\tgoto err;\n\t}\n\n\tsi.sid.signerType = signerTypeIssuerAndSerialNumber;\n\tsi.sid.signerValue.iasn.issuer = cms->cert->derIssuer;\n\tsi.sid.signerValue.iasn.serial = cms->cert->serialNumber;\n\n\tif (generate_algorithm_id(cms, &si.digestAlgorithm,\n\t\t\tdigest_get_digest_oid(cms)) < 0)\n\t\tgoto err;\n\n\n\tif (cms->raw_signature) {\n\t\tmemcpy(&si.signedAttrs, cms->raw_signed_attrs,\n\t\t\tsizeof (si.signedAttrs));\n\t\tmemcpy(&si.signature, cms->raw_signature, sizeof(si.signature));\n\t} else {\n\t\tif (generate_signed_attributes(cms, &si.signedAttrs) < 0)\n\t\t\tgoto err;\n\n\t\tif (sign_blob(cms, &si.signature, &si.signedAttrs) < 0)\n\t\t\tgoto err;\n\t}\n\n\tsi.signedAttrs.data[0] = SEC_ASN1_CONTEXT_SPECIFIC | 0 |\n\t\t\t\tSEC_ASN1_CONSTRUCTED;\n\n\tif (generate_algorithm_id(cms, &si.signatureAlgorithm,\n\t\t\t\tdigest_get_encryption_oid(cms)) < 0)\n\t\tgoto err;\n\n\tif (generate_unsigned_attributes(cms, &si.unsignedAttrs) < 0)\n\t\tgoto err;\n\n\tmemcpy(sip, &si, sizeof(si));\n\treturn 0;\nerr:\n\treturn -1;\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":231756,"func":"  folly::Optional<ClientTransportParameters> getClientTransportParams()\n      override {\n    std::vector<TransportParameter> transportParams;\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::initial_max_stream_data_bidi_local,\n        kDefaultStreamWindowSize));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::initial_max_stream_data_bidi_remote,\n        kDefaultStreamWindowSize));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::initial_max_stream_data_uni,\n        kDefaultStreamWindowSize));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::initial_max_streams_bidi,\n        kDefaultMaxStreamsBidirectional));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::initial_max_streams_uni,\n        kDefaultMaxStreamsUnidirectional));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::initial_max_data, kDefaultConnectionWindowSize));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::idle_timeout, kDefaultIdleTimeout.count()));\n    transportParams.push_back(encodeIntegerParameter(\n        TransportParameterId::max_packet_size, maxRecvPacketSize));\n    if (clientActiveConnectionIdLimit_) {\n      transportParams.push_back(encodeIntegerParameter(\n          TransportParameterId::active_connection_id_limit,\n          *clientActiveConnectionIdLimit_));\n    }\n    transportParams.push_back(encodeConnIdParameter(\n        TransportParameterId::initial_source_connection_id,\n        getTestConnectionId()));\n\n    return ClientTransportParameters{std::move(transportParams)};\n  }","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":247720,"func":"TEST_P(SslSocketTest, GetCertDigestServerCertWithIntermediateCA) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_chain.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedSha256Digest(TEST_NO_SAN_CERT_256_HASH)\n               .setExpectedSha1Digest(TEST_NO_SAN_CERT_1_HASH)\n               .setExpectedSerialNumber(TEST_NO_SAN_CERT_SERIAL));\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":359355,"func":"DEFUN (router_bgp, \n       router_bgp_cmd, \n       \"router bgp <1-65535>\",\n       ROUTER_STR\n       BGP_STR\n       AS_STR)\n{\n  int ret;\n  as_t as;\n  struct bgp *bgp;\n  const char *name = NULL;\n\n  VTY_GET_INTEGER_RANGE (\"AS\", as, argv[0], 1, 65535);\n\n  if (argc == 2)\n    name = argv[1];\n\n  ret = bgp_get (&bgp, &as, name);\n  switch (ret)\n    {\n    case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:\n      vty_out (vty, \"Please specify 'bgp multiple-instance' first%s\", \n\t       VTY_NEWLINE);\n      return CMD_WARNING;\n    case BGP_ERR_AS_MISMATCH:\n      vty_out (vty, \"BGP is already running; AS is %d%s\", as, VTY_NEWLINE);\n      return CMD_WARNING;\n    case BGP_ERR_INSTANCE_MISMATCH:\n      vty_out (vty, \"BGP view name and AS number mismatch%s\", VTY_NEWLINE);\n      vty_out (vty, \"BGP instance is already running; AS is %d%s\",\n\t       as, VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  vty->node = BGP_NODE;\n  vty->index = bgp;\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":491950,"func":"int fuse_fsync_common(struct file *file, struct dentry *de, int datasync,\n\t\t      int isdir)\n{\n\tstruct inode *inode = de->d_inode;\n\tstruct fuse_conn *fc = get_fuse_conn(inode);\n\tstruct fuse_file *ff = file->private_data;\n\tstruct fuse_req *req;\n\tstruct fuse_fsync_in inarg;\n\tint err;\n\n\tif (is_bad_inode(inode))\n\t\treturn -EIO;\n\n\tif ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir))\n\t\treturn 0;\n\n\t\/*\n\t * Start writeback against all dirty pages of the inode, then\n\t * wait for all outstanding writes, before sending the FSYNC\n\t * request.\n\t *\/\n\terr = write_inode_now(inode, 0);\n\tif (err)\n\t\treturn err;\n\n\tfuse_sync_writes(inode);\n\n\treq = fuse_get_req(fc);\n\tif (IS_ERR(req))\n\t\treturn PTR_ERR(req);\n\n\tmemset(&inarg, 0, sizeof(inarg));\n\tinarg.fh = ff->fh;\n\tinarg.fsync_flags = datasync ? 1 : 0;\n\treq->in.h.opcode = isdir ? FUSE_FSYNCDIR : FUSE_FSYNC;\n\treq->in.h.nodeid = get_node_id(inode);\n\treq->in.numargs = 1;\n\treq->in.args[0].size = sizeof(inarg);\n\treq->in.args[0].value = &inarg;\n\tfuse_request_send(fc, req);\n\terr = req->out.h.error;\n\tfuse_put_request(fc, req);\n\tif (err == -ENOSYS) {\n\t\tif (isdir)\n\t\t\tfc->no_fsyncdir = 1;\n\t\telse\n\t\t\tfc->no_fsync = 1;\n\t\terr = 0;\n\t}\n\treturn err;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":316992,"func":"static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)\n{\n\tint rc = 0;\n\tunsigned int msg_len;\n\tunsigned int data_len = skb->len;\n\tunsigned char *data = skb->data;\n\tstruct nlmsghdr *nlh;\n\tstruct sk_security_struct *sksec = sk->sk_security;\n\tu16 sclass = sksec->sclass;\n\tu32 perm;\n\n\twhile (data_len >= nlmsg_total_size(0)) {\n\t\tnlh = (struct nlmsghdr *)data;\n\n\t\t\/* NOTE: the nlmsg_len field isn't reliably set by some netlink\n\t\t *       users which means we can't reject skb's with bogus\n\t\t *       length fields; our solution is to follow what\n\t\t *       netlink_rcv_skb() does and simply skip processing at\n\t\t *       messages with length fields that are clearly junk\n\t\t *\/\n\t\tif (nlh->nlmsg_len < NLMSG_HDRLEN || nlh->nlmsg_len > data_len)\n\t\t\treturn 0;\n\n\t\trc = selinux_nlmsg_lookup(sclass, nlh->nlmsg_type, &perm);\n\t\tif (rc == 0) {\n\t\t\trc = sock_has_perm(sk, perm);\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t} else if (rc == -EINVAL) {\n\t\t\t\/* -EINVAL is a missing msg\/perm mapping *\/\n\t\t\tpr_warn_ratelimited(\"SELinux: unrecognized netlink\"\n\t\t\t\t\" message: protocol=%hu nlmsg_type=%hu sclass=%s\"\n\t\t\t\t\" pid=%d comm=%s\\n\",\n\t\t\t\tsk->sk_protocol, nlh->nlmsg_type,\n\t\t\t\tsecclass_map[sclass - 1].name,\n\t\t\t\ttask_pid_nr(current), current->comm);\n\t\t\tif (enforcing_enabled(&selinux_state) &&\n\t\t\t    !security_get_allow_unknown(&selinux_state))\n\t\t\t\treturn rc;\n\t\t\trc = 0;\n\t\t} else if (rc == -ENOENT) {\n\t\t\t\/* -ENOENT is a missing socket\/class mapping, ignore *\/\n\t\t\trc = 0;\n\t\t} else {\n\t\t\treturn rc;\n\t\t}\n\n\t\t\/* move to the next message after applying netlink padding *\/\n\t\tmsg_len = NLMSG_ALIGN(nlh->nlmsg_len);\n\t\tif (msg_len >= data_len)\n\t\t\treturn 0;\n\t\tdata_len -= msg_len;\n\t\tdata += msg_len;\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":514,"total_token_length":750,"max_tokens_setting":1024}
+{"idx":484743,"func":"static int xennet_get_extras(struct netfront_queue *queue,\n\t\t\t     struct xen_netif_extra_info *extras,\n\t\t\t     RING_IDX rp)\n\n{\n\tstruct xen_netif_extra_info extra;\n\tstruct device *dev = &queue->info->netdev->dev;\n\tRING_IDX cons = queue->rx.rsp_cons;\n\tint err = 0;\n\n\tdo {\n\t\tstruct sk_buff *skb;\n\t\tgrant_ref_t ref;\n\n\t\tif (unlikely(cons + 1 == rp)) {\n\t\t\tif (net_ratelimit())\n\t\t\t\tdev_warn(dev, \"Missing extra info\\n\");\n\t\t\terr = -EBADR;\n\t\t\tbreak;\n\t\t}\n\n\t\tRING_COPY_RESPONSE(&queue->rx, ++cons, &extra);\n\n\t\tif (unlikely(!extra.type ||\n\t\t\t     extra.type >= XEN_NETIF_EXTRA_TYPE_MAX)) {\n\t\t\tif (net_ratelimit())\n\t\t\t\tdev_warn(dev, \"Invalid extra type: %d\\n\",\n\t\t\t\t\t extra.type);\n\t\t\terr = -EINVAL;\n\t\t} else {\n\t\t\textras[extra.type - 1] = extra;\n\t\t}\n\n\t\tskb = xennet_get_rx_skb(queue, cons);\n\t\tref = xennet_get_rx_ref(queue, cons);\n\t\txennet_move_rx_slot(queue, skb, ref);\n\t} while (extra.flags & XEN_NETIF_EXTRA_FLAG_MORE);\n\n\txennet_set_rx_rsp_cons(queue, cons);\n\treturn err;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":369193,"func":"static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)\n\t__must_hold(&ctx->uring_lock)\n{\n\tunsigned int entries = io_sqring_entries(ctx);\n\tint submitted = 0;\n\n\tif (unlikely(!entries))\n\t\treturn 0;\n\t\/* make sure SQ entry isn't read before tail *\/\n\tnr = min3(nr, ctx->sq_entries, entries);\n\tio_get_task_refs(nr);\n\n\tio_submit_state_start(&ctx->submit_state, nr);\n\tdo {\n\t\tconst struct io_uring_sqe *sqe;\n\t\tstruct io_kiocb *req;\n\n\t\tif (unlikely(!io_alloc_req_refill(ctx))) {\n\t\t\tif (!submitted)\n\t\t\t\tsubmitted = -EAGAIN;\n\t\t\tbreak;\n\t\t}\n\t\treq = io_alloc_req(ctx);\n\t\tsqe = io_get_sqe(ctx);\n\t\tif (unlikely(!sqe)) {\n\t\t\twq_stack_add_head(&req->comp_list, &ctx->submit_state.free_list);\n\t\t\tbreak;\n\t\t}\n\t\t\/* will complete beyond this point, count as submitted *\/\n\t\tsubmitted++;\n\t\tif (io_submit_sqe(ctx, req, sqe)) {\n\t\t\t\/*\n\t\t\t * Continue submitting even for sqe failure if the\n\t\t\t * ring was setup with IORING_SETUP_SUBMIT_ALL\n\t\t\t *\/\n\t\t\tif (!(ctx->flags & IORING_SETUP_SUBMIT_ALL))\n\t\t\t\tbreak;\n\t\t}\n\t} while (submitted < nr);\n\n\tif (unlikely(submitted != nr)) {\n\t\tint ref_used = (submitted == -EAGAIN) ? 0 : submitted;\n\t\tint unused = nr - ref_used;\n\n\t\tcurrent->io_uring->cached_refs += unused;\n\t}\n\n\tio_submit_state_end(ctx);\n\t \/* Commit SQ ring head once we've consumed and submitted all SQEs *\/\n\tio_commit_sqring(ctx);\n\n\treturn submitted;","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":413842,"func":"void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int indy_index, TRAPS) {\n  ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(indy_index);\n  int pool_index = cpce->constant_pool_index();\n\n  \/\/ Resolve the bootstrap specifier (BSM + optional arguments).\n  BootstrapInfo bootstrap_specifier(pool, pool_index, indy_index);\n\n  \/\/ Check if CallSite has been bound already or failed already, and short circuit:\n  {\n    bool is_done = bootstrap_specifier.resolve_previously_linked_invokedynamic(result, CHECK);\n    if (is_done) return;\n  }\n\n  \/\/ The initial step in Call Site Specifier Resolution is to resolve the symbolic\n  \/\/ reference to a method handle which will be the bootstrap method for a dynamic\n  \/\/ call site.  If resolution for the java.lang.invoke.MethodHandle for the bootstrap\n  \/\/ method fails, then a MethodHandleInError is stored at the corresponding bootstrap\n  \/\/ method's CP index for the CONSTANT_MethodHandle_info.  So, there is no need to\n  \/\/ set the indy_rf flag since any subsequent invokedynamic instruction which shares\n  \/\/ this bootstrap method will encounter the resolution of MethodHandleInError.\n\n  resolve_dynamic_call(result, bootstrap_specifier, CHECK);\n\n  LogTarget(Debug, methodhandles, indy) lt_indy;\n  if (lt_indy.is_enabled()) {\n    LogStream ls(lt_indy);\n    bootstrap_specifier.print_msg_on(&ls, \"resolve_invokedynamic\");\n  }\n\n  \/\/ The returned linkage result is provisional up to the moment\n  \/\/ the interpreter or runtime performs a serialized check of\n  \/\/ the relevant CPCE::f1 field.  This is done by the caller\n  \/\/ of this method, via CPCE::set_dynamic_call, which uses\n  \/\/ an ObjectLocker to do the final serialization of updates\n  \/\/ to CPCE state, including f1.\n\n  \/\/ Log dynamic info to CDS classlist.\n  ArchiveUtils::log_to_classlist(&bootstrap_specifier, CHECK);\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":424921,"func":"static int iwl_pcie_load_cpu_sections_8000(struct iwl_trans *trans,\n\t\t\t\t\t   const struct fw_img *image,\n\t\t\t\t\t   int cpu,\n\t\t\t\t\t   int *first_ucode_section)\n{\n\tint shift_param;\n\tint i, ret = 0, sec_num = 0x1;\n\tu32 val, last_read_idx = 0;\n\n\tif (cpu == 1) {\n\t\tshift_param = 0;\n\t\t*first_ucode_section = 0;\n\t} else {\n\t\tshift_param = 16;\n\t\t(*first_ucode_section)++;\n\t}\n\n\tfor (i = *first_ucode_section; i < image->num_sec; i++) {\n\t\tlast_read_idx = i;\n\n\t\t\/*\n\t\t * CPU1_CPU2_SEPARATOR_SECTION delimiter - separate between\n\t\t * CPU1 to CPU2.\n\t\t * PAGING_SEPARATOR_SECTION delimiter - separate between\n\t\t * CPU2 non paged to CPU2 paging sec.\n\t\t *\/\n\t\tif (!image->sec[i].data ||\n\t\t    image->sec[i].offset == CPU1_CPU2_SEPARATOR_SECTION ||\n\t\t    image->sec[i].offset == PAGING_SEPARATOR_SECTION) {\n\t\t\tIWL_DEBUG_FW(trans,\n\t\t\t\t     \"Break since Data not valid or Empty section, sec = %d\\n\",\n\t\t\t\t     i);\n\t\t\tbreak;\n\t\t}\n\n\t\tret = iwl_pcie_load_section(trans, i, &image->sec[i]);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/* Notify ucode of loaded section number and status *\/\n\t\tval = iwl_read_direct32(trans, FH_UCODE_LOAD_STATUS);\n\t\tval = val | (sec_num << shift_param);\n\t\tiwl_write_direct32(trans, FH_UCODE_LOAD_STATUS, val);\n\n\t\tsec_num = (sec_num << 1) | 0x1;\n\t}\n\n\t*first_ucode_section = last_read_idx;\n\n\tiwl_enable_interrupts(trans);\n\n\tif (trans->trans_cfg->use_tfh) {\n\t\tif (cpu == 1)\n\t\t\tiwl_write_prph(trans, UREG_UCODE_LOAD_STATUS,\n\t\t\t\t       0xFFFF);\n\t\telse\n\t\t\tiwl_write_prph(trans, UREG_UCODE_LOAD_STATUS,\n\t\t\t\t       0xFFFFFFFF);\n\t} else {\n\t\tif (cpu == 1)\n\t\t\tiwl_write_direct32(trans, FH_UCODE_LOAD_STATUS,\n\t\t\t\t\t   0xFFFF);\n\t\telse\n\t\t\tiwl_write_direct32(trans, FH_UCODE_LOAD_STATUS,\n\t\t\t\t\t   0xFFFFFFFF);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":523,"total_token_length":759,"max_tokens_setting":1024}
+{"idx":338224,"func":"bool WasmBinaryBuilder::maybeVisitSIMDLoad(Expression*& out, uint32_t code) {\n  if (code == BinaryConsts::V128Load) {\n    auto* curr = allocator.alloc<Load>();\n    curr->type = Type::v128;\n    curr->bytes = 16;\n    readMemoryAccess(curr->align, curr->offset);\n    curr->isAtomic = false;\n    curr->ptr = popNonVoidExpression();\n    curr->finalize();\n    out = curr;\n    return true;\n  }\n  SIMDLoad* curr;\n  switch (code) {\n    case BinaryConsts::V128Load8Splat:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load8SplatVec128;\n      break;\n    case BinaryConsts::V128Load16Splat:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load16SplatVec128;\n      break;\n    case BinaryConsts::V128Load32Splat:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load32SplatVec128;\n      break;\n    case BinaryConsts::V128Load64Splat:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load64SplatVec128;\n      break;\n    case BinaryConsts::V128Load8x8S:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load8x8SVec128;\n      break;\n    case BinaryConsts::V128Load8x8U:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load8x8UVec128;\n      break;\n    case BinaryConsts::V128Load16x4S:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load16x4SVec128;\n      break;\n    case BinaryConsts::V128Load16x4U:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load16x4UVec128;\n      break;\n    case BinaryConsts::V128Load32x2S:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load32x2SVec128;\n      break;\n    case BinaryConsts::V128Load32x2U:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load32x2UVec128;\n      break;\n    case BinaryConsts::V128Load32Zero:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load32ZeroVec128;\n      break;\n    case BinaryConsts::V128Load64Zero:\n      curr = allocator.alloc<SIMDLoad>();\n      curr->op = Load64ZeroVec128;\n      break;\n    default:\n      return false;\n  }\n  readMemoryAccess(curr->align, curr->offset);\n  curr->ptr = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":703,"total_token_length":939,"max_tokens_setting":1024}
+{"idx":385883,"func":"SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)\n{\n\tconst struct cred *old_cred;\n\tstruct cred *override_cred;\n\tstruct path path;\n\tstruct inode *inode;\n\tint res;\n\tunsigned int lookup_flags = LOOKUP_FOLLOW;\n\n\tif (mode & ~S_IRWXO)\t\/* where's F_OK, X_OK, W_OK, R_OK? *\/\n\t\treturn -EINVAL;\n\n\toverride_cred = prepare_creds();\n\tif (!override_cred)\n\t\treturn -ENOMEM;\n\n\toverride_cred->fsuid = override_cred->uid;\n\toverride_cred->fsgid = override_cred->gid;\n\n\tif (!issecure(SECURE_NO_SETUID_FIXUP)) {\n\t\t\/* Clear the capabilities if we switch to a non-root user *\/\n\t\tkuid_t root_uid = make_kuid(override_cred->user_ns, 0);\n\t\tif (!uid_eq(override_cred->uid, root_uid))\n\t\t\tcap_clear(override_cred->cap_effective);\n\t\telse\n\t\t\toverride_cred->cap_effective =\n\t\t\t\toverride_cred->cap_permitted;\n\t}\n\n\told_cred = override_creds(override_cred);\nretry:\n\tres = user_path_at(dfd, filename, lookup_flags, &path);\n\tif (res)\n\t\tgoto out;\n\n\tinode = path.dentry->d_inode;\n\n\tif ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) {\n\t\t\/*\n\t\t * MAY_EXEC on regular files is denied if the fs is mounted\n\t\t * with the \"noexec\" flag.\n\t\t *\/\n\t\tres = -EACCES;\n\t\tif (path.mnt->mnt_flags & MNT_NOEXEC)\n\t\t\tgoto out_path_release;\n\t}\n\n\tres = inode_permission(inode, mode | MAY_ACCESS);\n\t\/* SuS v2 requires we report a read only fs too *\/\n\tif (res || !(mode & S_IWOTH) || special_file(inode->i_mode))\n\t\tgoto out_path_release;\n\t\/*\n\t * This is a rare case where using __mnt_is_readonly()\n\t * is OK without a mnt_want\/drop_write() pair.  Since\n\t * no actual write to the fs is performed here, we do\n\t * not need to telegraph to that to anyone.\n\t *\n\t * By doing this, we accept that this access is\n\t * inherently racy and know that the fs may change\n\t * state before we even see this result.\n\t *\/\n\tif (__mnt_is_readonly(path.mnt))\n\t\tres = -EROFS;\n\nout_path_release:\n\tpath_put(&path);\n\tif (retry_estale(res, lookup_flags)) {\n\t\tlookup_flags |= LOOKUP_REVAL;\n\t\tgoto retry;\n\t}\nout:\n\trevert_creds(old_cred);\n\tput_cred(override_cred);\n\treturn res;\n}","target":0,"code_token_length":577,"total_token_length":813,"max_tokens_setting":1024}
+{"idx":344816,"func":"strdelim_internal(char **s, int split_equals)\n{\n\tchar *old;\n\tint wspace = 0;\n\n\tif (*s == NULL)\n\t\treturn NULL;\n\n\told = *s;\n\n\t*s = strpbrk(*s,\n\t    split_equals ? WHITESPACE QUOTE \"=\" : WHITESPACE QUOTE);\n\tif (*s == NULL)\n\t\treturn (old);\n\n\tif (*s[0] == '\\\"') {\n\t\tmemmove(*s, *s + 1, strlen(*s)); \/* move nul too *\/\n\t\t\/* Find matching quote *\/\n\t\tif ((*s = strpbrk(*s, QUOTE)) == NULL) {\n\t\t\treturn (NULL);\t\t\/* no matching quote *\/\n\t\t} else {\n\t\t\t*s[0] = '\\0';\n\t\t\t*s += strspn(*s + 1, WHITESPACE) + 1;\n\t\t\treturn (old);\n\t\t}\n\t}\n\n\t\/* Allow only one '=' to be skipped *\/\n\tif (split_equals && *s[0] == '=')\n\t\twspace = 1;\n\t*s[0] = '\\0';\n\n\t\/* Skip any extra whitespace after first token *\/\n\t*s += strspn(*s + 1, WHITESPACE) + 1;\n\tif (split_equals && *s[0] == '=' && !wspace)\n\t\t*s += strspn(*s + 1, WHITESPACE) + 1;\n\n\treturn (old);\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":453042,"func":"static void nft_flow_rule_offload_abort(struct net *net,\n\t\t\t\t\tstruct nft_trans *trans)\n{\n\tstruct nftables_pernet *nft_net = nft_pernet(net);\n\tint err = 0;\n\n\tlist_for_each_entry_continue_reverse(trans, &nft_net->commit_list, list) {\n\t\tif (trans->ctx.family != NFPROTO_NETDEV)\n\t\t\tcontinue;\n\n\t\tswitch (trans->msg_type) {\n\t\tcase NFT_MSG_NEWCHAIN:\n\t\t\tif (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD) ||\n\t\t\t    nft_trans_chain_update(trans))\n\t\t\t\tcontinue;\n\n\t\t\terr = nft_flow_offload_chain(trans->ctx.chain, NULL,\n\t\t\t\t\t\t     FLOW_BLOCK_UNBIND);\n\t\t\tbreak;\n\t\tcase NFT_MSG_DELCHAIN:\n\t\t\tif (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))\n\t\t\t\tcontinue;\n\n\t\t\terr = nft_flow_offload_chain(trans->ctx.chain, NULL,\n\t\t\t\t\t\t     FLOW_BLOCK_BIND);\n\t\t\tbreak;\n\t\tcase NFT_MSG_NEWRULE:\n\t\t\tif (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))\n\t\t\t\tcontinue;\n\n\t\t\terr = nft_flow_offload_rule(trans->ctx.chain,\n\t\t\t\t\t\t    nft_trans_rule(trans),\n\t\t\t\t\t\t    NULL, FLOW_CLS_DESTROY);\n\t\t\tbreak;\n\t\tcase NFT_MSG_DELRULE:\n\t\t\tif (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))\n\t\t\t\tcontinue;\n\n\t\t\terr = nft_flow_offload_rule(trans->ctx.chain,\n\t\t\t\t\t\t    nft_trans_rule(trans),\n\t\t\t\t\t\t    nft_trans_flow_rule(trans),\n\t\t\t\t\t\t    FLOW_CLS_REPLACE);\n\t\t\tbreak;\n\t\t}\n\n\t\tif (WARN_ON_ONCE(err))\n\t\t\tbreak;\n\t}\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":299904,"func":"auths_init(void)\n{\nauth_instance *au, *bu;\nreadconf_driver_init(US\"authenticator\",\n  (driver_instance **)(&auths),      \/* chain anchor *\/\n  (driver_info *)auths_available,    \/* available drivers *\/\n  sizeof(auth_info),                 \/* size of info block *\/\n  &auth_defaults,                    \/* default values for generic options *\/\n  sizeof(auth_instance),             \/* size of instance block *\/\n  optionlist_auths,                  \/* generic options *\/\n  optionlist_auths_size);\n\nfor (au = auths; au != NULL; au = au->next)\n  {\n  if (au->public_name == NULL)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG, \"no public name specified for \"\n      \"the %s authenticator\", au->name);\n  for (bu = au->next; bu != NULL; bu = bu->next)\n    {\n    if (strcmpic(au->public_name, bu->public_name) == 0)\n      {\n      if ((au->client && bu->client) || (au->server && bu->server))\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG, \"two %s authenticators \"\n          \"(%s and %s) have the same public name (%s)\",\n          (au->client)? US\"client\" : US\"server\", au->name, bu->name,\n          au->public_name);\n      }\n    }\n  }\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":281069,"func":"static int xfrm_bundle_ok(struct xfrm_dst *first)\n{\n\tstruct dst_entry *dst = &first->u.dst;\n\tstruct xfrm_dst *last;\n\tu32 mtu;\n\n\tif (!dst_check(dst->path, ((struct xfrm_dst *)dst)->path_cookie) ||\n\t    (dst->dev && !netif_running(dst->dev)))\n\t\treturn 0;\n\n\tif (dst->flags & DST_XFRM_QUEUE)\n\t\treturn 1;\n\n\tlast = NULL;\n\n\tdo {\n\t\tstruct xfrm_dst *xdst = (struct xfrm_dst *)dst;\n\n\t\tif (dst->xfrm->km.state != XFRM_STATE_VALID)\n\t\t\treturn 0;\n\t\tif (xdst->xfrm_genid != dst->xfrm->genid)\n\t\t\treturn 0;\n\t\tif (xdst->num_pols > 0 &&\n\t\t    xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))\n\t\t\treturn 0;\n\n\t\tmtu = dst_mtu(dst->child);\n\t\tif (xdst->child_mtu_cached != mtu) {\n\t\t\tlast = xdst;\n\t\t\txdst->child_mtu_cached = mtu;\n\t\t}\n\n\t\tif (!dst_check(xdst->route, xdst->route_cookie))\n\t\t\treturn 0;\n\t\tmtu = dst_mtu(xdst->route);\n\t\tif (xdst->route_mtu_cached != mtu) {\n\t\t\tlast = xdst;\n\t\t\txdst->route_mtu_cached = mtu;\n\t\t}\n\n\t\tdst = dst->child;\n\t} while (dst->xfrm);\n\n\tif (likely(!last))\n\t\treturn 1;\n\n\tmtu = last->child_mtu_cached;\n\tfor (;;) {\n\t\tdst = &last->u.dst;\n\n\t\tmtu = xfrm_state_mtu(dst->xfrm, mtu);\n\t\tif (mtu > last->route_mtu_cached)\n\t\t\tmtu = last->route_mtu_cached;\n\t\tdst_metric_set(dst, RTAX_MTU, mtu);\n\n\t\tif (last == first)\n\t\t\tbreak;\n\n\t\tlast = (struct xfrm_dst *)last->u.dst.next;\n\t\tlast->child_mtu_cached = mtu;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":427179,"func":"static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {\n  FuncState *fs = ls->fs;\n  int extra = fs->freereg;  \/* eventual position to save local variable *\/\n  int conflict = 0;\n  for (; lh; lh = lh->prev) {  \/* check all previous assignments *\/\n    if (vkisindexed(lh->v.k)) {  \/* assignment to table field? *\/\n      if (lh->v.k == VINDEXUP) {  \/* is table an upvalue? *\/\n        if (v->k == VUPVAL && lh->v.u.ind.t == v->u.info) {\n          conflict = 1;  \/* table is the upvalue being assigned now *\/\n          lh->v.k = VINDEXSTR;\n          lh->v.u.ind.t = extra;  \/* assignment will use safe copy *\/\n        }\n      }\n      else {  \/* table is a register *\/\n        if (v->k == VLOCAL && lh->v.u.ind.t == v->u.var.ridx) {\n          conflict = 1;  \/* table is the local being assigned now *\/\n          lh->v.u.ind.t = extra;  \/* assignment will use safe copy *\/\n        }\n        \/* is index the local being assigned? *\/\n        if (lh->v.k == VINDEXED && v->k == VLOCAL &&\n            lh->v.u.ind.idx == v->u.var.ridx) {\n          conflict = 1;\n          lh->v.u.ind.idx = extra;  \/* previous assignment will use safe copy *\/\n        }\n      }\n    }\n  }\n  if (conflict) {\n    \/* copy upvalue\/local value to a temporary (in position 'extra') *\/\n    if (v->k == VLOCAL)\n      luaK_codeABC(fs, OP_MOVE, extra, v->u.var.ridx, 0);\n    else\n      luaK_codeABC(fs, OP_GETUPVAL, extra, v->u.info, 0);\n    luaK_reserveregs(fs, 1);\n  }\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":196894,"func":"Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const\n{\n\tDoQuickSanityCheck();\n\tModularArithmetic modn(m_n);\n\tInteger r, rInv;\n\tdo {\t\/\/ do this in a loop for people using small numbers for testing\n\t\tr.Randomize(rng, Integer::One(), m_n - Integer::One());\n\t\trInv = modn.MultiplicativeInverse(r);\n\t} while (rInv.IsZero());\n\tInteger re = modn.Square(r);\n\tre = modn.Multiply(re, x);\t\t\t\/\/ blind\n\n\tInteger cp=re%m_p, cq=re%m_q;\n\tif (Jacobi(cp, m_p) * Jacobi(cq, m_q) != 1)\n\t{\n\t\tcp = cp.IsOdd() ? (cp+m_p) >> 1 : cp >> 1;\n\t\tcq = cq.IsOdd() ? (cq+m_q) >> 1 : cq >> 1;\n\t}\n\n\t#pragma omp parallel\n\t\t#pragma omp sections\n\t\t{\n\t\t\t#pragma omp section\n\t\t\t\tcp = ModularSquareRoot(cp, m_p);\n\t\t\t#pragma omp section\n\t\t\t\tcq = ModularSquareRoot(cq, m_q);\n\t\t}\n\n\tInteger y = CRT(cq, m_q, cp, m_p, m_u);\n\ty = modn.Multiply(y, rInv);\t\t\t\t\/\/ unblind\n\ty = STDMIN(y, m_n-y);\n\tif (ApplyFunction(y) != x)\t\t\t\t\/\/ check\n\t\tthrow Exception(Exception::OTHER_ERROR, \"InvertibleRWFunction: computational error during private key operation\");\n\treturn y;\n}","target":1,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":405377,"func":"static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,\n\t\t\t\t\t\t struct xfrm_flo *xflo,\n\t\t\t\t\t\t const struct flowi *fl,\n\t\t\t\t\t\t int num_xfrms,\n\t\t\t\t\t\t u16 family)\n{\n\tint err;\n\tstruct net_device *dev;\n\tstruct dst_entry *dst;\n\tstruct dst_entry *dst1;\n\tstruct xfrm_dst *xdst;\n\n\txdst = xfrm_alloc_dst(net, family);\n\tif (IS_ERR(xdst))\n\t\treturn xdst;\n\n\tif (!(xflo->flags & XFRM_LOOKUP_QUEUE) ||\n\t    net->xfrm.sysctl_larval_drop ||\n\t    num_xfrms <= 0)\n\t\treturn xdst;\n\n\tdst = xflo->dst_orig;\n\tdst1 = &xdst->u.dst;\n\tdst_hold(dst);\n\txdst->route = dst;\n\n\tdst_copy_metrics(dst1, dst);\n\n\tdst1->obsolete = DST_OBSOLETE_FORCE_CHK;\n\tdst1->flags |= DST_XFRM_QUEUE;\n\tdst1->lastuse = jiffies;\n\n\tdst1->input = dst_discard;\n\tdst1->output = xdst_queue_output;\n\n\tdst_hold(dst);\n\txfrm_dst_set_child(xdst, dst);\n\txdst->path = dst;\n\n\txfrm_init_path((struct xfrm_dst *)dst1, dst, 0);\n\n\terr = -ENODEV;\n\tdev = dst->dev;\n\tif (!dev)\n\t\tgoto free_dst;\n\n\terr = xfrm_fill_dst(xdst, dev, fl);\n\tif (err)\n\t\tgoto free_dst;\n\nout:\n\treturn xdst;\n\nfree_dst:\n\tdst_release(dst1);\n\txdst = ERR_PTR(err);\n\tgoto out;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":338062,"func":"void WasmBinaryWriter::writeType(Type type) {\n  if (type.isRef() && !type.isBasic()) {\n    if (type.isNullable()) {\n      o << S32LEB(BinaryConsts::EncodedType::nullable);\n    } else {\n      o << S32LEB(BinaryConsts::EncodedType::nonnullable);\n    }\n    writeHeapType(type.getHeapType());\n    return;\n  }\n  if (type.isRtt()) {\n    auto rtt = type.getRtt();\n    if (rtt.hasDepth()) {\n      o << S32LEB(BinaryConsts::EncodedType::rtt_n);\n      o << U32LEB(rtt.depth);\n    } else {\n      o << S32LEB(BinaryConsts::EncodedType::rtt);\n    }\n    writeIndexedHeapType(rtt.heapType);\n    return;\n  }\n  int ret = 0;\n  TODO_SINGLE_COMPOUND(type);\n  switch (type.getBasic()) {\n    \/\/ None only used for block signatures. TODO: Separate out?\n    case Type::none:\n      ret = BinaryConsts::EncodedType::Empty;\n      break;\n    case Type::i32:\n      ret = BinaryConsts::EncodedType::i32;\n      break;\n    case Type::i64:\n      ret = BinaryConsts::EncodedType::i64;\n      break;\n    case Type::f32:\n      ret = BinaryConsts::EncodedType::f32;\n      break;\n    case Type::f64:\n      ret = BinaryConsts::EncodedType::f64;\n      break;\n    case Type::v128:\n      ret = BinaryConsts::EncodedType::v128;\n      break;\n    case Type::funcref:\n      ret = BinaryConsts::EncodedType::funcref;\n      break;\n    case Type::externref:\n      ret = BinaryConsts::EncodedType::externref;\n      break;\n    case Type::anyref:\n      ret = BinaryConsts::EncodedType::anyref;\n      break;\n    case Type::eqref:\n      ret = BinaryConsts::EncodedType::eqref;\n      break;\n    case Type::i31ref:\n      ret = BinaryConsts::EncodedType::i31ref;\n      break;\n    case Type::dataref:\n      ret = BinaryConsts::EncodedType::dataref;\n      break;\n    default:\n      WASM_UNREACHABLE(\"unexpected type\");\n  }\n  o << S32LEB(ret);\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":216905,"func":"bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)\n{\n\n  if (!((options & SELECT_DISTINCT) && !group_list.elements))\n    hidden_bit_fields= 0;\n\n  \/\/ find_order_in_list() may need some extra space, so multiply by two.\n  order_group_num*= 2;\n\n  \/*\n    We have to create array in prepared statement memory if it is a\n    prepared statement\n  *\/\n  Query_arena *arena= thd->stmt_arena;\n  const uint n_elems= (n_sum_items +\n                       n_child_sum_items +\n                       item_list.elements +\n                       select_n_reserved +\n                       select_n_having_items +\n                       select_n_where_fields +\n                       order_group_num +\n                       hidden_bit_fields +\n                       fields_in_window_functions) * 5;\n  if (!ref_pointer_array.is_null())\n  {\n    \/*\n      We need to take 'n_sum_items' into account when allocating the array,\n      and this may actually increase during the optimization phase due to\n      MIN\/MAX rewrite in Item_in_subselect::single_value_transformer.\n      In the usual case we can reuse the array from the prepare phase.\n      If we need a bigger array, we must allocate a new one.\n     *\/\n    if (ref_pointer_array.size() >= n_elems)\n      return false;\n   }\n  Item **array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));\n  if (array != NULL)\n    ref_pointer_array= Ref_ptr_array(array, n_elems);\n\n  return array == NULL;\n}","target":1,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":317140,"func":"static int smack_file_send_sigiotask(struct task_struct *tsk,\n\t\t\t\t     struct fown_struct *fown, int signum)\n{\n\tstruct smack_known **blob;\n\tstruct smack_known *skp;\n\tstruct smack_known *tkp = smk_of_task(smack_cred(tsk->cred));\n\tconst struct cred *tcred;\n\tstruct file *file;\n\tint rc;\n\tstruct smk_audit_info ad;\n\n\t\/*\n\t * struct fown_struct is never outside the context of a struct file\n\t *\/\n\tfile = container_of(fown, struct file, f_owner);\n\n\t\/* we don't log here as rc can be overriden *\/\n\tblob = smack_file(file);\n\tskp = *blob;\n\trc = smk_access(skp, tkp, MAY_DELIVER, NULL);\n\trc = smk_bu_note(\"sigiotask\", skp, tkp, MAY_DELIVER, rc);\n\n\trcu_read_lock();\n\ttcred = __task_cred(tsk);\n\tif (rc != 0 && smack_privileged_cred(CAP_MAC_OVERRIDE, tcred))\n\t\trc = 0;\n\trcu_read_unlock();\n\n\tsmk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK);\n\tsmk_ad_setfield_u_tsk(&ad, tsk);\n\tsmack_log(skp->smk_known, tkp->smk_known, MAY_DELIVER, rc, &ad);\n\treturn rc;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":226227,"func":"GF_Err video_sample_entry_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_ESDS:\n\t\tBOX_FIELD_ASSIGN(esd, GF_ESDBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_RINF:\n\t\tBOX_FIELD_ASSIGN(rinf, GF_RestrictedSchemeInfoBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_AVCC:\n\t\tBOX_FIELD_ASSIGN(avc_config, GF_AVCConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_HVCC:\n\t\tBOX_FIELD_ASSIGN(hevc_config, GF_HEVCConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_VVCC:\n\t\tBOX_FIELD_ASSIGN(vvc_config, GF_VVCConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_SVCC:\n\t\tBOX_FIELD_ASSIGN(svc_config, GF_AVCConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_MVCC:\n\t\tBOX_FIELD_ASSIGN(mvc_config, GF_AVCConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_LHVC:\n\t\tBOX_FIELD_ASSIGN(lhvc_config, GF_HEVCConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_AV1C:\n\t\tBOX_FIELD_ASSIGN(av1_config, GF_AV1ConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_VPCC:\n\t\tBOX_FIELD_ASSIGN(vp_config, GF_VPConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_DVCC:\n\tcase GF_ISOM_BOX_TYPE_DVVC:\n\t\tBOX_FIELD_ASSIGN(dovi_config, GF_DOVIConfigurationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_UUID:\n\t\tif (! memcmp(((GF_UnknownUUIDBox*)a)->uuid, GF_ISOM_IPOD_EXT, 16)) {\n\t\t\tBOX_FIELD_ASSIGN(ipod_ext, GF_UnknownUUIDBox)\n\t\t} else {\n\t\t\treturn GF_OK;\n\t\t}\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_D263:\n\t\tBOX_FIELD_ASSIGN(cfg_3gpp, GF_3GPPConfigBox)\n\t\t\/*for 3GP config, remember sample entry type in config*\/\n\t\tif (ptr->cfg_3gpp)\n\t\t\tptr->cfg_3gpp->cfg.type = ptr->type;\n\t\tbreak;\n\n\tcase GF_ISOM_BOX_TYPE_JP2H:\n\t\tBOX_FIELD_ASSIGN(jp2h, GF_J2KHeaderBox)\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_PASP:\n\tcase GF_ISOM_BOX_TYPE_CLAP:\n\tcase GF_ISOM_BOX_TYPE_COLR:\n\tcase GF_ISOM_BOX_TYPE_MDCV:\n\tcase GF_ISOM_BOX_TYPE_CLLI:\n\tcase GF_ISOM_BOX_TYPE_CCST:\n\tcase GF_ISOM_BOX_TYPE_AUXI:\n\tcase GF_ISOM_BOX_TYPE_RVCC:\n\tcase GF_ISOM_BOX_TYPE_M4DS:\n\t\tif (!is_rem && !gf_isom_box_check_unique(s->child_boxes, a)) {\n\t\t\tERROR_ON_DUPLICATED_BOX(a, ptr)\n\t\t}\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":676,"total_token_length":912,"max_tokens_setting":1024}
+{"idx":508801,"func":"Item *st_select_lex::build_cond_for_grouping_fields(THD *thd, Item *cond,\n\t\t\t\t\t\t    bool no_top_clones)\n{\n  if (cond->get_extraction_flag() == FULL_EXTRACTION_FL)\n  {\n    if (no_top_clones)\n      return cond;\n    cond->clear_extraction_flag();\n    return cond->build_clone(thd, thd->mem_root);\n  }\n  if (cond->type() == Item::COND_ITEM)\n  {\n    bool cond_and= false;\n    Item_cond *new_cond;\n    if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)\n    {\n      cond_and= true;\n      new_cond=  new (thd->mem_root) Item_cond_and(thd);\n    }\n    else\n      new_cond= new (thd->mem_root) Item_cond_or(thd);\n    if (!new_cond)\n      return 0;\t\t\n    List_iterator<Item> li(*((Item_cond*) cond)->argument_list());\n    Item *item;\n    while ((item=li++))\n    {\n      if (item->get_extraction_flag() == NO_EXTRACTION_FL)\n      {\n\tDBUG_ASSERT(cond_and);\n\titem->clear_extraction_flag();\n\tcontinue;\n      }\n      Item *fix= build_cond_for_grouping_fields(thd, item,\n\t\t\t\t\t\tno_top_clones & cond_and);\n      if (!fix)\n      {\n\tif (cond_and)\n\t  continue;\n\tbreak;\n      }\n      new_cond->argument_list()->push_back(fix, thd->mem_root);\n    }\n    \n    if (!cond_and && item)\n    {\n      while((item= li++))\n\titem->clear_extraction_flag();\n      return 0;\n    }\n    switch (new_cond->argument_list()->elements) \n    {\n    case 0:\n      return 0;\t\t\t\n    case 1:\n      return new_cond->argument_list()->head();\n    default:\n      return new_cond;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":221523,"func":"get_dconf_data (const char  *app_id,\n                const char **paths,\n                const char  *migrate_path,\n                char       **defaults,\n                gsize       *defaults_size,\n                char       **values,\n                gsize       *values_size,\n                char       **locks,\n                gsize       *locks_size)\n{\n#ifdef HAVE_DCONF\n  DConfClient *client = NULL;\n  g_autofree char *prefix = NULL;\n#endif\n  g_autoptr(GKeyFile) defaults_data = NULL;\n  g_autoptr(GKeyFile) values_data = NULL;\n  g_autoptr(GString) locks_data = NULL;\n\n  defaults_data = g_key_file_new ();\n  values_data = g_key_file_new ();\n  locks_data = g_string_new (\"\");\n\n#ifdef HAVE_DCONF\n\n  client = dconf_client_new ();\n\n  prefix = flatpak_dconf_path_for_app_id (app_id);\n\n  if (migrate_path)\n    {\n      g_debug (\"Add values in dir '%s', prefix is '%s'\", migrate_path, prefix);\n      if (flatpak_dconf_path_is_similar (migrate_path, prefix))\n        add_dconf_dir_to_keyfile (values_data, client, migrate_path, DCONF_READ_USER_VALUE);\n      else\n        g_warning (\"Ignoring D-Conf migrate-path setting %s\", migrate_path);\n    }\n\n  g_debug (\"Add defaults in dir %s\", prefix);\n  add_dconf_dir_to_keyfile (defaults_data, client, prefix, DCONF_READ_DEFAULT_VALUE);\n\n  g_debug (\"Add locks in dir %s\", prefix);\n  add_dconf_locks_to_list (locks_data, client, prefix);\n\n  \/* We allow extra paths for defaults and locks, but not for user values *\/\n  if (paths)\n    {\n      int i;\n      for (i = 0; paths[i]; i++)\n        {\n          if (dconf_is_dir (paths[i], NULL))\n            {\n              g_debug (\"Add defaults in dir %s\", paths[i]);\n              add_dconf_dir_to_keyfile (defaults_data, client, paths[i], DCONF_READ_DEFAULT_VALUE);\n\n              g_debug (\"Add locks in dir %s\", paths[i]);\n              add_dconf_locks_to_list (locks_data, client, paths[i]);\n            }\n          else if (dconf_is_key (paths[i], NULL))\n            {\n              g_debug (\"Add individual key %s\", paths[i]);\n              add_dconf_key_to_keyfile (defaults_data, client, paths[i], DCONF_READ_DEFAULT_VALUE);\n              add_dconf_key_to_keyfile (values_data, client, paths[i], DCONF_READ_USER_VALUE);\n            }\n          else\n            {\n              g_warning (\"Ignoring settings path '%s': neither dir nor key\", paths[i]);\n            }\n        }\n    }\n#endif\n\n  *defaults = g_key_file_to_data (defaults_data, defaults_size, NULL);\n  *values = g_key_file_to_data (values_data, values_size, NULL);\n  *locks_size = locks_data->len;\n  *locks = g_string_free (g_steal_pointer (&locks_data), FALSE);\n\n#ifdef HAVE_DCONF\n  g_object_unref (client);\n#endif\n}","target":0,"code_token_length":666,"total_token_length":902,"max_tokens_setting":1024}
+{"idx":336005,"func":"static void sr9700_set_multicast(struct net_device *netdev)\n{\n\tstruct usbnet *dev = netdev_priv(netdev);\n\t\/* We use the 20 byte dev->data for our 8 byte filter buffer\n\t * to avoid allocating memory that is tricky to free later\n\t *\/\n\tu8 *hashes = (u8 *)&dev->data;\n\t\/* rx_ctl setting : enable, disable_long, disable_crc *\/\n\tu8 rx_ctl = RCR_RXEN | RCR_DIS_CRC | RCR_DIS_LONG;\n\n\tmemset(hashes, 0x00, SR_MCAST_SIZE);\n\t\/* broadcast address *\/\n\thashes[SR_MCAST_SIZE - 1] |= SR_MCAST_ADDR_FLAG;\n\tif (netdev->flags & IFF_PROMISC) {\n\t\trx_ctl |= RCR_PRMSC;\n\t} else if (netdev->flags & IFF_ALLMULTI ||\n\t\t   netdev_mc_count(netdev) > SR_MCAST_MAX) {\n\t\trx_ctl |= RCR_RUNT;\n\t} else if (!netdev_mc_empty(netdev)) {\n\t\tstruct netdev_hw_addr *ha;\n\n\t\tnetdev_for_each_mc_addr(ha, netdev) {\n\t\t\tu32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26;\n\t\t\thashes[crc >> 3] |= 1 << (crc & 0x7);\n\t\t}\n\t}\n\n\tsr_write_async(dev, SR_MAR, SR_MCAST_SIZE, hashes);\n\tsr_write_reg_async(dev, SR_RCR, rx_ctl);\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":279922,"func":"rename_buffer(char_u *new_fname)\n{\n    char_u\t*fname, *sfname, *xfname;\n    buf_T\t*buf;\n\n    buf = curbuf;\n    apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);\n    \/\/ buffer changed, don't change name now\n    if (buf != curbuf)\n\treturn FAIL;\n#ifdef FEAT_EVAL\n    if (aborting())\t    \/\/ autocmds may abort script processing\n\treturn FAIL;\n#endif\n    \/*\n     * The name of the current buffer will be changed.\n     * A new (unlisted) buffer entry needs to be made to hold the old file\n     * name, which will become the alternate file name.\n     * But don't set the alternate file name if the buffer didn't have a\n     * name.\n     *\/\n    fname = curbuf->b_ffname;\n    sfname = curbuf->b_sfname;\n    xfname = curbuf->b_fname;\n    curbuf->b_ffname = NULL;\n    curbuf->b_sfname = NULL;\n    if (setfname(curbuf, new_fname, NULL, TRUE) == FAIL)\n    {\n\tcurbuf->b_ffname = fname;\n\tcurbuf->b_sfname = sfname;\n\treturn FAIL;\n    }\n    curbuf->b_flags |= BF_NOTEDITED;\n    if (xfname != NULL && *xfname != NUL)\n    {\n\tbuf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0);\n\tif (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)\n\t    curwin->w_alt_fnum = buf->b_fnum;\n    }\n    vim_free(fname);\n    vim_free(sfname);\n    apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);\n\n    \/\/ Change directories when the 'acd' option is set.\n    DO_AUTOCHDIR;\n    return OK;\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":481268,"func":"static int mlx5_fpga_conn_post_recv(struct mlx5_fpga_conn *conn,\n\t\t\t\t    struct mlx5_fpga_dma_buf *buf)\n{\n\tstruct mlx5_wqe_data_seg *data;\n\tunsigned int ix;\n\tint err = 0;\n\n\terr = mlx5_fpga_conn_map_buf(conn, buf);\n\tif (unlikely(err))\n\t\tgoto out;\n\n\tif (unlikely(conn->qp.rq.pc - conn->qp.rq.cc >= conn->qp.rq.size)) {\n\t\tmlx5_fpga_conn_unmap_buf(conn, buf);\n\t\treturn -EBUSY;\n\t}\n\n\tix = conn->qp.rq.pc & (conn->qp.rq.size - 1);\n\tdata = mlx5_wq_cyc_get_wqe(&conn->qp.wq.rq, ix);\n\tdata->byte_count = cpu_to_be32(buf->sg[0].size);\n\tdata->lkey = cpu_to_be32(conn->fdev->conn_res.mkey.key);\n\tdata->addr = cpu_to_be64(buf->sg[0].dma_addr);\n\n\tconn->qp.rq.pc++;\n\tconn->qp.rq.bufs[ix] = buf;\n\n\t\/* Make sure that descriptors are written before doorbell record. *\/\n\tdma_wmb();\n\t*conn->qp.wq.rq.db = cpu_to_be32(conn->qp.rq.pc & 0xffff);\nout:\n\treturn err;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":463211,"func":"static int split_attribs(const char *data, int datalen,\n                         struct buf *value, struct annotate_metadata *mdata)\n{\n    unsigned long tmp; \/* for alignment *\/\n    const char *tmps;\n    const char *end = data + datalen;\n\n    \/* initialize metadata *\/\n    memset(mdata, 0, sizeof(struct annotate_metadata));\n\n    \/* xxx sanity check the data? *\/\n    if (datalen <= 0)\n            return 1;\n    \/*\n     * Sigh...this is dumb.  We take care to be machine independent by\n     * storing the length in network byte order...but the size of the\n     * length field depends on whether we're running on a 32b or 64b\n     * platform.\n     *\/\n    memcpy(&tmp, data, sizeof(unsigned long));\n    data += sizeof(unsigned long); \/* skip to value *\/\n\n    buf_init_ro(value, data, ntohl(tmp));\n\n    \/*\n     * In records written by older versions of Cyrus, there will be\n     * binary encoded content-type and modifiedsince values after the\n     * data. We don't care about those anymore, so we just ignore them\n     * and skip to the entry's metadata.\n     *\/\n    tmps = data + ntohl(tmp) + 1;  \/* Skip zero-terminated value *\/\n    if (tmps < end) {\n        tmps += strlen(tmps) + 1;      \/* Skip zero-terminated content-type *\/\n        tmps += sizeof(unsigned long); \/* Skip modifiedsince value *\/\n    }\n\n    if (tmps < end) {\n        \/* make sure ntohll's input is correctly aligned *\/\n        modseq_t modseq;\n        memcpy(&modseq, tmps, sizeof(modseq));\n        mdata->modseq = ntohll(modseq);\n        tmps += sizeof(modseq_t);\n    }\n\n    if (tmps < end) {\n        mdata->flags = *tmps;\n        tmps++;\n    }\n\n    \/* normalise deleted entries *\/\n    if (mdata->flags & ANNOTATE_FLAG_DELETED) {\n        buf_reset(value);\n    }\n\n    return 0;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":229337,"func":"Status GetDeviceForInput(const EagerOperation& op, const EagerContext& ctx,\n                         TensorHandle* tensor_handle, Device** result) {\n  Device* cpu_device = ctx.HostCPU();\n  string device_name;\n  if (tensor_handle->Type() != TensorHandle::LOCAL) {\n    Device* device = tensor_handle->device();\n    device_name = device != nullptr ? device->name() : cpu_device->name();\n    *result = (device == nullptr ? cpu_device : device);\n  } else if (tensor_handle->dtype == DT_RESOURCE) {\n    \/\/ Use the resource's actual device because it is the device that will\n    \/\/ influence partitioning the multi-device function.\n    const Tensor* tensor;\n    \/\/ TODO(fishx): Avoid blocking here.\n    TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor));\n    if (tensor->NumElements() == 0) {\n      return errors::InvalidArgument(\"Empty resource handle\");\n    }\n    const ResourceHandle& handle = tensor->flat<ResourceHandle>()(0);\n    device_name = handle.device();\n\n    Device* input_device;\n    TF_RETURN_IF_ERROR(\n        ctx.FindDeviceFromName(device_name.c_str(), &input_device));\n    *result = input_device;\n  } else {\n    Device* device = tensor_handle->device();\n    const bool is_tpu = device != nullptr && device->device_type() == \"TPU\";\n    \/\/ int32 return values can be placed on TPUs.\n    const bool use_host_memory =\n        is_tpu ? MTypeFromDTypeIntsOnDevice(tensor_handle->dtype)\n               : MTypeFromDType(tensor_handle->dtype);\n    if (use_host_memory) {\n      *result = cpu_device;\n    } else {\n      \/\/ Eager ops executing as functions should have their preferred inputs set\n      \/\/ to the op's device. This allows us to avoid expensive D2H copies if a\n      \/\/ mirror of the tensor already exists on the op's device.\n      if (!op.is_function() && device != nullptr && device != cpu_device) {\n        device = absl::get<Device*>(op.Device());\n      }\n      *result = (device == nullptr ? cpu_device : device);\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":482682,"func":"flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)\n{\n  gulong count, lines, row;\n  guchar x;\n\n  g_return_val_if_fail (flxdec != NULL, FALSE);\n\n  lines = flxdec->hdr.height;\n  while (lines--) {\n    \/* packet count.  \n     * should not be used anymore, since the flc format can\n     * contain more then 255 RLE packets. we use the frame \n     * width instead. \n     *\/\n    data++;\n\n    row = flxdec->hdr.width;\n    while (row) {\n      count = *data++;\n\n      if (count > 0x7f) {\n        \/* literal run *\/\n        count = 0x100 - count;\n        if ((glong) row - (glong) count < 0) {\n          GST_ERROR_OBJECT (flxdec, \"Invalid BRUN packet detected.\");\n          return FALSE;\n        }\n        row -= count;\n\n        while (count--)\n          *dest++ = *data++;\n\n      } else {\n        if ((glong) row - (glong) count < 0) {\n          GST_ERROR_OBJECT (flxdec, \"Invalid BRUN packet detected.\");\n          return FALSE;\n        }\n\n        \/* replicate run *\/\n        row -= count;\n        x = *data++;\n\n        while (count--)\n          *dest++ = x;\n      }\n    }\n  }\n\n  return TRUE;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":338237,"func":"bool WasmBinaryBuilder::maybeVisitSIMDExtract(Expression*& out, uint32_t code) {\n  SIMDExtract* curr;\n  switch (code) {\n    case BinaryConsts::I8x16ExtractLaneS:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneSVecI8x16;\n      curr->index = getLaneIndex(16);\n      break;\n    case BinaryConsts::I8x16ExtractLaneU:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneUVecI8x16;\n      curr->index = getLaneIndex(16);\n      break;\n    case BinaryConsts::I16x8ExtractLaneS:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneSVecI16x8;\n      curr->index = getLaneIndex(8);\n      break;\n    case BinaryConsts::I16x8ExtractLaneU:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneUVecI16x8;\n      curr->index = getLaneIndex(8);\n      break;\n    case BinaryConsts::I32x4ExtractLane:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneVecI32x4;\n      curr->index = getLaneIndex(4);\n      break;\n    case BinaryConsts::I64x2ExtractLane:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneVecI64x2;\n      curr->index = getLaneIndex(2);\n      break;\n    case BinaryConsts::F32x4ExtractLane:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneVecF32x4;\n      curr->index = getLaneIndex(4);\n      break;\n    case BinaryConsts::F64x2ExtractLane:\n      curr = allocator.alloc<SIMDExtract>();\n      curr->op = ExtractLaneVecF64x2;\n      curr->index = getLaneIndex(2);\n      break;\n    default:\n      return false;\n  }\n  curr->vec = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":421391,"func":"void jsC_dumpfunction(js_State *J, js_Function *F)\n{\n\tjs_Instruction *p = F->code;\n\tjs_Instruction *end = F->code + F->codelen;\n\tchar *s;\n\tdouble n;\n\tint i;\n\n\tminify = 0;\n\n\tprintf(\"%s(%d)\\n\", F->name, F->numparams);\n\tif (F->strict) printf(\"\\tstrict\\n\");\n\tif (F->lightweight) printf(\"\\tlightweight\\n\");\n\tif (F->arguments) printf(\"\\targuments\\n\");\n\tprintf(\"\\tsource %s:%d\\n\", F->filename, F->line);\n\tfor (i = 0; i < F->funlen; ++i)\n\t\tprintf(\"\\tfunction %d %s\\n\", i, F->funtab[i]->name);\n\tfor (i = 0; i < F->varlen; ++i)\n\t\tprintf(\"\\tlocal %d %s\\n\", i + 1, F->vartab[i]);\n\n\tprintf(\"{\\n\");\n\twhile (p < end) {\n\t\tint ln = *p++;\n\t\tint c = *p++;\n\n\t\tprintf(\"%5d(%3d): \", (int)(p - F->code) - 2, ln);\n\t\tps(opname[c]);\n\n\t\tswitch (c) {\n\t\tcase OP_INTEGER:\n\t\t\tprintf(\" %ld\", (long)((*p++) - 32768));\n\t\t\tbreak;\n\t\tcase OP_NUMBER:\n\t\t\tmemcpy(&n, p, sizeof(n));\n\t\t\tp += sizeof(n) \/ sizeof(*p);\n\t\t\tprintf(\" %.9g\", n);\n\t\t\tbreak;\n\t\tcase OP_STRING:\n\t\t\tmemcpy(&s, p, sizeof(s));\n\t\t\tp += sizeof(s) \/ sizeof(*p);\n\t\t\tpc(' ');\n\t\t\tpstr(s);\n\t\t\tbreak;\n\t\tcase OP_NEWREGEXP:\n\t\t\tpc(' ');\n\t\t\tmemcpy(&s, p, sizeof(s));\n\t\t\tp += sizeof(s) \/ sizeof(*p);\n\t\t\tpregexp(s, *p++);\n\t\t\tbreak;\n\n\t\tcase OP_GETVAR:\n\t\tcase OP_HASVAR:\n\t\tcase OP_SETVAR:\n\t\tcase OP_DELVAR:\n\t\tcase OP_GETPROP_S:\n\t\tcase OP_SETPROP_S:\n\t\tcase OP_DELPROP_S:\n\t\tcase OP_CATCH:\n\t\t\tmemcpy(&s, p, sizeof(s));\n\t\t\tp += sizeof(s) \/ sizeof(*p);\n\t\t\tpc(' ');\n\t\t\tps(s);\n\t\t\tbreak;\n\n\t\tcase OP_GETLOCAL:\n\t\tcase OP_SETLOCAL:\n\t\tcase OP_DELLOCAL:\n\t\t\tprintf(\" %s\", F->vartab[*p++ - 1]);\n\t\t\tbreak;\n\n\t\tcase OP_CLOSURE:\n\t\tcase OP_CALL:\n\t\tcase OP_NEW:\n\t\tcase OP_JUMP:\n\t\tcase OP_JTRUE:\n\t\tcase OP_JFALSE:\n\t\tcase OP_JCASE:\n\t\tcase OP_TRY:\n\t\t\tprintf(\" %ld\", (long)*p++);\n\t\t\tbreak;\n\t\t}\n\n\t\tnl();\n\t}\n\tprintf(\"}\\n\");\n\n\tfor (i = 0; i < F->funlen; ++i) {\n\t\tif (F->funtab[i] != F) {\n\t\t\tprintf(\"function %d \", i);\n\t\t\tjsC_dumpfunction(J, F->funtab[i]);\n\t\t}\n\t}\n}","target":0,"code_token_length":677,"total_token_length":913,"max_tokens_setting":1024}
+{"idx":314755,"func":"cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h,\n    const cdf_sat_t *sat, cdf_secid_t sid, size_t len, cdf_stream_t *scn)\n{\n\tsize_t ss = CDF_SEC_SIZE(h), i, j;\n\tssize_t nr;\n\tscn->sst_len = cdf_count_chain(sat, sid, ss);\n\tscn->sst_dirlen = len;\n\n\tif (scn->sst_len == (size_t)-1)\n\t\treturn -1;\n\n\tscn->sst_tab = calloc(scn->sst_len, ss);\n\tif (scn->sst_tab == NULL)\n\t\treturn -1;\n\n\tfor (j = i = 0; sid >= 0; i++, j++) {\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Read long sector chain loop limit\"));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (i >= scn->sst_len) {\n\t\t\tDPRINTF((\"Out of bounds reading long sector chain \"\n\t\t\t    \"%\" SIZE_T_FORMAT \"u > %\" SIZE_T_FORMAT \"u\\n\", i,\n\t\t\t    scn->sst_len));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif ((nr = cdf_read_sector(info, scn->sst_tab, i * ss, ss, h,\n\t\t    sid)) != (ssize_t)ss) {\n\t\t\tif (i == scn->sst_len - 1 && nr > 0) {\n\t\t\t\t\/* Last sector might be truncated *\/\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tDPRINTF((\"Reading long sector chain %d\", sid));\n\t\t\tgoto out;\n\t\t}\n\t\tsid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);\n\t}\n\treturn 0;\nout:\n\tfree(scn->sst_tab);\n\treturn -1;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":317044,"func":"static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,\n\t\t\t\t\t\tstruct socket_smack *ssp)\n{\n\tstruct smack_known *skp;\n\tint found = 0;\n\tint acat;\n\tint kcat;\n\n\t\/*\n\t * Netlabel found it in the cache.\n\t *\/\n\tif ((sap->flags & NETLBL_SECATTR_CACHE) != 0)\n\t\treturn (struct smack_known *)sap->cache->data;\n\n\tif ((sap->flags & NETLBL_SECATTR_SECID) != 0)\n\t\t\/*\n\t\t * Looks like a fallback, which gives us a secid.\n\t\t *\/\n\t\treturn smack_from_secid(sap->attr.secid);\n\n\tif ((sap->flags & NETLBL_SECATTR_MLS_LVL) != 0) {\n\t\t\/*\n\t\t * Looks like a CIPSO packet.\n\t\t * If there are flags but no level netlabel isn't\n\t\t * behaving the way we expect it to.\n\t\t *\n\t\t * Look it up in the label table\n\t\t * Without guidance regarding the smack value\n\t\t * for the packet fall back on the network\n\t\t * ambient value.\n\t\t *\/\n\t\trcu_read_lock();\n\t\tlist_for_each_entry_rcu(skp, &smack_known_list, list) {\n\t\t\tif (sap->attr.mls.lvl != skp->smk_netlabel.attr.mls.lvl)\n\t\t\t\tcontinue;\n\t\t\t\/*\n\t\t\t * Compare the catsets. Use the netlbl APIs.\n\t\t\t *\/\n\t\t\tif ((sap->flags & NETLBL_SECATTR_MLS_CAT) == 0) {\n\t\t\t\tif ((skp->smk_netlabel.flags &\n\t\t\t\t     NETLBL_SECATTR_MLS_CAT) == 0)\n\t\t\t\t\tfound = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (acat = -1, kcat = -1; acat == kcat; ) {\n\t\t\t\tacat = netlbl_catmap_walk(sap->attr.mls.cat,\n\t\t\t\t\t\t\t  acat + 1);\n\t\t\t\tkcat = netlbl_catmap_walk(\n\t\t\t\t\tskp->smk_netlabel.attr.mls.cat,\n\t\t\t\t\tkcat + 1);\n\t\t\t\tif (acat < 0 || kcat < 0)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (acat == kcat) {\n\t\t\t\tfound = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\trcu_read_unlock();\n\n\t\tif (found)\n\t\t\treturn skp;\n\n\t\tif (ssp != NULL && ssp->smk_in == &smack_known_star)\n\t\t\treturn &smack_known_web;\n\t\treturn &smack_known_star;\n\t}\n\t\/*\n\t * Without guidance regarding the smack value\n\t * for the packet fall back on the network\n\t * ambient value.\n\t *\/\n\treturn smack_net_ambient;\n}","target":0,"code_token_length":577,"total_token_length":813,"max_tokens_setting":1024}
+{"idx":200895,"func":"call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long end_idx)\n{\n    callback_T\t*cb = &qftf_cb;\n    list_T\t*qftf_list = NULL;\n\n    \/\/ If 'quickfixtextfunc' is set, then use the user-supplied function to get\n    \/\/ the text to display. Use the local value of 'quickfixtextfunc' if it is\n    \/\/ set.\n    if (qfl->qf_qftf_cb.cb_name != NULL)\n\tcb = &qfl->qf_qftf_cb;\n    if (cb->cb_name != NULL)\n    {\n\ttypval_T\targs[1];\n\tdict_T\t\t*d;\n\ttypval_T\trettv;\n\n\t\/\/ create the dict argument\n\tif ((d = dict_alloc_lock(VAR_FIXED)) == NULL)\n\t    return NULL;\n\tdict_add_number(d, \"quickfix\", (long)IS_QF_LIST(qfl));\n\tdict_add_number(d, \"winid\", (long)qf_winid);\n\tdict_add_number(d, \"id\", (long)qfl->qf_id);\n\tdict_add_number(d, \"start_idx\", start_idx);\n\tdict_add_number(d, \"end_idx\", end_idx);\n\t++d->dv_refcount;\n\targs[0].v_type = VAR_DICT;\n\targs[0].vval.v_dict = d;\n\n\tqftf_list = NULL;\n\tif (call_callback(cb, 0, &rettv, 1, args) != FAIL)\n\t{\n\t    if (rettv.v_type == VAR_LIST)\n\t    {\n\t\tqftf_list = rettv.vval.v_list;\n\t\tqftf_list->lv_refcount++;\n\t    }\n\t    clear_tv(&rettv);\n\t}\n\tdict_unref(d);\n    }\n\n    return qftf_list;\n}","target":1,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":226028,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nGF_Err dvcC_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_DOVIConfigurationBox *ptr = (GF_DOVIConfigurationBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\t\/\/GF_DOVIDecoderConfigurationRecord\n\tgf_bs_write_u8(bs,  ptr->DOVIConfig.dv_version_major);\n\tgf_bs_write_u8(bs,  ptr->DOVIConfig.dv_version_minor);\n\tgf_bs_write_int(bs, ptr->DOVIConfig.dv_profile, 7);\n\tgf_bs_write_int(bs, ptr->DOVIConfig.dv_level, 6);\n\tgf_bs_write_int(bs, ptr->DOVIConfig.rpu_present_flag, 1);\n\tgf_bs_write_int(bs, ptr->DOVIConfig.el_present_flag, 1);\n\tgf_bs_write_int(bs, ptr->DOVIConfig.bl_present_flag, 1);\n\tgf_bs_write_int(bs, ptr->DOVIConfig.dv_bl_signal_compatibility_id, 4);\n\tgf_bs_write_int(bs, 0, 28);\n\tgf_bs_write_u32(bs, 0);\n\tgf_bs_write_u32(bs, 0);\n\tgf_bs_write_u32(bs, 0);\n\tgf_bs_write_u32(bs, 0);\n\n\treturn GF_OK;","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":242574,"func":"get_section_vma_by_name (char *name, size_t namesz,\n\t\t\t char *buffer, size_t bufsz,\n\t\t\t PE_COFF_LOADER_IMAGE_CONTEXT *context,\n\t\t\t char **basep, size_t *sizep,\n\t\t\t EFI_IMAGE_SECTION_HEADER **sectionp)\n{\n\tUINTN i;\n\tchar namebuf[9];\n\n\tif (!name || namesz == 0 || !buffer || bufsz < namesz || !context\n\t    || !basep || !sizep || !sectionp)\n\t\treturn EFI_INVALID_PARAMETER;\n\n\t\/*\n\t * This code currently is only used for \".reloc\\0\\0\" and\n\t * \".sbat\\0\\0\\0\", and it doesn't know how to look up longer section\n\t * names.\n\t *\/\n\tif (namesz > 8)\n\t\treturn EFI_UNSUPPORTED;\n\n\tSetMem(namebuf, sizeof(namebuf), 0);\n\tCopyMem(namebuf, name, MIN(namesz, 8));\n\n\t\/*\n\t * Copy the executable's sections to their desired offsets\n\t *\/\n\tfor (i = 0; i < context->NumberOfSections; i++) {\n\t\tEFI_STATUS status;\n\t\tEFI_IMAGE_SECTION_HEADER *section = NULL;\n\t\tchar *base = NULL;\n\t\tsize_t size = 0;\n\n\t\tstatus = get_section_vma(i, buffer, bufsz, context, &base, &size, §ion);\n\t\tif (!EFI_ERROR(status)) {\n\t\t\tif (CompareMem(section->Name, namebuf, 8) == 0) {\n\t\t\t\t*basep = base;\n\t\t\t\t*sizep = size;\n\t\t\t\t*sectionp = section;\n\t\t\t\treturn EFI_SUCCESS;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch(status) {\n\t\tcase EFI_NOT_FOUND:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn EFI_NOT_FOUND;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":263390,"func":"Status BatchToSpaceShapeHelper(InferenceContext* c, ShapeHandle input_shape,\n                               ShapeHandle block_shape_shape,\n                               const Tensor* block_shape_t,\n                               ShapeHandle crops_shape, const Tensor* crops_t) {\n  if (c->Rank(block_shape_shape) != 1) {\n    return errors::InvalidArgument(\"block_shape must have rank 1.\");\n  }\n\n  const DimensionHandle num_block_dims_handle = c->Dim(block_shape_shape, 0);\n  if (!c->ValueKnown(num_block_dims_handle)) {\n    return errors::InvalidArgument(\"block_shape must have known size.\");\n  }\n\n  const int64_t num_block_dims = c->Value(num_block_dims_handle);\n\n  TF_RETURN_IF_ERROR(\n      c->WithRankAtLeast(input_shape, num_block_dims + 1, &input_shape));\n\n  TF_RETURN_IF_ERROR(\n      c->Merge(crops_shape, c->Matrix(num_block_dims, 2), &crops_shape));\n\n  DimensionHandle batch_size = c->Dim(input_shape, 0);\n  std::vector<int64_t> block_shape_vec;\n  if (block_shape_t) {\n    block_shape_vec = GetFlatInt64(*block_shape_t);\n    for (int64_t dim = 0; dim < num_block_dims; ++dim) {\n      const int64_t block_shape_value = block_shape_vec[dim];\n      if (block_shape_value < 1) {\n        return errors::InvalidArgument(\"block_shape must be positive\");\n      }\n      if (c->ValueKnown(batch_size)) {\n        TF_RETURN_IF_ERROR(c->Divide(batch_size, block_shape_value,\n                                     \/*evenly_divisible=*\/true, &batch_size));\n      } else {\n        batch_size = c->UnknownDim();\n      }\n    }\n  } else if (num_block_dims > 0) {\n    batch_size = c->UnknownDim();\n  }\n\n  std::vector<DimensionHandle> output_dims{batch_size};\n  output_dims.resize(num_block_dims + 1, c->UnknownDim());\n\n  if (crops_t) {\n    const std::vector<int64_t> crops_vec = GetFlatInt64(*crops_t);\n    for (int64_t dim = 0; dim < num_block_dims; ++dim) {\n      const int64_t crop_start = crops_vec[dim * 2],\n                    crop_end = crops_vec[dim * 2 + 1];\n      if (crop_start < 0 || crop_end < 0) {\n        return errors::InvalidArgument(\"crops cannot be negative\");\n      }\n      if (block_shape_t) {\n        DimensionHandle cropped_size;\n        TF_RETURN_IF_ERROR(c->Multiply(c->Dim(input_shape, dim + 1),\n                                       block_shape_vec[dim], &cropped_size));\n        TF_RETURN_IF_ERROR(\n            c->Subtract(cropped_size, crop_start, &cropped_size));\n        TF_RETURN_IF_ERROR(\n            c->Subtract(cropped_size, crop_end, &output_dims[dim + 1]));\n      }\n    }\n  }\n\n  ShapeHandle remaining_input_shape;\n  TF_RETURN_IF_ERROR(\n      c->Subshape(input_shape, 1 + num_block_dims, &remaining_input_shape));\n\n  ShapeHandle result;\n  TF_RETURN_IF_ERROR(c->Concatenate(c->MakeShape(output_dims),\n                                    remaining_input_shape, &result));\n  c->set_output(0, result);\n  return Status::OK();\n}","target":0,"code_token_length":716,"total_token_length":952,"max_tokens_setting":1024}
+{"idx":200831,"func":"set_routerstatus_from_routerinfo(routerstatus_t *rs,\n                                 routerinfo_t *ri, time_t now,\n                                 int naming, int listbadexits,\n                                 int listbaddirs, int vote_on_hsdirs)\n{\n  int unstable_version =\n    !tor_version_as_new_as(ri->platform,\"0.1.1.16-rc-cvs\");\n  memset(rs, 0, sizeof(routerstatus_t));\n\n  rs->is_authority =\n    router_digest_is_trusted_dir(ri->cache_info.identity_digest);\n\n  \/* Already set by compute_performance_thresholds. *\/\n  rs->is_exit = ri->is_exit;\n  rs->is_stable = ri->is_stable =\n    router_is_active(ri, now) &&\n    !dirserv_thinks_router_is_unreliable(now, ri, 1, 0) &&\n    !unstable_version;\n  rs->is_fast = ri->is_fast =\n    router_is_active(ri, now) &&\n    !dirserv_thinks_router_is_unreliable(now, ri, 0, 1);\n  rs->is_running = ri->is_running; \/* computed above *\/\n\n  if (naming) {\n    uint32_t name_status = dirserv_get_name_status(\n                         ri->cache_info.identity_digest, ri->nickname);\n    rs->is_named = (naming && (name_status & FP_NAMED)) ? 1 : 0;\n    rs->is_unnamed = (naming && (name_status & FP_UNNAMED)) ? 1 : 0;\n  }\n  rs->is_valid = ri->is_valid;\n\n  if (rs->is_fast &&\n      (router_get_advertised_bandwidth(ri) >= BANDWIDTH_TO_GUARANTEE_GUARD ||\n       router_get_advertised_bandwidth(ri) >=\n                              MIN(guard_bandwidth_including_exits,\n                                  guard_bandwidth_excluding_exits))) {\n    long tk = rep_hist_get_weighted_time_known(\n                                      ri->cache_info.identity_digest, now);\n    double wfu = rep_hist_get_weighted_fractional_uptime(\n                                      ri->cache_info.identity_digest, now);\n    rs->is_possible_guard = (wfu >= guard_wfu && tk >= guard_tk) ? 1 : 0;\n  } else {\n    rs->is_possible_guard = 0;\n  }\n  rs->is_bad_directory = listbaddirs && ri->is_bad_directory;\n  rs->is_bad_exit = listbadexits && ri->is_bad_exit;\n  ri->is_hs_dir = dirserv_thinks_router_is_hs_dir(ri, now);\n  rs->is_hs_dir = vote_on_hsdirs && ri->is_hs_dir;\n  rs->is_v2_dir = ri->dir_port != 0;\n\n  if (!strcasecmp(ri->nickname, UNNAMED_ROUTER_NICKNAME))\n    rs->is_named = rs->is_unnamed = 0;\n\n  rs->published_on = ri->cache_info.published_on;\n  memcpy(rs->identity_digest, ri->cache_info.identity_digest, DIGEST_LEN);\n  memcpy(rs->descriptor_digest, ri->cache_info.signed_descriptor_digest,\n         DIGEST_LEN);\n  rs->addr = ri->addr;\n  strlcpy(rs->nickname, ri->nickname, sizeof(rs->nickname));\n  rs->or_port = ri->or_port;\n  rs->dir_port = ri->dir_port;\n}","target":1,"code_token_length":720,"total_token_length":956,"max_tokens_setting":1024}
+{"idx":234216,"func":"debuginfod_fetch_separate_debug_info (struct dwarf_section * section,\n                                      char ** filename,\n                                      void * file)\n{\n  size_t build_id_len;\n  unsigned char * build_id;\n\n  if (strcmp (section->uncompressed_name, \".gnu_debuglink\") == 0)\n    {\n      \/* Get the build-id of file.  *\/\n      build_id = get_build_id (file);\n      build_id_len = 0;\n    }\n  else if (strcmp (section->uncompressed_name, \".gnu_debugaltlink\") == 0)\n    {\n      \/* Get the build-id of the debugaltlink file.  *\/\n      unsigned int filelen;\n\n      filelen = strnlen ((const char *)section->start, section->size);\n      if (filelen == section->size)\n        \/* Corrupt debugaltlink.  *\/\n        return false;\n\n      build_id = section->start + filelen + 1;\n      build_id_len = section->size - (filelen + 1);\n\n      if (build_id_len == 0)\n        return false;\n    }\n  else\n    return false;\n\n  if (build_id)\n    {\n      int fd;\n      debuginfod_client * client;\n\n      client = debuginfod_begin ();\n      if (client == NULL)\n        return false;\n\n      \/* Query debuginfod servers for the target file. If found its path\n         will be stored in filename.  *\/\n      fd = debuginfod_find_debuginfo (client, build_id, build_id_len, filename);\n      debuginfod_end (client);\n\n      \/* Only free build_id if we allocated space for a hex string\n         in get_build_id ().  *\/\n      if (build_id_len == 0)\n        free (build_id);\n\n      if (fd >= 0)\n        {\n          \/* File successfully retrieved. Close fd since we want to\n             use open_debug_file () on filename instead.  *\/\n          close (fd);\n          return true;\n        }\n    }\n\n  return false;\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":500673,"func":"ssize_t sftp_read(sftp_file handle, void *buf, size_t count) {\n  sftp_session sftp = handle->sftp;\n  sftp_message msg = NULL;\n  sftp_status_message status;\n  ssh_string datastring;\n  ssh_buffer buffer;\n  int id;\n\n  if (handle->eof) {\n    return 0;\n  }\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return -1;\n  }\n  id = sftp_get_new_id(handle->sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, handle->handle) < 0 ||\n      buffer_add_u64(buffer, htonll(handle->offset)) < 0 ||\n      buffer_add_u32(buffer,htonl(count)) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return -1;\n  }\n  if (sftp_packet_write(handle->sftp, SSH_FXP_READ, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    return -1;\n  }\n  ssh_buffer_free(buffer);\n\n  while (msg == NULL) {\n    if (handle->nonblocking) {\n      if (ssh_channel_poll(handle->sftp->channel, 0) == 0) {\n        \/* we cannot block *\/\n        return 0;\n      }\n    }\n    if (sftp_read_and_dispatch(handle->sftp) < 0) {\n      \/* something nasty has happened *\/\n      return -1;\n    }\n    msg = sftp_dequeue(handle->sftp, id);\n  }\n\n  switch (msg->packet_type) {\n    case SSH_FXP_STATUS:\n      status = parse_status_msg(msg);\n      sftp_message_free(msg);\n      if (status == NULL) {\n        return -1;\n      }\n      sftp_set_error(sftp, status->status);\n      switch (status->status) {\n        case SSH_FX_EOF:\n          handle->eof = 1;\n          status_msg_free(status);\n          return 0;\n        default:\n          break;\n      }\n      ssh_set_error(sftp->session,SSH_REQUEST_DENIED,\n          \"SFTP server: %s\", status->errormsg);\n      status_msg_free(status);\n      return -1;\n    case SSH_FXP_DATA:\n      datastring = buffer_get_ssh_string(msg->payload);\n      sftp_message_free(msg);\n      if (datastring == NULL) {\n        ssh_set_error(sftp->session, SSH_FATAL,\n            \"Received invalid DATA packet from sftp server\");\n        return -1;\n      }\n\n      if (ssh_string_len(datastring) > count) {\n        ssh_set_error(sftp->session, SSH_FATAL,\n            \"Received a too big DATA packet from sftp server: \"\n            \"%\" PRIdS \" and asked for %\" PRIdS,\n            ssh_string_len(datastring), count);\n        ssh_string_free(datastring);\n        return -1;\n      }\n      count = ssh_string_len(datastring);\n      handle->offset += count;\n      memcpy(buf, ssh_string_data(datastring), count);\n      ssh_string_free(datastring);\n      return count;\n    default:\n      ssh_set_error(sftp->session, SSH_FATAL,\n          \"Received message %d during read!\", msg->packet_type);\n      sftp_message_free(msg);\n      return -1;\n  }\n\n  return -1; \/* not reached *\/\n}","target":0,"code_token_length":727,"total_token_length":963,"max_tokens_setting":1024}
+{"idx":436151,"func":"\nstatic int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct io_kiocb *preq;\n\tbool completing;\n\tint ret;\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tpreq = io_poll_find(ctx, req->poll_update.old_user_data, true);\n\tif (!preq) {\n\t\tret = -ENOENT;\n\t\tgoto err;\n\t}\n\n\tif (!req->poll_update.update_events && !req->poll_update.update_user_data) {\n\t\tcompleting = true;\n\t\tret = io_poll_remove_one(preq) ? 0 : -EALREADY;\n\t\tgoto err;\n\t}\n\n\t\/*\n\t * Don't allow racy completion with singleshot, as we cannot safely\n\t * update those. For multishot, if we're racing with completion, just\n\t * let completion re-add it.\n\t *\/\n\tcompleting = !__io_poll_remove_one(preq, &preq->poll, false);\n\tif (completing && (preq->poll.events & EPOLLONESHOT)) {\n\t\tret = -EALREADY;\n\t\tgoto err;\n\t}\n\t\/* we now have a detached poll request. reissue. *\/\n\tret = 0;\nerr:\n\tif (ret < 0) {\n\t\tspin_unlock_irq(&ctx->completion_lock);\n\t\treq_set_fail(req);\n\t\tio_req_complete(req, ret);\n\t\treturn 0;\n\t}\n\t\/* only mask one event flags, keep behavior flags *\/\n\tif (req->poll_update.update_events) {\n\t\tpreq->poll.events &= ~0xffff;\n\t\tpreq->poll.events |= req->poll_update.events & 0xffff;\n\t\tpreq->poll.events |= IO_POLL_UNMASK;\n\t}\n\tif (req->poll_update.update_user_data)\n\t\tpreq->user_data = req->poll_update.new_user_data;\n\tspin_unlock_irq(&ctx->completion_lock);\n\n\t\/* complete update request, we're done with it *\/\n\tio_req_complete(req, ret);\n\n\tif (!completing) {\n\t\tret = io_poll_add(preq, issue_flags);\n\t\tif (ret < 0) {\n\t\t\treq_set_fail(preq);\n\t\t\tio_req_complete(preq, ret);\n\t\t}\n\t}\n\treturn 0;","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":373543,"func":"ipf_v6_key_extract(struct dp_packet *pkt, ovs_be16 dl_type, uint16_t zone,\n                   struct ipf_list_key *key, uint16_t *start_data_byte,\n                   uint16_t *end_data_byte, bool *ff, bool *lf)\n{\n    const struct ovs_16aligned_ip6_hdr *l3 = dp_packet_l3(pkt);\n    uint8_t nw_frag = 0;\n    uint8_t nw_proto = l3->ip6_nxt;\n    const void *data = l3 + 1;\n    size_t datasize = dp_packet_l3_size(pkt) - sizeof *l3;\n    const struct ovs_16aligned_ip6_frag *frag_hdr = NULL;\n\n    parse_ipv6_ext_hdrs(&data, &datasize, &nw_proto, &nw_frag, &frag_hdr);\n    ovs_assert(nw_frag && frag_hdr);\n    ovs_be16 ip6f_offlg = frag_hdr->ip6f_offlg;\n    *start_data_byte = ntohs(ip6f_offlg & IP6F_OFF_MASK) +\n        sizeof (struct ovs_16aligned_ip6_frag);\n    *end_data_byte = *start_data_byte + dp_packet_l4_size(pkt) - 1;\n    *ff = ipf_is_first_v6_frag(ip6f_offlg);\n    *lf = ipf_is_last_v6_frag(ip6f_offlg);\n    memset(key, 0, sizeof *key);\n    key->ip_id = get_16aligned_be32(&frag_hdr->ip6f_ident);\n    key->dl_type = dl_type;\n    memcpy(&key->src_addr.ipv6, &l3->ip6_src, sizeof key->src_addr.ipv6);\n    \/* We are not supporting parsing of the routing header to use as the\n     * dst address part of the key. *\/\n    memcpy(&key->dst_addr.ipv6, &l3->ip6_dst, sizeof key->dst_addr.ipv6);\n    key->nw_proto = 0;   \/* Not used for key for V6. *\/\n    key->zone = zone;\n    key->recirc_id = pkt->md.recirc_id;\n}","target":0,"code_token_length":470,"total_token_length":706,"max_tokens_setting":1024}
+{"idx":477382,"func":"R_API char *r_bin_java_print_methodhandle_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *value = malloc (size);\n\tut8 ref_kind = obj->info.cp_method_handle.reference_kind;\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%s.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tR_BIN_JAVA_REF_METAS[ref_kind].name, obj->info.cp_method_handle.reference_index);\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size);\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%s.%d\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\t\t\tR_BIN_JAVA_REF_METAS[ref_kind].name, obj->info.cp_method_handle.reference_index);\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":437336,"func":"set_sunday_quick_search_skip_table(UChar* s, UChar* end, OnigEncoding enc,\n                                   UChar skip[], int* roffset)\n{\n  int i, len, offset;\n\n  offset = 1;\n  if (ONIGENC_MBC_MINLEN(enc) > 1) {\n    UChar* p = s;\n    while (1) {\n      len = enclen(enc, p);\n      if (p + len >= end) {\n        UChar* q = p + (ONIGENC_MBC_MINLEN(enc) - 1);\n        while (q > p) {\n          if (*q != '\\0') {\n            offset = q - p + 1;\n            break;\n          }\n          q--;\n        }\n        break;\n      }\n      p += len;\n    }\n  }\n\n  len = (int )(end - s);\n  if (len + offset >= ONIG_CHAR_TABLE_SIZE)\n    return ONIGERR_PARSER_BUG;\n\n  *roffset = offset;\n\n  for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + offset);\n\n  for (i = 0; i < len; i++)\n    skip[s[i]] = len - i + (offset - 1);\n\n  return 0;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":225083,"func":"parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)\n{\n\tconst char *service = conninfo_getval(options, \"service\");\n\tchar\t\tserviceFile[MAXPGPATH];\n\tchar\t   *env;\n\tbool\t\tgroup_found = false;\n\tint\t\t\tstatus;\n\tstruct stat stat_buf;\n\n\t\/*\n\t * We have to special-case the environment variable PGSERVICE here, since\n\t * this is and should be called before inserting environment defaults for\n\t * other connection options.\n\t *\/\n\tif (service == NULL)\n\t\tservice = getenv(\"PGSERVICE\");\n\n\t\/* If no service name given, nothing to do *\/\n\tif (service == NULL)\n\t\treturn 0;\n\n\t\/*\n\t * Try PGSERVICEFILE if specified, else try ~\/.pg_service.conf (if that\n\t * exists).\n\t *\/\n\tif ((env = getenv(\"PGSERVICEFILE\")) != NULL)\n\t\tstrlcpy(serviceFile, env, sizeof(serviceFile));\n\telse\n\t{\n\t\tchar\t\thomedir[MAXPGPATH];\n\n\t\tif (!pqGetHomeDirectory(homedir, sizeof(homedir)))\n\t\t\tgoto next_file;\n\t\tsnprintf(serviceFile, MAXPGPATH, \"%s\/%s\", homedir, \".pg_service.conf\");\n\t\tif (stat(serviceFile, &stat_buf) != 0)\n\t\t\tgoto next_file;\n\t}\n\n\tstatus = parseServiceFile(serviceFile, service, options, errorMessage, &group_found);\n\tif (group_found || status != 0)\n\t\treturn status;\n\nnext_file:\n\n\t\/*\n\t * This could be used by any application so we can't use the binary\n\t * location to find our config files.\n\t *\/\n\tsnprintf(serviceFile, MAXPGPATH, \"%s\/pg_service.conf\",\n\t\t\t getenv(\"PGSYSCONFDIR\") ? getenv(\"PGSYSCONFDIR\") : SYSCONFDIR);\n\tif (stat(serviceFile, &stat_buf) != 0)\n\t\tgoto last_file;\n\n\tstatus = parseServiceFile(serviceFile, service, options, errorMessage, &group_found);\n\tif (status != 0)\n\t\treturn status;\n\nlast_file:\n\tif (!group_found)\n\t{\n\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"definition of service \\\"%s\\\" not found\\n\"), service);\n\t\treturn 3;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":279952,"func":"getfile(\n    int\t\tfnum,\n    char_u\t*ffname_arg,\n    char_u\t*sfname_arg,\n    int\t\tsetpm,\n    linenr_T\tlnum,\n    int\t\tforceit)\n{\n    char_u\t*ffname = ffname_arg;\n    char_u\t*sfname = sfname_arg;\n    int\t\tother;\n    int\t\tretval;\n    char_u\t*free_me = NULL;\n\n    if (text_locked())\n\treturn GETFILE_ERROR;\n    if (curbuf_locked())\n\treturn GETFILE_ERROR;\n\n    if (fnum == 0)\n    {\n\t\t\t\t\t\/\/ make ffname full path, set sfname\n\tfname_expand(curbuf, &ffname, &sfname);\n\tother = otherfile(ffname);\n\tfree_me = ffname;\t\t\/\/ has been allocated, free() later\n    }\n    else\n\tother = (fnum != curbuf->b_fnum);\n\n    if (other)\n\t++no_wait_return;\t    \/\/ don't wait for autowrite message\n    if (other && !forceit && curbuf->b_nwindows == 1 && !buf_hide(curbuf)\n\t\t   && curbufIsChanged() && autowrite(curbuf, forceit) == FAIL)\n    {\n#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)\n\tif (p_confirm && p_write)\n\t    dialog_changed(curbuf, FALSE);\n\tif (curbufIsChanged())\n#endif\n\t{\n\t    if (other)\n\t\t--no_wait_return;\n\t    no_write_message();\n\t    retval = GETFILE_NOT_WRITTEN;\t\/\/ file has been changed\n\t    goto theend;\n\t}\n    }\n    if (other)\n\t--no_wait_return;\n    if (setpm)\n\tsetpcmark();\n    if (!other)\n    {\n\tif (lnum != 0)\n\t    curwin->w_cursor.lnum = lnum;\n\tcheck_cursor_lnum();\n\tbeginline(BL_SOL | BL_FIX);\n\tretval = GETFILE_SAME_FILE;\t\/\/ it's in the same file\n    }\n    else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,\n\t     (buf_hide(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),\n\t\tcurwin) == OK)\n\tretval = GETFILE_OPEN_OTHER;\t\/\/ opened another file\n    else\n\tretval = GETFILE_ERROR;\t\t\/\/ error encountered\n\ntheend:\n    vim_free(free_me);\n    return retval;\n}","target":0,"code_token_length":534,"total_token_length":770,"max_tokens_setting":1024}
+{"idx":373638,"func":"estack_sfile(estack_arg_T which UNUSED)\n{\n    estack_T\t*entry;\n#ifdef FEAT_EVAL\n    garray_T\tga;\n    size_t\tlen;\n    int\t\tidx;\n    etype_T\tlast_type = ETYPE_SCRIPT;\n    char\t*type_name;\n#endif\n\n    entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;\n#ifdef FEAT_EVAL\n    if (which == ESTACK_SFILE && entry->es_type != ETYPE_UFUNC)\n#endif\n    {\n\tif (entry->es_name == NULL)\n\t    return NULL;\n\treturn vim_strsave(entry->es_name);\n    }\n#ifdef FEAT_EVAL\n    \/\/ expand('<sfile>') works in a function for backwards compatibility, but\n    \/\/ may give an unexpected result.  Disallow it in Vim 9 script.\n    if (which == ESTACK_SFILE && in_vim9script())\n    {\n\tint  save_emsg_off = emsg_off;\n\n\tif (emsg_off == 1)\n\t    \/\/ f_expand() silences errors but we do want this one\n\t    emsg_off = 0;\n\temsg(_(e_cannot_expand_sfile_in_vim9_function));\n\temsg_off = save_emsg_off;\n\treturn NULL;\n    }\n\n    \/\/ Give information about each stack entry up to the root.\n    \/\/ For a function we compose the call stack, as it was done in the past:\n    \/\/   \"function One[123]..Two[456]..Three\"\n    ga_init2(&ga, sizeof(char), 100);\n    for (idx = 0; idx < exestack.ga_len; ++idx)\n    {\n\tentry = ((estack_T *)exestack.ga_data) + idx;\n\tif (entry->es_name != NULL)\n\t{\n\t    long    lnum = 0;\n\t    char    *dots;\n\n\t    len = STRLEN(entry->es_name) + 15;\n\t    type_name = \"\";\n\t    if (entry->es_type != last_type)\n\t    {\n\t\tswitch (entry->es_type)\n\t\t{\n\t\t    case ETYPE_SCRIPT: type_name = \"script \"; break;\n\t\t    case ETYPE_UFUNC: type_name = \"function \"; break;\n\t\t    default: type_name = \"\"; break;\n\t\t}\n\t\tlast_type = entry->es_type;\n\t    }\n\t    len += STRLEN(type_name);\n\t    if (ga_grow(&ga, (int)len) == FAIL)\n\t\tbreak;\n\t    if (idx == exestack.ga_len - 1)\n\t\tlnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;\n\t    else\n\t\tlnum = entry->es_lnum;\n\t    dots = idx == exestack.ga_len - 1 ? \"\" : \"..\";\n\t    if (lnum == 0)\n\t\t\/\/ For the bottom entry of <sfile>: do not add the line number,\n\t\t\/\/ it is used in <slnum>.  Also leave it out when the number is\n\t\t\/\/ not set.\n\t\tvim_snprintf((char *)ga.ga_data + ga.ga_len, len, \"%s%s%s\",\n\t\t\t\ttype_name, entry->es_name, dots);\n\t    else\n\t\tvim_snprintf((char *)ga.ga_data + ga.ga_len, len, \"%s%s[%ld]%s\",\n\t\t\t\t    type_name, entry->es_name, lnum, dots);\n\t    ga.ga_len += (int)STRLEN((char *)ga.ga_data + ga.ga_len);\n\t}\n    }\n\n    return (char_u *)ga.ga_data;\n#endif\n}","target":0,"code_token_length":762,"total_token_length":998,"max_tokens_setting":1024}
+{"idx":221468,"func":"flatpak_run_get_minimal_env (gboolean devel, gboolean use_ld_so_cache)\n{\n  GPtrArray *env_array;\n  static const char * const copy[] = {\n    \"PWD\",\n    \"GDMSESSION\",\n    \"XDG_CURRENT_DESKTOP\",\n    \"XDG_SESSION_DESKTOP\",\n    \"DESKTOP_SESSION\",\n    \"EMAIL_ADDRESS\",\n    \"HOME\",\n    \"HOSTNAME\",\n    \"LOGNAME\",\n    \"REAL_NAME\",\n    \"TERM\",\n    \"USER\",\n    \"USERNAME\",\n  };\n  static const char * const copy_nodevel[] = {\n    \"LANG\",\n    \"LANGUAGE\",\n    \"LC_ALL\",\n    \"LC_ADDRESS\",\n    \"LC_COLLATE\",\n    \"LC_CTYPE\",\n    \"LC_IDENTIFICATION\",\n    \"LC_MEASUREMENT\",\n    \"LC_MESSAGES\",\n    \"LC_MONETARY\",\n    \"LC_NAME\",\n    \"LC_NUMERIC\",\n    \"LC_PAPER\",\n    \"LC_TELEPHONE\",\n    \"LC_TIME\",\n  };\n  int i;\n\n  env_array = g_ptr_array_new_with_free_func (g_free);\n\n  add_exports (env_array, default_exports, G_N_ELEMENTS (default_exports));\n\n  if (!use_ld_so_cache)\n    add_exports (env_array, no_ld_so_cache_exports, G_N_ELEMENTS (no_ld_so_cache_exports));\n\n  if (devel)\n    add_exports (env_array, devel_exports, G_N_ELEMENTS (devel_exports));\n\n  for (i = 0; i < G_N_ELEMENTS (copy); i++)\n    {\n      const char *current = g_getenv (copy[i]);\n      if (current)\n        g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", copy[i], current));\n    }\n\n  if (!devel)\n    {\n      for (i = 0; i < G_N_ELEMENTS (copy_nodevel); i++)\n        {\n          const char *current = g_getenv (copy_nodevel[i]);\n          if (current)\n            g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", copy_nodevel[i], current));\n        }\n    }\n\n  g_ptr_array_add (env_array, NULL);\n  return (char **) g_ptr_array_free (env_array, FALSE);\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":261241,"func":"static int SN_WillMessage(MqttClient *client, SN_Will *will)\n{\n    int rc, len;\n\n    \/* Validate required arguments *\/\n    if (client == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n#ifdef WOLFMQTT_MULTITHREAD\n    rc = wm_SemLock(&client->lockClient);\n    if (rc == 0) {\n        \/* inform other threads of expected response *\/\n        rc = MqttClient_RespList_Add(client,\n                (MqttPacketType)SN_MSG_TYPE_WILLMSGREQ, 0,\n                &will->pendResp, &will->resp.msgResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n    if (rc != 0) {\n        return rc; \/* Error locking client *\/\n    }\n#endif\n\n    \/* Wait for Will Message Request *\/\n    rc = SN_Client_WaitType(client, &will->resp.msgResp,\n            SN_MSG_TYPE_WILLMSGREQ, 0, client->cmd_timeout_ms);\n\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &will->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n    if (rc == 0) {\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n        \/* Encode Will Message *\/\n        len = rc = SN_Encode_WillMsg(client->tx_buf,\n            client->tx_buf_len, will);\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"EncodePacket: Len %d, Type %s (%d)\",\n            rc, SN_Packet_TypeDesc(SN_MSG_TYPE_WILLMSG),\n            SN_MSG_TYPE_WILLMSG);\n    #endif\n        if (rc > 0) {\n            \/* Send Will Topic packet *\/\n            rc = MqttPacket_Write(client, client->tx_buf, len);\n            if (rc == len) {\n                rc = 0;\n            }\n        }\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n    }\n\n    return rc;\n}","target":0,"code_token_length":526,"total_token_length":762,"max_tokens_setting":1024}
+{"idx":376676,"func":"query (void)\n{\n  static const GimpParamDef load_args[] =\n  {\n    { GIMP_PDB_INT32,  \"run-mode\",     \"The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }\" },\n    { GIMP_PDB_STRING, \"filename\",     \"The name of the file to load\" },\n    { GIMP_PDB_STRING, \"raw-filename\", \"The name of the file to load\" }\n  };\n  static const GimpParamDef load_return_vals[] =\n  {\n    { GIMP_PDB_IMAGE,  \"image\",        \"Output image\" }\n  };\n\n  static const GimpParamDef save_args[] =\n  {\n    { GIMP_PDB_INT32,    \"run-mode\",     \"The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }\" },\n    { GIMP_PDB_IMAGE,    \"image\",        \"Input image\" },\n    { GIMP_PDB_DRAWABLE, \"drawable\",     \"Drawable to save\" },\n    { GIMP_PDB_STRING,   \"filename\",     \"The name of the file to save the image in\" },\n    { GIMP_PDB_STRING,   \"raw-filename\", \"The name of the file to save the image in\" },\n    { GIMP_PDB_INT32,    \"spacing\",      \"Spacing of the brush\" },\n    { GIMP_PDB_STRING,   \"description\",  \"Short description of the brush\" }\n  };\n\n  gimp_install_procedure (LOAD_PROC,\n                          \"Loads GIMP brushes\",\n                          \"Loads GIMP brushes (1 or 4 bpp and old .gpb format)\",\n                          \"Tim Newsome, Jens Lautenbacher, Sven Neumann\",\n                          \"Tim Newsome, Jens Lautenbacher, Sven Neumann\",\n                          \"1997-2005\",\n                          N_(\"GIMP brush\"),\n                          NULL,\n                          GIMP_PLUGIN,\n                          G_N_ELEMENTS (load_args),\n                          G_N_ELEMENTS (load_return_vals),\n                          load_args, load_return_vals);\n\n  gimp_plugin_icon_register (LOAD_PROC, GIMP_ICON_TYPE_STOCK_ID,\n                             (const guint8 *) GIMP_STOCK_BRUSH);\n  gimp_register_file_handler_mime (LOAD_PROC, \"image\/x-gimp-gbr\");\n  gimp_register_magic_load_handler (LOAD_PROC,\n                                    \"gbr, gpb\",\n                                    \"\",\n                                    \"20, string, GIMP\");\n\n  gimp_install_procedure (SAVE_PROC,\n                          \"Saves files in the GIMP brush file format\",\n                          \"Saves files in the GIMP brush file format\",\n                          \"Tim Newsome, Jens Lautenbacher, Sven Neumann\",\n                          \"Tim Newsome, Jens Lautenbacher, Sven Neumann\",\n                          \"1997-2000\",\n                          N_(\"GIMP brush\"),\n                          \"RGB*, GRAY*\",\n                          GIMP_PLUGIN,\n                          G_N_ELEMENTS (save_args), 0,\n                          save_args, NULL);\n\n  gimp_plugin_icon_register (SAVE_PROC, GIMP_ICON_TYPE_STOCK_ID,\n                             (const guint8 *) GIMP_STOCK_BRUSH);\n  gimp_register_file_handler_mime (SAVE_PROC, \"image\/x-gimp-gbr\");\n  gimp_register_save_handler (SAVE_PROC, \"gbr\", \"\");\n}","target":0,"code_token_length":713,"total_token_length":949,"max_tokens_setting":1024}
+{"idx":415199,"func":"cmd_writecert (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  char *certid;\n  unsigned char *certdata;\n  size_t certdatalen;\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  line = skip_options (line);\n\n  if (!*line)\n    return set_error (GPG_ERR_ASS_PARAMETER, \"no certid given\");\n  certid = line;\n  while (*line && !spacep (line))\n    line++;\n  *line = 0;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  if (!ctrl->app_ctx)\n    return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);\n\n  certid = xtrystrdup (certid);\n  if (!certid)\n    return out_of_core ();\n\n  \/* Now get the actual keydata. *\/\n  rc = assuan_inquire (ctx, \"CERTDATA\",\n                       &certdata, &certdatalen, MAXLEN_CERTDATA);\n  if (rc)\n    {\n      xfree (certid);\n      return rc;\n    }\n\n  \/* Write the certificate to the card. *\/\n  rc = app_writecert (ctrl->app_ctx, ctrl, certid,\n                      pin_cb, ctx, certdata, certdatalen);\n  xfree (certid);\n  xfree (certdata);\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":253530,"func":"smb2_adjust_credits(struct TCP_Server_Info *server,\n\t\t    struct cifs_credits *credits,\n\t\t    const unsigned int payload_size)\n{\n\tint new_val = DIV_ROUND_UP(payload_size, SMB2_MAX_BUFFER_SIZE);\n\tint scredits, in_flight;\n\n\tif (!credits->value || credits->value == new_val)\n\t\treturn 0;\n\n\tif (credits->value < new_val) {\n\t\ttrace_smb3_too_many_credits(server->CurrentMid,\n\t\t\t\tserver->conn_id, server->hostname, 0, credits->value - new_val, 0);\n\t\tcifs_server_dbg(VFS, \"request has less credits (%d) than required (%d)\",\n\t\t\t\tcredits->value, new_val);\n\n\t\treturn -ENOTSUPP;\n\t}\n\n\tspin_lock(&server->req_lock);\n\n\tif (server->reconnect_instance != credits->instance) {\n\t\tscredits = server->credits;\n\t\tin_flight = server->in_flight;\n\t\tspin_unlock(&server->req_lock);\n\n\t\ttrace_smb3_reconnect_detected(server->CurrentMid,\n\t\t\tserver->conn_id, server->hostname, scredits,\n\t\t\tcredits->value - new_val, in_flight);\n\t\tcifs_server_dbg(VFS, \"trying to return %d credits to old session\\n\",\n\t\t\t credits->value - new_val);\n\t\treturn -EAGAIN;\n\t}\n\n\tserver->credits += credits->value - new_val;\n\tscredits = server->credits;\n\tin_flight = server->in_flight;\n\tspin_unlock(&server->req_lock);\n\twake_up(&server->request_q);\n\n\ttrace_smb3_add_credits(server->CurrentMid,\n\t\t\tserver->conn_id, server->hostname, scredits,\n\t\t\tcredits->value - new_val, in_flight);\n\tcifs_dbg(FYI, \"%s: adjust added %u credits total=%d\\n\",\n\t\t\t__func__, credits->value - new_val, scredits);\n\n\tcredits->value = new_val;\n\n\treturn 0;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":291836,"func":"static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path)\n{\n\tstruct rtrs_clt_con *con;\n\tunsigned int cid;\n\n\tWARN_ON(READ_ONCE(clt_path->state) == RTRS_CLT_CONNECTED);\n\n\t\/*\n\t * Possible race with rtrs_clt_open(), when DEVICE_REMOVAL comes\n\t * exactly in between.  Start destroying after it finishes.\n\t *\/\n\tmutex_lock(&clt_path->init_mutex);\n\tmutex_unlock(&clt_path->init_mutex);\n\n\t\/*\n\t * All IO paths must observe !CONNECTED state before we\n\t * free everything.\n\t *\/\n\tsynchronize_rcu();\n\n\trtrs_stop_hb(&clt_path->s);\n\n\t\/*\n\t * The order it utterly crucial: firstly disconnect and complete all\n\t * rdma requests with error (thus set in_use=false for requests),\n\t * then fail outstanding requests checking in_use for each, and\n\t * eventually notify upper layer about session disconnection.\n\t *\/\n\n\tfor (cid = 0; cid < clt_path->s.con_num; cid++) {\n\t\tif (!clt_path->s.con[cid])\n\t\t\tbreak;\n\t\tcon = to_clt_con(clt_path->s.con[cid]);\n\t\tstop_cm(con);\n\t}\n\tfail_all_outstanding_reqs(clt_path);\n\tfree_path_reqs(clt_path);\n\trtrs_clt_path_down(clt_path);\n\n\t\/*\n\t * Wait for graceful shutdown, namely when peer side invokes\n\t * rdma_disconnect(). 'connected_cnt' is decremented only on\n\t * CM events, thus if other side had crashed and hb has detected\n\t * something is wrong, here we will stuck for exactly timeout ms,\n\t * since CM does not fire anything.  That is fine, we are not in\n\t * hurry.\n\t *\/\n\twait_event_timeout(clt_path->state_wq,\n\t\t\t   !atomic_read(&clt_path->connected_cnt),\n\t\t\t   msecs_to_jiffies(RTRS_CONNECT_TIMEOUT_MS));\n\n\tfor (cid = 0; cid < clt_path->s.con_num; cid++) {\n\t\tif (!clt_path->s.con[cid])\n\t\t\tbreak;\n\t\tcon = to_clt_con(clt_path->s.con[cid]);\n\t\tmutex_lock(&con->con_mutex);\n\t\tdestroy_con_cq_qp(con);\n\t\tmutex_unlock(&con->con_mutex);\n\t\tdestroy_cm(con);\n\t\tdestroy_con(con);\n\t}\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":400102,"func":"int PipeSocketHandler::connect(const SocketEndpoint& endpoint) {\n  lock_guard<std::recursive_mutex> mutexGuard(globalMutex);\n\n  string pipePath = endpoint.name();\n  sockaddr_un remote;\n\n  int sockFd = ::socket(AF_UNIX, SOCK_STREAM, 0);\n  FATAL_FAIL(sockFd);\n  initSocket(sockFd);\n  remote.sun_family = AF_UNIX;\n  strncpy(remote.sun_path, pipePath.c_str(), sizeof(remote.sun_path));\n\n  VLOG(3) << \"Connecting to \" << endpoint << \" with fd \" << sockFd;\n  int result =\n      ::connect(sockFd, (struct sockaddr*)&remote, sizeof(sockaddr_un));\n  auto localErrno = GetErrno();\n  if (result < 0 && localErrno != EINPROGRESS) {\n    VLOG(3) << \"Connection result: \" << result << \" (\" << strerror(localErrno)\n            << \")\";\n#ifdef WIN32\n    ::shutdown(sockFd, SD_BOTH);\n#else\n    ::shutdown(sockFd, SHUT_RDWR);\n#endif\n#ifdef _MSC_VER\n    FATAL_FAIL(::closesocket(sockFd));\n#else\n    FATAL_FAIL(::close(sockFd));\n#endif\n    sockFd = -1;\n    SetErrno(localErrno);\n    return sockFd;\n  }\n\n  fd_set fdset;\n  FD_ZERO(&fdset);\n  FD_SET(sockFd, &fdset);\n  timeval tv;\n  tv.tv_sec = 3; \/* 3 second timeout *\/\n  tv.tv_usec = 0;\n  VLOG(4) << \"Before selecting sockFd\";\n  select(sockFd + 1, NULL, &fdset, NULL, &tv);\n\n  if (FD_ISSET(sockFd, &fdset)) {\n    VLOG(4) << \"sockFd \" << sockFd << \" is selected\";\n    int so_error;\n    socklen_t len = sizeof so_error;\n\n    FATAL_FAIL(\n        ::getsockopt(sockFd, SOL_SOCKET, SO_ERROR, (char*)&so_error, &len));\n\n    if (so_error == 0) {\n      LOG(INFO) << \"Connected to endpoint \" << endpoint;\n      \/\/ Initialize the socket again once it's blocking to make sure timeouts\n      \/\/ are set\n      initSocket(sockFd);\n\n      \/\/ if we get here, we must have connected successfully\n    } else {\n      LOG(INFO) << \"Error connecting to \" << endpoint << \": \" << so_error << \" \"\n                << strerror(so_error);\n#ifdef _MSC_VER\n      FATAL_FAIL(::closesocket(sockFd));\n#else\n      FATAL_FAIL(::close(sockFd));\n#endif\n      sockFd = -1;\n    }\n  } else {\n    auto localErrno = GetErrno();\n    LOG(INFO) << \"Error connecting to \" << endpoint << \": \" << localErrno << \" \"\n              << strerror(localErrno);\n#ifdef _MSC_VER\n    FATAL_FAIL(::closesocket(sockFd));\n#else\n    FATAL_FAIL(::close(sockFd));\n#endif\n    sockFd = -1;\n  }\n\n  LOG(INFO) << sockFd << \" is a good socket\";\n  if (sockFd >= 0) {\n    addToActiveSockets(sockFd);\n  }\n  return sockFd;\n}","target":0,"code_token_length":676,"total_token_length":912,"max_tokens_setting":1024}
+{"idx":477356,"func":"R_API char *r_bin_java_print_methodtype_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *value = malloc (size);\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tobj->info.cp_method_type.descriptor_index);\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size);\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\t\t\tobj->info.cp_method_type.descriptor_index);\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":208370,"func":"bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)\n{\n    int\t\tc;\n    char_u\tbuf[NUMBUFLEN + MB_MAXBYTES];\n    int\t\tidx = 0;\n    char_u\t*end = find_termcode((char_u *)\"PE\");\n    int\t\tret_char = -1;\n    int\t\tsave_allow_keys = allow_keys;\n    int\t\tsave_paste = p_paste;\n\n    \/\/ If the end code is too long we can't detect it, read everything.\n    if (end != NULL && STRLEN(end) >= NUMBUFLEN)\n\tend = NULL;\n    ++no_mapping;\n    allow_keys = 0;\n    if (!p_paste)\n\t\/\/ Also have the side effects of setting 'paste' to make it work much\n\t\/\/ faster.\n\tset_option_value((char_u *)\"paste\", TRUE, NULL, 0);\n\n    for (;;)\n    {\n\t\/\/ When the end is not defined read everything there is.\n\tif (end == NULL && vpeekc() == NUL)\n\t    break;\n\tdo\n\t    c = vgetc();\n\twhile (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);\n\tif (c == NUL || got_int || (ex_normal_busy > 0 && c == Ctrl_C))\n\t    \/\/ When CTRL-C was encountered the typeahead will be flushed and we\n\t    \/\/ won't get the end sequence.  Except when using \":normal\".\n\t    break;\n\n\tif (has_mbyte)\n\t    idx += (*mb_char2bytes)(c, buf + idx);\n\telse\n\t    buf[idx++] = c;\n\tbuf[idx] = NUL;\n\tif (end != NULL && STRNCMP(buf, end, idx) == 0)\n\t{\n\t    if (end[idx] == NUL)\n\t\tbreak; \/\/ Found the end of paste code.\n\t    continue;\n\t}\n\tif (!drop)\n\t{\n\t    switch (mode)\n\t    {\n\t\tcase PASTE_CMDLINE:\n\t\t    put_on_cmdline(buf, idx, TRUE);\n\t\t    break;\n\n\t\tcase PASTE_EX:\n\t\t    if (gap != NULL && ga_grow(gap, idx) == OK)\n\t\t    {\n\t\t\tmch_memmove((char *)gap->ga_data + gap->ga_len,\n\t\t\t\t\t\t\t     buf, (size_t)idx);\n\t\t\tgap->ga_len += idx;\n\t\t    }\n\t\t    break;\n\n\t\tcase PASTE_INSERT:\n\t\t    if (stop_arrow() == OK)\n\t\t    {\n\t\t\tc = buf[0];\n\t\t\tif (idx == 1 && (c == CAR || c == K_KENTER || c == NL))\n\t\t\t    ins_eol(c);\n\t\t\telse\n\t\t\t{\n\t\t\t    ins_char_bytes(buf, idx);\n\t\t\t    AppendToRedobuffLit(buf, idx);\n\t\t\t}\n\t\t    }\n\t\t    break;\n\n\t\tcase PASTE_ONE_CHAR:\n\t\t    if (ret_char == -1)\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t    ret_char = (*mb_ptr2char)(buf);\n\t\t\telse\n\t\t\t    ret_char = buf[0];\n\t\t    }\n\t\t    break;\n\t    }\n\t}\n\tidx = 0;\n    }\n\n    --no_mapping;\n    allow_keys = save_allow_keys;\n    if (!save_paste)\n\tset_option_value((char_u *)\"paste\", FALSE, NULL, 0);\n\n    return ret_char;\n}","target":1,"code_token_length":688,"total_token_length":924,"max_tokens_setting":1024}
+{"idx":224492,"func":"static void gf_webvtt_flush_sample(void *user, GF_WebVTTSample *samp)\n{\n\tu64 start, end;\n\tGF_TXTIn *ctx = (GF_TXTIn *)user;\n\tGF_ISOSample *s;\n\n\tstart = gf_webvtt_sample_get_start(samp);\n\tend = gf_webvtt_sample_get_end(samp);\n\n\tif (ctx->seek_state==2) {\n\t\tDouble tsend = (Double) end;\n\t\ttsend \/= 1000;\n\t\tif (tsend<ctx->start_range) return;\n\t\tctx->seek_state = 0;\n\t}\n\n\ts = gf_isom_webvtt_to_sample(samp);\n\tif (s) {\n\t\tGF_FilterPacket *pck;\n\t\tu8 *pck_data;\n\n\t\tpck = gf_filter_pck_new_alloc(ctx->opid, s->dataLength, &pck_data);\n\t\tif (pck) {\n\t\t\tmemcpy(pck_data, s->data, s->dataLength);\n\t\t\tgf_filter_pck_set_cts(pck, (u64) (ctx->timescale * start \/ 1000) );\n\t\t\tgf_filter_pck_set_sap(pck, GF_FILTER_SAP_1);\n\n\n\t\t\tif (end && (end>=start) ) {\n\t\t\t\tgf_filter_pck_set_duration(pck, (u32) (ctx->timescale * (end-start) \/ 1000) );\n\t\t\t}\n\t\t\tgf_filter_pck_send(pck);\n\t\t}\n\n\t\tgf_isom_sample_del(&s);\n\t}\n\tgf_webvtt_sample_del(samp);\n\n\tgf_filter_pid_set_info(ctx->opid, GF_PROP_PID_DOWN_BYTES, &PROP_LONGUINT( gf_ftell(ctx->src )) );\n\n\tif (gf_filter_pid_would_block(ctx->opid))\n\t\tgf_webvtt_parser_suspend(ctx->vttparser);\n\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":244131,"func":"GF_Err subs_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_SubSampleInformationBox *ptr = (GF_SubSampleInformationBox *)s;\n\tu32 entry_count, i, j;\n\tu16 subsample_count;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tentry_count = gf_bs_read_u32(bs);\n\n\tfor (i=0; i<entry_count; i++) {\n\t\tu32 subs_size=0;\n\t\tGF_SubSampleInfoEntry *pSamp = (GF_SubSampleInfoEntry*) gf_malloc(sizeof(GF_SubSampleInfoEntry));\n\t\tif (!pSamp) return GF_OUT_OF_MEM;\n\n\t\tmemset(pSamp, 0, sizeof(GF_SubSampleInfoEntry));\n\t\tpSamp->SubSamples = gf_list_new();\n\t\tpSamp->sample_delta = gf_bs_read_u32(bs);\n\t\tsubsample_count = gf_bs_read_u16(bs);\n\t\tsubs_size=6;\n\n\t\tfor (j=0; j<subsample_count; j++) {\n\t\t\tGF_SubSampleEntry *pSubSamp = (GF_SubSampleEntry*) gf_malloc(sizeof(GF_SubSampleEntry));\n\t\t\tif (!pSubSamp) return GF_OUT_OF_MEM;\n\n\t\t\tmemset(pSubSamp, 0, sizeof(GF_SubSampleEntry));\n\t\t\tif (ptr->version==1) {\n\t\t\t\tpSubSamp->subsample_size = gf_bs_read_u32(bs);\n\t\t\t\tsubs_size+=4;\n\t\t\t} else {\n\t\t\t\tpSubSamp->subsample_size = gf_bs_read_u16(bs);\n\t\t\t\tsubs_size+=2;\n\t\t\t}\n\t\t\tpSubSamp->subsample_priority = gf_bs_read_u8(bs);\n\t\t\tpSubSamp->discardable = gf_bs_read_u8(bs);\n\t\t\tpSubSamp->reserved = gf_bs_read_u32(bs);\n\t\t\tsubs_size+=6;\n\n\t\t\tgf_list_add(pSamp->SubSamples, pSubSamp);\n\t\t}\n\t\tgf_list_add(ptr->Samples, pSamp);\n\t\tISOM_DECREASE_SIZE(ptr, subs_size);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":456,"total_token_length":692,"max_tokens_setting":1024}
+{"idx":218748,"func":"static MagickBooleanType CheckPSDChannels(const Image *image,\n  const PSDInfo *psd_info,LayerInfo *layer_info)\n{\n  int\n    channel_type;\n\n  size_t\n    blob_size;\n\n  ssize_t\n    i;\n\n  if (layer_info->channels < psd_info->min_channels)\n    return(MagickFalse);\n  channel_type=RedChannel;\n  if (psd_info->min_channels >= 3)\n    channel_type|=(GreenChannel | BlueChannel);\n  if (psd_info->min_channels >= 4)\n    channel_type|=BlackChannel;\n  blob_size=(size_t) GetBlobSize(image);\n  for (i=0; i < (ssize_t) layer_info->channels; i++)\n  {\n    short\n      type;\n\n    if (layer_info->channel_info[i].size >= blob_size)\n      return(MagickFalse);\n    type=layer_info->channel_info[i].type;\n    if ((i == 0) && (psd_info->mode == IndexedMode) && (type != 0))\n      return(MagickFalse);\n    if (type == -1)\n      {\n        channel_type|=AlphaChannel;\n        continue;\n      }\n    if (type < -1)\n      continue;\n    if (type == 0)\n      channel_type&=~RedChannel;\n    else if (type == 1)\n      channel_type&=~GreenChannel;\n    else if (type == 2)\n      channel_type&=~BlueChannel;\n    else if (type == 3)\n      channel_type&=~BlackChannel;\n  }\n  if (channel_type == 0)\n    return(MagickTrue);\n  if ((channel_type == AlphaChannel) &&\n      (layer_info->channels >= psd_info->min_channels + 1))\n    return(MagickTrue);\n  return(MagickFalse);\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":405380,"func":"int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,\n\t\t struct xfrm_migrate *m, int num_migrate,\n\t\t struct xfrm_kmaddress *k, struct net *net,\n\t\t struct xfrm_encap_tmpl *encap, u32 if_id)\n{\n\tint i, err, nx_cur = 0, nx_new = 0;\n\tstruct xfrm_policy *pol = NULL;\n\tstruct xfrm_state *x, *xc;\n\tstruct xfrm_state *x_cur[XFRM_MAX_DEPTH];\n\tstruct xfrm_state *x_new[XFRM_MAX_DEPTH];\n\tstruct xfrm_migrate *mp;\n\n\t\/* Stage 0 - sanity checks *\/\n\tif ((err = xfrm_migrate_check(m, num_migrate)) < 0)\n\t\tgoto out;\n\n\tif (dir >= XFRM_POLICY_MAX) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t\/* Stage 1 - find policy *\/\n\tif ((pol = xfrm_migrate_policy_find(sel, dir, type, net, if_id)) == NULL) {\n\t\terr = -ENOENT;\n\t\tgoto out;\n\t}\n\n\t\/* Stage 2 - find and update state(s) *\/\n\tfor (i = 0, mp = m; i < num_migrate; i++, mp++) {\n\t\tif ((x = xfrm_migrate_state_find(mp, net, if_id))) {\n\t\t\tx_cur[nx_cur] = x;\n\t\t\tnx_cur++;\n\t\t\txc = xfrm_state_migrate(x, mp, encap);\n\t\t\tif (xc) {\n\t\t\t\tx_new[nx_new] = xc;\n\t\t\t\tnx_new++;\n\t\t\t} else {\n\t\t\t\terr = -ENODATA;\n\t\t\t\tgoto restore_state;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* Stage 3 - update policy *\/\n\tif ((err = xfrm_policy_migrate(pol, m, num_migrate)) < 0)\n\t\tgoto restore_state;\n\n\t\/* Stage 4 - delete old state(s) *\/\n\tif (nx_cur) {\n\t\txfrm_states_put(x_cur, nx_cur);\n\t\txfrm_states_delete(x_cur, nx_cur);\n\t}\n\n\t\/* Stage 5 - announce *\/\n\tkm_migrate(sel, dir, type, m, num_migrate, k, encap);\n\n\txfrm_pol_put(pol);\n\n\treturn 0;\nout:\n\treturn err;\n\nrestore_state:\n\tif (pol)\n\t\txfrm_pol_put(pol);\n\tif (nx_cur)\n\t\txfrm_states_put(x_cur, nx_cur);\n\tif (nx_new)\n\t\txfrm_states_delete(x_new, nx_new);\n\n\treturn err;\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":229169,"func":"static void handle_input(VirtIODevice *vdev, VirtQueue *vq)\n{\n    \/*\n     * Users of virtio-serial would like to know when guest becomes\n     * writable again -- i.e. if a vq had stuff queued up and the\n     * guest wasn't reading at all, the host would not be able to\n     * write to the vq anymore.  Once the guest reads off something,\n     * we can start queueing things up again.  However, this call is\n     * made for each buffer addition by the guest -- even though free\n     * buffers existed prior to the current buffer addition.  This is\n     * done so as not to maintain previous state, which will need\n     * additional live-migration-related changes.\n     *\/\n    VirtIOSerial *vser;\n    VirtIOSerialPort *port;\n    VirtIOSerialPortClass *vsc;\n\n    vser = VIRTIO_SERIAL(vdev);\n    port = find_port_by_vq(vser, vq);\n\n    if (!port) {\n        return;\n    }\n    vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n\n    \/*\n     * If guest_connected is false, this call is being made by the\n     * early-boot queueing up of descriptors, which is just noise for\n     * the host apps -- don't disturb them in that case.\n     *\/\n    if (port->guest_connected && port->host_connected && vsc->guest_writable) {\n        vsc->guest_writable(port);\n    }\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":264654,"func":"GF_Err BM_ParseIndexDelete(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)\n{\n\tu32 NodeID, NumBits, ind, field_ind;\n\ts32 pos;\n\tGF_Command *com;\n\tu8 type;\n\tGF_Node *node;\n\tGF_Err e;\n\tGF_CommandField *inf;\n\tGF_FieldInfo field;\n\n\tNodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits);\n\tnode = gf_sg_find_node(codec->current_graph, NodeID);\n\tif (!node) return GF_NON_COMPLIANT_BITSTREAM;\n\n\tNumBits = gf_get_bit_size(gf_node_get_num_fields_in_mode(node, GF_SG_FIELD_CODING_IN) - 1);\n\tind = gf_bs_read_int(bs, NumBits);\n\n\ttype = gf_bs_read_int(bs, 2);\n\tswitch (type) {\n\tcase 0:\n\t\tpos = (u32) gf_bs_read_int(bs, 16);\n\t\tbreak;\n\tcase 2:\n\t\tpos = 0;\n\t\tbreak;\n\tcase 3:\n\t\tpos = -1;\n\t\tbreak;\n\tdefault:\n\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t}\n\te = gf_bifs_get_field_index(node, ind, GF_SG_FIELD_CODING_IN, &field_ind);\n\tif (e) return e;\n\te = gf_node_get_field(node, field_ind, &field);\n\tif (e) return e;\n\tif (gf_sg_vrml_is_sf_field(field.fieldType)) return GF_NON_COMPLIANT_BITSTREAM;\n\tcom = gf_sg_command_new(codec->current_graph, GF_SG_INDEXED_DELETE);\n\tBM_SetCommandNode(com, node);\n\tinf = gf_sg_command_field_new(com);\n\tinf->pos = pos;\n\tinf->fieldIndex = field.fieldIndex;\n\tinf->fieldType = gf_sg_vrml_get_sf_type(field.fieldType);\n\tgf_list_add(com_list, com);\n\treturn codec->LastError;\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":276955,"func":"SampleEncrypter::EncryptVideoSample(AP4_DataBuffer& sample, AP4_UI08 nalu_length_size)\n{\n    AP4_DataBuffer encrypted;\n    \n    AP4_UI08* nalu = sample.UseData();\n    AP4_Size  bytes_remaining = sample.GetDataSize();\n    while (bytes_remaining > nalu_length_size) {\n        AP4_Size nalu_length = 0;\n        switch (nalu_length_size) {\n            case 1:\n                nalu_length = nalu[0];\n                break;\n                \n            case 2:\n                nalu_length = AP4_BytesToUInt16BE(nalu);\n                break;\n    \n            case 4:\n                nalu_length = AP4_BytesToUInt32BE(nalu);\n                break;\n                \n            default:\n                break;\n        }\n        \n        if (bytes_remaining < nalu_length_size+nalu_length) {\n            break;\n        }\n        \n        AP4_UI08 nalu_type = nalu[nalu_length_size] & 0x1F;\n        if (nalu_length > 48 && (nalu_type == 1 || nalu_type == 5)) {\n            AP4_Size encrypted_size = 16*((nalu_length-32)\/16);\n            if ((nalu_length%16) == 0) {\n                encrypted_size -= 16;\n            }\n            m_StreamCipher->SetIV(m_IV);\n            for (unsigned int i=0; i<encrypted_size; i += 10*16) {\n                AP4_Size one_block_size = 16;\n                m_StreamCipher->ProcessBuffer(nalu+nalu_length_size+32+i, one_block_size,\n                                              nalu+nalu_length_size+32+i, &one_block_size);\n            }\n\n            \/\/ perform startcode emulation prevention\n            AP4_DataBuffer escaped_nalu;\n            PreventStartCodeEmulation(nalu+nalu_length_size, nalu_length, escaped_nalu);\n            \n            \/\/ the size may have changed\n            \/\/ TODO: this could overflow if nalu_length_size is too small\n            switch (nalu_length_size) {\n                case 1:\n                    nalu[0] = (AP4_UI08)(escaped_nalu.GetDataSize()&0xFF);\n                    break;\n                    \n                case 2:\n                    AP4_BytesFromUInt16BE(nalu, escaped_nalu.GetDataSize());\n                    break;\n        \n                case 4:\n                    AP4_BytesFromUInt32BE(nalu, escaped_nalu.GetDataSize());\n                    break;\n                    \n                default:\n                    break;\n            }\n\n            encrypted.AppendData(nalu, nalu_length_size);\n            encrypted.AppendData(escaped_nalu.GetData(), escaped_nalu.GetDataSize());\n        } else {\n            encrypted.AppendData(nalu, nalu_length_size);\n            encrypted.AppendData(nalu+nalu_length_size, nalu_length);\n        }\n        \n        nalu            += nalu_length_size+nalu_length;\n        bytes_remaining -= nalu_length_size+nalu_length;\n    }\n    \n    sample.SetData(encrypted.GetData(), encrypted.GetDataSize());\n    \n    return AP4_SUCCESS;\n}","target":0,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":346461,"func":"ex_scriptnames(exarg_T *eap)\n{\n    int i;\n\n    if (eap->addr_count > 0 || *eap->arg != NUL)\n    {\n\t\/\/ :script {scriptId}: edit the script\n\tif (eap->addr_count > 0 && !SCRIPT_ID_VALID(eap->line2))\n\t    emsg(_(e_invalid_argument));\n\telse\n\t{\n\t    if (eap->addr_count > 0)\n\t\teap->arg = SCRIPT_ITEM(eap->line2)->sn_name;\n\t    else\n\t    {\n\t\texpand_env(eap->arg, NameBuff, MAXPATHL);\n\t\teap->arg = NameBuff;\n\t    }\n\t    do_exedit(eap, NULL);\n\t}\n\treturn;\n    }\n\n    for (i = 1; i <= script_items.ga_len && !got_int; ++i)\n    {\n\tscriptitem_T *si = SCRIPT_ITEM(i);\n\n\tif (si->sn_name != NULL)\n\t{\n\t    home_replace(NULL, si->sn_name, NameBuff, MAXPATHL, TRUE);\n\t    vim_snprintf((char *)IObuff, IOSIZE, \"%3d%s: %s\",\n\t\t    i,\n\t\t    si->sn_state == SN_STATE_NOT_LOADED ? \" A\" : \"\",\n\t\t    NameBuff);\n\t    if (!message_filtered(IObuff))\n\t    {\n\t\tmsg_putchar('\\n');\n\t\tmsg_outtrans(IObuff);\n\t\tout_flush();\t    \/\/ output one line at a time\n\t\tui_breakcheck();\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":315,"total_token_length":551,"max_tokens_setting":1024}
+{"idx":276993,"func":"fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n  struct mrb_context *c = fiber_check(mrb, self);\n  struct mrb_context *old_c = mrb->c;\n  enum mrb_fiber_state status;\n  mrb_value value;\n\n  fiber_check_cfunc(mrb, c);\n  status = c->status;\n  switch (status) {\n  case MRB_FIBER_TRANSFERRED:\n    if (resume) {\n      mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n    }\n    break;\n  case MRB_FIBER_RUNNING:\n  case MRB_FIBER_RESUMED:\n    mrb_raise(mrb, E_FIBER_ERROR, \"double resume\");\n    break;\n  case MRB_FIBER_TERMINATED:\n    mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n    break;\n  default:\n    break;\n  }\n  old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n  c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);\n  fiber_switch_context(mrb, c);\n  if (status == MRB_FIBER_CREATED) {\n    mrb_value *b, *e;\n\n    if (!c->ci->proc) {\n      mrb_raise(mrb, E_FIBER_ERROR, \"double resume (current)\");\n    }\n    if (vmexec) {\n      c->ci--;                    \/* pop dummy callinfo *\/\n    }\n    if (len >= 15) {\n      mrb_stack_extend(mrb, 3);   \/* for receiver, args and (optional) block *\/\n      c->stbase[1] = mrb_ary_new_from_values(mrb, len, a);\n      len = 15;\n    }\n    else {\n      mrb_stack_extend(mrb, len+2); \/* for receiver and (optional) block *\/\n      b = c->stbase+1;\n      e = b + len;\n      while (b<e) {\n        *b++ = *a++;\n      }\n    }\n    c->cibase->n = len;\n    value = c->stbase[0] = MRB_PROC_ENV(c->cibase->proc)->stack[0];\n  }\n  else {\n    value = fiber_result(mrb, a, len);\n    if (vmexec) {\n      c->ci[1].stack[0] = value;\n    }\n  }\n\n  if (vmexec) {\n    c->vmexec = TRUE;\n    value = mrb_vm_exec(mrb, c->ci->proc, c->ci->pc);\n    mrb->c = old_c;\n  }\n  else {\n    MARK_CONTEXT_MODIFY(c);\n  }\n  return value;\n}","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":402602,"func":"handle_signing(context *ctx, struct pollfd *pollfd, socklen_t size,\n\t       int attached, bool with_file_type)\n{\n\tstruct msghdr msg;\n\tstruct iovec iov;\n\tssize_t n;\n\tchar *buffer = malloc(size);\n\tuint32_t file_format;\n\n\tif (!buffer) {\noom:\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unable to allocate memory: %m\");\n\t\texit(1);\n\t}\n\n\tmemset(&msg, '\\0', sizeof(msg));\n\n\tiov.iov_base = buffer;\n\tiov.iov_len = size;\n\tmsg.msg_iov = &iov;\n\tmsg.msg_iovlen = 1;\n\n\tn = recvmsg(pollfd->fd, &msg, MSG_WAITALL);\n\n\tif (with_file_type) {\n\t\tfile_format = *((uint32_t *) buffer);\n\t\tn -= sizeof(uint32_t);\n\t} else {\n\t\tfile_format = FORMAT_PE_BINARY;\n\t}\n\n\tpesignd_string *tn = (pesignd_string *)(buffer + sizeof(uint32_t));\n\tif (n < (long long)sizeof(tn->size)) {\nmalformed:\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"handle_signing: invalid data\");\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"possible exploit attempt. closing.\");\n\t\tclose(pollfd->fd);\n\t\treturn;\n\t}\n\n\tn -= sizeof(tn->size);\n\tif ((size_t)n < tn->size)\n\t\tgoto malformed;\n\tn -= tn->size;\n\n\t\/* authenticating with nss frees these ... best API ever. *\/\n\tctx->cms->tokenname = PORT_ArenaStrdup(ctx->cms->arena,\n\t\t\t\t\t\t(char *)tn->value);\n\tif (!ctx->cms->tokenname)\n\t\tgoto oom;\n\n\tif ((size_t)n < sizeof(tn->size))\n\t\tgoto malformed;\n\tpesignd_string *cn = pesignd_string_next(tn);\n\tn -= sizeof(cn->size);\n\tif ((size_t)n < cn->size)\n\t\tgoto malformed;\n\n\tctx->cms->certname = PORT_ArenaStrdup(ctx->cms->arena,\n\t\t\t\t\t\t(char *)cn->value);\n\tif (!ctx->cms->certname)\n\t\tgoto oom;\n\n\tn -= cn->size;\n\tif (n != 0)\n\t\tgoto malformed;\n\n\tint infd=-1;\n\tsocket_get_fd(ctx, pollfd->fd, &infd);\n\n\tint outfd=-1;\n\tsocket_get_fd(ctx, pollfd->fd, &outfd);\n\n\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\"attempting to sign with key \\\"%s:%s\\\"\",\n\t\ttn->value, cn->value);\n\tfree(buffer);\n\n\tint rc = find_certificate(ctx->cms, 1);\n\tif (rc < 0) {\n\t\tgoto finish;\n\t}\n\n\tswitch (file_format) {\n\tcase FORMAT_PE_BINARY:\n\t\trc = sign_pe(ctx, infd, outfd, attached);\n\t\tbreak;\n\tcase FORMAT_KERNEL_MODULE:\n\t\trc = sign_kmod(ctx, infd, outfd, attached);\n\t\tbreak;\n\tdefault:\n\t\trc = -1;\n\t\tbreak;\n\t}\n\n\tif (rc < 0)\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t      \"unrecognised format %d\", file_format);\n\nfinish:\n\tclose(infd);\n\tclose(outfd);\n\n\tsend_response(ctx, ctx->cms, pollfd, rc);\n\tteardown_digests(ctx->cms);\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":244297,"func":"GF_Err mvcg_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_MultiviewGroupBox *ptr = (GF_MultiviewGroupBox *) s;\n\tISOM_DECREASE_SIZE(s, 7)\n\tptr->multiview_group_id = gf_bs_read_u32(bs);\n\tptr->num_entries = gf_bs_read_u16(bs);\n\tgf_bs_read_u8(bs);\n\tptr->entries = gf_malloc(ptr->num_entries * sizeof(MVCIEntry));\n\tmemset(ptr->entries, 0, ptr->num_entries * sizeof(MVCIEntry));\n\tfor (i=0; i<ptr->num_entries; i++) {\n\t\tISOM_DECREASE_SIZE(s, 1)\n\t\tptr->entries[i].entry_type = gf_bs_read_u8(bs);\n\t\tswitch (ptr->entries[i].entry_type) {\n\t\tcase 0:\n\t\t\tISOM_DECREASE_SIZE(s, 4)\n\t\t\tptr->entries[i].trackID = gf_bs_read_u32(bs);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tISOM_DECREASE_SIZE(s, 6)\n\t\t\tptr->entries[i].trackID = gf_bs_read_u32(bs);\n\t\t\tptr->entries[i].tierID = gf_bs_read_u16(bs);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tISOM_DECREASE_SIZE(s, 2)\n\t\t\tgf_bs_read_int(bs, 6);\n\t\t\tptr->entries[i].output_view_id = gf_bs_read_int(bs, 10);\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tISOM_DECREASE_SIZE(s, 4)\n\t\t\tgf_bs_read_int(bs, 6)\t;\n\t\t\tptr->entries[i].start_view_id = gf_bs_read_int(bs, 10);\n\t\t\tptr->entries[i].view_count = gf_bs_read_u16(bs);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":225925,"func":"\nGF_Err vwid_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i, j;\n\tGF_ViewIdentifierBox *ptr = (GF_ViewIdentifierBox *) s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_int(bs, 0, 2);\n\tgf_bs_write_int(bs, ptr->min_temporal_id, 3);\n\tgf_bs_write_int(bs, ptr->max_temporal_id, 3);\n\tgf_bs_write_u16(bs, ptr->num_views);\n\n\tfor (i=0; i<ptr->num_views; i++) {\n\t\tgf_bs_write_int(bs, 0, 6);\n\t\tgf_bs_write_int(bs, ptr->views[i].view_id, 10);\n\t\tgf_bs_write_int(bs, 0, 6);\n\t\tgf_bs_write_int(bs, ptr->views[i].view_order_index, 10);\n\n\t\tgf_bs_write_int(bs, ptr->views[i].texture_in_stream, 1);\n\t\tgf_bs_write_int(bs, ptr->views[i].texture_in_track, 1);\n\t\tgf_bs_write_int(bs, ptr->views[i].depth_in_stream, 1);\n\t\tgf_bs_write_int(bs, ptr->views[i].depth_in_track, 1);\n\t\tgf_bs_write_int(bs, ptr->views[i].base_view_type, 2);\n\t\tgf_bs_write_int(bs, ptr->views[i].num_ref_views, 10);\n\n\t\tfor (j=0; j<ptr->views[i].num_ref_views; j++) {\n\t\t\tgf_bs_write_int(bs, 0, 4);\n\t\t\tgf_bs_write_int(bs, ptr->views[i].view_refs[j].dep_comp_idc, 2);\n\t\t\tgf_bs_write_int(bs, ptr->views[i].view_refs[j].ref_view_id, 10);\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":427729,"func":"cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,\n    cdf_catalog_t **cat)\n{\n\tsize_t ss = cdf_check_stream(sst, h);\n\tconst char *b = CAST(const char *, sst->sst_tab);\n\tconst char *nb, *eb = b + ss * sst->sst_len;\n\tsize_t nr, i, j, k;\n\tcdf_catalog_entry_t *ce;\n\tuint16_t reclen;\n\tconst uint16_t *np;\n\n\tfor (nr = 0;; nr++) {\n\t\tmemcpy(&reclen, b, sizeof(reclen));\n\t\treclen = CDF_TOLE2(reclen);\n\t\tif (reclen == 0)\n\t\t\tbreak;\n\t\tb += reclen;\n\t\tif (b > eb)\n\t\t    break;\n\t}\n\tif (nr == 0)\n\t\treturn -1;\n\tnr--;\n\t*cat = CAST(cdf_catalog_t *,\n\t    CDF_MALLOC(sizeof(cdf_catalog_t) + nr * sizeof(*ce)));\n\tif (*cat == NULL)\n\t\treturn -1;\n\tce = (*cat)->cat_e;\n\tmemset(ce, 0, nr * sizeof(*ce));\n\tb = CAST(const char *, sst->sst_tab);\n\tfor (j = i = 0; i < nr; b += reclen) {\n\t\tcdf_catalog_entry_t *cep = &ce[j];\n\t\tuint16_t rlen;\n\n\t\textract_catalog_field(uint16_t, ce_namlen, 0);\n\t\textract_catalog_field(uint16_t, ce_num, 4);\n\t\textract_catalog_field(uint64_t, ce_timestamp, 8);\n\t\treclen = cep->ce_namlen;\n\n\t\tif (reclen < 14) {\n\t\t\tcep->ce_namlen = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tcep->ce_namlen = __arraycount(cep->ce_name) - 1;\n\t\trlen = reclen - 14;\n\t\tif (cep->ce_namlen > rlen)\n\t\t\tcep->ce_namlen = rlen;\n\n\t\tnp = CAST(const uint16_t *, CAST(const void *, (b + 16)));\n\t\tnb = CAST(const char *, CAST(const void *,\n\t\t    (np + cep->ce_namlen)));\n\t\tif (nb > eb) {\n\t\t\tcep->ce_namlen = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (k = 0; k < cep->ce_namlen; k++)\n\t\t\tcep->ce_name[k] = np[k]; \/* XXX: CDF_TOLE2? *\/\n\t\tcep->ce_name[cep->ce_namlen] = 0;\n\t\tj = i;\n\t\ti++;\n\t}\n\t(*cat)->cat_num = j;\n\treturn 0;\n}","target":0,"code_token_length":607,"total_token_length":843,"max_tokens_setting":1024}
+{"idx":273875,"func":"static void mlsd_printf(ctrl_t *ctrl, char *buf, size_t len, char *path, char *name, struct stat *st)\n{\n\tchar perms[10] = \"\";\n\tint ro = !access(path, R_OK);\n\tint rw = !access(path, W_OK);\n\n\tif (S_ISDIR(st->st_mode)) {\n\t\t\/* XXX: Verify 'e' by checking that we can CD to the 'name' *\/\n\t\tif (ro)\n\t\t\tstrlcat(perms, \"le\", sizeof(perms));\n\t\tif (rw)\n\t\t\tstrlcat(perms, \"pc\", sizeof(perms)); \/* 'd' RMD, 'm' MKD *\/\n\t} else {\n\t\tif (ro)\n\t\t\tstrlcat(perms, \"r\", sizeof(perms));\n\t\tif (rw)\n\t\t\tstrlcat(perms, \"w\", sizeof(perms)); \/* 'f' RNFR, 'd' DELE *\/\n\t}\n\n\tmemset(buf, 0, len);\n\tif (ctrl->d_num == -1 && (ctrl->list_mode & 0x0F) == 2)\n\t\tstrlcat(buf, \" \", len);\n\n\tfor (int i = 0; ctrl->facts[i]; i++)\n\t\tmlsd_fact(ctrl->facts[i], buf, len, name, perms, st);\n\n\tstrlcat(buf, \" \", len);\n\tstrlcat(buf, name, len);\n\tstrlcat(buf, \"\\r\\n\", len);\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":424965,"func":"static ssize_t iwl_dbgfs_interrupt_read(struct file *file,\n\t\t\t\t\tchar __user *user_buf,\n\t\t\t\t\tsize_t count, loff_t *ppos)\n{\n\tstruct iwl_trans *trans = file->private_data;\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tstruct isr_statistics *isr_stats = &trans_pcie->isr_stats;\n\n\tint pos = 0;\n\tchar *buf;\n\tint bufsz = 24 * 64; \/* 24 items * 64 char per item *\/\n\tssize_t ret;\n\n\tbuf = kzalloc(bufsz, GFP_KERNEL);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tpos += scnprintf(buf + pos, bufsz - pos,\n\t\t\t\"Interrupt Statistics Report:\\n\");\n\n\tpos += scnprintf(buf + pos, bufsz - pos, \"HW Error:\\t\\t\\t %u\\n\",\n\t\tisr_stats->hw);\n\tpos += scnprintf(buf + pos, bufsz - pos, \"SW Error:\\t\\t\\t %u\\n\",\n\t\tisr_stats->sw);\n\tif (isr_stats->sw || isr_stats->hw) {\n\t\tpos += scnprintf(buf + pos, bufsz - pos,\n\t\t\t\"\\tLast Restarting Code:  0x%X\\n\",\n\t\t\tisr_stats->err_code);\n\t}\n#ifdef CONFIG_IWLWIFI_DEBUG\n\tpos += scnprintf(buf + pos, bufsz - pos, \"Frame transmitted:\\t\\t %u\\n\",\n\t\tisr_stats->sch);\n\tpos += scnprintf(buf + pos, bufsz - pos, \"Alive interrupt:\\t\\t %u\\n\",\n\t\tisr_stats->alive);\n#endif\n\tpos += scnprintf(buf + pos, bufsz - pos,\n\t\t\"HW RF KILL switch toggled:\\t %u\\n\", isr_stats->rfkill);\n\n\tpos += scnprintf(buf + pos, bufsz - pos, \"CT KILL:\\t\\t\\t %u\\n\",\n\t\tisr_stats->ctkill);\n\n\tpos += scnprintf(buf + pos, bufsz - pos, \"Wakeup Interrupt:\\t\\t %u\\n\",\n\t\tisr_stats->wakeup);\n\n\tpos += scnprintf(buf + pos, bufsz - pos,\n\t\t\"Rx command responses:\\t\\t %u\\n\", isr_stats->rx);\n\n\tpos += scnprintf(buf + pos, bufsz - pos, \"Tx\/FH interrupt:\\t\\t %u\\n\",\n\t\tisr_stats->tx);\n\n\tpos += scnprintf(buf + pos, bufsz - pos, \"Unexpected INTA:\\t\\t %u\\n\",\n\t\tisr_stats->unhandled);\n\n\tret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);\n\tkfree(buf);\n\treturn ret;\n}","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":220243,"func":"Node::NodeClass Node::GetNodeClassForOp(const std::string& ts) {\n  static const absl::flat_hash_map<std::string, Node::NodeClass>*\n      kNodeClassTable =\n#define REF_CLASS(key, value) \\\n  {key, value}, { \"Ref\" key, value }\n          new absl::flat_hash_map<std::string, Node::NodeClass>({\n              \/\/ Keep in same order as NodeClass values\n              REF_CLASS(\"Switch\", NC_SWITCH),\n              REF_CLASS(\"_SwitchN\", NC_SWITCH),\n              REF_CLASS(\"Merge\", NC_MERGE),\n              REF_CLASS(\"Enter\", NC_ENTER),\n              REF_CLASS(\"Exit\", NC_EXIT),\n              REF_CLASS(\"NextIteration\", NC_NEXT_ITERATION),\n              {\"LoopCond\", NC_LOOP_COND},\n              {\"ControlTrigger\", NC_CONTROL_TRIGGER},\n              {\"_Send\", NC_SEND},\n              {\"_HostSend\", NC_HOST_SEND},\n              {\"_Recv\", NC_RECV},\n              {\"_HostRecv\", NC_HOST_RECV},\n              {\"Const\", NC_CONSTANT},\n              {\"HostConst\", NC_CONSTANT},\n              {\"Variable\", NC_VARIABLE},\n              {\"VariableV2\", NC_VARIABLE},\n              REF_CLASS(\"Identity\", NC_IDENTITY),\n              {\"GetSessionHandle\", NC_GET_SESSION_HANDLE},\n              {\"GetSessionHandleV2\", NC_GET_SESSION_HANDLE},\n              {\"GetSessionTensor\", NC_GET_SESSION_TENSOR},\n              {\"DeleteSessionTensor\", NC_DELETE_SESSION_TENSOR},\n              {\"Size\", NC_METADATA},\n              {\"Shape\", NC_METADATA},\n              {\"Rank\", NC_METADATA},\n              {\"_ScopedAllocator\", NC_SCOPED_ALLOCATOR},\n              {\"CollectiveReduce\", NC_COLLECTIVE},\n              {\"CollectiveBcastSend\", NC_COLLECTIVE},\n              {\"CollectiveBcastRecv\", NC_COLLECTIVE},\n              {\"CollectiveGather\", NC_COLLECTIVE},\n              {\"FakeParam\", NC_FAKE_PARAM},\n              {\"PartitionedCall\", NC_PARTITIONED_CALL},\n              {\"StatefulPartitionedCall\", NC_PARTITIONED_CALL},\n              {\"SymbolicGradient\", NC_SYMBOLIC_GRADIENT},\n              {\"If\", NC_IF},\n              {\"StatelessIf\", NC_IF},\n              {\"While\", NC_WHILE},\n              {\"StatelessWhile\", NC_WHILE},\n              {\"Case\", NC_CASE},\n              {\"StatelessCase\", NC_CASE},\n              \/\/ Not using the constants defined in FunctionLibraryDefinition\n              \/\/ for the\n              \/\/ 4 ops below because android inference library does not link\n              \/\/ tf.function related files.\n              {\"_Arg\", NC_ARG},\n              {\"_DeviceArg\", NC_ARG},\n              {\"_Retval\", NC_RETVAL},\n              {\"_DeviceRetval\", NC_RETVAL},\n              {\"_XlaMerge\", NC_MERGE},\n          });\n#undef REF_CLASS\n\n  auto it = kNodeClassTable->find(ts);\n  if (it != kNodeClassTable->end()) {\n    return it->second;\n  } else {\n    return NC_OTHER;\n  }\n}","target":0,"code_token_length":610,"total_token_length":846,"max_tokens_setting":1024}
+{"idx":220936,"func":"GF_Err mpgviddmx_configure_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_remove)\n{\n\tBool was_mpeg12;\n\tconst GF_PropertyValue *p;\n\tGF_MPGVidDmxCtx *ctx = gf_filter_get_udta(filter);\n\n\tif (is_remove) {\n\t\tctx->ipid = NULL;\n\t\tif (ctx->opid) {\n\t\t\tgf_filter_pid_remove(ctx->opid);\n\t\t\tctx->opid = NULL;\n\t\t}\n\t\treturn GF_OK;\n\t}\n\tif (! gf_filter_pid_check_caps(pid))\n\t\treturn GF_NOT_SUPPORTED;\n\n\tctx->ipid = pid;\n\tctx->cur_fps = ctx->fps;\n\tif (!ctx->fps.num || !ctx->fps.den) {\n\t\tctx->cur_fps.num = 25000;\n\t\tctx->cur_fps.den = 1000;\n\t}\n\n\tp = gf_filter_pid_get_property(pid, GF_PROP_PID_TIMESCALE);\n\tif (p) {\n\t\tctx->timescale = ctx->cur_fps.num = p->value.uint;\n\t\tctx->cur_fps.den = 0;\n\t\tp = gf_filter_pid_get_property(pid, GF_PROP_PID_FPS);\n\t\tif (p) {\n\t\t\tctx->cur_fps = p->value.frac;\n\t\t}\n\t\tp = gf_filter_pid_get_property_str(pid, \"nocts\");\n\t\tif (p && p->value.boolean) ctx->recompute_cts = GF_TRUE;\n\t}\n\n\twas_mpeg12 = ctx->is_mpg12;\n\n\tp = gf_filter_pid_get_property(pid, GF_PROP_PID_CODECID);\n\tif (p) {\n\t\tswitch (p->value.uint) {\n\t\tcase GF_CODECID_MPEG1:\n\t\tcase GF_CODECID_MPEG2_422:\n\t\tcase GF_CODECID_MPEG2_SNR:\n\t\tcase GF_CODECID_MPEG2_HIGH:\n\t\tcase GF_CODECID_MPEG2_MAIN:\n\t\tcase GF_CODECID_MPEG2_SIMPLE:\n\t\tcase GF_CODECID_MPEG2_SPATIAL:\n\t\t\tctx->is_mpg12 = GF_TRUE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse {\n\t\tp = gf_filter_pid_get_property(pid, GF_PROP_PID_MIME);\n\t\tif (p && p->value.string && (strstr(p->value.string, \"m1v\") || strstr(p->value.string, \"m2v\")) ) ctx->is_mpg12 = GF_TRUE;\n\t\telse {\n\t\t\tp = gf_filter_pid_get_property(pid, GF_PROP_PID_FILE_EXT);\n\t\t\tif (p && p->value.string && (strstr(p->value.string, \"m1v\") || strstr(p->value.string, \"m2v\")) ) ctx->is_mpg12 = GF_TRUE;\n\t\t}\n\t}\n\n\tif (ctx->vparser && (was_mpeg12 != ctx->is_mpg12)) {\n\t\tgf_m4v_parser_del_no_bs(ctx->vparser);\n\t\tctx->vparser = NULL;\n\t}\n\n\tif (ctx->timescale && !ctx->opid) {\n\t\tctx->opid = gf_filter_pid_new(filter);\n\t\tgf_filter_pid_copy_properties(ctx->opid, ctx->ipid);\n\t\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_UNFRAMED, NULL);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":699,"total_token_length":935,"max_tokens_setting":1024}
+{"idx":229235,"func":"void cql_server::response::serialize(const event::schema_change& event, uint8_t version)\n{\n    if (version >= 3) {\n        write_string(to_string(event.change));\n        write_string(to_string(event.target));\n        write_string(event.keyspace);\n        switch (event.target) {\n        case event::schema_change::target_type::KEYSPACE:\n            break;\n        case event::schema_change::target_type::TYPE:\n        case event::schema_change::target_type::TABLE:\n            write_string(event.arguments[0]);\n            break;\n        case event::schema_change::target_type::FUNCTION:\n        case event::schema_change::target_type::AGGREGATE:\n            write_string(event.arguments[0]);\n            write_string_list(std::vector<sstring>(event.arguments.begin() + 1, event.arguments.end()));\n            break;\n        }\n    } else {\n        switch (event.target) {\n        \/\/ FIXME: Should we handle FUNCTION and AGGREGATE the same way as type?\n        \/\/ FIXME: How do we get here? Can a client using v2 know about UDF?\n        case event::schema_change::target_type::TYPE:\n        case event::schema_change::target_type::FUNCTION:\n        case event::schema_change::target_type::AGGREGATE:\n            \/\/ The v1\/v2 protocol is unable to represent these changes. Tell the\n            \/\/ client that the keyspace was updated instead.\n            write_string(to_string(event::schema_change::change_type::UPDATED));\n            write_string(event.keyspace);\n            write_string(\"\");\n            break;\n        case event::schema_change::target_type::TABLE:\n        case event::schema_change::target_type::KEYSPACE:\n            write_string(to_string(event.change));\n            write_string(event.keyspace);\n            if (event.target == event::schema_change::target_type::TABLE) {\n                write_string(event.arguments[0]);\n            } else {\n                write_string(\"\");\n            }\n        }\n    }\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":434079,"func":"check_arg_idx(win_T *win)\n{\n    if (WARGCOUNT(win) > 1 && !editing_arg_idx(win))\n    {\n\t\/\/ We are not editing the current entry in the argument list.\n\t\/\/ Set \"arg_had_last\" if we are editing the last one.\n\twin->w_arg_idx_invalid = TRUE;\n\tif (win->w_arg_idx != WARGCOUNT(win) - 1\n\t\t&& arg_had_last == FALSE\n\t\t&& ALIST(win) == &global_alist\n\t\t&& GARGCOUNT > 0\n\t\t&& win->w_arg_idx < GARGCOUNT\n\t\t&& (win->w_buffer->b_fnum == GARGLIST[GARGCOUNT - 1].ae_fnum\n\t\t    || (win->w_buffer->b_ffname != NULL\n\t\t\t&& (fullpathcmp(alist_name(&GARGLIST[GARGCOUNT - 1]),\n\t\t\t  win->w_buffer->b_ffname, TRUE, TRUE) & FPC_SAME))))\n\t    arg_had_last = TRUE;\n    }\n    else\n    {\n\t\/\/ We are editing the current entry in the argument list.\n\t\/\/ Set \"arg_had_last\" if it's also the last one\n\twin->w_arg_idx_invalid = FALSE;\n\tif (win->w_arg_idx == WARGCOUNT(win) - 1\n\t\t\t\t\t      && win->w_alist == &global_alist)\n\t    arg_had_last = TRUE;\n    }\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":252308,"func":"static void hufPackEncTable(\n    const long long *hcode,  \/\/ i : encoding table [HUF_ENCSIZE]\n    int im,                  \/\/ i : min hcode index\n    int iM,                  \/\/ i : max hcode index\n    char **pcode)            \/\/  o: ptr to packed table (updated)\n{\n  char *p = *pcode;\n  long long c = 0;\n  int lc = 0;\n\n  for (; im <= iM; im++) {\n    int l = hufLength(hcode[im]);\n\n    if (l == 0) {\n      int zerun = 1;\n\n      while ((im < iM) && (zerun < LONGEST_LONG_RUN)) {\n        if (hufLength(hcode[im + 1]) > 0) break;\n        im++;\n        zerun++;\n      }\n\n      if (zerun >= 2) {\n        if (zerun >= SHORTEST_LONG_RUN) {\n          outputBits(6, LONG_ZEROCODE_RUN, c, lc, p);\n          outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p);\n        } else {\n          outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p);\n        }\n        continue;\n      }\n    }\n\n    outputBits(6, l, c, lc, p);\n  }\n\n  if (lc > 0) *p++ = (unsigned char)(c << (8 - lc));\n\n  *pcode = p;\n}","target":0,"code_token_length":335,"total_token_length":571,"max_tokens_setting":1024}
+{"idx":226380,"func":"\nGF_Err chnl_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u8(bs, ptr->layout.stream_structure);\n\tif (ptr->layout.stream_structure & 1) {\n\t\tgf_bs_write_u8(bs, ptr->layout.definedLayout);\n\t\tif (ptr->layout.definedLayout==0) {\n\t\t\tu32 i;\n\t\t\tfor (i=0; i<ptr->layout.channels_count; i++) {\n\t\t\t\tgf_bs_write_u8(bs, ptr->layout.layouts[i].position);\n\t\t\t\tif (ptr->layout.layouts[i].position==126) {\n\t\t\t\t\tgf_bs_write_int(bs, ptr->layout.layouts[i].azimuth, 16);\n\t\t\t\t\tgf_bs_write_int(bs, ptr->layout.layouts[i].elevation, 8);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tgf_bs_write_u64(bs, ptr->layout.omittedChannelsMap);\n\t\t}\n\t}\n\tif (ptr->layout.stream_structure & 2) {\n\t\tgf_bs_write_u8(bs, ptr->layout.object_count);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":459141,"func":"static int tc_chain_fill_node(const struct tcf_proto_ops *tmplt_ops,\n\t\t\t      void *tmplt_priv, u32 chain_index,\n\t\t\t      struct net *net, struct sk_buff *skb,\n\t\t\t      struct tcf_block *block,\n\t\t\t      u32 portid, u32 seq, u16 flags, int event)\n{\n\tunsigned char *b = skb_tail_pointer(skb);\n\tconst struct tcf_proto_ops *ops;\n\tstruct nlmsghdr *nlh;\n\tstruct tcmsg *tcm;\n\tvoid *priv;\n\n\tops = tmplt_ops;\n\tpriv = tmplt_priv;\n\n\tnlh = nlmsg_put(skb, portid, seq, event, sizeof(*tcm), flags);\n\tif (!nlh)\n\t\tgoto out_nlmsg_trim;\n\ttcm = nlmsg_data(nlh);\n\ttcm->tcm_family = AF_UNSPEC;\n\ttcm->tcm__pad1 = 0;\n\ttcm->tcm__pad2 = 0;\n\ttcm->tcm_handle = 0;\n\tif (block->q) {\n\t\ttcm->tcm_ifindex = qdisc_dev(block->q)->ifindex;\n\t\ttcm->tcm_parent = block->q->handle;\n\t} else {\n\t\ttcm->tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK;\n\t\ttcm->tcm_block_index = block->index;\n\t}\n\n\tif (nla_put_u32(skb, TCA_CHAIN, chain_index))\n\t\tgoto nla_put_failure;\n\n\tif (ops) {\n\t\tif (nla_put_string(skb, TCA_KIND, ops->kind))\n\t\t\tgoto nla_put_failure;\n\t\tif (ops->tmplt_dump(skb, net, priv) < 0)\n\t\t\tgoto nla_put_failure;\n\t}\n\n\tnlh->nlmsg_len = skb_tail_pointer(skb) - b;\n\treturn skb->len;\n\nout_nlmsg_trim:\nnla_put_failure:\n\tnlmsg_trim(skb, b);\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":411,"total_token_length":647,"max_tokens_setting":1024}
+{"idx":492683,"func":"vte_sequence_handler_al (VteTerminal *terminal, GValueArray *params)\n{\n\tVteScreen *screen;\n\tlong start, end, param, i;\n\tGValue *value;\n\n\t\/* Find out which part of the screen we're messing with. *\/\n\tscreen = terminal->pvt->screen;\n\tstart = screen->cursor_current.row;\n\tif (screen->scrolling_restricted) {\n\t\tend = screen->insert_delta + screen->scrolling_region.end;\n\t} else {\n\t\tend = screen->insert_delta + terminal->row_count - 1;\n\t}\n\n\t\/* Extract any parameters. *\/\n\tparam = 1;\n\tif ((params != NULL) && (params->n_values > 0)) {\n\t\tvalue = g_value_array_get_nth(params, 0);\n\t\tif (G_VALUE_HOLDS_LONG(value)) {\n\t\t\tparam = g_value_get_long(value);\n\t\t}\n\t}\n\n\t\/* Insert the right number of lines. *\/\n\tfor (i = 0; i < param; i++) {\n\t\t\/* Clear a line off the end of the region and add one to the\n\t\t * top of the region. *\/\n\t\t_vte_terminal_ring_remove (terminal, end);\n\t\t_vte_terminal_ring_insert (terminal, start, TRUE);\n\t\t\/* Adjust the scrollbars if necessary. *\/\n\t\t_vte_terminal_adjust_adjustments(terminal);\n\t}\n\n\t\/* Update the display. *\/\n\t_vte_terminal_scroll_region(terminal, start, end - start + 1, param);\n\n\t\/* We've modified the display.  Make a note of it. *\/\n\tterminal->pvt->text_deleted_flag = TRUE;\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":413336,"func":"PHP_METHOD(snmp, setSecurity)\n{\n\tphp_snmp_object *snmp_object;\n\tzval *object = getThis();\n\tchar *a1 = \"\", *a2 = \"\", *a3 = \"\", *a4 = \"\", *a5 = \"\", *a6 = \"\", *a7 = \"\";\n\tint a1_len = 0, a2_len = 0, a3_len = 0, a4_len = 0, a5_len = 0, a6_len = 0, a7_len = 0;\n\tint argc = ZEND_NUM_ARGS();\n\n\tsnmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC);\n\n\tif (zend_parse_parameters(argc TSRMLS_CC, \"s|ssssss\", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,\n\t\t&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (netsnmp_session_set_security(snmp_object->session, a1, a2, a3, a4, a5, a6, a7 TSRMLS_CC)) {\n\t\t\/* Warning message sent already, just bail out *\/\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_TRUE;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":264413,"func":"struct Cookie *Curl_cookie_getlist(struct Curl_easy *data,\n                                   struct CookieInfo *c,\n                                   const char *host, const char *path,\n                                   bool secure)\n{\n  struct Cookie *newco;\n  struct Cookie *co;\n  struct Cookie *mainco = NULL;\n  size_t matches = 0;\n  bool is_ip;\n  const size_t myhash = cookiehash(host);\n\n  if(!c || !c->cookies[myhash])\n    return NULL; \/* no cookie struct or no cookies in the struct *\/\n\n  \/* at first, remove expired cookies *\/\n  remove_expired(c);\n\n  \/* check if host is an IP(v4|v6) address *\/\n  is_ip = Curl_host_is_ipnum(host);\n\n  co = c->cookies[myhash];\n\n  while(co) {\n    \/* if the cookie requires we're secure we must only continue if we are! *\/\n    if(co->secure?secure:TRUE) {\n\n      \/* now check if the domain is correct *\/\n      if(!co->domain ||\n         (co->tailmatch && !is_ip && tailmatch(co->domain, host)) ||\n         ((!co->tailmatch || is_ip) && strcasecompare(host, co->domain)) ) {\n        \/*\n         * the right part of the host matches the domain stuff in the\n         * cookie data\n         *\/\n\n        \/*\n         * now check the left part of the path with the cookies path\n         * requirement\n         *\/\n        if(!co->spath || pathmatch(co->spath, path) ) {\n\n          \/*\n           * and now, we know this is a match and we should create an\n           * entry for the return-linked-list\n           *\/\n\n          newco = dup_cookie(co);\n          if(newco) {\n            \/* then modify our next *\/\n            newco->next = mainco;\n\n            \/* point the main to us *\/\n            mainco = newco;\n\n            matches++;\n            if(matches >= MAX_COOKIE_SEND_AMOUNT) {\n              infof(data, \"Included max number of cookies (%zu) in request!\",\n                    matches);\n              break;\n            }\n          }\n          else\n            goto fail;\n        }\n      }\n    }\n    co = co->next;\n  }\n\n  if(matches) {\n    \/*\n     * Now we need to make sure that if there is a name appearing more than\n     * once, the longest specified path version comes first. To make this\n     * the swiftest way, we just sort them all based on path length.\n     *\/\n    struct Cookie **array;\n    size_t i;\n\n    \/* alloc an array and store all cookie pointers *\/\n    array = malloc(sizeof(struct Cookie *) * matches);\n    if(!array)\n      goto fail;\n\n    co = mainco;\n\n    for(i = 0; co; co = co->next)\n      array[i++] = co;\n\n    \/* now sort the cookie pointers in path length order *\/\n    qsort(array, matches, sizeof(struct Cookie *), cookie_sort);\n\n    \/* remake the linked list order according to the new order *\/\n\n    mainco = array[0]; \/* start here *\/\n    for(i = 0; i<matches-1; i++)\n      array[i]->next = array[i + 1];\n    array[matches-1]->next = NULL; \/* terminate the list *\/\n\n    free(array); \/* remove the temporary data again *\/\n  }\n\n  return mainco; \/* return the new list *\/\n\nfail:\n  \/* failure, clear up the allocated chain and return NULL *\/\n  Curl_cookie_freelist(mainco);\n  return NULL;\n}","target":0,"code_token_length":734,"total_token_length":970,"max_tokens_setting":1024}
+{"idx":234835,"func":"static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)\n{\n\tstruct btrfs_fs_devices *fs_devices;\n\tstruct btrfs_device *device;\n\tstruct btrfs_device *orig_dev;\n\tint ret = 0;\n\n\tfs_devices = alloc_fs_devices(orig->fsid, NULL);\n\tif (IS_ERR(fs_devices))\n\t\treturn fs_devices;\n\n\tmutex_lock(&orig->device_list_mutex);\n\tfs_devices->total_devices = orig->total_devices;\n\n\tlist_for_each_entry(orig_dev, &orig->devices, dev_list) {\n\t\tstruct rcu_string *name;\n\n\t\tdevice = btrfs_alloc_device(NULL, &orig_dev->devid,\n\t\t\t\t\t    orig_dev->uuid);\n\t\tif (IS_ERR(device)) {\n\t\t\tret = PTR_ERR(device);\n\t\t\tgoto error;\n\t\t}\n\n\t\t\/*\n\t\t * This is ok to do without rcu read locked because we hold the\n\t\t * uuid mutex so nothing we touch in here is going to disappear.\n\t\t *\/\n\t\tif (orig_dev->name) {\n\t\t\tname = rcu_string_strdup(orig_dev->name->str,\n\t\t\t\t\tGFP_KERNEL);\n\t\t\tif (!name) {\n\t\t\t\tbtrfs_free_device(device);\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t\trcu_assign_pointer(device->name, name);\n\t\t}\n\n\t\tlist_add(&device->dev_list, &fs_devices->devices);\n\t\tdevice->fs_devices = fs_devices;\n\t\tfs_devices->num_devices++;\n\t}\n\tmutex_unlock(&orig->device_list_mutex);\n\treturn fs_devices;\nerror:\n\tmutex_unlock(&orig->device_list_mutex);\n\tfree_fs_devices(fs_devices);\n\treturn ERR_PTR(ret);\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":329918,"func":"composite_tristrip (void\t\t\t*_dst,\n\t\t    cairo_operator_t\top,\n\t\t    cairo_surface_t\t*abstract_src,\n\t\t    int\t\t\tsrc_x,\n\t\t    int\t\t\tsrc_y,\n\t\t    int\t\t\tdst_x,\n\t\t    int\t\t\tdst_y,\n\t\t    const cairo_rectangle_int_t *extents,\n\t\t    cairo_antialias_t\tantialias,\n\t\t    cairo_tristrip_t\t*strip)\n{\n    cairo_image_surface_t *dst = (cairo_image_surface_t *) _dst;\n    cairo_image_source_t *src = (cairo_image_source_t *) abstract_src;\n    pixman_image_t *mask;\n    pixman_format_code_t format;\n\n    TRACE ((stderr, \"%s\\n\", __FUNCTION__));\n\n    if (strip->num_points < 3)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (1) { \/* pixman doesn't eliminate self-intersecting triangles\/edges *\/\n\t    cairo_int_status_t status;\n\t    cairo_traps_t traps;\n\t    int n;\n\n\t    _cairo_traps_init (&traps);\n\t    for (n = 0; n < strip->num_points; n++) {\n\t\t    cairo_point_t p[4];\n\n\t\t    p[0] = strip->points[0];\n\t\t    p[1] = strip->points[1];\n\t\t    p[2] = strip->points[2];\n\t\t    p[3] = strip->points[0];\n\n\t\t    _cairo_traps_tessellate_convex_quad (&traps, p);\n\t    }\n\t    status = composite_traps (_dst, op, abstract_src,\n\t\t\t\t      src_x, src_y,\n\t\t\t\t      dst_x, dst_y,\n\t\t\t\t      extents, antialias, &traps);\n\t    _cairo_traps_fini (&traps);\n\n\t    return status;\n    }\n\n    format = antialias == CAIRO_ANTIALIAS_NONE ? PIXMAN_a1 : PIXMAN_a8;\n    if (dst->pixman_format == format &&\n\t(abstract_src == NULL ||\n\t (op == CAIRO_OPERATOR_ADD && src->is_opaque_solid)))\n    {\n\t_pixman_image_add_tristrip (dst->pixman_image, dst_x, dst_y, strip);\n\treturn CAIRO_STATUS_SUCCESS;\n    }\n\n    mask = pixman_image_create_bits (format,\n\t\t\t\t     extents->width, extents->height,\n\t\t\t\t     NULL, 0);\n    if (unlikely (mask == NULL))\n\treturn _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n    _pixman_image_add_tristrip (mask, extents->x, extents->y, strip);\n    pixman_image_composite32 (_pixman_operator (op),\n                              src->pixman_image, mask, dst->pixman_image,\n                              extents->x + src_x, extents->y + src_y,\n                              0, 0,\n                              extents->x - dst_x, extents->y - dst_y,\n                              extents->width, extents->height);\n\n    pixman_image_unref (mask);\n\n    return  CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":201006,"func":"static int FNAME(cmpxchg_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,\n\t\t\t       pt_element_t __user *ptep_user, unsigned index,\n\t\t\t       pt_element_t orig_pte, pt_element_t new_pte)\n{\n\tint npages;\n\tpt_element_t ret;\n\tpt_element_t *table;\n\tstruct page *page;\n\n\tnpages = get_user_pages_fast((unsigned long)ptep_user, 1, FOLL_WRITE, &page);\n\tif (likely(npages == 1)) {\n\t\ttable = kmap_atomic(page);\n\t\tret = CMPXCHG(&table[index], orig_pte, new_pte);\n\t\tkunmap_atomic(table);\n\n\t\tkvm_release_page_dirty(page);\n\t} else {\n\t\tstruct vm_area_struct *vma;\n\t\tunsigned long vaddr = (unsigned long)ptep_user & PAGE_MASK;\n\t\tunsigned long pfn;\n\t\tunsigned long paddr;\n\n\t\tmmap_read_lock(current->mm);\n\t\tvma = find_vma_intersection(current->mm, vaddr, vaddr + PAGE_SIZE);\n\t\tif (!vma || !(vma->vm_flags & VM_PFNMAP)) {\n\t\t\tmmap_read_unlock(current->mm);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\tpfn = ((vaddr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;\n\t\tpaddr = pfn << PAGE_SHIFT;\n\t\ttable = memremap(paddr, PAGE_SIZE, MEMREMAP_WB);\n\t\tif (!table) {\n\t\t\tmmap_read_unlock(current->mm);\n\t\t\treturn -EFAULT;\n\t\t}\n\t\tret = CMPXCHG(&table[index], orig_pte, new_pte);\n\t\tmemunmap(table);\n\t\tmmap_read_unlock(current->mm);\n\t}\n\n\treturn (ret != orig_pte);\n}","target":1,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":400718,"func":"ssize_t __import_iovec(int type, const struct iovec __user *uvec,\n\t\t unsigned nr_segs, unsigned fast_segs, struct iovec **iovp,\n\t\t struct iov_iter *i, bool compat)\n{\n\tssize_t total_len = 0;\n\tunsigned long seg;\n\tstruct iovec *iov;\n\n\tiov = iovec_from_user(uvec, nr_segs, fast_segs, *iovp, compat);\n\tif (IS_ERR(iov)) {\n\t\t*iovp = NULL;\n\t\treturn PTR_ERR(iov);\n\t}\n\n\t\/*\n\t * According to the Single Unix Specification we should return EINVAL if\n\t * an element length is < 0 when cast to ssize_t or if the total length\n\t * would overflow the ssize_t return value of the system call.\n\t *\n\t * Linux caps all read\/write calls to MAX_RW_COUNT, and avoids the\n\t * overflow case.\n\t *\/\n\tfor (seg = 0; seg < nr_segs; seg++) {\n\t\tssize_t len = (ssize_t)iov[seg].iov_len;\n\n\t\tif (!access_ok(iov[seg].iov_base, len)) {\n\t\t\tif (iov != *iovp)\n\t\t\t\tkfree(iov);\n\t\t\t*iovp = NULL;\n\t\t\treturn -EFAULT;\n\t\t}\n\n\t\tif (len > MAX_RW_COUNT - total_len) {\n\t\t\tlen = MAX_RW_COUNT - total_len;\n\t\t\tiov[seg].iov_len = len;\n\t\t}\n\t\ttotal_len += len;\n\t}\n\n\tiov_iter_init(i, type, iov, nr_segs, total_len);\n\tif (iov == *iovp)\n\t\t*iovp = NULL;\n\telse\n\t\t*iovp = iov;\n\treturn total_len;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":259298,"func":"static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n#define DDTS_SIZE 20\n    uint8_t buf[DDTS_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];\n    AVStream *st = NULL;\n    uint32_t frame_duration_code = 0;\n    uint32_t channel_layout_code = 0;\n    GetBitContext gb;\n    int ret;\n\n    if ((ret = ffio_read_size(pb, buf, DDTS_SIZE)) < 0)\n        return ret;\n\n    init_get_bits(&gb, buf, 8 * DDTS_SIZE);\n\n    if (c->fc->nb_streams < 1) {\n        return 0;\n    }\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    st->codecpar->sample_rate = get_bits_long(&gb, 32);\n    if (st->codecpar->sample_rate <= 0) {\n        av_log(c->fc, AV_LOG_ERROR, \"Invalid sample rate %d\\n\", st->codecpar->sample_rate);\n        return AVERROR_INVALIDDATA;\n    }\n    skip_bits_long(&gb, 32); \/* max bitrate *\/\n    st->codecpar->bit_rate = get_bits_long(&gb, 32);\n    st->codecpar->bits_per_coded_sample = get_bits(&gb, 8);\n    frame_duration_code = get_bits(&gb, 2);\n    skip_bits(&gb, 30); \/* various fields *\/\n    channel_layout_code = get_bits(&gb, 16);\n\n    st->codecpar->frame_size =\n            (frame_duration_code == 0) ? 512 :\n            (frame_duration_code == 1) ? 1024 :\n            (frame_duration_code == 2) ? 2048 :\n            (frame_duration_code == 3) ? 4096 : 0;\n\n    if (channel_layout_code > 0xff) {\n        av_log(c->fc, AV_LOG_WARNING, \"Unsupported DTS audio channel layout\\n\");\n    }\n    av_channel_layout_uninit(&st->codecpar->ch_layout);\n    av_channel_layout_from_mask(&st->codecpar->ch_layout,\n            ((channel_layout_code & 0x1) ? AV_CH_FRONT_CENTER : 0) |\n            ((channel_layout_code & 0x2) ? AV_CH_FRONT_LEFT : 0) |\n            ((channel_layout_code & 0x2) ? AV_CH_FRONT_RIGHT : 0) |\n            ((channel_layout_code & 0x4) ? AV_CH_SIDE_LEFT : 0) |\n            ((channel_layout_code & 0x4) ? AV_CH_SIDE_RIGHT : 0) |\n            ((channel_layout_code & 0x8) ? AV_CH_LOW_FREQUENCY : 0));\n\n    return 0;\n}","target":0,"code_token_length":603,"total_token_length":839,"max_tokens_setting":1024}
+{"idx":254022,"func":"static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);\n\tint devnr = ((struct v4l2loopback_private *)video_get_drvdata(dev->vdev))->devicenr;\n        __u32 capabilities = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;\n\n\tstrlcpy(cap->driver, \"v4l2 loopback\", sizeof(cap->driver));\n\tvidioc_fill_name(cap->card, sizeof(cap->card), devnr);\n\tsnprintf(cap->bus_info, sizeof(cap->bus_info), \"platform:v4l2loopback-%03d\", devnr);\n\n#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)\n\t\/* since 3.1.0, the v4l2-core system is supposed to set the version *\/\n\tcap->version = V4L2LOOPBACK_VERSION_CODE;\n#endif\n\n#ifdef V4L2_CAP_VIDEO_M2M\n\tcapabilities |= V4L2_CAP_VIDEO_M2M;\n#endif \/* V4L2_CAP_VIDEO_M2M *\/\n\n\tif (dev->announce_all_caps) {\n\t\tcapabilities |= V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT;\n\t} else {\n\n\t\tif (dev->ready_for_capture) {\n\t\t\tcapabilities |= V4L2_CAP_VIDEO_CAPTURE;\n\t\t}\n\t\tif (dev->ready_for_output) {\n\t\t\tcapabilities |= V4L2_CAP_VIDEO_OUTPUT;\n\t\t}\n\t}\n\n\tdev->vdev->device_caps = cap->device_caps = cap->capabilities = capabilities;\n\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)\n\tcap->capabilities |= V4L2_CAP_DEVICE_CAPS;\n#endif\n\n\tmemset(cap->reserved, 0, sizeof(cap->reserved));\n\treturn 0;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":225982,"func":"\nGF_Err chnl_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s;\n\n\tISOM_DECREASE_SIZE(s, 1)\n\tptr->layout.stream_structure = gf_bs_read_u8(bs);\n\tif (ptr->layout.stream_structure & 1) {\n\t\tISOM_DECREASE_SIZE(s, 1)\n\t\tptr->layout.definedLayout = gf_bs_read_u8(bs);\n\t\tif (ptr->layout.definedLayout) {\n\t\t\tu32 remain = (u32) ptr->size;\n\t\t\tif (ptr->layout.stream_structure & 2) remain--;\n\t\t\tptr->layout.channels_count = 0;\n\t\t\twhile (remain) {\n\t\t\t\tISOM_DECREASE_SIZE(s, 1)\n\t\t\t\tptr->layout.layouts[ptr->layout.channels_count].position = gf_bs_read_u8(bs);\n\t\t\t\tremain--;\n\t\t\t\tif (ptr->layout.layouts[ptr->layout.channels_count].position == 126) {\n\t\t\t\t\tISOM_DECREASE_SIZE(s, 3)\n\t\t\t\t\tptr->layout.layouts[ptr->layout.channels_count].azimuth = gf_bs_read_int(bs, 16);\n\t\t\t\t\tptr->layout.layouts[ptr->layout.channels_count].elevation = gf_bs_read_int(bs, 8);\n\t\t\t\t\tremain-=3;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(s, 8)\n\t\t\tptr->layout.omittedChannelsMap = gf_bs_read_u64(bs);\n\t\t}\n\t}\n\tif (ptr->layout.stream_structure & 2) {\n\t\tISOM_DECREASE_SIZE(s, 1)\n\t\tptr->layout.object_count = gf_bs_read_u8(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":432092,"func":"store_word(\n    spellinfo_T\t*spin,\n    char_u\t*word,\n    int\t\tflags,\t\t\/\/ extra flags, WF_BANNED\n    int\t\tregion,\t\t\/\/ supported region(s)\n    char_u\t*pfxlist,\t\/\/ list of prefix IDs or NULL\n    int\t\tneed_affix)\t\/\/ only store word with affix ID\n{\n    int\t\tlen = (int)STRLEN(word);\n    int\t\tct = captype(word, word + len);\n    char_u\tfoldword[MAXWLEN];\n    int\t\tres = OK;\n    char_u\t*p;\n\n    \/\/ Avoid adding illegal bytes to the word tree.\n    if (!valid_spell_word(word, word + len))\n\treturn FAIL;\n\n    (void)spell_casefold(curwin, word, len, foldword, MAXWLEN);\n    for (p = pfxlist; res == OK; ++p)\n    {\n\tif (!need_affix || (p != NULL && *p != NUL))\n\t    res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,\n\t\t\t\t\t\t  region, p == NULL ? 0 : *p);\n\tif (p == NULL || *p == NUL)\n\t    break;\n    }\n    ++spin->si_foldwcount;\n\n    if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP)))\n    {\n\tfor (p = pfxlist; res == OK; ++p)\n\t{\n\t    if (!need_affix || (p != NULL && *p != NUL))\n\t\tres = tree_add_word(spin, word, spin->si_keeproot, flags,\n\t\t\t\t\t\t  region, p == NULL ? 0 : *p);\n\t    if (p == NULL || *p == NUL)\n\t\tbreak;\n\t}\n\t++spin->si_keepwcount;\n    }\n    return res;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":309929,"func":"main(int argc, char *argv[])\n{\n    int ch;\n    int fg, bg;\n    double r;\n    double c;\n#if HAVE_USE_DEFAULT_COLORS\n    bool d_option = FALSE;\n#endif\n    int m_option = 2;\n    int r_option = 0;\n    int s_option = 1;\n    size_t need;\n    char *my_env;\n\n    while ((ch = getopt(argc, argv, \"T:dem:r:s:\")) != -1) {\n\tswitch (ch) {\n\tcase 'T':\n\t    need = 6 + strlen(optarg);\n\t    my_env = malloc(need);\n\t    _nc_SPRINTF(my_env, _nc_SLIMIT(need) \"TERM=%s\", optarg);\n\t    putenv(my_env);\n\t    break;\n#if HAVE_USE_DEFAULT_COLORS\n\tcase 'd':\n\t    d_option = TRUE;\n\t    break;\n#endif\n#if HAVE_USE_ENV\n\tcase 'e':\n\t    use_env(TRUE);\n\t    break;\n#endif\n\tcase 'm':\n\t    m_option = atoi(optarg);\n\t    break;\n\tcase 'r':\n\t    r_option = atoi(optarg);\n\t    break;\n\tcase 's':\n\t    s_option = atoi(optarg);\n\t    break;\n\tdefault:\n\t    usage();\n\t    break;\n\t}\n    }\n\n    srand((unsigned) time(0));\n\n    SetupAlarm(r_option);\n    InitAndCatch(initscr(), onsig);\n\n    if (has_colors()) {\n\tstart_color();\n#if HAVE_USE_DEFAULT_COLORS\n\tif (d_option)\n\t    use_default_colors();\n#endif\n\tfor (fg = 0; fg < COLORS; fg++) {\n\t    for (bg = 0; bg < COLORS; bg++) {\n\t\tint pair;\n\t\tif (interrupted) {\n\t\t    cleanup();\n\t\t    ExitProgram(EXIT_FAILURE);\n\t\t}\n\t\tpair = mypair(fg, bg);\n\t\tif (pair > 0)\n\t\t    init_pair((short) pair, (short) fg, (short) bg);\n\t    }\n\t}\n    }\n\n    r = (double) (LINES - (m_option * 2));\n    c = (double) (COLS - (m_option * 2));\n    started = time((time_t *) 0);\n\n    fg = COLOR_WHITE;\n    bg = COLOR_BLACK;\n    while (!interrupted) {\n\tint x = (int) (c * ranf()) + m_option;\n\tint y = (int) (r * ranf()) + m_option;\n\tint p = (ranf() > 0.9) ? '*' : ' ';\n\n\tmove(y, x);\n\tif (has_colors()) {\n\t    int z = (int) (ranf() * COLORS);\n\t    if (ranf() > 0.01) {\n\t\tset_colors(fg = z, bg);\n\t\tattron(COLOR_PAIR(mypair(fg, bg)));\n\t    } else {\n\t\tset_colors(fg, bg = z);\n\t\tif (s_option)\n\t\t    napms(s_option);\n\t    }\n\t} else {\n\t    if (ranf() <= 0.01) {\n\t\tif (ranf() > 0.6) {\n\t\t    attron(A_REVERSE);\n\t\t} else {\n\t\t    attroff(A_REVERSE);\n\t\t}\n\t\tif (s_option)\n\t\t    napms(s_option);\n\t    }\n\t}\n\tAddCh(p);\n\trefresh();\n\t++total_chars;\n    }\n    cleanup();\n    ExitProgram(EXIT_SUCCESS);\n}","target":0,"code_token_length":698,"total_token_length":934,"max_tokens_setting":1024}
+{"idx":513291,"func":"int join_init_read_record(JOIN_TAB *tab)\n{\n  \/* \n    Note: the query plan tree for the below operations is constructed in\n    save_agg_explain_data.\n  *\/\n  if (tab->distinct && tab->remove_duplicates())  \/\/ Remove duplicates.\n    return 1;\n  if (tab->filesort && tab->sort_table())     \/\/ Sort table.\n    return 1;\n\n  DBUG_EXECUTE_IF(\"kill_join_init_read_record\",\n                  tab->join->thd->set_killed(KILL_QUERY););\n  if (tab->select && tab->select->quick && tab->select->quick->reset())\n  {\n    \/* Ensures error status is propagated back to client *\/\n    report_error(tab->table,\n                 tab->join->thd->killed ? HA_ERR_QUERY_INTERRUPTED : HA_ERR_OUT_OF_MEM);\n    return 1;\n  }\n  \/* make sure we won't get ER_QUERY_INTERRUPTED from any code below *\/\n  DBUG_EXECUTE_IF(\"kill_join_init_read_record\",\n                  tab->join->thd->reset_killed(););\n  if (!tab->preread_init_done  && tab->preread_init())\n    return 1;\n  if (init_read_record(&tab->read_record, tab->join->thd, tab->table,\n                       tab->select, tab->filesort_result, 1,1, FALSE))\n    return 1;\n  return (*tab->read_record.read_record)(&tab->read_record);\n}","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":369403,"func":"static void tctx_task_work(struct callback_head *cb)\n{\n\tbool uring_locked = false;\n\tstruct io_ring_ctx *ctx = NULL;\n\tstruct io_uring_task *tctx = container_of(cb, struct io_uring_task,\n\t\t\t\t\t\t  task_work);\n\n\twhile (1) {\n\t\tstruct io_wq_work_node *node1, *node2;\n\n\t\tif (!tctx->task_list.first &&\n\t\t    !tctx->prior_task_list.first && uring_locked)\n\t\t\tio_submit_flush_completions(ctx);\n\n\t\tspin_lock_irq(&tctx->task_lock);\n\t\tnode1 = tctx->prior_task_list.first;\n\t\tnode2 = tctx->task_list.first;\n\t\tINIT_WQ_LIST(&tctx->task_list);\n\t\tINIT_WQ_LIST(&tctx->prior_task_list);\n\t\tif (!node2 && !node1)\n\t\t\ttctx->task_running = false;\n\t\tspin_unlock_irq(&tctx->task_lock);\n\t\tif (!node2 && !node1)\n\t\t\tbreak;\n\n\t\tif (node1)\n\t\t\thandle_prev_tw_list(node1, &ctx, &uring_locked);\n\n\t\tif (node2)\n\t\t\thandle_tw_list(node2, &ctx, &uring_locked);\n\t\tcond_resched();\n\t}\n\n\tctx_flush_and_put(ctx, &uring_locked);\n\n\t\/* relaxed read is enough as only the task itself sets ->in_idle *\/\n\tif (unlikely(atomic_read(&tctx->in_idle)))\n\t\tio_uring_drop_tctx_refs(current);\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":273058,"func":"linear_regression(double *m, double *b, double *r2, const double *x, const double *y, int n)\n{\n  double x_val;\n  double sum_x  = 0;\n  double sum_x2 = 0;\n  double sum_y  = 0;\n  double sum_y2 = 0;\n  double sum_xy = 0;\n  double denom;\n  int i;\n\n  for (i = 0; i < n; i++)\n    {\n      x_val   = x ? x[i] : (double)i;\n      sum_x  += x_val;\n      sum_x2 += x_val * x_val;\n      sum_y  += y[i];\n      sum_y2 += y[i] * y[i];\n      sum_xy += x_val * y[i];\n    }\n\n  denom = (n * sum_x2 - sum_x * sum_x);\n  if (denom == 0)\n    return -1;\n\n  *m = (n * sum_xy - sum_x * sum_y) \/ denom;\n  *b = (sum_y * sum_x2 - sum_x * sum_xy) \/ denom;\n  if (r2)\n    *r2 = (sum_xy - (sum_x * sum_y)\/n) * (sum_xy - (sum_x * sum_y)\/n) \/ ((sum_x2 - (sum_x * sum_x)\/n) * (sum_y2 - (sum_y * sum_y)\/n));\n\n  return 0;\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":391646,"func":"NTSTATUS get_relative_fid_filename(connection_struct *conn,\n\t\t\t\t   struct smb_request *req,\n\t\t\t\t   uint16_t root_dir_fid,\n\t\t\t\t   const struct smb_filename *smb_fname,\n\t\t\t\t   struct smb_filename **smb_fname_out)\n{\n\tfiles_struct *dir_fsp;\n\tchar *parent_fname = NULL;\n\tchar *new_base_name = NULL;\n\tNTSTATUS status;\n\n\tif (root_dir_fid == 0 || !smb_fname) {\n\t\tstatus = NT_STATUS_INTERNAL_ERROR;\n\t\tgoto out;\n\t}\n\n\tdir_fsp = file_fsp(req, root_dir_fid);\n\n\tif (dir_fsp == NULL) {\n\t\tstatus = NT_STATUS_INVALID_HANDLE;\n\t\tgoto out;\n\t}\n\n\tif (is_ntfs_stream_smb_fname(dir_fsp->fsp_name)) {\n\t\tstatus = NT_STATUS_INVALID_HANDLE;\n\t\tgoto out;\n\t}\n\n\tif (!dir_fsp->is_directory) {\n\n\t\t\/*\n\t\t * Check to see if this is a mac fork of some kind.\n\t\t *\/\n\n\t\tif ((conn->fs_capabilities & FILE_NAMED_STREAMS) &&\n\t\t    is_ntfs_stream_smb_fname(smb_fname)) {\n\t\t\tstatus = NT_STATUS_OBJECT_PATH_NOT_FOUND;\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/*\n\t\t  we need to handle the case when we get a\n\t\t  relative open relative to a file and the\n\t\t  pathname is blank - this is a reopen!\n\t\t  (hint from demyn plantenberg)\n\t\t*\/\n\n\t\tstatus = NT_STATUS_INVALID_HANDLE;\n\t\tgoto out;\n\t}\n\n\tif (ISDOT(dir_fsp->fsp_name->base_name)) {\n\t\t\/*\n\t\t * We're at the toplevel dir, the final file name\n\t\t * must not contain .\/, as this is filtered out\n\t\t * normally by srvstr_get_path and unix_convert\n\t\t * explicitly rejects paths containing .\/.\n\t\t *\/\n\t\tparent_fname = talloc_strdup(talloc_tos(), \"\");\n\t\tif (parent_fname == NULL) {\n\t\t\tstatus = NT_STATUS_NO_MEMORY;\n\t\t\tgoto out;\n\t\t}\n\t} else {\n\t\tsize_t dir_name_len = strlen(dir_fsp->fsp_name->base_name);\n\n\t\t\/*\n\t\t * Copy in the base directory name.\n\t\t *\/\n\n\t\tparent_fname = talloc_array(talloc_tos(), char,\n\t\t    dir_name_len+2);\n\t\tif (parent_fname == NULL) {\n\t\t\tstatus = NT_STATUS_NO_MEMORY;\n\t\t\tgoto out;\n\t\t}\n\t\tmemcpy(parent_fname, dir_fsp->fsp_name->base_name,\n\t\t    dir_name_len+1);\n\n\t\t\/*\n\t\t * Ensure it ends in a '\/'.\n\t\t * We used TALLOC_SIZE +2 to add space for the '\/'.\n\t\t *\/\n\n\t\tif(dir_name_len\n\t\t    && (parent_fname[dir_name_len-1] != '\\\\')\n\t\t    && (parent_fname[dir_name_len-1] != '\/')) {\n\t\t\tparent_fname[dir_name_len] = '\/';\n\t\t\tparent_fname[dir_name_len+1] = '\\0';\n\t\t}\n\t}\n\n\tnew_base_name = talloc_asprintf(talloc_tos(), \"%s%s\", parent_fname,\n\t\t\t\t\tsmb_fname->base_name);\n\tif (new_base_name == NULL) {\n\t\tstatus = NT_STATUS_NO_MEMORY;\n\t\tgoto out;\n\t}\n\n\tstatus = filename_convert(req,\n\t\t\t\tconn,\n\t\t\t\treq->flags2 & FLAGS2_DFS_PATHNAMES,\n\t\t\t\tnew_base_name,\n\t\t\t\t0,\n\t\t\t\tNULL,\n\t\t\t\tsmb_fname_out);\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\tgoto out;\n\t}\n\n out:\n\tTALLOC_FREE(parent_fname);\n\tTALLOC_FREE(new_base_name);\n\treturn status;\n}","target":0,"code_token_length":731,"total_token_length":967,"max_tokens_setting":1024}
+{"idx":244307,"func":"GF_Err fpar_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tFilePartitionBox *ptr = (FilePartitionBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_int(bs, ptr->itemID, ptr->version ? 32 : 16);\n\tgf_bs_write_u16(bs, ptr->packet_payload_size);\n\tgf_bs_write_u8(bs, 0);\n\tgf_bs_write_u8(bs, ptr->FEC_encoding_ID);\n\tgf_bs_write_u16(bs, ptr->FEC_instance_ID);\n\tgf_bs_write_u16(bs, ptr->max_source_block_length);\n\tgf_bs_write_u16(bs, ptr->encoding_symbol_length);\n\tgf_bs_write_u16(bs, ptr->max_number_of_encoding_symbols);\n\tif (ptr->scheme_specific_info) {\n\t\tgf_bs_write_data(bs, ptr->scheme_specific_info, (u32)strlen(ptr->scheme_specific_info) );\n\t}\n\t\/\/null terminated string\n\tgf_bs_write_u8(bs, 0);\n\n\tgf_bs_write_int(bs, ptr->nb_entries, ptr->version ? 32 : 16);\n\n\tfor (i=0;i < ptr->nb_entries; i++) {\n\t\tgf_bs_write_u16(bs, ptr->entries[i].block_count);\n\t\tgf_bs_write_u32(bs, ptr->entries[i].block_size);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":424980,"func":"void iwl_pcie_dump_csr(struct iwl_trans *trans)\n{\n\tint i;\n\tstatic const u32 csr_tbl[] = {\n\t\tCSR_HW_IF_CONFIG_REG,\n\t\tCSR_INT_COALESCING,\n\t\tCSR_INT,\n\t\tCSR_INT_MASK,\n\t\tCSR_FH_INT_STATUS,\n\t\tCSR_GPIO_IN,\n\t\tCSR_RESET,\n\t\tCSR_GP_CNTRL,\n\t\tCSR_HW_REV,\n\t\tCSR_EEPROM_REG,\n\t\tCSR_EEPROM_GP,\n\t\tCSR_OTP_GP_REG,\n\t\tCSR_GIO_REG,\n\t\tCSR_GP_UCODE_REG,\n\t\tCSR_GP_DRIVER_REG,\n\t\tCSR_UCODE_DRV_GP1,\n\t\tCSR_UCODE_DRV_GP2,\n\t\tCSR_LED_REG,\n\t\tCSR_DRAM_INT_TBL_REG,\n\t\tCSR_GIO_CHICKEN_BITS,\n\t\tCSR_ANA_PLL_CFG,\n\t\tCSR_MONITOR_STATUS_REG,\n\t\tCSR_HW_REV_WA_REG,\n\t\tCSR_DBG_HPET_MEM_REG\n\t};\n\tIWL_ERR(trans, \"CSR values:\\n\");\n\tIWL_ERR(trans, \"(2nd byte of CSR_INT_COALESCING is \"\n\t\t\"CSR_INT_PERIODIC_REG)\\n\");\n\tfor (i = 0; i <  ARRAY_SIZE(csr_tbl); i++) {\n\t\tIWL_ERR(trans, \"  %25s: 0X%08x\\n\",\n\t\t\tget_csr_string(csr_tbl[i]),\n\t\t\tiwl_read32(trans, csr_tbl[i]));\n\t}\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":252383,"func":"static MZ_FORCEINLINE void tdefl_find_match(\n    tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist,\n    mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) {\n  mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK,\n                match_len = *pMatch_len, probe_pos = pos, next_probe_pos,\n                probe_len;\n  mz_uint num_probes_left = d->m_max_probes[match_len >= 32];\n  const mz_uint8 *s = d->m_dict + pos, *p, *q;\n  mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1];\n  MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN);\n  if (max_match_len <= match_len) return;\n  for (;;) {\n    for (;;) {\n      if (--num_probes_left == 0) return;\n#define TDEFL_PROBE                                                      \\\n  next_probe_pos = d->m_next[probe_pos];                                 \\\n  if ((!next_probe_pos) ||                                               \\\n      ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \\\n    return;                                                              \\\n  probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK;                  \\\n  if ((d->m_dict[probe_pos + match_len] == c0) &&                        \\\n      (d->m_dict[probe_pos + match_len - 1] == c1))                      \\\n    break;\n      TDEFL_PROBE;\n      TDEFL_PROBE;\n      TDEFL_PROBE;\n    }\n    if (!dist) break;\n    p = s;\n    q = d->m_dict + probe_pos;\n    for (probe_len = 0; probe_len < max_match_len; probe_len++)\n      if (*p++ != *q++) break;\n    if (probe_len > match_len) {\n      *pMatch_dist = dist;\n      if ((*pMatch_len = match_len = probe_len) == max_match_len) return;\n      c0 = d->m_dict[pos + match_len];\n      c1 = d->m_dict[pos + match_len - 1];\n    }\n  }\n}","target":0,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":198259,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Get the input Tensors.\n    OpInputList params_nested_splits_in;\n    OP_REQUIRES_OK(context, context->input_list(\"params_nested_splits\",\n                                                ¶ms_nested_splits_in));\n    const Tensor& params_dense_values_in =\n        context->input(params_nested_splits_in.size());\n    const Tensor& indices_in =\n        context->input(params_nested_splits_in.size() + 1);\n\n    DCHECK_GT(params_nested_splits_in.size(), 0);  \/\/ Enforced by REGISTER_OP.\n    SPLITS_TYPE num_params = params_nested_splits_in[0].dim_size(0) - 1;\n    OP_REQUIRES_OK(context, ValidateIndices(indices_in, num_params));\n\n    OP_REQUIRES(context, params_dense_values_in.dims() > 0,\n                errors::InvalidArgument(\"params.rank must be nonzero\"));\n    SPLITS_TYPE num_params_dense_values = params_dense_values_in.dim_size(0);\n\n    \/\/ Calculate the `splits`, and store the value slices that we need to\n    \/\/ copy in `value_slices`.\n    std::vector<std::pair<SPLITS_TYPE, SPLITS_TYPE>> value_slices;\n    SPLITS_TYPE num_values = 0;\n    std::vector<std::vector<SPLITS_TYPE>> out_splits;\n    OP_REQUIRES_OK(context, MakeSplits(indices_in, params_nested_splits_in,\n                                       num_params_dense_values, &out_splits,\n                                       &value_slices, &num_values));\n\n    \/\/ Write the output tensors.\n    OP_REQUIRES_OK(context, WriteSplits(out_splits, context));\n    OP_REQUIRES_OK(context,\n                   WriteValues(params_dense_values_in, value_slices,\n                               out_splits.size(), num_values, context));\n  }","target":1,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":455171,"func":"MOBI_RET mobi_parse_huff(MOBIHuffCdic *huffcdic, const MOBIPdbRecord *record) {\n    MOBIBuffer *buf = mobi_buffer_init_null(record->data, record->size);\n    if (buf == NULL) {\n        debug_print(\"%s\\n\", \"Memory allocation failed\");\n        return MOBI_MALLOC_FAILED;\n    }\n    char huff_magic[5];\n    mobi_buffer_getstring(huff_magic, buf, 4);\n    const size_t header_length = mobi_buffer_get32(buf);\n    if (strncmp(huff_magic, HUFF_MAGIC, 4) != 0 || header_length < HUFF_HEADER_LEN) {\n        debug_print(\"HUFF wrong magic: %s\\n\", huff_magic);\n        mobi_buffer_free_null(buf);\n        return MOBI_DATA_CORRUPT;\n    }\n    const size_t data1_offset = mobi_buffer_get32(buf);\n    const size_t data2_offset = mobi_buffer_get32(buf);\n    \/* skip little-endian table offsets *\/\n    mobi_buffer_setpos(buf, data1_offset);\n    if (buf->offset + (256 * 4) > buf->maxlen) {\n        debug_print(\"%s\", \"HUFF data1 too short\\n\");\n        mobi_buffer_free_null(buf);\n        return MOBI_DATA_CORRUPT;\n    }\n    \/* read 256 indices from data1 big-endian *\/\n    for (int i = 0; i < 256; i++) {\n        huffcdic->table1[i] = mobi_buffer_get32(buf);\n    }\n    mobi_buffer_setpos(buf, data2_offset);\n    if (buf->offset + (64 * 4) > buf->maxlen) {\n        debug_print(\"%s\", \"HUFF data2 too short\\n\");\n        mobi_buffer_free_null(buf);\n        return MOBI_DATA_CORRUPT;\n    }\n    \/* read 32 mincode-maxcode pairs from data2 big-endian *\/\n    huffcdic->mincode_table[0] = 0;\n    huffcdic->maxcode_table[0] = 0xFFFFFFFF;\n    for (int i = 1; i < HUFF_CODETABLE_SIZE; i++) {\n        const uint32_t mincode = mobi_buffer_get32(buf);\n        const uint32_t maxcode = mobi_buffer_get32(buf);\n        huffcdic->mincode_table[i] =  mincode << (32 - i);\n        huffcdic->maxcode_table[i] =  ((maxcode + 1) << (32 - i)) - 1;\n    }\n    mobi_buffer_free_null(buf);\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":589,"total_token_length":825,"max_tokens_setting":1024}
+{"idx":198703,"func":"int CLASS ljpeg_start (struct jhead *jh, int info_only)\n{\n  int c, tag, len;\n  uchar data[0x10000];\n  const uchar *dp;\n\n  memset (jh, 0, sizeof *jh);\n  jh->restart = INT_MAX;\n  fread (data, 2, 1, ifp);\n  if (data[1] != 0xd8) return 0;\n  do {\n    fread (data, 2, 2, ifp);\n    tag =  data[0] << 8 | data[1];\n    len = (data[2] << 8 | data[3]) - 2;\n    if (tag <= 0xff00) return 0;\n    fread (data, 1, len, ifp);\n    switch (tag) {\n      case 0xffc3:\n\tjh->sraw = ((data[7] >> 4) * (data[7] & 15) - 1) & 3;\n      case 0xffc0:\n\tjh->bits = data[0];\n\tjh->high = data[1] << 8 | data[2];\n\tjh->wide = data[3] << 8 | data[4];\n\tjh->clrs = data[5] + jh->sraw;\n\tif (len == 9 && !dng_version) getc(ifp);\n\tbreak;\n      case 0xffc4:\n\tif (info_only) break;\n\tfor (dp = data; dp < data+len && (c = *dp++) < 4; )\n\t  jh->free[c] = jh->huff[c] = make_decoder_ref (&dp);\n\tbreak;\n      case 0xffda:\n\tjh->psv = data[1+data[0]*2];\n\tjh->bits -= data[3+data[0]*2] & 15;\n\tbreak;\n      case 0xffdd:\n\tjh->restart = data[0] << 8 | data[1];\n    }\n  } while (tag != 0xffda);\n  if (info_only) return 1;\n  if (jh->clrs > 6 || !jh->huff[0]) return 0;\n  FORC(5) if (!jh->huff[c+1]) jh->huff[c+1] = jh->huff[c];\n  if (jh->sraw) {\n    FORC(4)        jh->huff[2+c] = jh->huff[1];\n    FORC(jh->sraw) jh->huff[1+c] = jh->huff[0];\n  }\n  jh->row = (ushort *) calloc (jh->wide*jh->clrs, 4);\n  merror (jh->row, \"ljpeg_start()\");\n  return zero_after_ff = 1;\n}","target":1,"code_token_length":629,"total_token_length":865,"max_tokens_setting":1024}
+{"idx":231685,"func":"TEST_P(QuicServerTransportAllowMigrationTest, IgnoreInvalidPathResponse) {\n  auto data = IOBuf::copyBuffer(\"bad data\");\n  auto packetData = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      2,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n\n  EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 0);\n\n  auto peerAddress = server->getConn().peerAddress;\n\n  folly::SocketAddress newPeer(\"100.101.102.103\", 23456);\n\n  deliverData(std::move(packetData), false, &newPeer);\n\n  EXPECT_TRUE(server->getConn().pendingEvents.pathChallenge);\n\n  EXPECT_TRUE(server->getConn().pathValidationLimiter != nullptr);\n  EXPECT_EQ(server->getConn().peerAddress, newPeer);\n  EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1);\n  EXPECT_EQ(\n      server->getConn().migrationState.previousPeerAddresses.back(),\n      peerAddress);\n\n  loopForWrites();\n  EXPECT_FALSE(server->getConn().pendingEvents.pathChallenge);\n  EXPECT_TRUE(server->getConn().outstandingPathValidation);\n  EXPECT_TRUE(server->getConn().pendingEvents.schedulePathValidationTimeout);\n  EXPECT_TRUE(server->pathValidationTimeout().isScheduled());\n\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  ASSERT_TRUE(builder.canBuildPacket());\n\n  writeSimpleFrame(\n      PathResponseFrame(\n          server->getConn().outstandingPathValidation->pathData ^ 1),\n      builder);\n  auto packet = std::move(builder).buildPacket();\n  deliverData(packetToBuf(packet), false, &newPeer);\n  EXPECT_TRUE(server->getConn().outstandingPathValidation);\n  EXPECT_TRUE(server->getConn().pendingEvents.schedulePathValidationTimeout);\n  EXPECT_TRUE(server->pathValidationTimeout().isScheduled());\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":413844,"func":"void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig,\n                                                  Klass* current_klass,\n                                                  Klass* sel_klass, TRAPS) {\n  Handle ref_loader(THREAD, current_klass->class_loader());\n  Handle sel_loader(THREAD, sel_klass->class_loader());\n\n  ResourceMark rm(THREAD);  \/\/ needed for check_signature_loaders\n  Symbol* failed_type_symbol =\n    SystemDictionary::check_signature_loaders(sig,\n                                              \/*klass_being_linked*\/ NULL, \/\/ We are not linking class\n                                              ref_loader, sel_loader,\n                                              false);\n  if (failed_type_symbol != NULL) {\n    stringStream ss;\n    const char* failed_type_name = failed_type_symbol->as_klass_external_name();\n\n    ss.print(\"loader constraint violation: when resolving field \\\"%s\\\" of type %s, \"\n             \"the class loader %s of the current class, %s, \"\n             \"and the class loader %s for the field's defining %s, %s, \"\n             \"have different Class objects for type %s (%s; %s)\",\n             field->as_C_string(),\n             failed_type_name,\n             current_klass->class_loader_data()->loader_name_and_id(),\n             current_klass->external_name(),\n             sel_klass->class_loader_data()->loader_name_and_id(),\n             sel_klass->external_kind(),\n             sel_klass->external_name(),\n             failed_type_name,\n             current_klass->class_in_module_of_loader(false, true),\n             sel_klass->class_in_module_of_loader(false, true));\n    THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());\n  }\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":267843,"func":"opfunc_call (vm_frame_ctx_t *frame_ctx_p) \/**< frame context *\/\n{\n  const uint8_t *byte_code_p = frame_ctx_p->byte_code_p + 1;\n  uint8_t opcode = byte_code_p[-1];\n  uint32_t arguments_list_len;\n\n  if (opcode >= CBC_CALL0)\n  {\n    arguments_list_len = (unsigned int) ((opcode - CBC_CALL0) \/ 6);\n  }\n  else\n  {\n    arguments_list_len = *byte_code_p++;\n  }\n\n  bool is_call_prop = ((opcode - CBC_CALL) % 6) >= 3;\n\n  ecma_value_t *stack_top_p = frame_ctx_p->stack_top_p - arguments_list_len;\n  ecma_value_t this_value = is_call_prop ? stack_top_p[-3] : ECMA_VALUE_UNDEFINED;\n  ecma_value_t func_value = stack_top_p[-1];\n  ecma_value_t completion_value;\n\n  if (!ecma_is_value_object (func_value)\n      || !ecma_op_object_is_callable (ecma_get_object_from_value (func_value)))\n  {\n    completion_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function));\n  }\n  else\n  {\n    ecma_object_t *func_obj_p = ecma_get_object_from_value (func_value);\n\n    completion_value = ecma_op_function_call (func_obj_p,\n                                              this_value,\n                                              stack_top_p,\n                                              arguments_list_len);\n  }\n\n  JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_DIRECT_EVAL;\n\n  \/* Free registers. *\/\n  for (uint32_t i = 0; i < arguments_list_len; i++)\n  {\n    ecma_fast_free_value (stack_top_p[i]);\n  }\n\n  if (is_call_prop)\n  {\n    ecma_free_value (*(--stack_top_p));\n    ecma_free_value (*(--stack_top_p));\n  }\n\n  if (JERRY_UNLIKELY (ECMA_IS_VALUE_ERROR (completion_value)))\n  {\n#if JERRY_DEBUGGER\n    JERRY_CONTEXT (debugger_exception_byte_code_p) = frame_ctx_p->byte_code_p;\n#endif \/* JERRY_DEBUGGER *\/\n    frame_ctx_p->byte_code_p = (uint8_t *) vm_error_byte_code_p;\n  }\n  else\n  {\n    frame_ctx_p->byte_code_p = byte_code_p;\n    ecma_free_value (*(--stack_top_p));\n    uint32_t opcode_data = vm_decode_table[opcode];\n\n    if (!(opcode_data & (VM_OC_PUT_STACK | VM_OC_PUT_BLOCK)))\n    {\n      ecma_fast_free_value (completion_value);\n    }\n    else if (opcode_data & VM_OC_PUT_STACK)\n    {\n      *stack_top_p++ = completion_value;\n    }\n    else\n    {\n      ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));\n      VM_GET_REGISTERS (frame_ctx_p)[0] = completion_value;\n    }\n  }\n\n  frame_ctx_p->stack_top_p = stack_top_p;\n} \/* opfunc_call *\/","target":0,"code_token_length":646,"total_token_length":882,"max_tokens_setting":1024}
+{"idx":502702,"func":"SSL_SESSION *SSL_SESSION_new(void)\n{\n    SSL_SESSION *ss;\n\n    ss = (SSL_SESSION *)OPENSSL_malloc(sizeof(SSL_SESSION));\n    if (ss == NULL) {\n        SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);\n        return (0);\n    }\n    memset(ss, 0, sizeof(SSL_SESSION));\n\n    ss->verify_result = 1;      \/* avoid 0 (= X509_V_OK) just in case *\/\n    ss->references = 1;\n    ss->timeout = 60 * 5 + 4;   \/* 5 minute timeout by default *\/\n    ss->time = (unsigned long)time(NULL);\n    ss->prev = NULL;\n    ss->next = NULL;\n    ss->compress_meth = 0;\n#ifndef OPENSSL_NO_TLSEXT\n    ss->tlsext_hostname = NULL;\n# ifndef OPENSSL_NO_EC\n    ss->tlsext_ecpointformatlist_length = 0;\n    ss->tlsext_ecpointformatlist = NULL;\n    ss->tlsext_ellipticcurvelist_length = 0;\n    ss->tlsext_ellipticcurvelist = NULL;\n# endif\n#endif\n    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);\n#ifndef OPENSSL_NO_PSK\n    ss->psk_identity_hint = NULL;\n    ss->psk_identity = NULL;\n#endif\n#ifndef OPENSSL_NO_SRP\n    ss->srp_username = NULL;\n#endif\n    return (ss);\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":255574,"func":"njs_module_path(njs_vm_t *vm, const njs_str_t *dir, njs_module_info_t *info)\n{\n    char        *p;\n    size_t      length;\n    njs_bool_t  trail;\n    char        src[NJS_MAX_PATH + 1];\n\n    trail = 0;\n    length = info->name.length;\n\n    if (dir != NULL) {\n        length += dir->length;\n\n        if (length == 0) {\n            return NJS_DECLINED;\n        }\n\n        trail = (dir->start[dir->length - 1] != '\/');\n\n        if (trail) {\n            length++;\n        }\n    }\n\n    if (njs_slow_path(length > NJS_MAX_PATH)) {\n        return NJS_ERROR;\n    }\n\n    p = &src[0];\n\n    if (dir != NULL) {\n        p = (char *) njs_cpymem(p, dir->start, dir->length);\n\n        if (trail) {\n            *p++ = '\/';\n        }\n    }\n\n    p = (char *) njs_cpymem(p, info->name.start, info->name.length);\n    *p = '\\0';\n\n    p = realpath(&src[0], &info->path[0]);\n    if (p == NULL) {\n        return NJS_DECLINED;\n    }\n\n    info->fd = open(&info->path[0], O_RDONLY);\n    if (info->fd < 0) {\n        return NJS_DECLINED;\n    }\n\n\n    info->file.start = (u_char *) &info->path[0];\n    info->file.length = njs_strlen(info->file.start);\n\n    return NJS_OK;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":389738,"func":"typval_compare_func(\n\ttypval_T    *tv1,\n\ttypval_T    *tv2,\n\texprtype_T  type,\n\tint\t    ic,\n\tint\t    *res)\n{\n    int\t    val = 0;\n\n    if (type != EXPR_EQUAL && type != EXPR_NEQUAL\n\t    && type != EXPR_IS && type != EXPR_ISNOT)\n    {\n\temsg(_(e_invalid_operation_for_funcrefs));\n\treturn FAIL;\n    }\n    if ((tv1->v_type == VAR_PARTIAL && tv1->vval.v_partial == NULL)\n\t    || (tv2->v_type == VAR_PARTIAL && tv2->vval.v_partial == NULL))\n\t\/\/ When both partials are NULL, then they are equal.\n\t\/\/ Otherwise they are not equal.\n\tval = (tv1->vval.v_partial == tv2->vval.v_partial);\n    else if (type == EXPR_IS || type == EXPR_ISNOT)\n    {\n\tif (tv1->v_type == VAR_FUNC && tv2->v_type == VAR_FUNC)\n\t    \/\/ strings are considered the same if their value is\n\t    \/\/ the same\n\t    val = tv_equal(tv1, tv2, ic, FALSE);\n\telse if (tv1->v_type == VAR_PARTIAL && tv2->v_type == VAR_PARTIAL)\n\t    val = (tv1->vval.v_partial == tv2->vval.v_partial);\n\telse\n\t    val = FALSE;\n    }\n    else\n\tval = tv_equal(tv1, tv2, ic, FALSE);\n    if (type == EXPR_NEQUAL || type == EXPR_ISNOT)\n\tval = !val;\n    *res = val;\n    return OK;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":329908,"func":"_inplace_spans (void *abstract_renderer,\n\t\tint y, int h,\n\t\tconst cairo_half_open_span_t *spans,\n\t\tunsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n    uint8_t *mask;\n    int x0, x1;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (num_spans == 2 && spans[0].coverage == 0xff) {\n\tpixman_image_composite32 (r->op, r->src, NULL, r->u.composite.dst,\n\t\t\t\t  spans[0].x + r->u.composite.src_x,\n\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  spans[0].x, y,\n\t\t\t\t  spans[1].x - spans[0].x, h);\n\treturn CAIRO_STATUS_SUCCESS;\n    }\n\n    mask = (uint8_t *)pixman_image_get_data (r->mask);\n    x1 = x0 = spans[0].x;\n    do {\n\tint len = spans[1].x - spans[0].x;\n\t*mask++ = spans[0].coverage;\n\tif (len > 1) {\n\t    if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {\n\t\tif (x1 != x0) {\n\t\t    pixman_image_composite32 (r->op, r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t      x0 + r->u.composite.src_x,\n\t\t\t\t\t      y + r->u.composite.src_y,\n\t\t\t\t\t      0, 0,\n\t\t\t\t\t      x0, y,\n\t\t\t\t\t      x1 - x0, h);\n\t\t}\n\t\tpixman_image_composite32 (r->op, r->src, NULL, r->u.composite.dst,\n\t\t\t\t\t  spans[0].x + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  spans[0].x, y,\n\t\t\t\t\t  len, h);\n\t\tmask = (uint8_t *)pixman_image_get_data (r->mask);\n\t\tx0 = spans[1].x;\n\t    } else if (spans[0].coverage == 0x0 &&\n\t\t       x1 - x0 > r->u.composite.run_length) {\n\t\tpixman_image_composite32 (r->op, r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  x1 - x0, h);\n\t\tmask = (uint8_t *)pixman_image_get_data (r->mask);\n\t\tx0 = spans[1].x;\n\t    }else {\n\t\tmemset (mask, spans[0].coverage, --len);\n\t\tmask += len;\n\t    }\n\t}\n\tx1 = spans[1].x;\n\tspans++;\n    } while (--num_spans > 1);\n\n    if (x1 != x0) {\n\tpixman_image_composite32 (r->op, r->src, r->mask, r->u.composite.dst,\n\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  x1 - x0, h);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":248258,"func":"static cfg_opt_t *cfg_getopt_array(cfg_opt_t *rootopts, int cfg_flags, const char *name)\n{\n\tunsigned int i;\n\tcfg_opt_t *opts = rootopts;\n\n\tif (!rootopts || !name) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\twhile (name && *name) {\n\t\tcfg_t *seccfg;\n\t\tchar *secname;\n\t\tsize_t len = strcspn(name, \"|\");\n\n\t\tif (name[len] == 0 \/*len == strlen(name) *\/ )\n\t\t\t\/* no more subsections *\/\n\t\t\tbreak;\n\n\t\tif (len) {\n\t\t\tcfg_opt_t *secopt;\n\n\t\t\tsecname = strndup(name, len);\n\t\t\tif (!secname)\n\t\t\t\treturn NULL;\n\n\t\t\tsecopt = cfg_getopt_array(opts, cfg_flags, secname);\n\t\t\tfree(secname);\n\t\t\tif (!secopt) {\n\t\t\t\t\/*fprintf(stderr, \"section not found\\n\"); *\/\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (secopt->type != CFGT_SEC) {\n\t\t\t\t\/*fprintf(stderr, \"not a section!\\n\"); *\/\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tif (!is_set(CFGF_MULTI, secopt->flags) && (seccfg = cfg_opt_getnsec(secopt, 0)) != NULL)\n\t\t\t\topts = seccfg->opts;\n\t\t\telse\n\t\t\t\topts = secopt->subopts;\n\n\t\t\tif (!opts) {\n\t\t\t\t\/*fprintf(stderr, \"section have no subopts!?\\n\"); *\/\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tname += len;\n\t\tname += strspn(name, \"|\");\n\t}\n\n\tfor (i = 0; opts[i].name; i++) {\n\t\tif (is_set(CFGF_NOCASE, cfg_flags)) {\n\t\t\tif (strcasecmp(opts[i].name, name) == 0)\n\t\t\t\treturn &opts[i];\n\t\t} else {\n\t\t\tif (strcmp(opts[i].name, name) == 0)\n\t\t\t\treturn &opts[i];\n\t\t}\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":444,"total_token_length":680,"max_tokens_setting":1024}
+{"idx":443151,"func":"int jfs_commit_inode(struct inode *inode, int wait)\n{\n\tint rc = 0;\n\ttid_t tid;\n\tstatic int noisy = 5;\n\n\tjfs_info(\"In jfs_commit_inode, inode = 0x%p\", inode);\n\n\t\/*\n\t * Don't commit if inode has been committed since last being\n\t * marked dirty, or if it has been deleted.\n\t *\/\n\tif (inode->i_nlink == 0 || !test_cflag(COMMIT_Dirty, inode))\n\t\treturn 0;\n\n\tif (isReadOnly(inode)) {\n\t\t\/* kernel allows writes to devices on read-only\n\t\t * partitions and may think inode is dirty\n\t\t *\/\n\t\tif (!special_file(inode->i_mode) && noisy) {\n\t\t\tjfs_err(\"jfs_commit_inode(0x%p) called on read-only volume\",\n\t\t\t\tinode);\n\t\t\tjfs_err(\"Is remount racy?\");\n\t\t\tnoisy--;\n\t\t}\n\t\treturn 0;\n\t}\n\n\ttid = txBegin(inode->i_sb, COMMIT_INODE);\n\tmutex_lock(&JFS_IP(inode)->commit_mutex);\n\n\t\/*\n\t * Retest inode state after taking commit_mutex\n\t *\/\n\tif (inode->i_nlink && test_cflag(COMMIT_Dirty, inode))\n\t\trc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0);\n\n\ttxEnd(tid);\n\tmutex_unlock(&JFS_IP(inode)->commit_mutex);\n\treturn rc;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":309957,"func":"position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend)\n\/* check to see if the real cursor position matches the virtual *\/\n{\n    char buf[20];\n    char *s;\n    int y, x;\n\n    if (!_nc_tracing || (expected_y < 0 && expected_x < 0))\n\treturn;\n\n    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);\n    memset(buf, '\\0', sizeof(buf));\n    NCURSES_PUTP2_FLUSH(\"cpr\", \"\\033[6n\");\t\/* only works on ANSI-compatibles *\/\n    *(s = buf) = 0;\n    do {\n\tint ask = sizeof(buf) - 1 - (s - buf);\n\tint got = read(0, s, ask);\n\tif (got == 0)\n\t    break;\n\ts += got;\n    } while (strchr(buf, 'R') == 0);\n    _tracef(\"probe returned %s\", _nc_visbuf(buf));\n\n    \/* try to interpret as a position report *\/\n    if (sscanf(buf, \"\\033[%d;%dR\", &y, &x) != 2) {\n\t_tracef(\"position probe failed in %s\", legend);\n    } else {\n\tif (expected_x < 0)\n\t    expected_x = x - 1;\n\tif (expected_y < 0)\n\t    expected_y = y - 1;\n\tif (y - 1 != expected_y || x - 1 != expected_x) {\n\t    NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_2(\"\\033[%d;%dH\",\n\t\t\t\t\t     expected_y + 1,\n\t\t\t\t\t     expected_x + 1),\n\t\t\t\t    1, NCURSES_SP_NAME(_nc_outch));\n\t    _tracef(\"position seen (%d, %d) doesn't match expected one (%d, %d) in %s\",\n\t\t    y - 1, x - 1, expected_y, expected_x, legend);\n\t} else {\n\t    _tracef(\"position matches OK in %s\", legend);\n\t}\n    }\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":312428,"func":"qf_get_next_file_line(qfstate_T *state)\n{\n    int\t    discard;\n    int\t    growbuflen;\n\n    if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL)\n\treturn QF_END_OF_INPUT;\n\n    discard = FALSE;\n    state->linelen = (int)STRLEN(IObuff);\n    if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\\n'))\n    {\n\t\/\/ The current line exceeds IObuff, continue reading using\n\t\/\/ growbuf until EOL or LINE_MAXLEN bytes is read.\n\tif (state->growbuf == NULL)\n\t{\n\t    state->growbufsiz = 2 * (IOSIZE - 1);\n\t    state->growbuf = alloc_id(state->growbufsiz, aid_qf_linebuf);\n\t    if (state->growbuf == NULL)\n\t\treturn QF_NOMEM;\n\t}\n\n\t\/\/ Copy the read part of the line, excluding null-terminator\n\tmemcpy(state->growbuf, IObuff, IOSIZE - 1);\n\tgrowbuflen = state->linelen;\n\n\tfor (;;)\n\t{\n\t    char_u\t*p;\n\n\t    if (fgets((char *)state->growbuf + growbuflen,\n\t\t\tstate->growbufsiz - growbuflen, state->fd) == NULL)\n\t\tbreak;\n\t    state->linelen = (int)STRLEN(state->growbuf + growbuflen);\n\t    growbuflen += state->linelen;\n\t    if ((state->growbuf)[growbuflen - 1] == '\\n')\n\t\tbreak;\n\t    if (state->growbufsiz == LINE_MAXLEN)\n\t    {\n\t\tdiscard = TRUE;\n\t\tbreak;\n\t    }\n\n\t    state->growbufsiz = 2 * state->growbufsiz < LINE_MAXLEN\n\t\t? 2 * state->growbufsiz : LINE_MAXLEN;\n\t    if ((p = vim_realloc(state->growbuf, state->growbufsiz)) == NULL)\n\t\treturn QF_NOMEM;\n\t    state->growbuf = p;\n\t}\n\n\twhile (discard)\n\t{\n\t    \/\/ The current line is longer than LINE_MAXLEN, continue\n\t    \/\/ reading but discard everything until EOL or EOF is\n\t    \/\/ reached.\n\t    if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL\n\t\t    || (int)STRLEN(IObuff) < IOSIZE - 1\n\t\t    || IObuff[IOSIZE - 2] == '\\n')\n\t\tbreak;\n\t}\n\n\tstate->linebuf = state->growbuf;\n\tstate->linelen = growbuflen;\n    }\n    else\n\tstate->linebuf = IObuff;\n\n    \/\/ Convert a line if it contains a non-ASCII character.\n    if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf))\n    {\n\tchar_u\t*line;\n\n\tline = string_convert(&state->vc, state->linebuf, &state->linelen);\n\tif (line != NULL)\n\t{\n\t    if (state->linelen < IOSIZE)\n\t    {\n\t\tSTRCPY(state->linebuf, line);\n\t\tvim_free(line);\n\t    }\n\t    else\n\t    {\n\t\tvim_free(state->growbuf);\n\t\tstate->linebuf = state->growbuf = line;\n\t\tstate->growbufsiz = state->linelen < LINE_MAXLEN\n\t\t\t\t\t\t? state->linelen : LINE_MAXLEN;\n\t    }\n\t}\n    }\n\n    return QF_OK;\n}","target":0,"code_token_length":752,"total_token_length":988,"max_tokens_setting":1024}
+{"idx":475988,"func":"static inline lzw_result lzw__next_code(\n\t\tstruct lzw_read_ctx *ctx,\n\t\tuint8_t code_size,\n\t\tuint32_t *code_out)\n{\n\tuint32_t code = 0;\n\tuint8_t current_bit = ctx->sb_bit & 0x7;\n\tuint8_t byte_advance = (current_bit + code_size) >> 3;\n\n\tassert(byte_advance <= 2);\n\n\tif (ctx->sb_bit + code_size <= ctx->sb_bit_count) {\n\t\t\/* Fast path: code fully inside this sub-block *\/\n\t\tconst uint8_t *data = ctx->sb_data + (ctx->sb_bit >> 3);\n\t\tswitch (byte_advance) {\n\t\t\tcase 2: code |= data[2] << 16; \/* Fall through *\/\n\t\t\tcase 1: code |= data[1] <<  8; \/* Fall through *\/\n\t\t\tcase 0: code |= data[0] <<  0;\n\t\t}\n\t\tctx->sb_bit += code_size;\n\t} else {\n\t\t\/* Slow path: code spans sub-blocks *\/\n\t\tuint8_t byte = 0;\n\t\tuint8_t bits_remaining_0 = (code_size < (8 - current_bit)) ?\n\t\t\t\tcode_size : (8 - current_bit);\n\t\tuint8_t bits_remaining_1 = code_size - bits_remaining_0;\n\t\tuint8_t bits_used[3] = {\n\t\t\t[0] = bits_remaining_0,\n\t\t\t[1] = bits_remaining_1 < 8 ? bits_remaining_1 : 8,\n\t\t\t[2] = bits_remaining_1 - 8,\n\t\t};\n\n\t\twhile (true) {\n\t\t\tconst uint8_t *data = ctx->sb_data;\n\t\t\tlzw_result res;\n\n\t\t\t\/* Get any data from end of this sub-block *\/\n\t\t\twhile (byte <= byte_advance &&\n\t\t\t\t\tctx->sb_bit < ctx->sb_bit_count) {\n\t\t\t\tcode |= data[ctx->sb_bit >> 3] << (byte << 3);\n\t\t\t\tctx->sb_bit += bits_used[byte];\n\t\t\t\tbyte++;\n\t\t\t}\n\n\t\t\t\/* Check if we have all we need *\/\n\t\t\tif (byte > byte_advance) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t\/* Move to next sub-block *\/\n\t\t\tres = lzw__block_advance(ctx);\n\t\t\tif (res != LZW_OK) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\t}\n\n\t*code_out = (code >> current_bit) & ((1 << code_size) - 1);\n\treturn LZW_OK;\n}","target":0,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":459209,"func":"static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,\n\t\t\t      struct nlmsghdr *n, struct tcf_proto *tp,\n\t\t\t      struct tcf_block *block, struct Qdisc *q,\n\t\t\t      u32 parent, void *fh, bool unicast, bool *last,\n\t\t\t      bool rtnl_held, struct netlink_ext_ack *extack)\n{\n\tstruct sk_buff *skb;\n\tu32 portid = oskb ? NETLINK_CB(oskb).portid : 0;\n\tint err;\n\n\tskb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);\n\tif (!skb)\n\t\treturn -ENOBUFS;\n\n\tif (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid,\n\t\t\t  n->nlmsg_seq, n->nlmsg_flags, RTM_DELTFILTER,\n\t\t\t  false, rtnl_held) <= 0) {\n\t\tNL_SET_ERR_MSG(extack, \"Failed to build del event notification\");\n\t\tkfree_skb(skb);\n\t\treturn -EINVAL;\n\t}\n\n\terr = tp->ops->delete(tp, fh, last, rtnl_held, extack);\n\tif (err) {\n\t\tkfree_skb(skb);\n\t\treturn err;\n\t}\n\n\tif (unicast)\n\t\terr = rtnl_unicast(skb, net, portid);\n\telse\n\t\terr = rtnetlink_send(skb, net, portid, RTNLGRP_TC,\n\t\t\t\t     n->nlmsg_flags & NLM_F_ECHO);\n\tif (err < 0)\n\t\tNL_SET_ERR_MSG(extack, \"Failed to send filter delete notification\");\n\n\treturn err;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":390628,"func":"XkbWriteGeomShapes(char *wire,XkbGeometryPtr geom,Bool swap)\n{\nint\t\t\ti;\nXkbShapePtr\t\tshape;\nxkbShapeWireDesc *\tshapeWire;\n\n    for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {\n\tregister int \t\to;\n\tXkbOutlinePtr\t\tol;\n\txkbOutlineWireDesc *\tolWire;\n\tshapeWire= (xkbShapeWireDesc *)wire;\n\tshapeWire->name= shape->name;\n\tshapeWire->nOutlines= shape->num_outlines;\n\tif (shape->primary!=NULL)\n\t     shapeWire->primaryNdx= XkbOutlineIndex(shape,shape->primary);\n\telse shapeWire->primaryNdx= XkbNoShape;\n\tif (shape->approx!=NULL)\n\t     shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx);\n\telse shapeWire->approxNdx= XkbNoShape;\n\tif (swap) {\n\t    register int n;\n\t    swapl(&shapeWire->name,n);\n\t}\n\twire= (char *)&shapeWire[1];\n\tfor (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {\n\t    register int\tp;\n\t    XkbPointPtr\t\tpt;\n\t    xkbPointWireDesc *\tptWire;\n\t    olWire= (xkbOutlineWireDesc *)wire;\n\t    olWire->nPoints= ol->num_points;\n\t    olWire->cornerRadius= ol->corner_radius;\n\t    wire= (char *)&olWire[1];\n\t    ptWire= (xkbPointWireDesc *)wire;\n\t    for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {\n\t\tptWire[p].x= pt->x;\n\t\tptWire[p].y= pt->y;\n\t\tif (swap) {\n\t\t    register int n;\n\t\t    swaps(&ptWire[p].x,n);\n\t\t    swaps(&ptWire[p].y,n);\n\t\t}\n\t    }\n\t    wire= (char *)&ptWire[ol->num_points];\n\t}\n    }\n    return wire;\n}","target":0,"code_token_length":446,"total_token_length":682,"max_tokens_setting":1024}
+{"idx":233880,"func":" *\/\nstatic void php_wddx_serialize_array(wddx_packet *packet, zval *arr)\n{\n\tzval *ent;\n\tzend_string *key;\n\tint is_struct = 0;\n\tzend_ulong idx;\n\tHashTable *target_hash;\n\tchar tmp_buf[WDDX_BUF_LEN];\n\tzend_ulong ind = 0;\n\n\ttarget_hash = Z_ARRVAL_P(arr);\n\tZEND_HASH_FOREACH_KEY(target_hash, idx, key) {\n\t\tif (key) {\n\t\t\tis_struct = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (idx != ind) {\n\t\t\tis_struct = 1;\n\t\t\tbreak;\n\t\t}\n\t\tind++;\n\t} ZEND_HASH_FOREACH_END();\n\n\tif (is_struct) {\n\t\tphp_wddx_add_chunk_static(packet, WDDX_STRUCT_S);\n\t} else {\n\t\tsnprintf(tmp_buf, sizeof(tmp_buf), WDDX_ARRAY_S, zend_hash_num_elements(target_hash));\n\t\tphp_wddx_add_chunk(packet, tmp_buf);\n\t}\n\n\tZEND_HASH_FOREACH_KEY_VAL(target_hash, idx, key, ent) {\n\t\tif (ent == arr) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_struct) {\n\t\t\tif (key) {\n\t\t\t\tphp_wddx_serialize_var(packet, ent, key);\n\t\t\t} else {\n\t\t\t\tkey = zend_long_to_str(idx);\n\t\t\t\tphp_wddx_serialize_var(packet, ent, key);\n\t\t\t\tzend_string_release(key);\n\t\t\t}\n\t\t} else {\n\t\t\tphp_wddx_serialize_var(packet, ent, NULL);\n\t\t}\n\t} ZEND_HASH_FOREACH_END();\n\n\tif (is_struct) {\n\t\tphp_wddx_add_chunk_static(packet, WDDX_STRUCT_E);\n\t} else {\n\t\tphp_wddx_add_chunk_static(packet, WDDX_ARRAY_E);\n\t}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":328837,"func":"R_API char *r_bin_java_print_name_and_type_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *value = malloc (size);\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tobj->info.cp_name_and_type.name_idx,\n\t\t\tobj->info.cp_name_and_type.descriptor_idx);\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size);\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d.%d\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\t\t\tobj->info.cp_name_and_type.name_idx,\n\t\t\t\t\tobj->info.cp_name_and_type.descriptor_idx);\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":242265,"func":"static int PamConversationCallback(int num_msg,\n#if defined(__sun)\n                                   struct pam_message** msgm,\n#else\n                                   const struct pam_message** msgm,\n#endif\n                                   struct pam_response** response,\n                                   void* appdata_ptr)\n{\n  if (!appdata_ptr) {\n    Dmsg0(debuglevel, \"pam_conv_callback pointer error\\n\");\n    return PAM_BUF_ERR;\n  }\n\n  if ((num_msg <= 0) || (num_msg > PAM_MAX_NUM_MSG)) {\n    Dmsg0(debuglevel, \"pam_conv_callback wrong number of messages\\n\");\n    return (PAM_CONV_ERR);\n  }\n\n  struct pam_response* resp = static_cast<pam_response*>(\n      calloc(num_msg, sizeof(struct pam_response)));\n\n  if (!resp) {\n    Dmsg0(debuglevel, \"pam_conv_callback memory error\\n\");\n    return PAM_BUF_ERR;\n  }\n\n  PamData* pam_data = static_cast<PamData*>(appdata_ptr);\n\n  bool error = false;\n  int i = 0;\n  for (; i < num_msg && !error; i++) {\n    switch (msgm[i]->msg_style) {\n      case PAM_PROMPT_ECHO_OFF:\n      case PAM_PROMPT_ECHO_ON:\n        if (!PamConvSendMessage(pam_data->UA_sock_, msgm[i]->msg,\n                                msgm[i]->msg_style)) {\n          error = true;\n          break;\n        }\n        if (pam_data->UA_sock_->IsStop() || pam_data->UA_sock_->IsError()) {\n          error = true;\n          break;\n        }\n        if (pam_data->UA_sock_->recv()) {\n          resp[i].resp = strdup(pam_data->UA_sock_->msg);\n          resp[i].resp_retcode = 0;\n        }\n        if (pam_data->UA_sock_->IsStop() || pam_data->UA_sock_->IsError()) {\n          error = true;\n          break;\n        }\n        break;\n      case PAM_ERROR_MSG:\n      case PAM_TEXT_INFO:\n        if (!PamConvSendMessage(pam_data->UA_sock_, msgm[i]->msg,\n                                PAM_PROMPT_ECHO_ON)) {\n          error = true;\n        }\n        break;\n      default:\n        Dmsg3(debuglevel, \"message[%d]: pam error type: %d error: \\\"%s\\\"\\n\", 1,\n              msgm[i]->msg_style, msgm[i]->msg);\n        error = true;\n        break;\n    } \/* switch (msgm[i]->msg_style) { *\/\n  }   \/* for( ; i < num_msg ..) *\/\n\n  if (error) {\n    for (int i = 0; i < num_msg; ++i) {\n      if (resp[i].resp) {\n        memset(resp[i].resp, 0, strlen(resp[i].resp));\n        free(resp[i].resp);\n      }\n    }\n    memset(resp, 0, num_msg * sizeof *resp);\n    free(resp);\n    *response = nullptr;\n    return PAM_CONV_ERR;\n  }\n\n  *response = resp;\n  return PAM_SUCCESS;\n}","target":0,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":333054,"func":"sub_equal(regsub_T *sub1, regsub_T *sub2)\n{\n    int\t\ti;\n    int\t\ttodo;\n    linenr_T\ts1;\n    linenr_T\ts2;\n    char_u\t*sp1;\n    char_u\t*sp2;\n\n    todo = sub1->in_use > sub2->in_use ? sub1->in_use : sub2->in_use;\n    if (REG_MULTI)\n    {\n\tfor (i = 0; i < todo; ++i)\n\t{\n\t    if (i < sub1->in_use)\n\t\ts1 = sub1->list.multi[i].start_lnum;\n\t    else\n\t\ts1 = -1;\n\t    if (i < sub2->in_use)\n\t\ts2 = sub2->list.multi[i].start_lnum;\n\t    else\n\t\ts2 = -1;\n\t    if (s1 != s2)\n\t\treturn FALSE;\n\t    if (s1 != -1 && sub1->list.multi[i].start_col\n\t\t\t\t\t     != sub2->list.multi[i].start_col)\n\t\treturn FALSE;\n\n\t    if (rex.nfa_has_backref)\n\t    {\n\t\tif (i < sub1->in_use)\n\t\t    s1 = sub1->list.multi[i].end_lnum;\n\t\telse\n\t\t    s1 = -1;\n\t\tif (i < sub2->in_use)\n\t\t    s2 = sub2->list.multi[i].end_lnum;\n\t\telse\n\t\t    s2 = -1;\n\t\tif (s1 != s2)\n\t\t    return FALSE;\n\t\tif (s1 != -1 && sub1->list.multi[i].end_col\n\t\t\t\t\t       != sub2->list.multi[i].end_col)\n\t\treturn FALSE;\n\t    }\n\t}\n    }\n    else\n    {\n\tfor (i = 0; i < todo; ++i)\n\t{\n\t    if (i < sub1->in_use)\n\t\tsp1 = sub1->list.line[i].start;\n\t    else\n\t\tsp1 = NULL;\n\t    if (i < sub2->in_use)\n\t\tsp2 = sub2->list.line[i].start;\n\t    else\n\t\tsp2 = NULL;\n\t    if (sp1 != sp2)\n\t\treturn FALSE;\n\t    if (rex.nfa_has_backref)\n\t    {\n\t\tif (i < sub1->in_use)\n\t\t    sp1 = sub1->list.line[i].end;\n\t\telse\n\t\t    sp1 = NULL;\n\t\tif (i < sub2->in_use)\n\t\t    sp2 = sub2->list.line[i].end;\n\t\telse\n\t\t    sp2 = NULL;\n\t\tif (sp1 != sp2)\n\t\t    return FALSE;\n\t    }\n\t}\n    }\n\n    return TRUE;\n}","target":0,"code_token_length":567,"total_token_length":803,"max_tokens_setting":1024}
+{"idx":450328,"func":"static void vnc_refresh(DisplayChangeListener *dcl)\n{\n    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);\n    VncState *vs, *vn;\n    int has_dirty, rects = 0;\n\n    if (QTAILQ_EMPTY(&vd->clients)) {\n        update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_MAX);\n        return;\n    }\n\n    graphic_hw_update(vd->dcl.con);\n\n    if (vnc_trylock_display(vd)) {\n        update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);\n        return;\n    }\n\n    has_dirty = vnc_refresh_server_surface(vd);\n    vnc_unlock_display(vd);\n\n    QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {\n        rects += vnc_update_client(vs, has_dirty);\n        \/* vs might be free()ed here *\/\n    }\n\n    if (has_dirty && rects) {\n        vd->dcl.update_interval \/= 2;\n        if (vd->dcl.update_interval < VNC_REFRESH_INTERVAL_BASE) {\n            vd->dcl.update_interval = VNC_REFRESH_INTERVAL_BASE;\n        }\n    } else {\n        vd->dcl.update_interval += VNC_REFRESH_INTERVAL_INC;\n        if (vd->dcl.update_interval > VNC_REFRESH_INTERVAL_MAX) {\n            vd->dcl.update_interval = VNC_REFRESH_INTERVAL_MAX;\n        }\n    }\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":455389,"func":"xfs_iget(\n\txfs_mount_t\t*mp,\n\txfs_trans_t\t*tp,\n\txfs_ino_t\tino,\n\tuint\t\tflags,\n\tuint\t\tlock_flags,\n\txfs_inode_t\t**ipp)\n{\n\txfs_inode_t\t*ip;\n\tint\t\terror;\n\txfs_perag_t\t*pag;\n\txfs_agino_t\tagino;\n\n\t\/*\n\t * xfs_reclaim_inode() uses the ILOCK to ensure an inode\n\t * doesn't get freed while it's being referenced during a\n\t * radix tree traversal here.  It assumes this function\n\t * aqcuires only the ILOCK (and therefore it has no need to\n\t * involve the IOLOCK in this synchronization).\n\t *\/\n\tASSERT((lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) == 0);\n\n\t\/* reject inode numbers outside existing AGs *\/\n\tif (!ino || XFS_INO_TO_AGNO(mp, ino) >= mp->m_sb.sb_agcount)\n\t\treturn -EINVAL;\n\n\tXFS_STATS_INC(mp, xs_ig_attempts);\n\n\t\/* get the perag structure and ensure that it's inode capable *\/\n\tpag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));\n\tagino = XFS_INO_TO_AGINO(mp, ino);\n\nagain:\n\terror = 0;\n\trcu_read_lock();\n\tip = radix_tree_lookup(&pag->pag_ici_root, agino);\n\n\tif (ip) {\n\t\terror = xfs_iget_cache_hit(pag, ip, ino, flags, lock_flags);\n\t\tif (error)\n\t\t\tgoto out_error_or_again;\n\t} else {\n\t\trcu_read_unlock();\n\t\tif (flags & XFS_IGET_INCORE) {\n\t\t\terror = -ENODATA;\n\t\t\tgoto out_error_or_again;\n\t\t}\n\t\tXFS_STATS_INC(mp, xs_ig_missed);\n\n\t\terror = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,\n\t\t\t\t\t\t\tflags, lock_flags);\n\t\tif (error)\n\t\t\tgoto out_error_or_again;\n\t}\n\txfs_perag_put(pag);\n\n\t*ipp = ip;\n\n\t\/*\n\t * If we have a real type for an on-disk inode, we can setup the inode\n\t * now.\t If it's a new inode being created, xfs_ialloc will handle it.\n\t *\/\n\tif (xfs_iflags_test(ip, XFS_INEW) && VFS_I(ip)->i_mode != 0)\n\t\txfs_setup_existing_inode(ip);\n\treturn 0;\n\nout_error_or_again:\n\tif (!(flags & XFS_IGET_INCORE) && error == -EAGAIN) {\n\t\tdelay(1);\n\t\tgoto again;\n\t}\n\txfs_perag_put(pag);\n\treturn error;\n}","target":0,"code_token_length":596,"total_token_length":832,"max_tokens_setting":1024}
+{"idx":200305,"func":"pcx_write_rle(const byte * from, const byte * end, int step, gp_file * file)\n{\t\t\t\t\/*\n                                 * The PCX format theoretically allows encoding runs of 63\n                                 * identical bytes, but some readers can't handle repetition\n                                 * counts greater than 15.\n                                 *\/\n#define MAX_RUN_COUNT 15\n    int max_run = step * MAX_RUN_COUNT;\n\n    while (from < end) {\n        byte data = *from;\n\n        from += step;\n        if (data != *from || from == end) {\n            if (data >= 0xc0)\n                gp_fputc(0xc1, file);\n        } else {\n            const byte *start = from;\n\n            while ((from < end) && (*from == data))\n                from += step;\n            \/* Now (from - start) \/ step + 1 is the run length. *\/\n            while (from - start >= max_run) {\n                gp_fputc(0xc0 + MAX_RUN_COUNT, file);\n                gp_fputc(data, file);\n                start += max_run;\n            }\n            if (from > start || data >= 0xc0)\n                gp_fputc((from - start) \/ step + 0xc1, file);\n        }\n        gp_fputc(data, file);\n    }\n#undef MAX_RUN_COUNT\n}","target":1,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":349888,"func":"int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,\n\t\t\t     struct hw_atl_utils_fw_rpc **rpc)\n{\n\tstruct aq_hw_atl_utils_fw_rpc_tid_s sw;\n\tstruct aq_hw_atl_utils_fw_rpc_tid_s fw;\n\tint err = 0;\n\n\tdo {\n\t\tsw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR);\n\n\t\tself->rpc_tid = sw.tid;\n\n\t\terr = readx_poll_timeout_atomic(hw_atl_utils_rpc_state_get,\n\t\t\t\t\t\tself, fw.val,\n\t\t\t\t\t\tsw.tid == fw.tid,\n\t\t\t\t\t\t1000U, 100000U);\n\t\tif (err < 0)\n\t\t\tgoto err_exit;\n\n\t\terr = aq_hw_err_from_flags(self);\n\t\tif (err < 0)\n\t\t\tgoto err_exit;\n\n\t\tif (fw.len == 0xFFFFU) {\n\t\t\tif (sw.len > sizeof(self->rpc)) {\n\t\t\t\tprintk(KERN_INFO \"Invalid sw len: %x\\n\", sw.len);\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto err_exit;\n\t\t\t}\n\t\t\terr = hw_atl_utils_fw_rpc_call(self, sw.len);\n\t\t\tif (err < 0)\n\t\t\t\tgoto err_exit;\n\t\t}\n\t} while (sw.tid != fw.tid || 0xFFFFU == fw.len);\n\n\tif (rpc) {\n\t\tif (fw.len) {\n\t\t\tif (fw.len > sizeof(self->rpc)) {\n\t\t\t\tprintk(KERN_INFO \"Invalid fw len: %x\\n\", fw.len);\n\t\t\t\terr = -EINVAL;\n\t\t\t\tgoto err_exit;\n\t\t\t}\n\t\t\terr =\n\t\t\thw_atl_utils_fw_downld_dwords(self,\n\t\t\t\t\t\t      self->rpc_addr,\n\t\t\t\t\t\t      (u32 *)(void *)\n\t\t\t\t\t\t      &self->rpc,\n\t\t\t\t\t\t      (fw.len + sizeof(u32) -\n\t\t\t\t\t\t       sizeof(u8)) \/\n\t\t\t\t\t\t      sizeof(u32));\n\t\t\tif (err < 0)\n\t\t\t\tgoto err_exit;\n\t\t}\n\n\t\t*rpc = &self->rpc;\n\t}\n\nerr_exit:\n\treturn err;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":503874,"func":"SCM_DEFINE (scm_readdir, \"readdir\", 1, 0, 0,\n\t    (SCM port),\n\t    \"Return (as a string) the next directory entry from the directory stream\\n\"\n\t    \"@var{port}.  If there is no remaining entry to be read then the\\n\"\n\t    \"end of file object is returned.\")\n#define FUNC_NAME s_scm_readdir\n{\n  struct dirent_or_dirent64 *rdent;\n\n  SCM_VALIDATE_DIR (1, port);\n  if (!SCM_DIR_OPEN_P (port))\n    SCM_MISC_ERROR (\"Directory ~S is not open.\", scm_list_1 (port));\n\n#if HAVE_READDIR_R\n  \/* As noted in the glibc manual, on various systems (such as Solaris) the\n     d_name[] field is only 1 char and you're expected to size the dirent\n     buffer for readdir_r based on NAME_MAX.  The SCM_MAX expressions below\n     effectively give either sizeof(d_name) or NAME_MAX+1, whichever is\n     bigger.\n\n     On solaris 10 there's no NAME_MAX constant, it's necessary to use\n     pathconf().  We prefer NAME_MAX though, since it should be a constant\n     and will therefore save a system call.  We also prefer it since dirfd()\n     is not available everywhere.\n\n     An alternative to dirfd() would be to open() the directory and then use\n     fdopendir(), if the latter is available.  That'd let us hold the fd\n     somewhere in the smob, or just the dirent size calculated once.  *\/\n  {\n    struct dirent_or_dirent64 de; \/* just for sizeof *\/\n    DIR    *ds = (DIR *) SCM_SMOB_DATA_1 (port);\n#ifdef NAME_MAX\n    char   buf [SCM_MAX (sizeof (de),\n\t\t\t sizeof (de) - sizeof (de.d_name) + NAME_MAX + 1)];\n#else\n    char   *buf;\n    long   name_max = fpathconf (dirfd (ds), _PC_NAME_MAX);\n    if (name_max == -1)\n      SCM_SYSERROR;\n    buf = alloca (SCM_MAX (sizeof (de),\n\t\t\t   sizeof (de) - sizeof (de.d_name) + name_max + 1));\n#endif\n\n    errno = 0;\n    SCM_SYSCALL (readdir_r_or_readdir64_r (ds, (struct dirent_or_dirent64 *) buf, &rdent));\n    if (errno != 0)\n      SCM_SYSERROR;\n    if (! rdent)\n      return SCM_EOF_VAL;\n\n    return (rdent ? scm_from_locale_stringn (rdent->d_name, NAMLEN (rdent))\n\t    : SCM_EOF_VAL);\n  }\n#else\n  {\n    SCM ret;\n    scm_dynwind_begin (0);\n    scm_i_dynwind_pthread_mutex_lock (&scm_i_misc_mutex);\n\n    errno = 0;\n    SCM_SYSCALL (rdent = readdir_or_readdir64 ((DIR *) SCM_SMOB_DATA_1 (port)));\n    if (errno != 0)\n      SCM_SYSERROR;\n\n    ret = (rdent ? scm_from_locale_stringn (rdent->d_name, NAMLEN (rdent))\n\t   : SCM_EOF_VAL);\n\n    scm_dynwind_end ();\n    return ret;\n  }\n#endif\n}","target":0,"code_token_length":709,"total_token_length":945,"max_tokens_setting":1024}
+{"idx":225049,"func":"pqDropServerData(PGconn *conn)\n{\n\tPGnotify   *notify;\n\tpgParameterStatus *pstatus;\n\n\t\/* Forget pending notifies *\/\n\tnotify = conn->notifyHead;\n\twhile (notify != NULL)\n\t{\n\t\tPGnotify   *prev = notify;\n\n\t\tnotify = notify->next;\n\t\tfree(prev);\n\t}\n\tconn->notifyHead = conn->notifyTail = NULL;\n\n\tpqFreeCommandQueue(conn->cmd_queue_head);\n\tconn->cmd_queue_head = conn->cmd_queue_tail = NULL;\n\n\tpqFreeCommandQueue(conn->cmd_queue_recycle);\n\tconn->cmd_queue_recycle = NULL;\n\n\t\/* Reset ParameterStatus data, as well as variables deduced from it *\/\n\tpstatus = conn->pstatus;\n\twhile (pstatus != NULL)\n\t{\n\t\tpgParameterStatus *prev = pstatus;\n\n\t\tpstatus = pstatus->next;\n\t\tfree(prev);\n\t}\n\tconn->pstatus = NULL;\n\tconn->client_encoding = PG_SQL_ASCII;\n\tconn->std_strings = false;\n\tconn->default_transaction_read_only = PG_BOOL_UNKNOWN;\n\tconn->in_hot_standby = PG_BOOL_UNKNOWN;\n\tconn->sversion = 0;\n\n\t\/* Drop large-object lookup data *\/\n\tif (conn->lobjfuncs)\n\t\tfree(conn->lobjfuncs);\n\tconn->lobjfuncs = NULL;\n\n\t\/* Reset assorted other per-connection state *\/\n\tconn->last_sqlstate[0] = '\\0';\n\tconn->auth_req_received = false;\n\tconn->password_needed = false;\n\tconn->write_failed = false;\n\tif (conn->write_err_msg)\n\t\tfree(conn->write_err_msg);\n\tconn->write_err_msg = NULL;\n\tconn->be_pid = 0;\n\tconn->be_key = 0;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":328955,"func":"R_API RBinJavaBootStrapMethod *r_bin_java_bootstrap_method_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaBootStrapArgument *bsm_arg = NULL;\n\tut32 i = 0;\n\tut64 offset = 0;\n\tRBinJavaBootStrapMethod *bsm = R_NEW0 (RBinJavaBootStrapMethod);\n\tif (!bsm) {\n\t\t\/\/ TODO eprintf failed to allocate bytes for bootstrap_method.\n\t\treturn bsm;\n\t}\n\tmemset (bsm, 0, sizeof (RBinJavaBootStrapMethod));\n\tbsm->file_offset = buf_offset;\n\tbsm->bootstrap_method_ref = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tbsm->num_bootstrap_arguments = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tbsm->bootstrap_arguments = r_list_new ();\n\tfor (i = 0; i < bsm->num_bootstrap_arguments; i++) {\n\t\tif (offset >= sz) {\n\t\t\tbreak;\n\t\t}\n\t\t\/\/ bsm_arg = r_bin_java_bootstrap_method_argument_new (bin, bin->b->cur);\n\t\tbsm_arg = r_bin_java_bootstrap_method_argument_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\tif (bsm_arg) {\n\t\t\toffset += bsm_arg->size;\n\t\t\tr_list_append (bsm->bootstrap_arguments, (void *) bsm_arg);\n\t\t} else {\n\t\t\t\/\/ TODO eprintf Failed to read the %d boot strap method.\n\t\t}\n\t}\n\tbsm->size = offset;\n\treturn bsm;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":310019,"func":"show_tty_change(TTY * old_settings,\n\t\tTTY * new_settings,\n\t\tconst char *name,\n\t\tint which,\n\t\tunsigned def)\n{\n    unsigned older, newer;\n    char *p;\n\n    newer = new_settings->c_cc[which];\n    older = old_settings->c_cc[which];\n\n    if (older == newer && older == def)\n\treturn;\n\n    (void) fprintf(stderr, \"%s %s \", name, older == newer ? \"is\" : \"set to\");\n\n    if (DISABLED(newer)) {\n\t(void) fprintf(stderr, \"undef.\\n\");\n\t\/*\n\t * Check 'delete' before 'backspace', since the key_backspace value\n\t * is ambiguous.\n\t *\/\n    } else if (newer == 0177) {\n\t(void) fprintf(stderr, \"delete.\\n\");\n    } else if ((p = key_backspace) != 0\n\t       && newer == (unsigned char) p[0]\n\t       && p[1] == '\\0') {\n\t(void) fprintf(stderr, \"backspace.\\n\");\n    } else if (newer < 040) {\n\tnewer ^= 0100;\n\t(void) fprintf(stderr, \"control-%c (^%c).\\n\", UChar(newer), UChar(newer));\n    } else\n\t(void) fprintf(stderr, \"%c.\\n\", UChar(newer));\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":267859,"func":"Status ModularFrameDecoder::DecodeQuantTable(\n    size_t required_size_x, size_t required_size_y, BitReader* br,\n    QuantEncoding* encoding, size_t idx,\n    ModularFrameDecoder* modular_frame_decoder) {\n  JXL_RETURN_IF_ERROR(F16Coder::Read(br, &encoding->qraw.qtable_den));\n  if (encoding->qraw.qtable_den < kAlmostZero) {\n    \/\/ qtable[] values are already checked for <= 0 so the denominator may not\n    \/\/ be negative.\n    return JXL_FAILURE(\"Invalid qtable_den: value too small\");\n  }\n  Image image(required_size_x, required_size_y, 8, 3);\n  ModularOptions options;\n  if (modular_frame_decoder) {\n    JXL_RETURN_IF_ERROR(ModularGenericDecompress(\n        br, image, \/*header=*\/nullptr,\n        ModularStreamId::QuantTable(idx).ID(modular_frame_decoder->frame_dim),\n        &options, \/*undo_transforms=*\/-1, &modular_frame_decoder->tree,\n        &modular_frame_decoder->code, &modular_frame_decoder->context_map));\n  } else {\n    JXL_RETURN_IF_ERROR(ModularGenericDecompress(br, image, \/*header=*\/nullptr,\n                                                 0, &options,\n                                                 \/*undo_transforms=*\/-1));\n  }\n  if (!encoding->qraw.qtable) {\n    encoding->qraw.qtable = new std::vector<int>();\n  }\n  encoding->qraw.qtable->resize(required_size_x * required_size_y * 3);\n  for (size_t c = 0; c < 3; c++) {\n    for (size_t y = 0; y < required_size_y; y++) {\n      int* JXL_RESTRICT row = image.channel[c].Row(y);\n      for (size_t x = 0; x < required_size_x; x++) {\n        (*encoding->qraw.qtable)[c * required_size_x * required_size_y +\n                                 y * required_size_x + x] = row[x];\n        if (row[x] <= 0) {\n          return JXL_FAILURE(\"Invalid raw quantization table\");\n        }\n      }\n    }\n  }\n  return true;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":474063,"func":"onig_error_code_to_str(s, code, va_alist)\n  UChar* s;\n  int code;\n  va_dcl\n#endif\n{\n  UChar *p, *q;\n  OnigErrorInfo* einfo;\n  size_t len;\n  int is_over;\n  UChar parbuf[MAX_ERROR_PAR_LEN];\n  va_list vargs;\n\n  va_init_list(vargs, code);\n\n  switch (code) {\n  case ONIGERR_UNDEFINED_NAME_REFERENCE:\n  case ONIGERR_UNDEFINED_GROUP_REFERENCE:\n  case ONIGERR_MULTIPLEX_DEFINED_NAME:\n  case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:\n  case ONIGERR_INVALID_GROUP_NAME:\n  case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:\n  case ONIGERR_INVALID_CHAR_PROPERTY_NAME:\n    einfo = va_arg(vargs, OnigErrorInfo*);\n    len = to_ascii(einfo->enc, einfo->par, einfo->par_end,\n\t\t   parbuf, MAX_ERROR_PAR_LEN - 3, &is_over);\n    q = onig_error_code_to_format(code);\n    p = s;\n    while (*q != '\\0') {\n      if (*q == '%') {\n\tq++;\n\tif (*q == 'n') { \/* '%n': name *\/\n\t  xmemcpy(p, parbuf, len);\n\t  p += len;\n\t  if (is_over != 0) {\n\t    xmemcpy(p, \"...\", 3);\n\t    p += 3;\n\t  }\n\t  q++;\n\t}\n\telse\n\t  goto normal_char;\n      }\n      else {\n      normal_char:\n\t*p++ = *q++;\n      }\n    }\n    *p = '\\0';\n    len = p - s;\n    break;\n\n  default:\n    q = onig_error_code_to_format(code);\n    len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, q);\n    xmemcpy(s, q, len);\n    s[len] = '\\0';\n    break;\n  }\n\n  va_end(vargs);\n  return (int)len;\n}","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":481795,"func":"int qh_register_handler(const char *name, const char *description, unsigned int options, qh_handler handler)\n{\n\tstruct query_handler *qh = NULL;\n\tint result = 0;\n\n\tif (name == NULL) {\n\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE, \"qh: Failed to register handler with no name\\n\");\n\t\treturn -1;\n\t}\n\n\tif (handler == NULL) {\n\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE, \"qh: Failed to register handler '%s': No handler function specified\\n\", name);\n\t\treturn -1;\n\t}\n\n\tif (strlen(name) > 128) {\n\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE, \"qh: Failed to register handler '%s': Name too long\\n\", name);\n\t\treturn -ENAMETOOLONG;\n\t}\n\n\t\/* names must be unique *\/\n\tif (qh_find_handler(name)) {\n\t\tlogit(NSLOG_RUNTIME_WARNING, TRUE, \"qh: Handler '%s' registered more than once\\n\", name);\n\t\treturn -1;\n\t}\n\n\tqh = calloc(1, sizeof(*qh));\n\tif (qh == NULL) {\n\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE, \"qh: Failed to allocate memory for handler '%s'\\n\", name);\n\t\treturn -errno;\n\t}\n\n\tqh->name               = name;\n\tqh->description        = description;\n\tqh->handler            = handler;\n\tqh->options            = options;\n\tqh->next_qh            = qhandlers;\n\n\tif (qhandlers) {\n\t\tqhandlers->prev_qh = qh;\n\t}\n\n\tqhandlers              = qh;\n\n\tresult = dkhash_insert(qh_table, qh->name, NULL, qh);\n\tif (result < 0) {\n\t\tlogit(NSLOG_RUNTIME_ERROR, TRUE,\n\t\t\t  \"qh: Failed to insert query handler '%s' (%p) into hash table %p (%d): %s\\n\",\n\t\t\t  name, qh, qh_table, result, strerror(errno));\n\t\tfree(qh);\n\t\treturn result;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":229312,"func":"cql_server::connection::process_on_shard(::shared_ptr<messages::result_message::bounce_to_shard> bounce_msg, uint16_t stream, fragmented_temporary_buffer::istream is,\n        service::client_state& cs, service_permit permit, tracing::trace_state_ptr trace_state, Process process_fn) {\n    return _server.container().invoke_on(*bounce_msg->move_to_shard(), _server._config.bounce_request_smp_service_group,\n            [this, is = std::move(is), cs = cs.move_to_other_shard(), stream, permit = std::move(permit), process_fn,\n             gt = tracing::global_trace_state_ptr(std::move(trace_state)),\n             cached_vals = std::move(bounce_msg->take_cached_pk_function_calls())] (cql_server& server) {\n        service::client_state client_state = cs.get();\n        return do_with(bytes_ostream(), std::move(client_state), std::move(cached_vals),\n                [this, &server, is = std::move(is), stream, process_fn,\n                 trace_state = tracing::trace_state_ptr(gt)] (bytes_ostream& linearization_buffer,\n                    service::client_state& client_state,\n                    cql3::computed_function_values& cached_vals) mutable {\n            request_reader in(is, linearization_buffer);\n            return process_fn(client_state, server._query_processor, in, stream, _version, _cql_serialization_format,\n                    \/* FIXME *\/empty_service_permit(), std::move(trace_state), false, std::move(cached_vals)).then([] (auto msg) {\n                \/\/ result here has to be foreign ptr\n                return std::get<cql_server::result_with_foreign_response_ptr>(std::move(msg));\n            });\n        });\n    });\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":274692,"func":"callbacks_drawingarea_motion_notify_event (GtkWidget *widget, GdkEventMotion *event)\n{\n\tint x, y;\n\tGdkModifierType state;\n\n\tif (event->is_hint)\n\t\tgdk_window_get_pointer (event->window, &x, &y, &state);\n\telse {\n\t\tx = event->x;\n\t\ty = event->y;\n\t\tstate = event->state;\n\t}\n\n\tswitch (screen.state) {\n\t\tcase IN_MOVE: {\n\t\t    if (screen.last_x != 0 || screen.last_y != 0) {\n\t\t\t\/* Move pixmap to get a snappier feel of movement *\/\n\t\t\tscreen.off_x += x - screen.last_x;\n\t\t\tscreen.off_y += y - screen.last_y;\n\t\t    }\n    \t\t    screenRenderInfo.lowerLeftX -= ((x - screen.last_x) \/ screenRenderInfo.scaleFactorX);\n\t\t    screenRenderInfo.lowerLeftY += ((y - screen.last_y) \/ screenRenderInfo.scaleFactorY);\n\t\t    callbacks_force_expose_event_for_screen ();\n\t\t    callbacks_update_scrollbar_positions ();\n\t\t\tscreen.last_x = x;\n\t\t\tscreen.last_y = y;\n\t\t    break;\n\t\t}\n\t\tcase IN_ZOOM_OUTLINE: {\n\t\t\tif (screen.last_x || screen.last_y)\n\t\t\t\trender_draw_zoom_outline(screen.centered_outline_zoom);\n\t\t\tscreen.last_x = x;\n\t\t\tscreen.last_y = y;\n\t\t\trender_draw_zoom_outline(screen.centered_outline_zoom);\n\t\t\tbreak;\n\t\t}\n\t\tcase IN_MEASURE: {\n\t\t\t\/* clear the previous drawn line by drawing over it *\/\n\t\t\trender_toggle_measure_line();\n\t\t\tcallbacks_screen2board(&(screen.measure_stop_x),\n\t\t\t    &(screen.measure_stop_y), x, y);\n\t\t\t\/* screen.last_[xy] are updated to move the ruler pointers *\/\n\t\t\tscreen.last_x = x;\n\t\t\tscreen.last_y = y;\n\t\t\t\/* draw the new line and write the new distance *\/\n\t\t\trender_draw_measure_distance();\n\t\t\tbreak;\n\t\t}\n\t\tcase IN_SELECTION_DRAG: {\n\t\t\tif (screen.last_x || screen.last_y)\n\t\t\t\trender_draw_selection_box_outline();\n\t\t\tscreen.last_x = x;\n\t\t\tscreen.last_y = y;\n\t\t\trender_draw_selection_box_outline();\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tscreen.last_x = x;\n\t\t\tscreen.last_y = y;\n\t\t\tbreak;\n\t}\n\tcallbacks_update_statusbar_coordinates (x, y);\n\tcallbacks_update_ruler_pointers ();\n\treturn TRUE;\n} \/* motion_notify_event *\/","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":195091,"func":"llvm::Optional<Value> simplifyBroadcast(ShapeComponentAnalysis& analysis,\n                                        ValueRange shapes, Location loc,\n                                        OpBuilder* builder) {\n  \/\/ First find the input shape with the largest rank.\n  SmallVector<ArrayRef<ShapeComponentAnalysis::SymbolicExpr>> shapes_found;\n  size_t maxRank = 0;\n  for (const auto &shape : llvm::enumerate(shapes)) {\n    auto found_shape = analysis.GetValueInfo(shape.value());\n    if (!found_shape) return {};\n    shapes_found.push_back(*found_shape);\n    maxRank = std::max(maxRank, found_shape->size());\n  }\n\n  SmallVector<const ShapeComponentAnalysis::SymbolicExpr*> joined_dimensions(\n      maxRank);\n  SmallVector<std::pair<Value, int64_t>> shape_and_rank_for_dim(maxRank);\n  for (const auto &shape : llvm::enumerate(shapes_found)) {\n    for (const auto &dim : llvm::enumerate(llvm::reverse(shape.value()))) {\n      \/\/ 1 dimensions don't contribute to the final result.\n      if (dim.value().isConstant(1)) continue;\n      \/\/ If it's not a 1 dimension it will be present in the result. Remember\n      \/\/ where it came from.\n      auto index = maxRank - dim.index() - 1;\n      if (!joined_dimensions[index]) {\n        joined_dimensions[index] = &dim.value();\n        shape_and_rank_for_dim[index] =\n            std::make_pair(shapes[shape.index()], shape.value().size());\n        continue;\n      }\n      \/\/ Bail if the dimensions are neither equal nor 1.\n      if (*joined_dimensions[index] != dim.value()) return {};\n    }\n  }\n  \/\/ If the output is the same as one of the inputs just return that.\n  if (llvm::is_splat(shape_and_rank_for_dim) &&\n      shape_and_rank_for_dim[0].first) {\n    return shape_and_rank_for_dim[0].first;\n  }\n  \/\/ Otherwise rematerialize the shape from the pieces we have.\n  SmallVector<Value> elements;\n  for (int i = 0; i != maxRank; ++i) {\n    \/\/ 1 dimensions are filtered above, recreate the constant.\n    if (!shape_and_rank_for_dim[i].first) {\n      auto one = builder->getIntegerAttr(\n          shapes[0].getType().cast<RankedTensorType>().getElementType(), 1);\n      elements.push_back(builder->create<ConstantOp>(loc, one));\n      continue;\n    }\n    \/\/ Extract from one of the shapes, accounting for the reverse indexing\n    \/\/ performed by broadcast.\n    Value index = builder->create<ConstantIndexOp>(\n        loc, i - maxRank + shape_and_rank_for_dim[i].second);\n    elements.push_back(builder->create<tensor::ExtractOp>(\n        loc, shape_and_rank_for_dim[i].first, index));\n  }\n  return Value(builder->create<tensor::FromElementsOp>(loc, elements));\n}","target":1,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":377482,"func":"void r_coresym_cache_element_free(RCoreSymCacheElement *element) {\n\tif (!element) {\n\t\treturn;\n\t}\n\tsize_t i;\n\tif (element->segments) {\n\t\tfor (i = 0; i < element->hdr->n_segments; i++) {\n\t\t\tr_coresym_cache_element_segment_fini (&element->segments[i]);\n\t\t}\n\t}\n\tif (element->sections) {\n\t\tfor (i = 0; i < element->hdr->n_sections; i++) {\n\t\t\tr_coresym_cache_element_section_fini (&element->sections[i]);\n\t\t}\n\t}\n\tif (element->symbols) {\n\t\tfor (i = 0; i < element->hdr->n_symbols; i++) {\n\t\t\tr_coresym_cache_element_symbol_fini (&element->symbols[i]);\n\t\t}\n\t}\n\tif (element->lined_symbols) {\n\t\tfor (i = 0; i < element->hdr->n_lined_symbols; i++) {\n\t\t\tr_coresym_cache_element_lined_symbol_fini (&element->lined_symbols[i]);\n\t\t}\n\t}\n\tif (element->line_info) {\n\t\tfor (i = 0; i < element->hdr->n_line_info; i++) {\n\t\t\tr_coresym_cache_element_line_info_fini (&element->line_info[i]);\n\t\t}\n\t}\n\tfree (element->segments);\n\tfree (element->sections);\n\tfree (element->symbols);\n\tfree (element->lined_symbols);\n\tfree (element->line_info);\n\tfree (element->hdr);\n\tfree (element->file_name);\n\tfree (element->binary_version);\n\tfree (element);\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":413862,"func":"void LinkResolver::resolve_handle_call(CallInfo& result,\n                                       const LinkInfo& link_info,\n                                       TRAPS) {\n  \/\/ JSR 292:  this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar\n  Klass* resolved_klass = link_info.resolved_klass();\n  assert(resolved_klass == vmClasses::MethodHandle_klass() ||\n         resolved_klass == vmClasses::VarHandle_klass(), \"\");\n  assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), \"\");\n  Handle resolved_appendix;\n  Method* m = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK);\n  methodHandle resolved_method(THREAD, m);\n\n  if (link_info.check_access()) {\n    Symbol* name = link_info.name();\n    vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name);\n    if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) {\n      \/\/ Check if method can be accessed by the referring class.\n      \/\/ MH.linkTo* invocations are not rewritten to invokehandle.\n      assert(iid == vmIntrinsicID::_invokeBasic, \"%s\", vmIntrinsics::name_at(iid));\n\n      Klass* current_klass = link_info.current_klass();\n      assert(current_klass != NULL , \"current_klass should not be null\");\n      check_method_accessability(current_klass,\n                                 resolved_klass,\n                                 resolved_method->method_holder(),\n                                 resolved_method,\n                                 CHECK);\n    } else {\n      \/\/ Java code is free to arbitrarily link signature-polymorphic invokers.\n      assert(iid == vmIntrinsics::_invokeGeneric, \"not an invoker: %s\", vmIntrinsics::name_at(iid));\n      assert(MethodHandles::is_signature_polymorphic_public_name(resolved_klass, name), \"not public\");\n    }\n  }\n  result.set_handle(resolved_klass, resolved_method, resolved_appendix, CHECK);\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":205734,"func":"static pyc_object *get_complex_object(RzBinPycObj *pyc, RzBuffer *buffer) {\n\tpyc_object *ret = NULL;\n\tbool error = false;\n\tut32 size = 0;\n\tut32 n1 = 0;\n\tut32 n2 = 0;\n\n\tret = RZ_NEW0(pyc_object);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\n\tif ((pyc->magic_int & 0xffff) <= 62061) {\n\t\tn1 = get_ut8(buffer, &error);\n\t} else {\n\t\tn1 = get_st32(buffer, &error);\n\t}\n\tif (error) {\n\t\tfree(ret);\n\t\treturn NULL;\n\t}\n\tut8 *s1 = malloc(n1 + 1);\n\tif (!s1) {\n\t\treturn NULL;\n\t}\n\t\/* object contain string representation of the number *\/\n\tsize = rz_buf_read(buffer, s1, n1);\n\tif (size != n1) {\n\t\tRZ_FREE(s1);\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\ts1[n1] = '\\0';\n\n\tif ((pyc->magic_int & 0xffff) <= 62061) {\n\t\tn2 = get_ut8(buffer, &error);\n\t} else\n\t\tn2 = get_st32(buffer, &error);\n\tif (error) {\n\t\treturn NULL;\n\t}\n\tut8 *s2 = malloc(n2 + 1);\n\tif (!s2) {\n\t\treturn NULL;\n\t}\n\t\/* object contain string representation of the number *\/\n\tsize = rz_buf_read(buffer, s2, n2);\n\tif (size != n2) {\n\t\tRZ_FREE(s1);\n\t\tRZ_FREE(s2);\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\ts2[n2] = '\\0';\n\n\tret->type = TYPE_COMPLEX;\n\tret->data = rz_str_newf(\"%s+%sj\", s1, s2);\n\tRZ_FREE(s1);\n\tRZ_FREE(s2);\n\tif (!ret->data) {\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\treturn ret;\n}","target":1,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":223424,"func":"static void compile_assert_backtrackingpath(compiler_common *common, struct backtrack_common *current)\n{\nDEFINE_COMPILER;\nPCRE2_SPTR cc = current->cc;\nPCRE2_UCHAR bra = OP_BRA;\nstruct sljit_jump *brajump = NULL;\n\nSLJIT_ASSERT(*cc != OP_BRAMINZERO);\nif (*cc == OP_BRAZERO)\n  {\n  bra = *cc;\n  cc++;\n  }\n\nif (bra == OP_BRAZERO)\n  {\n  SLJIT_ASSERT(current->topbacktracks == NULL);\n  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));\n  }\n\nif (CURRENT_AS(assert_backtrack)->framesize < 0)\n  {\n  set_jumps(current->topbacktracks, LABEL());\n\n  if (bra == OP_BRAZERO)\n    {\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);\n    CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(assert_backtrack)->matchingpath);\n    free_stack(common, 1);\n    }\n  return;\n  }\n\nif (bra == OP_BRAZERO)\n  {\n  if (*cc == OP_ASSERT_NOT || *cc == OP_ASSERTBACK_NOT)\n    {\n    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);\n    CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(assert_backtrack)->matchingpath);\n    free_stack(common, 1);\n    return;\n    }\n  free_stack(common, 1);\n  brajump = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);\n  }\n\nif (*cc == OP_ASSERT || *cc == OP_ASSERTBACK)\n  {\n  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), CURRENT_AS(assert_backtrack)->private_data_ptr);\n  add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(-2));\n  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (CURRENT_AS(assert_backtrack)->framesize - 1) * sizeof(sljit_sw));\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), CURRENT_AS(assert_backtrack)->private_data_ptr, TMP1, 0);\n\n  set_jumps(current->topbacktracks, LABEL());\n  }\nelse\n  set_jumps(current->topbacktracks, LABEL());\n\nif (bra == OP_BRAZERO)\n  {\n  \/* We know there is enough place on the stack. *\/\n  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));\n  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);\n  JUMPTO(SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);\n  JUMPHERE(brajump);\n  }\n}","target":0,"code_token_length":734,"total_token_length":970,"max_tokens_setting":1024}
+{"idx":256413,"func":"static void parse_rtcp_fb(pjmedia_rtcp_session *sess,\n\t\t\t  const void *pkt,\n\t\t\t  pj_size_t size)\n{\n    unsigned cnt = 1;\n    pjmedia_rtcp_fb_nack nack[1];\n    \/\/pjmedia_rtcp_fb_sli sli[1];\n    \/\/pjmedia_rtcp_fb_rpsi rpsi;\n    pjmedia_event ev;\n    pj_timestamp ts_now;\n\n    pj_get_timestamp(&ts_now);\n\n    if (pjmedia_rtcp_fb_parse_nack(pkt, size, &cnt, nack)==PJ_SUCCESS)\n    {\n\tpjmedia_event_init(&ev, PJMEDIA_EVENT_RX_RTCP_FB, &ts_now, sess);\n\tev.data.rx_rtcp_fb.cap.type = PJMEDIA_RTCP_FB_NACK;\n\tev.data.rx_rtcp_fb.msg.nack = nack[0];\n\tpjmedia_event_publish(NULL, sess, &ev, 0);\n\n    } else if (pjmedia_rtcp_fb_parse_pli(pkt, size)==PJ_SUCCESS)\n    {\n\tpjmedia_event_init(&ev, PJMEDIA_EVENT_RX_RTCP_FB, &ts_now, sess);\n\tev.data.rx_rtcp_fb.cap.type = PJMEDIA_RTCP_FB_NACK;\n\tpj_strset2(&ev.data.rx_rtcp_fb.cap.param, (char*)\"pli\");\n\tpjmedia_event_publish(NULL, sess, &ev, 0);\n\n\t\/*  For other FB type implementations later\n    } else if (pjmedia_rtcp_fb_parse_sli(pkt, size, &cnt, sli)==PJ_SUCCESS)\n    {\n    } else if (pjmedia_rtcp_fb_parse_rpsi(pkt, size, &rpsi)==PJ_SUCCESS)\n    {\n\t*\/\n    } else {\n\t\/* Ignore unknown RTCP Feedback *\/\n\tTRACE_((sess->name, \"Received unknown RTCP feedback\"));\n    }\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":390622,"func":"ProcXkbSetMap(ClientPtr client)\n{\n    DeviceIntPtr\tdev;\n    char *\t\ttmp;\n    int                 rc;\n\n    REQUEST(xkbSetMapReq);\n    REQUEST_AT_LEAST_SIZE(xkbSetMapReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess);\n    CHK_MASK_LEGAL(0x01,stuff->present,XkbAllMapComponentsMask);\n\n    tmp = (char *)&stuff[1];\n\n    \/* Check if we can to the SetMap on the requested device. If this\n       succeeds, do the same thing for all extension devices (if needed).\n       If any of them fails, fail.  *\/\n    rc = _XkbSetMapChecks(client, dev, stuff, tmp);\n\n    if (rc != Success)\n        return rc;\n\n    if (stuff->deviceSpec == XkbUseCoreKbd)\n    {\n        DeviceIntPtr other;\n        for (other = inputInfo.devices; other; other = other->next)\n        {\n            if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))\n            {\n                rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);\n                if (rc == Success)\n                {\n                    rc = _XkbSetMapChecks(client, other, stuff, tmp);\n                    if (rc != Success)\n                        return rc;\n                }\n            }\n        }\n    }\n\n    \/* We know now that we will succed with the SetMap. In theory anyway. *\/\n    rc = _XkbSetMap(client, dev, stuff, tmp);\n    if (rc != Success)\n        return rc;\n\n    if (stuff->deviceSpec == XkbUseCoreKbd)\n    {\n        DeviceIntPtr other;\n        for (other = inputInfo.devices; other; other = other->next)\n        {\n            if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))\n            {\n                rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);\n                if (rc == Success)\n                    _XkbSetMap(client, other, stuff, tmp);\n                \/* ignore rc. if the SetMap failed although the check above\n                   reported true there isn't much we can do. we still need to\n                   set all other devices, hoping that at least they stay in\n                   sync. *\/\n            }\n        }\n    }\n\n    return client->noClientException;\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":430417,"func":"static int __parse_flow_nlattrs(const struct nlattr *attr,\n\t\t\t\tconst struct nlattr *a[],\n\t\t\t\tu64 *attrsp, bool log, bool nz)\n{\n\tconst struct nlattr *nla;\n\tu64 attrs;\n\tint rem;\n\n\tattrs = *attrsp;\n\tnla_for_each_nested(nla, attr, rem) {\n\t\tu16 type = nla_type(nla);\n\t\tint expected_len;\n\n\t\tif (type > OVS_KEY_ATTR_MAX) {\n\t\t\tOVS_NLERR(log, \"Key type %d is out of range max %d\",\n\t\t\t\t  type, OVS_KEY_ATTR_MAX);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (type == OVS_KEY_ATTR_PACKET_TYPE ||\n\t\t    type == OVS_KEY_ATTR_ND_EXTENSIONS ||\n\t\t    type == OVS_KEY_ATTR_TUNNEL_INFO) {\n\t\t\tOVS_NLERR(log, \"Key type %d is not supported\", type);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (attrs & (1ULL << type)) {\n\t\t\tOVS_NLERR(log, \"Duplicate key (type %d).\", type);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\texpected_len = ovs_key_lens[type].len;\n\t\tif (!check_attr_len(nla_len(nla), expected_len)) {\n\t\t\tOVS_NLERR(log, \"Key %d has unexpected len %d expected %d\",\n\t\t\t\t  type, nla_len(nla), expected_len);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (!nz || !is_all_zero(nla_data(nla), nla_len(nla))) {\n\t\t\tattrs |= 1ULL << type;\n\t\t\ta[type] = nla;\n\t\t}\n\t}\n\tif (rem) {\n\t\tOVS_NLERR(log, \"Message has %d unknown bytes.\", rem);\n\t\treturn -EINVAL;\n\t}\n\n\t*attrsp = attrs;\n\treturn 0;\n}","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":261442,"func":"static inline int decode_coeff_abs_level_greater1(thread_context* tctx,\n                                                  int cIdx, int i,\n                                                  bool firstCoeffInSubblock,\n                                                  bool firstSubblock,\n                                                  int  lastSubblock_greater1Ctx,\n                                                  int* lastInvocation_greater1Ctx,\n                                                  int* lastInvocation_coeff_abs_level_greater1_flag,\n                                                  int* lastInvocation_ctxSet, int c1)\n{\n  logtrace(LogSlice,\"# coeff_abs_level_greater1\\n\");\n\n  logtrace(LogSlice,\"  cIdx:%d i:%d firstCoeffInSB:%d firstSB:%d lastSB>1:%d last>1Ctx:%d lastLev>1:%d lastCtxSet:%d\\n\", cIdx,i,firstCoeffInSubblock,firstSubblock,lastSubblock_greater1Ctx,\n\t   *lastInvocation_greater1Ctx,\n\t   *lastInvocation_coeff_abs_level_greater1_flag,\n\t   *lastInvocation_ctxSet);\n\n  int lastGreater1Ctx;\n  int greater1Ctx;\n  int ctxSet;\n\n  logtrace(LogSlice,\"c1: %d\\n\",c1);\n\n  if (firstCoeffInSubblock) {\n    \/\/ block with real DC -> ctx 0\n    if (i==0 || cIdx>0) { ctxSet=0; }\n    else { ctxSet=2; }\n\n    if (firstSubblock) { lastGreater1Ctx=1; }\n    else { lastGreater1Ctx = lastSubblock_greater1Ctx; }\n\n    if (lastGreater1Ctx==0) { ctxSet++; }\n\n    logtrace(LogSlice,\"ctxSet: %d\\n\",ctxSet);\n\n    greater1Ctx=1;\n  }\n  else { \/\/ !firstCoeffInSubblock\n    ctxSet = *lastInvocation_ctxSet;\n    logtrace(LogSlice,\"ctxSet (old): %d\\n\",ctxSet);\n\n    greater1Ctx = *lastInvocation_greater1Ctx;\n    if (greater1Ctx>0) {\n      int lastGreater1Flag=*lastInvocation_coeff_abs_level_greater1_flag;\n      if (lastGreater1Flag==1) greater1Ctx=0;\n      else { \/*if (greater1Ctx>0)*\/ greater1Ctx++; }\n    }\n  }\n\n  ctxSet = c1; \/\/ use HM algo\n\n  int ctxIdxInc = (ctxSet*4) + (greater1Ctx>=3 ? 3 : greater1Ctx);\n\n  if (cIdx>0) { ctxIdxInc+=16; }\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &tctx->ctx_model[CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG + ctxIdxInc]);\n\n  *lastInvocation_greater1Ctx = greater1Ctx;\n  *lastInvocation_coeff_abs_level_greater1_flag = bit;\n  *lastInvocation_ctxSet = ctxSet;\n\n  \/\/logtrace(LogSymbols,\"$1 coeff_abs_level_greater1=%d\\n\",bit);\n\n  return bit;\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":279941,"func":"do_sub_msg(\n    int\t    count_only)\t\t\/\/ used 'n' flag for \":s\"\n{\n    \/*\n     * Only report substitutions when:\n     * - more than 'report' substitutions\n     * - command was typed by user, or number of changed lines > 'report'\n     * - giving messages is not disabled by 'lazyredraw'\n     *\/\n    if (((sub_nsubs > p_report && (KeyTyped || sub_nlines > 1 || p_report < 1))\n\t\t|| count_only)\n\t    && messaging())\n    {\n\tchar\t*msg_single;\n\tchar\t*msg_plural;\n\n\tif (got_int)\n\t    STRCPY(msg_buf, _(\"(Interrupted) \"));\n\telse\n\t    *msg_buf = NUL;\n\n\tmsg_single = count_only\n\t\t    ? NGETTEXT(\"%ld match on %ld line\",\n\t\t\t\t\t  \"%ld matches on %ld line\", sub_nsubs)\n\t\t    : NGETTEXT(\"%ld substitution on %ld line\",\n\t\t\t\t   \"%ld substitutions on %ld line\", sub_nsubs);\n\tmsg_plural = count_only\n\t\t    ? NGETTEXT(\"%ld match on %ld lines\",\n\t\t\t\t\t \"%ld matches on %ld lines\", sub_nsubs)\n\t\t    : NGETTEXT(\"%ld substitution on %ld lines\",\n\t\t\t\t  \"%ld substitutions on %ld lines\", sub_nsubs);\n\n\tvim_snprintf_add(msg_buf, sizeof(msg_buf),\n\t\t\t\t NGETTEXT(msg_single, msg_plural, sub_nlines),\n\t\t\t\t sub_nsubs, (long)sub_nlines);\n\n\tif (msg(msg_buf))\n\t    \/\/ save message to display it after redraw\n\t    set_keep_msg((char_u *)msg_buf, 0);\n\treturn TRUE;\n    }\n    if (got_int)\n    {\n\temsg(_(e_interrupted));\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":343313,"func":"void doestp(void)\n{\n    struct sockaddr_storage dataconn;\n    socklen_t socksize;\n    char hbuf[NI_MAXHOST];\n    char pbuf[NI_MAXSERV];\n\n    if (passive == 0 || datafd == -1) {\n        addreply_noformat(520, MSG_CANT_PASSIVE);\n        return;\n    }\n    if (xferfd == -1) {\n        opendata();\n        if (xferfd == -1) {\n            addreply_noformat(425, MSG_CANT_CREATE_DATA_SOCKET);\n            return;\n        }\n    }\n    socksize = (socklen_t) sizeof dataconn;\n    if (getpeername(xferfd, (struct sockaddr *) &dataconn, &socksize) < 0 ||\n        getnameinfo((struct sockaddr *) &dataconn, STORAGE_LEN(dataconn),\n                    hbuf, sizeof hbuf, pbuf, sizeof pbuf,\n                    NI_NUMERICHOST | NI_NUMERICSERV) != 0) {\n        addreply_noformat(425, MSG_GETSOCKNAME_DATA);\n        closedata();\n        return;\n    }\n    addreply(225, \"Connected to (|%c|%s|%s|)\",\n             STORAGE_FAMILY(dataconn) == AF_INET6 ? '2' : '1', hbuf, pbuf);\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":385818,"func":"int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)\n{\n\tstruct inode *inode = file_inode(file);\n\tlong ret;\n\n\tif (offset < 0 || len <= 0)\n\t\treturn -EINVAL;\n\n\t\/* Return error if mode is not supported *\/\n\tif (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))\n\t\treturn -EOPNOTSUPP;\n\n\t\/* Punch hole must have keep size set *\/\n\tif ((mode & FALLOC_FL_PUNCH_HOLE) &&\n\t    !(mode & FALLOC_FL_KEEP_SIZE))\n\t\treturn -EOPNOTSUPP;\n\n\tif (!(file->f_mode & FMODE_WRITE))\n\t\treturn -EBADF;\n\n\t\/* It's not possible punch hole on append only file *\/\n\tif (mode & FALLOC_FL_PUNCH_HOLE && IS_APPEND(inode))\n\t\treturn -EPERM;\n\n\tif (IS_IMMUTABLE(inode))\n\t\treturn -EPERM;\n\n\t\/*\n\t * Revalidate the write permissions, in case security policy has\n\t * changed since the files were opened.\n\t *\/\n\tret = security_file_permission(file, MAY_WRITE);\n\tif (ret)\n\t\treturn ret;\n\n\tif (S_ISFIFO(inode->i_mode))\n\t\treturn -ESPIPE;\n\n\t\/*\n\t * Let individual file system decide if it supports preallocation\n\t * for directories or not.\n\t *\/\n\tif (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))\n\t\treturn -ENODEV;\n\n\t\/* Check for wrap through zero too *\/\n\tif (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))\n\t\treturn -EFBIG;\n\n\tif (!file->f_op->fallocate)\n\t\treturn -EOPNOTSUPP;\n\n\tsb_start_write(inode->i_sb);\n\tret = file->f_op->fallocate(file, mode, offset, len);\n\tsb_end_write(inode->i_sb);\n\treturn ret;\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":210896,"func":"void *memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,\n                       int group_id)\n{\n    int slot_id;\n    int generation;\n    unsigned long h_virt;\n\n    MemSlot *slot;\n\n    if (group_id > info->num_memslots_groups) {\n        spice_critical(\"group_id too big\");\n        return NULL;\n    }\n\n    slot_id = memslot_get_id(info, addr);\n    if (slot_id > info->num_memslots) {\n        print_memslots(info);\n        spice_critical(\"slot_id %d too big, addr=%\" PRIx64, slot_id, addr);\n        return NULL;\n    }\n\n    slot = &info->mem_slots[group_id][slot_id];\n\n    generation = memslot_get_generation(info, addr);\n    if (generation != slot->generation) {\n        print_memslots(info);\n        spice_critical(\"address generation is not valid, group_id %d, slot_id %d, \"\n                       \"gen %d, slot_gen %d\",\n                       group_id, slot_id,\n                       generation, slot->generation);\n        return NULL;\n    }\n\n    h_virt = __get_clean_virt(info, addr);\n    h_virt += slot->address_delta;\n\n    if (!memslot_validate_virt(info, h_virt, slot_id, add_size, group_id)) {\n        return NULL;\n    }\n\n    return (void*)(uintptr_t)h_virt;\n}","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":226258,"func":"\nGF_Err fdpa_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_FDpacketBox *ptr = (GF_FDpacketBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_int(bs, ptr->info.sender_current_time_present, 1);\n\tgf_bs_write_int(bs, ptr->info.expected_residual_time_present, 1);\n\tgf_bs_write_int(bs, ptr->info.session_close_bit, 1);\n\tgf_bs_write_int(bs, ptr->info.object_close_bit, 1);\n\tgf_bs_write_int(bs, 0, 4);\n\tgf_bs_write_u16(bs, ptr->info.transport_object_identifier);\n\tgf_bs_write_u16(bs, ptr->header_ext_count);\n\tfor (i=0; i<ptr->header_ext_count; i++) {\n\t\tgf_bs_write_u8(bs, ptr->headers[i].header_extension_type);\n\t\tif (ptr->headers[i].header_extension_type > 127) {\n\t\t\tgf_bs_write_data(bs, (const char *) ptr->headers[i].content, 3);\n\t\t} else {\n\t\t\tgf_bs_write_u8(bs, ptr->headers[i].data_length ? (ptr->headers[i].data_length+2)\/4 : 0);\n\t\t\tif (ptr->headers[i].data_length) {\n\t\t\t\tgf_bs_write_data(bs, ptr->headers[i].data, ptr->headers[i].data_length);\n\t\t\t}\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":335098,"func":"static int skcipher_accept_parent_nokey(void *private, struct sock *sk)\n{\n\tstruct skcipher_ctx *ctx;\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct skcipher_tfm *tfm = private;\n\tstruct crypto_ablkcipher *skcipher = tfm->skcipher;\n\tunsigned int len = sizeof(*ctx) + crypto_ablkcipher_reqsize(skcipher);\n\n\tctx = sock_kmalloc(sk, len, GFP_KERNEL);\n\tif (!ctx)\n\t\treturn -ENOMEM;\n\n\tctx->iv = sock_kmalloc(sk, crypto_ablkcipher_ivsize(skcipher),\n\t\t\t       GFP_KERNEL);\n\tif (!ctx->iv) {\n\t\tsock_kfree_s(sk, ctx, len);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(ctx->iv, 0, crypto_ablkcipher_ivsize(skcipher));\n\n\n\tINIT_LIST_HEAD(&ctx->tsgl);\n\tctx->len = len;\n\tctx->used = 0;\n\tctx->more = 0;\n\tctx->merge = 0;\n\tctx->enc = 0;\n\taf_alg_init_completion(&ctx->completion);\n\n\task->private = ctx;\n\n\tablkcipher_request_set_tfm(&ctx->req, skcipher);\n\tablkcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG,\n\t\t\t\t\taf_alg_complete, &ctx->completion);\n\n\tsk->sk_destruct = skcipher_sock_destruct;\n\n\treturn 0;\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":500685,"func":"static sftp_message sftp_get_message(sftp_packet packet) {\n  sftp_session sftp = packet->sftp;\n  sftp_message msg = NULL;\n\n  sftp_enter_function();\n\n  msg = sftp_message_new(sftp);\n  if (msg == NULL) {\n    sftp_leave_function();\n    return NULL;\n  }\n\n  msg->sftp = packet->sftp;\n  msg->packet_type = packet->type;\n\n  if ((packet->type != SSH_FXP_STATUS) && (packet->type!=SSH_FXP_HANDLE) &&\n      (packet->type != SSH_FXP_DATA) && (packet->type != SSH_FXP_ATTRS) &&\n      (packet->type != SSH_FXP_NAME) && (packet->type != SSH_FXP_EXTENDED_REPLY)) {\n    ssh_set_error(packet->sftp->session, SSH_FATAL,\n        \"Unknown packet type %d\", packet->type);\n    sftp_message_free(msg);\n    sftp_leave_function();\n    return NULL;\n  }\n\n  if (buffer_get_u32(packet->payload, &msg->id) != sizeof(uint32_t)) {\n    ssh_set_error(packet->sftp->session, SSH_FATAL,\n        \"Invalid packet %d: no ID\", packet->type);\n    sftp_message_free(msg);\n    sftp_leave_function();\n    return NULL;\n  }\n\n  ssh_log(packet->sftp->session, SSH_LOG_PACKET,\n      \"Packet with id %d type %d\",\n      msg->id,\n      msg->packet_type);\n\n  if (buffer_add_data(msg->payload, buffer_get_rest(packet->payload),\n        buffer_get_rest_len(packet->payload)) < 0) {\n    ssh_set_error_oom(sftp->session);\n    sftp_message_free(msg);\n    sftp_leave_function();\n    return NULL;\n  }\n\n  sftp_leave_function();\n  return msg;\n}","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":310154,"func":"wrap_cursor(NCURSES_SP_DCL0)\n{\n    if (eat_newline_glitch) {\n\t\/*\n\t * xenl can manifest two different ways.  The vt100 way is that, when\n\t * you'd expect the cursor to wrap, it stays hung at the right margin\n\t * (on top of the character just emitted) and doesn't wrap until the\n\t * *next* graphic char is emitted.  The c100 way is to ignore LF\n\t * received just after an am wrap.\n\t *\n\t * An aggressive way to handle this would be to emit CR\/LF after the\n\t * char and then assume the wrap is done, you're on the first position\n\t * of the next line, and the terminal out of its weird state.  Here\n\t * it's safe to just tell the code that the cursor is in hyperspace and\n\t * let the next mvcur() call straighten things out.\n\t *\/\n\tSP_PARM->_curscol = -1;\n\tSP_PARM->_cursrow = -1;\n    } else if (auto_right_margin) {\n\tSP_PARM->_curscol = 0;\n\tSP_PARM->_cursrow++;\n\t\/*\n\t * We've actually moved - but may have to work around problems with\n\t * video attributes not working.\n\t *\/\n\tif (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP_PARM))) {\n\t    TR(TRACE_CHARPUT, (\"turning off (%#lx) %s before wrapping\",\n\t\t\t       (unsigned long) AttrOf(SCREEN_ATTRS(SP_PARM)),\n\t\t\t       _traceattr(AttrOf(SCREEN_ATTRS(SP_PARM)))));\n\t    VIDPUTS(SP_PARM, A_NORMAL, 0);\n\t}\n    } else {\n\tSP_PARM->_curscol--;\n    }\n    position_check(NCURSES_SP_ARGx\n\t\t   SP_PARM->_cursrow,\n\t\t   SP_PARM->_curscol,\n\t\t   \"wrap_cursor\");\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":259603,"func":"void HierarchicalBitmapRequester::AddImageScale(class Frame *frame,bool expandh,bool expandv)\n{\n#if ACCUSOFT_CODE\n  if (m_pLargestScale == NULL) {\n    assert(m_pSmallestScale == NULL);\n    assert(expandh == false && expandv == false);\n    \/\/ Actually, this is the smallest scale... as it is the first we build.\n    m_pLargestScale  = frame->BuildLineAdapter();\n    m_pSmallestScale = m_pLargestScale;\n    frame->SetImageBuffer(m_pLargestScale);\n  } else {\n    class LineMerger *merger;\n    \/\/ Two things need to be build: The adapter to the new band, and the merger\n    \/\/ that merges this band with the output and scales the result\n    \/\/ apropriately.\n    assert(m_pTempAdapter == NULL);\n    \/\/ This object will pull out lines from the new high-pass...\n    m_pTempAdapter   = frame->BuildLineAdapter();\n    \/\/ ...and this guy will merge them with what we currently have.\n    merger           = new(m_pEnviron) class LineMerger(frame,m_pLargestScale,m_pTempAdapter,\n                                                        expandh,expandv);\n    \/\/\n    \/\/ And this becomes the next largest scale.\n    m_pLargestScale  = merger;\n    \/\/ and controls now the life-time of its children.\n    frame->SetImageBuffer(m_pTempAdapter);\n    m_pTempAdapter   = NULL; \n  }\n#else\n  NOREF(frame);\n  NOREF(expandh);\n  NOREF(expandv);\n#endif\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":492672,"func":"_vte_terminal_clear_above_current (VteTerminal *terminal)\n{\n\tVteRowData *rowdata;\n\tlong i;\n\tVteScreen *screen;\n\tscreen = terminal->pvt->screen;\n\t\/* If the cursor is actually on the screen, clear data in the row\n\t * which corresponds to the cursor. *\/\n\tfor (i = screen->insert_delta; i < screen->cursor_current.row; i++) {\n\t\tif (_vte_ring_next(screen->row_data) > i) {\n\t\t\t\/* Get the data for the row we're erasing. *\/\n\t\t\trowdata = _vte_ring_index_writable (screen->row_data, i);\n\t\t\tg_assert(rowdata != NULL);\n\t\t\t\/* Remove it. *\/\n\t\t\t_vte_row_data_shrink (rowdata, 0);\n\t\t\t\/* Add new cells until we fill the row. *\/\n\t\t\t_vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count);\n\t\t\trowdata->attr.soft_wrapped = 0;\n\t\t\t\/* Repaint the row. *\/\n\t\t\t_vte_invalidate_cells(terminal,\n\t\t\t\t\t0, terminal->column_count, i, 1);\n\t\t}\n\t}\n\t\/* We've modified the display.  Make a note of it. *\/\n\tterminal->pvt->text_deleted_flag = TRUE;\n}","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":219922,"func":"GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumber, GF_ISOTrackID SourceTrackID, u32 StreamDescriptionIndex, u16 DataLength, u32 offsetInDescription, u8 AtBegin)\n{\n\tGF_TrackBox *trak;\n\tGF_HintSampleEntryBox *entry;\n\tu32 count;\n\tu16 refIndex;\n\tGF_HintPacket *pck;\n\tGF_StreamDescDTE *dte;\n\tGF_Err e;\n\tGF_TrackReferenceTypeBox *hint;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM;\n\n\te = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count);\n\tif (e) return e;\n\tif (!entry->hint_sample) return GF_BAD_PARAM;\n\tcount = gf_list_count(entry->hint_sample->packetTable);\n\tif (!count) return GF_BAD_PARAM;\n\tpck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1);\n\n\tdte = (GF_StreamDescDTE *) NewDTE(3);\n\tdte->byteOffset = offsetInDescription;\n\tdte->dataLength = DataLength;\n\tdte->streamDescIndex = StreamDescriptionIndex;\n\tif (SourceTrackID == trak->Header->trackID) {\n\t\tdte->trackRefIndex = (s8) -1;\n\t} else {\n\t\t\/\/get (or set) the track reference index\n\t\te = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint);\n\t\tif (e) return e;\n\t\te = reftype_AddRefTrack(hint, SourceTrackID, &refIndex);\n\t\tif (e) return e;\n\t\t\/\/WARNING: IN QT, MUST BE 0-based !!!\n\t\tdte->trackRefIndex = (u8) (refIndex - 1);\n\t}\n\treturn gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin);\n}","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":492678,"func":"vte_sequence_handler_cs (VteTerminal *terminal, GValueArray *params)\n{\n\tlong start=-1, end=-1, rows;\n\tGValue *value;\n\tVteScreen *screen;\n\n\t_vte_terminal_home_cursor (terminal);\n\n\t\/* We require two parameters.  Anything less is a reset. *\/\n\tscreen = terminal->pvt->screen;\n\tif ((params == NULL) || (params->n_values < 2)) {\n\t\tscreen->scrolling_restricted = FALSE;\n\t\treturn;\n\t}\n\t\/* Extract the two values. *\/\n\tvalue = g_value_array_get_nth(params, 0);\n\tif (G_VALUE_HOLDS_LONG(value)) {\n\t\tstart = g_value_get_long(value);\n\t}\n\tvalue = g_value_array_get_nth(params, 1);\n\tif (G_VALUE_HOLDS_LONG(value)) {\n\t\tend = g_value_get_long(value);\n\t}\n\t\/* Catch garbage. *\/\n\trows = terminal->row_count;\n\tif (start <= 0 || start >= rows) {\n\t\tstart = 0;\n\t}\n\tif (end <= 0 || end >= rows) {\n\t\tend = rows - 1;\n\t}\n\t\/* Set the right values. *\/\n\tscreen->scrolling_region.start = start;\n\tscreen->scrolling_region.end = end;\n\tscreen->scrolling_restricted = TRUE;\n\t\/* Special case -- run wild, run free. *\/\n\tif (screen->scrolling_region.start == 0 &&\n\t    screen->scrolling_region.end == rows - 1) {\n\t\tscreen->scrolling_restricted = FALSE;\n\t}\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":437293,"func":"print_anchor(FILE* f, int anchor)\n{\n  int q = 0;\n\n  fprintf(f, \"[\");\n\n  if (anchor & ANCHOR_BEGIN_BUF) {\n    fprintf(f, \"begin-buf\");\n    q = 1;\n  }\n  if (anchor & ANCHOR_BEGIN_LINE) {\n    if (q) fprintf(f, \", \");\n    q = 1;\n    fprintf(f, \"begin-line\");\n  }\n  if (anchor & ANCHOR_BEGIN_POSITION) {\n    if (q) fprintf(f, \", \");\n    q = 1;\n    fprintf(f, \"begin-pos\");\n  }\n  if (anchor & ANCHOR_END_BUF) {\n    if (q) fprintf(f, \", \");\n    q = 1;\n    fprintf(f, \"end-buf\");\n  }\n  if (anchor & ANCHOR_SEMI_END_BUF) {\n    if (q) fprintf(f, \", \");\n    q = 1;\n    fprintf(f, \"semi-end-buf\");\n  }\n  if (anchor & ANCHOR_END_LINE) {\n    if (q) fprintf(f, \", \");\n    q = 1;\n    fprintf(f, \"end-line\");\n  }\n  if (anchor & ANCHOR_ANYCHAR_INF) {\n    if (q) fprintf(f, \", \");\n    q = 1;\n    fprintf(f, \"anychar-inf\");\n  }\n  if (anchor & ANCHOR_ANYCHAR_INF_ML) {\n    if (q) fprintf(f, \", \");\n    fprintf(f, \"anychar-inf-ml\");\n  }\n\n  fprintf(f, \"]\");\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":482553,"func":"putChar(const FileInfo *file, widechar c, TranslationTableHeader **table,\n\t\tTranslationTableOffset *characterOffset) {\n\t\/* See if a character is in the appropriate table. If not, insert it. In either case,\n\t * return a pointer to it. *\/\n\tTranslationTableCharacter *character;\n\tTranslationTableOffset offset;\n\tif ((character = getChar(c, *table, characterOffset))) return character;\n\tif (!allocateSpaceInTranslationTable(file, &offset, sizeof(*character), table))\n\t\treturn NULL;\n\tcharacter = (TranslationTableCharacter *)&(*table)->ruleArea[offset];\n\tmemset(character, 0, sizeof(*character));\n\tcharacter->sourceFile = file->sourceFile;\n\tcharacter->sourceLine = file->lineNumber;\n\tcharacter->value = c;\n\tconst unsigned long int charHash = _lou_charHash(c);\n\tconst TranslationTableOffset bucket = (*table)->characters[charHash];\n\tif (!bucket)\n\t\t(*table)->characters[charHash] = offset;\n\telse {\n\t\tTranslationTableCharacter *oldchar =\n\t\t\t\t(TranslationTableCharacter *)&(*table)->ruleArea[bucket];\n\t\twhile (oldchar->next)\n\t\t\toldchar = (TranslationTableCharacter *)&(*table)->ruleArea[oldchar->next];\n\t\toldchar->next = offset;\n\t}\n\tif (characterOffset) *characterOffset = offset;\n\treturn character;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":386560,"func":"void DL_Dxf::addMText(DL_CreationInterface* creationInterface) {\n    double angle = 0.0;\n\n    if (hasValue(50)) {\n        if (libVersion<=0x02000200) {\n            \/\/ wrong but compatible with dxflib <=2.0.2.0 (angle stored in rad):\n            angle = getRealValue(50, 0.0);\n        } else {\n            angle = (getRealValue(50, 0.0)*2*M_PI)\/360.0;\n        }\n    } else if (hasValue(11) && hasValue(21)) {\n        double x = getRealValue(11, 0.0);\n        double y = getRealValue(21, 0.0);\n\n        if (fabs(x)<1.0e-6) {\n            if (y>0.0) {\n                angle = M_PI\/2.0;\n            } else {\n                angle = M_PI\/2.0*3.0;\n            }\n        } else {\n            angle = atan(y\/x);\n        }\n    }\n\n    DL_MTextData d(\n        \/\/ insertion point\n        getRealValue(10, 0.0),\n        getRealValue(20, 0.0),\n        getRealValue(30, 0.0),\n        \/\/ X direction vector\n        getRealValue(11, 0.0),\n        getRealValue(21, 0.0),\n        getRealValue(31, 0.0),\n        \/\/ height\n        getRealValue(40, 2.5),\n        \/\/ width\n        getRealValue(41, 0.0),\n        \/\/ attachment point\n        getIntValue(71, 1),\n        \/\/ drawing direction\n        getIntValue(72, 1),\n        \/\/ line spacing style\n        getIntValue(73, 1),\n        \/\/ line spacing factor\n        getRealValue(44, 1.0),\n        \/\/ text\n        getStringValue(1, \"\"),\n        \/\/ style\n        getStringValue(7, \"\"),\n        \/\/ angle\n        angle);\n    creationInterface->addMText(d);\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":220928,"func":"static void mpgviddmx_finalize(GF_Filter *filter)\n{\n\tGF_MPGVidDmxCtx *ctx = gf_filter_get_udta(filter);\n\tif (ctx->bs) gf_bs_del(ctx->bs);\n\tif (ctx->vparser) gf_m4v_parser_del_no_bs(ctx->vparser);\n\tif (ctx->indexes) gf_free(ctx->indexes);\n\tif (ctx->hdr_store) gf_free(ctx->hdr_store);\n\tif (ctx->pck_queue) {\n\t\twhile (gf_list_count(ctx->pck_queue)) {\n\t\t\tGF_FilterPacket *pck = gf_list_pop_back(ctx->pck_queue);\n\t\t\tgf_filter_pck_discard(pck);\n\t\t}\n\t\tgf_list_del(ctx->pck_queue);\n\t}\n\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\tif (ctx->importer) {\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, (\"%s Import results: %d VOPs (%d Is - %d Ps - %d Bs)\\n\", ctx->is_mpg12 ? \"MPEG-1\/2\" : \"MPEG-4 (Part 2)\", ctx->nb_frames, ctx->nb_i, ctx->nb_p, ctx->nb_b));\n\t\tif (ctx->nb_b) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, (\"\\t%d max consecutive B-frames%s\\n\", ctx->max_b, ctx->is_packed ? \" - packed bitstream\" : \"\" ));\n\t\t}\n\t\tif (ctx->is_vfr && ctx->nb_b && ctx->is_packed) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, (\"Warning: Mix of non-coded frames: packed bitstream and encoder skiped - unpredictable timing\\n\"));\n\t\t}\n\t}\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":264648,"func":"GF_Err gf_bifs_flush_command_list(GF_BifsDecoder *codec)\n{\n\tGF_BitStream *bs;\n\tGF_Err e;\n\tCommandBufferItem *cbi;\n\tGF_SceneGraph *prev_root = codec->current_graph;\n\tM_QuantizationParameter *prev_qp = codec->ActiveQP;\n\tu32 prev_qp_count = gf_list_count(codec->QPs);\n\tu32 NbPass = gf_list_count(codec->command_buffers);\n\n\n\tcodec->ActiveQP = NULL;\n\tGF_List *nextPass = gf_list_new();\n\twhile (NbPass) {\n\t\twhile (gf_list_count(codec->command_buffers)) {\n\t\t\tcbi = (CommandBufferItem *)gf_list_get(codec->command_buffers, 0);\n\t\t\tgf_list_rem(codec->command_buffers, 0);\n\n\t\t\tcodec->current_graph = gf_node_get_graph(cbi->node);\n\t\t\te = GF_OK;\n\t\t\tif (cbi->cb->bufferSize) {\n\t\t\t\tbs = gf_bs_new((char*)cbi->cb->buffer, cbi->cb->bufferSize, GF_BITSTREAM_READ);\n\t\t\t\tgf_bs_set_eos_callback(bs, BM_EndOfStream, codec);\n\t\t\t\te = BM_ParseCommand(codec, bs, cbi->cb->commandList);\n\t\t\t\tgf_bs_del(bs);\n\t\t\t}\n\t\t\tif (!e) {\n\t\t\t\tgf_node_unregister(cbi->node, NULL);\n\t\t\t\tgf_free(cbi);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/*this may be an error or a dependency pb - reset coimmand list and move to next pass*\/\n\t\t\twhile (gf_list_count(cbi->cb->commandList)) {\n\t\t\t\tu32 i;\n\t\t\t\tGF_CommandField *cf;\n\t\t\t\tGF_Command *com = (GF_Command *)gf_list_get(cbi->cb->commandList, 0);\n\t\t\t\tgf_list_rem(cbi->cb->commandList, 0);\n\t\t\t\tcf = (GF_CommandField *) gf_list_get(com->command_fields, 0);\n\t\t\t\tif (cf && cf->fieldType==GF_SG_VRML_SFCOMMANDBUFFER) {\n\t\t\t\t\tfor (i=0; i<gf_list_count(codec->command_buffers); i++) {\n\t\t\t\t\t\tCommandBufferItem *cbi2 = (CommandBufferItem *)gf_list_get(codec->command_buffers, i);\n\t\t\t\t\t\tif (cbi2->cb == cf->field_ptr) {\n\t\t\t\t\t\t\tgf_node_unregister(cbi2->node, NULL);\n\t\t\t\t\t\t\tgf_free(cbi2);\n\t\t\t\t\t\t\tgf_list_rem(codec->command_buffers, i);\n\t\t\t\t\t\t\ti--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgf_sg_command_del(com);\n\t\t\t}\n\t\t\tgf_list_add(nextPass, cbi);\n\t\t}\n\t\tif (!gf_list_count(nextPass)) break;\n\t\t\/*prepare next pass*\/\n\t\twhile (gf_list_count(nextPass)) {\n\t\t\tcbi = (CommandBufferItem *)gf_list_get(nextPass, 0);\n\t\t\tgf_list_rem(nextPass, 0);\n\t\t\tgf_list_add(codec->command_buffers, cbi);\n\t\t}\n\t\tNbPass --;\n\t\tif (NbPass > gf_list_count(codec->command_buffers)) NbPass = gf_list_count(codec->command_buffers);\n\n\t\t\/\/restore QP state\n\t\twhile (gf_list_count(codec->QPs) > prev_qp_count) {\n\t\t\tgf_list_rem(codec->QPs, 0); \/\/QPs are inserted at head of list\n\t\t}\n\t\tcodec->ActiveQP = NULL;\n\t\tcodec->LastError = GF_OK;\n\t}\n\tgf_list_del(nextPass);\n\tcodec->current_graph = prev_root;\n\tcodec->ActiveQP = prev_qp;\n\treturn GF_OK;\n}","target":0,"code_token_length":774,"total_token_length":1010,"max_tokens_setting":1024}
+{"idx":224486,"func":"static GF_Err txtin_webvtt_setup(GF_Filter *filter, GF_TXTIn *ctx)\n{\n\tGF_Err e;\n\tu32 ID, OCR_ES_ID, file_size, w, h;\n\tBool is_srt;\n\tchar *ext;\n\n\tctx->src = gf_fopen(ctx->file_name, \"rb\");\n\tif (!ctx->src) return GF_URL_ERROR;\n\n\tfile_size = (u32) gf_fsize(ctx->src);\n\n\tctx->unicode_type = gf_text_get_utf_type(ctx->src);\n\tif (ctx->unicode_type<0) {\n\t\tgf_fclose(ctx->src);\n\t\tctx->src = NULL;\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] Unsupported SRT UTF encoding\\n\"));\n\t\treturn GF_NOT_SUPPORTED;\n\t}\n\text = gf_file_ext_start(ctx->file_name);\n\tis_srt = (ext && !strnicmp(ext, \".srt\", 4)) ? GF_TRUE : GF_FALSE;\n\n\n\tif (!ctx->timescale) ctx->timescale = 1000;\n\tOCR_ES_ID = ID = 0;\n\n\tif (!ctx->opid) ctx->opid = gf_filter_pid_new(filter);\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_TEXT) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, &PROP_UINT(GF_CODECID_WEBVTT) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(ctx->timescale) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DOWN_SIZE, &PROP_LONGUINT(file_size) );\n\n\tw = ctx->width;\n\th = ctx->height;\n\tif (!ID) ID = 1;\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ID, &PROP_UINT(ID) );\n\tif (OCR_ES_ID) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CLOCK_ID, &PROP_UINT(OCR_ES_ID) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH, &PROP_UINT(w) );\n\tgf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT, &PROP_UINT(h) );\n\tif (ctx->zorder) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ZORDER, &PROP_SINT(ctx->zorder) );\n\tif (ctx->lang) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_LANGUAGE, &PROP_STRING( ctx->lang) );\n\n\tctx->vttparser = gf_webvtt_parser_new();\n\n\te = gf_webvtt_parser_init(ctx->vttparser, ctx->src, ctx->unicode_type, is_srt, ctx, gf_webvtt_import_report, gf_webvtt_flush_sample, gf_webvtt_import_header);\n\tif (e != GF_OK) {\n\t\tgf_webvtt_parser_del(ctx->vttparser);\n\t\tctx->vttparser = NULL;\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, (\"[TXTIn] WebVTT parser init error %s\\n\", gf_error_to_string(e) ));\n\t}\n\t\/\/get the header\n\te = gf_webvtt_parser_parse(ctx->vttparser);\n\n\ttxtin_probe_duration(ctx);\n\treturn e;\n}","target":0,"code_token_length":699,"total_token_length":935,"max_tokens_setting":1024}
+{"idx":233883,"func":" *\/\nstatic void php_wddx_process_data(void *user_data, const XML_Char *s, int len)\n{\n\tst_entry *ent;\n\twddx_stack *stack = (wddx_stack *)user_data;\n\n\tif (!wddx_stack_is_empty(stack) && !stack->done) {\n\t\twddx_stack_top(stack, (void**)&ent);\n\t\tswitch (ent->type) {\n\t\t\tcase ST_BINARY:\n\t\t\tcase ST_STRING:\n\t\t\t\tif (Z_STRLEN(ent->data) == 0) {\n\t\t\t\t\tzval_ptr_dtor(&ent->data);\n\t\t\t\t\tZVAL_STRINGL(&ent->data, (char *)s, len);\n\t\t\t\t} else {\n\t\t\t\t\tZ_STR(ent->data) = zend_string_extend(Z_STR(ent->data), Z_STRLEN(ent->data) + len, 0);\n\t\t\t\t\tmemcpy(Z_STRVAL(ent->data) + Z_STRLEN(ent->data) - len, (char *)s, len);\n\t\t\t\t\tZ_STRVAL(ent->data)[Z_STRLEN(ent->data)] = '\\0';\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase ST_NUMBER:\n\t\t\t\tZVAL_STRINGL(&ent->data, (char *)s, len);\n\t\t\t\tconvert_scalar_to_number(&ent->data);\n\t\t\t\tbreak;\n\n\t\t\tcase ST_BOOLEAN:\n\t\t\t\tif (!strcmp((char *)s, \"true\")) {\n\t\t\t\t\tZVAL_TRUE(&ent->data);\n\t\t\t\t} else if (!strcmp((char *)s, \"false\")) {\n\t\t\t\t\tZVAL_FALSE(&ent->data);\n\t\t\t\t} else {\n\t\t\t\t\tzval_ptr_dtor(&ent->data);\n\t\t\t\t\tif (ent->varname) {\n\t\t\t\t\t\tefree(ent->varname);\n\t\t\t\t\t\tent->varname = NULL;\n\t\t\t\t\t}\n\t\t\t\t\tZVAL_UNDEF(&ent->data);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase ST_DATETIME: {\n\t\t\t\tchar *tmp;\n\n\t\t\t\ttmp = emalloc(len + 1);\n\t\t\t\tmemcpy(tmp, (char *)s, len);\n\t\t\t\ttmp[len] = '\\0';\n\n\t\t\t\tZ_LVAL(ent->data) = php_parse_date(tmp, NULL);\n\t\t\t\t\/* date out of range < 1969 or > 2038 *\/\n\t\t\t\tif (Z_LVAL(ent->data) == -1) {\n\t\t\t\t\tZVAL_STRINGL(&ent->data, (char *)s, len);\n\t\t\t\t}\n\t\t\t\tefree(tmp);\n\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":265538,"func":"void *mempool_getbuffer(MemoryPoolHandle handle, size_t expected_buffer_size) {\n  int rc;\n  int bufs_to_allocate;\n  int bufs_that_can_be_allocated = 0;\n  struct memory_pool_element *pool_item = NULL;\n  struct mempool *pool = (struct mempool *)handle;\n  char *log_msg_fmt =\n      \"mempool(%p): mempool_getbuffer called for invalid \"\n      \"expected_buffer_size(%zu), current pool manages only \"\n      \"mempool_item_size(%zu)\";\n  char log_msg[300];\n\n  if (pool == NULL) {\n    return NULL;\n  }\n\n  if (pool->mempool_item_size != expected_buffer_size) {\n    \/\/ This should never happen unless mempool is used wrongly.\n    if (pool->log_callback_func) {\n      snprintf(log_msg, sizeof(log_msg), log_msg_fmt, (void *)pool,\n               expected_buffer_size, pool->mempool_item_size);\n      pool->log_callback_func(MEMPOOL_LOG_FATAL, log_msg);\n      return NULL;\n    }\n  }\n\n  if ((pool->flags & ENABLE_LOCKING) != 0) {\n    pthread_mutex_lock(&pool->lock);\n  }\n\n  \/* If the free list is empty then expand the pool's free list *\/\n  if (pool->free_bufs_in_pool == 0) {\n    bufs_to_allocate = pool->expandable_size \/ pool->mempool_item_size;\n    bufs_that_can_be_allocated = pool_can_expand_by(pool);\n    if (bufs_that_can_be_allocated > 0) {\n      \/* We can at least allocate\n         min(bufs_that_can_be_allocated, bufs_to_allocate) *\/\n      bufs_to_allocate = ((bufs_to_allocate > bufs_that_can_be_allocated)\n                              ? bufs_that_can_be_allocated\n                              : bufs_to_allocate);\n\n      rc = freelist_allocate(pool, bufs_to_allocate);\n      if (rc != 0) {\n        if ((pool->flags & ENABLE_LOCKING) != 0) {\n          pthread_mutex_unlock(&pool->lock);\n        }\n        return NULL;\n      }\n    } else {\n      \/* We cannot allocate any more buffers, reached max threshold *\/\n      if ((pool->flags & ENABLE_LOCKING) != 0) {\n        pthread_mutex_unlock(&pool->lock);\n      }\n      return NULL;\n    }\n  }\n\n  \/* Done with expansion of pool in case of pre allocated pools *\/\n\n  \/* Logic of allocation from free list *\/\n  \/* If there is an item on the pool's free list, then take that... *\/\n  if (pool->free_list != NULL) {\n    pool_item = pool->free_list;\n    pool->free_list = pool_item->next;\n    pool_item->next = (struct memory_pool_element *)NULL;\n    pool->free_bufs_in_pool--;\n  }\n\n  if (pool_item) {\n    pool->number_of_bufs_shared++;\n  }\n\n  if ((pool->flags & ENABLE_LOCKING) != 0) {\n    pthread_mutex_unlock(&pool->lock);\n  }\n\n  return (void *)pool_item;\n}","target":0,"code_token_length":653,"total_token_length":889,"max_tokens_setting":1024}
+{"idx":385875,"func":"static int path_lookupat(int dfd, const char *name,\n\t\t\t\tunsigned int flags, struct nameidata *nd)\n{\n\tstruct file *base = NULL;\n\tstruct path path;\n\tint err;\n\n\t\/*\n\t * Path walking is largely split up into 2 different synchronisation\n\t * schemes, rcu-walk and ref-walk (explained in\n\t * Documentation\/filesystems\/path-lookup.txt). These share much of the\n\t * path walk code, but some things particularly setup, cleanup, and\n\t * following mounts are sufficiently divergent that functions are\n\t * duplicated. Typically there is a function foo(), and its RCU\n\t * analogue, foo_rcu().\n\t *\n\t * -ECHILD is the error number of choice (just to avoid clashes) that\n\t * is returned if some aspect of an rcu-walk fails. Such an error must\n\t * be handled by restarting a traditional ref-walk (which will always\n\t * be able to complete).\n\t *\/\n\terr = path_init(dfd, name, flags | LOOKUP_PARENT, nd, &base);\n\n\tif (unlikely(err))\n\t\treturn err;\n\n\tcurrent->total_link_count = 0;\n\terr = link_path_walk(name, nd);\n\n\tif (!err && !(flags & LOOKUP_PARENT)) {\n\t\terr = lookup_last(nd, &path);\n\t\twhile (err > 0) {\n\t\t\tvoid *cookie;\n\t\t\tstruct path link = path;\n\t\t\terr = may_follow_link(&link, nd);\n\t\t\tif (unlikely(err))\n\t\t\t\tbreak;\n\t\t\tnd->flags |= LOOKUP_PARENT;\n\t\t\terr = follow_link(&link, nd, &cookie);\n\t\t\tif (err)\n\t\t\t\tbreak;\n\t\t\terr = lookup_last(nd, &path);\n\t\t\tput_link(nd, &link, cookie);\n\t\t}\n\t}\n\n\tif (!err)\n\t\terr = complete_walk(nd);\n\n\tif (!err && nd->flags & LOOKUP_DIRECTORY) {\n\t\tif (!can_lookup(nd->inode)) {\n\t\t\tpath_put(&nd->path);\n\t\t\terr = -ENOTDIR;\n\t\t}\n\t}\n\n\tif (base)\n\t\tfput(base);\n\n\tif (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {\n\t\tpath_put(&nd->root);\n\t\tnd->root.mnt = NULL;\n\t}\n\treturn err;\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":292227,"func":"inbound_next_nick (session *sess, char *nick, int error,\n\t\t\t\t\t\t const message_tags_data *tags_data)\n{\n\tchar *newnick;\n\tserver *serv = sess->server;\n\tircnet *net;\n\n\tserv->nickcount++;\n\n\tswitch (serv->nickcount)\n\t{\n\tcase 2:\n\t\tnewnick = prefs.hex_irc_nick2;\n\t\tnet = serv->network;\n\t\t\/* use network specific \"Second choice\"? *\/\n\t\tif (net && !(net->flags & FLAG_USE_GLOBAL) && net->nick2)\n\t\t{\n\t\t\tnewnick = net->nick2;\n\t\t}\n\t\tserv->p_change_nick (serv, newnick);\n\t\tif (error)\n\t\t{\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_NICKERROR, sess, nick, newnick, NULL, NULL,\n\t\t\t\t\t\t\t\t\t\t  0, tags_data->timestamp);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_NICKCLASH, sess, nick, newnick, NULL, NULL,\n\t\t\t\t\t\t\t\t\t\t  0, tags_data->timestamp);\n\t\t}\n\t\tbreak;\n\n\tcase 3:\n\t\tserv->p_change_nick (serv, prefs.hex_irc_nick3);\n\t\tif (error)\n\t\t{\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_NICKERROR, sess, nick, prefs.hex_irc_nick3,\n\t\t\t\t\t\t\t\t\t\t  NULL, NULL, 0, tags_data->timestamp);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_NICKCLASH, sess, nick, prefs.hex_irc_nick3,\n\t\t\t\t\t\t\t\t\t\t  NULL, NULL, 0, tags_data->timestamp);\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_NICKFAIL, sess, NULL, NULL, NULL, NULL, 0,\n\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\t}\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":313850,"func":"get_visual_text(\n    cmdarg_T\t*cap,\n    char_u\t**pp,\t    \/\/ return: start of selected text\n    int\t\t*lenp)\t    \/\/ return: length of selected text\n{\n    if (VIsual_mode != 'V')\n\tunadjust_for_sel();\n    if (VIsual.lnum != curwin->w_cursor.lnum)\n    {\n\tif (cap != NULL)\n\t    clearopbeep(cap->oap);\n\treturn FAIL;\n    }\n    if (VIsual_mode == 'V')\n    {\n\t*pp = ml_get_curline();\n\t*lenp = (int)STRLEN(*pp);\n    }\n    else\n    {\n\tif (LT_POS(curwin->w_cursor, VIsual))\n\t{\n\t    *pp = ml_get_pos(&curwin->w_cursor);\n\t    *lenp = VIsual.col - curwin->w_cursor.col + 1;\n\t}\n\telse\n\t{\n\t    *pp = ml_get_pos(&VIsual);\n\t    *lenp = curwin->w_cursor.col - VIsual.col + 1;\n\t}\n\tif (**pp == NUL)\n\t    *lenp = 0;\n\tif (*lenp > 0)\n\t{\n\t    if (has_mbyte)\n\t\t\/\/ Correct the length to include all bytes of the last\n\t\t\/\/ character.\n\t\t*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;\n\t    else if ((*pp)[*lenp - 1] == NUL)\n\t\t\/\/ Do not include a trailing NUL.\n\t\t*lenp -= 1;\n\t}\n    }\n    reset_VIsual_and_resel();\n    return OK;\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":443693,"func":"init(void)\n{\n#ifdef USE_CALLOUT\n\n    int id;\n    OnigEncoding enc;\n    char* name;\n    unsigned int args[4];\n    OnigValue    opts[4];\n\n    enc = ONIG_ENCODING_UTF16_LE;\n\n    name = \"F\\000A\\000I\\000L\\000\\000\\000\";            BC0_P(name, fail);\n    name = \"M\\000I\\000S\\000M\\000A\\000T\\000C\\000H\\000\\000\\000\"; BC0_P(name, mismatch);\n\n    name = \"M\\000A\\000X\\000\\000\\000\";\n    args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\n    args[1] = ONIG_TYPE_CHAR;\n    opts[0].c = 'X';\n    BC_B_O(name, max, 2, args, 1, opts);\n\n    name = \"E\\000R\\000R\\000O\\000R\\000\\000\\000\";\n    args[0] = ONIG_TYPE_LONG; opts[0].l = ONIG_ABORT;\n    BC_P_O(name, error, 1, args, 1, opts);\n\n    name = \"C\\000O\\000U\\000N\\000T\\000\\000\\000\";\n    args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';\n    BC_B_O(name, count, 1, args, 1, opts);\n\n    name = \"T\\000O\\000T\\000A\\000L\\000_\\000C\\000O\\000U\\000N\\000T\\000\\000\\000\";\n    args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';\n    BC_B_O(name, total_count, 1, args, 1, opts);\n\n    name = \"C\\000M\\000P\\000\\000\\000\";\n    args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\n    args[1] = ONIG_TYPE_STRING;\n    args[2] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\n    BC_P(name, cmp, 3, args);\n\n#endif \/* USE_CALLOUT *\/\n\n  return ONIG_NORMAL;\n}","target":0,"code_token_length":590,"total_token_length":826,"max_tokens_setting":1024}
+{"idx":312399,"func":"call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long end_idx)\n{\n    callback_T\t*cb = &qftf_cb;\n    list_T\t*qftf_list = NULL;\n    static int\trecursive = FALSE;\n\n    if (recursive)\n\treturn NULL;  \/\/ this doesn't work properly recursively\n    recursive = TRUE;\n\n    \/\/ If 'quickfixtextfunc' is set, then use the user-supplied function to get\n    \/\/ the text to display. Use the local value of 'quickfixtextfunc' if it is\n    \/\/ set.\n    if (qfl->qf_qftf_cb.cb_name != NULL)\n\tcb = &qfl->qf_qftf_cb;\n    if (cb->cb_name != NULL)\n    {\n\ttypval_T\targs[1];\n\tdict_T\t\t*d;\n\ttypval_T\trettv;\n\n\t\/\/ create the dict argument\n\tif ((d = dict_alloc_lock(VAR_FIXED)) == NULL)\n\t{\n\t    recursive = FALSE;\n\t    return NULL;\n\t}\n\tdict_add_number(d, \"quickfix\", (long)IS_QF_LIST(qfl));\n\tdict_add_number(d, \"winid\", (long)qf_winid);\n\tdict_add_number(d, \"id\", (long)qfl->qf_id);\n\tdict_add_number(d, \"start_idx\", start_idx);\n\tdict_add_number(d, \"end_idx\", end_idx);\n\t++d->dv_refcount;\n\targs[0].v_type = VAR_DICT;\n\targs[0].vval.v_dict = d;\n\n\tqftf_list = NULL;\n\tif (call_callback(cb, 0, &rettv, 1, args) != FAIL)\n\t{\n\t    if (rettv.v_type == VAR_LIST)\n\t    {\n\t\tqftf_list = rettv.vval.v_list;\n\t\tqftf_list->lv_refcount++;\n\t    }\n\t    clear_tv(&rettv);\n\t}\n\tdict_unref(d);\n    }\n\n    recursive = FALSE;\n    return qftf_list;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":328942,"func":"R_API ut64 r_bin_java_element_value_calc_size(RBinJavaElementValue *element_value) {\n\tRListIter *iter, *iter_tmp;\n\tRBinJavaElementValue *ev_element;\n\tRBinJavaElementValuePair *evps;\n\tut64 sz = 0;\n\tif (!element_value) {\n\t\treturn sz;\n\t}\n\t\/\/ tag\n\tsz += 1;\n\tswitch (element_value->tag) {\n\tcase R_BIN_JAVA_EV_TAG_BYTE:\n\tcase R_BIN_JAVA_EV_TAG_CHAR:\n\tcase R_BIN_JAVA_EV_TAG_DOUBLE:\n\tcase R_BIN_JAVA_EV_TAG_FLOAT:\n\tcase R_BIN_JAVA_EV_TAG_INT:\n\tcase R_BIN_JAVA_EV_TAG_LONG:\n\tcase R_BIN_JAVA_EV_TAG_SHORT:\n\tcase R_BIN_JAVA_EV_TAG_BOOLEAN:\n\tcase R_BIN_JAVA_EV_TAG_STRING:\n\t\t\/\/ look up value in bin->cp_list\n\t\t\/\/ (ut16) read and set const_value.const_value_idx\n\t\t\/\/ element_value->value.const_value.const_value_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ENUM:\n\t\t\/\/ (ut16) read and set enum_const_value.type_name_idx\n\t\t\/\/ element_value->value.enum_const_value.type_name_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\t\/\/ (ut16) read and set enum_const_value.const_name_idx\n\t\t\/\/ element_value->value.enum_const_value.const_name_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_CLASS:\n\t\t\/\/ (ut16) read and set class_value.class_info_idx\n\t\t\/\/ element_value->value.class_value.class_info_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ARRAY:\n\t\t\/\/ (ut16) read and set array_value.num_values\n\t\t\/\/ element_value->value.array_value.num_values = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\tr_list_foreach_safe (element_value->value.array_value.values, iter, iter_tmp, ev_element) {\n\t\t\tif (ev_element) {\n\t\t\t\tsz += r_bin_java_element_value_calc_size (ev_element);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase R_BIN_JAVA_EV_TAG_ANNOTATION:\n\t\t\/\/ annotation new is not used here.\n\t\t\/\/ (ut16) read and set annotation_value.type_idx;\n\t\t\/\/ element_value->value.annotation_value.type_idx = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\t\/\/ (ut16) read and set annotation_value.num_element_value_pairs;\n\t\t\/\/ element_value->value.annotation_value.num_element_value_pairs = r_bin_java_read_short(bin, bin->b->cur);\n\t\tsz += 2;\n\t\telement_value->value.annotation_value.element_value_pairs = r_list_newf (r_bin_java_element_pair_free);\n\t\tr_list_foreach_safe (element_value->value.annotation_value.element_value_pairs, iter, iter_tmp, evps) {\n\t\t\tif (evps) {\n\t\t\t\tsz += r_bin_java_element_pair_calc_size (evps);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\t\/\/ eprintf unable to handle tag\n\t\tbreak;\n\t}\n\treturn sz;\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":343167,"func":"static inline int esp_remove_trailer(struct sk_buff *skb)\n{\n\tstruct xfrm_state *x = xfrm_input_state(skb);\n\tstruct xfrm_offload *xo = xfrm_offload(skb);\n\tstruct crypto_aead *aead = x->data;\n\tint alen, hlen, elen;\n\tint padlen, trimlen;\n\t__wsum csumdiff;\n\tu8 nexthdr[2];\n\tint ret;\n\n\talen = crypto_aead_authsize(aead);\n\thlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead);\n\telen = skb->len - hlen;\n\n\tif (xo && (xo->flags & XFRM_ESP_NO_TRAILER)) {\n\t\tret = xo->proto;\n\t\tgoto out;\n\t}\n\n\tif (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2))\n\t\tBUG();\n\n\tret = -EINVAL;\n\tpadlen = nexthdr[0];\n\tif (padlen + 2 + alen >= elen) {\n\t\tnet_dbg_ratelimited(\"ipsec esp packet is garbage padlen=%d, elen=%d\\n\",\n\t\t\t\t    padlen + 2, elen - alen);\n\t\tgoto out;\n\t}\n\n\ttrimlen = alen + padlen + 2;\n\tif (skb->ip_summed == CHECKSUM_COMPLETE) {\n\t\tcsumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);\n\t\tskb->csum = csum_block_sub(skb->csum, csumdiff,\n\t\t\t\t\t   skb->len - trimlen);\n\t}\n\tpskb_trim(skb, skb->len - trimlen);\n\n\tret = nexthdr[1];\n\nout:\n\treturn ret;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":244312,"func":"static u32 sgpd_size_entry(u32 grouping_type, void *entry)\n{\n\tswitch (grouping_type) {\n\tcase GF_ISOM_SAMPLE_GROUP_ROLL:\n\tcase GF_ISOM_SAMPLE_GROUP_PROL:\n\t\treturn 2;\n\tcase GF_ISOM_SAMPLE_GROUP_TELE:\n\tcase GF_ISOM_SAMPLE_GROUP_RAP:\n\tcase GF_ISOM_SAMPLE_GROUP_SAP:\n\tcase GF_ISOM_SAMPLE_GROUP_SYNC:\n\t\treturn 1;\n\tcase GF_ISOM_SAMPLE_GROUP_TSCL:\n\t\treturn 20;\n\tcase GF_ISOM_SAMPLE_GROUP_LBLI:\n\t\treturn 2;\n\tcase GF_ISOM_SAMPLE_GROUP_TSAS:\n\tcase GF_ISOM_SAMPLE_GROUP_STSA:\n\t\treturn 0;\n\tcase GF_ISOM_SAMPLE_GROUP_SEIG:\n\t{\n\t\tGF_CENCSampleEncryptionGroupEntry *seig = (GF_CENCSampleEncryptionGroupEntry *)entry;\n\t\tBool use_mkey = seig->key_info[0] ? GF_TRUE : GF_FALSE;\n\t\tif (use_mkey) {\n\t\t\treturn 3 + seig->key_info_size-1;\n\t\t}\n\t\treturn seig->key_info_size; \/\/== 3 + (seig->key_info_size-3);\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_OINF:\n\t\treturn gf_isom_oinf_size_entry(entry);\n\tcase GF_ISOM_SAMPLE_GROUP_LINF:\n\t\treturn gf_isom_linf_size_entry(entry);\n\tcase GF_ISOM_SAMPLE_GROUP_SPOR:\n\t{\n\t\tGF_SubpictureOrderEntry *spor = (GF_SubpictureOrderEntry *)entry;\n\t\tu32 s = 2 + 2*spor->num_subpic_ref_idx;\n\t\tif (spor->subpic_id_info_flag) {\n\t\t\ts += 3;\n\t\t}\n\t\treturn s;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_SULM:\n\t{\n\t\tGF_SubpictureLayoutMapEntry *sulm = (GF_SubpictureLayoutMapEntry *) entry;\n\t\treturn 6 + 2*sulm->nb_entries;\n\t}\n\n\tdefault:\n\t\treturn ((GF_DefaultSampleGroupDescriptionEntry *)entry)->length;\n\t}\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":353176,"func":"static void setSat(unsigned char rIn, unsigned char gIn, unsigned char bIn, int sat,\n\t\t   unsigned char *rOut, unsigned char *gOut, unsigned char *bOut) {\n  int rgbMin, rgbMid, rgbMax;\n  unsigned char *minOut, *midOut, *maxOut;\n\n  if (rIn < gIn) {\n    rgbMin = rIn;  minOut = rOut;\n    rgbMid = gIn;  midOut = gOut;\n  } else {\n    rgbMin = gIn;  minOut = gOut;\n    rgbMid = rIn;  midOut = rOut;\n  }\n  if (bIn > rgbMid) {\n    rgbMax = bIn;  maxOut = bOut;\n  } else if (bIn > rgbMin) {\n    rgbMax = rgbMid;  maxOut = midOut;\n    rgbMid = bIn;     midOut = bOut;\n  } else {\n    rgbMax = rgbMid;  maxOut = midOut;\n    rgbMid = rgbMin;  midOut = minOut;\n    rgbMin = bIn;     minOut = bOut;\n  }\n  if (rgbMax > rgbMin) {\n    *midOut = (unsigned char)((rgbMid - rgbMin) * sat) \/ (rgbMax - rgbMin);\n    *maxOut = (unsigned char)sat;\n  } else {\n    *midOut = *maxOut = 0;\n  }\n  *minOut = 0;\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":207754,"func":"static size_t push_pipe(struct iov_iter *i, size_t size,\n\t\t\tint *iter_headp, size_t *offp)\n{\n\tstruct pipe_inode_info *pipe = i->pipe;\n\tunsigned int p_tail = pipe->tail;\n\tunsigned int p_mask = pipe->ring_size - 1;\n\tunsigned int iter_head;\n\tsize_t off;\n\tssize_t left;\n\n\tif (unlikely(size > i->count))\n\t\tsize = i->count;\n\tif (unlikely(!size))\n\t\treturn 0;\n\n\tleft = size;\n\tdata_start(i, &iter_head, &off);\n\t*iter_headp = iter_head;\n\t*offp = off;\n\tif (off) {\n\t\tleft -= PAGE_SIZE - off;\n\t\tif (left <= 0) {\n\t\t\tpipe->bufs[iter_head & p_mask].len += size;\n\t\t\treturn size;\n\t\t}\n\t\tpipe->bufs[iter_head & p_mask].len = PAGE_SIZE;\n\t\titer_head++;\n\t}\n\twhile (!pipe_full(iter_head, p_tail, pipe->max_usage)) {\n\t\tstruct pipe_buffer *buf = &pipe->bufs[iter_head & p_mask];\n\t\tstruct page *page = alloc_page(GFP_USER);\n\t\tif (!page)\n\t\t\tbreak;\n\n\t\tbuf->ops = &default_pipe_buf_ops;\n\t\tbuf->page = page;\n\t\tbuf->offset = 0;\n\t\tbuf->len = min_t(ssize_t, left, PAGE_SIZE);\n\t\tleft -= buf->len;\n\t\titer_head++;\n\t\tpipe->head = iter_head;\n\n\t\tif (left == 0)\n\t\t\treturn size;\n\t}\n\treturn size - left;\n}","target":1,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":230625,"func":"void fill_luma_motion_vector_predictors(base_context* ctx,\n                                        const slice_segment_header* shdr,\n                                        de265_image* img,\n                                        int xC,int yC,int nCS,int xP,int yP,\n                                        int nPbW,int nPbH, int l,\n                                        int refIdx, int partIdx,\n                                        MotionVector out_mvpList[2])\n{\n  \/\/ 8.5.3.1.6: derive two spatial vector predictors A (0) and B (1)\n\n  uint8_t availableFlagLXN[2];\n  MotionVector mvLXN[2];\n\n  derive_spatial_luma_vector_prediction(ctx, img, shdr, xC,yC, nCS, xP,yP,\n                                        nPbW,nPbH, l, refIdx, partIdx,\n                                        availableFlagLXN, mvLXN);\n\n  \/\/ 8.5.3.1.7: if we only have one spatial vector or both spatial vectors are the same,\n  \/\/ derive a temporal predictor\n\n  uint8_t availableFlagLXCol;\n  MotionVector mvLXCol;\n\n\n  if (availableFlagLXN[0] &&\n      availableFlagLXN[1] &&\n      (mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)) {\n    availableFlagLXCol = 0;\n  }\n  else {\n    derive_temporal_luma_vector_prediction(ctx, img, shdr,\n                                           xP,yP, nPbW,nPbH, refIdx,l,\n                                           &mvLXCol, &availableFlagLXCol);\n  }\n\n\n  \/\/ --- build candidate vector list with exactly two entries ---\n\n  int numMVPCandLX=0;\n\n  \/\/ spatial predictor A\n\n  if (availableFlagLXN[0])\n    {\n      out_mvpList[numMVPCandLX++] = mvLXN[0];\n    }\n\n  \/\/ spatial predictor B (if not same as A)\n\n  if (availableFlagLXN[1] &&\n      (!availableFlagLXN[0] || \/\/ in case A in not available, but mvLXA initialized to same as mvLXB\n       (mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)))\n    {\n      out_mvpList[numMVPCandLX++] = mvLXN[1];\n    }\n\n  \/\/ temporal predictor\n\n  if (availableFlagLXCol)\n    {\n      out_mvpList[numMVPCandLX++] = mvLXCol;\n    }\n\n  \/\/ fill with zero predictors\n\n  while (numMVPCandLX<2) {\n    out_mvpList[numMVPCandLX].x = 0;\n    out_mvpList[numMVPCandLX].y = 0;\n    numMVPCandLX++;\n  }\n\n\n  assert(numMVPCandLX==2);\n}","target":0,"code_token_length":663,"total_token_length":899,"max_tokens_setting":1024}
+{"idx":195092,"func":"Literal *hermes::evalUnaryOperator(\n    UnaryOperatorInst::OpKind kind,\n    IRBuilder &builder,\n    Literal *operand) {\n  switch (kind) {\n    case UnaryOperatorInst::OpKind::MinusKind:\n      \/\/ Negate constant integers.\n      switch (operand->getKind()) {\n        case ValueKind::LiteralNumberKind:\n          if (auto *literalNum = llvh::dyn_cast<LiteralNumber>(operand)) {\n            auto V = -literalNum->getValue();\n            return builder.getLiteralNumber(V);\n          }\n          break;\n        case ValueKind::LiteralUndefinedKind:\n          return builder.getLiteralNaN();\n        case ValueKind::LiteralBoolKind:\n          if (evalIsTrue(builder, operand)) {\n            return builder.getLiteralNumber(-1);\n          } else { \/\/ evalIsFalse(operand)\n            return builder.getLiteralNegativeZero();\n          }\n        case ValueKind::LiteralNullKind:\n          return builder.getLiteralNegativeZero();\n        default:\n          break;\n      }\n      break;\n    case UnaryOperatorInst::OpKind::TypeofKind:\n      switch (operand->getKind()) {\n        case ValueKind::GlobalObjectKind:\n        case ValueKind::LiteralNullKind:\n          return builder.getLiteralString(\"object\");\n        case ValueKind::LiteralUndefinedKind:\n          return builder.getLiteralString(\"undefined\");\n        case ValueKind::LiteralBoolKind:\n          return builder.getLiteralString(\"boolean\");\n        case ValueKind::LiteralNumberKind:\n          return builder.getLiteralString(\"number\");\n        case ValueKind::LiteralStringKind:\n          return builder.getLiteralString(\"string\");\n        default:\n          llvm_unreachable(\"Invalid literal kind.\");\n      }\n      break;\n\n    case UnaryOperatorInst::OpKind::BangKind:\n      if (evalIsTrue(builder, operand)) {\n        return builder.getLiteralBool(false);\n      }\n      if (evalIsFalse(builder, operand)) {\n        return builder.getLiteralBool(true);\n      }\n      break;\n\n    case UnaryOperatorInst::OpKind::VoidKind:\n      return builder.getLiteralUndefined();\n\n    default:\n      break;\n  }\n\n  return nullptr;\n}","target":1,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":487656,"func":"asmlinkage long sys_times(struct tms __user * tbuf)\n{\n\t\/*\n\t *\tIn the SMP world we might just be unlucky and have one of\n\t *\tthe times increment as we use it. Since the value is an\n\t *\tatomically safe type this is just fine. Conceptually its\n\t *\tas if the syscall took an instant longer to occur.\n\t *\/\n\tif (tbuf) {\n\t\tstruct tms tmp;\n\t\tstruct task_struct *tsk = current;\n\t\tstruct task_struct *t;\n\t\tcputime_t utime, stime, cutime, cstime;\n\n\t\tspin_lock_irq(&tsk->sighand->siglock);\n\t\tutime = tsk->signal->utime;\n\t\tstime = tsk->signal->stime;\n\t\tt = tsk;\n\t\tdo {\n\t\t\tutime = cputime_add(utime, t->utime);\n\t\t\tstime = cputime_add(stime, t->stime);\n\t\t\tt = next_thread(t);\n\t\t} while (t != tsk);\n\n\t\tcutime = tsk->signal->cutime;\n\t\tcstime = tsk->signal->cstime;\n\t\tspin_unlock_irq(&tsk->sighand->siglock);\n\n\t\ttmp.tms_utime = cputime_to_clock_t(utime);\n\t\ttmp.tms_stime = cputime_to_clock_t(stime);\n\t\ttmp.tms_cutime = cputime_to_clock_t(cutime);\n\t\ttmp.tms_cstime = cputime_to_clock_t(cstime);\n\t\tif (copy_to_user(tbuf, &tmp, sizeof(struct tms)))\n\t\t\treturn -EFAULT;\n\t}\n\treturn (long) jiffies_64_to_clock_t(get_jiffies_64());\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":384873,"func":"pathcmp(const char *p, const char *q, int maxlen)\n{\n    int\t\ti, j;\n    int\t\tc1, c2;\n    const char\t*s = NULL;\n\n    for (i = 0, j = 0; maxlen < 0 || (i < maxlen && j < maxlen);)\n    {\n\tc1 = PTR2CHAR((char_u *)p + i);\n\tc2 = PTR2CHAR((char_u *)q + j);\n\n\t\/\/ End of \"p\": check if \"q\" also ends or just has a slash.\n\tif (c1 == NUL)\n\t{\n\t    if (c2 == NUL)  \/\/ full match\n\t\treturn 0;\n\t    s = q;\n\t    i = j;\n\t    break;\n\t}\n\n\t\/\/ End of \"q\": check if \"p\" just has a slash.\n\tif (c2 == NUL)\n\t{\n\t    s = p;\n\t    break;\n\t}\n\n\tif ((p_fic ? MB_TOUPPER(c1) != MB_TOUPPER(c2) : c1 != c2)\n#ifdef BACKSLASH_IN_FILENAME\n\t\t\/\/ consider '\/' and '\\\\' to be equal\n\t\t&& !((c1 == '\/' && c2 == '\\\\')\n\t\t    || (c1 == '\\\\' && c2 == '\/'))\n#endif\n\t\t)\n\t{\n\t    if (vim_ispathsep(c1))\n\t\treturn -1;\n\t    if (vim_ispathsep(c2))\n\t\treturn 1;\n\t    return p_fic ? MB_TOUPPER(c1) - MB_TOUPPER(c2)\n\t\t    : c1 - c2;  \/\/ no match\n\t}\n\n\ti += mb_ptr2len((char_u *)p + i);\n\tj += mb_ptr2len((char_u *)q + j);\n    }\n    if (s == NULL)\t\/\/ \"i\" or \"j\" ran into \"maxlen\"\n\treturn 0;\n\n    c1 = PTR2CHAR((char_u *)s + i);\n    c2 = PTR2CHAR((char_u *)s + i + mb_ptr2len((char_u *)s + i));\n    \/\/ ignore a trailing slash, but not \"\/\/\" or \":\/\"\n    if (c2 == NUL\n\t    && i > 0\n\t    && !after_pathsep((char_u *)s, (char_u *)s + i)\n#ifdef BACKSLASH_IN_FILENAME\n\t    && (c1 == '\/' || c1 == '\\\\')\n#else\n\t    && c1 == '\/'\n#endif\n       )\n\treturn 0;   \/\/ match with trailing slash\n    if (s == q)\n\treturn -1;\t    \/\/ no match\n    return 1;\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":220396,"func":"mrb_ary_aget(mrb_state *mrb, mrb_value self)\n{\n  struct RArray *a = mrb_ary_ptr(self);\n  mrb_int i;\n  mrb_int len, alen;\n  mrb_value index;\n\n  if (mrb_get_argc(mrb) == 1) {\n    index = mrb_get_arg1(mrb);\n    switch (mrb_type(index)) {\n      \/* a[n..m] *\/\n    case MRB_TT_RANGE:\n      if (mrb_range_beg_len(mrb, index, &i, &len, ARY_LEN(a), TRUE) == MRB_RANGE_OK) {\n        return ary_subseq(mrb, a, i, len);\n      }\n      else {\n        return mrb_nil_value();\n      }\n    case MRB_TT_INTEGER:\n      return mrb_ary_ref(mrb, self, mrb_integer(index));\n    default:\n      return mrb_ary_ref(mrb, self, aget_index(mrb, index));\n    }\n  }\n\n  mrb_get_args(mrb, \"oi\", &index, &len);\n  i = aget_index(mrb, index);\n  alen = ARY_LEN(a);\n  if (i < 0) i += alen;\n  if (i < 0 || alen < i) return mrb_nil_value();\n  if (len < 0) return mrb_nil_value();\n  if (alen == i) return mrb_ary_new(mrb);\n  if (len > alen - i) len = alen - i;\n\n  return ary_subseq(mrb, a, i, len);\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":455278,"func":"set_shell_name (argv0)\n     char *argv0;\n{\n  \/* Here's a hack.  If the name of this shell is \"sh\", then don't do\n     any startup files; just try to be more like \/bin\/sh. *\/\n  shell_name = argv0 ? base_pathname (argv0) : PROGRAM;\n\n  if (argv0 && *argv0 == '-')\n    {\n      if (*shell_name == '-')\n\tshell_name++;\n      login_shell = 1;\n    }\n\n  if (shell_name[0] == 's' && shell_name[1] == 'h' && shell_name[2] == '\\0')\n    act_like_sh++;\n  if (shell_name[0] == 's' && shell_name[1] == 'u' && shell_name[2] == '\\0')\n    su_shell++;\n\n  shell_name = argv0 ? argv0 : PROGRAM;\n  FREE (dollar_vars[0]);\n  dollar_vars[0] = savestring (shell_name);\n\n  \/* A program may start an interactive shell with\n\t  \"execl (\"\/bin\/bash\", \"-\", NULL)\".\n     If so, default the name of this shell to our name. *\/\n  if (!shell_name || !*shell_name || (shell_name[0] == '-' && !shell_name[1]))\n    shell_name = PROGRAM;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":267846,"func":"vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) \/**< frame context *\/\n{\n  JERRY_ASSERT (frame_ctx_p->byte_code_p[0] == CBC_EXT_OPCODE);\n\n  uint8_t opcode = frame_ctx_p->byte_code_p[1];\n  ecma_value_t completion_value;\n  ecma_value_t collection = *(--frame_ctx_p->stack_top_p);\n\n  ecma_collection_t *collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, collection);\n  ecma_value_t func_value = *(--frame_ctx_p->stack_top_p);\n  bool is_call_prop = opcode >= CBC_EXT_SPREAD_CALL_PROP;\n\n  if (frame_ctx_p->byte_code_p[1] == CBC_EXT_SPREAD_NEW)\n  {\n    const char *constructor_message_p = ecma_check_constructor (func_value);\n    if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR)\n    {\n      completion_value = ecma_raise_type_error (constructor_message_p);\n    }\n    else\n    {\n      ecma_object_t *constructor_obj_p = ecma_get_object_from_value (func_value);\n\n      completion_value = ecma_op_function_construct (constructor_obj_p,\n                                                     constructor_obj_p,\n                                                     collection_p->buffer_p,\n                                                     collection_p->item_count);\n    }\n  }\n  else\n  {\n    ecma_value_t this_value = is_call_prop ? frame_ctx_p->stack_top_p[-2] : ECMA_VALUE_UNDEFINED;\n\n    if (!ecma_is_value_object (func_value)\n        || !ecma_op_object_is_callable (ecma_get_object_from_value (func_value)))\n    {\n      completion_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function));\n    }\n    else\n    {\n      ecma_object_t *func_obj_p = ecma_get_object_from_value (func_value);\n\n      completion_value = ecma_op_function_call (func_obj_p,\n                                                this_value,\n                                                collection_p->buffer_p,\n                                                collection_p->item_count);\n    }\n\n    if (is_call_prop)\n    {\n      ecma_free_value (*(--frame_ctx_p->stack_top_p));\n      ecma_free_value (*(--frame_ctx_p->stack_top_p));\n    }\n  }\n\n  ecma_collection_free (collection_p);\n  ecma_free_value (func_value);\n\n  if (JERRY_UNLIKELY (ECMA_IS_VALUE_ERROR (completion_value)))\n  {\n#if JERRY_DEBUGGER\n    JERRY_CONTEXT (debugger_exception_byte_code_p) = frame_ctx_p->byte_code_p;\n#endif \/* JERRY_DEBUGGER *\/\n    frame_ctx_p->byte_code_p = (uint8_t *) vm_error_byte_code_p;\n  }\n  else\n  {\n    uint32_t opcode_data = vm_decode_table[(CBC_END + 1) + opcode];\n\n    if (!(opcode_data & (VM_OC_PUT_STACK | VM_OC_PUT_BLOCK)))\n    {\n      ecma_fast_free_value (completion_value);\n    }\n    else if (opcode_data & VM_OC_PUT_STACK)\n    {\n      *frame_ctx_p->stack_top_p++ = completion_value;\n    }\n    else\n    {\n      ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));\n      VM_GET_REGISTERS (frame_ctx_p)[0] = completion_value;\n    }\n\n    \/* EXT_OPCODE, SPREAD_OPCODE, BYTE_ARG *\/\n    frame_ctx_p->byte_code_p += 3;\n  }\n} \/* vm_spread_operation *\/","target":0,"code_token_length":716,"total_token_length":952,"max_tokens_setting":1024}
+{"idx":336490,"func":"SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)\n{\n    \/* remove the server from the list of servers so that we don't attempt to\n     * free it again at exit *\/\n    pthread_mutex_lock(&global_reds_lock);\n    servers = g_list_remove(servers, reds);\n    pthread_mutex_unlock(&global_reds_lock);\n\n    for (auto qxl: reds->qxl_instances) {\n        red_qxl_destroy(qxl);\n    }\n\n    if (reds->inputs_channel) {\n        reds->inputs_channel->destroy();\n    }\n    \/* This requires a bit of explanation on how reference counting is\n     * not enough. The full reply is in docs\/spice_threading_model.txt,\n     * mainly the RedChannels are owned by both RedsState and\n     * RedChannelClient so we need both to get destroyed. This call\n     * remove RedChannelClients *\/\n    if (reds->main_channel) {\n        reds->main_channel->destroy();\n    }\n    red_timer_remove(reds->mig_timer);\n\n    if (reds->ctx) {\n        SSL_CTX_free(reds->ctx);\n    }\n\n    reds->main_dispatcher.reset();\n    reds_cleanup_net(reds);\n    reds->agent_dev.reset();\n\n    \/\/ NOTE: don't replace with g_list_free_full as this function that passed callback\n    \/\/ don't change the list while unreferencing in this case will change it.\n    reds->char_devices.clear();\n\n    spice_buffer_free(&reds->client_monitors_config);\n    red_record_unref(reds->record);\n    reds_cleanup(reds);\n#ifdef RED_STATISTICS\n    stat_file_free(reds->stat_file);\n#endif\n\n    reds_config_free(reds->config);\n    delete reds;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":513276,"func":"bool JOIN::setup_subquery_caches()\n{\n  DBUG_ENTER(\"JOIN::setup_subquery_caches\");\n\n  \/*\n    We have to check all this condition together because items created in\n    one of this clauses can be moved to another one by optimizer\n  *\/\n  if (select_lex->expr_cache_may_be_used[IN_WHERE] ||\n      select_lex->expr_cache_may_be_used[IN_HAVING] ||\n      select_lex->expr_cache_may_be_used[IN_ON] ||\n      select_lex->expr_cache_may_be_used[NO_MATTER])\n  {\n    if (conds)\n      conds= conds->transform(thd, &Item::expr_cache_insert_transformer,\n                              NULL);\n    JOIN_TAB *tab;\n    for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES);\n         tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))\n    {\n      if (tab->select_cond)\n        tab->select_cond=\n          tab->select_cond->transform(thd, &Item::expr_cache_insert_transformer,\n                                      NULL);\n      if (tab->cache_select && tab->cache_select->cond)\n        tab->cache_select->cond=\n          tab->cache_select->\n          cond->transform(thd, &Item::expr_cache_insert_transformer,\n                          NULL);\n\n    }\n\n    if (having)\n      having= having->transform(thd, &Item::expr_cache_insert_transformer,\n                                NULL);\n    if (tmp_having)\n    {\n      DBUG_ASSERT(having == NULL);\n      tmp_having= tmp_having->transform(thd, &Item::expr_cache_insert_transformer,\n                                        NULL);\n    }\n  }\n  if (select_lex->expr_cache_may_be_used[SELECT_LIST] ||\n      select_lex->expr_cache_may_be_used[IN_GROUP_BY] ||\n      select_lex->expr_cache_may_be_used[NO_MATTER])\n  {\n    List_iterator<Item> li(all_fields);\n    Item *item;\n    while ((item= li++))\n    {\n      Item *new_item=\n        item->transform(thd, &Item::expr_cache_insert_transformer,\n                        NULL);\n      if (new_item != item)\n      {\n        thd->change_item_tree(li.ref(), new_item);\n      }\n    }\n    for (ORDER *tmp_group= group_list; tmp_group ; tmp_group= tmp_group->next)\n    {\n      *tmp_group->item=\n        (*tmp_group->item)->transform(thd, &Item::expr_cache_insert_transformer,\n                                      NULL);\n    }\n  }\n  if (select_lex->expr_cache_may_be_used[NO_MATTER])\n  {\n    for (ORDER *ord= order; ord; ord= ord->next)\n    {\n      *ord->item=\n        (*ord->item)->transform(thd, &Item::expr_cache_insert_transformer,\n                                NULL);\n    }\n  }\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":210928,"func":"void jfs_evict_inode(struct inode *inode)\n{\n\tstruct jfs_inode_info *ji = JFS_IP(inode);\n\n\tjfs_info(\"In jfs_evict_inode, inode = 0x%p\", inode);\n\n\tif (!inode->i_nlink && !is_bad_inode(inode)) {\n\t\tdquot_initialize(inode);\n\n\t\tif (JFS_IP(inode)->fileset == FILESYSTEM_I) {\n\t\t\ttruncate_inode_pages_final(&inode->i_data);\n\n\t\t\tif (test_cflag(COMMIT_Freewmap, inode))\n\t\t\t\tjfs_free_zero_link(inode);\n\n\t\t\tif (JFS_SBI(inode->i_sb)->ipimap)\n\t\t\t\tdiFree(inode);\n\n\t\t\t\/*\n\t\t\t * Free the inode from the quota allocation.\n\t\t\t *\/\n\t\t\tdquot_free_inode(inode);\n\t\t}\n\t} else {\n\t\ttruncate_inode_pages_final(&inode->i_data);\n\t}\n\tclear_inode(inode);\n\tdquot_drop(inode);\n\n\tBUG_ON(!list_empty(&ji->anon_inode_list));\n\n\tspin_lock_irq(&ji->ag_lock);\n\tif (ji->active_ag != -1) {\n\t\tstruct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;\n\t\tatomic_dec(&bmap->db_active[ji->active_ag]);\n\t\tji->active_ag = -1;\n\t}\n\tspin_unlock_irq(&ji->ag_lock);\n}","target":1,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":224194,"func":"gen_hash(codegen_scope *s, node *tree, int val, int limit)\n{\n  int slimit = GEN_VAL_STACK_MAX;\n  if (cursp() >= GEN_LIT_ARY_MAX) slimit = INT16_MAX;\n  int len = 0;\n  mrb_bool update = FALSE;\n  mrb_bool first = TRUE;\n\n  while (tree) {\n    if (nint(tree->car->car->car) == NODE_KW_REST_ARGS) {\n      if (val && first) {\n        genop_2(s, OP_HASH, cursp(), 0);\n        push();\n        update = TRUE;\n      }\n      else if (val && len > 0) {\n        pop_n(len*2);\n        if (!update) {\n          genop_2(s, OP_HASH, cursp(), len);\n        }\n        else {\n          pop();\n          genop_2(s, OP_HASHADD, cursp(), len);\n        }\n        push();\n      }\n      codegen(s, tree->car->cdr, val);\n      if (val && (len > 0 || update)) {\n        pop(); pop();\n        genop_1(s, OP_HASHCAT, cursp());\n        push();\n      }\n      update = TRUE;\n      len = 0;\n    }\n    else {\n      codegen(s, tree->car->car, val);\n      codegen(s, tree->car->cdr, val);\n      len++;\n    }\n    tree = tree->cdr;\n    if (val && cursp() >= slimit) {\n      pop_n(len*2);\n      if (!update) {\n        genop_2(s, OP_HASH, cursp(), len);\n      }\n      else {\n        pop();\n        genop_2(s, OP_HASHADD, cursp(), len);\n      }\n      push();\n      update = TRUE;\n      len = 0;\n    }\n    first = FALSE;\n  }\n  if (val && len > limit) {\n    pop_n(len*2);\n    genop_2(s, OP_HASH, cursp(), len);\n    push();\n    return -1;\n  }\n  if (update) {\n    if (val && len > 0) {\n      pop_n(len*2+1);\n      genop_2(s, OP_HASHADD, cursp(), len);\n      push();\n    }\n    return -1;                  \/* variable length *\/\n  }\n  return len;\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":430373,"func":"void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,\n\t\t  int rowsize, int groupsize, const void *buf, size_t len,\n\t\t  bool ascii)\n{\n\tconst u8 *ptr = buf;\n\tint i, linelen, remaining = len;\n\tchar *buffer;\n\tsize_t size;\n\tint ret;\n\n\tif (rowsize != 16 && rowsize != 32)\n\t\trowsize = 16;\n\n\tfor (i = 0; i < len && !seq_has_overflowed(m); i += rowsize) {\n\t\tlinelen = min(remaining, rowsize);\n\t\tremaining -= rowsize;\n\n\t\tswitch (prefix_type) {\n\t\tcase DUMP_PREFIX_ADDRESS:\n\t\t\tseq_printf(m, \"%s%p: \", prefix_str, ptr + i);\n\t\t\tbreak;\n\t\tcase DUMP_PREFIX_OFFSET:\n\t\t\tseq_printf(m, \"%s%.8x: \", prefix_str, i);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tseq_printf(m, \"%s\", prefix_str);\n\t\t\tbreak;\n\t\t}\n\n\t\tsize = seq_get_buf(m, &buffer);\n\t\tret = hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,\n\t\t\t\t\t buffer, size, ascii);\n\t\tseq_commit(m, ret < size ? ret : -1);\n\n\t\tseq_putc(m, '\\n');\n\t}\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":286737,"func":"static int SWTPM_HMAC(unsigned char *md, unsigned int *md_len,\n                      const void *key, int key_len,\n                      const unsigned char *in, uint32_t in_length,\n                      const unsigned char *ivec, uint32_t ivec_length)\n{\n    OSSL_PARAM params[2];\n    EVP_MAC_CTX *ctx;\n    EVP_MAC *hmac;\n    size_t outl;\n    int ret = 0;\n\n    hmac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL);\n    if (!hmac)\n        return 0;\n\n    ctx = EVP_MAC_CTX_new(hmac);\n    if (!ctx)\n        goto err;\n\n    params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST,\n                                                 \"sha256\", 0);\n    params[1] = OSSL_PARAM_construct_end();\n\n    if (!EVP_MAC_init(ctx, key, key_len, params) ||\n        !EVP_MAC_update(ctx, in, in_length))\n        goto err;\n\n    if (ivec &&\n        !EVP_MAC_update(ctx, ivec, ivec_length))\n        goto err;\n\n    if (!EVP_MAC_final(ctx, md, &outl, *md_len))\n        goto err;\n    *md_len = outl;\n\n    ret = 1;\n\nerr:\n    EVP_MAC_CTX_free(ctx);\n    EVP_MAC_free(hmac);\n\n    return ret;\n}","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":398514,"func":"static RzList \/*<RzBinDwarfARangeSet>*\/ *parse_aranges_raw(const ut8 *obuf, size_t obuf_sz, bool big_endian) {\n\trz_return_val_if_fail(obuf, NULL);\n\tconst ut8 *buf = obuf;\n\tconst ut8 *buf_end = buf + obuf_sz;\n\n\tRzList *r = rz_list_newf((RzListFree)rz_bin_dwarf_arange_set_free);\n\tif (!r) {\n\t\treturn NULL;\n\t}\n\n\t\/\/ DWARF 3 Standard Section 6.1.2 Lookup by Address\n\t\/\/ also useful to grep for display_debug_aranges in binutils\n\twhile (buf < buf_end) {\n\t\tconst ut8 *start = buf;\n\t\tbool is_64bit;\n\t\tut64 unit_length = dwarf_read_initial_length(&is_64bit, big_endian, &buf, buf_end);\n\t\t\/\/ Sanity check: length must be at least the minimal size of the remaining header fields\n\t\t\/\/ and at maximum the remaining buffer size.\n\t\tsize_t header_rest_size = 2 + (is_64bit ? 8 : 4) + 1 + 1;\n\t\tif (unit_length < header_rest_size || unit_length > buf_end - buf) {\n\t\t\tbreak;\n\t\t}\n\t\tconst ut8 *next_set_buf = buf + unit_length;\n\t\tRzBinDwarfARangeSet *set = RZ_NEW(RzBinDwarfARangeSet);\n\t\tif (!set) {\n\t\t\tbreak;\n\t\t}\n\t\tset->unit_length = unit_length;\n\t\tset->is_64bit = is_64bit;\n\t\tset->version = READ16(buf);\n\t\tset->debug_info_offset = dwarf_read_offset(set->is_64bit, big_endian, &buf, buf_end);\n\t\tset->address_size = READ8(buf);\n\t\tset->segment_size = READ8(buf);\n\t\tunit_length -= header_rest_size;\n\t\tif (!set->address_size) {\n\t\t\tfree(set);\n\t\t\tbreak;\n\t\t}\n\n\t\t\/\/ align to 2*addr_size\n\t\tsize_t off = buf - start;\n\t\tsize_t pad = rz_num_align_delta(off, 2 * set->address_size);\n\t\tif (pad > unit_length || pad > buf_end - buf) {\n\t\t\tfree(set);\n\t\t\tbreak;\n\t\t}\n\t\tbuf += pad;\n\t\tunit_length -= pad;\n\n\t\tsize_t arange_size = 2 * set->address_size;\n\t\tset->aranges_count = unit_length \/ arange_size;\n\t\tif (!set->aranges_count) {\n\t\t\tfree(set);\n\t\t\tbreak;\n\t\t}\n\t\tset->aranges = RZ_NEWS0(RzBinDwarfARange, set->aranges_count);\n\t\tif (!set->aranges) {\n\t\t\tfree(set);\n\t\t\tbreak;\n\t\t}\n\t\tsize_t i;\n\t\tfor (i = 0; i < set->aranges_count; i++) {\n\t\t\tset->aranges[i].addr = dwarf_read_address(set->address_size, big_endian, &buf, buf_end);\n\t\t\tset->aranges[i].length = dwarf_read_address(set->address_size, big_endian, &buf, buf_end);\n\t\t\tif (!set->aranges[i].addr && !set->aranges[i].length) {\n\t\t\t\t\/\/ last entry has two 0s\n\t\t\t\ti++; \/\/ so i will be the total count of read entries\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tset->aranges_count = i;\n\t\tbuf = next_set_buf;\n\t\trz_list_push(r, set);\n\t}\n\n\treturn r;\n}","target":0,"code_token_length":770,"total_token_length":1006,"max_tokens_setting":1024}
+{"idx":356707,"func":"bool Statement::Bind(const Parameters & parameters) {\n    if (parameters.size() == 0) {\n        return true;\n    }\n\n    sqlite3_reset(_handle);\n    sqlite3_clear_bindings(_handle);\n\n    Parameters::const_iterator it = parameters.begin();\n    Parameters::const_iterator end = parameters.end();\n\n    for (; it < end; ++it) {\n        Values::Field* field = *it;\n\n        if (field != NULL) {\n            unsigned int pos;\n            if (field->index > 0) {\n                pos = field->index;\n            }\n            else {\n                pos = sqlite3_bind_parameter_index(_handle, field->name.c_str());\n            }\n\n            switch (field->type) {\n                case SQLITE_INTEGER: {\n                    status = sqlite3_bind_int(_handle, pos,\n                        ((Values::Integer*)field)->value);\n                } break;\n                case SQLITE_FLOAT: {\n                    status = sqlite3_bind_double(_handle, pos,\n                        ((Values::Float*)field)->value);\n                } break;\n                case SQLITE_TEXT: {\n                    status = sqlite3_bind_text(_handle, pos,\n                        ((Values::Text*)field)->value.c_str(),\n                        ((Values::Text*)field)->value.size(), SQLITE_TRANSIENT);\n                } break;\n                case SQLITE_BLOB: {\n                    status = sqlite3_bind_blob(_handle, pos,\n                        ((Values::Blob*)field)->value,\n                        ((Values::Blob*)field)->length, SQLITE_TRANSIENT);\n                } break;\n                case SQLITE_NULL: {\n                    status = sqlite3_bind_null(_handle, pos);\n                } break;\n            }\n\n            if (status != SQLITE_OK) {\n                message = std::string(sqlite3_errmsg(db->_handle));\n                return false;\n            }\n        }\n    }\n\n    return true;\n}","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":291791,"func":"static int init_conns(struct rtrs_clt_path *clt_path)\n{\n\tunsigned int cid;\n\tint err;\n\n\t\/*\n\t * On every new session connections increase reconnect counter\n\t * to avoid clashes with previous sessions not yet closed\n\t * sessions on a server side.\n\t *\/\n\tclt_path->s.recon_cnt++;\n\n\t\/* Establish all RDMA connections  *\/\n\tfor (cid = 0; cid < clt_path->s.con_num; cid++) {\n\t\terr = create_con(clt_path, cid);\n\t\tif (err)\n\t\t\tgoto destroy;\n\n\t\terr = create_cm(to_clt_con(clt_path->s.con[cid]));\n\t\tif (err) {\n\t\t\tdestroy_con(to_clt_con(clt_path->s.con[cid]));\n\t\t\tgoto destroy;\n\t\t}\n\t}\n\terr = alloc_path_reqs(clt_path);\n\tif (err)\n\t\tgoto destroy;\n\n\trtrs_start_hb(&clt_path->s);\n\n\treturn 0;\n\ndestroy:\n\twhile (cid--) {\n\t\tstruct rtrs_clt_con *con = to_clt_con(clt_path->s.con[cid]);\n\n\t\tstop_cm(con);\n\n\t\tmutex_lock(&con->con_mutex);\n\t\tdestroy_con_cq_qp(con);\n\t\tmutex_unlock(&con->con_mutex);\n\t\tdestroy_cm(con);\n\t\tdestroy_con(con);\n\t}\n\t\/*\n\t * If we've never taken async path and got an error, say,\n\t * doing rdma_resolve_addr(), switch to CONNECTION_ERR state\n\t * manually to keep reconnecting.\n\t *\/\n\trtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING_ERR, NULL);\n\n\treturn err;\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":265061,"func":"promptexpand(char *s, int ns, char *rs, char *Rs, zattr *txtchangep)\n{\n    struct buf_vars new_vars;\n\n    if(!s)\n\treturn ztrdup(\"\");\n\n    if ((termflags & TERM_UNKNOWN) && (unset(INTERACTIVE)))\n        init_term();\n\n    if (isset(PROMPTSUBST)) {\n\tint olderr = errflag;\n\tint oldval = lastval;\n\n\ts = dupstring(s);\n\tif (!parsestr(&s))\n\t    singsub(&s);\n\t\/*\n\t * We don't need the special Nularg hack here and we're\n\t * going to be using Nularg for other things.\n\t *\/\n\tif (*s == Nularg && s[1] == '\\0')\n\t    *s = '\\0';\n\n\t\/*\n\t * Ignore errors and status change in prompt substitution.\n\t * However, keep any user interrupt error that occurred.\n\t *\/\n\terrflag = olderr | (errflag & ERRFLAG_INT);\n\tlastval = oldval;\n    }\n\n    memset(&new_vars, 0, sizeof(new_vars));\n    new_vars.last = bv;\n    bv = &new_vars;\n\n    new_vars.rstring = rs;\n    new_vars.Rstring = Rs;\n    new_vars.fm = s;\n    new_vars.bufspc = 256;\n    new_vars.bp = new_vars.bufline = new_vars.buf = zshcalloc(new_vars.bufspc);\n    new_vars.bp1 = NULL;\n    new_vars.truncwidth = 0;\n\n    putpromptchar(1, '\\0', txtchangep);\n    addbufspc(2);\n    if (new_vars.dontcount)\n\t*new_vars.bp++ = Outpar;\n    *new_vars.bp = '\\0';\n    if (!ns) {\n\t\/* If zero, Inpar, Outpar and Nularg should be removed. *\/\n\tfor (new_vars.bp = new_vars.buf; *new_vars.bp; ) {\n\t    if (*new_vars.bp == Meta)\n\t\tnew_vars.bp += 2;\n\t    else if (*new_vars.bp == Inpar || *new_vars.bp == Outpar ||\n\t\t     *new_vars.bp == Nularg)\n\t\tchuck(new_vars.bp);\n\t    else\n\t\tnew_vars.bp++;\n\t}\n    }\n\n    bv = new_vars.last;\n\n    return new_vars.buf;\n}","target":0,"code_token_length":486,"total_token_length":722,"max_tokens_setting":1024}
+{"idx":474000,"func":"onigenc_unicode_mbc_case_fold(OnigEncoding enc,\n    OnigCaseFoldType flag ARG_UNUSED, const UChar** pp, const UChar* end,\n    UChar* fold)\n{\n  CodePointList3 *to;\n  OnigCodePoint code;\n  int i, len, rlen;\n  const UChar *p = *pp;\n\n  if (CaseFoldInited == 0) init_case_fold_table();\n\n  code = ONIGENC_MBC_TO_CODE(enc, p, end);\n  len = enclen(enc, p, end);\n  *pp += len;\n\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n  if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {\n    if (code == 0x0049) {\n      return ONIGENC_CODE_TO_MBC(enc, 0x0131, fold);\n    }\n    else if (code == 0x0130) {\n      return ONIGENC_CODE_TO_MBC(enc, 0x0069, fold);\n    }\n  }\n#endif\n\n  if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) {\n    if (to->n == 1) {\n      return ONIGENC_CODE_TO_MBC(enc, to->code[0], fold);\n    }\n#if 0\n    \/* NO NEEDS TO CHECK *\/\n    else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0)\n#else\n    else\n#endif\n    {\n      rlen = 0;\n      for (i = 0; i < to->n; i++) {\n\tlen = ONIGENC_CODE_TO_MBC(enc, to->code[i], fold);\n\tfold += len;\n\trlen += len;\n      }\n      return rlen;\n    }\n  }\n\n  for (i = 0; i < len; i++) {\n    *fold++ = *p++;\n  }\n  return len;\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":252368,"func":"static bool DecompressRle(unsigned char *dst,\n                          const unsigned long uncompressed_size,\n                          const unsigned char *src, unsigned long src_size) {\n  if (uncompressed_size == src_size) {\n    \/\/ Data is not compressed(Issue 40).\n    memcpy(dst, src, src_size);\n    return true;\n  }\n\n  \/\/ Workaround for issue #112.\n  \/\/ TODO(syoyo): Add more robust out-of-bounds check in `rleUncompress`.\n  if (src_size <= 2) {\n    return false;\n  }\n\n  std::vector<unsigned char> tmpBuf(uncompressed_size);\n\n  int ret = rleUncompress(static_cast<int>(src_size),\n                          static_cast<int>(uncompressed_size),\n                          reinterpret_cast<const signed char *>(src),\n                          reinterpret_cast<char *>(&tmpBuf.at(0)));\n  if (ret != static_cast<int>(uncompressed_size)) {\n    return false;\n  }\n\n  \/\/\n  \/\/ Apply EXR-specific? postprocess. Grabbed from OpenEXR's\n  \/\/ ImfRleCompressor.cpp\n  \/\/\n\n  \/\/ Predictor.\n  {\n    unsigned char *t = &tmpBuf.at(0) + 1;\n    unsigned char *stop = &tmpBuf.at(0) + uncompressed_size;\n\n    while (t < stop) {\n      int d = int(t[-1]) + int(t[0]) - 128;\n      t[0] = static_cast<unsigned char>(d);\n      ++t;\n    }\n  }\n\n  \/\/ Reorder the pixel data.\n  {\n    const char *t1 = reinterpret_cast<const char *>(&tmpBuf.at(0));\n    const char *t2 = reinterpret_cast<const char *>(&tmpBuf.at(0)) +\n                     (uncompressed_size + 1) \/ 2;\n    char *s = reinterpret_cast<char *>(dst);\n    char *stop = s + uncompressed_size;\n\n    for (;;) {\n      if (s < stop)\n        *(s++) = *(t1++);\n      else\n        break;\n\n      if (s < stop)\n        *(s++) = *(t2++);\n      else\n        break;\n    }\n  }\n\n  return true;\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":417469,"func":"virNodeDeviceCapsListExport(virNodeDeviceDefPtr def,\n                            virNodeDevCapType **list)\n{\n    virNodeDevCapsDefPtr caps = NULL;\n    virNodeDevCapType *tmp = NULL;\n    bool want_list = !!list;\n    int ncaps = 0;\n    int ret = -1;\n\n#define MAYBE_ADD_CAP(cap) \\\n    do { \\\n        if (want_list) \\\n            tmp[ncaps] = cap; \\\n    } while (0)\n\n    if (virNodeDeviceUpdateCaps(def) < 0)\n        goto cleanup;\n\n    if (want_list)\n        tmp = g_new0(virNodeDevCapType, VIR_NODE_DEV_CAP_LAST - 1);\n\n    for (caps = def->caps; caps; caps = caps->next) {\n        unsigned int flags;\n\n        MAYBE_ADD_CAP(caps->data.type);\n        ncaps++;\n\n        \/* check nested caps for a given type as well *\/\n        if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {\n            flags = caps->data.scsi_host.flags;\n\n            if (flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {\n                MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_FC_HOST);\n                ncaps++;\n            }\n\n            if (flags  & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {\n                MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_VPORTS);\n                ncaps++;\n            }\n        }\n\n        if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {\n            flags = caps->data.pci_dev.flags;\n\n            if (flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {\n                MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_MDEV_TYPES);\n                ncaps++;\n            }\n        }\n\n        if (caps->data.type == VIR_NODE_DEV_CAP_CSS_DEV) {\n            flags = caps->data.ccw_dev.flags;\n\n            if (flags & VIR_NODE_DEV_CAP_FLAG_CSS_MDEV) {\n                MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_MDEV_TYPES);\n                ncaps++;\n            }\n        }\n    }\n\n#undef MAYBE_ADD_CAP\n\n    if (want_list)\n        *list = g_steal_pointer(&tmp);\n    ret = ncaps;\n cleanup:\n    VIR_FREE(tmp);\n    return ret;\n}","target":0,"code_token_length":475,"total_token_length":711,"max_tokens_setting":1024}
+{"idx":477355,"func":"R_API RBinSymbol *r_bin_java_create_new_symbol_from_ref(RBinJavaObj *bin, RBinJavaCPTypeObj *obj, ut64 baddr) {\n\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\tif (!sym) {\n\t\treturn NULL;\n\t}\n\tchar *class_name, *name, *type_name;\n\tif (obj == NULL || (obj->tag != R_BIN_JAVA_CP_METHODREF &&\n\tobj->tag != R_BIN_JAVA_CP_INTERFACEMETHOD_REF &&\n\tobj->tag != R_BIN_JAVA_CP_FIELDREF)) {\n\t\tR_FREE (sym);\n\t\treturn sym;\n\t}\n\tif (sym) {\n\t\tclass_name = r_bin_java_get_name_from_bin_cp_list (bin,\n\t\t\tobj->info.cp_method.class_idx);\n\t\tname = r_bin_java_get_name_from_bin_cp_list (bin,\n\t\t\tobj->info.cp_method.name_and_type_idx);\n\t\ttype_name = r_bin_java_get_name_from_bin_cp_list (bin,\n\t\t\tobj->info.cp_method.name_and_type_idx);\n\t\tif (name) {\n\t\t\tsym->name = name;\n\t\t\tname = NULL;\n\t\t}\n\t\tif (type_name) {\n\t\t\tsym->type = r_str_constpool_get (&bin->constpool, type_name);\n\t\t\tR_FREE (type_name);\n\t\t}\n\t\tif (class_name) {\n\t\t\tsym->classname = strdup (class_name);\n\t\t}\n\t\tsym->paddr = obj->file_offset + baddr;\n\t\tsym->vaddr = obj->file_offset + baddr;\n\t\tsym->ordinal = obj->metas->ord;\n\t\tsym->size = 0;\n\t}\n\treturn sym;\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":366207,"func":"struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,\n\t\t\t\t\tint flag)\n{\n\tstruct mount *res, *p, *q, *r, *parent;\n\n\tif (!(flag & CL_COPY_UNBINDABLE) && IS_MNT_UNBINDABLE(mnt))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tif (!(flag & CL_COPY_MNT_NS_FILE) && is_mnt_ns_file(dentry))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tres = q = clone_mnt(mnt, dentry, flag);\n\tif (IS_ERR(q))\n\t\treturn q;\n\n\tq->mnt_mountpoint = mnt->mnt_mountpoint;\n\n\tp = mnt;\n\tlist_for_each_entry(r, &mnt->mnt_mounts, mnt_child) {\n\t\tstruct mount *s;\n\t\tif (!is_subdir(r->mnt_mountpoint, dentry))\n\t\t\tcontinue;\n\n\t\tfor (s = r; s; s = next_mnt(s, r)) {\n\t\t\tif (!(flag & CL_COPY_UNBINDABLE) &&\n\t\t\t    IS_MNT_UNBINDABLE(s)) {\n\t\t\t\tif (s->mnt.mnt_flags & MNT_LOCKED) {\n\t\t\t\t\t\/* Both unbindable and locked. *\/\n\t\t\t\t\tq = ERR_PTR(-EPERM);\n\t\t\t\t\tgoto out;\n\t\t\t\t} else {\n\t\t\t\t\ts = skip_mnt_tree(s);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(flag & CL_COPY_MNT_NS_FILE) &&\n\t\t\t    is_mnt_ns_file(s->mnt.mnt_root)) {\n\t\t\t\ts = skip_mnt_tree(s);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\twhile (p != s->mnt_parent) {\n\t\t\t\tp = p->mnt_parent;\n\t\t\t\tq = q->mnt_parent;\n\t\t\t}\n\t\t\tp = s;\n\t\t\tparent = q;\n\t\t\tq = clone_mnt(p, p->mnt.mnt_root, flag);\n\t\t\tif (IS_ERR(q))\n\t\t\t\tgoto out;\n\t\t\tlock_mount_hash();\n\t\t\tlist_add_tail(&q->mnt_list, &res->mnt_list);\n\t\t\tattach_mnt(q, parent, p->mnt_mp);\n\t\t\tunlock_mount_hash();\n\t\t}\n\t}\n\treturn res;\nout:\n\tif (res) {\n\t\tlock_mount_hash();\n\t\tumount_tree(res, UMOUNT_SYNC);\n\t\tunlock_mount_hash();\n\t}\n\treturn q;\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":509518,"func":"static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,\n                                const char *fmt, va_list args)\n{\n  THD *thd= (THD *) param->thd;\n  Protocol *protocol= thd->protocol;\n  size_t length, msg_length;\n  char msgbuf[MYSQL_ERRMSG_SIZE];\n  char name[NAME_LEN * 2 + 2];\n\n  if (param->testflag & T_SUPPRESS_ERR_HANDLING)\n    return;\n\n  msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);\n  msgbuf[sizeof(msgbuf) - 1]= 0;                \/\/ healthy paranoia\n\n  DBUG_PRINT(msg_type, (\"message: %s\", msgbuf));\n\n  if (!thd->vio_ok())\n  {\n    _ma_check_print(param, msg_type, msgbuf);\n    return;\n  }\n\n  if (param->testflag &\n      (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))\n  {\n    myf flag= 0;\n    if (msg_type == MA_CHECK_INFO)\n      flag= ME_NOTE;\n    else if (msg_type == MA_CHECK_WARNING)\n      flag= ME_WARNING;\n    my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag));\n    if (thd->variables.log_warnings > 2)\n      _ma_check_print(param, msg_type, msgbuf);\n    return;\n  }\n  length= (uint) (strxmov(name, param->db_name, \".\", param->table_name,\n                          NullS) - name);\n  \/*\n    TODO: switch from protocol to push_warning here. The main reason we didn't\n    it yet is parallel repair, which threads have no THD object accessible via\n    current_thd.\n\n    Also we likely need to lock mutex here (in both cases with protocol and\n    push_warning).\n  *\/\n  protocol->prepare_for_resend();\n  protocol->store(name, (uint)length, system_charset_info);\n  protocol->store(param->op_name, system_charset_info);\n  protocol->store(msg_type, system_charset_info);\n  protocol->store(msgbuf, (uint)msg_length, system_charset_info);\n  if (protocol->write())\n    sql_print_error(\"Failed on my_net_write, writing to stderr instead: %s.%s: %s\\n\",\n                    param->db_name, param->table_name, msgbuf);\n  else if (thd->variables.log_warnings > 2)\n    _ma_check_print(param, msg_type, msgbuf);\n\n  return;\n}","target":0,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":259322,"func":"static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    int version, offset_size, length_size, base_offset_size, index_size;\n    int item_count, extent_count;\n    uint64_t base_offset, extent_offset, extent_length;\n    uint8_t value;\n\n    if (!c->is_still_picture_avif) {\n        \/\/ * For non-avif, we simply ignore the iloc box.\n        \/\/ * For animated avif, we don't care about the iloc box as all the\n        \/\/   necessary information can be found in the moov box.\n        return 0;\n    }\n\n    if (c->fc->nb_streams) {\n        av_log(c->fc, AV_LOG_INFO, \"Duplicate iloc box found\\n\");\n        return 0;\n    }\n\n    version = avio_r8(pb);\n    avio_rb24(pb);  \/\/ flags.\n\n    value = avio_r8(pb);\n    offset_size = (value >> 4) & 0xF;\n    length_size = value & 0xF;\n    value = avio_r8(pb);\n    base_offset_size = (value >> 4) & 0xF;\n    index_size = !version ? 0 : (value & 0xF);\n    if (index_size) {\n        av_log(c->fc, AV_LOG_ERROR, \"iloc: index_size != 0 not supported.\\n\");\n        return AVERROR_PATCHWELCOME;\n    }\n    item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);\n\n    c->avif_info = av_malloc_array(item_count, sizeof(*c->avif_info));\n    if (!c->avif_info)\n        return AVERROR(ENOMEM);\n    c->avif_info_size = item_count;\n\n    for (int i = 0; i < item_count; i++) {\n        int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);\n        if (avio_feof(pb))\n            return AVERROR_INVALIDDATA;\n        c->avif_info[i].item_id = item_id;\n\n        if (version > 0)\n            avio_rb16(pb);  \/\/ construction_method.\n        avio_rb16(pb);  \/\/ data_reference_index.\n        if (rb_size(pb, &base_offset, base_offset_size) < 0)\n            return AVERROR_INVALIDDATA;\n        extent_count = avio_rb16(pb);\n        if (extent_count > 1) {\n            \/\/ For still AVIF images, we only support one extent item.\n            av_log(c->fc, AV_LOG_ERROR, \"iloc: extent_count > 1 not supported.\\n\");\n            return AVERROR_PATCHWELCOME;\n        }\n        for (int j = 0; j < extent_count; j++) {\n            if (rb_size(pb, &extent_offset, offset_size) < 0 ||\n                rb_size(pb, &extent_length, length_size) < 0)\n                return AVERROR_INVALIDDATA;\n            c->avif_info[i].extent_length = extent_length;\n            c->avif_info[i].extent_offset = base_offset + extent_offset;\n        }\n    }\n\n    return atom.size;\n}","target":0,"code_token_length":693,"total_token_length":929,"max_tokens_setting":1024}
+{"idx":224287,"func":"gopherStart(FwdState * fwd)\n{\n    GopherStateData *gopherState = new GopherStateData(fwd);\n\n    debugs(10, 3, gopherState->entry->url());\n\n    ++ statCounter.server.all.requests;\n\n    ++ statCounter.server.other.requests;\n\n    \/* Parse url. *\/\n    gopher_request_parse(fwd->request,\n                         &gopherState->type_id, gopherState->request);\n\n    comm_add_close_handler(fwd->serverConnection()->fd, gopherStateFree, gopherState);\n\n    if (((gopherState->type_id == GOPHER_INDEX) || (gopherState->type_id == GOPHER_CSO))\n            && (strchr(gopherState->request, '?') == NULL)) {\n        \/* Index URL without query word *\/\n        \/* We have to generate search page back to client. No need for connection *\/\n        gopherMimeCreate(gopherState);\n\n        if (gopherState->type_id == GOPHER_INDEX) {\n            gopherState->conversion = GopherStateData::HTML_INDEX_PAGE;\n        } else {\n            if (gopherState->type_id == GOPHER_CSO) {\n                gopherState->conversion = GopherStateData::HTML_CSO_PAGE;\n            } else {\n                gopherState->conversion = GopherStateData::HTML_INDEX_PAGE;\n            }\n        }\n\n        gopherToHTML(gopherState, (char *) NULL, 0);\n        fwd->markStoredReplyAsWhole(\"gopher instant internal request satisfaction\");\n        fwd->complete();\n        return;\n    }\n\n    \/\/ XXX: Sharing open Connection with FwdState that has its own handlers\/etc.\n    gopherState->serverConn = fwd->serverConnection();\n    gopherSendRequest(fwd->serverConnection()->fd, gopherState);\n    AsyncCall::Pointer timeoutCall = commCbCall(5, 4, \"gopherTimeout\",\n                                     CommTimeoutCbPtrFun(gopherTimeout, gopherState));\n    commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":281656,"func":"void CLASS packed_load_raw()\n{\n  int vbits=0, bwide, rbits, bite, half, irow, row, col, val, i;\n  UINT64 bitbuf=0;\n\n  bwide = raw_width * tiff_bps \/ 8;\n  bwide += bwide & load_flags >> 7;\n  rbits = bwide * 8 - raw_width * tiff_bps;\n  if (load_flags & 1) bwide = bwide * 16 \/ 15;\n  bite = 8 + (load_flags & 24);\n  half = (raw_height+1) >> 1;\n  for (irow=0; irow < raw_height; irow++) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    row = irow;\n    if (load_flags & 2 &&\n\t(row = irow % half * 2 + irow \/ half) == 1 &&\n\tload_flags & 4) {\n      if (vbits=0, tiff_compress)\n\tfseek (ifp, data_offset - (-half*bwide & -2048), SEEK_SET);\n      else {\n\tfseek (ifp, 0, SEEK_END);\n\tfseek (ifp, ftell(ifp) >> 3 << 2, SEEK_SET);\n      }\n    }\n    for (col=0; col < raw_width; col++) {\n      for (vbits -= tiff_bps; vbits < 0; vbits += bite) {\n\tbitbuf <<= bite;\n\tfor (i=0; i < bite; i+=8)\n\t  bitbuf |= (unsigned) (fgetc(ifp) << i);\n      }\n      val = bitbuf << (64-tiff_bps-vbits) >> (64-tiff_bps);\n      RAW(row,col ^ (load_flags >> 6 & 1)) = val;\n      if (load_flags & 1 && (col % 10) == 9 &&\n\tfgetc(ifp) && col < width+left_margin) derror();\n    }\n    vbits -= rbits;\n  }\n}","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":252339,"func":"int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version,\n                             const unsigned char *memory, size_t size,\n                             const char **err) {\n  if (memory == NULL || exr_header == NULL) {\n    tinyexr::SetErrorMessage(\n        \"Invalid argument. `memory` or `exr_header` argument is null in \"\n        \"ParseEXRHeaderFromMemory()\",\n        err);\n\n    \/\/ Invalid argument\n    return TINYEXR_ERROR_INVALID_ARGUMENT;\n  }\n\n  if (size < tinyexr::kEXRVersionSize) {\n    tinyexr::SetErrorMessage(\"Insufficient header\/data size.\\n\", err);\n    return TINYEXR_ERROR_INVALID_DATA;\n  }\n\n  const unsigned char *marker = memory + tinyexr::kEXRVersionSize;\n  size_t marker_size = size - tinyexr::kEXRVersionSize;\n\n  tinyexr::HeaderInfo info;\n  info.clear();\n\n  std::string err_str;\n  int ret = ParseEXRHeader(&info, NULL, version, &err_str, marker, marker_size);\n\n  if (ret != TINYEXR_SUCCESS) {\n    if (err && !err_str.empty()) {\n      tinyexr::SetErrorMessage(err_str, err);\n    }\n  }\n\n  ConvertHeader(exr_header, info);\n\n  \/\/ transfoer `tiled` from version.\n  exr_header->tiled = version->tiled;\n\n  return ret;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":313553,"func":"static int rose_neigh_show(struct seq_file *seq, void *v)\n{\n\tchar buf[11];\n\tint i;\n\n\tif (v == SEQ_START_TOKEN)\n\t\tseq_puts(seq,\n\t\t\t \"addr  callsign  dev  count use mode restart  t0  tf digipeaters\\n\");\n\telse {\n\t\tstruct rose_neigh *rose_neigh = v;\n\n\t\t\/* if (!rose_neigh->loopback) { *\/\n\t\tseq_printf(seq, \"%05d %-9s %-4s   %3d %3d  %3s     %3s %3lu %3lu\",\n\t\t\t   rose_neigh->number,\n\t\t\t   (rose_neigh->loopback) ? \"RSLOOP-0\" : ax2asc(buf, &rose_neigh->callsign),\n\t\t\t   rose_neigh->dev ? rose_neigh->dev->name : \"???\",\n\t\t\t   rose_neigh->count,\n\t\t\t   rose_neigh->use,\n\t\t\t   (rose_neigh->dce_mode) ? \"DCE\" : \"DTE\",\n\t\t\t   (rose_neigh->restarted) ? \"yes\" : \"no\",\n\t\t\t   ax25_display_timer(&rose_neigh->t0timer) \/ HZ,\n\t\t\t   ax25_display_timer(&rose_neigh->ftimer)  \/ HZ);\n\n\t\tif (rose_neigh->digipeat != NULL) {\n\t\t\tfor (i = 0; i < rose_neigh->digipeat->ndigi; i++)\n\t\t\t\tseq_printf(seq, \" %s\", ax2asc(buf, &rose_neigh->digipeat->calls[i]));\n\t\t}\n\n\t\tseq_puts(seq, \"\\n\");\n\t}\n\treturn 0;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":317038,"func":"static int smack_inode_setsecurity(struct inode *inode, const char *name,\n\t\t\t\t   const void *value, size_t size, int flags)\n{\n\tstruct smack_known *skp;\n\tstruct inode_smack *nsp = smack_inode(inode);\n\tstruct socket_smack *ssp;\n\tstruct socket *sock;\n\tint rc = 0;\n\n\tif (value == NULL || size > SMK_LONGLABEL || size == 0)\n\t\treturn -EINVAL;\n\n\tskp = smk_import_entry(value, size);\n\tif (IS_ERR(skp))\n\t\treturn PTR_ERR(skp);\n\n\tif (strcmp(name, XATTR_SMACK_SUFFIX) == 0) {\n\t\tnsp->smk_inode = skp;\n\t\tnsp->smk_flags |= SMK_INODE_INSTANT;\n\t\treturn 0;\n\t}\n\t\/*\n\t * The rest of the Smack xattrs are only on sockets.\n\t *\/\n\tif (inode->i_sb->s_magic != SOCKFS_MAGIC)\n\t\treturn -EOPNOTSUPP;\n\n\tsock = SOCKET_I(inode);\n\tif (sock == NULL || sock->sk == NULL)\n\t\treturn -EOPNOTSUPP;\n\n\tssp = sock->sk->sk_security;\n\n\tif (strcmp(name, XATTR_SMACK_IPIN) == 0)\n\t\tssp->smk_in = skp;\n\telse if (strcmp(name, XATTR_SMACK_IPOUT) == 0) {\n\t\tssp->smk_out = skp;\n\t\tif (sock->sk->sk_family == PF_INET) {\n\t\t\trc = smack_netlbl_add(sock->sk);\n\t\t\tif (rc != 0)\n\t\t\t\tprintk(KERN_WARNING\n\t\t\t\t\t\"Smack: \\\"%s\\\" netlbl error %d.\\n\",\n\t\t\t\t\t__func__, -rc);\n\t\t}\n\t} else\n\t\treturn -EOPNOTSUPP;\n\n#ifdef SMACK_IPV6_PORT_LABELING\n\tif (sock->sk->sk_family == PF_INET6)\n\t\tsmk_ipv6_port_label(sock, NULL);\n#endif\n\n\treturn 0;\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":508923,"func":"st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond,\n                                                         TABLE_LIST *derived)\n{\n  cond->clear_extraction_flag();\n  if (cond->type() == Item::COND_ITEM)\n  {\n    bool and_cond= ((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC;\n    List<Item> *arg_list=  ((Item_cond*) cond)->argument_list();\n    List_iterator<Item> li(*arg_list);\n    uint count= 0;         \/\/ to count items not containing NO_EXTRACTION_FL\n    uint count_full= 0;    \/\/ to count items with FULL_EXTRACTION_FL\n    Item *item;\n    while ((item=li++))\n    {\n      check_cond_extraction_for_grouping_fields(item, derived);\n      if (item->get_extraction_flag() !=  NO_EXTRACTION_FL)\n      {\n        count++;\n        if (item->get_extraction_flag() == FULL_EXTRACTION_FL)\n          count_full++;\n      }\n      else if (!and_cond)\n        break;\n    }\n    if ((and_cond && count == 0) || item)\n      cond->set_extraction_flag(NO_EXTRACTION_FL);\n    if (count_full == arg_list->elements)\n      cond->set_extraction_flag(FULL_EXTRACTION_FL);\n    if (cond->get_extraction_flag() != 0)\n    {\n      li.rewind();\n      while ((item=li++))\n        item->clear_extraction_flag();\n    }\n  }\n  else\n  {\n    int fl= cond->excl_dep_on_grouping_fields(this) ?\n      FULL_EXTRACTION_FL : NO_EXTRACTION_FL;\n    cond->set_extraction_flag(fl);\n  }\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":413861,"func":"void LinkResolver::check_klass_accessibility(Klass* ref_klass, Klass* sel_klass, TRAPS) {\n  Klass* base_klass = sel_klass;\n  if (sel_klass->is_objArray_klass()) {\n    base_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();\n  }\n  \/\/ The element type could be a typeArray - we only need the access\n  \/\/ check if it is a reference to another class.\n  if (!base_klass->is_instance_klass()) {\n    return;  \/\/ no relevant check to do\n  }\n\n  Reflection::VerifyClassAccessResults vca_result =\n    Reflection::verify_class_access(ref_klass, InstanceKlass::cast(base_klass), true);\n  if (vca_result != Reflection::ACCESS_OK) {\n    ResourceMark rm(THREAD);\n    char* msg = Reflection::verify_class_access_msg(ref_klass,\n                                                    InstanceKlass::cast(base_klass),\n                                                    vca_result);\n    bool same_module = (base_klass->module() == ref_klass->module());\n    if (msg == NULL) {\n      Exceptions::fthrow(\n        THREAD_AND_LOCATION,\n        vmSymbols::java_lang_IllegalAccessError(),\n        \"failed to access class %s from class %s (%s%s%s)\",\n        base_klass->external_name(),\n        ref_klass->external_name(),\n        (same_module) ? base_klass->joint_in_module_of_loader(ref_klass) : base_klass->class_in_module_of_loader(),\n        (same_module) ? \"\" : \"; \",\n        (same_module) ? \"\" : ref_klass->class_in_module_of_loader());\n    } else {\n      \/\/ Use module specific message returned by verify_class_access_msg().\n      Exceptions::fthrow(\n        THREAD_AND_LOCATION,\n        vmSymbols::java_lang_IllegalAccessError(),\n        \"%s\", msg);\n    }\n  }\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":473928,"func":"mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)\n{\n  int firstbyte = *p++;\n  state_t s;\n  s = trans[0][firstbyte];\n  if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1) :\n                                  ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-1);\n  s = trans[s][*p++];\n  if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2) :\n                                  ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-2);\n  s = trans[s][*p++];\n  if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(3) :\n                                  ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-3);\n  s = trans[s][*p++];\n  return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4) :\n                       ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":247533,"func":"  void initialize() {\n    TestUtility::loadFromYaml(TestEnvironment::substitute(server_ctx_yaml_),\n                              downstream_tls_context_);\n    auto server_cfg =\n        std::make_unique<ServerContextConfigImpl>(downstream_tls_context_, factory_context_);\n    manager_ = std::make_unique<ContextManagerImpl>(time_system_);\n    server_ssl_socket_factory_ = std::make_unique<ServerSslSocketFactory>(\n        std::move(server_cfg), *manager_, server_stats_store_, std::vector<std::string>{});\n\n    socket_ = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(\n        Network::Test::getCanonicalLoopbackAddress(GetParam()));\n    listener_ = dispatcher_->createListener(socket_, listener_callbacks_, runtime_, true, false);\n\n    TestUtility::loadFromYaml(TestEnvironment::substitute(client_ctx_yaml_), upstream_tls_context_);\n    auto client_cfg =\n        std::make_unique<ClientContextConfigImpl>(upstream_tls_context_, factory_context_);\n\n    client_ssl_socket_factory_ = std::make_unique<ClientSslSocketFactory>(\n        std::move(client_cfg), *manager_, client_stats_store_);\n    auto transport_socket = client_ssl_socket_factory_->createTransportSocket(nullptr);\n    client_transport_socket_ = transport_socket.get();\n    client_connection_ =\n        dispatcher_->createClientConnection(socket_->connectionInfoProvider().localAddress(),\n                                            source_address_, std::move(transport_socket), nullptr);\n    client_connection_->addConnectionCallbacks(client_callbacks_);\n    client_connection_->connect();\n    read_filter_ = std::make_shared<Network::MockReadFilter>();\n  }","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":231038,"func":"    BaseType_t xQueueCRSend( QueueHandle_t xQueue,\r\n                             const void * pvItemToQueue,\r\n                             TickType_t xTicksToWait )\r\n    {\r\n        BaseType_t xReturn;\r\n        Queue_t * const pxQueue = xQueue;\r\n\r\n        \/* If the queue is already full we may have to block.  A critical section\r\n         * is required to prevent an interrupt removing something from the queue\r\n         * between the check to see if the queue is full and blocking on the queue. *\/\r\n        portDISABLE_INTERRUPTS();\r\n        {\r\n            if( prvIsQueueFull( pxQueue ) != pdFALSE )\r\n            {\r\n                \/* The queue is full - do we want to block or just leave without\r\n                 * posting? *\/\r\n                if( xTicksToWait > ( TickType_t ) 0 )\r\n                {\r\n                    \/* As this is called from a coroutine we cannot block directly, but\r\n                     * return indicating that we need to block. *\/\r\n                    vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );\r\n                    portENABLE_INTERRUPTS();\r\n                    return errQUEUE_BLOCKED;\r\n                }\r\n                else\r\n                {\r\n                    portENABLE_INTERRUPTS();\r\n                    return errQUEUE_FULL;\r\n                }\r\n            }\r\n        }\r\n        portENABLE_INTERRUPTS();\r\n\r\n        portDISABLE_INTERRUPTS();\r\n        {\r\n            if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r\n            {\r\n                \/* There is room in the queue, copy the data into the queue. *\/\r\n                prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );\r\n                xReturn = pdPASS;\r\n\r\n                \/* Were any co-routines waiting for data to become available? *\/\r\n                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r\n                {\r\n                    \/* In this instance the co-routine could be placed directly\r\n                     * into the ready list as we are within a critical section.\r\n                     * Instead the same pending ready list mechanism is used as if\r\n                     * the event were caused from within an interrupt. *\/\r\n                    if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r\n                    {\r\n                        \/* The co-routine waiting has a higher priority so record\r\n                         * that a yield might be appropriate. *\/\r\n                        xReturn = errQUEUE_YIELD;\r\n                    }\r\n                    else\r\n                    {\r\n                        mtCOVERAGE_TEST_MARKER();\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n            }\r\n            else\r\n            {\r\n                xReturn = errQUEUE_FULL;\r\n            }\r\n        }\r\n        portENABLE_INTERRUPTS();\r\n\r\n        return xReturn;\r\n    }\r","target":0,"code_token_length":553,"total_token_length":789,"max_tokens_setting":1024}
+{"idx":483492,"func":"static ssize_t systab_show(struct kobject *kobj,\n\t\t\t   struct kobj_attribute *attr, char *buf)\n{\n\tchar *str = buf;\n\n\tif (!kobj || !buf)\n\t\treturn -EINVAL;\n\n\tif (efi.mps != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"MPS=0x%lx\\n\", efi.mps);\n\tif (efi.acpi20 != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"ACPI20=0x%lx\\n\", efi.acpi20);\n\tif (efi.acpi != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"ACPI=0x%lx\\n\", efi.acpi);\n\t\/*\n\t * If both SMBIOS and SMBIOS3 entry points are implemented, the\n\t * SMBIOS3 entry point shall be preferred, so we list it first to\n\t * let applications stop parsing after the first match.\n\t *\/\n\tif (efi.smbios3 != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"SMBIOS3=0x%lx\\n\", efi.smbios3);\n\tif (efi.smbios != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"SMBIOS=0x%lx\\n\", efi.smbios);\n\tif (efi.hcdp != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"HCDP=0x%lx\\n\", efi.hcdp);\n\tif (efi.boot_info != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"BOOTINFO=0x%lx\\n\", efi.boot_info);\n\tif (efi.uga != EFI_INVALID_TABLE_ADDR)\n\t\tstr += sprintf(str, \"UGA=0x%lx\\n\", efi.uga);\n\n\treturn str - buf;\n}","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":206588,"func":"gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)\n{\n  int lastBorder;\n  \/* Seek left *\/\n  int leftLimit, rightLimit;\n  int i;\n  leftLimit = (-1);\n  if (border < 0)\n    {\n      \/* Refuse to fill to a non-solid border *\/\n      return;\n    }\n  for (i = x; (i >= 0); i--)\n    {\n      if (gdImageGetPixel (im, i, y) == border)\n\t{\n\t  break;\n\t}\n      gdImageSetPixel (im, i, y, color);\n      leftLimit = i;\n    }\n  if (leftLimit == (-1))\n    {\n      return;\n    }\n  \/* Seek right *\/\n  rightLimit = x;\n  for (i = (x + 1); (i < im->sx); i++)\n    {\n      if (gdImageGetPixel (im, i, y) == border)\n\t{\n\t  break;\n\t}\n      gdImageSetPixel (im, i, y, color);\n      rightLimit = i;\n    }\n  \/* Look at lines above and below and start paints *\/\n  \/* Above *\/\n  if (y > 0)\n    {\n      lastBorder = 1;\n      for (i = leftLimit; (i <= rightLimit); i++)\n\t{\n\t  int c;\n\t  c = gdImageGetPixel (im, i, y - 1);\n\t  if (lastBorder)\n\t    {\n\t      if ((c != border) && (c != color))\n\t\t{\n\t\t  gdImageFillToBorder (im, i, y - 1,\n\t\t\t\t       border, color);\n\t\t  lastBorder = 0;\n\t\t}\n\t    }\n\t  else if ((c == border) || (c == color))\n\t    {\n\t      lastBorder = 1;\n\t    }\n\t}\n    }\n  \/* Below *\/\n  if (y < ((im->sy) - 1))\n    {\n      lastBorder = 1;\n      for (i = leftLimit; (i <= rightLimit); i++)\n\t{\n\t  int c;\n\t  c = gdImageGetPixel (im, i, y + 1);\n\t  if (lastBorder)\n\t    {\n\t      if ((c != border) && (c != color))\n\t\t{\n\t\t  gdImageFillToBorder (im, i, y + 1,\n\t\t\t\t       border, color);\n\t\t  lastBorder = 0;\n\t\t}\n\t    }\n\t  else if ((c == border) || (c == color))\n\t    {\n\t      lastBorder = 1;\n\t    }\n\t}\n    }\n}","target":1,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":238436,"func":"static void mark_ptr_or_null_reg(struct bpf_func_state *state,\n\t\t\t\t struct bpf_reg_state *reg, u32 id,\n\t\t\t\t bool is_null)\n{\n\tif (type_may_be_null(reg->type) && reg->id == id &&\n\t    !WARN_ON_ONCE(!reg->id)) {\n\t\tif (WARN_ON_ONCE(reg->smin_value || reg->smax_value ||\n\t\t\t\t !tnum_equals_const(reg->var_off, 0) ||\n\t\t\t\t reg->off)) {\n\t\t\t\/* Old offset (both fixed and variable parts) should\n\t\t\t * have been known-zero, because we don't allow pointer\n\t\t\t * arithmetic on pointers that might be NULL. If we\n\t\t\t * see this happening, don't convert the register.\n\t\t\t *\/\n\t\t\treturn;\n\t\t}\n\t\tif (is_null) {\n\t\t\treg->type = SCALAR_VALUE;\n\t\t\t\/* We don't need id and ref_obj_id from this point\n\t\t\t * onwards anymore, thus we should better reset it,\n\t\t\t * so that state pruning has chances to take effect.\n\t\t\t *\/\n\t\t\treg->id = 0;\n\t\t\treg->ref_obj_id = 0;\n\n\t\t\treturn;\n\t\t}\n\n\t\tmark_ptr_not_null_reg(reg);\n\n\t\tif (!reg_may_point_to_spin_lock(reg)) {\n\t\t\t\/* For not-NULL ptr, reg->ref_obj_id will be reset\n\t\t\t * in release_reg_references().\n\t\t\t *\n\t\t\t * reg->id is still used by spin_lock ptr. Other\n\t\t\t * than spin_lock ptr type, reg->id can be reset.\n\t\t\t *\/\n\t\t\treg->id = 0;\n\t\t}\n\t}\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":512814,"func":"static bool convert_const_to_int(THD *thd, Item_field *field_item,\n                                  Item **item)\n{\n  Field *field= field_item->field;\n  int result= 0;\n\n  \/*\n    We don't need to convert an integer to an integer,\n    pretend it's already converted.\n\n    But we still convert it if it is compared with a Field_year,\n    as YEAR(2) may change the value of an integer when converting it\n    to an integer (say, 0 to 70).\n  *\/\n  if ((*item)->cmp_type() == INT_RESULT &&\n      field_item->field_type() != MYSQL_TYPE_YEAR)\n    return 1;\n\n  if ((*item)->const_item() && !(*item)->is_expensive())\n  {\n    TABLE *table= field->table;\n    Sql_mode_save sql_mode(thd);\n    Check_level_instant_set check_level_save(thd, CHECK_FIELD_IGNORE);\n    MY_BITMAP *old_maps[2] = { NULL, NULL };\n    ulonglong UNINIT_VAR(orig_field_val); \/* original field value if valid *\/\n\n    \/* table->read_set may not be set if we come here from a CREATE TABLE *\/\n    if (table && table->read_set)\n      dbug_tmp_use_all_columns(table, old_maps,\n                               &table->read_set, &table->write_set);\n    \/* For comparison purposes allow invalid dates like 2000-01-32 *\/\n    thd->variables.sql_mode= (thd->variables.sql_mode & ~MODE_NO_ZERO_DATE) |\n                             MODE_INVALID_DATES;\n\n    \/*\n      Store the value of the field\/constant because the call to save_in_field\n      below overrides that value. Don't save field value if no data has been\n      read yet.\n    *\/\n    bool save_field_value= (field_item->const_item() ||\n                            !(field->table->status & STATUS_NO_RECORD));\n    if (save_field_value)\n      orig_field_val= field->val_int();\n    if (!(*item)->save_in_field(field, 1) && !field->is_null())\n    {\n      int field_cmp= 0;\n      \/\/ If item is a decimal value, we must reject it if it was truncated.\n      if (field->type() == MYSQL_TYPE_LONGLONG)\n      {\n        field_cmp= stored_field_cmp_to_item(thd, field, *item);\n        DBUG_PRINT(\"info\", (\"convert_const_to_int %d\", field_cmp));\n      }\n\n      if (0 == field_cmp)\n      {\n        Item *tmp= new (thd->mem_root) Item_int_with_ref(thd, field->val_int(), *item,\n                                         MY_TEST(field->flags & UNSIGNED_FLAG));\n        if (tmp)\n          thd->change_item_tree(item, tmp);\n        result= 1;\t\t\t\t\t\/\/ Item was replaced\n      }\n    }\n    \/* Restore the original field value. *\/\n    if (save_field_value)\n    {\n      result= field->store(orig_field_val, TRUE);\n      \/* orig_field_val must be a valid value that can be restored back. *\/\n      DBUG_ASSERT(!result);\n    }\n    if (table && table->read_set)\n      dbug_tmp_restore_column_maps(&table->read_set, &table->write_set, old_maps);\n  }\n  return result;\n}","target":0,"code_token_length":692,"total_token_length":928,"max_tokens_setting":1024}
+{"idx":210091,"func":"get_password(const char *prompt, char *input, int capacity)\n{\n#ifdef ENABLE_SYSTEMD\n\tint is_systemd_running;\n\tstruct stat a, b;\n\n\t\/* We simply test whether the systemd cgroup hierarchy is\n\t * mounted *\/\n\tis_systemd_running = (lstat(\"\/sys\/fs\/cgroup\", &a) == 0)\n\t\t&& (lstat(\"\/sys\/fs\/cgroup\/systemd\", &b) == 0)\n\t\t&& (a.st_dev != b.st_dev);\n\n\tif (is_systemd_running) {\n\t\tchar *cmd, *ret;\n\t\tFILE *ask_pass_fp = NULL;\n\n\t\tcmd = ret = NULL;\n\t\tif (asprintf(&cmd, \"systemd-ask-password \\\"%s\\\"\", prompt) >= 0) {\n\t\t\task_pass_fp = popen (cmd, \"re\");\n\t\t\tfree (cmd);\n\t\t}\n\n\t\tif (ask_pass_fp) {\n\t\t\tret = fgets(input, capacity, ask_pass_fp);\n\t\t\tpclose(ask_pass_fp);\n\t\t}\n\n\t\tif (ret) {\n\t\t\tint len = strlen(input);\n\t\t\tif (input[len - 1] == '\\n')\n\t\t\t\tinput[len - 1] = '\\0';\n\t\t\treturn input;\n\t\t}\n\t}\n#endif\n\n\t\/*\n\t * Falling back to getpass(..)\n\t * getpass is obsolete, but there's apparently nothing that replaces it\n\t *\/\n\tchar *tmp_pass = getpass(prompt);\n\tif (!tmp_pass)\n\t\treturn NULL;\n\n\tstrncpy(input, tmp_pass, capacity - 1);\n\tinput[capacity - 1] = '\\0';\n\n\t\/* zero-out the static buffer *\/\n\tmemset(tmp_pass, 0, strlen(tmp_pass));\n\n\treturn input;\n}","target":1,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":293766,"func":"static void process_constructors(RKernelCacheObj *obj, struct MACH0_(obj_t) *mach0, RList *ret, ut64 paddr, bool is_first, int mode, const char *prefix) {\n\tstruct section_t *sections = NULL;\n\tif (!(sections = MACH0_(get_sections) (mach0))) {\n\t\treturn;\n\t}\n\tint i, type;\n\tfor (i = 0; !sections[i].last; i++) {\n\t\tif (sections[i].size == 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (strstr (sections[i].name, \"_mod_fini_func\") || strstr (sections[i].name, \"_mod_term_func\")) {\n\t\t\ttype  = R_BIN_ENTRY_TYPE_FINI;\n\t\t} else if (strstr (sections[i].name, \"_mod_init_func\")) {\n\t\t\ttype  = is_first ? 0 : R_BIN_ENTRY_TYPE_INIT;\n\t\t\tis_first = false;\n\t\t} else {\n\t\t\tcontinue;\n\t\t}\n\n\t\tut8 *buf = calloc (sections[i].size, 1);\n\t\tif (!buf) {\n\t\t\tbreak;\n\t\t}\n\t\tif (r_buf_read_at (obj->cache_buf, sections[i].offset + paddr, buf, sections[i].size) < sections[i].size) {\n\t\t\tfree (buf);\n\t\t\tbreak;\n\t\t}\n\t\tint j;\n\t\tint count = 0;\n\t\tfor (j = 0; j < sections[i].size; j += 8) {\n\t\t\tut64 addr64 = K_RPTR (buf + j);\n\t\t\tut64 paddr64 = sections[i].offset + paddr + j;\n\t\t\tif (mode == R_K_CONSTRUCTOR_TO_ENTRY) {\n\t\t\t\tRBinAddr *ba = newEntry (paddr64, addr64, type);\n\t\t\t\tr_list_append (ret, ba);\n\t\t\t} else if (mode == R_K_CONSTRUCTOR_TO_SYMBOL) {\n\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tif (!sym) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsym->name = r_str_newf (\"%s.%s.%d\", prefix, (type == R_BIN_ENTRY_TYPE_INIT) ? \"init\" : \"fini\", count++);\n\t\t\t\tsym->vaddr = addr64;\n\t\t\t\tsym->paddr = paddr64;\n\t\t\t\tsym->size = 0;\n\t\t\t\tsym->forwarder = \"NONE\";\n\t\t\t\tsym->bind = \"GLOBAL\";\n\t\t\t\tsym->type = \"FUNC\";\n\n\t\t\t\tr_list_append (ret, sym);\n\t\t\t}\n\t\t}\n\t\tfree (buf);\n\t}\n\tfree (sections);\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":437324,"func":"renumber_by_map(Node* node, GroupNumRemap* map)\n{\n  int r = 0;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n  case NODE_ALT:\n    do {\n      r = renumber_by_map(NODE_CAR(node), map);\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_QUANT:\n    r = renumber_by_map(NODE_BODY(node), map);\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      r = renumber_by_map(NODE_BODY(node), map);\n      if (r != 0) return r;\n\n      if (en->type == ENCLOSURE_IF_ELSE) {\n        if (IS_NOT_NULL(en->te.Then)) {\n          r = renumber_by_map(en->te.Then, map);\n          if (r != 0) return r;\n        }\n        if (IS_NOT_NULL(en->te.Else)) {\n          r = renumber_by_map(en->te.Else, map);\n          if (r != 0) return r;\n        }\n      }\n    }\n    break;\n\n  case NODE_BACKREF:\n    r = renumber_node_backref(node, map);\n    break;\n\n  case NODE_ANCHOR:\n    if (IS_NOT_NULL(NODE_BODY(node)))\n      r = renumber_by_map(NODE_BODY(node), map);\n    break;\n\n  default:\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":221459,"func":"flatpak_run_add_pulseaudio_args (FlatpakBwrap *bwrap)\n{\n  g_autofree char *pulseaudio_server = flatpak_run_get_pulseaudio_server ();\n  g_autofree char *pulseaudio_socket = NULL;\n  g_autofree char *pulse_runtime_dir = flatpak_run_get_pulse_runtime_dir ();\n\n  if (pulseaudio_server)\n    pulseaudio_socket = flatpak_run_parse_pulse_server (pulseaudio_server);\n\n  if (!pulseaudio_socket)\n    {\n      pulseaudio_socket = g_build_filename (pulse_runtime_dir, \"native\", NULL);\n\n      if (!g_file_test (pulseaudio_socket, G_FILE_TEST_EXISTS))\n        g_clear_pointer (&pulseaudio_socket, g_free);\n    }\n\n  if (!pulseaudio_socket)\n    {\n      pulseaudio_socket = realpath (\"\/var\/run\/pulse\/native\", NULL);\n\n      if (pulseaudio_socket && !g_file_test (pulseaudio_socket, G_FILE_TEST_EXISTS))\n        g_clear_pointer (&pulseaudio_socket, g_free);\n    }\n\n  flatpak_bwrap_unset_env (bwrap, \"PULSE_SERVER\");\n\n  if (pulseaudio_socket && g_file_test (pulseaudio_socket, G_FILE_TEST_EXISTS))\n    {\n      static const char sandbox_socket_path[] = \"\/run\/flatpak\/pulse\/native\";\n      static const char pulse_server[] = \"unix:\/run\/flatpak\/pulse\/native\";\n      static const char config_path[] = \"\/run\/flatpak\/pulse\/config\";\n      gboolean share_shm = FALSE; \/* TODO: When do we add this? *\/\n      g_autofree char *client_config = g_strdup_printf (\"enable-shm=%s\\n\", share_shm ? \"yes\" : \"no\");\n\n      \/* FIXME - error handling *\/\n      if (!flatpak_bwrap_add_args_data (bwrap, \"pulseaudio\", client_config, -1, config_path, NULL))\n        return;\n\n      flatpak_bwrap_add_args (bwrap,\n                              \"--ro-bind\", pulseaudio_socket, sandbox_socket_path,\n                              NULL);\n\n      flatpak_bwrap_set_env (bwrap, \"PULSE_SERVER\", pulse_server, TRUE);\n      flatpak_bwrap_set_env (bwrap, \"PULSE_CLIENTCONFIG\", config_path, TRUE);\n      flatpak_bwrap_add_runtime_dir_member (bwrap, \"pulse\");\n    }\n  else\n    g_debug (\"Could not find pulseaudio socket\");\n\n  \/* Also allow ALSA access. This was added in 1.8, and is not ideally named. However,\n   * since the practical permission of ALSA and PulseAudio are essentially the same, and\n   * since we don't want to add more permissions for something we plan to replace with\n   * portals\/pipewire going forward we reinterpret pulseaudio to also mean ALSA.\n   *\/\n  if (g_file_test (\"\/dev\/snd\", G_FILE_TEST_IS_DIR))\n    flatpak_bwrap_add_args (bwrap, \"--dev-bind\", \"\/dev\/snd\", \"\/dev\/snd\", NULL);\n}","target":0,"code_token_length":618,"total_token_length":854,"max_tokens_setting":1024}
+{"idx":209931,"func":"static PresentationContext* PresentationContext_new(VideoClientContext* video, BYTE PresentationId,\n                                                    UINT32 x, UINT32 y, UINT32 width, UINT32 height)\n{\n\tVideoClientContextPriv* priv = video->priv;\n\tPresentationContext* ret = calloc(1, sizeof(*ret));\n\tif (!ret)\n\t\treturn NULL;\n\n\tret->video = video;\n\tret->PresentationId = PresentationId;\n\n\tret->h264 = h264_context_new(FALSE);\n\tif (!ret->h264)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create a h264 context\");\n\t\tgoto error_h264;\n\t}\n\th264_context_reset(ret->h264, width, height);\n\n\tret->currentSample = Stream_New(NULL, 4096);\n\tif (!ret->currentSample)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create current packet stream\");\n\t\tgoto error_currentSample;\n\t}\n\n\tret->surfaceData = BufferPool_Take(priv->surfacePool, width * height * 4);\n\tif (!ret->surfaceData)\n\t{\n\t\tWLog_ERR(TAG, \"unable to allocate surfaceData\");\n\t\tgoto error_surfaceData;\n\t}\n\n\tret->surface = video->createSurface(video, ret->surfaceData, x, y, width, height);\n\tif (!ret->surface)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create surface\");\n\t\tgoto error_surface;\n\t}\n\n\tret->yuv = yuv_context_new(FALSE);\n\tif (!ret->yuv)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create YUV decoder\");\n\t\tgoto error_yuv;\n\t}\n\n\tyuv_context_reset(ret->yuv, width, height);\n\tret->refCounter = 1;\n\treturn ret;\n\nerror_yuv:\n\tvideo->deleteSurface(video, ret->surface);\nerror_surface:\n\tBufferPool_Return(priv->surfacePool, ret->surfaceData);\nerror_surfaceData:\n\tStream_Free(ret->currentSample, TRUE);\nerror_currentSample:\n\th264_context_free(ret->h264);\nerror_h264:\n\tfree(ret);\n\treturn NULL;\n}","target":1,"code_token_length":445,"total_token_length":681,"max_tokens_setting":1024}
+{"idx":455332,"func":"restore_tilde (val, directory_part)\n     char *val, *directory_part;\n{\n  int l, vl, dl2, xl;\n  char *dh2, *expdir, *ret, *v;\n\n  vl = strlen (val);\n\n  \/* We need to duplicate the expansions readline performs on the directory\n     portion before passing it to our completion function. *\/\n  dh2 = directory_part ? bash_dequote_filename (directory_part, 0) : 0;\n  bash_directory_expansion (&dh2);\n  dl2 = strlen (dh2);\n\n  expdir = bash_tilde_expand (directory_part, 0);\n  xl = strlen (expdir);\n  if (*directory_part == '~' && STREQ (directory_part, expdir))\n    {\n      \/* tilde expansion failed, so what should we return? we use what the\n\t user typed. *\/\n      v = mbschr (val, '\/');\n      vl = STRLEN (v);\n      ret = (char *)xmalloc (xl + vl + 2);\n      strcpy (ret, directory_part);\n      if (v && *v)\n\tstrcpy (ret + xl, v);\n\n      free (dh2);\n      free (expdir);\n\n      return ret;\n    }\n  free (expdir);\n\n  \/*\n     dh2 = unexpanded but dequoted tilde-prefix\n     dl2 = length of tilde-prefix\n     expdir = tilde-expanded tilde-prefix\n     xl = length of expanded tilde-prefix\n     l = length of remainder after tilde-prefix\n  *\/\n  l = (vl - xl) + 1;\n  if (l <= 0)\n    {\n      free (dh2);\n      return (savestring (val));\t\t\/* XXX - just punt *\/\n    }\n\n  ret = (char *)xmalloc (dl2 + 2 + l);\n  strcpy (ret, dh2);\n  strcpy (ret + dl2, val + xl);\n\n  free (dh2);\n  return (ret);\n}","target":0,"code_token_length":420,"total_token_length":656,"max_tokens_setting":1024}
+{"idx":328949,"func":"R_API void r_bin_java_print_code_attr_summary(RBinJavaAttrInfo *attr) {\n\tRListIter *iter = NULL, *iter_tmp = NULL;\n\tRBinJavaExceptionEntry *exc_entry = NULL;\n\tRBinJavaAttrInfo *_attr = NULL;\n\tif (!attr) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaAttrInfo *Code.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"Code Attribute Information:\\n\");\n\tprintf (\"  Attribute Offset: 0x%08\"PFMT64x \"\\n\", attr->file_offset);\n\tprintf (\"  Attribute Name Index: %d (%s)\\n\", attr->name_idx, attr->name);\n\tprintf (\"  Attribute Length: %d, Attribute Count: %d\\n\", attr->length, attr->info.code_attr.attributes_count);\n\tprintf (\"    Max Stack: %d\\n\", attr->info.code_attr.max_stack);\n\tprintf (\"    Max Locals: %d\\n\", attr->info.code_attr.max_locals);\n\tprintf (\"    Code Length: %d\\n\", attr->info.code_attr.code_length);\n\tprintf (\"    Code At Offset: 0x%08\"PFMT64x \"\\n\", (ut64) attr->info.code_attr.code_offset);\n\tprintf (\"Code Attribute Exception Table Information:\\n\");\n\tprintf (\"  Exception Table Length: %d\\n\", attr->info.code_attr.exception_table_length);\n\tif (attr->info.code_attr.exception_table) {\n\t\t\/\/ Delete the attr entries\n\t\tr_list_foreach_safe (attr->info.code_attr.exception_table, iter, iter_tmp, exc_entry) {\n\t\t\tr_bin_java_print_code_exceptions_attr_summary (exc_entry);\n\t\t}\n\t}\n\tprintf (\"  Implicit Method Stack Frame:\\n\");\n\tr_bin_java_print_stack_map_frame_summary (attr->info.code_attr.implicit_frame);\n\tprintf (\"Code Attribute Attributes Information:\\n\");\n\tif (attr->info.code_attr.attributes && attr->info.code_attr.attributes_count > 0) {\n\t\tprintf (\"  Code Attribute Attributes Count: %d\\n\", attr->info.code_attr.attributes_count);\n\t\tr_list_foreach_safe (attr->info.code_attr.attributes, iter, iter_tmp, _attr) {\n\t\t\tr_bin_java_print_attr_summary (_attr);\n\t\t}\n\t}\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":253595,"func":"smb3_notify(const unsigned int xid, struct file *pfile,\n\t    void __user *ioc_buf)\n{\n\tstruct smb3_notify notify;\n\tstruct dentry *dentry = pfile->f_path.dentry;\n\tstruct inode *inode = file_inode(pfile);\n\tstruct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);\n\tstruct cifs_open_parms oparms;\n\tstruct cifs_fid fid;\n\tstruct cifs_tcon *tcon;\n\tconst unsigned char *path;\n\tvoid *page = alloc_dentry_path();\n\t__le16 *utf16_path = NULL;\n\tu8 oplock = SMB2_OPLOCK_LEVEL_NONE;\n\tint rc = 0;\n\n\tpath = build_path_from_dentry(dentry, page);\n\tif (IS_ERR(path)) {\n\t\trc = PTR_ERR(path);\n\t\tgoto notify_exit;\n\t}\n\n\tutf16_path = cifs_convert_path_to_utf16(path, cifs_sb);\n\tif (utf16_path == NULL) {\n\t\trc = -ENOMEM;\n\t\tgoto notify_exit;\n\t}\n\n\tif (copy_from_user(¬ify, ioc_buf, sizeof(struct smb3_notify))) {\n\t\trc = -EFAULT;\n\t\tgoto notify_exit;\n\t}\n\n\ttcon = cifs_sb_master_tcon(cifs_sb);\n\toparms.tcon = tcon;\n\toparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;\n\toparms.disposition = FILE_OPEN;\n\toparms.create_options = cifs_create_options(cifs_sb, 0);\n\toparms.fid = &fid;\n\toparms.reconnect = false;\n\n\trc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL, NULL,\n\t\t       NULL);\n\tif (rc)\n\t\tgoto notify_exit;\n\n\trc = SMB2_change_notify(xid, tcon, fid.persistent_fid, fid.volatile_fid,\n\t\t\t\tnotify.watch_tree, notify.completion_filter);\n\n\tSMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);\n\n\tcifs_dbg(FYI, \"change notify for path %s rc %d\\n\", path, rc);\n\nnotify_exit:\n\tfree_dentry_path(page);\n\tkfree(utf16_path);\n\treturn rc;\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":514300,"func":"static bool check_fields(THD *thd, List<Item> &items, bool update_view)\n{\n  Item *item;\n  if (update_view)\n  {\n    List_iterator<Item> it(items);\n    Item_field *field;\n    while ((item= it++))\n    {\n      if (!(field= item->field_for_view_update()))\n      {\n        \/* item has name, because it comes from VIEW SELECT list *\/\n        my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name.str);\n        return TRUE;\n      }\n      \/*\n        we make temporary copy of Item_field, to avoid influence of changing\n        result_field on Item_ref which refer on this field\n      *\/\n      thd->change_item_tree(it.ref(),\n                            new (thd->mem_root) Item_field(thd, field));\n    }\n  }\n\n  if (thd->variables.sql_mode & MODE_SIMULTANEOUS_ASSIGNMENT)\n  {\n    \/\/ Make sure that a column is updated only once\n    List_iterator_fast<Item> it(items);\n    while ((item= it++))\n    {\n      item->field_for_view_update()->field->clear_has_explicit_value();\n    }\n    it.rewind();\n    while ((item= it++))\n    {\n      Field *f= item->field_for_view_update()->field;\n      if (f->has_explicit_value())\n      {\n        my_error(ER_UPDATED_COLUMN_ONLY_ONCE, MYF(0),\n                 *(f->table_name), f->field_name.str);\n        return TRUE;\n      }\n      f->set_has_explicit_value();\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":457772,"func":"static size_t handle_returned_header (void *ptr, size_t size, size_t nmemb, void *stream)\n{\n    auth_client *auth_user = stream;\n    size_t len = size * nmemb;\n    client_t *client = auth_user->client;\n\n    if (client) {\n        auth_t *auth = client->auth;\n        auth_url *url = auth->state;\n\n        if (url->auth_header && len >= url->auth_header_len && strncasecmp(ptr, url->auth_header, url->auth_header_len) == 0)\n            client->authenticated = 1;\n\n        if (url->timelimit_header && len > url->timelimit_header_len && strncasecmp(ptr, url->timelimit_header, url->timelimit_header_len) == 0) {\n            const char *input = ptr;\n            unsigned int limit = 0;\n\n            if (len >= 2 && input[len - 2] == '\\r' && input[len - 1] == '\\n') {\n                input += url->timelimit_header_len;\n\n                if (sscanf(input, \"%u\\r\\n\", &limit) == 1) {\n                    client->con->discon_time = time(NULL) + limit;\n                } else {\n                    ICECAST_LOG_ERROR(\"Auth backend returned invalid timeline header: Can not parse limit\");\n                }\n            } else {\n                ICECAST_LOG_ERROR(\"Auth backend returned invalid timelimit header.\");\n            }\n        }\n\n        if (len > 24 && strncasecmp(ptr, \"icecast-auth-message: \", 22) == 0) {\n            const char *input = ptr;\n            size_t copy_len = len - 24 + 1; \/* length of string plus \\0-termination *\/\n\n            if (copy_len > sizeof(url->errormsg)) {\n                copy_len = sizeof(url->errormsg);\n            }\n\n            if (len >= 2 && input[len - 2] == '\\r' && input[len - 1] == '\\n') {\n                input += 22;\n                memcpy(url->errormsg, input, copy_len);\n                url->errormsg[copy_len-1] = 0;\n            } else {\n                ICECAST_LOG_ERROR(\"Auth backend returned invalid message header.\");\n            }\n        }\n    }\n\n    return len;\n}","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":281635,"func":"void CLASS parse_exif (int base)\n{\n  unsigned kodak, entries, tag, type, len, save, c;\n  double expo;\n\n  kodak = !strncmp(make,\"EASTMAN\",7) && tiff_nifds < 3;\n  entries = get2();\n  while (entries--) {\n    tiff_get (base, &tag, &type, &len, &save);\n    switch (tag) {\n      case 33434:  shutter = getreal(type);\t\tbreak;\n      case 33437:  aperture = getreal(type);\t\tbreak;\n      case 34855:  iso_speed = get2();\t\t\tbreak;\n      case 36867:\n      case 36868:  get_timestamp(0);\t\t\tbreak;\n      case 37377:  if ((expo = -getreal(type)) < 128)\n\t\t     shutter = pow (2.0, expo);\t\tbreak;\n      case 37378:  aperture = pow (2.0, getreal(type)\/2);\tbreak;\n      case 37386:  focal_len = getreal(type);\t\tbreak;\n      case 37500:  parse_makernote (base, 0);\t\tbreak;\n      case 40962:  if (kodak) raw_width  = get4();\tbreak;\n      case 40963:  if (kodak) raw_height = get4();\tbreak;\n      case 41730:\n\tif (get4() == 0x20002)\n\t  for (exif_cfa=c=0; c < 8; c+=2)\n\t    exif_cfa |= fgetc(ifp) * 0x01010101 << c;\n    }\n    fseek (ifp, save, SEEK_SET);\n  }\n}","target":0,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":225010,"func":"conninfo_uri_decode(const char *str, PQExpBuffer errorMessage)\n{\n\tchar\t   *buf;\n\tchar\t   *p;\n\tconst char *q = str;\n\n\tbuf = malloc(strlen(str) + 1);\n\tif (buf == NULL)\n\t{\n\t\tappendPQExpBufferStr(errorMessage, libpq_gettext(\"out of memory\\n\"));\n\t\treturn NULL;\n\t}\n\tp = buf;\n\n\tfor (;;)\n\t{\n\t\tif (*q != '%')\n\t\t{\n\t\t\t\/* copy and check for NUL terminator *\/\n\t\t\tif (!(*(p++) = *(q++)))\n\t\t\t\tbreak;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint\t\t\thi;\n\t\t\tint\t\t\tlo;\n\t\t\tint\t\t\tc;\n\n\t\t\t++q;\t\t\t\t\/* skip the percent sign itself *\/\n\n\t\t\t\/*\n\t\t\t * Possible EOL will be caught by the first call to\n\t\t\t * get_hexdigit(), so we never dereference an invalid q pointer.\n\t\t\t *\/\n\t\t\tif (!(get_hexdigit(*q++, &hi) && get_hexdigit(*q++, &lo)))\n\t\t\t{\n\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"invalid percent-encoded token: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t  str);\n\t\t\t\tfree(buf);\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tc = (hi << 4) | lo;\n\t\t\tif (c == 0)\n\t\t\t{\n\t\t\t\tappendPQExpBuffer(errorMessage,\n\t\t\t\t\t\t\t\t  libpq_gettext(\"forbidden value %%00 in percent-encoded value: \\\"%s\\\"\\n\"),\n\t\t\t\t\t\t\t\t  str);\n\t\t\t\tfree(buf);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\t*(p++) = c;\n\t\t}\n\t}\n\n\treturn buf;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":198116,"func":"  void Compute(OpKernelContext *ctx) override {\n    const Tensor *indices_t, *values_t, *shape_t, *reduction_axes_t;\n    OP_REQUIRES_OK(ctx, ctx->input(\"input_indices\", &indices_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"input_values\", &values_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"input_shape\", &shape_t));\n    OP_REQUIRES_OK(ctx, ctx->input(\"reduction_axes\", &reduction_axes_t));\n\n    OP_REQUIRES_OK(ctx, ValidateInputs(shape_t, reduction_axes_t));\n\n    \/\/ TODO(zongheng): we will call Reorder() below, which will modify\n    \/\/ in-place the underlying indices and values buffers.  To avoid\n    \/\/ surprises of this kernel being stateful, we work around the above by\n    \/\/ making deep copies here.  Remove this if\/when we change Reorder()'s\n    \/\/ semantics.\n    const auto shape_vec = shape_t->vec<int64>();\n    SparseTensor sp;\n    OP_REQUIRES_OK(ctx, SparseTensor::Create(\n        tensor::DeepCopy(*indices_t), tensor::DeepCopy(*values_t),\n                    TensorShape(shape_vec), &sp));\n    ReduceDetails reduction = SparseTensorReduceHelper(\n        sp, reduction_axes_t->flat<int32>(), keep_dims_);\n\n    Tensor *out_values;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_output(0, reduction.reduced_shape, &out_values));\n    auto out_flat = out_values->flat<T>();\n    out_flat.setZero();\n\n    Tensor tmp_reduced_val;\n    OP_REQUIRES_OK(ctx, ctx->allocate_temp(DataTypeToEnum<T>::value,\n                                           TensorShape({}), &tmp_reduced_val));\n    auto reduced_val = tmp_reduced_val.scalar<T>();\n\n    \/\/ Compute strides, and use it to convert coords to flat index.  The\n    \/\/ coordinates returned by .group() have the same ndims as group_by_dims.\n    gtl::InlinedVector<int64, 8> output_strides(reduction.group_by_dims.size());\n    if (!output_strides.empty()) {  \/\/ Do this iff we don't reduce all.\n      output_strides.back() = 1;\n      for (int d = output_strides.size() - 2; d >= 0; --d) {\n        output_strides[d] =\n            output_strides[d + 1] * shape_vec(reduction.group_by_dims[d + 1]);\n      }\n    }\n\n    auto CoordinatesToFlatIndex = [](ArraySlice<int64> coords,\n                                     ArraySlice<int64> strides) -> int64 {\n      if (strides.empty()) {  \/\/ Reduce all.\n        return 0;\n      }\n      CHECK_EQ(coords.size(), strides.size());\n      int64_t idx = 0;\n      for (int i = 0; i < coords.size(); ++i) {\n        idx += coords[i] * strides[i];\n      }\n      return idx;\n    };\n\n    \/\/ Each group maps one-on-one onto a value in the reduced tensor.\n    \/\/ g.group() provides the coordinates of a particular reduced value.\n    sp.Reorder<T>(reduction.reorder_dims);\n    for (const auto &g : sp.group(reduction.group_by_dims)) {\n      Op::template Run<T>(ctx, reduced_val, g.template values<T>());\n      const int64_t idx = CoordinatesToFlatIndex(g.group(), output_strides);\n      out_flat(idx) = reduced_val();\n      VLOG(2) << \"coords: \" << absl::StrJoin(g.group(), \",\")\n              << \"; idx: \" << idx << \"; group \" << Op::Name() << \": \"\n              << reduced_val();\n    }\n  }","target":1,"code_token_length":783,"total_token_length":1019,"max_tokens_setting":1024}
+{"idx":512578,"func":"longlong Item_in_optimizer::val_int()\n{\n  bool tmp;\n  DBUG_ASSERT(fixed == 1);\n  cache->store(args[0]);\n  cache->cache_value();\n  DBUG_ENTER(\" Item_in_optimizer::val_int\");\n\n  if (invisible_mode())\n  {\n    longlong res= args[1]->val_int();\n    null_value= args[1]->null_value;\n    DBUG_PRINT(\"info\", (\"pass trough\"));\n    DBUG_RETURN(res);\n  }\n\n  if (cache->null_value_inside)\n  {\n     DBUG_PRINT(\"info\", (\"Left NULL...\"));\n    \/*\n      We're evaluating \n      \"<outer_value_list> [NOT] IN (SELECT <inner_value_list>...)\" \n      where one or more of the outer values is NULL. \n    *\/\n    if (((Item_in_subselect*)args[1])->is_top_level_item())\n    {\n      \/*\n        We're evaluating a top level item, e.g. \n\t\"<outer_value_list> IN (SELECT <inner_value_list>...)\",\n\tand in this case a NULL value in the outer_value_list means\n        that the result shall be NULL\/FALSE (makes no difference for\n        top level items). The cached value is NULL, so just return\n        NULL.\n      *\/\n      null_value= 1;\n    }\n    else\n    {\n      \/*\n\tWe're evaluating an item where a NULL value in either the\n        outer or inner value list does not automatically mean that we\n        can return NULL\/FALSE. An example of such a query is\n        \"<outer_value_list> NOT IN (SELECT <inner_value_list>...)\" \n        The result when there is at least one NULL value is: NULL if the\n        SELECT evaluated over the non-NULL values produces at least\n        one row, FALSE otherwise\n      *\/\n      Item_in_subselect *item_subs=(Item_in_subselect*)args[1]; \n      bool all_left_cols_null= true;\n      const uint ncols= cache->cols();\n\n      \/*\n        Turn off the predicates that are based on column compares for\n        which the left part is currently NULL\n      *\/\n      for (uint i= 0; i < ncols; i++)\n      {\n        if (cache->element_index(i)->null_value)\n          item_subs->set_cond_guard_var(i, FALSE);\n        else \n          all_left_cols_null= false;\n      }\n\n      if (!item_subs->is_correlated && \n          all_left_cols_null && result_for_null_param != UNKNOWN)\n      {\n        \/* \n           This is a non-correlated subquery, all values in the outer\n           value list are NULL, and we have already evaluated the\n           subquery for all NULL values: Return the same result we\n           did last time without evaluating the subquery.\n        *\/\n        null_value= result_for_null_param;\n      } \n      else \n      {\n        \/* The subquery has to be evaluated *\/\n        (void) item_subs->val_bool_result();\n        if (item_subs->engine->no_rows())\n          null_value= item_subs->null_value;\n        else\n          null_value= TRUE;\n        if (all_left_cols_null)\n          result_for_null_param= null_value;\n      }\n\n      \/* Turn all predicates back on *\/\n      for (uint i= 0; i < ncols; i++)\n        item_subs->set_cond_guard_var(i, TRUE);\n    }\n    DBUG_RETURN(0);\n  }\n  tmp= args[1]->val_bool_result();\n  null_value= args[1]->null_value;\n  DBUG_RETURN(tmp);\n}","target":0,"code_token_length":742,"total_token_length":978,"max_tokens_setting":1024}
+{"idx":344818,"func":"safe_path(const char *name, struct stat *stp, const char *pw_dir,\n    uid_t uid, char *err, size_t errlen)\n{\n\tchar buf[PATH_MAX], homedir[PATH_MAX];\n\tchar *cp;\n\tint comparehome = 0;\n\tstruct stat st;\n\n\tif (realpath(name, buf) == NULL) {\n\t\tsnprintf(err, errlen, \"realpath %s failed: %s\", name,\n\t\t    strerror(errno));\n\t\treturn -1;\n\t}\n\tif (pw_dir != NULL && realpath(pw_dir, homedir) != NULL)\n\t\tcomparehome = 1;\n\n\tif (!S_ISREG(stp->st_mode)) {\n\t\tsnprintf(err, errlen, \"%s is not a regular file\", buf);\n\t\treturn -1;\n\t}\n\tif ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) ||\n\t    (stp->st_mode & 022) != 0) {\n\t\tsnprintf(err, errlen, \"bad ownership or modes for file %s\",\n\t\t    buf);\n\t\treturn -1;\n\t}\n\n\t\/* for each component of the canonical path, walking upwards *\/\n\tfor (;;) {\n\t\tif ((cp = dirname(buf)) == NULL) {\n\t\t\tsnprintf(err, errlen, \"dirname() failed\");\n\t\t\treturn -1;\n\t\t}\n\t\tstrlcpy(buf, cp, sizeof(buf));\n\n\t\tif (stat(buf, &st) == -1 ||\n\t\t    (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) ||\n\t\t    (st.st_mode & 022) != 0) {\n\t\t\tsnprintf(err, errlen,\n\t\t\t    \"bad ownership or modes for directory %s\", buf);\n\t\t\treturn -1;\n\t\t}\n\n\t\t\/* If are past the homedir then we can stop *\/\n\t\tif (comparehome && strcmp(homedir, buf) == 0)\n\t\t\tbreak;\n\n\t\t\/*\n\t\t * dirname should always complete with a \"\/\" path,\n\t\t * but we can be paranoid and check for \".\" too\n\t\t *\/\n\t\tif ((strcmp(\"\/\", buf) == 0) || (strcmp(\".\", buf) == 0))\n\t\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":353239,"func":"void SplashOutputDev::updateTransfer(GfxState *state) {\n  Function **transfer;\n  unsigned char red[256], green[256], blue[256], gray[256];\n  double x, y;\n  int i;\n\n  transfer = state->getTransfer();\n  if (transfer[0] &&\n      transfer[0]->getInputSize() == 1 &&\n      transfer[0]->getOutputSize() == 1) {\n    if (transfer[1] &&\n\ttransfer[1]->getInputSize() == 1 &&\n\ttransfer[1]->getOutputSize() == 1 &&\n\ttransfer[2] &&\n\ttransfer[2]->getInputSize() == 1 &&\n\ttransfer[2]->getOutputSize() == 1 &&\n\ttransfer[3] &&\n\ttransfer[3]->getInputSize() == 1 &&\n\ttransfer[3]->getOutputSize() == 1) {\n      for (i = 0; i < 256; ++i) {\n\tx = i \/ 255.0;\n\ttransfer[0]->transform(&x, &y);\n\tred[i] = (unsigned char)(y * 255.0 + 0.5);\n\ttransfer[1]->transform(&x, &y);\n\tgreen[i] = (unsigned char)(y * 255.0 + 0.5);\n\ttransfer[2]->transform(&x, &y);\n\tblue[i] = (unsigned char)(y * 255.0 + 0.5);\n\ttransfer[3]->transform(&x, &y);\n\tgray[i] = (unsigned char)(y * 255.0 + 0.5);\n      }\n    } else {\n      for (i = 0; i < 256; ++i) {\n\tx = i \/ 255.0;\n\ttransfer[0]->transform(&x, &y);\n\tred[i] = green[i] = blue[i] = gray[i] = (unsigned char)(y * 255.0 + 0.5);\n      }\n    }\n  } else {\n    for (i = 0; i < 256; ++i) {\n      red[i] = green[i] = blue[i] = gray[i] = (unsigned char)i;\n    }\n  }\n  splash->setTransfer(red, green, blue, gray);\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":386599,"func":"void DL_Dxf::writeHatch2(DL_WriterA& dw,\n                         const DL_HatchData& data,\n                         const DL_Attributes& \/*attrib*\/) {\n\n    dw.dxfInt(75, 0);                \/\/ odd parity\n    dw.dxfInt(76, 1);                \/\/ pattern type\n    if (data.solid==false) {\n        dw.dxfReal(52, data.angle);\n        dw.dxfReal(41, data.scale);\n        dw.dxfInt(77, 0);            \/\/ not double\n        \/\/dw.dxfInt(78, 0);\n        dw.dxfInt(78, 1);\n        dw.dxfReal(53, 45.0);\n        dw.dxfReal(43, 0.0);\n        dw.dxfReal(44, 0.0);\n        dw.dxfReal(45, -0.0883883476483184);\n        dw.dxfReal(46, 0.0883883476483185);\n        dw.dxfInt(79, 0);\n    }\n    dw.dxfInt(98, 0);\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(1001, \"ACAD\");\n        dw.dxfReal(1010, data.originX);\n        dw.dxfReal(1020, data.originY);\n        dw.dxfInt(1030, 0.0);\n    }\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":259304,"func":"static int cbcs_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *input, int size)\n{\n    int i, ret, rem_bytes;\n    uint8_t iv[16];\n    uint8_t *data;\n\n    if (!sc->cenc.aes_ctx) {\n        \/* initialize the cipher *\/\n        sc->cenc.aes_ctx = av_aes_alloc();\n        if (!sc->cenc.aes_ctx) {\n            return AVERROR(ENOMEM);\n        }\n\n        ret = av_aes_init(sc->cenc.aes_ctx, c->decryption_key, 16 * 8, 1);\n        if (ret < 0) {\n            return ret;\n        }\n    }\n\n    \/* whole-block full sample encryption *\/\n    if (!sample->subsample_count) {\n        \/* decrypt the whole packet *\/\n        memcpy(iv, sample->iv, 16);\n        av_aes_crypt(sc->cenc.aes_ctx, input, input, size\/16, iv, 1);\n        return 0;\n    } else if (!sample->crypt_byte_block && !sample->skip_byte_block) {\n        av_log(c->fc, AV_LOG_ERROR, \"pattern encryption is not present in 'cbcs' scheme\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n\n    for (i = 0; i < sample->subsample_count; i++) {\n        if (sample->subsamples[i].bytes_of_clear_data + sample->subsamples[i].bytes_of_protected_data > size) {\n            av_log(c->fc, AV_LOG_ERROR, \"subsample size exceeds the packet size left\\n\");\n            return AVERROR_INVALIDDATA;\n        }\n\n        \/* skip the clear bytes *\/\n        input += sample->subsamples[i].bytes_of_clear_data;\n        size -= sample->subsamples[i].bytes_of_clear_data;\n\n        \/* decrypt the encrypted bytes *\/\n        memcpy(iv, sample->iv, 16);\n        data = input;\n        rem_bytes = sample->subsamples[i].bytes_of_protected_data;\n        while (rem_bytes > 0) {\n            if (rem_bytes < 16*sample->crypt_byte_block) {\n                break;\n            }\n            av_aes_crypt(sc->cenc.aes_ctx, data, data, sample->crypt_byte_block, iv, 1);\n            data += 16*sample->crypt_byte_block;\n            rem_bytes -= 16*sample->crypt_byte_block;\n            data += FFMIN(16*sample->skip_byte_block, rem_bytes);\n            rem_bytes -= FFMIN(16*sample->skip_byte_block, rem_bytes);\n        }\n        input += sample->subsamples[i].bytes_of_protected_data;\n        size -= sample->subsamples[i].bytes_of_protected_data;\n    }\n\n    if (size > 0) {\n        av_log(c->fc, AV_LOG_ERROR, \"leftover packet bytes after subsample processing\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n\n    return 0;\n}","target":0,"code_token_length":640,"total_token_length":876,"max_tokens_setting":1024}
+{"idx":234833,"func":"static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info)\n{\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tstruct btrfs_fs_devices *old_devices;\n\tstruct btrfs_fs_devices *seed_devices;\n\tstruct btrfs_super_block *disk_super = fs_info->super_copy;\n\tstruct btrfs_device *device;\n\tu64 super_flags;\n\n\tlockdep_assert_held(&uuid_mutex);\n\tif (!fs_devices->seeding)\n\t\treturn -EINVAL;\n\n\t\/*\n\t * Private copy of the seed devices, anchored at\n\t * fs_info->fs_devices->seed_list\n\t *\/\n\tseed_devices = alloc_fs_devices(NULL, NULL);\n\tif (IS_ERR(seed_devices))\n\t\treturn PTR_ERR(seed_devices);\n\n\t\/*\n\t * It's necessary to retain a copy of the original seed fs_devices in\n\t * fs_uuids so that filesystems which have been seeded can successfully\n\t * reference the seed device from open_seed_devices. This also supports\n\t * multiple fs seed.\n\t *\/\n\told_devices = clone_fs_devices(fs_devices);\n\tif (IS_ERR(old_devices)) {\n\t\tkfree(seed_devices);\n\t\treturn PTR_ERR(old_devices);\n\t}\n\n\tlist_add(&old_devices->fs_list, &fs_uuids);\n\n\tmemcpy(seed_devices, fs_devices, sizeof(*seed_devices));\n\tseed_devices->opened = 1;\n\tINIT_LIST_HEAD(&seed_devices->devices);\n\tINIT_LIST_HEAD(&seed_devices->alloc_list);\n\tmutex_init(&seed_devices->device_list_mutex);\n\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tlist_splice_init_rcu(&fs_devices->devices, &seed_devices->devices,\n\t\t\t      synchronize_rcu);\n\tlist_for_each_entry(device, &seed_devices->devices, dev_list)\n\t\tdevice->fs_devices = seed_devices;\n\n\tfs_devices->seeding = false;\n\tfs_devices->num_devices = 0;\n\tfs_devices->open_devices = 0;\n\tfs_devices->missing_devices = 0;\n\tfs_devices->rotating = false;\n\tlist_add(&seed_devices->seed_list, &fs_devices->seed_list);\n\n\tgenerate_random_uuid(fs_devices->fsid);\n\tmemcpy(fs_devices->metadata_uuid, fs_devices->fsid, BTRFS_FSID_SIZE);\n\tmemcpy(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE);\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\tsuper_flags = btrfs_super_flags(disk_super) &\n\t\t      ~BTRFS_SUPER_FLAG_SEEDING;\n\tbtrfs_set_super_flags(disk_super, super_flags);\n\n\treturn 0;\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":220461,"func":"  static bool Run(OpKernelContext* ctx, const Tensor& input,\n                  const Tensor& filter, int batch, int input_rows,\n                  int input_cols, int in_depth, int filter_rows,\n                  int filter_cols, int pad_rows, int pad_cols, int out_rows,\n                  int out_cols, int out_depth, int dilation_rows,\n                  int dilation_cols, int stride_rows, int stride_cols,\n                  Tensor* output, TensorFormat data_format) {\n    auto num_threads =\n        ctx->device()->tensorflow_cpu_worker_threads()->num_threads;\n    \/\/ See libxsmm_dnn.h for this struct definition.\n    libxsmm_dnn_conv_desc desc;\n    desc.N = batch;\n    desc.C = in_depth;\n    desc.H = input_rows;\n    desc.W = input_cols;\n    desc.K = out_depth;\n    desc.R = filter_rows;\n    desc.S = filter_cols;\n    desc.u = stride_rows;\n    desc.v = stride_cols;\n    desc.pad_h = pad_rows;\n    desc.pad_w = pad_cols;\n    desc.pad_h_in = 0;\n    desc.pad_w_in = 0;\n    desc.pad_h_out = 0;\n    desc.pad_w_out = 0;\n    desc.threads = num_threads;\n    desc.algo = LIBXSMM_DNN_CONV_ALGO_DIRECT;\n    desc.buffer_format = LIBXSMM_DNN_TENSOR_FORMAT_NHWC;\n    desc.filter_format = LIBXSMM_DNN_TENSOR_FORMAT_LIBXSMM;\n    desc.fuse_ops = LIBXSMM_DNN_CONV_FUSE_NONE;\n    desc.options = LIBXSMM_DNN_CONV_OPTION_OVERWRITE;\n    desc.datatype_out = LIBXSMM_DNN_DATATYPE_F32;\n    desc.datatype_in = LIBXSMM_DNN_DATATYPE_F32;\n    if (dilation_rows != 1 || dilation_cols != 1 ||\n        !CanUseXsmmConv2D(desc, data_format)) {\n      return false;\n    }\n\n    auto input_ptr = input.template flat<float>().data();\n    auto filter_ptr = filter.template flat<float>().data();\n    auto output_ptr = output->template flat<float>().data();\n\n    bool success = functor::XsmmFwdConv2D<CPUDevice, float>()(\n        ctx, desc, input_ptr, filter_ptr, output_ptr);\n    return success;\n  }","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":209106,"func":"static int ax25_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tax25_cb *ax25;\n\tax25_dev *ax25_dev;\n\n\tif (sk == NULL)\n\t\treturn 0;\n\n\tsock_hold(sk);\n\tlock_sock(sk);\n\tsock_orphan(sk);\n\tax25 = sk_to_ax25(sk);\n\tax25_dev = ax25->ax25_dev;\n\tif (ax25_dev) {\n\t\tdev_put_track(ax25_dev->dev, &ax25_dev->dev_tracker);\n\t\tax25_dev_put(ax25_dev);\n\t}\n\n\tif (sk->sk_type == SOCK_SEQPACKET) {\n\t\tswitch (ax25->state) {\n\t\tcase AX25_STATE_0:\n\t\t\trelease_sock(sk);\n\t\t\tax25_disconnect(ax25, 0);\n\t\t\tlock_sock(sk);\n\t\t\tax25_destroy_socket(ax25);\n\t\t\tbreak;\n\n\t\tcase AX25_STATE_1:\n\t\tcase AX25_STATE_2:\n\t\t\tax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);\n\t\t\trelease_sock(sk);\n\t\t\tax25_disconnect(ax25, 0);\n\t\t\tlock_sock(sk);\n\t\t\tif (!sock_flag(ax25->sk, SOCK_DESTROY))\n\t\t\t\tax25_destroy_socket(ax25);\n\t\t\tbreak;\n\n\t\tcase AX25_STATE_3:\n\t\tcase AX25_STATE_4:\n\t\t\tax25_clear_queues(ax25);\n\t\t\tax25->n2count = 0;\n\n\t\t\tswitch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {\n\t\t\tcase AX25_PROTO_STD_SIMPLEX:\n\t\t\tcase AX25_PROTO_STD_DUPLEX:\n\t\t\t\tax25_send_control(ax25,\n\t\t\t\t\t\t  AX25_DISC,\n\t\t\t\t\t\t  AX25_POLLON,\n\t\t\t\t\t\t  AX25_COMMAND);\n\t\t\t\tax25_stop_t2timer(ax25);\n\t\t\t\tax25_stop_t3timer(ax25);\n\t\t\t\tax25_stop_idletimer(ax25);\n\t\t\t\tbreak;\n#ifdef CONFIG_AX25_DAMA_SLAVE\n\t\t\tcase AX25_PROTO_DAMA_SLAVE:\n\t\t\t\tax25_stop_t3timer(ax25);\n\t\t\t\tax25_stop_idletimer(ax25);\n\t\t\t\tbreak;\n#endif\n\t\t\t}\n\t\t\tax25_calculate_t1(ax25);\n\t\t\tax25_start_t1timer(ax25);\n\t\t\tax25->state = AX25_STATE_2;\n\t\t\tsk->sk_state                = TCP_CLOSE;\n\t\t\tsk->sk_shutdown            |= SEND_SHUTDOWN;\n\t\t\tsk->sk_state_change(sk);\n\t\t\tsock_set_flag(sk, SOCK_DESTROY);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t} else {\n\t\tsk->sk_state     = TCP_CLOSE;\n\t\tsk->sk_shutdown |= SEND_SHUTDOWN;\n\t\tsk->sk_state_change(sk);\n\t\tax25_destroy_socket(ax25);\n\t}\n\n\tsock->sk   = NULL;\n\trelease_sock(sk);\n\tsock_put(sk);\n\n\treturn 0;\n}","target":1,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":473958,"func":"onigenc_minimum_property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)\n{\n  static const PosixBracketEntryType PBS[] = {\n    PosixBracketEntryInit(\"Alnum\",  ONIGENC_CTYPE_ALNUM),\n    PosixBracketEntryInit(\"Alpha\",  ONIGENC_CTYPE_ALPHA),\n    PosixBracketEntryInit(\"Blank\",  ONIGENC_CTYPE_BLANK),\n    PosixBracketEntryInit(\"Cntrl\",  ONIGENC_CTYPE_CNTRL),\n    PosixBracketEntryInit(\"Digit\",  ONIGENC_CTYPE_DIGIT),\n    PosixBracketEntryInit(\"Graph\",  ONIGENC_CTYPE_GRAPH),\n    PosixBracketEntryInit(\"Lower\",  ONIGENC_CTYPE_LOWER),\n    PosixBracketEntryInit(\"Print\",  ONIGENC_CTYPE_PRINT),\n    PosixBracketEntryInit(\"Punct\",  ONIGENC_CTYPE_PUNCT),\n    PosixBracketEntryInit(\"Space\",  ONIGENC_CTYPE_SPACE),\n    PosixBracketEntryInit(\"Upper\",  ONIGENC_CTYPE_UPPER),\n    PosixBracketEntryInit(\"XDigit\", ONIGENC_CTYPE_XDIGIT),\n    PosixBracketEntryInit(\"ASCII\",  ONIGENC_CTYPE_ASCII),\n    PosixBracketEntryInit(\"Word\",   ONIGENC_CTYPE_WORD),\n  };\n\n  const PosixBracketEntryType *pb, *pbe;\n  int len;\n\n  len = onigenc_strlen(enc, p, end);\n  for (pbe = (pb = PBS) + sizeof(PBS)\/sizeof(PBS[0]); pb < pbe; ++pb) {\n    if (len == pb->len &&\n        STRNCASECMP((char *)p, (char *)pb->name, len) == 0)\n      return pb->ctype;\n  }\n\n  return ONIGERR_INVALID_CHAR_PROPERTY_NAME;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":463204,"func":"EXPORTED int specialuse_validate(const char *mboxname, const char *userid,\n                                 const char *src, struct buf *dest)\n{\n    const char *specialuse_extra_opt = config_getstring(IMAPOPT_SPECIALUSE_EXTRA);\n    char *strval = NULL;\n    strarray_t *valid = NULL;\n    strarray_t *new_attribs = NULL;\n    strarray_t *cur_attribs = NULL;\n    struct buf mbattribs = BUF_INITIALIZER;\n    int i, j;\n    int r = 0;\n\n    if (!src) {\n        buf_reset(dest);\n        return 0;\n    }\n\n    \/* If there is a valid mboxname, we get the current specialuse annotations.\n     *\/\n    if (mboxname) {\n        annotatemore_lookup(mboxname, \"\/specialuse\", userid, &mbattribs);\n        if (mbattribs.len) {\n            cur_attribs = strarray_split(buf_cstring(&mbattribs), NULL, 0);\n        }\n    }\n\n    \/* check specialuse_extra option if set *\/\n    if (specialuse_extra_opt)\n        valid = strarray_split(specialuse_extra_opt, NULL, 0);\n    else\n        valid = strarray_new();\n\n    \/* strarray_add(valid, \"\\\\All\"); -- we don't support virtual folders right now *\/\n    strarray_add(valid, \"\\\\Archive\");\n    strarray_add(valid, \"\\\\Drafts\");\n    \/* strarray_add(valid, \"\\\\Flagged\"); -- we don't support virtual folders right now *\/\n    strarray_add(valid, \"\\\\Important\"); \/\/ draft-ietf-specialuse-important\n    strarray_add(valid, \"\\\\Junk\");\n    strarray_add(valid, \"\\\\Sent\");\n    strarray_add(valid, \"\\\\Trash\");\n    strarray_add(valid, \"\\\\Snoozed\"); \/\/ JMAP\n\n    new_attribs = strarray_split(src, NULL, 0);\n\n    for (i = 0; i < new_attribs->count; i++) {\n        int skip_mbcheck = 0;\n        const char *item = strarray_nth(new_attribs, i);\n\n        for (j = 0; j < valid->count; j++) { \/* can't use find here *\/\n            if (!strcasecmp(strarray_nth(valid, j), item))\n                break;\n            \/* or without the leading '\\' *\/\n            if (!strcasecmp(strarray_nth(valid, j) + 1, item))\n                break;\n        }\n\n        if (j >= valid->count) {\n            r = IMAP_ANNOTATION_BADENTRY;\n            goto done;\n        }\n\n        if (cur_attribs &&\n            (strarray_find_case(cur_attribs, strarray_nth(valid, j), 0) >= 0)) {\n            \/* The mailbox has this specialuse attribute set already *\/\n            skip_mbcheck = 1;\n        }\n\n        \/* don't allow names that are already in use *\/\n        if (!skip_mbcheck) {\n            char *mbname = mboxlist_find_specialuse(strarray_nth(valid, j),\n                                                    userid);\n            if (mbname) {\n                free(mbname);\n                r = IMAP_MAILBOX_SPECIALUSE;\n                goto done;\n            }\n        }\n\n        \/* normalise the value *\/\n        strarray_set(new_attribs, i, strarray_nth(valid, j));\n    }\n\n    strval = strarray_join(new_attribs, \" \");\n    buf_setcstr(dest, strval);\n\ndone:\n    free(strval);\n    strarray_free(valid);\n    strarray_free(new_attribs);\n    strarray_free(cur_attribs);\n    buf_free(&mbattribs);\n    return r;\n}","target":0,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":247568,"func":"TEST_P(SslSocketTest, ClientCertificateHashListVerificationNoCA) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  server_validation_ctx->add_verify_certificate_hash(\n      \"0000000000000000000000000000000000000000000000000000000000000000\");\n  server_validation_ctx->add_verify_certificate_hash(TEST_SAN_URI_CERT_256_HASH);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"));\n\n  TestUtilOptionsV2 test_options(listener, client, true, GetParam());\n  testUtilV2(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedServerCertDigest(TEST_SAN_DNS_CERT_256_HASH));\n\n  \/\/ Works even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":477306,"func":"static void tipc_crypto_do_cmd(struct net *net, int cmd)\n{\n\tstruct tipc_net *tn = tipc_net(net);\n\tstruct tipc_crypto *tx = tn->crypto_tx, *rx;\n\tstruct list_head *p;\n\tunsigned int stat;\n\tint i, j, cpu;\n\tchar buf[200];\n\n\t\/* Currently only one command is supported *\/\n\tswitch (cmd) {\n\tcase 0xfff1:\n\t\tgoto print_stats;\n\tdefault:\n\t\treturn;\n\t}\n\nprint_stats:\n\t\/* Print a header *\/\n\tpr_info(\"\\n=============== TIPC Crypto Statistics ===============\\n\\n\");\n\n\t\/* Print key status *\/\n\tpr_info(\"Key status:\\n\");\n\tpr_info(\"TX(%7.7s)\\n%s\", tipc_own_id_string(net),\n\t\ttipc_crypto_key_dump(tx, buf));\n\n\trcu_read_lock();\n\tfor (p = tn->node_list.next; p != &tn->node_list; p = p->next) {\n\t\trx = tipc_node_crypto_rx_by_list(p);\n\t\tpr_info(\"RX(%7.7s)\\n%s\", tipc_node_get_id_str(rx->node),\n\t\t\ttipc_crypto_key_dump(rx, buf));\n\t}\n\trcu_read_unlock();\n\n\t\/* Print crypto statistics *\/\n\tfor (i = 0, j = 0; i < MAX_STATS; i++)\n\t\tj += scnprintf(buf + j, 200 - j, \"|%11s \", hstats[i]);\n\tpr_info(\"Counter     %s\", buf);\n\n\tmemset(buf, '-', 115);\n\tbuf[115] = '\\0';\n\tpr_info(\"%s\\n\", buf);\n\n\tj = scnprintf(buf, 200, \"TX(%7.7s) \", tipc_own_id_string(net));\n\tfor_each_possible_cpu(cpu) {\n\t\tfor (i = 0; i < MAX_STATS; i++) {\n\t\t\tstat = per_cpu_ptr(tx->stats, cpu)->stat[i];\n\t\t\tj += scnprintf(buf + j, 200 - j, \"|%11d \", stat);\n\t\t}\n\t\tpr_info(\"%s\", buf);\n\t\tj = scnprintf(buf, 200, \"%12s\", \" \");\n\t}\n\n\trcu_read_lock();\n\tfor (p = tn->node_list.next; p != &tn->node_list; p = p->next) {\n\t\trx = tipc_node_crypto_rx_by_list(p);\n\t\tj = scnprintf(buf, 200, \"RX(%7.7s) \",\n\t\t\t      tipc_node_get_id_str(rx->node));\n\t\tfor_each_possible_cpu(cpu) {\n\t\t\tfor (i = 0; i < MAX_STATS; i++) {\n\t\t\t\tstat = per_cpu_ptr(rx->stats, cpu)->stat[i];\n\t\t\t\tj += scnprintf(buf + j, 200 - j, \"|%11d \",\n\t\t\t\t\t       stat);\n\t\t\t}\n\t\t\tpr_info(\"%s\", buf);\n\t\t\tj = scnprintf(buf, 200, \"%12s\", \" \");\n\t\t}\n\t}\n\trcu_read_unlock();\n\n\tpr_info(\"\\n======================== Done ========================\\n\");\n}","target":0,"code_token_length":652,"total_token_length":888,"max_tokens_setting":1024}
+{"idx":329924,"func":"_inplace_src_opacity_spans (void *abstract_renderer, int y, int h,\n\t\t\t    const cairo_half_open_span_t *spans,\n\t\t\t    unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n    uint8_t *mask;\n    int x0;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    x0 = spans[0].x;\n    mask = (uint8_t *)pixman_image_get_data (r->mask);\n    do {\n\tint len = spans[1].x - spans[0].x;\n\tuint8_t m = mul8_8(spans[0].coverage, r->bpp);\n\tif (m == 0) {\n\t    if (spans[0].x != x0) {\n#if PIXMAN_HAS_OP_LERP\n\t\tpixman_image_composite32 (PIXMAN_OP_LERP_SRC,\n\t\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n#else\n\t\tpixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,\n\t\t\t\t\t  r->mask, NULL, r->u.composite.dst,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n\t\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x0, y,\n\t\t\t\t\t  spans[0].x - x0, h);\n#endif\n\t    }\n\n\t    mask = (uint8_t *)pixman_image_get_data (r->mask);\n\t    x0 = spans[1].x;\n\t} else {\n\t    *mask++ = m;\n\t    if (len > 1) {\n\t\tmemset (mask, m, --len);\n\t\tmask += len;\n\t    }\n\t}\n\tspans++;\n    } while (--num_spans > 1);\n\n    if (spans[0].x != x0) {\n#if PIXMAN_HAS_OP_LERP\n\tpixman_image_composite32 (PIXMAN_OP_LERP_SRC,\n\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  spans[0].x - x0, h);\n#else\n\tpixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,\n\t\t\t\t  r->mask, NULL, r->u.composite.dst,\n\t\t\t\t  0, 0,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  spans[0].x - x0, h);\n\tpixman_image_composite32 (PIXMAN_OP_ADD,\n\t\t\t\t  r->src, r->mask, r->u.composite.dst,\n\t\t\t\t  x0 + r->u.composite.src_x,\n\t\t\t\t  y + r->u.composite.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  x0, y,\n\t\t\t\t  spans[0].x - x0, h);\n#endif\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":738,"total_token_length":974,"max_tokens_setting":1024}
+{"idx":230287,"func":"njs_array_compare(const void *a, const void *b, void *c)\n{\n    double                 num;\n    njs_int_t              ret;\n    njs_value_t            arguments[3], retval;\n    njs_array_sort_ctx_t   *ctx;\n    njs_array_sort_slot_t  *aslot, *bslot;\n\n    ctx = c;\n\n    if (ctx->exception) {\n        return 0;\n    }\n\n    aslot = (njs_array_sort_slot_t *) a;\n    bslot = (njs_array_sort_slot_t *) b;\n\n    if (ctx->function != NULL) {\n        njs_set_undefined(&arguments[0]);\n        arguments[1] = aslot->value;\n        arguments[2] = bslot->value;\n\n        ret = njs_function_apply(ctx->vm, ctx->function, arguments, 3, &retval);\n        if (njs_slow_path(ret != NJS_OK)) {\n            goto exception;\n        }\n\n        ret = njs_value_to_number(ctx->vm, &retval, &num);\n        if (njs_slow_path(ret != NJS_OK)) {\n            goto exception;\n        }\n\n        if (njs_slow_path(isnan(num))) {\n            return 0;\n        }\n\n        if (num != 0) {\n            return (num > 0) - (num < 0);\n        }\n\n        goto compare_same;\n    }\n\n    if (aslot->str == NULL) {\n        aslot->str = njs_arr_add(&ctx->strings);\n        ret = njs_value_to_string(ctx->vm, aslot->str, &aslot->value);\n        if (njs_slow_path(ret != NJS_OK)) {\n            goto exception;\n        }\n    }\n\n    if (bslot->str == NULL) {\n        bslot->str = njs_arr_add(&ctx->strings);\n        ret = njs_value_to_string(ctx->vm, bslot->str, &bslot->value);\n        if (njs_slow_path(ret != NJS_OK)) {\n            goto exception;\n        }\n    }\n\n    ret = njs_string_cmp(aslot->str, bslot->str);\n\n    if (ret != 0) {\n        return ret;\n    }\n\ncompare_same:\n\n    \/* Ensures stable sorting. *\/\n\n    return (aslot->pos > bslot->pos) - (aslot->pos < bslot->pos);\n\nexception:\n\n    ctx->exception = 1;\n\n    return 0;\n}","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":222898,"func":"  Status UpdateOutputShapesAndValues(const NodeDef& node, NodeContext* c) {\n    InferenceContext* ic = c->inference_context.get();\n\n    \/\/ Input to EvaluateNode()\n    TensorVector inputs;\n    \/\/ Container for temporarily created tensor object.\n    std::vector<Tensor> input_tensor_vector(ic->num_inputs());\n    CreateInputTensors(c, &input_tensor_vector, &inputs);\n\n    \/\/ Output for EvaluateNode() and output tensor clean up object.\n    TensorVector outputs;\n    auto outputs_cleanup = gtl::MakeCleanup([&outputs] {\n      for (const auto& output : outputs) {\n        if (output.tensor) {\n          delete output.tensor;\n        }\n      }\n    });\n\n    TF_RETURN_IF_ERROR(EvaluateNode(node, inputs, \/*cpu_device=*\/nullptr,\n                                    &resource_mgr_, &outputs));\n    c->output_tensors_as_shapes.resize(outputs.size());\n    c->output_tensor_protos.resize(outputs.size(), nullptr);\n    for (int k = 0, outputs_size = outputs.size(); k < outputs_size; k++) {\n      const auto& t = outputs[k];\n      \/\/ Override output shape.\n      ShapeHandle output_shape;\n      TF_RETURN_IF_ERROR(\n          ic->MakeShapeFromTensorShape(t->shape(), &output_shape));\n      if (ic->FullyDefined(ic->output(k)) &&\n          !EquivalentShapes(ic->output(k), output_shape)) {\n        LOG(WARNING) << \"UpdateOutputShapesAndValues() -- node: \" << node.name()\n                     << \", inferred output shape \"\n                     << \"doesn't match for k=\" << k << \": \"\n                     << \"ic->output(k): \" << ic->DebugString(ic->output(k))\n                     << \", output_shape: \" << ic->DebugString(output_shape)\n                     << \" -- \" << node.DebugString();\n      }\n      ic->set_output(k, output_shape);\n      \/\/ Set output_tensors_as_shape.\n      MaybeTensorValueToShape(ic, *t.tensor, &c->output_tensors_as_shapes[k]);\n\n      \/\/ Set output_tensor_protos.\n      TensorProto tensor_proto;\n      t->AsProtoTensorContent(&tensor_proto);\n      const_tensors_to_propagate_.push_back(tensor_proto);\n      c->output_tensor_protos[k] = &const_tensors_to_propagate_.back();\n    }\n    return Status::OK();\n  }","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":328954,"func":"R_API RBinJavaAttrInfo *r_bin_java_signature_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tut64 offset = 6;\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_SIGNATURE_ATTR;\n\t\/\/ attr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\/\/ offset += 2;\n\tattr->info.signature_attr.signature_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.signature_attr.signature = r_bin_java_get_utf8_from_bin_cp_list (\n\t\tR_BIN_JAVA_GLOBAL_BIN, attr->info.signature_attr.signature_idx);\n\tif (!attr->info.signature_attr.signature) {\n\t\teprintf (\"r_bin_java_signature_attr_new: Unable to resolve the \"\n\t\t\t\"Signature UTF8 String Index: 0x%02x\\n\", attr->info.signature_attr.signature_idx);\n\t}\n\tattr->size = offset;\n\t\/\/ IFDBG r_bin_java_print_source_code_file_attr_summary(attr);\n\treturn attr;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":318984,"func":"assert_inrange(typval_T *argvars)\n{\n    garray_T\tga;\n    int\t\terror = FALSE;\n    char_u\t*tofree;\n    char\tmsg[200];\n    char_u\tnumbuf[NUMBUFLEN];\n\n#ifdef FEAT_FLOAT\n    if (argvars[0].v_type == VAR_FLOAT\n\t    || argvars[1].v_type == VAR_FLOAT\n\t    || argvars[2].v_type == VAR_FLOAT)\n    {\n\tfloat_T flower = tv_get_float(&argvars[0]);\n\tfloat_T fupper = tv_get_float(&argvars[1]);\n\tfloat_T factual = tv_get_float(&argvars[2]);\n\n\tif (factual < flower || factual > fupper)\n\t{\n\t    prepare_assert_error(&ga);\n\t    if (argvars[3].v_type != VAR_UNKNOWN)\n\t    {\n\t\tga_concat(&ga, tv2string(&argvars[3], &tofree, numbuf, 0));\n\t\tvim_free(tofree);\n\t    }\n\t    else\n\t    {\n\t\tvim_snprintf(msg, 200, \"Expected range %g - %g, but got %g\",\n\t\t\t\t\t\t      flower, fupper, factual);\n\t\tga_concat(&ga, (char_u *)msg);\n\t    }\n\t    assert_error(&ga);\n\t    ga_clear(&ga);\n\t    return 1;\n\t}\n    }\n    else\n#endif\n    {\n\tvarnumber_T\tlower = tv_get_number_chk(&argvars[0], &error);\n\tvarnumber_T\tupper = tv_get_number_chk(&argvars[1], &error);\n\tvarnumber_T\tactual = tv_get_number_chk(&argvars[2], &error);\n\n\tif (error)\n\t    return 0;\n\tif (actual < lower || actual > upper)\n\t{\n\t    prepare_assert_error(&ga);\n\t    if (argvars[3].v_type != VAR_UNKNOWN)\n\t    {\n\t\tga_concat(&ga, tv2string(&argvars[3], &tofree, numbuf, 0));\n\t\tvim_free(tofree);\n\t    }\n\t    else\n\t    {\n\t\tvim_snprintf(msg, 200, \"Expected range %ld - %ld, but got %ld\",\n\t\t\t\t       (long)lower, (long)upper, (long)actual);\n\t\tga_concat(&ga, (char_u *)msg);\n\t    }\n\t    assert_error(&ga);\n\t    ga_clear(&ga);\n\t    return 1;\n\t}\n    }\n    return 0;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":238473,"func":"static void scalar_min_max_rsh(struct bpf_reg_state *dst_reg,\n\t\t\t       struct bpf_reg_state *src_reg)\n{\n\tu64 umax_val = src_reg->umax_value;\n\tu64 umin_val = src_reg->umin_value;\n\n\t\/* BPF_RSH is an unsigned shift.  If the value in dst_reg might\n\t * be negative, then either:\n\t * 1) src_reg might be zero, so the sign bit of the result is\n\t *    unknown, so we lose our signed bounds\n\t * 2) it's known negative, thus the unsigned bounds capture the\n\t *    signed bounds\n\t * 3) the signed bounds cross zero, so they tell us nothing\n\t *    about the result\n\t * If the value in dst_reg is known nonnegative, then again the\n\t * unsigned bounds capture the signed bounds.\n\t * Thus, in all cases it suffices to blow away our signed bounds\n\t * and rely on inferring new ones from the unsigned bounds and\n\t * var_off of the result.\n\t *\/\n\tdst_reg->smin_value = S64_MIN;\n\tdst_reg->smax_value = S64_MAX;\n\tdst_reg->var_off = tnum_rshift(dst_reg->var_off, umin_val);\n\tdst_reg->umin_value >>= umax_val;\n\tdst_reg->umax_value >>= umin_val;\n\n\t\/* Its not easy to operate on alu32 bounds here because it depends\n\t * on bits being shifted in. Take easy way out and mark unbounded\n\t * so we can recalculate later from tnum.\n\t *\/\n\t__mark_reg32_unbounded(dst_reg);\n\t__update_reg_bounds(dst_reg);\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":232946,"func":"static CURLcode brotli_unencode_write(struct Curl_easy *data,\n                                      struct contenc_writer *writer,\n                                      const char *buf, size_t nbytes)\n{\n  struct brotli_params *bp = (struct brotli_params *) &writer->params;\n  const uint8_t *src = (const uint8_t *) buf;\n  char *decomp;\n  uint8_t *dst;\n  size_t dstleft;\n  CURLcode result = CURLE_OK;\n  BrotliDecoderResult r = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;\n\n  if(!bp->br)\n    return CURLE_WRITE_ERROR;  \/* Stream already ended. *\/\n\n  decomp = malloc(DSIZ);\n  if(!decomp)\n    return CURLE_OUT_OF_MEMORY;\n\n  while((nbytes || r == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) &&\n        result == CURLE_OK) {\n    dst = (uint8_t *) decomp;\n    dstleft = DSIZ;\n    r = BrotliDecoderDecompressStream(bp->br,\n                                      &nbytes, &src, &dstleft, &dst, NULL);\n    result = Curl_unencode_write(data, writer->downstream,\n                                 decomp, DSIZ - dstleft);\n    if(result)\n      break;\n    switch(r) {\n    case BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:\n    case BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:\n      break;\n    case BROTLI_DECODER_RESULT_SUCCESS:\n      BrotliDecoderDestroyInstance(bp->br);\n      bp->br = NULL;\n      if(nbytes)\n        result = CURLE_WRITE_ERROR;\n      break;\n    default:\n      result = brotli_map_error(BrotliDecoderGetErrorCode(bp->br));\n      break;\n    }\n  }\n  free(decomp);\n  return result;\n}","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":379656,"func":"R_API char *r_anal_var_get_constraints_readable(RAnalVar *var) {\n\tsize_t n = var->constraints.len;\n\tif (!n) {\n\t\treturn NULL;\n\t}\n\tbool low = false, high = false;\n\tRStrBuf sb;\n\tr_strbuf_init (&sb);\n\tsize_t i;\n\tfor (i = 0; i < n; i += 1) {\n\t\tRAnalVarConstraint *constr = r_vector_index_ptr (&var->constraints, i);\n\t\tswitch (constr->cond) {\n\t\tcase R_ANAL_COND_LE:\n\t\t\tif (high) {\n\t\t\t\tr_strbuf_append (&sb, \" && \");\n\t\t\t}\n\t\t\tr_strbuf_appendf (&sb, \"<= 0x%\"PFMT64x \"\", constr->val);\n\t\t\tlow = true;\n\t\t\tbreak;\n\t\tcase R_ANAL_COND_LT:\n\t\t\tif (high) {\n\t\t\t\tr_strbuf_append (&sb, \" && \");\n\t\t\t}\n\t\t\tr_strbuf_appendf (&sb, \"< 0x%\"PFMT64x \"\", constr->val);\n\t\t\tlow = true;\n\t\t\tbreak;\n\t\tcase R_ANAL_COND_GE:\n\t\t\tr_strbuf_appendf (&sb, \">= 0x%\"PFMT64x \"\", constr->val);\n\t\t\thigh = true;\n\t\t\tbreak;\n\t\tcase R_ANAL_COND_GT:\n\t\t\tr_strbuf_appendf (&sb, \"> 0x%\"PFMT64x \"\", constr->val);\n\t\t\thigh = true;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tif (low && high && i != n - 1) {\n\t\t\tr_strbuf_append (&sb, \" || \");\n\t\t\tlow = false;\n\t\t\thigh = false;\n\t\t}\n\t}\n\treturn r_strbuf_drain_nofree (&sb);\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":246726,"func":"void PrintEncodeUsage()\n{\n\tu32 i=0;\n\tgf_sys_format_help(helpout, help_flags, \"# MPEG-4 Scene Encoding Options\\n\"\n\t\t\"## General considerations\\n\"\n\t\t\"MP4Box supports encoding and decoding of of BT, XMT, VRML and (partially) X3D formats int MPEG-4 BIFS, and encoding and decoding of XSR and SVG into MPEG-4 LASeR\\n\"\n\t\t\"Any media track specified through a `MuxInfo` element will be imported in the resulting MP4 file.\\n\"\n\t\t\"See https:\/\/wiki.gpac.io\/MPEG-4-BIFS-Textual-Format and related pages.\\n\"\n\t\t\"## Scene Random Access\\n\"\n\t\t\"MP4Box can encode BIFS or LASeR streams and insert random access points at a given frequency. This is useful when packaging content for broadcast, where users will not turn in the scene at the same time. In MPEG-4 terminology, this is called the __scene carousel__.\"\n\t\t\"## BIFS Chunk Processing\\n\"\n\t\t\"The BIFS chunk encoding mode alows encoding single BIFS access units from an initial context and a set of commands.\\n\"\n\t\t\"The generated AUs are raw BIFS (not SL-packetized), in files called FILE-ESID-AUIDX.bifs, with FILE the basename of the input file.\\n\"\n\t\t\"Commands with a timing of 0 in the input will modify the carousel version only (i.e. output context).\\n\"\n\t\t\"Commands with a timing different from 0 in the input will generate new AUs.\\n\"\n\t\t\"  \\n\"\n\t\t\"Options:\\n\"\n\t);\n\n\twhile (m4b_senc_args[i].name) {\n\t\tGF_GPACArg *arg = (GF_GPACArg *) &m4b_senc_args[i];\n\t\ti++;\n\t\tgf_sys_print_arg(helpout, help_flags, arg, \"mp4box-senc\");\n\t}\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":390601,"func":"ProcXkbGetNames(ClientPtr client)\n{\n    DeviceIntPtr\tdev;\n    XkbDescPtr\t\txkb;\n    xkbGetNamesReply \trep;\n\n    REQUEST(xkbGetNamesReq);\n    REQUEST_SIZE_MATCH(xkbGetNamesReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);\n    CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask);\n\n    xkb = dev->key->xkbInfo->desc;\n    rep.type= X_Reply;\n    rep.sequenceNumber= client->sequence;\n    rep.length = 0;\n    rep.deviceID = dev->id;\n    rep.which = stuff->which;\n    rep.nTypes = xkb->map->num_types;\n    rep.firstKey = xkb->min_key_code;\n    rep.nKeys = XkbNumKeys(xkb);\n    if (xkb->names!=NULL) {\n\trep.nKeyAliases= xkb->names->num_key_aliases;\n\trep.nRadioGroups = xkb->names->num_rg;\n    }\n    else {\n\trep.nKeyAliases= rep.nRadioGroups= 0;\n    }\n    XkbComputeGetNamesReplySize(xkb,&rep);\n    return XkbSendNames(client,xkb,&rep);\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":198449,"func":"PJ_DEF(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t buf_len, \n\t\t\t\t      pjstun_msg *msg)\n{\n    pj_uint16_t msg_type, msg_len;\n    char *p_attr;\n\n    PJ_CHECK_STACK();\n\n    msg->hdr = (pjstun_msg_hdr*)buf;\n    msg_type = pj_ntohs(msg->hdr->type);\n\n    switch (msg_type) {\n    case PJSTUN_BINDING_REQUEST:\n    case PJSTUN_BINDING_RESPONSE:\n    case PJSTUN_BINDING_ERROR_RESPONSE:\n    case PJSTUN_SHARED_SECRET_REQUEST:\n    case PJSTUN_SHARED_SECRET_RESPONSE:\n    case PJSTUN_SHARED_SECRET_ERROR_RESPONSE:\n\tbreak;\n    default:\n\tPJ_LOG(4,(THIS_FILE, \"Error: unknown msg type %d\", msg_type));\n\treturn PJLIB_UTIL_ESTUNINMSGTYPE;\n    }\n\n    msg_len = pj_ntohs(msg->hdr->length);\n    if (msg_len != buf_len - sizeof(pjstun_msg_hdr)) {\n\tPJ_LOG(4,(THIS_FILE, \"Error: invalid msg_len %d (expecting %d)\", \n\t\t\t     msg_len, buf_len - sizeof(pjstun_msg_hdr)));\n\treturn PJLIB_UTIL_ESTUNINMSGLEN;\n    }\n\n    msg->attr_count = 0;\n    p_attr = (char*)buf + sizeof(pjstun_msg_hdr);\n\n    while (msg_len > 0) {\n\tpjstun_attr_hdr **attr = &msg->attr[msg->attr_count];\n\tpj_uint32_t len;\n\tpj_uint16_t attr_type;\n\n\t*attr = (pjstun_attr_hdr*)p_attr;\n\tlen = pj_ntohs((pj_uint16_t) ((*attr)->length)) + sizeof(pjstun_attr_hdr);\n\tlen = (len + 3) & ~3;\n\n\tif (msg_len < len) {\n\t    PJ_LOG(4,(THIS_FILE, \"Error: length mismatch in attr %d\", \n\t\t\t\t msg->attr_count));\n\t    return PJLIB_UTIL_ESTUNINATTRLEN;\n\t}\n\n\tattr_type = pj_ntohs((*attr)->type);\n\tif (attr_type > PJSTUN_ATTR_REFLECTED_FROM &&\n\t    attr_type != PJSTUN_ATTR_XOR_MAPPED_ADDR)\n\t{\n\t    PJ_LOG(5,(THIS_FILE, \"Warning: unknown attr type %x in attr %d. \"\n\t\t\t\t \"Attribute was ignored.\",\n\t\t\t\t attr_type, msg->attr_count));\n\t}\n\n\tmsg_len = (pj_uint16_t)(msg_len - len);\n\tp_attr += len;\n\t++msg->attr_count;\n    }\n\n    return PJ_SUCCESS;\n}","target":1,"code_token_length":553,"total_token_length":789,"max_tokens_setting":1024}
+{"idx":224469,"func":"static char *ttxt_parse_string(char *str, Bool strip_lines)\n{\n\tu32 i=0;\n\tu32 k=0;\n\tu32 len = (u32) strlen(str);\n\tu32 state = 0;\n\n\tif (!strip_lines) {\n\t\tfor (i=0; i<len; i++) {\n\t\t\tif ((str[i] == '\\r') && (str[i+1] == '\\n')) {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tstr[k] = str[i];\n\t\t\tk++;\n\t\t}\n\t\tstr[k]=0;\n\t\treturn str;\n\t}\n\n\tif (str[0]!='\\'') return str;\n\tfor (i=0; i<len; i++) {\n\t\tif (str[i] == '\\'') {\n\n\t\t\tif (!state) {\n\t\t\t\tif (k) {\n\t\t\t\t\tstr[k]='\\n';\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t\tstate = 1; \/\/!state;\n\t\t\t} else {\n\t\t\t\tif ( (i+1==len) ||\n\t\t\t\t        ((str[i+1]==' ') || (str[i+1]=='\\n') || (str[i+1]=='\\r') || (str[i+1]=='\\t') || (str[i+1]=='\\''))\n\t\t\t\t   ) {\n\t\t\t\t\tstate = !state;\n\t\t\t\t} else {\n\t\t\t\t\tstr[k] = str[i];\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state) {\n\t\t\tstr[k] = str[i];\n\t\t\tk++;\n\t\t}\n\t}\n\tstr[k]=0;\n\treturn str;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":219024,"func":"Status ConstantFolding::MaterializeConstantValuedNode(\n    NodeDef* node, const GraphProperties& properties) {\n  if (disable_compressed_tensor_optimization_) {\n    return Status::OK();\n  }\n  \/\/ Nodes that generate constant-valued outputs can be represented compactly in\n  \/\/ compressed format, regardless of their shape.\n  const std::vector<OpInfo::TensorProperties>& output_props =\n      properties.GetOutputProperties(node->name());\n  if (output_props.size() != 1) return Status::OK();\n  const auto& output_shape = output_props[0].shape();\n  if (!PartialTensorShape(output_shape).IsFullyDefined()) {\n    return Status::OK();\n  }\n  if (IsFill(*node)) {\n    const auto output_dtype = output_props[0].dtype();\n    NodeDef* input_node = nullptr;\n    for (int i = 0; i < 2; ++i) {\n      input_node = node_map_->GetNode(NodeName(node->input(i)));\n      if (input_node == nullptr || !IsReallyConstant(*input_node)) {\n        return Status::OK();\n      }\n    }\n    TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, \"value\"));\n\n    \/\/ Copy the input tensor to the fill node, set the output shape and data\n    \/\/ type, and change the node type to Const.\n    TensorProto* tensor = (*node->mutable_attr())[\"value\"].mutable_tensor();\n    const TensorProto& input_tensor = input_node->attr().at(\"value\").tensor();\n    if (!input_tensor.tensor_content().empty()) {\n      \/\/ Convert the value to repeated field format, so we can use the\n      \/\/ decompression mechanism to store only a single value in the constant\n      \/\/ node, even if the shape specified in the original Fill is large.\n      Tensor t;\n      if (!t.FromProto(input_tensor)) {\n        return errors::InvalidArgument(\n            \"Could not construct Tensor form TensorProto in node: \",\n            input_node->name());\n      }\n      tensor->clear_tensor_content();\n      t.AsProtoField(tensor);\n    } else {\n      *tensor = input_tensor;\n    }\n    *(tensor->mutable_tensor_shape()) = output_shape;\n    (*node->mutable_attr())[\"dtype\"].set_type(output_dtype);\n    node->mutable_attr()->erase(\"T\");\n    node->mutable_attr()->erase(\"index_type\");\n    node->set_op(\"Const\");\n    for (int i = 0; i < 2; i++) {\n      \/\/ Change inputs to a control inputs.\n      const string ctrl_dep = AsControlDependency(node->input(i));\n      node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep);\n      node->set_input(i, ctrl_dep);\n    }\n    graph_modified_ = true;\n  } else {\n    double value =\n        (IsZerosLike(*node) ? 0.0 : (IsOnesLike(*node) ? 1.0 : -1.0));\n    if (value >= 0) {\n      TF_RETURN_IF_ERROR(ReplaceOperationWithConstant(\n          value, properties, output_shape, node, graph_));\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":666,"total_token_length":902,"max_tokens_setting":1024}
+{"idx":211695,"func":"reg_match_visual(void)\n{\n    pos_T\ttop, bot;\n    linenr_T    lnum;\n    colnr_T\tcol;\n    win_T\t*wp = rex.reg_win == NULL ? curwin : rex.reg_win;\n    int\t\tmode;\n    colnr_T\tstart, end;\n    colnr_T\tstart2, end2;\n    colnr_T\tcols;\n    colnr_T\tcurswant;\n\n    \/\/ Check if the buffer is the current buffer.\n    if (rex.reg_buf != curbuf || VIsual.lnum == 0)\n\treturn FALSE;\n\n    if (VIsual_active)\n    {\n\tif (LT_POS(VIsual, wp->w_cursor))\n\t{\n\t    top = VIsual;\n\t    bot = wp->w_cursor;\n\t}\n\telse\n\t{\n\t    top = wp->w_cursor;\n\t    bot = VIsual;\n\t}\n\tmode = VIsual_mode;\n\tcurswant = wp->w_curswant;\n    }\n    else\n    {\n\tif (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end))\n\t{\n\t    top = curbuf->b_visual.vi_start;\n\t    bot = curbuf->b_visual.vi_end;\n\t}\n\telse\n\t{\n\t    top = curbuf->b_visual.vi_end;\n\t    bot = curbuf->b_visual.vi_start;\n\t}\n\tmode = curbuf->b_visual.vi_mode;\n\tcurswant = curbuf->b_visual.vi_curswant;\n    }\n    lnum = rex.lnum + rex.reg_firstlnum;\n    if (lnum < top.lnum || lnum > bot.lnum)\n\treturn FALSE;\n\n    if (mode == 'v')\n    {\n\tcol = (colnr_T)(rex.input - rex.line);\n\tif ((lnum == top.lnum && col < top.col)\n\t\t|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))\n\t    return FALSE;\n    }\n    else if (mode == Ctrl_V)\n    {\n\tgetvvcol(wp, &top, &start, NULL, &end);\n\tgetvvcol(wp, &bot, &start2, NULL, &end2);\n\tif (start2 < start)\n\t    start = start2;\n\tif (end2 > end)\n\t    end = end2;\n\tif (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)\n\t    end = MAXCOL;\n\tcols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));\n\tif (cols < start || cols > end - (*p_sel == 'e'))\n\t    return FALSE;\n    }\n    return TRUE;\n}","target":1,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":331779,"func":"QRectF QVectorPath::controlPointRect() const\n{\n    if (m_hints & ControlPointRect)\n        return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2));\n\n    if (m_count == 0) {\n        m_cp_rect.x1 = m_cp_rect.x2 = m_cp_rect.y1 = m_cp_rect.y2 = 0;\n        m_hints |= ControlPointRect;\n        return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2));\n    }\n    Q_ASSERT(m_points && m_count > 0);\n\n    const qreal *pts = m_points;\n    m_cp_rect.x1 = m_cp_rect.x2 = *pts;\n    ++pts;\n    m_cp_rect.y1 = m_cp_rect.y2 = *pts;\n    ++pts;\n\n    const qreal *epts = m_points + (m_count << 1);\n    while (pts < epts) {\n        qreal x = *pts;\n        if (x < m_cp_rect.x1) m_cp_rect.x1 = x;\n        else if (x > m_cp_rect.x2) m_cp_rect.x2 = x;\n        ++pts;\n\n        qreal y = *pts;\n        if (y < m_cp_rect.y1) m_cp_rect.y1 = y;\n        else if (y > m_cp_rect.y2) m_cp_rect.y2 = y;\n        ++pts;\n    }\n\n    m_hints |= ControlPointRect;\n    return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2));\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":409423,"func":"settmode(tmode_T tmode)\n{\n#ifdef FEAT_GUI\n    \/\/ don't set the term where gvim was started to any mode\n    if (gui.in_use)\n\treturn;\n#endif\n\n    if (full_screen)\n    {\n\t\/*\n\t * When returning after calling a shell cur_tmode is TMODE_UNKNOWN,\n\t * set the terminal to raw mode, even though we think it already is,\n\t * because the shell program may have reset the terminal mode.\n\t * When we think the terminal is normal, don't try to set it to\n\t * normal again, because that causes problems (logout!) on some\n\t * machines.\n\t *\/\n\tif (tmode != cur_tmode)\n\t{\n#ifdef FEAT_TERMRESPONSE\n# ifdef FEAT_GUI\n\t    if (!gui.in_use && !gui.starting)\n# endif\n\t    {\n\t\t\/\/ May need to check for T_CRV response and termcodes, it\n\t\t\/\/ doesn't work in Cooked mode, an external program may get\n\t\t\/\/ them.\n\t\tif (tmode != TMODE_RAW && termrequest_any_pending())\n\t\t    (void)vpeekc_nomap();\n\t\tcheck_for_codes_from_term();\n\t    }\n#endif\n\t    if (tmode != TMODE_RAW)\n\t\tmch_setmouse(FALSE);\t\/\/ switch mouse off\n\n\t    \/\/ Disable bracketed paste and modifyOtherKeys in cooked mode.\n\t    \/\/ Avoid doing this too often, on some terminals the codes are not\n\t    \/\/ handled properly.\n\t    if (termcap_active && tmode != TMODE_SLEEP\n\t\t\t\t\t\t   && cur_tmode != TMODE_SLEEP)\n\t    {\n\t\tMAY_WANT_TO_LOG_THIS;\n\n\t\tif (tmode != TMODE_RAW)\n\t\t{\n\t\t    out_str(T_BD);\t\/\/ disable bracketed paste mode\n\t\t    out_str(T_CTE);\t\/\/ possibly disables modifyOtherKeys\n\t\t}\n\t\telse\n\t\t{\n\t\t    out_str(T_BE);\t\/\/ enable bracketed paste mode (should\n\t\t\t\t\t\/\/ be before mch_settmode().\n\t\t    out_str(T_CTI);\t\/\/ possibly enables modifyOtherKeys\n\t\t}\n\t    }\n\t    out_flush();\n\t    mch_settmode(tmode);\t\/\/ machine specific function\n\t    cur_tmode = tmode;\n\t    if (tmode == TMODE_RAW)\n\t\tsetmouse();\t\t\/\/ may switch mouse on\n\t    out_flush();\n\t}\n#ifdef FEAT_TERMRESPONSE\n\tmay_req_termresponse();\n#endif\n    }\n}","target":0,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":276912,"func":"static int do_i2c_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t\t  char *const argv[])\n{\n\tint\t\tret = 0;\n\tint\tbus_no;\n\n\tif (argc == 1) {\n\t\t\/* querying current setting *\/\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tstruct udevice *bus;\n\n\t\tif (!i2c_get_cur_bus(&bus))\n\t\t\tbus_no = dev_seq(bus);\n\t\telse\n\t\t\tbus_no = -1;\n#else\n\t\tbus_no = i2c_get_bus_num();\n#endif\n\t\tprintf(\"Current bus is %d\\n\", bus_no);\n\t} else {\n\t\tbus_no = dectoul(argv[1], NULL);\n#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)\n\t\tif (bus_no >= CONFIG_SYS_NUM_I2C_BUSES) {\n\t\t\tprintf(\"Invalid bus %d\\n\", bus_no);\n\t\t\treturn -1;\n\t\t}\n#endif\n\t\tprintf(\"Setting bus to %d\\n\", bus_no);\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tret = cmd_i2c_set_bus_num(bus_no);\n#else\n\t\tret = i2c_set_bus_num(bus_no);\n#endif\n\t\tif (ret)\n\t\t\tprintf(\"Failure changing bus number (%d)\\n\", ret);\n\t}\n\n\treturn ret ? CMD_RET_FAILURE : 0;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":206771,"func":"bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* \/*creationInterface*\/) {\n    \/\/ Allocate LWPolyline vertices (group code 90):\n    if (groupCode==90) {\n        maxVertices = toInt(groupValue);\n        if (maxVertices>0) {\n            if (vertices!=NULL) {\n                delete[] vertices;\n            }\n            vertices = new double[4*maxVertices];\n            for (int i=0; i<maxVertices; ++i) {\n                vertices[i*4] = 0.0;\n                vertices[i*4+1] = 0.0;\n                vertices[i*4+2] = 0.0;\n                vertices[i*4+3] = 0.0;\n            }\n        }\n        vertexIndex=-1;\n        return true;\n    }\n\n    \/\/ Process LWPolylines vertices (group codes 10\/20\/30\/42):\n    else if (groupCode==10 || groupCode==20 ||\n             groupCode==30 || groupCode==42) {\n\n        if (vertexIndex<maxVertices-1 && groupCode==10) {\n            vertexIndex++;\n        }\n\n        if (groupCode<=30) {\n            if (vertexIndex>=0 && vertexIndex<maxVertices) {\n                vertices[4*vertexIndex + (groupCode\/10-1)] = toReal(groupValue);\n            }\n        } else if (groupCode==42 && vertexIndex<maxVertices) {\n            vertices[4*vertexIndex + 3] = toReal(groupValue);\n        }\n        return true;\n    }\n    return false;\n}","target":1,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":317255,"func":"static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts)\n{\n\tchar *from = options;\n\tchar *to = options;\n\tbool first = true;\n\tint rc;\n\n\twhile (1) {\n\t\tint len = opt_len(from);\n\t\tint token;\n\t\tchar *arg = NULL;\n\n\t\ttoken = match_opt_prefix(from, len, &arg);\n\n\t\tif (token != Opt_error) {\n\t\t\tchar *p, *q;\n\n\t\t\t\/* strip quotes *\/\n\t\t\tif (arg) {\n\t\t\t\tfor (p = q = arg; p < from + len; p++) {\n\t\t\t\t\tchar c = *p;\n\t\t\t\t\tif (c != '\"')\n\t\t\t\t\t\t*q++ = c;\n\t\t\t\t}\n\t\t\t\targ = kmemdup_nul(arg, q - arg, GFP_KERNEL);\n\t\t\t\tif (!arg) {\n\t\t\t\t\trc = -ENOMEM;\n\t\t\t\t\tgoto free_opt;\n\t\t\t\t}\n\t\t\t}\n\t\t\trc = selinux_add_opt(token, arg, mnt_opts);\n\t\t\tif (unlikely(rc)) {\n\t\t\t\tkfree(arg);\n\t\t\t\tgoto free_opt;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!first) {\t\/\/ copy with preceding comma\n\t\t\t\tfrom--;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tif (to != from)\n\t\t\t\tmemmove(to, from, len);\n\t\t\tto += len;\n\t\t\tfirst = false;\n\t\t}\n\t\tif (!from[len])\n\t\t\tbreak;\n\t\tfrom += len + 1;\n\t}\n\t*to = '\\0';\n\treturn 0;\n\nfree_opt:\n\tif (*mnt_opts) {\n\t\tselinux_free_mnt_opts(*mnt_opts);\n\t\t*mnt_opts = NULL;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":269312,"func":"static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){\n    int i;\n\n    if(v){\n        const int a= FFABS(v);\n        const int e= av_log2(a);\n        const int el= FFMIN(e, 10);\n        put_rac(c, state+0, 0);\n\n        for(i=0; i<el; i++){\n            put_rac(c, state+1+i, 1);  \/\/1..10\n        }\n        for(; i<e; i++){\n            put_rac(c, state+1+9, 1);  \/\/1..10\n        }\n        put_rac(c, state+1+FFMIN(i,9), 0);\n\n        for(i=e-1; i>=el; i--){\n            put_rac(c, state+22+9, (a>>i)&1); \/\/22..31\n        }\n        for(; i>=0; i--){\n            put_rac(c, state+22+i, (a>>i)&1); \/\/22..31\n        }\n\n        if(is_signed)\n            put_rac(c, state+11 + el, v < 0); \/\/11..21\n    }else{\n        put_rac(c, state+0, 1);\n    }\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":253583,"func":"static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,\n\t\t\t    loff_t offset, loff_t len, bool keep_size)\n{\n\tstruct cifs_ses *ses = tcon->ses;\n\tstruct inode *inode;\n\tstruct cifsInodeInfo *cifsi;\n\tstruct cifsFileInfo *cfile = file->private_data;\n\tstruct file_zero_data_information fsctl_buf;\n\tlong rc;\n\tunsigned int xid;\n\t__le64 eof;\n\n\txid = get_xid();\n\n\tinode = d_inode(cfile->dentry);\n\tcifsi = CIFS_I(inode);\n\n\ttrace_smb3_zero_enter(xid, cfile->fid.persistent_fid, tcon->tid,\n\t\t\t      ses->Suid, offset, len);\n\n\t\/*\n\t * We zero the range through ioctl, so we need remove the page caches\n\t * first, otherwise the data may be inconsistent with the server.\n\t *\/\n\ttruncate_pagecache_range(inode, offset, offset + len - 1);\n\n\t\/* if file not oplocked can't be sure whether asking to extend size *\/\n\tif (!CIFS_CACHE_READ(cifsi))\n\t\tif (keep_size == false) {\n\t\t\trc = -EOPNOTSUPP;\n\t\t\ttrace_smb3_zero_err(xid, cfile->fid.persistent_fid,\n\t\t\t\ttcon->tid, ses->Suid, offset, len, rc);\n\t\t\tfree_xid(xid);\n\t\t\treturn rc;\n\t\t}\n\n\tcifs_dbg(FYI, \"Offset %lld len %lld\\n\", offset, len);\n\n\tfsctl_buf.FileOffset = cpu_to_le64(offset);\n\tfsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);\n\n\trc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,\n\t\t\tcfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, true,\n\t\t\t(char *)&fsctl_buf,\n\t\t\tsizeof(struct file_zero_data_information),\n\t\t\t0, NULL, NULL);\n\tif (rc)\n\t\tgoto zero_range_exit;\n\n\t\/*\n\t * do we also need to change the size of the file?\n\t *\/\n\tif (keep_size == false && i_size_read(inode) < offset + len) {\n\t\teof = cpu_to_le64(offset + len);\n\t\trc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,\n\t\t\t\t  cfile->fid.volatile_fid, cfile->pid, &eof);\n\t}\n\n zero_range_exit:\n\tfree_xid(xid);\n\tif (rc)\n\t\ttrace_smb3_zero_err(xid, cfile->fid.persistent_fid, tcon->tid,\n\t\t\t      ses->Suid, offset, len, rc);\n\telse\n\t\ttrace_smb3_zero_done(xid, cfile->fid.persistent_fid, tcon->tid,\n\t\t\t      ses->Suid, offset, len);\n\treturn rc;\n}","target":0,"code_token_length":598,"total_token_length":834,"max_tokens_setting":1024}
+{"idx":195040,"func":"Status BuildXlaCompilationCache(DeviceBase* device, FunctionLibraryRuntime* flr,\n                                const XlaPlatformInfo& platform_info,\n                                XlaCompilationCache** cache) {\n  if (platform_info.xla_device_metadata()) {\n    *cache = new XlaCompilationCache(\n        platform_info.xla_device_metadata()->client(),\n        platform_info.xla_device_metadata()->jit_device_type());\n    return Status::OK();\n  }\n\n  auto platform =\n      se::MultiPlatformManager::PlatformWithId(platform_info.platform_id());\n  if (!platform.ok()) {\n    return platform.status();\n  }\n\n  StatusOr<xla::Compiler*> compiler_for_platform =\n      xla::Compiler::GetForPlatform(platform.ValueOrDie());\n  if (!compiler_for_platform.ok()) {\n    \/\/ In some rare cases (usually in unit tests with very small clusters) we\n    \/\/ may end up transforming an XLA cluster with at least one GPU operation\n    \/\/ (which would normally force the cluster to be compiled using XLA:GPU)\n    \/\/ into an XLA cluster with no GPU operations (i.e. containing only CPU\n    \/\/ operations).  Such a cluster can fail compilation (in way that\n    \/\/ MarkForCompilation could not have detected) if the CPU JIT is not linked\n    \/\/ in.\n    \/\/\n    \/\/ So bail out of _XlaCompile in this case, and let the executor handle the\n    \/\/ situation for us.\n    const Status& status = compiler_for_platform.status();\n    if (status.code() == error::NOT_FOUND) {\n      return errors::Unimplemented(\"Could not find compiler for platform \",\n                                   platform.ValueOrDie()->Name(), \": \",\n                                   status.ToString());\n    }\n  }\n\n  xla::LocalClientOptions client_options;\n  client_options.set_platform(platform.ValueOrDie());\n  client_options.set_intra_op_parallelism_threads(\n      device->tensorflow_cpu_worker_threads()->num_threads);\n\n  string allowed_gpus =\n      flr->config_proto()->gpu_options().visible_device_list();\n  TF_ASSIGN_OR_RETURN(absl::optional<std::set<int>> gpu_ids,\n                      ParseVisibleDeviceList(allowed_gpus));\n  client_options.set_allowed_devices(gpu_ids);\n\n  auto client = xla::ClientLibrary::GetOrCreateLocalClient(client_options);\n  if (!client.ok()) {\n    return client.status();\n  }\n  const XlaOpRegistry::DeviceRegistration* registration;\n  if (!XlaOpRegistry::GetCompilationDevice(platform_info.device_type().type(),\n                                           ®istration)) {\n    return errors::InvalidArgument(\"No JIT device registered for \",\n                                   platform_info.device_type().type());\n  }\n  *cache = new XlaCompilationCache(\n      client.ValueOrDie(), DeviceType(registration->compilation_device_name));\n  return Status::OK();\n}","target":1,"code_token_length":572,"total_token_length":808,"max_tokens_setting":1024}
+{"idx":197466,"func":"void RestoreTensor(OpKernelContext* context,\n                   checkpoint::TensorSliceReader::OpenTableFunction open_func,\n                   int preferred_shard, bool restore_slice, int restore_index) {\n  const Tensor& file_pattern_t = context->input(0);\n  {\n    const int64_t size = file_pattern_t.NumElements();\n    OP_REQUIRES(\n        context, size == 1,\n        errors::InvalidArgument(\n            \"Input 0 (file_pattern) must be a string scalar; got a tensor of \",\n            size, \"elements\"));\n  }\n  const string& file_pattern = file_pattern_t.flat<tstring>()(0);\n\n  const Tensor& tensor_name_t = context->input(1);\n  const string& tensor_name = tensor_name_t.flat<tstring>()(restore_index);\n\n  \/\/ If we cannot find a cached reader we will allocate our own.\n  std::unique_ptr<checkpoint::TensorSliceReader> allocated_reader;\n\n  const checkpoint::TensorSliceReader* reader = nullptr;\n\n  if (context->slice_reader_cache()) {\n    reader = context->slice_reader_cache()->GetReader(file_pattern, open_func,\n                                                      preferred_shard);\n  }\n  if (!reader) {\n    allocated_reader.reset(new checkpoint::TensorSliceReader(\n        file_pattern, open_func, preferred_shard));\n    reader = allocated_reader.get();\n  }\n  OP_REQUIRES_OK(context, CHECK_NOTNULL(reader)->status());\n\n  \/\/ Get the shape and type from the save file.\n  DataType type;\n  TensorShape saved_shape;\n  OP_REQUIRES(\n      context, reader->HasTensor(tensor_name, &saved_shape, &type),\n      errors::NotFound(\"Tensor name \\\"\", tensor_name,\n                       \"\\\" not found in checkpoint files \", file_pattern));\n  OP_REQUIRES(\n      context, type == context->expected_output_dtype(restore_index),\n      errors::InvalidArgument(\"Expected to restore a tensor of type \",\n                              DataTypeString(context->expected_output_dtype(0)),\n                              \", got a tensor of type \", DataTypeString(type),\n                              \" instead: tensor_name = \", tensor_name));\n\n  \/\/ Shape of the output and slice to load.\n  TensorShape output_shape(saved_shape);\n  TensorSlice slice_to_load(saved_shape.dims());\n  if (restore_slice) {\n    const tstring& shape_spec =\n        context->input(2).flat<tstring>()(restore_index);\n    if (!shape_spec.empty()) {\n      TensorShape parsed_shape;\n      OP_REQUIRES_OK(context, checkpoint::ParseShapeAndSlice(\n                                  shape_spec, &parsed_shape, &slice_to_load,\n                                  &output_shape));\n      OP_REQUIRES(\n          context, parsed_shape.IsSameSize(saved_shape),\n          errors::InvalidArgument(\n              \"Shape in shape_and_slice spec does not match the shape in the \"\n              \"save file: \",\n              parsed_shape.DebugString(),\n              \", save file shape: \", saved_shape.DebugString()));\n    }\n  }\n\n  Tensor* t = nullptr;\n  OP_REQUIRES_OK(context,\n                 context->allocate_output(restore_index, output_shape, &t));\n\n  if (output_shape.num_elements() == 0) return;\n\n#define READER_COPY(T)                                                \\\n  case DataTypeToEnum<T>::value:                                      \\\n    OP_REQUIRES(context,                                              \\\n                reader->CopySliceData(tensor_name, slice_to_load,     \\\n                                      t->flat<T>().data()),           \\\n                errors::InvalidArgument(\"Error copying slice data\")); \\\n    break;\n\n  switch (type) {\n    TF_CALL_SAVE_RESTORE_TYPES(READER_COPY)\n    default:\n      context->SetStatus(errors::Unimplemented(\n          \"Restoring data type \", DataTypeString(type), \" not yet supported\"));\n  }\n#undef READER_COPY\n}","target":1,"code_token_length":761,"total_token_length":997,"max_tokens_setting":1024}
+{"idx":487666,"func":"asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)\n{\n\tstruct task_struct *p;\n\tstruct task_struct *group_leader = current->group_leader;\n\tint err = -EINVAL;\n\n\tif (!pid)\n\t\tpid = group_leader->pid;\n\tif (!pgid)\n\t\tpgid = pid;\n\tif (pgid < 0)\n\t\treturn -EINVAL;\n\n\t\/* From this point forward we keep holding onto the tasklist lock\n\t * so that our parent does not change from under us. -DaveM\n\t *\/\n\twrite_lock_irq(&tasklist_lock);\n\n\terr = -ESRCH;\n\tp = find_task_by_pid(pid);\n\tif (!p)\n\t\tgoto out;\n\n\terr = -EINVAL;\n\tif (!thread_group_leader(p))\n\t\tgoto out;\n\n\tif (p->real_parent == group_leader) {\n\t\terr = -EPERM;\n\t\tif (task_session(p) != task_session(group_leader))\n\t\t\tgoto out;\n\t\terr = -EACCES;\n\t\tif (p->did_exec)\n\t\t\tgoto out;\n\t} else {\n\t\terr = -ESRCH;\n\t\tif (p != group_leader)\n\t\t\tgoto out;\n\t}\n\n\terr = -EPERM;\n\tif (p->signal->leader)\n\t\tgoto out;\n\n\tif (pgid != pid) {\n\t\tstruct task_struct *g =\n\t\t\tfind_task_by_pid_type(PIDTYPE_PGID, pgid);\n\n\t\tif (!g || task_session(g) != task_session(group_leader))\n\t\t\tgoto out;\n\t}\n\n\terr = security_task_setpgid(p, pgid);\n\tif (err)\n\t\tgoto out;\n\n\tif (process_group(p) != pgid) {\n\t\tdetach_pid(p, PIDTYPE_PGID);\n\t\tp->signal->pgrp = pgid;\n\t\tattach_pid(p, PIDTYPE_PGID, pgid);\n\t}\n\n\terr = 0;\nout:\n\t\/* All paths lead to here, thus we are safe. -DaveM *\/\n\twrite_unlock_irq(&tasklist_lock);\n\treturn err;\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":437404,"func":"vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,\n\t\t\tint main_fd __rte_unused)\n{\n\tstruct virtio_net *dev = *pdev;\n\tuint64_t features = msg->payload.u64;\n\tuint64_t vhost_features = 0;\n\tstruct rte_vdpa_device *vdpa_dev;\n\tint did = -1;\n\n\trte_vhost_driver_get_features(dev->ifname, &vhost_features);\n\tif (features & ~vhost_features) {\n\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\"(%d) received invalid negotiated features.\\n\",\n\t\t\tdev->vid);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tif (dev->flags & VIRTIO_DEV_RUNNING) {\n\t\tif (dev->features == features)\n\t\t\treturn RTE_VHOST_MSG_RESULT_OK;\n\n\t\t\/*\n\t\t * Error out if master tries to change features while device is\n\t\t * in running state. The exception being VHOST_F_LOG_ALL, which\n\t\t * is enabled when the live-migration starts.\n\t\t *\/\n\t\tif ((dev->features ^ features) & ~(1ULL << VHOST_F_LOG_ALL)) {\n\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\t\"(%d) features changed while device is running.\\n\",\n\t\t\t\tdev->vid);\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\n\t\tif (dev->notify_ops->features_changed)\n\t\t\tdev->notify_ops->features_changed(dev->vid, features);\n\t}\n\n\tdev->features = features;\n\tif (dev->features &\n\t\t((1 << VIRTIO_NET_F_MRG_RXBUF) | (1ULL << VIRTIO_F_VERSION_1))) {\n\t\tdev->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf);\n\t} else {\n\t\tdev->vhost_hlen = sizeof(struct virtio_net_hdr);\n\t}\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"negotiated Virtio features: 0x%\" PRIx64 \"\\n\", dev->features);\n\tVHOST_LOG_DEBUG(VHOST_CONFIG,\n\t\t\"(%d) mergeable RX buffers %s, virtio 1 %s\\n\",\n\t\tdev->vid,\n\t\t(dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? \"on\" : \"off\",\n\t\t(dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? \"on\" : \"off\");\n\n\tif ((dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET) &&\n\t    !(dev->features & (1ULL << VIRTIO_NET_F_MQ))) {\n\t\t\/*\n\t\t * Remove all but first queue pair if MQ hasn't been\n\t\t * negotiated. This is safe because the device is not\n\t\t * running at this stage.\n\t\t *\/\n\t\twhile (dev->nr_vring > 2) {\n\t\t\tstruct vhost_virtqueue *vq;\n\n\t\t\tvq = dev->virtqueue[--dev->nr_vring];\n\t\t\tif (!vq)\n\t\t\t\tcontinue;\n\n\t\t\tdev->virtqueue[dev->nr_vring] = NULL;\n\t\t\tcleanup_vq(vq, 1);\n\t\t\tfree_vq(dev, vq);\n\t\t}\n\t}\n\n\tdid = dev->vdpa_dev_id;\n\tvdpa_dev = rte_vdpa_get_device(did);\n\tif (vdpa_dev && vdpa_dev->ops->set_features)\n\t\tvdpa_dev->ops->set_features(dev->vid);\n\n\treturn RTE_VHOST_MSG_RESULT_OK;\n}","target":0,"code_token_length":740,"total_token_length":976,"max_tokens_setting":1024}
+{"idx":246449,"func":"static RBinWasmCustomNameEntry *parse_custom_name_entry(RBinWasmObj *bin, ut64 bound) {\n\tRBuffer *b = bin->buf;\n\tRBinWasmCustomNameEntry *cust = R_NEW0 (RBinWasmCustomNameEntry);\n\tif (!cust) {\n\t\treturn NULL;\n\t}\n\tcust->type = R_BIN_WASM_NAMETYPE_None;\n\n\tsize_t start = r_buf_tell (b);\n\tif (!consume_u7_r (b, bound, &cust->type)) {\n\t\tgoto beach;\n\t};\n\n\tif (!consume_u32_r (b, bound, &cust->size)) {\n\t\tgoto beach;\n\t};\n\n\tswitch (cust->type) {\n\tcase R_BIN_WASM_NAMETYPE_Module:\n\t\tif (!consume_encoded_name_new (b, bound, NULL, &cust->mod_name)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tbreak;\n\tcase R_BIN_WASM_NAMETYPE_Function:\n\t\tcust->func = R_NEW0 (RBinWasmCustomNameFunctionNames);\n\t\tif (!cust->func) {\n\t\t\tgoto beach;\n\t\t}\n\t\tcust->func->names = r_id_storage_new (0, UT32_MAX);\n\t\tif (!cust->func->names) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tif (!parse_namemap (b, bound, cust->func->names, &cust->func->count)) {\n\t\t\tgoto beach;\n\t\t}\n\t\tbreak;\n\tcase R_BIN_WASM_NAMETYPE_Local:\n\t\tcust->local = parse_custom_names_local (b, bound);\n\t\tif (!cust->local) {\n\t\t\tgoto beach;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tR_LOG_WARN (\"[wasm] Halting custom name section parsing at unknown type 0x%x offset 0x%\" PFMTSZx \"\\n\", cust->type, start);\n\t\tcust->type = R_BIN_WASM_NAMETYPE_None;\n\t\tgoto beach;\n\t}\n\n\treturn cust;\nbeach:\n\twasm_custom_name_free (cust);\n\treturn NULL;\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":210271,"func":"sug_filltree(spellinfo_T *spin, slang_T *slang)\n{\n    char_u\t*byts;\n    idx_T\t*idxs;\n    int\t\tdepth;\n    idx_T\tarridx[MAXWLEN];\n    int\t\tcuri[MAXWLEN];\n    char_u\ttword[MAXWLEN];\n    char_u\ttsalword[MAXWLEN];\n    int\t\tc;\n    idx_T\tn;\n    unsigned\twords_done = 0;\n    int\t\twordcount[MAXWLEN];\n\n    \/\/ We use si_foldroot for the soundfolded trie.\n    spin->si_foldroot = wordtree_alloc(spin);\n    if (spin->si_foldroot == NULL)\n\treturn FAIL;\n\n    \/\/ let tree_add_word() know we're adding to the soundfolded tree\n    spin->si_sugtree = TRUE;\n\n    \/*\n     * Go through the whole case-folded tree, soundfold each word and put it\n     * in the trie.\n     *\/\n    byts = slang->sl_fbyts;\n    idxs = slang->sl_fidxs;\n\n    arridx[0] = 0;\n    curi[0] = 1;\n    wordcount[0] = 0;\n\n    depth = 0;\n    while (depth >= 0 && !got_int)\n    {\n\tif (curi[depth] > byts[arridx[depth]])\n\t{\n\t    \/\/ Done all bytes at this node, go up one level.\n\t    idxs[arridx[depth]] = wordcount[depth];\n\t    if (depth > 0)\n\t\twordcount[depth - 1] += wordcount[depth];\n\n\t    --depth;\n\t    line_breakcheck();\n\t}\n\telse\n\t{\n\n\t    \/\/ Do one more byte at this node.\n\t    n = arridx[depth] + curi[depth];\n\t    ++curi[depth];\n\n\t    c = byts[n];\n\t    if (c == 0)\n\t    {\n\t\t\/\/ Sound-fold the word.\n\t\ttword[depth] = NUL;\n\t\tspell_soundfold(slang, tword, TRUE, tsalword);\n\n\t\t\/\/ We use the \"flags\" field for the MSB of the wordnr,\n\t\t\/\/ \"region\" for the LSB of the wordnr.\n\t\tif (tree_add_word(spin, tsalword, spin->si_foldroot,\n\t\t\t\twords_done >> 16, words_done & 0xffff,\n\t\t\t\t\t\t\t   0) == FAIL)\n\t\t    return FAIL;\n\n\t\t++words_done;\n\t\t++wordcount[depth];\n\n\t\t\/\/ Reset the block count each time to avoid compression\n\t\t\/\/ kicking in.\n\t\tspin->si_blocks_cnt = 0;\n\n\t\t\/\/ Skip over any other NUL bytes (same word with different\n\t\t\/\/ flags).  But don't go over the end.\n\t\twhile (n + 1 < slang->sl_fbyts_len && byts[n + 1] == 0)\n\t\t{\n\t\t    ++n;\n\t\t    ++curi[depth];\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Normal char, go one level deeper.\n\t\ttword[depth++] = c;\n\t\tarridx[depth] = idxs[n];\n\t\tcuri[depth] = 1;\n\t\twordcount[depth] = 0;\n\t    }\n\t}\n    }\n\n    smsg(_(\"Total number of words: %d\"), words_done);\n\n    return OK;\n}","target":1,"code_token_length":720,"total_token_length":956,"max_tokens_setting":1024}
+{"idx":245692,"func":"njs_array_length_set(njs_vm_t *vm, njs_value_t *value,\n    njs_object_prop_t *prev, njs_value_t *setval)\n{\n    double        num, idx;\n    int64_t       prev_length;\n    uint32_t      i, length;\n    njs_int_t     ret;\n    njs_array_t   *array, *keys;\n\n    array = njs_object_proto_lookup(njs_object(value), NJS_ARRAY, njs_array_t);\n    if (njs_slow_path(array == NULL)) {\n        return NJS_DECLINED;\n    }\n\n    ret = njs_value_to_number(vm, setval, &num);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = (uint32_t) njs_number_to_length(num);\n    if ((double) length != num) {\n        njs_range_error(vm, \"Invalid array length\");\n        return NJS_ERROR;\n    }\n\n    ret = njs_value_to_length(vm, &prev->value, &prev_length);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    keys = NULL;\n\n    if (length < prev_length) {\n        keys = njs_array_indices(vm, value);\n        if (njs_slow_path(keys == NULL)) {\n            return NJS_ERROR;\n        }\n\n        if (keys->length != 0) {\n            i = keys->length - 1;\n\n            do {\n                idx = njs_string_to_index(&keys->start[i]);\n                if (idx >= length) {\n                    ret = njs_value_property_delete(vm, value, &keys->start[i],\n                                                    NULL, 1);\n                    if (njs_slow_path(ret == NJS_ERROR)) {\n                        goto done;\n                    }\n                }\n            } while (i-- != 0);\n        }\n    }\n\n    ret = njs_array_length_redefine(vm, value, length);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = NJS_OK;\n\ndone:\n\n    if (keys != NULL) {\n        njs_array_destroy(vm, keys);\n    }\n\n    return ret;\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":259222,"func":"static int avif_add_stream(MOVContext *c, int item_id)\n{\n    MOVStreamContext *sc;\n    AVStream *st;\n    int item_index = -1;\n    for (int i = 0; i < c->avif_info_size; i++)\n        if (c->avif_info[i].item_id == item_id) {\n            item_index = i;\n            break;\n        }\n    if (item_index < 0)\n        return AVERROR_INVALIDDATA;\n    st = avformat_new_stream(c->fc, NULL);\n    if (!st)\n        return AVERROR(ENOMEM);\n    st->id = c->fc->nb_streams;\n    sc = av_mallocz(sizeof(MOVStreamContext));\n    if (!sc)\n        return AVERROR(ENOMEM);\n\n    st->priv_data = sc;\n    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;\n    st->codecpar->codec_id = AV_CODEC_ID_AV1;\n    sc->ffindex = st->index;\n    c->trak_index = st->index;\n    st->avg_frame_rate.num = st->avg_frame_rate.den = 1;\n    st->time_base.num = st->time_base.den = 1;\n    st->nb_frames = 1;\n    sc->time_scale = 1;\n    sc = st->priv_data;\n    sc->pb = c->fc->pb;\n    sc->pb_is_copied = 1;\n\n    \/\/ Populate the necessary fields used by mov_build_index.\n    sc->stsc_count = 1;\n    sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data));\n    if (!sc->stsc_data)\n        return AVERROR(ENOMEM);\n    sc->stsc_data[0].first = 1;\n    sc->stsc_data[0].count = 1;\n    sc->stsc_data[0].id = 1;\n    sc->chunk_count = 1;\n    sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets));\n    if (!sc->chunk_offsets)\n        return AVERROR(ENOMEM);\n    sc->sample_count = 1;\n    sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes));\n    if (!sc->sample_sizes)\n        return AVERROR(ENOMEM);\n    sc->stts_count = 1;\n    sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data));\n    if (!sc->stts_data)\n        return AVERROR(ENOMEM);\n    sc->stts_data[0].count = 1;\n    \/\/ Not used for still images. But needed by mov_build_index.\n    sc->stts_data[0].duration = 0;\n    sc->sample_sizes[0] = c->avif_info[item_index].extent_length;\n    sc->chunk_offsets[0] = c->avif_info[item_index].extent_offset;\n\n    mov_build_index(c, st);\n    return 0;\n}","target":0,"code_token_length":635,"total_token_length":871,"max_tokens_setting":1024}
+{"idx":244301,"func":"GF_Err sbgp_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_SampleGroupBox *ptr = (GF_SampleGroupBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 8);\n\tptr->grouping_type = gf_bs_read_u32(bs);\n\n\tif (ptr->version==1) {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->grouping_type_parameter = gf_bs_read_u32(bs);\n\t}\n\tptr->entry_count = gf_bs_read_u32(bs);\n\n\tif (ptr->size < sizeof(GF_SampleGroupEntry)*ptr->entry_count || (u64)ptr->entry_count > (u64)SIZE_MAX\/sizeof(GF_SampleGroupEntry))\n\t    return GF_ISOM_INVALID_FILE;\n\n\tptr->sample_entries = gf_malloc(sizeof(GF_SampleGroupEntry)*ptr->entry_count);\n\tif (!ptr->sample_entries) return GF_OUT_OF_MEM;\n\n\tfor (i=0; i<ptr->entry_count; i++) {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->sample_entries[i].sample_count = gf_bs_read_u32(bs);\n\t\tptr->sample_entries[i].group_description_index = gf_bs_read_u32(bs);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":291794,"func":"static int rtrs_post_send_rdma(struct rtrs_clt_con *con,\n\t\t\t\tstruct rtrs_clt_io_req *req,\n\t\t\t\tstruct rtrs_rbuf *rbuf, u32 off,\n\t\t\t\tu32 imm, struct ib_send_wr *wr)\n{\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\tenum ib_send_flags flags;\n\tstruct ib_sge sge;\n\n\tif (!req->sg_size) {\n\t\trtrs_wrn(con->c.path,\n\t\t\t \"Doing RDMA Write failed, no data supplied\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t\/* user data and user message in the first list element *\/\n\tsge.addr   = req->iu->dma_addr;\n\tsge.length = req->sg_size;\n\tsge.lkey   = clt_path->s.dev->ib_pd->local_dma_lkey;\n\n\t\/*\n\t * From time to time we have to post signalled sends,\n\t * or send queue will fill up and only QP reset can help.\n\t *\/\n\tflags = atomic_inc_return(&con->c.wr_cnt) % clt_path->s.signal_interval ?\n\t\t\t0 : IB_SEND_SIGNALED;\n\n\tib_dma_sync_single_for_device(clt_path->s.dev->ib_dev,\n\t\t\t\t      req->iu->dma_addr,\n\t\t\t\t      req->sg_size, DMA_TO_DEVICE);\n\n\treturn rtrs_iu_post_rdma_write_imm(&con->c, req->iu, &sge, 1,\n\t\t\t\t\t    rbuf->rkey, rbuf->addr + off,\n\t\t\t\t\t    imm, flags, wr, NULL);\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":462440,"func":"addSess(ptcplstn_t *pLstn, int sock, prop_t *peerName, prop_t *peerIP)\n{\n\tDEFiRet;\n\tptcpsess_t *pSess = NULL;\n\tptcpsrv_t *pSrv = pLstn->pSrv;\n\n\tCHKmalloc(pSess = malloc(sizeof(ptcpsess_t)));\n\tCHKmalloc(pSess->pMsg = malloc(iMaxLine));\n\tpSess->pLstn = pLstn;\n\tpSess->sock = sock;\n\tpSess->bSuppOctetFram = pLstn->bSuppOctetFram;\n\tpSess->bSPFramingFix = pLstn->bSPFramingFix;\n\tpSess->inputState = eAtStrtFram;\n\tpSess->iMsg = 0;\n\tpSess->bzInitDone = 0;\n\tpSess->bAtStrtOfFram = 1;\n\tpSess->peerName = peerName;\n\tpSess->peerIP = peerIP;\n\tpSess->compressionMode = pLstn->pSrv->compressionMode;\n\n\t\/* add to start of server's listener list *\/\n\tpSess->prev = NULL;\n\tpthread_mutex_lock(&pSrv->mutSessLst);\n\tpSess->next = pSrv->pSess;\n\tif(pSrv->pSess != NULL)\n\t\tpSrv->pSess->prev = pSess;\n\tpSrv->pSess = pSess;\n\tpthread_mutex_unlock(&pSrv->mutSessLst);\n\n\tCHKiRet(addEPollSock(epolld_sess, pSess, sock, &pSess->epd));\n\nfinalize_it:\n\tif(iRet != RS_RET_OK) {\n\t\tif(pSess != NULL) {\n\t\t\tif(pSess->pMsg != NULL)\n\t\t\t\tfree(pSess->pMsg);\n\t\t\tfree(pSess);\n\t\t}\n\t}\n\n\tRETiRet;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":343255,"func":"void dofeat(void)\n{\n# define FEAT  \"Extensions supported:\" CRLF \\\n    \" UTF8\" CRLF \\\n    \" EPRT\" CRLF \" IDLE\" CRLF \" MDTM\" CRLF \" SIZE\" CRLF \" MFMT\" CRLF \\\n    \" REST STREAM\" CRLF \\\n    \" MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;\" CRLF \\\n    \" MLSD\" CRLF \\\n    \" PRET\"\n\n# ifdef WITH_TLS\n#  define FEAT_TLS CRLF \" AUTH TLS\" CRLF \" PBSZ\" CRLF \" PROT\"\n# else\n#  define FEAT_TLS \"\"\n# endif\n# ifdef DEBUG\n#  define FEAT_DEBUG CRLF \" XDBG\"\n# else\n#  define FEAT_DEBUG \"\"\n# endif\n# ifdef WITH_VIRTUAL_CHROOT\n#  define FEAT_TVFS \"\"\n# else\n#  define FEAT_TVFS CRLF \" TVFS\"\n# endif\n# define FEAT_PASV CRLF \" PASV\" CRLF \" EPSV\"\n\n# ifdef MINIMAL\n#  define FEAT_ESTA \"\"\n#  define FEAT_ESTP \"\"\n# else\n#  define FEAT_ESTA CRLF \" ESTA\"\n#  define FEAT_ESTP CRLF \" ESTP\"\n# endif\n\n    char feat[] = FEAT FEAT_DEBUG FEAT_TLS FEAT_TVFS FEAT_ESTA FEAT_PASV FEAT_ESTP;\n\n    if (disallow_passive != 0) {\n        feat[sizeof FEAT FEAT_DEBUG FEAT_TLS FEAT_TVFS FEAT_ESTA - 1U] = 0;\n    }\n# ifndef MINIMAL\n    else if (STORAGE_FAMILY(force_passive_ip) != 0) {\n        feat[sizeof FEAT FEAT_DEBUG FEAT_TLS FEAT_TVFS FEAT_ESTA FEAT_PASV - 1U] = 0;\n    }\n# endif\n    addreply_noformat(0, feat);\n    addreply_noformat(211, \"End.\");\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":263503,"func":"static int sco_sock_getsockopt(struct socket *sock, int level, int optname,\n\t\t\t       char __user *optval, int __user *optlen)\n{\n\tstruct sock *sk = sock->sk;\n\tint len, err = 0;\n\tstruct bt_voice voice;\n\tu32 phys;\n\tint pkt_status;\n\n\tBT_DBG(\"sk %p\", sk);\n\n\tif (level == SOL_SCO)\n\t\treturn sco_sock_getsockopt_old(sock, optname, optval, optlen);\n\n\tif (get_user(len, optlen))\n\t\treturn -EFAULT;\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\n\tcase BT_DEFER_SETUP:\n\t\tif (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) {\n\t\t\terr = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags),\n\t\t\t     (u32 __user *)optval))\n\t\t\terr = -EFAULT;\n\n\t\tbreak;\n\n\tcase BT_VOICE:\n\t\tvoice.setting = sco_pi(sk)->setting;\n\n\t\tlen = min_t(unsigned int, len, sizeof(voice));\n\t\tif (copy_to_user(optval, (char *)&voice, len))\n\t\t\terr = -EFAULT;\n\n\t\tbreak;\n\n\tcase BT_PHY:\n\t\tif (sk->sk_state != BT_CONNECTED) {\n\t\t\terr = -ENOTCONN;\n\t\t\tbreak;\n\t\t}\n\n\t\tphys = hci_conn_get_phy(sco_pi(sk)->conn->hcon);\n\n\t\tif (put_user(phys, (u32 __user *) optval))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\n\tcase BT_PKT_STATUS:\n\t\tpkt_status = (sco_pi(sk)->cmsg_mask & SCO_CMSG_PKT_STATUS);\n\n\t\tif (put_user(pkt_status, (int __user *)optval))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\n\tcase BT_SNDMTU:\n\tcase BT_RCVMTU:\n\t\tif (sk->sk_state != BT_CONNECTED) {\n\t\t\terr = -ENOTCONN;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (put_user(sco_pi(sk)->conn->mtu, (u32 __user *)optval))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\n\tdefault:\n\t\terr = -ENOPROTOOPT;\n\t\tbreak;\n\t}\n\n\trelease_sock(sk);\n\treturn err;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":313547,"func":"int rose_rt_ioctl(unsigned int cmd, void __user *arg)\n{\n\tstruct rose_route_struct rose_route;\n\tstruct net_device *dev;\n\tint err;\n\n\tswitch (cmd) {\n\tcase SIOCADDRT:\n\t\tif (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))\n\t\t\treturn -EFAULT;\n\t\tif ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)\n\t\t\treturn -EINVAL;\n\t\tif (rose_dev_exists(&rose_route.address)) \/* Can't add routes to ourself *\/\n\t\t\treturn -EINVAL;\n\t\tif (rose_route.mask > 10) \/* Mask can't be more than 10 digits *\/\n\t\t\treturn -EINVAL;\n\t\tif (rose_route.ndigis > AX25_MAX_DIGIS)\n\t\t\treturn -EINVAL;\n\t\terr = rose_add_node(&rose_route, dev);\n\t\treturn err;\n\n\tcase SIOCDELRT:\n\t\tif (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))\n\t\t\treturn -EFAULT;\n\t\tif ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)\n\t\t\treturn -EINVAL;\n\t\terr = rose_del_node(&rose_route, dev);\n\t\treturn err;\n\n\tcase SIOCRSCLRRT:\n\t\treturn rose_clear_routes();\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":498081,"func":"static void print_header(void)\n{\n\tchar *logo = NULL, *logo_link = NULL;\n\n\thtml(\"<table id='header'>\\n\");\n\thtml(\"<tr>\\n\");\n\n\tif (ctx.repo && ctx.repo->logo && *ctx.repo->logo)\n\t\tlogo = ctx.repo->logo;\n\telse\n\t\tlogo = ctx.cfg.logo;\n\tif (ctx.repo && ctx.repo->logo_link && *ctx.repo->logo_link)\n\t\tlogo_link = ctx.repo->logo_link;\n\telse\n\t\tlogo_link = ctx.cfg.logo_link;\n\tif (logo && *logo) {\n\t\thtml(\"<td class='logo' rowspan='2'><a href='\");\n\t\tif (logo_link && *logo_link)\n\t\t\thtml_attr(logo_link);\n\t\telse\n\t\t\thtml_attr(cgit_rooturl());\n\t\thtml(\"'><img src='\");\n\t\thtml_attr(logo);\n\t\thtml(\"' alt='cgit logo'\/><\/a><\/td>\\n\");\n\t}\n\n\thtml(\"<td class='main'>\");\n\tif (ctx.repo) {\n\t\tcgit_index_link(\"index\", NULL, NULL, NULL, NULL, 0, 1);\n\t\thtml(\" : \");\n\t\tcgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);\n\t\tif (ctx.env.authenticated) {\n\t\t\thtml(\"<\/td><td class='form'>\");\n\t\t\thtml(\"<form method='get' action=''>\\n\");\n\t\t\tcgit_add_hidden_formfields(0, 1, ctx.qry.page);\n\t\t\thtml(\"<select name='h' onchange='this.form.submit();'>\\n\");\n\t\t\tfor_each_branch_ref(print_branch_option, ctx.qry.head);\n\t\t\tif (ctx.repo->enable_remote_branches)\n\t\t\t\tfor_each_remote_ref(print_branch_option, ctx.qry.head);\n\t\t\thtml(\"<\/select> \");\n\t\t\thtml(\"<input type='submit' name='' value='switch'\/>\");\n\t\t\thtml(\"<\/form>\");\n\t\t}\n\t} else\n\t\thtml_txt(ctx.cfg.root_title);\n\thtml(\"<\/td><\/tr>\\n\");\n\n\thtml(\"<tr><td class='sub'>\");\n\tif (ctx.repo) {\n\t\thtml_txt(ctx.repo->desc);\n\t\thtml(\"<\/td><td class='sub right'>\");\n\t\thtml_txt(ctx.repo->owner);\n\t} else {\n\t\tif (ctx.cfg.root_desc)\n\t\t\thtml_txt(ctx.cfg.root_desc);\n\t\telse if (ctx.cfg.index_info)\n\t\t\thtml_include(ctx.cfg.index_info);\n\t}\n\thtml(\"<\/td><\/tr><\/table>\\n\");\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":483489,"func":"static int __init efisubsys_init(void)\n{\n\tint error;\n\n\tif (!efi_enabled(EFI_BOOT))\n\t\treturn 0;\n\n\t\/*\n\t * Since we process only one efi_runtime_service() at a time, an\n\t * ordered workqueue (which creates only one execution context)\n\t * should suffice all our needs.\n\t *\/\n\tefi_rts_wq = alloc_ordered_workqueue(\"efi_rts_wq\", 0);\n\tif (!efi_rts_wq) {\n\t\tpr_err(\"Creating efi_rts_wq failed, EFI runtime services disabled.\\n\");\n\t\tclear_bit(EFI_RUNTIME_SERVICES, &efi.flags);\n\t\treturn 0;\n\t}\n\n\t\/* We register the efi directory at \/sys\/firmware\/efi *\/\n\tefi_kobj = kobject_create_and_add(\"efi\", firmware_kobj);\n\tif (!efi_kobj) {\n\t\tpr_err(\"efi: Firmware registration failed.\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\terror = generic_ops_register();\n\tif (error)\n\t\tgoto err_put;\n\n\tif (efi_enabled(EFI_RUNTIME_SERVICES))\n\t\tefivar_ssdt_load();\n\n\terror = sysfs_create_group(efi_kobj, &efi_subsys_attr_group);\n\tif (error) {\n\t\tpr_err(\"efi: Sysfs attribute export failed with error %d.\\n\",\n\t\t       error);\n\t\tgoto err_unregister;\n\t}\n\n\terror = efi_runtime_map_init(efi_kobj);\n\tif (error)\n\t\tgoto err_remove_group;\n\n\t\/* and the standard mountpoint for efivarfs *\/\n\terror = sysfs_create_mount_point(efi_kobj, \"efivars\");\n\tif (error) {\n\t\tpr_err(\"efivars: Subsystem registration failed.\\n\");\n\t\tgoto err_remove_group;\n\t}\n\n\treturn 0;\n\nerr_remove_group:\n\tsysfs_remove_group(efi_kobj, &efi_subsys_attr_group);\nerr_unregister:\n\tgeneric_ops_unregister();\nerr_put:\n\tkobject_put(efi_kobj);\n\treturn error;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":224572,"func":"Status QuantizeV2Shape(InferenceContext* c) {\n  int axis = -1;\n  Status s = c->GetAttr(\"axis\", &axis);\n  if (!s.ok() && s.code() != error::NOT_FOUND) {\n    return s;\n  }\n  if (axis < -1) {\n    return errors::InvalidArgument(\"axis should be at least -1, got \", axis);\n  }\n  const int minmax_rank = (axis == -1) ? 0 : 1;\n  TF_RETURN_IF_ERROR(shape_inference::UnchangedShape(c));\n  ShapeHandle minmax;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(1), minmax_rank, &minmax));\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(2), minmax_rank, &minmax));\n  if (axis != -1) {\n    ShapeHandle input;\n    TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input));\n    DimensionHandle depth;\n    TF_RETURN_IF_ERROR(\n        c->Merge(c->Dim(minmax, 0), c->Dim(input, axis), &depth));\n  }\n  c->set_output(1, minmax);\n  c->set_output(2, minmax);\n  return Status::OK();\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":256459,"func":"JANET_CORE_FN(cfun_array_remove,\n              \"(array\/remove arr at &opt n)\",\n              \"Remove up to `n` elements starting at index `at` in array `arr`. `at` can index from \"\n              \"the end of the array with a negative index, and `n` must be a non-negative integer. \"\n              \"By default, `n` is 1. \"\n              \"Returns the array.\") {\n    janet_arity(argc, 2, 3);\n    JanetArray *array = janet_getarray(argv, 0);\n    int32_t at = janet_getinteger(argv, 1);\n    int32_t n = 1;\n    if (at < 0) {\n        at = array->count + at + 1;\n    }\n    if (at < 0 || at > array->count)\n        janet_panicf(\"removal index %d out of range [0,%d]\", at, array->count);\n    if (argc == 3) {\n        n = janet_getinteger(argv, 2);\n        if (n < 0)\n            janet_panicf(\"expected non-negative integer for argument n, got %v\", argv[2]);\n    }\n    if (at + n > array->count) {\n        n = array->count - at;\n    }\n    memmove(array->data + at,\n            array->data + at + n,\n            (array->count - at - n) * sizeof(Janet));\n    array->count -= n;\n    return argv[0];\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":201913,"func":"set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,\n    mode_t mode, unsigned long set, unsigned long clear)\n{\n\tint\t\t ret;\n\tint\t\t myfd = fd;\n\tint newflags, oldflags;\n\t\/*\n\t * Linux has no define for the flags that are only settable by\n\t * the root user.  This code may seem a little complex, but\n\t * there seem to be some Linux systems that lack these\n\t * defines. (?)  The code below degrades reasonably gracefully\n\t * if sf_mask is incomplete.\n\t *\/\n\tconst int sf_mask = 0\n#if defined(FS_IMMUTABLE_FL)\n\t    | FS_IMMUTABLE_FL\n#elif defined(EXT2_IMMUTABLE_FL)\n\t    | EXT2_IMMUTABLE_FL\n#endif\n#if defined(FS_APPEND_FL)\n\t    | FS_APPEND_FL\n#elif defined(EXT2_APPEND_FL)\n\t    | EXT2_APPEND_FL\n#endif\n#if defined(FS_JOURNAL_DATA_FL)\n\t    | FS_JOURNAL_DATA_FL\n#endif\n\t;\n\n\tif (set == 0 && clear == 0)\n\t\treturn (ARCHIVE_OK);\n\t\/* Only regular files and dirs can have flags. *\/\n\tif (!S_ISREG(mode) && !S_ISDIR(mode))\n\t\treturn (ARCHIVE_OK);\n\n\t\/* If we weren't given an fd, open it ourselves. *\/\n\tif (myfd < 0) {\n\t\tmyfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY | O_CLOEXEC);\n\t\t__archive_ensure_cloexec_flag(myfd);\n\t}\n\tif (myfd < 0)\n\t\treturn (ARCHIVE_OK);\n\n\t\/*\n\t * XXX As above, this would be way simpler if we didn't have\n\t * to read the current flags from disk. XXX\n\t *\/\n\tret = ARCHIVE_OK;\n\n\t\/* Read the current file flags. *\/\n\tif (ioctl(myfd,\n#ifdef FS_IOC_GETFLAGS\n\t    FS_IOC_GETFLAGS,\n#else\n\t    EXT2_IOC_GETFLAGS,\n#endif\n\t    &oldflags) < 0)\n\t\tgoto fail;\n\n\t\/* Try setting the flags as given. *\/\n\tnewflags = (oldflags & ~clear) | set;\n\tif (ioctl(myfd,\n#ifdef FS_IOC_SETFLAGS\n\t    FS_IOC_SETFLAGS,\n#else\n\t    EXT2_IOC_SETFLAGS,\n#endif\n\t    &newflags) >= 0)\n\t\tgoto cleanup;\n\tif (errno != EPERM)\n\t\tgoto fail;\n\n\t\/* If we couldn't set all the flags, try again with a subset. *\/\n\tnewflags &= ~sf_mask;\n\toldflags &= sf_mask;\n\tnewflags |= oldflags;\n\tif (ioctl(myfd,\n#ifdef FS_IOC_SETFLAGS\n\t    FS_IOC_SETFLAGS,\n#else\n\t    EXT2_IOC_SETFLAGS,\n#endif\n\t    &newflags) >= 0)\n\t\tgoto cleanup;\n\n\t\/* We couldn't set the flags, so report the failure. *\/\nfail:\n\tarchive_set_error(&a->archive, errno,\n\t    \"Failed to set file flags\");\n\tret = ARCHIVE_WARN;\ncleanup:\n\tif (fd < 0)\n\t\tclose(myfd);\n\treturn (ret);\n}","target":1,"code_token_length":655,"total_token_length":891,"max_tokens_setting":1024}
+{"idx":310045,"func":"decode_tabs(const char *tab_list)\n{\n    int *result = typeCalloc(int, strlen(tab_list) + (unsigned) max_cols);\n    int n = 0;\n    int value = 0;\n    int prior = 0;\n    int ch;\n\n    if (result == 0)\n\tfailed(\"decode_tabs\");\n\n    while ((ch = *tab_list++) != '\\0') {\n\tif (isdigit(UChar(ch))) {\n\t    value *= 10;\n\t    value += (ch - '0');\n\t} else if (ch == ',') {\n\t    result[n] = value + prior;\n\t    if (n > 0 && result[n] <= result[n - 1]) {\n\t\tfprintf(stderr,\n\t\t\t\"%s: tab-stops are not in increasing order: %d %d\\n\",\n\t\t\t_nc_progname, value, result[n - 1]);\n\t\tfree(result);\n\t\tresult = 0;\n\t\tbreak;\n\t    }\n\t    ++n;\n\t    value = 0;\n\t    prior = 0;\n\t} else if (ch == '+') {\n\t    if (n)\n\t\tprior = result[n - 1];\n\t}\n    }\n\n    if (result != 0) {\n\t\/*\n\t * If there is only one value, then it is an option such as \"-8\".\n\t *\/\n\tif ((n == 0) && (value > 0)) {\n\t    int step = value;\n\t    value = 1;\n\t    while (n < max_cols - 1) {\n\t\tresult[n++] = value;\n\t\tvalue += step;\n\t    }\n\t}\n\n\t\/*\n\t * Add the last value, if any.\n\t *\/\n\tresult[n++] = value + prior;\n\tresult[n] = 0;\n    }\n\n    return result;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":476142,"func":"static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf)\n{\n\tstruct usb_function *f;\n\tstruct usb_os_desc *d;\n\tstruct usb_os_desc_ext_prop *ext_prop;\n\tint j, count, n, ret;\n\n\tf = c->interface[interface];\n\tcount = 10; \/* header length *\/\n\tbuf += 10;\n\tfor (j = 0; j < f->os_desc_n; ++j) {\n\t\tif (interface != f->os_desc_table[j].if_id)\n\t\t\tcontinue;\n\t\td = f->os_desc_table[j].os_desc;\n\t\tif (d)\n\t\t\tlist_for_each_entry(ext_prop, &d->ext_prop, entry) {\n\t\t\t\tn = ext_prop->data_len +\n\t\t\t\t\text_prop->name_len + 14;\n\t\t\t\tif (count + n >= USB_COMP_EP0_OS_DESC_BUFSIZ)\n\t\t\t\t\treturn count;\n\t\t\t\tusb_ext_prop_put_size(buf, n);\n\t\t\t\tusb_ext_prop_put_type(buf, ext_prop->type);\n\t\t\t\tret = usb_ext_prop_put_name(buf, ext_prop->name,\n\t\t\t\t\t\t\t    ext_prop->name_len);\n\t\t\t\tif (ret < 0)\n\t\t\t\t\treturn ret;\n\t\t\t\tswitch (ext_prop->type) {\n\t\t\t\tcase USB_EXT_PROP_UNICODE:\n\t\t\t\tcase USB_EXT_PROP_UNICODE_ENV:\n\t\t\t\tcase USB_EXT_PROP_UNICODE_LINK:\n\t\t\t\t\tusb_ext_prop_put_unicode(buf, ret,\n\t\t\t\t\t\t\t ext_prop->data,\n\t\t\t\t\t\t\t ext_prop->data_len);\n\t\t\t\t\tbreak;\n\t\t\t\tcase USB_EXT_PROP_BINARY:\n\t\t\t\t\tusb_ext_prop_put_binary(buf, ret,\n\t\t\t\t\t\t\text_prop->data,\n\t\t\t\t\t\t\text_prop->data_len);\n\t\t\t\t\tbreak;\n\t\t\t\tcase USB_EXT_PROP_LE32:\n\t\t\t\t\t\/* not implemented *\/\n\t\t\t\tcase USB_EXT_PROP_BE32:\n\t\t\t\t\t\/* not implemented *\/\n\t\t\t\tdefault:\n\t\t\t\t\treturn -EINVAL;\n\t\t\t\t}\n\t\t\t\tbuf += n;\n\t\t\t\tcount += n;\n\t\t\t}\n\t}\n\n\treturn count;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":346431,"func":"cmd_source(char_u *fname, exarg_T *eap)\n{\n    int clearvars = FALSE;\n\n    if (*fname != NUL && STRNCMP(fname, \"++clear\", 7) == 0)\n    {\n\t\/\/ ++clear argument is supplied\n\tclearvars = TRUE;\n\tfname = fname + 7;\n\tif (*fname != NUL)\n\t{\n\t    semsg(_(e_invalid_argument_str), eap->arg);\n\t    return;\n\t}\n    }\n\n    if (*fname != NUL && eap != NULL && eap->addr_count > 0)\n    {\n\t\/\/ if a filename is specified to :source, then a range is not allowed\n\temsg(_(e_no_range_allowed));\n\treturn;\n    }\n\n    if (eap != NULL && *fname == NUL)\n    {\n\tif (eap->forceit)\n\t    \/\/ a file name is needed to source normal mode commands\n\t    emsg(_(e_argument_required));\n\telse\n\t    \/\/ source ex commands from the current buffer\n\t    do_source_ext(NULL, FALSE, FALSE, NULL, eap, clearvars);\n    }\n    else if (eap != NULL && eap->forceit)\n\t\/\/ \":source!\": read Normal mode commands\n\t\/\/ Need to execute the commands directly.  This is required at least\n\t\/\/ for:\n\t\/\/ - \":g\" command busy\n\t\/\/ - after \":argdo\", \":windo\" or \":bufdo\"\n\t\/\/ - another command follows\n\t\/\/ - inside a loop\n\topenscript(fname, global_busy || listcmd_busy || eap->nextcmd != NULL\n#ifdef FEAT_EVAL\n\t\t\t\t\t\t || eap->cstack->cs_idx >= 0\n#endif\n\t\t\t\t\t\t );\n\n    \/\/ \":source\" read ex commands\n    else if (do_source(fname, FALSE, DOSO_NONE, NULL) == FAIL)\n\tsemsg(_(e_cant_open_file_str), fname);\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":274629,"func":"cupsdInitCerts(void)\n{\n#ifndef HAVE_ARC4RANDOM\n  cups_file_t\t*fp;\t\t\t\/* \/dev\/random file *\/\n\n\n \/*\n  * Initialize the random number generator using the random device or\n  * the current time, as available...\n  *\/\n\n  if ((fp = cupsFileOpen(\"\/dev\/urandom\", \"rb\")) == NULL)\n  {\n    struct timeval tod;\t\t\t\/* Time of day *\/\n\n   \/*\n    * Get the time in usecs and use it as the initial seed...\n    *\/\n\n    gettimeofday(&tod, NULL);\n\n    CUPS_SRAND((unsigned)(tod.tv_sec + tod.tv_usec));\n  }\n  else\n  {\n    unsigned\tseed;\t\t\t\/* Seed for random number generator *\/\n\n   \/*\n    * Read 4 random characters from the random device and use\n    * them as the seed...\n    *\/\n\n    seed = (unsigned)cupsFileGetChar(fp);\n    seed = (seed << 8) | (unsigned)cupsFileGetChar(fp);\n    seed = (seed << 8) | (unsigned)cupsFileGetChar(fp);\n    CUPS_SRAND((seed << 8) | (unsigned)cupsFileGetChar(fp));\n\n    cupsFileClose(fp);\n  }\n#endif \/* !HAVE_ARC4RANDOM *\/\n\n \/*\n  * Create a root certificate and return...\n  *\/\n\n  if (!RunUser)\n    cupsdAddCert(0, \"root\", cupsdDefaultAuthType());\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":229245,"func":"future<fragmented_temporary_buffer> cql_server::connection::read_and_decompress_frame(size_t length, uint8_t flags)\n{\n    using namespace compression_buffers;\n    if (flags & cql_frame_flags::compression) {\n        if (_compression == cql_compression::lz4) {\n            if (length < 4) {\n                throw std::runtime_error(fmt::format(\"CQL frame truncated: expected to have at least 4 bytes, got {}\", length));\n            }\n            return _buffer_reader.read_exactly(_read_buf, length).then([this] (fragmented_temporary_buffer buf) {\n                auto linearization_buffer = bytes_ostream();\n                int32_t uncomp_len = request_reader(buf.get_istream(), linearization_buffer).read_int();\n                if (uncomp_len < 0) {\n                    throw std::runtime_error(\"CQL frame uncompressed length is negative: \" + std::to_string(uncomp_len));\n                }\n                buf.remove_prefix(4);\n                auto in = input_buffer.get_linearized_view(fragmented_temporary_buffer::view(buf));\n                auto uncomp = output_buffer.make_fragmented_temporary_buffer(uncomp_len, fragmented_temporary_buffer::default_fragment_size, [&] (bytes_mutable_view out) {\n                    auto ret = LZ4_decompress_safe(reinterpret_cast<const char*>(in.data()), reinterpret_cast<char*>(out.data()),\n                                                   in.size(), out.size());\n                    if (ret < 0) {\n                        throw std::runtime_error(\"CQL frame LZ4 uncompression failure\");\n                    }\n                    if (ret != out.size()) {\n                        throw std::runtime_error(\"Malformed CQL frame - provided uncompressed size different than real uncompressed size\");\n                    }\n                    return static_cast<size_t>(ret);\n                });\n                on_compression_buffer_use();\n                return uncomp;\n            });\n        } else if (_compression == cql_compression::snappy) {\n            return _buffer_reader.read_exactly(_read_buf, length).then([this] (fragmented_temporary_buffer buf) {\n                auto in = input_buffer.get_linearized_view(fragmented_temporary_buffer::view(buf));\n                size_t uncomp_len;\n                if (snappy_uncompressed_length(reinterpret_cast<const char*>(in.data()), in.size(), &uncomp_len) != SNAPPY_OK) {\n                    throw std::runtime_error(\"CQL frame Snappy uncompressed size is unknown\");\n                }\n                auto uncomp = output_buffer.make_fragmented_temporary_buffer(uncomp_len, fragmented_temporary_buffer::default_fragment_size, [&] (bytes_mutable_view out) {\n                    size_t output_len = out.size();\n                    if (snappy_uncompress(reinterpret_cast<const char*>(in.data()), in.size(), reinterpret_cast<char*>(out.data()), &output_len) != SNAPPY_OK) {\n                        throw std::runtime_error(\"CQL frame Snappy uncompression failure\");\n                    }\n                    return output_len;\n                });\n                on_compression_buffer_use();\n                return uncomp;\n            });\n        } else {\n            throw exceptions::protocol_exception(format(\"Unknown compression algorithm\"));\n        }\n    }\n    return _buffer_reader.read_exactly(_read_buf, length);\n}","target":0,"code_token_length":645,"total_token_length":881,"max_tokens_setting":1024}
+{"idx":233862,"func":"void fmtutil_macbitmap_read_pixmap_only_fields(deark *c, dbuf *f, struct fmtutil_macbitmap_info *bi,\n\ti64 pos)\n{\n\ti64 pixmap_version;\n\ti64 pack_size;\n\ti64 plane_bytes;\n\ti64 n;\n\n\tde_dbg(c, \"additional PixMap header fields, at %d\", (int)pos);\n\tde_dbg_indent(c, 1);\n\n\tpixmap_version = dbuf_getu16be(f, pos+0);\n\tde_dbg(c, \"pixmap version: %d\", (int)pixmap_version);\n\n\tbi->packing_type = dbuf_getu16be(f, pos+2);\n\tde_dbg(c, \"packing type: %d\", (int)bi->packing_type);\n\n\tpack_size = dbuf_getu32be(f, pos+4);\n\tde_dbg(c, \"pixel data length: %d\", (int)pack_size);\n\n\tbi->hdpi = pict_read_fixed(f, pos+8);\n\tbi->vdpi = pict_read_fixed(f, pos+12);\n\tde_dbg(c, \"dpi: %.2f\"DE_CHAR_TIMES\"%.2f\", bi->hdpi, bi->vdpi);\n\n\tbi->pixeltype = dbuf_getu16be(f, pos+16);\n\tbi->pixelsize = dbuf_getu16be(f, pos+18);\n\tbi->cmpcount = dbuf_getu16be(f, pos+20);\n\tbi->cmpsize = dbuf_getu16be(f, pos+22);\n\tde_dbg(c, \"pixel type=%d, bits\/pixel=%d, components\/pixel=%d, bits\/comp=%d\",\n\t\t(int)bi->pixeltype, (int)bi->pixelsize, (int)bi->cmpcount, (int)bi->cmpsize);\n\n\tif(bi->pixelsize>0) {\n\t\tbi->pdwidth = (bi->rowbytes*8)\/bi->pixelsize;\n\t}\n\tif(bi->pdwidth < bi->npwidth) {\n\t\tbi->pdwidth = bi->npwidth;\n\t}\n\n\tplane_bytes = dbuf_getu32be(f, pos+24);\n\tde_dbg(c, \"plane bytes: %d\", (int)plane_bytes);\n\n\tbi->pmTable = (u32)dbuf_getu32be(f, pos+28);\n\tde_dbg(c, \"pmTable: 0x%08x\", (unsigned int)bi->pmTable);\n\n\tn = dbuf_getu32be(f, pos+32);\n\tde_dbg(c, \"pmReserved: 0x%08x\", (unsigned int)n);\n\n\tde_dbg_indent(c, -1);\n}","target":0,"code_token_length":584,"total_token_length":820,"max_tokens_setting":1024}
+{"idx":309845,"func":"_nc_mouse_inline(SCREEN *sp)\n\/* mouse report received in the keyboard stream -- parse its info *\/\n{\n    bool result = FALSE;\n    MEVENT *eventp = sp->_mouse_eventp;\n\n    TR(MY_TRACE, (\"_nc_mouse_inline() called\"));\n\n    if (sp->_mouse_type == M_XTERM) {\n\tswitch (sp->_mouse_format) {\n\tcase MF_X10:\n\t    result = decode_xterm_X10(sp, eventp);\n\t    break;\n\tcase MF_SGR1006:\n\t    result = decode_xterm_SGR1006(sp, eventp);\n\t    break;\n#ifdef EXP_XTERM_1005\n\tcase MF_XTERM_1005:\n\t    result = decode_xterm_1005(sp, eventp);\n\t    break;\n#endif\n\t}\n\n\tTR(MY_TRACE,\n\t   (\"_nc_mouse_inline: primitive mouse-event %s has slot %ld\",\n\t    _nc_tracemouse(sp, eventp),\n\t    (long) IndexEV(sp, eventp)));\n\n\t\/* bump the next-free pointer into the circular list *\/\n\tsp->_mouse_eventp = NEXT(eventp);\n\n\tif (!result) {\n\t    \/* If this event is from a wheel-mouse, treat it like position\n\t     * reports and avoid waiting for the release-events which will\n\t     * never come.\n\t     *\/\n\t    if (eventp->bstate & BUTTON_PRESSED) {\n\t\tint b;\n\n\t\tfor (b = 4; b <= MAX_BUTTONS; ++b) {\n\t\t    if ((eventp->bstate & MASK_PRESS(b))) {\n\t\t\tresult = TRUE;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n\n    return (result);\n}","target":0,"code_token_length":355,"total_token_length":591,"max_tokens_setting":1024}
+{"idx":339725,"func":"static Bigint * multadd(Bigint *b, int m, int a) \/* multiply by m and add a *\/\n{\n\tint i, wds;\n\tULong *x, y;\n#ifdef Pack_32\n\tULong xi, z;\n#endif\n\tBigint *b1;\n\n\twds = b->wds;\n\tx = b->x;\n\ti = 0;\n\tdo {\n#ifdef Pack_32\n\t\txi = *x;\n\t\ty = (xi & 0xffff) * m + a;\n\t\tz = (xi >> 16) * m + (y >> 16);\n\t\ta = (int)(z >> 16);\n\t\t*x++ = (z << 16) + (y & 0xffff);\n#else\n\t\ty = *x * m + a;\n\t\ta = (int)(y >> 16);\n\t\t*x++ = y & 0xffff;\n#endif\n\t}\n\twhile(++i < wds);\n\tif (a) {\n\t\tif (wds >= b->maxwds) {\n\t\t\tb1 = Balloc(b->k+1);\n\t\t\tBcopy(b1, b);\n\t\t\tBfree(b);\n\t\t\tb = b1;\n\t\t}\n\t\tb->x[wds++] = a;\n\t\tb->wds = wds;\n\t}\n\treturn b;\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":95905,"func":"void AddUninstallShortcutWorkItems(const InstallerState& installer_state,\n                                   const FilePath& setup_path,\n                                   const Version& new_version,\n                                   WorkItemList* install_list,\n                                   const Product& product) {\n  HKEY reg_root = installer_state.root_key();\n  BrowserDistribution* browser_dist = product.distribution();\n  DCHECK(browser_dist);\n\n  FilePath install_path(installer_state.target_path());\n  FilePath installer_path(installer_state.GetInstallerDirectory(new_version));\n  installer_path = installer_path.Append(setup_path.BaseName());\n\n  CommandLine uninstall_arguments(CommandLine::NO_PROGRAM);\n  AppendUninstallCommandLineFlags(installer_state, product,\n                                  &uninstall_arguments);\n\n  if (product.is_chrome() &&\n      installer_state.operation() != InstallerState::UNINSTALL) {\n    const Products& products = installer_state.products();\n    for (size_t i = 0; i < products.size(); ++i) {\n      const Product& p = *products[i];\n      if (!p.is_chrome() && !p.ShouldCreateUninstallEntry())\n        p.AppendUninstallFlags(&uninstall_arguments);\n    }\n  }\n\n  std::wstring update_state_key(browser_dist->GetStateKey());\n  install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key);\n  install_list->AddSetRegValueWorkItem(reg_root, update_state_key,\n      installer::kUninstallStringField, installer_path.value(), true);\n  install_list->AddSetRegValueWorkItem(reg_root, update_state_key,\n      installer::kUninstallArgumentsField,\n      uninstall_arguments.command_line_string(), true);\n\n  if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) {\n    CommandLine quoted_uninstall_cmd(installer_path);\n    DCHECK_EQ(quoted_uninstall_cmd.command_line_string()[0], '\"');\n    quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false);\n\n    std::wstring uninstall_reg = browser_dist->GetUninstallRegPath();\n    install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg);\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n        installer::kUninstallDisplayNameField,\n        browser_dist->GetAppShortCutName(), true);\n    install_list->AddSetRegValueWorkItem(reg_root,\n        uninstall_reg, installer::kUninstallStringField,\n        quoted_uninstall_cmd.command_line_string(), true);\n    install_list->AddSetRegValueWorkItem(reg_root,\n                                         uninstall_reg,\n                                         L\"InstallLocation\",\n                                         install_path.value(),\n                                         true);\n\n    FilePath chrome_icon(install_path.Append(installer::kChromeExe));\n    ShellUtil::GetChromeIcon(product.distribution(), chrome_icon.value());\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"DisplayIcon\", chrome_icon.value(),\n                                         true);\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"NoModify\", static_cast<DWORD>(1),\n                                         true);\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"NoRepair\", static_cast<DWORD>(1),\n                                         true);\n\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"Publisher\",\n                                         browser_dist->GetPublisherName(),\n                                         true);\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"Version\",\n                                         UTF8ToWide(new_version.GetString()),\n                                         true);\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"DisplayVersion\",\n                                         UTF8ToWide(new_version.GetString()),\n                                         true);\n    install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,\n                                         L\"InstallDate\",\n                                         InstallUtil::GetCurrentDate(),\n                                         false);\n  }\n}\n","target":0,"code_token_length":773,"total_token_length":1009,"max_tokens_setting":1024}
+{"idx":329876,"func":"_blit_xrgb32_lerp_spans (void *abstract_renderer, int y, int h,\n\t\t\t const cairo_half_open_span_t *spans, unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (likely(h == 1)) {\n\tuint8_t *src = r->u.blit.src_data + y*r->u.blit.src_stride;\n\tuint8_t *dst = r->u.blit.data + y*r->u.blit.stride;\n\tdo {\n\t    uint8_t a = mul8_8 (spans[0].coverage, r->bpp);\n\t    if (a) {\n\t\tuint32_t *s = (uint32_t*)src + spans[0].x;\n\t\tuint32_t *d = (uint32_t*)dst + spans[0].x;\n\t\tint len = spans[1].x - spans[0].x;\n\t\tif (a == 0xff) {\n\t\t    if (len == 1)\n\t\t\t*d = *s;\n\t\t    else\n\t\t\tmemcpy(d, s, len*4);\n\t\t} else {\n\t\t    while (len-- > 0) {\n\t\t\t*d = lerp8x4 (*s, a, *d);\n\t\t\ts++, d++;\n\t\t    }\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    } else {\n\tdo {\n\t    uint8_t a = mul8_8 (spans[0].coverage, r->bpp);\n\t    if (a) {\n\t\tint yy = y, hh = h;\n\t\tdo {\n\t\t    uint32_t *s = (uint32_t *)(r->u.blit.src_data + yy*r->u.blit.src_stride + spans[0].x * 4);\n\t\t    uint32_t *d = (uint32_t *)(r->u.blit.data + yy*r->u.blit.stride + spans[0].x * 4);\n\t\t    int len = spans[1].x - spans[0].x;\n\t\t    if (a == 0xff) {\n\t\t\tif (len == 1)\n\t\t\t    *d = *s;\n\t\t\telse\n\t\t\t    memcpy(d, s, len * 4);\n\t\t    } else {\n\t\t\twhile (len-- > 0) {\n\t\t\t    *d = lerp8x4 (*s, a, *d);\n\t\t\t    s++, d++;\n\t\t\t}\n\t\t    }\n\t\t    yy++;\n\t\t} while (--hh);\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":482529,"func":"passGetAttributes(CharsString *passLine, int *passLinepos,\n\t\tTranslationTableCharacterAttributes *attributes, const FileInfo *file) {\n\tint more = 1;\n\t*attributes = 0;\n\twhile (more) {\n\t\tswitch (passLine->chars[*passLinepos]) {\n\t\tcase pass_any:\n\t\t\t*attributes = 0xffffffff;\n\t\t\tbreak;\n\t\tcase pass_digit:\n\t\t\t*attributes |= CTC_Digit;\n\t\t\tbreak;\n\t\tcase pass_litDigit:\n\t\t\t*attributes |= CTC_LitDigit;\n\t\t\tbreak;\n\t\tcase pass_letter:\n\t\t\t*attributes |= CTC_Letter;\n\t\t\tbreak;\n\t\tcase pass_math:\n\t\t\t*attributes |= CTC_Math;\n\t\t\tbreak;\n\t\tcase pass_punctuation:\n\t\t\t*attributes |= CTC_Punctuation;\n\t\t\tbreak;\n\t\tcase pass_sign:\n\t\t\t*attributes |= CTC_Sign;\n\t\t\tbreak;\n\t\tcase pass_space:\n\t\t\t*attributes |= CTC_Space;\n\t\t\tbreak;\n\t\tcase pass_uppercase:\n\t\t\t*attributes |= CTC_UpperCase;\n\t\t\tbreak;\n\t\tcase pass_lowercase:\n\t\t\t*attributes |= CTC_LowerCase;\n\t\t\tbreak;\n\t\tcase pass_class1:\n\t\t\t*attributes |= CTC_UserDefined9;\n\t\t\tbreak;\n\t\tcase pass_class2:\n\t\t\t*attributes |= CTC_UserDefined10;\n\t\t\tbreak;\n\t\tcase pass_class3:\n\t\t\t*attributes |= CTC_UserDefined11;\n\t\t\tbreak;\n\t\tcase pass_class4:\n\t\t\t*attributes |= CTC_UserDefined12;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmore = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (more) (*passLinepos)++;\n\t}\n\tif (!*attributes) {\n\t\tcompileError(file, \"missing attribute\");\n\t\t(*passLinepos)--;\n\t\treturn 0;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":310146,"func":"scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank)\n{\n    int i;\n\n    if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))\n\treturn ERR;\n\n    GoTo(NCURSES_SP_ARGx del, 0);\n    UpdateAttrs(SP_PARM, blank);\n    if (n == 1 && delete_line) {\n\tNCURSES_PUTP2(\"delete_line\", delete_line);\n    } else if (parm_delete_line) {\n\tTPUTS_TRACE(\"parm_delete_line\");\n\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\tTIPARM_1(parm_delete_line, n),\n\t\t\t\tn,\n\t\t\t\tNCURSES_SP_NAME(_nc_outch));\n    } else {\t\t\t\/* if (delete_line) *\/\n\tfor (i = 0; i < n; i++) {\n\t    NCURSES_PUTP2(\"delete_line\", delete_line);\n\t}\n    }\n\n    GoTo(NCURSES_SP_ARGx ins, 0);\n    UpdateAttrs(SP_PARM, blank);\n    if (n == 1 && insert_line) {\n\tNCURSES_PUTP2(\"insert_line\", insert_line);\n    } else if (parm_insert_line) {\n\tTPUTS_TRACE(\"parm_insert_line\");\n\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\tTIPARM_1(parm_insert_line, n),\n\t\t\t\tn,\n\t\t\t\tNCURSES_SP_NAME(_nc_outch));\n    } else {\t\t\t\/* if (insert_line) *\/\n\tfor (i = 0; i < n; i++) {\n\t    NCURSES_PUTP2(\"insert_line\", insert_line);\n\t}\n    }\n\n    return OK;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":466132,"func":"static int em_sysexit(struct x86_emulate_ctxt *ctxt)\n{\n\tstruct x86_emulate_ops *ops = ctxt->ops;\n\tstruct desc_struct cs, ss;\n\tu64 msr_data;\n\tint usermode;\n\tu16 cs_sel = 0, ss_sel = 0;\n\n\t\/* inject #GP if in real mode or Virtual 8086 mode *\/\n\tif (ctxt->mode == X86EMUL_MODE_REAL ||\n\t    ctxt->mode == X86EMUL_MODE_VM86)\n\t\treturn emulate_gp(ctxt, 0);\n\n\tsetup_syscalls_segments(ctxt, &cs, &ss);\n\n\tif ((ctxt->rex_prefix & 0x8) != 0x0)\n\t\tusermode = X86EMUL_MODE_PROT64;\n\telse\n\t\tusermode = X86EMUL_MODE_PROT32;\n\n\tcs.dpl = 3;\n\tss.dpl = 3;\n\tops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data);\n\tswitch (usermode) {\n\tcase X86EMUL_MODE_PROT32:\n\t\tcs_sel = (u16)(msr_data + 16);\n\t\tif ((msr_data & 0xfffc) == 0x0)\n\t\t\treturn emulate_gp(ctxt, 0);\n\t\tss_sel = (u16)(msr_data + 24);\n\t\tbreak;\n\tcase X86EMUL_MODE_PROT64:\n\t\tcs_sel = (u16)(msr_data + 32);\n\t\tif (msr_data == 0x0)\n\t\t\treturn emulate_gp(ctxt, 0);\n\t\tss_sel = cs_sel + 8;\n\t\tcs.d = 0;\n\t\tcs.l = 1;\n\t\tbreak;\n\t}\n\tcs_sel |= SELECTOR_RPL_MASK;\n\tss_sel |= SELECTOR_RPL_MASK;\n\n\tops->set_segment(ctxt, cs_sel, &cs, 0, VCPU_SREG_CS);\n\tops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS);\n\n\tctxt->_eip = ctxt->regs[VCPU_REGS_RDX];\n\tctxt->regs[VCPU_REGS_RSP] = ctxt->regs[VCPU_REGS_RCX];\n\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":473941,"func":"set_optimize_exact_info(regex_t* reg, OptExactInfo* e)\n{\n  int r;\n\n  if (e->len == 0) return 0;\n\n  if (e->ignore_case) {\n    reg->exact = (UChar* )xmalloc(e->len);\n    CHECK_NULL_RETURN_MEMERR(reg->exact);\n    xmemcpy(reg->exact, e->s, e->len);\n    reg->exact_end = reg->exact + e->len;\n    reg->optimize = ONIG_OPTIMIZE_EXACT_IC;\n  }\n  else {\n    int allow_reverse;\n\n    reg->exact = str_dup(e->s, e->s + e->len);\n    CHECK_NULL_RETURN_MEMERR(reg->exact);\n    reg->exact_end = reg->exact + e->len;\n\n    allow_reverse =\n\tONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);\n\n    if (e->len >= 3 || (e->len >= 2 && allow_reverse)) {\n      r = set_bm_skip(reg->exact, reg->exact_end, reg->enc,\n\t              reg->map, &(reg->int_map));\n      if (r) return r;\n\n      reg->optimize = (allow_reverse != 0\n\t\t       ? ONIG_OPTIMIZE_EXACT_BM : ONIG_OPTIMIZE_EXACT_BM_NOT_REV);\n    }\n    else {\n      reg->optimize = ONIG_OPTIMIZE_EXACT;\n    }\n  }\n\n  reg->dmin = e->mmd.min;\n  reg->dmax = e->mmd.max;\n\n  if (reg->dmin != ONIG_INFINITE_DISTANCE) {\n    reg->threshold_len = (int)(reg->dmin + (reg->exact_end - reg->exact));\n  }\n\n  return 0;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":437408,"func":"vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,\n\t\t\t   int main_fd __rte_unused)\n{\n\tuint64_t mmap_size, mmap_offset;\n\tuint16_t num_queues, queue_size;\n\tuint32_t pervq_inflight_size;\n\tstruct virtio_net *dev = *pdev;\n\tvoid *addr;\n\tint fd;\n\n\tfd = msg->fds[0];\n\tif (msg->size != sizeof(msg->payload.inflight) || fd < 0) {\n\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\"invalid set_inflight_fd message size is %d,fd is %d\\n\",\n\t\t\tmsg->size, fd);\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tmmap_size = msg->payload.inflight.mmap_size;\n\tmmap_offset = msg->payload.inflight.mmap_offset;\n\tnum_queues = msg->payload.inflight.num_queues;\n\tqueue_size = msg->payload.inflight.queue_size;\n\n\tif (vq_is_packed(dev))\n\t\tpervq_inflight_size = get_pervq_shm_size_packed(queue_size);\n\telse\n\t\tpervq_inflight_size = get_pervq_shm_size_split(queue_size);\n\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"set_inflight_fd mmap_size: %\"PRIu64\"\\n\", mmap_size);\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"set_inflight_fd mmap_offset: %\"PRIu64\"\\n\", mmap_offset);\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"set_inflight_fd num_queues: %u\\n\", num_queues);\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"set_inflight_fd queue_size: %u\\n\", queue_size);\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"set_inflight_fd fd: %d\\n\", fd);\n\tRTE_LOG(INFO, VHOST_CONFIG,\n\t\t\"set_inflight_fd pervq_inflight_size: %d\\n\",\n\t\tpervq_inflight_size);\n\n\tif (!dev->inflight_info) {\n\t\tdev->inflight_info = calloc(1,\n\t\t\t\t\t    sizeof(struct inflight_mem_info));\n\t\tif (dev->inflight_info == NULL) {\n\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n\t\t\t\t\"failed to alloc dev inflight area\\n\");\n\t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t\t}\n\t}\n\n\tif (dev->inflight_info->addr)\n\t\tmunmap(dev->inflight_info->addr, dev->inflight_info->size);\n\n\taddr = mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,\n\t\t    fd, mmap_offset);\n\tif (addr == MAP_FAILED) {\n\t\tRTE_LOG(ERR, VHOST_CONFIG, \"failed to mmap share memory.\\n\");\n\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n\t}\n\n\tif (dev->inflight_info->fd)\n\t\tclose(dev->inflight_info->fd);\n\n\tdev->inflight_info->fd = fd;\n\tdev->inflight_info->addr = addr;\n\tdev->inflight_info->size = mmap_size;\n\n\treturn RTE_VHOST_MSG_RESULT_OK;\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":436040,"func":"static int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_async_msghdr iomsg, *kmsg;\n\tstruct socket *sock;\n\tunsigned flags;\n\tint min_ret = 0;\n\tint ret;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tkmsg = req->async_data;\n\tif (!kmsg) {\n\t\tret = io_sendmsg_copy_hdr(req, &iomsg);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tkmsg = &iomsg;\n\t}\n\n\tflags = req->sr_msg.msg_flags;\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\tflags |= MSG_DONTWAIT;\n\tif (flags & MSG_WAITALL)\n\t\tmin_ret = iov_iter_count(&kmsg->msg.msg_iter);\n\n\tret = __sys_sendmsg_sock(sock, &kmsg->msg, flags);\n\tif ((issue_flags & IO_URING_F_NONBLOCK) && ret == -EAGAIN)\n\t\treturn io_setup_async_msg(req, kmsg);\n\tif (ret == -ERESTARTSYS)\n\t\tret = -EINTR;\n\n\t\/* fast path, check for non-NULL to avoid function call *\/\n\tif (kmsg->free_iov)\n\t\tkfree(kmsg->free_iov);\n\treq->flags &= ~REQ_F_NEED_CLEANUP;\n\tif (ret < min_ret)\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":318955,"func":"f_test_gui_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)\n{\n# ifdef FEAT_GUI\n    char_u\t*event;\n\n    rettv->v_type = VAR_BOOL;\n    rettv->vval.v_number = FALSE;\n\n    if (check_for_string_arg(argvars, 0) == FAIL\n\t    || check_for_dict_arg(argvars, 1) == FAIL\n\t    || argvars[1].vval.v_dict == NULL)\n\treturn;\n\n    event = tv_get_string(&argvars[0]);\n    if (STRCMP(event, \"dropfiles\") == 0)\n\trettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict);\n#  if defined(FIND_REPLACE_DIALOG)\n    else if (STRCMP(event, \"findrepl\") == 0)\n\trettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict);\n#  endif\n    else if (STRCMP(event, \"mouse\") == 0)\n\trettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict);\n    else if (STRCMP(event, \"scrollbar\") == 0)\n\trettv->vval.v_number = test_gui_scrollbar(argvars[1].vval.v_dict);\n    else if (STRCMP(event, \"tabline\") == 0)\n\trettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict);\n    else if (STRCMP(event, \"tabmenu\") == 0)\n\trettv->vval.v_number = test_gui_tabmenu_event(argvars[1].vval.v_dict);\n    else\n    {\n\tsemsg(_(e_invalid_argument_str), event);\n\treturn;\n    }\n# endif\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":355627,"func":"eval7t(\n    char_u\t**arg,\n    typval_T\t*rettv,\n    evalarg_T\t*evalarg,\n    int\t\twant_string)\t\/\/ after \".\" operator\n{\n    type_T\t*want_type = NULL;\n    garray_T\ttype_list;\t    \/\/ list of pointers to allocated types\n    int\t\tres;\n    int\t\tevaluate = evalarg == NULL ? 0\n\t\t\t\t       : (evalarg->eval_flags & EVAL_EVALUATE);\n\n    \/\/ Recognize <type> in Vim9 script only.\n    if (in_vim9script() && **arg == '<' && eval_isnamec1((*arg)[1])\n\t\t\t\t\t     && STRNCMP(*arg, \"<SNR>\", 5) != 0)\n    {\n\t++*arg;\n\tga_init2(&type_list, sizeof(type_T *), 10);\n\twant_type = parse_type(arg, &type_list, TRUE);\n\tif (want_type == NULL && (evaluate || **arg != '>'))\n\t{\n\t    clear_type_list(&type_list);\n\t    return FAIL;\n\t}\n\n\tif (**arg != '>')\n\t{\n\t    if (*skipwhite(*arg) == '>')\n\t\tsemsg(_(e_no_white_space_allowed_before_str_str), \">\", *arg);\n\t    else\n\t\temsg(_(e_missing_gt));\n\t    clear_type_list(&type_list);\n\t    return FAIL;\n\t}\n\t++*arg;\n\t*arg = skipwhite_and_linebreak(*arg, evalarg);\n    }\n\n    res = eval7(arg, rettv, evalarg, want_string);\n\n    if (want_type != NULL && evaluate)\n    {\n\tif (res == OK)\n\t{\n\t    type_T *actual = typval2type(rettv, get_copyID(), &type_list,\n\t\t\t\t\t\t\t       TVTT_DO_MEMBER);\n\n\t    if (!equal_type(want_type, actual, 0))\n\t    {\n\t\tif (want_type == &t_bool && actual != &t_bool\n\t\t\t\t\t&& (actual->tt_flags & TTFLAG_BOOL_OK))\n\t\t{\n\t\t    int n = tv2bool(rettv);\n\n\t\t    \/\/ can use \"0\" and \"1\" for boolean in some places\n\t\t    clear_tv(rettv);\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = n ? VVAL_TRUE : VVAL_FALSE;\n\t\t}\n\t\telse\n\t\t{\n\t\t    where_T where = WHERE_INIT;\n\n\t\t    where.wt_variable = TRUE;\n\t\t    res = check_type(want_type, actual, TRUE, where);\n\t\t}\n\t    }\n\t}\n\tclear_type_list(&type_list);\n    }\n\n    return res;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":275940,"func":"static void bits2int(uECC_word_t *native,\n                     const uint8_t *bits,\n                     unsigned bits_size,\n                     uECC_Curve curve) {\n    unsigned num_n_bytes = BITS_TO_BYTES(curve->num_n_bits);\n    unsigned num_n_words = BITS_TO_WORDS(curve->num_n_bits);\n    int shift;\n    uECC_word_t carry;\n    uECC_word_t *ptr;\n\n    if (bits_size > num_n_bytes) {\n        bits_size = num_n_bytes;\n    }\n\n    uECC_vli_clear(native, num_n_words);\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    bcopy((uint8_t *) native, bits, bits_size);\n#else\n    uECC_vli_bytesToNative(native, bits, bits_size);\n#endif\n    if (bits_size * 8 <= (unsigned)curve->num_n_bits) {\n        return;\n    }\n    shift = bits_size * 8 - curve->num_n_bits;\n    carry = 0;\n    ptr = native + num_n_words;\n    while (ptr-- > native) {\n        uECC_word_t temp = *ptr;\n        *ptr = (temp >> shift) | carry;\n        carry = temp << (uECC_WORD_BITS - shift);\n    }\n\n    \/* Reduce mod curve_n *\/\n    if (uECC_vli_cmp_unsafe(curve->n, native, num_n_words) != 1) {\n        uECC_vli_sub(native, native, curve->n, num_n_words);\n    }\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":436136,"func":"static void kiocb_done(struct kiocb *kiocb, ssize_t ret,\n\t\t       unsigned int issue_flags)\n{\n\tstruct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);\n\tstruct io_async_rw *io = req->async_data;\n\tbool check_reissue = kiocb->ki_complete == io_complete_rw;\n\n\t\/* add previously done IO, if any *\/\n\tif (io && io->bytes_done > 0) {\n\t\tif (ret < 0)\n\t\t\tret = io->bytes_done;\n\t\telse\n\t\t\tret += io->bytes_done;\n\t}\n\n\tif (req->flags & REQ_F_CUR_POS)\n\t\treq->file->f_pos = kiocb->ki_pos;\n\tif (ret >= 0 && check_reissue)\n\t\t__io_complete_rw(req, ret, 0, issue_flags);\n\telse\n\t\tio_rw_done(kiocb, ret);\n\n\tif (check_reissue && (req->flags & REQ_F_REISSUE)) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\tif (io_resubmit_prep(req)) {\n\t\t\treq_ref_get(req);\n\t\t\tio_queue_async_work(req);\n\t\t} else {\n\t\t\tint cflags = 0;\n\n\t\t\treq_set_fail(req);\n\t\t\tif (req->flags & REQ_F_BUFFER_SELECTED)\n\t\t\t\tcflags = io_put_rw_kbuf(req);\n\t\t\t__io_req_complete(req, issue_flags, ret, cflags);\n\t\t}\n\t}\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":238786,"func":"show_pat_in_path(\n    char_u  *line,\n    int\t    type,\n    int\t    did_show,\n    int\t    action,\n    FILE    *fp,\n    linenr_T *lnum,\n    long    count)\n{\n    char_u  *p;\n\n    if (did_show)\n\tmsg_putchar('\\n');\t\/\/ cursor below last one\n    else if (!msg_silent)\n\tgotocmdline(TRUE);\t\/\/ cursor at status line\n    if (got_int)\t\t\/\/ 'q' typed at \"--more--\" message\n\treturn;\n    for (;;)\n    {\n\tp = line + STRLEN(line) - 1;\n\tif (fp != NULL)\n\t{\n\t    \/\/ We used fgets(), so get rid of newline at end\n\t    if (p >= line && *p == '\\n')\n\t\t--p;\n\t    if (p >= line && *p == '\\r')\n\t\t--p;\n\t    *(p + 1) = NUL;\n\t}\n\tif (action == ACTION_SHOW_ALL)\n\t{\n\t    sprintf((char *)IObuff, \"%3ld: \", count);\t\/\/ show match nr\n\t    msg_puts((char *)IObuff);\n\t    sprintf((char *)IObuff, \"%4ld\", *lnum);\t\/\/ show line nr\n\t\t\t\t\t\t\/\/ Highlight line numbers\n\t    msg_puts_attr((char *)IObuff, HL_ATTR(HLF_N));\n\t    msg_puts(\" \");\n\t}\n\tmsg_prt_line(line, FALSE);\n\tout_flush();\t\t\t\/\/ show one line at a time\n\n\t\/\/ Definition continues until line that doesn't end with '\\'\n\tif (got_int || type != FIND_DEFINE || p < line || *p != '\\\\')\n\t    break;\n\n\tif (fp != NULL)\n\t{\n\t    if (vim_fgets(line, LSIZE, fp)) \/\/ end of file\n\t\tbreak;\n\t    ++*lnum;\n\t}\n\telse\n\t{\n\t    if (++*lnum > curbuf->b_ml.ml_line_count)\n\t\tbreak;\n\t    line = ml_get(*lnum);\n\t}\n\tmsg_putchar('\\n');\n    }\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":211868,"func":"struct nft_flow_rule *nft_flow_rule_create(struct net *net,\n\t\t\t\t\t   const struct nft_rule *rule)\n{\n\tstruct nft_offload_ctx *ctx;\n\tstruct nft_flow_rule *flow;\n\tint num_actions = 0, err;\n\tstruct nft_expr *expr;\n\n\texpr = nft_expr_first(rule);\n\twhile (nft_expr_more(rule, expr)) {\n\t\tif (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION)\n\t\t\tnum_actions++;\n\n\t\texpr = nft_expr_next(expr);\n\t}\n\n\tif (num_actions == 0)\n\t\treturn ERR_PTR(-EOPNOTSUPP);\n\n\tflow = nft_flow_rule_alloc(num_actions);\n\tif (!flow)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\texpr = nft_expr_first(rule);\n\n\tctx = kzalloc(sizeof(struct nft_offload_ctx), GFP_KERNEL);\n\tif (!ctx) {\n\t\terr = -ENOMEM;\n\t\tgoto err_out;\n\t}\n\tctx->net = net;\n\tctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC;\n\n\twhile (nft_expr_more(rule, expr)) {\n\t\tif (!expr->ops->offload) {\n\t\t\terr = -EOPNOTSUPP;\n\t\t\tgoto err_out;\n\t\t}\n\t\terr = expr->ops->offload(ctx, flow, expr);\n\t\tif (err < 0)\n\t\t\tgoto err_out;\n\n\t\texpr = nft_expr_next(expr);\n\t}\n\tnft_flow_rule_transfer_vlan(ctx, flow);\n\n\tflow->proto = ctx->dep.l3num;\n\tkfree(ctx);\n\n\treturn flow;\nerr_out:\n\tkfree(ctx);\n\tnft_flow_rule_destroy(flow);\n\n\treturn ERR_PTR(err);\n}","target":1,"code_token_length":343,"total_token_length":579,"max_tokens_setting":1024}
+{"idx":498622,"func":"save_dialog (void)\n{\n  GtkWidget *dialog;\n  GtkWidget *label;\n  GtkWidget *toggle;\n  GtkWidget *combo;\n  GtkWidget *vbox;\n  GtkWidget *hbox;\n  gboolean   run;\n\n  dialog = gimp_export_dialog_new (_(\"TGA\"), PLUG_IN_BINARY, SAVE_PROC);\n\n  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);\n  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);\n  gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)),\n                      vbox, TRUE, TRUE, 0);\n  gtk_widget_show (vbox);\n\n  \/*  rle  *\/\n  toggle = gtk_check_button_new_with_mnemonic (_(\"_RLE compression\"));\n  gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);\n  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), tsvals.rle);\n  gtk_widget_show (toggle);\n\n  g_signal_connect (toggle, \"toggled\",\n                    G_CALLBACK (gimp_toggle_button_update),\n                    &tsvals.rle);\n\n  \/*  origin  *\/\n  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);\n  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);\n  gtk_widget_show (hbox);\n\n  label = gtk_label_new_with_mnemonic (_(\"Or_igin:\"));\n  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);\n  gtk_widget_show (label);\n\n  combo = gimp_int_combo_box_new (_(\"Bottom left\"), ORIGIN_BOTTOM_LEFT,\n                                  _(\"Top left\"),    ORIGIN_TOP_LEFT,\n                                  NULL);\n  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);\n  gtk_widget_show (combo);\n\n  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);\n\n  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),\n                              tsvals.origin,\n                              G_CALLBACK (gimp_int_combo_box_get_active),\n                              &tsvals.origin);\n\n  gtk_widget_show (dialog);\n\n  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);\n\n  gtk_widget_destroy (dialog);\n\n  return run;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":262791,"func":"static void mctp_serial_push(struct mctp_serial *dev, unsigned char c)\n{\n\tswitch (dev->rxstate) {\n\tcase STATE_IDLE:\n\t\tdev->rxstate = STATE_HEADER;\n\t\tfallthrough;\n\tcase STATE_HEADER:\n\t\tmctp_serial_push_header(dev, c);\n\t\tbreak;\n\n\tcase STATE_ESCAPE:\n\t\tc |= 0x20;\n\t\tfallthrough;\n\tcase STATE_DATA:\n\t\tif (dev->rxstate != STATE_ESCAPE && c == BYTE_ESC) {\n\t\t\tdev->rxstate = STATE_ESCAPE;\n\t\t} else {\n\t\t\tdev->rxfcs = crc_ccitt_byte(dev->rxfcs, c);\n\t\t\tdev->rxbuf[dev->rxpos] = c;\n\t\t\tdev->rxpos++;\n\t\t\tdev->rxstate = STATE_DATA;\n\t\t\tif (dev->rxpos == dev->rxlen) {\n\t\t\t\tdev->rxpos = 0;\n\t\t\t\tdev->rxstate = STATE_TRAILER;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase STATE_TRAILER:\n\t\tmctp_serial_push_trailer(dev, c);\n\t\tbreak;\n\n\tcase STATE_ERR:\n\t\tif (c == BYTE_FRAME)\n\t\t\tdev->rxstate = STATE_IDLE;\n\t\tbreak;\n\n\tdefault:\n\t\tnetdev_err_once(dev->netdev, \"invalid rx state %d\\n\",\n\t\t\t\tdev->rxstate);\n\t}\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":412087,"func":"respip_inform_super(struct module_qstate* qstate, int id,\n\tstruct module_qstate* super)\n{\n\tstruct respip_qstate* rq = (struct respip_qstate*)super->minfo[id];\n\tstruct reply_info* new_rep = NULL;\n\n\trq->state = RESPIP_SUBQUERY_FINISHED;\n\n\t\/* respip subquery should have always been created with a valid reply\n\t * in super. *\/\n\tlog_assert(super->return_msg && super->return_msg->rep);\n\n\t\/* return_msg can be NULL when, e.g., the sub query resulted in\n\t * SERVFAIL, in which case we regard it as a failure of the original\n\t * query.  Other checks are probably redundant, but we check them\n\t * for safety. *\/\n\tif(!qstate->return_msg || !qstate->return_msg->rep ||\n\t\tqstate->return_rcode != LDNS_RCODE_NOERROR)\n\t\tgoto fail;\n\n\tif(!respip_merge_cname(super->return_msg->rep, &qstate->qinfo,\n\t\tqstate->return_msg->rep, super->client_info,\n\t\tsuper->env->need_to_validate, &new_rep, super->region))\n\t\tgoto fail;\n\tsuper->return_msg->rep = new_rep;\n\treturn;\n\n  fail:\n\tsuper->return_rcode = LDNS_RCODE_SERVFAIL;\n\tsuper->return_msg = NULL;\n\treturn;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":343183,"func":"static int esp6_init_state(struct xfrm_state *x)\n{\n\tstruct crypto_aead *aead;\n\tu32 align;\n\tint err;\n\n\tx->data = NULL;\n\n\tif (x->aead)\n\t\terr = esp_init_aead(x);\n\telse\n\t\terr = esp_init_authenc(x);\n\n\tif (err)\n\t\tgoto error;\n\n\taead = x->data;\n\n\tx->props.header_len = sizeof(struct ip_esp_hdr) +\n\t\t\t      crypto_aead_ivsize(aead);\n\tswitch (x->props.mode) {\n\tcase XFRM_MODE_BEET:\n\t\tif (x->sel.family != AF_INET6)\n\t\t\tx->props.header_len += IPV4_BEET_PHMAXLEN +\n\t\t\t\t\t       (sizeof(struct ipv6hdr) - sizeof(struct iphdr));\n\t\tbreak;\n\tdefault:\n\tcase XFRM_MODE_TRANSPORT:\n\t\tbreak;\n\tcase XFRM_MODE_TUNNEL:\n\t\tx->props.header_len += sizeof(struct ipv6hdr);\n\t\tbreak;\n\t}\n\n\tif (x->encap) {\n\t\tstruct xfrm_encap_tmpl *encap = x->encap;\n\n\t\tswitch (encap->encap_type) {\n\t\tdefault:\n\t\t\terr = -EINVAL;\n\t\t\tgoto error;\n\t\tcase UDP_ENCAP_ESPINUDP:\n\t\t\tx->props.header_len += sizeof(struct udphdr);\n\t\t\tbreak;\n\t\tcase UDP_ENCAP_ESPINUDP_NON_IKE:\n\t\t\tx->props.header_len += sizeof(struct udphdr) + 2 * sizeof(u32);\n\t\t\tbreak;\n#ifdef CONFIG_INET6_ESPINTCP\n\t\tcase TCP_ENCAP_ESPINTCP:\n\t\t\t\/* only the length field, TCP encap is done by\n\t\t\t * the socket\n\t\t\t *\/\n\t\t\tx->props.header_len += 2;\n\t\t\tbreak;\n#endif\n\t\t}\n\t}\n\n\talign = ALIGN(crypto_aead_blocksize(aead), 4);\n\tx->props.trailer_len = align + 1 + crypto_aead_authsize(aead);\n\nerror:\n\treturn err;\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":309853,"func":"mouse_server(unsigned long param)\n#endif\n{\n    SCREEN *sp = (SCREEN *) param;\n    unsigned short fWait = MOU_WAIT;\n    \/* NOPTRRECT mourt = { 0,0,24,79 }; *\/\n    MOUEVENTINFO mouev;\n    HMOU hmou;\n    unsigned short mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;\n    int nbuttons = 3;\n    int oldstate = 0;\n    char err[80];\n    unsigned long rc;\n\n    \/* open the handle for the mouse *\/\n    if (MouOpen(NULL, &hmou) == 0) {\n\trc = MouSetEventMask(&mask, hmou);\n\tif (rc) {\t\t\/* retry with 2 buttons *\/\n\t    mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN;\n\t    rc = MouSetEventMask(&mask, hmou);\n\t    nbuttons = 2;\n\t}\n\tif (rc == 0 && MouDrawPtr(hmou) == 0) {\n\t    for (;;) {\n\t\t\/* sit and wait on the event queue *\/\n\t\trc = MouReadEventQue(&mouev, &fWait, hmou);\n\t\tif (rc) {\n\t\t    _nc_SPRINTF(err, _nc_SLIMIT(sizeof(err))\n\t\t\t\t\"Error reading mouse queue, rc=%lu.\\r\\n\", rc);\n\t\t    break;\n\t\t}\n\t\tif (!sp->_emxmouse_activated)\n\t\t    goto finish;\n\n\t\t\/*\n\t\t * OS\/2 numbers a 3-button mouse inconsistently from other\n\t\t * platforms:\n\t\t *      1 = left\n\t\t *      2 = right\n\t\t *      3 = middle.\n\t\t *\/\n\t\tif ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)\n\t\t    write_event(sp, mouev.fs & MOUSE_BN1_DOWN,\n\t\t\t\tsp->_emxmouse_buttons[1], mouev.col, mouev.row);\n\t\tif ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)\n\t\t    write_event(sp, mouev.fs & MOUSE_BN2_DOWN,\n\t\t\t\tsp->_emxmouse_buttons[3], mouev.col, mouev.row);\n\t\tif ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)\n\t\t    write_event(sp, mouev.fs & MOUSE_BN3_DOWN,\n\t\t\t\tsp->_emxmouse_buttons[2], mouev.col, mouev.row);\n\n\t      finish:\n\t\toldstate = mouev.fs;\n\t    }\n\t} else {\n\t    _nc_SPRINTF(err, _nc_SLIMIT(sizeof(err))\n\t\t\t\"Error setting event mask, buttons=%d, rc=%lu.\\r\\n\",\n\t\t\tnbuttons, rc);\n\t}\n\n\tDosWrite(2, err, strlen(err), &rc);\n\tMouClose(hmou);\n    }\n    DosExit(EXIT_THREAD, 0L);\n}","target":0,"code_token_length":610,"total_token_length":846,"max_tokens_setting":1024}
+{"idx":335431,"func":"ex_redir(exarg_T *eap)\n{\n    char\t*mode;\n    char_u\t*fname;\n    char_u\t*arg = eap->arg;\n\n#ifdef FEAT_EVAL\n    if (redir_execute)\n    {\n\temsg(_(e_cannot_use_redir_inside_execute));\n\treturn;\n    }\n#endif\n\n    if (STRICMP(eap->arg, \"END\") == 0)\n\tclose_redir();\n    else\n    {\n\tif (*arg == '>')\n\t{\n\t    ++arg;\n\t    if (*arg == '>')\n\t    {\n\t\t++arg;\n\t\tmode = \"a\";\n\t    }\n\t    else\n\t\tmode = \"w\";\n\t    arg = skipwhite(arg);\n\n\t    close_redir();\n\n\t    \/\/ Expand environment variables and \"~\/\".\n\t    fname = expand_env_save(arg);\n\t    if (fname == NULL)\n\t\treturn;\n#ifdef FEAT_BROWSE\n\t    if (cmdmod.cmod_flags & CMOD_BROWSE)\n\t    {\n\t\tchar_u\t*browseFile;\n\n\t\tbrowseFile = do_browse(BROWSE_SAVE,\n\t\t\t(char_u *)_(\"Save Redirection\"),\n\t\t\tfname, NULL, NULL,\n\t\t\t(char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf);\n\t\tif (browseFile == NULL)\n\t\t    return;\t\t\/\/ operation cancelled\n\t\tvim_free(fname);\n\t\tfname = browseFile;\n\t\teap->forceit = TRUE;\t\/\/ since dialog already asked\n\t    }\n#endif\n\n\t    redir_fd = open_exfile(fname, eap->forceit, mode);\n\t    vim_free(fname);\n\t}\n#ifdef FEAT_EVAL\n\telse if (*arg == '@')\n\t{\n\t    \/\/ redirect to a register a-z (resp. A-Z for appending)\n\t    close_redir();\n\t    ++arg;\n\t    if (ASCII_ISALPHA(*arg)\n# ifdef FEAT_CLIPBOARD\n\t\t    || *arg == '*'\n\t\t    || *arg == '+'\n# endif\n\t\t    || *arg == '\"')\n\t    {\n\t\tredir_reg = *arg++;\n\t\tif (*arg == '>' && arg[1] == '>')  \/\/ append\n\t\t    arg += 2;\n\t\telse\n\t\t{\n\t\t    \/\/ Can use both \"@a\" and \"@a>\".\n\t\t    if (*arg == '>')\n\t\t\targ++;\n\t\t    \/\/ Make register empty when not using @A-@Z and the\n\t\t    \/\/ command is valid.\n\t\t    if (*arg == NUL && !isupper(redir_reg))\n\t\t\twrite_reg_contents(redir_reg, (char_u *)\"\", -1, FALSE);\n\t\t}\n\t    }\n\t    if (*arg != NUL)\n\t    {\n\t\tredir_reg = 0;\n\t\tsemsg(_(e_invalid_argument_str), eap->arg);\n\t    }\n\t}\n\telse if (*arg == '=' && arg[1] == '>')\n\t{\n\t    int append;\n\n\t    \/\/ redirect to a variable\n\t    close_redir();\n\t    arg += 2;\n\n\t    if (*arg == '>')\n\t    {\n\t\t++arg;\n\t\tappend = TRUE;\n\t    }\n\t    else\n\t\tappend = FALSE;\n\n\t    if (var_redir_start(skipwhite(arg), append) == OK)\n\t\tredir_vname = 1;\n\t}\n#endif\n\n\t\/\/ TODO: redirect to a buffer\n\n\telse\n\t    semsg(_(e_invalid_argument_str), eap->arg);\n    }\n\n    \/\/ Make sure redirection is not off.  Can happen for cmdline completion\n    \/\/ that indirectly invokes a command to catch its output.\n    if (redir_fd != NULL\n#ifdef FEAT_EVAL\n\t\t\t  || redir_reg || redir_vname\n#endif\n\t\t\t\t\t\t\t)\n\tredir_off = FALSE;\n}","target":0,"code_token_length":765,"total_token_length":1001,"max_tokens_setting":1024}
+{"idx":432697,"func":"static float lite_font_stringwidth( wmfAPI* API, wmfFont* font, char* str)\n{\n#if 0\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  Image\n    *image = ddata->image;\n\n  DrawInfo\n    *draw_info;\n\n  ExceptionInfo\n    *exception;\n\n  TypeMetric\n    metrics;\n\n  float\n    stringwidth = 0;\n\n  double\n    orig_x_resolution,\n    orig_y_resolution;\n\n  ResolutionType\n    orig_resolution_units;\n\n  orig_x_resolution = image->resolution.x;\n  orig_y_resolution = image->resolution.y;\n  orig_resolution_units = image->units;\n\n  draw_info=ddata->draw_info;\n  if (draw_info == (const DrawInfo *) NULL)\n    return 0;\n\n  draw_info->font=WMF_FONT_PSNAME(font);\n  draw_info->pointsize=12;\n  draw_info->text=str;\n\n  image->resolution.x = 72;\n  image->resolution.y = 72;\n  image->units = PixelsPerInchResolution;\n\n  exception=ddata->exception;\n  if (GetTypeMetrics(image, draw_info, &metrics, exception) != MagickFalse)\n    stringwidth = ((metrics.width * 72)\/(image->resolution.x * draw_info->pointsize)); \/* *0.916348; *\/\n\n  draw_info->font=NULL;\n  draw_info->text=NULL;\n\n#if 0\n  printf(\"\\nlite_font_stringwidth\\n\");\n  printf(\"string                  = \\\"%s\\\"\\n\", str);\n  printf(\"WMF_FONT_NAME           = \\\"%s\\\"\\n\", WMF_FONT_NAME(font));\n  printf(\"WMF_FONT_PSNAME         = \\\"%s\\\"\\n\", WMF_FONT_PSNAME(font));\n  printf(\"stringwidth             = %g\\n\", stringwidth);\n  \/* printf(\"WMF_FONT_HEIGHT         = %i\\n\", (int)WMF_FONT_HEIGHT(font)); *\/\n  \/* printf(\"WMF_FONT_WIDTH          = %i\\n\", (int)WMF_FONT_WIDTH(font)); *\/\n  fflush(stdout);\n#endif\n\n  image->resolution.x = orig_x_resolution;\n  image->resolution.y = orig_y_resolution;\n  image->units = orig_resolution_units;\n\n  return stringwidth;\n#else\n  (void) API;\n  (void) font;\n  (void) str;\n\n  return 0;\n#endif\n}","target":0,"code_token_length":509,"total_token_length":745,"max_tokens_setting":1024}
+{"idx":223482,"func":"static void read_char7_type(compiler_common *common, jump_list **backtracks, BOOL negated)\n{\n\/* Reads the precise character type of a character into TMP1, if the character\nis less than 128. Otherwise it returns with zero. Does not check STR_END. The\nfull_read argument tells whether characters above max are accepted or not. *\/\nDEFINE_COMPILER;\nstruct sljit_jump *jump;\n\nSLJIT_ASSERT(common->utf);\n\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);\nOP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));\n\n\/* All values > 127 are zero in ctypes. *\/\nOP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);\n\nif (negated)\n  {\n  jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x80);\n\n  if (common->invalid_utf)\n    {\n    add_jump(compiler, &common->utfreadchar_invalid, JUMP(SLJIT_FAST_CALL));\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR));\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);\n    }\n  else\n    {\n    OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);\n    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);\n    }\n  JUMPHERE(jump);\n  }\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":509566,"func":"void ha_maria::get_auto_increment(ulonglong offset, ulonglong increment,\n                                  ulonglong nb_desired_values,\n                                  ulonglong *first_value,\n                                  ulonglong *nb_reserved_values)\n{\n  ulonglong nr;\n  int error;\n  uchar key[MARIA_MAX_KEY_BUFF];\n\n  if (!table->s->next_number_key_offset)\n  {                                             \/\/ Autoincrement at key-start\n    ha_maria::info(HA_STATUS_AUTO);\n    *first_value= stats.auto_increment_value;\n    \/* Maria has only table-level lock for now, so reserves to +inf *\/\n    *nb_reserved_values= ULONGLONG_MAX;\n    return;\n  }\n\n  \/* it's safe to call the following if bulk_insert isn't on *\/\n  maria_flush_bulk_insert(file, table->s->next_number_index);\n\n  (void) extra(HA_EXTRA_KEYREAD);\n  key_copy(key, table->record[0],\n           table->key_info + table->s->next_number_index,\n           table->s->next_number_key_offset);\n  error= maria_rkey(file, table->record[1], (int) table->s->next_number_index,\n                    key, make_prev_keypart_map(table->s->next_number_keypart),\n                    HA_READ_PREFIX_LAST);\n  if (error)\n    nr= 1;\n  else\n  {\n    \/* Get data from record[1] *\/\n    nr= ((ulonglong) table->next_number_field->\n         val_int_offset(table->s->rec_buff_length) + 1);\n  }\n  extra(HA_EXTRA_NO_KEYREAD);\n  *first_value= nr;\n  \/*\n    MySQL needs to call us for next row: assume we are inserting (\"a\",null)\n    here, we return 3, and next this statement will want to insert (\"b\",null):\n    there is no reason why (\"b\",3+1) would be the good row to insert: maybe it\n    already exists, maybe 3+1 is too large...\n  *\/\n  *nb_reserved_values= 1;\n}","target":0,"code_token_length":426,"total_token_length":662,"max_tokens_setting":1024}
+{"idx":247094,"func":"Bool gf_fs_solve_js_script(char *szPath, const char *file_name, const char *file_ext)\n{\n\tconst char *js_dirs;\n\tif (gf_opts_default_shared_directory(szPath)) {\n\t\tstrcat(szPath, \"\/scripts\/jsf\/\");\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, (\"Trying JS filter %s\\n\", szPath));\n\t\tif (locate_js_script(szPath, file_name, file_ext)) {\n\t\t\treturn GF_TRUE;\n\t\t}\n\t} else {\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_FILTER, (\"Failed to get default shared dir\\n\"));\n\t}\n\tjs_dirs = gf_opts_get_key(\"core\", \"js-dirs\");\n\twhile (js_dirs && js_dirs[0]) {\n\t\tchar *sep = strchr(js_dirs, ',');\n\t\tif (sep) {\n\t\t\tu32 cplen = (u32) (sep-js_dirs);\n\t\t\tif (cplen>=GF_MAX_PATH) cplen = GF_MAX_PATH-1;\n\t\t\tstrncpy(szPath, js_dirs, cplen);\n\t\t\tszPath[cplen]=0;\n\t\t\tjs_dirs = sep+1;\n\t\t} else {\n\t\t\tstrcpy(szPath, js_dirs);\n\t\t}\n\t\tif (strcmp(szPath, \"$GJS\")) {\n\t\t\tu32 len = (u32) strlen(szPath);\n\t\t\tif (len && (szPath[len-1]!='\/') && (szPath[len-1]!='\\\\'))\n\t\t\t\tstrcat(szPath, \"\/\");\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, (\"Trying JS filter in %s\\n\", szPath));\n\t\t\tif (locate_js_script(szPath, file_name, file_ext))\n\t\t\t\treturn GF_TRUE;\n\t\t}\n\t\tif (!sep) break;\n\t}\n\treturn GF_FALSE;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":387580,"func":"struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,\n\t\t\t\t  void *private_data)\n{\n\tstruct snd_kcontrol *kctl;\n\tunsigned int count;\n\tunsigned int access;\n\tint err;\n\n\tif (snd_BUG_ON(!ncontrol || !ncontrol->info))\n\t\treturn NULL;\n\n\tcount = ncontrol->count;\n\tif (count == 0)\n\t\tcount = 1;\n\n\taccess = ncontrol->access;\n\tif (access == 0)\n\t\taccess = SNDRV_CTL_ELEM_ACCESS_READWRITE;\n\taccess &= (SNDRV_CTL_ELEM_ACCESS_READWRITE |\n\t\t   SNDRV_CTL_ELEM_ACCESS_VOLATILE |\n\t\t   SNDRV_CTL_ELEM_ACCESS_INACTIVE |\n\t\t   SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |\n\t\t   SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND |\n\t\t   SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK |\n\t\t   SNDRV_CTL_ELEM_ACCESS_LED_MASK |\n\t\t   SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK);\n\n\terr = snd_ctl_new(&kctl, count, access, NULL);\n\tif (err < 0)\n\t\treturn NULL;\n\n\t\/* The 'numid' member is decided when calling snd_ctl_add(). *\/\n\tkctl->id.iface = ncontrol->iface;\n\tkctl->id.device = ncontrol->device;\n\tkctl->id.subdevice = ncontrol->subdevice;\n\tif (ncontrol->name) {\n\t\tstrscpy(kctl->id.name, ncontrol->name, sizeof(kctl->id.name));\n\t\tif (strcmp(ncontrol->name, kctl->id.name) != 0)\n\t\t\tpr_warn(\"ALSA: Control name '%s' truncated to '%s'\\n\",\n\t\t\t\tncontrol->name, kctl->id.name);\n\t}\n\tkctl->id.index = ncontrol->index;\n\n\tkctl->info = ncontrol->info;\n\tkctl->get = ncontrol->get;\n\tkctl->put = ncontrol->put;\n\tkctl->tlv.p = ncontrol->tlv.p;\n\n\tkctl->private_value = ncontrol->private_value;\n\tkctl->private_data = private_data;\n\n\treturn kctl;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":271525,"func":"  Status operator()(OpKernelContext *context, const TensorShape &input_shape,\n                    const TensorShape &output_shape,\n                    typename TTypes<int64>::ConstMatrix input_indices,\n                    typename TTypes<int64>::Matrix output_indices) const {\n    (void)context;  \/\/ Unused (only used in GPU implementation)\n    const int64_t input_rank = input_shape.dims();\n    const int64_t output_rank = output_shape.dims();\n    const int64_t nnz = input_indices.dimension(0);\n    gtl::InlinedVector<int64, 8> input_strides(input_rank);\n    if (input_rank > 0) {\n      input_strides[input_rank - 1] = 1;\n      for (int d = input_rank - 2; d >= 0; --d) {\n        input_strides[d] = input_strides[d + 1] * input_shape.dim_size(d + 1);\n      }\n    }\n\n    gtl::InlinedVector<int64, 8> output_strides(output_rank);\n    if (output_rank > 0) {\n      output_strides[output_rank - 1] = 1;\n      for (int d = output_rank - 2; d >= 0; --d) {\n        output_strides[d] =\n            output_strides[d + 1] * output_shape.dim_size(d + 1);\n      }\n    }\n\n    for (int i = 0; i < nnz; ++i) {\n      int64_t id = 0;\n      for (int j = 0; j < input_rank; ++j) {\n        id += input_indices(i, j) * input_strides[j];\n      }\n      for (int j = 0; j < output_rank; ++j) {\n        output_indices(i, j) = id \/ output_strides[j];\n        id %= output_strides[j];\n      }\n    }\n    return Status::OK();\n  }","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":512907,"func":"longlong Item_func_dyncol_exists::val_int()\n{\n  char buff[STRING_BUFFER_USUAL_SIZE], nmstrbuf[11];\n  String tmp(buff, sizeof(buff), &my_charset_bin),\n         nmbuf(nmstrbuf, sizeof(nmstrbuf), system_charset_info);\n  DYNAMIC_COLUMN col;\n  String *str;\n  LEX_STRING buf, *name= NULL;\n  ulonglong num= 0;\n  enum enum_dyncol_func_result rc;\n\n  if (args[1]->result_type() == INT_RESULT)\n    num= args[1]->val_int();\n  else\n  {\n    String *nm= args[1]->val_str(&nmbuf);\n    if (!nm || args[1]->null_value)\n    {\n      null_value= 1;\n      return 1;\n    }\n    if (my_charset_same(nm->charset(), DYNCOL_UTF))\n    {\n      buf.str= (char *) nm->ptr();\n      buf.length= nm->length();\n    }\n    else\n    {\n      uint strlen= nm->length() * DYNCOL_UTF->mbmaxlen + 1;\n      uint dummy_errors;\n      buf.str= (char *) current_thd->alloc(strlen);\n      if (buf.str)\n      {\n        buf.length=\n          copy_and_convert(buf.str, strlen, DYNCOL_UTF,\n                           nm->ptr(), nm->length(), nm->charset(),\n                           &dummy_errors);\n      }\n      else\n        buf.length= 0;\n    }\n    name= &buf;\n  }\n  str= args[0]->val_str(&tmp);\n  if (args[0]->null_value || args[1]->null_value || num > UINT_MAX16)\n    goto null;\n  col.length= str->length();\n  \/* We do not change the string, so could do this trick *\/\n  col.str= (char *)str->ptr();\n  rc= ((name == NULL) ?\n       mariadb_dyncol_exists_num(&col, (uint) num) :\n       mariadb_dyncol_exists_named(&col, name));\n  if (rc < 0)\n  {\n    dynamic_column_error_message(rc);\n    goto null;\n  }\n  null_value= FALSE;\n  return rc == ER_DYNCOL_YES;\n\nnull:\n  null_value= TRUE;\n  return 0;\n}","target":0,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":366276,"func":"static struct mountpoint *get_mountpoint(struct dentry *dentry)\n{\n\tstruct mountpoint *mp, *new = NULL;\n\tint ret;\n\n\tif (d_mountpoint(dentry)) {\n\t\t\/* might be worth a WARN_ON() *\/\n\t\tif (d_unlinked(dentry))\n\t\t\treturn ERR_PTR(-ENOENT);\nmountpoint:\n\t\tread_seqlock_excl(&mount_lock);\n\t\tmp = lookup_mountpoint(dentry);\n\t\tread_sequnlock_excl(&mount_lock);\n\t\tif (mp)\n\t\t\tgoto done;\n\t}\n\n\tif (!new)\n\t\tnew = kmalloc(sizeof(struct mountpoint), GFP_KERNEL);\n\tif (!new)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\n\t\/* Exactly one processes may set d_mounted *\/\n\tret = d_set_mounted(dentry);\n\n\t\/* Someone else set d_mounted? *\/\n\tif (ret == -EBUSY)\n\t\tgoto mountpoint;\n\n\t\/* The dentry is not available as a mountpoint? *\/\n\tmp = ERR_PTR(ret);\n\tif (ret)\n\t\tgoto done;\n\n\t\/* Add the new mountpoint to the hash table *\/\n\tread_seqlock_excl(&mount_lock);\n\tnew->m_dentry = dget(dentry);\n\tnew->m_count = 1;\n\thlist_add_head(&new->m_hash, mp_hash(dentry));\n\tINIT_HLIST_HEAD(&new->m_list);\n\tread_sequnlock_excl(&mount_lock);\n\n\tmp = new;\n\tnew = NULL;\ndone:\n\tkfree(new);\n\treturn mp;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":231644,"func":"TEST_F(QuicServerTransportTest, ReceivePacketAfterLocalError) {\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  ASSERT_TRUE(builder.canBuildPacket());\n\n  \/\/ Deliver a reset to non existent stream to trigger a local conn error\n  StreamId streamId = 0x01;\n  RstStreamFrame rstFrame(streamId, GenericApplicationErrorCode::UNKNOWN, 0);\n  writeFrame(std::move(rstFrame), builder);\n  auto packet = std::move(builder).buildPacket();\n  deliverDataWithoutErrorCheck(packetToBuf(packet));\n  EXPECT_TRUE(verifyFramePresent(\n      serverWrites,\n      *makeClientEncryptedCodec(),\n      QuicFrame::Type::ConnectionCloseFrame));\n  serverWrites.clear();\n\n  ShortHeader header2(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder2(\n      server->getConn().udpSendPacketLen,\n      std::move(header2),\n      0 \/* largestAcked *\/);\n  builder2.encodePacketHeader();\n  RstStreamFrame rstFrame2(streamId, GenericApplicationErrorCode::UNKNOWN, 0);\n  writeFrame(std::move(rstFrame2), builder2);\n  auto packet2 = std::move(builder2).buildPacket();\n  deliverDataWithoutErrorCheck(packetToBuf(packet2));\n  EXPECT_TRUE(hasNotReceivedNewPacketsSinceLastCloseSent(server->getConn()));\n  EXPECT_TRUE(verifyFramePresent(\n      serverWrites,\n      *makeClientEncryptedCodec(),\n      QuicFrame::Type::ConnectionCloseFrame));\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":349892,"func":"int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self)\n{\n\tstruct aq_hw_link_status_s *link_status = &self->aq_link_status;\n\tu32 mpi_state;\n\tu32 speed;\n\n\tmpi_state = hw_atl_utils_mpi_get_state(self);\n\tspeed = mpi_state >> HW_ATL_MPI_SPEED_SHIFT;\n\n\tif (!speed) {\n\t\tlink_status->mbps = 0U;\n\t} else {\n\t\tswitch (speed) {\n\t\tcase HAL_ATLANTIC_RATE_10G:\n\t\t\tlink_status->mbps = 10000U;\n\t\t\tbreak;\n\n\t\tcase HAL_ATLANTIC_RATE_5G:\n\t\tcase HAL_ATLANTIC_RATE_5GSR:\n\t\t\tlink_status->mbps = 5000U;\n\t\t\tbreak;\n\n\t\tcase HAL_ATLANTIC_RATE_2G5:\n\t\t\tlink_status->mbps = 2500U;\n\t\t\tbreak;\n\n\t\tcase HAL_ATLANTIC_RATE_1G:\n\t\t\tlink_status->mbps = 1000U;\n\t\t\tbreak;\n\n\t\tcase HAL_ATLANTIC_RATE_100M:\n\t\t\tlink_status->mbps = 100U;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\treturn -EBUSY;\n\t\t}\n\t}\n\tlink_status->full_duplex = true;\n\n\treturn 0;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":263497,"func":"static int sco_connect(struct hci_dev *hdev, struct sock *sk)\n{\n\tstruct sco_conn *conn;\n\tstruct hci_conn *hcon;\n\tint err, type;\n\n\tBT_DBG(\"%pMR -> %pMR\", &sco_pi(sk)->src, &sco_pi(sk)->dst);\n\n\tif (lmp_esco_capable(hdev) && !disable_esco)\n\t\ttype = ESCO_LINK;\n\telse\n\t\ttype = SCO_LINK;\n\n\tif (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&\n\t    (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev)))\n\t\treturn -EOPNOTSUPP;\n\n\thcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,\n\t\t\t       sco_pi(sk)->setting);\n\tif (IS_ERR(hcon))\n\t\treturn PTR_ERR(hcon);\n\n\tconn = sco_conn_add(hcon);\n\tif (!conn) {\n\t\thci_conn_drop(hcon);\n\t\treturn -ENOMEM;\n\t}\n\n\t\/* Update source addr of the socket *\/\n\tbacpy(&sco_pi(sk)->src, &hcon->src);\n\n\terr = sco_chan_add(conn, sk, NULL);\n\tif (err)\n\t\treturn err;\n\n\tif (hcon->state == BT_CONNECTED) {\n\t\tsco_sock_clear_timer(sk);\n\t\tsk->sk_state = BT_CONNECTED;\n\t} else {\n\t\tsk->sk_state = BT_CONNECT;\n\t\tsco_sock_set_timer(sk, sk->sk_sndtimeo);\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":338188,"func":"void WasmBinaryBuilder::readNextDebugLocation() {\n  if (!sourceMap) {\n    return;\n  }\n\n  while (nextDebugLocation.first && nextDebugLocation.first <= pos) {\n    debugLocation.clear();\n    \/\/ use debugLocation only for function expressions\n    if (currFunction) {\n      debugLocation.insert(nextDebugLocation.second);\n    }\n\n    char ch;\n    *sourceMap >> ch;\n    if (ch == '\\\"') { \/\/ end of records\n      nextDebugLocation.first = 0;\n      break;\n    }\n    if (ch != ',') {\n      throw MapParseException(\"Unexpected delimiter\");\n    }\n\n    int32_t positionDelta = readBase64VLQ(*sourceMap);\n    uint32_t position = nextDebugLocation.first + positionDelta;\n    int32_t fileIndexDelta = readBase64VLQ(*sourceMap);\n    uint32_t fileIndex = nextDebugLocation.second.fileIndex + fileIndexDelta;\n    int32_t lineNumberDelta = readBase64VLQ(*sourceMap);\n    uint32_t lineNumber = nextDebugLocation.second.lineNumber + lineNumberDelta;\n    int32_t columnNumberDelta = readBase64VLQ(*sourceMap);\n    uint32_t columnNumber =\n      nextDebugLocation.second.columnNumber + columnNumberDelta;\n\n    nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}};\n  }\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":474462,"func":"HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)\n{\n    rfbRREHeader hdr;\n    int i;\n    CARDBPP pix;\n    uint8_t *ptr;\n    int x, y, w, h;\n\n    if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))\n\treturn FALSE;\n\n    hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);\n\n    if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))\n\treturn FALSE;\n\n    client->GotFillRect(client, rx, ry, rw, rh, pix);\n\n    if (hdr.nSubrects > RFB_BUFFER_SIZE \/ (4 + (BPP \/ 8)) || !ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP \/ 8))))\n\treturn FALSE;\n\n    ptr = (uint8_t *)client->buffer;\n\n    for (i = 0; i < hdr.nSubrects; i++) {\n\tpix = *(CARDBPP *)ptr;\n\tptr += BPP\/8;\n\tx = *ptr++;\n\ty = *ptr++;\n\tw = *ptr++;\n\th = *ptr++;\n\n\tclient->GotFillRect(client, rx+x, ry+y, w, h, pix);\n    }\n\n    return TRUE;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":310272,"func":"dirserv_load_fingerprint_file(void)\n{\n  char *fname;\n  char *cf;\n  char *nickname, *fingerprint;\n  authdir_config_t *fingerprint_list_new;\n  int result;\n  config_line_t *front=NULL, *list;\n  or_options_t *options = get_options();\n\n  fname = get_datadir_fname(\"approved-routers\");\n  log_info(LD_GENERAL,\n           \"Reloading approved fingerprints from \\\"%s\\\"...\", fname);\n\n  cf = read_file_to_str(fname, RFTS_IGNORE_MISSING, NULL);\n  if (!cf) {\n    if (options->NamingAuthoritativeDir) {\n      log_warn(LD_FS, \"Cannot open fingerprint file '%s'. Failing.\", fname);\n      tor_free(fname);\n      return -1;\n    } else {\n      log_info(LD_FS, \"Cannot open fingerprint file '%s'. That's ok.\", fname);\n      tor_free(fname);\n      return 0;\n    }\n  }\n  tor_free(fname);\n\n  result = config_get_lines(cf, &front);\n  tor_free(cf);\n  if (result < 0) {\n    log_warn(LD_CONFIG, \"Error reading from fingerprint file\");\n    return -1;\n  }\n\n  fingerprint_list_new = authdir_config_new();\n\n  for (list=front; list; list=list->next) {\n    char digest_tmp[DIGEST_LEN];\n    nickname = list->key; fingerprint = list->value;\n    if (strlen(nickname) > MAX_NICKNAME_LEN) {\n      log_notice(LD_CONFIG,\n                 \"Nickname '%s' too long in fingerprint file. Skipping.\",\n                 nickname);\n      continue;\n    }\n    if (!is_legal_nickname(nickname) &&\n        strcasecmp(nickname, \"!reject\") &&\n        strcasecmp(nickname, \"!invalid\") &&\n        strcasecmp(nickname, \"!badexit\")) {\n      log_notice(LD_CONFIG,\n                 \"Invalid nickname '%s' in fingerprint file. Skipping.\",\n                 nickname);\n      continue;\n    }\n    tor_strstrip(fingerprint, \" \"); \/* remove spaces *\/\n    if (strlen(fingerprint) != HEX_DIGEST_LEN ||\n        base16_decode(digest_tmp, sizeof(digest_tmp),\n                      fingerprint, HEX_DIGEST_LEN) < 0) {\n      log_notice(LD_CONFIG,\n                 \"Invalid fingerprint (nickname '%s', \"\n                 \"fingerprint %s). Skipping.\",\n                 nickname, fingerprint);\n      continue;\n    }\n    if (0==strcasecmp(nickname, DEFAULT_CLIENT_NICKNAME)) {\n      \/* If you approved an OR called \"client\", then clients who use\n       * the default nickname could all be rejected.  That's no good. *\/\n      log_notice(LD_CONFIG,\n                 \"Authorizing nickname '%s' would break \"\n                 \"many clients; skipping.\",\n                 DEFAULT_CLIENT_NICKNAME);\n      continue;\n    }\n    if (0==strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME)) {\n      \/* If you approved an OR called \"unnamed\", then clients will be\n       * confused. *\/\n      log_notice(LD_CONFIG,\n                 \"Authorizing nickname '%s' is not allowed; skipping.\",\n                 UNNAMED_ROUTER_NICKNAME);\n      continue;\n    }\n    if (add_fingerprint_to_dir(nickname, fingerprint, fingerprint_list_new)\n        != 0)\n      log_notice(LD_CONFIG, \"Duplicate nickname '%s'.\", nickname);\n  }\n\n  config_free_lines(front);\n  dirserv_free_fingerprint_list();\n  fingerprint_list = fingerprint_list_new;\n  \/* Delete any routers whose fingerprints we no longer recognize *\/\n  directory_remove_invalid();\n  return 0;\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":256407,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_sli(\n\t\t\t\t\tconst void *buf,\n\t\t\t\t\tpj_size_t length,\n\t\t\t\t\tunsigned *sli_cnt,\n\t\t\t\t\tpjmedia_rtcp_fb_sli sli[])\n{\n    pjmedia_rtcp_fb_common *hdr = (pjmedia_rtcp_fb_common*) buf;\n    pj_uint8_t *p;\n    unsigned cnt, i;\n\n    PJ_ASSERT_RETURN(buf && sli_cnt && sli, PJ_EINVAL);\n    PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_fb_common), PJ_ETOOSMALL);\n\n    \/* PLI uses pt==RTCP_PSFB and FMT==2 *\/\n    if (hdr->rtcp_common.pt != RTCP_PSFB || hdr->rtcp_common.count != 2)\n\treturn PJ_ENOTFOUND;\n\n    cnt = pj_ntohs((pj_uint16_t)hdr->rtcp_common.length) - 2;\n    if (length < (cnt+3)*4)\n\treturn PJ_ETOOSMALL;\n\n    *sli_cnt = PJ_MIN(*sli_cnt, cnt);\n\n    p = (pj_uint8_t*)hdr + sizeof(*hdr);\n    for (i = 0; i < *sli_cnt; ++i) {\n\t\/* 'first' takes 13 bit *\/\n\tsli[i].first = (p[0] << 5) + ((p[1] & 0xF8) >> 3);\n\t\/* 'number' takes 13 bit *\/\n\tsli[i].number = ((p[1] & 0x07) << 10) +\n\t\t\t(p[2] << 2) +\n\t\t\t((p[3] & 0xC0) >> 6);\n\t\/* 'pict_id' takes 6 bit *\/\n\tsli[i].pict_id = (p[3] & 0x3F);\n\tp += 4;\n    }\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":206510,"func":"int udf_expand_file_adinicb(struct inode *inode)\n{\n\tstruct page *page;\n\tchar *kaddr;\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\tint err;\n\tstruct writeback_control udf_wbc = {\n\t\t.sync_mode = WB_SYNC_NONE,\n\t\t.nr_to_write = 1,\n\t};\n\n\tWARN_ON_ONCE(!inode_is_locked(inode));\n\tif (!iinfo->i_lenAlloc) {\n\t\tif (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))\n\t\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;\n\t\telse\n\t\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;\n\t\t\/* from now on we have normal address_space methods *\/\n\t\tinode->i_data.a_ops = &udf_aops;\n\t\tup_write(&iinfo->i_data_sem);\n\t\tmark_inode_dirty(inode);\n\t\treturn 0;\n\t}\n\t\/*\n\t * Release i_data_sem so that we can lock a page - page lock ranks\n\t * above i_data_sem. i_mutex still protects us against file changes.\n\t *\/\n\tup_write(&iinfo->i_data_sem);\n\n\tpage = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);\n\tif (!page)\n\t\treturn -ENOMEM;\n\n\tif (!PageUptodate(page)) {\n\t\tkaddr = kmap_atomic(page);\n\t\tmemset(kaddr + iinfo->i_lenAlloc, 0x00,\n\t\t       PAGE_SIZE - iinfo->i_lenAlloc);\n\t\tmemcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr,\n\t\t\tiinfo->i_lenAlloc);\n\t\tflush_dcache_page(page);\n\t\tSetPageUptodate(page);\n\t\tkunmap_atomic(kaddr);\n\t}\n\tdown_write(&iinfo->i_data_sem);\n\tmemset(iinfo->i_data + iinfo->i_lenEAttr, 0x00,\n\t       iinfo->i_lenAlloc);\n\tiinfo->i_lenAlloc = 0;\n\tif (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;\n\telse\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;\n\t\/* from now on we have normal address_space methods *\/\n\tinode->i_data.a_ops = &udf_aops;\n\tup_write(&iinfo->i_data_sem);\n\terr = inode->i_data.a_ops->writepage(page, &udf_wbc);\n\tif (err) {\n\t\t\/* Restore everything back so that we don't lose data... *\/\n\t\tlock_page(page);\n\t\tdown_write(&iinfo->i_data_sem);\n\t\tkaddr = kmap_atomic(page);\n\t\tmemcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, inode->i_size);\n\t\tkunmap_atomic(kaddr);\n\t\tunlock_page(page);\n\t\tiinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;\n\t\tinode->i_data.a_ops = &udf_adinicb_aops;\n\t\tup_write(&iinfo->i_data_sem);\n\t}\n\tput_page(page);\n\tmark_inode_dirty(inode);\n\n\treturn err;\n}","target":1,"code_token_length":672,"total_token_length":908,"max_tokens_setting":1024}
+{"idx":229341,"func":"Status GetKernelOutputs(\n    std::vector<EagerKernelRet>* outputs, int num_outputs,\n    TensorHandle** retvals, EagerContext* ctx, KernelAndDevice* kernel,\n    const absl::optional<EagerFunctionParams>& eager_func_params) {\n  for (int i = 0, end = num_outputs; i < end; ++i) {\n    if (retvals[i] == nullptr) {\n      EagerKernelRet& ret = (*outputs)[i];\n      Device* output_device = ctx->CanonicalDevice(kernel->OutputDevice(i));\n      if (ret.index() == 0) {\n        retvals[i] = TensorHandle::CreateLocalHandle(\n            std::move(absl::get<Tensor>(ret)),\n            \/* d= *\/ output_device,\n            \/* op_device= *\/ kernel->device(),\n            \/* resource_device= *\/ kernel->OutputResourceDevice(i), ctx);\n      } else {\n        const DataTypeVector& output_dtypes = kernel->output_dtypes();\n        TF_RETURN_IF_ERROR(\n            CreateUnshapedOutput(*kernel, i, output_device, output_dtypes[i],\n                                 eager_func_params, ctx, &retvals[i]));\n#if !defined(IS_MOBILE_PLATFORM)\n        TF_RETURN_IF_ERROR(\n            retvals[i]->SetRemoteShape(absl::get<TensorShape>(ret),\n                                       output_device, ctx->GetContextViewId()));\n#endif  \/\/ IS_MOBILE_PLATFORM\n      }\n    } else {\n      if (!kernel->IsFunction() &&\n          TF_PREDICT_FALSE(kernel->device() != retvals[i]->op_device())) {\n        return errors::Internal(\n            \"Kernel output tensor handle has a different op device than the \"\n            \"kernel. This should never happen.\");\n      }\n      if (TF_PREDICT_FALSE(ctx->CanonicalDevice(kernel->OutputDevice(i)) !=\n                           retvals[i]->device())) {\n        return errors::Internal(\n            \"Kernel output tensor handle locates on a different device than \"\n            \"the specified kernel output device. This should never happen.\");\n      }\n\n      EagerKernelRet& ret = (*outputs)[i];\n      if (ret.index() == 0) {\n        TF_RETURN_IF_ERROR(retvals[i]->SetTensor(\n            std::move(absl::get<Tensor>(ret)),\n            ctx->CanonicalDevice(kernel->OutputDevice(i))));\n      } else {\n#if defined(IS_MOBILE_PLATFORM)\n        return errors::Unimplemented(\n            \"Remote outputs are not available on mobile devices.\");\n#else  \/\/ !IS_MOBILE_PLATFORM\n        TF_RETURN_IF_ERROR(retvals[i]->SetRemoteShape(\n            absl::get<TensorShape>(ret), retvals[i]->device(),\n            ctx->GetContextViewId()));\n#endif  \/\/ !IS_MOBILE_PLATFORM\n      }\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":570,"total_token_length":806,"max_tokens_setting":1024}
+{"idx":225494,"func":"Status MutableGraphView::DeleteNodes(\n    const absl::flat_hash_set<string>& nodes_to_delete) {\n  TF_RETURN_IF_ERROR(CheckNodesCanBeDeleted(nodes_to_delete));\n\n  \/\/ Find nodes in internal state and delete.\n  for (const string& node_name_to_delete : nodes_to_delete) {\n    NodeDef* node = GetNode(node_name_to_delete);\n    if (node != nullptr) {\n      RemoveFaninsInternal(node, \/*keep_controlling_fanins=*\/false);\n      RemoveFanoutsInternal(node);\n    }\n  }\n  for (const string& node_name_to_delete : nodes_to_delete) {\n    nodes().erase(node_name_to_delete);\n  }\n\n  \/\/ Find nodes in graph and delete by partitioning into nodes to retain and\n  \/\/ nodes to delete based on input set of nodes to delete by name.\n  \/\/ TODO(lyandy): Use a node name->idx hashmap if this is a performance\n  \/\/ bottleneck.\n  int pos = 0;\n  const int last_idx = graph()->node_size() - 1;\n  int last_pos = last_idx;\n  while (pos <= last_pos) {\n    if (nodes_to_delete.contains(graph()->node(pos).name())) {\n      graph()->mutable_node()->SwapElements(pos, last_pos);\n      --last_pos;\n    } else {\n      ++pos;\n    }\n  }\n  if (last_pos < last_idx) {\n    graph()->mutable_node()->DeleteSubrange(last_pos + 1, last_idx - last_pos);\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":319,"total_token_length":555,"max_tokens_setting":1024}
+{"idx":424904,"func":"void iwl_pcie_apply_destination(struct iwl_trans *trans)\n{\n\tconst struct iwl_fw_dbg_dest_tlv_v1 *dest = trans->dbg.dest_tlv;\n\tint i;\n\n\tif (iwl_trans_dbg_ini_valid(trans)) {\n\t\tif (!trans->dbg.num_blocks)\n\t\t\treturn;\n\n\t\tIWL_DEBUG_FW(trans,\n\t\t\t     \"WRT: Applying DRAM buffer[0] destination\\n\");\n\t\tiwl_write_umac_prph(trans, MON_BUFF_BASE_ADDR_VER2,\n\t\t\t\t    trans->dbg.fw_mon[0].physical >>\n\t\t\t\t    MON_BUFF_SHIFT_VER2);\n\t\tiwl_write_umac_prph(trans, MON_BUFF_END_ADDR_VER2,\n\t\t\t\t    (trans->dbg.fw_mon[0].physical +\n\t\t\t\t     trans->dbg.fw_mon[0].size - 256) >>\n\t\t\t\t    MON_BUFF_SHIFT_VER2);\n\t\treturn;\n\t}\n\n\tIWL_INFO(trans, \"Applying debug destination %s\\n\",\n\t\t get_fw_dbg_mode_string(dest->monitor_mode));\n\n\tif (dest->monitor_mode == EXTERNAL_MODE)\n\t\tiwl_pcie_alloc_fw_monitor(trans, dest->size_power);\n\telse\n\t\tIWL_WARN(trans, \"PCI should have external buffer debug\\n\");\n\n\tfor (i = 0; i < trans->dbg.n_dest_reg; i++) {\n\t\tu32 addr = le32_to_cpu(dest->reg_ops[i].addr);\n\t\tu32 val = le32_to_cpu(dest->reg_ops[i].val);\n\n\t\tswitch (dest->reg_ops[i].op) {\n\t\tcase CSR_ASSIGN:\n\t\t\tiwl_write32(trans, addr, val);\n\t\t\tbreak;\n\t\tcase CSR_SETBIT:\n\t\t\tiwl_set_bit(trans, addr, BIT(val));\n\t\t\tbreak;\n\t\tcase CSR_CLEARBIT:\n\t\t\tiwl_clear_bit(trans, addr, BIT(val));\n\t\t\tbreak;\n\t\tcase PRPH_ASSIGN:\n\t\t\tiwl_write_prph(trans, addr, val);\n\t\t\tbreak;\n\t\tcase PRPH_SETBIT:\n\t\t\tiwl_set_bits_prph(trans, addr, BIT(val));\n\t\t\tbreak;\n\t\tcase PRPH_CLEARBIT:\n\t\t\tiwl_clear_bits_prph(trans, addr, BIT(val));\n\t\t\tbreak;\n\t\tcase PRPH_BLOCKBIT:\n\t\t\tif (iwl_read_prph(trans, addr) & BIT(val)) {\n\t\t\t\tIWL_ERR(trans,\n\t\t\t\t\t\"BIT(%u) in address 0x%x is 1, stopping FW configuration\\n\",\n\t\t\t\t\tval, addr);\n\t\t\t\tgoto monitor;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tIWL_ERR(trans, \"FW debug - unknown OP %d\\n\",\n\t\t\t\tdest->reg_ops[i].op);\n\t\t\tbreak;\n\t\t}\n\t}\n\nmonitor:\n\tif (dest->monitor_mode == EXTERNAL_MODE && trans->dbg.fw_mon[0].size) {\n\t\tiwl_write_prph(trans, le32_to_cpu(dest->base_reg),\n\t\t\t       trans->dbg.fw_mon[0].physical >>\n\t\t\t       dest->base_shift);\n\t\tif (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_8000)\n\t\t\tiwl_write_prph(trans, le32_to_cpu(dest->end_reg),\n\t\t\t\t       (trans->dbg.fw_mon[0].physical +\n\t\t\t\t\ttrans->dbg.fw_mon[0].size - 256) >>\n\t\t\t\t\t\tdest->end_shift);\n\t\telse\n\t\t\tiwl_write_prph(trans, le32_to_cpu(dest->end_reg),\n\t\t\t\t       (trans->dbg.fw_mon[0].physical +\n\t\t\t\t\ttrans->dbg.fw_mon[0].size) >>\n\t\t\t\t\t\tdest->end_shift);\n\t}\n}","target":0,"code_token_length":749,"total_token_length":985,"max_tokens_setting":1024}
+{"idx":446061,"func":"LZWPostEncode(TIFF* tif)\n{\n\tregister LZWCodecState *sp = EncoderState(tif);\n\tuint8* op = tif->tif_rawcp;\n\tlong nextbits = sp->lzw_nextbits;\n\tunsigned long nextdata = sp->lzw_nextdata;\n\tlong outcount = sp->enc_outcount;\n\tint nbits = sp->lzw_nbits;\n\n\tif (op > sp->enc_rawlimit) {\n\t\ttif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);\n\t\tif( !TIFFFlushData1(tif) )\n                    return 0;\n\t\top = tif->tif_rawdata;\n\t}\n\tif (sp->enc_oldcode != (hcode_t) -1) {\n                int free_ent = sp->lzw_free_ent;\n\n\t\tPutNextCode(op, sp->enc_oldcode);\n\t\tsp->enc_oldcode = (hcode_t) -1;\n                free_ent ++;\n\n                if (free_ent == CODE_MAX-1) {\n                        \/* table is full, emit clear code and reset *\/\n                        outcount = 0;\n                        PutNextCode(op, CODE_CLEAR);\n                        nbits = BITS_MIN;\n                } else {\n                        \/*\n                        * If the next entry is going to be too big for\n                        * the code size, then increase it, if possible.\n                        *\/\n                        if (free_ent > sp->lzw_maxcode) {\n                                nbits++;\n                                assert(nbits <= BITS_MAX);\n                        }\n                }\n\t}\n\tPutNextCode(op, CODE_EOI);\n        \/* Explicit 0xff masking to make icc -check=conversions happy *\/\n\tif (nextbits > 0) \n\t\t*op++ = (unsigned char)((nextdata << (8-nextbits))&0xff);\n\ttif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);\n\treturn (1);\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":292200,"func":"inbound_ping_reply (session *sess, char *timestring, char *from,\n\t\t\t\t\t\t  const message_tags_data *tags_data)\n{\n\tunsigned long tim, nowtim, dif;\n\tint lag = 0;\n\tchar outbuf[64];\n\n\tif (strncmp (timestring, \"LAG\", 3) == 0)\n\t{\n\t\ttimestring += 3;\n\t\tlag = 1;\n\t}\n\n\ttim = strtoul (timestring, NULL, 10);\n\tnowtim = make_ping_time ();\n\tdif = nowtim - tim;\n\n\tsess->server->ping_recv = time (0);\n\n\tif (lag)\n\t{\n\t\tsess->server->lag_sent = 0;\n\t\tsess->server->lag = dif;\n\t\tfe_set_lag (sess->server, dif);\n\t\treturn;\n\t}\n\n\tif (atol (timestring) == 0)\n\t{\n\t\tif (sess->server->lag_sent)\n\t\t\tsess->server->lag_sent = 0;\n\t\telse\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_PINGREP, sess, from, \"?\", NULL, NULL, 0,\n\t\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\t} else\n\t{\n\t\tg_snprintf (outbuf, sizeof (outbuf), \"%ld.%03ld\", dif \/ 1000, dif % 1000);\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_PINGREP, sess, from, outbuf, NULL, NULL, 0,\n\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\t}\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":232314,"func":"static void FixSDTPInTRAF(GF_MovieFragmentBox *moof)\n{\n\tu32 k;\n\tif (!moof)\n\t\treturn;\n\n\tfor (k = 0; k < gf_list_count(moof->TrackList); k++) {\n\t\tGF_TrackFragmentBox *traf = gf_list_get(moof->TrackList, k);\n\t\tif (traf->sdtp) {\n\t\t\tGF_TrackFragmentRunBox *trun;\n\t\t\tu32 j = 0, sample_index = 0;\n\n\t\t\tif (traf->sdtp->sampleCount == gf_list_count(traf->TrackRuns)) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Warning: TRAF box of track id=%u contains a SDTP. Converting to TRUN sample flags.\\n\", traf->tfhd->trackID));\n\t\t\t}\n\n\t\t\twhile ((trun = (GF_TrackFragmentRunBox*)gf_list_enum(traf->TrackRuns, &j))) {\n\t\t\t\tu32 i;\n\t\t\t\ttrun->flags |= GF_ISOM_TRUN_FLAGS;\n\t\t\t\tfor (i=0; i<trun->nb_samples; i++) {\n\t\t\t\t\tGF_TrunEntry *entry = &trun->samples[i];\n\t\t\t\t\tconst u8 info = traf->sdtp->sample_info[sample_index];\n\t\t\t\t\tentry->flags |= GF_ISOM_GET_FRAG_DEPEND_FLAGS(info >> 6, info >> 4, info >> 2, info);\n\t\t\t\t\tsample_index++;\n\t\t\t\t\tif (sample_index > traf->sdtp->sampleCount) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Error: TRAF box of track id=%u contained an inconsistent SDTP.\\n\", traf->tfhd->trackID));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (sample_index < traf->sdtp->sampleCount) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Error: TRAF box of track id=%u list less samples than SDTP.\\n\", traf->tfhd->trackID));\n\t\t\t}\n\t\t\tgf_isom_box_del_parent(&traf->child_boxes, (GF_Box*)traf->sdtp);\n\t\t\ttraf->sdtp = NULL;\n\t\t}\n\t}\n}","target":0,"code_token_length":498,"total_token_length":734,"max_tokens_setting":1024}
+{"idx":275509,"func":"njs_vm_value_to_bytes(njs_vm_t *vm, njs_str_t *dst, njs_value_t *src)\n{\n    u_char              *start;\n    size_t              size, length, offset;\n    njs_int_t           ret;\n    njs_value_t         value;\n    njs_typed_array_t   *array;\n    njs_array_buffer_t  *buffer;\n\n    if (njs_slow_path(src == NULL)) {\n        return NJS_ERROR;\n    }\n\n    ret = NJS_OK;\n    value = *src;\n\n    switch (value.type) {\n    case NJS_TYPED_ARRAY:\n    case NJS_DATA_VIEW:\n    case NJS_ARRAY_BUFFER:\n\n        if (value.type != NJS_ARRAY_BUFFER) {\n            array = njs_typed_array(&value);\n            buffer = njs_typed_array_buffer(array);\n            offset = array->offset;\n            length = array->byte_length;\n\n        } else {\n            buffer = njs_array_buffer(&value);\n            offset = 0;\n            length = buffer->size;\n        }\n\n        if (njs_slow_path(njs_is_detached_buffer(buffer))) {\n            njs_type_error(vm, \"detached buffer\");\n            return NJS_ERROR;\n        }\n\n        dst->start = &buffer->u.u8[offset];\n        dst->length = length;\n        break;\n\n    default:\n        ret = njs_value_to_string(vm, &value, &value);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NJS_ERROR;\n        }\n\n        size = value.short_string.size;\n\n        if (size != NJS_STRING_LONG) {\n            start = njs_mp_alloc(vm->mem_pool, size);\n            if (njs_slow_path(start == NULL)) {\n                njs_memory_error(vm);\n                return NJS_ERROR;\n            }\n\n            memcpy(start, value.short_string.start, size);\n\n        } else {\n            size = value.long_string.size;\n            start = value.long_string.data->start;\n        }\n\n        dst->length = size;\n        dst->start = start;\n    }\n\n    return ret;\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":286733,"func":"SWTPM_NVRAM_GetPlainData(unsigned char **plain, uint32_t *plain_length,\n                         const unsigned char *data, uint32_t length,\n                         uint16_t tag_data,\n                         uint8_t hdrversion)\n{\n    TPM_RESULT rc = 0;\n    tlv_data td[1];\n\n    switch (hdrversion) {\n    case 1:\n        *plain = malloc(length);\n        if (*plain) {\n            memcpy(*plain, data, length);\n            *plain_length = length;\n        } else {\n            logprintf(STDERR_FILENO,\n                      \"Could not allocate %u bytes.\\n\", length);\n            rc = TPM_FAIL;\n        }\n    break;\n\n    case 2:\n        if (!tlv_data_find_tag(data, length, tag_data, &td[0])) {\n            logprintf(STDERR_FILENO,\n                      \"Could not find plain data in byte stream.\\n\");\n            rc = TPM_FAIL;\n            break;\n        }\n        *plain = malloc(td->tlv.length);\n        if (*plain) {\n            memcpy(*plain, td->u.const_ptr, td->tlv.length);\n            *plain_length = td->tlv.length;\n        } else {\n            logprintf(STDERR_FILENO,\n                      \"Could not allocate %u bytes.\\n\", td->tlv.length);\n            rc = TPM_FAIL;\n        }\n    break;\n    }\n\n    return rc;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":230115,"func":"static int update_credential(struct config_module * config, json_t * j_params, const char * username, const char * credential_id, int status) {\n  json_t * j_query;\n  char * username_escaped, * mod_name_escaped, * username_clause;\n  int res, ret;\n\n  username_escaped = h_escape_string_with_quotes(config->conn, username);\n  mod_name_escaped = h_escape_string_with_quotes(config->conn, json_string_value(json_object_get(j_params, \"mod_name\")));\n  username_clause = msprintf(\" = (SELECT gswu_id FROM \"G_TABLE_WEBAUTHN_USER\" WHERE UPPER(gswu_username) = UPPER(%s) AND gswu_mod_name = %s)\", username_escaped, mod_name_escaped);\n  j_query = json_pack(\"{sss{si}s{sss{ssss}}}\",\n                      \"table\",\n                      G_TABLE_WEBAUTHN_CREDENTIAL,\n                      \"set\",\n                        \"gswc_status\",\n                        status,\n                      \"where\",\n                        \"gswc_credential_id\",\n                        credential_id,\n                        \"gswu_id\",\n                          \"operator\",\n                          \"raw\",\n                          \"value\",\n                          username_clause);\n  o_free(username_clause);\n  o_free(username_escaped);\n  o_free(mod_name_escaped);\n  res = h_update(config->conn, j_query, NULL);\n  json_decref(j_query);\n  if (res == H_OK) {\n    ret = G_OK;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"get_credential - Error executing j_query\");\n    config->glewlwyd_module_callback_metrics_increment_counter(config, GLWD_METRICS_DATABSE_ERROR, 1, NULL);\n    ret = G_ERROR_DB;\n  }\n  return ret;\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":235763,"func":"Status ValidateShapes(OpKernelContext* ctx, const Tensor& hypothesis_indices,\n                      const Tensor& hypothesis_values,\n                      const Tensor& hypothesis_shape,\n                      const Tensor& truth_indices, const Tensor& truth_values,\n                      const Tensor& truth_shape) {\n  if (!TensorShapeUtils::IsMatrix(hypothesis_indices.shape()))\n    return errors::InvalidArgument(\n        \"hypothesis_indices should be a matrix, but got shape: \",\n        hypothesis_indices.shape().DebugString());\n  if (!TensorShapeUtils::IsMatrix(truth_indices.shape()))\n    return errors::InvalidArgument(\n        \"truth_indices should be a matrix, but got shape: \",\n        truth_indices.shape().DebugString());\n  if (!TensorShapeUtils::IsVector(hypothesis_values.shape()))\n    return errors::InvalidArgument(\n        \"hypothesis_values should be a vector, but got shape: \",\n        hypothesis_values.shape().DebugString());\n  if (!TensorShapeUtils::IsVector(truth_values.shape()))\n    return errors::InvalidArgument(\n        \"truth_values should be a vector, but got shape: \",\n        truth_values.shape().DebugString());\n  if (!TensorShapeUtils::IsVector(hypothesis_shape.shape()))\n    return errors::InvalidArgument(\n        \"hypothesis_shape should be a vector, but got shape: \",\n        hypothesis_shape.shape().DebugString());\n  if (!TensorShapeUtils::IsVector(truth_shape.shape()))\n    return errors::InvalidArgument(\n        \"truth_shape should be a vector, but got shape: \",\n        truth_shape.shape().DebugString());\n  if (hypothesis_values.NumElements() != hypothesis_indices.dim_size(0))\n    return errors::InvalidArgument(\n        \"Expected hypothesis_values.NumElements == \"\n        \"#rows(hypothesis_indices), their shapes are: \",\n        hypothesis_values.shape().DebugString(), \" and \",\n        hypothesis_indices.shape().DebugString());\n  if (hypothesis_shape.NumElements() != hypothesis_indices.dim_size(1))\n    return errors::InvalidArgument(\n        \"Expected hypothesis_shape.NumElements == \"\n        \"#cols(hypothesis_indices), their shapes are: \",\n        hypothesis_shape.shape().DebugString(), \" and \",\n        hypothesis_indices.shape().DebugString());\n  if (truth_shape.NumElements() < 2)\n    return errors::InvalidArgument(\n        \"Input SparseTensors must have rank at least 2, but truth_shape \"\n        \"rank is: \",\n        truth_shape.NumElements());\n  if (truth_values.NumElements() != truth_indices.dim_size(0))\n    return errors::InvalidArgument(\n        \"Expected truth_values.NumElements == \"\n        \"#rows(truth_indices), their shapes are: \",\n        truth_values.shape().DebugString(), \" and \",\n        truth_indices.shape().DebugString());\n  if (truth_shape.NumElements() != truth_indices.dim_size(1))\n    return errors::InvalidArgument(\n        \"Expected truth_shape.NumElements == \"\n        \"#cols(truth_indices), their shapes are: \",\n        truth_shape.shape().DebugString(), \" and \",\n        truth_indices.shape().DebugString());\n  if (truth_shape.NumElements() != hypothesis_shape.NumElements())\n    return errors::InvalidArgument(\n        \"Expected truth and hypothesis to have matching ranks, but \"\n        \"their shapes are: \",\n        truth_shape.shape().DebugString(), \" and \",\n        hypothesis_shape.shape().DebugString());\n\n  return Status::OK();\n}","target":0,"code_token_length":691,"total_token_length":927,"max_tokens_setting":1024}
+{"idx":505658,"func":"static int smtp_command_parse(struct smtp_command_parser *parser)\n{\n\tconst unsigned char *begin;\n\tsize_t size, old_bytes = 0;\n\tint ret;\n\n\twhile ((ret = i_stream_read_data(parser->input, &begin, &size,\n\t\t\t\t\t old_bytes)) > 0) {\n\t\tparser->cur = begin;\n\t\tparser->end = parser->cur + size;\n\n\t\tret = smtp_command_parse_line(parser);\n\t\ti_stream_skip(parser->input, parser->cur - begin);\n\t\tif (ret != 0)\n\t\t\treturn ret;\n\t\told_bytes = i_stream_get_data_size(parser->input);\n\t}\n\n\tif (ret == -2) {\n\t\t\/* should not really happen *\/\n\t\tsmtp_command_parser_error(parser,\n\t\t\tSMTP_COMMAND_PARSE_ERROR_LINE_TOO_LONG,\n\t\t\t\"%s line is too long\",\n\t\t\t(parser->auth_response ?\n\t\t\t\t\"AUTH response\" : \"Command\"));\n\t\treturn -1;\n\t}\n\tif (ret < 0) {\n\t\ti_assert(parser->input->eof);\n\t\tif (parser->input->stream_errno == 0) {\n\t\t\tif (parser->state.state == SMTP_COMMAND_PARSE_STATE_INIT)\n\t\t\t\tret = -2;\n\t\t\tsmtp_command_parser_error(parser,\n\t\t\t\tSMTP_COMMAND_PARSE_ERROR_BROKEN_COMMAND,\n\t\t\t\t\"Premature end of input\");\n\t\t} else {\n\t\t\tsmtp_command_parser_error(parser,\n\t\t\t\tSMTP_COMMAND_PARSE_ERROR_BROKEN_STREAM,\n\t\t\t\t\"Stream error: %s\",\n\t\t\t\ti_stream_get_error(parser->input));\n\t\t}\n\t}\n\treturn ret;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":439107,"func":"static MagickBooleanType ReadPSDChannelRLE(Image *image,const PSDInfo *psd_info,\n  const ssize_t type,MagickOffsetType *sizes,ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  size_t\n    length,\n    row_size;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *compact_pixels,\n    *pixels;\n\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n       \"      layer data is RLE compressed\");\n\n  row_size=GetPSDRowSize(image);\n  pixels=(unsigned char *) AcquireQuantumMemory(row_size,sizeof(*pixels));\n  if (pixels == (unsigned char *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n\n  length=0;\n  for (y=0; y < (ssize_t) image->rows; y++)\n    if ((MagickOffsetType) length < sizes[y])\n      length=(size_t) sizes[y];\n\n  if (length > (row_size+512))\n    {\n      pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n      ThrowBinaryException(ResourceLimitError,\"InvalidLength\",image->filename);\n    }\n\n  compact_pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels));\n  if (compact_pixels == (unsigned char *) NULL)\n    {\n      pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n      ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n        image->filename);\n    }\n\n  (void) memset(compact_pixels,0,length*sizeof(*compact_pixels));\n\n  status=MagickTrue;\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    status=MagickFalse;\n\n    count=ReadBlob(image,(size_t) sizes[y],compact_pixels);\n    if (count != (ssize_t) sizes[y])\n      break;\n\n    count=DecodePSDPixels((size_t) sizes[y],compact_pixels,\n      (ssize_t) (image->depth == 1 ? 123456 : image->depth),row_size,pixels);\n    if (count != (ssize_t) row_size)\n      break;\n\n    status=ReadPSDChannelPixels(image,psd_info->channels,y,type,pixels,\n      exception);\n    if (status == MagickFalse)\n      break;\n  }\n\n  compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);\n  pixels=(unsigned char *) RelinquishMagickMemory(pixels);\n  return(status);\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":221078,"func":"u32 gf_bs_read_ue_log_idx3(GF_BitStream *bs, const char *fname, s32 idx1, s32 idx2, s32 idx3)\n{\n\tu32 val=0, code;\n\ts32 nb_lead = -1;\n\tu32 bits = 0;\n\tfor (code=0; !code; nb_lead++) {\n\t\tif (nb_lead>=32) {\n\t\t\tbreak;\n\t\t}\n\t\tcode = gf_bs_read_int(bs, 1);\n\t\tbits++;\n\t}\n\n\tif (nb_lead>=32) {\n\t\t\/\/gf_bs_read_int keeps returning 0 on EOS, so if no more bits available, rbsp was truncated otherwise code is broken in rbsp)\n\t\t\/\/we only test once nb_lead>=32 to avoid testing at each bit read\n\t\tif (!gf_bs_available(bs)) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[Core] exp-golomb read failed, not enough bits in bitstream !\\n\"));\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[Core] corrupted exp-golomb code, %d leading zeros, max 31 allowed !\\n\", nb_lead));\n\t\t}\n\t\treturn 0;\n\t}\n\n\tif (nb_lead) {\n\t\tu32 leads=1;\n\t\tval = gf_bs_read_int(bs, nb_lead);\n\t\tleads <<= nb_lead;\n\t\tleads -= 1;\n\t\tval += leads;\n\/\/\t\tval += (1 << nb_lead) - 1;\n\t\tbits += nb_lead;\n\t}\n\n\tif (fname) {\n\t\tgf_bs_log_idx(bs, bits, fname, val, idx1, idx2, idx3);\n\t}\n\treturn val;\n}","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":379657,"func":"R_API void r_anal_var_set_access(RAnalVar *var, const char *reg, ut64 access_addr, int access_type, st64 stackptr) {\n\tr_return_if_fail (var);\n\tst64 offset = access_addr - var->fcn->addr;\n\n\t\/\/ accesses are stored ordered by offset, use binary search to get the matching existing or the index to insert a new one\n\tsize_t index;\n\tr_vector_lower_bound (&var->accesses, offset, index, ACCESS_CMP);\n\tRAnalVarAccess *acc = NULL;\n\tif (index < var->accesses.len) {\n\t\tacc = r_vector_index_ptr (&var->accesses, index);\n\t}\n\tif (!acc || acc->offset != offset) {\n\t\tacc = r_vector_insert (&var->accesses, index, NULL);\n\t\tacc->offset = offset;\n\t\tacc->type = 0;\n\t}\n\n\tacc->type |= (ut8)access_type;\n\tacc->stackptr = stackptr;\n\tacc->reg = r_str_constpool_get (&var->fcn->anal->constpool, reg);\n\n\t\/\/ add the inverse reference from the instruction to the var\n\tRPVector *inst_accesses = ht_up_find (var->fcn->inst_vars, (ut64)offset, NULL);\n\tif (!inst_accesses) {\n\t\tinst_accesses = r_pvector_new (NULL);\n\t\tif (!inst_accesses) {\n\t\t\treturn;\n\t\t}\n\t\tht_up_insert (var->fcn->inst_vars, (ut64)offset, inst_accesses);\n\t}\n\tif (!r_pvector_contains (inst_accesses, var)) {\n\t\tr_pvector_push (inst_accesses, var);\n\t}\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":436138,"func":"\nstatic void io_ring_exit_work(struct work_struct *work)\n{\n\tstruct io_ring_ctx *ctx = container_of(work, struct io_ring_ctx, exit_work);\n\tunsigned long timeout = jiffies + HZ * 60 * 5;\n\tstruct io_tctx_exit exit;\n\tstruct io_tctx_node *node;\n\tint ret;\n\n\t\/*\n\t * If we're doing polled IO and end up having requests being\n\t * submitted async (out-of-line), then completions can come in while\n\t * we're waiting for refs to drop. We need to reap these manually,\n\t * as nobody else will be looking for them.\n\t *\/\n\tdo {\n\t\tio_uring_try_cancel_requests(ctx, NULL, true);\n\t\tif (ctx->sq_data) {\n\t\t\tstruct io_sq_data *sqd = ctx->sq_data;\n\t\t\tstruct task_struct *tsk;\n\n\t\t\tio_sq_thread_park(sqd);\n\t\t\ttsk = sqd->thread;\n\t\t\tif (tsk && tsk->io_uring && tsk->io_uring->io_wq)\n\t\t\t\tio_wq_cancel_cb(tsk->io_uring->io_wq,\n\t\t\t\t\t\tio_cancel_ctx_cb, ctx, true);\n\t\t\tio_sq_thread_unpark(sqd);\n\t\t}\n\n\t\tWARN_ON_ONCE(time_after(jiffies, timeout));\n\t} while (!wait_for_completion_timeout(&ctx->ref_comp, HZ\/20));\n\n\tinit_completion(&exit.completion);\n\tinit_task_work(&exit.task_work, io_tctx_exit_cb);\n\texit.ctx = ctx;\n\t\/*\n\t * Some may use context even when all refs and requests have been put,\n\t * and they are free to do so while still holding uring_lock or\n\t * completion_lock, see io_req_task_submit(). Apart from other work,\n\t * this lock\/unlock section also waits them to finish.\n\t *\/\n\tmutex_lock(&ctx->uring_lock);\n\twhile (!list_empty(&ctx->tctx_list)) {\n\t\tWARN_ON_ONCE(time_after(jiffies, timeout));\n\n\t\tnode = list_first_entry(&ctx->tctx_list, struct io_tctx_node,\n\t\t\t\t\tctx_node);\n\t\t\/* don't spin on a single task if cancellation failed *\/\n\t\tlist_rotate_left(&ctx->tctx_list);\n\t\tret = task_work_add(node->task, &exit.task_work, TWA_SIGNAL);\n\t\tif (WARN_ON_ONCE(ret))\n\t\t\tcontinue;\n\t\twake_up_process(node->task);\n\n\t\tmutex_unlock(&ctx->uring_lock);\n\t\twait_for_completion(&exit.completion);\n\t\tmutex_lock(&ctx->uring_lock);\n\t}\n\tmutex_unlock(&ctx->uring_lock);\n\tspin_lock_irq(&ctx->completion_lock);\n\tspin_unlock_irq(&ctx->completion_lock);\n\n\tio_ring_ctx_free(ctx);","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":463220,"func":"static int find_cb(void *rock, const char *key, size_t keylen,\n                   const char *data, size_t datalen)\n{\n    struct find_rock *frock = (struct find_rock *) rock;\n    const char *mboxname, *entry, *userid;\n    unsigned int uid;\n    char newkey[MAX_MAILBOX_PATH+1];\n    size_t newkeylen;\n    struct buf value = BUF_INITIALIZER;\n    struct annotate_metadata mdata;\n    int r;\n\n    assert(keylen < MAX_MAILBOX_PATH);\n\n    r = split_key(frock->d, key, keylen, &mboxname,\n                  &uid, &entry, &userid);\n    if (r) {\n        syslog(LOG_ERR, \"find_cb: can't split bogus key %*.s\", (int)keylen, key);\n        return r;\n    }\n\n    newkeylen = make_key(mboxname, uid, entry, userid, newkey, sizeof(newkey));\n    if (keylen != newkeylen || strncmp(newkey, key, keylen)) {\n        syslog(LOG_ERR, \"find_cb: bogus key %s %d %s %s (%d %d)\", mboxname, uid, entry, userid, (int)keylen, (int)newkeylen);\n    }\n\n    r = split_attribs(data, datalen, &value, &mdata);\n    if (r) {\n        buf_free(&value);\n        return r;\n    }\n#if DEBUG\n    syslog(LOG_ERR, \"find_cb: found key %s in %s with modseq \" MODSEQ_FMT,\n            key_as_string(frock->d, key, keylen), frock->d->filename, mdata.modseq);\n#endif\n\n    if (frock->since_modseq && frock->since_modseq >= mdata.modseq) {\n#if DEBUG\n        syslog(LOG_ERR,\"find_cb: ignoring key %s: \" \" modseq \" MODSEQ_FMT \" is <= \" MODSEQ_FMT,\n                key_as_string(frock->d, key, keylen), mdata.modseq, frock->since_modseq);\n#endif\n        buf_free(&value);\n        return 0;\n    }\n\n    if (((mdata.flags & ANNOTATE_FLAG_DELETED) || !buf_len(&value)) &&\n        !(frock->flags & ANNOTATE_TOMBSTONES)) {\n#if DEBUG\n    syslog(LOG_ERR, \"find_cb: ignoring key %s, tombstones are ignored\",\n            key_as_string(frock->d, key, keylen));\n#endif\n        buf_free(&value);\n        return 0;\n    }\n\n    if (!r) r = frock->proc(mboxname, uid, entry, userid, &value, &mdata,\n                            frock->rock);\n    buf_free(&value);\n    return r;\n}","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":462410,"func":"AcceptConnReq(ptcplstn_t *pLstn, int *newSock, prop_t **peerName, prop_t **peerIP)\n{\n\tint sockflags;\n\tstruct sockaddr_storage addr;\n\tsocklen_t addrlen = sizeof(addr);\n\tint iNewSock = -1;\n\n\tDEFiRet;\n\n\tiNewSock = accept(pLstn->sock, (struct sockaddr*) &addr, &addrlen);\n\tif(iNewSock < 0) {\n\t\tif(errno == EAGAIN || errno == EWOULDBLOCK || errno == EMFILE)\n\t\t\tABORT_FINALIZE(RS_RET_NO_MORE_DATA);\n\t\tABORT_FINALIZE(RS_RET_ACCEPT_ERR);\n\t}\n\n\tif(pLstn->pSrv->bKeepAlive)\n\t\tEnableKeepAlive(pLstn, iNewSock);\/* we ignore errors, best to do! *\/\n\n\tCHKiRet(getPeerNames(peerName, peerIP, (struct sockaddr *) &addr, pLstn->pSrv->bUnixSocket));\n\n\t\/* set the new socket to non-blocking IO *\/\n\tif((sockflags = fcntl(iNewSock, F_GETFL)) != -1) {\n\t\tsockflags |= O_NONBLOCK;\n\t\t\/* SETFL could fail too, so get it caught by the subsequent\n\t\t * error check.\n\t\t *\/\n\t\tsockflags = fcntl(iNewSock, F_SETFL, sockflags);\n\t}\n\tif(sockflags == -1) {\n\t\tDBGPRINTF(\"error %d setting fcntl(O_NONBLOCK) on tcp socket %d\", errno, iNewSock);\n\t\tprop.Destruct(peerName);\n\t\tprop.Destruct(peerIP);\n\t\tABORT_FINALIZE(RS_RET_IO_ERROR);\n\t}\n\n\t*newSock = iNewSock;\n\nfinalize_it:\n\tif(iRet != RS_RET_OK) {\n\t\t\/* the close may be redundant, but that doesn't hurt... *\/\n\t\tif(iNewSock != -1)\n\t\t\tclose(iNewSock);\n\t}\n\n\tRETiRet;\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":413683,"func":"static void analPaths(RCoreAnalPaths *p, PJ *pj) {\n\tRAnalBlock *cur = p->cur;\n\tif (!cur) {\n\t\t\/\/ eprintf (\"eof\\n\");\n\t\treturn;\n\t}\n\t\/* handle ^C *\/\n\tif (r_cons_is_breaked ()) {\n\t\treturn;\n\t}\n\tdict_set (&p->visited, cur->addr, 1, NULL);\n\tr_list_append (p->path, cur);\n\tif (p->followDepth && --p->followDepth == 0) {\n\t\treturn;\n\t}\n\tif (p->toBB && cur->addr == p->toBB->addr) {\n\t\tif (!printAnalPaths (p, pj)) {\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tRAnalBlock *c = cur;\n\t\tut64 j = cur->jump;\n\t\tut64 f = cur->fail;\n\t\tanalPathFollow (p, j, pj);\n\t\tcur = c;\n\t\tanalPathFollow (p, f, pj);\n\t\tif (p->followCalls) {\n\t\t\tint i;\n\t\t\tfor (i = 0; i < cur->op_pos_size; i++) {\n\t\t\t\tut64 addr = cur->addr + cur->op_pos[i];\n\t\t\t\tRAnalOp *op = r_core_anal_op (p->core, addr, R_ANAL_OP_MASK_BASIC);\n\t\t\t\tif (op && op->type == R_ANAL_OP_TYPE_CALL) {\n\t\t\t\t\tanalPathFollow (p, op->jump, pj);\n\t\t\t\t}\n\t\t\t\tcur = c;\n\t\t\t\tr_anal_op_free (op);\n\t\t\t}\n\t\t}\n\t}\n\tp->cur = r_list_pop (p->path);\n\tdict_del (&p->visited, cur->addr);\n\tif (p->followDepth) {\n\t\tp->followDepth++;\n\t}\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":508309,"func":"static bool setup_natural_join_row_types(THD *thd,\n                                         List<TABLE_LIST> *from_clause,\n                                         Name_resolution_context *context)\n{\n  DBUG_ENTER(\"setup_natural_join_row_types\");\n  thd->where= \"from clause\";\n  if (from_clause->elements == 0)\n    DBUG_RETURN(false); \/* We come here in the case of UNIONs. *\/\n\n  \/* \n     Do not redo work if already done:\n     1) for stored procedures,\n     2) for multitable update after lock failure and table reopening.\n  *\/\n  if (!context->select_lex->first_natural_join_processing)\n  {\n    context->first_name_resolution_table= context->natural_join_first_table;\n    DBUG_PRINT(\"info\", (\"using cached setup_natural_join_row_types\"));\n    DBUG_RETURN(false);\n  }\n\n  List_iterator_fast<TABLE_LIST> table_ref_it(*from_clause);\n  TABLE_LIST *table_ref; \/* Current table reference. *\/\n  \/* Table reference to the left of the current. *\/\n  TABLE_LIST *left_neighbor;\n  \/* Table reference to the right of the current. *\/\n  TABLE_LIST *right_neighbor= NULL;\n\n  \/* Note that tables in the list are in reversed order *\/\n  for (left_neighbor= table_ref_it++; left_neighbor ; )\n  {\n    table_ref= left_neighbor;\n    do\n    {\n      left_neighbor= table_ref_it++;\n    }\n    while (left_neighbor && left_neighbor->sj_subq_pred);\n\n    if (store_top_level_join_columns(thd, table_ref,\n                                     left_neighbor, right_neighbor))\n      DBUG_RETURN(true);\n    if (left_neighbor)\n    {\n      TABLE_LIST *first_leaf_on_the_right;\n      first_leaf_on_the_right= table_ref->first_leaf_for_name_resolution();\n      left_neighbor->next_name_resolution_table= first_leaf_on_the_right;\n    }\n    right_neighbor= table_ref;\n  }\n\n  \/*\n    Store the top-most, left-most NATURAL\/USING join, so that we start\n    the search from that one instead of context->table_list. At this point\n    right_neighbor points to the left-most top-level table reference in the\n    FROM clause.\n  *\/\n  DBUG_ASSERT(right_neighbor);\n  context->first_name_resolution_table=\n    right_neighbor->first_leaf_for_name_resolution();\n  \/*\n    This is only to ensure that first_name_resolution_table doesn't\n    change on re-execution\n  *\/\n  context->natural_join_first_table= context->first_name_resolution_table;\n  context->select_lex->first_natural_join_processing= false;\n  DBUG_RETURN (false);\n}","target":0,"code_token_length":544,"total_token_length":780,"max_tokens_setting":1024}
+{"idx":222673,"func":"void get_in_jail(void)\n{\n\tstruct passwd *pw;\n\tuid_t uid;\n\tgid_t gid;\n\n\tpw = getpwnam(TMATE_JAIL_USER);\n\tif (!pw) {\n\t\ttmate_fatal(\"Cannot get the \/etc\/passwd entry for %s\",\n\t\t\t    TMATE_JAIL_USER);\n\t}\n\tuid = pw->pw_uid;\n\tgid = pw->pw_gid;\n\n\tif (getuid() != 0)\n\t\ttmate_fatal(\"Need root privileges to create the jail\");\n\n\tif (chroot(TMATE_WORKDIR \"\/jail\") < 0)\n\t\ttmate_fatal(\"Cannot chroot()\");\n\n\tif (chdir(\"\/\") < 0)\n\t\ttmate_fatal(\"Cannot chdir()\");\n\n#ifdef IS_LINUX\n\tif (unshare(CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNS | CLONE_NEWNET) < 0)\n\t\ttmate_fatal(\"Cannot create new namespace\");\n#endif\n\n\tif (setgroups(1, (gid_t[]){gid}) < 0)\n\t\ttmate_fatal(\"Cannot setgroups()\");\n\n#if defined(HAVE_SETRESGID)\n\tif (setresgid(gid, gid, gid) < 0)\n\t\ttmate_fatal(\"Cannot setresgid() %d\", gid);\n#elif defined(HAVE_SETREGID)\n\tif (setregid(gid, gid) < 0)\n\t\ttmate_fatal(\"Cannot setregid()\");\n#else\n\tif (setgid(gid) < 0)\n\t\ttmate_fatal(\"Cannot setgid()\");\n#endif\n\n#if defined(HAVE_SETRESUID)\n\tif (setresuid(uid, uid, uid) < 0)\n\t\ttmate_fatal(\"Cannot setresuid()\");\n#elif defined(HAVE_SETREUID)\n\tif (setreuid(uid, uid) < 0)\n\t\ttmate_fatal(\"Cannot setreuid()\");\n#else\n\tif (setuid(uid) < 0)\n\t\ttmate_fatal(\"Cannot setuid()\");\n#endif\n\n\tnice(1);\n\n\ttmate_debug(\"Dropped priviledges to %s (%d,%d), jailed in %s\",\n\t\t    TMATE_JAIL_USER, uid, gid, TMATE_WORKDIR \"\/jail\");\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":387825,"func":"void InstanceKlass::oop_print_on(oop obj, outputStream* st) {\n  Klass::oop_print_on(obj, st);\n\n  if (this == SystemDictionary::String_klass()) {\n    typeArrayOop value  = java_lang_String::value(obj);\n    juint        length = java_lang_String::length(obj);\n    if (value != NULL &&\n        value->is_typeArray() &&\n        length <= (juint) value->length()) {\n      st->print(BULLET\"string: \");\n      java_lang_String::print(obj, st);\n      st->cr();\n      if (!WizardMode)  return;  \/\/ that is enough\n    }\n  }\n\n  st->print_cr(BULLET\"---- fields (total size %d words):\", oop_size(obj));\n  FieldPrinter print_field(st, obj);\n  do_nonstatic_fields(&print_field);\n\n  if (this == SystemDictionary::Class_klass()) {\n    st->print(BULLET\"signature: \");\n    java_lang_Class::print_signature(obj, st);\n    st->cr();\n    Klass* mirrored_klass = java_lang_Class::as_Klass(obj);\n    st->print(BULLET\"fake entry for mirror: \");\n    mirrored_klass->print_value_on_maybe_null(st);\n    st->cr();\n    Klass* array_klass = java_lang_Class::array_klass_acquire(obj);\n    st->print(BULLET\"fake entry for array: \");\n    array_klass->print_value_on_maybe_null(st);\n    st->cr();\n    st->print_cr(BULLET\"fake entry for oop_size: %d\", java_lang_Class::oop_size(obj));\n    st->print_cr(BULLET\"fake entry for static_oop_field_count: %d\", java_lang_Class::static_oop_field_count(obj));\n    Klass* real_klass = java_lang_Class::as_Klass(obj);\n    if (real_klass != NULL && real_klass->is_instance_klass()) {\n      InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field);\n    }\n  } else if (this == SystemDictionary::MethodType_klass()) {\n    st->print(BULLET\"signature: \");\n    java_lang_invoke_MethodType::print_signature(obj, st);\n    st->cr();\n  }\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":221638,"func":"LogicalResult DynamicBroadcastInDimOpLowering::matchAndRewrite(\n    mhlo::DynamicBroadcastInDimOp op, mlir::PatternRewriter& rewriter) const {\n  MLIRContext* ctx = getContext();\n\n  auto in_type = op.operand().getType().dyn_cast<RankedTensorType>();\n  auto out_type = op.getResult().getType().dyn_cast<RankedTensorType>();\n  if (!in_type || !out_type) return failure();\n\n  \/\/ Check that broadcast is right-aligned (numpy style), so that operand\n  \/\/ dimensions broadcasted to match inner-most dimensions of the output.\n  auto bcast_dims = op.broadcast_dimensions().getValues<int64_t>();\n  auto expected_bcast_dims = llvm::seq<int64_t>(\n      out_type.getRank() - in_type.getRank(), out_type.getRank());\n  if (!llvm::equal(bcast_dims, expected_bcast_dims)) return failure();\n\n  ShapeComponentAnalysis shape_component_analysis;\n  auto input_map = isNonExpandingBroadcast(\n      shape_component_analysis, op.operand(), op.output_dimensions());\n  if (!input_map) return failure();\n\n  \/\/ Resolve dynamic output dimensions for the `linalg.init_tensor` operation.\n  SmallVector<Value> output_dyn_dimensions;\n  Location loc = op.getLoc();\n  int64_t rank = out_type.getRank();\n  for (size_t d = 0; d < rank; ++d) {\n    int64_t output_dim = out_type.getShape()[d];\n\n    \/\/ Skip static output dimensions, they will be resolved from the shape.\n    if (output_dim >= 0) continue;\n\n    \/\/ Resolve the dynamic size of the output dimension.\n    Value output_dyn_dim = rewriter.create<tensor::ExtractOp>(\n        loc, op.output_dimensions(),\n        ValueRange{rewriter.create<ConstantIndexOp>(loc, d)});\n\n    \/\/ Symbolic shape analysis might have given us an i32 or i64. Cast to index.\n    if (!output_dyn_dim.getType().isIndex())\n      output_dyn_dim = rewriter.create<IndexCastOp>(loc, output_dyn_dim,\n                                                    rewriter.getIndexType());\n\n    output_dyn_dimensions.push_back(output_dyn_dim);\n  }\n\n  \/\/ Create a linalg.tensor_init operation to initialize output.\n  Value init = rewriter.create<linalg::InitTensorOp>(loc, output_dyn_dimensions,\n                                                     out_type.getShape(),\n                                                     out_type.getElementType());\n\n  \/\/ Output indexing map is an identity with `rank` number of loops.\n  AffineMap output_map = AffineMap::getMultiDimIdentityMap(rank, ctx);\n\n  \/\/ All iterators are parallel.\n  SmallVector<llvm::StringRef> iterator_types(rank, \"parallel\");\n\n  rewriter.replaceOpWithNewOp<linalg::GenericOp>(\n      op, \/*resultTensorTypes=*\/TypeRange{init.getType()},\n      \/*inputs=*\/ValueRange{op.operand()},\n      \/*outputs=*\/ValueRange{init},\n      \/*indexingMaps=*\/llvm::makeArrayRef({*input_map, output_map}),\n      \/*iteratorTypes=*\/iterator_types,\n      [&](OpBuilder& nested_builder, Location nested_loc, ValueRange args) {\n        nested_builder.create<linalg::YieldOp>(nested_loc, args[0]);\n      });\n\n  return success();\n}","target":0,"code_token_length":678,"total_token_length":914,"max_tokens_setting":1024}
+{"idx":242960,"func":"static int ssl_consume_current_message( mbedtls_ssl_context *ssl )\n{\n    \/*\n     * Consume last content-layer message and potentially\n     * update in_msglen which keeps track of the contents'\n     * consumption state.\n     *\n     * (1) Handshake messages:\n     *     Remove last handshake message, move content\n     *     and adapt in_msglen.\n     *\n     * (2) Alert messages:\n     *     Consume whole record content, in_msglen = 0.\n     *\n     * (3) Change cipher spec:\n     *     Consume whole record content, in_msglen = 0.\n     *\n     * (4) Application data:\n     *     Don't do anything - the record layer provides\n     *     the application data as a stream transport\n     *     and consumes through mbedtls_ssl_read only.\n     *\n     *\/\n\n    \/* Case (1): Handshake messages *\/\n    if( ssl->in_hslen != 0 )\n    {\n        \/* Hard assertion to be sure that no application data\n         * is in flight, as corrupting ssl->in_msglen during\n         * ssl->in_offt != NULL is fatal. *\/\n        if( ssl->in_offt != NULL )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"should never happen\" ) );\n            return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n        }\n\n        \/*\n         * Get next Handshake message in the current record\n         *\/\n\n        \/* Notes:\n         * (1) in_hslen is not necessarily the size of the\n         *     current handshake content: If DTLS handshake\n         *     fragmentation is used, that's the fragment\n         *     size instead. Using the total handshake message\n         *     size here is faulty and should be changed at\n         *     some point.\n         * (2) While it doesn't seem to cause problems, one\n         *     has to be very careful not to assume that in_hslen\n         *     is always <= in_msglen in a sensible communication.\n         *     Again, it's wrong for DTLS handshake fragmentation.\n         *     The following check is therefore mandatory, and\n         *     should not be treated as a silently corrected assertion.\n         *     Additionally, ssl->in_hslen might be arbitrarily out of\n         *     bounds after handling a DTLS message with an unexpected\n         *     sequence number, see mbedtls_ssl_prepare_handshake_record.\n         *\/\n        if( ssl->in_hslen < ssl->in_msglen )\n        {\n            ssl->in_msglen -= ssl->in_hslen;\n            memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen,\n                     ssl->in_msglen );\n\n            MBEDTLS_SSL_DEBUG_BUF( 4, \"remaining content in record\",\n                                   ssl->in_msg, ssl->in_msglen );\n        }\n        else\n        {\n            ssl->in_msglen = 0;\n        }\n\n        ssl->in_hslen   = 0;\n    }\n    \/* Case (4): Application data *\/\n    else if( ssl->in_offt != NULL )\n    {\n        return( 0 );\n    }\n    \/* Everything else (CCS & Alerts) *\/\n    else\n    {\n        ssl->in_msglen = 0;\n    }\n\n    return( 0 );\n}","target":0,"code_token_length":695,"total_token_length":931,"max_tokens_setting":1024}
+{"idx":336496,"func":"void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void *message,\n                             size_t size)\n{\n    RedCharDeviceVDIPort *dev = reds->agent_dev.get();\n    VDIChunkHeader *header;\n    AgentMsgFilterResult res;\n\n    res = agent_msg_filter_process_data(&dev->priv->write_filter,\n                                        (const uint8_t*) message, size);\n    switch (res) {\n    case AGENT_MSG_FILTER_OK:\n        break;\n    case AGENT_MSG_FILTER_DISCARD:\n        return;\n    case AGENT_MSG_FILTER_MONITORS_CONFIG:\n        reds_on_main_agent_monitors_config(reds, mcc, message, size);\n        return;\n    case AGENT_MSG_FILTER_PROTO_ERROR:\n        mcc->shutdown();\n        return;\n    }\n\n    spice_assert(dev->priv->recv_from_client_buf);\n    spice_assert(message == dev->priv->recv_from_client_buf->buf + sizeof(VDIChunkHeader));\n    \/\/ TODO - start tracking agent data per channel\n    header =  (VDIChunkHeader *)dev->priv->recv_from_client_buf->buf;\n    header->port = VDP_CLIENT_PORT;\n    header->size = size;\n    dev->priv->recv_from_client_buf->buf_used = sizeof(VDIChunkHeader) + size;\n\n    dev->priv->recv_from_client_buf_pushed = TRUE;\n    dev->write_buffer_add(dev->priv->recv_from_client_buf);\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":437277,"func":"compile_range_repeat_node(QuantNode* qn, int target_len, int empty_info,\n                          regex_t* reg, ScanEnv* env)\n{\n  int r;\n  int num_repeat = reg->num_repeat;\n\n  r = add_opcode(reg, qn->greedy ? OP_REPEAT : OP_REPEAT_NG);\n  if (r != 0) return r;\n  r = add_mem_num(reg, num_repeat); \/* OP_REPEAT ID *\/\n  reg->num_repeat++;\n  if (r != 0) return r;\n  r = add_rel_addr(reg, target_len + SIZE_OP_REPEAT_INC);\n  if (r != 0) return r;\n\n  r = entry_repeat_range(reg, num_repeat, qn->lower, qn->upper);\n  if (r != 0) return r;\n\n  r = compile_tree_empty_check(NODE_QUANT_BODY(qn), reg, empty_info, env);\n  if (r != 0) return r;\n\n  if (\n#ifdef USE_CALL\n      NODE_IS_IN_MULTI_ENTRY(qn) ||\n#endif\n      NODE_IS_IN_REAL_REPEAT(qn)) {\n    r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC_SG : OP_REPEAT_INC_NG_SG);\n  }\n  else {\n    r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC : OP_REPEAT_INC_NG);\n  }\n  if (r != 0) return r;\n  r = add_mem_num(reg, num_repeat); \/* OP_REPEAT ID *\/\n  return r;\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":259199,"func":"static int update_frag_index(MOVContext *c, int64_t offset)\n{\n    int index, i;\n    MOVFragmentIndexItem * item;\n    MOVFragmentStreamInfo * frag_stream_info;\n\n    \/\/ If moof_offset already exists in frag_index, return index to it\n    index = search_frag_moof_offset(&c->frag_index, offset);\n    if (index < c->frag_index.nb_items &&\n        c->frag_index.item[index].moof_offset == offset)\n        return index;\n\n    \/\/ offset is not yet in frag index.\n    \/\/ Insert new item at index (sorted by moof offset)\n    item = av_fast_realloc(c->frag_index.item,\n                           &c->frag_index.allocated_size,\n                           (c->frag_index.nb_items + 1) *\n                           sizeof(*c->frag_index.item));\n    if (!item)\n        return -1;\n    c->frag_index.item = item;\n\n    frag_stream_info = av_realloc_array(NULL, c->fc->nb_streams,\n                                        sizeof(*item->stream_info));\n    if (!frag_stream_info)\n        return -1;\n\n    for (i = 0; i < c->fc->nb_streams; i++) {\n        \/\/ Avoid building frag index if streams lack track id.\n        if (c->fc->streams[i]->id < 0) {\n            av_free(frag_stream_info);\n            return AVERROR_INVALIDDATA;\n        }\n\n        frag_stream_info[i].id = c->fc->streams[i]->id;\n        frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE;\n        frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE;\n        frag_stream_info[i].next_trun_dts = AV_NOPTS_VALUE;\n        frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE;\n        frag_stream_info[i].index_base = -1;\n        frag_stream_info[i].index_entry = -1;\n        frag_stream_info[i].encryption_index = NULL;\n    }\n\n    if (index < c->frag_index.nb_items)\n        memmove(c->frag_index.item + index + 1, c->frag_index.item + index,\n                (c->frag_index.nb_items - index) * sizeof(*c->frag_index.item));\n\n    item = &c->frag_index.item[index];\n    item->headers_read = 0;\n    item->current = 0;\n    item->nb_stream_info = c->fc->nb_streams;\n    item->moof_offset = offset;\n    item->stream_info = frag_stream_info;\n    c->frag_index.nb_items++;\n\n    return index;\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":233943,"func":"Value DocumentSourceUnionWith::serialize(boost::optional<ExplainOptions::Verbosity> explain) const {\n    auto collectionless = _pipeline->getContext()->ns.isCollectionlessAggregateNS();\n    if (explain) {\n        \/\/ There are several different possible states depending on the explain verbosity as well as\n        \/\/ the other stages in the pipeline:\n        \/\/  * If verbosity is queryPlanner, then the sub-pipeline should be untouched and we can\n        \/\/  explain it directly.\n        \/\/  * If verbosity is execStats or allPlansExecution, then whether or not to explain the\n        \/\/  sub-pipeline depends on if we've started reading from it. For instance, there could be a\n        \/\/  $limit stage after the $unionWith which results in only reading from the base collection\n        \/\/  branch and not the sub-pipeline.\n        Pipeline* pipeCopy = nullptr;\n        if (*explain == ExplainOptions::Verbosity::kQueryPlanner) {\n            pipeCopy = Pipeline::create(_pipeline->getSources(), _pipeline->getContext()).release();\n        } else if (*explain >= ExplainOptions::Verbosity::kExecStats &&\n                   _executionState > ExecutionProgress::kIteratingSource) {\n            \/\/ We've either exhausted the sub-pipeline or at least started iterating it. Use the\n            \/\/ cached pipeline to get the explain output since the '_pipeline' may have been\n            \/\/ modified for any optimizations or pushdowns into the initial $cursor stage.\n            pipeCopy = Pipeline::create(_cachedPipeline, _pipeline->getContext()).release();\n        } else {\n            \/\/ The plan does not require reading from the sub-pipeline, so just include the\n            \/\/ serialization in the explain output.\n            BSONArrayBuilder bab;\n            for (auto&& stage : _pipeline->serialize())\n                bab << stage;\n            auto spec = collectionless\n                ? DOC(\"pipeline\" << bab.arr())\n                : DOC(\"coll\" << _pipeline->getContext()->ns.coll() << \"pipeline\" << bab.arr());\n            return Value(DOC(getSourceName() << spec));\n        }\n\n        invariant(pipeCopy);\n        BSONObj explainLocal =\n            pExpCtx->mongoProcessInterface->preparePipelineAndExplain(pipeCopy, *explain);\n        LOGV2_DEBUG(4553501, 3, \"$unionWith attached cursor to pipeline for explain\");\n        \/\/ We expect this to be an explanation of a pipeline -- there should only be one field.\n        invariant(explainLocal.nFields() == 1);\n\n        auto spec = collectionless ? DOC(\"pipeline\" << explainLocal.firstElement())\n                                   : DOC(\"coll\" << _pipeline->getContext()->ns.coll() << \"pipeline\"\n                                                << explainLocal.firstElement());\n        return Value(DOC(getSourceName() << spec));\n    } else {\n        BSONArrayBuilder bab;\n        for (auto&& stage : _pipeline->serialize())\n            bab << stage;\n        auto spec = collectionless\n            ? DOC(\"pipeline\" << bab.arr())\n            : DOC(\"coll\" << _pipeline->getContext()->ns.coll() << \"pipeline\" << bab.arr());\n        return Value(DOC(getSourceName() << spec));\n    }\n}","target":0,"code_token_length":663,"total_token_length":899,"max_tokens_setting":1024}
+{"idx":387781,"func":"InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) {\n  const int size = InstanceKlass::size(parser.vtable_size(),\n                                       parser.itable_size(),\n                                       nonstatic_oop_map_size(parser.total_oop_map_count()),\n                                       parser.is_interface(),\n                                       parser.is_anonymous(),\n                                       should_store_fingerprint(parser.is_anonymous()));\n\n  const Symbol* const class_name = parser.class_name();\n  assert(class_name != NULL, \"invariant\");\n  ClassLoaderData* loader_data = parser.loader_data();\n  assert(loader_data != NULL, \"invariant\");\n\n  InstanceKlass* ik;\n\n  \/\/ Allocation\n  if (REF_NONE == parser.reference_type()) {\n    if (class_name == vmSymbols::java_lang_Class()) {\n      \/\/ mirror\n      ik = new (loader_data, size, THREAD) InstanceMirrorKlass(parser);\n    }\n    else if (is_class_loader(class_name, parser)) {\n      \/\/ class loader\n      ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser);\n    } else {\n      \/\/ normal\n      ik = new (loader_data, size, THREAD) InstanceKlass(parser, InstanceKlass::_misc_kind_other);\n    }\n  } else {\n    \/\/ reference\n    ik = new (loader_data, size, THREAD) InstanceRefKlass(parser);\n  }\n\n  \/\/ Check for pending exception before adding to the loader data and incrementing\n  \/\/ class count.  Can get OOM here.\n  if (HAS_PENDING_EXCEPTION) {\n    return NULL;\n  }\n\n  return ik;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":313548,"func":"static int rose_del_node(struct rose_route_struct *rose_route,\n\tstruct net_device *dev)\n{\n\tstruct rose_node  *rose_node;\n\tstruct rose_neigh *rose_neigh;\n\tint i, err = 0;\n\n\tspin_lock_bh(&rose_node_list_lock);\n\tspin_lock_bh(&rose_neigh_list_lock);\n\n\trose_node = rose_node_list;\n\twhile (rose_node != NULL) {\n\t\tif ((rose_node->mask == rose_route->mask) &&\n\t\t    (rosecmpm(&rose_route->address, &rose_node->address,\n\t\t\t      rose_route->mask) == 0))\n\t\t\tbreak;\n\t\trose_node = rose_node->next;\n\t}\n\n\tif (rose_node == NULL || rose_node->loopback) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\trose_neigh = rose_neigh_list;\n\twhile (rose_neigh != NULL) {\n\t\tif (ax25cmp(&rose_route->neighbour,\n\t\t\t    &rose_neigh->callsign) == 0 &&\n\t\t    rose_neigh->dev == dev)\n\t\t\tbreak;\n\t\trose_neigh = rose_neigh->next;\n\t}\n\n\tif (rose_neigh == NULL) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tfor (i = 0; i < rose_node->count; i++) {\n\t\tif (rose_node->neighbour[i] == rose_neigh) {\n\t\t\trose_neigh->count--;\n\n\t\t\tif (rose_neigh->count == 0 && rose_neigh->use == 0)\n\t\t\t\trose_remove_neigh(rose_neigh);\n\n\t\t\trose_node->count--;\n\n\t\t\tif (rose_node->count == 0) {\n\t\t\t\trose_remove_node(rose_node);\n\t\t\t} else {\n\t\t\t\tswitch (i) {\n\t\t\t\tcase 0:\n\t\t\t\t\trose_node->neighbour[0] =\n\t\t\t\t\t\trose_node->neighbour[1];\n\t\t\t\t\tfallthrough;\n\t\t\t\tcase 1:\n\t\t\t\t\trose_node->neighbour[1] =\n\t\t\t\t\t\trose_node->neighbour[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgoto out;\n\t\t}\n\t}\n\terr = -EINVAL;\n\nout:\n\tspin_unlock_bh(&rose_neigh_list_lock);\n\tspin_unlock_bh(&rose_node_list_lock);\n\n\treturn err;\n}","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":391639,"func":"static NTSTATUS smbd_calculate_maximum_allowed_access(\n\tconnection_struct *conn,\n\tconst struct smb_filename *smb_fname,\n\tbool use_privs,\n\tuint32_t *p_access_mask)\n{\n\tstruct security_descriptor *sd;\n\tuint32_t access_granted;\n\tNTSTATUS status;\n\n\tif (!use_privs && (get_current_uid(conn) == (uid_t)0)) {\n\t\t*p_access_mask |= FILE_GENERIC_ALL;\n\t\treturn NT_STATUS_OK;\n\t}\n\n\tstatus = SMB_VFS_GET_NT_ACL(conn, smb_fname->base_name,\n\t\t\t\t    (SECINFO_OWNER |\n\t\t\t\t     SECINFO_GROUP |\n\t\t\t\t     SECINFO_DACL),\n\t\t\t\t    talloc_tos(), &sd);\n\n\tif (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {\n\t\t\/*\n\t\t * File did not exist\n\t\t *\/\n\t\t*p_access_mask = FILE_GENERIC_ALL;\n\t\treturn NT_STATUS_OK;\n\t}\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\tDEBUG(10,(\"Could not get acl on file %s: %s\\n\",\n\t\t\t  smb_fname_str_dbg(smb_fname),\n\t\t\t  nt_errstr(status)));\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\n\t\/*\n\t * If we can access the path to this file, by\n\t * default we have FILE_READ_ATTRIBUTES from the\n\t * containing directory. See the section:\n\t * \"Algorithm to Check Access to an Existing File\"\n\t * in MS-FSA.pdf.\n\t *\n\t * se_file_access_check()\n\t * also takes care of owner WRITE_DAC and READ_CONTROL.\n\t *\/\n\tstatus = se_file_access_check(sd,\n\t\t\t\t get_current_nttok(conn),\n\t\t\t\t use_privs,\n\t\t\t\t (*p_access_mask & ~FILE_READ_ATTRIBUTES),\n\t\t\t\t &access_granted);\n\n\tTALLOC_FREE(sd);\n\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\tDEBUG(10, (\"Access denied on file %s: \"\n\t\t\t   \"when calculating maximum access\\n\",\n\t\t\t   smb_fname_str_dbg(smb_fname)));\n\t\treturn NT_STATUS_ACCESS_DENIED;\n\t}\n\t*p_access_mask = (access_granted | FILE_READ_ATTRIBUTES);\n\n\tif (!(access_granted & DELETE_ACCESS)) {\n\t\tif (can_delete_file_in_directory(conn, smb_fname)) {\n\t\t\t*p_access_mask |= DELETE_ACCESS;\n\t\t}\n\t}\n\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":238584,"func":"static void __scalar64_min_max_lsh(struct bpf_reg_state *dst_reg,\n\t\t\t\t   u64 umin_val, u64 umax_val)\n{\n\t\/* Special case <<32 because it is a common compiler pattern to sign\n\t * extend subreg by doing <<32 s>>32. In this case if 32bit bounds are\n\t * positive we know this shift will also be positive so we can track\n\t * bounds correctly. Otherwise we lose all sign bit information except\n\t * what we can pick up from var_off. Perhaps we can generalize this\n\t * later to shifts of any length.\n\t *\/\n\tif (umin_val == 32 && umax_val == 32 && dst_reg->s32_max_value >= 0)\n\t\tdst_reg->smax_value = (s64)dst_reg->s32_max_value << 32;\n\telse\n\t\tdst_reg->smax_value = S64_MAX;\n\n\tif (umin_val == 32 && umax_val == 32 && dst_reg->s32_min_value >= 0)\n\t\tdst_reg->smin_value = (s64)dst_reg->s32_min_value << 32;\n\telse\n\t\tdst_reg->smin_value = S64_MIN;\n\n\t\/* If we might shift our top bit out, then we know nothing *\/\n\tif (dst_reg->umax_value > 1ULL << (63 - umax_val)) {\n\t\tdst_reg->umin_value = 0;\n\t\tdst_reg->umax_value = U64_MAX;\n\t} else {\n\t\tdst_reg->umin_value <<= umin_val;\n\t\tdst_reg->umax_value <<= umax_val;\n\t}\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":244267,"func":"GF_Err stsz_box_size(GF_Box *s)\n{\n\tu32 i, fieldSize, size;\n\tGF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s;\n\n\tptr->size += 8;\n\tif (!ptr->sampleCount) return GF_OK;\n\n\t\/\/regular table\n\tif (ptr->type == GF_ISOM_BOX_TYPE_STSZ) {\n\t\tif (ptr->sampleSize) return GF_OK;\n\t\tptr->size += (4 * ptr->sampleCount);\n\t\treturn GF_OK;\n\t}\n\tif (!ptr->sizes) return GF_ISOM_INVALID_FILE;\n\n\t\/\/compact size table\n\tfieldSize = 4;\n\tsize = ptr->sizes[0];\n\n\tfor (i=0; i < ptr->sampleCount; i++) {\n\t\tif (ptr->sizes[i] <= 0xF) {\n\t\t}\n\t\t\/\/switch to 8-bit table\n\t\telse if (ptr->sizes[i] <= 0xFF) {\n\t\t\tfieldSize = 8;\n\t\t}\n\t\t\/\/switch to 16-bit table\n\t\telse if (ptr->sizes[i] <= 0xFFFF) {\n\t\t\tfieldSize = 16;\n\t\t}\n\t\t\/\/switch to 32-bit table\n\t\telse {\n\t\t\tfieldSize = 32;\n\t\t}\n\n\t\t\/\/check the size\n\t\tif (size != ptr->sizes[i]) size = 0;\n\t}\n\t\/\/if all samples are of the same size, switch to regular (more compact)\n\tif (size) {\n\t\tptr->type = GF_ISOM_BOX_TYPE_STSZ;\n\t\tptr->sampleSize = size;\n\t\tgf_free(ptr->sizes);\n\t\tptr->sizes = NULL;\n\t\treturn GF_OK;\n\t}\n\n\tif (fieldSize == 32) {\n\t\t\/\/oops, doesn't fit in a compact table\n\t\tptr->type = GF_ISOM_BOX_TYPE_STSZ;\n\t\tptr->size += (4 * ptr->sampleCount);\n\t\treturn GF_OK;\n\t}\n\n\t\/\/make sure we are a compact table (no need to change the mem representation)\n\tptr->type = GF_ISOM_BOX_TYPE_STZ2;\n\tptr->sampleSize = fieldSize;\n\tif (fieldSize == 4) {\n\t\t\/\/do not forget the 0 padding field for odd count\n\t\tptr->size += (ptr->sampleCount + 1) \/ 2;\n\t} else {\n\t\tptr->size += (ptr->sampleCount) * (fieldSize\/8);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":258079,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& input = context->input(0);\n    const Tensor& sparse_dims = context->input(1);\n\n    if (TensorShapeUtils::IsScalar(input.shape()) || input.NumElements() == 0) {\n      context->set_output(0, input);\n    } else {\n      const int input_dims = input.dims();\n      const TensorShape& sparse_dims_shape = sparse_dims.shape();\n      const auto& axes_sparse_flat = sparse_dims.flat<Tidx>();\n\n      OP_REQUIRES(context, TensorShapeUtils::IsVector(sparse_dims_shape),\n                  errors::InvalidArgument(\"'dims' must be 1-dimension, not \",\n                                          sparse_dims.dims()));\n      gtl::InlinedVector<bool, 8> axes_dense(input_dims, false);\n      for (int dummy = 0; dummy < axes_sparse_flat.size(); dummy++) {\n        Tidx axis = internal::SubtleMustCopy<Tidx>(axes_sparse_flat(dummy));\n        Tidx canonical_axis = axis < 0 ? input_dims + axis : axis;\n        OP_REQUIRES(context, canonical_axis >= 0 && canonical_axis < input_dims,\n                    errors::InvalidArgument(\"'axis'[\", dummy, \"] = \", axis,\n                                            \" is out of valid range [\", 0, \", \",\n                                            input_dims - 1));\n        OP_REQUIRES(context, !axes_dense[canonical_axis],\n                    errors::InvalidArgument(\"axis \", canonical_axis,\n                                            \" specified more than once.\"));\n        axes_dense[canonical_axis] = true;\n      }\n\n      OP_REQUIRES(context, input_dims <= 8,\n                  errors::Unimplemented(\n                      \"reverse is not implemented for tensors of rank > 8.\"));\n\n      Tensor* output = nullptr;\n      OP_REQUIRES_OK(context,\n                     context->allocate_output(0, input.shape(), &output));\n\n      \/\/ TODO(cwhipkey): we can do dimension folding to reduce, e.g., a reverse\n      \/\/ of a single dimension to the dims=3 or dims=2 case, regardless of the\n      \/\/ number of dimensions in the tensor. This would let some ops use faster\n      \/\/ lower-dimension code (and use optimized versions).\n\n#define HANDLE_REVERSE(NDIMS)                                           \\\n  case NDIMS:                                                           \\\n    HandleReverseV2Case<Device, T, NDIMS>(context, axes_dense, output); \\\n    return;\n\n      switch (input_dims) {\n        HANDLE_REVERSE(0);\n        HANDLE_REVERSE(1);\n        HANDLE_REVERSE(2);\n        HANDLE_REVERSE(3);\n        HANDLE_REVERSE(4);\n        HANDLE_REVERSE(5);\n        HANDLE_REVERSE(6);\n        HANDLE_REVERSE(7);\n        HANDLE_REVERSE(8);\n      }\n#undef HANDLE_REVERSE\n    }\n  }","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":197395,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& input = context->input(0);\n    const Tensor& dims = context->input(1);\n\n    if (TensorShapeUtils::IsScalar(input.shape())) {\n      context->set_output(0, input);\n    } else {\n      const int input_dims = input.dims();\n      OP_REQUIRES(context, TensorShapeUtils::IsVector(dims.shape()),\n                  errors::InvalidArgument(\"'dims' must be 1-dimension, not \",\n                                          dims.dims()));\n\n      OP_REQUIRES(\n          context, input_dims == dims.dim_size(0),\n          errors::InvalidArgument(\n              \"'dims' must have the same number of values as 'input' has \"\n              \"dimensions. 'input' has \",\n              input_dims, \"'dims' has \", dims.dim_size(0), \" values\"));\n      OP_REQUIRES(context, input_dims <= 8,\n                  errors::Unimplemented(\n                      \"reverse is not implemented for tensors of rank > 8.\"));\n\n      Tensor* output = nullptr;\n      OP_REQUIRES_OK(context,\n                     context->allocate_output(0, input.shape(), &output));\n\n#define HANDLE_REVERSE(NDIMS)                                               \\\n  case NDIMS:                                                               \\\n    HandleReverseCase<Device, T, NDIMS>(context, dims.vec<bool>(), output); \\\n    return;\n\n      switch (input_dims) {\n        HANDLE_REVERSE(0);\n        HANDLE_REVERSE(1);\n        HANDLE_REVERSE(2);\n        HANDLE_REVERSE(3);\n        HANDLE_REVERSE(4);\n        HANDLE_REVERSE(5);\n        HANDLE_REVERSE(6);\n        HANDLE_REVERSE(7);\n        HANDLE_REVERSE(8);\n      }\n#undef HANDLE_REVERSE\n    }\n  }","target":1,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":427798,"func":"int svm_mem_enc_op(struct kvm *kvm, void __user *argp)\n{\n\tstruct kvm_sev_cmd sev_cmd;\n\tint r;\n\n\tif (!sev_enabled)\n\t\treturn -ENOTTY;\n\n\tif (!argp)\n\t\treturn 0;\n\n\tif (copy_from_user(&sev_cmd, argp, sizeof(struct kvm_sev_cmd)))\n\t\treturn -EFAULT;\n\n\tmutex_lock(&kvm->lock);\n\n\t\/* Only the enc_context_owner handles some memory enc operations. *\/\n\tif (is_mirroring_enc_context(kvm) &&\n\t    !cmd_allowed_from_miror(sev_cmd.id)) {\n\t\tr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tswitch (sev_cmd.id) {\n\tcase KVM_SEV_ES_INIT:\n\t\tif (!sev_es_enabled) {\n\t\t\tr = -ENOTTY;\n\t\t\tgoto out;\n\t\t}\n\t\tfallthrough;\n\tcase KVM_SEV_INIT:\n\t\tr = sev_guest_init(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_LAUNCH_START:\n\t\tr = sev_launch_start(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_LAUNCH_UPDATE_DATA:\n\t\tr = sev_launch_update_data(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_LAUNCH_UPDATE_VMSA:\n\t\tr = sev_launch_update_vmsa(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_LAUNCH_MEASURE:\n\t\tr = sev_launch_measure(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_LAUNCH_FINISH:\n\t\tr = sev_launch_finish(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_GUEST_STATUS:\n\t\tr = sev_guest_status(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_DBG_DECRYPT:\n\t\tr = sev_dbg_crypt(kvm, &sev_cmd, true);\n\t\tbreak;\n\tcase KVM_SEV_DBG_ENCRYPT:\n\t\tr = sev_dbg_crypt(kvm, &sev_cmd, false);\n\t\tbreak;\n\tcase KVM_SEV_LAUNCH_SECRET:\n\t\tr = sev_launch_secret(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_GET_ATTESTATION_REPORT:\n\t\tr = sev_get_attestation_report(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_SEND_START:\n\t\tr = sev_send_start(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_SEND_UPDATE_DATA:\n\t\tr = sev_send_update_data(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_SEND_FINISH:\n\t\tr = sev_send_finish(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_SEND_CANCEL:\n\t\tr = sev_send_cancel(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_RECEIVE_START:\n\t\tr = sev_receive_start(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_RECEIVE_UPDATE_DATA:\n\t\tr = sev_receive_update_data(kvm, &sev_cmd);\n\t\tbreak;\n\tcase KVM_SEV_RECEIVE_FINISH:\n\t\tr = sev_receive_finish(kvm, &sev_cmd);\n\t\tbreak;\n\tdefault:\n\t\tr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tif (copy_to_user(argp, &sev_cmd, sizeof(struct kvm_sev_cmd)))\n\t\tr = -EFAULT;\n\nout:\n\tmutex_unlock(&kvm->lock);\n\treturn r;\n}","target":0,"code_token_length":741,"total_token_length":977,"max_tokens_setting":1024}
+{"idx":313851,"func":"check_scrollbind(linenr_T topline_diff, long leftcol_diff)\n{\n    int\t\twant_ver;\n    int\t\twant_hor;\n    win_T\t*old_curwin = curwin;\n    buf_T\t*old_curbuf = curbuf;\n    int\t\told_VIsual_select = VIsual_select;\n    int\t\told_VIsual_active = VIsual_active;\n    colnr_T\ttgt_leftcol = curwin->w_leftcol;\n    long\ttopline;\n    long\ty;\n\n    \/\/ check 'scrollopt' string for vertical and horizontal scroll options\n    want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0);\n#ifdef FEAT_DIFF\n    want_ver |= old_curwin->w_p_diff;\n#endif\n    want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0));\n\n    \/\/ loop through the scrollbound windows and scroll accordingly\n    VIsual_select = VIsual_active = 0;\n    FOR_ALL_WINDOWS(curwin)\n    {\n\tcurbuf = curwin->w_buffer;\n\t\/\/ skip original window  and windows with 'noscrollbind'\n\tif (curwin != old_curwin && curwin->w_p_scb)\n\t{\n\t    \/\/ do the vertical scroll\n\t    if (want_ver)\n\t    {\n#ifdef FEAT_DIFF\n\t\tif (old_curwin->w_p_diff && curwin->w_p_diff)\n\t\t{\n\t\t    diff_set_topline(old_curwin, curwin);\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    curwin->w_scbind_pos += topline_diff;\n\t\t    topline = curwin->w_scbind_pos;\n\t\t    if (topline > curbuf->b_ml.ml_line_count)\n\t\t\ttopline = curbuf->b_ml.ml_line_count;\n\t\t    if (topline < 1)\n\t\t\ttopline = 1;\n\n\t\t    y = topline - curwin->w_topline;\n\t\t    if (y > 0)\n\t\t\tscrollup(y, FALSE);\n\t\t    else\n\t\t\tscrolldown(-y, FALSE);\n\t\t}\n\n\t\tredraw_later(VALID);\n\t\tcursor_correct();\n\t\tcurwin->w_redr_status = TRUE;\n\t    }\n\n\t    \/\/ do the horizontal scroll\n\t    if (want_hor && curwin->w_leftcol != tgt_leftcol)\n\t    {\n\t\tcurwin->w_leftcol = tgt_leftcol;\n\t\tleftcol_changed();\n\t    }\n\t}\n    }\n\n    \/\/ reset current-window\n    VIsual_select = old_VIsual_select;\n    VIsual_active = old_VIsual_active;\n    curwin = old_curwin;\n    curbuf = old_curbuf;\n}","target":0,"code_token_length":570,"total_token_length":806,"max_tokens_setting":1024}
+{"idx":300798,"func":"static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk)\n{\n\tu32 peer_node, peer_port;\n\tu32 conn_type, conn_instance;\n\tstruct nlattr *nest;\n\n\tpeer_node = tsk_peer_node(tsk);\n\tpeer_port = tsk_peer_port(tsk);\n\tconn_type = msg_nametype(&tsk->phdr);\n\tconn_instance = msg_nameinst(&tsk->phdr);\n\tnest = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_CON);\n\tif (!nest)\n\t\treturn -EMSGSIZE;\n\n\tif (nla_put_u32(skb, TIPC_NLA_CON_NODE, peer_node))\n\t\tgoto msg_full;\n\tif (nla_put_u32(skb, TIPC_NLA_CON_SOCK, peer_port))\n\t\tgoto msg_full;\n\n\tif (tsk->conn_addrtype != 0) {\n\t\tif (nla_put_flag(skb, TIPC_NLA_CON_FLAG))\n\t\t\tgoto msg_full;\n\t\tif (nla_put_u32(skb, TIPC_NLA_CON_TYPE, conn_type))\n\t\t\tgoto msg_full;\n\t\tif (nla_put_u32(skb, TIPC_NLA_CON_INST, conn_instance))\n\t\t\tgoto msg_full;\n\t}\n\tnla_nest_end(skb, nest);\n\n\treturn 0;\n\nmsg_full:\n\tnla_nest_cancel(skb, nest);\n\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":436139,"func":" *\/\nstatic int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,\n\t\t\t  const sigset_t __user *sig, size_t sigsz,\n\t\t\t  struct __kernel_timespec __user *uts)\n{\n\tstruct io_wait_queue iowq = {\n\t\t.wq = {\n\t\t\t.private\t= current,\n\t\t\t.func\t\t= io_wake_function,\n\t\t\t.entry\t\t= LIST_HEAD_INIT(iowq.wq.entry),\n\t\t},\n\t\t.ctx\t\t= ctx,\n\t\t.to_wait\t= min_events,\n\t};\n\tstruct io_rings *rings = ctx->rings;\n\tsigned long timeout = MAX_SCHEDULE_TIMEOUT;\n\tint ret;\n\n\tdo {\n\t\tio_cqring_overflow_flush(ctx, false);\n\t\tif (io_cqring_events(ctx) >= min_events)\n\t\t\treturn 0;\n\t\tif (!io_run_task_work())\n\t\t\tbreak;\n\t} while (1);\n\n\tif (sig) {\n#ifdef CONFIG_COMPAT\n\t\tif (in_compat_syscall())\n\t\t\tret = set_compat_user_sigmask((const compat_sigset_t __user *)sig,\n\t\t\t\t\t\t      sigsz);\n\t\telse\n#endif\n\t\t\tret = set_user_sigmask(sig, sigsz);\n\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tif (uts) {\n\t\tstruct timespec64 ts;\n\n\t\tif (get_timespec64(&ts, uts))\n\t\t\treturn -EFAULT;\n\t\ttimeout = timespec64_to_jiffies(&ts);\n\t}\n\n\tiowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);\n\ttrace_io_uring_cqring_wait(ctx, min_events);\n\tdo {\n\t\t\/* if we can't even flush overflow, don't wait for more *\/\n\t\tif (!io_cqring_overflow_flush(ctx, false)) {\n\t\t\tret = -EBUSY;\n\t\t\tbreak;\n\t\t}\n\t\tprepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq,\n\t\t\t\t\t\tTASK_INTERRUPTIBLE);\n\t\tret = io_cqring_wait_schedule(ctx, &iowq, &timeout);\n\t\tfinish_wait(&ctx->cq_wait, &iowq.wq);\n\t\tcond_resched();\n\t} while (ret > 0);\n\n\trestore_saved_sigmask_unless(ret == -EINTR);\n\n\treturn READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0;","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":206639,"func":"static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,\n\t\t\t    struct nft_data_desc *desc, const struct nlattr *nla)\n{\n\tu8 genmask = nft_genmask_next(ctx->net);\n\tstruct nlattr *tb[NFTA_VERDICT_MAX + 1];\n\tstruct nft_chain *chain;\n\tint err;\n\n\terr = nla_parse_nested_deprecated(tb, NFTA_VERDICT_MAX, nla,\n\t\t\t\t\t  nft_verdict_policy, NULL);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (!tb[NFTA_VERDICT_CODE])\n\t\treturn -EINVAL;\n\tdata->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));\n\n\tswitch (data->verdict.code) {\n\tdefault:\n\t\tswitch (data->verdict.code & NF_VERDICT_MASK) {\n\t\tcase NF_ACCEPT:\n\t\tcase NF_DROP:\n\t\tcase NF_QUEUE:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tfallthrough;\n\tcase NFT_CONTINUE:\n\tcase NFT_BREAK:\n\tcase NFT_RETURN:\n\t\tbreak;\n\tcase NFT_JUMP:\n\tcase NFT_GOTO:\n\t\tif (tb[NFTA_VERDICT_CHAIN]) {\n\t\t\tchain = nft_chain_lookup(ctx->net, ctx->table,\n\t\t\t\t\t\t tb[NFTA_VERDICT_CHAIN],\n\t\t\t\t\t\t genmask);\n\t\t} else if (tb[NFTA_VERDICT_CHAIN_ID]) {\n\t\t\tchain = nft_chain_lookup_byid(ctx->net, ctx->table,\n\t\t\t\t\t\t      tb[NFTA_VERDICT_CHAIN_ID]);\n\t\t\tif (IS_ERR(chain))\n\t\t\t\treturn PTR_ERR(chain);\n\t\t} else {\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (IS_ERR(chain))\n\t\t\treturn PTR_ERR(chain);\n\t\tif (nft_is_base_chain(chain))\n\t\t\treturn -EOPNOTSUPP;\n\t\tif (desc->flags & NFT_DATA_DESC_SETELEM &&\n\t\t    chain->flags & NFT_CHAIN_BINDING)\n\t\t\treturn -EINVAL;\n\n\t\tchain->use++;\n\t\tdata->verdict.chain = chain;\n\t\tbreak;\n\t}\n\n\tdesc->len = sizeof(data->verdict);\n\n\treturn 0;\n}","target":1,"code_token_length":455,"total_token_length":691,"max_tokens_setting":1024}
+{"idx":349873,"func":"int hw_atl_utils_update_stats(struct aq_hw_s *self)\n{\n\tstruct aq_stats_s *cs = &self->curr_stats;\n\tstruct hw_atl_utils_mbox mbox;\n\n\thw_atl_utils_mpi_read_stats(self, &mbox);\n\n#define AQ_SDELTA(_N_) (self->curr_stats._N_ += \\\n\t\t\tmbox.stats._N_ - self->last_stats._N_)\n\n\tif (self->aq_link_status.mbps) {\n\t\tAQ_SDELTA(uprc);\n\t\tAQ_SDELTA(mprc);\n\t\tAQ_SDELTA(bprc);\n\t\tAQ_SDELTA(erpt);\n\n\t\tAQ_SDELTA(uptc);\n\t\tAQ_SDELTA(mptc);\n\t\tAQ_SDELTA(bptc);\n\t\tAQ_SDELTA(erpr);\n\n\t\tAQ_SDELTA(ubrc);\n\t\tAQ_SDELTA(ubtc);\n\t\tAQ_SDELTA(mbrc);\n\t\tAQ_SDELTA(mbtc);\n\t\tAQ_SDELTA(bbrc);\n\t\tAQ_SDELTA(bbtc);\n\t\tAQ_SDELTA(dpc);\n\t}\n#undef AQ_SDELTA\n\n\tcs->dma_pkt_rc = hw_atl_stats_rx_dma_good_pkt_counter_get(self);\n\tcs->dma_pkt_tc = hw_atl_stats_tx_dma_good_pkt_counter_get(self);\n\tcs->dma_oct_rc = hw_atl_stats_rx_dma_good_octet_counter_get(self);\n\tcs->dma_oct_tc = hw_atl_stats_tx_dma_good_octet_counter_get(self);\n\n\tmemcpy(&self->last_stats, &mbox.stats, sizeof(mbox.stats));\n\n\treturn 0;\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":220017,"func":"int callback_glewlwyd_get_api_key_list (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_api_key_list;\n  size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE;\n  long int l_converted = 0;\n  char * endptr = NULL;\n  \n  if (u_map_get(request->map_url, \"offset\") != NULL) {\n    l_converted = strtol(u_map_get(request->map_url, \"offset\"), &endptr, 10);\n    if (!(*endptr) && l_converted > 0) {\n      offset = (size_t)l_converted;\n    }\n  }\n  if (u_map_get(request->map_url, \"limit\") != NULL) {\n    l_converted = strtol(u_map_get(request->map_url, \"limit\"), &endptr, 10);\n    if (!(*endptr) && l_converted >= 0) {\n      limit = (size_t)l_converted;\n    }\n  }\n  j_api_key_list = get_api_key_list(config, u_map_get(request->map_url, \"pattern\"), offset, limit);\n  if (check_result_value(j_api_key_list, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_api_key_list, \"api_key\"));\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_api_key_list - Error get_api_key_list\");\n    response->status = 500;\n  }\n  json_decref(j_api_key_list);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":225117,"func":"string SummarizeOpDef(const OpDef& op_def) {\n  string ret = strings::StrCat(\"Op<name=\", op_def.name());\n  strings::StrAppend(&ret, \"; signature=\", SummarizeArgs(op_def.input_arg()),\n                     \" -> \", SummarizeArgs(op_def.output_arg()));\n  for (int i = 0; i < op_def.attr_size(); ++i) {\n    strings::StrAppend(&ret, \"; attr=\", op_def.attr(i).name(), \":\",\n                       op_def.attr(i).type());\n    if (op_def.attr(i).has_default_value()) {\n      strings::StrAppend(&ret, \",default=\",\n                         SummarizeAttrValue(op_def.attr(i).default_value()));\n    }\n    if (op_def.attr(i).has_minimum()) {\n      strings::StrAppend(&ret, \",min=\", op_def.attr(i).minimum());\n    }\n    if (op_def.attr(i).has_allowed_values()) {\n      strings::StrAppend(&ret, \",allowed=\",\n                         SummarizeAttrValue(op_def.attr(i).allowed_values()));\n    }\n  }\n  if (op_def.is_commutative()) {\n    strings::StrAppend(&ret, \"; is_commutative=true\");\n  }\n  if (op_def.is_aggregate()) {\n    strings::StrAppend(&ret, \"; is_aggregate=true\");\n  }\n  if (op_def.is_stateful()) {\n    strings::StrAppend(&ret, \"; is_stateful=true\");\n  }\n  if (op_def.allows_uninitialized_input()) {\n    strings::StrAppend(&ret, \"; allows_uninitialized_input=true\");\n  }\n  if (op_def.is_distributed_communication()) {\n    strings::StrAppend(&ret, \"; is_distributed_communication=true\");\n  }\n  strings::StrAppend(&ret, \">\");\n  return ret;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":276914,"func":"static int do_i2c_mw(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t     char *const argv[])\n{\n\tuint\tchip;\n\tulong\taddr;\n\tuint\talen;\n\tuchar\tbyte;\n\tuint\tcount;\n\tint ret;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *dev;\n#endif\n\n\tif ((argc < 4) || (argc > 5))\n\t\treturn CMD_RET_USAGE;\n\n\t\/*\n\t * Chip is always specified.\n\t *\/\n\tchip = hextoul(argv[1], NULL);\n\n\t\/*\n\t * Address is always specified.\n\t *\/\n\taddr = hextoul(argv[2], NULL);\n\talen = get_alen(argv[2], DEFAULT_ADDR_LEN);\n\tif (alen > 3)\n\t\treturn CMD_RET_USAGE;\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (!ret && alen != -1)\n\t\tret = i2c_set_chip_offset_len(dev, alen);\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_WRITE);\n#endif\n\t\/*\n\t * Value to write is always specified.\n\t *\/\n\tbyte = hextoul(argv[3], NULL);\n\n\t\/*\n\t * Optional count\n\t *\/\n\tif (argc == 5)\n\t\tcount = hextoul(argv[4], NULL);\n\telse\n\t\tcount = 1;\n\n\twhile (count-- > 0) {\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tret = dm_i2c_write(dev, addr++, &byte, 1);\n#else\n\t\tret = i2c_write(chip, addr++, alen, &byte, 1);\n#endif\n\t\tif (ret)\n\t\t\treturn i2c_report_err(ret, I2C_ERR_WRITE);\n\t\t\/*\n\t\t * Wait for the write to complete.  The write can take\n\t\t * up to 10mSec (we allow a little more time).\n\t\t *\/\n\/*\n * No write delay with FRAM devices.\n *\/\n#if !defined(CONFIG_SYS_I2C_FRAM)\n\t\tudelay(11000);\n#endif\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":208107,"func":"static int xfrm_expand_policies(const struct flowi *fl, u16 family,\n\t\t\t\tstruct xfrm_policy **pols,\n\t\t\t\tint *num_pols, int *num_xfrms)\n{\n\tint i;\n\n\tif (*num_pols == 0 || !pols[0]) {\n\t\t*num_pols = 0;\n\t\t*num_xfrms = 0;\n\t\treturn 0;\n\t}\n\tif (IS_ERR(pols[0]))\n\t\treturn PTR_ERR(pols[0]);\n\n\t*num_xfrms = pols[0]->xfrm_nr;\n\n#ifdef CONFIG_XFRM_SUB_POLICY\n\tif (pols[0]->action == XFRM_POLICY_ALLOW &&\n\t    pols[0]->type != XFRM_POLICY_TYPE_MAIN) {\n\t\tpols[1] = xfrm_policy_lookup_bytype(xp_net(pols[0]),\n\t\t\t\t\t\t    XFRM_POLICY_TYPE_MAIN,\n\t\t\t\t\t\t    fl, family,\n\t\t\t\t\t\t    XFRM_POLICY_OUT,\n\t\t\t\t\t\t    pols[0]->if_id);\n\t\tif (pols[1]) {\n\t\t\tif (IS_ERR(pols[1])) {\n\t\t\t\txfrm_pols_put(pols, *num_pols);\n\t\t\t\treturn PTR_ERR(pols[1]);\n\t\t\t}\n\t\t\t(*num_pols)++;\n\t\t\t(*num_xfrms) += pols[1]->xfrm_nr;\n\t\t}\n\t}\n#endif\n\tfor (i = 0; i < *num_pols; i++) {\n\t\tif (pols[i]->action != XFRM_POLICY_ALLOW) {\n\t\t\t*num_xfrms = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n\n}","target":1,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":473815,"func":"st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)\n{\n    st_table_entry *ptr, **last, *tmp;\n    enum st_retval retval;\n    st_index_t i;\n\n    if (table->entries_packed) {\n        for (i = 0; i < table->num_entries; i++) {\n            st_index_t j;\n            st_data_t key, val;\n            key = (st_data_t)table->bins[i*2];\n            val = (st_data_t)table->bins[i*2+1];\n            retval = (*func)(key, val, arg);\n\t    if (!table->entries_packed) goto unpacked;\n            switch (retval) {\n\t      case ST_CHECK:\t\/* check if hash is modified during iteration *\/\n                for (j = 0; j < table->num_entries; j++) {\n                    if ((st_data_t)table->bins[j*2] == key)\n                        break;\n                }\n                if (j == table->num_entries) {\n                    \/* call func with error notice *\/\n                    retval = (*func)(0, 0, arg, 1);\n                    return 1;\n                }\n\t\t\/* fall through *\/\n\t      case ST_CONTINUE:\n\t\tbreak;\n\t      case ST_STOP:\n\t\treturn 0;\n\t      case ST_DELETE:\n                table->num_entries--;\n                memmove(&table->bins[i*2], &table->bins[(i+1)*2],\n                        sizeof(struct st_table_entry*) * 2*(table->num_entries-i));\n                i--;\n                break;\n            }\n        }\n        return 0;\n      unpacked:\n\tptr = table->head;\n\twhile (i-- > 0) {\n\t    if (!(ptr = ptr->fore)) return 0;\n\t}\n    }\n    else {\n\tptr = table->head;\n    }\n\n    if (ptr != 0) {\n\tdo {\n\t    i = ptr->hash % table->num_bins;\n\t    retval = (*func)(ptr->key, ptr->record, arg);\n\t    switch (retval) {\n\t      case ST_CHECK:\t\/* check if hash is modified during iteration *\/\n\t\tfor (tmp = table->bins[i]; tmp != ptr; tmp = tmp->next) {\n\t\t    if (!tmp) {\n\t\t\t\/* call func with error notice *\/\n\t\t\tretval = (*func)(0, 0, arg, 1);\n\t\t\treturn 1;\n\t\t    }\n\t\t}\n\t\t\/* fall through *\/\n\t      case ST_CONTINUE:\n\t\tptr = ptr->fore;\n\t\tbreak;\n\t      case ST_STOP:\n\t\treturn 0;\n\t      case ST_DELETE:\n\t\tlast = &table->bins[ptr->hash % table->num_bins];\n\t\tfor (; (tmp = *last) != 0; last = &tmp->next) {\n\t\t    if (ptr == tmp) {\n\t\t\ttmp = ptr->fore;\n\t\t\t*last = ptr->next;\n\t\t\tREMOVE_ENTRY(table, ptr);\n\t\t\tfree(ptr);\n\t\t\tif (ptr == tmp) return 0;\n\t\t\tptr = tmp;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t} while (ptr && table->head);\n    }\n    return 0;\n}","target":0,"code_token_length":661,"total_token_length":897,"max_tokens_setting":1024}
+{"idx":195410,"func":"  void MakeDataset(OpKernelContext* ctx, DatasetBase** output) override {\n    \/\/ Create a new SparseTensorSliceDatasetOp::Dataset, insert it in\n    \/\/ the step container, and return it as the output.\n    const Tensor* indices;\n    OP_REQUIRES_OK(ctx, ctx->input(\"indices\", &indices));\n    const Tensor* values;\n    OP_REQUIRES_OK(ctx, ctx->input(\"values\", &values));\n    const Tensor* dense_shape;\n    OP_REQUIRES_OK(ctx, ctx->input(\"dense_shape\", &dense_shape));\n\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices->shape()),\n                errors::InvalidArgument(\n                    \"Input indices should be a matrix but received shape \",\n                    indices->shape().DebugString()));\n\n    const auto num_indices = indices->NumElements();\n    const auto num_values = values->NumElements();\n    if (num_indices == 0 || num_values == 0) {\n      OP_REQUIRES(ctx, num_indices == num_values,\n                  errors::InvalidArgument(\n                      \"If indices or values are empty, the other one must also \"\n                      \"be. Got indices of shape \",\n                      indices->shape().DebugString(), \" and values of shape \",\n                      values->shape().DebugString()));\n    }\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(values->shape()),\n                errors::InvalidArgument(\n                    \"Input values should be a vector but received shape \",\n                    indices->shape().DebugString()));\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(dense_shape->shape()),\n                errors::InvalidArgument(\n                    \"Input shape should be a vector but received shape \",\n                    dense_shape->shape().DebugString()));\n\n    \/\/ We currently ensure that `sparse_tensor` is ordered in the\n    \/\/ batch dimension.\n    \/\/ TODO(mrry): Investigate ways to avoid this unconditional check\n    \/\/ if we can be sure that the sparse tensor was produced in an\n    \/\/ appropriate order (e.g. by `tf.parse_example()` or a Dataset\n    \/\/ that batches elements into rows of a SparseTensor).\n    int64_t previous_batch_index = -1;\n    for (int64_t i = 0; i < indices->dim_size(0); ++i) {\n      int64_t next_batch_index = indices->matrix<int64_t>()(i, 0);\n      OP_REQUIRES(\n          ctx, next_batch_index >= previous_batch_index,\n          errors::Unimplemented(\"The SparseTensor must be ordered in the batch \"\n                                \"dimension; handling arbitrarily ordered input \"\n                                \"is not currently supported.\"));\n      previous_batch_index = next_batch_index;\n    }\n    gtl::InlinedVector<int64_t, 8> std_order(dense_shape->NumElements(), 0);\n    sparse::SparseTensor tensor;\n    OP_REQUIRES_OK(\n        ctx, sparse::SparseTensor::Create(\n                 *indices, *values, TensorShape(dense_shape->vec<int64_t>()),\n                 std_order, &tensor));\n    *output = new Dataset<T>(ctx, std::move(tensor));\n  }","target":1,"code_token_length":644,"total_token_length":880,"max_tokens_setting":1024}
+{"idx":488400,"func":"static noinline int do_no_pfn(struct mm_struct *mm, struct vm_area_struct *vma,\n\t\t     unsigned long address, pte_t *page_table, pmd_t *pmd,\n\t\t     int write_access)\n{\n\tspinlock_t *ptl;\n\tpte_t entry;\n\tunsigned long pfn;\n\n\tpte_unmap(page_table);\n\tBUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)));\n\tBUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags));\n\n\tpfn = vma->vm_ops->nopfn(vma, address & PAGE_MASK);\n\n\tBUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn));\n\n\tif (unlikely(pfn == NOPFN_OOM))\n\t\treturn VM_FAULT_OOM;\n\telse if (unlikely(pfn == NOPFN_SIGBUS))\n\t\treturn VM_FAULT_SIGBUS;\n\telse if (unlikely(pfn == NOPFN_REFAULT))\n\t\treturn 0;\n\n\tpage_table = pte_offset_map_lock(mm, pmd, address, &ptl);\n\n\t\/* Only go through if we didn't race with anybody else... *\/\n\tif (pte_none(*page_table)) {\n\t\tentry = pfn_pte(pfn, vma->vm_page_prot);\n\t\tif (write_access)\n\t\t\tentry = maybe_mkwrite(pte_mkdirty(entry), vma);\n\t\tset_pte_at(mm, address, page_table, entry);\n\t}\n\tpte_unmap_unlock(page_table, ptl);\n\treturn 0;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":513062,"func":"void Regexp_processor_pcre::pcre_exec_warn(int rc) const\n{\n  char buf[64];\n  const char *errmsg= NULL;\n  THD *thd= current_thd;\n\n  \/*\n    Make a descriptive message only for those pcre_exec() error codes\n    that can actually happen in MariaDB.\n  *\/\n  switch (rc)\n  {\n  case PCRE_ERROR_NULL:\n    errmsg= \"pcre_exec: null argument passed\";\n    break;\n  case PCRE_ERROR_BADOPTION:\n    errmsg= \"pcre_exec: bad option\";\n    break;\n  case PCRE_ERROR_BADMAGIC:\n    errmsg= \"pcre_exec: bad magic - not a compiled regex\";\n    break;\n  case PCRE_ERROR_UNKNOWN_OPCODE:\n    errmsg= \"pcre_exec: error in compiled regex\";\n    break;\n  case PCRE_ERROR_NOMEMORY:\n    errmsg= \"pcre_exec: Out of memory\";\n    break;\n  case PCRE_ERROR_NOSUBSTRING:\n    errmsg= \"pcre_exec: no substring\";\n    break;\n  case PCRE_ERROR_MATCHLIMIT:\n    errmsg= \"pcre_exec: match limit exceeded\";\n    break;\n  case PCRE_ERROR_CALLOUT:\n    errmsg= \"pcre_exec: callout error\";\n    break;\n  case PCRE_ERROR_BADUTF8:\n    errmsg= \"pcre_exec: Invalid utf8 byte sequence in the subject string\";\n    break;\n  case PCRE_ERROR_BADUTF8_OFFSET:\n    errmsg= \"pcre_exec: Started at invalid location within utf8 byte sequence\";\n    break;\n  case PCRE_ERROR_PARTIAL:\n    errmsg= \"pcre_exec: partial match\";\n    break;\n  case PCRE_ERROR_INTERNAL:\n    errmsg= \"pcre_exec: internal error\";\n    break;\n  case PCRE_ERROR_BADCOUNT:\n    errmsg= \"pcre_exec: ovesize is negative\";\n    break;\n  case PCRE_ERROR_RECURSIONLIMIT:\n    my_snprintf(buf, sizeof(buf), \"pcre_exec: recursion limit of %ld exceeded\",\n                m_pcre_extra.match_limit_recursion);\n    errmsg= buf;\n    break;\n  case PCRE_ERROR_BADNEWLINE:\n    errmsg= \"pcre_exec: bad newline options\";\n    break;\n  case PCRE_ERROR_BADOFFSET:\n    errmsg= \"pcre_exec: start offset negative or greater than string length\";\n    break;\n  case PCRE_ERROR_SHORTUTF8:\n    errmsg= \"pcre_exec: ended in middle of utf8 sequence\";\n    break;\n  case PCRE_ERROR_JIT_STACKLIMIT:\n    errmsg= \"pcre_exec: insufficient stack memory for JIT compile\";\n    break;\n  case PCRE_ERROR_RECURSELOOP:\n    errmsg= \"pcre_exec: Recursion loop detected\";\n    break;\n  case PCRE_ERROR_BADMODE:\n    errmsg= \"pcre_exec: compiled pattern passed to wrong bit library function\";\n    break;\n  case PCRE_ERROR_BADENDIANNESS:\n    errmsg= \"pcre_exec: compiled pattern passed to wrong endianness processor\";\n    break;\n  case PCRE_ERROR_JIT_BADOPTION:\n    errmsg= \"pcre_exec: bad jit option\";\n    break;\n  case PCRE_ERROR_BADLENGTH:\n    errmsg= \"pcre_exec: negative length\";\n    break;\n  default:\n    \/*\n      As other error codes should normally not happen,\n      we just report the error code without textual description\n      of the code.\n    *\/\n    my_snprintf(buf, sizeof(buf), \"pcre_exec: Internal error (%d)\", rc);\n    errmsg= buf;\n  }\n  push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,\n                      ER_REGEXP_ERROR, ER_THD(thd, ER_REGEXP_ERROR), errmsg);\n}","target":0,"code_token_length":784,"total_token_length":1020,"max_tokens_setting":1024}
+{"idx":500680,"func":"sftp_attributes sftp_fstat(sftp_file file) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  ssh_buffer buffer;\n  uint32_t id;\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(file->sftp->session);\n    return NULL;\n  }\n\n  id = sftp_get_new_id(file->sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, file->handle) < 0) {\n    ssh_set_error_oom(file->sftp->session);\n    ssh_buffer_free(buffer);\n    return NULL;\n  }\n  if (sftp_packet_write(file->sftp, SSH_FXP_FSTAT, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    return NULL;\n  }\n  ssh_buffer_free(buffer);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(file->sftp) < 0) {\n      return NULL;\n    }\n    msg = sftp_dequeue(file->sftp, id);\n  }\n\n  if (msg->packet_type == SSH_FXP_ATTRS){\n    return sftp_parse_attr(file->sftp, msg->payload, 0);\n  } else if (msg->packet_type == SSH_FXP_STATUS) {\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return NULL;\n    }\n    ssh_set_error(file->sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n\n    return NULL;\n  }\n  ssh_set_error(file->sftp->session, SSH_FATAL,\n      \"Received msg %d during fstat()\", msg->packet_type);\n  sftp_message_free(msg);\n\n  return NULL;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":473858,"func":"static int backref_match_at_nested_level(regex_t* reg\n\t , OnigStackType* top, OnigStackType* stk_base\n\t , int ignore_case, int case_fold_flag\n\t , int nest, int mem_num, UChar* memp, UChar** s, const UChar* send)\n{\n  UChar *ss, *p, *pstart, *pend = NULL_UCHARP;\n  int level;\n  OnigStackType* k;\n\n  level = 0;\n  k = top;\n  k--;\n  while (k >= stk_base) {\n    if (k->type == STK_CALL_FRAME) {\n      level--;\n    }\n    else if (k->type == STK_RETURN) {\n      level++;\n    }\n    else if (level == nest) {\n      if (k->type == STK_MEM_START) {\n\tif (mem_is_in_memp(k->u.mem.num, mem_num, memp)) {\n\t  pstart = k->u.mem.pstr;\n\t  if (pend != NULL_UCHARP) {\n\t    if (pend - pstart > send - *s) return 0; \/* or goto next_mem; *\/\n\t    p  = pstart;\n\t    ss = *s;\n\n\t    if (ignore_case != 0) {\n\t      if (string_cmp_ic(reg->enc, case_fold_flag,\n\t\t\t\tpstart, &ss, (int )(pend - pstart), send) == 0)\n\t\treturn 0; \/* or goto next_mem; *\/\n\t    }\n\t    else {\n\t      while (p < pend) {\n\t\tif (*p++ != *ss++) return 0; \/* or goto next_mem; *\/\n\t      }\n\t    }\n\n\t    *s = ss;\n\t    return 1;\n\t  }\n\t}\n      }\n      else if (k->type == STK_MEM_END) {\n\tif (mem_is_in_memp(k->u.mem.num, mem_num, memp)) {\n\t  pend = k->u.mem.pstr;\n\t}\n      }\n    }\n    k--;\n  }\n\n  return 0;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":447056,"func":"    size_t RemoteIo::Impl::populateBlocks(size_t lowBlock, size_t highBlock)\n    {\n        assert(isMalloced_);\n\n        \/\/ optimize: ignore all true blocks on left & right sides.\n        while(!blocksMap_[lowBlock].isNone()  && lowBlock  < highBlock) lowBlock++;\n        while(!blocksMap_[highBlock].isNone() && highBlock > lowBlock)  highBlock--;\n\n        size_t rcount = 0;\n        if (blocksMap_[highBlock].isNone())\n        {\n            std::string data;\n            getDataByRange( (long) lowBlock, (long) highBlock, data);\n            rcount = (size_t)data.length();\n            if (rcount == 0) {\n                throw Error(1, \"Data By Range is empty. Please check the permission.\");\n            }\n            byte* source = (byte*)data.c_str();\n            size_t remain = rcount, totalRead = 0;\n            size_t iBlock = (rcount == size_) ? 0 : lowBlock;\n\n            while (remain) {\n                size_t allow = EXV_MIN(remain, blockSize_);\n                blocksMap_[iBlock].populate(&source[totalRead], allow);\n                remain -= allow;\n                totalRead += allow;\n                iBlock++;\n            }\n        }\n\n        return rcount;\n    }","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":279908,"func":"ex_drop(exarg_T *eap)\n{\n    int\t\tsplit = FALSE;\n    win_T\t*wp;\n    buf_T\t*buf;\n    tabpage_T\t*tp;\n\n    if (ERROR_IF_POPUP_WINDOW || ERROR_IF_TERM_POPUP_WINDOW)\n\treturn;\n\n    \/*\n     * Check if the first argument is already being edited in a window.  If\n     * so, jump to that window.\n     * We would actually need to check all arguments, but that's complicated\n     * and mostly only one file is dropped.\n     * This also ignores wildcards, since it is very unlikely the user is\n     * editing a file name with a wildcard character.\n     *\/\n    set_arglist(eap->arg);\n\n    \/*\n     * Expanding wildcards may result in an empty argument list.  E.g. when\n     * editing \"foo.pyc\" and \".pyc\" is in 'wildignore'.  Assume that we\n     * already did an error message for this.\n     *\/\n    if (ARGCOUNT == 0)\n\treturn;\n\n    if (cmdmod.cmod_tab)\n    {\n\t\/\/ \":tab drop file ...\": open a tab for each argument that isn't\n\t\/\/ edited in a window yet.  It's like \":tab all\" but without closing\n\t\/\/ windows or tabs.\n\tex_all(eap);\n    }\n    else\n    {\n\t\/\/ \":drop file ...\": Edit the first argument.  Jump to an existing\n\t\/\/ window if possible, edit in current window if the current buffer\n\t\/\/ can be abandoned, otherwise open a new window.\n\tbuf = buflist_findnr(ARGLIST[0].ae_fnum);\n\n\tFOR_ALL_TAB_WINDOWS(tp, wp)\n\t{\n\t    if (wp->w_buffer == buf)\n\t    {\n\t\tgoto_tabpage_win(tp, wp);\n\t\tcurwin->w_arg_idx = 0;\n\t\tif (!bufIsChanged(curbuf))\n\t\t{\n\t\t    int save_ar = curbuf->b_p_ar;\n\n\t\t    \/\/ reload the file if it is newer\n\t\t    curbuf->b_p_ar = TRUE;\n\t\t    buf_check_timestamp(curbuf, FALSE);\n\t\t    curbuf->b_p_ar = save_ar;\n\t\t}\n\t\treturn;\n\t    }\n\t}\n\n\t\/*\n\t * Check whether the current buffer is changed. If so, we will need\n\t * to split the current window or data could be lost.\n\t * Skip the check if the 'hidden' option is set, as in this case the\n\t * buffer won't be lost.\n\t *\/\n\tif (!buf_hide(curbuf))\n\t{\n\t    ++emsg_off;\n\t    split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);\n\t    --emsg_off;\n\t}\n\n\t\/\/ Fake a \":sfirst\" or \":first\" command edit the first argument.\n\tif (split)\n\t{\n\t    eap->cmdidx = CMD_sfirst;\n\t    eap->cmd[0] = 's';\n\t}\n\telse\n\t    eap->cmdidx = CMD_first;\n\tex_rewind(eap);\n    }\n}","target":0,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":198476,"func":"njs_await_fulfilled(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    njs_int_t           ret;\n    njs_value_t         **cur_local, **cur_closures, **cur_temp, *value;\n    njs_frame_t         *frame, *async_frame;\n    njs_function_t      *function;\n    njs_async_ctx_t     *ctx;\n    njs_native_frame_t  *top, *async;\n\n    ctx = vm->top_frame->function->context;\n\n    value = njs_arg(args, nargs, 1);\n    if (njs_is_error(value)) {\n        goto failed;\n    }\n\n    async_frame = ctx->await;\n    async = &async_frame->native;\n    async->previous = vm->top_frame;\n\n    function = async->function;\n\n    cur_local = vm->levels[NJS_LEVEL_LOCAL];\n    cur_closures = vm->levels[NJS_LEVEL_CLOSURE];\n    cur_temp = vm->levels[NJS_LEVEL_TEMP];\n    top = vm->top_frame;\n    frame = vm->active_frame;\n\n    vm->levels[NJS_LEVEL_LOCAL] = async->local;\n    vm->levels[NJS_LEVEL_CLOSURE] = njs_function_closures(async->function);\n    vm->levels[NJS_LEVEL_TEMP] = async->temp;\n\n    vm->top_frame = async;\n    vm->active_frame = async_frame;\n\n    *njs_scope_value(vm, ctx->index) = *value;\n    vm->retval = *value;\n\n    vm->top_frame->retval = &vm->retval;\n\n    function->context = ctx->capability;\n    function->await = ctx;\n\n    ret = njs_vmcode_interpreter(vm, ctx->pc);\n\n    function->context = NULL;\n    function->await = NULL;\n\n    vm->levels[NJS_LEVEL_LOCAL] = cur_local;\n    vm->levels[NJS_LEVEL_CLOSURE] = cur_closures;\n    vm->levels[NJS_LEVEL_TEMP] = cur_temp;\n\n    vm->top_frame = top;\n    vm->active_frame = frame;\n\n    if (ret == NJS_OK) {\n        ret = njs_function_call(vm, njs_function(&ctx->capability->resolve),\n                            &njs_value_undefined, &vm->retval, 1, &vm->retval);\n\n        njs_async_context_free(vm, ctx);\n\n    } else if (ret == NJS_AGAIN) {\n        ret = NJS_OK;\n\n    } else if (ret == NJS_ERROR) {\n        if (njs_is_memory_error(vm, &vm->retval)) {\n            return NJS_ERROR;\n        }\n\n        value = &vm->retval;\n\n        goto failed;\n    }\n\n    return ret;\n\nfailed:\n\n    (void) njs_function_call(vm, njs_function(&ctx->capability->reject),\n                             &njs_value_undefined, value, 1, &vm->retval);\n\n    njs_async_context_free(vm, ctx);\n\n    return NJS_ERROR;\n}","target":1,"code_token_length":636,"total_token_length":872,"max_tokens_setting":1024}
+{"idx":309937,"func":"sysmouse_server(SCREEN *sp)\n{\n    struct mouse_info the_mouse;\n    MEVENT *work;\n\n    the_mouse.operation = MOUSE_GETINFO;\n    if (sp != 0\n\t&& sp->_mouse_fd >= 0\n\t&& sp->_sysmouse_tail < FIFO_SIZE\n\t&& ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {\n\n\tif (sp->_sysmouse_head > sp->_sysmouse_tail) {\n\t    sp->_sysmouse_tail = 0;\n\t    sp->_sysmouse_head = 0;\n\t}\n\twork = &(sp->_sysmouse_fifo[sp->_sysmouse_tail]);\n\tmemset(work, 0, sizeof(*work));\n\twork->id = NORMAL_EVENT;\t\/* there's only one mouse... *\/\n\n\tsp->_sysmouse_old_buttons = sp->_sysmouse_new_buttons;\n\tsp->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;\n\n\tif (sp->_sysmouse_new_buttons) {\n\t    if (sp->_sysmouse_new_buttons & 1)\n\t\twork->bstate |= BUTTON1_PRESSED;\n\t    if (sp->_sysmouse_new_buttons & 2)\n\t\twork->bstate |= BUTTON2_PRESSED;\n\t    if (sp->_sysmouse_new_buttons & 4)\n\t\twork->bstate |= BUTTON3_PRESSED;\n\t} else {\n\t    if (sp->_sysmouse_old_buttons & 1)\n\t\twork->bstate |= BUTTON1_RELEASED;\n\t    if (sp->_sysmouse_old_buttons & 2)\n\t\twork->bstate |= BUTTON2_RELEASED;\n\t    if (sp->_sysmouse_old_buttons & 4)\n\t\twork->bstate |= BUTTON3_RELEASED;\n\t}\n\n\t\/* for cosmetic bug in syscons.c on FreeBSD 3.[34] *\/\n\tthe_mouse.operation = MOUSE_HIDE;\n\tioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);\n\tthe_mouse.operation = MOUSE_SHOW;\n\tioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);\n\n\t\/*\n\t * We're only interested if the button is pressed or released.\n\t * FIXME: implement continuous event-tracking.\n\t *\/\n\tif (sp->_sysmouse_new_buttons != sp->_sysmouse_old_buttons) {\n\t    sp->_sysmouse_tail += 1;\n\t}\n\twork->x = the_mouse.u.data.x \/ sp->_sysmouse_char_width;\n\twork->y = the_mouse.u.data.y \/ sp->_sysmouse_char_height;\n    }\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":442573,"func":"void memslot_info_init(RedMemSlotInfo *info,\n                       uint32_t num_groups, uint32_t num_slots,\n                       uint8_t generation_bits,\n                       uint8_t id_bits,\n                       uint8_t internal_groupslot_id)\n{\n    uint32_t i;\n\n    spice_assert(num_slots > 0);\n    spice_assert(num_groups > 0);\n\n    info->num_memslots_groups = num_groups;\n    info->num_memslots = num_slots;\n    info->generation_bits = generation_bits;\n    info->mem_slot_bits = id_bits;\n    info->internal_groupslot_id = internal_groupslot_id;\n\n    info->mem_slots = g_new(MemSlot *, num_groups);\n\n    for (i = 0; i < num_groups; ++i) {\n        info->mem_slots[i] = g_new0(MemSlot, num_slots);\n    }\n\n    \/* TODO: use QXLPHYSICAL_BITS *\/\n    info->memslot_id_shift = 64 - info->mem_slot_bits;\n    info->memslot_gen_shift = 64 - (info->mem_slot_bits + info->generation_bits);\n    info->memslot_gen_mask = ~((QXLPHYSICAL)-1 << info->generation_bits);\n    info->memslot_clean_virt_mask = (((QXLPHYSICAL)(-1)) >>\n                                       (info->mem_slot_bits + info->generation_bits));\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":234156,"func":"frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_regs)\n{\n  unsigned int r;\n  char tmp[100];\n\n  if (*max_regs != fc->ncols)\n    *max_regs = fc->ncols;\n\n  if (*need_col_headers)\n    {\n      *need_col_headers = 0;\n\n      printf (\"%-*s CFA      \", eh_addr_size * 2, \"   LOC\");\n\n      for (r = 0; r < *max_regs; r++)\n\tif (fc->col_type[r] != DW_CFA_unreferenced)\n\t  {\n\t    if (r == fc->ra)\n\t      printf (\"ra    \");\n\t    else\n\t      printf (\"%-5s \", regname (r, 1));\n\t  }\n\n      printf (\"\\n\");\n    }\n\n  print_dwarf_vma (fc->pc_begin, eh_addr_size);\n  if (fc->cfa_exp)\n    strcpy (tmp, \"exp\");\n  else\n    sprintf (tmp, \"%s%+d\", regname (fc->cfa_reg, 1), (int) fc->cfa_offset);\n  printf (\"%-8s \", tmp);\n\n  for (r = 0; r < fc->ncols; r++)\n    {\n      if (fc->col_type[r] != DW_CFA_unreferenced)\n\t{\n\t  switch (fc->col_type[r])\n\t    {\n\t    case DW_CFA_undefined:\n\t      strcpy (tmp, \"u\");\n\t      break;\n\t    case DW_CFA_same_value:\n\t      strcpy (tmp, \"s\");\n\t      break;\n\t    case DW_CFA_offset:\n\t      sprintf (tmp, \"c%+d\", fc->col_offset[r]);\n\t      break;\n\t    case DW_CFA_val_offset:\n\t      sprintf (tmp, \"v%+d\", fc->col_offset[r]);\n\t      break;\n\t    case DW_CFA_register:\n\t      sprintf (tmp, \"%s\", regname (fc->col_offset[r], 0));\n\t      break;\n\t    case DW_CFA_expression:\n\t      strcpy (tmp, \"exp\");\n\t      break;\n\t    case DW_CFA_val_expression:\n\t      strcpy (tmp, \"vexp\");\n\t      break;\n\t    default:\n\t      strcpy (tmp, \"n\/a\");\n\t      break;\n\t    }\n\t  printf (\"%-5s \", tmp);\n\t}\n    }\n  printf (\"\\n\");\n}","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":317074,"func":"static int smk_ptrace_rule_check(struct task_struct *tracer,\n\t\t\t\t struct smack_known *tracee_known,\n\t\t\t\t unsigned int mode, const char *func)\n{\n\tint rc;\n\tstruct smk_audit_info ad, *saip = NULL;\n\tstruct task_smack *tsp;\n\tstruct smack_known *tracer_known;\n\tconst struct cred *tracercred;\n\n\tif ((mode & PTRACE_MODE_NOAUDIT) == 0) {\n\t\tsmk_ad_init(&ad, func, LSM_AUDIT_DATA_TASK);\n\t\tsmk_ad_setfield_u_tsk(&ad, tracer);\n\t\tsaip = &ad;\n\t}\n\n\trcu_read_lock();\n\ttracercred = __task_cred(tracer);\n\ttsp = smack_cred(tracercred);\n\ttracer_known = smk_of_task(tsp);\n\n\tif ((mode & PTRACE_MODE_ATTACH) &&\n\t    (smack_ptrace_rule == SMACK_PTRACE_EXACT ||\n\t     smack_ptrace_rule == SMACK_PTRACE_DRACONIAN)) {\n\t\tif (tracer_known->smk_known == tracee_known->smk_known)\n\t\t\trc = 0;\n\t\telse if (smack_ptrace_rule == SMACK_PTRACE_DRACONIAN)\n\t\t\trc = -EACCES;\n\t\telse if (smack_privileged_cred(CAP_SYS_PTRACE, tracercred))\n\t\t\trc = 0;\n\t\telse\n\t\t\trc = -EACCES;\n\n\t\tif (saip)\n\t\t\tsmack_log(tracer_known->smk_known,\n\t\t\t\t  tracee_known->smk_known,\n\t\t\t\t  0, rc, saip);\n\n\t\trcu_read_unlock();\n\t\treturn rc;\n\t}\n\n\t\/* In case of rule==SMACK_PTRACE_DEFAULT or mode==PTRACE_MODE_READ *\/\n\trc = smk_tskacc(tsp, tracee_known, smk_ptrace_mode(mode), saip);\n\n\trcu_read_unlock();\n\treturn rc;\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":247653,"func":"TEST_P(SslSocketTest, OverrideRequestedServerNameWithoutSniInUpstreamTlsContext) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n\n  Network::TransportSocketOptionsConstSharedPtr transport_socket_options(\n      new Network::TransportSocketOptionsImpl(\"example.com\"));\n  TestUtilOptionsV2 test_options(listener, client, true, GetParam());\n  testUtilV2(test_options.setExpectedRequestedServerName(\"example.com\")\n                 .setTransportSocketOptions(transport_socket_options));\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":473899,"func":"code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc ARG_UNUSED)\n{\n#define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80)\n#define UTF8_TRAIL0(code)        (UChar )(((code) & 0x3f) | 0x80)\n\n  if ((code & 0xffffff80) == 0) {\n    *buf = (UChar )code;\n    return 1;\n  }\n  else {\n    UChar *p = buf;\n\n    if ((code & 0xfffff800) == 0) {\n      *p++ = (UChar )(((code>>6)& 0x1f) | 0xc0);\n    }\n    else if ((code & 0xffff0000) == 0) {\n      *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);\n      *p++ = UTF8_TRAILS(code, 6);\n    }\n    else if ((code & 0xffe00000) == 0) {\n      *p++ = (UChar )(((code>>18) & 0x07) | 0xf0);\n      *p++ = UTF8_TRAILS(code, 12);\n      *p++ = UTF8_TRAILS(code,  6);\n    }\n    else if ((code & 0xfc000000) == 0) {\n      *p++ = (UChar )(((code>>24) & 0x03) | 0xf8);\n      *p++ = UTF8_TRAILS(code, 18);\n      *p++ = UTF8_TRAILS(code, 12);\n      *p++ = UTF8_TRAILS(code,  6);\n    }\n    else if ((code & 0x80000000) == 0) {\n      *p++ = (UChar )(((code>>30) & 0x01) | 0xfc);\n      *p++ = UTF8_TRAILS(code, 24);\n      *p++ = UTF8_TRAILS(code, 18);\n      *p++ = UTF8_TRAILS(code, 12);\n      *p++ = UTF8_TRAILS(code,  6);\n    }\n#ifdef USE_INVALID_CODE_SCHEME\n    else if (code == INVALID_CODE_FE) {\n      *p = 0xfe;\n      return 1;\n    }\n    else if (code == INVALID_CODE_FF) {\n      *p = 0xff;\n      return 1;\n    }\n#endif\n    else {\n      return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;\n    }\n\n    *p++ = UTF8_TRAIL0(code);\n    return (int)(p - buf);\n  }\n}","target":0,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":500084,"func":"static struct tm *k_gmtime(ASN1_GENERALIZEDTIME *gtime, struct tm *k_tm)\n\t{\n\tchar \t\tc, *p;\n\n\tif (!k_tm)  return NULL;\n\tif (gtime == NULL  ||  gtime->length < 14)  return NULL;\n\tif (gtime->data == NULL)  return NULL;\n\n\tp = (char *)>ime->data[14];\n\n\tc = *p;\t *p = '\\0';  p -= 2;  k_tm->tm_sec  = atoi(p);      *(p+2) = c;\n\tc = *p;\t *p = '\\0';  p -= 2;  k_tm->tm_min  = atoi(p);      *(p+2) = c;\n\tc = *p;\t *p = '\\0';  p -= 2;  k_tm->tm_hour = atoi(p);      *(p+2) = c;\n\tc = *p;\t *p = '\\0';  p -= 2;  k_tm->tm_mday = atoi(p);      *(p+2) = c;\n\tc = *p;\t *p = '\\0';  p -= 2;  k_tm->tm_mon  = atoi(p)-1;    *(p+2) = c;\n\tc = *p;\t *p = '\\0';  p -= 4;  k_tm->tm_year = atoi(p)-1900; *(p+4) = c;\n\n\treturn k_tm;\n\t}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":436102,"func":"\nstatic int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)\n{\n\tstruct io_uring_task *tctx;\n\tint submitted = 0;\n\n\t\/* make sure SQ entry isn't read before tail *\/\n\tnr = min3(nr, ctx->sq_entries, io_sqring_entries(ctx));\n\tif (!percpu_ref_tryget_many(&ctx->refs, nr))\n\t\treturn -EAGAIN;\n\n\ttctx = current->io_uring;\n\ttctx->cached_refs -= nr;\n\tif (unlikely(tctx->cached_refs < 0)) {\n\t\tunsigned int refill = -tctx->cached_refs + IO_TCTX_REFS_CACHE_NR;\n\n\t\tpercpu_counter_add(&tctx->inflight, refill);\n\t\trefcount_add(refill, ¤t->usage);\n\t\ttctx->cached_refs += refill;\n\t}\n\tio_submit_state_start(&ctx->submit_state, nr);\n\n\twhile (submitted < nr) {\n\t\tconst struct io_uring_sqe *sqe;\n\t\tstruct io_kiocb *req;\n\n\t\treq = io_alloc_req(ctx);\n\t\tif (unlikely(!req)) {\n\t\t\tif (!submitted)\n\t\t\t\tsubmitted = -EAGAIN;\n\t\t\tbreak;\n\t\t}\n\t\tsqe = io_get_sqe(ctx);\n\t\tif (unlikely(!sqe)) {\n\t\t\tkmem_cache_free(req_cachep, req);\n\t\t\tbreak;\n\t\t}\n\t\t\/* will complete beyond this point, count as submitted *\/\n\t\tsubmitted++;\n\t\tif (io_submit_sqe(ctx, req, sqe))\n\t\t\tbreak;\n\t}\n\n\tif (unlikely(submitted != nr)) {\n\t\tint ref_used = (submitted == -EAGAIN) ? 0 : submitted;\n\t\tint unused = nr - ref_used;\n\n\t\tcurrent->io_uring->cached_refs += unused;\n\t\tpercpu_ref_put_many(&ctx->refs, unused);\n\t}\n\n\tio_submit_state_end(&ctx->submit_state, ctx);\n\t \/* Commit SQ ring head once we've consumed and submitted all SQEs *\/\n\tio_commit_sqring(ctx);\n\n\treturn submitted;","target":0,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":376329,"func":"gpg_ctx_free (struct _GpgCtx *gpg)\n{\n\tgint i;\n\n\tif (gpg == NULL)\n\t\treturn;\n\n\tif (gpg->session)\n\t\tg_object_unref (gpg->session);\n\n\tg_hash_table_foreach (gpg->userid_hint, userid_hint_free, NULL);\n\tg_hash_table_destroy (gpg->userid_hint);\n\n\tg_slist_free_full (gpg->userids, g_free);\n\n\tg_free (gpg->sigfile);\n\n\tif (gpg->recipients) {\n\t\tfor (i = 0; i < gpg->recipients->len; i++)\n\t\t\tg_free (gpg->recipients->pdata[i]);\n\n\t\tg_ptr_array_free (gpg->recipients, TRUE);\n\t}\n\n\tif (gpg->stdin_fd != -1)\n\t\tclose (gpg->stdin_fd);\n\tif (gpg->stdout_fd != -1)\n\t\tclose (gpg->stdout_fd);\n\tif (gpg->stderr_fd != -1)\n\t\tclose (gpg->stderr_fd);\n\tif (gpg->status_fd != -1)\n\t\tclose (gpg->status_fd);\n\tif (gpg->passwd_fd != -1)\n\t\tclose (gpg->passwd_fd);\n\n\tg_free (gpg->statusbuf);\n\n\tg_free (gpg->need_id);\n\n\tif (gpg->passwd) {\n\t\tmemset (gpg->passwd, 0, strlen (gpg->passwd));\n\t\tg_free (gpg->passwd);\n\t}\n\n\tif (gpg->istream)\n\t\tg_object_unref (gpg->istream);\n\n\tif (gpg->ostream)\n\t\tg_object_unref (gpg->ostream);\n\n\tg_object_unref (gpg->diagnostics);\n\n\tif (gpg->signers)\n\t\tg_string_free (gpg->signers, TRUE);\n\n\tg_free (gpg);\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":506438,"func":"mech_rpa_build_token2(struct rpa_auth_request *request, size_t *size)\n{\n\tconst struct auth_settings *set = request->auth_request.set;\n\tunsigned int realms_len, length;\n\tstring_t *realms;\n\tbuffer_t *buf;\n\tunsigned char timestamp[RPA_TIMESTAMP_LEN \/ 2];\n\tconst char *const *tmp;\n\n\trealms = t_str_new(64);\n\tfor (tmp = set->realms_arr; *tmp != NULL; tmp++) {\n\t\trpa_add_realm(realms, *tmp, request->auth_request.service);\n\t}\n\n\tif (str_len(realms) == 0) {\n\t\trpa_add_realm(realms, *set->default_realm != '\\0' ?\n\t\t\t      set->default_realm : my_hostname,\n\t\t\t      request->auth_request.service);\n\t}\n\n\trealms_len = str_len(realms) - 1;\n        length = sizeof(rpa_oid) + 3 + RPA_SCHALLENGE_LEN +\n\t\tRPA_TIMESTAMP_LEN + 2 + realms_len;\n\n\tbuf = buffer_create_dynamic(request->pool, length + 4);\n\n\tbuffer_append_c(buf, ASN1_APPLICATION);\n\tbuffer_append_asn1_length(buf, length);\n\tbuffer_append(buf, rpa_oid, sizeof(rpa_oid));\n\n\t\/* Protocol version *\/\n\tbuffer_append_c(buf, 3);\n\tbuffer_append_c(buf, 0);\n\n\t\/* Service challenge *\/\n\trequest->service_challenge =\n\t\tp_malloc(request->pool, RPA_SCHALLENGE_LEN);\n\trandom_fill(request->service_challenge, RPA_SCHALLENGE_LEN);\n\tbuffer_append_c(buf, RPA_SCHALLENGE_LEN);\n\tbuffer_append(buf, request->service_challenge, RPA_SCHALLENGE_LEN);\n\n\t\/* Timestamp, looks like clients accept anything we send *\/\n\trandom_fill(timestamp, sizeof(timestamp));\n\trequest->service_timestamp = p_malloc(request->pool, RPA_TIMESTAMP_LEN);\n\tmemcpy(request->service_timestamp,\n\t       binary_to_hex(timestamp, sizeof(timestamp)),\n\t       RPA_TIMESTAMP_LEN);\n\tbuffer_append(buf, request->service_timestamp, RPA_TIMESTAMP_LEN);\n\n\t\/* Realm list *\/\n\tbuffer_append_c(buf, realms_len >> 8);\n\tbuffer_append_c(buf, realms_len & 0xff);\n\tbuffer_append(buf, str_c(realms), realms_len);\n\n\t*size = buf->used;\n\treturn buffer_free_without_data(&buf);\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":267971,"func":"R_IPI RBinFile *r_bin_file_xtr_load_buffer(RBin *bin, RBinXtrPlugin *xtr, const char *filename, RBuffer *buf, ut64 baseaddr, ut64 loadaddr, int idx, int fd, int rawstr) {\n\tr_return_val_if_fail (bin && xtr && buf, NULL);\n\n\tRBinFile *bf = r_bin_file_find_by_name (bin, filename);\n\tif (!bf) {\n\t\tbf = r_bin_file_new (bin, filename, r_buf_size (buf), rawstr, fd, xtr->name, bin->sdb, false);\n\t\tif (!bf) {\n\t\t\treturn NULL;\n\t\t}\n\t\tr_list_append (bin->binfiles, bf);\n\t\tif (!bin->cur) {\n\t\t\tbin->cur = bf;\n\t\t}\n\t}\n\tr_list_free (bf->xtr_data);\n\tbf->xtr_data = NULL;\n\tif (xtr->extractall_from_buffer) {\n\t\tbf->xtr_data = xtr->extractall_from_buffer (bin, buf);\n\t} else if (xtr->extractall_from_bytes) {\n\t\tut64 sz = 0;\n\t\tconst ut8 *bytes = r_buf_data (buf, &sz);\n\t\teprintf (\"TODO: Implement extractall_from_buffer in '%s' xtr.bin plugin\\n\", xtr->name);\n\t\tbf->xtr_data = xtr->extractall_from_bytes (bin, bytes, sz);\n\t}\n\tif (bf->xtr_data) {\n\t\tRListIter *iter;\n\t\tRBinXtrData *x;\n\t\t\/\/populate xtr_data with baddr and laddr that will be used later on\n\t\t\/\/r_bin_file_object_new_from_xtr_data\n\t\tr_list_foreach (bf->xtr_data, iter, x) {\n\t\t\tx->baddr = baseaddr? baseaddr : UT64_MAX;\n\t\t\tx->laddr = loadaddr? loadaddr : UT64_MAX;\n\t\t}\n\t}\n\tbf->loadaddr = loadaddr;\n\treturn bf;\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":196790,"func":"Status Examples::Initialize(OpKernelContext* const context,\n                            const ModelWeights& weights,\n                            const int num_sparse_features,\n                            const int num_sparse_features_with_values,\n                            const int num_dense_features) {\n  num_features_ = num_sparse_features + num_dense_features;\n\n  OpInputList sparse_example_indices_inputs;\n  TF_RETURN_IF_ERROR(context->input_list(\"sparse_example_indices\",\n                                         &sparse_example_indices_inputs));\n  if (sparse_example_indices_inputs.size() != num_sparse_features)\n    return errors::InvalidArgument(\n        \"Expected \", num_sparse_features,\n        \" tensors in sparse_example_indices but got \",\n        sparse_example_indices_inputs.size());\n  OpInputList sparse_feature_indices_inputs;\n  TF_RETURN_IF_ERROR(context->input_list(\"sparse_feature_indices\",\n                                         &sparse_feature_indices_inputs));\n  if (sparse_feature_indices_inputs.size() != num_sparse_features)\n    return errors::InvalidArgument(\n        \"Expected \", num_sparse_features,\n        \" tensors in sparse_feature_indices but got \",\n        sparse_feature_indices_inputs.size());\n  OpInputList sparse_feature_values_inputs;\n  if (num_sparse_features_with_values > 0) {\n    TF_RETURN_IF_ERROR(context->input_list(\"sparse_feature_values\",\n                                           &sparse_feature_values_inputs));\n    if (sparse_feature_values_inputs.size() != num_sparse_features_with_values)\n      return errors::InvalidArgument(\n          \"Expected \", num_sparse_features_with_values,\n          \" tensors in sparse_feature_values but got \",\n          sparse_feature_values_inputs.size());\n  }\n\n  const Tensor* example_weights_t;\n  TF_RETURN_IF_ERROR(context->input(\"example_weights\", &example_weights_t));\n  auto example_weights = example_weights_t->flat<float>();\n\n  if (example_weights.size() >= std::numeric_limits<int>::max()) {\n    return errors::InvalidArgument(strings::Printf(\n        \"Too many examples in a mini-batch: %zu > %d\", example_weights.size(),\n        std::numeric_limits<int>::max()));\n  }\n\n  \/\/ The static_cast here is safe since num_examples can be at max an int.\n  const int num_examples = static_cast<int>(example_weights.size());\n  const Tensor* example_labels_t;\n  TF_RETURN_IF_ERROR(context->input(\"example_labels\", &example_labels_t));\n  auto example_labels = example_labels_t->flat<float>();\n\n  OpInputList dense_features_inputs;\n  TF_RETURN_IF_ERROR(\n      context->input_list(\"dense_features\", &dense_features_inputs));\n\n  examples_.clear();\n  examples_.resize(num_examples);\n  probabilities_.resize(num_examples);\n  sampled_index_.resize(num_examples);\n  sampled_count_.resize(num_examples);\n  for (int example_id = 0; example_id < num_examples; ++example_id) {\n    Example* const example = &examples_[example_id];\n    example->sparse_features_.resize(num_sparse_features);\n    example->dense_vectors_.resize(num_dense_features);\n    example->example_weight_ = example_weights(example_id);\n    example->example_label_ = example_labels(example_id);\n  }\n  const DeviceBase::CpuWorkerThreads& worker_threads =\n      *context->device()->tensorflow_cpu_worker_threads();\n  TF_RETURN_IF_ERROR(CreateSparseFeatureRepresentation(\n      worker_threads, num_examples, num_sparse_features, weights,\n      sparse_example_indices_inputs, sparse_feature_indices_inputs,\n      sparse_feature_values_inputs, &examples_));\n  TF_RETURN_IF_ERROR(CreateDenseFeatureRepresentation(\n      worker_threads, num_examples, num_dense_features, weights,\n      dense_features_inputs, &examples_));\n  TF_RETURN_IF_ERROR(ComputeSquaredNormPerExample(\n      worker_threads, num_examples, num_sparse_features, num_dense_features,\n      &examples_));\n  return Status::OK();\n}","target":1,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":390602,"func":"XkbSendIndicatorMap(\tClientPtr\t\t\tclient,\n\t\t\tXkbIndicatorPtr\t\t\tindicators,\n\t\t\txkbGetIndicatorMapReply *\trep)\n{\nint \t\t\tlength;\nCARD8 *\t\t\tmap;\nregister int\t\ti;\nregister unsigned\tbit;\n\n    length = rep->length*4;\n    if (length>0) {\n\tCARD8 *to;\n\tto= map= (CARD8 *)xalloc(length);\n\tif (map) {\n\t    xkbIndicatorMapWireDesc  *wire = (xkbIndicatorMapWireDesc *)to;\n\t    for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {\n\t\tif (rep->which&bit) {\n\t\t    wire->flags= indicators->maps[i].flags;\n\t\t    wire->whichGroups= indicators->maps[i].which_groups;\n\t\t    wire->groups= indicators->maps[i].groups;\n\t\t    wire->whichMods= indicators->maps[i].which_mods;\n\t\t    wire->mods= indicators->maps[i].mods.mask;\n\t\t    wire->realMods= indicators->maps[i].mods.real_mods;\n\t\t    wire->virtualMods= indicators->maps[i].mods.vmods;\n\t\t    wire->ctrls= indicators->maps[i].ctrls;\n\t\t    if (client->swapped) {\n\t\t\tregister int n;\n\t\t\tswaps(&wire->virtualMods,n);\n\t\t\tswapl(&wire->ctrls,n);\n\t\t    }\n\t\t    wire++;\n\t\t}\n\t    }\n\t    to = (CARD8 *)wire;\n\t    if ((to-map)!=length) {\n\t\tclient->errorValue = _XkbErrCode2(0xff,length);\n\t\treturn BadLength;\n\t    }\n\t}\n\telse return BadAlloc;\n    }\n    else map = NULL;\n    if (client->swapped) {\n\tswaps(&rep->sequenceNumber,i);\n\tswapl(&rep->length,i);\n\tswapl(&rep->which,i);\n\tswapl(&rep->realIndicators,i);\n    }\n    WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply), (char *)rep);\n    if (map) {\n\tWriteToClient(client, length, (char *)map);\n\txfree((char *)map);\n    }\n    return client->noClientException;\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":400113,"func":"vector<PortForwardSourceRequest> parseRangesToRequests(const string& input) {\n  vector<PortForwardSourceRequest> pfsrs;\n  auto j = split(input, ',');\n  for (auto& pair : j) {\n    vector<string> sourceDestination = split(pair, ':');\n    try {\n      if (sourceDestination[0].find_first_not_of(\"0123456789-\") !=\n              string::npos &&\n          sourceDestination[1].find_first_not_of(\"0123456789-\") !=\n              string::npos) {\n        PortForwardSourceRequest pfsr;\n        pfsr.set_environmentvariable(sourceDestination[0]);\n        pfsr.mutable_destination()->set_name(sourceDestination[1]);\n        pfsrs.push_back(pfsr);\n      } else if (sourceDestination[0].find('-') != string::npos &&\n                 sourceDestination[1].find('-') != string::npos) {\n        vector<string> sourcePortRange = split(sourceDestination[0], '-');\n        int sourcePortStart = stoi(sourcePortRange[0]);\n        int sourcePortEnd = stoi(sourcePortRange[1]);\n\n        vector<string> destinationPortRange = split(sourceDestination[1], '-');\n        int destinationPortStart = stoi(destinationPortRange[0]);\n        int destinationPortEnd = stoi(destinationPortRange[1]);\n\n        if (sourcePortEnd - sourcePortStart !=\n            destinationPortEnd - destinationPortStart) {\n          STFATAL << \"source\/destination port range mismatch\";\n          exit(1);\n        } else {\n          int portRangeLength = sourcePortEnd - sourcePortStart + 1;\n          for (int i = 0; i < portRangeLength; ++i) {\n            PortForwardSourceRequest pfsr;\n            pfsr.mutable_source()->set_port(sourcePortStart + i);\n            pfsr.mutable_destination()->set_port(destinationPortStart + i);\n            pfsrs.push_back(pfsr);\n          }\n        }\n      } else if (sourceDestination[0].find('-') != string::npos ||\n                 sourceDestination[1].find('-') != string::npos) {\n        STFATAL << \"Invalid port range syntax: if source is range, \"\n                   \"destination must be range\";\n      } else {\n        PortForwardSourceRequest pfsr;\n        pfsr.mutable_source()->set_port(stoi(sourceDestination[0]));\n        pfsr.mutable_destination()->set_port(stoi(sourceDestination[1]));\n        pfsrs.push_back(pfsr);\n      }\n    } catch (const std::logic_error& lr) {\n      STFATAL << \"Logic error: \" << lr.what();\n      exit(1);\n    }\n  }\n  return pfsrs;\n}","target":0,"code_token_length":575,"total_token_length":811,"max_tokens_setting":1024}
+{"idx":333077,"func":"st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED)\n{\n#ifdef NFA_REGEXP_ERROR_LOG\n    FILE *df;\n    int *p2;\n\n    df = fopen(NFA_REGEXP_ERROR_LOG, \"a\");\n    if (df)\n    {\n\tfprintf(df, \"Error popping the stack!\\n\");\n# ifdef DEBUG\n\tfprintf(df, \"Current regexp is \\\"%s\\\"\\n\", nfa_regengine.expr);\n# endif\n\tfprintf(df, \"Postfix form is: \");\n# ifdef DEBUG\n\tfor (p2 = postfix; p2 < end; p2++)\n\t{\n\t    nfa_set_code(*p2);\n\t    fprintf(df, \"%s, \", code);\n\t}\n\tnfa_set_code(*p);\n\tfprintf(df, \"\\nCurrent position is: \");\n\tfor (p2 = postfix; p2 <= p; p2 ++)\n\t{\n\t    nfa_set_code(*p2);\n\t    fprintf(df, \"%s, \", code);\n\t}\n# else\n\tfor (p2 = postfix; p2 < end; p2++)\n\t    fprintf(df, \"%d, \", *p2);\n\tfprintf(df, \"\\nCurrent position is: \");\n\tfor (p2 = postfix; p2 <= p; p2 ++)\n\t    fprintf(df, \"%d, \", *p2);\n# endif\n\tfprintf(df, \"\\n--------------------------\\n\");\n\tfclose(df);\n    }\n#endif\n    emsg(_(\"E874: (NFA) Could not pop the stack!\"));\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":238543,"func":"static int check_sock_access(struct bpf_verifier_env *env, int insn_idx,\n\t\t\t     u32 regno, int off, int size,\n\t\t\t     enum bpf_access_type t)\n{\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tstruct bpf_reg_state *reg = ®s[regno];\n\tstruct bpf_insn_access_aux info = {};\n\tbool valid;\n\n\tif (reg->smin_value < 0) {\n\t\tverbose(env, \"R%d min value is negative, either use unsigned index or do a if (index >=0) check.\\n\",\n\t\t\tregno);\n\t\treturn -EACCES;\n\t}\n\n\tswitch (reg->type) {\n\tcase PTR_TO_SOCK_COMMON:\n\t\tvalid = bpf_sock_common_is_valid_access(off, size, t, &info);\n\t\tbreak;\n\tcase PTR_TO_SOCKET:\n\t\tvalid = bpf_sock_is_valid_access(off, size, t, &info);\n\t\tbreak;\n\tcase PTR_TO_TCP_SOCK:\n\t\tvalid = bpf_tcp_sock_is_valid_access(off, size, t, &info);\n\t\tbreak;\n\tcase PTR_TO_XDP_SOCK:\n\t\tvalid = bpf_xdp_sock_is_valid_access(off, size, t, &info);\n\t\tbreak;\n\tdefault:\n\t\tvalid = false;\n\t}\n\n\n\tif (valid) {\n\t\tenv->insn_aux_data[insn_idx].ctx_field_size =\n\t\t\tinfo.ctx_field_size;\n\t\treturn 0;\n\t}\n\n\tverbose(env, \"R%d invalid %s access off=%d size=%d\\n\",\n\t\tregno, reg_type_str(env, reg->type), off, size);\n\n\treturn -EACCES;\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":234799,"func":"static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,\n\t\t\t  struct btrfs_device *device,\n\t\t\t  u64 start, u64 *dev_extent_len)\n{\n\tstruct btrfs_fs_info *fs_info = device->fs_info;\n\tstruct btrfs_root *root = fs_info->dev_root;\n\tint ret;\n\tstruct btrfs_path *path;\n\tstruct btrfs_key key;\n\tstruct btrfs_key found_key;\n\tstruct extent_buffer *leaf = NULL;\n\tstruct btrfs_dev_extent *extent = NULL;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tkey.objectid = device->devid;\n\tkey.offset = start;\n\tkey.type = BTRFS_DEV_EXTENT_KEY;\nagain:\n\tret = btrfs_search_slot(trans, root, &key, path, -1, 1);\n\tif (ret > 0) {\n\t\tret = btrfs_previous_item(root, path, key.objectid,\n\t\t\t\t\t  BTRFS_DEV_EXTENT_KEY);\n\t\tif (ret)\n\t\t\tgoto out;\n\t\tleaf = path->nodes[0];\n\t\tbtrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);\n\t\textent = btrfs_item_ptr(leaf, path->slots[0],\n\t\t\t\t\tstruct btrfs_dev_extent);\n\t\tBUG_ON(found_key.offset > start || found_key.offset +\n\t\t       btrfs_dev_extent_length(leaf, extent) < start);\n\t\tkey = found_key;\n\t\tbtrfs_release_path(path);\n\t\tgoto again;\n\t} else if (ret == 0) {\n\t\tleaf = path->nodes[0];\n\t\textent = btrfs_item_ptr(leaf, path->slots[0],\n\t\t\t\t\tstruct btrfs_dev_extent);\n\t} else {\n\t\tgoto out;\n\t}\n\n\t*dev_extent_len = btrfs_dev_extent_length(leaf, extent);\n\n\tret = btrfs_del_item(trans, root, path);\n\tif (ret == 0)\n\t\tset_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags);\nout:\n\tbtrfs_free_path(path);\n\treturn ret;\n}","target":0,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":439174,"func":"static MagickBooleanType WriteAVSImage(const ImageInfo *image_info,Image *image)\n{\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    scene;\n\n  MemoryInfo\n    *pixel_info;\n\n  register const PixelPacket\n    *magick_restrict p;\n\n  register ssize_t\n    x;\n\n  register unsigned char\n    *magick_restrict q;\n\n  size_t\n    imageListLength;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    *pixels;\n\n  \/*\n    Open output image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(image != (Image *) NULL);\n  assert(image->signature == MagickCoreSignature);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);\n  if (status == MagickFalse)\n    return(status);\n  scene=0;\n  imageListLength=GetImageListLength(image);\n  do\n  {\n    \/*\n      Write AVS header.\n    *\/\n    (void) TransformImageColorspace(image,sRGBColorspace);\n    (void) WriteBlobMSBLong(image,(unsigned int) image->columns);\n    (void) WriteBlobMSBLong(image,(unsigned int) image->rows);\n    \/*\n      Allocate memory for pixels.\n    *\/\n    pixel_info=AcquireVirtualMemory(image->columns,4*sizeof(*pixels));\n    if (pixel_info == (MemoryInfo *) NULL)\n      ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    \/*\n      Convert MIFF to AVS raster pixels.\n    *\/\n    for (y=0; y < (ssize_t) image->rows; y++)\n    {\n      p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);\n      if (p == (PixelPacket *) NULL)\n        break;\n      q=pixels;\n      for (x=0; x < (ssize_t) image->columns; x++)\n      {\n        *q++=ScaleQuantumToChar((Quantum) (QuantumRange-(image->matte !=\n          MagickFalse ? GetPixelOpacity(p) : OpaqueOpacity)));\n        *q++=ScaleQuantumToChar(GetPixelRed(p));\n        *q++=ScaleQuantumToChar(GetPixelGreen(p));\n        *q++=ScaleQuantumToChar(GetPixelBlue(p));\n        p++;\n      }\n      count=WriteBlob(image,(size_t) (q-pixels),pixels);\n      if (count != (ssize_t) (q-pixels))\n        break;\n      if (image->previous == (Image *) NULL)\n        {\n          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,\n            image->rows);\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (GetNextImageInList(image) == (Image *) NULL)\n      break;\n    image=SyncNextImageInList(image);\n    status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);\n    if (status == MagickFalse)\n      break;\n  } while (image_info->adjoin != MagickFalse);\n  (void) CloseBlob(image);\n  return(MagickTrue);\n}","target":0,"code_token_length":735,"total_token_length":971,"max_tokens_setting":1024}
+{"idx":300766,"func":"static int tipc_connect(struct socket *sock, struct sockaddr *dest,\n\t\t\tint destlen, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest;\n\tstruct msghdr m = {NULL,};\n\tlong timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout;\n\tint previous;\n\tint res = 0;\n\n\tif (destlen != sizeof(struct sockaddr_tipc))\n\t\treturn -EINVAL;\n\n\tlock_sock(sk);\n\n\tif (tsk->group) {\n\t\tres = -EINVAL;\n\t\tgoto exit;\n\t}\n\n\tif (dst->family == AF_UNSPEC) {\n\t\tmemset(&tsk->peer, 0, sizeof(struct sockaddr_tipc));\n\t\tif (!tipc_sk_type_connectionless(sk))\n\t\t\tres = -EINVAL;\n\t\tgoto exit;\n\t}\n\tif (!tipc_sockaddr_is_sane(dst)) {\n\t\tres = -EINVAL;\n\t\tgoto exit;\n\t}\n\t\/* DGRAM\/RDM connect(), just save the destaddr *\/\n\tif (tipc_sk_type_connectionless(sk)) {\n\t\tmemcpy(&tsk->peer, dest, destlen);\n\t\tgoto exit;\n\t} else if (dst->addrtype == TIPC_SERVICE_RANGE) {\n\t\tres = -EINVAL;\n\t\tgoto exit;\n\t}\n\n\tprevious = sk->sk_state;\n\n\tswitch (sk->sk_state) {\n\tcase TIPC_OPEN:\n\t\t\/* Send a 'SYN-' to destination *\/\n\t\tm.msg_name = dest;\n\t\tm.msg_namelen = destlen;\n\n\t\t\/* If connect is in non-blocking case, set MSG_DONTWAIT to\n\t\t * indicate send_msg() is never blocked.\n\t\t *\/\n\t\tif (!timeout)\n\t\t\tm.msg_flags = MSG_DONTWAIT;\n\n\t\tres = __tipc_sendmsg(sock, &m, 0);\n\t\tif ((res < 0) && (res != -EWOULDBLOCK))\n\t\t\tgoto exit;\n\n\t\t\/* Just entered TIPC_CONNECTING state; the only\n\t\t * difference is that return value in non-blocking\n\t\t * case is EINPROGRESS, rather than EALREADY.\n\t\t *\/\n\t\tres = -EINPROGRESS;\n\t\tfallthrough;\n\tcase TIPC_CONNECTING:\n\t\tif (!timeout) {\n\t\t\tif (previous == TIPC_CONNECTING)\n\t\t\t\tres = -EALREADY;\n\t\t\tgoto exit;\n\t\t}\n\t\ttimeout = msecs_to_jiffies(timeout);\n\t\t\/* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs *\/\n\t\tres = tipc_wait_for_connect(sock, &timeout);\n\t\tbreak;\n\tcase TIPC_ESTABLISHED:\n\t\tres = -EISCONN;\n\t\tbreak;\n\tdefault:\n\t\tres = -EINVAL;\n\t}\n\nexit:\n\trelease_sock(sk);\n\treturn res;\n}","target":0,"code_token_length":598,"total_token_length":834,"max_tokens_setting":1024}
+{"idx":276897,"func":"static int do_i2c_probe(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t\tchar *const argv[])\n{\n\tint j;\n\tint addr = -1;\n\tint found = 0;\n#if defined(CONFIG_SYS_I2C_NOPROBES)\n\tint k, skip;\n\tunsigned int bus = GET_BUS_NUM;\n#endif\t\/* NOPROBES *\/\n\tint ret;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *bus, *dev;\n\n\tif (i2c_get_cur_bus(&bus))\n\t\treturn CMD_RET_FAILURE;\n#endif\n\n\tif (argc == 2)\n\t\taddr = simple_strtol(argv[1], 0, 16);\n\n\tputs (\"Valid chip addresses:\");\n\tfor (j = 0; j < 128; j++) {\n\t\tif ((0 <= addr) && (j != addr))\n\t\t\tcontinue;\n\n#if defined(CONFIG_SYS_I2C_NOPROBES)\n\t\tskip = 0;\n\t\tfor (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) {\n\t\t\tif (COMPARE_BUS(bus, k) && COMPARE_ADDR(j, k)) {\n\t\t\t\tskip = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (skip)\n\t\t\tcontinue;\n#endif\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tret = dm_i2c_probe(bus, j, 0, &dev);\n#else\n\t\tret = i2c_probe(j);\n#endif\n\t\tif (ret == 0) {\n\t\t\tprintf(\" %02X\", j);\n\t\t\tfound++;\n\t\t}\n\t}\n\tputc ('\\n');\n\n#if defined(CONFIG_SYS_I2C_NOPROBES)\n\tputs (\"Excluded chip addresses:\");\n\tfor (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) {\n\t\tif (COMPARE_BUS(bus,k))\n\t\t\tprintf(\" %02X\", NO_PROBE_ADDR(k));\n\t}\n\tputc ('\\n');\n#endif\n\n\treturn (0 == found);\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":430380,"func":"static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa,\n\t\t\t\t       int attr_len, bool log)\n{\n\n\tstruct sw_flow_actions *acts;\n\tint new_acts_size;\n\tsize_t req_size = NLA_ALIGN(attr_len);\n\tint next_offset = offsetof(struct sw_flow_actions, actions) +\n\t\t\t\t\t(*sfa)->actions_len;\n\n\tif (req_size <= (ksize(*sfa) - next_offset))\n\t\tgoto out;\n\n\tnew_acts_size = max(next_offset + req_size, ksize(*sfa) * 2);\n\n\tif (new_acts_size > MAX_ACTIONS_BUFSIZE) {\n\t\tif ((next_offset + req_size) > MAX_ACTIONS_BUFSIZE) {\n\t\t\tOVS_NLERR(log, \"Flow action size exceeds max %u\",\n\t\t\t\t  MAX_ACTIONS_BUFSIZE);\n\t\t\treturn ERR_PTR(-EMSGSIZE);\n\t\t}\n\t\tnew_acts_size = MAX_ACTIONS_BUFSIZE;\n\t}\n\n\tacts = nla_alloc_flow_actions(new_acts_size);\n\tif (IS_ERR(acts))\n\t\treturn (void *)acts;\n\n\tmemcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len);\n\tacts->actions_len = (*sfa)->actions_len;\n\tacts->orig_len = (*sfa)->orig_len;\n\tkfree(*sfa);\n\t*sfa = acts;\n\nout:\n\t(*sfa)->actions_len += req_size;\n\treturn  (struct nlattr *) ((unsigned char *)(*sfa) + next_offset);\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":224582,"func":"Status ValidateSparseTensor(InferenceContext* c, ShapeHandle indices_shape,\n                            ShapeHandle values_shape, ShapeHandle shape_shape) {\n  \/\/ Validate ranks.\n  ShapeHandle unused_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(indices_shape, 2, &unused_shape));\n  TF_RETURN_IF_ERROR(c->WithRank(values_shape, 1, &unused_shape));\n  TF_RETURN_IF_ERROR(c->WithRank(shape_shape, 1, &unused_shape));\n\n  \/\/ Number of elements in indices and values must match.\n  DimensionHandle num_index_elements_dim = c->Dim(indices_shape, 0);\n  if (c->ValueKnown(num_index_elements_dim)) {\n    DimensionHandle num_values_elements_dim = c->Dim(values_shape, 0);\n    if (c->ValueKnown(num_values_elements_dim)) {\n      int64_t num_index_elements = c->Value(num_index_elements_dim);\n      int64_t num_values_elements = c->Value(num_values_elements_dim);\n      if (num_index_elements != num_values_elements) {\n        return errors::InvalidArgument(\"Number of elements in index (\",\n                                       num_index_elements, \") and values (\",\n                                       num_values_elements, \") do not match.\");\n      }\n    }\n  }\n\n  \/\/ Rank embedded in indices must match shape.\n  DimensionHandle index_rank_dim = c->Dim(indices_shape, 1);\n  if (c->ValueKnown(index_rank_dim)) {\n    DimensionHandle shape_rank_dim = c->Dim(shape_shape, 0);\n    if (c->ValueKnown(shape_rank_dim)) {\n      int64_t index_rank = c->Value(index_rank_dim);\n      int32_t shape_rank = c->Value(shape_rank_dim);\n      if (index_rank != shape_rank) {\n        return errors::InvalidArgument(\"Index rank (\", index_rank,\n                                       \") and shape rank (\", shape_rank,\n                                       \") do not match.\");\n      }\n    }\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":234188,"func":"display_debug_str_offsets (struct dwarf_section *section,\n\t\t\t   void *file ATTRIBUTE_UNUSED)\n{\n  unsigned long idx;\n\n  if (section->size == 0)\n    {\n      printf (_(\"\\nThe %s section is empty.\\n\"), section->name);\n      return 0;\n    }\n\n  unsigned char *start = section->start;\n  unsigned char *end = start + section->size;\n  unsigned char *curr = start;\n\n  const char *suffix = strrchr (section->name, '.');\n  bool dwo = suffix && strcmp (suffix, \".dwo\") == 0;\n\n  if (dwo)\n    load_debug_section_with_follow (str_dwo, file);\n  else\n    load_debug_section_with_follow (str, file);\n\n  introduce (section, false);\n\n  while (curr < end)\n    {\n      dwarf_vma length;\n      dwarf_vma entry_length;\n\n      SAFE_BYTE_GET_AND_INC (length, curr, 4, end);\n      \/* FIXME: We assume that this means 64-bit DWARF is being used.  *\/\n      if (length == 0xffffffff)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (length, curr, 8, end);\n\t  entry_length = 8;\n\t}\n      else\n\tentry_length = 4;\n\n      unsigned char *entries_end;\n      if (length == 0)\n\t{\n\t  \/* This is probably an old style .debug_str_offset section which\n\t     just contains offsets and no header (and the first offset is 0).  *\/\n\t  length = section->size;\n\t  curr   = section->start;\n\t  entries_end = end;\n\n\t  printf (_(\"    Length: %#lx\\n\"), (unsigned long) length);\n\t  printf (_(\"       Index   Offset [String]\\n\"));\n\t}\n      else\n\t{\n\t  if (length <= (dwarf_vma) (end - curr))\n\t    entries_end = curr + length;\n\t  else\n\t    {\n\t      warn (_(\"Section %s is too small %#lx\\n\"),\n\t\t    section->name, (unsigned long) section->size);\n\t      entries_end = end;\n\t    }\n\n\t  int version;\n\t  SAFE_BYTE_GET_AND_INC (version, curr, 2, entries_end);\n\t  if (version != 5)\n\t    warn (_(\"Unexpected version number in str_offset header: %#x\\n\"), version);\n\n\t  int padding;\n\t  SAFE_BYTE_GET_AND_INC (padding, curr, 2, entries_end);\n\t  if (padding != 0)\n\t    warn (_(\"Unexpected value in str_offset header's padding field: %#x\\n\"), padding);\n\n\t  printf (_(\"    Length: %#lx\\n\"), (unsigned long) length);\n\t  printf (_(\"    Version: %#lx\\n\"), (unsigned long) version);\n\t  printf (_(\"       Index   Offset [String]\\n\"));\n\t}\n\n      for (idx = 0; curr < entries_end; idx++)\n\t{\n\t  dwarf_vma offset;\n\t  const unsigned char * string;\n\n\t  if ((dwarf_vma) (entries_end - curr) < entry_length)\n\t    \/* Not enough space to read one entry_length, give up.  *\/\n\t    return 0;\n\n\t  SAFE_BYTE_GET_AND_INC (offset, curr, entry_length, entries_end);\n\t  if (dwo)\n\t    string = (const unsigned char *)\n\t      fetch_indexed_string (idx, NULL, entry_length, dwo, 0);\n\t  else\n\t    string = fetch_indirect_string (offset);\n\n\t  printf (\"    %8lu %8s %s\\n\", idx, dwarf_vmatoa (\"x\", offset),\n\t\t  string);\n\t}\n    }\n\n  return 1;\n}","target":0,"code_token_length":756,"total_token_length":992,"max_tokens_setting":1024}
+{"idx":432734,"func":"static void ipa_region_clip(wmfAPI *API, wmfPolyRectangle_t *poly_rect)\n{\n  long\n    i;\n\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData (API);\n\n  \/* Reset any existing clip paths by popping wand *\/\n  if (ddata->clipping)\n    (void) PopDrawingWand(WmfDrawingWand);\n  ddata->clipping = MagickFalse;\n\n  if (poly_rect->count > 0)\n    {\n      char\n        clip_mask_id[MagickPathExtent];\n\n      \/* Define clip path *\/\n      ddata->clip_mask_id++;\n      DrawPushDefs(WmfDrawingWand);\n      (void) FormatLocaleString(clip_mask_id,MagickPathExtent,\"clip_%lu\",\n        ddata->clip_mask_id);\n      DrawPushClipPath(WmfDrawingWand,clip_mask_id);\n      (void) PushDrawingWand(WmfDrawingWand);\n      for (i = 0; i < (long) poly_rect->count; i++)\n        {\n          DrawRectangle(WmfDrawingWand,\n                         XC(poly_rect->TL[i].x), YC(poly_rect->TL[i].y),\n                         XC(poly_rect->BR[i].x), YC(poly_rect->BR[i].y));\n        }\n      (void) PopDrawingWand(WmfDrawingWand);\n      DrawPopClipPath(WmfDrawingWand);\n      DrawPopDefs(WmfDrawingWand);\n\n      \/* Push wand for new clip paths *\/\n      (void) PushDrawingWand(WmfDrawingWand);\n      (void) DrawSetClipPath(WmfDrawingWand,clip_mask_id);\n      ddata->clipping = MagickTrue;\n    }\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":366195,"func":"static int do_move_mount(struct path *old_path, struct path *new_path)\n{\n\tstruct mnt_namespace *ns;\n\tstruct mount *p;\n\tstruct mount *old;\n\tstruct mount *parent;\n\tstruct mountpoint *mp, *old_mp;\n\tint err;\n\tbool attached;\n\n\tmp = lock_mount(new_path);\n\tif (IS_ERR(mp))\n\t\treturn PTR_ERR(mp);\n\n\told = real_mount(old_path->mnt);\n\tp = real_mount(new_path->mnt);\n\tparent = old->mnt_parent;\n\tattached = mnt_has_parent(old);\n\told_mp = old->mnt_mp;\n\tns = old->mnt_ns;\n\n\terr = -EINVAL;\n\t\/* The mountpoint must be in our namespace. *\/\n\tif (!check_mnt(p))\n\t\tgoto out;\n\n\t\/* The thing moved must be mounted... *\/\n\tif (!is_mounted(&old->mnt))\n\t\tgoto out;\n\n\t\/* ... and either ours or the root of anon namespace *\/\n\tif (!(attached ? check_mnt(old) : is_anon_ns(ns)))\n\t\tgoto out;\n\n\tif (old->mnt.mnt_flags & MNT_LOCKED)\n\t\tgoto out;\n\n\tif (old_path->dentry != old_path->mnt->mnt_root)\n\t\tgoto out;\n\n\tif (d_is_dir(new_path->dentry) !=\n\t    d_is_dir(old_path->dentry))\n\t\tgoto out;\n\t\/*\n\t * Don't move a mount residing in a shared parent.\n\t *\/\n\tif (attached && IS_MNT_SHARED(parent))\n\t\tgoto out;\n\t\/*\n\t * Don't move a mount tree containing unbindable mounts to a destination\n\t * mount which is shared.\n\t *\/\n\tif (IS_MNT_SHARED(p) && tree_contains_unbindable(old))\n\t\tgoto out;\n\terr = -ELOOP;\n\tif (!check_for_nsfs_mounts(old))\n\t\tgoto out;\n\tfor (; mnt_has_parent(p); p = p->mnt_parent)\n\t\tif (p == old)\n\t\t\tgoto out;\n\n\terr = attach_recursive_mnt(old, real_mount(new_path->mnt), mp,\n\t\t\t\t   attached);\n\tif (err)\n\t\tgoto out;\n\n\t\/* if the mount is moved, it should no longer be expire\n\t * automatically *\/\n\tlist_del_init(&old->mnt_expire);\n\tif (attached)\n\t\tput_mountpoint(old_mp);\nout:\n\tunlock_mount(mp);\n\tif (!err) {\n\t\tif (attached)\n\t\t\tmntput_no_expire(parent);\n\t\telse\n\t\t\tfree_mnt_ns(ns);\n\t}\n\treturn err;\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":413636,"func":"static RList *anal_graph_to(RCore *core, ut64 addr, int depth, HtUP *avoid) {\n\tRAnalFunction *cur_fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);\n\tRList *list = r_list_new ();\n\tHtUP *state = ht_up_new0 ();\n\n\tif (!list || !state || !cur_fcn) {\n\t\tr_list_free (list);\n\t\tht_up_free (state);\n\t\treturn NULL;\n\t}\n\n\t\/\/ forward search\n\tif (anal_path_exists (core, core->offset, addr, list, depth - 1, state, avoid)) {\n\t\tht_up_free (state);\n\t\treturn list;\n\t}\n\n\t\/\/ backward search\n\tRList *xrefs = r_anal_xrefs_get (core->anal, cur_fcn->addr);\n\tif (xrefs) {\n\t\tRListIter *iter;\n\t\tRAnalRef *xref = NULL;\n\t\tr_list_foreach (xrefs, iter, xref) {\n\t\t\tif (xref->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\t\tut64 offset = core->offset;\n\t\t\t\tcore->offset = xref->addr;\n\t\t\t\tr_list_free (list);\n\t\t\t\tlist = anal_graph_to (core, addr, depth - 1, avoid);\n\t\t\t\tcore->offset = offset;\n\t\t\t\tif (list && r_list_length (list)) {\n\t\t\t\t\tr_list_free (xrefs);\n\t\t\t\t\tht_up_free (state);\n\t\t\t\t\treturn list;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tr_list_free (xrefs);\n\tht_up_free (state);\n\tr_list_free (list);\n\treturn NULL;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":253616,"func":"smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,\n\t\t       struct smb_rqst *new_rq, struct smb_rqst *old_rq)\n{\n\tstruct page **pages;\n\tstruct smb2_transform_hdr *tr_hdr = new_rq[0].rq_iov[0].iov_base;\n\tunsigned int npages;\n\tunsigned int orig_len = 0;\n\tint i, j;\n\tint rc = -ENOMEM;\n\n\tfor (i = 1; i < num_rqst; i++) {\n\t\tnpages = old_rq[i - 1].rq_npages;\n\t\tpages = kmalloc_array(npages, sizeof(struct page *),\n\t\t\t\t      GFP_KERNEL);\n\t\tif (!pages)\n\t\t\tgoto err_free;\n\n\t\tnew_rq[i].rq_pages = pages;\n\t\tnew_rq[i].rq_npages = npages;\n\t\tnew_rq[i].rq_offset = old_rq[i - 1].rq_offset;\n\t\tnew_rq[i].rq_pagesz = old_rq[i - 1].rq_pagesz;\n\t\tnew_rq[i].rq_tailsz = old_rq[i - 1].rq_tailsz;\n\t\tnew_rq[i].rq_iov = old_rq[i - 1].rq_iov;\n\t\tnew_rq[i].rq_nvec = old_rq[i - 1].rq_nvec;\n\n\t\torig_len += smb_rqst_len(server, &old_rq[i - 1]);\n\n\t\tfor (j = 0; j < npages; j++) {\n\t\t\tpages[j] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM);\n\t\t\tif (!pages[j])\n\t\t\t\tgoto err_free;\n\t\t}\n\n\t\t\/* copy pages form the old *\/\n\t\tfor (j = 0; j < npages; j++) {\n\t\t\tchar *dst, *src;\n\t\t\tunsigned int offset, len;\n\n\t\t\trqst_page_get_length(&new_rq[i], j, &len, &offset);\n\n\t\t\tdst = (char *) kmap(new_rq[i].rq_pages[j]) + offset;\n\t\t\tsrc = (char *) kmap(old_rq[i - 1].rq_pages[j]) + offset;\n\n\t\t\tmemcpy(dst, src, len);\n\t\t\tkunmap(new_rq[i].rq_pages[j]);\n\t\t\tkunmap(old_rq[i - 1].rq_pages[j]);\n\t\t}\n\t}\n\n\t\/* fill the 1st iov with a transform header *\/\n\tfill_transform_hdr(tr_hdr, orig_len, old_rq, server->cipher_type);\n\n\trc = crypt_message(server, num_rqst, new_rq, 1);\n\tcifs_dbg(FYI, \"Encrypt message returned %d\\n\", rc);\n\tif (rc)\n\t\tgoto err_free;\n\n\treturn rc;\n\nerr_free:\n\tsmb3_free_compound_rqst(num_rqst - 1, &new_rq[1]);\n\treturn rc;\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":247528,"func":"TEST_P(SslSocketTest, ClientCertificateSpkiVerification) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n\n  server_validation_ctx->mutable_trusted_ca()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"));\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_DNS_CERT_SPKI);\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_URI_CERT_SPKI);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"));\n\n  TestUtilOptionsV2 test_options(listener, client, true, GetParam());\n  testUtilV2(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedServerCertDigest(TEST_SAN_DNS_CERT_256_HASH));\n\n  \/\/ Works even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":224496,"func":"static void ttxt_parse_text_style(GF_TXTIn *ctx, GF_XMLNode *n, GF_StyleRecord *style)\n{\n\tu32 i=0;\n\tGF_XMLAttribute *att;\n\tmemset(style, 0, sizeof(GF_StyleRecord));\n\tstyle->fontID = 1;\n\tstyle->font_size = ctx->fontsize ;\n\tstyle->text_color = 0xFFFFFFFF;\n\n\twhile ( (att=(GF_XMLAttribute *)gf_list_enum(n->attributes, &i))) {\n\t\tif (!stricmp(att->name, \"fromChar\")) style->startCharOffset = atoi(att->value);\n\t\telse if (!stricmp(att->name, \"toChar\")) style->endCharOffset = atoi(att->value);\n\t\telse if (!stricmp(att->name, \"fontID\")) style->fontID = atoi(att->value);\n\t\telse if (!stricmp(att->name, \"fontSize\")) style->font_size = atoi(att->value);\n\t\telse if (!stricmp(att->name, \"color\")) style->text_color = ttxt_get_color(att->value);\n\t\telse if (!stricmp(att->name, \"styles\")) {\n\t\t\tif (strstr(att->value, \"Bold\")) style->style_flags |= GF_TXT_STYLE_BOLD;\n\t\t\tif (strstr(att->value, \"Italic\")) style->style_flags |= GF_TXT_STYLE_ITALIC;\n\t\t\tif (strstr(att->value, \"Underlined\")) style->style_flags |= GF_TXT_STYLE_UNDERLINED;\n\t\t\tif (strstr(att->value, \"Strikethrough\")) style->style_flags |= GF_TXT_STYLE_STRIKETHROUGH;\n\t\t}\n\t}\n}","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":405711,"func":"static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg,\n\t\t\t\tu16 val)\n{\n\tstruct net_local *lp = bus->priv;\n\tu32 ctrl_reg;\n\n\tdev_dbg(&lp->ndev->dev,\n\t\t\"%s(phy_id=%i, reg=%x, val=%x)\\n\", __func__,\n\t\tphy_id, reg, val);\n\n\tif (xemaclite_mdio_wait(lp))\n\t\treturn -ETIMEDOUT;\n\n\t\/* Write the PHY address, register number and clear the OP bit in the\n\t * MDIO Address register and then write the value into the MDIO Write\n\t * Data register. Finally, set the Status bit in the MDIO Control\n\t * register to start a MDIO write transaction.\n\t *\/\n\tctrl_reg = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET);\n\txemaclite_writel(~XEL_MDIOADDR_OP_MASK &\n\t\t\t ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg),\n\t\t\t lp->base_addr + XEL_MDIOADDR_OFFSET);\n\txemaclite_writel(val, lp->base_addr + XEL_MDIOWR_OFFSET);\n\txemaclite_writel(ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK,\n\t\t\t lp->base_addr + XEL_MDIOCTRL_OFFSET);\n\n\treturn 0;\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":317318,"func":"static int smack_set_mnt_opts(struct super_block *sb,\n\t\tvoid *mnt_opts,\n\t\tunsigned long kern_flags,\n\t\tunsigned long *set_kern_flags)\n{\n\tstruct dentry *root = sb->s_root;\n\tstruct inode *inode = d_backing_inode(root);\n\tstruct superblock_smack *sp = smack_superblock(sb);\n\tstruct inode_smack *isp;\n\tstruct smack_known *skp;\n\tstruct smack_mnt_opts *opts = mnt_opts;\n\tbool transmute = false;\n\n\tif (sp->smk_flags & SMK_SB_INITIALIZED)\n\t\treturn 0;\n\n\tif (inode->i_security == NULL) {\n\t\tint rc = lsm_inode_alloc(inode);\n\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tif (!smack_privileged(CAP_MAC_ADMIN)) {\n\t\t\/*\n\t\t * Unprivileged mounts don't get to specify Smack values.\n\t\t *\/\n\t\tif (opts)\n\t\t\treturn -EPERM;\n\t\t\/*\n\t\t * Unprivileged mounts get root and default from the caller.\n\t\t *\/\n\t\tskp = smk_of_current();\n\t\tsp->smk_root = skp;\n\t\tsp->smk_default = skp;\n\t\t\/*\n\t\t * For a handful of fs types with no user-controlled\n\t\t * backing store it's okay to trust security labels\n\t\t * in the filesystem. The rest are untrusted.\n\t\t *\/\n\t\tif (sb->s_user_ns != &init_user_ns &&\n\t\t    sb->s_magic != SYSFS_MAGIC && sb->s_magic != TMPFS_MAGIC &&\n\t\t    sb->s_magic != RAMFS_MAGIC) {\n\t\t\ttransmute = true;\n\t\t\tsp->smk_flags |= SMK_SB_UNTRUSTED;\n\t\t}\n\t}\n\n\tsp->smk_flags |= SMK_SB_INITIALIZED;\n\n\tif (opts) {\n\t\tif (opts->fsdefault) {\n\t\t\tskp = smk_import_entry(opts->fsdefault, 0);\n\t\t\tif (IS_ERR(skp))\n\t\t\t\treturn PTR_ERR(skp);\n\t\t\tsp->smk_default = skp;\n\t\t}\n\t\tif (opts->fsfloor) {\n\t\t\tskp = smk_import_entry(opts->fsfloor, 0);\n\t\t\tif (IS_ERR(skp))\n\t\t\t\treturn PTR_ERR(skp);\n\t\t\tsp->smk_floor = skp;\n\t\t}\n\t\tif (opts->fshat) {\n\t\t\tskp = smk_import_entry(opts->fshat, 0);\n\t\t\tif (IS_ERR(skp))\n\t\t\t\treturn PTR_ERR(skp);\n\t\t\tsp->smk_hat = skp;\n\t\t}\n\t\tif (opts->fsroot) {\n\t\t\tskp = smk_import_entry(opts->fsroot, 0);\n\t\t\tif (IS_ERR(skp))\n\t\t\t\treturn PTR_ERR(skp);\n\t\t\tsp->smk_root = skp;\n\t\t}\n\t\tif (opts->fstransmute) {\n\t\t\tskp = smk_import_entry(opts->fstransmute, 0);\n\t\t\tif (IS_ERR(skp))\n\t\t\t\treturn PTR_ERR(skp);\n\t\t\tsp->smk_root = skp;\n\t\t\ttransmute = true;\n\t\t}\n\t}\n\n\t\/*\n\t * Initialize the root inode.\n\t *\/\n\tinit_inode_smack(inode, sp->smk_root);\n\n\tif (transmute) {\n\t\tisp = smack_inode(inode);\n\t\tisp->smk_flags |= SMK_INODE_TRANSMUTE;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":709,"total_token_length":945,"max_tokens_setting":1024}
+{"idx":197998,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& input = context->input(0);\n    const TensorShape& input_shape = input.shape();\n    const int32 input_dims = input_shape.dims();\n\n    const Tensor& segment_id = context->input(1);\n    const TensorShape& segment_id_shape = segment_id.shape();\n    const int32 segment_dims = segment_id_shape.dims();\n\n    const Tensor& num_segments_tensor = context->input(2);\n    auto num_segments = num_segments_tensor.scalar<NUM_SEGMENTS_TYPE>()();\n\n    OP_REQUIRES(context, segment_dims != 0,\n                errors::InvalidArgument(\"Segment_id cannot have rank 0\"));\n\n    OP_REQUIRES(\n        context, segment_dims <= input_dims,\n        errors::OutOfRange(\"Invalid segment_id rank \", segment_dims,\n                           \" for input with \", input_dims, \" dimension(s)\"));\n    for (auto i = 0; i < segment_dims; i++) {\n      OP_REQUIRES(\n          context, segment_id_shape.dim_size(i) == input_shape.dim_size(i),\n          errors::InvalidArgument(\n              \"Segment dimension is \", segment_id_shape.dim_size(i),\n              \" while input dimension is \", input_dims, \" in rank \", i));\n    }\n\n    \/\/ Making output tensor.\n    Tensor* output_tensor = nullptr;\n    TensorShape output_shape =\n        GetOutputShape(input_shape, segment_id_shape, num_segments);\n    OP_REQUIRES_OK(context, context->allocate_output(\"output\", output_shape,\n                                                     &output_tensor));\n\n    \/\/ Preparating flat tensors.\n    auto output_flat = output_tensor->flat<tstring>();\n    auto flat_segment_id = segment_id.flat<INDICES_TYPE>();\n    auto flat_input = input.flat<tstring>();\n\n    for (int i = 0; i < flat_segment_id.size(); i++) {\n      OP_REQUIRES(\n          context,\n          ((flat_segment_id(i) < num_segments) && (flat_segment_id(i) >= 0)),\n          errors::InvalidArgument(\n              \"segment_ids are not allowed to exceed num_segments or\"\n              \" to have negative values.\"));\n    }\n\n    int64 big_stride;\n    int64 small_stride;\n    std::tie(big_stride, small_stride) =\n        GetStrides<INDICES_TYPE>(input_shape, segment_id_shape);\n    auto relative_offset_set =\n        GetFlattenedRelativeOffsets<INDICES_TYPE>(small_stride, big_stride);\n    for (auto start_offset = 0; start_offset < big_stride; start_offset++) {\n      for (auto i = 0; i < relative_offset_set.size(); i++) {\n        auto output_index = start_offset + flat_segment_id(i) * big_stride;\n        auto offset = start_offset + relative_offset_set[i];\n        if (output_flat(output_index).length() != 0)\n          output_flat(output_index).append(separator_.c_str());\n        output_flat(output_index).append(flat_input(offset));\n      }\n    }\n  }","target":1,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":455291,"func":"run_wordexp (words)\n     char *words;\n{\n  int code, nw, nb;\n  WORD_LIST *wl, *tl, *result;\n\n  code = setjmp_nosigs (top_level);\n\n  if (code != NOT_JUMPED)\n    {\n      switch (code)\n\t{\n\t  \/* Some kind of throw to top_level has occurred. *\/\n\tcase FORCE_EOF:\n\t  return last_command_exit_value = 127;\n\tcase ERREXIT:\n\tcase EXITPROG:\n\t  return last_command_exit_value;\n\tcase DISCARD:\n\t  return last_command_exit_value = 1;\n\tdefault:\n\t  command_error (\"run_wordexp\", CMDERR_BADJUMP, code, 0);\n\t}\n    }\n\n  \/* Run it through the parser to get a list of words and expand them *\/\n  if (words && *words)\n    {\n      with_input_from_string (words, \"--wordexp\");\n      if (parse_command () != 0)\n\treturn (126);\n      if (global_command == 0)\n\t{\n\t  printf (\"0\\n0\\n\");\n\t  return (0);\n\t}\n      if (global_command->type != cm_simple)\n\treturn (126);\n      wl = global_command->value.Simple->words;\n      if (protected_mode)\n\tfor (tl = wl; tl; tl = tl->next)\n\t  tl->word->flags |= W_NOCOMSUB|W_NOPROCSUB;\n      result = wl ? expand_words_no_vars (wl) : (WORD_LIST *)0;\n    }\n  else\n    result = (WORD_LIST *)0;\n\n  last_command_exit_value = 0;\n\n  if (result == 0)\n    {\n      printf (\"0\\n0\\n\");\n      return (0);\n    }\n\n  \/* Count up the number of words and bytes, and print them.  Don't count\n     the trailing NUL byte. *\/\n  for (nw = nb = 0, wl = result; wl; wl = wl->next)\n    {\n      nw++;\n      nb += strlen (wl->word->word);\n    }\n  printf (\"%u\\n%u\\n\", nw, nb);\n  \/* Print each word on a separate line.  This will have to be changed when\n     the interface to glibc is completed. *\/\n  for (wl = result; wl; wl = wl->next)\n    printf (\"%s\\n\", wl->word->word);\n\n  return (0);\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":405394,"func":"static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie)\n{\n\t\/* Code (such as __xfrm4_bundle_create()) sets dst->obsolete\n\t * to DST_OBSOLETE_FORCE_CHK to force all XFRM destinations to\n\t * get validated by dst_ops->check on every use.  We do this\n\t * because when a normal route referenced by an XFRM dst is\n\t * obsoleted we do not go looking around for all parent\n\t * referencing XFRM dsts so that we can invalidate them.  It\n\t * is just too much work.  Instead we make the checks here on\n\t * every use.  For example:\n\t *\n\t *\tXFRM dst A --> IPv4 dst X\n\t *\n\t * X is the \"xdst->route\" of A (X is also the \"dst->path\" of A\n\t * in this example).  If X is marked obsolete, \"A\" will not\n\t * notice.  That's what we are validating here via the\n\t * stale_bundle() check.\n\t *\n\t * When a dst is removed from the fib tree, DST_OBSOLETE_DEAD will\n\t * be marked on it.\n\t * This will force stale_bundle() to fail on any xdst bundle with\n\t * this dst linked in it.\n\t *\/\n\tif (dst->obsolete < 0 && !stale_bundle(dst))\n\t\treturn dst;\n\n\treturn NULL;\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":205806,"func":"void sdb_edit(procinfo *pi)\n{\n  char * filename = omStrDup(\"\/tmp\/sd000000\");\n  sprintf(filename+7,\"%d\",getpid());\n  FILE *fp=fopen(filename,\"w\");\n  if (fp==NULL)\n  {\n    Print(\"cannot open %s\\n\",filename);\n    omFree(filename);\n    return;\n  }\n  if (pi->language!= LANG_SINGULAR)\n  {\n    Print(\"cannot edit type %d\\n\",pi->language);\n    fclose(fp);\n    fp=NULL;\n  }\n  else\n  {\n    const char *editor=getenv(\"EDITOR\");\n    if (editor==NULL)\n      editor=getenv(\"VISUAL\");\n    if (editor==NULL)\n      editor=\"vi\";\n    editor=omStrDup(editor);\n\n    if (pi->data.s.body==NULL)\n    {\n      iiGetLibProcBuffer(pi);\n      if (pi->data.s.body==NULL)\n      {\n        PrintS(\"cannot get the procedure body\\n\");\n        fclose(fp);\n        si_unlink(filename);\n        omFree(filename);\n        return;\n      }\n    }\n\n    fwrite(pi->data.s.body,1,strlen(pi->data.s.body),fp);\n    fclose(fp);\n\n    int pid=fork();\n    if (pid!=0)\n    {\n      si_wait(&pid);\n    }\n    else if(pid==0)\n    {\n      if (strchr(editor,' ')==NULL)\n      {\n        execlp(editor,editor,filename,NULL);\n        Print(\"cannot exec %s\\n\",editor);\n      }\n      else\n      {\n        char *p=(char *)omAlloc(strlen(editor)+strlen(filename)+2);\n        sprintf(p,\"%s %s\",editor,filename);\n        system(p);\n      }\n      exit(0);\n    }\n    else\n    {\n      PrintS(\"cannot fork\\n\");\n    }\n\n    fp=fopen(filename,\"r\");\n    if (fp==NULL)\n    {\n      Print(\"cannot read from %s\\n\",filename);\n    }\n    else\n    {\n      fseek(fp,0L,SEEK_END);\n      long len=ftell(fp);\n      fseek(fp,0L,SEEK_SET);\n\n      omFree((ADDRESS)pi->data.s.body);\n      pi->data.s.body=(char *)omAlloc((int)len+1);\n      myfread( pi->data.s.body, len, 1, fp);\n      pi->data.s.body[len]='\\0';\n      fclose(fp);\n    }\n  }\n  si_unlink(filename);\n  omFree(filename);\n}","target":1,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":225765,"func":"GF_Err moov_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MovieBox *ptr = (GF_MovieBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_IODS:\n\t\tBOX_FIELD_ASSIGN(iods, GF_ObjectDescriptorBox)\n\t\t\/\/if no IOD, delete the box\n\t\tif (ptr->iods && !ptr->iods->descriptor) {\n\t\t\tptr->iods = NULL;\n\t\t\tgf_isom_box_del_parent(&s->child_boxes, a);\n\t\t}\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_MVHD:\n\t\tBOX_FIELD_ASSIGN(mvhd, GF_MovieHeaderBox)\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_UDTA:\n\t\tBOX_FIELD_ASSIGN(udta, GF_UserDataBox)\n\t\treturn GF_OK;\n\n#ifndef\tGPAC_DISABLE_ISOM_FRAGMENTS\n\tcase GF_ISOM_BOX_TYPE_MVEX:\n\t\tBOX_FIELD_ASSIGN(mvex, GF_MovieExtendsBox)\n\t\tif (ptr->mvex)\n\t\t\tptr->mvex->mov = ptr->mov;\n\t\treturn GF_OK;\n#endif\n\n\tcase GF_ISOM_BOX_TYPE_META:\n\t\tBOX_FIELD_ASSIGN(meta, GF_MetaBox)\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_TRAK:\n\t\tif (is_rem) {\n\t\t\tgf_list_del_item(ptr->trackList, a);\n\t\t\treturn GF_OK;\n\t\t}\n\t\t{\n\t\t\tGF_TrackBox *tk = (GF_TrackBox *)a;\n\t\t\t\/\/set our pointer to this obj\n\t\t\ttk->moov = ptr;\n\t\t\ttk->index = gf_list_count(ptr->trackList);\n\t\t\tif (tk->References) {\n\t\t\t\tGF_TrackReferenceTypeBox *dpnd=NULL;\n\t\t\t\tTrack_FindRef(tk, GF_ISOM_REF_BASE, &dpnd);\n\t\t\t\tif (dpnd)\n\t\t\t\t\ttk->nb_base_refs = dpnd->trackIDCount;\n\t\t\t}\n\t\t}\n\t\treturn gf_list_add(ptr->trackList, a);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":243003,"func":"int mbedtls_ssl_check_pending( const mbedtls_ssl_context *ssl )\n{\n    \/*\n     * Case A: We're currently holding back\n     * a message for further processing.\n     *\/\n\n    if( ssl->keep_current_message == 1 )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ssl_check_pending: record held back for processing\" ) );\n        return( 1 );\n    }\n\n    \/*\n     * Case B: Further records are pending in the current datagram.\n     *\/\n\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n    if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&\n        ssl->in_left > ssl->next_record_offset )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ssl_check_pending: more records within current datagram\" ) );\n        return( 1 );\n    }\n#endif \/* MBEDTLS_SSL_PROTO_DTLS *\/\n\n    \/*\n     * Case C: A handshake message is being processed.\n     *\/\n\n    if( ssl->in_hslen > 0 && ssl->in_hslen < ssl->in_msglen )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ssl_check_pending: more handshake messages within current record\" ) );\n        return( 1 );\n    }\n\n    \/*\n     * Case D: An application data message is being processed\n     *\/\n    if( ssl->in_offt != NULL )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ssl_check_pending: application data record is being processed\" ) );\n        return( 1 );\n    }\n\n    \/*\n     * In all other cases, the rest of the message can be dropped.\n     * As in ssl_get_next_record, this needs to be adapted if\n     * we implement support for multiple alerts in single records.\n     *\/\n\n    MBEDTLS_SSL_DEBUG_MSG( 3, ( \"ssl_check_pending: nothing pending\" ) );\n    return( 0 );\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":230617,"func":"void derive_zero_motion_vector_candidates(const slice_segment_header* shdr,\n                                          PBMotion* out_mergeCandList,\n                                          int* inout_numCurrMergeCand,\n                                          int maxCandidates)\n{\n  logtrace(LogMotion,\"derive_zero_motion_vector_candidates\\n\");\n\n  int numRefIdx;\n\n  if (shdr->slice_type==SLICE_TYPE_P) {\n    numRefIdx = shdr->num_ref_idx_l0_active;\n  }\n  else {\n    numRefIdx = libde265_min(shdr->num_ref_idx_l0_active,\n                             shdr->num_ref_idx_l1_active);\n  }\n\n\n  \/\/int numInputMergeCand = *inout_numMergeCand;\n  int zeroIdx = 0;\n\n  while (*inout_numCurrMergeCand < maxCandidates) {\n    \/\/ 1.\n\n    logtrace(LogMotion,\"zeroIdx:%d numRefIdx:%d\\n\", zeroIdx, numRefIdx);\n\n    PBMotion* newCand = &out_mergeCandList[*inout_numCurrMergeCand];\n\n    const int refIdx = (zeroIdx < numRefIdx) ? zeroIdx : 0;\n\n    if (shdr->slice_type==SLICE_TYPE_P) {\n      newCand->refIdx[0] = refIdx;\n      newCand->refIdx[1] = -1;\n      newCand->predFlag[0] = 1;\n      newCand->predFlag[1] = 0;\n    }\n    else {\n      newCand->refIdx[0] = refIdx;\n      newCand->refIdx[1] = refIdx;\n      newCand->predFlag[0] = 1;\n      newCand->predFlag[1] = 1;\n    }\n\n    newCand->mv[0].x = 0;\n    newCand->mv[0].y = 0;\n    newCand->mv[1].x = 0;\n    newCand->mv[1].y = 0;\n\n    (*inout_numCurrMergeCand)++;\n\n    \/\/ 2.\n\n    zeroIdx++;\n  }\n}","target":0,"code_token_length":456,"total_token_length":692,"max_tokens_setting":1024}
+{"idx":197824,"func":"static GF_Err BM_ParseGlobalQuantizer(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)\n{\n\tGF_Node *node;\n\tGF_Command *com;\n\tGF_CommandField *inf;\n\tnode = gf_bifs_dec_node(codec, bs, NDT_SFWorldNode);\n\tif (!node) return GF_NON_COMPLIANT_BITSTREAM;\n\n\t\/*reset global QP*\/\n\tif (codec->scenegraph->global_qp) {\n\t\tgf_node_unregister(codec->scenegraph->global_qp, NULL);\n\t}\n\tcodec->ActiveQP = NULL;\n\tcodec->scenegraph->global_qp = NULL;\n\n\tif (gf_node_get_tag(node) != TAG_MPEG4_QuantizationParameter) {\n\t\tgf_node_unregister(node, NULL);\n\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t}\n\n\t\/*register global QP*\/\n\tcodec->ActiveQP = (M_QuantizationParameter *) node;\n\tcodec->ActiveQP->isLocal = 0;\n\tcodec->scenegraph->global_qp = node;\n\n\t\/*register TWICE: once for the command, and for the scenegraph globalQP*\/\n\tnode->sgprivate->num_instances = 2;\n\n\tcom = gf_sg_command_new(codec->current_graph, GF_SG_GLOBAL_QUANTIZER);\n\tinf = gf_sg_command_field_new(com);\n\tinf->new_node = node;\n\tinf->field_ptr = &inf->new_node;\n\tinf->fieldType = GF_SG_VRML_SFNODE;\n\tgf_list_add(com_list, com);\n\treturn GF_OK;\n}","target":1,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":219966,"func":"int callback_glewlwyd_set_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) {\n  struct config_elements * config = (struct config_elements *)client_data;\n  json_t * j_module, * j_module_valid, * j_search_module;\n  \n  j_search_module = get_client_module(config, u_map_get(request->map_url, \"name\"));\n  if (check_result_value(j_search_module, G_OK)) {\n    j_module = ulfius_get_json_body_request(request, NULL);\n    if (j_module != NULL) {\n      json_object_del(j_module, \"enabled\");\n      j_module_valid = is_client_module_valid(config, j_module, 0);\n      if (check_result_value(j_module_valid, G_OK)) {\n        if (set_client_module(config, u_map_get(request->map_url, \"name\"), j_module) != G_OK) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_client_module - Error set_client_module\");\n          response->status = 500;\n        } else {\n          y_log_message(Y_LOG_LEVEL_INFO, \"Event - Client backend module '%s' updated\", u_map_get(request->map_url, \"name\"));\n        }\n      } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) {\n        if (json_object_get(j_module_valid, \"error\") != NULL) {\n          ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, \"error\"));\n        } else {\n          response->status = 400;\n        }\n      } else if (!check_result_value(j_module_valid, G_OK)) {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_client_module - Error is_client_module_valid\");\n        response->status = 500;\n      }\n      json_decref(j_module_valid);\n    } else {\n      response->status = 400;\n    }\n    json_decref(j_module);\n  } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_client_module - Error get_client_module\");\n    response->status = 500;\n  }\n  json_decref(j_search_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":294615,"func":"d_lite_initialize(int argc, VALUE *argv, VALUE self)\n{\n    VALUE jd, vjd, vdf, sf, vsf, vof, vsg;\n    int df, of;\n    double sg;\n\n    rb_check_frozen(self);\n\n    rb_scan_args(argc, argv, \"05\", &vjd, &vdf, &vsf, &vof, &vsg);\n\n    jd = INT2FIX(0);\n    df = 0;\n    sf = INT2FIX(0);\n    of = 0;\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 5:\n\tval2sg(vsg, sg);\n      case 4:\n\tval2off(vof, of);\n      case 3:\n\tsf = vsf;\n\tif (f_lt_p(sf, INT2FIX(0)) ||\n\t    f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS)))\n\t    rb_raise(eDateError, \"invalid second fraction\");\n      case 2:\n\tdf = NUM2INT(vdf);\n\tif (df < 0 || df >= DAY_IN_SECONDS)\n\t    rb_raise(eDateError, \"invalid day fraction\");\n      case 1:\n\tjd = vjd;\n    }\n\n    {\n\tVALUE nth;\n\tint rjd;\n\n\tget_d1(self);\n\n\tdecode_jd(jd, &nth, &rjd);\n\tif (!df && f_zero_p(sf) && !of) {\n\t    set_to_simple(self, &dat->s, nth, rjd, sg, 0, 0, 0, HAVE_JD);\n\t}\n\telse {\n\t    if (!complex_dat_p(dat))\n\t\trb_raise(rb_eArgError,\n\t\t\t \"cannot load complex into simple\");\n\n\t    set_to_complex(self, &dat->c, nth, rjd, df, sf, of, sg,\n\t\t\t   0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF);\n\t}\n    }\n    return self;\n}","target":0,"code_token_length":418,"total_token_length":654,"max_tokens_setting":1024}
+{"idx":387615,"func":"static int __snd_ctl_elem_info(struct snd_card *card,\n\t\t\t       struct snd_kcontrol *kctl,\n\t\t\t       struct snd_ctl_elem_info *info,\n\t\t\t       struct snd_ctl_file *ctl)\n{\n\tstruct snd_kcontrol_volatile *vd;\n\tunsigned int index_offset;\n\tint result;\n\n#ifdef CONFIG_SND_DEBUG\n\tinfo->access = 0;\n#endif\n\tresult = snd_power_ref_and_wait(card);\n\tif (!result)\n\t\tresult = kctl->info(kctl, info);\n\tsnd_power_unref(card);\n\tif (result >= 0) {\n\t\tsnd_BUG_ON(info->access);\n\t\tindex_offset = snd_ctl_get_ioff(kctl, &info->id);\n\t\tvd = &kctl->vd[index_offset];\n\t\tsnd_ctl_build_ioff(&info->id, kctl, index_offset);\n\t\tinfo->access = vd->access;\n\t\tif (vd->owner) {\n\t\t\tinfo->access |= SNDRV_CTL_ELEM_ACCESS_LOCK;\n\t\t\tif (vd->owner == ctl)\n\t\t\t\tinfo->access |= SNDRV_CTL_ELEM_ACCESS_OWNER;\n\t\t\tinfo->owner = pid_vnr(vd->owner->pid);\n\t\t} else {\n\t\t\tinfo->owner = -1;\n\t\t}\n\t\tif (!snd_ctl_skip_validation(info) &&\n\t\t    snd_ctl_check_elem_info(card, info) < 0)\n\t\t\tresult = -EINVAL;\n\t}\n\treturn result;\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":224537,"func":"Status SparseReduceShapeFn(InferenceContext* c) {\n  \/\/ Input 0: input_indices\n  \/\/ Input 1: input_values\n  \/\/ Input 2: input_shape\n  \/\/ Input 3: reduction_axes\n  \/\/ Attr: keep_dims\n  bool keep_dims = false;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"keep_dims\", &keep_dims));\n\n  const Tensor* shape_tensor = c->input_tensor(2);\n  const Tensor* axes_tensor = c->input_tensor(3);\n  if (shape_tensor != nullptr && axes_tensor != nullptr) {\n    auto shape_vec = shape_tensor->flat<int64_t>();\n    auto axes_vec = axes_tensor->flat<int32>();\n\n    int64_t ndims = shape_vec.size();\n    absl::flat_hash_set<int64_t> axes;\n    if (ndims == 0)\n      return errors::InvalidArgument(\n          \"Number of dims in shape tensor must not be 0\");\n    for (int i = 0; i < axes_vec.size(); i++) {\n      axes.insert((axes_vec(i) + ndims) % ndims);\n    }\n\n    std::vector<DimensionHandle> dims;\n    if (keep_dims) {\n      dims.reserve(ndims);\n      for (int d = 0; d < ndims; ++d) {\n        if (axes.find(d) == axes.end()) {\n          dims.push_back(c->MakeDim(shape_vec(d)));\n        } else {\n          dims.push_back(c->MakeDim(1));\n        }\n      }\n    } else {\n      for (int d = 0; d < ndims; ++d) {\n        if (axes.find(d) == axes.end()) {\n          dims.push_back(c->MakeDim(shape_vec(d)));\n        }\n      }\n    }\n\n    c->set_output(0, c->MakeShape(dims));\n    return Status::OK();\n  }\n  return UnknownShape(c);\n}","target":0,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":424901,"func":"iwl_trans_pcie_dump_pointers(struct iwl_trans *trans,\n\t\t\t     struct iwl_fw_error_dump_fw_mon *fw_mon_data)\n{\n\tu32 base, base_high, write_ptr, write_ptr_val, wrap_cnt;\n\n\tif (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {\n\t\tbase = DBGC_CUR_DBGBUF_BASE_ADDR_LSB;\n\t\tbase_high = DBGC_CUR_DBGBUF_BASE_ADDR_MSB;\n\t\twrite_ptr = DBGC_CUR_DBGBUF_STATUS;\n\t\twrap_cnt = DBGC_DBGBUF_WRAP_AROUND;\n\t} else if (trans->dbg.dest_tlv) {\n\t\twrite_ptr = le32_to_cpu(trans->dbg.dest_tlv->write_ptr_reg);\n\t\twrap_cnt = le32_to_cpu(trans->dbg.dest_tlv->wrap_count);\n\t\tbase = le32_to_cpu(trans->dbg.dest_tlv->base_reg);\n\t} else {\n\t\tbase = MON_BUFF_BASE_ADDR;\n\t\twrite_ptr = MON_BUFF_WRPTR;\n\t\twrap_cnt = MON_BUFF_CYCLE_CNT;\n\t}\n\n\twrite_ptr_val = iwl_read_prph(trans, write_ptr);\n\tfw_mon_data->fw_mon_cycle_cnt =\n\t\tcpu_to_le32(iwl_read_prph(trans, wrap_cnt));\n\tfw_mon_data->fw_mon_base_ptr =\n\t\tcpu_to_le32(iwl_read_prph(trans, base));\n\tif (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {\n\t\tfw_mon_data->fw_mon_base_high_ptr =\n\t\t\tcpu_to_le32(iwl_read_prph(trans, base_high));\n\t\twrite_ptr_val &= DBGC_CUR_DBGBUF_STATUS_OFFSET_MSK;\n\t}\n\tfw_mon_data->fw_mon_wr_ptr = cpu_to_le32(write_ptr_val);\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":513359,"func":"void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab, \n                                table_map last_remaining_tables, \n                                bool first_alt, uint no_jbuf_before,\n                                double *outer_rec_count, double *reopt_cost)\n{\n  double cost, rec_count;\n  table_map reopt_remaining_tables= last_remaining_tables;\n  uint i;\n\n  if (first_tab > join->const_tables)\n  {\n    cost=      join->positions[first_tab - 1].prefix_cost.total_cost();\n    rec_count= join->positions[first_tab - 1].prefix_record_count;\n  }\n  else\n  {\n    cost= 0.0;\n    rec_count= 1;\n  }\n\n  *outer_rec_count= rec_count;\n  for (i= first_tab; i <= last_tab; i++)\n    reopt_remaining_tables |= join->positions[i].table->table->map;\n  \n  \/*\n    best_access_path() optimization depends on the value of \n    join->cur_sj_inner_tables. Our goal in this function is to do a\n    re-optimization with disabled join buffering, but no other changes.\n    In order to achieve this, cur_sj_inner_tables needs have the same \n    value it had during the original invocations of best_access_path. \n\n    We know that this function, optimize_wo_join_buffering() is called to\n    re-optimize semi-join join order range, which allows to conclude that \n    the \"original\" value of cur_sj_inner_tables was 0.\n  *\/\n  table_map save_cur_sj_inner_tables= join->cur_sj_inner_tables;\n  join->cur_sj_inner_tables= 0;\n\n  for (i= first_tab; i <= last_tab; i++)\n  {\n    JOIN_TAB *rs= join->positions[i].table;\n    POSITION pos, loose_scan_pos;\n    \n    if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer)\n    {\n      \/* Find the best access method that would not use join buffering *\/\n      best_access_path(join, rs, reopt_remaining_tables,\n                       join->positions, i,\n                       TRUE, rec_count,\n                       &pos, &loose_scan_pos);\n    }\n    else \n      pos= join->positions[i];\n\n    if ((i == first_tab && first_alt))\n      pos= loose_scan_pos;\n\n    reopt_remaining_tables &= ~rs->table->map;\n    rec_count= COST_MULT(rec_count, pos.records_read);\n    cost= COST_ADD(cost, pos.read_time);\n\n\n    if (!rs->emb_sj_nest)\n      *outer_rec_count= COST_MULT(*outer_rec_count, pos.records_read);\n  }\n  join->cur_sj_inner_tables= save_cur_sj_inner_tables;\n\n  *reopt_cost= cost;\n}","target":0,"code_token_length":588,"total_token_length":824,"max_tokens_setting":1024}
+{"idx":234778,"func":"int btrfs_cancel_balance(struct btrfs_fs_info *fs_info)\n{\n\tmutex_lock(&fs_info->balance_mutex);\n\tif (!fs_info->balance_ctl) {\n\t\tmutex_unlock(&fs_info->balance_mutex);\n\t\treturn -ENOTCONN;\n\t}\n\n\t\/*\n\t * A paused balance with the item stored on disk can be resumed at\n\t * mount time if the mount is read-write. Otherwise it's still paused\n\t * and we must not allow cancelling as it deletes the item.\n\t *\/\n\tif (sb_rdonly(fs_info->sb)) {\n\t\tmutex_unlock(&fs_info->balance_mutex);\n\t\treturn -EROFS;\n\t}\n\n\tatomic_inc(&fs_info->balance_cancel_req);\n\t\/*\n\t * if we are running just wait and return, balance item is\n\t * deleted in btrfs_balance in this case\n\t *\/\n\tif (test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags)) {\n\t\tmutex_unlock(&fs_info->balance_mutex);\n\t\twait_event(fs_info->balance_wait_q,\n\t\t\t   !test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags));\n\t\tmutex_lock(&fs_info->balance_mutex);\n\t} else {\n\t\tmutex_unlock(&fs_info->balance_mutex);\n\t\t\/*\n\t\t * Lock released to allow other waiters to continue, we'll\n\t\t * reexamine the status again.\n\t\t *\/\n\t\tmutex_lock(&fs_info->balance_mutex);\n\n\t\tif (fs_info->balance_ctl) {\n\t\t\treset_balance_state(fs_info);\n\t\t\tbtrfs_exclop_finish(fs_info);\n\t\t\tbtrfs_info(fs_info, \"balance: canceled\");\n\t\t}\n\t}\n\n\tBUG_ON(fs_info->balance_ctl ||\n\t\ttest_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags));\n\tatomic_dec(&fs_info->balance_cancel_req);\n\tmutex_unlock(&fs_info->balance_mutex);\n\treturn 0;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":195328,"func":"char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicode_type)\n{\n\tu32 i, j, len;\n\tchar *sOK;\n\tchar szLineConv[1024];\n\tunsigned short *sptr;\n\n\tmemset(szLine, 0, sizeof(char)*lineSize);\n\tsOK = gf_fgets(szLine, lineSize, txt_in);\n\tif (!sOK) return NULL;\n\tif (unicode_type<=1) {\n\t\tj=0;\n\t\tlen = (u32) strlen(szLine);\n\t\tfor (i=0; i<len; i++) {\n\t\t\tif (!unicode_type && (szLine[i] & 0x80)) {\n\t\t\t\t\/*non UTF8 (likely some win-CP)*\/\n\t\t\t\tif ((szLine[i+1] & 0xc0) != 0x80) {\n\t\t\t\t\tszLineConv[j] = 0xc0 | ( (szLine[i] >> 6) & 0x3 );\n\t\t\t\t\tj++;\n\t\t\t\t\tszLine[i] &= 0xbf;\n\t\t\t\t}\n\t\t\t\t\/*UTF8 2 bytes char*\/\n\t\t\t\telse if ( (szLine[i] & 0xe0) == 0xc0) {\n\t\t\t\t\tszLineConv[j] = szLine[i];\n\t\t\t\t\ti++;\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\t\/*UTF8 3 bytes char*\/\n\t\t\t\telse if ( (szLine[i] & 0xf0) == 0xe0) {\n\t\t\t\t\tszLineConv[j] = szLine[i];\n\t\t\t\t\ti++;\n\t\t\t\t\tj++;\n\t\t\t\t\tszLineConv[j] = szLine[i];\n\t\t\t\t\ti++;\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\t\/*UTF8 4 bytes char*\/\n\t\t\t\telse if ( (szLine[i] & 0xf8) == 0xf0) {\n\t\t\t\t\tszLineConv[j] = szLine[i];\n\t\t\t\t\ti++;\n\t\t\t\t\tj++;\n\t\t\t\t\tszLineConv[j] = szLine[i];\n\t\t\t\t\ti++;\n\t\t\t\t\tj++;\n\t\t\t\t\tszLineConv[j] = szLine[i];\n\t\t\t\t\ti++;\n\t\t\t\t\tj++;\n\t\t\t\t} else {\n\t\t\t\t\ti+=1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tszLineConv[j] = szLine[i];\n\t\t\tj++;\n\t\t}\n\t\tszLineConv[j] = 0;\n\t\tstrcpy(szLine, szLineConv);\n\t\treturn sOK;\n\t}\n\n#ifdef GPAC_BIG_ENDIAN\n\tif (unicode_type==3)\n#else\n\tif (unicode_type==2)\n#endif\n\t{\n\t\ti=0;\n\t\twhile (1) {\n\t\t\tchar c;\n\t\t\tif (!szLine[i] && !szLine[i+1]) break;\n\t\t\tc = szLine[i+1];\n\t\t\tszLine[i+1] = szLine[i];\n\t\t\tszLine[i] = c;\n\t\t\ti+=2;\n\t\t}\n\t}\n\tsptr = (u16 *)szLine;\n\ti = (u32) gf_utf8_wcstombs(szLineConv, 1024, (const unsigned short **) &sptr);\n\tszLineConv[i] = 0;\n\tstrcpy(szLine, szLineConv);\n\t\/*this is ugly indeed: since input is UTF16-LE, there are many chances the gf_fgets never reads the \\0 after a \\n*\/\n\tif (unicode_type==3) gf_fgetc(txt_in);\n\treturn sOK;\n}","target":1,"code_token_length":722,"total_token_length":958,"max_tokens_setting":1024}
+{"idx":234844,"func":"static int btrfs_free_stale_devices(const char *path,\n\t\t\t\t     struct btrfs_device *skip_device)\n{\n\tstruct btrfs_fs_devices *fs_devices, *tmp_fs_devices;\n\tstruct btrfs_device *device, *tmp_device;\n\tint ret = 0;\n\n\tif (path)\n\t\tret = -ENOENT;\n\n\tlist_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) {\n\n\t\tmutex_lock(&fs_devices->device_list_mutex);\n\t\tlist_for_each_entry_safe(device, tmp_device,\n\t\t\t\t\t &fs_devices->devices, dev_list) {\n\t\t\tif (skip_device && skip_device == device)\n\t\t\t\tcontinue;\n\t\t\tif (path && !device->name)\n\t\t\t\tcontinue;\n\t\t\tif (path && !device_path_matched(path, device))\n\t\t\t\tcontinue;\n\t\t\tif (fs_devices->opened) {\n\t\t\t\t\/* for an already deleted device return 0 *\/\n\t\t\t\tif (path && ret != 0)\n\t\t\t\t\tret = -EBUSY;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t\/* delete the stale device *\/\n\t\t\tfs_devices->num_devices--;\n\t\t\tlist_del(&device->dev_list);\n\t\t\tbtrfs_free_device(device);\n\n\t\t\tret = 0;\n\t\t}\n\t\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\t\tif (fs_devices->num_devices == 0) {\n\t\t\tbtrfs_sysfs_remove_fsid(fs_devices);\n\t\t\tlist_del(&fs_devices->fs_list);\n\t\t\tfree_fs_devices(fs_devices);\n\t\t}\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":424522,"func":"static PresentationContext* PresentationContext_new(VideoClientContext* video, BYTE PresentationId,\n                                                    UINT32 x, UINT32 y, UINT32 width, UINT32 height)\n{\n\tsize_t s;\n\tVideoClientContextPriv* priv = video->priv;\n\tPresentationContext* ret;\n\ts = width * height * 4ULL;\n\tif (s > INT32_MAX)\n\t\treturn NULL;\n\n\tret = calloc(1, sizeof(*ret));\n\tif (!ret)\n\t\treturn NULL;\n\n\tret->video = video;\n\tret->PresentationId = PresentationId;\n\n\tret->h264 = h264_context_new(FALSE);\n\tif (!ret->h264)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create a h264 context\");\n\t\tgoto error_h264;\n\t}\n\th264_context_reset(ret->h264, width, height);\n\n\tret->currentSample = Stream_New(NULL, 4096);\n\tif (!ret->currentSample)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create current packet stream\");\n\t\tgoto error_currentSample;\n\t}\n\n\tret->surfaceData = BufferPool_Take(priv->surfacePool, s);\n\tif (!ret->surfaceData)\n\t{\n\t\tWLog_ERR(TAG, \"unable to allocate surfaceData\");\n\t\tgoto error_surfaceData;\n\t}\n\n\tret->surface = video->createSurface(video, ret->surfaceData, x, y, width, height);\n\tif (!ret->surface)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create surface\");\n\t\tgoto error_surface;\n\t}\n\n\tret->yuv = yuv_context_new(FALSE);\n\tif (!ret->yuv)\n\t{\n\t\tWLog_ERR(TAG, \"unable to create YUV decoder\");\n\t\tgoto error_yuv;\n\t}\n\n\tyuv_context_reset(ret->yuv, width, height);\n\tret->refCounter = 1;\n\treturn ret;\n\nerror_yuv:\n\tvideo->deleteSurface(video, ret->surface);\nerror_surface:\n\tBufferPool_Return(priv->surfacePool, ret->surfaceData);\nerror_surfaceData:\n\tStream_Free(ret->currentSample, TRUE);\nerror_currentSample:\n\th264_context_free(ret->h264);\nerror_h264:\n\tfree(ret);\n\treturn NULL;\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":513213,"func":"plugin_ref plugin_lock(THD *thd, plugin_ref ptr)\n{\n  LEX *lex= thd ? thd->lex : 0;\n  plugin_ref rc;\n  DBUG_ENTER(\"plugin_lock\");\n\n#ifdef DBUG_OFF\n  \/*\n    In optimized builds we don't do reference counting for built-in\n    (plugin->plugin_dl == 0) plugins.\n\n    Note that we access plugin->plugin_dl outside of LOCK_plugin, and for\n    dynamic plugins a 'plugin' could correspond to plugin that was unloaded\n    meanwhile!  But because st_plugin_int is always allocated on\n    plugin_mem_root, the pointer can never be invalid - the memory is never\n    freed.\n    Of course, the memory that 'plugin' points to can be overwritten by\n    another plugin being loaded, but plugin->plugin_dl can never change\n    from zero to non-zero or vice versa.\n    That is, it's always safe to check for plugin->plugin_dl==0 even\n    without a mutex.\n  *\/\n  if (! plugin_dlib(ptr))\n  {\n    plugin_ref_to_int(ptr)->locks_total++;\n    DBUG_RETURN(ptr);\n  }\n#endif\n  mysql_mutex_lock(&LOCK_plugin);\n  plugin_ref_to_int(ptr)->locks_total++;\n  rc= intern_plugin_lock(lex, ptr);\n  mysql_mutex_unlock(&LOCK_plugin);\n  DBUG_RETURN(rc);\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":364738,"func":"set_tagstack(win_T *wp, dict_T *d, int action)\n{\n    dictitem_T\t*di;\n    list_T\t*l = NULL;\n\n#ifdef FEAT_EVAL\n    \/\/ not allowed to alter the tag stack entries from inside tagfunc\n    if (tfu_in_use)\n    {\n\temsg(_(e_cannot_modify_tag_stack_within_tagfunc));\n\treturn FAIL;\n    }\n#endif\n\n    if ((di = dict_find(d, (char_u *)\"items\", -1)) != NULL)\n    {\n\tif (di->di_tv.v_type != VAR_LIST)\n\t{\n\t    emsg(_(e_list_required));\n\t    return FAIL;\n\t}\n\tl = di->di_tv.vval.v_list;\n    }\n\n    if ((di = dict_find(d, (char_u *)\"curidx\", -1)) != NULL)\n\ttagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1);\n\n    if (action == 't')\t\t    \/\/ truncate the stack\n    {\n\ttaggy_T\t*tagstack = wp->w_tagstack;\n\tint\ttagstackidx = wp->w_tagstackidx;\n\tint\ttagstacklen = wp->w_tagstacklen;\n\n\t\/\/ delete all the tag stack entries above the current entry\n\twhile (tagstackidx < tagstacklen)\n\t    tagstack_clear_entry(&tagstack[--tagstacklen]);\n\twp->w_tagstacklen = tagstacklen;\n    }\n\n    if (l != NULL)\n    {\n\tif (action == 'r')\t\t\/\/ replace the stack\n\t    tagstack_clear(wp);\n\n\ttagstack_push_items(wp, l);\n\t\/\/ set the current index after the last entry\n\twp->w_tagstackidx = wp->w_tagstacklen;\n    }\n\n    return OK;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":226112,"func":"GF_Err stts_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_TimeToSampleBox *ptr = (GF_TimeToSampleBox *)s;\n\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\tptr->w_LastDTS = 0;\n#endif\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->nb_entries = gf_bs_read_u32(bs);\n\tif (ptr->size \/ 8 < ptr->nb_entries || (u64)ptr->nb_entries > (u64)SIZE_MAX\/sizeof(GF_SttsEntry)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of entries %d in stts\\n\", ptr->nb_entries));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tptr->alloc_size = ptr->nb_entries;\n\tptr->entries = gf_malloc(sizeof(GF_SttsEntry)*ptr->alloc_size);\n\tif (!ptr->entries) return GF_OUT_OF_MEM;\n\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tptr->entries[i].sampleCount = gf_bs_read_u32(bs);\n\t\tptr->entries[i].sampleDelta = gf_bs_read_u32(bs);\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\t\tptr->w_currentSampleNum += ptr->entries[i].sampleCount;\n\t\tptr->w_LastDTS += (u64)ptr->entries[i].sampleCount * ptr->entries[i].sampleDelta;\n#endif\n\t\tif (ptr->max_ts_delta<ptr->entries[i].sampleDelta)\n\t\t\tptr->max_ts_delta = ptr->entries[i].sampleDelta;\n\n\t\tif (!ptr->entries[i].sampleDelta) {\n\t\t\tif ((i+1<ptr->nb_entries) ) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] Found stts entry with sample_delta=0 - forbidden ! Fixing to 1\\n\" ));\n\t\t\t\tptr->entries[i].sampleDelta = 1;\n\t\t\t} else if (ptr->entries[i].sampleCount>1) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] more than one stts entry at the end of the track with sample_delta=0 - forbidden ! Fixing to 1\\n\" ));\n\t\t\t\tptr->entries[i].sampleDelta = 1;\n\t\t\t}\n\t\t}\n\t\t\/\/cf issue 1644: some media streams may have sample duration > 2^31 (ttml mostly), we cannot patch this\n\t\t\/\/for now we disable the check, one opt could be to have the check only for some media types, or only for the first entry\n#if 0\n\t\telse if ((s32) ptr->entries[i].sampleDelta < 0) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] stts entry %d has negative duration %d - forbidden ! Fixing to 1, sync may get lost (consider reimport raw media)\\n\", i, (s32) ptr->entries[i].sampleDelta ));\n\t\t\tptr->entries[i].sampleDelta = 1;\n\t\t}\n#endif\n\n\t}\n\tISOM_DECREASE_SIZE(ptr, ptr->nb_entries*8);\n\n\t\/\/remove the last sample delta.\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\tif (ptr->nb_entries) ptr->w_LastDTS -= ptr->entries[ptr->nb_entries-1].sampleDelta;\n#endif\n\treturn GF_OK;\n}","target":0,"code_token_length":744,"total_token_length":980,"max_tokens_setting":1024}
+{"idx":252320,"func":"static mz_bool mz_zip_writer_create_local_dir_header(\n    mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size,\n    mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size,\n    mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags,\n    mz_uint16 dos_time, mz_uint16 dos_date) {\n  (void)pZip;\n  memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size);\n  MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size);\n  MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size);\n  return MZ_TRUE;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":242961,"func":"static int ssl_write_real( mbedtls_ssl_context *ssl,\n                           const unsigned char *buf, size_t len )\n{\n    int ret = mbedtls_ssl_get_max_out_record_payload( ssl );\n    const size_t max_len = (size_t) ret;\n\n    if( ret < 0 )\n    {\n        MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_get_max_out_record_payload\", ret );\n        return( ret );\n    }\n\n    if( len > max_len )\n    {\n#if defined(MBEDTLS_SSL_PROTO_DTLS)\n        if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )\n        {\n            MBEDTLS_SSL_DEBUG_MSG( 1, ( \"fragment larger than the (negotiated) \"\n                                \"maximum fragment length: %\" MBEDTLS_PRINTF_SIZET\n                                \" > %\" MBEDTLS_PRINTF_SIZET,\n                                len, max_len ) );\n            return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );\n        }\n        else\n#endif\n            len = max_len;\n    }\n\n    if( ssl->out_left != 0 )\n    {\n        \/*\n         * The user has previously tried to send the data and\n         * MBEDTLS_ERR_SSL_WANT_WRITE or the message was only partially\n         * written. In this case, we expect the high-level write function\n         * (e.g. mbedtls_ssl_write()) to be called with the same parameters\n         *\/\n        if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_flush_output\", ret );\n            return( ret );\n        }\n    }\n    else\n    {\n        \/*\n         * The user is trying to send a message the first time, so we need to\n         * copy the data into the internal buffers and setup the data structure\n         * to keep track of partial writes\n         *\/\n        ssl->out_msglen  = len;\n        ssl->out_msgtype = MBEDTLS_SSL_MSG_APPLICATION_DATA;\n        memcpy( ssl->out_msg, buf, len );\n\n        if( ( ret = mbedtls_ssl_write_record( ssl, SSL_FORCE_FLUSH ) ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"mbedtls_ssl_write_record\", ret );\n            return( ret );\n        }\n    }\n\n    return( (int) len );\n}","target":0,"code_token_length":497,"total_token_length":733,"max_tokens_setting":1024}
+{"idx":387578,"func":"static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file,\n\t\t\t     struct snd_ctl_tlv __user *buf,\n                             int op_flag)\n{\n\tstruct snd_ctl_tlv header;\n\tunsigned int __user *container;\n\tunsigned int container_size;\n\tstruct snd_kcontrol *kctl;\n\tstruct snd_ctl_elem_id id;\n\tstruct snd_kcontrol_volatile *vd;\n\n\tif (copy_from_user(&header, buf, sizeof(header)))\n\t\treturn -EFAULT;\n\n\t\/* In design of control core, numerical ID starts at 1. *\/\n\tif (header.numid == 0)\n\t\treturn -EINVAL;\n\n\t\/* At least, container should include type and length fields.  *\/\n\tif (header.length < sizeof(unsigned int) * 2)\n\t\treturn -EINVAL;\n\tcontainer_size = header.length;\n\tcontainer = buf->tlv;\n\n\tkctl = snd_ctl_find_numid(file->card, header.numid);\n\tif (kctl == NULL)\n\t\treturn -ENOENT;\n\n\t\/* Calculate index of the element in this set. *\/\n\tid = kctl->id;\n\tsnd_ctl_build_ioff(&id, kctl, header.numid - id.numid);\n\tvd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];\n\n\tif (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {\n\t\treturn call_tlv_handler(file, op_flag, kctl, &id, container,\n\t\t\t\t\tcontainer_size);\n\t} else {\n\t\tif (op_flag == SNDRV_CTL_TLV_OP_READ) {\n\t\t\treturn read_tlv_buf(kctl, &id, container,\n\t\t\t\t\t    container_size);\n\t\t}\n\t}\n\n\t\/* Not supported. *\/\n\treturn -ENXIO;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":313848,"func":"clear_showcmd(void)\n{\n    if (!p_sc)\n\treturn;\n\n    if (VIsual_active && !char_avail())\n    {\n\tint\t\tcursor_bot = LT_POS(VIsual, curwin->w_cursor);\n\tlong\t\tlines;\n\tcolnr_T\t\tleftcol, rightcol;\n\tlinenr_T\ttop, bot;\n\n\t\/\/ Show the size of the Visual area.\n\tif (cursor_bot)\n\t{\n\t    top = VIsual.lnum;\n\t    bot = curwin->w_cursor.lnum;\n\t}\n\telse\n\t{\n\t    top = curwin->w_cursor.lnum;\n\t    bot = VIsual.lnum;\n\t}\n# ifdef FEAT_FOLDING\n\t\/\/ Include closed folds as a whole.\n\t(void)hasFolding(top, &top, NULL);\n\t(void)hasFolding(bot, NULL, &bot);\n# endif\n\tlines = bot - top + 1;\n\n\tif (VIsual_mode == Ctrl_V)\n\t{\n# ifdef FEAT_LINEBREAK\n\t    char_u *saved_sbr = p_sbr;\n\t    char_u *saved_w_sbr = curwin->w_p_sbr;\n\n\t    \/\/ Make 'sbr' empty for a moment to get the correct size.\n\t    p_sbr = empty_option;\n\t    curwin->w_p_sbr = empty_option;\n# endif\n\t    getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);\n# ifdef FEAT_LINEBREAK\n\t    p_sbr = saved_sbr;\n\t    curwin->w_p_sbr = saved_w_sbr;\n# endif\n\t    sprintf((char *)showcmd_buf, \"%ldx%ld\", lines,\n\t\t\t\t\t      (long)(rightcol - leftcol + 1));\n\t}\n\telse if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum)\n\t    sprintf((char *)showcmd_buf, \"%ld\", lines);\n\telse\n\t{\n\t    char_u  *s, *e;\n\t    int\t    l;\n\t    int\t    bytes = 0;\n\t    int\t    chars = 0;\n\n\t    if (cursor_bot)\n\t    {\n\t\ts = ml_get_pos(&VIsual);\n\t\te = ml_get_cursor();\n\t    }\n\t    else\n\t    {\n\t\ts = ml_get_cursor();\n\t\te = ml_get_pos(&VIsual);\n\t    }\n\t    while ((*p_sel != 'e') ? s <= e : s < e)\n\t    {\n\t\tl = (*mb_ptr2len)(s);\n\t\tif (l == 0)\n\t\t{\n\t\t    ++bytes;\n\t\t    ++chars;\n\t\t    break;  \/\/ end of line\n\t\t}\n\t\tbytes += l;\n\t\t++chars;\n\t\ts += l;\n\t    }\n\t    if (bytes == chars)\n\t\tsprintf((char *)showcmd_buf, \"%d\", chars);\n\t    else\n\t\tsprintf((char *)showcmd_buf, \"%d-%d\", chars, bytes);\n\t}\n\tshowcmd_buf[SHOWCMD_COLS] = NUL;\t\/\/ truncate\n\tshowcmd_visual = TRUE;\n    }\n    else\n    {\n\tshowcmd_buf[0] = NUL;\n\tshowcmd_visual = FALSE;\n\n\t\/\/ Don't actually display something if there is nothing to clear.\n\tif (showcmd_is_clear)\n\t    return;\n    }\n\n    display_showcmd();\n}","target":0,"code_token_length":696,"total_token_length":932,"max_tokens_setting":1024}
+{"idx":224219,"func":"R_API int r_io_bank_write_to_submap_at(RIO *io, const ut32 bankid, ut64 addr, const ut8 *buf, int len) {\n\tRIOBank *bank = r_io_bank_get (io, bankid);\n\tr_return_val_if_fail (io && bank, -1);\n\tif (!len) {\n\t\treturn 0;\n\t}\n\tRRBNode *node;\n\tif (bank->last_used && r_io_submap_contain (((RIOSubMap *)bank->last_used->data), addr)) {\n\t\tnode = bank->last_used;\n\t} else {\n\t\tnode = r_crbtree_find_node (bank->submaps, &addr, _find_sm_by_vaddr_cb, NULL);\n\t\tif (!node) {\n\t\t\treturn 0;\n\t\t}\n\t\tbank->last_used = node;\n\t}\n\tRIOSubMap *sm = (RIOSubMap *)node->data;\n\tif (!r_io_submap_contain (sm, addr)) {\n\t\treturn 0;\n\t}\n\tRIOMap *map = r_io_map_get_by_ref (io, &sm->mapref);\n\tif (!map || !(map->perm & R_PERM_W)) {\n\t\treturn -1;\n\t}\n\tconst int write_len = R_MIN (len, r_io_submap_to (sm) - addr + 1);\n\tconst ut64 paddr = addr - r_io_map_from (map) + map->delta;\n\treturn r_io_fd_write_at (io, map->fd, paddr, buf, write_len);\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":310137,"func":"decode_xterm_SGR1006(SCREEN *sp, MEVENT * eventp)\n{\n    SGR_DATA data;\n    bool result = FALSE;\n    if (read_SGR(sp, &data)) {\n\tint b = data.params[0];\n\tint b3 = 1 + (b & 3);\n\tint wheel = ((b & 64) == 64);\n\n\tif (b >= 132) {\n\t    b3 = MAX_BUTTONS + 1;\n\t} else if (b >= 128) {\n\t    b3 = (b - 120);\t\/* buttons 8-11 *\/\n\t} else if (b >= 64) {\n\t    b3 = (b - 60);\t\/* buttons 6-7 *\/\n\t}\n\n\teventp->id = NORMAL_EVENT;\n\tif (data.final == 'M') {\n\t    (void) handle_wheel(sp, eventp, b, wheel);\n\t} else if (b3 > MAX_BUTTONS) {\n\t    eventp->bstate = REPORT_MOUSE_POSITION;\n\t} else {\n\t    mmask_t pressed = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_PRESSED);\n\t    mmask_t release = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_RELEASED);\n\t    if (sp->_mouse_bstate & pressed) {\n\t\teventp->bstate = release;\n\t\tsp->_mouse_bstate &= ~pressed;\n\t    } else {\n\t\teventp->bstate = REPORT_MOUSE_POSITION;\n\t    }\n\t}\n\tif (b & 4) {\n\t    eventp->bstate |= BUTTON_SHIFT;\n\t}\n\tif (b & 8) {\n\t    eventp->bstate |= BUTTON_ALT;\n\t}\n\tif (b & 16) {\n\t    eventp->bstate |= BUTTON_CTRL;\n\t}\n\tresult = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;\n\teventp->x = (data.params[1] ? (data.params[1] - 1) : 0);\n\teventp->y = (data.params[2] ? (data.params[2] - 1) : 0);\n    }\n    return result;\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":332396,"func":"skip_comment(\n    char_u   *line,\n    int      process,\n    int\t     include_space,\n    int      *is_comment)\n{\n    char_u *comment_flags = NULL;\n    int    lead_len;\n    int    leader_offset = get_last_leader_offset(line, &comment_flags);\n\n    *is_comment = FALSE;\n    if (leader_offset != -1)\n    {\n\t\/\/ Let's check whether the line ends with an unclosed comment.\n\t\/\/ If the last comment leader has COM_END in flags, there's no comment.\n\twhile (*comment_flags)\n\t{\n\t    if (*comment_flags == COM_END\n\t\t    || *comment_flags == ':')\n\t\tbreak;\n\t    ++comment_flags;\n\t}\n\tif (*comment_flags != COM_END)\n\t    *is_comment = TRUE;\n    }\n\n    if (process == FALSE)\n\treturn line;\n\n    lead_len = get_leader_len(line, &comment_flags, FALSE, include_space);\n\n    if (lead_len == 0)\n\treturn line;\n\n    \/\/ Find:\n    \/\/ - COM_END,\n    \/\/ - colon,\n    \/\/ whichever comes first.\n    while (*comment_flags)\n    {\n\tif (*comment_flags == COM_END\n\t\t|| *comment_flags == ':')\n\t    break;\n\t++comment_flags;\n    }\n\n    \/\/ If we found a colon, it means that we are not processing a line\n    \/\/ starting with a closing part of a three-part comment. That's good,\n    \/\/ because we don't want to remove those as this would be annoying.\n    if (*comment_flags == ':' || *comment_flags == NUL)\n\tline += lead_len;\n\n    return line;\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":294427,"func":"date_s_commercial(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vw, vd, vsg, y, fr, fr2, ret;\n    int w, d;\n    double sg;\n\n    rb_scan_args(argc, argv, \"04\", &vy, &vw, &vd, &vsg);\n\n    y = INT2FIX(-4712);\n    w = 1;\n    d = 1;\n    fr2 = INT2FIX(0);\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 4:\n\tval2sg(vsg, sg);\n      case 3:\n        check_numeric(vd, \"cwday\");\n\tnum2int_with_frac(d, positive_inf);\n      case 2:\n        check_numeric(vw, \"cweek\");\n\tw = NUM2INT(vw);\n      case 1:\n        check_numeric(vy, \"year\");\n\ty = vy;\n    }\n\n    {\n\tVALUE nth;\n\tint ry, rw, rd, rjd, ns;\n\n\tif (!valid_commercial_p(y, w, d, sg,\n\t\t\t\t&nth, &ry,\n\t\t\t\t&rw, &rd, &rjd,\n\t\t\t\t&ns))\n\t    rb_raise(eDateError, \"invalid date\");\n\n\tret = d_simple_new_internal(klass,\n\t\t\t\t    nth, rjd,\n\t\t\t\t    sg,\n\t\t\t\t    0, 0, 0,\n\t\t\t\t    HAVE_JD);\n    }\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":331792,"func":"Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path)\n{\n    const qreal *points = path.points();\n    const QPainterPath::ElementType *types = path.elements();\n\n    QPainterPath p;\n    if (types) {\n        int id = 0;\n        for (int i=0; i<path.elementCount(); ++i) {\n            switch(types[i]) {\n            case QPainterPath::MoveToElement:\n                p.moveTo(QPointF(points[id], points[id+1]));\n                id+=2;\n                break;\n            case QPainterPath::LineToElement:\n                p.lineTo(QPointF(points[id], points[id+1]));\n                id+=2;\n                break;\n            case QPainterPath::CurveToElement: {\n                QPointF p1(points[id], points[id+1]);\n                QPointF p2(points[id+2], points[id+3]);\n                QPointF p3(points[id+4], points[id+5]);\n                p.cubicTo(p1, p2, p3);\n                id+=6;\n                break;\n            }\n            case QPainterPath::CurveToDataElement:\n                ;\n                break;\n            }\n        }\n    } else {\n        p.moveTo(QPointF(points[0], points[1]));\n        int id = 2;\n        for (int i=1; i<path.elementCount(); ++i) {\n            p.lineTo(QPointF(points[id], points[id+1]));\n            id+=2;\n        }\n    }\n    if (path.hints() & QVectorPath::WindingFill)\n        p.setFillRule(Qt::WindingFill);\n\n    return p;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":255937,"func":"Status ShapeRefiner::AddNodeInternal(\n    const Node* node, shape_inference::InferenceContext* outer_context) {\n  \/\/ Create the inference context for this node with the existing input shapes.\n  std::unique_ptr<InferenceContext> ic(new InferenceContext(\n      graph_def_version_, node->def(), node->op_def(),\n      std::vector<ShapeHandle>(node->num_inputs()), {}, {}, {}));\n  TF_RETURN_IF_ERROR(ic->construction_status());\n\n  \/\/ For each 'input' of this node, fetch the corresponding shape\n  \/\/ from 'input's InferenceContext, and store into this node's\n  \/\/ InferenceContext.\n  for (const Edge* e : node->in_edges()) {\n    if (e->IsControlEdge()) continue;\n\n    if (e->dst_input() < 0) {\n      return tensorflow::errors::Internal(\n          \"Index \", e->dst_input(), \" is negative but not a control edge.\");\n    }\n\n    const Node* input = e->src();\n    auto it = node_to_context_.find(input);\n    if (it == node_to_context_.end()) {\n      \/\/ v1 control flow adds loops to the graph; we have to break them\n      \/\/ somewhere, so we'll ignore this input and leave its shape undefined.\n      ic->SetInput(e->dst_input(), ic->UnknownShape());\n      continue;\n    }\n\n    InferenceContext* input_ic = it->second->get_context();\n    ic->SetInput(e->dst_input(), input_ic->output(e->src_output()));\n\n    const auto* in_v =\n        input_ic->output_handle_shapes_and_types(e->src_output());\n    if (in_v != nullptr) {\n      DataType input_type = e->src()->output_type(e->src_output());\n      DCHECK(input_type == DT_RESOURCE || input_type == DT_VARIANT);\n      ic->set_input_handle_shapes_and_types(e->dst_input(),\n                                            std::vector<ShapeAndType>(*in_v));\n    }\n  }\n\n  \/\/ Get the shape function for this node\n  const OpRegistrationData* op_reg_data;\n  TF_RETURN_IF_ERROR(ops_registry_->LookUp(node->type_string(), &op_reg_data));\n  if (op_reg_data->shape_inference_fn == nullptr &&\n      require_shape_inference_fns_) {\n    return errors::InvalidArgument(\n        \"No shape inference function exists for op '\", node->type_string(),\n        \"', did you forget to define it?\");\n  }\n\n  std::unique_ptr<ExtendedInferenceContext> ec(\n      new ExtendedInferenceContext(std::move(ic), node));\n\n  \/\/ Run the shape inference function, and return if there was an error.\n  TF_RETURN_IF_ERROR(RunShapeFn(node, op_reg_data, ec.get(), outer_context));\n\n  \/\/ Store the resulting context object in the map.\n  node_to_context_[node].swap(ec);\n\n  return Status::OK();\n}","target":0,"code_token_length":603,"total_token_length":839,"max_tokens_setting":1024}
+{"idx":259233,"func":"static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    int ret;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    if ((uint64_t)atom.size > (1<<30))\n        return AVERROR_INVALIDDATA;\n\n    if (atom.size >= 10) {\n        \/\/ Broken files created by legacy versions of libavformat will\n        \/\/ wrap a whole fiel atom inside of a glbl atom.\n        unsigned size = avio_rb32(pb);\n        unsigned type = avio_rl32(pb);\n        if (avio_feof(pb))\n            return AVERROR_INVALIDDATA;\n        avio_seek(pb, -8, SEEK_CUR);\n        if (type == MKTAG('f','i','e','l') && size == atom.size)\n            return mov_read_default(c, pb, atom);\n    }\n    if (st->codecpar->extradata_size > 1 && st->codecpar->extradata) {\n        av_log(c->fc, AV_LOG_WARNING, \"ignoring multiple glbl\\n\");\n        return 0;\n    }\n    ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);\n    if (ret < 0)\n        return ret;\n    if (atom.type == MKTAG('h','v','c','C') && st->codecpar->codec_tag == MKTAG('d','v','h','1'))\n        \/* HEVC-based Dolby Vision derived from hvc1.\n           Happens to match with an identifier\n           previously utilized for DV. Thus, if we have\n           the hvcC extradata box available as specified,\n           set codec to HEVC *\/\n        st->codecpar->codec_id = AV_CODEC_ID_HEVC;\n\n    return 0;\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":408973,"func":"ins_eol(int c)\n{\n    int\t    i;\n\n    if (echeck_abbr(c + ABBR_OFF))\n\treturn OK;\n    if (stop_arrow() == FAIL)\n\treturn FAIL;\n    undisplay_dollar();\n\n    \/*\n     * Strange Vi behaviour: In Replace mode, typing a NL will not delete the\n     * character under the cursor.  Only push a NUL on the replace stack,\n     * nothing to put back when the NL is deleted.\n     *\/\n    if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))\n\treplace_push(NUL);\n\n    \/*\n     * In VREPLACE mode, a NL replaces the rest of the line, and starts\n     * replacing the next line, so we push all of the characters left on the\n     * line onto the replace stack.  This is not done here though, it is done\n     * in open_line().\n     *\/\n\n    \/\/ Put cursor on NUL if on the last char and coladd is 1 (happens after\n    \/\/ CTRL-O).\n    if (virtual_active() && curwin->w_cursor.coladd > 0)\n\tcoladvance(getviscol());\n\n#ifdef FEAT_RIGHTLEFT\n    \/\/ NL in reverse insert will always start in the end of\n    \/\/ current line.\n    if (revins_on)\n\tcurwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());\n#endif\n\n    AppendToRedobuff(NL_STR);\n    i = open_line(FORWARD,\n\t    has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent,\n\t    NULL);\n    old_indent = 0;\n#ifdef FEAT_CINDENT\n    can_cindent = TRUE;\n#endif\n#ifdef FEAT_FOLDING\n    \/\/ When inserting a line the cursor line must never be in a closed fold.\n    foldOpenCursor();\n#endif\n\n    return i;\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":259269,"func":"static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)\n{\n    MOVStreamContext *sc = st->priv_data;\n    FFStream *const sti = ffstream(st);\n    int sample, time_sample, ret;\n    unsigned int i;\n\n    \/\/ Here we consider timestamp to be PTS, hence try to offset it so that we\n    \/\/ can search over the DTS timeline.\n    timestamp -= (sc->min_corrected_pts + sc->dts_shift);\n\n    ret = mov_seek_fragment(s, st, timestamp);\n    if (ret < 0)\n        return ret;\n\n    for (;;) {\n        sample = av_index_search_timestamp(st, timestamp, flags);\n        av_log(s, AV_LOG_TRACE, \"stream %d, timestamp %\"PRId64\", sample %d\\n\", st->index, timestamp, sample);\n        if (sample < 0 && sti->nb_index_entries && timestamp < sti->index_entries[0].timestamp)\n            sample = 0;\n        if (sample < 0) \/* not sure what to do *\/\n            return AVERROR_INVALIDDATA;\n\n        if (!sample || can_seek_to_key_sample(st, sample, timestamp))\n            break;\n        timestamp -= FFMAX(sc->min_sample_duration, 1);\n    }\n\n    mov_current_sample_set(sc, sample);\n    av_log(s, AV_LOG_TRACE, \"stream %d, found sample %d\\n\", st->index, sc->current_sample);\n    \/* adjust ctts index *\/\n    if (sc->ctts_data) {\n        time_sample = 0;\n        for (i = 0; i < sc->ctts_count; i++) {\n            int next = time_sample + sc->ctts_data[i].count;\n            if (next > sc->current_sample) {\n                sc->ctts_index = i;\n                sc->ctts_sample = sc->current_sample - time_sample;\n                break;\n            }\n            time_sample = next;\n        }\n    }\n\n    \/* adjust stsd index *\/\n    if (sc->chunk_count) {\n        time_sample = 0;\n        for (i = 0; i < sc->stsc_count; i++) {\n            int64_t next = time_sample + mov_get_stsc_samples(sc, i);\n            if (next > sc->current_sample) {\n                sc->stsc_index = i;\n                sc->stsc_sample = sc->current_sample - time_sample;\n                break;\n            }\n            av_assert0(next == (int)next);\n            time_sample = next;\n        }\n    }\n\n    return sample;\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":384195,"func":"static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,\n\t\t\t      const struct nlattr * const nla[])\n{\n\tstruct nftables_pernet *nft_net = nft_pernet(info->net);\n\tstruct netlink_ext_ack *extack = info->extack;\n\tu8 genmask = nft_genmask_next(info->net);\n\tu8 family = info->nfmsg->nfgen_family;\n\tstruct net *net = info->net;\n\tconst struct nlattr *attr;\n\tstruct nft_table *table;\n\tstruct nft_ctx ctx;\n\tu32 flags = 0;\n\tint err;\n\n\tif (!nft_supported_family(family))\n\t\treturn -EOPNOTSUPP;\n\n\tlockdep_assert_held(&nft_net->commit_mutex);\n\tattr = nla[NFTA_TABLE_NAME];\n\ttable = nft_table_lookup(net, attr, family, genmask,\n\t\t\t\t NETLINK_CB(skb).portid);\n\tif (IS_ERR(table)) {\n\t\tif (PTR_ERR(table) != -ENOENT)\n\t\t\treturn PTR_ERR(table);\n\t} else {\n\t\tif (info->nlh->nlmsg_flags & NLM_F_EXCL) {\n\t\t\tNL_SET_BAD_ATTR(extack, attr);\n\t\t\treturn -EEXIST;\n\t\t}\n\t\tif (info->nlh->nlmsg_flags & NLM_F_REPLACE)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tnft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);\n\n\t\treturn nf_tables_updtable(&ctx);\n\t}\n\n\tif (nla[NFTA_TABLE_FLAGS]) {\n\t\tflags = ntohl(nla_get_be32(nla[NFTA_TABLE_FLAGS]));\n\t\tif (flags & ~NFT_TABLE_F_MASK)\n\t\t\treturn -EOPNOTSUPP;\n\t}\n\n\terr = -ENOMEM;\n\ttable = kzalloc(sizeof(*table), GFP_KERNEL_ACCOUNT);\n\tif (table == NULL)\n\t\tgoto err_kzalloc;\n\n\ttable->name = nla_strdup(attr, GFP_KERNEL_ACCOUNT);\n\tif (table->name == NULL)\n\t\tgoto err_strdup;\n\n\tif (nla[NFTA_TABLE_USERDATA]) {\n\t\ttable->udata = nla_memdup(nla[NFTA_TABLE_USERDATA], GFP_KERNEL_ACCOUNT);\n\t\tif (table->udata == NULL)\n\t\t\tgoto err_table_udata;\n\n\t\ttable->udlen = nla_len(nla[NFTA_TABLE_USERDATA]);\n\t}\n\n\terr = rhltable_init(&table->chains_ht, &nft_chain_ht_params);\n\tif (err)\n\t\tgoto err_chain_ht;\n\n\tINIT_LIST_HEAD(&table->chains);\n\tINIT_LIST_HEAD(&table->sets);\n\tINIT_LIST_HEAD(&table->objects);\n\tINIT_LIST_HEAD(&table->flowtables);\n\ttable->family = family;\n\ttable->flags = flags;\n\ttable->handle = ++nft_net->table_handle;\n\tif (table->flags & NFT_TABLE_F_OWNER)\n\t\ttable->nlpid = NETLINK_CB(skb).portid;\n\n\tnft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);\n\terr = nft_trans_table_add(&ctx, NFT_MSG_NEWTABLE);\n\tif (err < 0)\n\t\tgoto err_trans;\n\n\tlist_add_tail_rcu(&table->list, &nft_net->tables);\n\treturn 0;\nerr_trans:\n\trhltable_destroy(&table->chains_ht);\nerr_chain_ht:\n\tkfree(table->udata);\nerr_table_udata:\n\tkfree(table->name);\nerr_strdup:\n\tkfree(table);\nerr_kzalloc:\n\treturn err;\n}","target":0,"code_token_length":742,"total_token_length":978,"max_tokens_setting":1024}
+{"idx":218771,"func":"static void XDrawBevel(Display *display,const XWindowInfo *window_info,\n  const XWidgetInfo *bevel_info)\n{\n  int\n    x1,\n    x2,\n    y1,\n    y2;\n\n  unsigned int\n    bevel_width;\n\n  XPoint\n    points[6];\n\n  \/*\n    Draw upper and left beveled border.\n  *\/\n  x1=bevel_info->x;\n  y1=bevel_info->y+bevel_info->height;\n  x2=bevel_info->x+bevel_info->width;\n  y2=bevel_info->y;\n  bevel_width=bevel_info->bevel_width;\n  points[0].x=x1;\n  points[0].y=y1;\n  points[1].x=x1;\n  points[1].y=y2;\n  points[2].x=x2;\n  points[2].y=y2;\n  points[3].x=x2+bevel_width;\n  points[3].y=y2-bevel_width;\n  points[4].x=x1-bevel_width;\n  points[4].y=y2-bevel_width;\n  points[5].x=x1-bevel_width;\n  points[5].y=y1+bevel_width;\n  XSetBevelColor(display,window_info,bevel_info->raised);\n  (void) XFillPolygon(display,window_info->id,window_info->widget_context,\n    points,6,Complex,CoordModeOrigin);\n  \/*\n    Draw lower and right beveled border.\n  *\/\n  points[0].x=x1;\n  points[0].y=y1;\n  points[1].x=x2;\n  points[1].y=y1;\n  points[2].x=x2;\n  points[2].y=y2;\n  points[3].x=x2+bevel_width;\n  points[3].y=y2-bevel_width;\n  points[4].x=x2+bevel_width;\n  points[4].y=y1+bevel_width;\n  points[5].x=x1-bevel_width;\n  points[5].y=y1+bevel_width;\n  XSetBevelColor(display,window_info,!bevel_info->raised);\n  (void) XFillPolygon(display,window_info->id,window_info->widget_context,\n    points,6,Complex,CoordModeOrigin);\n  (void) XSetFillStyle(display,window_info->widget_context,FillSolid);\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":247557,"func":"TEST_P(SslSocketTest, RsaAndEcdsaPrivateKeyProviderMultiCertFail) {\n  const std::string client_ctx_yaml = absl::StrCat(R\"EOF(\n    common_tls_context:\n      tls_params:\n        tls_minimum_protocol_version: TLSv1_2\n        tls_maximum_protocol_version: TLSv1_2\n        cipher_suites:\n        - ECDHE-ECDSA-AES128-GCM-SHA256\n        - ECDHE-RSA-AES128-GCM-SHA256\n      validation_context:\n        verify_certificate_hash: )EOF\",\n                                                   TEST_SELFSIGNED_ECDSA_P256_CERT_256_HASH);\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_cert.pem\"\n      private_key_provider:\n        provider_name: test\n        typed_config:\n          \"@type\": type.googleapis.com\/google.protobuf.Struct\n          value:\n            private_key_file: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n            expected_operation: sign\n            sync_mode: false\n            mode: rsa\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_ecdsa_p256_cert.pem\"\n      private_key_provider:\n        provider_name: test\n        typed_config:\n          \"@type\": type.googleapis.com\/google.protobuf.Struct\n          value:\n            private_key_file: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_ecdsa_p256_key.pem\"\n            expected_operation: sign\n            async_method_error: true\n            mode: ecdsa\n)EOF\";\n  TestUtilOptions failing_test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(failing_test_options.setPrivateKeyMethodExpected(true)\n               .setExpectedServerCloseEvent(Network::ConnectionEvent::LocalClose)\n               .setExpectedServerStats(\"ssl.connection_error\"));\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":247159,"func":"Bool gf_fs_fire_event(GF_FilterSession *fs, GF_Filter *f, GF_FilterEvent *evt, Bool upstream)\n{\n\tBool ret = GF_FALSE;\n\tif (!fs || !evt) return GF_FALSE;\n\n\tGF_FilterPid *on_pid = evt->base.on_pid;\n\tevt->base.on_pid = NULL;\n\tif (f) {\n\t\tif (evt->base.type==GF_FEVT_USER) {\n\t\t\tif (f->freg->process_event && f->event_target) {\n\t\t\t\tgf_mx_p(f->tasks_mx);\n\t\t\t\tf->freg->process_event(f, evt);\n\t\t\t\tgf_mx_v(f->tasks_mx);\n\t\t\t\tret = GF_TRUE;\n\t\t\t}\n\t\t}\n\t\tif (!ret) {\n\t\t\tgf_mx_p(f->tasks_mx);\n\t\t\tif (f->num_output_pids && upstream) ret = GF_TRUE;\n\t\t\telse if (f->num_input_pids && !upstream) ret = GF_TRUE;\n\t\t\tgf_filter_send_event(f, evt, upstream);\n\t\t\tgf_mx_v(f->tasks_mx);\n\t\t}\n\t} else {\n\t\tu32 i, count;\n\t\tgf_fs_lock_filters(fs, GF_TRUE);\n\t\tcount = gf_list_count(fs->filters);\n\t\tfor (i=0; i<count; i++) {\n\t\t\tBool canceled;\n\t\t\tf = gf_list_get(fs->filters, i);\n\t\t\tif (f->disabled || f->removed) continue;\n\t\t\tif (f->multi_sink_target) continue;\n\t\t\tif (!f->freg->process_event) continue;\n\t\t\tif (!f->event_target) continue;\n\n\t\t\tgf_mx_p(f->tasks_mx);\n\t\t\tcanceled = f->freg->process_event(f, evt);\n\t\t\tgf_mx_v(f->tasks_mx);\n\t\t\tret = GF_TRUE;\n\t\t\tif (canceled) break;\n\t\t}\n\t\tgf_fs_lock_filters(fs, GF_FALSE);\n\t}\n\tevt->base.on_pid = on_pid;\n\treturn ret;\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":477271,"func":"static bool tipc_crypto_key_try_align(struct tipc_crypto *rx, u8 new_pending)\n{\n\tstruct tipc_aead *tmp1, *tmp2 = NULL;\n\tstruct tipc_key key;\n\tbool aligned = false;\n\tu8 new_passive = 0;\n\tint x;\n\n\tspin_lock(&rx->lock);\n\tkey = rx->key;\n\tif (key.pending == new_pending) {\n\t\taligned = true;\n\t\tgoto exit;\n\t}\n\tif (key.active)\n\t\tgoto exit;\n\tif (!key.pending)\n\t\tgoto exit;\n\tif (tipc_aead_users(rx->aead[key.pending]) > 0)\n\t\tgoto exit;\n\n\t\/* Try to \"isolate\" this pending key first *\/\n\ttmp1 = tipc_aead_rcu_ptr(rx->aead[key.pending], &rx->lock);\n\tif (!refcount_dec_if_one(&tmp1->refcnt))\n\t\tgoto exit;\n\trcu_assign_pointer(rx->aead[key.pending], NULL);\n\n\t\/* Move passive key if any *\/\n\tif (key.passive) {\n\t\ttmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, lockdep_is_held(&rx->lock));\n\t\tx = (key.passive - key.pending + new_pending) % KEY_MAX;\n\t\tnew_passive = (x <= 0) ? x + KEY_MAX : x;\n\t}\n\n\t\/* Re-allocate the key(s) *\/\n\ttipc_crypto_key_set_state(rx, new_passive, 0, new_pending);\n\trcu_assign_pointer(rx->aead[new_pending], tmp1);\n\tif (new_passive)\n\t\trcu_assign_pointer(rx->aead[new_passive], tmp2);\n\trefcount_set(&tmp1->refcnt, 1);\n\taligned = true;\n\tpr_info_ratelimited(\"%s: key[%d] -> key[%d]\\n\", rx->name, key.pending,\n\t\t\t    new_pending);\n\nexit:\n\tspin_unlock(&rx->lock);\n\treturn aligned;\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":277476,"func":"static MOBI_RET mobi_parse_tagx(MOBIBuffer *buf, MOBITagx *tagx) {\n    tagx->control_byte_count = 0;\n    tagx->tags_count = 0;\n    tagx->tags = NULL;\n    mobi_buffer_seek(buf, 4); \/* skip header *\/\n    uint32_t tagx_record_length = mobi_buffer_get32(buf);\n    if (tagx_record_length < 12) {\n        debug_print(\"INDX record too short: %u\\n\", tagx_record_length);\n        return MOBI_DATA_CORRUPT;\n    }\n    tagx->control_byte_count = mobi_buffer_get32(buf);\n    tagx_record_length -= 12;\n    if (tagx_record_length + buf->offset > buf->maxlen) {\n        debug_print(\"INDX record too long: %u\\n\", tagx_record_length);\n        return MOBI_DATA_CORRUPT;\n    }\n    tagx->tags = malloc(tagx_record_length * sizeof(TAGXTags));\n    if (tagx->tags == NULL) {\n        debug_print(\"%s\", \"Memory allocation failed for TAGX tags\\n\");\n        return MOBI_MALLOC_FAILED;\n    }\n    size_t i = 0;\n    const size_t tagx_data_length = tagx_record_length \/ 4;\n    size_t control_byte_count = 0;\n    while (i < tagx_data_length) {\n        tagx->tags[i].tag = mobi_buffer_get8(buf);\n        tagx->tags[i].values_count = mobi_buffer_get8(buf);\n        tagx->tags[i].bitmask = mobi_buffer_get8(buf);\n        const uint8_t control_byte = mobi_buffer_get8(buf);\n        if (control_byte) { control_byte_count++; }\n        tagx->tags[i].control_byte = control_byte;\n        debug_print(\"tagx[%zu]:\\t%i\\t%i\\t%i\\t%i\\n\", i, tagx->tags[i].tag, tagx->tags[i].values_count, tagx->tags[i].bitmask, control_byte);\n        i++;\n    }\n    if (tagx->control_byte_count != control_byte_count) {\n        debug_print(\"Wrong count of control bytes: %zu != %zu\\n\", tagx->control_byte_count, control_byte_count);\n        free(tagx->tags);\n        tagx->tags = NULL;\n        tagx->control_byte_count = 0;\n        return MOBI_DATA_CORRUPT;\n    }\n    tagx->tags_count = i;\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":544,"total_token_length":780,"max_tokens_setting":1024}
+{"idx":247697,"func":"TEST_P(SslSocketTest, GetIssueExpireTimesPeerCert) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n  require_client_certificate: true\n)EOF\";\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedSerialNumber(TEST_NO_SAN_CERT_SERIAL)\n               .setExpectedValidFromTimePeerCert(TEST_NO_SAN_CERT_NOT_BEFORE)\n               .setExpectedExpirationTimePeerCert(TEST_NO_SAN_CERT_NOT_AFTER));\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":488367,"func":"static __init int vdso_fixup_datapage(struct lib32_elfinfo *v32,\n\t\t\t\t       struct lib64_elfinfo *v64)\n{\n\tElf32_Sym *sym32;\n#ifdef CONFIG_PPC64\n\tElf64_Sym *sym64;\n\n       \tsym64 = find_symbol64(v64, \"__kernel_datapage_offset\");\n\tif (sym64 == NULL) {\n\t\tprintk(KERN_ERR \"vDSO64: Can't find symbol \"\n\t\t       \"__kernel_datapage_offset !\\n\");\n\t\treturn -1;\n\t}\n\t*((int *)(vdso64_kbase + sym64->st_value - VDSO64_LBASE)) =\n\t\t(vdso64_pages << PAGE_SHIFT) -\n\t\t(sym64->st_value - VDSO64_LBASE);\n#endif \/* CONFIG_PPC64 *\/\n\n\tsym32 = find_symbol32(v32, \"__kernel_datapage_offset\");\n\tif (sym32 == NULL) {\n\t\tprintk(KERN_ERR \"vDSO32: Can't find symbol \"\n\t\t       \"__kernel_datapage_offset !\\n\");\n\t\treturn -1;\n\t}\n\t*((int *)(vdso32_kbase + (sym32->st_value - VDSO32_LBASE))) =\n\t\t(vdso32_pages << PAGE_SHIFT) -\n\t\t(sym32->st_value - VDSO32_LBASE);\n\n\treturn 0;\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":202659,"func":"static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t\tu8 type, u8 code, int offset, __be32 info)\n{\n\tconst struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb->data;\n\t__be16 *p = (__be16 *)(skb->data + offset);\n\tint grehlen = offset + 4;\n\tstruct ip6_tnl *t;\n\t__be16 flags;\n\n\tflags = p[0];\n\tif (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {\n\t\tif (flags&(GRE_VERSION|GRE_ROUTING))\n\t\t\treturn;\n\t\tif (flags&GRE_KEY) {\n\t\t\tgrehlen += 4;\n\t\t\tif (flags&GRE_CSUM)\n\t\t\t\tgrehlen += 4;\n\t\t}\n\t}\n\n\t\/* If only 8 bytes returned, keyed message will be dropped here *\/\n\tif (!pskb_may_pull(skb, grehlen))\n\t\treturn;\n\tipv6h = (const struct ipv6hdr *)skb->data;\n\tp = (__be16 *)(skb->data + offset);\n\n\tt = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,\n\t\t\t\tflags & GRE_KEY ?\n\t\t\t\t*(((__be32 *)p) + (grehlen \/ 4) - 1) : 0,\n\t\t\t\tp[1]);\n\tif (!t)\n\t\treturn;\n\n\tswitch (type) {\n\t\t__u32 teli;\n\t\tstruct ipv6_tlv_tnl_enc_lim *tel;\n\t\t__u32 mtu;\n\tcase ICMPV6_DEST_UNREACH:\n\t\tnet_dbg_ratelimited(\"%s: Path to destination invalid or inactive!\\n\",\n\t\t\t\t    t->parms.name);\n\t\tbreak;\n\tcase ICMPV6_TIME_EXCEED:\n\t\tif (code == ICMPV6_EXC_HOPLIMIT) {\n\t\t\tnet_dbg_ratelimited(\"%s: Too small hop limit or routing loop in tunnel!\\n\",\n\t\t\t\t\t    t->parms.name);\n\t\t}\n\t\tbreak;\n\tcase ICMPV6_PARAMPROB:\n\t\tteli = 0;\n\t\tif (code == ICMPV6_HDR_FIELD)\n\t\t\tteli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);\n\n\t\tif (teli && teli == be32_to_cpu(info) - 2) {\n\t\t\ttel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];\n\t\t\tif (tel->encap_limit == 0) {\n\t\t\t\tnet_dbg_ratelimited(\"%s: Too small encapsulation limit or routing loop in tunnel!\\n\",\n\t\t\t\t\t\t    t->parms.name);\n\t\t\t}\n\t\t} else {\n\t\t\tnet_dbg_ratelimited(\"%s: Recipient unable to parse tunneled packet!\\n\",\n\t\t\t\t\t    t->parms.name);\n\t\t}\n\t\tbreak;\n\tcase ICMPV6_PKT_TOOBIG:\n\t\tmtu = be32_to_cpu(info) - offset;\n\t\tif (mtu < IPV6_MIN_MTU)\n\t\t\tmtu = IPV6_MIN_MTU;\n\t\tt->dev->mtu = mtu;\n\t\tbreak;\n\t}\n\n\tif (time_before(jiffies, t->err_time + IP6TUNNEL_ERR_TIMEO))\n\t\tt->err_count++;\n\telse\n\t\tt->err_count = 1;\n\tt->err_time = jiffies;\n}","target":1,"code_token_length":724,"total_token_length":960,"max_tokens_setting":1024}
+{"idx":198556,"func":"fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n  struct mrb_context *c = fiber_check(mrb, self);\n  struct mrb_context *old_c = mrb->c;\n  enum mrb_fiber_state status;\n  mrb_value value;\n\n  fiber_check_cfunc(mrb, c);\n  status = c->status;\n  switch (status) {\n  case MRB_FIBER_TRANSFERRED:\n    if (resume) {\n      mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n    }\n    break;\n  case MRB_FIBER_RUNNING:\n  case MRB_FIBER_RESUMED:\n    mrb_raise(mrb, E_FIBER_ERROR, \"double resume\");\n    break;\n  case MRB_FIBER_TERMINATED:\n    mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n    break;\n  default:\n    break;\n  }\n  old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n  c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);\n  fiber_switch_context(mrb, c);\n  if (status == MRB_FIBER_CREATED) {\n    mrb_value *b, *e;\n\n    if (!c->ci->proc) {\n      mrb_raise(mrb, E_FIBER_ERROR, \"double resume (current)\");\n    }\n    mrb_stack_extend(mrb, len+2); \/* for receiver and (optional) block *\/\n    b = c->stbase+1;\n    e = b + len;\n    while (b<e) {\n      *b++ = *a++;\n    }\n    if (vmexec) {\n      c->ci--;                    \/* pop dummy callinfo *\/\n    }\n    c->cibase->n = len;\n    value = c->stbase[0] = MRB_PROC_ENV(c->cibase->proc)->stack[0];\n  }\n  else {\n    value = fiber_result(mrb, a, len);\n    if (vmexec) {\n      c->ci[1].stack[0] = value;\n    }\n  }\n\n  if (vmexec) {\n    c->vmexec = TRUE;\n    value = mrb_vm_exec(mrb, c->ci->proc, c->ci->pc);\n    mrb->c = old_c;\n  }\n  else {\n    MARK_CONTEXT_MODIFY(c);\n  }\n  return value;\n}","target":1,"code_token_length":540,"total_token_length":776,"max_tokens_setting":1024}
+{"idx":455331,"func":"parse_long_options (argv, arg_start, arg_end)\n     char **argv;\n     int arg_start, arg_end;\n{\n  int arg_index, longarg, i;\n  char *arg_string;\n\n  arg_index = arg_start;\n  while ((arg_index != arg_end) && (arg_string = argv[arg_index]) &&\n\t (*arg_string == '-'))\n    {\n      longarg = 0;\n\n      \/* Make --login equivalent to -login. *\/\n      if (arg_string[1] == '-' && arg_string[2])\n\t{\n\t  longarg = 1;\n\t  arg_string++;\n\t}\n\n      for (i = 0; long_args[i].name; i++)\n\t{\n\t  if (STREQ (arg_string + 1, long_args[i].name))\n\t    {\n\t      if (long_args[i].type == Int)\n\t\t*long_args[i].int_value = 1;\n\t      else if (argv[++arg_index] == 0)\n\t\t{\n\t\t  report_error (_(\"%s: option requires an argument\"), long_args[i].name);\n\t\t  exit (EX_BADUSAGE);\n\t\t}\n\t      else\n\t\t*long_args[i].char_value = argv[arg_index];\n\n\t      break;\n\t    }\n\t}\n      if (long_args[i].name == 0)\n\t{\n\t  if (longarg)\n\t    {\n\t      report_error (_(\"%s: invalid option\"), argv[arg_index]);\n\t      show_shell_usage (stderr, 0);\n\t      exit (EX_BADUSAGE);\n\t    }\n\t  break;\t\t\/* No such argument.  Maybe flag arg. *\/\n\t}\n\n      arg_index++;\n    }\n\n  return (arg_index);\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":293941,"func":"get_number_indent(linenr_T lnum)\n{\n    colnr_T\tcol;\n    pos_T\tpos;\n\n    regmatch_T\tregmatch;\n    int\t\tlead_len = 0;\t\/\/ length of comment leader\n\n    if (lnum > curbuf->b_ml.ml_line_count)\n\treturn -1;\n    pos.lnum = 0;\n\n    \/\/ In format_lines() (i.e. not insert mode), fo+=q is needed too...\n    if ((State & INSERT) || has_format_option(FO_Q_COMS))\n\tlead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);\n\n    regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);\n    if (regmatch.regprog != NULL)\n    {\n\tregmatch.rm_ic = FALSE;\n\n\t\/\/ vim_regexec() expects a pointer to a line.  This lets us\n\t\/\/ start matching for the flp beyond any comment leader...\n\tif (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0))\n\t{\n\t    pos.lnum = lnum;\n\t    pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum));\n\t    pos.coladd = 0;\n\t}\n\tvim_regfree(regmatch.regprog);\n    }\n\n    if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)\n\treturn -1;\n    getvcol(curwin, &pos, &col, NULL, NULL);\n    return (int)col;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":352962,"func":"serialNumberAndIssuerNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *in,\n\tstruct berval *out,\n\tvoid *ctx )\n{\n\tstruct berval sn, sn2, sn3, i, ni;\n\tchar sbuf2[SLAP_SN_BUFLEN];\n\tchar sbuf3[SLAP_SN_BUFLEN];\n\tchar *p;\n\tint rc;\n\n\tassert( in != NULL );\n\tassert( out != NULL );\n\n\tDebug( LDAP_DEBUG_TRACE, \">>> serialNumberAndIssuerNormalize: <%s>\\n\",\n\t\tin->bv_val );\n\n\trc = serialNumberAndIssuerCheck( in, &sn, &i, ctx );\n\tif ( rc ) {\n\t\treturn rc;\n\t}\n\n\trc = dnNormalize( usage, syntax, mr, &i, &ni, ctx );\n\n\tif ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) {\n\t\tslap_sl_free( i.bv_val, ctx );\n\t}\n\n\tif ( rc ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* Convert sn to canonical hex *\/\n\tsn2.bv_val = sbuf2;\n\tif ( sn.bv_len > sizeof( sbuf2 ) ) {\n\t\tsn2.bv_val = slap_sl_malloc( sn.bv_len, ctx );\n\t}\n\tsn2.bv_len = sn.bv_len;\n\tsn3.bv_val = sbuf3;\n\tsn3.bv_len = sizeof(sbuf3);\n\tif ( lutil_str2bin( &sn, &sn2, ctx ) || slap_bin2hex( &sn2, &sn3, ctx ) ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto func_leave;\n\t}\n\n\tout->bv_len = STRLENOF( \"{ serialNumber , issuer rdnSequence:\\\"\\\" }\" )\n\t\t+ sn3.bv_len + ni.bv_len;\n\tout->bv_val = slap_sl_malloc( out->bv_len + 1, ctx );\n\tif ( out->bv_val == NULL ) {\n\t\tout->bv_len = 0;\n\t\trc = LDAP_OTHER;\n\t\tgoto func_leave;\n\t}\n\n\tp = out->bv_val;\n\n\tp = lutil_strcopy( p, \"{ serialNumber \" \/*}*\/ );\n\tp = lutil_strbvcopy( p, &sn3 );\n\tp = lutil_strcopy( p, \", issuer rdnSequence:\\\"\" );\n\tp = lutil_strbvcopy( p, &ni );\n\tp = lutil_strcopy( p, \/*{*\/ \"\\\" }\" );\n\n\tassert( p == &out->bv_val[out->bv_len] );\n\nfunc_leave:\n\tDebug( LDAP_DEBUG_TRACE, \"<<< serialNumberAndIssuerNormalize: <%s> => <%s>\\n\",\n\t\tin->bv_val, rc == LDAP_SUCCESS ? out->bv_val : \"(err)\" );\n\n\tif ( sn2.bv_val != sbuf2 ) {\n\t\tslap_sl_free( sn2.bv_val, ctx );\n\t}\n\n\tif ( sn3.bv_val != sbuf3 ) {\n\t\tslap_sl_free( sn3.bv_val, ctx );\n\t}\n\n\tslap_sl_free( ni.bv_val, ctx );\n\n\treturn rc;\n}","target":0,"code_token_length":671,"total_token_length":907,"max_tokens_setting":1024}
+{"idx":390573,"func":"ProcXkbSetIndicatorMap(ClientPtr client)\n{\n    int                 i, bit;\n    int                 nIndicators;\n    DeviceIntPtr        dev;\n    xkbIndicatorMapWireDesc     *from;\n    int                 rc;\n\n    REQUEST(xkbSetIndicatorMapReq);\n    REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);\n\n    if (stuff->which==0)\n\treturn client->noClientException;\n\n    for (nIndicators=i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {\n\tif (stuff->which&bit)\n\t    nIndicators++;\n    }\n    if (stuff->length!=((SIZEOF(xkbSetIndicatorMapReq)+\n\t\t\t(nIndicators*SIZEOF(xkbIndicatorMapWireDesc)))\/4)) {\n\treturn BadLength;\n    }\n\n    from = (xkbIndicatorMapWireDesc *)&stuff[1];\n    for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {\n\tif (stuff->which&bit) {\n\t    if (client->swapped) {\n\t\tint n;\n\t\tswaps(&from->virtualMods,n);\n\t\tswapl(&from->ctrls,n);\n\t    }\n\t    CHK_MASK_LEGAL(i,from->whichGroups,XkbIM_UseAnyGroup);\n\t    CHK_MASK_LEGAL(i,from->whichMods,XkbIM_UseAnyMods);\n\t    from++;\n\t}\n    }\n\n    from = (xkbIndicatorMapWireDesc *)&stuff[1];\n    rc = _XkbSetIndicatorMap(client, dev, stuff->which, from);\n    if (rc != Success)\n        return rc;\n\n    if (stuff->deviceSpec == XkbUseCoreKbd)\n    {\n        DeviceIntPtr other;\n        for (other = inputInfo.devices; other; other = other->next)\n        {\n            if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))\n            {\n                rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess);\n                if (rc == Success)\n                    _XkbSetIndicatorMap(client, other, stuff->which, from);\n            }\n        }\n    }\n\n    return Success;\n}","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":247609,"func":"TEST_P(SslSocketTest, UpstreamNotReadySslSocket) {\n  Stats::TestUtil::TestStore stats_store;\n  NiceMock<LocalInfo::MockLocalInfo> local_info;\n  testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext> factory_context;\n  NiceMock<Init::MockManager> init_manager;\n  NiceMock<Event::MockDispatcher> dispatcher;\n  EXPECT_CALL(factory_context, localInfo()).WillOnce(ReturnRef(local_info));\n  EXPECT_CALL(factory_context, stats()).WillOnce(ReturnRef(stats_store));\n  EXPECT_CALL(factory_context, initManager()).WillRepeatedly(ReturnRef(init_manager));\n  EXPECT_CALL(factory_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher));\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context;\n  auto sds_secret_configs =\n      tls_context.mutable_common_tls_context()->mutable_tls_certificate_sds_secret_configs()->Add();\n  sds_secret_configs->set_name(\"abc.com\");\n  sds_secret_configs->mutable_sds_config();\n  auto client_cfg = std::make_unique<ClientContextConfigImpl>(tls_context, factory_context);\n  EXPECT_TRUE(client_cfg->tlsCertificates().empty());\n  EXPECT_FALSE(client_cfg->isReady());\n\n  ContextManagerImpl manager(time_system_);\n  ClientSslSocketFactory client_ssl_socket_factory(std::move(client_cfg), manager, stats_store);\n  auto transport_socket = client_ssl_socket_factory.createTransportSocket(nullptr);\n  EXPECT_EQ(EMPTY_STRING, transport_socket->protocol());\n  EXPECT_EQ(nullptr, transport_socket->ssl());\n  EXPECT_EQ(true, transport_socket->canFlushClose());\n  Buffer::OwnedImpl buffer;\n  Network::IoResult result = transport_socket->doRead(buffer);\n  EXPECT_EQ(Network::PostIoAction::Close, result.action_);\n  result = transport_socket->doWrite(buffer, true);\n  EXPECT_EQ(Network::PostIoAction::Close, result.action_);\n  EXPECT_EQ(\"TLS error: Secret is not supplied by SDS\", transport_socket->failureReason());\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":351178,"func":"static void copy_related (const char *inName, const char *outName,\n\t\t\t  const char *old_ext, const char *new_ext)\n{\n  size_t name_len = strlen(inName);\n  const size_t old_len  = strlen(old_ext);\n  const size_t new_len  = strlen(new_ext);\n\n  char *in = malloc(name_len - old_len + new_len + 1);\n  strncpy(in, inName, (name_len - old_len));\n  strcpy(&in[(name_len - old_len)], new_ext);\n  FILE *inFile = fopen(in, \"rb\");\n  if (!inFile) {\n    free(in);\n    return;\n  }\n  name_len = strlen(outName);\n  char *out = malloc(name_len - old_len + new_len + 1);\n  if (!out) {\n    fprintf(stderr, \"%s:%d: couldn't copy related file!\\n\",\n\t    __FILE__, __LINE__);\n    fclose(inFile);\n    free(in);\n    free(out);\n    return;\n  }\n  strncpy(out, outName, (name_len - old_len));\n  strcpy(&out[(name_len - old_len)], new_ext);\n\n  FILE *outFile = fopen(out, \"wb\");\n\n  int c;\n  while ((c = fgetc(inFile)) != EOF) {\n    fputc(c, outFile);\n  }\n  fclose(inFile);\n  fclose(outFile);\n  free(in);\n  free(out);\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":275497,"func":"njs_vm_value(njs_vm_t *vm, const njs_str_t *path, njs_value_t *retval)\n{\n    u_char       *start, *p, *end;\n    size_t       size;\n    njs_int_t    ret;\n    njs_value_t  value, key;\n\n    start = path->start;\n    end = start + path->length;\n\n    njs_set_object(&value, &vm->global_object);\n\n    for ( ;; ) {\n        p = njs_strlchr(start, end, '.');\n\n        size = ((p != NULL) ? p : end) - start;\n        if (njs_slow_path(size == 0)) {\n            njs_type_error(vm, \"empty path element\");\n            return NJS_ERROR;\n        }\n\n        ret = njs_string_set(vm, &key, start, size);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NJS_ERROR;\n        }\n\n        ret = njs_value_property(vm, &value, &key, njs_value_arg(retval));\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (p == NULL) {\n            break;\n        }\n\n        start = p + 1;\n        value = *retval;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":336803,"func":"lprn_bubble_flush(gx_device_printer * pdev, gp_file * fp, Bubble * bbl)\n{\n    gx_device_lprn *const lprn = (gx_device_lprn *) pdev;\n    int i, j, bx;\n    byte *p;\n    int bx0 = bbl->brect.p.x \/ lprn->nBw;\n    int bx1 = (bbl->brect.q.x + lprn->nBw - 1) \/ lprn->nBw;\n    int bpl = gdev_mem_bytes_per_scan_line(pdev);\n    int x = bbl->brect.p.x * 8;\n    int y = bbl->brect.p.y;\n    int width = (bbl->brect.q.x - bbl->brect.p.x + 1) * 8;\n    int height = bbl->brect.q.y - bbl->brect.p.y + 1;\n    int maxY = lprn->BlockLine \/ lprn->nBh * lprn->nBh;\n\n    for (i = 0; i < height; i++) {\n        p = lprn->ImageBuf + ((i + y) % maxY) * bpl;\n        for (j = 0; j < width \/ 8; j++) {\n            if (lprn->NegativePrint)\n                *(lprn->TmpBuf + i * width \/ 8 + j) = ~*(p + j + bbl->brect.p.x);\n            else\n                *(lprn->TmpBuf + i * width \/ 8 + j) = *(p + j + bbl->brect.p.x);\n        }\n    }\n\n    (*lprn->image_out) (pdev, fp, x, y, width, height);\n\n    \/* Initialize bubbleTbl *\/\n    for (bx = bx0; bx <= bx1; bx++) {\n        assert(lprn->bubbleTbl[bx] == bbl);\n        lprn->bubbleTbl[bx] = NULL;\n    }\n\n    bbl->next = lprn->freeBubbleList;\n    lprn->freeBubbleList = bbl;\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":262025,"func":"Proto_DumpRequest(ProtoRequest *req)\n{\n#if VGAUTH_PROTO_TRACE\n   printf(\"raw data: %s\\n\", req->rawData ? req->rawData : \"<none>\");\n#endif\n   Debug(\"complete: %d\\n\", req->complete);\n   Debug(\"sequenceNumber: %d\\n\", req->sequenceNumber);\n   Log(\"requestType: %d(%s REQ)\\n\", req->reqType,\n       ProtoRequestTypeText(req->reqType));\n\n   switch (req->reqType) {\n   case PROTO_REQUEST_SESSION_REQ:\n      Debug(\"version #: %d\\n\", req->reqData.sessionReq.version);\n      Log(\"userName: '%s'\\n\", req->reqData.sessionReq.userName);\n      break;\n   case PROTO_REQUEST_CONN:\n      \/\/ no details\n      break;\n   case PROTO_REQUEST_ADDALIAS:\n      Log(\"userName: %s\\n\", req->reqData.addAlias.userName);\n      Log(\"addMapped: %d\\n\", req->reqData.addAlias.addMapped);\n      Debug(\"pemCert: %s\\n\", req->reqData.addAlias.pemCert);\n      if (req->reqData.addAlias.aliasInfo.type == SUBJECT_TYPE_NAMED) {\n         Log(\"Subject: %s\\n\", req->reqData.addAlias.aliasInfo.name);\n      } else  if (req->reqData.addAlias.aliasInfo.type == SUBJECT_TYPE_ANY) {\n         Log(\"ANY Subject\\n\");\n      } else {\n         Warning(\"*** UNKNOWN Subject type ***\\n\");\n      }\n      Log(\"comment: %s\\n\", req->reqData.addAlias.aliasInfo.comment);\n      break;\n   case PROTO_REQUEST_REMOVEALIAS:\n      Log(\"userName: %s\\n\", req->reqData.removeAlias.userName);\n      Debug(\"pemCert: %s\\n\", req->reqData.removeAlias.pemCert);\n      if (req->reqData.removeAlias.subject.type == SUBJECT_TYPE_NAMED) {\n         Log(\"Subject: %s\\n\", req->reqData.removeAlias.subject.name);\n      } else  if (req->reqData.removeAlias.subject.type == SUBJECT_TYPE_ANY) {\n         Log(\"ANY Subject\\n\");\n      } else {\n         Log(\"No Subject type specified (assuming removeAll case)\\n\");\n      }\n      break;\n   case PROTO_REQUEST_QUERYALIASES:\n      Log(\"userName: %s\\n\", req->reqData.queryAliases.userName);\n      break;\n   case PROTO_REQUEST_QUERYMAPPEDALIASES:\n      \/\/ no details\n      break;\n   case PROTO_REQUEST_CREATETICKET:\n      Log(\"userName '%s'\\n\", req->reqData.createTicket.userName);\n      break;\n   case PROTO_REQUEST_VALIDATETICKET:\n      Log(\"ticket '%s'\\n\", req->reqData.validateTicket.ticket);\n      break;\n   case PROTO_REQUEST_REVOKETICKET:\n      Log(\"ticket '%s'\\n\", req->reqData.revokeTicket.ticket);\n      break;\n   case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:\n      Debug(\"token '%s'\\n\", req->reqData.validateSamlBToken.samlToken);\n      Log(\"username '%s'\\n\", req->reqData.validateSamlBToken.userName);\n      Log(\"validate Only '%s'\\n\",\n            req->reqData.validateSamlBToken.validateOnly ? \"TRUE\" : \"FALSE\");\n      break;\n   default:\n      Warning(\"Unknown request type -- no request specific data\\n\");\n      break;\n   }\n}","target":0,"code_token_length":725,"total_token_length":961,"max_tokens_setting":1024}
+{"idx":513336,"func":"int join_read_key2(THD *thd, JOIN_TAB *tab, TABLE *table, TABLE_REF *table_ref)\n{\n  int error;\n  if (!table->file->inited)\n  {\n    error= table->file->ha_index_init(table_ref->key, tab ? tab->sorted : TRUE);\n    if (error)\n    {\n      (void) report_error(table, error);\n      return 1;\n    }\n  }\n\n  \/*\n    The following is needed when one makes ref (or eq_ref) access from row\n    comparisons: one must call row->bring_value() to get the new values.\n  *\/\n  if (tab && tab->bush_children)\n  {\n    TABLE_LIST *emb_sj_nest= tab->bush_children->start->emb_sj_nest;\n    emb_sj_nest->sj_subq_pred->left_expr->bring_value();\n  }\n\n  \/* TODO: Why don't we do \"Late NULLs Filtering\" here? *\/\n\n  if (cmp_buffer_with_ref(thd, table, table_ref) ||\n      (table->status & (STATUS_GARBAGE | STATUS_NO_PARENT | STATUS_NULL_ROW)))\n  {\n    if (table_ref->key_err)\n    {\n      table->status=STATUS_NOT_FOUND;\n      return -1;\n    }\n    \/*\n      Moving away from the current record. Unlock the row\n      in the handler if it did not match the partial WHERE.\n    *\/\n    if (tab && tab->ref.has_record && tab->ref.use_count == 0)\n    {\n      tab->read_record.table->file->unlock_row();\n      table_ref->has_record= FALSE;\n    }\n    error=table->file->ha_index_read_map(table->record[0],\n                                  table_ref->key_buff,\n                                  make_prev_keypart_map(table_ref->key_parts),\n                                  HA_READ_KEY_EXACT);\n    if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)\n      return report_error(table, error);\n\n    if (! error)\n    {\n      table_ref->has_record= TRUE;\n      table_ref->use_count= 1;\n    }\n  }\n  else if (table->status == 0)\n  {\n    DBUG_ASSERT(table_ref->has_record);\n    table_ref->use_count++;\n  }\n  table->null_row=0;\n  return table->status ? -1 : 0;\n}","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":300823,"func":"static int tipc_setsockopt(struct socket *sock, int lvl, int opt,\n\t\t\t   sockptr_t ov, unsigned int ol)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct tipc_group_req mreq;\n\tu32 value = 0;\n\tint res = 0;\n\n\tif ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))\n\t\treturn 0;\n\tif (lvl != SOL_TIPC)\n\t\treturn -ENOPROTOOPT;\n\n\tswitch (opt) {\n\tcase TIPC_IMPORTANCE:\n\tcase TIPC_SRC_DROPPABLE:\n\tcase TIPC_DEST_DROPPABLE:\n\tcase TIPC_CONN_TIMEOUT:\n\tcase TIPC_NODELAY:\n\t\tif (ol < sizeof(value))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_sockptr(&value, ov, sizeof(u32)))\n\t\t\treturn -EFAULT;\n\t\tbreak;\n\tcase TIPC_GROUP_JOIN:\n\t\tif (ol < sizeof(mreq))\n\t\t\treturn -EINVAL;\n\t\tif (copy_from_sockptr(&mreq, ov, sizeof(mreq)))\n\t\t\treturn -EFAULT;\n\t\tbreak;\n\tdefault:\n\t\tif (!sockptr_is_null(ov) || ol)\n\t\t\treturn -EINVAL;\n\t}\n\n\tlock_sock(sk);\n\n\tswitch (opt) {\n\tcase TIPC_IMPORTANCE:\n\t\tres = tsk_set_importance(sk, value);\n\t\tbreak;\n\tcase TIPC_SRC_DROPPABLE:\n\t\tif (sock->type != SOCK_STREAM)\n\t\t\ttsk_set_unreliable(tsk, value);\n\t\telse\n\t\t\tres = -ENOPROTOOPT;\n\t\tbreak;\n\tcase TIPC_DEST_DROPPABLE:\n\t\ttsk_set_unreturnable(tsk, value);\n\t\tbreak;\n\tcase TIPC_CONN_TIMEOUT:\n\t\ttipc_sk(sk)->conn_timeout = value;\n\t\tbreak;\n\tcase TIPC_MCAST_BROADCAST:\n\t\ttsk->mc_method.rcast = false;\n\t\ttsk->mc_method.mandatory = true;\n\t\tbreak;\n\tcase TIPC_MCAST_REPLICAST:\n\t\ttsk->mc_method.rcast = true;\n\t\ttsk->mc_method.mandatory = true;\n\t\tbreak;\n\tcase TIPC_GROUP_JOIN:\n\t\tres = tipc_sk_join(tsk, &mreq);\n\t\tbreak;\n\tcase TIPC_GROUP_LEAVE:\n\t\tres = tipc_sk_leave(tsk);\n\t\tbreak;\n\tcase TIPC_NODELAY:\n\t\ttsk->nodelay = !!value;\n\t\ttsk_set_nagle(tsk);\n\t\tbreak;\n\tdefault:\n\t\tres = -EINVAL;\n\t}\n\n\trelease_sock(sk);\n\n\treturn res;\n}","target":0,"code_token_length":532,"total_token_length":768,"max_tokens_setting":1024}
+{"idx":225457,"func":"Status MutableGraphView::CheckNodesCanBeDeleted(\n    const absl::flat_hash_set<string>& nodes_to_delete) {\n  std::vector<string> missing_nodes;\n  std::vector<string> nodes_with_fanouts;\n  for (const string& node_name_to_delete : nodes_to_delete) {\n    NodeDef* node = GetNode(node_name_to_delete);\n    if (node == nullptr) {\n      \/\/ Can't delete missing node.\n      missing_nodes.push_back(node_name_to_delete);\n      continue;\n    }\n    const int max_port = gtl::FindWithDefault(max_regular_output_port(), node,\n                                              Graph::kControlSlot);\n    for (int i = Graph::kControlSlot; i <= max_port; ++i) {\n      auto it = fanouts().find({node, i});\n      bool has_retained_fanout = false;\n      if (it != fanouts().end()) {\n        for (const auto& fanout : it->second) {\n          \/\/ Check if fanouts are of nodes to be deleted, and if so, they can be\n          \/\/ ignored, as they will be removed also.\n          if (!nodes_to_delete.contains(fanout.node->name())) {\n            \/\/ Removing node will leave graph in an invalid state.\n            has_retained_fanout = true;\n            break;\n          }\n        }\n      }\n      if (has_retained_fanout) {\n        nodes_with_fanouts.push_back(node_name_to_delete);\n        break;\n      }\n    }\n  }\n\n  \/\/ Error message can get quite long, so we only show the first 5 node names.\n  auto sort_and_sample = [](std::vector<string>* s) {\n    constexpr int kMaxNodeNames = 5;\n    std::sort(s->begin(), s->end());\n    if (s->size() > kMaxNodeNames) {\n      return absl::StrCat(\n          absl::StrJoin(s->begin(), s->begin() + kMaxNodeNames, \", \"), \", ...\");\n    }\n    return absl::StrJoin(*s, \", \");\n  };\n\n  if (!missing_nodes.empty()) {\n    VLOG(2) << absl::Substitute(\"Attempting to delete missing node(s) [$0].\",\n                                sort_and_sample(&missing_nodes));\n  }\n  if (!nodes_with_fanouts.empty()) {\n    std::vector<string> input_node_names(nodes_to_delete.begin(),\n                                         nodes_to_delete.end());\n    string params = absl::Substitute(\"nodes_to_delete={$0}\",\n                                     sort_and_sample(&input_node_names));\n    string error_msg =\n        absl::Substitute(\"can't delete node(s) with retained fanouts(s) [$0]\",\n                         sort_and_sample(&nodes_with_fanouts));\n    return MutationError(\"DeleteNodes\", params, error_msg);\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":313806,"func":"add_to_showcmd(int c)\n{\n    char_u\t*p;\n    int\t\told_len;\n    int\t\textra_len;\n    int\t\toverflow;\n    int\t\ti;\n    static int\tignore[] =\n    {\n#ifdef FEAT_GUI\n\tK_VER_SCROLLBAR, K_HOR_SCROLLBAR,\n\tK_LEFTMOUSE_NM, K_LEFTRELEASE_NM,\n#endif\n\tK_IGNORE, K_PS,\n\tK_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE,\n\tK_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE,\n\tK_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE,\n\tK_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT,\n\tK_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE,\n\tK_CURSORHOLD,\n\t0\n    };\n\n    if (!p_sc || msg_silent != 0)\n\treturn FALSE;\n\n    if (showcmd_visual)\n    {\n\tshowcmd_buf[0] = NUL;\n\tshowcmd_visual = FALSE;\n    }\n\n    \/\/ Ignore keys that are scrollbar updates and mouse clicks\n    if (IS_SPECIAL(c))\n\tfor (i = 0; ignore[i] != 0; ++i)\n\t    if (ignore[i] == c)\n\t\treturn FALSE;\n\n    p = transchar(c);\n    if (*p == ' ')\n\tSTRCPY(p, \"<20>\");\n    old_len = (int)STRLEN(showcmd_buf);\n    extra_len = (int)STRLEN(p);\n    overflow = old_len + extra_len - SHOWCMD_COLS;\n    if (overflow > 0)\n\tmch_memmove(showcmd_buf, showcmd_buf + overflow,\n\t\t\t\t\t\t      old_len - overflow + 1);\n    STRCAT(showcmd_buf, p);\n\n    if (char_avail())\n\treturn FALSE;\n\n    display_showcmd();\n\n    return TRUE;\n}","target":0,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":317167,"func":"static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,\n\t\t\t\tint addrlen)\n{\n\tint rc = 0;\n\n\tif (sock->sk == NULL)\n\t\treturn 0;\n\tif (sock->sk->sk_family != PF_INET &&\n\t    (!IS_ENABLED(CONFIG_IPV6) || sock->sk->sk_family != PF_INET6))\n\t\treturn 0;\n\tif (addrlen < offsetofend(struct sockaddr, sa_family))\n\t\treturn 0;\n\tif (IS_ENABLED(CONFIG_IPV6) && sap->sa_family == AF_INET6) {\n\t\tstruct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;\n\t\tstruct smack_known *rsp = NULL;\n\n\t\tif (addrlen < SIN6_LEN_RFC2133)\n\t\t\treturn 0;\n\t\tif (__is_defined(SMACK_IPV6_SECMARK_LABELING))\n\t\t\trsp = smack_ipv6host_label(sip);\n\t\tif (rsp != NULL) {\n\t\t\tstruct socket_smack *ssp = sock->sk->sk_security;\n\n\t\t\trc = smk_ipv6_check(ssp->smk_out, rsp, sip,\n\t\t\t\t\t    SMK_CONNECTING);\n\t\t}\n\t\tif (__is_defined(SMACK_IPV6_PORT_LABELING))\n\t\t\trc = smk_ipv6_port_check(sock->sk, sip, SMK_CONNECTING);\n\n\t\treturn rc;\n\t}\n\tif (sap->sa_family != AF_INET || addrlen < sizeof(struct sockaddr_in))\n\t\treturn 0;\n\trc = smk_ipv4_check(sock->sk, (struct sockaddr_in *)sap);\n\treturn rc;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":195752,"func":"  void MakeDataset(OpKernelContext* ctx, DatasetBase** output) override {\n    \/\/ Create a new SparseTensorSliceDatasetOp::Dataset, insert it in\n    \/\/ the step container, and return it as the output.\n    const Tensor* indices;\n    OP_REQUIRES_OK(ctx, ctx->input(\"indices\", &indices));\n    const Tensor* values;\n    OP_REQUIRES_OK(ctx, ctx->input(\"values\", &values));\n    const Tensor* dense_shape;\n    OP_REQUIRES_OK(ctx, ctx->input(\"dense_shape\", &dense_shape));\n\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices->shape()),\n                errors::InvalidArgument(\n                    \"Input indices should be a matrix but received shape \",\n                    indices->shape().DebugString()));\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(values->shape()),\n                errors::InvalidArgument(\n                    \"Input values should be a vector but received shape \",\n                    indices->shape().DebugString()));\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(dense_shape->shape()),\n                errors::InvalidArgument(\n                    \"Input shape should be a vector but received shape \",\n                    dense_shape->shape().DebugString()));\n\n    \/\/ We currently ensure that `sparse_tensor` is ordered in the\n    \/\/ batch dimension.\n    \/\/ TODO(mrry): Investigate ways to avoid this unconditional check\n    \/\/ if we can be sure that the sparse tensor was produced in an\n    \/\/ appropriate order (e.g. by `tf.parse_example()` or a Dataset\n    \/\/ that batches elements into rows of a SparseTensor).\n    int64_t previous_batch_index = -1;\n    for (int64_t i = 0; i < indices->dim_size(0); ++i) {\n      int64_t next_batch_index = indices->matrix<int64>()(i, 0);\n      OP_REQUIRES(\n          ctx, next_batch_index >= previous_batch_index,\n          errors::Unimplemented(\"The SparseTensor must be ordered in the batch \"\n                                \"dimension; handling arbitrarily ordered input \"\n                                \"is not currently supported.\"));\n      previous_batch_index = next_batch_index;\n    }\n    gtl::InlinedVector<int64, 8> std_order(dense_shape->NumElements(), 0);\n    sparse::SparseTensor tensor;\n    OP_REQUIRES_OK(\n        ctx, sparse::SparseTensor::Create(\n                 *indices, *values, TensorShape(dense_shape->vec<int64>()),\n                 std_order, &tensor));\n    *output = new Dataset<T>(ctx, std::move(tensor));\n  }","target":1,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":238377,"func":"njs_function_prototype_call(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    njs_int_t           ret;\n    njs_function_t      *function;\n    const njs_value_t   *this;\n    njs_native_frame_t  *frame;\n\n    if (!njs_is_function(&args[0])) {\n        njs_type_error(vm, \"\\\"this\\\" argument is not a function\");\n        return NJS_ERROR;\n    }\n\n    if (nargs > 1) {\n        this = &args[1];\n        nargs -= 2;\n\n    } else {\n        this = (njs_value_t *) &njs_value_undefined;\n        nargs = 0;\n    }\n\n    frame = vm->top_frame;\n\n    \/* Skip the \"call\" method frame. *\/\n    frame->skip = 1;\n\n    function = njs_function(&args[0]);\n\n    ret = njs_function_frame(vm, function, this, &args[2], nargs, 0);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_function_frame_invoke(vm, frame->retval);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    return NJS_DECLINED;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":252284,"func":"static void WriteChannelInfo(std::vector<unsigned char> &data,\n                             const std::vector<ChannelInfo> &channels) {\n  size_t sz = 0;\n\n  \/\/ Calculate total size.\n  for (size_t c = 0; c < channels.size(); c++) {\n    sz += strlen(channels[c].name.c_str()) + 1;  \/\/ +1 for \\0\n    sz += 16;                                    \/\/ 4 * int\n  }\n  data.resize(sz + 1);\n\n  unsigned char *p = &data.at(0);\n\n  for (size_t c = 0; c < channels.size(); c++) {\n    memcpy(p, channels[c].name.c_str(), strlen(channels[c].name.c_str()));\n    p += strlen(channels[c].name.c_str());\n    (*p) = '\\0';\n    p++;\n\n    int pixel_type = channels[c].pixel_type;\n    int x_sampling = channels[c].x_sampling;\n    int y_sampling = channels[c].y_sampling;\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&pixel_type));\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&x_sampling));\n    tinyexr::swap4(reinterpret_cast<unsigned int *>(&y_sampling));\n\n    memcpy(p, &pixel_type, sizeof(int));\n    p += sizeof(int);\n\n    (*p) = channels[c].p_linear;\n    p += 4;\n\n    memcpy(p, &x_sampling, sizeof(int));\n    p += sizeof(int);\n\n    memcpy(p, &y_sampling, sizeof(int));\n    p += sizeof(int);\n  }\n\n  (*p) = '\\0';\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":197247,"func":"Status ShapeRefiner::InferShapesForFunctionSubNode(\n    const Node* node, InferenceContext* outer_context) {\n  TF_RETURN_IF_ERROR(AddNodeInternal(node, outer_context));\n  InferenceContext* node_context = CHECK_NOTNULL(GetContext(node));\n\n  if (StringPiece(node->type_string()) == kArgOp) {\n    \/\/ Handle special node: function input.\n    \/\/ Shapes for these nodes are provided in the outer inference\n    \/\/ context.\n\n    int index;\n    TF_RETURN_IF_ERROR(GetNodeAttr(AttrSlice(node->def()), \"index\", &index));\n\n    if (index < 0 || outer_context->num_inputs() <= index) {\n      return errors::Internal(\n          \"Function instantiation included invalid input index: \", index,\n          \" not in [0, \", outer_context->num_inputs(), \").\");\n    }\n\n    \/\/ TODO(b\/134547156): TEMPORARY WORKAROUND. If input shape handle is not set\n    \/\/ in outer context, set _Arg node output shape to unknown.\n    if (outer_context->input(index).SameHandle(ShapeHandle())) {\n      VLOG(1) << \"Function instantiation has undefined input shape at \"\n              << \"index: \" << index << \" in the outer inference context.\";\n      node_context->set_output(0, node_context->UnknownShape());\n    } else {\n      node_context->set_output(0, outer_context->input(index));\n    }\n\n    auto* resource = outer_context->input_handle_shapes_and_types(index);\n    if (resource) {\n      node_context->set_output_handle_shapes_and_types(0, *resource);\n    }\n  } else if (StringPiece(node->type_string()) == kRetvalOp) {\n    \/\/ Handle special node: function output.\n    \/\/ Shapes inferred for these nodes go into the outer inference\n    \/\/ context.\n\n    int index;\n    TF_RETURN_IF_ERROR(GetNodeAttr(AttrSlice(node->def()), \"index\", &index));\n\n    if (index < 0 || outer_context->num_outputs() <= index) {\n      return errors::Internal(\n          \"Function instantiation included invalid output index: \", index,\n          \" not in [0, \", outer_context->num_outputs(), \").\");\n    }\n\n    \/\/ outer_context outlives node_context, therefore we need to create\n    \/\/ a new shape handle owned by outer_context instead.\n    ShapeHandle handle;\n    TensorShapeProto proto;\n    node_context->ShapeHandleToProto(node_context->input(0), &proto);\n    TF_RETURN_IF_ERROR(outer_context->MakeShapeFromShapeProto(proto, &handle));\n    outer_context->set_output(index, handle);\n\n    auto* resource = node_context->input_handle_shapes_and_types(0);\n    if (resource) {\n      outer_context->set_output_handle_shapes_and_types(index, *resource);\n    }\n  }\n\n  return Status::OK();\n}","target":1,"code_token_length":603,"total_token_length":839,"max_tokens_setting":1024}
+{"idx":238403,"func":"njs_function_capture_global_closures(njs_vm_t *vm, njs_function_t *function)\n{\n    void                   *start, *end;\n    uint32_t               n;\n    njs_value_t            *value, **refs, **global;\n    njs_index_t            *indexes, index;\n    njs_native_frame_t     *native;\n    njs_function_lambda_t  *lambda;\n\n    lambda = function->u.lambda;\n\n    if (lambda->nclosures == 0) {\n        return NJS_OK;\n    }\n\n    native = vm->top_frame;\n\n    while (native->previous->function != NULL) {\n        native = native->previous;\n    }\n\n    start = native;\n    end = native->free;\n\n    indexes = lambda->closures;\n    refs = njs_function_closures(function);\n\n    global = vm->levels[NJS_LEVEL_GLOBAL];\n\n    n = lambda->nclosures;\n\n    while (n > 0) {\n        n--;\n\n        index = indexes[n];\n\n        switch (njs_scope_index_type(index)) {\n        case NJS_LEVEL_LOCAL:\n            value = njs_function_closure_value(vm, native->local, index,\n                                               start, end);\n            break;\n\n        case NJS_LEVEL_GLOBAL:\n            value = njs_function_closure_value(vm, global, index, start, end);\n            break;\n\n        default:\n            njs_type_error(vm, \"unexpected value type for closure \\\"%uD\\\"\",\n                           njs_scope_index_type(index));\n            return NJS_ERROR;\n        }\n\n        if (njs_slow_path(value == NULL)) {\n            return NJS_ERROR;\n        }\n\n        refs[n] = value;\n    }\n\n    function->closure_copied = 1;\n\n    return NJS_OK;\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":437708,"func":"int cx23888_ir_probe(struct cx23885_dev *dev)\n{\n\tstruct cx23888_ir_state *state;\n\tstruct v4l2_subdev *sd;\n\tstruct v4l2_subdev_ir_parameters default_params;\n\tint ret;\n\n\tstate = kzalloc(sizeof(struct cx23888_ir_state), GFP_KERNEL);\n\tif (state == NULL)\n\t\treturn -ENOMEM;\n\n\tspin_lock_init(&state->rx_kfifo_lock);\n\tif (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE,\n\t\t\tGFP_KERNEL)) {\n\t\tkfree(state);\n\t\treturn -ENOMEM;\n\t}\n\n\tstate->dev = dev;\n\tsd = &state->sd;\n\n\tv4l2_subdev_init(sd, &cx23888_ir_controller_ops);\n\tv4l2_set_subdevdata(sd, state);\n\t\/* FIXME - fix the formatting of dev->v4l2_dev.name and use it *\/\n\tsnprintf(sd->name, sizeof(sd->name), \"%s\/888-ir\", dev->name);\n\tsd->grp_id = CX23885_HW_888_IR;\n\n\tret = v4l2_device_register_subdev(&dev->v4l2_dev, sd);\n\tif (ret == 0) {\n\t\t\/*\n\t\t * Ensure no interrupts arrive from '888 specific conditions,\n\t\t * since we ignore them in this driver to have commonality with\n\t\t * similar IR controller cores.\n\t\t *\/\n\t\tcx23888_ir_write4(dev, CX23888_IR_IRQEN_REG, 0);\n\n\t\tmutex_init(&state->rx_params_lock);\n\t\tdefault_params = default_rx_params;\n\t\tv4l2_subdev_call(sd, ir, rx_s_parameters, &default_params);\n\n\t\tmutex_init(&state->tx_params_lock);\n\t\tdefault_params = default_tx_params;\n\t\tv4l2_subdev_call(sd, ir, tx_s_parameters, &default_params);\n\t} else {\n\t\tkfifo_free(&state->rx_kfifo);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":275526,"func":"njs_vm_object_alloc(njs_vm_t *vm, njs_value_t *retval, ...)\n{\n    va_list             args;\n    njs_int_t           ret;\n    njs_value_t         *name, *value;\n    njs_object_t        *object;\n    njs_object_prop_t   *prop;\n    njs_lvlhsh_query_t  lhq;\n\n    object = njs_object_alloc(vm);\n    if (njs_slow_path(object == NULL)) {\n        return NJS_ERROR;\n    }\n\n    ret = NJS_ERROR;\n\n    va_start(args, retval);\n\n    for ( ;; ) {\n        name = va_arg(args, njs_value_t *);\n        if (name == NULL) {\n            break;\n        }\n\n        value = va_arg(args, njs_value_t *);\n        if (value == NULL) {\n            njs_type_error(vm, \"missed value for a key\");\n            goto done;\n        }\n\n        if (njs_slow_path(!njs_is_string(name))) {\n            njs_type_error(vm, \"prop name is not a string\");\n            goto done;\n        }\n\n        lhq.replace = 0;\n        lhq.pool = vm->mem_pool;\n        lhq.proto = &njs_object_hash_proto;\n\n        njs_string_get(name, &lhq.key);\n        lhq.key_hash = njs_djb_hash(lhq.key.start, lhq.key.length);\n\n        prop = njs_object_prop_alloc(vm, name, value, 1);\n        if (njs_slow_path(prop == NULL)) {\n            goto done;\n        }\n\n        lhq.value = prop;\n\n        ret = njs_lvlhsh_insert(&object->hash, &lhq);\n        if (njs_slow_path(ret != NJS_OK)) {\n            njs_internal_error(vm, NULL);\n            goto done;\n        }\n    }\n\n    ret = NJS_OK;\n\n    njs_set_object(retval, object);\n\ndone:\n\n    va_end(args);\n\n    return ret;\n}","target":0,"code_token_length":411,"total_token_length":647,"max_tokens_setting":1024}
+{"idx":482550,"func":"passFindCharacters(const FileInfo *file, widechar *instructions, int end,\n\t\twidechar **characters, int *length) {\n\tint IC = 0;\n\tint lookback = 0;\n\n\t*characters = NULL;\n\t*length = 0;\n\n\twhile (IC < end) {\n\t\twidechar instruction = instructions[IC];\n\n\t\tswitch (instruction) {\n\t\tcase pass_string:\n\t\tcase pass_dots: {\n\t\t\tint count = instructions[IC + 1];\n\t\t\tIC += 2;\n\t\t\tif (count > lookback) {\n\t\t\t\t*characters = &instructions[IC + lookback];\n\t\t\t\t*length = count - lookback;\n\t\t\t\treturn 1;\n\t\t\t} else {\n\t\t\t\tlookback -= count;\n\t\t\t}\n\t\t\tIC += count;\n\t\t\tcontinue;\n\t\t}\n\n\t\tcase pass_attributes:\n\t\t\tIC += 7;\n\t\t\tif (instructions[IC - 2] == instructions[IC - 1] &&\n\t\t\t\t\tinstructions[IC - 1] <= lookback) {\n\t\t\t\tlookback -= instructions[IC - 1];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tgoto NO_CHARACTERS;\n\n\t\tcase pass_swap:\n\t\t\tIC += 2;\n\t\t\t\/* fall through *\/\n\n\t\tcase pass_groupstart:\n\t\tcase pass_groupend:\n\t\tcase pass_groupreplace:\n\t\t\tIC += 3;\n\n\t\tNO_CHARACTERS : { return 1; }\n\n\t\tcase pass_eq:\n\t\tcase pass_lt:\n\t\tcase pass_gt:\n\t\tcase pass_lteq:\n\t\tcase pass_gteq:\n\t\t\tIC += 3;\n\t\t\tcontinue;\n\n\t\tcase pass_lookback:\n\t\t\tlookback += instructions[IC + 1];\n\t\t\tIC += 2;\n\t\t\tcontinue;\n\n\t\tcase pass_not:\n\t\tcase pass_startReplace:\n\t\tcase pass_endReplace:\n\t\tcase pass_first:\n\t\tcase pass_last:\n\t\tcase pass_copy:\n\t\tcase pass_omit:\n\t\tcase pass_plus:\n\t\tcase pass_hyphen:\n\t\t\tIC += 1;\n\t\t\tcontinue;\n\n\t\tcase pass_endTest:\n\t\t\tgoto NO_CHARACTERS;\n\n\t\tdefault:\n\t\t\tcompileError(file, \"unhandled test suboperand: \\\\x%02x\", instruction);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tgoto NO_CHARACTERS;\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":343286,"func":"static int dlmap_init(DLHandler * const dlhandler, const int clientfd,\n                      void * const tls_clientfd, const int xferfd,\n                      const char * const name, const int f,\n                      void * const tls_fd, const off_t restartat,\n                      const int ascii_mode, const unsigned long bandwidth)\n{\n    if (ascii_mode > 0) {\n#ifdef WITHOUT_ASCII\n        addreply_noformat(450, MSG_ASCII_MODE_UNSUPPORTED);\n        return -1;\n#else\n        addreply_noformat(0, MSG_ASCII_MODE_WARNING);\n#endif\n    }\n    if (dlhandler_init(dlhandler, clientfd, tls_clientfd, xferfd, name, f,\n                       tls_fd, restartat, ascii_mode, bandwidth) != 0) {\n        return -1;\n    }\n    dlhandler->min_chunk_size = DL_MIN_CHUNK_SIZE;\n    if (ascii_mode > 0) {\n        dlhandler->default_chunk_size = dlhandler->max_chunk_size =\n            DL_DEFAULT_CHUNK_SIZE_ASCII;\n    } else {\n        dlhandler->max_chunk_size = DL_MAX_CHUNK_SIZE;\n        if (bandwidth <= 0UL) {\n            dlhandler->default_chunk_size = dlhandler->max_chunk_size;\n        } else {\n            dlhandler->default_chunk_size = DL_DEFAULT_CHUNK_SIZE;\n        }\n    }\n    dlhandler->chunk_size = dlhandler->default_chunk_size;\n    dlhandler->dlmap_size =\n        (DL_DLMAP_SIZE + page_size - (size_t) 1U) & ~(page_size - (size_t) 1U);\n    dlhandler->cur_pos = restartat;\n    dlhandler->dlmap_pos = (off_t) 0;\n    dlhandler->dlmap_fdpos = (off_t) -1;\n    dlhandler->sizeof_map = (size_t) 0U;\n    dlhandler->map_data = NULL;\n    dlhandler->sizeof_map = dlhandler->dlmap_size;\n    dlhandler->map = malloc(dlhandler->sizeof_map);\n    if (dlhandler->map == NULL) {\n        die_mem();\n    }\n    return 0;\n}","target":0,"code_token_length":447,"total_token_length":683,"max_tokens_setting":1024}
+{"idx":338156,"func":"void WasmBinaryBuilder::pushExpression(Expression* curr) {\n  auto type = curr->type;\n  if (type.isTuple()) {\n    \/\/ Store tuple to local and push individual extracted values\n    Builder builder(wasm);\n    \/\/ Non-nullable types require special handling as they cannot be stored to\n    \/\/ a local.\n    std::vector<Type> finalTypes;\n    if (!wasm.features.hasGCNNLocals()) {\n      for (auto t : type) {\n        if (t.isNonNullable()) {\n          t = Type(t.getHeapType(), Nullable);\n        }\n        finalTypes.push_back(t);\n      }\n    }\n    auto nullableType = Type(Tuple(finalTypes));\n    requireFunctionContext(\"pushExpression-tuple\");\n    Index tuple = builder.addVar(currFunction, nullableType);\n    expressionStack.push_back(builder.makeLocalSet(tuple, curr));\n    for (Index i = 0; i < nullableType.size(); ++i) {\n      Expression* value =\n        builder.makeTupleExtract(builder.makeLocalGet(tuple, nullableType), i);\n      if (nullableType[i] != type[i]) {\n        \/\/ We modified this to be nullable; undo that.\n        value = builder.makeRefAs(RefAsNonNull, value);\n      }\n      expressionStack.push_back(value);\n    }\n  } else {\n    expressionStack.push_back(curr);\n  }\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":432283,"func":"static MemoryRegionSection memory_region_find_rcu(MemoryRegion *mr,\n                                                  hwaddr addr, uint64_t size)\n{\n    MemoryRegionSection ret = { .mr = NULL };\n    MemoryRegion *root;\n    AddressSpace *as;\n    AddrRange range;\n    FlatView *view;\n    FlatRange *fr;\n\n    addr += mr->addr;\n    for (root = mr; root->container; ) {\n        root = root->container;\n        addr += root->addr;\n    }\n\n    as = memory_region_to_address_space(root);\n    if (!as) {\n        return ret;\n    }\n    range = addrrange_make(int128_make64(addr), int128_make64(size));\n\n    view = address_space_to_flatview(as);\n    fr = flatview_lookup(view, range);\n    if (!fr) {\n        return ret;\n    }\n\n    while (fr > view->ranges && addrrange_intersects(fr[-1].addr, range)) {\n        --fr;\n    }\n\n    ret.mr = fr->mr;\n    ret.fv = view;\n    range = addrrange_intersection(range, fr->addr);\n    ret.offset_within_region = fr->offset_in_region;\n    ret.offset_within_region += int128_get64(int128_sub(range.start,\n                                                        fr->addr.start));\n    ret.size = range.size;\n    ret.offset_within_address_space = int128_get64(range.start);\n    ret.readonly = fr->readonly;\n    return ret;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":198662,"func":"ex_copy(linenr_T line1, linenr_T line2, linenr_T n)\n{\n    linenr_T\tcount;\n    char_u\t*p;\n\n    count = line2 - line1 + 1;\n    if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)\n    {\n\tcurbuf->b_op_start.lnum = n + 1;\n\tcurbuf->b_op_end.lnum = n + count;\n\tcurbuf->b_op_start.col = curbuf->b_op_end.col = 0;\n    }\n\n    \/*\n     * there are three situations:\n     * 1. destination is above line1\n     * 2. destination is between line1 and line2\n     * 3. destination is below line2\n     *\n     * n = destination (when starting)\n     * curwin->w_cursor.lnum = destination (while copying)\n     * line1 = start of source (while copying)\n     * line2 = end of source (while copying)\n     *\/\n    if (u_save(n, n + 1) == FAIL)\n\treturn;\n\n    curwin->w_cursor.lnum = n;\n    while (line1 <= line2)\n    {\n\t\/\/ need to use vim_strsave() because the line will be unlocked within\n\t\/\/ ml_append()\n\tp = vim_strsave(ml_get(line1));\n\tif (p != NULL)\n\t{\n\t    ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE);\n\t    vim_free(p);\n\t}\n\t\/\/ situation 2: skip already copied lines\n\tif (line1 == n)\n\t    line1 = curwin->w_cursor.lnum;\n\t++line1;\n\tif (curwin->w_cursor.lnum < line1)\n\t    ++line1;\n\tif (curwin->w_cursor.lnum < line2)\n\t    ++line2;\n\t++curwin->w_cursor.lnum;\n    }\n\n    appended_lines_mark(n, count);\n\n    msgmore((long)count);\n}","target":1,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":366257,"func":"static void umount_tree(struct mount *mnt, enum umount_tree_flags how)\n{\n\tLIST_HEAD(tmp_list);\n\tstruct mount *p;\n\n\tif (how & UMOUNT_PROPAGATE)\n\t\tpropagate_mount_unlock(mnt);\n\n\t\/* Gather the mounts to umount *\/\n\tfor (p = mnt; p; p = next_mnt(p, mnt)) {\n\t\tp->mnt.mnt_flags |= MNT_UMOUNT;\n\t\tlist_move(&p->mnt_list, &tmp_list);\n\t}\n\n\t\/* Hide the mounts from mnt_mounts *\/\n\tlist_for_each_entry(p, &tmp_list, mnt_list) {\n\t\tlist_del_init(&p->mnt_child);\n\t}\n\n\t\/* Add propogated mounts to the tmp_list *\/\n\tif (how & UMOUNT_PROPAGATE)\n\t\tpropagate_umount(&tmp_list);\n\n\twhile (!list_empty(&tmp_list)) {\n\t\tstruct mnt_namespace *ns;\n\t\tbool disconnect;\n\t\tp = list_first_entry(&tmp_list, struct mount, mnt_list);\n\t\tlist_del_init(&p->mnt_expire);\n\t\tlist_del_init(&p->mnt_list);\n\t\tns = p->mnt_ns;\n\t\tif (ns) {\n\t\t\tns->mounts--;\n\t\t\t__touch_mnt_namespace(ns);\n\t\t}\n\t\tp->mnt_ns = NULL;\n\t\tif (how & UMOUNT_SYNC)\n\t\t\tp->mnt.mnt_flags |= MNT_SYNC_UMOUNT;\n\n\t\tdisconnect = disconnect_mount(p, how);\n\t\tif (mnt_has_parent(p)) {\n\t\t\tmnt_add_count(p->mnt_parent, -1);\n\t\t\tif (!disconnect) {\n\t\t\t\t\/* Don't forget about p *\/\n\t\t\t\tlist_add_tail(&p->mnt_child, &p->mnt_parent->mnt_mounts);\n\t\t\t} else {\n\t\t\t\tumount_mnt(p);\n\t\t\t}\n\t\t}\n\t\tchange_mnt_propagation(p, MS_PRIVATE);\n\t\tif (disconnect)\n\t\t\thlist_add_head(&p->mnt_umount, &unmounted);\n\t}\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":383370,"func":"gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)\n{\n  gdPoint pts[3];\n  int i;\n  int lx = 0, ly = 0;\n  int fx = 0, fy = 0;\n  int w2, h2;\n  w2 = w \/ 2;\n  h2 = h \/ 2;\n  while (e < s)\n    {\n      e += 360;\n    }\n  for (i = s; (i <= e); i++)\n    {\n      int x, y;\n      x = ((long) gdCosT[i % 360] * (long) w2 \/ 1024) + cx;\n      y = ((long) gdSinT[i % 360] * (long) h2 \/ 1024) + cy;\n      if (i != s)\n\t{\n\t  if (!(style & gdChord))\n\t    {\n\t      if (style & gdNoFill)\n\t\t{\n\t\t  gdImageLine (im, lx, ly, x, y, color);\n\t\t}\n\t      else\n\t\t{\n\t\t  \/* This is expensive! *\/\n\t\t  pts[0].x = lx;\n\t\t  pts[0].y = ly;\n\t\t  pts[1].x = x;\n\t\t  pts[1].y = y;\n\t\t  pts[2].x = cx;\n\t\t  pts[2].y = cy;\n\t\t  gdImageFilledPolygon (im, pts, 3, color);\n\t\t}\n\t    }\n\t}\n      else\n\t{\n\t  fx = x;\n\t  fy = y;\n\t}\n      lx = x;\n      ly = y;\n    }\n  if (style & gdChord)\n    {\n      if (style & gdNoFill)\n\t{\n\t  if (style & gdEdged)\n\t    {\n\t      gdImageLine (im, cx, cy, lx, ly, color);\n\t      gdImageLine (im, cx, cy, fx, fy, color);\n\t    }\n\t  gdImageLine (im, fx, fy, lx, ly, color);\n\t}\n      else\n\t{\n\t  pts[0].x = fx;\n\t  pts[0].y = fy;\n\t  pts[1].x = lx;\n\t  pts[1].y = ly;\n\t  pts[2].x = cx;\n\t  pts[2].y = cy;\n\t  gdImageFilledPolygon (im, pts, 3, color);\n\t}\n    }\n  else\n    {\n      if (style & gdNoFill)\n\t{\n\t  if (style & gdEdged)\n\t    {\n\t      gdImageLine (im, cx, cy, lx, ly, color);\n\t      gdImageLine (im, cx, cy, fx, fy, color);\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":605,"total_token_length":841,"max_tokens_setting":1024}
+{"idx":333064,"func":"nfa_regcomp(char_u *expr, int re_flags)\n{\n    nfa_regprog_T\t*prog = NULL;\n    size_t\t\tprog_size;\n    int\t\t\t*postfix;\n\n    if (expr == NULL)\n\treturn NULL;\n\n#ifdef DEBUG\n    nfa_regengine.expr = expr;\n#endif\n    nfa_re_flags = re_flags;\n\n    init_class_tab();\n\n    if (nfa_regcomp_start(expr, re_flags) == FAIL)\n\treturn NULL;\n\n    \/\/ Build postfix form of the regexp. Needed to build the NFA\n    \/\/ (and count its size).\n    postfix = re2post();\n    if (postfix == NULL)\n\tgoto fail;\t    \/\/ Cascaded (syntax?) error\n\n    \/*\n     * In order to build the NFA, we parse the input regexp twice:\n     * 1. first pass to count size (so we can allocate space)\n     * 2. second to emit code\n     *\/\n#ifdef ENABLE_LOG\n    {\n\tFILE *f = fopen(NFA_REGEXP_RUN_LOG, \"a\");\n\n\tif (f != NULL)\n\t{\n\t    fprintf(f, \"\\n*****************************\\n\\n\\n\\n\\tCompiling regexp \\\"%s\\\"... hold on !\\n\", expr);\n\t    fclose(f);\n\t}\n    }\n#endif\n\n    \/*\n     * PASS 1\n     * Count number of NFA states in \"nstate\". Do not build the NFA.\n     *\/\n    post2nfa(postfix, post_ptr, TRUE);\n\n    \/\/ allocate the regprog with space for the compiled regexp\n    prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1);\n    prog = alloc(prog_size);\n    if (prog == NULL)\n\tgoto fail;\n    state_ptr = prog->state;\n    prog->re_in_use = FALSE;\n\n    \/*\n     * PASS 2\n     * Build the NFA\n     *\/\n    prog->start = post2nfa(postfix, post_ptr, FALSE);\n    if (prog->start == NULL)\n\tgoto fail;\n\n    prog->regflags = regflags;\n    prog->engine = &nfa_regengine;\n    prog->nstate = nstate;\n    prog->has_zend = rex.nfa_has_zend;\n    prog->has_backref = rex.nfa_has_backref;\n    prog->nsubexp = regnpar;\n\n    nfa_postprocess(prog);\n\n    prog->reganch = nfa_get_reganch(prog->start, 0);\n    prog->regstart = nfa_get_regstart(prog->start, 0);\n    prog->match_text = nfa_get_match_text(prog->start);\n\n#ifdef ENABLE_LOG\n    nfa_postfix_dump(expr, OK);\n    nfa_dump(prog);\n#endif\n#ifdef FEAT_SYN_HL\n    \/\/ Remember whether this pattern has any \\z specials in it.\n    prog->reghasz = re_has_z;\n#endif\n    prog->pattern = vim_strsave(expr);\n#ifdef DEBUG\n    nfa_regengine.expr = NULL;\n#endif\n\nout:\n    VIM_CLEAR(post_start);\n    post_ptr = post_end = NULL;\n    state_ptr = NULL;\n    return (regprog_T *)prog;\n\nfail:\n    VIM_CLEAR(prog);\n#ifdef ENABLE_LOG\n    nfa_postfix_dump(expr, FAIL);\n#endif\n#ifdef DEBUG\n    nfa_regengine.expr = NULL;\n#endif\n    goto out;\n}","target":0,"code_token_length":710,"total_token_length":946,"max_tokens_setting":1024}
+{"idx":196893,"func":"void DefaultCertValidator::updateDigestForSessionId(bssl::ScopedEVP_MD_CTX& md,\n                                                    uint8_t hash_buffer[EVP_MAX_MD_SIZE],\n                                                    unsigned hash_length) {\n  int rc;\n\n  \/\/ Hash all the settings that affect whether the server will allow\/accept\n  \/\/ the client connection. This ensures that the client is always validated against\n  \/\/ the correct settings, even if session resumption across different listeners\n  \/\/ is enabled.\n  if (ca_cert_ != nullptr) {\n    rc = X509_digest(ca_cert_.get(), EVP_sha256(), hash_buffer, &hash_length);\n    RELEASE_ASSERT(rc == 1, Utility::getLastCryptoError().value_or(\"\"));\n    RELEASE_ASSERT(hash_length == SHA256_DIGEST_LENGTH,\n                   fmt::format(\"invalid SHA256 hash length {}\", hash_length));\n\n    rc = EVP_DigestUpdate(md.get(), hash_buffer, hash_length);\n    RELEASE_ASSERT(rc == 1, Utility::getLastCryptoError().value_or(\"\"));\n  }\n\n  for (const auto& hash : verify_certificate_hash_list_) {\n    rc = EVP_DigestUpdate(md.get(), hash.data(),\n                          hash.size() *\n                              sizeof(std::remove_reference<decltype(hash)>::type::value_type));\n    RELEASE_ASSERT(rc == 1, Utility::getLastCryptoError().value_or(\"\"));\n  }\n\n  for (const auto& hash : verify_certificate_spki_list_) {\n    rc = EVP_DigestUpdate(md.get(), hash.data(),\n                          hash.size() *\n                              sizeof(std::remove_reference<decltype(hash)>::type::value_type));\n    RELEASE_ASSERT(rc == 1, Utility::getLastCryptoError().value_or(\"\"));\n  }\n}","target":1,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":508385,"func":"void close_thread_table(THD *thd, TABLE **table_ptr)\n{\n  TABLE *table= *table_ptr;\n  DBUG_ENTER(\"close_thread_table\");\n  DBUG_PRINT(\"tcache\", (\"table: '%s'.'%s' %p\", table->s->db.str,\n                        table->s->table_name.str, table));\n  DBUG_ASSERT(!table->file->keyread_enabled());\n  DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);\n\n  \/*\n    The metadata lock must be released after giving back\n    the table to the table cache.\n  *\/\n  DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE,\n                                             table->s->db.str,\n                                             table->s->table_name.str,\n                                             MDL_SHARED));\n  table->mdl_ticket= NULL;\n\n  if (table->file)\n  {\n    table->file->update_global_table_stats();\n    table->file->update_global_index_stats();\n  }\n\n  mysql_mutex_lock(&thd->LOCK_thd_data);\n  *table_ptr=table->next;\n  mysql_mutex_unlock(&thd->LOCK_thd_data);\n\n  if (! table->needs_reopen())\n  {\n    \/* Avoid having MERGE tables with attached children in table cache. *\/\n    table->file->extra(HA_EXTRA_DETACH_CHILDREN);\n    \/* Free memory and reset for next loop. *\/\n    free_field_buffers_larger_than(table, MAX_TDC_BLOB_SIZE);\n    table->file->ha_reset();\n  }\n\n  \/*\n    Do this *before* entering the TABLE_SHARE::tdc.LOCK_table_share\n    critical section.\n  *\/\n  MYSQL_UNBIND_TABLE(table->file);\n\n  tc_release_table(table);\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":369,"total_token_length":605,"max_tokens_setting":1024}
+{"idx":214124,"func":"lzw_result lzw_decode(struct lzw_ctx *ctx,\n\t\tconst uint8_t ** const stack_pos_out)\n{\n\tlzw_result res;\n\tuint32_t code_new;\n\tuint32_t code_out;\n\tuint8_t last_value;\n\tuint8_t *stack_pos = ctx->stack_base;\n\tuint32_t clear_code = ctx->clear_code;\n\tuint32_t current_entry = ctx->current_entry;\n\tstruct lzw_dictionary_entry * const table = ctx->table;\n\n\t\/* Get a new code from the input *\/\n\tres = lzw__next_code(&ctx->input, ctx->current_code_size, &code_new);\n\tif (res != LZW_OK) {\n\t\treturn res;\n\t}\n\n\t\/* Handle the new code *\/\n\tif (code_new == clear_code) {\n\t\t\/* Got Clear code *\/\n\t\treturn lzw__clear_codes(ctx, stack_pos_out);\n\n\t} else if (code_new == ctx->eoi_code) {\n\t\t\/* Got End of Information code *\/\n\t\treturn LZW_EOI_CODE;\n\n\t} else if (code_new > current_entry) {\n\t\t\/* Code is invalid *\/\n\t\treturn LZW_BAD_CODE;\n\n\t} else if (code_new < current_entry) {\n\t\t\/* Code is in table *\/\n\t\tcode_out = code_new;\n\t\tlast_value = table[code_new].first_value;\n\t} else {\n\t\t\/* Code not in table *\/\n\t\t*stack_pos++ = ctx->previous_code_first;\n\t\tcode_out = ctx->previous_code;\n\t\tlast_value = ctx->previous_code_first;\n\t}\n\n\t\/* Add to the dictionary, only if there's space *\/\n\tif (current_entry < (1 << LZW_CODE_MAX)) {\n\t\tstruct lzw_dictionary_entry *entry = table + current_entry;\n\t\tentry->last_value     = last_value;\n\t\tentry->first_value    = ctx->previous_code_first;\n\t\tentry->previous_entry = ctx->previous_code;\n\t\tctx->current_entry++;\n\t}\n\n\t\/* Ensure code size is increased, if needed. *\/\n\tif (current_entry == ctx->current_code_size_max) {\n\t\tif (ctx->current_code_size < LZW_CODE_MAX) {\n\t\t\tctx->current_code_size++;\n\t\t\tctx->current_code_size_max =\n\t\t\t\t\t(1 << ctx->current_code_size) - 1;\n\t\t}\n\t}\n\n\t\/* Store details of this code as \"previous code\" to the context. *\/\n\tctx->previous_code_first = table[code_new].first_value;\n\tctx->previous_code = code_new;\n\n\t\/* Put rest of data for this code on output stack.\n\t * Note, in the case of \"code not in table\", the last entry of the\n\t * current code has already been placed on the stack above. *\/\n\twhile (code_out > clear_code) {\n\t\tstruct lzw_dictionary_entry *entry = table + code_out;\n\t\t*stack_pos++ = entry->last_value;\n\t\tcode_out = entry->previous_entry;\n\t}\n\t*stack_pos++ = table[code_out].last_value;\n\n\t*stack_pos_out = stack_pos;\n\treturn LZW_OK;\n}","target":1,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":214282,"func":"R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaClassesAttribute *icattr;\n\tRBinJavaAttrInfo *attr = NULL;\n\tRBinJavaCPTypeObj *obj;\n\tut32 i = 0;\n\tut64 offset = 0, curpos;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr == NULL) {\n\t\t\/\/ TODO eprintf\n\t\treturn attr;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR;\n\tattr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free);\n\tfor (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (offset + 8 > sz) {\n\t\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\t\tbreak;\n\t\t}\n\t\ticattr = R_NEW0 (RBinJavaClassesAttribute);\n\t\tif (!icattr) {\n\t\t\tbreak;\n\t\t}\n\t\ticattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags);\n\t\ticattr->file_offset = curpos;\n\t\ticattr->size = 8;\n\n\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx);\n\t\tif (obj == NULL) {\n\t\t\teprintf (\"BINCPLIS IS HULL %d\\n\", icattr->inner_name_idx);\n\t\t}\n\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\tif (!icattr->name) {\n\t\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx);\n\t\t\tif (!obj) {\n\t\t\t\teprintf (\"BINCPLIST IS NULL %d\\n\", icattr->inner_class_info_idx);\n\t\t\t}\n\t\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\t\tif (!icattr->name) {\n\t\t\t\ticattr->name = r_str_dup (NULL, \"NULL\");\n\t\t\t\teprintf (\"r_bin_java_inner_classes_attr: Unable to find the name for %d index.\\n\", icattr->inner_name_idx);\n\t\t\t\tfree (icattr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tIFDBG eprintf(\"r_bin_java_inner_classes_attr: Inner class name %d is %s.\\n\", icattr->inner_name_idx, icattr->name);\n\t\tr_list_append (attr->info.inner_classes_attr.classes, (void *) icattr);\n\t}\n\tattr->size = offset;\n\t\/\/ IFDBG r_bin_java_print_inner_classes_attr_summary(attr);\n\treturn attr;\n}","target":1,"code_token_length":765,"total_token_length":1001,"max_tokens_setting":1024}
+{"idx":473930,"func":"fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,\n\t   UChar** rname_end, ScanEnv* env, int* rback_num, int ref)\n{\n  int r, is_num, sign;\n  OnigCodePoint end_code;\n  OnigCodePoint c = 0;\n  OnigEncoding enc = env->enc;\n  UChar *name_end;\n  UChar *pnum_head;\n  UChar *p = *src;\n  PFETCH_READY;\n\n  *rback_num = 0;\n\n  end_code = get_name_end_code_point(start_code);\n\n  name_end = end;\n  pnum_head = *src;\n  r = 0;\n  is_num = 0;\n  sign = 1;\n  if (PEND) {\n    return ONIGERR_EMPTY_GROUP_NAME;\n  }\n  else {\n    PFETCH(c);\n    if (c == end_code)\n      return ONIGERR_EMPTY_GROUP_NAME;\n\n    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {\n      if (ref == 1)\n\tis_num = 1;\n      else {\n\tr = ONIGERR_INVALID_GROUP_NAME;\n\tis_num = 0;\n      }\n    }\n    else if (c == '-') {\n      if (ref == 1) {\n\tis_num = 2;\n\tsign = -1;\n\tpnum_head = p;\n      }\n      else {\n\tr = ONIGERR_INVALID_GROUP_NAME;\n\tis_num = 0;\n      }\n    }\n    else if (!ONIGENC_IS_CODE_WORD(enc, c)) {\n      r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;\n    }\n  }\n\n  if (r == 0) {\n    while (!PEND) {\n      name_end = p;\n      PFETCH(c);\n      if (c == end_code || c == ')') {\n\tif (is_num == 2) \tr = ONIGERR_INVALID_GROUP_NAME;\n\tbreak;\n      }\n\n      if (is_num != 0) {\n\tif (ONIGENC_IS_CODE_DIGIT(enc, c)) {\n\t  is_num = 1;\n\t}\n\telse {\n\t  if (!ONIGENC_IS_CODE_WORD(enc, c))\n\t    r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;\n\t  else\n\t    r = ONIGERR_INVALID_GROUP_NAME;\n\n\t  is_num = 0;\n\t}\n      }\n      else {\n\tif (!ONIGENC_IS_CODE_WORD(enc, c)) {\n\t  r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;\n\t}\n      }\n    }\n\n    if (c != end_code) {\n      r = ONIGERR_INVALID_GROUP_NAME;\n      name_end = end;\n    }\n\n    if (is_num != 0) {\n      *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc);\n      if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER;\n      else if (*rback_num == 0) {\n\tr = ONIGERR_INVALID_GROUP_NAME;\n\tgoto err;\n      }\n\n      *rback_num *= sign;\n    }\n\n    *rname_end = name_end;\n    *src = p;\n    return 0;\n  }\n  else {\n    while (!PEND) {\n      name_end = p;\n      PFETCH(c);\n      if (c == end_code || c == ')')\n\tbreak;\n    }\n    if (PEND)\n      name_end = end;\n\n  err:\n    onig_scan_env_set_error_string(env, r, *src, name_end);\n    return r;\n  }\n}","target":0,"code_token_length":733,"total_token_length":969,"max_tokens_setting":1024}
+{"idx":402603,"func":"handle_get_cmd_version(context *ctx, struct pollfd *pollfd, socklen_t size)\n{\n\tstruct msghdr msg;\n\tstruct iovec iov;\n\tssize_t n;\n\n\tint rc = cms_context_alloc(&ctx->cms);\n\tif (rc < 0) {\n\t\tsend_response(ctx, ctx->backup_cms, pollfd, rc);\n\t\treturn;\n\t}\n\n\tsteal_from_cms(ctx->backup_cms, ctx->cms);\n\n\tchar *buffer = malloc(size);\n\tif (!buffer) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unable to allocate memory: %m\");\n\t\texit(1);\n\t}\n\n\tmemset(&msg, '\\0', sizeof(msg));\n\n\tiov.iov_base = buffer;\n\tiov.iov_len = size;\n\tmsg.msg_iov = &iov;\n\tmsg.msg_iovlen = 1;\n\n\tn = recvmsg(pollfd->fd, &msg, MSG_WAITALL);\n\n\tint32_t version = -1;\n\tuint32_t command;\n\n\tif (n < (long long)sizeof(command)) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"unlock-token: invalid data\");\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,\n\t\t\t\"possible exploit attempt. closing.\");\n\t\tclose(pollfd->fd);\n\t\treturn;\n\t}\n\n\tmemcpy(&command, buffer, sizeof (command));\n\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\t\"searching for command %d\", command);\n\n\tfor (int i = 0; cmd_table[i].cmd != CMD_LIST_END; i++) {\n\t\tif (cmd_table[i].cmd == command) {\n\t\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\t\t\t\"cmd-version: found command \\\"%s\\\" \"\n\t\t\t\t\t\"version %d\",\n\t\t\t\t\tcmd_table[i].name,\n\t\t\t\t\tcmd_table[i].version);\n\t\t\tversion = cmd_table[i].version;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (version == -1) {\n\t\tctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,\n\t\t\t\t\"cmd-version: could not find command %d\",\n\t\t\t\tcommand);\n\t}\n\tsend_response(ctx, ctx->cms, pollfd, version);\n\n\tfree(buffer);\n\n\thide_stolen_goods_from_cms(ctx->cms, ctx->backup_cms);\n\tcms_context_fini(ctx->cms);\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":310257,"func":"dirserv_dump_directory_to_string(char **dir_out,\n                                 crypto_pk_env_t *private_key)\n{\n  char *cp;\n  char *identity_pkey; \/* Identity key, DER64-encoded. *\/\n  char *recommended_versions;\n  char digest[DIGEST_LEN];\n  char published[ISO_TIME_LEN+1];\n  char *buf = NULL;\n  size_t buf_len;\n  size_t identity_pkey_len;\n  time_t now = time(NULL);\n\n  tor_assert(dir_out);\n  *dir_out = NULL;\n\n  if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,\n                                           &identity_pkey_len)<0) {\n    log_warn(LD_BUG,\"write identity_pkey to string failed!\");\n    return -1;\n  }\n\n  recommended_versions =\n    format_versions_list(get_options()->RecommendedVersions);\n\n  format_iso_time(published, now);\n\n  buf_len = 2048+strlen(recommended_versions);\n\n  buf = tor_malloc(buf_len);\n  \/* We'll be comparing against buf_len throughout the rest of the\n     function, though strictly speaking we shouldn't be able to exceed\n     it.  This is C, after all, so we may as well check for buffer\n     overruns.*\/\n\n  tor_snprintf(buf, buf_len,\n               \"signed-directory\\n\"\n               \"published %s\\n\"\n               \"recommended-software %s\\n\"\n               \"router-status %s\\n\"\n               \"dir-signing-key\\n%s\\n\",\n               published, recommended_versions, \"\",\n               identity_pkey);\n\n  tor_free(recommended_versions);\n  tor_free(identity_pkey);\n\n  cp = buf + strlen(buf);\n  *cp = '\\0';\n\n  \/* These multiple strlcat calls are inefficient, but dwarfed by the RSA\n     signature. *\/\n  if (strlcat(buf, \"directory-signature \", buf_len) >= buf_len)\n    goto truncated;\n  if (strlcat(buf, get_options()->Nickname, buf_len) >= buf_len)\n    goto truncated;\n  if (strlcat(buf, \"\\n\", buf_len) >= buf_len)\n    goto truncated;\n\n  if (router_get_dir_hash(buf,digest)) {\n    log_warn(LD_BUG,\"couldn't compute digest\");\n    tor_free(buf);\n    return -1;\n  }\n  note_crypto_pk_op(SIGN_DIR);\n  if (router_append_dirobj_signature(buf,buf_len,digest,DIGEST_LEN,\n                                     private_key)<0) {\n    tor_free(buf);\n    return -1;\n  }\n\n  *dir_out = buf;\n  return 0;\n truncated:\n  log_warn(LD_BUG,\"tried to exceed string length.\");\n  tor_free(buf);\n  return -1;\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":369220,"func":"\nstatic __cold int io_sq_offload_create(struct io_ring_ctx *ctx,\n\t\t\t\t       struct io_uring_params *p)\n{\n\tint ret;\n\n\t\/* Retain compatibility with failing for an invalid attach attempt *\/\n\tif ((ctx->flags & (IORING_SETUP_ATTACH_WQ | IORING_SETUP_SQPOLL)) ==\n\t\t\t\tIORING_SETUP_ATTACH_WQ) {\n\t\tstruct fd f;\n\n\t\tf = fdget(p->wq_fd);\n\t\tif (!f.file)\n\t\t\treturn -ENXIO;\n\t\tif (f.file->f_op != &io_uring_fops) {\n\t\t\tfdput(f);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tfdput(f);\n\t}\n\tif (ctx->flags & IORING_SETUP_SQPOLL) {\n\t\tstruct task_struct *tsk;\n\t\tstruct io_sq_data *sqd;\n\t\tbool attached;\n\n\t\tret = security_uring_sqpoll();\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tsqd = io_get_sq_data(p, &attached);\n\t\tif (IS_ERR(sqd)) {\n\t\t\tret = PTR_ERR(sqd);\n\t\t\tgoto err;\n\t\t}\n\n\t\tctx->sq_creds = get_current_cred();\n\t\tctx->sq_data = sqd;\n\t\tctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle);\n\t\tif (!ctx->sq_thread_idle)\n\t\t\tctx->sq_thread_idle = HZ;\n\n\t\tio_sq_thread_park(sqd);\n\t\tlist_add(&ctx->sqd_list, &sqd->ctx_list);\n\t\tio_sqd_update_thread_idle(sqd);\n\t\t\/* don't attach to a dying SQPOLL thread, would be racy *\/\n\t\tret = (attached && !sqd->thread) ? -ENXIO : 0;\n\t\tio_sq_thread_unpark(sqd);\n\n\t\tif (ret < 0)\n\t\t\tgoto err;\n\t\tif (attached)\n\t\t\treturn 0;\n\n\t\tif (p->flags & IORING_SETUP_SQ_AFF) {\n\t\t\tint cpu = p->sq_thread_cpu;\n\n\t\t\tret = -EINVAL;\n\t\t\tif (cpu >= nr_cpu_ids || !cpu_online(cpu))\n\t\t\t\tgoto err_sqpoll;\n\t\t\tsqd->sq_cpu = cpu;\n\t\t} else {\n\t\t\tsqd->sq_cpu = -1;\n\t\t}\n\n\t\tsqd->task_pid = current->pid;\n\t\tsqd->task_tgid = current->tgid;\n\t\ttsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);\n\t\tif (IS_ERR(tsk)) {\n\t\t\tret = PTR_ERR(tsk);\n\t\t\tgoto err_sqpoll;\n\t\t}\n\n\t\tsqd->thread = tsk;\n\t\tret = io_uring_alloc_task_context(tsk, ctx);\n\t\twake_up_new_task(tsk);\n\t\tif (ret)\n\t\t\tgoto err;\n\t} else if (p->flags & IORING_SETUP_SQ_AFF) {\n\t\t\/* Can't have SQ_AFF without SQPOLL *\/\n\t\tret = -EINVAL;\n\t\tgoto err;\n\t}\n\n\treturn 0;\nerr_sqpoll:\n\tcomplete(&ctx->sq_data->exited);\nerr:\n\tio_sq_thread_finish(ctx);\n\treturn ret;","target":0,"code_token_length":662,"total_token_length":898,"max_tokens_setting":1024}
+{"idx":312532,"func":"qf_setprop_get_qfidx(\n\tqf_info_T\t*qi,\n\tdict_T\t\t*what,\n\tint\t\taction,\n\tint\t\t*newlist)\n{\n    dictitem_T\t*di;\n    int\t\tqf_idx = qi->qf_curlist;    \/\/ default is the current list\n\n    if ((di = dict_find(what, (char_u *)\"nr\", -1)) != NULL)\n    {\n\t\/\/ Use the specified quickfix\/location list\n\tif (di->di_tv.v_type == VAR_NUMBER)\n\t{\n\t    \/\/ for zero use the current list\n\t    if (di->di_tv.vval.v_number != 0)\n\t\tqf_idx = di->di_tv.vval.v_number - 1;\n\n\t    if ((action == ' ' || action == 'a') && qf_idx == qi->qf_listcount)\n\t    {\n\t\t\/\/ When creating a new list, accept qf_idx pointing to the next\n\t\t\/\/ non-available list and add the new list at the end of the\n\t\t\/\/ stack.\n\t\t*newlist = TRUE;\n\t\tqf_idx = qf_stack_empty(qi) ? 0 : qi->qf_listcount - 1;\n\t    }\n\t    else if (qf_idx < 0 || qf_idx >= qi->qf_listcount)\n\t\treturn INVALID_QFIDX;\n\t    else if (action != ' ')\n\t\t*newlist = FALSE;\t\/\/ use the specified list\n\t}\n\telse if (di->di_tv.v_type == VAR_STRING\n\t\t&& di->di_tv.vval.v_string != NULL\n\t\t&& STRCMP(di->di_tv.vval.v_string, \"$\") == 0)\n\t{\n\t    if (!qf_stack_empty(qi))\n\t\tqf_idx = qi->qf_listcount - 1;\n\t    else if (*newlist)\n\t\tqf_idx = 0;\n\t    else\n\t\treturn INVALID_QFIDX;\n\t}\n\telse\n\t    return INVALID_QFIDX;\n    }\n\n    if (!*newlist && (di = dict_find(what, (char_u *)\"id\", -1)) != NULL)\n    {\n\t\/\/ Use the quickfix\/location list with the specified id\n\tif (di->di_tv.v_type != VAR_NUMBER)\n\t    return INVALID_QFIDX;\n\n\treturn qf_id2nr(qi, di->di_tv.vval.v_number);\n    }\n\n    return qf_idx;\n}","target":0,"code_token_length":514,"total_token_length":750,"max_tokens_setting":1024}
+{"idx":386531,"func":"void DL_Dxf::writeInsert(DL_WriterA& dw,\n                         const DL_InsertData& data,\n                         const DL_Attributes& attrib) {\n\n    if (data.name.empty()) {\n        std::cerr << \"DL_Dxf::writeInsert: \"\n        << \"Block name must not be empty\\n\";\n        return;\n    }\n\n    dw.entity(\"INSERT\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        if (data.cols!=1 || data.rows!=1) {\n            dw.dxfString(100, \"AcDbMInsertBlock\");\n        }\n        else {\n            dw.dxfString(100, \"AcDbBlockReference\");\n        }\n    }\n    dw.dxfString(2, data.name);\n    dw.dxfReal(10, data.ipx);\n    dw.dxfReal(20, data.ipy);\n    dw.dxfReal(30, data.ipz);\n    if (data.sx!=1.0 || data.sy!=1.0) {\n        dw.dxfReal(41, data.sx);\n        dw.dxfReal(42, data.sy);\n        dw.dxfReal(43, 1.0);\n    }\n    if (data.angle!=0.0) {\n        dw.dxfReal(50, data.angle);\n    }\n    if (data.cols!=1 || data.rows!=1) {\n        dw.dxfInt(70, data.cols);\n        dw.dxfInt(71, data.rows);\n    }\n    if (data.colSp!=0.0 || data.rowSp!=0.0) {\n        dw.dxfReal(44, data.colSp);\n        dw.dxfReal(45, data.rowSp);\n    }\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":222496,"func":"string Print(const AttrValue& attr_value,\n             const bool hash_string_attrs = false) {\n  if (attr_value.value_case() == AttrValue::kType) {\n    return DataTypeString(attr_value.type());\n  } else if ((attr_value.value_case() == AttrValue::kList) &&\n             (attr_value.list().type_size() > 0)) {\n    string ret = \"{\";\n    for (int i = 0; i < attr_value.list().type_size(); ++i) {\n      if (i > 0) strings::StrAppend(&ret, \", \");\n      strings::StrAppend(&ret, DataTypeString(attr_value.list().type(i)));\n    }\n    strings::StrAppend(&ret, \"}\");\n    return ret;\n  } else if (attr_value.value_case() == AttrValue::kFunc) {\n    if (attr_value.func().attr_size() == 0) {\n      return attr_value.func().name();\n    }\n    std::vector<string> entries;\n    for (const auto& p : attr_value.func().attr()) {\n      entries.push_back(strings::StrCat(p.first, \"=\", Print(p.second)));\n    }\n    std::sort(entries.begin(), entries.end());\n    return strings::StrCat(attr_value.func().name(), \"[\",\n                           absl::StrJoin(entries, \", \"), \"]\");\n  } else if (attr_value.value_case() == AttrValue::kS && hash_string_attrs) {\n    return strings::StrCat(Fingerprint64(attr_value.s()));\n  }\n  return SummarizeAttrValue(attr_value);\n}","target":0,"code_token_length":320,"total_token_length":556,"max_tokens_setting":1024}
+{"idx":369157,"func":" *\/\nstatic int io_poll_check_events(struct io_kiocb *req, bool locked)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tint v;\n\n\t\/* req->task == current here, checking PF_EXITING is safe *\/\n\tif (unlikely(req->task->flags & PF_EXITING))\n\t\tio_poll_mark_cancelled(req);\n\n\tdo {\n\t\tv = atomic_read(&req->poll_refs);\n\n\t\t\/* tw handler should be the owner, and so have some references *\/\n\t\tif (WARN_ON_ONCE(!(v & IO_POLL_REF_MASK)))\n\t\t\treturn 0;\n\t\tif (v & IO_POLL_CANCEL_FLAG)\n\t\t\treturn -ECANCELED;\n\n\t\tif (!req->result) {\n\t\t\tstruct poll_table_struct pt = { ._key = req->apoll_events };\n\t\t\tunsigned flags = locked ? 0 : IO_URING_F_UNLOCKED;\n\n\t\t\tif (unlikely(!io_assign_file(req, flags)))\n\t\t\t\treturn -EBADF;\n\t\t\treq->result = vfs_poll(req->file, &pt) & req->apoll_events;\n\t\t}\n\n\t\t\/* multishot, just fill an CQE and proceed *\/\n\t\tif (req->result && !(req->apoll_events & EPOLLONESHOT)) {\n\t\t\t__poll_t mask = mangle_poll(req->result & req->apoll_events);\n\t\t\tbool filled;\n\n\t\t\tspin_lock(&ctx->completion_lock);\n\t\t\tfilled = io_fill_cqe_aux(ctx, req->user_data, mask,\n\t\t\t\t\t\t IORING_CQE_F_MORE);\n\t\t\tio_commit_cqring(ctx);\n\t\t\tspin_unlock(&ctx->completion_lock);\n\t\t\tif (unlikely(!filled))\n\t\t\t\treturn -ECANCELED;\n\t\t\tio_cqring_ev_posted(ctx);\n\t\t} else if (req->result) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t\/*\n\t\t * Release all references, retry if someone tried to restart\n\t\t * task_work while we were executing it.\n\t\t *\/\n\t} while (atomic_sub_return(v & IO_POLL_REF_MASK, &req->poll_refs));\n\n\treturn 1;","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":432189,"func":"static void phys_page_compact(struct uc_struct *uc, PhysPageEntry *lp, Node *nodes)\n{\n    unsigned valid_ptr = P_L2_SIZE;\n    int valid = 0;\n    PhysPageEntry *p;\n    int i;\n\n    if (lp->ptr == PHYS_MAP_NODE_NIL) {\n        return;\n    }\n\n    p = nodes[lp->ptr];\n    for (i = 0; i < P_L2_SIZE; i++) {\n        if (p[i].ptr == PHYS_MAP_NODE_NIL) {\n            continue;\n        }\n\n        valid_ptr = i;\n        valid++;\n        if (p[i].skip) {\n            phys_page_compact(uc, &p[i], nodes);\n        }\n    }\n\n    \/* We can only compress if there's only one child. *\/\n    if (valid != 1) {\n        return;\n    }\n\n    assert(valid_ptr < P_L2_SIZE);\n\n    \/* Don't compress if it won't fit in the # of bits we have. *\/\n    if (P_L2_LEVELS >= (1 << 6) &&\n        lp->skip + p[valid_ptr].skip >= (1 << 6)) {\n        return;\n    }\n\n    lp->ptr = p[valid_ptr].ptr;\n    if (!p[valid_ptr].skip) {\n        \/* If our only child is a leaf, make this a leaf. *\/\n        \/* By design, we should have made this node a leaf to begin with so we\n         * should never reach here.\n         * But since it's so simple to handle this, let's do it just in case we\n         * change this rule.\n         *\/\n        lp->skip = 0;\n    } else {\n        lp->skip += p[valid_ptr].skip;\n    }\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":197615,"func":"Status TensorSliceReader::GetTensor(\n    const string& name, std::unique_ptr<tensorflow::Tensor>* out_tensor) const {\n  DataType type;\n  TensorShape shape;\n  TensorSlice slice;\n  {\n    mutex_lock l(mu_);\n    const TensorSliceSet* tss = gtl::FindPtrOrNull(tensors_, name);\n    if (tss == nullptr) {\n      return errors::NotFound(name, \" not found in checkpoint file\");\n    }\n\n    if (tss->Slices().size() > 1) {\n      \/\/ TODO(sherrym): Support multi-slice checkpoints.\n      return errors::Unimplemented(\"Sliced checkpoints are not supported\");\n    }\n\n    type = tss->type();\n    shape = tss->shape();\n    slice = tss->Slices().begin()->second.slice;\n  }\n\n  std::unique_ptr<tensorflow::Tensor> t(new tensorflow::Tensor(type, shape));\n  bool success = false;\n\n#define READER_COPY(dt)                                                  \\\n  case dt:                                                               \\\n    success = CopySliceData(name, slice,                                 \\\n                            t->flat<EnumToDataType<dt>::Type>().data()); \\\n    break;\n\n  switch (type) {\n    READER_COPY(DT_FLOAT);\n    READER_COPY(DT_DOUBLE);\n    READER_COPY(DT_INT32);\n    READER_COPY(DT_UINT8);\n    READER_COPY(DT_INT16);\n    READER_COPY(DT_INT8);\n    READER_COPY(DT_INT64);\n    READER_COPY(DT_STRING);\n    default:\n      return errors::Unimplemented(\"Data type not supported\");\n  }\n#undef READER_COPY\n\n  if (!success) {\n    return errors::NotFound(name, \" not found in checkpoint file\");\n  }\n  std::swap(*out_tensor, t);\n\n  return Status::OK();\n}","target":1,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":252366,"func":"static void hufCanonicalCodeTable(long long hcode[HUF_ENCSIZE]) {\n  long long n[59];\n\n  \/\/\n  \/\/ For each i from 0 through 58, count the\n  \/\/ number of different codes of length i, and\n  \/\/ store the count in n[i].\n  \/\/\n\n  for (int i = 0; i <= 58; ++i) n[i] = 0;\n\n  for (int i = 0; i < HUF_ENCSIZE; ++i) n[hcode[i]] += 1;\n\n  \/\/\n  \/\/ For each i from 58 through 1, compute the\n  \/\/ numerically lowest code with length i, and\n  \/\/ store that code in n[i].\n  \/\/\n\n  long long c = 0;\n\n  for (int i = 58; i > 0; --i) {\n    long long nc = ((c + n[i]) >> 1);\n    n[i] = c;\n    c = nc;\n  }\n\n  \/\/\n  \/\/ hcode[i] contains the length, l, of the\n  \/\/ code for symbol i.  Assign the next available\n  \/\/ code of length l to the symbol and store both\n  \/\/ l and the code in hcode[i].\n  \/\/\n\n  for (int i = 0; i < HUF_ENCSIZE; ++i) {\n    int l = static_cast<int>(hcode[i]);\n\n    if (l > 0) hcode[i] = l | (n[l]++ << 6);\n  }\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":488381,"func":"static inline int handle_pte_fault(struct mm_struct *mm,\n\t\tstruct vm_area_struct *vma, unsigned long address,\n\t\tpte_t *pte, pmd_t *pmd, int write_access)\n{\n\tpte_t entry;\n\tspinlock_t *ptl;\n\n\tentry = *pte;\n\tif (!pte_present(entry)) {\n\t\tif (pte_none(entry)) {\n\t\t\tif (vma->vm_ops) {\n\t\t\t\tif (likely(vma->vm_ops->fault))\n\t\t\t\t\treturn do_linear_fault(mm, vma, address,\n\t\t\t\t\t\tpte, pmd, write_access, entry);\n\t\t\t\tif (unlikely(vma->vm_ops->nopfn))\n\t\t\t\t\treturn do_no_pfn(mm, vma, address, pte,\n\t\t\t\t\t\t\t pmd, write_access);\n\t\t\t}\n\t\t\treturn do_anonymous_page(mm, vma, address,\n\t\t\t\t\t\t pte, pmd, write_access);\n\t\t}\n\t\tif (pte_file(entry))\n\t\t\treturn do_nonlinear_fault(mm, vma, address,\n\t\t\t\t\tpte, pmd, write_access, entry);\n\t\treturn do_swap_page(mm, vma, address,\n\t\t\t\t\tpte, pmd, write_access, entry);\n\t}\n\n\tptl = pte_lockptr(mm, pmd);\n\tspin_lock(ptl);\n\tif (unlikely(!pte_same(*pte, entry)))\n\t\tgoto unlock;\n\tif (write_access) {\n\t\tif (!pte_write(entry))\n\t\t\treturn do_wp_page(mm, vma, address,\n\t\t\t\t\tpte, pmd, ptl, entry);\n\t\tentry = pte_mkdirty(entry);\n\t}\n\tentry = pte_mkyoung(entry);\n\tif (ptep_set_access_flags(vma, address, pte, entry, write_access)) {\n\t\tupdate_mmu_cache(vma, address, entry);\n\t} else {\n\t\t\/*\n\t\t * This is needed only for protection faults but the arch code\n\t\t * is not yet telling us if this is a protection fault or not.\n\t\t * This still avoids useless tlb flushes for .text page faults\n\t\t * with threads.\n\t\t *\/\n\t\tif (write_access)\n\t\t\tflush_tlb_page(vma, address);\n\t}\nunlock:\n\tpte_unmap_unlock(pte, ptl);\n\treturn 0;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":254072,"func":"inline std::unique_ptr<std::pair<std::string, std::string>> qs_dict_name2kv(const char * dict_name, char * const * qs_kv, int qs_kv_size, int nth = 0)\n{\n    int i;\n    size_t name_len, skip_to_eq, skip_to_brace_open, skip_to_brace_close;\n\n    name_len = strlen(dict_name);\n\n#ifdef _qsSORTING\n\/\/ TODO: binary search for key in the sorted qs_kv\n#else  \/\/ _qsSORTING\n    for(i=0; i<qs_kv_size; i++)\n    {\n        if ( strncmp(dict_name, qs_kv[i], name_len) == 0 )\n        {\n            skip_to_eq = strcspn(qs_kv[i], \"=\");\n            if ( qs_kv[i][skip_to_eq] == '=' )\n                skip_to_eq++;\n            skip_to_brace_open = strcspn(qs_kv[i], \"[\");\n            if ( qs_kv[i][skip_to_brace_open] == '[' )\n                skip_to_brace_open++;\n            skip_to_brace_close = strcspn(qs_kv[i], \"]\");\n\n            if ( skip_to_brace_open <= skip_to_brace_close &&\n                 skip_to_brace_open > 0 &&\n                 skip_to_brace_close > 0 &&\n                 nth == 0 )\n            {\n                auto key = std::string(qs_kv[i] + skip_to_brace_open, skip_to_brace_close - skip_to_brace_open);\n                auto value = std::string(qs_kv[i] + skip_to_eq);\n                return std::unique_ptr<std::pair<std::string, std::string>>(new std::pair<std::string, std::string>(key, value));\n            }\n            else\n            {\n                --nth;\n            }\n        }\n    }\n#endif  \/\/ _qsSORTING\n\n    return nullptr;\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":508331,"func":"static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)\n{\n  TABLE_SHARE *share;\n  TABLE *entry;\n  bool result= TRUE;\n\n  thd->clear_error();\n\n  if (!(entry= (TABLE*)my_malloc(sizeof(TABLE), MYF(MY_WME))))\n    return result;\n\n  if (!(share= tdc_acquire_share(thd, table_list, GTS_TABLE)))\n    goto end_free;\n\n  DBUG_ASSERT(! share->is_view);\n\n  if (open_table_from_share(thd, share, table_list->alias,\n                            HA_OPEN_KEYFILE | HA_TRY_READ_ONLY,\n                            EXTRA_RECORD,\n                            ha_open_options | HA_OPEN_FOR_REPAIR,\n                            entry, FALSE) || ! entry->file ||\n      (entry->file->is_crashed() && entry->file->ha_check_and_repair(thd)))\n  {\n    \/* Give right error message *\/\n    thd->clear_error();\n    my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str);\n    sql_print_error(\"Couldn't repair table: %s.%s\", share->db.str,\n                    share->table_name.str);\n    if (entry->file)\n      closefrm(entry);\n  }\n  else\n  {\n    thd->clear_error();\t\t\t\/\/ Clear error message\n    closefrm(entry);\n    result= FALSE;\n  }\n\n  tdc_release_share(share);\n  \/* Remove the repaired share from the table cache. *\/\n  tdc_remove_table(thd, TDC_RT_REMOVE_ALL,\n                   table_list->db, table_list->table_name,\n                   FALSE);\nend_free:\n  my_free(entry);\n  return result;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":463189,"func":"static int annotate_canon_value(struct buf *value, int type)\n{\n    char *p = NULL;\n    unsigned long uwhatever = 0;\n    long whatever = 0;\n\n    \/* check for NIL *\/\n    if (value->s == NULL)\n        return 0;\n\n    switch (type) {\n    case ATTRIB_TYPE_STRING:\n        \/* free form *\/\n        break;\n\n    case ATTRIB_TYPE_BOOLEAN:\n        \/* make sure its \"true\" or \"false\" *\/\n        if (value->len == 4 && !strncasecmp(value->s, \"true\", 4)) {\n            buf_reset(value);\n            buf_appendcstr(value, \"true\");\n            buf_cstring(value);\n        }\n        else if (value->len == 5 && !strncasecmp(value->s, \"false\", 5)) {\n            buf_reset(value);\n            buf_appendcstr(value, \"false\");\n            buf_cstring(value);\n        }\n        else return IMAP_ANNOTATION_BADVALUE;\n        break;\n\n    case ATTRIB_TYPE_UINT:\n        \/* make sure its a valid ulong ( >= 0 ) *\/\n        errno = 0;\n        buf_cstring(value);\n        uwhatever = strtoul(value->s, &p, 10);\n        if ((p == value->s)             \/* no value *\/\n            || (*p != '\\0')             \/* illegal char *\/\n            || (unsigned)(p - value->s) != value->len\n                                        \/* embedded NUL *\/\n            || errno                    \/* overflow *\/\n            || strchr(value->s, '-')) { \/* negative number *\/\n            return IMAP_ANNOTATION_BADVALUE;\n        }\n        break;\n\n    case ATTRIB_TYPE_INT:\n        \/* make sure its a valid long *\/\n        errno = 0;\n        buf_cstring(value);\n        whatever = strtol(value->s, &p, 10);\n        if ((p == value->s)             \/* no value *\/\n            || (*p != '\\0')             \/* illegal char *\/\n            || (unsigned)(p - value->s) != value->len\n                                        \/* embedded NUL *\/\n            || errno) {                 \/* underflow\/overflow *\/\n            return IMAP_ANNOTATION_BADVALUE;\n        }\n        break;\n\n    default:\n        \/* unknown type *\/\n        return IMAP_ANNOTATION_BADVALUE;\n    }\n\n    if (whatever || uwhatever) \/* filthy compiler magic *\/\n        return 0;\n\n    return 0;\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":282876,"func":"static int rsi_send_w9116_features(struct rsi_common *common)\n{\n\tstruct rsi_wlan_9116_features *w9116_features;\n\tu16 frame_len = sizeof(struct rsi_wlan_9116_features);\n\tstruct sk_buff *skb;\n\n\trsi_dbg(MGMT_TX_ZONE,\n\t\t\"%s: Sending wlan 9116 features\\n\", __func__);\n\n\tskb = dev_alloc_skb(frame_len);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\tmemset(skb->data, 0, frame_len);\n\n\tw9116_features = (struct rsi_wlan_9116_features *)skb->data;\n\n\tw9116_features->pll_mode = common->w9116_features.pll_mode;\n\tw9116_features->rf_type = common->w9116_features.rf_type;\n\tw9116_features->wireless_mode = common->w9116_features.wireless_mode;\n\tw9116_features->enable_ppe = common->w9116_features.enable_ppe;\n\tw9116_features->afe_type = common->w9116_features.afe_type;\n\tif (common->w9116_features.dpd)\n\t\tw9116_features->feature_enable |= cpu_to_le32(RSI_DPD);\n\tif (common->w9116_features.sifs_tx_enable)\n\t\tw9116_features->feature_enable |=\n\t\t\tcpu_to_le32(RSI_SIFS_TX_ENABLE);\n\tif (common->w9116_features.ps_options & RSI_DUTY_CYCLING)\n\t\tw9116_features->feature_enable |= cpu_to_le32(RSI_DUTY_CYCLING);\n\tif (common->w9116_features.ps_options & RSI_END_OF_FRAME)\n\t\tw9116_features->feature_enable |= cpu_to_le32(RSI_END_OF_FRAME);\n\tw9116_features->feature_enable |=\n\t\tcpu_to_le32((common->w9116_features.ps_options & ~0x3) << 2);\n\n\trsi_set_len_qno(&w9116_features->desc.desc_dword0.len_qno,\n\t\t\tframe_len - FRAME_DESC_SZ, RSI_WIFI_MGMT_Q);\n\tw9116_features->desc.desc_dword0.frame_type = FEATURES_ENABLE;\n\tskb_put(skb, frame_len);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":530,"total_token_length":766,"max_tokens_setting":1024}
+{"idx":300830,"func":"void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,\n\t\t       struct sk_buff_head *inputq)\n{\n\tu32 self = tipc_own_addr(net);\n\tstruct sk_buff *skb, *_skb;\n\tu32 portid, onode;\n\tstruct sk_buff_head tmpq;\n\tstruct list_head dports;\n\tstruct tipc_msg *hdr;\n\tstruct tipc_uaddr ua;\n\tint user, mtyp, hlen;\n\n\t__skb_queue_head_init(&tmpq);\n\tINIT_LIST_HEAD(&dports);\n\tua.addrtype = TIPC_SERVICE_RANGE;\n\n\t\/* tipc_skb_peek() increments the head skb's reference counter *\/\n\tskb = tipc_skb_peek(arrvq, &inputq->lock);\n\tfor (; skb; skb = tipc_skb_peek(arrvq, &inputq->lock)) {\n\t\thdr = buf_msg(skb);\n\t\tuser = msg_user(hdr);\n\t\tmtyp = msg_type(hdr);\n\t\thlen = skb_headroom(skb) + msg_hdr_sz(hdr);\n\t\tonode = msg_orignode(hdr);\n\t\tua.sr.type = msg_nametype(hdr);\n\t\tua.sr.lower = msg_namelower(hdr);\n\t\tua.sr.upper = msg_nameupper(hdr);\n\t\tif (onode == self)\n\t\t\tua.scope = TIPC_ANY_SCOPE;\n\t\telse\n\t\t\tua.scope = TIPC_CLUSTER_SCOPE;\n\n\t\tif (mtyp == TIPC_GRP_UCAST_MSG || user == GROUP_PROTOCOL) {\n\t\t\tspin_lock_bh(&inputq->lock);\n\t\t\tif (skb_peek(arrvq) == skb) {\n\t\t\t\t__skb_dequeue(arrvq);\n\t\t\t\t__skb_queue_tail(inputq, skb);\n\t\t\t}\n\t\t\tkfree_skb(skb);\n\t\t\tspin_unlock_bh(&inputq->lock);\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/* Group messages require exact scope match *\/\n\t\tif (msg_in_group(hdr)) {\n\t\t\tua.sr.lower = 0;\n\t\t\tua.sr.upper = ~0;\n\t\t\tua.scope = msg_lookup_scope(hdr);\n\t\t}\n\n\t\t\/* Create destination port list: *\/\n\t\ttipc_nametbl_lookup_mcast_sockets(net, &ua, &dports);\n\n\t\t\/* Clone message per destination *\/\n\t\twhile (tipc_dest_pop(&dports, NULL, &portid)) {\n\t\t\t_skb = __pskb_copy(skb, hlen, GFP_ATOMIC);\n\t\t\tif (_skb) {\n\t\t\t\tmsg_set_destport(buf_msg(_skb), portid);\n\t\t\t\t__skb_queue_tail(&tmpq, _skb);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpr_warn(\"Failed to clone mcast rcv buffer\\n\");\n\t\t}\n\t\t\/* Append clones to inputq only if skb is still head of arrvq *\/\n\t\tspin_lock_bh(&inputq->lock);\n\t\tif (skb_peek(arrvq) == skb) {\n\t\t\tskb_queue_splice_tail_init(&tmpq, inputq);\n\t\t\t\/* Decrement the skb's refcnt *\/\n\t\t\tkfree_skb(__skb_dequeue(arrvq));\n\t\t}\n\t\tspin_unlock_bh(&inputq->lock);\n\t\t__skb_queue_purge(&tmpq);\n\t\tkfree_skb(skb);\n\t}\n\ttipc_sk_rcv(net, inputq);\n}","target":0,"code_token_length":687,"total_token_length":923,"max_tokens_setting":1024}
+{"idx":257695,"func":"static void mod_wstunnel_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {\n    switch (cpv->k_id) { \/* index into static config_plugin_keys_t cpk[] *\/\n      case 0: \/* wstunnel.server *\/\n        if (cpv->vtype == T_CONFIG_LOCAL) {\n            gw_plugin_config * const gw = cpv->v.v;\n            pconf->gw.exts      = gw->exts;\n            pconf->gw.exts_auth = gw->exts_auth;\n            pconf->gw.exts_resp = gw->exts_resp;\n        }\n        break;\n      case 1: \/* wstunnel.balance *\/\n        \/*if (cpv->vtype == T_CONFIG_LOCAL)*\/\/*always true here for this param*\/\n            pconf->gw.balance = (int)cpv->v.u;\n        break;\n      case 2: \/* wstunnel.debug *\/\n        pconf->gw.debug = (int)cpv->v.u;\n        break;\n      case 3: \/* wstunnel.map-extensions *\/\n        pconf->gw.ext_mapping = cpv->v.a;\n        break;\n      case 4: \/* wstunnel.frame-type *\/\n        pconf->frame_type = cpv->v.u;\n        break;\n      case 5: \/* wstunnel.origins *\/\n        pconf->origins = cpv->v.a;\n        break;\n      case 6: \/* wstunnel.ping-interval *\/\n        pconf->ping_interval = cpv->v.shrt;\n        break;\n      default:\/* should not happen *\/\n        return;\n    }\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":343318,"func":"static int ul_handle_data(ULHandler * const ulhandler, off_t * const uploaded,\n                          const double ts_start)\n{\n    ssize_t readnb;\n    double required_sleep = 0.0;\n    int pollret;\n    int ret;\n\n    if (ulhandler->max_filesize >= (off_t) 0 &&\n        ulhandler->total_uploaded > ulhandler->max_filesize) {\n        addreply(552, MSG_ABORTED \" (quota)\");\n        return -2;\n    }\n    if (ulhandler->chunk_size > (off_t) ulhandler->sizeof_buf) {\n        ulhandler->chunk_size = ulhandler->max_chunk_size =\n            ulhandler->sizeof_buf;\n    }\n    if (ulhandler->tls_fd != NULL) {\n#ifdef WITH_TLS\n        readnb = SSL_read(ulhandler->tls_fd, ulhandler->buf,\n                          ulhandler->chunk_size);\n#else\n        abort();\n#endif\n    } else {\n        readnb = read(ulhandler->xferfd, ulhandler->buf,\n                      ulhandler->chunk_size);\n    }\n    if (readnb == (ssize_t) 0) {\n        return 2;\n    }\n    if (readnb < (ssize_t) 0) {\n        if (errno == EAGAIN || errno == EINTR) {\n            return 0;\n        }\n        addreply_noformat(451, MSG_DATA_READ_FAILED);\n        return -1;\n    }\n    if (ul_dowrite(ulhandler, ulhandler->buf, readnb, uploaded) != 0) {\n        addreply_noformat(452, MSG_WRITE_FAILED);\n        return -1;\n    }\n    ulhandler->cur_pos += *uploaded;\n#ifdef FTPWHO\n        if (shm_data_cur != NULL) {\n            shm_data_cur->download_current_size =\n                shm_data_cur->download_total_size = ulhandler->cur_pos;\n        }\n#endif\n    ulhandler->total_uploaded += *uploaded;\n    if (ulhandler->bandwidth > 0UL) {\n        ulhandler_throttle(ulhandler, *uploaded, ts_start, &required_sleep);\n        if (required_sleep > 0.0) {\n            repoll:\n            ulhandler->pfds_command.revents = 0;\n            pollret = poll(&ulhandler->pfds_command, 1, required_sleep * 1000.0);\n            if (pollret == 0) {\n                return 0;\n            }\n            if (pollret < 0) {\n                if (errno == EINTR) {\n                    goto repoll;\n                }\n                return -1;\n            }\n            if ((ulhandler->pfds_command.revents &\n                 (POLLERR | POLLHUP | POLLNVAL)) != 0) {\n                return -1;\n            }\n            if ((ulhandler->pfds_command.revents & (POLLIN | POLLPRI)) != 0) {\n                ret = ulhandler_handle_commands(ulhandler);\n                if (ret != 0) {\n                    return ret;\n                }\n                goto repoll;\n            }\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":660,"total_token_length":896,"max_tokens_setting":1024}
+{"idx":369166,"func":"\nstatic int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)\n{\n\tunsigned int to_submit;\n\tint ret = 0;\n\n\tto_submit = io_sqring_entries(ctx);\n\t\/* if we're handling multiple rings, cap submit size for fairness *\/\n\tif (cap_entries && to_submit > IORING_SQPOLL_CAP_ENTRIES_VALUE)\n\t\tto_submit = IORING_SQPOLL_CAP_ENTRIES_VALUE;\n\n\tif (!wq_list_empty(&ctx->iopoll_list) || to_submit) {\n\t\tconst struct cred *creds = NULL;\n\n\t\tif (ctx->sq_creds != current_cred())\n\t\t\tcreds = override_creds(ctx->sq_creds);\n\n\t\tmutex_lock(&ctx->uring_lock);\n\t\tif (!wq_list_empty(&ctx->iopoll_list))\n\t\t\tio_do_iopoll(ctx, true);\n\n\t\t\/*\n\t\t * Don't submit if refs are dying, good for io_uring_register(),\n\t\t * but also it is relied upon by io_ring_exit_work()\n\t\t *\/\n\t\tif (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)) &&\n\t\t    !(ctx->flags & IORING_SETUP_R_DISABLED))\n\t\t\tret = io_submit_sqes(ctx, to_submit);\n\t\tmutex_unlock(&ctx->uring_lock);\n\n\t\tif (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))\n\t\t\twake_up(&ctx->sqo_sq_wait);\n\t\tif (creds)\n\t\t\trevert_creds(creds);\n\t}\n\n\treturn ret;","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":343302,"func":"static int ul_dowrite(ULHandler * const ulhandler, const unsigned char *buf_,\n                      const size_t size_, off_t * const uploaded)\n{\n    size_t size = size_;\n    ssize_t written;\n    const unsigned char *buf = buf_;\n    unsigned char *unasciibuf = NULL;\n    int ret = 0;\n\n    if (size_ <= (size_t) 0U) {\n        *uploaded = 0;\n        return -1;\n    }\n#ifndef WITHOUT_ASCII\n    if (ulhandler->ascii_mode > 0) {\n        unsigned char *unasciibufpnt;\n        size_t z = (size_t) 0U;\n\n        if (size > (size_t) ulhandler->chunk_size ||\n            (unasciibuf = ALLOCA((size_t) ulhandler->chunk_size)) == NULL) {\n            return -1;\n        }\n        unasciibufpnt = unasciibuf;\n        do {\n            if (buf_[z] != (unsigned char) '\\r') {\n                *unasciibufpnt++ = buf_[z];\n            }\n            z++;\n        } while (z < size);\n        buf = unasciibuf;\n        size = (size_t) (unasciibufpnt - unasciibuf);\n    }\n#endif\n    written = safe_write(ulhandler->f, buf, size, -1);\n    ret = - (written != (ssize_t) size);\n    if (unasciibuf != NULL) {\n        ALLOCA_FREE(unasciibuf);\n    }\n    if (ret < 0) {\n        *uploaded = 0;\n    } else {\n        *uploaded = size;\n    }\n    return ret;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":247649,"func":"TEST_P(SslSocketTest, GetPeerCert) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n  require_client_certificate: true\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  std::string expected_peer_cert =\n      TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(\n          \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"));\n  testUtil(test_options.setExpectedSerialNumber(TEST_NO_SAN_CERT_SERIAL)\n               .setExpectedPeerIssuer(\n                   \"CN=Test CA,OU=Lyft Engineering,O=Lyft,L=San Francisco,ST=California,C=US\")\n               .setExpectedPeerSubject(\n                   \"CN=Test Server,OU=Lyft Engineering,O=Lyft,L=San Francisco,ST=California,C=US\")\n               .setExpectedLocalSubject(\n                   \"CN=Test Server,OU=Lyft Engineering,O=Lyft,L=San Francisco,ST=California,C=US\")\n               .setExpectedPeerCert(expected_peer_cert));\n}","target":0,"code_token_length":411,"total_token_length":647,"max_tokens_setting":1024}
+{"idx":247362,"func":"rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx)\n{\n    DIGEST_CTX ctx = rpmDigestDup(hashctx);\n    uint8_t *hash = NULL;\n    size_t hashlen = 0;\n    rpmRC res = RPMRC_FAIL; \/* assume failure *\/\n\n    if (sig == NULL || ctx == NULL)\n\tgoto exit;\n\n    if (sig->hash != NULL)\n\trpmDigestUpdate(ctx, sig->hash, sig->hashlen);\n\n    if (sig->version == 4) {\n\t\/* V4 trailer is six octets long (rfc4880) *\/\n\tuint8_t trailer[6];\n\tuint32_t nb = sig->hashlen;\n\tnb = htonl(nb);\n\ttrailer[0] = sig->version;\n\ttrailer[1] = 0xff;\n\tmemcpy(trailer+2, &nb, 4);\n\trpmDigestUpdate(ctx, trailer, sizeof(trailer));\n    }\n\n    rpmDigestFinal(ctx, (void **)&hash, &hashlen, 0);\n\n    \/* Compare leading 16 bits of digest for quick check. *\/\n    if (hash == NULL || memcmp(hash, sig->signhash16, 2) != 0)\n\tgoto exit;\n\n    \/*\n     * If we have a key, verify the signature for real. Otherwise we've\n     * done all we can, return NOKEY to indicate \"looks okay but dunno.\"\n     *\/\n    if (key && key->alg) {\n\tpgpDigAlg sa = sig->alg;\n\tpgpDigAlg ka = key->alg;\n\tif (sa && sa->verify) {\n\t    if (sa->verify(ka, sa, hash, hashlen, sig->hash_algo) == 0) {\n\t\tres = RPMRC_OK;\n\t    }\n\t}\n    } else {\n\tres = RPMRC_NOKEY;\n    }\n\nexit:\n    free(hash);\n    return res;\n\n}","target":0,"code_token_length":407,"total_token_length":643,"max_tokens_setting":1024}
+{"idx":344789,"func":"tun_open(int tun, int mode, char **ifname)\n{\n#if defined(CUSTOM_SYS_TUN_OPEN)\n\treturn (sys_tun_open(tun, mode, ifname));\n#elif defined(SSH_TUN_OPENBSD)\n\tstruct ifreq ifr;\n\tchar name[100];\n\tint fd = -1, sock;\n\tconst char *tunbase = \"tun\";\n\n\tif (ifname != NULL)\n\t\t*ifname = NULL;\n\n\tif (mode == SSH_TUNMODE_ETHERNET)\n\t\ttunbase = \"tap\";\n\n\t\/* Open the tunnel device *\/\n\tif (tun <= SSH_TUNID_MAX) {\n\t\tsnprintf(name, sizeof(name), \"\/dev\/%s%d\", tunbase, tun);\n\t\tfd = open(name, O_RDWR);\n\t} else if (tun == SSH_TUNID_ANY) {\n\t\tfor (tun = 100; tun >= 0; tun--) {\n\t\t\tsnprintf(name, sizeof(name), \"\/dev\/%s%d\",\n\t\t\t    tunbase, tun);\n\t\t\tif ((fd = open(name, O_RDWR)) >= 0)\n\t\t\t\tbreak;\n\t\t}\n\t} else {\n\t\tdebug_f(\"invalid tunnel %u\", tun);\n\t\treturn -1;\n\t}\n\n\tif (fd == -1) {\n\t\tdebug_f(\"%s open: %s\", name, strerror(errno));\n\t\treturn -1;\n\t}\n\n\tdebug_f(\"%s mode %d fd %d\", name, mode, fd);\n\n\t\/* Bring interface up if it is not already *\/\n\tsnprintf(ifr.ifr_name, sizeof(ifr.ifr_name), \"%s%d\", tunbase, tun);\n\tif ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1)\n\t\tgoto failed;\n\n\tif (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) {\n\t\tdebug_f(\"get interface %s flags: %s\", ifr.ifr_name,\n\t\t    strerror(errno));\n\t\tgoto failed;\n\t}\n\n\tif (!(ifr.ifr_flags & IFF_UP)) {\n\t\tifr.ifr_flags |= IFF_UP;\n\t\tif (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) {\n\t\t\tdebug_f(\"activate interface %s: %s\", ifr.ifr_name,\n\t\t\t    strerror(errno));\n\t\t\tgoto failed;\n\t\t}\n\t}\n\n\tif (ifname != NULL)\n\t\t*ifname = xstrdup(ifr.ifr_name);\n\n\tclose(sock);\n\treturn fd;\n\n failed:\n\tif (fd >= 0)\n\t\tclose(fd);\n\tif (sock >= 0)\n\t\tclose(sock);\n\treturn -1;\n#else\n\terror(\"Tunnel interfaces are not supported on this platform\");\n\treturn (-1);\n#endif\n}","target":0,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":261897,"func":"njs_encode_base64_core(njs_str_t *dst, const njs_str_t *src,\n    const u_char *basis, njs_bool_t padding)\n{\n   u_char  *d, *s, c0, c1, c2;\n   size_t  len;\n\n    len = src->length;\n    s = src->start;\n    d = dst->start;\n\n    while (len > 2) {\n        c0 = s[0];\n        c1 = s[1];\n        c2 = s[2];\n\n        *d++ = basis[c0 >> 2];\n        *d++ = basis[((c0 & 0x03) << 4) | (c1 >> 4)];\n        *d++ = basis[((c1 & 0x0f) << 2) | (c2 >> 6)];\n        *d++ = basis[c2 & 0x3f];\n\n        s += 3;\n        len -= 3;\n    }\n\n    if (len > 0) {\n        c0 = s[0];\n        *d++ = basis[c0 >> 2];\n\n        if (len == 1) {\n            *d++ = basis[(c0 & 0x03) << 4];\n            if (padding) {\n                *d++ = '=';\n                *d++ = '=';\n            }\n\n        } else {\n            c1 = s[1];\n\n            *d++ = basis[((c0 & 0x03) << 4) | (c1 >> 4)];\n            *d++ = basis[(c1 & 0x0f) << 2];\n\n            if (padding) {\n                *d++ = '=';\n            }\n        }\n\n    }\n\n    dst->length = d - dst->start;\n}","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":409521,"func":"stoptermcap(void)\n{\n    screen_stop_highlight();\n    reset_cterm_colors();\n    if (termcap_active)\n    {\n#ifdef FEAT_TERMRESPONSE\n# ifdef FEAT_GUI\n\tif (!gui.in_use && !gui.starting)\n# endif\n\t{\n\t    \/\/ May need to discard T_CRV, T_U7 or T_RBG response.\n\t    if (termrequest_any_pending())\n\t    {\n# ifdef UNIX\n\t\t\/\/ Give the terminal a chance to respond.\n\t\tmch_delay(100L, 0);\n# endif\n# ifdef TCIFLUSH\n\t\t\/\/ Discard data received but not read.\n\t\tif (exiting)\n\t\t    tcflush(fileno(stdin), TCIFLUSH);\n# endif\n\t    }\n\t    \/\/ Check for termcodes first, otherwise an external program may\n\t    \/\/ get them.\n\t    check_for_codes_from_term();\n\t}\n#endif\n\tMAY_WANT_TO_LOG_THIS;\n\n#if defined(UNIX) || defined(VMS)\n\t\/\/ Disable xterm's focus reporting mode if 'esckeys' is set.\n\tif (p_ek && *T_FD != NUL)\n\t    out_str(T_FD);\n#endif\n\n\tout_str(T_BD);\t\t\t\/\/ disable bracketed paste mode\n\tout_str(T_KE);\t\t\t\/\/ stop \"keypad transmit\" mode\n\tout_flush();\n\ttermcap_active = FALSE;\n\tcursor_on();\t\t\t\/\/ just in case it is still off\n\tout_str(T_CTE);\t\t\t\/\/ stop \"raw\" mode\n\tout_str(T_TE);\t\t\t\/\/ stop termcap mode\n\tscreen_start();\t\t\t\/\/ don't know where cursor is now\n\tout_flush();\n    }\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":269521,"func":"static MagickBooleanType EncodeLabImage(Image *image,ExceptionInfo *exception)\n{\n  CacheView\n    *image_view;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    y;\n\n  status=MagickTrue;\n  image_view=AcquireAuthenticCacheView(image,exception);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    Quantum\n      *magick_restrict q;\n\n    ssize_t\n      x;\n\n    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      {\n        status=MagickFalse;\n        break;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      double\n        a,\n        b;\n\n      a=QuantumScale*GetPixela(image,q)-0.5;\n      if (a < 0.0)\n        a+=1.0;\n      b=QuantumScale*GetPixelb(image,q)-0.5;\n      if (b < 0.0)\n        b+=1.0;\n      SetPixela(image,QuantumRange*a,q);\n      SetPixelb(image,QuantumRange*b,q);\n      q+=GetPixelChannels(image);\n    }\n    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n      {\n        status=MagickFalse;\n        break;\n      }\n  }\n  image_view=DestroyCacheView(image_view);\n  return(status);\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":229232,"func":"future<std::unique_ptr<cql_server::response>> cql_server::connection::process_auth_response(uint16_t stream, request_reader in, service::client_state& client_state,\n        tracing::trace_state_ptr trace_state) {\n    ++_server._stats.auth_responses;\n    auto sasl_challenge = client_state.get_auth_service()->underlying_authenticator().new_sasl_challenge();\n    auto buf = in.read_raw_bytes_view(in.bytes_left());\n    auto challenge = sasl_challenge->evaluate_response(buf);\n    if (sasl_challenge->is_complete()) {\n        return sasl_challenge->get_authenticated_user().then([this, sasl_challenge, stream, &client_state, challenge = std::move(challenge), trace_state](auth::authenticated_user user) mutable {\n            client_state.set_login(std::move(user));\n            auto f = client_state.check_user_can_login();\n            f = f.then([&client_state] {\n                return client_state.maybe_update_per_service_level_params();\n            });\n            return f.then([this, stream, &client_state, challenge = std::move(challenge), trace_state]() mutable {\n                return make_ready_future<std::unique_ptr<cql_server::response>>(make_auth_success(stream, std::move(challenge), trace_state));\n            });\n        });\n    }\n    return make_ready_future<std::unique_ptr<cql_server::response>>(make_auth_challenge(stream, std::move(challenge), trace_state));\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":418779,"func":"ins_mouse(int c)\n{\n    pos_T\ttpos;\n    win_T\t*old_curwin = curwin;\n\n# ifdef FEAT_GUI\n    \/\/ When GUI is active, also move\/paste when 'mouse' is empty\n    if (!gui.in_use)\n# endif\n\tif (!mouse_has(MOUSE_INSERT))\n\t    return;\n\n    undisplay_dollar();\n    tpos = curwin->w_cursor;\n    if (do_mouse(NULL, c, BACKWARD, 1L, 0))\n    {\n\twin_T\t*new_curwin = curwin;\n\n\tif (curwin != old_curwin && win_valid(old_curwin))\n\t{\n\t    \/\/ Mouse took us to another window.  We need to go back to the\n\t    \/\/ previous one to stop insert there properly.\n\t    curwin = old_curwin;\n\t    curbuf = curwin->w_buffer;\n#ifdef FEAT_JOB_CHANNEL\n\t    if (bt_prompt(curbuf))\n\t\t\/\/ Restart Insert mode when re-entering the prompt buffer.\n\t\tcurbuf->b_prompt_insert = 'A';\n#endif\n\t}\n\tstart_arrow(curwin == old_curwin ? &tpos : NULL);\n\tif (curwin != new_curwin && win_valid(new_curwin))\n\t{\n\t    curwin = new_curwin;\n\t    curbuf = curwin->w_buffer;\n\t}\n\tset_can_cindent(TRUE);\n    }\n\n    \/\/ redraw status lines (in case another window became active)\n    redraw_statuslines();\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":247699,"func":"TEST_P(SslReadBufferLimitTest, SmallReadsIntoSameSlice) {\n  \/\/ write_size * num_writes must be large enough to cause buffer reserving fragmentation,\n  \/\/ but smaller than one reservation so the expected slice to be 1.\n  const uint32_t write_size = 1;\n  const uint32_t num_writes = 12 * 1024;\n  const uint32_t read_buffer_limit = write_size * num_writes;\n  const uint32_t expected_chunk_size = write_size * num_writes;\n\n  initialize();\n\n  EXPECT_CALL(listener_callbacks_, onAccept_(_))\n      .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {\n        server_connection_ = dispatcher_->createServerConnection(\n            std::move(socket), server_ssl_socket_factory_->createTransportSocket(nullptr),\n            stream_info_);\n        server_connection_->setBufferLimits(read_buffer_limit);\n        server_connection_->addConnectionCallbacks(server_callbacks_);\n        server_connection_->addReadFilter(read_filter_);\n        EXPECT_EQ(\"\", server_connection_->nextProtocol());\n        EXPECT_EQ(read_buffer_limit, server_connection_->bufferLimit());\n      }));\n\n  EXPECT_CALL(client_callbacks_, onEvent(Network::ConnectionEvent::Connected))\n      .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { dispatcher_->exit(); }));\n  dispatcher_->run(Event::Dispatcher::RunType::Block);\n\n  uint32_t filter_seen = 0;\n\n  EXPECT_CALL(*read_filter_, onNewConnection());\n  EXPECT_CALL(*read_filter_, onData(_, _))\n      .WillRepeatedly(Invoke([&](Buffer::Instance& data, bool) -> Network::FilterStatus {\n        EXPECT_GE(expected_chunk_size, data.length());\n        EXPECT_EQ(1, data.getRawSlices().size());\n        filter_seen += data.length();\n        data.drain(data.length());\n        if (filter_seen == (write_size * num_writes)) {\n          server_connection_->close(Network::ConnectionCloseType::FlushWrite);\n        }\n        return Network::FilterStatus::StopIteration;\n      }));\n\n  EXPECT_CALL(client_callbacks_, onEvent(Network::ConnectionEvent::RemoteClose))\n      .WillOnce(Invoke([&](Network::ConnectionEvent) -> void {\n        EXPECT_EQ((write_size * num_writes), filter_seen);\n        dispatcher_->exit();\n      }));\n\n  for (uint32_t i = 0; i < num_writes; i++) {\n    Buffer::OwnedImpl data(std::string(write_size, 'a'));\n    client_connection_->write(data, false);\n  }\n\n  dispatcher_->run(Event::Dispatcher::RunType::Block);\n}","target":0,"code_token_length":537,"total_token_length":773,"max_tokens_setting":1024}
+{"idx":238609,"func":"static void scalar32_min_max_xor(struct bpf_reg_state *dst_reg,\n\t\t\t\t struct bpf_reg_state *src_reg)\n{\n\tbool src_known = tnum_subreg_is_const(src_reg->var_off);\n\tbool dst_known = tnum_subreg_is_const(dst_reg->var_off);\n\tstruct tnum var32_off = tnum_subreg(dst_reg->var_off);\n\ts32 smin_val = src_reg->s32_min_value;\n\n\tif (src_known && dst_known) {\n\t\t__mark_reg32_known(dst_reg, var32_off.value);\n\t\treturn;\n\t}\n\n\t\/* We get both minimum and maximum from the var32_off. *\/\n\tdst_reg->u32_min_value = var32_off.value;\n\tdst_reg->u32_max_value = var32_off.value | var32_off.mask;\n\n\tif (dst_reg->s32_min_value >= 0 && smin_val >= 0) {\n\t\t\/* XORing two positive sign numbers gives a positive,\n\t\t * so safe to cast u32 result into s32.\n\t\t *\/\n\t\tdst_reg->s32_min_value = dst_reg->u32_min_value;\n\t\tdst_reg->s32_max_value = dst_reg->u32_max_value;\n\t} else {\n\t\tdst_reg->s32_min_value = S32_MIN;\n\t\tdst_reg->s32_max_value = S32_MAX;\n\t}\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":195296,"func":"    void publish(Topic *iterator, size_t start, size_t stop, std::string_view topic, std::pair<std::string_view, std::string_view> message) {\n        \/* If we already have 64 triggered topics make sure to drain it here *\/\n        if (numTriggeredTopics == 64) {\n            drain();\n        }\n\n        \/* Iterate over all segments in given topic *\/\n        for (; stop != std::string::npos; start = stop + 1) {\n            stop = topic.find('\/', start);\n            std::string_view segment = topic.substr(start, stop - start);\n\n            \/* It is very important to disallow wildcards when publishing.\n             * We will not catch EVERY misuse this lazy way, but enough to hinder\n             * explosive recursion.\n             * Terminating wildcards MAY still get triggered along the way, if for\n             * instace the error is found late while iterating the topic segments. *\/\n            if (segment.length() == 1) {\n                if (segment[0] == '+' || segment[0] == '#') {\n                    return;\n                }\n            }\n\n            \/* Do we have a terminating wildcard child? *\/\n            if (iterator->terminatingWildcardChild) {\n                iterator->terminatingWildcardChild->messages[messageId] = message;\n\n                \/* Add this topic to triggered *\/\n                if (!iterator->terminatingWildcardChild->triggered) {\n                    triggeredTopics[numTriggeredTopics++] = iterator->terminatingWildcardChild;\n                    iterator->terminatingWildcardChild->triggered = true;\n                }\n            }\n\n            \/* Do we have a wildcard child? *\/\n            if (iterator->wildcardChild) {\n                publish(iterator->wildcardChild, stop + 1, stop, topic, message);\n            }\n\n            std::map<std::string_view, Topic *>::iterator it = iterator->children.find(segment);\n            if (it == iterator->children.end()) {\n                \/* Stop trying to match by exact string *\/\n                return;\n            }\n\n            iterator = it->second;\n        }\n\n        \/* If we went all the way we matched exactly *\/\n        iterator->messages[messageId] = message;\n\n        \/* Add this topic to triggered *\/\n        if (!iterator->triggered) {\n            triggeredTopics[numTriggeredTopics++] = iterator;\n            iterator->triggered = true;\n        }\n    }","target":1,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":472123,"func":"int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)\n{\n\tstruct cgroup_fs_context *ctx = cgroup_fc2context(fc);\n\tstruct cgroup_subsys *ss;\n\tstruct fs_parse_result result;\n\tint opt, i;\n\n\topt = fs_parse(fc, cgroup1_fs_parameters, param, &result);\n\tif (opt == -ENOPARAM) {\n\t\tif (strcmp(param->key, \"source\") == 0) {\n\t\t\tif (param->type != fs_value_is_string)\n\t\t\t\treturn invalf(fc, \"Non-string source\");\n\t\t\tif (fc->source)\n\t\t\t\treturn invalf(fc, \"Multiple sources not supported\");\n\t\t\tfc->source = param->string;\n\t\t\tparam->string = NULL;\n\t\t\treturn 0;\n\t\t}\n\t\tfor_each_subsys(ss, i) {\n\t\t\tif (strcmp(param->key, ss->legacy_name))\n\t\t\t\tcontinue;\n\t\t\tif (!cgroup_ssid_enabled(i) || cgroup1_ssid_disabled(i))\n\t\t\t\treturn invalfc(fc, \"Disabled controller '%s'\",\n\t\t\t\t\t       param->key);\n\t\t\tctx->subsys_mask |= (1 << i);\n\t\t\treturn 0;\n\t\t}\n\t\treturn invalfc(fc, \"Unknown subsys name '%s'\", param->key);\n\t}\n\tif (opt < 0)\n\t\treturn opt;\n\n\tswitch (opt) {\n\tcase Opt_none:\n\t\t\/* Explicitly have no subsystems *\/\n\t\tctx->none = true;\n\t\tbreak;\n\tcase Opt_all:\n\t\tctx->all_ss = true;\n\t\tbreak;\n\tcase Opt_noprefix:\n\t\tctx->flags |= CGRP_ROOT_NOPREFIX;\n\t\tbreak;\n\tcase Opt_clone_children:\n\t\tctx->cpuset_clone_children = true;\n\t\tbreak;\n\tcase Opt_cpuset_v2_mode:\n\t\tctx->flags |= CGRP_ROOT_CPUSET_V2_MODE;\n\t\tbreak;\n\tcase Opt_xattr:\n\t\tctx->flags |= CGRP_ROOT_XATTR;\n\t\tbreak;\n\tcase Opt_release_agent:\n\t\t\/* Specifying two release agents is forbidden *\/\n\t\tif (ctx->release_agent)\n\t\t\treturn invalfc(fc, \"release_agent respecified\");\n\t\tctx->release_agent = param->string;\n\t\tparam->string = NULL;\n\t\tbreak;\n\tcase Opt_name:\n\t\t\/* blocked by boot param? *\/\n\t\tif (cgroup_no_v1_named)\n\t\t\treturn -ENOENT;\n\t\t\/* Can't specify an empty name *\/\n\t\tif (!param->size)\n\t\t\treturn invalfc(fc, \"Empty name\");\n\t\tif (param->size > MAX_CGROUP_ROOT_NAMELEN - 1)\n\t\t\treturn invalfc(fc, \"Name too long\");\n\t\t\/* Must match [\\w.-]+ *\/\n\t\tfor (i = 0; i < param->size; i++) {\n\t\t\tchar c = param->string[i];\n\t\t\tif (isalnum(c))\n\t\t\t\tcontinue;\n\t\t\tif ((c == '.') || (c == '-') || (c == '_'))\n\t\t\t\tcontinue;\n\t\t\treturn invalfc(fc, \"Invalid name\");\n\t\t}\n\t\t\/* Specifying two names is forbidden *\/\n\t\tif (ctx->name)\n\t\t\treturn invalfc(fc, \"name respecified\");\n\t\tctx->name = param->string;\n\t\tparam->string = NULL;\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":230973,"func":"eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c)\n{\n  struct RProc *p;\n  mrb_callinfo *ci;\n  int nregs;\n\n  check_block(mrb, blk);\n  ci = mrb->c->ci;\n  if (ci->cci == CINFO_DIRECT) {\n    return mrb_yield_with_class(mrb, blk, 1, &self, self, c);\n  }\n  ci->u.target_class = c;\n  p = mrb_proc_ptr(blk);\n  mrb_vm_ci_proc_set(ci, p);\n  ci->n = 1;\n  ci->nk = 0;\n  ci->mid = ci[-1].mid;\n  if (MRB_PROC_CFUNC_P(p)) {\n    mrb_stack_extend(mrb, 4);\n    mrb->c->ci->stack[0] = self;\n    mrb->c->ci->stack[1] = self;\n    mrb->c->ci->stack[2] = mrb_nil_value();\n    return MRB_PROC_CFUNC(p)(mrb, self);\n  }\n  nregs = p->body.irep->nregs;\n  if (nregs < 4) nregs = 4;\n  mrb_stack_extend(mrb, nregs);\n  mrb->c->ci->stack[0] = self;\n  mrb->c->ci->stack[1] = self;\n  stack_clear(mrb->c->ci->stack+2, nregs-2);\n  ci = cipush(mrb, 0, 0, NULL, NULL, 0, 0);\n\n  return self;\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":318773,"func":"drill_add_drill_hole (gerbv_image_t *image, drill_state_t *state,\n\t\tgerbv_drill_stats_t *stats, gerbv_net_t *curr_net)\n{\n    gerbv_render_size_t *bbox;\n    double r;\n\n    \/* Add one to drill stats  for the current tool *\/\n    drill_stats_increment_drill_counter(image->drill_stats->drill_list,\n\t    state->current_tool);\n\n    curr_net->next = g_new0(gerbv_net_t, 1);\n    if (curr_net->next == NULL)\n\tGERB_FATAL_ERROR(\"malloc curr_net->next failed in %s()\",\n\t\t\t__FUNCTION__);\n\n    curr_net = curr_net->next;\n    curr_net->layer = image->layers;\n    curr_net->state = image->states;\n    curr_net->start_x = state->curr_x;\n    curr_net->start_y = state->curr_y;\n    \/* KLUDGE. This function isn't allowed to return anything\n       but inches *\/\n    if(state->unit == GERBV_UNIT_MM) {\n\tcurr_net->start_x \/= 25.4;\n\tcurr_net->start_y \/= 25.4;\n\t\/* KLUDGE. All images, regardless of input format,\n\t   are returned in INCH format *\/\n\tcurr_net->state->unit = GERBV_UNIT_INCH;\n    }\n\n    curr_net->stop_x = curr_net->start_x - state->origin_x;\n    curr_net->stop_y = curr_net->start_y - state->origin_y;\n    curr_net->aperture = state->current_tool;\n    curr_net->aperture_state = GERBV_APERTURE_STATE_FLASH;\n\n    \/* Check if aperture is set. Ignore the below instead of\n       causing SEGV... *\/\n    if(image->aperture[state->current_tool] == NULL)\n\treturn curr_net;\n\n    bbox = &curr_net->boundingBox;\n    r = image->aperture[state->current_tool]->parameter[0] \/ 2;\n\n    \/* Set boundingBox *\/\n    bbox->left   = curr_net->start_x - r;\n    bbox->right  = curr_net->start_x + r;\n    bbox->bottom = curr_net->start_y - r;\n    bbox->top    = curr_net->start_y + r;\n\n    drill_update_image_info_min_max_from_bbox(image->info, bbox);\n\n    return curr_net;\n}","target":0,"code_token_length":497,"total_token_length":733,"max_tokens_setting":1024}
+{"idx":369301,"func":"\nstatic int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,\n\t\t\t\t   unsigned int nr_args, u64 __user *tags)\n{\n\tstruct page *last_hpage = NULL;\n\tstruct io_rsrc_data *data;\n\tint i, ret;\n\tstruct iovec iov;\n\n\tif (ctx->user_bufs)\n\t\treturn -EBUSY;\n\tif (!nr_args || nr_args > IORING_MAX_REG_BUFFERS)\n\t\treturn -EINVAL;\n\tret = io_rsrc_node_switch_start(ctx);\n\tif (ret)\n\t\treturn ret;\n\tret = io_rsrc_data_alloc(ctx, io_rsrc_buf_put, tags, nr_args, &data);\n\tif (ret)\n\t\treturn ret;\n\tret = io_buffers_map_alloc(ctx, nr_args);\n\tif (ret) {\n\t\tio_rsrc_data_free(data);\n\t\treturn ret;\n\t}\n\n\tfor (i = 0; i < nr_args; i++, ctx->nr_user_bufs++) {\n\t\tret = io_copy_iov(ctx, &iov, arg, i);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = io_buffer_validate(&iov);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tif (!iov.iov_base && *io_get_tag_slot(data, i)) {\n\t\t\tret = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\n\t\tret = io_sqe_buffer_register(ctx, &iov, &ctx->user_bufs[i],\n\t\t\t\t\t     &last_hpage);\n\t\tif (ret)\n\t\t\tbreak;\n\t}\n\n\tWARN_ON_ONCE(ctx->buf_data);\n\n\tctx->buf_data = data;\n\tif (ret)\n\t\t__io_sqe_buffers_unregister(ctx);\n\telse\n\t\tio_rsrc_node_switch(ctx, NULL);\n\treturn ret;","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":218809,"func":"MagickExport void XProgressMonitorWidget(Display *display,XWindows *windows,\n  const char *task,const MagickOffsetType offset,const MagickSizeType span)\n{\n  unsigned int\n    width;\n\n  XEvent\n    event;\n\n  assert(display != (Display *) NULL);\n  assert(windows != (XWindows *) NULL);\n  assert(task != (const char *) NULL);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",task);\n  if (span == 0)\n    return;\n  \/*\n    Update image windows if there is a pending expose event.\n  *\/\n  while (XCheckTypedWindowEvent(display,windows->command.id,Expose,&event))\n    (void) XCommandWidget(display,windows,(const char *const *) NULL,&event);\n  while (XCheckTypedWindowEvent(display,windows->image.id,Expose,&event))\n    XRefreshWindow(display,&windows->image,&event);\n  while (XCheckTypedWindowEvent(display,windows->info.id,Expose,&event))\n    if (monitor_info.text != (char *) NULL)\n      XInfoWidget(display,windows,monitor_info.text);\n  \/*\n    Draw progress monitor bar to represent percent completion of a task.\n  *\/\n  if ((windows->info.mapped == MagickFalse) || (task != monitor_info.text))\n    XInfoWidget(display,windows,task);\n  width=(unsigned int) (((offset+1)*(windows->info.width-\n    (2*monitor_info.x)))\/span);\n  if (width < monitor_info.width)\n    {\n      monitor_info.raised=MagickTrue;\n      XDrawWidgetText(display,&windows->info,&monitor_info);\n      monitor_info.raised=MagickFalse;\n    }\n  monitor_info.width=width;\n  XDrawWidgetText(display,&windows->info,&monitor_info);\n  (void) XFlush(display);\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":269503,"func":"static MagickBooleanType DecodeLabImage(Image *image,ExceptionInfo *exception)\n{\n  CacheView\n    *image_view;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    y;\n\n  status=MagickTrue;\n  image_view=AcquireAuthenticCacheView(image,exception);\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    Quantum\n      *magick_restrict q;\n\n    ssize_t\n      x;\n\n    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);\n    if (q == (Quantum *) NULL)\n      {\n        status=MagickFalse;\n        break;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      double\n        a,\n        b;\n\n      a=QuantumScale*GetPixela(image,q)+0.5;\n      if (a > 1.0)\n        a-=1.0;\n      b=QuantumScale*GetPixelb(image,q)+0.5;\n      if (b > 1.0)\n        b-=1.0;\n      SetPixela(image,QuantumRange*a,q);\n      SetPixelb(image,QuantumRange*b,q);\n      q+=GetPixelChannels(image);\n    }\n    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)\n      {\n        status=MagickFalse;\n        break;\n      }\n  }\n  image_view=DestroyCacheView(image_view);\n  return(status);\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":231650,"func":"TEST_P(\n    QuicServerTransportPendingDataTest,\n    TestNoCipherProcessPendingOneRttData) {\n  server->getNonConstConn().qLogger =\n      std::make_shared<quic::FileQLogger>(VantagePoint::Server);\n  recvClientHello();\n  auto data = IOBuf::copyBuffer(\"bad data\");\n  StreamId streamId = 2;\n  \/\/ Write packet with zero rtt keys\n  auto packetData = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      streamId,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/,\n      folly::none,\n      false));\n  deliverData(std::move(packetData));\n  EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);\n  EXPECT_EQ(server->getConn().pendingOneRttData->size(), 1);\n\n  recvClientFinished();\n  EXPECT_EQ(server->getConn().streamManager->streamCount(), 1);\n  EXPECT_EQ(server->getConn().pendingZeroRttData, nullptr);\n  EXPECT_EQ(server->getConn().pendingOneRttData, nullptr);\n  EXPECT_EQ(\n      server->getConn().qLogger->scid, server->getConn().serverConnectionId);\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":500671,"func":"static sftp_attributes sftp_xstat(sftp_session sftp, const char *path,\n    int param) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  ssh_string pathstr;\n  ssh_buffer buffer;\n  uint32_t id;\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return NULL;\n  }\n\n  pathstr = ssh_string_from_char(path);\n  if (pathstr == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return NULL;\n  }\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, pathstr) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    ssh_string_free(pathstr);\n    return NULL;\n  }\n  if (sftp_packet_write(sftp, param, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(pathstr);\n    return NULL;\n  }\n  ssh_buffer_free(buffer);\n  ssh_string_free(pathstr);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      return NULL;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  if (msg->packet_type == SSH_FXP_ATTRS) {\n    sftp_attributes attr = sftp_parse_attr(sftp, msg->payload, 0);\n    sftp_message_free(msg);\n\n    return attr;\n  } else if (msg->packet_type == SSH_FXP_STATUS) {\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return NULL;\n    }\n    sftp_set_error(sftp, status->status);\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n    return NULL;\n  }\n  ssh_set_error(sftp->session, SSH_FATAL,\n      \"Received mesg %d during stat()\", msg->packet_type);\n  sftp_message_free(msg);\n\n  return NULL;\n}","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":508383,"func":"Locked_tables_list::init_locked_tables(THD *thd)\n{\n  DBUG_ASSERT(thd->locked_tables_mode == LTM_NONE);\n  DBUG_ASSERT(m_locked_tables == NULL);\n  DBUG_ASSERT(m_reopen_array == NULL);\n  DBUG_ASSERT(m_locked_tables_count == 0);\n\n  for (TABLE *table= thd->open_tables; table;\n       table= table->next, m_locked_tables_count++)\n  {\n    TABLE_LIST *src_table_list= table->pos_in_table_list;\n    char *db, *table_name, *alias;\n    size_t db_len=         table->s->db.length;\n    size_t table_name_len= table->s->table_name.length;\n    size_t alias_len=      table->alias.length();\n    TABLE_LIST *dst_table_list;\n\n    if (! multi_alloc_root(&m_locked_tables_root,\n                           &dst_table_list, sizeof(*dst_table_list),\n                           &db, db_len + 1,\n                           &table_name, table_name_len + 1,\n                           &alias, alias_len + 1,\n                           NullS))\n    {\n      reset();\n      return TRUE;\n    }\n\n    memcpy(db,         table->s->db.str, db_len + 1);\n    memcpy(table_name, table->s->table_name.str, table_name_len + 1);\n    strmake(alias,     table->alias.ptr(), alias_len);\n    dst_table_list->init_one_table(db, db_len, table_name, table_name_len,\n                                   alias, table->reginfo.lock_type);\n    dst_table_list->table= table;\n    dst_table_list->mdl_request.ticket= src_table_list->mdl_request.ticket;\n\n    \/* Link last into the list of tables *\/\n    *(dst_table_list->prev_global= m_locked_tables_last)= dst_table_list;\n    m_locked_tables_last= &dst_table_list->next_global;\n    table->pos_in_locked_tables= dst_table_list;\n  }\n  if (m_locked_tables_count)\n  {\n    \/**\n      Allocate an auxiliary array to pass to mysql_lock_tables()\n      in reopen_tables(). reopen_tables() is a critical\n      path and we don't want to complicate it with extra allocations.\n    *\/\n    m_reopen_array= (TABLE_LIST**)alloc_root(&m_locked_tables_root,\n                                             sizeof(TABLE_LIST*) *\n                                             (m_locked_tables_count+1));\n    if (m_reopen_array == NULL)\n    {\n      reset();\n      return TRUE;\n    }\n  }\n\n  TRANSACT_TRACKER(add_trx_state(thd, TX_LOCKED_TABLES));\n\n  thd->enter_locked_tables_mode(LTM_LOCK_TABLES);\n\n  return FALSE;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":512251,"func":"bool Arg_comparator::set_cmp_func_real()\n{\n  if ((((*a)->result_type() == DECIMAL_RESULT && !(*a)->const_item() &&\n        (*b)->result_type() == STRING_RESULT  &&  (*b)->const_item()) ||\n      ((*b)->result_type() == DECIMAL_RESULT && !(*b)->const_item() &&\n       (*a)->result_type() == STRING_RESULT  &&  (*a)->const_item())))\n  {\n    \/*\n     <non-const decimal expression> <cmp> <const string expression>\n     or\n     <const string expression> <cmp> <non-const decimal expression>\n\n     Do comparison as decimal rather than float, in order not to lose precision.\n    *\/\n    m_compare_handler= &type_handler_newdecimal;\n    return set_cmp_func_decimal();\n  }\n\n  THD *thd= current_thd;\n  func= is_owner_equal_func() ? &Arg_comparator::compare_e_real :\n                                &Arg_comparator::compare_real;\n  if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)\n  {\n    precision= 5 \/ log_10[MY_MAX((*a)->decimals, (*b)->decimals) + 1];\n    if (func == &Arg_comparator::compare_real)\n      func= &Arg_comparator::compare_real_fixed;\n    else if (func == &Arg_comparator::compare_e_real)\n      func= &Arg_comparator::compare_e_real_fixed;\n  }\n  a= cache_converted_constant(thd, a, &a_cache, compare_type_handler());\n  b= cache_converted_constant(thd, b, &b_cache, compare_type_handler());\n  return false;\n}","target":0,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":246719,"func":"static u32 do_import_sub()\n{\n\t\/* We import the subtitle file,\n\t   i.e. we parse it and store the content as samples of a 3GPP Timed Text track in an ISO file,\n\t   possibly for later export (e.g. when converting SRT to TTXT, ...) *\/\n#ifndef GPAC_DISABLE_MEDIA_IMPORT\n\tGF_Err e;\n\tGF_MediaImporter import;\n\t\/* Prepare the importer *\/\n\tfile = gf_isom_open(\"ttxt_convert\", GF_ISOM_OPEN_WRITE, NULL);\n\tif (timescale && file) gf_isom_set_timescale(file, timescale);\n\n\tmemset(&import, 0, sizeof(GF_MediaImporter));\n\timport.dest = file;\n\timport.in_name = inName;\n\t\/* Start the import *\/\n\te = gf_media_import(&import);\n\tif (e) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Error importing %s: %s\\n\", inName, gf_error_to_string(e)));\n\t\tgf_isom_delete(file);\n\t\tgf_file_delete(\"ttxt_convert\");\n\t\treturn mp4box_cleanup(1);\n\t}\n\t\/* Prepare the export *\/\n\tstrcpy(outfile, inName);\n\tif (strchr(outfile, '.')) {\n\t\twhile (outfile[strlen(outfile)-1] != '.') outfile[strlen(outfile)-1] = 0;\n\t\toutfile[strlen(outfile)-1] = 0;\n\t}\n#ifndef GPAC_DISABLE_ISOM_DUMP\n\t\/* Start the export of the track #1, in the appropriate dump type, indicating it's a conversion *\/\n\tdump_isom_timed_text(file, gf_isom_get_track_id(file, 1),\n\t\t\t\t\t\t  dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE,\n\t\t\t\t\t\t  GF_TRUE,\n\t\t\t\t\t\t  (import_subtitle==2) ? GF_TEXTDUMPTYPE_SVG : (dump_srt ? GF_TEXTDUMPTYPE_SRT : GF_TEXTDUMPTYPE_TTXT));\n#endif\n\t\/* Clean the importer *\/\n\tgf_isom_delete(file);\n\tgf_file_delete(\"ttxt_convert\");\n\tif (e) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Error converting %s: %s\\n\", inName, gf_error_to_string(e)));\n\t\treturn mp4box_cleanup(1);\n\t}\n\treturn mp4box_cleanup(0);\n#else\n\tM4_LOG(GF_LOG_ERROR, (\"Feature not supported\\n\"));\n\treturn mp4box_cleanup(1);\n#endif\n}","target":0,"code_token_length":506,"total_token_length":742,"max_tokens_setting":1024}
+{"idx":500679,"func":"int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr) {\n  uint32_t flags = (attr ? attr->flags : 0);\n\n  flags &= (SSH_FILEXFER_ATTR_SIZE | SSH_FILEXFER_ATTR_UIDGID |\n      SSH_FILEXFER_ATTR_PERMISSIONS | SSH_FILEXFER_ATTR_ACMODTIME);\n\n  if (buffer_add_u32(buffer, htonl(flags)) < 0) {\n    return -1;\n  }\n\n  if (attr) {\n    if (flags & SSH_FILEXFER_ATTR_SIZE) {\n      if (buffer_add_u64(buffer, htonll(attr->size)) < 0) {\n        return -1;\n      }\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_UIDGID) {\n      if (buffer_add_u32(buffer,htonl(attr->uid)) < 0 ||\n          buffer_add_u32(buffer,htonl(attr->gid)) < 0) {\n        return -1;\n      }\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_PERMISSIONS) {\n      if (buffer_add_u32(buffer, htonl(attr->permissions)) < 0) {\n        return -1;\n      }\n    }\n\n    if (flags & SSH_FILEXFER_ATTR_ACMODTIME) {\n      if (buffer_add_u32(buffer, htonl(attr->atime)) < 0 ||\n          buffer_add_u32(buffer, htonl(attr->mtime)) < 0) {\n        return -1;\n      }\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":353164,"func":"static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest,\n\t\t\t\t    SplashColorPtr blend, SplashColorMode cm) {\n  int i;\n\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n    }\n  }\n#endif\n  {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      blend[i] = src[i] < 0x80\n                   ? (dest[i] * 2 * src[i]) \/ 255\n                   : 255 - 2 * ((255 - dest[i]) * (255 - src[i])) \/ 255;\n    }\n  }\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n      blend[i] = 255 - blend[i];\n    }\n  }\n#endif\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":369215,"func":"static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)\n{\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct file *file = req->file;\n\tint ret;\n\n\tif (unlikely(!file || !(file->f_mode & mode)))\n\t\treturn -EBADF;\n\n\tif (!io_req_ffs_set(req))\n\t\treq->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;\n\n\tkiocb->ki_flags = iocb_flags(file);\n\tret = kiocb_set_rw_flags(kiocb, req->rw.flags);\n\tif (unlikely(ret))\n\t\treturn ret;\n\n\t\/*\n\t * If the file is marked O_NONBLOCK, still allow retry for it if it\n\t * supports async. Otherwise it's impossible to use O_NONBLOCK files\n\t * reliably. If not, or it IOCB_NOWAIT is set, don't retry.\n\t *\/\n\tif ((kiocb->ki_flags & IOCB_NOWAIT) ||\n\t    ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req)))\n\t\treq->flags |= REQ_F_NOWAIT;\n\n\tif (ctx->flags & IORING_SETUP_IOPOLL) {\n\t\tif (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tkiocb->private = NULL;\n\t\tkiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE;\n\t\tkiocb->ki_complete = io_complete_rw_iopoll;\n\t\treq->iopoll_completed = 0;\n\t} else {\n\t\tif (kiocb->ki_flags & IOCB_HIPRI)\n\t\t\treturn -EINVAL;\n\t\tkiocb->ki_complete = io_complete_rw;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":247566,"func":"TEST_P(SslSocketTest, RevokedCertificate) {\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      crl:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.crl\"\n)EOF\";\n\n  \/\/ This should fail, since the certificate has been revoked.\n  const std::string revoked_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n)EOF\";\n\n  TestUtilOptions revoked_test_options(revoked_client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n\n  \/\/ This should succeed, since the cert isn't revoked.\n  const std::string successful_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns2_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns2_key.pem\"\n)EOF\";\n\n  TestUtilOptions successful_test_options(successful_client_ctx_yaml, server_ctx_yaml, true,\n                                          GetParam());\n  testUtil(successful_test_options.setExpectedSerialNumber(TEST_SAN_DNS2_CERT_SERIAL));\n}","target":0,"code_token_length":452,"total_token_length":688,"max_tokens_setting":1024}
+{"idx":230978,"func":"mrb_protect_error(mrb_state *mrb, mrb_protect_error_func *body, void *userdata, mrb_bool *error)\n{\n  struct mrb_jmpbuf *prev_jmp = mrb->jmp;\n  struct mrb_jmpbuf c_jmp;\n  mrb_value result = mrb_nil_value();\n  int ai = mrb_gc_arena_save(mrb);\n  const struct mrb_context *c = mrb->c;\n  ptrdiff_t ci_index = c->ci - c->cibase;\n\n  if (error) { *error = FALSE; }\n\n  MRB_TRY(&c_jmp) {\n    mrb->jmp = &c_jmp;\n    result = body(mrb, userdata);\n    mrb->jmp = prev_jmp;\n  }\n  MRB_CATCH(&c_jmp) {\n    mrb->jmp = prev_jmp;\n    result = mrb_obj_value(mrb->exc);\n    mrb->exc = NULL;\n    if (error) { *error = TRUE; }\n    if (mrb->c == c) {\n      while (c->ci - c->cibase > ci_index) {\n        cipop(mrb);\n      }\n    }\n    else {\n      \/\/ It was probably switched by mrb_fiber_resume().\n      \/\/ Simply destroy all successive CINFO_DIRECTs once the fiber has been switched.\n      c = mrb->c;\n      while (c->ci > c->cibase && c->ci->cci == CINFO_DIRECT) {\n        cipop(mrb);\n      }\n    }\n  }\n  MRB_END_EXC(&c_jmp);\n\n  mrb_gc_arena_restore(mrb, ai);\n  mrb_gc_protect(mrb, result);\n  return result;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":369915,"func":"static struct dentry *proc_base_instantiate(struct inode *dir,\n\tstruct dentry *dentry, struct task_struct *task, const void *ptr)\n{\n\tconst struct pid_entry *p = ptr;\n\tstruct inode *inode;\n\tstruct proc_inode *ei;\n\tstruct dentry *error;\n\n\t\/* Allocate the inode *\/\n\terror = ERR_PTR(-ENOMEM);\n\tinode = new_inode(dir->i_sb);\n\tif (!inode)\n\t\tgoto out;\n\n\t\/* Initialize the inode *\/\n\tei = PROC_I(inode);\n\tinode->i_ino = get_next_ino();\n\tinode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;\n\n\t\/*\n\t * grab the reference to the task.\n\t *\/\n\tei->pid = get_task_pid(task, PIDTYPE_PID);\n\tif (!ei->pid)\n\t\tgoto out_iput;\n\n\tinode->i_mode = p->mode;\n\tif (S_ISDIR(inode->i_mode))\n\t\tset_nlink(inode, 2);\n\tif (S_ISLNK(inode->i_mode))\n\t\tinode->i_size = 64;\n\tif (p->iop)\n\t\tinode->i_op = p->iop;\n\tif (p->fop)\n\t\tinode->i_fop = p->fop;\n\tei->op = p->op;\n\td_add(dentry, inode);\n\terror = NULL;\nout:\n\treturn error;\nout_iput:\n\tiput(inode);\n\tgoto out;\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":230968,"func":"stack_extend_alloc(mrb_state *mrb, mrb_int room)\n{\n  mrb_value *oldbase = mrb->c->stbase;\n  mrb_value *newstack;\n  size_t oldsize = mrb->c->stend - mrb->c->stbase;\n  size_t size = oldsize;\n  size_t off = mrb->c->ci->stack ? mrb->c->stend - mrb->c->ci->stack : 0;\n\n  if (off > size) size = off;\n#ifdef MRB_STACK_EXTEND_DOUBLING\n  if ((size_t)room <= size)\n    size *= 2;\n  else\n    size += room;\n#else\n  \/* Use linear stack growth.\n     It is slightly slower than doubling the stack space,\n     but it saves memory on small devices. *\/\n  if (room <= MRB_STACK_GROWTH)\n    size += MRB_STACK_GROWTH;\n  else\n    size += room;\n#endif\n\n  newstack = (mrb_value *)mrb_realloc_simple(mrb, mrb->c->stbase, sizeof(mrb_value) * size);\n  if (newstack == NULL) {\n    mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));\n  }\n  stack_clear(&(newstack[oldsize]), size - oldsize);\n  envadjust(mrb, oldbase, newstack, oldsize);\n  mrb->c->stbase = newstack;\n  mrb->c->stend = mrb->c->stbase + size;\n\n  \/* Raise an exception if the new stack size will be too large,\n     to prevent infinite recursion. However, do this only after resizing the stack, so mrb_raise has stack space to work with. *\/\n  if (size > MRB_STACK_MAX) {\n    mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));\n  }\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":417127,"func":"mp_sint32 PlayerGeneric::startPlaying(XModule* module, \n\t\t\t\t\t\t\t\t\t  bool repeat\/* = false*\/, \n\t\t\t\t\t\t\t\t\t  mp_uint32 startPosition\/* = 0*\/, \n\t\t\t\t\t\t\t\t\t  mp_uint32 startRow\/* = 0*\/,\n\t\t\t\t\t\t\t\t\t  mp_sint32 numChannels\/* = -1*\/, \n\t\t\t\t\t\t\t\t\t  const mp_ubyte* customPanningTable\/* = NULL*\/,\n\t\t\t\t\t\t\t\t\t  bool idle\/* = false*\/,\n\t\t\t\t\t\t\t\t\t  mp_sint32 patternIndex\/* = -1*\/,\n\t\t\t\t\t\t\t\t\t  bool playOneRowOnly\/* = false*\/)\n{\n\tthis->idle = idle;\n\tthis->repeat = repeat;\n\tthis->playOneRowOnly = playOneRowOnly;\n\n\tif (mixer == NULL)\n\t{\n\t\tmixer = new MasterMixer(frequency, bufferSize, 1, audioDriver);\n\t\tmixer->setMasterMixerNotificationListener(listener);\n\t\tmixer->setSampleShift(sampleShift);\n\t\tif (audioDriver == NULL)\n\t\t\tmixer->setCurrentAudioDriverByName(audioDriverName);\n\t}\n\n\tif (!player || player->getType() != getPreferredPlayerType(module))\n\t{\n\t\tif (player)\n\t\t{\n\t\t\tif (!mixer->isDeviceRemoved(player))\n\t\t\t\tmixer->removeDevice(player);\n\t\t\tdelete player;\n\t\t}\n\t\t\n\t\tplayer = getPreferredPlayer(module);\n\t\t\n\t\tif (player)\n\t\t{\n\t\t\t\/\/ apply our own \"state\" to the state of the newly allocated player\n\t\t\tplayer->resetMainVolumeOnStartPlay(resetMainVolumeOnStartPlayFlag);\n\t\t\tplayer->resetOnStop(resetOnStopFlag);\n\t\t\tplayer->setBufferSize(bufferSize);\n\t\t\tplayer->setResamplerType(resamplerType);\n\t\t\tplayer->setMasterVolume(masterVolume);\n\t\t\tplayer->setPanningSeparation(panningSeparation);\n\t\t\tplayer->setPlayMode(playMode);\n\n\t\t\tfor (mp_sint32 i = PlayModeOptionFirst; i < PlayModeOptionLast; i++)\n\t\t\t\tplayer->enable((PlayModeOptions)i, options[i]);\t\t\t\n\t\t\t\n\t\t\tplayer->setDisableMixing(disableMixing);\n\t\t\tplayer->setAllowFilters(allowFilters);\n\t\t\t\/\/if (paused)\n\t\t\t\/\/\tplayer->pausePlaying();\n\n\t\t\t\/\/ adjust number of virtual channels if necessary\n\t\t\tsetNumMaxVirChannels(numMaxVirChannels);\n\t\t}\t\t\n\t}\n\t\n\tif (player && mixer)\n\t{\n\t\tif (!mixer->isDeviceRemoved(player))\n\t\t\tmixer->removeDevice(player);\n\t\t\t\n\t\tplayer->startPlaying(module, repeat, startPosition, startRow, numChannels, customPanningTable, idle, patternIndex, playOneRowOnly);\n\t\t\n\t\tmixer->addDevice(player);\n\t\t\n\t\tif (!mixer->isPlaying())\n\t\t\treturn mixer->start();\n\t}\n\n\n\treturn MP_OK;\n}","target":0,"code_token_length":567,"total_token_length":803,"max_tokens_setting":1024}
+{"idx":450363,"func":"static void zrle_choose_palette_rle(VncState *vs, int w, int h,\n                                    VncPalette *palette, int bpp_out,\n                                    int runs, int single_pixels,\n                                    int zywrle_level,\n                                    bool *use_rle, bool *use_palette)\n{\n    size_t estimated_bytes;\n    size_t plain_rle_bytes;\n\n    *use_palette = *use_rle = false;\n\n    estimated_bytes = w * h * (bpp_out \/ 8); \/* start assuming raw *\/\n\n    if (bpp_out != 8) {\n        if (zywrle_level > 0 && !(zywrle_level & 0x80))\n            estimated_bytes >>= zywrle_level;\n    }\n\n    plain_rle_bytes = ((bpp_out \/ 8) + 1) * (runs + single_pixels);\n\n    if (plain_rle_bytes < estimated_bytes) {\n        *use_rle = true;\n        estimated_bytes = plain_rle_bytes;\n    }\n\n    if (palette_size(palette) < 128) {\n        int palette_rle_bytes;\n\n        palette_rle_bytes = (bpp_out \/ 8) * palette_size(palette);\n        palette_rle_bytes += 2 * runs + single_pixels;\n\n        if (palette_rle_bytes < estimated_bytes) {\n            *use_rle = true;\n            *use_palette = true;\n            estimated_bytes = palette_rle_bytes;\n        }\n\n        if (palette_size(palette) < 17) {\n            int packed_bytes;\n\n            packed_bytes = (bpp_out \/ 8) * palette_size(palette);\n            packed_bytes += w * h *\n                bits_per_packed_pixel[palette_size(palette)-1] \/ 8;\n\n            if (packed_bytes < estimated_bytes) {\n                *use_rle = false;\n                *use_palette = true;\n            }\n        }\n    }\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":379321,"func":"apply_cmdmod(cmdmod_T *cmod)\n{\n#ifdef HAVE_SANDBOX\n    if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox)\n    {\n\t++sandbox;\n\tcmod->cmod_did_sandbox = TRUE;\n    }\n#endif\n    if (cmod->cmod_verbose > 0)\n    {\n\tif (cmod->cmod_verbose_save == 0)\n\t    cmod->cmod_verbose_save = p_verbose + 1;\n\tp_verbose = cmod->cmod_verbose - 1;\n    }\n\n    if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))\n\t    && cmod->cmod_save_msg_silent == 0)\n    {\n\tcmod->cmod_save_msg_silent = msg_silent + 1;\n\tcmod->cmod_save_msg_scroll = msg_scroll;\n    }\n    if (cmod->cmod_flags & CMOD_SILENT)\n\t++msg_silent;\n    if (cmod->cmod_flags & CMOD_UNSILENT)\n\tmsg_silent = 0;\n\n    if (cmod->cmod_flags & CMOD_ERRSILENT)\n    {\n\t++emsg_silent;\n\t++cmod->cmod_did_esilent;\n    }\n\n    if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL)\n    {\n\t\/\/ Set 'eventignore' to \"all\".\n\t\/\/ First save the existing option value for restoring it later.\n\tcmod->cmod_save_ei = vim_strsave(p_ei);\n\tset_string_option_direct((char_u *)\"ei\", -1,\n\t\t\t\t\t  (char_u *)\"all\", OPT_FREE, SID_NONE);\n    }\n}","target":0,"code_token_length":381,"total_token_length":617,"max_tokens_setting":1024}
+{"idx":198003,"func":"  void Compute(OpKernelContext* ctx) override {\n    auto x = ctx->input(0);\n    auto i = ctx->input(1);\n    auto v = ctx->input(2);\n\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(i.shape()),\n                errors::InvalidArgument(\"i must be a vector. \",\n                                        i.shape().DebugString()));\n    OP_REQUIRES(ctx, x.dims() == v.dims(),\n                errors::InvalidArgument(\n                    \"x and v shape doesn't match (ranks differ): \",\n                    x.shape().DebugString(), \" vs. \", v.shape().DebugString()));\n    for (int i = 1; i < x.dims(); ++i) {\n      OP_REQUIRES(\n          ctx, x.dim_size(i) == v.dim_size(i),\n          errors::InvalidArgument(\"x and v shape doesn't match at index \", i,\n                                  \" : \", x.shape().DebugString(), \" vs. \",\n                                  v.shape().DebugString()));\n    }\n    OP_REQUIRES(ctx, i.dim_size(0) == v.dim_size(0),\n                errors::InvalidArgument(\n                    \"i and x shape doesn't match at index 0: \",\n                    i.shape().DebugString(), \" vs. \", v.shape().DebugString()));\n\n    Tensor y = x;  \/\/ This creates an alias intentionally.\n    \/\/ Skip processing if tensors are empty.\n    if (x.NumElements() > 0 || v.NumElements() > 0) {\n      OP_REQUIRES_OK(ctx, DoCompute(ctx, i, v, &y));\n    }\n    ctx->set_output(0, y);\n  }","target":1,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":225074,"func":"emitHostIdentityInfo(PGconn *conn, const char *host_addr)\n{\n#ifdef HAVE_UNIX_SOCKETS\n\tif (IS_AF_UNIX(conn->raddr.addr.ss_family))\n\t{\n\t\tchar\t\tservice[NI_MAXHOST];\n\n\t\tpg_getnameinfo_all(&conn->raddr.addr, conn->raddr.salen,\n\t\t\t\t\t\t   NULL, 0,\n\t\t\t\t\t\t   service, sizeof(service),\n\t\t\t\t\t\t   NI_NUMERICSERV);\n\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"connection to server on socket \\\"%s\\\" failed: \"),\n\t\t\t\t\t\t  service);\n\t}\n\telse\n#endif\t\t\t\t\t\t\t\/* HAVE_UNIX_SOCKETS *\/\n\t{\n\t\tconst char *displayed_host;\n\t\tconst char *displayed_port;\n\n\t\t\/* To which host and port were we actually connecting? *\/\n\t\tif (conn->connhost[conn->whichhost].type == CHT_HOST_ADDRESS)\n\t\t\tdisplayed_host = conn->connhost[conn->whichhost].hostaddr;\n\t\telse\n\t\t\tdisplayed_host = conn->connhost[conn->whichhost].host;\n\t\tdisplayed_port = conn->connhost[conn->whichhost].port;\n\t\tif (displayed_port == NULL || displayed_port[0] == '\\0')\n\t\t\tdisplayed_port = DEF_PGPORT_STR;\n\n\t\t\/*\n\t\t * If the user did not supply an IP address using 'hostaddr', and\n\t\t * 'host' was missing or does not match our lookup, display the\n\t\t * looked-up IP address.\n\t\t *\/\n\t\tif (conn->connhost[conn->whichhost].type != CHT_HOST_ADDRESS &&\n\t\t\thost_addr[0] &&\n\t\t\tstrcmp(displayed_host, host_addr) != 0)\n\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"connection to server at \\\"%s\\\" (%s), port %s failed: \"),\n\t\t\t\t\t\t\t  displayed_host, host_addr,\n\t\t\t\t\t\t\t  displayed_port);\n\t\telse\n\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t  libpq_gettext(\"connection to server at \\\"%s\\\", port %s failed: \"),\n\t\t\t\t\t\t\t  displayed_host,\n\t\t\t\t\t\t\t  displayed_port);\n\t}\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":253728,"func":"int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)\n{\n\tint ret;\n\n\tcmd->engine_error = 0;\n\tcmd_q->cmd_error = 0;\n\tcmd_q->int_rcvd = 0;\n\tcmd_q->free_slots = cmd_q->ccp->vdata->perform->get_free_slots(cmd_q);\n\n\tswitch (cmd->engine) {\n\tcase CCP_ENGINE_AES:\n\t\tswitch (cmd->u.aes.mode) {\n\t\tcase CCP_AES_MODE_CMAC:\n\t\t\tret = ccp_run_aes_cmac_cmd(cmd_q, cmd);\n\t\t\tbreak;\n\t\tcase CCP_AES_MODE_GCM:\n\t\t\tret = ccp_run_aes_gcm_cmd(cmd_q, cmd);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tret = ccp_run_aes_cmd(cmd_q, cmd);\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tcase CCP_ENGINE_XTS_AES_128:\n\t\tret = ccp_run_xts_aes_cmd(cmd_q, cmd);\n\t\tbreak;\n\tcase CCP_ENGINE_DES3:\n\t\tret = ccp_run_des3_cmd(cmd_q, cmd);\n\t\tbreak;\n\tcase CCP_ENGINE_SHA:\n\t\tret = ccp_run_sha_cmd(cmd_q, cmd);\n\t\tbreak;\n\tcase CCP_ENGINE_RSA:\n\t\tret = ccp_run_rsa_cmd(cmd_q, cmd);\n\t\tbreak;\n\tcase CCP_ENGINE_PASSTHRU:\n\t\tif (cmd->flags & CCP_CMD_PASSTHRU_NO_DMA_MAP)\n\t\t\tret = ccp_run_passthru_nomap_cmd(cmd_q, cmd);\n\t\telse\n\t\t\tret = ccp_run_passthru_cmd(cmd_q, cmd);\n\t\tbreak;\n\tcase CCP_ENGINE_ECC:\n\t\tret = ccp_run_ecc_cmd(cmd_q, cmd);\n\t\tbreak;\n\tdefault:\n\t\tret = -EINVAL;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":265436,"func":"static int sqfs_split_path(char **file, char **dir, const char *path)\n{\n\tchar *dirc, *basec, *bname, *dname, *tmp_path;\n\tint ret = 0;\n\n\t*file = NULL;\n\t*dir = NULL;\n\tdirc = NULL;\n\tbasec = NULL;\n\tbname = NULL;\n\tdname = NULL;\n\ttmp_path = NULL;\n\n\t\/* check for first slash in path*\/\n\tif (path[0] == '\/') {\n\t\ttmp_path = strdup(path);\n\t\tif (!tmp_path) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t} else {\n\t\ttmp_path = malloc(strlen(path) + 2);\n\t\tif (!tmp_path) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t\ttmp_path[0] = '\/';\n\t\tstrcpy(tmp_path + 1, path);\n\t}\n\n\t\/* String duplicates *\/\n\tdirc = strdup(tmp_path);\n\tif (!dirc) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tbasec = strdup(tmp_path);\n\tif (!basec) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tdname = sqfs_dirname(dirc);\n\tbname = sqfs_basename(basec);\n\n\t*file = strdup(bname);\n\n\tif (!*file) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tif (*dname == '\\0') {\n\t\t*dir = malloc(2);\n\t\tif (!*dir) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\t(*dir)[0] = '\/';\n\t\t(*dir)[1] = '\\0';\n\t} else {\n\t\t*dir = strdup(dname);\n\t\tif (!*dir) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t}\n\nout:\n\tif (ret) {\n\t\tfree(*file);\n\t\tfree(*dir);\n\t\t*dir = NULL;\n\t\t*file = NULL;\n\t}\n\tfree(basec);\n\tfree(dirc);\n\tfree(tmp_path);\n\n\treturn ret;\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":197632,"func":"njs_promise_perform_then(njs_vm_t *vm, njs_value_t *value,\n    njs_value_t *fulfilled, njs_value_t *rejected,\n    njs_promise_capability_t *capability)\n{\n    njs_int_t               ret;\n    njs_value_t             arguments[2];\n    njs_promise_t           *promise;\n    njs_function_t          *function;\n    njs_promise_data_t      *data;\n    njs_promise_reaction_t  *fulfilled_reaction, *rejected_reaction;\n\n    if (!njs_is_function(fulfilled)) {\n        fulfilled = njs_value_arg(&njs_value_undefined);\n    }\n\n    if (!njs_is_function(rejected)) {\n        rejected = njs_value_arg(&njs_value_undefined);\n    }\n\n    promise = njs_promise(value);\n    data = njs_data(&promise->value);\n\n    fulfilled_reaction = njs_mp_alloc(vm->mem_pool,\n                                      sizeof(njs_promise_reaction_t));\n    if (njs_slow_path(fulfilled_reaction == NULL)) {\n        njs_memory_error(vm);\n        return NJS_ERROR;\n    }\n\n    fulfilled_reaction->capability = capability;\n    fulfilled_reaction->handler = *fulfilled;\n    fulfilled_reaction->type = NJS_PROMISE_FULFILL;\n\n    rejected_reaction = njs_mp_alloc(vm->mem_pool,\n                                     sizeof(njs_promise_reaction_t));\n    if (njs_slow_path(rejected_reaction == NULL)) {\n        njs_memory_error(vm);\n        return NJS_ERROR;\n    }\n\n    rejected_reaction->capability = capability;\n    rejected_reaction->handler = *rejected;\n    rejected_reaction->type = NJS_PROMISE_REJECTED;\n\n    if (data->state == NJS_PROMISE_PENDING) {\n        njs_queue_insert_tail(&data->fulfill_queue, &fulfilled_reaction->link);\n        njs_queue_insert_tail(&data->reject_queue, &rejected_reaction->link);\n\n    } else {\n        function = njs_promise_create_function(vm,\n                                               sizeof(njs_promise_context_t));\n        function->u.native = njs_promise_reaction_job;\n\n        if (data->state == NJS_PROMISE_REJECTED) {\n            njs_set_data(&arguments[0], rejected_reaction, 0);\n\n            ret = njs_promise_host_rejection_tracker(vm, promise,\n                                                     NJS_PROMISE_HANDLE);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n        } else {\n            njs_set_data(&arguments[0], fulfilled_reaction, 0);\n        }\n\n        arguments[1] = data->result;\n\n        ret = njs_promise_add_event(vm, function, arguments, 2);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n    }\n\n    data->is_handled = 1;\n\n    if (capability == NULL) {\n        njs_vm_retval_set(vm, &njs_value_undefined);\n\n    } else {\n        njs_vm_retval_set(vm, &capability->promise);\n    }\n\n    return NJS_OK;\n}","target":1,"code_token_length":647,"total_token_length":883,"max_tokens_setting":1024}
+{"idx":259166,"func":"static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    \/\/ Set by mov_read_tfhd(). mov_read_trun() will reject files missing tfhd.\n    c->fragment.found_tfhd = 0;\n\n    if (!c->has_looked_for_mfra && c->use_mfra_for > 0) {\n        c->has_looked_for_mfra = 1;\n        if (pb->seekable & AVIO_SEEKABLE_NORMAL) {\n            int ret;\n            av_log(c->fc, AV_LOG_VERBOSE, \"stream has moof boxes, will look \"\n                    \"for a mfra\\n\");\n            if ((ret = mov_read_mfra(c, pb)) < 0) {\n                av_log(c->fc, AV_LOG_VERBOSE, \"found a moof box but failed to \"\n                        \"read the mfra (may be a live ismv)\\n\");\n            }\n        } else {\n            av_log(c->fc, AV_LOG_VERBOSE, \"found a moof box but stream is not \"\n                    \"seekable, can not look for mfra\\n\");\n        }\n    }\n    c->fragment.moof_offset = c->fragment.implicit_offset = avio_tell(pb) - 8;\n    av_log(c->fc, AV_LOG_TRACE, \"moof offset %\"PRIx64\"\\n\", c->fragment.moof_offset);\n    c->frag_index.current = update_frag_index(c, c->fragment.moof_offset);\n    return mov_read_default(c, pb, atom);\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":219001,"func":"bool ConstantFolding::IsZeros(const NodeDef& node) const {\n  if (feed_nodes_.find(node.name()) != feed_nodes_.end()) {\n    return false;\n  }\n  if (IsOnesLike(node)) return false;\n  if (IsZerosLike(node)) return true;\n  if (node.op() == \"Fill\") {\n    NodeDef* values = node_map_->GetNode(NodeName(node.input(1)));\n    return values != nullptr && IsZeros(*values);\n  }\n  if (!IsConstant(node)) return false;\n  if (node.attr().count(\"dtype\") == 0) return false;\n  const auto dtype = node.attr().at(\"dtype\").type();\n  switch (dtype) {\n    IS_ZEROS_CASE(DT_BOOL);\n    IS_ZEROS_CASE(DT_HALF);\n    IS_ZEROS_CASE(DT_BFLOAT16);\n    IS_ZEROS_CASE(DT_FLOAT);\n    IS_ZEROS_CASE(DT_DOUBLE);\n    IS_ZEROS_CASE(DT_COMPLEX64);\n    IS_ZEROS_CASE(DT_COMPLEX128);\n    IS_ZEROS_CASE(DT_UINT8);\n    IS_ZEROS_CASE(DT_INT8);\n    IS_ZEROS_CASE(DT_UINT16);\n    IS_ZEROS_CASE(DT_INT16);\n    IS_ZEROS_CASE(DT_INT32);\n    IS_ZEROS_CASE(DT_INT64);\n    IS_ZEROS_CASE(DT_QINT32);\n    IS_ZEROS_CASE(DT_QINT16);\n    IS_ZEROS_CASE(DT_QUINT16);\n    IS_ZEROS_CASE(DT_QINT8);\n    IS_ZEROS_CASE(DT_QUINT8);\n    default:\n      VLOG(1) << \"Unsupported type \" << DataTypeString(dtype);\n      return false;\n  }\n  return false;\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":424940,"func":"iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,\n\t\t\t    struct iwl_trans *trans,\n\t\t\t    const struct iwl_cfg_trans_params *cfg_trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tint max_irqs, num_irqs, i, ret;\n\tu16 pci_cmd;\n\n\tif (!cfg_trans->mq_rx_supported)\n\t\tgoto enable_msi;\n\n\tmax_irqs = min_t(u32, num_online_cpus() + 2, IWL_MAX_RX_HW_QUEUES);\n\tfor (i = 0; i < max_irqs; i++)\n\t\ttrans_pcie->msix_entries[i].entry = i;\n\n\tnum_irqs = pci_enable_msix_range(pdev, trans_pcie->msix_entries,\n\t\t\t\t\t MSIX_MIN_INTERRUPT_VECTORS,\n\t\t\t\t\t max_irqs);\n\tif (num_irqs < 0) {\n\t\tIWL_DEBUG_INFO(trans,\n\t\t\t       \"Failed to enable msi-x mode (ret %d). Moving to msi mode.\\n\",\n\t\t\t       num_irqs);\n\t\tgoto enable_msi;\n\t}\n\ttrans_pcie->def_irq = (num_irqs == max_irqs) ? num_irqs - 1 : 0;\n\n\tIWL_DEBUG_INFO(trans,\n\t\t       \"MSI-X enabled. %d interrupt vectors were allocated\\n\",\n\t\t       num_irqs);\n\n\t\/*\n\t * In case the OS provides fewer interrupts than requested, different\n\t * causes will share the same interrupt vector as follows:\n\t * One interrupt less: non rx causes shared with FBQ.\n\t * Two interrupts less: non rx causes shared with FBQ and RSS.\n\t * More than two interrupts: we will use fewer RSS queues.\n\t *\/\n\tif (num_irqs <= max_irqs - 2) {\n\t\ttrans_pcie->trans->num_rx_queues = num_irqs + 1;\n\t\ttrans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX |\n\t\t\tIWL_SHARED_IRQ_FIRST_RSS;\n\t} else if (num_irqs == max_irqs - 1) {\n\t\ttrans_pcie->trans->num_rx_queues = num_irqs;\n\t\ttrans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX;\n\t} else {\n\t\ttrans_pcie->trans->num_rx_queues = num_irqs - 1;\n\t}\n\tWARN_ON(trans_pcie->trans->num_rx_queues > IWL_MAX_RX_HW_QUEUES);\n\n\ttrans_pcie->alloc_vecs = num_irqs;\n\ttrans_pcie->msix_enabled = true;\n\treturn;\n\nenable_msi:\n\tret = pci_enable_msi(pdev);\n\tif (ret) {\n\t\tdev_err(&pdev->dev, \"pci_enable_msi failed - %d\\n\", ret);\n\t\t\/* enable rfkill interrupt: hw bug w\/a *\/\n\t\tpci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);\n\t\tif (pci_cmd & PCI_COMMAND_INTX_DISABLE) {\n\t\t\tpci_cmd &= ~PCI_COMMAND_INTX_DISABLE;\n\t\t\tpci_write_config_word(pdev, PCI_COMMAND, pci_cmd);\n\t\t}\n\t}\n}","target":0,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":294591,"func":"datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;\n    int d, h, min, s, rof;\n    double sg;\n\n    rb_scan_args(argc, argv, \"07\", &vy, &vd, &vh, &vmin, &vs, &vof, &vsg);\n\n    y = INT2FIX(-4712);\n    d = 1;\n\n    h = min = s = 0;\n    fr2 = INT2FIX(0);\n    rof = 0;\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 7:\n\tval2sg(vsg, sg);\n      case 6:\n\tval2off(vof, rof);\n      case 5:\n        check_numeric(vs, \"second\");\n\tnum2int_with_frac(s, positive_inf);\n      case 4:\n        check_numeric(vmin, \"minute\");\n\tnum2int_with_frac(min, 4);\n      case 3:\n        check_numeric(vh, \"hour\");\n\tnum2int_with_frac(h, 3);\n      case 2:\n        check_numeric(vd, \"yday\");\n\tnum2int_with_frac(d, 2);\n      case 1:\n        check_numeric(vy, \"year\");\n\ty = vy;\n    }\n\n    {\n\tVALUE nth;\n\tint ry, rd, rh, rmin, rs, rjd, rjd2, ns;\n\n\tif (!valid_ordinal_p(y, d, sg,\n\t\t\t     &nth, &ry,\n\t\t\t     &rd, &rjd,\n\t\t\t     &ns))\n\t    rb_raise(eDateError, \"invalid date\");\n\tif (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))\n\t    rb_raise(eDateError, \"invalid date\");\n\tcanon24oc();\n\n\trjd2 = jd_local_to_utc(rjd,\n\t\t\t       time_to_df(rh, rmin, rs),\n\t\t\t       rof);\n\n\tret = d_complex_new_internal(klass,\n\t\t\t\t     nth, rjd2,\n\t\t\t\t     0, INT2FIX(0),\n\t\t\t\t     rof, sg,\n\t\t\t\t     0, 0, 0,\n\t\t\t\t     rh, rmin, rs,\n\t\t\t\t     HAVE_JD | HAVE_TIME);\n    }\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":499,"total_token_length":735,"max_tokens_setting":1024}
+{"idx":244102,"func":"GF_Err xtra_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_XtraBox *ptr = (GF_XtraBox *)s;\n\twhile (ptr->size) {\n\t\tGF_XtraTag *tag;\n\t\tu32 prop_type = 0;\n\n\t\tchar *data=NULL, *data2=NULL;\n\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, 8)\n\t\ts32 tag_size = gf_bs_read_u32(bs);\n\t\tu32 name_size = gf_bs_read_u32(bs);\n\t\tif (tag_size < 8) return GF_ISOM_INVALID_FILE;\n\n\t\ttag_size -= 8;\n\t\tif ((tag_size>ptr->size) || (name_size>ptr->size)) {\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, 10)\n\n\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, name_size)\n\t\tdata = gf_malloc(sizeof(char) * (name_size+1));\n\t\tgf_bs_read_data(bs, data, name_size);\n\t\tdata[name_size] = 0;\n\t\ttag_size-=name_size;\n\n\t\tu32 flags = gf_bs_read_u32(bs);\n\t\tu32 prop_size = gf_bs_read_u32(bs);\n\t\ttag_size-=8;\n\n\t\tif (prop_size>4) {\n\t\t\ttag_size-=2;\n\t\t\tprop_type = gf_bs_read_u16(bs);\n\t\t\tprop_size -= 6;\n\t\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, prop_size)\n\t\t\t\/\/add 3 extra bytes for UTF16 case string dump (3 because we need 0-aligned short value)\n\t\t\tdata2 = gf_malloc(sizeof(char) * (prop_size+3));\n\t\t\tgf_bs_read_data(bs, data2, prop_size);\n\t\t\tdata2[prop_size] = 0;\n\t\t\tdata2[prop_size+1] = 0;\n\t\t\tdata2[prop_size+2] = 0;\n\t\t\ttag_size-=prop_size;\n\t\t} else {\n\t\t\tprop_size = 0;\n\t\t}\n\t\tGF_SAFEALLOC(tag, GF_XtraTag)\n\t\ttag->flags = flags;\n\t\ttag->name = data;\n\t\ttag->prop_size = prop_size;\n\t\ttag->prop_value = data2;\n\t\ttag->prop_type = prop_type;\n\t\tgf_list_add(ptr->tags, tag);\n\n\t\tif (tag_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[isom] invalid tag size in Xtra !\\n\"));\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":300781,"func":"static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,\n\t\t\t\tu32 peer_node)\n{\n\tstruct sock *sk = &tsk->sk;\n\tstruct net *net = sock_net(sk);\n\tstruct tipc_msg *msg = &tsk->phdr;\n\n\tmsg_set_syn(msg, 0);\n\tmsg_set_destnode(msg, peer_node);\n\tmsg_set_destport(msg, peer_port);\n\tmsg_set_type(msg, TIPC_CONN_MSG);\n\tmsg_set_lookup_scope(msg, 0);\n\tmsg_set_hdr_sz(msg, SHORT_H_SIZE);\n\n\tsk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV);\n\ttipc_set_sk_state(sk, TIPC_ESTABLISHED);\n\ttipc_node_add_conn(net, peer_node, tsk->portid, peer_port);\n\ttsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid, true);\n\ttsk->peer_caps = tipc_node_get_capabilities(net, peer_node);\n\ttsk_set_nagle(tsk);\n\t__skb_queue_purge(&sk->sk_write_queue);\n\tif (tsk->peer_caps & TIPC_BLOCK_FLOWCTL)\n\t\treturn;\n\n\t\/* Fall back to message based flow control *\/\n\ttsk->rcv_win = FLOWCTL_MSG_WIN;\n\ttsk->snd_win = FLOWCTL_MSG_WIN;\n}","target":0,"code_token_length":288,"total_token_length":524,"max_tokens_setting":1024}
+{"idx":231687,"func":"TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterCloseStream) {\n  server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 3;\n  std::array<std::string, 4> words = {\n      \"Hey Bob, this is Alice, for real.\",\n      \"What message did I send you last time?\",\n      \"You don't sound like Alice\",\n      \"You are a liar!\",\n  };\n\n  StreamId streamId = 0x00;\n  auto stream = server->getNonConstConn().streamManager->getStream(streamId);\n  stream->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false);\n  stream->readBuffer.emplace_back(\n      IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false);\n  stream->retransmissionBuffer.emplace(\n      std::piecewise_construct,\n      std::forward_as_tuple(0),\n      std::forward_as_tuple(std::make_unique<StreamBuffer>(\n          IOBuf::copyBuffer(words.at(2)), 0, false)));\n  stream->writeBuffer.append(IOBuf::copyBuffer(words.at(3)));\n  stream->currentWriteOffset = words.at(2).length() + words.at(3).length();\n  stream->currentReadOffset = words.at(0).length() + words.at(1).length();\n  server->getNonConstConn().flowControlState.sumCurStreamBufferLen = 100;\n\n  server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 5;\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n\n  StopSendingFrame stopSendingFrame(\n      streamId, GenericApplicationErrorCode::UNKNOWN);\n  ASSERT_TRUE(builder.canBuildPacket());\n  writeFrame(QuicSimpleFrame(stopSendingFrame), builder);\n  auto packet = std::move(builder).buildPacket();\n  server->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN);\n  EXPECT_CALL(connCallback, onStopSending(_, _)).Times(0);\n  deliverData(packetToBuf(packet));\n}","target":0,"code_token_length":496,"total_token_length":732,"max_tokens_setting":1024}
+{"idx":258082,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& input = context->input(0);\n    \/\/ If input is provided, check to make sure the first dimension is valid.\n    if (input.dims() > 0) {\n      OP_REQUIRES(\n          context, input.dim_size(0) != 0,\n          errors::InvalidArgument(\"Invalid input first dimension. Found 0.\"));\n    }\n    const Tensor& dims = context->input(1);\n\n    if (TensorShapeUtils::IsScalar(input.shape())) {\n      context->set_output(0, input);\n    } else {\n      const int input_dims = input.dims();\n      OP_REQUIRES(context, TensorShapeUtils::IsVector(dims.shape()),\n                  errors::InvalidArgument(\"'dims' must be 1-dimension, not \",\n                                          dims.dims()));\n\n      OP_REQUIRES(\n          context, input_dims == dims.dim_size(0),\n          errors::InvalidArgument(\n              \"'dims' must have the same number of values as 'input' has \"\n              \"dimensions. 'input' has \",\n              input_dims, \"'dims' has \", dims.dim_size(0), \" values\"));\n      OP_REQUIRES(context, input_dims <= 8,\n                  errors::Unimplemented(\n                      \"reverse is not implemented for tensors of rank > 8.\"));\n\n      Tensor* output = nullptr;\n      OP_REQUIRES_OK(context,\n                     context->allocate_output(0, input.shape(), &output));\n\n#define HANDLE_REVERSE(NDIMS)                                               \\\n  case NDIMS:                                                               \\\n    HandleReverseCase<Device, T, NDIMS>(context, dims.vec<bool>(), output); \\\n    return;\n\n      switch (input_dims) {\n        HANDLE_REVERSE(0);\n        HANDLE_REVERSE(1);\n        HANDLE_REVERSE(2);\n        HANDLE_REVERSE(3);\n        HANDLE_REVERSE(4);\n        HANDLE_REVERSE(5);\n        HANDLE_REVERSE(6);\n        HANDLE_REVERSE(7);\n        HANDLE_REVERSE(8);\n      }\n#undef HANDLE_REVERSE\n    }\n  }","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":389696,"func":"eval_interp_string(char_u **arg, typval_T *rettv, int evaluate)\n{\n    typval_T\ttv;\n    int\t\tret = OK;\n    int\t\tquote;\n    garray_T\tga;\n    char_u\t*p;\n\n    ga_init2(&ga, 1, 80);\n\n    \/\/ *arg is on the '$' character, move it to the first string character.\n    ++*arg;\n    quote = **arg;\n    ++*arg;\n\n    for (;;)\n    {\n\t\/\/ Get the string up to the matching quote or to a single '{'.\n\t\/\/ \"arg\" is advanced to either the quote or the '{'.\n\tif (quote == '\"')\n\t    ret = eval_string(arg, &tv, evaluate, TRUE);\n\telse\n\t    ret = eval_lit_string(arg, &tv, evaluate, TRUE);\n\tif (ret == FAIL)\n\t    break;\n\tif (evaluate)\n\t{\n\t    ga_concat(&ga, tv.vval.v_string);\n\t    clear_tv(&tv);\n\t}\n\n\tif (**arg != '{')\n\t{\n\t    \/\/ found terminating quote\n\t    ++*arg;\n\t    break;\n\t}\n\tp = eval_one_expr_in_str(*arg, &ga, evaluate);\n\tif (p == NULL)\n\t{\n\t    ret = FAIL;\n\t    break;\n\t}\n\t*arg = p;\n    }\n\n    rettv->v_type = VAR_STRING;\n    if (ret == FAIL || !evaluate || ga_append(&ga, NUL) == FAIL)\n    {\n\tga_clear(&ga);\n\trettv->vval.v_string = NULL;\n\treturn ret;\n    }\n\n    rettv->vval.v_string = ga.ga_data;\n    return OK;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":261422,"func":"void thread_task_ctb_row::work()\n{\n  thread_task_ctb_row* data = this;\n  thread_context* tctx = data->tctx;\n  de265_image* img = tctx->img;\n\n  const seq_parameter_set& sps = img->get_sps();\n  int ctbW = sps.PicWidthInCtbsY;\n\n  state = Running;\n  img->thread_run(this);\n\n  setCtbAddrFromTS(tctx);\n\n  int ctby = tctx->CtbAddrInRS \/ ctbW;\n  int myCtbRow = ctby;\n\n  \/\/printf(\"start CTB-row decoding at row %d\\n\", ctby);\n\n  if (data->firstSliceSubstream) {\n    bool success = initialize_CABAC_at_slice_segment_start(tctx);\n    if (!success) {\n      \/\/ could not decode this row, mark whole row as finished\n      for (int x=0;x<ctbW;x++) {\n        img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER);\n      }\n\n      state = Finished;\n      tctx->sliceunit->finished_threads.increase_progress(1);\n      img->thread_finishes(this);\n      return;\n    }\n    \/\/initialize_CABAC(tctx);\n  }\n\n  init_CABAC_decoder_2(&tctx->cabac_decoder);\n\n  bool firstIndependentSubstream =\n    data->firstSliceSubstream && !tctx->shdr->dependent_slice_segment_flag;\n\n  \/*enum DecodeResult result =*\/\n  decode_substream(tctx, true, firstIndependentSubstream);\n\n  \/\/ mark progress on remaining CTBs in row (in case of decoder error and early termination)\n\n  \/\/ TODO: what about slices that end properly in the middle of a CTB row?\n\n  if (tctx->CtbY == myCtbRow) {\n    int lastCtbX = sps.PicWidthInCtbsY; \/\/ assume no tiles when WPP is on\n    for (int x = tctx->CtbX; x<lastCtbX ; x++) {\n\n      if (x        < sps.PicWidthInCtbsY &&\n          myCtbRow < sps.PicHeightInCtbsY) {\n        img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER);\n      }\n    }\n  }\n\n  state = Finished;\n  tctx->sliceunit->finished_threads.increase_progress(1);\n  img->thread_finishes(this);\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":466182,"func":"static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt,\n\t\t\t\t struct tss_segment_16 *tss)\n{\n\tint ret;\n\n\tctxt->_eip = tss->ip;\n\tctxt->eflags = tss->flag | 2;\n\tctxt->regs[VCPU_REGS_RAX] = tss->ax;\n\tctxt->regs[VCPU_REGS_RCX] = tss->cx;\n\tctxt->regs[VCPU_REGS_RDX] = tss->dx;\n\tctxt->regs[VCPU_REGS_RBX] = tss->bx;\n\tctxt->regs[VCPU_REGS_RSP] = tss->sp;\n\tctxt->regs[VCPU_REGS_RBP] = tss->bp;\n\tctxt->regs[VCPU_REGS_RSI] = tss->si;\n\tctxt->regs[VCPU_REGS_RDI] = tss->di;\n\n\t\/*\n\t * SDM says that segment selectors are loaded before segment\n\t * descriptors\n\t *\/\n\tset_segment_selector(ctxt, tss->ldt, VCPU_SREG_LDTR);\n\tset_segment_selector(ctxt, tss->es, VCPU_SREG_ES);\n\tset_segment_selector(ctxt, tss->cs, VCPU_SREG_CS);\n\tset_segment_selector(ctxt, tss->ss, VCPU_SREG_SS);\n\tset_segment_selector(ctxt, tss->ds, VCPU_SREG_DS);\n\n\t\/*\n\t * Now load segment descriptors. If fault happenes at this stage\n\t * it is handled in a context of new task\n\t *\/\n\tret = load_segment_descriptor(ctxt, tss->ldt, VCPU_SREG_LDTR);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\tret = load_segment_descriptor(ctxt, tss->es, VCPU_SREG_ES);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\tret = load_segment_descriptor(ctxt, tss->cs, VCPU_SREG_CS);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\tret = load_segment_descriptor(ctxt, tss->ss, VCPU_SREG_SS);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\tret = load_segment_descriptor(ctxt, tss->ds, VCPU_SREG_DS);\n\tif (ret != X86EMUL_CONTINUE)\n\t\treturn ret;\n\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":515,"total_token_length":751,"max_tokens_setting":1024}
+{"idx":210204,"func":"static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa,\n\t\t\t\t       int attr_len, bool log)\n{\n\n\tstruct sw_flow_actions *acts;\n\tint new_acts_size;\n\tsize_t req_size = NLA_ALIGN(attr_len);\n\tint next_offset = offsetof(struct sw_flow_actions, actions) +\n\t\t\t\t\t(*sfa)->actions_len;\n\n\tif (req_size <= (ksize(*sfa) - next_offset))\n\t\tgoto out;\n\n\tnew_acts_size = max(next_offset + req_size, ksize(*sfa) * 2);\n\n\tif (new_acts_size > MAX_ACTIONS_BUFSIZE) {\n\t\tif ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) {\n\t\t\tOVS_NLERR(log, \"Flow action size exceeds max %u\",\n\t\t\t\t  MAX_ACTIONS_BUFSIZE);\n\t\t\treturn ERR_PTR(-EMSGSIZE);\n\t\t}\n\t\tnew_acts_size = MAX_ACTIONS_BUFSIZE;\n\t}\n\n\tacts = nla_alloc_flow_actions(new_acts_size);\n\tif (IS_ERR(acts))\n\t\treturn (void *)acts;\n\n\tmemcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len);\n\tacts->actions_len = (*sfa)->actions_len;\n\tacts->orig_len = (*sfa)->orig_len;\n\tkfree(*sfa);\n\t*sfa = acts;\n\nout:\n\t(*sfa)->actions_len += req_size;\n\treturn  (struct nlattr *) ((unsigned char *)(*sfa) + next_offset);\n}","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":221690,"func":"void Socket::stopSsl()\n{\n#ifdef NETDEBUG\n    std::cout << thread_id << \"ssl stopping\" << std::endl;\n#endif\n    if(!isssl) return;\n\n    isssl = false;\n\n    if (ssl != NULL) {\n        if (issslserver) {\n#ifdef NETDEBUG\n            std::cout << thread_id << \"this is a server connection\" << std::endl;\n            if (SSL_get_shutdown(ssl) & SSL_SENT_SHUTDOWN) {\n                std::cout << thread_id << \"SSL_SENT_SHUTDOWN IS SET\" << std::endl;\n            }\n            if (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) {\n                std::cout << thread_id << \"SSL_RECEIVED_SHUTDOWN IS SET\" << std::endl;\n            }\n            std::cout << thread_id << \"calling 1st ssl shutdown\" << std::endl;\n#endif\n            if (!SSL_shutdown(ssl)) {\n#ifdef NETDEBUG\n                std::cout << thread_id << \"need to call SSL shutdown again\" << std::endl;\n                if (SSL_get_shutdown(ssl) & SSL_SENT_SHUTDOWN) {\n                    std::cout << thread_id << \"SSL_SENT_SHUTDOWN IS SET\" << std::endl;\n                }\n                if (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) {\n                    std::cout << thread_id << \"SSL_RECEIVED_SHUTDOWN IS SET\" << std::endl;\n                }\n                std::cout << thread_id << \"Discarding extra data from client\" << std::endl;\n#endif\n\n                shutdown(SSL_get_fd(ssl), SHUT_WR);\n                char junk[1024];\n                readFromSocket(junk, sizeof(junk), 0, 5);\n#ifdef NETDEBUG\n                std::cout << thread_id << \"done\" << std::endl;\n#endif\n            }\n        } else {\n#ifdef NETDEBUG\n            std::cout << thread_id << \"this is a client connection\" << std::endl;\n            if (SSL_get_shutdown(ssl) & SSL_SENT_SHUTDOWN) {\n                std::cout << thread_id << \"SSL_SENT_SHUTDOWN IS SET\" << std::endl;\n            }\n            if (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) {\n                std::cout << thread_id << \"SSL_RECEIVED_SHUTDOWN IS SET\" << std::endl;\n            }\n            std::cout << thread_id << \"calling ssl shutdown\" << std::endl;\n#endif\n            SSL_shutdown(ssl);\n#ifdef NETDEBUG\n            std::cout << thread_id << \"done\" << std::endl;\n#endif\n        }\n    }\n\n    cleanSsl();\n\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":489150,"func":"sctp_disposition_t sctp_sf_do_prm_asoc(const struct sctp_endpoint *ep,\n\t\t\t\t       const struct sctp_association *asoc,\n\t\t\t\t       const sctp_subtype_t type,\n\t\t\t\t       void *arg,\n\t\t\t\t       sctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *repl;\n\tstruct sctp_association* my_asoc;\n\n\t\/* The comment below says that we enter COOKIE-WAIT AFTER\n\t * sending the INIT, but that doesn't actually work in our\n\t * implementation...\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,\n\t\t\tSCTP_STATE(SCTP_STATE_COOKIE_WAIT));\n\n\t\/* RFC 2960 5.1 Normal Establishment of an Association\n\t *\n\t * A) \"A\" first sends an INIT chunk to \"Z\".  In the INIT, \"A\"\n\t * must provide its Verification Tag (Tag_A) in the Initiate\n\t * Tag field.  Tag_A SHOULD be a random number in the range of\n\t * 1 to 4294967295 (see 5.3.1 for Tag value selection). ...\n\t *\/\n\n\trepl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0);\n\tif (!repl)\n\t\tgoto nomem;\n\n\t\/* Cast away the const modifier, as we want to just\n\t * rerun it through as a sideffect.\n\t *\/\n\tmy_asoc = (struct sctp_association *)asoc;\n\tsctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(my_asoc));\n\n\t\/* Choose transport for INIT. *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_INIT_CHOOSE_TRANSPORT,\n\t\t\tSCTP_CHUNK(repl));\n\n\t\/* After sending the INIT, \"A\" starts the T1-init timer and\n\t * enters the COOKIE-WAIT state.\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,\n\t\t\tSCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));\n\tsctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));\n\treturn SCTP_DISPOSITION_CONSUME;\n\nnomem:\n\treturn SCTP_DISPOSITION_NOMEM;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":230312,"func":"njs_array_alloc(njs_vm_t *vm, njs_bool_t flat, uint64_t length, uint32_t spare)\n{\n    uint64_t     size;\n    njs_int_t    ret;\n    njs_array_t  *array;\n    njs_value_t  value;\n\n    if (njs_slow_path(length > UINT32_MAX)) {\n        goto overflow;\n    }\n\n    array = njs_mp_alloc(vm->mem_pool, sizeof(njs_array_t));\n    if (njs_slow_path(array == NULL)) {\n        goto memory_error;\n    }\n\n    size = length + spare;\n\n    if (flat || size <= NJS_ARRAY_LARGE_OBJECT_LENGTH) {\n        array->data = njs_mp_align(vm->mem_pool, sizeof(njs_value_t),\n                                   size * sizeof(njs_value_t));\n        if (njs_slow_path(array->data == NULL)) {\n            goto memory_error;\n        }\n\n    } else {\n        array->data = NULL;\n    }\n\n    array->start = array->data;\n    njs_lvlhsh_init(&array->object.hash);\n    array->object.shared_hash = vm->shared->array_instance_hash;\n    array->object.__proto__ = &vm->prototypes[NJS_OBJ_TYPE_ARRAY].object;\n    array->object.slots = NULL;\n    array->object.type = NJS_ARRAY;\n    array->object.shared = 0;\n    array->object.extensible = 1;\n    array->object.error_data = 0;\n    array->object.fast_array = (array->data != NULL);\n\n    if (njs_fast_path(array->object.fast_array)) {\n        array->size = size;\n        array->length = length;\n\n    } else {\n        array->size = 0;\n        array->length = 0;\n\n        njs_set_array(&value, array);\n        ret = njs_array_length_redefine(vm, &value, length);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return NULL;\n        }\n    }\n\n    return array;\n\nmemory_error:\n\n    njs_memory_error(vm);\n\n    return NULL;\n\noverflow:\n\n    njs_range_error(vm, \"Invalid array length\");\n\n    return NULL;\n}","target":0,"code_token_length":459,"total_token_length":695,"max_tokens_setting":1024}
+{"idx":369871,"func":"static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,\n\t\t\t\t\tsize_t count, loff_t *ppos)\n{\n\tstruct task_struct *task;\n\tchar buffer[PROC_NUMBUF];\n\tunsigned long flags;\n\tint oom_score_adj;\n\tint err;\n\n\tmemset(buffer, 0, sizeof(buffer));\n\tif (count > sizeof(buffer) - 1)\n\t\tcount = sizeof(buffer) - 1;\n\tif (copy_from_user(buffer, buf, count)) {\n\t\terr = -EFAULT;\n\t\tgoto out;\n\t}\n\n\terr = kstrtoint(strstrip(buffer), 0, &oom_score_adj);\n\tif (err)\n\t\tgoto out;\n\tif (oom_score_adj < OOM_SCORE_ADJ_MIN ||\n\t\t\toom_score_adj > OOM_SCORE_ADJ_MAX) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\ttask = get_proc_task(file->f_path.dentry->d_inode);\n\tif (!task) {\n\t\terr = -ESRCH;\n\t\tgoto out;\n\t}\n\n\ttask_lock(task);\n\tif (!task->mm) {\n\t\terr = -EINVAL;\n\t\tgoto err_task_lock;\n\t}\n\n\tif (!lock_task_sighand(task, &flags)) {\n\t\terr = -ESRCH;\n\t\tgoto err_task_lock;\n\t}\n\n\tif (oom_score_adj < task->signal->oom_score_adj_min &&\n\t\t\t!capable(CAP_SYS_RESOURCE)) {\n\t\terr = -EACCES;\n\t\tgoto err_sighand;\n\t}\n\n\ttask->signal->oom_score_adj = oom_score_adj;\n\tif (has_capability_noaudit(current, CAP_SYS_RESOURCE))\n\t\ttask->signal->oom_score_adj_min = oom_score_adj;\n\ttrace_oom_score_adj_update(task);\n\t\/*\n\t * Scale \/proc\/pid\/oom_adj appropriately ensuring that OOM_DISABLE is\n\t * always attainable.\n\t *\/\n\tif (task->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)\n\t\ttask->signal->oom_adj = OOM_DISABLE;\n\telse\n\t\ttask->signal->oom_adj = (oom_score_adj * OOM_ADJUST_MAX) \/\n\t\t\t\t\t\t\tOOM_SCORE_ADJ_MAX;\nerr_sighand:\n\tunlock_task_sighand(task, &flags);\nerr_task_lock:\n\ttask_unlock(task);\n\tput_task_struct(task);\nout:\n\treturn err < 0 ? err : count;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":254007,"func":"static int vidioc_try_fmt_out(struct file *file, void *priv, struct v4l2_format *fmt)\n{\n\tstruct v4l2_loopback_device *dev;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\n\t\/* TODO(vasaka) loopback does not care about formats writer want to set,\n\t * maybe it is a good idea to restrict format somehow *\/\n\tif (dev->ready_for_capture) {\n\t\tfmt->fmt.pix = dev->pix_format;\n\t} else {\n\t\t__u32 w = fmt->fmt.pix.width;\n\t\t__u32 h = fmt->fmt.pix.height;\n\t\t__u32 pixfmt = fmt->fmt.pix.pixelformat;\n\t\tconst struct v4l2l_format *format = format_by_fourcc(pixfmt);\n\n\t\tif (w > max_width)\n\t\t\tw = max_width;\n\t\tif (h > max_height)\n\t\t\th = max_height;\n\n\t\tdprintk(\"trying image %dx%d\\n\", w, h);\n\n\t\tif (w < 1)\n\t\t\tw = V4L2LOOPBACK_SIZE_DEFAULT_WIDTH;\n\n\t\tif (h < 1)\n\t\t\th = V4L2LOOPBACK_SIZE_DEFAULT_HEIGHT;\n\n\t\tif (NULL == format)\n\t\t\tformat = &formats[0];\n\n\t\tpix_format_set_size(&fmt->fmt.pix, format, w, h);\n\n\t\tfmt->fmt.pix.pixelformat = format->fourcc;\n\t\tfmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;\n\n\t\tif (V4L2_FIELD_ANY == fmt->fmt.pix.field)\n\t\t\tfmt->fmt.pix.field = V4L2_FIELD_NONE;\n\n\t\t\/* FIXXME: try_fmt should never modify the device-state *\/\n\t\tdev->pix_format = fmt->fmt.pix;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":221467,"func":"add_document_portal_args (FlatpakBwrap *bwrap,\n                          const char   *app_id,\n                          char        **out_mount_path)\n{\n  g_autoptr(GDBusConnection) session_bus = NULL;\n  g_autofree char *doc_mount_path = NULL;\n\n  session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);\n  if (session_bus)\n    {\n      g_autoptr(GError) local_error = NULL;\n      g_autoptr(GDBusMessage) reply = NULL;\n      g_autoptr(GDBusMessage) msg =\n        g_dbus_message_new_method_call (\"org.freedesktop.portal.Documents\",\n                                        \"\/org\/freedesktop\/portal\/documents\",\n                                        \"org.freedesktop.portal.Documents\",\n                                        \"GetMountPoint\");\n      g_dbus_message_set_body (msg, g_variant_new (\"()\"));\n      reply =\n        g_dbus_connection_send_message_with_reply_sync (session_bus, msg,\n                                                        G_DBUS_SEND_MESSAGE_FLAGS_NONE,\n                                                        30000,\n                                                        NULL,\n                                                        NULL,\n                                                        NULL);\n      if (reply)\n        {\n          if (g_dbus_message_to_gerror (reply, &local_error))\n            {\n              if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN))\n                g_debug (\"Document portal not available, not mounting \/run\/flatpak\/doc\");\n              else\n                g_message (\"Can't get document portal: %s\", local_error->message);\n            }\n          else\n            {\n              static const char dst_path[] = \"\/run\/flatpak\/doc\";\n              g_autofree char *src_path = NULL;\n              g_variant_get (g_dbus_message_get_body (reply),\n                             \"(^ay)\", &doc_mount_path);\n\n              src_path = g_strdup_printf (\"%s\/by-app\/%s\",\n                                          doc_mount_path, app_id);\n              flatpak_bwrap_add_args (bwrap, \"--bind\", src_path, dst_path, NULL);\n              flatpak_bwrap_add_runtime_dir_member (bwrap, \"doc\");\n            }\n        }\n    }\n\n  *out_mount_path = g_steal_pointer (&doc_mount_path);\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":369973,"func":"static int map_files_d_revalidate(struct dentry *dentry, struct nameidata *nd)\n{\n\tunsigned long vm_start, vm_end;\n\tbool exact_vma_exists = false;\n\tstruct mm_struct *mm = NULL;\n\tstruct task_struct *task;\n\tconst struct cred *cred;\n\tstruct inode *inode;\n\tint status = 0;\n\n\tif (nd && nd->flags & LOOKUP_RCU)\n\t\treturn -ECHILD;\n\n\tif (!capable(CAP_SYS_ADMIN)) {\n\t\tstatus = -EACCES;\n\t\tgoto out_notask;\n\t}\n\n\tinode = dentry->d_inode;\n\ttask = get_proc_task(inode);\n\tif (!task)\n\t\tgoto out_notask;\n\n\tif (!ptrace_may_access(task, PTRACE_MODE_READ))\n\t\tgoto out;\n\n\tmm = get_task_mm(task);\n\tif (!mm)\n\t\tgoto out;\n\n\tif (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) {\n\t\tdown_read(&mm->mmap_sem);\n\t\texact_vma_exists = !!find_exact_vma(mm, vm_start, vm_end);\n\t\tup_read(&mm->mmap_sem);\n\t}\n\n\tmmput(mm);\n\n\tif (exact_vma_exists) {\n\t\tif (task_dumpable(task)) {\n\t\t\trcu_read_lock();\n\t\t\tcred = __task_cred(task);\n\t\t\tinode->i_uid = cred->euid;\n\t\t\tinode->i_gid = cred->egid;\n\t\t\trcu_read_unlock();\n\t\t} else {\n\t\t\tinode->i_uid = 0;\n\t\t\tinode->i_gid = 0;\n\t\t}\n\t\tsecurity_task_to_inode(task, inode);\n\t\tstatus = 1;\n\t}\n\nout:\n\tput_task_struct(task);\n\nout_notask:\n\tif (status <= 0)\n\t\td_drop(dentry);\n\n\treturn status;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":262030,"func":"ServiceProtoQueryAliases(ServiceConnection *conn,\n                         ProtoRequest *req)\n{\n   VGAuthError err;\n   gchar *packet;\n   int num;\n   ServiceAlias *aList;\n\n   \/*\n    * The alias code will do argument validation.\n    *\/\n   err = ServiceAliasQueryAliases(req->reqData.queryAliases.userName,\n                                  &num,\n                                  &aList);\n\n   if (err != VGAUTH_E_OK) {\n      packet = Proto_MakeErrorReply(conn, req, err, \"queryAliases failed\");\n   } else {\n      int i;\n      gchar *endPacket;\n\n      packet = g_markup_printf_escaped(VGAUTH_QUERYALIASES_REPLY_FORMAT_START,\n                                       req->sequenceNumber);\n      \/\/ now the aliases\n      for (i = 0; i < num; i++) {\n         gchar *certPacket;\n         int j;\n\n         certPacket = g_markup_printf_escaped(VGAUTH_ALIAS_FORMAT_START,\n                                              aList[i].pemCert);\n         packet = Proto_ConcatXMLStrings(packet, certPacket);\n         for (j = 0; j < aList[i].num; j++) {\n            gchar *aiPacket;\n            ServiceAliasInfo *ai = &(aList[i].infos[j]);\n\n            if (ai->type == SUBJECT_TYPE_ANY) {\n               aiPacket = g_markup_printf_escaped(VGAUTH_ANYALIASINFO_FORMAT,\n                                                  ai->comment);\n            } else if (ai->type == SUBJECT_TYPE_NAMED) {\n               aiPacket = g_markup_printf_escaped(VGAUTH_NAMEDALIASINFO_FORMAT,\n                                                  ai->name,\n                                                  ai->comment);\n            } else {\n               aiPacket = NULL;\n               ASSERT(0);\n            }\n            packet = Proto_ConcatXMLStrings(packet, aiPacket);\n         }\n         packet = Proto_ConcatXMLStrings(packet,\n                                         g_markup_printf_escaped(VGAUTH_ALIAS_FORMAT_END));\n      }\n\n      \/\/ now the end of the reply\n      endPacket = g_markup_printf_escaped(VGAUTH_QUERYALIASES_REPLY_FORMAT_END);\n      packet = Proto_ConcatXMLStrings(packet, endPacket);\n\n\n      ServiceAliasFreeAliasList(num, aList);\n   }\n\n   err = ServiceNetworkWriteData(conn, strlen(packet), packet);\n   if (err != VGAUTH_E_OK) {\n      Warning(\"%s: failed to send QueryAliases reply\\n\", __FUNCTION__);\n   }\n\n   g_free(packet);\n\n   return err;\n}","target":0,"code_token_length":500,"total_token_length":736,"max_tokens_setting":1024}
+{"idx":371185,"func":"static pyc_object *get_complex_object(RzBinPycObj *pyc, RzBuffer *buffer) {\n\tpyc_object *ret = NULL;\n\tbool error = false;\n\tut32 n1 = 0;\n\tut32 n2 = 0;\n\n\tret = RZ_NEW0(pyc_object);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\n\tif ((pyc->magic_int & 0xffff) <= 62061) {\n\t\tn1 = get_ut8(buffer, &error);\n\t} else {\n\t\tn1 = get_st32(buffer, &error);\n\t}\n\tif (error || UT32_ADD_OVFCHK(n1, 1)) {\n\t\tfree(ret);\n\t\treturn NULL;\n\t}\n\tut8 *s1 = malloc(n1 + 1);\n\tif (!s1) {\n\t\treturn NULL;\n\t}\n\t\/* object contain string representation of the number *\/\n\tif (rz_buf_read(buffer, s1, n1) != n1) {\n\t\tRZ_FREE(s1);\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\ts1[n1] = '\\0';\n\n\tif ((pyc->magic_int & 0xffff) <= 62061) {\n\t\tn2 = get_ut8(buffer, &error);\n\t} else {\n\t\tn2 = get_st32(buffer, &error);\n\t}\n\tif (error || UT32_ADD_OVFCHK(n2, 1)) {\n\t\treturn NULL;\n\t}\n\tut8 *s2 = malloc(n2 + 1);\n\tif (!s2) {\n\t\treturn NULL;\n\t}\n\t\/* object contain string representation of the number *\/\n\tif (rz_buf_read(buffer, s2, n2) != n2) {\n\t\tRZ_FREE(s1);\n\t\tRZ_FREE(s2);\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\ts2[n2] = '\\0';\n\n\tret->type = TYPE_COMPLEX;\n\tret->data = rz_str_newf(\"%s+%sj\", s1, s2);\n\tRZ_FREE(s1);\n\tRZ_FREE(s2);\n\tif (!ret->data) {\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":231040,"func":"void vQueueDelete( QueueHandle_t xQueue )\r\n{\r\n    Queue_t * const pxQueue = xQueue;\r\n\r\n    configASSERT( pxQueue );\r\n    traceQUEUE_DELETE( pxQueue );\r\n\r\n    #if ( configQUEUE_REGISTRY_SIZE > 0 )\r\n        {\r\n            vQueueUnregisterQueue( pxQueue );\r\n        }\r\n    #endif\r\n\r\n    #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )\r\n        {\r\n            \/* The queue can only have been allocated dynamically - free it\r\n             * again. *\/\r\n            vPortFree( pxQueue );\r\n        }\r\n    #elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )\r\n        {\r\n            \/* The queue could have been allocated statically or dynamically, so\r\n             * check before attempting to free the memory. *\/\r\n            if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdFALSE )\r\n            {\r\n                vPortFree( pxQueue );\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n        }\r\n    #else \/* if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) *\/\r\n        {\r\n            \/* The queue must have been statically allocated, so is not going to be\r\n             * deleted.  Avoid compiler warnings about the unused parameter. *\/\r\n            ( void ) pxQueue;\r\n        }\r\n    #endif \/* configSUPPORT_DYNAMIC_ALLOCATION *\/\r\n}\r","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":222489,"func":"bool FunctionDefsEqual(const FunctionDef& f1, const FunctionDef& f2) {\n  if (!OpDefEqual(f1.signature(), f2.signature())) return false;\n\n  std::map<string, AttrValue> f1_attrs = GetSetAttrs(f1);\n  std::map<string, AttrValue> f2_attrs = GetSetAttrs(f2);\n  if (f1_attrs.size() != f2_attrs.size()) return false;\n  for (const auto& iter1 : f1_attrs) {\n    auto iter2 = f2_attrs.find(iter1.first);\n    if (iter2 == f2_attrs.end()) return false;\n    if (!AreAttrValuesEqual(iter1.second, iter2->second)) return false;\n  }\n\n  if (!EqualRepeatedNodeDef(f1.node_def(), f2.node_def(), nullptr)) {\n    return false;\n  }\n\n  std::map<string, string> ret1(f1.ret().begin(), f1.ret().end());\n  std::map<string, string> ret2(f2.ret().begin(), f2.ret().end());\n  if (ret1 != ret2) return false;\n\n  std::map<string, string> control_ret1(f1.control_ret().begin(),\n                                        f1.control_ret().end());\n  std::map<string, string> control_ret2(f2.control_ret().begin(),\n                                        f2.control_ret().end());\n  if (control_ret1 != control_ret2) return false;\n\n  return true;\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":238493,"func":"static int do_check_common(struct bpf_verifier_env *env, int subprog)\n{\n\tbool pop_log = !(env->log.level & BPF_LOG_LEVEL2);\n\tstruct bpf_verifier_state *state;\n\tstruct bpf_reg_state *regs;\n\tint ret, i;\n\n\tenv->prev_linfo = NULL;\n\tenv->pass_cnt++;\n\n\tstate = kzalloc(sizeof(struct bpf_verifier_state), GFP_KERNEL);\n\tif (!state)\n\t\treturn -ENOMEM;\n\tstate->curframe = 0;\n\tstate->speculative = false;\n\tstate->branches = 1;\n\tstate->frame[0] = kzalloc(sizeof(struct bpf_func_state), GFP_KERNEL);\n\tif (!state->frame[0]) {\n\t\tkfree(state);\n\t\treturn -ENOMEM;\n\t}\n\tenv->cur_state = state;\n\tinit_func_state(env, state->frame[0],\n\t\t\tBPF_MAIN_FUNC \/* callsite *\/,\n\t\t\t0 \/* frameno *\/,\n\t\t\tsubprog);\n\n\tregs = state->frame[state->curframe]->regs;\n\tif (subprog || env->prog->type == BPF_PROG_TYPE_EXT) {\n\t\tret = btf_prepare_func_args(env, subprog, regs);\n\t\tif (ret)\n\t\t\tgoto out;\n\t\tfor (i = BPF_REG_1; i <= BPF_REG_5; i++) {\n\t\t\tif (regs[i].type == PTR_TO_CTX)\n\t\t\t\tmark_reg_known_zero(env, regs, i);\n\t\t\telse if (regs[i].type == SCALAR_VALUE)\n\t\t\t\tmark_reg_unknown(env, regs, i);\n\t\t\telse if (base_type(regs[i].type) == PTR_TO_MEM) {\n\t\t\t\tconst u32 mem_size = regs[i].mem_size;\n\n\t\t\t\tmark_reg_known_zero(env, regs, i);\n\t\t\t\tregs[i].mem_size = mem_size;\n\t\t\t\tregs[i].id = ++env->id_gen;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t\/* 1st arg to a function *\/\n\t\tregs[BPF_REG_1].type = PTR_TO_CTX;\n\t\tmark_reg_known_zero(env, regs, BPF_REG_1);\n\t\tret = btf_check_subprog_arg_match(env, subprog, regs);\n\t\tif (ret == -EFAULT)\n\t\t\t\/* unlikely verifier bug. abort.\n\t\t\t * ret == 0 and ret < 0 are sadly acceptable for\n\t\t\t * main() function due to backward compatibility.\n\t\t\t * Like socket filter program may be written as:\n\t\t\t * int bpf_prog(struct pt_regs *ctx)\n\t\t\t * and never dereference that ctx in the program.\n\t\t\t * 'struct pt_regs' is a type mismatch for socket\n\t\t\t * filter that should be using 'struct __sk_buff'.\n\t\t\t *\/\n\t\t\tgoto out;\n\t}\n\n\tret = do_check(env);\nout:\n\t\/* check for NULL is necessary, since cur_state can be freed inside\n\t * do_check() under memory pressure.\n\t *\/\n\tif (env->cur_state) {\n\t\tfree_verifier_state(env->cur_state, true);\n\t\tenv->cur_state = NULL;\n\t}\n\twhile (!pop_stack(env, NULL, NULL, false));\n\tif (!ret && pop_log)\n\t\tbpf_vlog_reset(&env->log, 0);\n\tfree_states(env);\n\treturn ret;\n}","target":0,"code_token_length":674,"total_token_length":910,"max_tokens_setting":1024}
+{"idx":281627,"func":"void CLASS phase_one_flat_field (int is_float, int nc)\n{\n  ushort head[8];\n  unsigned wide, y, x, c, rend, cend, row, col;\n  float *mrow, num, mult[4];\n\n  read_shorts (head, 8);\n  wide = head[2] \/ head[4];\n  mrow = (float *) calloc (nc*wide, sizeof *mrow);\n  merror (mrow, \"phase_one_flat_field()\");\n  for (y=0; y < head[3] \/ head[5]; y++) {\n    for (x=0; x < wide; x++)\n      for (c=0; c < nc; c+=2) {\n\tnum = is_float ? getreal(11) : get2()\/32768.0;\n\tif (y==0) mrow[c*wide+x] = num;\n\telse mrow[(c+1)*wide+x] = (num - mrow[c*wide+x]) \/ head[5];\n      }\n    if (y==0) continue;\n    rend = head[1] + y*head[5];\n    for (row = rend-head[5]; row < raw_height && row < rend; row++) {\n      for (x=1; x < wide; x++) {\n\tfor (c=0; c < nc; c+=2) {\n\t  mult[c] = mrow[c*wide+x-1];\n\t  mult[c+1] = (mrow[c*wide+x] - mult[c]) \/ head[4];\n\t}\n\tcend = head[0] + x*head[4];\n\tfor (col = cend-head[4]; col < raw_width && col < cend; col++) {\n\t  c = nc > 2 ? FC(row-top_margin,col-left_margin) : 0;\n\t  if (!(c & 1)) {\n\t    c = RAW(row,col) * mult[c];\n\t    RAW(row,col) = LIM(c,0,65535);\n\t  }\n\t  for (c=0; c < nc; c+=2)\n\t    mult[c] += mult[c+1];\n\t}\n      }\n      for (x=0; x < wide; x++)\n\tfor (c=0; c < nc; c+=2)\n\t  mrow[c*wide+x] += mrow[(c+1)*wide+x];\n    }\n  }\n  free (mrow);\n}","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":223465,"func":"static SLJIT_INLINE PCRE2_SPTR compile_control_verb_matchingpath(compiler_common *common, PCRE2_SPTR cc, backtrack_common *parent)\n{\nDEFINE_COMPILER;\nbacktrack_common *backtrack;\nPCRE2_UCHAR opcode = *cc;\nPCRE2_SPTR ccend = cc + 1;\n\nif (opcode == OP_COMMIT_ARG || opcode == OP_PRUNE_ARG ||\n    opcode == OP_SKIP_ARG || opcode == OP_THEN_ARG)\n  ccend += 2 + cc[1];\n\nPUSH_BACKTRACK(sizeof(backtrack_common), cc, NULL);\n\nif (opcode == OP_SKIP)\n  {\n  allocate_stack(common, 1);\n  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);\n  return ccend;\n  }\n\nif (opcode == OP_COMMIT_ARG || opcode == OP_PRUNE_ARG || opcode == OP_THEN_ARG)\n  {\n  if (HAS_VIRTUAL_REGISTERS)\n    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);\n  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP2, 0);\n  OP1(SLJIT_MOV, SLJIT_MEM1(HAS_VIRTUAL_REGISTERS ? TMP1 : ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);\n  }\n\nreturn ccend;\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":508381,"func":"bool setup_on_expr(THD *thd, TABLE_LIST *table, bool is_update)\n{\n  uchar buff[STACK_BUFF_ALLOC];\t\t\t\/\/ Max argument in function\n  if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))\n    return TRUE;\t\t\t\t\/\/ Fatal error flag is set!\n  for(; table; table= table->next_local)\n  {\n    TABLE_LIST *embedded; \/* The table at the current level of nesting. *\/\n    TABLE_LIST *embedding= table; \/* The parent nested table reference. *\/\n    do\n    {\n      embedded= embedding;\n      if (embedded->on_expr)\n      {\n        thd->where=\"on clause\";\n        embedded->on_expr->mark_as_condition_AND_part(embedded);\n        if ((!embedded->on_expr->fixed &&\n             embedded->on_expr->fix_fields(thd, &embedded->on_expr)) ||\n            embedded->on_expr->check_cols(1))\n          return TRUE;\n      }\n      \/*\n        If it's a semi-join nest, fix its \"left expression\", as it is used by\n        the SJ-Materialization\n      *\/\n      if (embedded->sj_subq_pred)\n      {\n        Item **left_expr= &embedded->sj_subq_pred->left_expr;\n        if (!(*left_expr)->fixed && (*left_expr)->fix_fields(thd, left_expr))\n          return TRUE;\n      }\n\n      embedding= embedded->embedding;\n    }\n    while (embedding &&\n           embedding->nested_join->join_list.head() == embedded);\n\n    if (table->is_merged_derived())\n    {\n      SELECT_LEX *select_lex= table->get_single_select();\n      setup_on_expr(thd, select_lex->get_table_list(), is_update);\n    }\n\n    \/* process CHECK OPTION *\/\n    if (is_update)\n    {\n      TABLE_LIST *view= table->top_table();\n      if (view->effective_with_check)\n      {\n        if (view->prepare_check_option(thd))\n          return TRUE;\n        thd->change_item_tree(&table->check_option, view->check_option);\n      }\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":463030,"func":"extract_argv (EvDocument *document, gint page)\n{\n\tComicsDocument *comics_document = COMICS_DOCUMENT (document);\n\tchar **argv;\n\tchar *command_line, *quoted_archive, *quoted_filename;\n\tGError *err = NULL;\n\n\tif (g_strrstr (comics_document->page_names->pdata[page], \"--checkpoint-action=\"))\n\t{\n\t\tg_warning (\"File unsupported\\n\");\n\t\tgtk_main_quit ();\n\t}\n\n        if (page >= comics_document->page_names->len)\n                return NULL;\n\n\tif (comics_document->regex_arg) {\n\t\tquoted_archive = g_shell_quote (comics_document->archive);\n\t\tquoted_filename =\n\t\t\tcomics_regex_quote (comics_document->page_names->pdata[page]);\n\t} else {\n\t\tquoted_archive = g_shell_quote (comics_document->archive);\n\t\tquoted_filename = g_shell_quote (comics_document->page_names->pdata[page]);\n\t}\n\n\tcommand_line = g_strdup_printf (\"%s %s %s\",\n\t\t\t\t\tcomics_document->extract_command,\n\t\t\t\t\tquoted_archive,\n\t\t\t\t\tquoted_filename);\n\tg_free (quoted_archive);\n\tg_free (quoted_filename);\n\n\tg_shell_parse_argv (command_line, NULL, &argv, &err);\n\tg_free (command_line);\n\n\tif (err) {\n\t\tg_warning (_(\"Error %s\"), err->message);\n\t\tg_error_free (err);\n\t\treturn NULL;\n\t}\n\n\treturn argv;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":359473,"func":"bgp_default_update_send (struct peer *peer, struct attr *attr,\n\t\t\t afi_t afi, safi_t safi, struct peer *from)\n{\n  struct stream *s;\n  struct stream *packet;\n  struct prefix p;\n  unsigned long pos;\n  bgp_size_t total_attr_len;\n  char attrstr[BUFSIZ];\n  char buf[BUFSIZ];\n\n#ifdef DISABLE_BGP_ANNOUNCE\n  return;\n#endif \/* DISABLE_BGP_ANNOUNCE *\/\n\n  if (afi == AFI_IP)\n    str2prefix (\"0.0.0.0\/0\", &p);\n#ifdef HAVE_IPV6\n  else \n    str2prefix (\"::\/0\", &p);\n#endif \/* HAVE_IPV6 *\/\n\n  \/* Logging the attribute. *\/\n  if (BGP_DEBUG (update, UPDATE_OUT))\n    {\n      bgp_dump_attr (peer, attr, attrstr, BUFSIZ);\n      zlog (peer->log, LOG_DEBUG, \"%s send UPDATE %s\/%d %s\",\n\t    peer->host, inet_ntop(p.family, &(p.u.prefix), buf, BUFSIZ),\n\t    p.prefixlen, attrstr);\n    }\n\n  s = stream_new (BGP_MAX_PACKET_SIZE);\n\n  \/* Make BGP update packet. *\/\n  bgp_packet_set_marker (s, BGP_MSG_UPDATE);\n\n  \/* Unfeasible Routes Length. *\/\n  stream_putw (s, 0);\n\n  \/* Make place for total attribute length.  *\/\n  pos = stream_get_endp (s);\n  stream_putw (s, 0);\n  total_attr_len = bgp_packet_attribute (NULL, peer, s, attr, &p, afi, safi, from, NULL, NULL);\n\n  \/* Set Total Path Attribute Length. *\/\n  stream_putw_at (s, pos, total_attr_len);\n\n  \/* NLRI set. *\/\n  if (p.family == AF_INET && safi == SAFI_UNICAST)\n    stream_put_prefix (s, &p);\n\n  \/* Set size. *\/\n  bgp_packet_set_size (s);\n\n  packet = stream_dup (s);\n  stream_free (s);\n\n  \/* Dump packet if debug option is set. *\/\n#ifdef DEBUG\n  \/* bgp_packet_dump (packet); *\/\n#endif \/* DEBUG *\/\n\n  \/* Add packet to the peer. *\/\n  bgp_packet_add (peer, packet);\n\n  BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":234150,"func":"get_type_abbrev_from_form (unsigned long form,\n\t\t\t   unsigned long uvalue,\n\t\t\t   dwarf_vma cu_offset,\n\t\t\t   unsigned char *cu_end,\n\t\t\t   const struct dwarf_section *section,\n\t\t\t   unsigned long *abbrev_num_return,\n\t\t\t   unsigned char **data_return,\n\t\t\t   abbrev_map **map_return)\n{\n  unsigned long   abbrev_number;\n  abbrev_map *    map;\n  abbrev_entry *  entry;\n  unsigned char * data;\n\n  if (abbrev_num_return != NULL)\n    * abbrev_num_return = 0;\n  if (data_return != NULL)\n    * data_return = NULL;\n\n  switch (form)\n    {\n    case DW_FORM_GNU_ref_alt:\n    case DW_FORM_ref_sig8:\n      \/* FIXME: We are unable to handle this form at the moment.  *\/\n      return NULL;\n\n    case DW_FORM_ref_addr:\n      if (uvalue >= section->size)\n\t{\n\t  warn (_(\"Unable to resolve ref_addr form: uvalue %lx > section size %lx (%s)\\n\"),\n\t\tuvalue, (long) section->size, section->name);\n\t  return NULL;\n\t}\n      break;\n\n    case DW_FORM_ref_sup4:\n    case DW_FORM_ref_sup8:\n      break;\n\n    case DW_FORM_ref1:\n    case DW_FORM_ref2:\n    case DW_FORM_ref4:\n    case DW_FORM_ref8:\n    case DW_FORM_ref_udata:\n      if (uvalue + cu_offset > (size_t) (cu_end - section->start))\n\t{\n\t  warn (_(\"Unable to resolve ref form: uvalue %lx + cu_offset %lx > CU size %lx\\n\"),\n\t\tuvalue, (long) cu_offset, (long) (cu_end - section->start));\n\t  return NULL;\n\t}\n      uvalue += cu_offset;\n      break;\n\n      \/* FIXME: Are there other DW_FORMs that can be used by types ?  *\/\n\n    default:\n      warn (_(\"Unexpected form %lx encountered whilst finding abbreviation for type\\n\"), form);\n      return NULL;\n    }\n\n  data = (unsigned char *) section->start + uvalue;\n  map = find_abbrev_map_by_offset (uvalue);\n\n  if (map == NULL)\n    {\n      warn (_(\"Unable to find abbreviations for CU offset %#lx\\n\"), uvalue);\n      return NULL;\n    }\n  if (map->list == NULL)\n    {\n      warn (_(\"Empty abbreviation list encountered for CU offset %lx\\n\"), uvalue);\n      return NULL;\n    }\n\n  if (map_return != NULL)\n    {\n      if (form == DW_FORM_ref_addr)\n\t*map_return = map;\n      else\n\t*map_return = NULL;\n    }\n\t\n  READ_ULEB (abbrev_number, data, section->start + section->size);\n\n  for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)\n    if (entry->number == abbrev_number)\n      break;\n\n  if (abbrev_num_return != NULL)\n    * abbrev_num_return = abbrev_number;\n\n  if (data_return != NULL)\n    * data_return = data;\n\n  if (entry == NULL)\n    warn (_(\"Unable to find entry for abbreviation %lu\\n\"), abbrev_number);\n\n  return entry;\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":243982,"func":"GF_Err stsz_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\t\/\/in both versions this is still valid\n\tif (ptr->type == GF_ISOM_BOX_TYPE_STSZ) {\n\t\tgf_bs_write_u32(bs, ptr->sampleSize);\n\t} else {\n\t\tgf_bs_write_u24(bs, 0);\n\t\tgf_bs_write_u8(bs, ptr->sampleSize);\n\t}\n\tgf_bs_write_u32(bs, ptr->sampleCount);\n\n\tif (ptr->type == GF_ISOM_BOX_TYPE_STSZ) {\n\t\tif (ptr->sampleSize) return GF_OK;\n\t\tfor (i = 0; i < ptr->sampleCount; i++) {\n\t\t\tgf_bs_write_u32(bs, ptr->sizes ? ptr->sizes[i] : 0);\n\t\t}\n\t} else {\n\t\tif (!ptr->sizes) return GF_ISOM_INVALID_FILE;\n\t\tfor (i = 0; i < ptr->sampleCount; ) {\n\t\t\tswitch (ptr->sampleSize) {\n\t\t\tcase 4:\n\t\t\t\tgf_bs_write_int(bs, ptr->sizes[i], 4);\n\t\t\t\tif (i+1 < ptr->sampleCount) {\n\t\t\t\t\tgf_bs_write_int(bs, ptr->sizes[i+1], 4);\n\t\t\t\t} else {\n\t\t\t\t\t\/\/0 padding in odd sample count\n\t\t\t\t\tgf_bs_write_int(bs, 0, 4);\n\t\t\t\t}\n\t\t\t\ti += 2;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tgf_bs_write_int(bs, ptr->sizes[i], ptr->sampleSize);\n\t\t\t\ti += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":458991,"func":"HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, hdr_t hdr)\n{\n\tconst char *ptr;\n\tunsigned l;\n\n\tCHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);\n\tCHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);\n\tAN(hdr);\n\n\tl = hdr[0];\n\tassert(l > 0);\n\tassert(l == strlen(hdr + 1));\n\tassert(hdr[l] == ':');\n\thdr++;\n\n\tif (hdr[0] == ':') {\n\t\t\/* Special cases *\/\n\t\tptr = ObjGetAttr(wrk, oc, OA_HEADERS, NULL);\n\t\tAN(ptr);\n\t\tptr += 4;\t\/* Skip nhd and status *\/\n\n\t\t\/* XXX: should we also have h2_hdr_eq() ? *\/\n\t\tif (!strcmp(hdr, \":proto:\"))\n\t\t\treturn (ptr);\n\t\tptr = strchr(ptr, '\\0') + 1;\n\t\tif (!strcmp(hdr, \":status:\"))\n\t\t\treturn (ptr);\n\t\tptr = strchr(ptr, '\\0') + 1;\n\t\tif (!strcmp(hdr, \":reason:\"))\n\t\t\treturn (ptr);\n\t\tWRONG(\"Unknown magic packed header\");\n\t}\n\n\tHTTP_FOREACH_PACK(wrk, oc, ptr) {\n\t\tif (http_hdr_at(ptr, hdr, l)) {\n\t\t\tptr += l;\n\t\t\twhile (vct_islws(*ptr))\n\t\t\t\tptr++;\n\t\t\treturn (ptr);\n\t\t}\n\t}\n\n\treturn (NULL);\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":247579,"func":"TEST_P(SslSocketTest, CertificatesWithPassword) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/password_protected_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/password_protected_key.pem\"));\n  server_cert->mutable_password()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/password_protected_password.txt\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  server_validation_ctx->mutable_trusted_ca()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"));\n  server_validation_ctx->add_verify_certificate_hash(\n      \"0000000000000000000000000000000000000000000000000000000000000000\");\n  server_validation_ctx->add_verify_certificate_hash(TEST_PASSWORD_PROTECTED_CERT_256_HASH);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/password_protected_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir \"\n      \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/password_protected_key.pem\"));\n  client_cert->mutable_password()->set_inline_string(\n      TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(\n          \"{{ test_rundir \"\n          \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/password_protected_password.txt\")));\n\n  TestUtilOptionsV2 test_options(listener, client, true, GetParam());\n  testUtilV2(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedServerCertDigest(TEST_PASSWORD_PROTECTED_CERT_256_HASH));\n\n  \/\/ Works even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":693,"total_token_length":929,"max_tokens_setting":1024}
+{"idx":223413,"func":"static void do_getucdtype(compiler_common *common)\n{\n\/* Search the UCD record for the character comes in TMP1.\nReturns chartype in TMP1 and UCD offset in TMP2. *\/\nDEFINE_COMPILER;\n#if PCRE2_CODE_UNIT_WIDTH == 32\nstruct sljit_jump *jump;\n#endif\n\n#if defined SLJIT_DEBUG && SLJIT_DEBUG\n\/* dummy_ucd_record *\/\nconst ucd_record *record = GET_UCD(UNASSIGNED_UTF_CHAR);\nSLJIT_ASSERT(record->script == ucp_Unknown && record->chartype == ucp_Cn && record->gbprop == ucp_gbOther);\nSLJIT_ASSERT(record->caseset == 0 && record->other_case == 0);\n#endif\n\nSLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && sizeof(ucd_record) == 12);\n\nsljit_emit_fast_enter(compiler, RETURN_ADDR, 0);\n\n#if PCRE2_CODE_UNIT_WIDTH == 32\nif (!common->utf)\n  {\n  jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1);\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, UNASSIGNED_UTF_CHAR);\n  JUMPHERE(jump);\n  }\n#endif\n\nOP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);\nOP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));\nOP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\nOP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));\nOP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);\n\n\/* TMP2 is multiplied by 12. Same as (TMP2 << 2) + ((TMP2 << 2) << 1). *\/\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\nOP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 1);\n\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n}","target":0,"code_token_length":714,"total_token_length":950,"max_tokens_setting":1024}
+{"idx":244206,"func":"void sgpd_del_entry(u32 grouping_type, void *entry)\n{\n\tswitch (grouping_type) {\n\tcase GF_ISOM_SAMPLE_GROUP_SYNC:\n\tcase GF_ISOM_SAMPLE_GROUP_ROLL:\n\tcase GF_ISOM_SAMPLE_GROUP_PROL:\n\tcase GF_ISOM_SAMPLE_GROUP_RAP:\n\tcase GF_ISOM_SAMPLE_GROUP_TELE:\n\tcase GF_ISOM_SAMPLE_GROUP_SAP:\n\t\tgf_free(entry);\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_SEIG:\n\t{\n\t\tGF_CENCSampleEncryptionGroupEntry *seig = (GF_CENCSampleEncryptionGroupEntry *)entry;\n\t\tif (seig->key_info) gf_free(seig->key_info);\n\t\tgf_free(entry);\n\t}\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_OINF:\n\t\tgf_isom_oinf_del_entry(entry);\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_LINF:\n\t\tgf_isom_linf_del_entry(entry);\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_SPOR:\n\t{\n\t\tGF_SubpictureOrderEntry *spor = (GF_SubpictureOrderEntry *)entry;\n\t\tif (spor->subp_track_ref_idx) gf_free(spor->subp_track_ref_idx);\n\t\tgf_free(spor);\n\t}\n\t\treturn;\n\n\tcase GF_ISOM_SAMPLE_GROUP_SULM:\n\t{\n\t\tGF_SubpictureLayoutMapEntry *sulm = (GF_SubpictureLayoutMapEntry *) entry;\n\t\tif (sulm->groupIDs) gf_free(sulm->groupIDs);\n\t\tgf_free(sulm);\n\t\treturn;\n\t}\n\n\tdefault:\n\t{\n\t\tGF_DefaultSampleGroupDescriptionEntry *ptr = (GF_DefaultSampleGroupDescriptionEntry *)entry;\n\t\tif (ptr->data) gf_free(ptr->data);\n\t\tgf_free(ptr);\n\t}\n\t}\n}","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":318093,"func":"static int rsi_usb_load_data_master_write(struct rsi_hw *adapter,\n\t\t\t\t\t  u32 base_address,\n\t\t\t\t\t  u32 instructions_sz, u16 block_size,\n\t\t\t\t\t  u8 *ta_firmware)\n{\n\tu16 num_blocks;\n\tu32 cur_indx, i;\n\tu8 temp_buf[256];\n\tint status;\n\n\tnum_blocks = instructions_sz \/ block_size;\n\trsi_dbg(INFO_ZONE, \"num_blocks: %d\\n\", num_blocks);\n\n\tfor (cur_indx = 0, i = 0; i < num_blocks; i++, cur_indx += block_size) {\n\t\tmemcpy(temp_buf, ta_firmware + cur_indx, block_size);\n\t\tstatus = rsi_usb_write_register_multiple(adapter, base_address,\n\t\t\t\t\t\t\t (u8 *)(temp_buf),\n\t\t\t\t\t\t\t block_size);\n\t\tif (status < 0)\n\t\t\treturn status;\n\n\t\trsi_dbg(INFO_ZONE, \"%s: loading block: %d\\n\", __func__, i);\n\t\tbase_address += block_size;\n\t}\n\n\tif (instructions_sz % block_size) {\n\t\tmemset(temp_buf, 0, block_size);\n\t\tmemcpy(temp_buf, ta_firmware + cur_indx,\n\t\t       instructions_sz % block_size);\n\t\tstatus = rsi_usb_write_register_multiple\n\t\t\t\t\t\t(adapter, base_address,\n\t\t\t\t\t\t (u8 *)temp_buf,\n\t\t\t\t\t\t instructions_sz % block_size);\n\t\tif (status < 0)\n\t\t\treturn status;\n\t\trsi_dbg(INFO_ZONE,\n\t\t\t\"Written Last Block in Address 0x%x Successfully\\n\",\n\t\t\tcur_indx);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":386590,"func":"void DL_Dxf::writeDimAligned(DL_WriterA& dw,\n                             const DL_DimensionData& data,\n                             const DL_DimAlignedData& edata,\n                             const DL_Attributes& attrib) {\n\n    dw.entity(\"DIMENSION\");\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbDimension\");\n    }\n\n    dw.dxfReal(10, data.dpx);\n    dw.dxfReal(20, data.dpy);\n    dw.dxfReal(30, data.dpz);\n\n    dw.dxfReal(11, data.mpx);\n    dw.dxfReal(21, data.mpy);\n    dw.dxfReal(31, 0.0);\n\n    dw.dxfInt(70, data.type);\n    if (version>DL_VERSION_R12) {\n        dw.dxfInt(71, data.attachmentPoint);\n        dw.dxfInt(72, data.lineSpacingStyle); \/\/ opt\n        dw.dxfInt(74, data.arrow1Flipped);\n        dw.dxfInt(75, data.arrow2Flipped);\n        dw.dxfReal(41, data.lineSpacingFactor); \/\/ opt\n    }\n\n    dw.dxfReal(42, data.angle);\n\n    dw.dxfString(1, data.text);   \/\/ opt\n    \/\/dw.dxfString(3, data.style);\n    dw.dxfString(3, \"Standard\");\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbAlignedDimension\");\n    }\n\n    dw.dxfReal(13, edata.epx1);\n    dw.dxfReal(23, edata.epy1);\n    dw.dxfReal(33, 0.0);\n\n    dw.dxfReal(14, edata.epx2);\n    dw.dxfReal(24, edata.epy2);\n    dw.dxfReal(34, 0.0);\n\n    writeDimStyleOverrides(dw, data);\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":437718,"func":"static void control_rx_s_carrier_window(struct cx23885_dev *dev,\n\t\t\t\t\tunsigned int carrier,\n\t\t\t\t\tunsigned int *carrier_range_low,\n\t\t\t\t\tunsigned int *carrier_range_high)\n{\n\tu32 v;\n\tunsigned int c16 = carrier * 16;\n\n\tif (*carrier_range_low < DIV_ROUND_CLOSEST(c16, 16 + 3)) {\n\t\tv = CNTRL_WIN_3_4;\n\t\t*carrier_range_low = DIV_ROUND_CLOSEST(c16, 16 + 4);\n\t} else {\n\t\tv = CNTRL_WIN_3_3;\n\t\t*carrier_range_low = DIV_ROUND_CLOSEST(c16, 16 + 3);\n\t}\n\n\tif (*carrier_range_high > DIV_ROUND_CLOSEST(c16, 16 - 3)) {\n\t\tv |= CNTRL_WIN_4_3;\n\t\t*carrier_range_high = DIV_ROUND_CLOSEST(c16, 16 - 4);\n\t} else {\n\t\tv |= CNTRL_WIN_3_3;\n\t\t*carrier_range_high = DIV_ROUND_CLOSEST(c16, 16 - 3);\n\t}\n\tcx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~CNTRL_WIN, v);\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":224575,"func":"Status ReduceScatterShape(shape_inference::InferenceContext* c) {\n  shape_inference::ShapeHandle in = c->input(0);\n  if (!c->RankKnown(in)) {\n    \/\/ Input shape unknown, so set unknown output shape.\n    c->set_output(0, in);\n    return Status::OK();\n  }\n\n  shape_inference::ShapeHandle group_assignment_shape = c->input(1);\n  if (c->Rank(group_assignment_shape) != 2)\n    return errors::InvalidArgument(\n        \"ReduceScatter group_assignment should be rank 2\");\n\n  const Tensor* scatter_dimension = c->input_tensor(2);\n  if (!scatter_dimension) {\n    c->set_output(0, c->UnknownShape());\n    return Status::OK();\n  }\n  int64_t scatter_dim;\n  TF_RETURN_IF_ERROR(c->GetScalarFromTensor(scatter_dimension, &scatter_dim));\n\n  std::vector<shape_inference::DimensionHandle> out_dims;\n  out_dims.reserve(c->Rank(in));\n  for (int i = 0; i < c->Rank(in); ++i) {\n    \/\/ If the dimension is the scatter_dimension, then divide the dimension\n    \/\/ by the partition size in the group_assignment.\n    if (i == scatter_dim) {\n      shape_inference::DimensionHandle dim = c->Dim(in, i);\n      shape_inference::DimensionHandle out_dim;\n      TF_RETURN_IF_ERROR(c->Divide(dim, c->Dim(group_assignment_shape, 1),\n                                   \/*evenly_divisible=*\/true, &out_dim));\n      out_dims.push_back(out_dim);\n    } else {\n      out_dims.emplace_back(c->Dim(in, i));\n    }\n  }\n  c->set_output(0, c->MakeShape(out_dims));\n  return Status::OK();\n}","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":413659,"func":"static int fcn_print_verbose(RCore *core, RAnalFunction *fcn, bool use_color) {\n\tchar *name = r_core_anal_fcn_name (core, fcn);\n\tint ebbs = 0;\n\tint addrwidth = 8;\n\tconst char *color = \"\";\n\tconst char *color_end = \"\";\n\tif (use_color) {\n\t\tcolor_end = Color_RESET;\n\t\tif (strstr (name, \"sym.imp.\")) {\n\t\t\tcolor = Color_YELLOW;\n\t\t} else if (strstr (name, \"sym.\")) {\n\t\t\tcolor = Color_GREEN;\n\t\t} else if (strstr (name, \"sub.\")) {\n\t\t\tcolor = Color_MAGENTA;\n\t\t}\n\t}\n\n\tif (core->anal->bits == 64) {\n\t\taddrwidth = 16;\n\t}\n\n\tr_cons_printf (FCN_LIST_VERBOSE_ENTRY, color,\n\t\t\taddrwidth, fcn->addr,\n\t\t\tr_anal_function_realsize (fcn),\n\t\t\tr_list_length (fcn->bbs),\n\t\t\tr_anal_function_count_edges (fcn, &ebbs),\n\t\t\tr_anal_function_complexity (fcn),\n\t\t\tr_anal_function_cost (fcn),\n\t\t\taddrwidth, r_anal_function_min_addr (fcn),\n\t\t\tr_anal_function_linear_size (fcn),\n\t\t\taddrwidth, r_anal_function_max_addr (fcn),\n\t\t\tfcn->meta.numcallrefs,\n\t\t\tr_anal_var_count_locals (fcn),\n\t\t\tr_anal_var_count_args (fcn),\n\t\t\tfcn->meta.numrefs,\n\t\t\tfcn->maxstack,\n\t\t\tname,\n\t\t\tcolor_end);\n\tfree (name);\n\treturn 0;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":450352,"func":"static void write_png_palette(int idx, uint32_t pix, void *opaque)\n{\n    struct palette_cb_priv *priv = opaque;\n    VncState *vs = priv->vs;\n    png_colorp color = &priv->png_palette[idx];\n\n    if (vs->tight->pixel24)\n    {\n        color->red = (pix >> vs->client_pf.rshift) & vs->client_pf.rmax;\n        color->green = (pix >> vs->client_pf.gshift) & vs->client_pf.gmax;\n        color->blue = (pix >> vs->client_pf.bshift) & vs->client_pf.bmax;\n    }\n    else\n    {\n        int red, green, blue;\n\n        red = (pix >> vs->client_pf.rshift) & vs->client_pf.rmax;\n        green = (pix >> vs->client_pf.gshift) & vs->client_pf.gmax;\n        blue = (pix >> vs->client_pf.bshift) & vs->client_pf.bmax;\n        color->red = ((red * 255 + vs->client_pf.rmax \/ 2) \/\n                      vs->client_pf.rmax);\n        color->green = ((green * 255 + vs->client_pf.gmax \/ 2) \/\n                        vs->client_pf.gmax);\n        color->blue = ((blue * 255 + vs->client_pf.bmax \/ 2) \/\n                       vs->client_pf.bmax);\n    }\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":252321,"func":"static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs,\n                                     const void *pBuf, size_t n) {\n  mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;\n  mz_zip_internal_state *pState = pZip->m_pState;\n  mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size);\n#ifdef _MSC_VER\n  if ((!n) ||\n      ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)))\n#else\n  if ((!n) ||\n      ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)))\n#endif\n    return 0;\n  if (new_size > pState->m_mem_capacity) {\n    void *pNew_block;\n    size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity);\n    while (new_capacity < new_size) new_capacity *= 2;\n    if (NULL == (pNew_block = pZip->m_pRealloc(\n                     pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity)))\n      return 0;\n    pState->m_pMem = pNew_block;\n    pState->m_mem_capacity = new_capacity;\n  }\n  memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n);\n  pState->m_mem_size = (size_t)new_size;\n  return n;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":259261,"func":"static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    int last, type, size, ret;\n    uint8_t buf[4];\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    if ((uint64_t)atom.size > (1<<30) || atom.size < 42)\n        return AVERROR_INVALIDDATA;\n\n    \/* Check FlacSpecificBox version. *\/\n    if (avio_r8(pb) != 0)\n        return AVERROR_INVALIDDATA;\n\n    avio_rb24(pb); \/* Flags *\/\n\n    if (avio_read(pb, buf, sizeof(buf)) != sizeof(buf)) {\n        av_log(c->fc, AV_LOG_ERROR, \"failed to read FLAC metadata block header\\n\");\n        return pb->error < 0 ? pb->error : AVERROR_INVALIDDATA;\n    }\n    flac_parse_block_header(buf, &last, &type, &size);\n\n    if (type != FLAC_METADATA_TYPE_STREAMINFO || size != FLAC_STREAMINFO_SIZE) {\n        av_log(c->fc, AV_LOG_ERROR, \"STREAMINFO must be first FLACMetadataBlock\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n\n    ret = ff_get_extradata(c->fc, st->codecpar, pb, size);\n    if (ret < 0)\n        return ret;\n\n    if (!last)\n        av_log(c->fc, AV_LOG_WARNING, \"non-STREAMINFO FLACMetadataBlock(s) ignored\\n\");\n\n    return 0;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":253549,"func":"receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,\n\t\t       int *num_mids)\n{\n\tchar *buf = server->smallbuf;\n\tstruct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf;\n\tunsigned int npages;\n\tstruct page **pages;\n\tunsigned int len;\n\tunsigned int buflen = server->pdu_size;\n\tint rc;\n\tint i = 0;\n\tstruct smb2_decrypt_work *dw;\n\n\t*num_mids = 1;\n\tlen = min_t(unsigned int, buflen, server->vals->read_rsp_size +\n\t\tsizeof(struct smb2_transform_hdr)) - HEADER_SIZE(server) + 1;\n\n\trc = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, len);\n\tif (rc < 0)\n\t\treturn rc;\n\tserver->total_read += rc;\n\n\tlen = le32_to_cpu(tr_hdr->OriginalMessageSize) -\n\t\tserver->vals->read_rsp_size;\n\tnpages = DIV_ROUND_UP(len, PAGE_SIZE);\n\n\tpages = kmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);\n\tif (!pages) {\n\t\trc = -ENOMEM;\n\t\tgoto discard_data;\n\t}\n\n\tfor (; i < npages; i++) {\n\t\tpages[i] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM);\n\t\tif (!pages[i]) {\n\t\t\trc = -ENOMEM;\n\t\t\tgoto discard_data;\n\t\t}\n\t}\n\n\t\/* read read data into pages *\/\n\trc = read_data_into_pages(server, pages, npages, len);\n\tif (rc)\n\t\tgoto free_pages;\n\n\trc = cifs_discard_remaining_data(server);\n\tif (rc)\n\t\tgoto free_pages;\n\n\t\/*\n\t * For large reads, offload to different thread for better performance,\n\t * use more cores decrypting which can be expensive\n\t *\/\n\n\tif ((server->min_offload) && (server->in_flight > 1) &&\n\t    (server->pdu_size >= server->min_offload)) {\n\t\tdw = kmalloc(sizeof(struct smb2_decrypt_work), GFP_KERNEL);\n\t\tif (dw == NULL)\n\t\t\tgoto non_offloaded_decrypt;\n\n\t\tdw->buf = server->smallbuf;\n\t\tserver->smallbuf = (char *)cifs_small_buf_get();\n\n\t\tINIT_WORK(&dw->decrypt, smb2_decrypt_offload);\n\n\t\tdw->npages = npages;\n\t\tdw->server = server;\n\t\tdw->ppages = pages;\n\t\tdw->len = len;\n\t\tqueue_work(decrypt_wq, &dw->decrypt);\n\t\t*num_mids = 0; \/* worker thread takes care of finding mid *\/\n\t\treturn -1;\n\t}\n\nnon_offloaded_decrypt:\n\trc = decrypt_raw_data(server, buf, server->vals->read_rsp_size,\n\t\t\t      pages, npages, len, false);\n\tif (rc)\n\t\tgoto free_pages;\n\n\t*mid = smb2_find_mid(server, buf);\n\tif (*mid == NULL)\n\t\tcifs_dbg(FYI, \"mid not found\\n\");\n\telse {\n\t\tcifs_dbg(FYI, \"mid found\\n\");\n\t\t(*mid)->decrypted = true;\n\t\trc = handle_read_data(server, *mid, buf,\n\t\t\t\t      server->vals->read_rsp_size,\n\t\t\t\t      pages, npages, len, false);\n\t\tif (rc >= 0) {\n\t\t\tif (server->ops->is_network_name_deleted) {\n\t\t\t\tserver->ops->is_network_name_deleted(buf,\n\t\t\t\t\t\t\t\tserver);\n\t\t\t}\n\t\t}\n\t}\n\nfree_pages:\n\tfor (i = i - 1; i >= 0; i--)\n\t\tput_page(pages[i]);\n\tkfree(pages);\n\treturn rc;\ndiscard_data:\n\tcifs_discard_remaining_data(server);\n\tgoto free_pages;\n}","target":0,"code_token_length":778,"total_token_length":1014,"max_tokens_setting":1024}
+{"idx":222877,"func":"  bool ShouldUpdateOutputShapesAndValues(NodeContext* c, int64_t max_size) {\n    InferenceContext* ic = c->inference_context.get();\n\n    \/\/ Due to the cost of running EvaluateNode(), we limit only to white listed\n    \/\/ op types.\n    if (!IsAllowListedOpTypeForEvaluateNode(c->op_data->op_def.name())) {\n      return false;\n    }\n\n    \/\/ Check input dtypes are number types.\n    for (const auto& input_type : c->input_types) {\n      if (!IsNumericType(input_type)) {\n        return false;\n      }\n    }\n\n    \/\/ Check output dtypes are number types.\n    for (const auto& output_type : c->output_types) {\n      if (!IsNumericType(output_type)) {\n        return false;\n      }\n    }\n\n    \/\/ Check if the number of elements of each of input tensor is no larger than\n    \/\/ the given max size.\n    for (int i = 0; i < ic->num_inputs(); i++) {\n      const Tensor* tensor = ic->input_tensor(i);\n      const ShapeHandle& input_shape_handle = ic->input(i);\n      if (tensor != nullptr) {\n        if (tensor->NumElements() > max_size) {\n          return false;\n        }\n      } else if (ic->Value(ic->NumElements(input_shape_handle)) > max_size) {\n        return false;\n      }\n    }\n\n    \/\/ Check if we know the shape of each output tensor, and the number of\n    \/\/ elements is larger than the given max size.\n    for (int i = 0; i < ic->num_outputs(); i++) {\n      const ShapeHandle& shape_handle = ic->output(i);\n      if (!ic->FullyDefined(shape_handle) ||\n          ic->Value(ic->NumElements(shape_handle)) > max_size) {\n        return false;\n      }\n    }\n    return true;\n  }","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":427733,"func":"cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,\n    const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,\n    const cdf_dir_t *dir)\n{\n\tsize_t i, j;\n\tcdf_directory_t *d;\n\tchar name[__arraycount(d->d_name)];\n\tcdf_stream_t scn;\n\tstruct timespec ts;\n\n\tstatic const char *types[] = { \"empty\", \"user storage\",\n\t    \"user stream\", \"lockbytes\", \"property\", \"root storage\" };\n\n\tfor (i = 0; i < dir->dir_len; i++) {\n\t\tchar buf[26];\n\t\td = &dir->dir_tab[i];\n\t\tfor (j = 0; j < sizeof(name); j++)\n\t\t\tname[j] = (char)CDF_TOLE2(d->d_name[j]);\n\t\t(void)fprintf(stderr, \"Directory %\" SIZE_T_FORMAT \"u: %s\\n\",\n\t\t    i, name);\n\t\tif (d->d_type < __arraycount(types))\n\t\t\t(void)fprintf(stderr, \"Type: %s\\n\", types[d->d_type]);\n\t\telse\n\t\t\t(void)fprintf(stderr, \"Type: %d\\n\", d->d_type);\n\t\t(void)fprintf(stderr, \"Color: %s\\n\",\n\t\t    d->d_color ? \"black\" : \"red\");\n\t\t(void)fprintf(stderr, \"Left child: %d\\n\", d->d_left_child);\n\t\t(void)fprintf(stderr, \"Right child: %d\\n\", d->d_right_child);\n\t\t(void)fprintf(stderr, \"Flags: %#x\\n\", d->d_flags);\n\t\tcdf_timestamp_to_timespec(&ts, d->d_created);\n\t\t(void)fprintf(stderr, \"Created %s\", cdf_ctime(&ts.tv_sec, buf));\n\t\tcdf_timestamp_to_timespec(&ts, d->d_modified);\n\t\t(void)fprintf(stderr, \"Modified %s\",\n\t\t    cdf_ctime(&ts.tv_sec, buf));\n\t\t(void)fprintf(stderr, \"Stream %d\\n\", d->d_stream_first_sector);\n\t\t(void)fprintf(stderr, \"Size %d\\n\", d->d_size);\n\t\tswitch (d->d_type) {\n\t\tcase CDF_DIR_TYPE_USER_STORAGE:\n\t\t\t(void)fprintf(stderr, \"Storage: %d\\n\", d->d_storage);\n\t\t\tbreak;\n\t\tcase CDF_DIR_TYPE_USER_STREAM:\n\t\t\tif (sst == NULL)\n\t\t\t\tbreak;\n\t\t\tif (cdf_read_sector_chain(info, h, sat, ssat, sst,\n\t\t\t    d->d_stream_first_sector, d->d_size, &scn) == -1) {\n\t\t\t\twarn(\"Can't read stream for %s at %d len %d\",\n\t\t\t\t    name, d->d_stream_first_sector, d->d_size);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcdf_dump_stream(&scn);\n\t\t\tfree(scn.sst_tab);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t}\n}","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":264412,"func":"static CURLcode cookie_output(struct Curl_easy *data,\n                              struct CookieInfo *c, const char *filename)\n{\n  struct Cookie *co;\n  FILE *out = NULL;\n  bool use_stdout = FALSE;\n  char *tempstore = NULL;\n  CURLcode error = CURLE_OK;\n\n  if(!c)\n    \/* no cookie engine alive *\/\n    return CURLE_OK;\n\n  \/* at first, remove expired cookies *\/\n  remove_expired(c);\n\n  if(!strcmp(\"-\", filename)) {\n    \/* use stdout *\/\n    out = stdout;\n    use_stdout = TRUE;\n  }\n  else {\n    error = Curl_fopen(data, filename, &out, &tempstore);\n    if(error)\n      goto error;\n  }\n\n  fputs(\"# Netscape HTTP Cookie File\\n\"\n        \"# https:\/\/curl.se\/docs\/http-cookies.html\\n\"\n        \"# This file was generated by libcurl! Edit at your own risk.\\n\\n\",\n        out);\n\n  if(c->numcookies) {\n    unsigned int i;\n    size_t nvalid = 0;\n    struct Cookie **array;\n\n    array = calloc(1, sizeof(struct Cookie *) * c->numcookies);\n    if(!array) {\n      error = CURLE_OUT_OF_MEMORY;\n      goto error;\n    }\n\n    \/* only sort the cookies with a domain property *\/\n    for(i = 0; i < COOKIE_HASH_SIZE; i++) {\n      for(co = c->cookies[i]; co; co = co->next) {\n        if(!co->domain)\n          continue;\n        array[nvalid++] = co;\n      }\n    }\n\n    qsort(array, nvalid, sizeof(struct Cookie *), cookie_sort_ct);\n\n    for(i = 0; i < nvalid; i++) {\n      char *format_ptr = get_netscape_format(array[i]);\n      if(!format_ptr) {\n        free(array);\n        error = CURLE_OUT_OF_MEMORY;\n        goto error;\n      }\n      fprintf(out, \"%s\\n\", format_ptr);\n      free(format_ptr);\n    }\n\n    free(array);\n  }\n\n  if(!use_stdout) {\n    fclose(out);\n    out = NULL;\n    if(tempstore && Curl_rename(tempstore, filename)) {\n      unlink(tempstore);\n      error = CURLE_WRITE_ERROR;\n      goto error;\n    }\n  }\n\n  \/*\n   * If we reach here we have successfully written a cookie file so theree is\n   * no need to inspect the error, any error case should have jumped into the\n   * error block below.\n   *\/\n  free(tempstore);\n  return CURLE_OK;\n\nerror:\n  if(out && !use_stdout)\n    fclose(out);\n  free(tempstore);\n  return error;\n}","target":0,"code_token_length":554,"total_token_length":790,"max_tokens_setting":1024}
+{"idx":432705,"func":"static void ipa_bmp_draw(wmfAPI *API, wmfBMP_Draw_t *bmp_draw)\n{\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  ExceptionInfo\n    *exception;\n\n  Image\n    *image;\n\n  MagickWand\n    *magick_wand;\n\n  double\n    height,\n    width;\n\n  PixelInfo\n    white;\n\n  if (bmp_draw->bmp.data == 0)\n    return;\n\n  image = (Image*)bmp_draw->bmp.data;\n  if (!image)\n     return;\n\n  exception=ddata->exception;\n  if (bmp_draw->crop.x || bmp_draw->crop.y ||\n     (bmp_draw->crop.w != bmp_draw->bmp.width) ||\n     (bmp_draw->crop.h != bmp_draw->bmp.height))\n    {\n      \/* Image needs to be cropped *\/\n      Image\n        *crop_image;\n\n      RectangleInfo\n        crop_info;\n\n      crop_info.x = bmp_draw->crop.x;\n      crop_info.y = bmp_draw->crop.y;\n      crop_info.width = bmp_draw->crop.w;\n      crop_info.height = bmp_draw->crop.h;\n\n      crop_image = CropImage( image, &crop_info, exception );\n      if (crop_image)\n        {\n          image=DestroyImageList(image);\n          image = crop_image;\n          bmp_draw->bmp.data = (void*)image;\n        }\n    }\n\n  QueryColorCompliance( \"white\", AllCompliance, &white, exception );\n\n  if ( ddata->image_info->texture ||\n       !(IsPixelInfoEquivalent(&ddata->image_info->background_color,&white)) ||\n       ddata->image_info->background_color.alpha != OpaqueAlpha )\n  {\n    \/*\n      Set image white background to transparent so that it may be\n      overlaid over non-white backgrounds.\n    *\/\n    QueryColorCompliance( \"white\", AllCompliance, &white, exception );\n    TransparentPaintImage( image, &white, QuantumRange, MagickFalse, exception );\n  }\n\n  width = fabs(bmp_draw->pixel_width * (double) bmp_draw->crop.w);\n  height = fabs(bmp_draw->pixel_height * (double) bmp_draw->crop.h);\n  magick_wand=NewMagickWandFromImage(image);\n  (void) DrawComposite(WmfDrawingWand, CopyCompositeOp,\n    XC(bmp_draw->pt.x) * ddata->scale_x, YC(bmp_draw->pt.y) * ddata->scale_y,\n    width * ddata->scale_x, height * ddata->scale_y, magick_wand);\n  magick_wand=DestroyMagickWand(magick_wand);\n\n#if 0\n  printf(\"bmp_draw->bmp.data   = 0x%lx\\n\", (long)bmp_draw->bmp.data);\n  printf(\"registry id          = %li\\n\", id);\n  \/* printf(\"pixel_width          = %g\\n\", bmp_draw->pixel_width); *\/\n  \/* printf(\"pixel_height         = %g\\n\", bmp_draw->pixel_height); *\/\n  printf(\"bmp_draw->bmp WxH    = %ix%i\\n\", bmp_draw->bmp.width, bmp_draw->bmp.height);\n  printf(\"bmp_draw->crop WxH   = %ix%i\\n\", bmp_draw->crop.w, bmp_draw->crop.h);\n  printf(\"bmp_draw->crop x,y   = %i,%i\\n\", bmp_draw->crop.x, bmp_draw->crop.y);\n  printf(\"image size WxH       = %lux%lu\\n\", image->columns, image->rows);\n#endif\n}","target":0,"code_token_length":762,"total_token_length":998,"max_tokens_setting":1024}
+{"idx":338194,"func":"void WasmBinaryBuilder::readSourceMapHeader() {\n  if (!sourceMap) {\n    return;\n  }\n\n  auto skipWhitespace = [&]() {\n    while (sourceMap->peek() == ' ' || sourceMap->peek() == '\\n') {\n      sourceMap->get();\n    }\n  };\n\n  auto maybeReadChar = [&](char expected) {\n    if (sourceMap->peek() != expected) {\n      return false;\n    }\n    sourceMap->get();\n    return true;\n  };\n\n  auto mustReadChar = [&](char expected) {\n    char c = sourceMap->get();\n    if (c != expected) {\n      throw MapParseException(std::string(\"Unexpected char: expected '\") +\n                              expected + \"' got '\" + c + \"'\");\n    }\n  };\n\n  auto findField = [&](const char* name) {\n    bool matching = false;\n    size_t len = strlen(name);\n    size_t pos;\n    while (1) {\n      int ch = sourceMap->get();\n      if (ch == EOF) {\n        return false;\n      }\n      if (ch == '\\\"') {\n        if (matching) {\n          \/\/ we matched a terminating quote.\n          if (pos == len) {\n            break;\n          }\n          matching = false;\n        } else {\n          matching = true;\n          pos = 0;\n        }\n      } else if (matching && name[pos] == ch) {\n        ++pos;\n      } else if (matching) {\n        matching = false;\n      }\n    }\n    skipWhitespace();\n    mustReadChar(':');\n    skipWhitespace();\n    return true;\n  };\n\n  auto readString = [&](std::string& str) {\n    std::vector<char> vec;\n    skipWhitespace();\n    mustReadChar('\\\"');\n    if (!maybeReadChar('\\\"')) {\n      while (1) {\n        int ch = sourceMap->get();\n        if (ch == EOF) {\n          throw MapParseException(\"unexpected EOF in the middle of string\");\n        }\n        if (ch == '\\\"') {\n          break;\n        }\n        vec.push_back(ch);\n      }\n    }\n    skipWhitespace();\n    str = std::string(vec.begin(), vec.end());\n  };\n\n  if (!findField(\"sources\")) {\n    throw MapParseException(\"cannot find the 'sources' field in map\");\n  }\n\n  skipWhitespace();\n  mustReadChar('[');\n  if (!maybeReadChar(']')) {\n    do {\n      std::string file;\n      readString(file);\n      Index index = wasm.debugInfoFileNames.size();\n      wasm.debugInfoFileNames.push_back(file);\n      debugInfoFileIndices[file] = index;\n    } while (maybeReadChar(','));\n    mustReadChar(']');\n  }\n\n  if (!findField(\"mappings\")) {\n    throw MapParseException(\"cannot find the 'mappings' field in map\");\n  }\n\n  mustReadChar('\\\"');\n  if (maybeReadChar('\\\"')) { \/\/ empty mappings\n    nextDebugLocation.first = 0;\n    return;\n  }\n  \/\/ read first debug location\n  uint32_t position = readBase64VLQ(*sourceMap);\n  uint32_t fileIndex = readBase64VLQ(*sourceMap);\n  uint32_t lineNumber =\n    readBase64VLQ(*sourceMap) + 1; \/\/ adjust zero-based line number\n  uint32_t columnNumber = readBase64VLQ(*sourceMap);\n  nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}};\n}","target":0,"code_token_length":734,"total_token_length":970,"max_tokens_setting":1024}
+{"idx":312553,"func":"ex_cbuffer(exarg_T *eap)\n{\n    buf_T\t*buf = NULL;\n    qf_info_T\t*qi;\n    char_u\t*au_name = NULL;\n    int\t\tres;\n    int_u\tsave_qfid;\n    win_T\t*wp = NULL;\n    char_u\t*qf_title;\n    linenr_T\tline1;\n    linenr_T\tline2;\n\n    au_name = cbuffer_get_auname(eap->cmdidx);\n    if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,\n\t\t\t\t\tcurbuf->b_fname, TRUE, curbuf))\n    {\n#ifdef FEAT_EVAL\n\tif (aborting())\n\t    return;\n#endif\n    }\n\n    \/\/ Must come after autocommands.\n    qi = qf_cmd_get_or_alloc_stack(eap, &wp);\n    if (qi == NULL)\n\treturn;\n\n    if (cbuffer_process_args(eap, &buf, &line1, &line2) == FAIL)\n\treturn;\n\n    qf_title = qf_cmdtitle(*eap->cmdlinep);\n\n    if (buf->b_sfname)\n    {\n\tvim_snprintf((char *)IObuff, IOSIZE, \"%s (%s)\",\n\t\t(char *)qf_title, (char *)buf->b_sfname);\n\tqf_title = IObuff;\n    }\n\n    incr_quickfix_busy();\n\n    res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,\n\t    (eap->cmdidx != CMD_caddbuffer\n\t     && eap->cmdidx != CMD_laddbuffer),\n\t    line1, line2,\n\t    qf_title, NULL);\n    if (qf_stack_empty(qi))\n    {\n\tdecr_quickfix_busy();\n\treturn;\n    }\n    if (res >= 0)\n\tqf_list_changed(qf_get_curlist(qi));\n\n    \/\/ Remember the current quickfix list identifier, so that we can\n    \/\/ check for autocommands changing the current quickfix list.\n    save_qfid = qf_get_curlist(qi)->qf_id;\n    if (au_name != NULL)\n    {\n\tbuf_T *curbuf_old = curbuf;\n\n\tapply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname,\n\t\t\t\t\t\t\t\tTRUE, curbuf);\n\tif (curbuf != curbuf_old)\n\t    \/\/ Autocommands changed buffer, don't jump now, \"qi\" may\n\t    \/\/ be invalid.\n\t    res = 0;\n    }\n    \/\/ Jump to the first error for a new list and if autocmds didn't\n    \/\/ free the list.\n    if (res > 0 && (eap->cmdidx == CMD_cbuffer ||\n\t\teap->cmdidx == CMD_lbuffer)\n\t    && qflist_valid(wp, save_qfid))\n\t\/\/ display the first error\n\tqf_jump_first(qi, save_qfid, eap->forceit);\n\n    decr_quickfix_busy();\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":487642,"func":"static void k_getrusage(struct task_struct *p, int who, struct rusage *r)\n{\n\tstruct task_struct *t;\n\tunsigned long flags;\n\tcputime_t utime, stime;\n\n\tmemset((char *) r, 0, sizeof *r);\n\tutime = stime = cputime_zero;\n\n\trcu_read_lock();\n\tif (!lock_task_sighand(p, &flags)) {\n\t\trcu_read_unlock();\n\t\treturn;\n\t}\n\n\tswitch (who) {\n\t\tcase RUSAGE_BOTH:\n\t\tcase RUSAGE_CHILDREN:\n\t\t\tutime = p->signal->cutime;\n\t\t\tstime = p->signal->cstime;\n\t\t\tr->ru_nvcsw = p->signal->cnvcsw;\n\t\t\tr->ru_nivcsw = p->signal->cnivcsw;\n\t\t\tr->ru_minflt = p->signal->cmin_flt;\n\t\t\tr->ru_majflt = p->signal->cmaj_flt;\n\n\t\t\tif (who == RUSAGE_CHILDREN)\n\t\t\t\tbreak;\n\n\t\tcase RUSAGE_SELF:\n\t\t\tutime = cputime_add(utime, p->signal->utime);\n\t\t\tstime = cputime_add(stime, p->signal->stime);\n\t\t\tr->ru_nvcsw += p->signal->nvcsw;\n\t\t\tr->ru_nivcsw += p->signal->nivcsw;\n\t\t\tr->ru_minflt += p->signal->min_flt;\n\t\t\tr->ru_majflt += p->signal->maj_flt;\n\t\t\tt = p;\n\t\t\tdo {\n\t\t\t\tutime = cputime_add(utime, t->utime);\n\t\t\t\tstime = cputime_add(stime, t->stime);\n\t\t\t\tr->ru_nvcsw += t->nvcsw;\n\t\t\t\tr->ru_nivcsw += t->nivcsw;\n\t\t\t\tr->ru_minflt += t->min_flt;\n\t\t\t\tr->ru_majflt += t->maj_flt;\n\t\t\t\tt = next_thread(t);\n\t\t\t} while (t != p);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tBUG();\n\t}\n\n\tunlock_task_sighand(p, &flags);\n\trcu_read_unlock();\n\n\tcputime_to_timeval(utime, &r->ru_utime);\n\tcputime_to_timeval(stime, &r->ru_stime);\n}","target":0,"code_token_length":501,"total_token_length":737,"max_tokens_setting":1024}
+{"idx":222738,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_xr_update_info( \n\t\t\t\t\t pjmedia_rtcp_xr_session *sess,\n\t\t\t\t\t unsigned info,\n\t\t\t\t\t pj_int32_t val)\n{\n    int v = val;\n\n    switch(info) {\n\tcase PJMEDIA_RTCP_XR_INFO_SIGNAL_LVL:\n\t    sess->stat.rx.voip_mtc.signal_lvl = (pj_int8_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_NOISE_LVL:\n\t    sess->stat.rx.voip_mtc.noise_lvl = (pj_int8_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_RERL:\n\t    sess->stat.rx.voip_mtc.rerl = (pj_uint8_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_R_FACTOR:\n\t    sess->stat.rx.voip_mtc.ext_r_factor = (pj_uint8_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_MOS_LQ:\n\t    sess->stat.rx.voip_mtc.mos_lq = (pj_uint8_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_MOS_CQ:\n\t    sess->stat.rx.voip_mtc.mos_cq = (pj_uint8_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_CONF_PLC:\n\t    if (v >= 0 && v <= 3) {\n\t\tsess->stat.rx.voip_mtc.rx_config &= 0x3F;\n\t\tsess->stat.rx.voip_mtc.rx_config |= (pj_uint8_t) (v << 6);\n\t    }\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_CONF_JBA:\n\t    if (v >= 0 && v <= 3) {\n\t\tsess->stat.rx.voip_mtc.rx_config &= 0xCF;\n\t\tsess->stat.rx.voip_mtc.rx_config |= (pj_uint8_t) (v << 4);\n\t    }\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_CONF_JBR:\n\t    if (v >= 0 && v <= 15) {\n\t\tsess->stat.rx.voip_mtc.rx_config &= 0xF0;\n\t\tsess->stat.rx.voip_mtc.rx_config |= (pj_uint8_t) v;\n\t    }\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_JB_NOM:\n\t    sess->stat.rx.voip_mtc.jb_nom = (pj_uint16_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_JB_MAX:\n\t    sess->stat.rx.voip_mtc.jb_max = (pj_uint16_t) v;\n\t    break;\n\n\tcase PJMEDIA_RTCP_XR_INFO_JB_ABS_MAX:\n\t    sess->stat.rx.voip_mtc.jb_abs_max = (pj_uint16_t) v;\n\t    break;\n\n\tdefault:\n\t    return PJ_EINVAL;\n    }\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":618,"total_token_length":854,"max_tokens_setting":1024}
+{"idx":215948,"func":"ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp)\n{\n  mp_limb_t u1, u0;\n  mp_size_t n;\n\n  n = 2*p->size;\n  u1 = rp[--n];\n  u0 = rp[n-1];\n\n  \/* This is not particularly fast, but should work well with assembly implementation. *\/\n  for (; n >= p->size; n--)\n    {\n      mp_limb_t q2, q1, q0, t, cy;\n\n      \/* <q2, q1, q0> = v * u1 + <u1,u0>, with v = 2^32 - 1:\n\n\t   +---+---+\n\t   | u1| u0|\n\t   +---+---+\n\t       |-u1|\n\t     +-+-+-+\n\t     | u1|\n       +---+-+-+-+-+\n       | q2| q1| q0|\n       +---+---+---+\n      *\/\n      q1 = u1 - (u1 > u0);\n      q0 = u0 - u1;\n      t = u1 << 32;\n      q0 += t;\n      t = (u1 >> 32) + (q0 < t) + 1;\n      q1 += t;\n      q2 = q1 < t;\n\n      \/* Compute candidate remainder *\/\n      u1 = u0 + (q1 << 32) - q1;\n      t = -(mp_limb_t) (u1 > q0);\n      u1 -= t & 0xffffffff;\n      q1 += t;\n      q2 += t + (q1 < t);\n\n      assert (q2 < 2);\n\n      \/* We multiply by two low limbs of p, 2^96 - 1, so we could use\n\t shifts rather than mul. *\/\n      t = mpn_submul_1 (rp + n - 4, p->m, 2, q1);\n      t += cnd_sub_n (q2, rp + n - 3, p->m, 1);\n      t += (-q2) & 0xffffffff;\n\n      u0 = rp[n-2];\n      cy = (u0 < t);\n      u0 -= t;\n      t = (u1 < cy);\n      u1 -= cy;\n      u1 += cnd_add_n (t, rp + n - 4, p->m, 3);\n      u1 -= (-t) & 0xffffffff;\n    }\n  rp[2] = u0;\n  rp[3] = u1;\n}","target":1,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":513139,"func":"static void plugin_deinitialize(struct st_plugin_int *plugin, bool ref_check)\n{\n  \/*\n    we don't want to hold the LOCK_plugin mutex as it may cause\n    deinitialization to deadlock if plugins have worker threads\n    with plugin locks\n  *\/\n  mysql_mutex_assert_not_owner(&LOCK_plugin);\n\n  if (plugin->plugin->status_vars)\n  {\n    \/*\n      historical ndb behavior caused MySQL plugins to specify\n      status var names in full, with the plugin name prefix.\n      this was never fixed in MySQL.\n      MariaDB fixes that but supports MySQL style too.\n    *\/\n    SHOW_VAR *show_vars= plugin->plugin->status_vars;\n    SHOW_VAR tmp_array[2]= {\n      {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},\n      {0, 0, SHOW_UNDEF}\n    };\n    if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length))\n      show_vars= tmp_array;\n\n    remove_status_vars(show_vars);\n  }\n\n  if (plugin_type_deinitialize[plugin->plugin->type])\n  {\n    if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin))\n    {\n      sql_print_error(\"Plugin '%s' of type %s failed deinitialization\",\n                      plugin->name.str, plugin_type_names[plugin->plugin->type].str);\n    }\n  }\n  else if (plugin->plugin->deinit)\n  {\n    DBUG_PRINT(\"info\", (\"Deinitializing plugin: '%s'\", plugin->name.str));\n    if (plugin->plugin->deinit(plugin))\n    {\n      DBUG_PRINT(\"warning\", (\"Plugin '%s' deinit function returned error.\",\n                             plugin->name.str));\n    }\n  }\n  plugin->state= PLUGIN_IS_UNINITIALIZED;\n\n  if (ref_check && plugin->ref_count)\n    sql_print_error(\"Plugin '%s' has ref_count=%d after deinitialization.\",\n                    plugin->name.str, plugin->ref_count);\n  plugin_variables_deinit(plugin);\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":261905,"func":"njs_string_prototype_index_of(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    int64_t            from, length;\n    njs_int_t          ret;\n    njs_value_t        *this, *search, *pos, search_lvalue, pos_lvalue;\n    njs_string_prop_t  string, s;\n\n    this = njs_argument(args, 0);\n\n    if (njs_slow_path(njs_is_null_or_undefined(this))) {\n        njs_type_error(vm, \"cannot convert \\\"%s\\\"to object\",\n                       njs_type_string(this->type));\n        return NJS_ERROR;\n    }\n\n    ret = njs_value_to_string(vm, this, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    search = njs_lvalue_arg(&search_lvalue, args, nargs, 1);\n    ret = njs_value_to_string(vm, search, search);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    pos = njs_lvalue_arg(&pos_lvalue, args, nargs, 2);\n    ret = njs_value_to_integer(vm, pos, &from);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = njs_string_prop(&string, this);\n    (void) njs_string_prop(&s, search);\n\n    from = njs_min(njs_max(from, 0), length);\n\n    njs_set_number(&vm->retval, njs_string_index_of(&string, &s, from));\n\n    return NJS_OK;\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":369328,"func":"\nstatic __cold int io_uring_alloc_task_context(struct task_struct *task,\n\t\t\t\t\t      struct io_ring_ctx *ctx)\n{\n\tstruct io_uring_task *tctx;\n\tint ret;\n\n\ttctx = kzalloc(sizeof(*tctx), GFP_KERNEL);\n\tif (unlikely(!tctx))\n\t\treturn -ENOMEM;\n\n\ttctx->registered_rings = kcalloc(IO_RINGFD_REG_MAX,\n\t\t\t\t\t sizeof(struct file *), GFP_KERNEL);\n\tif (unlikely(!tctx->registered_rings)) {\n\t\tkfree(tctx);\n\t\treturn -ENOMEM;\n\t}\n\n\tret = percpu_counter_init(&tctx->inflight, 0, GFP_KERNEL);\n\tif (unlikely(ret)) {\n\t\tkfree(tctx->registered_rings);\n\t\tkfree(tctx);\n\t\treturn ret;\n\t}\n\n\ttctx->io_wq = io_init_wq_offload(ctx, task);\n\tif (IS_ERR(tctx->io_wq)) {\n\t\tret = PTR_ERR(tctx->io_wq);\n\t\tpercpu_counter_destroy(&tctx->inflight);\n\t\tkfree(tctx->registered_rings);\n\t\tkfree(tctx);\n\t\treturn ret;\n\t}\n\n\txa_init(&tctx->xa);\n\tinit_waitqueue_head(&tctx->wait);\n\tatomic_set(&tctx->in_idle, 0);\n\ttask->io_uring = tctx;\n\tspin_lock_init(&tctx->task_lock);\n\tINIT_WQ_LIST(&tctx->task_list);\n\tINIT_WQ_LIST(&tctx->prior_task_list);\n\tinit_task_work(&tctx->task_work, tctx_task_work);\n\treturn 0;","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":328948,"func":"R_API RBinJavaElementValuePair *r_bin_java_element_pair_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (!buffer || sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaElementValuePair *evp = R_NEW0 (RBinJavaElementValuePair);\n\tif (!evp) {\n\t\treturn NULL;\n\t}\n\t\/\/ TODO: What is the signifigance of evp element\n\tevp->element_name_idx = R_BIN_JAVA_USHORT (buffer, 0);\n\tut64 offset = 2;\n\tevp->file_offset = buf_offset;\n\tevp->name = r_bin_java_get_utf8_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, evp->element_name_idx);\n\tif (!evp->name) {\n\t\t\/\/ TODO: eprintf unable to find the name for the given index\n\t\teprintf (\"ElementValue Name is invalid.\\n\");\n\t\tevp->name = strdup (\"UNKNOWN\");\n\t}\n\tif (offset >= sz) {\n\t\tfree (evp);\n\t\treturn NULL;\n\t}\n\tevp->value = r_bin_java_element_value_new (buffer + offset, sz - offset, buf_offset + offset);\n\tif (evp->value) {\n\t\toffset += evp->value->size;\n\t\tif (offset >= sz) {\n\t\t\tfree (evp->value);\n\t\t\tfree (evp);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\tevp->size = offset;\n\treturn evp;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":264663,"func":"static GF_Err BM_ParseProtoDelete(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)\n{\n\tu32 flag, count;\n\tGF_Command *com = gf_sg_command_new(codec->current_graph, GF_SG_PROTO_DELETE);\n\tflag = gf_bs_read_int(bs, 1);\n\tif (flag) {\n\t\tcount = 0;\n\t\tflag = gf_bs_read_int(bs, 1);\n\t\twhile (flag) {\n\t\t\tcom->del_proto_list = (u32*)gf_realloc(com->del_proto_list, sizeof(u32) * (com->del_proto_list_size+1));\n\t\t\tcom->del_proto_list[count] = gf_bs_read_int(bs, codec->info->config.ProtoIDBits);\n\t\t\tcom->del_proto_list_size++;\n\t\t\tflag = gf_bs_read_int(bs, 1);\n\t\t}\n\t} else {\n\t\tflag = gf_bs_read_int(bs, 5);\n\t\tcom->del_proto_list_size = gf_bs_read_int(bs, flag);\n\t\tcom->del_proto_list = (u32*)gf_realloc(com->del_proto_list, sizeof(u32) * (com->del_proto_list_size));\n\t\tflag = 0;\n\t\twhile (flag<com->del_proto_list_size) {\n\t\t\tcom->del_proto_list[flag] = gf_bs_read_int(bs, codec->info->config.ProtoIDBits);\n\t\t\tflag++;\n\t\t}\n\t}\n\tgf_list_add(com_list, com);\n\treturn GF_OK;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":352961,"func":"attributeCertificateValidate( Syntax *syntax, struct berval *in )\n{\n\tBerElementBuffer berbuf;\n\tBerElement *ber = (BerElement *)&berbuf;\n\tber_tag_t tag;\n\tber_len_t len;\n\tber_int_t version;\n\tint cont = 0;\n\n\tber_init2( ber, in, LBER_USE_DER );\n\t\n\ttag = ber_skip_tag( ber, &len );\t\/* Signed wrapper *\/\n\tif ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;\n\n\ttag = ber_skip_tag( ber, &len );\t\/* Sequence *\/\n\tif ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;\n\n\ttag = ber_peek_tag( ber, &len );\t\/* Version *\/\n\tif ( tag != LBER_INTEGER ) return LDAP_INVALID_SYNTAX;\n\ttag = ber_get_int( ber, &version );\t\/* X.509 only allows v2 *\/\n\tif ( version != SLAP_X509AC_V2 ) return LDAP_INVALID_SYNTAX;\n\n\ttag = ber_skip_tag( ber, &len );\t\/* Holder *\/\n\tif ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;\n\tber_skip_data( ber, len );\n\n\ttag = ber_skip_tag( ber, &len );\t\/* Issuer *\/\n\tif ( tag != SLAP_X509AC_ISSUER ) return LDAP_INVALID_SYNTAX;\n\tber_skip_data( ber, len );\n\n\ttag = ber_skip_tag( ber, &len );\t\/* Signature *\/\n\tif ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;\n\tber_skip_data( ber, len );\n\n\ttag = ber_skip_tag( ber, &len );\t\/* Serial number *\/\n\tif ( tag != LBER_INTEGER ) return LDAP_INVALID_SYNTAX;\n\tber_skip_data( ber, len );\n\n\ttag = ber_skip_tag( ber, &len );\t\/* AttCertValidityPeriod *\/\n\tif ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;\n\tber_skip_data( ber, len );\n\n\ttag = ber_skip_tag( ber, &len );\t\/* Attributes *\/\n\tif ( tag != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;\n\tber_skip_data( ber, len );\n\n\ttag = ber_peek_tag( ber, &len );\n\n\tif ( tag == LBER_BITSTRING ) {\t\/* issuerUniqueID *\/\n\t\ttag = ber_skip_tag( ber, &len );\n\t\tber_skip_data( ber, len );\n\t\ttag = ber_peek_tag( ber, &len );\n\t}\n\n\tif ( tag == LBER_SEQUENCE ) {\t\/* extensions or signatureAlgorithm *\/\n\t\ttag = ber_skip_tag( ber, &len );\n\t\tber_skip_data( ber, len );\n\t\tcont++;\n\t\ttag = ber_peek_tag( ber, &len );\n\t}\n\n\tif ( tag == LBER_SEQUENCE ) {\t\/* signatureAlgorithm *\/\n\t\ttag = ber_skip_tag( ber, &len );\n\t\tber_skip_data( ber, len );\n\t\tcont++;\n\t\ttag = ber_peek_tag( ber, &len );\n\t}\n\n\tif ( tag == LBER_BITSTRING ) {\t\/* Signature *\/\n\t\ttag = ber_skip_tag( ber, &len );\n\t\tber_skip_data( ber, len );\n\t\tcont++;\n\t\ttag = ber_peek_tag( ber, &len );\n\t}\n\n\t\/* Must be at end now *\/\n\tif ( len != 0 || tag != LBER_DEFAULT || cont < 2 ) return LDAP_INVALID_SYNTAX;\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":712,"total_token_length":948,"max_tokens_setting":1024}
+{"idx":369391,"func":"\nstatic __cold void io_ring_ctx_free(struct io_ring_ctx *ctx)\n{\n\tio_sq_thread_finish(ctx);\n\n\tif (ctx->mm_account) {\n\t\tmmdrop(ctx->mm_account);\n\t\tctx->mm_account = NULL;\n\t}\n\n\tio_rsrc_refs_drop(ctx);\n\t\/* __io_rsrc_put_work() may need uring_lock to progress, wait w\/o it *\/\n\tio_wait_rsrc_data(ctx->buf_data);\n\tio_wait_rsrc_data(ctx->file_data);\n\n\tmutex_lock(&ctx->uring_lock);\n\tif (ctx->buf_data)\n\t\t__io_sqe_buffers_unregister(ctx);\n\tif (ctx->file_data)\n\t\t__io_sqe_files_unregister(ctx);\n\tif (ctx->rings)\n\t\t__io_cqring_overflow_flush(ctx, true);\n\tio_eventfd_unregister(ctx);\n\tio_flush_apoll_cache(ctx);\n\tmutex_unlock(&ctx->uring_lock);\n\tio_destroy_buffers(ctx);\n\tif (ctx->sq_creds)\n\t\tput_cred(ctx->sq_creds);\n\n\t\/* there are no registered resources left, nobody uses it *\/\n\tif (ctx->rsrc_node)\n\t\tio_rsrc_node_destroy(ctx->rsrc_node);\n\tif (ctx->rsrc_backup_node)\n\t\tio_rsrc_node_destroy(ctx->rsrc_backup_node);\n\tflush_delayed_work(&ctx->rsrc_put_work);\n\tflush_delayed_work(&ctx->fallback_work);\n\n\tWARN_ON_ONCE(!list_empty(&ctx->rsrc_ref_list));\n\tWARN_ON_ONCE(!llist_empty(&ctx->rsrc_put_llist));\n\n#if defined(CONFIG_UNIX)\n\tif (ctx->ring_sock) {\n\t\tctx->ring_sock->file = NULL; \/* so that iput() is called *\/\n\t\tsock_release(ctx->ring_sock);\n\t}\n#endif\n\tWARN_ON_ONCE(!list_empty(&ctx->ltimeout_list));\n\n\tio_mem_free(ctx->rings);\n\tio_mem_free(ctx->sq_sqes);\n\n\tpercpu_ref_exit(&ctx->refs);\n\tfree_uid(ctx->user);\n\tio_req_caches_free(ctx);\n\tif (ctx->hash_map)\n\t\tio_wq_put_hash(ctx->hash_map);\n\tkfree(ctx->cancel_hash);\n\tkfree(ctx->dummy_ubuf);\n\tkfree(ctx->io_buffers);\n\tkfree(ctx);","target":0,"code_token_length":453,"total_token_length":689,"max_tokens_setting":1024}
+{"idx":489142,"func":"struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,\n\t\t\t\t\t      union sctp_addr\t      *laddr,\n\t\t\t\t\t      struct sockaddr\t      *addrs,\n\t\t\t\t\t      int\t\t      addrcnt,\n\t\t\t\t\t      __be16\t\t      flags)\n{\n\tsctp_addip_param_t\tparam;\n\tstruct sctp_chunk\t*retval;\n\tunion sctp_addr_param\taddr_param;\n\tunion sctp_addr\t\t*addr;\n\tvoid\t\t\t*addr_buf;\n\tstruct sctp_af\t\t*af;\n\tint\t\t\tparamlen = sizeof(param);\n\tint\t\t\taddr_param_len = 0;\n\tint \t\t\ttotallen = 0;\n\tint \t\t\ti;\n\n\t\/* Get total length of all the address parameters. *\/\n\taddr_buf = addrs;\n\tfor (i = 0; i < addrcnt; i++) {\n\t\taddr = (union sctp_addr *)addr_buf;\n\t\taf = sctp_get_af_specific(addr->v4.sin_family);\n\t\taddr_param_len = af->to_addr_param(addr, &addr_param);\n\n\t\ttotallen += paramlen;\n\t\ttotallen += addr_param_len;\n\n\t\taddr_buf += af->sockaddr_len;\n\t}\n\n\t\/* Create an asconf chunk with the required length. *\/\n\tretval = sctp_make_asconf(asoc, laddr, totallen);\n\tif (!retval)\n\t\treturn NULL;\n\n\t\/* Add the address parameters to the asconf chunk. *\/\n\taddr_buf = addrs;\n\tfor (i = 0; i < addrcnt; i++) {\n\t\taddr = (union sctp_addr *)addr_buf;\n\t\taf = sctp_get_af_specific(addr->v4.sin_family);\n\t\taddr_param_len = af->to_addr_param(addr, &addr_param);\n\t\tparam.param_hdr.type = flags;\n\t\tparam.param_hdr.length = htons(paramlen + addr_param_len);\n\t\tparam.crr_id = i;\n\n\t\tsctp_addto_chunk(retval, paramlen, ¶m);\n\t\tsctp_addto_chunk(retval, addr_param_len, &addr_param);\n\n\t\taddr_buf += af->sockaddr_len;\n\t}\n\treturn retval;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":274754,"func":"static int ntfs_attr_map_partial_runlist(ntfs_attr *na, VCN vcn)\n{\n\tVCN last_vcn;\n\tVCN highest_vcn;\n\tVCN needed;\n\trunlist_element *rl;\n\tATTR_RECORD *a;\n\tBOOL startseen;\n\tntfs_attr_search_ctx *ctx;\n\tBOOL done;\n\tBOOL newrunlist;\n\n\tif (NAttrFullyMapped(na))\n\t\treturn 0;\n\n\tctx = ntfs_attr_get_search_ctx(na->ni, NULL);\n\tif (!ctx)\n\t\treturn -1;\n\n\t\/* Get the last vcn in the attribute. *\/\n\tlast_vcn = na->allocated_size >> na->ni->vol->cluster_size_bits;\n\n\tneeded = vcn;\n\thighest_vcn = 0;\n\tstartseen = FALSE;\n\tdone = FALSE;\n\trl = (runlist_element*)NULL;\n\tdo {\n\t\tnewrunlist = FALSE;\n\t\t\/* Find the attribute in the mft record. *\/\n\t\tif (!ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,\n\t\t\t\tneeded, NULL, 0, ctx)) {\n\n\t\t\ta = ctx->attr;\n\t\t\t\t\/* Decode and merge the runlist. *\/\n\t\t\tif (ntfs_rl_vcn_to_lcn(na->rl, needed)\n\t\t\t\t\t\t== LCN_RL_NOT_MAPPED) {\n\t\t\t\trl = ntfs_mapping_pairs_decompress(na->ni->vol,\n\t\t\t\t\ta, na->rl);\n\t\t\t\tnewrunlist = TRUE;\n\t\t\t} else\n\t\t\t\trl = na->rl;\n\t\t\tif (rl) {\n\t\t\t\tna->rl = rl;\n\t\t\t\thighest_vcn = sle64_to_cpu(a->highest_vcn);\n\t\t\t\tif (highest_vcn < needed) {\n\t\t\t\t\/* corruption detection on unchanged runlists *\/\n\t\t\t\t\tif (newrunlist\n\t\t\t\t\t    && ((highest_vcn + 1) < last_vcn)) {\n\t\t\t\t\t\tntfs_log_error(\"Corrupt attribute list\\n\");\n\t\t\t\t\t\trl = (runlist_element*)NULL;\n\t\t\t\t\t\terrno = EIO;\n\t\t\t\t\t}\n\t\t\t\t\tdone = TRUE;\n\t\t\t\t}\n\t\t\t\tneeded = highest_vcn + 1;\n\t\t\t\tif (!a->lowest_vcn)\n\t\t\t\t\tstartseen = TRUE;\n\t\t\t}\n\t\t} else {\n\t\t\tdone = TRUE;\n\t\t}\n\t} while (rl && !done && (needed < last_vcn));\n\tntfs_attr_put_search_ctx(ctx);\n\t\t\/*\n\t\t * Make sure we reached the end, unless the last\n\t\t * runlist was modified earlier (using HOLES_DELAY\n\t\t * leads to have a visibility over attributes which\n\t\t * have not yet been fully updated)\n\t\t *\/\n\tif (done && newrunlist && (needed < last_vcn)) {\n\t\tntfs_log_error(\"End of runlist not reached\\n\");\n\t\trl = (runlist_element*)NULL;\n\t\terrno = EIO;\n\t}\n\t\t\/* mark fully mapped if we did so *\/\n\tif (rl && startseen)\n\t\tNAttrSetFullyMapped(na);\n\treturn (rl ? 0 : -1);\n}","target":0,"code_token_length":649,"total_token_length":885,"max_tokens_setting":1024}
+{"idx":415210,"func":"cmd_pksign (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  unsigned char *outdata;\n  size_t outdatalen;\n  char *keyidstr;\n  int hash_algo;\n\n  if (has_option (line, \"--hash=rmd160\"))\n    hash_algo = GCRY_MD_RMD160;\n  else if (has_option (line, \"--hash=sha1\"))\n    hash_algo = GCRY_MD_SHA1;\n  else if (has_option (line, \"--hash=sha224\"))\n    hash_algo = GCRY_MD_SHA224;\n  else if (has_option (line, \"--hash=sha256\"))\n    hash_algo = GCRY_MD_SHA256;\n  else if (has_option (line, \"--hash=sha384\"))\n    hash_algo = GCRY_MD_SHA384;\n  else if (has_option (line, \"--hash=sha512\"))\n    hash_algo = GCRY_MD_SHA512;\n  else if (has_option (line, \"--hash=md5\"))\n    hash_algo = GCRY_MD_MD5;\n  else if (!strstr (line, \"--\"))\n    hash_algo = GCRY_MD_SHA1;\n  else\n    return set_error (GPG_ERR_ASS_PARAMETER, \"invalid hash algorithm\");\n\n  line = skip_options (line);\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  \/* We have to use a copy of the key ID because the function may use\n     the pin_cb which in turn uses the assuan line buffer and thus\n     overwriting the original line with the keyid *\/\n  keyidstr = xtrystrdup (line);\n  if (!keyidstr)\n    return out_of_core ();\n\n  rc = app_sign (ctrl->app_ctx,\n                 keyidstr, hash_algo,\n                 pin_cb, ctx,\n                 ctrl->in_data.value, ctrl->in_data.valuelen,\n                 &outdata, &outdatalen);\n\n  xfree (keyidstr);\n  if (rc)\n    {\n      log_error (\"app_sign failed: %s\\n\", gpg_strerror (rc));\n    }\n  else\n    {\n      rc = assuan_send_data (ctx, outdata, outdatalen);\n      xfree (outdata);\n      if (rc)\n        return rc; \/* that is already an assuan error code *\/\n    }\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":559,"total_token_length":795,"max_tokens_setting":1024}
+{"idx":214276,"func":"static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)\n{\n\tstruct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx;\n\tstruct tipc_aead_key *skey = NULL;\n\tu16 key_gen = msg_key_gen(hdr);\n\tu16 size = msg_data_sz(hdr);\n\tu8 *data = msg_data(hdr);\n\n\tspin_lock(&rx->lock);\n\tif (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) {\n\t\tpr_err(\"%s: key existed <%p>, gen %d vs %d\\n\", rx->name,\n\t\t       rx->skey, key_gen, rx->key_gen);\n\t\tgoto exit;\n\t}\n\n\t\/* Allocate memory for the key *\/\n\tskey = kmalloc(size, GFP_ATOMIC);\n\tif (unlikely(!skey)) {\n\t\tpr_err(\"%s: unable to allocate memory for skey\\n\", rx->name);\n\t\tgoto exit;\n\t}\n\n\t\/* Copy key from msg data *\/\n\tskey->keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));\n\tmemcpy(skey->alg_name, data, TIPC_AEAD_ALG_NAME);\n\tmemcpy(skey->key, data + TIPC_AEAD_ALG_NAME + sizeof(__be32),\n\t       skey->keylen);\n\n\t\/* Sanity check *\/\n\tif (unlikely(size != tipc_aead_key_size(skey))) {\n\t\tkfree(skey);\n\t\tskey = NULL;\n\t\tgoto exit;\n\t}\n\n\trx->key_gen = key_gen;\n\trx->skey_mode = msg_key_mode(hdr);\n\trx->skey = skey;\n\trx->nokey = 0;\n\tmb(); \/* for nokey flag *\/\n\nexit:\n\tspin_unlock(&rx->lock);\n\n\t\/* Schedule the key attaching on this crypto *\/\n\tif (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0)))\n\t\treturn true;\n\n\treturn false;\n}","target":1,"code_token_length":422,"total_token_length":658,"max_tokens_setting":1024}
+{"idx":326915,"func":"static void vidtv_s302m_write_frames(struct vidtv_encoder *e)\n{\n\tstruct vidtv_access_unit *au = e->access_units;\n\tstruct vidtv_s302m_ctx *ctx = e->ctx;\n\tu32 nbytes_per_unit = 0;\n\tu32 nbytes = 0;\n\tu32 au_sz = 0;\n\tu16 sample;\n\tu32 j;\n\n\twhile (au) {\n\t\tau_sz = au->num_samples *\n\t\t\tsizeof(struct vidtv_s302m_frame_16);\n\n\t\tnbytes_per_unit = vidtv_s302m_write_h(e, au_sz);\n\n\t\tfor (j = 0; j < au->num_samples; ++j) {\n\t\t\tsample = vidtv_s302m_get_sample(e);\n\t\t\tnbytes_per_unit += vidtv_s302m_write_frame(e, sample);\n\n\t\t\tif (e->src_buf)\n\t\t\t\te->src_buf_offset += sizeof(u16);\n\n\t\t\te->sample_count++;\n\t\t}\n\n\t\tau->nbytes = nbytes_per_unit;\n\n\t\tif (au_sz + sizeof(struct vidtv_smpte_s302m_es) != nbytes_per_unit) {\n\t\t\tpr_warn_ratelimited(\"write size was %u, expected %zu\\n\",\n\t\t\t\t\t    nbytes_per_unit,\n\t\t\t\t\t    au_sz + sizeof(struct vidtv_smpte_s302m_es));\n\t\t}\n\n\t\tnbytes += nbytes_per_unit;\n\t\tau->offset = nbytes - nbytes_per_unit;\n\n\t\tnbytes_per_unit = 0;\n\t\tctx->au_count++;\n\n\t\tau = au->next;\n\t}\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":326619,"func":"set_xattrs(struct archive_write_disk *a)\n{\n\tstruct archive_entry *entry = a->entry;\n\tstruct archive_string errlist;\n\tint ret = ARCHIVE_OK;\n\tint i = archive_entry_xattr_reset(entry);\n\tshort fail = 0;\n\n\tarchive_string_init(&errlist);\n\n\twhile (i--) {\n\t\tconst char *name;\n\t\tconst void *value;\n\t\tsize_t size;\n\t\tint e;\n\n\t\tarchive_entry_xattr_next(entry, &name, &value, &size);\n\n\t\tif (name == NULL)\n\t\t\tcontinue;\n#if ARCHIVE_XATTR_LINUX\n\t\t\/* Linux: quietly skip POSIX.1e ACL extended attributes *\/\n\t\tif (strncmp(name, \"system.\", 7) == 0 &&\n\t\t   (strcmp(name + 7, \"posix_acl_access\") == 0 ||\n\t\t    strcmp(name + 7, \"posix_acl_default\") == 0))\n\t\t\tcontinue;\n\t\tif (strncmp(name, \"trusted.SGI_\", 12) == 0 &&\n\t\t   (strcmp(name + 12, \"ACL_DEFAULT\") == 0 ||\n\t\t    strcmp(name + 12, \"ACL_FILE\") == 0))\n\t\t\tcontinue;\n\n\t\t\/* Linux: xfsroot namespace is obsolete and unsupported *\/\n\t\tif (strncmp(name, \"xfsroot.\", 8) == 0) {\n\t\t\tfail = 1;\n\t\t\tarchive_strcat(&errlist, name);\n\t\t\tarchive_strappend_char(&errlist, ' ');\n\t\t\tcontinue;\n\t\t}\n#endif\n\n\t\tif (a->fd >= 0) {\n#if ARCHIVE_XATTR_LINUX\n\t\t\te = fsetxattr(a->fd, name, value, size, 0);\n#elif ARCHIVE_XATTR_DARWIN\n\t\t\te = fsetxattr(a->fd, name, value, size, 0, 0);\n#elif ARCHIVE_XATTR_AIX\n\t\t\te = fsetea(a->fd, name, value, size, 0);\n#endif\n\t\t} else {\n#if ARCHIVE_XATTR_LINUX\n\t\t\te = lsetxattr(archive_entry_pathname(entry),\n\t\t\t    name, value, size, 0);\n#elif ARCHIVE_XATTR_DARWIN\n\t\t\te = setxattr(archive_entry_pathname(entry),\n\t\t\t    name, value, size, 0, XATTR_NOFOLLOW);\n#elif ARCHIVE_XATTR_AIX\n\t\t\te = lsetea(archive_entry_pathname(entry),\n\t\t\t    name, value, size, 0);\n#endif\n\t\t}\n\t\tif (e == -1) {\n\t\t\tret = ARCHIVE_WARN;\n\t\t\tarchive_strcat(&errlist, name);\n\t\t\tarchive_strappend_char(&errlist, ' ');\n\t\t\tif (errno != ENOTSUP && errno != ENOSYS)\n\t\t\t\tfail = 1;\n\t\t}\n\t}\n\n\tif (ret == ARCHIVE_WARN) {\n\t\tif (fail && errlist.length > 0) {\n\t\t\terrlist.length--;\n\t\t\terrlist.s[errlist.length] = '\\0';\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t    \"Cannot restore extended attributes: %s\",\n\t\t\t    errlist.s);\n\t\t} else\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t    \"Cannot restore extended \"\n\t\t\t    \"attributes on this file system.\");\n\t}\n\n\tarchive_string_free(&errlist);\n\treturn (ret);\n}","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":233865,"func":"static void wrap_in_tiff(deark *c, dbuf *f, i64 dpos, i64 dlen,\n\tconst char *swstring, unsigned int tag, const char *ext, unsigned int createflags)\n{\n\tdbuf *outf = NULL;\n\ti64 ifdoffs;\n\ti64 sw_len, sw_len_padded;\n\ti64 data_len_padded;\n\n\tsw_len = 1+(i64)de_strlen(swstring);\n\tif(sw_len<=4) return;\n\tsw_len_padded = de_pad_to_2(sw_len);\n\n\tif(dlen>4) {\n\t\tdata_len_padded = de_pad_to_2(dlen);\n\t}\n\telse {\n\t\tdata_len_padded = 0;\n\t}\n\n\toutf = dbuf_create_output_file(c, ext, NULL, 0);\n\tdbuf_write(outf, (const u8*)\"\\x4d\\x4d\\x00\\x2a\", 4);\n\tifdoffs = 8 + sw_len_padded + data_len_padded;\n\tdbuf_writeu32be(outf, ifdoffs);\n\tdbuf_write(outf, (const u8*)swstring, sw_len);\n\tif(sw_len%2) dbuf_writebyte(outf, 0);\n\tif(dlen>4) {\n\t\tdbuf_copy(f, dpos, dlen, outf);\n\t\tif(dlen%2) dbuf_writebyte(outf, 0);\n\t}\n\n\tdbuf_writeu16be(outf, 2); \/\/ number of dir entries;\n\n\tdbuf_writeu16be(outf, 305); \/\/ Software tag\n\tdbuf_writeu16be(outf, 2); \/\/ type=ASCII\n\tdbuf_writeu32be(outf, sw_len);\n\tdbuf_writeu32be(outf, 8); \/\/ offset\n\n\tdbuf_writeu16be(outf, (i64)tag);\n\tdbuf_writeu16be(outf, 1);\n\tdbuf_writeu32be(outf, dlen);\n\tif(dlen>4) {\n\t\tdbuf_writeu32be(outf, 8+sw_len_padded);\n\t}\n\telse {\n\t\tdbuf_copy(f, dpos, dlen, outf);\n\t\tdbuf_write_zeroes(outf, 4-dlen);\n\t}\n\n\tdbuf_writeu32be(outf, 0); \/\/ end of IFD\n\tdbuf_close(outf);\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":217565,"func":"static MagickBooleanType GetICCProperty(const Image *image,const char *property)\n{\n  const StringInfo\n    *profile;\n\n  \/*\n    Return ICC profile property.\n  *\/\n  magick_unreferenced(property);\n  profile=GetImageProfile(image,\"icc\");\n  if (profile == (StringInfo *) NULL)\n    profile=GetImageProfile(image,\"icm\");\n  if (profile == (StringInfo *) NULL)\n    return(MagickFalse);\n  if (GetStringInfoLength(profile) < 128)\n    return(MagickFalse);  \/* minimum ICC profile length *\/\n#if defined(MAGICKCORE_LCMS_DELEGATE)\n  {\n    cmsHPROFILE\n      icc_profile;\n\n    icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),\n      (cmsUInt32Number) GetStringInfoLength(profile));\n    if (icc_profile != (cmsHPROFILE *) NULL)\n      {\n#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)\n        const char\n          *name;\n\n        name=cmsTakeProductName(icc_profile);\n        if (name != (const char *) NULL)\n          (void) SetImageProperty((Image *) image,\"icc:name\",name);\n#else\n        StringInfo\n          *info;\n\n        unsigned int\n          extent;\n\n        info=AcquireStringInfo(0);\n        extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,\"en\",\"US\",\n          NULL,0);\n        if (extent != 0)\n          {\n            SetStringInfoLength(info,extent+1);\n            extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,\"en\",\n              \"US\",(char *) GetStringInfoDatum(info),extent);\n            if (extent != 0)\n              (void) SetImageProperty((Image *) image,\"icc:description\",\n                (char *) GetStringInfoDatum(info));\n         }\n        extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,\"en\",\"US\",\n          NULL,0);\n       if (extent != 0)\n          {\n            SetStringInfoLength(info,extent+1);\n            extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,\"en\",\n              \"US\",(char *) GetStringInfoDatum(info),extent);\n            if (extent != 0)\n              (void) SetImageProperty((Image *) image,\"icc:manufacturer\",\n                (char *) GetStringInfoDatum(info));\n          }\n        extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,\"en\",\"US\",\n          NULL,0);\n        if (extent != 0)\n          {\n            SetStringInfoLength(info,extent+1);\n            extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,\"en\",\"US\",\n              (char *) GetStringInfoDatum(info),extent);\n            if (extent != 0)\n              (void) SetImageProperty((Image *) image,\"icc:model\",\n                (char *) GetStringInfoDatum(info));\n          }\n        extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,\"en\",\"US\",\n          NULL,0);\n        if (extent != 0)\n          {\n            SetStringInfoLength(info,extent+1);\n            extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,\"en\",\n              \"US\",(char *) GetStringInfoDatum(info),extent);\n            if (extent != 0)\n              (void) SetImageProperty((Image *) image,\"icc:copyright\",\n                (char *) GetStringInfoDatum(info));\n          }\n        info=DestroyStringInfo(info);\n#endif\n        (void) cmsCloseProfile(icc_profile);\n      }\n  }\n#endif\n  return(MagickTrue);\n}","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":349270,"func":"static int parse_exports_table(long long *table_start)\n{\n\t\/*\n\t * Note on overflow limits:\n\t * Size of SBlk.s.inodes is 2^32 (unsigned int)\n\t * Max indexes is (2^32*8)\/8K or 2^22\n\t * Max length is ((2^32*8)\/8K)*8 or 2^25\n\t *\/\n\tint res;\n\tint indexes = SQUASHFS_LOOKUP_BLOCKS((long long) sBlk.s.inodes);\n\tint length = SQUASHFS_LOOKUP_BLOCK_BYTES((long long) sBlk.s.inodes);\n\tlong long *export_index_table;\n\n\t\/*\n\t * The size of the index table (length bytes) should match the\n\t * table start and end points\n\t *\/\n\tif(length != (*table_start - sBlk.s.lookup_table_start)) {\n\t\tERROR(\"parse_exports_table: Bad inode count in super block\\n\");\n\t\treturn FALSE;\n\t}\n\n\texport_index_table = alloc_index_table(indexes);\n\n\tres = read_fs_bytes(fd, sBlk.s.lookup_table_start, length,\n\t\t\t\t\t\t\texport_index_table);\n\tif(res == FALSE) {\n\t\tERROR(\"parse_exports_table: failed to read export index table\\n\");\n\t\treturn FALSE;\n\t}\n\tSQUASHFS_INSWAP_LOOKUP_BLOCKS(export_index_table, indexes);\n\n\t\/*\n\t * export_index_table[0] stores the start of the compressed export blocks.\n\t * This by definition is also the end of the previous filesystem\n\t * table - the fragment table.\n\t *\/\n\t*table_start = export_index_table[0];\n\n\treturn TRUE;\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":313140,"func":"testStorageLookup(const void *args)\n{\n    const struct testLookupData *data = args;\n    int ret = 0;\n    virStorageSourcePtr result;\n    virStorageSourcePtr actualParent;\n    unsigned int idx;\n\n    if (virStorageFileParseChainIndex(data->target, data->name, &idx) < 0 &&\n        data->expIndex) {\n        fprintf(stderr, \"call should not have failed\\n\");\n        ret = -1;\n    }\n    if (idx != data->expIndex) {\n        fprintf(stderr, \"index: expected %u, got %u\\n\", data->expIndex, idx);\n        ret = -1;\n    }\n\n     \/* Test twice to ensure optional parameter doesn't cause NULL deref. *\/\n    result = virStorageFileChainLookup(data->chain, data->from,\n                                       idx ? NULL : data->name,\n                                       idx, NULL);\n\n    if (!data->expResult) {\n        if (virGetLastErrorCode() == VIR_ERR_OK) {\n            fprintf(stderr, \"call should have failed\\n\");\n            ret = -1;\n        }\n        virResetLastError();\n    } else {\n        if (virGetLastErrorCode()) {\n            fprintf(stderr, \"call should not have warned\\n\");\n            ret = -1;\n        }\n    }\n\n    if (!result) {\n        if (data->expResult) {\n            fprintf(stderr, \"result 1: expected %s, got NULL\\n\",\n                    data->expResult);\n            ret = -1;\n        }\n    } else if (STRNEQ_NULLABLE(data->expResult, result->path)) {\n        fprintf(stderr, \"result 1: expected %s, got %s\\n\",\n                NULLSTR(data->expResult), NULLSTR(result->path));\n        ret = -1;\n    }\n\n    result = virStorageFileChainLookup(data->chain, data->from,\n                                       data->name, idx, &actualParent);\n    if (!data->expResult)\n        virResetLastError();\n\n    if (!result) {\n        if (data->expResult) {\n            fprintf(stderr, \"result 2: expected %s, got NULL\\n\",\n                    data->expResult);\n            ret = -1;\n        }\n    } else if (STRNEQ_NULLABLE(data->expResult, result->path)) {\n        fprintf(stderr, \"result 2: expected %s, got %s\\n\",\n                NULLSTR(data->expResult), NULLSTR(result->path));\n        ret = -1;\n    }\n    if (data->expMeta != result) {\n        fprintf(stderr, \"meta: expected %p, got %p\\n\",\n                data->expMeta, result);\n        ret = -1;\n    }\n    if (data->expParent != actualParent) {\n        fprintf(stderr, \"parent: expected %s, got %s\\n\",\n                NULLSTR(data->expParent ? data->expParent->path : NULL),\n                NULLSTR(actualParent ? actualParent->path : NULL));\n        ret = -1;\n    }\n\n    return ret;\n}","target":0,"code_token_length":634,"total_token_length":870,"max_tokens_setting":1024}
+{"idx":252346,"func":"static mz_bool mz_zip_writer_add_to_central_dir(\n    mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size,\n    const void *pExtra, mz_uint16 extra_size, const void *pComment,\n    mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size,\n    mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags,\n    mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs,\n    mz_uint32 ext_attributes) {\n  mz_zip_internal_state *pState = pZip->m_pState;\n  mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;\n  size_t orig_central_dir_size = pState->m_central_dir.m_size;\n  mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];\n\n  \/\/ No zip64 support yet\n  if ((local_header_ofs > 0xFFFFFFFF) ||\n      (((mz_uint64)pState->m_central_dir.m_size +\n        MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size +\n        comment_size) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  if (!mz_zip_writer_create_central_dir_header(\n          pZip, central_dir_header, filename_size, extra_size, comment_size,\n          uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time,\n          dos_date, local_header_ofs, ext_attributes))\n    return MZ_FALSE;\n\n  if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header,\n                               MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename,\n                               filename_size)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra,\n                               extra_size)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment,\n                               comment_size)) ||\n      (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets,\n                               ¢ral_dir_ofs, 1))) {\n    \/\/ Try to push the central directory array back into its original state.\n    mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size,\n                        MZ_FALSE);\n    return MZ_FALSE;\n  }\n\n  return MZ_TRUE;\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":313555,"func":"void rose_rt_device_down(struct net_device *dev)\n{\n\tstruct rose_neigh *s, *rose_neigh;\n\tstruct rose_node  *t, *rose_node;\n\tint i;\n\n\tspin_lock_bh(&rose_node_list_lock);\n\tspin_lock_bh(&rose_neigh_list_lock);\n\trose_neigh = rose_neigh_list;\n\twhile (rose_neigh != NULL) {\n\t\ts          = rose_neigh;\n\t\trose_neigh = rose_neigh->next;\n\n\t\tif (s->dev != dev)\n\t\t\tcontinue;\n\n\t\trose_node = rose_node_list;\n\n\t\twhile (rose_node != NULL) {\n\t\t\tt         = rose_node;\n\t\t\trose_node = rose_node->next;\n\n\t\t\tfor (i = 0; i < t->count; i++) {\n\t\t\t\tif (t->neighbour[i] != s)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tt->count--;\n\n\t\t\t\tswitch (i) {\n\t\t\t\tcase 0:\n\t\t\t\t\tt->neighbour[0] = t->neighbour[1];\n\t\t\t\t\tfallthrough;\n\t\t\t\tcase 1:\n\t\t\t\t\tt->neighbour[1] = t->neighbour[2];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (t->count <= 0)\n\t\t\t\trose_remove_node(t);\n\t\t}\n\n\t\trose_remove_neigh(s);\n\t}\n\tspin_unlock_bh(&rose_neigh_list_lock);\n\tspin_unlock_bh(&rose_node_list_lock);\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":310079,"func":"NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)\n\/* ship binary character data to the printer via mc4\/mc5\/mc5p *\/\n{\n    int result;\n    char *mybuf, *switchon;\n    size_t onsize, offsize;\n    size_t need;\n\n    errno = 0;\n    if (!HasTInfoTerminal(SP_PARM)\n\t|| len <= 0\n\t|| (!prtr_non && (!prtr_on || !prtr_off))) {\n\terrno = ENODEV;\n\treturn (ERR);\n    }\n\n    if (prtr_non) {\n\tswitchon = TIPARM_1(prtr_non, len);\n\tonsize = strlen(switchon);\n\toffsize = 0;\n    } else {\n\tswitchon = prtr_on;\n\tonsize = strlen(prtr_on);\n\toffsize = strlen(prtr_off);\n    }\n\n    need = onsize + (size_t) len + offsize;\n\n    if (switchon == 0\n\t|| (mybuf = typeMalloc(char, need + 1)) == 0) {\n\terrno = ENOMEM;\n\treturn (ERR);\n    }\n\n    _nc_STRCPY(mybuf, switchon, need);\n    memcpy(mybuf + onsize, data, (size_t) len);\n    if (offsize)\n\t_nc_STRCPY(mybuf + onsize + len, prtr_off, need);\n\n    \/*\n     * We're relying on the atomicity of UNIX writes here.  The\n     * danger is that output from a refresh() might get interspersed\n     * with the printer data after the write call returns but before the\n     * data has actually been shipped to the terminal.  If the write(2)\n     * operation is truly atomic we're protected from this.\n     *\/\n    result = (int) write(TerminalOf(SP_PARM)->Filedes, mybuf, need);\n\n    \/*\n     * By giving up our scheduler slot here we increase the odds that the\n     * kernel will ship the contiguous clist items from the last write\n     * immediately.\n     *\/\n#ifndef _WIN32\n    (void) sleep(0);\n#endif\n    free(mybuf);\n    return (result);\n}","target":0,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":400116,"func":"IdKeyPair UserTerminalRouter::acceptNewConnection() {\n  lock_guard<recursive_mutex> guard(routerMutex);\n  LOG(INFO) << \"Listening to id\/key FIFO\";\n  int terminalFd = socketHandler->accept(serverFd);\n  if (terminalFd < 0) {\n    if (GetErrno() != EAGAIN && GetErrno() != EWOULDBLOCK) {\n      FATAL_FAIL(-1);  \/\/ STFATAL with the error\n    } else {\n      return IdKeyPair({\"\", \"\"});  \/\/ Nothing to accept this time\n    }\n  }\n\n  LOG(INFO) << \"Connected\";\n\n  try {\n    Packet packet;\n    if (!socketHandler->readPacket(terminalFd, &packet)) {\n      STFATAL << \"Missing user info packet\";\n    }\n    if (packet.getHeader() != TerminalPacketType::TERMINAL_USER_INFO) {\n      STFATAL << \"Got an invalid packet header: \" << int(packet.getHeader());\n    }\n    TerminalUserInfo tui = stringToProto<TerminalUserInfo>(packet.getPayload());\n    tui.set_fd(terminalFd);\n    idInfoMap[tui.id()] = tui;\n    return IdKeyPair({tui.id(), tui.passkey()});\n  } catch (const std::runtime_error &re) {\n    STFATAL << \"Router can't talk to terminal: \" << re.what();\n  }\n\n  STFATAL << \"Should never get here\";\n  return IdKeyPair({\"\", \"\"});\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":195083,"func":"bool Tensor::FromProto(Allocator* a, const TensorProto& proto) {\n  CHECK_NOTNULL(a);\n  TensorBuffer* p = nullptr;\n  if (!TensorShape::IsValid(proto.tensor_shape())) return false;\n  if (proto.dtype() == DT_INVALID) return false;\n  TensorShape shape(proto.tensor_shape());\n  const int64_t N = shape.num_elements();\n  if (N > 0 && proto.dtype()) {\n    bool dtype_error = false;\n    if (!proto.tensor_content().empty()) {\n      const auto& content = proto.tensor_content();\n      CASES_WITH_DEFAULT(proto.dtype(), p = Helper<T>::Decode(a, content, N),\n                         dtype_error = true, dtype_error = true);\n    } else {\n      CASES_WITH_DEFAULT(proto.dtype(), p = FromProtoField<T>(a, proto, N),\n                         dtype_error = true, dtype_error = true);\n    }\n    if (dtype_error || p == nullptr) return false;\n  }\n  shape_ = shape;\n  set_dtype(proto.dtype());\n  UnrefIfNonNull(buf_);\n  buf_ = p;\n  \/\/ TODO(misard) add tracking of which kernels and steps are calling\n  \/\/ FromProto.\n  if (MemoryLoggingEnabled() && buf_ != nullptr && buf_->data() != nullptr) {\n    LogMemory::RecordTensorAllocation(\"Unknown (from Proto)\",\n                                      LogMemory::UNKNOWN_STEP_ID, *this);\n  }\n  return true;\n}","target":1,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":310050,"func":"copy_input(FILE *source, const char *filename, char *alt_file)\n{\n    char my_altfile[PATH_MAX];\n    FILE *result = 0;\n    FILE *target = 0;\n    int ch;\n\n    if (alt_file == 0)\n\talt_file = my_altfile;\n\n    if (source == 0) {\n\tfailed(\"copy_input (source)\");\n    } else if ((target = open_tempfile(alt_file)) == 0) {\n\tfailed(\"copy_input (target)\");\n    } else {\n\tclearerr(source);\n\tfor (;;) {\n\t    ch = fgetc(source);\n\t    if (feof(source)) {\n\t\tbreak;\n\t    } else if (ferror(source)) {\n\t\tfailed(filename);\n\t    } else if (ch == 0) {\n\t\t\/* don't loop in case someone wants to convert \/dev\/zero *\/\n\t\tfprintf(stderr, \"%s: %s is not a text-file\\n\", _nc_progname, filename);\n\t\tExitProgram(EXIT_FAILURE);\n\t    }\n\t    fputc(ch, target);\n\t}\n\tfclose(source);\n\t\/*\n\t * rewind() does not force the target file's data to disk (not does\n\t * fflush()...).  So open a second stream on the data and then close\n\t * the one that we were writing on before starting to read from the\n\t * second stream.\n\t *\/\n\tresult = fopen(alt_file, \"r+\");\n\tfclose(target);\n\tto_remove = strdup(alt_file);\n    }\n    return result;\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":353151,"func":"SplashFunctionPattern::SplashFunctionPattern(SplashColorMode colorModeA, GfxState *stateA, GfxFunctionShading *shadingA)\n{\n  Matrix ctm;\n  SplashColor defaultColor;\n  GfxColor srcColor;\n  const double *matrix = shadingA->getMatrix();\n\n  shading = shadingA;\n  state = stateA;\n  colorMode = colorModeA;\n\n  state->getCTM(&ctm);\n\n  double a1 = ctm.m[0];\n  double b1 = ctm.m[1];\n  double c1 = ctm.m[2];\n  double d1 = ctm.m[3];\n\n  ctm.m[0] = matrix[0] * a1 + matrix[1] * c1;\n  ctm.m[1] = matrix[0] * b1 + matrix[1] * d1;\n  ctm.m[2] = matrix[2] * a1 + matrix[3] * c1;\n  ctm.m[3] = matrix[2] * b1 + matrix[3] * d1;\n  ctm.m[4] = matrix[4] * a1 + matrix[5] * c1 + ctm.m[4];\n  ctm.m[5] = matrix[4] * b1 + matrix[5] * d1 + ctm.m[5];\n  ctm.invertTo(&ictm);\n\n  gfxMode = shadingA->getColorSpace()->getMode();\n  shadingA->getColorSpace()->getDefaultColor(&srcColor);\n  shadingA->getDomain(&xMin, &yMin, &xMax, &yMax);\n  convertGfxColor(defaultColor, colorModeA, shadingA->getColorSpace(), &srcColor);\n}","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":500654,"func":"char *sftp_readlink(sftp_session sftp, const char *path) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  ssh_string path_s = NULL;\n  ssh_string link_s = NULL;\n  ssh_buffer buffer;\n  char *lnk;\n  uint32_t ignored;\n  uint32_t id;\n\n  if (sftp == NULL)\n    return NULL;\n  if (path == NULL) {\n    ssh_set_error_invalid(sftp, __FUNCTION__);\n    return NULL;\n  }\n  if (sftp->version < 3){\n    ssh_set_error(sftp,SSH_REQUEST_DENIED,\"sftp version %d does not support sftp_readlink\",sftp->version);\n    return NULL;\n  }\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return NULL;\n  }\n\n  path_s = ssh_string_from_char(path);\n  if (path_s == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return NULL;\n  }\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, path_s) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    ssh_string_free(path_s);\n    return NULL;\n  }\n  if (sftp_packet_write(sftp, SSH_FXP_READLINK, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(path_s);\n    return NULL;\n  }\n  ssh_buffer_free(buffer);\n  ssh_string_free(path_s);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      return NULL;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  if (msg->packet_type == SSH_FXP_NAME) {\n    \/* we don't care about \"count\" *\/\n    buffer_get_u32(msg->payload, &ignored);\n    \/* we only care about the file name string *\/\n    link_s = buffer_get_ssh_string(msg->payload);\n    sftp_message_free(msg);\n    if (link_s == NULL) {\n      \/* TODO: what error to set here? *\/\n      return NULL;\n    }\n    lnk = ssh_string_to_char(link_s);\n    ssh_string_free(link_s);\n\n    return lnk;\n  } else if (msg->packet_type == SSH_FXP_STATUS) { \/* bad response (error) *\/\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return NULL;\n    }\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n  } else { \/* this shouldn't happen *\/\n    ssh_set_error(sftp->session, SSH_FATAL,\n        \"Received message %d when attempting to set stats\", msg->packet_type);\n    sftp_message_free(msg);\n  }\n\n  return NULL;\n}","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":282864,"func":"int rsi_send_ps_request(struct rsi_hw *adapter, bool enable,\n\t\t\tstruct ieee80211_vif *vif)\n{\n\tstruct rsi_common *common = adapter->priv;\n\tstruct ieee80211_bss_conf *bss = &vif->bss_conf;\n\tstruct rsi_request_ps *ps;\n\tstruct rsi_ps_info *ps_info;\n\tstruct sk_buff *skb;\n\tint frame_len = sizeof(*ps);\n\n\tskb = dev_alloc_skb(frame_len);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\tmemset(skb->data, 0, frame_len);\n\n\tps = (struct rsi_request_ps *)skb->data;\n\tps_info = &adapter->ps_info;\n\n\trsi_set_len_qno(&ps->desc.desc_dword0.len_qno,\n\t\t\t(frame_len - FRAME_DESC_SZ), RSI_WIFI_MGMT_Q);\n\tps->desc.desc_dword0.frame_type = WAKEUP_SLEEP_REQUEST;\n\tif (enable) {\n\t\tps->ps_sleep.enable = RSI_PS_ENABLE;\n\t\tps->desc.desc_dword3.token = cpu_to_le16(RSI_SLEEP_REQUEST);\n\t} else {\n\t\tps->ps_sleep.enable = RSI_PS_DISABLE;\n\t\tps->desc.desc_dword0.len_qno |= cpu_to_le16(RSI_PS_DISABLE_IND);\n\t\tps->desc.desc_dword3.token = cpu_to_le16(RSI_WAKEUP_REQUEST);\n\t}\n\n\tps->ps_uapsd_acs = common->uapsd_bitmap;\n\n\tps->ps_sleep.sleep_type = ps_info->sleep_type;\n\tps->ps_sleep.num_bcns_per_lis_int =\n\t\tcpu_to_le16(ps_info->num_bcns_per_lis_int);\n\tps->ps_sleep.sleep_duration =\n\t\tcpu_to_le32(ps_info->deep_sleep_wakeup_period);\n\n\tif (bss->assoc)\n\t\tps->ps_sleep.connected_sleep = RSI_CONNECTED_SLEEP;\n\telse\n\t\tps->ps_sleep.connected_sleep = RSI_DEEP_SLEEP;\n\n\tps->ps_listen_interval = cpu_to_le32(ps_info->listen_interval);\n\tps->ps_dtim_interval_duration =\n\t\tcpu_to_le32(ps_info->dtim_interval_duration);\n\n\tif (ps_info->listen_interval > ps_info->dtim_interval_duration)\n\t\tps->ps_listen_interval = cpu_to_le32(RSI_PS_DISABLE);\n\n\tps->ps_num_dtim_intervals = cpu_to_le16(ps_info->num_dtims_per_sleep);\n\tskb_put(skb, frame_len);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":233868,"func":" *\/\nvoid php_wddx_serialize_var(wddx_packet *packet, zval *var, zend_string *name)\n{\n\tHashTable *ht;\n\n\tif (name) {\n\t\tchar *tmp_buf;\n\t\tzend_string *name_esc = php_escape_html_entities((unsigned char *) ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES, NULL);\n\t\ttmp_buf = emalloc(ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S));\n\t\tsnprintf(tmp_buf, ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S), WDDX_VAR_S, ZSTR_VAL(name_esc));\n\t\tphp_wddx_add_chunk(packet, tmp_buf);\n\t\tefree(tmp_buf);\n\t\tzend_string_release(name_esc);\n\t}\n\n\tif (Z_TYPE_P(var) == IS_INDIRECT) {\n\t\tvar = Z_INDIRECT_P(var);\n\t}\n\tZVAL_DEREF(var);\n\tswitch (Z_TYPE_P(var)) {\n\t\tcase IS_STRING:\n\t\t\tphp_wddx_serialize_string(packet, var);\n\t\t\tbreak;\n\n\t\tcase IS_LONG:\n\t\tcase IS_DOUBLE:\n\t\t\tphp_wddx_serialize_number(packet, var);\n\t\t\tbreak;\n\n\t\tcase IS_TRUE:\n\t\tcase IS_FALSE:\n\t\t\tphp_wddx_serialize_boolean(packet, var);\n\t\t\tbreak;\n\n\t\tcase IS_NULL:\n\t\t\tphp_wddx_serialize_unset(packet);\n\t\t\tbreak;\n\n\t\tcase IS_ARRAY:\n\t\t\tht = Z_ARRVAL_P(var);\n\t\t\tif (ht->u.v.nApplyCount > 1) {\n\t\t\t\tphp_error_docref(NULL, E_RECOVERABLE_ERROR, \"WDDX doesn't support circular references\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (ZEND_HASH_APPLY_PROTECTION(ht)) {\n\t\t\t\tht->u.v.nApplyCount++;\n\t\t\t}\n\t\t\tphp_wddx_serialize_array(packet, var);\n\t\t\tif (ZEND_HASH_APPLY_PROTECTION(ht)) {\n\t\t\t\tht->u.v.nApplyCount--;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IS_OBJECT:\n\t\t\tht = Z_OBJPROP_P(var);\n\t\t\tif (ht->u.v.nApplyCount > 1) {\n\t\t\t\tphp_error_docref(NULL, E_RECOVERABLE_ERROR, \"WDDX doesn't support circular references\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tht->u.v.nApplyCount++;\n \t\t\tphp_wddx_serialize_object(packet, var);\n\t\t\tht->u.v.nApplyCount--;\n\t\t\tbreak;\n\t}\n\n\tif (name) {\n\t\tphp_wddx_add_chunk_static(packet, WDDX_VAR_E);\n\t}","target":0,"code_token_length":531,"total_token_length":767,"max_tokens_setting":1024}
+{"idx":437330,"func":"recursive_call_check_trav(Node* node, ScanEnv* env, int state)\n{\n  int r = 0;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n  case NODE_ALT:\n    {\n      int ret;\n      do {\n        ret = recursive_call_check_trav(NODE_CAR(node), env, state);\n        if (ret == FOUND_CALLED_NODE) r = FOUND_CALLED_NODE;\n        else if (ret < 0) return ret;\n      } while (IS_NOT_NULL(node = NODE_CDR(node)));\n    }\n    break;\n\n  case NODE_QUANT:\n    r = recursive_call_check_trav(NODE_BODY(node), env, state);\n    if (QUANT_(node)->upper == 0) {\n      if (r == FOUND_CALLED_NODE)\n        QUANT_(node)->is_refered = 1;\n    }\n    break;\n\n  case NODE_ANCHOR:\n    {\n      AnchorNode* an = ANCHOR_(node);\n      if (ANCHOR_HAS_BODY(an))\n        r = recursive_call_check_trav(NODE_ANCHOR_BODY(an), env, state);\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      int ret;\n      int state1;\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      if (en->type == ENCLOSURE_MEMORY) {\n        if (NODE_IS_CALLED(node) || (state & IN_RECURSION) != 0) {\n          if (! NODE_IS_RECURSION(node)) {\n            NODE_STATUS_ADD(node, MARK1);\n            r = recursive_call_check(NODE_BODY(node));\n            if (r != 0)\n              NODE_STATUS_ADD(node, RECURSION);\n            NODE_STATUS_REMOVE(node, MARK1);\n          }\n\n          if (NODE_IS_CALLED(node))\n            r = FOUND_CALLED_NODE;\n        }\n      }\n\n      state1 = state;\n      if (NODE_IS_RECURSION(node))\n        state1 |= IN_RECURSION;\n\n      ret = recursive_call_check_trav(NODE_BODY(node), env, state1);\n      if (ret == FOUND_CALLED_NODE)\n        r = FOUND_CALLED_NODE;\n\n      if (en->type == ENCLOSURE_IF_ELSE) {\n        if (IS_NOT_NULL(en->te.Then)) {\n          ret = recursive_call_check_trav(en->te.Then, env, state1);\n          if (ret == FOUND_CALLED_NODE)\n            r = FOUND_CALLED_NODE;\n        }\n        if (IS_NOT_NULL(en->te.Else)) {\n          ret = recursive_call_check_trav(en->te.Else, env, state1);\n          if (ret == FOUND_CALLED_NODE)\n            r = FOUND_CALLED_NODE;\n        }\n      }\n    }\n    break;\n\n  default:\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":289259,"func":"static int snd_pcm_oss_register_minor(struct snd_pcm *pcm)\n{\n\tpcm->oss.reg = 0;\n\tif (dsp_map[pcm->card->number] == (int)pcm->device) {\n\t\tchar name[128];\n\t\tint duplex;\n\t\tregister_oss_dsp(pcm, 0);\n\t\tduplex = (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count > 0 && \n\t\t\t      pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count && \n\t\t\t      !(pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX));\n\t\tsprintf(name, \"%s%s\", pcm->name, duplex ? \" (DUPLEX)\" : \"\");\n#ifdef SNDRV_OSS_INFO_DEV_AUDIO\n\t\tsnd_oss_info_register(SNDRV_OSS_INFO_DEV_AUDIO,\n\t\t\t\t      pcm->card->number,\n\t\t\t\t      name);\n#endif\n\t\tpcm->oss.reg++;\n\t\tpcm->oss.reg_mask |= 1;\n\t}\n\tif (adsp_map[pcm->card->number] == (int)pcm->device) {\n\t\tregister_oss_dsp(pcm, 1);\n\t\tpcm->oss.reg++;\n\t\tpcm->oss.reg_mask |= 2;\n\t}\n\n\tif (pcm->oss.reg)\n\t\tsnd_pcm_oss_proc_init(pcm);\n\n\treturn 0;\n}","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":247350,"func":"int pgpPubkeyFingerprint(const uint8_t *h, size_t hlen,\n\t\t\t  uint8_t **fp, size_t *fplen)\n{\n    int rc = -1; \/* assume failure *\/\n    const uint8_t *se;\n    const uint8_t *pend = h + hlen;\n    uint8_t version = 0;\n\n    if (pgpVersion(h, hlen, &version))\n\treturn rc;\n\n    \/* We only permit V4 keys, V3 keys are long long since deprecated *\/\n    switch (version) {\n    case 4:\n      {\tpgpPktKeyV4 v = (pgpPktKeyV4) (h);\n\tint mpis = -1;\n\n\t\/* Packet must be larger than v to have room for the required MPIs *\/\n\tif (hlen > sizeof(*v)) {\n\t    switch (v->pubkey_algo) {\n\t    case PGPPUBKEYALGO_RSA:\n\t\tmpis = 2;\n\t\tbreak;\n\t    case PGPPUBKEYALGO_DSA:\n\t\tmpis = 4;\n\t\tbreak;\n\t    case PGPPUBKEYALGO_EDDSA:\n\t\tmpis = 1;\n\t\tbreak;\n\t    }\n\t}\n\n\tse = (uint8_t *)(v + 1);\n\t\/* EdDSA has a curve id before the MPIs *\/\n\tif (v->pubkey_algo == PGPPUBKEYALGO_EDDSA) {\n\t    if (se < pend && se[0] != 0x00 && se[0] != 0xff)\n\t\tse += 1 + se[0];\n\t    else\n\t\tse = pend;      \/* error out when reading the MPI *\/\n\t}\n\twhile (se < pend && mpis-- > 0)\n\t    se += pgpMpiLen(se);\n\n\t\/* Does the size and number of MPI's match our expectations? *\/\n\tif (se == pend && mpis == 0) {\n\t    DIGEST_CTX ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);\n\t    uint8_t *d = NULL;\n\t    size_t dlen = 0;\n\t    int i = se - h;\n\t    uint8_t in[3] = { 0x99, (i >> 8), i };\n\n\t    (void) rpmDigestUpdate(ctx, in, 3);\n\t    (void) rpmDigestUpdate(ctx, h, i);\n\t    (void) rpmDigestFinal(ctx, (void **)&d, &dlen, 0);\n\n\t    if (dlen == 20) {\n\t\trc = 0;\n\t\t*fp = d;\n\t\t*fplen = dlen;\n\t    } else {\n\t\tfree(d);\n\t    }\n\t}\n\n      }\tbreak;\n    default:\n\trpmlog(RPMLOG_WARNING, _(\"Unsupported version of key: V%d\\n\"), version);\n    }\n    return rc;\n}","target":0,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":259303,"func":"static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    unsigned mov_field_order;\n    enum AVFieldOrder decoded_field_order = AV_FIELD_UNKNOWN;\n\n    if (c->fc->nb_streams < 1) \/\/ will happen with jp2 files\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n    if (atom.size < 2)\n        return AVERROR_INVALIDDATA;\n    mov_field_order = avio_rb16(pb);\n    if ((mov_field_order & 0xFF00) == 0x0100)\n        decoded_field_order = AV_FIELD_PROGRESSIVE;\n    else if ((mov_field_order & 0xFF00) == 0x0200) {\n        switch (mov_field_order & 0xFF) {\n        case 0x01: decoded_field_order = AV_FIELD_TT;\n                   break;\n        case 0x06: decoded_field_order = AV_FIELD_BB;\n                   break;\n        case 0x09: decoded_field_order = AV_FIELD_TB;\n                   break;\n        case 0x0E: decoded_field_order = AV_FIELD_BT;\n                   break;\n        }\n    }\n    if (decoded_field_order == AV_FIELD_UNKNOWN && mov_field_order) {\n        av_log(c->fc, AV_LOG_ERROR, \"Unknown MOV field order 0x%04x\\n\", mov_field_order);\n    }\n    st->codecpar->field_order = decoded_field_order;\n\n    return 0;\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":281125,"func":"static int xfrm_policy_migrate(struct xfrm_policy *pol,\n\t\t\t       struct xfrm_migrate *m, int num_migrate)\n{\n\tstruct xfrm_migrate *mp;\n\tint i, j, n = 0;\n\n\twrite_lock_bh(&pol->lock);\n\tif (unlikely(pol->walk.dead)) {\n\t\t\/* target policy has been deleted *\/\n\t\twrite_unlock_bh(&pol->lock);\n\t\treturn -ENOENT;\n\t}\n\n\tfor (i = 0; i < pol->xfrm_nr; i++) {\n\t\tfor (j = 0, mp = m; j < num_migrate; j++, mp++) {\n\t\t\tif (!migrate_tmpl_match(mp, &pol->xfrm_vec[i]))\n\t\t\t\tcontinue;\n\t\t\tn++;\n\t\t\tif (pol->xfrm_vec[i].mode != XFRM_MODE_TUNNEL &&\n\t\t\t    pol->xfrm_vec[i].mode != XFRM_MODE_BEET)\n\t\t\t\tcontinue;\n\t\t\t\/* update endpoints *\/\n\t\t\tmemcpy(&pol->xfrm_vec[i].id.daddr, &mp->new_daddr,\n\t\t\t       sizeof(pol->xfrm_vec[i].id.daddr));\n\t\t\tmemcpy(&pol->xfrm_vec[i].saddr, &mp->new_saddr,\n\t\t\t       sizeof(pol->xfrm_vec[i].saddr));\n\t\t\tpol->xfrm_vec[i].encap_family = mp->new_family;\n\t\t\t\/* flush bundles *\/\n\t\t\tatomic_inc(&pol->genid);\n\t\t}\n\t}\n\n\twrite_unlock_bh(&pol->lock);\n\n\tif (!n)\n\t\treturn -ENODATA;\n\n\treturn 0;\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":231734,"func":"TEST_P(\n    QuicServerTransportAllowMigrationTest,\n    ReceiveProbingPacketFromChangedPeerAddress) {\n  auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);\n  server->getNonConstConn().qLogger = qLogger;\n  server->getNonConstConn().transportSettings.disableMigration = false;\n\n  \/\/ Add additional peer id so PathResponse completes.\n  server->getNonConstConn().peerConnectionIds.emplace_back(\n      ConnectionId({1, 2, 3, 4}), 1);\n\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  ASSERT_TRUE(builder.canBuildPacket());\n\n  writeSimpleFrame(PathChallengeFrame(123), builder);\n  auto packet = std::move(builder).buildPacket();\n  auto packetData = packetToBuf(packet);\n  folly::SocketAddress newPeer(\"100.101.102.103\", 23456);\n  try {\n    deliverData(std::move(packetData), true, &newPeer);\n    FAIL();\n  } catch (const std::runtime_error& ex) {\n    EXPECT_EQ(std::string(ex.what()), \"Invalid migration\");\n  }\n  EXPECT_TRUE(server->getConn().localConnectionError);\n  EXPECT_EQ(\n      server->getConn().localConnectionError->second,\n      \"Probing not supported yet\");\n\n  std::vector<int> indices =\n      getQLogEventIndices(QLogEventType::PacketDrop, qLogger);\n  EXPECT_EQ(indices.size(), 1);\n  auto tmp = std::move(qLogger->logs[indices[0]]);\n  auto event = dynamic_cast<QLogPacketDropEvent*>(tmp.get());\n  EXPECT_EQ(event->packetSize, 29);\n  EXPECT_EQ(\n      event->dropReason,\n      QuicTransportStatsCallback::toString(\n          PacketDropReason::PEER_ADDRESS_CHANGE));\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":384194,"func":"static int nf_tables_dump_rules(struct sk_buff *skb,\n\t\t\t\tstruct netlink_callback *cb)\n{\n\tconst struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);\n\tconst struct nft_rule_dump_ctx *ctx = cb->data;\n\tstruct nft_table *table;\n\tconst struct nft_chain *chain;\n\tunsigned int idx = 0;\n\tstruct net *net = sock_net(skb->sk);\n\tint family = nfmsg->nfgen_family;\n\tstruct nftables_pernet *nft_net;\n\n\trcu_read_lock();\n\tnft_net = nft_pernet(net);\n\tcb->seq = READ_ONCE(nft_net->base_seq);\n\n\tlist_for_each_entry_rcu(table, &nft_net->tables, list) {\n\t\tif (family != NFPROTO_UNSPEC && family != table->family)\n\t\t\tcontinue;\n\n\t\tif (ctx && ctx->table && strcmp(ctx->table, table->name) != 0)\n\t\t\tcontinue;\n\n\t\tif (ctx && ctx->table && ctx->chain) {\n\t\t\tstruct rhlist_head *list, *tmp;\n\n\t\t\tlist = rhltable_lookup(&table->chains_ht, ctx->chain,\n\t\t\t\t\t       nft_chain_ht_params);\n\t\t\tif (!list)\n\t\t\t\tgoto done;\n\n\t\t\trhl_for_each_entry_rcu(chain, tmp, list, rhlhead) {\n\t\t\t\tif (!nft_is_active(net, chain))\n\t\t\t\t\tcontinue;\n\t\t\t\t__nf_tables_dump_rules(skb, &idx,\n\t\t\t\t\t\t       cb, table, chain);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tgoto done;\n\t\t}\n\n\t\tlist_for_each_entry_rcu(chain, &table->chains, list) {\n\t\t\tif (__nf_tables_dump_rules(skb, &idx, cb, table, chain))\n\t\t\t\tgoto done;\n\t\t}\n\n\t\tif (ctx && ctx->table)\n\t\t\tbreak;\n\t}\ndone:\n\trcu_read_unlock();\n\n\tcb->args[0] = idx;\n\treturn skb->len;\n}","target":0,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":427202,"func":"LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,\n                       Dyndata *dyd, const char *name, int firstchar) {\n  LexState lexstate;\n  FuncState funcstate;\n  LClosure *cl = luaF_newLclosure(L, 1);  \/* create main closure *\/\n  setclLvalue2s(L, L->top, cl);  \/* anchor it (to avoid being collected) *\/\n  luaD_inctop(L);\n  lexstate.h = luaH_new(L);  \/* create table for scanner *\/\n  sethvalue2s(L, L->top, lexstate.h);  \/* anchor it *\/\n  luaD_inctop(L);\n  funcstate.f = cl->p = luaF_newproto(L);\n  luaC_objbarrier(L, cl, cl->p);\n  funcstate.f->source = luaS_new(L, name);  \/* create and anchor TString *\/\n  luaC_objbarrier(L, funcstate.f, funcstate.f->source);\n  lexstate.buff = buff;\n  lexstate.dyd = dyd;\n  dyd->actvar.n = dyd->gt.n = dyd->label.n = 0;\n  luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar);\n  mainfunc(&lexstate, &funcstate);\n  lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);\n  \/* all scopes should be correctly finished *\/\n  lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0);\n  L->top--;  \/* remove scanner's table *\/\n  return cl;  \/* closure is on the stack, too *\/\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":318092,"func":"static int rsi_find_bulk_in_and_out_endpoints(struct usb_interface *interface,\n\t\t\t\t\t      struct rsi_hw *adapter)\n{\n\tstruct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;\n\tstruct usb_host_interface *iface_desc;\n\tstruct usb_endpoint_descriptor *endpoint;\n\t__le16 buffer_size;\n\tint ii, bin_found = 0, bout_found = 0;\n\n\tiface_desc = &(interface->altsetting[0]);\n\n\tfor (ii = 0; ii < iface_desc->desc.bNumEndpoints; ++ii) {\n\t\tendpoint = &(iface_desc->endpoint[ii].desc);\n\n\t\tif (!dev->bulkin_endpoint_addr[bin_found] &&\n\t\t    (endpoint->bEndpointAddress & USB_DIR_IN) &&\n\t\t    ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==\n\t\t    USB_ENDPOINT_XFER_BULK)) {\n\t\t\tbuffer_size = endpoint->wMaxPacketSize;\n\t\t\tdev->bulkin_size[bin_found] = buffer_size;\n\t\t\tdev->bulkin_endpoint_addr[bin_found] =\n\t\t\t\tendpoint->bEndpointAddress;\n\t\t\tbin_found++;\n\t\t}\n\n\t\tif (!dev->bulkout_endpoint_addr[bout_found] &&\n\t\t    !(endpoint->bEndpointAddress & USB_DIR_IN) &&\n\t\t    ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==\n\t\t    USB_ENDPOINT_XFER_BULK)) {\n\t\t\tbuffer_size = endpoint->wMaxPacketSize;\n\t\t\tdev->bulkout_endpoint_addr[bout_found] =\n\t\t\t\tendpoint->bEndpointAddress;\n\t\t\tdev->bulkout_size[bout_found] = buffer_size;\n\t\t\tbout_found++;\n\t\t}\n\n\t\tif (bin_found >= MAX_BULK_EP || bout_found >= MAX_BULK_EP)\n\t\t\tbreak;\n\t}\n\n\tif (!(dev->bulkin_endpoint_addr[0]) &&\n\t    dev->bulkout_endpoint_addr[0])\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":405,"total_token_length":641,"max_tokens_setting":1024}
+{"idx":195220,"func":"int main(int argc, char **argv, char **envp)\n{\n\tint opt;\n\n\twhile ((opt = getopt(argc, argv, \"b:h:k:p:q:w:z:xv\")) != -1) {\n\t\tswitch (opt) {\n\t\tcase 'b':\n\t\t\ttmate_settings->bind_addr = xstrdup(optarg);\n\t\t\tbreak;\n\t\tcase 'h':\n\t\t\ttmate_settings->tmate_host = xstrdup(optarg);\n\t\t\tbreak;\n\t\tcase 'k':\n\t\t\ttmate_settings->keys_dir = xstrdup(optarg);\n\t\t\tbreak;\n\t\tcase 'p':\n\t\t\ttmate_settings->ssh_port = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'q':\n\t\t\ttmate_settings->ssh_port_advertized = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'w':\n\t\t\ttmate_settings->websocket_hostname = xstrdup(optarg);\n\t\t\tbreak;\n\t\tcase 'z':\n\t\t\ttmate_settings->websocket_port = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'x':\n\t\t\ttmate_settings->use_proxy_protocol = true;\n\t\t\tbreak;\n\t\tcase 'v':\n\t\t\ttmate_settings->log_level++;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tusage();\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tinit_logging(tmate_settings->log_level);\n\n\tsetup_locale();\n\n\tif (!tmate_settings->tmate_host)\n\t\ttmate_settings->tmate_host = get_full_hostname();\n\n\tcmdline = *argv;\n\tcmdline_end = *envp;\n\n\ttmate_preload_trace_lib();\n\ttmate_catch_sigsegv();\n\ttmate_init_rand();\n\n\tif ((mkdir(TMATE_WORKDIR, 0701)             < 0 && errno != EEXIST) ||\n\t    (mkdir(TMATE_WORKDIR \"\/sessions\", 0703) < 0 && errno != EEXIST) ||\n\t    (mkdir(TMATE_WORKDIR \"\/jail\", 0700)     < 0 && errno != EEXIST))\n\t\ttmate_fatal(\"Cannot prepare session in \" TMATE_WORKDIR);\n\n\t\/* The websocket server needs to access the \/session dir to rename sockets *\/\n\tif ((chmod(TMATE_WORKDIR, 0701)             < 0) ||\n\t    (chmod(TMATE_WORKDIR \"\/sessions\", 0703) < 0) ||\n\t    (chmod(TMATE_WORKDIR \"\/jail\", 0700)     < 0))\n\t\ttmate_fatal(\"Cannot prepare session in \" TMATE_WORKDIR);\n\n\ttmate_ssh_server_main(tmate_session,\n\t\t\t      tmate_settings->keys_dir, tmate_settings->bind_addr, tmate_settings->ssh_port);\n\treturn 0;\n}","target":1,"code_token_length":539,"total_token_length":775,"max_tokens_setting":1024}
+{"idx":234750,"func":"static int decide_stripe_size(struct btrfs_fs_devices *fs_devices,\n\t\t\t      struct alloc_chunk_ctl *ctl,\n\t\t\t      struct btrfs_device_info *devices_info)\n{\n\tstruct btrfs_fs_info *info = fs_devices->fs_info;\n\n\t\/*\n\t * Round down to number of usable stripes, devs_increment can be any\n\t * number so we can't use round_down() that requires power of 2, while\n\t * rounddown is safe.\n\t *\/\n\tctl->ndevs = rounddown(ctl->ndevs, ctl->devs_increment);\n\n\tif (ctl->ndevs < ctl->devs_min) {\n\t\tif (btrfs_test_opt(info, ENOSPC_DEBUG)) {\n\t\t\tbtrfs_debug(info,\n\t\"%s: not enough devices with free space: have=%d minimum required=%d\",\n\t\t\t\t    __func__, ctl->ndevs, ctl->devs_min);\n\t\t}\n\t\treturn -ENOSPC;\n\t}\n\n\tctl->ndevs = min(ctl->ndevs, ctl->devs_max);\n\n\tswitch (fs_devices->chunk_alloc_policy) {\n\tcase BTRFS_CHUNK_ALLOC_REGULAR:\n\t\treturn decide_stripe_size_regular(ctl, devices_info);\n\tcase BTRFS_CHUNK_ALLOC_ZONED:\n\t\treturn decide_stripe_size_zoned(ctl, devices_info);\n\tdefault:\n\t\tBUG();\n\t}\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":489171,"func":"sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\t\tvoid *arg,\n\t\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tunion sctp_addr from_addr;\n\tstruct sctp_transport *link;\n\tsctp_sender_hb_info_t *hbinfo;\n\tunsigned long max_interval;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the HEARTBEAT-ACK chunk has a valid length.  *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_heartbeat_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\thbinfo = (sctp_sender_hb_info_t *) chunk->skb->data;\n\t\/* Make sure that the length of the parameter is what we expect *\/\n\tif (ntohs(hbinfo->param_hdr.length) !=\n\t\t\t\t    sizeof(sctp_sender_hb_info_t)) {\n\t\treturn SCTP_DISPOSITION_DISCARD;\n\t}\n\n\tfrom_addr = hbinfo->daddr;\n\tlink = sctp_assoc_lookup_paddr(asoc, &from_addr);\n\n\t\/* This should never happen, but lets log it if so.  *\/\n\tif (unlikely(!link)) {\n\t\tif (from_addr.sa.sa_family == AF_INET6) {\n\t\t\tif (net_ratelimit())\n\t\t\t\tprintk(KERN_WARNING\n\t\t\t\t    \"%s association %p could not find address \"\n\t\t\t\t    NIP6_FMT \"\\n\",\n\t\t\t\t    __func__,\n\t\t\t\t    asoc,\n\t\t\t\t    NIP6(from_addr.v6.sin6_addr));\n\t\t} else {\n\t\t\tif (net_ratelimit())\n\t\t\t\tprintk(KERN_WARNING\n\t\t\t\t    \"%s association %p could not find address \"\n\t\t\t\t    NIPQUAD_FMT \"\\n\",\n\t\t\t\t    __func__,\n\t\t\t\t    asoc,\n\t\t\t\t    NIPQUAD(from_addr.v4.sin_addr.s_addr));\n\t\t}\n\t\treturn SCTP_DISPOSITION_DISCARD;\n\t}\n\n\t\/* Validate the 64-bit random nonce. *\/\n\tif (hbinfo->hb_nonce != link->hb_nonce)\n\t\treturn SCTP_DISPOSITION_DISCARD;\n\n\tmax_interval = link->hbinterval + link->rto;\n\n\t\/* Check if the timestamp looks valid.  *\/\n\tif (time_after(hbinfo->sent_at, jiffies) ||\n\t    time_after(jiffies, hbinfo->sent_at + max_interval)) {\n\t\tSCTP_DEBUG_PRINTK(\"%s: HEARTBEAT ACK with invalid timestamp \"\n\t\t\t\t  \"received for transport: %p\\n\",\n\t\t\t\t   __func__, link);\n\t\treturn SCTP_DISPOSITION_DISCARD;\n\t}\n\n\t\/* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of\n\t * the HEARTBEAT should clear the error counter of the\n\t * destination transport address to which the HEARTBEAT was\n\t * sent and mark the destination transport address as active if\n\t * it is not so marked.\n\t *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_TRANSPORT_ON, SCTP_TRANSPORT(link));\n\n\treturn SCTP_DISPOSITION_CONSUME;\n}","target":0,"code_token_length":679,"total_token_length":915,"max_tokens_setting":1024}
+{"idx":231028,"func":"    BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue,\r\n                                       void * pvBuffer,\r\n                                       BaseType_t * pxCoRoutineWoken )\r\n    {\r\n        BaseType_t xReturn;\r\n        Queue_t * const pxQueue = xQueue;\r\n\r\n        \/* We cannot block from an ISR, so check there is data available. If\r\n         * not then just leave without doing anything. *\/\r\n        if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r\n        {\r\n            \/* Copy the data from the queue. *\/\r\n            pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;\r\n\r\n            if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )\r\n            {\r\n                pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n\r\n            --( pxQueue->uxMessagesWaiting );\r\n            ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r\n\r\n            if( ( *pxCoRoutineWoken ) == pdFALSE )\r\n            {\r\n                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r\n                {\r\n                    if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r\n                    {\r\n                        *pxCoRoutineWoken = pdTRUE;\r\n                    }\r\n                    else\r\n                    {\r\n                        mtCOVERAGE_TEST_MARKER();\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n\r\n            xReturn = pdPASS;\r\n        }\r\n        else\r\n        {\r\n            xReturn = pdFAIL;\r\n        }\r\n\r\n        return xReturn;\r\n    }\r","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":318768,"func":"const char *drill_g_code_name(drill_g_code_t g_code)\n{\n    switch (g_code) {\n    case DRILL_G_ROUT:\n\treturn N_(\"rout mode\");\n    case DRILL_G_LINEARMOVE:\n\treturn N_(\"linear mode\");\n    case DRILL_G_CWMOVE:\n\treturn N_(\"circular CW mode\");\n    case DRILL_G_CCWMOVE:\n\treturn N_(\"circular CCW mode\");\n    case DRILL_G_VARIABLEDWELL:\n\treturn N_(\"variable dwell\");\n    case DRILL_G_DRILL:\n\treturn N_(\"drill mode\");\n    case DRILL_G_OVERRIDETOOLSPEED:\n\treturn N_(\"override tool feed or speed\");\n    case DRILL_G_ROUTCIRCLE:\n\treturn N_(\"routed CW circle\");\n    case DRILL_G_ROUTCIRCLECCW:\n\treturn N_(\"routed CCW circle\");\n    case DRILL_G_VISTOOL:\n\treturn N_(\"select vision tool\");\n    case DRILL_G_VISSINGLEPOINTOFFSET:\n\treturn N_(\"single point vision offset\");\n    case DRILL_G_VISMULTIPOINTTRANS:\n\treturn N_(\"multipoint vision translation\");\n    case DRILL_G_VISCANCEL:\n\treturn N_(\"cancel vision translation or offset\");\n    case DRILL_G_VISCORRHOLEDRILL:\n\treturn N_(\"vision corrected single hole drilling\");\n    case DRILL_G_VISAUTOCALIBRATION:\n\treturn N_(\"vision system autocalibration\");\n    case DRILL_G_CUTTERCOMPOFF:\n\treturn N_(\"cutter compensation off\");\n    case DRILL_G_CUTTERCOMPLEFT:\n\treturn N_(\"cutter compensation left\");\n    case DRILL_G_CUTTERCOMPRIGHT:\n\treturn N_(\"cutter compensation right\");\n    case DRILL_G_VISSINGLEPOINTOFFSETREL:\n\treturn N_(\"single point vision relative offset\");\n    case DRILL_G_VISMULTIPOINTTRANSREL:\n\treturn N_(\"multipoint vision relative translation\");\n    case DRILL_G_VISCANCELREL:\n\treturn N_(\"cancel vision relative translation or offset\");\n    case DRILL_G_VISCORRHOLEDRILLREL:\n\treturn N_(\"vision corrected single hole relative drilling\");\n    case DRILL_G_PACKDIP2:\n\treturn N_(\"dual in line package\");\n    case DRILL_G_PACKDIP:\n\treturn N_(\"dual in line package\");\n    case DRILL_G_PACK8PINL:\n\treturn N_(\"eight pin L package\");\n    case DRILL_G_CIRLE:\n\treturn N_(\"canned circle\");\n    case DRILL_G_SLOT:\n\treturn N_(\"canned slot\");\n    case DRILL_G_ROUTSLOT:\n\treturn N_(\"routed step slot\");\n    case DRILL_G_ABSOLUTE:\n\treturn N_(\"absolute input mode\");\n    case DRILL_G_INCREMENTAL:\n\treturn N_(\"incremental input mode\");\n    case DRILL_G_ZEROSET:\n\treturn N_(\"zero set\");\n\n    case DRILL_G_UNKNOWN:\n    default:\n\treturn N_(\"unknown G-code\");\n    }\n} \/* drill_g_code_name() *\/","target":0,"code_token_length":614,"total_token_length":850,"max_tokens_setting":1024}
+{"idx":393525,"func":"static SQInteger closure_getinfos(HSQUIRRELVM v) {\n    SQObject o = stack_get(v,1);\n    SQTable *res = SQTable::Create(_ss(v),4);\n    if(sq_type(o) == OT_CLOSURE) {\n        SQFunctionProto *f = _closure(o)->_function;\n        SQInteger nparams = f->_nparameters + (f->_varparams?1:0);\n        SQObjectPtr params = SQArray::Create(_ss(v),nparams);\n    SQObjectPtr defparams = SQArray::Create(_ss(v),f->_ndefaultparams);\n        for(SQInteger n = 0; n<f->_nparameters; n++) {\n            _array(params)->Set((SQInteger)n,f->_parameters[n]);\n        }\n    for(SQInteger j = 0; j<f->_ndefaultparams; j++) {\n            _array(defparams)->Set((SQInteger)j,_closure(o)->_defaultparams[j]);\n        }\n        if(f->_varparams) {\n            _array(params)->Set(nparams-1,SQString::Create(_ss(v),_SC(\"...\"),-1));\n        }\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"native\"),-1),false);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"name\"),-1),f->_name);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"src\"),-1),f->_sourcename);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"parameters\"),-1),params);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"varargs\"),-1),f->_varparams);\n    res->NewSlot(SQString::Create(_ss(v),_SC(\"defparams\"),-1),defparams);\n    }\n    else { \/\/OT_NATIVECLOSURE\n        SQNativeClosure *nc = _nativeclosure(o);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"native\"),-1),true);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"name\"),-1),nc->_name);\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"paramscheck\"),-1),nc->_nparamscheck);\n        SQObjectPtr typecheck;\n        if(nc->_typecheck.size() > 0) {\n            typecheck =\n                SQArray::Create(_ss(v), nc->_typecheck.size());\n            for(SQUnsignedInteger n = 0; n<nc->_typecheck.size(); n++) {\n                    _array(typecheck)->Set((SQInteger)n,nc->_typecheck[n]);\n            }\n        }\n        res->NewSlot(SQString::Create(_ss(v),_SC(\"typecheck\"),-1),typecheck);\n    }\n    v->Push(res);\n    return 1;\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":326626,"func":"_archive_write_disk_free(struct archive *_a)\n{\n\tstruct archive_write_disk *a;\n\tint ret;\n\tif (_a == NULL)\n\t\treturn (ARCHIVE_OK);\n\tarchive_check_magic(_a, ARCHIVE_WRITE_DISK_MAGIC,\n\t    ARCHIVE_STATE_ANY | ARCHIVE_STATE_FATAL, \"archive_write_disk_free\");\n\ta = (struct archive_write_disk *)_a;\n\tret = _archive_write_disk_close(&a->archive);\n\tarchive_write_disk_set_group_lookup(&a->archive, NULL, NULL, NULL);\n\tarchive_write_disk_set_user_lookup(&a->archive, NULL, NULL, NULL);\n\tarchive_entry_free(a->entry);\n\tarchive_string_free(&a->_name_data);\n\tarchive_string_free(&a->_tmpname_data);\n\tarchive_string_free(&a->archive.error_string);\n\tarchive_string_free(&a->path_safe);\n\ta->archive.magic = 0;\n\t__archive_clean(&a->archive);\n\tfree(a->decmpfs_header_p);\n\tfree(a->resource_fork);\n\tfree(a->compressed_buffer);\n\tfree(a->uncompressed_buffer);\n#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\\\n\t&& defined(HAVE_ZLIB_H)\n\tif (a->stream_valid) {\n\t\tswitch (deflateEnd(&a->stream)) {\n\t\tcase Z_OK:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t\t    \"Failed to clean up compressor\");\n\t\t\tret = ARCHIVE_FATAL;\n\t\t\tbreak;\n\t\t}\n\t}\n#endif\n\tfree(a);\n\treturn (ret);\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":227003,"func":"IRC_PROTOCOL_CALLBACK(kill)\n{\n    char *pos_comment;\n    struct t_irc_channel *ptr_channel;\n    struct t_irc_nick *ptr_nick, *ptr_nick_killed;\n\n    IRC_PROTOCOL_MIN_ARGS(3);\n    IRC_PROTOCOL_CHECK_HOST;\n\n    pos_comment = (argc > 3) ?\n        ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;\n\n    for (ptr_channel = server->channels; ptr_channel;\n         ptr_channel = ptr_channel->next_channel)\n    {\n        ptr_nick = irc_nick_search (server, ptr_channel, nick);\n        ptr_nick_killed = irc_nick_search (server, ptr_channel, argv[2]);\n\n        if (pos_comment)\n        {\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,\n                                                 ptr_channel->buffer),\n                date,\n                irc_protocol_tags (command, NULL, NULL, address),\n                _(\"%s%sYou were killed by %s%s%s %s(%s%s%s)\"),\n                weechat_prefix (\"quit\"),\n                IRC_COLOR_MESSAGE_KICK,\n                irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n                nick,\n                IRC_COLOR_MESSAGE_KICK,\n                IRC_COLOR_CHAT_DELIMITERS,\n                IRC_COLOR_REASON_KICK,\n                pos_comment,\n                IRC_COLOR_CHAT_DELIMITERS);\n        }\n        else\n        {\n            weechat_printf_date_tags (\n                irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,\n                                                 ptr_channel->buffer),\n                date,\n                irc_protocol_tags (command, NULL, NULL, address),\n                _(\"%s%sYou were killed by %s%s%s\"),\n                weechat_prefix (\"quit\"),\n                IRC_COLOR_MESSAGE_KICK,\n                irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n                nick,\n                IRC_COLOR_MESSAGE_KICK);\n        }\n\n        if (irc_server_strcasecmp (server, argv[2], server->nick) == 0)\n        {\n            \/*\n             * my nick was killed => free all nicks, channel is not active any\n             * more\n             *\/\n            irc_nick_free_all (server, ptr_channel);\n\n            irc_channel_modelist_set_state (ptr_channel,\n                                            IRC_MODELIST_STATE_MODIFIED);\n\n            irc_bar_item_update_channel ();\n        }\n        else\n        {\n            \/*\n             * someone was killed on channel (but not me) => remove only this\n             * nick\n             *\/\n            if (ptr_nick_killed)\n                irc_nick_free (server, ptr_channel, ptr_nick_killed);\n        }\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":492675,"func":"vte_sequence_handler_dc (VteTerminal *terminal, GValueArray *params)\n{\n\tVteScreen *screen;\n\tVteRowData *rowdata;\n\tlong col;\n\n\tscreen = terminal->pvt->screen;\n\n\tif (_vte_ring_next(screen->row_data) > screen->cursor_current.row) {\n\t\tlong len;\n\t\t\/* Get the data for the row which the cursor points to. *\/\n\t\trowdata = _vte_ring_index_writable (screen->row_data, screen->cursor_current.row);\n\t\tg_assert(rowdata != NULL);\n\t\tcol = screen->cursor_current.col;\n\t\tlen = _vte_row_data_length (rowdata);\n\t\t\/* Remove the column. *\/\n\t\tif (col < len) {\n\t\t\t_vte_row_data_remove (rowdata, col);\n\t\t\tif (screen->fill_defaults.attr.back != VTE_DEF_BG) {\n\t\t\t\t_vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count);\n\t\t\t\tlen = terminal->column_count;\n\t\t\t}\n\t\t\t\/* Repaint this row. *\/\n\t\t\t_vte_invalidate_cells(terminal,\n\t\t\t\t\tcol, len - col,\n\t\t\t\t\tscreen->cursor_current.row, 1);\n\t\t}\n\t}\n\n\t\/* We've modified the display.  Make a note of it. *\/\n\tterminal->pvt->text_deleted_flag = TRUE;\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":240294,"func":"get_reg_contents(int regname, int flags)\n{\n    long\ti;\n    char_u\t*retval;\n    int\t\tallocated;\n    long\tlen;\n\n    \/\/ Don't allow using an expression register inside an expression\n    if (regname == '=')\n    {\n\tif (flags & GREG_NO_EXPR)\n\t    return NULL;\n\tif (flags & GREG_EXPR_SRC)\n\t    return getreg_wrap_one_line(get_expr_line_src(), flags);\n\treturn getreg_wrap_one_line(get_expr_line(), flags);\n    }\n\n    if (regname == '@')\t    \/\/ \"@@\" is used for unnamed register\n\tregname = '\"';\n\n    \/\/ check for valid regname\n    if (regname != NUL && !valid_yank_reg(regname, FALSE))\n\treturn NULL;\n\n# ifdef FEAT_CLIPBOARD\n    regname = may_get_selection(regname);\n# endif\n\n    if (get_spec_reg(regname, &retval, &allocated, FALSE))\n    {\n\tif (retval == NULL)\n\t    return NULL;\n\tif (allocated)\n\t    return getreg_wrap_one_line(retval, flags);\n\treturn getreg_wrap_one_line(vim_strsave(retval), flags);\n    }\n\n    get_yank_register(regname, FALSE);\n    if (y_current->y_array == NULL)\n\treturn NULL;\n\n    if (flags & GREG_LIST)\n    {\n\tlist_T\t*list = list_alloc();\n\tint\terror = FALSE;\n\n\tif (list == NULL)\n\t    return NULL;\n\tfor (i = 0; i < y_current->y_size; ++i)\n\t    if (list_append_string(list, y_current->y_array[i], -1) == FAIL)\n\t\terror = TRUE;\n\tif (error)\n\t{\n\t    list_free(list);\n\t    return NULL;\n\t}\n\treturn (char_u *)list;\n    }\n\n    \/\/ Compute length of resulting string.\n    len = 0;\n    for (i = 0; i < y_current->y_size; ++i)\n    {\n\tlen += (long)STRLEN(y_current->y_array[i]);\n\t\/\/ Insert a newline between lines and after last line if\n\t\/\/ y_type is MLINE.\n\tif (y_current->y_type == MLINE || i < y_current->y_size - 1)\n\t    ++len;\n    }\n\n    retval = alloc(len + 1);\n\n    \/\/ Copy the lines of the yank register into the string.\n    if (retval != NULL)\n    {\n\tlen = 0;\n\tfor (i = 0; i < y_current->y_size; ++i)\n\t{\n\t    STRCPY(retval + len, y_current->y_array[i]);\n\t    len += (long)STRLEN(retval + len);\n\n\t    \/\/ Insert a NL between lines and after the last line if y_type is\n\t    \/\/ MLINE.\n\t    if (y_current->y_type == MLINE || i < y_current->y_size - 1)\n\t\tretval[len++] = '\\n';\n\t}\n\tretval[len] = NUL;\n    }\n\n    return retval;\n}","target":0,"code_token_length":618,"total_token_length":854,"max_tokens_setting":1024}
+{"idx":247749,"func":"TEST_P(SslSocketTest, NoCertUntrustedPermitted) {\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/fake_ca_cert.pem\"\n      trust_chain_verification: ACCEPT_UNTRUSTED\n      verify_certificate_hash: \"0000000000000000000000000000000000000000000000000000000000000000\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.no_certificate\")\n               .setExpectNoCert()\n               .setExpectNoCertChain());\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":512338,"func":"void Item_func_nullif::print(String *str, enum_query_type query_type)\n{\n  \/*\n    NULLIF(a,b) is implemented according to the SQL standard as a short for\n    CASE WHEN a=b THEN NULL ELSE a END\n\n    The constructor of Item_func_nullif sets args[0] and args[2] to the\n    same item \"a\", and sets args[1] to \"b\".\n\n    If \"this\" is a part of a WHERE or ON condition, then:\n    - the left \"a\" is a subject to equal field propagation with ANY_SUBST.\n    - the right \"a\" is a subject to equal field propagation with IDENTITY_SUBST.\n    Therefore, after equal field propagation args[0] and args[2] can point\n    to different items.\n  *\/\n  if ((query_type & QT_ITEM_ORIGINAL_FUNC_NULLIF) ||\n      (arg_count == 2) ||\n      (args[0] == args[2]))\n  {\n    \/*\n      If QT_ITEM_ORIGINAL_FUNC_NULLIF is requested,\n      that means we want the original NULLIF() representation,\n      e.g. when we are in:\n        SHOW CREATE {VIEW|FUNCTION|PROCEDURE}\n\n      The original representation is possible only if\n      args[0] and args[2] still point to the same Item.\n\n      The caller must never pass call print() with QT_ITEM_ORIGINAL_FUNC_NULLIF\n      if an expression has undergone some optimization\n      (e.g. equal field propagation done in optimize_cond()) already and\n      NULLIF() potentially has two different representations of \"a\":\n      - one \"a\" for comparison\n      - another \"a\" for the returned value!\n    *\/\n    DBUG_ASSERT(arg_count == 2 ||\n                args[0] == args[2] || current_thd->lex->context_analysis_only);\n    str->append(func_name());\n    str->append('(');\n    if (arg_count == 2)\n      args[0]->print(str, query_type);\n    else\n      args[2]->print(str, query_type);\n    str->append(',');\n    args[1]->print(str, query_type);\n    str->append(')');\n  }\n  else\n  {\n    \/*\n      args[0] and args[2] are different items.\n      This is possible after WHERE optimization (equal fields propagation etc),\n      e.g. in EXPLAIN EXTENDED or EXPLAIN FORMAT=JSON.\n      As it's not possible to print as a function with 2 arguments any more,\n      do it in the CASE style.\n    *\/\n    str->append(STRING_WITH_LEN(\"(case when \"));\n    args[0]->print(str, query_type);\n    str->append(STRING_WITH_LEN(\" = \"));\n    args[1]->print(str, query_type);\n    str->append(STRING_WITH_LEN(\" then NULL else \"));\n    args[2]->print(str, query_type);\n    str->append(STRING_WITH_LEN(\" end)\"));\n  }\n}","target":0,"code_token_length":619,"total_token_length":855,"max_tokens_setting":1024}
+{"idx":413845,"func":"Method* LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_info,\n                                                           TRAPS) {\n  \/\/ normal method resolution\n  Method* resolved_method = resolve_method(link_info, Bytecodes::_invokevirtual, CHECK_NULL);\n\n  assert(resolved_method->name() != vmSymbols::object_initializer_name(), \"should have been checked in verifier\");\n  assert(resolved_method->name() != vmSymbols::class_initializer_name (), \"should have been checked in verifier\");\n\n  \/\/ check if private interface method\n  Klass* resolved_klass = link_info.resolved_klass();\n  Klass* current_klass = link_info.current_klass();\n\n  \/\/ This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method\n  if (resolved_klass->is_interface() && resolved_method->is_private()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"private interface method requires invokespecial, not invokevirtual: method '\");\n    resolved_method->print_external_name(&ss);\n    ss.print(\"', caller-class: %s\",\n             (current_klass == NULL ? \"<null>\" : current_klass->internal_name()));\n    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n\n  \/\/ check if not static\n  if (resolved_method->is_static()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"Expecting non-static method '\");\n    resolved_method->print_external_name(&ss);\n    ss.print(\"'\");\n    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n\n  if (log_develop_is_enabled(Trace, vtables)) {\n    trace_method_resolution(\"invokevirtual resolved method: caller-class:\",\n                            current_klass, resolved_klass, resolved_method, false);\n  }\n\n  return resolved_method;\n}","target":0,"code_token_length":390,"total_token_length":626,"max_tokens_setting":1024}
+{"idx":220106,"func":"static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off,\n\t\tstruct file *dst_file, loff_t dst_off, loff_t count,\n\t\tunsigned int remap_flags)\n{\n\tstruct inode *dst_inode = file_inode(dst_file);\n\tstruct nfs_server *server = NFS_SERVER(dst_inode);\n\tstruct inode *src_inode = file_inode(src_file);\n\tunsigned int bs = server->clone_blksize;\n\tbool same_inode = false;\n\tint ret;\n\n\t\/* NFS does not support deduplication. *\/\n\tif (remap_flags & REMAP_FILE_DEDUP)\n\t\treturn -EOPNOTSUPP;\n\n\tif (remap_flags & ~REMAP_FILE_ADVISORY)\n\t\treturn -EINVAL;\n\n\tif (IS_SWAPFILE(dst_inode) || IS_SWAPFILE(src_inode))\n\t\treturn -ETXTBSY;\n\n\t\/* check alignment w.r.t. clone_blksize *\/\n\tret = -EINVAL;\n\tif (bs) {\n\t\tif (!IS_ALIGNED(src_off, bs) || !IS_ALIGNED(dst_off, bs))\n\t\t\tgoto out;\n\t\tif (!IS_ALIGNED(count, bs) && i_size_read(src_inode) != (src_off + count))\n\t\t\tgoto out;\n\t}\n\n\tif (src_inode == dst_inode)\n\t\tsame_inode = true;\n\n\t\/* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? *\/\n\tif (same_inode) {\n\t\tinode_lock(src_inode);\n\t} else if (dst_inode < src_inode) {\n\t\tinode_lock_nested(dst_inode, I_MUTEX_PARENT);\n\t\tinode_lock_nested(src_inode, I_MUTEX_CHILD);\n\t} else {\n\t\tinode_lock_nested(src_inode, I_MUTEX_PARENT);\n\t\tinode_lock_nested(dst_inode, I_MUTEX_CHILD);\n\t}\n\n\t\/* flush all pending writes on both src and dst so that server\n\t * has the latest data *\/\n\tret = nfs_sync_inode(src_inode);\n\tif (ret)\n\t\tgoto out_unlock;\n\tret = nfs_sync_inode(dst_inode);\n\tif (ret)\n\t\tgoto out_unlock;\n\n\tret = nfs42_proc_clone(src_file, dst_file, src_off, dst_off, count);\n\n\t\/* truncate inode page cache of the dst range so that future reads can fetch\n\t * new data from server *\/\n\tif (!ret)\n\t\ttruncate_inode_pages_range(&dst_inode->i_data, dst_off, dst_off + count - 1);\n\nout_unlock:\n\tif (same_inode) {\n\t\tinode_unlock(src_inode);\n\t} else if (dst_inode < src_inode) {\n\t\tinode_unlock(src_inode);\n\t\tinode_unlock(dst_inode);\n\t} else {\n\t\tinode_unlock(dst_inode);\n\t\tinode_unlock(src_inode);\n\t}\nout:\n\treturn ret < 0 ? ret : count;\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":294505,"func":"datetime_s_now(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vsg, nth, ret;\n    double sg;\n#ifdef HAVE_CLOCK_GETTIME\n    struct timespec ts;\n#else\n    struct timeval tv;\n#endif\n    time_t sec;\n    struct tm tm;\n    long sf, of;\n    int y, ry, m, d, h, min, s;\n\n    rb_scan_args(argc, argv, \"01\", &vsg);\n\n    if (argc < 1)\n\tsg = DEFAULT_SG;\n    else\n\tsg = NUM2DBL(vsg);\n\n#ifdef HAVE_CLOCK_GETTIME\n    if (clock_gettime(CLOCK_REALTIME, &ts) == -1)\n\trb_sys_fail(\"clock_gettime\");\n    sec = ts.tv_sec;\n#else\n    if (gettimeofday(&tv, NULL) == -1)\n\trb_sys_fail(\"gettimeofday\");\n    sec = tv.tv_sec;\n#endif\n    tzset();\n    if (!localtime_r(&sec, &tm))\n\trb_sys_fail(\"localtime\");\n\n    y = tm.tm_year + 1900;\n    m = tm.tm_mon + 1;\n    d = tm.tm_mday;\n    h = tm.tm_hour;\n    min = tm.tm_min;\n    s = tm.tm_sec;\n    if (s == 60)\n\ts = 59;\n#ifdef HAVE_STRUCT_TM_TM_GMTOFF\n    of = tm.tm_gmtoff;\n#elif defined(HAVE_TIMEZONE)\n#if defined(HAVE_ALTZONE) && !defined(_AIX)\n    of = (long)-((tm.tm_isdst > 0) ? altzone : timezone);\n#else\n    of = (long)-timezone;\n    if (tm.tm_isdst) {\n\ttime_t sec2;\n\n\ttm.tm_isdst = 0;\n\tsec2 = mktime(&tm);\n\tof += (long)difftime(sec2, sec);\n    }\n#endif\n#elif defined(HAVE_TIMEGM)\n    {\n\ttime_t sec2;\n\n\tsec2 = timegm(&tm);\n\tof = (long)difftime(sec2, sec);\n    }\n#else\n    {\n\tstruct tm tm2;\n\ttime_t sec2;\n\n\tif (!gmtime_r(&sec, &tm2))\n\t    rb_sys_fail(\"gmtime\");\n\ttm2.tm_isdst = tm.tm_isdst;\n\tsec2 = mktime(&tm2);\n\tof = (long)difftime(sec, sec2);\n    }\n#endif\n#ifdef HAVE_CLOCK_GETTIME\n    sf = ts.tv_nsec;\n#else\n    sf = tv.tv_usec * 1000;\n#endif\n\n    if (of < -DAY_IN_SECONDS || of > DAY_IN_SECONDS) {\n\tof = 0;\n\trb_warning(\"invalid offset is ignored\");\n    }\n\n    decode_year(INT2FIX(y), -1, &nth, &ry);\n\n    ret = d_complex_new_internal(klass,\n\t\t\t\t nth, 0,\n\t\t\t\t 0, LONG2NUM(sf),\n\t\t\t\t (int)of, GREGORIAN,\n\t\t\t\t ry, m, d,\n\t\t\t\t h, min, s,\n\t\t\t\t HAVE_CIVIL | HAVE_TIME);\n    {\n\tget_d1(ret);\n\tset_sg(dat, sg);\n    }\n    return ret;\n}","target":0,"code_token_length":666,"total_token_length":902,"max_tokens_setting":1024}
+{"idx":477811,"func":"int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)\n{\n\tstruct rtas_token_definition *d;\n\tstruct rtas_args args;\n\trtas_arg_t *orig_rets;\n\tgpa_t args_phys;\n\tint rc;\n\n\t\/*\n\t * r4 contains the guest physical address of the RTAS args\n\t * Mask off the top 4 bits since this is a guest real address\n\t *\/\n\targs_phys = kvmppc_get_gpr(vcpu, 4) & KVM_PAM;\n\n\tvcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);\n\trc = kvm_read_guest(vcpu->kvm, args_phys, &args, sizeof(args));\n\tsrcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);\n\tif (rc)\n\t\tgoto fail;\n\n\t\/*\n\t * args->rets is a pointer into args->args. Now that we've\n\t * copied args we need to fix it up to point into our copy,\n\t * not the guest args. We also need to save the original\n\t * value so we can restore it on the way out.\n\t *\/\n\torig_rets = args.rets;\n\tif (be32_to_cpu(args.nargs) >= ARRAY_SIZE(args.args)) {\n\t\t\/*\n\t\t * Don't overflow our args array: ensure there is room for\n\t\t * at least rets[0] (even if the call specifies 0 nret).\n\t\t *\n\t\t * Each handler must then check for the correct nargs and nret\n\t\t * values, but they may always return failure in rets[0].\n\t\t *\/\n\t\trc = -EINVAL;\n\t\tgoto fail;\n\t}\n\targs.rets = &args.args[be32_to_cpu(args.nargs)];\n\n\tmutex_lock(&vcpu->kvm->arch.rtas_token_lock);\n\n\trc = -ENOENT;\n\tlist_for_each_entry(d, &vcpu->kvm->arch.rtas_tokens, list) {\n\t\tif (d->token == be32_to_cpu(args.token)) {\n\t\t\td->handler->handler(vcpu, &args);\n\t\t\trc = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tmutex_unlock(&vcpu->kvm->arch.rtas_token_lock);\n\n\tif (rc == 0) {\n\t\targs.rets = orig_rets;\n\t\trc = kvm_write_guest(vcpu->kvm, args_phys, &args, sizeof(args));\n\t\tif (rc)\n\t\t\tgoto fail;\n\t}\n\n\treturn rc;\n\nfail:\n\t\/*\n\t * We only get here if the guest has called RTAS with a bogus\n\t * args pointer or nargs\/nret values that would overflow the\n\t * array. That means we can't get to the args, and so we can't\n\t * fail the RTAS call. So fail right out to userspace, which\n\t * should kill the guest.\n\t *\n\t * SLOF should actually pass the hcall return value from the\n\t * rtas handler call in r3, so enter_rtas could be modified to\n\t * return a failure indication in r3 and we could return such\n\t * errors to the guest rather than failing to host userspace.\n\t * However old guests that don't test for failure could then\n\t * continue silently after errors, so for now we won't do this.\n\t *\/\n\treturn rc;\n}","target":0,"code_token_length":704,"total_token_length":940,"max_tokens_setting":1024}
+{"idx":489213,"func":"int hfsplus_rename_cat(u32 cnid,\n\t\t       struct inode *src_dir, struct qstr *src_name,\n\t\t       struct inode *dst_dir, struct qstr *dst_name)\n{\n\tstruct super_block *sb;\n\tstruct hfs_find_data src_fd, dst_fd;\n\thfsplus_cat_entry entry;\n\tint entry_size, type;\n\tint err = 0;\n\n\tdprint(DBG_CAT_MOD, \"rename_cat: %u - %lu,%s - %lu,%s\\n\", cnid, src_dir->i_ino, src_name->name,\n\t\tdst_dir->i_ino, dst_name->name);\n\tsb = src_dir->i_sb;\n\thfs_find_init(HFSPLUS_SB(sb).cat_tree, &src_fd);\n\tdst_fd = src_fd;\n\n\t\/* find the old dir entry and read the data *\/\n\thfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);\n\terr = hfs_brec_find(&src_fd);\n\tif (err)\n\t\tgoto out;\n\n\thfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,\n\t\t\t\tsrc_fd.entrylength);\n\n\t\/* create new dir entry with the data from the old entry *\/\n\thfsplus_cat_build_key(sb, dst_fd.search_key, dst_dir->i_ino, dst_name);\n\terr = hfs_brec_find(&dst_fd);\n\tif (err != -ENOENT) {\n\t\tif (!err)\n\t\t\terr = -EEXIST;\n\t\tgoto out;\n\t}\n\n\terr = hfs_brec_insert(&dst_fd, &entry, src_fd.entrylength);\n\tif (err)\n\t\tgoto out;\n\tdst_dir->i_size++;\n\tdst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME_SEC;\n\tmark_inode_dirty(dst_dir);\n\n\t\/* finally remove the old entry *\/\n\thfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);\n\terr = hfs_brec_find(&src_fd);\n\tif (err)\n\t\tgoto out;\n\terr = hfs_brec_remove(&src_fd);\n\tif (err)\n\t\tgoto out;\n\tsrc_dir->i_size--;\n\tsrc_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME_SEC;\n\tmark_inode_dirty(src_dir);\n\n\t\/* remove old thread entry *\/\n\thfsplus_cat_build_key(sb, src_fd.search_key, cnid, NULL);\n\terr = hfs_brec_find(&src_fd);\n\tif (err)\n\t\tgoto out;\n\ttype = hfs_bnode_read_u16(src_fd.bnode, src_fd.entryoffset);\n\terr = hfs_brec_remove(&src_fd);\n\tif (err)\n\t\tgoto out;\n\n\t\/* create new thread entry *\/\n\thfsplus_cat_build_key(sb, dst_fd.search_key, cnid, NULL);\n\tentry_size = hfsplus_fill_cat_thread(sb, &entry, type, dst_dir->i_ino, dst_name);\n\terr = hfs_brec_find(&dst_fd);\n\tif (err != -ENOENT) {\n\t\tif (!err)\n\t\t\terr = -EEXIST;\n\t\tgoto out;\n\t}\n\terr = hfs_brec_insert(&dst_fd, &entry, entry_size);\nout:\n\thfs_bnode_put(dst_fd.bnode);\n\thfs_find_exit(&src_fd);\n\treturn err;\n}","target":0,"code_token_length":682,"total_token_length":918,"max_tokens_setting":1024}
+{"idx":453016,"func":"static int nft_immediate_init(const struct nft_ctx *ctx,\n\t\t\t      const struct nft_expr *expr,\n\t\t\t      const struct nlattr * const tb[])\n{\n\tstruct nft_immediate_expr *priv = nft_expr_priv(expr);\n\tstruct nft_data_desc desc;\n\tint err;\n\n\tif (tb[NFTA_IMMEDIATE_DREG] == NULL ||\n\t    tb[NFTA_IMMEDIATE_DATA] == NULL)\n\t\treturn -EINVAL;\n\n\terr = nft_data_init(ctx, &priv->data, sizeof(priv->data), &desc,\n\t\t\t    tb[NFTA_IMMEDIATE_DATA]);\n\tif (err < 0)\n\t\treturn err;\n\n\tpriv->dlen = desc.len;\n\n\terr = nft_parse_register_store(ctx, tb[NFTA_IMMEDIATE_DREG],\n\t\t\t\t       &priv->dreg, &priv->data, desc.type,\n\t\t\t\t       desc.len);\n\tif (err < 0)\n\t\tgoto err1;\n\n\tif (priv->dreg == NFT_REG_VERDICT) {\n\t\tstruct nft_chain *chain = priv->data.verdict.chain;\n\n\t\tswitch (priv->data.verdict.code) {\n\t\tcase NFT_JUMP:\n\t\tcase NFT_GOTO:\n\t\t\tif (nft_chain_is_bound(chain)) {\n\t\t\t\terr = -EBUSY;\n\t\t\t\tgoto err1;\n\t\t\t}\n\t\t\tchain->bound = true;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n\nerr1:\n\tnft_data_release(&priv->data, desc.type);\n\treturn err;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":221634,"func":"bool isKnownBroadcastable(ShapeComponentAnalysis& analysis,\n                          ValueRange bcasted_shapes, Value output_shape) {\n  auto output_shape_dims = analysis.GetValueInfo(output_shape);\n  if (!output_shape_dims) return false;\n  for (Value shape : bcasted_shapes) {\n    auto shape_dims = analysis.GetValueInfo(shape);\n    if (!shape_dims) return false;\n    \/\/ Iterate backwards over the smallest input shape.\n    for (auto zip : llvm::zip(llvm::reverse(*output_shape_dims),\n                              llvm::reverse(*shape_dims))) {\n      const auto& first = std::get<0>(zip);\n      const auto& second = std::get<1>(zip);\n      \/\/ TODO(ezhulenev): What to do with dimensions statically known to be\n      \/\/ zero?\n      \/\/ Numpy can only broadcast [0] with [1], however Tensorflow can broadcast\n      \/\/ [0] with any dimension size, and produces dimension of size [0].\n      \/\/ Currently we'll conservatively return failure and will not proceed with\n      \/\/ a rewrite.\n      if (first.isConstant(0) || second.isConstant(0)) return false;\n      \/\/ If either shape has a static one dimension the broadcast will always\n      \/\/ succeed.\n      if (first.isConstant(1) || second.isConstant(1)) continue;\n      \/\/ Otherwise dims have to be equal.\n      if (first != second) return false;\n    }\n  }\n  return true;\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":220163,"func":"void DecodeImageV2Op::DecodeBMP(const uint8* input, const int row_size,\n                                uint8* const output, const int width,\n                                const int height, const int output_channels,\n                                const int input_channels, bool top_down) {\n  for (int i = 0; i < height; i++) {\n    int src_pos;\n    int dst_pos;\n\n    for (int j = 0; j < width; j++) {\n      if (!top_down) {\n        src_pos = ((height - 1 - i) * row_size) + j * input_channels;\n      } else {\n        src_pos = i * row_size + j * input_channels;\n      }\n\n      dst_pos = (i * width + j) * output_channels;\n\n      switch (input_channels) {\n        case 1:\n          output[dst_pos] = input[src_pos];\n          \/\/ Set 2nd and 3rd channels if user requested for 3 or 4 channels.\n          \/\/ Repeat 1st channel's value.\n          if (output_channels == 3 || output_channels == 4) {\n            output[dst_pos + 1] = input[src_pos];\n            output[dst_pos + 2] = input[src_pos];\n          }\n          \/\/ Set 4th channel (alpha) to maximum value if user requested for\n          \/\/ 4 channels.\n          if (output_channels == 4) {\n            output[dst_pos + 3] = UINT8_MAX;\n          }\n          break;\n        case 3:\n          \/\/ BGR -> RGB\n          output[dst_pos] = input[src_pos + 2];\n          output[dst_pos + 1] = input[src_pos + 1];\n          output[dst_pos + 2] = input[src_pos];\n          \/\/ Set 4th channel (alpha) to maximum value if the user requested for\n          \/\/ 4 channels and the input image has 3 channels only.\n          if (output_channels == 4) {\n            output[dst_pos + 3] = UINT8_MAX;\n          }\n          break;\n        case 4:\n          \/\/ BGRA -> RGBA\n          output[dst_pos] = input[src_pos + 2];\n          output[dst_pos + 1] = input[src_pos + 1];\n          output[dst_pos + 2] = input[src_pos];\n          \/\/ Set 4th channel only if the user requested for 4 channels. If not,\n          \/\/ then user requested 3 channels; skip this step.\n          if (output_channels == 4) {\n            output[dst_pos + 3] = input[src_pos + 3];\n          }\n          break;\n        default:\n          LOG(FATAL) << \"Unexpected number of channels: \" << input_channels;\n          break;\n      }\n    }\n  }\n}","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":349257,"func":"int read_super_2(squashfs_operations **s_ops, void *s)\n{\n\t squashfs_super_block_3 *sBlk_3 = s;\n\n\tif(sBlk_3->s_magic != SQUASHFS_MAGIC || sBlk_3->s_major != 2 ||\n\t\t\t\t\t\t\tsBlk_3->s_minor > 1)\n\t\treturn -1;\n\n\tsBlk.s.s_magic = sBlk_3->s_magic;\n\tsBlk.s.inodes = sBlk_3->inodes;\n\tsBlk.s.mkfs_time = sBlk_3->mkfs_time;\n\tsBlk.s.block_size = sBlk_3->block_size;\n\tsBlk.s.fragments = sBlk_3->fragments;\n\tsBlk.s.block_log = sBlk_3->block_log;\n\tsBlk.s.flags = sBlk_3->flags;\n\tsBlk.s.s_major = sBlk_3->s_major;\n\tsBlk.s.s_minor = sBlk_3->s_minor;\n\tsBlk.s.root_inode = sBlk_3->root_inode;\n\tsBlk.s.bytes_used = sBlk_3->bytes_used_2;\n\tsBlk.s.inode_table_start = sBlk_3->inode_table_start;\n\tsBlk.s.directory_table_start = sBlk_3->directory_table_start_2;\n\tsBlk.s.fragment_table_start = sBlk_3->fragment_table_start_2;\n\tsBlk.s.inode_table_start = sBlk_3->inode_table_start_2;\n\tsBlk.no_uids = sBlk_3->no_uids;\n\tsBlk.no_guids = sBlk_3->no_guids;\n\tsBlk.uid_start = sBlk_3->uid_start_2;\n\tsBlk.guid_start = sBlk_3->guid_start_2;\n\tsBlk.s.xattr_id_table_start = SQUASHFS_INVALID_BLK;\n\n\t*s_ops = &ops;\n\n\t\/*\n\t * 2.x filesystems use gzip compression.\n\t *\/\n\tcomp = lookup_compressor(\"gzip\");\n\n\tif(sBlk_3->s_minor == 0)\n\t\tneeds_sorting = TRUE;\n\n\treturn TRUE;\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":508371,"func":"bool is_locked_view(THD *thd, TABLE_LIST *t)\n{\n  DBUG_ENTER(\"check_locked_view\");\n  \/*\n   Is this table a view and not a base table?\n   (it is work around to allow to open view with locked tables,\n   real fix will be made after definition cache will be made)\n\n   Since opening of view which was not explicitly locked by LOCK\n   TABLES breaks metadata locking protocol (potentially can lead\n   to deadlocks) it should be disallowed.\n  *\/\n  if (thd->mdl_context.is_lock_owner(MDL_key::TABLE,\n                                     t->db, t->table_name,\n                                     MDL_SHARED))\n  {\n    char path[FN_REFLEN + 1];\n    build_table_filename(path, sizeof(path) - 1,\n                         t->db, t->table_name, reg_ext, 0);\n    \/*\n      Note that we can't be 100% sure that it is a view since it's\n      possible that we either simply have not found unused TABLE\n      instance in THD::open_tables list or were unable to open table\n      during prelocking process (in this case in theory we still\n      should hold shared metadata lock on it).\n    *\/\n    if (dd_frm_is_view(thd, path))\n    {\n      \/*\n        If parent_l of the table_list is non null then a merge table\n        has this view as child table, which is not supported.\n      *\/\n      if (t->parent_l)\n      {\n        my_error(ER_WRONG_MRG_TABLE, MYF(0));\n        DBUG_RETURN(FALSE);\n      }\n\n      if (!tdc_open_view(thd, t, CHECK_METADATA_VERSION))\n      {\n        DBUG_ASSERT(t->view != 0);\n        DBUG_RETURN(TRUE); \/\/ VIEW\n      }\n    }\n  }\n\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":432692,"func":"static void ipa_functions(wmfAPI *API)\n{\n  wmf_magick_t\n    *ddata = 0;\n\n  wmfFunctionReference\n    *FR = (wmfFunctionReference *) API->function_reference;\n\n  \/*\n     IPA function reference links\n   *\/\n  FR->device_open = ipa_device_open;\n  FR->device_close = ipa_device_close;\n  FR->device_begin = ipa_device_begin;\n  FR->device_end = ipa_device_end;\n  FR->flood_interior = ipa_flood_interior;\n  FR->flood_exterior = ipa_flood_exterior;\n  FR->draw_pixel = ipa_draw_pixel;\n  FR->draw_pie = ipa_draw_pie;\n  FR->draw_chord = ipa_draw_chord;\n  FR->draw_arc = ipa_draw_arc;\n  FR->draw_ellipse = ipa_draw_ellipse;\n  FR->draw_line = ipa_draw_line;\n  FR->poly_line = ipa_poly_line;\n  FR->draw_polygon = ipa_draw_polygon;\n#if defined(MAGICKCORE_WMF_DELEGATE)\n  FR->draw_polypolygon = ipa_draw_polypolygon;\n#endif\n  FR->draw_rectangle = ipa_draw_rectangle;\n  FR->rop_draw = ipa_rop_draw;\n  FR->bmp_draw = ipa_bmp_draw;\n  FR->bmp_read = ipa_bmp_read;\n  FR->bmp_free = ipa_bmp_free;\n  FR->draw_text = ipa_draw_text;\n  FR->udata_init = ipa_udata_init;\n  FR->udata_copy = ipa_udata_copy;\n  FR->udata_set = ipa_udata_set;\n  FR->udata_free = ipa_udata_free;\n  FR->region_frame = ipa_region_frame;\n  FR->region_paint = ipa_region_paint;\n  FR->region_clip = ipa_region_clip;\n\n  \/*\n     Allocate device data structure\n   *\/\n  ddata = (wmf_magick_t *) wmf_malloc(API, sizeof(wmf_magick_t));\n  if (ERR(API))\n    return;\n\n  (void) ResetMagickMemory((void *) ddata, 0, sizeof(wmf_magick_t));\n  API->device_data = (void *) ddata;\n\n  \/*\n     Device data defaults\n   *\/\n  ddata->image = 0;\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":337826,"func":"bool sctp_verify_asconf(const struct sctp_association *asoc,\n\t\t\tstruct sctp_chunk *chunk, bool addr_param_needed,\n\t\t\tstruct sctp_paramhdr **errp)\n{\n\tstruct sctp_addip_chunk *addip;\n\tbool addr_param_seen = false;\n\tunion sctp_params param;\n\n\taddip = (struct sctp_addip_chunk *)chunk->chunk_hdr;\n\tsctp_walk_params(param, addip, addip_hdr.params) {\n\t\tsize_t length = ntohs(param.p->length);\n\n\t\t*errp = param.p;\n\t\tswitch (param.p->type) {\n\t\tcase SCTP_PARAM_ERR_CAUSE:\n\t\t\tbreak;\n\t\tcase SCTP_PARAM_IPV4_ADDRESS:\n\t\t\tif (length != sizeof(struct sctp_ipv4addr_param))\n\t\t\t\treturn false;\n\t\t\t\/* ensure there is only one addr param and it's in the\n\t\t\t * beginning of addip_hdr params, or we reject it.\n\t\t\t *\/\n\t\t\tif (param.v != addip->addip_hdr.params)\n\t\t\t\treturn false;\n\t\t\taddr_param_seen = true;\n\t\t\tbreak;\n\t\tcase SCTP_PARAM_IPV6_ADDRESS:\n\t\t\tif (length != sizeof(struct sctp_ipv6addr_param))\n\t\t\t\treturn false;\n\t\t\tif (param.v != addip->addip_hdr.params)\n\t\t\t\treturn false;\n\t\t\taddr_param_seen = true;\n\t\t\tbreak;\n\t\tcase SCTP_PARAM_ADD_IP:\n\t\tcase SCTP_PARAM_DEL_IP:\n\t\tcase SCTP_PARAM_SET_PRIMARY:\n\t\t\t\/* In ASCONF chunks, these need to be first. *\/\n\t\t\tif (addr_param_needed && !addr_param_seen)\n\t\t\t\treturn false;\n\t\t\tlength = ntohs(param.addip->param_hdr.length);\n\t\t\tif (length < sizeof(struct sctp_addip_param) +\n\t\t\t\t     sizeof(**errp))\n\t\t\t\treturn false;\n\t\t\tbreak;\n\t\tcase SCTP_PARAM_SUCCESS_REPORT:\n\t\tcase SCTP_PARAM_ADAPTATION_LAYER_IND:\n\t\t\tif (length != sizeof(struct sctp_addip_param))\n\t\t\t\treturn false;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t\/* This is unknown to us, reject! *\/\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t\/* Remaining sanity checks. *\/\n\tif (addr_param_needed && !addr_param_seen)\n\t\treturn false;\n\tif (!addr_param_needed && addr_param_seen)\n\t\treturn false;\n\tif (param.v != chunk->chunk_end)\n\t\treturn false;\n\n\treturn true;\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":293758,"func":"static void create_initterm_syms(RKext *kext, RList *ret, int type, ut64 *pointers) {\n\tint i = 0;\n\tint count = 0;\n\tfor (; pointers[i]; i++) {\n\t\tut64 func_vaddr = pointers[i];\n\t\tut64 text_start = kext->vaddr;\n\t\tut64 text_end = text_start + kext->text_range.size;\n\n\t\tif (text_start == text_end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (text_start > func_vaddr || func_vaddr >= text_end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\tif (!sym) {\n\t\t\tbreak;\n\t\t}\n\n\t\tsym->name = r_str_newf (\"%s.%s.%d\", kext_short_name (kext), (type == R_BIN_ENTRY_TYPE_INIT) ? \"init\" : \"fini\", count++);\n\t\tsym->vaddr = func_vaddr;\n\t\tsym->paddr = func_vaddr - kext->pa2va_exec;\n\t\tsym->size = 0;\n\t\tsym->forwarder = \"NONE\";\n\t\tsym->bind = \"GLOBAL\";\n\t\tsym->type = \"FUNC\";\n\n\t\tr_list_append (ret, sym);\n\t}\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":504607,"func":"static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc(\n                    TIFF* tif, uint64 offset, tmsize_t size, void** pdest)\n{\n#if SIZEOF_VOIDP == 8 || SIZEOF_SIZE_T == 8\n        tmsize_t threshold = INITIAL_THRESHOLD;\n#endif\n        tmsize_t already_read = 0;\n\n        assert( !isMapped(tif) );\n\n        if (!SeekOK(tif,offset))\n                return(TIFFReadDirEntryErrIo);\n\n        \/* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc *\/\n        \/* so as to avoid allocating too much memory in case the file is too *\/\n        \/* short. We could ask for the file size, but this might be *\/\n        \/* expensive with some I\/O layers (think of reading a gzipped file) *\/\n        \/* Restrict to 64 bit processes, so as to avoid reallocs() *\/\n        \/* on 32 bit processes where virtual memory is scarce.  *\/\n        while( already_read < size )\n        {\n            void* new_dest;\n            tmsize_t bytes_read;\n            tmsize_t to_read = size - already_read;\n#if SIZEOF_VOIDP == 8 || SIZEOF_SIZE_T == 8\n            if( to_read >= threshold && threshold < MAX_THRESHOLD )\n            {\n                to_read = threshold;\n                threshold *= THRESHOLD_MULTIPLIER;\n            }\n#endif\n\n            new_dest = (uint8*) _TIFFrealloc(\n                            *pdest, already_read + to_read);\n            if( new_dest == NULL )\n            {\n                TIFFErrorExt(tif->tif_clientdata, tif->tif_name,\n                            \"Failed to allocate memory for %s \"\n                            \"(%ld elements of %ld bytes each)\",\n                            \"TIFFReadDirEntryArray\",\n                             (long) 1, (long) already_read + to_read);\n                return TIFFReadDirEntryErrAlloc;\n            }\n            *pdest = new_dest;\n\n            bytes_read = TIFFReadFile(tif,\n                (char*)*pdest + already_read, to_read);\n            already_read += bytes_read;\n            if (bytes_read != to_read) {\n                return TIFFReadDirEntryErrIo;\n            }\n        }\n        return TIFFReadDirEntryErrOk;\n}","target":0,"code_token_length":490,"total_token_length":726,"max_tokens_setting":1024}
+{"idx":513324,"func":"AGGR_OP::end_send()\n{\n  enum_nested_loop_state rc= NESTED_LOOP_OK;\n  TABLE *table= join_tab->table;\n  JOIN *join= join_tab->join;\n\n  \/\/ All records were stored, send them further\n  int tmp, new_errno= 0;\n\n  if ((rc= put_record(true)) < NESTED_LOOP_OK)\n    return rc;\n\n  if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE)))\n  {\n    DBUG_PRINT(\"error\",(\"extra(HA_EXTRA_NO_CACHE) failed\"));\n    new_errno= tmp;\n  }\n  if ((tmp= table->file->ha_index_or_rnd_end()))\n  {\n    DBUG_PRINT(\"error\",(\"ha_index_or_rnd_end() failed\"));\n    new_errno= tmp;\n  }\n  if (new_errno)\n  {\n    table->file->print_error(new_errno,MYF(0));\n    return NESTED_LOOP_ERROR;\n  }\n\n  \/\/ Update ref array\n  join_tab->join->set_items_ref_array(*join_tab->ref_array);\n  bool keep_last_filesort_result = join_tab->filesort ? false : true;\n  if (join_tab->window_funcs_step)\n  {\n    if (join_tab->window_funcs_step->exec(join, keep_last_filesort_result))\n      return NESTED_LOOP_ERROR;\n  }\n\n  table->reginfo.lock_type= TL_UNLOCK;\n\n  bool in_first_read= true;\n\n  \/*\n     Reset the counter before copying rows from internal temporary table to\n     INSERT table.\n  *\/\n  join_tab->join->thd->get_stmt_da()->reset_current_row_for_warning();\n  while (rc == NESTED_LOOP_OK)\n  {\n    int error;\n    if (in_first_read)\n    {\n      in_first_read= false;\n      error= join_init_read_record(join_tab);\n    }\n    else\n      error= join_tab->read_record.read_record(&join_tab->read_record);\n\n    if (error > 0 || (join->thd->is_error()))   \/\/ Fatal error\n      rc= NESTED_LOOP_ERROR;\n    else if (error < 0)\n      break;\n    else if (join->thd->killed)\t\t  \/\/ Aborted by user\n    {\n      join->thd->send_kill_message();\n      rc= NESTED_LOOP_KILLED;\n    }\n    else\n    {\n      rc= evaluate_join_record(join, join_tab, 0);\n    }\n  }\n\n  if (keep_last_filesort_result)\n  {\n    delete join_tab->filesort_result;\n    join_tab->filesort_result= NULL;\n  }\n\n  \/\/ Finish rnd scn after sending records\n  if (join_tab->table->file->inited)\n    join_tab->table->file->ha_rnd_end();\n\n  return rc;\n}","target":0,"code_token_length":588,"total_token_length":824,"max_tokens_setting":1024}
+{"idx":232832,"func":"  void Compute(OpKernelContext* const context) override {\n    \/\/ Read float features list;\n    OpInputList float_features_list;\n    OP_REQUIRES_OK(\n        context, context->input_list(kFloatFeaturesName, &float_features_list));\n\n    \/\/ Parse example weights and get batch size.\n    const Tensor* example_weights_t;\n    OP_REQUIRES_OK(context,\n                   context->input(kExampleWeightsName, &example_weights_t));\n    DCHECK(float_features_list.size() > 0) << \"Got empty feature list\";\n    auto example_weights = example_weights_t->flat<float>();\n    const int64_t weight_size = example_weights.size();\n    const int64_t batch_size = float_features_list[0].flat<float>().size();\n    OP_REQUIRES(\n        context, weight_size == 1 || weight_size == batch_size,\n        errors::InvalidArgument(strings::Printf(\n            \"Weights should be a single value or same size as features.\")));\n    const Tensor* epsilon_t;\n    OP_REQUIRES_OK(context, context->input(kEpsilonName, &epsilon_t));\n    float epsilon = epsilon_t->scalar<float>()();\n\n    OpOutputList summaries_output_list;\n    OP_REQUIRES_OK(\n        context, context->output_list(kSummariesName, &summaries_output_list));\n\n    auto do_quantile_summary_gen = [&](const int64_t begin, const int64_t end) {\n      \/\/ Iterating features.\n      for (int64_t index = begin; index < end; index++) {\n        const auto feature_values = float_features_list[index].flat<float>();\n        QuantileStream stream(epsilon, batch_size + 1);\n        \/\/ Run quantile summary generation.\n        for (int64_t j = 0; j < batch_size; j++) {\n          stream.PushEntry(feature_values(j), (weight_size > 1)\n                                                  ? example_weights(j)\n                                                  : example_weights(0));\n        }\n        stream.Finalize();\n        const auto summary_entry_list = stream.GetFinalSummary().GetEntryList();\n        Tensor* output_t;\n        OP_REQUIRES_OK(\n            context,\n            summaries_output_list.allocate(\n                index,\n                TensorShape({static_cast<int64>(summary_entry_list.size()), 4}),\n                &output_t));\n        auto output = output_t->matrix<float>();\n        for (auto row = 0; row < summary_entry_list.size(); row++) {\n          const auto& entry = summary_entry_list[row];\n          output(row, 0) = entry.value;\n          output(row, 1) = entry.weight;\n          output(row, 2) = entry.min_rank;\n          output(row, 3) = entry.max_rank;\n        }\n      }\n    };\n    \/\/ TODO(tanzheny): comment on the magic number.\n    const int64_t kCostPerUnit = 500 * batch_size;\n    const DeviceBase::CpuWorkerThreads& worker_threads =\n        *context->device()->tensorflow_cpu_worker_threads();\n    Shard(worker_threads.num_threads, worker_threads.workers, num_features_,\n          kCostPerUnit, do_quantile_summary_gen);\n  }","target":0,"code_token_length":646,"total_token_length":882,"max_tokens_setting":1024}
+{"idx":281096,"func":"int xfrm_policy_register_afinfo(const struct xfrm_policy_afinfo *afinfo, int family)\n{\n\tint err = 0;\n\n\tif (WARN_ON(family >= ARRAY_SIZE(xfrm_policy_afinfo)))\n\t\treturn -EAFNOSUPPORT;\n\n\tspin_lock(&xfrm_policy_afinfo_lock);\n\tif (unlikely(xfrm_policy_afinfo[family] != NULL))\n\t\terr = -EEXIST;\n\telse {\n\t\tstruct dst_ops *dst_ops = afinfo->dst_ops;\n\t\tif (likely(dst_ops->kmem_cachep == NULL))\n\t\t\tdst_ops->kmem_cachep = xfrm_dst_cache;\n\t\tif (likely(dst_ops->check == NULL))\n\t\t\tdst_ops->check = xfrm_dst_check;\n\t\tif (likely(dst_ops->default_advmss == NULL))\n\t\t\tdst_ops->default_advmss = xfrm_default_advmss;\n\t\tif (likely(dst_ops->mtu == NULL))\n\t\t\tdst_ops->mtu = xfrm_mtu;\n\t\tif (likely(dst_ops->negative_advice == NULL))\n\t\t\tdst_ops->negative_advice = xfrm_negative_advice;\n\t\tif (likely(dst_ops->link_failure == NULL))\n\t\t\tdst_ops->link_failure = xfrm_link_failure;\n\t\tif (likely(dst_ops->neigh_lookup == NULL))\n\t\t\tdst_ops->neigh_lookup = xfrm_neigh_lookup;\n\t\tif (likely(!dst_ops->confirm_neigh))\n\t\t\tdst_ops->confirm_neigh = xfrm_confirm_neigh;\n\t\trcu_assign_pointer(xfrm_policy_afinfo[family], afinfo);\n\t}\n\tspin_unlock(&xfrm_policy_afinfo_lock);\n\n\treturn err;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":229167,"func":"static void virtser_port_device_realize(DeviceState *dev, Error **errp)\n{\n    VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev);\n    VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n    VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(dev));\n    int max_nr_ports;\n    bool plugging_port0;\n    Error *err = NULL;\n\n    port->vser = bus->vser;\n    port->bh = qemu_bh_new(flush_queued_data_bh, port);\n\n    assert(vsc->have_data);\n\n    \/*\n     * Is the first console port we're seeing? If so, put it up at\n     * location 0. This is done for backward compatibility (old\n     * kernel, new qemu).\n     *\/\n    plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0);\n\n    if (find_port_by_id(port->vser, port->id)) {\n        error_setg(errp, \"virtio-serial-bus: A port already exists at id %u\",\n                   port->id);\n        return;\n    }\n\n    if (port->name != NULL && find_port_by_name(port->name)) {\n        error_setg(errp, \"virtio-serial-bus: A port already exists by name %s\",\n                   port->name);\n        return;\n    }\n\n    if (port->id == VIRTIO_CONSOLE_BAD_ID) {\n        if (plugging_port0) {\n            port->id = 0;\n        } else {\n            port->id = find_free_port_id(port->vser);\n            if (port->id == VIRTIO_CONSOLE_BAD_ID) {\n                error_setg(errp, \"virtio-serial-bus: Maximum port limit for \"\n                                 \"this device reached\");\n                return;\n            }\n        }\n    }\n\n    max_nr_ports = port->vser->serial.max_virtserial_ports;\n    if (port->id >= max_nr_ports) {\n        error_setg(errp, \"virtio-serial-bus: Out-of-range port id specified, \"\n                         \"max. allowed: %u\", max_nr_ports - 1);\n        return;\n    }\n\n    vsc->realize(dev, &err);\n    if (err != NULL) {\n        error_propagate(errp, err);\n        return;\n    }\n\n    port->elem.out_num = 0;\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":318779,"func":"drill_parse_coordinate(gerb_file_t *fd, char firstchar,\n\t\t       gerbv_image_t *image, drill_state_t *state,\n\t\t       ssize_t file_line)\n{\n    int read;\n    gerbv_drill_stats_t *stats = image->drill_stats;\n\n    if(state->coordinate_mode == DRILL_MODE_ABSOLUTE) {\n\tif (firstchar == 'X') {\n\t    state->curr_x = read_double(fd, state->number_format, image->format->omit_zeros, state->decimals);\n\t    if ((read = (char)gerb_fgetc(fd)) == 'Y') {\n\t\tstate->curr_y = read_double(fd, state->number_format, image->format->omit_zeros, state->decimals);\n\t    } else {\n\t\tgerb_ungetc(fd);\n\t    }\n\t} else if (firstchar == 'Y') {\n\t    state->curr_y = read_double(fd, state->number_format, image->format->omit_zeros, state->decimals);\n\t}\n    } else if(state->coordinate_mode == DRILL_MODE_INCREMENTAL) {\n\tif (firstchar == 'X') {\n\t    state->curr_x += read_double(fd, state->number_format, image->format->omit_zeros, state->decimals);\n\t    if((read = (char)gerb_fgetc(fd)) == 'Y') {\n\t\tstate->curr_y += read_double(fd, state->number_format, image->format->omit_zeros, state->decimals);\n\t    } else {\n\t\tgerb_ungetc(fd);\n\t    }\n\t} else if (firstchar == 'Y') {\n\t    state->curr_y += read_double(fd, state->number_format, image->format->omit_zeros, state->decimals);\n\t}\n    } else {\n\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t_(\"Coordinate mode is not absolute and not incremental \"\n\t\t    \"at line %ld in file \\\"%s\\\"\"),\n\t\tfile_line, fd->filename);\n    }\n\n} \/* drill_parse_coordinate *\/","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":90191,"func":"  void UpdateNetworkStatus(const char* path,\n                           const char* key,\n                           const Value* value) {\n    if (key == NULL || value == NULL)\n      return;\n    if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {\n      BrowserThread::PostTask(\n          BrowserThread::UI, FROM_HERE,\n          NewRunnableMethod(this,\n                            &NetworkLibraryImpl::UpdateNetworkStatus,\n                            path, key, value));\n      return;\n    }\n\n    bool boolval = false;\n    int intval = 0;\n    std::string stringval;\n    Network* network;\n    if (ethernet_->service_path() == path) {\n      network = ethernet_;\n    } else {\n      CellularNetwork* cellular =\n          GetWirelessNetworkByPath(cellular_networks_, path);\n      WifiNetwork* wifi =\n          GetWirelessNetworkByPath(wifi_networks_, path);\n      if (cellular == NULL && wifi == NULL)\n        return;\n\n      WirelessNetwork* wireless;\n      if (wifi != NULL)\n        wireless = static_cast<WirelessNetwork*>(wifi);\n      else\n        wireless = static_cast<WirelessNetwork*>(cellular);\n\n      if (strcmp(key, kSignalStrengthProperty) == 0) {\n        if (value->GetAsInteger(&intval))\n          wireless->set_strength(intval);\n      } else if (cellular != NULL) {\n        if (strcmp(key, kRestrictedPoolProperty) == 0) {\n          if (value->GetAsBoolean(&boolval))\n            cellular->set_restricted_pool(boolval);\n        } else if (strcmp(key, kActivationStateProperty) == 0) {\n          if (value->GetAsString(&stringval))\n            cellular->set_activation_state(ParseActivationState(stringval));\n        } else if (strcmp(key, kPaymentURLProperty) == 0) {\n          if (value->GetAsString(&stringval))\n            cellular->set_payment_url(stringval);\n        } else if (strcmp(key, kNetworkTechnologyProperty) == 0) {\n          if (value->GetAsString(&stringval))\n            cellular->set_network_technology(\n                ParseNetworkTechnology(stringval));\n        } else if (strcmp(key, kRoamingStateProperty) == 0) {\n          if (value->GetAsString(&stringval))\n            cellular->set_roaming_state(ParseRoamingState(stringval));\n        }\n      }\n      network = wireless;\n    }\n    if (strcmp(key, kIsActiveProperty) == 0) {\n      if (value->GetAsBoolean(&boolval))\n        network->set_active(boolval);\n    } else if (strcmp(key, kStateProperty) == 0) {\n      if (value->GetAsString(&stringval))\n        network->set_state(ParseState(stringval));\n    }\n    NotifyNetworkChanged(network);\n  }\n","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":364781,"func":"do_tags(exarg_T *eap UNUSED)\n{\n    int\t\ti;\n    char_u\t*name;\n    taggy_T\t*tagstack = curwin->w_tagstack;\n    int\t\ttagstackidx = curwin->w_tagstackidx;\n    int\t\ttagstacklen = curwin->w_tagstacklen;\n\n    \/\/ Highlight title\n    msg_puts_title(_(\"\\n  # TO tag         FROM line  in file\/text\"));\n    for (i = 0; i < tagstacklen; ++i)\n    {\n\tif (tagstack[i].tagname != NULL)\n\t{\n\t    name = fm_getname(&(tagstack[i].fmark), 30);\n\t    if (name == NULL)\t    \/\/ file name not available\n\t\tcontinue;\n\n\t    msg_putchar('\\n');\n\t    vim_snprintf((char *)IObuff, IOSIZE, \"%c%2d %2d %-15s %5ld  \",\n\t\ti == tagstackidx ? '>' : ' ',\n\t\ti + 1,\n\t\ttagstack[i].cur_match + 1,\n\t\ttagstack[i].tagname,\n\t\ttagstack[i].fmark.mark.lnum);\n\t    msg_outtrans(IObuff);\n\t    msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum\n\t\t\t\t\t\t\t? HL_ATTR(HLF_D) : 0);\n\t    vim_free(name);\n\t}\n\tout_flush();\t\t    \/\/ show one line at a time\n    }\n    if (tagstackidx == tagstacklen)\t\/\/ idx at top of stack\n\tmsg_puts(\"\\n>\");\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":238568,"func":"static int is_branch64_taken(struct bpf_reg_state *reg, u64 val, u8 opcode)\n{\n\ts64 sval = (s64)val;\n\n\tswitch (opcode) {\n\tcase BPF_JEQ:\n\t\tif (tnum_is_const(reg->var_off))\n\t\t\treturn !!tnum_equals_const(reg->var_off, val);\n\t\tbreak;\n\tcase BPF_JNE:\n\t\tif (tnum_is_const(reg->var_off))\n\t\t\treturn !tnum_equals_const(reg->var_off, val);\n\t\tbreak;\n\tcase BPF_JSET:\n\t\tif ((~reg->var_off.mask & reg->var_off.value) & val)\n\t\t\treturn 1;\n\t\tif (!((reg->var_off.mask | reg->var_off.value) & val))\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JGT:\n\t\tif (reg->umin_value > val)\n\t\t\treturn 1;\n\t\telse if (reg->umax_value <= val)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JSGT:\n\t\tif (reg->smin_value > sval)\n\t\t\treturn 1;\n\t\telse if (reg->smax_value <= sval)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JLT:\n\t\tif (reg->umax_value < val)\n\t\t\treturn 1;\n\t\telse if (reg->umin_value >= val)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JSLT:\n\t\tif (reg->smax_value < sval)\n\t\t\treturn 1;\n\t\telse if (reg->smin_value >= sval)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JGE:\n\t\tif (reg->umin_value >= val)\n\t\t\treturn 1;\n\t\telse if (reg->umax_value < val)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JSGE:\n\t\tif (reg->smin_value >= sval)\n\t\t\treturn 1;\n\t\telse if (reg->smax_value < sval)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JLE:\n\t\tif (reg->umax_value <= val)\n\t\t\treturn 1;\n\t\telse if (reg->umin_value > val)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase BPF_JSLE:\n\t\tif (reg->smax_value <= sval)\n\t\t\treturn 1;\n\t\telse if (reg->smin_value > sval)\n\t\t\treturn 0;\n\t\tbreak;\n\t}\n\n\treturn -1;\n}","target":0,"code_token_length":519,"total_token_length":755,"max_tokens_setting":1024}
+{"idx":201353,"func":"static int rsi_init_usb_interface(struct rsi_hw *adapter,\n\t\t\t\t  struct usb_interface *pfunction)\n{\n\tstruct rsi_91x_usbdev *rsi_dev;\n\tint status;\n\n\trsi_dev = kzalloc(sizeof(*rsi_dev), GFP_KERNEL);\n\tif (!rsi_dev)\n\t\treturn -ENOMEM;\n\n\tadapter->rsi_dev = rsi_dev;\n\trsi_dev->usbdev = interface_to_usbdev(pfunction);\n\trsi_dev->priv = (void *)adapter;\n\n\tif (rsi_find_bulk_in_and_out_endpoints(pfunction, adapter)) {\n\t\tstatus = -EINVAL;\n\t\tgoto fail_eps;\n\t}\n\n\tadapter->device = &pfunction->dev;\n\tusb_set_intfdata(pfunction, adapter);\n\n\trsi_dev->tx_buffer = kmalloc(2048, GFP_KERNEL);\n\tif (!rsi_dev->tx_buffer) {\n\t\tstatus = -ENOMEM;\n\t\tgoto fail_eps;\n\t}\n\n\tif (rsi_usb_init_rx(adapter)) {\n\t\trsi_dbg(ERR_ZONE, \"Failed to init RX handle\\n\");\n\t\tstatus = -ENOMEM;\n\t\tgoto fail_rx;\n\t}\n\n\trsi_dev->tx_blk_size = 252;\n\tadapter->block_size = rsi_dev->tx_blk_size;\n\n\t\/* Initializing function callbacks *\/\n\tadapter->check_hw_queue_status = rsi_usb_check_queue_status;\n\tadapter->determine_event_timeout = rsi_usb_event_timeout;\n\tadapter->rsi_host_intf = RSI_HOST_INTF_USB;\n\tadapter->host_intf_ops = &usb_host_intf_ops;\n\n#ifdef CONFIG_RSI_DEBUGFS\n\t\/* In USB, one less than the MAX_DEBUGFS_ENTRIES entries is required *\/\n\tadapter->num_debugfs_entries = (MAX_DEBUGFS_ENTRIES - 1);\n#endif\n\n\trsi_dbg(INIT_ZONE, \"%s: Enabled the interface\\n\", __func__);\n\treturn 0;\n\nfail_rx:\n\tkfree(rsi_dev->tx_buffer);\n\nfail_eps:\n\tkfree(rsi_dev);\n\n\treturn status;\n}","target":1,"code_token_length":410,"total_token_length":646,"max_tokens_setting":1024}
+{"idx":246675,"func":"u32 parse_dash_profile(char *arg_val, u32 opt)\n{\n\tif (!stricmp(arg_val, \"live\") || !stricmp(arg_val, \"simple\")) dash_profile = GF_DASH_PROFILE_LIVE;\n\telse if (!stricmp(arg_val, \"onDemand\")) dash_profile = GF_DASH_PROFILE_ONDEMAND;\n\telse if (!stricmp(arg_val, \"hbbtv1.5:live\") || !stricmp(arg_val, \"hbbtv1.5.live\"))\n\t\tdash_profile = GF_DASH_PROFILE_HBBTV_1_5_ISOBMF_LIVE;\n\telse if (!stricmp(arg_val, \"dashavc264:live\") || !stricmp(arg_val, \"dashavc264.live\"))\n\t\tdash_profile = GF_DASH_PROFILE_AVC264_LIVE;\n\telse if (!stricmp(arg_val, \"dashavc264:onDemand\") || !stricmp(arg_val, \"dashavc264.onDemand\"))\n\t\tdash_profile = GF_DASH_PROFILE_AVC264_ONDEMAND;\n\telse if (!stricmp(arg_val, \"dashif.ll\")) dash_profile = GF_DASH_PROFILE_DASHIF_LL;\n\telse if (!stricmp(arg_val, \"main\")) dash_profile = GF_DASH_PROFILE_MAIN;\n\telse if (!stricmp(arg_val, \"full\")) dash_profile = GF_DASH_PROFILE_FULL;\n\telse {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Unrecognized DASH profile \\\"%s\\\" - please check usage\\n\", arg_val));\n\t\treturn 2;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":500060,"func":"kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session)\n        {\n\tint \t\tlength;\n\tkrb5_enctype\tenctype;\n\tkrb5_octet FAR\t*contents = NULL;\n\n\tif (!kssl_ctx)  return KSSL_CTX_ERR;\n\n\tif (kssl_ctx->key)\n                {\n\t\tOPENSSL_cleanse(kssl_ctx->key, kssl_ctx->length);\n\t\tkssl_free(kssl_ctx->key);\n\t\t}\n\n\tif (session)\n                {\n\n#ifdef KRB5_HEIMDAL\n\t\tlength = session->keyvalue->length;\n\t\tenctype = session->keytype;\n\t\tcontents = session->keyvalue->contents;\n#else\n\t\tlength = session->length;\n\t\tenctype = session->enctype;\n\t\tcontents = session->contents;\n#endif\n\t\tkssl_ctx->enctype = enctype;\n\t\tkssl_ctx->length  = length;\n\t\t}\n\telse\n                {\n\t\tkssl_ctx->enctype = ENCTYPE_UNKNOWN;\n\t\tkssl_ctx->length  = 0;\n\t\treturn KSSL_CTX_OK;\n\t\t}\n\n\tif ((kssl_ctx->key =\n                (krb5_octet FAR *) kssl_calloc(1, kssl_ctx->length)) == NULL)\n                {\n\t\tkssl_ctx->length  = 0;\n\t\treturn KSSL_CTX_ERR;\n\t\t}\n\telse\n\t\tmemcpy(kssl_ctx->key, contents, length);\n\n\treturn KSSL_CTX_OK;\n        }","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":220911,"func":"bool DependencyOptimizer::SafeToConvertToNoOp(const NodeDef& node) const {\n  if (HasRegularOutputs(node, *node_map_)) {\n    \/\/ The output values of this node may be needed.\n    VLOG(3) << \"Not safe to convert '\" << node.name()\n            << \" to NoOp. Node has outputs.\";\n    return false;\n  }\n  if (!fetch_nodes_known_) {\n    VLOG(3) << \"Not safe to convert '\" << node.name()\n            << \" to NoOp. Fetches unknown.\";\n    return false;\n  }\n  if (nodes_to_preserve_.find(node.name()) != nodes_to_preserve_.end()) {\n    VLOG(3) << \"Not safe to convert to NoOp: \" << node.name()\n            << \" is in preserve set.\";\n    return false;\n  }\n  if (IsMerge(node) || IsSwitch(node) || ModifiesFrameInfo(node)) {\n    VLOG(3) << \"Not safe to convert '\" << node.name()\n            << \" to NoOp. Node modifies frame info.\";\n    return false;\n  }\n  \/\/ Ops reading variables are marked as stateful, but are safe to remove if\n  \/\/ redundant.\n  static const absl::flat_hash_set<string>* gather_ops =\n      new absl::flat_hash_set<string>{\"Gather\", \"GatherV2\", \"GatherNd\",\n                                      \"ResourceGather\", \"ResourceGatherNd\"};\n  const bool is_variable_read =\n      IsReadVariableOp(node) || IsReadVariablesOp(node) ||\n      gather_ops->find(node.op()) != gather_ops->end();\n  if (!is_variable_read && !IsFreeOfSideEffect(node)) {\n    VLOG(3) << \"Not safe to convert '\" << node.name()\n            << \" to NoOp. Node has side effect.\";\n    return false;\n  }\n  if (node.op().rfind(\"Submodel\", 0) == 0) {\n    return false;\n  }\n  const OpDef* op_def = nullptr;\n  Status status = OpRegistry::Global()->LookUpOpDef(node.op(), &op_def);\n  if (!status.ok() || op_def->output_arg_size() == 0) {\n    return false;\n  }\n  const std::unordered_set<string> do_not_rewrite_ops{\n      \"Assert\",     \"CheckNumerics\",         \"_Retval\",\n      \"_Arg\",       \"_ParallelConcatUpdate\", \"TPUExecute\",\n      \"TPUCompile\", \"ControlTrigger\"};\n  if (do_not_rewrite_ops.find(node.op()) != do_not_rewrite_ops.end()) {\n    return false;\n  }\n  if (!SafeToRemoveIdentity(node)) {\n    return false;\n  }\n  return true;\n}","target":0,"code_token_length":567,"total_token_length":803,"max_tokens_setting":1024}
+{"idx":387817,"func":"void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {\n  \/\/ SystemDictionary::add_to_hierarchy() sets the init_state to loaded\n  \/\/ before the InstanceKlass is added to the SystemDictionary. Make\n  \/\/ sure the current state is <loaded.\n  assert(!is_loaded(), \"invalid init state\");\n  set_package(loader_data, CHECK);\n  Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);\n\n  Array<Method*>* methods = this->methods();\n  int num_methods = methods->length();\n  for (int index2 = 0; index2 < num_methods; ++index2) {\n    methodHandle m(THREAD, methods->at(index2));\n    m->restore_unshareable_info(CHECK);\n  }\n  if (JvmtiExport::has_redefined_a_class()) {\n    \/\/ Reinitialize vtable because RedefineClasses may have changed some\n    \/\/ entries in this vtable for super classes so the CDS vtable might\n    \/\/ point to old or obsolete entries.  RedefineClasses doesn't fix up\n    \/\/ vtables in the shared system dictionary, only the main one.\n    \/\/ It also redefines the itable too so fix that too.\n    ResourceMark rm(THREAD);\n    vtable().initialize_vtable(false, CHECK);\n    itable().initialize_itable(false, CHECK);\n  }\n\n  \/\/ restore constant pool resolved references\n  constants()->restore_unshareable_info(CHECK);\n\n  if (array_klasses() != NULL) {\n    \/\/ Array classes have null protection domain.\n    \/\/ --> see ArrayKlass::complete_create_array_klass()\n    array_klasses()->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK);\n  }\n}","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":387631,"func":"static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,\n\t\t\t      struct snd_ctl_elem_value *control)\n{\n\tstruct snd_kcontrol *kctl;\n\tstruct snd_kcontrol_volatile *vd;\n\tunsigned int index_offset;\n\tint result;\n\n\tdown_write(&card->controls_rwsem);\n\tkctl = snd_ctl_find_id(card, &control->id);\n\tif (kctl == NULL) {\n\t\tup_write(&card->controls_rwsem);\n\t\treturn -ENOENT;\n\t}\n\n\tindex_offset = snd_ctl_get_ioff(kctl, &control->id);\n\tvd = &kctl->vd[index_offset];\n\tif (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || kctl->put == NULL ||\n\t    (file && vd->owner && vd->owner != file)) {\n\t\tup_write(&card->controls_rwsem);\n\t\treturn -EPERM;\n\t}\n\n\tsnd_ctl_build_ioff(&control->id, kctl, index_offset);\n\tresult = snd_power_ref_and_wait(card);\n\t\/* validate input values *\/\n\tif (IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) && !result) {\n\t\tstruct snd_ctl_elem_info info;\n\n\t\tmemset(&info, 0, sizeof(info));\n\t\tinfo.id = control->id;\n\t\tresult = __snd_ctl_elem_info(card, kctl, &info, NULL);\n\t\tif (!result)\n\t\t\tresult = sanity_check_input_values(card, control, &info,\n\t\t\t\t\t\t\t   false);\n\t}\n\tif (!result)\n\t\tresult = kctl->put(kctl, control);\n\tsnd_power_unref(card);\n\tif (result < 0) {\n\t\tup_write(&card->controls_rwsem);\n\t\treturn result;\n\t}\n\n\tif (result > 0) {\n\t\tdowngrade_write(&card->controls_rwsem);\n\t\tsnd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_VALUE, kctl, index_offset);\n\t\tup_read(&card->controls_rwsem);\n\t} else {\n\t\tup_write(&card->controls_rwsem);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":359465,"func":"bgp_capability_vty_out (struct vty *vty, struct peer *peer)\n{\n  char *pnt;\n  char *end;\n  struct capability_mp_data mpc;\n  struct capability_header *hdr;\n\n  pnt = peer->notify.data;\n  end = pnt + peer->notify.length;\n  \n  while (pnt < end)\n    {\n      if (pnt + sizeof (struct capability_mp_data) + 2 > end)\n\treturn;\n      \n      hdr = (struct capability_header *)pnt;\n      if (pnt + hdr->length + 2 > end)\n\treturn;\n\n      memcpy (&mpc, pnt + 2, sizeof(struct capability_mp_data));\n\n      if (hdr->code == CAPABILITY_CODE_MP)\n\t{\n\t  vty_out (vty, \"  Capability error for: Multi protocol \");\n\n\t  switch (ntohs (mpc.afi))\n\t    {\n\t    case AFI_IP:\n\t      vty_out (vty, \"AFI IPv4, \");\n\t      break;\n\t    case AFI_IP6:\n\t      vty_out (vty, \"AFI IPv6, \");\n\t      break;\n\t    default:\n\t      vty_out (vty, \"AFI Unknown %d, \", ntohs (mpc.afi));\n\t      break;\n\t    }\n\t  switch (mpc.safi)\n\t    {\n\t    case SAFI_UNICAST:\n\t      vty_out (vty, \"SAFI Unicast\");\n\t      break;\n\t    case SAFI_MULTICAST:\n\t      vty_out (vty, \"SAFI Multicast\");\n\t      break;\n\t    case SAFI_UNICAST_MULTICAST:\n\t      vty_out (vty, \"SAFI Unicast Multicast\");\n\t      break;\n\t    case BGP_SAFI_VPNV4:\n\t      vty_out (vty, \"SAFI MPLS-VPN\");\n\t      break;\n\t    default:\n\t      vty_out (vty, \"SAFI Unknown %d \", mpc.safi);\n\t      break;\n\t    }\n\t  vty_out (vty, \"%s\", VTY_NEWLINE);\n\t}\n      else if (hdr->code >= 128)\n\tvty_out (vty, \"  Capability error: vendor specific capability code %d\",\n\t\t hdr->code);\n      else\n\tvty_out (vty, \"  Capability error: unknown capability code %d\", \n\t\t hdr->code);\n\n      pnt += hdr->length + 2;\n    }\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":437310,"func":"setup_called_state_call(Node* node, int state)\n{\n  switch (NODE_TYPE(node)) {\n  case NODE_ALT:\n    state |= IN_ALT;\n    \/* fall *\/\n  case NODE_LIST:\n    do {\n      setup_called_state_call(NODE_CAR(node), state);\n    } while (IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_QUANT:\n    {\n      QuantNode* qn = QUANT_(node);\n\n      if (IS_REPEAT_INFINITE(qn->upper) || qn->upper >= 2)\n        state |= IN_REAL_REPEAT;\n      if (qn->lower != qn->upper)\n        state |= IN_VAR_REPEAT;\n\n      setup_called_state_call(NODE_QUANT_BODY(qn), state);\n    }\n    break;\n\n  case NODE_ANCHOR:\n    {\n      AnchorNode* an = ANCHOR_(node);\n\n      switch (an->type) {\n      case ANCHOR_PREC_READ_NOT:\n      case ANCHOR_LOOK_BEHIND_NOT:\n        state |= IN_NOT;\n        \/* fall *\/\n      case ANCHOR_PREC_READ:\n      case ANCHOR_LOOK_BEHIND:\n        setup_called_state_call(NODE_ANCHOR_BODY(an), state);\n        break;\n      default:\n        break;\n      }\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      if (en->type == ENCLOSURE_MEMORY) {\n        if (NODE_IS_MARK1(node)) {\n          if ((~en->m.called_state & state) != 0) {\n            en->m.called_state |= state;\n            setup_called_state_call(NODE_BODY(node), state);\n          }\n        }\n        else {\n          NODE_STATUS_ADD(node, MARK1);\n          en->m.called_state |= state;\n          setup_called_state_call(NODE_BODY(node), state);\n          NODE_STATUS_REMOVE(node, MARK1);\n        }\n      }\n      else if (en->type == ENCLOSURE_IF_ELSE) {\n        if (IS_NOT_NULL(en->te.Then)) {\n          setup_called_state_call(en->te.Then, state);\n        }\n        if (IS_NOT_NULL(en->te.Else))\n          setup_called_state_call(en->te.Else, state);\n      }\n      else {\n        setup_called_state_call(NODE_BODY(node), state);\n      }\n    }\n    break;\n\n  case NODE_CALL:\n    setup_called_state_call(NODE_BODY(node), state);\n    break;\n\n  default:\n    break;\n  }\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":230139,"func":"static int check_certificate(struct config_module * config, json_t * j_params, const char * credential_id, json_int_t gswu_id) {\n  json_t * j_query, * j_result;\n  int res, ret;\n  char * credential_id_escaped, * mod_name_escaped, * where_clause;\n\n  credential_id_escaped = h_escape_string_with_quotes(config->conn, credential_id);\n  mod_name_escaped = h_escape_string_with_quotes(config->conn, json_string_value(json_object_get(j_params, \"mod_name\")));\n  where_clause = msprintf(\" IN (SELECT gswu_id FROM \" G_TABLE_WEBAUTHN_CREDENTIAL \" WHERE gswc_credential_id=%s AND gswc_status=1 AND gswu_id IN (SELECT gswu_id FROM \" G_TABLE_WEBAUTHN_USER \" WHERE gswu_mod_name=%s))\", credential_id_escaped, mod_name_escaped);\n  j_query = json_pack(\"{sss[s]s{s{ssss}si}}\",\n                      \"table\",\n                      G_TABLE_WEBAUTHN_CREDENTIAL,\n                      \"columns\",\n                        \"gswu_id\",\n                      \"where\",\n                        \"gswu_id\",\n                          \"operator\",\n                          \"raw\",\n                          \"value\",\n                          where_clause,\n                        \"gswc_status\",\n                        1);\n  o_free(where_clause);\n  o_free(mod_name_escaped);\n  o_free(credential_id_escaped);\n  res = h_select(config->conn, j_query, &j_result, NULL);\n  json_decref(j_query);\n  if (res == H_OK) {\n    if (json_array_size(j_result)) {\n      if (json_integer_value(json_object_get(json_array_get(j_result, 0), \"gswu_id\")) == gswu_id) {\n        ret = G_OK;\n      } else {\n        ret = G_ERROR_UNAUTHORIZED;\n      }\n    } else {\n      ret = G_ERROR_NOT_FOUND;\n    }\n    json_decref(j_result);\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"check_credential_id - Error executing j_query\");\n    config->glewlwyd_module_callback_metrics_increment_counter(config, GLWD_METRICS_DATABSE_ERROR, 1, NULL);\n    ret = G_ERROR_DB;\n  }\n  return ret;\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":372858,"func":"static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\tstruct msghdr *msg, size_t len)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct irda_sock *self;\n\tstruct sk_buff *skb;\n\tint err = -EPIPE;\n\n\tIRDA_DEBUG(4, \"%s(), len=%zd\\n\", __func__, len);\n\n\t\/* Note : socket.c set MSG_EOR on SEQPACKET sockets *\/\n\tif (msg->msg_flags & ~(MSG_DONTWAIT | MSG_EOR | MSG_CMSG_COMPAT |\n\t\t\t       MSG_NOSIGNAL)) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tlock_sock(sk);\n\n\tif (sk->sk_shutdown & SEND_SHUTDOWN)\n\t\tgoto out_err;\n\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\terr = -ENOTCONN;\n\t\tgoto out;\n\t}\n\n\tself = irda_sk(sk);\n\n\t\/* Check if IrTTP is wants us to slow down *\/\n\n\tif (wait_event_interruptible(*(sk_sleep(sk)),\n\t    (self->tx_flow != FLOW_STOP  ||  sk->sk_state != TCP_ESTABLISHED))) {\n\t\terr = -ERESTARTSYS;\n\t\tgoto out;\n\t}\n\n\t\/* Check if we are still connected *\/\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\terr = -ENOTCONN;\n\t\tgoto out;\n\t}\n\n\t\/* Check that we don't send out too big frames *\/\n\tif (len > self->max_data_size) {\n\t\tIRDA_DEBUG(2, \"%s(), Chopping frame from %zd to %d bytes!\\n\",\n\t\t\t   __func__, len, self->max_data_size);\n\t\tlen = self->max_data_size;\n\t}\n\n\tskb = sock_alloc_send_skb(sk, len + self->max_header_size + 16,\n\t\t\t\t  msg->msg_flags & MSG_DONTWAIT, &err);\n\tif (!skb)\n\t\tgoto out_err;\n\n\tskb_reserve(skb, self->max_header_size + 16);\n\tskb_reset_transport_header(skb);\n\tskb_put(skb, len);\n\terr = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len);\n\tif (err) {\n\t\tkfree_skb(skb);\n\t\tgoto out_err;\n\t}\n\n\t\/*\n\t * Just send the message to TinyTP, and let it deal with possible\n\t * errors. No need to duplicate all that here\n\t *\/\n\terr = irttp_data_request(self->tsap, skb);\n\tif (err) {\n\t\tIRDA_DEBUG(0, \"%s(), err=%d\\n\", __func__, err);\n\t\tgoto out_err;\n\t}\n\n\trelease_sock(sk);\n\t\/* Tell client how much data we actually sent *\/\n\treturn len;\n\nout_err:\n\terr = sk_stream_error(sk, msg->msg_flags, err);\nout:\n\trelease_sock(sk);\n\treturn err;\n\n}","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":310145,"func":"valid_db_path(const char *nominal)\n{\n    struct stat sb;\n#if USE_HASHED_DB\n    char suffix[] = DBM_SUFFIX;\n    size_t need = strlen(nominal) + sizeof(suffix);\n    char *result = malloc(need);\n\n    if (result == 0)\n\tfailed(\"valid_db_path\");\n    _nc_STRCPY(result, nominal, need);\n    if (strcmp(result + need - sizeof(suffix), suffix)) {\n\t_nc_STRCAT(result, suffix, need);\n    }\n#else\n    char *result = strdup(nominal);\n#endif\n\n    DEBUG(1, (\"** stat(%s)\", result));\n    if (stat(result, &sb) >= 0) {\n#if USE_HASHED_DB\n\tif (!S_ISREG(sb.st_mode)\n\t    || access(result, R_OK | W_OK) != 0) {\n\t    DEBUG(1, (\"...not a writable file\"));\n\t    free(result);\n\t    result = 0;\n\t}\n#else\n\tif (!S_ISDIR(sb.st_mode)\n\t    || access(result, R_OK | W_OK | X_OK) != 0) {\n\t    DEBUG(1, (\"...not a writable directory\"));\n\t    free(result);\n\t    result = 0;\n\t}\n#endif\n    } else {\n\t\/* check if parent is directory and is writable *\/\n\tunsigned leaf = _nc_pathlast(result);\n\n\tDEBUG(1, (\"...not found\"));\n\tif (leaf) {\n\t    char save = result[leaf];\n\t    result[leaf] = 0;\n\t    if (stat(result, &sb) >= 0\n\t\t&& S_ISDIR(sb.st_mode)\n\t\t&& access(result, R_OK | W_OK | X_OK) == 0) {\n\t\tresult[leaf] = save;\n\t    } else {\n\t\tDEBUG(1, (\"...parent directory %s is not writable\", result));\n\t\tfree(result);\n\t\tresult = 0;\n\t    }\n\t} else {\n\t    DEBUG(1, (\"... no parent directory\"));\n\t    free(result);\n\t    result = 0;\n\t}\n    }\n    return result;\n}","target":0,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":413863,"func":"Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,\n                                               bool checkpolymorphism,\n                                               bool in_imethod_resolve) {\n  NoSafepointVerifier nsv;  \/\/ Method* returned may not be reclaimed\n\n  Klass* klass = link_info.resolved_klass();\n  Symbol* name = link_info.name();\n  Symbol* signature = link_info.signature();\n\n  \/\/ Ignore overpasses so statics can be found during resolution\n  Method* result = klass->uncached_lookup_method(name, signature, Klass::OverpassLookupMode::skip);\n\n  if (klass->is_array_klass()) {\n    \/\/ Only consider klass and super klass for arrays\n    return result;\n  }\n\n  InstanceKlass* ik = InstanceKlass::cast(klass);\n\n  \/\/ JDK 8, JVMS 5.4.3.4: Interface method resolution should\n  \/\/ ignore static and non-public methods of java.lang.Object,\n  \/\/ like clone and finalize.\n  if (in_imethod_resolve &&\n      result != NULL &&\n      ik->is_interface() &&\n      (result->is_static() || !result->is_public()) &&\n      result->method_holder() == vmClasses::Object_klass()) {\n    result = NULL;\n  }\n\n  \/\/ Before considering default methods, check for an overpass in the\n  \/\/ current class if a method has not been found.\n  if (result == NULL) {\n    result = ik->find_method(name, signature);\n  }\n\n  if (result == NULL) {\n    Array<Method*>* default_methods = ik->default_methods();\n    if (default_methods != NULL) {\n      result = InstanceKlass::find_method(default_methods, name, signature);\n    }\n  }\n\n  if (checkpolymorphism && result != NULL) {\n    vmIntrinsics::ID iid = result->intrinsic_id();\n    if (MethodHandles::is_signature_polymorphic(iid)) {\n      \/\/ Do not link directly to these.  The VM must produce a synthetic one using lookup_polymorphic_method.\n      return NULL;\n    }\n  }\n  return result;\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":391650,"func":"NTSTATUS fd_open(struct connection_struct *conn,\n\t\t files_struct *fsp,\n\t\t int flags,\n\t\t mode_t mode)\n{\n\tstruct smb_filename *smb_fname = fsp->fsp_name;\n\tNTSTATUS status = NT_STATUS_OK;\n\n#ifdef O_NOFOLLOW\n\t\/* \n\t * Never follow symlinks on a POSIX client. The\n\t * client should be doing this.\n\t *\/\n\n\tif (fsp->posix_open || !lp_symlinks(SNUM(conn))) {\n\t\tflags |= O_NOFOLLOW;\n\t}\n#endif\n\n\tfsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, flags, mode);\n\tif (fsp->fh->fd == -1) {\n\t\tint posix_errno = errno;\n#ifdef O_NOFOLLOW\n#if defined(ENOTSUP) && defined(OSF1)\n\t\t\/* handle special Tru64 errno *\/\n\t\tif (errno == ENOTSUP) {\n\t\t\tposix_errno = ELOOP;\n\t\t}\n#endif \/* ENOTSUP *\/\n#ifdef EFTYPE\n\t\t\/* fix broken NetBSD errno *\/\n\t\tif (errno == EFTYPE) {\n\t\t\tposix_errno = ELOOP;\n\t\t}\n#endif \/* EFTYPE *\/\n\t\t\/* fix broken FreeBSD errno *\/\n\t\tif (errno == EMLINK) {\n\t\t\tposix_errno = ELOOP;\n\t\t}\n#endif \/* O_NOFOLLOW *\/\n\t\tstatus = map_nt_error_from_unix(posix_errno);\n\t\tif (errno == EMFILE) {\n\t\t\tstatic time_t last_warned = 0L;\n\n\t\t\tif (time((time_t *) NULL) > last_warned) {\n\t\t\t\tDEBUG(0,(\"Too many open files, unable \"\n\t\t\t\t\t\"to open more!  smbd's max \"\n\t\t\t\t\t\"open files = %d\\n\",\n\t\t\t\t\tlp_max_open_files()));\n\t\t\t\tlast_warned = time((time_t *) NULL);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tDEBUG(10,(\"fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\\n\",\n\t\t  smb_fname_str_dbg(smb_fname), flags, (int)mode, fsp->fh->fd,\n\t\t(fsp->fh->fd == -1) ? strerror(errno) : \"\" ));\n\n\treturn status;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":252290,"func":"mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip,\n                                       const char *pFilename) {\n  mz_zip_internal_state *pState;\n  if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return MZ_FALSE;\n  \/\/ No sense in trying to write to an archive that's already at the support max\n  \/\/ size\n  if ((pZip->m_total_files == 0xFFFF) ||\n      ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE +\n        MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))\n    return MZ_FALSE;\n\n  pState = pZip->m_pState;\n\n  if (pState->m_pFile) {\n#ifdef MINIZ_NO_STDIO\n    pFilename;\n    return MZ_FALSE;\n#else\n    \/\/ Archive is being read from stdio - try to reopen as writable.\n    if (pZip->m_pIO_opaque != pZip) return MZ_FALSE;\n    if (!pFilename) return MZ_FALSE;\n    pZip->m_pWrite = mz_zip_file_write_func;\n    if (NULL ==\n        (pState->m_pFile = MZ_FREOPEN(pFilename, \"r+b\", pState->m_pFile))) {\n      \/\/ The mz_zip_archive is now in a bogus state because pState->m_pFile is\n      \/\/ NULL, so just close it.\n      mz_zip_reader_end(pZip);\n      return MZ_FALSE;\n    }\n#endif  \/\/ #ifdef MINIZ_NO_STDIO\n  } else if (pState->m_pMem) {\n    \/\/ Archive lives in a memory block. Assume it's from the heap that we can\n    \/\/ resize using the realloc callback.\n    if (pZip->m_pIO_opaque != pZip) return MZ_FALSE;\n    pState->m_mem_capacity = pState->m_mem_size;\n    pZip->m_pWrite = mz_zip_heap_write_func;\n  }\n  \/\/ Archive is being read via a user provided read function - make sure the\n  \/\/ user has specified a write function too.\n  else if (!pZip->m_pWrite)\n    return MZ_FALSE;\n\n  \/\/ Start writing new files at the archive's current central directory\n  \/\/ location.\n  pZip->m_archive_size = pZip->m_central_directory_file_ofs;\n  pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;\n  pZip->m_central_directory_file_ofs = 0;\n\n  return MZ_TRUE;\n}","target":0,"code_token_length":554,"total_token_length":790,"max_tokens_setting":1024}
+{"idx":197808,"func":"mrb_f_send(mrb_state *mrb, mrb_value self)\n{\n  mrb_sym name;\n  mrb_value block, *regs;\n  mrb_method_t m;\n  struct RClass *c;\n  mrb_callinfo *ci = mrb->c->ci;\n  int n = ci->n;\n\n  if (ci->cci > CINFO_NONE) {\n  funcall:;\n    const mrb_value *argv;\n    mrb_int argc;\n    mrb_get_args(mrb, \"n*&\", &name, &argv, &argc, &block);\n    return mrb_funcall_with_block(mrb, self, name, argc, argv, block);\n  }\n\n  regs = mrb->c->ci->stack+1;\n\n  if (n == 0) {\n    mrb_argnum_error(mrb, 0, 1, -1);\n  }\n  else if (n == 15) {\n    name = mrb_obj_to_sym(mrb, RARRAY_PTR(regs[0])[0]);\n  }\n  else {\n    name = mrb_obj_to_sym(mrb, regs[0]);\n  }\n\n  c = mrb_class(mrb, self);\n  m = mrb_method_search_vm(mrb, &c, name);\n  if (MRB_METHOD_UNDEF_P(m)) {            \/* call method_mising *\/\n    goto funcall;\n  }\n\n  ci->mid = name;\n  ci->u.target_class = c;\n  \/* remove first symbol from arguments *\/\n  if (n == 15) {     \/* variable length arguments *\/\n    regs[0] = mrb_ary_subseq(mrb, regs[0], 1, RARRAY_LEN(regs[0]) - 1);\n  }\n  else { \/* n > 0 *\/\n    for (int i=0; i<n; i++) {\n      regs[i] = regs[i+1];\n    }\n    regs[n] = regs[n+1];        \/* copy kdict or block *\/\n    if (ci->nk > 0) {\n      regs[n+1] = regs[n+2];    \/* copy block *\/\n    }\n    ci->n--;\n  }\n\n  if (MRB_METHOD_CFUNC_P(m)) {\n    if (MRB_METHOD_NOARG_P(m)) {\n      check_method_noarg(mrb, ci);\n    }\n\n    if (MRB_METHOD_PROC_P(m)) {\n      mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));\n    }\n    return MRB_METHOD_CFUNC(m)(mrb, self);\n  }\n  return exec_irep(mrb, self, MRB_METHOD_PROC(m));\n}","target":1,"code_token_length":540,"total_token_length":776,"max_tokens_setting":1024}
+{"idx":405375,"func":"static void xfrm_policy_fini(struct net *net)\n{\n\tstruct xfrm_pol_inexact_bin *b, *t;\n\tunsigned int sz;\n\tint dir;\n\n\tflush_work(&net->xfrm.policy_hash_work);\n#ifdef CONFIG_XFRM_SUB_POLICY\n\txfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, false);\n#endif\n\txfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false);\n\n\tWARN_ON(!list_empty(&net->xfrm.policy_all));\n\n\tfor (dir = 0; dir < XFRM_POLICY_MAX; dir++) {\n\t\tstruct xfrm_policy_hash *htab;\n\n\t\tWARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir]));\n\n\t\thtab = &net->xfrm.policy_bydst[dir];\n\t\tsz = (htab->hmask + 1) * sizeof(struct hlist_head);\n\t\tWARN_ON(!hlist_empty(htab->table));\n\t\txfrm_hash_free(htab->table, sz);\n\t}\n\n\tsz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head);\n\tWARN_ON(!hlist_empty(net->xfrm.policy_byidx));\n\txfrm_hash_free(net->xfrm.policy_byidx, sz);\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\tlist_for_each_entry_safe(b, t, &net->xfrm.inexact_bins, inexact_bins)\n\t\t__xfrm_policy_inexact_prune_bin(b, true);\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":488375,"func":"static void remove_migration_pte(struct vm_area_struct *vma,\n\t\tstruct page *old, struct page *new)\n{\n\tstruct mm_struct *mm = vma->vm_mm;\n\tswp_entry_t entry;\n \tpgd_t *pgd;\n \tpud_t *pud;\n \tpmd_t *pmd;\n\tpte_t *ptep, pte;\n \tspinlock_t *ptl;\n\tunsigned long addr = page_address_in_vma(new, vma);\n\n\tif (addr == -EFAULT)\n\t\treturn;\n\n \tpgd = pgd_offset(mm, addr);\n\tif (!pgd_present(*pgd))\n                return;\n\n\tpud = pud_offset(pgd, addr);\n\tif (!pud_present(*pud))\n                return;\n\n\tpmd = pmd_offset(pud, addr);\n\tif (!pmd_present(*pmd))\n\t\treturn;\n\n\tptep = pte_offset_map(pmd, addr);\n\n\tif (!is_swap_pte(*ptep)) {\n\t\tpte_unmap(ptep);\n \t\treturn;\n \t}\n\n \tptl = pte_lockptr(mm, pmd);\n \tspin_lock(ptl);\n\tpte = *ptep;\n\tif (!is_swap_pte(pte))\n\t\tgoto out;\n\n\tentry = pte_to_swp_entry(pte);\n\n\tif (!is_migration_entry(entry) || migration_entry_to_page(entry) != old)\n\t\tgoto out;\n\n\t\/*\n\t * Yes, ignore the return value from a GFP_ATOMIC mem_cgroup_charge.\n\t * Failure is not an option here: we're now expected to remove every\n\t * migration pte, and will cause crashes otherwise.  Normally this\n\t * is not an issue: mem_cgroup_prepare_migration bumped up the old\n\t * page_cgroup count for safety, that's now attached to the new page,\n\t * so this charge should just be another incrementation of the count,\n\t * to keep in balance with rmap.c's mem_cgroup_uncharging.  But if\n\t * there's been a force_empty, those reference counts may no longer\n\t * be reliable, and this charge can actually fail: oh well, we don't\n\t * make the situation any worse by proceeding as if it had succeeded.\n\t *\/\n\tmem_cgroup_charge(new, mm, GFP_ATOMIC);\n\n\tget_page(new);\n\tpte = pte_mkold(mk_pte(new, vma->vm_page_prot));\n\tif (is_write_migration_entry(entry))\n\t\tpte = pte_mkwrite(pte);\n\tflush_cache_page(vma, addr, pte_pfn(pte));\n\tset_pte_at(mm, addr, ptep, pte);\n\n\tif (PageAnon(new))\n\t\tpage_add_anon_rmap(new, vma, addr);\n\telse\n\t\tpage_add_file_rmap(new);\n\n\t\/* No need to invalidate - it was non-present before *\/\n\tupdate_mmu_cache(vma, addr, pte);\n\nout:\n\tpte_unmap_unlock(ptep, ptl);\n}","target":0,"code_token_length":616,"total_token_length":852,"max_tokens_setting":1024}
+{"idx":476145,"func":"int usb_add_function(struct usb_configuration *config,\n\t\tstruct usb_function *function)\n{\n\tint\tvalue = -EINVAL;\n\n\tDBG(config->cdev, \"adding '%s'\/%p to config '%s'\/%p\\n\",\n\t\t\tfunction->name, function,\n\t\t\tconfig->label, config);\n\n\tif (!function->set_alt || !function->disable)\n\t\tgoto done;\n\n\tfunction->config = config;\n\tlist_add_tail(&function->list, &config->functions);\n\n\tif (function->bind_deactivated) {\n\t\tvalue = usb_function_deactivate(function);\n\t\tif (value)\n\t\t\tgoto done;\n\t}\n\n\t\/* REVISIT *require* function->bind? *\/\n\tif (function->bind) {\n\t\tvalue = function->bind(config, function);\n\t\tif (value < 0) {\n\t\t\tlist_del(&function->list);\n\t\t\tfunction->config = NULL;\n\t\t}\n\t} else\n\t\tvalue = 0;\n\n\t\/* We allow configurations that don't work at both speeds.\n\t * If we run into a lowspeed Linux system, treat it the same\n\t * as full speed ... it's the function drivers that will need\n\t * to avoid bulk and ISO transfers.\n\t *\/\n\tif (!config->fullspeed && function->fs_descriptors)\n\t\tconfig->fullspeed = true;\n\tif (!config->highspeed && function->hs_descriptors)\n\t\tconfig->highspeed = true;\n\tif (!config->superspeed && function->ss_descriptors)\n\t\tconfig->superspeed = true;\n\tif (!config->superspeed_plus && function->ssp_descriptors)\n\t\tconfig->superspeed_plus = true;\n\ndone:\n\tif (value)\n\t\tDBG(config->cdev, \"adding '%s'\/%p --> %d\\n\",\n\t\t\t\tfunction->name, function, value);\n\treturn value;\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":261213,"func":"static int MqttClient_RespList_Find(MqttClient *client,\n    MqttPacketType packet_type, word16 packet_id, MqttPendResp **retResp)\n{\n    int rc = 0;\n    MqttPendResp *tmpResp;\n\n    if (client == NULL)\n        return MQTT_CODE_ERROR_BAD_ARG;\n\n#ifdef WOLFMQTT_DEBUG_CLIENT\n    PRINTF(\"PendResp Find: Type %s (%d), ID %d\",\n        MqttPacket_TypeDesc(packet_type), packet_type, packet_id);\n#endif\n\n    if (retResp)\n        *retResp = NULL; \/* clear *\/\n\n    \/* Find pending response entry *\/\n    for (tmpResp = client->firstPendResp;\n         tmpResp != NULL;\n         tmpResp = tmpResp->next)\n    {\n        if (packet_type == tmpResp->packet_type &&\n           (packet_id == tmpResp->packet_id))\n        {\n        #ifdef WOLFMQTT_DEBUG_CLIENT\n            PRINTF(\"PendResp Found: %p, Type %s (%d), ID %d\",\n                tmpResp, MqttPacket_TypeDesc(tmpResp->packet_type),\n                tmpResp->packet_type, tmpResp->packet_id);\n        #endif\n\n            if (retResp)\n                *retResp = tmpResp;\n            rc = 1;\n            break;\n        }\n    }\n    return rc;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":222922,"func":"void VerboseLogUnknownDimensionSources(\n    const GraphDef& graph,\n    const absl::flat_hash_map<string, std::vector<OpInfo::TensorProperties>>&\n        input_properties_map,\n    const absl::flat_hash_map<string, std::vector<OpInfo::TensorProperties>>&\n        output_properties_map) {\n  if (!VLOG_IS_ON(2)) {\n    return;\n  }\n\n  VLOG(2) << \"Nodes with known inputs, but with unknown output dimensions:\";\n\n  \/\/ Find all nodes in the graph for which we\n  \/\/ do not have any unknown dimensions in their inputs, but\n  \/\/ we have some unknown dimensions in their outputs.\n  std::map<string, int> op_to_count;\n  for (const NodeDef& node : graph.node()) {\n    const auto& input_properties = input_properties_map.at(node.name());\n    const auto& output_properties = output_properties_map.at(node.name());\n\n    bool has_unknown_inputs = false;\n    for (const auto& input_prop : input_properties) {\n      if (HasAnyUnknownDimensions(input_prop.shape())) {\n        has_unknown_inputs = true;\n        break;\n      }\n    }\n\n    if (has_unknown_inputs) {\n      continue;\n    }\n\n    for (const auto& output_prop : output_properties) {\n      if (HasAnyUnknownDimensions(output_prop.shape())) {\n        string inputs = \"input_shapes=[\";\n        for (const auto& input_prop : input_properties) {\n          inputs += PartialTensorShape::DebugString(input_prop.shape());\n        }\n        inputs += \"]\";\n\n        string outputs = \"output_shapes=[\";\n        for (const auto& output_prop : output_properties) {\n          outputs += PartialTensorShape::DebugString(output_prop.shape());\n        }\n        outputs += \"]\";\n\n        VLOG(2) << \"Node: \" << node.name() << \", Op: \" << node.op() << \", \"\n                << inputs << \", \" << outputs;\n\n        op_to_count[node.op()]++;\n\n        \/\/ don't log again for this node\n        break;\n      }\n    }\n  }\n  VLOG(2) << \"Op types with known inputs, but with unknown output dimensions \"\n          << \"(format: <op_type> (<count>)):\";\n  for (const auto& p : op_to_count) {\n    VLOG(2) << p.first << \" (\" << p.second << \")\";\n  }\n}","target":0,"code_token_length":491,"total_token_length":727,"max_tokens_setting":1024}
+{"idx":281640,"func":"void CLASS lossless_jpeg_load_raw()\n{\n  int jwide, jrow, jcol, val, jidx, i, j, row=0, col=0;\n  struct jhead jh;\n  ushort *rp;\n\n  if (!ljpeg_start (&jh, 0)) return;\n\n  if(jh.wide<1 || jh.high<1 || jh.clrs<1 || jh.bits <1)\n#ifdef LIBRAW_LIBRARY_BUILD\n    throw LIBRAW_EXCEPTION_IO_CORRUPT;\n#else\n    longjmp (failure, 2);\n#endif\n  jwide = jh.wide * jh.clrs;\n\n#ifdef LIBRAW_LIBRARY_BUILD\n  try {\n#endif\n  for (jrow=0; jrow < jh.high; jrow++) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    rp = ljpeg_row (jrow, &jh);\n    if (load_flags & 1)\n      row = jrow & 1 ? height-1-jrow\/2 : jrow\/2;\n    for (jcol=0; jcol < jwide; jcol++) {\n      val = curve[*rp++];\n      if (cr2_slice[0]) {\n\tjidx = jrow*jwide + jcol;\n\ti = jidx \/ (cr2_slice[1]*jh.high);\n\tif ((j = i >= cr2_slice[0]))\n\t\t i  = cr2_slice[0];\n\tjidx -= i * (cr2_slice[1]*jh.high);\n\trow = jidx \/ cr2_slice[1+j];\n\tcol = jidx % cr2_slice[1+j] + i*cr2_slice[1];\n      }\n      if (raw_width == 3984 && (col -= 2) < 0)\n\tcol += (row--,raw_width);\n      if(row>raw_height)\n#ifdef LIBRAW_LIBRARY_BUILD\n        throw LIBRAW_EXCEPTION_IO_CORRUPT;\n#else\n        longjmp (failure, 3);\n#endif\n      if ((unsigned) row < raw_height) RAW(row,col) = val;\n      if (++col >= raw_width)\n\tcol = (row++,0);\n    }\n  }\n#ifdef LIBRAW_LIBRARY_BUILD\n  } catch (...) {\n    ljpeg_end (&jh);\n    throw;\n  }\n#endif\n  ljpeg_end (&jh);\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":261964,"func":"njs_string_prototype_trim(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t mode)\n{\n    uint32_t              u, trim, length;\n    njs_int_t             ret;\n    njs_value_t           *value;\n    const u_char          *p, *prev, *start, *end;\n    njs_string_prop_t     string;\n    njs_unicode_decode_t  ctx;\n\n    value = njs_argument(args, 0);\n    ret = njs_string_object_validate(vm, value);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    trim = 0;\n\n    njs_string_prop(&string, value);\n\n    start = string.start;\n    end = string.start + string.size;\n\n    if (njs_is_byte_or_ascii_string(&string)) {\n\n        if (mode & NJS_TRIM_START) {\n            for ( ;; ) {\n                if (start == end) {\n                    goto empty;\n                }\n\n                if (njs_is_whitespace(*start)) {\n                    start++;\n                    trim++;\n                    continue;\n                }\n\n                break;\n            }\n        }\n\n        if (mode & NJS_TRIM_END) {\n            for ( ;; ) {\n                if (start == end) {\n                    goto empty;\n                }\n\n                end--;\n\n                if (njs_is_whitespace(*end)) {\n                    trim++;\n                    continue;\n                }\n\n                end++;\n                break;\n            }\n        }\n\n    } else {\n        \/* UTF-8 string. *\/\n\n        if (mode & NJS_TRIM_START) {\n            njs_utf8_decode_init(&ctx);\n\n            for ( ;; ) {\n                if (start == end) {\n                    goto empty;\n                }\n\n                p = start;\n                u = njs_utf8_decode(&ctx, &start, end);\n\n                if (njs_utf8_is_whitespace(u)) {\n                    trim++;\n                    continue;\n                }\n\n                start = p;\n                break;\n            }\n        }\n\n        if (mode & NJS_TRIM_END) {\n            prev = end;\n\n            njs_utf8_decode_init(&ctx);\n\n            for ( ;; ) {\n                if (start == prev) {\n                    goto empty;\n                }\n\n                prev = njs_utf8_prev(prev);\n                p = prev;\n                u = njs_utf8_decode(&ctx, &p, end);\n\n                if (njs_utf8_is_whitespace(u)) {\n                    trim++;\n                    continue;\n                }\n\n                end = p;\n                break;\n            }\n        }\n    }\n\n    if (trim == 0) {\n        \/* GC: retain. *\/\n        vm->retval = *value;\n\n        return NJS_OK;\n    }\n\n    length = (string.length != 0) ? string.length - trim : 0;\n\n    return njs_string_new(vm, &vm->retval, start, end - start, length);\n\nempty:\n\n    vm->retval = njs_string_empty;\n\n    return NJS_OK;\n}","target":0,"code_token_length":621,"total_token_length":857,"max_tokens_setting":1024}
+{"idx":450412,"func":"static int vnc_display_listen(VncDisplay *vd,\n                              SocketAddress **saddr,\n                              size_t nsaddr,\n                              SocketAddress **wsaddr,\n                              size_t nwsaddr,\n                              Error **errp)\n{\n    size_t i;\n\n    if (nsaddr) {\n        vd->listener = qio_net_listener_new();\n        qio_net_listener_set_name(vd->listener, \"vnc-listen\");\n        for (i = 0; i < nsaddr; i++) {\n            if (qio_net_listener_open_sync(vd->listener,\n                                           saddr[i], 1,\n                                           errp) < 0)  {\n                return -1;\n            }\n        }\n\n        qio_net_listener_set_client_func(vd->listener,\n                                         vnc_listen_io, vd, NULL);\n    }\n\n    if (nwsaddr) {\n        vd->wslistener = qio_net_listener_new();\n        qio_net_listener_set_name(vd->wslistener, \"vnc-ws-listen\");\n        for (i = 0; i < nwsaddr; i++) {\n            if (qio_net_listener_open_sync(vd->wslistener,\n                                           wsaddr[i], 1,\n                                           errp) < 0)  {\n                return -1;\n            }\n        }\n\n        qio_net_listener_set_client_func(vd->wslistener,\n                                         vnc_listen_io, vd, NULL);\n    }\n\n    return 0;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":247553,"func":"TEST_P(SslSocketTest, GetPeerCertChain) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_chain.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n  require_client_certificate: true\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  std::string expected_peer_cert_chain =\n      TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(\n          \"{{ test_rundir \"\n          \"}}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_chain.pem\"));\n  testUtil(test_options.setExpectedSerialNumber(TEST_NO_SAN_CERT_SERIAL)\n               .setExpectedPeerCertChain(expected_peer_cert_chain));\n}","target":0,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":385872,"func":"static int check_acl(struct inode *inode, int mask)\n{\n#ifdef CONFIG_FS_POSIX_ACL\n\tstruct posix_acl *acl;\n\n\tif (mask & MAY_NOT_BLOCK) {\n\t\tacl = get_cached_acl_rcu(inode, ACL_TYPE_ACCESS);\n\t        if (!acl)\n\t                return -EAGAIN;\n\t\t\/* no ->get_acl() calls in RCU mode... *\/\n\t\tif (acl == ACL_NOT_CACHED)\n\t\t\treturn -ECHILD;\n\t        return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK);\n\t}\n\n\tacl = get_cached_acl(inode, ACL_TYPE_ACCESS);\n\n\t\/*\n\t * A filesystem can force a ACL callback by just never filling the\n\t * ACL cache. But normally you'd fill the cache either at inode\n\t * instantiation time, or on the first ->get_acl call.\n\t *\n\t * If the filesystem doesn't have a get_acl() function at all, we'll\n\t * just create the negative cache entry.\n\t *\/\n\tif (acl == ACL_NOT_CACHED) {\n\t        if (inode->i_op->get_acl) {\n\t\t\tacl = inode->i_op->get_acl(inode, ACL_TYPE_ACCESS);\n\t\t\tif (IS_ERR(acl))\n\t\t\t\treturn PTR_ERR(acl);\n\t\t} else {\n\t\t        set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);\n\t\t        return -EAGAIN;\n\t\t}\n\t}\n\n\tif (acl) {\n\t        int error = posix_acl_permission(inode, acl, mask);\n\t        posix_acl_release(acl);\n\t        return error;\n\t}\n#endif\n\n\treturn -EAGAIN;\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":336641,"func":"void reds_client_disconnect(RedsState *reds, RedClient *client)\n{\n    RedsMigTargetClient *mig_client;\n\n    if (reds->config->exit_on_disconnect)\n    {\n        spice_debug(\"Exiting server because of client disconnect.\");\n        exit(0);\n    }\n\n    if (!client || client->is_disconnecting()) {\n        spice_debug(\"client %p already during disconnection\", client);\n        return;\n    }\n\n    spice_debug(\"trace\");\n    \/* disconnecting is set to prevent recursion because of the following:\n     * main_channel_client_on_disconnect->\n     *  reds_client_disconnect->red_client_destroy->main_channel...\n     *\/\n    client->set_disconnecting();\n\n    \/\/ TODO: we need to handle agent properly for all clients!!!! (e.g., cut and paste, how?)\n    \/\/ We shouldn't initialize the agent when there are still clients connected\n\n    mig_client = reds_mig_target_client_find(reds, client);\n    if (mig_client) {\n        reds_mig_target_client_free(reds, mig_client);\n    }\n\n    if (reds->mig_wait_disconnect) {\n        reds_mig_remove_wait_disconnect_client(reds, client);\n    }\n\n    \/* note that client might be NULL, if the vdagent was once\n     * up and than was removed *\/\n    RedCharDeviceClientOpaque *client_opaque = (RedCharDeviceClientOpaque *) client;\n    if (reds->agent_dev->client_exists(client_opaque)) {\n        reds->agent_dev->client_remove(client_opaque);\n    }\n\n    reds->clients.remove(client);\n    client->destroy();\n\n   \/\/ TODO: we need to handle agent properly for all clients!!!! (e.g., cut and paste, how? Maybe throw away messages\n   \/\/ if we are in the middle of one from another client)\n    if (reds->clients.empty()) {\n        \/* Let the agent know the client is disconnected *\/\n        if (reds->agent_dev->priv->agent_attached) {\n            RedCharDeviceWriteBuffer *char_dev_buf =\n                vdagent_new_write_buffer(reds->agent_dev.get(),\n                                         VD_AGENT_CLIENT_DISCONNECTED,\n                                         0,\n                                         false);\n\n            reds->agent_dev->write_buffer_add(char_dev_buf);\n        }\n\n        \/* Reset write filter to start with clean state on client reconnect *\/\n        agent_msg_filter_init(&reds->agent_dev->priv->write_filter, reds->config->agent_copypaste,\n                              reds->config->agent_file_xfer,\n                              reds_use_client_monitors_config(reds), TRUE);\n\n        \/* Throw away pending chunks from the current (if any) and future\n         *  messages read from the agent *\/\n        reds->agent_dev->priv->read_filter.result = AGENT_MSG_FILTER_DISCARD;\n        reds->agent_dev->priv->read_filter.discard_all = TRUE;\n        g_free(reds->agent_dev->priv->mig_data);\n        reds->agent_dev->priv->mig_data = NULL;\n\n        reds_mig_cleanup(reds);\n    }\n}","target":0,"code_token_length":636,"total_token_length":872,"max_tokens_setting":1024}
+{"idx":500670,"func":"static sftp_statvfs_t sftp_parse_statvfs(sftp_session sftp, ssh_buffer buf) {\n\tsftp_statvfs_t  statvfs;\n  uint64_t tmp;\n  int ok = 0;\n\n  statvfs = malloc(sizeof(struct sftp_statvfs_struct));\n  if (statvfs == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return NULL;\n  }\n  ZERO_STRUCTP(statvfs);\n\n  \/* try .. catch *\/\n  do {\n    \/* file system block size *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_bsize = ntohll(tmp);\n\n    \/* fundamental fs block size *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_frsize = ntohll(tmp);\n\n    \/* number of blocks (unit f_frsize) *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_blocks = ntohll(tmp);\n\n    \/* free blocks in file system *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_bfree = ntohll(tmp);\n\n    \/* free blocks for non-root *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_bavail = ntohll(tmp);\n\n    \/* total file inodes *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_files = ntohll(tmp);\n\n    \/* free file inodes *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_ffree = ntohll(tmp);\n\n    \/* free file inodes for to non-root *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_favail = ntohll(tmp);\n\n    \/* file system id *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_fsid = ntohll(tmp);\n\n    \/* bit mask of f_flag values *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_flag = ntohll(tmp);\n\n    \/* maximum filename length *\/\n    if (buffer_get_u64(buf, &tmp) != sizeof(uint64_t)) {\n      break;\n    }\n    statvfs->f_namemax = ntohll(tmp);\n\n    ok = 1;\n  } while(0);\n\n  if (!ok) {\n    SAFE_FREE(statvfs);\n    ssh_set_error(sftp->session, SSH_FATAL, \"Invalid statvfs structure\");\n    return NULL;\n  }\n\n  return statvfs;\n}","target":0,"code_token_length":669,"total_token_length":905,"max_tokens_setting":1024}
+{"idx":436042,"func":"\nstatic int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)\n{\n\tunsigned int to_submit;\n\tint ret = 0;\n\n\tto_submit = io_sqring_entries(ctx);\n\t\/* if we're handling multiple rings, cap submit size for fairness *\/\n\tif (cap_entries && to_submit > IORING_SQPOLL_CAP_ENTRIES_VALUE)\n\t\tto_submit = IORING_SQPOLL_CAP_ENTRIES_VALUE;\n\n\tif (!list_empty(&ctx->iopoll_list) || to_submit) {\n\t\tunsigned nr_events = 0;\n\t\tconst struct cred *creds = NULL;\n\n\t\tif (ctx->sq_creds != current_cred())\n\t\t\tcreds = override_creds(ctx->sq_creds);\n\n\t\tmutex_lock(&ctx->uring_lock);\n\t\tif (!list_empty(&ctx->iopoll_list))\n\t\t\tio_do_iopoll(ctx, &nr_events, 0);\n\n\t\t\/*\n\t\t * Don't submit if refs are dying, good for io_uring_register(),\n\t\t * but also it is relied upon by io_ring_exit_work()\n\t\t *\/\n\t\tif (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)) &&\n\t\t    !(ctx->flags & IORING_SETUP_R_DISABLED))\n\t\t\tret = io_submit_sqes(ctx, to_submit);\n\t\tmutex_unlock(&ctx->uring_lock);\n\n\t\tif (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))\n\t\t\twake_up(&ctx->sqo_sq_wait);\n\t\tif (creds)\n\t\t\trevert_creds(creds);\n\t}\n\n\treturn ret;","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":225407,"func":"static void init_vdev(struct video_device *vdev, int nr)\n{\n\tMARK();\n\n#ifdef V4L2LOOPBACK_WITH_STD\n\tvdev->tvnorms = V4L2_STD_ALL;\n#endif \/* V4L2LOOPBACK_WITH_STD *\/\n\n\tvdev->vfl_type = VFL_TYPE_VIDEO;\n\tvdev->fops = &v4l2_loopback_fops;\n\tvdev->ioctl_ops = &v4l2_loopback_ioctl_ops;\n\tvdev->release = &video_device_release;\n\tvdev->minor = -1;\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)\n\tvdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT |\n\t\t\t    V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;\n#ifdef V4L2_CAP_VIDEO_M2M\n\tvdev->device_caps |= V4L2_CAP_VIDEO_M2M;\n#endif\n#endif \/* >=linux-4.7.0 *\/\n\n\tif (debug > 1)\n#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)\n\t\tvdev->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;\n#else\n\t\tvdev->dev_debug =\n\t\t\tV4L2_DEV_DEBUG_IOCTL | V4L2_DEV_DEBUG_IOCTL_ARG;\n#endif\n\n\t\t\/* since kernel-3.7, there is a new field 'vfl_dir' that has to be\n\t * set to VFL_DIR_M2M for bidirectional devices *\/\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)\n\tvdev->vfl_dir = VFL_DIR_M2M;\n#endif\n\n\tMARK();\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":466180,"func":"static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt)\n{\n\tstruct x86_emulate_ops *ops = ctxt->ops;\n\tu32 eax, ebx, ecx, edx;\n\n\t\/*\n\t * syscall should always be enabled in longmode - so only become\n\t * vendor specific (cpuid) if other modes are active...\n\t *\/\n\tif (ctxt->mode == X86EMUL_MODE_PROT64)\n\t\treturn true;\n\n\teax = 0x00000000;\n\tecx = 0x00000000;\n\tif (ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx)) {\n\t\t\/*\n\t\t * Intel (\"GenuineIntel\")\n\t\t * remark: Intel CPUs only support \"syscall\" in 64bit\n\t\t * longmode. Also an 64bit guest with a\n\t\t * 32bit compat-app running will #UD !! While this\n\t\t * behaviour can be fixed (by emulating) into AMD\n\t\t * response - CPUs of AMD can't behave like Intel.\n\t\t *\/\n\t\tif (ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx &&\n\t\t    ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx &&\n\t\t    edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx)\n\t\t\treturn false;\n\n\t\t\/* AMD (\"AuthenticAMD\") *\/\n\t\tif (ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx &&\n\t\t    ecx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx &&\n\t\t    edx == X86EMUL_CPUID_VENDOR_AuthenticAMD_edx)\n\t\t\treturn true;\n\n\t\t\/* AMD (\"AMDisbetter!\") *\/\n\t\tif (ebx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx &&\n\t\t    ecx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx &&\n\t\t    edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx)\n\t\t\treturn true;\n\t}\n\n\t\/* default: (not Intel, not AMD), apply Intel's stricter rules... *\/\n\treturn false;\n}","target":0,"code_token_length":459,"total_token_length":695,"max_tokens_setting":1024}
+{"idx":282860,"func":"int rsi_hal_load_key(struct rsi_common *common,\n\t\t     u8 *data,\n\t\t     u16 key_len,\n\t\t     u8 key_type,\n\t\t     u8 key_id,\n\t\t     u32 cipher,\n\t\t     s16 sta_id,\n\t\t     struct ieee80211_vif *vif)\n{\n\tstruct sk_buff *skb = NULL;\n\tstruct rsi_set_key *set_key;\n\tu16 key_descriptor = 0;\n\tu16 frame_len = sizeof(struct rsi_set_key);\n\n\trsi_dbg(MGMT_TX_ZONE, \"%s: Sending load key frame\\n\", __func__);\n\n\tskb = dev_alloc_skb(frame_len);\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, frame_len);\n\tset_key = (struct rsi_set_key *)skb->data;\n\n\tif (key_type == RSI_GROUP_KEY) {\n\t\tkey_descriptor = RSI_KEY_TYPE_BROADCAST;\n\t\tif (vif->type == NL80211_IFTYPE_AP)\n\t\t\tkey_descriptor |= RSI_KEY_MODE_AP;\n\t}\n\tif ((cipher == WLAN_CIPHER_SUITE_WEP40) ||\n\t    (cipher == WLAN_CIPHER_SUITE_WEP104)) {\n\t\tkey_id = 0;\n\t\tkey_descriptor |= RSI_WEP_KEY;\n\t\tif (key_len >= 13)\n\t\t\tkey_descriptor |= RSI_WEP_KEY_104;\n\t} else if (cipher != KEY_TYPE_CLEAR) {\n\t\tkey_descriptor |= RSI_CIPHER_WPA;\n\t\tif (cipher == WLAN_CIPHER_SUITE_TKIP)\n\t\t\tkey_descriptor |= RSI_CIPHER_TKIP;\n\t}\n\tkey_descriptor |= RSI_PROTECT_DATA_FRAMES;\n\tkey_descriptor |= (key_id << RSI_KEY_ID_OFFSET);\n\n\trsi_set_len_qno(&set_key->desc_dword0.len_qno,\n\t\t\t(frame_len - FRAME_DESC_SZ), RSI_WIFI_MGMT_Q);\n\tset_key->desc_dword0.frame_type = SET_KEY_REQ;\n\tset_key->key_desc = cpu_to_le16(key_descriptor);\n\tset_key->sta_id = sta_id;\n\n\tif (data) {\n\t\tif ((cipher == WLAN_CIPHER_SUITE_WEP40) ||\n\t\t    (cipher == WLAN_CIPHER_SUITE_WEP104)) {\n\t\t\tmemcpy(&set_key->key[key_id][1], data, key_len * 2);\n\t\t} else {\n\t\t\tmemcpy(&set_key->key[0][0], data, key_len);\n\t\t}\n\t\tmemcpy(set_key->tx_mic_key, &data[16], 8);\n\t\tmemcpy(set_key->rx_mic_key, &data[24], 8);\n\t} else {\n\t\tmemset(&set_key[FRAME_DESC_SZ], 0, frame_len - FRAME_DESC_SZ);\n\t}\n\n\tskb_put(skb, frame_len);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":432093,"func":"sug_filltree(spellinfo_T *spin, slang_T *slang)\n{\n    char_u\t*byts;\n    idx_T\t*idxs;\n    int\t\tdepth;\n    idx_T\tarridx[MAXWLEN];\n    int\t\tcuri[MAXWLEN];\n    char_u\ttword[MAXWLEN];\n    char_u\ttsalword[MAXWLEN];\n    int\t\tc;\n    idx_T\tn;\n    unsigned\twords_done = 0;\n    int\t\twordcount[MAXWLEN];\n\n    \/\/ We use si_foldroot for the soundfolded trie.\n    spin->si_foldroot = wordtree_alloc(spin);\n    if (spin->si_foldroot == NULL)\n\treturn FAIL;\n\n    \/\/ let tree_add_word() know we're adding to the soundfolded tree\n    spin->si_sugtree = TRUE;\n\n    \/*\n     * Go through the whole case-folded tree, soundfold each word and put it\n     * in the trie.  Bail out if the tree is empty.\n     *\/\n    byts = slang->sl_fbyts;\n    idxs = slang->sl_fidxs;\n    if (byts == NULL || idxs == NULL)\n\treturn FAIL;\n\n    arridx[0] = 0;\n    curi[0] = 1;\n    wordcount[0] = 0;\n\n    depth = 0;\n    while (depth >= 0 && !got_int)\n    {\n\tif (curi[depth] > byts[arridx[depth]])\n\t{\n\t    \/\/ Done all bytes at this node, go up one level.\n\t    idxs[arridx[depth]] = wordcount[depth];\n\t    if (depth > 0)\n\t\twordcount[depth - 1] += wordcount[depth];\n\n\t    --depth;\n\t    line_breakcheck();\n\t}\n\telse\n\t{\n\n\t    \/\/ Do one more byte at this node.\n\t    n = arridx[depth] + curi[depth];\n\t    ++curi[depth];\n\n\t    c = byts[n];\n\t    if (c == 0)\n\t    {\n\t\t\/\/ Sound-fold the word.\n\t\ttword[depth] = NUL;\n\t\tspell_soundfold(slang, tword, TRUE, tsalword);\n\n\t\t\/\/ We use the \"flags\" field for the MSB of the wordnr,\n\t\t\/\/ \"region\" for the LSB of the wordnr.\n\t\tif (tree_add_word(spin, tsalword, spin->si_foldroot,\n\t\t\t\twords_done >> 16, words_done & 0xffff,\n\t\t\t\t\t\t\t   0) == FAIL)\n\t\t    return FAIL;\n\n\t\t++words_done;\n\t\t++wordcount[depth];\n\n\t\t\/\/ Reset the block count each time to avoid compression\n\t\t\/\/ kicking in.\n\t\tspin->si_blocks_cnt = 0;\n\n\t\t\/\/ Skip over any other NUL bytes (same word with different\n\t\t\/\/ flags).  But don't go over the end.\n\t\twhile (n + 1 < slang->sl_fbyts_len && byts[n + 1] == 0)\n\t\t{\n\t\t    ++n;\n\t\t    ++curi[depth];\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\t\/\/ Normal char, go one level deeper.\n\t\ttword[depth++] = c;\n\t\tarridx[depth] = idxs[n];\n\t\tcuri[depth] = 1;\n\t\twordcount[depth] = 0;\n\t    }\n\t}\n    }\n\n    smsg(_(\"Total number of words: %d\"), words_done);\n\n    return OK;\n}","target":0,"code_token_length":745,"total_token_length":981,"max_tokens_setting":1024}
+{"idx":312486,"func":"ex_copen(exarg_T *eap)\n{\n    qf_info_T\t*qi;\n    qf_list_T\t*qfl;\n    int\t\theight;\n    int\t\tstatus = FAIL;\n    int\t\tlnum;\n\n    if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL)\n\treturn;\n\n    incr_quickfix_busy();\n\n    if (eap->addr_count != 0)\n\theight = eap->line2;\n    else\n\theight = QF_WINHEIGHT;\n\n    reset_VIsual_and_resel();\t\t\t\/\/ stop Visual mode\n#ifdef FEAT_GUI\n    need_mouse_correct = TRUE;\n#endif\n\n    \/\/ Find an existing quickfix window, or open a new one.\n    if (cmdmod.cmod_tab == 0)\n\tstatus = qf_goto_cwindow(qi, eap->addr_count != 0, height,\n\t\t\t\t\t\tcmdmod.cmod_split & WSP_VERT);\n    if (status == FAIL)\n\tif (qf_open_new_cwindow(qi, height) == FAIL)\n\t{\n\t    decr_quickfix_busy();\n\t    return;\n\t}\n\n    qfl = qf_get_curlist(qi);\n    qf_set_title_var(qfl);\n    \/\/ Save the current index here, as updating the quickfix buffer may free\n    \/\/ the quickfix list\n    lnum = qfl->qf_index;\n\n    \/\/ Fill the buffer with the quickfix list.\n    qf_fill_buffer(qfl, curbuf, NULL, curwin->w_id);\n\n    decr_quickfix_busy();\n\n    curwin->w_cursor.lnum = lnum;\n    curwin->w_cursor.col = 0;\n    check_cursor();\n    update_topline();\t\t\/\/ scroll to show the line\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":198743,"func":"static ptrdiff_t finderrfunc(lua_State *L)\n{\n  cTValue *frame = L->base-1, *bot = tvref(L->stack);\n  void *cf = L->cframe;\n  while (frame > bot && cf) {\n    while (cframe_nres(cframe_raw(cf)) < 0) {  \/* cframe without frame? *\/\n      if (frame >= restorestack(L, -cframe_nres(cf)))\n\tbreak;\n      if (cframe_errfunc(cf) >= 0)  \/* Error handler not inherited (-1)? *\/\n\treturn cframe_errfunc(cf);\n      cf = cframe_prev(cf);  \/* Else unwind cframe and continue searching. *\/\n      if (cf == NULL)\n\treturn 0;\n    }\n    switch (frame_typep(frame)) {\n    case FRAME_LUA:\n    case FRAME_LUAP:\n      frame = frame_prevl(frame);\n      break;\n    case FRAME_C:\n      cf = cframe_prev(cf);\n      \/* fallthrough *\/\n    case FRAME_VARG:\n      frame = frame_prevd(frame);\n      break;\n    case FRAME_CONT:\n#if LJ_HASFFI\n      if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK)\n\tcf = cframe_prev(cf);\n#endif\n      frame = frame_prevd(frame);\n      break;\n    case FRAME_CP:\n      if (cframe_canyield(cf)) return 0;\n      if (cframe_errfunc(cf) >= 0)\n\treturn cframe_errfunc(cf);\n      frame = frame_prevd(frame);\n      break;\n    case FRAME_PCALL:\n    case FRAME_PCALLH:\n      if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue)))  \/* xpcall? *\/\n\treturn savestack(L, frame-1);  \/* Point to xpcall's errorfunc. *\/\n      return 0;\n    default:\n      lua_assert(0);\n      return 0;\n    }\n  }\n  return 0;\n}","target":1,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":234831,"func":"int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)\n{\n\tstruct btrfs_path *path;\n\tstruct btrfs_root *root = fs_info->dev_root;\n\tstruct btrfs_key key;\n\tu64 prev_devid = 0;\n\tu64 prev_dev_ext_end = 0;\n\tint ret = 0;\n\n\t\/*\n\t * We don't have a dev_root because we mounted with ignorebadroots and\n\t * failed to load the root, so we want to skip the verification in this\n\t * case for sure.\n\t *\n\t * However if the dev root is fine, but the tree itself is corrupted\n\t * we'd still fail to mount.  This verification is only to make sure\n\t * writes can happen safely, so instead just bypass this check\n\t * completely in the case of IGNOREBADROOTS.\n\t *\/\n\tif (btrfs_test_opt(fs_info, IGNOREBADROOTS))\n\t\treturn 0;\n\n\tkey.objectid = 1;\n\tkey.type = BTRFS_DEV_EXTENT_KEY;\n\tkey.offset = 0;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tpath->reada = READA_FORWARD;\n\tret = btrfs_search_slot(NULL, root, &key, path, 0, 0);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tif (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {\n\t\tret = btrfs_next_leaf(root, path);\n\t\tif (ret < 0)\n\t\t\tgoto out;\n\t\t\/* No dev extents at all? Not good *\/\n\t\tif (ret > 0) {\n\t\t\tret = -EUCLEAN;\n\t\t\tgoto out;\n\t\t}\n\t}\n\twhile (1) {\n\t\tstruct extent_buffer *leaf = path->nodes[0];\n\t\tstruct btrfs_dev_extent *dext;\n\t\tint slot = path->slots[0];\n\t\tu64 chunk_offset;\n\t\tu64 physical_offset;\n\t\tu64 physical_len;\n\t\tu64 devid;\n\n\t\tbtrfs_item_key_to_cpu(leaf, &key, slot);\n\t\tif (key.type != BTRFS_DEV_EXTENT_KEY)\n\t\t\tbreak;\n\t\tdevid = key.objectid;\n\t\tphysical_offset = key.offset;\n\n\t\tdext = btrfs_item_ptr(leaf, slot, struct btrfs_dev_extent);\n\t\tchunk_offset = btrfs_dev_extent_chunk_offset(leaf, dext);\n\t\tphysical_len = btrfs_dev_extent_length(leaf, dext);\n\n\t\t\/* Check if this dev extent overlaps with the previous one *\/\n\t\tif (devid == prev_devid && physical_offset < prev_dev_ext_end) {\n\t\t\tbtrfs_err(fs_info,\n\"dev extent devid %llu physical offset %llu overlap with previous dev extent end %llu\",\n\t\t\t\t  devid, physical_offset, prev_dev_ext_end);\n\t\t\tret = -EUCLEAN;\n\t\t\tgoto out;\n\t\t}\n\n\t\tret = verify_one_dev_extent(fs_info, chunk_offset, devid,\n\t\t\t\t\t    physical_offset, physical_len);\n\t\tif (ret < 0)\n\t\t\tgoto out;\n\t\tprev_devid = devid;\n\t\tprev_dev_ext_end = physical_offset + physical_len;\n\n\t\tret = btrfs_next_item(root, path);\n\t\tif (ret < 0)\n\t\t\tgoto out;\n\t\tif (ret > 0) {\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* Ensure all chunks have corresponding dev extents *\/\n\tret = verify_chunk_dev_extent_mapping(fs_info);\nout:\n\tbtrfs_free_path(path);\n\treturn ret;\n}","target":0,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":218966,"func":"bool ConstantFolding::ForwardInputs(NodeDef* node,\n                                    absl::Span<const int> inputs_to_forward) {\n  for (int input_idx : inputs_to_forward) {\n    if (input_idx < 0 || input_idx >= node->input_size()) {\n      return false;\n    }\n  }\n\n  const auto& tmp = node_map_->GetOutputs(node->name());\n  const std::vector<NodeDef*> consumers(tmp.begin(), tmp.end());\n  bool updated_graph = false;\n  for (int input_idx : inputs_to_forward) {\n    const string& input = node->input(input_idx);\n    if (IsControlInput(input) && consumers.size() > 1) {\n      continue;\n    }\n    const NodeDef* input_node = node_map_->GetNode(NodeName(input));\n    if (input_node == nullptr) {\n      LOG(ERROR) << \"Bad input: \" << input;\n      break;\n    }\n    \/\/ Update each consumer.\n    for (NodeDef* consumer : consumers) {\n      bool add_dep = false;\n      for (int consumer_input_idx = 0;\n           consumer_input_idx < consumer->input_size(); ++consumer_input_idx) {\n        const string& consumer_input = consumer->input(consumer_input_idx);\n        if (IsControlInput(consumer_input)) {\n          break;\n        }\n        \/\/ It is illegal to add control dependencies to _Retval nodes, so we\n        \/\/ can't bypass value producing `node` and forward inputs to `consumer`.\n        if (IsRetval(*consumer)) {\n          break;\n        }\n        int output_idx;\n        const string input_node_name =\n            ParseNodeName(consumer_input, &output_idx);\n        if (input_node_name == node->name() && output_idx == input_idx) {\n          consumer->set_input(consumer_input_idx, input);\n          \/\/ We will keep the input from the node through a control\n          \/\/ dependency, so we only need to add the consumer as an output\n          \/\/ for the input node.\n          node_map_->AddOutput(NodeName(input), consumer->name());\n          add_dep = true;\n        }\n      }\n      if (add_dep) {\n        consumer->add_input(AsControlDependency(node->name()));\n        updated_graph = true;\n      }\n    }\n  }\n\n  if (updated_graph) {\n    for (NodeDef* consumer : consumers) {\n      DedupControlInputs(consumer);\n    }\n  }\n  return updated_graph;\n}","target":0,"code_token_length":505,"total_token_length":741,"max_tokens_setting":1024}
+{"idx":328902,"func":"R_API RBinSymbol *r_bin_java_create_new_symbol_from_field(RBinJavaField *fm_type, ut64 baddr) {\n\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\tif (!fm_type || !fm_type->field_ref_cp_obj || fm_type->field_ref_cp_obj == &R_BIN_JAVA_NULL_TYPE) {\n\t\tR_FREE (sym);\n\t}\n\tif (sym) {\n\t\tsym->name = strdup (fm_type->name);\n\t\t\/\/ strncpy (sym->type, fm_type->descriptor, R_BIN_SIZEOF_STRINGS);\n\t\tif (fm_type->type == R_BIN_JAVA_FIELD_TYPE_METHOD) {\n\t\t\tsym->type = R_BIN_TYPE_FUNC_STR;\n\t\t\tsym->paddr = r_bin_java_get_method_code_offset (fm_type);\n\t\t\tsym->vaddr = r_bin_java_get_method_code_offset (fm_type) + baddr;\n\t\t\tsym->size = r_bin_java_get_method_code_size (fm_type);\n\t\t} else {\n\t\t\tsym->type = \"FIELD\";\n\t\t\tsym->paddr = fm_type->file_offset;\/\/ r_bin_java_get_method_code_offset (fm_type);\n\t\t\tsym->vaddr = fm_type->file_offset + baddr;\n\t\t\tsym->size = fm_type->size;\n\t\t}\n\t\tif (r_bin_java_is_fm_type_protected (fm_type)) {\n\t\t\tsym->bind = R_BIN_BIND_LOCAL_STR;\n\t\t} else if (r_bin_java_is_fm_type_private (fm_type)) {\n\t\t\tsym->bind = R_BIN_BIND_LOCAL_STR;\n\t\t} else if (r_bin_java_is_fm_type_protected (fm_type)) {\n\t\t\tsym->bind = R_BIN_BIND_GLOBAL_STR;\n\t\t}\n\t\tsym->forwarder = \"NONE\";\n\t\tif (fm_type->class_name) {\n\t\t\tsym->classname = strdup (fm_type->class_name);\n\t\t} else {\n\t\t\tsym->classname = strdup (\"UNKNOWN\"); \/\/ dupped names?\n\t\t}\n\t\tsym->ordinal = fm_type->metas->ord;\n\t\tsym->visibility = fm_type->flags;\n\t\tif (fm_type->flags_str) {\n\t\t\tsym->visibility_str = strdup (fm_type->flags_str);\n\t\t}\n\t}\n\treturn sym;\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":270117,"func":"TfLiteStatus CalculateShapeForBroadcast(TfLiteContext* context,\n                                        const TfLiteTensor* input1,\n                                        const TfLiteTensor* input2,\n                                        const TfLiteTensor* input3,\n                                        TfLiteIntArray** output_shape) {\n  const int dims1 = NumDimensions(input1);\n  const int dims2 = NumDimensions(input2);\n  const int dims3 = NumDimensions(input3);\n  const int out_dims = std::max(std::max(dims1, dims2), dims3);\n  std::unique_ptr<TfLiteIntArray, void (*)(TfLiteIntArray*)> shape(\n      TfLiteIntArrayCreate(out_dims), TfLiteIntArrayFree);\n  for (int i = 0; i < out_dims; ++i) {\n    const int d1 = i >= dims1 ? 1 : SizeOfDimension(input1, dims1 - i - 1);\n    const int d2 = i >= dims2 ? 1 : SizeOfDimension(input2, dims2 - i - 1);\n    const int d3 = i >= dims3 ? 1 : SizeOfDimension(input3, dims3 - i - 1);\n    const int min_value = std::min(std::min(d1, d2), d3);\n    int max_value = std::max(std::max(d1, d2), d3);\n    \/\/ If one dimention is 0, others must be 0 or 1.\n    if (min_value == 0) max_value = 0;\n    if (!(d1 == 1 || d1 == max_value) || !(d2 == 1 || d2 == max_value) ||\n        !(d3 == 1 || d3 == max_value)) {\n      context->ReportError(\n          context, \"Given shapes, %s, %s and %s, are not broadcastable.\",\n          GetShapeDebugString(input1->dims).c_str(),\n          GetShapeDebugString(input2->dims).c_str(),\n          GetShapeDebugString(input3->dims).c_str());\n      return kTfLiteError;\n    }\n    shape->data[out_dims - i - 1] = max_value;\n  }\n  *output_shape = shape.release();\n  return kTfLiteOk;\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":195082,"func":"void recalc_intercepts(struct vcpu_svm *svm)\n{\n\tstruct vmcb_control_area *c, *h, *g;\n\tunsigned int i;\n\n\tvmcb_mark_dirty(svm->vmcb, VMCB_INTERCEPTS);\n\n\tif (!is_guest_mode(&svm->vcpu))\n\t\treturn;\n\n\tc = &svm->vmcb->control;\n\th = &svm->vmcb01.ptr->control;\n\tg = &svm->nested.ctl;\n\n\tfor (i = 0; i < MAX_INTERCEPT; i++)\n\t\tc->intercepts[i] = h->intercepts[i];\n\n\tif (g->int_ctl & V_INTR_MASKING_MASK) {\n\t\t\/* We only want the cr8 intercept bits of L1 *\/\n\t\tvmcb_clr_intercept(c, INTERCEPT_CR8_READ);\n\t\tvmcb_clr_intercept(c, INTERCEPT_CR8_WRITE);\n\n\t\t\/*\n\t\t * Once running L2 with HF_VINTR_MASK, EFLAGS.IF does not\n\t\t * affect any interrupt we may want to inject; therefore,\n\t\t * interrupt window vmexits are irrelevant to L0.\n\t\t *\/\n\t\tvmcb_clr_intercept(c, INTERCEPT_VINTR);\n\t}\n\n\t\/* We don't want to see VMMCALLs from a nested guest *\/\n\tvmcb_clr_intercept(c, INTERCEPT_VMMCALL);\n\n\tfor (i = 0; i < MAX_INTERCEPT; i++)\n\t\tc->intercepts[i] |= g->intercepts[i];\n\n\t\/* If SMI is not intercepted, ignore guest SMI intercept as well  *\/\n\tif (!intercept_smi)\n\t\tvmcb_clr_intercept(c, INTERCEPT_SMI);\n}","target":1,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":513367,"func":"static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,\n\t\t\t\t   Item *having)\n{\n  handler *file=table->file;\n  uchar *record=table->record[0];\n  int error;\n  DBUG_ENTER(\"remove_dup_with_compare\");\n\n  if (file->ha_rnd_init_with_error(1))\n    DBUG_RETURN(1);\n\n  error= file->ha_rnd_next(record);\n  for (;;)\n  {\n    if (thd->check_killed())\n    {\n      thd->send_kill_message();\n      error=0;\n      goto err;\n    }\n    if (error)\n    {\n      if (error == HA_ERR_RECORD_DELETED)\n      {\n        error= file->ha_rnd_next(record);\n        continue;\n      }\n      if (error == HA_ERR_END_OF_FILE)\n\tbreak;\n      goto err;\n    }\n    if (having && !having->val_int())\n    {\n      if ((error= file->ha_delete_row(record)))\n\tgoto err;\n      error= file->ha_rnd_next(record);\n      continue;\n    }\n    if (copy_blobs(first_field))\n    {\n      my_message(ER_OUTOFMEMORY, ER_THD(thd,ER_OUTOFMEMORY),\n                 MYF(ME_FATALERROR));\n      error=0;\n      goto err;\n    }\n    store_record(table,record[1]);\n\n    \/* Read through rest of file and mark duplicated rows deleted *\/\n    bool found=0;\n    for (;;)\n    {\n      if ((error= file->ha_rnd_next(record)))\n      {\n\tif (error == HA_ERR_RECORD_DELETED)\n\t  continue;\n\tif (error == HA_ERR_END_OF_FILE)\n\t  break;\n\tgoto err;\n      }\n      if (compare_record(table, first_field) == 0)\n      {\n\tif ((error= file->ha_delete_row(record)))\n\t  goto err;\n      }\n      else if (!found)\n      {\n\tfound=1;\n        if ((error= file->remember_rnd_pos()))\n          goto err;\n      }\n    }\n    if (!found)\n      break;\t\t\t\t\t\/\/ End of file\n    \/* Restart search on saved row *\/\n    if ((error= file->restart_rnd_next(record)))\n      goto err;\n  }\n\n  file->extra(HA_EXTRA_NO_CACHE);\n  (void) file->ha_rnd_end();\n  DBUG_RETURN(0);\nerr:\n  file->extra(HA_EXTRA_NO_CACHE);\n  (void) file->ha_rnd_end();\n  if (error)\n    file->print_error(error,MYF(0));\n  DBUG_RETURN(1);\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":245154,"func":"char *make_argv(char *buf, size_t len, int argc, char **argv)\n{\n\tsize_t left= len;\n\tconst char *arg;\n\n\tbuf[0]= 0;\n\t++argv; --argc;\n\twhile (argc > 0 && left > 0)\n\t{\n\t\targ = *argv;\n\t\tif (strncmp(*argv, \"--password\", strlen(\"--password\")) == 0) {\n\t\t\targ = \"--password=...\";\n\t\t}\n\t\tif (strncmp(*argv, \"-p\", strlen(\"-p\")) == 0) {\n\t\t\targ = \"-p...\";\n\t\t}\n\t\tif (strncmp(*argv, \"--encrypt-key\",\n\t\t\t\tstrlen(\"--encrypt-key\")) == 0) {\n\t\t\targ = \"--encrypt-key=...\";\n\t\t}\n\t\tif (strncmp(*argv, \"--encrypt_key\",\n\t\t\t\tstrlen(\"--encrypt_key\")) == 0) {\n\t\t\targ = \"--encrypt_key=...\";\n\t\t}\n\t\tif (strncmp(*argv, \"--transition-key\",\n\t\t\t\tstrlen(\"--transition-key\")) == 0) {\n\t\t\targ = \"--transition-key=...\";\n\t\t}\n\t\tif (strncmp(*argv, \"--transition_key\",\n\t\t\t\tstrlen(\"--transition_key\")) == 0) {\n\t\t\targ = \"--transition_key=...\";\n\t\t}\n\t\tleft-= ut_snprintf(buf + len - left, left,\n\t\t\t\"%s%c\", arg, argc > 1 ? ' ' : 0);\n\t\t++argv; --argc;\n\t}\n\n\treturn buf;\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":450402,"func":"VncInfo2List *qmp_query_vnc_servers(Error **errp)\n{\n    VncInfo2List *item, *prev = NULL;\n    VncInfo2 *info;\n    VncDisplay *vd;\n    DeviceState *dev;\n    size_t i;\n\n    QTAILQ_FOREACH(vd, &vnc_displays, next) {\n        info = g_new0(VncInfo2, 1);\n        info->id = g_strdup(vd->id);\n        info->clients = qmp_query_client_list(vd);\n        qmp_query_auth(vd->auth, vd->subauth, &info->auth,\n                       &info->vencrypt, &info->has_vencrypt);\n        if (vd->dcl.con) {\n            dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),\n                                                  \"device\", NULL));\n            info->has_display = true;\n            info->display = g_strdup(dev->id);\n        }\n        for (i = 0; vd->listener != NULL && i < vd->listener->nsioc; i++) {\n            info->server = qmp_query_server_entry(\n                vd->listener->sioc[i], false, vd->auth, vd->subauth,\n                info->server);\n        }\n        for (i = 0; vd->wslistener != NULL && i < vd->wslistener->nsioc; i++) {\n            info->server = qmp_query_server_entry(\n                vd->wslistener->sioc[i], true, vd->ws_auth,\n                vd->ws_subauth, info->server);\n        }\n\n        item = g_new0(VncInfo2List, 1);\n        item->value = info;\n        item->next = prev;\n        prev = item;\n    }\n    return prev;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":294489,"func":"date_initialize(int argc, VALUE *argv, VALUE self)\n{\n    VALUE vy, vm, vd, vsg, y, fr, fr2, ret;\n    int m, d;\n    double sg;\n    struct SimpleDateData *dat = rb_check_typeddata(self, &d_lite_type);\n\n    if (!simple_dat_p(dat)) {\n\trb_raise(rb_eTypeError, \"Date expected\");\n    }\n\n    rb_scan_args(argc, argv, \"04\", &vy, &vm, &vd, &vsg);\n\n    y = INT2FIX(-4712);\n    m = 1;\n    d = 1;\n    fr2 = INT2FIX(0);\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 4:\n\tval2sg(vsg, sg);\n      case 3:\n        check_numeric(vd, \"day\");\n\tnum2int_with_frac(d, positive_inf);\n      case 2:\n        check_numeric(vm, \"month\");\n\tm = NUM2INT(vm);\n      case 1:\n        check_numeric(vy, \"year\");\n\ty = vy;\n    }\n\n    if (guess_style(y, sg) < 0) {\n\tVALUE nth;\n\tint ry, rm, rd;\n\n\tif (!valid_gregorian_p(y, m, d,\n\t\t\t       &nth, &ry,\n\t\t\t       &rm, &rd))\n\t    rb_raise(eDateError, \"invalid date\");\n\n\tset_to_simple(self, dat, nth, 0, sg, ry, rm, rd, HAVE_CIVIL);\n    }\n    else {\n\tVALUE nth;\n\tint ry, rm, rd, rjd, ns;\n\n\tif (!valid_civil_p(y, m, d, sg,\n\t\t\t   &nth, &ry,\n\t\t\t   &rm, &rd, &rjd,\n\t\t\t   &ns))\n\t    rb_raise(eDateError, \"invalid date\");\n\n\tset_to_simple(self, dat, nth, rjd, sg, ry, rm, rd, HAVE_JD | HAVE_CIVIL);\n    }\n    ret = self;\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":225405,"func":"static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)\n{\n\tstruct v4l2_loopback_device *dev;\n\tstruct v4l2_loopback_opener *opener;\n\tint index;\n\tstruct v4l2l_buffer *b;\n\n\tdev = v4l2loopback_getdevice(file);\n\topener = fh_to_opener(fh);\n\tif (opener->timeout_image_io) {\n\t\t*buf = dev->timeout_image_buffer.buffer;\n\t\treturn 0;\n\t}\n\n\tswitch (buf->type) {\n\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n\t\tindex = get_capture_buffer(file);\n\t\tif (index < 0)\n\t\t\treturn index;\n\t\tdprintkrw(\"capture DQBUF pos: %d index: %d\\n\",\n\t\t\t  opener->read_position - 1, index);\n\t\tif (!(dev->buffers[index].buffer.flags &\n\t\t      V4L2_BUF_FLAG_MAPPED)) {\n\t\t\tdprintk(\"trying to return not mapped buf[%d]\\n\", index);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tunset_flags(&dev->buffers[index]);\n\t\t*buf = dev->buffers[index].buffer;\n\t\treturn 0;\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n\t\tb = list_entry(dev->outbufs_list.prev, struct v4l2l_buffer,\n\t\t\t       list_head);\n\t\tlist_move_tail(&b->list_head, &dev->outbufs_list);\n\t\tdprintkrw(\"output DQBUF index: %d\\n\", b->buffer.index);\n\t\tunset_flags(b);\n\t\t*buf = b->buffer;\n\t\tbuf->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":279943,"func":"ex_align(exarg_T *eap)\n{\n    pos_T\tsave_curpos;\n    int\t\tlen;\n    int\t\tindent = 0;\n    int\t\tnew_indent;\n    int\t\thas_tab;\n    int\t\twidth;\n\n#ifdef FEAT_RIGHTLEFT\n    if (curwin->w_p_rl)\n    {\n\t\/\/ switch left and right aligning\n\tif (eap->cmdidx == CMD_right)\n\t    eap->cmdidx = CMD_left;\n\telse if (eap->cmdidx == CMD_left)\n\t    eap->cmdidx = CMD_right;\n    }\n#endif\n\n    width = atoi((char *)eap->arg);\n    save_curpos = curwin->w_cursor;\n    if (eap->cmdidx == CMD_left)    \/\/ width is used for new indent\n    {\n\tif (width >= 0)\n\t    indent = width;\n    }\n    else\n    {\n\t\/*\n\t * if 'textwidth' set, use it\n\t * else if 'wrapmargin' set, use it\n\t * if invalid value, use 80\n\t *\/\n\tif (width <= 0)\n\t    width = curbuf->b_p_tw;\n\tif (width == 0 && curbuf->b_p_wm > 0)\n\t    width = curwin->w_width - curbuf->b_p_wm;\n\tif (width <= 0)\n\t    width = 80;\n    }\n\n    if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL)\n\treturn;\n\n    for (curwin->w_cursor.lnum = eap->line1;\n\t\t curwin->w_cursor.lnum <= eap->line2; ++curwin->w_cursor.lnum)\n    {\n\tif (eap->cmdidx == CMD_left)\t\t\/\/ left align\n\t    new_indent = indent;\n\telse\n\t{\n\t    has_tab = FALSE;\t\/\/ avoid uninit warnings\n\t    len = linelen(eap->cmdidx == CMD_right ? &has_tab\n\t\t\t\t\t\t   : NULL) - get_indent();\n\n\t    if (len <= 0)\t\t\t\/\/ skip blank lines\n\t\tcontinue;\n\n\t    if (eap->cmdidx == CMD_center)\n\t\tnew_indent = (width - len) \/ 2;\n\t    else\n\t    {\n\t\tnew_indent = width - len;\t\/\/ right align\n\n\t\t\/*\n\t\t * Make sure that embedded TABs don't make the text go too far\n\t\t * to the right.\n\t\t *\/\n\t\tif (has_tab)\n\t\t    while (new_indent > 0)\n\t\t    {\n\t\t\t(void)set_indent(new_indent, 0);\n\t\t\tif (linelen(NULL) <= width)\n\t\t\t{\n\t\t\t    \/*\n\t\t\t     * Now try to move the line as much as possible to\n\t\t\t     * the right.  Stop when it moves too far.\n\t\t\t     *\/\n\t\t\t    do\n\t\t\t\t(void)set_indent(++new_indent, 0);\n\t\t\t    while (linelen(NULL) <= width);\n\t\t\t    --new_indent;\n\t\t\t    break;\n\t\t\t}\n\t\t\t--new_indent;\n\t\t    }\n\t    }\n\t}\n\tif (new_indent < 0)\n\t    new_indent = 0;\n\t(void)set_indent(new_indent, 0);\t\t\/\/ set indent\n    }\n    changed_lines(eap->line1, 0, eap->line2 + 1, 0L);\n    curwin->w_cursor = save_curpos;\n    beginline(BL_WHITE | BL_FIX);\n}","target":0,"code_token_length":733,"total_token_length":969,"max_tokens_setting":1024}
+{"idx":254724,"func":"njs_typed_array_generic_compare(const void *a, const void *b, void *c)\n{\n    double                      num;\n    njs_int_t                   ret;\n    njs_value_t                 arguments[3], retval;\n    njs_typed_array_sort_ctx_t  *ctx;\n\n    ctx = c;\n\n    if (njs_slow_path(ctx->exception)) {\n        return 0;\n    }\n\n    njs_set_undefined(&arguments[0]);\n    njs_set_number(&arguments[1], ctx->get(a));\n    njs_set_number(&arguments[2], ctx->get(b));\n\n    ret = njs_function_apply(ctx->vm, ctx->function, arguments, 3, &retval);\n    if (njs_slow_path(ret != NJS_OK)) {\n        goto exception;\n    }\n\n    ret = njs_value_to_number(ctx->vm, &retval, &num);\n    if (njs_slow_path(ret != NJS_OK)) {\n        goto exception;\n    }\n\n    if (njs_slow_path(njs_is_detached_buffer(ctx->buffer))) {\n        njs_type_error(ctx->vm, \"detached buffer\");\n        goto exception;\n    }\n\n    if (njs_slow_path(isnan(num))) {\n        return 0;\n    }\n\n    if (num != 0) {\n        return (num > 0) - (num < 0);\n    }\n\n    return 0;\n\nexception:\n\n    ctx->exception = 1;\n\n    return 0;\n}","target":0,"code_token_length":310,"total_token_length":546,"max_tokens_setting":1024}
+{"idx":512560,"func":"void Item_equal::add_const(THD *thd, Item *c)\n{\n  if (cond_false)\n    return;\n  if (!with_const)\n  {\n    with_const= TRUE;\n    equal_items.push_front(c, thd->mem_root);\n    return;\n  }\n\n  \/*\n    Suppose we have an expression (with a string type field) like this:\n      WHERE field=const1 AND field=const2 ...\n\n    For all pairs field=constXXX we know that:\n\n    - Item_func_eq::fix_length_and_dec() performed collation and character\n    set aggregation and added character set converters when needed.\n    Note, the case like:\n      WHERE field=const1 COLLATE latin1_bin AND field=const2\n    is not handled here, because the field would be replaced to\n    Item_func_set_collation, which cannot get into Item_equal.\n    So all constXXX that are handled by Item_equal\n    already have compatible character sets with \"field\".\n\n    - Also, Field_str::test_if_equality_guarantees_uniqueness() guarantees\n    that the comparison collation of all equalities handled by Item_equal\n    match the the collation of the field.\n\n    Therefore, at Item_equal::add_const() time all constants constXXX\n    should be directly comparable to each other without an additional\n    character set conversion.\n    It's safe to do val_str() for \"const_item\" and \"c\" and compare\n    them according to the collation of the *field*.\n\n    So in a script like this:\n      CREATE TABLE t1 (a VARCHAR(10) COLLATE xxx);\n      INSERT INTO t1 VALUES ('a'),('A');\n      SELECT * FROM t1 WHERE a='a' AND a='A';\n    Item_equal::add_const() effectively rewrites the condition to:\n      SELECT * FROM t1 WHERE a='a' AND 'a' COLLATE xxx='A';\n    and then to:\n      SELECT * FROM t1 WHERE a='a'; \/\/ if the two constants were equal\n                                    \/\/ e.g. in case of latin1_swedish_ci\n    or to:\n      SELECT * FROM t1 WHERE FALSE; \/\/ if the two constants were not equal\n                                    \/\/ e.g. in case of latin1_bin\n\n    Note, both \"const_item\" and \"c\" can return NULL, e.g.:\n      SELECT * FROM t1 WHERE a=NULL    AND a='const';\n      SELECT * FROM t1 WHERE a='const' AND a=NULL;\n      SELECT * FROM t1 WHERE a='const' AND a=(SELECT MAX(a) FROM t2)\n  *\/\n\n  cond_false= !Item_equal::compare_type_handler()->Item_eq_value(thd, this, c,\n                                                                 get_const());\n  if (with_const && equal_items.elements == 1)\n    cond_true= TRUE;\n  if (cond_false || cond_true)\n    const_item_cache= 1;\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":408968,"func":"bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)\n{\n    int\t\tc;\n    char_u\tbuf[NUMBUFLEN + MB_MAXBYTES];\n    int\t\tidx = 0;\n    char_u\t*end = find_termcode((char_u *)\"PE\");\n    int\t\tret_char = -1;\n    int\t\tsave_allow_keys = allow_keys;\n    int\t\tsave_paste = p_paste;\n\n    \/\/ If the end code is too long we can't detect it, read everything.\n    if (end != NULL && STRLEN(end) >= NUMBUFLEN)\n\tend = NULL;\n    ++no_mapping;\n    allow_keys = 0;\n    if (!p_paste)\n\t\/\/ Also have the side effects of setting 'paste' to make it work much\n\t\/\/ faster.\n\tset_option_value((char_u *)\"paste\", TRUE, NULL, 0);\n\n    for (;;)\n    {\n\t\/\/ When the end is not defined read everything there is.\n\tif (end == NULL && vpeekc() == NUL)\n\t    break;\n\tdo\n\t    c = vgetc();\n\twhile (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);\n\tif (c == NUL || got_int || (ex_normal_busy > 0 && c == Ctrl_C))\n\t    \/\/ When CTRL-C was encountered the typeahead will be flushed and we\n\t    \/\/ won't get the end sequence.  Except when using \":normal\".\n\t    break;\n\n\tif (has_mbyte)\n\t    idx += (*mb_char2bytes)(c, buf + idx);\n\telse\n\t    buf[idx++] = c;\n\tbuf[idx] = NUL;\n\tif (end != NULL && STRNCMP(buf, end, idx) == 0)\n\t{\n\t    if (end[idx] == NUL)\n\t\tbreak; \/\/ Found the end of paste code.\n\t    continue;\n\t}\n\tif (!drop)\n\t{\n\t    switch (mode)\n\t    {\n\t\tcase PASTE_CMDLINE:\n\t\t    put_on_cmdline(buf, idx, TRUE);\n\t\t    break;\n\n\t\tcase PASTE_EX:\n\t\t    \/\/ add one for the NUL that is going to be appended\n\t\t    if (gap != NULL && ga_grow(gap, idx + 1) == OK)\n\t\t    {\n\t\t\tmch_memmove((char *)gap->ga_data + gap->ga_len,\n\t\t\t\t\t\t\t     buf, (size_t)idx);\n\t\t\tgap->ga_len += idx;\n\t\t    }\n\t\t    break;\n\n\t\tcase PASTE_INSERT:\n\t\t    if (stop_arrow() == OK)\n\t\t    {\n\t\t\tc = buf[0];\n\t\t\tif (idx == 1 && (c == CAR || c == K_KENTER || c == NL))\n\t\t\t    ins_eol(c);\n\t\t\telse\n\t\t\t{\n\t\t\t    ins_char_bytes(buf, idx);\n\t\t\t    AppendToRedobuffLit(buf, idx);\n\t\t\t}\n\t\t    }\n\t\t    break;\n\n\t\tcase PASTE_ONE_CHAR:\n\t\t    if (ret_char == -1)\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t    ret_char = (*mb_ptr2char)(buf);\n\t\t\telse\n\t\t\t    ret_char = buf[0];\n\t\t    }\n\t\t    break;\n\t    }\n\t}\n\tidx = 0;\n    }\n\n    --no_mapping;\n    allow_keys = save_allow_keys;\n    if (!save_paste)\n\tset_option_value((char_u *)\"paste\", FALSE, NULL, 0);\n\n    return ret_char;\n}","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":353146,"func":"bool SplashOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading) {\n  SplashFunctionPattern *pattern = new SplashFunctionPattern(colorMode, state, shading);\n  double xMin, yMin, xMax, yMax;\n  bool vaa = getVectorAntialias();\n  \/\/ restore vector antialias because we support it here\n  setVectorAntialias(true);\n\n  bool retVal = false;\n  \/\/ get the clip region bbox\n  if (pattern->getShading()->getHasBBox()) {\n    pattern->getShading()->getBBox(&xMin, &yMin, &xMax, &yMax);\n  } else {\n    state->getClipBBox(&xMin, &yMin, &xMax, &yMax);\n\n    xMin = floor (xMin);\n    yMin = floor (yMin);\n    xMax = ceil (xMax);\n    yMax = ceil (yMax);\n\n    {\n      Matrix ctm, ictm;\n      double x[4], y[4];\n      int i;\n\n      state->getCTM(&ctm);\n      ctm.invertTo(&ictm);\n\n      ictm.transform(xMin, yMin, &x[0], &y[0]);\n      ictm.transform(xMax, yMin, &x[1], &y[1]);\n      ictm.transform(xMin, yMax, &x[2], &y[2]);\n      ictm.transform(xMax, yMax, &x[3], &y[3]);\n\n      xMin = xMax = x[0];\n      yMin = yMax = y[0];\n      for (i = 1; i < 4; i++) {\n        xMin = std::min<double>(xMin, x[i]);\n        yMin = std::min<double>(yMin, y[i]);\n        xMax = std::max<double>(xMax, x[i]);\n        yMax = std::max<double>(yMax, y[i]);\n      }\n    }\n  }\n\n  \/\/ fill the region\n  state->moveTo(xMin, yMin);\n  state->lineTo(xMax, yMin);\n  state->lineTo(xMax, yMax);\n  state->lineTo(xMin, yMax);\n  state->closePath();\n  SplashPath path = convertPath(state, state->getPath(), true);\n\n#ifdef SPLASH_CMYK\n  pattern->getShading()->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS);\n#endif\n  setOverprintMask(pattern->getShading()->getColorSpace(), state->getFillOverprint(),\n\t\t   state->getOverprintMode(), nullptr);\n  retVal = (splash->shadedFill(&path, pattern->getShading()->getHasBBox(), pattern) == splashOk);\n  state->clearPath();\n  setVectorAntialias(vaa);\n\n  delete pattern;\n\n  return retVal;\n}","target":0,"code_token_length":625,"total_token_length":861,"max_tokens_setting":1024}
+{"idx":300733,"func":"int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb)\n{\n\tint err;\n\tu32 tsk_portid = cb->args[0];\n\tu32 last_publ = cb->args[1];\n\tu32 done = cb->args[2];\n\tstruct net *net = sock_net(skb->sk);\n\tstruct tipc_sock *tsk;\n\n\tif (!tsk_portid) {\n\t\tstruct nlattr **attrs = genl_dumpit_info(cb)->attrs;\n\t\tstruct nlattr *sock[TIPC_NLA_SOCK_MAX + 1];\n\n\t\tif (!attrs[TIPC_NLA_SOCK])\n\t\t\treturn -EINVAL;\n\n\t\terr = nla_parse_nested_deprecated(sock, TIPC_NLA_SOCK_MAX,\n\t\t\t\t\t\t  attrs[TIPC_NLA_SOCK],\n\t\t\t\t\t\t  tipc_nl_sock_policy, NULL);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (!sock[TIPC_NLA_SOCK_REF])\n\t\t\treturn -EINVAL;\n\n\t\ttsk_portid = nla_get_u32(sock[TIPC_NLA_SOCK_REF]);\n\t}\n\n\tif (done)\n\t\treturn 0;\n\n\ttsk = tipc_sk_lookup(net, tsk_portid);\n\tif (!tsk)\n\t\treturn -EINVAL;\n\n\tlock_sock(&tsk->sk);\n\terr = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ);\n\tif (!err)\n\t\tdone = 1;\n\trelease_sock(&tsk->sk);\n\tsock_put(&tsk->sk);\n\n\tcb->args[0] = tsk_portid;\n\tcb->args[1] = last_publ;\n\tcb->args[2] = done;\n\n\treturn skb->len;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":281094,"func":"xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,\n\t\t\t       const struct flowi *fl, u16 family,\n\t\t\t       struct dst_entry *dst_orig)\n{\n\tstruct net *net = xp_net(pols[0]);\n\tstruct xfrm_state *xfrm[XFRM_MAX_DEPTH];\n\tstruct dst_entry *dst;\n\tstruct xfrm_dst *xdst;\n\tint err;\n\n\t\/* Try to instantiate a bundle *\/\n\terr = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family);\n\tif (err <= 0) {\n\t\tif (err != 0 && err != -EAGAIN)\n\t\t\tXFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);\n\t\treturn ERR_PTR(err);\n\t}\n\n\tdst = xfrm_bundle_create(pols[0], xfrm, err, fl, dst_orig);\n\tif (IS_ERR(dst)) {\n\t\tXFRM_INC_STATS(net, LINUX_MIB_XFRMOUTBUNDLEGENERROR);\n\t\treturn ERR_CAST(dst);\n\t}\n\n\txdst = (struct xfrm_dst *)dst;\n\txdst->num_xfrms = err;\n\txdst->num_pols = num_pols;\n\tmemcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols);\n\txdst->policy_genid = atomic_read(&pols[0]->genid);\n\n\treturn xdst;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":411935,"func":"build_server_referral(krb5_context context,\n\t\t      krb5_kdc_configuration *config,\n\t\t      krb5_crypto session,\n\t\t      krb5_const_realm referred_realm,\n\t\t      const PrincipalName *true_principal_name,\n\t\t      const PrincipalName *requested_principal,\n\t\t      krb5_data *outdata)\n{\n    PA_ServerReferralData ref;\n    krb5_error_code ret;\n    EncryptedData ed;\n    krb5_data data;\n    size_t size = 0;\n\n    memset(&ref, 0, sizeof(ref));\n\n    if (referred_realm) {\n\tALLOC(ref.referred_realm);\n\tif (ref.referred_realm == NULL)\n\t    goto eout;\n\t*ref.referred_realm = strdup(referred_realm);\n\tif (*ref.referred_realm == NULL)\n\t    goto eout;\n    }\n    if (true_principal_name) {\n\tALLOC(ref.true_principal_name);\n\tif (ref.true_principal_name == NULL)\n\t    goto eout;\n\tret = copy_PrincipalName(true_principal_name, ref.true_principal_name);\n\tif (ret)\n\t    goto eout;\n    }\n    if (requested_principal) {\n\tALLOC(ref.requested_principal_name);\n\tif (ref.requested_principal_name == NULL)\n\t    goto eout;\n\tret = copy_PrincipalName(requested_principal,\n\t\t\t\t ref.requested_principal_name);\n\tif (ret)\n\t    goto eout;\n    }\n\n    ASN1_MALLOC_ENCODE(PA_ServerReferralData,\n\t\t       data.data, data.length,\n\t\t       &ref, &size, ret);\n    free_PA_ServerReferralData(&ref);\n    if (ret)\n\treturn ret;\n    if (data.length != size)\n\tkrb5_abortx(context, \"internal asn.1 encoder error\");\n\n    ret = krb5_encrypt_EncryptedData(context, session,\n\t\t\t\t     KRB5_KU_PA_SERVER_REFERRAL,\n\t\t\t\t     data.data, data.length,\n\t\t\t\t     0 \/* kvno *\/, &ed);\n    free(data.data);\n    if (ret)\n\treturn ret;\n\n    ASN1_MALLOC_ENCODE(EncryptedData,\n\t\t       outdata->data, outdata->length,\n\t\t       &ed, &size, ret);\n    free_EncryptedData(&ed);\n    if (ret)\n\treturn ret;\n    if (outdata->length != size)\n\tkrb5_abortx(context, \"internal asn.1 encoder error\");\n\n    return 0;\neout:\n    free_PA_ServerReferralData(&ref);\n    krb5_set_error_message(context, ENOMEM, \"malloc: out of memory\");\n    return ENOMEM;\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":459094,"func":"int tcf_classify(struct sk_buff *skb,\n\t\t const struct tcf_block *block,\n\t\t const struct tcf_proto *tp,\n\t\t struct tcf_result *res, bool compat_mode)\n{\n#if !IS_ENABLED(CONFIG_NET_TC_SKB_EXT)\n\tu32 last_executed_chain = 0;\n\n\treturn __tcf_classify(skb, tp, tp, res, compat_mode,\n\t\t\t      &last_executed_chain);\n#else\n\tu32 last_executed_chain = tp ? tp->chain->index : 0;\n\tconst struct tcf_proto *orig_tp = tp;\n\tstruct tc_skb_ext *ext;\n\tint ret;\n\n\tif (block) {\n\t\text = skb_ext_find(skb, TC_SKB_EXT);\n\n\t\tif (ext && ext->chain) {\n\t\t\tstruct tcf_chain *fchain;\n\n\t\t\tfchain = tcf_chain_lookup_rcu(block, ext->chain);\n\t\t\tif (!fchain)\n\t\t\t\treturn TC_ACT_SHOT;\n\n\t\t\t\/* Consume, so cloned\/redirect skbs won't inherit ext *\/\n\t\t\tskb_ext_del(skb, TC_SKB_EXT);\n\n\t\t\ttp = rcu_dereference_bh(fchain->filter_chain);\n\t\t\tlast_executed_chain = fchain->index;\n\t\t}\n\t}\n\n\tret = __tcf_classify(skb, tp, orig_tp, res, compat_mode,\n\t\t\t     &last_executed_chain);\n\n\t\/* If we missed on some chain *\/\n\tif (ret == TC_ACT_UNSPEC && last_executed_chain) {\n\t\tstruct tc_skb_cb *cb = tc_skb_cb(skb);\n\n\t\text = tc_skb_ext_alloc(skb);\n\t\tif (WARN_ON_ONCE(!ext))\n\t\t\treturn TC_ACT_SHOT;\n\t\text->chain = last_executed_chain;\n\t\text->mru = cb->mru;\n\t\text->post_ct = cb->post_ct;\n\t\text->post_ct_snat = cb->post_ct_snat;\n\t\text->post_ct_dnat = cb->post_ct_dnat;\n\t\text->zone = cb->zone;\n\t}\n\n\treturn ret;\n#endif\n}","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":300748,"func":"static int tipc_sendmcast(struct  socket *sock, struct tipc_uaddr *ua,\n\t\t\t  struct msghdr *msg, size_t dlen, long timeout)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct tipc_msg *hdr = &tsk->phdr;\n\tstruct net *net = sock_net(sk);\n\tint mtu = tipc_bcast_get_mtu(net);\n\tstruct sk_buff_head pkts;\n\tstruct tipc_nlist dsts;\n\tint rc;\n\n\tif (tsk->group)\n\t\treturn -EACCES;\n\n\t\/* Block or return if any destination link is congested *\/\n\trc = tipc_wait_for_cond(sock, &timeout, !tsk->cong_link_cnt);\n\tif (unlikely(rc))\n\t\treturn rc;\n\n\t\/* Lookup destination nodes *\/\n\ttipc_nlist_init(&dsts, tipc_own_addr(net));\n\ttipc_nametbl_lookup_mcast_nodes(net, ua, &dsts);\n\tif (!dsts.local && !dsts.remote)\n\t\treturn -EHOSTUNREACH;\n\n\t\/* Build message header *\/\n\tmsg_set_type(hdr, TIPC_MCAST_MSG);\n\tmsg_set_hdr_sz(hdr, MCAST_H_SIZE);\n\tmsg_set_lookup_scope(hdr, TIPC_CLUSTER_SCOPE);\n\tmsg_set_destport(hdr, 0);\n\tmsg_set_destnode(hdr, 0);\n\tmsg_set_nametype(hdr, ua->sr.type);\n\tmsg_set_namelower(hdr, ua->sr.lower);\n\tmsg_set_nameupper(hdr, ua->sr.upper);\n\n\t\/* Build message as chain of buffers *\/\n\t__skb_queue_head_init(&pkts);\n\trc = tipc_msg_build(hdr, msg, 0, dlen, mtu, &pkts);\n\n\t\/* Send message if build was successful *\/\n\tif (unlikely(rc == dlen)) {\n\t\ttrace_tipc_sk_sendmcast(sk, skb_peek(&pkts),\n\t\t\t\t\tTIPC_DUMP_SK_SNDQ, \" \");\n\t\trc = tipc_mcast_xmit(net, &pkts, &tsk->mc_method, &dsts,\n\t\t\t\t     &tsk->cong_link_cnt);\n\t}\n\n\ttipc_nlist_purge(&dsts);\n\n\treturn rc ? rc : dlen;\n}","target":0,"code_token_length":467,"total_token_length":703,"max_tokens_setting":1024}
+{"idx":424914,"func":"iwl_trans_pcie_dump_monitor(struct iwl_trans *trans,\n\t\t\t    struct iwl_fw_error_dump_data **data,\n\t\t\t    u32 monitor_len)\n{\n\tu32 len = 0;\n\n\tif (trans->dbg.dest_tlv ||\n\t    (trans->dbg.num_blocks &&\n\t     (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_7000 ||\n\t      trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210))) {\n\t\tstruct iwl_fw_error_dump_fw_mon *fw_mon_data;\n\n\t\t(*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_FW_MONITOR);\n\t\tfw_mon_data = (void *)(*data)->data;\n\n\t\tiwl_trans_pcie_dump_pointers(trans, fw_mon_data);\n\n\t\tlen += sizeof(**data) + sizeof(*fw_mon_data);\n\t\tif (trans->dbg.num_blocks) {\n\t\t\tmemcpy(fw_mon_data->data,\n\t\t\t       trans->dbg.fw_mon[0].block,\n\t\t\t       trans->dbg.fw_mon[0].size);\n\n\t\t\tmonitor_len = trans->dbg.fw_mon[0].size;\n\t\t} else if (trans->dbg.dest_tlv->monitor_mode == SMEM_MODE) {\n\t\t\tu32 base = le32_to_cpu(fw_mon_data->fw_mon_base_ptr);\n\t\t\t\/*\n\t\t\t * Update pointers to reflect actual values after\n\t\t\t * shifting\n\t\t\t *\/\n\t\t\tif (trans->dbg.dest_tlv->version) {\n\t\t\t\tbase = (iwl_read_prph(trans, base) &\n\t\t\t\t\tIWL_LDBG_M2S_BUF_BA_MSK) <<\n\t\t\t\t       trans->dbg.dest_tlv->base_shift;\n\t\t\t\tbase *= IWL_M2S_UNIT_SIZE;\n\t\t\t\tbase += trans->cfg->smem_offset;\n\t\t\t} else {\n\t\t\t\tbase = iwl_read_prph(trans, base) <<\n\t\t\t\t       trans->dbg.dest_tlv->base_shift;\n\t\t\t}\n\n\t\t\tiwl_trans_read_mem(trans, base, fw_mon_data->data,\n\t\t\t\t\t   monitor_len \/ sizeof(u32));\n\t\t} else if (trans->dbg.dest_tlv->monitor_mode == MARBH_MODE) {\n\t\t\tmonitor_len =\n\t\t\t\tiwl_trans_pci_dump_marbh_monitor(trans,\n\t\t\t\t\t\t\t\t fw_mon_data,\n\t\t\t\t\t\t\t\t monitor_len);\n\t\t} else {\n\t\t\t\/* Didn't match anything - output no monitor data *\/\n\t\t\tmonitor_len = 0;\n\t\t}\n\n\t\tlen += monitor_len;\n\t\t(*data)->len = cpu_to_le32(monitor_len + sizeof(*fw_mon_data));\n\t}\n\n\treturn len;\n}","target":0,"code_token_length":534,"total_token_length":770,"max_tokens_setting":1024}
+{"idx":344235,"func":"void luaV_concat (lua_State *L, int total) {\n  if (total == 1)\n    return;  \/* \"all\" values already concatenated *\/\n  do {\n    StkId top = L->top;\n    int n = 2;  \/* number of elements handled in this pass (at least 2) *\/\n    if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) ||\n        !tostring(L, s2v(top - 1)))\n      luaT_tryconcatTM(L);\n    else if (isemptystr(s2v(top - 1)))  \/* second operand is empty? *\/\n      cast_void(tostring(L, s2v(top - 2)));  \/* result is first operand *\/\n    else if (isemptystr(s2v(top - 2))) {  \/* first operand is empty string? *\/\n      setobjs2s(L, top - 2, top - 1);  \/* result is second op. *\/\n    }\n    else {\n      \/* at least two non-empty string values; get as many as possible *\/\n      size_t tl = vslen(s2v(top - 1));\n      TString *ts;\n      \/* collect total length and number of strings *\/\n      for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {\n        size_t l = vslen(s2v(top - n - 1));\n        if (l_unlikely(l >= (MAX_SIZE\/sizeof(char)) - tl)) {\n          L->top = top - total;  \/* pop strings to avoid wasting stack *\/\n          luaG_runerror(L, \"string length overflow\");\n        }\n        tl += l;\n      }\n      if (tl <= LUAI_MAXSHORTLEN) {  \/* is result a short string? *\/\n        char buff[LUAI_MAXSHORTLEN];\n        copy2buff(top, n, buff);  \/* copy strings to buffer *\/\n        ts = luaS_newlstr(L, buff, tl);\n      }\n      else {  \/* long string; copy strings directly to final result *\/\n        ts = luaS_createlngstrobj(L, tl);\n        copy2buff(top, n, getstr(ts));\n      }\n      setsvalue2s(L, top - n, ts);  \/* create result *\/\n    }\n    total -= n-1;  \/* got 'n' strings to create 1 new *\/\n    L->top = top - (n - 1);  \/* popped 'n' strings and pushed one *\/\n  } while (total > 1);  \/* repeat until only 1 result left *\/\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":338192,"func":"Index WasmBinaryBuilder::getAbsoluteLocalIndex(Index index) {\n  \/\/ Wasm binaries put each let at the bottom of the index space, which may be\n  \/\/ good for binary size as often the uses of the let variables are close to\n  \/\/ the let itself. However, in Binaryen IR we just have a simple flat index\n  \/\/ space of absolute values, which we add to as we parse, and we depend on\n  \/\/ later optimizations to reorder locals for size.\n  \/\/\n  \/\/ For example, if we have $x, then we add a let with $y, the binary would map\n  \/\/ 0 => y, 1 => x, while in Binaryen IR $x always stays at 0, and $y is added\n  \/\/ at 1.\n  \/\/\n  \/\/ Compute the relative index in the let we were added. We start by looking at\n  \/\/ the last let added, and if we belong to it, we are already relative to it.\n  \/\/ We will continue relativizing as we go down, til we find our let.\n  int64_t relative = index;\n  for (auto i = int64_t(letStack.size()) - 1; i >= 0; i--) {\n    auto& info = letStack[i];\n    int64_t currNum = info.num;\n    \/\/ There were |currNum| let items added in this let. Check if we were one of\n    \/\/ them.\n    if (relative < currNum) {\n      return info.absoluteStart + relative;\n    }\n    relative -= currNum;\n  }\n  \/\/ We were not a let, but a normal var from the beginning. In that case, after\n  \/\/ we subtracted the let items, we have the proper absolute index.\n  return relative;\n}","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":459212,"func":"static inline int __tcf_classify(struct sk_buff *skb,\n\t\t\t\t const struct tcf_proto *tp,\n\t\t\t\t const struct tcf_proto *orig_tp,\n\t\t\t\t struct tcf_result *res,\n\t\t\t\t bool compat_mode,\n\t\t\t\t u32 *last_executed_chain)\n{\n#ifdef CONFIG_NET_CLS_ACT\n\tconst int max_reclassify_loop = 16;\n\tconst struct tcf_proto *first_tp;\n\tint limit = 0;\n\nreclassify:\n#endif\n\tfor (; tp; tp = rcu_dereference_bh(tp->next)) {\n\t\t__be16 protocol = skb_protocol(skb, false);\n\t\tint err;\n\n\t\tif (tp->protocol != protocol &&\n\t\t    tp->protocol != htons(ETH_P_ALL))\n\t\t\tcontinue;\n\n\t\terr = tp->classify(skb, tp, res);\n#ifdef CONFIG_NET_CLS_ACT\n\t\tif (unlikely(err == TC_ACT_RECLASSIFY && !compat_mode)) {\n\t\t\tfirst_tp = orig_tp;\n\t\t\t*last_executed_chain = first_tp->chain->index;\n\t\t\tgoto reset;\n\t\t} else if (unlikely(TC_ACT_EXT_CMP(err, TC_ACT_GOTO_CHAIN))) {\n\t\t\tfirst_tp = res->goto_tp;\n\t\t\t*last_executed_chain = err & TC_ACT_EXT_VAL_MASK;\n\t\t\tgoto reset;\n\t\t}\n#endif\n\t\tif (err >= 0)\n\t\t\treturn err;\n\t}\n\n\treturn TC_ACT_UNSPEC; \/* signal: continue lookup *\/\n#ifdef CONFIG_NET_CLS_ACT\nreset:\n\tif (unlikely(limit++ >= max_reclassify_loop)) {\n\t\tnet_notice_ratelimited(\"%u: reclassify loop, rule prio %u, protocol %02x\\n\",\n\t\t\t\t       tp->chain->block->index,\n\t\t\t\t       tp->prio & 0xffff,\n\t\t\t\t       ntohs(tp->protocol));\n\t\treturn TC_ACT_SHOT;\n\t}\n\n\ttp = first_tp;\n\tgoto reclassify;\n#endif\n}","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":245718,"func":"static int extract_url (const char *url, int default_port,\n                        struct request_s *request)\n{\n        char *p;\n        int port;\n\n        \/* Split the URL on the slash to separate host from path *\/\n        p = strchr (url, '\/');\n        if (p != NULL) {\n                int len;\n                len = p - url;\n                request->host = (char *) safemalloc (len + 1);\n                memcpy (request->host, url, len);\n                request->host[len] = '\\0';\n                request->path = safestrdup (p);\n        } else {\n                request->host = safestrdup (url);\n                request->path = safestrdup (\"\/\");\n        }\n\n        if (!request->host || !request->path)\n                goto ERROR_EXIT;\n\n        \/* Remove the username\/password if they're present *\/\n        strip_username_password (request->host);\n\n        \/* Find a proper port in www.site.com:8001 URLs *\/\n        port = strip_return_port (request->host);\n        request->port = (port != 0) ? port : default_port;\n\n        \/* Remove any surrounding '[' and ']' from IPv6 literals *\/\n        p = strrchr (request->host, ']');\n        if (p && (*(request->host) == '[')) {\n                memmove(request->host, request->host + 1,\n                        strlen(request->host) - 2);\n                *p = '\\0';\n                p--;\n                *p = '\\0';\n        }\n\n        return 0;\n\nERROR_EXIT:\n        if (request->host)\n                safefree (request->host);\n        if (request->path)\n                safefree (request->path);\n\n        return -1;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":442795,"func":"static void dumpeasycode(struct Configurable *config)\n{\n  struct curl_slist *ptr = easycode;\n  char *o = config->libcurl;\n\n  if(o) {\n    FILE *out;\n    bool fopened = FALSE;\n    if(strcmp(o, \"-\")) {\n      out = fopen(o, \"wt\");\n      fopened = TRUE;\n    }\n    else\n      out= stdout;\n    if(!out)\n      warnf(config, \"Failed to open %s to write libcurl code!\\n\", o);\n    else {\n      int i;\n      const char *c;\n\n      for(i=0; (c = srchead[i]); i++) {\n        if(!memcmp((char *)c, \"[m]\", 3)) {\n#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS > 32)\n          fprintf(out, \"#define _FILE_OFFSET_BITS %d \"\n                  \"\/* for curl_off_t magic *\/\\n\",\n                  _FILE_OFFSET_BITS);\n#endif\n        }\n        else\n          fprintf(out, \"%s\\n\", c);\n      }\n\n      while(ptr) {\n        fprintf(out, \"  %s\\n\", ptr->data);\n        ptr = ptr->next;\n      }\n      fprintf(out,\n              \"}\\n\"\n              \"\/* *\/\\n\");\n      if(fopened)\n        fclose(out);\n    }\n  }\n  curl_slist_free_all(easycode);\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":225382,"func":"static int vidioc_try_fmt_out(struct file *file, void *priv,\n\t\t\t      struct v4l2_format *fmt)\n{\n\tstruct v4l2_loopback_device *dev;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\n\t\/* TODO(vasaka) loopback does not care about formats writer want to set,\n\t * maybe it is a good idea to restrict format somehow *\/\n\tif (dev->ready_for_capture) {\n\t\tfmt->fmt.pix = dev->pix_format;\n\t} else {\n\t\t__u32 w = fmt->fmt.pix.width;\n\t\t__u32 h = fmt->fmt.pix.height;\n\t\t__u32 pixfmt = fmt->fmt.pix.pixelformat;\n\t\tconst struct v4l2l_format *format = format_by_fourcc(pixfmt);\n\n\t\tif (w > dev->max_width)\n\t\t\tw = dev->max_width;\n\t\tif (h > dev->max_height)\n\t\t\th = dev->max_height;\n\n\t\tdprintk(\"trying image %dx%d\\n\", w, h);\n\n\t\tif (w < 1)\n\t\t\tw = V4L2LOOPBACK_SIZE_DEFAULT_WIDTH;\n\n\t\tif (h < 1)\n\t\t\th = V4L2LOOPBACK_SIZE_DEFAULT_HEIGHT;\n\n\t\tif (NULL == format)\n\t\t\tformat = &formats[0];\n\n\t\tpix_format_set_size(&fmt->fmt.pix, format, w, h);\n\n\t\tfmt->fmt.pix.pixelformat = format->fourcc;\n\n\t\tif ((fmt->fmt.pix.colorspace == V4L2_COLORSPACE_DEFAULT) ||\n\t\t    (fmt->fmt.pix.colorspace > V4L2_COLORSPACE_DCI_P3))\n\t\t\tfmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;\n\n\t\tif (V4L2_FIELD_ANY == fmt->fmt.pix.field)\n\t\t\tfmt->fmt.pix.field = V4L2_FIELD_NONE;\n\n\t\t\/* FIXXME: try_fmt should never modify the device-state *\/\n\t\tdev->pix_format = fmt->fmt.pix;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":229346,"func":"Status MaybePackInputTensor(EagerOperation* op) {\n  if (op->is_function() || op->EagerContext().RunEagerOpAsFunction()) {\n    \/\/ Functions could take packed TensorHandles as inputs.\n    return Status::OK();\n  }\n  EagerContext& ctx = op->EagerContext();\n  const absl::InlinedVector<TensorHandle*, 4>* inputs;\n  TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n  for (int i = 0; i < inputs->size(); ++i) {\n    TensorHandle* handle = (*inputs)[i];\n    if (handle->Type() == TensorHandle::PACKED) {\n      EagerOperation pack_op(&ctx);\n      TF_RETURN_IF_ERROR(pack_op.Reset(\"Pack\", \/*device_name=*\/nullptr,\n                                       \/*remote=*\/false, \/*executor=*\/nullptr));\n      pack_op.MutableAttrs()->Set(\"N\", handle->NumPackedHandles());\n      pack_op.MutableAttrs()->Set(\"T\", handle->dtype);\n      for (int i = 0; i < handle->NumPackedHandles(); ++i) {\n        tensorflow::TensorHandle* h = nullptr;\n        TF_RETURN_IF_ERROR(handle->ExtractPackedHandle(i, &h));\n        TF_RETURN_IF_ERROR(pack_op.AddInput(h));\n      }\n      int num_retvals = 1;\n      absl::FixedArray<tensorflow::TensorHandle*> retvals(num_retvals);\n      TF_RETURN_IF_ERROR(\n          EagerLocalExecute(&pack_op, retvals.data(), &num_retvals));\n      tensorflow::TensorHandle* ret = retvals.at(0);\n      op->UpdateInput(i, ret);\n      ret->Unref();\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":360,"total_token_length":596,"max_tokens_setting":1024}
+{"idx":400406,"func":"ins_ctrl_ey(int tc)\n{\n    int\t    c = tc;\n\n    if (ctrl_x_mode_scroll())\n    {\n\tif (c == Ctrl_Y)\n\t    scrolldown_clamp();\n\telse\n\t    scrollup_clamp();\n\tredraw_later(UPD_VALID);\n    }\n    else\n    {\n\tc = ins_copychar(curwin->w_cursor.lnum + (c == Ctrl_Y ? -1 : 1));\n\tif (c != NUL)\n\t{\n\t    long\ttw_save;\n\n\t    \/\/ The character must be taken literally, insert like it\n\t    \/\/ was typed after a CTRL-V, and pretend 'textwidth'\n\t    \/\/ wasn't set.  Digits, 'o' and 'x' are special after a\n\t    \/\/ CTRL-V, don't use it for these.\n\t    if (c < 256 && !isalnum(c))\n\t\tAppendToRedobuff((char_u *)CTRL_V_STR);\t\/\/ CTRL-V\n\t    tw_save = curbuf->b_p_tw;\n\t    curbuf->b_p_tw = -1;\n\t    insert_special(c, TRUE, FALSE);\n\t    curbuf->b_p_tw = tw_save;\n#ifdef FEAT_RIGHTLEFT\n\t    revins_chars++;\n\t    revins_legal++;\n#endif\n\t    c = Ctrl_V;\t\/\/ pretend CTRL-V is last character\n\t    auto_format(FALSE, TRUE);\n\t}\n    }\n    return c;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":414931,"func":"\nstatic xmlChar *\nxmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {\n    xmlChar buf[XML_MAX_NAMELEN + 5];\n    int len = 0, l;\n    int c;\n\n    \/*\n     * Handler for more complex cases\n     *\/\n    c = CUR_CHAR(l);\n    if ((c == ' ') || (c == '>') || (c == '\/') || \/* accelerators *\/\n        (c == '[') || (c == ']') || (c == '@') || \/* accelerators *\/\n        (c == '*') || \/* accelerators *\/\n\t(!IS_LETTER(c) && (c != '_') &&\n         ((qualified) && (c != ':')))) {\n\treturn(NULL);\n    }\n\n    while ((c != ' ') && (c != '>') && (c != '\/') && \/* test bigname.xml *\/\n\t   ((IS_LETTER(c)) || (IS_DIGIT(c)) ||\n            (c == '.') || (c == '-') ||\n\t    (c == '_') || ((qualified) && (c == ':')) ||\n\t    (IS_COMBINING(c)) ||\n\t    (IS_EXTENDER(c)))) {\n\tCOPY_BUF(l,buf,len,c);\n\tNEXTL(l);\n\tc = CUR_CHAR(l);\n\tif (len >= XML_MAX_NAMELEN) {\n\t    \/*\n\t     * Okay someone managed to make a huge name, so he's ready to pay\n\t     * for the processing speed.\n\t     *\/\n\t    xmlChar *buffer;\n\t    int max = len * 2;\n\n            if (len > XML_MAX_NAME_LENGTH) {\n                XP_ERRORNULL(XPATH_EXPR_ERROR);\n            }\n\t    buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));\n\t    if (buffer == NULL) {\n\t\tXP_ERRORNULL(XPATH_MEMORY_ERROR);\n\t    }\n\t    memcpy(buffer, buf, len);\n\t    while ((IS_LETTER(c)) || (IS_DIGIT(c)) || \/* test bigname.xml *\/\n\t\t   (c == '.') || (c == '-') ||\n\t\t   (c == '_') || ((qualified) && (c == ':')) ||\n\t\t   (IS_COMBINING(c)) ||\n\t\t   (IS_EXTENDER(c))) {\n\t\tif (len + 10 > max) {\n                    if (max > XML_MAX_NAME_LENGTH) {\n                        XP_ERRORNULL(XPATH_EXPR_ERROR);\n                    }\n\t\t    max *= 2;\n\t\t    buffer = (xmlChar *) xmlRealloc(buffer,\n\t\t\t                            max * sizeof(xmlChar));\n\t\t    if (buffer == NULL) {\n\t\t\tXP_ERRORNULL(XPATH_MEMORY_ERROR);\n\t\t    }\n\t\t}\n\t\tCOPY_BUF(l,buffer,len,c);\n\t\tNEXTL(l);\n\t\tc = CUR_CHAR(l);\n\t    }\n\t    buffer[len] = 0;\n\t    return(buffer);\n\t}\n    }\n    if (len == 0)\n\treturn(NULL);","target":0,"code_token_length":583,"total_token_length":819,"max_tokens_setting":1024}
+{"idx":450764,"func":"reg_match_visual(void)\n{\n    pos_T\ttop, bot;\n    linenr_T    lnum;\n    colnr_T\tcol;\n    win_T\t*wp = rex.reg_win == NULL ? curwin : rex.reg_win;\n    int\t\tmode;\n    colnr_T\tstart, end;\n    colnr_T\tstart2, end2;\n    colnr_T\tcols;\n    colnr_T\tcurswant;\n\n    \/\/ Check if the buffer is the current buffer.\n    if (rex.reg_buf != curbuf || VIsual.lnum == 0)\n\treturn FALSE;\n\n    if (VIsual_active)\n    {\n\tif (LT_POS(VIsual, wp->w_cursor))\n\t{\n\t    top = VIsual;\n\t    bot = wp->w_cursor;\n\t}\n\telse\n\t{\n\t    top = wp->w_cursor;\n\t    bot = VIsual;\n\t}\n\tmode = VIsual_mode;\n\tcurswant = wp->w_curswant;\n    }\n    else\n    {\n\tif (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end))\n\t{\n\t    top = curbuf->b_visual.vi_start;\n\t    bot = curbuf->b_visual.vi_end;\n\t}\n\telse\n\t{\n\t    top = curbuf->b_visual.vi_end;\n\t    bot = curbuf->b_visual.vi_start;\n\t}\n\tmode = curbuf->b_visual.vi_mode;\n\tcurswant = curbuf->b_visual.vi_curswant;\n    }\n    lnum = rex.lnum + rex.reg_firstlnum;\n    if (lnum < top.lnum || lnum > bot.lnum)\n\treturn FALSE;\n\n    col = (colnr_T)(rex.input - rex.line);\n    if (mode == 'v')\n    {\n\tif ((lnum == top.lnum && col < top.col)\n\t\t|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))\n\t    return FALSE;\n    }\n    else if (mode == Ctrl_V)\n    {\n\tgetvvcol(wp, &top, &start, NULL, &end);\n\tgetvvcol(wp, &bot, &start2, NULL, &end2);\n\tif (start2 < start)\n\t    start = start2;\n\tif (end2 > end)\n\t    end = end2;\n\tif (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)\n\t    end = MAXCOL;\n\n\t\/\/ getvvcol() flushes rex.line, need to get it again\n\trex.line = reg_getline(rex.lnum);\n\trex.input = rex.line + col;\n\n\tcols = win_linetabsize(wp, rex.line, col);\n\tif (cols < start || cols > end - (*p_sel == 'e'))\n\t    return FALSE;\n    }\n    return TRUE;\n}","target":0,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":225595,"func":"GF_Err stbl_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_SampleTableBox *ptr = (GF_SampleTableBox *)s;\n\n\tgf_isom_check_position(s, (GF_Box *)ptr->SampleDescription, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->TimeToSample, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->CompositionOffset, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->CompositionToDecode, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->SyncSample, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->ShadowSync, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->SampleToChunk, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->SampleSize, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->ChunkOffset, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->DegradationPriority, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->SampleDep, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->PaddingBits, &pos);\n\n\tif (ptr->sub_samples) {\n\t\tgf_isom_check_position_list(s, ptr->sub_samples, &pos);\n\t}\n\tif (ptr->sampleGroupsDescription) {\n\t\tgf_isom_check_position_list(s, ptr->sampleGroupsDescription, &pos);\n\t}\n\tif (ptr->sampleGroups) {\n\t\tgf_isom_check_position_list(s, ptr->sampleGroups, &pos);\n\t}\n\tif (ptr->sai_sizes) {\n\t\tgf_isom_check_position_list(s, ptr->sai_sizes, &pos);\n\t}\n\tif (ptr->sai_offsets) {\n\t\tgf_isom_check_position_list(s, ptr->sai_offsets, &pos);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":421379,"func":"static void pobject(int d, js_Ast *list)\n{\n\tpc('{');\n\tif (list) {\n\t\tnl();\n\t\tin(d+1);\n\t}\n\twhile (list) {\n\t\tjs_Ast *kv = list->a;\n\t\tassert(list->type == AST_LIST);\n\t\tswitch (kv->type) {\n\t\tdefault: break;\n\t\tcase EXP_PROP_VAL:\n\t\t\tpexpi(d+1, COMMA, kv->a);\n\t\t\tpc(':'); sp();\n\t\t\tpexpi(d+1, COMMA, kv->b);\n\t\t\tbreak;\n\t\tcase EXP_PROP_GET:\n\t\t\tps(\"get \");\n\t\t\tpexpi(d+1, COMMA, kv->a);\n\t\t\tps(\"()\"); sp(); pc('{'); nl();\n\t\t\tpstmlist(d+1, kv->c);\n\t\t\tin(d+1); pc('}');\n\t\t\tbreak;\n\t\tcase EXP_PROP_SET:\n\t\t\tps(\"set \");\n\t\t\tpexpi(d+1, COMMA, kv->a);\n\t\t\tpc('(');\n\t\t\tpargs(d+1, kv->b);\n\t\t\tpc(')'); sp(); pc('{'); nl();\n\t\t\tpstmlist(d+1, kv->c);\n\t\t\tin(d+1); pc('}');\n\t\t\tbreak;\n\t\t}\n\t\tlist = list->b;\n\t\tif (list) {\n\t\t\tpc(',');\n\t\t\tnl();\n\t\t\tin(d+1);\n\t\t} else {\n\t\t\tnl();\n\t\t\tin(d);\n\t\t}\n\t}\n\tpc('}');\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":247735,"func":"TEST_P(SslSocketTest, RsaPrivateKeyProviderMultiCertSuccess) {\n  const std::string client_ctx_yaml = absl::StrCat(R\"EOF(\n    common_tls_context:\n      tls_params:\n        tls_minimum_protocol_version: TLSv1_2\n        tls_maximum_protocol_version: TLSv1_2\n        cipher_suites:\n        - ECDHE-ECDSA-AES128-GCM-SHA256\n        - ECDHE-RSA-AES128-GCM-SHA256\n      validation_context:\n        verify_certificate_hash: )EOF\",\n                                                   TEST_SELFSIGNED_ECDSA_P256_CERT_256_HASH);\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_cert.pem\"\n      private_key_provider:\n        provider_name: test\n        typed_config:\n          \"@type\": type.googleapis.com\/google.protobuf.Struct\n          value:\n            private_key_file: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n            expected_operation: sign\n            sync_mode: false\n            mode: rsa\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_ecdsa_p256_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_ecdsa_p256_key.pem\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setPrivateKeyMethodExpected(true));\n}","target":0,"code_token_length":370,"total_token_length":606,"max_tokens_setting":1024}
+{"idx":238397,"func":"njs_function_prototype_create(njs_vm_t *vm, njs_object_prop_t *prop,\n    njs_value_t *value, njs_value_t *setval, njs_value_t *retval)\n{\n    njs_value_t     *proto, proto_value, *cons;\n    njs_object_t    *prototype;\n    njs_function_t  *function;\n\n    if (setval == NULL) {\n        prototype = njs_object_alloc(vm);\n        if (njs_slow_path(prototype == NULL)) {\n            return NJS_ERROR;\n        }\n\n        njs_set_object(&proto_value, prototype);\n\n        setval = &proto_value;\n    }\n\n    function = njs_function_value_copy(vm, value);\n    if (njs_slow_path(function == NULL)) {\n        return NJS_ERROR;\n    }\n\n    proto = njs_function_property_prototype_set(vm, njs_object_hash(value),\n                                                setval);\n    if (njs_slow_path(proto == NULL)) {\n        return NJS_ERROR;\n    }\n\n    if (setval == &proto_value && njs_is_object(proto)) {\n        \/* Only in getter context. *\/\n        cons = njs_property_constructor_set(vm, njs_object_hash(proto), value);\n        if (njs_slow_path(cons == NULL)) {\n            return NJS_ERROR;\n        }\n    }\n\n    *retval = *proto;\n\n    return NJS_OK;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":389687,"func":"eval_option(\n    char_u\t**arg,\n    typval_T\t*rettv,\t\/\/ when NULL, only check if option exists\n    int\t\tevaluate)\n{\n    char_u\t*option_end;\n    long\tnumval;\n    char_u\t*stringval;\n    getoption_T\topt_type;\n    int\t\tc;\n    int\t\tworking = (**arg == '+');    \/\/ has(\"+option\")\n    int\t\tret = OK;\n    int\t\tscope;\n\n    \/\/ Isolate the option name and find its value.\n    option_end = find_option_end(arg, &scope);\n    if (option_end == NULL)\n    {\n\tif (rettv != NULL)\n\t    semsg(_(e_option_name_missing_str), *arg);\n\treturn FAIL;\n    }\n\n    if (!evaluate)\n    {\n\t*arg = option_end;\n\treturn OK;\n    }\n\n    c = *option_end;\n    *option_end = NUL;\n    opt_type = get_option_value(*arg, &numval,\n\t\t\t       rettv == NULL ? NULL : &stringval, NULL, scope);\n\n    if (opt_type == gov_unknown)\n    {\n\tif (rettv != NULL)\n\t    semsg(_(e_unknown_option_str), *arg);\n\tret = FAIL;\n    }\n    else if (rettv != NULL)\n    {\n\trettv->v_lock = 0;\n\tif (opt_type == gov_hidden_string)\n\t{\n\t    rettv->v_type = VAR_STRING;\n\t    rettv->vval.v_string = NULL;\n\t}\n\telse if (opt_type == gov_hidden_bool || opt_type == gov_hidden_number)\n\t{\n\t    rettv->v_type = in_vim9script() && opt_type == gov_hidden_bool\n\t\t\t\t\t\t       ? VAR_BOOL : VAR_NUMBER;\n\t    rettv->vval.v_number = 0;\n\t}\n\telse if (opt_type == gov_bool || opt_type == gov_number)\n\t{\n\t    if (in_vim9script() && opt_type == gov_bool)\n\t    {\n\t\trettv->v_type = VAR_BOOL;\n\t\trettv->vval.v_number = numval ? VVAL_TRUE : VVAL_FALSE;\n\t    }\n\t    else\n\t    {\n\t\trettv->v_type = VAR_NUMBER;\n\t\trettv->vval.v_number = numval;\n\t    }\n\t}\n\telse\t\t\t\t\/\/ string option\n\t{\n\t    rettv->v_type = VAR_STRING;\n\t    rettv->vval.v_string = stringval;\n\t}\n    }\n    else if (working && (opt_type == gov_hidden_bool\n\t\t\t|| opt_type == gov_hidden_number\n\t\t\t|| opt_type == gov_hidden_string))\n\tret = FAIL;\n\n    *option_end = c;\t\t    \/\/ put back for error messages\n    *arg = option_end;\n\n    return ret;\n}","target":0,"code_token_length":575,"total_token_length":811,"max_tokens_setting":1024}
+{"idx":208522,"func":"dnsc_load_local_data(struct dnsc_env* dnscenv, struct config_file *cfg)\n{\n    size_t i, j;\n\t\/\/ Insert 'local-zone: \"2.dnscrypt-cert.example.com\" deny'\n    if(!cfg_str2list_insert(&cfg->local_zones,\n                            strdup(dnscenv->provider_name),\n                            strdup(\"deny\"))) {\n        log_err(\"Could not load dnscrypt local-zone: %s deny\",\n                dnscenv->provider_name);\n        return -1;\n    }\n\n    \/\/ Add local data entry of type:\n    \/\/ 2.dnscrypt-cert.example.com 86400 IN TXT \"DNSC......\"\n    for(i=0; i<dnscenv->signed_certs_count; i++) {\n        const char *ttl_class_type = \" 86400 IN TXT \\\"\";\n        int rotated_cert = 0;\n\tuint32_t serial;\n\tuint16_t rrlen;\n\tchar* rr;\n        struct SignedCert *cert = dnscenv->signed_certs + i;\n\t\t\/\/ Check if the certificate is being rotated and should not be published\n        for(j=0; j<dnscenv->rotated_certs_count; j++){\n            if(cert == dnscenv->rotated_certs[j]) {\n                rotated_cert = 1;\n                break;\n            }\n        }\n\t\tmemcpy(&serial, cert->serial, sizeof serial);\n\t\tserial = htonl(serial);\n        if(rotated_cert) {\n            verbose(VERB_OPS,\n                \"DNSCrypt: not adding cert with serial #%\"\n                PRIu32\n                \" to local-data as it is rotated\",\n                serial\n            );\n            continue;\n        }\n        rrlen = strlen(dnscenv->provider_name) +\n                         strlen(ttl_class_type) +\n                         4 * sizeof(struct SignedCert) + \/\/ worst case scenario\n                         1 + \/\/ trailing double quote\n                         1;\n        rr = malloc(rrlen);\n        if(!rr) {\n            log_err(\"Could not allocate memory\");\n            return -2;\n        }\n        snprintf(rr, rrlen - 1, \"%s 86400 IN TXT \\\"\", dnscenv->provider_name);\n        for(j=0; j<sizeof(struct SignedCert); j++) {\n\t\t\tint c = (int)*((const uint8_t *) cert + j);\n            if (isprint(c) && c != '\"' && c != '\\\\') {\n                snprintf(rr + strlen(rr), rrlen - 1 - strlen(rr), \"%c\", c);\n            } else {\n                snprintf(rr + strlen(rr), rrlen - 1 - strlen(rr), \"\\\\%03d\", c);\n            }\n        }\n        verbose(VERB_OPS,\n\t\t\t\"DNSCrypt: adding cert with serial #%\"\n\t\t\tPRIu32\n\t\t\t\" to local-data to config: %s\",\n\t\t\tserial, rr\n\t\t);\n        snprintf(rr + strlen(rr), rrlen - 1 - strlen(rr), \"\\\"\");\n        cfg_strlist_insert(&cfg->local_data, strdup(rr));\n        free(rr);\n    }\n    return dnscenv->signed_certs_count;\n}","target":1,"code_token_length":669,"total_token_length":905,"max_tokens_setting":1024}
+{"idx":197305,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_rpsi(\n\t\t\t\t\tconst void *buf,\n\t\t\t\t\tpj_size_t length,\n\t\t\t\t\tpjmedia_rtcp_fb_rpsi *rpsi)\n{\n    pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;\n    pj_uint8_t *p;\n    pj_uint8_t padlen;\n    pj_size_t rpsi_len;\n\n    PJ_ASSERT_RETURN(buf && rpsi, PJ_EINVAL);\n    PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);\n\n    \/* RPSI uses pt==RTCP_PSFB and FMT==3 *\/\n    if (hdr->pt != RTCP_PSFB || hdr->count != 3)\n\treturn PJ_ENOTFOUND;\n\n    rpsi_len = (pj_ntohs((pj_uint16_t)hdr->length)-2) * 4;\n    if (length < rpsi_len + 12)\n\treturn PJ_ETOOSMALL;\n\n    p = (pj_uint8_t*)hdr + sizeof(*hdr);\n    padlen = *p++;\n    rpsi->pt = (*p++ & 0x7F);\n    rpsi->rpsi_bit_len = rpsi_len*8 - 16 - padlen;\n    pj_strset(&rpsi->rpsi, (char*)p, (rpsi->rpsi_bit_len + 7)\/8);\n\n    return PJ_SUCCESS;\n}","target":1,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":310077,"func":"same_ti_tc(const char *ti, const char *tc, bool * embedded)\n{\n    bool same = TRUE;\n    double ti_delay = 0.0;\n    double tc_delay = 0.0;\n    const char *ti_last;\n\n    *embedded = FALSE;\n    ti_last = parse_ti_delay(ti, &ti_delay);\n    tc = parse_tc_delay(tc, &tc_delay);\n\n    while ((ti < ti_last) && *tc) {\n\tif (*ti == '\\\\' && ispunct(UChar(ti[1]))) {\n\t    ++ti;\n\t    if ((*ti == '^') && !strncmp(tc, \"\\\\136\", 4)) {\n\t\tti += 1;\n\t\ttc += 4;\n\t\tcontinue;\n\t    }\n\t} else if (ti[0] == '$' && ti[1] == '<') {\n\t    double no_delay;\n\t    const char *ss = parse_ti_delay(ti, &no_delay);\n\t    if (ss != ti) {\n\t\t*embedded = TRUE;\n\t\tti = ss;\n\t\tcontinue;\n\t    }\n\t}\n\tif (*tc == '\\\\' && ispunct(UChar(tc[1]))) {\n\t    ++tc;\n\t}\n\tif (*ti++ != *tc++) {\n\t    same = FALSE;\n\t    break;\n\t}\n    }\n\n    if (*embedded) {\n\tif (same) {\n\t    same = FALSE;\n\t} else {\n\t    *embedded = FALSE;\t\/* report only one problem *\/\n\t}\n    }\n\n    return same;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":361289,"func":"stl_load_edge_exact(stl_file *stl, stl_hash_edge *edge,\n                    stl_vertex *a, stl_vertex *b) {\n\n  float diff_x;\n  float diff_y;\n  float diff_z;\n  float max_diff;\n\n  if (stl->error) return;\n\n  diff_x = ABS(a->x - b->x);\n  diff_y = ABS(a->y - b->y);\n  diff_z = ABS(a->z - b->z);\n  max_diff = STL_MAX(diff_x, diff_y);\n  max_diff = STL_MAX(diff_z, max_diff);\n  stl->stats.shortest_edge = STL_MIN(max_diff, stl->stats.shortest_edge);\n\n  if(diff_x == max_diff) {\n    if(a->x > b->x) {\n      memcpy(&edge->key[0], a, sizeof(stl_vertex));\n      memcpy(&edge->key[3], b, sizeof(stl_vertex));\n    } else {\n      memcpy(&edge->key[0], b, sizeof(stl_vertex));\n      memcpy(&edge->key[3], a, sizeof(stl_vertex));\n      edge->which_edge += 3; \/* this edge is loaded backwards *\/\n    }\n  } else if(diff_y == max_diff) {\n    if(a->y > b->y) {\n      memcpy(&edge->key[0], a, sizeof(stl_vertex));\n      memcpy(&edge->key[3], b, sizeof(stl_vertex));\n    } else {\n      memcpy(&edge->key[0], b, sizeof(stl_vertex));\n      memcpy(&edge->key[3], a, sizeof(stl_vertex));\n      edge->which_edge += 3; \/* this edge is loaded backwards *\/\n    }\n  } else {\n    if(a->z > b->z) {\n      memcpy(&edge->key[0], a, sizeof(stl_vertex));\n      memcpy(&edge->key[3], b, sizeof(stl_vertex));\n    } else {\n      memcpy(&edge->key[0], b, sizeof(stl_vertex));\n      memcpy(&edge->key[3], a, sizeof(stl_vertex));\n      edge->which_edge += 3; \/* this edge is loaded backwards *\/\n    }\n  }\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":517422,"func":"static void do_home_file(HttpResponse res) {\n        char buf[STRLEN];\n        boolean_t on = true;\n        boolean_t header = true;\n\n        for (Service_T s = servicelist_conf; s; s = s->next_conf) {\n                if (s->type != Service_File)\n                        continue;\n                if (header) {\n                        StringBuffer_append(res->outputbuffer,\n                                            \"<table id='header-row'>\"\n                                            \"<tr>\"\n                                            \"<th class='left first'>File<\/th>\"\n                                            \"<th class='left'>Status<\/th>\"\n                                            \"<th class='right'>Size<\/th>\"\n                                            \"<th class='right'>Permission<\/th>\"\n                                            \"<th class='right'>UID<\/th>\"\n                                            \"<th class='right'>GID<\/th>\"\n                                            \"<\/tr>\");\n\n                        header = false;\n                }\n                StringBuffer_append(res->outputbuffer,\n                                    \"<tr %s>\"\n                                    \"<td class='left'><a href='%s'>%s<\/a><\/td>\"\n                                    \"<td class='left'>%s<\/td>\",\n                                    on ? \"class='stripe'\" : \"\",\n                                    s->name, s->name,\n                                    get_service_status(HTML, s, buf, sizeof(buf)));\n                if (! Util_hasServiceStatus(s) || s->inf.file->size < 0)\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                else\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%s<\/td>\", Fmt_bytes2str(s->inf.file->size, (char[10]){}));\n                if (! Util_hasServiceStatus(s) || s->inf.file->mode < 0)\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                else\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%04o<\/td>\", s->inf.file->mode & 07777);\n                if (! Util_hasServiceStatus(s) || s->inf.file->uid < 0)\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                else\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%d<\/td>\", s->inf.file->uid);\n                if (! Util_hasServiceStatus(s) || s->inf.file->gid < 0)\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>-<\/td>\");\n                else\n                        StringBuffer_append(res->outputbuffer, \"<td class='right'>%d<\/td>\", s->inf.file->gid);\n                StringBuffer_append(res->outputbuffer, \"<\/tr>\");\n                on = ! on;\n        }\n        if (! header)\n                StringBuffer_append(res->outputbuffer, \"<\/table>\");\n}","target":0,"code_token_length":571,"total_token_length":807,"max_tokens_setting":1024}
+{"idx":437001,"func":"static void mcba_usb_process_can(struct mcba_priv *priv,\n\t\t\t\t struct mcba_usb_msg_can *msg)\n{\n\tstruct can_frame *cf;\n\tstruct sk_buff *skb;\n\tstruct net_device_stats *stats = &priv->netdev->stats;\n\tu16 sid;\n\n\tskb = alloc_can_skb(priv->netdev, &cf);\n\tif (!skb)\n\t\treturn;\n\n\tsid = get_unaligned_be16(&msg->sid);\n\n\tif (sid & MCBA_SIDL_EXID_MASK) {\n\t\t\/* SIDH    | SIDL                 | EIDH   | EIDL\n\t\t * 28 - 21 | 20 19 18 x x x 17 16 | 15 - 8 | 7 - 0\n\t\t *\/\n\t\tcf->can_id = CAN_EFF_FLAG;\n\n\t\t\/* store 28-18 bits *\/\n\t\tcf->can_id |= (sid & 0xffe0) << 13;\n\t\t\/* store 17-16 bits *\/\n\t\tcf->can_id |= (sid & 3) << 16;\n\t\t\/* store 15-0 bits *\/\n\t\tcf->can_id |= get_unaligned_be16(&msg->eid);\n\t} else {\n\t\t\/* SIDH   | SIDL\n\t\t * 10 - 3 | 2 1 0 x x x x x\n\t\t *\/\n\t\tcf->can_id = (sid & 0xffe0) >> 5;\n\t}\n\n\tcf->len = can_cc_dlc2len(msg->dlc & MCBA_DLC_MASK);\n\n\tif (msg->dlc & MCBA_DLC_RTR_MASK) {\n\t\tcf->can_id |= CAN_RTR_FLAG;\n\t} else {\n\t\tmemcpy(cf->data, msg->data, cf->len);\n\n\t\tstats->rx_bytes += cf->len;\n\t}\n\tstats->rx_packets++;\n\n\tcan_led_event(priv->netdev, CAN_LED_EVENT_RX);\n\tnetif_rx(skb);\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":385913,"func":"static int do_dentry_open(struct file *f,\n\t\t\t  int (*open)(struct inode *, struct file *),\n\t\t\t  const struct cred *cred)\n{\n\tstatic const struct file_operations empty_fops = {};\n\tstruct inode *inode;\n\tint error;\n\n\tf->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |\n\t\t\t\tFMODE_PREAD | FMODE_PWRITE;\n\n\tif (unlikely(f->f_flags & O_PATH))\n\t\tf->f_mode = FMODE_PATH;\n\n\tpath_get(&f->f_path);\n\tinode = f->f_inode = f->f_path.dentry->d_inode;\n\tif (f->f_mode & FMODE_WRITE) {\n\t\terror = __get_file_write_access(inode, f->f_path.mnt);\n\t\tif (error)\n\t\t\tgoto cleanup_file;\n\t\tif (!special_file(inode->i_mode))\n\t\t\tfile_take_write(f);\n\t}\n\n\tf->f_mapping = inode->i_mapping;\n\tfile_sb_list_add(f, inode->i_sb);\n\n\tif (unlikely(f->f_mode & FMODE_PATH)) {\n\t\tf->f_op = &empty_fops;\n\t\treturn 0;\n\t}\n\n\tf->f_op = fops_get(inode->i_fop);\n\n\terror = security_file_open(f, cred);\n\tif (error)\n\t\tgoto cleanup_all;\n\n\terror = break_lease(inode, f->f_flags);\n\tif (error)\n\t\tgoto cleanup_all;\n\n\tif (!open && f->f_op)\n\t\topen = f->f_op->open;\n\tif (open) {\n\t\terror = open(inode, f);\n\t\tif (error)\n\t\t\tgoto cleanup_all;\n\t}\n\tif ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)\n\t\ti_readcount_inc(inode);\n\n\tf->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);\n\n\tfile_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);\n\n\treturn 0;\n\ncleanup_all:\n\tfops_put(f->f_op);\n\tfile_sb_list_del(f);\n\tif (f->f_mode & FMODE_WRITE) {\n\t\tput_write_access(inode);\n\t\tif (!special_file(inode->i_mode)) {\n\t\t\t\/*\n\t\t\t * We don't consider this a real\n\t\t\t * mnt_want\/drop_write() pair\n\t\t\t * because it all happenend right\n\t\t\t * here, so just reset the state.\n\t\t\t *\/\n\t\t\tfile_reset_write(f);\n\t\t\t__mnt_drop_write(f->f_path.mnt);\n\t\t}\n\t}\ncleanup_file:\n\tpath_put(&f->f_path);\n\tf->f_path.mnt = NULL;\n\tf->f_path.dentry = NULL;\n\tf->f_inode = NULL;\n\treturn error;\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":438670,"func":"static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,\n\t\t\t     struct rpmsg_hdr *msg, unsigned int len)\n{\n\tstruct rpmsg_endpoint *ept;\n\tstruct scatterlist sg;\n\tbool little_endian = virtio_is_little_endian(vrp->vdev);\n\tunsigned int msg_len = __rpmsg16_to_cpu(little_endian, msg->len);\n\tint err;\n\n\tdev_dbg(dev, \"From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\\n\",\n\t\t__rpmsg32_to_cpu(little_endian, msg->src),\n\t\t__rpmsg32_to_cpu(little_endian, msg->dst), msg_len,\n\t\t__rpmsg16_to_cpu(little_endian, msg->flags),\n\t\t__rpmsg32_to_cpu(little_endian, msg->reserved));\n#if defined(CONFIG_DYNAMIC_DEBUG)\n\tdynamic_hex_dump(\"rpmsg_virtio RX: \", DUMP_PREFIX_NONE, 16, 1,\n\t\t\t msg, sizeof(*msg) + msg_len, true);\n#endif\n\n\t\/*\n\t * We currently use fixed-sized buffers, so trivially sanitize\n\t * the reported payload length.\n\t *\/\n\tif (len > vrp->buf_size ||\n\t    msg_len > (len - sizeof(struct rpmsg_hdr))) {\n\t\tdev_warn(dev, \"inbound msg too big: (%d, %d)\\n\", len, msg_len);\n\t\treturn -EINVAL;\n\t}\n\n\t\/* use the dst addr to fetch the callback of the appropriate user *\/\n\tmutex_lock(&vrp->endpoints_lock);\n\n\tept = idr_find(&vrp->endpoints, __rpmsg32_to_cpu(little_endian, msg->dst));\n\n\t\/* let's make sure no one deallocates ept while we use it *\/\n\tif (ept)\n\t\tkref_get(&ept->refcount);\n\n\tmutex_unlock(&vrp->endpoints_lock);\n\n\tif (ept) {\n\t\t\/* make sure ept->cb doesn't go away while we use it *\/\n\t\tmutex_lock(&ept->cb_lock);\n\n\t\tif (ept->cb)\n\t\t\tept->cb(ept->rpdev, msg->data, msg_len, ept->priv,\n\t\t\t\t__rpmsg32_to_cpu(little_endian, msg->src));\n\n\t\tmutex_unlock(&ept->cb_lock);\n\n\t\t\/* farewell, ept, we don't need you anymore *\/\n\t\tkref_put(&ept->refcount, __ept_release);\n\t} else\n\t\tdev_warn_ratelimited(dev, \"msg received with no recipient\\n\");\n\n\t\/* publish the real size of the buffer *\/\n\trpmsg_sg_init(&sg, msg, vrp->buf_size);\n\n\t\/* add the buffer back to the remote processor's virtqueue *\/\n\terr = virtqueue_add_inbuf(vrp->rvq, &sg, 1, msg, GFP_KERNEL);\n\tif (err < 0) {\n\t\tdev_err(dev, \"failed to add a virtqueue buffer: %d\\n\", err);\n\t\treturn err;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":359643,"func":"community_list_set_vty (struct vty *vty, int argc, const char **argv, \n                        int style, int reject_all_digit_name)\n{\n  int ret;\n  int direct;\n  char *str;\n\n  \/* Check the list type. *\/\n  if (strncmp (argv[1], \"p\", 1) == 0)\n    direct = COMMUNITY_PERMIT;\n  else if (strncmp (argv[1], \"d\", 1) == 0)\n    direct = COMMUNITY_DENY;\n  else\n    {\n      vty_out (vty, \"%% Matching condition must be permit or deny%s\",\n\t       VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  \/* All digit name check.  *\/\n  if (reject_all_digit_name && all_digit (argv[0]))\n    {\n      vty_out (vty, \"%% Community name cannot have all digits%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  \/* Concat community string argument.  *\/\n  if (argc > 1)\n    str = argv_concat (argv, argc, 2);\n  else\n    str = NULL;\n\n  \/* When community_list_set() return nevetive value, it means\n     malformed community string.  *\/\n  ret = community_list_set (bgp_clist, argv[0], str, direct, style);\n\n  \/* Free temporary community list string allocated by\n     argv_concat().  *\/\n  if (str)\n    XFREE (MTYPE_TMP, str);\n\n  if (ret < 0)\n    {\n      \/* Display error string.  *\/\n      community_list_perror (vty, ret);\n      return CMD_WARNING;\n    }\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":358,"total_token_length":594,"max_tokens_setting":1024}
+{"idx":481269,"func":"static void mlx5_fpga_conn_sq_cqe(struct mlx5_fpga_conn *conn,\n\t\t\t\t  struct mlx5_cqe64 *cqe, u8 status)\n{\n\tstruct mlx5_fpga_dma_buf *buf, *nextbuf;\n\tunsigned long flags;\n\tint ix;\n\n\tspin_lock_irqsave(&conn->qp.sq.lock, flags);\n\n\tix = be16_to_cpu(cqe->wqe_counter) & (conn->qp.sq.size - 1);\n\tbuf = conn->qp.sq.bufs[ix];\n\tconn->qp.sq.bufs[ix] = NULL;\n\tconn->qp.sq.cc++;\n\n\t\/* Handle backlog still under the spinlock to ensure message post order *\/\n\tif (unlikely(!list_empty(&conn->qp.sq.backlog))) {\n\t\tif (likely(conn->qp.active)) {\n\t\t\tnextbuf = list_first_entry(&conn->qp.sq.backlog,\n\t\t\t\t\t\t   struct mlx5_fpga_dma_buf, list);\n\t\t\tlist_del(&nextbuf->list);\n\t\t\tmlx5_fpga_conn_post_send(conn, nextbuf);\n\t\t}\n\t}\n\n\tspin_unlock_irqrestore(&conn->qp.sq.lock, flags);\n\n\tif (unlikely(status && (status != MLX5_CQE_SYNDROME_WR_FLUSH_ERR)))\n\t\tmlx5_fpga_warn(conn->fdev, \"SQ buf %p on FPGA QP %u completion status %d\\n\",\n\t\t\t       buf, conn->fpga_qpn, status);\n\telse\n\t\tmlx5_fpga_dbg(conn->fdev, \"SQ buf %p on FPGA QP %u completion status %d\\n\",\n\t\t\t      buf, conn->fpga_qpn, status);\n\n\tmlx5_fpga_conn_unmap_buf(conn, buf);\n\n\tif (likely(buf->complete))\n\t\tbuf->complete(conn, conn->fdev, buf, status);\n\n\tif (unlikely(status))\n\t\tconn->qp.active = false;\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":261906,"func":"njs_string_from_char_code(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t is_point)\n{\n    double                num;\n    u_char                *p, *start, *end;\n    ssize_t               len;\n    int32_t               code;\n    uint32_t              cp;\n    uint64_t              length, size;\n    njs_int_t             ret;\n    njs_uint_t            i;\n    njs_unicode_decode_t  ctx;\n    u_char                buf[4];\n\n    size = 0;\n    length = 0;\n\n    cp = 0x00;\n    end = buf + sizeof(buf);\n\n    njs_utf16_decode_init(&ctx);\n\n    for (i = 1; i < nargs; i++) {\n        if (!njs_is_numeric(&args[i])) {\n            ret = njs_value_to_numeric(vm, &args[i], &args[i]);\n            if (ret != NJS_OK) {\n                return ret;\n            }\n        }\n\n        if (is_point) {\n            num = njs_number(&args[i]);\n            if (isnan(num)) {\n                goto range_error;\n            }\n\n            code = num;\n\n            if (code != num || code < 0 || code > 0x10FFFF) {\n                goto range_error;\n            }\n\n        } else {\n            code = njs_number_to_uint16(njs_number(&args[i]));\n        }\n\n        start = buf;\n        len = njs_utf16_encode(code, &start, end);\n\n        start = buf;\n        cp = njs_utf16_decode(&ctx, (const u_char **) &start, start + len);\n\n        if (cp > NJS_UNICODE_MAX_CODEPOINT) {\n            if (cp == NJS_UNICODE_CONTINUE) {\n                continue;\n            }\n\n            cp = NJS_UNICODE_REPLACEMENT;\n        }\n\n        size += njs_utf8_size(cp);\n        length++;\n    }\n\n    if (cp == NJS_UNICODE_CONTINUE) {\n        size += njs_utf8_size(NJS_UNICODE_REPLACEMENT);\n        length++;\n    }\n\n    p = njs_string_alloc(vm, &vm->retval, size, length);\n    if (njs_slow_path(p == NULL)) {\n        return NJS_ERROR;\n    }\n\n    njs_utf16_decode_init(&ctx);\n\n    for (i = 1; i < nargs; i++) {\n        if (is_point) {\n            code = njs_number(&args[i]);\n\n        } else {\n            code = njs_number_to_uint16(njs_number(&args[i]));\n        }\n\n        start = buf;\n        len = njs_utf16_encode(code, &start, end);\n\n        start = buf;\n        cp = njs_utf16_decode(&ctx, (const u_char **) &start, start + len);\n\n        if (cp > NJS_UNICODE_MAX_CODEPOINT) {\n            if (cp == NJS_UNICODE_CONTINUE && i + 1 != nargs) {\n                continue;\n            }\n\n            cp = NJS_UNICODE_REPLACEMENT;\n        }\n\n        p = njs_utf8_encode(p, cp);\n    }\n\n    return NJS_OK;\n\nrange_error:\n\n    njs_range_error(vm, NULL);\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":687,"total_token_length":923,"max_tokens_setting":1024}
+{"idx":223420,"func":"static unsigned int char_get_othercase_bit(compiler_common *common, PCRE2_SPTR cc)\n{\n\/* Detects if the character and its othercase has only 1 bit difference. *\/\nunsigned int c, oc, bit;\n#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8\nint n;\n#endif\n\n#ifdef SUPPORT_UNICODE\nif (common->utf || common->ucp)\n  {\n  if (common->utf)\n    {\n    GETCHAR(c, cc);\n    }\n  else\n    c = *cc;\n\n  if (c <= 127)\n    oc = common->fcc[c];\n  else\n    oc = UCD_OTHERCASE(c);\n  }\nelse\n  {\n  c = *cc;\n  oc = TABLE_GET(c, common->fcc, c);\n  }\n#else\nc = *cc;\noc = TABLE_GET(c, common->fcc, c);\n#endif\n\nSLJIT_ASSERT(c != oc);\n\nbit = c ^ oc;\n\/* Optimized for English alphabet. *\/\nif (c <= 127 && bit == 0x20)\n  return (0 << 8) | 0x20;\n\n\/* Since c != oc, they must have at least 1 bit difference. *\/\nif (!is_powerof2(bit))\n  return 0;\n\n#if PCRE2_CODE_UNIT_WIDTH == 8\n\n#ifdef SUPPORT_UNICODE\nif (common->utf && c > 127)\n  {\n  n = GET_EXTRALEN(*cc);\n  while ((bit & 0x3f) == 0)\n    {\n    n--;\n    bit >>= 6;\n    }\n  return (n << 8) | bit;\n  }\n#endif \/* SUPPORT_UNICODE *\/\nreturn (0 << 8) | bit;\n\n#elif PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32\n\n#ifdef SUPPORT_UNICODE\nif (common->utf && c > 65535)\n  {\n  if (bit >= (1u << 10))\n    bit >>= 10;\n  else\n    return (bit < 256) ? ((2 << 8) | bit) : ((3 << 8) | (bit >> 8));\n  }\n#endif \/* SUPPORT_UNICODE *\/\nreturn (bit < 256) ? ((0u << 8) | bit) : ((1u << 8) | (bit >> 8));\n\n#endif \/* PCRE2_CODE_UNIT_WIDTH == [8|16|32] *\/\n}","target":0,"code_token_length":532,"total_token_length":768,"max_tokens_setting":1024}
+{"idx":247576,"func":"TEST_P(SslSocketTest, GetUriWithUriSan) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      match_typed_subject_alt_names:\n      - san_type: URI\n        matcher:\n          exact: \"spiffe:\/\/lyft.com\/test-team\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n               .setExpectedSerialNumber(TEST_SAN_URI_CERT_SERIAL));\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":259246,"func":"static int mov_rewrite_dvd_sub_extradata(AVStream *st)\n{\n    char buf[256] = {0};\n    uint8_t *src = st->codecpar->extradata;\n    int i, ret;\n\n    if (st->codecpar->extradata_size != 64)\n        return 0;\n\n    if (st->codecpar->width > 0 &&  st->codecpar->height > 0)\n        snprintf(buf, sizeof(buf), \"size: %dx%d\\n\",\n                 st->codecpar->width, st->codecpar->height);\n    av_strlcat(buf, \"palette: \", sizeof(buf));\n\n    for (i = 0; i < 16; i++) {\n        uint32_t yuv = AV_RB32(src + i * 4);\n        uint32_t rgba = yuv_to_rgba(yuv);\n\n        av_strlcatf(buf, sizeof(buf), \"%06\"PRIx32\"%s\", rgba, i != 15 ? \", \" : \"\");\n    }\n\n    if (av_strlcat(buf, \"\\n\", sizeof(buf)) >= sizeof(buf))\n        return 0;\n\n    ret = ff_alloc_extradata(st->codecpar, strlen(buf));\n    if (ret < 0)\n        return ret;\n    memcpy(st->codecpar->extradata, buf, st->codecpar->extradata_size);\n\n    return 0;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":259182,"func":"static void mov_estimate_video_delay(MOVContext *c, AVStream* st)\n{\n    MOVStreamContext *msc = st->priv_data;\n    FFStream *const sti = ffstream(st);\n    int ctts_ind = 0;\n    int ctts_sample = 0;\n    int64_t pts_buf[MAX_REORDER_DELAY + 1]; \/\/ Circular buffer to sort pts.\n    int buf_start = 0;\n    int j, r, num_swaps;\n\n    for (j = 0; j < MAX_REORDER_DELAY + 1; j++)\n        pts_buf[j] = INT64_MIN;\n\n    if (st->codecpar->video_delay <= 0 && msc->ctts_data &&\n        st->codecpar->codec_id == AV_CODEC_ID_H264) {\n        st->codecpar->video_delay = 0;\n        for (int ind = 0; ind < sti->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) {\n            \/\/ Point j to the last elem of the buffer and insert the current pts there.\n            j = buf_start;\n            buf_start = (buf_start + 1);\n            if (buf_start == MAX_REORDER_DELAY + 1)\n                buf_start = 0;\n\n            pts_buf[j] = sti->index_entries[ind].timestamp + msc->ctts_data[ctts_ind].duration;\n\n            \/\/ The timestamps that are already in the sorted buffer, and are greater than the\n            \/\/ current pts, are exactly the timestamps that need to be buffered to output PTS\n            \/\/ in correct sorted order.\n            \/\/ Hence the video delay (which is the buffer size used to sort DTS and output PTS),\n            \/\/ can be computed as the maximum no. of swaps any particular timestamp needs to\n            \/\/ go through, to keep this buffer in sorted order.\n            num_swaps = 0;\n            while (j != buf_start) {\n                r = j - 1;\n                if (r < 0) r = MAX_REORDER_DELAY;\n                if (pts_buf[j] < pts_buf[r]) {\n                    FFSWAP(int64_t, pts_buf[j], pts_buf[r]);\n                    ++num_swaps;\n                } else {\n                    break;\n                }\n                j = r;\n            }\n            st->codecpar->video_delay = FFMAX(st->codecpar->video_delay, num_swaps);\n\n            ctts_sample++;\n            if (ctts_sample == msc->ctts_data[ctts_ind].count) {\n                ctts_ind++;\n                ctts_sample = 0;\n            }\n        }\n        av_log(c->fc, AV_LOG_DEBUG, \"Setting codecpar->delay to %d for stream st: %d\\n\",\n               st->codecpar->video_delay, st->index);\n    }\n}","target":0,"code_token_length":598,"total_token_length":834,"max_tokens_setting":1024}
+{"idx":487611,"func":"asmlinkage long sys_getpriority(int which, int who)\n{\n\tstruct task_struct *g, *p;\n\tstruct user_struct *user;\n\tlong niceval, retval = -ESRCH;\n\tstruct pid *pgrp;\n\n\tif (which > 2 || which < 0)\n\t\treturn -EINVAL;\n\n\tread_lock(&tasklist_lock);\n\tswitch (which) {\n\t\tcase PRIO_PROCESS:\n\t\t\tif (who)\n\t\t\t\tp = find_task_by_pid(who);\n\t\t\telse\n\t\t\t\tp = current;\n\t\t\tif (p) {\n\t\t\t\tniceval = 20 - task_nice(p);\n\t\t\t\tif (niceval > retval)\n\t\t\t\t\tretval = niceval;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase PRIO_PGRP:\n\t\t\tif (who)\n\t\t\t\tpgrp = find_pid(who);\n\t\t\telse\n\t\t\t\tpgrp = task_pgrp(current);\n\t\t\tdo_each_pid_task(pgrp, PIDTYPE_PGID, p) {\n\t\t\t\tniceval = 20 - task_nice(p);\n\t\t\t\tif (niceval > retval)\n\t\t\t\t\tretval = niceval;\n\t\t\t} while_each_pid_task(pgrp, PIDTYPE_PGID, p);\n\t\t\tbreak;\n\t\tcase PRIO_USER:\n\t\t\tuser = current->user;\n\t\t\tif (!who)\n\t\t\t\twho = current->uid;\n\t\t\telse\n\t\t\t\tif ((who != current->uid) && !(user = find_user(who)))\n\t\t\t\t\tgoto out_unlock;\t\/* No processes for this user *\/\n\n\t\t\tdo_each_thread(g, p)\n\t\t\t\tif (p->uid == who) {\n\t\t\t\t\tniceval = 20 - task_nice(p);\n\t\t\t\t\tif (niceval > retval)\n\t\t\t\t\t\tretval = niceval;\n\t\t\t\t}\n\t\t\twhile_each_thread(g, p);\n\t\t\tif (who != current->uid)\n\t\t\t\tfree_uid(user);\t\t\/* for find_user() *\/\n\t\t\tbreak;\n\t}\nout_unlock:\n\tread_unlock(&tasklist_lock);\n\n\treturn retval;\n}","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":259155,"func":"static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    int i;\n    int64_t creation_time;\n    int version = avio_r8(pb); \/* version *\/\n    avio_rb24(pb); \/* flags *\/\n\n    if (version == 1) {\n        creation_time = avio_rb64(pb);\n        avio_rb64(pb);\n    } else {\n        creation_time = avio_rb32(pb);\n        avio_rb32(pb); \/* modification time *\/\n    }\n    mov_metadata_creation_time(&c->fc->metadata, creation_time, c->fc);\n    c->time_scale = avio_rb32(pb); \/* time scale *\/\n    if (c->time_scale <= 0) {\n        av_log(c->fc, AV_LOG_ERROR, \"Invalid mvhd time scale %d, defaulting to 1\\n\", c->time_scale);\n        c->time_scale = 1;\n    }\n    av_log(c->fc, AV_LOG_TRACE, \"time scale = %i\\n\", c->time_scale);\n\n    c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); \/* duration *\/\n    \/\/ set the AVFormatContext duration because the duration of individual tracks\n    \/\/ may be inaccurate\n    if (!c->trex_data)\n        c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);\n    avio_rb32(pb); \/* preferred scale *\/\n\n    avio_rb16(pb); \/* preferred volume *\/\n\n    avio_skip(pb, 10); \/* reserved *\/\n\n    \/* movie display matrix, store it in main context and use it later on *\/\n    for (i = 0; i < 3; i++) {\n        c->movie_display_matrix[i][0] = avio_rb32(pb); \/\/ 16.16 fixed point\n        c->movie_display_matrix[i][1] = avio_rb32(pb); \/\/ 16.16 fixed point\n        c->movie_display_matrix[i][2] = avio_rb32(pb); \/\/  2.30 fixed point\n    }\n\n    avio_rb32(pb); \/* preview time *\/\n    avio_rb32(pb); \/* preview duration *\/\n    avio_rb32(pb); \/* poster time *\/\n    avio_rb32(pb); \/* selection time *\/\n    avio_rb32(pb); \/* selection duration *\/\n    avio_rb32(pb); \/* current time *\/\n    avio_rb32(pb); \/* next track ID *\/\n\n    return 0;\n}","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":482472,"func":"addBackwardRuleWithSingleCell(const FileInfo *file, widechar cell,\n\t\tTranslationTableOffset ruleOffset, TranslationTableRule *rule,\n\t\tTranslationTableHeader **table) {\n\t\/* direction = 1, rule->dotslen = 1 *\/\n\tTranslationTableCharacter *dots;\n\tif (rule->opcode == CTO_SwapCc || rule->opcode == CTO_Repeated)\n\t\treturn; \/* too ambiguous *\/\n\t\/\/ get the cell from the table, or if the cell is not defined yet, define it (without\n\t\/\/ adding attributes)\n\tdots = putDots(file, cell, table);\n\t\/\/ putDots may have moved table, so make sure rule is still valid\n\trule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];\n\tif (rule->opcode >= CTO_Space && rule->opcode < CTO_UpLow)\n\t\tdots->definitionRule = ruleOffset;\n\tTranslationTableOffset *otherRule = &dots->otherRules;\n\twhile (*otherRule) {\n\t\tTranslationTableRule *r = (TranslationTableRule *)&(*table)->ruleArea[*otherRule];\n\t\tif (rule->charslen > r->charslen || r->dotslen == 0) break;\n\t\tif (r->opcode >= CTO_Space && r->opcode < CTO_UpLow)\n\t\t\tif (!(rule->opcode >= CTO_Space && rule->opcode < CTO_UpLow)) break;\n\t\totherRule = &r->dotsnext;\n\t}\n\trule->dotsnext = *otherRule;\n\t*otherRule = ruleOffset;\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":310094,"func":"decode_xterm_1005(SCREEN *sp, MEVENT * eventp)\n{\n    char kbuf[80];\n    size_t grabbed;\n    size_t limit = (sizeof(kbuf) - 1);\n    unsigned coords[2];\n    bool result;\n\n    coords[0] = 0;\n    coords[1] = 0;\n\n# if USE_PTHREADS_EINTR\n#  if USE_WEAK_SYMBOLS\n    if ((pthread_self) && (pthread_kill) && (pthread_equal))\n#  endif\n\t_nc_globals.read_thread = pthread_self();\n# endif\n    for (grabbed = 0; grabbed < limit;) {\n\tint res;\n\n\tres = (int) read(\n#if USE_EMX_MOUSE\n\t\t\t    (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd,\n#else\n\t\t\t    sp->_ifd,\n#endif\n\t\t\t    (kbuf + grabbed), (size_t) 1);\n\tif (res == -1)\n\t    break;\n\tgrabbed += (size_t) res;\n\tif (grabbed > 1) {\n\t    size_t check = 1;\n\t    int n;\n\n\t    for (n = 0; n < 2; ++n) {\n\t\tint rc;\n\n\t\tif (check >= grabbed)\n\t\t    break;\n\t\trc = _nc_conv_to_utf32(&coords[n], kbuf + check, (unsigned)\n\t\t\t\t       (grabbed - check));\n\t\tif (!rc)\n\t\t    break;\n\t\tcheck += (size_t) rc;\n\t    }\n\t    if (n >= 2)\n\t\tbreak;\n\t}\n    }\n#if USE_PTHREADS_EINTR\n    _nc_globals.read_thread = 0;\n#endif\n\n    TR(TRACE_IEVENT,\n       (\"_nc_mouse_inline sees the following xterm data: %s\",\n\t_nc_visbufn(kbuf, (int) grabbed)));\n\n    \/* there's only one mouse... *\/\n    eventp->id = NORMAL_EVENT;\n\n    result = decode_X10_bstate(sp, eventp, UChar(kbuf[0]));\n\n    eventp->x = (int) (coords[0] - ' ') - 1;\n    eventp->y = (int) (coords[1] - ' ') - 1;\n\n    return result;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":195019,"func":"Status ConstantFolding::EvaluateOneFoldable(const NodeDef& node,\n                                            std::vector<NodeDef>* outputs,\n                                            bool* result_too_large) {\n  TensorVector inputs;\n  TensorVector output_tensors;\n  auto inputs_cleanup = gtl::MakeCleanup([&inputs, &output_tensors] {\n    for (const auto& input : inputs) {\n      delete input.tensor;\n    }\n    for (const auto& output : output_tensors) {\n      if (output.tensor) {\n        delete output.tensor;\n      }\n    }\n  });\n\n  size_t total_inputs_size = 0;\n  for (const auto& input : node.input()) {\n    const TensorId input_tensor = ParseTensorName(input);\n    if (input_tensor.index() < 0) {\n      \/\/ Control dependency\n      break;\n    }\n    const NodeDef* input_node = node_map_->GetNode(input);\n    if (!IsReallyConstant(*input_node)) {\n      return Status(error::INVALID_ARGUMENT,\n                    strings::StrCat(\"Can't fold \", node.name(), \", its \", input,\n                                    \" isn't constant\"));\n    }\n    TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, \"value\"));\n    const TensorProto& raw_val = input_node->attr().at(\"value\").tensor();\n    if (raw_val.dtype() == DT_INVALID) {\n      return Status(\n          error::INVALID_ARGUMENT,\n          strings::StrCat(\"A tensor in the input node, with TensorId of \",\n                          input_tensor.ToString(),\n                          \" has a dtype of DT_INVALID.\"));\n    }\n    Tensor* value = new Tensor(raw_val.dtype(), raw_val.tensor_shape());\n    if (!value->FromProto(raw_val)) {\n      delete (value);\n      return errors::InvalidArgument(\"Unable to make Tensor from proto for \",\n                                     node.name(), \" with shape \",\n                                     raw_val.tensor_shape().DebugString());\n    }\n    inputs.emplace_back(value);\n    total_inputs_size += value->TotalBytes();\n  }\n\n  TF_RETURN_IF_ERROR(EvaluateNode(node, inputs, &output_tensors));\n  if (output_tensors.empty()) {\n    return Status(error::INVALID_ARGUMENT, \"Expected at least one output.\");\n  }\n\n  outputs->resize(output_tensors.size());\n  for (size_t i = 0; i < output_tensors.size(); i++) {\n    string node_name = OptimizedNodeName(node, \"-folded\");\n    if (output_tensors.size() > 1) {\n      node_name = strings::StrCat(node_name, \"-\", i);\n    }\n    if (output_tensors[i].tensor) {\n      Status s = CreateNodeDef(node_name, output_tensors[i], &outputs->at(i),\n                               total_inputs_size);\n      if (!s.ok()) {\n        *result_too_large = true;\n        return s;\n      }\n    } else {\n      \/\/ Create an empty NodeDef to identify dead outputs (e.g. the output of a\n      \/\/ switch that's not selected by the switch predicate).\n      outputs->at(i) = NodeDef();\n    }\n  }\n  return Status::OK();\n}","target":1,"code_token_length":626,"total_token_length":862,"max_tokens_setting":1024}
+{"idx":384127,"func":"raptor_xml_writer_indent(raptor_xml_writer *xml_writer)\n{\n  int num_spaces;\n\n  if(!XML_WRITER_AUTO_INDENT(xml_writer)) {\n    if(xml_writer->pending_newline) {\n      raptor_iostream_write_byte('\\n', xml_writer->iostr);\n      xml_writer->pending_newline = 0;\n\n      if(xml_writer->current_element)\n        xml_writer->current_element->content_cdata_seen = 1;\n    }\n    return 0;\n  }\n  \n  num_spaces = xml_writer->depth * XML_WRITER_INDENT(xml_writer);\n\n  \/* Do not write an extra newline at the start of the document\n   * (after the XML declaration or XMP processing instruction has\n   * been writtten)\n   *\/\n  if(xml_writer->xml_declaration_checked == 1)\n    xml_writer->xml_declaration_checked++;\n  else {\n    raptor_iostream_write_byte('\\n', xml_writer->iostr);\n    xml_writer->pending_newline = 0;\n  }\n  \n  while(num_spaces > 0) {\n\n    int count = (num_spaces > RAPTOR_GOOD_CAST(int, SPACES_BUFFER_SIZE)) ?\n                 RAPTOR_GOOD_CAST(int, SPACES_BUFFER_SIZE) : num_spaces;\n\n    raptor_iostream_counted_string_write(spaces_buffer, count,\n                                         xml_writer->iostr);\n\n    num_spaces -= count;\n  }\n\n  if(xml_writer->current_element)\n    xml_writer->current_element->content_cdata_seen = 1;\n\n  return 0;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":300747,"func":"static void __tipc_shutdown(struct socket *sock, int error)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct net *net = sock_net(sk);\n\tlong timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT);\n\tu32 dnode = tsk_peer_node(tsk);\n\tstruct sk_buff *skb;\n\n\t\/* Avoid that hi-prio shutdown msgs bypass msgs in link wakeup queue *\/\n\ttipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt &&\n\t\t\t\t\t    !tsk_conn_cong(tsk)));\n\n\t\/* Push out delayed messages if in Nagle mode *\/\n\ttipc_sk_push_backlog(tsk, false);\n\t\/* Remove pending SYN *\/\n\t__skb_queue_purge(&sk->sk_write_queue);\n\n\t\/* Remove partially received buffer if any *\/\n\tskb = skb_peek(&sk->sk_receive_queue);\n\tif (skb && TIPC_SKB_CB(skb)->bytes_read) {\n\t\t__skb_unlink(skb, &sk->sk_receive_queue);\n\t\tkfree_skb(skb);\n\t}\n\n\t\/* Reject all unreceived messages if connectionless *\/\n\tif (tipc_sk_type_connectionless(sk)) {\n\t\ttsk_rej_rx_queue(sk, error);\n\t\treturn;\n\t}\n\n\tswitch (sk->sk_state) {\n\tcase TIPC_CONNECTING:\n\tcase TIPC_ESTABLISHED:\n\t\ttipc_set_sk_state(sk, TIPC_DISCONNECTING);\n\t\ttipc_node_remove_conn(net, dnode, tsk->portid);\n\t\t\/* Send a FIN+\/- to its peer *\/\n\t\tskb = __skb_dequeue(&sk->sk_receive_queue);\n\t\tif (skb) {\n\t\t\t__skb_queue_purge(&sk->sk_receive_queue);\n\t\t\ttipc_sk_respond(sk, skb, error);\n\t\t\tbreak;\n\t\t}\n\t\tskb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE,\n\t\t\t\t      TIPC_CONN_MSG, SHORT_H_SIZE, 0, dnode,\n\t\t\t\t      tsk_own_node(tsk), tsk_peer_port(tsk),\n\t\t\t\t      tsk->portid, error);\n\t\tif (skb)\n\t\t\ttipc_node_xmit_skb(net, skb, dnode, tsk->portid);\n\t\tbreak;\n\tcase TIPC_LISTEN:\n\t\t\/* Reject all SYN messages *\/\n\t\ttsk_rej_rx_queue(sk, error);\n\t\tbreak;\n\tdefault:\n\t\t__skb_queue_purge(&sk->sk_receive_queue);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":355632,"func":"eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)\n{\n    char_u\t*p;\n    int\t\tgetnext;\n    exprtype_T\ttype = EXPR_UNKNOWN;\n    int\t\tlen = 2;\n    int\t\ttype_is = FALSE;\n\n    \/*\n     * Get the first variable.\n     *\/\n    if (eval5(arg, rettv, evalarg) == FAIL)\n\treturn FAIL;\n\n    p = eval_next_non_blank(*arg, evalarg, &getnext);\n    type = get_compare_type(p, &len, &type_is);\n\n    \/*\n     * If there is a comparative operator, use it.\n     *\/\n    if (type != EXPR_UNKNOWN)\n    {\n\ttypval_T    var2;\n\tint\t    ic;\n\tint\t    vim9script = in_vim9script();\n\tint\t    evaluate = evalarg == NULL\n\t\t\t\t   ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);\n\n\tif (getnext)\n\t{\n\t    *arg = eval_next_line(evalarg);\n\t    p = *arg;\n\t}\n\telse if (evaluate && vim9script && !VIM_ISWHITE(**arg))\n\t{\n\t    error_white_both(*arg, len);\n\t    clear_tv(rettv);\n\t    return FAIL;\n\t}\n\n\tif (vim9script && type_is && (p[len] == '?' || p[len] == '#'))\n\t{\n\t    semsg(_(e_invalid_expression_str), p);\n\t    clear_tv(rettv);\n\t    return FAIL;\n\t}\n\n\t\/\/ extra question mark appended: ignore case\n\tif (p[len] == '?')\n\t{\n\t    ic = TRUE;\n\t    ++len;\n\t}\n\t\/\/ extra '#' appended: match case\n\telse if (p[len] == '#')\n\t{\n\t    ic = FALSE;\n\t    ++len;\n\t}\n\t\/\/ nothing appended: use 'ignorecase' if not in Vim script\n\telse\n\t    ic = vim9script ? FALSE : p_ic;\n\n\t\/*\n\t * Get the second variable.\n\t *\/\n\tif (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len]))\n\t{\n\t    error_white_both(p, len);\n\t    clear_tv(rettv);\n\t    return FAIL;\n\t}\n\t*arg = skipwhite_and_linebreak(p + len, evalarg);\n\tif (eval5(arg, &var2, evalarg) == FAIL)\n\t{\n\t    clear_tv(rettv);\n\t    return FAIL;\n\t}\n\tif (evaluate)\n\t{\n\t    int ret;\n\n\t    if (vim9script && check_compare_types(type, rettv, &var2) == FAIL)\n\t    {\n\t\tret = FAIL;\n\t\tclear_tv(rettv);\n\t    }\n\t    else\n\t\tret = typval_compare(rettv, &var2, type, ic);\n\t    clear_tv(&var2);\n\t    return ret;\n\t}\n    }\n\n    return OK;\n}","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":223371,"func":"static sljit_s32 SLJIT_FUNC do_callout(struct jit_arguments *arguments, pcre2_callout_block *callout_block, PCRE2_SPTR *jit_ovector)\n{\nPCRE2_SPTR begin;\nPCRE2_SIZE *ovector;\nsljit_u32 oveccount, capture_top;\n\nif (arguments->callout == NULL)\n  return 0;\n\nSLJIT_COMPILE_ASSERT(sizeof (PCRE2_SIZE) <= sizeof (sljit_sw), pcre2_size_must_be_lower_than_sljit_sw_size);\n\nbegin = arguments->begin;\novector = (PCRE2_SIZE*)(callout_block + 1);\noveccount = callout_block->capture_top;\n\nSLJIT_ASSERT(oveccount >= 1);\n\ncallout_block->version = 2;\ncallout_block->callout_flags = 0;\n\n\/* Offsets in subject. *\/\ncallout_block->subject_length = arguments->end - arguments->begin;\ncallout_block->start_match = jit_ovector[0] - begin;\ncallout_block->current_position = (PCRE2_SPTR)callout_block->offset_vector - begin;\ncallout_block->subject = begin;\n\n\/* Convert and copy the JIT offset vector to the ovector array. *\/\ncallout_block->capture_top = 1;\ncallout_block->offset_vector = ovector;\n\novector[0] = PCRE2_UNSET;\novector[1] = PCRE2_UNSET;\novector += 2;\njit_ovector += 2;\ncapture_top = 1;\n\n\/* Convert pointers to sizes. *\/\nwhile (--oveccount != 0)\n  {\n  capture_top++;\n\n  ovector[0] = (PCRE2_SIZE)(jit_ovector[0] - begin);\n  ovector[1] = (PCRE2_SIZE)(jit_ovector[1] - begin);\n\n  if (ovector[0] != PCRE2_UNSET)\n    callout_block->capture_top = capture_top;\n\n  ovector += 2;\n  jit_ovector += 2;\n  }\n\nreturn (arguments->callout)(callout_block, arguments->callout_data);\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":353188,"func":"void SplashOutputDev::iccTransform(void *data, SplashBitmap *bitmap) {\n  SplashOutImageData *imgData = (SplashOutImageData *)data;\n  int nComps = imgData->colorMap->getNumPixelComps();\n\n  unsigned char *colorLine = (unsigned char *) gmalloc(nComps * bitmap->getWidth());\n  unsigned char *rgbxLine = (imgData->colorMode == splashModeXBGR8) ? (unsigned char *) gmalloc(3 * bitmap->getWidth()) : nullptr;\n  for (int i = 0; i < bitmap->getHeight(); i++) {\n    unsigned char *p = bitmap->getDataPtr() + i * bitmap->getRowSize();\n    switch (imgData->colorMode) {\n    case splashModeMono1:\n    case splashModeMono8:\n      imgData->colorMap->getGrayLine(p, colorLine, bitmap->getWidth());\n      memcpy(p, colorLine, nComps * bitmap->getWidth());\n      break;\n    case splashModeRGB8:\n    case splashModeBGR8:\n      imgData->colorMap->getRGBLine(p, colorLine, bitmap->getWidth());\n      memcpy(p, colorLine, nComps * bitmap->getWidth());\n      break;\n#ifdef SPLASH_CMYK\n    case splashModeCMYK8:\n      imgData->colorMap->getCMYKLine(p, colorLine, bitmap->getWidth());\n      memcpy(p, colorLine, nComps * bitmap->getWidth());\n      break;\n    case splashModeDeviceN8:\n      imgData->colorMap->getDeviceNLine(p, colorLine, bitmap->getWidth());\n      memcpy(p, colorLine, nComps * bitmap->getWidth());\n      break;\n#endif\n    case splashModeXBGR8:\n      unsigned char *q;\n      unsigned char *b = p;\n      int x;\n      for (x = 0, q = rgbxLine; x < bitmap->getWidth(); ++x, b+=4) {\n        *q++ = b[2];\n        *q++ = b[1];\n        *q++ = b[0];\n      }\n      imgData->colorMap->getRGBLine(rgbxLine, colorLine, bitmap->getWidth());\n      b = p;\n      for (x = 0, q = colorLine; x < bitmap->getWidth(); ++x, b+=4) {\n        b[2] = *q++;\n        b[1] = *q++;\n        b[0] = *q++;\n      }\n      break;\n    }\n  }\n  gfree(colorLine);\n  if (rgbxLine != nullptr) \n    gfree(rgbxLine);\n}","target":0,"code_token_length":557,"total_token_length":793,"max_tokens_setting":1024}
+{"idx":402599,"func":"generate_auth_info(cms_context *cms, SECItem *der, char *url)\n{\n\tAuthInfo ai;\n\n\tSECOidData *oid = SECOID_FindOIDByTag(SEC_OID_PKIX_CA_ISSUERS);\n\tif (!oid)\n\t\tcmsreterr(-1, cms, \"could not get CA issuers OID\");\n\n\tmemcpy(&ai.oid, &oid->oid, sizeof (ai.oid));\n\n\tSECItem urlitem = {\n\t\t.data = (unsigned char *)url,\n\t\t.len = strlen(url),\n\t\t.type = siBuffer\n\t};\n\tint rc = make_context_specific(cms, 6, &ai.url, &urlitem);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tvoid *ret;\n\tSECItem unwrapped;\n\tret = SEC_ASN1EncodeItem(cms->arena, &unwrapped, &ai, AuthInfoTemplate);\n\tif (ret == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode CA Issuers\");\n\n\trc = wrap_in_seq(cms, der, &unwrapped, 1);\n\tif (rc < 0)\n\t\treturn rc;\n\treturn 0;\n\n\t\/* I've no idea how to get SEC_ASN1EncodeItem to spit out the thing\n\t * we actually want here.  So once again, just force the data to\n\t * look correct :( *\/\n\tif (unwrapped.len < 12) {\n\t\tcms->log(cms, LOG_ERR, \"%s:%s:%d generated CA Issuers Info \"\n\t\t\t\"cannot possibly be valid\",\n\t\t\t__FILE__, __func__, __LINE__);\n\t\treturn -1;\n\t}\n\tunwrapped.data[12] = 0x86;\n\tunwrapped.type = siBuffer;\n\n\tAuthInfo wrapper;\n\toid = SECOID_FindOIDByTag(SEC_OID_X509_AUTH_INFO_ACCESS);\n\tif (!oid)\n\t\tcmsreterr(-1, cms, \"could not find Auth Info Access OID\");\n\n\tmemcpy(&wrapper.oid, &oid->oid, sizeof (ai.oid));\n\n\twrap_in_seq(cms, &wrapper.url, &unwrapped, 1);\n\n\tret = SEC_ASN1EncodeItem(cms->arena, der, &wrapper,\n\t\t\t\t\tAuthInfoWrapperTemplate);\n\tif (ret == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode CA Issuers OID\");\n\n\treturn 0;\n}","target":0,"code_token_length":508,"total_token_length":744,"max_tokens_setting":1024}
+{"idx":405391,"func":"static void xfrm_policy_inexact_node_reinsert(struct net *net,\n\t\t\t\t\t      struct xfrm_pol_inexact_node *n,\n\t\t\t\t\t      struct rb_root *new,\n\t\t\t\t\t      u16 family)\n{\n\tstruct xfrm_pol_inexact_node *node;\n\tstruct rb_node **p, *parent;\n\n\t\/* we should not have another subtree here *\/\n\tWARN_ON_ONCE(!RB_EMPTY_ROOT(&n->root));\nrestart:\n\tparent = NULL;\n\tp = &new->rb_node;\n\twhile (*p) {\n\t\tu8 prefixlen;\n\t\tint delta;\n\n\t\tparent = *p;\n\t\tnode = rb_entry(*p, struct xfrm_pol_inexact_node, node);\n\n\t\tprefixlen = min(node->prefixlen, n->prefixlen);\n\n\t\tdelta = xfrm_policy_addr_delta(&n->addr, &node->addr,\n\t\t\t\t\t       prefixlen, family);\n\t\tif (delta < 0) {\n\t\t\tp = &parent->rb_left;\n\t\t} else if (delta > 0) {\n\t\t\tp = &parent->rb_right;\n\t\t} else {\n\t\t\tbool same_prefixlen = node->prefixlen == n->prefixlen;\n\t\t\tstruct xfrm_policy *tmp;\n\n\t\t\thlist_for_each_entry(tmp, &n->hhead, bydst) {\n\t\t\t\ttmp->bydst_reinsert = true;\n\t\t\t\thlist_del_rcu(&tmp->bydst);\n\t\t\t}\n\n\t\t\tnode->prefixlen = prefixlen;\n\n\t\t\txfrm_policy_inexact_list_reinsert(net, node, family);\n\n\t\t\tif (same_prefixlen) {\n\t\t\t\tkfree_rcu(n, rcu);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\trb_erase(*p, new);\n\t\t\tkfree_rcu(n, rcu);\n\t\t\tn = node;\n\t\t\tgoto restart;\n\t\t}\n\t}\n\n\trb_link_node_rcu(&n->node, parent, p);\n\trb_insert_color(&n->node, new);\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":383379,"func":"void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)\n{\n\tint x=0,mx1=0,mx2=0,my1=0,my2=0;\n\tlong aq,bq,dx,dy,r,rx,ry,a,b;\n\n\ta=w>>1;\n\tb=h>>1;\n\tgdImageSetPixel(im,mx+a, my, c);\n\tgdImageSetPixel(im,mx-a, my, c);\n\tmx1 = mx-a;my1 = my;\n\tmx2 = mx+a;my2 = my;\n\n\taq = a * a;\n\tbq = b * b;\n\tdx = aq << 1;\n\tdy = bq << 1;\n\tr  = a * bq;\n\trx = r << 1;\n\try = 0;\n\tx = a;\n\twhile (x > 0){\n\t\tif (r > 0) {\n\t\t\tmy1++;my2--;\n\t\t\try +=dx;\n\t\t\tr  -=ry;\n\t\t}\n\t\tif (r <= 0){\n\t\t\tx--;\n\t\t\tmx1++;mx2--;\n\t\t\trx -=dy;\n\t\t\tr  +=rx;\n\t\t}\n\t\tgdImageSetPixel(im,mx1, my1, c);\n\t\tgdImageSetPixel(im,mx1, my2, c);\n\t\tgdImageSetPixel(im,mx2, my1, c);\n\t\tgdImageSetPixel(im,mx2, my2, c);\n\t}\n}","target":0,"code_token_length":324,"total_token_length":560,"max_tokens_setting":1024}
+{"idx":278246,"func":"get_expr_indent(void)\n{\n    int\t\tindent = -1;\n    char_u\t*inde_copy;\n    pos_T\tsave_pos;\n    colnr_T\tsave_curswant;\n    int\t\tsave_set_curswant;\n    int\t\tsave_State;\n    int\t\tuse_sandbox = was_set_insecurely((char_u *)\"indentexpr\",\n\t\t\t\t\t\t\t\t   OPT_LOCAL);\n    sctx_T\tsave_sctx = current_sctx;\n\n    \/\/ Save and restore cursor position and curswant, in case it was changed\n    \/\/ via :normal commands\n    save_pos = curwin->w_cursor;\n    save_curswant = curwin->w_curswant;\n    save_set_curswant = curwin->w_set_curswant;\n    set_vim_var_nr(VV_LNUM, curwin->w_cursor.lnum);\n    if (use_sandbox)\n\t++sandbox;\n    ++textlock;\n    current_sctx = curbuf->b_p_script_ctx[BV_INDE];\n\n    \/\/ Need to make a copy, the 'indentexpr' option could be changed while\n    \/\/ evaluating it.\n    inde_copy = vim_strsave(curbuf->b_p_inde);\n    if (inde_copy != NULL)\n    {\n\tindent = (int)eval_to_number(inde_copy);\n\tvim_free(inde_copy);\n    }\n\n    if (use_sandbox)\n\t--sandbox;\n    --textlock;\n    current_sctx = save_sctx;\n\n    \/\/ Restore the cursor position so that 'indentexpr' doesn't need to.\n    \/\/ Pretend to be in Insert mode, allow cursor past end of line for \"o\"\n    \/\/ command.\n    save_State = State;\n    State = MODE_INSERT;\n    curwin->w_cursor = save_pos;\n    curwin->w_curswant = save_curswant;\n    curwin->w_set_curswant = save_set_curswant;\n    check_cursor();\n    State = save_State;\n\n    \/\/ Reset did_throw, unless 'debug' has \"throw\" and inside a try\/catch.\n    if (did_throw && (vim_strchr(p_debug, 't') == NULL || trylevel == 0))\n    {\n\thandle_did_throw();\n\tdid_throw = FALSE;\n    }\n\n    \/\/ If there is an error, just keep the current indent.\n    if (indent < 0)\n\tindent = get_indent();\n\n    return indent;\n}","target":0,"code_token_length":498,"total_token_length":734,"max_tokens_setting":1024}
+{"idx":333076,"func":"match_backref(\n    regsub_T\t*sub,\t    \/\/ pointers to subexpressions\n    int\t\tsubidx,\n    int\t\t*bytelen)   \/\/ out: length of match in bytes\n{\n    int\t\tlen;\n\n    if (sub->in_use <= subidx)\n    {\nretempty:\n\t\/\/ backref was not set, match an empty string\n\t*bytelen = 0;\n\treturn TRUE;\n    }\n\n    if (REG_MULTI)\n    {\n\tif (sub->list.multi[subidx].start_lnum < 0\n\t\t\t\t       || sub->list.multi[subidx].end_lnum < 0)\n\t    goto retempty;\n\tif (sub->list.multi[subidx].start_lnum == rex.lnum\n\t\t\t       && sub->list.multi[subidx].end_lnum == rex.lnum)\n\t{\n\t    len = sub->list.multi[subidx].end_col\n\t\t\t\t\t  - sub->list.multi[subidx].start_col;\n\t    if (cstrncmp(rex.line + sub->list.multi[subidx].start_col,\n\t\t\t\t\t\t\t rex.input, &len) == 0)\n\t    {\n\t\t*bytelen = len;\n\t\treturn TRUE;\n\t    }\n\t}\n\telse\n\t{\n\t    if (match_with_backref(\n\t\t\tsub->list.multi[subidx].start_lnum,\n\t\t\tsub->list.multi[subidx].start_col,\n\t\t\tsub->list.multi[subidx].end_lnum,\n\t\t\tsub->list.multi[subidx].end_col,\n\t\t\tbytelen) == RA_MATCH)\n\t\treturn TRUE;\n\t}\n    }\n    else\n    {\n\tif (sub->list.line[subidx].start == NULL\n\t\t\t\t\t|| sub->list.line[subidx].end == NULL)\n\t    goto retempty;\n\tlen = (int)(sub->list.line[subidx].end - sub->list.line[subidx].start);\n\tif (cstrncmp(sub->list.line[subidx].start, rex.input, &len) == 0)\n\t{\n\t    *bytelen = len;\n\t    return TRUE;\n\t}\n    }\n    return FALSE;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":445881,"func":"_fr_window_ask_overwrite_dialog (OverwriteData *odata)\n{\n\tgboolean perform_extraction = TRUE;\n\n\tif ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL)) {\n\t\tconst char *base_name;\n\t\tGFile      *destination;\n\n\t\tbase_name = _g_path_get_relative_basename_safe ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths);\n\t\tif (base_name != NULL) {\n\t\t\tdestination = g_file_get_child (odata->edata->destination, base_name);\n\t\t\tg_file_query_info_async (destination,\n\t\t\t\t\t\t G_FILE_ATTRIBUTE_STANDARD_TYPE \",\" G_FILE_ATTRIBUTE_STANDARD_NAME \",\" G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,\n\t\t\t\t\t\t G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,\n\t\t\t\t\t\t G_PRIORITY_DEFAULT,\n\t\t\t\t\t\t odata->window->priv->cancellable,\n\t\t\t\t\t\t query_info_ready_for_overwrite_dialog_cb,\n\t\t\t\t\t\t odata);\n\n\t\t\tg_object_unref (destination);\n\n\t\t\treturn;\n\t\t}\n\t\telse\n\t\t\tperform_extraction = FALSE;\n\t}\n\n\tif (odata->edata->file_list == NULL)\n\t\tperform_extraction = FALSE;\n\n\tif (perform_extraction) {\n\t\t\/* speed optimization: passing NULL when extracting all the\n\t\t * files is faster if the command supports the\n\t\t * propCanExtractAll property. *\/\n\t\tif (odata->extract_all) {\n\t\t\t_g_string_list_free (odata->edata->file_list);\n\t\t\todata->edata->file_list = NULL;\n\t\t}\n\t\todata->edata->overwrite = FR_OVERWRITE_YES;\n\t\t_fr_window_archive_extract_from_edata (odata->window, odata->edata);\n\t}\n\telse {\n\t\tGtkWidget *d;\n\n\t\td = _gtk_message_dialog_new (GTK_WINDOW (odata->window),\n\t\t\t\t\t     0,\n\t\t\t\t\t     GTK_STOCK_DIALOG_WARNING,\n\t\t\t\t\t     _(\"Extraction not performed\"),\n\t\t\t\t\t     NULL,\n\t\t\t\t\t     GTK_STOCK_OK, GTK_RESPONSE_OK,\n\t\t\t\t\t     NULL);\n\t\tgtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK);\n\t\tfr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window), _(\"Extraction not performed\"));\n\n\t\tfr_window_stop_batch (odata->window);\n\t}\n\n\tg_free (odata);\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":313770,"func":"nv_left(cmdarg_T *cap)\n{\n    long\tn;\n\n    if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))\n    {\n\t\/\/ <C-Left> and <S-Left> move a word or WORD left\n\tif (mod_mask & MOD_MASK_CTRL)\n\t    cap->arg = 1;\n\tnv_bck_word(cap);\n\treturn;\n    }\n\n    cap->oap->motion_type = MCHAR;\n    cap->oap->inclusive = FALSE;\n    for (n = cap->count1; n > 0; --n)\n    {\n\tif (oneleft() == FAIL)\n\t{\n\t    \/\/ <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'.\n\t    \/\/\t\t 'h' wraps to previous line if 'whichwrap' has 'h'.\n\t    \/\/\t   CURS_LEFT wraps to previous line if 'whichwrap' has '<'.\n\t    if (       (((cap->cmdchar == K_BS\n\t\t\t\t|| cap->cmdchar == Ctrl_H)\n\t\t\t    && vim_strchr(p_ww, 'b') != NULL)\n\t\t\t|| (cap->cmdchar == 'h'\n\t\t\t    && vim_strchr(p_ww, 'h') != NULL)\n\t\t\t|| (cap->cmdchar == K_LEFT\n\t\t\t    && vim_strchr(p_ww, '<') != NULL))\n\t\t    && curwin->w_cursor.lnum > 1)\n\t    {\n\t\t--(curwin->w_cursor.lnum);\n\t\tcoladvance((colnr_T)MAXCOL);\n\t\tcurwin->w_set_curswant = TRUE;\n\n\t\t\/\/ When the NL before the first char has to be deleted we\n\t\t\/\/ put the cursor on the NUL after the previous line.\n\t\t\/\/ This is a very special case, be careful!\n\t\t\/\/ Don't adjust op_end now, otherwise it won't work.\n\t\tif (\t   (cap->oap->op_type == OP_DELETE\n\t\t\t    || cap->oap->op_type == OP_CHANGE)\n\t\t\t&& !LINEEMPTY(curwin->w_cursor.lnum))\n\t\t{\n\t\t    char_u *cp = ml_get_cursor();\n\n\t\t    if (*cp != NUL)\n\t\t    {\n\t\t\tif (has_mbyte)\n\t\t\t    curwin->w_cursor.col += (*mb_ptr2len)(cp);\n\t\t\telse\n\t\t\t    ++curwin->w_cursor.col;\n\t\t    }\n\t\t    cap->retval |= CA_NO_ADJ_OP_END;\n\t\t}\n\t\tcontinue;\n\t    }\n\t    \/\/ Only beep and flush if not moved at all\n\t    else if (cap->oap->op_type == OP_NOP && n == cap->count1)\n\t\tbeep_flush();\n\t    break;\n\t}\n    }\n#ifdef FEAT_FOLDING\n    if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped\n\t\t\t\t\t       && cap->oap->op_type == OP_NOP)\n\tfoldOpenCursor();\n#endif\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":223453,"func":"static void do_getucd(compiler_common *common)\n{\n\/* Search the UCD record for the character comes in TMP1.\nReturns chartype in TMP1 and UCD offset in TMP2. *\/\nDEFINE_COMPILER;\n#if PCRE2_CODE_UNIT_WIDTH == 32\nstruct sljit_jump *jump;\n#endif\n\n#if defined SLJIT_DEBUG && SLJIT_DEBUG\n\/* dummy_ucd_record *\/\nconst ucd_record *record = GET_UCD(UNASSIGNED_UTF_CHAR);\nSLJIT_ASSERT(record->script == ucp_Unknown && record->chartype == ucp_Cn && record->gbprop == ucp_gbOther);\nSLJIT_ASSERT(record->caseset == 0 && record->other_case == 0);\n#endif\n\nSLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && sizeof(ucd_record) == 12);\n\nsljit_emit_fast_enter(compiler, RETURN_ADDR, 0);\n\n#if PCRE2_CODE_UNIT_WIDTH == 32\nif (!common->utf)\n  {\n  jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1);\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, UNASSIGNED_UTF_CHAR);\n  JUMPHERE(jump);\n  }\n#endif\n\nOP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);\nOP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));\nOP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\nOP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));\nOP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":477277,"func":"static int tipc_aead_init(struct tipc_aead **aead, struct tipc_aead_key *ukey,\n\t\t\t  u8 mode)\n{\n\tstruct tipc_tfm *tfm_entry, *head;\n\tstruct crypto_aead *tfm;\n\tstruct tipc_aead *tmp;\n\tint keylen, err, cpu;\n\tint tfm_cnt = 0;\n\n\tif (unlikely(*aead))\n\t\treturn -EEXIST;\n\n\t\/* Allocate a new AEAD *\/\n\ttmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);\n\tif (unlikely(!tmp))\n\t\treturn -ENOMEM;\n\n\t\/* The key consists of two parts: [AES-KEY][SALT] *\/\n\tkeylen = ukey->keylen - TIPC_AES_GCM_SALT_SIZE;\n\n\t\/* Allocate per-cpu TFM entry pointer *\/\n\ttmp->tfm_entry = alloc_percpu(struct tipc_tfm *);\n\tif (!tmp->tfm_entry) {\n\t\tkfree_sensitive(tmp);\n\t\treturn -ENOMEM;\n\t}\n\n\t\/* Make a list of TFMs with the user key data *\/\n\tdo {\n\t\ttfm = crypto_alloc_aead(ukey->alg_name, 0, 0);\n\t\tif (IS_ERR(tfm)) {\n\t\t\terr = PTR_ERR(tfm);\n\t\t\tbreak;\n\t\t}\n\n\t\tif (unlikely(!tfm_cnt &&\n\t\t\t     crypto_aead_ivsize(tfm) != TIPC_AES_GCM_IV_SIZE)) {\n\t\t\tcrypto_free_aead(tfm);\n\t\t\terr = -ENOTSUPP;\n\t\t\tbreak;\n\t\t}\n\n\t\terr = crypto_aead_setauthsize(tfm, TIPC_AES_GCM_TAG_SIZE);\n\t\terr |= crypto_aead_setkey(tfm, ukey->key, keylen);\n\t\tif (unlikely(err)) {\n\t\t\tcrypto_free_aead(tfm);\n\t\t\tbreak;\n\t\t}\n\n\t\ttfm_entry = kmalloc(sizeof(*tfm_entry), GFP_KERNEL);\n\t\tif (unlikely(!tfm_entry)) {\n\t\t\tcrypto_free_aead(tfm);\n\t\t\terr = -ENOMEM;\n\t\t\tbreak;\n\t\t}\n\t\tINIT_LIST_HEAD(&tfm_entry->list);\n\t\ttfm_entry->tfm = tfm;\n\n\t\t\/* First entry? *\/\n\t\tif (!tfm_cnt) {\n\t\t\thead = tfm_entry;\n\t\t\tfor_each_possible_cpu(cpu) {\n\t\t\t\t*per_cpu_ptr(tmp->tfm_entry, cpu) = head;\n\t\t\t}\n\t\t} else {\n\t\t\tlist_add_tail(&tfm_entry->list, &head->list);\n\t\t}\n\n\t} while (++tfm_cnt < sysctl_tipc_max_tfms);\n\n\t\/* Not any TFM is allocated? *\/\n\tif (!tfm_cnt) {\n\t\tfree_percpu(tmp->tfm_entry);\n\t\tkfree_sensitive(tmp);\n\t\treturn err;\n\t}\n\n\t\/* Form a hex string of some last bytes as the key's hint *\/\n\tbin2hex(tmp->hint, ukey->key + keylen - TIPC_AEAD_HINT_LEN,\n\t\tTIPC_AEAD_HINT_LEN);\n\n\t\/* Initialize the other data *\/\n\ttmp->mode = mode;\n\ttmp->cloned = NULL;\n\ttmp->authsize = TIPC_AES_GCM_TAG_SIZE;\n\ttmp->key = kmemdup(ukey, tipc_aead_key_size(ukey), GFP_KERNEL);\n\tmemcpy(&tmp->salt, ukey->key + keylen, TIPC_AES_GCM_SALT_SIZE);\n\tatomic_set(&tmp->users, 0);\n\tatomic64_set(&tmp->seqno, 0);\n\trefcount_set(&tmp->refcnt, 1);\n\n\t*aead = tmp;\n\treturn 0;\n}","target":0,"code_token_length":747,"total_token_length":983,"max_tokens_setting":1024}
+{"idx":292156,"func":"methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code,\n                                                     const constantPoolHandle& pool, int index, TRAPS) {\n  \/\/ This method is used only\n  \/\/ (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),\n  \/\/ and\n  \/\/ (2) in Bytecode_invoke::static_target\n  \/\/ It appears to fail when applied to an invokeinterface call site.\n  \/\/ FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.\n  \/\/ resolve klass\n  if (code == Bytecodes::_invokedynamic) {\n    Klass* resolved_klass = SystemDictionary::MethodHandle_klass();\n    Symbol* method_name = vmSymbols::invoke_name();\n    Symbol* method_signature = pool->signature_ref_at(index);\n    Klass*  current_klass = pool->pool_holder();\n    LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);\n    return resolve_method(link_info, code, THREAD);\n  }\n\n  LinkInfo link_info(pool, index, methodHandle(), CHECK_NULL);\n  Klass* resolved_klass = link_info.resolved_klass();\n\n  if (pool->has_preresolution()\n      || (resolved_klass == SystemDictionary::MethodHandle_klass() &&\n          MethodHandles::is_signature_polymorphic_name(resolved_klass, link_info.name()))) {\n    Method* result = ConstantPool::method_at_if_loaded(pool, index);\n    if (result != NULL) {\n      return methodHandle(THREAD, result);\n    }\n  }\n\n  if (code == Bytecodes::_invokeinterface) {\n    return resolve_interface_method(link_info, code, THREAD);\n  } else if (code == Bytecodes::_invokevirtual) {\n    return resolve_method(link_info, code, THREAD);\n  } else if (!resolved_klass->is_interface()) {\n    return resolve_method(link_info, code, THREAD);\n  } else {\n    return resolve_interface_method(link_info, code, THREAD);\n  }\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":389686,"func":"typval_compare_string(\n\ttypval_T    *tv1,\n\ttypval_T    *tv2,\n\texprtype_T  type,\n\tint\t    ic,\n\tint\t    *res)\n{\n    int\t\ti = 0;\n    int\t\tval = FALSE;\n    char_u\t*s1, *s2;\n    char_u\tbuf1[NUMBUFLEN], buf2[NUMBUFLEN];\n\n    if (in_vim9script()\n\t  && ((tv1->v_type != VAR_STRING && tv1->v_type != VAR_SPECIAL)\n\t   || (tv2->v_type != VAR_STRING && tv2->v_type != VAR_SPECIAL)))\n    {\n\tsemsg(_(e_cannot_compare_str_with_str),\n\t\t   vartype_name(tv1->v_type), vartype_name(tv2->v_type));\n\treturn FAIL;\n    }\n    s1 = tv_get_string_buf(tv1, buf1);\n    s2 = tv_get_string_buf(tv2, buf2);\n    if (type != EXPR_MATCH && type != EXPR_NOMATCH)\n\ti = ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2);\n    switch (type)\n    {\n\tcase EXPR_IS:\t    if (in_vim9script())\n\t\t\t    {\n\t\t\t\t\/\/ Really check it is the same string, not just\n\t\t\t\t\/\/ the same value.\n\t\t\t\tval = tv1->vval.v_string == tv2->vval.v_string;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t    \/\/ FALLTHROUGH\n\tcase EXPR_EQUAL:    val = (i == 0); break;\n\tcase EXPR_ISNOT:    if (in_vim9script())\n\t\t\t    {\n\t\t\t\t\/\/ Really check it is not the same string, not\n\t\t\t\t\/\/ just a different value.\n\t\t\t\tval = tv1->vval.v_string != tv2->vval.v_string;\n\t\t\t\tbreak;\n\t\t\t    }\n\t\t\t    \/\/ FALLTHROUGH\n\tcase EXPR_NEQUAL:   val = (i != 0); break;\n\tcase EXPR_GREATER:  val = (i > 0); break;\n\tcase EXPR_GEQUAL:   val = (i >= 0); break;\n\tcase EXPR_SMALLER:  val = (i < 0); break;\n\tcase EXPR_SEQUAL:   val = (i <= 0); break;\n\n\tcase EXPR_MATCH:\n\tcase EXPR_NOMATCH:\n\t\tval = pattern_match(s2, s1, ic);\n\t\tif (type == EXPR_NOMATCH)\n\t\t    val = !val;\n\t\tbreak;\n\n\tdefault:  break;  \/\/ avoid gcc warning\n    }\n    *res = val;\n    return OK;\n}","target":0,"code_token_length":551,"total_token_length":787,"max_tokens_setting":1024}
+{"idx":198927,"func":"RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {\n\tif (!bin->entry_table) {\n\t\treturn NULL;\n\t}\n\tRList *entries = r_list_newf (free);\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_bin_ne_get_segments (bin);\n\tif (!segments) {\n\t\tr_list_free (entries);\n\t\treturn NULL;\n\t}\n\tif (bin->ne_header->csEntryPoint) {\n\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\tif (!entry) {\n\t\t\tr_list_free (entries);\n\t\t\treturn NULL;\n\t\t}\n\t\tentry->bits = 16;\n\t\tut32 entry_cs = bin->ne_header->csEntryPoint;\n\t\tRBinSection *s = r_list_get_n (segments, entry_cs - 1);\n\t\tentry->paddr = bin->ne_header->ipEntryPoint + (s? s->paddr: 0);\n\n\t\tr_list_append (entries, entry);\n\t}\n\tint off = 0;\n\tsize_t tableat = bin->header_offset + bin->ne_header->EntryTableOffset;\n\twhile (off < bin->ne_header->EntryTableLength) {\n\t\tif (tableat + off >= r_buf_size (bin->buf)) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 bundle_length = *(ut8 *)(bin->entry_table + off);\n\t\tif (!bundle_length) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tut8 bundle_type = *(ut8 *)(bin->entry_table + off);\n\t\toff++;\n\t\tint i;\n\t\tfor (i = 0; i < bundle_length; i++) {\n\t\t\tif (tableat + off + 4 >= r_buf_size (bin->buf)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\t\tif (!entry) {\n\t\t\t\tr_list_free (entries);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\toff++;\n\t\t\tif (!bundle_type) { \/\/ Skip\n\t\t\t\toff--;\n\t\t\t\tfree (entry);\n\t\t\t\tbreak;\n\t\t\t} else if (bundle_type == 0xff) { \/\/ moveable\n\t\t\t\toff += 2;\n\t\t\t\tut8 segnum = *(bin->entry_table + off);\n\t\t\t\toff++;\n\t\t\t\tut16 segoff = *(ut16 *)(bin->entry_table + off);\n\t\t\t\tif (segnum > 0) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;\n\t\t\t\t}\n\t\t\t} else { \/\/ Fixed\n\t\t\t\tif (bundle_type < bin->ne_header->SegCount) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset\n\t\t\t\t\t\t* bin->alignment + *(ut16 *)(bin->entry_table + off);\n\t\t\t\t}\n\t\t\t}\n\t\t\toff += 2;\n\t\t\tr_list_append (entries, entry);\n\t\t}\n\t}\n\tr_list_free (segments);\n\tbin->entries = entries;\n\treturn entries;\n}","target":1,"code_token_length":657,"total_token_length":893,"max_tokens_setting":1024}
+{"idx":293502,"func":"static gif_result gif_skip_frame_extensions(gif_animation *gif)\n{\n        const unsigned char *gif_data, *gif_end;\n        ssize_t gif_bytes;\n        ssize_t block_size;\n\n        \/* Get our buffer position etc.\t*\/\n        gif_data = (const unsigned char *)(gif->gif_data + gif->buffer_position);\n        gif_end = (const unsigned char *)(gif->gif_data + gif->buffer_size);\n        gif_bytes = (gif_end - gif_data);\n\n        \/* Skip the extensions *\/\n        while (gif_data < gif_end && gif_data[0] == GIF_EXTENSION_INTRODUCER) {\n                ++gif_data;\n                if (gif_data >= gif_end) {\n                        return GIF_INSUFFICIENT_FRAME_DATA;\n                }\n\n                \/* Switch on extension label *\/\n                switch(gif_data[0]) {\n                case GIF_EXTENSION_COMMENT:\n                        \/* Move the pointer to the first data sub-block\n                         * 1 byte for the extension label\n                         *\/\n                        ++gif_data;\n                        break;\n\n                default:\n                        \/* Move the pointer to the first data sub-block 2 bytes\n                         * for the extension label and size fields Skip the\n                         * extension size itself\n                         *\/\n                        if (gif_data + 1 >= gif_end) {\n                                return GIF_INSUFFICIENT_FRAME_DATA;\n                        }\n                        gif_data += (2 + gif_data[1]);\n                }\n\n                \/* Repeatedly skip blocks until we get a zero block or run out\n                 * of data This data is ignored by this gif decoder\n                 *\/\n                gif_bytes = (gif_end - gif_data);\n                block_size = 0;\n                while (gif_data < gif_end && gif_data[0] != GIF_BLOCK_TERMINATOR) {\n                        block_size = gif_data[0] + 1;\n                        if ((gif_bytes -= block_size) < 0) {\n                                return GIF_INSUFFICIENT_FRAME_DATA;\n                        }\n                        gif_data += block_size;\n                }\n                ++gif_data;\n        }\n\n        \/* Set buffer position and return *\/\n        gif->buffer_position = (gif_data - gif->gif_data);\n        return GIF_OK;\n}","target":0,"code_token_length":437,"total_token_length":673,"max_tokens_setting":1024}
+{"idx":353184,"func":"static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest,\n\t\t\t\t    SplashColorPtr blend, SplashColorMode cm) {\n  int i;\n\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n    }\n  }\n#endif\n  {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      blend[i] = dest[i] + src[i] - (2 * dest[i] * src[i]) \/ 255;\n    }\n  }\n#ifdef SPLASH_CMYK\n  if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) {\n    for (i = 0; i < splashColorModeNComps[cm]; ++i) {\n      dest[i] = 255 - dest[i];\n      src[i] = 255 - src[i];\n      blend[i] = 255 - blend[i];\n    }\n  }\n  if (cm == splashModeDeviceN8) {\n    for (i = 4; i < splashColorModeNComps[cm]; ++i) {\n      if (dest[i] == 0 && src[i] == 0)\n        blend[i] = 0;\n    }\n  }\n#endif\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":272336,"func":"generate_auth_info(cms_context *cms, SECItem *der, char *url)\n{\n\tAuthInfo ai;\n\n\tSECOidData *oid = SECOID_FindOIDByTag(SEC_OID_PKIX_CA_ISSUERS);\n\tif (!oid)\n\t\tcnreterr(-1, cms, \"could not get CA issuers OID\");\n\n\tmemcpy(&ai.oid, &oid->oid, sizeof (ai.oid));\n\n\tSECItem urlitem = {\n\t\t.data = (unsigned char *)url,\n\t\t.len = strlen(url),\n\t\t.type = siBuffer\n\t};\n\tint rc = make_context_specific(cms, 6, &ai.url, &urlitem);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tvoid *ret;\n\tSECItem unwrapped;\n\tret = SEC_ASN1EncodeItem(cms->arena, &unwrapped, &ai, AuthInfoTemplate);\n\tif (ret == NULL)\n\t\tcnreterr(-1, cms, \"could not encode CA Issuers\");\n\n\trc = wrap_in_seq(cms, der, &unwrapped, 1);\n\tif (rc < 0)\n\t\treturn rc;\n\treturn 0;\n\n\t\/* I've no idea how to get SEC_ASN1EncodeItem to spit out the thing\n\t * we actually want here.  So once again, just force the data to\n\t * look correct :( *\/\n\tif (unwrapped.len < 12)\n\t\tcnreterr(-1, cms,\n\t\t\t \"generated CA Issuers Info cannot possibly be valid\");\n\n\tunwrapped.data[12] = 0x86;\n\tunwrapped.type = siBuffer;\n\n\tAuthInfo wrapper;\n\toid = SECOID_FindOIDByTag(SEC_OID_X509_AUTH_INFO_ACCESS);\n\tif (!oid)\n\t\tcnreterr(-1, cms, \"could not find Auth Info Access OID\");\n\n\tmemcpy(&wrapper.oid, &oid->oid, sizeof (ai.oid));\n\n\twrap_in_seq(cms, &wrapper.url, &unwrapped, 1);\n\n\tret = SEC_ASN1EncodeItem(cms->arena, der, &wrapper,\n\t\t\t\t\tAuthInfoWrapperTemplate);\n\tif (ret == NULL)\n\t\tcnreterr(-1, cms, \"could not encode CA Issuers OID\");\n\n\treturn 0;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":314473,"func":"static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)\n{\n\tstruct guest_walker walker;\n\tint r;\n\tunsigned long mmu_seq;\n\tbool is_self_change_mapping;\n\n\tpgprintk(\"%s: addr %lx err %x\\n\", __func__, fault->addr, fault->error_code);\n\tWARN_ON_ONCE(fault->is_tdp);\n\n\t\/*\n\t * Look up the guest pte for the faulting address.\n\t * If PFEC.RSVD is set, this is a shadow page fault.\n\t * The bit needs to be cleared before walking guest page tables.\n\t *\/\n\tr = FNAME(walk_addr)(&walker, vcpu, fault->addr,\n\t\t\t     fault->error_code & ~PFERR_RSVD_MASK);\n\n\t\/*\n\t * The page is not mapped by the guest.  Let the guest handle it.\n\t *\/\n\tif (!r) {\n\t\tpgprintk(\"%s: guest page fault\\n\", __func__);\n\t\tif (!fault->prefetch)\n\t\t\tkvm_inject_emulated_page_fault(vcpu, &walker.fault);\n\n\t\treturn RET_PF_RETRY;\n\t}\n\n\tfault->gfn = walker.gfn;\n\tfault->slot = kvm_vcpu_gfn_to_memslot(vcpu, fault->gfn);\n\n\tif (page_fault_handle_page_track(vcpu, fault)) {\n\t\tshadow_page_table_clear_flood(vcpu, fault->addr);\n\t\treturn RET_PF_EMULATE;\n\t}\n\n\tr = mmu_topup_memory_caches(vcpu, true);\n\tif (r)\n\t\treturn r;\n\n\tvcpu->arch.write_fault_to_shadow_pgtable = false;\n\n\tis_self_change_mapping = FNAME(is_self_change_mapping)(vcpu,\n\t      &walker, fault->user, &vcpu->arch.write_fault_to_shadow_pgtable);\n\n\tif (is_self_change_mapping)\n\t\tfault->max_level = PG_LEVEL_4K;\n\telse\n\t\tfault->max_level = walker.level;\n\n\tmmu_seq = vcpu->kvm->mmu_notifier_seq;\n\tsmp_rmb();\n\n\tif (kvm_faultin_pfn(vcpu, fault, &r))\n\t\treturn r;\n\n\tif (handle_abnormal_pfn(vcpu, fault, walker.pte_access, &r))\n\t\treturn r;\n\n\t\/*\n\t * Do not change pte_access if the pfn is a mmio page, otherwise\n\t * we will cache the incorrect access into mmio spte.\n\t *\/\n\tif (fault->write && !(walker.pte_access & ACC_WRITE_MASK) &&\n\t    !is_cr0_wp(vcpu->arch.mmu) && !fault->user && fault->slot) {\n\t\twalker.pte_access |= ACC_WRITE_MASK;\n\t\twalker.pte_access &= ~ACC_USER_MASK;\n\n\t\t\/*\n\t\t * If we converted a user page to a kernel page,\n\t\t * so that the kernel can write to it when cr0.wp=0,\n\t\t * then we should prevent the kernel from executing it\n\t\t * if SMEP is enabled.\n\t\t *\/\n\t\tif (is_cr4_smep(vcpu->arch.mmu))\n\t\t\twalker.pte_access &= ~ACC_EXEC_MASK;\n\t}\n\n\tr = RET_PF_RETRY;\n\twrite_lock(&vcpu->kvm->mmu_lock);\n\n\tif (is_page_fault_stale(vcpu, fault, mmu_seq))\n\t\tgoto out_unlock;\n\n\tr = make_mmu_pages_available(vcpu);\n\tif (r)\n\t\tgoto out_unlock;\n\tr = FNAME(fetch)(vcpu, fault, &walker);\n\nout_unlock:\n\twrite_unlock(&vcpu->kvm->mmu_lock);\n\tkvm_release_pfn_clean(fault->pfn);\n\treturn r;\n}","target":0,"code_token_length":764,"total_token_length":1000,"max_tokens_setting":1024}
+{"idx":254035,"func":"static void init_vdev(struct video_device *vdev, int nr)\n{\n\tMARK();\n\tvidioc_fill_name(vdev->name, sizeof(vdev->name), nr);\n\n#ifdef V4L2LOOPBACK_WITH_STD\n\tvdev->tvnorms      = V4L2_STD_ALL;\n#endif \/* V4L2LOOPBACK_WITH_STD *\/\n\n\tvdev->vfl_type     = VFL_TYPE_VIDEO;\n\tvdev->fops         = &v4l2_loopback_fops;\n\tvdev->ioctl_ops    = &v4l2_loopback_ioctl_ops;\n\tvdev->release      = &video_device_release;\n\tvdev->minor        = -1;\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)\n\tvdev->device_caps  =\n\t\tV4L2_CAP_DEVICE_CAPS |\n#ifdef V4L2_CAP_VIDEO_M2M\n\t\tV4L2_CAP_VIDEO_M2M |\n#endif\n                V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT |\n                V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;\n#endif\n\tif (debug > 1)\n\t\t#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)\n\t\t\tvdev->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;\n\t\t#else\n\t\t\tvdev->dev_debug = V4L2_DEV_DEBUG_IOCTL | V4L2_DEV_DEBUG_IOCTL_ARG;\n\t\t#endif\n\n\t\/* since kernel-3.7, there is a new field 'vfl_dir' that has to be\n\t * set to VFL_DIR_M2M for bidrectional devices *\/\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)\n\tvdev->vfl_dir = VFL_DIR_M2M;\n#endif\n\n\tMARK();\n}","target":0,"code_token_length":388,"total_token_length":624,"max_tokens_setting":1024}
+{"idx":219943,"func":"int callback_glewlwyd_user_update_profile (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_profile, * j_result;\n\n  j_profile = ulfius_get_json_body_request(request, NULL);\n  if (j_profile != NULL && json_is_object(j_profile)) {\n    j_result = user_set_profile(config, json_string_value(json_object_get((json_t *)response->shared_data, \"username\")), j_profile);\n    if (check_result_value(j_result, G_ERROR_PARAM)) {\n      if (json_object_get(j_result, \"error\") != NULL) {\n        ulfius_set_json_body_response(response, 400, json_object_get(j_result, \"error\"));\n      } else {\n        response->status = 400;\n      }\n    } else if (!check_result_value(j_result, G_OK)) {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_update_profile - Error user_set_profile\");\n      response->status = 500;\n    } else {\n      y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' updated (profile)\", json_string_value(json_object_get((json_t *)response->shared_data, \"username\")));\n    }\n    json_decref(j_result);\n  } else {\n    response->status = 400;\n  }\n  json_decref(j_profile);\n  \n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":436053,"func":"\nstatic void io_clean_op(struct io_kiocb *req)\n{\n\tif (req->flags & REQ_F_BUFFER_SELECTED) {\n\t\tswitch (req->opcode) {\n\t\tcase IORING_OP_READV:\n\t\tcase IORING_OP_READ_FIXED:\n\t\tcase IORING_OP_READ:\n\t\t\tkfree((void *)(unsigned long)req->rw.addr);\n\t\t\tbreak;\n\t\tcase IORING_OP_RECVMSG:\n\t\tcase IORING_OP_RECV:\n\t\t\tkfree(req->sr_msg.kbuf);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (req->flags & REQ_F_NEED_CLEANUP) {\n\t\tswitch (req->opcode) {\n\t\tcase IORING_OP_READV:\n\t\tcase IORING_OP_READ_FIXED:\n\t\tcase IORING_OP_READ:\n\t\tcase IORING_OP_WRITEV:\n\t\tcase IORING_OP_WRITE_FIXED:\n\t\tcase IORING_OP_WRITE: {\n\t\t\tstruct io_async_rw *io = req->async_data;\n\n\t\t\tkfree(io->free_iovec);\n\t\t\tbreak;\n\t\t\t}\n\t\tcase IORING_OP_RECVMSG:\n\t\tcase IORING_OP_SENDMSG: {\n\t\t\tstruct io_async_msghdr *io = req->async_data;\n\n\t\t\tkfree(io->free_iov);\n\t\t\tbreak;\n\t\t\t}\n\t\tcase IORING_OP_SPLICE:\n\t\tcase IORING_OP_TEE:\n\t\t\tif (!(req->splice.flags & SPLICE_F_FD_IN_FIXED))\n\t\t\t\tio_put_file(req->splice.file_in);\n\t\t\tbreak;\n\t\tcase IORING_OP_OPENAT:\n\t\tcase IORING_OP_OPENAT2:\n\t\t\tif (req->open.filename)\n\t\t\t\tputname(req->open.filename);\n\t\t\tbreak;\n\t\tcase IORING_OP_RENAMEAT:\n\t\t\tputname(req->rename.oldpath);\n\t\t\tputname(req->rename.newpath);\n\t\t\tbreak;\n\t\tcase IORING_OP_UNLINKAT:\n\t\t\tputname(req->unlink.filename);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ((req->flags & REQ_F_POLLED) && req->apoll) {\n\t\tkfree(req->apoll->double_poll);\n\t\tkfree(req->apoll);\n\t\treq->apoll = NULL;\n\t}\n\tif (req->flags & REQ_F_INFLIGHT) {\n\t\tstruct io_uring_task *tctx = req->task->io_uring;\n\n\t\tatomic_dec(&tctx->inflight_tracked);\n\t}\n\tif (req->flags & REQ_F_CREDS)\n\t\tput_cred(req->creds);\n\n\treq->flags &= ~IO_REQ_CLEAN_FLAGS;","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":256426,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_get_ntp_time(const pjmedia_rtcp_session *sess,\n\t\t\t\t\t      pjmedia_rtcp_ntp_rec *ntp)\n{\n\/* Seconds between 1900-01-01 to 1970-01-01 *\/\n#define JAN_1970  (2208988800UL)\n    pj_timestamp ts;\n    pj_status_t status;\n\n    status = pj_get_timestamp(&ts);\n\n    \/* Fill up the high 32bit part *\/\n    ntp->hi = (pj_uint32_t)((ts.u64 - sess->ts_base.u64) \/ sess->ts_freq.u64)\n\t      + sess->tv_base.sec + JAN_1970;\n\n    \/* Calculate seconds fractions *\/\n    ts.u64 = (ts.u64 - sess->ts_base.u64) % sess->ts_freq.u64;\n    pj_assert(ts.u64 < sess->ts_freq.u64);\n    ts.u64 = (ts.u64 << 32) \/ sess->ts_freq.u64;\n\n    \/* Fill up the low 32bit part *\/\n    ntp->lo = ts.u32.lo;\n\n\n#if (defined(PJ_WIN32) && PJ_WIN32!=0) || \\\n    (defined(PJ_WIN64) && PJ_WIN64!=0) || \\\n    (defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0)\n\n    \/* On Win32, since we use QueryPerformanceCounter() as the backend\n     * timestamp API, we need to protect against this bug:\n     *   Performance counter value may unexpectedly leap forward\n     *   http:\/\/support.microsoft.com\/default.aspx?scid=KB;EN-US;Q274323\n     *\/\n    {\n\t\/*\n\t * Compare elapsed time reported by timestamp with actual elapsed \n\t * time. If the difference is too excessive, then we use system\n\t * time instead.\n\t *\/\n\n\t\/* MIN_DIFF needs to be large enough so that \"normal\" diff caused\n\t * by system activity or context switch doesn't trigger the time\n\t * correction.\n\t *\/\n\tenum { MIN_DIFF = 400 };\n\n\tpj_time_val ts_time, elapsed, diff;\n\n\tpj_gettimeofday(&elapsed);\n\n\tts_time.sec = ntp->hi - sess->tv_base.sec - JAN_1970;\n\tts_time.msec = (long)(ntp->lo * 1000.0 \/ 0xFFFFFFFF);\n\n\tPJ_TIME_VAL_SUB(elapsed, sess->tv_base);\n\n\tif (PJ_TIME_VAL_LT(ts_time, elapsed)) {\n\t    diff = elapsed;\n\t    PJ_TIME_VAL_SUB(diff, ts_time);\n\t} else {\n\t    diff = ts_time;\n\t    PJ_TIME_VAL_SUB(diff, elapsed);\n\t}\n\n\tif (PJ_TIME_VAL_MSEC(diff) >= MIN_DIFF) {\n\n\t    TRACE_((sess->name, \"RTCP NTP timestamp corrected by %d ms\",\n\t\t    PJ_TIME_VAL_MSEC(diff)));\n\n\n\t    ntp->hi = elapsed.sec + sess->tv_base.sec + JAN_1970;\n\t    ntp->lo = (elapsed.msec * 65536 \/ 1000) << 16;\n\t}\n\n    }\n#endif\n\n    return status;\n}","target":0,"code_token_length":712,"total_token_length":948,"max_tokens_setting":1024}
+{"idx":437329,"func":"setup_anchor(Node* node, regex_t* reg, int state, ScanEnv* env)\n{\n\/* allowed node types in look-behind *\/\n#define ALLOWED_TYPE_IN_LB \\\n  ( NODE_BIT_LIST | NODE_BIT_ALT | NODE_BIT_STRING | NODE_BIT_CCLASS \\\n  | NODE_BIT_CTYPE | NODE_BIT_ANCHOR | NODE_BIT_ENCLOSURE | NODE_BIT_QUANT \\\n  | NODE_BIT_CALL | NODE_BIT_GIMMICK)\n\n#define ALLOWED_ENCLOSURE_IN_LB       ( 1<<ENCLOSURE_MEMORY | 1<<ENCLOSURE_OPTION )\n#define ALLOWED_ENCLOSURE_IN_LB_NOT   (1<<ENCLOSURE_OPTION)\n\n#define ALLOWED_ANCHOR_IN_LB \\\n  ( ANCHOR_LOOK_BEHIND | ANCHOR_BEGIN_LINE | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF \\\n  | ANCHOR_BEGIN_POSITION | ANCHOR_WORD_BOUNDARY | ANCHOR_NO_WORD_BOUNDARY \\\n  | ANCHOR_WORD_BEGIN | ANCHOR_WORD_END \\\n  | ANCHOR_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY \\\n  | ANCHOR_NO_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY )\n\n#define ALLOWED_ANCHOR_IN_LB_NOT \\\n  ( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE \\\n  | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_WORD_BOUNDARY \\\n  | ANCHOR_NO_WORD_BOUNDARY | ANCHOR_WORD_BEGIN | ANCHOR_WORD_END \\\n  | ANCHOR_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY \\\n  | ANCHOR_NO_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY )\n\n  int r;\n  AnchorNode* an = ANCHOR_(node);\n\n  switch (an->type) {\n  case ANCHOR_PREC_READ:\n    r = setup_tree(NODE_ANCHOR_BODY(an), reg, state, env);\n    break;\n  case ANCHOR_PREC_READ_NOT:\n    r = setup_tree(NODE_ANCHOR_BODY(an), reg, (state | IN_NOT), env);\n    break;\n\n  case ANCHOR_LOOK_BEHIND:\n    {\n      r = check_type_tree(NODE_ANCHOR_BODY(an), ALLOWED_TYPE_IN_LB,\n                          ALLOWED_ENCLOSURE_IN_LB, ALLOWED_ANCHOR_IN_LB);\n      if (r < 0) return r;\n      if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;\n      r = setup_tree(NODE_ANCHOR_BODY(an), reg, state, env);\n      if (r != 0) return r;\n      r = setup_look_behind(node, reg, env);\n    }\n    break;\n\n  case ANCHOR_LOOK_BEHIND_NOT:\n    {\n      r = check_type_tree(NODE_ANCHOR_BODY(an), ALLOWED_TYPE_IN_LB,\n                          ALLOWED_ENCLOSURE_IN_LB_NOT, ALLOWED_ANCHOR_IN_LB_NOT);\n      if (r < 0) return r;\n      if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;\n      r = setup_tree(NODE_ANCHOR_BODY(an), reg, (state | IN_NOT), env);\n      if (r != 0) return r;\n      r = setup_look_behind(node, reg, env);\n    }\n    break;\n\n  default:\n    r = 0;\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":730,"total_token_length":966,"max_tokens_setting":1024}
+{"idx":252313,"func":"mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename,\n                                mz_uint64 size_to_reserve_at_beginning) {\n  MZ_FILE *pFile;\n  pZip->m_pWrite = mz_zip_file_write_func;\n  pZip->m_pIO_opaque = pZip;\n  if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE;\n  if (NULL == (pFile = MZ_FOPEN(pFilename, \"wb\"))) {\n    mz_zip_writer_end(pZip);\n    return MZ_FALSE;\n  }\n  pZip->m_pState->m_pFile = pFile;\n  if (size_to_reserve_at_beginning) {\n    mz_uint64 cur_ofs = 0;\n    char buf[4096];\n    MZ_CLEAR_OBJ(buf);\n    do {\n      size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning);\n      if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) {\n        mz_zip_writer_end(pZip);\n        return MZ_FALSE;\n      }\n      cur_ofs += n;\n      size_to_reserve_at_beginning -= n;\n    } while (size_to_reserve_at_beginning);\n  }\n  return MZ_TRUE;\n}","target":0,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":276997,"func":"fiber_init(mrb_state *mrb, mrb_value self)\n{\n  static const struct mrb_context mrb_context_zero = { 0 };\n  struct RFiber *f = fiber_ptr(self);\n  struct mrb_context *c;\n  struct RProc *p;\n  mrb_callinfo *ci;\n  mrb_value blk;\n  size_t slen;\n\n  mrb_get_args(mrb, \"&!\", &blk);\n\n  if (f->cxt) {\n    mrb_raise(mrb, E_RUNTIME_ERROR, \"cannot initialize twice\");\n  }\n  p = mrb_proc_ptr(blk);\n  if (MRB_PROC_CFUNC_P(p)) {\n    mrb_raise(mrb, E_FIBER_ERROR, \"tried to create Fiber from C defined method\");\n  }\n\n  c = (struct mrb_context*)mrb_malloc(mrb, sizeof(struct mrb_context));\n  *c = mrb_context_zero;\n  f->cxt = c;\n\n  \/* initialize VM stack *\/\n  slen = FIBER_STACK_INIT_SIZE;\n  if (p->body.irep->nregs > slen) {\n    slen += p->body.irep->nregs;\n  }\n  c->stbase = (mrb_value *)mrb_malloc(mrb, slen*sizeof(mrb_value));\n  c->stend = c->stbase + slen;\n\n  {\n    mrb_value *p = c->stbase;\n    mrb_value *pend = c->stend;\n\n    while (p < pend) {\n      SET_NIL_VALUE(*p);\n      p++;\n    }\n  }\n\n  \/* copy receiver from a block *\/\n  c->stbase[0] = mrb->c->ci->stack[0];\n\n  \/* initialize callinfo stack *\/\n  c->cibase = (mrb_callinfo *)mrb_calloc(mrb, FIBER_CI_INIT_SIZE, sizeof(mrb_callinfo));\n  c->ciend = c->cibase + FIBER_CI_INIT_SIZE;\n  c->ci = c->cibase;\n\n  \/* adjust return callinfo *\/\n  ci = c->ci;\n  mrb_vm_ci_target_class_set(ci, MRB_PROC_TARGET_CLASS(p));\n  mrb_vm_ci_proc_set(ci, p);\n  mrb_field_write_barrier(mrb, (struct RBasic*)mrb_obj_ptr(self), (struct RBasic*)p);\n  ci->stack = c->stbase;\n  ci[1] = ci[0];\n  c->ci++;                      \/* push dummy callinfo *\/\n\n  c->fib = f;\n  c->status = MRB_FIBER_CREATED;\n\n  return self;\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":223441,"func":"static BOOL check_fast_forward_char_pair_simd(compiler_common *common, fast_forward_char_data *chars, int max)\n{\n  sljit_s32 i, j, max_i = 0, max_j = 0;\n  sljit_u32 max_pri = 0;\n  PCRE2_UCHAR a1, a2, a_pri, b1, b2, b_pri;\n\n  for (i = max - 1; i >= 1; i--)\n    {\n    if (chars[i].last_count > 2)\n      {\n      a1 = chars[i].chars[0];\n      a2 = chars[i].chars[1];\n      a_pri = chars[i].last_count;\n\n      j = i - max_fast_forward_char_pair_offset();\n      if (j < 0)\n        j = 0;\n\n      while (j < i)\n        {\n        b_pri = chars[j].last_count;\n        if (b_pri > 2 && a_pri + b_pri >= max_pri)\n          {\n          b1 = chars[j].chars[0];\n          b2 = chars[j].chars[1];\n\n          if (a1 != b1 && a1 != b2 && a2 != b1 && a2 != b2)\n            {\n            max_pri = a_pri + b_pri;\n            max_i = i;\n            max_j = j;\n            }\n          }\n        j++;\n        }\n      }\n    }\n\nif (max_pri == 0)\n  return FALSE;\n\nfast_forward_char_pair_simd(common, max_i, chars[max_i].chars[0], chars[max_i].chars[1], max_j, chars[max_j].chars[0], chars[max_j].chars[1]);\nreturn TRUE;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":261390,"func":"de265_error read_slice_segment_data(thread_context* tctx)\n{\n  setCtbAddrFromTS(tctx);\n\n  de265_image* img = tctx->img;\n  const pic_parameter_set& pps = img->get_pps();\n  const seq_parameter_set& sps = img->get_sps();\n  slice_segment_header* shdr = tctx->shdr;\n\n  bool success = initialize_CABAC_at_slice_segment_start(tctx);\n  if (!success) {\n    return DE265_ERROR_UNSPECIFIED_DECODING_ERROR;\n  }\n\n  init_CABAC_decoder_2(&tctx->cabac_decoder);\n\n  \/\/printf(\"-----\\n\");\n\n  bool first_slice_substream = !shdr->dependent_slice_segment_flag;\n\n  int substream=0;\n\n  enum DecodeResult result;\n  do {\n    int ctby = tctx->CtbY;\n\n\n    \/\/ check whether entry_points[] are correct in the bitstream\n\n    if (substream>0) {\n      if (substream-1 >= tctx->shdr->entry_point_offset.size() ||\n          tctx->cabac_decoder.bitstream_curr - tctx->cabac_decoder.bitstream_start -2 \/* -2 because of CABAC init *\/\n          != tctx->shdr->entry_point_offset[substream-1]) {\n        tctx->decctx->add_warning(DE265_WARNING_INCORRECT_ENTRY_POINT_OFFSET, true);\n      }\n    }\n\n    substream++;\n\n\n    result = decode_substream(tctx, false, first_slice_substream);\n\n\n    if (result == Decode_EndOfSliceSegment ||\n        result == Decode_Error) {\n      break;\n    }\n\n    first_slice_substream = false;\n\n    if (pps.tiles_enabled_flag) {\n      initialize_CABAC_models(tctx);\n    }\n  } while (true);\n\n  return DE265_OK;\n}","target":0,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":225124,"func":"  void CreateNgrams(const tstring* data, tstring* output, int num_ngrams,\n                    int ngram_width) const {\n    for (int ngram_index = 0; ngram_index < num_ngrams; ++ngram_index) {\n      int pad_width = get_pad_width(ngram_width);\n      int left_padding = std::max(0, pad_width - ngram_index);\n      int right_padding =\n          std::max(0, pad_width - (num_ngrams - (ngram_index + 1)));\n      int num_tokens = ngram_width - (left_padding + right_padding);\n      int data_start_index = left_padding > 0 ? 0 : ngram_index - pad_width;\n\n      \/\/ Calculate the total expected size of the ngram so we can reserve the\n      \/\/ correct amount of space in the string.\n      int ngram_size = 0;\n      \/\/ Size of the left padding.\n      ngram_size += left_padding * left_pad_.length();\n      \/\/ Size of the tokens.\n      for (int n = 0; n < num_tokens; ++n) {\n        ngram_size += data[data_start_index + n].length();\n      }\n      \/\/ Size of the right padding.\n      ngram_size += right_padding * right_pad_.length();\n      \/\/ Size of the separators.\n      int num_separators = left_padding + right_padding + num_tokens - 1;\n      ngram_size += num_separators * separator_.length();\n\n      \/\/ Build the ngram.\n      tstring* ngram = &output[ngram_index];\n      ngram->reserve(ngram_size);\n      for (int n = 0; n < left_padding; ++n) {\n        ngram->append(left_pad_);\n        ngram->append(separator_);\n      }\n      \/\/ Only output first num_tokens - 1 pairs of data and separator\n      for (int n = 0; n < num_tokens - 1; ++n) {\n        ngram->append(data[data_start_index + n]);\n        ngram->append(separator_);\n      }\n      \/\/ Handle case when there are no tokens or no right padding as these can\n      \/\/ result in consecutive separators.\n      if (num_tokens > 0) {\n        \/\/ If we have tokens, then output last and then pair each separator with\n        \/\/ the right padding that follows, to ensure ngram ends either with the\n        \/\/ token or with the right pad.\n        ngram->append(data[data_start_index + num_tokens - 1]);\n        for (int n = 0; n < right_padding; ++n) {\n          ngram->append(separator_);\n          ngram->append(right_pad_);\n        }\n      } else {\n        \/\/ If we don't have tokens, then the last item inserted into the ngram\n        \/\/ has been the separator from the left padding loop above. Hence,\n        \/\/ output right pad and separator and make sure to finish with a\n        \/\/ padding, not a separator.\n        for (int n = 0; n < right_padding - 1; ++n) {\n          ngram->append(right_pad_);\n          ngram->append(separator_);\n        }\n        ngram->append(right_pad_);\n      }\n\n      \/\/ In debug mode only: validate that we've reserved enough space for the\n      \/\/ ngram.\n      DCHECK_EQ(ngram_size, ngram->size());\n    }\n  }","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":232405,"func":"  void MakeDataset(OpKernelContext* ctx, DatasetBase** output) override {\n    \/\/ Create a new SparseTensorSliceDatasetOp::Dataset, insert it in\n    \/\/ the step container, and return it as the output.\n    const Tensor* indices;\n    OP_REQUIRES_OK(ctx, ctx->input(\"indices\", &indices));\n    const Tensor* values;\n    OP_REQUIRES_OK(ctx, ctx->input(\"values\", &values));\n    const Tensor* dense_shape;\n    OP_REQUIRES_OK(ctx, ctx->input(\"dense_shape\", &dense_shape));\n\n    OP_REQUIRES(ctx, TensorShapeUtils::IsMatrix(indices->shape()),\n                errors::InvalidArgument(\n                    \"Input indices should be a matrix but received shape \",\n                    indices->shape().DebugString()));\n\n    const auto num_indices = indices->NumElements();\n    const auto num_values = values->NumElements();\n    if (num_indices == 0 || num_values == 0) {\n      OP_REQUIRES(ctx, num_indices == num_values,\n                  errors::InvalidArgument(\n                      \"If indices or values are empty, the other one must also \"\n                      \"be. Got indices of shape \",\n                      indices->shape().DebugString(), \" and values of shape \",\n                      values->shape().DebugString()));\n    }\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(values->shape()),\n                errors::InvalidArgument(\n                    \"Input values should be a vector but received shape \",\n                    indices->shape().DebugString()));\n    OP_REQUIRES(ctx, TensorShapeUtils::IsVector(dense_shape->shape()),\n                errors::InvalidArgument(\n                    \"Input shape should be a vector but received shape \",\n                    dense_shape->shape().DebugString()));\n\n    \/\/ We currently ensure that `sparse_tensor` is ordered in the\n    \/\/ batch dimension.\n    \/\/ TODO(mrry): Investigate ways to avoid this unconditional check\n    \/\/ if we can be sure that the sparse tensor was produced in an\n    \/\/ appropriate order (e.g. by `tf.parse_example()` or a Dataset\n    \/\/ that batches elements into rows of a SparseTensor).\n    int64_t previous_batch_index = -1;\n    for (int64_t i = 0; i < indices->dim_size(0); ++i) {\n      int64_t next_batch_index = indices->matrix<int64>()(i, 0);\n      OP_REQUIRES(\n          ctx, next_batch_index >= previous_batch_index,\n          errors::Unimplemented(\"The SparseTensor must be ordered in the batch \"\n                                \"dimension; handling arbitrarily ordered input \"\n                                \"is not currently supported.\"));\n      previous_batch_index = next_batch_index;\n    }\n    gtl::InlinedVector<int64, 8> std_order(dense_shape->NumElements(), 0);\n    sparse::SparseTensor tensor;\n    OP_REQUIRES_OK(\n        ctx, sparse::SparseTensor::Create(\n                 *indices, *values, TensorShape(dense_shape->vec<int64>()),\n                 std_order, &tensor));\n    *output = new Dataset<T>(ctx, std::move(tensor));\n  }","target":0,"code_token_length":641,"total_token_length":877,"max_tokens_setting":1024}
+{"idx":195059,"func":"bool DependencyOptimizer::SafeToRemoveIdentity(const NodeDef& node) const {\n  if (!IsIdentity(node) && !IsIdentityN(node)) {\n    return true;\n  }\n\n  if (nodes_to_preserve_.find(node.name()) != nodes_to_preserve_.end()) {\n    return false;\n  }\n  if (!fetch_nodes_known_) {\n    \/\/ The output values of this node may be needed.\n    return false;\n  }\n\n  if (node.input_size() < 1) {\n    \/\/ Node lacks input, is invalid\n    return false;\n  }\n\n  const NodeDef* input = node_map_->GetNode(NodeName(node.input(0)));\n  CHECK(input != nullptr) << \"node = \" << node.name()\n                          << \" input = \" << node.input(0);\n  \/\/ Don't remove Identity nodes corresponding to Variable reads or following\n  \/\/ Recv.\n  if (IsVariable(*input) || IsRecv(*input)) {\n    return false;\n  }\n  for (const auto& consumer : node_map_->GetOutputs(node.name())) {\n    if (node.input_size() > 1 && (IsRetval(*consumer) || IsMerge(*consumer))) {\n      return false;\n    }\n    if (IsSwitch(*input)) {\n      for (const string& consumer_input : consumer->input()) {\n        if (consumer_input == AsControlDependency(node.name())) {\n          return false;\n        }\n      }\n    }\n  }\n  return true;\n}","target":1,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":317207,"func":"static int smack_fs_context_dup(struct fs_context *fc,\n\t\t\t\tstruct fs_context *src_fc)\n{\n\tstruct smack_mnt_opts *dst, *src = src_fc->security;\n\n\tif (!src)\n\t\treturn 0;\n\n\tfc->security = kzalloc(sizeof(struct smack_mnt_opts), GFP_KERNEL);\n\tif (!fc->security)\n\t\treturn -ENOMEM;\n\tdst = fc->security;\n\n\tif (src->fsdefault) {\n\t\tdst->fsdefault = kstrdup(src->fsdefault, GFP_KERNEL);\n\t\tif (!dst->fsdefault)\n\t\t\treturn -ENOMEM;\n\t}\n\tif (src->fsfloor) {\n\t\tdst->fsfloor = kstrdup(src->fsfloor, GFP_KERNEL);\n\t\tif (!dst->fsfloor)\n\t\t\treturn -ENOMEM;\n\t}\n\tif (src->fshat) {\n\t\tdst->fshat = kstrdup(src->fshat, GFP_KERNEL);\n\t\tif (!dst->fshat)\n\t\t\treturn -ENOMEM;\n\t}\n\tif (src->fsroot) {\n\t\tdst->fsroot = kstrdup(src->fsroot, GFP_KERNEL);\n\t\tif (!dst->fsroot)\n\t\t\treturn -ENOMEM;\n\t}\n\tif (src->fstransmute) {\n\t\tdst->fstransmute = kstrdup(src->fstransmute, GFP_KERNEL);\n\t\tif (!dst->fstransmute)\n\t\t\treturn -ENOMEM;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":450324,"func":"void vnc_disconnect_finish(VncState *vs)\n{\n    int i;\n\n    trace_vnc_client_disconnect_finish(vs, vs->ioc);\n\n    vnc_jobs_join(vs); \/* Wait encoding jobs *\/\n\n    vnc_lock_output(vs);\n    vnc_qmp_event(vs, QAPI_EVENT_VNC_DISCONNECTED);\n\n    buffer_free(&vs->input);\n    buffer_free(&vs->output);\n\n    qapi_free_VncClientInfo(vs->info);\n\n    vnc_zlib_clear(vs);\n    vnc_tight_clear(vs);\n    vnc_zrle_clear(vs);\n\n#ifdef CONFIG_VNC_SASL\n    vnc_sasl_client_cleanup(vs);\n#endif \/* CONFIG_VNC_SASL *\/\n    audio_del(vs);\n    qkbd_state_lift_all_keys(vs->vd->kbd);\n\n    if (vs->mouse_mode_notifier.notify != NULL) {\n        qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier);\n    }\n    QTAILQ_REMOVE(&vs->vd->clients, vs, next);\n    if (QTAILQ_EMPTY(&vs->vd->clients)) {\n        \/* last client gone *\/\n        vnc_update_server_surface(vs->vd);\n    }\n\n    vnc_unlock_output(vs);\n\n    qemu_mutex_destroy(&vs->output_mutex);\n    if (vs->bh != NULL) {\n        qemu_bh_delete(vs->bh);\n    }\n    buffer_free(&vs->jobs_buffer);\n\n    for (i = 0; i < VNC_STAT_ROWS; ++i) {\n        g_free(vs->lossy_rect[i]);\n    }\n    g_free(vs->lossy_rect);\n\n    object_unref(OBJECT(vs->ioc));\n    vs->ioc = NULL;\n    object_unref(OBJECT(vs->sioc));\n    vs->sioc = NULL;\n    vs->magic = 0;\n    g_free(vs->zrle);\n    g_free(vs->tight);\n    g_free(vs);\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":198399,"func":"static void handle_PORT(ctrl_t *ctrl, char *str)\n{\n\tint a, b, c, d, e, f;\n\tchar addr[INET_ADDRSTRLEN];\n\tstruct sockaddr_in sin;\n\n\tif (ctrl->data_sd > 0) {\n\t\tuev_io_stop(&ctrl->data_watcher);\n\t\tclose(ctrl->data_sd);\n\t\tctrl->data_sd = -1;\n\t}\n\n\t\/* Convert PORT command's argument to IP address + port *\/\n\tsscanf(str, \"%d,%d,%d,%d,%d,%d\", &a, &b, &c, &d, &e, &f);\n\tsprintf(addr, \"%d.%d.%d.%d\", a, b, c, d);\n\n\t\/* Check IPv4 address using inet_aton(), throw away converted result *\/\n\tif (!inet_aton(addr, &(sin.sin_addr))) {\n\t\tERR(0, \"Invalid address '%s' given to PORT command\", addr);\n\t\tsend_msg(ctrl->sd, \"500 Illegal PORT command.\\r\\n\");\n\t\treturn;\n\t}\n\n\tstrlcpy(ctrl->data_address, addr, sizeof(ctrl->data_address));\n\tctrl->data_port = e * 256 + f;\n\n\tDBG(\"Client PORT command accepted for %s:%d\", ctrl->data_address, ctrl->data_port);\n\tsend_msg(ctrl->sd, \"200 PORT command successful.\\r\\n\");\n}","target":1,"code_token_length":290,"total_token_length":526,"max_tokens_setting":1024}
+{"idx":264213,"func":"static void set_pixel_format(VncState *vs,\n                             int bits_per_pixel, int depth,\n                             int big_endian_flag, int true_color_flag,\n                             int red_max, int green_max, int blue_max,\n                             int red_shift, int green_shift, int blue_shift)\n{\n    if (!true_color_flag) {\n        vnc_client_error(vs);\n        return;\n    }\n\n    vs->client_pf.rmax = red_max;\n    vs->client_pf.rbits = hweight_long(red_max);\n    vs->client_pf.rshift = red_shift;\n    vs->client_pf.rmask = red_max << red_shift;\n    vs->client_pf.gmax = green_max;\n    vs->client_pf.gbits = hweight_long(green_max);\n    vs->client_pf.gshift = green_shift;\n    vs->client_pf.gmask = green_max << green_shift;\n    vs->client_pf.bmax = blue_max;\n    vs->client_pf.bbits = hweight_long(blue_max);\n    vs->client_pf.bshift = blue_shift;\n    vs->client_pf.bmask = blue_max << blue_shift;\n    vs->client_pf.bits_per_pixel = bits_per_pixel;\n    vs->client_pf.bytes_per_pixel = bits_per_pixel \/ 8;\n    vs->client_pf.depth = bits_per_pixel == 32 ? 24 : bits_per_pixel;\n    vs->client_be = big_endian_flag;\n\n    set_pixel_conversion(vs);\n\n    graphic_hw_invalidate(NULL);\n    graphic_hw_update(NULL);\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":383317,"func":"int gdImageGrayScale(gdImagePtr src)\n{\n\tint x, y;\n\tint r,g,b,a;\n\tint new_pxl, pxl;\n\ttypedef int (*FuncPtr)(gdImagePtr, int, int);\n\tFuncPtr f;\n\tf = GET_PIXEL_FUNCTION(src);\n\n\tif (src==NULL) {\n\t\treturn 0;\n\t}\n\n\tfor (y=0; y<src->sy; ++y) {\n\t\tfor (x=0; x<src->sx; ++x) {\n\t\t\tpxl = f (src, x, y);\n\t\t\tr = gdImageRed(src, pxl);\n\t\t\tg = gdImageGreen(src, pxl);\n\t\t\tb = gdImageBlue(src, pxl);\n\t\t\ta = gdImageAlpha(src, pxl);\n\t\t\tr = g = b = (int) (.299 * r + .587 * g + .114 * b);\n\n\t\t\tnew_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);\n\t\t\tif (new_pxl == -1) {\n\t\t\t\tnew_pxl = gdImageColorClosestAlpha(src, r, g, b, a);\n\t\t\t}\n\t\t\tif ((y >= 0) && (y < src->sy)) {\n\t\t\t\tgdImageSetPixel (src, x, y, new_pxl);\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":253537,"func":"smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,\n\t\t       unsigned int epoch, bool *purge_cache)\n{\n\tchar message[5] = {0};\n\tunsigned int new_oplock = 0;\n\n\toplock &= 0xFF;\n\tcinode->lease_granted = true;\n\tif (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)\n\t\treturn;\n\n\t\/* Check if the server granted an oplock rather than a lease *\/\n\tif (oplock & SMB2_OPLOCK_LEVEL_EXCLUSIVE)\n\t\treturn smb2_set_oplock_level(cinode, oplock, epoch,\n\t\t\t\t\t     purge_cache);\n\n\tif (oplock & SMB2_LEASE_READ_CACHING_HE) {\n\t\tnew_oplock |= CIFS_CACHE_READ_FLG;\n\t\tstrcat(message, \"R\");\n\t}\n\tif (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {\n\t\tnew_oplock |= CIFS_CACHE_HANDLE_FLG;\n\t\tstrcat(message, \"H\");\n\t}\n\tif (oplock & SMB2_LEASE_WRITE_CACHING_HE) {\n\t\tnew_oplock |= CIFS_CACHE_WRITE_FLG;\n\t\tstrcat(message, \"W\");\n\t}\n\tif (!new_oplock)\n\t\tstrncpy(message, \"None\", sizeof(message));\n\n\tcinode->oplock = new_oplock;\n\tcifs_dbg(FYI, \"%s Lease granted on inode %p\\n\", message,\n\t\t &cinode->vfs_inode);\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":221161,"func":"void gf_odf_avc_cfg_del(GF_AVCConfig *cfg)\n{\n\tif (!cfg) return;\n\twhile (gf_list_count(cfg->sequenceParameterSets)) {\n\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(cfg->sequenceParameterSets, 0);\n\t\tgf_list_rem(cfg->sequenceParameterSets, 0);\n\t\tif (sl->data) gf_free(sl->data);\n\t\tgf_free(sl);\n\t}\n\tgf_list_del(cfg->sequenceParameterSets);\n\tcfg->sequenceParameterSets = NULL;\n\n\twhile (gf_list_count(cfg->pictureParameterSets)) {\n\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(cfg->pictureParameterSets, 0);\n\t\tgf_list_rem(cfg->pictureParameterSets, 0);\n\t\tif (sl->data) gf_free(sl->data);\n\t\tgf_free(sl);\n\t}\n\tgf_list_del(cfg->pictureParameterSets);\n\tcfg->pictureParameterSets = NULL;\n\n\tif (cfg->sequenceParameterSetExtensions) {\n\t\twhile (gf_list_count(cfg->sequenceParameterSetExtensions)) {\n\t\t\tGF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(cfg->sequenceParameterSetExtensions, 0);\n\t\t\tgf_list_rem(cfg->sequenceParameterSetExtensions, 0);\n\t\t\tif (sl->data) gf_free(sl->data);\n\t\t\tgf_free(sl);\n\t\t}\n\t\tgf_list_del(cfg->sequenceParameterSetExtensions);\n\t\tcfg->sequenceParameterSetExtensions = NULL;\n\t}\n\tgf_free(cfg);\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":312434,"func":"qf_jump_goto_line(\n\tlinenr_T\tqf_lnum,\n\tint\t\tqf_col,\n\tchar_u\t\tqf_viscol,\n\tchar_u\t\t*qf_pattern)\n{\n    linenr_T\t\ti;\n\n    if (qf_pattern == NULL)\n    {\n\t\/\/ Go to line with error, unless qf_lnum is 0.\n\ti = qf_lnum;\n\tif (i > 0)\n\t{\n\t    if (i > curbuf->b_ml.ml_line_count)\n\t\ti = curbuf->b_ml.ml_line_count;\n\t    curwin->w_cursor.lnum = i;\n\t}\n\tif (qf_col > 0)\n\t{\n\t    curwin->w_cursor.coladd = 0;\n\t    if (qf_viscol == TRUE)\n\t\tcoladvance(qf_col - 1);\n\t    else\n\t\tcurwin->w_cursor.col = qf_col - 1;\n\t    curwin->w_set_curswant = TRUE;\n\t    check_cursor();\n\t}\n\telse\n\t    beginline(BL_WHITE | BL_FIX);\n    }\n    else\n    {\n\tpos_T save_cursor;\n\n\t\/\/ Move the cursor to the first line in the buffer\n\tsave_cursor = curwin->w_cursor;\n\tcurwin->w_cursor.lnum = 0;\n\tif (!do_search(NULL, '\/', '\/', qf_pattern, (long)1, SEARCH_KEEP, NULL))\n\t    curwin->w_cursor = save_cursor;\n    }\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":318778,"func":"drill_parse_M_code(gerb_file_t *fd, drill_state_t *state,\n\tgerbv_image_t *image, ssize_t file_line)\n{\n    gerbv_drill_stats_t *stats = image->drill_stats;\n    drill_m_code_t m_code;\n    char op[3];\n\n    dprintf(\"---> entering %s() ...\\n\", __FUNCTION__);\n\n    op[0] = gerb_fgetc(fd);\n    op[1] = gerb_fgetc(fd);\n    op[2] = '\\0';\n\n    if (op[0] == EOF\n    ||  op[1] == EOF) {\n\tgerbv_stats_printf(stats->error_list, GERBV_MESSAGE_ERROR, -1,\n\t\t_(\"Unexpected EOF found while parsing M-code in file \\\"%s\\\"\"),\n\t\tfd->filename);\n\n\treturn DRILL_M_UNKNOWN;\n    }\n\n    dprintf(\"  Compare M-code \\\"%s\\\" at line %ld\\n\", op, file_line);\n\n    switch (m_code = atoi(op)) {\n    case 0:\n\t\/* atoi() return 0 in case of error, recheck string *\/\n\tif (0 != strncmp(op, \"00\", 2)) {\n\t    m_code = DRILL_M_UNKNOWN;\n\t    gerb_ungetc(fd);\n\t    gerb_ungetc(fd);\n\t    break;\n\t}\n\tstats->M00++;\n\tbreak;\n    case 1:\n\tstats->M01++;\n\tbreak;\n    case 18:\n\tstats->M18++;\n\tbreak;\n    case 25:\n\tstats->M25++;\n\tbreak;\n    case 30:\n\tstats->M30++;\n\tbreak;\n    case 45:\n\tstats->M45++;\n\tbreak;\n    case 47:\n\tstats->M47++;\n\tbreak;\n    case 48:\n\tstats->M48++;\n\tbreak;\n    case 71:\n\tstats->M71++;\n\teat_line(fd);\n\tbreak;\n    case 72:\n\tstats->M72++;\n\teat_line(fd);\n\tbreak;\n    case 95:\n\tstats->M95++;\n\tbreak;\n    case 97:\n\tstats->M97++;\n\tbreak;\n    case 98:\n\tstats->M98++;\n\tbreak;\n\n    default:\n    case DRILL_M_UNKNOWN:\n\tbreak;\n    }\n\n\n    dprintf(\"<----  ...leaving %s()\\n\", __FUNCTION__);\n\n    return m_code;\n} \/* drill_parse_M_code() *\/","target":0,"code_token_length":504,"total_token_length":740,"max_tokens_setting":1024}
+{"idx":247665,"func":"TEST_P(SslReadBufferLimitTest, TestBind) {\n  std::string address_string = TestUtility::getIpv4Loopback();\n  if (GetParam() == Network::Address::IpVersion::v4) {\n    source_address_ = Network::Address::InstanceConstSharedPtr{\n        new Network::Address::Ipv4Instance(address_string, 0, nullptr)};\n  } else {\n    address_string = \"::1\";\n    source_address_ = Network::Address::InstanceConstSharedPtr{\n        new Network::Address::Ipv6Instance(address_string, 0, nullptr)};\n  }\n\n  initialize();\n\n  EXPECT_CALL(listener_callbacks_, onAccept_(_))\n      .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {\n        server_connection_ = dispatcher_->createServerConnection(\n            std::move(socket), server_ssl_socket_factory_->createTransportSocket(nullptr),\n            stream_info_);\n        server_connection_->addConnectionCallbacks(server_callbacks_);\n        server_connection_->addReadFilter(read_filter_);\n        EXPECT_EQ(\"\", server_connection_->nextProtocol());\n      }));\n\n  EXPECT_CALL(client_callbacks_, onEvent(Network::ConnectionEvent::Connected))\n      .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { dispatcher_->exit(); }));\n  dispatcher_->run(Event::Dispatcher::RunType::Block);\n\n  EXPECT_EQ(address_string,\n            server_connection_->connectionInfoProvider().remoteAddress()->ip()->addressAsString());\n\n  disconnect();\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":281645,"func":"void CLASS subtract (const char *fname)\n{\n  FILE *fp;\n  int dim[3]={0,0,0}, comment=0, number=0, error=0, nd=0, c, row, col;\n  ushort *pixel;\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_DARK_FRAME,0,2);\n#endif\n\n  if (!(fp = fopen (fname, \"rb\"))) {\n#ifdef DCRAW_VERBOSE\n    perror (fname); \n#endif\n#ifdef LIBRAW_LIBRARY_BUILD\n    imgdata.process_warnings |= LIBRAW_WARN_BAD_DARKFRAME_FILE;\n#endif\n    return;\n  }\n  if (fgetc(fp) != 'P' || fgetc(fp) != '5') error = 1;\n  while (!error && nd < 3 && (c = fgetc(fp)) != EOF) {\n    if (c == '#')  comment = 1;\n    if (c == '\\n') comment = 0;\n    if (comment) continue;\n    if (isdigit(c)) number = 1;\n    if (number) {\n      if (isdigit(c)) dim[nd] = dim[nd]*10 + c -'0';\n      else if (isspace(c)) {\n\tnumber = 0;  nd++;\n      } else error = 1;\n    }\n  }\n  if (error || nd < 3) {\n#ifdef DCRAW_VERBOSE\n    fprintf (stderr,_(\"%s is not a valid PGM file!\\n\"), fname);\n#endif\n    fclose (fp);  return;\n  } else if (dim[0] != width || dim[1] != height || dim[2] != 65535) {\n#ifdef DCRAW_VERBOSE\n      fprintf (stderr,_(\"%s has the wrong dimensions!\\n\"), fname);\n#endif\n#ifdef LIBRAW_LIBRARY_BUILD\n      imgdata.process_warnings |= LIBRAW_WARN_BAD_DARKFRAME_DIM;\n#endif\n    fclose (fp);  return;\n  }\n  pixel = (ushort *) calloc (width, sizeof *pixel);\n  merror (pixel, \"subtract()\");\n  for (row=0; row < height; row++) {\n    fread (pixel, 2, width, fp);\n    for (col=0; col < width; col++)\n      BAYER(row,col) = MAX (BAYER(row,col) - ntohs(pixel[col]), 0);\n  }\n  free (pixel);\n  fclose (fp);\n  memset (cblack, 0, sizeof cblack);\n  black = 0;\n#ifdef LIBRAW_LIBRARY_BUILD\n  RUN_CALLBACK(LIBRAW_PROGRESS_DARK_FRAME,1,2);\n#endif\n}","target":0,"code_token_length":550,"total_token_length":786,"max_tokens_setting":1024}
+{"idx":437320,"func":"numbered_ref_check(Node* node)\n{\n  int r = 0;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n  case NODE_ALT:\n    do {\n      r = numbered_ref_check(NODE_CAR(node));\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_ANCHOR:\n    if (IS_NULL(NODE_BODY(node)))\n      break;\n    \/* fall *\/\n  case NODE_QUANT:\n    r = numbered_ref_check(NODE_BODY(node));\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n\n      r = numbered_ref_check(NODE_BODY(node));\n      if (r != 0) return r;\n\n      if (en->type == ENCLOSURE_IF_ELSE) {\n        if (IS_NOT_NULL(en->te.Then)) {\n          r = numbered_ref_check(en->te.Then);\n          if (r != 0) return r;\n        }\n        if (IS_NOT_NULL(en->te.Else)) {\n          r = numbered_ref_check(en->te.Else);\n          if (r != 0) return r;\n        }\n      }\n    }\n\n    break;\n\n  case NODE_BACKREF:\n    if (! NODE_IS_BY_NAME(node))\n      return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;\n    break;\n\n  default:\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":276908,"func":"static int do_i2c_read(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t       char *const argv[])\n{\n\tuint\tchip;\n\tuint\tdevaddr, length;\n\tuint\talen;\n\tu_char  *memaddr;\n\tint ret;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *dev;\n#endif\n\n\tif (argc != 5)\n\t\treturn CMD_RET_USAGE;\n\n\t\/*\n\t * I2C chip address\n\t *\/\n\tchip = hextoul(argv[1], NULL);\n\n\t\/*\n\t * I2C data address within the chip.  This can be 1 or\n\t * 2 bytes long.  Some day it might be 3 bytes long :-).\n\t *\/\n\tdevaddr = hextoul(argv[2], NULL);\n\talen = get_alen(argv[2], DEFAULT_ADDR_LEN);\n\tif (alen > 3)\n\t\treturn CMD_RET_USAGE;\n\n\t\/*\n\t * Length is the number of objects, not number of bytes.\n\t *\/\n\tlength = hextoul(argv[3], NULL);\n\n\t\/*\n\t * memaddr is the address where to store things in memory\n\t *\/\n\tmemaddr = (u_char *)hextoul(argv[4], NULL);\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (!ret && alen != -1)\n\t\tret = i2c_set_chip_offset_len(dev, alen);\n\tif (!ret)\n\t\tret = dm_i2c_read(dev, devaddr, memaddr, length);\n#else\n\tret = i2c_read(chip, devaddr, alen, memaddr, length);\n#endif\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n\n\treturn 0;\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":513361,"func":"add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)\n{\n  Field *field=key_field->field;\n  TABLE *form= field->table;\n\n  if (key_field->eq_func && !(key_field->optimize & KEY_OPTIMIZE_EXISTS))\n  {\n    for (uint key=0 ; key < form->s->keys ; key++)\n    {\n      if (!(form->keys_in_use_for_query.is_set(key)))\n\tcontinue;\n      if (form->key_info[key].flags & (HA_FULLTEXT | HA_SPATIAL))\n\tcontinue;    \/\/ ToDo: ft-keys in non-ft queries.   SerG\n\n      KEY *keyinfo= form->key_info+key;\n      uint key_parts= form->actual_n_key_parts(keyinfo);\n      for (uint part=0 ; part <  key_parts ; part++)\n      {\n        if (field->eq(form->key_info[key].key_part[part].field) &&\n            field->can_optimize_keypart_ref(key_field->cond, key_field->val))\n\t{\n          if (add_keyuse(keyuse_array, key_field, key, part))\n            return TRUE;\n\t}\n      }\n    }\n    if (field->hash_join_is_possible() &&\n        (key_field->optimize & KEY_OPTIMIZE_EQ) &&\n        key_field->val->used_tables())\n    {\n      if (!field->can_optimize_hash_join(key_field->cond, key_field->val))\n        return false;      \n      \/* \n        If a key use is extracted from an equi-join predicate then it is\n        added not only as a key use for every index whose component can\n        be evalusted utilizing this key use, but also as a key use for\n        hash join. Such key uses are marked with a special key number. \n      *\/    \n      if (add_keyuse(keyuse_array, key_field, get_hash_join_key_no(), 0))\n        return TRUE;\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":163835,"func":"v8::Handle<v8::Value> V8ThrowException::createDOMException(v8::Isolate* isolate, int ec, const String& sanitizedMessage, const String& unsanitizedMessage, const v8::Handle<v8::Object>& creationContext)\n{\n    if (ec <= 0 || v8::V8::IsExecutionTerminating())\n        return v8Undefined();\n\n    ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty());\n\n    if (ec == V8GeneralError)\n        return V8ThrowException::createGeneralError(isolate, sanitizedMessage);\n    if (ec == V8TypeError)\n        return V8ThrowException::createTypeError(isolate, sanitizedMessage);\n    if (ec == V8RangeError)\n        return V8ThrowException::createRangeError(isolate, sanitizedMessage);\n    if (ec == V8SyntaxError)\n        return V8ThrowException::createSyntaxError(isolate, sanitizedMessage);\n     if (ec == V8ReferenceError)\n         return V8ThrowException::createReferenceError(isolate, sanitizedMessage);\n \n    v8::Handle<v8::Object> sanitizedCreationContext = creationContext;\n\n    \/\/ FIXME: Is the current context always the right choice?\n    Frame* frame = toFrameIfNotDetached(creationContext->CreationContext());\n    if (!frame || !BindingSecurity::shouldAllowAccessToFrame(isolate, frame, DoNotReportSecurityError))\n        sanitizedCreationContext = isolate->GetCurrentContext()->Global();\n\n\n     RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, sanitizedMessage, unsanitizedMessage);\n    v8::Handle<v8::Value> exception = toV8(domException.get(), sanitizedCreationContext, isolate);\n \n     if (exception.IsEmpty())\n         return v8Undefined();\n\n    v8::Handle<v8::Value> error = v8::Exception::Error(v8String(isolate, domException->message()));\n    ASSERT(!error.IsEmpty());\n    ASSERT(exception->IsObject());\n    exception->ToObject(isolate)->SetAccessor(v8AtomicString(isolate, \"stack\"), domExceptionStackGetter, domExceptionStackSetter, error);\n    V8HiddenValue::setHiddenValue(isolate, exception->ToObject(isolate), V8HiddenValue::error(isolate), error);\n\n    return exception;\n}\n","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":427239,"func":"static void retstat (LexState *ls) {\n  \/* stat -> RETURN [explist] [';'] *\/\n  FuncState *fs = ls->fs;\n  expdesc e;\n  int nret;  \/* number of values being returned *\/\n  int first = luaY_nvarstack(fs);  \/* first slot to be returned *\/\n  if (block_follow(ls, 1) || ls->t.token == ';')\n    nret = 0;  \/* return no values *\/\n  else {\n    nret = explist(ls, &e);  \/* optional return values *\/\n    if (hasmultret(e.k)) {\n      luaK_setmultret(fs, &e);\n      if (e.k == VCALL && nret == 1 && !fs->bl->insidetbc) {  \/* tail call? *\/\n        SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);\n        lua_assert(GETARG_A(getinstruction(fs,&e)) == luaY_nvarstack(fs));\n      }\n      nret = LUA_MULTRET;  \/* return all values *\/\n    }\n    else {\n      if (nret == 1)  \/* only one single value? *\/\n        first = luaK_exp2anyreg(fs, &e);  \/* can use original slot *\/\n      else {  \/* values must go to the top of the stack *\/\n        luaK_exp2nextreg(fs, &e);\n        lua_assert(nret == fs->freereg - first);\n      }\n    }\n  }\n  luaK_ret(fs, first, nret);\n  testnext(ls, ';');  \/* skip optional semicolon *\/\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":310318,"func":"connection_dirserv_add_networkstatus_bytes_to_outbuf(dir_connection_t *conn)\n{\n\n  while (buf_datalen(conn->_base.outbuf) < DIRSERV_BUFFER_MIN) {\n    if (conn->cached_dir) {\n      int uncompressing = (conn->zlib_state != NULL);\n      int r = connection_dirserv_add_dir_bytes_to_outbuf(conn);\n      if (conn->dir_spool_src == DIR_SPOOL_NONE) {\n        \/* add_dir_bytes thinks we're done with the cached_dir.  But we\n         * may have more cached_dirs! *\/\n        conn->dir_spool_src = DIR_SPOOL_NETWORKSTATUS;\n        \/* This bit is tricky.  If we were uncompressing the last\n         * networkstatus, we may need to make a new zlib object to\n         * uncompress the next one. *\/\n        if (uncompressing && ! conn->zlib_state &&\n            conn->fingerprint_stack &&\n            smartlist_len(conn->fingerprint_stack)) {\n          conn->zlib_state = tor_zlib_new(0, ZLIB_METHOD);\n        }\n      }\n      if (r) return r;\n    } else if (conn->fingerprint_stack &&\n               smartlist_len(conn->fingerprint_stack)) {\n      \/* Add another networkstatus; start serving it. *\/\n      char *fp = smartlist_pop_last(conn->fingerprint_stack);\n      cached_dir_t *d = lookup_cached_dir_by_fp(fp);\n      tor_free(fp);\n      if (d) {\n        ++d->refcnt;\n        conn->cached_dir = d;\n        conn->cached_dir_offset = 0;\n      }\n    } else {\n      connection_dirserv_finish_spooling(conn);\n      smartlist_free(conn->fingerprint_stack);\n      conn->fingerprint_stack = NULL;\n      return 0;\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":361746,"func":"void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)\n{\n\tmemset(ctl, 0, sizeof(*ctl));\n\n\tctl->fname   = XC2028_DEFAULT_FIRMWARE;\n\tctl->max_len = 64;\n\tctl->mts = em28xx_boards[dev->model].mts_firmware;\n\n\tswitch (dev->model) {\n\tcase EM2880_BOARD_EMPIRE_DUAL_TV:\n\tcase EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:\n\tcase EM2882_BOARD_TERRATEC_HYBRID_XS:\n\tcase EM2880_BOARD_TERRATEC_HYBRID_XS:\n\tcase EM2880_BOARD_TERRATEC_HYBRID_XS_FR:\n\tcase EM2881_BOARD_PINNACLE_HYBRID_PRO:\n\tcase EM2882_BOARD_ZOLID_HYBRID_TV_STICK:\n\t\tctl->demod = XC3028_FE_ZARLINK456;\n\t\tbreak;\n\tcase EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:\n\tcase EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:\n\t\tctl->demod = XC3028_FE_DEFAULT;\n\t\tbreak;\n\tcase EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:\n\t\tctl->demod = XC3028_FE_DEFAULT;\n\t\tctl->fname = XC3028L_DEFAULT_FIRMWARE;\n\t\tbreak;\n\tcase EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:\n\tcase EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:\n\tcase EM2880_BOARD_PINNACLE_PCTV_HD_PRO:\n\t\t\/* FIXME: Better to specify the needed IF *\/\n\t\tctl->demod = XC3028_FE_DEFAULT;\n\t\tbreak;\n\tcase EM2883_BOARD_KWORLD_HYBRID_330U:\n\tcase EM2882_BOARD_DIKOM_DK300:\n\tcase EM2882_BOARD_KWORLD_VS_DVBT:\n\t\tctl->demod = XC3028_FE_CHINA;\n\t\tctl->fname = XC2028_DEFAULT_FIRMWARE;\n\t\tbreak;\n\tcase EM2882_BOARD_EVGA_INDTUBE:\n\t\tctl->demod = XC3028_FE_CHINA;\n\t\tctl->fname = XC3028L_DEFAULT_FIRMWARE;\n\t\tbreak;\n\tdefault:\n\t\tctl->demod = XC3028_FE_OREN538;\n\t}\n}","target":0,"code_token_length":608,"total_token_length":844,"max_tokens_setting":1024}
+{"idx":400735,"func":"static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t bytes,\n\t\t\t struct iov_iter *i)\n{\n\tstruct pipe_inode_info *pipe = i->pipe;\n\tstruct pipe_buffer *buf;\n\tunsigned int p_tail = pipe->tail;\n\tunsigned int p_mask = pipe->ring_size - 1;\n\tunsigned int i_head = i->head;\n\tsize_t off;\n\n\tif (unlikely(bytes > i->count))\n\t\tbytes = i->count;\n\n\tif (unlikely(!bytes))\n\t\treturn 0;\n\n\tif (!sanity(i))\n\t\treturn 0;\n\n\toff = i->iov_offset;\n\tbuf = &pipe->bufs[i_head & p_mask];\n\tif (off) {\n\t\tif (offset == off && buf->page == page) {\n\t\t\t\/* merge with the last one *\/\n\t\t\tbuf->len += bytes;\n\t\t\ti->iov_offset += bytes;\n\t\t\tgoto out;\n\t\t}\n\t\ti_head++;\n\t\tbuf = &pipe->bufs[i_head & p_mask];\n\t}\n\tif (pipe_full(i_head, p_tail, pipe->max_usage))\n\t\treturn 0;\n\n\tbuf->ops = &page_cache_pipe_buf_ops;\n\tbuf->flags = 0;\n\tget_page(page);\n\tbuf->page = page;\n\tbuf->offset = offset;\n\tbuf->len = bytes;\n\n\tpipe->head = i_head + 1;\n\ti->iov_offset = offset + bytes;\n\ti->head = i_head;\nout:\n\ti->count -= bytes;\n\treturn bytes;\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":279906,"func":"prepare_tagpreview(\n    int\t\tundo_sync,\t    \/\/ sync undo when leaving the window\n    int\t\tuse_previewpopup,   \/\/ use popup if 'previewpopup' set\n    use_popup_T\tuse_popup)\t    \/\/ use other popup window\n{\n    win_T\t*wp;\n\n# ifdef FEAT_GUI\n    need_mouse_correct = TRUE;\n# endif\n\n    \/*\n     * If there is already a preview window open, use that one.\n     *\/\n    if (!curwin->w_p_pvw)\n    {\n# ifdef FEAT_PROP_POPUP\n\tif (use_previewpopup && *p_pvp != NUL)\n\t{\n\t    wp = popup_find_preview_window();\n\t    if (wp != NULL)\n\t\tpopup_set_wantpos_cursor(wp, wp->w_minwidth, NULL);\n\t}\n\telse if (use_popup != USEPOPUP_NONE)\n\t{\n\t    wp = popup_find_info_window();\n\t    if (wp != NULL)\n\t    {\n\t\tif (use_popup == USEPOPUP_NORMAL)\n\t\t    popup_show(wp);\n\t\telse\n\t\t    popup_hide(wp);\n\t\t\/\/ When the popup moves or resizes it may reveal part of\n\t\t\/\/ another window.  TODO: can this be done more efficiently?\n\t\tredraw_all_later(NOT_VALID);\n\t    }\n\t}\n\telse\n# endif\n\t{\n\t    FOR_ALL_WINDOWS(wp)\n\t\tif (wp->w_p_pvw)\n\t\t    break;\n\t}\n\tif (wp != NULL)\n\t    win_enter(wp, undo_sync);\n\telse\n\t{\n\t    \/*\n\t     * There is no preview window open yet.  Create one.\n\t     *\/\n# ifdef FEAT_PROP_POPUP\n\t    if ((use_previewpopup && *p_pvp != NUL)\n\t\t\t\t\t\t || use_popup != USEPOPUP_NONE)\n\t\treturn popup_create_preview_window(use_popup != USEPOPUP_NONE);\n# endif\n\t    if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0) == FAIL)\n\t\treturn FALSE;\n\t    curwin->w_p_pvw = TRUE;\n\t    curwin->w_p_wfh = TRUE;\n\t    RESET_BINDING(curwin);\t    \/\/ don't take over 'scrollbind'\n\t    \/\/ and 'cursorbind'\n# ifdef FEAT_DIFF\n\t    curwin->w_p_diff = FALSE;\t    \/\/ no 'diff'\n# endif\n# ifdef FEAT_FOLDING\n\t    curwin->w_p_fdc = 0;\t    \/\/ no 'foldcolumn'\n# endif\n\t    return TRUE;\n\t}\n    }\n    return FALSE;\n}","target":0,"code_token_length":526,"total_token_length":762,"max_tokens_setting":1024}
+{"idx":513272,"func":"end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),\n\t   bool end_of_records)\n{\n  TABLE *const table= join_tab->table;\n  ORDER   *group;\n  int\t  error;\n  DBUG_ENTER(\"end_update\");\n\n  if (end_of_records)\n    DBUG_RETURN(NESTED_LOOP_OK);\n\n  join->found_records++;\n  copy_fields(join_tab->tmp_table_param);\t\/\/ Groups are copied twice.\n  \/* Make a key of group index *\/\n  for (group=table->group ; group ; group=group->next)\n  {\n    Item *item= *group->item;\n    if (group->fast_field_copier_setup != group->field)\n    {\n      DBUG_PRINT(\"info\", (\"new setup %p -> %p\",\n                          group->fast_field_copier_setup,\n                          group->field));\n      group->fast_field_copier_setup= group->field;\n      group->fast_field_copier_func=\n        item->setup_fast_field_copier(group->field);\n    }\n    item->save_org_in_field(group->field, group->fast_field_copier_func);\n    \/* Store in the used key if the field was 0 *\/\n    if (item->maybe_null)\n      group->buff[-1]= (char) group->field->is_null();\n  }\n  if (!table->file->ha_index_read_map(table->record[1],\n                                      join_tab->tmp_table_param->group_buff,\n                                      HA_WHOLE_KEY,\n                                      HA_READ_KEY_EXACT))\n  {\t\t\t\t\t\t\/* Update old record *\/\n    restore_record(table,record[1]);\n    update_tmptable_sum_func(join->sum_funcs,table);\n    if ((error= table->file->ha_update_tmp_row(table->record[1],\n                                               table->record[0])))\n    {\n      table->file->print_error(error,MYF(0));\t\/* purecov: inspected *\/\n      DBUG_RETURN(NESTED_LOOP_ERROR);            \/* purecov: inspected *\/\n    }\n    goto end;\n  }\n\n  init_tmptable_sum_functions(join->sum_funcs);\n  if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd))\n    DBUG_RETURN(NESTED_LOOP_ERROR);           \/* purecov: inspected *\/\n  if ((error= table->file->ha_write_tmp_row(table->record[0])))\n  {\n    if (create_internal_tmp_table_from_heap(join->thd, table,\n                                       join_tab->tmp_table_param->start_recinfo,\n                                            &join_tab->tmp_table_param->recinfo,\n                                            error, 0, NULL))\n      DBUG_RETURN(NESTED_LOOP_ERROR);            \/\/ Not a table_is_full error\n    \/* Change method to update rows *\/\n    if ((error= table->file->ha_index_init(0, 0)))\n    {\n      table->file->print_error(error, MYF(0));\n      DBUG_RETURN(NESTED_LOOP_ERROR);\n    }\n\n    join_tab->aggr->set_write_func(end_unique_update);\n  }\n  join_tab->send_records++;\nend:\n  if (join->thd->check_killed())\n  {\n    join->thd->send_kill_message();\n    DBUG_RETURN(NESTED_LOOP_KILLED);             \/* purecov: inspected *\/\n  }\n  DBUG_RETURN(NESTED_LOOP_OK);\n}","target":0,"code_token_length":708,"total_token_length":944,"max_tokens_setting":1024}
+{"idx":297216,"func":"static int exif_scan_thumbnail(image_info_type *ImageInfo TSRMLS_DC)\n{\n\tuchar           c, *data = (uchar*)ImageInfo->Thumbnail.data;\n\tint             n, marker;\n\tsize_t          length=2, pos=0;\n\tjpeg_sof_info   sof_info;\n\n\tif (!data) {\n\t\treturn FALSE; \/* nothing to do here *\/\n\t}\n\tif (memcmp(data, \"\\xFF\\xD8\\xFF\", 3)) {\n\t\tif (!ImageInfo->Thumbnail.width && !ImageInfo->Thumbnail.height) {\n\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Thumbnail is not a JPEG image\");\n\t\t}\n\t\treturn FALSE;\n\t}\n\tfor (;;) {\n\t\tpos += length;\n\t\tif (pos>=ImageInfo->Thumbnail.size)\n\t\t\treturn FALSE;\n\t\tc = data[pos++];\n\t\tif (pos>=ImageInfo->Thumbnail.size)\n\t\t\treturn FALSE;\n\t\tif (c != 0xFF) {\n\t\t\treturn FALSE;\n\t\t}\n\t\tn = 8;\n\t\twhile ((c = data[pos++]) == 0xFF && n--) {\n\t\t\tif (pos+3>=ImageInfo->Thumbnail.size)\n\t\t\t\treturn FALSE;\n\t\t\t\/* +3 = pos++ of next check when reaching marker + 2 bytes for length *\/\n\t\t}\n\t\tif (c == 0xFF)\n\t\t\treturn FALSE;\n\t\tmarker = c;\n\t\tlength = php_jpg_get16(data+pos);\n\t\tif (pos+length>=ImageInfo->Thumbnail.size) {\n\t\t\treturn FALSE;\n\t\t}\n#ifdef EXIF_DEBUG\n\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Thumbnail: process section(x%02X=%s) @ x%04X + x%04X\", marker, exif_get_markername(marker), pos, length);\n#endif\n\t\tswitch (marker) {\n\t\t\tcase M_SOF0:\n\t\t\tcase M_SOF1:\n\t\t\tcase M_SOF2:\n\t\t\tcase M_SOF3:\n\t\t\tcase M_SOF5:\n\t\t\tcase M_SOF6:\n\t\t\tcase M_SOF7:\n\t\t\tcase M_SOF9:\n\t\t\tcase M_SOF10:\n\t\t\tcase M_SOF11:\n\t\t\tcase M_SOF13:\n\t\t\tcase M_SOF14:\n\t\t\tcase M_SOF15:\n\t\t\t\t\/* handle SOFn block *\/\n\t\t\t\texif_process_SOFn(data+pos, marker, &sof_info);\n\t\t\t\tImageInfo->Thumbnail.height   = sof_info.height;\n\t\t\t\tImageInfo->Thumbnail.width    = sof_info.width;\n#ifdef EXIF_DEBUG\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, \"Thumbnail: size: %d * %d\", sof_info.width, sof_info.height);\n#endif\n\t\t\t\treturn TRUE;\n\n\t\t\tcase M_SOS:\n\t\t\tcase M_EOI:\n\t\t\t\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Could not compute size of thumbnail\");\n\t\t\t\treturn FALSE;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t\/* just skip *\/\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\texif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, \"Could not compute size of thumbnail\");\n\treturn FALSE;\n}","target":0,"code_token_length":678,"total_token_length":914,"max_tokens_setting":1024}
+{"idx":198566,"func":"MOBI_RET mobi_decode_infl(unsigned char *decoded, int *decoded_size, const unsigned char *rule) {\n    int pos = *decoded_size;\n    char mod = 'i';\n    char dir = '<';\n    char olddir;\n    unsigned char c;\n    while ((c = *rule++)) {\n        if (c <= 4) {\n            mod = (c <= 2) ? 'i' : 'd'; \/* insert, delete *\/\n            olddir = dir;\n            dir = (c & 2) ? '<' : '>'; \/* left, right *\/\n            if (olddir != dir && olddir) {\n                pos = (c & 2) ? *decoded_size : 0;\n            }\n        }\n        else if (c > 10 && c < 20) {\n            if (dir == '>') {\n                pos = *decoded_size;\n            }\n            pos -= c - 10;\n            dir = 0;\n            if (pos < 0 || pos > *decoded_size) {\n                debug_print(\"Position setting failed (%s)\\n\", decoded);\n                return MOBI_DATA_CORRUPT;\n            }\n        }\n        else {\n            if (mod == 'i') {\n                const unsigned char *s = decoded + pos;\n                unsigned char *d = decoded + pos + 1;\n                const int l = *decoded_size - pos;\n                if (l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {\n                    debug_print(\"Out of buffer in %s at pos: %i\\n\", decoded, pos);\n                    return MOBI_DATA_CORRUPT;\n                }\n                memmove(d, s, (size_t) l);\n                decoded[pos] = c;\n                (*decoded_size)++;\n                if (dir == '>') { pos++; }\n            } else {\n                if (dir == '<') { pos--; }\n                const unsigned char *s = decoded + pos + 1;\n                unsigned char *d = decoded + pos;\n                const int l = *decoded_size - pos;\n                if (l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {\n                    debug_print(\"Out of buffer in %s at pos: %i\\n\", decoded, pos);\n                    return MOBI_DATA_CORRUPT;\n                }\n                if (decoded[pos] != c) {\n                    debug_print(\"Character mismatch in %s at pos: %i (%c != %c)\\n\", decoded, pos, decoded[pos], c);\n                    return MOBI_DATA_CORRUPT;\n                }\n                memmove(d, s, (size_t) l);\n                (*decoded_size)--;\n            }\n        }\n    }\n    return MOBI_SUCCESS;\n}","target":1,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":242647,"func":"GF_Err isoffin_initialize(GF_Filter *filter)\n{\n\tISOMReader *read = gf_filter_get_udta(filter);\n\tGF_Err e = GF_OK;\n\tread->filter = filter;\n\tread->channels = gf_list_new();\n\n\tif (read->xps_check==MP4DMX_XPS_AUTO) {\n\t\tread->xps_check = (read->smode==MP4DMX_SPLIT_EXTRACTORS) ? MP4DMX_XPS_KEEP : MP4DMX_XPS_REMOVE;\n\t}\n\n\tif (read->src) {\n\t\tread->input_loaded = GF_TRUE;\n\t\treturn isoffin_setup(filter, read);\n\t}\n\telse if (read->mov) {\n\t\tread->extern_mov = GF_TRUE;\n\t\tread->input_loaded = GF_TRUE;\n\t\tread->frag_type = gf_isom_is_fragmented(read->mov) ? 1 : 0;\n\t\tread->timescale = gf_isom_get_timescale(read->mov);\n\n\t\tif (read->sigfrag) {\n\t\t\tgf_isom_enable_traf_map_templates(read->mov);\n\t\t}\n\n\t\tif (read->catseg) {\n\t\t\te = gf_isom_open_segment(read->mov, read->catseg, 0, 0, 0);\n\t\t}\n\t\tif (!e)\n\t\t\te = isor_declare_objects(read);\n\n\t\tgf_filter_post_process_task(filter);\n\t}\n\treturn e;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":294514,"func":"datetime_s_weeknum(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vw, vd, vf, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;\n    int w, d, f, h, min, s, rof;\n    double sg;\n\n    rb_scan_args(argc, argv, \"09\", &vy, &vw, &vd, &vf,\n\t\t &vh, &vmin, &vs, &vof, &vsg);\n\n    y = INT2FIX(-4712);\n    w = 0;\n    d = 1;\n    f = 0;\n\n    h = min = s = 0;\n    fr2 = INT2FIX(0);\n    rof = 0;\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 9:\n\tval2sg(vsg, sg);\n      case 8:\n\tval2off(vof, rof);\n      case 7:\n\tnum2int_with_frac(s, positive_inf);\n      case 6:\n\tnum2int_with_frac(min, 6);\n      case 5:\n\tnum2int_with_frac(h, 5);\n      case 4:\n\tf = NUM2INT(vf);\n      case 3:\n\tnum2int_with_frac(d, 4);\n      case 2:\n\tw = NUM2INT(vw);\n      case 1:\n\ty = vy;\n    }\n\n    {\n\tVALUE nth;\n\tint ry, rw, rd, rh, rmin, rs, rjd, rjd2, ns;\n\n\tif (!valid_weeknum_p(y, w, d, f, sg,\n\t\t\t     &nth, &ry,\n\t\t\t     &rw, &rd, &rjd,\n\t\t\t     &ns))\n\t    rb_raise(eDateError, \"invalid date\");\n\tif (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))\n\t    rb_raise(eDateError, \"invalid date\");\n\tcanon24oc();\n\n\trjd2 = jd_local_to_utc(rjd,\n\t\t\t       time_to_df(rh, rmin, rs),\n\t\t\t       rof);\n\tret = d_complex_new_internal(klass,\n\t\t\t\t     nth, rjd2,\n\t\t\t\t     0, INT2FIX(0),\n\t\t\t\t     rof, sg,\n\t\t\t\t     0, 0, 0,\n\t\t\t\t     rh, rmin, rs,\n\t\t\t\t     HAVE_JD | HAVE_TIME);\n    }\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":272367,"func":"unescape_html_in_place(char *s)\n{\n\tsize_t sz = strlen(s) + 1;\n\tsize_t pos = 0;\n\tchar *s1;\n\n\tdprintf(\"unescaping pos:%zd sz:%zd \\\"%s\\\"\", pos, sz, s);\n\tdo {\n\t\ts1 = strchrnul(&s[pos], '%');\n\t\tif (s1[0] == '\\0')\n\t\t\tbreak;\n\t\tdprintf(\"s1 is \\\"%s\\\"\", s1);\n\t\tif ((size_t)(s1 - s) < (size_t)(sz - 3)) {\n\t\t\tint c;\n\n\t\t\tc = (hexchar_to_bin(s1[1]) << 4)\n\t\t\t    | (hexchar_to_bin(s1[2]) & 0xf);\n\t\t\tdprintf(\"replacing %%%c%c with 0x%02hhx\", s1[1], s1[2], (char)c);\n\t\t\ts1[0] = c;\n\t\t\tmemmove(&s1[1], &s1[3], sz - (&s1[3] - s));\n\t\t\tsz -= 2;\n\t\t\tpos = &s1[1] - s;\n\t\t\tdprintf(\"new pos:%zd sz:%zd s:\\\"%s\\\"\", pos, sz, s);\n\t\t}\n\t} while (pos < sz);\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":229253,"func":"std::unique_ptr<cql_server::response> cql_server::connection::make_supported(int16_t stream, const tracing::trace_state_ptr& tr_state) const\n{\n    std::multimap<sstring, sstring> opts;\n    opts.insert({\"CQL_VERSION\", cql3::query_processor::CQL_VERSION});\n    opts.insert({\"COMPRESSION\", \"lz4\"});\n    opts.insert({\"COMPRESSION\", \"snappy\"});\n    if (_server._config.allow_shard_aware_drivers) {\n        opts.insert({\"SCYLLA_SHARD\", format(\"{:d}\", this_shard_id())});\n        opts.insert({\"SCYLLA_NR_SHARDS\", format(\"{:d}\", smp::count)});\n        opts.insert({\"SCYLLA_SHARDING_ALGORITHM\", dht::cpu_sharding_algorithm_name()});\n        if (_server._config.shard_aware_transport_port) {\n            opts.insert({\"SCYLLA_SHARD_AWARE_PORT\", format(\"{:d}\", *_server._config.shard_aware_transport_port)});\n        }\n        if (_server._config.shard_aware_transport_port_ssl) {\n            opts.insert({\"SCYLLA_SHARD_AWARE_PORT_SSL\", format(\"{:d}\", *_server._config.shard_aware_transport_port_ssl)});\n        }\n        opts.insert({\"SCYLLA_SHARDING_IGNORE_MSB\", format(\"{:d}\", _server._config.sharding_ignore_msb)});\n        opts.insert({\"SCYLLA_PARTITIONER\", _server._config.partitioner_name});\n    }\n    for (cql_protocol_extension ext : supported_cql_protocol_extensions()) {\n        const sstring ext_key_name = protocol_extension_name(ext);\n        std::vector<sstring> params = additional_options_for_proto_ext(ext);\n        if (params.empty()) {\n            opts.emplace(ext_key_name, \"\");\n        } else {\n            for (sstring val : params) {\n                opts.emplace(ext_key_name, std::move(val));\n            }\n        }\n    }\n    auto response = std::make_unique<cql_server::response>(stream, cql_binary_opcode::SUPPORTED, tr_state);\n    response->write_string_multimap(std::move(opts));\n    return response;\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":508779,"func":"static int rr_from_cache(READ_RECORD *info)\n{\n  uint i;\n  ulong length;\n  my_off_t rest_of_file;\n  int16 error;\n  uchar *position,*ref_position,*record_pos;\n  ulong record;\n\n  for (;;)\n  {\n    if (info->cache_pos != info->cache_end)\n    {\n      if (info->cache_pos[info->error_offset])\n      {\n\tshortget(error,info->cache_pos);\n\tif (info->print_error)\n\t  info->table->file->print_error(error,MYF(0));\n      }\n      else\n      {\n\terror=0;\n\tmemcpy(info->record,info->cache_pos,\n               (size_t) info->table->s->reclength);\n      }\n      info->cache_pos+=info->reclength;\n      return ((int) error);\n    }\n    length=info->rec_cache_size;\n    rest_of_file=info->io_cache->end_of_file - my_b_tell(info->io_cache);\n    if ((my_off_t) length > rest_of_file)\n      length= (ulong) rest_of_file;\n    if (!length || my_b_read(info->io_cache,info->cache,length))\n    {\n      DBUG_PRINT(\"info\",(\"Found end of file\"));\n      return -1;\t\t\t\/* End of file *\/\n    }\n\n    length\/=info->ref_length;\n    position=info->cache;\n    ref_position=info->read_positions;\n    for (i=0 ; i < length ; i++,position+=info->ref_length)\n    {\n      memcpy(ref_position,position,(size_t) info->ref_length);\n      ref_position+=MAX_REFLENGTH;\n      int3store(ref_position,(long) i);\n      ref_position+=3;\n    }\n    my_qsort(info->read_positions, length, info->struct_length,\n             (qsort_cmp) rr_cmp);\n\n    position=info->read_positions;\n    for (i=0 ; i < length ; i++)\n    {\n      memcpy(info->ref_pos,position,(size_t) info->ref_length);\n      position+=MAX_REFLENGTH;\n      record=uint3korr(position);\n      position+=3;\n      record_pos=info->cache+record*info->reclength;\n      if ((error=(int16) info->table->file->ha_rnd_pos(record_pos,info->ref_pos)))\n      {\n\trecord_pos[info->error_offset]=1;\n\tshortstore(record_pos,error);\n\tDBUG_PRINT(\"error\",(\"Got error: %d:%d when reading row\",\n\t\t\t    my_errno, error));\n      }\n      else\n\trecord_pos[info->error_offset]=0;\n    }\n    info->cache_end=(info->cache_pos=info->cache)+length*info->reclength;\n  }\n} \/* rr_from_cache *\/","target":0,"code_token_length":585,"total_token_length":821,"max_tokens_setting":1024}
+{"idx":237879,"func":"qeh_write_type (struct qpack_enc_hdl *qeh)\n{\n    int s;\n\n#ifndef NDEBUG\n    const char *env = getenv(\"LSQUIC_RND_VARINT_LEN\");\n    if (env && atoi(env))\n    {\n        s = rand() & 3;\n        LSQ_DEBUG(\"writing %d-byte stream type\", 1 << s);\n    }\n    else\n#endif\n        s = 0;\n\n    switch (s)\n    {\n    case 0:\n        return lsquic_frab_list_write(&qeh->qeh_fral,\n                                (unsigned char []) { HQUST_QPACK_ENC }, 1);\n    case 1:\n        return lsquic_frab_list_write(&qeh->qeh_fral,\n                            (unsigned char []) { 0x40, HQUST_QPACK_ENC }, 2);\n    case 2:\n        return lsquic_frab_list_write(&qeh->qeh_fral,\n                (unsigned char []) { 0x80, 0x00, 0x00, HQUST_QPACK_ENC }, 4);\n    default:\n        return lsquic_frab_list_write(&qeh->qeh_fral,\n                (unsigned char []) { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n                                                        HQUST_QPACK_ENC }, 8);\n    }\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":349268,"func":"static void squashfs_stat(char *source)\n{\n\ttime_t mkfs_time = (time_t) sBlk.s.mkfs_time;\n\tstruct tm *t = use_localtime ? localtime(&mkfs_time) :\n\t\t\t\t\tgmtime(&mkfs_time);\n\tchar *mkfs_str = asctime(t);\n\n#if __BYTE_ORDER == __BIG_ENDIAN\n\tprintf(\"Found a valid %sSQUASHFS %d:%d superblock on %s.\\n\",\n\t\tswap ? \"little endian \" : \"big endian \", sBlk.s.s_major,\n\t\tsBlk.s.s_minor, source);\n#else\n\tprintf(\"Found a valid %sSQUASHFS %d:%d superblock on %s.\\n\",\n\t\tswap ? \"big endian \" : \"little endian \", sBlk.s.s_major,\n\t\tsBlk.s.s_minor, source);\n#endif\n\n\tprintf(\"Creation or last append time %s\", mkfs_str ? mkfs_str :\n\t\t\"failed to get time\\n\");\n\tprintf(\"Filesystem size %llu bytes (%.2f Kbytes \/ %.2f Mbytes)\\n\",\n\t\tsBlk.s.bytes_used, sBlk.s.bytes_used \/ 1024.0,\n\t\tsBlk.s.bytes_used \/ (1024.0 * 1024.0));\n\n\tprintf(\"Block size %d\\n\", sBlk.s.block_size);\n\tprintf(\"Filesystem is %sexportable via NFS\\n\",\n\t\tSQUASHFS_EXPORTABLE(sBlk.s.flags) ? \"\" : \"not \");\n\tprintf(\"Inodes are %scompressed\\n\",\n\t\tSQUASHFS_UNCOMPRESSED_INODES(sBlk.s.flags) ? \"un\" : \"\");\n\tprintf(\"Data is %scompressed\\n\",\n\t\tSQUASHFS_UNCOMPRESSED_DATA(sBlk.s.flags) ? \"un\" : \"\");\n\n\tif(SQUASHFS_NO_FRAGMENTS(sBlk.s.flags))\n\t\tprintf(\"Fragments are not stored\\n\");\n\telse {\n\t\tprintf(\"Fragments are %scompressed\\n\",\n\t\t\tSQUASHFS_UNCOMPRESSED_FRAGMENTS(sBlk.s.flags) ?  \"un\" : \"\");\n\t\tprintf(\"Always-use-fragments option is %sspecified\\n\",\n\t\t\t\tSQUASHFS_ALWAYS_FRAGMENTS(sBlk.s.flags) ? \"\" : \"not \");\n\t}\n\n\tprintf(\"Check data is %spresent in the filesystem\\n\",\n\t\tSQUASHFS_CHECK_DATA(sBlk.s.flags) ? \"\" : \"not \");\n\tprintf(\"Duplicates are %sremoved\\n\", SQUASHFS_DUPLICATES(sBlk.s.flags) ? \"\" : \"not \");\n\tprintf(\"Number of fragments %d\\n\", sBlk.s.fragments);\n\tprintf(\"Number of inodes %d\\n\", sBlk.s.inodes);\n\tprintf(\"Number of uids %d\\n\", sBlk.no_uids);\n\tprintf(\"Number of gids %d\\n\", sBlk.no_guids);\n\n\tTRACE(\"sBlk.s.inode_table_start 0x%llx\\n\", sBlk.s.inode_table_start);\n\tTRACE(\"sBlk.s.directory_table_start 0x%llx\\n\", sBlk.s.directory_table_start);\n\tTRACE(\"sBlk.s.fragment_table_start 0x%llx\\n\\n\", sBlk.s.fragment_table_start);\n\tTRACE(\"sBlk.uid_start 0x%llx\\n\", sBlk.uid_start);\n\tTRACE(\"sBlk.guid_start 0x%llx\\n\", sBlk.guid_start);\n}","target":0,"code_token_length":728,"total_token_length":964,"max_tokens_setting":1024}
+{"idx":484748,"func":"static int xennet_xdp_set(struct net_device *dev, struct bpf_prog *prog,\n\t\t\t  struct netlink_ext_ack *extack)\n{\n\tunsigned long max_mtu = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM;\n\tstruct netfront_info *np = netdev_priv(dev);\n\tstruct bpf_prog *old_prog;\n\tunsigned int i, err;\n\n\tif (dev->mtu > max_mtu) {\n\t\tnetdev_warn(dev, \"XDP requires MTU less than %lu\\n\", max_mtu);\n\t\treturn -EINVAL;\n\t}\n\n\tif (!np->netback_has_xdp_headroom)\n\t\treturn 0;\n\n\txenbus_switch_state(np->xbdev, XenbusStateReconfiguring);\n\n\terr = talk_to_netback_xdp(np, prog ? NETBACK_XDP_HEADROOM_ENABLE :\n\t\t\t\t  NETBACK_XDP_HEADROOM_DISABLE);\n\tif (err)\n\t\treturn err;\n\n\t\/* avoid the race with XDP headroom adjustment *\/\n\twait_event(module_wq,\n\t\t   xenbus_read_driver_state(np->xbdev->otherend) ==\n\t\t   XenbusStateReconfigured);\n\tnp->netfront_xdp_enabled = true;\n\n\told_prog = rtnl_dereference(np->queues[0].xdp_prog);\n\n\tif (prog)\n\t\tbpf_prog_add(prog, dev->real_num_tx_queues);\n\n\tfor (i = 0; i < dev->real_num_tx_queues; ++i)\n\t\trcu_assign_pointer(np->queues[i].xdp_prog, prog);\n\n\tif (old_prog)\n\t\tfor (i = 0; i < dev->real_num_tx_queues; ++i)\n\t\t\tbpf_prog_put(old_prog);\n\n\txenbus_switch_state(np->xbdev, XenbusStateConnected);\n\n\treturn 0;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":359657,"func":"community_list_config_write (struct vty *vty)\n{\n  struct community_list *list;\n  struct community_entry *entry;\n  struct community_list_master *cm;\n  int write = 0;\n\n  \/* Community-list.  *\/\n  cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);\n\n  for (list = cm->num.head; list; list = list->next)\n    for (entry = list->head; entry; entry = entry->next)\n      {\n\tvty_out (vty, \"ip community-list %s %s %s%s\",\n\t\t list->name, community_direct_str (entry->direct),\n\t\t community_list_config_str (entry),\n\t\t VTY_NEWLINE);\n\twrite++;\n      }\n  for (list = cm->str.head; list; list = list->next)\n    for (entry = list->head; entry; entry = entry->next)\n      {\n\tvty_out (vty, \"ip community-list %s %s %s %s%s\",\n\t\t entry->style == COMMUNITY_LIST_STANDARD\n\t\t ? \"standard\" : \"expanded\",\n\t\t list->name, community_direct_str (entry->direct),\n\t\t community_list_config_str (entry),\n\t\t VTY_NEWLINE);\n\twrite++;\n      }\n\n  \/* Extcommunity-list.  *\/\n  cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);\n\n  for (list = cm->num.head; list; list = list->next)\n    for (entry = list->head; entry; entry = entry->next)\n      {\n\tvty_out (vty, \"ip extcommunity-list %s %s %s%s\",\n\t\t list->name, community_direct_str (entry->direct),\n\t\t community_list_config_str (entry), VTY_NEWLINE);\n\twrite++;\n      }\n  for (list = cm->str.head; list; list = list->next)\n    for (entry = list->head; entry; entry = entry->next)\n      {\n\tvty_out (vty, \"ip extcommunity-list %s %s %s %s%s\",\n\t\t entry->style == EXTCOMMUNITY_LIST_STANDARD\n\t\t ? \"standard\" : \"expanded\",\n\t\t list->name, community_direct_str (entry->direct),\n\t\t community_list_config_str (entry), VTY_NEWLINE);\n\twrite++;\n      }\n  return write;\n}","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":374036,"func":"static void header(RBinFile *bf) {\n\tr_return_if_fail (bf && bf->o);\n\n\tRCoreSymCacheElement *element = bf->o->bin_obj;\n\tif (!element) {\n\t\treturn;\n\t}\n\n\tRBin *bin = bf->rbin;\n\tPrintfCallback p = bin->cb_printf;\n\tPJ *pj = pj_new ();\n\tif (!pj) {\n\t\treturn;\n\t}\n\n\tpj_o (pj);\n\tpj_kn (pj, \"cs_version\", element->hdr->version);\n\tpj_kn (pj, \"size\", element->hdr->size);\n\tif (element->file_name) {\n\t\tpj_ks (pj, \"name\", element->file_name);\n\t}\n\tif (element->binary_version) {\n\t\tpj_ks (pj, \"version\", element->binary_version);\n\t}\n\tchar uuidstr[R_UUID_LENGTH];\n\tr_hex_bin2str (element->hdr->uuid, 16, uuidstr);\n\tpj_ks (pj, \"uuid\", uuidstr);\n\tpj_kn (pj, \"segments\", element->hdr->n_segments);\n\tpj_kn (pj, \"sections\", element->hdr->n_sections);\n\tpj_kn (pj, \"symbols\", element->hdr->n_symbols);\n\tpj_kn (pj, \"lined_symbols\", element->hdr->n_lined_symbols);\n\tpj_kn (pj, \"line_info\", element->hdr->n_line_info);\n\tpj_end (pj);\n\n\tp (\"%s\\n\", pj_string (pj));\n\tpj_free (pj);\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":262803,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Read ragged_splits inputs.\n    OpInputList ragged_nested_splits_in;\n    OP_REQUIRES_OK(context, context->input_list(\"rt_nested_splits\",\n                                                &ragged_nested_splits_in));\n    const int ragged_nested_splits_len = ragged_nested_splits_in.size();\n    RaggedTensorVariant batched_ragged_input;\n    \/\/ Read ragged_values input.\n    batched_ragged_input.set_values(context->input(ragged_nested_splits_len));\n    batched_ragged_input.mutable_nested_splits()->reserve(\n        ragged_nested_splits_len);\n    for (int i = 0; i < ragged_nested_splits_len; i++) {\n      batched_ragged_input.append_splits(ragged_nested_splits_in[i]);\n    }\n\n    if (!batched_input_) {\n      \/\/ Encode as a Scalar Variant Tensor.\n      Tensor* encoded_scalar;\n      OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({}),\n                                                       &encoded_scalar));\n      encoded_scalar->scalar<Variant>()() = std::move(batched_ragged_input);\n      return;\n    }\n\n    \/\/ Checked here instead of at input in case batched_input_ is false\n    OP_REQUIRES(context, ragged_nested_splits_len > 0,\n                errors::InvalidArgument(\n                    \"rt_nested_splits must be a list of one or more, but \"\n                    \"received rt_nested_splits of length 0.\"));\n\n    \/\/ Unbatch the Ragged Tensor and encode the components.\n    std::vector<RaggedTensorVariant> unbatched_ragged_input;\n    auto batched_splits_top_vec =\n        batched_ragged_input.splits(0).vec<SPLIT_TYPE>();\n    int num_components = batched_splits_top_vec.size() - 1;\n    OP_REQUIRES(context, num_components >= 0,\n                errors::Internal(\"Invalid split argument.\"));\n    OP_REQUIRES_OK(context, UnbatchRaggedZerothDim<VALUE_TYPE, SPLIT_TYPE>(\n                                batched_ragged_input, &unbatched_ragged_input));\n\n    \/\/ Bundle the encoded scalar Variant Tensors into a rank-1 Variant Tensor.\n    Tensor* encoded_vector;\n    int output_size = unbatched_ragged_input.size();\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(0, TensorShape({output_size}),\n                                            &encoded_vector));\n    auto encoded_vector_t = encoded_vector->vec<Variant>();\n    for (int i = 0; i < output_size; i++) {\n      encoded_vector_t(i) = unbatched_ragged_input[i];\n    }\n  }","target":0,"code_token_length":535,"total_token_length":771,"max_tokens_setting":1024}
+{"idx":361742,"func":"static void request_module_async(struct work_struct *work)\n{\n\tstruct em28xx *dev = container_of(work,\n\t\t\t     struct em28xx, request_module_wk);\n\n\t\/*\n\t * The em28xx extensions can be modules or builtin. If the\n\t * modules are already loaded or are built in, those extensions\n\t * can be initialised right now. Otherwise, the module init\n\t * code will do it.\n\t *\/\n\n\t\/*\n\t * Devices with an audio-only intf also have a V4L\/DVB\/RC\n\t * intf. Don't register extensions twice on those devices.\n\t *\/\n\tif (dev->is_audio_only) {\n#if defined(CONFIG_MODULES) && defined(MODULE)\n\t\trequest_module(\"em28xx-alsa\");\n#endif\n\t\treturn;\n\t}\n\n\tem28xx_init_extension(dev);\n\n#if defined(CONFIG_MODULES) && defined(MODULE)\n\tif (dev->has_video)\n\t\trequest_module(\"em28xx-v4l\");\n\tif (dev->usb_audio_type == EM28XX_USB_AUDIO_CLASS)\n\t\trequest_module(\"snd-usb-audio\");\n\telse if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)\n\t\trequest_module(\"em28xx-alsa\");\n\tif (dev->board.has_dvb)\n\t\trequest_module(\"em28xx-dvb\");\n\tif (dev->board.buttons ||\n\t    ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir))\n\t\trequest_module(\"em28xx-rc\");\n#endif \/* CONFIG_MODULES *\/\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":221389,"func":"static int nested_svm_intercept(struct vcpu_svm *svm)\n{\n\tu32 exit_code = svm->vmcb->control.exit_code;\n\tint vmexit = NESTED_EXIT_HOST;\n\n\tswitch (exit_code) {\n\tcase SVM_EXIT_MSR:\n\t\tvmexit = nested_svm_exit_handled_msr(svm);\n\t\tbreak;\n\tcase SVM_EXIT_IOIO:\n\t\tvmexit = nested_svm_intercept_ioio(svm);\n\t\tbreak;\n\tcase SVM_EXIT_READ_CR0 ... SVM_EXIT_WRITE_CR8: {\n\t\tif (vmcb_is_intercept(&svm->nested.ctl, exit_code))\n\t\t\tvmexit = NESTED_EXIT_DONE;\n\t\tbreak;\n\t}\n\tcase SVM_EXIT_READ_DR0 ... SVM_EXIT_WRITE_DR7: {\n\t\tif (vmcb_is_intercept(&svm->nested.ctl, exit_code))\n\t\t\tvmexit = NESTED_EXIT_DONE;\n\t\tbreak;\n\t}\n\tcase SVM_EXIT_EXCP_BASE ... SVM_EXIT_EXCP_BASE + 0x1f: {\n\t\t\/*\n\t\t * Host-intercepted exceptions have been checked already in\n\t\t * nested_svm_exit_special.  There is nothing to do here,\n\t\t * the vmexit is injected by svm_check_nested_events.\n\t\t *\/\n\t\tvmexit = NESTED_EXIT_DONE;\n\t\tbreak;\n\t}\n\tcase SVM_EXIT_ERR: {\n\t\tvmexit = NESTED_EXIT_DONE;\n\t\tbreak;\n\t}\n\tdefault: {\n\t\tif (vmcb_is_intercept(&svm->nested.ctl, exit_code))\n\t\t\tvmexit = NESTED_EXIT_DONE;\n\t}\n\t}\n\n\treturn vmexit;\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":259176,"func":"static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n    unsigned int i, entries;\n\n    if (c->trak_index < 0) {\n        av_log(c->fc, AV_LOG_WARNING, \"STCO outside TRAK\\n\");\n        return 0;\n    }\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n    sc = st->priv_data;\n\n    avio_r8(pb); \/* version *\/\n    avio_rb24(pb); \/* flags *\/\n\n    entries = avio_rb32(pb);\n\n    if (!entries)\n        return 0;\n\n    if (sc->chunk_offsets) {\n        av_log(c->fc, AV_LOG_WARNING, \"Ignoring duplicated STCO atom\\n\");\n        return 0;\n    }\n    av_free(sc->chunk_offsets);\n    sc->chunk_count = 0;\n    sc->chunk_offsets = av_malloc_array(entries, sizeof(*sc->chunk_offsets));\n    if (!sc->chunk_offsets)\n        return AVERROR(ENOMEM);\n    sc->chunk_count = entries;\n\n    if      (atom.type == MKTAG('s','t','c','o'))\n        for (i = 0; i < entries && !pb->eof_reached; i++)\n            sc->chunk_offsets[i] = avio_rb32(pb);\n    else if (atom.type == MKTAG('c','o','6','4'))\n        for (i = 0; i < entries && !pb->eof_reached; i++)\n            sc->chunk_offsets[i] = avio_rb64(pb);\n    else\n        return AVERROR_INVALIDDATA;\n\n    sc->chunk_count = i;\n\n    if (pb->eof_reached) {\n        av_log(c->fc, AV_LOG_WARNING, \"reached eof, corrupted STCO atom\\n\");\n        return AVERROR_EOF;\n    }\n\n    return 0;\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":344774,"func":"convtime(const char *s)\n{\n\tlong total, secs, multiplier;\n\tconst char *p;\n\tchar *endp;\n\n\terrno = 0;\n\ttotal = 0;\n\tp = s;\n\n\tif (p == NULL || *p == '\\0')\n\t\treturn -1;\n\n\twhile (*p) {\n\t\tsecs = strtol(p, &endp, 10);\n\t\tif (p == endp ||\n\t\t    (errno == ERANGE && (secs == INT_MIN || secs == INT_MAX)) ||\n\t\t    secs < 0)\n\t\t\treturn -1;\n\n\t\tmultiplier = 1;\n\t\tswitch (*endp++) {\n\t\tcase '\\0':\n\t\t\tendp--;\n\t\t\tbreak;\n\t\tcase 's':\n\t\tcase 'S':\n\t\t\tbreak;\n\t\tcase 'm':\n\t\tcase 'M':\n\t\t\tmultiplier = MINUTES;\n\t\t\tbreak;\n\t\tcase 'h':\n\t\tcase 'H':\n\t\t\tmultiplier = HOURS;\n\t\t\tbreak;\n\t\tcase 'd':\n\t\tcase 'D':\n\t\t\tmultiplier = DAYS;\n\t\t\tbreak;\n\t\tcase 'w':\n\t\tcase 'W':\n\t\t\tmultiplier = WEEKS;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -1;\n\t\t}\n\t\tif (secs > INT_MAX \/ multiplier)\n\t\t\treturn -1;\n\t\tsecs *= multiplier;\n\t\tif  (total > INT_MAX - secs)\n\t\t\treturn -1;\n\t\ttotal += secs;\n\t\tif (total < 0)\n\t\t\treturn -1;\n\t\tp = endp;\n\t}\n\n\treturn total;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":369429,"func":"\nstatic int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)\n{\n\tconst struct io_op_def *def = &io_op_defs[req->opcode];\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct async_poll *apoll;\n\tstruct io_poll_table ipt;\n\t__poll_t mask = EPOLLONESHOT | POLLERR | POLLPRI;\n\tint ret;\n\n\tif (!def->pollin && !def->pollout)\n\t\treturn IO_APOLL_ABORTED;\n\tif (!file_can_poll(req->file) || (req->flags & REQ_F_POLLED))\n\t\treturn IO_APOLL_ABORTED;\n\n\tif (def->pollin) {\n\t\tmask |= POLLIN | POLLRDNORM;\n\n\t\t\/* If reading from MSG_ERRQUEUE using recvmsg, ignore POLLIN *\/\n\t\tif ((req->opcode == IORING_OP_RECVMSG) &&\n\t\t    (req->sr_msg.msg_flags & MSG_ERRQUEUE))\n\t\t\tmask &= ~POLLIN;\n\t} else {\n\t\tmask |= POLLOUT | POLLWRNORM;\n\t}\n\tif (def->poll_exclusive)\n\t\tmask |= EPOLLEXCLUSIVE;\n\tif (!(issue_flags & IO_URING_F_UNLOCKED) &&\n\t    !list_empty(&ctx->apoll_cache)) {\n\t\tapoll = list_first_entry(&ctx->apoll_cache, struct async_poll,\n\t\t\t\t\t\tpoll.wait.entry);\n\t\tlist_del_init(&apoll->poll.wait.entry);\n\t} else {\n\t\tapoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);\n\t\tif (unlikely(!apoll))\n\t\t\treturn IO_APOLL_ABORTED;\n\t}\n\tapoll->double_poll = NULL;\n\treq->apoll = apoll;\n\treq->flags |= REQ_F_POLLED;\n\tipt.pt._qproc = io_async_queue_proc;\n\n\tio_kbuf_recycle(req, issue_flags);\n\n\tret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask);\n\tif (ret || ipt.error)\n\t\treturn ret ? IO_APOLL_READY : IO_APOLL_ABORTED;\n\n\ttrace_io_uring_poll_arm(ctx, req, req->user_data, req->opcode,\n\t\t\t\tmask, apoll->poll.events);\n\treturn IO_APOLL_OK;","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":391662,"func":"static void validate_my_share_entries(struct smbd_server_connection *sconn,\n\t\t\t\t      int num,\n\t\t\t\t      struct share_mode_entry *share_entry)\n{\n\tstruct server_id self = messaging_server_id(sconn->msg_ctx);\n\tfiles_struct *fsp;\n\n\tif (!serverid_equal(&self, &share_entry->pid)) {\n\t\treturn;\n\t}\n\n\tif (!is_valid_share_mode_entry(share_entry)) {\n\t\treturn;\n\t}\n\n\tfsp = file_find_dif(sconn, share_entry->id,\n\t\t\t    share_entry->share_file_id);\n\tif (!fsp) {\n\t\tDEBUG(0,(\"validate_my_share_entries: PANIC : %s\\n\",\n\t\t\t share_mode_str(talloc_tos(), num, share_entry) ));\n\t\tsmb_panic(\"validate_my_share_entries: Cannot match a \"\n\t\t\t  \"share entry with an open file\\n\");\n\t}\n\n\tif (((uint16)fsp->oplock_type) != share_entry->op_type) {\n\t\tgoto panic;\n\t}\n\n\treturn;\n\n panic:\n\t{\n\t\tchar *str;\n\t\tDEBUG(0,(\"validate_my_share_entries: PANIC : %s\\n\",\n\t\t\t share_mode_str(talloc_tos(), num, share_entry) ));\n\t\tstr = talloc_asprintf(talloc_tos(),\n\t\t\t\"validate_my_share_entries: \"\n\t\t\t\"file %s, oplock_type = 0x%x, op_type = 0x%x\\n\",\n\t\t\t fsp->fsp_name->base_name,\n\t\t\t (unsigned int)fsp->oplock_type,\n\t\t\t (unsigned int)share_entry->op_type );\n\t\tsmb_panic(str);\n\t}\n}","target":0,"code_token_length":331,"total_token_length":567,"max_tokens_setting":1024}
+{"idx":514315,"func":"bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List<Item> *fields,\n                        List<Item> *values, COND *conds, ulonglong options,\n                        enum enum_duplicates handle_duplicates,\n                        bool ignore, SELECT_LEX_UNIT *unit,\n                        SELECT_LEX *select_lex, multi_update **result)\n{\n  bool res;\n  DBUG_ENTER(\"mysql_multi_update\");\n\n  if (!(*result= new (thd->mem_root) multi_update(thd, table_list,\n                                 &thd->lex->select_lex.leaf_tables,\n                                 fields, values, handle_duplicates, ignore)))\n  {\n    DBUG_RETURN(TRUE);\n  }\n\n  if ((*result)->init(thd))\n    DBUG_RETURN(1);\n\n  thd->abort_on_warning= !ignore && thd->is_strict_mode();\n  List<Item> total_list;\n\n  if (setup_tables(thd, &select_lex->context, &select_lex->top_join_list,\n                   table_list, select_lex->leaf_tables, FALSE, FALSE))\n    DBUG_RETURN(1);\n\n  if (select_lex->vers_setup_conds(thd, table_list))\n    DBUG_RETURN(1);\n\n  res= mysql_select(thd,\n                    table_list, select_lex->with_wild, total_list, conds,\n                    select_lex->order_list.elements,\n                    select_lex->order_list.first, NULL, NULL, NULL,\n                    options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |\n                    OPTION_SETUP_TABLES_DONE,\n                    *result, unit, select_lex);\n\n  DBUG_PRINT(\"info\",(\"res: %d  report_error: %d\", res, (int) thd->is_error()));\n  res|= thd->is_error();\n  if (unlikely(res))\n    (*result)->abort_result_set();\n  else\n  {\n    if (thd->lex->describe || thd->lex->analyze_stmt)\n      res= thd->lex->explain->send_explain(thd);\n  }\n  thd->abort_on_warning= 0;\n  DBUG_RETURN(res);\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":351177,"func":"static struct DataStruct * build_index (SHPHandle shp, DBFHandle dbf) {\n  struct DataStruct *data = malloc (sizeof *data * nShapes);\n  if (!data) {\n    fputs(\"malloc failed!\\n\", stderr);\n    exit(EXIT_FAILURE);\n  }\n\n  \/* populate array *\/\n  for (int i = 0; i < nShapes; i++) {\n    data[i].value = malloc(sizeof data[0].value[0] * nFields);\n    if (0 == data[i].value) {\n      fputs(\"malloc failed!\\n\", stderr);\n      exit(EXIT_FAILURE);\n    }\n    data[i].record = i;\n    for (int j = 0; j < nFields; j++) {\n      data[i].value[j].null = 0;\n      switch (fldType[j]) {\n      case FIDType:\n\tdata[i].value[j].u.i = i;\n\tbreak;\n      case SHPType:\n       {\n        SHPObject *feat = SHPReadObject(shp, i);\n\tswitch (feat->nSHPType) {\n\tcase SHPT_NULL:\n\t  fprintf(stderr, \"Shape %d is a null feature!\\n\", i);\n\t  data[i].value[j].null = 1;\n\t  break;\n\tcase SHPT_POINT:\n\tcase SHPT_POINTZ:\n\tcase SHPT_POINTM:\n\tcase SHPT_MULTIPOINT:\n\tcase SHPT_MULTIPOINTZ:\n\tcase SHPT_MULTIPOINTM:\n\tcase SHPT_MULTIPATCH:\n\t  \/* Y-sort bounds *\/\n\t  data[i].value[j].u.d = feat->dfYMax;\n\t  break;\n\tcase SHPT_ARC:\n\tcase SHPT_ARCZ:\n\tcase SHPT_ARCM:\n\t  data[i].value[j].u.d = shp_length(feat);\n\t  break;\n\tcase SHPT_POLYGON:\n\tcase SHPT_POLYGONZ:\n\tcase SHPT_POLYGONM:\n\t  data[i].value[j].u.d = shp_area(feat);\n\t  break;\n\tdefault:\n\t  fputs(\"Can't sort on Shapefile feature type!\\n\", stderr);\n\t  exit(EXIT_FAILURE);\n\t}\n\tSHPDestroyObject(feat);\n\tbreak;\n       }\n      case FTString:\n\tdata[i].value[j].null = DBFIsAttributeNULL(dbf, i, fldIdx[j]);\n\tif (!data[i].value[j].null) {\n\t  data[i].value[j].u.s = dupstr(DBFReadStringAttribute(dbf, i, fldIdx[j]));\n\t}\n\tbreak;\n      case FTInteger:\n      case FTLogical:\n\tdata[i].value[j].null = DBFIsAttributeNULL(dbf, i, fldIdx[j]);\n\tif (!data[i].value[j].null) {\n\t  data[i].value[j].u.i  = DBFReadIntegerAttribute(dbf, i, fldIdx[j]);\n\t}\n\tbreak;\n      case FTDouble:\n\tdata[i].value[j].null = DBFIsAttributeNULL(dbf, i, fldIdx[j]);\n\tif (!data[i].value[j].null) {\n\t  data[i].value[j].u.d = DBFReadDoubleAttribute(dbf, i, fldIdx[j]);\n\t}\n\tbreak;\n      }\n    }\n  }\n\n#ifdef DEBUG\n  PrintDataStruct(data);\n  fputs(\"build_index: sorting array\\n\", stdout);\n#endif\n\n  qsort (data, nShapes, sizeof data[0], compare);\n\n#ifdef DEBUG\n  PrintDataStruct(data);\n  fputs(\"build_index: returning array\\n\", stdout);\n#endif\n\n  return data;\n}","target":0,"code_token_length":726,"total_token_length":962,"max_tokens_setting":1024}
+{"idx":204278,"func":"static void build_dirs(char *src, char *dst, size_t src_prefix_len, size_t dst_prefix_len) {\n\tchar *p = src + src_prefix_len + 1;\n\tchar *q = dst + dst_prefix_len + 1;\n\tchar *r = dst + dst_prefix_len;\n\tstruct stat s;\n\tbool last = false;\n\t*r = '\\0';\n\tfor (; !last; p++, q++) {\n\t\tif (*p == '\\0') {\n\t\t\tlast = true;\n\t\t}\n\t\tif (*p == '\\0' || (*p == '\/' && *(p - 1) != '\/')) {\n\t\t\t\/\/ We found a new component of our src path.\n\t\t\t\/\/ Null-terminate it temporarily here so that we can work\n\t\t\t\/\/ with it.\n\t\t\t*p = '\\0';\n\t\t\tif (stat(src, &s) == 0 && S_ISDIR(s.st_mode)) {\n\t\t\t\t\/\/ Null-terminate the dst path and undo its previous\n\t\t\t\t\/\/ termination.\n\t\t\t\t*q = '\\0';\n\t\t\t\t*r = '\/';\n\t\t\t\tr = q;\n\t\t\t\tmkdir_attr(dst, s.st_mode, 0, 0);\n\t\t\t}\n\t\t\tif (!last) {\n\t\t\t\t\/\/ If we're not at the final terminating null, restore\n\t\t\t\t\/\/ the slash so that we can continue our traversal.\n\t\t\t\t*p = '\/';\n\t\t\t}\n\t\t}\n\t}\n}","target":1,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":318958,"func":"test_gui_drop_files(dict_T *args UNUSED)\n{\n#  if defined(HAVE_DROP_FILE)\n    int\t\trow;\n    int\t\tcol;\n    int_u\tmods;\n    char_u\t**fnames;\n    int\t\tcount = 0;\n    typval_T\tt;\n    list_T\t*l;\n    listitem_T\t*li;\n\n    if (dict_find(args, (char_u *)\"files\", -1) == NULL\n\t    || dict_find(args, (char_u *)\"row\", -1) == NULL\n\t    || dict_find(args, (char_u *)\"col\", -1) == NULL\n\t    || dict_find(args, (char_u *)\"modifiers\", -1) == NULL)\n\treturn FALSE;\n\n    (void)dict_get_tv(args, (char_u *)\"files\", &t);\n    row = (int)dict_get_number(args, (char_u *)\"row\");\n    col = (int)dict_get_number(args, (char_u *)\"col\");\n    mods = (int)dict_get_number(args, (char_u *)\"modifiers\");\n\n    if (t.v_type != VAR_LIST || list_len(t.vval.v_list) == 0)\n\treturn FALSE;\n\n    l = t.vval.v_list;\n    fnames = ALLOC_MULT(char_u *, list_len(l));\n    if (fnames == NULL)\n\treturn FALSE;\n\n    FOR_ALL_LIST_ITEMS(l, li)\n    {\n\t\/\/ ignore non-string items\n\tif (li->li_tv.v_type != VAR_STRING\n\t\t|| li->li_tv.vval.v_string == NULL)\n\t    continue;\n\n\tfnames[count] = vim_strsave(li->li_tv.vval.v_string);\n\tif (fnames[count] == NULL)\n\t{\n\t    while (--count >= 0)\n\t\tvim_free(fnames[count]);\n\t    vim_free(fnames);\n\t    return FALSE;\n\t}\n\tcount++;\n    }\n\n    if (count > 0)\n\tgui_handle_drop(TEXT_X(col - 1), TEXT_Y(row - 1), mods, fnames, count);\n    else\n\tvim_free(fnames);\n#  endif\n\n    return TRUE;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":353185,"func":"void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state,\n\t\t\t\t\t       Object *ref, Stream *str,\n\t\t\t\t\t       int width, int height,\n\t\t\t\t\t       bool invert,\n\t\t\t\t\t       bool inlineImg, double *baseMatrix) {\n  const double *ctm;\n  SplashCoord mat[6];\n  SplashOutImageMaskData imgMaskData;\n  Splash *maskSplash;\n  SplashColor maskColor;\n  double bbox[4] = {0, 0, 1, 1}; \/\/ default;\n\n  if (state->getFillColorSpace()->isNonMarking()) {\n    return;\n  }\n\n  ctm = state->getCTM();\n  for (int i = 0; i < 6; ++i) {\n    if (!std::isfinite(ctm[i])) return;\n  }\n  \n  beginTransparencyGroup(state, bbox, nullptr, false, false, false);\n  baseMatrix[4] -= transpGroupStack->tx;\n  baseMatrix[5] -= transpGroupStack->ty;\n\n  ctm = state->getCTM();\n  mat[0] = ctm[0];\n  mat[1] = ctm[1];\n  mat[2] = -ctm[2];\n  mat[3] = -ctm[3];\n  mat[4] = ctm[2] + ctm[4];\n  mat[5] = ctm[3] + ctm[5];\n  imgMaskData.imgStr = new ImageStream(str, width, 1, 1);\n  imgMaskData.imgStr->reset();\n  imgMaskData.invert = invert ? 0 : 1;\n  imgMaskData.width = width;\n  imgMaskData.height = height;\n  imgMaskData.y = 0;\n\n  transpGroupStack->softmask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), 1, splashModeMono8, false);\n  maskSplash = new Splash(transpGroupStack->softmask, vectorAntialias);\n  maskColor[0] = 0;\n  maskSplash->clear(maskColor);\n  maskColor[0] = 0xff;\n  maskSplash->setFillPattern(new SplashSolidColor(maskColor));\n  maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData,  width, height, mat, t3GlyphStack != nullptr);\n  delete maskSplash;\n  delete imgMaskData.imgStr;\n  str->close();\n}","target":0,"code_token_length":515,"total_token_length":751,"max_tokens_setting":1024}
+{"idx":352963,"func":"firstComponentNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tint rc;\n\tstruct berval comp;\n\tber_len_t len;\n\n\tif( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage )) {\n\t\tber_dupbv_x( normalized, val, ctx );\n\t\treturn LDAP_SUCCESS;\n\t}\n\n\tif( val->bv_len < 3 ) return LDAP_INVALID_SYNTAX;\n\n\tif( ! ( val->bv_val[0] == '(' \/*')'*\/\n\t\t\t&& val->bv_val[val->bv_len - 1] == \/*'('*\/ ')' )\n\t\t&& ! ( val->bv_val[0] == '{' \/*'}'*\/\n\t\t\t&& val->bv_val[val->bv_len - 1] == \/*'('*\/ '}' ) )\n\t{\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* trim leading white space *\/\n\tfor( len=1;\n\t\tlen < val->bv_len && ASCII_SPACE(val->bv_val[len]);\n\t\tlen++ )\n\t{\n\t\t\/* empty *\/\n\t}\n\n\t\/* grab next word *\/\n\tcomp.bv_val = &val->bv_val[len];\n\tlen = val->bv_len - len - STRLENOF(\/*\"{\"*\/ \"}\");\n\tfor( comp.bv_len = 0;\n\t\t!ASCII_SPACE(comp.bv_val[comp.bv_len]) && comp.bv_len < len;\n\t\tcomp.bv_len++ )\n\t{\n\t\t\/* empty *\/\n\t}\n\n\tif( mr == slap_schema.si_mr_objectIdentifierFirstComponentMatch ) {\n\t\trc = numericoidValidate( NULL, &comp );\n\t} else if( mr == slap_schema.si_mr_integerFirstComponentMatch ) {\n\t\trc = integerValidate( NULL, &comp );\n\t} else {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t}\n\t\n\n\tif( rc == LDAP_SUCCESS ) {\n\t\tber_dupbv_x( normalized, &comp, ctx );\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":425,"total_token_length":661,"max_tokens_setting":1024}
+{"idx":386605,"func":"bool DL_Dxf::handleXRecordData(DL_CreationInterface* creationInterface) {\n    if (groupCode==105) {\n        return false;\n    }\n\n    if (groupCode==5) {\n        creationInterface->addXRecord(groupValue);\n        return true;\n    }\n\n    if (groupCode==280) {\n        xRecordValues = true;\n        return true;\n    }\n\n    if (!xRecordValues) {\n        return false;\n    }\n\n    \/\/ string:\n    if (groupCode<=9 ||\n        groupCode==100 || groupCode==102 || groupCode==105 ||\n        (groupCode>=300 && groupCode<=369) ||\n        (groupCode>=1000 && groupCode<=1009)) {\n\n        creationInterface->addXRecordString(groupCode, groupValue);\n        return true;\n    }\n\n    \/\/ int:\n    else if ((groupCode>=60 && groupCode<=99) || (groupCode>=160 && groupCode<=179) || (groupCode>=270 && groupCode<=289)) {\n        creationInterface->addXRecordInt(groupCode, toInt(groupValue));\n        return true;\n    }\n\n    \/\/ bool:\n    else if (groupCode>=290 && groupCode<=299) {\n        creationInterface->addXRecordBool(groupCode, toBool(groupValue));\n        return true;\n    }\n\n    \/\/ double:\n    else if ((groupCode>=10 && groupCode<=59) || (groupCode>=110 && groupCode<=149) || (groupCode>=210 && groupCode<=239)) {\n        creationInterface->addXRecordReal(groupCode, toReal(groupValue));\n        return true;\n    }\n\n    return false;\n}","target":0,"code_token_length":389,"total_token_length":625,"max_tokens_setting":1024}
+{"idx":462403,"func":"sessActivity(ptcpsess_t *pSess, int *continue_polling)\n{\n\tint lenRcv;\n\tint lenBuf;\n\tuchar *peerName;\n\tint lenPeer;\n\tint remsock = 0; \/* init just to keep compiler happy... :-( *\/\n\tsbool bEmitOnClose = 0;\n\tchar rcvBuf[128*1024];\n\tDEFiRet;\n\n\tDBGPRINTF(\"imptcp: new activity on session socket %d\\n\", pSess->sock);\n\n\twhile(1) {\n\t\tlenBuf = sizeof(rcvBuf);\n\t\tlenRcv = recv(pSess->sock, rcvBuf, lenBuf, 0);\n\n\t\tif(lenRcv > 0) {\n\t\t\t\/* have data, process it *\/\n\t\t\tDBGPRINTF(\"imptcp: data(%d) on socket %d: %s\\n\", lenBuf, pSess->sock, rcvBuf);\n\t\t\tCHKiRet(DataRcvd(pSess, rcvBuf, lenRcv));\n\t\t} else if (lenRcv == 0) {\n\t\t\t\/* session was closed, do clean-up *\/\n\t\t\tif(pSess->pLstn->pSrv->bEmitMsgOnClose) {\n\t\t\t\tprop.GetString(pSess->peerName, &peerName, &lenPeer),\n\t\t\t\tremsock = pSess->sock;\n\t\t\t\tbEmitOnClose = 1;\n\t\t\t}\n\t\t\t*continue_polling = 0;\n\t\t\tCHKiRet(closeSess(pSess)); \/* close may emit more messages in strmzip mode! *\/\n\t\t\tif(bEmitOnClose) {\n\t\t\t\terrmsg.LogError(0, RS_RET_PEER_CLOSED_CONN, \"imptcp session %d closed by \"\n\t\t\t\t\t  \t\"remote peer %s.\", remsock, peerName);\n\t\t\t}\n\t\t\tbreak;\n\t\t} else {\n\t\t\tif(errno == EAGAIN || errno == EWOULDBLOCK)\n\t\t\t\tbreak;\n\t\t\tDBGPRINTF(\"imptcp: error on session socket %d - closed.\\n\", pSess->sock);\n\t\t\t*continue_polling = 0;\n\t\t\tcloseSess(pSess); \/* try clean-up by dropping session *\/\n\t\t\tbreak;\n\t\t}\n\t}\n\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":483,"total_token_length":719,"max_tokens_setting":1024}
+{"idx":349871,"func":"int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a,\n\t\t\t\t  u32 *p, u32 cnt)\n{\n\tint err = 0;\n\tu32 val;\n\n\terr = readx_poll_timeout_atomic(hw_atl_sem_ram_get,\n\t\t\t\t\tself, val, val == 1U,\n\t\t\t\t\t1U, 10000U);\n\n\tif (err < 0) {\n\t\tbool is_locked;\n\n\t\thw_atl_reg_glb_cpu_sem_set(self, 1U, HW_ATL_FW_SM_RAM);\n\t\tis_locked = hw_atl_sem_ram_get(self);\n\t\tif (!is_locked) {\n\t\t\terr = -ETIME;\n\t\t\tgoto err_exit;\n\t\t}\n\t}\n\n\taq_hw_write_reg(self, HW_ATL_MIF_ADDR, a);\n\n\tfor (++cnt; --cnt && !err;) {\n\t\taq_hw_write_reg(self, HW_ATL_MIF_CMD, 0x00008000U);\n\n\t\tif (ATL_HW_IS_CHIP_FEATURE(self, REVISION_B1))\n\t\t\terr = readx_poll_timeout_atomic(hw_atl_utils_mif_addr_get,\n\t\t\t\t\t\t\tself, val, val != a,\n\t\t\t\t\t\t\t1U, 1000U);\n\t\telse\n\t\t\terr = readx_poll_timeout_atomic(hw_atl_utils_mif_cmd_get,\n\t\t\t\t\t\t\tself, val,\n\t\t\t\t\t\t\t!(val & 0x100),\n\t\t\t\t\t\t\t1U, 1000U);\n\n\t\t*(p++) = aq_hw_read_reg(self, HW_ATL_MIF_VAL);\n\t\ta += 4;\n\t}\n\n\thw_atl_reg_glb_cpu_sem_set(self, 1U, HW_ATL_FW_SM_RAM);\n\nerr_exit:\n\treturn err;\n}","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":427709,"func":"cdf_read_short_sector_chain(const cdf_header_t *h,\n    const cdf_sat_t *ssat, const cdf_stream_t *sst,\n    cdf_secid_t sid, size_t len, cdf_stream_t *scn)\n{\n\tsize_t ss = CDF_SHORT_SEC_SIZE(h), i, j;\n\tscn->sst_tab = NULL;\n\tscn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));\n\tscn->sst_dirlen = len;\n\tscn->sst_ss = ss;\n\n\tif (scn->sst_len == CAST(size_t, -1))\n\t\tgoto out;\n\n\tscn->sst_tab = CDF_CALLOC(scn->sst_len, ss);\n\tif (scn->sst_tab == NULL)\n\t\treturn cdf_zero_stream(scn);\n\n\tfor (j = i = 0; sid >= 0; i++, j++) {\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Read short sector chain loop limit\"));\n\t\t\tgoto out;\n\t\t}\n\t\tif (i >= scn->sst_len) {\n\t\t\tDPRINTF((\"Out of bounds reading short sector chain \"\n\t\t\t    \"%\" SIZE_T_FORMAT \"u > %\" SIZE_T_FORMAT \"u\\n\",\n\t\t\t    i, scn->sst_len));\n\t\t\tgoto out;\n\t\t}\n\t\tif (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,\n\t\t    sid) != CAST(ssize_t, ss)) {\n\t\t\tDPRINTF((\"Reading short sector chain %d\", sid));\n\t\t\tgoto out;\n\t\t}\n\t\tsid = CDF_TOLE4(CAST(uint32_t, ssat->sat_tab[sid]));\n\t}\n\treturn 0;\nout:\n\terrno = EFTYPE;\n\treturn cdf_zero_stream(scn);\n}","target":0,"code_token_length":375,"total_token_length":611,"max_tokens_setting":1024}
+{"idx":218969,"func":"bool ConstantFolding::IsReductionCandidateForSimplification(\n    const NodeDef& node, const GraphProperties& properties,\n    TensorShapeProto* input_tensor_shape, TensorShapeProto* output_tensor_shape,\n    bool* is_single_element_op) const {\n  \/\/ Get the properties of the input & output tensors and check if they both\n  \/\/ contain a single element.\n  if (!properties.HasInputProperties(node.name()) ||\n      !properties.HasOutputProperties(node.name())) {\n    return false;\n  }\n  const auto& input_props = properties.GetInputProperties(node.name())[0];\n  const auto& output_props = properties.GetOutputProperties(node.name())[0];\n  if (!input_props.has_shape() || input_props.shape().unknown_rank() ||\n      !output_props.has_shape() || output_props.shape().unknown_rank()) {\n    return false;\n  }\n  *input_tensor_shape = input_props.shape();\n  *output_tensor_shape = output_props.shape();\n  for (int i = 0; i < input_tensor_shape->dim_size(); ++i) {\n    if (input_tensor_shape->dim(i).size() < 0) {\n      return false;\n    }\n  }\n  for (int i = 0; i < output_tensor_shape->dim_size(); ++i) {\n    if (output_tensor_shape->dim(i).size() < 0) {\n      return false;\n    }\n  }\n  const int input_num_elements =\n      TensorShape(*input_tensor_shape).num_elements();\n  const int output_num_elements =\n      TensorShape(*output_tensor_shape).num_elements();\n  *is_single_element_op = input_num_elements == 1 && output_num_elements == 1;\n\n  return true;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":386568,"func":"void DL_Dxf::writeAttribute(DL_WriterA& dw,\n                   const DL_AttributeData& data,\n                   const DL_Attributes& attrib) {\n\n    dw.entity(\"ATTRIB\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbText\");\n    }\n    dw.dxfReal(10, data.ipx);\n    dw.dxfReal(20, data.ipy);\n    dw.dxfReal(30, data.ipz);\n    dw.dxfReal(40, data.height);\n    dw.dxfString(1, data.text);\n    dw.dxfReal(50, data.angle\/(2*M_PI)*360.0);\n    dw.dxfReal(41, data.xScaleFactor);\n    dw.dxfString(7, data.style);\n\n    dw.dxfInt(71, data.textGenerationFlags);\n    dw.dxfInt(72, data.hJustification);\n\n    dw.dxfReal(11, data.apx);\n    dw.dxfReal(21, data.apy);\n    dw.dxfReal(31, data.apz);\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbAttribute\");\n    }\n\n    dw.dxfString(2, data.tag);\n    dw.dxfInt(74, data.vJustification);\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":381861,"func":"int udf_setsize(struct inode *inode, loff_t newsize)\n{\n\tint err;\n\tstruct udf_inode_info *iinfo;\n\tunsigned int bsize = i_blocksize(inode);\n\n\tif (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||\n\t      S_ISLNK(inode->i_mode)))\n\t\treturn -EINVAL;\n\tif (IS_APPEND(inode) || IS_IMMUTABLE(inode))\n\t\treturn -EPERM;\n\n\tiinfo = UDF_I(inode);\n\tif (newsize > inode->i_size) {\n\t\tdown_write(&iinfo->i_data_sem);\n\t\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {\n\t\t\tif (bsize <\n\t\t\t    (udf_file_entry_alloc_offset(inode) + newsize)) {\n\t\t\t\terr = udf_expand_file_adinicb(inode);\n\t\t\t\tif (err)\n\t\t\t\t\treturn err;\n\t\t\t\tdown_write(&iinfo->i_data_sem);\n\t\t\t} else {\n\t\t\t\tiinfo->i_lenAlloc = newsize;\n\t\t\t\tgoto set_size;\n\t\t\t}\n\t\t}\n\t\terr = udf_extend_file(inode, newsize);\n\t\tif (err) {\n\t\t\tup_write(&iinfo->i_data_sem);\n\t\t\treturn err;\n\t\t}\nset_size:\n\t\tup_write(&iinfo->i_data_sem);\n\t\ttruncate_setsize(inode, newsize);\n\t} else {\n\t\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {\n\t\t\tdown_write(&iinfo->i_data_sem);\n\t\t\tudf_clear_extent_cache(inode);\n\t\t\tmemset(iinfo->i_data + iinfo->i_lenEAttr + newsize,\n\t\t\t       0x00, bsize - newsize -\n\t\t\t       udf_file_entry_alloc_offset(inode));\n\t\t\tiinfo->i_lenAlloc = newsize;\n\t\t\ttruncate_setsize(inode, newsize);\n\t\t\tup_write(&iinfo->i_data_sem);\n\t\t\tgoto update_time;\n\t\t}\n\t\terr = block_truncate_page(inode->i_mapping, newsize,\n\t\t\t\t\t  udf_get_block);\n\t\tif (err)\n\t\t\treturn err;\n\t\ttruncate_setsize(inode, newsize);\n\t\tdown_write(&iinfo->i_data_sem);\n\t\tudf_clear_extent_cache(inode);\n\t\terr = udf_truncate_extents(inode);\n\t\tup_write(&iinfo->i_data_sem);\n\t\tif (err)\n\t\t\treturn err;\n\t}\nupdate_time:\n\tinode->i_mtime = inode->i_ctime = current_time(inode);\n\tif (IS_SYNC(inode))\n\t\tudf_sync_inode(inode);\n\telse\n\t\tmark_inode_dirty(inode);\n\treturn 0;\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":229330,"func":"Status EagerExecute(EagerOperation* op, TensorHandle** retvals,\n                    int* num_retvals) {\n  profiler::TraceMe activity([&] {\n    return ::tensorflow::profiler::TraceMeEncode(\n        \"EagerExecute\",\n        {{\"eager_op\", op->Name()}, {\"is_func\", op->is_function()}});\n  });\n\n  if (!op->Executor().Async()) {\n    VLOG(6) << \"op: \" << op->Name() << \" is not Async.\";\n    if (!op->EagerContext()\n             .GetGlobalRendezvousForFunctionLocalRendezvousStatus()\n             .ok()) {\n      VLOG(6) << \"global_rendezvous_for_functions_ is in bad state. Resetting.\";\n      op->EagerContext().ResetGlobalRendezvousForFunction();\n    }\n    \/\/ In sync mode, always clear error to maintain the same behavior as before.\n    \/\/ TODO(b\/141004939): Remove this.\n    op->Executor().ClearError();\n  }\n\n  std::unique_ptr<tensorflow::EagerOperation> out_op;\n  TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite(\n      EagerOpRewriteRegistry::PRE_EXECUTION, op, &out_op));\n\n  if (op->IsLocal()) {\n    if (out_op) {\n      op = out_op.get();\n    }\n    TF_RETURN_IF_ERROR(MaybePackInputTensor(op));\n    return EagerLocalExecute(op, retvals, num_retvals);\n  }\n\n#if defined(IS_MOBILE_PLATFORM)\n  return errors::Unimplemented(\n      \"Eager's remote execution is not available on mobile devices.\");\n#else   \/\/ !IS_MOBILE_PLATFORM\n  if (out_op) {\n    op = out_op.get();\n  }\n  return EagerRemoteExecute(op, retvals, num_retvals);\n#endif  \/\/ !IS_MOBILE_PLATFORM\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":446060,"func":"TIFFInitLZW(TIFF* tif, int scheme)\n{\n\tstatic const char module[] = \"TIFFInitLZW\";\n\tassert(scheme == COMPRESSION_LZW);\n\t\/*\n\t * Allocate state block so tag methods have storage to record values.\n\t *\/\n\ttif->tif_data = (uint8*) _TIFFmalloc(sizeof (LZWCodecState));\n\tif (tif->tif_data == NULL)\n\t\tgoto bad;\n\tDecoderState(tif)->dec_codetab = NULL;\n\tDecoderState(tif)->dec_decode = NULL;\n\tEncoderState(tif)->enc_hashtab = NULL;\n        LZWState(tif)->rw_mode = tif->tif_mode;\n\n\t\/*\n\t * Install codec methods.\n\t *\/\n\ttif->tif_fixuptags = LZWFixupTags; \n\ttif->tif_setupdecode = LZWSetupDecode;\n\ttif->tif_predecode = LZWPreDecode;\n\ttif->tif_decoderow = LZWDecode;\n\ttif->tif_decodestrip = LZWDecode;\n\ttif->tif_decodetile = LZWDecode;\n\ttif->tif_setupencode = LZWSetupEncode;\n\ttif->tif_preencode = LZWPreEncode;\n\ttif->tif_postencode = LZWPostEncode;\n\ttif->tif_encoderow = LZWEncode;\n\ttif->tif_encodestrip = LZWEncode;\n\ttif->tif_encodetile = LZWEncode;\n\ttif->tif_cleanup = LZWCleanup;\n\t\/*\n\t * Setup predictor setup.\n\t *\/\n\t(void) TIFFPredictorInit(tif);\n\treturn (1);\nbad:\n\tTIFFErrorExt(tif->tif_clientdata, module, \n\t\t     \"No space for LZW state block\");\n\treturn (0);\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":197748,"func":"Status TransposeShapeFn(InferenceContext* c) {\n  ShapeHandle input = c->input(0);\n  ShapeHandle perm_shape = c->input(1);\n  const Tensor* perm = c->input_tensor(1);\n  DimensionHandle perm_elems = c->NumElements(perm_shape);\n  \/\/ If we don't have rank information on the input or value information on\n  \/\/ perm we can't return any shape information, otherwise we have enough\n  \/\/ information to at least find the rank of the output.\n  if (!c->RankKnown(input) && !c->ValueKnown(perm_elems) && perm == nullptr) {\n    c->set_output(0, c->UnknownShape());\n    return Status::OK();\n  }\n\n  \/\/ Find our value of the rank.\n  int64_t rank;\n  if (c->RankKnown(input)) {\n    rank = c->Rank(input);\n  } else if (c->ValueKnown(perm_elems)) {\n    rank = c->Value(perm_elems);\n  } else {\n    rank = perm->NumElements();\n  }\n  if (!c->RankKnown(input) && rank < 2) {\n    \/\/ A permutation array containing a single element is ambiguous. It could\n    \/\/ indicate either a scalar or a 1-dimensional array, both of which the\n    \/\/ transpose op returns unchanged.\n    c->set_output(0, input);\n    return Status::OK();\n  }\n\n  std::vector<DimensionHandle> dims;\n  dims.resize(rank);\n  TF_RETURN_IF_ERROR(c->WithRank(input, rank, &input));\n  \/\/ Ensure that perm is a vector and has rank elements.\n  TF_RETURN_IF_ERROR(c->WithRank(perm_shape, 1, &perm_shape));\n  TF_RETURN_IF_ERROR(c->WithValue(perm_elems, rank, &perm_elems));\n\n  \/\/ If we know the rank of the input and the value of perm, we can return\n  \/\/ all shape information, otherwise we can only return rank information,\n  \/\/ but no information for the dimensions.\n  if (perm != nullptr) {\n    std::vector<int64_t> data;\n    if (perm->dtype() == DT_INT32) {\n      data = AsInt64<int32>(perm, rank);\n    } else {\n      data = AsInt64<int64_t>(perm, rank);\n    }\n\n    for (int32_t i = 0; i < rank; ++i) {\n      int64_t in_idx = data[i];\n      if (in_idx >= rank) {\n        return errors::InvalidArgument(\"perm dim \", in_idx,\n                                       \" is out of range of input rank \", rank);\n      }\n      dims[i] = c->Dim(input, in_idx);\n    }\n  } else {\n    for (int i = 0; i < rank; ++i) {\n      dims[i] = c->UnknownDim();\n    }\n  }\n\n  c->set_output(0, c->MakeShape(dims));\n  return Status::OK();\n}","target":1,"code_token_length":634,"total_token_length":870,"max_tokens_setting":1024}
+{"idx":234822,"func":"static void btrfs_close_one_device(struct btrfs_device *device)\n{\n\tstruct btrfs_fs_devices *fs_devices = device->fs_devices;\n\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&\n\t    device->devid != BTRFS_DEV_REPLACE_DEVID) {\n\t\tlist_del_init(&device->dev_alloc_list);\n\t\tfs_devices->rw_devices--;\n\t}\n\n\tif (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))\n\t\tfs_devices->missing_devices--;\n\n\tbtrfs_close_bdev(device);\n\tif (device->bdev) {\n\t\tfs_devices->open_devices--;\n\t\tdevice->bdev = NULL;\n\t}\n\tclear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);\n\tbtrfs_destroy_dev_zone_info(device);\n\n\tdevice->fs_info = NULL;\n\tatomic_set(&device->dev_stats_ccnt, 0);\n\textent_io_tree_release(&device->alloc_state);\n\n\t\/* Verify the device is back in a pristine state  *\/\n\tASSERT(!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state));\n\tASSERT(!test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state));\n\tASSERT(list_empty(&device->dev_alloc_list));\n\tASSERT(list_empty(&device->post_commit_list));\n\tASSERT(atomic_read(&device->reada_in_flight) == 0);\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":310182,"func":"immedhook(ENTRY * ep GCC_UNUSED)\n\/* write out entries with no use capabilities immediately to save storage *\/\n{\n#if !HAVE_BIG_CORE\n    \/*\n     * This is strictly a core-economy kluge.  The really clean way to handle\n     * compilation is to slurp the whole file into core and then do all the\n     * name-collision checks and entry writes in one swell foop.  But the\n     * terminfo master file is large enough that some core-poor systems swap\n     * like crazy when you compile it this way...there have been reports of\n     * this process taking *three hours*, rather than the twenty seconds or\n     * less typical on my development box.\n     *\n     * So.  This hook *immediately* writes out the referenced entry if it\n     * has no use capabilities.  The compiler main loop refrains from\n     * adding the entry to the in-core list when this hook fires.  If some\n     * other entry later needs to reference an entry that got written\n     * immediately, that's OK; the resolution code will fetch it off disk\n     * when it can't find it in core.\n     *\n     * Name collisions will still be detected, just not as cleanly.  The\n     * write_entry() code complains before overwriting an entry that\n     * postdates the time of tic's first call to write_entry().  Thus\n     * it will complain about overwriting entries newly made during the\n     * tic run, but not about overwriting ones that predate it.\n     *\n     * The reason this is a hook, and not in line with the rest of the\n     * compiler code, is that the support for termcap fallback cannot assume\n     * it has anywhere to spool out these entries!\n     *\n     * The _nc_set_type() call here requires a compensating one in\n     * _nc_parse_entry().\n     *\n     * If you define HAVE_BIG_CORE, you'll disable this kluge.  This will\n     * make tic a bit faster (because the resolution code won't have to do\n     * disk I\/O nearly as often).\n     *\/\n    if (ep->nuses == 0) {\n\tint oldline = _nc_curr_line;\n\n\twrite_it(ep);\n\t_nc_curr_line = oldline;\n\tfree(ep->tterm.str_table);\n\treturn (TRUE);\n    }\n#endif \/* HAVE_BIG_CORE *\/\n    return (FALSE);\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":489148,"func":"sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\t\tvoid *arg,\n\t\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_transport *transport = (struct sctp_transport *) arg;\n\n\tif (asoc->overall_error_count > asoc->max_retrans) {\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,\n\t\t\t\tSCTP_ERROR(ETIMEDOUT));\n\t\t\/* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. *\/\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,\n\t\t\t\tSCTP_PERR(SCTP_ERROR_NO_ERROR));\n\t\tSCTP_INC_STATS(SCTP_MIB_ABORTEDS);\n\t\tSCTP_DEC_STATS(SCTP_MIB_CURRESTAB);\n\t\treturn SCTP_DISPOSITION_DELETE_TCB;\n\t}\n\n\t\/* Section 3.3.5.\n\t * The Sender-specific Heartbeat Info field should normally include\n\t * information about the sender's current time when this HEARTBEAT\n\t * chunk is sent and the destination transport address to which this\n\t * HEARTBEAT is sent (see Section 8.3).\n\t *\/\n\n\tif (transport->param_flags & SPP_HB_ENABLE) {\n\t\tif (SCTP_DISPOSITION_NOMEM ==\n\t\t\t\tsctp_sf_heartbeat(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands))\n\t\t\treturn SCTP_DISPOSITION_NOMEM;\n\t\t\/* Set transport error counter and association error counter\n\t\t * when sending heartbeat.\n\t\t *\/\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_TRANSPORT_RESET,\n\t\t\t\tSCTP_TRANSPORT(transport));\n\t}\n\tsctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMER_UPDATE,\n\t\t\tSCTP_TRANSPORT(transport));\n\n\treturn SCTP_DISPOSITION_CONSUME;\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":344231,"func":"void luaV_finishOp (lua_State *L) {\n  CallInfo *ci = L->ci;\n  StkId base = ci->func + 1;\n  Instruction inst = *(ci->u.l.savedpc - 1);  \/* interrupted instruction *\/\n  OpCode op = GET_OPCODE(inst);\n  switch (op) {  \/* finish its execution *\/\n    case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: {\n      setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top);\n      break;\n    }\n    case OP_UNM: case OP_BNOT: case OP_LEN:\n    case OP_GETTABUP: case OP_GETTABLE: case OP_GETI:\n    case OP_GETFIELD: case OP_SELF: {\n      setobjs2s(L, base + GETARG_A(inst), --L->top);\n      break;\n    }\n    case OP_LT: case OP_LE:\n    case OP_LTI: case OP_LEI:\n    case OP_GTI: case OP_GEI:\n    case OP_EQ: {  \/* note that 'OP_EQI'\/'OP_EQK' cannot yield *\/\n      int res = !l_isfalse(s2v(L->top - 1));\n      L->top--;\n#if defined(LUA_COMPAT_LT_LE)\n      if (ci->callstatus & CIST_LEQ) {  \/* \"<=\" using \"<\" instead? *\/\n        ci->callstatus ^= CIST_LEQ;  \/* clear mark *\/\n        res = !res;  \/* negate result *\/\n      }\n#endif\n      lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);\n      if (res != GETARG_k(inst))  \/* condition failed? *\/\n        ci->u.l.savedpc++;  \/* skip jump instruction *\/\n      break;\n    }\n    case OP_CONCAT: {\n      StkId top = L->top - 1;  \/* top when 'luaT_tryconcatTM' was called *\/\n      int a = GETARG_A(inst);      \/* first element to concatenate *\/\n      int total = cast_int(top - 1 - (base + a));  \/* yet to concatenate *\/\n      setobjs2s(L, top - 2, top);  \/* put TM result in proper position *\/\n      L->top = top - 1;  \/* top is one after last element (at top-2) *\/\n      luaV_concat(L, total);  \/* concat them (may yield again) *\/\n      break;\n    }\n    case OP_CLOSE: {  \/* yielded closing variables *\/\n      ci->u.l.savedpc--;  \/* repeat instruction to close other vars. *\/\n      break;\n    }\n    case OP_RETURN: {  \/* yielded closing variables *\/\n      StkId ra = base + GETARG_A(inst);\n      \/* adjust top to signal correct number of returns, in case the\n         return is \"up to top\" ('isIT') *\/\n      L->top = ra + ci->u2.nres;\n      \/* repeat instruction to close other vars. and complete the return *\/\n      ci->u.l.savedpc--;\n      break;\n    }\n    default: {\n      \/* only these other opcodes can yield *\/\n      lua_assert(op == OP_TFORCALL || op == OP_CALL ||\n           op == OP_TAILCALL || op == OP_SETTABUP || op == OP_SETTABLE ||\n           op == OP_SETI || op == OP_SETFIELD);\n      break;\n    }\n  }\n}","target":0,"code_token_length":731,"total_token_length":967,"max_tokens_setting":1024}
+{"idx":391638,"func":"static NTSTATUS fcb_or_dos_open(struct smb_request *req,\n\t\t\t\tconnection_struct *conn,\n\t\t\t\tfiles_struct *fsp_to_dup_into,\n\t\t\t\tconst struct smb_filename *smb_fname,\n\t\t\t\tstruct file_id id,\n\t\t\t\tuint16 file_pid,\n\t\t\t\tuint64_t vuid,\n\t\t\t\tuint32 access_mask,\n\t\t\t\tuint32 share_access,\n\t\t\t\tuint32 create_options)\n{\n\tfiles_struct *fsp;\n\n\tDEBUG(5,(\"fcb_or_dos_open: attempting old open semantics for \"\n\t\t \"file %s.\\n\", smb_fname_str_dbg(smb_fname)));\n\n\tfor(fsp = file_find_di_first(conn->sconn, id); fsp;\n\t    fsp = file_find_di_next(fsp)) {\n\n\t\tDEBUG(10,(\"fcb_or_dos_open: checking file %s, fd = %d, \"\n\t\t\t  \"vuid = %llu, file_pid = %u, private_options = 0x%x \"\n\t\t\t  \"access_mask = 0x%x\\n\", fsp_str_dbg(fsp),\n\t\t\t  fsp->fh->fd, (unsigned long long)fsp->vuid,\n\t\t\t  (unsigned int)fsp->file_pid,\n\t\t\t  (unsigned int)fsp->fh->private_options,\n\t\t\t  (unsigned int)fsp->access_mask ));\n\n\t\tif (fsp != fsp_to_dup_into &&\n\t\t    fsp->fh->fd != -1 &&\n\t\t    fsp->vuid == vuid &&\n\t\t    fsp->file_pid == file_pid &&\n\t\t    (fsp->fh->private_options & (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS |\n\t\t\t\t\t\t NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) &&\n\t\t    (fsp->access_mask & FILE_WRITE_DATA) &&\n\t\t    strequal(fsp->fsp_name->base_name, smb_fname->base_name) &&\n\t\t    strequal(fsp->fsp_name->stream_name,\n\t\t\t     smb_fname->stream_name)) {\n\t\t\tDEBUG(10,(\"fcb_or_dos_open: file match\\n\"));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!fsp) {\n\t\treturn NT_STATUS_NOT_FOUND;\n\t}\n\n\t\/* quite an insane set of semantics ... *\/\n\tif (is_executable(smb_fname->base_name) &&\n\t    (fsp->fh->private_options & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS)) {\n\t\tDEBUG(10,(\"fcb_or_dos_open: file fail due to is_executable.\\n\"));\n\t\treturn NT_STATUS_INVALID_PARAMETER;\n\t}\n\n\t\/* We need to duplicate this fsp. *\/\n\treturn dup_file_fsp(req, fsp, access_mask, share_access,\n\t\t\t    create_options, fsp_to_dup_into);\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":292187,"func":"CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS) {\n  Klass* resolved_method_holder = resolved_method->method_holder();\n  if (resolved_klass == NULL) { \/\/ 2nd argument defaults to holder of 1st\n    resolved_klass = resolved_method_holder;\n  }\n  _resolved_klass  = resolved_klass;\n  _selected_klass  = resolved_klass;\n  _resolved_method = resolved_method;\n  _selected_method = resolved_method;\n  \/\/ classify:\n  CallKind kind = CallInfo::unknown_kind;\n  int index = resolved_method->vtable_index();\n  if (resolved_method->can_be_statically_bound()) {\n    kind = CallInfo::direct_call;\n  } else if (!resolved_method_holder->is_interface()) {\n    \/\/ Could be an Object method inherited into an interface, but still a vtable call.\n    kind = CallInfo::vtable_call;\n  } else if (!resolved_klass->is_interface()) {\n    \/\/ A default or miranda method.  Compute the vtable index.\n    index = LinkResolver::vtable_index_of_interface_method(resolved_klass,\n                           resolved_method);\n    assert(index >= 0 , \"we should have valid vtable index at this point\");\n\n    kind = CallInfo::vtable_call;\n  } else if (resolved_method->has_vtable_index()) {\n    \/\/ Can occur if an interface redeclares a method of Object.\n\n#ifdef ASSERT\n    \/\/ Ensure that this is really the case.\n    Klass* object_klass = SystemDictionary::Object_klass();\n    Method * object_resolved_method = object_klass->vtable().method_at(index);\n    assert(object_resolved_method->name() == resolved_method->name(),\n      \"Object and interface method names should match at vtable index %d, %s != %s\",\n      index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string());\n    assert(object_resolved_method->signature() == resolved_method->signature(),\n      \"Object and interface method signatures should match at vtable index %d, %s != %s\",\n      index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string());\n#endif \/\/ ASSERT\n\n    kind = CallInfo::vtable_call;\n  } else {\n    \/\/ A regular interface call.\n    kind = CallInfo::itable_call;\n    index = resolved_method->itable_index();\n  }\n  assert(index == Method::nonvirtual_vtable_index || index >= 0, \"bad index %d\", index);\n  _call_kind  = kind;\n  _call_index = index;\n  _resolved_appendix = Handle();\n  \/\/ Find or create a ResolvedMethod instance for this Method*\n  set_resolved_method_name(CHECK);\n\n  DEBUG_ONLY(verify());\n}","target":0,"code_token_length":595,"total_token_length":831,"max_tokens_setting":1024}
+{"idx":289305,"func":"static int snd_pcm_oss_format_to(snd_pcm_format_t format)\n{\n\tswitch (format) {\n\tcase SNDRV_PCM_FORMAT_MU_LAW:\treturn AFMT_MU_LAW;\n\tcase SNDRV_PCM_FORMAT_A_LAW:\treturn AFMT_A_LAW;\n\tcase SNDRV_PCM_FORMAT_IMA_ADPCM:\treturn AFMT_IMA_ADPCM;\n\tcase SNDRV_PCM_FORMAT_U8:\t\treturn AFMT_U8;\n\tcase SNDRV_PCM_FORMAT_S16_LE:\treturn AFMT_S16_LE;\n\tcase SNDRV_PCM_FORMAT_S16_BE:\treturn AFMT_S16_BE;\n\tcase SNDRV_PCM_FORMAT_S8:\t\treturn AFMT_S8;\n\tcase SNDRV_PCM_FORMAT_U16_LE:\treturn AFMT_U16_LE;\n\tcase SNDRV_PCM_FORMAT_U16_BE:\treturn AFMT_U16_BE;\n\tcase SNDRV_PCM_FORMAT_MPEG:\t\treturn AFMT_MPEG;\n\tcase SNDRV_PCM_FORMAT_S32_LE:\treturn AFMT_S32_LE;\n\tcase SNDRV_PCM_FORMAT_S32_BE:\treturn AFMT_S32_BE;\n\tcase SNDRV_PCM_FORMAT_S24_LE:\treturn AFMT_S24_LE;\n\tcase SNDRV_PCM_FORMAT_S24_BE:\treturn AFMT_S24_BE;\n\tcase SNDRV_PCM_FORMAT_S24_3LE:\treturn AFMT_S24_PACKED;\n\tcase SNDRV_PCM_FORMAT_FLOAT:\treturn AFMT_FLOAT;\n\tcase SNDRV_PCM_FORMAT_IEC958_SUBFRAME: return AFMT_SPDIF_RAW;\n\tdefault:\t\t\treturn -EINVAL;\n\t}\n}","target":0,"code_token_length":326,"total_token_length":562,"max_tokens_setting":1024}
+{"idx":261908,"func":"njs_string_prototype_to_string(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    njs_int_t          ret;\n    njs_str_t          enc, str;\n    njs_value_t        value;\n    njs_string_prop_t  string;\n\n    ret = njs_string_prototype_value_of(vm, args, nargs, unused);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (nargs < 2) {\n        return NJS_OK;\n    }\n\n    if (njs_slow_path(!njs_is_string(&args[1]))) {\n        njs_type_error(vm, \"encoding must be a string\");\n        return NJS_ERROR;\n    }\n\n    value = vm->retval;\n\n    (void) njs_string_prop(&string, &value);\n\n    njs_string_get(&args[1], &enc);\n\n    str.length = string.size;\n    str.start = string.start;\n\n    if (enc.length == 3 && memcmp(enc.start, \"hex\", 3) == 0) {\n        return njs_string_hex(vm, &vm->retval, &str);\n\n    } else if (enc.length == 6 && memcmp(enc.start, \"base64\", 6) == 0) {\n        return njs_string_base64(vm, &vm->retval, &str);\n\n    } else if (enc.length == 9 && memcmp(enc.start, \"base64url\", 9) == 0) {\n        return njs_string_base64url(vm, &vm->retval, &str);\n    }\n\n    njs_type_error(vm, \"Unknown encoding: \\\"%V\\\"\", &enc);\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":247371,"func":"int pgpPrtParamsSubkeys(const uint8_t *pkts, size_t pktlen,\n\t\t\tpgpDigParams mainkey, pgpDigParams **subkeys,\n\t\t\tint *subkeysCount)\n{\n    const uint8_t *p = pkts;\n    const uint8_t *pend = pkts + pktlen;\n    pgpDigParams *digps = NULL;\n    int count = 0;\n    int alloced = 10;\n    struct pgpPkt pkt;\n    int rc, i;\n\n    digps = xmalloc(alloced * sizeof(*digps));\n\n    while (p < pend) {\n\tif (decodePkt(p, (pend - p), &pkt))\n\t    break;\n\n\tp += (pkt.body - pkt.head) + pkt.blen;\n\n\tif (pkt.tag == PGPTAG_PUBLIC_SUBKEY) {\n\t    if (count == alloced) {\n\t\talloced <<= 1;\n\t\tdigps = xrealloc(digps, alloced * sizeof(*digps));\n\t    }\n\n\t    digps[count] = pgpDigParamsNew(PGPTAG_PUBLIC_SUBKEY);\n\t    \/* Copy UID from main key to subkey *\/\n\t    digps[count]->userid = xstrdup(mainkey->userid);\n\n\t    if (getKeyID(pkt.body, pkt.blen, digps[count]->signid)) {\n\t\tpgpDigParamsFree(digps[count]);\n\t\tcontinue;\n\t    }\n\n\t    if (pgpPrtKey(pkt.tag, pkt.body, pkt.blen, digps[count])) {\n\t\tpgpDigParamsFree(digps[count]);\n\t\tcontinue;\n\t    }\n\t    count++;\n\t}\n    }\n    rc = (p == pend) ? 0 : -1;\n\n    if (rc == 0) {\n\t*subkeys = xrealloc(digps, count * sizeof(*digps));\n\t*subkeysCount = count;\n    } else {\n\tfor (i = 0; i < count; i++)\n\t    pgpDigParamsFree(digps[i]);\n\tfree(digps);\n    }\n\n    return rc;\n}","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":253574,"func":"smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t   struct cifsFileInfo *cfile, void __user *ioc_buf)\n{\n\tchar *retbuf = NULL;\n\tunsigned int ret_data_len = 0;\n\tint rc;\n\tu32 max_response_size;\n\tstruct smb_snapshot_array snapshot_in;\n\n\t\/*\n\t * On the first query to enumerate the list of snapshots available\n\t * for this volume the buffer begins with 0 (number of snapshots\n\t * which can be returned is zero since at that point we do not know\n\t * how big the buffer needs to be). On the second query,\n\t * it (ret_data_len) is set to number of snapshots so we can\n\t * know to set the maximum response size larger (see below).\n\t *\/\n\tif (get_user(ret_data_len, (unsigned int __user *)ioc_buf))\n\t\treturn -EFAULT;\n\n\t\/*\n\t * Note that for snapshot queries that servers like Azure expect that\n\t * the first query be minimal size (and just used to get the number\/size\n\t * of previous versions) so response size must be specified as EXACTLY\n\t * sizeof(struct snapshot_array) which is 16 when rounded up to multiple\n\t * of eight bytes.\n\t *\/\n\tif (ret_data_len == 0)\n\t\tmax_response_size = MIN_SNAPSHOT_ARRAY_SIZE;\n\telse\n\t\tmax_response_size = CIFSMaxBufSize;\n\n\trc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,\n\t\t\tcfile->fid.volatile_fid,\n\t\t\tFSCTL_SRV_ENUMERATE_SNAPSHOTS,\n\t\t\ttrue \/* is_fsctl *\/,\n\t\t\tNULL, 0 \/* no input data *\/, max_response_size,\n\t\t\t(char **)&retbuf,\n\t\t\t&ret_data_len);\n\tcifs_dbg(FYI, \"enum snaphots ioctl returned %d and ret buflen is %d\\n\",\n\t\t\trc, ret_data_len);\n\tif (rc)\n\t\treturn rc;\n\n\tif (ret_data_len && (ioc_buf != NULL) && (retbuf != NULL)) {\n\t\t\/* Fixup buffer *\/\n\t\tif (copy_from_user(&snapshot_in, ioc_buf,\n\t\t    sizeof(struct smb_snapshot_array))) {\n\t\t\trc = -EFAULT;\n\t\t\tkfree(retbuf);\n\t\t\treturn rc;\n\t\t}\n\n\t\t\/*\n\t\t * Check for min size, ie not large enough to fit even one GMT\n\t\t * token (snapshot).  On the first ioctl some users may pass in\n\t\t * smaller size (or zero) to simply get the size of the array\n\t\t * so the user space caller can allocate sufficient memory\n\t\t * and retry the ioctl again with larger array size sufficient\n\t\t * to hold all of the snapshot GMT tokens on the second try.\n\t\t *\/\n\t\tif (snapshot_in.snapshot_array_size < GMT_TOKEN_SIZE)\n\t\t\tret_data_len = sizeof(struct smb_snapshot_array);\n\n\t\t\/*\n\t\t * We return struct SRV_SNAPSHOT_ARRAY, followed by\n\t\t * the snapshot array (of 50 byte GMT tokens) each\n\t\t * representing an available previous version of the data\n\t\t *\/\n\t\tif (ret_data_len > (snapshot_in.snapshot_array_size +\n\t\t\t\t\tsizeof(struct smb_snapshot_array)))\n\t\t\tret_data_len = snapshot_in.snapshot_array_size +\n\t\t\t\t\tsizeof(struct smb_snapshot_array);\n\n\t\tif (copy_to_user(ioc_buf, retbuf, ret_data_len))\n\t\t\trc = -EFAULT;\n\t}\n\n\tkfree(retbuf);\n\treturn rc;\n}","target":0,"code_token_length":721,"total_token_length":957,"max_tokens_setting":1024}
+{"idx":450406,"func":"static int send_png_rect(VncState *vs, int x, int y, int w, int h,\n                         VncPalette *palette)\n{\n    png_byte color_type;\n    png_structp png_ptr;\n    png_infop info_ptr;\n    png_colorp png_palette = NULL;\n    pixman_image_t *linebuf;\n    int level = tight_png_conf[vs->tight->compression].png_zlib_level;\n    int filters = tight_png_conf[vs->tight->compression].png_filters;\n    uint8_t *buf;\n    int dy;\n\n    png_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL,\n                                        NULL, vnc_png_malloc, vnc_png_free);\n\n    if (png_ptr == NULL)\n        return -1;\n\n    info_ptr = png_create_info_struct(png_ptr);\n\n    if (info_ptr == NULL) {\n        png_destroy_write_struct(&png_ptr, NULL);\n        return -1;\n    }\n\n    png_set_write_fn(png_ptr, (void *) vs, png_write_data, png_flush_data);\n    png_set_compression_level(png_ptr, level);\n    png_set_filter(png_ptr, PNG_FILTER_TYPE_DEFAULT, filters);\n\n    if (palette) {\n        color_type = PNG_COLOR_TYPE_PALETTE;\n    } else {\n        color_type = PNG_COLOR_TYPE_RGB;\n    }\n\n    png_set_IHDR(png_ptr, info_ptr, w, h,\n                 8, color_type, PNG_INTERLACE_NONE,\n                 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);\n\n    if (color_type == PNG_COLOR_TYPE_PALETTE) {\n        struct palette_cb_priv priv;\n\n        png_palette = png_malloc(png_ptr, sizeof(*png_palette) *\n                                 palette_size(palette));\n\n        priv.vs = vs;\n        priv.png_palette = png_palette;\n        palette_iter(palette, write_png_palette, &priv);\n\n        png_set_PLTE(png_ptr, info_ptr, png_palette, palette_size(palette));\n\n        if (vs->client_pf.bytes_per_pixel == 4) {\n            tight_encode_indexed_rect32(vs->tight->tight.buffer, w * h,\n                                        palette);\n        } else {\n            tight_encode_indexed_rect16(vs->tight->tight.buffer, w * h,\n                                        palette);\n        }\n    }\n\n    png_write_info(png_ptr, info_ptr);\n\n    buffer_reserve(&vs->tight->png, 2048);\n    linebuf = qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, w);\n    buf = (uint8_t *)pixman_image_get_data(linebuf);\n    for (dy = 0; dy < h; dy++)\n    {\n        if (color_type == PNG_COLOR_TYPE_PALETTE) {\n            memcpy(buf, vs->tight->tight.buffer + (dy * w), w);\n        } else {\n            qemu_pixman_linebuf_fill(linebuf, vs->vd->server, w, x, y + dy);\n        }\n        png_write_row(png_ptr, buf);\n    }\n    qemu_pixman_image_unref(linebuf);\n\n    png_write_end(png_ptr, NULL);\n\n    if (color_type == PNG_COLOR_TYPE_PALETTE) {\n        png_free(png_ptr, png_palette);\n    }\n\n    png_destroy_write_struct(&png_ptr, &info_ptr);\n\n    vnc_write_u8(vs, VNC_TIGHT_PNG << 4);\n\n    tight_send_compact_size(vs, vs->tight->png.offset);\n    vnc_write(vs, vs->tight->png.buffer, vs->tight->png.offset);\n    buffer_reset(&vs->tight->png);\n    return 1;\n}","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":245191,"func":"char* get_xtrabackup_info(MYSQL *connection)\n{\n\tconst char *uuid = get_backup_uuid(connection);\n\tchar *server_version = read_mysql_one_value(connection, \"SELECT VERSION()\");\n\n\tstatic const size_t time_buf_size = 100;\n\tchar buf_start_time[time_buf_size];\n\tchar buf_end_time[time_buf_size];\n\n\tformat_time(history_start_time, buf_start_time, time_buf_size);\n\tformat_time(history_end_time, buf_end_time, time_buf_size);\n\n\tut_a(uuid);\n\tut_a(server_version);\n\tchar* result = NULL;\n\tasprintf(&result,\n\t\t\"uuid = %s\\n\"\n\t\t\"name = %s\\n\"\n\t\t\"tool_name = %s\\n\"\n\t\t\"tool_command = %s\\n\"\n\t\t\"tool_version = %s\\n\"\n\t\t\"ibbackup_version = %s\\n\"\n\t\t\"server_version = %s\\n\"\n\t\t\"start_time = %s\\n\"\n\t\t\"end_time = %s\\n\"\n\t\t\"lock_time = %ld\\n\"\n\t\t\"binlog_pos = %s\\n\"\n\t\t\"innodb_from_lsn = \" LSN_PF \"\\n\"\n\t\t\"innodb_to_lsn = \" LSN_PF \"\\n\"\n\t\t\"partial = %s\\n\"\n\t\t\"incremental = %s\\n\"\n\t\t\"format = %s\\n\"\n\t\t\"compact = %s\\n\"\n\t\t\"compressed = %s\\n\"\n\t\t\"encrypted = %s\\n\",\n\t\tuuid, \/* uuid *\/\n\t\topt_history ? opt_history : \"\",  \/* name *\/\n\t\ttool_name,  \/* tool_name *\/\n\t\ttool_args,  \/* tool_command *\/\n\t\tXTRABACKUP_VERSION,  \/* tool_version *\/\n\t\tXTRABACKUP_VERSION,  \/* ibbackup_version *\/\n\t\tserver_version,  \/* server_version *\/\n\t\tbuf_start_time,  \/* start_time *\/\n\t\tbuf_end_time,  \/* end_time *\/\n\t\t(long int)history_lock_time, \/* lock_time *\/\n\t\tmysql_binlog_position ?\n\t\t\tmysql_binlog_position : \"\", \/* binlog_pos *\/\n\t\tincremental_lsn, \/* innodb_from_lsn *\/\n\t\tmetadata_to_lsn, \/* innodb_to_lsn *\/\n\t\t(xtrabackup_tables \/* partial *\/\n\t\t || xtrabackup_tables_exclude\n\t\t || xtrabackup_tables_file\n\t\t || xtrabackup_databases\n\t\t || xtrabackup_databases_exclude\n\t\t || xtrabackup_databases_file) ? \"Y\" : \"N\",\n\t\txtrabackup_incremental ? \"Y\" : \"N\", \/* incremental *\/\n\t\txb_stream_format_name[xtrabackup_stream_fmt], \/* format *\/\n\t\txtrabackup_compact ? \"Y\" : \"N\", \/* compact *\/\n\t\txtrabackup_compress ? \"compressed\" : \"N\", \/* compressed *\/\n\t\txtrabackup_encrypt ? \"Y\" : \"N\"); \/* encrypted *\/\n\n\tfree(server_version);\n\treturn result;\n}","target":0,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":254877,"func":"Value DocumentSourceGroup::serialize(boost::optional<ExplainOptions::Verbosity> explain) const {\n    MutableDocument insides;\n\n    \/\/ Add the _id.\n    if (_idFieldNames.empty()) {\n        invariant(_idExpressions.size() == 1);\n        insides[\"_id\"] = _idExpressions[0]->serialize(static_cast<bool>(explain));\n    } else {\n        \/\/ Decomposed document case.\n        invariant(_idExpressions.size() == _idFieldNames.size());\n        MutableDocument md;\n        for (size_t i = 0; i < _idExpressions.size(); i++) {\n            md[_idFieldNames[i]] = _idExpressions[i]->serialize(static_cast<bool>(explain));\n        }\n        insides[\"_id\"] = md.freezeToValue();\n    }\n\n    \/\/ Add the remaining fields.\n    for (auto&& accumulatedField : _accumulatedFields) {\n        intrusive_ptr<AccumulatorState> accum = accumulatedField.makeAccumulator();\n        insides[accumulatedField.fieldName] =\n            Value(accum->serialize(accumulatedField.expr.initializer,\n                                   accumulatedField.expr.argument,\n                                   static_cast<bool>(explain)));\n    }\n\n    if (_doingMerge) {\n        \/\/ This makes the output unparsable (with error) on pre 2.6 shards, but it will never\n        \/\/ be sent to old shards when this flag is true since they can't do a merge anyway.\n        insides[\"$doingMerge\"] = Value(true);\n    }\n\n    return Value(DOC(getSourceName() << insides.freeze()));\n}","target":0,"code_token_length":322,"total_token_length":558,"max_tokens_setting":1024}
+{"idx":482484,"func":"parseDots(const FileInfo *file, CharsString *cells, const CharsString *token) {\n\t\/* get dot patterns *\/\n\twidechar cell = 0; \/* assembly place for dots *\/\n\tint cellCount = 0;\n\tint index;\n\tint start = 0;\n\n\tfor (index = 0; index < token->length; index++) {\n\t\tint started = index != start;\n\t\twidechar character = token->chars[index];\n\t\tswitch (character) { \/* or dots to make up Braille cell *\/\n\t\t\t{\n\t\t\t\tint dot;\n\t\t\tcase '1':\n\t\t\t\tdot = LOU_DOT_1;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '2':\n\t\t\t\tdot = LOU_DOT_2;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '3':\n\t\t\t\tdot = LOU_DOT_3;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '4':\n\t\t\t\tdot = LOU_DOT_4;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '5':\n\t\t\t\tdot = LOU_DOT_5;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '6':\n\t\t\t\tdot = LOU_DOT_6;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '7':\n\t\t\t\tdot = LOU_DOT_7;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '8':\n\t\t\t\tdot = LOU_DOT_8;\n\t\t\t\tgoto haveDot;\n\t\t\tcase '9':\n\t\t\t\tdot = LOU_DOT_9;\n\t\t\t\tgoto haveDot;\n\t\t\tcase 'a':\n\t\t\tcase 'A':\n\t\t\t\tdot = LOU_DOT_10;\n\t\t\t\tgoto haveDot;\n\t\t\tcase 'b':\n\t\t\tcase 'B':\n\t\t\t\tdot = LOU_DOT_11;\n\t\t\t\tgoto haveDot;\n\t\t\tcase 'c':\n\t\t\tcase 'C':\n\t\t\t\tdot = LOU_DOT_12;\n\t\t\t\tgoto haveDot;\n\t\t\tcase 'd':\n\t\t\tcase 'D':\n\t\t\t\tdot = LOU_DOT_13;\n\t\t\t\tgoto haveDot;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\t\tdot = LOU_DOT_14;\n\t\t\t\tgoto haveDot;\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\t\tdot = LOU_DOT_15;\n\t\t\thaveDot:\n\t\t\t\tif (started && !cell) goto invalid;\n\t\t\t\tif (cell & dot) {\n\t\t\t\t\tcompileError(file, \"dot specified more than once.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tcell |= dot;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tcase '0': \/* blank *\/\n\t\t\tif (started) goto invalid;\n\t\t\tbreak;\n\t\tcase '-': \/* got all dots for this cell *\/\n\t\t\tif (!started) {\n\t\t\t\tcompileError(file, \"missing cell specification.\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tcells->chars[cellCount++] = cell | LOU_DOTS;\n\t\t\tcell = 0;\n\t\t\tstart = index + 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\tinvalid:\n\t\t\tcompileError(\n\t\t\t\t\tfile, \"invalid dot number %s.\", _lou_showString(&character, 1, 0));\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (index == start) {\n\t\tcompileError(file, \"missing cell specification.\");\n\t\treturn 0;\n\t}\n\tcells->chars[cellCount++] = cell | LOU_DOTS; \/* last cell *\/\n\tcells->length = cellCount;\n\treturn 1;\n}","target":0,"code_token_length":695,"total_token_length":931,"max_tokens_setting":1024}
+{"idx":265058,"func":"tsetcap(int cap, int flags)\n{\n    if (tccan(cap) && !isset(SINGLELINEZLE) &&\n        !(termflags & (TERM_NOUP|TERM_BAD|TERM_UNKNOWN))) {\n\tswitch (flags & TSC_OUTPUT_MASK) {\n\tcase TSC_RAW:\n\t    tputs(tcstr[cap], 1, putraw);\n\t    break;\n\tcase 0:\n\tdefault:\n\t    tputs(tcstr[cap], 1, putshout);\n\t    break;\n\tcase TSC_PROMPT:\n\t    if (!bv->dontcount) {\n\t\taddbufspc(1);\n\t\t*bv->bp++ = Inpar;\n\t    }\n\t    tputs(tcstr[cap], 1, putstr);\n\t    if (!bv->dontcount) {\n\t\tint glitch = 0;\n\n\t\tif (cap == TCSTANDOUTBEG || cap == TCSTANDOUTEND)\n\t\t    glitch = tgetnum(\"sg\");\n\t\telse if (cap == TCUNDERLINEBEG || cap == TCUNDERLINEEND)\n\t\t    glitch = tgetnum(\"ug\");\n\t\tif(glitch < 0)\n\t\t    glitch = 0;\n\t\taddbufspc(glitch + 1);\n\t\twhile(glitch--)\n\t\t    *bv->bp++ = Nularg;\n\t\t*bv->bp++ = Outpar;\n\t    }\n\t    break;\n\t}\n\n\tif (flags & TSC_DIRTY) {\n\t    flags &= ~TSC_DIRTY;\n\t    if (txtisset(TXTBOLDFACE) && cap != TCBOLDFACEBEG)\n\t\ttsetcap(TCBOLDFACEBEG, flags);\n\t    if (txtisset(TXTSTANDOUT))\n\t\ttsetcap(TCSTANDOUTBEG, flags);\n\t    if (txtisset(TXTUNDERLINE))\n\t\ttsetcap(TCUNDERLINEBEG, flags);\n\t    if (txtisset(TXTFGCOLOUR))\n\t\tset_colour_attribute(txtattrmask, COL_SEQ_FG, TSC_PROMPT);\n\t    if (txtisset(TXTBGCOLOUR))\n\t\tset_colour_attribute(txtattrmask, COL_SEQ_BG, TSC_PROMPT);\n\t}\n    }\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":318105,"func":"static int rsi_reset_card(struct rsi_hw *adapter)\n{\n\tint ret;\n\n\trsi_dbg(INFO_ZONE, \"Resetting Card...\\n\");\n\trsi_usb_master_reg_write(adapter, RSI_TA_HOLD_REG, 0xE, 4);\n\n\t\/* This msleep will ensure Thread-Arch processor to go to hold\n\t * and any pending dma transfers to rf in device to finish.\n\t *\/\n\tmsleep(100);\n\n\tret = rsi_usb_master_reg_write(adapter, SWBL_REGOUT,\n\t\t\t\t       RSI_FW_WDT_DISABLE_REQ,\n\t\t\t\t       RSI_COMMON_REG_SIZE);\n\tif (ret < 0) {\n\t\trsi_dbg(ERR_ZONE, \"Disabling firmware watchdog timer failed\\n\");\n\t\tgoto fail;\n\t}\n\n\tif (adapter->device_model != RSI_DEV_9116) {\n\t\tret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_1,\n\t\t\t\t\t RSI_ULP_WRITE_2, 32);\n\t\tif (ret < 0)\n\t\t\tgoto fail;\n\t\tret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_2,\n\t\t\t\t\t RSI_ULP_WRITE_0, 32);\n\t\tif (ret < 0)\n\t\t\tgoto fail;\n\t\tret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_DELAY_TIMER_1,\n\t\t\t\t\t RSI_ULP_WRITE_50, 32);\n\t\tif (ret < 0)\n\t\t\tgoto fail;\n\t\tret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_DELAY_TIMER_2,\n\t\t\t\t\t RSI_ULP_WRITE_0, 32);\n\t\tif (ret < 0)\n\t\t\tgoto fail;\n\t\tret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_ENABLE,\n\t\t\t\t\t RSI_ULP_TIMER_ENABLE, 32);\n\t\tif (ret < 0)\n\t\t\tgoto fail;\n\t} else {\n\t\tif ((rsi_usb_master_reg_write(adapter,\n\t\t\t\t\t      NWP_WWD_INTERRUPT_TIMER,\n\t\t\t\t\t      NWP_WWD_INT_TIMER_CLKS,\n\t\t\t\t\t      RSI_9116_REG_SIZE)) < 0) {\n\t\t\tgoto fail;\n\t\t}\n\t\tif ((rsi_usb_master_reg_write(adapter,\n\t\t\t\t\t      NWP_WWD_SYSTEM_RESET_TIMER,\n\t\t\t\t\t      NWP_WWD_SYS_RESET_TIMER_CLKS,\n\t\t\t\t\t      RSI_9116_REG_SIZE)) < 0) {\n\t\t\tgoto fail;\n\t\t}\n\t\tif ((rsi_usb_master_reg_write(adapter,\n\t\t\t\t\t      NWP_WWD_MODE_AND_RSTART,\n\t\t\t\t\t      NWP_WWD_TIMER_DISABLE,\n\t\t\t\t\t      RSI_9116_REG_SIZE)) < 0) {\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\trsi_dbg(INFO_ZONE, \"Reset card done\\n\");\n\treturn ret;\n\nfail:\n\trsi_dbg(ERR_ZONE, \"Reset card failed\\n\");\n\treturn ret;\n}","target":0,"code_token_length":586,"total_token_length":822,"max_tokens_setting":1024}
+{"idx":492677,"func":"vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)\n{\n\tVteScreen *screen;\n\tlong old_len, newcol, col;\n\n\t\/* Calculate which column is the next tab stop. *\/\n\tscreen = terminal->pvt->screen;\n\tnewcol = col = screen->cursor_current.col;\n\n\tg_assert (col >= 0);\n\n\tif (terminal->pvt->tabstops != NULL) {\n\t\t\/* Find the next tabstop. *\/\n\t\tfor (newcol++; newcol < VTE_TAB_MAX; newcol++) {\n\t\t\tif (_vte_terminal_get_tabstop(terminal, newcol)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t\/* If we have no tab stops or went past the end of the line, stop\n\t * at the right-most column. *\/\n\tif (newcol >= terminal->column_count) {\n\t\tnewcol = terminal->column_count - 1;\n\t}\n\n\t\/* but make sure we don't move cursor back (bug #340631) *\/\n\tif (col < newcol) {\n\t\tVteRowData *rowdata = _vte_terminal_ensure_row (terminal);\n\n\t\t\/* Smart tab handling: bug 353610\n\t\t *\n\t\t * If we currently don't have any cells in the space this\n\t\t * tab creates, we try to make the tab character copyable,\n\t\t * by appending a single tab char with lots of fragment\n\t\t * cells following it.\n\t\t *\n\t\t * Otherwise, just append empty cells that will show up\n\t\t * as a space each.\n\t\t *\/\n\n\t\told_len = _vte_row_data_length (rowdata);\n\t\t_vte_row_data_fill (rowdata, &screen->fill_defaults, newcol);\n\n\t\t\/* Insert smart tab if there's nothing in the line after\n\t\t * us.  Though, there may be empty cells (with non-default\n\t\t * background color for example.\n\t\t *\n\t\t * Notable bugs here: 545924 and 597242 *\/\n\t\t{\n\t\t\tglong i;\n\t\t\tgboolean found = FALSE;\n\t\t\tfor (i = old_len; i > col; i--) {\n\t\t\t\tconst VteCell *cell = _vte_row_data_get (rowdata, i - 1);\n\t\t\t\tif (cell->attr.fragment || cell->c != 0) {\n\t\t\t\t\tfound = TRUE;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/* Nothing found on the line after us, turn this into\n\t\t\t * a smart tab *\/\n\t\t\tif (!found) {\n\t\t\t\tVteCell *cell = _vte_row_data_get_writable (rowdata, col);\n\t\t\t\tVteCell tab = *cell;\n\t\t\t\ttab.attr.columns = newcol - col;\n\t\t\t\ttab.c = '\\t';\n\t\t\t\t\/* Check if it fits in columns *\/\n\t\t\t\tif (tab.attr.columns == newcol - col) {\n\t\t\t\t\t\/* Save tab char *\/\n\t\t\t\t\t*cell = tab;\n\t\t\t\t\t\/* And adjust the fragments *\/\n\t\t\t\t\tfor (i = col + 1; i < newcol; i++) {\n\t\t\t\t\t\tcell = _vte_row_data_get_writable (rowdata, i);\n\t\t\t\t\t\tcell->c = '\\t';\n\t\t\t\t\t\tcell->attr.columns = 1;\n\t\t\t\t\t\tcell->attr.fragment = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t_vte_invalidate_cells (terminal,\n\t\t\t\tscreen->cursor_current.col,\n\t\t\t\tnewcol - screen->cursor_current.col,\n\t\t\t\tscreen->cursor_current.row, 1);\n\t\tscreen->cursor_current.col = newcol;\n\t}\n}","target":0,"code_token_length":758,"total_token_length":994,"max_tokens_setting":1024}
+{"idx":275970,"func":"static void mul2add(uECC_word_t a,\n                    uECC_word_t b,\n                    uECC_word_t *r0,\n                    uECC_word_t *r1,\n                    uECC_word_t *r2) {\n#if uECC_WORD_SIZE == 8 && !SUPPORTS_INT128\n    uint64_t a0 = a & 0xffffffffull;\n    uint64_t a1 = a >> 32;\n    uint64_t b0 = b & 0xffffffffull;\n    uint64_t b1 = b >> 32;\n\n    uint64_t i0 = a0 * b0;\n    uint64_t i1 = a0 * b1;\n    uint64_t i2 = a1 * b0;\n    uint64_t i3 = a1 * b1;\n\n    uint64_t p0, p1;\n\n    i2 += (i0 >> 32);\n    i2 += i1;\n    if (i2 < i1)\n    { \/* overflow *\/\n        i3 += 0x100000000ull;\n    }\n\n    p0 = (i0 & 0xffffffffull) | (i2 << 32);\n    p1 = i3 + (i2 >> 32);\n\n    *r2 += (p1 >> 63);\n    p1 = (p1 << 1) | (p0 >> 63);\n    p0 <<= 1;\n\n    *r0 += p0;\n    *r1 += (p1 + (*r0 < p0));\n    *r2 += ((*r1 < p1) || (*r1 == p1 && *r0 < p0));\n#else\n    uECC_dword_t p = (uECC_dword_t)a * b;\n    uECC_dword_t r01 = ((uECC_dword_t)(*r1) << uECC_WORD_BITS) | *r0;\n    *r2 += (p >> (uECC_WORD_BITS * 2 - 1));\n    p *= 2;\n    r01 += p;\n    *r2 += (r01 < p);\n    *r1 = r01 >> uECC_WORD_BITS;\n    *r0 = (uECC_word_t)r01;\n#endif\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":359377,"func":"bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,\n\t\t\t       safi_t safi, int *write)\n{\n  int i;\n\n  \/* Unicast redistribution only.  *\/\n  if (safi != SAFI_UNICAST)\n    return 0;\n\n  for (i = 0; i < ZEBRA_ROUTE_MAX; i++)\n    {\n      \/* Redistribute BGP does not make sense.  *\/\n      if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)\n\t{\n\t  \/* Display \"address-family\" when it is not yet diplayed.  *\/\n\t  bgp_config_write_family_header (vty, afi, safi, write);\n\n\t  \/* \"redistribute\" configuration.  *\/\n\t  vty_out (vty, \" redistribute %s\", zebra_route_string(i));\n\n\t  if (bgp->redist_metric_flag[afi][i])\n\t    vty_out (vty, \" metric %d\", bgp->redist_metric[afi][i]);\n\n\t  if (bgp->rmap[afi][i].name)\n\t    vty_out (vty, \" route-map %s\", bgp->rmap[afi][i].name);\n\n\t  vty_out (vty, \"%s\", VTY_NEWLINE);\n\t}\n    }\n  return *write;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":265423,"func":"static int getLineToStop( const std::string &fulltext){\n\tint lineNo=1;\n\tbool inString=false;\n\tfor (unsigned int i=0; i<fulltext.length(); ++i) {\n\t\/\/ increase line number\n\t\tif (fulltext[i] == '\\n') {\n\t\t\tlineNo++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/\/ skip escaped quotes inside strings\n\t\tif (inString && fulltext.compare(i, 2, \"\\\\\\\"\") == 0) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/\/start or end of string negate the checkpoint\n\t\tif (fulltext[i] == '\"') {\n\t\t\tinString = !inString;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!inString && fulltext.compare(i, 2, \"\/\/\") == 0) {\n\t\t\ti++;\n\t\t\twhile (fulltext[i] != '\\n' && i<fulltext.length()) i++;\n\t\t\tlineNo++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t\/\/start of multi line comment if check is true\n\t\tif (!inString && fulltext.compare(i, 2, \"\/*\") == 0) {\n\t\t\ti ++;\n\t\t\tif(i<fulltext.length()) {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/\/ till *\/ every character is comment\n\t\t\twhile (fulltext.compare(i, 2, \"*\/\") != 0 && i<fulltext.length()) {\n\t\t\t\tif(fulltext[i]=='\\n'){\n\t\t\t\t\tlineNo++;\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\n\t\tif (fulltext[i]== '{') {\n\t\t\treturn lineNo;\n\t\t}\n\t}\n\treturn lineNo;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":384885,"func":"transstr(char_u *s)\n{\n    char_u\t*res;\n    char_u\t*p;\n    int\t\tl, len, c;\n    char_u\thexbuf[11];\n\n    if (has_mbyte)\n    {\n\t\/\/ Compute the length of the result, taking account of unprintable\n\t\/\/ multi-byte characters.\n\tlen = 0;\n\tp = s;\n\twhile (*p != NUL)\n\t{\n\t    if ((l = (*mb_ptr2len)(p)) > 1)\n\t    {\n\t\tc = (*mb_ptr2char)(p);\n\t\tp += l;\n\t\tif (vim_isprintc(c))\n\t\t    len += l;\n\t\telse\n\t\t{\n\t\t    transchar_hex(hexbuf, c);\n\t\t    len += (int)STRLEN(hexbuf);\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\tl = byte2cells(*p++);\n\t\tif (l > 0)\n\t\t    len += l;\n\t\telse\n\t\t    len += 4;\t\/\/ illegal byte sequence\n\t    }\n\t}\n\tres = alloc(len + 1);\n    }\n    else\n\tres = alloc(vim_strsize(s) + 1);\n    if (res != NULL)\n    {\n\t*res = NUL;\n\tp = s;\n\twhile (*p != NUL)\n\t{\n\t    if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)\n\t    {\n\t\tc = (*mb_ptr2char)(p);\n\t\tif (vim_isprintc(c))\n\t\t    STRNCAT(res, p, l);\t\/\/ append printable multi-byte char\n\t\telse\n\t\t    transchar_hex(res + STRLEN(res), c);\n\t\tp += l;\n\t    }\n\t    else\n\t\tSTRCAT(res, transchar_byte(*p++));\n\t}\n    }\n    return res;\n}","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":291849,"func":"static void rtrs_clt_path_up(struct rtrs_clt_path *clt_path)\n{\n\tstruct rtrs_clt_sess *clt = clt_path->clt;\n\tint up;\n\n\t\/*\n\t * We can fire RECONNECTED event only when all paths were\n\t * connected on rtrs_clt_open(), then each was disconnected\n\t * and the first one connected again.  That's why this nasty\n\t * game with counter value.\n\t *\/\n\n\tmutex_lock(&clt->paths_ev_mutex);\n\tup = ++clt->paths_up;\n\t\/*\n\t * Here it is safe to access paths num directly since up counter\n\t * is greater than MAX_PATHS_NUM only while rtrs_clt_open() is\n\t * in progress, thus paths removals are impossible.\n\t *\/\n\tif (up > MAX_PATHS_NUM && up == MAX_PATHS_NUM + clt->paths_num)\n\t\tclt->paths_up = clt->paths_num;\n\telse if (up == 1)\n\t\tclt->link_ev(clt->priv, RTRS_CLT_LINK_EV_RECONNECTED);\n\tmutex_unlock(&clt->paths_ev_mutex);\n\n\t\/* Mark session as established *\/\n\tclt_path->established = true;\n\tclt_path->reconnect_attempts = 0;\n\tclt_path->stats->reconnects.successful_cnt++;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":226377,"func":"\nGF_Err fpar_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tFilePartitionBox *ptr = (FilePartitionBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, ((ptr->version ? 4 : 2) + 12) );\n\tptr->itemID = gf_bs_read_int(bs, ptr->version ? 32 : 16);\n\tptr->packet_payload_size = gf_bs_read_u16(bs);\n\tgf_bs_read_u8(bs);\n\tptr->FEC_encoding_ID = gf_bs_read_u8(bs);\n\tptr->FEC_instance_ID = gf_bs_read_u16(bs);\n\tptr->max_source_block_length = gf_bs_read_u16(bs);\n\tptr->encoding_symbol_length = gf_bs_read_u16(bs);\n\tptr->max_number_of_encoding_symbols = gf_bs_read_u16(bs);\n\n\te = gf_isom_read_null_terminated_string(s, bs, ptr->size, &ptr->scheme_specific_info);\n\tif (e) return e;\n\n\tISOM_DECREASE_SIZE(ptr, (ptr->version ? 4 : 2) );\n\tptr->nb_entries = gf_bs_read_int(bs, ptr->version ? 32 : 16);\n\tif (ptr->nb_entries > ptr->size \/ 6 || (u64)ptr->nb_entries > (u64)SIZE_MAX\/sizeof(FilePartitionEntry))\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tISOM_DECREASE_SIZE(ptr, ptr->nb_entries * 6 );\n\tGF_SAFE_ALLOC_N(ptr->entries, ptr->nb_entries, FilePartitionEntry);\n\tif (!ptr->entries) return GF_OUT_OF_MEM;\n\n\tfor (i=0;i < ptr->nb_entries; i++) {\n\t\tptr->entries[i].block_count = gf_bs_read_u16(bs);\n\t\tptr->entries[i].block_size = gf_bs_read_u32(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":452256,"func":"PHP_FUNCTION(xsl_xsltprocessor_register_php_functions)\n{\n\tzval *id;\n\txsl_object *intern;\n\tzval *array_value, **entry, *new_string;\n\tint  name_len = 0;\n\tchar *name;\n\n\tDOM_GET_THIS(id);\n\n\tif (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"a\",  &array_value) == SUCCESS) {\n\t\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\t\tzend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));\n\n\t\twhile (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) {\n\t\t\tSEPARATE_ZVAL(entry);\n\t\t\tconvert_to_string_ex(entry);\n\n\t\t\tMAKE_STD_ZVAL(new_string);\n\t\t\tZVAL_LONG(new_string,1);\n\n\t\t\tzend_hash_update(intern->registered_phpfunctions, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL);\n\t\t\tzend_hash_move_forward(Z_ARRVAL_P(array_value));\n\t\t}\n\t\tintern->registerPhpFunctions = 2;\n\n\t} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, \"s\",  &name, &name_len) == SUCCESS) {\n\t\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\n\t\tMAKE_STD_ZVAL(new_string);\n\t\tZVAL_LONG(new_string,1);\n\t\tzend_hash_update(intern->registered_phpfunctions, name, name_len + 1, &new_string, sizeof(zval*), NULL);\n\t\tintern->registerPhpFunctions = 2;\n\n\t} else {\n\t\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\t\tintern->registerPhpFunctions = 1;\n\t}\n\n}","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":267354,"func":"parse_opt (int key, char *arg, struct argp_state *state)\n{\n  switch (key)\n    {\n    case OPTION_CONSOLE_SOCKET:\n      exec_options.console_socket = arg;\n      break;\n\n    case OPTION_PID_FILE:\n      exec_options.pid_file = arg;\n      break;\n\n    case OPTION_NO_NEW_PRIVS:\n      exec_options.no_new_privs = true;\n      break;\n\n    case OPTION_PROCESS_LABEL:\n      exec_options.process_label = argp_mandatory_argument (arg, state);\n      break;\n\n    case OPTION_APPARMOR:\n      exec_options.apparmor = argp_mandatory_argument (arg, state);\n      break;\n\n    case OPTION_PRESERVE_FDS:\n      exec_options.preserve_fds = strtoul (argp_mandatory_argument (arg, state), NULL, 10);\n      break;\n\n    case OPTION_CGROUP:\n      exec_options.cgroup = argp_mandatory_argument (arg, state);\n      break;\n\n    case 'd':\n      exec_options.detach = true;\n      break;\n\n    case 'p':\n      exec_options.process = arg;\n      break;\n\n    case 't':\n      exec_options.tty = arg == NULL || (strcmp (arg, \"false\") != 0 && strcmp (arg, \"no\") != 0);\n      break;\n\n    case 'u':\n      exec_options.user = arg;\n      break;\n\n    case 'e':\n      append_env (arg);\n      break;\n\n    case 'c':\n      append_cap (arg);\n      break;\n\n    case OPTION_CWD:\n      exec_options.cwd = xstrdup (arg);\n      break;\n\n    case ARGP_KEY_NO_ARGS:\n      libcrun_fail_with_error (0, \"please specify a ID for the container\");\n\n    default:\n      return ARGP_ERR_UNKNOWN;\n    }\n\n  return 0;\n}","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":405385,"func":"static int xfrm_policy_addr_delta(const xfrm_address_t *a,\n\t\t\t\t  const xfrm_address_t *b,\n\t\t\t\t  u8 prefixlen, u16 family)\n{\n\tu32 ma, mb, mask;\n\tunsigned int pdw, pbi;\n\tint delta = 0;\n\n\tswitch (family) {\n\tcase AF_INET:\n\t\tif (prefixlen == 0)\n\t\t\treturn 0;\n\t\tmask = ~0U << (32 - prefixlen);\n\t\tma = ntohl(a->a4) & mask;\n\t\tmb = ntohl(b->a4) & mask;\n\t\tif (ma < mb)\n\t\t\tdelta = -1;\n\t\telse if (ma > mb)\n\t\t\tdelta = 1;\n\t\tbreak;\n\tcase AF_INET6:\n\t\tpdw = prefixlen >> 5;\n\t\tpbi = prefixlen & 0x1f;\n\n\t\tif (pdw) {\n\t\t\tdelta = memcmp(a->a6, b->a6, pdw << 2);\n\t\t\tif (delta)\n\t\t\t\treturn delta;\n\t\t}\n\t\tif (pbi) {\n\t\t\tmask = ~0U << (32 - pbi);\n\t\t\tma = ntohl(a->a6[pdw]) & mask;\n\t\t\tmb = ntohl(b->a6[pdw]) & mask;\n\t\t\tif (ma < mb)\n\t\t\t\tdelta = -1;\n\t\t\telse if (ma > mb)\n\t\t\t\tdelta = 1;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn delta;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":373549,"func":"    OVS_REQUIRES(ipf->ipf_lock)\n{\n    bool duped_frag = ipf_is_frag_duped(ipf_list->frag_list,\n        ipf_list->last_inuse_idx, start_data_byte, end_data_byte);\n    int last_inuse_idx = ipf_list->last_inuse_idx;\n\n    if (!duped_frag) {\n        if (last_inuse_idx < ipf_list->size - 1) {\n            \/* In the case of dpdk, it would be unfortunate if we had\n             * to create a clone fragment outside the dpdk mp due to the\n             * mempool size being too limited. We will otherwise need to\n             * recommend not setting the mempool number of buffers too low\n             * and also clamp the number of fragments. *\/\n            struct ipf_frag *frag = &ipf_list->frag_list[last_inuse_idx + 1];\n            frag->pkt = dp_packet_clone(pkt);\n            frag->start_data_byte = start_data_byte;\n            frag->end_data_byte = end_data_byte;\n            ipf_list->last_inuse_idx++;\n            atomic_count_inc(&ipf->nfrag);\n            ipf_count(ipf, v6, IPF_NFRAGS_ACCEPTED);\n            ipf_list_state_transition(ipf, ipf_list, ff, lf, v6);\n        } else {\n            OVS_NOT_REACHED();\n        }\n    } else {\n        ipf_count(ipf, v6, IPF_NFRAGS_OVERLAP);\n        pkt->md.ct_state = CS_INVALID;\n        return false;\n    }\n    return true;\n}","target":0,"code_token_length":338,"total_token_length":574,"max_tokens_setting":1024}
+{"idx":317199,"func":"static void selinux_bprm_committed_creds(struct linux_binprm *bprm)\n{\n\tconst struct task_security_struct *tsec = selinux_cred(current_cred());\n\tu32 osid, sid;\n\tint rc;\n\n\tosid = tsec->osid;\n\tsid = tsec->sid;\n\n\tif (sid == osid)\n\t\treturn;\n\n\t\/* Check whether the new SID can inherit signal state from the old SID.\n\t * If not, clear itimers to avoid subsequent signal generation and\n\t * flush and unblock signals.\n\t *\n\t * This must occur _after_ the task SID has been updated so that any\n\t * kill done after the flush will be checked against the new SID.\n\t *\/\n\trc = avc_has_perm(&selinux_state,\n\t\t\t  osid, sid, SECCLASS_PROCESS, PROCESS__SIGINH, NULL);\n\tif (rc) {\n\t\tclear_itimer();\n\n\t\tspin_lock_irq(¤t->sighand->siglock);\n\t\tif (!fatal_signal_pending(current)) {\n\t\t\tflush_sigqueue(¤t->pending);\n\t\t\tflush_sigqueue(¤t->signal->shared_pending);\n\t\t\tflush_signal_handlers(current, 1);\n\t\t\tsigemptyset(¤t->blocked);\n\t\t\trecalc_sigpending();\n\t\t}\n\t\tspin_unlock_irq(¤t->sighand->siglock);\n\t}\n\n\t\/* Wake up the parent if it is waiting so that it can recheck\n\t * wait permission to the new task SID. *\/\n\tread_lock(&tasklist_lock);\n\t__wake_up_parent(current, current->real_parent);\n\tread_unlock(&tasklist_lock);\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":202822,"func":"search_impl(i_ctx_t *i_ctx_p, bool forward)\n{\n    os_ptr op = osp;\n    os_ptr op1 = op - 1;\n    uint size = r_size(op);\n    uint count;\n    byte *pat;\n    byte *ptr;\n    byte ch;\n    int incr = forward ? 1 : -1;\n\n    check_read_type(*op1, t_string);\n    check_read_type(*op, t_string);\n    if (size > r_size(op1)) {\t\/* can't match *\/\n        make_false(op);\n        return 0;\n    }\n    count = r_size(op1) - size;\n    ptr = op1->value.bytes;\n    if (size == 0)\n        goto found;\n    if (!forward)\n        ptr += count;\n    pat = op->value.bytes;\n    ch = pat[0];\n    do {\n        if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size)))\n            goto found;\n        ptr += incr;\n    }\n    while (count--);\n    \/* No match *\/\n    make_false(op);\n    return 0;\nfound:\n    op->tas.type_attrs = op1->tas.type_attrs;\n    op->value.bytes = ptr;\n    r_set_size(op, size);\n    push(2);\n    op[-1] = *op1;\n    r_set_size(op - 1, ptr - op[-1].value.bytes);\n    op1->value.bytes = ptr + size;\n    r_set_size(op1, count + (!forward ? (size - 1) : 0));\n    make_true(op);\n    return 0;\n}","target":1,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":261969,"func":"njs_string_slice_args(njs_vm_t *vm, njs_slice_prop_t *slice, njs_value_t *args,\n    njs_uint_t nargs)\n{\n    int64_t      start, end, length;\n    njs_int_t    ret;\n    njs_value_t  *value;\n\n    length = slice->string_length;\n\n    value = njs_arg(args, nargs, 1);\n\n    if (njs_slow_path(!njs_is_number(value))) {\n        ret = njs_value_to_integer(vm, value, &start);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n    } else {\n        start = njs_number_to_integer(njs_number(value));\n    }\n\n    if (start < 0) {\n        start += length;\n\n        if (start < 0) {\n            start = 0;\n        }\n    }\n\n    if (start >= length) {\n        start = 0;\n        length = 0;\n\n    } else {\n        value = njs_arg(args, nargs, 2);\n\n        if (njs_slow_path(!njs_is_number(value))) {\n            if (njs_is_defined(value)) {\n                ret = njs_value_to_integer(vm, value, &end);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    return ret;\n                }\n\n            } else {\n                end = length;\n            }\n\n        } else {\n            end = njs_number_to_integer(njs_number(value));\n        }\n\n        if (end < 0) {\n            end += length;\n        }\n\n        if (length >= end) {\n            length = end - start;\n\n            if (length < 0) {\n                start = 0;\n                length = 0;\n            }\n\n        } else {\n            length -= start;\n        }\n    }\n\n    slice->start = start;\n    slice->length = length;\n\n    return NJS_OK;\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":352943,"func":"csnSidNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tstruct berval\tbv;\n\tchar\t\t*ptr,\n\t\t\tbuf[ 4 ];\n\n\n\tif ( BER_BVISEMPTY( val ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX(usage) ) {\n\t\treturn sidNormalize( 0, NULL, NULL, val, normalized, ctx );\n\t}\n\n\tassert( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) != 0 );\n\n\tptr = ber_bvchr( val, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_val = ptr + 1;\n\tbv.bv_len = val->bv_len - ( ptr + 1 - val->bv_val );\n\n\tptr = ber_bvchr( &bv, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_val = ptr + 1;\n\tbv.bv_len = val->bv_len - ( ptr + 1 - val->bv_val );\n\t\t\n\tptr = ber_bvchr( &bv, '#' );\n\tif ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_len = ptr - bv.bv_val;\n\n\tif ( bv.bv_len == 2 ) {\n\t\t\/* OpenLDAP 2.3 SID *\/\n\t\tbuf[ 0 ] = '0';\n\t\tbuf[ 1 ] = bv.bv_val[ 0 ];\n\t\tbuf[ 2 ] = bv.bv_val[ 1 ];\n\t\tbuf[ 3 ] = '\\0';\n\n\t\tbv.bv_val = buf;\n\t\tbv.bv_len = 3;\n\t}\n\n\treturn sidNormalize( 0, NULL, NULL, &bv, normalized, ctx );\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":477300,"func":"static int tipc_aead_clone(struct tipc_aead **dst, struct tipc_aead *src)\n{\n\tstruct tipc_aead *aead;\n\tint cpu;\n\n\tif (!src)\n\t\treturn -ENOKEY;\n\n\tif (src->mode != CLUSTER_KEY)\n\t\treturn -EINVAL;\n\n\tif (unlikely(*dst))\n\t\treturn -EEXIST;\n\n\taead = kzalloc(sizeof(*aead), GFP_ATOMIC);\n\tif (unlikely(!aead))\n\t\treturn -ENOMEM;\n\n\taead->tfm_entry = alloc_percpu_gfp(struct tipc_tfm *, GFP_ATOMIC);\n\tif (unlikely(!aead->tfm_entry)) {\n\t\tkfree_sensitive(aead);\n\t\treturn -ENOMEM;\n\t}\n\n\tfor_each_possible_cpu(cpu) {\n\t\t*per_cpu_ptr(aead->tfm_entry, cpu) =\n\t\t\t\t*per_cpu_ptr(src->tfm_entry, cpu);\n\t}\n\n\tmemcpy(aead->hint, src->hint, sizeof(src->hint));\n\taead->mode = src->mode;\n\taead->salt = src->salt;\n\taead->authsize = src->authsize;\n\tatomic_set(&aead->users, 0);\n\tatomic64_set(&aead->seqno, 0);\n\trefcount_set(&aead->refcnt, 1);\n\n\tWARN_ON(!refcount_inc_not_zero(&src->refcnt));\n\taead->cloned = src;\n\n\t*dst = aead;\n\treturn 0;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":273074,"func":"keyval_sort(struct keyval *kv)\n{\n  struct onekeyval *head;\n  struct onekeyval *okv;\n  struct onekeyval *sokv;\n\n  if (!kv || !kv->head)\n    return;\n\n  head = kv->head;\n  for (okv = kv->head; okv; okv = okv->next)\n    {\n      okv->sort = NULL;\n      for (sokv = kv->head; sokv; sokv = sokv->next)\n\t{\n\t  \/\/ We try to find a name which is greater than okv->name\n\t  \/\/ but less than our current candidate (okv->sort->name)\n\t  if ( (strcmp(sokv->name, okv->name) > 0) &&\n\t       ((okv->sort == NULL) || (strcmp(sokv->name, okv->sort->name) < 0)) )\n\t    okv->sort = sokv;\n\t}\n\n      \/\/ Find smallest name, which will be the new head\n      if (strcmp(okv->name, head->name) < 0)\n\thead = okv;\n    }\n\n  while ((okv = kv->head))\n    {\n      kv->head  = okv->next;\n      okv->next = okv->sort;\n    }\n\n  kv->head = head;\n  for (okv = kv->head; okv; okv = okv->next)\n    kv->tail = okv;\n\n  DPRINTF(E_DBG, L_MISC, \"Keyval sorted. New head: %s. New tail: %s.\\n\", kv->head->name, kv->tail->name);\n}","target":0,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":252464,"func":"static bool DecompressZfp(float *dst, int dst_width, int dst_num_lines,\n                          int num_channels, const unsigned char *src,\n                          unsigned long src_size,\n                          const ZFPCompressionParam ¶m) {\n  size_t uncompressed_size = dst_width * dst_num_lines * num_channels;\n\n  if (uncompressed_size == src_size) {\n    \/\/ Data is not compressed(Issue 40).\n    memcpy(dst, src, src_size);\n  }\n\n  zfp_stream *zfp = NULL;\n  zfp_field *field = NULL;\n\n  assert((dst_width % 4) == 0);\n  assert((dst_num_lines % 4) == 0);\n\n  if ((dst_width & 3U) || (dst_num_lines & 3U)) {\n    return false;\n  }\n\n  field =\n      zfp_field_2d(reinterpret_cast<void *>(const_cast<unsigned char *>(src)),\n                   zfp_type_float, dst_width, dst_num_lines * num_channels);\n  zfp = zfp_stream_open(NULL);\n\n  if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) {\n    zfp_stream_set_rate(zfp, param.rate, zfp_type_float, \/* dimention *\/ 2,\n                        \/* write random access *\/ 0);\n  } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) {\n    zfp_stream_set_precision(zfp, param.precision, zfp_type_float);\n  } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) {\n    zfp_stream_set_accuracy(zfp, param.tolerance, zfp_type_float);\n  } else {\n    assert(0);\n  }\n\n  size_t buf_size = zfp_stream_maximum_size(zfp, field);\n  std::vector<unsigned char> buf(buf_size);\n  memcpy(&buf.at(0), src, src_size);\n\n  bitstream *stream = stream_open(&buf.at(0), buf_size);\n  zfp_stream_set_bit_stream(zfp, stream);\n  zfp_stream_rewind(zfp);\n\n  size_t image_size = dst_width * dst_num_lines;\n\n  for (int c = 0; c < num_channels; c++) {\n    \/\/ decompress 4x4 pixel block.\n    for (int y = 0; y < dst_num_lines; y += 4) {\n      for (int x = 0; x < dst_width; x += 4) {\n        float fblock[16];\n        zfp_decode_block_float_2(zfp, fblock);\n        for (int j = 0; j < 4; j++) {\n          for (int i = 0; i < 4; i++) {\n            dst[c * image_size + ((y + j) * dst_width + (x + i))] =\n                fblock[j * 4 + i];\n          }\n        }\n      }\n    }\n  }\n\n  zfp_field_free(field);\n  zfp_stream_close(zfp);\n  stream_close(stream);\n\n  return true;\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":458987,"func":"http_DoConnection(struct http *hp, stream_close_t sc_close)\n{\n\tconst char *h, *b, *e;\n\tstream_close_t retval;\n\tunsigned u, v;\n\tstruct http_hdrflg *f;\n\n\tCHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);\n\tassert(sc_close == SC_REQ_CLOSE || sc_close == SC_RESP_CLOSE);\n\n\tif (hp->protover == 10)\n\t\tretval = SC_REQ_HTTP10;\n\telse\n\t\tretval = SC_NULL;\n\n\thttp_CollectHdr(hp, H_Connection);\n\tif (!http_GetHdr(hp, H_Connection, &h))\n\t\treturn (retval);\n\tAN(h);\n\twhile (http_split(&h, NULL, \",\", &b, &e)) {\n\t\tu = pdiff(b, e);\n\t\tif (u == 5 && http_hdr_at(b, \"close\", u))\n\t\t\tretval = sc_close;\n\t\tif (u == 10 && http_hdr_at(b, \"keep-alive\", u))\n\t\t\tretval = SC_NULL;\n\n\t\t\/* Refuse removal of well-known-headers if they would pass. *\/\n\t\tf = http_hdr_flags(b, e);\n\t\tif (f != NULL && !(f->flag & HTTPH_R_PASS))\n\t\t\treturn (SC_RX_BAD);\n\n\t\tfor (v = HTTP_HDR_FIRST; v < hp->nhd; v++) {\n\t\t\tTcheck(hp->hd[v]);\n\t\t\tif (hp->hd[v].e < hp->hd[v].b + u + 1)\n\t\t\t\tcontinue;\n\t\t\tif (hp->hd[v].b[u] != ':')\n\t\t\t\tcontinue;\n\t\t\tif (!http_hdr_at(b, hp->hd[v].b, u))\n\t\t\t\tcontinue;\n\t\t\thp->hdf[v] |= HDF_FILTER;\n\t\t}\n\t}\n\tCHECK_OBJ_NOTNULL(retval, STREAM_CLOSE_MAGIC);\n\treturn (retval);\n}","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":437304,"func":"print_optimize_info(FILE* f, regex_t* reg)\n{\n  static const char* on[] = { \"NONE\", \"EXACT\",\n                              \"EXACT_FAST\", \"EXACT_FAST_STEP_FORWARD\",\n                              \"EXACT_IC\", \"MAP\" };\n\n  fprintf(f, \"optimize: %s\\n\", on[reg->optimize]);\n  fprintf(f, \"  anchor: \"); print_anchor(f, reg->anchor);\n  if ((reg->anchor & ANCHOR_END_BUF_MASK) != 0)\n    print_distance_range(f, reg->anchor_dmin, reg->anchor_dmax);\n  fprintf(f, \"\\n\");\n\n  if (reg->optimize) {\n    fprintf(f, \"  sub anchor: \"); print_anchor(f, reg->sub_anchor);\n    fprintf(f, \"\\n\");\n  }\n  fprintf(f, \"\\n\");\n\n  if (reg->exact) {\n    UChar *p;\n    fprintf(f, \"exact: [\");\n    for (p = reg->exact; p < reg->exact_end; p++) {\n      fputc(*p, f);\n    }\n    fprintf(f, \"]: length: %ld\\n\", (reg->exact_end - reg->exact));\n  }\n  else if (reg->optimize & OPTIMIZE_MAP) {\n    int c, i, n = 0;\n\n    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)\n      if (reg->map[i]) n++;\n\n    fprintf(f, \"map: n=%d\\n\", n);\n    if (n > 0) {\n      c = 0;\n      fputc('[', f);\n      for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {\n        if (reg->map[i] != 0) {\n          if (c > 0)  fputs(\", \", f);\n          c++;\n          if (ONIGENC_MBC_MAXLEN(reg->enc) == 1 &&\n              ONIGENC_IS_CODE_PRINT(reg->enc, (OnigCodePoint )i))\n            fputc(i, f);\n          else\n            fprintf(f, \"%d\", i);\n        }\n      }\n      fprintf(f, \"]\\n\");\n    }\n  }\n}","target":0,"code_token_length":459,"total_token_length":695,"max_tokens_setting":1024}
+{"idx":333508,"func":"int gdTransformAffineGetImage(gdImagePtr *dst,\n\t\t  const gdImagePtr src,\n\t\t  gdRectPtr src_area,\n\t\t  const double affine[6])\n{\n\tint res;\n\tdouble m[6];\n\tgdRect bbox;\n\tgdRect area_full;\n\n\tif (src_area == NULL) {\n\t\tarea_full.x = 0;\n\t\tarea_full.y = 0;\n\t\tarea_full.width  = gdImageSX(src);\n\t\tarea_full.height = gdImageSY(src);\n\t\tsrc_area = &area_full;\n\t}\n\n\tgdTransformAffineBoundingBox(src_area, affine, &bbox);\n\n\t*dst = gdImageCreateTrueColor(bbox.width, bbox.height);\n\tif (*dst == NULL) {\n\t\treturn GD_FALSE;\n\t}\n\t(*dst)->saveAlphaFlag = 1;\n\n\tif (!src->trueColor) {\n\t\tgdImagePaletteToTrueColor(src);\n\t}\n\n\t\/* Translate to dst origin (0,0) *\/\n\tgdAffineTranslate(m, -bbox.x, -bbox.y);\n\tgdAffineConcat(m, affine, m);\n\n\tgdImageAlphaBlending(*dst, 0);\n\n\tres = gdTransformAffineCopy(*dst,\n\t\t  0,0,\n\t\t  src,\n\t\t  src_area,\n\t\t  m);\n\n\tif (res != GD_TRUE) {\n\t\tgdImageDestroy(*dst);\n\t\tdst = NULL;\n\t\treturn GD_FALSE;\n\t} else {\n\t\treturn GD_TRUE;\n\t}\n}","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":292153,"func":"void LinkResolver::check_klass_accessability(Klass* ref_klass, Klass* sel_klass,\n                                             bool fold_type_to_class, TRAPS) {\n  Klass* base_klass = sel_klass;\n  if (fold_type_to_class) {\n    if (sel_klass->is_objArray_klass()) {\n      base_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();\n    }\n    \/\/ The element type could be a typeArray - we only need the access\n    \/\/ check if it is a reference to another class.\n    if (!base_klass->is_instance_klass()) {\n      return;  \/\/ no relevant check to do\n    }\n  }\n  Reflection::VerifyClassAccessResults vca_result =\n    Reflection::verify_class_access(ref_klass, InstanceKlass::cast(base_klass), true);\n  if (vca_result != Reflection::ACCESS_OK) {\n    ResourceMark rm(THREAD);\n    char* msg = Reflection::verify_class_access_msg(ref_klass,\n                                                    InstanceKlass::cast(base_klass),\n                                                    vca_result);\n    bool same_module = (base_klass->module() == ref_klass->module());\n    if (msg == NULL) {\n      Exceptions::fthrow(\n        THREAD_AND_LOCATION,\n        vmSymbols::java_lang_IllegalAccessError(),\n        \"failed to access class %s from class %s (%s%s%s)\",\n        base_klass->external_name(),\n        ref_klass->external_name(),\n        (same_module) ? base_klass->joint_in_module_of_loader(ref_klass) : base_klass->class_in_module_of_loader(),\n        (same_module) ? \"\" : \"; \",\n        (same_module) ? \"\" : ref_klass->class_in_module_of_loader());\n    } else {\n      \/\/ Use module specific message returned by verify_class_access_msg().\n      Exceptions::fthrow(\n        THREAD_AND_LOCATION,\n        vmSymbols::java_lang_IllegalAccessError(),\n        \"%s\", msg);\n    }\n  }\n}","target":0,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":240589,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& value = context->input(1);\n    core::RefCountPtr<Var> variable;\n    OP_REQUIRES_OK(context, LookupOrCreateResource<Var>(\n                                context, HandleFromInput(context, 0), &variable,\n                                [](Var** ptr) {\n                                  \/\/ Created on host.\n                                  *ptr = new Var(DT_VARIANT);\n                                  return Status::OK();\n                                }));\n\n    \/\/ For purposes of forwarding DT_VARIANT, we want the least\n    \/\/ restrictive attr; we already know the input is on host.\n    AllocatorAttributes attr;\n\n    \/\/ Copying is unnecessary if we are the last user of the value\n    \/\/ tensor, we can just adopt the input tensor's buffer instead.\n    \/\/ Note that Variant objects themselves always reside on host.\n    \/\/\n    \/\/ We nevertheless want to signal to the runtime that the tensor\n    \/\/ should reside in memory of the associated device, as Variant\n    \/\/ tensors may be marked as sitting on either CPU or GPU.  This\n    \/\/ helps to elide one or more copies.\n    std::unique_ptr<Tensor> input_alias = context->forward_input(\n        1, OpKernelContext::Params::kNoReservation \/*output_index*\/, DT_VARIANT,\n        value.shape(),\n        DEVICE_MEMORY \/* HOST_MEMORY is only reserved for special cases *\/,\n        attr);\n\n    mutex_lock ml(*variable->mu());\n    OP_REQUIRES(context, variable->tensor()->dtype() == DT_VARIANT,\n                errors::InvalidArgument(\n                    \"Trying to assign variable with wrong dtype. Expected \",\n                    DataTypeString(variable->tensor()->dtype()), \" got \",\n                    DataTypeString(DT_VARIANT)));\n    variable->is_initialized = true;\n    *variable->tensor() = Tensor(DT_VARIANT, value.shape());\n\n    if (input_alias) {\n      *variable->tensor() = *input_alias;\n      return;\n    }\n\n    \/\/ Need to copy, but maybe we can re-use variable's buffer?\n    if (!variable->tensor()->RefCountIsOne() ||\n        !variable->tensor()->shape().IsSameSize(value.shape())) {\n      \/\/ Allocation of DT_VARIANT is always on host.\n      attr.set_on_host(true);\n      OP_REQUIRES_OK(context, context->allocate_temp(DT_VARIANT, value.shape(),\n                                                     variable->tensor(), attr));\n    }\n\n    const auto elements_in = value.flat<Variant>();\n    auto elements_out = variable->tensor()->flat<Variant>();\n    for (int64_t i = 0; i < elements_in.size(); ++i) {\n      elements_out(i) = elements_in(i);\n    }\n  }","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":255783,"func":"svn_repos_authz_check_access(svn_authz_t *authz, const char *repos_name,\n                             const char *path, const char *user,\n                             svn_repos_authz_access_t required_access,\n                             svn_boolean_t *access_granted,\n                             apr_pool_t *pool)\n{\n  const authz_access_t required =\n    ((required_access & svn_authz_read ? authz_access_read_flag : 0)\n     | (required_access & svn_authz_write ? authz_access_write_flag : 0));\n\n  \/* Pick or create the suitable pre-filtered path rule tree. *\/\n  authz_user_rules_t *rules = get_user_rules(\n      authz,\n      (repos_name ? repos_name : AUTHZ_ANY_REPOSITORY),\n      user);\n\n  \/* In many scenarios, users have uniform access to a repository\n   * (blanket access or no access at all).\n   *\n   * In these cases, don't bother creating or consulting the filtered tree.\n   *\/\n  if ((rules->global_rights.min_access & required) == required)\n    {\n      *access_granted = TRUE;\n      return SVN_NO_ERROR;\n    }\n\n  if ((rules->global_rights.max_access & required) != required)\n    {\n      *access_granted = FALSE;\n      return SVN_NO_ERROR;\n    }\n\n  \/* No specific path given, i.e. looking for anywhere in the tree? *\/\n  if (!path)\n    {\n      *access_granted =\n        ((rules->global_rights.max_access & required) == required);\n      return SVN_NO_ERROR;\n    }\n\n  \/* Rules tree lookup *\/\n\n  \/* Did we already filter the data model? *\/\n  if (!rules->root)\n    SVN_ERR(filter_tree(authz, pool));\n\n  \/* Re-use previous lookup results, if possible. *\/\n  path = init_lockup_state(authz->filtered->lookup_state,\n                           authz->filtered->root, path);\n\n  \/* Sanity check. *\/\n  SVN_ERR_ASSERT(path[0] == '\/');\n\n  \/* Determine the granted access for the requested path.\n   * PATH does not need to be normalized for lockup(). *\/\n  *access_granted = lookup(rules->lookup_state, path, required,\n                           !!(required_access & svn_authz_recursive), pool);\n\n  return SVN_NO_ERROR;\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":447054,"func":"    void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, long from, long to)\n    {\n        std::string scriptPath(getEnv(envHTTPPOST));\n        if (scriptPath == \"\") {\n            throw Error(1, \"Please set the path of the server script to handle http post data to EXIV2_HTTP_POST environmental variable.\");\n        }\n\n        \/\/ standadize the path without \"\/\" at the beginning.\n        std::size_t protocolIndex = scriptPath.find(\":\/\/\");\n        if (protocolIndex == std::string::npos && scriptPath[0] != '\/') {\n            scriptPath = \"\/\" + scriptPath;\n        }\n\n        Exiv2::Dictionary response;\n        Exiv2::Dictionary request;\n        std::string errors;\n\n        Uri scriptUri = Exiv2::Uri::Parse(scriptPath);\n        request[\"server\"] = scriptUri.Host == \"\" ? hostInfo_.Host : scriptUri.Host;\n        if (scriptUri.Port != \"\") request[\"port\"] = scriptUri.Port;\n        request[\"page\"] = scriptUri.Path;\n        request[\"verb\"] = \"POST\";\n\n        \/\/ encode base64\n        size_t encodeLength = ((size + 2) \/ 3) * 4 + 1;\n        char* encodeData = new char[encodeLength];\n        base64encode(data, size, encodeData, encodeLength);\n        \/\/ url encode\n        char* urlencodeData = urlencode(encodeData);\n        delete[] encodeData;\n\n        std::stringstream ss;\n        ss << \"path=\"   << hostInfo_.Path << \"&\"\n           << \"from=\"   << from           << \"&\"\n           << \"to=\"     << to             << \"&\"\n           << \"data=\"   << urlencodeData;\n        std::string postData = ss.str();\n        delete[] urlencodeData;\n\n        \/\/ create the header\n        ss.str(\"\");\n        ss << \"Content-Length: \" << postData.length()  << \"\\n\"\n           << \"Content-Type: application\/x-www-form-urlencoded\\n\"\n           << \"\\n\" << postData << \"\\r\\n\";\n        request[\"header\"] = ss.str();\n\n        int serverCode = http(request, response, errors);\n        if (serverCode < 0 || serverCode >= 400 || errors.compare(\"\") != 0) {\n            throw Error(55, \"Server\", serverCode);\n        }\n    }","target":0,"code_token_length":494,"total_token_length":730,"max_tokens_setting":1024}
+{"idx":513188,"func":"void plugin_thdvar_init(THD *thd)\n{\n  plugin_ref old_table_plugin= thd->variables.table_plugin;\n  plugin_ref old_tmp_table_plugin= thd->variables.tmp_table_plugin;\n  plugin_ref old_enforced_table_plugin= thd->variables.enforced_table_plugin;\n  DBUG_ENTER(\"plugin_thdvar_init\");\n\n  \/\/ This function may be called many times per THD (e.g. on COM_CHANGE_USER)\n  thd->variables.table_plugin= NULL;\n  thd->variables.tmp_table_plugin= NULL;\n  thd->variables.enforced_table_plugin= NULL;\n  cleanup_variables(&thd->variables);\n\n  thd->variables= global_system_variables;\n\n  \/* we are going to allocate these lazily *\/\n  thd->variables.dynamic_variables_version= 0;\n  thd->variables.dynamic_variables_size= 0;\n  thd->variables.dynamic_variables_ptr= 0;\n\n  mysql_mutex_lock(&LOCK_plugin);\n  thd->variables.table_plugin=\n      intern_plugin_lock(NULL, global_system_variables.table_plugin);\n  if (global_system_variables.tmp_table_plugin)\n    thd->variables.tmp_table_plugin=\n          intern_plugin_lock(NULL, global_system_variables.tmp_table_plugin);\n  if (global_system_variables.enforced_table_plugin)\n    thd->variables.enforced_table_plugin=\n          intern_plugin_lock(NULL, global_system_variables.enforced_table_plugin);\n  intern_plugin_unlock(NULL, old_table_plugin);\n  intern_plugin_unlock(NULL, old_tmp_table_plugin);\n  intern_plugin_unlock(NULL, old_enforced_table_plugin);\n  mysql_mutex_unlock(&LOCK_plugin);\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":314517,"func":"PJ_DEF(pjmedia_sdp_media*) pjmedia_sdp_media_clone_deactivate(\n\t\t\t\t\t\tpj_pool_t *pool,\n\t\t\t\t\t\tconst pjmedia_sdp_media *rhs)\n{\n    unsigned int i;\n    pjmedia_sdp_media *m;\n\n    PJ_ASSERT_RETURN(pool && rhs, NULL);\n\n    m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);\n    pj_memcpy(m, rhs, sizeof(*m));\n\n    \/* Clone the media line only *\/\n    pj_strdup (pool, &m->desc.media, &rhs->desc.media);\n    pj_strdup (pool, &m->desc.transport, &rhs->desc.transport);\n    for (i=0; i<rhs->desc.fmt_count; ++i)\n\tpj_strdup(pool, &m->desc.fmt[i], &rhs->desc.fmt[i]);\n\n    if (rhs->conn) {\n\tm->conn = pjmedia_sdp_conn_clone (pool, rhs->conn);\n\tPJ_ASSERT_RETURN(m->conn != NULL, NULL);\n    }\n\n    m->bandw_count = rhs->bandw_count;\n    for (i=0; i < rhs->bandw_count; ++i) {\n\tm->bandw[i] = pjmedia_sdp_bandw_clone (pool, rhs->bandw[i]);\n\tPJ_ASSERT_RETURN(m->bandw[i] != NULL, NULL);\n    }\n\n    \/* And deactivate it *\/\n    pjmedia_sdp_media_deactivate(pool, m);\n\n    return m;\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":463106,"func":"static int _annotate_getdb(const char *mboxname,\n                           unsigned int uid,\n                           int dbflags,\n                           annotate_db_t **dbp)\n{\n    annotate_db_t *d, *prev = NULL;\n    char *fname = NULL;\n    struct db *db;\n    int r;\n\n    *dbp = NULL;\n\n    \/*\n     * The incoming (mboxname,uid) tuple tells us which scope we\n     * need a database for.  Translate into the mboxname used to\n     * key annotate_db_t's, which is slightly different: message\n     * scope goes into a per-mailbox db, others in the global db.\n     *\/\n    if (!strcmpsafe(mboxname, NULL) \/*server scope*\/ ||\n        !uid \/* mailbox scope*\/)\n        mboxname = NULL;\n\n    \/* try to find an existing db for the mbox *\/\n    for (d = all_dbs_head ; d ; prev = d, d = d->next) {\n        if (!strcmpsafe(mboxname, d->mboxname)) {\n            \/* found it, bump the refcount *\/\n            d->refcount++;\n            *dbp = d;\n            \/*\n             * Splay the db_t to the end of the global list.\n             * This ensures the list remains in getdb() call\n             * order, and in particular that the dbs are\n             * committed in getdb() call order.  This is\n             * necessary to ensure safety should a commit fail\n             * while moving annotations between per-mailbox dbs\n             *\/\n            detach_db(prev, d);\n            append_db(d);\n            return 0;\n        }\n    }\n    \/* not found, open\/create a new one *\/\n\n    r = annotate_dbname(mboxname, &fname);\n    if (r)\n        goto error;\n#if DEBUG\n    syslog(LOG_ERR, \"Opening annotations db %s\\n\", fname);\n#endif\n\n    r = cyrusdb_open(DB, fname, dbflags | CYRUSDB_CONVERT, &db);\n    if (r != 0) {\n        if (!(dbflags & CYRUSDB_CREATE) && r == CYRUSDB_NOTFOUND)\n            goto error;\n        syslog(LOG_ERR, \"DBERROR: opening %s: %s\",\n                        fname, cyrusdb_strerror(r));\n        goto error;\n    }\n\n    \/* record all the above *\/\n    d = xzmalloc(sizeof(*d));\n    d->refcount = 1;\n    d->mboxname = xstrdupnull(mboxname);\n    d->filename = fname;\n    d->db = db;\n\n    append_db(d);\n\n    *dbp = d;\n    return 0;\n\nerror:\n    free(fname);\n    *dbp = NULL;\n    return r;\n}","target":0,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":512759,"func":"int Arg_comparator::compare_row()\n{\n  int res= 0;\n  bool was_null= 0;\n  (*a)->bring_value();\n  (*b)->bring_value();\n\n  if ((*a)->null_value || (*b)->null_value)\n  {\n    owner->null_value= 1;\n    return -1;\n  }\n\n  uint n= (*a)->cols();\n  for (uint i= 0; i<n; i++)\n  {\n    res= comparators[i].compare();\n    \/* Aggregate functions don't need special null handling. *\/\n    if (owner->null_value && owner->type() == Item::FUNC_ITEM)\n    {\n      \/\/ NULL was compared\n      switch (((Item_func*)owner)->functype()) {\n      case Item_func::NE_FUNC:\n        break; \/\/ NE never aborts on NULL even if abort_on_null is set\n      case Item_func::LT_FUNC:\n      case Item_func::LE_FUNC:\n      case Item_func::GT_FUNC:\n      case Item_func::GE_FUNC:\n        return -1; \/\/ <, <=, > and >= always fail on NULL\n      case Item_func::EQ_FUNC:\n        if (((Item_func_eq*)owner)->abort_on_null)\n          return -1; \/\/ We do not need correct NULL returning\n        break;\n      default:\n        DBUG_ASSERT(0);\n        break;\n      }\n      was_null= 1;\n      owner->null_value= 0;\n      res= 0;  \/\/ continue comparison (maybe we will meet explicit difference)\n    }\n    else if (res)\n      return res;\n  }\n  if (was_null)\n  {\n    \/*\n      There was NULL(s) in comparison in some parts, but there was no\n      explicit difference in other parts, so we have to return NULL.\n    *\/\n    owner->null_value= 1;\n    return -1;\n  }\n  return 0;\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":364743,"func":"findtags_in_help_init(findtags_state_T *st)\n{\n    int\t\ti;\n    char_u\t*s;\n\n    \/\/ Keep 'en' as the language if the file extension is '.txt'\n    if (st->is_txt)\n\tSTRCPY(st->help_lang, \"en\");\n    else\n    {\n\t\/\/ Prefer help tags according to 'helplang'.  Put the two-letter\n\t\/\/ language name in help_lang[].\n\ti = (int)STRLEN(st->tag_fname);\n\tif (i > 3 && st->tag_fname[i - 3] == '-')\n\t    vim_strncpy(st->help_lang, st->tag_fname + i - 2, 2);\n\telse\n\t    STRCPY(st->help_lang, \"en\");\n    }\n    \/\/ When searching for a specific language skip tags files for other\n    \/\/ languages.\n    if (st->help_lang_find != NULL\n\t    && STRICMP(st->help_lang, st->help_lang_find) != 0)\n\treturn FALSE;\n\n    \/\/ For CTRL-] in a help file prefer a match with the same language.\n    if ((st->flags & TAG_KEEP_LANG)\n\t    && st->help_lang_find == NULL\n\t    && curbuf->b_fname != NULL\n\t    && (i = (int)STRLEN(curbuf->b_fname)) > 4\n\t    && curbuf->b_fname[i - 1] == 'x'\n\t    && curbuf->b_fname[i - 4] == '.'\n\t    && STRNICMP(curbuf->b_fname + i - 3, st->help_lang, 2) == 0)\n\tst->help_pri = 0;\n    else\n    {\n\t\/\/ search for the language in 'helplang'\n\tst->help_pri = 1;\n\tfor (s = p_hlg; *s != NUL; ++s)\n\t{\n\t    if (STRNICMP(s, st->help_lang, 2) == 0)\n\t\tbreak;\n\t    ++st->help_pri;\n\t    if ((s = vim_strchr(s, ',')) == NULL)\n\t\tbreak;\n\t}\n\tif (s == NULL || *s == NUL)\n\t{\n\t    \/\/ Language not in 'helplang': use last, prefer English, unless\n\t    \/\/ found already.\n\t    ++st->help_pri;\n\t    if (STRICMP(st->help_lang, \"en\") != 0)\n\t\t++st->help_pri;\n\t}\n    }\n\n    return TRUE;\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":207803,"func":"void add_interrupt_randomness(int irq, int irq_flags)\n{\n\tstruct entropy_store\t*r;\n\tstruct fast_pool\t*fast_pool = this_cpu_ptr(&irq_randomness);\n\tstruct pt_regs\t\t*regs = get_irq_regs();\n\tunsigned long\t\tnow = jiffies;\n\tcycles_t\t\tcycles = random_get_entropy();\n\t__u32\t\t\tc_high, j_high;\n\t__u64\t\t\tip;\n\tunsigned long\t\tseed;\n\tint\t\t\tcredit = 0;\n\n\tif (cycles == 0)\n\t\tcycles = get_reg(fast_pool, regs);\n\tc_high = (sizeof(cycles) > 4) ? cycles >> 32 : 0;\n\tj_high = (sizeof(now) > 4) ? now >> 32 : 0;\n\tfast_pool->pool[0] ^= cycles ^ j_high ^ irq;\n\tfast_pool->pool[1] ^= now ^ c_high;\n\tip = regs ? instruction_pointer(regs) : _RET_IP_;\n\tfast_pool->pool[2] ^= ip;\n\tfast_pool->pool[3] ^= (sizeof(ip) > 4) ? ip >> 32 :\n\t\tget_reg(fast_pool, regs);\n\n\tfast_mix(fast_pool);\n\tadd_interrupt_bench(cycles);\n\n\tif (unlikely(crng_init == 0)) {\n\t\tif ((fast_pool->count >= 64) &&\n\t\t    crng_fast_load((char *) fast_pool->pool,\n\t\t\t\t   sizeof(fast_pool->pool))) {\n\t\t\tfast_pool->count = 0;\n\t\t\tfast_pool->last = now;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ((fast_pool->count < 64) &&\n\t    !time_after(now, fast_pool->last + HZ))\n\t\treturn;\n\n\tr = &input_pool;\n\tif (!spin_trylock(&r->lock))\n\t\treturn;\n\n\tfast_pool->last = now;\n\t__mix_pool_bytes(r, &fast_pool->pool, sizeof(fast_pool->pool));\n\n\t\/*\n\t * If we have architectural seed generator, produce a seed and\n\t * add it to the pool.  For the sake of paranoia don't let the\n\t * architectural seed generator dominate the input from the\n\t * interrupt noise.\n\t *\/\n\tif (arch_get_random_seed_long(&seed)) {\n\t\t__mix_pool_bytes(r, &seed, sizeof(seed));\n\t\tcredit = 1;\n\t}\n\tspin_unlock(&r->lock);\n\n\tfast_pool->count = 0;\n\n\t\/* award one bit for the contents of the fast pool *\/\n\tcredit_entropy_bits(r, credit + 1);\n}","target":1,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":369196,"func":"\nstatic int __io_sqe_buffers_update(struct io_ring_ctx *ctx,\n\t\t\t\t   struct io_uring_rsrc_update2 *up,\n\t\t\t\t   unsigned int nr_args)\n{\n\tu64 __user *tags = u64_to_user_ptr(up->tags);\n\tstruct iovec iov, __user *iovs = u64_to_user_ptr(up->data);\n\tstruct page *last_hpage = NULL;\n\tbool needs_switch = false;\n\t__u32 done;\n\tint i, err;\n\n\tif (!ctx->buf_data)\n\t\treturn -ENXIO;\n\tif (up->offset + nr_args > ctx->nr_user_bufs)\n\t\treturn -EINVAL;\n\n\tfor (done = 0; done < nr_args; done++) {\n\t\tstruct io_mapped_ubuf *imu;\n\t\tint offset = up->offset + done;\n\t\tu64 tag = 0;\n\n\t\terr = io_copy_iov(ctx, &iov, iovs, done);\n\t\tif (err)\n\t\t\tbreak;\n\t\tif (tags && copy_from_user(&tag, &tags[done], sizeof(tag))) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\terr = io_buffer_validate(&iov);\n\t\tif (err)\n\t\t\tbreak;\n\t\tif (!iov.iov_base && tag) {\n\t\t\terr = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\terr = io_sqe_buffer_register(ctx, &iov, &imu, &last_hpage);\n\t\tif (err)\n\t\t\tbreak;\n\n\t\ti = array_index_nospec(offset, ctx->nr_user_bufs);\n\t\tif (ctx->user_bufs[i] != ctx->dummy_ubuf) {\n\t\t\terr = io_queue_rsrc_removal(ctx->buf_data, i,\n\t\t\t\t\t\t    ctx->rsrc_node, ctx->user_bufs[i]);\n\t\t\tif (unlikely(err)) {\n\t\t\t\tio_buffer_unmap(ctx, &imu);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tctx->user_bufs[i] = NULL;\n\t\t\tneeds_switch = true;\n\t\t}\n\n\t\tctx->user_bufs[i] = imu;\n\t\t*io_get_tag_slot(ctx->buf_data, offset) = tag;\n\t}\n\n\tif (needs_switch)\n\t\tio_rsrc_node_switch(ctx, ctx->buf_data);\n\treturn done ? done : err;","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":366319,"func":"int path_mount(const char *dev_name, struct path *path,\n\t\tconst char *type_page, unsigned long flags, void *data_page)\n{\n\tunsigned int mnt_flags = 0, sb_flags;\n\tint ret;\n\n\t\/* Discard magic *\/\n\tif ((flags & MS_MGC_MSK) == MS_MGC_VAL)\n\t\tflags &= ~MS_MGC_MSK;\n\n\t\/* Basic sanity checks *\/\n\tif (data_page)\n\t\t((char *)data_page)[PAGE_SIZE - 1] = 0;\n\n\tif (flags & MS_NOUSER)\n\t\treturn -EINVAL;\n\n\tret = security_sb_mount(dev_name, path, type_page, flags, data_page);\n\tif (ret)\n\t\treturn ret;\n\tif (!may_mount())\n\t\treturn -EPERM;\n\tif ((flags & SB_MANDLOCK) && !may_mandlock())\n\t\treturn -EPERM;\n\n\t\/* Default to relatime unless overriden *\/\n\tif (!(flags & MS_NOATIME))\n\t\tmnt_flags |= MNT_RELATIME;\n\n\t\/* Separate the per-mountpoint flags *\/\n\tif (flags & MS_NOSUID)\n\t\tmnt_flags |= MNT_NOSUID;\n\tif (flags & MS_NODEV)\n\t\tmnt_flags |= MNT_NODEV;\n\tif (flags & MS_NOEXEC)\n\t\tmnt_flags |= MNT_NOEXEC;\n\tif (flags & MS_NOATIME)\n\t\tmnt_flags |= MNT_NOATIME;\n\tif (flags & MS_NODIRATIME)\n\t\tmnt_flags |= MNT_NODIRATIME;\n\tif (flags & MS_STRICTATIME)\n\t\tmnt_flags &= ~(MNT_RELATIME | MNT_NOATIME);\n\tif (flags & MS_RDONLY)\n\t\tmnt_flags |= MNT_READONLY;\n\tif (flags & MS_NOSYMFOLLOW)\n\t\tmnt_flags |= MNT_NOSYMFOLLOW;\n\n\t\/* The default atime for remount is preservation *\/\n\tif ((flags & MS_REMOUNT) &&\n\t    ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME |\n\t\t       MS_STRICTATIME)) == 0)) {\n\t\tmnt_flags &= ~MNT_ATIME_MASK;\n\t\tmnt_flags |= path->mnt->mnt_flags & MNT_ATIME_MASK;\n\t}\n\n\tsb_flags = flags & (SB_RDONLY |\n\t\t\t    SB_SYNCHRONOUS |\n\t\t\t    SB_MANDLOCK |\n\t\t\t    SB_DIRSYNC |\n\t\t\t    SB_SILENT |\n\t\t\t    SB_POSIXACL |\n\t\t\t    SB_LAZYTIME |\n\t\t\t    SB_I_VERSION);\n\n\tif ((flags & (MS_REMOUNT | MS_BIND)) == (MS_REMOUNT | MS_BIND))\n\t\treturn do_reconfigure_mnt(path, mnt_flags);\n\tif (flags & MS_REMOUNT)\n\t\treturn do_remount(path, flags, sb_flags, mnt_flags, data_page);\n\tif (flags & MS_BIND)\n\t\treturn do_loopback(path, dev_name, flags & MS_REC);\n\tif (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))\n\t\treturn do_change_type(path, flags);\n\tif (flags & MS_MOVE)\n\t\treturn do_move_mount_old(path, dev_name);\n\n\treturn do_new_mount(path, type_page, sb_flags, mnt_flags, dev_name,\n\t\t\t    data_page);\n}","target":0,"code_token_length":679,"total_token_length":915,"max_tokens_setting":1024}
+{"idx":95906,"func":"void AddUsageStatsWorkItems(const InstallationState& original_state,\n                            const InstallerState& installer_state,\n                            WorkItemList* install_list) {\n  DCHECK(installer_state.operation() == InstallerState::MULTI_INSTALL ||\n         installer_state.operation() == InstallerState::MULTI_UPDATE);\n\n  HKEY root_key = installer_state.root_key();\n  bool value_found = false;\n  DWORD usagestats = 0;\n  const Products& products = installer_state.products();\n\n  for (Products::const_iterator scan = products.begin(), end = products.end();\n       !value_found && scan != end; ++scan) {\n    BrowserDistribution* dist = (*scan)->distribution();\n    const ProductState* product_state =\n        original_state.GetNonVersionedProductState(\n            installer_state.system_install(), dist->GetType());\n    value_found = product_state->GetUsageStats(&usagestats);\n  }\n\n  if (value_found) {\n    std::wstring state_key(\n        installer_state.multi_package_binaries_distribution()->GetStateKey());\n    install_list->AddCreateRegKeyWorkItem(root_key, state_key);\n    install_list->AddSetRegValueWorkItem(root_key, state_key,\n                                         google_update::kRegUsageStatsField,\n                                         usagestats, false);\n\n    for (Products::const_iterator scan = products.begin(), end = products.end();\n         scan != end; ++scan) {\n      BrowserDistribution* dist = (*scan)->distribution();\n      if (installer_state.system_install()) {\n        install_list->AddDeleteRegValueWorkItem(\n            root_key, dist->GetStateMediumKey(),\n            google_update::kRegUsageStatsField);\n        install_list->AddDeleteRegValueWorkItem(\n            HKEY_CURRENT_USER, dist->GetStateKey(),\n            google_update::kRegUsageStatsField);\n      }\n      install_list->AddDeleteRegValueWorkItem(root_key, dist->GetStateKey(),\n          google_update::kRegUsageStatsField);\n    }\n  }\n}\n","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":359474,"func":"quagga_timestamp(int timestamp_precision, char *buf, size_t buflen)\n{\n  static struct {\n    time_t last;\n    size_t len;\n    char buf[28];\n  } cache;\n  struct timeval clock;\n\n  \/* would it be sufficient to use global 'recent_time' here?  I fear not... *\/\n  gettimeofday(&clock, NULL);\n\n  \/* first, we update the cache if the time has changed *\/\n  if (cache.last != clock.tv_sec)\n    {\n      struct tm *tm;\n      cache.last = clock.tv_sec;\n      tm = localtime(&cache.last);\n      cache.len = strftime(cache.buf, sizeof(cache.buf),\n      \t\t\t   \"%Y\/%m\/%d %H:%M:%S\", tm);\n    }\n  \/* note: it's not worth caching the subsecond part, because\n     chances are that back-to-back calls are not sufficiently close together\n     for the clock not to have ticked forward *\/\n\n  if (buflen > cache.len)\n    {\n      memcpy(buf, cache.buf, cache.len);\n      if ((timestamp_precision > 0) &&\n\t  (buflen > cache.len+1+timestamp_precision))\n\t{\n\t  \/* should we worry about locale issues? *\/\n\t  static const int divisor[] = {0, 100000, 10000, 1000, 100, 10, 1};\n\t  int prec;\n\t  char *p = buf+cache.len+1+(prec = timestamp_precision);\n\t  *p-- = '\\0';\n\t  while (prec > 6)\n\t    \/* this is unlikely to happen, but protect anyway *\/\n\t    {\n\t      *p-- = '0';\n\t      prec--;\n\t    }\n\t  clock.tv_usec \/= divisor[prec];\n\t  do\n\t    {\n\t      *p-- = '0'+(clock.tv_usec % 10);\n\t      clock.tv_usec \/= 10;\n\t    }\n\t  while (--prec > 0);\n\t  *p = '.';\n\t  return cache.len+1+timestamp_precision;\n\t}\n      buf[cache.len] = '\\0';\n      return cache.len;\n    }\n  if (buflen > 0)\n    buf[0] = '\\0';\n  return 0;\n}","target":0,"code_token_length":466,"total_token_length":702,"max_tokens_setting":1024}
+{"idx":246749,"func":"static GF_Err do_export_tracks_non_isobmf()\n{\n\tu32 i;\n\n\tGF_MediaExporter mdump;\n\tchar szFile[GF_MAX_PATH+24];\n\tfor (i=0; i<nb_track_act; i++) {\n\t\tGF_Err e;\n\t\tTrackAction *tka = &tracks[i];\n\t\tif (tka->act_type != TRAC_ACTION_RAW_EXTRACT) continue;\n\t\tmemset(&mdump, 0, sizeof(mdump));\n\t\tmdump.in_name = inName;\n\t\tmdump.flags = tka->dump_type;\n\t\tmdump.trackID = tka->trackID;\n\t\tmdump.track_type = tka->dump_track_type;\n\t\tmdump.sample_num = tka->sample_num;\n\n\t\tif (dump_std) {\n\t\t\tmdump.out_name = \"std\";\n\t\t}\n\t\telse if (outName) {\n\t\t\tmdump.out_name = outName;\n\t\t\tmdump.flags |= GF_EXPORT_MERGE;\n\t\t} else if (nb_track_act>1) {\n\t\t\tsprintf(szFile, \"%s_track%d\", outfile, mdump.trackID);\n\t\t\tmdump.out_name = szFile;\n\t\t} else {\n\t\t\tmdump.out_name = outfile;\n\t\t}\n\t\tmdump.print_stats_graph = fs_dump_flags;\n\t\te = gf_media_export(&mdump);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":242656,"func":"static void isoffin_purge_mem(ISOMReader *read, u64 min_offset)\n{\n\tu32 i, count;\n\tu64 top_offset;\n\tu32 nb_bytes_to_purge;\n\tu64 bytes_missing;\n\n\t\/\/purge every\n\tif (read->mstore_purge && (min_offset - read->last_min_offset < read->mstore_purge))\n\t\treturn;\n\n\tif (read->frag_type) {\n\t\t\/\/get position of current box being parsed - if new offset is greater than this box we cannot remove\n\t\t\/\/bytes (we would trash the top-level box header)\n\t\tgf_isom_get_current_top_box_offset(read->mov, &top_offset);\n\t\tif (top_offset<min_offset) {\n\t\t\treturn;\n\t\t}\n\t}\n\tread->last_min_offset = min_offset;\n\n\tassert(min_offset>=read->bytes_removed);\n\t\/\/min_offset is given in absolute file position\n\tnb_bytes_to_purge = (u32) (min_offset - read->bytes_removed);\n\tassert(nb_bytes_to_purge<=read->mem_blob.size);\n\n\tmemmove(read->mem_blob.data, read->mem_blob.data+nb_bytes_to_purge, read->mem_blob.size - nb_bytes_to_purge);\n\tread->mem_blob.size -= nb_bytes_to_purge;\n\tread->bytes_removed += nb_bytes_to_purge;\n\tgf_isom_set_removed_bytes(read->mov, read->bytes_removed);\n\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[IsoMedia] mem mode %d bytes in mem, \"LLU\" bytes trashed since start\\n\", read->mem_blob.size, read->bytes_removed));\n\n\t\/\/force a refresh\n\tgf_isom_refresh_fragmented(read->mov, &bytes_missing, read->mem_url);\n\n\tif (!read->frag_type)\n\t\treturn;\n\n\t\/\/fragmented file, cleanup sample tables\n\tcount = gf_list_count(read->channels);\n\tfor (i=0; i<count; i++) {\n\t\tISOMChannel *ch = gf_list_get(read->channels, i);\n\t\tu32 num_samples;\n\t\tu32 prev_samples = gf_isom_get_sample_count(read->mov, ch->track);\n\t\t\/\/don't run this too often\n\t\tif (ch->sample_num<=1+read->mstore_samples) continue;\n\n\t\tnum_samples = ch->sample_num-1;\n\t\tif (num_samples>=prev_samples) continue;\n\n\t\tif (gf_isom_purge_samples(read->mov, ch->track, num_samples) == GF_OK)\n\t\t\tch->sample_num = 1;\n\n\t\tnum_samples = gf_isom_get_sample_count(read->mov, ch->track);\n\t\tassert(ch->sample_num<=num_samples);\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[IsoMedia] mem mode %d samples now in track %d (prev %d)\\n\", num_samples, ch->track_id, prev_samples));\n\t}\n}","target":0,"code_token_length":617,"total_token_length":853,"max_tokens_setting":1024}
+{"idx":336011,"func":"static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf)\n{\n\tstruct net_device *netdev;\n\tstruct mii_if_info *mii;\n\tu8 addr[ETH_ALEN];\n\tint ret;\n\n\tret = usbnet_get_endpoints(dev, intf);\n\tif (ret)\n\t\tgoto out;\n\n\tnetdev = dev->net;\n\n\tnetdev->netdev_ops = &sr9700_netdev_ops;\n\tnetdev->ethtool_ops = &sr9700_ethtool_ops;\n\tnetdev->hard_header_len += SR_TX_OVERHEAD;\n\tdev->hard_mtu = netdev->mtu + netdev->hard_header_len;\n\t\/* bulkin buffer is preferably not less than 3K *\/\n\tdev->rx_urb_size = 3072;\n\n\tmii = &dev->mii;\n\tmii->dev = netdev;\n\tmii->mdio_read = sr_mdio_read;\n\tmii->mdio_write = sr_mdio_write;\n\tmii->phy_id_mask = 0x1f;\n\tmii->reg_num_mask = 0x1f;\n\n\tsr_write_reg(dev, SR_NCR, NCR_RST);\n\tudelay(20);\n\n\t\/* read MAC\n\t * After Chip Power on, the Chip will reload the MAC from\n\t * EEPROM automatically to PAR. In case there is no EEPROM externally,\n\t * a default MAC address is stored in PAR for making chip work properly.\n\t *\/\n\tif (sr_read(dev, SR_PAR, ETH_ALEN, addr) < 0) {\n\t\tnetdev_err(netdev, \"Error reading MAC address\\n\");\n\t\tret = -ENODEV;\n\t\tgoto out;\n\t}\n\teth_hw_addr_set(netdev, addr);\n\n\t\/* power up and reset phy *\/\n\tsr_write_reg(dev, SR_PRR, PRR_PHY_RST);\n\t\/* at least 10ms, here 20ms for safe *\/\n\tmsleep(20);\n\tsr_write_reg(dev, SR_PRR, 0);\n\t\/* at least 1ms, here 2ms for reading right register *\/\n\tudelay(2 * 1000);\n\n\t\/* receive broadcast packets *\/\n\tsr9700_set_multicast(netdev);\n\n\tsr_mdio_write(netdev, mii->phy_id, MII_BMCR, BMCR_RESET);\n\tsr_mdio_write(netdev, mii->phy_id, MII_ADVERTISE, ADVERTISE_ALL |\n\t\t      ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);\n\tmii_nway_restart(mii);\n\nout:\n\treturn ret;\n}","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":251513,"func":"static inline void RelinquishDCMMemory(DCMInfo *info,DCMMap *map,\n  DCMStreamInfo *stream_info,LinkedListInfo *stack,unsigned char *data)\n{\n  if (info->scale != (Quantum *) NULL)\n    info->scale=(Quantum *) RelinquishMagickMemory(info->scale);\n  if (map->gray != (int *) NULL)\n    map->gray=(int *) RelinquishMagickMemory(map->gray);\n  if (map->blue != (int *) NULL)\n    map->blue=(int *) RelinquishMagickMemory(map->blue);\n  if (map->green != (int *) NULL)\n    map->green=(int *) RelinquishMagickMemory(map->green);\n  if (map->red != (int *) NULL)\n    map->red=(int *) RelinquishMagickMemory(map->red);\n  if (stream_info->offsets != (ssize_t *) NULL)\n    stream_info->offsets=(ssize_t *) RelinquishMagickMemory(\n      stream_info->offsets);\n  if (stream_info != (DCMStreamInfo *) NULL)\n    stream_info=(DCMStreamInfo *) RelinquishMagickMemory(stream_info);\n  if (stack != (LinkedListInfo *) NULL)\n    stack=DestroyLinkedList(stack,RelinquishDCMInfo);\n  if (data != (unsigned char *) NULL)\n    data=(unsigned char *) RelinquishMagickMemory(data);\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":507780,"func":"ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,\n                                               ECPARAMETERS *params)\n{\n    size_t len = 0;\n    ECPARAMETERS *ret = NULL;\n    const BIGNUM *tmp;\n    unsigned char *buffer = NULL;\n    const EC_POINT *point = NULL;\n    point_conversion_form_t form;\n    ASN1_INTEGER *orig;\n\n    if (params == NULL) {\n        if ((ret = ECPARAMETERS_new()) == NULL) {\n            ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    } else\n        ret = params;\n\n    \/* set the version (always one) *\/\n    ret->version = (long)0x1;\n\n    \/* set the fieldID *\/\n    if (!ec_asn1_group2fieldid(group, ret->fieldID)) {\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n\n    \/* set the curve *\/\n    if (!ec_asn1_group2curve(group, ret->curve)) {\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n\n    \/* set the base point *\/\n    if ((point = EC_GROUP_get0_generator(group)) == NULL) {\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, EC_R_UNDEFINED_GENERATOR);\n        goto err;\n    }\n\n    form = EC_GROUP_get_point_conversion_form(group);\n\n    len = EC_POINT_point2buf(group, point, form, &buffer, NULL);\n    if (len == 0) {\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (ret->base == NULL && (ret->base = ASN1_OCTET_STRING_new()) == NULL) {\n        OPENSSL_free(buffer);\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    ASN1_STRING_set0(ret->base, buffer, len);\n\n    \/* set the order *\/\n    tmp = EC_GROUP_get0_order(group);\n    if (tmp == NULL) {\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    ret->order = BN_to_ASN1_INTEGER(tmp, orig = ret->order);\n    if (ret->order == NULL) {\n        ret->order = orig;\n        ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n\n    \/* set the cofactor (optional) *\/\n    tmp = EC_GROUP_get0_cofactor(group);\n    if (tmp != NULL) {\n        ret->cofactor = BN_to_ASN1_INTEGER(tmp, orig = ret->cofactor);\n        if (ret->cofactor == NULL) {\n            ret->cofactor = orig;\n            ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB);\n            goto err;\n        }\n    }\n\n    return ret;\n\n err:\n    if (params == NULL)\n        ECPARAMETERS_free(ret);\n    return NULL;\n}","target":0,"code_token_length":672,"total_token_length":908,"max_tokens_setting":1024}
+{"idx":242976,"func":"static int ssl_flight_append( mbedtls_ssl_context *ssl )\n{\n    mbedtls_ssl_flight_item *msg;\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"=> ssl_flight_append\" ) );\n    MBEDTLS_SSL_DEBUG_BUF( 4, \"message appended to flight\",\n                           ssl->out_msg, ssl->out_msglen );\n\n    \/* Allocate space for current message *\/\n    if( ( msg = mbedtls_calloc( 1, sizeof(  mbedtls_ssl_flight_item ) ) ) == NULL )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"alloc %\" MBEDTLS_PRINTF_SIZET \" bytes failed\",\n                            sizeof( mbedtls_ssl_flight_item ) ) );\n        return( MBEDTLS_ERR_SSL_ALLOC_FAILED );\n    }\n\n    if( ( msg->p = mbedtls_calloc( 1, ssl->out_msglen ) ) == NULL )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"alloc %\" MBEDTLS_PRINTF_SIZET \" bytes failed\",\n                                    ssl->out_msglen ) );\n        mbedtls_free( msg );\n        return( MBEDTLS_ERR_SSL_ALLOC_FAILED );\n    }\n\n    \/* Copy current handshake message with headers *\/\n    memcpy( msg->p, ssl->out_msg, ssl->out_msglen );\n    msg->len = ssl->out_msglen;\n    msg->type = ssl->out_msgtype;\n    msg->next = NULL;\n\n    \/* Append to the current flight *\/\n    if( ssl->handshake->flight == NULL )\n        ssl->handshake->flight = msg;\n    else\n    {\n        mbedtls_ssl_flight_item *cur = ssl->handshake->flight;\n        while( cur->next != NULL )\n            cur = cur->next;\n        cur->next = msg;\n    }\n\n    MBEDTLS_SSL_DEBUG_MSG( 2, ( \"<= ssl_flight_append\" ) );\n    return( 0 );\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":343312,"func":"static int create_home_and_chdir(const char * const home)\n{\n    char *pathcomp;\n    char *z;\n    size_t len;\n    const char delim = '\/';\n\n    if (home == NULL || *home != '\/') {\n        return -1;\n    }\n    if (chdir(home) == 0) {\n        return 0;\n    }\n    if (create_home == 0) {\n        return -1;\n    }\n    len = strlen(home) + (size_t) 1U;\n    if (len < (size_t) 2U || *home != delim) {\n        return -1;\n    }\n    if ((pathcomp = ALLOCA(len)) == NULL) {\n        return -1;\n    }\n    memcpy(pathcomp, home, len);       \/* safe, no possible overflow *\/\n    z = pathcomp;\n    for (;;) {\n        z++;\n        if (*z == 0) {\n            break;\n        }\n        if (*z == delim) {\n            *z = 0;\n            if (z[1] == 0) {\n                break;\n            }\n            (void) mkdir(pathcomp, (mode_t) 0755);\n            *z = delim;\n        }\n    }\n    ALLOCA_FREE(pathcomp);\n    (void) mkdir(home, (mode_t) 0700);\n    if (chdir(home) != 0) {\n        return -1;\n    }\n    if (chmod(home, (mode_t) 0777 & ~u_mask_d) < 0 ||\n        chown(home, authresult.uid, authresult.gid) < 0) {\n        return -1;\n    }\n\n    return chdir(home);\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":219903,"func":"GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text)\n{\n\tGF_TrackBox *trak;\n\tGF_UserDataMap *map;\n\tGF_HintTrackInfoBox *hnti;\n\tGF_SDPBox *sdp;\n\tGF_Err e;\n\tchar *buf;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak) return GF_BAD_PARAM;\n\n\t\/\/currently, only RTP hinting supports SDP\n\tif (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM;\n\n\tmap = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);\n\tif (!map) return GF_ISOM_INVALID_FILE;\n\n\t\/\/we should have only one HNTI in the UDTA\n\tif (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE;\n\n\thnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0);\n\tif (!hnti->SDP) {\n\t\te = hnti_on_child_box((GF_Box*)hnti, gf_isom_box_new_parent(&hnti->child_boxes, GF_ISOM_BOX_TYPE_SDP), GF_FALSE);\n\t\tif (e) return e;\n\t}\n\tsdp = (GF_SDPBox *) hnti->SDP;\n\n\tif (!sdp->sdpText) {\n\t\tsdp->sdpText = (char *)gf_malloc(sizeof(char) * (strlen(text) + 3));\n\t\tif (!sdp->sdpText) return GF_OUT_OF_MEM;\n\n\t\tstrcpy(sdp->sdpText, text);\n\t\tstrcat(sdp->sdpText, \"\\r\\n\");\n\t\treturn GF_OK;\n\t}\n\tbuf = (char *)gf_malloc(sizeof(char) * (strlen(sdp->sdpText) + strlen(text) + 3));\n\tif (!buf) return GF_OUT_OF_MEM;\n\n\tstrcpy(buf, sdp->sdpText);\n\tstrcat(buf, text);\n\tstrcat(buf, \"\\r\\n\");\n\tgf_free(sdp->sdpText);\n\tReorderSDP(buf, GF_FALSE);\n\tsdp->sdpText = buf;\n\treturn GF_OK;\n}","target":0,"code_token_length":479,"total_token_length":715,"max_tokens_setting":1024}
+{"idx":437292,"func":"update_string_node_case_fold(regex_t* reg, Node *node)\n{\n  UChar *p, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];\n  UChar *sbuf, *ebuf, *sp;\n  int r, i, len, sbuf_size;\n  StrNode* sn = STR_(node);\n\n  end = sn->end;\n  sbuf_size = (int )(end - sn->s) * 2;\n  sbuf = (UChar* )xmalloc(sbuf_size);\n  CHECK_NULL_RETURN_MEMERR(sbuf);\n  ebuf = sbuf + sbuf_size;\n\n  sp = sbuf;\n  p = sn->s;\n  while (p < end) {\n    len = ONIGENC_MBC_CASE_FOLD(reg->enc, reg->case_fold_flag, &p, end, buf);\n    for (i = 0; i < len; i++) {\n      if (sp >= ebuf) {\n        sbuf = (UChar* )xrealloc(sbuf, sbuf_size * 2);\n        CHECK_NULL_RETURN_MEMERR(sbuf);\n        sp = sbuf + sbuf_size;\n        sbuf_size *= 2;\n        ebuf = sbuf + sbuf_size;\n      }\n\n      *sp++ = buf[i];\n    }\n  }\n\n  r = onig_node_str_set(node, sbuf, sp);\n  if (r != 0) {\n    xfree(sbuf);\n    return r;\n  }\n\n  xfree(sbuf);\n  return 0;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":442788,"func":"static int myprogress (void *clientp,\n                       double dltotal,\n                       double dlnow,\n                       double ultotal,\n                       double ulnow)\n{\n  \/* The original progress-bar source code was written for curl by Lars Aas,\n     and this new edition inherits some of his concepts. *\/\n\n  char line[256];\n  char outline[256];\n  char format[40];\n  double frac;\n  double percent;\n  int barwidth;\n  int num;\n  int i;\n\n  struct ProgressData *bar = (struct ProgressData *)clientp;\n  curl_off_t total = (curl_off_t)dltotal + (curl_off_t)ultotal +\n    bar->initial_size; \/* expected transfer size *\/\n  curl_off_t point = (curl_off_t)dlnow + (curl_off_t)ulnow +\n    bar->initial_size; \/* we've come this far *\/\n\n  if(point > total)\n    \/* we have got more than the expected total! *\/\n    total = point;\n\n  bar->calls++; \/* simply count invokes *\/\n\n  if(total < 1) {\n    curl_off_t prevblock = bar->prev \/ 1024;\n    curl_off_t thisblock = point \/ 1024;\n    while ( thisblock > prevblock ) {\n      fprintf( bar->out, \"#\" );\n      prevblock++;\n    }\n  }\n  else {\n    frac = (double)point \/ (double)total;\n    percent = frac * 100.0f;\n    barwidth = bar->width - 7;\n    num = (int) (((double)barwidth) * frac);\n    i = 0;\n    for ( i = 0; i < num; i++ ) {\n      line[i] = '#';\n    }\n    line[i] = '\\0';\n    snprintf( format, sizeof(format), \"%%-%ds %%5.1f%%%%\", barwidth );\n    snprintf( outline, sizeof(outline), format, line, percent );\n    fprintf( bar->out, \"\\r%s\", outline );\n  }\n  fflush(bar->out);\n  bar->prev = point;\n\n  return 0;\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":437380,"func":"setup_call_node_call(CallNode* cn, ScanEnv* env, int state)\n{\n  MemEnv* mem_env = SCANENV_MEMENV(env);\n\n  if (cn->by_number != 0) {\n    int gnum = cn->group_num;\n\n    if (env->num_named > 0 &&\n        IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&\n        ! ONIG_IS_OPTION_ON(env->options, ONIG_OPTION_CAPTURE_GROUP)) {\n      return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;\n    }\n\n    if (gnum > env->num_mem) {\n      onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_GROUP_REFERENCE,\n                                     cn->name, cn->name_end);\n      return ONIGERR_UNDEFINED_GROUP_REFERENCE;\n    }\n\n  set_call_attr:\n    NODE_CALL_BODY(cn) = mem_env[cn->group_num].node;\n    if (IS_NULL(NODE_CALL_BODY(cn))) {\n      onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_NAME_REFERENCE,\n                                     cn->name, cn->name_end);\n      return ONIGERR_UNDEFINED_NAME_REFERENCE;\n    }\n  }\n  else {\n    int *refs;\n\n    int n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, &refs);\n    if (n <= 0) {\n      onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_NAME_REFERENCE,\n                                     cn->name, cn->name_end);\n      return ONIGERR_UNDEFINED_NAME_REFERENCE;\n    }\n    else if (n > 1) {\n      onig_scan_env_set_error_string(env, ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL,\n                                     cn->name, cn->name_end);\n      return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;\n    }\n    else {\n      cn->group_num = refs[0];\n      goto set_call_attr;\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":406,"total_token_length":642,"max_tokens_setting":1024}
+{"idx":261242,"func":"int SN_Client_WillTopicUpdate(MqttClient *client, SN_Will *will)\n{\n    int rc = 0, len = 0;\n\n    \/* Validate required arguments *\/\n    if (client == NULL) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    if (will->stat == MQTT_MSG_BEGIN) {\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n\n        \/* Encode Will Topic Update *\/\n        len = rc = SN_Encode_WillTopicUpdate(client->tx_buf,\n                client->tx_buf_len, will);\n    #ifdef WOLFMQTT_DEBUG_CLIENT\n        PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d)\",\n            rc, SN_Packet_TypeDesc(SN_MSG_TYPE_WILLTOPICUPD),\n            SN_MSG_TYPE_WILLTOPICUPD);\n    #endif\n        if (rc <= 0) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            return rc;\n        }\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        rc = wm_SemLock(&client->lockClient);\n        if (rc == 0) {\n            \/* inform other threads of expected response *\/\n            rc = MqttClient_RespList_Add(client,\n                    (MqttPacketType)SN_MSG_TYPE_WILLTOPICRESP,\n                    0, &will->pendResp, &will->resp.topicResp);\n            wm_SemUnlock(&client->lockClient);\n        }\n        if (rc != 0) {\n            wm_SemUnlock(&client->lockSend);\n            return rc; \/* Error locking client *\/\n        }\n    #endif\n\n        \/* Send Will Topic Update packet *\/\n        rc = MqttPacket_Write(client, client->tx_buf, len);\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n        if (rc != len) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            if (wm_SemLock(&client->lockClient) == 0) {\n                MqttClient_RespList_Remove(client, &will->pendResp);\n                wm_SemUnlock(&client->lockClient);\n            }\n        #endif\n        }\n        will->stat = MQTT_MSG_WAIT;\n    }\n\n    \/* Wait for Will Topic Update Response packet *\/\n    rc = SN_Client_WaitType(client, &will->resp.topicResp,\n            SN_MSG_TYPE_WILLTOPICRESP, 0, client->cmd_timeout_ms);\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &will->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n    \/* reset state *\/\n    will->stat = MQTT_MSG_BEGIN;\n\n    return rc;\n}","target":0,"code_token_length":679,"total_token_length":915,"max_tokens_setting":1024}
+{"idx":270411,"func":"static bool ok_png_read_palette(ok_png_decoder *decoder, uint32_t chunk_length) {\n    ok_png *png = decoder->png;\n    decoder->palette_length = chunk_length \/ 3;\n\n    if (decoder->palette_length > 256 || decoder->palette_length * 3 != chunk_length) {\n        ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid palette chunk length\");\n        return false;\n    }\n    const bool src_is_bgr = decoder->is_ios_format;\n    const bool dst_is_bgr = (decoder->decode_flags & OK_PNG_COLOR_FORMAT_BGRA) != 0;\n    const bool should_byteswap = src_is_bgr != dst_is_bgr;\n    uint8_t *dst = decoder->palette;\n    uint8_t buffer[256 * 3];\n    if (!ok_read(decoder, buffer, 3 * decoder->palette_length)) {\n        return false;\n    }\n    uint8_t *in = buffer;\n    if (should_byteswap) {\n        for (uint32_t i = 0; i < decoder->palette_length; i++, in += 3, dst += 4) {\n            dst[0] = in[2];\n            dst[1] = in[1];\n            dst[2] = in[0];\n            dst[3] = 0xff;\n        }\n    } else {\n        for (uint32_t i = 0; i < decoder->palette_length; i++, in += 3, dst += 4) {\n            dst[0] = in[0];\n            dst[1] = in[1];\n            dst[2] = in[2];\n            dst[3] = 0xff;\n        }\n    }\n    return true;\n}","target":0,"code_token_length":373,"total_token_length":609,"max_tokens_setting":1024}
+{"idx":257000,"func":"static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,\n\t\t\t bool rtnl_held, struct netlink_ext_ack *extack)\n{\n\tstruct route4_head *head = rtnl_dereference(tp->root);\n\tstruct route4_filter *f = arg;\n\tstruct route4_filter __rcu **fp;\n\tstruct route4_filter *nf;\n\tstruct route4_bucket *b;\n\tunsigned int h = 0;\n\tint i, h1;\n\n\tif (!head || !f)\n\t\treturn -EINVAL;\n\n\th = f->handle;\n\tb = f->bkt;\n\n\tfp = &b->ht[from_hash(h >> 16)];\n\tfor (nf = rtnl_dereference(*fp); nf;\n\t     fp = &nf->next, nf = rtnl_dereference(*fp)) {\n\t\tif (nf == f) {\n\t\t\t\/* unlink it *\/\n\t\t\tRCU_INIT_POINTER(*fp, rtnl_dereference(f->next));\n\n\t\t\t\/* Remove any fastmap lookups that might ref filter\n\t\t\t * notice we unlink'd the filter so we can't get it\n\t\t\t * back in the fastmap.\n\t\t\t *\/\n\t\t\troute4_reset_fastmap(head);\n\n\t\t\t\/* Delete it *\/\n\t\t\ttcf_unbind_filter(tp, &f->res);\n\t\t\ttcf_exts_get_net(&f->exts);\n\t\t\ttcf_queue_work(&f->rwork, route4_delete_filter_work);\n\n\t\t\t\/* Strip RTNL protected tree *\/\n\t\t\tfor (i = 0; i <= 32; i++) {\n\t\t\t\tstruct route4_filter *rt;\n\n\t\t\t\trt = rtnl_dereference(b->ht[i]);\n\t\t\t\tif (rt)\n\t\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\t\/* OK, session has no flows *\/\n\t\t\tRCU_INIT_POINTER(head->table[to_hash(h)], NULL);\n\t\t\tkfree_rcu(b, rcu);\n\t\t\tbreak;\n\t\t}\n\t}\n\nout:\n\t*last = true;\n\tfor (h1 = 0; h1 <= 256; h1++) {\n\t\tif (rcu_access_pointer(head->table[h1])) {\n\t\t\t*last = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":348425,"func":"static int mkiss_open(struct tty_struct *tty)\n{\n\tstruct net_device *dev;\n\tstruct mkiss *ax;\n\tint err;\n\n\tif (!capable(CAP_NET_ADMIN))\n\t\treturn -EPERM;\n\tif (tty->ops->write == NULL)\n\t\treturn -EOPNOTSUPP;\n\n\tdev = alloc_netdev(sizeof(struct mkiss), \"ax%d\", NET_NAME_UNKNOWN,\n\t\t\t   ax_setup);\n\tif (!dev) {\n\t\terr = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tax = netdev_priv(dev);\n\tax->dev = dev;\n\n\tspin_lock_init(&ax->buflock);\n\trefcount_set(&ax->refcnt, 1);\n\tinit_completion(&ax->dead);\n\n\tax->tty = tty;\n\ttty->disc_data = ax;\n\ttty->receive_room = 65535;\n\n\ttty_driver_flush_buffer(tty);\n\n\t\/* Restore default settings *\/\n\tdev->type = ARPHRD_AX25;\n\n\t\/* Perform the low-level AX25 initialization. *\/\n\terr = ax_open(ax->dev);\n\tif (err)\n\t\tgoto out_free_netdev;\n\n\terr = register_netdev(dev);\n\tif (err)\n\t\tgoto out_free_buffers;\n\n\t\/* after register_netdev() - because else printk smashes the kernel *\/\n\tswitch (crc_force) {\n\tcase 3:\n\t\tax->crcmode  = CRC_MODE_SMACK;\n\t\tprintk(KERN_INFO \"mkiss: %s: crc mode smack forced.\\n\",\n\t\t       ax->dev->name);\n\t\tbreak;\n\tcase 2:\n\t\tax->crcmode  = CRC_MODE_FLEX;\n\t\tprintk(KERN_INFO \"mkiss: %s: crc mode flexnet forced.\\n\",\n\t\t       ax->dev->name);\n\t\tbreak;\n\tcase 1:\n\t\tax->crcmode  = CRC_MODE_NONE;\n\t\tprintk(KERN_INFO \"mkiss: %s: crc mode disabled.\\n\",\n\t\t       ax->dev->name);\n\t\tbreak;\n\tcase 0:\n\tdefault:\n\t\tcrc_force = 0;\n\t\tprintk(KERN_INFO \"mkiss: %s: crc mode is auto.\\n\",\n\t\t       ax->dev->name);\n\t\tax->crcmode  = CRC_MODE_SMACK_TEST;\n\t}\n\tax->crcauto = (crc_force ? 0 : 1);\n\n\tnetif_start_queue(dev);\n\n\t\/* Done.  We have linked the TTY line to a channel. *\/\n\treturn 0;\n\nout_free_buffers:\n\tkfree(ax->rbuff);\n\tkfree(ax->xbuff);\n\nout_free_netdev:\n\tfree_netdev(dev);\n\nout:\n\treturn err;\n}","target":0,"code_token_length":523,"total_token_length":759,"max_tokens_setting":1024}
+{"idx":458296,"func":"SYSCALL_DEFINE2(ioprio_get, int, which, int, who)\n{\n\tstruct task_struct *g, *p;\n\tstruct user_struct *user;\n\tstruct pid *pgrp;\n\tkuid_t uid;\n\tint ret = -ESRCH;\n\tint tmpio;\n\n\trcu_read_lock();\n\tswitch (which) {\n\t\tcase IOPRIO_WHO_PROCESS:\n\t\t\tif (!who)\n\t\t\t\tp = current;\n\t\t\telse\n\t\t\t\tp = find_task_by_vpid(who);\n\t\t\tif (p)\n\t\t\t\tret = get_task_ioprio(p);\n\t\t\tbreak;\n\t\tcase IOPRIO_WHO_PGRP:\n\t\t\tif (!who)\n\t\t\t\tpgrp = task_pgrp(current);\n\t\t\telse\n\t\t\t\tpgrp = find_vpid(who);\n\t\t\tdo_each_pid_thread(pgrp, PIDTYPE_PGID, p) {\n\t\t\t\ttmpio = get_task_ioprio(p);\n\t\t\t\tif (tmpio < 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (ret == -ESRCH)\n\t\t\t\t\tret = tmpio;\n\t\t\t\telse\n\t\t\t\t\tret = ioprio_best(ret, tmpio);\n\t\t\t} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);\n\t\t\tbreak;\n\t\tcase IOPRIO_WHO_USER:\n\t\t\tuid = make_kuid(current_user_ns(), who);\n\t\t\tif (!who)\n\t\t\t\tuser = current_user();\n\t\t\telse\n\t\t\t\tuser = find_user(uid);\n\n\t\t\tif (!user)\n\t\t\t\tbreak;\n\n\t\t\tdo_each_thread(g, p) {\n\t\t\t\tif (!uid_eq(task_uid(p), user->uid) ||\n\t\t\t\t    !task_pid_vnr(p))\n\t\t\t\t\tcontinue;\n\t\t\t\ttmpio = get_task_ioprio(p);\n\t\t\t\tif (tmpio < 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (ret == -ESRCH)\n\t\t\t\t\tret = tmpio;\n\t\t\t\telse\n\t\t\t\t\tret = ioprio_best(ret, tmpio);\n\t\t\t} while_each_thread(g, p);\n\n\t\t\tif (who)\n\t\t\t\tfree_uid(user);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tret = -EINVAL;\n\t}\n\n\trcu_read_unlock();\n\treturn ret;\n}","target":0,"code_token_length":429,"total_token_length":665,"max_tokens_setting":1024}
+{"idx":218999,"func":"Status ConstantFolding::RemoveReverse(const GraphProperties& properties,\n                                      bool use_shape_info,\n                                      GraphDef* optimized_graph,\n                                      NodeDef* node) {\n  if (!use_shape_info || node->op() != \"ReverseV2\") return Status::OK();\n  Tensor axis;\n  if (properties.HasInputProperties(node->name()) &&\n      GetTensorFromConstNode(node->input(1), &axis)) {\n    const auto& shape = properties.GetInputProperties(node->name())[0].shape();\n    if (shape.unknown_rank()) return Status::OK();\n    std::set<int> target_axes;\n    for (int j = 0; j < axis.NumElements(); ++j) {\n      \/\/ value of axis can be negative.\n      if (axis.dtype() == DT_INT64) {\n        target_axes.insert((axis.vec<int64_t>()(j) + shape.dim_size()) %\n                           shape.dim_size());\n      } else {\n        target_axes.insert((axis.vec<int>()(j) + shape.dim_size()) %\n                           shape.dim_size());\n      }\n    }\n\n    \/\/ The node is replaceable iff\n    \/\/ unknown_rank == false &&\n    \/\/ (dim_size == 0 || all dims have size 1 ||\n    \/\/  all dims with > 1 size are not in target_axes)\n    bool replaceable = true;\n    for (int j = 0; replaceable && j < shape.dim_size(); ++j) {\n      replaceable &=\n          shape.dim(j).size() == 1 || target_axes.find(j) == target_axes.end();\n    }\n    if (replaceable) {\n      ReplaceOperationWithIdentity(0, properties, node, optimized_graph);\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":261887,"func":"njs_string_prototype_repeat(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    u_char             *p;\n    int64_t            n, max;\n    uint64_t           size, length;\n    njs_int_t          ret;\n    njs_value_t        *this;\n    njs_string_prop_t  string;\n\n    this = njs_argument(args, 0);\n\n    if (njs_slow_path(njs_is_null_or_undefined(this))) {\n        njs_type_error(vm, \"cannot convert \\\"%s\\\"to object\",\n                       njs_type_string(this->type));\n        return NJS_ERROR;\n    }\n\n    ret = njs_value_to_string(vm, this, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &n);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_slow_path(n < 0 || n == INT64_MAX)) {\n        njs_range_error(vm, NULL);\n        return NJS_ERROR;\n    }\n\n    (void) njs_string_prop(&string, this);\n\n    if (njs_slow_path(n == 0 || string.size == 0)) {\n        vm->retval = njs_string_empty;\n        return NJS_OK;\n    }\n\n    max = NJS_STRING_MAX_LENGTH \/ string.size;\n\n    if (njs_slow_path(n >= max)) {\n        njs_range_error(vm, NULL);\n        return NJS_ERROR;\n    }\n\n    size = string.size * n;\n    length = string.length * n;\n\n    p = njs_string_alloc(vm, &vm->retval, size, length);\n    if (njs_slow_path(p == NULL)) {\n        return NJS_ERROR;\n    }\n\n    while (n != 0) {\n        p = memcpy(p, string.start, string.size);\n        p += string.size;\n        n--;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":446,"total_token_length":682,"max_tokens_setting":1024}
+{"idx":462215,"func":"static pj_status_t decode_sockaddr_attr(pj_pool_t *pool, \n\t\t\t\t        const pj_uint8_t *buf, \n\t\t\t\t\tconst pj_stun_msg_hdr *msghdr, \n\t\t\t\t        void **p_attr)\n{\n    pj_stun_sockaddr_attr *attr;\n    int af;\n    unsigned addr_len;\n    pj_uint32_t val;\n\n    PJ_CHECK_STACK();\n    \n    PJ_UNUSED_ARG(msghdr);\n\n    \/* Create the attribute *\/\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr);\n    GETATTRHDR(buf, &attr->hdr);\n\n    \/* Check that the attribute length is valid *\/\n    if (attr->hdr.length != STUN_GENERIC_IPV4_ADDR_LEN &&\n\tattr->hdr.length != STUN_GENERIC_IPV6_ADDR_LEN)\n    {\n\treturn PJNATH_ESTUNINATTRLEN;\n    }\n\n    \/* Check address family *\/\n    val = *(pj_uint8_t*)(buf + ATTR_HDR_LEN + 1);\n\n    \/* Check address family is valid *\/\n    if (val == 1) {\n\tif (attr->hdr.length != STUN_GENERIC_IPV4_ADDR_LEN)\n\t    return PJNATH_ESTUNINATTRLEN;\n\taf = pj_AF_INET();\n\taddr_len = 4;\n    } else if (val == 2) {\n\tif (attr->hdr.length != STUN_GENERIC_IPV6_ADDR_LEN)\n\t    return PJNATH_ESTUNINATTRLEN;\n\taf = pj_AF_INET6();\n\taddr_len = 16;\n    } else {\n\t\/* Invalid address family *\/\n\treturn PJNATH_EINVAF;\n    }\n\n    \/* Get port and address *\/\n    pj_sockaddr_init(af, &attr->sockaddr, NULL, 0);\n    pj_sockaddr_set_port(&attr->sockaddr, \n\t\t\t GETVAL16H(buf, ATTR_HDR_LEN+2));\n    pj_memcpy(pj_sockaddr_get_addr(&attr->sockaddr),\n\t      buf+ATTR_HDR_LEN+4,\n\t      addr_len);\n\n    \/* Done *\/\n    *p_attr = (void*)attr;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":225769,"func":"\nGF_Err metx_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox *)s;\n\tGF_Err e = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_data(bs, ptr->reserved, 6);\n\tgf_bs_write_u16(bs, ptr->dataReferenceIndex);\n\n\tif (ptr->type!=GF_ISOM_BOX_TYPE_STPP) {\n\t\tif (ptr->content_encoding)\n\t\t\tgf_bs_write_data(bs, ptr->content_encoding, (u32) strlen(ptr->content_encoding));\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\n\tif ((ptr->type==GF_ISOM_BOX_TYPE_METX) || (ptr->type==GF_ISOM_BOX_TYPE_STPP)) {\n\t\tif (ptr->xml_namespace)\n\t\t\tgf_bs_write_data(bs, ptr->xml_namespace, (u32) strlen(ptr->xml_namespace));\n\n\t\tgf_bs_write_u8(bs, 0);\n\n\t\tif (ptr->xml_schema_loc)\n\t\t\tgf_bs_write_data(bs, ptr->xml_schema_loc, (u32) strlen(ptr->xml_schema_loc));\n\t\tgf_bs_write_u8(bs, 0);\n\n\t\tif (ptr->type==GF_ISOM_BOX_TYPE_STPP) {\n\t\t\tif (ptr->mime_type)\n\t\t\t\tgf_bs_write_data(bs, ptr->mime_type, (u32) strlen(ptr->mime_type));\n\n\t\t\tgf_bs_write_u8(bs, 0);\n\t\t}\n\t}\n\t\/\/mett, sbtt, stxt\n\telse {\n\t\tif (ptr->mime_type)\n\t\t\tgf_bs_write_data(bs, ptr->mime_type, (u32) strlen(ptr->mime_type));\n\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\n\treturn GF_OK;","target":0,"code_token_length":399,"total_token_length":635,"max_tokens_setting":1024}
+{"idx":276921,"func":"static int do_i2c_md(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t     char *const argv[])\n{\n\tuint\tchip;\n\tuint\taddr, length;\n\tuint\talen;\n\tuint\tj, nbytes, linebytes;\n\tint ret;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *dev;\n#endif\n\n\t\/* We use the last specified parameters, unless new ones are\n\t * entered.\n\t *\/\n\tchip   = i2c_dp_last_chip;\n\taddr   = i2c_dp_last_addr;\n\talen   = i2c_dp_last_alen;\n\tlength = i2c_dp_last_length;\n\n\tif (argc < 3)\n\t\treturn CMD_RET_USAGE;\n\n\tif ((flag & CMD_FLAG_REPEAT) == 0) {\n\t\t\/*\n\t\t * New command specified.\n\t\t *\/\n\n\t\t\/*\n\t\t * I2C chip address\n\t\t *\/\n\t\tchip = hextoul(argv[1], NULL);\n\n\t\t\/*\n\t\t * I2C data address within the chip.  This can be 1 or\n\t\t * 2 bytes long.  Some day it might be 3 bytes long :-).\n\t\t *\/\n\t\taddr = hextoul(argv[2], NULL);\n\t\talen = get_alen(argv[2], DEFAULT_ADDR_LEN);\n\t\tif (alen > 3)\n\t\t\treturn CMD_RET_USAGE;\n\n\t\t\/*\n\t\t * If another parameter, it is the length to display.\n\t\t * Length is the number of objects, not number of bytes.\n\t\t *\/\n\t\tif (argc > 3)\n\t\t\tlength = hextoul(argv[3], NULL);\n\t}\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (!ret && alen != -1)\n\t\tret = i2c_set_chip_offset_len(dev, alen);\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n#endif\n\n\t\/*\n\t * Print the lines.\n\t *\n\t * We buffer all read data, so we can make sure data is read only\n\t * once.\n\t *\/\n\tnbytes = length;\n\tdo {\n\t\tunsigned char\tlinebuf[DISP_LINE_LEN];\n\t\tunsigned char\t*cp;\n\n\t\tlinebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tret = dm_i2c_read(dev, addr, linebuf, linebytes);\n#else\n\t\tret = i2c_read(chip, addr, alen, linebuf, linebytes);\n#endif\n\t\tif (ret)\n\t\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n\t\telse {\n\t\t\tprintf(\"%04x:\", addr);\n\t\t\tcp = linebuf;\n\t\t\tfor (j=0; j<linebytes; j++) {\n\t\t\t\tprintf(\" %02x\", *cp++);\n\t\t\t\taddr++;\n\t\t\t}\n\t\t\tputs (\"    \");\n\t\t\tcp = linebuf;\n\t\t\tfor (j=0; j<linebytes; j++) {\n\t\t\t\tif ((*cp < 0x20) || (*cp > 0x7e))\n\t\t\t\t\tputs (\".\");\n\t\t\t\telse\n\t\t\t\t\tprintf(\"%c\", *cp);\n\t\t\t\tcp++;\n\t\t\t}\n\t\t\tputc ('\\n');\n\t\t}\n\t\tnbytes -= linebytes;\n\t} while (nbytes > 0);\n\n\ti2c_dp_last_chip   = chip;\n\ti2c_dp_last_addr   = addr;\n\ti2c_dp_last_alen   = alen;\n\ti2c_dp_last_length = length;\n\n\treturn 0;\n}","target":0,"code_token_length":743,"total_token_length":979,"max_tokens_setting":1024}
+{"idx":90900,"func":"  void GetUsageForOrigins(const std::set<GURL>& origins, StorageType type) {\n    DCHECK(original_message_loop()->BelongsToCurrentThread());\n    std::vector<GURL> origins_to_gather;\n    std::set<GURL> cached_origins;\n    client_tracker()->GetCachedOrigins(&cached_origins);\n    std::set<GURL> already_added;\n    for (std::set<GURL>::const_iterator iter = origins.begin();\n         iter != origins.end(); ++iter) {\n      if (cached_origins.find(*iter) == cached_origins.end() &&\n          already_added.insert(*iter).second) {\n        origins_to_gather.push_back(*iter);\n      }\n    }\n    if (origins_to_gather.empty()) {\n      CallCompleted();\n      DeleteSoon();\n      return;\n    }\n\n    std::sort(origins_to_gather.begin(), origins_to_gather.end(), SortByHost);\n\n    for (std::vector<GURL>::const_iterator iter = origins_to_gather.begin();\n         iter != origins_to_gather.end(); iter++)\n      pending_origins_.push_back(*iter);\n\n    for (std::vector<GURL>::const_iterator iter = origins_to_gather.begin();\n         iter != origins_to_gather.end(); iter++)\n      client_->GetOriginUsage(\n          *iter,\n          tracker_->type(),\n          callback_factory_.NewCallback(&GatherUsageTaskBase::DidGetUsage));\n  }\n","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":348444,"func":"static void ax_changedmtu(struct mkiss *ax)\n{\n\tstruct net_device *dev = ax->dev;\n\tunsigned char *xbuff, *rbuff, *oxbuff, *orbuff;\n\tint len;\n\n\tlen = dev->mtu * 2;\n\n\t\/*\n\t * allow for arrival of larger UDP packets, even if we say not to\n\t * also fixes a bug in which SunOS sends 512-byte packets even with\n\t * an MSS of 128\n\t *\/\n\tif (len < 576 * 2)\n\t\tlen = 576 * 2;\n\n\txbuff = kmalloc(len + 4, GFP_ATOMIC);\n\trbuff = kmalloc(len + 4, GFP_ATOMIC);\n\n\tif (xbuff == NULL || rbuff == NULL)  {\n\t\tprintk(KERN_ERR \"mkiss: %s: unable to grow ax25 buffers, \"\n\t\t       \"MTU change cancelled.\\n\",\n\t\t       ax->dev->name);\n\t\tdev->mtu = ax->mtu;\n\t\tkfree(xbuff);\n\t\tkfree(rbuff);\n\t\treturn;\n\t}\n\n\tspin_lock_bh(&ax->buflock);\n\n\toxbuff    = ax->xbuff;\n\tax->xbuff = xbuff;\n\torbuff    = ax->rbuff;\n\tax->rbuff = rbuff;\n\n\tif (ax->xleft) {\n\t\tif (ax->xleft <= len) {\n\t\t\tmemcpy(ax->xbuff, ax->xhead, ax->xleft);\n\t\t} else  {\n\t\t\tax->xleft = 0;\n\t\t\tdev->stats.tx_dropped++;\n\t\t}\n\t}\n\n\tax->xhead = ax->xbuff;\n\n\tif (ax->rcount) {\n\t\tif (ax->rcount <= len) {\n\t\t\tmemcpy(ax->rbuff, orbuff, ax->rcount);\n\t\t} else  {\n\t\t\tax->rcount = 0;\n\t\t\tdev->stats.rx_over_errors++;\n\t\t\tset_bit(AXF_ERROR, &ax->flags);\n\t\t}\n\t}\n\n\tax->mtu      = dev->mtu + 73;\n\tax->buffsize = len;\n\n\tspin_unlock_bh(&ax->buflock);\n\n\tkfree(oxbuff);\n\tkfree(orbuff);\n}","target":0,"code_token_length":465,"total_token_length":701,"max_tokens_setting":1024}
+{"idx":500682,"func":"int sftp_unlink(sftp_session sftp, const char *file) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  ssh_string filename;\n  ssh_buffer buffer;\n  uint32_t id;\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return -1;\n  }\n\n  filename = ssh_string_from_char(file);\n  if (filename == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return -1;\n  }\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, filename) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    ssh_string_free(filename);\n    return -1;\n  }\n  if (sftp_packet_write(sftp, SSH_FXP_REMOVE, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(filename);\n    return -1;\n  }\n  ssh_string_free(filename);\n  ssh_buffer_free(buffer);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp)) {\n      return -1;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  if (msg->packet_type == SSH_FXP_STATUS) {\n    \/* by specification, this command's only supposed to return SSH_FXP_STATUS *\/\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return -1;\n    }\n    sftp_set_error(sftp, status->status);\n    switch (status->status) {\n      case SSH_FX_OK:\n        status_msg_free(status);\n        return 0;\n      default:\n        break;\n    }\n\n    \/*\n     * The status should be SSH_FX_OK if the command was successful, if it\n     * didn't, then there was an error\n     *\/\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n    return -1;\n  } else {\n    ssh_set_error(sftp->session,SSH_FATAL,\n        \"Received message %d when attempting to remove file\", msg->packet_type);\n    sftp_message_free(msg);\n  }\n\n  return -1;\n}","target":0,"code_token_length":517,"total_token_length":753,"max_tokens_setting":1024}
+{"idx":355641,"func":"eval7_leader(\n\ttypval_T    *rettv,\n\tint\t    numeric_only,\n\tchar_u\t    *start_leader,\n\tchar_u\t    **end_leaderp)\n{\n    char_u\t*end_leader = *end_leaderp;\n    int\t\tret = OK;\n    int\t\terror = FALSE;\n    varnumber_T val = 0;\n    vartype_T\ttype = rettv->v_type;\n#ifdef FEAT_FLOAT\n    float_T\t    f = 0.0;\n\n    if (rettv->v_type == VAR_FLOAT)\n\tf = rettv->vval.v_float;\n    else\n#endif\n    {\n\twhile (VIM_ISWHITE(end_leader[-1]))\n\t    --end_leader;\n\tif (in_vim9script() && end_leader[-1] == '!')\n\t    val = tv2bool(rettv);\n\telse\n\t    val = tv_get_number_chk(rettv, &error);\n    }\n    if (error)\n    {\n\tclear_tv(rettv);\n\tret = FAIL;\n    }\n    else\n    {\n\twhile (end_leader > start_leader)\n\t{\n\t    --end_leader;\n\t    if (*end_leader == '!')\n\t    {\n\t\tif (numeric_only)\n\t\t{\n\t\t    ++end_leader;\n\t\t    break;\n\t\t}\n#ifdef FEAT_FLOAT\n\t\tif (rettv->v_type == VAR_FLOAT)\n\t\t{\n\t\t    if (in_vim9script())\n\t\t    {\n\t\t\trettv->v_type = VAR_BOOL;\n\t\t\tval = f == 0.0 ? VVAL_TRUE : VVAL_FALSE;\n\t\t    }\n\t\t    else\n\t\t\tf = !f;\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t    val = !val;\n\t\t    type = VAR_BOOL;\n\t\t}\n\t    }\n\t    else if (*end_leader == '-')\n\t    {\n#ifdef FEAT_FLOAT\n\t\tif (rettv->v_type == VAR_FLOAT)\n\t\t    f = -f;\n\t\telse\n#endif\n\t\t{\n\t\t    val = -val;\n\t\t    type = VAR_NUMBER;\n\t\t}\n\t    }\n\t}\n#ifdef FEAT_FLOAT\n\tif (rettv->v_type == VAR_FLOAT)\n\t{\n\t    clear_tv(rettv);\n\t    rettv->vval.v_float = f;\n\t}\n\telse\n#endif\n\t{\n\t    clear_tv(rettv);\n\t    if (in_vim9script())\n\t\trettv->v_type = type;\n\t    else\n\t\trettv->v_type = VAR_NUMBER;\n\t    rettv->vval.v_number = val;\n\t}\n    }\n    *end_leaderp = end_leader;\n    return ret;\n}","target":0,"code_token_length":521,"total_token_length":757,"max_tokens_setting":1024}
+{"idx":289253,"func":"static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct count_info __user * _info)\n{\t\n\tstruct snd_pcm_substream *substream;\n\tstruct snd_pcm_runtime *runtime;\n\tsnd_pcm_sframes_t delay;\n\tint fixup;\n\tstruct count_info info;\n\tint err;\n\n\tif (_info == NULL)\n\t\treturn -EFAULT;\n\tsubstream = pcm_oss_file->streams[stream];\n\tif (substream == NULL)\n\t\treturn -EINVAL;\n\terr = snd_pcm_oss_make_ready(substream);\n\tif (err < 0)\n\t\treturn err;\n\truntime = substream->runtime;\n\tif (runtime->oss.params || runtime->oss.prepare) {\n\t\tmemset(&info, 0, sizeof(info));\n\t\tif (copy_to_user(_info, &info, sizeof(info)))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tif (stream == SNDRV_PCM_STREAM_PLAYBACK) {\n\t\terr = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay);\n\t\tif (err == -EPIPE || err == -ESTRPIPE || (! err && delay < 0)) {\n\t\t\terr = 0;\n\t\t\tdelay = 0;\n\t\t\tfixup = 0;\n\t\t} else {\n\t\t\tfixup = runtime->oss.buffer_used;\n\t\t}\n\t} else {\n\t\terr = snd_pcm_oss_capture_position_fixup(substream, &delay);\n\t\tfixup = -runtime->oss.buffer_used;\n\t}\n\tif (err < 0)\n\t\treturn err;\n\tinfo.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size);\n\tif (atomic_read(&substream->mmap_count)) {\n\t\tsnd_pcm_sframes_t n;\n\t\tdelay = get_hw_ptr_period(runtime);\n\t\tn = delay - runtime->oss.prev_hw_ptr_period;\n\t\tif (n < 0)\n\t\t\tn += runtime->boundary;\n\t\tinfo.blocks = n \/ runtime->period_size;\n\t\truntime->oss.prev_hw_ptr_period = delay;\n\t\tif (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)\n\t\t\tsnd_pcm_oss_simulate_fill(substream, delay);\n\t\tinfo.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;\n\t} else {\n\t\tdelay = snd_pcm_oss_bytes(substream, delay);\n\t\tif (stream == SNDRV_PCM_STREAM_PLAYBACK) {\n\t\t\tif (substream->oss.setup.buggyptr)\n\t\t\t\tinfo.blocks = (runtime->oss.buffer_bytes - delay - fixup) \/ runtime->oss.period_bytes;\n\t\t\telse\n\t\t\t\tinfo.blocks = (delay + fixup) \/ runtime->oss.period_bytes;\n\t\t\tinfo.bytes = (runtime->oss.bytes - delay) & INT_MAX;\n\t\t} else {\n\t\t\tdelay += fixup;\n\t\t\tinfo.blocks = delay \/ runtime->oss.period_bytes;\n\t\t\tinfo.bytes = (runtime->oss.bytes + delay) & INT_MAX;\n\t\t}\n\t}\n\tif (copy_to_user(_info, &info, sizeof(info)))\n\t\treturn -EFAULT;\n\treturn 0;\n}","target":0,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":233937,"func":"DocumentSource::GetNextResult DocumentSourceUnionWith::doGetNext() {\n    if (!_pipeline) {\n        \/\/ We must have already been disposed, so we're finished.\n        return GetNextResult::makeEOF();\n    }\n\n    if (_executionState == ExecutionProgress::kIteratingSource) {\n        auto nextInput = pSource->getNext();\n        if (!nextInput.isEOF()) {\n            return nextInput;\n        }\n        _executionState = ExecutionProgress::kStartingSubPipeline;\n        \/\/ All documents from the base collection have been returned, switch to iterating the sub-\n        \/\/ pipeline by falling through below.\n    }\n\n    if (_executionState == ExecutionProgress::kStartingSubPipeline) {\n        auto serializedPipe = _pipeline->serializeToBson();\n        \/\/ $$SEARCH_META can be set during runtime earlier in the pipeline, and therefore must be\n        \/\/ copied to the subpipeline manually.\n        if (pExpCtx->variables.hasConstantValue(Variables::kSearchMetaId)) {\n            _pipeline->getContext()->variables.setReservedValue(\n                Variables::kSearchMetaId,\n                pExpCtx->variables.getValue(Variables::kSearchMetaId, Document()),\n                true);\n        }\n        logStartingSubPipeline(serializedPipe);\n        try {\n            _pipeline =\n                pExpCtx->mongoProcessInterface->attachCursorSourceToPipeline(_pipeline.release());\n            _executionState = ExecutionProgress::kIteratingSubPipeline;\n        } catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& e) {\n            _pipeline = buildPipelineFromViewDefinition(\n                pExpCtx,\n                ExpressionContext::ResolvedNamespace{e->getNamespace(), e->getPipeline()},\n                serializedPipe);\n            logShardedViewFound(e);\n            return doGetNext();\n        }\n    }\n\n    auto res = _pipeline->getNext();\n    if (res)\n        return std::move(*res);\n\n    \/\/ Record the plan summary stats after $unionWith operation is done.\n    recordPlanSummaryStats(*_pipeline);\n\n    _executionState = ExecutionProgress::kFinished;\n    return GetNextResult::makeEOF();\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":459523,"func":"static long __bpf_get_stackid(struct bpf_map *map,\n\t\t\t      struct perf_callchain_entry *trace, u64 flags)\n{\n\tstruct bpf_stack_map *smap = container_of(map, struct bpf_stack_map, map);\n\tstruct stack_map_bucket *bucket, *new_bucket, *old_bucket;\n\tu32 max_depth = map->value_size \/ stack_map_data_size(map);\n\t\/* stack_map_alloc() checks that max_depth <= sysctl_perf_event_max_stack *\/\n\tu32 init_nr = sysctl_perf_event_max_stack - max_depth;\n\tu32 skip = flags & BPF_F_SKIP_FIELD_MASK;\n\tu32 hash, id, trace_nr, trace_len;\n\tbool user = flags & BPF_F_USER_STACK;\n\tu64 *ips;\n\tbool hash_matches;\n\n\t\/* get_perf_callchain() guarantees that trace->nr >= init_nr\n\t * and trace-nr <= sysctl_perf_event_max_stack, so trace_nr <= max_depth\n\t *\/\n\ttrace_nr = trace->nr - init_nr;\n\n\tif (trace_nr <= skip)\n\t\t\/* skipping more than usable stack trace *\/\n\t\treturn -EFAULT;\n\n\ttrace_nr -= skip;\n\ttrace_len = trace_nr * sizeof(u64);\n\tips = trace->ip + skip + init_nr;\n\thash = jhash2((u32 *)ips, trace_len \/ sizeof(u32), 0);\n\tid = hash & (smap->n_buckets - 1);\n\tbucket = READ_ONCE(smap->buckets[id]);\n\n\thash_matches = bucket && bucket->hash == hash;\n\t\/* fast cmp *\/\n\tif (hash_matches && flags & BPF_F_FAST_STACK_CMP)\n\t\treturn id;\n\n\tif (stack_map_use_build_id(map)) {\n\t\t\/* for build_id+offset, pop a bucket before slow cmp *\/\n\t\tnew_bucket = (struct stack_map_bucket *)\n\t\t\tpcpu_freelist_pop(&smap->freelist);\n\t\tif (unlikely(!new_bucket))\n\t\t\treturn -ENOMEM;\n\t\tnew_bucket->nr = trace_nr;\n\t\tstack_map_get_build_id_offset(\n\t\t\t(struct bpf_stack_build_id *)new_bucket->data,\n\t\t\tips, trace_nr, user);\n\t\ttrace_len = trace_nr * sizeof(struct bpf_stack_build_id);\n\t\tif (hash_matches && bucket->nr == trace_nr &&\n\t\t    memcmp(bucket->data, new_bucket->data, trace_len) == 0) {\n\t\t\tpcpu_freelist_push(&smap->freelist, &new_bucket->fnode);\n\t\t\treturn id;\n\t\t}\n\t\tif (bucket && !(flags & BPF_F_REUSE_STACKID)) {\n\t\t\tpcpu_freelist_push(&smap->freelist, &new_bucket->fnode);\n\t\t\treturn -EEXIST;\n\t\t}\n\t} else {\n\t\tif (hash_matches && bucket->nr == trace_nr &&\n\t\t    memcmp(bucket->data, ips, trace_len) == 0)\n\t\t\treturn id;\n\t\tif (bucket && !(flags & BPF_F_REUSE_STACKID))\n\t\t\treturn -EEXIST;\n\n\t\tnew_bucket = (struct stack_map_bucket *)\n\t\t\tpcpu_freelist_pop(&smap->freelist);\n\t\tif (unlikely(!new_bucket))\n\t\t\treturn -ENOMEM;\n\t\tmemcpy(new_bucket->data, ips, trace_len);\n\t}\n\n\tnew_bucket->hash = hash;\n\tnew_bucket->nr = trace_nr;\n\n\told_bucket = xchg(&smap->buckets[id], new_bucket);\n\tif (old_bucket)\n\t\tpcpu_freelist_push(&smap->freelist, &old_bucket->fnode);\n\treturn id;\n}","target":0,"code_token_length":732,"total_token_length":968,"max_tokens_setting":1024}
+{"idx":463147,"func":"EXPORTED int annotatemore_rawwrite(const char *mboxname, const char *entry,\n                                   const char *userid, const struct buf *value)\n{\n    char key[MAX_MAILBOX_PATH+1];\n    int keylen, r;\n    annotate_db_t *d = NULL;\n    uint32_t uid = 0;\n\n    init_internal();\n\n    r = _annotate_getdb(mboxname, uid, CYRUSDB_CREATE, &d);\n    if (r) goto done;\n\n    \/* must be in a transaction to modify the db *\/\n    annotate_begin(d);\n\n    keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key));\n\n    if (value->s == NULL) {\n        do {\n            r = cyrusdb_delete(d->db, key, keylen, tid(d), \/*force*\/1);\n        } while (r == CYRUSDB_AGAIN);\n    }\n    else {\n        struct buf data = BUF_INITIALIZER;\n\n        make_entry(&data, value, uid, \/*flags*\/0);\n\n        do {\n            r = cyrusdb_store(d->db, key, keylen, data.s, data.len, tid(d));\n        } while (r == CYRUSDB_AGAIN);\n        buf_free(&data);\n    }\n\n    if (r) goto done;\n    r = annotate_commit(d);\n\ndone:\n    annotate_putdb(&d);\n\n    return r;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":226214,"func":"\nGF_Err subs_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_SubSampleInformationBox *ptr = (GF_SubSampleInformationBox *)s;\n\tu32 entry_count, i, j;\n\tu16 subsample_count;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tentry_count = gf_bs_read_u32(bs);\n\n\tfor (i=0; i<entry_count; i++) {\n\t\tu32 subs_size=0;\n\t\tGF_SubSampleInfoEntry *pSamp = (GF_SubSampleInfoEntry*) gf_malloc(sizeof(GF_SubSampleInfoEntry));\n\t\tif (!pSamp) return GF_OUT_OF_MEM;\n\n\t\tmemset(pSamp, 0, sizeof(GF_SubSampleInfoEntry));\n\t\tpSamp->SubSamples = gf_list_new();\n\t\tpSamp->sample_delta = gf_bs_read_u32(bs);\n\t\tsubsample_count = gf_bs_read_u16(bs);\n\t\tsubs_size=6;\n\n\t\tfor (j=0; j<subsample_count; j++) {\n\t\t\tGF_SubSampleEntry *pSubSamp = (GF_SubSampleEntry*) gf_malloc(sizeof(GF_SubSampleEntry));\n\t\t\tif (!pSubSamp) return GF_OUT_OF_MEM;\n\n\t\t\tmemset(pSubSamp, 0, sizeof(GF_SubSampleEntry));\n\t\t\tif (ptr->version==1) {\n\t\t\t\tpSubSamp->subsample_size = gf_bs_read_u32(bs);\n\t\t\t\tsubs_size+=4;\n\t\t\t} else {\n\t\t\t\tpSubSamp->subsample_size = gf_bs_read_u16(bs);\n\t\t\t\tsubs_size+=2;\n\t\t\t}\n\t\t\tpSubSamp->subsample_priority = gf_bs_read_u8(bs);\n\t\t\tpSubSamp->discardable = gf_bs_read_u8(bs);\n\t\t\tpSubSamp->reserved = gf_bs_read_u32(bs);\n\t\t\tsubs_size+=6;\n\n\t\t\tgf_list_add(pSamp->SubSamples, pSubSamp);\n\t\t}\n\t\tgf_list_add(ptr->Samples, pSamp);\n\t\tISOM_DECREASE_SIZE(ptr, subs_size);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":456,"total_token_length":692,"max_tokens_setting":1024}
+{"idx":369916,"func":"static ssize_t oom_adjust_write(struct file *file, const char __user *buf,\n\t\t\t\tsize_t count, loff_t *ppos)\n{\n\tstruct task_struct *task;\n\tchar buffer[PROC_NUMBUF];\n\tint oom_adjust;\n\tunsigned long flags;\n\tint err;\n\n\tmemset(buffer, 0, sizeof(buffer));\n\tif (count > sizeof(buffer) - 1)\n\t\tcount = sizeof(buffer) - 1;\n\tif (copy_from_user(buffer, buf, count)) {\n\t\terr = -EFAULT;\n\t\tgoto out;\n\t}\n\n\terr = kstrtoint(strstrip(buffer), 0, &oom_adjust);\n\tif (err)\n\t\tgoto out;\n\tif ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) &&\n\t     oom_adjust != OOM_DISABLE) {\n\t\terr = -EINVAL;\n\t\tgoto out;\n\t}\n\n\ttask = get_proc_task(file->f_path.dentry->d_inode);\n\tif (!task) {\n\t\terr = -ESRCH;\n\t\tgoto out;\n\t}\n\n\ttask_lock(task);\n\tif (!task->mm) {\n\t\terr = -EINVAL;\n\t\tgoto err_task_lock;\n\t}\n\n\tif (!lock_task_sighand(task, &flags)) {\n\t\terr = -ESRCH;\n\t\tgoto err_task_lock;\n\t}\n\n\tif (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {\n\t\terr = -EACCES;\n\t\tgoto err_sighand;\n\t}\n\n\t\/*\n\t * Warn that \/proc\/pid\/oom_adj is deprecated, see\n\t * Documentation\/feature-removal-schedule.txt.\n\t *\/\n\tprintk_once(KERN_WARNING \"%s (%d): \/proc\/%d\/oom_adj is deprecated, please use \/proc\/%d\/oom_score_adj instead.\\n\",\n\t\t  current->comm, task_pid_nr(current), task_pid_nr(task),\n\t\t  task_pid_nr(task));\n\ttask->signal->oom_adj = oom_adjust;\n\t\/*\n\t * Scale \/proc\/pid\/oom_score_adj appropriately ensuring that a maximum\n\t * value is always attainable.\n\t *\/\n\tif (task->signal->oom_adj == OOM_ADJUST_MAX)\n\t\ttask->signal->oom_score_adj = OOM_SCORE_ADJ_MAX;\n\telse\n\t\ttask->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) \/\n\t\t\t\t\t\t\t\t-OOM_DISABLE;\n\ttrace_oom_score_adj_update(task);\nerr_sighand:\n\tunlock_task_sighand(task, &flags);\nerr_task_lock:\n\ttask_unlock(task);\n\tput_task_struct(task);\nout:\n\treturn err < 0 ? err : count;\n}","target":0,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":256431,"func":"static pj_status_t get_codec_info_from_sdp(pjmedia_endpt *endpt,\n\t\t\t\t\t   const pjmedia_sdp_media *m,\n\t\t\t\t\t   unsigned *sci_cnt,\n\t\t\t\t\t   sdp_codec_info_t sci[])\n{\n    pjmedia_codec_mgr *codec_mgr;\n    unsigned j, cnt = 0;\n    pjmedia_type type = PJMEDIA_TYPE_UNKNOWN;\n    pj_status_t status;\n\n    type = pjmedia_get_type(&m->desc.media);\n    if (type != PJMEDIA_TYPE_AUDIO && type != PJMEDIA_TYPE_VIDEO)\n\treturn PJMEDIA_EUNSUPMEDIATYPE;\n\n    codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);\n    for (j = 0; j < m->desc.fmt_count && cnt < *sci_cnt; ++j) {\n\tunsigned pt = 0;\n\tpt = pj_strtoul(&m->desc.fmt[j]);\n\tif (pt < 96) {\n\t    if (type == PJMEDIA_TYPE_AUDIO) {\n\t\tconst pjmedia_codec_info *ci;\n\t\tstatus = pjmedia_codec_mgr_get_codec_info(codec_mgr, pt, &ci);\n\t\tif (status != PJ_SUCCESS)\n\t\t    continue;\n\n\t\tpjmedia_codec_info_to_id(ci, sci[cnt].id, sizeof(sci[0].id));\n\t    } else {\n#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)\n\t\tconst pjmedia_vid_codec_info *ci;\n\t\tstatus = pjmedia_vid_codec_mgr_get_codec_info(NULL, pt, &ci);\n\t\tif (status != PJ_SUCCESS)\n\t\t    continue;\n\n\t\tpjmedia_vid_codec_info_to_id(ci, sci[cnt].id,\n\t\t\t\t\t     sizeof(sci[0].id));\n#else\n\t\tcontinue;\n#endif\n\t    }\n\t} else {\n\t    pjmedia_sdp_attr *a;\n\t    pjmedia_sdp_rtpmap r;\n\t    a = pjmedia_sdp_media_find_attr2(m, \"rtpmap\",\n\t\t\t\t\t     &m->desc.fmt[j]);\n\t    if (a == NULL)\n\t\tcontinue;\n\t    status = pjmedia_sdp_attr_get_rtpmap(a, &r);\n\t    if (status != PJ_SUCCESS)\n\t\tcontinue;\n\n\t    if (type == PJMEDIA_TYPE_AUDIO) {\n\t\t\/* Audio codec id format: \"name\/clock-rate\/channel-count\" *\/\n\t\tif (r.param.slen) {\n\t\t    pj_ansi_snprintf(sci[cnt].id, sizeof(sci[0].id),\n\t\t\t\t     \"%.*s\/%d\/%.*s\",\n\t\t\t\t     (int)r.enc_name.slen, r.enc_name.ptr,\n\t\t\t\t     r.clock_rate,\n\t\t\t\t     (int)r.param.slen, r.param.ptr);\n\t\t} else {\n\t\t    pj_ansi_snprintf(sci[cnt].id, sizeof(sci[0].id),\n\t\t\t\t     \"%.*s\/%d\/1\",\n\t\t\t\t     (int)r.enc_name.slen, r.enc_name.ptr,\n\t\t\t\t     r.clock_rate);\n\t\t}\n\t    } else {\n\t\t\/* Video codec id format: \"name\/payload-type\" *\/\n\t\tpj_ansi_snprintf(sci[cnt].id, sizeof(sci[0].id),\n\t\t\t\t \"%.*s\/%d\",\n\t\t\t\t (int)r.enc_name.slen, r.enc_name.ptr, pt);\n\t    }\n\t}\n\tsci[cnt++].pt = pt;\n    }\n    *sci_cnt = cnt;\n    \n    return PJ_SUCCESS;\n}","target":0,"code_token_length":690,"total_token_length":926,"max_tokens_setting":1024}
+{"idx":484053,"func":"testSuite_SecureChannel(void) {\n    Suite *s = suite_create(\"SecureChannel\");\n\n    TCase *tc_initAndDelete = tcase_create(\"Initialize and delete Securechannel\");\n    tcase_add_checked_fixture(tc_initAndDelete, setup_funcs_called, teardown_funcs_called);\n    tcase_add_checked_fixture(tc_initAndDelete, setup_key_sizes, teardown_key_sizes);\n    tcase_add_test(tc_initAndDelete, SecureChannel_initAndDelete);\n    suite_add_tcase(s, tc_initAndDelete);\n\n    TCase *tc_sendAsymmetricOPNMessage = tcase_create(\"Test sendAsymmetricOPNMessage function\");\n    tcase_add_checked_fixture(tc_sendAsymmetricOPNMessage, setup_funcs_called, teardown_funcs_called);\n    tcase_add_checked_fixture(tc_sendAsymmetricOPNMessage, setup_key_sizes, teardown_key_sizes);\n    tcase_add_checked_fixture(tc_sendAsymmetricOPNMessage, setup_secureChannel, teardown_secureChannel);\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_withoutConnection);\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_invalidParameters);\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeInvalid);\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeNone);\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_sentDataIsValid);\n#ifdef UA_ENABLE_ENCRYPTION\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeSign);\n    tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeSignAndEncrypt);\n    tcase_add_test(tc_sendAsymmetricOPNMessage,\n                   Securechannel_sendAsymmetricOPNMessage_extraPaddingPresentWhenKeyLargerThan2048Bits);\n#endif\n    suite_add_tcase(s, tc_sendAsymmetricOPNMessage);\n\n    TCase *tc_sendSymmetricMessage = tcase_create(\"Test sendSymmetricMessage function\");\n    tcase_add_checked_fixture(tc_sendSymmetricMessage, setup_funcs_called, teardown_funcs_called);\n    tcase_add_checked_fixture(tc_sendSymmetricMessage, setup_key_sizes, teardown_key_sizes);\n    tcase_add_checked_fixture(tc_sendSymmetricMessage, setup_secureChannel, teardown_secureChannel);\n    tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage);\n    tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_invalidParameters);\n    tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_modeNone);\n#ifdef UA_ENABLE_ENCRYPTION\n    tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_modeSign);\n    tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_modeSignAndEncrypt);\n#endif\n    suite_add_tcase(s, tc_sendSymmetricMessage);\n\n    TCase *tc_processBuffer = tcase_create(\"Test chunk assembly\");\n    tcase_add_checked_fixture(tc_processBuffer, setup_funcs_called, teardown_funcs_called);\n    tcase_add_checked_fixture(tc_processBuffer, setup_key_sizes, teardown_key_sizes);\n    tcase_add_checked_fixture(tc_processBuffer, setup_secureChannel, teardown_secureChannel);\n    tcase_add_test(tc_processBuffer, SecureChannel_assemblePartialChunks);\n    suite_add_tcase(s, tc_processBuffer);\n\n    return s;\n}","target":0,"code_token_length":739,"total_token_length":975,"max_tokens_setting":1024}
+{"idx":436132,"func":"\nstatic int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,\n\t\t\t   bool is_timeout_link)\n{\n\tstruct io_timeout_data *data;\n\tunsigned flags;\n\tu32 off = READ_ONCE(sqe->off);\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->buf_index || sqe->len != 1)\n\t\treturn -EINVAL;\n\tif (off && is_timeout_link)\n\t\treturn -EINVAL;\n\tflags = READ_ONCE(sqe->timeout_flags);\n\tif (flags & ~IORING_TIMEOUT_ABS)\n\t\treturn -EINVAL;\n\n\treq->timeout.off = off;\n\tif (unlikely(off && !req->ctx->off_timeout_used))\n\t\treq->ctx->off_timeout_used = true;\n\n\tif (!req->async_data && io_alloc_async_data(req))\n\t\treturn -ENOMEM;\n\n\tdata = req->async_data;\n\tdata->req = req;\n\n\tif (get_timespec64(&data->ts, u64_to_user_ptr(sqe->addr)))\n\t\treturn -EFAULT;\n\n\tdata->mode = io_translate_timeout_mode(flags);\n\thrtimer_init(&data->timer, CLOCK_MONOTONIC, data->mode);\n\tif (is_timeout_link)\n\t\tio_req_track_inflight(req);\n\treturn 0;","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
+{"idx":270111,"func":"TfLiteStatus CalculateActivationRangeQuantizedImpl(\n    TfLiteContext* context, TfLiteFusedActivation activation, int32_t qmin,\n    int32_t qmax, TfLiteTensor* output, int32_t* act_min, int32_t* act_max) {\n  const auto scale = output->params.scale;\n  const auto zero_point = output->params.zero_point;\n\n  int32_t tmp_q;\n  if (activation == kTfLiteActRelu) {\n    TF_LITE_ENSURE_OK(context,\n                      Quantize(context, scale, zero_point, 0.0, tmp_q));\n    *act_min = std::max(qmin, tmp_q);\n    *act_max = qmax;\n  } else if (activation == kTfLiteActRelu6) {\n    TF_LITE_ENSURE_OK(context,\n                      Quantize(context, scale, zero_point, 0.0, tmp_q));\n    *act_min = std::max(qmin, tmp_q);\n    TF_LITE_ENSURE_OK(context,\n                      Quantize(context, scale, zero_point, 6.0, tmp_q));\n    *act_max = std::min(qmax, tmp_q);\n  } else if (activation == kTfLiteActReluN1To1) {\n    TF_LITE_ENSURE_OK(context,\n                      Quantize(context, scale, zero_point, -1.0, tmp_q));\n    *act_min = std::max(qmin, tmp_q);\n    TF_LITE_ENSURE_OK(context,\n                      Quantize(context, scale, zero_point, 1.0, tmp_q));\n    *act_max = std::min(qmax, tmp_q);\n  } else {\n    *act_min = qmin;\n    *act_max = qmax;\n  }\n  return kTfLiteOk;\n}","target":0,"code_token_length":383,"total_token_length":619,"max_tokens_setting":1024}
+{"idx":384207,"func":"static int nf_tables_dump_flowtable(struct sk_buff *skb,\n\t\t\t\t    struct netlink_callback *cb)\n{\n\tconst struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);\n\tstruct nft_flowtable_filter *filter = cb->data;\n\tunsigned int idx = 0, s_idx = cb->args[0];\n\tstruct net *net = sock_net(skb->sk);\n\tint family = nfmsg->nfgen_family;\n\tstruct nft_flowtable *flowtable;\n\tstruct nftables_pernet *nft_net;\n\tconst struct nft_table *table;\n\n\trcu_read_lock();\n\tnft_net = nft_pernet(net);\n\tcb->seq = READ_ONCE(nft_net->base_seq);\n\n\tlist_for_each_entry_rcu(table, &nft_net->tables, list) {\n\t\tif (family != NFPROTO_UNSPEC && family != table->family)\n\t\t\tcontinue;\n\n\t\tlist_for_each_entry_rcu(flowtable, &table->flowtables, list) {\n\t\t\tif (!nft_is_active(net, flowtable))\n\t\t\t\tgoto cont;\n\t\t\tif (idx < s_idx)\n\t\t\t\tgoto cont;\n\t\t\tif (idx > s_idx)\n\t\t\t\tmemset(&cb->args[1], 0,\n\t\t\t\t       sizeof(cb->args) - sizeof(cb->args[0]));\n\t\t\tif (filter && filter->table &&\n\t\t\t    strcmp(filter->table, table->name))\n\t\t\t\tgoto cont;\n\n\t\t\tif (nf_tables_fill_flowtable_info(skb, net, NETLINK_CB(cb->skb).portid,\n\t\t\t\t\t\t\t  cb->nlh->nlmsg_seq,\n\t\t\t\t\t\t\t  NFT_MSG_NEWFLOWTABLE,\n\t\t\t\t\t\t\t  NLM_F_MULTI | NLM_F_APPEND,\n\t\t\t\t\t\t\t  table->family,\n\t\t\t\t\t\t\t  flowtable,\n\t\t\t\t\t\t\t  &flowtable->hook_list) < 0)\n\t\t\t\tgoto done;\n\n\t\t\tnl_dump_check_consistent(cb, nlmsg_hdr(skb));\ncont:\n\t\t\tidx++;\n\t\t}\n\t}\ndone:\n\trcu_read_unlock();\n\n\tcb->args[0] = idx;\n\treturn skb->len;\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":448549,"func":"static struct stream *bgp_update_packet_eor(struct peer *peer, afi_t afi,\n\t\t\t\t\t    safi_t safi)\n{\n\tstruct stream *s;\n\tiana_afi_t pkt_afi = IANA_AFI_IPV4;\n\tiana_safi_t pkt_safi = IANA_SAFI_UNICAST;\n\n\tif (DISABLE_BGP_ANNOUNCE)\n\t\treturn NULL;\n\n\tif (bgp_debug_neighbor_events(peer))\n\t\tzlog_debug(\"send End-of-RIB for %s to %s\",\n\t\t\t   get_afi_safi_str(afi, safi, false), peer->host);\n\n\ts = stream_new(peer->max_packet_size);\n\n\t\/* Make BGP update packet. *\/\n\tbgp_packet_set_marker(s, BGP_MSG_UPDATE);\n\n\t\/* Unfeasible Routes Length *\/\n\tstream_putw(s, 0);\n\n\tif (afi == AFI_IP && safi == SAFI_UNICAST) {\n\t\t\/* Total Path Attribute Length *\/\n\t\tstream_putw(s, 0);\n\t} else {\n\t\t\/* Convert AFI, SAFI to values for packet. *\/\n\t\tbgp_map_afi_safi_int2iana(afi, safi, &pkt_afi, &pkt_safi);\n\n\t\t\/* Total Path Attribute Length *\/\n\t\tstream_putw(s, 6);\n\t\tstream_putc(s, BGP_ATTR_FLAG_OPTIONAL);\n\t\tstream_putc(s, BGP_ATTR_MP_UNREACH_NLRI);\n\t\tstream_putc(s, 3);\n\t\tstream_putw(s, pkt_afi);\n\t\tstream_putc(s, pkt_safi);\n\t}\n\n\tbgp_packet_set_size(s);\n\treturn s;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":314525,"func":"PJ_DEF(pj_uint32_t) pjmedia_sdp_transport_get_proto(const pj_str_t *tp)\n{\n    pj_str_t token, rest = {0};\n    pj_ssize_t idx;\n\n    PJ_ASSERT_RETURN(tp, PJMEDIA_TP_PROTO_NONE);\n\n    idx = pj_strtok2(tp, \"\/\", &token, 0);\n    if (idx != tp->slen)\n\tpj_strset(&rest, tp->ptr + token.slen + 1, tp->slen - token.slen - 1);\n\n    if (pj_stricmp2(&token, \"RTP\") == 0) {\n\t\/* Starts with \"RTP\" *\/\n\n\t\/* RTP\/AVP *\/\n\tif (pj_stricmp2(&rest, \"AVP\") == 0)\n\t    return PJMEDIA_TP_PROTO_RTP_AVP;\n\n\t\/* RTP\/SAVP *\/\n\tif (pj_stricmp2(&rest, \"SAVP\") == 0)\n\t    return PJMEDIA_TP_PROTO_RTP_SAVP;\n\n\t\/* RTP\/AVPF *\/\n\tif (pj_stricmp2(&rest, \"AVPF\") == 0)\n\t    return PJMEDIA_TP_PROTO_RTP_AVPF;\n\n\t\/* RTP\/SAVPF *\/\n\tif (pj_stricmp2(&rest, \"SAVPF\") == 0)\n\t    return PJMEDIA_TP_PROTO_RTP_SAVPF;\n\n    } else if (pj_stricmp2(&token, \"UDP\") == 0) {\n\t\/* Starts with \"UDP\" *\/\n\n\t\/* Plain UDP *\/\n\tif (rest.slen == 0)\n\t    return PJMEDIA_TP_PROTO_UDP;\n\n\t\/* DTLS-SRTP *\/\n\tif (pj_stricmp2(&rest, \"TLS\/RTP\/SAVP\") == 0)\n\t    return PJMEDIA_TP_PROTO_DTLS_SRTP;\n\n\t\/* DTLS-SRTP with RTCP-FB *\/\n\tif (pj_stricmp2(&rest, \"TLS\/RTP\/SAVPF\") == 0)\n\t    return PJMEDIA_TP_PROTO_DTLS_SRTPF;\n    }\n\n    \/* Unknown transport *\/\n    return PJMEDIA_TP_PROTO_UNKNOWN;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":359255,"func":"bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, \n                           afi_t afi, safi_t safi)\n{\n  struct peer *peer;\n  struct listnode *node, *nnode;\n  int count = 0;\n\n  \/* Header string for each address family. *\/\n  static char header[] = \"Neighbor        V    AS  Export-Policy  Import-Policy  Up\/Down  State\";\n\n  for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))\n    {\n      if (peer->afc[afi][safi] &&\n         CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))\n       {\n         if (! count)\n           {\n             vty_out (vty,\n                      \"Route Server's BGP router identifier %s%s\",\n                      inet_ntoa (bgp->router_id), VTY_NEWLINE);\n             vty_out (vty,\n              \"Route Server's local AS number %d%s\", bgp->as,\n                       VTY_NEWLINE);\n\n             vty_out (vty, \"%s\", VTY_NEWLINE);\n             vty_out (vty, \"%s%s\", header, VTY_NEWLINE);\n           }\n\n         count += bgp_write_rsclient_summary (vty, peer, afi, safi);\n       }\n    }\n\n  if (count)\n    vty_out (vty, \"%sTotal number of Route Server Clients %d%s\", VTY_NEWLINE,\n            count, VTY_NEWLINE);\n  else\n    vty_out (vty, \"No %s Route Server Client is configured%s\",\n            afi == AFI_IP ? \"IPv4\" : \"IPv6\", VTY_NEWLINE);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":380,"total_token_length":616,"max_tokens_setting":1024}
+{"idx":231779,"func":"void handleCipherUnavailable(\n    CipherUnavailable* originalData,\n    QuicServerConnectionState& conn,\n    size_t packetSize,\n    ServerEvents::ReadData& readData) {\n  if (!originalData->packet || originalData->packet->empty()) {\n    VLOG(10) << \"drop because no data \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kNoData);\n    }\n    QUIC_TRACE(packet_drop, conn, \"no_data\");\n    return;\n  }\n  if (originalData->protectionType != ProtectionType::ZeroRtt &&\n      originalData->protectionType != ProtectionType::KeyPhaseZero) {\n    VLOG(10) << \"drop because unexpected protection level \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kUnexpectedProtectionLevel);\n    }\n    QUIC_TRACE(packet_drop, conn, \"unexpected_protection_level\");\n    return;\n  }\n\n  size_t combinedSize =\n      (conn.pendingZeroRttData ? conn.pendingZeroRttData->size() : 0) +\n      (conn.pendingOneRttData ? conn.pendingOneRttData->size() : 0);\n  if (combinedSize >= conn.transportSettings.maxPacketsToBuffer) {\n    VLOG(10) << \"drop because max buffered \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kMaxBuffered);\n    }\n    QUIC_TRACE(packet_drop, conn, \"max_buffered\");\n    return;\n  }\n\n  auto& pendingData = originalData->protectionType == ProtectionType::ZeroRtt\n      ? conn.pendingZeroRttData\n      : conn.pendingOneRttData;\n  if (pendingData) {\n    QUIC_TRACE(\n        packet_buffered,\n        conn,\n        originalData->packetNum,\n        originalData->protectionType,\n        packetSize);\n    if (conn.qLogger) {\n      conn.qLogger->addPacketBuffered(\n          originalData->packetNum, originalData->protectionType, packetSize);\n    }\n    ServerEvents::ReadData pendingReadData;\n    pendingReadData.peer = readData.peer;\n    pendingReadData.networkData = NetworkDataSingle(\n        std::move(originalData->packet), readData.networkData.receiveTimePoint);\n    pendingData->emplace_back(std::move(pendingReadData));\n    VLOG(10) << \"Adding pending data to \"\n             << toString(originalData->protectionType)\n             << \" buffer size=\" << pendingData->size() << \" \" << conn;\n  } else {\n    VLOG(10) << \"drop because \" << toString(originalData->protectionType)\n             << \" buffer no longer available \" << conn;\n    if (conn.qLogger) {\n      conn.qLogger->addPacketDrop(packetSize, kBufferUnavailable);\n    }\n    QUIC_TRACE(packet_drop, conn, \"buffer_unavailable\");\n  }\n}","target":0,"code_token_length":636,"total_token_length":872,"max_tokens_setting":1024}
+{"idx":273913,"func":"static int recv_msg(int sd, char *msg, size_t len, char **cmd, char **argument)\n{\n\tchar *ptr;\n\tssize_t bytes;\n\tuint8_t *raw = (uint8_t *)msg;\n\n\t\/* Clear for every new command. *\/\n\tmemset(msg, 0, len);\n\n\t\/* Save one byte (-1) for NUL termination *\/\n\tbytes = recv(sd, msg, len - 1, 0);\n\tif (bytes < 0) {\n\t\tif (EINTR == errno)\n\t\t\treturn 1;\n\n\t\tif (ECONNRESET == errno)\n\t\t\tDBG(\"Connection reset by client.\");\n\t\telse\n\t\t\tERR(errno, \"Failed reading client command\");\n\t\treturn 1;\n\t}\n\n\tif (!bytes) {\n\t\tINFO(\"Client disconnected.\");\n\t\treturn 1;\n\t}\n\n\tif (raw[0] == 0xff) {\n\t\tchar tmp[4];\n\t\tchar buf[20] = { 0 };\n\t\tint i;\n\n\t\ti = recv(sd, &msg[bytes], len - bytes - 1, MSG_OOB | MSG_DONTWAIT);\n\t\tif (i > 0)\n\t\t\tbytes += i;\n\n\t\tfor (i = 0; i < bytes; i++) {\n\t\t\tsnprintf(tmp, sizeof(tmp), \"%2X%s\", raw[i], i + 1 < bytes ? \" \" : \"\");\n\t\t\tstrlcat(buf, tmp, sizeof(buf));\n\t\t}\n\n\t\tstrlcpy(msg, buf, len);\n\t\t*cmd      = msg;\n\t\t*argument = NULL;\n\n\t\tDBG(\"Recv: [%s], %zd bytes\", msg, bytes);\n\n\t\treturn 0;\n\t}\n\n\t\/* NUL terminate for strpbrk() *\/\n\tmsg[bytes] = 0;\n\n\t*cmd = msg;\n\tptr  = strpbrk(msg, \" \");\n\tif (ptr) {\n\t\t*ptr = 0;\n\t\tptr++;\n\t\t*argument = ptr;\n\t} else {\n\t\t*argument = NULL;\n\t\tptr = msg;\n\t}\n\n\tptr = strpbrk(ptr, \"\\r\\n\");\n\tif (ptr)\n\t\t*ptr = 0;\n\n\t\/* Convert command to std ftp upper case, issue #18 *\/\n\tfor (ptr = msg; *ptr; ++ptr) *ptr = toupper(*ptr);\n\n\tDBG(\"Recv: %s %s\", *cmd, *argument ?: \"\");\n\n\treturn 0;\n}","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":513150,"func":"static int plugin_initialize(MEM_ROOT *tmp_root, struct st_plugin_int *plugin,\n                             int *argc, char **argv, bool options_only)\n{\n  int ret= 1;\n  DBUG_ENTER(\"plugin_initialize\");\n\n  mysql_mutex_assert_owner(&LOCK_plugin);\n  uint state= plugin->state;\n  DBUG_ASSERT(state == PLUGIN_IS_UNINITIALIZED);\n\n  mysql_mutex_unlock(&LOCK_plugin);\n\n  mysql_prlock_wrlock(&LOCK_system_variables_hash);\n  if (test_plugin_options(tmp_root, plugin, argc, argv))\n    state= PLUGIN_IS_DISABLED;\n  mysql_prlock_unlock(&LOCK_system_variables_hash);\n\n  if (options_only || state == PLUGIN_IS_DISABLED)\n  {\n    ret= !options_only && plugin_is_forced(plugin);\n    state= PLUGIN_IS_DISABLED;\n    goto err;\n  }\n\n  if (plugin_type_initialize[plugin->plugin->type])\n  {\n    if ((*plugin_type_initialize[plugin->plugin->type])(plugin))\n    {\n      sql_print_error(\"Plugin '%s' registration as a %s failed.\",\n                      plugin->name.str, plugin_type_names[plugin->plugin->type].str);\n      goto err;\n    }\n  }\n  else if (plugin->plugin->init)\n  {\n    if (plugin->plugin->init(plugin))\n    {\n      sql_print_error(\"Plugin '%s' init function returned error.\",\n                      plugin->name.str);\n      goto err;\n    }\n  }\n  state= PLUGIN_IS_READY; \/\/ plugin->init() succeeded\n\n  if (plugin->plugin->status_vars)\n  {\n    \/*\n      historical ndb behavior caused MySQL plugins to specify\n      status var names in full, with the plugin name prefix.\n      this was never fixed in MySQL.\n      MariaDB fixes that but supports MySQL style too.\n    *\/\n    SHOW_VAR *show_vars= plugin->plugin->status_vars;\n    SHOW_VAR tmp_array[2]= {\n      {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},\n      {0, 0, SHOW_UNDEF}\n    };\n    if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length))\n      show_vars= tmp_array;\n\n    if (add_status_vars(show_vars))\n      goto err;\n  }\n\n  ret= 0;\n\nerr:\n  if (ret)\n    plugin_variables_deinit(plugin);\n\n  mysql_mutex_lock(&LOCK_plugin);\n  plugin->state= state;\n\n  DBUG_RETURN(ret);\n}","target":0,"code_token_length":509,"total_token_length":745,"max_tokens_setting":1024}
+{"idx":341817,"func":"search_impl(i_ctx_t *i_ctx_p, bool forward)\n{\n    os_ptr op = osp;\n    os_ptr op1 = op - 1;\n    uint size = r_size(op);\n    uint count;\n    byte *pat;\n    byte *ptr;\n    byte ch;\n    int incr = forward ? 1 : -1;\n\n    check_read_type(*op1, t_string);\n    check_read_type(*op, t_string);\n    if (size > r_size(op1)) {\t\/* can't match *\/\n        make_false(op);\n        return 0;\n    }\n    count = r_size(op1) - size;\n    ptr = op1->value.bytes;\n    if (size == 0)\n        goto found;\n    if (!forward)\n        ptr += count;\n    pat = op->value.bytes;\n    ch = pat[0];\n    do {\n        if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size)))\n            goto found;\n        ptr += incr;\n    }\n    while (count--);\n    \/* No match *\/\n    make_false(op);\n    return 0;\nfound:\n    op->tas.type_attrs = op1->tas.type_attrs;\n    op->value.bytes = ptr;\t\t\t\t\/* match *\/\n    op->tas.rsize = size;\t\t\t\t\/* match *\/\n    push(2);\n    op[-1] = *op1;\t\t\t\t\t\/* pre *\/\n    op[-3].value.bytes = ptr + size;\t\t\t\/* post *\/\n    if (forward) {\n        op[-1].tas.rsize = ptr - op[-1].value.bytes;\t\/* pre *\/\n        op[-3].tas.rsize = count;\t\t\t\/* post *\/\n    } else {\n        op[-1].tas.rsize = count;\t\t\t\/* pre *\/\n        op[-3].tas.rsize -= count + size;\t\t\/* post *\/\n    }\n    make_true(op);\n    return 0;\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":405387,"func":"static void xfrm_policy_inexact_list_reinsert(struct net *net,\n\t\t\t\t\t      struct xfrm_pol_inexact_node *n,\n\t\t\t\t\t      u16 family)\n{\n\tunsigned int matched_s, matched_d;\n\tstruct xfrm_policy *policy, *p;\n\n\tmatched_s = 0;\n\tmatched_d = 0;\n\n\tlist_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {\n\t\tstruct hlist_node *newpos = NULL;\n\t\tbool matches_s, matches_d;\n\n\t\tif (!policy->bydst_reinsert)\n\t\t\tcontinue;\n\n\t\tWARN_ON_ONCE(policy->family != family);\n\n\t\tpolicy->bydst_reinsert = false;\n\t\thlist_for_each_entry(p, &n->hhead, bydst) {\n\t\t\tif (policy->priority > p->priority)\n\t\t\t\tnewpos = &p->bydst;\n\t\t\telse if (policy->priority == p->priority &&\n\t\t\t\t policy->pos > p->pos)\n\t\t\t\tnewpos = &p->bydst;\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (newpos)\n\t\t\thlist_add_behind_rcu(&policy->bydst, newpos);\n\t\telse\n\t\t\thlist_add_head_rcu(&policy->bydst, &n->hhead);\n\n\t\t\/* paranoia checks follow.\n\t\t * Check that the reinserted policy matches at least\n\t\t * saddr or daddr for current node prefix.\n\t\t *\n\t\t * Matching both is fine, matching saddr in one policy\n\t\t * (but not daddr) and then matching only daddr in another\n\t\t * is a bug.\n\t\t *\/\n\t\tmatches_s = xfrm_policy_addr_delta(&policy->selector.saddr,\n\t\t\t\t\t\t   &n->addr,\n\t\t\t\t\t\t   n->prefixlen,\n\t\t\t\t\t\t   family) == 0;\n\t\tmatches_d = xfrm_policy_addr_delta(&policy->selector.daddr,\n\t\t\t\t\t\t   &n->addr,\n\t\t\t\t\t\t   n->prefixlen,\n\t\t\t\t\t\t   family) == 0;\n\t\tif (matches_s && matches_d)\n\t\t\tcontinue;\n\n\t\tWARN_ON_ONCE(!matches_s && !matches_d);\n\t\tif (matches_s)\n\t\t\tmatched_s++;\n\t\tif (matches_d)\n\t\t\tmatched_d++;\n\t\tWARN_ON_ONCE(matched_s && matched_d);\n\t}\n}","target":0,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":427807,"func":"static void dump_ghcb(struct vcpu_svm *svm)\n{\n\tstruct ghcb *ghcb = svm->ghcb;\n\tunsigned int nbits;\n\n\t\/* Re-use the dump_invalid_vmcb module parameter *\/\n\tif (!dump_invalid_vmcb) {\n\t\tpr_warn_ratelimited(\"set kvm_amd.dump_invalid_vmcb=1 to dump internal KVM state.\\n\");\n\t\treturn;\n\t}\n\n\tnbits = sizeof(ghcb->save.valid_bitmap) * 8;\n\n\tpr_err(\"GHCB (GPA=%016llx):\\n\", svm->vmcb->control.ghcb_gpa);\n\tpr_err(\"%-20s%016llx is_valid: %u\\n\", \"sw_exit_code\",\n\t       ghcb->save.sw_exit_code, ghcb_sw_exit_code_is_valid(ghcb));\n\tpr_err(\"%-20s%016llx is_valid: %u\\n\", \"sw_exit_info_1\",\n\t       ghcb->save.sw_exit_info_1, ghcb_sw_exit_info_1_is_valid(ghcb));\n\tpr_err(\"%-20s%016llx is_valid: %u\\n\", \"sw_exit_info_2\",\n\t       ghcb->save.sw_exit_info_2, ghcb_sw_exit_info_2_is_valid(ghcb));\n\tpr_err(\"%-20s%016llx is_valid: %u\\n\", \"sw_scratch\",\n\t       ghcb->save.sw_scratch, ghcb_sw_scratch_is_valid(ghcb));\n\tpr_err(\"%-20s%*pb\\n\", \"valid_bitmap\", nbits, ghcb->save.valid_bitmap);\n}","target":0,"code_token_length":342,"total_token_length":578,"max_tokens_setting":1024}
+{"idx":247572,"func":"TEST_P(SslSocketTest, FailedClientCertificateSpkiVerificationNoCAWrongClientCertificate) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_DNS_CERT_SPKI);\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_URI_CERT_SPKI);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"));\n\n  TestUtilOptionsV2 test_options(listener, client, false, GetParam());\n  testUtilV2(test_options.setExpectedServerStats(\"ssl.fail_verify_cert_hash\")\n                 .setExpectedTransportFailureReasonContains(\"SSLV3_ALERT_CERTIFICATE_UNKNOWN\"));\n\n  \/\/ Fails even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":223442,"func":"static SLJIT_INLINE void compile_control_verb_backtrackingpath(compiler_common *common, struct backtrack_common *current)\n{\nDEFINE_COMPILER;\nPCRE2_UCHAR opcode = *current->cc;\nstruct sljit_label *loop;\nstruct sljit_jump *jump;\n\nif (opcode == OP_THEN || opcode == OP_THEN_ARG)\n  {\n  if (common->then_trap != NULL)\n    {\n    SLJIT_ASSERT(common->control_head_ptr != 0);\n\n    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, type_then_trap);\n    OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, common->then_trap->start);\n    jump = JUMP(SLJIT_JUMP);\n\n    loop = LABEL();\n    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), STACK(0));\n    JUMPHERE(jump);\n    CMPTO(SLJIT_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0, loop);\n    CMPTO(SLJIT_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(2), TMP2, 0, loop);\n    add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));\n    return;\n    }\n  else if (!common->local_quit_available && common->in_positive_assertion)\n    {\n    add_jump(compiler, &common->positive_assertion_quit, JUMP(SLJIT_JUMP));\n    return;\n    }\n  }\n\nif (common->local_quit_available)\n  {\n  \/* Abort match with a fail. *\/\n  if (common->quit_label == NULL)\n    add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));\n  else\n    JUMPTO(SLJIT_JUMP, common->quit_label);\n  return;\n  }\n\nif (opcode == OP_SKIP_ARG)\n  {\n  SLJIT_ASSERT(common->control_head_ptr != 0 && TMP1 == SLJIT_R0 && STR_PTR == SLJIT_R1);\n  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);\n  OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, (sljit_sw)(current->cc + 2));\n  sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_ARGS2(W, W, W), SLJIT_IMM, SLJIT_FUNC_ADDR(do_search_mark));\n\n  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_R0, 0);\n  add_jump(compiler, &common->reset_match, CMP(SLJIT_NOT_EQUAL, SLJIT_R0, 0, SLJIT_IMM, 0));\n  return;\n  }\n\nif (opcode == OP_SKIP)\n  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));\nelse\n  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_IMM, 0);\nadd_jump(compiler, &common->reset_match, JUMP(SLJIT_JUMP));\n}","target":0,"code_token_length":736,"total_token_length":972,"max_tokens_setting":1024}
+{"idx":482495,"func":"getAChar(FileInfo *file) {\n\t\/* Read a big endian, little endian or ASCII 8 file and convert it to\n\t * 16- or 32-bit unsigned integers *\/\n\tint ch1 = 0, ch2 = 0;\n\twidechar character;\n\tif (file->encoding == ascii8)\n\t\tif (file->status == 2) {\n\t\t\tfile->status++;\n\t\t\treturn file->checkencoding[1];\n\t\t}\n\twhile ((ch1 = fgetc(file->in)) != EOF) {\n\t\tif (file->status < 2) file->checkencoding[file->status] = ch1;\n\t\tfile->status++;\n\t\tif (file->status == 2) {\n\t\t\tif (file->checkencoding[0] == 0xfe && file->checkencoding[1] == 0xff)\n\t\t\t\tfile->encoding = bigEndian;\n\t\t\telse if (file->checkencoding[0] == 0xff && file->checkencoding[1] == 0xfe)\n\t\t\t\tfile->encoding = littleEndian;\n\t\t\telse if (file->checkencoding[0] < 128 && file->checkencoding[1] < 128) {\n\t\t\t\tfile->encoding = ascii8;\n\t\t\t\treturn file->checkencoding[0];\n\t\t\t} else {\n\t\t\t\tcompileError(file,\n\t\t\t\t\t\t\"encoding is neither big-endian, little-endian nor ASCII 8.\");\n\t\t\t\tch1 = EOF;\n\t\t\t\tbreak;\n\t\t\t\t;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tswitch (file->encoding) {\n\t\tcase noEncoding:\n\t\t\tbreak;\n\t\tcase ascii8:\n\t\t\treturn ch1;\n\t\t\tbreak;\n\t\tcase bigEndian:\n\t\t\tch2 = fgetc(file->in);\n\t\t\tif (ch2 == EOF) break;\n\t\t\tcharacter = (widechar)(ch1 << 8) | ch2;\n\t\t\treturn (int)character;\n\t\t\tbreak;\n\t\tcase littleEndian:\n\t\t\tch2 = fgetc(file->in);\n\t\t\tif (ch2 == EOF) break;\n\t\t\tcharacter = (widechar)(ch2 << 8) | ch1;\n\t\t\treturn (int)character;\n\t\t\tbreak;\n\t\t}\n\t\tif (ch1 == EOF || ch2 == EOF) break;\n\t}\n\treturn EOF;\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":336150,"func":"static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)\n{\n\tstruct net_device *dev = t->dev;\n\tstruct __ip6_tnl_parm *p = &t->parms;\n\tstruct flowi6 *fl6 = &t->fl.u.ip6;\n\tint t_hlen;\n\n\tif (dev->type != ARPHRD_ETHER) {\n\t\tmemcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr));\n\t\tmemcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));\n\t}\n\n\t\/* Set up flowi template *\/\n\tfl6->saddr = p->laddr;\n\tfl6->daddr = p->raddr;\n\tfl6->flowi6_oif = p->link;\n\tfl6->flowlabel = 0;\n\tfl6->flowi6_proto = IPPROTO_GRE;\n\n\tif (!(p->flags&IP6_TNL_F_USE_ORIG_TCLASS))\n\t\tfl6->flowlabel |= IPV6_TCLASS_MASK & p->flowinfo;\n\tif (!(p->flags&IP6_TNL_F_USE_ORIG_FLOWLABEL))\n\t\tfl6->flowlabel |= IPV6_FLOWLABEL_MASK & p->flowinfo;\n\n\tp->flags &= ~(IP6_TNL_F_CAP_XMIT|IP6_TNL_F_CAP_RCV|IP6_TNL_F_CAP_PER_PACKET);\n\tp->flags |= ip6_tnl_get_cap(t, &p->laddr, &p->raddr);\n\n\tif (p->flags&IP6_TNL_F_CAP_XMIT &&\n\t\t\tp->flags&IP6_TNL_F_CAP_RCV && dev->type != ARPHRD_ETHER)\n\t\tdev->flags |= IFF_POINTOPOINT;\n\telse\n\t\tdev->flags &= ~IFF_POINTOPOINT;\n\n\tt->tun_hlen = gre_calc_hlen(t->parms.o_flags);\n\n\tt->hlen = t->encap_hlen + t->tun_hlen;\n\n\tt_hlen = t->hlen + sizeof(struct ipv6hdr);\n\n\tif (p->flags & IP6_TNL_F_CAP_XMIT) {\n\t\tint strict = (ipv6_addr_type(&p->raddr) &\n\t\t\t      (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));\n\n\t\tstruct rt6_info *rt = rt6_lookup(t->net,\n\t\t\t\t\t\t &p->raddr, &p->laddr,\n\t\t\t\t\t\t p->link, strict);\n\n\t\tif (!rt)\n\t\t\treturn;\n\n\t\tif (rt->dst.dev) {\n\t\t\tdev->hard_header_len = rt->dst.dev->hard_header_len +\n\t\t\t\t\t       t_hlen;\n\n\t\t\tif (set_mtu) {\n\t\t\t\tdev->mtu = rt->dst.dev->mtu - t_hlen;\n\t\t\t\tif (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))\n\t\t\t\t\tdev->mtu -= 8;\n\t\t\t\tif (dev->type == ARPHRD_ETHER)\n\t\t\t\t\tdev->mtu -= ETH_HLEN;\n\n\t\t\t\tif (dev->mtu < IPV6_MIN_MTU)\n\t\t\t\t\tdev->mtu = IPV6_MIN_MTU;\n\t\t\t}\n\t\t}\n\t\tip6_rt_put(rt);\n\t}\n}","target":0,"code_token_length":669,"total_token_length":905,"max_tokens_setting":1024}
+{"idx":231054,"func":"    void vQueueWaitForMessageRestricted( QueueHandle_t xQueue,\r\n                                         TickType_t xTicksToWait,\r\n                                         const BaseType_t xWaitIndefinitely )\r\n    {\r\n        Queue_t * const pxQueue = xQueue;\r\n\r\n        \/* This function should not be called by application code hence the\r\n         * 'Restricted' in its name.  It is not part of the public API.  It is\r\n         * designed for use by kernel code, and has special calling requirements.\r\n         * It can result in vListInsert() being called on a list that can only\r\n         * possibly ever have one item in it, so the list will be fast, but even\r\n         * so it should be called with the scheduler locked and not from a critical\r\n         * section. *\/\r\n\r\n        \/* Only do anything if there are no messages in the queue.  This function\r\n         *  will not actually cause the task to block, just place it on a blocked\r\n         *  list.  It will not block until the scheduler is unlocked - at which\r\n         *  time a yield will be performed.  If an item is added to the queue while\r\n         *  the queue is locked, and the calling task blocks on the queue, then the\r\n         *  calling task will be immediately unblocked when the queue is unlocked. *\/\r\n        prvLockQueue( pxQueue );\r\n\r\n        if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U )\r\n        {\r\n            \/* There is nothing in the queue, block for the specified period. *\/\r\n            vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait, xWaitIndefinitely );\r\n        }\r\n        else\r\n        {\r\n            mtCOVERAGE_TEST_MARKER();\r\n        }\r\n\r\n        prvUnlockQueue( pxQueue );\r\n    }\r","target":0,"code_token_length":377,"total_token_length":613,"max_tokens_setting":1024}
+{"idx":200781,"func":"cvtchar(register const char *sp)\n\/* convert a character to a terminfo push *\/\n{\n    unsigned char c = 0;\n    int len;\n\n    switch (*sp) {\n    case '\\\\':\n\tswitch (*++sp) {\n\tcase '\\'':\n\tcase '$':\n\tcase '\\\\':\n\tcase '%':\n\t    c = UChar(*sp);\n\t    len = 2;\n\t    break;\n\tcase '\\0':\n\t    c = '\\\\';\n\t    len = 1;\n\t    break;\n\tcase '0':\n\tcase '1':\n\tcase '2':\n\tcase '3':\n\t    len = 1;\n\t    while (isdigit(UChar(*sp))) {\n\t\tc = UChar(8 * c + (*sp++ - '0'));\n\t\tlen++;\n\t    }\n\t    break;\n\tdefault:\n\t    c = UChar(*sp);\n\t    len = (c != '\\0') ? 2 : 1;\n\t    break;\n\t}\n\tbreak;\n    case '^':\n\tc = UChar(*++sp);\n\tif (c == '?')\n\t    c = 127;\n\telse\n\t    c &= 0x1f;\n\tlen = 2;\n\tbreak;\n    default:\n\tc = UChar(*sp);\n\tlen = (c != '\\0') ? 1 : 0;\n    }\n    if (isgraph(c) && c != ',' && c != '\\'' && c != '\\\\' && c != ':') {\n\tdp = save_string(dp, \"%\\'\");\n\tdp = save_char(dp, c);\n\tdp = save_char(dp, '\\'');\n    } else if (c != '\\0') {\n\tdp = save_string(dp, \"%{\");\n\tif (c > 99)\n\t    dp = save_char(dp, c \/ 100 + '0');\n\tif (c > 9)\n\t    dp = save_char(dp, ((int) (c \/ 10)) % 10 + '0');\n\tdp = save_char(dp, c % 10 + '0');\n\tdp = save_char(dp, '}');\n    }\n    return len;\n}","target":1,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":238411,"func":"static int check_ptr_alignment(struct bpf_verifier_env *env,\n\t\t\t       const struct bpf_reg_state *reg, int off,\n\t\t\t       int size, bool strict_alignment_once)\n{\n\tbool strict = env->strict_alignment || strict_alignment_once;\n\tconst char *pointer_desc = \"\";\n\n\tswitch (reg->type) {\n\tcase PTR_TO_PACKET:\n\tcase PTR_TO_PACKET_META:\n\t\t\/* Special case, because of NET_IP_ALIGN. Given metadata sits\n\t\t * right in front, treat it the very same way.\n\t\t *\/\n\t\treturn check_pkt_ptr_alignment(env, reg, off, size, strict);\n\tcase PTR_TO_FLOW_KEYS:\n\t\tpointer_desc = \"flow keys \";\n\t\tbreak;\n\tcase PTR_TO_MAP_KEY:\n\t\tpointer_desc = \"key \";\n\t\tbreak;\n\tcase PTR_TO_MAP_VALUE:\n\t\tpointer_desc = \"value \";\n\t\tbreak;\n\tcase PTR_TO_CTX:\n\t\tpointer_desc = \"context \";\n\t\tbreak;\n\tcase PTR_TO_STACK:\n\t\tpointer_desc = \"stack \";\n\t\t\/* The stack spill tracking logic in check_stack_write_fixed_off()\n\t\t * and check_stack_read_fixed_off() relies on stack accesses being\n\t\t * aligned.\n\t\t *\/\n\t\tstrict = true;\n\t\tbreak;\n\tcase PTR_TO_SOCKET:\n\t\tpointer_desc = \"sock \";\n\t\tbreak;\n\tcase PTR_TO_SOCK_COMMON:\n\t\tpointer_desc = \"sock_common \";\n\t\tbreak;\n\tcase PTR_TO_TCP_SOCK:\n\t\tpointer_desc = \"tcp_sock \";\n\t\tbreak;\n\tcase PTR_TO_XDP_SOCK:\n\t\tpointer_desc = \"xdp_sock \";\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn check_generic_ptr_alignment(env, reg, pointer_desc, off, size,\n\t\t\t\t\t   strict);\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":310092,"func":"usage(void)\n{\n#define DATA(s) s \"\\n\"\n    static const char options_string[] =\n    {\n\tDATA(\"Options:\")\n\tDATA(\"  -0         format translation output all capabilities on one line\")\n\tDATA(\"  -1         format translation output one capability per line\")\n#if NCURSES_XNAMES\n\tDATA(\"  -a         retain commented-out capabilities (sets -x also)\")\n#endif\n\tDATA(\"  -C         translate entries to termcap source form\")\n\tDATA(\"  -D         print list of tic's database locations (first must be writable)\")\n\tDATA(\"  -c         check only, validate input without compiling or translating\")\n\tDATA(\"  -e<names>  translate\/compile only entries named by comma-separated list\")\n\tDATA(\"  -f         format complex strings for readability\")\n\tDATA(\"  -G         format %{number} to %'char'\")\n\tDATA(\"  -g         format %'char' to %{number}\")\n\tDATA(\"  -I         translate entries to terminfo source form\")\n\tDATA(\"  -K         translate entries to termcap source form with BSD syntax\")\n\tDATA(\"  -L         translate entries to full terminfo source form\")\n\tDATA(\"  -N         disable smart defaults for source translation\")\n\tDATA(\"  -o<dir>    set output directory for compiled entry writes\")\n\tDATA(\"  -Q[n]      dump compiled description\")\n\tDATA(\"  -q    brief listing, removes headers\")\n\tDATA(\"  -R<name>   restrict translation to given terminfo\/termcap version\")\n\tDATA(\"  -r         force resolution of all use entries in source translation\")\n\tDATA(\"  -s         print summary statistics\")\n\tDATA(\"  -T         remove size-restrictions on compiled description\")\n#if NCURSES_XNAMES\n\tDATA(\"  -t         suppress commented-out capabilities\")\n#endif\n\tDATA(\"  -U         suppress post-processing of entries\")\n\tDATA(\"  -V         print version\")\n\tDATA(\"  -W         wrap long strings according to -w[n] option\")\n\tDATA(\"  -v[n]      set verbosity level\")\n\tDATA(\"  -w[n]      set format width for translation output\")\n#if NCURSES_XNAMES\n\tDATA(\"  -x         treat unknown capabilities as user-defined\")\n#endif\n\tDATA(\"\")\n\tDATA(\"Parameters:\")\n\tDATA(\"  <file>     file to translate or compile\")\n    };\n#undef DATA\n\n    fprintf(stderr, \"Usage: %s %s\\n\", _nc_progname, usage_string);\n    fputs(options_string, stderr);\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":553,"total_token_length":789,"max_tokens_setting":1024}
+{"idx":234729,"func":"static int relocating_repair_kthread(void *data)\n{\n\tstruct btrfs_block_group *cache = (struct btrfs_block_group *)data;\n\tstruct btrfs_fs_info *fs_info = cache->fs_info;\n\tu64 target;\n\tint ret = 0;\n\n\ttarget = cache->start;\n\tbtrfs_put_block_group(cache);\n\n\tif (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) {\n\t\tbtrfs_info(fs_info,\n\t\t\t   \"zoned: skip relocating block group %llu to repair: EBUSY\",\n\t\t\t   target);\n\t\treturn -EBUSY;\n\t}\n\n\tmutex_lock(&fs_info->reclaim_bgs_lock);\n\n\t\/* Ensure block group still exists *\/\n\tcache = btrfs_lookup_block_group(fs_info, target);\n\tif (!cache)\n\t\tgoto out;\n\n\tif (!cache->relocating_repair)\n\t\tgoto out;\n\n\tret = btrfs_may_alloc_data_chunk(fs_info, target);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tbtrfs_info(fs_info,\n\t\t   \"zoned: relocating block group %llu to repair IO failure\",\n\t\t   target);\n\tret = btrfs_relocate_chunk(fs_info, target);\n\nout:\n\tif (cache)\n\t\tbtrfs_put_block_group(cache);\n\tmutex_unlock(&fs_info->reclaim_bgs_lock);\n\tbtrfs_exclop_finish(fs_info);\n\n\treturn ret;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":238435,"func":"static void find_good_pkt_pointers(struct bpf_verifier_state *vstate,\n\t\t\t\t   struct bpf_reg_state *dst_reg,\n\t\t\t\t   enum bpf_reg_type type,\n\t\t\t\t   bool range_right_open)\n{\n\tint new_range, i;\n\n\tif (dst_reg->off < 0 ||\n\t    (dst_reg->off == 0 && range_right_open))\n\t\t\/* This doesn't give us any range *\/\n\t\treturn;\n\n\tif (dst_reg->umax_value > MAX_PACKET_OFF ||\n\t    dst_reg->umax_value + dst_reg->off > MAX_PACKET_OFF)\n\t\t\/* Risk of overflow.  For instance, ptr + (1<<63) may be less\n\t\t * than pkt_end, but that's because it's also less than pkt.\n\t\t *\/\n\t\treturn;\n\n\tnew_range = dst_reg->off;\n\tif (range_right_open)\n\t\tnew_range++;\n\n\t\/* Examples for register markings:\n\t *\n\t * pkt_data in dst register:\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (r2 > pkt_end) goto <handle exception>\n\t *   <access okay>\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (r2 < pkt_end) goto <access okay>\n\t *   <handle exception>\n\t *\n\t *   Where:\n\t *     r2 == dst_reg, pkt_end == src_reg\n\t *     r2=pkt(id=n,off=8,r=0)\n\t *     r3=pkt(id=n,off=0,r=0)\n\t *\n\t * pkt_data in src register:\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (pkt_end >= r2) goto <access okay>\n\t *   <handle exception>\n\t *\n\t *   r2 = r3;\n\t *   r2 += 8;\n\t *   if (pkt_end <= r2) goto <handle exception>\n\t *   <access okay>\n\t *\n\t *   Where:\n\t *     pkt_end == dst_reg, r2 == src_reg\n\t *     r2=pkt(id=n,off=8,r=0)\n\t *     r3=pkt(id=n,off=0,r=0)\n\t *\n\t * Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8)\n\t * or r3=pkt(id=n,off=0,r=8-1), so that range of bytes [r3, r3 + 8)\n\t * and [r3, r3 + 8-1) respectively is safe to access depending on\n\t * the check.\n\t *\/\n\n\t\/* If our ids match, then we must have the same max_value.  And we\n\t * don't care about the other reg's fixed offset, since if it's too big\n\t * the range won't allow anything.\n\t * dst_reg->off is known < MAX_PACKET_OFF, therefore it fits in a u16.\n\t *\/\n\tfor (i = 0; i <= vstate->curframe; i++)\n\t\t__find_good_pkt_pointers(vstate->frame[i], dst_reg, type,\n\t\t\t\t\t new_range);\n}","target":0,"code_token_length":695,"total_token_length":931,"max_tokens_setting":1024}
+{"idx":289304,"func":"static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait)\n{\n\tstruct snd_pcm_oss_file *pcm_oss_file;\n\t__poll_t mask;\n\tstruct snd_pcm_substream *psubstream = NULL, *csubstream = NULL;\n\t\n\tpcm_oss_file = file->private_data;\n\n\tpsubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];\n\tcsubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];\n\n\tmask = 0;\n\tif (psubstream != NULL) {\n\t\tstruct snd_pcm_runtime *runtime = psubstream->runtime;\n\t\tpoll_wait(file, &runtime->sleep, wait);\n\t\tsnd_pcm_stream_lock_irq(psubstream);\n\t\tif (runtime->status->state != SNDRV_PCM_STATE_DRAINING &&\n\t\t    (runtime->status->state != SNDRV_PCM_STATE_RUNNING ||\n\t\t     snd_pcm_oss_playback_ready(psubstream)))\n\t\t\tmask |= EPOLLOUT | EPOLLWRNORM;\n\t\tsnd_pcm_stream_unlock_irq(psubstream);\n\t}\n\tif (csubstream != NULL) {\n\t\tstruct snd_pcm_runtime *runtime = csubstream->runtime;\n\t\tsnd_pcm_state_t ostate;\n\t\tpoll_wait(file, &runtime->sleep, wait);\n\t\tsnd_pcm_stream_lock_irq(csubstream);\n\t\tostate = runtime->status->state;\n\t\tif (ostate != SNDRV_PCM_STATE_RUNNING ||\n\t\t    snd_pcm_oss_capture_ready(csubstream))\n\t\t\tmask |= EPOLLIN | EPOLLRDNORM;\n\t\tsnd_pcm_stream_unlock_irq(csubstream);\n\t\tif (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) {\n\t\t\tstruct snd_pcm_oss_file ofile;\n\t\t\tmemset(&ofile, 0, sizeof(ofile));\n\t\t\tofile.streams[SNDRV_PCM_STREAM_CAPTURE] = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];\n\t\t\truntime->oss.trigger = 0;\n\t\t\tsnd_pcm_oss_set_trigger(&ofile, PCM_ENABLE_INPUT);\n\t\t}\n\t}\n\n\treturn mask;\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":291796,"func":"static struct rtrs_clt_path *alloc_path(struct rtrs_clt_sess *clt,\n\t\t\t\t\tconst struct rtrs_addr *path,\n\t\t\t\t\tsize_t con_num, u32 nr_poll_queues)\n{\n\tstruct rtrs_clt_path *clt_path;\n\tint err = -ENOMEM;\n\tint cpu;\n\tsize_t total_con;\n\n\tclt_path = kzalloc(sizeof(*clt_path), GFP_KERNEL);\n\tif (!clt_path)\n\t\tgoto err;\n\n\t\/*\n\t * irqmode and poll\n\t * +1: Extra connection for user messages\n\t *\/\n\ttotal_con = con_num + nr_poll_queues + 1;\n\tclt_path->s.con = kcalloc(total_con, sizeof(*clt_path->s.con),\n\t\t\t\t  GFP_KERNEL);\n\tif (!clt_path->s.con)\n\t\tgoto err_free_path;\n\n\tclt_path->s.con_num = total_con;\n\tclt_path->s.irq_con_num = con_num + 1;\n\n\tclt_path->stats = kzalloc(sizeof(*clt_path->stats), GFP_KERNEL);\n\tif (!clt_path->stats)\n\t\tgoto err_free_con;\n\n\tmutex_init(&clt_path->init_mutex);\n\tuuid_gen(&clt_path->s.uuid);\n\tmemcpy(&clt_path->s.dst_addr, path->dst,\n\t       rdma_addr_size((struct sockaddr *)path->dst));\n\n\t\/*\n\t * rdma_resolve_addr() passes src_addr to cma_bind_addr, which\n\t * checks the sa_family to be non-zero. If user passed src_addr=NULL\n\t * the sess->src_addr will contain only zeros, which is then fine.\n\t *\/\n\tif (path->src)\n\t\tmemcpy(&clt_path->s.src_addr, path->src,\n\t\t       rdma_addr_size((struct sockaddr *)path->src));\n\tstrscpy(clt_path->s.sessname, clt->sessname,\n\t\tsizeof(clt_path->s.sessname));\n\tclt_path->clt = clt;\n\tclt_path->max_pages_per_mr = RTRS_MAX_SEGMENTS;\n\tinit_waitqueue_head(&clt_path->state_wq);\n\tclt_path->state = RTRS_CLT_CONNECTING;\n\tatomic_set(&clt_path->connected_cnt, 0);\n\tINIT_WORK(&clt_path->close_work, rtrs_clt_close_work);\n\tINIT_DELAYED_WORK(&clt_path->reconnect_dwork, rtrs_clt_reconnect_work);\n\trtrs_clt_init_hb(clt_path);\n\n\tclt_path->mp_skip_entry = alloc_percpu(typeof(*clt_path->mp_skip_entry));\n\tif (!clt_path->mp_skip_entry)\n\t\tgoto err_free_stats;\n\n\tfor_each_possible_cpu(cpu)\n\t\tINIT_LIST_HEAD(per_cpu_ptr(clt_path->mp_skip_entry, cpu));\n\n\terr = rtrs_clt_init_stats(clt_path->stats);\n\tif (err)\n\t\tgoto err_free_percpu;\n\n\treturn clt_path;\n\nerr_free_percpu:\n\tfree_percpu(clt_path->mp_skip_entry);\nerr_free_stats:\n\tkfree(clt_path->stats);\nerr_free_con:\n\tkfree(clt_path->s.con);\nerr_free_path:\n\tkfree(clt_path);\nerr:\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":657,"total_token_length":893,"max_tokens_setting":1024}
+{"idx":387623,"func":"static int snd_ctl_elem_init_enum_names(struct user_element *ue)\n{\n\tchar *names, *p;\n\tsize_t buf_len, name_len;\n\tunsigned int i;\n\tconst uintptr_t user_ptrval = ue->info.value.enumerated.names_ptr;\n\n\tbuf_len = ue->info.value.enumerated.names_length;\n\tif (buf_len > 64 * 1024)\n\t\treturn -EINVAL;\n\n\tif (check_user_elem_overflow(ue->card, buf_len))\n\t\treturn -ENOMEM;\n\tnames = vmemdup_user((const void __user *)user_ptrval, buf_len);\n\tif (IS_ERR(names))\n\t\treturn PTR_ERR(names);\n\n\t\/* check that there are enough valid names *\/\n\tp = names;\n\tfor (i = 0; i < ue->info.value.enumerated.items; ++i) {\n\t\tname_len = strnlen(p, buf_len);\n\t\tif (name_len == 0 || name_len >= 64 || name_len == buf_len) {\n\t\t\tkvfree(names);\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tp += name_len + 1;\n\t\tbuf_len -= name_len + 1;\n\t}\n\n\tue->priv_data = names;\n\tue->info.value.enumerated.names_ptr = 0;\n\t\/\/ increment the allocation size; decremented again at private_free.\n\tue->card->user_ctl_alloc_size += ue->info.value.enumerated.names_length;\n\n\treturn 0;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":387572,"func":"static ssize_t snd_ctl_read(struct file *file, char __user *buffer,\n\t\t\t    size_t count, loff_t * offset)\n{\n\tstruct snd_ctl_file *ctl;\n\tint err = 0;\n\tssize_t result = 0;\n\n\tctl = file->private_data;\n\tif (snd_BUG_ON(!ctl || !ctl->card))\n\t\treturn -ENXIO;\n\tif (!ctl->subscribed)\n\t\treturn -EBADFD;\n\tif (count < sizeof(struct snd_ctl_event))\n\t\treturn -EINVAL;\n\tspin_lock_irq(&ctl->read_lock);\n\twhile (count >= sizeof(struct snd_ctl_event)) {\n\t\tstruct snd_ctl_event ev;\n\t\tstruct snd_kctl_event *kev;\n\t\twhile (list_empty(&ctl->events)) {\n\t\t\twait_queue_entry_t wait;\n\t\t\tif ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {\n\t\t\t\terr = -EAGAIN;\n\t\t\t\tgoto __end_lock;\n\t\t\t}\n\t\t\tinit_waitqueue_entry(&wait, current);\n\t\t\tadd_wait_queue(&ctl->change_sleep, &wait);\n\t\t\tset_current_state(TASK_INTERRUPTIBLE);\n\t\t\tspin_unlock_irq(&ctl->read_lock);\n\t\t\tschedule();\n\t\t\tremove_wait_queue(&ctl->change_sleep, &wait);\n\t\t\tif (ctl->card->shutdown)\n\t\t\t\treturn -ENODEV;\n\t\t\tif (signal_pending(current))\n\t\t\t\treturn -ERESTARTSYS;\n\t\t\tspin_lock_irq(&ctl->read_lock);\n\t\t}\n\t\tkev = snd_kctl_event(ctl->events.next);\n\t\tev.type = SNDRV_CTL_EVENT_ELEM;\n\t\tev.data.elem.mask = kev->mask;\n\t\tev.data.elem.id = kev->id;\n\t\tlist_del(&kev->list);\n\t\tspin_unlock_irq(&ctl->read_lock);\n\t\tkfree(kev);\n\t\tif (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {\n\t\t\terr = -EFAULT;\n\t\t\tgoto __end;\n\t\t}\n\t\tspin_lock_irq(&ctl->read_lock);\n\t\tbuffer += sizeof(struct snd_ctl_event);\n\t\tcount -= sizeof(struct snd_ctl_event);\n\t\tresult += sizeof(struct snd_ctl_event);\n\t}\n      __end_lock:\n\tspin_unlock_irq(&ctl->read_lock);\n      __end:\n      \treturn result > 0 ? result : err;\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":489220,"func":"int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)\n{\n\tstruct page *page;\n\tstruct address_space *mapping;\n\t__be32 *pptr, *curr, *end;\n\tu32 mask, len, pnr;\n\tint i;\n\n\t\/* is there any actual work to be done? *\/\n\tif (!count)\n\t\treturn 0;\n\n\tdprint(DBG_BITMAP, \"block_free: %u,%u\\n\", offset, count);\n\t\/* are all of the bits in range? *\/\n\tif ((offset + count) > HFSPLUS_SB(sb).total_blocks)\n\t\treturn -2;\n\n\tmutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);\n\tmapping = HFSPLUS_SB(sb).alloc_file->i_mapping;\n\tpnr = offset \/ PAGE_CACHE_BITS;\n\tpage = read_mapping_page(mapping, pnr, NULL);\n\tpptr = kmap(page);\n\tcurr = pptr + (offset & (PAGE_CACHE_BITS - 1)) \/ 32;\n\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\tlen = count;\n\n\t\/* do any partial u32 at the start *\/\n\ti = offset % 32;\n\tif (i) {\n\t\tint j = 32 - i;\n\t\tmask = 0xffffffffU << j;\n\t\tif (j > count) {\n\t\t\tmask |= 0xffffffffU >> (i + count);\n\t\t\t*curr++ &= cpu_to_be32(mask);\n\t\t\tgoto out;\n\t\t}\n\t\t*curr++ &= cpu_to_be32(mask);\n\t\tcount -= j;\n\t}\n\n\t\/* do full u32s *\/\n\twhile (1) {\n\t\twhile (curr < end) {\n\t\t\tif (count < 32)\n\t\t\t\tgoto done;\n\t\t\t*curr++ = 0;\n\t\t\tcount -= 32;\n\t\t}\n\t\tif (!count)\n\t\t\tbreak;\n\t\tset_page_dirty(page);\n\t\tkunmap(page);\n\t\tpage = read_mapping_page(mapping, ++pnr, NULL);\n\t\tpptr = kmap(page);\n\t\tcurr = pptr;\n\t\tend = pptr + PAGE_CACHE_BITS \/ 32;\n\t}\ndone:\n\t\/* do any partial u32 at end *\/\n\tif (count) {\n\t\tmask = 0xffffffffU >> count;\n\t\t*curr &= cpu_to_be32(mask);\n\t}\nout:\n\tset_page_dirty(page);\n\tkunmap(page);\n\tHFSPLUS_SB(sb).free_blocks += len;\n\tsb->s_dirt = 1;\n\tmutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);\n\n\treturn 0;\n}","target":0,"code_token_length":548,"total_token_length":784,"max_tokens_setting":1024}
+{"idx":447051,"func":"    std::string XPathIo::writeDataToFile(const std::string& orgPath) {\n        Protocol prot = fileProtocol(orgPath);\n\n        \/\/ generating the name for temp file.\n        std::time_t timestamp = std::time(NULL);\n        std::stringstream ss;\n        ss << timestamp << XPathIo::TEMP_FILE_EXT;\n        std::string path = ss.str();\n        std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);\n\n        if (prot == pStdin) {\n            if (isatty(fileno(stdin)))\n                throw Error(53);\n#if defined(_MSC_VER) || defined(__MINGW__)\n            \/\/ convert stdin to binary\n            if (_setmode(_fileno(stdin), _O_BINARY) == -1)\n                throw Error(54);\n#endif\n            \/\/ read stdin and write to the temp file.\n            char readBuf[100*1024];\n            std::streamsize readBufSize = 0;\n            do {\n                std::cin.read(readBuf, sizeof(readBuf));\n                readBufSize = std::cin.gcount();\n                if (readBufSize > 0) {\n                    fs.write (readBuf, readBufSize);\n                }\n            } while(readBufSize);\n        } else if (prot == pDataUri) {\n            \/\/ read data uri and write to the temp file.\n            size_t base64Pos = orgPath.find(\"base64,\");\n            if (base64Pos == std::string::npos)\n                throw Error(1, \"No base64 data\");\n\n            std::string data = orgPath.substr(base64Pos+7);\n            char* decodeData = new char[data.length()];\n            long size = base64decode(data.c_str(), decodeData, data.length());\n            if (size > 0)\n                fs.write(decodeData, size);\n            else\n                throw Error(1, \"Unable to decode base 64.\");\n            delete[] decodeData;\n        }\n\n        fs.close();\n        return path;\n    }","target":0,"code_token_length":434,"total_token_length":670,"max_tokens_setting":1024}
+{"idx":223426,"func":"static void do_utfpeakcharback_invalid(compiler_common *common)\n{\n\/* Peak a character back. Does not modify STR_PTR. *\/\nDEFINE_COMPILER;\nstruct sljit_jump *jump;\nstruct sljit_jump *exit_invalid[3];\n\nsljit_emit_fast_enter(compiler, RETURN_ADDR, 0);\n\njump = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xe000);\nOP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));\nexit_invalid[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xdc00);\nexit_invalid[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, STR_PTR, 0);\n\nOP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000 - 0xdc00);\nOP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);\nexit_invalid[2] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x400);\nOP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 10);\nOP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\n\nJUMPHERE(jump);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n\nJUMPHERE(exit_invalid[0]);\nJUMPHERE(exit_invalid[1]);\nJUMPHERE(exit_invalid[2]);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);\nOP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0);\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":212339,"func":"static size_t handle_returned_header (void *ptr, size_t size, size_t nmemb, void *stream)\n{\n    auth_client *auth_user = stream;\n    size_t bytes = size * nmemb;\n    client_t *client = auth_user->client;\n\n    if (client)\n    {\n        auth_t *auth = client->auth;\n        auth_url *url = auth->state;\n        if (strncasecmp (ptr, url->auth_header, url->auth_header_len) == 0)\n            client->authenticated = 1;\n        if (strncasecmp (ptr, url->timelimit_header, url->timelimit_header_len) == 0)\n        {\n            unsigned int limit = 0;\n            sscanf ((char *)ptr+url->timelimit_header_len, \"%u\\r\\n\", &limit);\n            client->con->discon_time = time(NULL) + limit;\n        }\n        if (strncasecmp (ptr, \"icecast-auth-message: \", 22) == 0)\n        {\n            char *eol;\n            snprintf (url->errormsg, sizeof (url->errormsg), \"%s\", (char*)ptr+22);\n            eol = strchr (url->errormsg, '\\r');\n            if (eol == NULL)\n                eol = strchr (url->errormsg, '\\n');\n            if (eol)\n                *eol = '\\0';\n        }\n    }\n\n    return bytes;\n}","target":1,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":204412,"func":"static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)\n{\n\tunsigned long cons_pos, prod_pos, new_prod_pos, flags;\n\tu32 len, pg_off;\n\tstruct bpf_ringbuf_hdr *hdr;\n\n\tif (unlikely(size > RINGBUF_MAX_RECORD_SZ))\n\t\treturn NULL;\n\n\tlen = round_up(size + BPF_RINGBUF_HDR_SZ, 8);\n\tcons_pos = smp_load_acquire(&rb->consumer_pos);\n\n\tif (in_nmi()) {\n\t\tif (!spin_trylock_irqsave(&rb->spinlock, flags))\n\t\t\treturn NULL;\n\t} else {\n\t\tspin_lock_irqsave(&rb->spinlock, flags);\n\t}\n\n\tprod_pos = rb->producer_pos;\n\tnew_prod_pos = prod_pos + len;\n\n\t\/* check for out of ringbuf space by ensuring producer position\n\t * doesn't advance more than (ringbuf_size - 1) ahead\n\t *\/\n\tif (new_prod_pos - cons_pos > rb->mask) {\n\t\tspin_unlock_irqrestore(&rb->spinlock, flags);\n\t\treturn NULL;\n\t}\n\n\thdr = (void *)rb->data + (prod_pos & rb->mask);\n\tpg_off = bpf_ringbuf_rec_pg_off(rb, hdr);\n\thdr->len = size | BPF_RINGBUF_BUSY_BIT;\n\thdr->pg_off = pg_off;\n\n\t\/* pairs with consumer's smp_load_acquire() *\/\n\tsmp_store_release(&rb->producer_pos, new_prod_pos);\n\n\tspin_unlock_irqrestore(&rb->spinlock, flags);\n\n\treturn (void *)hdr + BPF_RINGBUF_HDR_SZ;\n}","target":1,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":218802,"func":"static MagickBooleanType ApplyPSDOpacityMask(Image *image,const Image *mask,\n  Quantum background,MagickBooleanType revert,ExceptionInfo *exception)\n{\n  Image\n    *complete_mask;\n\n  MagickBooleanType\n    status;\n\n  MagickPixelPacket\n    color;\n\n  ssize_t\n    y;\n\n  if (image->matte == MagickFalse)\n    return(MagickTrue);\n  if (image->debug != MagickFalse)\n    (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n      \"  applying opacity mask\");\n  complete_mask=CloneImage(image,0,0,MagickTrue,exception);\n  if (complete_mask == (Image *) NULL)\n    return(MagickFalse);\n  complete_mask->matte=MagickTrue;\n  GetMagickPixelPacket(complete_mask,&color);\n  color.red=(MagickRealType) background;\n  (void) SetImageColor(complete_mask,&color);\n  status=CompositeImage(complete_mask,OverCompositeOp,mask,\n    mask->page.x-image->page.x,mask->page.y-image->page.y);\n  if (status == MagickFalse)\n    {\n      complete_mask=DestroyImage(complete_mask);\n      return(status);\n    }\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n#pragma omp parallel for schedule(static) shared(status) \\\n  magick_number_threads(image,image,image->rows,1)\n#endif\n  for (y=0; y < (ssize_t) image->rows; y++)\n  {\n    PixelPacket\n      *magick_restrict q;\n\n    PixelPacket\n      *p;\n\n    ssize_t\n      x;\n\n    if (status == MagickFalse)\n      continue;\n    q=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n    p=GetAuthenticPixels(complete_mask,0,y,complete_mask->columns,1,exception);\n    if ((q == (PixelPacket *) NULL) || (p == (PixelPacket *) NULL))\n      {\n        status=MagickFalse;\n        continue;\n      }\n    for (x=0; x < (ssize_t) image->columns; x++)\n    {\n      MagickRealType\n        alpha,\n        intensity;\n\n      alpha=(MagickRealType) GetPixelAlpha(q);\n      intensity=GetPixelIntensity(complete_mask,p);\n      if (revert == MagickFalse)\n        SetPixelAlpha(q,ClampToQuantum(intensity*(QuantumScale*alpha)));\n      else if (intensity > 0)\n        SetPixelAlpha(q,ClampToQuantum((alpha\/intensity)*QuantumRange));\n      q++;\n      p++;\n    }\n    if (SyncAuthenticPixels(image,exception) == MagickFalse)\n      status=MagickFalse;\n  }\n  complete_mask=DestroyImage(complete_mask);\n  return(status);\n}","target":0,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":445932,"func":"fr_window_update_current_location (FrWindow *window)\n{\n\tconst char *current_dir = fr_window_get_current_location (window);\n\tchar       *path;\n\tGtkTreeIter iter;\n\n\tif (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {\n\t\tgtk_widget_hide (window->priv->location_bar);\n\t\treturn;\n\t}\n\n\tgtk_widget_show (window->priv->location_bar);\n\n\tgtk_entry_set_text (GTK_ENTRY (window->priv->location_entry), window->priv->archive_present? current_dir: \"\");\n\n\tset_sensitive (window, \"GoBack\", window->priv->archive_present && (current_dir != NULL) && (window->priv->history_current != NULL) && (window->priv->history_current->next != NULL));\n\tset_sensitive (window, \"GoForward\", window->priv->archive_present && (current_dir != NULL) && (window->priv->history_current != NULL) && (window->priv->history_current->prev != NULL));\n\tset_sensitive (window, \"GoUp\", window->priv->archive_present && (current_dir != NULL) && (strcmp (current_dir, \"\/\") != 0));\n\tset_sensitive (window, \"GoHome\", window->priv->archive_present);\n\tgtk_widget_set_sensitive (window->priv->location_entry, window->priv->archive_present);\n\tgtk_widget_set_sensitive (window->priv->location_label, window->priv->archive_present);\n\tgtk_widget_set_sensitive (window->priv->filter_entry, window->priv->archive_present);\n\n\tfr_window_deactivate_filter (window);\n\n#if 0\n\tfr_window_history_print (window);\n#endif\n\n\tpath = _g_path_remove_ending_separator (current_dir);\n\tif (get_tree_iter_from_path (window, path, NULL, &iter)) {\n\t\tGtkTreeSelection *selection;\n\t\tGtkTreePath      *t_path;\n\n\t\tt_path = gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store), &iter);\n\t\tgtk_tree_view_expand_to_path (GTK_TREE_VIEW (window->priv->tree_view), t_path);\n\t\tgtk_tree_path_free (t_path);\n\n\t\tselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view));\n\t\tgtk_tree_selection_select_iter (selection, &iter);\n\t}\n\tg_free (path);\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":242898,"func":"  Status operator()(OpKernelContext* context,\n                    typename TTypes<Tindex>::ConstVec reverse_index_map,\n                    typename TTypes<T>::ConstVec grad_values,\n                    typename TTypes<T>::Vec d_values,\n                    typename TTypes<T>::Scalar d_default_value) {\n    const CPUDevice& device = context->eigen_device<CPUDevice>();\n    const Tindex N = reverse_index_map.dimension(0);\n    const Tindex N_full = grad_values.dimension(0);\n\n    T& d_default_value_scalar = d_default_value();\n    d_default_value_scalar = T();\n\n    Tensor visited_t;\n    TF_RETURN_IF_ERROR(\n        context->allocate_temp(DT_BOOL, TensorShape({N_full}), &visited_t));\n    auto visited = visited_t.vec<bool>();\n    visited.device(device) = visited.constant(false);\n\n    for (int i = 0; i < N; ++i) {\n      \/\/ Locate the index of the output of the forward prop associated\n      \/\/ with this location in the input of the forward prop.  Copy\n      \/\/ the gradient into it.  Mark it as visited.\n      int64_t reverse_index = reverse_index_map(i);\n      if (reverse_index < 0 || reverse_index >= N_full) {\n        return errors::InvalidArgument(\n            \"Elements in reverse index must be in [0, \", N_full, \") but got \",\n            reverse_index);\n      }\n      d_values(i) = grad_values(reverse_index);\n      visited(reverse_index) = true;\n    }\n    for (int j = 0; j < N_full; ++j) {\n      \/\/ The default value gradient gets the accumulated remainder of\n      \/\/ the backprop values (since the default value was used to fill\n      \/\/ in these slots in the forward calculation).\n      if (!visited(j)) {\n        d_default_value_scalar += grad_values(j);\n      }\n    }\n    return Status::OK();\n  }","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":289278,"func":"static snd_pcm_format_t snd_pcm_oss_format_from(int format)\n{\n\tswitch (format) {\n\tcase AFMT_MU_LAW:\treturn SNDRV_PCM_FORMAT_MU_LAW;\n\tcase AFMT_A_LAW:\treturn SNDRV_PCM_FORMAT_A_LAW;\n\tcase AFMT_IMA_ADPCM:\treturn SNDRV_PCM_FORMAT_IMA_ADPCM;\n\tcase AFMT_U8:\t\treturn SNDRV_PCM_FORMAT_U8;\n\tcase AFMT_S16_LE:\treturn SNDRV_PCM_FORMAT_S16_LE;\n\tcase AFMT_S16_BE:\treturn SNDRV_PCM_FORMAT_S16_BE;\n\tcase AFMT_S8:\t\treturn SNDRV_PCM_FORMAT_S8;\n\tcase AFMT_U16_LE:\treturn SNDRV_PCM_FORMAT_U16_LE;\n\tcase AFMT_U16_BE:\treturn SNDRV_PCM_FORMAT_U16_BE;\n\tcase AFMT_MPEG:\t\treturn SNDRV_PCM_FORMAT_MPEG;\n\tcase AFMT_S32_LE:\treturn SNDRV_PCM_FORMAT_S32_LE;\n\tcase AFMT_S32_BE:\treturn SNDRV_PCM_FORMAT_S32_BE;\n\tcase AFMT_S24_LE:\treturn SNDRV_PCM_FORMAT_S24_LE;\n\tcase AFMT_S24_BE:\treturn SNDRV_PCM_FORMAT_S24_BE;\n\tcase AFMT_S24_PACKED:\treturn SNDRV_PCM_FORMAT_S24_3LE;\n\tcase AFMT_FLOAT:\treturn SNDRV_PCM_FORMAT_FLOAT;\n\tcase AFMT_SPDIF_RAW:\treturn SNDRV_PCM_FORMAT_IEC958_SUBFRAME;\n\tdefault:\t\treturn SNDRV_PCM_FORMAT_U8;\n\t}\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":398518,"func":"static const ut8 *parse_die(const ut8 *buf, const ut8 *buf_end, RzBinDwarfDebugInfo *info, RzBinDwarfAbbrevDecl *abbrev,\n\tRzBinDwarfCompUnitHdr *hdr, RzBinDwarfDie *die, const ut8 *debug_str, size_t debug_str_len, bool big_endian) {\n\tsize_t i;\n\tconst char *comp_dir = NULL;\n\tut64 line_info_offset = UT64_MAX;\n\tif (abbrev->count) {\n\t\tfor (i = 0; i < abbrev->count - 1; i++) {\n\t\t\tmemset(&die->attr_values[i], 0, sizeof(die->attr_values[i]));\n\n\t\t\tbuf = parse_attr_value(buf, buf_end - buf, &abbrev->defs[i],\n\t\t\t\t&die->attr_values[i], hdr, debug_str, debug_str_len, big_endian);\n\n\t\t\tRzBinDwarfAttrValue *attribute = &die->attr_values[i];\n\n\t\t\tif (attribute->attr_name == DW_AT_comp_dir && (attribute->attr_form == DW_FORM_strp || attribute->attr_form == DW_FORM_string) && attribute->string.content) {\n\t\t\t\tcomp_dir = attribute->string.content;\n\t\t\t}\n\t\t\tif (attribute->attr_name == DW_AT_stmt_list) {\n\t\t\t\tif (attribute->kind == DW_AT_KIND_CONSTANT) {\n\t\t\t\t\tline_info_offset = attribute->uconstant;\n\t\t\t\t} else if (attribute->kind == DW_AT_KIND_REFERENCE) {\n\t\t\t\t\tline_info_offset = attribute->reference;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdie->count++;\n\t\t}\n\t}\n\n\t\/\/ If this is a compilation unit dir attribute, we want to cache it so the line info parsing\n\t\/\/ which will need this info can quickly look it up.\n\tif (comp_dir && line_info_offset != UT64_MAX) {\n\t\tchar *name = strdup(comp_dir);\n\t\tif (name) {\n\t\t\tif (!ht_up_insert(info->line_info_offset_comp_dir, line_info_offset, name)) {\n\t\t\t\tfree(name);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buf;\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":338123,"func":"void WasmBinaryWriter::writeFeaturesSection() {\n  if (!wasm->hasFeaturesSection || wasm->features.isMVP()) {\n    return;\n  }\n\n  \/\/ TODO(tlively): unify feature names with rest of toolchain and use\n  \/\/ FeatureSet::toString()\n  auto toString = [](FeatureSet::Feature f) {\n    switch (f) {\n      case FeatureSet::Atomics:\n        return BinaryConsts::UserSections::AtomicsFeature;\n      case FeatureSet::MutableGlobals:\n        return BinaryConsts::UserSections::MutableGlobalsFeature;\n      case FeatureSet::TruncSat:\n        return BinaryConsts::UserSections::TruncSatFeature;\n      case FeatureSet::SIMD:\n        return BinaryConsts::UserSections::SIMD128Feature;\n      case FeatureSet::BulkMemory:\n        return BinaryConsts::UserSections::BulkMemoryFeature;\n      case FeatureSet::SignExt:\n        return BinaryConsts::UserSections::SignExtFeature;\n      case FeatureSet::ExceptionHandling:\n        return BinaryConsts::UserSections::ExceptionHandlingFeature;\n      case FeatureSet::TailCall:\n        return BinaryConsts::UserSections::TailCallFeature;\n      case FeatureSet::ReferenceTypes:\n        return BinaryConsts::UserSections::ReferenceTypesFeature;\n      case FeatureSet::Multivalue:\n        return BinaryConsts::UserSections::MultivalueFeature;\n      case FeatureSet::GC:\n        return BinaryConsts::UserSections::GCFeature;\n      case FeatureSet::Memory64:\n        return BinaryConsts::UserSections::Memory64Feature;\n      case FeatureSet::TypedFunctionReferences:\n        return BinaryConsts::UserSections::TypedFunctionReferencesFeature;\n      case FeatureSet::RelaxedSIMD:\n        return BinaryConsts::UserSections::RelaxedSIMDFeature;\n      default:\n        WASM_UNREACHABLE(\"unexpected feature flag\");\n    }\n  };\n\n  std::vector<const char*> features;\n  wasm->features.iterFeatures(\n    [&](FeatureSet::Feature f) { features.push_back(toString(f)); });\n\n  auto start = startSection(BinaryConsts::User);\n  writeInlineString(BinaryConsts::UserSections::TargetFeatures);\n  o << U32LEB(features.size());\n  for (auto& f : features) {\n    o << uint8_t(BinaryConsts::FeatureUsed);\n    writeInlineString(f);\n  }\n  finishSection(start);\n}","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":352932,"func":"numericStringNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\t\/* removal all spaces *\/\n\tchar *p, *q;\n\n\tassert( !BER_BVISEMPTY( val ) );\n\n\tnormalized->bv_val = slap_sl_malloc( val->bv_len + 1, ctx );\n\n\tp = val->bv_val;\n\tq = normalized->bv_val;\n\n\twhile ( *p ) {\n\t\tif ( ASCII_SPACE( *p ) ) {\n\t\t\t\/* Ignore whitespace *\/\n\t\t\tp++;\n\t\t} else {\n\t\t\t*q++ = *p++;\n\t\t}\n\t}\n\n\t\/* we should have copied no more than is in val *\/\n\tassert( (q - normalized->bv_val) <= (p - val->bv_val) );\n\n\t\/* null terminate *\/\n\t*q = '\\0';\n\n\tnormalized->bv_len = q - normalized->bv_val;\n\n\tif( BER_BVISEMPTY( normalized ) ) {\n\t\tnormalized->bv_val = slap_sl_realloc( normalized->bv_val, 2, ctx );\n\t\tnormalized->bv_val[0] = ' ';\n\t\tnormalized->bv_val[1] = '\\0';\n\t\tnormalized->bv_len = 1;\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":444892,"func":"assemble_mountinfo(struct parsed_mount_info *parsed_info,\n\t\t   const char *thisprogram, const char *mountpoint,\n\t\t   const char *orig_dev, char *orgoptions)\n{\n\tint rc;\n\n\trc = drop_capabilities(0);\n\tif (rc)\n\t\tgoto assemble_exit;\n\n\trc = drop_child_privs();\n\tif (rc)\n\t\tgoto assemble_exit;\n\n\tif (getuid()) {\n\t\trc = check_fstab(thisprogram, mountpoint, orig_dev,\n\t\t\t\t &orgoptions);\n\t\tif (rc)\n\t\t\tgoto assemble_exit;\n\n\t\t\/* enable any default user mount flags *\/\n\t\tparsed_info->flags |= CIFS_SETUID_FLAGS;\n\t}\n\n\trc = get_pw_from_env(parsed_info);\n\tif (rc)\n\t\tgoto assemble_exit;\n\n\tif (orgoptions) {\n\t\trc = parse_options(orgoptions, parsed_info);\n\t\tif (rc)\n\t\t\tgoto assemble_exit;\n\t}\n\n\tif (getuid()) {\n\t\tif (!(parsed_info->flags & (MS_USERS | MS_USER))) {\n\t\t\tfprintf(stderr, \"%s: permission denied\\n\", thisprogram);\n\t\t\trc = EX_USAGE;\n\t\t\tgoto assemble_exit;\n\t\t}\n\t}\n\n\tparsed_info->flags &= ~(MS_USERS | MS_USER);\n\n\trc = parse_unc(orig_dev, parsed_info);\n\tif (rc)\n\t\tgoto assemble_exit;\n\n\tif (parsed_info->addrlist[0] == '\\0')\n\t\trc = resolve_host(parsed_info->host, parsed_info->addrlist);\n\n\tswitch (rc) {\n\tcase EX_USAGE:\n\t\tfprintf(stderr, \"mount error: could not resolve address for \"\n\t\t\t\"%s: %s\\n\", parsed_info->host,\n\t\t\trc == EAI_SYSTEM ? strerror(errno) : gai_strerror(rc));\n\t\tgoto assemble_exit;\n\n\tcase EX_SYSERR:\n\t\tfprintf(stderr, \"mount error: problem parsing address \"\n\t\t\t\"list: %s\\n\", strerror(errno));\n\t\tgoto assemble_exit;\n\t}\n\n\tif (!parsed_info->got_user) {\n\t\t\/*\n\t\t * Note that the password will not be retrieved from the\n\t\t * USER env variable (ie user%password form) as there is\n\t\t * already a PASSWD environment varaible\n\t\t *\/\n\t\tif (getenv(\"USER\"))\n\t\t\tstrlcpy(parsed_info->username, getenv(\"USER\"),\n\t\t\t\tsizeof(parsed_info->username));\n\t\telse\n\t\t\tstrlcpy(parsed_info->username, getusername(getuid()),\n\t\t\t\tsizeof(parsed_info->username));\n\t\tparsed_info->got_user = 1;\n\t}\n\n\tif (!parsed_info->got_password) {\n\t\t\/* getpass is obsolete, but there's apparently nothing that replaces it *\/\n\t\tchar *tmp_pass = getpass(\"Password: \");\n\t\tif (!tmp_pass) {\n\t\t\tfprintf(stderr, \"Error reading password, exiting\\n\");\n\t\t\trc = EX_SYSERR;\n\t\t\tgoto assemble_exit;\n\t\t}\n\t\trc = set_password(parsed_info, tmp_pass);\n\t\tif (rc)\n\t\t\tgoto assemble_exit;\n\t}\n\n\t\/* copy in ver= string. It's not really needed, but what the hell *\/\n\tstrlcat(parsed_info->options, \",ver=\", sizeof(parsed_info->options));\n\tstrlcat(parsed_info->options, OPTIONS_VERSION, sizeof(parsed_info->options));\n\n\t\/* copy in user= string *\/\n\tif (parsed_info->got_user) {\n\t\tstrlcat(parsed_info->options, \",user=\",\n\t\t\tsizeof(parsed_info->options));\n\t\tstrlcat(parsed_info->options, parsed_info->username,\n\t\t\tsizeof(parsed_info->options));\n\t}\n\n\tif (*parsed_info->domain) {\n\t\tstrlcat(parsed_info->options, \",domain=\",\n\t\t\tsizeof(parsed_info->options));\n\t\tstrlcat(parsed_info->options, parsed_info->domain,\n\t\t\tsizeof(parsed_info->options));\n\t}\n\nassemble_exit:\n\treturn rc;\n}","target":0,"code_token_length":772,"total_token_length":1008,"max_tokens_setting":1024}
+{"idx":352978,"func":"serialNumberAndIssuerSerialPretty(\n\tSyntax *syntax,\n\tstruct berval *in,\n\tstruct berval *out,\n\tvoid *ctx )\n{\n\tstruct berval sn, i, i_sn, ni = BER_BVNULL;\n\tchar *p;\n\tint rc;\n\n\tassert( in != NULL );\n\tassert( out != NULL );\n\n\tDebug( LDAP_DEBUG_TRACE, \">>> serialNumberAndIssuerSerialPretty: <%s>\\n\",\n\t\tin->bv_val );\n\n\trc = serialNumberAndIssuerSerialCheck( in, &sn, &i, &i_sn, ctx );\n\tif ( rc ) {\n\t\tgoto done;\n\t}\n\n\trc = dnPretty( syntax, &i, &ni, ctx );\n\n\tif ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) {\n\t\tslap_sl_free( i.bv_val, ctx );\n\t}\n\n\tif ( rc ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t\tgoto done;\n\t}\n\n\t\/* make room from sn + \"$\" *\/\n\tout->bv_len = STRLENOF(\"{ serialNumber , issuer { baseCertificateID { issuer { directoryName:rdnSequence:\\\"\\\" }, serial  } } }\")\n\t\t+ sn.bv_len + ni.bv_len + i_sn.bv_len;\n\tout->bv_val = slap_sl_malloc( out->bv_len + 1, ctx );\n\n\tif ( out->bv_val == NULL ) {\n\t\tout->bv_len = 0;\n\t\trc = LDAP_OTHER;\n\t\tgoto done;\n\t}\n\n\tp = out->bv_val;\n\tp = lutil_strcopy( p, \"{ serialNumber \" );\n\tp = lutil_strbvcopy( p, &sn );\n\tp = lutil_strcopy( p, \", issuer { baseCertificateID { issuer { directoryName:rdnSequence:\\\"\" );\n\tp = lutil_strbvcopy( p, &ni );\n\tp = lutil_strcopy( p, \"\\\" }, serial \" );\n\tp = lutil_strbvcopy( p, &i_sn );\n\tp = lutil_strcopy( p, \" } } }\" );\n\n\tassert( p == &out->bv_val[out->bv_len] );\n\ndone:;\n\tDebug( LDAP_DEBUG_TRACE, \"<<< serialNumberAndIssuerSerialPretty: <%s> => <%s>\\n\",\n\t\tin->bv_val, rc == LDAP_SUCCESS ? out->bv_val : \"(err)\" );\n\n\tslap_sl_free( ni.bv_val, ctx );\n\n\treturn rc; \n}","target":0,"code_token_length":516,"total_token_length":752,"max_tokens_setting":1024}
+{"idx":259292,"func":"static int mov_read_kind(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVFormatContext *ctx = c->fc;\n    AVStream *st = NULL;\n    AVBPrint scheme_buf, value_buf;\n    int64_t scheme_str_len = 0, value_str_len = 0;\n    int version, flags, ret = AVERROR_BUG;\n    int64_t size = atom.size;\n\n    if (atom.size < 6)\n        \/\/ 4 bytes for version + flags, 2x 1 byte for null\n        return AVERROR_INVALIDDATA;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    version = avio_r8(pb);\n    flags   = avio_rb24(pb);\n    size   -= 4;\n\n    if (version != 0 || flags != 0) {\n        av_log(ctx, AV_LOG_ERROR,\n               \"Unsupported 'kind' box with version %d, flags: %x\",\n               version, flags);\n        return AVERROR_INVALIDDATA;\n    }\n\n    av_bprint_init(&scheme_buf, 0, AV_BPRINT_SIZE_UNLIMITED);\n    av_bprint_init(&value_buf,  0, AV_BPRINT_SIZE_UNLIMITED);\n\n    if ((scheme_str_len = ff_read_string_to_bprint_overwrite(pb, &scheme_buf,\n                                                             size)) < 0) {\n        ret = scheme_str_len;\n        goto cleanup;\n    }\n\n    if (scheme_str_len + 1 >= size) {\n        \/\/ we need to have another string, even if nullptr.\n        \/\/ we check with + 1 since we expect that if size was not hit,\n        \/\/ an additional null was read.\n        ret = AVERROR_INVALIDDATA;\n        goto cleanup;\n    }\n\n    size -= scheme_str_len + 1;\n\n    if ((value_str_len = ff_read_string_to_bprint_overwrite(pb, &value_buf,\n                                                            size)) < 0) {\n        ret = value_str_len;\n        goto cleanup;\n    }\n\n    if (value_str_len == size) {\n        \/\/ in case of no trailing null, box is not valid.\n        ret = AVERROR_INVALIDDATA;\n        goto cleanup;\n    }\n\n    av_log(ctx, AV_LOG_TRACE,\n           \"%s stream %d KindBox(scheme: %s, value: %s)\\n\",\n           av_get_media_type_string(st->codecpar->codec_type),\n           st->index,\n           scheme_buf.str, value_buf.str);\n\n    for (int i = 0; ff_mov_track_kind_table[i].scheme_uri; i++) {\n        const struct MP4TrackKindMapping map = ff_mov_track_kind_table[i];\n        if (!av_strstart(scheme_buf.str, map.scheme_uri, NULL))\n            continue;\n\n        for (int j = 0; map.value_maps[j].disposition; j++) {\n            const struct MP4TrackKindValueMapping value_map = map.value_maps[j];\n            if (!av_strstart(value_buf.str, value_map.value, NULL))\n                continue;\n\n            st->disposition |= value_map.disposition;\n        }\n    }\n\n    ret = 0;\n\ncleanup:\n\n    av_bprint_finalize(&scheme_buf, NULL);\n    av_bprint_finalize(&value_buf,  NULL);\n\n    return ret;\n}","target":0,"code_token_length":707,"total_token_length":943,"max_tokens_setting":1024}
+{"idx":291820,"func":"int rtrs_clt_request(int dir, struct rtrs_clt_req_ops *ops,\n\t\t     struct rtrs_clt_sess *clt, struct rtrs_permit *permit,\n\t\t     const struct kvec *vec, size_t nr, size_t data_len,\n\t\t     struct scatterlist *sg, unsigned int sg_cnt)\n{\n\tstruct rtrs_clt_io_req *req;\n\tstruct rtrs_clt_path *clt_path;\n\n\tenum dma_data_direction dma_dir;\n\tint err = -ECONNABORTED, i;\n\tsize_t usr_len, hdr_len;\n\tstruct path_it it;\n\n\t\/* Get kvec length *\/\n\tfor (i = 0, usr_len = 0; i < nr; i++)\n\t\tusr_len += vec[i].iov_len;\n\n\tif (dir == READ) {\n\t\thdr_len = sizeof(struct rtrs_msg_rdma_read) +\n\t\t\t  sg_cnt * sizeof(struct rtrs_sg_desc);\n\t\tdma_dir = DMA_FROM_DEVICE;\n\t} else {\n\t\thdr_len = sizeof(struct rtrs_msg_rdma_write);\n\t\tdma_dir = DMA_TO_DEVICE;\n\t}\n\n\trcu_read_lock();\n\tfor (path_it_init(&it, clt);\n\t     (clt_path = it.next_path(&it)) && it.i < it.clt->paths_num; it.i++) {\n\t\tif (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED)\n\t\t\tcontinue;\n\n\t\tif (usr_len + hdr_len > clt_path->max_hdr_size) {\n\t\t\trtrs_wrn_rl(clt_path->clt,\n\t\t\t\t     \"%s request failed, user message size is %zu and header length %zu, but max size is %u\\n\",\n\t\t\t\t     dir == READ ? \"Read\" : \"Write\",\n\t\t\t\t     usr_len, hdr_len, clt_path->max_hdr_size);\n\t\t\terr = -EMSGSIZE;\n\t\t\tbreak;\n\t\t}\n\t\treq = rtrs_clt_get_req(clt_path, ops->conf_fn, permit, ops->priv,\n\t\t\t\t       vec, usr_len, sg, sg_cnt, data_len,\n\t\t\t\t       dma_dir);\n\t\tif (dir == READ)\n\t\t\terr = rtrs_clt_read_req(req);\n\t\telse\n\t\t\terr = rtrs_clt_write_req(req);\n\t\tif (err) {\n\t\t\treq->in_use = false;\n\t\t\tcontinue;\n\t\t}\n\t\t\/* Success path *\/\n\t\tbreak;\n\t}\n\tpath_it_deinit(&it);\n\trcu_read_unlock();\n\n\treturn err;\n}","target":0,"code_token_length":511,"total_token_length":747,"max_tokens_setting":1024}
+{"idx":263495,"func":"static int sco_sock_accept(struct socket *sock, struct socket *newsock,\n\t\t\t   int flags, bool kern)\n{\n\tDEFINE_WAIT_FUNC(wait, woken_wake_function);\n\tstruct sock *sk = sock->sk, *ch;\n\tlong timeo;\n\tint err = 0;\n\n\tlock_sock(sk);\n\n\ttimeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);\n\n\tBT_DBG(\"sk %p timeo %ld\", sk, timeo);\n\n\t\/* Wait for an incoming connection. (wake-one). *\/\n\tadd_wait_queue_exclusive(sk_sleep(sk), &wait);\n\twhile (1) {\n\t\tif (sk->sk_state != BT_LISTEN) {\n\t\t\terr = -EBADFD;\n\t\t\tbreak;\n\t\t}\n\n\t\tch = bt_accept_dequeue(sk, newsock);\n\t\tif (ch)\n\t\t\tbreak;\n\n\t\tif (!timeo) {\n\t\t\terr = -EAGAIN;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (signal_pending(current)) {\n\t\t\terr = sock_intr_errno(timeo);\n\t\t\tbreak;\n\t\t}\n\n\t\trelease_sock(sk);\n\n\t\ttimeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);\n\t\tlock_sock(sk);\n\t}\n\tremove_wait_queue(sk_sleep(sk), &wait);\n\n\tif (err)\n\t\tgoto done;\n\n\tnewsock->state = SS_CONNECTED;\n\n\tBT_DBG(\"new socket %p\", ch);\n\ndone:\n\trelease_sock(sk);\n\treturn err;\n}","target":0,"code_token_length":293,"total_token_length":529,"max_tokens_setting":1024}
+{"idx":437299,"func":"concat_opt_exact(OptExact* to, OptExact* add, OnigEncoding enc)\n{\n  int i, j, len, r;\n  UChar *p, *end;\n  OptAnc tanc;\n\n  if (! to->ignore_case && add->ignore_case) {\n    if (to->len >= add->len) return 0;  \/* avoid *\/\n\n    to->ignore_case = 1;\n  }\n\n  r = 0;\n  p = add->s;\n  end = p + add->len;\n  for (i = to->len; p < end; ) {\n    len = enclen(enc, p);\n    if (i + len > OPT_EXACT_MAXLEN) {\n      r = 1; \/* 1:full *\/\n      break;\n    }\n    for (j = 0; j < len && p < end; j++)\n      to->s[i++] = *p++;\n  }\n\n  to->len = i;\n  to->reach_end = (p == end ? add->reach_end : 0);\n\n  concat_opt_anc_info(&tanc, &to->anc, &add->anc, 1, 1);\n  if (! to->reach_end) tanc.right = 0;\n  copy_opt_anc_info(&to->anc, &tanc);\n\n  return r;\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":292236,"func":"inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,\n\t\t\t\t\t  const message_tags_data *tags_data)\n{\n\tsession *sess;\n\tstruct User *user;\n\tchar idtext[64];\n\tgboolean nodiag = FALSE;\n\n\tsess = find_dialog (serv, from);\n\n\tif (sess || prefs.hex_gui_autoopen_dialog)\n\t{\n\t\t\/*0=ctcp  1=priv will set hex_gui_autoopen_dialog=0 here is flud detected *\/\n\t\tif (!sess)\n\t\t{\n\t\t\tif (flood_check (from, ip, serv, current_sess, 1))\n\t\t\t\t\/* Create a dialog session *\/\n\t\t\t\tsess = inbound_open_dialog (serv, from, tags_data);\n\t\t\telse\n\t\t\t\tsess = serv->server_session;\n\t\t\tif (!sess)\n\t\t\t\treturn; \/* ?? *\/\n\t\t}\n\n\t\tif (ip && ip[0])\n\t\t\tset_topic (sess, ip, ip);\n\t\tinbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id, tags_data);\n\t\treturn;\n\t}\n\n\tsess = find_session_from_nick (from, serv);\n\tif (!sess)\n\t{\n\t\tsess = serv->front_session;\n\t\tnodiag = TRUE; \/* We don't want it to look like a normal message in front sess *\/\n\t}\n\n\tuser = userlist_find (sess, from);\n\tif (user)\n\t{\n\t\tuser->lasttalk = time (0);\n\t\tif (user->account)\n\t\t\tid = TRUE;\n\t}\n\t\n\tinbound_make_idtext (serv, idtext, sizeof (idtext), id);\n\n\tif (sess->type == SESS_DIALOG && !nodiag)\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0,\n\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\telse\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_PRIVMSG, sess, from, text, idtext, NULL, 0, \n\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":242936,"func":"static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n    size_t len;\n\n    if( ssl->conf->f_cookie_write == NULL ||\n        ssl->conf->f_cookie_check == NULL )\n    {\n        \/* If we can't use cookies to verify reachability of the peer,\n         * drop the record. *\/\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"no cookie callbacks, \"\n                                    \"can't check reconnect validity\" ) );\n        return( 0 );\n    }\n\n    ret = ssl_check_dtls_clihlo_cookie(\n            ssl,\n            ssl->cli_id, ssl->cli_id_len,\n            ssl->in_buf, ssl->in_left,\n            ssl->out_buf, MBEDTLS_SSL_OUT_CONTENT_LEN, &len );\n\n    MBEDTLS_SSL_DEBUG_RET( 2, \"ssl_check_dtls_clihlo_cookie\", ret );\n\n    if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED )\n    {\n        int send_ret;\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"sending HelloVerifyRequest\" ) );\n        MBEDTLS_SSL_DEBUG_BUF( 4, \"output record sent to network\",\n                                  ssl->out_buf, len );\n        \/* Don't check write errors as we can't do anything here.\n         * If the error is permanent we'll catch it later,\n         * if it's not, then hopefully it'll work next time. *\/\n        send_ret = ssl->f_send( ssl->p_bio, ssl->out_buf, len );\n        MBEDTLS_SSL_DEBUG_RET( 2, \"ssl->f_send\", send_ret );\n        (void) send_ret;\n\n        return( 0 );\n    }\n\n    if( ret == 0 )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 1, ( \"cookie is valid, resetting context\" ) );\n        if( ( ret = mbedtls_ssl_session_reset_int( ssl, 1 ) ) != 0 )\n        {\n            MBEDTLS_SSL_DEBUG_RET( 1, \"reset\", ret );\n            return( ret );\n        }\n\n        return( MBEDTLS_ERR_SSL_CLIENT_RECONNECT );\n    }\n\n    return( ret );\n}","target":0,"code_token_length":465,"total_token_length":701,"max_tokens_setting":1024}
+{"idx":301363,"func":"static int vfswrap_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode)\n{\n\tint result;\n\tbool has_dacl = False;\n\tchar *parent = NULL;\n\n\tSTART_PROFILE(syscall_mkdir);\n\n\tif (lp_inherit_acls(SNUM(handle->conn))\n\t    && parent_dirname(talloc_tos(), path, &parent, NULL)\n\t    && (has_dacl = directory_has_default_acl(handle->conn, parent)))\n\t\tmode = (0777 & lp_dir_mask(SNUM(handle->conn)));\n\n\tTALLOC_FREE(parent);\n\n\tresult = mkdir(path, mode);\n\n\tif (result == 0 && !has_dacl) {\n\t\t\/*\n\t\t * We need to do this as the default behavior of POSIX ACLs\n\t\t * is to set the mask to be the requested group permission\n\t\t * bits, not the group permission bits to be the requested\n\t\t * group permission bits. This is not what we want, as it will\n\t\t * mess up any inherited ACL bits that were set. JRA.\n\t\t *\/\n\t\tint saved_errno = errno; \/* We may get ENOSYS *\/\n\t\tif ((SMB_VFS_CHMOD_ACL(handle->conn, path, mode) == -1) && (errno == ENOSYS))\n\t\t\terrno = saved_errno;\n\t}\n\n\tEND_PROFILE(syscall_mkdir);\n\treturn result;\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":484772,"func":"static int xennet_connect(struct net_device *dev)\n{\n\tstruct netfront_info *np = netdev_priv(dev);\n\tunsigned int num_queues = 0;\n\tint err;\n\tunsigned int j = 0;\n\tstruct netfront_queue *queue = NULL;\n\n\tif (!xenbus_read_unsigned(np->xbdev->otherend, \"feature-rx-copy\", 0)) {\n\t\tdev_info(&dev->dev,\n\t\t\t \"backend does not support copying receive path\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\terr = talk_to_netback(np->xbdev, np);\n\tif (err)\n\t\treturn err;\n\tif (np->netback_has_xdp_headroom)\n\t\tpr_info(\"backend supports XDP headroom\\n\");\n\tif (np->bounce)\n\t\tdev_info(&np->xbdev->dev,\n\t\t\t \"bouncing transmitted data to zeroed pages\\n\");\n\n\t\/* talk_to_netback() sets the correct number of queues *\/\n\tnum_queues = dev->real_num_tx_queues;\n\n\tif (dev->reg_state == NETREG_UNINITIALIZED) {\n\t\terr = register_netdev(dev);\n\t\tif (err) {\n\t\t\tpr_warn(\"%s: register_netdev err=%d\\n\", __func__, err);\n\t\t\tdevice_unregister(&np->xbdev->dev);\n\t\t\treturn err;\n\t\t}\n\t}\n\n\trtnl_lock();\n\tnetdev_update_features(dev);\n\trtnl_unlock();\n\n\t\/*\n\t * All public and private state should now be sane.  Get\n\t * ready to start sending and receiving packets and give the driver\n\t * domain a kick because we've probably just requeued some\n\t * packets.\n\t *\/\n\tnetif_tx_lock_bh(np->netdev);\n\tnetif_device_attach(np->netdev);\n\tnetif_tx_unlock_bh(np->netdev);\n\n\tnetif_carrier_on(np->netdev);\n\tfor (j = 0; j < num_queues; ++j) {\n\t\tqueue = &np->queues[j];\n\n\t\tnotify_remote_via_irq(queue->tx_irq);\n\t\tif (queue->tx_irq != queue->rx_irq)\n\t\t\tnotify_remote_via_irq(queue->rx_irq);\n\n\t\tspin_lock_irq(&queue->tx_lock);\n\t\txennet_tx_buf_gc(queue);\n\t\tspin_unlock_irq(&queue->tx_lock);\n\n\t\tspin_lock_bh(&queue->rx_lock);\n\t\txennet_alloc_rx_buffers(queue);\n\t\tspin_unlock_bh(&queue->rx_lock);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":500,"total_token_length":736,"max_tokens_setting":1024}
+{"idx":216027,"func":"pax_decode_header (struct tar_sparse_file *file)\n{\n  if (file->stat_info->sparse_major > 0)\n    {\n      uintmax_t u;\n      char nbuf[UINTMAX_STRSIZE_BOUND];\n      union block *blk;\n      char *p;\n      size_t i;\n      off_t start;\n      \n#define COPY_BUF(b,buf,src) do                                     \\\n {                                                                 \\\n   char *endp = b->buffer + BLOCKSIZE;                             \\\n   char *dst = buf;                                                \\\n   do                                                              \\\n     {                                                             \\\n       if (dst == buf + UINTMAX_STRSIZE_BOUND -1)                  \\\n         {                                                         \\\n           ERROR ((0, 0, _(\"%s: numeric overflow in sparse archive member\"), \\\n\t          file->stat_info->orig_file_name));               \\\n           return false;                                           \\\n         }                                                         \\\n       if (src == endp)                                            \\\n\t {                                                         \\\n\t   set_next_block_after (b);                               \\\n           b = find_next_block ();                                 \\\n           src = b->buffer;                                        \\\n\t   endp = b->buffer + BLOCKSIZE;                           \\\n\t }                                                         \\\n       *dst = *src++;                                              \\\n     }                                                             \\\n   while (*dst++ != '\\n');                                         \\\n   dst[-1] = 0;                                                    \\\n } while (0)\n\n      start = current_block_ordinal ();\n      set_next_block_after (current_header);\n      blk = find_next_block ();\n      p = blk->buffer;\n      COPY_BUF (blk,nbuf,p);\n      if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))\n\t{\n\t  ERROR ((0, 0, _(\"%s: malformed sparse archive member\"),\n\t\t  file->stat_info->orig_file_name));\n\t  return false;\n\t}\n      file->stat_info->sparse_map_size = u;\n      file->stat_info->sparse_map = xcalloc (file->stat_info->sparse_map_size,\n\t\t\t\t\t     sizeof (*file->stat_info->sparse_map));\n      file->stat_info->sparse_map_avail = 0;\n      for (i = 0; i < file->stat_info->sparse_map_size; i++)\n\t{\n\t  struct sp_array sp;\n\n\t  COPY_BUF (blk,nbuf,p);\n\t  if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t)))\n\t    {\n\t      ERROR ((0, 0, _(\"%s: malformed sparse archive member\"),\n\t\t      file->stat_info->orig_file_name));\n\t      return false;\n\t    }\n\t  sp.offset = u;\n\t  COPY_BUF (blk,nbuf,p);\n\t  if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t)))\n\t    {\n\t      ERROR ((0, 0, _(\"%s: malformed sparse archive member\"),\n\t\t      file->stat_info->orig_file_name));\n\t      return false;\n\t    }\n\t  sp.numbytes = u;\n\t  sparse_add_map (file->stat_info, &sp);\n\t}\n      set_next_block_after (blk);\n\n      file->dumped_size += BLOCKSIZE * (current_block_ordinal () - start);\n    }\n\n  return true;\n}","target":1,"code_token_length":638,"total_token_length":874,"max_tokens_setting":1024}
+{"idx":294648,"func":"offset_to_sec(VALUE vof, int *rof)\n{\n    int try_rational = 1;\n\n  again:\n    switch (TYPE(vof)) {\n      case T_FIXNUM:\n\t{\n\t    long n;\n\n\t    n = FIX2LONG(vof);\n\t    if (n != -1 && n != 0 && n != 1)\n\t\treturn 0;\n\t    *rof = (int)n * DAY_IN_SECONDS;\n\t    return 1;\n\t}\n      case T_FLOAT:\n\t{\n\t    double n;\n\n\t    n = RFLOAT_VALUE(vof) * DAY_IN_SECONDS;\n\t    if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)\n\t\treturn 0;\n\t    *rof = (int)round(n);\n\t    if (*rof != n)\n\t\trb_warning(\"fraction of offset is ignored\");\n\t    return 1;\n\t}\n      default:\n\texpect_numeric(vof);\n\tvof = f_to_r(vof);\n\tif (!k_rational_p(vof)) {\n\t    if (!try_rational) Check_Type(vof, T_RATIONAL);\n\t    try_rational = 0;\n\t    goto again;\n\t}\n\t\/* fall through *\/\n      case T_RATIONAL:\n\t{\n\t    VALUE vs, vn, vd;\n\t    long n;\n\n\t    vs = day_to_sec(vof);\n\n\t    if (!k_rational_p(vs)) {\n\t\tvn = vs;\n\t\tgoto rounded;\n\t    }\n\t    vn = rb_rational_num(vs);\n\t    vd = rb_rational_den(vs);\n\n\t    if (FIXNUM_P(vn) && FIXNUM_P(vd) && (FIX2LONG(vd) == 1))\n\t\tn = FIX2LONG(vn);\n\t    else {\n\t\tvn = f_round(vs);\n\t\tif (!f_eqeq_p(vn, vs))\n\t\t    rb_warning(\"fraction of offset is ignored\");\n\t      rounded:\n\t\tif (!FIXNUM_P(vn))\n\t\t    return 0;\n\t\tn = FIX2LONG(vn);\n\t\tif (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)\n\t\t    return 0;\n\t    }\n\t    *rof = (int)n;\n\t    return 1;\n\t}\n      case T_STRING:\n\t{\n\t    VALUE vs = date_zone_to_diff(vof);\n\t    long n;\n\n\t    if (!FIXNUM_P(vs))\n\t\treturn 0;\n\t    n = FIX2LONG(vs);\n\t    if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)\n\t\treturn 0;\n\t    *rof = (int)n;\n\t    return 1;\n\t}\n    }\n    return 0;\n}","target":0,"code_token_length":533,"total_token_length":769,"max_tokens_setting":1024}
+{"idx":487633,"func":"asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,\n\t\t\t  unsigned long arg4, unsigned long arg5)\n{\n\tlong error;\n\n\terror = security_task_prctl(option, arg2, arg3, arg4, arg5);\n\tif (error)\n\t\treturn error;\n\n\tswitch (option) {\n\t\tcase PR_SET_PDEATHSIG:\n\t\t\tif (!valid_signal(arg2)) {\n\t\t\t\terror = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrent->pdeath_signal = arg2;\n\t\t\tbreak;\n\t\tcase PR_GET_PDEATHSIG:\n\t\t\terror = put_user(current->pdeath_signal, (int __user *)arg2);\n\t\t\tbreak;\n\t\tcase PR_GET_DUMPABLE:\n\t\t\terror = current->mm->dumpable;\n\t\t\tbreak;\n\t\tcase PR_SET_DUMPABLE:\n\t\t\tif (arg2 < 0 || arg2 > 1) {\n\t\t\t\terror = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrent->mm->dumpable = arg2;\n\t\t\tbreak;\n\n\t\tcase PR_SET_UNALIGN:\n\t\t\terror = SET_UNALIGN_CTL(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_GET_UNALIGN:\n\t\t\terror = GET_UNALIGN_CTL(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_SET_FPEMU:\n\t\t\terror = SET_FPEMU_CTL(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_GET_FPEMU:\n\t\t\terror = GET_FPEMU_CTL(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_SET_FPEXC:\n\t\t\terror = SET_FPEXC_CTL(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_GET_FPEXC:\n\t\t\terror = GET_FPEXC_CTL(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_GET_TIMING:\n\t\t\terror = PR_TIMING_STATISTICAL;\n\t\t\tbreak;\n\t\tcase PR_SET_TIMING:\n\t\t\tif (arg2 == PR_TIMING_STATISTICAL)\n\t\t\t\terror = 0;\n\t\t\telse\n\t\t\t\terror = -EINVAL;\n\t\t\tbreak;\n\n\t\tcase PR_GET_KEEPCAPS:\n\t\t\tif (current->keep_capabilities)\n\t\t\t\terror = 1;\n\t\t\tbreak;\n\t\tcase PR_SET_KEEPCAPS:\n\t\t\tif (arg2 != 0 && arg2 != 1) {\n\t\t\t\terror = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrent->keep_capabilities = arg2;\n\t\t\tbreak;\n\t\tcase PR_SET_NAME: {\n\t\t\tstruct task_struct *me = current;\n\t\t\tunsigned char ncomm[sizeof(me->comm)];\n\n\t\t\tncomm[sizeof(me->comm)-1] = 0;\n\t\t\tif (strncpy_from_user(ncomm, (char __user *)arg2,\n\t\t\t\t\t\tsizeof(me->comm)-1) < 0)\n\t\t\t\treturn -EFAULT;\n\t\t\tset_task_comm(me, ncomm);\n\t\t\treturn 0;\n\t\t}\n\t\tcase PR_GET_NAME: {\n\t\t\tstruct task_struct *me = current;\n\t\t\tunsigned char tcomm[sizeof(me->comm)];\n\n\t\t\tget_task_comm(tcomm, me);\n\t\t\tif (copy_to_user((char __user *)arg2, tcomm, sizeof(tcomm)))\n\t\t\t\treturn -EFAULT;\n\t\t\treturn 0;\n\t\t}\n\t\tcase PR_GET_ENDIAN:\n\t\t\terror = GET_ENDIAN(current, arg2);\n\t\t\tbreak;\n\t\tcase PR_SET_ENDIAN:\n\t\t\terror = SET_ENDIAN(current, arg2);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\terror = -EINVAL;\n\t\t\tbreak;\n\t}\n\treturn error;\n}","target":0,"code_token_length":703,"total_token_length":939,"max_tokens_setting":1024}
+{"idx":329889,"func":"fill_boxes (void\t\t*_dst,\n\t    cairo_operator_t\t op,\n\t    const cairo_color_t\t*color,\n\t    cairo_boxes_t\t*boxes)\n{\n    cairo_image_surface_t *dst = _dst;\n    struct _cairo_boxes_chunk *chunk;\n    uint32_t pixel;\n    int i;\n\n    TRACE ((stderr, \"%s x %d\\n\", __FUNCTION__, boxes->num_boxes));\n\n    if (fill_reduces_to_source (op, color, dst, &pixel)) {\n\tfor (chunk = &boxes->chunks; chunk; chunk = chunk->next) {\n\t    for (i = 0; i < chunk->count; i++) {\n\t\tint x = _cairo_fixed_integer_part (chunk->base[i].p1.x);\n\t\tint y = _cairo_fixed_integer_part (chunk->base[i].p1.y);\n\t\tint w = _cairo_fixed_integer_part (chunk->base[i].p2.x) - x;\n\t\tint h = _cairo_fixed_integer_part (chunk->base[i].p2.y) - y;\n\t\tpixman_fill ((uint32_t *) dst->data,\n\t\t\t     dst->stride \/ sizeof (uint32_t),\n\t\t\t     PIXMAN_FORMAT_BPP (dst->pixman_format),\n\t\t\t     x, y, w, h, pixel);\n\t    }\n\t}\n    }\n    else\n    {\n\tpixman_image_t *src = _pixman_image_for_color (color);\n\tif (unlikely (src == NULL))\n\t    return _cairo_error (CAIRO_STATUS_NO_MEMORY);\n\n\top = _pixman_operator (op);\n\tfor (chunk = &boxes->chunks; chunk; chunk = chunk->next) {\n\t    for (i = 0; i < chunk->count; i++) {\n\t\tint x1 = _cairo_fixed_integer_part (chunk->base[i].p1.x);\n\t\tint y1 = _cairo_fixed_integer_part (chunk->base[i].p1.y);\n\t\tint x2 = _cairo_fixed_integer_part (chunk->base[i].p2.x);\n\t\tint y2 = _cairo_fixed_integer_part (chunk->base[i].p2.y);\n\t\tpixman_image_composite32 (op,\n\t\t\t\t\t  src, NULL, dst->pixman_image,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  0, 0,\n\t\t\t\t\t  x1, y1,\n\t\t\t\t\t  x2-x1, y2-y1);\n\t    }\n\t}\n\n\tpixman_image_unref (src);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":310118,"func":"init_xterm_mouse(SCREEN *sp)\n{\n    sp->_mouse_type = M_XTERM;\n    sp->_mouse_format = MF_X10;\n    sp->_mouse_xtermcap = tigetstr(\"XM\");\n    if (VALID_STRING(sp->_mouse_xtermcap)) {\n\tchar *code = strstr(sp->_mouse_xtermcap, \"[?\");\n\tif (code != 0) {\n\t    code += 2;\n\t    while ((*code >= '0') && (*code <= '9')) {\n\t\tchar *next = code;\n\t\twhile ((*next >= '0') && (*next <= '9')) {\n\t\t    ++next;\n\t\t}\n\t\tif (!strncmp(code, \"1006\", (size_t) (next - code))) {\n\t\t    sp->_mouse_format = MF_SGR1006;\n\t\t}\n#ifdef EXP_XTERM_1005\n\t\tif (!strncmp(code, \"1005\", (size_t) (next - code))) {\n\t\t    sp->_mouse_format = MF_XTERM_1005;\n\t\t}\n#endif\n\t\tif (*next == ';') {\n\t\t    while (*next == ';') {\n\t\t\t++next;\n\t\t    }\n\t\t    code = next;\n\t\t} else {\n\t\t    break;\n\t\t}\n\t    }\n\t}\n    } else {\n\tint code = tigetnum(\"XM\");\n\tswitch (code) {\n\tcase 1006:\n\t    break;\n\tdefault:\n\t    code = 1000;\n\t    break;\n\t}\n\tsp->_mouse_xtermcap = \"\\033[?1000%?%p1%{1}%=%th%el%;\";\n    }\n}","target":0,"code_token_length":347,"total_token_length":583,"max_tokens_setting":1024}
+{"idx":209968,"func":"static int formatIPTCfromBuffer(Image *ofile, char *s, ssize_t len)\n{\n  char\n    temp[MaxTextExtent];\n\n  unsigned int\n    foundiptc,\n    tagsfound;\n\n  unsigned char\n    recnum,\n    dataset;\n\n  unsigned char\n    *readable,\n    *str;\n\n  ssize_t\n    tagindx,\n    taglen;\n\n  int\n    i,\n    tagcount = (int) (sizeof(tags) \/ sizeof(tag_spec));\n\n  int\n    c;\n\n  foundiptc = 0; \/* found the IPTC-Header *\/\n  tagsfound = 0; \/* number of tags found *\/\n\n  while (len > 0)\n  {\n    c = *s++; len--;\n    if (c == 0x1c)\n      foundiptc = 1;\n    else\n      {\n        if (foundiptc)\n          return -1;\n        else\n          continue;\n      }\n    \/*\n      We found the 0x1c tag and now grab the dataset and record number tags.\n    *\/\n    c = *s++; len--;\n    if (len < 0) return -1;\n    dataset = (unsigned char) c;\n    c = *s++; len--;\n    if (len < 0) return -1;\n    recnum = (unsigned char) c;\n    \/* try to match this record to one of the ones in our named table *\/\n    for (i=0; i< tagcount; i++)\n      if (tags[i].id == (short) recnum)\n        break;\n    if (i < tagcount)\n      readable=(unsigned char *) tags[i].name;\n    else\n      readable=(unsigned char *) \"\";\n    \/*\n      We decode the length of the block that follows - ssize_t or short fmt.\n    *\/\n    c=(*s++);\n    len--;\n    if (len < 0)\n      return(-1);\n    if (c & (unsigned char) 0x80)\n      return(0);\n    else\n      {\n        s--;\n        len++;\n        taglen=readWordFromBuffer(&s, &len);\n      }\n    if (taglen < 0)\n      return(-1);\n    if (taglen > 65535)\n      return(-1);\n    \/* make a buffer to hold the tag datand snag it from the input stream *\/\n    str=(unsigned char *) AcquireQuantumMemory((size_t) (taglen+MaxTextExtent),\n      sizeof(*str));\n    if (str == (unsigned char *) NULL)\n      return 0;\n    for (tagindx=0; tagindx<taglen; tagindx++)\n    {\n      c = *s++; len--;\n      if (len < 0)\n        return(-1);\n      str[tagindx]=(unsigned char) c;\n    }\n    str[taglen]=0;\n\n    \/* now finish up by formatting this binary data into ASCII equivalent *\/\n    if (strlen((char *)readable) > 0)\n      (void) FormatLocaleString(temp,MaxTextExtent,\"%d#%d#%s=\",\n        (unsigned int) dataset,(unsigned int) recnum, readable);\n    else\n      (void) FormatLocaleString(temp,MaxTextExtent,\"%d#%d=\",\n        (unsigned int) dataset,(unsigned int) recnum);\n    (void) WriteBlobString(ofile,temp);\n    formatString( ofile, (char *)str, taglen );\n    str=(unsigned char *) RelinquishMagickMemory(str);\n\n    tagsfound++;\n  }\n  return ((int) tagsfound);\n}","target":1,"code_token_length":755,"total_token_length":991,"max_tokens_setting":1024}
+{"idx":405352,"func":"static int xfrm_bundle_ok(struct xfrm_dst *first)\n{\n\tstruct xfrm_dst *bundle[XFRM_MAX_DEPTH];\n\tstruct dst_entry *dst = &first->u.dst;\n\tstruct xfrm_dst *xdst;\n\tint start_from, nr;\n\tu32 mtu;\n\n\tif (!dst_check(xfrm_dst_path(dst), ((struct xfrm_dst *)dst)->path_cookie) ||\n\t    (dst->dev && !netif_running(dst->dev)))\n\t\treturn 0;\n\n\tif (dst->flags & DST_XFRM_QUEUE)\n\t\treturn 1;\n\n\tstart_from = nr = 0;\n\tdo {\n\t\tstruct xfrm_dst *xdst = (struct xfrm_dst *)dst;\n\n\t\tif (dst->xfrm->km.state != XFRM_STATE_VALID)\n\t\t\treturn 0;\n\t\tif (xdst->xfrm_genid != dst->xfrm->genid)\n\t\t\treturn 0;\n\t\tif (xdst->num_pols > 0 &&\n\t\t    xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))\n\t\t\treturn 0;\n\n\t\tbundle[nr++] = xdst;\n\n\t\tmtu = dst_mtu(xfrm_dst_child(dst));\n\t\tif (xdst->child_mtu_cached != mtu) {\n\t\t\tstart_from = nr;\n\t\t\txdst->child_mtu_cached = mtu;\n\t\t}\n\n\t\tif (!dst_check(xdst->route, xdst->route_cookie))\n\t\t\treturn 0;\n\t\tmtu = dst_mtu(xdst->route);\n\t\tif (xdst->route_mtu_cached != mtu) {\n\t\t\tstart_from = nr;\n\t\t\txdst->route_mtu_cached = mtu;\n\t\t}\n\n\t\tdst = xfrm_dst_child(dst);\n\t} while (dst->xfrm);\n\n\tif (likely(!start_from))\n\t\treturn 1;\n\n\txdst = bundle[start_from - 1];\n\tmtu = xdst->child_mtu_cached;\n\twhile (start_from--) {\n\t\tdst = &xdst->u.dst;\n\n\t\tmtu = xfrm_state_mtu(dst->xfrm, mtu);\n\t\tif (mtu > xdst->route_mtu_cached)\n\t\t\tmtu = xdst->route_mtu_cached;\n\t\tdst_metric_set(dst, RTAX_MTU, mtu);\n\t\tif (!start_from)\n\t\t\tbreak;\n\n\t\txdst = bundle[start_from - 1];\n\t\txdst->child_mtu_cached = mtu;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":525,"total_token_length":761,"max_tokens_setting":1024}
+{"idx":245450,"func":"cipush(mrb_state *mrb, mrb_int push_stacks, uint8_t cci,\n       struct RClass *target_class, const struct RProc *proc, mrb_sym mid, uint8_t argc)\n{\n  struct mrb_context *c = mrb->c;\n  mrb_callinfo *ci = c->ci;\n\n  if (ci + 1 == c->ciend) {\n    ptrdiff_t size = ci - c->cibase;\n\n    if (size > MRB_CALL_LEVEL_MAX) {\n      mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));\n    }\n    c->cibase = (mrb_callinfo *)mrb_realloc(mrb, c->cibase, sizeof(mrb_callinfo)*size*2);\n    c->ci = c->cibase + size;\n    c->ciend = c->cibase + size * 2;\n  }\n  ci = ++c->ci;\n  ci->mid = mid;\n  mrb_vm_ci_proc_set(ci, proc);\n  ci->stack = ci[-1].stack + push_stacks;\n  ci->n = argc & 0xf;\n  ci->nk = (argc>>4) & 0xf;\n  ci->cci = cci;\n  ci->u.target_class = target_class;\n\n  return ci;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":326602,"func":"cleanup_pathname_fsobj(char *path, int *a_eno, struct archive_string *a_estr,\n    int flags)\n{\n\tchar *dest, *src;\n\tchar separator = '\\0';\n\n\tdest = src = path;\n\tif (*src == '\\0') {\n\t\tfsobj_error(a_eno, a_estr, ARCHIVE_ERRNO_MISC,\n\t\t    \"Invalid empty \", \"pathname\");\n\t\treturn (ARCHIVE_FAILED);\n\t}\n\n#if defined(__CYGWIN__)\n\tcleanup_pathname_win(path);\n#endif\n\t\/* Skip leading '\/'. *\/\n\tif (*src == '\/') {\n\t\tif (flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {\n\t\t\tfsobj_error(a_eno, a_estr, ARCHIVE_ERRNO_MISC,\n\t\t\t    \"Path is \", \"absolute\");\n\t\t\treturn (ARCHIVE_FAILED);\n\t\t}\n\n\t\tseparator = *src++;\n\t}\n\n\t\/* Scan the pathname one element at a time. *\/\n\tfor (;;) {\n\t\t\/* src points to first char after '\/' *\/\n\t\tif (src[0] == '\\0') {\n\t\t\tbreak;\n\t\t} else if (src[0] == '\/') {\n\t\t\t\/* Found '\/\/', ignore second one. *\/\n\t\t\tsrc++;\n\t\t\tcontinue;\n\t\t} else if (src[0] == '.') {\n\t\t\tif (src[1] == '\\0') {\n\t\t\t\t\/* Ignore trailing '.' *\/\n\t\t\t\tbreak;\n\t\t\t} else if (src[1] == '\/') {\n\t\t\t\t\/* Skip '.\/'. *\/\n\t\t\t\tsrc += 2;\n\t\t\t\tcontinue;\n\t\t\t} else if (src[1] == '.') {\n\t\t\t\tif (src[2] == '\/' || src[2] == '\\0') {\n\t\t\t\t\t\/* Conditionally warn about '..' *\/\n\t\t\t\t\tif (flags\n\t\t\t\t\t    & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {\n\t\t\t\t\t\tfsobj_error(a_eno, a_estr,\n\t\t\t\t\t\t    ARCHIVE_ERRNO_MISC,\n\t\t\t\t\t\t    \"Path contains \", \"'..'\");\n\t\t\t\t\t\treturn (ARCHIVE_FAILED);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\/*\n\t\t\t\t * Note: Under no circumstances do we\n\t\t\t\t * remove '..' elements.  In\n\t\t\t\t * particular, restoring\n\t\t\t\t * '\/foo\/..\/bar\/' should create the\n\t\t\t\t * 'foo' dir as a side-effect.\n\t\t\t\t *\/\n\t\t\t}\n\t\t}\n\n\t\t\/* Copy current element, including leading '\/'. *\/\n\t\tif (separator)\n\t\t\t*dest++ = '\/';\n\t\twhile (*src != '\\0' && *src != '\/') {\n\t\t\t*dest++ = *src++;\n\t\t}\n\n\t\tif (*src == '\\0')\n\t\t\tbreak;\n\n\t\t\/* Skip '\/' separator. *\/\n\t\tseparator = *src++;\n\t}\n\t\/*\n\t * We've just copied zero or more path elements, not including the\n\t * final '\/'.\n\t *\/\n\tif (dest == path) {\n\t\t\/*\n\t\t * Nothing got copied.  The path must have been something\n\t\t * like '.' or '\/' or '.\/' or '\/.\/.\/.\/.\/\/.\/'.\n\t\t *\/\n\t\tif (separator)\n\t\t\t*dest++ = '\/';\n\t\telse\n\t\t\t*dest++ = '.';\n\t}\n\t\/* Terminate the result. *\/\n\t*dest = '\\0';\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":670,"total_token_length":906,"max_tokens_setting":1024}
+{"idx":513287,"func":"void JOIN_TAB::cleanup()\n{\n  DBUG_ENTER(\"JOIN_TAB::cleanup\");\n  \n  DBUG_PRINT(\"enter\", (\"tab: %p  table %s.%s\",\n                       this,\n                       (table ? table->s->db.str : \"?\"),\n                       (table ? table->s->table_name.str : \"?\")));\n  delete select;\n  select= 0;\n  delete quick;\n  quick= 0;\n  if (cache)\n  {\n    cache->free();\n    cache= 0;\n  }\n  limit= 0;\n  \/\/ Free select that was created for filesort outside of create_sort_index\n  if (filesort && filesort->select && !filesort->own_select)\n    delete filesort->select;\n  delete filesort;\n  filesort= NULL;\n  \/* Skip non-existing derived tables\/views result tables *\/\n  if (table &&\n      (table->s->tmp_table != INTERNAL_TMP_TABLE || table->is_created()))\n  {\n    table->file->ha_end_keyread();\n    table->file->ha_index_or_rnd_end();\n  }\n  if (table)\n  {\n    table->file->ha_end_keyread();\n    table->file->ha_index_or_rnd_end();\n    preread_init_done= FALSE;\n    if (table->pos_in_table_list && \n        table->pos_in_table_list->jtbm_subselect)\n    {\n      if (table->pos_in_table_list->jtbm_subselect->is_jtbm_const_tab)\n      {\n        \/*\n          Set this to NULL so that cleanup_empty_jtbm_semi_joins() doesn't\n          attempt to make another free_tmp_table call.\n        *\/\n        table->pos_in_table_list->table= NULL;\n        free_tmp_table(join->thd, table);\n        table= NULL;\n      }\n      else\n      {\n        TABLE_LIST *tmp= table->pos_in_table_list;\n        end_read_record(&read_record);\n        tmp->jtbm_subselect->cleanup();\n        \/* \n          The above call freed the materializedd temptable. Set it to NULL so\n          that we don't attempt to touch it if JOIN_TAB::cleanup() is invoked\n          multiple times (it may be)\n        *\/\n        tmp->table= NULL;\n        table= NULL;\n      }\n      DBUG_VOID_RETURN;\n    }\n    \/*\n      We need to reset this for next select\n      (Tested in part_of_refkey)\n    *\/\n    table->reginfo.join_tab= 0;\n  }\n  end_read_record(&read_record);\n  explain_plan= NULL;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":544,"total_token_length":780,"max_tokens_setting":1024}
+{"idx":238478,"func":"static void scalar32_min_max_or(struct bpf_reg_state *dst_reg,\n\t\t\t\tstruct bpf_reg_state *src_reg)\n{\n\tbool src_known = tnum_subreg_is_const(src_reg->var_off);\n\tbool dst_known = tnum_subreg_is_const(dst_reg->var_off);\n\tstruct tnum var32_off = tnum_subreg(dst_reg->var_off);\n\ts32 smin_val = src_reg->s32_min_value;\n\tu32 umin_val = src_reg->u32_min_value;\n\n\tif (src_known && dst_known) {\n\t\t__mark_reg32_known(dst_reg, var32_off.value);\n\t\treturn;\n\t}\n\n\t\/* We get our maximum from the var_off, and our minimum is the\n\t * maximum of the operands' minima\n\t *\/\n\tdst_reg->u32_min_value = max(dst_reg->u32_min_value, umin_val);\n\tdst_reg->u32_max_value = var32_off.value | var32_off.mask;\n\tif (dst_reg->s32_min_value < 0 || smin_val < 0) {\n\t\t\/* Lose signed bounds when ORing negative numbers,\n\t\t * ain't nobody got time for that.\n\t\t *\/\n\t\tdst_reg->s32_min_value = S32_MIN;\n\t\tdst_reg->s32_max_value = S32_MAX;\n\t} else {\n\t\t\/* ORing two positives gives a positive, so safe to\n\t\t * cast result into s64.\n\t\t *\/\n\t\tdst_reg->s32_min_value = dst_reg->u32_min_value;\n\t\tdst_reg->s32_max_value = dst_reg->u32_max_value;\n\t}\n}","target":0,"code_token_length":361,"total_token_length":597,"max_tokens_setting":1024}
+{"idx":208525,"func":"cmdline_insert_reg(int *gotesc UNUSED)\n{\n    int\t\ti;\n    int\t\tc;\n\n#ifdef USE_ON_FLY_SCROLL\n    dont_scroll = TRUE;\t\/\/ disallow scrolling here\n#endif\n    putcmdline('\"', TRUE);\n    ++no_mapping;\n    ++allow_keys;\n    i = c = plain_vgetc();\t\/\/ CTRL-R <char>\n    if (i == Ctrl_O)\n\ti = Ctrl_R;\t\t\/\/ CTRL-R CTRL-O == CTRL-R CTRL-R\n    if (i == Ctrl_R)\n\tc = plain_vgetc();\t\/\/ CTRL-R CTRL-R <char>\n    extra_char = NUL;\n    --no_mapping;\n    --allow_keys;\n#ifdef FEAT_EVAL\n    \/*\n     * Insert the result of an expression.\n     * Need to save the current command line, to be able to enter\n     * a new one...\n     *\/\n    new_cmdpos = -1;\n    if (c == '=')\n    {\n\tif (ccline.cmdfirstc == '='  \/\/ can't do this recursively\n\t\t|| cmdline_star > 0) \/\/ or when typing a password\n\t{\n\t    beep_flush();\n\t    c = ESC;\n\t}\n\telse\n\t    c = get_expr_register();\n    }\n#endif\n    if (c != ESC)\t    \/\/ use ESC to cancel inserting register\n    {\n\tcmdline_paste(c, i == Ctrl_R, FALSE);\n\n#ifdef FEAT_EVAL\n\t\/\/ When there was a serious error abort getting the\n\t\/\/ command line.\n\tif (aborting())\n\t{\n\t    *gotesc = TRUE;  \/\/ will free ccline.cmdbuff after\n\t    \/\/ putting it in history\n\t    return GOTO_NORMAL_MODE;\n\t}\n#endif\n\tKeyTyped = FALSE;\t\/\/ Don't do p_wc completion.\n#ifdef FEAT_EVAL\n\tif (new_cmdpos >= 0)\n\t{\n\t    \/\/ set_cmdline_pos() was used\n\t    if (new_cmdpos > ccline.cmdlen)\n\t\tccline.cmdpos = ccline.cmdlen;\n\t    else\n\t\tccline.cmdpos = new_cmdpos;\n\t}\n#endif\n    }\n    \/\/ remove the double quote\n    redrawcmd();\n\n    \/\/ The text has been stuffed, the command line didn't change yet.\n    return CMDLINE_NOT_CHANGED;\n}","target":1,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":328836,"func":"R_API RBinJavaAttrInfo *r_bin_java_bootstrap_methods_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0;\n\tRBinJavaBootStrapMethod *bsm = NULL;\n\tut64 offset = 0;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_BOOTSTRAP_METHODS_ATTR;\n\t\tif (offset + 8 > sz)  {\n\t\t\tfree (attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tattr->info.bootstrap_methods_attr.num_bootstrap_methods = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tattr->info.bootstrap_methods_attr.bootstrap_methods = r_list_newf (r_bin_java_bootstrap_method_free);\n\t\tfor (i = 0; i < attr->info.bootstrap_methods_attr.num_bootstrap_methods; i++) {\n\t\t\t\/\/ bsm = r_bin_java_bootstrap_method_new (bin, bin->b->cur);\n\t\t\tif (offset >= sz) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbsm = r_bin_java_bootstrap_method_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\t\tif (bsm) {\n\t\t\t\toffset += bsm->size;\n\t\t\t\tr_list_append (attr->info.bootstrap_methods_attr.bootstrap_methods, (void *) bsm);\n\t\t\t} else {\n\t\t\t\t\/\/ TODO eprintf Failed to read the %d boot strap method.\n\t\t\t}\n\t\t}\n\t\tattr->size = offset;\n\t}\n\treturn attr;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":359617,"func":"bgp_str2route_type (int afi, const char *str)\n{\n  if (! str)\n    return 0;\n\n  if (afi == AFI_IP)\n    {\n      if (strncmp (str, \"k\", 1) == 0)\n\treturn ZEBRA_ROUTE_KERNEL;\n      else if (strncmp (str, \"c\", 1) == 0)\n\treturn ZEBRA_ROUTE_CONNECT;\n      else if (strncmp (str, \"s\", 1) == 0)\n\treturn ZEBRA_ROUTE_STATIC;\n      else if (strncmp (str, \"r\", 1) == 0)\n\treturn ZEBRA_ROUTE_RIP;\n      else if (strncmp (str, \"o\", 1) == 0)\n\treturn ZEBRA_ROUTE_OSPF;\n    }\n  if (afi == AFI_IP6)\n    {\n      if (strncmp (str, \"k\", 1) == 0)\n\treturn ZEBRA_ROUTE_KERNEL;\n      else if (strncmp (str, \"c\", 1) == 0)\n\treturn ZEBRA_ROUTE_CONNECT;\n      else if (strncmp (str, \"s\", 1) == 0)\n\treturn ZEBRA_ROUTE_STATIC;\n      else if (strncmp (str, \"r\", 1) == 0)\n\treturn ZEBRA_ROUTE_RIPNG;\n      else if (strncmp (str, \"o\", 1) == 0)\n\treturn ZEBRA_ROUTE_OSPF6;\n    }\n  return 0;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":90148,"func":"std::string Network::GetStateString() const {\n  switch (state_) {\n    case STATE_UNKNOWN:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_UNKNOWN);\n    case STATE_IDLE:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_IDLE);\n    case STATE_CARRIER:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_CARRIER);\n    case STATE_ASSOCIATION:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_ASSOCIATION);\n    case STATE_CONFIGURATION:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_CONFIGURATION);\n    case STATE_READY:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_READY);\n    case STATE_DISCONNECT:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_DISCONNECT);\n    case STATE_FAILURE:\n      return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_FAILURE);\n    case STATE_ACTIVATION_FAILURE:\n      return l10n_util::GetStringUTF8(\n          IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE);\n    default:\n      break;\n  }\n  return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED);\n}\n","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":312433,"func":"jump_to_help_window(qf_info_T *qi, int newwin, int *opened_window)\n{\n    win_T\t*wp;\n    int\t\tflags;\n\n    if (cmdmod.cmod_tab != 0 || newwin)\n\twp = NULL;\n    else\n\twp = qf_find_help_win();\n    if (wp != NULL && wp->w_buffer->b_nwindows > 0)\n\twin_enter(wp, TRUE);\n    else\n    {\n\t\/\/ Split off help window; put it at far top if no position\n\t\/\/ specified, the current window is vertically split and narrow.\n\tflags = WSP_HELP;\n\tif (cmdmod.cmod_split == 0 && curwin->w_width != Columns\n\t\t&& curwin->w_width < 80)\n\t    flags |= WSP_TOP;\n\t\/\/ If the user asks to open a new window, then copy the location list.\n\t\/\/ Otherwise, don't copy the location list.\n\tif (IS_LL_STACK(qi) && !newwin)\n\t    flags |= WSP_NEWLOC;\n\n\tif (win_split(0, flags) == FAIL)\n\t    return FAIL;\n\n\t*opened_window = TRUE;\n\n\tif (curwin->w_height < p_hh)\n\t    win_setheight((int)p_hh);\n\n\t\/\/ When using location list, the new window should use the supplied\n\t\/\/ location list. If the user asks to open a new window, then the new\n\t\/\/ window will get a copy of the location list.\n\tif (IS_LL_STACK(qi) && !newwin)\n\t    win_set_loclist(curwin, qi);\n    }\n\n    if (!p_im)\n\trestart_edit = 0;\t    \/\/ don't want insert mode in help file\n\n    return OK;\n}","target":0,"code_token_length":362,"total_token_length":598,"max_tokens_setting":1024}
+{"idx":197518,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& gradient = ctx->input(0);\n    const Tensor& input = ctx->input(1);\n    Tensor* input_backprop = nullptr;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(0, input.shape(), &input_backprop));\n    OP_REQUIRES(\n        ctx, axis_ >= -1,\n        errors::InvalidArgument(\"Axis must be at least -1. Found \", axis_));\n    OP_REQUIRES(ctx, (axis_ == -1 || axis_ < input.shape().dims()),\n                errors::InvalidArgument(\n                    \"Axis should be -1 or 0 or a positive value less than \",\n                    input.shape().dims(), \"but given axis value was \", axis_));\n\n    OP_REQUIRES(\n        ctx, input.IsSameSize(gradient),\n        errors::InvalidArgument(\"gradient and input must be the same size\"));\n    const int depth = (axis_ == -1) ? 1 : input.dim_size(axis_);\n    const Tensor& input_min_tensor = ctx->input(2);\n    OP_REQUIRES(ctx,\n                input_min_tensor.dims() == 0 || input_min_tensor.dims() == 1,\n                errors::InvalidArgument(\n                    \"Input min tensor must have dimension 1. Recieved \",\n                    input_min_tensor.dims(), \".\"));\n    const Tensor& input_max_tensor = ctx->input(3);\n    OP_REQUIRES(ctx,\n                input_max_tensor.dims() == 0 || input_max_tensor.dims() == 1,\n                errors::InvalidArgument(\n                    \"Input max tensor must have dimension 1. Recieved \",\n                    input_max_tensor.dims(), \".\"));\n    if (axis_ != -1) {\n      OP_REQUIRES(\n          ctx, input_min_tensor.dim_size(0) == depth,\n          errors::InvalidArgument(\"min has incorrect size, expected \", depth,\n                                  \" was \", input_min_tensor.dim_size(0)));\n      OP_REQUIRES(\n          ctx, input_max_tensor.dim_size(0) == depth,\n          errors::InvalidArgument(\"max has incorrect size, expected \", depth,\n                                  \" was \", input_max_tensor.dim_size(0)));\n    }\n\n    TensorShape min_max_shape(input_min_tensor.shape());\n    Tensor* input_min_backprop;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(1, min_max_shape, &input_min_backprop));\n\n    Tensor* input_max_backprop;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(2, min_max_shape, &input_max_backprop));\n\n    if (axis_ == -1) {\n      functor::QuantizeAndDequantizeOneScaleGradientFunctor<Device, T> f;\n      f(ctx->eigen_device<Device>(), gradient.template flat<T>(),\n        input.template flat<T>(), input_min_tensor.scalar<T>(),\n        input_max_tensor.scalar<T>(), input_backprop->template flat<T>(),\n        input_min_backprop->template scalar<T>(),\n        input_max_backprop->template scalar<T>());\n    } else {\n      functor::QuantizeAndDequantizePerChannelGradientFunctor<Device, T> f;\n      f(ctx->eigen_device<Device>(),\n        gradient.template flat_inner_outer_dims<T, 3>(axis_ - 1),\n        input.template flat_inner_outer_dims<T, 3>(axis_ - 1),\n        &input_min_tensor, &input_max_tensor,\n        input_backprop->template flat_inner_outer_dims<T, 3>(axis_ - 1),\n        input_min_backprop->template flat<T>(),\n        input_max_backprop->template flat<T>());\n    }\n  }","target":1,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":219958,"func":"int callback_glewlwyd_user_delete_profile (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  int ret = G_OK;\n  const char * username = json_string_value(json_object_get((json_t *)response->shared_data, \"username\"));\n  json_t * j_session, * j_cur_session;\n  char * session_uid = get_session_id(config, request);\n  size_t index;\n\n  j_session = get_current_user_for_session(config, session_uid);\n  if (check_result_value(j_session, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else if (!check_result_value(j_session, G_OK)) {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_delete_profile - Error get_current_user_for_session\");\n    response->status = 500;\n  } else {\n    json_array_foreach(json_object_get(j_session, \"session\"), index, j_cur_session) {\n      if (0 == o_strcasecmp(username, json_string_value(json_object_get(j_cur_session, \"username\")))) {\n        if (delete_user_session_from_hash(config, json_string_value(json_object_get(j_cur_session, \"username\")), NULL) != G_OK) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_delete_profile - Error delete_user_session_from_hash\");\n          response->status = 500;\n          ret = G_ERROR;\n        } else {\n          if (user_session_delete(config, session_uid, json_string_value(json_object_get(j_cur_session, \"username\"))) != G_OK) {\n            y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_delete_profile - Error user_session_delete\");\n            response->status = 500;\n            ret = G_ERROR;\n          } else {\n            y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' removed (profile)\", json_string_value(json_object_get((json_t *)response->shared_data, \"username\")));\n          }\n        }\n      }\n    }\n    json_decref(j_session);\n    if (ret == G_OK) {\n      ret = user_delete_profile(config, username);\n      if (ret == G_ERROR_UNAUTHORIZED) {\n        response->status = 403;\n      } else if (ret != G_OK) {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_user_delete_profile - Error user_delete_profile\");\n        response->status = 500;\n      }\n    }\n  }\n  o_free(session_uid);\n  \n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":246745,"func":"void PrintGeneralUsage()\n{\n\tu32 i=0;\n\tgf_sys_format_help(helpout, help_flags, \"# General Options\\n\"\n\t\t\"MP4Box is a multimedia packager, with a vast number of functionalities: conversion, splitting, hinting, dumping, DASH-ing, encryption, transcoding and others.\\n\"\n\t\t\"MP4Box provides a large set of options, classified by categories (see [-h]()). These options do not follow any particular ordering.\\n\"\n\t\t\"  \\n\"\n\t\t\"By default, MP4Box rewrites the input file. You can change this behavior by using the [-out]() option.\\n\"\n\t\t\"MP4Box stores by default the file with 0.5 second interleaving and meta-data (`moov` ...) at the beginning, making it suitable for HTTP download-and-play. This may however takes longer to store the file, use [-flat]() to change this behavior.\\n\"\n\t\t\"  \\n\"\n\t\t\"MP4Box usually generates a temporary file when creating a new IsoMedia file. The location of this temporary file is OS-dependent, and it may happen that the drive\/partition the temporary file is created on has not enough space or no write access. In such a case, you can specify a temporary file location with [-tmp]().\\n\"\n\t\t\"  \\n\"\n\t\t\"Option values:\\n\"\n\t\t\"Unless specified otherwise, an option of type `integer` expects a trackID value following it.\"\n\t\t\"An option of type `boolean` expects no following value.\"\n\t\t\"Note: Track operations identify tracks through their ID (usually referred to as tkID in the help), not their order.\\n\"\n\t\t\"  \\n\"\n\t);\n\n\n\twhile (m4b_gen_args[i].name) {\n\t\tGF_GPACArg *arg = (GF_GPACArg *) &m4b_gen_args[i];\n\t\ti++;\n\t\tgf_sys_print_arg(helpout, help_flags, arg, \"mp4box-gen\");\n\t}\n}","target":0,"code_token_length":432,"total_token_length":668,"max_tokens_setting":1024}
+{"idx":195668,"func":"gen_values(codegen_scope *s, node *t, int val, int limit)\n{\n  int n = 0;\n  int first = 1;\n  int slimit = GEN_VAL_STACK_MAX;\n\n  if (limit == 0) limit = GEN_LIT_ARY_MAX;\n  if (cursp() >= slimit) slimit = INT16_MAX;\n\n  if (!val) {\n    while (t) {\n      codegen(s, t->car, NOVAL);\n      n++;\n      t = t->cdr;\n    }\n    return n;\n  }\n\n  while (t) {\n    int is_splat = nint(t->car->car) == NODE_SPLAT;\n\n    if (is_splat || n > limit || cursp() >= slimit) { \/* flush stack *\/\n      pop_n(n);\n      if (first) {\n        if (n == 0) {\n          genop_1(s, OP_LOADNIL, cursp());\n        }\n        else {\n          genop_2(s, OP_ARRAY, cursp(), n);\n        }\n        push();\n        first = 0;\n        limit = GEN_LIT_ARY_MAX;\n      }\n      else if (n > 0) {\n        pop();\n        genop_2(s, OP_ARYPUSH, cursp(), n);\n        push();\n      }\n      n = 0;\n    }\n    codegen(s, t->car, val);\n    if (is_splat) {\n      pop(); pop();\n      genop_1(s, OP_ARYCAT, cursp());\n      push();\n    }\n    else {\n      n++;\n    }\n    t = t->cdr;\n  }\n  if (!first) {\n    pop();\n    if (n > 0) {\n      pop_n(n);\n      genop_2(s, OP_ARYPUSH, cursp(), n);\n    }\n    return -1;                  \/* variable length *\/\n  }\n  return n;\n}","target":1,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":226102,"func":"\nvoid sgpd_del_entry(u32 grouping_type, void *entry)\n{\n\tswitch (grouping_type) {\n\tcase GF_ISOM_SAMPLE_GROUP_SYNC:\n\tcase GF_ISOM_SAMPLE_GROUP_ROLL:\n\tcase GF_ISOM_SAMPLE_GROUP_PROL:\n\tcase GF_ISOM_SAMPLE_GROUP_RAP:\n\tcase GF_ISOM_SAMPLE_GROUP_TELE:\n\tcase GF_ISOM_SAMPLE_GROUP_SAP:\n\t\tgf_free(entry);\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_SEIG:\n\t{\n\t\tGF_CENCSampleEncryptionGroupEntry *seig = (GF_CENCSampleEncryptionGroupEntry *)entry;\n\t\tif (seig->key_info) gf_free(seig->key_info);\n\t\tgf_free(entry);\n\t}\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_OINF:\n\t\tgf_isom_oinf_del_entry(entry);\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_LINF:\n\t\tgf_isom_linf_del_entry(entry);\n\t\treturn;\n\tcase GF_ISOM_SAMPLE_GROUP_SPOR:\n\t{\n\t\tGF_SubpictureOrderEntry *spor = (GF_SubpictureOrderEntry *)entry;\n\t\tif (spor->subp_track_ref_idx) gf_free(spor->subp_track_ref_idx);\n\t\tgf_free(spor);\n\t}\n\t\treturn;\n\n\tcase GF_ISOM_SAMPLE_GROUP_SULM:\n\t{\n\t\tGF_SubpictureLayoutMapEntry *sulm = (GF_SubpictureLayoutMapEntry *) entry;\n\t\tif (sulm->groupIDs) gf_free(sulm->groupIDs);\n\t\tgf_free(sulm);\n\t\treturn;\n\t}\n\n\tdefault:\n\t{\n\t\tGF_DefaultSampleGroupDescriptionEntry *ptr = (GF_DefaultSampleGroupDescriptionEntry *)entry;\n\t\tif (ptr->data) gf_free(ptr->data);\n\t\tgf_free(ptr);\n\t}\n\t}","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":261886,"func":"njs_string_prototype_to_lower_case(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    size_t             size, length;\n    u_char             *p;\n    uint32_t           code;\n    njs_int_t          ret;\n    const u_char       *s, *end;\n    njs_string_prop_t  string;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    (void) njs_string_prop(&string, njs_argument(args, 0));\n\n    if (njs_is_byte_or_ascii_string(&string)) {\n\n        p = njs_string_alloc(vm, &vm->retval, string.size, string.length);\n        if (njs_slow_path(p == NULL)) {\n            return NJS_ERROR;\n        }\n\n        s = string.start;\n        size = string.size;\n\n        while (size != 0) {\n            *p++ = njs_lower_case(*s++);\n            size--;\n        }\n\n    } else {\n        \/* UTF-8 string. *\/\n        s = string.start;\n        end = s + string.size;\n        length = string.length;\n\n        size = 0;\n\n        while (length != 0) {\n            code = njs_utf8_lower_case(&s, end);\n            size += njs_utf8_size(code);\n            length--;\n        }\n\n        p = njs_string_alloc(vm, &vm->retval, size, string.length);\n        if (njs_slow_path(p == NULL)) {\n            return NJS_ERROR;\n        }\n\n        s = string.start;\n        length = string.length;\n\n        while (length != 0) {\n            code = njs_utf8_lower_case(&s, end);\n            p = njs_utf8_encode(p, code);\n            length--;\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":412,"total_token_length":648,"max_tokens_setting":1024}
+{"idx":424979,"func":"static u32 iwl_trans_pcie_dump_rbs(struct iwl_trans *trans,\n\t\t\t\t   struct iwl_fw_error_dump_data **data,\n\t\t\t\t   int allocated_rb_nums)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tint max_len = PAGE_SIZE << trans_pcie->rx_page_order;\n\t\/* Dump RBs is supported only for pre-9000 devices (1 queue) *\/\n\tstruct iwl_rxq *rxq = &trans_pcie->rxq[0];\n\tu32 i, r, j, rb_len = 0;\n\n\tspin_lock(&rxq->lock);\n\n\tr = le16_to_cpu(iwl_get_closed_rb_stts(trans, rxq)) & 0x0FFF;\n\n\tfor (i = rxq->read, j = 0;\n\t     i != r && j < allocated_rb_nums;\n\t     i = (i + 1) & RX_QUEUE_MASK, j++) {\n\t\tstruct iwl_rx_mem_buffer *rxb = rxq->queue[i];\n\t\tstruct iwl_fw_error_dump_rb *rb;\n\n\t\tdma_unmap_page(trans->dev, rxb->page_dma, max_len,\n\t\t\t       DMA_FROM_DEVICE);\n\n\t\trb_len += sizeof(**data) + sizeof(*rb) + max_len;\n\n\t\t(*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RB);\n\t\t(*data)->len = cpu_to_le32(sizeof(*rb) + max_len);\n\t\trb = (void *)(*data)->data;\n\t\trb->index = cpu_to_le32(i);\n\t\tmemcpy(rb->data, page_address(rxb->page), max_len);\n\t\t\/* remap the page for the free benefit *\/\n\t\trxb->page_dma = dma_map_page(trans->dev, rxb->page, 0,\n\t\t\t\t\t\t     max_len,\n\t\t\t\t\t\t     DMA_FROM_DEVICE);\n\n\t\t*data = iwl_fw_error_next_data(*data);\n\t}\n\n\tspin_unlock(&rxq->lock);\n\n\treturn rb_len;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":253982,"func":"static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)\n{\n\tenum v4l2_buf_type type;\n\tint index;\n\tstruct v4l2_loopback_device *dev;\n\tstruct v4l2_loopback_opener *opener;\n\n\tMARK();\n\n\ttype = b->type;\n\tindex = b->index;\n\tdev = v4l2loopback_getdevice(file);\n\topener = file->private_data;\n\n\tif ((b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&\n\t\t\t(b->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)) {\n\t\treturn -EINVAL;\n\t}\n\tif (b->index > max_buffers)\n\t\treturn -EINVAL;\n\n\tif (opener->timeout_image_io)\n\t\t*b = dev->timeout_image_buffer.buffer;\n\telse\n\t\t*b = dev->buffers[b->index % dev->used_buffers].buffer;\n\n\tb->type = type;\n\tb->index = index;\n\tdprintkrw(\"buffer type: %d (of %d with size=%ld)\\n\", b->memory, dev->buffers_number, dev->buffer_size);\n\n\t\/*  Hopefully fix 'DQBUF return bad index if queue bigger then 2 for capture'\n\t\thttps:\/\/github.com\/umlaeute\/v4l2loopback\/issues\/60 *\/\n\tb->flags &= ~V4L2_BUF_FLAG_DONE;\n\tb->flags |= V4L2_BUF_FLAG_QUEUED;\n\n\treturn 0;\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":269500,"func":"static tmsize_t TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,ssize_t row,\n  tsample_t sample,Image *image)\n{\n  ssize_t\n    i;\n\n  tmsize_t\n    status;\n\n  size_t\n    number_tiles,\n    tile_width;\n\n  ssize_t\n    bytes_per_pixel,\n    j,\n    k,\n    l;\n\n  unsigned char\n    *p,\n    *q;\n\n  if (TIFFIsTiled(tiff) == 0)\n    return(TIFFWriteScanline(tiff,tiff_info->scanline,(uint32) row,sample));\n  \/*\n    Fill scanlines to tile height.\n  *\/\n  i=(ssize_t) (row % tiff_info->tile_geometry.height)*TIFFScanlineSize(tiff);\n  (void) memcpy(tiff_info->scanlines+i,(char *) tiff_info->scanline,\n    (size_t) TIFFScanlineSize(tiff));\n  if (((size_t) (row % tiff_info->tile_geometry.height) !=\n      (tiff_info->tile_geometry.height-1)) &&\n      (row != (ssize_t) (image->rows-1)))\n    return(0);\n  \/*\n    Write tile to TIFF image.\n  *\/\n  status=0;\n  bytes_per_pixel=TIFFTileSize(tiff)\/(ssize_t) (\n    tiff_info->tile_geometry.height*tiff_info->tile_geometry.width);\n  number_tiles=(image->columns+tiff_info->tile_geometry.width)\/\n    tiff_info->tile_geometry.width;\n  for (i=0; i < (ssize_t) number_tiles; i++)\n  {\n    tile_width=(i == (ssize_t) (number_tiles-1)) ? image->columns-(i*\n      tiff_info->tile_geometry.width) : tiff_info->tile_geometry.width;\n    for (j=0; j < (ssize_t) ((row % tiff_info->tile_geometry.height)+1); j++)\n      for (k=0; k < (ssize_t) tile_width; k++)\n      {\n        if (bytes_per_pixel == 0)\n          {\n            p=tiff_info->scanlines+(j*TIFFScanlineSize(tiff)+(i*\n              tiff_info->tile_geometry.width+k)\/8);\n            q=tiff_info->pixels+(j*TIFFTileRowSize(tiff)+k\/8);\n            *q++=(*p++);\n            continue;\n          }\n        p=tiff_info->scanlines+(j*TIFFScanlineSize(tiff)+(i*\n          tiff_info->tile_geometry.width+k)*bytes_per_pixel);\n        q=tiff_info->pixels+(j*TIFFTileRowSize(tiff)+k*bytes_per_pixel);\n        for (l=0; l < bytes_per_pixel; l++)\n          *q++=(*p++);\n      }\n    if ((i*tiff_info->tile_geometry.width) != image->columns)\n      status=TIFFWriteTile(tiff,tiff_info->pixels,(uint32) (i*\n        tiff_info->tile_geometry.width),(uint32) ((row\/\n        tiff_info->tile_geometry.height)*tiff_info->tile_geometry.height),0,\n        sample);\n    if (status < 0)\n      break;\n  }\n  return(status);\n}","target":0,"code_token_length":696,"total_token_length":932,"max_tokens_setting":1024}
+{"idx":232840,"func":"  void Compute(OpKernelContext* context) override {\n    core::RefCountPtr<QuantileStreamResource> streams_resource;\n    \/\/ Create a reference to the underlying resource using the handle.\n    OP_REQUIRES_OK(context, LookupResource(context, HandleFromInput(context, 0),\n                                           &streams_resource));\n    \/\/ Remove the reference at the end of this scope.\n    mutex_lock l(*streams_resource->mutex());\n\n    OpInputList bucket_boundaries_list;\n    OP_REQUIRES_OK(context, context->input_list(kBucketBoundariesName,\n                                                &bucket_boundaries_list));\n\n    auto do_quantile_deserialize = [&](const int64_t begin, const int64_t end) {\n      \/\/ Iterating over all streams.\n      for (int64_t stream_idx = begin; stream_idx < end; stream_idx++) {\n        const Tensor& bucket_boundaries_t = bucket_boundaries_list[stream_idx];\n        const auto& bucket_boundaries = bucket_boundaries_t.vec<float>();\n        std::vector<float> result;\n        result.reserve(bucket_boundaries.size());\n        for (size_t i = 0; i < bucket_boundaries.size(); ++i) {\n          result.push_back(bucket_boundaries(i));\n        }\n        streams_resource->set_boundaries(result, stream_idx);\n      }\n    };\n\n    \/\/ TODO(tanzheny): comment on the magic number.\n    const int64_t kCostPerUnit = 500 * num_features_;\n    const DeviceBase::CpuWorkerThreads& worker_threads =\n        *context->device()->tensorflow_cpu_worker_threads();\n    Shard(worker_threads.num_threads, worker_threads.workers, num_features_,\n          kCostPerUnit, do_quantile_deserialize);\n  }","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":225766,"func":"\nGF_Err xtra_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_XtraBox *ptr = (GF_XtraBox *)s;\n\twhile (ptr->size) {\n\t\tGF_XtraTag *tag;\n\t\tu32 prop_type = 0;\n\n\t\tchar *data=NULL, *data2=NULL;\n\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, 8)\n\t\ts32 tag_size = gf_bs_read_u32(bs);\n\t\tu32 name_size = gf_bs_read_u32(bs);\n\t\tif (tag_size < 8) return GF_ISOM_INVALID_FILE;\n\n\t\ttag_size -= 8;\n\t\tif ((tag_size>ptr->size) || (name_size>ptr->size)) {\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, 10)\n\n\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, name_size)\n\t\tdata = gf_malloc(sizeof(char) * (name_size+1));\n\t\tgf_bs_read_data(bs, data, name_size);\n\t\tdata[name_size] = 0;\n\t\ttag_size-=name_size;\n\n\t\tu32 flags = gf_bs_read_u32(bs);\n\t\tu32 prop_size = gf_bs_read_u32(bs);\n\t\ttag_size-=8;\n\n\t\tif (prop_size>4) {\n\t\t\ttag_size-=2;\n\t\t\tprop_type = gf_bs_read_u16(bs);\n\t\t\tprop_size -= 6;\n\t\t\tISOM_DECREASE_SIZE_NO_ERR(ptr, prop_size)\n\t\t\tdata2 = gf_malloc(sizeof(char) * (prop_size));\n\t\t\tgf_bs_read_data(bs, data2, prop_size);\n\t\t\ttag_size-=prop_size;\n\t\t} else {\n\t\t\tprop_size = 0;\n\t\t}\n\t\tGF_SAFEALLOC(tag, GF_XtraTag)\n\t\ttag->flags = flags;\n\t\ttag->name = data;\n\t\ttag->prop_size = prop_size;\n\t\ttag->prop_value = data2;\n\t\ttag->prop_type = prop_type;\n\t\tgf_list_add(ptr->tags, tag);\n\n\t\tif (tag_size) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[isom] invalid tag size in Xtra !\\n\"));\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":486,"total_token_length":722,"max_tokens_setting":1024}
+{"idx":234801,"func":"static struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,\n\t\t\t\t\t\t       u64 bytenr, u64 bytenr_orig)\n{\n\tstruct btrfs_super_block *disk_super;\n\tstruct page *page;\n\tvoid *p;\n\tpgoff_t index;\n\n\t\/* make sure our super fits in the device *\/\n\tif (bytenr + PAGE_SIZE >= i_size_read(bdev->bd_inode))\n\t\treturn ERR_PTR(-EINVAL);\n\n\t\/* make sure our super fits in the page *\/\n\tif (sizeof(*disk_super) > PAGE_SIZE)\n\t\treturn ERR_PTR(-EINVAL);\n\n\t\/* make sure our super doesn't straddle pages on disk *\/\n\tindex = bytenr >> PAGE_SHIFT;\n\tif ((bytenr + sizeof(*disk_super) - 1) >> PAGE_SHIFT != index)\n\t\treturn ERR_PTR(-EINVAL);\n\n\t\/* pull in the page with our super *\/\n\tpage = read_cache_page_gfp(bdev->bd_inode->i_mapping, index, GFP_KERNEL);\n\n\tif (IS_ERR(page))\n\t\treturn ERR_CAST(page);\n\n\tp = page_address(page);\n\n\t\/* align our pointer to the offset of the super block *\/\n\tdisk_super = p + offset_in_page(bytenr);\n\n\tif (btrfs_super_bytenr(disk_super) != bytenr_orig ||\n\t    btrfs_super_magic(disk_super) != BTRFS_MAGIC) {\n\t\tbtrfs_release_disk_super(p);\n\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\tif (disk_super->label[0] && disk_super->label[BTRFS_LABEL_SIZE - 1])\n\t\tdisk_super->label[BTRFS_LABEL_SIZE - 1] = 0;\n\n\treturn disk_super;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":289284,"func":"static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)\n{\n\tstruct snd_pcm_substream *substream;\n\tint err;\n\tint direct;\n\tstruct snd_pcm_hw_params *params;\n\tunsigned int formats = 0;\n\tconst struct snd_mask *format_mask;\n\tint fmt;\n\n\terr = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);\n\tif (err < 0)\n\t\treturn err;\n\tif (atomic_read(&substream->mmap_count))\n\t\tdirect = 1;\n\telse\n\t\tdirect = substream->oss.setup.direct;\n\tif (!direct)\n\t\treturn AFMT_MU_LAW | AFMT_U8 |\n\t\t       AFMT_S16_LE | AFMT_S16_BE |\n\t\t       AFMT_S8 | AFMT_U16_LE |\n\t\t       AFMT_U16_BE |\n\t\t\tAFMT_S32_LE | AFMT_S32_BE |\n\t\t\tAFMT_S24_LE | AFMT_S24_BE |\n\t\t\tAFMT_S24_PACKED;\n\tparams = kmalloc(sizeof(*params), GFP_KERNEL);\n\tif (!params)\n\t\treturn -ENOMEM;\n\t_snd_pcm_hw_params_any(params);\n\terr = snd_pcm_hw_refine(substream, params);\n\tif (err < 0)\n\t\tgoto error;\n\tformat_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);\n\tfor (fmt = 0; fmt < 32; ++fmt) {\n\t\tif (snd_mask_test(format_mask, fmt)) {\n\t\t\tint f = snd_pcm_oss_format_to((__force snd_pcm_format_t)fmt);\n\t\t\tif (f >= 0)\n\t\t\t\tformats |= f;\n\t\t}\n\t}\n\n error:\n\tkfree(params);\n\treturn err < 0 ? err : formats;\n}","target":0,"code_token_length":371,"total_token_length":607,"max_tokens_setting":1024}
+{"idx":197898,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& gradient = ctx->input(0);\n    const Tensor& input = ctx->input(1);\n    Tensor* input_backprop = nullptr;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(0, input.shape(), &input_backprop));\n\n    OP_REQUIRES(\n        ctx, input.IsSameSize(gradient),\n        errors::InvalidArgument(\"gradient and input must be the same size\"));\n    const int depth = (axis_ == -1) ? 1 : input.dim_size(axis_);\n    const Tensor& input_min_tensor = ctx->input(2);\n    OP_REQUIRES(ctx,\n                input_min_tensor.dims() == 0 || input_min_tensor.dims() == 1,\n                errors::InvalidArgument(\n                    \"Input min tensor must have dimension 1. Recieved \",\n                    input_min_tensor.dims(), \".\"));\n    const Tensor& input_max_tensor = ctx->input(3);\n    OP_REQUIRES(ctx,\n                input_max_tensor.dims() == 0 || input_max_tensor.dims() == 1,\n                errors::InvalidArgument(\n                    \"Input max tensor must have dimension 1. Recieved \",\n                    input_max_tensor.dims(), \".\"));\n    if (axis_ != -1) {\n      OP_REQUIRES(\n          ctx, input_min_tensor.dim_size(0) == depth,\n          errors::InvalidArgument(\"min has incorrect size, expected \", depth,\n                                  \" was \", input_min_tensor.dim_size(0)));\n      OP_REQUIRES(\n          ctx, input_max_tensor.dim_size(0) == depth,\n          errors::InvalidArgument(\"max has incorrect size, expected \", depth,\n                                  \" was \", input_max_tensor.dim_size(0)));\n    }\n\n    TensorShape min_max_shape(input_min_tensor.shape());\n    Tensor* input_min_backprop;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(1, min_max_shape, &input_min_backprop));\n\n    Tensor* input_max_backprop;\n    OP_REQUIRES_OK(ctx,\n                   ctx->allocate_output(2, min_max_shape, &input_max_backprop));\n\n    if (axis_ == -1) {\n      functor::QuantizeAndDequantizeOneScaleGradientFunctor<Device, T> f;\n      f(ctx->eigen_device<Device>(), gradient.template flat<T>(),\n        input.template flat<T>(), input_min_tensor.scalar<T>(),\n        input_max_tensor.scalar<T>(), input_backprop->template flat<T>(),\n        input_min_backprop->template scalar<T>(),\n        input_max_backprop->template scalar<T>());\n    } else {\n      functor::QuantizeAndDequantizePerChannelGradientFunctor<Device, T> f;\n      f(ctx->eigen_device<Device>(),\n        gradient.template flat_inner_outer_dims<T, 3>(axis_ - 1),\n        input.template flat_inner_outer_dims<T, 3>(axis_ - 1),\n        &input_min_tensor, &input_max_tensor,\n        input_backprop->template flat_inner_outer_dims<T, 3>(axis_ - 1),\n        input_min_backprop->template flat<T>(),\n        input_max_backprop->template flat<T>());\n    }\n  }","target":1,"code_token_length":659,"total_token_length":895,"max_tokens_setting":1024}
+{"idx":352964,"func":"integerIndexer(\n\tslap_mask_t use,\n\tslap_mask_t flags,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *prefix,\n\tBerVarray values,\n\tBerVarray *keysp,\n\tvoid *ctx )\n{\n\tchar ibuf[64];\n\tstruct berval itmp;\n\tBerVarray keys;\n\tber_len_t vlen;\n\tint i, rc;\n\tunsigned maxstrlen = index_intlen_strlen + INDEX_INTLEN_CHOP-1;\n\n\t\/* count the values and find max needed length *\/\n\tvlen = 0;\n\tfor( i = 0; !BER_BVISNULL( &values[i] ); i++ ) {\n\t\tif ( vlen < values[i].bv_len )\n\t\t\tvlen = values[i].bv_len;\n\t}\n\tif ( vlen > maxstrlen )\n\t\tvlen = maxstrlen;\n\n\t\/* we should have at least one value at this point *\/\n\tassert( i > 0 );\n\n\tkeys = slap_sl_malloc( sizeof( struct berval ) * (i+1), ctx );\n\tfor ( i = 0; !BER_BVISNULL( &values[i] ); i++ ) {\n\t\tkeys[i].bv_len = index_intlen;\n\t\tkeys[i].bv_val = slap_sl_malloc( index_intlen, ctx );\n\t}\n\tkeys[i].bv_len = 0;\n\tkeys[i].bv_val = NULL;\n\n\tif ( vlen > sizeof(ibuf) ) {\n\t\titmp.bv_val = slap_sl_malloc( vlen, ctx );\n\t} else {\n\t\titmp.bv_val = ibuf;\n\t}\n\titmp.bv_len = sizeof(ibuf);\n\n\tfor ( i=0; !BER_BVISNULL( &values[i] ); i++ ) {\n\t\tif ( itmp.bv_val != ibuf ) {\n\t\t\titmp.bv_len = values[i].bv_len;\n\t\t\tif ( itmp.bv_len <= sizeof(ibuf) )\n\t\t\t\titmp.bv_len = sizeof(ibuf);\n\t\t\telse if ( itmp.bv_len > maxstrlen )\n\t\t\t\titmp.bv_len = maxstrlen;\n\t\t}\n\t\trc = integerVal2Key( &values[i], &keys[i], &itmp, ctx );\n\t\tif ( rc ) {\n\t\t\tslap_sl_free( keys, ctx );\n\t\t\tgoto func_leave;\n\t\t}\n\t}\n\t*keysp = keys;\nfunc_leave:\n\tif ( itmp.bv_val != ibuf ) {\n\t\tslap_sl_free( itmp.bv_val, ctx );\n\t}\n\treturn rc;\n}","target":0,"code_token_length":528,"total_token_length":764,"max_tokens_setting":1024}
+{"idx":224539,"func":"Status BiasAddShape(shape_inference::InferenceContext* c) {\n  ShapeHandle input_shape;\n\n  \/\/ Fetch the data_format attribute, which may not exist.\n  string data_format;\n  Status s = c->GetAttr(\"data_format\", &data_format);\n\n  if (s.ok() && data_format == \"NCHW\") {\n    TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 3, &input_shape));\n  } else {\n    TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 2, &input_shape));\n  }\n\n  ShapeHandle bias_shape;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &bias_shape));\n  DimensionHandle bias_dim = c->Dim(bias_shape, 0);\n\n  \/\/ If rank unknown, return unknown shape.\n  if (!c->RankKnown(input_shape)) {\n    c->set_output(0, c->UnknownShape());\n    return Status::OK();\n  }\n\n  \/\/ Output has the same shape as the input, and matches the length of\n  \/\/ the bias in its bias dimension.\n  ShapeHandle output_shape;\n  if (s.ok() && data_format == \"NCHW\") {\n    \/\/ Merge the length of bias_shape into the third to last dimension\n    ShapeHandle first;\n    TF_RETURN_IF_ERROR(c->Subshape(input_shape, 0, 1, &first));\n\n    ShapeHandle last;\n    TF_RETURN_IF_ERROR(c->Subshape(input_shape, 2, &last));\n\n    DimensionHandle input_bias_dim = c->Dim(input_shape, 1);\n    DimensionHandle merged_bias_dim;\n    TF_RETURN_IF_ERROR(c->Merge(input_bias_dim, bias_dim, &merged_bias_dim));\n    ShapeHandle merged_bias = c->Vector(merged_bias_dim);\n\n    ShapeHandle temp;\n    TF_RETURN_IF_ERROR(c->Concatenate(first, merged_bias, &temp));\n    TF_RETURN_IF_ERROR(c->Concatenate(temp, last, &output_shape));\n  } else {\n    ShapeHandle all_but_bias;\n    TF_RETURN_IF_ERROR(c->Subshape(input_shape, 0, -1, &all_but_bias));\n\n    DimensionHandle input_bias_dim = c->Dim(input_shape, -1);\n    DimensionHandle merged_bias_dim;\n    TF_RETURN_IF_ERROR(c->Merge(input_bias_dim, bias_dim, &merged_bias_dim));\n\n    ShapeHandle merged_bias = c->Vector(merged_bias_dim);\n    TF_RETURN_IF_ERROR(\n        c->Concatenate(all_but_bias, merged_bias, &output_shape));\n  }\n\n  c->set_output(0, output_shape);\n  return Status::OK();\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":201925,"func":"*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args)\n{\n\tu32 priv_sz = sizeof(struct vidtv_s302m_ctx);\n\tstruct vidtv_s302m_ctx *ctx;\n\tstruct vidtv_encoder *e;\n\n\te = kzalloc(sizeof(*e), GFP_KERNEL);\n\tif (!e)\n\t\treturn NULL;\n\n\te->id = S302M;\n\n\tif (args.name)\n\t\te->name = kstrdup(args.name, GFP_KERNEL);\n\n\te->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ);\n\te->encoder_buf_sz = VIDTV_S302M_BUF_SZ;\n\te->encoder_buf_offset = 0;\n\n\te->sample_count = 0;\n\n\te->src_buf = (args.src_buf) ? args.src_buf : NULL;\n\te->src_buf_sz = (args.src_buf) ? args.src_buf_sz : 0;\n\te->src_buf_offset = 0;\n\n\te->is_video_encoder = false;\n\n\tctx = kzalloc(priv_sz, GFP_KERNEL);\n\tif (!ctx) {\n\t\tkfree(e);\n\t\treturn NULL;\n\t}\n\n\te->ctx = ctx;\n\tctx->last_duration = 0;\n\n\te->encode = vidtv_s302m_encode;\n\te->clear = vidtv_s302m_clear;\n\n\te->es_pid = cpu_to_be16(args.es_pid);\n\te->stream_id = cpu_to_be16(PES_PRIVATE_STREAM_1);\n\n\te->sync = args.sync;\n\te->sampling_rate_hz = S302M_SAMPLING_RATE_HZ;\n\n\te->last_sample_cb = args.last_sample_cb;\n\n\te->destroy = vidtv_s302m_encoder_destroy;\n\n\tif (args.head) {\n\t\twhile (args.head->next)\n\t\t\targs.head = args.head->next;\n\n\t\targs.head->next = e;\n\t}\n\n\te->next = NULL;\n\n\treturn e;\n}","target":1,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":437713,"func":"static int cx23888_ir_tx_s_parameters(struct v4l2_subdev *sd,\n\t\t\t\t      struct v4l2_subdev_ir_parameters *p)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tstruct cx23885_dev *dev = state->dev;\n\tstruct v4l2_subdev_ir_parameters *o = &state->tx_params;\n\tu16 txclk_divider;\n\n\tif (p->shutdown)\n\t\treturn cx23888_ir_tx_shutdown(sd);\n\n\tif (p->mode != V4L2_SUBDEV_IR_MODE_PULSE_WIDTH)\n\t\treturn -ENOSYS;\n\n\tmutex_lock(&state->tx_params_lock);\n\n\to->shutdown = p->shutdown;\n\n\to->mode = p->mode = V4L2_SUBDEV_IR_MODE_PULSE_WIDTH;\n\n\to->bytes_per_data_element = p->bytes_per_data_element\n\t\t\t\t  = sizeof(union cx23888_ir_fifo_rec);\n\n\t\/* Before we tweak the hardware, we have to disable the transmitter *\/\n\tirqenable_tx(dev, 0);\n\tcontrol_tx_enable(dev, false);\n\n\tcontrol_tx_modulation_enable(dev, p->modulation);\n\to->modulation = p->modulation;\n\n\tif (p->modulation) {\n\t\tp->carrier_freq = txclk_tx_s_carrier(dev, p->carrier_freq,\n\t\t\t\t\t\t     &txclk_divider);\n\t\to->carrier_freq = p->carrier_freq;\n\n\t\tp->duty_cycle = cduty_tx_s_duty_cycle(dev, p->duty_cycle);\n\t\to->duty_cycle = p->duty_cycle;\n\n\t\tp->max_pulse_width =\n\t\t\t(u32) pulse_width_count_to_ns(FIFO_RXTX, txclk_divider);\n\t} else {\n\t\tp->max_pulse_width =\n\t\t\t    txclk_tx_s_max_pulse_width(dev, p->max_pulse_width,\n\t\t\t\t\t\t       &txclk_divider);\n\t}\n\to->max_pulse_width = p->max_pulse_width;\n\tatomic_set(&state->txclk_divider, txclk_divider);\n\n\tp->resolution = clock_divider_to_resolution(txclk_divider);\n\to->resolution = p->resolution;\n\n\t\/* FIXME - make this dependent on resolution for better performance *\/\n\tcontrol_tx_irq_watermark(dev, TX_FIFO_HALF_EMPTY);\n\n\tcontrol_tx_polarity_invert(dev, p->invert_carrier_sense);\n\to->invert_carrier_sense = p->invert_carrier_sense;\n\n\tcontrol_tx_level_invert(dev, p->invert_level);\n\to->invert_level = p->invert_level;\n\n\to->interrupt_enable = p->interrupt_enable;\n\to->enable = p->enable;\n\tif (p->enable) {\n\t\tif (p->interrupt_enable)\n\t\t\tirqenable_tx(dev, IRQEN_TSE);\n\t\tcontrol_tx_enable(dev, p->enable);\n\t}\n\n\tmutex_unlock(&state->tx_params_lock);\n\treturn 0;\n}","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":289252,"func":"snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const char *ptr, snd_pcm_uframes_t frames, int in_kernel)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tint ret;\n\twhile (1) {\n\t\tif (runtime->status->state == SNDRV_PCM_STATE_XRUN ||\n\t\t    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {\n#ifdef OSS_DEBUG\n\t\t\tpcm_dbg(substream->pcm,\n\t\t\t\t\"pcm_oss: write: recovering from %s\\n\",\n\t\t\t\truntime->status->state == SNDRV_PCM_STATE_XRUN ?\n\t\t\t\t\"XRUN\" : \"SUSPEND\");\n#endif\n\t\t\tret = snd_pcm_oss_prepare(substream);\n\t\t\tif (ret < 0)\n\t\t\t\tbreak;\n\t\t}\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t\tret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,\n\t\t\t\t\t frames, in_kernel);\n\t\tmutex_lock(&runtime->oss.params_lock);\n\t\tif (ret != -EPIPE && ret != -ESTRPIPE)\n\t\t\tbreak;\n\t\t\/* test, if we can't store new data, because the stream *\/\n\t\t\/* has not been started *\/\n\t\tif (runtime->status->state == SNDRV_PCM_STATE_PREPARED)\n\t\t\treturn -EAGAIN;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":233811,"func":"void fmtutil_handle_iptc(deark *c, dbuf *f, i64 pos, i64 len,\n\tunsigned int flags)\n{\n\tint should_decode;\n\tint should_extract;\n\tint user_opt;\n\tint extract_fmt = 1; \/\/ 0=raw, 1=TIFF-wrapped\n\n\tif(len<1) return;\n\n\tuser_opt = de_get_ext_option_bool(c, \"extractiptc\", -1);\n\n\tif(user_opt==1 || (c->extract_level>=2 && user_opt!=0)) {\n\t\tshould_decode = 0;\n\t\tshould_extract = 1;\n\t\tif(flags&0x2) {\n\t\t\t\/\/ Avoid \"extracting\" in a way that would just recreate the exact same file.\n\t\t\textract_fmt = 0;\n\t\t}\n\t}\n\telse {\n\t\tshould_decode = 1;\n\t\tshould_extract = 0;\n\t}\n\n\tif(should_decode) {\n\t\tde_run_module_by_id_on_slice(c, \"iptc\", NULL, f, pos, len);\n\t}\n\n\tif(should_extract && extract_fmt==0) {\n\t\tdbuf_create_file_from_slice(f, pos, len, \"iptc\", NULL, DE_CREATEFLAG_IS_AUX);\n\t}\n\telse if(should_extract && extract_fmt==1) {\n\t\twrap_in_tiff(c, f, pos, len, \"Deark extracted IPTC\", 33723, \"iptctiff\",\n\t\t\tDE_CREATEFLAG_IS_AUX);\n\t}\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":445992,"func":"fr_window_file_list_drag_data_get (FrWindow         *window,\n\t\t\t\t   GdkDragContext   *context,\n\t\t\t\t   GtkSelectionData *selection_data,\n\t\t\t\t   GList            *path_list)\n{\n\tchar  *uri;\n\tGFile *destination;\n\tGFile *destination_folder;\n\n\tdebug (DEBUG_INFO, \"::DragDataGet -->\\n\");\n\n\tif (window->priv->path_clicked != NULL) {\n\t\tgtk_tree_path_free (window->priv->path_clicked);\n\t\twindow->priv->path_clicked = NULL;\n\t}\n\n\tif (window->priv->activity_ref > 0)\n\t\treturn FALSE;\n\n\tif (gtk_selection_data_get_target (selection_data) == XFR_ATOM) {\n\t\tFrClipboardData *tmp;\n\t\tchar            *data;\n\n\t\ttmp = fr_clipboard_data_new ();\n\t\ttmp->files = fr_window_get_file_list_selection (window, TRUE, NULL);\n\t\ttmp->op = FR_CLIPBOARD_OP_COPY;\n\t\ttmp->base_dir = g_strdup (fr_window_get_current_location (window));\n\n\t\tdata = get_selection_data_from_clipboard_data (window, tmp);\n\t\tgtk_selection_data_set (selection_data, XFR_ATOM, 8, (guchar *) data, strlen (data));\n\n\t\tfr_clipboard_data_unref (tmp);\n\t\tg_free (data);\n\n\t\treturn TRUE;\n\t}\n\n\tif (! nautilus_xds_dnd_is_valid_xds_context (context))\n\t\treturn FALSE;\n\n\turi = get_xds_atom_value (context);\n\tg_return_val_if_fail (uri != NULL, FALSE);\n\n\tdestination = g_file_new_for_uri (uri);\n\tdestination_folder = g_file_get_parent (destination);\n\n\tg_object_unref (destination);\n\n\t\/* check whether the extraction can be performed in the destination\n\t * folder *\/\n\n\tg_clear_error (&window->priv->drag_error);\n\n\tif (! _g_file_check_permissions (destination_folder, R_OK | W_OK)) {\n\t\tchar *display_name;\n\n\t\tdisplay_name = _g_file_get_display_basename (destination_folder);\n\t\twindow->priv->drag_error = g_error_new (FR_ERROR, 0, _(\"You don't have the right permissions to extract archives in the folder \\\"%s\\\"\"), display_name);\n\n\t\tg_free (display_name);\n\t}\n\n\tif (window->priv->drag_error == NULL) {\n\t\t_g_object_unref (window->priv->drag_destination_folder);\n\t\tg_free (window->priv->drag_base_dir);\n\t\t_g_string_list_free (window->priv->drag_file_list);\n\t\twindow->priv->drag_destination_folder = g_object_ref (destination_folder);\n\t\twindow->priv->drag_base_dir = g_strdup (fr_window_get_current_location (window));\n\t\twindow->priv->drag_file_list = fr_window_get_file_list_from_path_list (window, path_list, NULL);\n\t}\n\n\tg_object_unref (destination_folder);\n\n\t\/* sends back the response *\/\n\n\tgtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL) ? \"S\" : \"E\"), 1);\n\n\tdebug (DEBUG_INFO, \"::DragDataGet <--\\n\");\n\n\treturn TRUE;\n}","target":0,"code_token_length":646,"total_token_length":882,"max_tokens_setting":1024}
+{"idx":220843,"func":"inline int32x4x4_t MultiplyByQuantizedMultiplier4Rows(\n    int32x4x4_t input_val, int32_t quantized_multiplier, int shift) {\n  TFLITE_DCHECK(quantized_multiplier >= 0);\n\n  const int right_shift = std::min(-1, shift);\n  const int left_shift = shift - right_shift;\n\n  const int32x4_t multiplier_dup = vdupq_n_s32(quantized_multiplier);\n  const int32x4_t left_shift_dup = vdupq_n_s32(left_shift);\n  const int32x4_t right_shift_dup = vdupq_n_s32(right_shift);\n\n  int32x4x4_t result;\n  result.val[0] = vrshlq_s32(\n      vqdmulhq_s32(vshlq_s32(input_val.val[0], left_shift_dup), multiplier_dup),\n      right_shift_dup);\n\n  result.val[1] = vrshlq_s32(\n      vqdmulhq_s32(vshlq_s32(input_val.val[1], left_shift_dup), multiplier_dup),\n      right_shift_dup);\n\n  result.val[2] = vrshlq_s32(\n      vqdmulhq_s32(vshlq_s32(input_val.val[2], left_shift_dup), multiplier_dup),\n      right_shift_dup);\n\n  result.val[3] = vrshlq_s32(\n      vqdmulhq_s32(vshlq_s32(input_val.val[3], left_shift_dup), multiplier_dup),\n      right_shift_dup);\n\n  return result;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":247637,"func":"TEST_P(SslSocketTest, ClientCertificateHashVerification) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = absl::StrCat(R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      verify_certificate_hash: \")EOF\",\n                                                   TEST_SAN_URI_CERT_256_HASH, \"\\\"\");\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n               .setExpectedSerialNumber(TEST_SAN_URI_CERT_SERIAL));\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":243986,"func":"GF_Err udta_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_Err e;\n\tu32 box_type;\n\tGF_UserDataMap *map;\n\tGF_UserDataBox *ptr = (GF_UserDataBox *)s;\n\tif (!ptr) return GF_BAD_PARAM;\n\tif (!a) return GF_OK;\n\n\t\/\/detach from parent list if any\n\tgf_list_del_item(ptr->child_boxes, a);\n\n\t\/* for unknown udta boxes, we reference them by their original box type *\/\n\tbox_type = a->type;\n\tif (box_type == GF_ISOM_BOX_TYPE_UNKNOWN) {\n\t\tGF_UnknownBox* unkn = (GF_UnknownBox *)a;\n\t\tbox_type = unkn->original_4cc;\n\t}\n\n\tmap = udta_getEntry(ptr, box_type, (a->type==GF_ISOM_BOX_TYPE_UUID) ? & ((GF_UUIDBox *)a)->uuid : NULL);\n\tif (map == NULL) {\n\t\tif (is_rem) return GF_OK;\n\n\t\tmap = (GF_UserDataMap *) gf_malloc(sizeof(GF_UserDataMap));\n\t\tif (map == NULL) return GF_OUT_OF_MEM;\n\t\tmemset(map, 0, sizeof(GF_UserDataMap));\n\n\t\tmap->boxType = box_type;\n\t\tif (a->type == GF_ISOM_BOX_TYPE_UUID)\n\t\t\tmemcpy(map->uuid, ((GF_UUIDBox *)a)->uuid, 16);\n\t\tmap->boxes = gf_list_new();\n\t\tif (!map->boxes) {\n\t\t\tgf_free(map);\n\t\t\treturn GF_OUT_OF_MEM;\n\t\t}\n\t\te = gf_list_add(ptr->recordList, map);\n\t\tif (e) return e;\n\t}\n\tif (is_rem) {\n\t\tgf_list_del_item(map->boxes, a);\n\t\treturn GF_OK;\n\t}\n\treturn gf_list_add(map->boxes, a);\n}","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":254717,"func":"njs_typed_array_prop_set(njs_vm_t *vm, njs_typed_array_t *array, uint32_t index,\n    double v)\n{\n    int8_t              i8;\n    int16_t             i16;\n    int32_t             i32;\n    njs_array_buffer_t  *buffer;\n\n    buffer = array->buffer;\n    index += array->offset;\n\n    njs_assert(!buffer->object.shared);\n\n    switch (array->type) {\n    case NJS_OBJ_TYPE_UINT8_CLAMPED_ARRAY:\n        if (isnan(v) || v < 0) {\n            v = 0;\n        } else if (v > 255) {\n            v = 255;\n        }\n\n        buffer->u.u8[index] = lrint(v);\n\n        break;\n\n    case NJS_OBJ_TYPE_UINT8_ARRAY:\n    case NJS_OBJ_TYPE_INT8_ARRAY:\n        i8 = njs_number_to_int32(v);\n        buffer->u.u8[index] = i8;\n        break;\n\n    case NJS_OBJ_TYPE_UINT16_ARRAY:\n    case NJS_OBJ_TYPE_INT16_ARRAY:\n        i16 = njs_number_to_int32(v);\n        buffer->u.u16[index] = i16;\n        break;\n\n    case NJS_OBJ_TYPE_UINT32_ARRAY:\n    case NJS_OBJ_TYPE_INT32_ARRAY:\n        i32 = njs_number_to_int32(v);\n        buffer->u.u32[index] = i32;\n        break;\n\n    case NJS_OBJ_TYPE_FLOAT32_ARRAY:\n        buffer->u.f32[index] = v;\n        break;\n\n    default:\n\n        \/* NJS_OBJ_TYPE_FLOAT64_ARRAY. *\/\n\n        buffer->u.f64[index] = v;\n    }\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":508406,"func":"static void update_field_dependencies(THD *thd, Field *field, TABLE *table)\n{\n  DBUG_ENTER(\"update_field_dependencies\");\n  if (thd->mark_used_columns != MARK_COLUMNS_NONE)\n  {\n    MY_BITMAP *bitmap;\n\n    \/*\n      We always want to register the used keys, as the column bitmap may have\n      been set for all fields (for example for view).\n    *\/\n      \n    table->covering_keys.intersect(field->part_of_key);\n\n    if (field->vcol_info)\n      table->mark_virtual_col(field);\n\n    if (thd->mark_used_columns == MARK_COLUMNS_READ)\n      bitmap= table->read_set;\n    else\n      bitmap= table->write_set;\n\n    \/* \n       The test-and-set mechanism in the bitmap is not reliable during\n       multi-UPDATE statements under MARK_COLUMNS_READ mode\n       (thd->mark_used_columns == MARK_COLUMNS_READ), as this bitmap contains\n       only those columns that are used in the SET clause. I.e they are being\n       set here. See multi_update::prepare()\n    *\/\n    if (bitmap_fast_test_and_set(bitmap, field->field_index))\n    {\n      if (thd->mark_used_columns == MARK_COLUMNS_WRITE)\n      {\n        DBUG_PRINT(\"warning\", (\"Found duplicated field\"));\n        thd->dup_field= field;\n      }\n      else\n      {\n        DBUG_PRINT(\"note\", (\"Field found before\"));\n      }\n      DBUG_VOID_RETURN;\n    }\n    if (table->get_fields_in_item_tree)\n      field->flags|= GET_FIXED_FIELDS_FLAG;\n    table->used_fields++;\n  }\n  else if (table->get_fields_in_item_tree)\n    field->flags|= GET_FIXED_FIELDS_FLAG;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":366,"total_token_length":602,"max_tokens_setting":1024}
+{"idx":256445,"func":"JANET_CORE_FN(cfun_array_insert,\n              \"(array\/insert arr at & xs)\",\n              \"Insert all `xs` into array `arr` at index `at`. `at` should be an integer between \"\n              \"0 and the length of the array. A negative value for `at` will index backwards from \"\n              \"the end of the array, such that inserting at -1 appends to the array. \"\n              \"Returns the array.\") {\n    size_t chunksize, restsize;\n    janet_arity(argc, 2, -1);\n    JanetArray *array = janet_getarray(argv, 0);\n    int32_t at = janet_getinteger(argv, 1);\n    if (at < 0) {\n        at = array->count + at + 1;\n    }\n    if (at < 0 || at > array->count)\n        janet_panicf(\"insertion index %d out of range [0,%d]\", at, array->count);\n    chunksize = (argc - 2) * sizeof(Janet);\n    restsize = (array->count - at) * sizeof(Janet);\n    if (INT32_MAX - (argc - 2) < array->count) {\n        janet_panic(\"array overflow\");\n    }\n    janet_array_ensure(array, array->count + argc - 2, 2);\n    if (restsize) {\n        memmove(array->data + at + argc - 2,\n                array->data + at,\n                restsize);\n    }\n    safe_memcpy(array->data + at, argv + 2, chunksize);\n    array->count += (argc - 2);\n    return argv[0];\n}","target":0,"code_token_length":365,"total_token_length":601,"max_tokens_setting":1024}
+{"idx":241050,"func":"static int query_get_string_answer(cmd_request_t cmd)\n{\n\tstruct booth_site *site;\n\tstruct boothc_hdr_msg reply;\n\tstruct boothc_header *header;\n\tchar *data;\n\tint data_len;\n\tint rv;\n\tstruct booth_transport const *tpt;\n\tint (*test_reply_f) (cmd_result_t reply_code, cmd_request_t cmd);\n\tsize_t msg_size;\n\tvoid *request;\n\n\tif (cl.type == GEOSTORE) {\n\t\ttest_reply_f = test_attr_reply;\n\t\tmsg_size = sizeof(cl.attr_msg);\n\t\trequest = &cl.attr_msg;\n\t} else {\n\t\ttest_reply_f = test_reply;\n\t\tmsg_size = sizeof(cl.msg);\n\t\trequest = &cl.msg;\n\t}\n\theader = (struct boothc_header *)request;\n\tdata = NULL;\n\n\tinit_header(header, cmd, 0, cl.options, 0, 0, msg_size);\n\n\tif (!*cl.site)\n\t\tsite = local;\n\telse if (!find_site_by_name(cl.site, &site, 1)) {\n\t\tlog_error(\"cannot find site \\\"%s\\\"\", cl.site);\n\t\trv = ENOENT;\n\t\tgoto out;\n\t}\n\n\ttpt = booth_transport + TCP;\n\trv = tpt->open(site);\n\tif (rv < 0)\n\t\tgoto out_close;\n\n\trv = tpt->send(site, request, msg_size);\n\tif (rv < 0)\n\t\tgoto out_close;\n\n\trv = tpt->recv_auth(site, &reply, sizeof(reply));\n\tif (rv < 0)\n\t\tgoto out_close;\n\n\tdata_len = ntohl(reply.header.length) - rv;\n\n\t\/* no attribute, or no ticket found *\/\n\tif (!data_len) {\n\t\tgoto out_test_reply;\n\t}\n\n\tdata = malloc(data_len+1);\n\tif (!data) {\n\t\trv = -ENOMEM;\n\t\tgoto out_close;\n\t}\n\trv = tpt->recv(site, data, data_len);\n\tif (rv < 0)\n\t\tgoto out_close;\n\t*(data+data_len) = '\\0';\n\n\t*(data + data_len) = '\\0';\n\t(void)fputs(data, stdout);\n\tfflush(stdout);\n\trv = 0;\n\nout_test_reply:\n\trv = test_reply_f(ntohl(reply.header.result), cmd);\nout_close:\n\ttpt->close(site);\nout:\n\tif (data)\n\t\tfree(data);\n\treturn rv;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":247358,"func":"static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen,\n\t\t     pgpDigParams _digp)\n{\n    uint8_t version = 0;\n    const uint8_t * p = NULL;\n    int rc = 1;\n\n    if (pgpVersion(h, hlen, &version))\n\treturn rc;\n\n    \/* We only permit V4 keys, V3 keys are long long since deprecated *\/\n    switch (version) {\n    case 4:\n    {   pgpPktKeyV4 v = (pgpPktKeyV4)h;\n\n\tif (hlen > sizeof(*v)) {\n\t    pgpPrtVal(\"V4 \", pgpTagTbl, tag);\n\t    pgpPrtVal(\" \", pgpPubkeyTbl, v->pubkey_algo);\n\t    pgpPrtTime(\" \", v->time, sizeof(v->time));\n\t    pgpPrtNL();\n\n\t    \/* If _digp->hash is not NULL then signature is already loaded *\/\n\t    if (_digp->hash == NULL) {\n\t\t_digp->version = v->version;\n\t\t_digp->time = pgpGrab(v->time, sizeof(v->time));\n\t\t_digp->pubkey_algo = v->pubkey_algo;\n\t    }\n\n\t    p = ((uint8_t *)v) + sizeof(*v);\n\t    rc = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen, _digp);\n\t}\n    }\tbreak;\n    default:\n\trpmlog(RPMLOG_WARNING, _(\"Unsupported version of key: V%d\\n\"), h[0]);\n    }\n    return rc;\n}","target":0,"code_token_length":357,"total_token_length":593,"max_tokens_setting":1024}
+{"idx":244225,"func":"GF_Err vwid_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_ViewIdentifierBox *ptr = (GF_ViewIdentifierBox *) s;\n\tISOM_DECREASE_SIZE(s, 3)\n\tgf_bs_read_int(bs, 2);\n\tptr->min_temporal_id = gf_bs_read_int(bs, 3);\n\tptr->max_temporal_id = gf_bs_read_int(bs, 3);\n\tptr->num_views = gf_bs_read_u16(bs);\n\tif (ptr->num_views > ptr->size \/ 6)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tptr->views = gf_malloc(sizeof(ViewIDEntry)*ptr->num_views);\n\tmemset(ptr->views, 0, sizeof(ViewIDEntry)*ptr->num_views);\n\tfor (i=0; i<ptr->num_views; i++) {\n\t\tu32 j;\n\t\tISOM_DECREASE_SIZE(s, 6)\n\n\t\tgf_bs_read_int(bs, 6);\n\t\tptr->views[i].view_id = gf_bs_read_int(bs, 10);\n\t\tgf_bs_read_int(bs, 6);\n\t\tptr->views[i].view_order_index = gf_bs_read_int(bs, 10);\n\t\tptr->views[i].texture_in_stream = gf_bs_read_int(bs, 1);\n\t\tptr->views[i].texture_in_track = gf_bs_read_int(bs, 1);\n\t\tptr->views[i].depth_in_stream = gf_bs_read_int(bs, 1);\n\t\tptr->views[i].depth_in_track = gf_bs_read_int(bs, 1);\n\t\tptr->views[i].base_view_type = gf_bs_read_int(bs, 2);\n\t\tptr->views[i].num_ref_views = gf_bs_read_int(bs, 10);\n\n\t\tif (ptr->views[i].num_ref_views > ptr->size \/ 2)\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\n\t\tptr->views[i].view_refs = gf_malloc(sizeof(ViewIDRefViewEntry)*ptr->views[i].num_ref_views);\n\t\tfor (j=0; j<ptr->views[i].num_ref_views; j++) {\n\t\t\tISOM_DECREASE_SIZE(s, 2)\n\t\t\tgf_bs_read_int(bs, 4);\n\t\t\tptr->views[i].view_refs[j].dep_comp_idc = gf_bs_read_int(bs, 2);\n\t\t\tptr->views[i].view_refs[j].ref_view_id = gf_bs_read_int(bs, 10);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":529,"total_token_length":765,"max_tokens_setting":1024}
+{"idx":309930,"func":"NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx\n\t\t\t       int old_pair,\n\t\t\t       int pair,\n\t\t\t       int reverse,\n\t\t\t       NCURSES_SP_OUTC outc)\n{\n#ifdef USE_TERM_DRIVER\n    CallDriver_4(SP_PARM, td_docolor, old_pair, pair, reverse, outc);\n#else\n    int fg = COLOR_DEFAULT;\n    int bg = COLOR_DEFAULT;\n    int old_fg = -1;\n    int old_bg = -1;\n\n    if (!ValidPair(SP_PARM, pair)) {\n\treturn;\n    } else if (pair != 0) {\n\tif (set_color_pair) {\n\t    TPUTS_TRACE(\"set_color_pair\");\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_1(set_color_pair, pair),\n\t\t\t\t    1, outc);\n\t    return;\n\t} else if (SP_PARM != 0) {\n\t    if (_nc_pair_content(SP_PARM, pair, &fg, &bg) == ERR)\n\t\treturn;\n\t}\n    }\n\n    if (old_pair >= 0\n\t&& SP_PARM != 0\n\t&& _nc_pair_content(SP_PARM, old_pair, &old_fg, &old_bg) != ERR) {\n\tif ((isDefaultColor(fg) && !isDefaultColor(old_fg))\n\t    || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {\n#if NCURSES_EXT_FUNCS\n\t    \/*\n\t     * A minor optimization - but extension.  If \"AX\" is specified in\n\t     * the terminal description, treat it as screen's indicator of ECMA\n\t     * SGR 39 and SGR 49, and assume the two sequences are independent.\n\t     *\/\n\t    if (SP_PARM->_has_sgr_39_49\n\t\t&& isDefaultColor(old_bg)\n\t\t&& !isDefaultColor(old_fg)) {\n\t\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx \"\\033[39m\", 1, outc);\n\t    } else if (SP_PARM->_has_sgr_39_49\n\t\t       && isDefaultColor(old_fg)\n\t\t       && !isDefaultColor(old_bg)) {\n\t\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx \"\\033[49m\", 1, outc);\n\t    } else\n#endif\n\t\treset_color_pair(NCURSES_SP_ARG);\n\t}\n    } else {\n\treset_color_pair(NCURSES_SP_ARG);\n\tif (old_pair < 0 && pair <= 0)\n\t    return;\n    }\n\n#if NCURSES_EXT_FUNCS\n    if (isDefaultColor(fg))\n\tfg = default_fg(NCURSES_SP_ARG);\n    if (isDefaultColor(bg))\n\tbg = default_bg(NCURSES_SP_ARG);\n#endif\n\n    if (reverse) {\n\tint xx = fg;\n\tfg = bg;\n\tbg = xx;\n    }\n\n    TR(TRACE_ATTRS, (\"setting colors: pair = %d, fg = %d, bg = %d\", pair,\n\t\t     fg, bg));\n\n    if (!isDefaultColor(fg)) {\n\tset_foreground_color(NCURSES_SP_ARGx fg, outc);\n    }\n    if (!isDefaultColor(bg)) {\n\tset_background_color(NCURSES_SP_ARGx bg, outc);\n    }\n#endif\n}","target":0,"code_token_length":714,"total_token_length":950,"max_tokens_setting":1024}
+{"idx":300800,"func":"static int tipc_getsockopt(struct socket *sock, int lvl, int opt,\n\t\t\t   char __user *ov, int __user *ol)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct tipc_service_range seq;\n\tint len, scope;\n\tu32 value;\n\tint res;\n\n\tif ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))\n\t\treturn put_user(0, ol);\n\tif (lvl != SOL_TIPC)\n\t\treturn -ENOPROTOOPT;\n\tres = get_user(len, ol);\n\tif (res)\n\t\treturn res;\n\n\tlock_sock(sk);\n\n\tswitch (opt) {\n\tcase TIPC_IMPORTANCE:\n\t\tvalue = tsk_importance(tsk);\n\t\tbreak;\n\tcase TIPC_SRC_DROPPABLE:\n\t\tvalue = tsk_unreliable(tsk);\n\t\tbreak;\n\tcase TIPC_DEST_DROPPABLE:\n\t\tvalue = tsk_unreturnable(tsk);\n\t\tbreak;\n\tcase TIPC_CONN_TIMEOUT:\n\t\tvalue = tsk->conn_timeout;\n\t\t\/* no need to set \"res\", since already 0 at this point *\/\n\t\tbreak;\n\tcase TIPC_NODE_RECVQ_DEPTH:\n\t\tvalue = 0; \/* was tipc_queue_size, now obsolete *\/\n\t\tbreak;\n\tcase TIPC_SOCK_RECVQ_DEPTH:\n\t\tvalue = skb_queue_len(&sk->sk_receive_queue);\n\t\tbreak;\n\tcase TIPC_SOCK_RECVQ_USED:\n\t\tvalue = sk_rmem_alloc_get(sk);\n\t\tbreak;\n\tcase TIPC_GROUP_JOIN:\n\t\tseq.type = 0;\n\t\tif (tsk->group)\n\t\t\ttipc_group_self(tsk->group, &seq, &scope);\n\t\tvalue = seq.type;\n\t\tbreak;\n\tdefault:\n\t\tres = -EINVAL;\n\t}\n\n\trelease_sock(sk);\n\n\tif (res)\n\t\treturn res;\t\/* \"get\" failed *\/\n\n\tif (len < sizeof(value))\n\t\treturn -EINVAL;\n\n\tif (copy_to_user(ov, &value, sizeof(value)))\n\t\treturn -EFAULT;\n\n\treturn put_user(sizeof(value), ol);\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":386482,"func":"int DL_Dxf::getLibVersion(const std::string& str) {\n    int d[4];\n    int idx = 0;\n    \/\/char v[4][5];\n    std::string v[4];\n    int ret = 0;\n\n    for (unsigned int i=0; i<str.length() && idx<3; ++i) {\n        if (str[i]=='.') {\n            d[idx] = i;\n            idx++;\n        }\n    }\n\n    if (idx>=2) {\n        d[3] = str.length();\n\n        v[0] = str.substr(0, d[0]);\n        v[1] = str.substr(d[0]+1, d[1]-d[0]-1);\n        v[2] = str.substr(d[1]+1, d[2]-d[1]-1);\n        if (idx>=3) {\n            v[3] = str.substr(d[2]+1, d[3]-d[2]-1);\n        }\n        else {\n            v[3] = \"0\";\n        }\n\n        ret = (atoi(v[0].c_str())<<(3*8)) +\n              (atoi(v[1].c_str())<<(2*8)) +\n              (atoi(v[2].c_str())<<(1*8)) +\n              (atoi(v[3].c_str())<<(0*8));\n\n        return ret;\n    } else {\n        std::cerr << \"DL_Dxf::getLibVersion: invalid version number: \" << str << \"\\n\";\n        return 0;\n    }\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":221178,"func":"GF_Err gf_odf_encode_ui_config(GF_UIConfig *cfg, GF_DefaultDescriptor **out_dsi)\n{\n\tu32 i, len;\n\tGF_BitStream *bs;\n\tGF_DefaultDescriptor *dsi;\n\tif (!out_dsi || (cfg->tag != GF_ODF_UI_CFG_TAG)) return GF_BAD_PARAM;\n\n\t*out_dsi = NULL;\n\tif (!cfg->deviceName) return GF_OK;\n\n\tbs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\tlen = (u32) strlen(cfg->deviceName);\n\tgf_bs_write_int(bs, len, 8);\n\tfor (i=0; i<len; i++) gf_bs_write_int(bs, cfg->deviceName[i], 8);\n\tif (!stricmp(cfg->deviceName, \"StringSensor\")) {\n\t\t\/*fixme - this should be UTF-8 chars*\/\n\t\tif (cfg->delChar || cfg->termChar) {\n\t\t\tgf_bs_write_int(bs, cfg->termChar, 8);\n\t\t\tgf_bs_write_int(bs, cfg->delChar, 8);\n\t\t}\n\t}\n\tif (cfg->ui_data) gf_bs_write_data(bs, cfg->ui_data, cfg->ui_data_length);\n\n\tdsi = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG);\n\tgf_bs_get_content(bs, &dsi->data, &dsi->dataLength);\n\tgf_bs_del(bs);\n\t*out_dsi = dsi;\n\treturn GF_OK;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":247640,"func":"TEST_P(SslSocketTest, FailedClientCertificateHashAndSpkiVerificationNoCAWrongClientCertificate) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains();\n  envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert =\n      tls_context.mutable_common_tls_context()->add_tls_certificates();\n  server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"));\n  server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"));\n  envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext*\n      server_validation_ctx =\n          tls_context.mutable_common_tls_context()->mutable_validation_context();\n  server_validation_ctx->add_verify_certificate_hash(\n      \"0000000000000000000000000000000000000000000000000000000000000000\");\n  server_validation_ctx->add_verify_certificate_spki(TEST_SAN_URI_CERT_SPKI);\n  updateFilterChain(tls_context, *filter_chain);\n\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n  envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert =\n      client.mutable_common_tls_context()->add_tls_certificates();\n  client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"));\n  client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute(\n      \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"));\n\n  TestUtilOptionsV2 test_options(listener, client, false, GetParam());\n  testUtilV2(test_options.setExpectedServerStats(\"ssl.fail_verify_cert_hash\")\n                 .setExpectedTransportFailureReasonContains(\"SSLV3_ALERT_CERTIFICATE_UNKNOWN\"));\n\n  \/\/ Fails even with client renegotiation.\n  client.set_allow_renegotiation(true);\n  testUtilV2(test_options);\n}","target":0,"code_token_length":543,"total_token_length":779,"max_tokens_setting":1024}
+{"idx":216973,"func":"create_worker_threads(uint n)\n{\n\tcomp_thread_ctxt_t\t*threads;\n\tuint \t\t\ti;\n\n\tthreads = (comp_thread_ctxt_t *)\n\t\tmy_malloc(sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE));\n\n\tfor (i = 0; i < n; i++) {\n\t\tcomp_thread_ctxt_t *thd = threads + i;\n\n\t\tthd->num = i + 1;\n\t\tthd->started = FALSE;\n\t\tthd->cancelled = FALSE;\n\t\tthd->data_avail = FALSE;\n\n\t\tthd->to = (char *) my_malloc(COMPRESS_CHUNK_SIZE +\n\t\t\t\t\t\t   MY_QLZ_COMPRESS_OVERHEAD,\n\t\t\t\t\t\t   MYF(MY_FAE));\n\n\t\t\/* Initialize the control mutex and condition var *\/\n\t\tif (pthread_mutex_init(&thd->ctrl_mutex, NULL) ||\n\t\t    pthread_cond_init(&thd->ctrl_cond, NULL)) {\n\t\t\tgoto err;\n\t\t}\n\n\t\t\/* Initialize and data mutex and condition var *\/\n\t\tif (pthread_mutex_init(&thd->data_mutex, NULL) ||\n\t\t    pthread_cond_init(&thd->data_cond, NULL)) {\n\t\t\tgoto err;\n\t\t}\n\n\t\tpthread_mutex_lock(&thd->ctrl_mutex);\n\n\t\tif (pthread_create(&thd->id, NULL, compress_worker_thread_func,\n\t\t\t\t   thd)) {\n\t\t\tmsg(\"compress: pthread_create() failed: \"\n\t\t\t    \"errno = %d\", errno);\n\t\t\tgoto err;\n\t\t}\n\t}\n\n\t\/* Wait for the threads to start *\/\n\tfor (i = 0; i < n; i++) {\n\t\tcomp_thread_ctxt_t *thd = threads + i;\n\n\t\twhile (thd->started == FALSE)\n\t\t\tpthread_cond_wait(&thd->ctrl_cond, &thd->ctrl_mutex);\n\t\tpthread_mutex_unlock(&thd->ctrl_mutex);\n\t}\n\n\treturn threads;\n\nerr:\n\tmy_free(threads);\n\treturn NULL;\n}","target":1,"code_token_length":398,"total_token_length":634,"max_tokens_setting":1024}
+{"idx":436080,"func":"static int io_close(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct files_struct *files = current->files;\n\tstruct io_close *close = &req->close;\n\tstruct fdtable *fdt;\n\tstruct file *file = NULL;\n\tint ret = -EBADF;\n\n\tspin_lock(&files->file_lock);\n\tfdt = files_fdtable(files);\n\tif (close->fd >= fdt->max_fds) {\n\t\tspin_unlock(&files->file_lock);\n\t\tgoto err;\n\t}\n\tfile = fdt->fd[close->fd];\n\tif (!file || file->f_op == &io_uring_fops) {\n\t\tspin_unlock(&files->file_lock);\n\t\tfile = NULL;\n\t\tgoto err;\n\t}\n\n\t\/* if the file has a flush method, be safe and punt to async *\/\n\tif (file->f_op->flush && (issue_flags & IO_URING_F_NONBLOCK)) {\n\t\tspin_unlock(&files->file_lock);\n\t\treturn -EAGAIN;\n\t}\n\n\tret = __close_fd_get_file(close->fd, &file);\n\tspin_unlock(&files->file_lock);\n\tif (ret < 0) {\n\t\tif (ret == -ENOENT)\n\t\t\tret = -EBADF;\n\t\tgoto err;\n\t}\n\n\t\/* No ->flush() or already async, safely close from here *\/\n\tret = filp_close(file, current->files);\nerr:\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tif (file)\n\t\tfput(file);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":381869,"func":"static int udf_extend_file(struct inode *inode, loff_t newsize)\n{\n\n\tstruct extent_position epos;\n\tstruct kernel_lb_addr eloc;\n\tuint32_t elen;\n\tint8_t etype;\n\tstruct super_block *sb = inode->i_sb;\n\tsector_t first_block = newsize >> sb->s_blocksize_bits, offset;\n\tunsigned long partial_final_block;\n\tint adsize;\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\tstruct kernel_long_ad extent;\n\tint err = 0;\n\tint within_final_block;\n\n\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)\n\t\tadsize = sizeof(struct short_ad);\n\telse if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)\n\t\tadsize = sizeof(struct long_ad);\n\telse\n\t\tBUG();\n\n\tetype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);\n\twithin_final_block = (etype != -1);\n\n\tif ((!epos.bh && epos.offset == udf_file_entry_alloc_offset(inode)) ||\n\t    (epos.bh && epos.offset == sizeof(struct allocExtDesc))) {\n\t\t\/* File has no extents at all or has empty last\n\t\t * indirect extent! Create a fake extent... *\/\n\t\textent.extLocation.logicalBlockNum = 0;\n\t\textent.extLocation.partitionReferenceNum = 0;\n\t\textent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;\n\t} else {\n\t\tepos.offset -= adsize;\n\t\tetype = udf_next_aext(inode, &epos, &extent.extLocation,\n\t\t\t\t      &extent.extLength, 0);\n\t\textent.extLength |= etype << 30;\n\t}\n\n\tpartial_final_block = newsize & (sb->s_blocksize - 1);\n\n\t\/* File has extent covering the new size (could happen when extending\n\t * inside a block)?\n\t *\/\n\tif (within_final_block) {\n\t\t\/* Extending file within the last file block *\/\n\t\tudf_do_extend_final_block(inode, &epos, &extent,\n\t\t\t\t\t  partial_final_block);\n\t} else {\n\t\tloff_t add = ((loff_t)offset << sb->s_blocksize_bits) |\n\t\t\t     partial_final_block;\n\t\terr = udf_do_extend_file(inode, &epos, &extent, add);\n\t}\n\n\tif (err < 0)\n\t\tgoto out;\n\terr = 0;\n\tiinfo->i_lenExtents = newsize;\nout:\n\tbrelse(epos.bh);\n\treturn err;\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":391672,"func":"static NTSTATUS fd_open_atomic(struct connection_struct *conn,\n\t\t\tfiles_struct *fsp,\n\t\t\tint flags,\n\t\t\tmode_t mode,\n\t\t\tbool *file_created)\n{\n\tNTSTATUS status = NT_STATUS_UNSUCCESSFUL;\n\tbool file_existed = VALID_STAT(fsp->fsp_name->st);\n\n\t*file_created = false;\n\n\tif (!(flags & O_CREAT)) {\n\t\t\/*\n\t\t * We're not creating the file, just pass through.\n\t\t *\/\n\t\treturn fd_open(conn, fsp, flags, mode);\n\t}\n\n\tif (flags & O_EXCL) {\n\t\t\/*\n\t\t * Fail if already exists, just pass through.\n\t\t *\/\n\t\tstatus = fd_open(conn, fsp, flags, mode);\n\n\t\t\/*\n\t\t * Here we've opened with O_CREAT|O_EXCL. If that went\n\t\t * NT_STATUS_OK, we *know* we created this file.\n\t\t *\/\n\t\t*file_created = NT_STATUS_IS_OK(status);\n\n\t\treturn status;\n\t}\n\n\t\/*\n\t * Now it gets tricky. We have O_CREAT, but not O_EXCL.\n\t * To know absolutely if we created the file or not,\n\t * we can never call O_CREAT without O_EXCL. So if\n\t * we think the file existed, try without O_CREAT|O_EXCL.\n\t * If we think the file didn't exist, try with\n\t * O_CREAT|O_EXCL. Keep bouncing between these two\n\t * requests until either the file is created, or\n\t * opened. Either way, we keep going until we get\n\t * a returnable result (error, or open\/create).\n\t *\/\n\n\twhile(1) {\n\t\tint curr_flags = flags;\n\n\t\tif (file_existed) {\n\t\t\t\/* Just try open, do not create. *\/\n\t\t\tcurr_flags &= ~(O_CREAT);\n\t\t\tstatus = fd_open(conn, fsp, curr_flags, mode);\n\t\t\tif (NT_STATUS_EQUAL(status,\n\t\t\t\t\tNT_STATUS_OBJECT_NAME_NOT_FOUND)) {\n\t\t\t\t\/*\n\t\t\t\t * Someone deleted it in the meantime.\n\t\t\t\t * Retry with O_EXCL.\n\t\t\t\t *\/\n\t\t\t\tfile_existed = false;\n\t\t\t\tDEBUG(10,(\"fd_open_atomic: file %s existed. \"\n\t\t\t\t\t\"Retry.\\n\",\n\t\t\t\t\tsmb_fname_str_dbg(fsp->fsp_name)));\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else {\n\t\t\t\/* Try create exclusively, fail if it exists. *\/\n\t\t\tcurr_flags |= O_EXCL;\n\t\t\tstatus = fd_open(conn, fsp, curr_flags, mode);\n\t\t\tif (NT_STATUS_EQUAL(status,\n\t\t\t\t\tNT_STATUS_OBJECT_NAME_COLLISION)) {\n\t\t\t\t\/*\n\t\t\t\t * Someone created it in the meantime.\n\t\t\t\t * Retry without O_CREAT.\n\t\t\t\t *\/\n\t\t\t\tfile_existed = true;\n\t\t\t\tDEBUG(10,(\"fd_open_atomic: file %s \"\n\t\t\t\t\t\"did not exist. Retry.\\n\",\n\t\t\t\t\tsmb_fname_str_dbg(fsp->fsp_name)));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (NT_STATUS_IS_OK(status)) {\n\t\t\t\t\/*\n\t\t\t\t * Here we've opened with O_CREAT|O_EXCL\n\t\t\t\t * and got success. We *know* we created\n\t\t\t\t * this file.\n\t\t\t\t *\/\n\t\t\t\t*file_created = true;\n\t\t\t}\n\t\t}\n\t\t\/* Create is done, or failed. *\/\n\t\tbreak;\n\t}\n\treturn status;\n}","target":0,"code_token_length":694,"total_token_length":930,"max_tokens_setting":1024}
+{"idx":261921,"func":"njs_string_alloc(njs_vm_t *vm, njs_value_t *value, uint64_t size,\n    uint64_t length)\n{\n    uint32_t      total, map_offset, *map;\n    njs_string_t  *string;\n\n    if (njs_slow_path(size > NJS_STRING_MAX_LENGTH)) {\n        njs_range_error(vm, \"invalid string length\");\n        return NULL;\n    }\n\n    value->type = NJS_STRING;\n    njs_string_truth(value, size);\n\n    if (size <= NJS_STRING_SHORT) {\n        value->short_string.size = size;\n        value->short_string.length = length;\n\n        return value->short_string.start;\n    }\n\n    \/*\n     * Setting UTF-8 length is not required here, it just allows\n     * to store the constant in whole byte instead of bit twiddling.\n     *\/\n    value->short_string.size = NJS_STRING_LONG;\n    value->short_string.length = 0;\n    value->long_string.external = 0;\n    value->long_string.size = size;\n\n    if (size != length && length > NJS_STRING_MAP_STRIDE) {\n        map_offset = njs_string_map_offset(size);\n        total = map_offset + njs_string_map_size(length);\n\n    } else {\n        map_offset = 0;\n        total = size;\n    }\n\n    string = njs_mp_alloc(vm->mem_pool, sizeof(njs_string_t) + total);\n\n    if (njs_fast_path(string != NULL)) {\n        value->long_string.data = string;\n\n        string->start = (u_char *) string + sizeof(njs_string_t);\n        string->length = length;\n        string->retain = 1;\n\n        if (map_offset != 0) {\n            map = (uint32_t *) (string->start + map_offset);\n            map[0] = 0;\n        }\n\n        return string->start;\n    }\n\n    njs_memory_error(vm);\n\n    return NULL;\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":325820,"func":"copy_ciphersuites(gnutls_session_t session,\n\t\t  gnutls_buffer_st * cdata, int add_scsv)\n{\n\tint ret;\n\tuint8_t cipher_suites[MAX_CIPHERSUITE_SIZE + RESERVED_CIPHERSUITES]; \/* allow space for SCSV *\/\n\tint cipher_suites_size;\n\tsize_t init_length = cdata->length;\n\n\tret =\n\t    _gnutls_supported_ciphersuites(session, cipher_suites,\n\t\t\t\t\t   sizeof(cipher_suites) - RESERVED_CIPHERSUITES);\n\tif (ret < 0)\n\t\treturn gnutls_assert_val(ret);\n\n\t\/* Here we remove any ciphersuite that does not conform\n\t * the certificate requested, or to the\n\t * authentication requested (eg SRP).\n\t *\/\n\tret =\n\t    _gnutls_remove_unwanted_ciphersuites(session, cipher_suites,\n\t\t\t\t\t\t ret, NULL, 0);\n\tif (ret < 0)\n\t\treturn gnutls_assert_val(ret);\n\n\t\/* If no cipher suites were enabled.\n\t *\/\n\tif (ret == 0)\n\t\treturn\n\t\t    gnutls_assert_val(GNUTLS_E_INSUFFICIENT_CREDENTIALS);\n\n\tcipher_suites_size = ret;\n\tif (add_scsv) {\n\t\tcipher_suites[cipher_suites_size] = 0x00;\n\t\tcipher_suites[cipher_suites_size + 1] = 0xff;\n\t\tcipher_suites_size += 2;\n\n\t\tret = _gnutls_ext_sr_send_cs(session);\n\t\tif (ret < 0)\n\t\t\treturn gnutls_assert_val(ret);\n\t}\n\n\tif (session->internals.priorities.fallback) {\n\t\tcipher_suites[cipher_suites_size] =\n\t\t\tGNUTLS_FALLBACK_SCSV_MAJOR;\n\t\tcipher_suites[cipher_suites_size + 1] =\n\t\t\tGNUTLS_FALLBACK_SCSV_MINOR;\n\t\tcipher_suites_size += 2;\n\t}\n\n\tret =\n\t    _gnutls_buffer_append_data_prefix(cdata, 16, cipher_suites,\n\t\t\t\t\t      cipher_suites_size);\n\tif (ret < 0)\n\t\treturn gnutls_assert_val(ret);\n\n\tret = cdata->length - init_length;\n\n\treturn ret;\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":265544,"func":"int mempool_releasebuffer(MemoryPoolHandle handle, void *buf,\n                          size_t released_buffer_size) {\n  struct mempool *pool = (struct mempool *)handle;\n  struct memory_pool_element *pool_item = (struct memory_pool_element *)buf;\n  char *log_msg_fmt =\n      \"mempool(%p): mempool_releasebuffer called for invalid \"\n      \"released_buffer_size(%zu), current pool manages only \"\n      \"mempool_item_size(%zu)\";\n  char log_msg[300];\n\n  if ((pool == NULL) || (pool_item == NULL)) {\n    return S3_MEMPOOL_INVALID_ARG;\n  }\n\n  if (pool->mempool_item_size != released_buffer_size) {\n    \/\/ This should never happen unless mempool is used wrongly.\n    if (pool->log_callback_func) {\n      snprintf(log_msg, sizeof(log_msg), log_msg_fmt, (void *)pool,\n               released_buffer_size, pool->mempool_item_size);\n      pool->log_callback_func(MEMPOOL_LOG_FATAL, log_msg);\n      return S3_MEMPOOL_INVALID_ARG;\n    }\n  }\n\n  if ((pool->flags & ENABLE_LOCKING) != 0) {\n    pthread_mutex_lock(&pool->lock);\n  }\n\n  \/* Clean up the buffer so that we get it 'clean' when we allocate it next\n   * time*\/\n  if ((pool->flags & ZEROED_BUFFER) != 0) {\n    memset(pool_item, 0, pool->mempool_item_size);\n  }\n\n  \/\/ Add the buffer back to pool\n  pool_item->next = pool->free_list;\n  pool->free_list = pool_item;\n  pool->free_bufs_in_pool++;\n  pool_item = NULL;\n\n  pool->number_of_bufs_shared--;\n\n  if ((pool->flags & ENABLE_LOCKING) != 0) {\n    pthread_mutex_unlock(&pool->lock);\n  }\n\n  return 0;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":369171,"func":"static void handle_prev_tw_list(struct io_wq_work_node *node,\n\t\t\t\tstruct io_ring_ctx **ctx, bool *uring_locked)\n{\n\tif (*ctx && !*uring_locked)\n\t\tspin_lock(&(*ctx)->completion_lock);\n\n\tdo {\n\t\tstruct io_wq_work_node *next = node->next;\n\t\tstruct io_kiocb *req = container_of(node, struct io_kiocb,\n\t\t\t\t\t\t    io_task_work.node);\n\n\t\tprefetch(container_of(next, struct io_kiocb, io_task_work.node));\n\n\t\tif (req->ctx != *ctx) {\n\t\t\tif (unlikely(!*uring_locked && *ctx))\n\t\t\t\tctx_commit_and_unlock(*ctx);\n\n\t\t\tctx_flush_and_put(*ctx, uring_locked);\n\t\t\t*ctx = req->ctx;\n\t\t\t\/* if not contended, grab and improve batching *\/\n\t\t\t*uring_locked = mutex_trylock(&(*ctx)->uring_lock);\n\t\t\tpercpu_ref_get(&(*ctx)->refs);\n\t\t\tif (unlikely(!*uring_locked))\n\t\t\t\tspin_lock(&(*ctx)->completion_lock);\n\t\t}\n\t\tif (likely(*uring_locked))\n\t\t\treq->io_task_work.func(req, uring_locked);\n\t\telse\n\t\t\t__io_req_complete_post(req, req->result,\n\t\t\t\t\t\tio_put_kbuf_comp(req));\n\t\tnode = next;\n\t} while (node);\n\n\tif (unlikely(!*uring_locked))\n\t\tctx_commit_and_unlock(*ctx);\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":231018,"func":"static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,\r\n                                   const UBaseType_t uxItemSize,\r\n                                   uint8_t * pucQueueStorage,\r\n                                   const uint8_t ucQueueType,\r\n                                   Queue_t * pxNewQueue )\r\n{\r\n    \/* Remove compiler warnings about unused parameters should\r\n     * configUSE_TRACE_FACILITY not be set to 1. *\/\r\n    ( void ) ucQueueType;\r\n\r\n    if( uxItemSize == ( UBaseType_t ) 0 )\r\n    {\r\n        \/* No RAM was allocated for the queue storage area, but PC head cannot\r\n         * be set to NULL because NULL is used as a key to say the queue is used as\r\n         * a mutex.  Therefore just set pcHead to point to the queue as a benign\r\n         * value that is known to be within the memory map. *\/\r\n        pxNewQueue->pcHead = ( int8_t * ) pxNewQueue;\r\n    }\r\n    else\r\n    {\r\n        \/* Set the head to the start of the queue storage area. *\/\r\n        pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage;\r\n    }\r\n\r\n    \/* Initialise the queue members as described where the queue type is\r\n     * defined. *\/\r\n    pxNewQueue->uxLength = uxQueueLength;\r\n    pxNewQueue->uxItemSize = uxItemSize;\r\n    ( void ) xQueueGenericReset( pxNewQueue, pdTRUE );\r\n\r\n    #if ( configUSE_TRACE_FACILITY == 1 )\r\n        {\r\n            pxNewQueue->ucQueueType = ucQueueType;\r\n        }\r\n    #endif \/* configUSE_TRACE_FACILITY *\/\r\n\r\n    #if ( configUSE_QUEUE_SETS == 1 )\r\n        {\r\n            pxNewQueue->pxQueueSetContainer = NULL;\r\n        }\r\n    #endif \/* configUSE_QUEUE_SETS *\/\r\n\r\n    traceQUEUE_CREATE( pxNewQueue );\r\n}\r","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":481277,"func":"static int mlx5_fpga_conn_connect(struct mlx5_fpga_conn *conn)\n{\n\tstruct mlx5_fpga_device *fdev = conn->fdev;\n\tint err;\n\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, state, MLX5_FPGA_QPC_STATE_ACTIVE);\n\terr = mlx5_fpga_modify_qp(conn->fdev->mdev, conn->fpga_qpn,\n\t\t\t\t  MLX5_FPGA_QPC_STATE, &conn->fpga_qpc);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to activate FPGA RC QP: %d\\n\", err);\n\t\tgoto out;\n\t}\n\n\terr = mlx5_fpga_conn_reset_qp(conn);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to change QP state to reset\\n\");\n\t\tgoto err_fpga_qp;\n\t}\n\n\terr = mlx5_fpga_conn_init_qp(conn);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to modify QP from RESET to INIT\\n\");\n\t\tgoto err_fpga_qp;\n\t}\n\tconn->qp.active = true;\n\n\twhile (!mlx5_fpga_conn_post_recv_buf(conn))\n\t\t;\n\n\terr = mlx5_fpga_conn_rtr_qp(conn);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to change QP state from INIT to RTR\\n\");\n\t\tgoto err_recv_bufs;\n\t}\n\n\terr = mlx5_fpga_conn_rts_qp(conn);\n\tif (err) {\n\t\tmlx5_fpga_err(fdev, \"Failed to change QP state from RTR to RTS\\n\");\n\t\tgoto err_recv_bufs;\n\t}\n\tgoto out;\n\nerr_recv_bufs:\n\tmlx5_fpga_conn_free_recv_bufs(conn);\nerr_fpga_qp:\n\tMLX5_SET(fpga_qpc, conn->fpga_qpc, state, MLX5_FPGA_QPC_STATE_INIT);\n\tif (mlx5_fpga_modify_qp(conn->fdev->mdev, conn->fpga_qpn,\n\t\t\t\tMLX5_FPGA_QPC_STATE, &conn->fpga_qpc))\n\t\tmlx5_fpga_err(fdev, \"Failed to revert FPGA QP to INIT\\n\");\nout:\n\treturn err;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":386518,"func":"void DL_Dxf::writeLayer(DL_WriterA& dw,\n                        const DL_LayerData& data,\n                        const DL_Attributes& attrib) {\n\n    if (data.name.empty()) {\n        std::cerr << \"DL_Dxf::writeLayer: \"\n        << \"Layer name must not be empty\\n\";\n        return;\n    }\n\n    int color = attrib.getColor();\n    if (color>=256) {\n        std::cerr << \"Layer color cannot be \" << color << \". Changed to 7.\\n\";\n        color = 7;\n    }\n    if (data.off) {\n        \/\/ negative color value means layer is off:\n        color = -color;\n    }\n\n    if (data.name == \"0\") {\n        dw.tableLayerEntry(0x10);\n    } else {\n        dw.tableLayerEntry();\n    }\n\n    dw.dxfString(2, data.name);\n    dw.dxfInt(70, data.flags);\n    dw.dxfInt(62, color);\n    if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) {\n        dw.dxfInt(420, attrib.getColor24());\n    }\n\n    dw.dxfString(6, (attrib.getLinetype().length()==0 ?\n                     std::string(\"CONTINUOUS\") : attrib.getLinetype()));\n\n    if (version>=DL_VERSION_2000) {\n        \/\/ layer defpoints cannot be plotted\n        std::string lstr = data.name;\n        std::transform(lstr.begin(), lstr.end(), lstr.begin(), tolower);\n        if (lstr==\"defpoints\") {\n            dw.dxfInt(290, 0);\n        }\n    }\n    if (version>=DL_VERSION_2000 && attrib.getWidth()!=-1) {\n        dw.dxfInt(370, attrib.getWidth());\n    }\n    if (version>=DL_VERSION_2000) {\n        dw.dxfHex(390, 0xF);\n    }\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":202082,"func":"R_API RBinJavaAttrInfo *r_bin_java_bootstrap_methods_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0;\n\tRBinJavaBootStrapMethod *bsm = NULL;\n\tut64 offset = 0;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_BOOTSTRAP_METHODS_ATTR;\n\t\tattr->info.bootstrap_methods_attr.num_bootstrap_methods = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tattr->info.bootstrap_methods_attr.bootstrap_methods = r_list_newf (r_bin_java_bootstrap_method_free);\n\t\tfor (i = 0; i < attr->info.bootstrap_methods_attr.num_bootstrap_methods; i++) {\n\t\t\t\/\/ bsm = r_bin_java_bootstrap_method_new (bin, bin->b->cur);\n\t\t\tif (offset >= sz) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbsm = r_bin_java_bootstrap_method_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\t\tif (bsm) {\n\t\t\t\toffset += bsm->size;\n\t\t\t\tr_list_append (attr->info.bootstrap_methods_attr.bootstrap_methods, (void *) bsm);\n\t\t\t} else {\n\t\t\t\t\/\/ TODO eprintf Failed to read the %d boot strap method.\n\t\t\t}\n\t\t}\n\t\tattr->size = offset;\n\t}\n\treturn attr;\n}","target":1,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":267921,"func":"char *ogs_nas_5gs_suci_from_mobile_identity(\n        ogs_nas_5gs_mobile_identity_t *mobile_identity)\n{\n    ogs_nas_5gs_mobile_identity_suci_t *mobile_identity_suci = NULL;\n    ogs_plmn_id_t plmn_id;\n    char tmp[OGS_NAS_MAX_SCHEME_OUTPUT_LEN*2+1];\n    char routing_indicator[5];\n    char *suci = NULL;\n    int scheme_output_len = 0;\n\n    ogs_assert(mobile_identity);\n\n    mobile_identity_suci =\n        (ogs_nas_5gs_mobile_identity_suci_t *)mobile_identity->buffer;\n    ogs_assert(mobile_identity_suci);\n\n    ogs_expect_or_return_val(mobile_identity_suci->h.supi_format ==\n            OGS_NAS_5GS_SUPI_FORMAT_IMSI, NULL);\n    ogs_expect_or_return_val(mobile_identity_suci->protection_scheme_id ==\n            OGS_NAS_5GS_NULL_SCHEME, NULL);\n\n    suci = ogs_msprintf(\"suci-%d-\", mobile_identity_suci->h.supi_format);\n    ogs_expect_or_return_val(suci, NULL);\n\n    ogs_nas_to_plmn_id(&plmn_id, &mobile_identity_suci->nas_plmn_id);\n    if (ogs_plmn_id_mnc_len(&plmn_id) == 2) {\n        suci = ogs_mstrcatf(suci, \"%03d-%02d-\",\n                ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));\n        ogs_expect_or_return_val(suci, NULL);\n    } else {\n        suci = ogs_mstrcatf(suci, \"%03d-%03d-\",\n                ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));\n        ogs_expect_or_return_val(suci, NULL);\n    }\n\n    memset(routing_indicator, 0, sizeof(routing_indicator));\n    if (mobile_identity_suci->routing_indicator1 != 0xf) {\n        routing_indicator[0] =\n            mobile_identity_suci->routing_indicator1 + '0';\n        if (mobile_identity_suci->routing_indicator2 != 0xf) {\n            routing_indicator[1] =\n                mobile_identity_suci->routing_indicator2 + '0';\n            if (mobile_identity_suci->routing_indicator3 != 0xf) {\n                routing_indicator[2] =\n                    mobile_identity_suci->routing_indicator3 + '0';\n                if (mobile_identity_suci->routing_indicator4 != 0xf)\n                    routing_indicator[3] =\n                        mobile_identity_suci->routing_indicator4 + '0';\n            }\n        }\n    }\n\n    scheme_output_len = mobile_identity->length - 8;\n    ogs_expect_or_return_val(scheme_output_len > 0, NULL);\n    ogs_expect_or_return_val(\n            scheme_output_len <= OGS_NAS_MAX_SCHEME_OUTPUT_LEN, NULL);\n    ogs_buffer_to_bcd(mobile_identity_suci->scheme_output,\n            scheme_output_len, tmp);\n\n    suci = ogs_mstrcatf(suci, \"%s-%d-%d-%s\",\n            routing_indicator,\n            mobile_identity_suci->protection_scheme_id,\n            mobile_identity_suci->home_network_pki_value,\n            tmp);\n    ogs_expect(suci);\n\n    return suci;\n}","target":0,"code_token_length":707,"total_token_length":943,"max_tokens_setting":1024}
+{"idx":210571,"func":"int cx23888_ir_probe(struct cx23885_dev *dev)\n{\n\tstruct cx23888_ir_state *state;\n\tstruct v4l2_subdev *sd;\n\tstruct v4l2_subdev_ir_parameters default_params;\n\tint ret;\n\n\tstate = kzalloc(sizeof(struct cx23888_ir_state), GFP_KERNEL);\n\tif (state == NULL)\n\t\treturn -ENOMEM;\n\n\tspin_lock_init(&state->rx_kfifo_lock);\n\tif (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))\n\t\treturn -ENOMEM;\n\n\tstate->dev = dev;\n\tsd = &state->sd;\n\n\tv4l2_subdev_init(sd, &cx23888_ir_controller_ops);\n\tv4l2_set_subdevdata(sd, state);\n\t\/* FIXME - fix the formatting of dev->v4l2_dev.name and use it *\/\n\tsnprintf(sd->name, sizeof(sd->name), \"%s\/888-ir\", dev->name);\n\tsd->grp_id = CX23885_HW_888_IR;\n\n\tret = v4l2_device_register_subdev(&dev->v4l2_dev, sd);\n\tif (ret == 0) {\n\t\t\/*\n\t\t * Ensure no interrupts arrive from '888 specific conditions,\n\t\t * since we ignore them in this driver to have commonality with\n\t\t * similar IR controller cores.\n\t\t *\/\n\t\tcx23888_ir_write4(dev, CX23888_IR_IRQEN_REG, 0);\n\n\t\tmutex_init(&state->rx_params_lock);\n\t\tdefault_params = default_rx_params;\n\t\tv4l2_subdev_call(sd, ir, rx_s_parameters, &default_params);\n\n\t\tmutex_init(&state->tx_params_lock);\n\t\tdefault_params = default_tx_params;\n\t\tv4l2_subdev_call(sd, ir, tx_s_parameters, &default_params);\n\t} else {\n\t\tkfifo_free(&state->rx_kfifo);\n\t}\n\treturn ret;\n}","target":1,"code_token_length":431,"total_token_length":667,"max_tokens_setting":1024}
+{"idx":448919,"func":"int ZEXPORT inflateCopy(dest, source)\nz_streamp dest;\nz_streamp source;\n{\n    struct inflate_state FAR *state;\n    struct inflate_state FAR *copy;\n    unsigned char FAR *window;\n    unsigned wsize;\n\n    \/* check input *\/\n    if (inflateStateCheck(source) || dest == Z_NULL)\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)source->state;\n\n    \/* allocate space *\/\n    copy = (struct inflate_state FAR *)\n           ZALLOC(source, 1, sizeof(struct inflate_state));\n    if (copy == Z_NULL) return Z_MEM_ERROR;\n    window = Z_NULL;\n    if (state->window != Z_NULL) {\n        window = (unsigned char FAR *)\n                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));\n        if (window == Z_NULL) {\n            ZFREE(source, copy);\n            return Z_MEM_ERROR;\n        }\n    }\n\n    \/* copy state *\/\n    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));\n    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));\n    copy->strm = dest;\n    if (state->lencode >= state->codes &&\n        state->lencode <= state->codes + ENOUGH - 1) {\n        copy->lencode = copy->codes + (state->lencode - state->codes);\n        copy->distcode = copy->codes + (state->distcode - state->codes);\n    }\n    copy->next = copy->codes + (state->next - state->codes);\n    if (window != Z_NULL) {\n        wsize = 1U << state->wbits;\n        zmemcpy(window, state->window, wsize);\n    }\n    copy->window = window;\n    dest->state = (struct internal_state FAR *)copy;\n    return Z_OK;\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":270369,"func":"static void ok_inflater_make_huffman_tree_from_array(ok_inflater_huffman_tree *tree,\n                                                     const uint8_t *code_length, int length) {\n    tree->bits = 1;\n\n    \/\/ Count the number of codes for each code length.\n    \/\/ Let code_length_count[n] be the number of codes of length n, n >= 1.\n    unsigned int code_length_count[MAX_CODE_LENGTH];\n    int i;\n    for (i = 0; i < MAX_CODE_LENGTH; i++) {\n        code_length_count[i] = 0;\n    }\n    for (i = 0; i < length; i++) {\n        code_length_count[code_length[i]]++;\n    }\n\n    \/\/ Find the numerical value of the smallest code for each code length:\n    unsigned int next_code[MAX_CODE_LENGTH];\n    unsigned int code = 0;\n    for (i = 1; i < MAX_CODE_LENGTH; i++) {\n        code = (code + code_length_count[i - 1]) << 1;\n        next_code[i] = code;\n        if (code_length_count[i] != 0) {\n            tree->bits = (unsigned int)i;\n        }\n    }\n\n    \/\/ Init lookup table\n    const unsigned int max = 1 << tree->bits;\n    memset(tree->lookup_table, 0, sizeof(tree->lookup_table[0]) * max);\n\n    \/\/ Assign numerical values to all codes, using consecutive values for all\n    \/\/ codes of the same length with the base values determined at step 2.\n    \/\/ Codes that are never used (which have a bit length of zero) must not be\n    \/\/ assigned a value.\n    for (i = 0; i < length; i++) {\n        unsigned int len = code_length[i];\n        if (len != 0) {\n            code = next_code[len];\n            next_code[len]++;\n\n            unsigned int value = (unsigned int)i | (len << VALUE_BITS);\n            tree->lookup_table[ok_inflater_reverse_bits(code, len)] = (uint16_t)value;\n        }\n    }\n\n    \/\/ Fill in the missing parts of the lookup table\n    int next_limit = 1;\n    int num_bits = 0;\n    int mask = 0;\n    for (i = 1; i < (int)max; i++) {\n        if (i == next_limit) {\n            mask = (1 << num_bits) - 1;\n            num_bits++;\n            next_limit <<= 1;\n        }\n        if (tree->lookup_table[i] == 0) {\n            tree->lookup_table[i] = tree->lookup_table[i & mask];\n        }\n    }\n}","target":0,"code_token_length":556,"total_token_length":792,"max_tokens_setting":1024}
+{"idx":207755,"func":"PHP_FUNCTION(openssl_encrypt)\n{\n\tzend_bool raw_output = 0;\n\tchar *data, *method, *password, *iv = \"\";\n\tint data_len, method_len, password_len, iv_len = 0, max_iv_len;\n\tconst EVP_CIPHER *cipher_type;\n\tEVP_CIPHER_CTX cipher_ctx;\n\tint i, outlen, keylen;\n\tunsigned char *outbuf, *key;\n\tzend_bool free_iv;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"sss|bs\", &data, &data_len, &method, &method_len, &password, &password_len, &raw_output, &iv, &iv_len) == FAILURE) {\n\t\treturn;\n\t}\n\tcipher_type = EVP_get_cipherbyname(method);\n\tif (!cipher_type) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown cipher algorithm\");\n\t\tRETURN_FALSE;\n\t}\n\n\tkeylen = EVP_CIPHER_key_length(cipher_type);\n\tif (keylen > password_len) {\n\t\tkey = emalloc(keylen);\n\t\tmemset(key, 0, keylen);\n\t\tmemcpy(key, password, password_len);\n\t} else {\n\t\tkey = (unsigned char*)password;\n\t}\n\n\tmax_iv_len = EVP_CIPHER_iv_length(cipher_type);\n\tif (iv_len <= 0 && max_iv_len > 0) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Using an empty Initialization Vector (iv) is potentially insecure and not recommended\");\n\t}\n\tfree_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len TSRMLS_CC);\n\n\toutlen = data_len + EVP_CIPHER_block_size(cipher_type);\n\toutbuf = emalloc(outlen + 1);\n\n\tEVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);\n\tif (password_len > keylen) {\n\t\tEVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len);\n\t}\n\tEVP_EncryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv);\n\tEVP_EncryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len);\n\toutlen = i;\n\tif (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) {\n\t\toutlen += i;\n\t\tif (raw_output) {\n\t\t\toutbuf[outlen] = '\\0';\n\t\t\tRETVAL_STRINGL((char *)outbuf, outlen, 0);\n\t\t} else {\n\t\t\tint base64_str_len;\n\t\t\tchar *base64_str;\n\n\t\t\tbase64_str = (char*)php_base64_encode(outbuf, outlen, &base64_str_len);\n\t\t\tefree(outbuf);\n\t\t\tRETVAL_STRINGL(base64_str, base64_str_len, 0);\n\t\t}\n\t} else {\n\t\tefree(outbuf);\n\t\tRETVAL_FALSE;\n\t}\n\tif (key != (unsigned char*)password) {\n\t\tefree(key);\n\t}\n\tif (free_iv) {\n\t\tefree(iv);\n\t}\n\tEVP_CIPHER_CTX_cleanup(&cipher_ctx);\n}","target":1,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":349261,"func":"void sort_directory(struct dir *dir)\n{\n\tstruct dir_ent *cur, *l1, *l2, *next;\n\tint len1, len2, stride = 1;\n\n\tif(dir->dir_count < 2)\n\t\treturn;\n\n\t\/*\n\t * We can consider our linked-list to be made up of stride length\n\t * sublists.  Eacn iteration around this loop merges adjacent\n\t * stride length sublists into larger 2*stride sublists.  We stop\n\t * when stride becomes equal to the entire list.\n\t *\n\t * Initially stride = 1 (by definition a sublist of 1 is sorted), and\n\t * these 1 element sublists are merged into 2 element sublists,  which\n\t * are then merged into 4 element sublists and so on.\n\t *\/\n\tdo {\n\t\tl2 = dir->dirs; \/* head of current linked list *\/\n\t\tcur = NULL; \/* empty output list *\/\n\n\t\t\/*\n\t\t * Iterate through the linked list, merging adjacent sublists.\n\t\t * On each interation l2 points to the next sublist pair to be\n\t\t * merged (if there's only one sublist left this is simply added\n\t\t * to the output list)\n\t\t *\/\n\t\twhile(l2) {\n\t\t\tl1 = l2;\n\t\t\tfor(len1 = 0; l2 && len1 < stride; len1 ++, l2 = l2->next);\n\t\t\tlen2 = stride;\n\n\t\t\t\/*\n\t\t\t * l1 points to first sublist.\n\t\t\t * l2 points to second sublist.\n\t\t\t * Merge them onto the output list\n\t\t\t *\/\n\t\t\twhile(len1 && l2 && len2) {\n\t\t\t\tif(strcmp(l1->name, l2->name) <= 0) {\n\t\t\t\t\tnext = l1;\n\t\t\t\t\tl1 = l1->next;\n\t\t\t\t\tlen1 --;\n\t\t\t\t} else {\n\t\t\t\t\tnext = l2;\n\t\t\t\t\tl2 = l2->next;\n\t\t\t\t\tlen2 --;\n\t\t\t\t}\n\n\t\t\t\tif(cur) {\n\t\t\t\t\tcur->next = next;\n\t\t\t\t\tcur = next;\n\t\t\t\t} else\n\t\t\t\t\tdir->dirs = cur = next;\n\t\t\t}\n\t\t\t\/*\n\t\t\t * One sublist is now empty, copy the other one onto the\n\t\t\t * output list\n\t\t\t *\/\n\t\t\tfor(; len1; len1 --, l1 = l1->next) {\n\t\t\t\tif(cur) {\n\t\t\t\t\tcur->next = l1;\n\t\t\t\t\tcur = l1;\n\t\t\t\t} else\n\t\t\t\t\tdir->dirs = cur = l1;\n\t\t\t}\n\t\t\tfor(; l2 && len2; len2 --, l2 = l2->next) {\n\t\t\t\tif(cur) {\n\t\t\t\t\tcur->next = l2;\n\t\t\t\t\tcur = l2;\n\t\t\t\t} else\n\t\t\t\t\tdir->dirs = cur = l2;\n\t\t\t}\n\t\t}\n\t\tcur->next = NULL;\n\t\tstride = stride << 1;\n\t} while(stride < dir->dir_count);\n}","target":0,"code_token_length":620,"total_token_length":856,"max_tokens_setting":1024}
+{"idx":234761,"func":"static noinline int init_first_rw_device(struct btrfs_trans_handle *trans)\n{\n\tstruct btrfs_fs_info *fs_info = trans->fs_info;\n\tu64 alloc_profile;\n\tstruct btrfs_block_group *meta_bg;\n\tstruct btrfs_block_group *sys_bg;\n\n\t\/*\n\t * When adding a new device for sprouting, the seed device is read-only\n\t * so we must first allocate a metadata and a system chunk. But before\n\t * adding the block group items to the extent, device and chunk btrees,\n\t * we must first:\n\t *\n\t * 1) Create both chunks without doing any changes to the btrees, as\n\t *    otherwise we would get -ENOSPC since the block groups from the\n\t *    seed device are read-only;\n\t *\n\t * 2) Add the device item for the new sprout device - finishing the setup\n\t *    of a new block group requires updating the device item in the chunk\n\t *    btree, so it must exist when we attempt to do it. The previous step\n\t *    ensures this does not fail with -ENOSPC.\n\t *\n\t * After that we can add the block group items to their btrees:\n\t * update existing device item in the chunk btree, add a new block group\n\t * item to the extent btree, add a new chunk item to the chunk btree and\n\t * finally add the new device extent items to the devices btree.\n\t *\/\n\n\talloc_profile = btrfs_metadata_alloc_profile(fs_info);\n\tmeta_bg = btrfs_alloc_chunk(trans, alloc_profile);\n\tif (IS_ERR(meta_bg))\n\t\treturn PTR_ERR(meta_bg);\n\n\talloc_profile = btrfs_system_alloc_profile(fs_info);\n\tsys_bg = btrfs_alloc_chunk(trans, alloc_profile);\n\tif (IS_ERR(sys_bg))\n\t\treturn PTR_ERR(sys_bg);\n\n\treturn 0;\n}","target":0,"code_token_length":392,"total_token_length":628,"max_tokens_setting":1024}
+{"idx":455305,"func":"bash_filename_stat_hook (dirname)\n     char **dirname;\n{\n  char *local_dirname, *new_dirname, *t;\n  int should_expand_dirname, return_value;\n  int global_nounset;\n  WORD_LIST *wl;\n\n  local_dirname = *dirname;\n  should_expand_dirname = return_value = 0;\n  if (t = mbschr (local_dirname, '$'))\n    should_expand_dirname = '$';\n  else if (t = mbschr (local_dirname, '`'))\t\/* XXX *\/\n    should_expand_dirname = '`';\n\n  if (should_expand_dirname && directory_exists (local_dirname, 0))\n    should_expand_dirname = 0;\n  \n  if (should_expand_dirname)  \n    {\n      new_dirname = savestring (local_dirname);\n      \/* no error messages, and expand_prompt_string doesn't longjmp so we don't\n\t have to worry about restoring this setting. *\/\n      global_nounset = unbound_vars_is_error;\n      unbound_vars_is_error = 0;\n      wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE);\t\/* does the right thing *\/\n      unbound_vars_is_error = global_nounset;\n      if (wl)\n\t{\n\t  free (new_dirname);\n\t  new_dirname = string_list (wl);\n\t  \/* Tell the completer we actually expanded something and change\n\t     *dirname only if we expanded to something non-null -- stat\n\t     behaves unpredictably when passed null or empty strings *\/\n\t  if (new_dirname && *new_dirname)\n\t    {\n\t      free (local_dirname);\t\/* XXX *\/\n\t      local_dirname = *dirname = new_dirname;\n\t      return_value = STREQ (local_dirname, *dirname) == 0;\n\t    }\n\t  else\n\t    free (new_dirname);\n\t  dispose_words (wl);\n\t}\n      else\n\tfree (new_dirname);\n    }\t\n\n  \/* This is very similar to the code in bash_directory_completion_hook below,\n     but without spelling correction and not worrying about whether or not\n     we change relative pathnames. *\/\n  if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))\n    {\n      char *temp1, *temp2;\n\n      t = get_working_directory (\"symlink-hook\");\n      temp1 = make_absolute (local_dirname, t);\n      free (t);\n      temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);\n\n      \/* If we can't canonicalize, bail. *\/\n      if (temp2 == 0)\n\t{\n\t  free (temp1);\n\t  return return_value;\n\t}\n\n      free (local_dirname);\n      *dirname = temp2;\n      free (temp1);\n    }\n\n  return (return_value);\n}","target":0,"code_token_length":613,"total_token_length":849,"max_tokens_setting":1024}
+{"idx":427168,"func":"static void close_func (LexState *ls) {\n  lua_State *L = ls->L;\n  FuncState *fs = ls->fs;\n  Proto *f = fs->f;\n  luaK_ret(fs, luaY_nvarstack(fs), 0);  \/* final return *\/\n  leaveblock(fs);\n  lua_assert(fs->bl == NULL);\n  luaK_finish(fs);\n  luaM_shrinkvector(L, f->code, f->sizecode, fs->pc, Instruction);\n  luaM_shrinkvector(L, f->lineinfo, f->sizelineinfo, fs->pc, ls_byte);\n  luaM_shrinkvector(L, f->abslineinfo, f->sizeabslineinfo,\n                       fs->nabslineinfo, AbsLineInfo);\n  luaM_shrinkvector(L, f->k, f->sizek, fs->nk, TValue);\n  luaM_shrinkvector(L, f->p, f->sizep, fs->np, Proto *);\n  luaM_shrinkvector(L, f->locvars, f->sizelocvars, fs->ndebugvars, LocVar);\n  luaM_shrinkvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc);\n  ls->fs = fs->prev;\n  luaC_checkGC(L);\n}","target":0,"code_token_length":285,"total_token_length":521,"max_tokens_setting":1024}
+{"idx":225106,"func":"Status ValidateAttrValue(const AttrValue& attr_value,\n                         const OpDef::AttrDef& attr) {\n  \/\/ Is it a valid value?\n  TF_RETURN_WITH_CONTEXT_IF_ERROR(AttrValueHasType(attr_value, attr.type()),\n                                  \" for attr '\", attr.name(), \"'\");\n\n  \/\/ Does the value satisfy the minimum constraint in the AttrDef?\n  if (attr.has_minimum()) {\n    if (attr.type() == \"int\") {\n      if (attr_value.i() < attr.minimum()) {\n        return errors::InvalidArgument(\n            \"Value for attr '\", attr.name(), \"' of \", attr_value.i(),\n            \" must be at least minimum \", attr.minimum());\n      }\n    } else {\n      int length = -1;\n      if (attr.type() == \"list(string)\") {\n        length = attr_value.list().s_size();\n      } else if (attr.type() == \"list(int)\") {\n        length = attr_value.list().i_size();\n      } else if (attr.type() == \"list(float)\") {\n        length = attr_value.list().f_size();\n      } else if (attr.type() == \"list(bool)\") {\n        length = attr_value.list().b_size();\n      } else if (attr.type() == \"list(type)\") {\n        length = attr_value.list().type_size();\n      } else if (attr.type() == \"list(shape)\") {\n        length = attr_value.list().shape_size();\n      } else if (attr.type() == \"list(tensor)\") {\n        length = attr_value.list().tensor_size();\n      } else if (attr.type() == \"list(func)\") {\n        length = attr_value.list().func_size();\n      }\n      if (length < attr.minimum()) {\n        return errors::InvalidArgument(\n            \"Length for attr '\", attr.name(), \"' of \", length,\n            \" must be at least minimum \", attr.minimum());\n      }\n    }\n  }\n\n  \/\/ Does the value satisfy the allowed_value constraint in the AttrDef?\n  if (attr.has_allowed_values()) {\n    if (attr.type() == \"type\") {\n      TF_RETURN_IF_ERROR(AllowedTypeValue(attr_value.type(), attr));\n    } else if (attr.type() == \"list(type)\") {\n      for (int dt : attr_value.list().type()) {\n        TF_RETURN_IF_ERROR(AllowedTypeValue(static_cast<DataType>(dt), attr));\n      }\n    } else if (attr.type() == \"string\") {\n      TF_RETURN_IF_ERROR(AllowedStringValue(attr_value.s(), attr));\n    } else if (attr.type() == \"list(string)\") {\n      for (const string& str : attr_value.list().s()) {\n        TF_RETURN_IF_ERROR(AllowedStringValue(str, attr));\n      }\n    } else {\n      return errors::Unimplemented(\n          \"Support for allowed_values not implemented for type \", attr.type());\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":592,"total_token_length":828,"max_tokens_setting":1024}
+{"idx":275929,"func":"int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, uECC_Curve curve) {\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    uECC_word_t *_private = (uECC_word_t *)private_key;\n    uECC_word_t *_public = (uECC_word_t *)public_key;\n#else\n    uECC_word_t _private[uECC_MAX_WORDS];\n    uECC_word_t _public[uECC_MAX_WORDS * 2];\n#endif\n\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0\n    uECC_vli_bytesToNative(_private, private_key, BITS_TO_BYTES(curve->num_n_bits));\n#endif\n\n    \/* Make sure the private key is in the range [1, n-1]. *\/\n    if (uECC_vli_isZero(_private, BITS_TO_WORDS(curve->num_n_bits))) {\n        return 0;\n    }\n\n    if (uECC_vli_cmp(curve->n, _private, BITS_TO_WORDS(curve->num_n_bits)) != 1) {\n        return 0;\n    }\n\n    \/* Compute public key. *\/\n    if (!EccPoint_compute_public_key(_public, _private, curve)) {\n        return 0;\n    }\n\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0\n    uECC_vli_nativeToBytes(public_key, curve->num_bytes, _public);\n    uECC_vli_nativeToBytes(\n        public_key + curve->num_bytes, curve->num_bytes, _public + curve->num_words);\n#endif\n    return 1;\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":221661,"func":"int Socket::readFromSocketn(char *buff, int len, unsigned int flags, int timeout)\n{\n    return readFromSocket(buff, len, flags, timeout, true, false);\n\n\n#ifdef NODEF\n    if (!isssl) {\n        return BaseSocket::readFromSocketn(buff, len, flags, timeout);\n    }\n\n    int cnt, rc;\n    cnt = len;\n\n    \/\/ first, return what's left from the previous buffer read, if anything\n    if ((bufflen - buffstart) > 0) {\n#ifdef NETDEBUG\n        std::cout << thread_id << \"Socket::readFromSocketn: data already in buffer; bufflen: \" << bufflen << \" buffstart: \" << buffstart << std::endl;\n#endif\n        int tocopy = len;\n        if ((bufflen - buffstart) < len)\n            tocopy = bufflen - buffstart;\n        memcpy(buff, buffer + buffstart, tocopy);\n        cnt -= tocopy;\n        buffstart += tocopy;\n        buff += tocopy;\n        if (cnt == 0)\n            return len;\n    }\n\n    while (cnt > 0) {\n    \/\/    try {\n            \/\/bcheckSForInput(timeout);        \/\/  this may be wrong - why is data not being read into socket buffer????\n    \/\/    } catch (std::exception &e) {\n     \/\/       return -1;\n     \/\/   }\n        ERR_clear_error();\n        rc = SSL_read(ssl, buff, cnt);\n#ifdef NETDEBUG\n        std::cout << thread_id << \"ssl read said: \" << rc << std::endl;\n#endif\n\n        if (rc < 0) {\n       \/\/     if (errno == EINTR) {\n         \/\/       continue;\n           \/\/ }\n            log_ssl_errors(\"ssl_read failed %s\", \"\");\n           s_errno = errno;\n            return -1;\n        }\n        if (rc == 0) { \/\/ eof\n             ishup = true;\n            return len - cnt;\n        }\n        buff += rc;\n        cnt -= rc;\n    }\n    return len;\n#endif\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":232828,"func":"  void Compute(OpKernelContext* context) override {\n    ResourceHandle handle;\n    OP_REQUIRES_OK(context,\n                   HandleFromInput(context, kResourceHandleName, &handle));\n    core::RefCountPtr<QuantileStreamResource> stream_resource;\n    \/\/ Create a reference to the underlying resource using the handle.\n    OP_REQUIRES_OK(context, LookupResource(context, handle, &stream_resource));\n    \/\/ Remove the reference at the end of this scope.\n    mutex_lock l(*stream_resource->mutex());\n\n    const Tensor* num_buckets_t;\n    OP_REQUIRES_OK(context, context->input(kNumBucketsName, &num_buckets_t));\n    const int64_t num_buckets = num_buckets_t->scalar<int64>()();\n    const int64_t num_streams = stream_resource->num_streams();\n\n    auto do_quantile_flush = [&](const int64_t begin, const int64_t end) {\n      \/\/ Iterating over all streams.\n      for (int64_t stream_idx = begin; stream_idx < end; ++stream_idx) {\n        QuantileStream* stream = stream_resource->stream(stream_idx);\n        stream->Finalize();\n        stream_resource->set_boundaries(\n            generate_quantiles_ ? GenerateQuantiles(*stream, num_buckets)\n                                : GenerateBoundaries(*stream, num_buckets),\n            stream_idx);\n      }\n    };\n\n    \/\/ TODO(tanzheny): comment on the magic number.\n    const int64_t kCostPerUnit = 500 * num_streams;\n    const DeviceBase::CpuWorkerThreads& worker_threads =\n        *context->device()->tensorflow_cpu_worker_threads();\n    Shard(worker_threads.num_threads, worker_threads.workers, num_streams,\n          kCostPerUnit, do_quantile_flush);\n\n    stream_resource->ResetStreams();\n    stream_resource->set_buckets_ready(true);\n  }","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":492670,"func":"_vte_terminal_scroll_text (VteTerminal *terminal, int scroll_amount)\n{\n\tlong start, end, i;\n\tVteScreen *screen;\n\n\tscreen = terminal->pvt->screen;\n\n\tif (screen->scrolling_restricted) {\n\t\tstart = screen->insert_delta + screen->scrolling_region.start;\n\t\tend = screen->insert_delta + screen->scrolling_region.end;\n\t} else {\n\t\tstart = screen->insert_delta;\n\t\tend = start + terminal->row_count - 1;\n\t}\n\n\twhile (_vte_ring_next(screen->row_data) <= end)\n\t\t_vte_terminal_ring_append (terminal, FALSE);\n\n\tif (scroll_amount > 0) {\n\t\tfor (i = 0; i < scroll_amount; i++) {\n\t\t\t_vte_terminal_ring_remove (terminal, end);\n\t\t\t_vte_terminal_ring_insert (terminal, start, TRUE);\n\t\t}\n\t} else {\n\t\tfor (i = 0; i < -scroll_amount; i++) {\n\t\t\t_vte_terminal_ring_remove (terminal, start);\n\t\t\t_vte_terminal_ring_insert (terminal, end, TRUE);\n\t\t}\n\t}\n\n\t\/* Update the display. *\/\n\t_vte_terminal_scroll_region(terminal, start, end - start + 1,\n\t\t\t\t   scroll_amount);\n\n\t\/* Adjust the scrollbars if necessary. *\/\n\t_vte_terminal_adjust_adjustments(terminal);\n\n\t\/* We've modified the display.  Make a note of it. *\/\n\tterminal->pvt->text_inserted_flag = TRUE;\n\tterminal->pvt->text_deleted_flag = TRUE;\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":261239,"func":"int SN_Client_Connect(MqttClient *client, SN_Connect *mc_connect)\n{\n    int rc = 0, len = 0;\n    static byte will_done;\n\n    \/* Validate required arguments *\/\n    if ((client == NULL) || (mc_connect == NULL)) {\n        return MQTT_CODE_ERROR_BAD_ARG;\n    }\n\n    if (mc_connect->stat == MQTT_MSG_BEGIN) {\n\n        will_done = 0;\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        \/* Lock send socket mutex *\/\n        rc = wm_SemLock(&client->lockSend);\n        if (rc != 0) {\n            return rc;\n        }\n    #endif\n\n    \/* Encode the connect packet *\/\n        rc = SN_Encode_Connect(client->tx_buf, client->tx_buf_len, mc_connect);\n#ifdef WOLFMQTT_DEBUG_CLIENT\n    PRINTF(\"MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d\",\n        rc, SN_Packet_TypeDesc(SN_MSG_TYPE_CONNECT),\n        SN_MSG_TYPE_CONNECT, 0, 0);\n#endif\n        if (rc <= 0) {\n        #ifdef WOLFMQTT_MULTITHREAD\n            wm_SemUnlock(&client->lockSend);\n        #endif\n            return rc;\n        }\n        len = rc;\n\n    #ifdef WOLFMQTT_MULTITHREAD\n        rc = wm_SemLock(&client->lockClient);\n        if (rc == 0) {\n            \/* inform other threads of expected response *\/\n            rc = MqttClient_RespList_Add(client,\n                    (MqttPacketType)SN_MSG_TYPE_CONNACK, 0,\n                    &mc_connect->pendResp, &mc_connect->ack);\n            wm_SemUnlock(&client->lockClient);\n        }\n        if (rc != 0) {\n            wm_SemUnlock(&client->lockSend);\n            return rc; \/* Error locking client *\/\n        }\n    #endif\n\n        \/* Send connect packet *\/\n        rc = MqttPacket_Write(client, client->tx_buf, len);\n    #ifdef WOLFMQTT_MULTITHREAD\n        wm_SemUnlock(&client->lockSend);\n    #endif\n        if (rc != len) {\n            return rc;\n        }\n\n        mc_connect->stat = MQTT_MSG_WAIT;\n    }\n\n    if ((mc_connect->enable_lwt == 1) && (will_done != 1)) {\n        \/* If the will is enabled, then the gateway requests the topic and\n           message in separate packets. *\/\n        rc = SN_WillTopic(client, &mc_connect->will);\n        if (rc != 0) {\n            return rc;\n        }\n\n        rc = SN_WillMessage(client, &mc_connect->will);\n        if (rc != 0) {\n            return rc;\n        }\n        will_done = 1;\n    }\n\n    \/* Wait for connect ack packet *\/\n    rc = SN_Client_WaitType(client, &mc_connect->ack,\n            SN_MSG_TYPE_CONNACK, 0, client->cmd_timeout_ms);\n#ifdef WOLFMQTT_NONBLOCK\n    if (rc == MQTT_CODE_CONTINUE)\n        return rc;\n#endif\n\n#ifdef WOLFMQTT_MULTITHREAD\n    if (wm_SemLock(&client->lockClient) == 0) {\n        MqttClient_RespList_Remove(client, &mc_connect->pendResp);\n        wm_SemUnlock(&client->lockClient);\n    }\n#endif\n\n    \/* reset state *\/\n    mc_connect->stat = MQTT_MSG_BEGIN;\n\n    return rc;\n}","target":0,"code_token_length":748,"total_token_length":984,"max_tokens_setting":1024}
+{"idx":436114,"func":"static int io_send(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_sr_msg *sr = &req->sr_msg;\n\tstruct msghdr msg;\n\tstruct iovec iov;\n\tstruct socket *sock;\n\tunsigned flags;\n\tint min_ret = 0;\n\tint ret;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tret = import_single_range(WRITE, sr->buf, sr->len, &iov, &msg.msg_iter);\n\tif (unlikely(ret))\n\t\treturn ret;\n\n\tmsg.msg_name = NULL;\n\tmsg.msg_control = NULL;\n\tmsg.msg_controllen = 0;\n\tmsg.msg_namelen = 0;\n\n\tflags = req->sr_msg.msg_flags;\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\tflags |= MSG_DONTWAIT;\n\tif (flags & MSG_WAITALL)\n\t\tmin_ret = iov_iter_count(&msg.msg_iter);\n\n\tmsg.msg_flags = flags;\n\tret = sock_sendmsg(sock, &msg);\n\tif ((issue_flags & IO_URING_F_NONBLOCK) && ret == -EAGAIN)\n\t\treturn -EAGAIN;\n\tif (ret == -ERESTARTSYS)\n\t\tret = -EINTR;\n\n\tif (ret < min_ret)\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":390537,"func":"XkbWriteKeyTypes(\tXkbDescPtr\t\txkb,\n\t\t\txkbGetMapReply *\trep,\n\t\t\tchar *\t\t\tbuf,\n\t\t\tClientPtr \t\tclient)\n{\n    XkbKeyTypePtr\ttype;\n    unsigned\t\ti;\n    xkbKeyTypeWireDesc *wire;\n\n    type= &xkb->map->types[rep->firstType];\n    for (i=0;i<rep->nTypes;i++,type++) {\n\tregister unsigned n;\n\twire= (xkbKeyTypeWireDesc *)buf;\n\twire->mask = type->mods.mask;\n\twire->realMods = type->mods.real_mods;\n\twire->virtualMods = type->mods.vmods;\n\twire->numLevels = type->num_levels;\n\twire->nMapEntries = type->map_count;\n\twire->preserve = (type->preserve!=NULL);\n\tif (client->swapped) {\n\t    register int n;\n\t    swaps(&wire->virtualMods,n);\n\t}\t\n\n\tbuf= (char *)&wire[1];\n\tif (wire->nMapEntries>0) {\n\t    xkbKTMapEntryWireDesc *\twire;\n\t    XkbKTMapEntryPtr\t\tentry;\n\t    wire= (xkbKTMapEntryWireDesc *)buf;\n\t    entry= type->map;\n\t    for (n=0;n<type->map_count;n++,wire++,entry++) {\n\t\twire->active= entry->active;\n\t\twire->mask= entry->mods.mask;\n\t\twire->level= entry->level;\n\t\twire->realMods= entry->mods.real_mods;\n\t\twire->virtualMods= entry->mods.vmods;\n\t\tif (client->swapped) {\n\t\t    register int n;\n\t\t    swaps(&wire->virtualMods,n);\n\t\t}\n\t    }\n\t    buf= (char *)wire;\n\t    if (type->preserve!=NULL) {\n\t\txkbModsWireDesc *\tpwire;\n\t\tXkbModsPtr\t\tpreserve;\n\t\tpwire= (xkbModsWireDesc *)buf;\n\t\tpreserve= type->preserve;\n\t\tfor (n=0;n<type->map_count;n++,pwire++,preserve++) {\n\t\t    pwire->mask= preserve->mask;\n\t\t    pwire->realMods= preserve->real_mods;\n\t\t    pwire->virtualMods= preserve->vmods;\n\t\t    if (client->swapped) {\n\t\t\tregister int n;\n\t\t\tswaps(&pwire->virtualMods,n);\n\t\t    }\n\t\t}\n\t\tbuf= (char *)pwire;\n\t    }\n\t}\n    }\n    return buf;\n}","target":0,"code_token_length":532,"total_token_length":768,"max_tokens_setting":1024}
+{"idx":488334,"func":"static int __init vdso_do_func_patch64(struct lib32_elfinfo *v32,\n\t\t\t\t       struct lib64_elfinfo *v64,\n\t\t\t\t       const char *orig, const char *fix)\n{\n\tElf64_Sym *sym64_gen, *sym64_fix;\n\n\tsym64_gen = find_symbol64(v64, orig);\n\tif (sym64_gen == NULL) {\n\t\tprintk(KERN_ERR \"vDSO64: Can't find symbol %s !\\n\", orig);\n\t\treturn -1;\n\t}\n\tif (fix == NULL) {\n\t\tsym64_gen->st_name = 0;\n\t\treturn 0;\n\t}\n\tsym64_fix = find_symbol64(v64, fix);\n\tif (sym64_fix == NULL) {\n\t\tprintk(KERN_ERR \"vDSO64: Can't find symbol %s !\\n\", fix);\n\t\treturn -1;\n\t}\n\tsym64_gen->st_value = sym64_fix->st_value;\n\tsym64_gen->st_size = sym64_fix->st_size;\n\tsym64_gen->st_info = sym64_fix->st_info;\n\tsym64_gen->st_other = sym64_fix->st_other;\n\tsym64_gen->st_shndx = sym64_fix->st_shndx;\n\n\treturn 0;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":338207,"func":"bool WasmBinaryBuilder::getBasicType(int32_t code, Type& out) {\n  switch (code) {\n    case BinaryConsts::EncodedType::i32:\n      out = Type::i32;\n      return true;\n    case BinaryConsts::EncodedType::i64:\n      out = Type::i64;\n      return true;\n    case BinaryConsts::EncodedType::f32:\n      out = Type::f32;\n      return true;\n    case BinaryConsts::EncodedType::f64:\n      out = Type::f64;\n      return true;\n    case BinaryConsts::EncodedType::v128:\n      out = Type::v128;\n      return true;\n    case BinaryConsts::EncodedType::funcref:\n      out = Type::funcref;\n      return true;\n    case BinaryConsts::EncodedType::externref:\n      out = Type::externref;\n      return true;\n    case BinaryConsts::EncodedType::anyref:\n      out = Type::anyref;\n      return true;\n    case BinaryConsts::EncodedType::eqref:\n      out = Type::eqref;\n      return true;\n    case BinaryConsts::EncodedType::i31ref:\n      out = Type(HeapType::i31, NonNullable);\n      return true;\n    case BinaryConsts::EncodedType::dataref:\n      out = Type(HeapType::data, NonNullable);\n      return true;\n    default:\n      return false;\n  }\n}","target":0,"code_token_length":328,"total_token_length":564,"max_tokens_setting":1024}
+{"idx":270390,"func":"static bool ok_inflater_init_fixed_huffman(ok_inflater *inflater) {\n    if (!inflater->fixed_literal_huffman) {\n        ok_inflater_huffman_tree *tree = ok_alloc(inflater, sizeof(ok_inflater_huffman_tree));\n        if (tree) {\n            uint8_t code_length[288];\n            int i;\n            for (i = 0; i < 144; i++) {\n                code_length[i] = 8;\n            }\n            for (i = 144; i < 256; i++) {\n                code_length[i] = 9;\n            }\n            for (i = 256; i < 280; i++) {\n                code_length[i] = 7;\n            }\n            for (i = 280; i < 288; i++) {\n                code_length[i] = 8;\n            }\n            ok_inflater_make_huffman_tree_from_array(tree, code_length,\n                                                     sizeof(code_length) \/ sizeof(code_length[0]));\n            inflater->fixed_literal_huffman = tree;\n        }\n    }\n    if (!inflater->fixed_distance_huffman) {\n        ok_inflater_huffman_tree *tree = ok_alloc(inflater, sizeof(ok_inflater_huffman_tree));\n        if (tree) {\n            uint8_t distance_code_length[32];\n            for (int i = 0; i < 32; i++) {\n                distance_code_length[i] = 5;\n            }\n            ok_inflater_make_huffman_tree_from_array(tree, distance_code_length, 32);\n            inflater->fixed_distance_huffman = tree;\n        }\n    }\n    return inflater->fixed_literal_huffman && inflater->fixed_distance_huffman;\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":267968,"func":"R_IPI RBinFile *r_bin_file_new(RBin *bin, const char *file, ut64 file_sz, int rawstr, int fd, const char *xtrname, Sdb *sdb, bool steal_ptr) {\n\tut32 bf_id;\n\tif (!r_id_pool_grab_id (bin->ids->pool, &bf_id)) {\n\t\treturn NULL;\n\t}\n\tRBinFile *bf = R_NEW0 (RBinFile);\n\tif (bf) {\n\t\tbf->id = bf_id;\n\t\tbf->rbin = bin;\n\t\tbf->file = file ? strdup (file) : NULL;\n\t\tbf->rawstr = rawstr;\n\t\tbf->fd = fd;\n\t\tbf->curxtr = xtrname ? r_bin_get_xtrplugin_by_name (bin, xtrname) : NULL;\n\t\tbf->sdb = sdb;\n\t\tbf->size = file_sz;\n\t\tbf->xtr_data = r_list_newf ((RListFree)r_bin_xtrdata_free);\n\t\tbf->xtr_obj = NULL;\n\t\tbf->sdb = sdb_new0 ();\n\t\tbf->sdb_addrinfo = sdb_new0 (); \/\/ns (bf->sdb, \"addrinfo\", 1);\n\t\t\/\/ bf->sdb_addrinfo->refs++;\n\t}\n\treturn bf;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":365622,"func":"_asn1_change_integer_value (asn1_node node)\n{\n  asn1_node p;\n  unsigned char val[SIZEOF_UNSIGNED_LONG_INT];\n  unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];\n  int len;\n\n  if (node == NULL)\n    return ASN1_ELEMENT_NOT_FOUND;\n\n  p = node;\n  while (p)\n    {\n      if ((type_field (p->type) == ASN1_ETYPE_INTEGER)\n\t  && (p->type & CONST_ASSIGN))\n\t{\n\t  if (p->value)\n\t    {\n\t      _asn1_convert_integer (p->value, val, sizeof (val), &len);\n\t      asn1_octet_der (val, len, val2, &len);\n\t      _asn1_set_value (p, val2, len);\n\t    }\n\t}\n\n      if (p->down)\n\t{\n\t  p = p->down;\n\t}\n      else\n\t{\n\t  if (p == node)\n\t    p = NULL;\n\t  else if (p->right)\n\t    p = p->right;\n\t  else\n\t    {\n\t      while (1)\n\t\t{\n\t\t  p = _asn1_get_up (p);\n\t\t  if (p == node)\n\t\t    {\n\t\t      p = NULL;\n\t\t      break;\n\t\t    }\n\t\t  if (p->right)\n\t\t    {\n\t\t      p = p->right;\n\t\t      break;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n\n  return ASN1_SUCCESS;\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":219916,"func":"GF_Err gf_isom_setup_hint_track(GF_ISOFile *movie, u32 trackNumber, GF_ISOHintFormat HintType)\n{\n\tGF_Err e;\n\tGF_TrackBox *trak;\n\tGF_TrackReferenceBox *tref;\n\tGF_TrackReferenceTypeBox *dpnd;\n\tGF_HintMediaHeaderBox *hmhd;\n\t\/\/UDTA related ...\n\tGF_UserDataBox *udta;\n\n\n\t\/\/what do we support\n\tswitch (HintType) {\n\tcase GF_ISOM_HINT_RTP:\n\t\tbreak;\n\tdefault:\n\t\treturn GF_NOT_SUPPORTED;\n\t}\n\te = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE);\n\tif (e) return e;\n\n\ttrak = gf_isom_get_track_from_file(movie, trackNumber);\n\tif (!trak) return gf_isom_last_error(movie);\n\n\t\/\/check we have a hint ...\n\tif ( !IsHintTrack(trak)) {\n\t\treturn GF_BAD_PARAM;\n\t}\n\thmhd = (GF_HintMediaHeaderBox *)trak->Media->information->InfoHeader;\n\t\/\/make sure the subtype was not already defined\n\tif (hmhd->subType) return GF_BAD_PARAM;\n\t\/\/store the HintTrack format for later use...\n\thmhd->subType = HintType;\n\n\n\t\/\/hint tracks always have a tref and everything ...\n\tif (!trak->References) {\n\t\ttref = (GF_TrackReferenceBox *) gf_isom_box_new_parent(&trak->child_boxes, GF_ISOM_BOX_TYPE_TREF);\n\t\tif (!tref) return GF_OUT_OF_MEM;\n\t\te = trak_on_child_box((GF_Box*)trak, (GF_Box *)tref, GF_FALSE);\n\t\tif (e) return e;\n\t}\n\ttref = trak->References;\n\n\t\/\/do we have a hint reference on this trak ???\n\te = Track_FindRef(trak, GF_ISOM_BOX_TYPE_HINT, &dpnd);\n\tif (e) return e;\n\t\/\/if yes, return false (existing hint track...)\n\tif (dpnd) return GF_BAD_PARAM;\n\n\t\/\/create our dep\n\tdpnd = (GF_TrackReferenceTypeBox *) gf_isom_box_new_parent(&tref->child_boxes, GF_ISOM_BOX_TYPE_REFT);\n\tif (!dpnd) return GF_OUT_OF_MEM;\n\tdpnd->reference_type = GF_ISOM_BOX_TYPE_HINT;\n\n\t\/\/for RTP, we need to do some UDTA-related stuff...\n\tif (HintType != GF_ISOM_HINT_RTP) return GF_OK;\n\n\tif (!trak->udta) {\n\t\t\/\/create one\n\t\tudta = (GF_UserDataBox *) gf_isom_box_new_parent(&trak->child_boxes, GF_ISOM_BOX_TYPE_UDTA);\n\t\tif (!udta) return GF_OUT_OF_MEM;\n\t\te = trak_on_child_box((GF_Box*)trak, (GF_Box *) udta, GF_FALSE);\n\t\tif (e) return e;\n\t}\n\tudta = trak->udta;\n\n\t\/\/HNTI\n\te = udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE);\n\tif (e) return e;\n\n\t\/*\n\t\t\/\/NAME\n\t\te = udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_NAME));\n\t\tif (e) return e;\n\t\t\/\/HINF\n\t\treturn udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HINF));\n\t*\/\n\treturn GF_OK;\n}","target":0,"code_token_length":752,"total_token_length":988,"max_tokens_setting":1024}
+{"idx":513353,"func":"change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,\n                         Item *and_father, Item *cond,\n                         Item_bool_func2 *field_value_owner,\n                         Item *field, Item *value)\n{\n  if (cond->type() == Item::COND_ITEM)\n  {\n    bool and_level= ((Item_cond*) cond)->functype() ==\n      Item_func::COND_AND_FUNC;\n    List_iterator<Item> li(*((Item_cond*) cond)->argument_list());\n    Item *item;\n    while ((item=li++))\n      change_cond_ref_to_const(thd, save_list,and_level ? cond : item, item,\n\t\t\t       field_value_owner, field, value);\n    return;\n  }\n  if (cond->eq_cmp_result() == Item::COND_OK)\n    return;\t\t\t\t\t\/\/ Not a boolean function\n\n  Item_bool_func2 *func=  (Item_bool_func2*) cond;\n  Item **args= func->arguments();\n  Item *left_item=  args[0];\n  Item *right_item= args[1];\n  Item_func::Functype functype=  func->functype();\n\n  if (can_change_cond_ref_to_const(func, right_item, left_item,\n                                   field_value_owner, field, value))\n  {\n    Item *tmp=value->clone_item(thd);\n    if (tmp)\n    {\n      tmp->collation.set(right_item->collation);\n      thd->change_item_tree(args + 1, tmp);\n      func->update_used_tables();\n      if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)\n\t  && and_father != cond && !left_item->const_item())\n      {\n\tcond->marker=1;\n\tCOND_CMP *tmp2;\n        if ((tmp2= new (thd->mem_root) COND_CMP(and_father, func)))\n\t  save_list->push_back(tmp2);\n      }\n      \/*\n        LIKE can be optimized for BINARY\/VARBINARY\/BLOB columns, e.g.:\n\n        from: WHERE CONCAT(c1)='const1' AND CONCAT(c1) LIKE 'const2'\n          to: WHERE CONCAT(c1)='const1' AND 'const1' LIKE 'const2'\n\n        So make sure to use set_cmp_func() only for non-LIKE operators.\n      *\/\n      if (functype != Item_func::LIKE_FUNC)\n        ((Item_bool_rowready_func2*) func)->set_cmp_func();\n    }\n  }\n  else if (can_change_cond_ref_to_const(func, left_item, right_item,\n                                        field_value_owner, field, value))\n  {\n    Item *tmp= value->clone_item(thd);\n    if (tmp)\n    {\n      tmp->collation.set(left_item->collation);\n      thd->change_item_tree(args, tmp);\n      value= tmp;\n      func->update_used_tables();\n      if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)\n\t  && and_father != cond && !right_item->const_item())\n      {\n        args[0]= args[1];                       \/\/ For easy check\n        thd->change_item_tree(args + 1, value);\n\tcond->marker=1;\n\tCOND_CMP *tmp2;\n        if ((tmp2=new (thd->mem_root) COND_CMP(and_father, func)))\n\t  save_list->push_back(tmp2);\n      }\n      if (functype != Item_func::LIKE_FUNC)\n        ((Item_bool_rowready_func2*) func)->set_cmp_func();\n    }\n  }\n}","target":0,"code_token_length":751,"total_token_length":987,"max_tokens_setting":1024}
+{"idx":220903,"func":"int DependencyOptimizer::NumEdgesIfBypassed(\n    const NodeDef& node, const std::vector<NodeDef*>& output_nodes) const {\n  const bool is_multi_input_identity_n =\n      IsIdentityN(node) && !IsIdentityNSingleInput(node);\n  const int num_outputs = output_nodes.size();\n  const int num_inputs = node.input_size();\n\n  if (is_multi_input_identity_n) {\n    \/\/ multi-input identity_n with input\/output control dependencies will likely\n    \/\/ increase number of edges after optimization.\n    int num_edges_if_bypassed(0);\n    for (const string& input_node_name : node.input()) {\n      if (IsControlInput(input_node_name)) {\n        num_edges_if_bypassed += num_outputs;\n      } else {\n        ++num_edges_if_bypassed;\n      }\n    }\n\n    for (auto consumer : output_nodes) {\n      for (int j = 0; j < consumer->input_size(); ++j) {\n        const TensorId consumer_input = ParseTensorName(consumer->input(j));\n        if (consumer_input.node() == node.name()) {\n          if (IsControlInput(consumer_input)) {\n            num_edges_if_bypassed += num_inputs;\n          } else {\n            ++num_edges_if_bypassed;\n          }\n        }\n      }\n    }\n    return num_edges_if_bypassed;\n  } else {\n    return num_inputs * num_outputs;\n  }\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":218964,"func":"bool ExtractShape(const NodeDef& shape_node, const GraphProperties& properties,\n                  BCast::Vec* shape, int64_t* min_id) {\n  if (shape_node.op() == \"Shape\") {\n    const std::vector<OpInfo::TensorProperties>& prop1 =\n        properties.GetInputProperties(shape_node.name());\n    if (prop1.size() != 1) {\n      return false;\n    }\n    const TensorShapeProto& shp = prop1[0].shape();\n    if (shp.unknown_rank()) {\n      return false;\n    }\n    for (const auto& dim : shp.dim()) {\n      shape->push_back(dim.size());\n      *min_id = std::min<int64_t>(*min_id, dim.size());\n    }\n  } else {\n    if (shape_node.attr().count(\"value\") == 0) {\n      return false;\n    }\n    const TensorProto& raw_val = shape_node.attr().at(\"value\").tensor();\n    if (raw_val.dtype() != DT_INT64 && raw_val.dtype() != DT_INT32) {\n      return false;\n    }\n    Tensor value(raw_val.dtype(), raw_val.tensor_shape());\n    if (!value.FromProto(raw_val)) {\n      return false;\n    }\n    for (int j = 0; j < value.NumElements(); ++j) {\n      if (raw_val.dtype() == DT_INT64) {\n        shape->push_back(value.vec<int64_t>()(j));\n      } else {\n        shape->push_back(value.vec<int>()(j));\n      }\n    }\n  }\n  return true;\n}","target":0,"code_token_length":337,"total_token_length":573,"max_tokens_setting":1024}
+{"idx":359357,"func":"extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,\n\t\t\t     int style)\n{\n  int ret;\n  int direct = 0;\n  char *str = NULL;\n\n  if (argc > 1)\n    {\n      \/* Check the list direct. *\/\n      if (strncmp (argv[1], \"p\", 1) == 0)\n\tdirect = COMMUNITY_PERMIT;\n      else if (strncmp (argv[1], \"d\", 1) == 0)\n\tdirect = COMMUNITY_DENY;\n      else\n\t{\n\t  vty_out (vty, \"%% Matching condition must be permit or deny%s\",\n\t\t   VTY_NEWLINE);\n\t  return CMD_WARNING;\n\t}\n\n      \/* Concat community string argument.  *\/\n      str = argv_concat (argv, argc, 2);\n    }\n\n  \/* Unset community list.  *\/\n  ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);\n\n  \/* Free temporary community list string allocated by\n     argv_concat().  *\/\n  if (str)\n    XFREE (MTYPE_TMP, str);\n\n  if (ret < 0)\n    {\n      community_list_perror (vty, ret);\n      return CMD_WARNING;\n    }\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":507772,"func":"static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)\n{\n    int ok = 0;\n    BIGNUM *tmp_1 = NULL, *tmp_2 = NULL;\n    unsigned char *a_buf = NULL, *b_buf = NULL;\n    size_t len;\n\n    if (!group || !curve || !curve->a || !curve->b)\n        return 0;\n\n    if ((tmp_1 = BN_new()) == NULL || (tmp_2 = BN_new()) == NULL) {\n        ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    \/* get a and b *\/\n    if (!EC_GROUP_get_curve(group, NULL, tmp_1, tmp_2, NULL)) {\n        ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB);\n        goto err;\n    }\n\n    \/*\n     * Per SEC 1, the curve coefficients must be padded up to size. See C.2's\n     * definition of Curve, C.1's definition of FieldElement, and 2.3.5's\n     * definition of how to encode the field elements.\n     *\/\n    len = ((size_t)EC_GROUP_get_degree(group) + 7) \/ 8;\n    if ((a_buf = OPENSSL_malloc(len)) == NULL\n        || (b_buf = OPENSSL_malloc(len)) == NULL) {\n        ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (BN_bn2binpad(tmp_1, a_buf, len) < 0\n        || BN_bn2binpad(tmp_2, b_buf, len) < 0) {\n        ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    \/* set a and b *\/\n    if (!ASN1_OCTET_STRING_set(curve->a, a_buf, len)\n        || !ASN1_OCTET_STRING_set(curve->b, b_buf, len)) {\n        ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB);\n        goto err;\n    }\n\n    \/* set the seed (optional) *\/\n    if (group->seed) {\n        if (!curve->seed)\n            if ((curve->seed = ASN1_BIT_STRING_new()) == NULL) {\n                ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n        curve->seed->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);\n        curve->seed->flags |= ASN1_STRING_FLAG_BITS_LEFT;\n        if (!ASN1_BIT_STRING_set(curve->seed, group->seed,\n                                 (int)group->seed_len)) {\n            ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB);\n            goto err;\n        }\n    } else {\n        ASN1_BIT_STRING_free(curve->seed);\n        curve->seed = NULL;\n    }\n\n    ok = 1;\n\n err:\n    OPENSSL_free(a_buf);\n    OPENSSL_free(b_buf);\n    BN_free(tmp_1);\n    BN_free(tmp_2);\n    return ok;\n}","target":0,"code_token_length":698,"total_token_length":934,"max_tokens_setting":1024}
+{"idx":292171,"func":"void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig,\n                                                  Klass* current_klass,\n                                                  Klass* sel_klass, TRAPS) {\n  Handle ref_loader(THREAD, current_klass->class_loader());\n  Handle sel_loader(THREAD, sel_klass->class_loader());\n\n  ResourceMark rm(THREAD);  \/\/ needed for check_signature_loaders\n  Symbol* failed_type_symbol =\n    SystemDictionary::check_signature_loaders(sig,\n                                              ref_loader, sel_loader,\n                                              false,\n                                              CHECK);\n  if (failed_type_symbol != NULL) {\n    stringStream ss;\n    const char* failed_type_name = failed_type_symbol->as_klass_external_name();\n\n    ss.print(\"loader constraint violation: when resolving field\"\n             \" \\\"%s\\\" of type %s, the class loader %s of the current class, \"\n             \"%s, and the class loader %s for the field's defining \"\n             \"type, %s, have different Class objects for type %s (%s; %s)\",\n             field->as_C_string(),\n             failed_type_name,\n             current_klass->class_loader_data()->loader_name_and_id(),\n             current_klass->external_name(),\n             sel_klass->class_loader_data()->loader_name_and_id(),\n             sel_klass->external_name(),\n             failed_type_name,\n             current_klass->class_in_module_of_loader(false, true),\n             sel_klass->class_in_module_of_loader(false, true));\n    THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());\n  }\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":285161,"func":"void __init(RBuffer *buf, r_bin_ne_obj_t *bin) {\n\tbin->header_offset = r_buf_read_le16_at (buf, 0x3c);\n\tbin->ne_header = R_NEW0 (NE_image_header);\n\tif (!bin->ne_header) {\n\t\treturn;\n\t}\n\tbin->buf = buf;\n\t\/\/ XXX this is endian unsafe\n\tif (r_buf_read_at (buf, bin->header_offset, (ut8 *)bin->ne_header, sizeof (NE_image_header)) < 1) {\n\t\tR_FREE (bin->ne_header);\n\t\treturn;\n\t}\n\tif (bin->ne_header->FileAlnSzShftCnt > 15) {\n\t\tbin->ne_header->FileAlnSzShftCnt = 15;\n\t}\n\tut64 from = bin->ne_header->ModRefTable + bin->header_offset;\n\tut64 left = r_buf_size (bin->buf) - from;\n\tif (from + bin->ne_header->ModRefs * sizeof (ut16) >= left) {\n\t\tbin->ne_header->ModRefs = left \/ sizeof (ut16);\n\t}\n\tbin->alignment = 1 << bin->ne_header->FileAlnSzShftCnt;\n\tif (!bin->alignment) {\n\t\tbin->alignment = 1 << 9;\n\t}\n\tbin->os = __get_target_os (bin);\n\n\tut16 offset = bin->ne_header->SegTableOffset + bin->header_offset;\n\tsize_t size = bin->ne_header->SegCount * sizeof (NE_image_segment_entry);\n\tif (offset >= r_buf_size (bin->buf)) {\n\t\treturn;\n\t}\n\tsize_t remaining = r_buf_size (bin->buf) - offset;\n\tsize = R_MIN (remaining, size);\n\tbin->ne_header->SegCount = size \/ sizeof (NE_image_segment_entry); \/\/ * sizeof (NE_image_segment_entry);\n\tbin->segment_entries = calloc (1, size);\n\tif (size >= remaining) {\n\t\tbin->ne_header->SegCount = size \/ sizeof (NE_image_segment_entry);\n\t}\n\tif (!bin->segment_entries) {\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, offset, (ut8 *)bin->segment_entries, size);\n\tbin->entry_table = calloc (4, bin->ne_header->EntryTableLength);\n\tif (!bin->entry_table) {\n\t\tR_FREE (bin->segment_entries);\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, (ut64)bin->header_offset + bin->ne_header->EntryTableOffset, bin->entry_table, bin->ne_header->EntryTableLength);\n\tbin->imports = r_bin_ne_get_imports (bin);\n\t__ne_get_resources (bin);\n}","target":0,"code_token_length":588,"total_token_length":824,"max_tokens_setting":1024}
+{"idx":234718,"func":"int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,\n\t\t\tstruct btrfs_ioctl_get_dev_stats *stats)\n{\n\tstruct btrfs_device *dev;\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tint i;\n\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tdev = btrfs_find_device(fs_info->fs_devices, stats->devid, NULL, NULL);\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\tif (!dev) {\n\t\tbtrfs_warn(fs_info, \"get dev_stats failed, device not found\");\n\t\treturn -ENODEV;\n\t} else if (!dev->dev_stats_valid) {\n\t\tbtrfs_warn(fs_info, \"get dev_stats failed, not yet valid\");\n\t\treturn -ENODEV;\n\t} else if (stats->flags & BTRFS_DEV_STATS_RESET) {\n\t\tfor (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) {\n\t\t\tif (stats->nr_items > i)\n\t\t\t\tstats->values[i] =\n\t\t\t\t\tbtrfs_dev_stat_read_and_reset(dev, i);\n\t\t\telse\n\t\t\t\tbtrfs_dev_stat_set(dev, i, 0);\n\t\t}\n\t\tbtrfs_info(fs_info, \"device stats zeroed by %s (%d)\",\n\t\t\t   current->comm, task_pid_nr(current));\n\t} else {\n\t\tfor (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)\n\t\t\tif (stats->nr_items > i)\n\t\t\t\tstats->values[i] = btrfs_dev_stat_read(dev, i);\n\t}\n\tif (stats->nr_items > BTRFS_DEV_STAT_VALUES_MAX)\n\t\tstats->nr_items = BTRFS_DEV_STAT_VALUES_MAX;\n\treturn 0;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":434101,"func":"do_argfile(exarg_T *eap, int argn)\n{\n    int\t\tother;\n    char_u\t*p;\n    int\t\told_arg_idx = curwin->w_arg_idx;\n\n    if (ERROR_IF_ANY_POPUP_WINDOW)\n\treturn;\n    if (argn < 0 || argn >= ARGCOUNT)\n    {\n\tif (ARGCOUNT <= 1)\n\t    emsg(_(\"E163: There is only one file to edit\"));\n\telse if (argn < 0)\n\t    emsg(_(\"E164: Cannot go before first file\"));\n\telse\n\t    emsg(_(\"E165: Cannot go beyond last file\"));\n    }\n    else\n    {\n\tsetpcmark();\n#ifdef FEAT_GUI\n\tneed_mouse_correct = TRUE;\n#endif\n\n\t\/\/ split window or create new tab page first\n\tif (*eap->cmd == 's' || cmdmod.cmod_tab != 0)\n\t{\n\t    if (win_split(0, 0) == FAIL)\n\t\treturn;\n\t    RESET_BINDING(curwin);\n\t}\n\telse\n\t{\n\t    \/\/ if 'hidden' set, only check for changed file when re-editing\n\t    \/\/ the same buffer\n\t    other = TRUE;\n\t    if (buf_hide(curbuf))\n\t    {\n\t\tp = fix_fname(alist_name(&ARGLIST[argn]));\n\t\tother = otherfile(p);\n\t\tvim_free(p);\n\t    }\n\t    if ((!buf_hide(curbuf) || !other)\n\t\t  && check_changed(curbuf, CCGD_AW\n\t\t\t\t\t | (other ? 0 : CCGD_MULTWIN)\n\t\t\t\t\t | (eap->forceit ? CCGD_FORCEIT : 0)\n\t\t\t\t\t | CCGD_EXCMD))\n\t\treturn;\n\t}\n\n\tcurwin->w_arg_idx = argn;\n\tif (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)\n\t    arg_had_last = TRUE;\n\n\t\/\/ Edit the file; always use the last known line number.\n\t\/\/ When it fails (e.g. Abort for already edited file) restore the\n\t\/\/ argument index.\n\tif (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,\n\t\t      eap, ECMD_LAST,\n\t\t      (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)\n\t\t\t + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)\n\t    curwin->w_arg_idx = old_arg_idx;\n\t\/\/ like Vi: set the mark where the cursor is in the file.\n\telse if (eap->cmdidx != CMD_argdo)\n\t    setmark('\\'');\n    }\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":383385,"func":"HWB_Diff (int r1, int g1, int b1, int r2, int g2, int b2)\n{\n  RGBType RGB1, RGB2;\n  HWBType HWB1, HWB2;\n  float diff;\n\n  SETUP_RGB (RGB1, r1, g1, b1);\n  SETUP_RGB (RGB2, r2, g2, b2);\n\n  RGB_to_HWB (RGB1, &HWB1);\n  RGB_to_HWB (RGB2, &HWB2);\n\n  \/*\n   * I made this bit up; it seems to produce OK results, and it is certainly\n   * more visually correct than the current RGB metric. (PJW)\n   *\/\n\n  if ((HWB1.H == HWB_UNDEFINED) || (HWB2.H == HWB_UNDEFINED))\n    {\n      diff = 0.0f;\t\t\t\/* Undefined hues always match... *\/\n    }\n  else\n    {\n      diff = fabsf(HWB1.H - HWB2.H);\n      if (diff > 3.0f)\n\t{\n\t  diff = 6.0f - diff;\t\/* Remember, it's a colour circle *\/\n\t}\n    }\n\n  diff = diff * diff + (HWB1.W - HWB2.W) * (HWB1.W - HWB2.W) + (HWB1.B - HWB2.B) * (HWB1.B - HWB2.B);\n\n  return diff;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":230390,"func":"static int xml_print_node( const pj_xml_node *node, int indent, \n\t\t\t   char *buf, pj_size_t len )\n{\n    int i;\n    char *p = buf;\n    pj_xml_attr *attr;\n    pj_xml_node *sub_node;\n\n#define SIZE_LEFT()\t((int)(len - (p-buf)))\n\n    PJ_CHECK_STACK();\n\n    \/* Print name. *\/\n    if (SIZE_LEFT() < node->name.slen + indent + 5)\n\treturn -1;\n    for (i=0; i<indent; ++i)\n\t*p++ = ' ';\n    *p++ = '<';\n    pj_memcpy(p, node->name.ptr, node->name.slen);\n    p += node->name.slen;\n\n    \/* Print attributes. *\/\n    attr = node->attr_head.next;\n    while (attr != &node->attr_head) {\n\n\tif (SIZE_LEFT() < attr->name.slen + attr->value.slen + 4)\n\t    return -1;\n\n\t*p++ = ' ';\n\n\t\/* Attribute name. *\/\n\tpj_memcpy(p, attr->name.ptr, attr->name.slen);\n\tp += attr->name.slen;\n\n\t\/* Attribute value. *\/\n\tif (attr->value.slen) {\n\t    *p++ = '=';\n\t    *p++ = '\"';\n\t    pj_memcpy(p, attr->value.ptr, attr->value.slen);\n\t    p += attr->value.slen;\n\t    *p++ = '\"';\n\t}\n\n\tattr = attr->next;\n    }\n\n    \/* Check for empty node. *\/\n    if (node->content.slen==0 &&\n\tnode->node_head.next==(pj_xml_node*)&node->node_head)\n    {\n        if (SIZE_LEFT() < 3) return -1;\n\t*p++ = ' ';\n\t*p++ = '\/';\n\t*p++ = '>';\n\treturn (int)(p-buf);\n    }\n\n    \/* Enclosing '>' *\/\n    if (SIZE_LEFT() < 1) return -1;\n    *p++ = '>';\n\n    \/* Print sub nodes. *\/\n    sub_node = node->node_head.next;\n    while (sub_node != (pj_xml_node*)&node->node_head) {\n\tint printed;\n\n\tif (SIZE_LEFT() < indent + 3)\n\t    return -1;\n\t\/\/*p++ = '\\r';\n\t*p++ = '\\n';\n\n\tprinted = xml_print_node(sub_node, indent + 1, p, SIZE_LEFT());\n\tif (printed < 0)\n\t    return -1;\n\n\tp += printed;\n\tsub_node = sub_node->next;\n    }\n\n    \/* Content. *\/\n    if (node->content.slen) {\n\tif (SIZE_LEFT() < node->content.slen) return -1;\n\tpj_memcpy(p, node->content.ptr, node->content.slen);\n\tp += node->content.slen;\n    }\n\n    \/* Enclosing node. *\/\n    if (node->node_head.next != (pj_xml_node*)&node->node_head) {\n\tif (SIZE_LEFT() < node->name.slen + 5 + indent)\n\t    return -1;\n\t\/\/*p++ = '\\r';\n\t*p++ = '\\n';\n\tfor (i=0; i<indent; ++i)\n\t    *p++ = ' ';\n    } else {\n\tif (SIZE_LEFT() < node->name.slen + 3)\n\t    return -1;\n    }\n    *p++ = '<';\n    *p++ = '\/';\n    pj_memcpy(p, node->name.ptr, node->name.slen);\n    p += node->name.slen;\n    *p++ = '>';\n\n#undef SIZE_LEFT\n\n    return (int)(p-buf);\n}","target":0,"code_token_length":755,"total_token_length":991,"max_tokens_setting":1024}
+{"idx":242636,"func":"void isor_declare_pssh(ISOMChannel *ch)\n{\n\tu32 i, PSSH_count;\n\tu8 *psshd;\n\tGF_BitStream *pssh_bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\tu32 s;\n\n\tPSSH_count = gf_isom_get_pssh_count(ch->owner->mov);\n\tgf_bs_write_u32(pssh_bs, PSSH_count);\n\n\t\/*fill PSSH in the structure. We will free it in CENC_Setup*\/\n\tfor (i=0; i<PSSH_count; i++) {\n\t\tbin128 SystemID;\n\t\tu32 version;\n\t\tu32 KID_count;\n\t\tbin128 *KIDs;\n\t\tu32 private_data_size;\n\t\tu8 *private_data;\n\t\tgf_isom_get_pssh_info(ch->owner->mov, i+1, SystemID, &version, &KID_count, (const bin128 **) & KIDs, (const u8 **) &private_data, &private_data_size);\n\n\t\tgf_bs_write_data(pssh_bs, SystemID, 16);\n\t\tgf_bs_write_u32(pssh_bs, version);\n\t\tgf_bs_write_u32(pssh_bs, KID_count);\n\t\tfor (s=0; s<KID_count; s++) {\n\t\t\tgf_bs_write_data(pssh_bs, KIDs[s], 16);\n\t\t}\n\t\tgf_bs_write_u32(pssh_bs, private_data_size);\n\t\tgf_bs_write_data(pssh_bs, private_data, private_data_size);\n\t}\n\tgf_bs_get_content(pssh_bs, &psshd, &s);\n\tgf_bs_del(pssh_bs);\n\tgf_filter_pid_set_property(ch->pid, GF_PROP_PID_CENC_PSSH, & PROP_DATA_NO_COPY(psshd, s) );\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":197326,"func":"  static Status ParseEquation(const string& equation,\n                              OperandLabels* input_labels,\n                              Labels* output_labels,\n                              std::vector<DimensionType>* label_types,\n                              OperandLabelCounts* input_label_counts,\n                              LabelCounts* output_label_counts,\n                              gtl::InlinedVector<bool, 2>* input_has_ellipsis,\n                              bool* output_has_ellipsis) {\n    gtl::InlinedVector<string, 2> input_str;\n    string output_str;\n    TF_RETURN_IF_ERROR(ParseEinsumEquation(equation, &input_str, &output_str));\n\n    \/\/ Temporary map from single character labels to (consecutive) integer\n    \/\/ labels.\n    absl::flat_hash_map<char, int> label_mapping;\n    int num_inputs = input_str.size();\n    input_labels->resize(num_inputs);\n\n    \/\/ Map from single characters to integer labels.\n    for (int i = 0; i < num_inputs; ++i) {\n      MapToLabels(input_str[i], &input_labels->at(i), &label_mapping);\n    }\n    MapToLabels(output_str, output_labels, &label_mapping);\n\n    \/\/ Compute counts for input and output labels.\n    int num_labels = label_mapping.size();\n    input_label_counts->resize(num_inputs);\n    input_has_ellipsis->resize(num_inputs);\n    for (int i = 0; i < num_inputs; ++i) {\n      input_label_counts->at(i).resize(num_labels);\n      for (const int label : input_labels->at(i)) {\n        if (label != kEllipsisLabel)\n          input_label_counts->at(i)[label] += 1;\n        else\n          input_has_ellipsis->at(i) = true;\n      }\n    }\n    output_label_counts->resize(num_labels);\n    for (const int label : *output_labels) {\n      if (label != kEllipsisLabel)\n        output_label_counts->at(label) += 1;\n      else\n        *output_has_ellipsis = true;\n    }\n\n    \/\/ Map each label to a unique DimensionType.\n    label_types->resize(num_labels);\n    for (int label = 0; label < num_labels; ++label) {\n      if (label == kEllipsisLabel) continue;\n      bool removed = (*output_label_counts)[label] == 0;\n      bool unique = num_inputs == 1 || (*input_label_counts)[0][label] == 0 ||\n                    (*input_label_counts)[1][label] == 0;\n      (*label_types)[label] = GetDimensionType(removed, unique);\n    }\n    return Status::OK();\n  }","target":1,"code_token_length":541,"total_token_length":777,"max_tokens_setting":1024}
+{"idx":210619,"func":"u_undo_end(\n    int\t\tdid_undo,\t\/\/ just did an undo\n    int\t\tabsolute)\t\/\/ used \":undo N\"\n{\n    char\t*msgstr;\n    u_header_T\t*uhp;\n    char_u\tmsgbuf[80];\n\n#ifdef FEAT_FOLDING\n    if ((fdo_flags & FDO_UNDO) && KeyTyped)\n\tfoldOpenCursor();\n#endif\n\n    if (global_busy\t    \/\/ no messages now, wait until global is finished\n\t    || !messaging())  \/\/ 'lazyredraw' set, don't do messages now\n\treturn;\n\n    if (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t--u_newcount;\n\n    u_oldcount -= u_newcount;\n    if (u_oldcount == -1)\n\tmsgstr = N_(\"more line\");\n    else if (u_oldcount < 0)\n\tmsgstr = N_(\"more lines\");\n    else if (u_oldcount == 1)\n\tmsgstr = N_(\"line less\");\n    else if (u_oldcount > 1)\n\tmsgstr = N_(\"fewer lines\");\n    else\n    {\n\tu_oldcount = u_newcount;\n\tif (u_newcount == 1)\n\t    msgstr = N_(\"change\");\n\telse\n\t    msgstr = N_(\"changes\");\n    }\n\n    if (curbuf->b_u_curhead != NULL)\n    {\n\t\/\/ For \":undo N\" we prefer a \"after #N\" message.\n\tif (absolute && curbuf->b_u_curhead->uh_next.ptr != NULL)\n\t{\n\t    uhp = curbuf->b_u_curhead->uh_next.ptr;\n\t    did_undo = FALSE;\n\t}\n\telse if (did_undo)\n\t    uhp = curbuf->b_u_curhead;\n\telse\n\t    uhp = curbuf->b_u_curhead->uh_next.ptr;\n    }\n    else\n\tuhp = curbuf->b_u_newhead;\n\n    if (uhp == NULL)\n\t*msgbuf = NUL;\n    else\n\tadd_time(msgbuf, sizeof(msgbuf), uhp->uh_time);\n\n#ifdef FEAT_CONCEAL\n    {\n\twin_T\t*wp;\n\n\tFOR_ALL_WINDOWS(wp)\n\t{\n\t    if (wp->w_buffer == curbuf && wp->w_p_cole > 0)\n\t\tredraw_win_later(wp, NOT_VALID);\n\t}\n    }\n#endif\n\n    smsg_attr_keep(0, _(\"%ld %s; %s #%ld  %s\"),\n\t    u_oldcount < 0 ? -u_oldcount : u_oldcount,\n\t    _(msgstr),\n\t    did_undo ? _(\"before\") : _(\"after\"),\n\t    uhp == NULL ? 0L : uhp->uh_seq,\n\t    msgbuf);\n}","target":1,"code_token_length":573,"total_token_length":809,"max_tokens_setting":1024}
+{"idx":195029,"func":"void Node::RunForwardTypeInference() {\n  VLOG(4) << \"Forward type inference: \" << props_->node_def.DebugString();\n\n  if (props_->fwd_type_fn == nullptr) {\n    return;\n  }\n\n  std::vector<Node*> input_nodes(props_->input_types.size(), nullptr);\n  std::vector<int> input_idx(props_->input_types.size(), 0);\n  for (const auto& edge : in_edges_) {\n    if (edge->IsControlEdge()) {\n      continue;\n    }\n    DCHECK(edge->dst_input() < input_nodes.size()) << DebugString();\n    int i = edge->dst_input();\n    input_nodes.at(i) = edge->src();\n    input_idx.at(i) = edge->src_output();\n  }\n\n  \/\/ Note: technically, we could use a very generic type when some of the inputs\n  \/\/ are unknown. But there is an expectation that a node will have complete\n  \/\/ inputs soon, so updating intermediate types is largely unnecessary.\n\n  for (const auto* node : input_nodes) {\n    if (node == nullptr) {\n      \/\/ Incomplete inputs, bail.\n      ClearTypeInfo();\n      return;\n    }\n  }\n\n  static FullTypeDef* no_type = new FullTypeDef();\n\n  std::vector<std::reference_wrapper<const FullTypeDef>> input_types;\n  for (int i = 0; i < input_nodes.size(); i++) {\n    const auto* node = input_nodes[i];\n    if (node->def().has_experimental_type()) {\n      const auto& node_t = node->def().experimental_type();\n      if (node_t.type_id() != TFT_UNSET) {\n        int ix = input_idx[i];\n        DCHECK(ix < node_t.args_size())\n            << \"input \" << i << \" should have an output \" << ix\n            << \" but instead only has \" << node_t.args_size()\n            << \" outputs: \" << node_t.DebugString();\n        input_types.emplace_back(node_t.args(ix));\n      } else {\n        input_types.emplace_back(*no_type);\n      }\n    } else {\n      \/\/ Incomplete inputs, bail.\n      ClearTypeInfo();\n      return;\n    }\n  }\n\n  const auto infer_type = props_->fwd_type_fn(input_types);\n  const FullTypeDef infer_typedef = infer_type.ValueOrDie();\n  if (infer_typedef.type_id() != TFT_UNSET) {\n    MaybeCopyOnWrite();\n    *(props_->node_def.mutable_experimental_type()) = infer_typedef;\n  }\n}","target":1,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":220437,"func":"mrb_ary_aset(mrb_state *mrb, mrb_value self)\n{\n  mrb_value v1, v2, v3;\n  mrb_int i, len;\n\n  ary_modify(mrb, mrb_ary_ptr(self));\n  if (mrb_get_argc(mrb) == 2) {\n    const mrb_value *vs = mrb_get_argv(mrb);\n    v1 = vs[0]; v2 = vs[1];\n\n    \/* a[n..m] = v *\/\n    switch (mrb_range_beg_len(mrb, v1, &i, &len, RARRAY_LEN(self), FALSE)) {\n    case MRB_RANGE_TYPE_MISMATCH:\n      mrb_ary_set(mrb, self, aget_index(mrb, v1), v2);\n      break;\n    case MRB_RANGE_OK:\n      mrb_ary_splice(mrb, self, i, len, v2);\n      break;\n    case MRB_RANGE_OUT:\n      mrb_raisef(mrb, E_RANGE_ERROR, \"%v out of range\", v1);\n      break;\n    }\n    return v2;\n  }\n\n  mrb_get_args(mrb, \"ooo\", &v1, &v2, &v3);\n  \/* a[n,m] = v *\/\n  mrb_ary_splice(mrb, self, aget_index(mrb, v1), aget_index(mrb, v2), v3);\n  return v3;\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":336642,"func":"SPICE_GNUC_VISIBLE int spice_server_migrate_connect(SpiceServer *reds, const char* dest,\n                                                    int port, int secure_port,\n                                                    const char* cert_subject)\n{\n    SpiceMigrateInterface *sif;\n    int try_seamless;\n\n    spice_debug(\"trace\");\n    spice_assert(reds->migration_interface);\n\n    if (reds->expect_migrate) {\n        spice_debug(\"consecutive calls without migration. Canceling previous call\");\n        reds->main_channel->migrate_src_complete(FALSE);\n    }\n\n    sif = SPICE_UPCAST(SpiceMigrateInterface, reds->migration_interface->base.sif);\n\n    if (!reds_set_migration_dest_info(reds, dest, port, secure_port, cert_subject)) {\n        sif->migrate_connect_complete(reds->migration_interface);\n        return -1;\n    }\n\n    reds->expect_migrate = TRUE;\n\n    \/*\n     * seamless migration support was added to the client after the support in\n     * agent_connect_tokens, so there shouldn't be contradicition - if\n     * the client is capable of seamless migration, it is capbable of agent_connected_tokens.\n     * The demand for agent_connected_tokens support is in order to assure that if migration\n     * occured when the agent was not connected, the tokens state after migration will still\n     * be valid (see reds_reset_vdp for more details).\n     *\/\n    try_seamless = reds->seamless_migration_enabled &&\n                   reds->main_channel->test_remote_cap(SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS);\n    \/* main channel will take care of clients that are still during migration (at target)*\/\n    if (reds->main_channel->migrate_connect(reds->config->mig_spice, try_seamless)) {\n        reds_mig_started(reds);\n    } else {\n        if (reds->clients.empty()) {\n            reds_mig_release(reds->config);\n            spice_debug(\"no client connected\");\n        }\n        sif->migrate_connect_complete(reds->migration_interface);\n    }\n\n    return 0;\n}","target":0,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":427799,"func":"void sev_vm_destroy(struct kvm *kvm)\n{\n\tstruct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;\n\tstruct list_head *head = &sev->regions_list;\n\tstruct list_head *pos, *q;\n\n\tif (!sev_guest(kvm))\n\t\treturn;\n\n\t\/* If this is a mirror_kvm release the enc_context_owner and skip sev cleanup *\/\n\tif (is_mirroring_enc_context(kvm)) {\n\t\tkvm_put_kvm(sev->enc_context_owner);\n\t\treturn;\n\t}\n\n\tmutex_lock(&kvm->lock);\n\n\t\/*\n\t * Ensure that all guest tagged cache entries are flushed before\n\t * releasing the pages back to the system for use. CLFLUSH will\n\t * not do this, so issue a WBINVD.\n\t *\/\n\twbinvd_on_all_cpus();\n\n\t\/*\n\t * if userspace was terminated before unregistering the memory regions\n\t * then lets unpin all the registered memory.\n\t *\/\n\tif (!list_empty(head)) {\n\t\tlist_for_each_safe(pos, q, head) {\n\t\t\t__unregister_enc_region_locked(kvm,\n\t\t\t\tlist_entry(pos, struct enc_region, list));\n\t\t\tcond_resched();\n\t\t}\n\t}\n\n\tmutex_unlock(&kvm->lock);\n\n\tsev_unbind_asid(kvm, sev->handle);\n\tsev_asid_free(sev);\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":259180,"func":"static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n    unsigned i, entries;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n    sc = st->priv_data;\n\n    avio_rb32(pb); \/\/ version + flags\n\n    entries = avio_rb32(pb);\n    if (sc->stps_data)\n        av_log(c->fc, AV_LOG_WARNING, \"Duplicated STPS atom\\n\");\n    av_free(sc->stps_data);\n    sc->stps_count = 0;\n    sc->stps_data = av_malloc_array(entries, sizeof(*sc->stps_data));\n    if (!sc->stps_data)\n        return AVERROR(ENOMEM);\n\n    for (i = 0; i < entries && !pb->eof_reached; i++) {\n        sc->stps_data[i] = avio_rb32(pb);\n    }\n\n    sc->stps_count = i;\n\n    if (pb->eof_reached) {\n        av_log(c->fc, AV_LOG_WARNING, \"reached eof, corrupted STPS atom\\n\");\n        return AVERROR_EOF;\n    }\n\n    return 0;\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":214003,"func":"HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)\n{\n    rfbRREHeader hdr;\n    int i;\n    CARDBPP pix;\n    uint8_t *ptr;\n    int x, y, w, h;\n\n    if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))\n\treturn FALSE;\n\n    hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);\n\n    if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))\n\treturn FALSE;\n\n    client->GotFillRect(client, rx, ry, rw, rh, pix);\n\n    if (hdr.nSubrects * (4 + (BPP \/ 8)) > RFB_BUFFER_SIZE || !ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP \/ 8))))\n\treturn FALSE;\n\n    ptr = (uint8_t *)client->buffer;\n\n    for (i = 0; i < hdr.nSubrects; i++) {\n\tpix = *(CARDBPP *)ptr;\n\tptr += BPP\/8;\n\tx = *ptr++;\n\ty = *ptr++;\n\tw = *ptr++;\n\th = *ptr++;\n\n\tclient->GotFillRect(client, rx+x, ry+y, w, h, pix);\n    }\n\n    return TRUE;\n}","target":1,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":223389,"func":"static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)\n{\nDEFINE_COMPILER;\nstruct sljit_label *loop;\nsljit_s32 i;\n\n\/* At this point we can freely use all temporary registers. *\/\nSLJIT_ASSERT(length > 1);\n\/* TMP1 returns with begin - 1. *\/\nOP2(SLJIT_SUB, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_S0), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, IN_UCHARS(1));\nif (length < 8)\n  {\n  for (i = 1; i < length; i++)\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(i), SLJIT_R0, 0);\n  }\nelse\n  {\n  if (sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_SUPP | SLJIT_MEM_STORE | SLJIT_MEM_PRE, SLJIT_R0, SLJIT_MEM1(SLJIT_R1), sizeof(sljit_sw)) == SLJIT_SUCCESS)\n    {\n    GET_LOCAL_BASE(SLJIT_R1, 0, OVECTOR_START);\n    OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, length - 1);\n    loop = LABEL();\n    sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_STORE | SLJIT_MEM_PRE, SLJIT_R0, SLJIT_MEM1(SLJIT_R1), sizeof(sljit_sw));\n    OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, 1);\n    JUMPTO(SLJIT_NOT_ZERO, loop);\n    }\n  else\n    {\n    GET_LOCAL_BASE(SLJIT_R1, 0, OVECTOR_START + sizeof(sljit_sw));\n    OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, length - 1);\n    loop = LABEL();\n    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R0, 0);\n    OP2(SLJIT_ADD, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, sizeof(sljit_sw));\n    OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, 1);\n    JUMPTO(SLJIT_NOT_ZERO, loop);\n    }\n  }\n}","target":0,"code_token_length":601,"total_token_length":837,"max_tokens_setting":1024}
+{"idx":509508,"func":"bool maria_show_status(handlerton *hton,\n                       THD *thd,\n                       stat_print_fn *print,\n                       enum ha_stat_type stat)\n{\n  const LEX_CSTRING *engine_name= hton_name(hton);\n  switch (stat) {\n  case HA_ENGINE_LOGS:\n  {\n    TRANSLOG_ADDRESS horizon= translog_get_horizon();\n    uint32 last_file= LSN_FILE_NO(horizon);\n    uint32 first_needed= translog_get_first_needed_file();\n    uint32 first_file= translog_get_first_file(horizon);\n    uint32 i;\n    const char unknown[]= \"unknown\";\n    const char needed[]= \"in use\";\n    const char unneeded[]= \"free\";\n    char path[FN_REFLEN];\n\n    if (first_file == 0)\n    {\n      const char error[]= \"error\";\n      print(thd, engine_name->str, engine_name->length,\n            STRING_WITH_LEN(\"\"), error, sizeof(error) - 1);\n      break;\n    }\n\n    for (i= first_file; i <= last_file; i++)\n    {\n      char *file;\n      const char *status;\n      size_t length, status_len;\n      MY_STAT stat_buff, *stat;\n      const char error[]= \"can't stat\";\n      char object[SHOW_MSG_LEN];\n      file= translog_filename_by_fileno(i, path);\n      if (!(stat= mysql_file_stat(key_file_translog, file, &stat_buff, MYF(0))))\n      {\n        status= error;\n        status_len= sizeof(error) - 1;\n        length= my_snprintf(object, SHOW_MSG_LEN, \"Size unknown ; %s\", file);\n      }\n      else\n      {\n        if (first_needed == 0)\n        {\n          status= unknown;\n          status_len= sizeof(unknown) - 1;\n        }\n        else if (i < first_needed)\n        {\n          status= unneeded;\n          status_len= sizeof(unneeded) - 1;\n        }\n        else\n        {\n          status= needed;\n          status_len= sizeof(needed) - 1;\n        }\n        length= my_snprintf(object, SHOW_MSG_LEN, \"Size %12llu ; %s\",\n                            (ulonglong) stat->st_size, file);\n      }\n\n      print(thd, engine_name->str, engine_name->length,\n            object, length, status, status_len);\n    }\n    break;\n  }\n  case HA_ENGINE_STATUS:\n  case HA_ENGINE_MUTEX:\n  default:\n    break;\n  }\n  return 0;\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":231673,"func":"TEST_F(\n    QuicUnencryptedServerTransportTest,\n    TestReceiveClientFinishedFromChangedPeerAddress) {\n  auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);\n  server->getNonConstConn().qLogger = qLogger;\n  recvClientHello();\n\n  folly::SocketAddress newPeer(\"100.101.102.103\", 23456);\n\n  try {\n    recvClientFinished(true, &newPeer);\n  } catch (const std::runtime_error& ex) {\n    EXPECT_EQ(std::string(ex.what()), \"Invalid migration\");\n  }\n  EXPECT_TRUE(server->getConn().localConnectionError);\n  EXPECT_EQ(\n      server->getConn().localConnectionError->second,\n      \"Migration not allowed during handshake\");\n  EXPECT_TRUE(server->isClosed());\n\n  std::vector<int> indices =\n      getQLogEventIndices(QLogEventType::PacketDrop, qLogger);\n  EXPECT_EQ(indices.size(), 1);\n  auto tmp = std::move(qLogger->logs[indices[0]]);\n  auto event = dynamic_cast<QLogPacketDropEvent*>(tmp.get());\n  EXPECT_EQ(event->packetSize, 44);\n  EXPECT_EQ(\n      event->dropReason,\n      QuicTransportStatsCallback::toString(\n          PacketDropReason::PEER_ADDRESS_CHANGE));\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":328826,"func":"R_API char *r_bin_java_unmangle_method(const char *flags, const char *name, const char *params, const char *r_value) {\n\tRList *the_list = params ? r_bin_java_extract_type_values (params) : r_list_new ();\n\tRListIter *iter = NULL;\n\t\/\/ second case removes leading space if no flags are given\n\tconst char *fmt = flags ? \"%s %s %s (%s)\" : \"%s%s %s (%s)\";\n\tchar *str = NULL, *f_val_str = NULL, *r_val_str = NULL, *prototype = NULL, *p_val_str = NULL;\n\tut32 params_idx = 0, params_len = 0, prototype_len = 0;\n\tif (!extract_type_value (r_value, &r_val_str)) {\n\t\tr_list_free (the_list);\n\t\treturn NULL;\n\t}\n\tif (!r_val_str) {\n\t\tr_val_str = strdup (\"UNKNOWN\");\n\t}\n\tf_val_str = strdup (r_str_get (flags));\n\tr_list_foreach (the_list, iter, str) {\n\t\tparams_len += strlen (str);\n\t\tif (params_idx > 0) {\n\t\t\tparams_len += 2;\n\t\t}\n\t\tparams_idx++;\n\t}\n\tif (params_len > 0) {\n\t\tut32 offset = 0;\n\t\tparams_len += 1;\n\t\tp_val_str = malloc (params_len);\n\t\tr_list_foreach (the_list, iter, str) {\n\t\t\tif (offset != 0) {\n\t\t\t\toffset += snprintf (p_val_str + offset, params_len - offset, \", %s\", str);\n\t\t\t} else {\n\t\t\t\toffset += snprintf (p_val_str + offset, params_len - offset, \"%s\", str);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tp_val_str = strdup (\"\");\n\t}\n\n\tprototype_len += (flags ? strlen (flags) + 1 : 0); \/\/ space vs no space\n\tprototype_len += strlen (name) + 1; \/\/ name + space\n\tprototype_len += strlen (r_val_str) + 1; \/\/ r_value + space\n\tprototype_len += strlen (p_val_str) + 3; \/\/ space + l_paren + params + r_paren\n\tprototype_len += 1; \/\/ null\n\tprototype = malloc (prototype_len);\n\t\/\/\/ TODO enable this function and start using it to demangle strings\n\tsnprintf (prototype, prototype_len, fmt, f_val_str, r_val_str, name, p_val_str);\n\tfree (f_val_str);\n\tfree (r_val_str);\n\tfree (p_val_str);\n\tr_list_free (the_list);\n\treturn prototype;\n}","target":0,"code_token_length":561,"total_token_length":797,"max_tokens_setting":1024}
+{"idx":361305,"func":"stl_remove_unconnected_facets(stl_file *stl) {\n  \/* A couple of things need to be done here.  One is to remove any *\/\n  \/* completely unconnected facets (0 edges connected) since these are *\/\n  \/* useless and could be completely wrong.   The second thing that needs to *\/\n  \/* be done is to remove any degenerate facets that were created during *\/\n  \/* stl_check_facets_nearby(). *\/\n\n  int i;\n\n  if (stl->error) return;\n\n  \/* remove degenerate facets *\/\n  for(i = 0; i < stl->stats.number_of_facets; i++) {\n    if(   !memcmp(&stl->facet_start[i].vertex[0],\n                  &stl->facet_start[i].vertex[1], sizeof(stl_vertex))\n          || !memcmp(&stl->facet_start[i].vertex[1],\n                     &stl->facet_start[i].vertex[2], sizeof(stl_vertex))\n          || !memcmp(&stl->facet_start[i].vertex[0],\n                     &stl->facet_start[i].vertex[2], sizeof(stl_vertex))) {\n      stl_remove_degenerate(stl, i);\n      i--;\n    }\n  }\n\n  if(stl->stats.connected_facets_1_edge < stl->stats.number_of_facets) {\n    \/* remove completely unconnected facets *\/\n    for(i = 0; i < stl->stats.number_of_facets; i++) {\n      if(   (stl->neighbors_start[i].neighbor[0] == -1)\n            && (stl->neighbors_start[i].neighbor[1] == -1)\n            && (stl->neighbors_start[i].neighbor[2] == -1)) {\n        \/* This facet is completely unconnected.  Remove it. *\/\n        stl_remove_facet(stl, i);\n        i--;\n      }\n    }\n  }\n}","target":0,"code_token_length":402,"total_token_length":638,"max_tokens_setting":1024}
+{"idx":272369,"func":"void cms_set_pw_data(cms_context *cms, secuPWData *pwdata)\n{\n\tingress();\n\n\tswitch (cms->pwdata.source) {\n\tcase PW_SOURCE_INVALID:\n\tcase PW_PROMPT:\n\tcase PW_DEVICE:\n\tcase PW_SOURCE_MAX:\n\t\tbreak;\n\n\tcase PW_FROMFD:\n\t\tif (cms->pwdata.intdata >= 0 &&\n\t\t    !(pwdata && pwdata->source == PW_FROMFD &&\n\t\t      cms->pwdata.intdata == pwdata->intdata))\n\t\t\tclose(cms->pwdata.intdata);\n\t\tbreak;\n\n\tcase PW_FROMFILEDB:\n\tcase PW_FROMENV:\n\tcase PW_FROMFILE:\n\tcase PW_PLAINTEXT:\n\t\tmemset(cms->pwdata.data, 0, strlen(cms->pwdata.data));\n\t\txfree(cms->pwdata.data);\n\t\tbreak;\n\n\tcase PW_DATABASE:\n\t\txfree(cms->pwdata.data);\n\t\tbreak;\n\t}\n\n\tif (!pwdata) {\n\t\tcms->pwdata.source = PW_SOURCE_INVALID;\n\t\tdprintf(\"pwdata:NULL\");\n\t} else {\n\t\tmemmove(&cms->pwdata, pwdata, sizeof(*pwdata));\n\t\tdprintf(\"pwdata:%p\", pwdata);\n\t\tdprintf(\"pwdata->source:%d\", pwdata->source);\n\t\tdprintf(\"pwdata->data:%p (\\\"%s\\\")\", pwdata->data,\n\t\t\tpwdata->data ? pwdata->data : \"(null)\");\n\t}\n\n\tegress();\n}","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":314536,"func":"static int print_media_desc(const pjmedia_sdp_media *m, char *buf, pj_size_t len)\n{\n    char *p = buf;\n    char *end = buf+len;\n    unsigned i;\n    int printed;\n\n    \/* check length for the \"m=\" line. *\/\n    if (len < (pj_size_t)m->desc.media.slen+m->desc.transport.slen+12+24) {\n\treturn -1;\n    }\n    *p++ = 'm';\t    \/* m= *\/\n    *p++ = '=';\n    pj_memcpy(p, m->desc.media.ptr, m->desc.media.slen);\n    p += m->desc.media.slen;\n    *p++ = ' ';\n    printed = pj_utoa(m->desc.port, p);\n    p += printed;\n    if (m->desc.port_count > 1) {\n\t*p++ = '\/';\n\tprinted = pj_utoa(m->desc.port_count, p);\n\tp += printed;\n    }\n    *p++ = ' ';\n    pj_memcpy(p, m->desc.transport.ptr, m->desc.transport.slen);\n    p += m->desc.transport.slen;\n    for (i=0; i<m->desc.fmt_count; ++i) {\n\tif (end-p > m->desc.fmt[i].slen) {\n\t    *p++ = ' ';\n\t    pj_memcpy(p, m->desc.fmt[i].ptr, m->desc.fmt[i].slen);\n\t    p += m->desc.fmt[i].slen;\n\t} else {\n\t    return -1;\n\t}\n    }\n\n    if (end-p >= 2) {\n\t*p++ = '\\r';\n\t*p++ = '\\n';\n    } else {\n\treturn -1;\n    }\n\n    \/* print connection info, if present. *\/\n    if (m->conn) {\n\tprinted = print_connection_info(m->conn, p, (int)(end-p));\n\tif (printed < 0) {\n\t    return -1;\n\t}\n\tp += printed;\n    }\n    \n    \/* print optional bandwidth info. *\/\n    for (i=0; i<m->bandw_count; ++i) {\n\tprinted = (int)print_bandw(m->bandw[i], p, end-p);\n\tif (printed < 0) {\n\t    return -1;\n\t}\n\tp += printed;\n    }\n\n    \/* print attributes. *\/\n    for (i=0; i<m->attr_count; ++i) {\n\tprinted = (int)print_attr(m->attr[i], p, end-p);\n\tif (printed < 0) {\n\t    return -1;\n\t}\n\tp += printed;\n    }\n\n    return (int)(p-buf);\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":427704,"func":"main(int argc, char *argv[])\n{\n\tint i;\n\tcdf_header_t h;\n\tcdf_sat_t sat, ssat;\n\tcdf_stream_t sst, scn;\n\tcdf_dir_t dir;\n\tcdf_info_t info;\n\tconst cdf_directory_t *root;\n#ifdef __linux__\n#define getprogname() __progname\n\textern char *__progname;\n#endif\n\tif (argc < 2) {\n\t\t(void)fprintf(stderr, \"Usage: %s <filename>\\n\", getprogname());\n\t\treturn -1;\n\t}\n\n\tinfo.i_buf = NULL;\n\tinfo.i_len = 0;\n\tfor (i = 1; i < argc; i++) {\n\t\tif ((info.i_fd = open(argv[1], O_RDONLY)) == -1)\n\t\t\terr(EXIT_FAILURE, \"Cannot open `%s'\", argv[1]);\n\n\t\tif (cdf_read_header(&info, &h) == -1)\n\t\t\terr(EXIT_FAILURE, \"Cannot read header\");\n#ifdef CDF_DEBUG\n\t\tcdf_dump_header(&h);\n#endif\n\n\t\tif (cdf_read_sat(&info, &h, &sat) == -1)\n\t\t\terr(EXIT_FAILURE, \"Cannot read sat\");\n#ifdef CDF_DEBUG\n\t\tcdf_dump_sat(\"SAT\", &sat, CDF_SEC_SIZE(&h));\n#endif\n\n\t\tif (cdf_read_ssat(&info, &h, &sat, &ssat) == -1)\n\t\t\terr(EXIT_FAILURE, \"Cannot read ssat\");\n#ifdef CDF_DEBUG\n\t\tcdf_dump_sat(\"SSAT\", &ssat, CDF_SHORT_SEC_SIZE(&h));\n#endif\n\n\t\tif (cdf_read_dir(&info, &h, &sat, &dir) == -1)\n\t\t\terr(EXIT_FAILURE, \"Cannot read dir\");\n\n\t\tif (cdf_read_short_stream(&info, &h, &sat, &dir, &sst, &root)\n\t\t    == -1)\n\t\t\terr(EXIT_FAILURE, \"Cannot read short stream\");\n#ifdef CDF_DEBUG\n\t\tcdf_dump_stream(&sst);\n#endif\n\n#ifdef CDF_DEBUG\n\t\tcdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);\n#endif\n\n\n\t\tif (cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,\n\t\t    &scn) == -1)\n\t\t\twarn(\"Cannot read summary info\");\n#ifdef CDF_DEBUG\n\t\telse\n\t\t\tcdf_dump_summary_info(&h, &scn);\n#endif\n\t\tif (cdf_read_user_stream(&info, &h, &sat, &ssat, &sst,\n\t\t    &dir, \"Catalog\", &scn) == -1)\n\t\t\twarn(\"Cannot read catalog\");\n#ifdef CDF_DEBUG\n\t\telse\n\t\t\tcdf_dump_catalog(&h, &scn);\n#endif\n\n\t\t(void)close(info.i_fd);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":602,"total_token_length":838,"max_tokens_setting":1024}
+{"idx":317033,"func":"static int selinux_getprocattr(struct task_struct *p,\n\t\t\t       char *name, char **value)\n{\n\tconst struct task_security_struct *__tsec;\n\tu32 sid;\n\tint error;\n\tunsigned len;\n\n\trcu_read_lock();\n\t__tsec = selinux_cred(__task_cred(p));\n\n\tif (current != p) {\n\t\terror = avc_has_perm(&selinux_state,\n\t\t\t\t     current_sid(), __tsec->sid,\n\t\t\t\t     SECCLASS_PROCESS, PROCESS__GETATTR, NULL);\n\t\tif (error)\n\t\t\tgoto bad;\n\t}\n\n\tif (!strcmp(name, \"current\"))\n\t\tsid = __tsec->sid;\n\telse if (!strcmp(name, \"prev\"))\n\t\tsid = __tsec->osid;\n\telse if (!strcmp(name, \"exec\"))\n\t\tsid = __tsec->exec_sid;\n\telse if (!strcmp(name, \"fscreate\"))\n\t\tsid = __tsec->create_sid;\n\telse if (!strcmp(name, \"keycreate\"))\n\t\tsid = __tsec->keycreate_sid;\n\telse if (!strcmp(name, \"sockcreate\"))\n\t\tsid = __tsec->sockcreate_sid;\n\telse {\n\t\terror = -EINVAL;\n\t\tgoto bad;\n\t}\n\trcu_read_unlock();\n\n\tif (!sid)\n\t\treturn 0;\n\n\terror = security_sid_to_context(&selinux_state, sid, value, &len);\n\tif (error)\n\t\treturn error;\n\treturn len;\n\nbad:\n\trcu_read_unlock();\n\treturn error;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":329893,"func":"composite_glyphs (void\t\t\t\t*_dst,\n\t\t  cairo_operator_t\t\t op,\n\t\t  cairo_surface_t\t\t*_src,\n\t\t  int\t\t\t\t src_x,\n\t\t  int\t\t\t\t src_y,\n\t\t  int\t\t\t\t dst_x,\n\t\t  int\t\t\t\t dst_y,\n\t\t  cairo_composite_glyphs_info_t *info)\n{\n    cairo_scaled_glyph_t *glyph_cache[64];\n    pixman_image_t *dst, *src;\n    cairo_status_t status;\n    int i;\n\n    TRACE ((stderr, \"%s\\n\", __FUNCTION__));\n\n    if (info->num_glyphs == 1)\n\treturn composite_one_glyph(_dst, op, _src, src_x, src_y, dst_x, dst_y, info);\n\n    if (info->use_mask)\n\treturn composite_glyphs_via_mask(_dst, op, _src, src_x, src_y, dst_x, dst_y, info);\n\n    op = _pixman_operator (op);\n    dst = to_pixman_image (_dst);\n    src = ((cairo_image_source_t *)_src)->pixman_image;\n\n    memset (glyph_cache, 0, sizeof (glyph_cache));\n    status = CAIRO_STATUS_SUCCESS;\n\n    for (i = 0; i < info->num_glyphs; i++) {\n\tint x, y;\n\tcairo_image_surface_t *glyph_surface;\n\tcairo_scaled_glyph_t *scaled_glyph;\n\tunsigned long glyph_index = info->glyphs[i].index;\n\tint cache_index = glyph_index % ARRAY_LENGTH (glyph_cache);\n\n\tscaled_glyph = glyph_cache[cache_index];\n\tif (scaled_glyph == NULL ||\n\t    _cairo_scaled_glyph_index (scaled_glyph) != glyph_index)\n\t{\n\t    status = _cairo_scaled_glyph_lookup (info->font, glyph_index,\n\t\t\t\t\t\t CAIRO_SCALED_GLYPH_INFO_SURFACE,\n\t\t\t\t\t\t &scaled_glyph);\n\n\t    if (unlikely (status))\n\t\tbreak;\n\n\t    glyph_cache[cache_index] = scaled_glyph;\n\t}\n\n\tglyph_surface = scaled_glyph->surface;\n\tif (glyph_surface->width && glyph_surface->height) {\n\t    \/* round glyph locations to the nearest pixel *\/\n\t    \/* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug? *\/\n\t    x = _cairo_lround (info->glyphs[i].x -\n\t\t\t       glyph_surface->base.device_transform.x0);\n\t    y = _cairo_lround (info->glyphs[i].y -\n\t\t\t       glyph_surface->base.device_transform.y0);\n\n\t    pixman_image_composite32 (op, src, glyph_surface->pixman_image, dst,\n                                      x + src_x,  y + src_y,\n                                      0, 0,\n                                      x - dst_x, y - dst_y,\n\t\t\t\t      glyph_surface->width,\n\t\t\t\t      glyph_surface->height);\n\t}\n    }\n\n    return status;\n}","target":0,"code_token_length":574,"total_token_length":810,"max_tokens_setting":1024}
+{"idx":204351,"func":"bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)\n{\n    SQObjectPtr temp;\n    bool belongs_to_static_table = sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE || bstatic;\n    if(_locked && !belongs_to_static_table)\n        return false; \/\/the class already has an instance so cannot be modified\n    if(_members->Get(key,temp) && _isfield(temp)) \/\/overrides the default value\n    {\n        _defaultvalues[_member_idx(temp)].val = val;\n        return true;\n    }\n    if(belongs_to_static_table) {\n        SQInteger mmidx;\n        if((sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE) &&\n            (mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {\n            _metamethods[mmidx] = val;\n        }\n        else {\n            SQObjectPtr theval = val;\n            if(_base && sq_type(val) == OT_CLOSURE) {\n                theval = _closure(val)->Clone();\n                _closure(theval)->_base = _base;\n                __ObjAddRef(_base); \/\/ref for the closure\n            }\n            if(sq_type(temp) == OT_NULL) {\n                bool isconstructor;\n                SQVM::IsEqual(ss->_constructoridx, key, isconstructor);\n                if(isconstructor) {\n                    _constructoridx = (SQInteger)_methods.size();\n                }\n                SQClassMember m;\n                m.val = theval;\n                _members->NewSlot(key,SQObjectPtr(_make_method_idx(_methods.size())));\n                _methods.push_back(m);\n            }\n            else {\n                _methods[_member_idx(temp)].val = theval;\n            }\n        }\n        return true;\n    }\n    SQClassMember m;\n    m.val = val;\n    _members->NewSlot(key,SQObjectPtr(_make_field_idx(_defaultvalues.size())));\n    _defaultvalues.push_back(m);\n    return true;\n}","target":1,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":247741,"func":"TEST_P(SslSocketTest, TicketSessionResumptionDifferentVerifyCertSpki) {\n  const std::string server_ctx_yaml1 = absl::StrCat(R\"EOF(\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      verify_certificate_spki:\n        - \")EOF\",\n                                                    TEST_SAN_URI_CERT_SPKI, \"\\\"\");\n\n  const std::string server_ctx_yaml2 = absl::StrCat(R\"EOF(\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      verify_certificate_spki:\n        - \"NvqYIYSbgK2vCJpQhObf77vv+bQWtc5ek5RIOwPiC9A=\"\n        - \")EOF\",\n                                                    TEST_SAN_URI_CERT_SPKI, \"\\\"\");\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n)EOF\";\n\n  testTicketSessionResumption(server_ctx_yaml1, {}, server_ctx_yaml1, {}, client_ctx_yaml, true,\n                              GetParam());\n  testTicketSessionResumption(server_ctx_yaml1, {}, server_ctx_yaml2, {}, client_ctx_yaml, false,\n                              GetParam());\n}","target":0,"code_token_length":533,"total_token_length":769,"max_tokens_setting":1024}
+{"idx":385928,"func":"long vfs_truncate(struct path *path, loff_t length)\n{\n\tstruct inode *inode;\n\tlong error;\n\n\tinode = path->dentry->d_inode;\n\n\t\/* For directories it's -EISDIR, for other non-regulars - -EINVAL *\/\n\tif (S_ISDIR(inode->i_mode))\n\t\treturn -EISDIR;\n\tif (!S_ISREG(inode->i_mode))\n\t\treturn -EINVAL;\n\n\terror = mnt_want_write(path->mnt);\n\tif (error)\n\t\tgoto out;\n\n\terror = inode_permission(inode, MAY_WRITE);\n\tif (error)\n\t\tgoto mnt_drop_write_and_out;\n\n\terror = -EPERM;\n\tif (IS_APPEND(inode))\n\t\tgoto mnt_drop_write_and_out;\n\n\terror = get_write_access(inode);\n\tif (error)\n\t\tgoto mnt_drop_write_and_out;\n\n\t\/*\n\t * Make sure that there are no leases.  get_write_access() protects\n\t * against the truncate racing with a lease-granting setlease().\n\t *\/\n\terror = break_lease(inode, O_WRONLY);\n\tif (error)\n\t\tgoto put_write_and_out;\n\n\terror = locks_verify_truncate(inode, NULL, length);\n\tif (!error)\n\t\terror = security_path_truncate(path);\n\tif (!error)\n\t\terror = do_truncate(path->dentry, length, 0, NULL);\n\nput_write_and_out:\n\tput_write_access(inode);\nmnt_drop_write_and_out:\n\tmnt_drop_write(path->mnt);\nout:\n\treturn error;\n}","target":0,"code_token_length":303,"total_token_length":539,"max_tokens_setting":1024}
+{"idx":225505,"func":"Status MutableGraphView::AddSubgraph(GraphDef&& subgraph) {\n  \/\/ 1. Add all new functions and check that functions with the same name\n  \/\/ have identical definition.\n  const int function_size = subgraph.library().function_size();\n  if (function_size > 0) {\n    absl::flat_hash_map<absl::string_view, const FunctionDef*> graph_fdefs;\n    for (const FunctionDef& fdef : graph()->library().function()) {\n      graph_fdefs.emplace(fdef.signature().name(), &fdef);\n    }\n\n    for (FunctionDef& fdef : *subgraph.mutable_library()->mutable_function()) {\n      const auto graph_fdef = graph_fdefs.find(fdef.signature().name());\n\n      if (graph_fdef == graph_fdefs.end()) {\n        VLOG(3) << \"Add new function definition: \" << fdef.signature().name();\n        graph()->mutable_library()->add_function()->Swap(&fdef);\n      } else {\n        if (!FunctionDefsEqual(fdef, *graph_fdef->second)) {\n          return MutationError(\n              \"AddSubgraph\",\n              absl::Substitute(\"function_size=$0\", function_size),\n              absl::StrCat(\n                  \"Found different function definition with the same name: \",\n                  fdef.signature().name()));\n        }\n      }\n    }\n  }\n\n  \/\/ 2. Add all nodes to the underlying graph.\n  int node_size_before = graph()->node_size();\n\n  for (NodeDef& node : *subgraph.mutable_node()) {\n    auto* node_in_graph = graph()->add_node();\n    node_in_graph->Swap(&node);\n    TF_RETURN_IF_ERROR(AddUniqueNode(node_in_graph));\n  }\n\n  \/\/ TODO(ezhulenev, lyandy): Right now AddAndDedupFanouts do not check that\n  \/\/ fanins actually exists in the graph, and there is already TODO for that.\n\n  for (int i = node_size_before; i < graph()->node_size(); ++i) {\n    NodeDef* node = graph()->mutable_node(i);\n    AddAndDedupFanouts(node);\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":451,"total_token_length":687,"max_tokens_setting":1024}
+{"idx":253527,"func":"static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,\n\t\t\t    loff_t off, loff_t len)\n{\n\tint rc;\n\tunsigned int xid;\n\tstruct inode *inode;\n\tstruct cifsFileInfo *cfile = file->private_data;\n\tstruct cifsInodeInfo *cifsi;\n\t__le64 eof;\n\n\txid = get_xid();\n\n\tinode = d_inode(cfile->dentry);\n\tcifsi = CIFS_I(inode);\n\n\tif (off >= i_size_read(inode) ||\n\t    off + len >= i_size_read(inode)) {\n\t\trc = -EINVAL;\n\t\tgoto out;\n\t}\n\n\trc = smb2_copychunk_range(xid, cfile, cfile, off + len,\n\t\t\t\t  i_size_read(inode) - off - len, off);\n\tif (rc < 0)\n\t\tgoto out;\n\n\teof = cpu_to_le64(i_size_read(inode) - len);\n\trc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,\n\t\t\t  cfile->fid.volatile_fid, cfile->pid, &eof);\n\tif (rc < 0)\n\t\tgoto out;\n\n\trc = 0;\n\n\tcifsi->server_eof = i_size_read(inode) - len;\n\ttruncate_setsize(inode, cifsi->server_eof);\n\tfscache_resize_cookie(cifs_inode_cookie(inode), cifsi->server_eof);\n out:\n\tfree_xid(xid);\n\treturn rc;\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":447069,"func":"    long CurlIo::CurlImpl::getFileLength()\n    {\n        curl_easy_reset(curl_); \/\/ reset all options\n        std::string response;\n        curl_easy_setopt(curl_, CURLOPT_URL, path_.c_str());\n        curl_easy_setopt(curl_, CURLOPT_NOBODY, 1); \/\/ HEAD\n        curl_easy_setopt(curl_, CURLOPT_WRITEFUNCTION, curlWriter);\n        curl_easy_setopt(curl_, CURLOPT_WRITEDATA, &response);\n        curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYPEER, 0L);\n        curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYHOST, 0L);\n        curl_easy_setopt(curl_, CURLOPT_CONNECTTIMEOUT, timeout_);\n        \/\/curl_easy_setopt(curl_, CURLOPT_VERBOSE, 1); \/\/ debugging mode\n\n        \/* Perform the request, res will get the return code *\/\n        CURLcode res = curl_easy_perform(curl_);\n        if(res != CURLE_OK) { \/\/ error happends\n            throw Error(1, curl_easy_strerror(res));\n        }\n        \/\/ get return code\n        long returnCode;\n        curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &returnCode); \/\/ get code\n        if (returnCode >= 400 || returnCode < 0) {\n            throw Error(55, \"Server\", returnCode);\n        }\n        \/\/ get length\n        double temp;\n        curl_easy_getinfo(curl_, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &temp); \/\/ return -1 if unknown\n        return (long) temp;\n    }","target":0,"code_token_length":308,"total_token_length":544,"max_tokens_setting":1024}
+{"idx":301467,"func":"suggest_try_change(suginfo_T *su)\n{\n    char_u\tfword[MAXWLEN];\t    \/\/ copy of the bad word, case-folded\n    int\t\tn;\n    char_u\t*p;\n    int\t\tlpi;\n    langp_T\t*lp;\n\n    \/\/ We make a copy of the case-folded bad word, so that we can modify it\n    \/\/ to find matches (esp. REP items).  Append some more text, changing\n    \/\/ chars after the bad word may help.\n    STRCPY(fword, su->su_fbadword);\n    n = (int)STRLEN(fword);\n    p = su->su_badptr + su->su_badlen;\n    (void)spell_casefold(curwin, p, (int)STRLEN(p), fword + n, MAXWLEN - n);\n\n    \/\/ Make sure the resulting text is not longer than the original text.\n    n = (int)STRLEN(su->su_badptr);\n    if (n < MAXWLEN)\n\tfword[n] = NUL;\n\n    for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)\n    {\n\tlp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);\n\n\t\/\/ If reloading a spell file fails it's still in the list but\n\t\/\/ everything has been cleared.\n\tif (lp->lp_slang->sl_fbyts == NULL)\n\t    continue;\n\n\t\/\/ Try it for this language.  Will add possible suggestions.\n#ifdef SUGGEST_PROFILE\n\tprof_init();\n#endif\n\tsuggest_trie_walk(su, lp, fword, FALSE);\n#ifdef SUGGEST_PROFILE\n\tprof_report(\"try_change\");\n#endif\n    }\n}","target":0,"code_token_length":372,"total_token_length":608,"max_tokens_setting":1024}
+{"idx":413627,"func":"R_API void r_core_anal_datarefs(RCore *core, ut64 addr) {\n\tRAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, -1);\n\tif (fcn) {\n\t\tbool found = false;\n\t\tconst char *me = fcn->name;\n\t\tRListIter *iter;\n\t\tRAnalRef *ref;\n\t\tRList *refs = r_anal_function_get_refs (fcn);\n\t\tr_list_foreach (refs, iter, ref) {\n\t\t\tRBinObject *obj = r_bin_cur_object (core->bin);\n\t\t\tRBinSection *binsec = r_bin_get_section_at (obj, ref->addr, true);\n\t\t\tif (binsec && binsec->is_data) {\n\t\t\t\tif (!found) {\n\t\t\t\t\tr_cons_printf (\"agn %s\\n\", me);\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t\tRFlagItem *item = r_flag_get_i (core->flags, ref->addr);\n\t\t\t\tr_strf_buffer (32);\n\t\t\t\tconst char *dst = item? item->name: r_strf (\"0x%08\"PFMT64x, ref->addr);\n\t\t\t\tr_cons_printf (\"agn %s\\n\", dst);\n\t\t\t\tr_cons_printf (\"age %s %s\\n\", me, dst);\n\t\t\t}\n\t\t}\n\t\tr_list_free (refs);\n\t} else {\n\t\teprintf (\"Not in a function. Use 'df' to define it.\\n\");\n\t}\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":452384,"func":"static MagickBooleanType GetTIFFInfo(const ImageInfo *image_info,TIFF *tiff,\n  TIFFInfo *tiff_info)\n{\n#define TIFFStripSizeDefault  1048576\n\n  const char\n    *option;\n\n  MagickStatusType\n    flags;\n\n  uint32\n    tile_columns,\n    tile_rows;\n\n  assert(tiff_info != (TIFFInfo *) NULL);\n  (void) memset(tiff_info,0,sizeof(*tiff_info));\n  option=GetImageOption(image_info,\"tiff:tile-geometry\");\n  if (option == (const char *) NULL)\n    {\n      size_t\n        extent;\n\n      uint32\n        rows = 0,\n        rows_per_strip = 0;\n\n      extent=TIFFScanlineSize(tiff);\n      rows_per_strip=TIFFStripSizeDefault\/(extent == 0 ? 1 : (uint32) extent);\n      rows_per_strip=16*(((rows_per_strip < 16 ? 16 : rows_per_strip)+1)\/16);\n      (void) TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&rows);\n      if (rows_per_strip > rows)\n        rows_per_strip=rows;\n      option=GetImageOption(image_info,\"tiff:rows-per-strip\");\n      if (option != (const char *) NULL)\n        rows_per_strip=(uint32) strtoul(option,(char **) NULL,10);\n      rows_per_strip=TIFFDefaultStripSize(tiff,rows_per_strip);\n      (void) TIFFSetField(tiff,TIFFTAG_ROWSPERSTRIP,rows_per_strip);\n      return(MagickTrue);\n    }\n  flags=ParseAbsoluteGeometry(option,&tiff_info->tile_geometry);\n  if ((flags & HeightValue) == 0)\n    tiff_info->tile_geometry.height=tiff_info->tile_geometry.width;\n  tile_columns=(uint32) tiff_info->tile_geometry.width;\n  tile_rows=(uint32) tiff_info->tile_geometry.height;\n  TIFFDefaultTileSize(tiff,&tile_columns,&tile_rows);\n  (void) TIFFSetField(tiff,TIFFTAG_TILEWIDTH,tile_columns);\n  (void) TIFFSetField(tiff,TIFFTAG_TILELENGTH,tile_rows);\n  tiff_info->tile_geometry.width=tile_columns;\n  tiff_info->tile_geometry.height=tile_rows;\n  if ((TIFFScanlineSize(tiff) <= 0) || (TIFFTileSize(tiff) <= 0))\n    {\n      DestroyTIFFInfo(tiff_info);\n      return(MagickFalse);\n    }\n  tiff_info->scanlines=(unsigned char *) AcquireQuantumMemory((size_t)\n    tile_rows*TIFFScanlineSize(tiff),sizeof(*tiff_info->scanlines));\n  tiff_info->pixels=(unsigned char *) AcquireQuantumMemory((size_t)\n    tile_rows*TIFFTileSize(tiff),sizeof(*tiff_info->scanlines));\n  if ((tiff_info->scanlines == (unsigned char *) NULL) ||\n      (tiff_info->pixels == (unsigned char *) NULL))\n    {\n      DestroyTIFFInfo(tiff_info);\n      return(MagickFalse);\n    }\n  return(MagickTrue);\n}","target":0,"code_token_length":688,"total_token_length":924,"max_tokens_setting":1024}
+{"idx":256995,"func":"static int route4_set_parms(struct net *net, struct tcf_proto *tp,\n\t\t\t    unsigned long base, struct route4_filter *f,\n\t\t\t    u32 handle, struct route4_head *head,\n\t\t\t    struct nlattr **tb, struct nlattr *est, int new,\n\t\t\t    u32 flags, struct netlink_ext_ack *extack)\n{\n\tu32 id = 0, to = 0, nhandle = 0x8000;\n\tstruct route4_filter *fp;\n\tunsigned int h1;\n\tstruct route4_bucket *b;\n\tint err;\n\n\terr = tcf_exts_validate(net, tp, tb, est, &f->exts, flags, extack);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (tb[TCA_ROUTE4_TO]) {\n\t\tif (new && handle & 0x8000)\n\t\t\treturn -EINVAL;\n\t\tto = nla_get_u32(tb[TCA_ROUTE4_TO]);\n\t\tif (to > 0xFF)\n\t\t\treturn -EINVAL;\n\t\tnhandle = to;\n\t}\n\n\tif (tb[TCA_ROUTE4_FROM]) {\n\t\tif (tb[TCA_ROUTE4_IIF])\n\t\t\treturn -EINVAL;\n\t\tid = nla_get_u32(tb[TCA_ROUTE4_FROM]);\n\t\tif (id > 0xFF)\n\t\t\treturn -EINVAL;\n\t\tnhandle |= id << 16;\n\t} else if (tb[TCA_ROUTE4_IIF]) {\n\t\tid = nla_get_u32(tb[TCA_ROUTE4_IIF]);\n\t\tif (id > 0x7FFF)\n\t\t\treturn -EINVAL;\n\t\tnhandle |= (id | 0x8000) << 16;\n\t} else\n\t\tnhandle |= 0xFFFF << 16;\n\n\tif (handle && new) {\n\t\tnhandle |= handle & 0x7F00;\n\t\tif (nhandle != handle)\n\t\t\treturn -EINVAL;\n\t}\n\n\th1 = to_hash(nhandle);\n\tb = rtnl_dereference(head->table[h1]);\n\tif (!b) {\n\t\tb = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL);\n\t\tif (b == NULL)\n\t\t\treturn -ENOBUFS;\n\n\t\trcu_assign_pointer(head->table[h1], b);\n\t} else {\n\t\tunsigned int h2 = from_hash(nhandle >> 16);\n\n\t\tfor (fp = rtnl_dereference(b->ht[h2]);\n\t\t     fp;\n\t\t     fp = rtnl_dereference(fp->next))\n\t\t\tif (fp->handle == f->handle)\n\t\t\t\treturn -EEXIST;\n\t}\n\n\tif (tb[TCA_ROUTE4_TO])\n\t\tf->id = to;\n\n\tif (tb[TCA_ROUTE4_FROM])\n\t\tf->id = to | id<<16;\n\telse if (tb[TCA_ROUTE4_IIF])\n\t\tf->iif = id;\n\n\tf->handle = nhandle;\n\tf->bkt = b;\n\tf->tp = tp;\n\n\tif (tb[TCA_ROUTE4_CLASSID]) {\n\t\tf->res.classid = nla_get_u32(tb[TCA_ROUTE4_CLASSID]);\n\t\ttcf_bind_filter(tp, &f->res, base);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":676,"total_token_length":912,"max_tokens_setting":1024}
+{"idx":454751,"func":"static int ismt_process_desc(const struct ismt_desc *desc,\n\t\t\t     union i2c_smbus_data *data,\n\t\t\t     struct ismt_priv *priv, int size,\n\t\t\t     char read_write)\n{\n\tu8 *dma_buffer = PTR_ALIGN(&priv->buffer[0], 16);\n\n\tdev_dbg(&priv->pci_dev->dev, \"Processing completed descriptor\\n\");\n\t__ismt_desc_dump(&priv->pci_dev->dev, desc);\n\tismt_gen_reg_dump(priv);\n\tismt_mstr_reg_dump(priv);\n\n\tif (desc->status & ISMT_DESC_SCS) {\n\t\tif (read_write == I2C_SMBUS_WRITE &&\n\t\t    size != I2C_SMBUS_PROC_CALL &&\n\t\t    size != I2C_SMBUS_BLOCK_PROC_CALL)\n\t\t\treturn 0;\n\n\t\tswitch (size) {\n\t\tcase I2C_SMBUS_BYTE:\n\t\tcase I2C_SMBUS_BYTE_DATA:\n\t\t\tdata->byte = dma_buffer[0];\n\t\t\tbreak;\n\t\tcase I2C_SMBUS_WORD_DATA:\n\t\tcase I2C_SMBUS_PROC_CALL:\n\t\t\tdata->word = dma_buffer[0] | (dma_buffer[1] << 8);\n\t\t\tbreak;\n\t\tcase I2C_SMBUS_BLOCK_DATA:\n\t\tcase I2C_SMBUS_BLOCK_PROC_CALL:\n\t\t\tif (desc->rxbytes != dma_buffer[0] + 1)\n\t\t\t\treturn -EMSGSIZE;\n\n\t\t\tmemcpy(data->block, dma_buffer, desc->rxbytes);\n\t\t\tbreak;\n\t\tcase I2C_SMBUS_I2C_BLOCK_DATA:\n\t\t\tmemcpy(&data->block[1], dma_buffer, desc->rxbytes);\n\t\t\tdata->block[0] = desc->rxbytes;\n\t\t\tbreak;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tif (likely(desc->status & ISMT_DESC_NAK))\n\t\treturn -ENXIO;\n\n\tif (desc->status & ISMT_DESC_CRC)\n\t\treturn -EBADMSG;\n\n\tif (desc->status & ISMT_DESC_COL)\n\t\treturn -EAGAIN;\n\n\tif (desc->status & ISMT_DESC_LPR)\n\t\treturn -EPROTO;\n\n\tif (desc->status & (ISMT_DESC_DLTO | ISMT_DESC_CLTO))\n\t\treturn -ETIMEDOUT;\n\n\treturn -EIO;\n}","target":0,"code_token_length":481,"total_token_length":717,"max_tokens_setting":1024}
+{"idx":195038,"func":"mrb_ary_shift_m(mrb_state *mrb, mrb_value self)\n{\n  struct RArray *a = mrb_ary_ptr(self);\n  mrb_int len = ARY_LEN(a);\n  mrb_int n;\n  mrb_value val;\n\n  if (mrb_get_args(mrb, \"|i\", &n) == 0) {\n    return mrb_ary_shift(mrb, self);\n  };\n  ary_modify_check(mrb, a);\n  if (len == 0 || n == 0) return mrb_ary_new(mrb);\n  if (n < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, \"negative array shift\");\n  if (n > len) n = len;\n  val = mrb_ary_new_from_values(mrb, n, ARY_PTR(a));\n  if (ARY_SHARED_P(a)) {\n  L_SHIFT:\n    a->as.heap.ptr+=n;\n    a->as.heap.len-=n;\n    return val;\n  }\n  if (len > ARY_SHIFT_SHARED_MIN) {\n    ary_make_shared(mrb, a);\n    goto L_SHIFT;\n  }\n  else if (len == n) {\n    ARY_SET_LEN(a, 0);\n  }\n  else {\n    mrb_value *ptr = ARY_PTR(a);\n    mrb_int size = len-n;\n\n    while (size--) {\n      *ptr = *(ptr+n);\n      ++ptr;\n    }\n    ARY_SET_LEN(a, len-n);\n  }\n  return val;\n}","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":209927,"func":"static void agent_connect(UdscsConnection *conn)\n{\n    struct agent_data *agent_data;\n    agent_data = g_new0(struct agent_data, 1);\n    GError *err = NULL;\n\n    if (session_info) {\n        PidUid pid_uid = vdagent_connection_get_peer_pid_uid(VDAGENT_CONNECTION(conn), &err);\n        if (err || pid_uid.pid <= 0) {\n            static const char msg[] = \"Could not get peer PID, disconnecting new client\";\n            if (err) {\n                syslog(LOG_ERR, \"%s: %s\", msg, err->message);\n                g_error_free(err);\n            } else {\n                syslog(LOG_ERR, \"%s\", msg);\n            }\n            agent_data_destroy(agent_data);\n            udscs_server_destroy_connection(server, conn);\n            return;\n        }\n\n        agent_data->session = session_info_session_for_pid(session_info, pid_uid.pid);\n\n        uid_t session_uid = session_info_uid_for_session(session_info, agent_data->session);\n\n        \/* Check that the UID of the PID did not change, this should be done after\n         * computing the session to avoid race conditions.\n         * This can happen as vdagent_connection_get_peer_pid_uid get information\n         * from the time of creating the socket, but the process in the meantime\n         * have been replaced *\/\n        if (!check_uid_of_pid(pid_uid.pid, pid_uid.uid) ||\n            \/* Check that the user launching the Agent is the same as session one\n             * or root user.\n             * This prevents session hijacks from other users. *\/\n            (pid_uid.uid != 0 && pid_uid.uid != session_uid)) {\n            syslog(LOG_ERR, \"UID mismatch: UID=%u PID=%u suid=%u\", pid_uid.uid,\n                   pid_uid.pid, session_uid);\n            agent_data_destroy(agent_data);\n            udscs_server_destroy_connection(server, conn);\n            return;\n        }\n    }\n\n    g_object_set_data_full(G_OBJECT(conn), \"agent_data\", agent_data,\n                           (GDestroyNotify) agent_data_destroy);\n    udscs_write(conn, VDAGENTD_VERSION, 0, 0,\n                (uint8_t *)VERSION, strlen(VERSION) + 1);\n    update_active_session_connection(conn);\n\n    if (device_info) {\n        forward_data_to_session_agent(VDAGENTD_GRAPHICS_DEVICE_INFO,\n                                      (uint8_t *) device_info, device_info_size);\n    }\n}","target":1,"code_token_length":509,"total_token_length":745,"max_tokens_setting":1024}
+{"idx":390517,"func":"SetKeyExplicit(XkbSrvInfoPtr xkbi,xkbSetMapReq *req,CARD8 *wire,\n\t\t\t\t\t\t\tXkbChangesPtr changes)\n{\nregister unsigned\ti,first,last;\nXkbServerMapPtr\t\txkb = xkbi->desc->server;\nCARD8 *\t\t\tstart;\n\n    start= wire;\n    first= req->firstKeyExplicit;\n    last=  req->firstKeyExplicit+req->nKeyExplicit-1;\n    bzero(&xkb->explicit[first],req->nKeyExplicit);\n    for (i=0;i<req->totalKeyExplicit;i++,wire+= 2) {\n\txkb->explicit[wire[0]]= wire[1];\n    }\n    if (first>0) {\n\tif (changes->map.changed&XkbExplicitComponentsMask) {\n\t    int oldLast;\n\t    oldLast= changes->map.first_key_explicit+\n\t\t\t\t\tchanges->map.num_key_explicit-1;\n\t    if (changes->map.first_key_explicit<first)\n\t\tfirst= changes->map.first_key_explicit;\n\t    if (oldLast>last)\n\t\tlast= oldLast;\n\t}\n\tchanges->map.first_key_explicit= first;\n\tchanges->map.num_key_explicit= (last-first)+1;\n    }\n    wire+= XkbPaddedSize(wire-start)-(wire-start);\n    return (char *)wire;\n}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":216515,"func":"int ssl3_get_new_session_ticket(SSL *s)\n{\n    int ok, al, ret = 0, ticklen;\n    long n;\n    const unsigned char *p;\n    unsigned char *d;\n\n    n = s->method->ssl_get_message(s,\n                                   SSL3_ST_CR_SESSION_TICKET_A,\n                                   SSL3_ST_CR_SESSION_TICKET_B,\n                                   SSL3_MT_NEWSESSION_TICKET, 16384, &ok);\n\n    if (!ok)\n        return ((int)n);\n\n    if (n < 6) {\n        \/* need at least ticket_lifetime_hint + ticket length *\/\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n\n    p = d = (unsigned char *)s->init_msg;\n    n2l(p, s->session->tlsext_tick_lifetime_hint);\n    n2s(p, ticklen);\n    \/* ticket_lifetime_hint + ticket_length + ticket *\/\n    if (ticklen + 6 != n) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n    if (s->session->tlsext_tick) {\n        OPENSSL_free(s->session->tlsext_tick);\n        s->session->tlsext_ticklen = 0;\n    }\n    s->session->tlsext_tick = OPENSSL_malloc(ticklen);\n    if (!s->session->tlsext_tick) {\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    memcpy(s->session->tlsext_tick, p, ticklen);\n    s->session->tlsext_ticklen = ticklen;\n    \/*\n     * There are two ways to detect a resumed ticket session. One is to set\n     * an appropriate session ID and then the server must return a match in\n     * ServerHello. This allows the normal client session ID matching to work\n     * and we know much earlier that the ticket has been accepted. The\n     * other way is to set zero length session ID when the ticket is\n     * presented and rely on the handshake to determine session resumption.\n     * We choose the former approach because this fits in with assumptions\n     * elsewhere in OpenSSL. The session ID is set to the SHA256 (or SHA1 is\n     * SHA256 is disabled) hash of the ticket.\n     *\/\n    EVP_Digest(p, ticklen,\n               s->session->session_id, &s->session->session_id_length,\n# ifndef OPENSSL_NO_SHA256\n               EVP_sha256(), NULL);\n# else\n               EVP_sha1(), NULL);\n# endif\n    ret = 1;\n    return (ret);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    s->state = SSL_ST_ERR;\n    return (-1);\n}","target":1,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":338074,"func":"void WasmBinaryBuilder::pushBlockElements(Block* curr,\n                                          Type type,\n                                          size_t start) {\n  assert(start <= expressionStack.size());\n  \/\/ The results of this block are the last values pushed to the expressionStack\n  Expression* results = nullptr;\n  if (type.isConcrete()) {\n    results = popTypedExpression(type);\n  }\n  if (expressionStack.size() < start) {\n    throwError(\"Block requires more values than are available\");\n  }\n  \/\/ Everything else on the stack after `start` is either a none-type expression\n  \/\/ or a concretely-type expression that is implicitly dropped due to\n  \/\/ unreachability at the end of the block, like this:\n  \/\/\n  \/\/  block i32\n  \/\/   i32.const 1\n  \/\/   i32.const 2\n  \/\/   i32.const 3\n  \/\/   return\n  \/\/  end\n  \/\/\n  \/\/ The first two const elements will be emitted as drops in the block (the\n  \/\/ optimizer can remove them, of course, but in general we may need dropped\n  \/\/ items here as they may have side effects).\n  \/\/\n  for (size_t i = start; i < expressionStack.size(); ++i) {\n    auto* item = expressionStack[i];\n    if (item->type.isConcrete()) {\n      item = Builder(wasm).makeDrop(item);\n    }\n    curr->list.push_back(item);\n  }\n  expressionStack.resize(start);\n  if (results != nullptr) {\n    curr->list.push_back(results);\n  }\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":432279,"func":"MemTxResult flatview_read_continue(struct uc_struct *uc, FlatView *fv, hwaddr addr,\n                                   MemTxAttrs attrs, void *ptr,\n                                   hwaddr len, hwaddr addr1, hwaddr l,\n                                   MemoryRegion *mr)\n{\n    uint8_t *ram_ptr;\n    uint64_t val;\n    MemTxResult result = MEMTX_OK;\n    bool release_lock = false;\n    uint8_t *buf = ptr;\n\n    for (;;) {\n        if (!memory_access_is_direct(mr, false)) {\n            \/* I\/O case *\/\n            release_lock |= prepare_mmio_access(mr);\n            l = memory_access_size(mr, l, addr1);\n            result |= memory_region_dispatch_read(uc, mr, addr1, &val,\n                                                  size_memop(l), attrs);\n            stn_he_p(buf, l, val);\n        } else {\n            \/* RAM case *\/\n            ram_ptr = qemu_ram_ptr_length(fv->root->uc, mr->ram_block, addr1, &l, false);\n            memcpy(buf, ram_ptr, l);\n        }\n\n        if (release_lock) {\n            release_lock = false;\n        }\n\n        len -= l;\n        buf += l;\n        addr += l;\n\n        if (!len) {\n            break;\n        }\n\n        l = len;\n        mr = flatview_translate(uc, fv, addr, &addr1, &l, false, attrs);\n    }\n\n    return result;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":219962,"func":"int callback_glewlwyd_set_user (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_user, * j_user_valid, * j_search_user;\n  \n  j_search_user = get_user(config, u_map_get(request->map_url, \"username\"), u_map_get(request->map_url, \"source\"));\n  if (check_result_value(j_search_user, G_OK)) {\n    j_user = ulfius_get_json_body_request(request, NULL);\n    if (j_user != NULL) {\n      j_user_valid = is_user_valid(config, u_map_get(request->map_url, \"username\"), j_user, 0, json_string_value(json_object_get(json_object_get(j_search_user, \"user\"), \"source\")));\n      if (check_result_value(j_user_valid, G_OK)) {\n        if (set_user(config, u_map_get(request->map_url, \"username\"), j_user, json_string_value(json_object_get(json_object_get(j_search_user, \"user\"), \"source\"))) != G_OK) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_user - Error set_user\");\n          response->status = 500;\n        } else {\n          y_log_message(Y_LOG_LEVEL_INFO, \"Event - User '%s' updated\", u_map_get(request->map_url, \"username\"));\n        }\n      } else if (check_result_value(j_user_valid, G_ERROR_PARAM)) {\n        if (json_object_get(j_user_valid, \"error\") != NULL) {\n          ulfius_set_json_body_response(response, 400, json_object_get(j_user_valid, \"error\"));\n        } else {\n          response->status = 400;\n        }\n      } else if (!check_result_value(j_user_valid, G_OK)) {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_user - Error is_user_valid\");\n        response->status = 500;\n      }\n      json_decref(j_user_valid);\n    } else {\n      response->status = 400;\n    }\n    json_decref(j_user);\n  } else if (check_result_value(j_search_user, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_set_user - Error get_user\");\n    response->status = 500;\n  }\n  json_decref(j_search_user);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":197801,"func":"bool TensorSliceReader::CopySliceData(const string& name,\n                                      const TensorSlice& slice, T* data) const {\n  std::vector<std::pair<TensorSlice, string>> details;\n  const TensorSliceSet* tss;\n  {\n    mutex_lock l(mu_);\n    tss = FindTensorSlice(name, slice, &details);\n    if (!tss && !all_shards_loaded_) {\n      VLOG(1) << \"Did not find slice in preferred shard, loading all shards.\"\n              << name << \": \" << slice.DebugString();\n      LoadAllShards();\n      tss = FindTensorSlice(name, slice, &details);\n    }\n    if (!tss) {\n      \/\/ No such tensor\n      return false;\n    }\n  }\n  \/\/ We have the data -- copy it over.\n  string value;\n  for (const auto& x : details) {\n    const TensorSlice& slice_s = x.first;\n    const string& fname = x.second;\n    int idx = gtl::FindWithDefault(fname_to_index_, fname, -1);\n    CHECK_GE(idx, 0) << \"Failed to find the index for filename \" << fname;\n    \/\/ We read a record in the corresponding sstable\n    const string key = EncodeTensorNameSlice(name, slice_s);\n    if (!sss_[idx]->Get(key, &value)) {\n      VLOG(1) << \"Failed to seek to the record for tensor \" << name\n              << \", slice \" << slice_s.DebugString()\n              << \": computed key = \" << key;\n      return false;\n    }\n    SavedTensorSlices sts;\n    if (!ParseProtoUnlimited(&sts, value)) {\n      VLOG(1) << \"Failed to parse the record for tensor \" << name << \", slice \"\n              << slice_s.DebugString() << \": computed key = \" << key;\n      return false;\n    }\n    CopyDataFromTensorSliceToTensorSlice(\n        tss->shape(), slice_s, slice,\n        checkpoint::TensorProtoData<T>(sts.data().data()), data);\n  }\n  return true;\n}","target":1,"code_token_length":439,"total_token_length":675,"max_tokens_setting":1024}
+{"idx":226298,"func":"\nGF_Err leva_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_LevelAssignmentBox *ptr = (GF_LevelAssignmentBox*)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u8(bs, ptr->level_count);\n\tfor (i = 0; i<ptr->level_count; i++) {\n\t\tgf_bs_write_u32(bs, ptr->levels[i].track_id);\n\t\tgf_bs_write_u8(bs, ptr->levels[i].padding_flag << 7 | (ptr->levels[i].type & 0x7F));\n\t\tif (ptr->levels[i].type == 0) {\n\t\t\tgf_bs_write_u32(bs, ptr->levels[i].grouping_type);\n\t\t}\n\t\telse if (ptr->levels[i].type == 1) {\n\t\t\tgf_bs_write_u32(bs, ptr->levels[i].grouping_type);\n\t\t\tgf_bs_write_u32(bs, ptr->levels[i].grouping_type_parameter);\n\t\t}\n\t\telse if (ptr->levels[i].type == 4) {\n\t\t\tgf_bs_write_u32(bs, ptr->levels[i].sub_track_id);\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":219913,"func":"GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text)\n{\n\tGF_UserDataMap *map;\n\tGF_RTPBox *rtp;\n\tGF_Err e;\n\tGF_HintTrackInfoBox *hnti;\n\tchar *buf;\n\n\tif (!movie->moov) return GF_BAD_PARAM;\n\n\t\/\/check if we have a udta ...\n\tif (!movie->moov->udta) {\n\t\te = moov_on_child_box((GF_Box*)movie->moov, gf_isom_box_new_parent(&movie->moov->child_boxes, GF_ISOM_BOX_TYPE_UDTA), GF_FALSE);\n\t\tif (e) return e;\n\t}\n\t\/\/find a hnti in the udta\n\tmap = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);\n\tif (!map) {\n\t\te = udta_on_child_box((GF_Box *)movie->moov->udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE);\n\t\tif (e) return e;\n\t\tmap = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);\n\t}\n\n\t\/\/there should be one and only one hnti\n\tif (!gf_list_count(map->boxes) ) {\n\t\te = udta_on_child_box((GF_Box *)movie->moov->udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE);\n\t\tif (e) return e;\n\t}\n\telse if (gf_list_count(map->boxes) < 1) return GF_ISOM_INVALID_FILE;\n\n\thnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0);\n\n\tif (!hnti->SDP) {\n\t\tGF_Box *a = gf_isom_box_new_ex(GF_ISOM_BOX_TYPE_RTP, GF_ISOM_BOX_TYPE_HNTI, 0, GF_FALSE);\n\t\tif (!a) return GF_OUT_OF_MEM;\n\t\thnti_on_child_box((GF_Box*)hnti, a, GF_FALSE);\n\t\tif (!hnti->child_boxes) hnti->child_boxes = gf_list_new();\n\t\tgf_list_add(hnti->child_boxes, a);\n\t}\n\trtp = (GF_RTPBox *) hnti->SDP;\n\n\tif (!rtp->sdpText) {\n\t\trtp->sdpText = (char*)gf_malloc(sizeof(char) * (strlen(text) + 3));\n\t\tif (!rtp->sdpText) return GF_OUT_OF_MEM;\n\n\t\tstrcpy(rtp->sdpText, text);\n\t\tstrcat(rtp->sdpText, \"\\r\\n\");\n\t\treturn GF_OK;\n\t}\n\tbuf = (char*)gf_malloc(sizeof(char) * (strlen(rtp->sdpText) + strlen(text) + 3));\n\tif (!buf) return GF_OUT_OF_MEM;\n\t\n\tstrcpy(buf, rtp->sdpText);\n\tstrcat(buf, text);\n\tstrcat(buf, \"\\r\\n\");\n\tgf_free(rtp->sdpText);\n\tReorderSDP(buf, GF_TRUE);\n\trtp->sdpText = buf;\n\treturn GF_OK;\n}","target":0,"code_token_length":685,"total_token_length":921,"max_tokens_setting":1024}
+{"idx":244305,"func":"GF_Err csgp_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tGF_CompactSampleGroupBox *ptr = (GF_CompactSampleGroupBox*)s;\n\tu32 pattern_size = get_size_by_code( ((ptr->flags>>4) & 0x3) );\n\tu32 scount_size = get_size_by_code( ((ptr->flags>>2) & 0x3) );\n\tu32 index_size = get_size_by_code( (ptr->flags & 0x3) );\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u8(bs, ptr->version);\n\tgf_bs_write_int(bs, ptr->flags, 24);\n\tgf_bs_write_u32(bs, ptr->grouping_type);\n\n\tif (ptr->flags & (1<<6))\n\t\tgf_bs_write_u32(bs, ptr->grouping_type_parameter);\n\n\tgf_bs_write_u32(bs, ptr->pattern_count);\n\n\tfor (i = 0; i<ptr->pattern_count; i++ ) {\n\t\tgf_bs_write_int(bs, ptr->patterns[i].length, pattern_size);\n\t\tgf_bs_write_int(bs, ptr->patterns[i].sample_count, scount_size);\n\t}\n\n\tfor (i = 0; i<ptr->pattern_count; i++ ) {\n\t\tu32 j;\n\t\tfor (j=0; j<ptr->patterns[i].length; j++) {\n\t\t\tu32 idx = ptr->patterns[i].sample_group_description_indices[j];\n\t\t\tif (idx > 0x10000) {\n\t\t\t\tidx -= 0x10000;\n\t\t\t\tgf_bs_write_int(bs, 1, 1);\n\t\t\t\tgf_bs_write_int(bs, idx, index_size-1);\n\t\t\t} else {\n\t\t\t\tgf_bs_write_int(bs, idx, index_size);\n\t\t\t}\n\t\t}\n\t}\n\tgf_bs_align(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":427816,"func":"void __init sev_hardware_setup(void)\n{\n#ifdef CONFIG_KVM_AMD_SEV\n\tunsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count;\n\tbool sev_es_supported = false;\n\tbool sev_supported = false;\n\n\tif (!sev_enabled || !npt_enabled)\n\t\tgoto out;\n\n\t\/* Does the CPU support SEV? *\/\n\tif (!boot_cpu_has(X86_FEATURE_SEV))\n\t\tgoto out;\n\n\t\/* Retrieve SEV CPUID information *\/\n\tcpuid(0x8000001f, &eax, &ebx, &ecx, &edx);\n\n\t\/* Set encryption bit location for SEV-ES guests *\/\n\tsev_enc_bit = ebx & 0x3f;\n\n\t\/* Maximum number of encrypted guests supported simultaneously *\/\n\tmax_sev_asid = ecx;\n\tif (!max_sev_asid)\n\t\tgoto out;\n\n\t\/* Minimum ASID value that should be used for SEV guest *\/\n\tmin_sev_asid = edx;\n\tsev_me_mask = 1UL << (ebx & 0x3f);\n\n\t\/*\n\t * Initialize SEV ASID bitmaps. Allocate space for ASID 0 in the bitmap,\n\t * even though it's never used, so that the bitmap is indexed by the\n\t * actual ASID.\n\t *\/\n\tnr_asids = max_sev_asid + 1;\n\tsev_asid_bitmap = bitmap_zalloc(nr_asids, GFP_KERNEL);\n\tif (!sev_asid_bitmap)\n\t\tgoto out;\n\n\tsev_reclaim_asid_bitmap = bitmap_zalloc(nr_asids, GFP_KERNEL);\n\tif (!sev_reclaim_asid_bitmap) {\n\t\tbitmap_free(sev_asid_bitmap);\n\t\tsev_asid_bitmap = NULL;\n\t\tgoto out;\n\t}\n\n\tsev_asid_count = max_sev_asid - min_sev_asid + 1;\n\tif (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count))\n\t\tgoto out;\n\n\tpr_info(\"SEV supported: %u ASIDs\\n\", sev_asid_count);\n\tsev_supported = true;\n\n\t\/* SEV-ES support requested? *\/\n\tif (!sev_es_enabled)\n\t\tgoto out;\n\n\t\/* Does the CPU support SEV-ES? *\/\n\tif (!boot_cpu_has(X86_FEATURE_SEV_ES))\n\t\tgoto out;\n\n\t\/* Has the system been allocated ASIDs for SEV-ES? *\/\n\tif (min_sev_asid == 1)\n\t\tgoto out;\n\n\tsev_es_asid_count = min_sev_asid - 1;\n\tif (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))\n\t\tgoto out;\n\n\tpr_info(\"SEV-ES supported: %u ASIDs\\n\", sev_es_asid_count);\n\tsev_es_supported = true;\n\nout:\n\tsev_enabled = sev_supported;\n\tsev_es_enabled = sev_es_supported;\n#endif\n}","target":0,"code_token_length":620,"total_token_length":856,"max_tokens_setting":1024}
+{"idx":349246,"func":"int read_super_3(char *source, squashfs_operations **s_ops, void *s)\n{\n\tsquashfs_super_block_3 *sBlk_3 = s;\n\n\t\/*\n\t * Try to read a squashfs 3 superblock (compatible with 1 and 2 filesystems)\n\t *\/\n\tint res = read_fs_bytes(fd, SQUASHFS_START, sizeof(*sBlk_3), sBlk_3);\n\n\tif(res == FALSE)\n\t\treturn res;\n\t\/*\n\t * Check it is a SQUASHFS superblock\n\t *\/\n\tswap = 0;\n\tif(sBlk_3->s_magic == SQUASHFS_MAGIC_SWAP) {\n\t\tsquashfs_super_block_3 sblk;\n\t\tERROR(\"Reading a different endian SQUASHFS filesystem on %s\\n\", source);\n\t\tSQUASHFS_SWAP_SUPER_BLOCK_3(&sblk, sBlk_3);\n\t\tmemcpy(sBlk_3, &sblk, sizeof(squashfs_super_block_3));\n\t\tswap = 1;\n\t}\n\n\tif(sBlk_3->s_magic != SQUASHFS_MAGIC || sBlk_3->s_major != 3 ||\n\t\t\t\t\t\t\tsBlk_3->s_minor > 1)\n\t\treturn -1;\n\n\tsBlk.s.s_magic = sBlk_3->s_magic;\n\tsBlk.s.inodes = sBlk_3->inodes;\n\tsBlk.s.mkfs_time = sBlk_3->mkfs_time;\n\tsBlk.s.block_size = sBlk_3->block_size;\n\tsBlk.s.fragments = sBlk_3->fragments;\n\tsBlk.s.block_log = sBlk_3->block_log;\n\tsBlk.s.flags = sBlk_3->flags;\n\tsBlk.s.s_major = sBlk_3->s_major;\n\tsBlk.s.s_minor = sBlk_3->s_minor;\n\tsBlk.s.root_inode = sBlk_3->root_inode;\n\tsBlk.s.bytes_used = sBlk_3->bytes_used;\n\tsBlk.s.inode_table_start = sBlk_3->inode_table_start;\n\tsBlk.s.directory_table_start = sBlk_3->directory_table_start;\n\tsBlk.s.fragment_table_start = sBlk_3->fragment_table_start;\n\tsBlk.s.lookup_table_start = sBlk_3->lookup_table_start;\n\tsBlk.no_uids = sBlk_3->no_uids;\n\tsBlk.no_guids = sBlk_3->no_guids;\n\tsBlk.uid_start = sBlk_3->uid_start;\n\tsBlk.guid_start = sBlk_3->guid_start;\n\tsBlk.s.xattr_id_table_start = SQUASHFS_INVALID_BLK;\n\n\t*s_ops = &ops;\n\n\t\/*\n\t * 3.x filesystems use gzip compression.\n\t *\/\n\tcomp = lookup_compressor(\"gzip\");\n\treturn TRUE;\n}","target":0,"code_token_length":633,"total_token_length":869,"max_tokens_setting":1024}
+{"idx":310034,"func":"check_pending(NCURSES_SP_DCL0)\n\/* check for pending input *\/\n{\n    bool have_pending = FALSE;\n\n    \/*\n     * Only carry out this check when the flag is zero, otherwise we'll\n     * have the refreshing slow down drastically (or stop) if there's an\n     * unread character available.\n     *\/\n    if (SP_PARM->_fifohold != 0)\n\treturn FALSE;\n\n    if (SP_PARM->_checkfd >= 0) {\n#if USE_FUNC_POLL\n\tstruct pollfd fds[1];\n\tfds[0].fd = SP_PARM->_checkfd;\n\tfds[0].events = POLLIN;\n\tif (poll(fds, (size_t) 1, 0) > 0) {\n\t    have_pending = TRUE;\n\t}\n#elif defined(__BEOS__)\n\t\/*\n\t * BeOS's select() is declared in socket.h, so the configure script does\n\t * not see it.  That's just as well, since that function works only for\n\t * sockets.  This (using snooze and ioctl) was distilled from Be's patch\n\t * for ncurses which uses a separate thread to simulate select().\n\t *\n\t * FIXME: the return values from the ioctl aren't very clear if we get\n\t * interrupted.\n\t *\/\n\tint n = 0;\n\tint howmany = ioctl(0, 'ichr', &n);\n\tif (howmany >= 0 && n > 0) {\n\t    have_pending = TRUE;\n\t}\n#elif HAVE_SELECT\n\tfd_set fdset;\n\tstruct timeval ktimeout;\n\n\tktimeout.tv_sec =\n\t    ktimeout.tv_usec = 0;\n\n\tFD_ZERO(&fdset);\n\tFD_SET(SP_PARM->_checkfd, &fdset);\n\tif (select(SP_PARM->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {\n\t    have_pending = TRUE;\n\t}\n#endif\n    }\n    if (have_pending) {\n\tSP_PARM->_fifohold = 5;\n\tNCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);\n    }\n    return FALSE;\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":344765,"func":"tilde_expand(const char *filename, uid_t uid, char **retp)\n{\n\tconst char *path, *sep;\n\tchar user[128], *ret;\n\tstruct passwd *pw;\n\tu_int len, slash;\n\n\tif (*filename != '~') {\n\t\t*retp = xstrdup(filename);\n\t\treturn 0;\n\t}\n\tfilename++;\n\n\tpath = strchr(filename, '\/');\n\tif (path != NULL && path > filename) {\t\t\/* ~user\/path *\/\n\t\tslash = path - filename;\n\t\tif (slash > sizeof(user) - 1) {\n\t\t\terror_f(\"~username too long\");\n\t\t\treturn -1;\n\t\t}\n\t\tmemcpy(user, filename, slash);\n\t\tuser[slash] = '\\0';\n\t\tif ((pw = getpwnam(user)) == NULL) {\n\t\t\terror_f(\"No such user %s\", user);\n\t\t\treturn -1;\n\t\t}\n\t} else if ((pw = getpwuid(uid)) == NULL) {\t\/* ~\/path *\/\n\t\terror_f(\"No such uid %ld\", (long)uid);\n\t\treturn -1;\n\t}\n\n\t\/* Make sure directory has a trailing '\/' *\/\n\tlen = strlen(pw->pw_dir);\n\tif (len == 0 || pw->pw_dir[len - 1] != '\/')\n\t\tsep = \"\/\";\n\telse\n\t\tsep = \"\";\n\n\t\/* Skip leading '\/' from specified path *\/\n\tif (path != NULL)\n\t\tfilename = path + 1;\n\n\tif (xasprintf(&ret, \"%s%s%s\", pw->pw_dir, sep, filename) >= PATH_MAX) {\n\t\terror_f(\"Path too long\");\n\t\treturn -1;\n\t}\n\n\t*retp = ret;\n\treturn 0;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":195069,"func":"static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si)\n{\n\ts32 pps_id;\n\n\t\/*s->current_picture.reference= h->nal_ref_idc != 0;*\/\n\tgf_bs_read_ue_log(bs, \"first_mb_in_slice\");\n\tsi->slice_type = gf_bs_read_ue_log(bs, \"slice_type\");\n\tif (si->slice_type > 9) return -1;\n\n\tpps_id = gf_bs_read_ue_log(bs, \"pps_id\");\n\tif (pps_id > 255)\n\t\treturn -1;\n\tsi->pps = &avc->pps[pps_id];\n\tsi->pps->id = pps_id;\n\tif (!si->pps->slice_group_count)\n\t\treturn -2;\n\tsi->sps = &avc->sps[si->pps->sps_id + GF_SVC_SSPS_ID_SHIFT];\n\tif (!si->sps->log2_max_frame_num)\n\t\treturn -2;\n\n\tsi->frame_num = gf_bs_read_int_log(bs, si->sps->log2_max_frame_num, \"frame_num\");\n\n\tsi->field_pic_flag = 0;\n\tif (si->sps->frame_mbs_only_flag) {\n\t\t\/*s->picture_structure= PICT_FRAME;*\/\n\t}\n\telse {\n\t\tsi->field_pic_flag = gf_bs_read_int_log(bs, 1, \"field_pic_flag\");\n\t\tif (si->field_pic_flag) si->bottom_field_flag = gf_bs_read_int_log(bs, 1, \"bottom_field_flag\");\n\t}\n\tif (si->nal_unit_type == GF_AVC_NALU_IDR_SLICE || si->NalHeader.idr_pic_flag)\n\t\tsi->idr_pic_id = gf_bs_read_ue_log(bs, \"idr_pic_id\");\n\n\tif (si->sps->poc_type == 0) {\n\t\tsi->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, \"poc_lsb\");\n\t\tif (si->pps->pic_order_present && !si->field_pic_flag) {\n\t\t\tsi->delta_poc_bottom = gf_bs_read_se_log(bs, \"delta_poc_bottom\");\n\t\t}\n\t}\n\telse if ((si->sps->poc_type == 1) && !si->sps->delta_pic_order_always_zero_flag) {\n\t\tsi->delta_poc[0] = gf_bs_read_se_log(bs, \"delta_poc0\");\n\t\tif ((si->pps->pic_order_present == 1) && !si->field_pic_flag)\n\t\t\tsi->delta_poc[1] = gf_bs_read_se_log(bs, \"delta_poc1\");\n\t}\n\tif (si->pps->redundant_pic_cnt_present) {\n\t\tsi->redundant_pic_cnt = gf_bs_read_ue_log(bs, \"redundant_pic_cnt\");\n\t}\n\treturn 0;\n}","target":1,"code_token_length":638,"total_token_length":874,"max_tokens_setting":1024}
+{"idx":385789,"func":"SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,\n\t\tint, newdfd, const char __user *, newname, int, flags)\n{\n\tstruct dentry *new_dentry;\n\tstruct path old_path, new_path;\n\tint how = 0;\n\tint error;\n\n\tif ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0)\n\t\treturn -EINVAL;\n\t\/*\n\t * To use null names we require CAP_DAC_READ_SEARCH\n\t * This ensures that not everyone will be able to create\n\t * handlink using the passed filedescriptor.\n\t *\/\n\tif (flags & AT_EMPTY_PATH) {\n\t\tif (!capable(CAP_DAC_READ_SEARCH))\n\t\t\treturn -ENOENT;\n\t\thow = LOOKUP_EMPTY;\n\t}\n\n\tif (flags & AT_SYMLINK_FOLLOW)\n\t\thow |= LOOKUP_FOLLOW;\nretry:\n\terror = user_path_at(olddfd, oldname, how, &old_path);\n\tif (error)\n\t\treturn error;\n\n\tnew_dentry = user_path_create(newdfd, newname, &new_path,\n\t\t\t\t\t(how & LOOKUP_REVAL));\n\terror = PTR_ERR(new_dentry);\n\tif (IS_ERR(new_dentry))\n\t\tgoto out;\n\n\terror = -EXDEV;\n\tif (old_path.mnt != new_path.mnt)\n\t\tgoto out_dput;\n\terror = may_linkat(&old_path);\n\tif (unlikely(error))\n\t\tgoto out_dput;\n\terror = security_path_link(old_path.dentry, &new_path, new_dentry);\n\tif (error)\n\t\tgoto out_dput;\n\terror = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);\nout_dput:\n\tdone_path_create(&new_path, new_dentry);\n\tif (retry_estale(error, how)) {\n\t\thow |= LOOKUP_REVAL;\n\t\tgoto retry;\n\t}\nout:\n\tpath_put(&old_path);\n\n\treturn error;\n}","target":0,"code_token_length":403,"total_token_length":639,"max_tokens_setting":1024}
+{"idx":231729,"func":"TEST_F(QuicServerTransportTest, ReceiveRstStreamNonExistentAndOtherFrame) {\n  StreamId clientUnidirectional = 0x02;\n\n  \/\/ Deliver reset on peer unidirectional stream to close the stream.\n  RstStreamFrame rstFrame(\n      clientUnidirectional, GenericApplicationErrorCode::UNKNOWN, 0);\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  writeFrame(rstFrame, builder);\n  auto packet = packetToBuf(std::move(builder).buildPacket());\n  deliverData(std::move(packet));\n\n  auto streamId =\n      server->createBidirectionalStream(false \/* replaySafe *\/).value();\n\n  ShortHeader header2(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder2(\n      server->getConn().udpSendPacketLen,\n      std::move(header2),\n      0 \/* largestAcked *\/);\n  builder2.encodePacketHeader();\n  writeFrame(rstFrame, builder2);\n\n  auto data = folly::IOBuf::copyBuffer(\"hello\");\n  writeStreamFrameHeader(\n      builder2,\n      streamId,\n      0,\n      data->computeChainDataLength(),\n      data->computeChainDataLength(),\n      false,\n      folly::none \/* skipLenHint *\/);\n  writeStreamFrameData(builder2, data->clone(), data->computeChainDataLength());\n  auto packetObject = std::move(builder2).buildPacket();\n  auto packet2 = packetToBuf(std::move(packetObject));\n  deliverData(std::move(packet2));\n\n  auto readData = server->read(streamId, 0);\n  ASSERT_TRUE(readData.hasValue());\n  ASSERT_NE(readData.value().first, nullptr);\n  EXPECT_TRUE(folly::IOBufEqualTo()(*readData.value().first, *data));\n}","target":0,"code_token_length":454,"total_token_length":690,"max_tokens_setting":1024}
+{"idx":405710,"func":"static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int reg)\n{\n\tstruct net_local *lp = bus->priv;\n\tu32 ctrl_reg;\n\tu32 rc;\n\n\tif (xemaclite_mdio_wait(lp))\n\t\treturn -ETIMEDOUT;\n\n\t\/* Write the PHY address, register number and set the OP bit in the\n\t * MDIO Address register. Set the Status bit in the MDIO Control\n\t * register to start a MDIO read transaction.\n\t *\/\n\tctrl_reg = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET);\n\txemaclite_writel(XEL_MDIOADDR_OP_MASK |\n\t\t\t ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg),\n\t\t\t lp->base_addr + XEL_MDIOADDR_OFFSET);\n\txemaclite_writel(ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK,\n\t\t\t lp->base_addr + XEL_MDIOCTRL_OFFSET);\n\n\tif (xemaclite_mdio_wait(lp))\n\t\treturn -ETIMEDOUT;\n\n\trc = xemaclite_readl(lp->base_addr + XEL_MDIORD_OFFSET);\n\n\tdev_dbg(&lp->ndev->dev,\n\t\t\"%s(phy_id=%i, reg=%x) == %x\\n\", __func__,\n\t\tphy_id, reg, rc);\n\n\treturn rc;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":512405,"func":"Item *Item_in_optimizer::transform(THD *thd, Item_transformer transformer,\n                                   uchar *argument)\n{\n  Item *new_item;\n\n  DBUG_ASSERT(fixed);\n  DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare());\n  DBUG_ASSERT(arg_count == 2);\n\n  \/* Transform the left IN operand. *\/\n  new_item= (*args)->transform(thd, transformer, argument);\n  if (!new_item)\n    return 0;\n  \/*\n    THD::change_item_tree() should be called only if the tree was\n    really transformed, i.e. when a new item has been created.\n    Otherwise we'll be allocating a lot of unnecessary memory for\n    change records at each execution.\n  *\/\n  if ((*args) != new_item)\n    thd->change_item_tree(args, new_item);\n\n  if (invisible_mode())\n  {\n    \/* MAX\/MIN transformed => pass through *\/\n    new_item= args[1]->transform(thd, transformer, argument);\n    if (!new_item)\n      return 0;\n    if (args[1] != new_item)\n      thd->change_item_tree(args + 1, new_item);\n  }\n  else\n  {\n    \/*\n      Transform the right IN operand which should be an Item_in_subselect or a\n      subclass of it. The left operand of the IN must be the same as the left\n      operand of this Item_in_optimizer, so in this case there is no further\n      transformation, we only make both operands the same.\n      TODO: is it the way it should be?\n    *\/\n    DBUG_ASSERT((args[1])->type() == Item::SUBSELECT_ITEM &&\n                (((Item_subselect*)(args[1]))->substype() ==\n                 Item_subselect::IN_SUBS ||\n                 ((Item_subselect*)(args[1]))->substype() ==\n                 Item_subselect::ALL_SUBS ||\n                 ((Item_subselect*)(args[1]))->substype() ==\n                 Item_subselect::ANY_SUBS));\n\n    Item_in_subselect *in_arg= (Item_in_subselect*)args[1];\n    thd->change_item_tree(&in_arg->left_expr, args[0]);\n  }\n  return (this->*transformer)(thd, argument);\n}","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":194989,"func":"static MagickBooleanType ReadPSDChannelPixels(Image *image,\n  const size_t channels,const ssize_t row,const ssize_t type,\n  const unsigned char *pixels,ExceptionInfo *exception)\n{\n  Quantum\n    pixel;\n\n  const unsigned char\n    *p;\n\n  IndexPacket\n    *indexes;\n\n  PixelPacket\n    *q;\n\n  ssize_t\n    x;\n\n  size_t\n    packet_size;\n\n  unsigned short\n    nibble;\n\n  p=pixels;\n  q=GetAuthenticPixels(image,0,row,image->columns,1,exception);\n  if (q == (PixelPacket *) NULL)\n    return MagickFalse;\n  indexes=GetAuthenticIndexQueue(image);\n  packet_size=GetPSDPacketSize(image);\n  for (x=0; x < (ssize_t) image->columns; x++)\n  {\n    if (packet_size == 1)\n      pixel=ScaleCharToQuantum(*p++);\n    else\n      if (packet_size == 2)\n        {\n          p=PushShortPixel(MSBEndian,p,&nibble);\n          pixel=ScaleShortToQuantum(nibble);\n        }\n      else\n        {\n          MagickFloatType\n            nibble;\n\n          p=PushFloatPixel(MSBEndian,p,&nibble);\n          pixel=ClampToQuantum((MagickRealType)QuantumRange*nibble);\n        }\n    if (image->depth > 1)\n      {\n        SetPSDPixel(image,channels,type,packet_size,pixel,q,indexes,x);\n        q++;\n      }\n    else\n      {\n        ssize_t\n          bit,\n          number_bits;\n\n        number_bits=(ssize_t) image->columns-x;\n        if (number_bits > 8)\n          number_bits=8;\n        for (bit=0; bit < number_bits; bit++)\n        {\n          SetPSDPixel(image,channels,type,packet_size,(((unsigned char) pixel)\n            & (0x01 << (7-bit))) != 0 ? 0 : QuantumRange,q++,indexes,x++);\n        }\n        if (x != (ssize_t) image->columns)\n          x--;\n        continue;\n      }\n  }\n  return(SyncAuthenticPixels(image,exception));\n}","target":1,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":234862,"func":"static noinline int btrfs_update_device(struct btrfs_trans_handle *trans,\n\t\t\t\t\tstruct btrfs_device *device)\n{\n\tint ret;\n\tstruct btrfs_path *path;\n\tstruct btrfs_root *root = device->fs_info->chunk_root;\n\tstruct btrfs_dev_item *dev_item;\n\tstruct extent_buffer *leaf;\n\tstruct btrfs_key key;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tkey.objectid = BTRFS_DEV_ITEMS_OBJECTID;\n\tkey.type = BTRFS_DEV_ITEM_KEY;\n\tkey.offset = device->devid;\n\n\tret = btrfs_search_slot(trans, root, &key, path, 0, 1);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tif (ret > 0) {\n\t\tret = -ENOENT;\n\t\tgoto out;\n\t}\n\n\tleaf = path->nodes[0];\n\tdev_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_item);\n\n\tbtrfs_set_device_id(leaf, dev_item, device->devid);\n\tbtrfs_set_device_type(leaf, dev_item, device->type);\n\tbtrfs_set_device_io_align(leaf, dev_item, device->io_align);\n\tbtrfs_set_device_io_width(leaf, dev_item, device->io_width);\n\tbtrfs_set_device_sector_size(leaf, dev_item, device->sector_size);\n\tbtrfs_set_device_total_bytes(leaf, dev_item,\n\t\t\t\t     btrfs_device_get_disk_total_bytes(device));\n\tbtrfs_set_device_bytes_used(leaf, dev_item,\n\t\t\t\t    btrfs_device_get_bytes_used(device));\n\tbtrfs_mark_buffer_dirty(leaf);\n\nout:\n\tbtrfs_free_path(path);\n\treturn ret;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":300739,"func":"static int __tipc_nl_list_sk_publ(struct sk_buff *skb,\n\t\t\t\t  struct netlink_callback *cb,\n\t\t\t\t  struct tipc_sock *tsk, u32 *last_publ)\n{\n\tint err;\n\tstruct publication *p;\n\n\tif (*last_publ) {\n\t\tlist_for_each_entry(p, &tsk->publications, binding_sock) {\n\t\t\tif (p->key == *last_publ)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (p->key != *last_publ) {\n\t\t\t\/* We never set seq or call nl_dump_check_consistent()\n\t\t\t * this means that setting prev_seq here will cause the\n\t\t\t * consistence check to fail in the netlink callback\n\t\t\t * handler. Resulting in the last NLMSG_DONE message\n\t\t\t * having the NLM_F_DUMP_INTR flag set.\n\t\t\t *\/\n\t\t\tcb->prev_seq = 1;\n\t\t\t*last_publ = 0;\n\t\t\treturn -EPIPE;\n\t\t}\n\t} else {\n\t\tp = list_first_entry(&tsk->publications, struct publication,\n\t\t\t\t     binding_sock);\n\t}\n\n\tlist_for_each_entry_from(p, &tsk->publications, binding_sock) {\n\t\terr = __tipc_nl_add_sk_publ(skb, cb, p);\n\t\tif (err) {\n\t\t\t*last_publ = p->key;\n\t\t\treturn err;\n\t\t}\n\t}\n\t*last_publ = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":196846,"func":"TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n  auto* params = reinterpret_cast<TfLiteDivParams*>(node->builtin_data);\n  OpData* data = reinterpret_cast<OpData*>(node->user_data);\n\n  const TfLiteTensor* input1;\n  TF_LITE_ENSURE_OK(context,\n                    GetInputSafe(context, node, kInputTensor1, &input1));\n  const TfLiteTensor* input2;\n  TF_LITE_ENSURE_OK(context,\n                    GetInputSafe(context, node, kInputTensor2, &input2));\n  TfLiteTensor* output;\n  TF_LITE_ENSURE_OK(context,\n                    GetOutputSafe(context, node, kOutputTensor, &output));\n\n  if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) {\n    EvalDiv<kernel_type>(context, node, params, data, input1, input2, output);\n  } else if (output->type == kTfLiteUInt8) {\n    TF_LITE_ENSURE_OK(\n        context, EvalQuantized<kernel_type>(context, node, params, data, input1,\n                                            input2, output));\n  } else {\n    context->ReportError(\n        context,\n        \"Div only supports FLOAT32, INT32 and quantized UINT8 now, got %d.\",\n        output->type);\n    return kTfLiteError;\n  }\n\n  return kTfLiteOk;\n}","target":1,"code_token_length":314,"total_token_length":550,"max_tokens_setting":1024}
+{"idx":513346,"func":"add_ft_keys(DYNAMIC_ARRAY *keyuse_array,\n            JOIN_TAB *stat,COND *cond,table_map usable_tables)\n{\n  Item_func_match *cond_func=NULL;\n\n  if (!cond)\n    return FALSE;\n\n  if (cond->type() == Item::FUNC_ITEM)\n  {\n    Item_func *func=(Item_func *)cond;\n    Item_func::Functype functype=  func->functype();\n    if (functype == Item_func::FT_FUNC)\n      cond_func=(Item_func_match *)cond;\n    else if (func->argument_count() == 2)\n    {\n      Item *arg0=(Item *)(func->arguments()[0]),\n           *arg1=(Item *)(func->arguments()[1]);\n      if (arg1->const_item() && arg1->cols() == 1 &&\n           arg0->type() == Item::FUNC_ITEM &&\n           ((Item_func *) arg0)->functype() == Item_func::FT_FUNC &&\n          ((functype == Item_func::GE_FUNC && arg1->val_real() > 0) ||\n           (functype == Item_func::GT_FUNC && arg1->val_real() >=0)))\n        cond_func= (Item_func_match *) arg0;\n      else if (arg0->const_item() && arg0->cols() == 1 &&\n                arg1->type() == Item::FUNC_ITEM &&\n                ((Item_func *) arg1)->functype() == Item_func::FT_FUNC &&\n               ((functype == Item_func::LE_FUNC && arg0->val_real() > 0) ||\n                (functype == Item_func::LT_FUNC && arg0->val_real() >=0)))\n        cond_func= (Item_func_match *) arg1;\n    }\n  }\n  else if (cond->type() == Item::COND_ITEM)\n  {\n    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());\n\n    if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)\n    {\n      Item *item;\n      while ((item=li++))\n      {\n        if (add_ft_keys(keyuse_array,stat,item,usable_tables))\n          return TRUE;\n      }\n    }\n  }\n\n  if (!cond_func || cond_func->key == NO_SUCH_KEY ||\n      !(usable_tables & cond_func->table->map))\n    return FALSE;\n\n  KEYUSE keyuse;\n  keyuse.table= cond_func->table;\n  keyuse.val =  cond_func;\n  keyuse.key =  cond_func->key;\n  keyuse.keypart= FT_KEYPART;\n  keyuse.used_tables=cond_func->key_item()->used_tables();\n  keyuse.optimize= 0;\n  keyuse.keypart_map= 0;\n  keyuse.sj_pred_no= UINT_MAX;\n  return insert_dynamic(keyuse_array,(uchar*) &keyuse);\n}","target":0,"code_token_length":593,"total_token_length":829,"max_tokens_setting":1024}
+{"idx":349250,"func":"int read_super_1(squashfs_operations **s_ops, void *s)\n{\n\tsquashfs_super_block_3 *sBlk_3 = s;\n\n\tif(sBlk_3->s_magic != SQUASHFS_MAGIC || sBlk_3->s_major != 1 ||\n\t\t\t\t\t\t\tsBlk_3->s_minor != 0)\n\t\treturn -1;\n\n\tsBlk.s.s_magic = sBlk_3->s_magic;\n\tsBlk.s.inodes = sBlk_3->inodes;\n\tsBlk.s.mkfs_time = sBlk_3->mkfs_time;\n\tsBlk.s.block_size = sBlk_3->block_size_1;\n\tsBlk.s.fragments = 0;\n\tsBlk.s.block_log = sBlk_3->block_log;\n\tsBlk.s.flags = sBlk_3->flags;\n\tsBlk.s.s_major = sBlk_3->s_major;\n\tsBlk.s.s_minor = sBlk_3->s_minor;\n\tsBlk.s.root_inode = sBlk_3->root_inode;\n\tsBlk.s.bytes_used = sBlk_3->bytes_used_2;\n\tsBlk.s.inode_table_start = sBlk_3->inode_table_start_2;\n\tsBlk.s.directory_table_start = sBlk_3->directory_table_start_2;\n\tsBlk.s.fragment_table_start = SQUASHFS_INVALID_BLK;\n\tsBlk.s.lookup_table_start = sBlk_3->lookup_table_start;\n\tsBlk.no_uids = sBlk_3->no_uids;\n\tsBlk.no_guids = sBlk_3->no_guids;\n\tsBlk.uid_start = sBlk_3->uid_start_2;\n\tsBlk.guid_start = sBlk_3->guid_start_2;\n\tsBlk.s.xattr_id_table_start = SQUASHFS_INVALID_BLK;\n\n\t*s_ops = &ops;\n\n\t\/*\n\t * 1.x filesystems use gzip compression.\n\t *\/\n\tcomp = lookup_compressor(\"gzip\");\n\treturn TRUE;\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":272341,"func":"unlock_nss_token(cms_context *cms)\n{\n\tchar *tokenname = resolve_token_name(cms->tokenname);\n\n\tdprintf(\"setting password function to %s\", cms->func ? \"cms->func\" : \"SECU_GetModulePassword\");\n\tPK11_SetPasswordFunc(cms->func ? cms->func : SECU_GetModulePassword);\n\n\tPK11SlotList *slots = NULL;\n\tslots = PK11_GetAllTokens(CKM_RSA_PKCS, PR_FALSE, PR_TRUE, cms);\n\tif (!slots)\n\t\tcnreterr(-1, cms, \"could not get pk11 token list\");\n\n\tPK11SlotListElement *psle = NULL;\n\tpsle = PK11_GetFirstSafe(slots);\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tcnreterr(-1, cms, \"could not get pk11 safe\");\n\t}\n\n\twhile (psle) {\n\t\tif (!strcmp(tokenname, PK11_GetTokenName(psle->slot)))\n\t\t\tbreak;\n\n\t\tpsle = PK11_GetNextSafe(slots, psle, PR_FALSE);\n\t}\n\n\tif (!psle) {\n\t\tsave_port_err() {\n\t\t\tPK11_FreeSlotList(slots);\n\t\t}\n\t\tnssreterr(-1, \"Could not find token \\\"%s\\\"\", tokenname);\n\t}\n\n\tSECStatus status;\n\tif (PK11_NeedLogin(psle->slot) &&\n\t\t\t!PK11_IsLoggedIn(psle->slot, cms)) {\n\t\tstatus = PK11_Authenticate(psle->slot, PR_TRUE, cms);\n\t\tif (status != SECSuccess) {\n\t\t\tsave_port_err() {\n\t\t\t\tint err = PORT_GetError();\n\t\t\t\tPK11_DestroySlotListElement(slots, &psle);\n\t\t\t\tPK11_FreeSlotList(slots);\n\t\t\t\tcms->log(cms, LOG_ERR,\n\t\t\t\t\t \"authentication failed for token \\\"%s\\\": %s\",\n\t\t\t\t\t tokenname, PORT_ErrorToString(err));\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tPK11_DestroySlotListElement(slots, &psle);\n\tPK11_FreeSlotList(slots);\n\treturn 0;\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":252283,"func":"static int hufEncode            \/\/ return: output size (in bits)\n    (const long long *hcode,    \/\/ i : encoding table\n     const unsigned short *in,  \/\/ i : uncompressed input buffer\n     const int ni,              \/\/ i : input buffer size (in bytes)\n     int rlc,                   \/\/ i : rl code\n     char *out)                 \/\/  o: compressed output buffer\n{\n  char *outStart = out;\n  long long c = 0;  \/\/ bits not yet written to out\n  int lc = 0;       \/\/ number of valid bits in c (LSB)\n  int s = in[0];\n  int cs = 0;\n\n  \/\/\n  \/\/ Loop on input values\n  \/\/\n\n  for (int i = 1; i < ni; i++) {\n    \/\/\n    \/\/ Count same values or send code\n    \/\/\n\n    if (s == in[i] && cs < 255) {\n      cs++;\n    } else {\n      sendCode(hcode[s], cs, hcode[rlc], c, lc, out);\n      cs = 0;\n    }\n\n    s = in[i];\n  }\n\n  \/\/\n  \/\/ Send remaining code\n  \/\/\n\n  sendCode(hcode[s], cs, hcode[rlc], c, lc, out);\n\n  if (lc) *out = (c << (8 - lc)) & 0xff;\n\n  return (out - outStart) * 8 + lc;\n}","target":0,"code_token_length":316,"total_token_length":552,"max_tokens_setting":1024}
+{"idx":245710,"func":"static int get_all_headers (int fd, orderedmap hashofheaders)\n{\n        char *line = NULL;\n        char *header = NULL;\n        int count;\n        char *tmp;\n        ssize_t linelen;\n        ssize_t len = 0;\n        unsigned int double_cgi = FALSE;        \/* boolean *\/\n\n        assert (fd >= 0);\n        assert (hashofheaders != NULL);\n\n        for (count = 0; count < MAX_HEADERS; count++) {\n                if ((linelen = readline (fd, &line)) <= 0) {\n                        safefree (header);\n                        safefree (line);\n                        return -1;\n                }\n\n                \/*\n                 * If we received a CR LF or a non-continuation line, then add\n                 * the accumulated header field, if any, to the hashmap, and\n                 * reset it.\n                 *\/\n                if (CHECK_CRLF (line, linelen) || !CHECK_LWS (line, linelen)) {\n                        if (!double_cgi\n                            && len > 0\n                            && add_header_to_connection (hashofheaders, header,\n                                                         len) < 0) {\n                                safefree (header);\n                                safefree (line);\n                                return -1;\n                        }\n\n                        len = 0;\n                }\n\n                \/*\n                 * If we received just a CR LF on a line, the headers are\n                 * finished.\n                 *\/\n                if (CHECK_CRLF (line, linelen)) {\n                        safefree (header);\n                        safefree (line);\n                        return 0;\n                }\n\n                \/*\n                 * BUG FIX: The following code detects a \"Double CGI\"\n                 * situation so that we can handle the nonconforming system.\n                 * This problem was found when accessing cgi.ebay.com, and it\n                 * turns out to be a wider spread problem as well.\n                 *\n                 * If \"Double CGI\" is in effect, duplicate headers are\n                 * ignored.\n                 *\n                 * FIXME: Might need to change this to a more robust check.\n                 *\/\n                if (linelen >= 5 && strncasecmp (line, \"HTTP\/\", 5) == 0) {\n                        double_cgi = TRUE;\n                }\n\n                \/*\n                 * Append the new line to the current header field.\n                 *\/\n                tmp = (char *) saferealloc (header, len + linelen);\n                if (tmp == NULL) {\n                        safefree (header);\n                        safefree (line);\n                        return -1;\n                }\n\n                header = tmp;\n                memcpy (header + len, line, linelen);\n                len += linelen;\n\n                safefree (line);\n        }\n\n        \/*\n         * If we get here, this means we reached MAX_HEADERS count.\n         * Bail out with error.\n         *\/\n        safefree (header);\n        safefree (line);\n        return -1;\n}","target":0,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":356170,"func":"static void build_dirs(char *src, char *dst, size_t src_prefix_len, size_t dst_prefix_len) {\n\tchar *p = src + src_prefix_len + 1;\n\tchar *q = dst + dst_prefix_len + 1;\n\tchar *r = dst + dst_prefix_len;\n\tstruct stat s;\n\tbool last = false;\n\t*r = '\\0';\n\tfor (; !last; p++, q++) {\n\t\tif (*p == '\\0') {\n\t\t\tlast = true;\n\t\t}\n\t\tif (*p == '\\0' || (*p == '\/' && *(p - 1) != '\/')) {\n\t\t\t\/\/ We found a new component of our src path.\n\t\t\t\/\/ Null-terminate it temporarily here so that we can work\n\t\t\t\/\/ with it.\n\t\t\t*p = '\\0';\n\t\t\tif (stat(src, &s) == 0 && S_ISDIR(s.st_mode)) {\n\t\t\t\t\/\/ Null-terminate the dst path and undo its previous\n\t\t\t\t\/\/ termination.\n\t\t\t\t*q = '\\0';\n\t\t\t\t*r = '\/';\n\t\t\t\tr = q;\n\t\t\t\tif (mkdir(dst, 0700) != 0 && errno != EEXIST)\n\t\t\t\t\terrExit(\"mkdir\");\n\t\t\t\tif (chmod(dst, s.st_mode) != 0)\n\t\t\t\t\terrExit(\"chmod\");\n\t\t\t}\n\t\t\tif (!last) {\n\t\t\t\t\/\/ If we're not at the final terminating null, restore\n\t\t\t\t\/\/ the slash so that we can continue our traversal.\n\t\t\t\t*p = '\/';\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":323,"total_token_length":559,"max_tokens_setting":1024}
+{"idx":256139,"func":"inline BlockingCounter* SparseMatMul<TL, TR>::ShuffleMatrix(\n    const typename SparseMatMul<TL, TR>::ConstMatrixMapR& mat,\n    int slice_row_start, int slice_num_rows, int slice_col_start,\n    int slice_num_cols, const int N,\n    const DeviceBase::CpuWorkerThreads* thread_pool, MatrixR* buffer) {\n  DCHECK_EQ(N % 2, 0);\n  DCHECK_LE(kNumOperands * sizeof(float) \/ sizeof(TR), N);\n  \/\/ Note(nikhilsarda): This heuristic is optimal in benchmarks as of\n  \/\/ Jan 21, 2020.\n  int num_threads = std::min(thread_pool->num_threads, 8);\n  BlockingCounter* counter = new BlockingCounter(num_threads);\n  DCHECK_EQ(N, buffer->dimension(1));\n  auto shuffle_work = [&mat, slice_row_start, slice_num_rows, slice_col_start,\n                       slice_num_cols, N, buffer, counter](int s, int e) {\n    const int row_start = s % slice_num_rows + slice_row_start;\n    const int col_start = s \/ slice_num_rows * N + slice_col_start;\n    auto* out_start = &(*buffer)(s, 0);\n    const auto* input_start = &mat(row_start, col_start);\n    const auto* input_end = &mat(slice_row_start + slice_num_rows - 1,\n                                 slice_col_start + slice_num_cols - 1);\n    const int mat_num_cols = mat.dimension(1);\n    const int row_slice_size = slice_num_rows * mat_num_cols;\n\n    const int aligned_end = slice_num_cols \/ N * slice_num_rows;\n    const int e1 = std::min(e, aligned_end);\n    while (s < e1) {\n      CopyAndMayBeInterleave<TR>(out_start, input_start, N);\n      out_start += N;\n      input_start += mat_num_cols;\n      if (input_start > input_end) {\n        input_start = input_start - row_slice_size + N;\n      }\n      ++s;\n    }\n    int s1 = std::max(s, aligned_end);\n    const int copy_num_cols = slice_num_cols % N;\n    while (s1 < e) {\n      CopyAndMayBeInterleave<TR>(out_start, input_start, copy_num_cols);\n      out_start += N;\n      input_start += mat_num_cols;\n      ++s1;\n    }\n    if (counter) counter->DecrementCount();\n  };\n\n  int start = 0;\n  int end = 0;\n  int num_out_rows = (slice_num_cols + N - 1) \/ N * slice_num_rows;\n  DCHECK_LE(num_out_rows, buffer->dimension(0));\n  for (int i = std::max(1, num_threads); i > 0; --i) {\n    end = start + num_out_rows \/ i;\n    thread_pool->workers->Schedule([=]() { shuffle_work(start, end); });\n    num_out_rows -= (end - start);\n    start = end;\n  }\n  return counter;\n}","target":0,"code_token_length":654,"total_token_length":890,"max_tokens_setting":1024}
+{"idx":252367,"func":"mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip,\n                                          mz_uint file_index) {\n  mz_uint filename_len, external_attr;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  if (!p) return MZ_FALSE;\n\n  \/\/ First see if the filename ends with a '\/' character.\n  filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  if (filename_len) {\n    if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '\/')\n      return MZ_TRUE;\n  }\n\n  \/\/ Bugfix: This code was also checking if the internal attribute was non-zero,\n  \/\/ which wasn't correct.\n  \/\/ Most\/all zip writers (hopefully) set DOS file\/directory attributes in the\n  \/\/ low 16-bits, so check for the DOS directory flag and ignore the source OS\n  \/\/ ID in the created by field.\n  \/\/ FIXME: Remove this check? Is it necessary - we already check the filename.\n  external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);\n  if ((external_attr & 0x10) != 0) return MZ_TRUE;\n\n  return MZ_FALSE;\n}","target":0,"code_token_length":282,"total_token_length":518,"max_tokens_setting":1024}
+{"idx":252470,"func":"void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index,\n                                    size_t *pSize, mz_uint flags) {\n  mz_uint64 comp_size, uncomp_size, alloc_size;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  void *pBuf;\n\n  if (pSize) *pSize = 0;\n  if (!p) return NULL;\n\n  comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);\n  uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);\n\n  alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;\n#ifdef _MSC_VER\n  if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))\n#else\n  if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))\n#endif\n    return NULL;\n  if (NULL ==\n      (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size)))\n    return NULL;\n\n  if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size,\n                                    flags)) {\n    pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);\n    return NULL;\n  }\n\n  if (pSize) *pSize = (size_t)alloc_size;\n  return pBuf;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":447058,"func":"    void SshIo::SshImpl::writeRemote(const byte* data, size_t size, long from, long to)\n    {\n        if (protocol_ == pSftp) throw Error(1, \"not support SFTP write access.\");\n\n        \/\/printf(\"ssh update size=%ld from=%ld to=%ld\\n\", (long)size, from, to);\n        assert(isMalloced_);\n\n        std::string tempFile = hostInfo_.Path + \".exiv2tmp\";\n        std::string response;\n        std::stringstream ss;\n        \/\/ copy the head (byte 0 to byte fromByte) of original file to filepath.exiv2tmp\n        ss  << \"head -c \" << from\n            << \" \"   << hostInfo_.Path\n            << \" > \" << tempFile;\n        std::string cmd = ss.str();\n        if (ssh_->runCommand(cmd, &response) != 0) {\n            throw Error(1, \"SSH: Unable to cope the head of file to temp\");\n        }\n\n        \/\/ upload the data (the byte ranges which are different between the original\n        \/\/ file and the new file) to filepath.exiv2datatemp\n        if (ssh_->scp(hostInfo_.Path + \".exiv2datatemp\", data, size) != 0) {\n            throw Error(1, \"SSH: Unable to copy file\");\n        }\n\n        \/\/ concatenate the filepath.exiv2datatemp to filepath.exiv2tmp\n        cmd = \"cat \" + hostInfo_.Path + \".exiv2datatemp >> \" + tempFile;\n        if (ssh_->runCommand(cmd, &response) != 0) {\n            throw Error(1, \"SSH: Unable to copy the rest\");\n        }\n\n        \/\/ copy the tail (from byte toByte to the end of file) of original file to filepath.exiv2tmp\n        ss.str(\"\");\n        ss  << \"tail -c+\" << (to + 1)\n            << \" \"   << hostInfo_.Path\n            << \" >> \"   << tempFile;\n        cmd = ss.str();\n        if (ssh_->runCommand(cmd, &response) != 0) {\n            throw Error(1, \"SSH: Unable to copy the rest\");\n        }\n\n        \/\/ replace the original file with filepath.exiv2tmp\n        cmd = \"mv \" + tempFile + \" \" + hostInfo_.Path;\n        if (ssh_->runCommand(cmd, &response) != 0) {\n            throw Error(1, \"SSH: Unable to copy the rest\");\n        }\n\n        \/\/ remove filepath.exiv2datatemp\n        cmd = \"rm \" + hostInfo_.Path + \".exiv2datatemp\";\n        if (ssh_->runCommand(cmd, &response) != 0) {\n            throw Error(1, \"SSH: Unable to copy the rest\");\n        }\n    }","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":261920,"func":"njs_string_match_multiple(njs_vm_t *vm, njs_value_t *args,\n    njs_regexp_pattern_t *pattern)\n{\n    size_t             c0, c1;\n    int32_t            size, length;\n    njs_int_t          ret;\n    njs_utf8_t         utf8;\n    njs_array_t        *array;\n    const u_char       *p, *start, *end;\n    njs_regexp_utf8_t  type;\n    njs_string_prop_t  string;\n\n    njs_set_number(&args[1].data.u.regexp->last_index, 0);\n    vm->retval = njs_value_null;\n\n    (void) njs_string_prop(&string, &args[0]);\n\n    utf8 = NJS_STRING_BYTE;\n    type = NJS_REGEXP_BYTE;\n\n    if (string.length != 0) {\n        utf8 = NJS_STRING_ASCII;\n        type = NJS_REGEXP_UTF8;\n\n        if (string.length != string.size) {\n            utf8 = NJS_STRING_UTF8;\n        }\n    }\n\n    if (njs_regex_is_valid(&pattern->regex[type])) {\n\n        array = njs_array_alloc(vm, 0, 0, NJS_ARRAY_SPARE);\n        if (njs_slow_path(array == NULL)) {\n            return NJS_ERROR;\n        }\n\n        p = string.start;\n        end = p + string.size;\n\n        do {\n            ret = njs_regexp_match(vm, &pattern->regex[type], p, 0, string.size,\n                                   vm->single_match_data);\n            if (ret < 0) {\n                if (njs_fast_path(ret == NJS_DECLINED)) {\n                    break;\n                }\n\n                njs_internal_error(vm, \"njs_regexp_match() failed\");\n\n                return NJS_ERROR;\n            }\n\n            ret = njs_array_expand(vm, array, 0, 1);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            c0 = njs_regex_capture(vm->single_match_data, 0);\n            c1 = njs_regex_capture(vm->single_match_data, 1);\n            start = p + c0;\n\n            if (c1 == 0) {\n                if (start < end) {\n                    p = (utf8 != NJS_STRING_BYTE) ? njs_utf8_next(start, end)\n                                                  : start + 1;\n                    string.size = end - p;\n\n                } else {\n                    \/* To exit the loop. *\/\n                    p++;\n                }\n\n                size = 0;\n                length = 0;\n\n            } else {\n                p += c1;\n                string.size -= c1;\n\n                size = c1 - c0;\n                length = njs_string_calc_length(utf8, start, size);\n            }\n\n            ret = njs_string_new(vm, &array->start[array->length],\n                                 start, size, length);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n\n            array->length++;\n\n        } while (p <= end);\n\n        njs_set_array(&vm->retval, array);\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":670,"total_token_length":906,"max_tokens_setting":1024}
+{"idx":436144,"func":"static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx)\n{\n\tstruct io_submit_state *state = &ctx->submit_state;\n\n\tBUILD_BUG_ON(ARRAY_SIZE(state->reqs) < IO_REQ_ALLOC_BATCH);\n\n\tif (!state->free_reqs) {\n\t\tgfp_t gfp = GFP_KERNEL | __GFP_NOWARN;\n\t\tint ret, i;\n\n\t\tif (io_flush_cached_reqs(ctx))\n\t\t\tgoto got_req;\n\n\t\tret = kmem_cache_alloc_bulk(req_cachep, gfp, IO_REQ_ALLOC_BATCH,\n\t\t\t\t\t    state->reqs);\n\n\t\t\/*\n\t\t * Bulk alloc is all-or-nothing. If we fail to get a batch,\n\t\t * retry single alloc to be on the safe side.\n\t\t *\/\n\t\tif (unlikely(ret <= 0)) {\n\t\t\tstate->reqs[0] = kmem_cache_alloc(req_cachep, gfp);\n\t\t\tif (!state->reqs[0])\n\t\t\t\treturn NULL;\n\t\t\tret = 1;\n\t\t}\n\n\t\t\/*\n\t\t * Don't initialise the fields below on every allocation, but\n\t\t * do that in advance and keep valid on free.\n\t\t *\/\n\t\tfor (i = 0; i < ret; i++) {\n\t\t\tstruct io_kiocb *req = state->reqs[i];\n\n\t\t\treq->ctx = ctx;\n\t\t\treq->link = NULL;\n\t\t\treq->async_data = NULL;\n\t\t\t\/* not necessary, but safer to zero *\/\n\t\t\treq->result = 0;\n\t\t}\n\t\tstate->free_reqs = ret;\n\t}\ngot_req:\n\tstate->free_reqs--;\n\treturn state->reqs[state->free_reqs];\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":294387,"func":"datetime_s_commercial(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vw, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;\n    int w, d, h, min, s, rof;\n    double sg;\n\n    rb_scan_args(argc, argv, \"08\", &vy, &vw, &vd, &vh, &vmin, &vs, &vof, &vsg);\n\n    y = INT2FIX(-4712);\n    w = 1;\n    d = 1;\n\n    h = min = s = 0;\n    fr2 = INT2FIX(0);\n    rof = 0;\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 8:\n\tval2sg(vsg, sg);\n      case 7:\n\tval2off(vof, rof);\n      case 6:\n        check_numeric(vs, \"second\");\n\tnum2int_with_frac(s, positive_inf);\n      case 5:\n        check_numeric(vmin, \"minute\");\n\tnum2int_with_frac(min, 5);\n      case 4:\n        check_numeric(vh, \"hour\");\n\tnum2int_with_frac(h, 4);\n      case 3:\n        check_numeric(vd, \"cwday\");\n\tnum2int_with_frac(d, 3);\n      case 2:\n        check_numeric(vw, \"cweek\");\n\tw = NUM2INT(vw);\n      case 1:\n        check_numeric(vy, \"year\");\n\ty = vy;\n    }\n\n    {\n\tVALUE nth;\n\tint ry, rw, rd, rh, rmin, rs, rjd, rjd2, ns;\n\n\tif (!valid_commercial_p(y, w, d, sg,\n\t\t\t\t&nth, &ry,\n\t\t\t\t&rw, &rd, &rjd,\n\t\t\t\t&ns))\n\t    rb_raise(eDateError, \"invalid date\");\n\tif (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))\n\t    rb_raise(eDateError, \"invalid date\");\n\tcanon24oc();\n\n\trjd2 = jd_local_to_utc(rjd,\n\t\t\t       time_to_df(rh, rmin, rs),\n\t\t\t       rof);\n\n\tret = d_complex_new_internal(klass,\n\t\t\t\t     nth, rjd2,\n\t\t\t\t     0, INT2FIX(0),\n\t\t\t\t     rof, sg,\n\t\t\t\t     0, 0, 0,\n\t\t\t\t     rh, rmin, rs,\n\t\t\t\t     HAVE_JD | HAVE_TIME);\n    }\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":545,"total_token_length":781,"max_tokens_setting":1024}
+{"idx":259215,"func":"static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n    unsigned int i, entries, sample_size, field_size, num_bytes;\n    GetBitContext gb;\n    unsigned char* buf;\n    int ret;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n    sc = st->priv_data;\n\n    avio_r8(pb); \/* version *\/\n    avio_rb24(pb); \/* flags *\/\n\n    if (atom.type == MKTAG('s','t','s','z')) {\n        sample_size = avio_rb32(pb);\n        if (!sc->sample_size) \/* do not overwrite value computed in stsd *\/\n            sc->sample_size = sample_size;\n        sc->stsz_sample_size = sample_size;\n        field_size = 32;\n    } else {\n        sample_size = 0;\n        avio_rb24(pb); \/* reserved *\/\n        field_size = avio_r8(pb);\n    }\n    entries = avio_rb32(pb);\n\n    av_log(c->fc, AV_LOG_TRACE, \"sample_size = %u sample_count = %u\\n\", sc->sample_size, entries);\n\n    sc->sample_count = entries;\n    if (sample_size)\n        return 0;\n\n    if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {\n        av_log(c->fc, AV_LOG_ERROR, \"Invalid sample field size %u\\n\", field_size);\n        return AVERROR_INVALIDDATA;\n    }\n\n    if (!entries)\n        return 0;\n    if (entries >= (INT_MAX - 4 - 8 * AV_INPUT_BUFFER_PADDING_SIZE) \/ field_size)\n        return AVERROR_INVALIDDATA;\n    if (sc->sample_sizes)\n        av_log(c->fc, AV_LOG_WARNING, \"Duplicated STSZ atom\\n\");\n    av_free(sc->sample_sizes);\n    sc->sample_count = 0;\n    sc->sample_sizes = av_malloc_array(entries, sizeof(*sc->sample_sizes));\n    if (!sc->sample_sizes)\n        return AVERROR(ENOMEM);\n\n    num_bytes = (entries*field_size+4)>>3;\n\n    buf = av_malloc(num_bytes+AV_INPUT_BUFFER_PADDING_SIZE);\n    if (!buf) {\n        av_freep(&sc->sample_sizes);\n        return AVERROR(ENOMEM);\n    }\n\n    ret = ffio_read_size(pb, buf, num_bytes);\n    if (ret < 0) {\n        av_freep(&sc->sample_sizes);\n        av_free(buf);\n        av_log(c->fc, AV_LOG_WARNING, \"STSZ atom truncated\\n\");\n        return 0;\n    }\n\n    init_get_bits(&gb, buf, 8*num_bytes);\n\n    for (i = 0; i < entries; i++) {\n        sc->sample_sizes[i] = get_bits_long(&gb, field_size);\n        if (sc->sample_sizes[i] < 0) {\n            av_free(buf);\n            av_log(c->fc, AV_LOG_ERROR, \"Invalid sample size %d\\n\", sc->sample_sizes[i]);\n            return AVERROR_INVALIDDATA;\n        }\n        sc->data_size += sc->sample_sizes[i];\n    }\n\n    sc->sample_count = i;\n\n    av_free(buf);\n\n    return 0;\n}","target":0,"code_token_length":730,"total_token_length":966,"max_tokens_setting":1024}
+{"idx":369957,"func":"static struct dentry *proc_map_files_lookup(struct inode *dir,\n\t\tstruct dentry *dentry, struct nameidata *nd)\n{\n\tunsigned long vm_start, vm_end;\n\tstruct vm_area_struct *vma;\n\tstruct task_struct *task;\n\tstruct dentry *result;\n\tstruct mm_struct *mm;\n\n\tresult = ERR_PTR(-EACCES);\n\tif (!capable(CAP_SYS_ADMIN))\n\t\tgoto out;\n\n\tresult = ERR_PTR(-ENOENT);\n\ttask = get_proc_task(dir);\n\tif (!task)\n\t\tgoto out;\n\n\tresult = ERR_PTR(-EACCES);\n\tif (lock_trace(task))\n\t\tgoto out_put_task;\n\n\tresult = ERR_PTR(-ENOENT);\n\tif (dname_to_vma_addr(dentry, &vm_start, &vm_end))\n\t\tgoto out_unlock;\n\n\tmm = get_task_mm(task);\n\tif (!mm)\n\t\tgoto out_unlock;\n\n\tdown_read(&mm->mmap_sem);\n\tvma = find_exact_vma(mm, vm_start, vm_end);\n\tif (!vma)\n\t\tgoto out_no_vma;\n\n\tresult = proc_map_files_instantiate(dir, dentry, task, vma->vm_file);\n\nout_no_vma:\n\tup_read(&mm->mmap_sem);\n\tmmput(mm);\nout_unlock:\n\tunlock_trace(task);\nout_put_task:\n\tput_task_struct(task);\nout:\n\treturn result;\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":226438,"func":"    Status GetNextInternal(IteratorContext* ctx,\n                           std::vector<Tensor>* out_tensors,\n                           bool* end_of_sequence) override {\n      mutex_lock l(mu_);\n      if (i_ == num_elements_) {\n        *end_of_sequence = true;\n        return Status::OK();\n      }\n\n      out_tensors->clear();\n      out_tensors->reserve(3);\n      const int rank = Iterator::dataset()->sparse_tensor_.dims();\n\n      if (i_ > next_non_empty_i_ && iter_ != group_iterable_.end()) {\n        \/\/ We still have elements to consume from `group_iterable_`\n        \/\/ and we have emitted all elements up to and including the\n        \/\/ current position.\n        sparse::Group group = *iter_;\n        const auto indices = group.indices();\n        const auto values = group.values<T>();\n        const int64_t num_entries = values.size();\n        next_non_empty_i_ = indices(0, 0);\n\n        next_indices_ = Tensor(DT_INT64, {num_entries, rank - 1});\n        next_values_ = Tensor(DataTypeToEnum<T>::value, {num_entries});\n\n        auto next_indices_t = next_indices_.matrix<int64_t>();\n        auto next_values_t = next_values_.vec<T>();\n\n        for (int64_t i = 0; i < num_entries; ++i) {\n          for (int d = 1; d < rank; ++d) {\n            next_indices_t(i, d - 1) = indices(i, d);\n          }\n          next_values_t(i) = values(i);\n        }\n\n        ++iter_;\n      }\n      if (i_ == next_non_empty_i_) {\n        \/\/ The current position is non-empty in the input\n        \/\/ `SparseTensor`, and we have already read the value from the\n        \/\/ `GroupIterable`.\n        out_tensors->push_back(std::move(next_indices_));\n        out_tensors->push_back(std::move(next_values_));\n        out_tensors->push_back(dense_shape_);\n        next_non_empty_i_ = kNextNonEmptyUnknown;\n      } else {\n        DCHECK(i_ < next_non_empty_i_ || iter_ == group_iterable_.end());\n        \/\/ The current position is empty in the input `SparseTensor`,\n        \/\/ so emit empty indices and values.\n        out_tensors->push_back(Tensor(DT_INT64, TensorShape({0, rank - 1})));\n        out_tensors->push_back(Tensor(DataTypeToEnum<T>::value, {0}));\n        out_tensors->push_back(dense_shape_);\n      }\n\n      ++i_;\n      *end_of_sequence = false;\n      return Status::OK();\n    }","target":0,"code_token_length":553,"total_token_length":789,"max_tokens_setting":1024}
+{"idx":369901,"func":"static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)\n{\n\tstruct inode *inode;\n\tstruct task_struct *task;\n\tint fd;\n\tstruct files_struct *files;\n\tconst struct cred *cred;\n\n\tif (nd && nd->flags & LOOKUP_RCU)\n\t\treturn -ECHILD;\n\n\tinode = dentry->d_inode;\n\ttask = get_proc_task(inode);\n\tfd = proc_fd(inode);\n\n\tif (task) {\n\t\tfiles = get_files_struct(task);\n\t\tif (files) {\n\t\t\trcu_read_lock();\n\t\t\tif (fcheck_files(files, fd)) {\n\t\t\t\trcu_read_unlock();\n\t\t\t\tput_files_struct(files);\n\t\t\t\tif (task_dumpable(task)) {\n\t\t\t\t\trcu_read_lock();\n\t\t\t\t\tcred = __task_cred(task);\n\t\t\t\t\tinode->i_uid = cred->euid;\n\t\t\t\t\tinode->i_gid = cred->egid;\n\t\t\t\t\trcu_read_unlock();\n\t\t\t\t} else {\n\t\t\t\t\tinode->i_uid = 0;\n\t\t\t\t\tinode->i_gid = 0;\n\t\t\t\t}\n\t\t\t\tinode->i_mode &= ~(S_ISUID | S_ISGID);\n\t\t\t\tsecurity_task_to_inode(task, inode);\n\t\t\t\tput_task_struct(task);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\trcu_read_unlock();\n\t\t\tput_files_struct(files);\n\t\t}\n\t\tput_task_struct(task);\n\t}\n\td_drop(dentry);\n\treturn 0;\n}","target":0,"code_token_length":291,"total_token_length":527,"max_tokens_setting":1024}
+{"idx":405384,"func":"static struct xfrm_policy *xfrm_migrate_policy_find(const struct xfrm_selector *sel,\n\t\t\t\t\t\t    u8 dir, u8 type, struct net *net, u32 if_id)\n{\n\tstruct xfrm_policy *pol, *ret = NULL;\n\tstruct hlist_head *chain;\n\tu32 priority = ~0U;\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\tchain = policy_hash_direct(net, &sel->daddr, &sel->saddr, sel->family, dir);\n\thlist_for_each_entry(pol, chain, bydst) {\n\t\tif ((if_id == 0 || pol->if_id == if_id) &&\n\t\t    xfrm_migrate_selector_match(sel, &pol->selector) &&\n\t\t    pol->type == type) {\n\t\t\tret = pol;\n\t\t\tpriority = ret->priority;\n\t\t\tbreak;\n\t\t}\n\t}\n\tchain = &net->xfrm.policy_inexact[dir];\n\thlist_for_each_entry(pol, chain, bydst_inexact_list) {\n\t\tif ((pol->priority >= priority) && ret)\n\t\t\tbreak;\n\n\t\tif ((if_id == 0 || pol->if_id == if_id) &&\n\t\t    xfrm_migrate_selector_match(sel, &pol->selector) &&\n\t\t    pol->type == type) {\n\t\t\tret = pol;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\txfrm_pol_hold(ret);\n\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\n\treturn ret;\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":299895,"func":"read_named_list(tree_node **anchorp, int *numberp, int max, uschar *s,\n  uschar *tname)\n{\nBOOL forcecache = FALSE;\nuschar *ss;\ntree_node *t;\nnamedlist_block *nb = store_get(sizeof(namedlist_block));\n\nif (Ustrncmp(s, \"_cache\", 6) == 0)\n  {\n  forcecache = TRUE;\n  s += 6;\n  }\n\nif (!isspace(*s))\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"unrecognized configuration line\");\n\nif (*numberp >= max)\n log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"too many named %ss (max is %d)\\n\",\n   tname, max);\n\nwhile (isspace(*s)) s++;\nss = s;\nwhile (isalnum(*s) || *s == '_') s++;\nt = store_get(sizeof(tree_node) + s-ss);\nUstrncpy(t->name, ss, s-ss);\nt->name[s-ss] = 0;\nwhile (isspace(*s)) s++;\n\nif (!tree_insertnode(anchorp, t))\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"duplicate name \\\"%s\\\" for a named %s\", t->name, tname);\n\nt->data.ptr = nb;\nnb->number = *numberp;\n*numberp += 1;\n\nif (*s++ != '=') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n  \"missing '=' after \\\"%s\\\"\", t->name);\nwhile (isspace(*s)) s++;\nnb->string = read_string(s, t->name);\nnb->cache_data = NULL;\n\n\/* Check the string for any expansions; if any are found, mark this list\nuncacheable unless the user has explicited forced caching. *\/\n\nif (!forcecache && Ustrchr(nb->string, '$') != NULL) nb->number = -1;\n}","target":0,"code_token_length":421,"total_token_length":657,"max_tokens_setting":1024}
+{"idx":205630,"func":"static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)\n{\n\tstruct kiocb *kiocb = &req->rw.kiocb;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct file *file = req->file;\n\tint ret;\n\n\tif (unlikely(!file || !(file->f_mode & mode)))\n\t\treturn -EBADF;\n\n\tif (!io_req_ffs_set(req))\n\t\treq->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;\n\n\tkiocb->ki_flags = iocb_flags(file);\n\tret = kiocb_set_rw_flags(kiocb, req->rw.flags);\n\tif (unlikely(ret))\n\t\treturn ret;\n\n\t\/*\n\t * If the file is marked O_NONBLOCK, still allow retry for it if it\n\t * supports async. Otherwise it's impossible to use O_NONBLOCK files\n\t * reliably. If not, or it IOCB_NOWAIT is set, don't retry.\n\t *\/\n\tif ((kiocb->ki_flags & IOCB_NOWAIT) ||\n\t    ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req)))\n\t\treq->flags |= REQ_F_NOWAIT;\n\n\tif (ctx->flags & IORING_SETUP_IOPOLL) {\n\t\tif (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tkiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE;\n\t\tkiocb->ki_complete = io_complete_rw_iopoll;\n\t\treq->iopoll_completed = 0;\n\t} else {\n\t\tif (kiocb->ki_flags & IOCB_HIPRI)\n\t\t\treturn -EINVAL;\n\t\tkiocb->ki_complete = io_complete_rw;\n\t}\n\n\treturn 0;\n}","target":1,"code_token_length":394,"total_token_length":630,"max_tokens_setting":1024}
+{"idx":440872,"func":"LogFilePrep(const char *fname, const char *backup, const char *idstring)\n{\n    char *logFileName = NULL;\n\n    \/* the format string below is controlled by the user,\n       this code should never be called with elevated privileges *\/\n    if (asprintf(&logFileName, fname, idstring) == -1)\n        FatalError(\"Cannot allocate space for the log file name\\n\");\n\n    if (backup && *backup) {\n        struct stat buf;\n\n        if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {\n            char *suffix;\n            char *oldLog;\n\n            if ((asprintf(&suffix, backup, idstring) == -1) ||\n                (asprintf(&oldLog, \"%s%s\", logFileName, suffix) == -1)) {\n                FatalError(\"Cannot allocate space for the log file name\\n\");\n            }\n            free(suffix);\n\n            if (rename(logFileName, oldLog) == -1) {\n                FatalError(\"Cannot move old log file \\\"%s\\\" to \\\"%s\\\"\\n\",\n                           logFileName, oldLog);\n            }\n            free(oldLog);\n        }\n    }\n    else {\n        if (remove(logFileName) != 0 && errno != ENOENT) {\n            FatalError(\"Cannot remove old log file \\\"%s\\\": %s\\n\",\n                       logFileName, strerror(errno));\n        }\n    }\n\n    return logFileName;\n}","target":0,"code_token_length":292,"total_token_length":528,"max_tokens_setting":1024}
+{"idx":310302,"func":"dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,\n                        const char **msg)\n{\n  *msg = NULL;\n\n  if (!strcmp(key, \"\/tor\/server\/all\")) {\n    routerlist_t *rl = router_get_routerlist();\n    SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,\n                      smartlist_add(descs_out, &(r->cache_info)));\n  } else if (!strcmp(key, \"\/tor\/server\/authority\")) {\n    routerinfo_t *ri = router_get_my_routerinfo();\n    if (ri)\n      smartlist_add(descs_out, &(ri->cache_info));\n  } else if (!strcmpstart(key, \"\/tor\/server\/d\/\")) {\n    smartlist_t *digests = smartlist_create();\n    key += strlen(\"\/tor\/server\/d\/\");\n    dir_split_resource_into_fingerprints(key, digests, NULL,\n                                         DSR_HEX|DSR_SORT_UNIQ);\n    SMARTLIST_FOREACH(digests, const char *, d,\n       {\n         signed_descriptor_t *sd = router_get_by_descriptor_digest(d);\n         if (sd)\n           smartlist_add(descs_out,sd);\n       });\n    SMARTLIST_FOREACH(digests, char *, d, tor_free(d));\n    smartlist_free(digests);\n  } else if (!strcmpstart(key, \"\/tor\/server\/fp\/\")) {\n    smartlist_t *digests = smartlist_create();\n    time_t cutoff = time(NULL) - ROUTER_MAX_AGE_TO_PUBLISH;\n    key += strlen(\"\/tor\/server\/fp\/\");\n    dir_split_resource_into_fingerprints(key, digests, NULL,\n                                         DSR_HEX|DSR_SORT_UNIQ);\n    SMARTLIST_FOREACH(digests, const char *, d,\n       {\n         if (router_digest_is_me(d)) {\n           \/* make sure desc_routerinfo exists *\/\n           routerinfo_t *ri = router_get_my_routerinfo();\n           if (ri)\n             smartlist_add(descs_out, &(ri->cache_info));\n         } else {\n           routerinfo_t *ri = router_get_by_digest(d);\n           \/* Don't actually serve a descriptor that everyone will think is\n            * expired.  This is an (ugly) workaround to keep buggy 0.1.1.10\n            * Tors from downloading descriptors that they will throw away.\n            *\/\n           if (ri && ri->cache_info.published_on > cutoff)\n             smartlist_add(descs_out, &(ri->cache_info));\n         }\n       });\n    SMARTLIST_FOREACH(digests, char *, d, tor_free(d));\n    smartlist_free(digests);\n  } else {\n    *msg = \"Key not recognized\";\n    return -1;\n  }\n\n  if (!smartlist_len(descs_out)) {\n    *msg = \"Servers unavailable\";\n    return -1;\n  }\n  return 0;\n}","target":0,"code_token_length":596,"total_token_length":832,"max_tokens_setting":1024}
+{"idx":281106,"func":"static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,\n\t\t\t\t\t\t struct xfrm_flo *xflo,\n\t\t\t\t\t\t const struct flowi *fl,\n\t\t\t\t\t\t int num_xfrms,\n\t\t\t\t\t\t u16 family)\n{\n\tint err;\n\tstruct net_device *dev;\n\tstruct dst_entry *dst;\n\tstruct dst_entry *dst1;\n\tstruct xfrm_dst *xdst;\n\n\txdst = xfrm_alloc_dst(net, family);\n\tif (IS_ERR(xdst))\n\t\treturn xdst;\n\n\tif (!(xflo->flags & XFRM_LOOKUP_QUEUE) ||\n\t    net->xfrm.sysctl_larval_drop ||\n\t    num_xfrms <= 0)\n\t\treturn xdst;\n\n\tdst = xflo->dst_orig;\n\tdst1 = &xdst->u.dst;\n\tdst_hold(dst);\n\txdst->route = dst;\n\n\tdst_copy_metrics(dst1, dst);\n\n\tdst1->obsolete = DST_OBSOLETE_FORCE_CHK;\n\tdst1->flags |= DST_HOST | DST_XFRM_QUEUE;\n\tdst1->lastuse = jiffies;\n\n\tdst1->input = dst_discard;\n\tdst1->output = xdst_queue_output;\n\n\tdst_hold(dst);\n\tdst1->child = dst;\n\tdst1->path = dst;\n\n\txfrm_init_path((struct xfrm_dst *)dst1, dst, 0);\n\n\terr = -ENODEV;\n\tdev = dst->dev;\n\tif (!dev)\n\t\tgoto free_dst;\n\n\terr = xfrm_fill_dst(xdst, dev, fl);\n\tif (err)\n\t\tgoto free_dst;\n\nout:\n\treturn xdst;\n\nfree_dst:\n\tdst_release(dst1);\n\txdst = ERR_PTR(err);\n\tgoto out;\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":398532,"func":"RZ_API const char *rz_bin_dwarf_get_attr_name(ut64 attr_code) {\n\tif (attr_code < RZ_ARRAY_SIZE(dwarf_attr_encodings)) {\n\t\treturn dwarf_attr_encodings[attr_code];\n\t}\n\t\/\/ the below codes are much sparser, so putting them in an array would require a lot of\n\t\/\/ unused memory\n\tswitch (attr_code) {\n\tcase DW_AT_lo_user:\n\t\treturn \"DW_AT_lo_user\";\n\tcase DW_AT_MIPS_linkage_name:\n\t\treturn \"DW_AT_MIPS_linkage_name\";\n\tcase DW_AT_GNU_call_site_value:\n\t\treturn \"DW_AT_GNU_call_site_value\";\n\tcase DW_AT_GNU_call_site_data_value:\n\t\treturn \"DW_AT_GNU_call_site_data_value\";\n\tcase DW_AT_GNU_call_site_target:\n\t\treturn \"DW_AT_GNU_call_site_target\";\n\tcase DW_AT_GNU_call_site_target_clobbered:\n\t\treturn \"DW_AT_GNU_call_site_target_clobbered\";\n\tcase DW_AT_GNU_tail_call:\n\t\treturn \"DW_AT_GNU_tail_call\";\n\tcase DW_AT_GNU_all_tail_call_sites:\n\t\treturn \"DW_AT_GNU_all_tail_call_sites\";\n\tcase DW_AT_GNU_all_call_sites:\n\t\treturn \"DW_AT_GNU_all_call_sites\";\n\tcase DW_AT_GNU_all_source_call_sites:\n\t\treturn \"DW_AT_GNU_all_source_call_sites\";\n\tcase DW_AT_GNU_macros:\n\t\treturn \"DW_AT_GNU_macros\";\n\tcase DW_AT_GNU_deleted:\n\t\treturn \"DW_AT_GNU_deleted\";\n\tcase DW_AT_GNU_dwo_name:\n\t\treturn \"DW_AT_GNU_dwo_name\";\n\tcase DW_AT_GNU_dwo_id:\n\t\treturn \"DW_AT_GNU_dwo_id\";\n\tcase DW_AT_GNU_ranges_base:\n\t\treturn \"DW_AT_GNU_ranges_base\";\n\tcase DW_AT_GNU_addr_base:\n\t\treturn \"DW_AT_GNU_addr_base\";\n\tcase DW_AT_GNU_pubnames:\n\t\treturn \"DW_AT_GNU_pubnames\";\n\tcase DW_AT_GNU_pubtypes:\n\t\treturn \"DW_AT_GNU_pubtypes\";\n\tcase DW_AT_hi_user:\n\t\treturn \"DW_AT_hi_user\";\n\tdefault:\n\t\treturn NULL;\n\t}\n}","target":0,"code_token_length":452,"total_token_length":688,"max_tokens_setting":1024}
+{"idx":270364,"func":"static bool ok_png_read_header(ok_png_decoder *decoder, uint32_t chunk_length) {\n    ok_png *png = decoder->png;\n    if (chunk_length != 13) {\n        ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid IHDR chunk length\");\n        return false;\n    }\n    uint8_t chunk_data[13];\n    if (!ok_read(decoder, chunk_data, sizeof(chunk_data))) {\n        return false;\n    }\n    png->width = readBE32(chunk_data);\n    png->height = readBE32(chunk_data + 4);\n    png->bpp = 4; \/\/ Always decoding to 32-bit color\n    decoder->bit_depth = chunk_data[8];\n    decoder->color_type = chunk_data[9];\n    uint8_t compression_method = chunk_data[10];\n    uint8_t filter_method = chunk_data[11];\n    decoder->interlace_method = chunk_data[12];\n    uint64_t stride = (uint64_t)png->width * png->bpp;\n\n    if (compression_method != 0) {\n        ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid compression method\");\n        return false;\n    } else if (filter_method != 0) {\n        ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid filter method\");\n        return false;\n    } else if (decoder->interlace_method != 0 && decoder->interlace_method != 1) {\n        ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid interlace method\");\n        return false;\n    } else if (stride > UINT32_MAX) {\n        ok_png_error(png, OK_PNG_ERROR_UNSUPPORTED, \"Width too large\");\n        return false;\n    }\n\n    const int c = decoder->color_type;\n    const int b = decoder->bit_depth;\n    const bool valid =\n        (c == OK_PNG_COLOR_TYPE_GRAYSCALE && (b == 1 || b == 2 || b == 4 || b == 8 || b == 16)) ||\n        (c == OK_PNG_COLOR_TYPE_RGB && (b == 8 || b == 16)) ||\n        (c == OK_PNG_COLOR_TYPE_PALETTE && (b == 1 || b == 2 || b == 4 || b == 8)) ||\n        (c == OK_PNG_COLOR_TYPE_GRAYSCALE_WITH_ALPHA && (b == 8 || b == 16)) ||\n        (c == OK_PNG_COLOR_TYPE_RGB_WITH_ALPHA && (b == 8 || b == 16));\n\n    if (!valid) {\n        ok_png_error(png, OK_PNG_ERROR_INVALID, \"Invalid combination of color type and bit depth\");\n        return false;\n    }\n\n    png->stride = (uint32_t)stride;\n    png->has_alpha = (c == OK_PNG_COLOR_TYPE_GRAYSCALE_WITH_ALPHA ||\n                      c == OK_PNG_COLOR_TYPE_RGB_WITH_ALPHA);\n    decoder->interlace_pass = 0;\n    decoder->ready_for_next_interlace_pass = true;\n    return true;\n}","target":0,"code_token_length":651,"total_token_length":887,"max_tokens_setting":1024}
+{"idx":405325,"func":"xfrm_policy_inexact_insert_node(struct net *net,\n\t\t\t\tstruct rb_root *root,\n\t\t\t\txfrm_address_t *addr,\n\t\t\t\tu16 family, u8 prefixlen, u8 dir)\n{\n\tstruct xfrm_pol_inexact_node *cached = NULL;\n\tstruct rb_node **p, *parent = NULL;\n\tstruct xfrm_pol_inexact_node *node;\n\n\tp = &root->rb_node;\n\twhile (*p) {\n\t\tint delta;\n\n\t\tparent = *p;\n\t\tnode = rb_entry(*p, struct xfrm_pol_inexact_node, node);\n\n\t\tdelta = xfrm_policy_addr_delta(addr, &node->addr,\n\t\t\t\t\t       node->prefixlen,\n\t\t\t\t\t       family);\n\t\tif (delta == 0 && prefixlen >= node->prefixlen) {\n\t\t\tWARN_ON_ONCE(cached); \/* ipsec policies got lost *\/\n\t\t\treturn node;\n\t\t}\n\n\t\tif (delta < 0)\n\t\t\tp = &parent->rb_left;\n\t\telse\n\t\t\tp = &parent->rb_right;\n\n\t\tif (prefixlen < node->prefixlen) {\n\t\t\tdelta = xfrm_policy_addr_delta(addr, &node->addr,\n\t\t\t\t\t\t       prefixlen,\n\t\t\t\t\t\t       family);\n\t\t\tif (delta)\n\t\t\t\tcontinue;\n\n\t\t\t\/* This node is a subnet of the new prefix. It needs\n\t\t\t * to be removed and re-inserted with the smaller\n\t\t\t * prefix and all nodes that are now also covered\n\t\t\t * by the reduced prefixlen.\n\t\t\t *\/\n\t\t\trb_erase(&node->node, root);\n\n\t\t\tif (!cached) {\n\t\t\t\txfrm_pol_inexact_node_init(node, addr,\n\t\t\t\t\t\t\t   prefixlen);\n\t\t\t\tcached = node;\n\t\t\t} else {\n\t\t\t\t\/* This node also falls within the new\n\t\t\t\t * prefixlen. Merge the to-be-reinserted\n\t\t\t\t * node and this one.\n\t\t\t\t *\/\n\t\t\t\txfrm_policy_inexact_node_merge(net, node,\n\t\t\t\t\t\t\t       cached, family);\n\t\t\t\tkfree_rcu(node, rcu);\n\t\t\t}\n\n\t\t\t\/* restart *\/\n\t\t\tp = &root->rb_node;\n\t\t\tparent = NULL;\n\t\t}\n\t}\n\n\tnode = cached;\n\tif (!node) {\n\t\tnode = xfrm_pol_inexact_node_alloc(addr, prefixlen);\n\t\tif (!node)\n\t\t\treturn NULL;\n\t}\n\n\trb_link_node_rcu(&node->node, parent, p);\n\trb_insert_color(&node->node, root);\n\n\treturn node;\n}","target":0,"code_token_length":497,"total_token_length":733,"max_tokens_setting":1024}
+{"idx":265459,"func":"static int sqfs_get_lregfile_info(struct squashfs_lreg_inode *lreg,\n\t\t\t\t  struct squashfs_file_info *finfo,\n\t\t\t\t  struct squashfs_fragment_block_entry *fentry,\n\t\t\t\t __le32 blksz)\n{\n\tint datablk_count = 0, ret;\n\n\tfinfo->size = get_unaligned_le64(&lreg->file_size);\n\tfinfo->offset = get_unaligned_le32(&lreg->offset);\n\tfinfo->start = get_unaligned_le64(&lreg->start_block);\n\tfinfo->frag = SQFS_IS_FRAGMENTED(get_unaligned_le32(&lreg->fragment));\n\n\tif (finfo->frag && finfo->offset == 0xFFFFFFFF)\n\t\treturn -EINVAL;\n\n\tif (finfo->size < 1 || finfo->start == 0x7FFFFFFF)\n\t\treturn -EINVAL;\n\n\tif (finfo->frag) {\n\t\tdatablk_count = finfo->size \/ le32_to_cpu(blksz);\n\t\tret = sqfs_frag_lookup(get_unaligned_le32(&lreg->fragment),\n\t\t\t\t       fentry);\n\t\tif (ret < 0)\n\t\t\treturn -EINVAL;\n\t\tfinfo->comp = ret;\n\t\tif (fentry->size < 1 || fentry->start == 0x7FFFFFFF)\n\t\t\treturn -EINVAL;\n\t} else {\n\t\tdatablk_count = DIV_ROUND_UP(finfo->size, le32_to_cpu(blksz));\n\t}\n\n\tfinfo->blk_sizes = malloc(datablk_count * sizeof(u32));\n\tif (!finfo->blk_sizes)\n\t\treturn -ENOMEM;\n\n\treturn datablk_count;\n}","target":0,"code_token_length":345,"total_token_length":581,"max_tokens_setting":1024}
+{"idx":256169,"func":"ALWAYS_INLINE void MulAdd3Way128(const Packet a1, const Packet a2,\n                                 const Packet a3, const float** inp1,\n                                 const float** inp2, const float** inp3,\n                                 float** out) {\n  if (kNumOperands == 8) {\n    FourMulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n    FourMulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n    FourMulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n    FourMulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n  } else {\n    DCHECK_LE(4 * kNumOperands, 128);\n    for (int i = 0; i < 128 \/ (4 * kNumOperands); ++i) {\n      MulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n      MulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n      MulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n      MulAdd3Way(a1, a2, a3, inp1, inp2, inp3, out);\n    }\n  }\n}","target":0,"code_token_length":321,"total_token_length":557,"max_tokens_setting":1024}
+{"idx":225681,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nstatic u32 sgpd_size_entry(u32 grouping_type, void *entry)\n{\n\tswitch (grouping_type) {\n\tcase GF_ISOM_SAMPLE_GROUP_ROLL:\n\tcase GF_ISOM_SAMPLE_GROUP_PROL:\n\t\treturn 2;\n\tcase GF_ISOM_SAMPLE_GROUP_TELE:\n\tcase GF_ISOM_SAMPLE_GROUP_RAP:\n\tcase GF_ISOM_SAMPLE_GROUP_SAP:\n\tcase GF_ISOM_SAMPLE_GROUP_SYNC:\n\t\treturn 1;\n\tcase GF_ISOM_SAMPLE_GROUP_TSCL:\n\t\treturn 20;\n\tcase GF_ISOM_SAMPLE_GROUP_LBLI:\n\t\treturn 2;\n\tcase GF_ISOM_SAMPLE_GROUP_TSAS:\n\tcase GF_ISOM_SAMPLE_GROUP_STSA:\n\t\treturn 0;\n\tcase GF_ISOM_SAMPLE_GROUP_SEIG:\n\t{\n\t\tGF_CENCSampleEncryptionGroupEntry *seig = (GF_CENCSampleEncryptionGroupEntry *)entry;\n\t\tBool use_mkey = seig->key_info[0] ? GF_TRUE : GF_FALSE;\n\t\tif (use_mkey) {\n\t\t\treturn 3 + seig->key_info_size-1;\n\t\t}\n\t\treturn seig->key_info_size; \/\/== 3 + (seig->key_info_size-3);\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_OINF:\n\t\treturn gf_isom_oinf_size_entry(entry);\n\tcase GF_ISOM_SAMPLE_GROUP_LINF:\n\t\treturn gf_isom_linf_size_entry(entry);\n\tcase GF_ISOM_SAMPLE_GROUP_SPOR:\n\t{\n\t\tGF_SubpictureOrderEntry *spor = (GF_SubpictureOrderEntry *)entry;\n\t\tu32 s = 2 + 2*spor->num_subpic_ref_idx;\n\t\tif (spor->subpic_id_info_flag) {\n\t\t\ts += 3;\n\t\t}\n\t\treturn s;\n\t}\n\tcase GF_ISOM_SAMPLE_GROUP_SULM:\n\t{\n\t\tGF_SubpictureLayoutMapEntry *sulm = (GF_SubpictureLayoutMapEntry *) entry;\n\t\treturn 6 + 2*sulm->nb_entries;\n\t}\n\n\tdefault:\n\t\treturn ((GF_DefaultSampleGroupDescriptionEntry *)entry)->length;\n\t}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":359456,"func":"bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,\n        afi_t afi, safi_t safi)\n{\n  char timebuf[BGP_UPTIME_LEN];\n  char rmbuf[14];\n  const char *rmname;\n  struct peer *peer;\n  struct listnode *node, *nnode;\n  int len;\n  int count = 0;\n\n  if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))\n    {\n      for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))\n        {\n          count++;\n          bgp_write_rsclient_summary (vty, peer, afi, safi);\n        }\n      return count;\n    }\n\n  len = vty_out (vty, \"%s\", rsclient->host);\n  len = 16 - len;\n\n  if (len < 1)\n    vty_out (vty, \"%s%*s\", VTY_NEWLINE, 16, \" \");\n  else\n    vty_out (vty, \"%*s\", len, \" \");\n\n  vty_out (vty, \"4 \");\n\n  vty_out (vty, \"%5d \", rsclient->as);\n\n  rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);\n  if ( rmname && strlen (rmname) > 13 )\n    {\n      sprintf (rmbuf, \"%13s\", \"...\");\n      rmname = strncpy (rmbuf, rmname, 10);\n    }\n  else if (! rmname)\n    rmname = \"<none>\";\n  vty_out (vty, \" %13s \", rmname);\n\n  rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);\n  if ( rmname && strlen (rmname) > 13 )\n    {\n      sprintf (rmbuf, \"%13s\", \"...\");\n      rmname = strncpy (rmbuf, rmname, 10);\n    }\n  else if (! rmname)\n    rmname = \"<none>\";\n  vty_out (vty, \" %13s \", rmname);\n\n  vty_out (vty, \"%8s\", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));\n\n  if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))\n    vty_out (vty, \" Idle (Admin)\");\n  else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))\n    vty_out (vty, \" Idle (PfxCt)\");\n  else\n    vty_out (vty, \" %-11s\", LOOKUP(bgp_status_msg, rsclient->status));\n\n  vty_out (vty, \"%s\", VTY_NEWLINE);\n\n  return 1;\n}","target":0,"code_token_length":619,"total_token_length":855,"max_tokens_setting":1024}
+{"idx":252315,"func":"static bool hufBuildDecTable(const long long *hcode,  \/\/ i : encoding table\n                             int im,                  \/\/ i : min index in hcode\n                             int iM,                  \/\/ i : max index in hcode\n                             HufDec *hdecod)  \/\/  o: (allocated by caller)\n\/\/     decoding table [HUF_DECSIZE]\n{\n  \/\/\n  \/\/ Init hashtable & loop on all codes.\n  \/\/ Assumes that hufClearDecTable(hdecod) has already been called.\n  \/\/\n\n  for (; im <= iM; im++) {\n    long long c = hufCode(hcode[im]);\n    int l = hufLength(hcode[im]);\n\n    if (c >> l) {\n      \/\/\n      \/\/ Error: c is supposed to be an l-bit code,\n      \/\/ but c contains a value that is greater\n      \/\/ than the largest l-bit number.\n      \/\/\n\n      \/\/ invalidTableEntry();\n      return false;\n    }\n\n    if (l > HUF_DECBITS) {\n      \/\/\n      \/\/ Long code: add a secondary entry\n      \/\/\n\n      HufDec *pl = hdecod + (c >> (l - HUF_DECBITS));\n\n      if (pl->len) {\n        \/\/\n        \/\/ Error: a short code has already\n        \/\/ been stored in table entry *pl.\n        \/\/\n\n        \/\/ invalidTableEntry();\n        return false;\n      }\n\n      pl->lit++;\n\n      if (pl->p) {\n        int *p = pl->p;\n        pl->p = new int[pl->lit];\n\n        for (int i = 0; i < pl->lit - 1; ++i) pl->p[i] = p[i];\n\n        delete[] p;\n      } else {\n        pl->p = new int[1];\n      }\n\n      pl->p[pl->lit - 1] = im;\n    } else if (l) {\n      \/\/\n      \/\/ Short code: init all primary entries\n      \/\/\n\n      HufDec *pl = hdecod + (c << (HUF_DECBITS - l));\n\n      for (long long i = 1ULL << (HUF_DECBITS - l); i > 0; i--, pl++) {\n        if (pl->len || pl->p) {\n          \/\/\n          \/\/ Error: a short code or a long code has\n          \/\/ already been stored in table entry *pl.\n          \/\/\n\n          \/\/ invalidTableEntry();\n          return false;\n        }\n\n        pl->len = l;\n        pl->lit = im;\n      }\n    }\n  }\n\n  return true;\n}","target":0,"code_token_length":552,"total_token_length":788,"max_tokens_setting":1024}
+{"idx":220100,"func":"nfs4_file_open(struct inode *inode, struct file *filp)\n{\n\tstruct nfs_open_context *ctx;\n\tstruct dentry *dentry = file_dentry(filp);\n\tstruct dentry *parent = NULL;\n\tstruct inode *dir;\n\tunsigned openflags = filp->f_flags;\n\tstruct iattr attr;\n\tint err;\n\n\t\/*\n\t * If no cached dentry exists or if it's negative, NFSv4 handled the\n\t * opens in ->lookup() or ->create().\n\t *\n\t * We only get this far for a cached positive dentry.  We skipped\n\t * revalidation, so handle it here by dropping the dentry and returning\n\t * -EOPENSTALE.  The VFS will retry the lookup\/create\/open.\n\t *\/\n\n\tdprintk(\"NFS: open file(%pd2)\\n\", dentry);\n\n\terr = nfs_check_flags(openflags);\n\tif (err)\n\t\treturn err;\n\n\tif ((openflags & O_ACCMODE) == 3)\n\t\topenflags--;\n\n\t\/* We can't create new files here *\/\n\topenflags &= ~(O_CREAT|O_EXCL);\n\n\tparent = dget_parent(dentry);\n\tdir = d_inode(parent);\n\n\tctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp);\n\terr = PTR_ERR(ctx);\n\tif (IS_ERR(ctx))\n\t\tgoto out;\n\n\tattr.ia_valid = ATTR_OPEN;\n\tif (openflags & O_TRUNC) {\n\t\tattr.ia_valid |= ATTR_SIZE;\n\t\tattr.ia_size = 0;\n\t\tfilemap_write_and_wait(inode->i_mapping);\n\t}\n\n\tinode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr, NULL);\n\tif (IS_ERR(inode)) {\n\t\terr = PTR_ERR(inode);\n\t\tswitch (err) {\n\t\tdefault:\n\t\t\tgoto out_put_ctx;\n\t\tcase -ENOENT:\n\t\tcase -ESTALE:\n\t\tcase -EISDIR:\n\t\tcase -ENOTDIR:\n\t\tcase -ELOOP:\n\t\t\tgoto out_drop;\n\t\t}\n\t}\n\tif (inode != d_inode(dentry))\n\t\tgoto out_drop;\n\n\tnfs_file_set_open_context(filp, ctx);\n\tnfs_fscache_open_file(inode, filp);\n\terr = 0;\n\nout_put_ctx:\n\tput_nfs_open_context(ctx);\nout:\n\tdput(parent);\n\treturn err;\n\nout_drop:\n\td_drop(dentry);\n\terr = -EOPENSTALE;\n\tgoto out_put_ctx;\n}","target":0,"code_token_length":507,"total_token_length":743,"max_tokens_setting":1024}
+{"idx":222915,"func":"  Status UpdateOutputShapesUsingAnnotatedInformation(const NodeDef& node,\n                                                     NodeContext* c) const {\n    const auto& attr = node.attr();\n    if (attr.count(kOutputSame) == 0 || !attr.at(kOutputSame).b() ||\n        attr.count(kOutputShapes) == 0)\n      return Status::OK();\n\n    InferenceContext* ic = c->inference_context.get();\n    int output_size = attr.at(kOutputShapes).list().shape_size();\n\n    for (int i = 0; i < ic->num_outputs(); i++) {\n      \/\/ Annotated Switch node has only one output. Propagate the shape to all\n      \/\/ the outputs.\n      int shape_index = IsSwitch(node) ? 0 : i;\n      if (shape_index >= output_size) {\n        LOG(WARNING)\n            << \"UpdateOutputShapesUsingAnnotatedInformation() -- node: \"\n            << node.name() << \", inferred output shape size \"\n            << ic->num_outputs() << \", annotated output shape size \"\n            << output_size;\n        break;\n      }\n\n      const TensorShapeProto& shape =\n          attr.at(kOutputShapes).list().shape(shape_index);\n      if (shape.dim().empty()) continue;\n\n      ShapeHandle output_shape;\n      TF_RETURN_IF_ERROR(ic->MakeShapeFromShapeProto(shape, &output_shape));\n\n      \/\/ Check if annotated shapes are incompatible with inferred shapes.\n      if ((ic->FullyDefined(ic->output(i)) &&\n           !SameShapes(ic->output(i), output_shape)) ||\n          (!ic->FullyDefined(ic->output(i)) &&\n           !CompatibleShapes(ic->output(i), output_shape))) {\n        LOG(WARNING)\n            << \"UpdateOutputShapesUsingAnnotatedInformation() -- node: \"\n            << node.name() << \", inferred output shape \"\n            << \"doesn't match for i=\" << i << \": \"\n            << \"ic->output(k): \" << ic->DebugString(ic->output(i))\n            << \", annotated output shape: \" << ic->DebugString(output_shape)\n            << \" -- \" << node.DebugString();\n        c->shape_incompatible = true;\n      }\n\n      \/\/ Only use annotated shapes if the inference shape is unknown and\n      \/\/ compatible with annotated shapes.\n      if (!ic->FullyDefined(ic->output(i)) &&\n          CompatibleShapes(ic->output(i), output_shape)) {\n        VLOG(3) << \"UpdateOutputShapesUsingAnnotatedInformation() -- node: \"\n                << node.name() << \", inferred output shape \" << i << \": \"\n                << \"ic->output(i): \" << ic->DebugString(ic->output(i))\n                << \", annotated output shape: \" << ic->DebugString(output_shape)\n                << \" -- \" << node.ShortDebugString();\n        ic->set_output(i, output_shape);\n      }\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":594,"total_token_length":830,"max_tokens_setting":1024}
+{"idx":413703,"func":"static void print_hint_h_format(HintNode *node) {\n\tswitch (node->type) {\n\tcase HINT_NODE_ADDR: {\n\t\tconst RAnalAddrHintRecord *record;\n\t\tr_vector_foreach (node->addr_hints, record) {\n\t\t\tswitch (record->type) {\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_IMMBASE:\n\t\t\t\tr_cons_printf (\" immbase=%d\", record->immbase);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_JUMP:\n\t\t\t\tr_cons_printf (\" jump=0x%08\"PFMT64x, record->jump);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_FAIL:\n\t\t\t\tr_cons_printf (\" fail=0x%08\"PFMT64x, record->fail);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_STACKFRAME:\n\t\t\t\tr_cons_printf (\" stackframe=0x%\"PFMT64x, record->stackframe);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_PTR:\n\t\t\t\tr_cons_printf (\" ptr=0x%\"PFMT64x, record->ptr);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_NWORD:\n\t\t\t\tr_cons_printf (\" nword=%d\", record->nword);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_RET:\n\t\t\t\tr_cons_printf (\" ret=0x%08\"PFMT64x, record->retval);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_NEW_BITS:\n\t\t\t\tr_cons_printf (\" newbits=%d\", record->newbits);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_SIZE:\n\t\t\t\tr_cons_printf (\" size=%\"PFMT64u, record->size);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_SYNTAX:\n\t\t\t\tr_cons_printf (\" syntax='%s'\", record->syntax);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_OPTYPE: {\n\t\t\t\tconst char *type = r_anal_optype_to_string (record->optype);\n\t\t\t\tif (type) {\n\t\t\t\t\tr_cons_printf (\" type='%s'\", type);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_OPCODE:\n\t\t\t\tr_cons_printf (\" opcode='%s'\", record->opcode);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_TYPE_OFFSET:\n\t\t\t\tr_cons_printf (\" offset='%s'\", record->type_offset);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_ESIL:\n\t\t\t\tr_cons_printf (\" esil='%s'\", record->esil);\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_HIGH:\n\t\t\t\tr_cons_printf (\" high=true\");\n\t\t\t\tbreak;\n\t\t\tcase R_ANAL_ADDR_HINT_TYPE_VAL:\n\t\t\t\tr_cons_printf (\" val=0x%08\"PFMT64x, record->val);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\t}\n\tcase HINT_NODE_ARCH:\n\t\tif (node->arch) {\n\t\t\tr_cons_printf (\" arch='%s'\", node->arch);\n\t\t} else {\n\t\t\tr_cons_print (\" arch=RESET\");\n\t\t}\n\t\tbreak;\n\tcase HINT_NODE_BITS:\n\t\tif (node->bits) {\n\t\t\tr_cons_printf (\" bits=%d\", node->bits);\n\t\t} else {\n\t\t\tr_cons_print (\" bits=RESET\");\n\t\t}\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":674,"total_token_length":910,"max_tokens_setting":1024}
+{"idx":314494,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_attr_get_rtcp(const pjmedia_sdp_attr *attr,\n\t\t\t\t\t      pjmedia_sdp_rtcp_attr *rtcp)\n{\n    pj_scanner scanner;\n    pj_str_t token;\n    pj_status_t status = -1;\n    PJ_USE_EXCEPTION;\n\n    PJ_ASSERT_RETURN(pj_strcmp2(&attr->name, \"rtcp\")==0, PJ_EINVALIDOP);\n\n    if (attr->value.slen == 0)\n        return PJMEDIA_SDP_EINATTR;\n\n    init_sdp_parser();\n\n    \/* fmtp BNF:\n     *\ta=rtcp:<port> [nettype addrtype address]\n     *\/\n\n    \/* The buffer passed to the scanner is not guaranteed to be NULL\n     * terminated, but should be safe. See ticket #2063.\n     *\/\n    pj_scan_init(&scanner, (char*)attr->value.ptr, attr->value.slen,\n\t\t PJ_SCAN_AUTOSKIP_WS, &on_scanner_error);\n\n    \/* Init *\/\n    rtcp->net_type.slen = rtcp->addr_type.slen = rtcp->addr.slen = 0;\n\n    \/* Parse *\/\n    PJ_TRY {\n\n\t\/* Get the port *\/\n\tpj_scan_get(&scanner, &cs_token, &token);\n\trtcp->port = pj_strtoul(&token);\n\n\t\/* Have address? *\/\n\tif (!pj_scan_is_eof(&scanner)) {\n\n\t    \/* Get network type *\/\n\t    pj_scan_get(&scanner, &cs_token, &rtcp->net_type);\n\n\t    \/* Get address type *\/\n\t    pj_scan_get(&scanner, &cs_token, &rtcp->addr_type);\n\n\t    \/* Get the address *\/\n\t    \/\/pj_scan_get(&scanner, &cs_token, &rtcp->addr);\n\t    pj_scan_get_until_chr(&scanner, \"\/ \\t\\r\\n\", &rtcp->addr);\n\n\t}\n\n\tstatus = PJ_SUCCESS;\n\n    }\n    PJ_CATCH_ANY {\n\tstatus = PJMEDIA_SDP_EINRTCP;\n    }\n    PJ_END;\n\n    pj_scan_fini(&scanner);\n    return status;\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":223462,"func":"static void check_str_end(compiler_common *common, jump_list **end_reached)\n{\n\/* Does not affect registers. Usually used in a tight spot. *\/\nDEFINE_COMPILER;\nstruct sljit_jump *jump;\n\nif (common->mode == PCRE2_JIT_COMPLETE)\n  {\n  add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));\n  return;\n  }\n\njump = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);\nif (common->mode == PCRE2_JIT_PARTIAL_SOFT)\n  {\n  add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));\n  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);\n  add_jump(compiler, end_reached, JUMP(SLJIT_JUMP));\n  }\nelse\n  {\n  add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));\n  if (common->partialmatchlabel != NULL)\n    JUMPTO(SLJIT_JUMP, common->partialmatchlabel);\n  else\n    add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));\n  }\nJUMPHERE(jump);\n}","target":0,"code_token_length":333,"total_token_length":569,"max_tokens_setting":1024}
+{"idx":300835,"func":"static int __tipc_nl_add_sk_publ(struct sk_buff *skb,\n\t\t\t\t struct netlink_callback *cb,\n\t\t\t\t struct publication *publ)\n{\n\tvoid *hdr;\n\tstruct nlattr *attrs;\n\n\thdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,\n\t\t\t  &tipc_genl_family, NLM_F_MULTI, TIPC_NL_PUBL_GET);\n\tif (!hdr)\n\t\tgoto msg_cancel;\n\n\tattrs = nla_nest_start_noflag(skb, TIPC_NLA_PUBL);\n\tif (!attrs)\n\t\tgoto genlmsg_cancel;\n\n\tif (nla_put_u32(skb, TIPC_NLA_PUBL_KEY, publ->key))\n\t\tgoto attr_msg_cancel;\n\tif (nla_put_u32(skb, TIPC_NLA_PUBL_TYPE, publ->sr.type))\n\t\tgoto attr_msg_cancel;\n\tif (nla_put_u32(skb, TIPC_NLA_PUBL_LOWER, publ->sr.lower))\n\t\tgoto attr_msg_cancel;\n\tif (nla_put_u32(skb, TIPC_NLA_PUBL_UPPER, publ->sr.upper))\n\t\tgoto attr_msg_cancel;\n\n\tnla_nest_end(skb, attrs);\n\tgenlmsg_end(skb, hdr);\n\n\treturn 0;\n\nattr_msg_cancel:\n\tnla_nest_cancel(skb, attrs);\ngenlmsg_cancel:\n\tgenlmsg_cancel(skb, hdr);\nmsg_cancel:\n\treturn -EMSGSIZE;\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":336625,"func":"RedCharDeviceVDIPort::read_one_msg_from_device()\n{\n    RedsState *reds;\n    int n;\n\n    reds = get_server();\n    while (reds->vdagent) {\n        switch (priv->read_state) {\n        case VDI_PORT_READ_STATE_READ_HEADER:\n            n = read(priv->receive_pos, priv->receive_len);\n            if (!n) {\n                return RedPipeItemPtr();\n            }\n            if ((priv->receive_len -= n)) {\n                priv->receive_pos += n;\n                return RedPipeItemPtr();\n            }\n            priv->message_receive_len = priv->vdi_chunk_header.size;\n            priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;\n            \/* fall through *\/\n        case VDI_PORT_READ_STATE_GET_BUFF: {\n            if (!(priv->current_read_buf = vdi_port_get_read_buf(this))) {\n                return RedPipeItemPtr();\n            }\n            priv->receive_pos = priv->current_read_buf->data;\n            priv->receive_len = MIN(priv->message_receive_len,\n                                    sizeof(priv->current_read_buf->data));\n            priv->current_read_buf->len = priv->receive_len;\n            priv->message_receive_len -= priv->receive_len;\n            priv->read_state = VDI_PORT_READ_STATE_READ_DATA;\n        }\n            \/* fall through *\/\n        case VDI_PORT_READ_STATE_READ_DATA: {\n            n = read(priv->receive_pos, priv->receive_len);\n            if (!n) {\n                return RedPipeItemPtr();\n            }\n            if ((priv->receive_len -= n)) {\n                priv->receive_pos += n;\n                break;\n            }\n            auto dispatch_buf = std::move(priv->current_read_buf);\n            priv->receive_pos = NULL;\n            if (priv->message_receive_len == 0) {\n                priv->read_state = VDI_PORT_READ_STATE_READ_HEADER;\n                priv->receive_pos = (uint8_t *)&priv->vdi_chunk_header;\n                priv->receive_len = sizeof(priv->vdi_chunk_header);\n            } else {\n                priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;\n            }\n            switch (vdi_port_read_buf_process(this, *dispatch_buf)) {\n            case AGENT_MSG_FILTER_OK:\n                reds_adjust_agent_capabilities(reds, (VDAgentMessage *) dispatch_buf->data);\n                return dispatch_buf;\n            case AGENT_MSG_FILTER_PROTO_ERROR:\n                reds_agent_remove(reds);\n                \/* fall through *\/\n            case AGENT_MSG_FILTER_MONITORS_CONFIG:\n                \/* fall through *\/\n            case AGENT_MSG_FILTER_DISCARD:\n                dispatch_buf.reset();\n            }\n        }\n        } \/* END switch *\/\n    } \/* END while *\/\n    return RedPipeItemPtr();\n}","target":0,"code_token_length":562,"total_token_length":798,"max_tokens_setting":1024}
+{"idx":197511,"func":"void HierarchicalBitmapRequester::PrepareForDecoding(void)\n{\n#if ACCUSOFT_CODE\n\n  UBYTE i;\n\n  BuildCommon();\n\n  if (m_ppDecodingMCU == NULL) {\n    m_ppDecodingMCU = (struct Line **)m_pEnviron->AllocMem(sizeof(struct Line *) * m_ucCount*8);\n    memset(m_ppDecodingMCU,0,sizeof(struct Line *) * m_ucCount * 8);\n  }\n\n  if (m_ppUpsampler == NULL) {\n    m_ppUpsampler = (class UpsamplerBase **)m_pEnviron->AllocMem(sizeof(class UpsamplerBase *) * m_ucCount);\n    memset(m_ppUpsampler,0,sizeof(class Upsampler *) * m_ucCount);\n\n    for(i = 0;i < m_ucCount;i++) {\n      class Component *comp = m_pFrame->ComponentOf(i);\n      UBYTE sx = comp->SubXOf();\n      UBYTE sy = comp->SubYOf();\n\n      if (sx > 1 || sy > 1) {\n        m_ppUpsampler[i] = UpsamplerBase::CreateUpsampler(m_pEnviron,sx,sy,\n                                                          m_ulPixelWidth,m_ulPixelHeight,\n                                                          m_pFrame->TablesOf()->isChromaCentered());\n        m_bSubsampling   = true;\n      }\n    }\n  }\n\n  if (m_pLargestScale)\n    m_pLargestScale->PrepareForDecoding();\n#endif\n}","target":1,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":273103,"func":"murmur_hash64(const void *key, int len, uint32_t seed)\n{\n  const int r = 24;\n  const uint32_t m = 0x5bd1e995;\n\n  const uint32_t *data;\n  const unsigned char *data_tail;\n  uint32_t k1;\n  uint32_t h1;\n  uint32_t k2;\n  uint32_t h2;\n\n  uint64_t h;\n\n  h1 = seed ^ len;\n  h2 = 0;\n\n  data = (const uint32_t *)key;\n\n  while (len >= 8)\n    {\n      k1 = *data++;\n      k1 *= m; k1 ^= k1 >> r; k1 *= m;\n      h1 *= m; h1 ^= k1;\n\n      k2 = *data++;\n      k2 *= m; k2 ^= k2 >> r; k2 *= m;\n      h2 *= m; h2 ^= k2;\n\n      len -= 8;\n    }\n\n  if (len >= 4)\n    {\n      k1 = *data++;\n      k1 *= m; k1 ^= k1 >> r; k1 *= m;\n      h1 *= m; h1 ^= k1;\n      len -= 4;\n    }\n\n  data_tail = (const unsigned char *)data;\n\n  switch(len)\n    {\n      case 3:\n\th2 ^= (uint32_t)(data_tail[2]) << 16;\n      case 2:\n\th2 ^= (uint32_t)(data_tail[1]) << 8;\n      case 1:\n\th2 ^= (uint32_t)(data_tail[0]);\n\th2 *= m;\n    };\n\n  h1 ^= h2 >> 18; h1 *= m;\n  h2 ^= h1 >> 22; h2 *= m;\n  h1 ^= h2 >> 17; h1 *= m;\n  h2 ^= h1 >> 19; h2 *= m;\n\n  h = h1;\n  h = (h << 32) | h2;\n\n  return h;\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":424915,"func":"void iwl_trans_pcie_free(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tint i;\n\n\tiwl_pcie_synchronize_irqs(trans);\n\n\tif (trans->trans_cfg->gen2)\n\t\tiwl_pcie_gen2_tx_free(trans);\n\telse\n\t\tiwl_pcie_tx_free(trans);\n\tiwl_pcie_rx_free(trans);\n\n\tif (trans_pcie->rba.alloc_wq) {\n\t\tdestroy_workqueue(trans_pcie->rba.alloc_wq);\n\t\ttrans_pcie->rba.alloc_wq = NULL;\n\t}\n\n\tif (trans_pcie->msix_enabled) {\n\t\tfor (i = 0; i < trans_pcie->alloc_vecs; i++) {\n\t\t\tirq_set_affinity_hint(\n\t\t\t\ttrans_pcie->msix_entries[i].vector,\n\t\t\t\tNULL);\n\t\t}\n\n\t\ttrans_pcie->msix_enabled = false;\n\t} else {\n\t\tiwl_pcie_free_ict(trans);\n\t}\n\n\tiwl_pcie_free_fw_monitor(trans);\n\n\tfor_each_possible_cpu(i) {\n\t\tstruct iwl_tso_hdr_page *p =\n\t\t\tper_cpu_ptr(trans_pcie->tso_hdr_page, i);\n\n\t\tif (p->page)\n\t\t\t__free_page(p->page);\n\t}\n\n\tfree_percpu(trans_pcie->tso_hdr_page);\n\tmutex_destroy(&trans_pcie->mutex);\n\tiwl_trans_free(trans);\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":246687,"func":"static GF_Err do_export_tracks()\n{\n\tGF_Err e;\n\tu32 i;\n\tchar szFile[GF_MAX_PATH+24];\n\tGF_MediaExporter mdump;\n\tfor (i=0; i<nb_track_act; i++) {\n\t\tu32 j;\n\t\tTrackAction *tka = &tracks[i];\n\t\tif (tka->act_type != TRAC_ACTION_RAW_EXTRACT) continue;\n\t\tmemset(&mdump, 0, sizeof(mdump));\n\t\tmdump.file = file;\n\t\tmdump.flags = tka->dump_type;\n\t\tmdump.trackID = tka->trackID;\n\t\tmdump.sample_num = tka->sample_num;\n\t\tif (tka->out_name) {\n\t\t\tmdump.out_name = tka->out_name;\n\t\t} else if (outName) {\n\t\t\tmdump.out_name = outName;\n\t\t\tmdump.flags |= GF_EXPORT_MERGE;\n\t\t\t\/*don't infer extension on user-given filename*\/\n\t\t\tmdump.flags |= GF_EXPORT_NO_FILE_EXT;\n\t\t} else if (mdump.trackID) {\n\t\t\tsprintf(szFile, \"%s_track%d\", outfile, mdump.trackID);\n\t\t\tmdump.out_name = szFile;\n\t\t} else {\n\t\t\tsprintf(szFile, \"%s_export\", outfile);\n\t\t\tmdump.out_name = szFile;\n\t\t}\n\t\tif (tka->trackID==(u32) -1) {\n\t\t\tfor (j=0; j<gf_isom_get_track_count(file); j++) {\n\t\t\t\tmdump.trackID = gf_isom_get_track_id(file, j+1);\n\t\t\t\tsprintf(szFile, \"%s_track%d\", outfile, mdump.trackID);\n\t\t\t\tmdump.out_name = szFile;\n\t\t\t\tmdump.print_stats_graph = fs_dump_flags;\n\t\t\t\te = gf_media_export(&mdump);\n\t\t\t\tif (e) return e;\n\t\t\t}\n\t\t} else {\n\t\t\tmdump.print_stats_graph = fs_dump_flags;\n\t\t\te = gf_media_export(&mdump);\n\t\t\tif (e) return e;\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":441,"total_token_length":677,"max_tokens_setting":1024}
+{"idx":343265,"func":"static void clearargs(int argc, char **argv)\n{\n#ifndef NO_PROCNAME_CHANGE\n# if defined(__linux__) && !defined(HAVE_SETPROCTITLE)\n    int i;\n    char *first = NULL;\n    char *next = NULL;\n\n    for (i = 0; i < argc; i++) {\n        if (first == NULL) {\n            first = argv[i];\n        }\n        if (next == NULL || argv[i] == next + 1) {\n            next = argv[i] + strlen(argv[i]);\n        }\n    }\n    for (i = 0; environ[i] != NULL; i++) {\n        if (first == NULL) {\n            first = argv[i];\n        }\n        if (next == NULL) {\n            next = argv[i] + strlen(argv[i]);\n        }\n    }\n    if (first == NULL || next == NULL) {\n        return;\n    }\n    argv_lth = next - first;\n    argv0 = argv;\n    if (environ != NULL) {\n        char **new_environ;\n        unsigned int env_nb = 0U;\n\n        while (environ[env_nb] != NULL) {\n            env_nb++;\n        }\n        if ((new_environ = malloc((1U + env_nb) * sizeof (char *))) == NULL) {\n            abort();\n        }\n        new_environ[env_nb] = NULL;\n        while (env_nb > 0U) {\n            env_nb--;\n            new_environ[env_nb] = strdup(environ[env_nb]);\n        }\n        environ = new_environ;\n    }\n# else\n    (void) argc;\n    (void) argv;\n# endif\n#endif\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":247565,"func":"TEST_P(SslSocketTest, RsaPrivateKeyProviderAsyncSignFailure) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key_provider:\n        provider_name: test\n        typed_config:\n          \"@type\": type.googleapis.com\/google.protobuf.Struct\n          value:\n            private_key_file: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n            expected_operation: sign\n            sync_mode: false\n            crypto_error: true\n            mode: rsa\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      crl:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.crl\"\n)EOF\";\n  const std::string failing_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites:\n      - ECDHE-RSA-AES128-GCM-SHA256\n)EOF\";\n\n  TestUtilOptions failing_test_options(failing_client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(failing_test_options.setPrivateKeyMethodExpected(true).setExpectedServerStats(\n      \"ssl.connection_error\"));\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":204036,"func":"int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,\n\t\t\t     struct hw_atl_utils_fw_rpc **rpc)\n{\n\tstruct aq_hw_atl_utils_fw_rpc_tid_s sw;\n\tstruct aq_hw_atl_utils_fw_rpc_tid_s fw;\n\tint err = 0;\n\n\tdo {\n\t\tsw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR);\n\n\t\tself->rpc_tid = sw.tid;\n\n\t\terr = readx_poll_timeout_atomic(hw_atl_utils_rpc_state_get,\n\t\t\t\t\t\tself, fw.val,\n\t\t\t\t\t\tsw.tid == fw.tid,\n\t\t\t\t\t\t1000U, 100000U);\n\t\tif (err < 0)\n\t\t\tgoto err_exit;\n\n\t\terr = aq_hw_err_from_flags(self);\n\t\tif (err < 0)\n\t\t\tgoto err_exit;\n\n\t\tif (fw.len == 0xFFFFU) {\n\t\t\terr = hw_atl_utils_fw_rpc_call(self, sw.len);\n\t\t\tif (err < 0)\n\t\t\t\tgoto err_exit;\n\t\t}\n\t} while (sw.tid != fw.tid || 0xFFFFU == fw.len);\n\n\tif (rpc) {\n\t\tif (fw.len) {\n\t\t\terr =\n\t\t\thw_atl_utils_fw_downld_dwords(self,\n\t\t\t\t\t\t      self->rpc_addr,\n\t\t\t\t\t\t      (u32 *)(void *)\n\t\t\t\t\t\t      &self->rpc,\n\t\t\t\t\t\t      (fw.len + sizeof(u32) -\n\t\t\t\t\t\t       sizeof(u8)) \/\n\t\t\t\t\t\t      sizeof(u32));\n\t\t\tif (err < 0)\n\t\t\t\tgoto err_exit;\n\t\t}\n\n\t\t*rpc = &self->rpc;\n\t}\n\nerr_exit:\n\treturn err;\n}","target":1,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":477374,"func":"R_API char *r_bin_java_print_utf8_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *utf8_str = r_hex_bin2strdup (obj->info.cp_utf8.bytes, obj->info.cp_utf8.length);\n\tchar *value = malloc (size + strlen (utf8_str));\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d.%s\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tobj->info.cp_utf8.length,\n\t\t\tutf8_str);\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size + strlen (utf8_str));\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d.%s\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\t\t\tobj->info.cp_utf8.length,\n\t\t\t\t\tutf8_str);\n\t\t\t}\n\t\t}\n\t}\n\tfree (utf8_str);\n\treturn value;\n}","target":0,"code_token_length":339,"total_token_length":575,"max_tokens_setting":1024}
+{"idx":352995,"func":"csnValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tstruct berval\tbv;\n\tchar\t\t*ptr;\n\tint\t\trc;\n\n\tassert( in != NULL );\n\n\tif ( BER_BVISNULL( in ) || BER_BVISEMPTY( in ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv = *in;\n\n\tptr = ber_bvchr( &bv, '#' );\n\tif ( ptr == NULL || ptr == &bv.bv_val[bv.bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_len = ptr - bv.bv_val;\n\tif ( bv.bv_len != STRLENOF( \"YYYYmmddHHMMSS.uuuuuuZ\" ) &&\n\t\tbv.bv_len != STRLENOF( \"YYYYmmddHHMMSSZ\" ) )\n\t{\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\trc = generalizedTimeValidate( NULL, &bv );\n\tif ( rc != LDAP_SUCCESS ) {\n\t\treturn rc;\n\t}\n\n\tbv.bv_val = ptr + 1;\n\tbv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val );\n\n\tptr = ber_bvchr( &bv, '#' );\n\tif ( ptr == NULL || ptr == &in->bv_val[in->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_len = ptr - bv.bv_val;\n\tif ( bv.bv_len != 6 ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\trc = hexValidate( NULL, &bv );\n\tif ( rc != LDAP_SUCCESS ) {\n\t\treturn rc;\n\t}\n\n\tbv.bv_val = ptr + 1;\n\tbv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val );\n\n\tptr = ber_bvchr( &bv, '#' );\n\tif ( ptr == NULL || ptr == &in->bv_val[in->bv_len] ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tbv.bv_len = ptr - bv.bv_val;\n\tif ( bv.bv_len == 2 ) {\n\t\t\/* tolerate old 2-digit replica-id *\/\n\t\trc = hexValidate( NULL, &bv );\n\n\t} else {\n\t\trc = sidValidate( NULL, &bv );\n\t}\n\tif ( rc != LDAP_SUCCESS ) {\n\t\treturn rc;\n\t}\n\n\tbv.bv_val = ptr + 1;\n\tbv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val );\n\n\tif ( bv.bv_len != 6 ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\treturn hexValidate( NULL, &bv );\n}","target":0,"code_token_length":560,"total_token_length":796,"max_tokens_setting":1024}
+{"idx":336147,"func":"static void ip6gre_netlink_parms(struct nlattr *data[],\n\t\t\t\tstruct __ip6_tnl_parm *parms)\n{\n\tmemset(parms, 0, sizeof(*parms));\n\n\tif (!data)\n\t\treturn;\n\n\tif (data[IFLA_GRE_LINK])\n\t\tparms->link = nla_get_u32(data[IFLA_GRE_LINK]);\n\n\tif (data[IFLA_GRE_IFLAGS])\n\t\tparms->i_flags = gre_flags_to_tnl_flags(\n\t\t\t\tnla_get_be16(data[IFLA_GRE_IFLAGS]));\n\n\tif (data[IFLA_GRE_OFLAGS])\n\t\tparms->o_flags = gre_flags_to_tnl_flags(\n\t\t\t\tnla_get_be16(data[IFLA_GRE_OFLAGS]));\n\n\tif (data[IFLA_GRE_IKEY])\n\t\tparms->i_key = nla_get_be32(data[IFLA_GRE_IKEY]);\n\n\tif (data[IFLA_GRE_OKEY])\n\t\tparms->o_key = nla_get_be32(data[IFLA_GRE_OKEY]);\n\n\tif (data[IFLA_GRE_LOCAL])\n\t\tparms->laddr = nla_get_in6_addr(data[IFLA_GRE_LOCAL]);\n\n\tif (data[IFLA_GRE_REMOTE])\n\t\tparms->raddr = nla_get_in6_addr(data[IFLA_GRE_REMOTE]);\n\n\tif (data[IFLA_GRE_TTL])\n\t\tparms->hop_limit = nla_get_u8(data[IFLA_GRE_TTL]);\n\n\tif (data[IFLA_GRE_ENCAP_LIMIT])\n\t\tparms->encap_limit = nla_get_u8(data[IFLA_GRE_ENCAP_LIMIT]);\n\n\tif (data[IFLA_GRE_FLOWINFO])\n\t\tparms->flowinfo = nla_get_be32(data[IFLA_GRE_FLOWINFO]);\n\n\tif (data[IFLA_GRE_FLAGS])\n\t\tparms->flags = nla_get_u32(data[IFLA_GRE_FLAGS]);\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":267833,"func":"vm_execute (vm_frame_ctx_t *frame_ctx_p) \/**< frame context *\/\n{\n  while (true)\n  {\n    ecma_value_t completion_value = vm_loop (frame_ctx_p);\n\n    switch (frame_ctx_p->call_operation)\n    {\n      case VM_EXEC_CALL:\n      {\n        opfunc_call (frame_ctx_p);\n        break;\n      }\n#if JERRY_ESNEXT\n      case VM_EXEC_SUPER_CALL:\n      {\n        vm_super_call (frame_ctx_p);\n        break;\n      }\n      case VM_EXEC_SPREAD_OP:\n      {\n        vm_spread_operation (frame_ctx_p);\n        break;\n      }\n      case VM_EXEC_RETURN:\n      {\n        return completion_value;\n      }\n#endif \/* JERRY_ESNEXT *\/\n      case VM_EXEC_CONSTRUCT:\n      {\n        opfunc_construct (frame_ctx_p);\n        break;\n      }\n      default:\n      {\n        JERRY_ASSERT (frame_ctx_p->call_operation == VM_NO_EXEC_OP);\n\n        const ecma_compiled_code_t *bytecode_header_p = frame_ctx_p->shared_p->bytecode_header_p;\n        uint32_t register_end;\n\n        if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)\n        {\n          register_end = ((cbc_uint16_arguments_t *) bytecode_header_p)->register_end;\n        }\n        else\n        {\n          register_end = ((cbc_uint8_arguments_t *) bytecode_header_p)->register_end;\n        }\n\n        \/* Free arguments and registers *\/\n        ecma_value_t *registers_p = VM_GET_REGISTERS (frame_ctx_p);\n        for (uint32_t i = 0; i < register_end; i++)\n        {\n          ecma_fast_free_value (registers_p[i]);\n        }\n\n#if JERRY_DEBUGGER\n        if (JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p))\n        {\n          \/* The engine will stop when the next breakpoint is reached. *\/\n          JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_STOP);\n          JERRY_CONTEXT (debugger_stop_context) = NULL;\n        }\n#endif \/* JERRY_DEBUGGER *\/\n\n        JERRY_CONTEXT (vm_top_context_p) = frame_ctx_p->prev_context_p;\n        return completion_value;\n      }\n    }\n  }\n} \/* vm_execute *\/","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":224571,"func":"Status Conv2DBackpropInputShape(shape_inference::InferenceContext* c) {\n  string data_format_str;\n  if (!c->GetAttr(\"data_format\", &data_format_str).ok()) {\n    data_format_str = \"NHWC\";\n  }\n  TensorFormat data_format;\n  if (!FormatFromString(data_format_str, &data_format)) {\n    return errors::InvalidArgument(\"Invalid data format string: \",\n                                   data_format_str);\n  }\n\n  \/\/ For the rest of this function, output_grad_* describes out_backprop and\n  \/\/ input_grad_* describes in_backprop.\n  ShapeHandle output_grad_shape = c->input(2);\n  TF_RETURN_IF_ERROR(c->WithRank(output_grad_shape, 4, &output_grad_shape));\n  ShapeHandle filter_shape = c->input(1);\n  TF_RETURN_IF_ERROR(c->WithRank(filter_shape, 4, &filter_shape));\n\n  DimensionHandle batch_size_dim;\n  DimensionHandle output_grad_depth_dim;\n  gtl::InlinedVector<DimensionHandle, 2> output_grad_spatial_dims(2);\n  TF_RETURN_IF_ERROR(DimensionsFromShape(\n      output_grad_shape, data_format, &batch_size_dim,\n      absl::MakeSpan(output_grad_spatial_dims), &output_grad_depth_dim, c));\n  DimensionHandle unused;\n  TF_RETURN_IF_ERROR(\n      c->Merge(output_grad_depth_dim, c->Dim(filter_shape, 3), &unused));\n\n  ShapeHandle specified_input_grad_shape;\n  TF_RETURN_IF_ERROR(\n      c->MakeShapeFromShapeTensor(0, &specified_input_grad_shape));\n  if (c->Rank(specified_input_grad_shape) == InferenceContext::kUnknownRank) {\n    TF_RETURN_IF_ERROR(c->WithRank(specified_input_grad_shape, 4,\n                                   &specified_input_grad_shape));\n  }\n\n  \/\/ input_grad_depth_dim doesn't equal c->Dim(filter_shape,2) when the number\n  \/\/ of groups is larger than 1. If input_sizes is a 4D shape, we collect\n  \/\/ input_grad_depth_dim from input_sizes; otherwise we compute it as\n  \/\/ c->Dim(filter_shape,2).\n  DimensionHandle input_grad_depth_dim;\n  gtl::InlinedVector<DimensionHandle, 2> specified_input_grad_spatial_dims(2);\n  int specified_input_grad_rank = c->Rank(specified_input_grad_shape);\n  if (specified_input_grad_rank == 4) {\n    DimensionHandle specified_batch_size_dim;\n    TF_RETURN_IF_ERROR(DimensionsFromShape(\n        specified_input_grad_shape, data_format, &specified_batch_size_dim,\n        absl::MakeSpan(specified_input_grad_spatial_dims),\n        &input_grad_depth_dim, c));\n    TF_RETURN_IF_ERROR(\n        c->Merge(specified_batch_size_dim, batch_size_dim, &unused));\n  } else if (specified_input_grad_rank == 2) {\n    specified_input_grad_spatial_dims[0] =\n        c->Dim(specified_input_grad_shape, 0);\n    specified_input_grad_spatial_dims[1] =\n        c->Dim(specified_input_grad_shape, 1);\n    input_grad_depth_dim = c->Dim(filter_shape, 2);\n  } else {\n    return errors::InvalidArgument(\n        \"Conv2DBackpropInput requires input_sizes to contain 4 values or 2 \"\n        \"values, but got: \",\n        specified_input_grad_rank);\n  }\n\n  ShapeHandle input_grad_shape;\n  TF_RETURN_IF_ERROR(ShapeFromDimensions(\n      batch_size_dim, specified_input_grad_spatial_dims, input_grad_depth_dim,\n      data_format, \/*vect_size=*\/absl::nullopt, c, &input_grad_shape));\n  c->set_output(0, input_grad_shape);\n  return Status::OK();\n}","target":0,"code_token_length":787,"total_token_length":1023,"max_tokens_setting":1024}
+{"idx":491910,"func":"static ssize_t fuse_perform_write(struct file *file,\n\t\t\t\t  struct address_space *mapping,\n\t\t\t\t  struct iov_iter *ii, loff_t pos)\n{\n\tstruct inode *inode = mapping->host;\n\tstruct fuse_conn *fc = get_fuse_conn(inode);\n\tint err = 0;\n\tssize_t res = 0;\n\n\tif (is_bad_inode(inode))\n\t\treturn -EIO;\n\n\tdo {\n\t\tstruct fuse_req *req;\n\t\tssize_t count;\n\n\t\treq = fuse_get_req(fc);\n\t\tif (IS_ERR(req)) {\n\t\t\terr = PTR_ERR(req);\n\t\t\tbreak;\n\t\t}\n\n\t\tcount = fuse_fill_write_pages(req, mapping, ii, pos);\n\t\tif (count <= 0) {\n\t\t\terr = count;\n\t\t} else {\n\t\t\tsize_t num_written;\n\n\t\t\tnum_written = fuse_send_write_pages(req, file, inode,\n\t\t\t\t\t\t\t    pos, count);\n\t\t\terr = req->out.h.error;\n\t\t\tif (!err) {\n\t\t\t\tres += num_written;\n\t\t\t\tpos += num_written;\n\n\t\t\t\t\/* break out of the loop on short write *\/\n\t\t\t\tif (num_written != count)\n\t\t\t\t\terr = -EIO;\n\t\t\t}\n\t\t}\n\t\tfuse_put_request(fc, req);\n\t} while (!err && iov_iter_count(ii));\n\n\tif (res > 0)\n\t\tfuse_write_update_size(inode, pos);\n\n\tfuse_invalidate_attr(inode);\n\n\treturn res > 0 ? res : err;\n}","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":336544,"func":"SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port,\n                                            const char *ca_cert_file, const char *certs_file,\n                                            const char *private_key_file, const char *key_passwd,\n                                            const char *dh_key_file, const char *ciphersuite)\n{\n    if (port == 0 || ca_cert_file == NULL || certs_file == NULL ||\n        private_key_file == NULL) {\n        return -1;\n    }\n    if (port < 0 || port > 0xffff) {\n        return -1;\n    }\n    memset(&s->config->ssl_parameters, 0, sizeof(s->config->ssl_parameters));\n\n    s->config->spice_secure_port = port;\n    g_strlcpy(s->config->ssl_parameters.ca_certificate_file, ca_cert_file,\n              sizeof(s->config->ssl_parameters.ca_certificate_file));\n    g_strlcpy(s->config->ssl_parameters.certs_file, certs_file,\n              sizeof(s->config->ssl_parameters.certs_file));\n    g_strlcpy(s->config->ssl_parameters.private_key_file, private_key_file,\n              sizeof(s->config->ssl_parameters.private_key_file));\n\n    if (key_passwd) {\n        g_strlcpy(s->config->ssl_parameters.keyfile_password, key_passwd,\n                  sizeof(s->config->ssl_parameters.keyfile_password));\n    }\n    if (ciphersuite) {\n        g_strlcpy(s->config->ssl_parameters.ciphersuite, ciphersuite,\n                  sizeof(s->config->ssl_parameters.ciphersuite));\n    }\n    if (dh_key_file) {\n        g_strlcpy(s->config->ssl_parameters.dh_key_file, dh_key_file,\n                  sizeof(s->config->ssl_parameters.dh_key_file));\n    }\n    return 0;\n}","target":0,"code_token_length":376,"total_token_length":612,"max_tokens_setting":1024}
+{"idx":207753,"func":"static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t bytes,\n\t\t\t struct iov_iter *i)\n{\n\tstruct pipe_inode_info *pipe = i->pipe;\n\tstruct pipe_buffer *buf;\n\tunsigned int p_tail = pipe->tail;\n\tunsigned int p_mask = pipe->ring_size - 1;\n\tunsigned int i_head = i->head;\n\tsize_t off;\n\n\tif (unlikely(bytes > i->count))\n\t\tbytes = i->count;\n\n\tif (unlikely(!bytes))\n\t\treturn 0;\n\n\tif (!sanity(i))\n\t\treturn 0;\n\n\toff = i->iov_offset;\n\tbuf = &pipe->bufs[i_head & p_mask];\n\tif (off) {\n\t\tif (offset == off && buf->page == page) {\n\t\t\t\/* merge with the last one *\/\n\t\t\tbuf->len += bytes;\n\t\t\ti->iov_offset += bytes;\n\t\t\tgoto out;\n\t\t}\n\t\ti_head++;\n\t\tbuf = &pipe->bufs[i_head & p_mask];\n\t}\n\tif (pipe_full(i_head, p_tail, pipe->max_usage))\n\t\treturn 0;\n\n\tbuf->ops = &page_cache_pipe_buf_ops;\n\tget_page(page);\n\tbuf->page = page;\n\tbuf->offset = offset;\n\tbuf->len = bytes;\n\n\tpipe->head = i_head + 1;\n\ti->iov_offset = offset + bytes;\n\ti->head = i_head;\nout:\n\ti->count -= bytes;\n\treturn bytes;\n}","target":1,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":338096,"func":"bool WasmBinaryBuilder::maybeVisitSIMDReplace(Expression*& out, uint32_t code) {\n  SIMDReplace* curr;\n  switch (code) {\n    case BinaryConsts::I8x16ReplaceLane:\n      curr = allocator.alloc<SIMDReplace>();\n      curr->op = ReplaceLaneVecI8x16;\n      curr->index = getLaneIndex(16);\n      break;\n    case BinaryConsts::I16x8ReplaceLane:\n      curr = allocator.alloc<SIMDReplace>();\n      curr->op = ReplaceLaneVecI16x8;\n      curr->index = getLaneIndex(8);\n      break;\n    case BinaryConsts::I32x4ReplaceLane:\n      curr = allocator.alloc<SIMDReplace>();\n      curr->op = ReplaceLaneVecI32x4;\n      curr->index = getLaneIndex(4);\n      break;\n    case BinaryConsts::I64x2ReplaceLane:\n      curr = allocator.alloc<SIMDReplace>();\n      curr->op = ReplaceLaneVecI64x2;\n      curr->index = getLaneIndex(2);\n      break;\n    case BinaryConsts::F32x4ReplaceLane:\n      curr = allocator.alloc<SIMDReplace>();\n      curr->op = ReplaceLaneVecF32x4;\n      curr->index = getLaneIndex(4);\n      break;\n    case BinaryConsts::F64x2ReplaceLane:\n      curr = allocator.alloc<SIMDReplace>();\n      curr->op = ReplaceLaneVecF64x2;\n      curr->index = getLaneIndex(2);\n      break;\n    default:\n      return false;\n  }\n  curr->value = popNonVoidExpression();\n  curr->vec = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":415178,"func":"cmd_writekey (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  char *keyid;\n  int force = has_option (line, \"--force\");\n  unsigned char *keydata;\n  size_t keydatalen;\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  line = skip_options (line);\n\n  if (!*line)\n    return set_error (GPG_ERR_ASS_PARAMETER, \"no keyid given\");\n  keyid = line;\n  while (*line && !spacep (line))\n    line++;\n  *line = 0;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  if (!ctrl->app_ctx)\n    return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);\n\n  keyid = xtrystrdup (keyid);\n  if (!keyid)\n    return out_of_core ();\n\n  \/* Now get the actual keydata. *\/\n  assuan_begin_confidential (ctx);\n  rc = assuan_inquire (ctx, \"KEYDATA\", &keydata, &keydatalen, MAXLEN_KEYDATA);\n  assuan_end_confidential (ctx);\n  if (rc)\n    {\n      xfree (keyid);\n      return rc;\n    }\n\n  \/* Write the key to the card. *\/\n  rc = app_writekey (ctrl->app_ctx, ctrl, keyid, force? 1:0,\n                     pin_cb, ctx, keydata, keydatalen);\n  xfree (keyid);\n  xfree (keydata);\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":250688,"func":"DROGON_TEST(HttpFile)\n{\n    SUBSECTION(Save)\n    {\n        HttpFileImpl file;\n        file.setFileName(\"test_file_name\");\n        file.setFile(\"test\", 4);\n        auto out = file.save(\".\/test_uploads_dir\");\n\n        CHECK(out == 0);\n        CHECK(filesystem::exists(\".\/test_uploads_dir\/test_file_name\"));\n\n        filesystem::remove_all(\".\/test_uploads_dir\");\n    }\n\n    SUBSECTION(SavePathRelativeTraversal)\n    {\n        auto uploadPath = filesystem::current_path() \/ \"test_uploads_dir\";\n\n        HttpFileImpl file;\n        file.setFileName(\"..\/test_malicious_file_name\");\n        file.setFile(\"test\", 4);\n        auto out = file.save(uploadPath.string());\n\n        CHECK(out == -1);\n        CHECK(!filesystem::exists(uploadPath \/ \"..\/test_malicious_file_name\"));\n\n        filesystem::remove_all(uploadPath);\n        filesystem::remove(uploadPath \/ \"..\/test_malicious_file_name\");\n    }\n\n    SUBSECTION(SavePathAbsoluteTraversal)\n    {\n        HttpFileImpl file;\n        file.setFileName(\"\/tmp\/test_malicious_file_name\");\n        file.setFile(\"test\", 4);\n        auto out = file.save(\".\/test_uploads_dir\");\n\n        CHECK(out == -1);\n        CHECK(!filesystem::exists(\"\/tmp\/test_malicious_file_name\"));\n\n        filesystem::remove_all(\"test_uploads_dir\");\n        filesystem::remove_all(\"\/tmp\/test_malicious_file_name\");\n    }\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":462405,"func":"static rsRetVal addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal)\n{\n\tinstanceConf_t *inst;\n\tDEFiRet;\n\n\tCHKiRet(createInstance(&inst));\n\tif(pNewVal == NULL || *pNewVal == '\\0') {\n\t\terrmsg.LogError(0, NO_ERRCODE, \"imptcp: port number must be specified, listener ignored\");\n\t}\n\tif((pNewVal == NULL) || (pNewVal == '\\0')) {\n\t\tinst->pszBindPort = NULL;\n\t} else {\n\t\tCHKmalloc(inst->pszBindPort = ustrdup(pNewVal));\n\t}\n\tif((cs.lstnIP == NULL) || (cs.lstnIP[0] == '\\0')) {\n\t\tinst->pszBindAddr = NULL;\n\t} else {\n\t\tCHKmalloc(inst->pszBindAddr = ustrdup(cs.lstnIP));\n\t}\n\tif((cs.pszBindRuleset == NULL) || (cs.pszBindRuleset[0] == '\\0')) {\n\t\tinst->pszBindRuleset = NULL;\n\t} else {\n\t\tCHKmalloc(inst->pszBindRuleset = ustrdup(cs.pszBindRuleset));\n\t}\n\tif((cs.pszInputName == NULL) || (cs.pszInputName[0] == '\\0')) {\n\t\tinst->pszInputName = NULL;\n\t} else {\n\t\tCHKmalloc(inst->pszInputName = ustrdup(cs.pszInputName));\n\t}\n\tinst->pBindRuleset = NULL;\n\tinst->bSuppOctetFram = cs.bSuppOctetFram;\n\tinst->bKeepAlive = cs.bKeepAlive;\n\tinst->iKeepAliveIntvl = cs.iKeepAliveTime;\n\tinst->iKeepAliveProbes = cs.iKeepAliveProbes;\n\tinst->iKeepAliveTime = cs.iKeepAliveTime;\n\tinst->bEmitMsgOnClose = cs.bEmitMsgOnClose;\n\tinst->iAddtlFrameDelim = cs.iAddtlFrameDelim;\n\nfinalize_it:\n\tfree(pNewVal);\n\tRETiRet;\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":484058,"func":"START_TEST(SecureChannel_sendSymmetricMessage_invalidParameters) {\n    \/\/ initialize dummy message\n    UA_ReadRequest dummyMessage;\n    UA_ReadRequest_init(&dummyMessage);\n    UA_DataType dummyType = UA_TYPES[UA_TYPES_READREQUEST];\n\n    UA_StatusCode retval = UA_SecureChannel_sendSymmetricMessage(NULL, 42, UA_MESSAGETYPE_MSG,\n                                                                 &dummyMessage, &dummyType);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n\n    retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42,\n                                                   UA_MESSAGETYPE_HEL, &dummyMessage, &dummyType);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n\n    retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42,\n                                                   UA_MESSAGETYPE_ACK, &dummyMessage, &dummyType);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n\n    retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42,\n                                                   UA_MESSAGETYPE_ERR, &dummyMessage, &dummyType);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n\n    retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42,\n                                                   UA_MESSAGETYPE_OPN, &dummyMessage, &dummyType);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n\n    retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42,\n                                                   UA_MESSAGETYPE_MSG, NULL, &dummyType);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n\n    retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42,\n                                                   UA_MESSAGETYPE_MSG, &dummyMessage, NULL);\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure\");\n} END_TEST","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":195385,"func":"flatpak_dir_ensure_bundle_remote (FlatpakDir         *self,\n                                  GFile              *file,\n                                  GBytes             *extra_gpg_data,\n                                  FlatpakDecomposed **out_ref,\n                                  char              **out_checksum,\n                                  char              **out_metadata,\n                                  gboolean           *out_created_remote,\n                                  GCancellable       *cancellable,\n                                  GError            **error)\n{\n  g_autoptr(FlatpakDecomposed) ref = NULL;\n  gboolean created_remote = FALSE;\n  g_autoptr(GBytes) deploy_data = NULL;\n  g_autoptr(GVariant) metadata = NULL;\n  g_autofree char *origin = NULL;\n  g_autofree char *fp_metadata = NULL;\n  g_autofree char *basename = NULL;\n  g_autoptr(GBytes) included_gpg_data = NULL;\n  GBytes *gpg_data = NULL;\n  g_autofree char *to_checksum = NULL;\n  g_autofree char *remote = NULL;\n  g_autofree char *collection_id = NULL;\n\n  if (!flatpak_dir_ensure_repo (self, cancellable, error))\n    return NULL;\n\n  metadata = flatpak_bundle_load (file, &to_checksum,\n                                  &ref,\n                                  &origin,\n                                  NULL, &fp_metadata, NULL,\n                                  &included_gpg_data,\n                                  &collection_id,\n                                  error);\n  if (metadata == NULL)\n    return NULL;\n\n  gpg_data = extra_gpg_data ? extra_gpg_data : included_gpg_data;\n\n  deploy_data = flatpak_dir_get_deploy_data (self, ref, FLATPAK_DEPLOY_VERSION_ANY, cancellable, NULL);\n  if (deploy_data != NULL)\n    {\n      remote = g_strdup (flatpak_deploy_data_get_origin (deploy_data));\n\n      \/* We need to import any gpg keys because otherwise the pull will fail *\/\n      if (gpg_data != NULL)\n        {\n          g_autoptr(GKeyFile) new_config = NULL;\n\n          new_config = ostree_repo_copy_config (flatpak_dir_get_repo (self));\n\n          if (!flatpak_dir_modify_remote (self, remote, new_config,\n                                          gpg_data, cancellable, error))\n            return NULL;\n        }\n    }\n  else\n    {\n      g_autofree char *id = flatpak_decomposed_dup_id (ref);\n      \/* Add a remote for later updates *\/\n      basename = g_file_get_basename (file);\n      remote = flatpak_dir_create_origin_remote (self,\n                                                 origin,\n                                                 id,\n                                                 basename,\n                                                 flatpak_decomposed_get_ref (ref),\n                                                 gpg_data,\n                                                 collection_id,\n                                                 &created_remote,\n                                                 cancellable,\n                                                 error);\n      if (remote == NULL)\n        return NULL;\n    }\n\n  if (out_created_remote)\n    *out_created_remote = created_remote;\n\n  if (out_ref)\n    *out_ref = g_steal_pointer (&ref);\n\n  if (out_checksum)\n    *out_checksum = g_steal_pointer (&to_checksum);\n\n  if (out_metadata)\n    *out_metadata = g_steal_pointer (&fp_metadata);\n\n\n  return g_steal_pointer (&remote);\n}","target":1,"code_token_length":658,"total_token_length":894,"max_tokens_setting":1024}
+{"idx":338058,"func":"bool WasmBinaryBuilder::maybeVisitSIMDTernary(Expression*& out, uint32_t code) {\n  SIMDTernary* curr;\n  switch (code) {\n    case BinaryConsts::V128Bitselect:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = Bitselect;\n      break;\n    case BinaryConsts::I8x16Laneselect:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = LaneselectI8x16;\n      break;\n    case BinaryConsts::I16x8Laneselect:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = LaneselectI16x8;\n      break;\n    case BinaryConsts::I32x4Laneselect:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = LaneselectI32x4;\n      break;\n    case BinaryConsts::I64x2Laneselect:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = LaneselectI64x2;\n      break;\n    case BinaryConsts::F32x4RelaxedFma:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = RelaxedFmaVecF32x4;\n      break;\n    case BinaryConsts::F32x4RelaxedFms:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = RelaxedFmsVecF32x4;\n      break;\n    case BinaryConsts::F64x2RelaxedFma:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = RelaxedFmaVecF64x2;\n      break;\n    case BinaryConsts::F64x2RelaxedFms:\n      curr = allocator.alloc<SIMDTernary>();\n      curr->op = RelaxedFmsVecF64x2;\n      break;\n    default:\n      return false;\n  }\n  curr->c = popNonVoidExpression();\n  curr->b = popNonVoidExpression();\n  curr->a = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":478,"total_token_length":714,"max_tokens_setting":1024}
+{"idx":477354,"func":"R_API RBinJavaAttrInfo *r_bin_java_stack_map_table_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut32 i = 0;\n\tut64 offset = 0;\n\tRBinJavaStackMapFrame *stack_frame = NULL, *new_stack_frame = NULL;\n\tif (sz < 10) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tIFDBG eprintf(\"r_bin_java_stack_map_table_attr_new: New stack map allocated.\\n\");\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tattr->info.stack_map_table_attr.stack_map_frame_entries = r_list_newf (r_bin_java_stack_frame_free);\n\t\/\/ IFDBG r_bin_java_print_source_code_file_attr_summary(attr);\n\t\/\/ Current spec does not call for variable sizes.\n\tattr->info.stack_map_table_attr.number_of_entries = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tIFDBG eprintf(\"r_bin_java_stack_map_table_attr_new: Processing stack map, summary is:\\n\");\n\tIFDBG r_bin_java_print_stack_map_table_attr_summary(attr);\n\tfor (i = 0; i < attr->info.stack_map_table_attr.number_of_entries; i++) {\n\t\t\/\/ read next stack frame\n\t\tIFDBG eprintf(\"Reading StackMap Entry #%d @ 0x%08\"PFMT64x \"\\n\", i, buf_offset + offset);\n\t\tif (stack_frame == NULL && R_BIN_JAVA_GLOBAL_BIN && R_BIN_JAVA_GLOBAL_BIN->current_code_attr) {\n\t\t\tIFDBG eprintf(\"Setting an implicit frame at #%d @ 0x%08\"PFMT64x \"\\n\", i, buf_offset + offset);\n\t\t\tstack_frame = R_BIN_JAVA_GLOBAL_BIN->current_code_attr->info.code_attr.implicit_frame;\n\t\t}\n\t\tIFDBG eprintf(\"Reading StackMap Entry #%d @ 0x%08\"PFMT64x \", current stack_frame: %p\\n\", i, buf_offset + offset, stack_frame);\n\t\tif (offset >= sz) {\n\t\t\tr_bin_java_stack_map_table_attr_free (attr);\n\t\t\treturn NULL;\n\t\t}\n\t\tnew_stack_frame = r_bin_java_stack_map_frame_new (buffer + offset, sz - offset, stack_frame, buf_offset + offset);\n\t\tif (new_stack_frame) {\n\t\t\toffset += new_stack_frame->size;\n\t\t\t\/\/ append stack frame to the list\n\t\t\tr_list_append (attr->info.stack_map_table_attr.stack_map_frame_entries, (void *) new_stack_frame);\n\t\t\tstack_frame = new_stack_frame;\n\t\t} else {\n\t\t\teprintf (\"r_bin_java_stack_map_table_attr_new: Unable to parse the stack frame for the stack map table.\\n\");\n\t\t\tr_bin_java_stack_map_table_attr_free (attr);\n\t\t\tattr = NULL;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (attr) {\n\t\tattr->size = offset;\n\t}\n\treturn attr;\n}","target":0,"code_token_length":660,"total_token_length":896,"max_tokens_setting":1024}
+{"idx":247691,"func":"TEST_P(SslSocketTest, RevokedLeafCertificateOnlyLeafCRLValidation) {\n  \/\/ The test checks that revoked certificate will makes the validation fails even if we set\n  \/\/ only_verify_leaf_cert_crl to true.\n  \/\/\n  \/\/ Trust chain contains:\n  \/\/  - Root authority certificate (i.e., ca_cert.pem)\n  \/\/  - Intermediate authority certificate (i.e., intermediate_ca_cert.pem)\n  \/\/  - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl)\n  \/\/\n  \/\/ Trust chain omits (But this test will succeed):\n  \/\/  - Root authority certificate revocation list (i.e., ca_cert.crl)\n  const std::string incomplete_server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/intermediate_ca_cert_chain_with_crl.pem\"\n      only_verify_leaf_cert_crl: true\n)EOF\";\n\n  \/\/ This should fail, since the certificate has been revoked.\n  const std::string revoked_client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns3_key.pem\"\n)EOF\";\n\n  TestUtilOptions complete_revoked_test_options(revoked_client_ctx_yaml, incomplete_server_ctx_yaml,\n                                                false, GetParam());\n  testUtil(complete_revoked_test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED));\n}","target":0,"code_token_length":435,"total_token_length":671,"max_tokens_setting":1024}
+{"idx":427209,"func":"static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {\n  if (fs == NULL)  \/* no more levels? *\/\n    init_exp(var, VVOID, 0);  \/* default is global *\/\n  else {\n    int v = searchvar(fs, n, var);  \/* look up locals at current level *\/\n    if (v >= 0) {  \/* found? *\/\n      if (v == VLOCAL && !base)\n        markupval(fs, var->u.var.vidx);  \/* local will be used as an upval *\/\n    }\n    else {  \/* not found as local at current level; try upvalues *\/\n      int idx = searchupvalue(fs, n);  \/* try existing upvalues *\/\n      if (idx < 0) {  \/* not found? *\/\n        singlevaraux(fs->prev, n, var, 0);  \/* try upper levels *\/\n        if (var->k == VLOCAL || var->k == VUPVAL)  \/* local or upvalue? *\/\n          idx  = newupvalue(fs, n, var);  \/* will be a new upvalue *\/\n        else  \/* it is a global or a constant *\/\n          return;  \/* don't need to do anything at this level *\/\n      }\n      init_exp(var, VUPVAL, idx);  \/* new or old upvalue *\/\n    }\n  }\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":455342,"func":"bind_keyseq_to_unix_command (line)\n     char *line;\n{\n  Keymap kmap, cmd_xmap;\n  char *kseq, *value;\n  int i, kstart;\n\n  kmap = rl_get_keymap ();\n\n  \/* We duplicate some of the work done by rl_parse_and_bind here, but\n     this code only has to handle `\"keyseq\": [\"]command[\"]' and can\n     generate an error for anything else. *\/\n  i = isolate_sequence (line, 0, 1, &kstart);\n  if (i < 0)\n    return -1;\n\n  \/* Create the key sequence string to pass to rl_generic_bind *\/\n  kseq = substring (line, kstart, i);\n\n  for ( ; line[i] && line[i] != ':'; i++)\n    ;\n  if (line[i] != ':')\n    {\n      builtin_error (_(\"%s: missing colon separator\"), line);\n      FREE (kseq);\n      return -1;\n    }\n\n  i = isolate_sequence (line, i + 1, 0, &kstart);\n  if (i < 0)\n    {\n      FREE (kseq);\n      return -1;\n    }\n\n  \/* Create the value string containing the command to execute. *\/\n  value = substring (line, kstart, i);\n\n  \/* Save the command to execute and the key sequence in the CMD_XMAP *\/\n  cmd_xmap = get_cmd_xmap_from_keymap (kmap);\n  rl_generic_bind (ISMACR, kseq, value, cmd_xmap);\n\n  \/* and bind the key sequence in the current keymap to a function that\n     understands how to execute from CMD_XMAP *\/\n  rl_bind_keyseq_in_map (kseq, bash_execute_unix_command, kmap);\n\n  free (kseq);  \n  return 0;\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":476102,"func":"void usb_composite_overwrite_options(struct usb_composite_dev *cdev,\n\t\tstruct usb_composite_overwrite *covr)\n{\n\tstruct usb_device_descriptor\t*desc = &cdev->desc;\n\tstruct usb_gadget_strings\t*gstr = cdev->driver->strings[0];\n\tstruct usb_string\t\t*dev_str = gstr->strings;\n\n\tif (covr->idVendor)\n\t\tdesc->idVendor = cpu_to_le16(covr->idVendor);\n\n\tif (covr->idProduct)\n\t\tdesc->idProduct = cpu_to_le16(covr->idProduct);\n\n\tif (covr->bcdDevice)\n\t\tdesc->bcdDevice = cpu_to_le16(covr->bcdDevice);\n\n\tif (covr->serial_number) {\n\t\tdesc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id;\n\t\tdev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number;\n\t}\n\tif (covr->manufacturer) {\n\t\tdesc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;\n\t\tdev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer;\n\n\t} else if (!strlen(dev_str[USB_GADGET_MANUFACTURER_IDX].s)) {\n\t\tdesc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id;\n\t\tcdev->def_manufacturer = composite_default_mfr(cdev->gadget);\n\t\tdev_str[USB_GADGET_MANUFACTURER_IDX].s = cdev->def_manufacturer;\n\t}\n\n\tif (covr->product) {\n\t\tdesc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id;\n\t\tdev_str[USB_GADGET_PRODUCT_IDX].s = covr->product;\n\t}\n}","target":0,"code_token_length":384,"total_token_length":620,"max_tokens_setting":1024}
+{"idx":404721,"func":"int __close_range(unsigned fd, unsigned max_fd, unsigned int flags)\n{\n\tstruct task_struct *me = current;\n\tstruct files_struct *cur_fds = me->files, *fds = NULL;\n\n\tif (flags & ~(CLOSE_RANGE_UNSHARE | CLOSE_RANGE_CLOEXEC))\n\t\treturn -EINVAL;\n\n\tif (fd > max_fd)\n\t\treturn -EINVAL;\n\n\tif (flags & CLOSE_RANGE_UNSHARE) {\n\t\tint ret;\n\t\tunsigned int max_unshare_fds = NR_OPEN_MAX;\n\n\t\t\/*\n\t\t * If the caller requested all fds to be made cloexec we always\n\t\t * copy all of the file descriptors since they still want to\n\t\t * use them.\n\t\t *\/\n\t\tif (!(flags & CLOSE_RANGE_CLOEXEC)) {\n\t\t\t\/*\n\t\t\t * If the requested range is greater than the current\n\t\t\t * maximum, we're closing everything so only copy all\n\t\t\t * file descriptors beneath the lowest file descriptor.\n\t\t\t *\/\n\t\t\trcu_read_lock();\n\t\t\tif (max_fd >= last_fd(files_fdtable(cur_fds)))\n\t\t\t\tmax_unshare_fds = fd;\n\t\t\trcu_read_unlock();\n\t\t}\n\n\t\tret = unshare_fd(CLONE_FILES, max_unshare_fds, &fds);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t\/*\n\t\t * We used to share our file descriptor table, and have now\n\t\t * created a private one, make sure we're using it below.\n\t\t *\/\n\t\tif (fds)\n\t\t\tswap(cur_fds, fds);\n\t}\n\n\tif (flags & CLOSE_RANGE_CLOEXEC)\n\t\t__range_cloexec(cur_fds, fd, max_fd);\n\telse\n\t\t__range_close(cur_fds, fd, max_fd);\n\n\tif (fds) {\n\t\t\/*\n\t\t * We're done closing the files we were supposed to. Time to install\n\t\t * the new file descriptor table and drop the old one.\n\t\t *\/\n\t\ttask_lock(me);\n\t\tme->files = cur_fds;\n\t\ttask_unlock(me);\n\t\tput_files_struct(fds);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":310336,"func":"dirserv_get_networkstatus_v2_fingerprints(smartlist_t *result,\n                                          const char *key)\n{\n  tor_assert(result);\n\n  if (!cached_v2_networkstatus)\n    cached_v2_networkstatus = digestmap_new();\n\n  if (should_generate_v2_networkstatus())\n    generate_v2_networkstatus_opinion();\n\n  if (!strcmp(key,\"authority\")) {\n    if (authdir_mode_v2(get_options())) {\n      routerinfo_t *me = router_get_my_routerinfo();\n      if (me)\n        smartlist_add(result,\n                      tor_memdup(me->cache_info.identity_digest, DIGEST_LEN));\n    }\n  } else if (!strcmp(key, \"all\")) {\n    if (digestmap_size(cached_v2_networkstatus)) {\n      digestmap_iter_t *iter;\n      iter = digestmap_iter_init(cached_v2_networkstatus);\n      while (!digestmap_iter_done(iter)) {\n        const char *ident;\n        void *val;\n        digestmap_iter_get(iter, &ident, &val);\n        smartlist_add(result, tor_memdup(ident, DIGEST_LEN));\n        iter = digestmap_iter_next(cached_v2_networkstatus, iter);\n      }\n    } else {\n      SMARTLIST_FOREACH(router_get_trusted_dir_servers(),\n                  trusted_dir_server_t *, ds,\n                  if (ds->type & V2_AUTHORITY)\n                    smartlist_add(result, tor_memdup(ds->digest, DIGEST_LEN)));\n    }\n    smartlist_sort_digests(result);\n    if (smartlist_len(result) == 0)\n      log_info(LD_DIRSERV,\n               \"Client requested 'all' network status objects; we have none.\");\n  } else if (!strcmpstart(key, \"fp\/\")) {\n    dir_split_resource_into_fingerprints(key+3, result, NULL,\n                                         DSR_HEX|DSR_SORT_UNIQ);\n  }\n}","target":0,"code_token_length":387,"total_token_length":623,"max_tokens_setting":1024}
+{"idx":297215,"func":"char * exif_dump_data(int *dump_free, int format, int components, int length, int motorola_intel, char *value_ptr TSRMLS_DC) \/* {{{ *\/\n{\n\tchar *dump;\n\tint len;\n\n\t*dump_free = 0;\n\tif (format == TAG_FMT_STRING) {\n\t\treturn value_ptr ? value_ptr : \"<no data>\";\n\t}\n\tif (format == TAG_FMT_UNDEFINED) {\n\t\treturn \"<undefined>\\n\";\n\t}\n\tif (format == TAG_FMT_IFD) {\n\t\treturn \"\";\n\t}\n\tif (format == TAG_FMT_SINGLE || format == TAG_FMT_DOUBLE) {\n\t\treturn \"<not implemented>\";\n\t}\n\t*dump_free = 1;\n\tif (components > 1) {\n\t\tlen = spprintf(&dump, 0, \"(%d,%d) {\", components, length);\n\t} else {\n\t\tlen = spprintf(&dump, 0, \"{\");\n\t}\n\twhile(components > 0) {\n\t\tswitch(format) {\n\t\t\tcase TAG_FMT_BYTE:\n\t\t\tcase TAG_FMT_UNDEFINED:\n\t\t\tcase TAG_FMT_STRING:\n\t\t\tcase TAG_FMT_SBYTE:\n\t\t\t\tdump = erealloc(dump, len + 4 + 1);\n\t\t\t\tsnprintf(dump + len, 4 + 1, \"0x%02X\", *value_ptr);\n\t\t\t\tlen += 4;\n\t\t\t\tvalue_ptr++;\n\t\t\t\tbreak;\n\t\t\tcase TAG_FMT_USHORT:\n\t\t\tcase TAG_FMT_SSHORT:\n\t\t\t\tdump = erealloc(dump, len + 6 + 1);\n\t\t\t\tsnprintf(dump + len, 6 + 1, \"0x%04X\", php_ifd_get16s(value_ptr, motorola_intel));\n\t\t\t\tlen += 6;\n\t\t\t\tvalue_ptr += 2;\n\t\t\t\tbreak;\n\t\t\tcase TAG_FMT_ULONG:\n\t\t\tcase TAG_FMT_SLONG:\n\t\t\t\tdump = erealloc(dump, len + 6 + 1);\n\t\t\t\tsnprintf(dump + len, 6 + 1, \"0x%04X\", php_ifd_get32s(value_ptr, motorola_intel));\n\t\t\t\tlen += 6;\n\t\t\t\tvalue_ptr += 4;\n\t\t\t\tbreak;\n\t\t\tcase TAG_FMT_URATIONAL:\n\t\t\tcase TAG_FMT_SRATIONAL:\n\t\t\t\tdump = erealloc(dump, len + 13 + 1);\n\t\t\t\tsnprintf(dump + len, 13 + 1, \"0x%04X\/0x%04X\", php_ifd_get32s(value_ptr, motorola_intel), php_ifd_get32s(value_ptr+4, motorola_intel));\n\t\t\t\tlen += 13;\n\t\t\t\tvalue_ptr += 8;\n\t\t\t\tbreak;\n\t\t}\n\t\tif (components > 0) {\n\t\t\tdump = erealloc(dump, len + 2 + 1);\n\t\t\tsnprintf(dump + len, 2 + 1, \", \");\n\t\t\tlen += 2;\n\t\t\tcomponents--;\n\t\t} else{\n\t\t\tbreak;\n\t\t}\n\t}\n\tdump = erealloc(dump, len + 1 + 1);\n\tsnprintf(dump + len, 1 + 1, \"}\");\n\treturn dump;\n}","target":0,"code_token_length":661,"total_token_length":897,"max_tokens_setting":1024}
+{"idx":250694,"func":"int HttpFileImpl::save(const std::string &path) const\n{\n    assert(!path.empty());\n    if (fileName_.empty())\n        return -1;\n    filesystem::path fsUploadDir(utils::toNativePath(path));\n\n    if (!fsUploadDir.is_absolute() && (!fsUploadDir.has_parent_path() ||\n                                       (fsUploadDir.begin()->string() != \".\" &&\n                                        fsUploadDir.begin()->string() != \"..\")))\n    {\n        fsUploadDir = utils::toNativePath(\n                          HttpAppFrameworkImpl::instance().getUploadPath()) \/\n                      fsUploadDir;\n    }\n\n    fsUploadDir = filesystem::weakly_canonical(fsUploadDir);\n\n    if (!filesystem::exists(fsUploadDir))\n    {\n        LOG_TRACE << \"create path:\" << fsUploadDir;\n        drogon::error_code err;\n        filesystem::create_directories(fsUploadDir, err);\n        if (err)\n        {\n            LOG_SYSERR;\n            return -1;\n        }\n    }\n\n    filesystem::path fsSaveToPath(filesystem::weakly_canonical(\n        fsUploadDir \/ utils::toNativePath(fileName_)));\n\n    if (!std::equal(fsUploadDir.begin(),\n                    fsUploadDir.end(),\n                    fsSaveToPath.begin()))\n    {\n        LOG_ERROR\n            << \"Attempt writing outside of upload directory detected. Path: \"\n            << fileName_;\n        return -1;\n    }\n\n    return saveTo(fsSaveToPath);\n}","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":424935,"func":"void iwl_pcie_apm_config(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tu16 lctl;\n\tu16 cap;\n\n\t\/*\n\t * HW bug W\/A for instability in PCIe bus L0S->L1 transition.\n\t * Check if BIOS (or OS) enabled L1-ASPM on this device.\n\t * If so (likely), disable L0S, so device moves directly L0->L1;\n\t *    costs negligible amount of power savings.\n\t * If not (unlikely), enable L0S, so there is at least some\n\t *    power savings, even without L1.\n\t *\/\n\tpcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl);\n\tif (lctl & PCI_EXP_LNKCTL_ASPM_L1)\n\t\tiwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);\n\telse\n\t\tiwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);\n\ttrans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S);\n\n\tpcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_DEVCTL2, &cap);\n\ttrans->ltr_enabled = cap & PCI_EXP_DEVCTL2_LTR_EN;\n\tIWL_DEBUG_POWER(trans, \"L1 %sabled - LTR %sabled\\n\",\n\t\t\t(lctl & PCI_EXP_LNKCTL_ASPM_L1) ? \"En\" : \"Dis\",\n\t\t\ttrans->ltr_enabled ? \"En\" : \"Dis\");\n}","target":0,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":332384,"func":"op_colon(oparg_T *oap)\n{\n    stuffcharReadbuff(':');\n    if (oap->is_VIsual)\n\tstuffReadbuff((char_u *)\"'<,'>\");\n    else\n    {\n\t\/\/ Make the range look nice, so it can be repeated.\n\tif (oap->start.lnum == curwin->w_cursor.lnum)\n\t    stuffcharReadbuff('.');\n\telse\n\t    stuffnumReadbuff((long)oap->start.lnum);\n\tif (oap->end.lnum != oap->start.lnum)\n\t{\n\t    stuffcharReadbuff(',');\n\t    if (oap->end.lnum == curwin->w_cursor.lnum)\n\t\tstuffcharReadbuff('.');\n\t    else if (oap->end.lnum == curbuf->b_ml.ml_line_count)\n\t\tstuffcharReadbuff('$');\n\t    else if (oap->start.lnum == curwin->w_cursor.lnum)\n\t    {\n\t\tstuffReadbuff((char_u *)\".+\");\n\t\tstuffnumReadbuff((long)oap->line_count - 1);\n\t    }\n\t    else\n\t\tstuffnumReadbuff((long)oap->end.lnum);\n\t}\n    }\n    if (oap->op_type != OP_COLON)\n\tstuffReadbuff((char_u *)\"!\");\n    if (oap->op_type == OP_INDENT)\n    {\n#ifndef FEAT_CINDENT\n\tif (*get_equalprg() == NUL)\n\t    stuffReadbuff((char_u *)\"indent\");\n\telse\n#endif\n\t    stuffReadbuff(get_equalprg());\n\tstuffReadbuff((char_u *)\"\\n\");\n    }\n    else if (oap->op_type == OP_FORMAT)\n    {\n\tif (*curbuf->b_p_fp != NUL)\n\t    stuffReadbuff(curbuf->b_p_fp);\n\telse if (*p_fp != NUL)\n\t    stuffReadbuff(p_fp);\n\telse\n\t    stuffReadbuff((char_u *)\"fmt\");\n\tstuffReadbuff((char_u *)\"\\n']\");\n    }\n\n    \/\/ do_cmdline() does the rest\n}","target":0,"code_token_length":430,"total_token_length":666,"max_tokens_setting":1024}
+{"idx":314760,"func":"cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h,\n    const cdf_sat_t *sat, cdf_dir_t *dir)\n{\n\tsize_t i, j;\n\tsize_t ss = CDF_SEC_SIZE(h), ns, nd;\n\tchar *buf;\n\tcdf_secid_t sid = h->h_secid_first_directory;\n\n\tns = cdf_count_chain(sat, sid, ss);\n\tif (ns == (size_t)-1)\n\t\treturn -1;\n\n\tnd = ss \/ CDF_DIRECTORY_SIZE;\n\n\tdir->dir_len = ns * nd;\n\tdir->dir_tab = CAST(cdf_directory_t *,\n\t    calloc(dir->dir_len, sizeof(dir->dir_tab[0])));\n\tif (dir->dir_tab == NULL)\n\t\treturn -1;\n\n\tif ((buf = CAST(char *, malloc(ss))) == NULL) {\n\t\tfree(dir->dir_tab);\n\t\treturn -1;\n\t}\n\n\tfor (j = i = 0; i < ns; i++, j++) {\n\t\tif (j >= CDF_LOOP_LIMIT) {\n\t\t\tDPRINTF((\"Read dir loop limit\"));\n\t\t\terrno = EFTYPE;\n\t\t\tgoto out;\n\t\t}\n\t\tif (cdf_read_sector(info, buf, 0, ss, h, sid) != (ssize_t)ss) {\n\t\t\tDPRINTF((\"Reading directory sector %d\", sid));\n\t\t\tgoto out;\n\t\t}\n\t\tfor (j = 0; j < nd; j++) {\n\t\t\tcdf_unpack_dir(&dir->dir_tab[i * nd + j],\n\t\t\t    &buf[j * CDF_DIRECTORY_SIZE]);\n\t\t}\n\t\tsid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);\n\t}\n\tif (NEED_SWAP)\n\t\tfor (i = 0; i < dir->dir_len; i++)\n\t\t\tcdf_swap_dir(&dir->dir_tab[i]);\n\tfree(buf);\n\treturn 0;\nout:\n\tfree(dir->dir_tab);\n\tfree(buf);\n\treturn -1;\n}","target":0,"code_token_length":415,"total_token_length":651,"max_tokens_setting":1024}
+{"idx":222511,"func":"const FunctionDef* FunctionLibraryDefinition::GetAttrImpl(\n    const NodeDef& ndef) const {\n  if (ndef.op() != kGradientOp) {\n    \/\/ If 'ndef' calls a function and the function's def has the attr,\n    \/\/ returns it.\n    return Find(ndef.op());\n  }\n\n  \/\/ If ndef is SymbolicGradient[f=Foo], we use Foo's gradient or\n  \/\/ Foo's attributes.\n  const NameAttrList* forward_func_attrs;\n  if (!TryGetNodeAttr(ndef, kFuncAttr, &forward_func_attrs)) {\n    return nullptr;\n  }\n  const string& func_name = forward_func_attrs->name();\n  {\n    tf_shared_lock l(mu_);\n    const string& grad_name = FindGradientHelper(func_name);\n    \/\/ If 'func' has a user-defined gradient function, uses the grad\n    \/\/ function's attrs to see if noinline is specified. Otherwise,\n    \/\/ uses func's attrs.\n    if (!grad_name.empty()) {\n      if (const auto helper = FindHelper(grad_name)) {\n        return &(helper->fdef);\n      } else {\n        return nullptr;\n      }\n    }\n    if (const auto helper = FindHelper(func_name)) {\n      return &(helper->fdef);\n    } else {\n      return nullptr;\n    }\n  }\n}","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":289244,"func":"static int snd_pcm_oss_open(struct inode *inode, struct file *file)\n{\n\tint err;\n\tchar task_name[32];\n\tstruct snd_pcm *pcm;\n\tstruct snd_pcm_oss_file *pcm_oss_file;\n\tstruct snd_pcm_oss_setup setup[2];\n\tint nonblock;\n\twait_queue_entry_t wait;\n\n\terr = nonseekable_open(inode, file);\n\tif (err < 0)\n\t\treturn err;\n\n\tpcm = snd_lookup_oss_minor_data(iminor(inode),\n\t\t\t\t\tSNDRV_OSS_DEVICE_TYPE_PCM);\n\tif (pcm == NULL) {\n\t\terr = -ENODEV;\n\t\tgoto __error1;\n\t}\n\terr = snd_card_file_add(pcm->card, file);\n\tif (err < 0)\n\t\tgoto __error1;\n\tif (!try_module_get(pcm->card->module)) {\n\t\terr = -EFAULT;\n\t\tgoto __error2;\n\t}\n\tif (snd_task_name(current, task_name, sizeof(task_name)) < 0) {\n\t\terr = -EFAULT;\n\t\tgoto __error;\n\t}\n\tmemset(setup, 0, sizeof(setup));\n\tif (file->f_mode & FMODE_WRITE)\n\t\tsnd_pcm_oss_look_for_setup(pcm, SNDRV_PCM_STREAM_PLAYBACK,\n\t\t\t\t\t   task_name, &setup[0]);\n\tif (file->f_mode & FMODE_READ)\n\t\tsnd_pcm_oss_look_for_setup(pcm, SNDRV_PCM_STREAM_CAPTURE,\n\t\t\t\t\t   task_name, &setup[1]);\n\n\tnonblock = !!(file->f_flags & O_NONBLOCK);\n\tif (!nonblock)\n\t\tnonblock = nonblock_open;\n\n\tinit_waitqueue_entry(&wait, current);\n\tadd_wait_queue(&pcm->open_wait, &wait);\n\tmutex_lock(&pcm->open_mutex);\n\twhile (1) {\n\t\terr = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file,\n\t\t\t\t\t    iminor(inode), setup);\n\t\tif (err >= 0)\n\t\t\tbreak;\n\t\tif (err == -EAGAIN) {\n\t\t\tif (nonblock) {\n\t\t\t\terr = -EBUSY;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tbreak;\n\t\tset_current_state(TASK_INTERRUPTIBLE);\n\t\tmutex_unlock(&pcm->open_mutex);\n\t\tschedule();\n\t\tmutex_lock(&pcm->open_mutex);\n\t\tif (pcm->card->shutdown) {\n\t\t\terr = -ENODEV;\n\t\t\tbreak;\n\t\t}\n\t\tif (signal_pending(current)) {\n\t\t\terr = -ERESTARTSYS;\n\t\t\tbreak;\n\t\t}\n\t}\n\tremove_wait_queue(&pcm->open_wait, &wait);\n\tmutex_unlock(&pcm->open_mutex);\n\tif (err < 0)\n\t\tgoto __error;\n\tsnd_card_unref(pcm->card);\n\treturn err;\n\n      __error:\n     \tmodule_put(pcm->card->module);\n      __error2:\n      \tsnd_card_file_remove(pcm->card, file);\n      __error1:\n\tif (pcm)\n\t\tsnd_card_unref(pcm->card);\n\treturn err;\n}","target":0,"code_token_length":624,"total_token_length":860,"max_tokens_setting":1024}
+{"idx":338150,"func":"void WasmBinaryBuilder::processNames() {\n  for (auto* func : functions) {\n    wasm.addFunction(func);\n  }\n  for (auto& global : globals) {\n    wasm.addGlobal(std::move(global));\n  }\n  for (auto& table : tables) {\n    wasm.addTable(std::move(table));\n  }\n  for (auto& segment : elementSegments) {\n    wasm.addElementSegment(std::move(segment));\n  }\n\n  \/\/ now that we have names, apply things\n\n  if (startIndex != static_cast<Index>(-1)) {\n    wasm.start = getFunctionName(startIndex);\n  }\n\n  for (auto* curr : exportOrder) {\n    auto index = exportIndices[curr];\n    switch (curr->kind) {\n      case ExternalKind::Function: {\n        curr->value = getFunctionName(index);\n        break;\n      }\n      case ExternalKind::Table:\n        curr->value = getTableName(index);\n        break;\n      case ExternalKind::Memory:\n        curr->value = wasm.memory.name;\n        break;\n      case ExternalKind::Global:\n        curr->value = getGlobalName(index);\n        break;\n      case ExternalKind::Tag:\n        curr->value = getTagName(index);\n        break;\n      default:\n        throwError(\"bad export kind\");\n    }\n    wasm.addExport(curr);\n  }\n\n  for (auto& [index, refs] : functionRefs) {\n    for (auto* ref : refs) {\n      if (auto* call = ref->dynCast<Call>()) {\n        call->target = getFunctionName(index);\n      } else if (auto* refFunc = ref->dynCast<RefFunc>()) {\n        refFunc->func = getFunctionName(index);\n      } else {\n        WASM_UNREACHABLE(\"Invalid type in function references\");\n      }\n    }\n  }\n\n  for (auto& [index, refs] : tableRefs) {\n    for (auto* ref : refs) {\n      if (auto* callIndirect = ref->dynCast<CallIndirect>()) {\n        callIndirect->table = getTableName(index);\n      } else if (auto* get = ref->dynCast<TableGet>()) {\n        get->table = getTableName(index);\n      } else if (auto* set = ref->dynCast<TableSet>()) {\n        set->table = getTableName(index);\n      } else if (auto* size = ref->dynCast<TableSize>()) {\n        size->table = getTableName(index);\n      } else if (auto* grow = ref->dynCast<TableGrow>()) {\n        grow->table = getTableName(index);\n      } else {\n        WASM_UNREACHABLE(\"Invalid type in table references\");\n      }\n    }\n  }\n\n  for (auto& [index, refs] : globalRefs) {\n    for (auto* ref : refs) {\n      if (auto* get = ref->dynCast<GlobalGet>()) {\n        get->name = getGlobalName(index);\n      } else if (auto* set = ref->dynCast<GlobalSet>()) {\n        set->name = getGlobalName(index);\n      } else {\n        WASM_UNREACHABLE(\"Invalid type in global references\");\n      }\n    }\n  }\n\n  \/\/ Everything now has its proper name.\n\n  wasm.updateMaps();\n}","target":0,"code_token_length":685,"total_token_length":921,"max_tokens_setting":1024}
+{"idx":455420,"func":"xfs_inode_free_cowblocks(\n\tstruct xfs_inode\t*ip,\n\tint\t\t\tflags,\n\tvoid\t\t\t*args)\n{\n\tstruct xfs_eofblocks\t*eofb = args;\n\tstruct xfs_ifork\t*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);\n\tint\t\t\tmatch;\n\tint\t\t\tret = 0;\n\n\tif (!xfs_prep_free_cowblocks(ip, ifp))\n\t\treturn 0;\n\n\tif (eofb) {\n\t\tif (eofb->eof_flags & XFS_EOF_FLAGS_UNION)\n\t\t\tmatch = xfs_inode_match_id_union(ip, eofb);\n\t\telse\n\t\t\tmatch = xfs_inode_match_id(ip, eofb);\n\t\tif (!match)\n\t\t\treturn 0;\n\n\t\t\/* skip the inode if the file size is too small *\/\n\t\tif (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&\n\t\t    XFS_ISIZE(ip) < eofb->eof_min_file_size)\n\t\t\treturn 0;\n\t}\n\n\t\/* Free the CoW blocks *\/\n\txfs_ilock(ip, XFS_IOLOCK_EXCL);\n\txfs_ilock(ip, XFS_MMAPLOCK_EXCL);\n\n\t\/*\n\t * Check again, nobody else should be able to dirty blocks or change\n\t * the reflink iflag now that we have the first two locks held.\n\t *\/\n\tif (xfs_prep_free_cowblocks(ip, ifp))\n\t\tret = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, false);\n\n\txfs_iunlock(ip, XFS_MMAPLOCK_EXCL);\n\txfs_iunlock(ip, XFS_IOLOCK_EXCL);\n\n\treturn ret;\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":225709,"func":"\nGF_Err pcrb_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_PcrInfoBox *ptr = (GF_PcrInfoBox*) s;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->subsegment_count = gf_bs_read_u32(bs);\n\n\tif ((u64)ptr->subsegment_count > ptr->size \/ 8 || (u64)ptr->subsegment_count > (u64)SIZE_MAX\/sizeof(u64)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of subsegment %d in pcrb\\n\", ptr->subsegment_count));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tptr->pcr_values = gf_malloc(sizeof(u64)*ptr->subsegment_count);\n\tif (!ptr->pcr_values) return GF_OUT_OF_MEM;\n\tfor (i=0; i<ptr->subsegment_count; i++) {\n\t\tu64 data1 = gf_bs_read_u32(bs);\n\t\tu64 data2 = gf_bs_read_u16(bs);\n\t\tISOM_DECREASE_SIZE(ptr, 6);\n\t\tptr->pcr_values[i] = (data1 << 10) | (data2 >> 6);\n\n\t}\n\treturn GF_OK;","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":245158,"func":"lock_tables_maybe(MYSQL *connection, int timeout, int retry_count)\n{\n\tif (tables_locked || opt_lock_ddl_per_table) {\n\t\treturn(true);\n\t}\n\n\tif (have_backup_locks) {\n\t\treturn lock_tables_for_backup(connection, timeout, retry_count);\n\t}\n\n\tif (have_lock_wait_timeout) {\n\t\tchar query[200];\n\n\t\tut_snprintf(query, sizeof(query),\n\t\t\t    \"SET SESSION lock_wait_timeout=%d\", timeout);\n\n\t\txb_mysql_query(connection, query, false);\n\t}\n\n\tif (!opt_lock_wait_timeout && !opt_kill_long_queries_timeout) {\n\n\t\t\/* We do first a FLUSH TABLES. If a long update is running, the\n\t\tFLUSH TABLES will wait but will not stall the whole mysqld, and\n\t\twhen the long update is done the FLUSH TABLES WITH READ LOCK\n\t\twill start and succeed quickly. So, FLUSH TABLES is to lower\n\t\tthe probability of a stage where both mysqldump and most client\n\t\tconnections are stalled. Of course, if a second long update\n\t\tstarts between the two FLUSHes, we have that bad stall.\n\n\t\tOption lock_wait_timeout serve the same purpose and is not\n\t\tcompatible with this trick.\n\t\t*\/\n\n\t\tmsg_ts(\"Executing FLUSH NO_WRITE_TO_BINLOG TABLES...\\n\");\n\n\t\txb_mysql_query(connection,\n\t\t\t       \"FLUSH NO_WRITE_TO_BINLOG TABLES\", false);\n\t}\n\n\tif (opt_lock_wait_timeout) {\n\t\tif (!wait_for_no_updates(connection, opt_lock_wait_timeout,\n\t\t\t\t\t opt_lock_wait_threshold)) {\n\t\t\treturn(false);\n\t\t}\n\t}\n\n\tmsg_ts(\"Executing FLUSH TABLES WITH READ LOCK...\\n\");\n\n\tif (opt_kill_long_queries_timeout) {\n\t\tstart_query_killer();\n\t}\n\n\tif (have_galera_enabled) {\n\t\txb_mysql_query(connection,\n\t\t\t\t\"SET SESSION wsrep_causal_reads=0\", false);\n\t}\n\n\txb_mysql_query(connection, \"FLUSH TABLES WITH READ LOCK\", false);\n\n\tif (opt_kill_long_queries_timeout) {\n\t\tstop_query_killer();\n\t}\n\n\ttables_locked = true;\n\n\treturn(true);\n}","target":0,"code_token_length":457,"total_token_length":693,"max_tokens_setting":1024}
+{"idx":301498,"func":"score_comp_sal(suginfo_T *su)\n{\n    langp_T\t*lp;\n    char_u\tbadsound[MAXWLEN];\n    int\t\ti;\n    suggest_T   *stp;\n    suggest_T   *sstp;\n    int\t\tscore;\n    int\t\tlpi;\n\n    if (ga_grow(&su->su_sga, su->su_ga.ga_len) == FAIL)\n\treturn;\n\n    \/\/ Use the sound-folding of the first language that supports it.\n    for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)\n    {\n\tlp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);\n\tif (lp->lp_slang->sl_sal.ga_len > 0)\n\t{\n\t    \/\/ soundfold the bad word\n\t    spell_soundfold(lp->lp_slang, su->su_fbadword, TRUE, badsound);\n\n\t    for (i = 0; i < su->su_ga.ga_len; ++i)\n\t    {\n\t\tstp = &SUG(su->su_ga, i);\n\n\t\t\/\/ Case-fold the suggested word, sound-fold it and compute the\n\t\t\/\/ sound-a-like score.\n\t\tscore = stp_sal_score(stp, su, lp->lp_slang, badsound);\n\t\tif (score < SCORE_MAXMAX)\n\t\t{\n\t\t    \/\/ Add the suggestion.\n\t\t    sstp = &SUG(su->su_sga, su->su_sga.ga_len);\n\t\t    sstp->st_word = vim_strsave(stp->st_word);\n\t\t    if (sstp->st_word != NULL)\n\t\t    {\n\t\t\tsstp->st_wordlen = stp->st_wordlen;\n\t\t\tsstp->st_score = score;\n\t\t\tsstp->st_altscore = 0;\n\t\t\tsstp->st_orglen = stp->st_orglen;\n\t\t\t++su->su_sga.ga_len;\n\t\t    }\n\t\t}\n\t    }\n\t    break;\n\t}\n    }\n}","target":0,"code_token_length":427,"total_token_length":663,"max_tokens_setting":1024}
+{"idx":310047,"func":"_nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)\n{\n    int result = ERR;\n    int maxcolors;\n\n    T((T_CALLED(\"color_content(%p,%d,%p,%p,%p)\"),\n       (void *) sp,\n       color,\n       (void *) r,\n       (void *) g,\n       (void *) b));\n\n    if (sp == 0)\n\treturnCode(result);\n\n    maxcolors = MaxColors;\n\n    if (color < 0 || !OkColorHi(color) || !sp->_coloron) {\n\tresult = ERR;\n    } else {\n\tint c_r, c_g, c_b;\n\n\tif (sp->_direct_color.value) {\n\t    rgb_bits_t *work = &(sp->_direct_color);\n\n#define max_direct_color(name)\t((1 << work->bits.name) - 1)\n#define value_direct_color(max) (1000 * ((color >> bitoff) & max)) \/ max\n\n\t    int max_r = max_direct_color(red);\n\t    int max_g = max_direct_color(green);\n\t    int max_b = max_direct_color(blue);\n\n\t    int bitoff = 0;\n\n\t    c_b = value_direct_color(max_b);\n\t    bitoff += work->bits.blue;\n\n\t    c_g = value_direct_color(max_g);\n\t    bitoff += work->bits.green;\n\n\t    c_r = value_direct_color(max_r);\n\n\t} else {\n\t    c_r = sp->_color_table[color].red;\n\t    c_g = sp->_color_table[color].green;\n\t    c_b = sp->_color_table[color].blue;\n\t}\n\n\tif (r)\n\t    *r = c_r;\n\tif (g)\n\t    *g = c_g;\n\tif (b)\n\t    *b = c_b;\n\n\tTR(TRACE_ATTRS, (\"...color_content(%d,%d,%d,%d)\",\n\t\t\t color, c_r, c_g, c_b));\n\tresult = OK;\n    }\n    returnCode(result);\n}","target":0,"code_token_length":413,"total_token_length":649,"max_tokens_setting":1024}
+{"idx":450354,"func":"static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)\n{\n    char buf[1024];\n    VncShareMode mode;\n    int size;\n\n    mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;\n    switch (vs->vd->share_policy) {\n    case VNC_SHARE_POLICY_IGNORE:\n        \/*\n         * Ignore the shared flag.  Nothing to do here.\n         *\n         * Doesn't conform to the rfb spec but is traditional qemu\n         * behavior, thus left here as option for compatibility\n         * reasons.\n         *\/\n        break;\n    case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:\n        \/*\n         * Policy: Allow clients ask for exclusive access.\n         *\n         * Implementation: When a client asks for exclusive access,\n         * disconnect all others. Shared connects are allowed as long\n         * as no exclusive connection exists.\n         *\n         * This is how the rfb spec suggests to handle the shared flag.\n         *\/\n        if (mode == VNC_SHARE_MODE_EXCLUSIVE) {\n            VncState *client;\n            QTAILQ_FOREACH(client, &vs->vd->clients, next) {\n                if (vs == client) {\n                    continue;\n                }\n                if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&\n                    client->share_mode != VNC_SHARE_MODE_SHARED) {\n                    continue;\n                }\n                vnc_disconnect_start(client);\n            }\n        }\n        if (mode == VNC_SHARE_MODE_SHARED) {\n            if (vs->vd->num_exclusive > 0) {\n                vnc_disconnect_start(vs);\n                return 0;\n            }\n        }\n        break;\n    case VNC_SHARE_POLICY_FORCE_SHARED:\n        \/*\n         * Policy: Shared connects only.\n         * Implementation: Disallow clients asking for exclusive access.\n         *\n         * Useful for shared desktop sessions where you don't want\n         * someone forgetting to say -shared when running the vnc\n         * client disconnect everybody else.\n         *\/\n        if (mode == VNC_SHARE_MODE_EXCLUSIVE) {\n            vnc_disconnect_start(vs);\n            return 0;\n        }\n        break;\n    }\n    vnc_set_share_mode(vs, mode);\n\n    if (vs->vd->num_shared > vs->vd->connections_limit) {\n        vnc_disconnect_start(vs);\n        return 0;\n    }\n\n    assert(pixman_image_get_width(vs->vd->server) < 65536 &&\n           pixman_image_get_width(vs->vd->server) >= 0);\n    assert(pixman_image_get_height(vs->vd->server) < 65536 &&\n           pixman_image_get_height(vs->vd->server) >= 0);\n    vs->client_width = pixman_image_get_width(vs->vd->server);\n    vs->client_height = pixman_image_get_height(vs->vd->server);\n    vnc_write_u16(vs, vs->client_width);\n    vnc_write_u16(vs, vs->client_height);\n\n    pixel_format_message(vs);\n\n    if (qemu_name) {\n        size = snprintf(buf, sizeof(buf), \"QEMU (%s)\", qemu_name);\n        if (size > sizeof(buf)) {\n            size = sizeof(buf);\n        }\n    } else {\n        size = snprintf(buf, sizeof(buf), \"QEMU\");\n    }\n\n    vnc_write_u32(vs, size);\n    vnc_write(vs, buf, size);\n    vnc_flush(vs);\n\n    vnc_client_cache_auth(vs);\n    vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED);\n\n    vnc_read_when(vs, protocol_client_msg, 1);\n\n    return 0;\n}","target":0,"code_token_length":773,"total_token_length":1009,"max_tokens_setting":1024}
+{"idx":455285,"func":"bash_backward_shellword (count, key)\n     int count, key;\n{\n  size_t slen;\n  int c, p, prev_p;\n  DECLARE_MBSTATE;\n\n  if (count < 0)\n    return (bash_forward_shellword (-count, key));\n\n  p = rl_point;\n  slen = rl_end;\n\n  while (count)\n    {\n      if (p == 0)\n\t{\n\t  rl_point = 0;\n\t  return 0;\n\t}\n\n      \/* Move backward until we hit a non-metacharacter. We want to deal\n\t with the characters before point, so we move off a word if we're\n\t at its first character. *\/\n      BACKUP_CHAR (rl_line_buffer, slen, p);\n      while (p > 0)\n\t{\n\t  c = rl_line_buffer[p];\n\t  if (WORDDELIM (c) == 0 || char_is_quoted (rl_line_buffer, p))\n\t    break;\n\t  BACKUP_CHAR (rl_line_buffer, slen, p);\n\t}\n\n      if (p == 0)\n\t{\n\t  rl_point = 0;\n\t  return 0;\n\t}\n\n      \/* Now move backward until we hit a metacharacter or BOL. Leave point\n\t at the start of the shellword or at BOL. *\/\n      prev_p = p;\n      while (p > 0)\n\t{\n\t  c = rl_line_buffer[p];\n\t  if (WORDDELIM (c) && char_is_quoted (rl_line_buffer, p) == 0)\n\t    {\n\t      p = prev_p;\n\t      break;\n\t    }\n\t  prev_p = p;\n\t  BACKUP_CHAR (rl_line_buffer, slen, p);\n\t}\n\n      count--;\n    }\n\n  rl_point = p;\n  return 0;\n}","target":0,"code_token_length":378,"total_token_length":614,"max_tokens_setting":1024}
+{"idx":229315,"func":"void EagerKernelExecuteAsync(\n    EagerContext* ctx, const absl::InlinedVector<TensorHandle*, 4>& op_inputs,\n    const absl::optional<EagerFunctionParams>& eager_func_params,\n    const core::RefCountPtr<KernelAndDevice> kernel,\n    GraphCollector* graph_collector, CancellationManager* cancellation_manager,\n    TensorHandle** retvals, int num_outputs, StatusCallback done) {\n  auto inputs = std::make_shared<ExecuteNodeArgs>(op_inputs.size());\n  auto outputs = std::make_shared<std::vector<EagerKernelRet>>(1);\n\n  Status s = inputs->Init(ctx, op_inputs, kernel);\n  if (!s.ok()) {\n    done(s);\n    return;\n  }\n  CoordinationServiceAgent* coord_agent = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n  if (ctx->GetDistributedManager() != nullptr)\n    coord_agent = ctx->GetDistributedManager()->GetCoordinationServiceAgent();\n#endif  \/\/ !IS_MOBILE_PLATFORM\n\n  kernel->Ref();  \/\/ Ownership of reference is transferred to the callback\n  kernel->RunAsync(\n      ctx->StepContainer(), *inputs, outputs.get(), cancellation_manager,\n      eager_func_params, coord_agent,\n      [retvals, inputs, outputs, num_outputs, ctx, graph_collector,\n       eager_func_params, kernel_raw = kernel.get(),\n       done = std::move(done)](const Status& s) {\n        auto wrapped_done = [&](const Status& s) {\n          kernel_raw->Unref();\n          done(s);\n        };\n        if (!s.ok()) {\n          wrapped_done(s);\n          return;\n        }\n        if (graph_collector != nullptr) {\n          CollectGraphs(ctx);\n        }\n        DCHECK_EQ(num_outputs, outputs->size());\n        wrapped_done(GetKernelOutputs(outputs.get(), num_outputs, retvals, ctx,\n                                      kernel_raw, eager_func_params));\n      });\n}","target":0,"code_token_length":396,"total_token_length":632,"max_tokens_setting":1024}
+{"idx":508363,"func":"open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,\n                            Open_tables_backup *backup)\n{\n  Query_tables_list query_tables_list_backup;\n  LEX *lex= thd->lex;\n\n  DBUG_ENTER(\"open_system_tables_for_read\");\n\n  \/*\n    Besides using new Open_tables_state for opening system tables,\n    we also have to backup and reset\/and then restore part of LEX\n    which is accessed by open_tables() in order to determine if\n    prelocking is needed and what tables should be added for it.\n    close_system_tables() doesn't require such treatment.\n  *\/\n  lex->reset_n_backup_query_tables_list(&query_tables_list_backup);\n  thd->reset_n_backup_open_tables_state(backup);\n  thd->lex->sql_command= SQLCOM_SELECT;\n\n  if (open_and_lock_tables(thd, table_list, FALSE,\n                           MYSQL_OPEN_IGNORE_FLUSH |\n                           MYSQL_LOCK_IGNORE_TIMEOUT))\n  {\n    lex->restore_backup_query_tables_list(&query_tables_list_backup);\n    thd->restore_backup_open_tables_state(backup);\n    DBUG_RETURN(TRUE);\n  }\n\n  for (TABLE_LIST *tables= table_list; tables; tables= tables->next_global)\n  {\n    DBUG_ASSERT(tables->table->s->table_category == TABLE_CATEGORY_SYSTEM);\n    tables->table->use_all_columns();\n  }\n  lex->restore_backup_query_tables_list(&query_tables_list_backup);\n\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":305,"total_token_length":541,"max_tokens_setting":1024}
+{"idx":90142,"func":"  virtual std::string GetHtmlInfo(int refresh) {\n    std::string output;\n    output.append(\"<html><head><title>About Network<\/title>\");\n    if (refresh > 0)\n      output.append(\"<meta http-equiv=\\\"refresh\\\" content=\\\"\" +\n          base::IntToString(refresh) + \"\\\"\/>\");\n    output.append(\"<\/head><body>\");\n    if (refresh > 0) {\n      output.append(\"(Auto-refreshing page every \" +\n                    base::IntToString(refresh) + \"s)\");\n    } else {\n      output.append(\"(To auto-refresh this page: about:network\/<secs>)\");\n    }\n\n    output.append(\"<h3>Ethernet:<\/h3><table border=1>\");\n    if (ethernet_ && ethernet_enabled()) {\n      output.append(\"<tr>\" + ToHtmlTableHeader(ethernet_) + \"<\/tr>\");\n      output.append(\"<tr>\" + ToHtmlTableRow(ethernet_) + \"<\/tr>\");\n    }\n\n    output.append(\"<\/table><h3>Wifi:<\/h3><table border=1>\");\n    for (size_t i = 0; i < wifi_networks_.size(); ++i) {\n      if (i == 0)\n        output.append(\"<tr>\" + ToHtmlTableHeader(wifi_networks_[i]) + \"<\/tr>\");\n      output.append(\"<tr>\" + ToHtmlTableRow(wifi_networks_[i]) + \"<\/tr>\");\n    }\n\n    output.append(\"<\/table><h3>Cellular:<\/h3><table border=1>\");\n    for (size_t i = 0; i < cellular_networks_.size(); ++i) {\n      if (i == 0)\n        output.append(\"<tr>\" + ToHtmlTableHeader(cellular_networks_[i]) +\n            \"<\/tr>\");\n      output.append(\"<tr>\" + ToHtmlTableRow(cellular_networks_[i]) + \"<\/tr>\");\n    }\n\n    output.append(\"<\/table><h3>Remembered Wifi:<\/h3><table border=1>\");\n    for (size_t i = 0; i < remembered_wifi_networks_.size(); ++i) {\n      if (i == 0)\n        output.append(\n            \"<tr>\" + ToHtmlTableHeader(remembered_wifi_networks_[i]) +\n            \"<\/tr>\");\n      output.append(\"<tr>\" + ToHtmlTableRow(remembered_wifi_networks_[i]) +\n          \"<\/tr>\");\n    }\n\n    output.append(\"<\/table><\/body><\/html>\");\n    return output;\n  }\n","target":0,"code_token_length":510,"total_token_length":746,"max_tokens_setting":1024}
+{"idx":224589,"func":"Status ReductionShape(InferenceContext* c) {\n  ShapeHandle input = c->input(0);\n\n  ShapeHandle indices;\n  \/\/ Older versions of TensorFlow accidentally allowed higher rank tensors like\n  \/\/ [[1,2]] or [[1],[2]] to represent axis=[1,2].\n  if (c->graph_def_version() < 21) {\n    indices = c->input(1);\n  } else {\n    TF_RETURN_IF_ERROR(c->WithRankAtMost(c->input(1), 1, &indices));\n  }\n\n  bool keep_dims;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"keep_dims\", &keep_dims));\n\n  const Tensor* reduction_indices_t = c->input_tensor(1);\n  if (reduction_indices_t == nullptr || !c->RankKnown(input)) {\n    \/\/ If we do not have the reduction values at runtime, or the\n    \/\/ rank of the input, we don't know the output shape.\n\n    if (keep_dims && c->RankKnown(input)) {\n      \/\/ output rank matches input input if <keep_dims>.\n      c->set_output(0, c->UnknownShapeOfRank(c->Rank(input)));\n      return Status::OK();\n    } else {\n      return shape_inference::UnknownShape(c);\n    }\n  }\n\n  const int32_t input_rank = c->Rank(input);\n  std::set<int64_t> true_indices;\n  if (reduction_indices_t->dtype() == DataType::DT_INT32) {\n    TF_RETURN_IF_ERROR(ReductionShapeHelper<int32>(reduction_indices_t,\n                                                   input_rank, &true_indices));\n  } else if (reduction_indices_t->dtype() == DataType::DT_INT64) {\n    TF_RETURN_IF_ERROR(ReductionShapeHelper<int64_t>(\n        reduction_indices_t, input_rank, &true_indices));\n  } else {\n    return errors::InvalidArgument(\n        \"reduction_indices can only be int32 or int64\");\n  }\n\n  std::vector<DimensionHandle> dims;\n  for (int i = 0; i < input_rank; ++i) {\n    if (true_indices.count(i) > 0) {\n      if (keep_dims) {\n        dims.emplace_back(c->MakeDim(1));\n      }\n    } else {\n      dims.emplace_back(c->Dim(input, i));\n    }\n  }\n\n  c->set_output(0, c->MakeShape(dims));\n  return Status::OK();\n}","target":0,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":508790,"func":"void st_select_lex::remap_tables(TABLE_LIST *derived, table_map map,\n                                 uint tablenr, SELECT_LEX *parent_lex)\n{\n  bool first_table= TRUE;\n  TABLE_LIST *tl;\n  table_map first_map;\n  uint first_tablenr;\n\n  if (derived && derived->table)\n  {\n    first_map= derived->table->map;\n    first_tablenr= derived->table->tablenr;\n  }\n  else\n  {\n    first_map= map;\n    map<<= 1;\n    first_tablenr= tablenr++;\n  }\n  \/*\n    Assign table bit\/table number.\n    To the first table of the subselect the table bit\/tablenr of the\n    derived table is assigned. The rest of tables are getting bits\n    sequentially, starting from the provided table map\/tablenr.\n  *\/\n  List_iterator<TABLE_LIST> ti(leaf_tables);\n  while ((tl= ti++))\n  {\n    if (first_table)\n    {\n      first_table= FALSE;\n      tl->table->set_table_map(first_map, first_tablenr);\n    }\n    else\n    {\n      tl->table->set_table_map(map, tablenr);\n      tablenr++;\n      map<<= 1;\n    }\n    SELECT_LEX *old_sl= tl->select_lex;\n    tl->select_lex= parent_lex;\n    for(TABLE_LIST *emb= tl->embedding;\n        emb && emb->select_lex == old_sl;\n        emb= emb->embedding)\n      emb->select_lex= parent_lex;\n  }\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":369219,"func":"static int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_async_msghdr iomsg, *kmsg;\n\tstruct socket *sock;\n\tunsigned flags;\n\tint min_ret = 0;\n\tint ret;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tif (req_has_async_data(req)) {\n\t\tkmsg = req->async_data;\n\t} else {\n\t\tret = io_sendmsg_copy_hdr(req, &iomsg);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tkmsg = &iomsg;\n\t}\n\n\tflags = req->sr_msg.msg_flags;\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\tflags |= MSG_DONTWAIT;\n\tif (flags & MSG_WAITALL)\n\t\tmin_ret = iov_iter_count(&kmsg->msg.msg_iter);\n\n\tret = __sys_sendmsg_sock(sock, &kmsg->msg, flags);\n\n\tif (ret < min_ret) {\n\t\tif (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))\n\t\t\treturn io_setup_async_msg(req, kmsg);\n\t\tif (ret == -ERESTARTSYS)\n\t\t\tret = -EINTR;\n\t\treq_set_fail(req);\n\t}\n\t\/* fast path, check for non-NULL to avoid function call *\/\n\tif (kmsg->free_iov)\n\t\tkfree(kmsg->free_iov);\n\treq->flags &= ~REQ_F_NEED_CLEANUP;\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":329940,"func":"_fill_a8_lerp_opaque_spans (void *abstract_renderer, int y, int h,\n\t\t\t    const cairo_half_open_span_t *spans, unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (likely(h == 1)) {\n\tuint8_t *d = r->u.fill.data + r->u.fill.stride*y;\n\tdo {\n\t    uint8_t a = spans[0].coverage;\n\t    if (a) {\n\t\tint len = spans[1].x - spans[0].x;\n\t\tif (a == 0xff) {\n\t\t    memset(d + spans[0].x, r->u.fill.pixel, len);\n\t\t} else {\n\t\t    uint8_t s = mul8_8(a, r->u.fill.pixel);\n\t\t    uint8_t *dst = d + spans[0].x;\n\t\t    a = ~a;\n\t\t    while (len-- > 0) {\n\t\t\tuint8_t t = mul8_8(*dst, a);\n\t\t\t*dst++ = t + s;\n\t\t    }\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    } else {\n\tdo {\n\t    uint8_t a = spans[0].coverage;\n\t    if (a) {\n\t\tint yy = y, hh = h;\n\t\tif (a == 0xff) {\n\t\t    do {\n\t\t\tint len = spans[1].x - spans[0].x;\n\t\t\tuint8_t *d = r->u.fill.data + r->u.fill.stride*yy + spans[0].x;\n\t\t\tmemset(d, r->u.fill.pixel, len);\n\t\t\tyy++;\n\t\t    } while (--hh);\n\t\t} else {\n\t\t    uint8_t s = mul8_8(a, r->u.fill.pixel);\n\t\t    a = ~a;\n\t\t    do {\n\t\t\tint len = spans[1].x - spans[0].x;\n\t\t\tuint8_t *d = r->u.fill.data + r->u.fill.stride*yy + spans[0].x;\n\t\t\twhile (len-- > 0) {\n\t\t\t    uint8_t t = mul8_8(*d, a);\n\t\t\t    *d++ = t + s;\n\t\t\t}\n\t\t\tyy++;\n\t\t    } while (--hh);\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":520,"total_token_length":756,"max_tokens_setting":1024}
+{"idx":261757,"func":"void RtmpProtocol::send_complex_S0S1S2(int schemeType,const string &digest){\n    \/\/S1S2\u8ba1\u7b97\u53c2\u8003\u81ea:https:\/\/github.com\/hitYangfei\/golang\/blob\/master\/rtmpserver.go\n    \/\/\u53d1\u9001S0\n    char handshake_head = HANDSHAKE_PLAINTEXT;\n    onSendRawData(obtainBuffer(&handshake_head, 1));\n    \/\/S1\n    RtmpHandshake s1(0);\n    memcpy(s1.zero, \"\\x04\\x05\\x00\\x01\", 4);\n    char *digestPos;\n    if (schemeType == 0) {\n        \/* c1s1 schema0\n        time: 4bytes\n        version: 4bytes\n        key: 764bytes\n        digest: 764bytes\n         *\/\n        get_C1_digest(s1.random + C1_SCHEMA_SIZE, &digestPos);\n    } else {\n        \/* c1s1 schema1\n        time: 4bytes\n        version: 4bytes\n        digest: 764bytes\n        key: 764bytes\n         *\/\n        get_C1_digest(s1.random, &digestPos);\n    }\n    char *s1_start = (char *) &s1;\n    string s1_joined(s1_start, sizeof(s1));\n    s1_joined.erase(digestPos - s1_start, C1_DIGEST_SIZE);\n    string s1_digest = openssl_HMACsha256(FMSKey, S1_FMS_KEY_SIZE, s1_joined.data(), s1_joined.size());\n    memcpy(digestPos, s1_digest.data(), s1_digest.size());\n    onSendRawData(obtainBuffer((char *) &s1, sizeof(s1)));\n\n    \/\/S2\n    string s2_key = openssl_HMACsha256(FMSKey, S2_FMS_KEY_SIZE, digest.data(), digest.size());\n    RtmpHandshake s2(0);\n    s2.random_generate((char *) &s2, 8);\n    string s2_digest = openssl_HMACsha256(s2_key.data(), s2_key.size(), &s2, sizeof(s2) - C1_DIGEST_SIZE);\n    memcpy((char *) &s2 + C1_HANDSHARK_SIZE - C1_DIGEST_SIZE, s2_digest.data(), C1_DIGEST_SIZE);\n    onSendRawData(obtainBuffer((char *) &s2, sizeof(s2)));\n    \/\/\u7b49\u5f85C2\n    _next_step_func = [this](const char *data, size_t len) {\n        return handle_C2(data, len);\n    };\n}","target":0,"code_token_length":563,"total_token_length":799,"max_tokens_setting":1024}
+{"idx":259307,"func":"static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,\n                                 AVStream *st, MOVStreamContext *sc)\n{\n    uint8_t codec_name[32] = { 0 };\n    int64_t stsd_start;\n    unsigned int len;\n    uint32_t id = 0;\n\n    \/* The first 16 bytes of the video sample description are already\n     * read in ff_mov_read_stsd_entries() *\/\n    stsd_start = avio_tell(pb) - 16;\n\n    avio_rb16(pb); \/* version *\/\n    avio_rb16(pb); \/* revision level *\/\n    id = avio_rl32(pb); \/* vendor *\/\n    av_dict_set(&st->metadata, \"vendor_id\", av_fourcc2str(id), 0);\n    avio_rb32(pb); \/* temporal quality *\/\n    avio_rb32(pb); \/* spatial quality *\/\n\n    st->codecpar->width  = avio_rb16(pb); \/* width *\/\n    st->codecpar->height = avio_rb16(pb); \/* height *\/\n\n    avio_rb32(pb); \/* horiz resolution *\/\n    avio_rb32(pb); \/* vert resolution *\/\n    avio_rb32(pb); \/* data size, always 0 *\/\n    avio_rb16(pb); \/* frames per samples *\/\n\n    len = avio_r8(pb); \/* codec name, pascal string *\/\n    if (len > 31)\n        len = 31;\n    mov_read_mac_string(c, pb, len, codec_name, sizeof(codec_name));\n    if (len < 31)\n        avio_skip(pb, 31 - len);\n\n    if (codec_name[0])\n        av_dict_set(&st->metadata, \"encoder\", codec_name, 0);\n\n    \/* codec_tag YV12 triggers an UV swap in rawdec.c *\/\n    if (!strncmp(codec_name, \"Planar Y'CbCr 8-bit 4:2:0\", 25)) {\n        st->codecpar->codec_tag = MKTAG('I', '4', '2', '0');\n        st->codecpar->width &= ~1;\n        st->codecpar->height &= ~1;\n    }\n    \/* Flash Media Server uses tag H.263 with Sorenson Spark *\/\n    if (st->codecpar->codec_tag == MKTAG('H','2','6','3') &&\n        !strncmp(codec_name, \"Sorenson H263\", 13))\n        st->codecpar->codec_id = AV_CODEC_ID_FLV1;\n\n    st->codecpar->bits_per_coded_sample = avio_rb16(pb); \/* depth *\/\n\n    avio_seek(pb, stsd_start, SEEK_SET);\n\n    if (ff_get_qtpalette(st->codecpar->codec_id, pb, sc->palette)) {\n        st->codecpar->bits_per_coded_sample &= 0x1F;\n        sc->has_palette = 1;\n    }\n}","target":0,"code_token_length":644,"total_token_length":880,"max_tokens_setting":1024}
+{"idx":316982,"func":"static int selinux_inode_getsecurity(struct user_namespace *mnt_userns,\n\t\t\t\t     struct inode *inode, const char *name,\n\t\t\t\t     void **buffer, bool alloc)\n{\n\tu32 size;\n\tint error;\n\tchar *context = NULL;\n\tstruct inode_security_struct *isec;\n\n\t\/*\n\t * If we're not initialized yet, then we can't validate contexts, so\n\t * just let vfs_getxattr fall back to using the on-disk xattr.\n\t *\/\n\tif (!selinux_initialized(&selinux_state) ||\n\t    strcmp(name, XATTR_SELINUX_SUFFIX))\n\t\treturn -EOPNOTSUPP;\n\n\t\/*\n\t * If the caller has CAP_MAC_ADMIN, then get the raw context\n\t * value even if it is not defined by current policy; otherwise,\n\t * use the in-core value under current policy.\n\t * Use the non-auditing forms of the permission checks since\n\t * getxattr may be called by unprivileged processes commonly\n\t * and lack of permission just means that we fall back to the\n\t * in-core context value, not a denial.\n\t *\/\n\tisec = inode_security(inode);\n\tif (has_cap_mac_admin(false))\n\t\terror = security_sid_to_context_force(&selinux_state,\n\t\t\t\t\t\t      isec->sid, &context,\n\t\t\t\t\t\t      &size);\n\telse\n\t\terror = security_sid_to_context(&selinux_state, isec->sid,\n\t\t\t\t\t\t&context, &size);\n\tif (error)\n\t\treturn error;\n\terror = size;\n\tif (alloc) {\n\t\t*buffer = context;\n\t\tgoto out_nofree;\n\t}\n\tkfree(context);\nout_nofree:\n\treturn error;\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":462304,"func":"pcl_inquire_readback_entity(pcl_args_t * pargs, pcl_state_t * pcs)\n{\n    uint i = uint_arg(pargs);\n    int unit = pcs->location_unit;\n    stream st;\n\n    static const char *entity_types[] = {\n        \"FONTS\", \"MACROS\", \"PATTERNS\", \"SYMBOLSETS\", \"FONTS EXTENDED\"\n    };\n    pcl_data_storage_t storage;\n    int code = 0;\n    long pos;\n\n    if (i > 4)\n        return e_Range;\n    status_begin(&st, pcs);\n    stprintf(&st, \"INFO %s\\r\\n\", entity_types[i]);\n    switch (pcs->location_type) {\n        case 0:                \/* invalid location *\/\n            code = -1;\n            break;\n        case 1:                \/* currently selected *\/\n            storage = (pcl_data_storage_t) 0;   \/* indicates currently selected *\/\n            break;\n        case 2:                \/* all locations *\/\n            storage = (pcl_data_storage_t) ~ 0;\n            break;\n        case 3:                \/* internal *\/\n            if (unit != 0) {\n                code = -1;\n                break;\n            }\n            storage = pcds_internal;\n            break;\n        case 4:                \/* downloaded *\/\n            if (unit > 2)\n                code = -1;\n            else {\n                static const pcl_data_storage_t dl_masks[] =\n                    { pcds_downloaded, pcds_temporary, pcds_permanent\n                };\n                storage = dl_masks[unit];\n            }\n            break;\n        case 5:                \/* cartridges *\/\n            if (unit == 0)\n                storage = (pcl_data_storage_t) pcds_all_cartridges;\n            else if (unit <= pcds_cartridge_max)\n                storage = (pcl_data_storage_t)\n                    (1 << (pcds_cartridge_shift + unit - 1));\n            else\n                code = -1;\n            break;\n        case 6:                \/* SIMMs *\/\n            if (unit == 0)\n                storage = (pcl_data_storage_t) pcds_all_simms;\n            else if (unit <= pcds_simm_max)\n                storage =\n                    (pcl_data_storage_t) (1 << (pcds_simm_shift + unit - 1));\n            else\n                code = -1;\n            break;\n        default:\n            code = -1;\n            stputs(&st, \"ERROR=INVALID ENTITY\\r\\n\");\n            break;\n    }\n    if (code >= 0) {\n        pos = stell(&st);\n        code = (*status_write[i]) (&st, pcs, storage);\n        if (code >= 0) {\n            if (stell(&st) == pos)\n                stputs(&st, \"ERROR=NONE\\r\\n\");\n            else if (storage == 0)      \/* currently selected *\/\n                stprintf(&st, \"LOCTYPE=%d\\r\\nLOCUNIT=%d\\r\\n\",\n                         pcs->location_type, unit);\n        }\n    }\n    if (code < 0) {\n        if (code == e_Memory)\n            stputs(&st, \"ERROR=INTERNAL ERROR\\r\\n\");\n        else\n            stputs(&st, \"ERROR=INVALID LOCATION\\r\\n\");\n    }\n    status_end(&st, pcs);\n    return 0;\n}","target":0,"code_token_length":706,"total_token_length":942,"max_tokens_setting":1024}
+{"idx":274758,"func":"int ntfs_attr_map_runlist(ntfs_attr *na, VCN vcn)\n{\n\tLCN lcn;\n\tntfs_attr_search_ctx *ctx;\n\n\tntfs_log_trace(\"Entering for inode 0x%llx, attr 0x%x, vcn 0x%llx.\\n\",\n\t\t(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type), (long long)vcn);\n\n\tlcn = ntfs_rl_vcn_to_lcn(na->rl, vcn);\n\tif (lcn >= 0 || lcn == LCN_HOLE || lcn == LCN_ENOENT)\n\t\treturn 0;\n\n\tctx = ntfs_attr_get_search_ctx(na->ni, NULL);\n\tif (!ctx)\n\t\treturn -1;\n\n\t\/* Find the attribute in the mft record. *\/\n\tif (!ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,\n\t\t\tvcn, NULL, 0, ctx)) {\n\t\trunlist_element *rl;\n\n\t\t\/* Decode the runlist. *\/\n\t\trl = ntfs_mapping_pairs_decompress(na->ni->vol, ctx->attr,\n\t\t\t\tna->rl);\n\t\tif (rl) {\n\t\t\tna->rl = rl;\n\t\t\tntfs_attr_put_search_ctx(ctx);\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tntfs_attr_put_search_ctx(ctx);\n\treturn -1;\n}","target":0,"code_token_length":309,"total_token_length":545,"max_tokens_setting":1024}
+{"idx":488326,"func":"static int unmap_mapping_range_vma(struct vm_area_struct *vma,\n\t\tunsigned long start_addr, unsigned long end_addr,\n\t\tstruct zap_details *details)\n{\n\tunsigned long restart_addr;\n\tint need_break;\n\n\t\/*\n\t * files that support invalidating or truncating portions of the\n\t * file from under mmaped areas must have their ->fault function\n\t * return a locked page (and set VM_FAULT_LOCKED in the return).\n\t * This provides synchronisation against concurrent unmapping here.\n\t *\/\n\nagain:\n\trestart_addr = vma->vm_truncate_count;\n\tif (is_restart_addr(restart_addr) && start_addr < restart_addr) {\n\t\tstart_addr = restart_addr;\n\t\tif (start_addr >= end_addr) {\n\t\t\t\/* Top of vma has been split off since last time *\/\n\t\t\tvma->vm_truncate_count = details->truncate_count;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\trestart_addr = zap_page_range(vma, start_addr,\n\t\t\t\t\tend_addr - start_addr, details);\n\tneed_break = need_resched() || spin_needbreak(details->i_mmap_lock);\n\n\tif (restart_addr >= end_addr) {\n\t\t\/* We have now completed this vma: mark it so *\/\n\t\tvma->vm_truncate_count = details->truncate_count;\n\t\tif (!need_break)\n\t\t\treturn 0;\n\t} else {\n\t\t\/* Note restart_addr in vma's truncate_count field *\/\n\t\tvma->vm_truncate_count = restart_addr;\n\t\tif (!need_break)\n\t\t\tgoto again;\n\t}\n\n\tspin_unlock(details->i_mmap_lock);\n\tcond_resched();\n\tspin_lock(details->i_mmap_lock);\n\treturn -EINTR;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":335429,"func":"replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)\n{\n    char_u\t*new_cmdline;\n    char_u\t*program;\n    char_u\t*pos;\n    char_u\t*ptr;\n    int\t\tlen;\n    int\t\ti;\n\n    \/*\n     * Don't do it when \":vimgrep\" is used for \":grep\".\n     *\/\n    if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake\n\t\t     || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep\n\t\t     || eap->cmdidx == CMD_grepadd\n\t\t     || eap->cmdidx == CMD_lgrepadd)\n\t    && !grep_internal(eap->cmdidx))\n    {\n\tif (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep\n\t    || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd)\n\t{\n\t    if (*curbuf->b_p_gp == NUL)\n\t\tprogram = p_gp;\n\t    else\n\t\tprogram = curbuf->b_p_gp;\n\t}\n\telse\n\t{\n\t    if (*curbuf->b_p_mp == NUL)\n\t\tprogram = p_mp;\n\t    else\n\t\tprogram = curbuf->b_p_mp;\n\t}\n\n\tp = skipwhite(p);\n\n\tif ((pos = (char_u *)strstr((char *)program, \"$*\")) != NULL)\n\t{\n\t    \/\/ replace $* by given arguments\n\t    i = 1;\n\t    while ((pos = (char_u *)strstr((char *)pos + 2, \"$*\")) != NULL)\n\t\t++i;\n\t    len = (int)STRLEN(p);\n\t    new_cmdline = alloc(STRLEN(program) + (size_t)i * (len - 2) + 1);\n\t    if (new_cmdline == NULL)\n\t\treturn NULL;\t\t\t\/\/ out of memory\n\t    ptr = new_cmdline;\n\t    while ((pos = (char_u *)strstr((char *)program, \"$*\")) != NULL)\n\t    {\n\t\ti = (int)(pos - program);\n\t\tSTRNCPY(ptr, program, i);\n\t\tSTRCPY(ptr += i, p);\n\t\tptr += len;\n\t\tprogram = pos + 2;\n\t    }\n\t    STRCPY(ptr, program);\n\t}\n\telse\n\t{\n\t    new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2);\n\t    if (new_cmdline == NULL)\n\t\treturn NULL;\t\t\t\/\/ out of memory\n\t    STRCPY(new_cmdline, program);\n\t    STRCAT(new_cmdline, \" \");\n\t    STRCAT(new_cmdline, p);\n\t}\n\tmsg_make(p);\n\n\t\/\/ 'eap->cmd' is not set here, because it is not used at CMD_make\n\tvim_free(*cmdlinep);\n\t*cmdlinep = new_cmdline;\n\tp = new_cmdline;\n    }\n    return p;\n}","target":0,"code_token_length":642,"total_token_length":878,"max_tokens_setting":1024}
+{"idx":343207,"func":"static int doport3(const int protocol)\n{\n    struct sockaddr_storage dataconn;  \/* his endpoint *\/\n\n# ifndef NON_ROOT_FTP\n    static const in_port_t portlist[] = FTP_ACTIVE_SOURCE_PORTS;\n    const in_port_t *portlistpnt = portlist;\n# else\n    static const in_port_t portlist[] = { 0U };\n    const in_port_t *portlistpnt = portlist;\n# endif\n    int on;\n\n# ifndef NON_ROOT_FTP\n    disablesignals();\n    seteuid((uid_t) 0);\n# endif\n    if ((datafd = socket(protocol, SOCK_STREAM, IPPROTO_TCP)) == -1) {\n        data_socket_error:\n# ifndef NON_ROOT_FTP\n        if (seteuid(authresult.uid) != 0) {\n            _EXIT(EXIT_FAILURE);\n        }\n        enablesignals();\n# endif\n        (void) close(datafd);\n        datafd = -1;\n        error(425, MSG_CANT_CREATE_DATA_SOCKET);\n\n        return -1;\n    }\n    on = 1;\n# ifdef SO_REUSEPORT\n    (void) setsockopt(datafd, SOL_SOCKET, SO_REUSEPORT,\n                      (char *) &on, sizeof on);\n# else\n    (void) setsockopt(datafd, SOL_SOCKET, SO_REUSEADDR,\n                      (char *) &on, sizeof on);\n# endif\n    memcpy(&dataconn, &ctrlconn, sizeof dataconn);\n    for (;;) {\n        if (STORAGE_FAMILY(dataconn) == AF_INET6) {\n            STORAGE_PORT6(dataconn) = htons(*portlistpnt);\n        } else {\n            STORAGE_PORT(dataconn) = htons(*portlistpnt);\n        }\n        if (bind(datafd, (struct sockaddr *) &dataconn,\n                 STORAGE_LEN(dataconn)) == 0) {\n            break;\n        }\n# ifdef USE_ONLY_FIXED_DATA_PORT\n        (void) sleep(1U);\n# else\n        if (*portlistpnt == (in_port_t) 0U) {\n            goto data_socket_error;\n        }\n        portlistpnt++;\n# endif\n    }\n# ifndef NON_ROOT_FTP\n    if (seteuid(authresult.uid) != 0) {\n        _EXIT(EXIT_FAILURE);\n    }\n    enablesignals();\n# endif\n\n    return 0;\n}","target":0,"code_token_length":492,"total_token_length":728,"max_tokens_setting":1024}
+{"idx":233859,"func":"static int do_iff_chunk_sequence(deark *c, struct de_iffctx *ictx,\n\ti64 pos1, i64 len, int level)\n{\n\ti64 pos;\n\ti64 endpos;\n\ti64 chunk_len;\n\tstruct de_fourcc saved_container_fmt4cc;\n\tstruct de_fourcc saved_container_contentstype4cc;\n\tint ret;\n\n\tif(level >= 16) { \/\/ An arbitrary recursion limit.\n\t\treturn 0;\n\t}\n\n\tendpos = pos1+len;\n\tsaved_container_fmt4cc = ictx->curr_container_fmt4cc;\n\tsaved_container_contentstype4cc = ictx->curr_container_contentstype4cc;\n\n\tpos = pos1;\n\twhile(pos < endpos) {\n\t\tictx->curr_container_fmt4cc = saved_container_fmt4cc;\n\t\tictx->curr_container_contentstype4cc = saved_container_contentstype4cc;\n\n\t\tif(ictx->handle_nonchunk_data_fn) {\n\t\t\ti64 skip_len = 0;\n\t\t\tret = ictx->handle_nonchunk_data_fn(c, ictx, pos, &skip_len);\n\t\t\tif(ret && skip_len>0) {\n\t\t\t\tpos += de_pad_to_n(skip_len, ictx->alignment);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tret = do_iff_chunk(c, ictx, pos, endpos-pos, level, &chunk_len);\n\t\tif(!ret) return 0;\n\t\tpos += chunk_len;\n\t}\n\n\tictx->curr_container_fmt4cc = saved_container_fmt4cc;\n\tictx->curr_container_contentstype4cc = saved_container_contentstype4cc;\n\n\treturn 1;\n}","target":0,"code_token_length":349,"total_token_length":585,"max_tokens_setting":1024}
+{"idx":329917,"func":"_fill_xrgb32_lerp_opaque_spans (void *abstract_renderer, int y, int h,\n\t\t\t\tconst cairo_half_open_span_t *spans, unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    if (likely(h == 1)) {\n\tdo {\n\t    uint8_t a = spans[0].coverage;\n\t    if (a) {\n\t\tint len = spans[1].x - spans[0].x;\n\t\tuint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*y + spans[0].x*4);\n\t\tif (a == 0xff) {\n\t\t    if (len > 31) {\n\t\t\tpixman_fill ((uint32_t *)r->u.fill.data, r->u.fill.stride \/ sizeof(uint32_t), 32,\n\t\t\t\t     spans[0].x, y, len, 1, r->u.fill.pixel);\n\t\t    } else {\n\t\t\tuint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*y + spans[0].x*4);\n\t\t\twhile (len-- > 0)\n\t\t\t    *d++ = r->u.fill.pixel;\n\t\t    }\n\t\t} else while (len-- > 0) {\n\t\t    *d = lerp8x4 (r->u.fill.pixel, a, *d);\n\t\t    d++;\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    } else {\n\tdo {\n\t    uint8_t a = spans[0].coverage;\n\t    if (a) {\n\t\tif (a == 0xff) {\n\t\t    if (spans[1].x - spans[0].x > 16) {\n\t\t\tpixman_fill ((uint32_t *)r->u.fill.data, r->u.fill.stride \/ sizeof(uint32_t), 32,\n\t\t\t\t     spans[0].x, y, spans[1].x - spans[0].x, h,\n\t\t\t\t     r->u.fill.pixel);\n\t\t    } else {\n\t\t\tint yy = y, hh = h;\n\t\t\tdo {\n\t\t\t    int len = spans[1].x - spans[0].x;\n\t\t\t    uint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*yy + spans[0].x*4);\n\t\t\t    while (len-- > 0)\n\t\t\t\t*d++ = r->u.fill.pixel;\n\t\t\t    yy++;\n\t\t\t} while (--hh);\n\t\t    }\n\t\t} else {\n\t\t    int yy = y, hh = h;\n\t\t    do {\n\t\t\tint len = spans[1].x - spans[0].x;\n\t\t\tuint32_t *d = (uint32_t *)(r->u.fill.data + r->u.fill.stride*yy + spans[0].x*4);\n\t\t\twhile (len-- > 0) {\n\t\t\t    *d = lerp8x4 (r->u.fill.pixel, a, *d);\n\t\t\t    d++;\n\t\t\t}\n\t\t\tyy++;\n\t\t    } while (--hh);\n\t\t}\n\t    }\n\t    spans++;\n\t} while (--num_spans > 1);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":703,"total_token_length":939,"max_tokens_setting":1024}
+{"idx":424956,"func":"static int iwl_pcie_load_cpu_sections(struct iwl_trans *trans,\n\t\t\t\t      const struct fw_img *image,\n\t\t\t\t      int cpu,\n\t\t\t\t      int *first_ucode_section)\n{\n\tint i, ret = 0;\n\tu32 last_read_idx = 0;\n\n\tif (cpu == 1)\n\t\t*first_ucode_section = 0;\n\telse\n\t\t(*first_ucode_section)++;\n\n\tfor (i = *first_ucode_section; i < image->num_sec; i++) {\n\t\tlast_read_idx = i;\n\n\t\t\/*\n\t\t * CPU1_CPU2_SEPARATOR_SECTION delimiter - separate between\n\t\t * CPU1 to CPU2.\n\t\t * PAGING_SEPARATOR_SECTION delimiter - separate between\n\t\t * CPU2 non paged to CPU2 paging sec.\n\t\t *\/\n\t\tif (!image->sec[i].data ||\n\t\t    image->sec[i].offset == CPU1_CPU2_SEPARATOR_SECTION ||\n\t\t    image->sec[i].offset == PAGING_SEPARATOR_SECTION) {\n\t\t\tIWL_DEBUG_FW(trans,\n\t\t\t\t     \"Break since Data not valid or Empty section, sec = %d\\n\",\n\t\t\t\t     i);\n\t\t\tbreak;\n\t\t}\n\n\t\tret = iwl_pcie_load_section(trans, i, &image->sec[i]);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\t*first_ucode_section = last_read_idx;\n\n\treturn 0;\n}","target":0,"code_token_length":279,"total_token_length":515,"max_tokens_setting":1024}
+{"idx":227038,"func":"IRC_PROTOCOL_CALLBACK(mode)\n{\n    char *pos_modes, *pos_modes_args, *modes_args;\n    int smart_filter, local_mode;\n    struct t_irc_channel *ptr_channel;\n    struct t_irc_nick *ptr_nick;\n    struct t_gui_buffer *ptr_buffer;\n\n    IRC_PROTOCOL_MIN_ARGS(4);\n    IRC_PROTOCOL_CHECK_HOST;\n\n    pos_modes = (argv[3][0] == ':') ? argv[3] + 1 : argv[3];\n    pos_modes_args = (argc > 4) ?\n        ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL;\n\n    if (irc_channel_is_channel (server, argv[2]))\n    {\n        smart_filter = 0;\n        ptr_channel = irc_channel_search (server, argv[2]);\n        if (ptr_channel)\n        {\n            smart_filter = irc_mode_channel_set (server, ptr_channel, host,\n                                                 pos_modes, pos_modes_args);\n        }\n        local_mode = (irc_server_strcasecmp (server, nick, server->nick) == 0);\n        ptr_nick = irc_nick_search (server, ptr_channel, nick);\n        ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;\n        modes_args = irc_mode_get_arguments (pos_modes_args);\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,\n                                             ptr_buffer),\n            date,\n            irc_protocol_tags (command,\n                               (smart_filter && !local_mode) ?\n                               \"irc_smart_filter\" : NULL,\n                               NULL, address),\n            _(\"%sMode %s%s %s[%s%s%s%s%s]%s by %s%s\"),\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_CHANNEL,\n            (ptr_channel) ? ptr_channel->name : argv[2],\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            pos_modes,\n            (modes_args && modes_args[0]) ? \" \" : \"\",\n            (modes_args && modes_args[0]) ? modes_args : \"\",\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            irc_nick_color_for_msg (server, 1, ptr_nick, nick),\n            nick);\n        if (modes_args)\n            free (modes_args);\n    }\n    else\n    {\n        weechat_printf_date_tags (\n            irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),\n            date,\n            irc_protocol_tags (command, NULL, NULL, address),\n            _(\"%sUser mode %s[%s%s%s]%s by %s%s\"),\n            weechat_prefix (\"network\"),\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            pos_modes,\n            IRC_COLOR_CHAT_DELIMITERS,\n            IRC_COLOR_RESET,\n            irc_nick_color_for_msg (server, 1, NULL, nick),\n            nick);\n        irc_mode_user_set (server, pos_modes, 0);\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":639,"total_token_length":875,"max_tokens_setting":1024}
+{"idx":405337,"func":"int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)\n{\n\tstruct net *net = xp_net(policy);\n\tstruct xfrm_policy *delpol;\n\tstruct hlist_head *chain;\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\tchain = policy_hash_bysel(net, &policy->selector, policy->family, dir);\n\tif (chain)\n\t\tdelpol = xfrm_policy_insert_list(chain, policy, excl);\n\telse\n\t\tdelpol = xfrm_policy_inexact_insert(policy, dir, excl);\n\n\tif (IS_ERR(delpol)) {\n\t\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\t\treturn PTR_ERR(delpol);\n\t}\n\n\t__xfrm_policy_link(policy, dir);\n\n\t\/* After previous checking, family can either be AF_INET or AF_INET6 *\/\n\tif (policy->family == AF_INET)\n\t\trt_genid_bump_ipv4(net);\n\telse\n\t\trt_genid_bump_ipv6(net);\n\n\tif (delpol) {\n\t\txfrm_policy_requeue(delpol, policy);\n\t\t__xfrm_policy_unlink(delpol, dir);\n\t}\n\tpolicy->index = delpol ? delpol->index : xfrm_gen_index(net, dir, policy->index);\n\thlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index));\n\tpolicy->curlft.add_time = ktime_get_real_seconds();\n\tpolicy->curlft.use_time = 0;\n\tif (!mod_timer(&policy->timer, jiffies + HZ))\n\t\txfrm_pol_hold(policy);\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\n\tif (delpol)\n\t\txfrm_policy_kill(delpol);\n\telse if (xfrm_bydst_should_resize(net, dir, NULL))\n\t\tschedule_work(&net->xfrm.policy_hash_work);\n\n\treturn 0;\n}","target":0,"code_token_length":404,"total_token_length":640,"max_tokens_setting":1024}
+{"idx":413652,"func":"static void print_hint_tree(RBTree tree, int mode) {\n#define END_ADDR if (mode == 'j') { pj_end (pj); } else if (mode != '*') { r_cons_newline (); }\n\tPJ *pj = NULL;\n\tif (mode == 'j') {\n\t\tpj = pj_new ();\n\t\tpj_a (pj);\n\t}\n\tRBIter it;\n\tHintNode *node;\n\tut64 last_addr = 0;\n\tbool in_addr = false;\n\tr_rbtree_foreach (tree, it, node, HintNode, rb) {\n\t\tif (!in_addr || last_addr != node->addr) {\n\t\t\tif (in_addr) {\n\t\t\t\tEND_ADDR\n\t\t\t}\n\t\t\tin_addr = true;\n\t\t\tlast_addr = node->addr;\n\t\t\tif (pj) {\n\t\t\t\tpj_o (pj);\n\t\t\t\tpj_kn (pj, \"addr\", node->addr);\n\t\t\t} else if (mode != '*') {\n\t\t\t\tr_cons_printf (\" 0x%08\"PFMT64x\" =>\", node->addr);\n\t\t\t}\n\t\t}\n\t\thint_node_print (node, mode, pj);\n\t}\n\tif (in_addr) {\n\t\tEND_ADDR\n\t}\n\tif (pj) {\n\t\tpj_end (pj);\n\t\tr_cons_printf (\"%s\\n\", pj_string (pj));\n\t\tpj_free (pj);\n\t}\n#undef END_ADDR\n}","target":0,"code_token_length":299,"total_token_length":535,"max_tokens_setting":1024}
+{"idx":383330,"func":"gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)\n{\n\tint c, dc;\n\tint x, y;\n\tint tox, toy;\n\tint ncR, ncG, ncB;\n\tfloat g;\n\ttoy = dstY;\n\n\tfor (y = srcY; (y < (srcY + h)); y++) {\n\t\ttox = dstX;\n\t\tfor (x = srcX; (x < (srcX + w)); x++) {\n\t\t\tint nc;\n\t\t\tc = gdImageGetPixel (src, x, y);\n\t\t\t\/* Added 7\/24\/95: support transparent copies *\/\n\t\t\tif (gdImageGetTransparent(src) == c) {\n\t\t\t\ttox++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/* If it's the same image, mapping is trivial *\/\n\t\t\tif (dst == src) {\n\t\t\t\tnc = c;\n\t\t\t} else {\n\t\t\t\tdc = gdImageGetPixel(dst, tox, toy);\n\t\t\t\tg = (0.29900f * gdImageRed(dst, dc)) + (0.58700f * gdImageGreen(dst, dc)) + (0.11400f * gdImageBlue(dst, dc));\n\n\t\t\t\tncR = (int)(gdImageRed (src, c) * (pct \/ 100.0f) + gdImageRed(dst, dc) * g * ((100 - pct) \/ 100.0f));\n\t\t\t\tncG = (int)(gdImageGreen (src, c) * (pct \/ 100.0f) + gdImageGreen(dst, dc) * g * ((100 - pct) \/ 100.0f));\n\t\t\t\tncB = (int)(gdImageBlue (src, c) * (pct \/ 100.0f) + gdImageBlue(dst, dc) * g * ((100 - pct) \/ 100.0f));\n\n\t\t\t\t\/* First look for an exact match *\/\n\t\t\t\tnc = gdImageColorExact(dst, ncR, ncG, ncB);\n\t\t\t\tif (nc == (-1)) {\n\t\t\t\t\t\/* No, so try to allocate it *\/\n\t\t\t\t\tnc = gdImageColorAllocate(dst, ncR, ncG, ncB);\n\t\t\t\t\t\/* If we're out of colors, go for the closest color *\/\n\t\t\t\t\tif (nc == (-1)) {\n\t\t\t\t\t\tnc = gdImageColorClosest(dst, ncR, ncG, ncB);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tgdImageSetPixel(dst, tox, toy, nc);\n\t\t\ttox++;\n\t\t}\n\t\ttoy++;\n\t}\n}","target":0,"code_token_length":600,"total_token_length":836,"max_tokens_setting":1024}
+{"idx":265536,"func":"int mempool_create_with_shared_mem(\n    size_t pool_item_size, size_t pool_initial_size, size_t pool_expansion_size,\n    func_mem_available_callback_type mem_get_free_space_func,\n    func_mark_mem_used_callback_type mem_mark_used_space_func,\n    func_mark_mem_free_callback_type mem_mark_free_space_func,\n    func_log_callback_type log_callback_func, int flags,\n    MemoryPoolHandle *p_handle) {\n  int rc = 0;\n  struct mempool *pool = NULL;\n  if (mem_get_free_space_func == NULL || mem_mark_used_space_func == NULL ||\n      mem_mark_free_space_func == NULL || p_handle == NULL) {\n    return S3_MEMPOOL_INVALID_ARG;\n  }\n\n  if (pool_initial_size > mem_get_free_space_func()) {\n    return S3_MEMPOOL_THRESHOLD_EXCEEDED;\n  }\n\n  rc = mempool_create(pool_item_size, pool_initial_size, pool_expansion_size, 0,\n                      log_callback_func, flags, p_handle);\n  if (rc != 0) {\n    return rc;\n  }\n\n  pool = (struct mempool *)*p_handle;\n\n  pool->mem_get_free_space_func = mem_get_free_space_func;\n  pool->mem_mark_used_space_func = mem_mark_used_space_func;\n  pool->mem_mark_free_space_func = mem_mark_free_space_func;\n\n  \/* Explicitly mark used space, since mempool_create -> freelist_allocate\n     dont have the function callbacks set. *\/\n  pool->mem_mark_used_space_func(pool->total_bufs_allocated_by_pool *\n                                 pool->mempool_item_size);\n\n  return 0;\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":410712,"func":"static int packet_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct packet_sock *po;\n\tstruct packet_fanout *f;\n\tstruct net *net;\n\tunion tpacket_req_u req_u;\n\n\tif (!sk)\n\t\treturn 0;\n\n\tnet = sock_net(sk);\n\tpo = pkt_sk(sk);\n\n\tmutex_lock(&net->packet.sklist_lock);\n\tsk_del_node_init_rcu(sk);\n\tmutex_unlock(&net->packet.sklist_lock);\n\n\tpreempt_disable();\n\tsock_prot_inuse_add(net, sk->sk_prot, -1);\n\tpreempt_enable();\n\n\tspin_lock(&po->bind_lock);\n\tunregister_prot_hook(sk, false);\n\tpacket_cached_dev_reset(po);\n\n\tif (po->prot_hook.dev) {\n\t\tdev_put(po->prot_hook.dev);\n\t\tpo->prot_hook.dev = NULL;\n\t}\n\tspin_unlock(&po->bind_lock);\n\n\tpacket_flush_mclist(sk);\n\n\tlock_sock(sk);\n\tif (po->rx_ring.pg_vec) {\n\t\tmemset(&req_u, 0, sizeof(req_u));\n\t\tpacket_set_ring(sk, &req_u, 1, 0);\n\t}\n\n\tif (po->tx_ring.pg_vec) {\n\t\tmemset(&req_u, 0, sizeof(req_u));\n\t\tpacket_set_ring(sk, &req_u, 1, 1);\n\t}\n\trelease_sock(sk);\n\n\tf = fanout_release(sk);\n\n\tsynchronize_net();\n\n\tkfree(po->rollover);\n\tif (f) {\n\t\tfanout_release_data(f);\n\t\tkvfree(f);\n\t}\n\t\/*\n\t *\tNow the socket is dead. No more input will appear.\n\t *\/\n\tsock_orphan(sk);\n\tsock->sk = NULL;\n\n\t\/* Purge queues *\/\n\n\tskb_queue_purge(&sk->sk_receive_queue);\n\tpacket_free_pending(po);\n\tsk_refcnt_debug_release(sk);\n\n\tsock_put(sk);\n\treturn 0;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":275959,"func":"int uECC_shared_secret(const uint8_t *public_key,\n                       const uint8_t *private_key,\n                       uint8_t *secret,\n                       uECC_Curve curve) {\n    uECC_word_t _public[uECC_MAX_WORDS * 2];\n    uECC_word_t _private[uECC_MAX_WORDS];\n\n    uECC_word_t tmp[uECC_MAX_WORDS];\n    uECC_word_t *p2[2] = {_private, tmp};\n    uECC_word_t *initial_Z = 0;\n    uECC_word_t carry;\n    wordcount_t num_words = curve->num_words;\n    wordcount_t num_bytes = curve->num_bytes;\n\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    bcopy((uint8_t *) _private, private_key, num_bytes);\n    bcopy((uint8_t *) _public, public_key, num_bytes*2);\n#else\n    uECC_vli_bytesToNative(_private, private_key, BITS_TO_BYTES(curve->num_n_bits));\n    uECC_vli_bytesToNative(_public, public_key, num_bytes);\n    uECC_vli_bytesToNative(_public + num_words, public_key + num_bytes, num_bytes);\n#endif\n\n    \/* Regularize the bitcount for the private key so that attackers cannot use a side channel\n       attack to learn the number of leading zeros. *\/\n    carry = regularize_k(_private, _private, tmp, curve);\n\n    \/* If an RNG function was specified, try to get a random initial Z value to improve\n       protection against side-channel attacks. *\/\n    if (g_rng_function) {\n        if (!uECC_generate_random_int(p2[carry], curve->p, num_words)) {\n            return 0;\n        }\n        initial_Z = p2[carry];\n    }\n\n    EccPoint_mult(_public, _public, p2[!carry], initial_Z, curve->num_n_bits + 1, curve);\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    bcopy((uint8_t *) secret, (uint8_t *) _public, num_bytes);\n#else\n    uECC_vli_nativeToBytes(secret, num_bytes, _public);\n#endif\n    return !EccPoint_isZero(_public, curve);\n}","target":0,"code_token_length":484,"total_token_length":720,"max_tokens_setting":1024}
+{"idx":221472,"func":"flatpak_run_add_system_dbus_args (FlatpakBwrap   *app_bwrap,\n                                  FlatpakBwrap   *proxy_arg_bwrap,\n                                  FlatpakContext *context,\n                                  FlatpakRunFlags flags)\n{\n  gboolean unrestricted, no_proxy;\n  const char *dbus_address = g_getenv (\"DBUS_SYSTEM_BUS_ADDRESS\");\n  g_autofree char *real_dbus_address = NULL;\n  g_autofree char *dbus_system_socket = NULL;\n\n  unrestricted = (context->sockets & FLATPAK_CONTEXT_SOCKET_SYSTEM_BUS) != 0;\n  if (unrestricted)\n    g_debug (\"Allowing system-dbus access\");\n\n  no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY) != 0;\n\n  if (dbus_address != NULL)\n    dbus_system_socket = extract_unix_path_from_dbus_address (dbus_address);\n  else if (g_file_test (\"\/var\/run\/dbus\/system_bus_socket\", G_FILE_TEST_EXISTS))\n    dbus_system_socket = g_strdup (\"\/var\/run\/dbus\/system_bus_socket\");\n\n  if (dbus_system_socket != NULL && unrestricted)\n    {\n      flatpak_bwrap_add_args (app_bwrap,\n                              \"--ro-bind\", dbus_system_socket, \"\/run\/dbus\/system_bus_socket\",\n                              NULL);\n      flatpak_bwrap_set_env (app_bwrap, \"DBUS_SYSTEM_BUS_ADDRESS\", \"unix:path=\/run\/dbus\/system_bus_socket\", TRUE);\n\n      return TRUE;\n    }\n  else if (!no_proxy && flatpak_context_get_needs_system_bus_proxy (context))\n    {\n      g_autofree char *proxy_socket = create_proxy_socket (\"system-bus-proxy-XXXXXX\");\n\n      if (proxy_socket == NULL)\n        return FALSE;\n\n      if (dbus_address)\n        real_dbus_address = g_strdup (dbus_address);\n      else\n        real_dbus_address = g_strdup_printf (\"unix:path=%s\", dbus_system_socket);\n\n      flatpak_bwrap_add_args (proxy_arg_bwrap, real_dbus_address, proxy_socket, NULL);\n\n      if (!unrestricted)\n        flatpak_context_add_bus_filters (context, NULL, FALSE, flags & FLATPAK_RUN_FLAG_SANDBOX, proxy_arg_bwrap);\n\n      if ((flags & FLATPAK_RUN_FLAG_LOG_SYSTEM_BUS) != 0)\n        flatpak_bwrap_add_args (proxy_arg_bwrap, \"--log\", NULL);\n\n      flatpak_bwrap_add_args (app_bwrap,\n                              \"--ro-bind\", proxy_socket, \"\/run\/dbus\/system_bus_socket\",\n                              NULL);\n      flatpak_bwrap_set_env (app_bwrap, \"DBUS_SYSTEM_BUS_ADDRESS\", \"unix:path=\/run\/dbus\/system_bus_socket\", TRUE);\n\n      return TRUE;\n    }\n  return FALSE;\n}","target":0,"code_token_length":567,"total_token_length":803,"max_tokens_setting":1024}
+{"idx":498122,"func":"void cgit_print_docstart(void)\n{\n\tif (ctx.cfg.embedded) {\n\t\tif (ctx.cfg.header)\n\t\t\thtml_include(ctx.cfg.header);\n\t\treturn;\n\t}\n\n\tchar *host = cgit_hosturl();\n\thtml(cgit_doctype);\n\thtml(\"<html xmlns='http:\/\/www.w3.org\/1999\/xhtml' xml:lang='en' lang='en'>\\n\");\n\thtml(\"<head>\\n\");\n\thtml(\"<title>\");\n\thtml_txt(ctx.page.title);\n\thtml(\"<\/title>\\n\");\n\thtmlf(\"<meta name='generator' content='cgit %s'\/>\\n\", cgit_version);\n\tif (ctx.cfg.robots && *ctx.cfg.robots)\n\t\thtmlf(\"<meta name='robots' content='%s'\/>\\n\", ctx.cfg.robots);\n\thtml(\"<link rel='stylesheet' type='text\/css' href='\");\n\thtml_attr(ctx.cfg.css);\n\thtml(\"'\/>\\n\");\n\tif (ctx.cfg.favicon) {\n\t\thtml(\"<link rel='shortcut icon' href='\");\n\t\thtml_attr(ctx.cfg.favicon);\n\t\thtml(\"'\/>\\n\");\n\t}\n\tif (host && ctx.repo && ctx.qry.head) {\n\t\tchar *fileurl;\n\t\tstruct strbuf sb = STRBUF_INIT;\n\t\tstrbuf_addf(&sb, \"h=%s\", ctx.qry.head);\n\n\t\thtml(\"<link rel='alternate' title='Atom feed' href='\");\n\t\thtml(cgit_httpscheme());\n\t\thtml_attr(host);\n\t\tfileurl = cgit_fileurl(ctx.repo->url, \"atom\", ctx.qry.vpath,\n\t\t\t\t       sb.buf);\n\t\thtml_attr(fileurl);\n\t\thtml(\"' type='application\/atom+xml'\/>\\n\");\n\t\tstrbuf_release(&sb);\n\t\tfree(fileurl);\n\t}\n\tif (ctx.repo)\n\t\tcgit_add_clone_urls(print_rel_vcs_link);\n\tif (ctx.cfg.head_include)\n\t\thtml_include(ctx.cfg.head_include);\n\thtml(\"<\/head>\\n\");\n\thtml(\"<body>\\n\");\n\tif (ctx.cfg.header)\n\t\thtml_include(ctx.cfg.header);\n\tfree(host);\n}","target":0,"code_token_length":419,"total_token_length":655,"max_tokens_setting":1024}
+{"idx":234816,"func":"static int update_dev_stat_item(struct btrfs_trans_handle *trans,\n\t\t\t\tstruct btrfs_device *device)\n{\n\tstruct btrfs_fs_info *fs_info = trans->fs_info;\n\tstruct btrfs_root *dev_root = fs_info->dev_root;\n\tstruct btrfs_path *path;\n\tstruct btrfs_key key;\n\tstruct extent_buffer *eb;\n\tstruct btrfs_dev_stats_item *ptr;\n\tint ret;\n\tint i;\n\n\tkey.objectid = BTRFS_DEV_STATS_OBJECTID;\n\tkey.type = BTRFS_PERSISTENT_ITEM_KEY;\n\tkey.offset = device->devid;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\tret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1);\n\tif (ret < 0) {\n\t\tbtrfs_warn_in_rcu(fs_info,\n\t\t\t\"error %d while searching for dev_stats item for device %s\",\n\t\t\t      ret, rcu_str_deref(device->name));\n\t\tgoto out;\n\t}\n\n\tif (ret == 0 &&\n\t    btrfs_item_size_nr(path->nodes[0], path->slots[0]) < sizeof(*ptr)) {\n\t\t\/* need to delete old one and insert a new one *\/\n\t\tret = btrfs_del_item(trans, dev_root, path);\n\t\tif (ret != 0) {\n\t\t\tbtrfs_warn_in_rcu(fs_info,\n\t\t\t\t\"delete too small dev_stats item for device %s failed %d\",\n\t\t\t\t      rcu_str_deref(device->name), ret);\n\t\t\tgoto out;\n\t\t}\n\t\tret = 1;\n\t}\n\n\tif (ret == 1) {\n\t\t\/* need to insert a new item *\/\n\t\tbtrfs_release_path(path);\n\t\tret = btrfs_insert_empty_item(trans, dev_root, path,\n\t\t\t\t\t      &key, sizeof(*ptr));\n\t\tif (ret < 0) {\n\t\t\tbtrfs_warn_in_rcu(fs_info,\n\t\t\t\t\"insert dev_stats item for device %s failed %d\",\n\t\t\t\trcu_str_deref(device->name), ret);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\teb = path->nodes[0];\n\tptr = btrfs_item_ptr(eb, path->slots[0], struct btrfs_dev_stats_item);\n\tfor (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)\n\t\tbtrfs_set_dev_stats_value(eb, ptr, i,\n\t\t\t\t\t  btrfs_dev_stat_read(device, i));\n\tbtrfs_mark_buffer_dirty(eb);\n\nout:\n\tbtrfs_free_path(path);\n\treturn ret;\n}","target":0,"code_token_length":527,"total_token_length":763,"max_tokens_setting":1024}
+{"idx":264252,"func":"static void pointer_event(VncState *vs, int button_mask, int x, int y)\n{\n    static uint32_t bmap[INPUT_BUTTON_MAX] = {\n        [INPUT_BUTTON_LEFT]       = 0x01,\n        [INPUT_BUTTON_MIDDLE]     = 0x02,\n        [INPUT_BUTTON_RIGHT]      = 0x04,\n        [INPUT_BUTTON_WHEEL_UP]   = 0x08,\n        [INPUT_BUTTON_WHEEL_DOWN] = 0x10,\n    };\n    QemuConsole *con = vs->vd->dcl.con;\n    int width = surface_width(vs->vd->ds);\n    int height = surface_height(vs->vd->ds);\n\n    if (vs->last_bmask != button_mask) {\n        qemu_input_update_buttons(con, bmap, vs->last_bmask, button_mask);\n        vs->last_bmask = button_mask;\n    }\n\n    if (vs->absolute) {\n        qemu_input_queue_abs(con, INPUT_AXIS_X, x, width);\n        qemu_input_queue_abs(con, INPUT_AXIS_Y, y, height);\n    } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) {\n        qemu_input_queue_rel(con, INPUT_AXIS_X, x - 0x7FFF);\n        qemu_input_queue_rel(con, INPUT_AXIS_Y, y - 0x7FFF);\n    } else {\n        if (vs->last_x != -1) {\n            qemu_input_queue_rel(con, INPUT_AXIS_X, x - vs->last_x);\n            qemu_input_queue_rel(con, INPUT_AXIS_Y, y - vs->last_y);\n        }\n        vs->last_x = x;\n        vs->last_y = y;\n    }\n    qemu_input_event_sync();\n}","target":0,"code_token_length":368,"total_token_length":604,"max_tokens_setting":1024}
+{"idx":196231,"func":"void TensorSliceReader::LoadShard(int shard) const {\n  CHECK_LT(shard, sss_.size());\n  if (sss_[shard] || !status_.ok()) {\n    return;  \/\/ Already loaded, or invalid.\n  }\n  string value;\n  SavedTensorSlices sts;\n  const string fname = fnames_[shard];\n  VLOG(1) << \"Reading meta data from file \" << fname << \"...\";\n  Table* table;\n  Status s = open_function_(fname, &table);\n  if (!s.ok()) {\n    status_ = errors::DataLoss(\"Unable to open table file \", fname, \": \",\n                               s.ToString());\n    return;\n  }\n  sss_[shard].reset(table);\n  if (!(table->Get(kSavedTensorSlicesKey, &value) &&\n        ParseProtoUnlimited(&sts, value))) {\n    status_ = errors::Internal(\n        \"Failed to find the saved tensor slices at the beginning of the \"\n        \"checkpoint file: \",\n        fname);\n    return;\n  }\n  status_ = CheckVersions(sts.meta().versions(), TF_CHECKPOINT_VERSION,\n                          TF_CHECKPOINT_VERSION_MIN_PRODUCER, \"Checkpoint\",\n                          \"checkpoint\");\n  if (!status_.ok()) return;\n  for (const SavedSliceMeta& ssm : sts.meta().tensor()) {\n    TensorShape ssm_shape(ssm.shape());\n    for (const TensorSliceProto& tsp : ssm.slice()) {\n      TensorSlice ss_slice(tsp);\n      status_ = RegisterTensorSlice(ssm.name(), ssm_shape, ssm.type(), fname,\n                                    ss_slice, &tensors_);\n      if (!status_.ok()) return;\n    }\n  }\n}","target":1,"code_token_length":356,"total_token_length":592,"max_tokens_setting":1024}
+{"idx":430407,"func":"int ovs_nla_get_match(struct net *net, struct sw_flow_match *match,\n\t\t      const struct nlattr *nla_key,\n\t\t      const struct nlattr *nla_mask,\n\t\t      bool log)\n{\n\tconst struct nlattr *a[OVS_KEY_ATTR_MAX + 1];\n\tstruct nlattr *newmask = NULL;\n\tu64 key_attrs = 0;\n\tu64 mask_attrs = 0;\n\tint err;\n\n\terr = parse_flow_nlattrs(nla_key, a, &key_attrs, log);\n\tif (err)\n\t\treturn err;\n\n\terr = parse_vlan_from_nlattrs(match, &key_attrs, a, false, log);\n\tif (err)\n\t\treturn err;\n\n\terr = ovs_key_from_nlattrs(net, match, key_attrs, a, false, log);\n\tif (err)\n\t\treturn err;\n\n\tif (match->mask) {\n\t\tif (!nla_mask) {\n\t\t\t\/* Create an exact match mask. We need to set to 0xff\n\t\t\t * all the 'match->mask' fields that have been touched\n\t\t\t * in 'match->key'. We cannot simply memset\n\t\t\t * 'match->mask', because padding bytes and fields not\n\t\t\t * specified in 'match->key' should be left to 0.\n\t\t\t * Instead, we use a stream of netlink attributes,\n\t\t\t * copied from 'key' and set to 0xff.\n\t\t\t * ovs_key_from_nlattrs() will take care of filling\n\t\t\t * 'match->mask' appropriately.\n\t\t\t *\/\n\t\t\tnewmask = kmemdup(nla_key,\n\t\t\t\t\t  nla_total_size(nla_len(nla_key)),\n\t\t\t\t\t  GFP_KERNEL);\n\t\t\tif (!newmask)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tmask_set_nlattr(newmask, 0xff);\n\n\t\t\t\/* The userspace does not send tunnel attributes that\n\t\t\t * are 0, but we should not wildcard them nonetheless.\n\t\t\t *\/\n\t\t\tif (match->key->tun_proto)\n\t\t\t\tSW_FLOW_KEY_MEMSET_FIELD(match, tun_key,\n\t\t\t\t\t\t\t 0xff, true);\n\n\t\t\tnla_mask = newmask;\n\t\t}\n\n\t\terr = parse_flow_mask_nlattrs(nla_mask, a, &mask_attrs, log);\n\t\tif (err)\n\t\t\tgoto free_newmask;\n\n\t\t\/* Always match on tci. *\/\n\t\tSW_FLOW_KEY_PUT(match, eth.vlan.tci, htons(0xffff), true);\n\t\tSW_FLOW_KEY_PUT(match, eth.cvlan.tci, htons(0xffff), true);\n\n\t\terr = parse_vlan_from_nlattrs(match, &mask_attrs, a, true, log);\n\t\tif (err)\n\t\t\tgoto free_newmask;\n\n\t\terr = ovs_key_from_nlattrs(net, match, mask_attrs, a, true,\n\t\t\t\t\t   log);\n\t\tif (err)\n\t\t\tgoto free_newmask;\n\t}\n\n\tif (!match_validate(match, key_attrs, mask_attrs, log))\n\t\terr = -EINVAL;\n\nfree_newmask:\n\tkfree(newmask);\n\treturn err;\n}","target":0,"code_token_length":619,"total_token_length":855,"max_tokens_setting":1024}
+{"idx":384839,"func":"f_getcwd(typval_T *argvars, typval_T *rettv)\n{\n    win_T\t*wp = NULL;\n    tabpage_T\t*tp = NULL;\n    char_u\t*cwd;\n    int\t\tglobal = FALSE;\n\n    rettv->v_type = VAR_STRING;\n    rettv->vval.v_string = NULL;\n\n    if (in_vim9script()\n\t    && (check_for_opt_number_arg(argvars, 0) == FAIL\n\t\t|| (argvars[0].v_type != VAR_UNKNOWN\n\t\t    && check_for_opt_number_arg(argvars, 1) == FAIL)))\n\treturn;\n\n    if (argvars[0].v_type == VAR_NUMBER\n\t    && argvars[0].vval.v_number == -1\n\t    && argvars[1].v_type == VAR_UNKNOWN)\n\tglobal = TRUE;\n    else\n\twp = find_tabwin(&argvars[0], &argvars[1], &tp);\n\n    if (wp != NULL && wp->w_localdir != NULL\n\t\t\t\t\t   && argvars[0].v_type != VAR_UNKNOWN)\n\trettv->vval.v_string = vim_strsave(wp->w_localdir);\n    else if (tp != NULL && tp->tp_localdir != NULL\n\t\t\t\t\t   && argvars[0].v_type != VAR_UNKNOWN)\n\trettv->vval.v_string = vim_strsave(tp->tp_localdir);\n    else if (wp != NULL || tp != NULL || global)\n    {\n\tif (globaldir != NULL && argvars[0].v_type != VAR_UNKNOWN)\n\t    rettv->vval.v_string = vim_strsave(globaldir);\n\telse\n\t{\n\t    cwd = alloc(MAXPATHL);\n\t    if (cwd != NULL)\n\t    {\n\t\tif (mch_dirname(cwd, MAXPATHL) != FAIL)\n\t\t    rettv->vval.v_string = vim_strsave(cwd);\n\t\tvim_free(cwd);\n\t    }\n\t}\n    }\n#ifdef BACKSLASH_IN_FILENAME\n    if (rettv->vval.v_string != NULL)\n\tslash_adjust(rettv->vval.v_string);\n#endif\n}","target":0,"code_token_length":440,"total_token_length":676,"max_tokens_setting":1024}
+{"idx":473895,"func":"select_str_opcode(int mb_len, OnigDistance str_len, int ignore_case)\n{\n  int op;\n\n  if (ignore_case) {\n    switch (str_len) {\n    case 1:  op = OP_EXACT1_IC; break;\n    default: op = OP_EXACTN_IC; break;\n    }\n  }\n  else {\n    switch (mb_len) {\n    case 1:\n      switch (str_len) {\n      case 1:  op = OP_EXACT1; break;\n      case 2:  op = OP_EXACT2; break;\n      case 3:  op = OP_EXACT3; break;\n      case 4:  op = OP_EXACT4; break;\n      case 5:  op = OP_EXACT5; break;\n      default: op = OP_EXACTN; break;\n      }\n      break;\n\n    case 2:\n      switch (str_len) {\n      case 1:  op = OP_EXACTMB2N1; break;\n      case 2:  op = OP_EXACTMB2N2; break;\n      case 3:  op = OP_EXACTMB2N3; break;\n      default: op = OP_EXACTMB2N;  break;\n      }\n      break;\n\n    case 3:\n      op = OP_EXACTMB3N;\n      break;\n\n    default:\n      op = OP_EXACTMBN;\n      break;\n    }\n  }\n  return op;\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":282865,"func":"int rsi_send_block_unblock_frame(struct rsi_common *common, bool block_event)\n{\n\tstruct rsi_block_unblock_data *mgmt_frame;\n\tstruct sk_buff *skb;\n\n\trsi_dbg(MGMT_TX_ZONE, \"%s: Sending block\/unblock frame\\n\", __func__);\n\n\tskb = dev_alloc_skb(FRAME_DESC_SZ);\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, FRAME_DESC_SZ);\n\tmgmt_frame = (struct rsi_block_unblock_data *)skb->data;\n\n\trsi_set_len_qno(&mgmt_frame->desc_dword0.len_qno, 0, RSI_WIFI_MGMT_Q);\n\tmgmt_frame->desc_dword0.frame_type = BLOCK_HW_QUEUE;\n\tmgmt_frame->host_quiet_info = QUIET_INFO_VALID;\n\n\tif (block_event) {\n\t\trsi_dbg(INFO_ZONE, \"blocking the data qs\\n\");\n\t\tmgmt_frame->block_q_bitmap = cpu_to_le16(0xf);\n\t\tmgmt_frame->block_q_bitmap |= cpu_to_le16(0xf << 4);\n\t} else {\n\t\trsi_dbg(INFO_ZONE, \"unblocking the data qs\\n\");\n\t\tmgmt_frame->unblock_q_bitmap = cpu_to_le16(0xf);\n\t\tmgmt_frame->unblock_q_bitmap |= cpu_to_le16(0xf << 4);\n\t}\n\n\tskb_put(skb, FRAME_DESC_SZ);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":259242,"func":"static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    enum AVAudioServiceType *ast;\n    int ac3info, acmod, lfeon, bsmod;\n    uint64_t mask;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    ast = (enum AVAudioServiceType*)av_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE,\n                                                            sizeof(*ast));\n    if (!ast)\n        return AVERROR(ENOMEM);\n\n    ac3info = avio_rb24(pb);\n    bsmod = (ac3info >> 14) & 0x7;\n    acmod = (ac3info >> 11) & 0x7;\n    lfeon = (ac3info >> 10) & 0x1;\n\n    mask = ff_ac3_channel_layout_tab[acmod];\n    if (lfeon)\n        mask |= AV_CH_LOW_FREQUENCY;\n    av_channel_layout_uninit(&st->codecpar->ch_layout);\n    av_channel_layout_from_mask(&st->codecpar->ch_layout, mask);\n\n    *ast = bsmod;\n    if (st->codecpar->ch_layout.nb_channels > 1 && bsmod == 0x7)\n        *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;\n\n    return 0;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":313749,"func":"nv_gv_cmd(cmdarg_T *cap)\n{\n    pos_T\ttpos;\n    int\t\ti;\n\n    if (checkclearop(cap->oap))\n\treturn;\n\n    if (curbuf->b_visual.vi_start.lnum == 0\n\t    || curbuf->b_visual.vi_start.lnum > curbuf->b_ml.ml_line_count\n\t    || curbuf->b_visual.vi_end.lnum == 0)\n    {\n\tbeep_flush();\n\treturn;\n    }\n\n    \/\/ set w_cursor to the start of the Visual area, tpos to the end\n    if (VIsual_active)\n    {\n\ti = VIsual_mode;\n\tVIsual_mode = curbuf->b_visual.vi_mode;\n\tcurbuf->b_visual.vi_mode = i;\n# ifdef FEAT_EVAL\n\tcurbuf->b_visual_mode_eval = i;\n# endif\n\ti = curwin->w_curswant;\n\tcurwin->w_curswant = curbuf->b_visual.vi_curswant;\n\tcurbuf->b_visual.vi_curswant = i;\n\n\ttpos = curbuf->b_visual.vi_end;\n\tcurbuf->b_visual.vi_end = curwin->w_cursor;\n\tcurwin->w_cursor = curbuf->b_visual.vi_start;\n\tcurbuf->b_visual.vi_start = VIsual;\n    }\n    else\n    {\n\tVIsual_mode = curbuf->b_visual.vi_mode;\n\tcurwin->w_curswant = curbuf->b_visual.vi_curswant;\n\ttpos = curbuf->b_visual.vi_end;\n\tcurwin->w_cursor = curbuf->b_visual.vi_start;\n    }\n\n    VIsual_active = TRUE;\n    VIsual_reselect = TRUE;\n\n    \/\/ Set Visual to the start and w_cursor to the end of the Visual\n    \/\/ area.  Make sure they are on an existing character.\n    check_cursor();\n    VIsual = curwin->w_cursor;\n    curwin->w_cursor = tpos;\n    check_cursor();\n    update_topline();\n\n    \/\/ When called from normal \"g\" command: start Select mode when\n    \/\/ 'selectmode' contains \"cmd\".  When called for K_SELECT, always\n    \/\/ start Select mode.\n    if (cap->arg)\n    {\n\tVIsual_select = TRUE;\n\tVIsual_select_reg = 0;\n    }\n    else\n\tmay_start_select('c');\n    setmouse();\n#ifdef FEAT_CLIPBOARD\n    \/\/ Make sure the clipboard gets updated.  Needed because start and\n    \/\/ end are still the same, and the selection needs to be owned\n    clip_star.vmode = NUL;\n#endif\n    redraw_curbuf_later(INVERTED);\n    showmode();\n}","target":0,"code_token_length":573,"total_token_length":809,"max_tokens_setting":1024}
+{"idx":318104,"func":"static int rsi_usb_read_register_multiple(struct rsi_hw *adapter, u32 addr,\n\t\t\t\t\t  u8 *data, u16 count)\n{\n\tstruct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;\n\tu8 *buf;\n\tu16 transfer;\n\tint status;\n\n\tif (!addr)\n\t\treturn -EINVAL;\n\n\tbuf = kzalloc(RSI_USB_BUF_SIZE, GFP_KERNEL);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\twhile (count) {\n\t\ttransfer = min_t(u16, count, RSI_USB_BUF_SIZE);\n\t\tstatus = usb_control_msg(dev->usbdev,\n\t\t\t\t\t usb_rcvctrlpipe(dev->usbdev, 0),\n\t\t\t\t\t USB_VENDOR_REGISTER_READ,\n\t\t\t\t\t RSI_USB_REQ_IN,\n\t\t\t\t\t ((addr & 0xffff0000) >> 16),\n\t\t\t\t\t (addr & 0xffff), (void *)buf,\n\t\t\t\t\t transfer, USB_CTRL_GET_TIMEOUT);\n\t\tif (status < 0) {\n\t\t\trsi_dbg(ERR_ZONE,\n\t\t\t\t\"Reg read failed with error code :%d\\n\",\n\t\t\t\t status);\n\t\t\tkfree(buf);\n\t\t\treturn status;\n\t\t}\n\t\tmemcpy(data, buf, transfer);\n\t\tcount -= transfer;\n\t\tdata += transfer;\n\t\taddr += transfer;\n\t}\n\tkfree(buf);\n\treturn 0;\n}","target":0,"code_token_length":281,"total_token_length":517,"max_tokens_setting":1024}
+{"idx":486813,"func":"static void gem_receive_updatestats(CadenceGEMState *s, const uint8_t *packet,\n                                    unsigned bytes)\n{\n    uint64_t octets;\n\n    \/* Total octets (bytes) received *\/\n    octets = ((uint64_t)(s->regs[GEM_OCTRXLO]) << 32) |\n             s->regs[GEM_OCTRXHI];\n    octets += bytes;\n    s->regs[GEM_OCTRXLO] = octets >> 32;\n    s->regs[GEM_OCTRXHI] = octets;\n\n    \/* Error-free Frames received *\/\n    s->regs[GEM_RXCNT]++;\n\n    \/* Error-free Broadcast Frames counter *\/\n    if (!memcmp(packet, broadcast_addr, 6)) {\n        s->regs[GEM_RXBROADCNT]++;\n    }\n\n    \/* Error-free Multicast Frames counter *\/\n    if (packet[0] == 0x01) {\n        s->regs[GEM_RXMULTICNT]++;\n    }\n\n    if (bytes <= 64) {\n        s->regs[GEM_RX64CNT]++;\n    } else if (bytes <= 127) {\n        s->regs[GEM_RX65CNT]++;\n    } else if (bytes <= 255) {\n        s->regs[GEM_RX128CNT]++;\n    } else if (bytes <= 511) {\n        s->regs[GEM_RX256CNT]++;\n    } else if (bytes <= 1023) {\n        s->regs[GEM_RX512CNT]++;\n    } else if (bytes <= 1518) {\n        s->regs[GEM_RX1024CNT]++;\n    } else {\n        s->regs[GEM_RX1519CNT]++;\n    }\n}","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":252429,"func":"void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len,\n                                   size_t *pOut_len, int flags) {\n  tinfl_decompressor decomp;\n  void *pBuf = NULL, *pNew_buf;\n  size_t src_buf_ofs = 0, out_buf_capacity = 0;\n  *pOut_len = 0;\n  tinfl_init(&decomp);\n  for (;;) {\n    size_t src_buf_size = src_buf_len - src_buf_ofs,\n           dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;\n    tinfl_status status = tinfl_decompress(\n        &decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size,\n        (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL,\n        &dst_buf_size,\n        (flags & ~TINFL_FLAG_HAS_MORE_INPUT) |\n            TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);\n    if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) {\n      MZ_FREE(pBuf);\n      *pOut_len = 0;\n      return NULL;\n    }\n    src_buf_ofs += src_buf_size;\n    *pOut_len += dst_buf_size;\n    if (status == TINFL_STATUS_DONE) break;\n    new_out_buf_capacity = out_buf_capacity * 2;\n    if (new_out_buf_capacity < 128) new_out_buf_capacity = 128;\n    pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity);\n    if (!pNew_buf) {\n      MZ_FREE(pBuf);\n      *pOut_len = 0;\n      return NULL;\n    }\n    pBuf = pNew_buf;\n    out_buf_capacity = new_out_buf_capacity;\n  }\n  return pBuf;\n}","target":0,"code_token_length":414,"total_token_length":650,"max_tokens_setting":1024}
+{"idx":500054,"func":"static int \tkssl_test_confound(unsigned char *p)\n\t{\n\tint \tlen = 2;\n\tint \txx = 0, yy = 0;\n\n\tif (*p++ != 0x62)  return 0;\n\tif (*p > 0x82)  return 0;\n\tswitch(*p)  {\n\t\tcase 0x82:  p++;          xx = (*p++ << 8);  xx += *p++;  break;\n\t\tcase 0x81:  p++;          xx =  *p++;  break;\n\t\tcase 0x80:  return 0;\n\t\tdefault:    xx = *p++;  break;\n\t\t}\n\tif (*p++ != 0x30)  return 0;\n\tif (*p > 0x82)  return 0;\n\tswitch(*p)  {\n\t\tcase 0x82:  p++; len+=2;  yy = (*p++ << 8);  yy += *p++;  break;\n\t\tcase 0x81:  p++; len++;   yy =  *p++;  break;\n\t\tcase 0x80:  return 0;\n\t\tdefault:    yy = *p++;  break;\n\t\t}\n\n\treturn (xx - len == yy)? 1: 0;\n\t}","target":0,"code_token_length":289,"total_token_length":525,"max_tokens_setting":1024}
+{"idx":223421,"func":"static void check_newlinechar(compiler_common *common, int nltype, jump_list **backtracks, BOOL jumpifmatch)\n{\n\/* Character comes in TMP1. Checks if it is a newline. TMP2 may be destroyed. *\/\nDEFINE_COMPILER;\nstruct sljit_jump *jump;\n\nif (nltype == NLTYPE_ANY)\n  {\n  add_jump(compiler, &common->anynewline, JUMP(SLJIT_FAST_CALL));\n  sljit_set_current_flags(compiler, SLJIT_SET_Z);\n  add_jump(compiler, backtracks, JUMP(jumpifmatch ? SLJIT_NOT_ZERO : SLJIT_ZERO));\n  }\nelse if (nltype == NLTYPE_ANYCRLF)\n  {\n  if (jumpifmatch)\n    {\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR));\n    add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL));\n    }\n  else\n    {\n    jump = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);\n    add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL));\n    JUMPHERE(jump);\n    }\n  }\nelse\n  {\n  SLJIT_ASSERT(nltype == NLTYPE_FIXED && common->newline < 256);\n  add_jump(compiler, backtracks, CMP(jumpifmatch ? SLJIT_EQUAL : SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline));\n  }\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":219029,"func":"bool ConstantFolding::ReduceDivToReciprocalMul(GraphDef* optimized_graph,\n                                               NodeDef* node) {\n  \/\/ Strength reduce floating point division by a constant Div(x, const) to\n  \/\/ multiplication by the reciprocal Mul(x, Reciprocal(const)). This in turn\n  \/\/ will be constant folded to Mul(x, 1.0\/const).\n  if (node->input_size() >= 2 &&\n      (IsDiv(*node) || IsRealDiv(*node) || IsXdivy(*node))) {\n    const string& const_input = node->input(1);\n    const NodeDef* denom = node_map_->GetNode(const_input);\n    CHECK(denom != nullptr);\n    if (!IsReallyConstant(*denom)) {\n      return false;\n    }\n    if (node->attr().count(\"T\") == 0) {\n      return false;\n    }\n    DataType type = node->attr().at(\"T\").type();\n    \/\/ Skip integer division.\n    if (IsDiv(*node) &&\n        !(DataTypeIsFloating(type) || DataTypeIsComplex(type))) {\n      return false;\n    }\n    \/\/ Insert new reciprocal op and change node from Div to Mul.\n    NodeDef* reciprocal_node = optimized_graph->add_node();\n    reciprocal_node->set_name(OptimizedNodeName(*node, \"_recip\"));\n    reciprocal_node->set_op(\"Reciprocal\");\n    reciprocal_node->set_device(node->device());\n    reciprocal_node->add_input(const_input);\n    (*reciprocal_node->mutable_attr())[\"T\"].set_type(type);\n\n    \/\/ Re-wire inputs and outputs.\n    if (IsXdivy(*node)) {\n      node->set_op(\"MulNoNan\");\n      node->set_input(1, node->input(0));\n      node->set_input(0, reciprocal_node->name());\n    } else {\n      node->set_op(\"Mul\");\n      node->set_input(1, reciprocal_node->name());\n    }\n    node_map_->AddNode(reciprocal_node->name(), reciprocal_node);\n    node_map_->UpdateOutput(node->name(), const_input, reciprocal_node->name());\n\n    return true;\n  }\n\n  return false;\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":355638,"func":"eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)\n{\n    char_u\t*p;\n    int\t\tgetnext;\n\n    \/*\n     * Get the first variable.\n     *\/\n    if (eval3(arg, rettv, evalarg) == FAIL)\n\treturn FAIL;\n\n    \/*\n     * Handle the  \"||\" operator.\n     *\/\n    p = eval_next_non_blank(*arg, evalarg, &getnext);\n    if (p[0] == '|' && p[1] == '|')\n    {\n\tevalarg_T   *evalarg_used = evalarg;\n\tevalarg_T   local_evalarg;\n\tint\t    evaluate;\n\tint\t    orig_flags;\n\tlong\t    result = FALSE;\n\ttypval_T    var2;\n\tint\t    error = FALSE;\n\tint\t    vim9script = in_vim9script();\n\n\tif (evalarg == NULL)\n\t{\n\t    init_evalarg(&local_evalarg);\n\t    evalarg_used = &local_evalarg;\n\t}\n\torig_flags = evalarg_used->eval_flags;\n\tevaluate = orig_flags & EVAL_EVALUATE;\n\tif (evaluate)\n\t{\n\t    if (vim9script)\n\t\tresult = tv_get_bool_chk(rettv, &error);\n\t    else if (tv_get_number_chk(rettv, &error) != 0)\n\t\tresult = TRUE;\n\t    clear_tv(rettv);\n\t    if (error)\n\t\treturn FAIL;\n\t}\n\n\t\/*\n\t * Repeat until there is no following \"||\".\n\t *\/\n\twhile (p[0] == '|' && p[1] == '|')\n\t{\n\t    if (getnext)\n\t\t*arg = eval_next_line(evalarg_used);\n\t    else\n\t    {\n\t\tif (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))\n\t\t{\n\t\t    error_white_both(p, 2);\n\t\t    clear_tv(rettv);\n\t\t    return FAIL;\n\t\t}\n\t\t*arg = p;\n\t    }\n\n\t    \/*\n\t     * Get the second variable.\n\t     *\/\n\t    if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))\n\t    {\n\t\terror_white_both(*arg, 2);\n\t\tclear_tv(rettv);\n\t\treturn FAIL;\n\t    }\n\t    *arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);\n\t    evalarg_used->eval_flags = !result ? orig_flags\n\t\t\t\t\t\t : orig_flags & ~EVAL_EVALUATE;\n\t    if (eval3(arg, &var2, evalarg_used) == FAIL)\n\t\treturn FAIL;\n\n\t    \/*\n\t     * Compute the result.\n\t     *\/\n\t    if (evaluate && !result)\n\t    {\n\t\tif (vim9script)\n\t\t    result = tv_get_bool_chk(&var2, &error);\n\t\telse if (tv_get_number_chk(&var2, &error) != 0)\n\t\t    result = TRUE;\n\t\tclear_tv(&var2);\n\t\tif (error)\n\t\t    return FAIL;\n\t    }\n\t    if (evaluate)\n\t    {\n\t\tif (vim9script)\n\t\t{\n\t\t    rettv->v_type = VAR_BOOL;\n\t\t    rettv->vval.v_number = result ? VVAL_TRUE : VVAL_FALSE;\n\t\t}\n\t\telse\n\t\t{\n\t\t    rettv->v_type = VAR_NUMBER;\n\t\t    rettv->vval.v_number = result;\n\t\t}\n\t    }\n\n\t    p = eval_next_non_blank(*arg, evalarg_used, &getnext);\n\t}\n\n\tif (evalarg == NULL)\n\t    clear_evalarg(&local_evalarg, NULL);\n\telse\n\t    evalarg->eval_flags = orig_flags;\n    }\n\n    return OK;\n}","target":0,"code_token_length":749,"total_token_length":985,"max_tokens_setting":1024}
+{"idx":413665,"func":"static int fcn_list_table(RCore *core, const char *q, int fmt) {\n\tchar xref[128], ccstr[128], castr[128];\n\tRAnalFunction *fcn;\n\tRListIter *iter;\n\tRTable *t = r_core_table (core, \"fcns\");\n\tRTableColumnType *typeString = r_table_type (\"string\");\n\tRTableColumnType *typeNumber = r_table_type (\"number\");\n\tr_table_add_column (t, typeNumber, \"addr\", 0);\n\tr_table_add_column (t, typeNumber, \"size\", 0);\n\tr_table_add_column (t, typeString, \"name\", 0);\n\tr_table_add_column (t, typeNumber, \"nbbs\", 0);\n\tr_table_add_column (t, typeNumber, \"xref\", 0);\n\tr_table_add_column (t, typeNumber, \"calls\", 0);\n\tr_table_add_column (t, typeNumber, \"cc\", 0);\n\tr_list_foreach (core->anal->fcns, iter, fcn) {\n\t\tr_strf_var (fcnAddr, 32, \"0x%08\"PFMT64x, fcn->addr);\n\t\tr_strf_var (fcnSize, 32, \"%\"PFMT64u, r_anal_function_linear_size (fcn)); \/\/ r_anal_function_size (fcn));\n\t\tr_strf_var (nbbs, 32, \"%d\", r_list_length (fcn->bbs));\n\t\tRList *xrefs = r_anal_function_get_xrefs (fcn);\n\t\tsnprintf (xref, sizeof (xref), \"%d\", r_list_length (xrefs));\n\t\tr_list_free (xrefs);\n\n\t\tRList *calls = r_core_anal_fcn_get_calls (core, fcn);\n\t\tr_list_uniq_inplace (calls, (RListComparatorItem)RAnalRef_val);\n\t\tsnprintf (castr, sizeof (castr), \"%d\", r_list_length (calls));\n\t\tr_list_free (calls);\n\t\tsnprintf (ccstr, sizeof (ccstr), \"%d\", r_anal_function_complexity (fcn));\n\n\t\tr_table_add_row (t, fcnAddr, fcnSize, fcn->name, nbbs, xref, castr, ccstr, NULL);\n\t}\n\tif (r_table_query (t, q)) {\n\t\tchar *s = (fmt == 'j')\n\t\t\t? r_table_tojson (t)\n\t\t\t: r_table_tostring (t);\n\t\tr_cons_printf (\"%s\\n\", s);\n\t\tfree (s);\n\t}\n\tr_table_free (t);\n\treturn 0;\n}","target":0,"code_token_length":565,"total_token_length":801,"max_tokens_setting":1024}
+{"idx":244176,"func":"GF_Err ctts_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tu32 sampleCount;\n\tGF_CompositionOffsetBox *ptr = (GF_CompositionOffsetBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->nb_entries = gf_bs_read_u32(bs);\n\n\tif (ptr->nb_entries > ptr->size \/ 8 || (u64)ptr->nb_entries > (u64)SIZE_MAX\/sizeof(GF_DttsEntry) ) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of entries %d in ctts\\n\", ptr->nb_entries));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tptr->alloc_size = ptr->nb_entries;\n\tptr->entries = (GF_DttsEntry *)gf_malloc(sizeof(GF_DttsEntry)*ptr->alloc_size);\n\tif (!ptr->entries) return GF_OUT_OF_MEM;\n\tsampleCount = 0;\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->entries[i].sampleCount = gf_bs_read_u32(bs);\n\t\tif (ptr->version)\n\t\t\tptr->entries[i].decodingOffset = gf_bs_read_int(bs, 32);\n\t\telse\n\t\t\tptr->entries[i].decodingOffset = (s32) gf_bs_read_u32(bs);\n\n\t\tif (ptr->max_cts_delta <= ABS(ptr->entries[i].decodingOffset)) {\n\t\t\tptr->max_cts_delta = ABS(ptr->entries[i].decodingOffset);\n\t\t\t\/\/ptr->sample_num_max_cts_delta = sampleCount;\n\t\t}\n\t\tsampleCount += ptr->entries[i].sampleCount;\n\t}\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\tptr->w_LastSampleNumber = sampleCount;\n#endif\n\treturn GF_OK;\n}","target":0,"code_token_length":409,"total_token_length":645,"max_tokens_setting":1024}
+{"idx":443706,"func":"init(void)\n{\n#ifdef USE_CALLOUT\n\n    int id;\n    OnigEncoding enc;\n    char* name;\n    unsigned int args[4];\n    OnigValue opts[4];\n\n    enc = ONIG_ENCODING_UTF16_BE;\n\n    name = \"\\000F\\000A\\000I\\000L\\000\\000\";            BC0_P(name, fail);\n    name = \"\\000M\\000I\\000S\\000M\\000A\\000T\\000C\\000H\\000\\000\"; BC0_P(name, mismatch);\n\n    name = \"\\000M\\000A\\000X\\000\\000\";\n    args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\n    args[1] = ONIG_TYPE_CHAR;\n    opts[0].c = 'X';\n    BC_B_O(name, max, 2, args, 1, opts);\n\n    name = \"\\000E\\000R\\000R\\000O\\000R\\000\\000\";\n    args[0] = ONIG_TYPE_LONG; opts[0].l = ONIG_ABORT;\n    BC_P_O(name, error, 1, args, 1, opts);\n\n    name = \"\\000C\\000O\\000U\\000N\\000T\\000\\000\";\n    args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';\n    BC_B_O(name, count, 1, args, 1, opts);\n\n    name = \"\\000T\\000O\\000T\\000A\\000L\\000_\\000C\\000O\\000U\\000N\\000T\\000\\000\";\n    args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';\n    BC_B_O(name, total_count, 1, args, 1, opts);\n\n    name = \"\\000C\\000M\\000P\\000\\000\";\n    args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\n    args[1] = ONIG_TYPE_STRING;\n    args[2] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\n    BC_P(name, cmp, 3, args);\n\n#endif \/* USE_CALLOUT *\/\n\n  return ONIG_NORMAL;\n}","target":0,"code_token_length":582,"total_token_length":818,"max_tokens_setting":1024}
+{"idx":361296,"func":"stl_change_vertices(stl_file *stl, int facet_num, int vnot,\n                    stl_vertex new_vertex) {\n  int first_facet;\n  int direction;\n  int next_edge;\n  int pivot_vertex;\n\n  if (stl->error) return;\n\n  first_facet = facet_num;\n  direction = 0;\n\n  for(;;) {\n    if(vnot > 2) {\n      if(direction == 0) {\n        pivot_vertex = (vnot + 2) % 3;\n        next_edge = pivot_vertex;\n        direction = 1;\n      } else {\n        pivot_vertex = (vnot + 1) % 3;\n        next_edge = vnot % 3;\n        direction = 0;\n      }\n    } else {\n      if(direction == 0) {\n        pivot_vertex = (vnot + 1) % 3;\n        next_edge = vnot;\n      } else {\n        pivot_vertex = (vnot + 2) % 3;\n        next_edge = pivot_vertex;\n      }\n    }\n    stl->facet_start[facet_num].vertex[pivot_vertex] = new_vertex;\n    vnot = stl->neighbors_start[facet_num].which_vertex_not[next_edge];\n    facet_num = stl->neighbors_start[facet_num].neighbor[next_edge];\n\n    if(facet_num == -1) {\n      break;\n    }\n\n    if(facet_num == first_facet) {\n      \/* back to the beginning *\/\n      printf(\"\\\nBack to the first facet changing vertices: probably a mobius part.\\n\\\nTry using a smaller tolerance or don't do a nearby check\\n\");\n      return;\n    }\n  }\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":513120,"func":"bool mysql_install_plugin(THD *thd, const LEX_STRING *name,\n                          const LEX_STRING *dl_arg)\n{\n  TABLE_LIST tables;\n  TABLE *table;\n  LEX_STRING dl= *dl_arg;\n  bool error;\n  int argc=orig_argc;\n  char **argv=orig_argv;\n  unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =\n  { MYSQL_AUDIT_GENERAL_CLASSMASK };\n  DBUG_ENTER(\"mysql_install_plugin\");\n\n  tables.init_one_table(\"mysql\", 5, \"plugin\", 6, \"plugin\", TL_WRITE);\n  if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE))\n    DBUG_RETURN(TRUE);\n  WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);\n\n  \/* need to open before acquiring LOCK_plugin or it will deadlock *\/\n  if (! (table = open_ltable(thd, &tables, TL_WRITE,\n                             MYSQL_LOCK_IGNORE_TIMEOUT)))\n    DBUG_RETURN(TRUE);\n\n  if (my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL))\n  {\n    report_error(REPORT_TO_USER, ER_PLUGIN_IS_NOT_LOADED, name->str);\n    DBUG_RETURN(TRUE);\n  }\n\n  \/*\n    Pre-acquire audit plugins for events that may potentially occur\n    during [UN]INSTALL PLUGIN.\n\n    When audit event is triggered, audit subsystem acquires interested\n    plugins by walking through plugin list. Evidently plugin list\n    iterator protects plugin list by acquiring LOCK_plugin, see\n    plugin_foreach_with_mask().\n\n    On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin\n    rather for a long time.\n\n    When audit event is triggered during [UN]INSTALL PLUGIN, plugin\n    list iterator acquires the same lock (within the same thread)\n    second time.\n\n    This hack should be removed when LOCK_plugin is fixed so it\n    protects only what it supposed to protect.\n\n    See also mysql_uninstall_plugin() and initialize_audit_plugin()\n  *\/\n  if (mysql_audit_general_enabled())\n    mysql_audit_acquire_plugins(thd, event_class_mask);\n\n  mysql_mutex_lock(&LOCK_plugin);\n  error= plugin_add(thd->mem_root, name, &dl, REPORT_TO_USER);\n  if (error)\n    goto err;\n\n  if (name->str)\n    error= finalize_install(thd, table, name, &argc, argv);\n  else\n  {\n    st_plugin_dl *plugin_dl= plugin_dl_find(&dl);\n    struct st_maria_plugin *plugin;\n    for (plugin= plugin_dl->plugins; plugin->info; plugin++)\n    {\n      LEX_STRING str= { const_cast<char*>(plugin->name), strlen(plugin->name) };\n      error|= finalize_install(thd, table, &str, &argc, argv);\n    }\n  }\n\n  if (error)\n  {\n    reap_needed= true;\n    reap_plugins();\n  }\nerr:\n  global_plugin_version++;\n  mysql_mutex_unlock(&LOCK_plugin);\n  if (argv)\n    free_defaults(argv);\n  DBUG_RETURN(error);\n\nWSREP_ERROR_LABEL:\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":665,"total_token_length":901,"max_tokens_setting":1024}
+{"idx":436097,"func":"\nstatic bool io_drain_req(struct io_kiocb *req)\n{\n\tstruct io_kiocb *pos;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct io_defer_entry *de;\n\tint ret;\n\tu32 seq;\n\n\t\/*\n\t * If we need to drain a request in the middle of a link, drain the\n\t * head request and the next request\/link after the current link.\n\t * Considering sequential execution of links, IOSQE_IO_DRAIN will be\n\t * maintained for every request of our link.\n\t *\/\n\tif (ctx->drain_next) {\n\t\treq->flags |= REQ_F_IO_DRAIN;\n\t\tctx->drain_next = false;\n\t}\n\t\/* not interested in head, start from the first linked *\/\n\tio_for_each_link(pos, req->link) {\n\t\tif (pos->flags & REQ_F_IO_DRAIN) {\n\t\t\tctx->drain_next = true;\n\t\t\treq->flags |= REQ_F_IO_DRAIN;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t\/* Still need defer if there is pending req in defer list. *\/\n\tif (likely(list_empty_careful(&ctx->defer_list) &&\n\t\t!(req->flags & REQ_F_IO_DRAIN))) {\n\t\tctx->drain_active = false;\n\t\treturn false;\n\t}\n\n\tseq = io_get_sequence(req);\n\t\/* Still a chance to pass the sequence check *\/\n\tif (!req_need_defer(req, seq) && list_empty_careful(&ctx->defer_list))\n\t\treturn false;\n\n\tret = io_req_prep_async(req);\n\tif (ret)\n\t\treturn ret;\n\tio_prep_async_link(req);\n\tde = kmalloc(sizeof(*de), GFP_KERNEL);\n\tif (!de) {\n\t\tio_req_complete_failed(req, -ENOMEM);\n\t\treturn true;\n\t}\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tif (!req_need_defer(req, seq) && list_empty(&ctx->defer_list)) {\n\t\tspin_unlock_irq(&ctx->completion_lock);\n\t\tkfree(de);\n\t\tio_queue_async_work(req);\n\t\treturn true;\n\t}\n\n\ttrace_io_uring_defer(ctx, req, req->user_data);\n\tde->req = req;\n\tde->seq = seq;\n\tlist_add_tail(&de->list, &ctx->defer_list);\n\tspin_unlock_irq(&ctx->completion_lock);\n\treturn true;","target":0,"code_token_length":477,"total_token_length":713,"max_tokens_setting":1024}
+{"idx":202889,"func":"int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)\n{\n\tu8 *tail;\n\tint nfrags;\n\tint esph_offset;\n\tstruct page *page;\n\tstruct sk_buff *trailer;\n\tint tailen = esp->tailen;\n\n\tif (x->encap) {\n\t\tint err = esp6_output_encap(x, skb, esp);\n\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\tif (!skb_cloned(skb)) {\n\t\tif (tailen <= skb_tailroom(skb)) {\n\t\t\tnfrags = 1;\n\t\t\ttrailer = skb;\n\t\t\ttail = skb_tail_pointer(trailer);\n\n\t\t\tgoto skip_cow;\n\t\t} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)\n\t\t\t   && !skb_has_frag_list(skb)) {\n\t\t\tint allocsize;\n\t\t\tstruct sock *sk = skb->sk;\n\t\t\tstruct page_frag *pfrag = &x->xfrag;\n\n\t\t\tesp->inplace = false;\n\n\t\t\tallocsize = ALIGN(tailen, L1_CACHE_BYTES);\n\n\t\t\tspin_lock_bh(&x->lock);\n\n\t\t\tif (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {\n\t\t\t\tspin_unlock_bh(&x->lock);\n\t\t\t\tgoto cow;\n\t\t\t}\n\n\t\t\tpage = pfrag->page;\n\t\t\tget_page(page);\n\n\t\t\ttail = page_address(page) + pfrag->offset;\n\n\t\t\tesp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);\n\n\t\t\tnfrags = skb_shinfo(skb)->nr_frags;\n\n\t\t\t__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,\n\t\t\t\t\t     tailen);\n\t\t\tskb_shinfo(skb)->nr_frags = ++nfrags;\n\n\t\t\tpfrag->offset = pfrag->offset + allocsize;\n\n\t\t\tspin_unlock_bh(&x->lock);\n\n\t\t\tnfrags++;\n\n\t\t\tskb->len += tailen;\n\t\t\tskb->data_len += tailen;\n\t\t\tskb->truesize += tailen;\n\t\t\tif (sk && sk_fullsock(sk))\n\t\t\t\trefcount_add(tailen, &sk->sk_wmem_alloc);\n\n\t\t\tgoto out;\n\t\t}\n\t}\n\ncow:\n\tesph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);\n\n\tnfrags = skb_cow_data(skb, tailen, &trailer);\n\tif (nfrags < 0)\n\t\tgoto out;\n\ttail = skb_tail_pointer(trailer);\n\tesp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);\n\nskip_cow:\n\tesp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);\n\tpskb_put(skb, trailer, tailen);\n\nout:\n\treturn nfrags;\n}","target":1,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":441828,"func":"SProcXkbDispatch(ClientPtr client)\n{\n    REQUEST(xReq);\n    switch (stuff->data) {\n    case X_kbUseExtension:\n        return SProcXkbUseExtension(client);\n    case X_kbSelectEvents:\n        return SProcXkbSelectEvents(client);\n    case X_kbBell:\n        return SProcXkbBell(client);\n    case X_kbGetState:\n        return SProcXkbGetState(client);\n    case X_kbLatchLockState:\n        return SProcXkbLatchLockState(client);\n    case X_kbGetControls:\n        return SProcXkbGetControls(client);\n    case X_kbSetControls:\n        return SProcXkbSetControls(client);\n    case X_kbGetMap:\n        return SProcXkbGetMap(client);\n    case X_kbSetMap:\n        return SProcXkbSetMap(client);\n    case X_kbGetCompatMap:\n        return SProcXkbGetCompatMap(client);\n    case X_kbSetCompatMap:\n        return SProcXkbSetCompatMap(client);\n    case X_kbGetIndicatorState:\n        return SProcXkbGetIndicatorState(client);\n    case X_kbGetIndicatorMap:\n        return SProcXkbGetIndicatorMap(client);\n    case X_kbSetIndicatorMap:\n        return SProcXkbSetIndicatorMap(client);\n    case X_kbGetNamedIndicator:\n        return SProcXkbGetNamedIndicator(client);\n    case X_kbSetNamedIndicator:\n        return SProcXkbSetNamedIndicator(client);\n    case X_kbGetNames:\n        return SProcXkbGetNames(client);\n    case X_kbSetNames:\n        return SProcXkbSetNames(client);\n    case X_kbGetGeometry:\n        return SProcXkbGetGeometry(client);\n    case X_kbSetGeometry:\n        return SProcXkbSetGeometry(client);\n    case X_kbPerClientFlags:\n        return SProcXkbPerClientFlags(client);\n    case X_kbListComponents:\n        return SProcXkbListComponents(client);\n    case X_kbGetKbdByName:\n        return SProcXkbGetKbdByName(client);\n    case X_kbGetDeviceInfo:\n        return SProcXkbGetDeviceInfo(client);\n    case X_kbSetDeviceInfo:\n        return SProcXkbSetDeviceInfo(client);\n    case X_kbSetDebuggingFlags:\n        return SProcXkbSetDebuggingFlags(client);\n    default:\n        return BadRequest;\n    }\n}","target":0,"code_token_length":499,"total_token_length":735,"max_tokens_setting":1024}
+{"idx":437309,"func":"alt_merge_opt_exact(OptExact* to, OptExact* add, OptEnv* env)\n{\n  int i, j, len;\n\n  if (add->len == 0 || to->len == 0) {\n    clear_opt_exact(to);\n    return ;\n  }\n\n  if (! is_equal_mml(&to->mmd, &add->mmd)) {\n    clear_opt_exact(to);\n    return ;\n  }\n\n  for (i = 0; i < to->len && i < add->len; ) {\n    if (to->s[i] != add->s[i]) break;\n    len = enclen(env->enc, to->s + i);\n\n    for (j = 1; j < len; j++) {\n      if (to->s[i+j] != add->s[i+j]) break;\n    }\n    if (j < len) break;\n    i += len;\n  }\n\n  if (! add->reach_end || i < add->len || i < to->len) {\n    to->reach_end = 0;\n  }\n  to->len = i;\n  to->ignore_case |= add->ignore_case;\n\n  alt_merge_opt_anc_info(&to->anc, &add->anc);\n  if (! to->reach_end) to->anc.right = 0;\n}","target":0,"code_token_length":278,"total_token_length":514,"max_tokens_setting":1024}
+{"idx":349872,"func":"static int aq_fw1x_set_wake_magic(struct aq_hw_s *self, bool wol_enabled,\n\t\t\t\t  const u8 *mac)\n{\n\tstruct hw_atl_utils_fw_rpc *prpc = NULL;\n\tunsigned int rpc_size = 0U;\n\tint err = 0;\n\n\terr = hw_atl_utils_fw_rpc_wait(self, &prpc);\n\tif (err < 0)\n\t\tgoto err_exit;\n\n\tmemset(prpc, 0, sizeof(*prpc));\n\n\tif (wol_enabled) {\n\t\trpc_size = offsetof(struct hw_atl_utils_fw_rpc, msg_wol_add) +\n\t\t\t   sizeof(prpc->msg_wol_add);\n\n\n\t\tprpc->msg_id = HAL_ATLANTIC_UTILS_FW_MSG_WOL_ADD;\n\t\tprpc->msg_wol_add.priority =\n\t\t\t\tHAL_ATLANTIC_UTILS_FW_MSG_WOL_PRIOR;\n\t\tprpc->msg_wol_add.pattern_id =\n\t\t\t\tHAL_ATLANTIC_UTILS_FW_MSG_WOL_PATTERN;\n\t\tprpc->msg_wol_add.packet_type =\n\t\t\t\tHAL_ATLANTIC_UTILS_FW_MSG_WOL_MAG_PKT;\n\n\t\tether_addr_copy((u8 *)&prpc->msg_wol_add.magic_packet_pattern,\n\t\t\t\tmac);\n\t} else {\n\t\trpc_size = sizeof(prpc->msg_wol_remove) +\n\t\t\t   offsetof(struct hw_atl_utils_fw_rpc, msg_wol_remove);\n\n\t\tprpc->msg_id = HAL_ATLANTIC_UTILS_FW_MSG_WOL_DEL;\n\t\tprpc->msg_wol_add.pattern_id =\n\t\t\t\tHAL_ATLANTIC_UTILS_FW_MSG_WOL_PATTERN;\n\t}\n\n\terr = hw_atl_utils_fw_rpc_call(self, rpc_size);\n\nerr_exit:\n\treturn err;\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":225019,"func":"connectDBComplete(PGconn *conn)\n{\n\tPostgresPollingStatusType flag = PGRES_POLLING_WRITING;\n\ttime_t\t\tfinish_time = ((time_t) -1);\n\tint\t\t\ttimeout = 0;\n\tint\t\t\tlast_whichhost = -2;\t\/* certainly different from whichhost *\/\n\tstruct addrinfo *last_addr_cur = NULL;\n\n\tif (conn == NULL || conn->status == CONNECTION_BAD)\n\t\treturn 0;\n\n\t\/*\n\t * Set up a time limit, if connect_timeout isn't zero.\n\t *\/\n\tif (conn->connect_timeout != NULL)\n\t{\n\t\tif (!parse_int_param(conn->connect_timeout, &timeout, conn,\n\t\t\t\t\t\t\t \"connect_timeout\"))\n\t\t{\n\t\t\t\/* mark the connection as bad to report the parsing failure *\/\n\t\t\tconn->status = CONNECTION_BAD;\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (timeout > 0)\n\t\t{\n\t\t\t\/*\n\t\t\t * Rounding could cause connection to fail unexpectedly quickly;\n\t\t\t * to prevent possibly waiting hardly-at-all, insist on at least\n\t\t\t * two seconds.\n\t\t\t *\/\n\t\t\tif (timeout < 2)\n\t\t\t\ttimeout = 2;\n\t\t}\n\t\telse\t\t\t\t\t\/* negative means 0 *\/\n\t\t\ttimeout = 0;\n\t}\n\n\tfor (;;)\n\t{\n\t\tint\t\t\tret = 0;\n\n\t\t\/*\n\t\t * (Re)start the connect_timeout timer if it's active and we are\n\t\t * considering a different host than we were last time through.  If\n\t\t * we've already succeeded, though, needn't recalculate.\n\t\t *\/\n\t\tif (flag != PGRES_POLLING_OK &&\n\t\t\ttimeout > 0 &&\n\t\t\t(conn->whichhost != last_whichhost ||\n\t\t\t conn->addr_cur != last_addr_cur))\n\t\t{\n\t\t\tfinish_time = time(NULL) + timeout;\n\t\t\tlast_whichhost = conn->whichhost;\n\t\t\tlast_addr_cur = conn->addr_cur;\n\t\t}\n\n\t\t\/*\n\t\t * Wait, if necessary.  Note that the initial state (just after\n\t\t * PQconnectStart) is to wait for the socket to select for writing.\n\t\t *\/\n\t\tswitch (flag)\n\t\t{\n\t\t\tcase PGRES_POLLING_OK:\n\t\t\t\treturn 1;\t\t\/* success! *\/\n\n\t\t\tcase PGRES_POLLING_READING:\n\t\t\t\tret = pqWaitTimed(1, 0, conn, finish_time);\n\t\t\t\tif (ret == -1)\n\t\t\t\t{\n\t\t\t\t\t\/* hard failure, eg select() problem, aborts everything *\/\n\t\t\t\t\tconn->status = CONNECTION_BAD;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase PGRES_POLLING_WRITING:\n\t\t\t\tret = pqWaitTimed(0, 1, conn, finish_time);\n\t\t\t\tif (ret == -1)\n\t\t\t\t{\n\t\t\t\t\t\/* hard failure, eg select() problem, aborts everything *\/\n\t\t\t\t\tconn->status = CONNECTION_BAD;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t\/* Just in case we failed to set it in PQconnectPoll *\/\n\t\t\t\tconn->status = CONNECTION_BAD;\n\t\t\t\treturn 0;\n\t\t}\n\n\t\tif (ret == 1)\t\t\t\/* connect_timeout elapsed *\/\n\t\t{\n\t\t\t\/*\n\t\t\t * Give up on current server\/address, try the next one.\n\t\t\t *\/\n\t\t\tconn->try_next_addr = true;\n\t\t\tconn->status = CONNECTION_NEEDED;\n\t\t}\n\n\t\t\/*\n\t\t * Now try to advance the state machine.\n\t\t *\/\n\t\tflag = PQconnectPoll(conn);\n\t}\n}","target":0,"code_token_length":735,"total_token_length":971,"max_tokens_setting":1024}
+{"idx":196860,"func":"GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tunsigned int i;\n\tGF_AdobeFragRandomAccessBox *ptr = (GF_AdobeFragRandomAccessBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 9)\n\tptr->long_ids = gf_bs_read_int(bs, 1);\n\tptr->long_offsets = gf_bs_read_int(bs, 1);\n\tptr->global_entries = gf_bs_read_int(bs, 1);\n\tptr->reserved = gf_bs_read_int(bs, 5);\n\tptr->time_scale = gf_bs_read_u32(bs);\n\n\tptr->entry_count = gf_bs_read_u32(bs);\n\tif (ptr->size \/ ( (ptr->long_offsets ? 16 : 12) ) < ptr->entry_count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tfor (i=0; i<ptr->entry_count; i++) {\n\t\tGF_AfraEntry *ae = gf_malloc(sizeof(GF_AfraEntry));\n\t\tif (!ae) return GF_OUT_OF_MEM;\n\n\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\tae->time = gf_bs_read_u64(bs);\n\t\tif (ptr->long_offsets) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\tae->offset = gf_bs_read_u64(bs);\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\tae->offset = gf_bs_read_u32(bs);\n\t\t}\n\n\t\tgf_list_insert(ptr->local_access_entries, ae, i);\n\t}\n\n\tif (ptr->global_entries) {\n\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\tptr->global_entry_count = gf_bs_read_u32(bs);\n\t\tfor (i=0; i<ptr->global_entry_count; i++) {\n\t\t\tGF_GlobalAfraEntry *ae = gf_malloc(sizeof(GF_GlobalAfraEntry));\n\t\t\tif (!ae) return GF_OUT_OF_MEM;\n\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\tae->time = gf_bs_read_u64(bs);\n\t\t\tif (ptr->long_ids) {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\t\tae->segment = gf_bs_read_u32(bs);\n\t\t\t\tae->fragment = gf_bs_read_u32(bs);\n\t\t\t} else {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\t\tae->segment = gf_bs_read_u16(bs);\n\t\t\t\tae->fragment = gf_bs_read_u16(bs);\n\t\t\t}\n\t\t\tif (ptr->long_offsets) {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 16)\n\t\t\t\tae->afra_offset = gf_bs_read_u64(bs);\n\t\t\t\tae->offset_from_afra = gf_bs_read_u64(bs);\n\t\t\t} else {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\t\t\tae->afra_offset = gf_bs_read_u32(bs);\n\t\t\t\tae->offset_from_afra = gf_bs_read_u32(bs);\n\t\t\t}\n\n\t\t\tgf_list_insert(ptr->global_access_entries, ae, i);\n\t\t}\n\t}\n\n\treturn GF_OK;\n}","target":1,"code_token_length":673,"total_token_length":909,"max_tokens_setting":1024}
+{"idx":276907,"func":"static int do_i2c_write(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t\tchar *const argv[])\n{\n\tuint\tchip;\n\tuint\tdevaddr, length;\n\tuint\talen;\n\tu_char  *memaddr;\n\tint ret;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *dev;\n\tstruct dm_i2c_chip *i2c_chip;\n#endif\n\n\tif ((argc < 5) || (argc > 6))\n\t\treturn cmd_usage(cmdtp);\n\n\t\/*\n\t * memaddr is the address where to store things in memory\n\t *\/\n\tmemaddr = (u_char *)hextoul(argv[1], NULL);\n\n\t\/*\n\t * I2C chip address\n\t *\/\n\tchip = hextoul(argv[2], NULL);\n\n\t\/*\n\t * I2C data address within the chip.  This can be 1 or\n\t * 2 bytes long.  Some day it might be 3 bytes long :-).\n\t *\/\n\tdevaddr = hextoul(argv[3], NULL);\n\talen = get_alen(argv[3], DEFAULT_ADDR_LEN);\n\tif (alen > 3)\n\t\treturn cmd_usage(cmdtp);\n\n\t\/*\n\t * Length is the number of bytes.\n\t *\/\n\tlength = hextoul(argv[4], NULL);\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (!ret && alen != -1)\n\t\tret = i2c_set_chip_offset_len(dev, alen);\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_WRITE);\n\ti2c_chip = dev_get_parent_plat(dev);\n\tif (!i2c_chip)\n\t\treturn i2c_report_err(ret, I2C_ERR_WRITE);\n#endif\n\n\tif (argc == 6 && !strcmp(argv[5], \"-s\")) {\n\t\t\/*\n\t\t * Write all bytes in a single I2C transaction. If the target\n\t\t * device is an EEPROM, it is your responsibility to not cross\n\t\t * a page boundary. No write delay upon completion, take this\n\t\t * into account if linking commands.\n\t\t *\/\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\ti2c_chip->flags &= ~DM_I2C_CHIP_WR_ADDRESS;\n\t\tret = dm_i2c_write(dev, devaddr, memaddr, length);\n#else\n\t\tret = i2c_write(chip, devaddr, alen, memaddr, length);\n#endif\n\t\tif (ret)\n\t\t\treturn i2c_report_err(ret, I2C_ERR_WRITE);\n\t} else {\n\t\t\/*\n\t\t * Repeated addressing - perform <length> separate\n\t\t * write transactions of one byte each\n\t\t *\/\n\t\twhile (length-- > 0) {\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\t\ti2c_chip->flags |= DM_I2C_CHIP_WR_ADDRESS;\n\t\t\tret = dm_i2c_write(dev, devaddr++, memaddr++, 1);\n#else\n\t\t\tret = i2c_write(chip, devaddr++, alen, memaddr++, 1);\n#endif\n\t\t\tif (ret)\n\t\t\t\treturn i2c_report_err(ret, I2C_ERR_WRITE);\n\/*\n * No write delay with FRAM devices.\n *\/\n#if !defined(CONFIG_SYS_I2C_FRAM)\n\t\t\tudelay(11000);\n#endif\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":711,"total_token_length":947,"max_tokens_setting":1024}
+{"idx":356175,"func":"void fs_machineid(void) {\n\tunion machineid_t {\n\t\tuint8_t u8[16];\n\t\tuint32_t u32[4];\n\t} mid;\n\n\t\/\/ if --machine-id flag is inactive, do nothing\n\tif (arg_machineid == 0)\n\t\treturn;\n\tif (arg_debug)\n\t\tprintf(\"Generating a new machine-id\\n\");\n\n\t\/\/ init random number generator\n\tsrand(time(NULL));\n\n\t\/\/ generate random id\n\tmid.u32[0] = rand();\n\tmid.u32[1] = rand();\n\tmid.u32[2] = rand();\n\tmid.u32[3] = rand();\n\n\t\/\/ UUID version 4 and DCE variant\n\tmid.u8[6] = (mid.u8[6] & 0x0F) | 0x40;\n\tmid.u8[8] = (mid.u8[8] & 0x3F) | 0x80;\n\n\t\/\/ write it in a file\n\tFILE *fp = fopen(RUN_MACHINEID, \"we\");\n\tif (!fp)\n\t\terrExit(\"fopen\");\n\tfprintf(fp, \"%08x%08x%08x%08x\\n\", mid.u32[0], mid.u32[1], mid.u32[2], mid.u32[3]);\n\tfclose(fp);\n\tif (set_perms(RUN_MACHINEID, 0, 0, 0444))\n\t\terrExit(\"set_perms\");\n\n\tselinux_relabel_path(RUN_MACHINEID, \"\/etc\/machine-id\");\n\n\tstruct stat s;\n\tif (stat(\"\/etc\/machine-id\", &s) == 0) {\n\t\tif (arg_debug)\n\t\t\tprintf(\"installing a new \/etc\/machine-id\\n\");\n\n\t\tif (mount(RUN_MACHINEID, \"\/etc\/machine-id\", \"none\", MS_BIND, \"mode=444,gid=0\"))\n\t\t\terrExit(\"mount\");\n\t}\n\tif (stat(\"\/var\/lib\/dbus\/machine-id\", &s) == 0) {\n\t\tif (mount(RUN_MACHINEID, \"\/var\/lib\/dbus\/machine-id\", \"none\", MS_BIND, \"mode=444,gid=0\"))\n\t\t\terrExit(\"mount\");\n\t}\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":361302,"func":"stl_load_edge_nearby(stl_file *stl, stl_hash_edge *edge,\n                     stl_vertex *a, stl_vertex *b, float tolerance) {\n  float diff_x;\n  float diff_y;\n  float diff_z;\n  float max_diff;\n  unsigned vertex1[3];\n  unsigned vertex2[3];\n\n\n  diff_x = ABS(a->x - b->x);\n  diff_y = ABS(a->y - b->y);\n  diff_z = ABS(a->z - b->z);\n  max_diff = STL_MAX(diff_x, diff_y);\n  max_diff = STL_MAX(diff_z, max_diff);\n\n  vertex1[0] = (unsigned)((a->x - stl->stats.min.x) \/ tolerance);\n  vertex1[1] = (unsigned)((a->y - stl->stats.min.y) \/ tolerance);\n  vertex1[2] = (unsigned)((a->z - stl->stats.min.z) \/ tolerance);\n  vertex2[0] = (unsigned)((b->x - stl->stats.min.x) \/ tolerance);\n  vertex2[1] = (unsigned)((b->y - stl->stats.min.y) \/ tolerance);\n  vertex2[2] = (unsigned)((b->z - stl->stats.min.z) \/ tolerance);\n\n  if(   (vertex1[0] == vertex2[0])\n        && (vertex1[1] == vertex2[1])\n        && (vertex1[2] == vertex2[2])) {\n    \/* Both vertices hash to the same value *\/\n    return 0;\n  }\n\n  if(diff_x == max_diff) {\n    if(a->x > b->x) {\n      memcpy(&edge->key[0], vertex1, sizeof(stl_vertex));\n      memcpy(&edge->key[3], vertex2, sizeof(stl_vertex));\n    } else {\n      memcpy(&edge->key[0], vertex2, sizeof(stl_vertex));\n      memcpy(&edge->key[3], vertex1, sizeof(stl_vertex));\n      edge->which_edge += 3; \/* this edge is loaded backwards *\/\n    }\n  } else if(diff_y == max_diff) {\n    if(a->y > b->y) {\n      memcpy(&edge->key[0], vertex1, sizeof(stl_vertex));\n      memcpy(&edge->key[3], vertex2, sizeof(stl_vertex));\n    } else {\n      memcpy(&edge->key[0], vertex2, sizeof(stl_vertex));\n      memcpy(&edge->key[3], vertex1, sizeof(stl_vertex));\n      edge->which_edge += 3; \/* this edge is loaded backwards *\/\n    }\n  } else {\n    if(a->z > b->z) {\n      memcpy(&edge->key[0], vertex1, sizeof(stl_vertex));\n      memcpy(&edge->key[3], vertex2, sizeof(stl_vertex));\n    } else {\n      memcpy(&edge->key[0], vertex2, sizeof(stl_vertex));\n      memcpy(&edge->key[3], vertex1, sizeof(stl_vertex));\n      edge->which_edge += 3; \/* this edge is loaded backwards *\/\n    }\n  }\n  return 1;\n}","target":0,"code_token_length":675,"total_token_length":911,"max_tokens_setting":1024}
+{"idx":312436,"func":"ex_cnext(exarg_T *eap)\n{\n    qf_info_T\t*qi;\n    int\t\terrornr;\n    int\t\tdir;\n\n    if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL)\n\treturn;\n\n    if (eap->addr_count > 0\n\t    && (eap->cmdidx != CMD_cdo && eap->cmdidx != CMD_ldo\n\t\t&& eap->cmdidx != CMD_cfdo && eap->cmdidx != CMD_lfdo))\n\terrornr = (int)eap->line2;\n    else\n\terrornr = 1;\n\n    \/\/ Depending on the command jump to either next or previous entry\/file.\n    switch (eap->cmdidx)\n    {\n\tcase CMD_cnext: case CMD_lnext: case CMD_cdo: case CMD_ldo:\n\t    dir = FORWARD;\n\t    break;\n\tcase CMD_cprevious: case CMD_lprevious: case CMD_cNext:\n\tcase CMD_lNext:\n\t    dir = BACKWARD;\n\t    break;\n\tcase CMD_cnfile: case CMD_lnfile: case CMD_cfdo: case CMD_lfdo:\n\t    dir = FORWARD_FILE;\n\t    break;\n\tcase CMD_cpfile: case CMD_lpfile: case CMD_cNfile: case CMD_lNfile:\n\t    dir = BACKWARD_FILE;\n\t    break;\n\tdefault:\n\t    dir = FORWARD;\n\t    break;\n    }\n\n    qf_jump(qi, dir, errornr, eap->forceit);\n}","target":0,"code_token_length":306,"total_token_length":542,"max_tokens_setting":1024}
+{"idx":279938,"func":"skip_vimgrep_pat_ext(char_u *p, char_u **s, int *flags, char_u **nulp, int *cp)\n{\n    int\t\tc;\n\n    if (vim_isIDc(*p))\n    {\n\t\/\/ \":vimgrep pattern fname\"\n\tif (s != NULL)\n\t    *s = p;\n\tp = skiptowhite(p);\n\tif (s != NULL && *p != NUL)\n\t{\n\t    if (nulp != NULL)\n\t    {\n\t\t*nulp = p;\n\t\t*cp = *p;\n\t    }\n\t    *p++ = NUL;\n\t}\n    }\n    else\n    {\n\t\/\/ \":vimgrep \/pattern\/[g][j] fname\"\n\tif (s != NULL)\n\t    *s = p + 1;\n\tc = *p;\n\tp = skip_regexp(p + 1, c, TRUE);\n\tif (*p != c)\n\t    return NULL;\n\n\t\/\/ Truncate the pattern.\n\tif (s != NULL)\n\t{\n\t    if (nulp != NULL)\n\t    {\n\t\t*nulp = p;\n\t\t*cp = *p;\n\t    }\n\t    *p = NUL;\n\t}\n\t++p;\n\n\t\/\/ Find the flags\n\twhile (*p == 'g' || *p == 'j' || *p == 'f')\n\t{\n\t    if (flags != NULL)\n\t    {\n\t\tif (*p == 'g')\n\t\t    *flags |= VGR_GLOBAL;\n\t\telse if (*p == 'j')\n\t\t    *flags |= VGR_NOJUMP;\n\t\telse\n\t\t    *flags |= VGR_FUZZY;\n\t    }\n\t    ++p;\n\t}\n    }\n    return p;\n}","target":0,"code_token_length":352,"total_token_length":588,"max_tokens_setting":1024}
+{"idx":344249,"func":"int luaG_traceexec (lua_State *L, const Instruction *pc) {\n  CallInfo *ci = L->ci;\n  lu_byte mask = L->hookmask;\n  const Proto *p = ci_func(ci)->p;\n  int counthook;\n  if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) {  \/* no hooks? *\/\n    ci->u.l.trap = 0;  \/* don't need to stop again *\/\n    return 0;  \/* turn off 'trap' *\/\n  }\n  pc++;  \/* reference is always next instruction *\/\n  ci->u.l.savedpc = pc;  \/* save 'pc' *\/\n  counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));\n  if (counthook)\n    resethookcount(L);  \/* reset count *\/\n  else if (!(mask & LUA_MASKLINE))\n    return 1;  \/* no line hook and count != 0; nothing to be done now *\/\n  if (ci->callstatus & CIST_HOOKYIELD) {  \/* called hook last time? *\/\n    ci->callstatus &= ~CIST_HOOKYIELD;  \/* erase mark *\/\n    return 1;  \/* do not call hook again (VM yielded, so it did not move) *\/\n  }\n  if (!isIT(*(ci->u.l.savedpc - 1)))  \/* top not being used? *\/\n    L->top = ci->top;  \/* correct top *\/\n  if (counthook)\n    luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0);  \/* call count hook *\/\n  if (mask & LUA_MASKLINE) {\n    \/* 'L->oldpc' may be invalid; use zero in this case *\/\n    int oldpc = (L->oldpc < p->sizecode) ? L->oldpc : 0;\n    int npci = pcRel(pc, p);\n    if (npci <= oldpc ||  \/* call hook when jump back (loop), *\/\n        changedline(p, oldpc, npci)) {  \/* or when enter new line *\/\n      int newline = luaG_getfuncline(p, npci);\n      luaD_hook(L, LUA_HOOKLINE, newline, 0, 0);  \/* call line hook *\/\n    }\n    L->oldpc = npci;  \/* 'pc' of last call to line hook *\/\n  }\n  if (L->status == LUA_YIELD) {  \/* did hook yield? *\/\n    if (counthook)\n      L->hookcount = 1;  \/* undo decrement to zero *\/\n    ci->u.l.savedpc--;  \/* undo increment (resume will increment it again) *\/\n    ci->callstatus |= CIST_HOOKYIELD;  \/* mark that it yielded *\/\n    luaD_throw(L, LUA_YIELD);\n  }\n  return 1;  \/* keep 'trap' on *\/\n}","target":0,"code_token_length":625,"total_token_length":861,"max_tokens_setting":1024}
+{"idx":459086,"func":"int tc_setup_action(struct flow_action *flow_action,\n\t\t    struct tc_action *actions[])\n{\n\tint i, j, index, err = 0;\n\tstruct tc_action *act;\n\n\tBUILD_BUG_ON(TCA_ACT_HW_STATS_ANY != FLOW_ACTION_HW_STATS_ANY);\n\tBUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE);\n\tBUILD_BUG_ON(TCA_ACT_HW_STATS_DELAYED != FLOW_ACTION_HW_STATS_DELAYED);\n\n\tif (!actions)\n\t\treturn 0;\n\n\tj = 0;\n\ttcf_act_for_each_action(i, act, actions) {\n\t\tstruct flow_action_entry *entry;\n\n\t\tentry = &flow_action->entries[j];\n\t\tspin_lock_bh(&act->tcfa_lock);\n\t\terr = tcf_act_get_cookie(entry, act);\n\t\tif (err)\n\t\t\tgoto err_out_locked;\n\n\t\tentry->hw_stats = tc_act_hw_stats(act->hw_stats);\n\t\tentry->hw_index = act->tcfa_index;\n\t\tindex = 0;\n\t\terr = tc_setup_offload_act(act, entry, &index);\n\t\tif (!err)\n\t\t\tj += index;\n\t\telse\n\t\t\tgoto err_out_locked;\n\t\tspin_unlock_bh(&act->tcfa_lock);\n\t}\n\nerr_out:\n\tif (err)\n\t\ttc_cleanup_offload_action(flow_action);\n\n\treturn err;\nerr_out_locked:\n\tspin_unlock_bh(&act->tcfa_lock);\n\tgoto err_out;\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":201007,"func":"static int print_media_desc(const pjmedia_sdp_media *m, char *buf, pj_size_t len)\n{\n    char *p = buf;\n    char *end = buf+len;\n    unsigned i;\n    int printed;\n\n    \/* check length for the \"m=\" line. *\/\n    if (len < (pj_size_t)m->desc.media.slen+m->desc.transport.slen+12+24) {\n\treturn -1;\n    }\n    *p++ = 'm';\t    \/* m= *\/\n    *p++ = '=';\n    pj_memcpy(p, m->desc.media.ptr, m->desc.media.slen);\n    p += m->desc.media.slen;\n    *p++ = ' ';\n    printed = pj_utoa(m->desc.port, p);\n    p += printed;\n    if (m->desc.port_count > 1) {\n\t*p++ = '\/';\n\tprinted = pj_utoa(m->desc.port_count, p);\n\tp += printed;\n    }\n    *p++ = ' ';\n    pj_memcpy(p, m->desc.transport.ptr, m->desc.transport.slen);\n    p += m->desc.transport.slen;\n    for (i=0; i<m->desc.fmt_count; ++i) {\n\t*p++ = ' ';\n\tpj_memcpy(p, m->desc.fmt[i].ptr, m->desc.fmt[i].slen);\n\tp += m->desc.fmt[i].slen;\n    }\n    *p++ = '\\r';\n    *p++ = '\\n';\n\n    \/* print connection info, if present. *\/\n    if (m->conn) {\n\tprinted = print_connection_info(m->conn, p, (int)(end-p));\n\tif (printed < 0) {\n\t    return -1;\n\t}\n\tp += printed;\n    }\n    \n    \/* print optional bandwidth info. *\/\n    for (i=0; i<m->bandw_count; ++i) {\n\tprinted = (int)print_bandw(m->bandw[i], p, end-p);\n\tif (printed < 0) {\n\t    return -1;\n\t}\n\tp += printed;\n    }\n\n    \/* print attributes. *\/\n    for (i=0; i<m->attr_count; ++i) {\n\tprinted = (int)print_attr(m->attr[i], p, end-p);\n\tif (printed < 0) {\n\t    return -1;\n\t}\n\tp += printed;\n    }\n\n    return (int)(p-buf);\n}","target":1,"code_token_length":518,"total_token_length":754,"max_tokens_setting":1024}
+{"idx":463080,"func":"static void sungem_mmio_greg_write(void *opaque, hwaddr addr, uint64_t val,\n                                   unsigned size)\n{\n    SunGEMState *s = opaque;\n\n    if (!(addr < 0x20) && !(addr >= 0x1000 && addr <= 0x1010)) {\n        qemu_log_mask(LOG_GUEST_ERROR,\n                      \"Write to unknown GREG register 0x%\"HWADDR_PRIx\"\\n\",\n                      addr);\n        return;\n    }\n\n    trace_sungem_mmio_greg_write(addr, val);\n\n    \/* Pre-write filter *\/\n    switch (addr) {\n    \/* Read only registers *\/\n    case GREG_SEBSTATE:\n    case GREG_STAT:\n    case GREG_STAT2:\n    case GREG_PCIESTAT:\n        return; \/* No actual write *\/\n    case GREG_IACK:\n        val &= GREG_STAT_LATCH;\n        s->gregs[GREG_STAT >> 2] &= ~val;\n        sungem_eval_irq(s);\n        return; \/* No actual write *\/\n    case GREG_PCIEMASK:\n        val &= 0x7;\n        break;\n    }\n\n    s->gregs[addr  >> 2] = val;\n\n    \/* Post write action *\/\n    switch (addr) {\n    case GREG_IMASK:\n        \/* Re-evaluate interrupt *\/\n        sungem_eval_irq(s);\n        break;\n    case GREG_SWRST:\n        switch (val & (GREG_SWRST_TXRST | GREG_SWRST_RXRST)) {\n        case GREG_SWRST_RXRST:\n            sungem_reset_rx(s);\n            break;\n        case GREG_SWRST_TXRST:\n            sungem_reset_tx(s);\n            break;\n        case GREG_SWRST_RXRST | GREG_SWRST_TXRST:\n            sungem_reset_all(s, false);\n        }\n        break;\n    }\n}","target":0,"code_token_length":408,"total_token_length":644,"max_tokens_setting":1024}
+{"idx":234868,"func":"static struct btrfs_fs_devices *find_fsid_with_metadata_uuid(\n\t\t\t\tstruct btrfs_super_block *disk_super)\n{\n\n\tstruct btrfs_fs_devices *fs_devices;\n\n\t\/*\n\t * Handle scanned device having completed its fsid change but\n\t * belonging to a fs_devices that was created by first scanning\n\t * a device which didn't have its fsid\/metadata_uuid changed\n\t * at all and the CHANGING_FSID_V2 flag set.\n\t *\/\n\tlist_for_each_entry(fs_devices, &fs_uuids, fs_list) {\n\t\tif (fs_devices->fsid_change &&\n\t\t    memcmp(disk_super->metadata_uuid, fs_devices->fsid,\n\t\t\t   BTRFS_FSID_SIZE) == 0 &&\n\t\t    memcmp(fs_devices->fsid, fs_devices->metadata_uuid,\n\t\t\t   BTRFS_FSID_SIZE) == 0) {\n\t\t\treturn fs_devices;\n\t\t}\n\t}\n\t\/*\n\t * Handle scanned device having completed its fsid change but\n\t * belonging to a fs_devices that was created by a device that\n\t * has an outdated pair of fsid\/metadata_uuid and\n\t * CHANGING_FSID_V2 flag set.\n\t *\/\n\tlist_for_each_entry(fs_devices, &fs_uuids, fs_list) {\n\t\tif (fs_devices->fsid_change &&\n\t\t    memcmp(fs_devices->metadata_uuid,\n\t\t\t   fs_devices->fsid, BTRFS_FSID_SIZE) != 0 &&\n\t\t    memcmp(disk_super->metadata_uuid, fs_devices->metadata_uuid,\n\t\t\t   BTRFS_FSID_SIZE) == 0) {\n\t\t\treturn fs_devices;\n\t\t}\n\t}\n\n\treturn find_fsid(disk_super->fsid, disk_super->metadata_uuid);\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":261427,"func":"int check_CTB_available(const de265_image* img,\n                        int xC,int yC, int xN,int yN)\n{\n  \/\/ check whether neighbor is outside of frame\n\n  if (xN < 0 || yN < 0) { return 0; }\n  if (xN >= img->get_sps().pic_width_in_luma_samples)  { return 0; }\n  if (yN >= img->get_sps().pic_height_in_luma_samples) { return 0; }\n\n\n  int current_ctbAddrRS  = luma_pos_to_ctbAddrRS(&img->get_sps(), xC,yC);\n  int neighbor_ctbAddrRS = luma_pos_to_ctbAddrRS(&img->get_sps(), xN,yN);\n\n  \/\/ TODO: check if this is correct (6.4.1)\n\n  if (img->get_SliceAddrRS_atCtbRS(current_ctbAddrRS) !=\n      img->get_SliceAddrRS_atCtbRS(neighbor_ctbAddrRS)) {\n    return 0;\n  }\n\n  \/\/ check if both CTBs are in the same tile.\n\n  if (img->get_pps().TileIdRS[current_ctbAddrRS] !=\n      img->get_pps().TileIdRS[neighbor_ctbAddrRS]) {\n    return 0;\n  }\n\n  return 1;\n}","target":0,"code_token_length":296,"total_token_length":532,"max_tokens_setting":1024}
+{"idx":256402,"func":"static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,\n\t\tgfp_t gfp_mask)\n{\n\tunsigned int max_sectors = queue_max_hw_sectors(rq->q);\n\tstruct bio *bio;\n\tint ret;\n\tint j;\n\n\tif (!iov_iter_count(iter))\n\t\treturn -EINVAL;\n\n\tbio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_VECS));\n\tif (!bio)\n\t\treturn -ENOMEM;\n\tbio->bi_opf |= req_op(rq);\n\n\twhile (iov_iter_count(iter)) {\n\t\tstruct page **pages;\n\t\tssize_t bytes;\n\t\tsize_t offs, added = 0;\n\t\tint npages;\n\n\t\tbytes = iov_iter_get_pages_alloc(iter, &pages, LONG_MAX, &offs);\n\t\tif (unlikely(bytes <= 0)) {\n\t\t\tret = bytes ? bytes : -EFAULT;\n\t\t\tgoto out_unmap;\n\t\t}\n\n\t\tnpages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE);\n\n\t\tif (unlikely(offs & queue_dma_alignment(rq->q))) {\n\t\t\tret = -EINVAL;\n\t\t\tj = 0;\n\t\t} else {\n\t\t\tfor (j = 0; j < npages; j++) {\n\t\t\t\tstruct page *page = pages[j];\n\t\t\t\tunsigned int n = PAGE_SIZE - offs;\n\t\t\t\tbool same_page = false;\n\n\t\t\t\tif (n > bytes)\n\t\t\t\t\tn = bytes;\n\n\t\t\t\tif (!bio_add_hw_page(rq->q, bio, page, n, offs,\n\t\t\t\t\t\t     max_sectors, &same_page)) {\n\t\t\t\t\tif (same_page)\n\t\t\t\t\t\tput_page(page);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tadded += n;\n\t\t\t\tbytes -= n;\n\t\t\t\toffs = 0;\n\t\t\t}\n\t\t\tiov_iter_advance(iter, added);\n\t\t}\n\t\t\/*\n\t\t * release the pages we didn't map into the bio, if any\n\t\t *\/\n\t\twhile (j < npages)\n\t\t\tput_page(pages[j++]);\n\t\tkvfree(pages);\n\t\t\/* couldn't stuff something into bio? *\/\n\t\tif (bytes)\n\t\t\tbreak;\n\t}\n\n\tret = blk_rq_append_bio(rq, bio);\n\tif (ret)\n\t\tgoto out_unmap;\n\treturn 0;\n\n out_unmap:\n\tbio_release_pages(bio, false);\n\tbio_put(bio);\n\treturn ret;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":313859,"func":"v_swap_corners(int cmdchar)\n{\n    pos_T\told_cursor;\n    colnr_T\tleft, right;\n\n    if (cmdchar == 'O' && VIsual_mode == Ctrl_V)\n    {\n\told_cursor = curwin->w_cursor;\n\tgetvcols(curwin, &old_cursor, &VIsual, &left, &right);\n\tcurwin->w_cursor.lnum = VIsual.lnum;\n\tcoladvance(left);\n\tVIsual = curwin->w_cursor;\n\n\tcurwin->w_cursor.lnum = old_cursor.lnum;\n\tcurwin->w_curswant = right;\n\t\/\/ 'selection \"exclusive\" and cursor at right-bottom corner: move it\n\t\/\/ right one column\n\tif (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e')\n\t    ++curwin->w_curswant;\n\tcoladvance(curwin->w_curswant);\n\tif (curwin->w_cursor.col == old_cursor.col\n\t\t&& (!virtual_active()\n\t\t    || curwin->w_cursor.coladd == old_cursor.coladd))\n\t{\n\t    curwin->w_cursor.lnum = VIsual.lnum;\n\t    if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e')\n\t\t++right;\n\t    coladvance(right);\n\t    VIsual = curwin->w_cursor;\n\n\t    curwin->w_cursor.lnum = old_cursor.lnum;\n\t    coladvance(left);\n\t    curwin->w_curswant = left;\n\t}\n    }\n    else\n    {\n\told_cursor = curwin->w_cursor;\n\tcurwin->w_cursor = VIsual;\n\tVIsual = old_cursor;\n\tcurwin->w_set_curswant = TRUE;\n    }\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":413692,"func":"R_API RAnalOp* r_core_anal_op(RCore *core, ut64 addr, int mask) {\n\tint len;\n\tut8 buf[32];\n\tut8 *ptr;\n\n\tr_return_val_if_fail (core, NULL);\n\tif (addr == UT64_MAX) {\n\t\treturn NULL;\n\t}\n\tRAnalOp *op = R_NEW0 (RAnalOp);\n\tif (!op) {\n\t\treturn NULL;\n\t}\n\tint delta = (addr - core->offset);\n\tint minopsz = 8;\n\tif (delta > 0 && delta + minopsz < core->blocksize && addr >= core->offset && addr + 16 < core->offset + core->blocksize) {\n\t\tptr = core->block + delta;\n\t\tlen = core->blocksize - delta;\n\t\tif (len < 1) {\n\t\t\tgoto err_op;\n\t\t}\n\t} else {\n\t\tif (!r_io_read_at (core->io, addr, buf, sizeof (buf))) {\n\t\t\tgoto err_op;\n\t\t}\n\t\tptr = buf;\n\t\tlen = sizeof (buf);\n\t}\n\tif (r_anal_op (core->anal, op, addr, ptr, len, mask) < 1) {\n\t\tgoto err_op;\n\t}\n\t\/\/ TODO This code block must be deleted when all the anal plugs support disasm\n\tif (!op->mnemonic && mask & R_ANAL_OP_MASK_DISASM) {\n\t\tRAsmOp asmop;\n\t\tif (core->anal->verbose) {\n\t\t\teprintf (\"Warning: Implement RAnalOp.MASK_DISASM for current anal.arch. Using the sluggish RAsmOp fallback for now.\\n\");\n\t\t}\n\t\tr_asm_set_pc (core->rasm, addr);\n\t\tr_asm_op_init (&asmop);\n\t\tif (r_asm_disassemble (core->rasm, &asmop, ptr, len) > 0) {\n\t\t\top->mnemonic = strdup (r_strbuf_get (&asmop.buf_asm));\n\t\t}\n\t\tr_asm_op_fini (&asmop);\n\t}\n\treturn op;\nerr_op:\n\tfree (op);\n\treturn NULL;\n}","target":0,"code_token_length":450,"total_token_length":686,"max_tokens_setting":1024}
+{"idx":462570,"func":"void controller::write_item(std::shared_ptr<rss_item> item, std::ostream& ostr) {\n\tstd::vector<std::pair<LineType, std::string>> lines;\n\tstd::vector<linkpair> links; \/\/ not used\n\n\tstd::string title(_(\"Title: \"));\n\ttitle.append(item->title());\n\tlines.push_back(std::make_pair(LineType::wrappable, title));\n\n\tstd::string author(_(\"Author: \"));\n\tauthor.append(item->author());\n\tlines.push_back(std::make_pair(LineType::wrappable, author));\n\n\tstd::string date(_(\"Date: \"));\n\tdate.append(item->pubDate());\n\tlines.push_back(std::make_pair(LineType::wrappable, date));\n\n\tstd::string link(_(\"Link: \"));\n\tlink.append(item->link());\n\tlines.push_back(std::make_pair(LineType::softwrappable, link));\n\n\tif (item->enclosure_url() != \"\") {\n\t\tstd::string dlurl(_(\"Podcast Download URL: \"));\n\t\tdlurl.append(item->enclosure_url());\n\t\tlines.push_back(std::make_pair(LineType::softwrappable, dlurl));\n\t}\n\n\tlines.push_back(std::make_pair(LineType::wrappable, std::string(\"\")));\n\n\thtmlrenderer rnd(true);\n\trnd.render(item->description(), lines, links, item->feedurl());\n\ttextformatter txtfmt;\n\ttxtfmt.add_lines(lines);\n\n\tunsigned int width = cfg.get_configvalue_as_int(\"text-width\");\n\tif (width == 0)\n\t\twidth = 80;\n\tostr << txtfmt.format_text_plain(width) << std::endl;\n}","target":0,"code_token_length":318,"total_token_length":554,"max_tokens_setting":1024}
+{"idx":459522,"func":"BPF_CALL_3(bpf_get_stackid_pe, struct bpf_perf_event_data_kern *, ctx,\n\t   struct bpf_map *, map, u64, flags)\n{\n\tstruct perf_event *event = ctx->event;\n\tstruct perf_callchain_entry *trace;\n\tbool kernel, user;\n\t__u64 nr_kernel;\n\tint ret;\n\n\t\/* perf_sample_data doesn't have callchain, use bpf_get_stackid *\/\n\tif (!(event->attr.sample_type & __PERF_SAMPLE_CALLCHAIN_EARLY))\n\t\treturn bpf_get_stackid((unsigned long)(ctx->regs),\n\t\t\t\t       (unsigned long) map, flags, 0, 0);\n\n\tif (unlikely(flags & ~(BPF_F_SKIP_FIELD_MASK | BPF_F_USER_STACK |\n\t\t\t       BPF_F_FAST_STACK_CMP | BPF_F_REUSE_STACKID)))\n\t\treturn -EINVAL;\n\n\tuser = flags & BPF_F_USER_STACK;\n\tkernel = !user;\n\n\ttrace = ctx->data->callchain;\n\tif (unlikely(!trace))\n\t\treturn -EFAULT;\n\n\tnr_kernel = count_kernel_ip(trace);\n\n\tif (kernel) {\n\t\t__u64 nr = trace->nr;\n\n\t\ttrace->nr = nr_kernel;\n\t\tret = __bpf_get_stackid(map, trace, flags);\n\n\t\t\/* restore nr *\/\n\t\ttrace->nr = nr;\n\t} else { \/* user *\/\n\t\tu64 skip = flags & BPF_F_SKIP_FIELD_MASK;\n\n\t\tskip += nr_kernel;\n\t\tif (skip > BPF_F_SKIP_FIELD_MASK)\n\t\t\treturn -EFAULT;\n\n\t\tflags = (flags & ~BPF_F_SKIP_FIELD_MASK) | skip;\n\t\tret = __bpf_get_stackid(map, trace, flags);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":359,"total_token_length":595,"max_tokens_setting":1024}
+{"idx":195334,"func":"GF_Err iloc_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 item_count, extent_count, i, j;\n\tGF_ItemLocationBox *ptr = (GF_ItemLocationBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 2)\n\tptr->offset_size = gf_bs_read_int(bs, 4);\n\tptr->length_size = gf_bs_read_int(bs, 4);\n\tptr->base_offset_size = gf_bs_read_int(bs, 4);\n\tif (ptr->version == 1 || ptr->version == 2) {\n\t\tptr->index_size = gf_bs_read_int(bs, 4);\n\t} else {\n\t\tgf_bs_read_int(bs, 4);\n\t}\n\tif (ptr->version < 2) {\n\t\tISOM_DECREASE_SIZE(ptr, 2)\n\t\titem_count = gf_bs_read_u16(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\titem_count = gf_bs_read_u32(bs);\n\t}\n\n\tfor (i = 0; i < item_count; i++) {\n\t\tGF_ItemLocationEntry *location_entry = (GF_ItemLocationEntry *)gf_malloc(sizeof(GF_ItemLocationEntry));\n\t\tif (!location_entry) return GF_OUT_OF_MEM;\n\n\t\tgf_list_add(ptr->location_entries, location_entry);\n\t\tif (ptr->version < 2) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 2)\n\t\t\tlocation_entry->item_ID = gf_bs_read_u16(bs);\n\t\t} else {\n\t\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\t\tlocation_entry->item_ID = gf_bs_read_u32(bs);\n\t\t}\n\t\tif (ptr->version == 1 || ptr->version == 2) {\n\t\t\tISOM_DECREASE_SIZE(ptr, 2)\n\t\t\tlocation_entry->construction_method = gf_bs_read_u16(bs);\n\t\t}\n\t\telse {\n\t\t\tlocation_entry->construction_method = 0;\n\t\t}\n\t\tISOM_DECREASE_SIZE(ptr, (2 + ptr->base_offset_size) )\n\t\tlocation_entry->data_reference_index = gf_bs_read_u16(bs);\n\t\tlocation_entry->base_offset = gf_bs_read_int(bs, 8*ptr->base_offset_size);\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\t\tlocation_entry->original_base_offset = location_entry->base_offset;\n#endif\n\n\t\tISOM_DECREASE_SIZE(ptr, 2)\n\t\textent_count = gf_bs_read_u16(bs);\n\t\tlocation_entry->extent_entries = gf_list_new();\n\t\tfor (j = 0; j < extent_count; j++) {\n\t\t\tGF_ItemExtentEntry *extent_entry = (GF_ItemExtentEntry *)gf_malloc(sizeof(GF_ItemExtentEntry));\n\t\t\tif (!extent_entry) return GF_OUT_OF_MEM;\n\t\t\t\n\t\t\tgf_list_add(location_entry->extent_entries, extent_entry);\n\t\t\tif ((ptr->version == 1 || ptr->version == 2) && ptr->index_size > 0) {\n\t\t\t\tISOM_DECREASE_SIZE(ptr, ptr->index_size)\n\t\t\t\textent_entry->extent_index = gf_bs_read_int(bs, 8 * ptr->index_size);\n\t\t\t}\n\t\t\telse {\n\t\t\t\textent_entry->extent_index = 0;\n\t\t\t}\n\t\t\tISOM_DECREASE_SIZE(ptr, (ptr->offset_size+ptr->length_size) )\n\n\t\t\textent_entry->extent_offset = gf_bs_read_int(bs, 8*ptr->offset_size);\n\t\t\textent_entry->extent_length = gf_bs_read_int(bs, 8*ptr->length_size);\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\t\t\textent_entry->original_extent_offset = extent_entry->extent_offset;\n#endif\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":1,"code_token_length":786,"total_token_length":1022,"max_tokens_setting":1024}
+{"idx":337814,"func":"int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep,\n\t\t     const struct sctp_association *asoc, enum sctp_cid cid,\n\t\t     struct sctp_init_chunk *peer_init,\n\t\t     struct sctp_chunk *chunk, struct sctp_chunk **errp)\n{\n\tunion sctp_params param;\n\tbool has_cookie = false;\n\tint result;\n\n\t\/* Check for missing mandatory parameters. Note: Initial TSN is\n\t * also mandatory, but is not checked here since the valid range\n\t * is 0..2**32-1. RFC4960, section 3.3.3.\n\t *\/\n\tif (peer_init->init_hdr.num_outbound_streams == 0 ||\n\t    peer_init->init_hdr.num_inbound_streams == 0 ||\n\t    peer_init->init_hdr.init_tag == 0 ||\n\t    ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW)\n\t\treturn sctp_process_inv_mandatory(asoc, chunk, errp);\n\n\tsctp_walk_params(param, peer_init, init_hdr.params) {\n\t\tif (param.p->type == SCTP_PARAM_STATE_COOKIE)\n\t\t\thas_cookie = true;\n\t}\n\n\t\/* There is a possibility that a parameter length was bad and\n\t * in that case we would have stoped walking the parameters.\n\t * The current param.p would point at the bad one.\n\t * Current consensus on the mailing list is to generate a PROTOCOL\n\t * VIOLATION error.  We build the ERROR chunk here and let the normal\n\t * error handling code build and send the packet.\n\t *\/\n\tif (param.v != (void *)chunk->chunk_end)\n\t\treturn sctp_process_inv_paramlength(asoc, param.p, chunk, errp);\n\n\t\/* The only missing mandatory param possible today is\n\t * the state cookie for an INIT-ACK chunk.\n\t *\/\n\tif ((SCTP_CID_INIT_ACK == cid) && !has_cookie)\n\t\treturn sctp_process_missing_param(asoc, SCTP_PARAM_STATE_COOKIE,\n\t\t\t\t\t\t  chunk, errp);\n\n\t\/* Verify all the variable length parameters *\/\n\tsctp_walk_params(param, peer_init, init_hdr.params) {\n\t\tresult = sctp_verify_param(net, ep, asoc, param, cid,\n\t\t\t\t\t   chunk, errp);\n\t\tswitch (result) {\n\t\tcase SCTP_IERROR_ABORT:\n\t\tcase SCTP_IERROR_NOMEM:\n\t\t\treturn 0;\n\t\tcase SCTP_IERROR_ERROR:\n\t\t\treturn 1;\n\t\tcase SCTP_IERROR_NO_ERROR:\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t} \/* for (loop through all parameters) *\/\n\n\treturn 1;\n}","target":0,"code_token_length":553,"total_token_length":789,"max_tokens_setting":1024}
+{"idx":313780,"func":"normal_search(\n    cmdarg_T\t*cap,\n    int\t\tdir,\n    char_u\t*pat,\n    int\t\topt,\t\t\/\/ extra flags for do_search()\n    int\t\t*wrapped)\n{\n    int\t\ti;\n    searchit_arg_T sia;\n#ifdef FEAT_SEARCH_EXTRA\n    pos_T\tprev_cursor = curwin->w_cursor;\n#endif\n\n    cap->oap->motion_type = MCHAR;\n    cap->oap->inclusive = FALSE;\n    cap->oap->use_reg_one = TRUE;\n    curwin->w_set_curswant = TRUE;\n\n    CLEAR_FIELD(sia);\n    i = do_search(cap->oap, dir, dir, pat, cap->count1,\n\t\t\t    opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia);\n    if (wrapped != NULL)\n\t*wrapped = sia.sa_wrapped;\n    if (i == 0)\n\tclearop(cap->oap);\n    else\n    {\n\tif (i == 2)\n\t    cap->oap->motion_type = MLINE;\n\tcurwin->w_cursor.coladd = 0;\n#ifdef FEAT_FOLDING\n\tif (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped)\n\t    foldOpenCursor();\n#endif\n    }\n#ifdef FEAT_SEARCH_EXTRA\n    \/\/ Redraw the window to refresh the highlighted matches.\n    if (!EQUAL_POS(curwin->w_cursor, prev_cursor) && p_hls && !no_hlsearch)\n\tredraw_later(SOME_VALID);\n#endif\n\n    \/\/ \"\/$\" will put the cursor after the end of the line, may need to\n    \/\/ correct that here\n    check_cursor();\n    return i;\n}","target":0,"code_token_length":363,"total_token_length":599,"max_tokens_setting":1024}
+{"idx":216126,"func":"    kssl_keytab_is_available(KSSL_CTX *kssl_ctx)\n{\n    krb5_context\t\tkrb5context = NULL;\n    krb5_keytab \t\tkrb5keytab = NULL;\n    krb5_keytab_entry           entry;\n    krb5_principal              princ = NULL;\n    krb5_error_code  \t\tkrb5rc = KRB5KRB_ERR_GENERIC;\n    int rc = 0;\n\n    if ((krb5rc = krb5_init_context(&krb5context)))\n        return(0);\n\n    \/*\tkssl_ctx->keytab_file == NULL ==> use Kerberos default\n    *\/\n    if (kssl_ctx->keytab_file)\n    {\n        krb5rc = krb5_kt_resolve(krb5context, kssl_ctx->keytab_file,\n                                  &krb5keytab);\n        if (krb5rc)\n            goto exit;\n    }\n    else\n    {\n        krb5rc = krb5_kt_default(krb5context,&krb5keytab);\n        if (krb5rc)\n            goto exit;\n    }\n\n    \/* the host key we are looking for *\/\n    krb5rc = krb5_sname_to_principal(krb5context, NULL, \n                                     kssl_ctx->service_name ? kssl_ctx->service_name: KRB5SVC,\n                                     KRB5_NT_SRV_HST, &princ);\n\n    krb5rc = krb5_kt_get_entry(krb5context, krb5keytab, \n                                princ,\n                                0 \/* IGNORE_VNO *\/,\n                                0 \/* IGNORE_ENCTYPE *\/,\n                                &entry);\n    if ( krb5rc == KRB5_KT_NOTFOUND ) {\n        rc = 1;\n        goto exit;\n    } else if ( krb5rc )\n        goto exit;\n    \n    krb5_kt_free_entry(krb5context, &entry);\n    rc = 1;\n\n  exit:\n    if (krb5keytab)     krb5_kt_close(krb5context, krb5keytab);\n    if (princ)          krb5_free_principal(krb5context, princ);\n    if (krb5context)\tkrb5_free_context(krb5context);\n    return(rc);\n}","target":1,"code_token_length":468,"total_token_length":704,"max_tokens_setting":1024}
+{"idx":278266,"func":"tabstop_set(char_u *var, int **array)\n{\n    int\t    valcount = 1;\n    int\t    t;\n    char_u  *cp;\n\n    if (var[0] == NUL || (var[0] == '0' && var[1] == NUL))\n    {\n\t*array = NULL;\n\treturn OK;\n    }\n\n    for (cp = var; *cp != NUL; ++cp)\n    {\n\tif (cp == var || cp[-1] == ',')\n\t{\n\t    char_u *end;\n\n\t    if (strtol((char *)cp, (char **)&end, 10) <= 0)\n\t    {\n\t\tif (cp != end)\n\t\t    emsg(_(e_argument_must_be_positive));\n\t\telse\n\t\t    semsg(_(e_invalid_argument_str), cp);\n\t\treturn FAIL;\n\t    }\n\t}\n\n\tif (VIM_ISDIGIT(*cp))\n\t    continue;\n\tif (cp[0] == ',' && cp > var && cp[-1] != ',' && cp[1] != NUL)\n\t{\n\t    ++valcount;\n\t    continue;\n\t}\n\tsemsg(_(e_invalid_argument_str), var);\n\treturn FAIL;\n    }\n\n    *array = ALLOC_MULT(int, valcount + 1);\n    if (*array == NULL)\n\treturn FAIL;\n    (*array)[0] = valcount;\n\n    t = 1;\n    for (cp = var; *cp != NUL;)\n    {\n\tint n = atoi((char *)cp);\n\n\t\/\/ Catch negative values, overflow and ridiculous big values.\n\tif (n <= 0 || n > TABSTOP_MAX)\n\t{\n\t    semsg(_(e_invalid_argument_str), cp);\n\t    vim_free(*array);\n\t    *array = NULL;\n\t    return FAIL;\n\t}\n\t(*array)[t++] = n;\n\twhile (*cp != NUL && *cp != ',')\n\t    ++cp;\n\tif (*cp != NUL)\n\t    ++cp;\n    }\n\n    return OK;\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":282871,"func":"int rsi_send_bgscan_probe_req(struct rsi_common *common,\n\t\t\t      struct ieee80211_vif *vif)\n{\n\tstruct cfg80211_scan_request *scan_req = common->hwscan;\n\tstruct rsi_bgscan_probe *bgscan;\n\tstruct sk_buff *skb;\n\tstruct sk_buff *probereq_skb;\n\tu16 frame_len = sizeof(*bgscan);\n\tsize_t ssid_len = 0;\n\tu8 *ssid = NULL;\n\n\trsi_dbg(MGMT_TX_ZONE,\n\t\t\"%s: Sending bgscan probe req frame\\n\", __func__);\n\n\tif (common->priv->sc_nvifs <= 0)\n\t\treturn -ENODEV;\n\n\tif (scan_req->n_ssids) {\n\t\tssid = scan_req->ssids[0].ssid;\n\t\tssid_len = scan_req->ssids[0].ssid_len;\n\t}\n\n\tskb = dev_alloc_skb(frame_len + MAX_BGSCAN_PROBE_REQ_LEN);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\tmemset(skb->data, 0, frame_len + MAX_BGSCAN_PROBE_REQ_LEN);\n\n\tbgscan = (struct rsi_bgscan_probe *)skb->data;\n\tbgscan->desc_dword0.frame_type = BG_SCAN_PROBE_REQ;\n\tbgscan->flags = cpu_to_le16(HOST_BG_SCAN_TRIG);\n\tif (common->band == NL80211_BAND_5GHZ) {\n\t\tbgscan->mgmt_rate = cpu_to_le16(RSI_RATE_6);\n\t\tbgscan->def_chan = cpu_to_le16(40);\n\t} else {\n\t\tbgscan->mgmt_rate = cpu_to_le16(RSI_RATE_1);\n\t\tbgscan->def_chan = cpu_to_le16(11);\n\t}\n\tbgscan->channel_scan_time = cpu_to_le16(RSI_CHANNEL_SCAN_TIME);\n\n\tprobereq_skb = ieee80211_probereq_get(common->priv->hw, vif->addr, ssid,\n\t\t\t\t\t      ssid_len, scan_req->ie_len);\n\tif (!probereq_skb) {\n\t\tdev_kfree_skb(skb);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemcpy(&skb->data[frame_len], probereq_skb->data, probereq_skb->len);\n\n\tbgscan->probe_req_length = cpu_to_le16(probereq_skb->len);\n\n\trsi_set_len_qno(&bgscan->desc_dword0.len_qno,\n\t\t\t(frame_len - FRAME_DESC_SZ + probereq_skb->len),\n\t\t\tRSI_WIFI_MGMT_Q);\n\n\tskb_put(skb, frame_len + probereq_skb->len);\n\n\tdev_kfree_skb(probereq_skb);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":570,"total_token_length":806,"max_tokens_setting":1024}
+{"idx":349901,"func":"static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self)\n{\n\tu32 gsr, val, rbl_status;\n\tint k;\n\n\taq_hw_write_reg(self, 0x404, 0x40e1);\n\taq_hw_write_reg(self, 0x3a0, 0x1);\n\taq_hw_write_reg(self, 0x32a8, 0x0);\n\n\t\/* Alter RBL status *\/\n\taq_hw_write_reg(self, 0x388, 0xDEAD);\n\n\t\/* Cleanup SPI *\/\n\tval = aq_hw_read_reg(self, 0x53C);\n\taq_hw_write_reg(self, 0x53C, val | 0x10);\n\n\t\/* Global software reset*\/\n\thw_atl_rx_rx_reg_res_dis_set(self, 0U);\n\thw_atl_tx_tx_reg_res_dis_set(self, 0U);\n\taq_hw_write_reg_bit(self, HW_ATL_MAC_PHY_CONTROL,\n\t\t\t    BIT(HW_ATL_MAC_PHY_MPI_RESET_BIT),\n\t\t\t    HW_ATL_MAC_PHY_MPI_RESET_BIT, 0x0);\n\tgsr = aq_hw_read_reg(self, HW_ATL_GLB_SOFT_RES_ADR);\n\taq_hw_write_reg(self, HW_ATL_GLB_SOFT_RES_ADR,\n\t\t\t(gsr & 0xFFFFBFFF) | 0x8000);\n\n\tif (FORCE_FLASHLESS)\n\t\taq_hw_write_reg(self, 0x534, 0x0);\n\n\taq_hw_write_reg(self, 0x404, 0x40e0);\n\n\t\/* Wait for RBL boot *\/\n\tfor (k = 0; k < 1000; k++) {\n\t\trbl_status = aq_hw_read_reg(self, 0x388) & 0xFFFF;\n\t\tif (rbl_status && rbl_status != 0xDEAD)\n\t\t\tbreak;\n\t\tAQ_HW_SLEEP(10);\n\t}\n\tif (!rbl_status || rbl_status == 0xDEAD) {\n\t\taq_pr_err(\"RBL Restart failed\");\n\t\treturn -EIO;\n\t}\n\n\t\/* Restore NVR *\/\n\tif (FORCE_FLASHLESS)\n\t\taq_hw_write_reg(self, 0x534, 0xA0);\n\n\tif (rbl_status == 0xF1A7) {\n\t\taq_pr_err(\"No FW detected. Dynamic FW load not implemented\\n\");\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\tfor (k = 0; k < 1000; k++) {\n\t\tu32 fw_state = aq_hw_read_reg(self, HW_ATL_MPI_FW_VERSION);\n\n\t\tif (fw_state)\n\t\t\tbreak;\n\t\tAQ_HW_SLEEP(10);\n\t}\n\tif (k == 1000) {\n\t\taq_pr_err(\"FW kickstart failed\\n\");\n\t\treturn -EIO;\n\t}\n\t\/* Old FW requires fixed delay after init *\/\n\tAQ_HW_SLEEP(15);\n\n\treturn 0;\n}","target":0,"code_token_length":651,"total_token_length":887,"max_tokens_setting":1024}
+{"idx":312540,"func":"get_mef_name(void)\n{\n    char_u\t*p;\n    char_u\t*name;\n    static int\tstart = -1;\n    static int\toff = 0;\n#ifdef HAVE_LSTAT\n    stat_T\tsb;\n#endif\n\n    if (*p_mef == NUL)\n    {\n\tname = vim_tempname('e', FALSE);\n\tif (name == NULL)\n\t    emsg(_(e_cant_get_temp_file_name));\n\treturn name;\n    }\n\n    for (p = p_mef; *p; ++p)\n\tif (p[0] == '#' && p[1] == '#')\n\t    break;\n\n    if (*p == NUL)\n\treturn vim_strsave(p_mef);\n\n    \/\/ Keep trying until the name doesn't exist yet.\n    for (;;)\n    {\n\tif (start == -1)\n\t    start = mch_get_pid();\n\telse\n\t    off += 19;\n\n\tname = alloc_id(STRLEN(p_mef) + 30, aid_qf_mef_name);\n\tif (name == NULL)\n\t    break;\n\tSTRCPY(name, p_mef);\n\tsprintf((char *)name + (p - p_mef), \"%d%d\", start, off);\n\tSTRCAT(name, p + 2);\n\tif (mch_getperm(name) < 0\n#ifdef HAVE_LSTAT\n\t\t    \/\/ Don't accept a symbolic link, it's a security risk.\n\t\t    && mch_lstat((char *)name, &sb) < 0\n#endif\n\t\t)\n\t    break;\n\tvim_free(name);\n    }\n    return name;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":238531,"func":"static void scalar32_min_max_sub(struct bpf_reg_state *dst_reg,\n\t\t\t\t struct bpf_reg_state *src_reg)\n{\n\ts32 smin_val = src_reg->s32_min_value;\n\ts32 smax_val = src_reg->s32_max_value;\n\tu32 umin_val = src_reg->u32_min_value;\n\tu32 umax_val = src_reg->u32_max_value;\n\n\tif (signed_sub32_overflows(dst_reg->s32_min_value, smax_val) ||\n\t    signed_sub32_overflows(dst_reg->s32_max_value, smin_val)) {\n\t\t\/* Overflow possible, we know nothing *\/\n\t\tdst_reg->s32_min_value = S32_MIN;\n\t\tdst_reg->s32_max_value = S32_MAX;\n\t} else {\n\t\tdst_reg->s32_min_value -= smax_val;\n\t\tdst_reg->s32_max_value -= smin_val;\n\t}\n\tif (dst_reg->u32_min_value < umax_val) {\n\t\t\/* Overflow possible, we know nothing *\/\n\t\tdst_reg->u32_min_value = 0;\n\t\tdst_reg->u32_max_value = U32_MAX;\n\t} else {\n\t\t\/* Cannot overflow (as long as bounds are consistent) *\/\n\t\tdst_reg->u32_min_value -= umax_val;\n\t\tdst_reg->u32_max_value -= umin_val;\n\t}\n}","target":0,"code_token_length":312,"total_token_length":548,"max_tokens_setting":1024}
+{"idx":418794,"func":"ins_mousescroll(int dir)\n{\n    pos_T\ttpos;\n    win_T\t*old_curwin = curwin, *wp;\n    int\t\tdid_scroll = FALSE;\n\n    tpos = curwin->w_cursor;\n\n    if (mouse_row >= 0 && mouse_col >= 0)\n    {\n\tint row, col;\n\n\trow = mouse_row;\n\tcol = mouse_col;\n\n\t\/\/ find the window at the pointer coordinates\n\twp = mouse_find_win(&row, &col, FIND_POPUP);\n\tif (wp == NULL)\n\t    return;\n\tcurwin = wp;\n\tcurbuf = curwin->w_buffer;\n    }\n    if (curwin == old_curwin)\n\tundisplay_dollar();\n\n    \/\/ Don't scroll the window in which completion is being done.\n    if (!pum_visible() || curwin != old_curwin)\n    {\n\tlong step;\n\n\tif (dir == MSCR_DOWN || dir == MSCR_UP)\n\t{\n\t    if (mouse_vert_step < 0\n\t\t    || mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))\n\t\tstep = (long)(curwin->w_botline - curwin->w_topline);\n\t    else\n\t\tstep = mouse_vert_step;\n\t    scroll_redraw(dir, step);\n# ifdef FEAT_PROP_POPUP\n\tif (WIN_IS_POPUP(curwin))\n\t    popup_set_firstline(curwin);\n# endif\n\t}\n#ifdef FEAT_GUI\n\telse\n\t{\n\t    int val;\n\n\t    if (mouse_hor_step < 0\n\t\t    || mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))\n\t\tstep = curwin->w_width;\n\t    else\n\t\tstep = mouse_hor_step;\n\t    val = curwin->w_leftcol + (dir == MSCR_RIGHT ? -step : step);\n\t    if (val < 0)\n\t\tval = 0;\n\t    gui_do_horiz_scroll(val, TRUE);\n\t}\n#endif\n\tdid_scroll = TRUE;\n\tmay_trigger_winscrolled();\n    }\n\n    curwin->w_redr_status = TRUE;\n\n    curwin = old_curwin;\n    curbuf = curwin->w_buffer;\n\n    \/\/ The popup menu may overlay the window, need to redraw it.\n    \/\/ TODO: Would be more efficient to only redraw the windows that are\n    \/\/ overlapped by the popup menu.\n    if (pum_visible() && did_scroll)\n    {\n\tredraw_all_later(UPD_NOT_VALID);\n\tins_compl_show_pum();\n    }\n\n    if (!EQUAL_POS(curwin->w_cursor, tpos))\n    {\n\tstart_arrow(&tpos);\n\tset_can_cindent(TRUE);\n    }\n}","target":0,"code_token_length":546,"total_token_length":782,"max_tokens_setting":1024}
+{"idx":486832,"func":"static void gem_reset(DeviceState *d)\n{\n    int i;\n    CadenceGEMState *s = CADENCE_GEM(d);\n    const uint8_t *a;\n    uint32_t queues_mask = 0;\n\n    DB_PRINT(\"\\n\");\n\n    \/* Set post reset register values *\/\n    memset(&s->regs[0], 0, sizeof(s->regs));\n    s->regs[GEM_NWCFG] = 0x00080000;\n    s->regs[GEM_NWSTATUS] = 0x00000006;\n    s->regs[GEM_DMACFG] = 0x00020784;\n    s->regs[GEM_IMR] = 0x07ffffff;\n    s->regs[GEM_TXPAUSE] = 0x0000ffff;\n    s->regs[GEM_TXPARTIALSF] = 0x000003ff;\n    s->regs[GEM_RXPARTIALSF] = 0x000003ff;\n    s->regs[GEM_MODID] = s->revision;\n    s->regs[GEM_DESCONF] = 0x02D00111;\n    s->regs[GEM_DESCONF2] = 0x2ab10000 | s->jumbo_max_len;\n    s->regs[GEM_DESCONF5] = 0x002f2045;\n    s->regs[GEM_DESCONF6] = GEM_DESCONF6_64B_MASK;\n    s->regs[GEM_INT_Q1_MASK] = 0x00000CE6;\n    s->regs[GEM_JUMBO_MAX_LEN] = s->jumbo_max_len;\n\n    if (s->num_priority_queues > 1) {\n        queues_mask = MAKE_64BIT_MASK(1, s->num_priority_queues - 1);\n        s->regs[GEM_DESCONF6] |= queues_mask;\n    }\n\n    \/* Set MAC address *\/\n    a = &s->conf.macaddr.a[0];\n    s->regs[GEM_SPADDR1LO] = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24);\n    s->regs[GEM_SPADDR1HI] = a[4] | (a[5] << 8);\n\n    for (i = 0; i < 4; i++) {\n        s->sar_active[i] = false;\n    }\n\n    gem_phy_reset(s);\n\n    gem_update_int_status(s);\n}","target":0,"code_token_length":576,"total_token_length":812,"max_tokens_setting":1024}
+{"idx":401507,"func":"static inline void __run_timers(struct timer_base *base)\n{\n\tstruct hlist_head heads[LVL_DEPTH];\n\tint levels;\n\n\tif (!time_after_eq(jiffies, base->clk))\n\t\treturn;\n\n\ttimer_base_lock_expiry(base);\n\traw_spin_lock_irq(&base->lock);\n\n\t\/*\n\t * timer_base::must_forward_clk must be cleared before running\n\t * timers so that any timer functions that call mod_timer() will\n\t * not try to forward the base. Idle tracking \/ clock forwarding\n\t * logic is only used with BASE_STD timers.\n\t *\n\t * The must_forward_clk flag is cleared unconditionally also for\n\t * the deferrable base. The deferrable base is not affected by idle\n\t * tracking and never forwarded, so clearing the flag is a NOOP.\n\t *\n\t * The fact that the deferrable base is never forwarded can cause\n\t * large variations in granularity for deferrable timers, but they\n\t * can be deferred for long periods due to idle anyway.\n\t *\/\n\tbase->must_forward_clk = false;\n\n\twhile (time_after_eq(jiffies, base->clk)) {\n\n\t\tlevels = collect_expired_timers(base, heads);\n\t\tbase->clk++;\n\n\t\twhile (levels--)\n\t\t\texpire_timers(base, heads + levels);\n\t}\n\traw_spin_unlock_irq(&base->lock);\n\ttimer_base_unlock_expiry(base);\n}","target":0,"code_token_length":284,"total_token_length":520,"max_tokens_setting":1024}
+{"idx":317356,"func":"static int selinux_sctp_bind_connect(struct sock *sk, int optname,\n\t\t\t\t     struct sockaddr *address,\n\t\t\t\t     int addrlen)\n{\n\tint len, err = 0, walk_size = 0;\n\tvoid *addr_buf;\n\tstruct sockaddr *addr;\n\tstruct socket *sock;\n\n\tif (!selinux_policycap_extsockclass())\n\t\treturn 0;\n\n\t\/* Process one or more addresses that may be IPv4 or IPv6 *\/\n\tsock = sk->sk_socket;\n\taddr_buf = address;\n\n\twhile (walk_size < addrlen) {\n\t\tif (walk_size + sizeof(sa_family_t) > addrlen)\n\t\t\treturn -EINVAL;\n\n\t\taddr = addr_buf;\n\t\tswitch (addr->sa_family) {\n\t\tcase AF_UNSPEC:\n\t\tcase AF_INET:\n\t\t\tlen = sizeof(struct sockaddr_in);\n\t\t\tbreak;\n\t\tcase AF_INET6:\n\t\t\tlen = sizeof(struct sockaddr_in6);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (walk_size + len > addrlen)\n\t\t\treturn -EINVAL;\n\n\t\terr = -EINVAL;\n\t\tswitch (optname) {\n\t\t\/* Bind checks *\/\n\t\tcase SCTP_PRIMARY_ADDR:\n\t\tcase SCTP_SET_PEER_PRIMARY_ADDR:\n\t\tcase SCTP_SOCKOPT_BINDX_ADD:\n\t\t\terr = selinux_socket_bind(sock, addr, len);\n\t\t\tbreak;\n\t\t\/* Connect checks *\/\n\t\tcase SCTP_SOCKOPT_CONNECTX:\n\t\tcase SCTP_PARAM_SET_PRIMARY:\n\t\tcase SCTP_PARAM_ADD_IP:\n\t\tcase SCTP_SENDMSG_CONNECT:\n\t\t\terr = selinux_socket_connect_helper(sock, addr, len);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\n\t\t\t\/* As selinux_sctp_bind_connect() is called by the\n\t\t\t * SCTP protocol layer, the socket is already locked,\n\t\t\t * therefore selinux_netlbl_socket_connect_locked()\n\t\t\t * is called here. The situations handled are:\n\t\t\t * sctp_connectx(3), sctp_sendmsg(3), sendmsg(2),\n\t\t\t * whenever a new IP address is added or when a new\n\t\t\t * primary address is selected.\n\t\t\t * Note that an SCTP connect(2) call happens before\n\t\t\t * the SCTP protocol layer and is handled via\n\t\t\t * selinux_socket_connect().\n\t\t\t *\/\n\t\t\terr = selinux_netlbl_socket_connect_locked(sk, addr);\n\t\t\tbreak;\n\t\t}\n\n\t\tif (err)\n\t\t\treturn err;\n\n\t\taddr_buf += len;\n\t\twalk_size += len;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":515,"total_token_length":751,"max_tokens_setting":1024}
+{"idx":474448,"func":"ObjectSetLoadedAttributes(\n\t\t\t  OBJECT          *object,        \/\/ IN: object attributes to finalize\n\t\t\t  TPM_HANDLE       parentHandle   \/\/ IN: the parent handle\n\t\t\t  )\n{\n    OBJECT              *parent = HandleToObject(parentHandle);\n    TPMA_OBJECT          objectAttributes = object->publicArea.objectAttributes;\n    \/\/\n    \/\/ Copy the stClear attribute from the public area. This could be overwritten\n    \/\/ if the parent has stClear SET\n    object->attributes.stClear =\n\tIS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, stClear);\n    \/\/ If parent handle is a permanent handle, it is a primary (unless it is NULL\n    if(parent == NULL)\n\t{\n\t    object->attributes.primary = SET;\n\t    switch(parentHandle)\n\t\t{\n\t\t  case TPM_RH_ENDORSEMENT:\n\t\t    object->attributes.epsHierarchy = SET;\n\t\t    break;\n\t\t  case TPM_RH_OWNER:\n\t\t    object->attributes.spsHierarchy = SET;\n\t\t    break;\n\t\t  case TPM_RH_PLATFORM:\n\t\t    object->attributes.ppsHierarchy = SET;\n\t\t    break;\n\t\t  default:\n\t\t    \/\/ Treat the temporary attribute as a hierarchy\n\t\t    object->attributes.temporary = SET;\n\t\t    object->attributes.primary = CLEAR;\n\t\t    break;\n\t\t}\n\t}\n    else\n\t{\n\t    \/\/ is this a stClear object\n\t    object->attributes.stClear =\n\t\t(IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, stClear)\n\t\t || (parent->attributes.stClear == SET));\n\t    object->attributes.epsHierarchy = parent->attributes.epsHierarchy;\n\t    object->attributes.spsHierarchy = parent->attributes.spsHierarchy;\n\t    object->attributes.ppsHierarchy = parent->attributes.ppsHierarchy;\n\t    \/\/ An object is temporary if its parent is temporary or if the object\n\t    \/\/ is external\n\t    object->attributes.temporary = parent->attributes.temporary\n\t\t\t\t\t   || object->attributes.external;\n\t}\n    \/\/ If this is an external object, set the QN == name but don't SET other\n    \/\/ key properties ('parent' or 'derived')\n    if(object->attributes.external)\n\tobject->qualifiedName = object->name;\n    else\n\t{\n\t    \/\/ check attributes for different types of parents\n\t    if(IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, restricted)\n\t       && !object->attributes.publicOnly\n\t       && IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, decrypt)\n\t       && object->publicArea.nameAlg != TPM_ALG_NULL)\n\t\t{\n\t\t    \/\/ This is a parent. If it is not a KEYEDHASH, it is an ordinary parent.\n\t\t    \/\/ Otherwise, it is a derivation parent.\n\t\t    if(object->publicArea.type == TPM_ALG_KEYEDHASH)\n\t\t\tobject->attributes.derivation = SET;\n\t\t    else\n\t\t\tobject->attributes.isParent = SET;\n\t\t}\n\t    ComputeQualifiedName(parentHandle, object->publicArea.nameAlg,\n\t\t\t\t &object->name, &object->qualifiedName);\n\t}\n    \/\/ Set slot occupied\n    ObjectSetInUse(object);\n    return;\n}","target":0,"code_token_length":618,"total_token_length":854,"max_tokens_setting":1024}
+{"idx":218815,"func":"static MagickBooleanType ReadPSDMergedImage(const ImageInfo *image_info,\n  Image* image,const PSDInfo* psd_info,ExceptionInfo *exception)\n{\n  MagickOffsetType\n    *sizes;\n\n  MagickBooleanType\n    status;\n\n  PSDCompressionType\n    compression;\n\n  ssize_t\n    i;\n\n  compression=(PSDCompressionType) ReadBlobMSBShort(image);\n  image->compression=ConvertPSDCompression(compression);\n\n  if (compression != Raw && compression != RLE)\n    {\n      (void) ThrowMagickException(exception,GetMagickModule(),\n        TypeWarning,\"CompressionNotSupported\",\"'%.20g'\",(double) compression);\n      return(MagickFalse);\n    }\n\n  sizes=(MagickOffsetType *) NULL;\n  if (compression == RLE)\n    {\n      sizes=ReadPSDRLESizes(image,psd_info,image->rows*psd_info->channels);\n      if (sizes == (MagickOffsetType *) NULL)\n        ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n          image->filename);\n    }\n\n  status=MagickTrue;\n  for (i=0; i < (ssize_t) psd_info->channels; i++)\n  {\n    ssize_t\n      type;\n\n    type=i;\n    if ((type == 1) && (psd_info->channels == 2))\n      type=-1;\n\n    if (compression == RLE)\n      status=ReadPSDChannelRLE(image,psd_info,type,sizes+(i*image->rows),\n        exception);\n    else\n      status=ReadPSDChannelRaw(image,psd_info->channels,type,exception);\n\n    if (status != MagickFalse)\n      status=SetImageProgress(image,LoadImagesTag,(MagickOffsetType) i,\n        psd_info->channels);\n\n    if (status == MagickFalse)\n      break;\n  }\n\n  if ((status != MagickFalse) && (image->colorspace == CMYKColorspace))\n    status=NegateImage(image,MagickFalse);\n\n  if (status != MagickFalse)\n    status=CorrectPSDAlphaBlend(image_info,image,exception);\n\n  sizes=(MagickOffsetType *) RelinquishMagickMemory(sizes);\n\n  return(status);\n}","target":0,"code_token_length":471,"total_token_length":707,"max_tokens_setting":1024}
+{"idx":508402,"func":"int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,\n                COND **conds)\n{\n  SELECT_LEX *select_lex= thd->lex->current_select;\n  TABLE_LIST *table= NULL;\t\/\/ For HP compilers\n  \/*\n    it_is_update set to TRUE when tables of primary SELECT_LEX (SELECT_LEX\n    which belong to LEX, i.e. most up SELECT) will be updated by\n    INSERT\/UPDATE\/LOAD\n    NOTE: using this condition helps to prevent call of prepare_check_option()\n    from subquery of VIEW, because tables of subquery belongs to VIEW\n    (see condition before prepare_check_option() call)\n  *\/\n  bool it_is_update= (select_lex == &thd->lex->select_lex) &&\n    thd->lex->which_check_option_applicable();\n  bool save_is_item_list_lookup= select_lex->is_item_list_lookup;\n  TABLE_LIST *derived= select_lex->master_unit()->derived;\n  DBUG_ENTER(\"setup_conds\");\n\n  \/* Do not fix conditions for the derived tables that have been merged *\/\n  if (derived && derived->merged)\n    DBUG_RETURN(0);\n\n  select_lex->is_item_list_lookup= 0;\n\n  thd->mark_used_columns= MARK_COLUMNS_READ;\n  DBUG_PRINT(\"info\", (\"thd->mark_used_columns: %d\", thd->mark_used_columns));\n  select_lex->cond_count= 0;\n  select_lex->between_count= 0;\n  select_lex->max_equal_elems= 0;\n\n  for (table= tables; table; table= table->next_local)\n  {\n    if (select_lex == &thd->lex->select_lex &&\n        select_lex->first_cond_optimization &&\n        table->merged_for_insert &&\n        table->prepare_where(thd, conds, FALSE))\n      goto err_no_arena;\n  }\n\n  if (*conds)\n  {\n    thd->where=\"where clause\";\n    DBUG_EXECUTE(\"where\",\n                 print_where(*conds,\n                             \"WHERE in setup_conds\",\n                             QT_ORDINARY););\n    \/*\n      Wrap alone field in WHERE clause in case it will be outer field of subquery\n      which need persistent pointer on it, but conds could be changed by optimizer\n    *\/\n    if ((*conds)->type() == Item::FIELD_ITEM && !derived)\n      wrap_ident(thd, conds);\n    (*conds)->mark_as_condition_AND_part(NO_JOIN_NEST);\n    if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||\n\t(*conds)->check_cols(1))\n      goto err_no_arena;\n  }\n\n  \/*\n    Apply fix_fields() to all ON clauses at all levels of nesting,\n    including the ones inside view definitions.\n  *\/\n  if (setup_on_expr(thd, tables, it_is_update))\n    goto err_no_arena;\n\n  if (!thd->stmt_arena->is_conventional())\n  {\n    \/*\n      We are in prepared statement preparation code => we should store\n      WHERE clause changing for next executions.\n\n      We do this ON -> WHERE transformation only once per PS\/SP statement.\n    *\/\n    select_lex->where= *conds;\n  }\n  thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;\n  DBUG_RETURN(MY_TEST(thd->is_error()));\n\nerr_no_arena:\n  select_lex->is_item_list_lookup= save_is_item_list_lookup;\n  DBUG_RETURN(1);\n}","target":0,"code_token_length":742,"total_token_length":978,"max_tokens_setting":1024}
+{"idx":437352,"func":"set_optimize_exact(regex_t* reg, OptExact* e)\n{\n  int r;\n\n  if (e->len == 0) return 0;\n\n  if (e->ignore_case) {\n    reg->exact = (UChar* )xmalloc(e->len);\n    CHECK_NULL_RETURN_MEMERR(reg->exact);\n    xmemcpy(reg->exact, e->s, e->len);\n    reg->exact_end = reg->exact + e->len;\n    reg->optimize = OPTIMIZE_STR_IC;\n  }\n  else {\n    int allow_reverse;\n\n    reg->exact = onigenc_strdup(reg->enc, e->s, e->s + e->len);\n    CHECK_NULL_RETURN_MEMERR(reg->exact);\n    reg->exact_end = reg->exact + e->len;\n\n    allow_reverse =\n      ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);\n\n    if (e->len >= 3 || (e->len >= 2 && allow_reverse)) {\n#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM\n      r = set_sunday_quick_search_skip_table(reg->exact, reg->exact_end,\n                                             reg->enc, reg->map,\n                                             &(reg->map_offset));\n#else\n      r = set_bmh_search_skip_table(reg->exact, reg->exact_end,\n                                    reg->enc, reg->map);\n#endif\n      if (r != 0) return r;\n\n      reg->optimize = (allow_reverse != 0\n                       ? OPTIMIZE_STR_FAST\n                       : OPTIMIZE_STR_FAST_STEP_FORWARD);\n    }\n    else {\n      reg->optimize = OPTIMIZE_STR;\n    }\n  }\n\n  reg->dmin = e->mmd.min;\n  reg->dmax = e->mmd.max;\n\n  if (reg->dmin != INFINITE_LEN) {\n    reg->threshold_len = reg->dmin + (int )(reg->exact_end - reg->exact);\n  }\n\n  return 0;\n}","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":450382,"func":"static int zrle_compress_data(VncState *vs, int level)\n{\n    z_streamp zstream = &vs->zrle->stream;\n\n    buffer_reset(&vs->zrle->zlib);\n\n    if (zstream->opaque != vs) {\n        int err;\n\n        zstream->zalloc = vnc_zlib_zalloc;\n        zstream->zfree = vnc_zlib_zfree;\n\n        err = deflateInit2(zstream, level, Z_DEFLATED, MAX_WBITS,\n                           MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n\n        if (err != Z_OK) {\n            fprintf(stderr, \"VNC: error initializing zlib\\n\");\n            return -1;\n        }\n\n        zstream->opaque = vs;\n    }\n\n    \/* reserve memory in output buffer *\/\n    buffer_reserve(&vs->zrle->zlib, vs->zrle->zrle.offset + 64);\n\n    \/* set pointers *\/\n    zstream->next_in = vs->zrle->zrle.buffer;\n    zstream->avail_in = vs->zrle->zrle.offset;\n    zstream->next_out = vs->zrle->zlib.buffer + vs->zrle->zlib.offset;\n    zstream->avail_out = vs->zrle->zlib.capacity - vs->zrle->zlib.offset;\n    zstream->data_type = Z_BINARY;\n\n    \/* start encoding *\/\n    if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {\n        fprintf(stderr, \"VNC: error during zrle compression\\n\");\n        return -1;\n    }\n\n    vs->zrle->zlib.offset = vs->zrle->zlib.capacity - zstream->avail_out;\n    return vs->zrle->zlib.offset;\n}","target":0,"code_token_length":385,"total_token_length":621,"max_tokens_setting":1024}
+{"idx":508382,"func":"static bool check_lock_and_start_stmt(THD *thd,\n                                      Query_tables_list *prelocking_ctx,\n                                      TABLE_LIST *table_list)\n{\n  int error;\n  thr_lock_type lock_type;\n  DBUG_ENTER(\"check_lock_and_start_stmt\");\n\n  \/*\n    Prelocking placeholder is not set for TABLE_LIST that\n    are directly used by TOP level statement.\n  *\/\n  DBUG_ASSERT(table_list->prelocking_placeholder == false);\n\n  \/*\n    TL_WRITE_DEFAULT and TL_READ_DEFAULT are supposed to be parser only\n    types of locks so they should be converted to appropriate other types\n    to be passed to storage engine. The exact lock type passed to the\n    engine is important as, for example, InnoDB uses it to determine\n    what kind of row locks should be acquired when executing statement\n    in prelocked mode or under LOCK TABLES with @@innodb_table_locks = 0.\n\n    Last argument routine_modifies_data for read_lock_type_for_table()\n    is ignored, as prelocking placeholder will never be set here.\n  *\/\n  DBUG_ASSERT(table_list->prelocking_placeholder == false);\n  if (table_list->lock_type == TL_WRITE_DEFAULT)\n    lock_type= thd->update_lock_default;\n  else if (table_list->lock_type == TL_READ_DEFAULT)\n    lock_type= read_lock_type_for_table(thd, prelocking_ctx, table_list, true);\n  else\n    lock_type= table_list->lock_type;\n\n  if ((int) lock_type > (int) TL_WRITE_ALLOW_WRITE &&\n      (int) table_list->table->reginfo.lock_type <= (int) TL_WRITE_ALLOW_WRITE)\n  {\n    my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0),\n             table_list->table->alias.c_ptr());\n    DBUG_RETURN(1);\n  }\n  if ((error= table_list->table->file->start_stmt(thd, lock_type)))\n  {\n    table_list->table->file->print_error(error, MYF(0));\n    DBUG_RETURN(1);\n  }\n\n  \/*\n    Record in transaction state tracking\n  *\/\n  TRANSACT_TRACKER(add_trx_state(thd, lock_type,\n                                 table_list->table->file->has_transactions()));\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":472,"total_token_length":708,"max_tokens_setting":1024}
+{"idx":387598,"func":"static int snd_ctl_check_elem_info(struct snd_card *card,\n\t\t\t\t   const struct snd_ctl_elem_info *info)\n{\n\tstatic const unsigned int max_value_counts[] = {\n\t\t[SNDRV_CTL_ELEM_TYPE_BOOLEAN]\t= 128,\n\t\t[SNDRV_CTL_ELEM_TYPE_INTEGER]\t= 128,\n\t\t[SNDRV_CTL_ELEM_TYPE_ENUMERATED] = 128,\n\t\t[SNDRV_CTL_ELEM_TYPE_BYTES]\t= 512,\n\t\t[SNDRV_CTL_ELEM_TYPE_IEC958]\t= 1,\n\t\t[SNDRV_CTL_ELEM_TYPE_INTEGER64] = 64,\n\t};\n\n\tif (info->type < SNDRV_CTL_ELEM_TYPE_BOOLEAN ||\n\t    info->type > SNDRV_CTL_ELEM_TYPE_INTEGER64) {\n\t\tif (card)\n\t\t\tdev_err(card->dev,\n\t\t\t\t\"control %i:%i:%i:%s:%i: invalid type %d\\n\",\n\t\t\t\tinfo->id.iface, info->id.device,\n\t\t\t\tinfo->id.subdevice, info->id.name,\n\t\t\t\tinfo->id.index, info->type);\n\t\treturn -EINVAL;\n\t}\n\tif (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED &&\n\t    info->value.enumerated.items == 0) {\n\t\tif (card)\n\t\t\tdev_err(card->dev,\n\t\t\t\t\"control %i:%i:%i:%s:%i: zero enum items\\n\",\n\t\t\t\tinfo->id.iface, info->id.device,\n\t\t\t\tinfo->id.subdevice, info->id.name,\n\t\t\t\tinfo->id.index);\n\t\treturn -EINVAL;\n\t}\n\tif (info->count > max_value_counts[info->type]) {\n\t\tif (card)\n\t\t\tdev_err(card->dev,\n\t\t\t\t\"control %i:%i:%i:%s:%i: invalid count %d\\n\",\n\t\t\t\tinfo->id.iface, info->id.device,\n\t\t\t\tinfo->id.subdevice, info->id.name,\n\t\t\t\tinfo->id.index, info->count);\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":433,"total_token_length":669,"max_tokens_setting":1024}
+{"idx":317218,"func":"static unsigned int selinux_ip_output(struct sk_buff *skb,\n\t\t\t\t      u16 family)\n{\n\tstruct sock *sk;\n\tu32 sid;\n\n\tif (!netlbl_enabled())\n\t\treturn NF_ACCEPT;\n\n\t\/* we do this in the LOCAL_OUT path and not the POST_ROUTING path\n\t * because we want to make sure we apply the necessary labeling\n\t * before IPsec is applied so we can leverage AH protection *\/\n\tsk = skb->sk;\n\tif (sk) {\n\t\tstruct sk_security_struct *sksec;\n\n\t\tif (sk_listener(sk))\n\t\t\t\/* if the socket is the listening state then this\n\t\t\t * packet is a SYN-ACK packet which means it needs to\n\t\t\t * be labeled based on the connection\/request_sock and\n\t\t\t * not the parent socket.  unfortunately, we can't\n\t\t\t * lookup the request_sock yet as it isn't queued on\n\t\t\t * the parent socket until after the SYN-ACK is sent.\n\t\t\t * the \"solution\" is to simply pass the packet as-is\n\t\t\t * as any IP option based labeling should be copied\n\t\t\t * from the initial connection request (in the IP\n\t\t\t * layer).  it is far from ideal, but until we get a\n\t\t\t * security label in the packet itself this is the\n\t\t\t * best we can do. *\/\n\t\t\treturn NF_ACCEPT;\n\n\t\t\/* standard practice, label using the parent socket *\/\n\t\tsksec = sk->sk_security;\n\t\tsid = sksec->sid;\n\t} else\n\t\tsid = SECINITSID_KERNEL;\n\tif (selinux_netlbl_skbuff_setsid(skb, family, sid) != 0)\n\t\treturn NF_DROP;\n\n\treturn NF_ACCEPT;\n}","target":0,"code_token_length":353,"total_token_length":589,"max_tokens_setting":1024}
+{"idx":446405,"func":"static ut64 estimate_slide(RzDyldCache *cache, ut64 value_mask, ut64 value_add) {\n\tut64 slide = 0;\n\tif (cache->n_hdr > 1) {\n\t\treturn slide;\n\t}\n\tut64 *classlist = malloc(64);\n\tif (!classlist) {\n\t\tgoto beach;\n\t}\n\n\tRzListIter *iter;\n\tRzDyldBinImage *bin;\n\trz_list_foreach (cache->bins, iter, bin) {\n\t\tbool found_sample = false;\n\n\t\tstruct MACH0_(opts_t) opts = { 0 };\n\t\topts.header_at = bin->header_at;\n\n\t\tstruct MACH0_(obj_t) *mach0 = MACH0_(new_buf)(cache->buf, &opts);\n\t\tif (!mach0) {\n\t\t\tgoto beach;\n\t\t}\n\n\t\tstruct section_t *sections = NULL;\n\t\tif (!(sections = MACH0_(get_sections)(mach0))) {\n\t\t\tMACH0_(mach0_free)\n\t\t\t(mach0);\n\t\t\tgoto beach;\n\t\t}\n\n\t\tint i;\n\t\tint incomplete = 2;\n\t\tint classlist_idx = 0, data_idx = 0;\n\t\tfor (i = 0; !sections[i].last && incomplete; i++) {\n\t\t\tif (sections[i].size == 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (strstr(sections[i].name, \"__objc_classlist\")) {\n\t\t\t\tincomplete--;\n\t\t\t\tclasslist_idx = i;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (strstr(sections[i].name, \"__objc_data\")) {\n\t\t\t\tincomplete--;\n\t\t\t\tdata_idx = i;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (incomplete) {\n\t\t\tgoto next_bin;\n\t\t}\n\n\t\tint classlist_sample_size = RZ_MIN(64, sections[classlist_idx].size);\n\t\tint n_classes = classlist_sample_size \/ 8;\n\t\tut64 sect_offset = sections[classlist_idx].offset + bin->hdr_offset;\n\n\t\tif (rz_buf_fread_at(cache->buf, sect_offset, (ut8 *)classlist, \"l\", n_classes) < classlist_sample_size) {\n\t\t\tgoto next_bin;\n\t\t}\n\n\t\tut64 data_addr = sections[data_idx].addr;\n\t\tut64 data_tail = data_addr & 0xfff;\n\t\tut64 data_tail_end = (data_addr + sections[data_idx].size) & 0xfff;\n\t\tfor (i = 0; i < n_classes; i++) {\n\t\t\tut64 cl_addr = (classlist[i] & value_mask) + value_add;\n\t\t\tut64 cl_tail = cl_addr & 0xfff;\n\t\t\tif (cl_tail >= data_tail && cl_tail < data_tail_end) {\n\t\t\t\tut64 off = cl_tail - data_tail;\n\t\t\t\tslide = ((cl_addr - off) & value_mask) - (data_addr & value_mask);\n\t\t\t\tfound_sample = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\tnext_bin:\n\t\tMACH0_(mach0_free)\n\t\t(mach0);\n\t\tfree(sections);\n\n\t\tif (found_sample) {\n\t\t\tbreak;\n\t\t}\n\t}\n\nbeach:\n\tfree(classlist);\n\treturn slide;\n}","target":0,"code_token_length":694,"total_token_length":930,"max_tokens_setting":1024}
+{"idx":437282,"func":"noname_disable_map(Node** plink, GroupNumRemap* map, int* counter)\n{\n  int r = 0;\n  Node* node = *plink;\n\n  switch (NODE_TYPE(node)) {\n  case NODE_LIST:\n  case NODE_ALT:\n    do {\n      r = noname_disable_map(&(NODE_CAR(node)), map, counter);\n    } while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));\n    break;\n\n  case NODE_QUANT:\n    {\n      Node** ptarget = &(NODE_BODY(node));\n      Node*  old = *ptarget;\n      r = noname_disable_map(ptarget, map, counter);\n      if (*ptarget != old && NODE_TYPE(*ptarget) == NODE_QUANT) {\n        onig_reduce_nested_quantifier(node, *ptarget);\n      }\n    }\n    break;\n\n  case NODE_ENCLOSURE:\n    {\n      EnclosureNode* en = ENCLOSURE_(node);\n      if (en->type == ENCLOSURE_MEMORY) {\n        if (NODE_IS_NAMED_GROUP(node)) {\n          (*counter)++;\n          map[en->m.regnum].new_val = *counter;\n          en->m.regnum = *counter;\n          r = noname_disable_map(&(NODE_BODY(node)), map, counter);\n        }\n        else {\n          *plink = NODE_BODY(node);\n          NODE_BODY(node) = NULL_NODE;\n          onig_node_free(node);\n          r = noname_disable_map(plink, map, counter);\n        }\n      }\n      else if (en->type == ENCLOSURE_IF_ELSE) {\n        r = noname_disable_map(&(NODE_ENCLOSURE_BODY(en)), map, counter);\n        if (r != 0) return r;\n        if (IS_NOT_NULL(en->te.Then)) {\n          r = noname_disable_map(&(en->te.Then), map, counter);\n          if (r != 0) return r;\n        }\n        if (IS_NOT_NULL(en->te.Else)) {\n          r = noname_disable_map(&(en->te.Else), map, counter);\n          if (r != 0) return r;\n        }\n      }\n      else\n        r = noname_disable_map(&(NODE_BODY(node)), map, counter);\n    }\n    break;\n\n  case NODE_ANCHOR:\n    if (IS_NOT_NULL(NODE_BODY(node)))\n      r = noname_disable_map(&(NODE_BODY(node)), map, counter);\n    break;\n\n  default:\n    break;\n  }\n\n  return r;\n}","target":0,"code_token_length":526,"total_token_length":762,"max_tokens_setting":1024}
+{"idx":252424,"func":"static void DecodeTiledPixelData(\n    unsigned char **out_images, int *width, int *height,\n    const int *requested_pixel_types, const unsigned char *data_ptr,\n    size_t data_len, int compression_type, int line_order, int data_width,\n    int data_height, int tile_offset_x, int tile_offset_y, int tile_size_x,\n    int tile_size_y, size_t pixel_data_size, size_t num_attributes,\n    const EXRAttribute *attributes, size_t num_channels,\n    const EXRChannelInfo *channels,\n    const std::vector<size_t> &channel_offset_list) {\n  assert(tile_offset_x * tile_size_x < data_width);\n  assert(tile_offset_y * tile_size_y < data_height);\n\n  \/\/ Compute actual image size in a tile.\n  if ((tile_offset_x + 1) * tile_size_x >= data_width) {\n    (*width) = data_width - (tile_offset_x * tile_size_x);\n  } else {\n    (*width) = tile_size_x;\n  }\n\n  if ((tile_offset_y + 1) * tile_size_y >= data_height) {\n    (*height) = data_height - (tile_offset_y * tile_size_y);\n  } else {\n    (*height) = tile_size_y;\n  }\n\n  \/\/ Image size = tile size.\n  DecodePixelData(out_images, requested_pixel_types, data_ptr, data_len,\n                  compression_type, line_order, (*width), tile_size_y,\n                  \/* stride *\/ tile_size_x, \/* y *\/ 0, \/* line_no *\/ 0,\n                  (*height), pixel_data_size, num_attributes, attributes,\n                  num_channels, channels, channel_offset_list);\n}","target":0,"code_token_length":351,"total_token_length":587,"max_tokens_setting":1024}
+{"idx":195026,"func":"nfs4_file_open(struct inode *inode, struct file *filp)\n{\n\tstruct nfs_open_context *ctx;\n\tstruct dentry *dentry = file_dentry(filp);\n\tstruct dentry *parent = NULL;\n\tstruct inode *dir;\n\tunsigned openflags = filp->f_flags;\n\tstruct iattr attr;\n\tint err;\n\n\t\/*\n\t * If no cached dentry exists or if it's negative, NFSv4 handled the\n\t * opens in ->lookup() or ->create().\n\t *\n\t * We only get this far for a cached positive dentry.  We skipped\n\t * revalidation, so handle it here by dropping the dentry and returning\n\t * -EOPENSTALE.  The VFS will retry the lookup\/create\/open.\n\t *\/\n\n\tdprintk(\"NFS: open file(%pd2)\\n\", dentry);\n\n\terr = nfs_check_flags(openflags);\n\tif (err)\n\t\treturn err;\n\n\tif ((openflags & O_ACCMODE) == 3)\n\t\treturn nfs_open(inode, filp);\n\n\t\/* We can't create new files here *\/\n\topenflags &= ~(O_CREAT|O_EXCL);\n\n\tparent = dget_parent(dentry);\n\tdir = d_inode(parent);\n\n\tctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp);\n\terr = PTR_ERR(ctx);\n\tif (IS_ERR(ctx))\n\t\tgoto out;\n\n\tattr.ia_valid = ATTR_OPEN;\n\tif (openflags & O_TRUNC) {\n\t\tattr.ia_valid |= ATTR_SIZE;\n\t\tattr.ia_size = 0;\n\t\tfilemap_write_and_wait(inode->i_mapping);\n\t}\n\n\tinode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr, NULL);\n\tif (IS_ERR(inode)) {\n\t\terr = PTR_ERR(inode);\n\t\tswitch (err) {\n\t\tdefault:\n\t\t\tgoto out_put_ctx;\n\t\tcase -ENOENT:\n\t\tcase -ESTALE:\n\t\tcase -EISDIR:\n\t\tcase -ENOTDIR:\n\t\tcase -ELOOP:\n\t\t\tgoto out_drop;\n\t\t}\n\t}\n\tif (inode != d_inode(dentry))\n\t\tgoto out_drop;\n\n\tnfs_file_set_open_context(filp, ctx);\n\tnfs_fscache_open_file(inode, filp);\n\terr = 0;\n\nout_put_ctx:\n\tput_nfs_open_context(ctx);\nout:\n\tdput(parent);\n\treturn err;\n\nout_drop:\n\td_drop(dentry);\n\terr = -EOPENSTALE;\n\tgoto out_put_ctx;\n}","target":1,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":402626,"func":"generate_signed_attributes(cms_context *cms, SECItem *sattrs)\n{\n\tAttribute *attrs[5];\n\tmemset(attrs, '\\0', sizeof (attrs));\n\n\tSECItem encoded;\n\tSECOidTag tag;\n\tSECOidData *oid;\n\n\t\/* build the first attribute, which says we have no S\/MIME\n\t * capabilities whatsoever *\/\n\tattrs[0] = PORT_ArenaZAlloc(cms->arena, sizeof (Attribute));\n\tif (!attrs[0])\n\t\tgoto err;\n\n\toid = SECOID_FindOIDByTag(SEC_OID_PKCS9_SMIME_CAPABILITIES);\n\tattrs[0]->attrType = oid->oid;\n\n\tSECItem *smime_caps[2] = { NULL, NULL};\n\tif (generate_empty_sequence(cms, &encoded) < 0)\n\t\tgoto err;\n\tsmime_caps[0] = SECITEM_ArenaDupItem(cms->arena, &encoded);\n\tattrs[0]->attrValues = smime_caps;\n\n\t\/* build the second attribute, which says that this is\n\t * a PKCS9 content blob thingy *\/\n\tattrs[1] = PORT_ArenaZAlloc(cms->arena, sizeof (Attribute));\n\tif (!attrs[1])\n\t\tgoto err;\n\n\toid = SECOID_FindOIDByTag(SEC_OID_PKCS9_CONTENT_TYPE);\n\tattrs[1]->attrType = oid->oid;\n\n\tSECItem *content_types[2] = { NULL, NULL };\n\ttag = find_ms_oid_tag(SPC_INDIRECT_DATA_OBJID);\n\tif (tag == SEC_OID_UNKNOWN)\n\t\tgoto err;\n\tif (generate_object_id(cms, &encoded, tag) < 0)\n\t\tgoto err;\n\tcontent_types[0] = SECITEM_ArenaDupItem(cms->arena, &encoded);\n\tif (!content_types[0])\n\t\tgoto err;\n\tattrs[1]->attrValues = content_types;\n\n\t\/* build the third attribute.  This is our signing time. *\/\n\tattrs[2] = PORT_ArenaZAlloc(cms->arena, sizeof (Attribute));\n\tif (!attrs[2])\n\t\tgoto err;\n\n\toid = SECOID_FindOIDByTag(SEC_OID_PKCS9_SIGNING_TIME);\n\tattrs[2]->attrType = oid->oid;\n\n\tSECItem *signing_time[2] = { NULL, NULL };\n\tif (generate_time(cms, &encoded, time(NULL)) < 0)\n\t\tgoto err;\n\tsigning_time[0] = SECITEM_ArenaDupItem(cms->arena, &encoded);\n\tif (!signing_time[0])\n\t\tgoto err;\n\tattrs[2]->attrValues = signing_time;\n\n\t\/* build the fourth attribute, which is our PKCS9 message\n\t * digest (which is a SHA-whatever selected and generated elsewhere *\/\n\tattrs[3] = PORT_ArenaZAlloc(cms->arena, sizeof (Attribute));\n\tif (!attrs[3])\n\t\tgoto err;\n\n\toid = SECOID_FindOIDByTag(SEC_OID_PKCS9_MESSAGE_DIGEST);\n\tattrs[3]->attrType = oid->oid;\n\n\tSECItem *digest_values[2] = { NULL, NULL };\n\tif (generate_octet_string(cms, &encoded, cms->ci_digest) < 0)\n\t\tgoto err;\n\tdigest_values[0] = SECITEM_ArenaDupItem(cms->arena, &encoded);\n\tif (!digest_values[0])\n\t\tgoto err;\n\tattrs[3]->attrValues = digest_values;\n\n\tAttribute **attrtmp = attrs;\n\tif (SEC_ASN1EncodeItem(cms->arena, sattrs, &attrtmp,\n\t\t\t\tAttributeSetTemplate) == NULL)\n\t\tgoto err;\n\treturn 0;\nerr:\n\treturn -1;\n}","target":0,"code_token_length":779,"total_token_length":1015,"max_tokens_setting":1024}
+{"idx":457876,"func":"load_cache (GeglProperties *op_magick_load)\n{\n  if (!op_magick_load->user_data)\n    {\n      gchar    *filename;\n      GeglNode *graph, *sink, *loader;\n      GeglBuffer *newbuf = NULL;\n\n      \/* ImageMagick backed fallback FIXME: make this robust.\n       * maybe use pipes in a manner similar to the raw loader,\n       * or at least use a properly unique filename  *\/\n      char     *argv[4]  = {\"convert\", NULL, NULL, NULL};\n\n      filename = g_build_filename (g_get_tmp_dir (), \"gegl-magick.png\", NULL);\n\n      argv[1] = g_strdup_printf (\"%s[0]\", op_magick_load->path);\n      argv[2] = filename;\n      if (!g_spawn_sync (NULL, argv, NULL, G_SPAWN_DEFAULT, \n                         NULL, NULL, NULL, NULL, NULL, NULL))\n        g_warning (\"Error executing ImageMagick convert program\");\n\n      g_free (argv[1]);\n\n      graph = gegl_node_new ();\n      sink = gegl_node_new_child (graph,\n                                 \"operation\", \"gegl:buffer-sink\",\n                                 \"buffer\", &newbuf, NULL);\n      loader = gegl_node_new_child (graph,\n                                    \"operation\", \"gegl:png-load\",\n                                    \"path\", filename, NULL);\n      gegl_node_link_many (loader, sink, NULL);\n      gegl_node_process (sink);\n      op_magick_load->user_data = (gpointer) newbuf;\n      g_object_unref (graph);\n      g_free (filename);\n    }\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":314772,"func":"cdf_swap_header(cdf_header_t *h)\n{\n\tsize_t i;\n\n\th->h_magic = CDF_TOLE8(h->h_magic);\n\th->h_uuid[0] = CDF_TOLE8(h->h_uuid[0]);\n\th->h_uuid[1] = CDF_TOLE8(h->h_uuid[1]);\n\th->h_revision = CDF_TOLE2(h->h_revision);\n\th->h_version = CDF_TOLE2(h->h_version);\n\th->h_byte_order = CDF_TOLE2(h->h_byte_order);\n\th->h_sec_size_p2 = CDF_TOLE2(h->h_sec_size_p2);\n\th->h_short_sec_size_p2 = CDF_TOLE2(h->h_short_sec_size_p2);\n\th->h_num_sectors_in_sat = CDF_TOLE4(h->h_num_sectors_in_sat);\n\th->h_secid_first_directory = CDF_TOLE4(h->h_secid_first_directory);\n\th->h_min_size_standard_stream =\n\t    CDF_TOLE4(h->h_min_size_standard_stream);\n\th->h_secid_first_sector_in_short_sat =\n\t    CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_short_sat);\n\th->h_num_sectors_in_short_sat =\n\t    CDF_TOLE4(h->h_num_sectors_in_short_sat);\n\th->h_secid_first_sector_in_master_sat =\n\t    CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_master_sat);\n\th->h_num_sectors_in_master_sat =\n\t    CDF_TOLE4(h->h_num_sectors_in_master_sat);\n\tfor (i = 0; i < __arraycount(h->h_master_sat); i++)\n\t\th->h_master_sat[i] = CDF_TOLE4((uint32_t)h->h_master_sat[i]);\n}","target":0,"code_token_length":395,"total_token_length":631,"max_tokens_setting":1024}
+{"idx":333046,"func":"nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent)\n{\n    char_u  *p;\n\n    if (state == NULL)\n\treturn;\n\n    fprintf(debugf, \"(%2d)\", abs(state->id));\n\n    \/\/ Output indent\n    p = (char_u *)indent->ga_data;\n    if (indent->ga_len >= 3)\n    {\n\tint\tlast = indent->ga_len - 3;\n\tchar_u\tsave[2];\n\n\tSTRNCPY(save, &p[last], 2);\n\tSTRNCPY(&p[last], \"+-\", 2);\n\tfprintf(debugf, \" %s\", p);\n\tSTRNCPY(&p[last], save, 2);\n    }\n    else\n\tfprintf(debugf, \" %s\", p);\n\n    nfa_set_code(state->c);\n    fprintf(debugf, \"%s (%d) (id=%d) val=%d\\n\",\n\t\t code,\n\t\t state->c,\n\t\t abs(state->id),\n\t\t state->val);\n    if (state->id < 0)\n\treturn;\n\n    state->id = abs(state->id) * -1;\n\n    \/\/ grow indent for state->out\n    indent->ga_len -= 1;\n    if (state->out1)\n\tga_concat(indent, (char_u *)\"| \");\n    else\n\tga_concat(indent, (char_u *)\"  \");\n    ga_append(indent, '\\0');\n\n    nfa_print_state2(debugf, state->out, indent);\n\n    \/\/ replace last part of indent for state->out1\n    indent->ga_len -= 3;\n    ga_concat(indent, (char_u *)\"  \");\n    ga_append(indent, '\\0');\n\n    nfa_print_state2(debugf, state->out1, indent);\n\n    \/\/ shrink indent\n    indent->ga_len -= 3;\n    ga_append(indent, '\\0');\n}","target":0,"code_token_length":397,"total_token_length":633,"max_tokens_setting":1024}
+{"idx":405392,"func":"static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir)\n{\n\tstruct xfrm_policy *newp = xfrm_policy_alloc(xp_net(old), GFP_ATOMIC);\n\tstruct net *net = xp_net(old);\n\n\tif (newp) {\n\t\tnewp->selector = old->selector;\n\t\tif (security_xfrm_policy_clone(old->security,\n\t\t\t\t\t       &newp->security)) {\n\t\t\tkfree(newp);\n\t\t\treturn NULL;  \/* ENOMEM *\/\n\t\t}\n\t\tnewp->lft = old->lft;\n\t\tnewp->curlft = old->curlft;\n\t\tnewp->mark = old->mark;\n\t\tnewp->if_id = old->if_id;\n\t\tnewp->action = old->action;\n\t\tnewp->flags = old->flags;\n\t\tnewp->xfrm_nr = old->xfrm_nr;\n\t\tnewp->index = old->index;\n\t\tnewp->type = old->type;\n\t\tnewp->family = old->family;\n\t\tmemcpy(newp->xfrm_vec, old->xfrm_vec,\n\t\t       newp->xfrm_nr*sizeof(struct xfrm_tmpl));\n\t\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\t\txfrm_sk_policy_link(newp, dir);\n\t\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\t\txfrm_pol_put(newp);\n\t}\n\treturn newp;\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":476132,"func":"static int composite_bind(struct usb_gadget *gadget,\n\t\tstruct usb_gadget_driver *gdriver)\n{\n\tstruct usb_composite_dev\t*cdev;\n\tstruct usb_composite_driver\t*composite = to_cdriver(gdriver);\n\tint\t\t\t\tstatus = -ENOMEM;\n\n\tcdev = kzalloc(sizeof *cdev, GFP_KERNEL);\n\tif (!cdev)\n\t\treturn status;\n\n\tspin_lock_init(&cdev->lock);\n\tcdev->gadget = gadget;\n\tset_gadget_data(gadget, cdev);\n\tINIT_LIST_HEAD(&cdev->configs);\n\tINIT_LIST_HEAD(&cdev->gstrings);\n\n\tstatus = composite_dev_prepare(composite, cdev);\n\tif (status)\n\t\tgoto fail;\n\n\t\/* composite gadget needs to assign strings for whole device (like\n\t * serial number), register function drivers, potentially update\n\t * power state and consumption, etc\n\t *\/\n\tstatus = composite->bind(cdev);\n\tif (status < 0)\n\t\tgoto fail;\n\n\tif (cdev->use_os_string) {\n\t\tstatus = composite_os_desc_req_prepare(cdev, gadget->ep0);\n\t\tif (status)\n\t\t\tgoto fail;\n\t}\n\n\tupdate_unchanged_dev_desc(&cdev->desc, composite->dev);\n\n\t\/* has userspace failed to provide a serial number? *\/\n\tif (composite->needs_serial && !cdev->desc.iSerialNumber)\n\t\tWARNING(cdev, \"userspace failed to provide iSerialNumber\\n\");\n\n\tINFO(cdev, \"%s ready\\n\", composite->name);\n\treturn 0;\n\nfail:\n\t__composite_unbind(gadget, false);\n\treturn status;\n}","target":0,"code_token_length":332,"total_token_length":568,"max_tokens_setting":1024}
+{"idx":379324,"func":"do_exmode(\n    int\t\timproved)\t    \/\/ TRUE for \"improved Ex\" mode\n{\n    int\t\tsave_msg_scroll;\n    int\t\tprev_msg_row;\n    linenr_T\tprev_line;\n    varnumber_T\tchangedtick;\n\n    if (improved)\n\texmode_active = EXMODE_VIM;\n    else\n\texmode_active = EXMODE_NORMAL;\n    State = MODE_NORMAL;\n    may_trigger_modechanged();\n\n    \/\/ When using \":global \/pat\/ visual\" and then \"Q\" we return to continue\n    \/\/ the :global command.\n    if (global_busy)\n\treturn;\n\n    save_msg_scroll = msg_scroll;\n    ++RedrawingDisabled;\t    \/\/ don't redisplay the window\n    ++no_wait_return;\t\t    \/\/ don't wait for return\n#ifdef FEAT_GUI\n    \/\/ Ignore scrollbar and mouse events in Ex mode\n    ++hold_gui_events;\n#endif\n\n    msg(_(\"Entering Ex mode.  Type \\\"visual\\\" to go to Normal mode.\"));\n    while (exmode_active)\n    {\n\t\/\/ Check for a \":normal\" command and no more characters left.\n\tif (ex_normal_busy > 0 && typebuf.tb_len == 0)\n\t{\n\t    exmode_active = FALSE;\n\t    break;\n\t}\n\tmsg_scroll = TRUE;\n\tneed_wait_return = FALSE;\n\tex_pressedreturn = FALSE;\n\tex_no_reprint = FALSE;\n\tchangedtick = CHANGEDTICK(curbuf);\n\tprev_msg_row = msg_row;\n\tprev_line = curwin->w_cursor.lnum;\n\tif (improved)\n\t{\n\t    cmdline_row = msg_row;\n\t    do_cmdline(NULL, getexline, NULL, 0);\n\t}\n\telse\n\t    do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT);\n\tlines_left = Rows - 1;\n\n\tif ((prev_line != curwin->w_cursor.lnum\n\t\t   || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint)\n\t{\n\t    if (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t\temsg(_(e_empty_buffer));\n\t    else\n\t    {\n\t\tif (ex_pressedreturn)\n\t\t{\n\t\t    \/\/ go up one line, to overwrite the \":<CR>\" line, so the\n\t\t    \/\/ output doesn't contain empty lines.\n\t\t    msg_row = prev_msg_row;\n\t\t    if (prev_msg_row == Rows - 1)\n\t\t\tmsg_row--;\n\t\t}\n\t\tmsg_col = 0;\n\t\tprint_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE);\n\t\tmsg_clr_eos();\n\t    }\n\t}\n\telse if (ex_pressedreturn && !ex_no_reprint)\t\/\/ must be at EOF\n\t{\n\t    if (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t\temsg(_(e_empty_buffer));\n\t    else\n\t\temsg(_(e_at_end_of_file));\n\t}\n    }\n\n#ifdef FEAT_GUI\n    --hold_gui_events;\n#endif\n    --RedrawingDisabled;\n    --no_wait_return;\n    update_screen(CLEAR);\n    need_wait_return = FALSE;\n    msg_scroll = save_msg_scroll;\n}","target":0,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":197223,"func":"njs_module_path(njs_vm_t *vm, const njs_str_t *dir, njs_module_info_t *info)\n{\n    char        *p;\n    size_t      length;\n    njs_bool_t  trail;\n    char        src[NJS_MAX_PATH + 1];\n\n    trail = 0;\n    length = info->name.length;\n\n    if (dir != NULL) {\n        length = dir->length;\n\n        if (length == 0) {\n            return NJS_DECLINED;\n        }\n\n        trail = (dir->start[dir->length - 1] != '\/');\n\n        if (trail) {\n            length++;\n        }\n    }\n\n    if (njs_slow_path(length > NJS_MAX_PATH)) {\n        return NJS_ERROR;\n    }\n\n    p = &src[0];\n\n    if (dir != NULL) {\n        p = (char *) njs_cpymem(p, dir->start, dir->length);\n\n        if (trail) {\n            *p++ = '\/';\n        }\n    }\n\n    p = (char *) njs_cpymem(p, info->name.start, info->name.length);\n    *p = '\\0';\n\n    p = realpath(&src[0], &info->path[0]);\n    if (p == NULL) {\n        return NJS_DECLINED;\n    }\n\n    info->fd = open(&info->path[0], O_RDONLY);\n    if (info->fd < 0) {\n        return NJS_DECLINED;\n    }\n\n\n    info->file.start = (u_char *) &info->path[0];\n    info->file.length = njs_strlen(info->file.start);\n\n    return NJS_OK;\n}","target":1,"code_token_length":350,"total_token_length":586,"max_tokens_setting":1024}
+{"idx":413819,"func":"Method* LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) {\n\n  Klass* resolved_klass = link_info.resolved_klass();\n\n  \/\/ check if klass is interface\n  if (!resolved_klass->is_interface()) {\n    ResourceMark rm(THREAD);\n    char buf[200];\n    jio_snprintf(buf, sizeof(buf), \"Found class %s, but interface was expected\", resolved_klass->external_name());\n    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);\n  }\n\n  \/\/ check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref\n  if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"Method '\");\n    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());\n    ss.print(\"' must be InterfaceMethodref constant\");\n    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n\n  \/\/ lookup method in this interface or its super, java.lang.Object\n  \/\/ JDK8: also look for static methods\n  methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true));\n\n  if (resolved_method.is_null() && !resolved_klass->is_array_klass()) {\n    \/\/ lookup method in all the super-interfaces\n    resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info));\n  }\n\n  if (resolved_method.is_null()) {\n    \/\/ no method found\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"'\");\n    Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());\n    ss.print(\"'\");\n    THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), ss.as_string());\n  }\n\n  if (link_info.check_access()) {\n    \/\/ JDK8 adds non-public interface methods, and accessability check requirement\n    Klass* current_klass = link_info.current_klass();\n\n    assert(current_klass != NULL , \"current_klass should not be null\");\n\n    \/\/ check if method can be accessed by the referring class\n    check_method_accessability(current_klass,\n                               resolved_klass,\n                               resolved_method->method_holder(),\n                               resolved_method,\n                               CHECK_NULL);\n  }\n  if (link_info.check_loader_constraints()) {\n    check_method_loader_constraints(link_info, resolved_method, \"interface method\", CHECK_NULL);\n  }\n\n  if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"Expected instance not static method '\");\n    Method::print_external_name(&ss, resolved_klass,\n                                resolved_method->name(), resolved_method->signature());\n    ss.print(\"'\");\n    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n\n  if (log_develop_is_enabled(Trace, itables)) {\n    char buf[200];\n    jio_snprintf(buf, sizeof(buf), \"%s resolved interface method: caller-class:\",\n                 Bytecodes::name(code));\n    trace_method_resolution(buf, link_info.current_klass(), resolved_klass, resolved_method(), true);\n  }\n\n  return resolved_method();\n}","target":0,"code_token_length":707,"total_token_length":943,"max_tokens_setting":1024}
+{"idx":513140,"func":"static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)\n{\n  char buffer[FN_REFLEN];\n  LEX_STRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name;\n  char *p= buffer;\n  DBUG_ENTER(\"plugin_load_list\");\n  while (list)\n  {\n    if (p == buffer + sizeof(buffer) - 1)\n    {\n      sql_print_error(\"plugin-load parameter too long\");\n      DBUG_RETURN(TRUE);\n    }\n\n    switch ((*(p++)= *(list++))) {\n    case '\\0':\n      list= NULL; \/* terminate the loop *\/\n      \/* fall through *\/\n    case ';':\n#ifndef __WIN__\n    case ':':     \/* can't use this as delimiter as it may be drive letter *\/\n#endif\n      str->str[str->length]= '\\0';\n      if (str == &name)  \/\/ load all plugins in named module\n      {\n        if (!name.length)\n        {\n          p--;    \/* reset pointer *\/\n          continue;\n        }\n\n        dl= name;\n        mysql_mutex_lock(&LOCK_plugin);\n        free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));\n        name.str= 0; \/\/ load everything\n        if (plugin_add(tmp_root, &name, &dl, REPORT_TO_LOG))\n          goto error;\n      }\n      else\n      {\n        free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));\n        mysql_mutex_lock(&LOCK_plugin);\n        if (plugin_add(tmp_root, &name, &dl, REPORT_TO_LOG))\n          goto error;\n      }\n      mysql_mutex_unlock(&LOCK_plugin);\n      name.length= dl.length= 0;\n      dl.str= NULL; name.str= p= buffer;\n      str= &name;\n      continue;\n    case '=':\n    case '#':\n      if (str == &name)\n      {\n        name.str[name.length]= '\\0';\n        str= &dl;\n        str->str= p;\n        continue;\n      }\n      \/* fall through *\/\n    default:\n      str->length++;\n      continue;\n    }\n  }\n  DBUG_RETURN(FALSE);\nerror:\n  mysql_mutex_unlock(&LOCK_plugin);\n  if (name.str)\n    sql_print_error(\"Couldn't load plugin '%s' from '%s'.\",\n                    name.str, dl.str);\n  else\n    sql_print_error(\"Couldn't load plugins from '%s'.\", dl.str);\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":513,"total_token_length":749,"max_tokens_setting":1024}
+{"idx":259535,"func":"static CURLUcode hostname_check(struct Curl_URL *u, char *hostname)\n{\n  size_t len;\n  size_t hlen = strlen(hostname);\n\n  if(hostname[0] == '[') {\n    const char *l = \"0123456789abcdefABCDEF:.\";\n    if(hlen < 4) \/* '[::]' is the shortest possible valid string *\/\n      return CURLUE_BAD_IPV6;\n    hostname++;\n    hlen -= 2;\n\n    if(hostname[hlen] != ']')\n      return CURLUE_BAD_IPV6;\n\n    \/* only valid letters are ok *\/\n    len = strspn(hostname, l);\n    if(hlen != len) {\n      hlen = len;\n      if(hostname[len] == '%') {\n        \/* this could now be '%[zone id]' *\/\n        char zoneid[16];\n        int i = 0;\n        char *h = &hostname[len + 1];\n        \/* pass '25' if present and is a url encoded percent sign *\/\n        if(!strncmp(h, \"25\", 2) && h[2] && (h[2] != ']'))\n          h += 2;\n        while(*h && (*h != ']') && (i < 15))\n          zoneid[i++] = *h++;\n        if(!i || (']' != *h))\n          \/* impossible to reach? *\/\n          return CURLUE_MALFORMED_INPUT;\n        zoneid[i] = 0;\n        u->zoneid = strdup(zoneid);\n        if(!u->zoneid)\n          return CURLUE_OUT_OF_MEMORY;\n        hostname[len] = ']'; \/* insert end bracket *\/\n        hostname[len + 1] = 0; \/* terminate the hostname *\/\n      }\n      else\n        return CURLUE_BAD_IPV6;\n      \/* hostname is fine *\/\n    }\n#ifdef ENABLE_IPV6\n    {\n      char dest[16]; \/* fits a binary IPv6 address *\/\n      char norm[MAX_IPADR_LEN];\n      hostname[hlen] = 0; \/* end the address there *\/\n      if(1 != Curl_inet_pton(AF_INET6, hostname, dest))\n        return CURLUE_BAD_IPV6;\n\n      \/* check if it can be done shorter *\/\n      if(Curl_inet_ntop(AF_INET6, dest, norm, sizeof(norm)) &&\n         (strlen(norm) < hlen)) {\n        strcpy(hostname, norm);\n        hlen = strlen(norm);\n        hostname[hlen + 1] = 0;\n      }\n      hostname[hlen] = ']'; \/* restore ending bracket *\/\n    }\n#endif\n  }\n  else {\n    \/* letters from the second string are not ok *\/\n    len = strcspn(hostname, \" \\r\\n\\t\/:#?!@\");\n    if(hlen != len)\n      \/* hostname with bad content *\/\n      return CURLUE_BAD_HOSTNAME;\n  }\n  if(!hostname[0])\n    return CURLUE_NO_HOST;\n  return CURLUE_OK;\n}","target":0,"code_token_length":622,"total_token_length":858,"max_tokens_setting":1024}
+{"idx":336550,"func":"bool reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc,\n                              SpiceMigrateDataMain *mig_data, uint32_t size)\n{\n    RedCharDeviceVDIPort *agent_dev = reds->agent_dev.get();\n\n    spice_debug(\"main-channel: got migrate data\");\n    \/*\n     * Now that the client has switched to the target server, if main_channel\n     * controls the mm-time, we update the client's mm-time.\n     * (MSG_MAIN_INIT is not sent for a migrating connection)\n     *\/\n    if (reds->mm_time_enabled) {\n        reds_send_mm_time(reds);\n    }\n    if (mig_data->agent_base.connected) {\n        if (agent_dev->priv->agent_attached) { \/\/ agent was attached before migration data has arrived\n            if (!reds->vdagent) {\n                spice_assert(agent_dev->priv->plug_generation > 0);\n                reds->main_channel->push_agent_disconnected();\n                spice_debug(\"agent is no longer connected\");\n            } else {\n                if (agent_dev->priv->plug_generation > 1) {\n                    \/* red_char_device_state_reset takes care of not making the device wait for migration data *\/\n                    spice_debug(\"agent has been detached and reattached before receiving migration data\");\n                    reds->main_channel->push_agent_disconnected();\n                    reds->main_channel->push_agent_connected();\n                } else {\n                    spice_debug(\"restoring state from mig_data\");\n                    return reds_agent_state_restore(reds, mig_data);\n                }\n            }\n        } else {\n            \/* restore agent state when the agent gets attached *\/\n            spice_debug(\"saving mig_data\");\n            spice_assert(agent_dev->priv->plug_generation == 0);\n            agent_dev->priv->mig_data = (SpiceMigrateDataMain*) g_memdup(mig_data, size);\n        }\n    } else {\n        spice_debug(\"agent was not attached on the source host\");\n        if (reds->vdagent) {\n            RedCharDeviceClientOpaque *client_opaque =\n                (RedCharDeviceClientOpaque *) mcc->get_client();\n            \/* red_char_device_client_remove disables waiting for migration data *\/\n            agent_dev->client_remove(client_opaque);\n            reds->main_channel->push_agent_connected();\n        }\n    }\n\n    return TRUE;\n}","target":0,"code_token_length":485,"total_token_length":721,"max_tokens_setting":1024}
+{"idx":384917,"func":"f_writefile(typval_T *argvars, typval_T *rettv)\n{\n    int\t\tbinary = FALSE;\n    int\t\tappend = FALSE;\n#ifdef HAVE_FSYNC\n    int\t\tdo_fsync = p_fs;\n#endif\n    char_u\t*fname;\n    FILE\t*fd;\n    int\t\tret = 0;\n    listitem_T\t*li;\n    list_T\t*list = NULL;\n    blob_T\t*blob = NULL;\n\n    rettv->vval.v_number = -1;\n    if (check_secure())\n\treturn;\n\n    if (in_vim9script()\n\t    && (check_for_list_or_blob_arg(argvars, 0) == FAIL\n\t\t|| check_for_string_arg(argvars, 1) == FAIL\n\t\t|| check_for_opt_string_arg(argvars, 2) == FAIL))\n\treturn;\n\n    if (argvars[0].v_type == VAR_LIST)\n    {\n\tlist = argvars[0].vval.v_list;\n\tif (list == NULL)\n\t    return;\n\tCHECK_LIST_MATERIALIZE(list);\n\tFOR_ALL_LIST_ITEMS(list, li)\n\t    if (tv_get_string_chk(&li->li_tv) == NULL)\n\t\treturn;\n    }\n    else if (argvars[0].v_type == VAR_BLOB)\n    {\n\tblob = argvars[0].vval.v_blob;\n\tif (blob == NULL)\n\t    return;\n    }\n    else\n    {\n\tsemsg(_(e_invalid_argument_str),\n\t\t_(\"writefile() first argument must be a List or a Blob\"));\n\treturn;\n    }\n\n    if (argvars[2].v_type != VAR_UNKNOWN)\n    {\n\tchar_u *arg2 = tv_get_string_chk(&argvars[2]);\n\n\tif (arg2 == NULL)\n\t    return;\n\tif (vim_strchr(arg2, 'b') != NULL)\n\t    binary = TRUE;\n\tif (vim_strchr(arg2, 'a') != NULL)\n\t    append = TRUE;\n#ifdef HAVE_FSYNC\n\tif (vim_strchr(arg2, 's') != NULL)\n\t    do_fsync = TRUE;\n\telse if (vim_strchr(arg2, 'S') != NULL)\n\t    do_fsync = FALSE;\n#endif\n    }\n\n    fname = tv_get_string_chk(&argvars[1]);\n    if (fname == NULL)\n\treturn;\n\n    \/\/ Always open the file in binary mode, library functions have a mind of\n    \/\/ their own about CR-LF conversion.\n    if (*fname == NUL || (fd = mch_fopen((char *)fname,\n\t\t\t\t      append ? APPENDBIN : WRITEBIN)) == NULL)\n    {\n\tsemsg(_(e_cant_create_file_str), *fname == NUL ? (char_u *)_(\"<empty>\") : fname);\n\tret = -1;\n    }\n    else if (blob)\n    {\n\tif (write_blob(fd, blob) == FAIL)\n\t    ret = -1;\n#ifdef HAVE_FSYNC\n\telse if (do_fsync)\n\t    \/\/ Ignore the error, the user wouldn't know what to do about it.\n\t    \/\/ May happen for a device.\n\t    vim_ignored = vim_fsync(fileno(fd));\n#endif\n\tfclose(fd);\n    }\n    else\n    {\n\tif (write_list(fd, list, binary) == FAIL)\n\t    ret = -1;\n#ifdef HAVE_FSYNC\n\telse if (do_fsync)\n\t    \/\/ Ignore the error, the user wouldn't know what to do about it.\n\t    \/\/ May happen for a device.\n\t    vim_ignored = vim_fsync(fileno(fd));\n#endif\n\tfclose(fd);\n    }\n\n    rettv->vval.v_number = ret;\n}","target":0,"code_token_length":752,"total_token_length":988,"max_tokens_setting":1024}
+{"idx":226137,"func":"\nGF_Err sgpd_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 entry_count;\n\tGF_SampleGroupDescriptionBox *p = (GF_SampleGroupDescriptionBox *)s;\n\n\tISOM_DECREASE_SIZE(p, 8);\n\tp->grouping_type = gf_bs_read_u32(bs);\n\n\tif (p->version>=1) {\n\t\tISOM_DECREASE_SIZE(p, 4);\n\t\tp->default_length = gf_bs_read_u32(bs);\n\t}\n\tif (p->version>=2) {\n\t\tISOM_DECREASE_SIZE(p, 4);\n\t\tp->default_description_index = gf_bs_read_u32(bs);\n\t}\n\tentry_count = gf_bs_read_u32(bs);\n\n\tif (entry_count>p->size)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\twhile (entry_count) {\n\t\tvoid *ptr;\n\t\tu32 parsed_bytes=0;\n\t\tu32 size = p->default_length;\n\t\tif ((p->version>=1) && !size) {\n\t\t\tsize = gf_bs_read_u32(bs);\n\t\t\tISOM_DECREASE_SIZE(p, 4);\n\t\t}\n\t\tptr = sgpd_parse_entry(p->grouping_type, bs, (s32) p->size, size, &parsed_bytes);\n\t\t\/\/don't return an error, just stop parsing so that we skip over the sgpd box\n\t\tif (!ptr) return GF_OK;\n\t\tgf_list_add(p->group_descriptions, ptr);\n\n\t\tISOM_DECREASE_SIZE(p, parsed_bytes);\n\t\tentry_count--;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":220171,"func":"  void Compute(OpKernelContext* context) override {\n    const Tensor& contents = context->input(0);\n    OP_REQUIRES(\n        context, TensorShapeUtils::IsScalar(contents.shape()),\n        errors::InvalidArgument(\"`contents` must be scalar but got shape\",\n                                contents.shape().DebugString()));\n    const StringPiece input = contents.scalar<tstring>()();\n    OP_REQUIRES(context, !input.empty(),\n                errors::InvalidArgument(\"Input is empty.\"));\n    OP_REQUIRES(context, input.size() <= std::numeric_limits<int>::max(),\n                errors::InvalidArgument(\n                    \"Input contents are too large for int: \", input.size()));\n\n    \/\/ Parse magic bytes to determine file format.\n    switch (ClassifyFileFormat(input)) {\n      case kJpgFormat:\n        DecodeJpegV2(context, input);\n        break;\n      case kPngFormat:\n        DecodePngV2(context, input);\n        break;\n      case kGifFormat:\n        DecodeGifV2(context, input);\n        break;\n      case kBmpFormat:\n        DecodeBmpV2(context, input);\n        break;\n      case kUnknownFormat:\n        OP_REQUIRES(context, false,\n                    errors::InvalidArgument(\"Unknown image file format. One of \"\n                                            \"JPEG, PNG, GIF, BMP required.\"));\n        break;\n    }\n  }","target":0,"code_token_length":277,"total_token_length":513,"max_tokens_setting":1024}
+{"idx":335420,"func":"apply_cmdmod(cmdmod_T *cmod)\n{\n#ifdef HAVE_SANDBOX\n    if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox)\n    {\n\t++sandbox;\n\tcmod->cmod_did_sandbox = TRUE;\n    }\n#endif\n    if (cmod->cmod_verbose != 0)\n    {\n\tif (cmod->cmod_verbose_save == 0)\n\t    cmod->cmod_verbose_save = p_verbose + 1;\n\tp_verbose = cmod->cmod_verbose < 0 ? 0 : cmod->cmod_verbose;\n    }\n\n    if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))\n\t    && cmod->cmod_save_msg_silent == 0)\n    {\n\tcmod->cmod_save_msg_silent = msg_silent + 1;\n\tcmod->cmod_save_msg_scroll = msg_scroll;\n    }\n    if (cmod->cmod_flags & CMOD_SILENT)\n\t++msg_silent;\n    if (cmod->cmod_flags & CMOD_UNSILENT)\n\tmsg_silent = 0;\n\n    if (cmod->cmod_flags & CMOD_ERRSILENT)\n    {\n\t++emsg_silent;\n\t++cmod->cmod_did_esilent;\n    }\n\n    if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL)\n    {\n\t\/\/ Set 'eventignore' to \"all\".\n\t\/\/ First save the existing option value for restoring it later.\n\tcmod->cmod_save_ei = vim_strsave(p_ei);\n\tset_string_option_direct((char_u *)\"ei\", -1,\n\t\t\t\t\t  (char_u *)\"all\", OPT_FREE, SID_NONE);\n    }\n}","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":222864,"func":"Status GraphProperties::UpdateMerge(SymbolicShapeRefiner* shape_refiner,\n                                    const NodeDef* node,\n                                    bool* new_shapes) const {\n  InferenceContext* ic = shape_refiner->GetContext(node);\n  if (!ic) {\n    \/\/ Now we can run shape inference\n    TF_RETURN_IF_ERROR(shape_refiner->AddNode(node));\n    ic = CHECK_NOTNULL(shape_refiner->GetContext(node));\n    *new_shapes = true;\n\n    \/\/ Infer the shape of the second output once and for all since it never\n    \/\/ changes.\n    ShapeHandle out1 = ic->Scalar();\n    if (ic->num_outputs() >= 2) ic->set_output(1, out1);\n  }\n\n  ShapeHandle out;\n  const std::vector<ShapeAndType>* out_handle = nullptr;\n  bool out_initialized = false;\n  for (const GraphView::Edge fanin : shape_refiner->graph().GetFaninEdges(\n           *node, \/*include_controlling_edges=*\/false)) {\n    InferenceContext* src_ic = shape_refiner->GetContext(fanin.src.node);\n    if (!src_ic) {\n      \/\/ Handling a loop for the first time, the back edge won't have any shape\n      \/\/ info.\n      continue;\n    }\n    ShapeHandle input = src_ic->output(fanin.src.port_id);\n    ic->SetInput(fanin.dst.port_id, input);\n    auto* input_handle =\n        src_ic->output_handle_shapes_and_types(fanin.src.port_id);\n    if (input_handle)\n      ic->set_input_handle_shapes_and_types(fanin.dst.port_id, *input_handle);\n    if (!out_initialized) {\n      out_initialized = true;\n      out = input;\n      out_handle = input_handle;\n    } else {\n      \/\/ Note here only out, not out_handle, is modified.\n      out = shape_refiner->OutputAsUnion(node, 0, input, out);\n    }\n  }\n\n  if (*new_shapes || !shape_refiner->EquivalentShapes(out, ic->output(0))) {\n    ic->set_output(0, out);\n    if (out_handle) ic->set_output_handle_shapes_and_types(0, *out_handle);\n    *new_shapes = true;\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":480,"total_token_length":716,"max_tokens_setting":1024}
+{"idx":267919,"func":"void ogs_nas_5gs_nas_guti_to_mobility_identity_guti(\n        ogs_nas_5gs_guti_t *nas_guti,\n        ogs_nas_5gs_mobile_identity_guti_t *mobile_identity_guti)\n{\n    ogs_assert(nas_guti);\n    ogs_assert(mobile_identity_guti);\n\n    memset(mobile_identity_guti, 0, sizeof(*mobile_identity_guti));\n\n    \/*\n     * TS24.501\n     * 9.11.3.4 5GS mobile identity\n     * Figure 9.11.3.4.1 5GS mobile identity IE for type of identity \"5G-GUTI\"\n     *\n     * Octet 1 : 5GS mobile identity IEI\n     * Octet 2-3 : Length of 5GS mobile identity contents\n     * Octet 4 : 1 1 1 1 0 0 1 0\n     *\n     * <Octet 4>\n     *   h.supi_format = 0xf (1 1 1 1)\n     *   h.odd_even = 0 (Spare 0)\n     *   h.type = x x x (Type of identity : 5G-GUTI)\n     *\/\n    mobile_identity_guti->h.supi_format = 0xf;\n    mobile_identity_guti->h.type = OGS_NAS_5GS_MOBILE_IDENTITY_GUTI;\n\n    memcpy(&mobile_identity_guti->nas_plmn_id,\n            &nas_guti->nas_plmn_id, OGS_PLMN_ID_LEN);\n    memcpy(&mobile_identity_guti->amf_id,\n            &nas_guti->amf_id, sizeof(ogs_amf_id_t));\n    mobile_identity_guti->m_tmsi = htobe32(nas_guti->m_tmsi);\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":488430,"func":"static int do_move_pages(struct mm_struct *mm, struct page_to_node *pm,\n\t\t\t\tint migrate_all)\n{\n\tint err;\n\tstruct page_to_node *pp;\n\tLIST_HEAD(pagelist);\n\n\tdown_read(&mm->mmap_sem);\n\n\t\/*\n\t * Build a list of pages to migrate\n\t *\/\n\tmigrate_prep();\n\tfor (pp = pm; pp->node != MAX_NUMNODES; pp++) {\n\t\tstruct vm_area_struct *vma;\n\t\tstruct page *page;\n\n\t\t\/*\n\t\t * A valid page pointer that will not match any of the\n\t\t * pages that will be moved.\n\t\t *\/\n\t\tpp->page = ZERO_PAGE(0);\n\n\t\terr = -EFAULT;\n\t\tvma = find_vma(mm, pp->addr);\n\t\tif (!vma || !vma_migratable(vma))\n\t\t\tgoto set_status;\n\n\t\tpage = follow_page(vma, pp->addr, FOLL_GET);\n\n\t\terr = PTR_ERR(page);\n\t\tif (IS_ERR(page))\n\t\t\tgoto set_status;\n\n\t\terr = -ENOENT;\n\t\tif (!page)\n\t\t\tgoto set_status;\n\n\t\tif (PageReserved(page))\t\t\/* Check for zero page *\/\n\t\t\tgoto put_and_set;\n\n\t\tpp->page = page;\n\t\terr = page_to_nid(page);\n\n\t\tif (err == pp->node)\n\t\t\t\/*\n\t\t\t * Node already in the right place\n\t\t\t *\/\n\t\t\tgoto put_and_set;\n\n\t\terr = -EACCES;\n\t\tif (page_mapcount(page) > 1 &&\n\t\t\t\t!migrate_all)\n\t\t\tgoto put_and_set;\n\n\t\terr = isolate_lru_page(page, &pagelist);\nput_and_set:\n\t\t\/*\n\t\t * Either remove the duplicate refcount from\n\t\t * isolate_lru_page() or drop the page ref if it was\n\t\t * not isolated.\n\t\t *\/\n\t\tput_page(page);\nset_status:\n\t\tpp->status = err;\n\t}\n\n\tif (!list_empty(&pagelist))\n\t\terr = migrate_pages(&pagelist, new_page_node,\n\t\t\t\t(unsigned long)pm);\n\telse\n\t\terr = -ENOENT;\n\n\tup_read(&mm->mmap_sem);\n\treturn err;\n}","target":0,"code_token_length":449,"total_token_length":685,"max_tokens_setting":1024}
+{"idx":96951,"func":"void encode(ArgumentEncoder* encoder, CFTypeRef typeRef)\n{\n    CFType type = typeFromCFTypeRef(typeRef);\n    encoder->encodeEnum(type);\n\n    switch (type) {\n    case CFArray:\n        encode(encoder, static_cast<CFArrayRef>(typeRef));\n        return;\n    case CFBoolean:\n        encode(encoder, static_cast<CFBooleanRef>(typeRef));\n        return;\n    case CFData:\n        encode(encoder, static_cast<CFDataRef>(typeRef));\n        return;\n    case CFDate:\n        encode(encoder, static_cast<CFDateRef>(typeRef));\n        return;\n    case CFDictionary:\n        encode(encoder, static_cast<CFDictionaryRef>(typeRef));\n        return;\n    case CFNull:\n        return;\n    case CFNumber:\n        encode(encoder, static_cast<CFNumberRef>(typeRef));\n        return;\n    case CFString:\n        encode(encoder, static_cast<CFStringRef>(typeRef));\n        return;\n    case CFURL:\n        encode(encoder, static_cast<CFURLRef>(typeRef));\n        return;\n#if PLATFORM(MAC)\n    case SecCertificate:\n        encode(encoder, (SecCertificateRef)typeRef);\n        return;\n    case SecKeychainItem:\n        encode(encoder, (SecKeychainItemRef)typeRef);\n        return;\n#endif\n    case Null:\n        return;\n    case Unknown:\n        break;\n    }\n\n    ASSERT_NOT_REACHED();\n}\n","target":0,"code_token_length":298,"total_token_length":534,"max_tokens_setting":1024}
+{"idx":455414,"func":"xfs_inode_ag_walk(\n\tstruct xfs_mount\t*mp,\n\tstruct xfs_perag\t*pag,\n\tint\t\t\t(*execute)(struct xfs_inode *ip, int flags,\n\t\t\t\t\t   void *args),\n\tint\t\t\tflags,\n\tvoid\t\t\t*args,\n\tint\t\t\ttag,\n\tint\t\t\titer_flags)\n{\n\tuint32_t\t\tfirst_index;\n\tint\t\t\tlast_error = 0;\n\tint\t\t\tskipped;\n\tint\t\t\tdone;\n\tint\t\t\tnr_found;\n\nrestart:\n\tdone = 0;\n\tskipped = 0;\n\tfirst_index = 0;\n\tnr_found = 0;\n\tdo {\n\t\tstruct xfs_inode *batch[XFS_LOOKUP_BATCH];\n\t\tint\t\terror = 0;\n\t\tint\t\ti;\n\n\t\trcu_read_lock();\n\n\t\tif (tag == -1)\n\t\t\tnr_found = radix_tree_gang_lookup(&pag->pag_ici_root,\n\t\t\t\t\t(void **)batch, first_index,\n\t\t\t\t\tXFS_LOOKUP_BATCH);\n\t\telse\n\t\t\tnr_found = radix_tree_gang_lookup_tag(\n\t\t\t\t\t&pag->pag_ici_root,\n\t\t\t\t\t(void **) batch, first_index,\n\t\t\t\t\tXFS_LOOKUP_BATCH, tag);\n\n\t\tif (!nr_found) {\n\t\t\trcu_read_unlock();\n\t\t\tbreak;\n\t\t}\n\n\t\t\/*\n\t\t * Grab the inodes before we drop the lock. if we found\n\t\t * nothing, nr == 0 and the loop will be skipped.\n\t\t *\/\n\t\tfor (i = 0; i < nr_found; i++) {\n\t\t\tstruct xfs_inode *ip = batch[i];\n\n\t\t\tif (done || xfs_inode_ag_walk_grab(ip, iter_flags))\n\t\t\t\tbatch[i] = NULL;\n\n\t\t\t\/*\n\t\t\t * Update the index for the next lookup. Catch\n\t\t\t * overflows into the next AG range which can occur if\n\t\t\t * we have inodes in the last block of the AG and we\n\t\t\t * are currently pointing to the last inode.\n\t\t\t *\n\t\t\t * Because we may see inodes that are from the wrong AG\n\t\t\t * due to RCU freeing and reallocation, only update the\n\t\t\t * index if it lies in this AG. It was a race that lead\n\t\t\t * us to see this inode, so another lookup from the\n\t\t\t * same index will not find it again.\n\t\t\t *\/\n\t\t\tif (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag->pag_agno)\n\t\t\t\tcontinue;\n\t\t\tfirst_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);\n\t\t\tif (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino))\n\t\t\t\tdone = 1;\n\t\t}\n\n\t\t\/* unlock now we've grabbed the inodes. *\/\n\t\trcu_read_unlock();\n\n\t\tfor (i = 0; i < nr_found; i++) {\n\t\t\tif (!batch[i])\n\t\t\t\tcontinue;\n\t\t\tif ((iter_flags & XFS_AGITER_INEW_WAIT) &&\n\t\t\t    xfs_iflags_test(batch[i], XFS_INEW))\n\t\t\t\txfs_inew_wait(batch[i]);\n\t\t\terror = execute(batch[i], flags, args);\n\t\t\tIRELE(batch[i]);\n\t\t\tif (error == -EAGAIN) {\n\t\t\t\tskipped++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (error && last_error != -EFSCORRUPTED)\n\t\t\t\tlast_error = error;\n\t\t}\n\n\t\t\/* bail out if the filesystem is corrupted.  *\/\n\t\tif (error == -EFSCORRUPTED)\n\t\t\tbreak;\n\n\t\tcond_resched();\n\n\t} while (nr_found && !done);\n\n\tif (skipped) {\n\t\tdelay(1);\n\t\tgoto restart;\n\t}\n\treturn last_error;\n}","target":0,"code_token_length":771,"total_token_length":1007,"max_tokens_setting":1024}
+{"idx":369104,"func":"static void io_req_task_work_add(struct io_kiocb *req, bool priority)\n{\n\tstruct task_struct *tsk = req->task;\n\tstruct io_uring_task *tctx = tsk->io_uring;\n\tenum task_work_notify_mode notify;\n\tstruct io_wq_work_node *node;\n\tunsigned long flags;\n\tbool running;\n\n\tWARN_ON_ONCE(!tctx);\n\n\tio_drop_inflight_file(req);\n\n\tspin_lock_irqsave(&tctx->task_lock, flags);\n\tif (priority)\n\t\twq_list_add_tail(&req->io_task_work.node, &tctx->prior_task_list);\n\telse\n\t\twq_list_add_tail(&req->io_task_work.node, &tctx->task_list);\n\trunning = tctx->task_running;\n\tif (!running)\n\t\ttctx->task_running = true;\n\tspin_unlock_irqrestore(&tctx->task_lock, flags);\n\n\t\/* task_work already pending, we're done *\/\n\tif (running)\n\t\treturn;\n\n\t\/*\n\t * SQPOLL kernel thread doesn't need notification, just a wakeup. For\n\t * all other cases, use TWA_SIGNAL unconditionally to ensure we're\n\t * processing task_work. There's no reliable way to tell if TWA_RESUME\n\t * will do the job.\n\t *\/\n\tnotify = (req->ctx->flags & IORING_SETUP_SQPOLL) ? TWA_NONE : TWA_SIGNAL;\n\tif (likely(!task_work_add(tsk, &tctx->task_work, notify))) {\n\t\tif (notify == TWA_NONE)\n\t\t\twake_up_process(tsk);\n\t\treturn;\n\t}\n\n\tspin_lock_irqsave(&tctx->task_lock, flags);\n\ttctx->task_running = false;\n\tnode = wq_list_merge(&tctx->prior_task_list, &tctx->task_list);\n\tspin_unlock_irqrestore(&tctx->task_lock, flags);\n\n\twhile (node) {\n\t\treq = container_of(node, struct io_kiocb, io_task_work.node);\n\t\tnode = node->next;\n\t\tif (llist_add(&req->io_task_work.fallback_node,\n\t\t\t      &req->ctx->fallback_llist))\n\t\t\tschedule_delayed_work(&req->ctx->fallback_work, 1);\n\t}\n}","target":0,"code_token_length":464,"total_token_length":700,"max_tokens_setting":1024}
+{"idx":244226,"func":"GF_Err metx_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 size, i;\n\tGF_Err e;\n\tchar *str;\n\tGF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox*)s;\n\n\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);\n\tif (e) return e;\n\tISOM_DECREASE_SIZE(ptr, 8);\n\n\tif (ptr->size > (u64)SIZE_MAX) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid size \"LLU\" in metx\\n\", ptr->size));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tsize = (u32) ptr->size;\n\tstr = gf_malloc(sizeof(char)*size);\n\tif (!str) return GF_OUT_OF_MEM;\n\ti=0;\n\n\twhile (size) {\n\t\tstr[i] = gf_bs_read_u8(bs);\n\t\tsize--;\n\t\tif (!str[i]) {\n\t\t\ti++;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\tif (!size && i>1 && str[i-1]) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] metx read invalid string\\n\"));\n\t\tgf_free(str);\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tif (i>1) {\n\t\tif (ptr->type==GF_ISOM_BOX_TYPE_STPP) {\n\t\t\tptr->xml_namespace = gf_strdup(str);\n\t\t} else {\n\t\t\tptr->content_encoding = gf_strdup(str);\n\t\t}\n\t}\n\n\ti=0;\n\twhile (size) {\n\t\tstr[i] = gf_bs_read_u8(bs);\n\t\tsize--;\n\t\tif (!str[i]) {\n\t\t\ti++;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\tif (!size && i>1 && str[i-1]) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] metx read invalid string\\n\"));\n\t\tgf_free(str);\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tif ((ptr->type==GF_ISOM_BOX_TYPE_METX) || (ptr->type==GF_ISOM_BOX_TYPE_STPP)) {\n\t\tif (i>1) {\n\t\t\tif (ptr->type==GF_ISOM_BOX_TYPE_STPP) {\n\t\t\t\tptr->xml_schema_loc = gf_strdup(str);\n\t\t\t} else {\n\t\t\t\tptr->xml_namespace = gf_strdup(str);\n\t\t\t}\n\t\t}\n\n\t\ti=0;\n\t\twhile (size) {\n\t\t\tstr[i] = gf_bs_read_u8(bs);\n\t\t\tsize--;\n\t\t\tif (!str[i]) {\n\t\t\t\ti++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tif (!size && i>1 && str[i-1]) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] metx read invalid string\\n\"));\n\t\t\tgf_free(str);\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tif (i>1) {\n\t\t\tif (ptr->type==GF_ISOM_BOX_TYPE_STPP) {\n\t\t\t\tptr->mime_type = gf_strdup(str);\n\t\t\t} else {\n\t\t\t\tptr->xml_schema_loc = gf_strdup(str);\n\t\t\t}\n\t\t}\n\t}\n\t\/\/mett, sbtt, stxt, stpp\n\telse {\n\t\tif (i>1) ptr->mime_type = gf_strdup(str);\n\t}\n\tptr->size = size;\n\tgf_free(str);\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":737,"total_token_length":973,"max_tokens_setting":1024}
+{"idx":390593,"func":"_CheckSetShapes( \tXkbGeometryPtr\t\tgeom,\n\t\t\txkbSetGeometryReq *\treq,\n\t\t\tchar **\t\t\twire_inout,\n\t\t\tClientPtr\t\tclient)\n{\nregister int\ti;\nchar *\t\twire;\n\n    wire= *wire_inout;\n    if (req->nShapes<1) {\n\tclient->errorValue= _XkbErrCode2(0x06,req->nShapes);\n\treturn BadValue;\n    }\n    else {\n\txkbShapeWireDesc *\tshapeWire;\n\tXkbShapePtr\t\tshape;\n\tregister int\t\to;\n\tshapeWire= (xkbShapeWireDesc *)wire;\n\tfor (i=0;i<req->nShapes;i++) {\n\t    xkbOutlineWireDesc *\tolWire;\n\t    XkbOutlinePtr\t\tol;\n\t    shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines);\n\t    if (!shape)\n\t\treturn BadAlloc;\n\t    olWire= (xkbOutlineWireDesc *)(&shapeWire[1]);\n\t    for (o=0;o<shapeWire->nOutlines;o++) {\n\t\tregister int\t\tp;\n\t\tXkbPointPtr\t\tpt;\n\t\txkbPointWireDesc *\tptWire;\n\n\t\tol= XkbAddGeomOutline(shape,olWire->nPoints);\n\t\tif (!ol)\n\t\t    return BadAlloc;\n\t\tol->corner_radius=\tolWire->cornerRadius;\n\t\tptWire= (xkbPointWireDesc *)&olWire[1];\n\t\tfor (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) {\n\t\t    pt->x= ptWire[p].x;\n\t\t    pt->y= ptWire[p].y;\n\t\t    if (client->swapped) {\n\t\t\tregister int n;\n\t\t\tswaps(&pt->x,n);\n\t\t\tswaps(&pt->y,n);\n\t\t    }\n\t\t}\n\t\tol->num_points= olWire->nPoints;\n\t\tolWire= (xkbOutlineWireDesc *)(&ptWire[olWire->nPoints]);\n\t    }\n\t    if (shapeWire->primaryNdx!=XkbNoShape)\n\t\tshape->primary= &shape->outlines[shapeWire->primaryNdx];\n\t    if (shapeWire->approxNdx!=XkbNoShape)\n\t\tshape->approx= &shape->outlines[shapeWire->approxNdx];\n\t    shapeWire= (xkbShapeWireDesc *)olWire;\n\t}\n\twire= (char *)shapeWire;\n    }\n    if (geom->num_shapes!=req->nShapes) {\n\tclient->errorValue= _XkbErrCode3(0x07,geom->num_shapes,req->nShapes);\n\treturn BadMatch;\n    }\n\n    *wire_inout= wire;\n    return Success;\n}","target":0,"code_token_length":591,"total_token_length":827,"max_tokens_setting":1024}
+{"idx":218986,"func":"Status ConstantFolding::Optimize(Cluster* cluster, const GrapplerItem& item,\n                                 GraphDef* optimized_graph) {\n  \/\/ TensorFlow flushes denormals to zero and rounds to nearest, so we do\n  \/\/ the same here.\n  port::ScopedFlushDenormal flush;\n  port::ScopedSetRound round(FE_TONEAREST);\n  nodes_to_preserve_ = item.NodesToPreserve();\n  for (const auto& feed : item.feed) {\n    feed_nodes_.insert(NodeName(feed.first));\n  }\n\n  if (cpu_device_ == nullptr) {\n    owned_device_.reset(new DeviceSimple());\n    cpu_device_ = owned_device_.get();\n  }\n\n  graph_contains_assign_or_inplace_op_ = false;\n  for (const NodeDef& node : item.graph.node()) {\n    if (ModifiesInputsInPlace(node) || HasRefInput(node)) {\n      graph_contains_assign_or_inplace_op_ = true;\n      break;\n    }\n  }\n\n  has_fetch_ = !item.fetch.empty();\n  GrapplerItem item_to_optimize = item;\n  GraphProperties properties(item_to_optimize);\n  \/\/ It's possible to feed a placeholder with a tensor of any shape: make sure\n  \/\/ that the shape inference deals with this conservatively unless we're in\n  \/\/ aggressive mode.\n  const bool assume_valid_feeds = opt_level_ == RewriterConfig::AGGRESSIVE;\n  if (!properties\n           .InferStatically(assume_valid_feeds,\n                            \/*aggressive_shape_inference=*\/false,\n                            \/*include_input_tensor_values=*\/false,\n                            \/*include_output_tensor_values=*\/true)\n           .ok()) {\n    properties.Clear();\n  }\n\n  *optimized_graph = GraphDef();\n  item_to_optimize.graph.Swap(optimized_graph);\n  int64_t node_count;\n\n  do {\n    GRAPPLER_RETURN_IF_DEADLINE_EXCEEDED();\n    graph_modified_ = false;\n    item_to_optimize.graph.Swap(optimized_graph);\n    node_count = item_to_optimize.graph.node_size();\n    TF_RETURN_IF_ERROR(RunOptimizationPass(cluster, &item_to_optimize,\n                                           &properties, optimized_graph));\n  } while (graph_modified_ || optimized_graph->node_size() != node_count);\n  *optimized_graph->mutable_library() = item.graph.library();\n  *optimized_graph->mutable_versions() = item.graph.versions();\n\n  return Status::OK();\n}","target":0,"code_token_length":503,"total_token_length":739,"max_tokens_setting":1024}
+{"idx":442823,"func":"CURLcode _my_setopt(CURL *curl, const char *name, CURLoption tag, ...)\n{\n  va_list arg;\n  CURLcode ret;\n  char *bufp;\n  char value[256];\n  bool remark=FALSE;\n\n  va_start(arg, tag);\n\n  if(tag < CURLOPTTYPE_OBJECTPOINT) {\n    long lval = va_arg(arg, long);\n    snprintf(value, sizeof(value), \"%ld\", lval);\n    ret = curl_easy_setopt(curl, tag, lval);\n\n  }\n  else if(tag < CURLOPTTYPE_OFF_T) {\n    void *pval = va_arg(arg, void *);\n    unsigned char *ptr = (unsigned char *)pval;\n\n    \/* function pointers are never printable *\/\n    if (tag >= CURLOPTTYPE_FUNCTIONPOINT) {\n      if (pval) {\n        snprintf(value, sizeof(value), \"%p\", pval);\n        remark = TRUE;\n      }\n      else\n        strcpy(value, \"NULL\");\n    }\n    \/* attempt to figure out if it is a string (since the tag numerical doesn't\n       offer this info) and then output it as a string if so *\/\n    else if(pval && isgraph(ptr[0]) && isgraph(ptr[1]) && isgraph(ptr[2]))\n      snprintf(value, sizeof(value), \"\\\"%s\\\"\", (char *)ptr);\n    else if(pval) {\n      snprintf(value, sizeof(value), \"%p\", pval);\n      remark = TRUE;\n    }\n    else {\n      strcpy(value, \"NULL\"); \/* value fits more than 5 bytes *\/\n    }\n    ret = curl_easy_setopt(curl, tag, pval);\n\n  }\n  else {\n    curl_off_t oval = va_arg(arg, curl_off_t);\n    snprintf(value, sizeof(value), \"(curl_off_t)%Od\", oval);\n    ret = curl_easy_setopt(curl, tag, oval);\n  }\n\n  bufp = curl_maprintf(\"%scurl_easy_setopt(hnd, %s, %s);%s\",\n                       remark?\"\/* \":\"\", name, value,\n                       remark?\" [REMARK] *\/\":\"\");\n\n  if (!bufp || !curl_slist_append(easycode, bufp))\n    ret = CURLE_OUT_OF_MEMORY;\n  if (bufp)\n    curl_free(bufp);\n  va_end(arg);\n\n  return ret;\n}","target":0,"code_token_length":482,"total_token_length":718,"max_tokens_setting":1024}
+{"idx":219964,"func":"int callback_glewlwyd_check_user_profile_valid (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  char * session_uid;\n  json_t * j_user;\n  int ret, res;\n  \n  if ((session_uid = get_session_id(config, request)) != NULL) {\n    j_user = get_current_user_for_session(config, session_uid);\n    if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, \"user\"), \"enabled\") == json_true()) {\n      if ((res = is_scope_list_valid_for_session(config, config->profile_scope, session_uid)) == G_OK) {\n        if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, \"user\")), (void (*)(void *))&json_decref) != U_OK) {\n          ret = U_CALLBACK_ERROR;\n        } else {\n          ret = U_CALLBACK_IGNORE;\n        }\n      } else {\n        if (res == G_ERROR) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_check_user_session - Error is_scope_list_valid_for_session\");\n        }\n        ret = U_CALLBACK_UNAUTHORIZED;\n      }\n    } else {\n      ret = U_CALLBACK_UNAUTHORIZED;\n    }\n    json_decref(j_user);\n  } else {\n    ret = U_CALLBACK_UNAUTHORIZED;\n  }\n  o_free(session_uid);\n  return ret;\n}","target":0,"code_token_length":317,"total_token_length":553,"max_tokens_setting":1024}
+{"idx":508369,"func":"fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,\n            bool ignore_errors, bool update)\n{\n  List_iterator_fast<Item> f(fields),v(values);\n  Item *value, *fld;\n  Item_field *field;\n  bool save_abort_on_warning= thd->abort_on_warning;\n  bool save_no_errors= thd->no_errors;\n  DBUG_ENTER(\"fill_record\");\n\n  thd->no_errors= ignore_errors;\n  \/*\n    Reset the table->auto_increment_field_not_null as it is valid for\n    only one row.\n  *\/\n  if (fields.elements)\n  {\n    \/*\n      On INSERT or UPDATE fields are checked to be from the same table,\n      thus we safely can take table from the first field.\n    *\/\n    fld= (Item_field*)f++;\n    if (!(field= fld->field_for_view_update()))\n    {\n      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);\n      goto err;\n    }\n    DBUG_ASSERT(field->field->table == table_arg);\n    table_arg->auto_increment_field_not_null= FALSE;\n    f.rewind();\n  }\n\n  while ((fld= f++))\n  {\n    if (!(field= fld->field_for_view_update()))\n    {\n      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);\n      goto err;\n    }\n    value=v++;\n    Field *rfield= field->field;\n    TABLE* table= rfield->table;\n    if (table->next_number_field &&\n        rfield->field_index ==  table->next_number_field->field_index)\n      table->auto_increment_field_not_null= TRUE;\n    if (rfield->vcol_info &&\n        !value->vcol_assignment_allowed_value() &&\n        table->s->table_category != TABLE_CATEGORY_TEMPORARY)\n    {\n      push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,\n                          ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,\n                          ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),\n                          rfield->field_name, table->s->table_name.str);\n    }\n    if (rfield->stored_in_db() &&\n        (value->save_in_field(rfield, 0)) < 0 && !ignore_errors)\n    {\n      my_message(ER_UNKNOWN_ERROR, ER_THD(thd, ER_UNKNOWN_ERROR), MYF(0));\n      goto err;\n    }\n    rfield->set_has_explicit_value();\n  }\n\n  if (update)\n    table_arg->evaluate_update_default_function();\n  else\n    if (table_arg->default_field &&\n        table_arg->update_default_fields(ignore_errors))\n      goto err;\n\n  \/* Update virtual fields *\/\n  if (table_arg->vfield &&\n      table_arg->update_virtual_fields(table_arg->file, VCOL_UPDATE_FOR_WRITE))\n    goto err;\n  thd->abort_on_warning= save_abort_on_warning;\n  thd->no_errors=        save_no_errors;\n  DBUG_RETURN(thd->is_error());\nerr:\n  DBUG_PRINT(\"error\",(\"got error\"));\n  thd->abort_on_warning= save_abort_on_warning;\n  thd->no_errors=        save_no_errors;\n  if (fields.elements)\n    table_arg->auto_increment_field_not_null= FALSE;\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":703,"total_token_length":939,"max_tokens_setting":1024}
+{"idx":220205,"func":"void Graph::ToGraphDefSubRange(GraphDef* graph_def, int from_node_id) const {\n  graph_def->Clear();\n  *graph_def->mutable_versions() = versions();\n  *graph_def->mutable_library() = ops_.ToProto();\n\n  graph_def->mutable_node()->Reserve(std::max(1, num_nodes() - from_node_id));\n\n  std::vector<const Edge*>\n      inputs;  \/\/ Construct this outside the loop for speed.\n  for (auto id = from_node_id; id < num_node_ids(); ++id) {\n    const Node* node = FindNodeId(id);\n    if (node == nullptr || !node->IsOp()) continue;\n    NodeDef* node_def = graph_def->add_node();\n    *node_def = node->def();\n\n    \/\/ Use the node's assigned device, if any, instead of the device requested\n    \/\/ in the NodeDef.\n    if (!node->assigned_device_name().empty()) {\n      node_def->set_device(node->assigned_device_name());\n    }\n\n    \/\/ Get the inputs for this Node.  We make sure control inputs are\n    \/\/ after data inputs, as required by GraphDef.\n    inputs.clear();\n    inputs.resize(node->num_inputs(), nullptr);\n    for (const Edge* edge : node->in_edges()) {\n      if (edge->IsControlEdge()) {\n        inputs.push_back(edge);\n      } else {\n        DCHECK(edge->dst_input() < inputs.size())\n            << \"Edge \" << edge->DebugString()\n            << \" is overflowing the expected number of inputs (\"\n            << node->num_inputs() << \") for node \" << node->DebugString();\n        CHECK(inputs[edge->dst_input()] == nullptr)\n            << \"Edge \" << edge->src()->name() << \"->\" << edge->dst()->name()\n            << \" conflicts with pre-existing input edge \"\n            << inputs[edge->dst_input()]->src()->name() << \"->\"\n            << inputs[edge->dst_input()]->dst()->name();\n\n        inputs[edge->dst_input()] = edge;\n      }\n    }\n    \/\/ Sort the control inputs for more predictable serialization.\n    std::sort(inputs.begin() + node->num_inputs(), inputs.end(),\n              [](const Edge* a, const Edge* b) -> bool {\n                return a->src()->name() < b->src()->name();\n              });\n    node_def->clear_input();\n    node_def->mutable_input()->Reserve(inputs.size());\n\n    for (size_t i = 0; i < inputs.size(); ++i) {\n      const Edge* edge = inputs[i];\n      if (edge == nullptr) {\n        if (i < node->requested_inputs().size()) {\n          node_def->add_input(node->requested_inputs()[i]);\n        } else {\n          node_def->add_input(\"\");\n        }\n      } else {\n        const Node* src = edge->src();\n        if (!src->IsOp()) continue;\n        AddInput(node_def, src->name(), edge->src_output());\n      }\n    }\n  }\n}","target":0,"code_token_length":628,"total_token_length":864,"max_tokens_setting":1024}
+{"idx":418772,"func":"f_getmousepos(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    dict_T\t*d;\n    win_T\t*wp;\n    int\t\trow = mouse_row;\n    int\t\tcol = mouse_col;\n    varnumber_T winid = 0;\n    varnumber_T winrow = 0;\n    varnumber_T wincol = 0;\n    linenr_T\tlnum = 0;\n    varnumber_T column = 0;\n\n    if (rettv_dict_alloc(rettv) == FAIL)\n\treturn;\n    d = rettv->vval.v_dict;\n\n    dict_add_number(d, \"screenrow\", (varnumber_T)mouse_row + 1);\n    dict_add_number(d, \"screencol\", (varnumber_T)mouse_col + 1);\n\n    wp = mouse_find_win(&row, &col, FIND_POPUP);\n    if (wp != NULL)\n    {\n\tint\ttop_off = 0;\n\tint\tleft_off = 0;\n\tint\theight = wp->w_height + wp->w_status_height;\n\n#ifdef FEAT_PROP_POPUP\n\tif (WIN_IS_POPUP(wp))\n\t{\n\t    top_off = popup_top_extra(wp);\n\t    left_off = popup_left_extra(wp);\n\t    height = popup_height(wp);\n\t}\n#endif\n\tif (row < height)\n\t{\n\t    winid = wp->w_id;\n\t    winrow = row + 1;\n\t    wincol = col + 1;\n\t    row -= top_off;\n\t    col -= left_off;\n\t    if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)\n\t    {\n\t\t(void)mouse_comp_pos(wp, &row, &col, &lnum, NULL);\n\t\tcol = vcol2col(wp, lnum, col);\n\t\tcolumn = col + 1;\n\t    }\n\t}\n    }\n    dict_add_number(d, \"winid\", winid);\n    dict_add_number(d, \"winrow\", winrow);\n    dict_add_number(d, \"wincol\", wincol);\n    dict_add_number(d, \"line\", (varnumber_T)lnum);\n    dict_add_number(d, \"column\", column);\n}","target":0,"code_token_length":461,"total_token_length":697,"max_tokens_setting":1024}
+{"idx":312570,"func":"qf_jump_to_usable_window(int qf_fnum, int newwin, int *opened_window)\n{\n    win_T\t*usable_wp = NULL;\n    int\t\tusable_win = FALSE;\n    qf_info_T\t*ll_ref = NULL;\n\n    \/\/ If opening a new window, then don't use the location list referred by\n    \/\/ the current window.  Otherwise two windows will refer to the same\n    \/\/ location list.\n    if (!newwin)\n\tll_ref = curwin->w_llist_ref;\n\n    if (ll_ref != NULL)\n    {\n\t\/\/ Find a non-quickfix window with this location list\n\tusable_wp = qf_find_win_with_loclist(ll_ref);\n\tif (usable_wp != NULL)\n\t    usable_win = TRUE;\n    }\n\n    if (!usable_win)\n    {\n\t\/\/ Locate a window showing a normal buffer\n\twin_T\t*win = qf_find_win_with_normal_buf();\n\tif (win != NULL)\n\t    usable_win = TRUE;\n    }\n\n    \/\/ If no usable window is found and 'switchbuf' contains \"usetab\"\n    \/\/ then search in other tabs.\n    if (!usable_win && (swb_flags & SWB_USETAB))\n\tusable_win = qf_goto_tabwin_with_file(qf_fnum);\n\n    \/\/ If there is only one window and it is the quickfix window, create a\n    \/\/ new one above the quickfix window.\n    if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win || newwin)\n    {\n\tif (qf_open_new_file_win(ll_ref) != OK)\n\t    return FAIL;\n\t*opened_window = TRUE;\t\/\/ close it when fail\n    }\n    else\n    {\n\tif (curwin->w_llist_ref != NULL)\t\/\/ In a location window\n\t    qf_goto_win_with_ll_file(usable_wp, qf_fnum, ll_ref);\n\telse\t\t\t\t\t\/\/ In a quickfix window\n\t    qf_goto_win_with_qfl_file(qf_fnum);\n    }\n\n    return OK;\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":338221,"func":"bool WasmBinaryBuilder::maybeVisitAtomicRMW(Expression*& out, uint8_t code) {\n  if (code < BinaryConsts::AtomicRMWOps_Begin ||\n      code > BinaryConsts::AtomicRMWOps_End) {\n    return false;\n  }\n  auto* curr = allocator.alloc<AtomicRMW>();\n\n  \/\/ Set curr to the given opcode, type and size.\n#define SET(opcode, optype, size)                                              \\\n  curr->op = RMW##opcode;                                                      \\\n  curr->type = optype;                                                         \\\n  curr->bytes = size\n\n  \/\/ Handle the cases for all the valid types for a particular opcode\n#define SET_FOR_OP(Op)                                                         \\\n  case BinaryConsts::I32AtomicRMW##Op:                                         \\\n    SET(Op, Type::i32, 4);                                                     \\\n    break;                                                                     \\\n  case BinaryConsts::I32AtomicRMW##Op##8U:                                     \\\n    SET(Op, Type::i32, 1);                                                     \\\n    break;                                                                     \\\n  case BinaryConsts::I32AtomicRMW##Op##16U:                                    \\\n    SET(Op, Type::i32, 2);                                                     \\\n    break;                                                                     \\\n  case BinaryConsts::I64AtomicRMW##Op:                                         \\\n    SET(Op, Type::i64, 8);                                                     \\\n    break;                                                                     \\\n  case BinaryConsts::I64AtomicRMW##Op##8U:                                     \\\n    SET(Op, Type::i64, 1);                                                     \\\n    break;                                                                     \\\n  case BinaryConsts::I64AtomicRMW##Op##16U:                                    \\\n    SET(Op, Type::i64, 2);                                                     \\\n    break;                                                                     \\\n  case BinaryConsts::I64AtomicRMW##Op##32U:                                    \\\n    SET(Op, Type::i64, 4);                                                     \\\n    break;\n\n  switch (code) {\n    SET_FOR_OP(Add);\n    SET_FOR_OP(Sub);\n    SET_FOR_OP(And);\n    SET_FOR_OP(Or);\n    SET_FOR_OP(Xor);\n    SET_FOR_OP(Xchg);\n    default:\n      WASM_UNREACHABLE(\"unexpected opcode\");\n  }\n#undef SET_FOR_OP\n#undef SET\n\n  BYN_TRACE(\"zz node: AtomicRMW\\n\");\n  Address readAlign;\n  readMemoryAccess(readAlign, curr->offset);\n  if (readAlign != curr->bytes) {\n    throwError(\"Align of AtomicRMW must match size\");\n  }\n  curr->value = popNonVoidExpression();\n  curr->ptr = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":579,"total_token_length":815,"max_tokens_setting":1024}
+{"idx":452260,"func":"PHP_FUNCTION(xsl_xsltprocessor_transform_to_doc)\n{\n\tzval *id, *docp = NULL;\n\txmlDoc *newdocp;\n\txsltStylesheetPtr sheetp;\n\tint ret, ret_class_len=0;\n\tchar *ret_class = NULL;\n\txsl_object *intern;\n\n\tid = getThis();\n\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\tsheetp = (xsltStylesheetPtr) intern->ptr;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"o|s!\", &docp, &ret_class, &ret_class_len) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tnewdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);\n\n\tif (newdocp) {\n\t\tif (ret_class) {\n\t\t\tint found;\n\t\t\tchar *curclass_name;\n\t\t\tzend_class_entry *curce, **ce;\n\t\t\tphp_libxml_node_object *interndoc;\n\n\t\t\tcurce = Z_OBJCE_P(docp);\n\t\t\tcurclass_name = curce->name;\n\t\t\twhile (curce->parent != NULL) {\n\t\t\t\tcurce = curce->parent;\n\t\t\t}\n\n\t\t\tfound = zend_lookup_class(ret_class, ret_class_len, &ce TSRMLS_CC);\n\t\t\tif ((found != SUCCESS) || !instanceof_function(*ce, curce TSRMLS_CC)) {\n\t\t\t\txmlFreeDoc(newdocp);\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING,\n\t\t\t\t\t\"Expecting class compatible with %s, '%s' given\", curclass_name, ret_class);\n\t\t\t\tRETURN_FALSE;\n\t\t\t}\n\n\t\t\tobject_init_ex(return_value, *ce);\n\n\t\t\tinterndoc = (php_libxml_node_object *)zend_objects_get_address(return_value TSRMLS_CC);\n\t\t\tphp_libxml_increment_doc_ref(interndoc, newdocp TSRMLS_CC);\n\t\t\tphp_libxml_increment_node_ptr(interndoc, (xmlNodePtr)newdocp, (void *)interndoc TSRMLS_CC);\n\t\t} else {\n\t\t\tDOM_RET_OBJ((xmlNodePtr) newdocp, &ret, NULL);\n\t\t}\n\t} else {\n\t\tRETURN_FALSE;\n\t}\n\n}","target":0,"code_token_length":458,"total_token_length":694,"max_tokens_setting":1024}
+{"idx":272346,"func":"generate_name(cms_context *cms, SECItem *der, CERTName *certname)\n{\n\tvoid *marka = PORT_ArenaMark(cms->arena);\n\tCERTRDN **rdns = certname->rdns;\n\tCERTRDN *rdn;\n\n\tint num_items = 0;\n\tint rc = 0;\n\n\twhile (rdns && (rdn = *rdns++) != NULL) {\n\t\tCERTAVA **avas = rdn->avas;\n\t\twhile (avas && ((*avas++) != NULL))\n\t\t\tnum_items++;\n\t}\n\n\tif (num_items == 0) {\n\t\tPORT_ArenaRelease(cms->arena, marka);\n\t\tcnreterr(-1, cms, \"No name items to encode\");\n\t}\n\n\tSECItem items[num_items];\n\n\tint i = 0;\n\trdns = certname->rdns;\n\twhile (rdns && (rdn = *rdns++) != NULL) {\n\t\tCERTAVA **avas = rdn->avas;\n\t\tCERTAVA *ava;\n\t\twhile (avas && (ava = *avas++) != NULL) {\n\t\t\tSECItem avader;\n\t\t\trc = generate_ava(cms, &avader, ava);\n\t\t\tif (rc < 0) {\n\t\t\t\tPORT_ArenaRelease(cms->arena, marka);\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tSECItem *list[2] = {\n\t\t\t\t&avader,\n\t\t\t\tNULL,\n\t\t\t};\n\t\t\trc = wrap_in_set(cms, &items[i], list);\n\t\t\tif (rc < 0) {\n\t\t\t\tPORT_ArenaRelease(cms->arena, marka);\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\twrap_in_seq(cms, der, &items[0], num_items);\n\tPORT_ArenaUnmark(cms->arena, marka);\n\n\treturn 0;\n}","target":0,"code_token_length":400,"total_token_length":636,"max_tokens_setting":1024}
+{"idx":264709,"func":"Graph* GetConstantGraph(\n    const Graph* orig_graph, const std::vector<Node*>& nodes,\n    const std::unordered_map<const Node*, std::vector<Tensor>>&\n        shape_replacement_map,\n    std::map<NodeAndOutput, NodeAndOutput>* tensors_to_fetch,\n    const ConstantFoldNameGenerator& generate_new_name) {\n  Graph* constant_graph = new Graph(orig_graph->op_registry());\n  std::unordered_map<Node*, std::vector<Node*>> node_map;\n  node_map[orig_graph->source_node()] = {constant_graph->source_node()};\n  node_map[orig_graph->sink_node()] = {constant_graph->sink_node()};\n  for (Node* n : nodes) {\n    if (shape_replacement_map.count(n) == 0) {\n      AddNodeToConstantGraph(n, &node_map, constant_graph);\n    } else {\n      AddShapeNodeToConstantGraph(n, shape_replacement_map, &node_map,\n                                  generate_new_name, constant_graph);\n    }\n  }\n\n  for (auto const& added_nodes : node_map) {\n    for (const Edge* out_edge : added_nodes.first->out_edges()) {\n      if (node_map.count(out_edge->dst()) == 0) {\n        if (out_edge->IsControlEdge()) continue;\n        if (added_nodes.second.size() == 1) {\n          tensors_to_fetch->insert(\n              {{added_nodes.second[0], out_edge->src_output()},\n               {added_nodes.first, out_edge->src_output()}});\n        } else {\n          \/\/ The node had multiple outputs and was replaced by a\n          \/\/ vector of constants, so the NodeAndOutput is the 0th\n          \/\/ output of the kth added constant, rather than the kth\n          \/\/ output of the added node as in the standard case above.\n          tensors_to_fetch->insert(\n              {{added_nodes.second[out_edge->src_output()], 0},\n               {added_nodes.first, out_edge->src_output()}});\n        }\n      }\n    }\n  }\n\n  return constant_graph;\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":226127,"func":"\nGF_Err trun_box_size(GF_Box *s)\n{\n\tGF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s;\n\n#ifdef GF_ENABLE_CTRN\n\tif (ptr->use_ctrn)\n\t\treturn ctrn_box_size(ptr);\n#endif\n\n\tptr->size += 4;\n\t\/\/The rest depends on the flags\n\tif (ptr->flags & GF_ISOM_TRUN_DATA_OFFSET) ptr->size += 4;\n\tif (ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) ptr->size += 4;\n\n\tif (ptr->sample_order) {\n\t\tu32 nb_bytes = 1;\n\t\tif (ptr->sample_count>0xFFFFFF) nb_bytes = 4;\n\t\telse if (ptr->sample_count>0xFFFF) nb_bytes = 3;\n\t\telse if (ptr->sample_count>0xFF) nb_bytes = 2;\n\t\tptr->size += ptr->sample_count*nb_bytes;\n\t}\n\n\tif (! (ptr->flags & (GF_ISOM_TRUN_DURATION | GF_ISOM_TRUN_SIZE | GF_ISOM_TRUN_FLAGS | GF_ISOM_TRUN_CTS_OFFSET) ) ) {\n\t\treturn GF_OK;\n\t}\n\n\t\/\/if nothing to do, this will be skipped automatically\n\tif (ptr->flags & GF_ISOM_TRUN_DURATION) ptr->size += 4*ptr->nb_samples;\n\tif (ptr->flags & GF_ISOM_TRUN_SIZE) ptr->size += 4*ptr->nb_samples;\n\t\/\/SHOULDN'T BE USED IF GF_ISOM_TRUN_FIRST_FLAG IS DEFINED\n\tif (ptr->flags & GF_ISOM_TRUN_FLAGS) ptr->size += 4*ptr->nb_samples;\n\tif (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) ptr->size += 4*ptr->nb_samples;\n\n\treturn GF_OK;","target":0,"code_token_length":391,"total_token_length":627,"max_tokens_setting":1024}
+{"idx":281160,"func":"int xfrm_policy_flush(struct net *net, u8 type, bool task_valid)\n{\n\tint dir, err = 0, cnt = 0;\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\n\terr = xfrm_policy_flush_secctx_check(net, type, task_valid);\n\tif (err)\n\t\tgoto out;\n\n\tfor (dir = 0; dir < XFRM_POLICY_MAX; dir++) {\n\t\tstruct xfrm_policy *pol;\n\t\tint i;\n\n\tagain1:\n\t\thlist_for_each_entry(pol,\n\t\t\t\t     &net->xfrm.policy_inexact[dir], bydst) {\n\t\t\tif (pol->type != type)\n\t\t\t\tcontinue;\n\t\t\t__xfrm_policy_unlink(pol, dir);\n\t\t\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\t\t\tcnt++;\n\n\t\t\txfrm_audit_policy_delete(pol, 1, task_valid);\n\n\t\t\txfrm_policy_kill(pol);\n\n\t\t\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\t\t\tgoto again1;\n\t\t}\n\n\t\tfor (i = net->xfrm.policy_bydst[dir].hmask; i >= 0; i--) {\n\tagain2:\n\t\t\thlist_for_each_entry(pol,\n\t\t\t\t\t     net->xfrm.policy_bydst[dir].table + i,\n\t\t\t\t\t     bydst) {\n\t\t\t\tif (pol->type != type)\n\t\t\t\t\tcontinue;\n\t\t\t\t__xfrm_policy_unlink(pol, dir);\n\t\t\t\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\t\t\t\tcnt++;\n\n\t\t\t\txfrm_audit_policy_delete(pol, 1, task_valid);\n\t\t\t\txfrm_policy_kill(pol);\n\n\t\t\t\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\t\t\t\tgoto again2;\n\t\t\t}\n\t\t}\n\n\t}\n\tif (!cnt)\n\t\terr = -ESRCH;\nout:\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\treturn err;\n}","target":0,"code_token_length":386,"total_token_length":622,"max_tokens_setting":1024}
+{"idx":517437,"func":"static void do_viewlog(HttpRequest req, HttpResponse res) {\n        if (is_readonly(req)) {\n                send_error(req, res, SC_FORBIDDEN, \"You do not have sufficient privileges to access this page\");\n                return;\n        }\n        do_head(res, \"_viewlog\", \"View log\", 100);\n        if ((Run.flags & Run_Log) && ! (Run.flags & Run_UseSyslog)) {\n                FILE *f = fopen(Run.files.log, \"r\");\n                if (f) {\n                        size_t n;\n                        char buf[512];\n                        StringBuffer_append(res->outputbuffer, \"<br><p><form><textarea cols=120 rows=30 readonly>\");\n                        while ((n = fread(buf, sizeof(char), sizeof(buf) - 1, f)) > 0) {\n                                buf[n] = 0;\n                                escapeHTML(res->outputbuffer, buf);\n                        }\n                        fclose(f);\n                        StringBuffer_append(res->outputbuffer, \"<\/textarea><\/form>\");\n                } else {\n                        StringBuffer_append(res->outputbuffer, \"Error opening logfile: %s\", STRERROR);\n                }\n        } else {\n                StringBuffer_append(res->outputbuffer,\n                                    \"<b>Cannot view logfile:<\/b><br>\");\n                if (! (Run.flags & Run_Log))\n                        StringBuffer_append(res->outputbuffer, \"Monit was started without logging\");\n                else\n                        StringBuffer_append(res->outputbuffer, \"Monit uses syslog\");\n        }\n        do_foot(res);\n}","target":0,"code_token_length":313,"total_token_length":549,"max_tokens_setting":1024}
+{"idx":234158,"func":"load_debug_sup_file (const char * main_filename, void * file)\n{\n  if (! load_debug_section (debug_sup, file))\n    return; \/* No .debug_sup section.  *\/\n\n  struct dwarf_section * section;\n  section = & debug_displays [debug_sup].section;\n  assert (section != NULL);\n\n  if (section->start == NULL || section->size < 5)\n    {\n      warn (_(\".debug_sup section is corrupt\/empty\\n\"));\n      return;\n    }\n\n  if (section->start[2] != 0)\n    return; \/* This is a supplementary file.  *\/\n\n  const char * filename = (const char *) section->start + 3;\n  if (strnlen (filename, section->size - 3) == section->size - 3)\n    {\n      warn (_(\"filename in .debug_sup section is corrupt\\n\"));\n      return;\n    }\n\n  if (filename[0] != '\/' && strchr (main_filename, '\/'))\n    {\n      char * new_name;\n      int new_len;\n\n      new_len = asprintf (& new_name, \"%.*s\/%s\",\n\t\t\t  (int) (strrchr (main_filename, '\/') - main_filename),\n\t\t\t  main_filename,\n\t\t\t  filename);\n      if (new_len < 3)\n\t{\n\t  warn (_(\"unable to construct path for supplementary debug file\"));\n\t  if (new_len > -1)\n\t    free (new_name);\n\t  return;\n\t}\n      filename = new_name;\n    }\n  else\n    {\n      \/* PR 27796: Make sure that we pass a filename that can be free'd to\n\t add_separate_debug_file().  *\/\n      filename = strdup (filename);\n      if (filename == NULL)\n\t{\n\t  warn (_(\"out of memory constructing filename for .debug_sup link\\n\"));\n\t  return;\n\t}\n    }\n\n  void * handle = open_debug_file (filename);\n  if (handle == NULL)\n    {\n      warn (_(\"unable to open file '%s' referenced from .debug_sup section\\n\"), filename);\n      free ((void *) filename);\n      return;\n    }\n\n  printf (_(\"%s: Found supplementary debug file: %s\\n\\n\"), main_filename, filename);\n\n  \/* FIXME: Compare the checksums, if present.  *\/\n  add_separate_debug_file (filename, handle);\n}","target":0,"code_token_length":489,"total_token_length":725,"max_tokens_setting":1024}
+{"idx":224729,"func":"GF_Err meta_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MetaBox *ptr = (GF_MetaBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_HDLR:\n\t\tBOX_FIELD_ASSIGN(handler, GF_HandlerBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_PITM:\n\t\tBOX_FIELD_ASSIGN(primary_resource, GF_PrimaryItemBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_DINF:\n\t\tBOX_FIELD_ASSIGN(file_locations, GF_DataInformationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_ILOC:\n\t\tBOX_FIELD_ASSIGN(item_locations, GF_ItemLocationBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_IPRO:\n\t\tBOX_FIELD_ASSIGN(protections, GF_ItemProtectionBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_IINF:\n\t\tBOX_FIELD_ASSIGN(item_infos, GF_ItemInfoBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_IREF:\n\t\tBOX_FIELD_ASSIGN(item_refs, GF_ItemReferenceBox);\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_IPRP:\n\t\tBOX_FIELD_ASSIGN(item_props, GF_ItemPropertiesBox)\n\t\tbreak;\n\tcase GF_ISOM_BOX_TYPE_GRPL:\n\t\tBOX_FIELD_ASSIGN(groups_list, GF_GroupListBox)\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":276,"total_token_length":512,"max_tokens_setting":1024}
+{"idx":242266,"func":"bool PamAuthenticateUser(BareosSocket* UA_sock,\n                         const std::string& username_in,\n                         const std::string& password_in,\n                         std::string& authenticated_username)\n{\n  std::unique_ptr<PamData> pam_callback_data(new PamData(UA_sock, password_in));\n  std::unique_ptr<struct pam_conv> pam_conversation_container(\n      new struct pam_conv);\n  struct pam_handle* pamh = nullptr; \/* pam session handle *\/\n\n  bool interactive = true;\n  if (!username_in.empty() && !password_in.empty()) { interactive = false; }\n  pam_conversation_container->conv\n      = interactive ? PamConversationCallback : PamLocalCallback;\n  pam_conversation_container->appdata_ptr = pam_callback_data.get();\n\n  const char* username = username_in.empty() ? nullptr : username_in.c_str();\n  int err = pam_start(service_name.c_str(), username,\n                      pam_conversation_container.get(), &pamh);\n  if (err != PAM_SUCCESS) {\n    Dmsg1(debuglevel, \"PAM start failed: %s\\n\", pam_strerror(pamh, err));\n    return false;\n  }\n\n  err = DoPamAuth(pamh, username, authenticated_username);\n\n  if (pam_end(pamh, err) != PAM_SUCCESS) {\n    Dmsg1(debuglevel, \"PAM end failed: %s\\n\", pam_strerror(pamh, err));\n    return false;\n  }\n\n  if (err == PAM_SUCCESS) {\n    bool ok = true;\n    if (interactive) { ok = PamConvSendMessage(UA_sock, \"\", PAM_SUCCESS); }\n    return ok;\n  }\n  return false;\n}","target":0,"code_token_length":354,"total_token_length":590,"max_tokens_setting":1024}
+{"idx":436095,"func":"static int io_iopoll_check(struct io_ring_ctx *ctx, long min)\n{\n\tunsigned int nr_events = 0;\n\tint ret = 0;\n\n\t\/*\n\t * We disallow the app entering submit\/complete with polling, but we\n\t * still need to lock the ring to prevent racing with polled issue\n\t * that got punted to a workqueue.\n\t *\/\n\tmutex_lock(&ctx->uring_lock);\n\t\/*\n\t * Don't enter poll loop if we already have events pending.\n\t * If we do, we can potentially be spinning for commands that\n\t * already triggered a CQE (eg in error).\n\t *\/\n\tif (test_bit(0, &ctx->check_cq_overflow))\n\t\t__io_cqring_overflow_flush(ctx, false);\n\tif (io_cqring_events(ctx))\n\t\tgoto out;\n\tdo {\n\t\t\/*\n\t\t * If a submit got punted to a workqueue, we can have the\n\t\t * application entering polling for a command before it gets\n\t\t * issued. That app will hold the uring_lock for the duration\n\t\t * of the poll right here, so we need to take a breather every\n\t\t * now and then to ensure that the issue has a chance to add\n\t\t * the poll to the issued list. Otherwise we can spin here\n\t\t * forever, while the workqueue is stuck trying to acquire the\n\t\t * very same mutex.\n\t\t *\/\n\t\tif (list_empty(&ctx->iopoll_list)) {\n\t\t\tu32 tail = ctx->cached_cq_tail;\n\n\t\t\tmutex_unlock(&ctx->uring_lock);\n\t\t\tio_run_task_work();\n\t\t\tmutex_lock(&ctx->uring_lock);\n\n\t\t\t\/* some requests don't go through iopoll_list *\/\n\t\t\tif (tail != ctx->cached_cq_tail ||\n\t\t\t    list_empty(&ctx->iopoll_list))\n\t\t\t\tbreak;\n\t\t}\n\t\tret = io_do_iopoll(ctx, &nr_events, min);\n\t} while (!ret && nr_events < min && !need_resched());\nout:\n\tmutex_unlock(&ctx->uring_lock);\n\treturn ret;\n}","target":0,"code_token_length":436,"total_token_length":672,"max_tokens_setting":1024}
+{"idx":310324,"func":"dirserv_add_extrainfo(extrainfo_t *ei, const char **msg)\n{\n  routerinfo_t *ri;\n  int r;\n  tor_assert(msg);\n  *msg = NULL;\n\n  ri = router_get_by_digest(ei->cache_info.identity_digest);\n  if (!ri) {\n    *msg = \"No corresponding router descriptor for extra-info descriptor\";\n    extrainfo_free(ei);\n    return ROUTER_BAD_EI;\n  }\n\n  \/* If it's too big, refuse it now. Otherwise we'll cache it all over the\n   * network and it'll clog everything up. *\/\n  if (ei->cache_info.signed_descriptor_len > MAX_EXTRAINFO_UPLOAD_SIZE) {\n    log_notice(LD_DIR, \"Somebody attempted to publish an extrainfo \"\n               \"with size %d. Either this is an attack, or the \"\n               \"MAX_EXTRAINFO_UPLOAD_SIZE (%d) constant is too low.\",\n               (int)ei->cache_info.signed_descriptor_len,\n               MAX_EXTRAINFO_UPLOAD_SIZE);\n    *msg = \"Extrainfo document was too large\";\n    extrainfo_free(ei);\n    return ROUTER_BAD_EI;\n  }\n\n  if ((r = routerinfo_incompatible_with_extrainfo(ri, ei, NULL, msg))) {\n    extrainfo_free(ei);\n    return r < 0 ? ROUTER_WAS_NOT_NEW : ROUTER_BAD_EI;\n  }\n  router_add_extrainfo_to_routerlist(ei, msg, 0, 0);\n  return ROUTER_ADDED_SUCCESSFULLY;\n}","target":0,"code_token_length":330,"total_token_length":566,"max_tokens_setting":1024}
+{"idx":485285,"func":"static int unzzip_cat (int argc, char ** argv, int extract)\n{\n    int argn;\n    ZZIP_DIR* disk;\n    zzip_error_t error;\n    \n    if (argc == 1)\n    {\n        printf (__FILE__\" version \"ZZIP_PACKAGE\" \"ZZIP_VERSION\"\\n\");\n        return -1; \/* better provide an archive argument *\/\n    }\n    \n    disk = zzip_dir_open (argv[1], &error);\n    if (! disk) {\n\tfprintf(stderr, \"%s: %s\\n\", argv[1], zzip_strerror(error));\n\treturn -1;\n    }\n\n    if (argc == 2)\n    {  \/* list all *\/\n\tZZIP_DIRENT entry;\n\twhile(zzip_dir_read(disk, &entry))\n\t{\n\t    char* name = entry.d_name;\n\t    FILE* out = stdout;\n\t    if (extract) out = create_fopen(name, \"w\", 1);\n\t    if (out) {\n\t        unzzip_cat_file (disk, name, out);\n\t        if (extract) fclose(out);\n\t    }\n\t}\n    }\n    else\n    {   \/* list only the matching entries - in order of zip directory *\/\n\tZZIP_DIRENT entry;\n\twhile(zzip_dir_read(disk, &entry))\n\t{\n\t    char* name = entry.d_name;\n\t    for (argn=1; argn < argc; argn++)\n\t    {\n\t\tif (! _zzip_fnmatch (argv[argn], name, \n\t\t    FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))\n\t        {\n\t            FILE* out = stdout;\n\t            if (extract) out = create_fopen(name, \"w\", 1);\n\t            if (out) {\n\t\t        unzzip_cat_file (disk, name, out);\n\t\t        if (extract) fclose(out);\n\t\t    }\n\t\t    break; \/* match loop *\/\n\t        }\n\t    }\n\t}\n    }\n    zzip_dir_close(disk);\n    return 0;\n} ","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":359253,"func":"bgp_vty_return (struct vty *vty, int ret)\n{\n  const char *str = NULL;\n\n  switch (ret)\n    {\n    case BGP_ERR_INVALID_VALUE:\n      str = \"Invalid value\";\n      break;\n    case BGP_ERR_INVALID_FLAG:\n      str = \"Invalid flag\";\n      break;\n    case BGP_ERR_PEER_INACTIVE:\n      str = \"Activate the neighbor for the address family first\";\n      break;\n    case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:\n      str = \"Invalid command for a peer-group member\";\n      break;\n    case BGP_ERR_PEER_GROUP_SHUTDOWN:\n      str = \"Peer-group has been shutdown. Activate the peer-group first\";\n      break;\n    case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:\n      str = \"This peer is a peer-group member.  Please change peer-group configuration\";\n      break;\n    case BGP_ERR_PEER_FLAG_CONFLICT:\n      str = \"Can't set override-capability and strict-capability-match at the same time\";\n      break;\n    case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:\n      str = \"No activate for peergroup can be given only if peer-group has no members\";\n      break;\n    case BGP_ERR_PEER_BELONGS_TO_GROUP:\n      str = \"No activate for an individual peer-group member is invalid\";\n      break;\n    case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:\n      str = \"Activate the peer-group for the address family first\";\n      break;\n    case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:\n      str = \"Specify remote-as or peer-group remote AS first\";\n      break;\n    case BGP_ERR_PEER_GROUP_CANT_CHANGE:\n      str = \"Cannot change the peer-group. Deconfigure first\";\n      break;\n    case BGP_ERR_PEER_GROUP_MISMATCH:\n      str = \"Cannot have different peer-group for the neighbor\";\n      break;\n    case BGP_ERR_PEER_FILTER_CONFLICT:\n      str = \"Prefix\/distribute list can not co-exist\";\n      break;\n    case BGP_ERR_NOT_INTERNAL_PEER:\n      str = \"Invalid command. Not an internal neighbor\";\n      break;\n    case BGP_ERR_REMOVE_PRIVATE_AS:\n      str = \"Private AS cannot be removed for IBGP peers\";\n      break;\n    case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:\n      str = \"Local-AS allowed only for EBGP peers\";\n      break;\n    case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:\n      str = \"Cannot have local-as same as BGP AS number\";\n      break;\n    }\n  if (str)\n    {\n      vty_out (vty, \"%% %s%s\", str, VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":572,"total_token_length":808,"max_tokens_setting":1024}
+{"idx":344775,"func":"argv_assemble(int argc, char **argv)\n{\n\tint i, j, ws, r;\n\tchar c, *ret;\n\tstruct sshbuf *buf, *arg;\n\n\tif ((buf = sshbuf_new()) == NULL || (arg = sshbuf_new()) == NULL)\n\t\tfatal_f(\"sshbuf_new failed\");\n\n\tfor (i = 0; i < argc; i++) {\n\t\tws = 0;\n\t\tsshbuf_reset(arg);\n\t\tfor (j = 0; argv[i][j] != '\\0'; j++) {\n\t\t\tr = 0;\n\t\t\tc = argv[i][j];\n\t\t\tswitch (c) {\n\t\t\tcase ' ':\n\t\t\tcase '\\t':\n\t\t\t\tws = 1;\n\t\t\t\tr = sshbuf_put_u8(arg, c);\n\t\t\t\tbreak;\n\t\t\tcase '\\\\':\n\t\t\tcase '\\'':\n\t\t\tcase '\"':\n\t\t\t\tif ((r = sshbuf_put_u8(arg, '\\\\')) != 0)\n\t\t\t\t\tbreak;\n\t\t\t\t\/* FALLTHROUGH *\/\n\t\t\tdefault:\n\t\t\t\tr = sshbuf_put_u8(arg, c);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (r != 0)\n\t\t\t\tfatal_fr(r, \"sshbuf_put_u8\");\n\t\t}\n\t\tif ((i != 0 && (r = sshbuf_put_u8(buf, ' ')) != 0) ||\n\t\t    (ws != 0 && (r = sshbuf_put_u8(buf, '\"')) != 0) ||\n\t\t    (r = sshbuf_putb(buf, arg)) != 0 ||\n\t\t    (ws != 0 && (r = sshbuf_put_u8(buf, '\"')) != 0))\n\t\t\tfatal_fr(r, \"assemble\");\n\t}\n\tif ((ret = malloc(sshbuf_len(buf) + 1)) == NULL)\n\t\tfatal_f(\"malloc failed\");\n\tmemcpy(ret, sshbuf_ptr(buf), sshbuf_len(buf));\n\tret[sshbuf_len(buf)] = '\\0';\n\tsshbuf_free(buf);\n\tsshbuf_free(arg);\n\treturn ret;\n}","target":0,"code_token_length":417,"total_token_length":653,"max_tokens_setting":1024}
+{"idx":442802,"func":"void progressbarinit(struct ProgressData *bar,\n                     struct Configurable *config)\n{\n#ifdef __EMX__\n  \/* 20000318 mgs *\/\n  int scr_size [2];\n#endif\n  char *colp;\n\n  memset(bar, 0, sizeof(struct ProgressData));\n\n  \/* pass this through to progress function so\n   * it can display progress towards total file\n   * not just the part that's left. (21-may-03, dbyron) *\/\n  if (config->use_resume)\n    bar->initial_size = config->resume_from;\n\n\/* TODO: get terminal width through ansi escapes or something similar.\n         try to update width when xterm is resized... - 19990617 larsa *\/\n#ifndef __EMX__\n  \/* 20000318 mgs\n   * OS\/2 users most likely won't have this env var set, and besides that\n   * we're using our own way to determine screen width *\/\n  colp = curlx_getenv(\"COLUMNS\");\n  if (colp != NULL) {\n    bar->width = atoi(colp);\n    curl_free(colp);\n  }\n  else\n    bar->width = 79;\n#else\n  \/* 20000318 mgs\n   * We use this emx library call to get the screen width, and subtract\n   * one from what we got in order to avoid a problem with the cursor\n   * advancing to the next line if we print a string that is as long as\n   * the screen is wide. *\/\n\n  _scrsize(scr_size);\n  bar->width = scr_size[0] - 1;\n#endif\n\n  bar->out = config->errors;\n}","target":0,"code_token_length":379,"total_token_length":615,"max_tokens_setting":1024}
+{"idx":317259,"func":"static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,\n\t\t\t\tint size)\n{\n\tstruct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name;\n#if IS_ENABLED(CONFIG_IPV6)\n\tstruct sockaddr_in6 *sap = (struct sockaddr_in6 *) msg->msg_name;\n#endif\n#ifdef SMACK_IPV6_SECMARK_LABELING\n\tstruct socket_smack *ssp = sock->sk->sk_security;\n\tstruct smack_known *rsp;\n#endif\n\tint rc = 0;\n\n\t\/*\n\t * Perfectly reasonable for this to be NULL\n\t *\/\n\tif (sip == NULL)\n\t\treturn 0;\n\n\tswitch (sock->sk->sk_family) {\n\tcase AF_INET:\n\t\tif (msg->msg_namelen < sizeof(struct sockaddr_in) ||\n\t\t    sip->sin_family != AF_INET)\n\t\t\treturn -EINVAL;\n\t\trc = smk_ipv4_check(sock->sk, sip);\n\t\tbreak;\n#if IS_ENABLED(CONFIG_IPV6)\n\tcase AF_INET6:\n\t\tif (msg->msg_namelen < SIN6_LEN_RFC2133 ||\n\t\t    sap->sin6_family != AF_INET6)\n\t\t\treturn -EINVAL;\n#ifdef SMACK_IPV6_SECMARK_LABELING\n\t\trsp = smack_ipv6host_label(sap);\n\t\tif (rsp != NULL)\n\t\t\trc = smk_ipv6_check(ssp->smk_out, rsp, sap,\n\t\t\t\t\t\tSMK_CONNECTING);\n#endif\n#ifdef SMACK_IPV6_PORT_LABELING\n\t\trc = smk_ipv6_port_check(sock->sk, sap, SMK_SENDING);\n#endif\n#endif \/* IS_ENABLED(CONFIG_IPV6) *\/\n\t\tbreak;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":346,"total_token_length":582,"max_tokens_setting":1024}
+{"idx":500698,"func":"sftp_statvfs_t sftp_fstatvfs(sftp_file file) {\n  sftp_status_message status = NULL;\n  sftp_message msg = NULL;\n  sftp_session sftp;\n  ssh_string ext;\n  ssh_buffer buffer;\n  uint32_t id;\n\n  if (file == NULL) {\n    return NULL;\n  }\n  sftp = file->sftp;\n\n  buffer = ssh_buffer_new();\n  if (buffer == NULL) {\n    ssh_set_error_oom(sftp->session);\n    return NULL;\n  }\n\n  ext = ssh_string_from_char(\"fstatvfs@openssh.com\");\n  if (ext == NULL) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    return NULL;\n  }\n\n  id = sftp_get_new_id(sftp);\n  if (buffer_add_u32(buffer, id) < 0 ||\n      buffer_add_ssh_string(buffer, ext) < 0 ||\n      buffer_add_ssh_string(buffer, file->handle) < 0) {\n    ssh_set_error_oom(sftp->session);\n    ssh_buffer_free(buffer);\n    ssh_string_free(ext);\n    return NULL;\n  }\n  if (sftp_packet_write(sftp, SSH_FXP_EXTENDED, buffer) < 0) {\n    ssh_buffer_free(buffer);\n    ssh_string_free(ext);\n    return NULL;\n  }\n  ssh_buffer_free(buffer);\n  ssh_string_free(ext);\n\n  while (msg == NULL) {\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      return NULL;\n    }\n    msg = sftp_dequeue(sftp, id);\n  }\n\n  if (msg->packet_type == SSH_FXP_EXTENDED_REPLY) {\n  \tsftp_statvfs_t buf = sftp_parse_statvfs(sftp, msg->payload);\n    sftp_message_free(msg);\n    if (buf == NULL) {\n      return NULL;\n    }\n\n    return buf;\n  } else if (msg->packet_type == SSH_FXP_STATUS) { \/* bad response (error) *\/\n    status = parse_status_msg(msg);\n    sftp_message_free(msg);\n    if (status == NULL) {\n      return NULL;\n    }\n    ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n        \"SFTP server: %s\", status->errormsg);\n    status_msg_free(status);\n  } else { \/* this shouldn't happen *\/\n    ssh_set_error(sftp->session, SSH_FATAL,\n        \"Received message %d when attempting to set stats\", msg->packet_type);\n    sftp_message_free(msg);\n  }\n\n  return NULL;\n}","target":0,"code_token_length":538,"total_token_length":774,"max_tokens_setting":1024}
+{"idx":194998,"func":"Status ConstantFolding::IsSimplifiableReshape(\n    const NodeDef& node, const GraphProperties& properties) const {\n  if (!IsReshape(node)) {\n    return errors::Internal(\"Node \", node.name(), \" is not a Reshape node\");\n  }\n  if (2 > node.input_size()) {\n    return errors::Internal(\"Node \", node.name(),\n                            \" must have at most 2 inputs but has \",\n                            node.input_size());\n  }\n  const NodeDef* new_shape = node_map_->GetNode(node.input(1));\n  if (!IsReallyConstant(*new_shape)) {\n    return errors::Internal(\"Node \", node.name(), \" has shape \",\n                            new_shape->DebugString(),\n                            \" which is not a constant\");\n  }\n  TensorVector outputs;\n  auto outputs_cleanup = gtl::MakeCleanup([&outputs] {\n    for (const auto& output : outputs) {\n      delete output.tensor;\n    }\n  });\n\n  Status s = EvaluateNode(*new_shape, TensorVector(), &outputs);\n  if (!s.ok()) {\n    return errors::Internal(\"Could not evaluate node \", node.name());\n  }\n  if (outputs.size() != 1) {\n    return errors::Internal(\"Node \", node.name(),\n                            \" must have exactly 1 output but has \",\n                            outputs.size());\n  }\n\n  const std::vector<OpInfo::TensorProperties>& props =\n      properties.GetInputProperties(node.name());\n  if (props.empty()) {\n    return errors::Internal(\"Node \", node.name(), \" has no properties\");\n  }\n  const OpInfo::TensorProperties& prop = props[0];\n  if (prop.dtype() == DT_INVALID) {\n    return errors::Internal(\"Node \", node.name(), \" has property \",\n                            prop.DebugString(), \" with invalid dtype\");\n  }\n  const PartialTensorShape shape(prop.shape());\n  if (!shape.IsFullyDefined()) {\n    return errors::Internal(\"Node \", node.name(), \" has property \",\n                            prop.DebugString(), \" with shape \",\n                            shape.DebugString(), \" which is not fully defined\");\n  }\n\n  PartialTensorShape new_dims;\n  if (outputs[0]->dtype() == DT_INT32) {\n    std::vector<int32> shp;\n    for (int i = 0; i < outputs[0]->NumElements(); ++i) {\n      int32_t dim = outputs[0]->flat<int32>()(i);\n      shp.push_back(dim);\n    }\n    TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims));\n  } else {\n    std::vector<int64_t> shp;\n    for (int i = 0; i < outputs[0]->NumElements(); ++i) {\n      int64_t dim = outputs[0]->flat<int64_t>()(i);\n      shp.push_back(dim);\n    }\n    TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims));\n  }\n\n  if (!shape.IsCompatibleWith(new_dims)) {\n    return errors::Internal(\"Expected shape \", shape.DebugString(),\n                            \"to be compatible with \", new_dims.DebugString());\n  }\n\n  return Status::OK();\n}","target":1,"code_token_length":664,"total_token_length":900,"max_tokens_setting":1024}
+{"idx":364765,"func":"findtags_copy_matches(findtags_state_T *st, char_u ***matchesp)\n{\n    int\t\tname_only = (st->flags & TAG_NAMES);\n    char_u\t**matches;\n    int\t\tmtt;\n    int\t\ti;\n    char_u\t*mfp;\n    char_u\t*p;\n\n    if (st->match_count > 0)\n\tmatches = ALLOC_MULT(char_u *, st->match_count);\n    else\n\tmatches = NULL;\n    st->match_count = 0;\n    for (mtt = 0; mtt < MT_COUNT; ++mtt)\n    {\n\tfor (i = 0; i < st->ga_match[mtt].ga_len; ++i)\n\t{\n\t    mfp = ((char_u **)(st->ga_match[mtt].ga_data))[i];\n\t    if (matches == NULL)\n\t\tvim_free(mfp);\n\t    else\n\t    {\n\t\tif (!name_only)\n\t\t{\n\t\t    \/\/ Change mtt back to zero-based.\n\t\t    *mfp = *mfp - 1;\n\n\t\t    \/\/ change the TAG_SEP back to NUL\n\t\t    for (p = mfp + 1; *p != NUL; ++p)\n\t\t\tif (*p == TAG_SEP)\n\t\t\t    *p = NUL;\n\t\t}\n\t\tmatches[st->match_count++] = mfp;\n\t    }\n\t}\n\n\tga_clear(&st->ga_match[mtt]);\n\thash_clear(&st->ht_match[mtt]);\n    }\n\n    *matchesp = matches;\n    return st->match_count;\n}","target":0,"code_token_length":329,"total_token_length":565,"max_tokens_setting":1024}
+{"idx":293751,"func":"static int kernelcache_io_read(RIO *io, RIODesc *fd, ut8 *buf, int count) {\n\tr_return_val_if_fail (io, -1);\n\tRCore *core = (RCore*) io->corebind.core;\n\n\tif (!fd || !core || !core->bin || !core->bin->binfiles) {\n\t\treturn -1;\n\t}\n\n\tRKernelCacheObj *cache = NULL;\n\tRListIter *iter;\n\tRBinFile *bf;\n\tr_list_foreach (core->bin->binfiles, iter, bf) {\n\t\tif (bf->fd == fd->fd && bf->o && bf->o->bin_obj) {\n\t\t\tcache = bf->o->bin_obj;\n\t\t\tif (pending_bin_files) {\n\t\t\t\tRListIter *to_remove = r_list_contains (pending_bin_files, bf);\n\t\t\t\tif (to_remove) {\n\t\t\t\t\tr_list_delete (pending_bin_files, to_remove);\n\t\t\t\t\tif (r_list_empty (pending_bin_files)) {\n\t\t\t\t\t\tr_list_free (pending_bin_files);\n\t\t\t\t\t\tpending_bin_files = NULL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!cache) {\n\t\tr_list_foreach (pending_bin_files, iter, bf) {\n\t\t\tif (bf->fd == fd->fd && bf->o) {\n\t\t\t\tcache = bf->o->bin_obj;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!cache || !cache->original_io_read || cache->rebasing_buffer) {\n\t\tif (cache) {\n\t\t\tif ((!cache->rebasing_buffer && fd->plugin->read == &kernelcache_io_read) ||\n\t\t\t\t\t(cache->rebasing_buffer && !cache->original_io_read)) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (cache->rebasing_buffer) {\n\t\t\t\treturn cache->original_io_read (io, fd, buf, count);\n\t\t\t}\n\t\t}\n\t\tif (fd->plugin->read == kernelcache_io_read) {\n\t\t\tif (core->bin->verbose) {\n\t\t\t\teprintf (\"Avoid recursive reads\\n\");\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t\treturn fd->plugin->read (io, fd, buf, count);\n\t}\n\n\tif (cache->rebase_info) {\n\t\tr_rebase_info_populate (cache->rebase_info, cache);\n\t}\n\n\tstatic ut8 *internal_buffer = NULL;\n\tstatic int internal_buf_size = 0;\n\tif (count > internal_buf_size) {\n\t\tif (internal_buffer) {\n\t\t\tR_FREE (internal_buffer);\n\t\t\tinternal_buffer = NULL;\n\t\t}\n\t\tinternal_buffer = (ut8 *) malloc (count);\n\t\tinternal_buf_size = count;\n\t}\n\n\tif (!cache->original_io_read) {\n\t\treturn -1;\n\t}\n\tut64 io_off = io->off;\n\tint result = cache->original_io_read (io, fd, internal_buffer, count);\n\n\tif (result == count) {\n\t\tif (cache->mach0->chained_starts) {\n\t\t\trebase_buffer_fixup (cache, io_off, fd, internal_buffer, count);\n\t\t} else if (cache->rebase_info) {\n\t\t\trebase_buffer (cache, io_off, fd, internal_buffer, count);\n\t\t}\n\t\tmemcpy (buf, internal_buffer, result);\n\t}\n\n\treturn result;\n}","target":0,"code_token_length":695,"total_token_length":931,"max_tokens_setting":1024}
+{"idx":312461,"func":"qf_buf_add_line(\n\tbuf_T\t\t*buf,\t\t\/\/ quickfix window buffer\n\tlinenr_T\tlnum,\n\tqfline_T\t*qfp,\n\tchar_u\t\t*dirname,\n\tint\t\tfirst_bufline,\n\tchar_u\t\t*qftf_str)\n{\n    int\t\tlen;\n    buf_T\t*errbuf;\n\n    \/\/ If the 'quickfixtextfunc' function returned a non-empty custom string\n    \/\/ for this entry, then use it.\n    if (qftf_str != NULL && *qftf_str != NUL)\n\tvim_strncpy(IObuff, qftf_str, IOSIZE - 1);\n    else\n    {\n\tif (qfp->qf_module != NULL)\n\t{\n\t    vim_strncpy(IObuff, qfp->qf_module, IOSIZE - 1);\n\t    len = (int)STRLEN(IObuff);\n\t}\n\telse if (qfp->qf_fnum != 0\n\t\t&& (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL\n\t\t&& errbuf->b_fname != NULL)\n\t{\n\t    if (qfp->qf_type == 1)\t\/\/ :helpgrep\n\t\tvim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1);\n\t    else\n\t    {\n\t\t\/\/ Shorten the file name if not done already.\n\t\t\/\/ For optimization, do this only for the first entry in a\n\t\t\/\/ buffer.\n\t\tif (first_bufline && (errbuf->b_sfname == NULL\n\t\t\t\t|| mch_isFullName(errbuf->b_sfname)))\n\t\t{\n\t\t    if (*dirname == NUL)\n\t\t\tmch_dirname(dirname, MAXPATHL);\n\t\t    shorten_buf_fname(errbuf, dirname, FALSE);\n\t\t}\n\t\tvim_strncpy(IObuff, errbuf->b_fname, IOSIZE - 1);\n\t    }\n\t    len = (int)STRLEN(IObuff);\n\t}\n\telse\n\t    len = 0;\n\n\tif (len < IOSIZE - 1)\n\t    IObuff[len++] = '|';\n\n\tif (qfp->qf_lnum > 0)\n\t{\n\t    qf_range_text(qfp, IObuff + len, IOSIZE - len);\n\t    len += (int)STRLEN(IObuff + len);\n\n\t    vim_snprintf((char *)IObuff + len, IOSIZE - len, \"%s\",\n\t\t    (char *)qf_types(qfp->qf_type, qfp->qf_nr));\n\t    len += (int)STRLEN(IObuff + len);\n\t}\n\telse if (qfp->qf_pattern != NULL)\n\t{\n\t    qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);\n\t    len += (int)STRLEN(IObuff + len);\n\t}\n\tif (len < IOSIZE - 2)\n\t{\n\t    IObuff[len++] = '|';\n\t    IObuff[len++] = ' ';\n\t}\n\n\t\/\/ Remove newlines and leading whitespace from the text.\n\t\/\/ For an unrecognized line keep the indent, the compiler may\n\t\/\/ mark a word with ^^^^.\n\tqf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,\n\t\tIObuff + len, IOSIZE - len);\n    }\n\n    if (ml_append_buf(buf, lnum, IObuff,\n\t\t(colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL)\n\treturn FAIL;\n\n    return OK;\n}","target":0,"code_token_length":755,"total_token_length":991,"max_tokens_setting":1024}
+{"idx":221500,"func":"flatpak_run_add_session_dbus_args (FlatpakBwrap   *app_bwrap,\n                                   FlatpakBwrap   *proxy_arg_bwrap,\n                                   FlatpakContext *context,\n                                   FlatpakRunFlags flags,\n                                   const char     *app_id)\n{\n  static const char sandbox_socket_path[] = \"\/run\/flatpak\/bus\";\n  static const char sandbox_dbus_address[] = \"unix:path=\/run\/flatpak\/bus\";\n  gboolean unrestricted, no_proxy;\n  const char *dbus_address = g_getenv (\"DBUS_SESSION_BUS_ADDRESS\");\n  g_autofree char *dbus_session_socket = NULL;\n\n  unrestricted = (context->sockets & FLATPAK_CONTEXT_SOCKET_SESSION_BUS) != 0;\n\n  if (dbus_address != NULL)\n    {\n      dbus_session_socket = extract_unix_path_from_dbus_address (dbus_address);\n    }\n  else\n    {\n      g_autofree char *user_runtime_dir = flatpak_get_real_xdg_runtime_dir ();\n      struct stat statbuf;\n\n      dbus_session_socket = g_build_filename (user_runtime_dir, \"bus\", NULL);\n\n      if (stat (dbus_session_socket, &statbuf) < 0\n          || (statbuf.st_mode & S_IFMT) != S_IFSOCK\n          || statbuf.st_uid != getuid ())\n        return FALSE;\n    }\n\n  if (unrestricted)\n    g_debug (\"Allowing session-dbus access\");\n\n  no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY) != 0;\n\n  if (dbus_session_socket != NULL && unrestricted)\n    {\n      flatpak_bwrap_add_args (app_bwrap,\n                              \"--ro-bind\", dbus_session_socket, sandbox_socket_path,\n                              NULL);\n      flatpak_bwrap_set_env (app_bwrap, \"DBUS_SESSION_BUS_ADDRESS\", sandbox_dbus_address, TRUE);\n      flatpak_bwrap_add_runtime_dir_member (app_bwrap, \"bus\");\n\n      return TRUE;\n    }\n  else if (!no_proxy && dbus_address != NULL)\n    {\n      g_autofree char *proxy_socket = create_proxy_socket (\"session-bus-proxy-XXXXXX\");\n\n      if (proxy_socket == NULL)\n        return FALSE;\n\n      flatpak_bwrap_add_args (proxy_arg_bwrap, dbus_address, proxy_socket, NULL);\n\n      if (!unrestricted)\n        {\n          flatpak_context_add_bus_filters (context, app_id, TRUE, flags & FLATPAK_RUN_FLAG_SANDBOX, proxy_arg_bwrap);\n\n          \/* Allow calling any interface+method on all portals, but only receive broadcasts under \/org\/desktop\/portal *\/\n          flatpak_bwrap_add_arg (proxy_arg_bwrap,\n                                 \"--call=org.freedesktop.portal.*=*\");\n          flatpak_bwrap_add_arg (proxy_arg_bwrap,\n                                 \"--broadcast=org.freedesktop.portal.*=@\/org\/freedesktop\/portal\/*\");\n        }\n\n      if ((flags & FLATPAK_RUN_FLAG_LOG_SESSION_BUS) != 0)\n        flatpak_bwrap_add_args (proxy_arg_bwrap, \"--log\", NULL);\n\n      flatpak_bwrap_add_args (app_bwrap,\n                              \"--ro-bind\", proxy_socket, sandbox_socket_path,\n                              NULL);\n      flatpak_bwrap_set_env (app_bwrap, \"DBUS_SESSION_BUS_ADDRESS\", sandbox_dbus_address, TRUE);\n      flatpak_bwrap_add_runtime_dir_member (app_bwrap, \"bus\");\n\n      return TRUE;\n    }\n\n  return FALSE;\n}","target":0,"code_token_length":715,"total_token_length":951,"max_tokens_setting":1024}
+{"idx":459220,"func":"static struct tcf_block *__tcf_block_find(struct net *net, struct Qdisc *q,\n\t\t\t\t\t  unsigned long cl, int ifindex,\n\t\t\t\t\t  u32 block_index,\n\t\t\t\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct tcf_block *block;\n\n\tif (ifindex == TCM_IFINDEX_MAGIC_BLOCK) {\n\t\tblock = tcf_block_refcnt_get(net, block_index);\n\t\tif (!block) {\n\t\t\tNL_SET_ERR_MSG(extack, \"Block of given index was not found\");\n\t\t\treturn ERR_PTR(-EINVAL);\n\t\t}\n\t} else {\n\t\tconst struct Qdisc_class_ops *cops = q->ops->cl_ops;\n\n\t\tblock = cops->tcf_block(q, cl, extack);\n\t\tif (!block)\n\t\t\treturn ERR_PTR(-EINVAL);\n\n\t\tif (tcf_block_shared(block)) {\n\t\t\tNL_SET_ERR_MSG(extack, \"This filter block is shared. Please use the block index to manipulate the filters\");\n\t\t\treturn ERR_PTR(-EOPNOTSUPP);\n\t\t}\n\n\t\t\/* Always take reference to block in order to support execution\n\t\t * of rules update path of cls API without rtnl lock. Caller\n\t\t * must release block when it is finished using it. 'if' block\n\t\t * of this conditional obtain reference to block by calling\n\t\t * tcf_block_refcnt_get().\n\t\t *\/\n\t\trefcount_inc(&block->refcnt);\n\t}\n\n\treturn block;\n}","target":0,"code_token_length":301,"total_token_length":537,"max_tokens_setting":1024}
+{"idx":294715,"func":"d_lite_rshift(VALUE self, VALUE other)\n{\n    VALUE t, y, nth, rjd2;\n    int m, d, rjd;\n    double sg;\n\n    get_d1(self);\n    t = f_add3(f_mul(m_real_year(dat), INT2FIX(12)),\n\t       INT2FIX(m_mon(dat) - 1),\n\t       other);\n    if (FIXNUM_P(t)) {\n\tlong it = FIX2LONG(t);\n\ty = LONG2NUM(DIV(it, 12));\n\tit = MOD(it, 12);\n\tm = (int)it + 1;\n    }\n    else {\n\ty = f_idiv(t, INT2FIX(12));\n\tt = f_mod(t, INT2FIX(12));\n\tm = FIX2INT(t) + 1;\n    }\n    d = m_mday(dat);\n    sg = m_sg(dat);\n\n    while (1) {\n\tint ry, rm, rd, ns;\n\n\tif (valid_civil_p(y, m, d, sg,\n\t\t\t  &nth, &ry,\n\t\t\t  &rm, &rd, &rjd, &ns))\n\t    break;\n\tif (--d < 1)\n\t    rb_raise(eDateError, \"invalid date\");\n    }\n    encode_jd(nth, rjd, &rjd2);\n    return d_lite_plus(self, f_sub(rjd2, m_real_local_jd(dat)));\n}","target":0,"code_token_length":295,"total_token_length":531,"max_tokens_setting":1024}
+{"idx":387763,"func":"void InstanceKlass::mark_newly_obsolete_methods(Array<Method*>* old_methods,\n                                                int emcp_method_count) {\n  int obsolete_method_count = old_methods->length() - emcp_method_count;\n\n  if (emcp_method_count != 0 && obsolete_method_count != 0 &&\n      _previous_versions != NULL) {\n    \/\/ We have a mix of obsolete and EMCP methods so we have to\n    \/\/ clear out any matching EMCP method entries the hard way.\n    int local_count = 0;\n    for (int i = 0; i < old_methods->length(); i++) {\n      Method* old_method = old_methods->at(i);\n      if (old_method->is_obsolete()) {\n        \/\/ only obsolete methods are interesting\n        Symbol* m_name = old_method->name();\n        Symbol* m_signature = old_method->signature();\n\n        \/\/ previous versions are linked together through the InstanceKlass\n        int j = 0;\n        for (InstanceKlass* prev_version = _previous_versions;\n             prev_version != NULL;\n             prev_version = prev_version->previous_versions(), j++) {\n\n          Array<Method*>* method_refs = prev_version->methods();\n          for (int k = 0; k < method_refs->length(); k++) {\n            Method* method = method_refs->at(k);\n\n            if (!method->is_obsolete() &&\n                method->name() == m_name &&\n                method->signature() == m_signature) {\n              \/\/ The current RedefineClasses() call has made all EMCP\n              \/\/ versions of this method obsolete so mark it as obsolete\n              log_trace(redefine, class, iklass, add)\n                (\"%s(%s): flush obsolete method @%d in version @%d\",\n                 m_name->as_C_string(), m_signature->as_C_string(), k, j);\n\n              method->set_is_obsolete();\n              break;\n            }\n          }\n\n          \/\/ The previous loop may not find a matching EMCP method, but\n          \/\/ that doesn't mean that we can optimize and not go any\n          \/\/ further back in the PreviousVersion generations. The EMCP\n          \/\/ method for this generation could have already been made obsolete,\n          \/\/ but there still may be an older EMCP method that has not\n          \/\/ been made obsolete.\n        }\n\n        if (++local_count >= obsolete_method_count) {\n          \/\/ no more obsolete methods so bail out now\n          break;\n        }\n      }\n    }\n  }\n}","target":0,"code_token_length":515,"total_token_length":751,"max_tokens_setting":1024}
+{"idx":508359,"func":"TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type,\n                   uint lock_flags)\n{\n  TABLE *table;\n  Open_table_context ot_ctx(thd, lock_flags);\n  bool error;\n  DBUG_ENTER(\"open_ltable\");\n\n  \/* Ignore temporary tables as they have already been opened. *\/\n  if (table_list->table)\n    DBUG_RETURN(table_list->table);\n\n  \/* should not be used in a prelocked_mode context, see NOTE above *\/\n  DBUG_ASSERT(thd->locked_tables_mode < LTM_PRELOCKED);\n\n  THD_STAGE_INFO(thd, stage_opening_tables);\n  thd->current_tablenr= 0;\n  \/* open_ltable can be used only for BASIC TABLEs *\/\n  table_list->required_type= FRMTYPE_TABLE;\n\n  \/* This function can't properly handle requests for such metadata locks. *\/\n  DBUG_ASSERT(table_list->mdl_request.type < MDL_SHARED_UPGRADABLE);\n\n  while ((error= open_table(thd, table_list, &ot_ctx)) &&\n         ot_ctx.can_recover_from_failed_open())\n  {\n    \/*\n      Even though we have failed to open table we still need to\n      call release_transactional_locks() to release metadata locks which\n      might have been acquired successfully.\n    *\/\n    thd->mdl_context.rollback_to_savepoint(ot_ctx.start_of_statement_svp());\n    table_list->mdl_request.ticket= 0;\n    if (ot_ctx.recover_from_failed_open())\n      break;\n  }\n\n  if (!error)\n  {\n    \/*\n      We can't have a view or some special \"open_strategy\" in this function\n      so there should be a TABLE instance.\n    *\/\n    DBUG_ASSERT(table_list->table);\n    table= table_list->table;\n    if (table->file->ht->db_type == DB_TYPE_MRG_MYISAM)\n    {\n      \/* A MERGE table must not come here. *\/\n      \/* purecov: begin tested *\/\n      my_error(ER_WRONG_OBJECT, MYF(0), table->s->db.str,\n               table->s->table_name.str, \"BASE TABLE\");\n      table= 0;\n      goto end;\n      \/* purecov: end *\/\n    }\n\n    table_list->lock_type= lock_type;\n    table->grant= table_list->grant;\n    if (thd->locked_tables_mode)\n    {\n      if (check_lock_and_start_stmt(thd, thd->lex, table_list))\n\ttable= 0;\n    }\n    else\n    {\n      DBUG_ASSERT(thd->lock == 0);\t\/\/ You must lock everything at once\n      if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK)\n\tif (! (thd->lock= mysql_lock_tables(thd, &table_list->table, 1,\n                                            lock_flags)))\n        {\n          table= 0;\n        }\n    }\n  }\n  else\n    table= 0;\n\nend:\n  if (table == NULL)\n  {\n    if (!thd->in_sub_stmt)\n      trans_rollback_stmt(thd);\n    close_thread_tables(thd);\n  }\n  THD_STAGE_INFO(thd, stage_after_opening_tables);\n\n  thd_proc_info(thd, 0);\n  DBUG_RETURN(table);\n}","target":0,"code_token_length":694,"total_token_length":930,"max_tokens_setting":1024}
+{"idx":282868,"func":"static int rsi_load_9116_bootup_params(struct rsi_common *common)\n{\n\tstruct sk_buff *skb;\n\tstruct rsi_boot_params_9116 *boot_params;\n\n\trsi_dbg(MGMT_TX_ZONE, \"%s: Sending boot params frame\\n\", __func__);\n\n\tskb = dev_alloc_skb(sizeof(struct rsi_boot_params_9116));\n\tif (!skb)\n\t\treturn -ENOMEM;\n\tmemset(skb->data, 0, sizeof(struct rsi_boot_params));\n\tboot_params = (struct rsi_boot_params_9116 *)skb->data;\n\n\tif (common->channel_width == BW_40MHZ) {\n\t\tmemcpy(&boot_params->bootup_params,\n\t\t       &boot_params_9116_40,\n\t\t       sizeof(struct bootup_params_9116));\n\t\trsi_dbg(MGMT_TX_ZONE, \"%s: Packet 40MHZ <=== %d\\n\", __func__,\n\t\t\tUMAC_CLK_40BW);\n\t\tboot_params->umac_clk = cpu_to_le16(UMAC_CLK_40BW);\n\t} else {\n\t\tmemcpy(&boot_params->bootup_params,\n\t\t       &boot_params_9116_20,\n\t\t       sizeof(struct bootup_params_9116));\n\t\tif (boot_params_20.valid != cpu_to_le32(VALID_20)) {\n\t\t\tboot_params->umac_clk = cpu_to_le16(UMAC_CLK_20BW);\n\t\t\trsi_dbg(MGMT_TX_ZONE,\n\t\t\t\t\"%s: Packet 20MHZ <=== %d\\n\", __func__,\n\t\t\t\tUMAC_CLK_20BW);\n\t\t} else {\n\t\t\tboot_params->umac_clk = cpu_to_le16(UMAC_CLK_40MHZ);\n\t\t\trsi_dbg(MGMT_TX_ZONE,\n\t\t\t\t\"%s: Packet 20MHZ <=== %d\\n\", __func__,\n\t\t\t\tUMAC_CLK_40MHZ);\n\t\t}\n\t}\n\trsi_set_len_qno(&boot_params->desc_dword0.len_qno,\n\t\t\tsizeof(struct bootup_params_9116), RSI_WIFI_MGMT_Q);\n\tboot_params->desc_dword0.frame_type = BOOTUP_PARAMS_REQUEST;\n\tskb_put(skb, sizeof(struct rsi_boot_params_9116));\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":512,"total_token_length":748,"max_tokens_setting":1024}
+{"idx":197719,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Read ragged_splits inputs.\n    OpInputList ragged_nested_splits_in;\n    OP_REQUIRES_OK(context, context->input_list(\"rt_nested_splits\",\n                                                &ragged_nested_splits_in));\n    const int ragged_nested_splits_len = ragged_nested_splits_in.size();\n    RaggedTensorVariant batched_ragged_input;\n    \/\/ Read ragged_values input.\n    batched_ragged_input.set_values(context->input(ragged_nested_splits_len));\n    batched_ragged_input.mutable_nested_splits()->reserve(\n        ragged_nested_splits_len);\n    for (int i = 0; i < ragged_nested_splits_len; i++) {\n      batched_ragged_input.append_splits(ragged_nested_splits_in[i]);\n    }\n\n    if (!batched_input_) {\n      \/\/ Encode as a Scalar Variant Tensor.\n      Tensor* encoded_scalar;\n      OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({}),\n                                                       &encoded_scalar));\n      encoded_scalar->scalar<Variant>()() = std::move(batched_ragged_input);\n      return;\n    }\n\n    \/\/ Unbatch the Ragged Tensor and encode the components.\n    std::vector<RaggedTensorVariant> unbatched_ragged_input;\n    auto batched_splits_top_vec =\n        batched_ragged_input.splits(0).vec<SPLIT_TYPE>();\n    int num_components = batched_splits_top_vec.size() - 1;\n    OP_REQUIRES(context, num_components >= 0,\n                errors::Internal(\"Invalid split argument.\"));\n    OP_REQUIRES_OK(context, UnbatchRaggedZerothDim<VALUE_TYPE, SPLIT_TYPE>(\n                                batched_ragged_input, &unbatched_ragged_input));\n\n    \/\/ Bundle the encoded scalar Variant Tensors into a rank-1 Variant Tensor.\n    Tensor* encoded_vector;\n    int output_size = unbatched_ragged_input.size();\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(0, TensorShape({output_size}),\n                                            &encoded_vector));\n    auto encoded_vector_t = encoded_vector->vec<Variant>();\n    for (int i = 0; i < output_size; i++) {\n      encoded_vector_t(i) = unbatched_ragged_input[i];\n    }\n  }","target":1,"code_token_length":469,"total_token_length":705,"max_tokens_setting":1024}
+{"idx":281121,"func":"static void xfrm_dst_hash_transfer(struct net *net,\n\t\t\t\t   struct hlist_head *list,\n\t\t\t\t   struct hlist_head *ndsttable,\n\t\t\t\t   unsigned int nhashmask,\n\t\t\t\t   int dir)\n{\n\tstruct hlist_node *tmp, *entry0 = NULL;\n\tstruct xfrm_policy *pol;\n\tunsigned int h0 = 0;\n\tu8 dbits;\n\tu8 sbits;\n\nredo:\n\thlist_for_each_entry_safe(pol, tmp, list, bydst) {\n\t\tunsigned int h;\n\n\t\t__get_hash_thresh(net, pol->family, dir, &dbits, &sbits);\n\t\th = __addr_hash(&pol->selector.daddr, &pol->selector.saddr,\n\t\t\t\tpol->family, nhashmask, dbits, sbits);\n\t\tif (!entry0) {\n\t\t\thlist_del_rcu(&pol->bydst);\n\t\t\thlist_add_head_rcu(&pol->bydst, ndsttable + h);\n\t\t\th0 = h;\n\t\t} else {\n\t\t\tif (h != h0)\n\t\t\t\tcontinue;\n\t\t\thlist_del_rcu(&pol->bydst);\n\t\t\thlist_add_behind_rcu(&pol->bydst, entry0);\n\t\t}\n\t\tentry0 = &pol->bydst;\n\t}\n\tif (!hlist_empty(list)) {\n\t\tentry0 = NULL;\n\t\tgoto redo;\n\t}\n}","target":0,"code_token_length":286,"total_token_length":522,"max_tokens_setting":1024}
+{"idx":270387,"func":"static bool ok_inflater_inflate_huffman_tree(ok_inflater *inflater, ok_inflater_huffman_tree *tree,\n                                             ok_inflater_huffman_tree *code_length_huffman,\n                                             int num_codes) {\n    if (num_codes < 0 || num_codes >= MAX_NUM_CODES) {\n        ok_inflater_error(inflater, \"Invalid num_codes\");\n        return false;\n    }\n    const uint16_t *tree_lookup_table = code_length_huffman->lookup_table;\n    const unsigned int tree_bits = code_length_huffman->bits;\n    \/\/ 0 - 15: Represent code lengths of 0 - 15\n    \/\/     16: Copy the previous code length 3 - 6 times.\n    \/\/         (2 bits of length)\n    \/\/     17: Repeat a code length of 0 for 3 - 10 times.\n    \/\/         (3 bits of length)\n    \/\/     18: Repeat a code length of 0 for 11 - 138 times\n    \/\/         (7 bits of length)\n    while (inflater->state_count < num_codes) {\n        if (inflater->huffman_code < 0) {\n            inflater->huffman_code = ok_inflater_decode_literal(inflater, tree_lookup_table,\n                                                                tree_bits);\n            if (inflater->huffman_code < 0) {\n                return false;\n            }\n        }\n        if (inflater->huffman_code <= 15) {\n            inflater->tree_codes[inflater->state_count++] = (uint8_t)inflater->huffman_code;\n        } else {\n            int value = 0;\n            int len;\n            unsigned int len_bits;\n            switch (inflater->huffman_code) {\n                case 16:\n                    len = 3;\n                    len_bits = 2;\n                    if (inflater->state_count == 0) {\n                        ok_inflater_error(inflater, \"Invalid previous code\");\n                        return false;\n                    }\n                    value = inflater->tree_codes[inflater->state_count - 1];\n                    break;\n                case 17:\n                    len = 3;\n                    len_bits = 3;\n                    break;\n                case 18:\n                    len = 11;\n                    len_bits = 7;\n                    break;\n                default:\n                    ok_inflater_error(inflater, \"Invalid huffman code\");\n                    return false;\n            }\n            if (!ok_inflater_load_bits(inflater, len_bits)) {\n                return false;\n            }\n            len += ok_inflater_read_bits(inflater, len_bits);\n            if (len > num_codes - inflater->state_count) {\n                ok_inflater_error(inflater, \"Invalid length\");\n                return false;\n            }\n            memset(inflater->tree_codes + inflater->state_count, value, (size_t)len);\n            inflater->state_count += len;\n        }\n        inflater->huffman_code = -1;\n    }\n    ok_inflater_make_huffman_tree_from_array(tree, inflater->tree_codes, num_codes);\n    return true;\n}","target":0,"code_token_length":636,"total_token_length":872,"max_tokens_setting":1024}
+{"idx":484764,"func":"static int xennet_init_queue(struct netfront_queue *queue)\n{\n\tunsigned short i;\n\tint err = 0;\n\tchar *devid;\n\n\tspin_lock_init(&queue->tx_lock);\n\tspin_lock_init(&queue->rx_lock);\n\tspin_lock_init(&queue->rx_cons_lock);\n\n\ttimer_setup(&queue->rx_refill_timer, rx_refill_timeout, 0);\n\n\tdevid = strrchr(queue->info->xbdev->nodename, '\/') + 1;\n\tsnprintf(queue->name, sizeof(queue->name), \"vif%s-q%u\",\n\t\t devid, queue->id);\n\n\t\/* Initialise tx_skb_freelist as a free chain containing every entry. *\/\n\tqueue->tx_skb_freelist = 0;\n\tqueue->tx_pend_queue = TX_LINK_NONE;\n\tfor (i = 0; i < NET_TX_RING_SIZE; i++) {\n\t\tqueue->tx_link[i] = i + 1;\n\t\tqueue->grant_tx_ref[i] = INVALID_GRANT_REF;\n\t\tqueue->grant_tx_page[i] = NULL;\n\t}\n\tqueue->tx_link[NET_TX_RING_SIZE - 1] = TX_LINK_NONE;\n\n\t\/* Clear out rx_skbs *\/\n\tfor (i = 0; i < NET_RX_RING_SIZE; i++) {\n\t\tqueue->rx_skbs[i] = NULL;\n\t\tqueue->grant_rx_ref[i] = INVALID_GRANT_REF;\n\t}\n\n\t\/* A grant for every tx ring slot *\/\n\tif (gnttab_alloc_grant_references(NET_TX_RING_SIZE,\n\t\t\t\t\t  &queue->gref_tx_head) < 0) {\n\t\tpr_alert(\"can't alloc tx grant refs\\n\");\n\t\terr = -ENOMEM;\n\t\tgoto exit;\n\t}\n\n\t\/* A grant for every rx ring slot *\/\n\tif (gnttab_alloc_grant_references(NET_RX_RING_SIZE,\n\t\t\t\t\t  &queue->gref_rx_head) < 0) {\n\t\tpr_alert(\"can't alloc rx grant refs\\n\");\n\t\terr = -ENOMEM;\n\t\tgoto exit_free_tx;\n\t}\n\n\treturn 0;\n\n exit_free_tx:\n\tgnttab_free_grant_references(queue->gref_tx_head);\n exit:\n\treturn err;\n}","target":0,"code_token_length":442,"total_token_length":678,"max_tokens_setting":1024}
+{"idx":198545,"func":"static int do_i2c_md(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t     char *const argv[])\n{\n\tuint\tchip;\n\tuint\taddr, length;\n\tint alen;\n\tint\tj, nbytes, linebytes;\n\tint ret;\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tstruct udevice *dev;\n#endif\n\n\t\/* We use the last specified parameters, unless new ones are\n\t * entered.\n\t *\/\n\tchip   = i2c_dp_last_chip;\n\taddr   = i2c_dp_last_addr;\n\talen   = i2c_dp_last_alen;\n\tlength = i2c_dp_last_length;\n\n\tif (argc < 3)\n\t\treturn CMD_RET_USAGE;\n\n\tif ((flag & CMD_FLAG_REPEAT) == 0) {\n\t\t\/*\n\t\t * New command specified.\n\t\t *\/\n\n\t\t\/*\n\t\t * I2C chip address\n\t\t *\/\n\t\tchip = hextoul(argv[1], NULL);\n\n\t\t\/*\n\t\t * I2C data address within the chip.  This can be 1 or\n\t\t * 2 bytes long.  Some day it might be 3 bytes long :-).\n\t\t *\/\n\t\taddr = hextoul(argv[2], NULL);\n\t\talen = get_alen(argv[2], DEFAULT_ADDR_LEN);\n\t\tif (alen > 3)\n\t\t\treturn CMD_RET_USAGE;\n\n\t\t\/*\n\t\t * If another parameter, it is the length to display.\n\t\t * Length is the number of objects, not number of bytes.\n\t\t *\/\n\t\tif (argc > 3)\n\t\t\tlength = hextoul(argv[3], NULL);\n\t}\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (!ret && alen != -1)\n\t\tret = i2c_set_chip_offset_len(dev, alen);\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n#endif\n\n\t\/*\n\t * Print the lines.\n\t *\n\t * We buffer all read data, so we can make sure data is read only\n\t * once.\n\t *\/\n\tnbytes = length;\n\tdo {\n\t\tunsigned char\tlinebuf[DISP_LINE_LEN];\n\t\tunsigned char\t*cp;\n\n\t\tlinebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;\n\n#if CONFIG_IS_ENABLED(DM_I2C)\n\t\tret = dm_i2c_read(dev, addr, linebuf, linebytes);\n#else\n\t\tret = i2c_read(chip, addr, alen, linebuf, linebytes);\n#endif\n\t\tif (ret)\n\t\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n\t\telse {\n\t\t\tprintf(\"%04x:\", addr);\n\t\t\tcp = linebuf;\n\t\t\tfor (j=0; j<linebytes; j++) {\n\t\t\t\tprintf(\" %02x\", *cp++);\n\t\t\t\taddr++;\n\t\t\t}\n\t\t\tputs (\"    \");\n\t\t\tcp = linebuf;\n\t\t\tfor (j=0; j<linebytes; j++) {\n\t\t\t\tif ((*cp < 0x20) || (*cp > 0x7e))\n\t\t\t\t\tputs (\".\");\n\t\t\t\telse\n\t\t\t\t\tprintf(\"%c\", *cp);\n\t\t\t\tcp++;\n\t\t\t}\n\t\t\tputc ('\\n');\n\t\t}\n\t\tnbytes -= linebytes;\n\t} while (nbytes > 0);\n\n\ti2c_dp_last_chip   = chip;\n\ti2c_dp_last_addr   = addr;\n\ti2c_dp_last_alen   = alen;\n\ti2c_dp_last_length = length;\n\n\treturn 0;\n}","target":1,"code_token_length":743,"total_token_length":979,"max_tokens_setting":1024}
+{"idx":500672,"func":"int sftp_async_read(sftp_file file, void *data, uint32_t size, uint32_t id){\n  sftp_session sftp = file->sftp;\n  sftp_message msg = NULL;\n  sftp_status_message status;\n  ssh_string datastring;\n  int err = SSH_OK;\n  uint32_t len;\n\n  sftp_enter_function();\n\n  if (file->eof) {\n    sftp_leave_function();\n    return 0;\n  }\n\n  \/* handle an existing request *\/\n  while (msg == NULL) {\n    if (file->nonblocking){\n      if (ssh_channel_poll(sftp->channel, 0) == 0) {\n        \/* we cannot block *\/\n        return SSH_AGAIN;\n      }\n    }\n\n    if (sftp_read_and_dispatch(sftp) < 0) {\n      \/* something nasty has happened *\/\n      sftp_leave_function();\n      return SSH_ERROR;\n    }\n\n    msg = sftp_dequeue(sftp,id);\n  }\n\n  switch (msg->packet_type) {\n    case SSH_FXP_STATUS:\n      status = parse_status_msg(msg);\n      sftp_message_free(msg);\n      if (status == NULL) {\n        sftp_leave_function();\n        return -1;\n      }\n      sftp_set_error(sftp, status->status);\n      if (status->status != SSH_FX_EOF) {\n        ssh_set_error(sftp->session, SSH_REQUEST_DENIED,\n            \"SFTP server : %s\", status->errormsg);\n        sftp_leave_function();\n        err = SSH_ERROR;\n      } else {\n        file->eof = 1;\n      }\n      status_msg_free(status);\n      sftp_leave_function();\n      return err;\n    case SSH_FXP_DATA:\n      datastring = buffer_get_ssh_string(msg->payload);\n      sftp_message_free(msg);\n      if (datastring == NULL) {\n        ssh_set_error(sftp->session, SSH_FATAL,\n            \"Received invalid DATA packet from sftp server\");\n        sftp_leave_function();\n        return SSH_ERROR;\n      }\n      if (ssh_string_len(datastring) > size) {\n        ssh_set_error(sftp->session, SSH_FATAL,\n            \"Received a too big DATA packet from sftp server: \"\n            \"%\" PRIdS \" and asked for %u\",\n            ssh_string_len(datastring), size);\n        ssh_string_free(datastring);\n        sftp_leave_function();\n        return SSH_ERROR;\n      }\n      len = ssh_string_len(datastring);\n      \/* Update the offset with the correct value *\/\n      file->offset = file->offset - (size - len);\n      memcpy(data, ssh_string_data(datastring), len);\n      ssh_string_free(datastring);\n      sftp_leave_function();\n      return len;\n    default:\n      ssh_set_error(sftp->session,SSH_FATAL,\"Received message %d during read!\",msg->packet_type);\n      sftp_message_free(msg);\n      sftp_leave_function();\n      return SSH_ERROR;\n  }\n\n  sftp_leave_function();\n  return SSH_ERROR;\n}","target":0,"code_token_length":625,"total_token_length":861,"max_tokens_setting":1024}
+{"idx":205870,"func":"static RList *symbols(RBinFile *bf) {\n\tRList *res = r_list_newf ((RListFree)r_bin_symbol_free);\n\tr_return_val_if_fail (res && bf->o && bf->o->bin_obj, res);\n\tRCoreSymCacheElement *element = bf->o->bin_obj;\n\tsize_t i;\n\tHtUU *hash = ht_uu_new0 ();\n\tif (!hash) {\n\t\treturn res;\n\t}\n\tbool found = false;\n\tfor (i = 0; i < element->hdr->n_lined_symbols; i++) {\n\t\tRCoreSymCacheElementSymbol *sym = (RCoreSymCacheElementSymbol *)&element->lined_symbols[i];\n\t\tht_uu_find (hash, sym->paddr, &found);\n\t\tif (found) {\n\t\t\tcontinue;\n\t\t}\n\t\tRBinSymbol *s = bin_symbol_from_symbol (element, sym);\n\t\tif (s) {\n\t\t\tr_list_append (res, s);\n\t\t\tht_uu_insert (hash, sym->paddr, 1);\n\t\t}\n\t}\n\tif (element->symbols) {\n\t\tfor (i = 0; i < element->hdr->n_symbols; i++) {\n\t\t\tRCoreSymCacheElementSymbol *sym = &element->symbols[i];\n\t\t\tht_uu_find (hash, sym->paddr, &found);\n\t\t\tif (found) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tRBinSymbol *s = bin_symbol_from_symbol (element, sym);\n\t\t\tif (s) {\n\t\t\t\tr_list_append (res, s);\n\t\t\t}\n\t\t}\n\t}\n\tht_uu_free (hash);\n\treturn res;\n}","target":1,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":446111,"func":"static int atusb_get_and_show_revision(struct atusb *atusb)\n{\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\tchar *hw_name;\n\tunsigned char *buffer;\n\tint ret;\n\n\tbuffer = kmalloc(3, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\t\/* Get a couple of the ATMega Firmware values *\/\n\tret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),\n\t\t\t\tATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,\n\t\t\t\tbuffer, 3, 1000);\n\tif (ret >= 0) {\n\t\tatusb->fw_ver_maj = buffer[0];\n\t\tatusb->fw_ver_min = buffer[1];\n\t\tatusb->fw_hw_type = buffer[2];\n\n\t\tswitch (atusb->fw_hw_type) {\n\t\tcase ATUSB_HW_TYPE_100813:\n\t\tcase ATUSB_HW_TYPE_101216:\n\t\tcase ATUSB_HW_TYPE_110131:\n\t\t\thw_name = \"ATUSB\";\n\t\t\tatusb->data = &atusb_chip_data;\n\t\t\tbreak;\n\t\tcase ATUSB_HW_TYPE_RZUSB:\n\t\t\thw_name = \"RZUSB\";\n\t\t\tatusb->data = &atusb_chip_data;\n\t\t\tbreak;\n\t\tcase ATUSB_HW_TYPE_HULUSB:\n\t\t\thw_name = \"HULUSB\";\n\t\t\tatusb->data = &hulusb_chip_data;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\thw_name = \"UNKNOWN\";\n\t\t\tatusb->err = -ENOTSUPP;\n\t\t\tret = -ENOTSUPP;\n\t\t\tbreak;\n\t\t}\n\n\t\tdev_info(&usb_dev->dev,\n\t\t\t \"Firmware: major: %u, minor: %u, hardware type: %s (%d)\\n\",\n\t\t\t atusb->fw_ver_maj, atusb->fw_ver_min, hw_name,\n\t\t\t atusb->fw_hw_type);\n\t}\n\tif (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 2) {\n\t\tdev_info(&usb_dev->dev,\n\t\t\t \"Firmware version (%u.%u) predates our first public release.\",\n\t\t\t atusb->fw_ver_maj, atusb->fw_ver_min);\n\t\tdev_info(&usb_dev->dev, \"Please update to version 0.2 or newer\");\n\t}\n\n\tkfree(buffer);\n\treturn ret;\n}","target":0,"code_token_length":522,"total_token_length":758,"max_tokens_setting":1024}
+{"idx":466146,"func":"static int check_cr_write(struct x86_emulate_ctxt *ctxt)\n{\n\tu64 new_val = ctxt->src.val64;\n\tint cr = ctxt->modrm_reg;\n\tu64 efer = 0;\n\n\tstatic u64 cr_reserved_bits[] = {\n\t\t0xffffffff00000000ULL,\n\t\t0, 0, 0, \/* CR3 checked later *\/\n\t\tCR4_RESERVED_BITS,\n\t\t0, 0, 0,\n\t\tCR8_RESERVED_BITS,\n\t};\n\n\tif (!valid_cr(cr))\n\t\treturn emulate_ud(ctxt);\n\n\tif (new_val & cr_reserved_bits[cr])\n\t\treturn emulate_gp(ctxt, 0);\n\n\tswitch (cr) {\n\tcase 0: {\n\t\tu64 cr4;\n\t\tif (((new_val & X86_CR0_PG) && !(new_val & X86_CR0_PE)) ||\n\t\t    ((new_val & X86_CR0_NW) && !(new_val & X86_CR0_CD)))\n\t\t\treturn emulate_gp(ctxt, 0);\n\n\t\tcr4 = ctxt->ops->get_cr(ctxt, 4);\n\t\tctxt->ops->get_msr(ctxt, MSR_EFER, &efer);\n\n\t\tif ((new_val & X86_CR0_PG) && (efer & EFER_LME) &&\n\t\t    !(cr4 & X86_CR4_PAE))\n\t\t\treturn emulate_gp(ctxt, 0);\n\n\t\tbreak;\n\t\t}\n\tcase 3: {\n\t\tu64 rsvd = 0;\n\n\t\tctxt->ops->get_msr(ctxt, MSR_EFER, &efer);\n\t\tif (efer & EFER_LMA)\n\t\t\trsvd = CR3_L_MODE_RESERVED_BITS;\n\t\telse if (ctxt->ops->get_cr(ctxt, 4) & X86_CR4_PAE)\n\t\t\trsvd = CR3_PAE_RESERVED_BITS;\n\t\telse if (ctxt->ops->get_cr(ctxt, 0) & X86_CR0_PG)\n\t\t\trsvd = CR3_NONPAE_RESERVED_BITS;\n\n\t\tif (new_val & rsvd)\n\t\t\treturn emulate_gp(ctxt, 0);\n\n\t\tbreak;\n\t\t}\n\tcase 4: {\n\t\tctxt->ops->get_msr(ctxt, MSR_EFER, &efer);\n\n\t\tif ((efer & EFER_LMA) && !(new_val & X86_CR4_PAE))\n\t\t\treturn emulate_gp(ctxt, 0);\n\n\t\tbreak;\n\t\t}\n\t}\n\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":549,"total_token_length":785,"max_tokens_setting":1024}
+{"idx":223457,"func":"static SLJIT_INLINE void compile_then_trap_backtrackingpath(compiler_common *common, struct backtrack_common *current)\n{\nDEFINE_COMPILER;\nstruct sljit_jump *jump;\nint size;\n\nif (CURRENT_AS(then_trap_backtrack)->then_trap)\n  {\n  common->then_trap = CURRENT_AS(then_trap_backtrack)->then_trap;\n  return;\n  }\n\nsize = CURRENT_AS(then_trap_backtrack)->framesize;\nsize = 3 + (size < 0 ? 0 : size);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(size - 3));\nfree_stack(common, size);\njump = JUMP(SLJIT_JUMP);\n\nset_jumps(CURRENT_AS(then_trap_backtrack)->quit, LABEL());\n\/* STACK_TOP is set by THEN. *\/\nif (CURRENT_AS(then_trap_backtrack)->framesize >= 0)\n  {\n  add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));\n  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (CURRENT_AS(then_trap_backtrack)->framesize - 1) * sizeof(sljit_sw));\n  }\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));\nfree_stack(common, 3);\n\nJUMPHERE(jump);\nOP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, TMP1, 0);\n}","target":0,"code_token_length":336,"total_token_length":572,"max_tokens_setting":1024}
+{"idx":366316,"func":"static void mntput_no_expire(struct mount *mnt)\n{\n\tLIST_HEAD(list);\n\tint count;\n\n\trcu_read_lock();\n\tif (likely(READ_ONCE(mnt->mnt_ns))) {\n\t\t\/*\n\t\t * Since we don't do lock_mount_hash() here,\n\t\t * ->mnt_ns can change under us.  However, if it's\n\t\t * non-NULL, then there's a reference that won't\n\t\t * be dropped until after an RCU delay done after\n\t\t * turning ->mnt_ns NULL.  So if we observe it\n\t\t * non-NULL under rcu_read_lock(), the reference\n\t\t * we are dropping is not the final one.\n\t\t *\/\n\t\tmnt_add_count(mnt, -1);\n\t\trcu_read_unlock();\n\t\treturn;\n\t}\n\tlock_mount_hash();\n\t\/*\n\t * make sure that if __legitimize_mnt() has not seen us grab\n\t * mount_lock, we'll see their refcount increment here.\n\t *\/\n\tsmp_mb();\n\tmnt_add_count(mnt, -1);\n\tcount = mnt_get_count(mnt);\n\tif (count != 0) {\n\t\tWARN_ON(count < 0);\n\t\trcu_read_unlock();\n\t\tunlock_mount_hash();\n\t\treturn;\n\t}\n\tif (unlikely(mnt->mnt.mnt_flags & MNT_DOOMED)) {\n\t\trcu_read_unlock();\n\t\tunlock_mount_hash();\n\t\treturn;\n\t}\n\tmnt->mnt.mnt_flags |= MNT_DOOMED;\n\trcu_read_unlock();\n\n\tlist_del(&mnt->mnt_instance);\n\n\tif (unlikely(!list_empty(&mnt->mnt_mounts))) {\n\t\tstruct mount *p, *tmp;\n\t\tlist_for_each_entry_safe(p, tmp, &mnt->mnt_mounts,  mnt_child) {\n\t\t\t__put_mountpoint(unhash_mnt(p), &list);\n\t\t\thlist_add_head(&p->mnt_umount, &mnt->mnt_stuck_children);\n\t\t}\n\t}\n\tunlock_mount_hash();\n\tshrink_dentry_list(&list);\n\n\tif (likely(!(mnt->mnt.mnt_flags & MNT_INTERNAL))) {\n\t\tstruct task_struct *task = current;\n\t\tif (likely(!(task->flags & PF_KTHREAD))) {\n\t\t\tinit_task_work(&mnt->mnt_rcu, __cleanup_mnt);\n\t\t\tif (!task_work_add(task, &mnt->mnt_rcu, TWA_RESUME))\n\t\t\t\treturn;\n\t\t}\n\t\tif (llist_add(&mnt->mnt_llist, &delayed_mntput_list))\n\t\t\tschedule_delayed_work(&delayed_mntput_work, 1);\n\t\treturn;\n\t}\n\tcleanup_mnt(mnt);\n}","target":0,"code_token_length":555,"total_token_length":791,"max_tokens_setting":1024}
+{"idx":316989,"func":"static int smack_inode_getsecurity(struct user_namespace *mnt_userns,\n\t\t\t\t   struct inode *inode, const char *name,\n\t\t\t\t   void **buffer, bool alloc)\n{\n\tstruct socket_smack *ssp;\n\tstruct socket *sock;\n\tstruct super_block *sbp;\n\tstruct inode *ip = (struct inode *)inode;\n\tstruct smack_known *isp;\n\n\tif (strcmp(name, XATTR_SMACK_SUFFIX) == 0)\n\t\tisp = smk_of_inode(inode);\n\telse {\n\t\t\/*\n\t\t * The rest of the Smack xattrs are only on sockets.\n\t\t *\/\n\t\tsbp = ip->i_sb;\n\t\tif (sbp->s_magic != SOCKFS_MAGIC)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tsock = SOCKET_I(ip);\n\t\tif (sock == NULL || sock->sk == NULL)\n\t\t\treturn -EOPNOTSUPP;\n\n\t\tssp = sock->sk->sk_security;\n\n\t\tif (strcmp(name, XATTR_SMACK_IPIN) == 0)\n\t\t\tisp = ssp->smk_in;\n\t\telse if (strcmp(name, XATTR_SMACK_IPOUT) == 0)\n\t\t\tisp = ssp->smk_out;\n\t\telse\n\t\t\treturn -EOPNOTSUPP;\n\t}\n\n\tif (alloc) {\n\t\t*buffer = kstrdup(isp->smk_known, GFP_KERNEL);\n\t\tif (*buffer == NULL)\n\t\t\treturn -ENOMEM;\n\t}\n\n\treturn strlen(isp->smk_known);\n}","target":0,"code_token_length":307,"total_token_length":543,"max_tokens_setting":1024}
+{"idx":262013,"func":"Proto_FreeRequest(ProtoRequest *req)\n{\n   if (NULL == req) {\n      return;\n   }\n\n#if VGAUTH_PROTO_TRACE\n   g_free(req->rawData);\n#endif\n\n   switch (req->reqType) {\n   case PROTO_REQUEST_UNKNOWN:\n      \/\/ partial\/empty request -- no-op\n      break;\n   case PROTO_REQUEST_SESSION_REQ:\n      g_free(req->reqData.sessionReq.userName);\n      break;\n   case PROTO_REQUEST_CONN:\n      g_free(req->reqData.connect.pid);\n      break;\n   case PROTO_REQUEST_ADDALIAS:\n      g_free(req->reqData.addAlias.userName);\n      g_free(req->reqData.addAlias.pemCert);\n      \/\/ will be NULL if ANY, so should be safe\n      g_free(req->reqData.addAlias.aliasInfo.name);\n      g_free(req->reqData.addAlias.aliasInfo.comment);\n      break;\n   case PROTO_REQUEST_REMOVEALIAS:\n      g_free(req->reqData.removeAlias.userName);\n      g_free(req->reqData.removeAlias.pemCert);\n      \/\/ wll be NULL if ANY or unset, so should be safe\n      g_free(req->reqData.removeAlias.subject.name);\n      break;\n   case PROTO_REQUEST_QUERYALIASES:\n      g_free(req->reqData.queryAliases.userName);\n      break;\n   case PROTO_REQUEST_QUERYMAPPEDALIASES:\n      \/\/empty\n      break;\n   case PROTO_REQUEST_CREATETICKET:\n      g_free(req->reqData.createTicket.userName);\n      g_free(req->reqData.createTicket.token);\n      ServiceAliasFreeAliasInfoContents(&(req->reqData.createTicket.samlData.aliasInfo));\n      g_free(req->reqData.createTicket.samlData.samlSubject);\n      break;\n   case PROTO_REQUEST_VALIDATETICKET:\n      g_free(req->reqData.validateTicket.ticket);\n      break;\n   case PROTO_REQUEST_REVOKETICKET:\n      g_free(req->reqData.revokeTicket.ticket);\n      break;\n   case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:\n      g_free(req->reqData.validateSamlBToken.samlToken);\n      g_free(req->reqData.validateSamlBToken.userName);\n      break;\n   default:\n      Warning(\"%s: trying to free unknown request type %d\\n\",\n              __FUNCTION__, req->reqType);\n   }\n\n   g_free(req);\n}","target":0,"code_token_length":495,"total_token_length":731,"max_tokens_setting":1024}
+{"idx":264212,"func":"static void vnc_dpy_switch(DisplayChangeListener *dcl,\n                           DisplaySurface *surface)\n{\n    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);\n    VncState *vs;\n\n    vnc_abort_display_jobs(vd);\n\n    \/* server surface *\/\n    qemu_pixman_image_unref(vd->server);\n    vd->ds = surface;\n    vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,\n                                          surface_width(vd->ds),\n                                          surface_height(vd->ds),\n                                          NULL, 0);\n\n    \/* guest surface *\/\n#if 0 \/* FIXME *\/\n    if (ds_get_bytes_per_pixel(ds) != vd->guest.ds->pf.bytes_per_pixel)\n        console_color_init(ds);\n#endif\n    qemu_pixman_image_unref(vd->guest.fb);\n    vd->guest.fb = pixman_image_ref(surface->image);\n    vd->guest.format = surface->format;\n    VNC_SET_VISIBLE_PIXELS_DIRTY(vd->guest.dirty,\n                                 surface_width(vd->ds),\n                                 surface_height(vd->ds));\n\n    QTAILQ_FOREACH(vs, &vd->clients, next) {\n        vnc_colordepth(vs);\n        vnc_desktop_resize(vs);\n        if (vs->vd->cursor) {\n            vnc_cursor_define(vs);\n        }\n        VNC_SET_VISIBLE_PIXELS_DIRTY(vs->dirty,\n                                     surface_width(vd->ds),\n                                     surface_height(vd->ds));\n    }\n}","target":0,"code_token_length":304,"total_token_length":540,"max_tokens_setting":1024}
+{"idx":369415,"func":"\nstatic __cold int io_register_restrictions(struct io_ring_ctx *ctx,\n\t\t\t\t\t   void __user *arg, unsigned int nr_args)\n{\n\tstruct io_uring_restriction *res;\n\tsize_t size;\n\tint i, ret;\n\n\t\/* Restrictions allowed only if rings started disabled *\/\n\tif (!(ctx->flags & IORING_SETUP_R_DISABLED))\n\t\treturn -EBADFD;\n\n\t\/* We allow only a single restrictions registration *\/\n\tif (ctx->restrictions.registered)\n\t\treturn -EBUSY;\n\n\tif (!arg || nr_args > IORING_MAX_RESTRICTIONS)\n\t\treturn -EINVAL;\n\n\tsize = array_size(nr_args, sizeof(*res));\n\tif (size == SIZE_MAX)\n\t\treturn -EOVERFLOW;\n\n\tres = memdup_user(arg, size);\n\tif (IS_ERR(res))\n\t\treturn PTR_ERR(res);\n\n\tret = 0;\n\n\tfor (i = 0; i < nr_args; i++) {\n\t\tswitch (res[i].opcode) {\n\t\tcase IORING_RESTRICTION_REGISTER_OP:\n\t\t\tif (res[i].register_op >= IORING_REGISTER_LAST) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\t__set_bit(res[i].register_op,\n\t\t\t\t  ctx->restrictions.register_op);\n\t\t\tbreak;\n\t\tcase IORING_RESTRICTION_SQE_OP:\n\t\t\tif (res[i].sqe_op >= IORING_OP_LAST) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\t__set_bit(res[i].sqe_op, ctx->restrictions.sqe_op);\n\t\t\tbreak;\n\t\tcase IORING_RESTRICTION_SQE_FLAGS_ALLOWED:\n\t\t\tctx->restrictions.sqe_flags_allowed = res[i].sqe_flags;\n\t\t\tbreak;\n\t\tcase IORING_RESTRICTION_SQE_FLAGS_REQUIRED:\n\t\t\tctx->restrictions.sqe_flags_required = res[i].sqe_flags;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tret = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\t}\n\nout:\n\t\/* Reset all restrictions if an error happened *\/\n\tif (ret != 0)\n\t\tmemset(&ctx->restrictions, 0, sizeof(ctx->restrictions));\n\telse\n\t\tctx->restrictions.registered = true;\n\n\tkfree(res);\n\treturn ret;","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":232956,"func":"static CURLcode gzip_init_writer(struct Curl_easy *data,\n                                 struct contenc_writer *writer)\n{\n  struct zlib_params *zp = (struct zlib_params *) &writer->params;\n  z_stream *z = &zp->z;     \/* zlib state structure *\/\n\n  if(!writer->downstream)\n    return CURLE_WRITE_ERROR;\n\n  \/* Initialize zlib *\/\n  z->zalloc = (alloc_func) zalloc_cb;\n  z->zfree = (free_func) zfree_cb;\n\n  if(strcmp(zlibVersion(), \"1.2.0.4\") >= 0) {\n    \/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing *\/\n    if(inflateInit2(z, MAX_WBITS + 32) != Z_OK) {\n      return process_zlib_error(data, z);\n    }\n    zp->zlib_init = ZLIB_INIT_GZIP; \/* Transparent gzip decompress state *\/\n  }\n  else {\n    \/* we must parse the gzip header and trailer ourselves *\/\n    if(inflateInit2(z, -MAX_WBITS) != Z_OK) {\n      return process_zlib_error(data, z);\n    }\n    zp->trailerlen = 8; \/* A CRC-32 and a 32-bit input size (RFC 1952, 2.2) *\/\n    zp->zlib_init = ZLIB_INIT; \/* Initial call state *\/\n  }\n\n  return CURLE_OK;\n}","target":0,"code_token_length":311,"total_token_length":547,"max_tokens_setting":1024}
+{"idx":344227,"func":"static void collectvalidlines (lua_State *L, Closure *f) {\n  if (noLuaClosure(f)) {\n    setnilvalue(s2v(L->top));\n    api_incr_top(L);\n  }\n  else {\n    int i;\n    TValue v;\n    const Proto *p = f->l.p;\n    int currentline = p->linedefined;\n    Table *t = luaH_new(L);  \/* new table to store active lines *\/\n    sethvalue2s(L, L->top, t);  \/* push it on stack *\/\n    api_incr_top(L);\n    setbtvalue(&v);  \/* boolean 'true' to be the value of all indices *\/\n    if (!p->is_vararg)  \/* regular function? *\/\n      i = 0;  \/* consider all instructions *\/\n    else {  \/* vararg function *\/\n      lua_assert(GET_OPCODE(p->code[0]) == OP_VARARGPREP);\n      currentline = nextline(p, currentline, 0);\n      i = 1;  \/* skip first instruction (OP_VARARGPREP) *\/\n    }\n    for (; i < p->sizelineinfo; i++) {  \/* for each instruction *\/\n      currentline = nextline(p, currentline, i);  \/* get its line *\/\n      luaH_setint(L, t, currentline, &v);  \/* table[line] = true *\/\n    }\n  }\n}","target":0,"code_token_length":302,"total_token_length":538,"max_tokens_setting":1024}
+{"idx":220226,"func":"Node* Graph::AddNode(NodeDef node_def, Status* status) {\n  const OpRegistrationData* op_reg_data;\n  status->Update(ops_.LookUp(node_def.op(), &op_reg_data));\n  if (!status->ok()) return nullptr;\n\n  DataTypeVector inputs;\n  DataTypeVector outputs;\n  status->Update(\n      InOutTypesForNode(node_def, op_reg_data->op_def, &inputs, &outputs));\n  if (!status->ok()) {\n    *status = AttachDef(*status, node_def);\n    return nullptr;\n  }\n\n  Node::NodeClass node_class = op_reg_data->is_function_op\n                                   ? Node::NC_FUNCTION_OP\n                                   : Node::GetNodeClassForOp(node_def.op());\n\n  if (op_reg_data->type_ctor != nullptr) {\n    VLOG(3) << \"AddNode: found type constructor for \" << node_def.name();\n    const auto ctor_type =\n        full_type::SpecializeType(AttrSlice(node_def), op_reg_data->op_def);\n    if (!ctor_type.ok()) {\n      *status = errors::InvalidArgument(\"type error: \",\n                                        ctor_type.status().ToString());\n      return nullptr;\n    }\n    const FullTypeDef ctor_typedef = ctor_type.ValueOrDie();\n    if (ctor_typedef.type_id() != TFT_UNSET) {\n      *(node_def.mutable_experimental_type()) = ctor_typedef;\n    }\n  } else {\n    VLOG(3) << \"AddNode: no type constructor for \" << node_def.name();\n  }\n\n  Node* node = AllocateNode(std::make_shared<NodeProperties>(\n                                &op_reg_data->op_def, std::move(node_def),\n                                inputs, outputs, op_reg_data->fwd_type_fn),\n                            nullptr, node_class);\n  return node;\n}","target":0,"code_token_length":374,"total_token_length":610,"max_tokens_setting":1024}
+{"idx":300770,"func":"static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,\n\t\t\t\t   int dlen, long timeout)\n{\n\tstruct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct list_head *cong_links = &tsk->cong_links;\n\tint blks = tsk_blocks(GROUP_H_SIZE + dlen);\n\tstruct tipc_msg *hdr = &tsk->phdr;\n\tstruct tipc_member *first = NULL;\n\tstruct tipc_member *mbr = NULL;\n\tstruct net *net = sock_net(sk);\n\tu32 node, port, exclude;\n\tstruct list_head dsts;\n\tint lookups = 0;\n\tint dstcnt, rc;\n\tbool cong;\n\n\tINIT_LIST_HEAD(&dsts);\n\tua->sa.type = msg_nametype(hdr);\n\tua->scope = msg_lookup_scope(hdr);\n\n\twhile (++lookups < 4) {\n\t\texclude = tipc_group_exclude(tsk->group);\n\n\t\tfirst = NULL;\n\n\t\t\/* Look for a non-congested destination member, if any *\/\n\t\twhile (1) {\n\t\t\tif (!tipc_nametbl_lookup_group(net, ua, &dsts, &dstcnt,\n\t\t\t\t\t\t       exclude, false))\n\t\t\t\treturn -EHOSTUNREACH;\n\t\t\ttipc_dest_pop(&dsts, &node, &port);\n\t\t\tcong = tipc_group_cong(tsk->group, node, port, blks,\n\t\t\t\t\t       &mbr);\n\t\t\tif (!cong)\n\t\t\t\tbreak;\n\t\t\tif (mbr == first)\n\t\t\t\tbreak;\n\t\t\tif (!first)\n\t\t\t\tfirst = mbr;\n\t\t}\n\n\t\t\/* Start over if destination was not in member list *\/\n\t\tif (unlikely(!mbr))\n\t\t\tcontinue;\n\n\t\tif (likely(!cong && !tipc_dest_find(cong_links, node, 0)))\n\t\t\tbreak;\n\n\t\t\/* Block or return if destination link or member is congested *\/\n\t\trc = tipc_wait_for_cond(sock, &timeout,\n\t\t\t\t\t!tipc_dest_find(cong_links, node, 0) &&\n\t\t\t\t\ttsk->group &&\n\t\t\t\t\t!tipc_group_cong(tsk->group, node, port,\n\t\t\t\t\t\t\t blks, &mbr));\n\t\tif (unlikely(rc))\n\t\t\treturn rc;\n\n\t\t\/* Send, unless destination disappeared while waiting *\/\n\t\tif (likely(mbr))\n\t\t\tbreak;\n\t}\n\n\tif (unlikely(lookups >= 4))\n\t\treturn -EHOSTUNREACH;\n\n\trc = tipc_send_group_msg(net, tsk, m, mbr, node, port, dlen);\n\n\treturn rc ? rc : dlen;\n}","target":0,"code_token_length":578,"total_token_length":814,"max_tokens_setting":1024}
+{"idx":513338,"func":"end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),\n\t\t  bool end_of_records)\n{\n  TABLE *table= join_tab->table;\n  int\t  error;\n  DBUG_ENTER(\"end_unique_update\");\n\n  if (end_of_records)\n    DBUG_RETURN(NESTED_LOOP_OK);\n\n  init_tmptable_sum_functions(join->sum_funcs);\n  copy_fields(join_tab->tmp_table_param);\t\t\/\/ Groups are copied twice.\n  if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd))\n    DBUG_RETURN(NESTED_LOOP_ERROR);           \/* purecov: inspected *\/\n\n  if (!(error= table->file->ha_write_tmp_row(table->record[0])))\n    join_tab->send_records++;\t\t\t\/\/ New group\n  else\n  {\n    if ((int) table->file->get_dup_key(error) < 0)\n    {\n      table->file->print_error(error,MYF(0));\t\/* purecov: inspected *\/\n      DBUG_RETURN(NESTED_LOOP_ERROR);            \/* purecov: inspected *\/\n    }\n    \/* Prepare table for random positioning *\/\n    bool rnd_inited= (table->file->inited == handler::RND);\n    if (!rnd_inited &&\n        ((error= table->file->ha_index_end()) ||\n         (error= table->file->ha_rnd_init(0))))\n    {\n      table->file->print_error(error, MYF(0));\n      DBUG_RETURN(NESTED_LOOP_ERROR);\n    }\n    if (table->file->ha_rnd_pos(table->record[1],table->file->dup_ref))\n    {\n      table->file->print_error(error,MYF(0));\t\/* purecov: inspected *\/\n      DBUG_RETURN(NESTED_LOOP_ERROR);            \/* purecov: inspected *\/\n    }\n    restore_record(table,record[1]);\n    update_tmptable_sum_func(join->sum_funcs,table);\n    if ((error= table->file->ha_update_tmp_row(table->record[1],\n                                               table->record[0])))\n    {\n      table->file->print_error(error,MYF(0));\t\/* purecov: inspected *\/\n      DBUG_RETURN(NESTED_LOOP_ERROR);            \/* purecov: inspected *\/\n    }\n    if (!rnd_inited &&\n        ((error= table->file->ha_rnd_end()) ||\n         (error= table->file->ha_index_init(0, 0))))\n    {\n      table->file->print_error(error, MYF(0));\n      DBUG_RETURN(NESTED_LOOP_ERROR);\n    }\n  }\n  if (join->thd->check_killed())\n  {\n    join->thd->send_kill_message();\n    DBUG_RETURN(NESTED_LOOP_KILLED);             \/* purecov: inspected *\/\n  }\n  DBUG_RETURN(NESTED_LOOP_OK);\n}","target":0,"code_token_length":611,"total_token_length":847,"max_tokens_setting":1024}
+{"idx":427801,"func":"static void sev_flush_guest_memory(struct vcpu_svm *svm, void *va,\n\t\t\t\t   unsigned long len)\n{\n\t\/*\n\t * If hardware enforced cache coherency for encrypted mappings of the\n\t * same physical page is supported, nothing to do.\n\t *\/\n\tif (boot_cpu_has(X86_FEATURE_SME_COHERENT))\n\t\treturn;\n\n\t\/*\n\t * If the VM Page Flush MSR is supported, use it to flush the page\n\t * (using the page virtual address and the guest ASID).\n\t *\/\n\tif (boot_cpu_has(X86_FEATURE_VM_PAGE_FLUSH)) {\n\t\tstruct kvm_sev_info *sev;\n\t\tunsigned long va_start;\n\t\tu64 start, stop;\n\n\t\t\/* Align start and stop to page boundaries. *\/\n\t\tva_start = (unsigned long)va;\n\t\tstart = (u64)va_start & PAGE_MASK;\n\t\tstop = PAGE_ALIGN((u64)va_start + len);\n\n\t\tif (start < stop) {\n\t\t\tsev = &to_kvm_svm(svm->vcpu.kvm)->sev_info;\n\n\t\t\twhile (start < stop) {\n\t\t\t\twrmsrl(MSR_AMD64_VM_PAGE_FLUSH,\n\t\t\t\t       start | sev->asid);\n\n\t\t\t\tstart += PAGE_SIZE;\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tWARN(1, \"Address overflow, using WBINVD\\n\");\n\t}\n\n\t\/*\n\t * Hardware should always have one of the above features,\n\t * but if not, use WBINVD and issue a warning.\n\t *\/\n\tWARN_ONCE(1, \"Using WBINVD to flush guest memory\\n\");\n\twbinvd_on_all_cpus();\n}","target":0,"code_token_length":348,"total_token_length":584,"max_tokens_setting":1024}
+{"idx":282873,"func":"int rsi_handle_card_ready(struct rsi_common *common, u8 *msg)\n{\n\tint status;\n\n\tswitch (common->fsm_state) {\n\tcase FSM_CARD_NOT_READY:\n\t\trsi_dbg(INIT_ZONE, \"Card ready indication from Common HAL\\n\");\n\t\trsi_set_default_parameters(common);\n\t\tif (rsi_send_common_dev_params(common) < 0)\n\t\t\treturn -EINVAL;\n\t\tcommon->fsm_state = FSM_COMMON_DEV_PARAMS_SENT;\n\t\tbreak;\n\tcase FSM_COMMON_DEV_PARAMS_SENT:\n\t\trsi_dbg(INIT_ZONE, \"Card ready indication from WLAN HAL\\n\");\n\n\t\tif (common->priv->device_model == RSI_DEV_9116) {\n\t\t\tif (msg[16] != MAGIC_WORD) {\n\t\t\t\trsi_dbg(FSM_ZONE,\n\t\t\t\t\t\"%s: [EEPROM_READ] Invalid token\\n\",\n\t\t\t\t\t__func__);\n\t\t\t\tcommon->fsm_state = FSM_CARD_NOT_READY;\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tmemcpy(common->mac_addr, &msg[20], ETH_ALEN);\n\t\t\trsi_dbg(INIT_ZONE, \"MAC Addr %pM\", common->mac_addr);\n\t\t}\n\t\t\/* Get usb buffer status register address *\/\n\t\tcommon->priv->usb_buffer_status_reg = *(u32 *)&msg[8];\n\t\trsi_dbg(INFO_ZONE, \"USB buffer status register = %x\\n\",\n\t\t\tcommon->priv->usb_buffer_status_reg);\n\n\t\tif (common->priv->device_model == RSI_DEV_9116)\n\t\t\tstatus = rsi_load_9116_bootup_params(common);\n\t\telse\n\t\t\tstatus = rsi_load_bootup_params(common);\n\t\tif (status < 0) {\n\t\t\tcommon->fsm_state = FSM_CARD_NOT_READY;\n\t\t\treturn status;\n\t\t}\n\t\tcommon->fsm_state = FSM_BOOT_PARAMS_SENT;\n\t\tbreak;\n\tdefault:\n\t\trsi_dbg(ERR_ZONE,\n\t\t\t\"%s: card ready indication in invalid state %d.\\n\",\n\t\t\t__func__, common->fsm_state);\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":424913,"func":"static void iwl_trans_pcie_configure(struct iwl_trans *trans,\n\t\t\t\t     const struct iwl_trans_config *trans_cfg)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\n\ttrans_pcie->cmd_queue = trans_cfg->cmd_queue;\n\ttrans_pcie->cmd_fifo = trans_cfg->cmd_fifo;\n\ttrans_pcie->cmd_q_wdg_timeout = trans_cfg->cmd_q_wdg_timeout;\n\tif (WARN_ON(trans_cfg->n_no_reclaim_cmds > MAX_NO_RECLAIM_CMDS))\n\t\ttrans_pcie->n_no_reclaim_cmds = 0;\n\telse\n\t\ttrans_pcie->n_no_reclaim_cmds = trans_cfg->n_no_reclaim_cmds;\n\tif (trans_pcie->n_no_reclaim_cmds)\n\t\tmemcpy(trans_pcie->no_reclaim_cmds, trans_cfg->no_reclaim_cmds,\n\t\t       trans_pcie->n_no_reclaim_cmds * sizeof(u8));\n\n\ttrans_pcie->rx_buf_size = trans_cfg->rx_buf_size;\n\ttrans_pcie->rx_page_order =\n\t\tiwl_trans_get_rb_size_order(trans_pcie->rx_buf_size);\n\n\ttrans_pcie->bc_table_dword = trans_cfg->bc_table_dword;\n\ttrans_pcie->scd_set_active = trans_cfg->scd_set_active;\n\ttrans_pcie->sw_csum_tx = trans_cfg->sw_csum_tx;\n\n\ttrans_pcie->page_offs = trans_cfg->cb_data_offs;\n\ttrans_pcie->dev_cmd_offs = trans_cfg->cb_data_offs + sizeof(void *);\n\n\ttrans->command_groups = trans_cfg->command_groups;\n\ttrans->command_groups_size = trans_cfg->command_groups_size;\n\n\t\/* Initialize NAPI here - it should be before registering to mac80211\n\t * in the opmode but after the HW struct is allocated.\n\t * As this function may be called again in some corner cases don't\n\t * do anything if NAPI was already initialized.\n\t *\/\n\tif (trans_pcie->napi_dev.reg_state != NETREG_DUMMY)\n\t\tinit_dummy_netdev(&trans_pcie->napi_dev);\n}","target":0,"code_token_length":438,"total_token_length":674,"max_tokens_setting":1024}
+{"idx":463190,"func":"EXPORTED int annotate_delete_mailbox(struct mailbox *mailbox)\n{\n    int r = 0;\n    char *fname = NULL;\n    annotate_db_t *d = NULL;\n\n    init_internal();\n\n    assert(mailbox);\n\n    \/* remove any per-folder annotations from the global db *\/\n    r = _annotate_getdb(NULL, 0, \/*don't create*\/0, &d);\n    if (r == CYRUSDB_NOTFOUND) {\n        \/* no global database, must not be anything to rename *\/\n        r = 0;\n        goto out;\n    }\n    if (r) goto out;\n\n    annotate_begin(d);\n\n    r = _annotate_rewrite(mailbox,\n                          \/*olduid*\/0, \/*olduserid*\/NULL,\n                          \/*newmailbox*\/NULL,\n                          \/*newuid*\/0, \/*newuserid*\/NULL,\n                          \/*copy*\/0);\n    if (r) goto out;\n\n    \/* remove the entire per-folder database *\/\n    r = annotate_dbname_mailbox(mailbox, &fname);\n    if (r) goto out;\n\n    \/* (gnb)TODO: do we even need to do this?? *\/\n    if (unlink(fname) < 0 && errno != ENOENT) {\n        syslog(LOG_ERR, \"cannot unlink %s: %m\", fname);\n    }\n\n    r = annotate_commit(d);\n\nout:\n    annotate_putdb(&d);\n    free(fname);\n    return r;\n}","target":0,"code_token_length":294,"total_token_length":530,"max_tokens_setting":1024}
+{"idx":434081,"func":"alist_expand(int *fnum_list, int fnum_len)\n{\n    char_u\t**old_arg_files;\n    int\t\told_arg_count;\n    char_u\t**new_arg_files;\n    int\t\tnew_arg_file_count;\n    char_u\t*save_p_su = p_su;\n    int\t\ti;\n\n    \/\/ Don't use 'suffixes' here.  This should work like the shell did the\n    \/\/ expansion.  Also, the vimrc file isn't read yet, thus the user\n    \/\/ can't set the options.\n    p_su = empty_option;\n    old_arg_files = ALLOC_MULT(char_u *, GARGCOUNT);\n    if (old_arg_files != NULL)\n    {\n\tfor (i = 0; i < GARGCOUNT; ++i)\n\t    old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname);\n\told_arg_count = GARGCOUNT;\n\tif (expand_wildcards(old_arg_count, old_arg_files,\n\t\t    &new_arg_file_count, &new_arg_files,\n\t\t    EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK\n\t\t&& new_arg_file_count > 0)\n\t{\n\t    alist_set(&global_alist, new_arg_file_count, new_arg_files,\n\t\t\t\t\t\t   TRUE, fnum_list, fnum_len);\n\t    FreeWild(old_arg_count, old_arg_files);\n\t}\n    }\n    p_su = save_p_su;\n}","target":0,"code_token_length":300,"total_token_length":536,"max_tokens_setting":1024}
+{"idx":437389,"func":"onig_reg_init(regex_t* reg, OnigOptionType option, OnigCaseFoldType case_fold_flag,\n              OnigEncoding enc, OnigSyntaxType* syntax)\n{\n  int r;\n\n  xmemset(reg, 0, sizeof(*reg));\n\n  if (onig_inited == 0) {\n#if 0\n    return ONIGERR_LIBRARY_IS_NOT_INITIALIZED;\n#else\n    r = onig_initialize(&enc, 1);\n    if (r != 0)\n      return ONIGERR_FAIL_TO_INITIALIZE;\n\n    onig_warning(\"You didn't call onig_initialize() explicitly\");\n#endif\n  }\n\n  if (IS_NULL(reg))\n    return ONIGERR_INVALID_ARGUMENT;\n\n  if (ONIGENC_IS_UNDEF(enc))\n    return ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED;\n\n  if ((option & (ONIG_OPTION_DONT_CAPTURE_GROUP|ONIG_OPTION_CAPTURE_GROUP))\n      == (ONIG_OPTION_DONT_CAPTURE_GROUP|ONIG_OPTION_CAPTURE_GROUP)) {\n    return ONIGERR_INVALID_COMBINATION_OF_OPTIONS;\n  }\n\n  if ((option & ONIG_OPTION_NEGATE_SINGLELINE) != 0) {\n    option |= syntax->options;\n    option &= ~ONIG_OPTION_SINGLELINE;\n  }\n  else\n    option |= syntax->options;\n\n  (reg)->enc              = enc;\n  (reg)->options          = option;\n  (reg)->syntax           = syntax;\n  (reg)->optimize         = 0;\n  (reg)->exact            = (UChar* )NULL;\n  (reg)->extp             = (RegexExt* )NULL;\n\n  (reg)->p                = (UChar* )NULL;\n  (reg)->alloc            = 0;\n  (reg)->used             = 0;\n  (reg)->name_table       = (void* )NULL;\n\n  (reg)->case_fold_flag   = case_fold_flag;\n  return 0;\n}","target":0,"code_token_length":401,"total_token_length":637,"max_tokens_setting":1024}
+{"idx":238560,"func":"static int check_core_relo(struct bpf_verifier_env *env,\n\t\t\t   const union bpf_attr *attr,\n\t\t\t   bpfptr_t uattr)\n{\n\tu32 i, nr_core_relo, ncopy, expected_size, rec_size;\n\tstruct bpf_core_relo core_relo = {};\n\tstruct bpf_prog *prog = env->prog;\n\tconst struct btf *btf = prog->aux->btf;\n\tstruct bpf_core_ctx ctx = {\n\t\t.log = &env->log,\n\t\t.btf = btf,\n\t};\n\tbpfptr_t u_core_relo;\n\tint err;\n\n\tnr_core_relo = attr->core_relo_cnt;\n\tif (!nr_core_relo)\n\t\treturn 0;\n\tif (nr_core_relo > INT_MAX \/ sizeof(struct bpf_core_relo))\n\t\treturn -EINVAL;\n\n\trec_size = attr->core_relo_rec_size;\n\tif (rec_size < MIN_CORE_RELO_SIZE ||\n\t    rec_size > MAX_CORE_RELO_SIZE ||\n\t    rec_size % sizeof(u32))\n\t\treturn -EINVAL;\n\n\tu_core_relo = make_bpfptr(attr->core_relos, uattr.is_kernel);\n\texpected_size = sizeof(struct bpf_core_relo);\n\tncopy = min_t(u32, expected_size, rec_size);\n\n\t\/* Unlike func_info and line_info, copy and apply each CO-RE\n\t * relocation record one at a time.\n\t *\/\n\tfor (i = 0; i < nr_core_relo; i++) {\n\t\t\/* future proofing when sizeof(bpf_core_relo) changes *\/\n\t\terr = bpf_check_uarg_tail_zero(u_core_relo, expected_size, rec_size);\n\t\tif (err) {\n\t\t\tif (err == -E2BIG) {\n\t\t\t\tverbose(env, \"nonzero tailing record in core_relo\");\n\t\t\t\tif (copy_to_bpfptr_offset(uattr,\n\t\t\t\t\t\t\t  offsetof(union bpf_attr, core_relo_rec_size),\n\t\t\t\t\t\t\t  &expected_size, sizeof(expected_size)))\n\t\t\t\t\terr = -EFAULT;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tif (copy_from_bpfptr(&core_relo, u_core_relo, ncopy)) {\n\t\t\terr = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (core_relo.insn_off % 8 || core_relo.insn_off \/ 8 >= prog->len) {\n\t\t\tverbose(env, \"Invalid core_relo[%u].insn_off:%u prog->len:%u\\n\",\n\t\t\t\ti, core_relo.insn_off, prog->len);\n\t\t\terr = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\n\t\terr = bpf_core_apply(&ctx, &core_relo, i,\n\t\t\t\t     &prog->insnsi[core_relo.insn_off \/ 8]);\n\t\tif (err)\n\t\t\tbreak;\n\t\tbpfptr_add(&u_core_relo, rec_size);\n\t}\n\treturn err;\n}","target":0,"code_token_length":609,"total_token_length":845,"max_tokens_setting":1024}
+{"idx":293741,"func":"static RList *symbols(RBinFile *bf) {\n\tRList *ret = r_list_newf (free);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\n\tRKernelCacheObj *obj = (RKernelCacheObj*) bf->o->bin_obj;\n\n\tsymbols_from_mach0 (ret, obj->mach0, bf, 0, 0);\n\n\tHtPP *kernel_syms_by_addr = sdb_ht_new ();\n\tif (!kernel_syms_by_addr) {\n\t\tr_list_free (ret);\n\t\treturn NULL;\n\t}\n\n\tRListIter *iter;\n\tRBinSymbol *sym;\n\tut64 enosys_addr = 0;\n\tr_list_foreach (ret, iter, sym) {\n\t\tr_strf_var (key, 64, \"%\"PFMT64x, sym->vaddr);\n\t\tsdb_ht_insert (kernel_syms_by_addr, key, sym->dname ? sym->dname : sym->name);\n\t\tif (!enosys_addr && strstr (sym->name, \"enosys\")) {\n\t\t\tenosys_addr = sym->vaddr;\n\t\t}\n\t}\n\n\tRList *syscalls = resolve_syscalls (obj, enosys_addr);\n\tif (syscalls) {\n\t\tr_list_foreach (syscalls, iter, sym) {\n\t\t\tr_strf_var (key, 32, \"%\"PFMT64x, sym->vaddr);\n\t\t\tsdb_ht_insert (kernel_syms_by_addr, key, sym->name);\n\t\t\tr_list_append (ret, sym);\n\t\t}\n\t\tsyscalls->free = NULL;\n\t\tr_list_free (syscalls);\n\t}\n\n\tRList *subsystem = resolve_mig_subsystem (obj);\n\tif (subsystem) {\n\t\tr_list_foreach (subsystem, iter, sym) {\n\t\t\tr_strf_var (key, 64, \"%\"PFMT64x, sym->vaddr);\n\t\t\tsdb_ht_insert (kernel_syms_by_addr, key, sym->name);\n\t\t\tr_list_append (ret, sym);\n\t\t}\n\t\tsubsystem->free = NULL;\n\t\tr_list_free (subsystem);\n\t}\n\n\tensure_kexts_initialized (obj, bf);\n\n\tRKext *kext;\n\tint kiter;\n\tut64 *inits = NULL;\n\tut64 *terms = NULL;\n\tr_kext_index_foreach (obj->kexts, kiter, kext) {\n\t\tut8 magicbytes[4];\n\t\tr_buf_read_at (obj->cache_buf, kext->range.offset, magicbytes, 4);\n\t\tint magic = r_read_le32 (magicbytes);\n\t\tswitch (magic) {\n\t\tcase MH_MAGIC_64:\n\t\t\tsymbols_from_mach0 (ret, kext->mach0, bf, kext->range.offset, r_list_length (ret));\n\t\t\tsymbols_from_stubs (ret, kernel_syms_by_addr, obj, bf, kext, r_list_length (ret));\n\t\t\tprocess_constructors (obj, kext->mach0, ret, kext->range.offset, false, R_K_CONSTRUCTOR_TO_SYMBOL, kext_short_name (kext));\n\t\t\tprocess_kmod_init_term (obj, kext, ret, &inits, &terms);\n\n\t\t\tbreak;\n\t\tdefault:\n\t\t\teprintf (\"Unknown sub-bin\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tR_FREE (inits);\n\tR_FREE (terms);\n\n\tsdb_ht_free (kernel_syms_by_addr);\n\n\treturn ret;\n}","target":0,"code_token_length":737,"total_token_length":973,"max_tokens_setting":1024}
+{"idx":236126,"func":"GF_Err text_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu16 pSize;\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_data(bs, ptr->reserved, 6);\n\tgf_bs_write_u16(bs, ptr->dataReferenceIndex);\n\n\tgf_bs_write_u32(bs, ptr->displayFlags);\t\t\t\/*Display flags*\/\n\tgf_bs_write_u32(bs, ptr->textJustification);\t\/*Text justification*\/\n\tgf_bs_write_data(bs, ptr->background_color, 6);\t\/*Background color*\/\n\tgpp_write_box(bs, &ptr->default_box);\t\t\t\/*Default text box*\/\n\tgf_bs_write_data(bs, ptr->reserved1, 8);\t\t\/*Reserved*\/\n\tgf_bs_write_u16(bs, ptr->fontNumber);\t\t\t\/*Font number*\/\n\tgf_bs_write_u16(bs, ptr->fontFace);\t\t\t\t\/*Font face*\/\n\tgf_bs_write_u8(bs, ptr->reserved2);\t\t\t\t\/*Reserved*\/\n\tgf_bs_write_u16(bs, ptr->reserved3);\t\t\t\/*Reserved*\/\n\tgf_bs_write_data(bs, ptr->foreground_color, 6);\t\/*Foreground color*\/\n\t\/\/pSize assignment below is not a mistake\n\tif (ptr->textName && (pSize = (u16) strlen(ptr->textName))) {\n\t\tgf_bs_write_u8(bs, pSize);\t\t\t\t\t\/*a Pascal string begins with its size*\/\n\t\tgf_bs_write_data(bs, ptr->textName, pSize);\t\/*Font name*\/\n\t} else {\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":393,"total_token_length":629,"max_tokens_setting":1024}
+{"idx":281633,"func":"void CLASS parse_fuji (int offset)\n{\n  unsigned entries, tag, len, save, c;\n\n  fseek (ifp, offset, SEEK_SET);\n  entries = get4();\n  if (entries > 255) return;\n  while (entries--) {\n    tag = get2();\n    len = get2();\n    save = ftell(ifp);\n    if (tag == 0x100) {\n      raw_height = get2();\n      raw_width  = get2();\n    } else if (tag == 0x121) {\n      height = get2();\n      if ((width = get2()) == 4284) width += 3;\n    } else if (tag == 0x130) {\n      fuji_layout = fgetc(ifp) >> 7;\n      fuji_width = !(fgetc(ifp) & 8);\n    } else if (tag == 0x131) {\n      filters = 9;\n      FORC(36) xtrans[0][35-c] = fgetc(ifp) & 3;\n    } else if (tag == 0x2ff0) {\n      FORC4 cam_mul[c ^ 1] = get2();\n    } else if (tag == 0xc000) {\n      c = order;\n      order = 0x4949;\n      if ((tag = get4()) > 10000) tag = get4();\n      width = tag;\n      height = get4();\n      order = c;\n    }\n    fseek (ifp, save+len, SEEK_SET);\n  }\n  height <<= fuji_layout;\n  width  >>= fuji_layout;\n}","target":0,"code_token_length":367,"total_token_length":603,"max_tokens_setting":1024}
+{"idx":224291,"func":"gopherSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int xerrno, void *data)\n{\n    GopherStateData *gopherState = (GopherStateData *) data;\n    StoreEntry *entry = gopherState->entry;\n    debugs(10, 5, conn << \" size: \" << size << \" errflag: \" << errflag);\n\n    if (size > 0) {\n        fd_bytes(conn->fd, size, FD_WRITE);\n        statCounter.server.all.kbytes_out += size;\n        statCounter.server.other.kbytes_out += size;\n    }\n\n    if (!entry->isAccepting()) {\n        debugs(10, 3, \"terminating due to bad \" << *entry);\n        \/\/ TODO: Do not abuse connection for triggering cleanup.\n        gopherState->serverConn->close();\n        return;\n    }\n\n    if (errflag) {\n        const auto err = new ErrorState(ERR_WRITE_ERROR, Http::scServiceUnavailable, gopherState->fwd->request, gopherState->fwd->al);\n        err->xerrno = xerrno;\n        err->port = gopherState->fwd->request->url.port();\n        err->url = xstrdup(entry->url());\n        gopherState->fwd->fail(err);\n        gopherState->serverConn->close();\n        return;\n    }\n\n    \/*\n     * OK. We successfully reach remote site.  Start MIME typing\n     * stuff.  Do it anyway even though request is not HTML type.\n     *\/\n    entry->buffer();\n\n    gopherMimeCreate(gopherState);\n\n    switch (gopherState->type_id) {\n\n    case GOPHER_DIRECTORY:\n        \/* we got to convert it first *\/\n        gopherState->conversion = GopherStateData::HTML_DIR;\n        gopherState->HTML_header_added = 0;\n        break;\n\n    case GOPHER_INDEX:\n        \/* we got to convert it first *\/\n        gopherState->conversion = GopherStateData::HTML_INDEX_RESULT;\n        gopherState->HTML_header_added = 0;\n        break;\n\n    case GOPHER_CSO:\n        \/* we got to convert it first *\/\n        gopherState->conversion = GopherStateData::HTML_CSO_RESULT;\n        gopherState->cso_recno = 0;\n        gopherState->HTML_header_added = 0;\n        break;\n\n    default:\n        gopherState->conversion = GopherStateData::NORMAL;\n        entry->flush();\n    }\n\n    \/* Schedule read reply. *\/\n    AsyncCall::Pointer call =  commCbCall(5,5, \"gopherReadReply\",\n                                          CommIoCbPtrFun(gopherReadReply, gopherState));\n    entry->delayAwareRead(conn, gopherState->replybuf, BUFSIZ, call);\n}","target":0,"code_token_length":604,"total_token_length":840,"max_tokens_setting":1024}
+{"idx":450397,"func":"static int send_mono_rect(VncState *vs, int x, int y,\n                          int w, int h, uint32_t bg, uint32_t fg)\n{\n    ssize_t bytes;\n    int stream = 1;\n    int level = tight_conf[vs->tight->compression].mono_zlib_level;\n\n#ifdef CONFIG_VNC_PNG\n    if (tight_can_send_png_rect(vs, w, h)) {\n        int ret;\n        int bpp = vs->client_pf.bytes_per_pixel * 8;\n        VncPalette *palette = palette_new(2, bpp);\n\n        palette_put(palette, bg);\n        palette_put(palette, fg);\n        ret = send_png_rect(vs, x, y, w, h, palette);\n        palette_destroy(palette);\n        return ret;\n    }\n#endif\n\n    bytes = DIV_ROUND_UP(w, 8) * h;\n\n    vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);\n    vnc_write_u8(vs, VNC_TIGHT_FILTER_PALETTE);\n    vnc_write_u8(vs, 1);\n\n    switch (vs->client_pf.bytes_per_pixel) {\n    case 4:\n    {\n        uint32_t buf[2] = {bg, fg};\n        size_t ret = sizeof (buf);\n\n        if (vs->tight->pixel24) {\n            tight_pack24(vs, (unsigned char*)buf, 2, &ret);\n        }\n        vnc_write(vs, buf, ret);\n\n        tight_encode_mono_rect32(vs->tight->tight.buffer, w, h, bg, fg);\n        break;\n    }\n    case 2:\n        vnc_write(vs, &bg, 2);\n        vnc_write(vs, &fg, 2);\n        tight_encode_mono_rect16(vs->tight->tight.buffer, w, h, bg, fg);\n        break;\n    default:\n        vnc_write_u8(vs, bg);\n        vnc_write_u8(vs, fg);\n        tight_encode_mono_rect8(vs->tight->tight.buffer, w, h, bg, fg);\n        break;\n    }\n    vs->tight->tight.offset = bytes;\n\n    bytes = tight_compress_data(vs, stream, bytes, level, Z_DEFAULT_STRATEGY);\n    return (bytes >= 0);\n}","target":0,"code_token_length":488,"total_token_length":724,"max_tokens_setting":1024}
+{"idx":313556,"func":"static void rose_del_route_by_neigh(struct rose_neigh *rose_neigh)\n{\n\tstruct rose_route *rose_route, *s;\n\n\trose_neigh->restarted = 0;\n\n\trose_stop_t0timer(rose_neigh);\n\trose_start_ftimer(rose_neigh);\n\n\tskb_queue_purge(&rose_neigh->queue);\n\n\tspin_lock_bh(&rose_route_list_lock);\n\n\trose_route = rose_route_list;\n\n\twhile (rose_route != NULL) {\n\t\tif ((rose_route->neigh1 == rose_neigh && rose_route->neigh2 == rose_neigh) ||\n\t\t    (rose_route->neigh1 == rose_neigh && rose_route->neigh2 == NULL)       ||\n\t\t    (rose_route->neigh2 == rose_neigh && rose_route->neigh1 == NULL)) {\n\t\t\ts = rose_route->next;\n\t\t\trose_remove_route(rose_route);\n\t\t\trose_route = s;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (rose_route->neigh1 == rose_neigh) {\n\t\t\trose_route->neigh1->use--;\n\t\t\trose_route->neigh1 = NULL;\n\t\t\trose_transmit_clear_request(rose_route->neigh2, rose_route->lci2, ROSE_OUT_OF_ORDER, 0);\n\t\t}\n\n\t\tif (rose_route->neigh2 == rose_neigh) {\n\t\t\trose_route->neigh2->use--;\n\t\t\trose_route->neigh2 = NULL;\n\t\t\trose_transmit_clear_request(rose_route->neigh1, rose_route->lci1, ROSE_OUT_OF_ORDER, 0);\n\t\t}\n\n\t\trose_route = rose_route->next;\n\t}\n\tspin_unlock_bh(&rose_route_list_lock);\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":386565,"func":"bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* \/*creationInterface*\/) {\n    \/\/ Allocate LWPolyline vertices (group code 90):\n    if (groupCode==90) {\n        maxVertices = toInt(groupValue);\n        if (maxVertices>0) {\n            if (vertices!=NULL) {\n                delete[] vertices;\n            }\n            vertices = new double[4*maxVertices];\n            for (int i=0; i<maxVertices; ++i) {\n                vertices[i*4] = 0.0;\n                vertices[i*4+1] = 0.0;\n                vertices[i*4+2] = 0.0;\n                vertices[i*4+3] = 0.0;\n            }\n        }\n        vertexIndex=-1;\n        return true;\n    }\n\n    \/\/ Process LWPolylines vertices (group codes 10\/20\/30\/42):\n    else if (groupCode==10 || groupCode==20 ||\n             groupCode==30 || groupCode==42) {\n\n        if (vertexIndex<maxVertices-1 && groupCode==10) {\n            vertexIndex++;\n        }\n\n        if (groupCode<=30) {\n            if (vertexIndex>=0 && vertexIndex<maxVertices && vertexIndex>=0) {\n                vertices[4*vertexIndex + (groupCode\/10-1)] = toReal(groupValue);\n            }\n        } else if (groupCode==42 && vertexIndex<maxVertices && vertexIndex>=0) {\n            vertices[4*vertexIndex + 3] = toReal(groupValue);\n        }\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":364,"total_token_length":600,"max_tokens_setting":1024}
+{"idx":312412,"func":"qf_setprop_items_from_lines(\n\tqf_info_T\t*qi,\n\tint\t\tqf_idx,\n\tdict_T\t\t*what,\n\tdictitem_T\t*di,\n\tint\t\taction)\n{\n    char_u\t*errorformat = p_efm;\n    dictitem_T\t*efm_di;\n    int\t\tretval = FAIL;\n\n    \/\/ Use the user supplied errorformat settings (if present)\n    if ((efm_di = dict_find(what, (char_u *)\"efm\", -1)) != NULL)\n    {\n\tif (efm_di->di_tv.v_type != VAR_STRING ||\n\t\tefm_di->di_tv.vval.v_string == NULL)\n\t    return FAIL;\n\terrorformat = efm_di->di_tv.vval.v_string;\n    }\n\n    \/\/ Only a List value is supported\n    if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL)\n\treturn FAIL;\n\n    if (action == 'r')\n\tqf_free_items(&qi->qf_lists[qf_idx]);\n    if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat,\n\t\tFALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) >= 0)\n\tretval = OK;\n\n    return retval;\n}","target":0,"code_token_length":283,"total_token_length":519,"max_tokens_setting":1024}
+{"idx":225951,"func":"GF_Err esds_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e=GF_OK;\n\tu32 descSize;\n\tGF_ESDBox *ptr = (GF_ESDBox *)s;\n\n\tdescSize = (u32) (ptr->size);\n\n\tif (descSize) {\n\t\tchar *enc_desc = (char*)gf_malloc(sizeof(char) * descSize);\n\t\tif (!enc_desc) return GF_OUT_OF_MEM;\n\t\t\/\/get the payload\n\t\tgf_bs_read_data(bs, enc_desc, descSize);\n\t\t\/\/send it to the OD Codec\n\t\te = gf_odf_desc_read(enc_desc, descSize, (GF_Descriptor **) &ptr->desc);\n\t\t\/\/OK, free our desc\n\t\tgf_free(enc_desc);\n\n\t\tif (ptr->desc && (ptr->desc->tag!=GF_ODF_ESD_TAG) ) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid descriptor tag 0x%x in esds\\n\", ptr->desc->tag));\n\t\t\tgf_odf_desc_del((GF_Descriptor*)ptr->desc);\n\t\t\tptr->desc=NULL;\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\n\t\tif (e) {\n\t\t\tptr->desc = NULL;\n\t\t} else {\n\t\t\t\/*fix broken files*\/\n\t\t\tif (ptr->desc && !ptr->desc->URLString) {\n\t\t\t\tif (!ptr->desc->slConfig) {\n\t\t\t\t\tptr->desc->slConfig = (GF_SLConfig *) gf_odf_desc_new(GF_ODF_SLC_TAG);\n\t\t\t\t\tptr->desc->slConfig->predefined = SLPredef_MP4;\n\t\t\t\t} else if (ptr->desc->slConfig->predefined != SLPredef_MP4) {\n\t\t\t\t\tptr->desc->slConfig->predefined = SLPredef_MP4;\n\t\t\t\t\tgf_odf_slc_set_pref(ptr->desc->slConfig);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn e;\n}","target":0,"code_token_length":428,"total_token_length":664,"max_tokens_setting":1024}
+{"idx":326093,"func":"regconcat(int *flagp)\n{\n    char_u\t*first = NULL;\n    char_u\t*chain = NULL;\n    char_u\t*latest;\n    int\t\tflags;\n    int\t\tcont = TRUE;\n\n    *flagp = WORST;\t\t\/\/ Tentatively.\n\n    while (cont)\n    {\n\tswitch (peekchr())\n\t{\n\t    case NUL:\n\t    case Magic('|'):\n\t    case Magic('&'):\n\t    case Magic(')'):\n\t\t\t    cont = FALSE;\n\t\t\t    break;\n\t    case Magic('Z'):\n\t\t\t    regflags |= RF_ICOMBINE;\n\t\t\t    skipchr_keepstart();\n\t\t\t    break;\n\t    case Magic('c'):\n\t\t\t    regflags |= RF_ICASE;\n\t\t\t    skipchr_keepstart();\n\t\t\t    break;\n\t    case Magic('C'):\n\t\t\t    regflags |= RF_NOICASE;\n\t\t\t    skipchr_keepstart();\n\t\t\t    break;\n\t    case Magic('v'):\n\t\t\t    reg_magic = MAGIC_ALL;\n\t\t\t    skipchr_keepstart();\n\t\t\t    curchr = -1;\n\t\t\t    break;\n\t    case Magic('m'):\n\t\t\t    reg_magic = MAGIC_ON;\n\t\t\t    skipchr_keepstart();\n\t\t\t    curchr = -1;\n\t\t\t    break;\n\t    case Magic('M'):\n\t\t\t    reg_magic = MAGIC_OFF;\n\t\t\t    skipchr_keepstart();\n\t\t\t    curchr = -1;\n\t\t\t    break;\n\t    case Magic('V'):\n\t\t\t    reg_magic = MAGIC_NONE;\n\t\t\t    skipchr_keepstart();\n\t\t\t    curchr = -1;\n\t\t\t    break;\n\t    default:\n\t\t\t    latest = regpiece(&flags);\n\t\t\t    if (latest == NULL || reg_toolong)\n\t\t\t\treturn NULL;\n\t\t\t    *flagp |= flags & (HASWIDTH | HASNL | HASLOOKBH);\n\t\t\t    if (chain == NULL)\t\/\/ First piece.\n\t\t\t\t*flagp |= flags & SPSTART;\n\t\t\t    else\n\t\t\t\tregtail(chain, latest);\n\t\t\t    chain = latest;\n\t\t\t    if (first == NULL)\n\t\t\t\tfirst = latest;\n\t\t\t    break;\n\t}\n    }\n    if (first == NULL)\t\t\/\/ Loop ran zero times.\n\tfirst = regnode(NOTHING);\n    return first;\n}","target":0,"code_token_length":423,"total_token_length":659,"max_tokens_setting":1024}
+{"idx":384765,"func":"textpos2screenpos(\n\twin_T\t*wp,\n\tpos_T\t*pos,\n\tint\t*rowp,\t\/\/ screen row\n\tint\t*scolp,\t\/\/ start screen column\n\tint\t*ccolp,\t\/\/ cursor screen column\n\tint\t*ecolp)\t\/\/ end screen column\n{\n    colnr_T\tscol = 0, ccol = 0, ecol = 0;\n    int\t\trow = 0;\n    int\t\trowoff = 0;\n    colnr_T\tcoloff = 0;\n\n    if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline)\n    {\n\tcolnr_T off;\n\tcolnr_T col;\n\tint     width;\n\n\trow = plines_m_win(wp, wp->w_topline, pos->lnum - 1) + 1;\n\tgetvcol(wp, pos, &scol, &ccol, &ecol);\n\n\t\/\/ similar to what is done in validate_cursor_col()\n\tcol = scol;\n\toff = win_col_off(wp);\n\tcol += off;\n\twidth = wp->w_width - off + win_col_off2(wp);\n\n\t\/\/ long line wrapping, adjust row\n\tif (wp->w_p_wrap\n\t\t&& col >= (colnr_T)wp->w_width\n\t\t&& width > 0)\n\t{\n\t    \/\/ use same formula as what is used in curs_columns()\n\t    rowoff = ((col - wp->w_width) \/ width + 1);\n\t    col -= rowoff * width;\n\t}\n\tcol -= wp->w_leftcol;\n\tif (col >= wp->w_width)\n\t    col = -1;\n\tif (col >= 0 && row + rowoff <= wp->w_height)\n\t    coloff = col - scol + wp->w_wincol + 1;\n\telse\n\t    \/\/ character is left, right or below of the window\n\t    row = rowoff = scol = ccol = ecol = 0;\n    }\n    *rowp = W_WINROW(wp) + row + rowoff;\n    *scolp = scol + coloff;\n    *ccolp = ccol + coloff;\n    *ecolp = ecol + coloff;\n}","target":0,"code_token_length":476,"total_token_length":712,"max_tokens_setting":1024}
+{"idx":231041,"func":"    BaseType_t xQueueCRReceive( QueueHandle_t xQueue,\r\n                                void * pvBuffer,\r\n                                TickType_t xTicksToWait )\r\n    {\r\n        BaseType_t xReturn;\r\n        Queue_t * const pxQueue = xQueue;\r\n\r\n        \/* If the queue is already empty we may have to block.  A critical section\r\n         * is required to prevent an interrupt adding something to the queue\r\n         * between the check to see if the queue is empty and blocking on the queue. *\/\r\n        portDISABLE_INTERRUPTS();\r\n        {\r\n            if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )\r\n            {\r\n                \/* There are no messages in the queue, do we want to block or just\r\n                 * leave with nothing? *\/\r\n                if( xTicksToWait > ( TickType_t ) 0 )\r\n                {\r\n                    \/* As this is a co-routine we cannot block directly, but return\r\n                     * indicating that we need to block. *\/\r\n                    vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) );\r\n                    portENABLE_INTERRUPTS();\r\n                    return errQUEUE_BLOCKED;\r\n                }\r\n                else\r\n                {\r\n                    portENABLE_INTERRUPTS();\r\n                    return errQUEUE_FULL;\r\n                }\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n        }\r\n        portENABLE_INTERRUPTS();\r\n\r\n        portDISABLE_INTERRUPTS();\r\n        {\r\n            if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r\n            {\r\n                \/* Data is available from the queue. *\/\r\n                pxQueue->u.xQueue.pcReadFrom += pxQueue->uxItemSize;\r\n\r\n                if( pxQueue->u.xQueue.pcReadFrom >= pxQueue->u.xQueue.pcTail )\r\n                {\r\n                    pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead;\r\n                }\r\n                else\r\n                {\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n\r\n                --( pxQueue->uxMessagesWaiting );\r\n                ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.xQueue.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r\n\r\n                xReturn = pdPASS;\r\n\r\n                \/* Were any co-routines waiting for space to become available? *\/\r\n                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r\n                {\r\n                    \/* In this instance the co-routine could be placed directly\r\n                     * into the ready list as we are within a critical section.\r\n                     * Instead the same pending ready list mechanism is used as if\r\n                     * the event were caused from within an interrupt. *\/\r\n                    if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r\n                    {\r\n                        xReturn = errQUEUE_YIELD;\r\n                    }\r\n                    else\r\n                    {\r\n                        mtCOVERAGE_TEST_MARKER();\r\n                    }\r\n                }\r\n                else\r\n                {\r\n                    mtCOVERAGE_TEST_MARKER();\r\n                }\r\n            }\r\n            else\r\n            {\r\n                xReturn = pdFAIL;\r\n            }\r\n        }\r\n        portENABLE_INTERRUPTS();\r\n\r\n        return xReturn;\r\n    }\r","target":0,"code_token_length":643,"total_token_length":879,"max_tokens_setting":1024}
+{"idx":195398,"func":"static int vidioc_querycap(struct file *file, void *priv,\n\t\t\t   struct v4l2_capability *cap)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);\n\tint labellen = (sizeof(cap->card) < sizeof(dev->card_label)) ?\n\t\t\t       sizeof(cap->card) :\n\t\t\t\t     sizeof(dev->card_label);\n\tint device_nr =\n\t\t((struct v4l2loopback_private *)video_get_drvdata(dev->vdev))\n\t\t\t->device_nr;\n\t__u32 capabilities = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;\n\n\tstrlcpy(cap->driver, \"v4l2 loopback\", sizeof(cap->driver));\n\tsnprintf(cap->card, labellen, dev->card_label);\n\tsnprintf(cap->bus_info, sizeof(cap->bus_info),\n\t\t \"platform:v4l2loopback-%03d\", device_nr);\n\n#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)\n\t\/* since 3.1.0, the v4l2-core system is supposed to set the version *\/\n\tcap->version = V4L2LOOPBACK_VERSION_CODE;\n#endif\n\n#ifdef V4L2_CAP_VIDEO_M2M\n\tcapabilities |= V4L2_CAP_VIDEO_M2M;\n#endif \/* V4L2_CAP_VIDEO_M2M *\/\n\n\tif (dev->announce_all_caps) {\n\t\tcapabilities |= V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT;\n\t} else {\n\t\tif (dev->ready_for_capture) {\n\t\t\tcapabilities |= V4L2_CAP_VIDEO_CAPTURE;\n\t\t}\n\t\tif (dev->ready_for_output) {\n\t\t\tcapabilities |= V4L2_CAP_VIDEO_OUTPUT;\n\t\t}\n\t}\n\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)\n\tdev->vdev->device_caps =\n#endif \/* >=linux-4.7.0 *\/\n\t\tcap->device_caps = cap->capabilities = capabilities;\n\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)\n\tcap->capabilities |= V4L2_CAP_DEVICE_CAPS;\n#endif\n\n\tmemset(cap->reserved, 0, sizeof(cap->reserved));\n\treturn 0;\n}","target":1,"code_token_length":474,"total_token_length":710,"max_tokens_setting":1024}
+{"idx":432149,"func":"PipelineD::buildInnerQueryExecutor(const CollectionPtr& collection,\n                                   const NamespaceString& nss,\n                                   const AggregateCommandRequest* aggRequest,\n                                   Pipeline* pipeline) {\n    auto expCtx = pipeline->getContext();\n\n    \/\/ We will be modifying the source vector as we go.\n    Pipeline::SourceContainer& sources = pipeline->_sources;\n\n    if (!sources.empty() && !sources.front()->constraints().requiresInputDocSource) {\n        return {};\n    }\n\n    if (!sources.empty()) {\n        \/\/ Try to inspect if the DocumentSourceSample or a DocumentSourceInternalUnpackBucket stage\n        \/\/ can be optimized for sampling backed by a storage engine supplied random cursor.\n        auto&& [sampleStage, unpackBucketStage] = extractSampleUnpackBucket(sources);\n\n        \/\/ Optimize an initial $sample stage if possible.\n        if (collection && sampleStage) {\n            auto [attachExecutorCallback, exec] =\n                buildInnerQueryExecutorSample(sampleStage, unpackBucketStage, collection, pipeline);\n            if (exec) {\n                return std::make_pair(std::move(attachExecutorCallback), std::move(exec));\n            }\n        }\n    }\n\n    \/\/ If the first stage is $geoNear, prepare a special DocumentSourceGeoNearCursor stage;\n    \/\/ otherwise, create a generic DocumentSourceCursor.\n    const auto geoNearStage =\n        sources.empty() ? nullptr : dynamic_cast<DocumentSourceGeoNear*>(sources.front().get());\n    if (geoNearStage) {\n        return buildInnerQueryExecutorGeoNear(collection, nss, aggRequest, pipeline);\n    } else {\n        return buildInnerQueryExecutorGeneric(collection, nss, aggRequest, pipeline);\n    }\n}","target":0,"code_token_length":344,"total_token_length":580,"max_tokens_setting":1024}
+{"idx":229327,"func":"Status AddOrExecuteNode(core::RefCountPtr<KernelAndDevice> kernel,\n                        EagerOperation* op, TensorHandle** retvals) {\n  EagerExecutor& executor = op->Executor();\n  EagerContext& ctx = op->EagerContext();\n  GraphCollector* graph_collector = nullptr;\n  if (ctx.ShouldStoreGraphs()) {\n    graph_collector = ctx.GetGraphCollector();\n  }\n  const int num_outputs = kernel->num_outputs();\n  absl::optional<EagerFunctionParams> eager_func_params =\n      op->eager_func_params();\n  if (kernel->IsCrossProcess() && !eager_func_params.has_value()) {\n    \/\/ Create an eager op id for a cross-process function if not exist.\n#if defined(IS_MOBILE_PLATFORM)\n    return errors::Unimplemented(\n        \"Cross-process functions are not supported on mobile devices.\");\n#else  \/\/ !IS_MOBILE_PLATFORM\n    const int64_t op_id = ctx.RemoteMgr()->NextOpId();\n    eager_func_params = EagerFunctionParams{op_id, \/*step_id=*\/absl::nullopt};\n#endif  \/\/ !IS_MOBILE_PLATFORM\n  }\n  if (executor.Async()) {\n    const DataTypeVector& output_dtypes = kernel->output_dtypes();\n    for (int i = 0, end = num_outputs; i < end; ++i) {\n      Device* output_device = ctx.CanonicalDevice(kernel->OutputDevice(i));\n      if (output_device == nullptr || output_device->IsLocal()) {\n        retvals[i] = TensorHandle::CreateEmptyLocalHandle(\n            \/* d= *\/ output_device, \/* op_device= *\/ kernel->device(),\n            \/* resource_device= *\/ kernel->OutputResourceDevice(i),\n            output_dtypes[i], &ctx);\n      } else {\n        TF_RETURN_IF_ERROR(\n            CreateUnshapedOutput(*kernel, i, output_device, output_dtypes[i],\n                                 eager_func_params, &ctx, &retvals[i]));\n      }\n    }\n    const absl::InlinedVector<TensorHandle*, 4>* inputs;\n    TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n    auto node = absl::make_unique<AsyncExecuteNode>(\n        &ctx, *inputs, eager_func_params, std::move(kernel), graph_collector,\n        op->GetCancellationManager(),\n        absl::Span<TensorHandle*>(retvals, num_outputs), op->GetStackTrace());\n    \/\/ Release the inputs from the eager operation since the AsyncExecuteNode\n    \/\/ would have taken ownership. This allows the inputs to be forwarded if\n    \/\/ possible.\n    op->Clear();\n    \/\/ For async mode, execution order will make sure that all\n    \/\/ input handles are ready before executing them.\n    \/\/ TODO(b\/137118203): Consider executing \"cheap\" kernels inline for\n    \/\/ performance.\n    return executor.AddOrExecute(std::move(node));\n  } else {\n    for (int i = 0, end = num_outputs; i < end; ++i) {\n      retvals[i] = nullptr;\n    }\n    const absl::InlinedVector<TensorHandle*, 4>* inputs;\n    TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n    ExecuteNode node(&ctx, *inputs, eager_func_params, kernel, graph_collector,\n                     op->GetCancellationManager(),\n                     {retvals, static_cast<size_t>(num_outputs)},\n                     op->GetStackTrace());\n    Status s = executor.SyncExecute(&node);\n    \/\/ We release the inputs AFTER executing the operation in sync mode since\n    \/\/ ExecuteNode does not increment the reference count and thus does not have\n    \/\/ ownership of the inputs while executing.\n    op->Clear();\n    return s;\n  }\n}","target":0,"code_token_length":775,"total_token_length":1011,"max_tokens_setting":1024}
+{"idx":424976,"func":"static void iwl_pcie_map_rx_causes(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tu32 offset =\n\t\ttrans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS ? 1 : 0;\n\tu32 val, idx;\n\n\t\/*\n\t * The first RX queue - fallback queue, which is designated for\n\t * management frame, command responses etc, is always mapped to the\n\t * first interrupt vector. The other RX queues are mapped to\n\t * the other (N - 2) interrupt vectors.\n\t *\/\n\tval = BIT(MSIX_FH_INT_CAUSES_Q(0));\n\tfor (idx = 1; idx < trans->num_rx_queues; idx++) {\n\t\tiwl_write8(trans, CSR_MSIX_RX_IVAR(idx),\n\t\t\t   MSIX_FH_INT_CAUSES_Q(idx - offset));\n\t\tval |= BIT(MSIX_FH_INT_CAUSES_Q(idx));\n\t}\n\tiwl_write32(trans, CSR_MSIX_FH_INT_MASK_AD, ~val);\n\n\tval = MSIX_FH_INT_CAUSES_Q(0);\n\tif (trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_NON_RX)\n\t\tval |= MSIX_NON_AUTO_CLEAR_CAUSE;\n\tiwl_write8(trans, CSR_MSIX_RX_IVAR(0), val);\n\n\tif (trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS)\n\t\tiwl_write8(trans, CSR_MSIX_RX_IVAR(1), val);\n}","target":0,"code_token_length":325,"total_token_length":561,"max_tokens_setting":1024}
+{"idx":513204,"func":"void sync_dynamic_session_variables(THD* thd, bool global_lock)\n{\n  uint idx;\n\n  thd->variables.dynamic_variables_ptr= (char*)\n    my_realloc(thd->variables.dynamic_variables_ptr,\n               global_variables_dynamic_size,\n               MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));\n\n  if (global_lock)\n    mysql_mutex_lock(&LOCK_global_system_variables);\n\n  mysql_mutex_assert_owner(&LOCK_global_system_variables);\n\n  memcpy(thd->variables.dynamic_variables_ptr +\n           thd->variables.dynamic_variables_size,\n         global_system_variables.dynamic_variables_ptr +\n           thd->variables.dynamic_variables_size,\n         global_system_variables.dynamic_variables_size -\n           thd->variables.dynamic_variables_size);\n\n  \/*\n    now we need to iterate through any newly copied 'defaults'\n    and if it is a string type with MEMALLOC flag, we need to strdup\n  *\/\n  for (idx= 0; idx < bookmark_hash.records; idx++)\n  {\n    st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx);\n\n    if (v->version <= thd->variables.dynamic_variables_version)\n      continue; \/* already in thd->variables *\/\n\n    \/* Here we do anything special that may be required of the data types *\/\n\n    if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&\n         v->key[0] & BOOKMARK_MEMALLOC)\n    {\n      char **pp= (char**) (thd->variables.dynamic_variables_ptr + v->offset);\n      if (*pp)\n        *pp= my_strdup(*pp, MYF(MY_WME|MY_FAE));\n    }\n  }\n\n  if (global_lock)\n    mysql_mutex_unlock(&LOCK_global_system_variables);\n\n  thd->variables.dynamic_variables_version=\n         global_system_variables.dynamic_variables_version;\n  thd->variables.dynamic_variables_head=\n         global_system_variables.dynamic_variables_head;\n  thd->variables.dynamic_variables_size=\n         global_system_variables.dynamic_variables_size;\n}","target":0,"code_token_length":416,"total_token_length":652,"max_tokens_setting":1024}
+{"idx":197826,"func":"bool IsConstantFoldable(\n    const Node* n,\n    const std::unordered_map<string, std::vector<PartialTensorShape>>*\n        shape_map,\n    const std::function<bool(const Node*)>& consider,\n    int64_t max_constant_size_in_bytes,\n    std::unordered_map<const Node*, std::vector<Tensor>>*\n        shape_replacement_map) {\n  if (n->IsConstant()) {\n    return true;\n  }\n  if (MaybeReplaceShapeOp(n, shape_map, shape_replacement_map)) {\n    return true;\n  }\n  if (n->op_def().is_stateful()) {\n    return false;\n  }\n  if (consider && !consider(n)) {\n    return false;\n  }\n  if (shape_map != nullptr) {\n    \/\/ We can skip the node if an output is known to be oversized.\n    auto shape_it = shape_map->find(n->name());\n    if (shape_it != shape_map->end()) {\n      for (int64_t i = 0; i < shape_it->second.size(); ++i) {\n        const auto& out_shape = shape_it->second[i];\n        if (out_shape.IsFullyDefined() &&\n            out_shape.num_elements() * DataTypeSize(n->output_type(i)) >\n                max_constant_size_in_bytes) {\n          return false;\n        }\n      }\n    }\n  }\n  if (n->IsControlFlow() || n->IsSend() || n->IsRecv()) {\n    return false;\n  }\n  \/\/ TODO(yuanbyu): For now disable these session handle operations.\n  if (n->IsGetSessionHandle() || n->IsGetSessionTensor() ||\n      n->IsDeleteSessionTensor()) {\n    return false;\n  }\n  if (n->IsSource()) {\n    return false;\n  }\n  if (n->IsSink()) {\n    return false;\n  }\n  if (n->IsFakeParam()) {\n    return false;\n  }\n  \/\/ Since constant-folding runs on the CPU, do not attempt to constant-fold\n  \/\/ operators that have no CPU kernel. Also implies that we will not\n  \/\/ constant-fold functions.\n  \/\/ TODO(phawkins): allow constant-folding for functions; functions may\n  \/\/ be arbitrarily expensive to execute.\n  if (!KernelDefAvailable(DeviceType(DEVICE_CPU), n->def())) {\n    return false;\n  }\n  \/\/ Do not constant fold nodes which will be allocated by ScopedAllocator.\n  \/\/ This is because the constant-folding graph will not contain the\n  \/\/ `_ScopedAllocator` node, and that is necessary to be able to run a node\n  \/\/ that will use this allocator.\n  if (n->attrs().Find(kScopedAllocatorAttrName) != nullptr) {\n    VLOG(2) << \"Skip node [\" << n->DebugString()\n            << \"] for constant folding due to scoped allocator\";\n    return false;\n  }\n  return true;\n}","target":1,"code_token_length":612,"total_token_length":848,"max_tokens_setting":1024}
+{"idx":317148,"func":"static int sb_check_xattr_support(struct super_block *sb)\n{\n\tstruct superblock_security_struct *sbsec = sb->s_security;\n\tstruct dentry *root = sb->s_root;\n\tstruct inode *root_inode = d_backing_inode(root);\n\tu32 sid;\n\tint rc;\n\n\t\/*\n\t * Make sure that the xattr handler exists and that no\n\t * error other than -ENODATA is returned by getxattr on\n\t * the root directory.  -ENODATA is ok, as this may be\n\t * the first boot of the SELinux kernel before we have\n\t * assigned xattr values to the filesystem.\n\t *\/\n\tif (!(root_inode->i_opflags & IOP_XATTR)) {\n\t\tpr_warn(\"SELinux: (dev %s, type %s) has no xattr support\\n\",\n\t\t\tsb->s_id, sb->s_type->name);\n\t\tgoto fallback;\n\t}\n\n\trc = __vfs_getxattr(root, root_inode, XATTR_NAME_SELINUX, NULL, 0);\n\tif (rc < 0 && rc != -ENODATA) {\n\t\tif (rc == -EOPNOTSUPP) {\n\t\t\tpr_warn(\"SELinux: (dev %s, type %s) has no security xattr handler\\n\",\n\t\t\t\tsb->s_id, sb->s_type->name);\n\t\t\tgoto fallback;\n\t\t} else {\n\t\t\tpr_warn(\"SELinux: (dev %s, type %s) getxattr errno %d\\n\",\n\t\t\t\tsb->s_id, sb->s_type->name, -rc);\n\t\t\treturn rc;\n\t\t}\n\t}\n\treturn 0;\n\nfallback:\n\t\/* No xattr support - try to fallback to genfs if possible. *\/\n\trc = security_genfs_sid(&selinux_state, sb->s_type->name, \"\/\",\n\t\t\t\tSECCLASS_DIR, &sid);\n\tif (rc)\n\t\treturn -EOPNOTSUPP;\n\n\tpr_warn(\"SELinux: (dev %s, type %s) falling back to genfs\\n\",\n\t\tsb->s_id, sb->s_type->name);\n\tsbsec->behavior = SECURITY_FS_USE_GENFS;\n\tsbsec->sid = sid;\n\treturn 0;\n}","target":0,"code_token_length":463,"total_token_length":699,"max_tokens_setting":1024}
+{"idx":234719,"func":"static int should_balance_chunk(struct extent_buffer *leaf,\n\t\t\t\tstruct btrfs_chunk *chunk, u64 chunk_offset)\n{\n\tstruct btrfs_fs_info *fs_info = leaf->fs_info;\n\tstruct btrfs_balance_control *bctl = fs_info->balance_ctl;\n\tstruct btrfs_balance_args *bargs = NULL;\n\tu64 chunk_type = btrfs_chunk_type(leaf, chunk);\n\n\t\/* type filter *\/\n\tif (!((chunk_type & BTRFS_BLOCK_GROUP_TYPE_MASK) &\n\t      (bctl->flags & BTRFS_BALANCE_TYPE_MASK))) {\n\t\treturn 0;\n\t}\n\n\tif (chunk_type & BTRFS_BLOCK_GROUP_DATA)\n\t\tbargs = &bctl->data;\n\telse if (chunk_type & BTRFS_BLOCK_GROUP_SYSTEM)\n\t\tbargs = &bctl->sys;\n\telse if (chunk_type & BTRFS_BLOCK_GROUP_METADATA)\n\t\tbargs = &bctl->meta;\n\n\t\/* profiles filter *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_PROFILES) &&\n\t    chunk_profiles_filter(chunk_type, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/* usage filter *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_USAGE) &&\n\t    chunk_usage_filter(fs_info, chunk_offset, bargs)) {\n\t\treturn 0;\n\t} else if ((bargs->flags & BTRFS_BALANCE_ARGS_USAGE_RANGE) &&\n\t    chunk_usage_range_filter(fs_info, chunk_offset, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/* devid filter *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_DEVID) &&\n\t    chunk_devid_filter(leaf, chunk, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/* drange filter, makes sense only with devid filter *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_DRANGE) &&\n\t    chunk_drange_filter(leaf, chunk, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/* vrange filter *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_VRANGE) &&\n\t    chunk_vrange_filter(leaf, chunk, chunk_offset, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/* stripes filter *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_STRIPES_RANGE) &&\n\t    chunk_stripes_range_filter(leaf, chunk, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/* soft profile changing mode *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_SOFT) &&\n\t    chunk_soft_convert_filter(chunk_type, bargs)) {\n\t\treturn 0;\n\t}\n\n\t\/*\n\t * limited by count, must be the last filter\n\t *\/\n\tif ((bargs->flags & BTRFS_BALANCE_ARGS_LIMIT)) {\n\t\tif (bargs->limit == 0)\n\t\t\treturn 0;\n\t\telse\n\t\t\tbargs->limit--;\n\t} else if ((bargs->flags & BTRFS_BALANCE_ARGS_LIMIT_RANGE)) {\n\t\t\/*\n\t\t * Same logic as the 'limit' filter; the minimum cannot be\n\t\t * determined here because we do not have the global information\n\t\t * about the count of all chunks that satisfy the filters.\n\t\t *\/\n\t\tif (bargs->limit_max == 0)\n\t\t\treturn 0;\n\t\telse\n\t\t\tbargs->limit_max--;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":702,"total_token_length":938,"max_tokens_setting":1024}
+{"idx":359257,"func":"bgp_write (struct thread *thread)\n{\n  struct peer *peer;\n  u_char type;\n  struct stream *s; \n  int num;\n  unsigned int count = 0;\n  int write_errno;\n\n  \/* Yes first of all get peer pointer. *\/\n  peer = THREAD_ARG (thread);\n  peer->t_write = NULL;\n\n  \/* For non-blocking IO check. *\/\n  if (peer->status == Connect)\n    {\n      bgp_connect_check (peer);\n      return 0;\n    }\n\n    \/* Nonblocking write until TCP output buffer is full.  *\/\n  while (1)\n    {\n      int writenum;\n      int val;\n\n      s = bgp_write_packet (peer);\n      if (! s)\n\treturn 0;\n      \n      \/* XXX: FIXME, the socket should be NONBLOCK from the start\n       * status shouldnt need to be toggled on each write\n       *\/\n      val = fcntl (peer->fd, F_GETFL, 0);\n      fcntl (peer->fd, F_SETFL, val|O_NONBLOCK);\n\n      \/* Number of bytes to be sent.  *\/\n      writenum = stream_get_endp (s) - stream_get_getp (s);\n\n      \/* Call write() system call.  *\/\n      num = write (peer->fd, STREAM_PNT (s), writenum);\n      write_errno = errno;\n      fcntl (peer->fd, F_SETFL, val);\n      if (num <= 0)\n\t{\n\t  \/* Partial write. *\/\n\t  if (write_errno == EWOULDBLOCK || write_errno == EAGAIN)\n\t      break;\n\n\t  BGP_EVENT_ADD (peer, TCP_fatal_error);\n\t  return 0;\n\t}\n      if (num != writenum)\n\t{\n\t  stream_forward_getp (s, num);\n\n\t  if (write_errno == EAGAIN)\n\t    break;\n\n\t  continue;\n\t}\n\n      \/* Retrieve BGP packet type. *\/\n      stream_set_getp (s, BGP_MARKER_SIZE + 2);\n      type = stream_getc (s);\n\n      switch (type)\n\t{\n\tcase BGP_MSG_OPEN:\n\t  peer->open_out++;\n\t  break;\n\tcase BGP_MSG_UPDATE:\n\t  peer->update_out++;\n\t  break;\n\tcase BGP_MSG_NOTIFY:\n\t  peer->notify_out++;\n\t  \/* Double start timer. *\/\n\t  peer->v_start *= 2;\n\n\t  \/* Overflow check. *\/\n\t  if (peer->v_start >= (60 * 2))\n\t    peer->v_start = (60 * 2);\n\n\t  \/* Flush any existing events *\/\n\t  BGP_EVENT_ADD (peer, BGP_Stop);\n\t  return 0;\n\tcase BGP_MSG_KEEPALIVE:\n\t  peer->keepalive_out++;\n\t  break;\n\tcase BGP_MSG_ROUTE_REFRESH_NEW:\n\tcase BGP_MSG_ROUTE_REFRESH_OLD:\n\t  peer->refresh_out++;\n\t  break;\n\tcase BGP_MSG_CAPABILITY:\n\t  peer->dynamic_cap_out++;\n\t  break;\n\t}\n\n      \/* OK we send packet so delete it. *\/\n      bgp_packet_delete (peer);\n\n      if (++count >= BGP_WRITE_PACKET_MAX)\n\tbreak;\n    }\n  \n  if (bgp_write_proceed (peer))\n    BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);\n  \n  return 0;\n}","target":0,"code_token_length":686,"total_token_length":922,"max_tokens_setting":1024}
+{"idx":387725,"func":"void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) {\n  InstanceKlass* super = superklass();\n  if (super != NULL) {\n    super->do_nonstatic_fields(cl);\n  }\n  fieldDescriptor fd;\n  int length = java_fields_count();\n  \/\/ In DebugInfo nonstatic fields are sorted by offset.\n  int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass);\n  int j = 0;\n  for (int i = 0; i < length; i += 1) {\n    fd.reinitialize(this, i);\n    if (!fd.is_static()) {\n      fields_sorted[j + 0] = fd.offset();\n      fields_sorted[j + 1] = i;\n      j += 2;\n    }\n  }\n  if (j > 0) {\n    length = j;\n    \/\/ _sort_Fn is defined in growableArray.hpp.\n    qsort(fields_sorted, length\/2, 2*sizeof(int), (_sort_Fn)compare_fields_by_offset);\n    for (int i = 0; i < length; i += 2) {\n      fd.reinitialize(this, fields_sorted[i + 1]);\n      assert(!fd.is_static() && fd.offset() == fields_sorted[i], \"only nonstatic fields\");\n      cl->do_field(&fd);\n    }\n  }\n  FREE_C_HEAP_ARRAY(int, fields_sorted);\n}","target":0,"code_token_length":297,"total_token_length":533,"max_tokens_setting":1024}
+{"idx":442565,"func":"static void test_circular_small_chunks(void)\n{\n    RedMemSlotInfo mem_info;\n    RedCursorCmd *red_cursor_cmd;\n    QXLCursorCmd cursor_cmd;\n    QXLCursor *cursor;\n    QXLDataChunk *chunks[2];\n\n    init_meminfo(&mem_info);\n    g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,\n                          \"*red_get_data_chunks_ptr: data split in too many chunks, avoiding DoS*\");\n\n    \/* a circular list of small chunks should not be a problems *\/\n    memset(&cursor_cmd, 0, sizeof(cursor_cmd));\n    cursor_cmd.type = QXL_CURSOR_SET;\n\n    cursor = create_chunk(SPICE_OFFSETOF(QXLCursor, chunk), 1, NULL, 0xaa);\n    cursor->header.unique = 1;\n    cursor->header.width = 128;\n    cursor->header.height = 128;\n    cursor->data_size = 128 * 128 * 4;\n\n    chunks[0] = create_chunk(0, 1, &cursor->chunk, 0xaa);\n    chunks[0]->next_chunk = to_physical(&cursor->chunk);\n\n    cursor_cmd.u.set.shape = to_physical(cursor);\n\n    red_cursor_cmd = red_cursor_cmd_new(NULL, &mem_info, 0, to_physical(&cursor_cmd));\n    if (red_cursor_cmd != NULL) {\n        \/* function does not return errors so there should be no data *\/\n        g_assert_cmpuint(red_cursor_cmd->type, ==, QXL_CURSOR_SET);\n        g_assert_cmpuint(red_cursor_cmd->u.set.position.x, ==, 0);\n        g_assert_cmpuint(red_cursor_cmd->u.set.position.y, ==, 0);\n        g_assert_cmpuint(red_cursor_cmd->u.set.shape.data_size, ==, 0);\n        red_cursor_cmd_unref(red_cursor_cmd);\n    }\n    g_test_assert_expected_messages();\n\n    g_free(cursor);\n    g_free(chunks[0]);\n    memslot_info_destroy(&mem_info);\n}","target":0,"code_token_length":424,"total_token_length":660,"max_tokens_setting":1024}
+{"idx":310332,"func":"list_server_status_v1(smartlist_t *routers, char **router_status_out,\n                      int for_controller)\n{\n  \/* List of entries in a router-status style: An optional !, then an optional\n   * equals-suffixed nickname, then a dollar-prefixed hexdigest. *\/\n  smartlist_t *rs_entries;\n  time_t now = time(NULL);\n  time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;\n  or_options_t *options = get_options();\n  \/* We include v2 dir auths here too, because they need to answer\n   * controllers. Eventually we'll deprecate this whole function;\n   * see also networkstatus_getinfo_by_purpose(). *\/\n  int authdir = authdir_mode_publishes_statuses(options);\n  tor_assert(router_status_out);\n\n  rs_entries = smartlist_create();\n\n  SMARTLIST_FOREACH_BEGIN(routers, routerinfo_t *, ri) {\n    if (authdir) {\n      \/* Update router status in routerinfo_t. *\/\n      dirserv_set_router_is_running(ri, now);\n    }\n    if (for_controller) {\n      char name_buf[MAX_VERBOSE_NICKNAME_LEN+2];\n      char *cp = name_buf;\n      if (!ri->is_running)\n        *cp++ = '!';\n      router_get_verbose_nickname(cp, ri);\n      smartlist_add(rs_entries, tor_strdup(name_buf));\n    } else if (ri->cache_info.published_on >= cutoff) {\n      smartlist_add(rs_entries, list_single_server_status(ri, ri->is_running));\n    }\n  } SMARTLIST_FOREACH_END(ri);\n\n  *router_status_out = smartlist_join_strings(rs_entries, \" \", 0, NULL);\n\n  SMARTLIST_FOREACH(rs_entries, char *, cp, tor_free(cp));\n  smartlist_free(rs_entries);\n\n  return 0;\n}","target":0,"code_token_length":382,"total_token_length":618,"max_tokens_setting":1024}
+{"idx":229273,"func":"cql_server::connection::read_frame() {\n    using ret_type = std::optional<cql_binary_frame_v3>;\n    if (!_version) {\n        \/\/ We don't know the frame size before reading the first frame,\n        \/\/ so read just one byte, and then read the rest of the frame.\n        return _read_buf.read_exactly(1).then([this] (temporary_buffer<char> buf) {\n            if (buf.empty()) {\n                return make_ready_future<ret_type>();\n            }\n            _version = buf[0];\n            init_cql_serialization_format();\n            if (_version < 1 || _version > current_version) {\n                auto client_version = _version;\n                _version = current_version;\n                throw exceptions::protocol_exception(format(\"Invalid or unsupported protocol version: {:d}\", client_version));\n            }\n\n\n            return _read_buf.read_exactly(frame_size() - 1).then([this] (temporary_buffer<char> tail) {\n                temporary_buffer<char> full(frame_size());\n                full.get_write()[0] = _version;\n                std::copy(tail.get(), tail.get() + tail.size(), full.get_write() + 1);\n                auto frame = parse_frame(std::move(full));\n                \/\/ This is the very first frame, so reject obviously incorrect frames, to\n                \/\/ avoid allocating large amounts of memory for the message body\n                if (frame.length > 100'000) {\n                    \/\/ The STARTUP message body is a [string map] containing just a few options,\n                    \/\/ so it should be smaller that 100kB. See #4366.\n                    throw exceptions::protocol_exception(format(\"Initial message size too large ({:d}), rejecting as invalid\", frame.length));\n                }\n                return make_ready_future<ret_type>(frame);\n            });\n        });\n    } else {\n        \/\/ Not the first frame, so we know the size.\n        return _read_buf.read_exactly(frame_size()).then([this] (temporary_buffer<char> buf) {\n            if (buf.empty()) {\n                return make_ready_future<ret_type>();\n            }\n            return make_ready_future<ret_type>(parse_frame(std::move(buf)));\n        });\n    }\n}","target":0,"code_token_length":459,"total_token_length":695,"max_tokens_setting":1024}
+{"idx":238486,"func":"static int sanitize_err(struct bpf_verifier_env *env,\n\t\t\tconst struct bpf_insn *insn, int reason,\n\t\t\tconst struct bpf_reg_state *off_reg,\n\t\t\tconst struct bpf_reg_state *dst_reg)\n{\n\tstatic const char *err = \"pointer arithmetic with it prohibited for !root\";\n\tconst char *op = BPF_OP(insn->code) == BPF_ADD ? \"add\" : \"sub\";\n\tu32 dst = insn->dst_reg, src = insn->src_reg;\n\n\tswitch (reason) {\n\tcase REASON_BOUNDS:\n\t\tverbose(env, \"R%d has unknown scalar with mixed signed bounds, %s\\n\",\n\t\t\toff_reg == dst_reg ? dst : src, err);\n\t\tbreak;\n\tcase REASON_TYPE:\n\t\tverbose(env, \"R%d has pointer with unsupported alu operation, %s\\n\",\n\t\t\toff_reg == dst_reg ? src : dst, err);\n\t\tbreak;\n\tcase REASON_PATHS:\n\t\tverbose(env, \"R%d tried to %s from different maps, paths or scalars, %s\\n\",\n\t\t\tdst, op, err);\n\t\tbreak;\n\tcase REASON_LIMIT:\n\t\tverbose(env, \"R%d tried to %s beyond pointer bounds, %s\\n\",\n\t\t\tdst, op, err);\n\t\tbreak;\n\tcase REASON_STACK:\n\t\tverbose(env, \"R%d could not be pushed for speculative verification, %s\\n\",\n\t\t\tdst, err);\n\t\tbreak;\n\tdefault:\n\t\tverbose(env, \"verifier internal error: unknown reason (%d)\\n\",\n\t\t\treason);\n\t\tbreak;\n\t}\n\n\treturn -EACCES;\n}","target":0,"code_token_length":340,"total_token_length":576,"max_tokens_setting":1024}
+{"idx":261211,"func":"static int MqttClient_Publish_ReadPayload(MqttClient* client,\n    MqttPublish* publish, int timeout_ms)\n{\n    int rc = MQTT_CODE_SUCCESS;\n    byte msg_done;\n\n    \/* Handle packet callback and read remaining payload *\/\n    do {\n        \/* Determine if message is done *\/\n        msg_done = ((publish->buffer_pos + publish->buffer_len) >=\n                    publish->total_len) ? 1 : 0;\n\n        if (publish->buffer_new) {\n            \/* Issue callback for new message (first time only) *\/\n            if (client->msg_cb) {\n                \/* if using the temp publish message buffer,\n                   then populate message context with client context *\/\n                if (publish->ctx == NULL && &client->msg.publish == publish) {\n                    publish->ctx = client->ctx;\n                }\n                rc = client->msg_cb(client, publish, publish->buffer_new,\n                                    msg_done);\n                if (rc != MQTT_CODE_SUCCESS) {\n                    return rc;\n                };\n            }\n\n            \/* Reset topic name since valid on new message only *\/\n            publish->topic_name = NULL;\n            publish->topic_name_len = 0;\n\n            publish->buffer_new = 0;\n        }\n\n        \/* Read payload *\/\n        if (!msg_done) {\n            int msg_len;\n\n            \/* add last length to position and reset len *\/\n            publish->buffer_pos += publish->buffer_len;\n            publish->buffer_len = 0;\n\n            \/* set state to reading payload *\/\n            publish->stat = MQTT_MSG_READ_PAYLOAD;\n\n            msg_len = (publish->total_len - publish->buffer_pos);\n            if (msg_len > client->rx_buf_len) {\n                msg_len = client->rx_buf_len;\n            }\n\n            \/* make sure there is something to read *\/\n            if (msg_len > 0) {\n                #ifdef WOLFMQTT_TEST_NONBLOCK\n                    if (!testNbAlt) {\n                        testNbAlt = 1;\n                        return MQTT_CODE_CONTINUE;\n                    }\n                    testNbAlt = 0;\n                #endif\n\n                rc = MqttSocket_Read(client, client->rx_buf, msg_len,\n                        timeout_ms);\n                if (rc < 0) {\n                    break;\n                }\n\n                \/* Update message *\/\n                publish->buffer = client->rx_buf;\n                publish->buffer_len = rc;\n                rc = MQTT_CODE_SUCCESS; \/* mark success *\/\n\n                msg_done = ((publish->buffer_pos + publish->buffer_len) >=\n                    publish->total_len) ? 1 : 0;\n\n                \/* Issue callback for additional publish payload *\/\n                if (client->msg_cb) {\n                    rc = client->msg_cb(client, publish, publish->buffer_new,\n                                        msg_done);\n                    if (rc != MQTT_CODE_SUCCESS) {\n                        return rc;\n                    };\n                }\n            }\n        }\n    } while (!msg_done);\n\n    return rc;\n}","target":0,"code_token_length":594,"total_token_length":830,"max_tokens_setting":1024}
+{"idx":415213,"func":"cmd_pkauth (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  unsigned char *outdata;\n  size_t outdatalen;\n  char *keyidstr;\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  if (!ctrl->app_ctx)\n    return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);\n\n \/* We have to use a copy of the key ID because the function may use\n     the pin_cb which in turn uses the assuan line buffer and thus\n     overwriting the original line with the keyid *\/\n  keyidstr = xtrystrdup (line);\n  if (!keyidstr)\n    return out_of_core ();\n\n  rc = app_auth (ctrl->app_ctx,\n                 keyidstr,\n                 pin_cb, ctx,\n                 ctrl->in_data.value, ctrl->in_data.valuelen,\n                 &outdata, &outdatalen);\n  xfree (keyidstr);\n  if (rc)\n    {\n      log_error (\"app_auth failed: %s\\n\", gpg_strerror (rc));\n    }\n  else\n    {\n      rc = assuan_send_data (ctx, outdata, outdatalen);\n      xfree (outdata);\n      if (rc)\n        return rc; \/* that is already an assuan error code *\/\n    }\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":327,"total_token_length":563,"max_tokens_setting":1024}
+{"idx":259219,"func":"static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVEncryptionInfo **encrypted_samples;\n    MOVEncryptionIndex *encryption_index;\n    MOVStreamContext *sc;\n    int use_subsamples, ret;\n    unsigned int sample_count, i, alloc_size = 0;\n\n    ret = get_current_encryption_info(c, &encryption_index, &sc);\n    if (ret != 1)\n        return ret;\n\n    if (encryption_index->nb_encrypted_samples) {\n        \/\/ This can happen if we have both saio\/saiz and senc atoms.\n        av_log(c->fc, AV_LOG_DEBUG, \"Ignoring duplicate encryption info in senc\\n\");\n        return 0;\n    }\n\n    avio_r8(pb); \/* version *\/\n    use_subsamples = avio_rb24(pb) & 0x02; \/* flags *\/\n\n    sample_count = avio_rb32(pb);\n    if (sample_count >= INT_MAX \/ sizeof(*encrypted_samples))\n        return AVERROR(ENOMEM);\n\n    for (i = 0; i < sample_count; i++) {\n        unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count);\n        encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size,\n                                            min_samples * sizeof(*encrypted_samples));\n        if (encrypted_samples) {\n            encryption_index->encrypted_samples = encrypted_samples;\n\n            ret = mov_read_sample_encryption_info(\n                c, pb, sc, &encryption_index->encrypted_samples[i], use_subsamples);\n        } else {\n            ret = AVERROR(ENOMEM);\n        }\n        if (pb->eof_reached) {\n            av_log(c->fc, AV_LOG_ERROR, \"Hit EOF while reading senc\\n\");\n            if (ret >= 0)\n                av_encryption_info_free(encryption_index->encrypted_samples[i]);\n            ret = AVERROR_INVALIDDATA;\n        }\n\n        if (ret < 0) {\n            for (; i > 0; i--)\n                av_encryption_info_free(encryption_index->encrypted_samples[i - 1]);\n            av_freep(&encryption_index->encrypted_samples);\n            return ret;\n        }\n    }\n    encryption_index->nb_encrypted_samples = sample_count;\n\n    return 0;\n}","target":0,"code_token_length":493,"total_token_length":729,"max_tokens_setting":1024}
+{"idx":509490,"func":"bool ha_maria::check_if_incompatible_data(HA_CREATE_INFO *create_info,\n                                          uint table_changes)\n{\n  DBUG_ENTER(\"check_if_incompatible_data\");\n  uint options= table->s->db_options_in_use;\n  enum ha_choice page_checksum= table->s->page_checksum;\n\n  if (page_checksum == HA_CHOICE_UNDEF)\n    page_checksum= file->s->options & HA_OPTION_PAGE_CHECKSUM ? HA_CHOICE_YES\n                                                              : HA_CHOICE_NO;\n\n  if (create_info->auto_increment_value != stats.auto_increment_value ||\n      create_info->data_file_name != data_file_name ||\n      create_info->index_file_name != index_file_name ||\n      create_info->page_checksum != page_checksum ||\n      create_info->transactional != table->s->transactional ||\n      (maria_row_type(create_info) != data_file_type &&\n       create_info->row_type != ROW_TYPE_DEFAULT) ||\n      table_changes == IS_EQUAL_NO ||\n      (table_changes & IS_EQUAL_PACK_LENGTH)) \/\/ Not implemented yet\n    DBUG_RETURN(COMPATIBLE_DATA_NO);\n\n  if ((options & (HA_OPTION_CHECKSUM |\n                  HA_OPTION_DELAY_KEY_WRITE)) !=\n      (create_info->table_options & (HA_OPTION_CHECKSUM |\n                              HA_OPTION_DELAY_KEY_WRITE)))\n    DBUG_RETURN(COMPATIBLE_DATA_NO);\n  DBUG_RETURN(COMPATIBLE_DATA_YES);\n}","target":0,"code_token_length":287,"total_token_length":523,"max_tokens_setting":1024}
+{"idx":401499,"func":"signed long __sched schedule_timeout(signed long timeout)\n{\n\tstruct process_timer timer;\n\tunsigned long expire;\n\n\tswitch (timeout)\n\t{\n\tcase MAX_SCHEDULE_TIMEOUT:\n\t\t\/*\n\t\t * These two special cases are useful to be comfortable\n\t\t * in the caller. Nothing more. We could take\n\t\t * MAX_SCHEDULE_TIMEOUT from one of the negative value\n\t\t * but I' d like to return a valid offset (>=0) to allow\n\t\t * the caller to do everything it want with the retval.\n\t\t *\/\n\t\tschedule();\n\t\tgoto out;\n\tdefault:\n\t\t\/*\n\t\t * Another bit of PARANOID. Note that the retval will be\n\t\t * 0 since no piece of kernel is supposed to do a check\n\t\t * for a negative retval of schedule_timeout() (since it\n\t\t * should never happens anyway). You just have the printk()\n\t\t * that will tell you if something is gone wrong and where.\n\t\t *\/\n\t\tif (timeout < 0) {\n\t\t\tprintk(KERN_ERR \"schedule_timeout: wrong timeout \"\n\t\t\t\t\"value %lx\\n\", timeout);\n\t\t\tdump_stack();\n\t\t\tcurrent->state = TASK_RUNNING;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\texpire = timeout + jiffies;\n\n\ttimer.task = current;\n\ttimer_setup_on_stack(&timer.timer, process_timeout, 0);\n\t__mod_timer(&timer.timer, expire, MOD_TIMER_NOTPENDING);\n\tschedule();\n\tdel_singleshot_timer_sync(&timer.timer);\n\n\t\/* Remove the timer from the object tracker *\/\n\tdestroy_timer_on_stack(&timer.timer);\n\n\ttimeout = expire - jiffies;\n\n out:\n\treturn timeout < 0 ? 0 : timeout;\n}","target":0,"code_token_length":341,"total_token_length":577,"max_tokens_setting":1024}
+{"idx":253635,"func":"smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t   struct cifsFileInfo *cfile)\n{\n\tstruct smb2_file_network_open_info file_inf;\n\tstruct inode *inode;\n\tint rc;\n\n\trc = __SMB2_close(xid, tcon, cfile->fid.persistent_fid,\n\t\t   cfile->fid.volatile_fid, &file_inf);\n\tif (rc)\n\t\treturn;\n\n\tinode = d_inode(cfile->dentry);\n\n\tspin_lock(&inode->i_lock);\n\tCIFS_I(inode)->time = jiffies;\n\n\t\/* Creation time should not need to be updated on close *\/\n\tif (file_inf.LastWriteTime)\n\t\tinode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);\n\tif (file_inf.ChangeTime)\n\t\tinode->i_ctime = cifs_NTtimeToUnix(file_inf.ChangeTime);\n\tif (file_inf.LastAccessTime)\n\t\tinode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);\n\n\t\/*\n\t * i_blocks is not related to (i_size \/ i_blksize),\n\t * but instead 512 byte (2**9) size is required for\n\t * calculating num blocks.\n\t *\/\n\tif (le64_to_cpu(file_inf.AllocationSize) > 4096)\n\t\tinode->i_blocks =\n\t\t\t(512 - 1 + le64_to_cpu(file_inf.AllocationSize)) >> 9;\n\n\t\/* End of file and Attributes should not have to be updated on close *\/\n\tspin_unlock(&inode->i_lock);\n}","target":0,"code_token_length":334,"total_token_length":570,"max_tokens_setting":1024}
+{"idx":366317,"func":"static int do_remount(struct path *path, int ms_flags, int sb_flags,\n\t\t      int mnt_flags, void *data)\n{\n\tint err;\n\tstruct super_block *sb = path->mnt->mnt_sb;\n\tstruct mount *mnt = real_mount(path->mnt);\n\tstruct fs_context *fc;\n\n\tif (!check_mnt(mnt))\n\t\treturn -EINVAL;\n\n\tif (path->dentry != path->mnt->mnt_root)\n\t\treturn -EINVAL;\n\n\tif (!can_change_locked_flags(mnt, mnt_flags))\n\t\treturn -EPERM;\n\n\tfc = fs_context_for_reconfigure(path->dentry, sb_flags, MS_RMT_MASK);\n\tif (IS_ERR(fc))\n\t\treturn PTR_ERR(fc);\n\n\tfc->oldapi = true;\n\terr = parse_monolithic_mount_data(fc, data);\n\tif (!err) {\n\t\tdown_write(&sb->s_umount);\n\t\terr = -EPERM;\n\t\tif (ns_capable(sb->s_user_ns, CAP_SYS_ADMIN)) {\n\t\t\terr = reconfigure_super(fc);\n\t\t\tif (!err) {\n\t\t\t\tlock_mount_hash();\n\t\t\t\tset_mount_attributes(mnt, mnt_flags);\n\t\t\t\tunlock_mount_hash();\n\t\t\t}\n\t\t}\n\t\tup_write(&sb->s_umount);\n\t}\n\n\tmnt_warn_timestamp_expiry(path, &mnt->mnt);\n\n\tput_fs_context(fc);\n\treturn err;\n}","target":0,"code_token_length":280,"total_token_length":516,"max_tokens_setting":1024}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..98478993cbd05c1ff49d54a30bf8a9144bc0612c
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3e9fc7ec217d1e504614b6bfb2016af58eb4afb1e9de851a364a7c2bfc4ee2fa
+size 3471984
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..15d84028daf6be45956ae2f884a1ed460cc44558
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.jsonl
@@ -0,0 +1,21 @@
+{"idx":230138,"func":"static json_t * register_new_attestation(struct config_module * config, json_t * j_params, json_t * j_scheme_data, json_t * j_credential) {\n  json_t * j_return, * j_client_data = NULL, * j_error, * j_result, * j_pubkey = NULL, * j_cert = NULL, * j_query, * j_element = NULL;\n  unsigned char * client_data = NULL, * challenge_b64 = NULL, * att_obj = NULL, * cbor_bs_handle = NULL, rpid_hash[32], * fmt = NULL, * credential_id_b64 = NULL, * cbor_auth_data, * cred_pub_key, cert_x[256], cert_y[256], pubkey_export[1024];\n  char * challenge_hash = NULL, * message = NULL;\n  const char * rpid = NULL;\n  size_t client_data_len = 0, challenge_b64_len = 0, att_obj_len = 0, rpid_hash_len = 32, fmt_len = 0, credential_id_len = 0, credential_id_b64_len, cbor_auth_data_len, cred_pub_key_len, cert_x_len = 0, cert_y_len = 0, pubkey_export_len = 1024, index = 0, cbor_bs_handle_len, rpid_len;\n  uint32_t counter = 0;\n  int ret = G_OK, res, status, has_x = 0, has_y = 0, key_type_valid = 0, key_alg_valid = 0;\n  unsigned int i;\n  struct cbor_load_result cbor_result;\n  cbor_item_t * item = NULL, * key = NULL, * auth_data = NULL, * att_stmt = NULL, * cbor_cose = NULL, * cbor_key, * cbor_value;\n  gnutls_pubkey_t g_key = NULL;\n  gnutls_datum_t g_x, g_y;\n  gnutls_ecc_curve_t curve = GNUTLS_ECC_CURVE_INVALID;\n\n  if (j_scheme_data != NULL) {\n    j_error = json_array();\n    if (j_error != NULL) {\n      do {\n        if (!json_string_length(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"rawId\"))) {\n          json_array_append_new(j_error, json_string(\"rawId mandatory\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if (!json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"clientDataJSON\"))) {\n          json_array_append_new(j_error, json_string(\"clientDataJSON mandatory\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if ((client_data = o_malloc(json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"clientDataJSON\"))+1)) == NULL) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error allocating resources for client_data\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_MEMORY;\n          break;\n        }\n        if (!o_base64_decode((const unsigned char *)json_string_value(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"clientDataJSON\")), json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"clientDataJSON\")), client_data, &client_data_len)) {\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error o_base64_decode client_data\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        client_data[client_data_len] = '\\0';\n        j_client_data = json_loads((const char *)client_data, JSON_DECODE_ANY, NULL);\n        if (j_client_data == NULL) {\n          json_array_append_new(j_error, json_string(\"Error parsing JSON client data\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        \/\/ Step 3\n        if (0 != o_strcmp(json_string_value(json_object_get(j_client_data, \"type\")), \"webauthn.create\")) {\n          json_array_append_new(j_error, json_string(\"clientDataJSON.type invalid\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        \/\/ Step 4\n        if (!json_string_length(json_object_get(j_client_data, \"challenge\"))) {\n          json_array_append_new(j_error, json_string(\"clientDataJSON.challenge mandatory\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if ((challenge_b64 = o_malloc(json_string_length(json_object_get(j_client_data, \"challenge\"))+3)) == NULL) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error allocating resources for challenge_b64\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_MEMORY;\n          break;\n        }\n        if (!o_base64url_2_base64((unsigned char *)json_string_value(json_object_get(j_client_data, \"challenge\")), json_string_length(json_object_get(j_client_data, \"challenge\")), challenge_b64, &challenge_b64_len)) {\n          json_array_append_new(j_error, json_string(\"clientDataJSON.challenge invalid format\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        challenge_b64[challenge_b64_len] = '\\0';\n        if ((challenge_hash = generate_hash(config->hash_algorithm, (const char *)challenge_b64)) == NULL) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error generate_hash for challenge_b64\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR;\n          break;\n        }\n        if (0 != o_strcmp(challenge_hash, json_string_value(json_object_get(j_credential, \"challenge_hash\")))) {\n          json_array_append_new(j_error, json_string(\"clientDataJSON.challenge invalid\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        \/\/ Step 5\n        if (!json_string_length(json_object_get(j_client_data, \"origin\"))) {\n          json_array_append_new(j_error, json_string(\"clientDataJSON.origin mandatory\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if (0 != o_strcmp(json_string_value(json_object_get(j_params, \"rp-origin\")), json_string_value(json_object_get(j_client_data, \"origin\")))) {\n          message = msprintf(\"clientDataJSON.origin invalid - Client send %s, required %s\", json_string_value(json_object_get(j_client_data, \"origin\")), json_string_value(json_object_get(j_params, \"rp-origin\")));\n          json_array_append_new(j_error, json_string(message));\n          o_free(message);\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        \/\/ Step 6 ??\n\n        if (!json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"attestationObject\"))) {\n          json_array_append_new(j_error, json_string(\"attestationObject required\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        if ((att_obj = o_malloc(json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"attestationObject\")))) == NULL) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error allocating resources for o_malloc\");\n          ret = G_ERROR_MEMORY;\n          break;\n        }\n        if (!o_base64_decode((unsigned char *)json_string_value(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"attestationObject\")), json_string_length(json_object_get(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"response\"), \"attestationObject\")), att_obj, &att_obj_len)) {\n          json_array_append_new(j_error, json_string(\"attestationObject invalid base64\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Step 7\n        item = cbor_load(att_obj, att_obj_len, &cbor_result);\n        if (cbor_result.error.code != CBOR_ERR_NONE) {\n          json_array_append_new(j_error, json_string(\"attestationObject invalid cbor\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if (!cbor_isa_map(item)) {\n          json_array_append_new(j_error, json_string(\"attestationObject invalid cbor item\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Check attestation object\n        if (cbor_map_size(item) != 3) {\n          json_array_append_new(j_error, json_string(\"attestationObject invalid cbor item\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        for (i=0; i<3; i++) {\n          key = cbor_map_handle(item)[i].key;\n          if (cbor_isa_string(key)) {\n            if (0 == o_strncmp((const char *)cbor_string_handle(key), \"fmt\", MIN(o_strlen(\"fmt\"), cbor_string_length(key)))) {\n              if (!cbor_isa_string(cbor_map_handle(item)[i].value)) {\n                json_array_append_new(j_error, json_string(\"CBOR map value 'fmt' isnt't a string\"));\n                ret = G_ERROR_PARAM;\n                break;\n              } else {\n                fmt_len = cbor_string_length(cbor_map_handle(item)[i].value);\n                fmt = cbor_string_handle(cbor_map_handle(item)[i].value);\n              }\n            } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"attStmt\", MIN(o_strlen(\"attStmt\"), cbor_string_length(key)))) {\n              att_stmt = cbor_map_handle(item)[i].value;\n            } else if (0 == o_strncmp((const char *)cbor_string_handle(key), \"authData\", MIN(o_strlen(\"authData\"), cbor_string_length(key)))) {\n              auth_data = cbor_map_handle(item)[i].value;\n              if (!cbor_isa_bytestring(auth_data) || cbor_bytestring_length(auth_data) < 56 || cbor_bytestring_is_indefinite(auth_data)) {\n                json_array_append_new(j_error, json_string(\"CBOR map value 'authData' is invalid\"));\n                ret = G_ERROR_PARAM;\n                break;\n              }\n            } else {\n              message = msprintf(\"CBOR map element %d is not an expected item\", i);\n              json_array_append_new(j_error, json_string(message));\n              o_free(message);\n              ret = G_ERROR_PARAM;\n              break;\n            }\n          }\n        }\n\n        \/\/ Step 9\n        if (auth_data == NULL) {\n          json_array_append_new(j_error, json_string(\"authData invalid\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        cbor_bs_handle = cbor_bytestring_handle(auth_data);\n        cbor_bs_handle_len = cbor_bytestring_length(auth_data);\n        if (o_strstr(json_string_value(json_object_get(j_params, \"rp-origin\")), \":\/\/\") == NULL) {\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - rp-origin invalid\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        if (o_strstr(json_string_value(json_object_get(j_params, \"rp-origin\")), \":\/\/\") != NULL) {\n          rpid = o_strstr(json_string_value(json_object_get(j_params, \"rp-origin\")), \":\/\/\")+3;\n        } else {\n          rpid = json_string_value(json_object_get(j_params, \"rp-origin\"));\n        }\n        if (o_strchr(rpid, ':') != NULL) {\n          rpid_len = o_strchr(rpid, ':') - rpid;\n        } else {\n          rpid_len = o_strlen(rpid);\n        }\n\n        if (!generate_digest_raw(digest_SHA256, (unsigned char *)rpid, rpid_len, rpid_hash, &rpid_hash_len)) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error generate_digest_raw\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        if (0 != memcmp(cbor_bs_handle, rpid_hash, rpid_hash_len)) {\n          json_array_append_new(j_error, json_string(\"authData.rpIdHash invalid\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Step 10\n        if (!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_USER_PRESENT)) {\n          json_array_append_new(j_error, json_string(\"authData.userPresent not set\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if (!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_AT)) {\n          json_array_append_new(j_error, json_string(\"authData.Attested credential data not set\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Step 11 ignored for now\n        \/\/y_log_message(Y_LOG_LEVEL_DEBUG, \"authData.userVerified: %d\", !!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_USER_VERIFY));\n\n        \/\/ Step 12 ignored for now (no extension)\n        \/\/y_log_message(Y_LOG_LEVEL_DEBUG, \"authData.Extension: %d\", !!(cbor_bs_handle[FLAGS_OFFSET] & FLAG_ED));\n\n        credential_id_len = cbor_bs_handle[CRED_ID_L_OFFSET+1] | (cbor_bs_handle[CRED_ID_L_OFFSET] << 8);\n        if (cbor_bs_handle_len < CRED_ID_L_OFFSET+2+credential_id_len) {\n          json_array_append_new(j_error, json_string(\"auth_data invalid size\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        credential_id_b64 = o_malloc(credential_id_len*2);\n        if (credential_id_b64 == NULL) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error o_malloc for credential_id_b64\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        if (!o_base64_encode(cbor_bs_handle+CRED_ID_L_OFFSET+2, credential_id_len, credential_id_b64, &credential_id_b64_len)) {\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error o_base64_encode for credential_id_b64\");\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Compare credential_id_b64 with rawId\n        if (memcmp(credential_id_b64, json_string_value(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"rawId\")), MIN(json_string_length(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"rawId\")), credential_id_b64_len))) {\n          json_array_append_new(j_error, json_string(\"Invalid rawId\"));\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Extract public key from auth_data COSE structure\n\n        \/\/ Extract credential ID\n        cbor_auth_data_len = cbor_bytestring_length(auth_data);\n        cbor_auth_data = cbor_bytestring_handle(auth_data);\n\n        cred_pub_key = cbor_auth_data+CREDENTIAL_ID_OFFSET+credential_id_len;\n        cred_pub_key_len = cbor_auth_data_len-CREDENTIAL_ID_OFFSET-credential_id_len;\n        cbor_cose = cbor_load(cred_pub_key, cred_pub_key_len, &cbor_result);\n        if (cbor_result.error.code != CBOR_ERR_NONE) {\n          json_array_append_new(j_error, json_string(\"Invalid COSE key\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error cbor_load cbor_cose\");\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        if (!cbor_isa_map(cbor_cose)) {\n          json_array_append_new(j_error, json_string(\"Invalid COSE key\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error cbor_cose not a map\");\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        for (i=0; i<cbor_map_size(cbor_cose); i++) {\n          cbor_key = cbor_map_handle(cbor_cose)[i].key;\n          cbor_value = cbor_map_handle(cbor_cose)[i].value;\n          if (cbor_isa_negint(cbor_key) && cbor_get_int(cbor_key) == 1 && cbor_isa_bytestring(cbor_value)) {\n            has_x = 1;\n            memcpy(cert_x, cbor_bytestring_handle(cbor_value), cbor_bytestring_length(cbor_value));\n            cert_x_len = cbor_bytestring_length(cbor_value);\n            g_x.data = cert_x;\n            g_x.size = cbor_bytestring_length(cbor_value);\n          } else if (cbor_isa_negint(cbor_key) && cbor_get_int(cbor_key) == 2 && cbor_isa_bytestring(cbor_value)) {\n            has_y = 1;\n            memcpy(cert_y, cbor_bytestring_handle(cbor_value), cbor_bytestring_length(cbor_value));\n            cert_y_len = cbor_bytestring_length(cbor_value);\n            g_y.data = cert_y;\n            g_y.size = cbor_bytestring_length(cbor_value);\n          } else if (cbor_isa_uint(cbor_key) && cbor_get_int(cbor_key) == 1 && cbor_isa_uint(cbor_value) && cbor_get_int(cbor_value) == 2) {\n            key_type_valid = 1;\n          } else if (cbor_isa_uint(cbor_key) && cbor_get_int(cbor_key) == 3 && cbor_isa_negint(cbor_value)) {\n            if (cbor_get_int(cbor_value) == 6 || cbor_get_int(cbor_value) == 34 || cbor_get_int(cbor_value) == 35) {\n              json_array_foreach(json_object_get(j_params, \"pubKey-cred-params\"), index, j_element) {\n                if (cbor_get_int(cbor_value) == 6 && json_integer_value(json_object_get(j_element, \"alg\")) == ECDSA256) {\n                  key_alg_valid = 1;\n                  curve = GNUTLS_ECC_CURVE_SECP256R1;\n                } else if (cbor_get_int(cbor_value) == 34 && json_integer_value(json_object_get(j_element, \"alg\")) == ECDSA384) {\n                  key_alg_valid = 1;\n                  curve = GNUTLS_ECC_CURVE_SECP384R1;\n                } else if (cbor_get_int(cbor_value) == 35 && json_integer_value(json_object_get(j_element, \"alg\")) == ECDSA512) {\n                  key_alg_valid = 1;\n                  curve = GNUTLS_ECC_CURVE_SECP521R1;\n                }\n              }\n            }\n          }\n        }\n\n        if (!has_x || !has_y || !key_type_valid || !key_alg_valid) {\n          json_array_append_new(j_error, json_string(\"Invalid COSE key\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error invalid COSE key has_x %d && has_y %d && key_type_valid %d && key_alg_valid %d\", has_x, has_y, key_type_valid, key_alg_valid);\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        if (gnutls_pubkey_init(&g_key)) {\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error gnutls_pubkey_init\");\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if (gnutls_pubkey_import_ecc_raw(g_key, curve, &g_x, &g_y) < 0) {\n          json_array_append_new(j_error, json_string(\"Internal error\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - error gnutls_pubkey_import_ecc_raw\");\n          ret = G_ERROR_PARAM;\n          break;\n        }\n        if ((ret = gnutls_pubkey_export(g_key, GNUTLS_X509_FMT_PEM, pubkey_export, &pubkey_export_len)) < 0) {\n          json_array_append_new(j_error, json_string(\"Error exporting pubkey\"));\n          y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - Error gnutls_pubkey_export: %d\", ret);\n          ret = G_ERROR_PARAM;\n          break;\n        }\n\n        \/\/ Steps 13-14\n        if (0 == o_strncmp(\"packed\", (char *)fmt, MIN(fmt_len, o_strlen(\"packed\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"packed\") == json_true())) {\n          j_result = check_attestation_packed(j_params, auth_data, att_stmt, client_data, g_key);\n          if (check_result_value(j_result, G_ERROR_PARAM)) {\n            json_array_extend(j_error, json_object_get(j_result, \"error\"));\n            ret = G_ERROR_PARAM;\n          } else if (!check_result_value(j_result, G_OK)) {\n            ret = G_ERROR_PARAM;\n            y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error check_attestation_packed\");\n            json_array_append_new(j_error, json_string(\"internal error\"));\n          } else {\n            j_cert = json_incref(json_object_get(json_object_get(j_result, \"data\"), \"certificate\"));\n          }\n          json_decref(j_result);\n        } else if (0 == o_strncmp(\"tpm\", (char *)fmt, MIN(fmt_len, o_strlen(\"tpm\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"tpm\") == json_true())) {\n          json_array_append_new(j_error, json_string(\"Format 'tpm' not supported yet\"));\n          ret = G_ERROR_PARAM;\n        } else if (0 == o_strncmp(\"android-key\", (char *)fmt, MIN(fmt_len, o_strlen(\"android-key\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"android-key\") == json_true())) {\n          json_array_append_new(j_error, json_string(\"Format 'android-key' not supported yet\"));\n          ret = G_ERROR_PARAM;\n        } else if (0 == o_strncmp(\"android-safetynet\", (char *)fmt, MIN(fmt_len, o_strlen(\"android-safetynet\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"android-safetynet\") == json_true())) {\n          j_result = check_attestation_android_safetynet(j_params, auth_data, att_stmt, client_data);\n          if (check_result_value(j_result, G_ERROR_PARAM)) {\n            json_array_extend(j_error, json_object_get(j_result, \"error\"));\n            ret = G_ERROR_PARAM;\n          } else if (!check_result_value(j_result, G_OK)) {\n            ret = G_ERROR_PARAM;\n            y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error check_attestation_android_safetynet\");\n            json_array_append_new(j_error, json_string(\"internal error\"));\n          } else {\n            j_cert = json_incref(json_object_get(json_object_get(j_result, \"data\"), \"certificate\"));\n          }\n          json_decref(j_result);\n        } else if (0 == o_strncmp(\"fido-u2f\", (char *)fmt, MIN(fmt_len, o_strlen(\"fido-u2f\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"fido-u2f\") == json_true())) {\n          j_result = check_attestation_fido_u2f(j_params, (cbor_auth_data+CREDENTIAL_ID_OFFSET), credential_id_len, cert_x, cert_x_len, cert_y, cert_y_len, att_stmt, rpid_hash, rpid_hash_len, client_data);\n          if (check_result_value(j_result, G_ERROR_PARAM)) {\n            json_array_extend(j_error, json_object_get(j_result, \"error\"));\n            ret = G_ERROR_PARAM;\n          } else if (!check_result_value(j_result, G_OK)) {\n            ret = G_ERROR_PARAM;\n            y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error check_attestation_fido_u2f\");\n            json_array_append_new(j_error, json_string(\"internal error\"));\n          } else {\n            j_cert = json_incref(json_object_get(json_object_get(j_result, \"data\"), \"certificate\"));\n          }\n          json_decref(j_result);\n        } else if (0 == o_strncmp(\"apple\", (char *)fmt, MIN(fmt_len, o_strlen(\"apple\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"apple\") == json_true() || json_object_get(j_params, \"force-fmt-apple\") == json_true())) {\n          j_result = check_attestation_apple(j_params, auth_data, att_stmt, client_data, g_key);\n          if (check_result_value(j_result, G_ERROR_PARAM)) {\n            json_array_extend(j_error, json_object_get(j_result, \"error\"));\n            ret = G_ERROR_PARAM;\n          } else if (!check_result_value(j_result, G_OK)) {\n            ret = G_ERROR_PARAM;\n            y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error check_attestation_apple\");\n            json_array_append_new(j_error, json_string(\"internal error\"));\n          } else {\n            j_cert = json_incref(json_object_get(json_object_get(j_result, \"data\"), \"certificate\"));\n          }\n          json_decref(j_result);\n        } else if (0 == o_strncmp(\"none\", (char *)fmt, MIN(fmt_len, o_strlen(\"none\"))) && (json_object_get(json_object_get(j_params, \"fmt\"), \"none\") == json_true() || json_object_get(j_params, \"force-fmt-none\") == json_true())) {\n          if (att_stmt != NULL && cbor_isa_map(att_stmt) && cbor_map_is_definite(att_stmt) && !cbor_map_size(att_stmt)) {\n            j_cert = json_string(\"\");\n          } else {\n            y_log_message(Y_LOG_LEVEL_DEBUG, \"register_new_attestation - response type 'none' has invalid format\");\n            json_array_append_new(j_error, json_string(\"response invalid\"));\n            ret = G_ERROR_PARAM;\n          }\n        } else {\n          message = msprintf(\"Format '%.*s' is not supported by Glewlwyd WebAuthn scheme\", fmt_len, fmt);\n          json_array_append_new(j_error, json_string(message));\n          o_free(message);\n          ret = G_ERROR_PARAM;\n        }\n      } while (0); \/\/ This is not a loop, but a structure where you can easily cancel the rest of the process with breaks\n\n      if (ret != G_OK) {\n        if (json_array_size(j_error)) {\n          j_return = json_pack(\"{sisO}\", \"result\", ret, \"error\", j_error);\n        } else {\n          j_return = json_pack(\"{si}\", \"result\", ret);\n        }\n      } else {\n        if ((res = check_certificate(config, j_params, json_string_value(json_object_get(json_object_get(j_scheme_data, \"credential\"), \"rawId\")), json_integer_value(json_object_get(j_credential, \"gswu_id\")))) == G_OK) {\n          j_return = json_pack(\"{sis[s]}\", \"result\", G_ERROR_PARAM, \"error\", \"Credential already registered\");\n          status = 2;\n        } else if (res == G_ERROR_UNAUTHORIZED) {\n          j_return = json_pack(\"{sis[s]}\", \"result\", G_ERROR_PARAM, \"error\", \"Credential unauthorized\");\n          status = 2;\n        } else if (res != G_ERROR_NOT_FOUND) {\n          j_return = json_pack(\"{sis[s]}\", \"result\", G_ERROR_PARAM, \"error\", \"Internal error\");\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error check_certificate\");\n          status = 2;\n        } else {\n          j_return = json_pack(\"{si}\", \"result\", G_OK);\n          status = 1;\n        }\n        counter = cbor_bs_handle[COUNTER_OFFSET+3] | (cbor_bs_handle[COUNTER_OFFSET+2] << 8) | (cbor_bs_handle[COUNTER_OFFSET+1] << 16) | (cbor_bs_handle[COUNTER_OFFSET] << 24);\n        \/\/ Store credential in the database\n        j_query = json_pack(\"{sss{siss%sOss%sOsi}s{sO}}\",\n                            \"table\",\n                            G_TABLE_WEBAUTHN_CREDENTIAL,\n                            \"set\",\n                              \"gswc_status\",\n                              status,\n                              \"gswc_name\",\n                              fmt,\n                              fmt_len,\n                              \"gswc_credential_id\",\n                              json_object_get(json_object_get(j_scheme_data, \"credential\"), \"rawId\"),\n                              \"gswc_public_key\",\n                              pubkey_export,\n                              pubkey_export_len,\n                              \"gswc_certificate\",\n                              j_cert,\n                              \"gswc_counter\",\n                              counter,\n                            \"where\",\n                              \"gswc_id\",\n                              json_object_get(j_credential, \"gswc_id\"));\n        res = h_update(config->conn, j_query, NULL);\n        json_decref(j_query);\n        if (res != H_OK) {\n          y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error h_update\");\n        }\n      }\n      json_decref(j_error);\n      json_decref(j_client_data);\n      json_decref(j_pubkey);\n      json_decref(j_cert);\n      o_free(client_data);\n      o_free(challenge_b64);\n      o_free(challenge_hash);\n      o_free(att_obj);\n      o_free(credential_id_b64);\n      gnutls_pubkey_deinit(g_key);\n      if (item != NULL) {\n        cbor_decref(&item);\n      }\n      if (cbor_cose != NULL) {\n        cbor_decref(&cbor_cose);\n      }\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"register_new_attestation - Error allocating resources for j_error\");\n      j_return = json_pack(\"{si}\", \"result\", G_ERROR);\n    }\n  } else {\n    j_return = json_pack(\"{sis[s]}\", \"result\", G_ERROR_PARAM, \"error\", \"scheme_data mandatory\");\n  }\n  return j_return;\n}","target":0,"code_token_length":6526,"total_token_length":6762,"max_tokens_setting":8192}
+{"idx":295887,"func":"mp_sint32 LoaderXM::load(XMFileBase& f, XModule* module)\n{\n\tmp_ubyte insData[230];\t\t\n\tmp_sint32 smpReloc[MP_MAXINSSAMPS];\n\tmp_ubyte nbu[MP_MAXINSSAMPS];\n\tmp_uint32 fileSize = 0;\n\t\t\t\n\tmodule->cleanUp();\n\n\t\/\/ this will make code much easier to read\n\tTXMHeader*\t\theader = &module->header;\n\tTXMInstrument*\tinstr  = module->instr;\n\tTXMSample*\t\tsmp\t   = module->smp;\n\tTXMPattern*\t\tphead  = module->phead;\t\n\n\t\/\/ we're already out of memory here\n\tif (!phead || !instr || !smp)\n\t\treturn MP_OUT_OF_MEMORY;\n\t\n\tfileSize = f.sizeWithBaseOffset();\n\t\n\tf.read(&header->sig,1,17);\n\tf.read(&header->name,1,20);\n\tf.read(&header->whythis1a,1,1);\n\theader->whythis1a=0;\n\tf.read(&header->tracker,1,20);\n\tf.readWords(&header->ver,1);\n\t\n\tif (header->ver != 0x102 && \n\t\theader->ver != 0x103 && \/\/ untested\n\t\theader->ver != 0x104)\n\t\treturn MP_LOADER_FAILED;\n\t\n\tf.readDwords(&header->hdrsize,1);\n\t\n\theader->hdrsize-=4;\n\t\n\tmp_uint32 hdrSize = 0x110;\n\tif (header->hdrsize > hdrSize)\n\t\thdrSize = header->hdrsize;\n\t\t\t\t\n\tmp_ubyte* hdrBuff = new mp_ubyte[hdrSize];\n\tmemset(hdrBuff, 0, hdrSize);\n\t\n\tf.read(hdrBuff, 1, header->hdrsize);\n\t\n\theader->ordnum = LittleEndian::GET_WORD(hdrBuff);\n\theader->restart = LittleEndian::GET_WORD(hdrBuff+2);\n\theader->channum = LittleEndian::GET_WORD(hdrBuff+4);\n\theader->patnum = LittleEndian::GET_WORD(hdrBuff+6);\n\theader->insnum = LittleEndian::GET_WORD(hdrBuff+8);\n\theader->freqtab = LittleEndian::GET_WORD(hdrBuff+10);\n\theader->tempo = LittleEndian::GET_WORD(hdrBuff+12);\n\theader->speed = LittleEndian::GET_WORD(hdrBuff+14);\n\tmemcpy(header->ord, hdrBuff+16, 256);\n\tif(header->ordnum > MP_MAXORDERS)\n\t\theader->ordnum = MP_MAXORDERS;\n\tif(header->insnum > MP_MAXINS)\n\t\treturn MP_LOADER_FAILED;\n\n\tdelete[] hdrBuff;\n\t\n\theader->mainvol=255;\n\theader->flags = XModule::MODULE_XMNOTECLIPPING | \n\t\tXModule::MODULE_XMARPEGGIO | \n\t\tXModule::MODULE_XMPORTANOTEBUFFER | \n\t\tXModule::MODULE_XMVOLCOLUMNVIBRATO;\n\n\theader->uppernotebound = 119;\n\t\n\tmp_sint32 i,y,sc;\n\tfor (i=0;i<32;i++) header->pan[i]=0x80;\n\t\n\t\/\/ old version?\n\tif (header->ver == 0x102 || header->ver == 0x103)\n\t{\n\t\tmp_sint32 s = 0;\n\t\tmp_sint32 e = 0;\n\t\tfor (y=0;y<header->insnum;y++) {\n\t\t\t\n\t\t\tf.readDwords(&instr[y].size,1);\n\t\t\tf.read(&instr[y].name,1,22);\t\t\n\t\t\tf.read(&instr[y].type,1,1);\n\t\t\tmp_uword numSamples = 0;\n\t\t\tf.readWords(&numSamples,1);\n\t\t\tif(numSamples > MP_MAXINSSAMPS)\n\t\t\t\treturn MP_LOADER_FAILED;\n\t\t\tinstr[y].samp = numSamples;\n\n\t\t\tif (instr[y].size == 29)\n\t\t\t{\n#ifdef MILKYTRACKER\n\t\t\t\ts+=16;\n#endif\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tf.readDwords(&instr[y].shsize,1);\n\n\t\t\tmemset(insData, 0, 230);\n\t\t\t\n\t\t\tif (instr[y].size - 33 > 230)\n\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\n\t\t\tf.read(insData, 1, instr[y].size - 33);\n\t\t\t\t\t\t\n\t\t\tif (instr[y].samp) {\n\t\t\t\tmp_ubyte* insDataPtr = insData;\n\t\t\t\t\n\t\t\t\tmemcpy(nbu, insDataPtr, MP_MAXINSSAMPS);\n\t\t\t\tinsDataPtr+=MP_MAXINSSAMPS;\n\t\t\t\t\n\t\t\t\tTEnvelope venv;\n\t\t\t\tTEnvelope penv;\n\t\t\t\tmemset(&venv,0,sizeof(venv));\n\t\t\t\tmemset(&penv,0,sizeof(penv));\n\t\t\t\t\n\t\t\t\tmp_sint32 k;\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tvenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tvenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tpenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tpenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvenv.num = *insDataPtr++;\t\n\t\t\t\tif (venv.num > XM_ENVELOPENUMPOINTS) venv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tpenv.num = *insDataPtr++;\t\n\t\t\t\tif (penv.num > XM_ENVELOPENUMPOINTS) penv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tvenv.sustain = *insDataPtr++;\n\t\t\t\tvenv.loops = *insDataPtr++;\n\t\t\t\tvenv.loope = *insDataPtr++;\n\t\t\t\tpenv.sustain = *insDataPtr++;\n\t\t\t\tpenv.loops = *insDataPtr++;\n\t\t\t\tpenv.loope = *insDataPtr++;\n\t\t\t\tvenv.type = *insDataPtr++;\n\t\t\t\tpenv.type = *insDataPtr++;\t\t\t\t\n\t\t\t\t\n\t\t\t\tmp_ubyte vibtype, vibsweep, vibdepth, vibrate;\n\t\t\t\tmp_uword volfade;\n\t\t\t\t\n\t\t\t\tvibtype = *insDataPtr++;\n\t\t\t\tvibsweep = *insDataPtr++;\n\t\t\t\tvibdepth = *insDataPtr++;\n\t\t\t\tvibrate = *insDataPtr++;\n\t\t\t\t\n\t\t\t\tvibdepth<<=1;\n\t\t\t\t\n\t\t\t\tvolfade = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\tvolfade<<=1;\n\t\t\t\t\n\t\t\t\t\/\/instr[y].res = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\t\n\t\t\t\tfor (mp_sint32 l=0;l<XM_ENVELOPENUMPOINTS;l++) {\n\t\t\t\t\tvenv.env[l][1]<<=2;\n\t\t\t\t\tpenv.env[l][1]<<=2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!module->addVolumeEnvelope(venv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\tif (!module->addPanningEnvelope(penv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t\n\t\t\t\tmp_sint32 g=0, sc;\n\t\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].flags=3;\n\t\t\t\t\tsmp[g+s].venvnum=e+1;\n\t\t\t\t\tsmp[g+s].penvnum=e+1;\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].vibtype=vibtype;\n\t\t\t\t\tsmp[g+s].vibsweep=vibsweep;\n\t\t\t\t\tsmp[g+s].vibdepth=vibdepth;\n\t\t\t\t\tsmp[g+s].vibrate=vibrate;\n\t\t\t\t\tsmp[g+s].volfade=volfade;\n\t\t\t\t\t\n\t\t\t\t\t\/\/ not sure why I did that, actually doesn't make sense\n\t\t\t\t\t\/\/if (!(venv.type&1)) smp[g+s].volfade=0;\n\t\t\t\t\t\n\t\t\t\t\tf.readDwords(&smp[g+s].samplen,1);\n\t\t\t\t\tf.readDwords(&smp[g+s].loopstart,1);\n\t\t\t\t\tf.readDwords(&smp[g+s].looplen,1);\n\t\t\t\t\tsmp[g+s].vol=XModule::vol64to255(f.readByte());\n\t\t\t\t\t\/\/f.read(&smp[g+s].vol,1,1);\n\t\t\t\t\tf.read(&smp[g+s].finetune,1,1);\n\t\t\t\t\tf.read(&smp[g+s].type,1,1);\n#ifdef VERBOSE\n\t\t\t\t\tprintf(\"Before: %i, After: %i\\n\", smp[g+s].type, smp[g+s].type & (3+16));\n#endif\n\t\t\t\t\tf.read(&smp[g+s].pan,1,1);\n\t\t\t\t\tf.read(&smp[g+s].relnote,1,1);\n\t\t\t\t\tf.read(&smp[g+s].res,1,1);\n\t\t\t\t\tf.read(&smp[g+s].name,1,22);\n\t\t\t\t\t\n\t\t\t\t\tchar line[30];\n\t\t\t\t\tmemset(line, 0, sizeof(line));\n\t\t\t\t\tXModule::convertStr(line, smp[g+s].name, 23, false);\t\t\t\t\t\n\t\t\t\t\tif (line[0])\n\t\t\t\t\t\tmodule->addSongMessageLine(line);\n\t\t\t\t\t\n\t\t\t\t\t\/\/ ignore empty samples\n#ifndef MILKYTRACKER\n\t\t\t\t\t\/\/ ignore empty samples when not being a tracker\n\t\t\t\t\tif (smp[g+s].samplen) {\n\t\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\t\tg++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsmpReloc[sc] = -1;\n#else\n\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\tg++;\n#endif\n\t\t\t\t}\n\n\t\t\t\tinstr[y].samp = g;\n\n\t\t\t\tfor (sc = 0; sc < MP_MAXINSSAMPS; sc++) {\n\t\t\t\t\tif (smpReloc[nbu[sc]] == -1)\n\t\t\t\t\t\tinstr[y].snum[sc] = -1;\n\t\t\t\t\telse\n\t\t\t\t\t\tinstr[y].snum[sc] = smpReloc[nbu[sc]]+s;\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\te++;\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t}\n\n#ifdef MILKYTRACKER\n\t\t\ts+=16;\n#else\n\t\t\ts+=instr[y].samp;\n#endif\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\theader->smpnum=s;\n\t\theader->volenvnum=e;\n\t\theader->panenvnum=e;\n\t}\n\t\n\tfor (y=0;y<header->patnum;y++) {\n\t\t\n\t\tif (header->ver == 0x104 || header->ver == 0x103)\n\t\t{\n\t\t\tf.readDwords(&phead[y].len,1);\n\t\t\tf.read(&phead[y].ptype,1,1);\n\t\t\tf.readWords(&phead[y].rows,1);\n\t\t\tf.readWords(&phead[y].patdata,1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tf.readDwords(&phead[y].len,1);\n\t\t\tf.read(&phead[y].ptype,1,1);\n\t\t\tphead[y].rows = (mp_uword)f.readByte()+1;\n\t\t\tf.readWords(&phead[y].patdata,1);\t\t\t\n\t\t}\n\t\t\n\t\tphead[y].effnum=2;\n\t\tphead[y].channum=(mp_ubyte)header->channum;\n\t\t\n\t\tphead[y].patternData = new mp_ubyte[phead[y].rows*header->channum*6];\n\t\t\n\t\t\/\/ out of memory?\n\t\tif (phead[y].patternData == NULL)\n\t\t{\n\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t}\n\t\t\n\t\tmemset(phead[y].patternData,0,phead[y].rows*header->channum*6);\n\t\t\n\t\tif (phead[y].patdata) {\n\t\t\tmp_ubyte *buffer = new mp_ubyte[phead[y].patdata];\n\t\t\t\n\t\t\t\/\/ out of memory?\n\t\t\tif (buffer == NULL)\n\t\t\t{\n\t\t\t\treturn MP_OUT_OF_MEMORY;\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\tf.read(buffer,1,phead[y].patdata);\n\t\t\t\n\t\t\t\/\/printf(\"%i\\n\", phead[y].patdata);\n\t\t\t\n\t\t\tmp_sint32 pc = 0, bc = 0;\n\t\t\tfor (mp_sint32 r=0;r<phead[y].rows;r++) {\n\t\t\t\tfor (mp_sint32 c=0;c<header->channum;c++) {\n\t\t\t\t\t\n\t\t\t\t\tmp_ubyte slot[5];\n\t\t\t\t\tmemset(slot,0,5);\n\t\t\t\t\t\n\t\t\t\t\tif ((buffer[pc]&128)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tmp_ubyte pb = buffer[pc];\n\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif ((pb&1)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc]=buffer[pc];\n\t\t\t\t\t\t\tslot[0]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&2)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+1]=buffer[pc];\n\t\t\t\t\t\t\tslot[1]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&4)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+2]=buffer[pc];\n\t\t\t\t\t\t\tslot[2]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&8)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+3]=buffer[pc];\n\t\t\t\t\t\t\tslot[3]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&16)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+4]=buffer[pc];\n\t\t\t\t\t\t\tslot[4]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t\/\/memcpy(phead[y].patternData+bc,buffer+pc,5);\n\t\t\t\t\t\tmemcpy(slot,buffer+pc,5);\n\t\t\t\t\t\tpc+=5;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tchar gl=0;\n\t\t\t\t\tfor (mp_sint32 i=0;i<XModule::numValidXMEffects;i++)\n\t\t\t\t\t\tif (slot[3]==XModule::validXMEffects[i]) gl=1;\n\t\t\t\t\t\n\t\t\t\t\tif (!gl) slot[3]=slot[4]=0;\n\t\t\t\t\t\n\t\t\t\t\tif ((slot[3]==0xC)||(slot[3]==0x10)) {\n\t\t\t\t\t\tslot[4] = XModule::vol64to255(slot[4]);\n\t\t\t\t\t\t\/*mp_sint32 bl = slot[4];\n\t\t\t\t\t\tif (bl>64) bl=64;\n\t\t\t\t\t\tslot[4]=(bl*261120)>>16;*\/\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif ((!slot[3])&&(slot[4])) slot[3]=0x20;\n\t\t\t\t\t\n\t\t\t\t\tif (slot[3]==0xE) {\n\t\t\t\t\t\tslot[3]=(slot[4]>>4)+0x30;\n\t\t\t\t\t\tslot[4]=slot[4]&0xf;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (slot[3]==0x21) {\n\t\t\t\t\t\tslot[3]=(slot[4]>>4)+0x40;\n\t\t\t\t\t\tslot[4]=slot[4]&0xf;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (slot[0]==97) slot[0]=XModule::NOTE_OFF;\n\t\t\t\t\t\n\t\t\t\t\tphead[y].patternData[bc]=slot[0];\n\t\t\t\t\tphead[y].patternData[bc+1]=slot[1];\n\t\t\t\t\t\n\t\t\t\t\tXModule::convertXMVolumeEffects(slot[2], phead[y].patternData[bc+2], phead[y].patternData[bc+3]);\n\n\t\t\t\t\tphead[y].patternData[bc+4]=slot[3];\n\t\t\t\t\tphead[y].patternData[bc+5]=slot[4];\n\t\t\t\t\t\n\t\t\t\t\t\/*if ((y==3)&&(c==2)) {\n\t\t\t\t\t\tfor (mp_sint32 bl=0;bl<6;bl++) cprintf(\"%x \",phead[y].patternData[bc+bl]);\n\t\t\t\t\tcprintf(\"\\r\\n\");\n\t\t\t\t\tgetch();\n\t\t\t\t\t};*\/\n\t\t\t\t\t\n\t\t\t\t\t\/*printf(\"Note : %i\\r\\n\",phead[y].patternData[bc]);\n\t\t\t\t\tprintf(\"Ins  : %i\\r\\n\",phead[y].patternData[bc+1]);\n\t\t\t\t\tprintf(\"Vol  : %i\\r\\n\",phead[y].patternData[bc+2]);\n\t\t\t\t\tprintf(\"Eff  : %i\\r\\n\",phead[y].patternData[bc+3]);\n\t\t\t\t\tprintf(\"Effop: %i\\r\\n\",phead[y].patternData[bc+4]);\n\t\t\t\t\tgetch();*\/\n\t\t\t\t\t\n\t\t\t\t\tbc+=6;\n\t\t\t\t} \/\/ for c\n\t\t\t\t\t\n\t\t\t} \/\/ for r\n\t\t\t\t\n\t\t\tdelete[] buffer;\n\t\t}\n\t\t\t\n\t}\n\t\t\n\tif (header->ver == 0x104)\n\t{\n\t\tmp_sint32 s = 0;\n\t\tmp_sint32 e = 0;\n\t\tfor (y=0;y<header->insnum;y++) {\n\n\t\t\t\/\/ fixes MOOH.XM loading problems\n\t\t\t\/\/ seems to store more instruments in the header than in the actual file\n\t\t\tif (f.posWithBaseOffset() >= fileSize)\n\t\t\t\tbreak;\n\t\t\n\t\t\t\/\/TXMInstrument* ins = &instr[y];\n\t\t\n\t\t\tf.readDwords(&instr[y].size,1);\n\t\t\t\n\t\t\tif (instr[y].size >= 4 && instr[y].size < 29)\n\t\t\t{\n\t\t\t\tmp_ubyte buffer[29];\n\t\t\t\tmemset(buffer, 0, sizeof(buffer));\n\t\t\t\tf.read(buffer, 1, instr[y].size - 4);\n\t\t\t\tmemcpy(instr[y].name, buffer, 22);\n\t\t\t\tinstr[y].type = buffer[22];\n\t\t\t\tinstr[y].samp = LittleEndian::GET_WORD(buffer + 23);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tf.read(&instr[y].name,1,22);\t\t\n\t\t\t\tf.read(&instr[y].type,1,1);\n\t\t\t\tf.readWords(&instr[y].samp,1);\n\t\t\t}\n\t\t\tif (instr[y].samp > MP_MAXINSSAMPS)\n\t\t\t\treturn MP_LOADER_FAILED;\n\n\t\t\t\/\/printf(\"%i, %i\\n\", instr[y].size, instr[y].samp);\n\n\t\t\tif (instr[y].size <= 29)\n\t\t\t{\n#ifdef MILKYTRACKER\n\t\t\t\ts+=16;\n#endif\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tf.readDwords(&instr[y].shsize,1);\n#ifdef VERBOSE\n\t\t\tprintf(\"%i\/%i: %i, %i, %i, %s\\n\",y,header->insnum-1,instr[y].size,instr[y].shsize,instr[y].samp,instr[y].name);\t\t\t\n#endif\n\t\t\tmemset(insData, 0, 230);\n\t\t\t\n\t\t\tif (instr[y].size - 33 > 230)\n\t\t\t{\n\t\t\t\t\/\/return -7;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tf.read(insData, 1, instr[y].size - 33);\n\t\t\t\n\t\t\t\/*printf(\"%i\\r\\n\",instr[y].size);\n\t\t\tprintf(\"%s\\r\\n\",instr[y].name);\n\t\t\tprintf(\"%i\\r\\n\",instr[y].type);\n\t\t\tprintf(\"%i\\r\\n\",instr[y].samp);\n\t\t\tprintf(\"%i\\r\\n\",instr[y].shsize);*\/\n\t\t\t\/\/getch();\n\t\t\t\t\t\n\t\t\tmemset(smpReloc, 0, sizeof(smpReloc));\n\t\t\t\n\t\t\tif (instr[y].samp) {\n\t\t\t\tmp_ubyte* insDataPtr = insData;\n\t\t\t\t\n\t\t\t\t\/\/f.read(&nbu,1,96);\n\t\t\t\t\n\t\t\t\tmemcpy(nbu, insDataPtr, MP_MAXINSSAMPS);\n\t\t\t\tinsDataPtr+=MP_MAXINSSAMPS;\n\t\t\t\t\n\t\t\t\tTEnvelope venv;\n\t\t\t\tTEnvelope penv;\n\t\t\t\tmemset(&venv,0,sizeof(venv));\n\t\t\t\tmemset(&penv,0,sizeof(penv));\n\t\t\t\t\n\t\t\t\tmp_sint32 k;\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tvenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tvenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tpenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tpenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvenv.num = *insDataPtr++;\t\n\t\t\t\tif (venv.num > XM_ENVELOPENUMPOINTS) venv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tpenv.num = *insDataPtr++;\t\t\t\t\t\n\t\t\t\tif (penv.num > XM_ENVELOPENUMPOINTS) penv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tvenv.sustain = *insDataPtr++;\n\t\t\t\tvenv.loops = *insDataPtr++;\n\t\t\t\tvenv.loope = *insDataPtr++;\n\t\t\t\tpenv.sustain = *insDataPtr++;\n\t\t\t\tpenv.loops = *insDataPtr++;\n\t\t\t\tpenv.loope = *insDataPtr++;\n\t\t\t\tvenv.type = *insDataPtr++;\n\t\t\t\tpenv.type = *insDataPtr++;\t\t\t\t\n\t\t\t\t\n\t\t\t\tmp_ubyte vibtype, vibsweep, vibdepth, vibrate;\n\t\t\t\tmp_uword volfade;\n\t\t\t\t\n\t\t\t\tvibtype = *insDataPtr++;\n\t\t\t\tvibsweep = *insDataPtr++;\n\t\t\t\tvibdepth = *insDataPtr++;\n\t\t\t\tvibrate = *insDataPtr++;\n\t\t\t\t\n\t\t\t\tvibdepth<<=1;\n\t\t\t\t\n\t\t\t\t\/\/f.readWords(&volfade,1);\n\t\t\t\tvolfade = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\tvolfade<<=1;\n\t\t\t\t\n\t\t\t\t\/\/instr[y].res = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\t\n\t\t\t\tfor (mp_sint32 l=0;l<XM_ENVELOPENUMPOINTS;l++) {\n\t\t\t\t\tvenv.env[l][1]<<=2;\n\t\t\t\t\tpenv.env[l][1]<<=2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!module->addVolumeEnvelope(venv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\tif (!module->addPanningEnvelope(penv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t\n\t\t\t\tmp_sint32 g=0, sc;\n\t\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\t\t\t\t\t\/\/TXMSample* smpl = &smp[g+s];\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].flags=3;\n\t\t\t\t\tsmp[g+s].venvnum=e+1;\n\t\t\t\t\tsmp[g+s].penvnum=e+1;\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].vibtype=vibtype;\n\t\t\t\t\tsmp[g+s].vibsweep=vibsweep;\n\t\t\t\t\tsmp[g+s].vibdepth=vibdepth;\n\t\t\t\t\tsmp[g+s].vibrate=vibrate;\n\t\t\t\t\tsmp[g+s].volfade=volfade;\n\t\t\t\t\t\n\t\t\t\t\t\/\/ not sure why I did that, actually doesn't make sense\n\t\t\t\t\t\/\/if (!(venv.type&1)) smp[g+s].volfade=0;\n\t\t\t\t\t\n\t\t\t\t\tf.readDwords(&smp[g+s].samplen,1);\n\t\t\t\t\t\n\t\t\t\t\tf.readDwords(&smp[g+s].loopstart,1);\n\t\t\t\t\tf.readDwords(&smp[g+s].looplen,1);\n\t\t\t\t\tsmp[g+s].vol=XModule::vol64to255(f.readByte());\n\t\t\t\t\t\/\/f.read(&smp[g+s].vol,1,1);\n\t\t\t\t\tf.read(&smp[g+s].finetune,1,1);\n\t\t\t\t\tf.read(&smp[g+s].type,1,1);\n#ifdef VERBOSE\n\t\t\t\t\tprintf(\"Before: %i, After: %i\\n\", smp[g+s].type, smp[g+s].type & (3+16));\n#endif\n\t\t\t\t\tf.read(&smp[g+s].pan,1,1);\n\t\t\t\t\tf.read(&smp[g+s].relnote,1,1);\n\t\t\t\t\tf.read(&smp[g+s].res,1,1);\n\t\t\t\t\tf.read(&smp[g+s].name,1,22);\n\n\t\t\t\t\tchar line[30];\n\t\t\t\t\tmemset(line, 0, sizeof(line));\n\t\t\t\t\tXModule::convertStr(line, smp[g+s].name, 23, false);\t\t\t\t\t\n\t\t\t\t\tif (line[0])\n\t\t\t\t\t\tmodule->addSongMessageLine(line);\n\t\t\t\t\t\n#ifndef MILKYTRACKER\n\t\t\t\t\t\/\/ ignore empty samples when not being a tracker\n\t\t\t\t\tif (smp[g+s].samplen) {\n\t\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\t\tg++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsmpReloc[sc] = -1;\n#else\n\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\tg++;\n#endif\n\t\t\t\t}\n\n\t\t\t\tinstr[y].samp = g;\n\n\t\t\t\tfor (sc = 0; sc < MP_MAXINSSAMPS; sc++) {\t\t\t\t\t\n\t\t\t\t\tif (smpReloc[nbu[sc]] == -1)\n\t\t\t\t\t\tinstr[y].snum[sc] = -1;\n\t\t\t\t\telse\n\t\t\t\t\t\tinstr[y].snum[sc] = smpReloc[nbu[sc]]+s;\n\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\t\t\t\t\n\t\t\t\t\tif (smp[s].samplen)\n\t\t\t\t\t{\n\t\t\t\t\t\tbool adpcm = (smp[s].res == 0xAD);\n\t\t\t\t\t\n\t\t\t\t\t\tmp_uint32 oldSize = smp[s].samplen;\n\t\t\t\t\t\tif (smp[s].type&16) \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tmp_sint32 result = module->loadModuleSample(f, s, \n\t\t\t\t\t\t\t\t\t\t\t\t\t adpcm ? XModule::ST_PACKING_ADPCM : XModule::ST_DELTA, \n\t\t\t\t\t\t\t\t\t\t\t\t\t adpcm ? (XModule::ST_PACKING_ADPCM | XModule::ST_16BIT) : (XModule::ST_DELTA | XModule::ST_16BIT), \n\t\t\t\t\t\t\t\t\t\t\t\t\t oldSize);\n\t\t\t\t\t\tif (result != MP_OK)\n\t\t\t\t\t\t\treturn result;\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (adpcm)\n\t\t\t\t\t\t\tsmp[s].res = 0;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\ts++;\n\t\t\t\t\t\n\t\t\t\t\tif (s>=MP_MAXSAMPLES)\n\t\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\te++;\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t}\n\n#ifdef MILKYTRACKER\n\t\t\ts+=16 - instr[y].samp;\n#endif\t\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\theader->smpnum=s;\n\t\theader->volenvnum=e;\n\t\theader->panenvnum=e;\t\t\n\t\t\n\t}\n\telse\n\t{\n\t\tmp_sint32 s = 0;\n\t\tfor (y=0;y<header->insnum;y++) {\n\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\n\t\t\t\tif (smp[s].samplen)\n\t\t\t\t{\n\t\t\t\t\tmp_uint32 oldSize = smp[s].samplen;\n\t\t\t\t\tif (smp[s].type&16) \n\t\t\t\t\t{\n\t\t\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmp_sint32 result = module->loadModuleSample(f, s, XModule::ST_DELTA, XModule::ST_DELTA | XModule::ST_16BIT, oldSize);\n\t\t\t\t\tif (result != MP_OK)\n\t\t\t\t\t\treturn result;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ts++;\n\t\t\t\t\n\t\t\t\tif (s>=MP_MAXSAMPLES)\n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\t\t\t\t\n\t\t\t}\n\t\t\t\n#ifdef MILKYTRACKER\n\t\t\ts+=16 - instr[y].samp;\n#endif\n\t\t\t\n\t\t}\t\t\n\t}\n\t\n\t\/\/ convert modplug stereo samples\n\tfor (mp_sint32 s = 0; s < header->smpnum; s++)\n\t{\n\t\tif (smp[s].type & 32)\n\t\t{\t\t\n\t\t\t\/\/ that's what's allowed, stupid modplug tracker\n\t\t\tsmp[s].type &= 3+16;\t\t\t\t\t\n\n\t\t\tif (smp[s].sample == NULL)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (!(smp[s].type&16)) {\t\t\t\n\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\n\t\t\t\tmp_sbyte* sample = (mp_sbyte*)smp[s].sample;\n\t\t\t\tmp_sint32 samplen = smp[s].samplen;\n\t\t\t\tfor (mp_sint32 i = 0; i < samplen; i++)\n\t\t\t\t{\n\t\t\t\t\tmp_sint32 s = ((mp_sint32)sample[i] + (mp_sint32)sample[i + samplen]) >> 1;\n\t\t\t\t\tif (s < -128) s = -128;\n\t\t\t\t\tif (s > 127) s = 127;\n\t\t\t\t\tsample[i] = (mp_sbyte)s;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\n\t\t\t\tmp_sword* sample = (mp_sword*)smp[s].sample;\n\t\t\t\tmp_sint32 samplen = smp[s].samplen;\n\t\t\t\tfor (mp_sint32 i = 0; i < samplen; i++)\n\t\t\t\t{\n\t\t\t\t\tmp_sint32 s = ((mp_sint32)sample[i] + (mp_sint32)sample[i + samplen]) >> 1;\n\t\t\t\t\tif (s < -32768) s = -32768;\n\t\t\t\t\tif (s > 32767) s = 32767;\n\t\t\t\t\tsample[i] = (mp_sword)s;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\/\/ correct loop type 0x03 (undefined)\n\t\t\/\/ will become ping pong loop\n\t\t\/\/ note that FT2 will refuse to load XM files with such a loop type\n\t\tif ((smp[s].type & 0x3) == 0x3)\n\t\t\tsmp[s].type&=~1;\t\t\n\t}\n\n\t\/\/ correct number of patterns if necessary, otherwise the post processing will remove\n\t\/\/ the \"invalid\" patterns from the order list\n\tbool addPatterns = false;\n\tfor (i = 0; i < header->ordnum; i++)\n\t\tif (header->ord[i]+1 > header->patnum)\n\t\t{\n\t\t\theader->patnum = header->ord[i]+1;\t\n\t\t\taddPatterns = true;\n\t\t}\n\t\n\t\/\/ if the pattern number has been adjusted, add some empty patterns\n\tif (addPatterns)\n\t{\n\t\tfor (i = 0; i < header->patnum; i++)\n\t\t\tif (phead[i].patternData == NULL)\n\t\t\t{\n\t\t\t\tphead[i].rows = 64;\n\t\t\t\tphead[i].effnum = 2;\n\t\t\t\tphead[i].channum = (mp_ubyte)header->channum;\n\n\t\t\t\tphead[i].patternData = new mp_ubyte[phead[i].rows*header->channum*6];\n\t\t\t\n\t\t\t\t\/\/ out of memory?\n\t\t\t\tif (phead[i].patternData == NULL)\n\t\t\t\t{\n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t}\n\t\t\n\t\t\t\tmemset(phead[i].patternData,0,phead[i].rows*header->channum*6);\n\t\t\t}\n\t}\n\t\n\t\/\/ check for MODPLUG extensions\n\tif (f.posWithBaseOffset() + 8 <= fileSize)\n\t{\n\t\tchar buffer[4];\n\t\tf.read(buffer, 1, 4);\n\t\tif (memcmp(buffer, \"text\", 4) == 0)\n\t\t{\n\t\t\tmp_uint32 len = f.readDword();\n\t\t\tmodule->allocateSongMessage(len+1);\n\t\t\t\n\t\t\tmemset(module->message, 0, len+1);\n\t\t\t\n\t\t\tf.read(module->message, 1, len);\n\t\t}\n\t}\n\t\n\tmodule->postProcessSamples();\n\t\n\treturn MP_OK;\n}","target":0,"code_token_length":7148,"total_token_length":7384,"max_tokens_setting":8192}
+{"idx":299898,"func":"readconf_handle_option(uschar *buffer, optionlist *oltop, int last,\n  void *data_block, uschar *unknown_txt)\n{\nint ptr = 0;\nint offset = 0;\nint n, count, type, value;\nint issecure = 0;\nuid_t uid;\ngid_t gid;\nBOOL boolvalue = TRUE;\nBOOL freesptr = TRUE;\nBOOL extra_condition = FALSE;\noptionlist *ol, *ol2;\nstruct passwd *pw;\nvoid *reset_point;\nint intbase = 0;\nuschar *inttype = US\"\";\nuschar *sptr;\nuschar *s = buffer;\nuschar *saved_condition, *strtemp;\nuschar **str_target;\nuschar name[64];\nuschar name2[64];\n\n\/* There may be leading spaces; thereafter, we expect an option name starting\nwith a letter. *\/\n\nwhile (isspace(*s)) s++;\nif (!isalpha(*s))\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"option setting expected: %s\", s);\n\n\/* Read the name of the option, and skip any subsequent white space. If\nit turns out that what we read was \"hide\", set the flag indicating that\nthis is a secure option, and loop to read the next word. *\/\n\nfor (n = 0; n < 2; n++)\n  {\n  while (isalnum(*s) || *s == '_')\n    {\n    if (ptr < sizeof(name)-1) name[ptr++] = *s;\n    s++;\n    }\n  name[ptr] = 0;\n  while (isspace(*s)) s++;\n  if (Ustrcmp(name, \"hide\") != 0) break;\n  issecure = opt_secure;\n  ptr = 0;\n  }\n\n\/* Deal with \"no_\" or \"not_\" here for booleans *\/\n\nif (Ustrncmp(name, \"no_\", 3) == 0)\n  {\n  boolvalue = FALSE;\n  offset = 3;\n  }\n\nif (Ustrncmp(name, \"not_\", 4) == 0)\n  {\n  boolvalue = FALSE;\n  offset = 4;\n  }\n\n\/* Search the list for the given name. A non-existent name, or an option that\nis set twice, is a disaster. *\/\n\nol = find_option(name + offset, oltop, last);\n\nif (ol == NULL)\n  {\n  if (unknown_txt == NULL) return FALSE;\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, CS unknown_txt, name);\n  }\n\nif ((ol->type & opt_set) != 0)\n  {\n  uschar *mname = name;\n  if (Ustrncmp(mname, \"no_\", 3) == 0) mname += 3;\n  if (Ustrcmp(mname, \"condition\") == 0)\n    extra_condition = TRUE;\n  else\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"\\\"%s\\\" option set for the second time\", mname);\n  }\n\nol->type |= opt_set | issecure;\ntype = ol->type & opt_mask;\n\n\/* Types with data values must be followed by '='; the \"no[t]_\" prefix\napplies only to boolean values. *\/\n\nif (type < opt_bool || type > opt_bool_last)\n  {\n  if (offset != 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"negation prefix applied to a non-boolean option\");\n  if (*s == 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"unexpected end of line (data missing) after %s\", name);\n  if (*s != '=')\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"missing \\\"=\\\" after %s\", name);\n  }\n\n\/* If a boolean wasn't preceded by \"no[t]_\" it can be followed by = and\ntrue\/false\/yes\/no, or, in the case of opt_expanded_bool, a general string that\nultimately expands to one of those values. *\/\n\nelse if (*s != 0 && (offset != 0 || *s != '='))\n  extra_chars_error(s, US\"boolean option \", name, US\"\");\n\n\/* Skip white space after = *\/\n\nif (*s == '=') while (isspace((*(++s))));\n\n\/* If there is a data block and the opt_public flag is not set, change\nthe data block pointer to the private options block. *\/\n\nif (data_block != NULL && (ol->type & opt_public) == 0)\n  data_block = (void *)(((driver_instance *)data_block)->options_block);\n\n\/* Now get the data according to the type. *\/\n\nswitch (type)\n  {\n  \/* If a string value is not enclosed in quotes, it consists of\n  the rest of the current line, verbatim. Otherwise, string escapes\n  are processed.\n\n  A transport is specified as a string, which is then looked up in the\n  list of transports. A search type is specified as one of a number of\n  known strings.\n\n  A set or rewrite rules for a driver is specified as a string, which is\n  then parsed into a suitable chain of control blocks.\n\n  Uids and gids are specified as strings which are then looked up in the\n  passwd file. Lists of uids and gids are similarly specified as colon-\n  separated strings. *\/\n\n  case opt_stringptr:\n  case opt_uid:\n  case opt_gid:\n  case opt_expand_uid:\n  case opt_expand_gid:\n  case opt_uidlist:\n  case opt_gidlist:\n  case opt_rewrite:\n\n  reset_point = sptr = read_string(s, name);\n\n  \/* Having read a string, we now have several different ways of using it,\n  depending on the data type, so do another switch. If keeping the actual\n  string is not required (because it is interpreted), freesptr is set TRUE,\n  and at the end we reset the pool. *\/\n\n  switch (type)\n    {\n    \/* If this was a string, set the variable to point to the new string,\n    and set the flag so its store isn't reclaimed. If it was a list of rewrite\n    rules, we still keep the string (for printing), and parse the rules into a\n    control block and flags word. *\/\n\n    case opt_stringptr:\n    if (data_block == NULL)\n      str_target = (uschar **)(ol->value);\n    else\n      str_target = (uschar **)((uschar *)data_block + (long int)(ol->value));\n    if (extra_condition)\n      {\n      \/* We already have a condition, we're conducting a crude hack to let\n      multiple condition rules be chained together, despite storing them in\n      text form. *\/\n      saved_condition = *str_target;\n      strtemp = string_sprintf(\"${if and{{bool_lax{%s}}{bool_lax{%s}}}}\",\n          saved_condition, sptr);\n      *str_target = string_copy_malloc(strtemp);\n      \/* TODO(pdp): there is a memory leak here when we set 3 or more\n      conditions; I still don't understand the store mechanism enough\n      to know what's the safe way to free content from an earlier store.\n      AFAICT, stores stack, so freeing an early stored item also stores\n      all data alloc'd after it.  If we knew conditions were adjacent,\n      we could survive that, but we don't.  So I *think* we need to take\n      another bit from opt_type to indicate \"malloced\"; this seems like\n      quite a hack, especially for this one case.  It also means that\n      we can't ever reclaim the store from the *first* condition.\n\n      Because we only do this once, near process start-up, I'm prepared to\n      let this slide for the time being, even though it rankles.  *\/\n      }\n    else\n      {\n      *str_target = sptr;\n      freesptr = FALSE;\n      }\n    break;\n\n    case opt_rewrite:\n    if (data_block == NULL)\n      *((uschar **)(ol->value)) = sptr;\n    else\n      *((uschar **)((uschar *)data_block + (long int)(ol->value))) = sptr;\n    freesptr = FALSE;\n    if (type == opt_rewrite)\n      {\n      int sep = 0;\n      int *flagptr;\n      uschar *p = sptr;\n      rewrite_rule **chain;\n      optionlist *ol3;\n\n      sprintf(CS name2, \"*%.50s_rules\", name);\n      ol2 = find_option(name2, oltop, last);\n      sprintf(CS name2, \"*%.50s_flags\", name);\n      ol3 = find_option(name2, oltop, last);\n\n      if (ol2 == NULL || ol3 == NULL)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n          \"rewrite rules not available for driver\");\n\n      if (data_block == NULL)\n        {\n        chain = (rewrite_rule **)(ol2->value);\n        flagptr = (int *)(ol3->value);\n        }\n      else\n        {\n        chain = (rewrite_rule **)((uschar *)data_block + (long int)(ol2->value));\n        flagptr = (int *)((uschar *)data_block + (long int)(ol3->value));\n        }\n\n      while ((p = string_nextinlist(&sptr, &sep, big_buffer, BIG_BUFFER_SIZE))\n              != NULL)\n        {\n        rewrite_rule *next = readconf_one_rewrite(p, flagptr, FALSE);\n        *chain = next;\n        chain = &(next->next);\n        }\n\n      if ((*flagptr & (rewrite_all_envelope | rewrite_smtp)) != 0)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"rewrite rule specifies a \"\n          \"non-header rewrite - not allowed at transport time -\");\n      }\n    break;\n\n    \/* If it was an expanded uid, see if there is any expansion to be\n    done by checking for the presence of a $ character. If there is, save it\n    in the corresponding *expand_user option field. Otherwise, fall through\n    to treat it as a fixed uid. Ensure mutual exclusivity of the two kinds\n    of data. *\/\n\n    case opt_expand_uid:\n    sprintf(CS name2, \"*expand_%.50s\", name);\n    ol2 = find_option(name2, oltop, last);\n    if (ol2 != NULL)\n      {\n      uschar *ss = (Ustrchr(sptr, '$') != NULL)? sptr : NULL;\n\n      if (data_block == NULL)\n        *((uschar **)(ol2->value)) = ss;\n      else\n        *((uschar **)((uschar *)data_block + (long int)(ol2->value))) = ss;\n\n      if (ss != NULL)\n        {\n        *(get_set_flag(name, oltop, last, data_block)) = FALSE;\n        freesptr = FALSE;\n        break;\n        }\n      }\n\n    \/* Look up a fixed uid, and also make use of the corresponding gid\n    if a passwd entry is returned and the gid has not been set. *\/\n\n    case opt_uid:\n    if (!route_finduser(sptr, &pw, &uid))\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"user %s was not found\", sptr);\n    if (data_block == NULL)\n      *((uid_t *)(ol->value)) = uid;\n    else\n      *((uid_t *)((uschar *)data_block + (long int)(ol->value))) = uid;\n\n    \/* Set the flag indicating a fixed value is set *\/\n\n    *(get_set_flag(name, oltop, last, data_block)) = TRUE;\n\n    \/* Handle matching gid if we have a passwd entry: done by finding the\n    same name with terminating \"user\" changed to \"group\"; if not found,\n    ignore. Also ignore if the value is already set. *\/\n\n    if (pw == NULL) break;\n    Ustrcpy(name+Ustrlen(name)-4, \"group\");\n    ol2 = find_option(name, oltop, last);\n    if (ol2 != NULL && ((ol2->type & opt_mask) == opt_gid ||\n        (ol2->type & opt_mask) == opt_expand_gid))\n      {\n      BOOL *set_flag = get_set_flag(name, oltop, last, data_block);\n      if (! *set_flag)\n        {\n        if (data_block == NULL)\n          *((gid_t *)(ol2->value)) = pw->pw_gid;\n        else\n          *((gid_t *)((uschar *)data_block + (long int)(ol2->value))) = pw->pw_gid;\n        *set_flag = TRUE;\n        }\n      }\n    break;\n\n    \/* If it was an expanded gid, see if there is any expansion to be\n    done by checking for the presence of a $ character. If there is, save it\n    in the corresponding *expand_user option field. Otherwise, fall through\n    to treat it as a fixed gid. Ensure mutual exclusivity of the two kinds\n    of data. *\/\n\n    case opt_expand_gid:\n    sprintf(CS name2, \"*expand_%.50s\", name);\n    ol2 = find_option(name2, oltop, last);\n    if (ol2 != NULL)\n      {\n      uschar *ss = (Ustrchr(sptr, '$') != NULL)? sptr : NULL;\n\n      if (data_block == NULL)\n        *((uschar **)(ol2->value)) = ss;\n      else\n        *((uschar **)((uschar *)data_block + (long int)(ol2->value))) = ss;\n\n      if (ss != NULL)\n        {\n        *(get_set_flag(name, oltop, last, data_block)) = FALSE;\n        freesptr = FALSE;\n        break;\n        }\n      }\n\n    \/* Handle freestanding gid *\/\n\n    case opt_gid:\n    if (!route_findgroup(sptr, &gid))\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"group %s was not found\", sptr);\n    if (data_block == NULL)\n      *((gid_t *)(ol->value)) = gid;\n    else\n      *((gid_t *)((uschar *)data_block + (long int)(ol->value))) = gid;\n    *(get_set_flag(name, oltop, last, data_block)) = TRUE;\n    break;\n\n    \/* If it was a uid list, look up each individual entry, and build\n    a vector of uids, with a count in the first element. Put the vector\n    in malloc store so we can free the string. (We are reading into\n    permanent store already.) *\/\n\n    case opt_uidlist:\n      {\n      int count = 1;\n      uid_t *list;\n      int ptr = 0;\n      uschar *p;\n      uschar *op = expand_string (sptr);\n\n      if (op == NULL)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"failed to expand %s: %s\",\n          name, expand_string_message);\n\n      p = op;\n      if (*p != 0) count++;\n      while (*p != 0) if (*p++ == ':' && *p != 0) count++;\n      list = store_malloc(count*sizeof(uid_t));\n      list[ptr++] = (uid_t)(count - 1);\n\n      if (data_block == NULL)\n        *((uid_t **)(ol->value)) = list;\n      else\n        *((uid_t **)((uschar *)data_block + (long int)(ol->value))) = list;\n\n      p = op;\n      while (count-- > 1)\n        {\n        int sep = 0;\n        (void)string_nextinlist(&p, &sep, big_buffer, BIG_BUFFER_SIZE);\n        if (!route_finduser(big_buffer, NULL, &uid))\n          log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"user %s was not found\",\n            big_buffer);\n        list[ptr++] = uid;\n        }\n      }\n    break;\n\n    \/* If it was a gid list, look up each individual entry, and build\n    a vector of gids, with a count in the first element. Put the vector\n    in malloc store so we can free the string. (We are reading into permanent\n    store already.) *\/\n\n    case opt_gidlist:\n      {\n      int count = 1;\n      gid_t *list;\n      int ptr = 0;\n      uschar *p;\n      uschar *op = expand_string (sptr);\n\n      if (op == NULL)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"failed to expand %s: %s\",\n          name, expand_string_message);\n\n      p = op;\n      if (*p != 0) count++;\n      while (*p != 0) if (*p++ == ':' && *p != 0) count++;\n      list = store_malloc(count*sizeof(gid_t));\n      list[ptr++] = (gid_t)(count - 1);\n\n      if (data_block == NULL)\n        *((gid_t **)(ol->value)) = list;\n      else\n        *((gid_t **)((uschar *)data_block + (long int)(ol->value))) = list;\n\n      p = op;\n      while (count-- > 1)\n        {\n        int sep = 0;\n        (void)string_nextinlist(&p, &sep, big_buffer, BIG_BUFFER_SIZE);\n        if (!route_findgroup(big_buffer, &gid))\n          log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"group %s was not found\",\n            big_buffer);\n        list[ptr++] = gid;\n        }\n      }\n    break;\n    }\n\n  \/* Release store if the value of the string doesn't need to be kept. *\/\n\n  if (freesptr) store_reset(reset_point);\n  break;\n\n  \/* Expanded boolean: if no characters follow, or if there are no dollar\n  characters, this is a fixed-valued boolean, and we fall through. Otherwise,\n  save the string for later expansion in the alternate place. *\/\n\n  case opt_expand_bool:\n  if (*s != 0 && Ustrchr(s, '$') != 0)\n    {\n    sprintf(CS name2, \"*expand_%.50s\", name);\n    ol2 = find_option(name2, oltop, last);\n    if (ol2 != NULL)\n      {\n      reset_point = sptr = read_string(s, name);\n      if (data_block == NULL)\n        *((uschar **)(ol2->value)) = sptr;\n      else\n        *((uschar **)((uschar *)data_block + (long int)(ol2->value))) = sptr;\n      freesptr = FALSE;\n      break;\n      }\n    }\n  \/* Fall through *\/\n\n  \/* Boolean: if no characters follow, the value is boolvalue. Otherwise\n  look for yes\/not\/true\/false. Some booleans are stored in a single bit in\n  a single int. There's a special fudge for verify settings; without a suffix\n  they set both xx_sender and xx_recipient. The table points to the sender\n  value; search subsequently for the recipient. There's another special case:\n  opt_bool_set also notes when a boolean has been set. *\/\n\n  case opt_bool:\n  case opt_bit:\n  case opt_bool_verify:\n  case opt_bool_set:\n  if (*s != 0)\n    {\n    s = readconf_readname(name2, 64, s);\n    if (strcmpic(name2, US\"true\") == 0 || strcmpic(name2, US\"yes\") == 0)\n      boolvalue = TRUE;\n    else if (strcmpic(name2, US\"false\") == 0 || strcmpic(name2, US\"no\") == 0)\n      boolvalue = FALSE;\n    else log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"\\\"%s\\\" is not a valid value for the \\\"%s\\\" option\", name2, name);\n    if (*s != 0) extra_chars_error(s, string_sprintf(\"\\\"%s\\\" \", name2),\n      US\"for boolean option \", name);\n    }\n\n  \/* Handle single-bit type. *\/\n\n  if (type == opt_bit)\n    {\n    int bit = 1 << ((ol->type >> 16) & 31);\n    int *ptr = (data_block == NULL)?\n      (int *)(ol->value) :\n      (int *)((uschar *)data_block + (long int)ol->value);\n    if (boolvalue) *ptr |= bit; else *ptr &= ~bit;\n    break;\n    }\n\n  \/* Handle full BOOL types *\/\n\n  if (data_block == NULL)\n    *((BOOL *)(ol->value)) = boolvalue;\n  else\n    *((BOOL *)((uschar *)data_block + (long int)(ol->value))) = boolvalue;\n\n  \/* Verify fudge *\/\n\n  if (type == opt_bool_verify)\n    {\n    sprintf(CS name2, \"%.50s_recipient\", name + offset);\n    ol2 = find_option(name2, oltop, last);\n    if (ol2 != NULL)\n      {\n      if (data_block == NULL)\n        *((BOOL *)(ol2->value)) = boolvalue;\n      else\n        *((BOOL *)((uschar *)data_block + (long int)(ol2->value))) = boolvalue;\n      }\n    }\n\n  \/* Note that opt_bool_set type is set, if there is somewhere to do so *\/\n\n  else if (type == opt_bool_set)\n    {\n    sprintf(CS name2, \"*set_%.50s\", name + offset);\n    ol2 = find_option(name2, oltop, last);\n    if (ol2 != NULL)\n      {\n      if (data_block == NULL)\n        *((BOOL *)(ol2->value)) = TRUE;\n      else\n        *((BOOL *)((uschar *)data_block + (long int)(ol2->value))) = TRUE;\n      }\n    }\n  break;\n\n  \/* Octal integer *\/\n\n  case opt_octint:\n  intbase = 8;\n  inttype = US\"octal \";\n\n  \/*  Integer: a simple(ish) case; allow octal and hex formats, and\n  suffixes K and M. The different types affect output, not input. *\/\n\n  case opt_mkint:\n  case opt_int:\n    {\n    uschar *endptr;\n    long int lvalue;\n\n    errno = 0;\n    lvalue = strtol(CS s, CSS &endptr, intbase);\n\n    if (endptr == s)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"%sinteger expected for %s\",\n        inttype, name);\n\n    if (errno != ERANGE)\n      {\n      if (tolower(*endptr) == 'k')\n        {\n        if (lvalue > INT_MAX\/1024 || lvalue < INT_MIN\/1024) errno = ERANGE;\n          else lvalue *= 1024;\n        endptr++;\n        }\n      else if (tolower(*endptr) == 'm')\n        {\n        if (lvalue > INT_MAX\/(1024*1024) || lvalue < INT_MIN\/(1024*1024))\n          errno = ERANGE;\n        else lvalue *= 1024*1024;\n        endptr++;\n        }\n      }\n\n    if (errno == ERANGE || lvalue > INT_MAX || lvalue < INT_MIN)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n        \"absolute value of integer \\\"%s\\\" is too large (overflow)\", s);\n\n    while (isspace(*endptr)) endptr++;\n    if (*endptr != 0)\n      extra_chars_error(endptr, inttype, US\"integer value for \", name);\n\n    value = (int)lvalue;\n    }\n\n  if (data_block == NULL)\n    *((int *)(ol->value)) = value;\n  else\n    *((int *)((uschar *)data_block + (long int)(ol->value))) = value;\n  break;\n\n  \/*  Integer held in K: again, allow octal and hex formats, and suffixes K and\n  M. *\/\n\n  case opt_Kint:\n    {\n    uschar *endptr;\n    errno = 0;\n    value = strtol(CS s, CSS &endptr, intbase);\n\n    if (endptr == s)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"%sinteger expected for %s\",\n        inttype, name);\n\n    if (errno != ERANGE)\n      {\n      if (tolower(*endptr) == 'm')\n        {\n        if (value > INT_MAX\/1024 || value < INT_MIN\/1024) errno = ERANGE;\n          else value *= 1024;\n        endptr++;\n        }\n      else if (tolower(*endptr) == 'k')\n        {\n        endptr++;\n        }\n      else\n        {\n        value = (value + 512)\/1024;\n        }\n      }\n\n    if (errno == ERANGE) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"absolute value of integer \\\"%s\\\" is too large (overflow)\", s);\n\n    while (isspace(*endptr)) endptr++;\n    if (*endptr != 0)\n      extra_chars_error(endptr, inttype, US\"integer value for \", name);\n    }\n\n  if (data_block == NULL)\n    *((int *)(ol->value)) = value;\n  else\n    *((int *)((uschar *)data_block + (long int)(ol->value))) = value;\n  break;\n\n  \/*  Fixed-point number: held to 3 decimal places. *\/\n\n  case opt_fixed:\n  if (sscanf(CS s, \"%d%n\", &value, &count) != 1)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n      \"fixed-point number expected for %s\", name);\n\n  if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"integer \\\"%s\\\" is too large (overflow)\", s);\n\n  value *= 1000;\n\n  if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n    \"integer \\\"%s\\\" is too large (overflow)\", s);\n\n  if (s[count] == '.')\n    {\n    int d = 100;\n    while (isdigit(s[++count]))\n      {\n      value += (s[count] - '0') * d;\n      d \/= 10;\n      }\n    }\n\n  while (isspace(s[count])) count++;\n\n  if (s[count] != 0)\n    extra_chars_error(s+count, US\"fixed-point value for \", name, US\"\");\n\n  if (data_block == NULL)\n    *((int *)(ol->value)) = value;\n  else\n    *((int *)((uschar *)data_block + (long int)(ol->value))) = value;\n  break;\n\n  \/* There's a special routine to read time values. *\/\n\n  case opt_time:\n  value = readconf_readtime(s, 0, FALSE);\n  if (value < 0)\n    log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"invalid time value for %s\",\n      name);\n  if (data_block == NULL)\n    *((int *)(ol->value)) = value;\n  else\n    *((int *)((uschar *)data_block + (long int)(ol->value))) = value;\n  break;\n\n  \/* A time list is a list of colon-separated times, with the first\n  element holding the size of the list and the second the number of\n  entries used. *\/\n\n  case opt_timelist:\n    {\n    int count = 0;\n    int *list = (data_block == NULL)?\n      (int *)(ol->value) :\n      (int *)((uschar *)data_block + (long int)(ol->value));\n\n    if (*s != 0) for (count = 1; count <= list[0] - 2; count++)\n      {\n      int terminator = 0;\n      uschar *snext = Ustrchr(s, ':');\n      if (snext != NULL)\n        {\n        uschar *ss = snext;\n        while (ss > s && isspace(ss[-1])) ss--;\n        terminator = *ss;\n        }\n      value = readconf_readtime(s, terminator, FALSE);\n      if (value < 0)\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"invalid time value for %s\",\n          name);\n      if (count > 1 && value <= list[count])\n        log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,\n          \"time value out of order for %s\", name);\n      list[count+1] = value;\n      if (snext == NULL) break;\n      s = snext + 1;\n      while (isspace(*s)) s++;\n      }\n\n    if (count > list[0] - 2)\n      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"too many time values for %s\",\n        name);\n    if (count > 0 && list[2] == 0) count = 0;\n    list[1] = count;\n    }\n\n  break;\n  }\n\nreturn TRUE;\n}","target":0,"code_token_length":6330,"total_token_length":6566,"max_tokens_setting":8192}
+{"idx":332393,"func":"do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)\n{\n    oparg_T\t*oap = cap->oap;\n    pos_T\told_cursor;\n    int\t\tempty_region_error;\n    int\t\trestart_edit_save;\n#ifdef FEAT_LINEBREAK\n    int\t\tlbr_saved = curwin->w_p_lbr;\n#endif\n\n    \/\/ The visual area is remembered for redo\n    static redo_VIsual_T   redo_VIsual = {NUL, 0, 0, 0,0};\n\n    int\t\t    include_line_break = FALSE;\n\n#if defined(FEAT_CLIPBOARD)\n    \/\/ Yank the visual area into the GUI selection register before we operate\n    \/\/ on it and lose it forever.\n    \/\/ Don't do it if a specific register was specified, so that \"\"x\"*P works.\n    \/\/ This could call do_pending_operator() recursively, but that's OK\n    \/\/ because gui_yank will be TRUE for the nested call.\n    if ((clip_star.available || clip_plus.available)\n\t    && oap->op_type != OP_NOP\n\t    && !gui_yank\n\t    && VIsual_active\n\t    && !redo_VIsual_busy\n\t    && oap->regname == 0)\n\tclip_auto_select();\n#endif\n    old_cursor = curwin->w_cursor;\n\n    \/\/ If an operation is pending, handle it...\n    if ((finish_op || VIsual_active) && oap->op_type != OP_NOP)\n    {\n\t\/\/ Yank can be redone when 'y' is in 'cpoptions', but not when yanking\n\t\/\/ for the clipboard.\n\tint\tredo_yank = vim_strchr(p_cpo, CPO_YANK) != NULL && !gui_yank;\n\n#ifdef FEAT_LINEBREAK\n\t\/\/ Avoid a problem with unwanted linebreaks in block mode.\n\tif (curwin->w_p_lbr)\n\t    curwin->w_valid &= ~VALID_VIRTCOL;\n\tcurwin->w_p_lbr = FALSE;\n#endif\n\toap->is_VIsual = VIsual_active;\n\tif (oap->motion_force == 'V')\n\t    oap->motion_type = MLINE;\n\telse if (oap->motion_force == 'v')\n\t{\n\t    \/\/ If the motion was linewise, \"inclusive\" will not have been set.\n\t    \/\/ Use \"exclusive\" to be consistent.  Makes \"dvj\" work nice.\n\t    if (oap->motion_type == MLINE)\n\t\toap->inclusive = FALSE;\n\t    \/\/ If the motion already was characterwise, toggle \"inclusive\"\n\t    else if (oap->motion_type == MCHAR)\n\t\toap->inclusive = !oap->inclusive;\n\t    oap->motion_type = MCHAR;\n\t}\n\telse if (oap->motion_force == Ctrl_V)\n\t{\n\t    \/\/ Change line- or characterwise motion into Visual block mode.\n\t    if (!VIsual_active)\n\t    {\n\t\tVIsual_active = TRUE;\n\t\tVIsual = oap->start;\n\t    }\n\t    VIsual_mode = Ctrl_V;\n\t    VIsual_select = FALSE;\n\t    VIsual_reselect = FALSE;\n\t}\n\n\t\/\/ Only redo yank when 'y' flag is in 'cpoptions'.\n\t\/\/ Never redo \"zf\" (define fold).\n\tif ((redo_yank || oap->op_type != OP_YANK)\n\t\t&& ((!VIsual_active || oap->motion_force)\n\t\t    \/\/ Also redo Operator-pending Visual mode mappings\n\t\t    || (VIsual_active\n\t\t\t    && is_ex_cmdchar(cap) && oap->op_type != OP_COLON))\n\t\t&& cap->cmdchar != 'D'\n#ifdef FEAT_FOLDING\n\t\t&& oap->op_type != OP_FOLD\n\t\t&& oap->op_type != OP_FOLDOPEN\n\t\t&& oap->op_type != OP_FOLDOPENREC\n\t\t&& oap->op_type != OP_FOLDCLOSE\n\t\t&& oap->op_type != OP_FOLDCLOSEREC\n\t\t&& oap->op_type != OP_FOLDDEL\n\t\t&& oap->op_type != OP_FOLDDELREC\n#endif\n\t\t)\n\t{\n\t    prep_redo(oap->regname, cap->count0,\n\t\t    get_op_char(oap->op_type), get_extra_op_char(oap->op_type),\n\t\t    oap->motion_force, cap->cmdchar, cap->nchar);\n\t    if (cap->cmdchar == '\/' || cap->cmdchar == '?') \/\/ was a search\n\t    {\n\t\t\/\/ If 'cpoptions' does not contain 'r', insert the search\n\t\t\/\/ pattern to really repeat the same command.\n\t\tif (vim_strchr(p_cpo, CPO_REDO) == NULL)\n\t\t    AppendToRedobuffLit(cap->searchbuf, -1);\n\t\tAppendToRedobuff(NL_STR);\n\t    }\n\t    else if (is_ex_cmdchar(cap))\n\t    {\n\t\t\/\/ do_cmdline() has stored the first typed line in\n\t\t\/\/ \"repeat_cmdline\".  When several lines are typed repeating\n\t\t\/\/ won't be possible.\n\t\tif (repeat_cmdline == NULL)\n\t\t    ResetRedobuff();\n\t\telse\n\t\t{\n\t\t    AppendToRedobuffLit(repeat_cmdline, -1);\n\t\t    AppendToRedobuff(NL_STR);\n\t\t    VIM_CLEAR(repeat_cmdline);\n\t\t}\n\t    }\n\t}\n\n\tif (redo_VIsual_busy)\n\t{\n\t    \/\/ Redo of an operation on a Visual area. Use the same size from\n\t    \/\/ redo_VIsual.rv_line_count and redo_VIsual.rv_vcol.\n\t    oap->start = curwin->w_cursor;\n\t    curwin->w_cursor.lnum += redo_VIsual.rv_line_count - 1;\n\t    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t\tcurwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n\t    VIsual_mode = redo_VIsual.rv_mode;\n\t    if (redo_VIsual.rv_vcol == MAXCOL || VIsual_mode == 'v')\n\t    {\n\t\tif (VIsual_mode == 'v')\n\t\t{\n\t\t    if (redo_VIsual.rv_line_count <= 1)\n\t\t    {\n\t\t\tvalidate_virtcol();\n\t\t\tcurwin->w_curswant =\n\t\t\t\t     curwin->w_virtcol + redo_VIsual.rv_vcol - 1;\n\t\t    }\n\t\t    else\n\t\t\tcurwin->w_curswant = redo_VIsual.rv_vcol;\n\t\t}\n\t\telse\n\t\t{\n\t\t    curwin->w_curswant = MAXCOL;\n\t\t}\n\t\tcoladvance(curwin->w_curswant);\n\t    }\n\t    cap->count0 = redo_VIsual.rv_count;\n\t    if (redo_VIsual.rv_count != 0)\n\t\tcap->count1 = redo_VIsual.rv_count;\n\t    else\n\t\tcap->count1 = 1;\n\t}\n\telse if (VIsual_active)\n\t{\n\t    if (!gui_yank)\n\t    {\n\t\t\/\/ Save the current VIsual area for '< and '> marks, and \"gv\"\n\t\tcurbuf->b_visual.vi_start = VIsual;\n\t\tcurbuf->b_visual.vi_end = curwin->w_cursor;\n\t\tcurbuf->b_visual.vi_mode = VIsual_mode;\n\t\trestore_visual_mode();\n\t\tcurbuf->b_visual.vi_curswant = curwin->w_curswant;\n# ifdef FEAT_EVAL\n\t\tcurbuf->b_visual_mode_eval = VIsual_mode;\n# endif\n\t    }\n\n\t    \/\/ In Select mode, a linewise selection is operated upon like a\n\t    \/\/ characterwise selection.\n\t    \/\/ Special case: gH<Del> deletes the last line.\n\t    if (VIsual_select && VIsual_mode == 'V'\n\t\t\t\t\t    && cap->oap->op_type != OP_DELETE)\n\t    {\n\t\tif (LT_POS(VIsual, curwin->w_cursor))\n\t\t{\n\t\t    VIsual.col = 0;\n\t\t    curwin->w_cursor.col =\n\t\t\t       (colnr_T)STRLEN(ml_get(curwin->w_cursor.lnum));\n\t\t}\n\t\telse\n\t\t{\n\t\t    curwin->w_cursor.col = 0;\n\t\t    VIsual.col = (colnr_T)STRLEN(ml_get(VIsual.lnum));\n\t\t}\n\t\tVIsual_mode = 'v';\n\t    }\n\t    \/\/ If 'selection' is \"exclusive\", backup one character for\n\t    \/\/ charwise selections.\n\t    else if (VIsual_mode == 'v')\n\t\tinclude_line_break = unadjust_for_sel();\n\n\t    oap->start = VIsual;\n\t    if (VIsual_mode == 'V')\n\t    {\n\t\toap->start.col = 0;\n\t\toap->start.coladd = 0;\n\t    }\n\t}\n\n\t\/\/ Set oap->start to the first position of the operated text, oap->end\n\t\/\/ to the end of the operated text.  w_cursor is equal to oap->start.\n\tif (LT_POS(oap->start, curwin->w_cursor))\n\t{\n#ifdef FEAT_FOLDING\n\t    \/\/ Include folded lines completely.\n\t    if (!VIsual_active)\n\t    {\n\t\tif (hasFolding(oap->start.lnum, &oap->start.lnum, NULL))\n\t\t    oap->start.col = 0;\n\t\tif ((curwin->w_cursor.col > 0 || oap->inclusive\n\t\t\t\t\t\t  || oap->motion_type == MLINE)\n\t\t\t&& hasFolding(curwin->w_cursor.lnum, NULL,\n\t\t\t\t\t\t      &curwin->w_cursor.lnum))\n\t\t    curwin->w_cursor.col = (colnr_T)STRLEN(ml_get_curline());\n\t    }\n#endif\n\t    oap->end = curwin->w_cursor;\n\t    curwin->w_cursor = oap->start;\n\n\t    \/\/ w_virtcol may have been updated; if the cursor goes back to its\n\t    \/\/ previous position w_virtcol becomes invalid and isn't updated\n\t    \/\/ automatically.\n\t    curwin->w_valid &= ~VALID_VIRTCOL;\n\t}\n\telse\n\t{\n#ifdef FEAT_FOLDING\n\t    \/\/ Include folded lines completely.\n\t    if (!VIsual_active && oap->motion_type == MLINE)\n\t    {\n\t\tif (hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum,\n\t\t\t\t\t\t\t\t\tNULL))\n\t\t    curwin->w_cursor.col = 0;\n\t\tif (hasFolding(oap->start.lnum, NULL, &oap->start.lnum))\n\t\t    oap->start.col = (colnr_T)STRLEN(ml_get(oap->start.lnum));\n\t    }\n#endif\n\t    oap->end = oap->start;\n\t    oap->start = curwin->w_cursor;\n\t}\n\n\t\/\/ Just in case lines were deleted that make the position invalid.\n\tcheck_pos(curwin->w_buffer, &oap->end);\n\toap->line_count = oap->end.lnum - oap->start.lnum + 1;\n\n\t\/\/ Set \"virtual_op\" before resetting VIsual_active.\n\tvirtual_op = virtual_active();\n\n\tif (VIsual_active || redo_VIsual_busy)\n\t{\n\t    get_op_vcol(oap, redo_VIsual.rv_vcol, TRUE);\n\n\t    if (!redo_VIsual_busy && !gui_yank)\n\t    {\n\t\t\/\/ Prepare to reselect and redo Visual: this is based on the\n\t\t\/\/ size of the Visual text\n\t\tresel_VIsual_mode = VIsual_mode;\n\t\tif (curwin->w_curswant == MAXCOL)\n\t\t    resel_VIsual_vcol = MAXCOL;\n\t\telse\n\t\t{\n\t\t    if (VIsual_mode != Ctrl_V)\n\t\t\tgetvvcol(curwin, &(oap->end),\n\t\t\t\t\t\t  NULL, NULL, &oap->end_vcol);\n\t\t    if (VIsual_mode == Ctrl_V || oap->line_count <= 1)\n\t\t    {\n\t\t\tif (VIsual_mode != Ctrl_V)\n\t\t\t    getvvcol(curwin, &(oap->start),\n\t\t\t\t\t\t&oap->start_vcol, NULL, NULL);\n\t\t\tresel_VIsual_vcol = oap->end_vcol - oap->start_vcol + 1;\n\t\t    }\n\t\t    else\n\t\t\tresel_VIsual_vcol = oap->end_vcol;\n\t\t}\n\t\tresel_VIsual_line_count = oap->line_count;\n\t    }\n\n\t    \/\/ can't redo yank (unless 'y' is in 'cpoptions') and \":\"\n\t    if ((redo_yank || oap->op_type != OP_YANK)\n\t\t    && oap->op_type != OP_COLON\n#ifdef FEAT_FOLDING\n\t\t    && oap->op_type != OP_FOLD\n\t\t    && oap->op_type != OP_FOLDOPEN\n\t\t    && oap->op_type != OP_FOLDOPENREC\n\t\t    && oap->op_type != OP_FOLDCLOSE\n\t\t    && oap->op_type != OP_FOLDCLOSEREC\n\t\t    && oap->op_type != OP_FOLDDEL\n\t\t    && oap->op_type != OP_FOLDDELREC\n#endif\n\t\t    && oap->motion_force == NUL\n\t\t    )\n\t    {\n\t\t\/\/ Prepare for redoing.  Only use the nchar field for \"r\",\n\t\t\/\/ otherwise it might be the second char of the operator.\n\t\tif (cap->cmdchar == 'g' && (cap->nchar == 'n'\n\t\t\t\t\t\t\t|| cap->nchar == 'N'))\n\t\t    prep_redo(oap->regname, cap->count0,\n\t\t\t    get_op_char(oap->op_type),\n\t\t\t    get_extra_op_char(oap->op_type),\n\t\t\t    oap->motion_force, cap->cmdchar, cap->nchar);\n\t\telse if (!is_ex_cmdchar(cap))\n\t\t{\n\t\t    int opchar = get_op_char(oap->op_type);\n\t\t    int extra_opchar = get_extra_op_char(oap->op_type);\n\t\t    int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;\n\n\t\t    \/\/ reverse what nv_replace() did\n\t\t    if (nchar == REPLACE_CR_NCHAR)\n\t\t\tnchar = CAR;\n\t\t    else if (nchar == REPLACE_NL_NCHAR)\n\t\t\tnchar = NL;\n\n\t\t    if (opchar == 'g' && extra_opchar == '@')\n\t\t\t\/\/ also repeat the count for 'operatorfunc'\n\t\t\tprep_redo_num2(oap->regname, 0L, NUL, 'v',\n\t\t\t\t     cap->count0, opchar, extra_opchar, nchar);\n\t\t    else\n\t\t\tprep_redo(oap->regname, 0L, NUL, 'v',\n\t\t\t\t\t\t  opchar, extra_opchar, nchar);\n\t\t}\n\t\tif (!redo_VIsual_busy)\n\t\t{\n\t\t    redo_VIsual.rv_mode = resel_VIsual_mode;\n\t\t    redo_VIsual.rv_vcol = resel_VIsual_vcol;\n\t\t    redo_VIsual.rv_line_count = resel_VIsual_line_count;\n\t\t    redo_VIsual.rv_count = cap->count0;\n\t\t    redo_VIsual.rv_arg = cap->arg;\n\t\t}\n\t    }\n\n\t    \/\/ oap->inclusive defaults to TRUE.\n\t    \/\/ If oap->end is on a NUL (empty line) oap->inclusive becomes\n\t    \/\/ FALSE.  This makes \"d}P\" and \"v}dP\" work the same.\n\t    if (oap->motion_force == NUL || oap->motion_type == MLINE)\n\t\toap->inclusive = TRUE;\n\t    if (VIsual_mode == 'V')\n\t\toap->motion_type = MLINE;\n\t    else\n\t    {\n\t\toap->motion_type = MCHAR;\n\t\tif (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL\n\t\t\t&& (include_line_break || !virtual_op))\n\t\t{\n\t\t    oap->inclusive = FALSE;\n\t\t    \/\/ Try to include the newline, unless it's an operator\n\t\t    \/\/ that works on lines only.\n\t\t    if (*p_sel != 'o'\n\t\t\t    && !op_on_lines(oap->op_type)\n\t\t\t    && oap->end.lnum < curbuf->b_ml.ml_line_count)\n\t\t    {\n\t\t\t++oap->end.lnum;\n\t\t\toap->end.col = 0;\n\t\t\toap->end.coladd = 0;\n\t\t\t++oap->line_count;\n\t\t    }\n\t\t}\n\t    }\n\n\t    redo_VIsual_busy = FALSE;\n\n\t    \/\/ Switch Visual off now, so screen updating does\n\t    \/\/ not show inverted text when the screen is redrawn.\n\t    \/\/ With OP_YANK and sometimes with OP_COLON and OP_FILTER there is\n\t    \/\/ no screen redraw, so it is done here to remove the inverted\n\t    \/\/ part.\n\t    if (!gui_yank)\n\t    {\n\t\tVIsual_active = FALSE;\n\t\tsetmouse();\n\t\tmouse_dragging = 0;\n\t\tmay_clear_cmdline();\n\t\tif ((oap->op_type == OP_YANK\n\t\t\t    || oap->op_type == OP_COLON\n\t\t\t    || oap->op_type == OP_FUNCTION\n\t\t\t    || oap->op_type == OP_FILTER)\n\t\t\t&& oap->motion_force == NUL)\n\t\t{\n#ifdef FEAT_LINEBREAK\n\t\t    \/\/ make sure redrawing is correct\n\t\t    curwin->w_p_lbr = lbr_saved;\n#endif\n\t\t    redraw_curbuf_later(INVERTED);\n\t\t}\n\t    }\n\t}\n\n\t\/\/ Include the trailing byte of a multi-byte char.\n\tif (has_mbyte && oap->inclusive)\n\t{\n\t    int\t\tl;\n\n\t    l = (*mb_ptr2len)(ml_get_pos(&oap->end));\n\t    if (l > 1)\n\t\toap->end.col += l - 1;\n\t}\n\tcurwin->w_set_curswant = TRUE;\n\n\t\/\/ oap->empty is set when start and end are the same.  The inclusive\n\t\/\/ flag affects this too, unless yanking and the end is on a NUL.\n\toap->empty = (oap->motion_type == MCHAR\n\t\t    && (!oap->inclusive\n\t\t\t|| (oap->op_type == OP_YANK\n\t\t\t    && gchar_pos(&oap->end) == NUL))\n\t\t    && EQUAL_POS(oap->start, oap->end)\n\t\t    && !(virtual_op && oap->start.coladd != oap->end.coladd));\n\t\/\/ For delete, change and yank, it's an error to operate on an\n\t\/\/ empty region, when 'E' included in 'cpoptions' (Vi compatible).\n\tempty_region_error = (oap->empty\n\t\t\t\t&& vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL);\n\n\t\/\/ Force a redraw when operating on an empty Visual region, when\n\t\/\/ 'modifiable is off or creating a fold.\n\tif (oap->is_VIsual && (oap->empty || !curbuf->b_p_ma\n#ifdef FEAT_FOLDING\n\t\t    || oap->op_type == OP_FOLD\n#endif\n\t\t    ))\n\t{\n#ifdef FEAT_LINEBREAK\n\t    curwin->w_p_lbr = lbr_saved;\n#endif\n\t    redraw_curbuf_later(INVERTED);\n\t}\n\n\t\/\/ If the end of an operator is in column one while oap->motion_type\n\t\/\/ is MCHAR and oap->inclusive is FALSE, we put op_end after the last\n\t\/\/ character in the previous line. If op_start is on or before the\n\t\/\/ first non-blank in the line, the operator becomes linewise\n\t\/\/ (strange, but that's the way vi does it).\n\tif (\t   oap->motion_type == MCHAR\n\t\t&& oap->inclusive == FALSE\n\t\t&& !(cap->retval & CA_NO_ADJ_OP_END)\n\t\t&& oap->end.col == 0\n\t\t&& (!oap->is_VIsual || *p_sel == 'o')\n\t\t&& !oap->block_mode\n\t\t&& oap->line_count > 1)\n\t{\n\t    oap->end_adjusted = TRUE;\t    \/\/ remember that we did this\n\t    --oap->line_count;\n\t    --oap->end.lnum;\n\t    if (inindent(0))\n\t\toap->motion_type = MLINE;\n\t    else\n\t    {\n\t\toap->end.col = (colnr_T)STRLEN(ml_get(oap->end.lnum));\n\t\tif (oap->end.col)\n\t\t{\n\t\t    --oap->end.col;\n\t\t    oap->inclusive = TRUE;\n\t\t}\n\t    }\n\t}\n\telse\n\t    oap->end_adjusted = FALSE;\n\n\tswitch (oap->op_type)\n\t{\n\tcase OP_LSHIFT:\n\tcase OP_RSHIFT:\n\t    op_shift(oap, TRUE, oap->is_VIsual ? (int)cap->count1 : 1);\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase OP_JOIN_NS:\n\tcase OP_JOIN:\n\t    if (oap->line_count < 2)\n\t\toap->line_count = 2;\n\t    if (curwin->w_cursor.lnum + oap->line_count - 1 >\n\t\t\t\t\t\t   curbuf->b_ml.ml_line_count)\n\t\tbeep_flush();\n\t    else\n\t    {\n\t\t(void)do_join(oap->line_count, oap->op_type == OP_JOIN,\n\t\t\t\t\t\t\t    TRUE, TRUE, TRUE);\n\t\tauto_format(FALSE, TRUE);\n\t    }\n\t    break;\n\n\tcase OP_DELETE:\n\t    VIsual_reselect = FALSE;\t    \/\/ don't reselect now\n\t    if (empty_region_error)\n\t    {\n\t\tvim_beep(BO_OPER);\n\t\tCancelRedo();\n\t    }\n\t    else\n\t    {\n\t\t(void)op_delete(oap);\n\t\t\/\/ save cursor line for undo if it wasn't saved yet\n\t\tif (oap->motion_type == MLINE && has_format_option(FO_AUTO)\n\t\t\t\t\t\t      && u_save_cursor() == OK)\n\t\t    auto_format(FALSE, TRUE);\n\t    }\n\t    break;\n\n\tcase OP_YANK:\n\t    if (empty_region_error)\n\t    {\n\t\tif (!gui_yank)\n\t\t{\n\t\t    vim_beep(BO_OPER);\n\t\t    CancelRedo();\n\t\t}\n\t    }\n\t    else\n\t    {\n#ifdef FEAT_LINEBREAK\n\t\tcurwin->w_p_lbr = lbr_saved;\n#endif\n\t\toap->excl_tr_ws = cap->cmdchar == 'z';\n\t\t(void)op_yank(oap, FALSE, !gui_yank);\n\t    }\n\t    check_cursor_col();\n\t    break;\n\n\tcase OP_CHANGE:\n\t    VIsual_reselect = FALSE;\t    \/\/ don't reselect now\n\t    if (empty_region_error)\n\t    {\n\t\tvim_beep(BO_OPER);\n\t\tCancelRedo();\n\t    }\n\t    else\n\t    {\n\t\t\/\/ This is a new edit command, not a restart.  Need to\n\t\t\/\/ remember it to make 'insertmode' work with mappings for\n\t\t\/\/ Visual mode.  But do this only once and not when typed and\n\t\t\/\/ 'insertmode' isn't set.\n\t\tif (p_im || !KeyTyped)\n\t\t    restart_edit_save = restart_edit;\n\t\telse\n\t\t    restart_edit_save = 0;\n\t\trestart_edit = 0;\n#ifdef FEAT_LINEBREAK\n\t\t\/\/ Restore linebreak, so that when the user edits it looks as\n\t\t\/\/ before.\n\t\tcurwin->w_p_lbr = lbr_saved;\n#endif\n\t\t\/\/ Reset finish_op now, don't want it set inside edit().\n\t\tfinish_op = FALSE;\n\t\tif (op_change(oap))\t\/\/ will call edit()\n\t\t    cap->retval |= CA_COMMAND_BUSY;\n\t\tif (restart_edit == 0)\n\t\t    restart_edit = restart_edit_save;\n\t    }\n\t    break;\n\n\tcase OP_FILTER:\n\t    if (vim_strchr(p_cpo, CPO_FILTER) != NULL)\n\t\tAppendToRedobuff((char_u *)\"!\\r\");  \/\/ use any last used !cmd\n\t    else\n\t\tbangredo = TRUE;    \/\/ do_bang() will put cmd in redo buffer\n\t    \/\/ FALLTHROUGH\n\n\tcase OP_INDENT:\n\tcase OP_COLON:\n\n#if defined(FEAT_LISP) || defined(FEAT_CINDENT)\n\t    \/\/ If 'equalprg' is empty, do the indenting internally.\n\t    if (oap->op_type == OP_INDENT && *get_equalprg() == NUL)\n\t    {\n# ifdef FEAT_LISP\n\t\tif (curbuf->b_p_lisp)\n\t\t{\n\t\t    op_reindent(oap, get_lisp_indent);\n\t\t    break;\n\t\t}\n# endif\n# ifdef FEAT_CINDENT\n\t\top_reindent(oap,\n#  ifdef FEAT_EVAL\n\t\t\t*curbuf->b_p_inde != NUL ? get_expr_indent :\n#  endif\n\t\t\t    get_c_indent);\n\t\tbreak;\n# endif\n\t    }\n#endif\n\n\t    op_colon(oap);\n\t    break;\n\n\tcase OP_TILDE:\n\tcase OP_UPPER:\n\tcase OP_LOWER:\n\tcase OP_ROT13:\n\t    if (empty_region_error)\n\t    {\n\t\tvim_beep(BO_OPER);\n\t\tCancelRedo();\n\t    }\n\t    else\n\t\top_tilde(oap);\n\t    check_cursor_col();\n\t    break;\n\n\tcase OP_FORMAT:\n#if defined(FEAT_EVAL)\n\t    if (*curbuf->b_p_fex != NUL)\n\t\top_formatexpr(oap);\t\/\/ use expression\n\t    else\n#endif\n\t    {\n\t\tif (*p_fp != NUL || *curbuf->b_p_fp != NUL)\n\t\t    op_colon(oap);\t\t\/\/ use external command\n\t\telse\n\t\t    op_format(oap, FALSE);\t\/\/ use internal function\n\t    }\n\t    break;\n\tcase OP_FORMAT2:\n\t    op_format(oap, TRUE);\t\/\/ use internal function\n\t    break;\n\n\tcase OP_FUNCTION:\n\t    {\n\t\tredo_VIsual_T   save_redo_VIsual = redo_VIsual;\n\n#ifdef FEAT_LINEBREAK\n\t\t\/\/ Restore linebreak, so that when the user edits it looks as\n\t\t\/\/ before.\n\t\tcurwin->w_p_lbr = lbr_saved;\n#endif\n\t\t\/\/ call 'operatorfunc'\n\t\top_function(oap);\n\n\t\t\/\/ Restore the info for redoing Visual mode, the function may\n\t\t\/\/ invoke another operator and unintentionally change it.\n\t\tredo_VIsual = save_redo_VIsual;\n\t\tbreak;\n\t    }\n\n\tcase OP_INSERT:\n\tcase OP_APPEND:\n\t    VIsual_reselect = FALSE;\t\/\/ don't reselect now\n\t    if (empty_region_error)\n\t    {\n\t\tvim_beep(BO_OPER);\n\t\tCancelRedo();\n\t    }\n\t    else\n\t    {\n\t\t\/\/ This is a new edit command, not a restart.  Need to\n\t\t\/\/ remember it to make 'insertmode' work with mappings for\n\t\t\/\/ Visual mode.  But do this only once.\n\t\trestart_edit_save = restart_edit;\n\t\trestart_edit = 0;\n#ifdef FEAT_LINEBREAK\n\t\t\/\/ Restore linebreak, so that when the user edits it looks as\n\t\t\/\/ before.\n\t\tcurwin->w_p_lbr = lbr_saved;\n#endif\n\t\top_insert(oap, cap->count1);\n#ifdef FEAT_LINEBREAK\n\t\t\/\/ Reset linebreak, so that formatting works correctly.\n\t\tcurwin->w_p_lbr = FALSE;\n#endif\n\n\t\t\/\/ TODO: when inserting in several lines, should format all\n\t\t\/\/ the lines.\n\t\tauto_format(FALSE, TRUE);\n\n\t\tif (restart_edit == 0)\n\t\t    restart_edit = restart_edit_save;\n\t\telse\n\t\t    cap->retval |= CA_COMMAND_BUSY;\n\t    }\n\t    break;\n\n\tcase OP_REPLACE:\n\t    VIsual_reselect = FALSE;\t\/\/ don't reselect now\n\t    if (empty_region_error)\n\t    {\n\t\tvim_beep(BO_OPER);\n\t\tCancelRedo();\n\t    }\n\t    else\n\t    {\n#ifdef FEAT_LINEBREAK\n\t\t\/\/ Restore linebreak, so that when the user edits it looks as\n\t\t\/\/ before.\n\t\tcurwin->w_p_lbr = lbr_saved;\n#endif\n\t\top_replace(oap, cap->nchar);\n\t    }\n\t    break;\n\n#ifdef FEAT_FOLDING\n\tcase OP_FOLD:\n\t    VIsual_reselect = FALSE;\t\/\/ don't reselect now\n\t    foldCreate(oap->start.lnum, oap->end.lnum);\n\t    break;\n\n\tcase OP_FOLDOPEN:\n\tcase OP_FOLDOPENREC:\n\tcase OP_FOLDCLOSE:\n\tcase OP_FOLDCLOSEREC:\n\t    VIsual_reselect = FALSE;\t\/\/ don't reselect now\n\t    opFoldRange(oap->start.lnum, oap->end.lnum,\n\t\t    oap->op_type == OP_FOLDOPEN\n\t\t\t\t\t    || oap->op_type == OP_FOLDOPENREC,\n\t\t    oap->op_type == OP_FOLDOPENREC\n\t\t\t\t\t  || oap->op_type == OP_FOLDCLOSEREC,\n\t\t\t\t\t  oap->is_VIsual);\n\t    break;\n\n\tcase OP_FOLDDEL:\n\tcase OP_FOLDDELREC:\n\t    VIsual_reselect = FALSE;\t\/\/ don't reselect now\n\t    deleteFold(oap->start.lnum, oap->end.lnum,\n\t\t\t       oap->op_type == OP_FOLDDELREC, oap->is_VIsual);\n\t    break;\n#endif\n\tcase OP_NR_ADD:\n\tcase OP_NR_SUB:\n\t    if (empty_region_error)\n\t    {\n\t\tvim_beep(BO_OPER);\n\t\tCancelRedo();\n\t    }\n\t    else\n\t    {\n\t\tVIsual_active = TRUE;\n#ifdef FEAT_LINEBREAK\n\t\tcurwin->w_p_lbr = lbr_saved;\n#endif\n\t\top_addsub(oap, cap->count1, redo_VIsual.rv_arg);\n\t\tVIsual_active = FALSE;\n\t    }\n\t    check_cursor_col();\n\t    break;\n\tdefault:\n\t    clearopbeep(oap);\n\t}\n\tvirtual_op = MAYBE;\n\tif (!gui_yank)\n\t{\n\t    \/\/ if 'sol' not set, go back to old column for some commands\n\t    if (!p_sol && oap->motion_type == MLINE && !oap->end_adjusted\n\t\t    && (oap->op_type == OP_LSHIFT || oap->op_type == OP_RSHIFT\n\t\t\t\t\t\t|| oap->op_type == OP_DELETE))\n\t    {\n#ifdef FEAT_LINEBREAK\n\t\tcurwin->w_p_lbr = FALSE;\n#endif\n\t\tcoladvance(curwin->w_curswant = old_col);\n\t    }\n\t}\n\telse\n\t{\n\t    curwin->w_cursor = old_cursor;\n\t}\n\toap->block_mode = FALSE;\n\tclearop(oap);\n\tmotion_force = NUL;\n    }\n#ifdef FEAT_LINEBREAK\n    curwin->w_p_lbr = lbr_saved;\n#endif\n}","target":0,"code_token_length":6634,"total_token_length":6870,"max_tokens_setting":8192}
+{"idx":418786,"func":"check_termcode_mouse(\n    char_u\t*tp,\n    int\t\t*slen,\n    char_u\t*key_name,\n    char_u\t*modifiers_start,\n    int\t\tidx,\n    int\t\t*modifiers)\n{\n    int\t\tj;\n    char_u\t*p;\n# if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \\\n    || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)\n    char_u\tbytes[6];\n    int\t\tnum_bytes;\n# endif\n    int\t\tmouse_code = 0;\t    \/\/ init for GCC\n    int\t\tis_click, is_drag;\n    int\t\tis_release, release_is_ambiguous;\n    int\t\twheel_code = 0;\n    int\t\tcurrent_button;\n    static int\torig_num_clicks = 1;\n    static int\torig_mouse_code = 0x0;\n# ifdef CHECK_DOUBLE_CLICK\n    static int\torig_mouse_col = 0;\n    static int\torig_mouse_row = 0;\n    static struct timeval  orig_mouse_time = {0, 0};\n    \/\/ time of previous mouse click\n    struct timeval  mouse_time;\t\t\/\/ time of current mouse click\n    long\ttimediff;\t\t\/\/ elapsed time in msec\n# endif\n\n    is_click = is_drag = is_release = release_is_ambiguous = FALSE;\n\n# if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \\\n    || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)\n    if (key_name[0] == KS_MOUSE\n#  ifdef FEAT_MOUSE_GPM\n\t    || key_name[0] == KS_GPM_MOUSE\n#  endif\n       )\n    {\n\t\/*\n\t * For xterm we get \"<t_mouse>scr\", where s == encoded button state:\n\t *\t   0x20 = left button down\n\t *\t   0x21 = middle button down\n\t *\t   0x22 = right button down\n\t *\t   0x23 = any button release\n\t *\t   0x60 = button 4 down (scroll wheel down)\n\t *\t   0x61 = button 5 down (scroll wheel up)\n\t *\tadd 0x04 for SHIFT\n\t *\tadd 0x08 for ALT\n\t *\tadd 0x10 for CTRL\n\t *\tadd 0x20 for mouse drag (0x40 is drag with left button)\n\t *\tadd 0x40 for mouse move (0x80 is move, 0x81 too)\n\t *\t\t 0x43 (drag + release) is also move\n\t *  c == column + ' ' + 1 == column + 33\n\t *  r == row + ' ' + 1 == row + 33\n\t *\n\t * The coordinates are passed on through global variables.  Ugly, but\n\t * this avoids trouble with mouse clicks at an unexpected moment and\n\t * allows for mapping them.\n\t *\/\n\tfor (;;)\n\t{\n#  ifdef FEAT_GUI\n\t    if (gui.in_use)\n\t    {\n\t\t\/\/ GUI uses more bits for columns > 223\n\t\tnum_bytes = get_bytes_from_buf(tp + *slen, bytes, 5);\n\t\tif (num_bytes == -1)\t\/\/ not enough coordinates\n\t\t    return -1;\n\t\tmouse_code = bytes[0];\n\t\tmouse_col = 128 * (bytes[1] - ' ' - 1)\n\t\t    + bytes[2] - ' ' - 1;\n\t\tmouse_row = 128 * (bytes[3] - ' ' - 1)\n\t\t    + bytes[4] - ' ' - 1;\n\t    }\n\t    else\n#  endif\n\t    {\n\t\tnum_bytes = get_bytes_from_buf(tp + *slen, bytes, 3);\n\t\tif (num_bytes == -1)\t\/\/ not enough coordinates\n\t\t    return -1;\n\t\tmouse_code = bytes[0];\n\t\tmouse_col = bytes[1] - ' ' - 1;\n\t\tmouse_row = bytes[2] - ' ' - 1;\n\t    }\n\t    *slen += num_bytes;\n\n\t    \/\/ If the following bytes is also a mouse code and it has the same\n\t    \/\/ code, dump this one and get the next.  This makes dragging a\n\t    \/\/ whole lot faster.\n#  ifdef FEAT_GUI\n\t    if (gui.in_use)\n\t\tj = 3;\n\t    else\n#  endif\n\t\tj = get_termcode_len(idx);\n\t    if (STRNCMP(tp, tp + *slen, (size_t)j) == 0\n\t\t    && tp[*slen + j] == mouse_code\n\t\t    && tp[*slen + j + 1] != NUL\n\t\t    && tp[*slen + j + 2] != NUL\n#  ifdef FEAT_GUI\n\t\t    && (!gui.in_use\n\t\t\t|| (tp[*slen + j + 3] != NUL\n\t\t\t    && tp[*slen + j + 4] != NUL))\n#  endif\n\t       )\n\t\t*slen += j;\n\t    else\n\t\tbreak;\n\t}\n    }\n\n    if (key_name[0] == KS_URXVT_MOUSE\n\t    || key_name[0] == KS_SGR_MOUSE\n\t    || key_name[0] == KS_SGR_MOUSE_RELEASE)\n    {\n\t\/\/ URXVT 1015 mouse reporting mode:\n\t\/\/ Almost identical to xterm mouse mode, except the values are decimal\n\t\/\/ instead of bytes.\n\t\/\/\n\t\/\/ \\033[%d;%d;%dM\n\t\/\/\t       ^-- row\n\t\/\/\t    ^----- column\n\t\/\/\t ^-------- code\n\t\/\/\n\t\/\/ SGR 1006 mouse reporting mode:\n\t\/\/ Almost identical to xterm mouse mode, except the values are decimal\n\t\/\/ instead of bytes.\n\t\/\/\n\t\/\/ \\033[<%d;%d;%dM\n\t\/\/\t       ^-- row\n\t\/\/\t    ^----- column\n\t\/\/\t ^-------- code\n\t\/\/\n\t\/\/ \\033[<%d;%d;%dm\t  : mouse release event\n\t\/\/\t       ^-- row\n\t\/\/\t    ^----- column\n\t\/\/\t ^-------- code\n\tp = modifiers_start;\n\tif (p == NULL)\n\t    return -1;\n\n\tmouse_code = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\n\t\/\/ when mouse reporting is SGR, add 32 to mouse code\n\tif (key_name[0] == KS_SGR_MOUSE\n\t\t|| key_name[0] == KS_SGR_MOUSE_RELEASE)\n\t    mouse_code += 32;\n\n\tmouse_col = getdigits(&p) - 1;\n\tif (*p++ != ';')\n\t    return -1;\n\n\tmouse_row = getdigits(&p) - 1;\n\n\t\/\/ The modifiers were the mouse coordinates, not the modifier keys\n\t\/\/ (alt\/shift\/ctrl\/meta) state.\n\t*modifiers = 0;\n    }\n\n    if (key_name[0] == KS_SGR_MOUSE\n\t    || key_name[0] == KS_SGR_MOUSE_RELEASE)\n    {\n\tif (key_name[0] == KS_SGR_MOUSE_RELEASE)\n\t{\n\t    is_release = TRUE;\n\t    \/\/ This is used below to set held_button.\n\t    mouse_code |= MOUSE_RELEASE;\n\t}\n    }\n    else\n    {\n\trelease_is_ambiguous = TRUE;\n\tif ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE)\n\t    is_release = TRUE;\n    }\n\n    if (key_name[0] == KS_MOUSE\n#  ifdef FEAT_MOUSE_GPM\n\t    || key_name[0] == KS_GPM_MOUSE\n#  endif\n#  ifdef FEAT_MOUSE_URXVT\n\t    || key_name[0] == KS_URXVT_MOUSE\n#  endif\n\t    || key_name[0] == KS_SGR_MOUSE\n\t    || key_name[0] == KS_SGR_MOUSE_RELEASE)\n    {\n#  if !defined(MSWIN)\n\t\/*\n\t * Handle old style mouse events.\n\t * Recognize the xterm mouse wheel, but not in the GUI, the\n\t * Linux console with GPM and the MS-DOS or Win32 console\n\t * (multi-clicks use >= 0x60).\n\t *\/\n\tif (mouse_code >= MOUSEWHEEL_LOW\n#   ifdef FEAT_GUI\n\t\t&& !gui.in_use\n#   endif\n#   ifdef FEAT_MOUSE_GPM\n\t\t&& key_name[0] != KS_GPM_MOUSE\n#   endif\n\t   )\n\t{\n#   if defined(UNIX)\n\t    if (use_xterm_mouse() > 1 && mouse_code >= 0x80)\n\t\t\/\/ mouse-move event, using MOUSE_DRAG works\n\t\tmouse_code = MOUSE_DRAG;\n\t    else\n#   endif\n\t\t\/\/ Keep the mouse_code before it's changed, so that we\n\t\t\/\/ remember that it was a mouse wheel click.\n\t\twheel_code = mouse_code;\n\t}\n#   ifdef FEAT_MOUSE_XTERM\n\telse if (held_button == MOUSE_RELEASE\n#    ifdef FEAT_GUI\n\t\t&& !gui.in_use\n#    endif\n\t\t&& (mouse_code == 0x23 || mouse_code == 0x24\n\t\t    || mouse_code == 0x40 || mouse_code == 0x41))\n\t{\n\t    \/\/ Apparently 0x23 and 0x24 are used by rxvt scroll wheel.\n\t    \/\/ And 0x40 and 0x41 are used by some xterm emulator.\n\t    wheel_code = mouse_code - (mouse_code >= 0x40 ? 0x40 : 0x23)\n\t\t\t\t\t\t\t      + MOUSEWHEEL_LOW;\n\t}\n#   endif\n\n#   if defined(UNIX)\n\telse if (use_xterm_mouse() > 1)\n\t{\n\t    if (mouse_code & MOUSE_DRAG_XTERM)\n\t\tmouse_code |= MOUSE_DRAG;\n\t}\n#   endif\n#   ifdef FEAT_XCLIPBOARD\n\telse if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK))\n\t{\n\t    if (is_release)\n\t\tstop_xterm_trace();\n\t    else\n\t\tstart_xterm_trace(mouse_code);\n\t}\n#   endif\n#  endif\n    }\n# endif \/\/ !UNIX || FEAT_MOUSE_XTERM\n# ifdef FEAT_MOUSE_NET\n    if (key_name[0] == KS_NETTERM_MOUSE)\n    {\n\tint mc, mr;\n\n\t\/\/ expect a rather limited sequence like: balancing {\n\t\/\/ \\033}6,45\\r\n\t\/\/ '6' is the row, 45 is the column\n\tp = tp + *slen;\n\tmr = getdigits(&p);\n\tif (*p++ != ',')\n\t    return -1;\n\tmc = getdigits(&p);\n\tif (*p++ != '\\r')\n\t    return -1;\n\n\tmouse_col = mc - 1;\n\tmouse_row = mr - 1;\n\tmouse_code = MOUSE_LEFT;\n\t*slen += (int)(p - (tp + *slen));\n    }\n# endif\t\/\/ FEAT_MOUSE_NET\n# ifdef FEAT_MOUSE_JSB\n    if (key_name[0] == KS_JSBTERM_MOUSE)\n    {\n\tint mult, val, iter, button, status;\n\n\t\/*\n\t * JSBTERM Input Model\n\t * \\033[0~zw uniq escape sequence\n\t * (L-x)  Left button pressed - not pressed x not reporting\n\t * (M-x)  Middle button pressed - not pressed x not reporting\n\t * (R-x)  Right button pressed - not pressed x not reporting\n\t * (SDmdu)  Single , Double click, m: mouse move, d: button down,\n\t\t      *\t\t\t\t\t\t   u: button up\n\t *  ###   X cursor position padded to 3 digits\n\t *  ###   Y cursor position padded to 3 digits\n\t * (s-x)  SHIFT key pressed - not pressed x not reporting\n\t * (c-x)  CTRL key pressed - not pressed x not reporting\n\t * \\033\\\\ terminating sequence\n\t *\/\n\tp = tp + *slen;\n\tbutton = mouse_code = 0;\n\tswitch (*p++)\n\t{\n\t    case 'L': button = 1; break;\n\t    case '-': break;\n\t    case 'x': break; \/\/ ignore sequence\n\t    default:  return -1; \/\/ Unknown Result\n\t}\n\tswitch (*p++)\n\t{\n\t    case 'M': button |= 2; break;\n\t    case '-': break;\n\t    case 'x': break; \/\/ ignore sequence\n\t    default:  return -1; \/\/ Unknown Result\n\t}\n\tswitch (*p++)\n\t{\n\t    case 'R': button |= 4; break;\n\t    case '-': break;\n\t    case 'x': break; \/\/ ignore sequence\n\t    default:  return -1; \/\/ Unknown Result\n\t}\n\tstatus = *p++;\n\tfor (val = 0, mult = 100, iter = 0; iter < 3; iter++,\n\t\tmult \/= 10, p++)\n\t    if (*p >= '0' && *p <= '9')\n\t\tval += (*p - '0') * mult;\n\t    else\n\t\treturn -1;\n\tmouse_col = val;\n\tfor (val = 0, mult = 100, iter = 0; iter < 3; iter++,\n\t\tmult \/= 10, p++)\n\t    if (*p >= '0' && *p <= '9')\n\t\tval += (*p - '0') * mult;\n\t    else\n\t\treturn -1;\n\tmouse_row = val;\n\tswitch (*p++)\n\t{\n\t    case 's': button |= 8; break;  \/\/ SHIFT key Pressed\n\t    case '-': break;  \/\/ Not Pressed\n\t    case 'x': break;  \/\/ Not Reporting\n\t    default:  return -1; \/\/ Unknown Result\n\t}\n\tswitch (*p++)\n\t{\n\t    case 'c': button |= 16; break;  \/\/ CTRL key Pressed\n\t    case '-': break;  \/\/ Not Pressed\n\t    case 'x': break;  \/\/ Not Reporting\n\t    default:  return -1; \/\/ Unknown Result\n\t}\n\tif (*p++ != '\\033')\n\t    return -1;\n\tif (*p++ != '\\\\')\n\t    return -1;\n\tswitch (status)\n\t{\n\t    case 'D': \/\/ Double Click\n\t    case 'S': \/\/ Single Click\n\t\tif (button & 1) mouse_code |= MOUSE_LEFT;\n\t\tif (button & 2) mouse_code |= MOUSE_MIDDLE;\n\t\tif (button & 4) mouse_code |= MOUSE_RIGHT;\n\t\tif (button & 8) mouse_code |= MOUSE_SHIFT;\n\t\tif (button & 16) mouse_code |= MOUSE_CTRL;\n\t\tbreak;\n\t    case 'm': \/\/ Mouse move\n\t\tif (button & 1) mouse_code |= MOUSE_LEFT;\n\t\tif (button & 2) mouse_code |= MOUSE_MIDDLE;\n\t\tif (button & 4) mouse_code |= MOUSE_RIGHT;\n\t\tif (button & 8) mouse_code |= MOUSE_SHIFT;\n\t\tif (button & 16) mouse_code |= MOUSE_CTRL;\n\t\tif ((button & 7) != 0)\n\t\t{\n\t\t    held_button = mouse_code;\n\t\t    mouse_code |= MOUSE_DRAG;\n\t\t}\n\t\tis_drag = TRUE;\n\t\tshowmode();\n\t\tbreak;\n\t    case 'd': \/\/ Button Down\n\t\tif (button & 1) mouse_code |= MOUSE_LEFT;\n\t\tif (button & 2) mouse_code |= MOUSE_MIDDLE;\n\t\tif (button & 4) mouse_code |= MOUSE_RIGHT;\n\t\tif (button & 8) mouse_code |= MOUSE_SHIFT;\n\t\tif (button & 16) mouse_code |= MOUSE_CTRL;\n\t\tbreak;\n\t    case 'u': \/\/ Button Up\n\t\tis_release = TRUE;\n\t\tif (button & 1)\n\t\t    mouse_code |= MOUSE_LEFT;\n\t\tif (button & 2)\n\t\t    mouse_code |= MOUSE_MIDDLE;\n\t\tif (button & 4)\n\t\t    mouse_code |= MOUSE_RIGHT;\n\t\tif (button & 8)\n\t\t    mouse_code |= MOUSE_SHIFT;\n\t\tif (button & 16)\n\t\t    mouse_code |= MOUSE_CTRL;\n\t\tbreak;\n\t    default: return -1; \/\/ Unknown Result\n\t}\n\n\t*slen += (p - (tp + *slen));\n    }\n# endif \/\/ FEAT_MOUSE_JSB\n# ifdef FEAT_MOUSE_DEC\n    if (key_name[0] == KS_DEC_MOUSE)\n    {\n\t\/*\n\t * The DEC Locator Input Model\n\t * Netterm delivers the code sequence:\n\t *  \\033[2;4;24;80&w  (left button down)\n\t *  \\033[3;0;24;80&w  (left button up)\n\t *  \\033[6;1;24;80&w  (right button down)\n\t *  \\033[7;0;24;80&w  (right button up)\n\t * CSI Pe ; Pb ; Pr ; Pc ; Pp & w\n\t * Pe is the event code\n\t * Pb is the button code\n\t * Pr is the row coordinate\n\t * Pc is the column coordinate\n\t * Pp is the third coordinate (page number)\n\t * Pe, the event code indicates what event caused this report\n\t *    The following event codes are defined:\n\t *    0 - request, the terminal received an explicit request for a\n\t *\t  locator report, but the locator is unavailable\n\t *    1 - request, the terminal received an explicit request for a\n\t *\t  locator report\n\t *    2 - left button down\n\t *    3 - left button up\n\t *    4 - middle button down\n\t *    5 - middle button up\n\t *    6 - right button down\n\t *    7 - right button up\n\t *    8 - fourth button down\n\t *    9 - fourth button up\n\t *    10 - locator outside filter rectangle\n\t * Pb, the button code, ASCII decimal 0-15 indicating which buttons are\n\t *   down if any. The state of the four buttons on the locator\n\t *   correspond to the low four bits of the decimal value, \"1\" means\n\t *   button depressed\n\t *   0 - no buttons down,\n\t *   1 - right,\n\t *   2 - middle,\n\t *   4 - left,\n\t *   8 - fourth\n\t * Pr is the row coordinate of the locator position in the page,\n\t *   encoded as an ASCII decimal value.  If Pr is omitted, the locator\n\t *   position is undefined (outside the terminal window for example).\n\t * Pc is the column coordinate of the locator position in the page,\n\t *   encoded as an ASCII decimal value.  If Pc is omitted, the locator\n\t *   position is undefined (outside the terminal window for example).\n\t * Pp is the page coordinate of the locator position encoded as an\n\t *   ASCII decimal value.  The page coordinate may be omitted if the\n\t *   locator is on page one (the default).  We ignore it anyway.\n\t *\/\n\tint Pe, Pb, Pr, Pc;\n\n\tp = tp + *slen;\n\n\t\/\/ get event status\n\tPe = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\n\t\/\/ get button status\n\tPb = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\n\t\/\/ get row status\n\tPr = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\n\t\/\/ get column status\n\tPc = getdigits(&p);\n\n\t\/\/ the page parameter is optional\n\tif (*p == ';')\n\t{\n\t    p++;\n\t    (void)getdigits(&p);\n\t}\n\tif (*p++ != '&')\n\t    return -1;\n\tif (*p++ != 'w')\n\t    return -1;\n\n\tmouse_code = 0;\n\tswitch (Pe)\n\t{\n\t    case  0: return -1; \/\/ position request while unavailable\n\t    case  1: \/\/ a response to a locator position request includes\n\t\t     \/\/\tthe status of all buttons\n\t\t     Pb &= 7;   \/\/ mask off and ignore fourth button\n\t\t     if (Pb & 4)\n\t\t\t mouse_code  = MOUSE_LEFT;\n\t\t     if (Pb & 2)\n\t\t\t mouse_code  = MOUSE_MIDDLE;\n\t\t     if (Pb & 1)\n\t\t\t mouse_code  = MOUSE_RIGHT;\n\t\t     if (Pb)\n\t\t     {\n\t\t\t held_button = mouse_code;\n\t\t\t mouse_code |= MOUSE_DRAG;\n\t\t\t WantQueryMouse = TRUE;\n\t\t     }\n\t\t     is_drag = TRUE;\n\t\t     showmode();\n\t\t     break;\n\t    case  2: mouse_code = MOUSE_LEFT;\n\t\t     WantQueryMouse = TRUE;\n\t\t     break;\n\t    case  3: mouse_code = MOUSE_LEFT;\n\t\t     is_release = TRUE;\n\t\t     break;\n\t    case  4: mouse_code = MOUSE_MIDDLE;\n\t\t     WantQueryMouse = TRUE;\n\t\t     break;\n\t    case  5: mouse_code = MOUSE_MIDDLE;\n\t\t     is_release = TRUE;\n\t\t     break;\n\t    case  6: mouse_code = MOUSE_RIGHT;\n\t\t     WantQueryMouse = TRUE;\n\t\t     break;\n\t    case  7: mouse_code = MOUSE_RIGHT;\n\t\t     is_release = TRUE;\n\t\t     break;\n\t    case  8: return -1; \/\/ fourth button down\n\t    case  9: return -1; \/\/ fourth button up\n\t    case 10: return -1; \/\/ mouse outside of filter rectangle\n\t    default: return -1; \/\/ should never occur\n\t}\n\n\tmouse_col = Pc - 1;\n\tmouse_row = Pr - 1;\n\n\t*slen += (int)(p - (tp + *slen));\n    }\n# endif \/\/ FEAT_MOUSE_DEC\n# ifdef FEAT_MOUSE_PTERM\n    if (key_name[0] == KS_PTERM_MOUSE)\n    {\n\tint button, num_clicks, action;\n\n\tp = tp + *slen;\n\n\taction = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\n\tmouse_row = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\tmouse_col = getdigits(&p);\n\tif (*p++ != ';')\n\t    return -1;\n\n\tbutton = getdigits(&p);\n\tmouse_code = 0;\n\n\tswitch (button)\n\t{\n\t    case 4: mouse_code = MOUSE_LEFT; break;\n\t    case 1: mouse_code = MOUSE_RIGHT; break;\n\t    case 2: mouse_code = MOUSE_MIDDLE; break;\n\t    default: return -1;\n\t}\n\n\tswitch (action)\n\t{\n\t    case 31: \/\/ Initial press\n\t\tif (*p++ != ';')\n\t\t    return -1;\n\n\t\tnum_clicks = getdigits(&p); \/\/ Not used\n\t\tbreak;\n\n\t    case 32: \/\/ Release\n\t\tis_release = TRUE;\n\t\tbreak;\n\n\t    case 33: \/\/ Drag\n\t\theld_button = mouse_code;\n\t\tmouse_code |= MOUSE_DRAG;\n\t\tbreak;\n\n\t    default:\n\t\treturn -1;\n\t}\n\n\tif (*p++ != 't')\n\t    return -1;\n\n\t*slen += (p - (tp + *slen));\n    }\n# endif \/\/ FEAT_MOUSE_PTERM\n\n    \/\/ Interpret the mouse code\n    current_button = (mouse_code & MOUSE_CLICK_MASK);\n    if (is_release)\n\tcurrent_button |= MOUSE_RELEASE;\n\n    if (current_button == MOUSE_RELEASE\n# ifdef FEAT_MOUSE_XTERM\n\t    && wheel_code == 0\n# endif\n       )\n    {\n\t\/*\n\t * If we get a mouse drag or release event when there is no mouse\n\t * button held down (held_button == MOUSE_RELEASE), produce a K_IGNORE\n\t * below.\n\t * (can happen when you hold down two buttons and then let them go, or\n\t * click in the menu bar, but not on a menu, and drag into the text).\n\t *\/\n\tif ((mouse_code & MOUSE_DRAG) == MOUSE_DRAG)\n\t    is_drag = TRUE;\n\tcurrent_button = held_button;\n    }\n    else\n    {\n      if (wheel_code == 0)\n      {\n# ifdef CHECK_DOUBLE_CLICK\n#  ifdef FEAT_MOUSE_GPM\n\t\/*\n\t * Only for Unix, when GUI not active, we handle multi-clicks here, but\n\t * not for GPM mouse events.\n\t *\/\n#   ifdef FEAT_GUI\n\tif (key_name[0] != KS_GPM_MOUSE && !gui.in_use)\n#   else\n\t    if (key_name[0] != KS_GPM_MOUSE)\n#   endif\n#  else\n#   ifdef FEAT_GUI\n\t\tif (!gui.in_use)\n#   endif\n#  endif\n\t\t{\n\t\t    \/*\n\t\t     * Compute the time elapsed since the previous mouse click.\n\t\t     *\/\n\t\t    gettimeofday(&mouse_time, NULL);\n\t\t    if (orig_mouse_time.tv_sec == 0)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Avoid computing the difference between mouse_time\n\t\t\t * and orig_mouse_time for the first click, as the\n\t\t\t * difference would be huge and would cause\n\t\t\t * multiplication overflow.\n\t\t\t *\/\n\t\t\ttimediff = p_mouset;\n\t\t    }\n\t\t    else\n\t\t\ttimediff = time_diff_ms(&orig_mouse_time, &mouse_time);\n\t\t    orig_mouse_time = mouse_time;\n\t\t    if (mouse_code == orig_mouse_code\n\t\t\t    && timediff < p_mouset\n\t\t\t    && orig_num_clicks != 4\n\t\t\t    && orig_mouse_col == mouse_col\n\t\t\t    && orig_mouse_row == mouse_row\n\t\t\t    && (is_mouse_topline(curwin)\n\t\t\t\t\/\/ Double click in tab pages line also works\n\t\t\t\t\/\/ when window contents changes.\n\t\t\t\t|| (mouse_row == 0 && firstwin->w_winrow > 0))\n\t\t       )\n\t\t\t++orig_num_clicks;\n\t\t    else\n\t\t\torig_num_clicks = 1;\n\t\t    orig_mouse_col = mouse_col;\n\t\t    orig_mouse_row = mouse_row;\n\t\t    set_mouse_topline(curwin);\n\t\t}\n#  if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM)\n\t\telse\n\t\t    orig_num_clicks = NUM_MOUSE_CLICKS(mouse_code);\n#  endif\n# else\n\torig_num_clicks = NUM_MOUSE_CLICKS(mouse_code);\n# endif\n\tis_click = TRUE;\n      }\n      orig_mouse_code = mouse_code;\n    }\n    if (!is_drag)\n\theld_button = mouse_code & MOUSE_CLICK_MASK;\n\n    \/*\n     * Translate the actual mouse event into a pseudo mouse event.\n     * First work out what modifiers are to be used.\n     *\/\n    if (orig_mouse_code & MOUSE_SHIFT)\n\t*modifiers |= MOD_MASK_SHIFT;\n    if (orig_mouse_code & MOUSE_CTRL)\n\t*modifiers |= MOD_MASK_CTRL;\n    if (orig_mouse_code & MOUSE_ALT)\n\t*modifiers |= MOD_MASK_ALT;\n    if (orig_num_clicks == 2)\n\t*modifiers |= MOD_MASK_2CLICK;\n    else if (orig_num_clicks == 3)\n\t*modifiers |= MOD_MASK_3CLICK;\n    else if (orig_num_clicks == 4)\n\t*modifiers |= MOD_MASK_4CLICK;\n\n    \/\/ Work out our pseudo mouse event. Note that MOUSE_RELEASE gets added,\n    \/\/ then it's not mouse up\/down.\n    key_name[0] = KS_EXTRA;\n    if (wheel_code != 0 && (!is_release || release_is_ambiguous))\n    {\n\tif (wheel_code & MOUSE_CTRL)\n\t    *modifiers |= MOD_MASK_CTRL;\n\tif (wheel_code & MOUSE_ALT)\n\t    *modifiers |= MOD_MASK_ALT;\n\n\tif (wheel_code & 1 && wheel_code & 2)\n\t    key_name[1] = (int)KE_MOUSELEFT;\n\telse if (wheel_code & 2)\n\t    key_name[1] = (int)KE_MOUSERIGHT;\n\telse if (wheel_code & 1)\n\t    key_name[1] = (int)KE_MOUSEUP;\n\telse\n\t    key_name[1] = (int)KE_MOUSEDOWN;\n\n\theld_button = MOUSE_RELEASE;\n    }\n    else\n\tkey_name[1] = get_pseudo_mouse_code(current_button, is_click, is_drag);\n\n\n    \/\/ Make sure the mouse position is valid.  Some terminals may return weird\n    \/\/ values.\n    if (mouse_col >= Columns)\n\tmouse_col = Columns - 1;\n    if (mouse_row >= Rows)\n\tmouse_row = Rows - 1;\n\n    return 0;\n}","target":0,"code_token_length":6121,"total_token_length":6357,"max_tokens_setting":8192}
+{"idx":379323,"func":"do_one_cmd(\n    char_u\t**cmdlinep,\n    int\t\tflags,\n#ifdef FEAT_EVAL\n    cstack_T\t*cstack,\n#endif\n    char_u\t*(*fgetline)(int, void *, int, getline_opt_T),\n    void\t*cookie)\t\t\/\/ argument for fgetline()\n{\n    char_u\t*p;\n    linenr_T\tlnum;\n    long\tn;\n    char\t*errormsg = NULL;\t\/\/ error message\n    char_u\t*after_modifier = NULL;\n    exarg_T\tea;\t\t\t\/\/ Ex command arguments\n    cmdmod_T\tsave_cmdmod;\n    int\t\tsave_reg_executing = reg_executing;\n    int\t\tsave_pending_end_reg_executing = pending_end_reg_executing;\n    int\t\tni;\t\t\t\/\/ set when Not Implemented\n    char_u\t*cmd;\n    int\t\tstarts_with_colon = FALSE;\n#ifdef FEAT_EVAL\n    int\t\tmay_have_range;\n    int\t\tvim9script;\n    int\t\tdid_set_expr_line = FALSE;\n#endif\n    int\t\tsourcing = flags & DOCMD_VERBOSE;\n    int\t\tdid_append_cmd = FALSE;\n\n    CLEAR_FIELD(ea);\n    ea.line1 = 1;\n    ea.line2 = 1;\n#ifdef FEAT_EVAL\n    ++ex_nesting_level;\n#endif\n\n    \/\/ When the last file has not been edited :q has to be typed twice.\n    if (quitmore\n#ifdef FEAT_EVAL\n\t    \/\/ avoid that a function call in 'statusline' does this\n\t    && !getline_equal(fgetline, cookie, get_func_line)\n#endif\n\t    \/\/ avoid that an autocommand, e.g. QuitPre, does this\n\t    && !getline_equal(fgetline, cookie, getnextac))\n\t--quitmore;\n\n    \/*\n     * Reset browse, confirm, etc..  They are restored when returning, for\n     * recursive calls.\n     *\/\n    save_cmdmod = cmdmod;\n\n    \/\/ \"#!anything\" is handled like a comment.\n    if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!')\n\tgoto doend;\n\n\/*\n * 1. Skip comment lines and leading white space and colons.\n * 2. Handle command modifiers.\n *\/\n    \/\/ The \"ea\" structure holds the arguments that can be used.\n    ea.cmd = *cmdlinep;\n    ea.cmdlinep = cmdlinep;\n    ea.getline = fgetline;\n    ea.cookie = cookie;\n#ifdef FEAT_EVAL\n    ea.cstack = cstack;\n    starts_with_colon = *skipwhite(ea.cmd) == ':';\n#endif\n    if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)\n\tgoto doend;\n    apply_cmdmod(&cmdmod);\n#ifdef FEAT_EVAL\n    vim9script = in_vim9script();\n#endif\n    after_modifier = ea.cmd;\n\n#ifdef FEAT_EVAL\n    ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0\n\t\t\t && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE));\n#else\n    ea.skip = (if_level > 0);\n#endif\n\n\/*\n * 3. Skip over the range to find the command.  Let \"p\" point to after it.\n *\n * We need the command to know what kind of range it uses.\n *\/\n    cmd = ea.cmd;\n#ifdef FEAT_EVAL\n    \/\/ In Vim9 script a colon is required before the range.  This may also be\n    \/\/ after command modifiers.\n    if (vim9script && (flags & DOCMD_RANGEOK) == 0)\n    {\n\tmay_have_range = FALSE;\n\tfor (p = ea.cmd; p >= *cmdlinep; --p)\n\t{\n\t    if (*p == ':')\n\t\tmay_have_range = TRUE;\n\t    if (p < ea.cmd && !VIM_ISWHITE(*p))\n\t\tbreak;\n\t}\n    }\n    else\n\tmay_have_range = TRUE;\n    if (may_have_range)\n#endif\n\tea.cmd = skip_range(ea.cmd, TRUE, NULL);\n\n#ifdef FEAT_EVAL\n    if (vim9script && !may_have_range)\n    {\n\tif (ea.cmd == cmd + 1 && *cmd == '$')\n\t    \/\/ should be \"$VAR = val\"\n\t    --ea.cmd;\n\tp = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);\n\tif (ea.cmdidx == CMD_SIZE)\n\t{\n\t    char_u *ar = skip_range(ea.cmd, TRUE, NULL);\n\n\t    \/\/ If a ':' before the range is missing, give a clearer error\n\t    \/\/ message.\n\t    if (ar > ea.cmd && !ea.skip)\n\t    {\n\t\tsemsg(_(e_colon_required_before_range_str), ea.cmd);\n\t\tgoto doend;\n\t    }\n\t}\n    }\n    else\n#endif\n\tp = find_ex_command(&ea, NULL, NULL, NULL);\n\n#ifdef FEAT_EVAL\n# ifdef FEAT_PROFILE\n    \/\/ Count this line for profiling if skip is TRUE.\n    if (do_profiling == PROF_YES\n\t    && (!ea.skip || cstack->cs_idx == 0 || (cstack->cs_idx > 0\n\t\t     && (cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE))))\n    {\n\tint skip = did_emsg || got_int || did_throw;\n\n\tif (ea.cmdidx == CMD_catch)\n\t    skip = !skip && !(cstack->cs_idx >= 0\n\t\t\t  && (cstack->cs_flags[cstack->cs_idx] & CSF_THROWN)\n\t\t\t  && !(cstack->cs_flags[cstack->cs_idx] & CSF_CAUGHT));\n\telse if (ea.cmdidx == CMD_else || ea.cmdidx == CMD_elseif)\n\t    skip = skip || !(cstack->cs_idx >= 0\n\t\t\t  && !(cstack->cs_flags[cstack->cs_idx]\n\t\t\t\t\t\t  & (CSF_ACTIVE | CSF_TRUE)));\n\telse if (ea.cmdidx == CMD_finally)\n\t    skip = FALSE;\n\telse if (ea.cmdidx != CMD_endif\n\t\t&& ea.cmdidx != CMD_endfor\n\t\t&& ea.cmdidx != CMD_endtry\n\t\t&& ea.cmdidx != CMD_endwhile)\n\t    skip = ea.skip;\n\n\tif (!skip)\n\t{\n\t    if (getline_equal(fgetline, cookie, get_func_line))\n\t\tfunc_line_exec(getline_cookie(fgetline, cookie));\n\t    else if (getline_equal(fgetline, cookie, getsourceline))\n\t\tscript_line_exec();\n\t}\n    }\n# endif\n\n    \/\/ May go to debug mode.  If this happens and the \">quit\" debug command is\n    \/\/ used, throw an interrupt exception and skip the next command.\n    dbg_check_breakpoint(&ea);\n    if (!ea.skip && got_int)\n    {\n\tea.skip = TRUE;\n\t(void)do_intthrow(cstack);\n    }\n#endif\n\n\/*\n * 4. parse a range specifier of the form: addr [,addr] [;addr] ..\n *\n * where 'addr' is:\n *\n * %\t      (entire file)\n * $  [+-NUM]\n * 'x [+-NUM] (where x denotes a currently defined mark)\n * .  [+-NUM]\n * [+-NUM]..\n * NUM\n *\n * The ea.cmd pointer is updated to point to the first character following the\n * range spec. If an initial address is found, but no second, the upper bound\n * is equal to the lower.\n *\/\n\n    \/\/ ea.addr_type for user commands is set by find_ucmd\n    if (!IS_USER_CMDIDX(ea.cmdidx))\n    {\n\tif (ea.cmdidx != CMD_SIZE)\n\t    ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;\n\telse\n\t    ea.addr_type = ADDR_LINES;\n\n\t\/\/ :wincmd range depends on the argument.\n\tif (ea.cmdidx == CMD_wincmd && p != NULL)\n\t    get_wincmd_addr_type(skipwhite(p), &ea);\n#ifdef FEAT_QUICKFIX\n\t\/\/ :.cc in quickfix window uses line number\n\tif ((ea.cmdidx == CMD_cc || ea.cmdidx == CMD_ll) && bt_quickfix(curbuf))\n\t    ea.addr_type = ADDR_OTHER;\n#endif\n    }\n\n    ea.cmd = cmd;\n#ifdef FEAT_EVAL\n    if (!may_have_range)\n\tea.line1 = ea.line2 = default_address(&ea);\n    else\n#endif\n\tif (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)\n\t    goto doend;\n\n\/*\n * 5. Parse the command.\n *\/\n\n    \/*\n     * Skip ':' and any white space\n     *\/\n    ea.cmd = skipwhite(ea.cmd);\n    while (*ea.cmd == ':')\n\tea.cmd = skipwhite(ea.cmd + 1);\n\n    \/*\n     * If we got a line, but no command, then go to the line.\n     * If we find a '|' or '\\n' we set ea.nextcmd.\n     *\/\n    if (*ea.cmd == NUL || comment_start(ea.cmd, starts_with_colon)\n\t\t\t       || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL)\n    {\n\t\/*\n\t * strange vi behaviour:\n\t * \":3\"\t\tjumps to line 3\n\t * \":3|...\"\tprints line 3  (not in Vim9 script)\n\t * \":|\"\t\tprints current line  (not in Vim9 script)\n\t *\/\n\tif (ea.skip)\t    \/\/ skip this if inside :if\n\t    goto doend;\n\terrormsg = ex_range_without_command(&ea);\n\tgoto doend;\n    }\n\n    \/\/ If this looks like an undefined user command and there are CmdUndefined\n    \/\/ autocommands defined, trigger the matching autocommands.\n    if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip\n\t    && ASCII_ISUPPER(*ea.cmd)\n\t    && has_cmdundefined())\n    {\n\tint ret;\n\n\tp = ea.cmd;\n\twhile (ASCII_ISALNUM(*p))\n\t    ++p;\n\tp = vim_strnsave(ea.cmd, p - ea.cmd);\n\tret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);\n\tvim_free(p);\n\t\/\/ If the autocommands did something and didn't cause an error, try\n\t\/\/ finding the command again.\n\tp = (ret\n#ifdef FEAT_EVAL\n\t\t&& !aborting()\n#endif\n\t\t) ? find_ex_command(&ea, NULL, NULL, NULL) : ea.cmd;\n    }\n\n    if (p == NULL)\n    {\n\tif (!ea.skip)\n\t    errormsg = _(e_ambiguous_use_of_user_defined_command);\n\tgoto doend;\n    }\n    \/\/ Check for wrong commands.\n    if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78\n\t    && !IS_USER_CMDIDX(ea.cmdidx))\n    {\n\terrormsg = uc_fun_cmd();\n\tgoto doend;\n    }\n\n    if (ea.cmdidx == CMD_SIZE)\n    {\n\tif (!ea.skip)\n\t{\n\t    STRCPY(IObuff, _(e_not_an_editor_command));\n\t    if (!sourcing)\n\t    {\n\t\t\/\/ If the modifier was parsed OK the error must be in the\n\t\t\/\/ following command\n\t\tif (after_modifier != NULL)\n\t\t    append_command(after_modifier);\n\t\telse\n\t\t    append_command(*cmdlinep);\n\t\tdid_append_cmd = TRUE;\n\t    }\n\t    errormsg = (char *)IObuff;\n\t    did_emsg_syntax = TRUE;\n\t}\n\tgoto doend;\n    }\n\n    ni = (!IS_USER_CMDIDX(ea.cmdidx)\n\t    && (cmdnames[ea.cmdidx].cmd_func == ex_ni\n#ifdef HAVE_EX_SCRIPT_NI\n\t     || cmdnames[ea.cmdidx].cmd_func == ex_script_ni\n#endif\n\t     ));\n\n#ifndef FEAT_EVAL\n    \/*\n     * When the expression evaluation is disabled, recognize the \":if\" and\n     * \":endif\" commands and ignore everything in between it.\n     *\/\n    if (ea.cmdidx == CMD_if)\n\t++if_level;\n    if (if_level)\n    {\n\tif (ea.cmdidx == CMD_endif)\n\t    --if_level;\n\tgoto doend;\n    }\n\n#endif\n\n    \/\/ forced commands\n    if (*p == '!' && ea.cmdidx != CMD_substitute\n\t    && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic)\n    {\n\t++p;\n\tea.forceit = TRUE;\n    }\n    else\n\tea.forceit = FALSE;\n\n\/*\n * 6. Parse arguments.  Then check for errors.\n *\/\n    if (!IS_USER_CMDIDX(ea.cmdidx))\n\tea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;\n\n    if (!ea.skip)\n    {\n#ifdef HAVE_SANDBOX\n\tif (sandbox != 0 && !(ea.argt & EX_SBOXOK))\n\t{\n\t    \/\/ Command not allowed in sandbox.\n\t    errormsg = _(e_not_allowed_in_sandbox);\n\t    goto doend;\n\t}\n#endif\n\tif (restricted != 0 && (ea.argt & EX_RESTRICT))\n\t{\n\t    errormsg = _(e_command_not_allowed_in_rvim);\n\t    goto doend;\n\t}\n\tif (!curbuf->b_p_ma && (ea.argt & EX_MODIFY))\n\t{\n\t    \/\/ Command not allowed in non-'modifiable' buffer\n\t    errormsg = _(e_cannot_make_changes_modifiable_is_off);\n\t    goto doend;\n\t}\n\n\tif (!IS_USER_CMDIDX(ea.cmdidx))\n\t{\n#ifdef FEAT_CMDWIN\n\t    if (cmdwin_type != 0 && !(ea.argt & EX_CMDWIN))\n\t    {\n\t\t\/\/ Command not allowed in the command line window\n\t\terrormsg = _(e_invalid_in_cmdline_window);\n\t\tgoto doend;\n\t    }\n#endif\n\t    if (text_locked() && !(ea.argt & EX_LOCK_OK))\n\t    {\n\t\t\/\/ Command not allowed when text is locked\n\t\terrormsg = _(get_text_locked_msg());\n\t\tgoto doend;\n\t    }\n\t}\n\n\t\/\/ Disallow editing another buffer when \"curbuf_lock\" is set.\n\t\/\/ Do allow \":checktime\" (it is postponed).\n\t\/\/ Do allow \":edit\" (check for an argument later).\n\t\/\/ Do allow \":file\" with no arguments (check for an argument later).\n\tif (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK))\n\t\t&& ea.cmdidx != CMD_checktime\n\t\t&& ea.cmdidx != CMD_edit\n\t\t&& ea.cmdidx != CMD_file\n\t\t&& !IS_USER_CMDIDX(ea.cmdidx)\n\t\t&& curbuf_locked())\n\t    goto doend;\n\n\tif (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0)\n\t{\n\t    errormsg = _(e_no_range_allowed);\n\t    goto doend;\n\t}\n    }\n\n    if (!ni && !(ea.argt & EX_BANG) && ea.forceit)\n    {\n\terrormsg = _(e_no_bang_allowed);\n\tgoto doend;\n    }\n\n    \/*\n     * Don't complain about the range if it is not used\n     * (could happen if line_count is accidentally set to 0).\n     *\/\n    if (!ea.skip && !ni && (ea.argt & EX_RANGE))\n    {\n\t\/*\n\t * If the range is backwards, ask for confirmation and, if given, swap\n\t * ea.line1 & ea.line2 so it's forwards again.\n\t * When global command is busy, don't ask, will fail below.\n\t *\/\n\tif (!global_busy && ea.line1 > ea.line2)\n\t{\n\t    if (msg_silent == 0)\n\t    {\n\t\tif (sourcing || exmode_active)\n\t\t{\n\t\t    errormsg = _(e_backwards_range_given);\n\t\t    goto doend;\n\t\t}\n\t\tif (ask_yesno((char_u *)\n\t\t\t_(\"Backwards range given, OK to swap\"), FALSE) != 'y')\n\t\t    goto doend;\n\t    }\n\t    lnum = ea.line1;\n\t    ea.line1 = ea.line2;\n\t    ea.line2 = lnum;\n\t}\n\tif ((errormsg = invalid_range(&ea)) != NULL)\n\t    goto doend;\n    }\n\n    if ((ea.addr_type == ADDR_OTHER) && ea.addr_count == 0)\n\t\/\/ default is 1, not cursor\n\tea.line2 = 1;\n\n    correct_range(&ea);\n\n#ifdef FEAT_FOLDING\n    if (((ea.argt & EX_WHOLEFOLD) || ea.addr_count >= 2) && !global_busy\n\t    && ea.addr_type == ADDR_LINES)\n    {\n\t\/\/ Put the first line at the start of a closed fold, put the last line\n\t\/\/ at the end of a closed fold.\n\t(void)hasFolding(ea.line1, &ea.line1, NULL);\n\t(void)hasFolding(ea.line2, NULL, &ea.line2);\n    }\n#endif\n\n#ifdef FEAT_QUICKFIX\n    \/*\n     * For the \":make\" and \":grep\" commands we insert the 'makeprg'\/'grepprg'\n     * option here, so things like % get expanded.\n     *\/\n    p = replace_makeprg(&ea, p, cmdlinep);\n    if (p == NULL)\n\tgoto doend;\n#endif\n\n    \/*\n     * Skip to start of argument.\n     * Don't do this for the \":!\" command, because \":!! -l\" needs the space.\n     *\/\n    if (ea.cmdidx == CMD_bang)\n\tea.arg = p;\n    else\n\tea.arg = skipwhite(p);\n\n    \/\/ \":file\" cannot be run with an argument when \"curbuf_lock\" is set\n    if (ea.cmdidx == CMD_file && *ea.arg != NUL && curbuf_locked())\n\tgoto doend;\n\n    \/*\n     * Check for \"++opt=val\" argument.\n     * Must be first, allow \":w ++enc=utf8 !cmd\"\n     *\/\n    if (ea.argt & EX_ARGOPT)\n\twhile (ea.arg[0] == '+' && ea.arg[1] == '+')\n\t    if (getargopt(&ea) == FAIL && !ni)\n\t    {\n\t\terrormsg = _(e_invalid_argument);\n\t\tgoto doend;\n\t    }\n\n    if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update)\n    {\n\tif (*ea.arg == '>')\t\t\t\/\/ append\n\t{\n\t    if (*++ea.arg != '>')\t\t\/\/ typed wrong\n\t    {\n\t\terrormsg = _(e_use_w_or_w_gt_gt);\n\t\tgoto doend;\n\t    }\n\t    ea.arg = skipwhite(ea.arg + 1);\n\t    ea.append = TRUE;\n\t}\n\telse if (*ea.arg == '!' && ea.cmdidx == CMD_write)  \/\/ :w !filter\n\t{\n\t    ++ea.arg;\n\t    ea.usefilter = TRUE;\n\t}\n    }\n\n    if (ea.cmdidx == CMD_read)\n    {\n\tif (ea.forceit)\n\t{\n\t    ea.usefilter = TRUE;\t\t\/\/ :r! filter if ea.forceit\n\t    ea.forceit = FALSE;\n\t}\n\telse if (*ea.arg == '!')\t\t\/\/ :r !filter\n\t{\n\t    ++ea.arg;\n\t    ea.usefilter = TRUE;\n\t}\n    }\n\n    if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift)\n    {\n\tea.amount = 1;\n\twhile (*ea.arg == *ea.cmd)\t\t\/\/ count number of '>' or '<'\n\t{\n\t    ++ea.arg;\n\t    ++ea.amount;\n\t}\n\tea.arg = skipwhite(ea.arg);\n    }\n\n    \/*\n     * Check for \"+command\" argument, before checking for next command.\n     * Don't do this for \":read !cmd\" and \":write !cmd\".\n     *\/\n    if ((ea.argt & EX_CMDARG) && !ea.usefilter)\n\tea.do_ecmd_cmd = getargcmd(&ea.arg);\n\n    \/*\n     * For commands that do not use '|' inside their argument: Check for '|' to\n     * separate commands and '\"' or '#' to start comments.\n     *\n     * Otherwise: Check for <newline> to end a shell command.\n     * Also do this for \":read !cmd\", \":write !cmd\" and \":global\".\n     * Also do this inside a { - } block after :command and :autocmd.\n     * Any others?\n     *\/\n    if ((ea.argt & EX_TRLBAR) && !ea.usefilter)\n    {\n\tseparate_nextcmd(&ea, FALSE);\n    }\n    else if (ea.cmdidx == CMD_bang\n\t    || ea.cmdidx == CMD_terminal\n\t    || ea.cmdidx == CMD_global\n\t    || ea.cmdidx == CMD_vglobal\n\t    || ea.usefilter\n#ifdef FEAT_EVAL\n\t    || inside_block(&ea)\n#endif\n\t    )\n    {\n\tfor (p = ea.arg; *p; ++p)\n\t{\n\t    \/\/ Remove one backslash before a newline, so that it's possible to\n\t    \/\/ pass a newline to the shell and also a newline that is preceded\n\t    \/\/ with a backslash.  This makes it impossible to end a shell\n\t    \/\/ command in a backslash, but that doesn't appear useful.\n\t    \/\/ Halving the number of backslashes is incompatible with previous\n\t    \/\/ versions.\n\t    if (*p == '\\\\' && p[1] == '\\n')\n\t\tSTRMOVE(p, p + 1);\n\t    else if (*p == '\\n' && !(ea.argt & EX_EXPR_ARG))\n\t    {\n\t\tea.nextcmd = p + 1;\n\t\t*p = NUL;\n\t\tbreak;\n\t    }\n\t}\n    }\n\n    if ((ea.argt & EX_DFLALL) && ea.addr_count == 0)\n\taddress_default_all(&ea);\n\n    \/\/ accept numbered register only when no count allowed (:put)\n    if (       (ea.argt & EX_REGSTR)\n\t    && *ea.arg != NUL\n\t       \/\/ Do not allow register = for user commands\n\t    && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')\n\t    && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)))\n    {\n#ifndef FEAT_CLIPBOARD\n\t\/\/ check these explicitly for a more specific error message\n\tif (*ea.arg == '*' || *ea.arg == '+')\n\t{\n\t    errormsg = _(e_invalid_register_name);\n\t    goto doend;\n\t}\n#endif\n\tif (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put\n\t\t\t\t\t      && !IS_USER_CMDIDX(ea.cmdidx))))\n\t{\n\t    ea.regname = *ea.arg++;\n#ifdef FEAT_EVAL\n\t    \/\/ for '=' register: accept the rest of the line as an expression\n\t    if (ea.arg[-1] == '=' && ea.arg[0] != NUL)\n\t    {\n\t\tif (!ea.skip)\n\t\t{\n\t\t    set_expr_line(vim_strsave(ea.arg), &ea);\n\t\t    did_set_expr_line = TRUE;\n\t\t}\n\t\tea.arg += STRLEN(ea.arg);\n\t    }\n#endif\n\t    ea.arg = skipwhite(ea.arg);\n\t}\n    }\n\n    \/*\n     * Check for a count.  When accepting a EX_BUFNAME, don't use \"123foo\" as a\n     * count, it's a buffer name.\n     *\/\n    if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)\n\t    && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL\n\t\t\t\t\t\t\t  || VIM_ISWHITE(*p)))\n    {\n\tn = getdigits_quoted(&ea.arg);\n\tea.arg = skipwhite(ea.arg);\n\tif (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0)\n\t{\n\t    errormsg = _(e_positive_count_required);\n\t    goto doend;\n\t}\n\tif (ea.addr_type != ADDR_LINES)\t\/\/ e.g. :buffer 2, :sleep 3\n\t{\n\t    ea.line2 = n;\n\t    if (ea.addr_count == 0)\n\t\tea.addr_count = 1;\n\t}\n\telse\n\t{\n\t    ea.line1 = ea.line2;\n\t    if (ea.line2 >= LONG_MAX - (n - 1))\n\t\tea.line2 = LONG_MAX;  \/\/ avoid overflow\n\t    else\n\t\tea.line2 += n - 1;\n\t    ++ea.addr_count;\n\t    \/*\n\t     * Be vi compatible: no error message for out of range.\n\t     *\/\n\t    if (ea.line2 > curbuf->b_ml.ml_line_count)\n\t\tea.line2 = curbuf->b_ml.ml_line_count;\n\t}\n    }\n\n    \/*\n     * Check for flags: 'l', 'p' and '#'.\n     *\/\n    if (ea.argt & EX_FLAGS)\n\tget_flags(&ea);\n    if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL\n\t    && *ea.arg != '\"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0))\n    {\n\t\/\/ no arguments allowed but there is something\n\terrormsg = ex_errmsg(e_trailing_characters_str, ea.arg);\n\tgoto doend;\n    }\n\n    if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL)\n    {\n\terrormsg = _(e_argument_required);\n\tgoto doend;\n    }\n\n#ifdef FEAT_EVAL\n    \/*\n     * Skip the command when it's not going to be executed.\n     * The commands like :if, :endif, etc. always need to be executed.\n     * Also make an exception for commands that handle a trailing command\n     * themselves.\n     *\/\n    if (ea.skip)\n    {\n\tswitch (ea.cmdidx)\n\t{\n\t    \/\/ commands that need evaluation\n\t    case CMD_while:\n\t    case CMD_endwhile:\n\t    case CMD_for:\n\t    case CMD_endfor:\n\t    case CMD_if:\n\t    case CMD_elseif:\n\t    case CMD_else:\n\t    case CMD_endif:\n\t    case CMD_try:\n\t    case CMD_catch:\n\t    case CMD_finally:\n\t    case CMD_endtry:\n\t    case CMD_function:\n\t    case CMD_def:\n\t\t\t\tbreak;\n\n\t    \/\/ Commands that handle '|' themselves.  Check: A command should\n\t    \/\/ either have the EX_TRLBAR flag, appear in this list or appear in\n\t    \/\/ the list at \":help :bar\".\n\t    case CMD_aboveleft:\n\t    case CMD_and:\n\t    case CMD_belowright:\n\t    case CMD_botright:\n\t    case CMD_browse:\n\t    case CMD_call:\n\t    case CMD_confirm:\n\t    case CMD_const:\n\t    case CMD_delfunction:\n\t    case CMD_djump:\n\t    case CMD_dlist:\n\t    case CMD_dsearch:\n\t    case CMD_dsplit:\n\t    case CMD_echo:\n\t    case CMD_echoerr:\n\t    case CMD_echomsg:\n\t    case CMD_echon:\n\t    case CMD_eval:\n\t    case CMD_execute:\n\t    case CMD_filter:\n\t    case CMD_final:\n\t    case CMD_help:\n\t    case CMD_hide:\n\t    case CMD_ijump:\n\t    case CMD_ilist:\n\t    case CMD_isearch:\n\t    case CMD_isplit:\n\t    case CMD_keepalt:\n\t    case CMD_keepjumps:\n\t    case CMD_keepmarks:\n\t    case CMD_keeppatterns:\n\t    case CMD_leftabove:\n\t    case CMD_let:\n\t    case CMD_lockmarks:\n\t    case CMD_lockvar:\n\t    case CMD_lua:\n\t    case CMD_match:\n\t    case CMD_mzscheme:\n\t    case CMD_noautocmd:\n\t    case CMD_noswapfile:\n\t    case CMD_perl:\n\t    case CMD_psearch:\n\t    case CMD_py3:\n\t    case CMD_python3:\n\t    case CMD_python:\n\t    case CMD_return:\n\t    case CMD_rightbelow:\n\t    case CMD_ruby:\n\t    case CMD_silent:\n\t    case CMD_smagic:\n\t    case CMD_snomagic:\n\t    case CMD_substitute:\n\t    case CMD_syntax:\n\t    case CMD_tab:\n\t    case CMD_tcl:\n\t    case CMD_throw:\n\t    case CMD_tilde:\n\t    case CMD_topleft:\n\t    case CMD_unlet:\n\t    case CMD_unlockvar:\n\t    case CMD_var:\n\t    case CMD_verbose:\n\t    case CMD_vertical:\n\t    case CMD_wincmd:\n\t\t\t\tbreak;\n\n\t    default:\t\tgoto doend;\n\t}\n    }\n#endif\n\n    if (ea.argt & EX_XFILE)\n    {\n\tif (expand_filename(&ea, cmdlinep, &errormsg) == FAIL)\n\t    goto doend;\n    }\n\n    \/*\n     * Accept buffer name.  Cannot be used at the same time with a buffer\n     * number.  Don't do this for a user command.\n     *\/\n    if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0\n\t    && !IS_USER_CMDIDX(ea.cmdidx))\n    {\n\t\/*\n\t * :bdelete, :bwipeout and :bunload take several arguments, separated\n\t * by spaces: find next space (skipping over escaped characters).\n\t * The others take one argument: ignore trailing spaces.\n\t *\/\n\tif (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout\n\t\t\t\t\t\t  || ea.cmdidx == CMD_bunload)\n\t    p = skiptowhite_esc(ea.arg);\n\telse\n\t{\n\t    p = ea.arg + STRLEN(ea.arg);\n\t    while (p > ea.arg && VIM_ISWHITE(p[-1]))\n\t\t--p;\n\t}\n\tea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,\n\t\t\t\t\t\t\t\tFALSE, FALSE);\n\tif (ea.line2 < 0)\t    \/\/ failed\n\t    goto doend;\n\tea.addr_count = 1;\n\tea.arg = skipwhite(p);\n    }\n\n    \/\/ The :try command saves the emsg_silent flag, reset it here when\n    \/\/ \":silent! try\" was used, it should only apply to :try itself.\n    if (ea.cmdidx == CMD_try && cmdmod.cmod_did_esilent > 0)\n    {\n\temsg_silent -= cmdmod.cmod_did_esilent;\n\tif (emsg_silent < 0)\n\t    emsg_silent = 0;\n\tcmdmod.cmod_did_esilent = 0;\n    }\n\n\/*\n * 7. Execute the command.\n *\/\n\n    if (IS_USER_CMDIDX(ea.cmdidx))\n    {\n\t\/*\n\t * Execute a user-defined command.\n\t *\/\n\tdo_ucmd(&ea);\n    }\n    else\n    {\n\t\/*\n\t * Call the function to execute the builtin command.\n\t *\/\n\tea.errmsg = NULL;\n\t(cmdnames[ea.cmdidx].cmd_func)(&ea);\n\tif (ea.errmsg != NULL)\n\t    errormsg = ea.errmsg;\n    }\n\n#ifdef FEAT_EVAL\n    \/\/ Set flag that any command was executed, used by ex_vim9script().\n    \/\/ Not if this was a command that wasn't executed or :endif.\n    if (sourcing_a_script(&ea)\n\t    && current_sctx.sc_sid > 0\n\t    && ea.cmdidx != CMD_endif\n\t    && (cstack->cs_idx < 0\n\t\t    || (cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)))\n\tSCRIPT_ITEM(current_sctx.sc_sid)->sn_state = SN_STATE_HAD_COMMAND;\n\n    \/*\n     * If the command just executed called do_cmdline(), any throw or \":return\"\n     * or \":finish\" encountered there must also check the cstack of the still\n     * active do_cmdline() that called this do_one_cmd().  Rethrow an uncaught\n     * exception, or reanimate a returned function or finished script file and\n     * return or finish it again.\n     *\/\n    if (need_rethrow)\n\tdo_throw(cstack);\n    else if (check_cstack)\n    {\n\tif (source_finished(fgetline, cookie))\n\t    do_finish(&ea, TRUE);\n\telse if (getline_equal(fgetline, cookie, get_func_line)\n\t\t\t\t\t\t   && current_func_returned())\n\t    do_return(&ea, TRUE, FALSE, NULL);\n    }\n    need_rethrow = check_cstack = FALSE;\n#endif\n\ndoend:\n    if (curwin->w_cursor.lnum == 0)\t\/\/ can happen with zero line number\n    {\n\tcurwin->w_cursor.lnum = 1;\n\tcurwin->w_cursor.col = 0;\n    }\n\n    if (errormsg != NULL && *errormsg != NUL && !did_emsg)\n    {\n\tif ((sourcing || !KeyTyped) && !did_append_cmd)\n\t{\n\t    if (errormsg != (char *)IObuff)\n\t    {\n\t\tSTRCPY(IObuff, errormsg);\n\t\terrormsg = (char *)IObuff;\n\t    }\n\t    append_command(*cmdlinep);\n\t}\n\temsg(errormsg);\n    }\n#ifdef FEAT_EVAL\n    do_errthrow(cstack,\n\t    (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx))\n\t\t\t? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);\n\n    if (did_set_expr_line)\n\tset_expr_line(NULL, NULL);\n#endif\n\n    undo_cmdmod(&cmdmod);\n    cmdmod = save_cmdmod;\n    reg_executing = save_reg_executing;\n    pending_end_reg_executing = save_pending_end_reg_executing;\n\n    if (ea.nextcmd && *ea.nextcmd == NUL)\t\/\/ not really a next command\n\tea.nextcmd = NULL;\n\n#ifdef FEAT_EVAL\n    --ex_nesting_level;\n    vim_free(ea.cmdline_tofree);\n#endif\n\n    return ea.nextcmd;\n}","target":0,"code_token_length":7125,"total_token_length":7361,"max_tokens_setting":8192}
+{"idx":199952,"func":"mp_sint32 LoaderXM::load(XMFileBase& f, XModule* module)\n{\n\tmp_ubyte insData[230];\t\t\n\tmp_sint32 smpReloc[MP_MAXINSSAMPS];\n\tmp_ubyte nbu[MP_MAXINSSAMPS];\n\tmp_uint32 fileSize = 0;\n\t\t\t\n\tmodule->cleanUp();\n\n\t\/\/ this will make code much easier to read\n\tTXMHeader*\t\theader = &module->header;\n\tTXMInstrument*\tinstr  = module->instr;\n\tTXMSample*\t\tsmp\t   = module->smp;\n\tTXMPattern*\t\tphead  = module->phead;\t\n\n\t\/\/ we're already out of memory here\n\tif (!phead || !instr || !smp)\n\t\treturn MP_OUT_OF_MEMORY;\n\t\n\tfileSize = f.sizeWithBaseOffset();\n\t\n\tf.read(&header->sig,1,17);\n\tf.read(&header->name,1,20);\n\tf.read(&header->whythis1a,1,1);\n\theader->whythis1a=0;\n\tf.read(&header->tracker,1,20);\n\tf.readWords(&header->ver,1);\n\t\n\tif (header->ver != 0x102 && \n\t\theader->ver != 0x103 && \/\/ untested\n\t\theader->ver != 0x104)\n\t\treturn MP_LOADER_FAILED;\n\t\n\tf.readDwords(&header->hdrsize,1);\n\t\n\theader->hdrsize-=4;\n\t\n\tmp_uint32 hdrSize = 0x110;\n\tif (header->hdrsize > hdrSize)\n\t\thdrSize = header->hdrsize;\n\t\t\t\t\n\tmp_ubyte* hdrBuff = new mp_ubyte[hdrSize];\n\tmemset(hdrBuff, 0, hdrSize);\n\t\n\tf.read(hdrBuff, 1, header->hdrsize);\n\t\n\theader->ordnum = LittleEndian::GET_WORD(hdrBuff);\n\theader->restart = LittleEndian::GET_WORD(hdrBuff+2);\n\theader->channum = LittleEndian::GET_WORD(hdrBuff+4);\n\theader->patnum = LittleEndian::GET_WORD(hdrBuff+6);\n\theader->insnum = LittleEndian::GET_WORD(hdrBuff+8);\n\theader->freqtab = LittleEndian::GET_WORD(hdrBuff+10);\n\theader->tempo = LittleEndian::GET_WORD(hdrBuff+12);\n\theader->speed = LittleEndian::GET_WORD(hdrBuff+14);\n\tmemcpy(header->ord, hdrBuff+16, 256);\n\tif(header->ordnum > MP_MAXORDERS)\n\t\theader->ordnum = MP_MAXORDERS;\n\tif(header->insnum > MP_MAXINS)\n\t\treturn MP_LOADER_FAILED;\n\n\tdelete[] hdrBuff;\n\t\n\theader->mainvol=255;\n\theader->flags = XModule::MODULE_XMNOTECLIPPING | \n\t\tXModule::MODULE_XMARPEGGIO | \n\t\tXModule::MODULE_XMPORTANOTEBUFFER | \n\t\tXModule::MODULE_XMVOLCOLUMNVIBRATO;\n\n\theader->uppernotebound = 119;\n\t\n\tmp_sint32 i,y,sc;\n\tfor (i=0;i<32;i++) header->pan[i]=0x80;\n\t\n\t\/\/ old version?\n\tif (header->ver == 0x102 || header->ver == 0x103)\n\t{\n\t\tmp_sint32 s = 0;\n\t\tmp_sint32 e = 0;\n\t\tfor (y=0;y<header->insnum;y++) {\n\t\t\t\n\t\t\tf.readDwords(&instr[y].size,1);\n\t\t\tf.read(&instr[y].name,1,22);\t\t\n\t\t\tf.read(&instr[y].type,1,1);\n\t\t\tmp_uword numSamples = 0;\n\t\t\tf.readWords(&numSamples,1);\n\t\t\tif(numSamples > MP_MAXINSSAMPS)\n\t\t\t\treturn MP_LOADER_FAILED;\n\t\t\tinstr[y].samp = numSamples;\n\n\t\t\tif (instr[y].size == 29)\n\t\t\t{\n#ifdef MILKYTRACKER\n\t\t\t\ts+=16;\n#endif\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tf.readDwords(&instr[y].shsize,1);\n\n\t\t\tmemset(insData, 0, 230);\n\t\t\t\n\t\t\tif (instr[y].size - 33 > 230)\n\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\n\t\t\tf.read(insData, 1, instr[y].size - 33);\n\t\t\t\t\t\t\n\t\t\tif (instr[y].samp) {\n\t\t\t\tmp_ubyte* insDataPtr = insData;\n\t\t\t\t\n\t\t\t\tmemcpy(nbu, insDataPtr, MP_MAXINSSAMPS);\n\t\t\t\tinsDataPtr+=MP_MAXINSSAMPS;\n\t\t\t\t\n\t\t\t\tTEnvelope venv;\n\t\t\t\tTEnvelope penv;\n\t\t\t\tmemset(&venv,0,sizeof(venv));\n\t\t\t\tmemset(&penv,0,sizeof(penv));\n\t\t\t\t\n\t\t\t\tmp_sint32 k;\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tvenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tvenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tpenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tpenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvenv.num = *insDataPtr++;\t\n\t\t\t\tif (venv.num > XM_ENVELOPENUMPOINTS) venv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tpenv.num = *insDataPtr++;\t\n\t\t\t\tif (penv.num > XM_ENVELOPENUMPOINTS) penv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tvenv.sustain = *insDataPtr++;\n\t\t\t\tvenv.loops = *insDataPtr++;\n\t\t\t\tvenv.loope = *insDataPtr++;\n\t\t\t\tpenv.sustain = *insDataPtr++;\n\t\t\t\tpenv.loops = *insDataPtr++;\n\t\t\t\tpenv.loope = *insDataPtr++;\n\t\t\t\tvenv.type = *insDataPtr++;\n\t\t\t\tpenv.type = *insDataPtr++;\t\t\t\t\n\t\t\t\t\n\t\t\t\tmp_ubyte vibtype, vibsweep, vibdepth, vibrate;\n\t\t\t\tmp_uword volfade;\n\t\t\t\t\n\t\t\t\tvibtype = *insDataPtr++;\n\t\t\t\tvibsweep = *insDataPtr++;\n\t\t\t\tvibdepth = *insDataPtr++;\n\t\t\t\tvibrate = *insDataPtr++;\n\t\t\t\t\n\t\t\t\tvibdepth<<=1;\n\t\t\t\t\n\t\t\t\tvolfade = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\tvolfade<<=1;\n\t\t\t\t\n\t\t\t\t\/\/instr[y].res = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\t\n\t\t\t\tfor (mp_sint32 l=0;l<XM_ENVELOPENUMPOINTS;l++) {\n\t\t\t\t\tvenv.env[l][1]<<=2;\n\t\t\t\t\tpenv.env[l][1]<<=2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!module->addVolumeEnvelope(venv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\tif (!module->addPanningEnvelope(penv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t\n\t\t\t\tmp_sint32 g=0, sc;\n\t\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].flags=3;\n\t\t\t\t\tsmp[g+s].venvnum=e+1;\n\t\t\t\t\tsmp[g+s].penvnum=e+1;\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].vibtype=vibtype;\n\t\t\t\t\tsmp[g+s].vibsweep=vibsweep;\n\t\t\t\t\tsmp[g+s].vibdepth=vibdepth;\n\t\t\t\t\tsmp[g+s].vibrate=vibrate;\n\t\t\t\t\tsmp[g+s].volfade=volfade;\n\t\t\t\t\t\n\t\t\t\t\t\/\/ not sure why I did that, actually doesn't make sense\n\t\t\t\t\t\/\/if (!(venv.type&1)) smp[g+s].volfade=0;\n\t\t\t\t\t\n\t\t\t\t\tf.readDwords(&smp[g+s].samplen,1);\n\t\t\t\t\tf.readDwords(&smp[g+s].loopstart,1);\n\t\t\t\t\tf.readDwords(&smp[g+s].looplen,1);\n\t\t\t\t\tsmp[g+s].vol=XModule::vol64to255(f.readByte());\n\t\t\t\t\t\/\/f.read(&smp[g+s].vol,1,1);\n\t\t\t\t\tf.read(&smp[g+s].finetune,1,1);\n\t\t\t\t\tf.read(&smp[g+s].type,1,1);\n#ifdef VERBOSE\n\t\t\t\t\tprintf(\"Before: %i, After: %i\\n\", smp[g+s].type, smp[g+s].type & (3+16));\n#endif\n\t\t\t\t\tf.read(&smp[g+s].pan,1,1);\n\t\t\t\t\tf.read(&smp[g+s].relnote,1,1);\n\t\t\t\t\tf.read(&smp[g+s].res,1,1);\n\t\t\t\t\tf.read(&smp[g+s].name,1,22);\n\t\t\t\t\t\n\t\t\t\t\tchar line[30];\n\t\t\t\t\tmemset(line, 0, sizeof(line));\n\t\t\t\t\tXModule::convertStr(line, smp[g+s].name, 23, false);\t\t\t\t\t\n\t\t\t\t\tif (line[0])\n\t\t\t\t\t\tmodule->addSongMessageLine(line);\n\t\t\t\t\t\n\t\t\t\t\t\/\/ ignore empty samples\n#ifndef MILKYTRACKER\n\t\t\t\t\t\/\/ ignore empty samples when not being a tracker\n\t\t\t\t\tif (smp[g+s].samplen) {\n\t\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\t\tg++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsmpReloc[sc] = -1;\n#else\n\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\tg++;\n#endif\n\t\t\t\t}\n\n\t\t\t\tinstr[y].samp = g;\n\n\t\t\t\tfor (sc = 0; sc < MP_MAXINSSAMPS; sc++) {\n\t\t\t\t\tif (smpReloc[nbu[sc]] == -1)\n\t\t\t\t\t\tinstr[y].snum[sc] = -1;\n\t\t\t\t\telse\n\t\t\t\t\t\tinstr[y].snum[sc] = smpReloc[nbu[sc]]+s;\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\te++;\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t}\n\n#ifdef MILKYTRACKER\n\t\t\ts+=16;\n#else\n\t\t\ts+=instr[y].samp;\n#endif\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\theader->smpnum=s;\n\t\theader->volenvnum=e;\n\t\theader->panenvnum=e;\n\t}\n\t\n\tfor (y=0;y<header->patnum;y++) {\n\t\t\n\t\tif (header->ver == 0x104 || header->ver == 0x103)\n\t\t{\n\t\t\tf.readDwords(&phead[y].len,1);\n\t\t\tf.read(&phead[y].ptype,1,1);\n\t\t\tf.readWords(&phead[y].rows,1);\n\t\t\tf.readWords(&phead[y].patdata,1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tf.readDwords(&phead[y].len,1);\n\t\t\tf.read(&phead[y].ptype,1,1);\n\t\t\tphead[y].rows = (mp_uword)f.readByte()+1;\n\t\t\tf.readWords(&phead[y].patdata,1);\t\t\t\n\t\t}\n\t\t\n\t\tphead[y].effnum=2;\n\t\tphead[y].channum=(mp_ubyte)header->channum;\n\t\t\n\t\tphead[y].patternData = new mp_ubyte[phead[y].rows*header->channum*6];\n\t\t\n\t\t\/\/ out of memory?\n\t\tif (phead[y].patternData == NULL)\n\t\t{\n\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t}\n\t\t\n\t\tmemset(phead[y].patternData,0,phead[y].rows*header->channum*6);\n\t\t\n\t\tif (phead[y].patdata) {\n\t\t\tmp_ubyte *buffer = new mp_ubyte[phead[y].patdata];\n\t\t\t\n\t\t\t\/\/ out of memory?\n\t\t\tif (buffer == NULL)\n\t\t\t{\n\t\t\t\treturn MP_OUT_OF_MEMORY;\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\tf.read(buffer,1,phead[y].patdata);\n\t\t\t\n\t\t\t\/\/printf(\"%i\\n\", phead[y].patdata);\n\t\t\t\n\t\t\tmp_sint32 pc = 0, bc = 0;\n\t\t\tfor (mp_sint32 r=0;r<phead[y].rows;r++) {\n\t\t\t\tfor (mp_sint32 c=0;c<header->channum;c++) {\n\t\t\t\t\t\n\t\t\t\t\tmp_ubyte slot[5];\n\t\t\t\t\tmemset(slot,0,5);\n\t\t\t\t\t\n\t\t\t\t\tif ((buffer[pc]&128)) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tmp_ubyte pb = buffer[pc];\n\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif ((pb&1)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc]=buffer[pc];\n\t\t\t\t\t\t\tslot[0]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&2)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+1]=buffer[pc];\n\t\t\t\t\t\t\tslot[1]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&4)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+2]=buffer[pc];\n\t\t\t\t\t\t\tslot[2]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&8)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+3]=buffer[pc];\n\t\t\t\t\t\t\tslot[3]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pb&16)) {\n\t\t\t\t\t\t\t\/\/phead[y].patternData[bc+4]=buffer[pc];\n\t\t\t\t\t\t\tslot[4]=buffer[pc];\n\t\t\t\t\t\t\tpc++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t\/\/memcpy(phead[y].patternData+bc,buffer+pc,5);\n\t\t\t\t\t\tmemcpy(slot,buffer+pc,5);\n\t\t\t\t\t\tpc+=5;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tchar gl=0;\n\t\t\t\t\tfor (mp_sint32 i=0;i<XModule::numValidXMEffects;i++)\n\t\t\t\t\t\tif (slot[3]==XModule::validXMEffects[i]) gl=1;\n\t\t\t\t\t\n\t\t\t\t\tif (!gl) slot[3]=slot[4]=0;\n\t\t\t\t\t\n\t\t\t\t\tif ((slot[3]==0xC)||(slot[3]==0x10)) {\n\t\t\t\t\t\tslot[4] = XModule::vol64to255(slot[4]);\n\t\t\t\t\t\t\/*mp_sint32 bl = slot[4];\n\t\t\t\t\t\tif (bl>64) bl=64;\n\t\t\t\t\t\tslot[4]=(bl*261120)>>16;*\/\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif ((!slot[3])&&(slot[4])) slot[3]=0x20;\n\t\t\t\t\t\n\t\t\t\t\tif (slot[3]==0xE) {\n\t\t\t\t\t\tslot[3]=(slot[4]>>4)+0x30;\n\t\t\t\t\t\tslot[4]=slot[4]&0xf;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (slot[3]==0x21) {\n\t\t\t\t\t\tslot[3]=(slot[4]>>4)+0x40;\n\t\t\t\t\t\tslot[4]=slot[4]&0xf;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (slot[0]==97) slot[0]=XModule::NOTE_OFF;\n\t\t\t\t\t\n\t\t\t\t\tphead[y].patternData[bc]=slot[0];\n\t\t\t\t\tphead[y].patternData[bc+1]=slot[1];\n\t\t\t\t\t\n\t\t\t\t\tXModule::convertXMVolumeEffects(slot[2], phead[y].patternData[bc+2], phead[y].patternData[bc+3]);\n\n\t\t\t\t\tphead[y].patternData[bc+4]=slot[3];\n\t\t\t\t\tphead[y].patternData[bc+5]=slot[4];\n\t\t\t\t\t\n\t\t\t\t\t\/*if ((y==3)&&(c==2)) {\n\t\t\t\t\t\tfor (mp_sint32 bl=0;bl<6;bl++) cprintf(\"%x \",phead[y].patternData[bc+bl]);\n\t\t\t\t\tcprintf(\"\\r\\n\");\n\t\t\t\t\tgetch();\n\t\t\t\t\t};*\/\n\t\t\t\t\t\n\t\t\t\t\t\/*printf(\"Note : %i\\r\\n\",phead[y].patternData[bc]);\n\t\t\t\t\tprintf(\"Ins  : %i\\r\\n\",phead[y].patternData[bc+1]);\n\t\t\t\t\tprintf(\"Vol  : %i\\r\\n\",phead[y].patternData[bc+2]);\n\t\t\t\t\tprintf(\"Eff  : %i\\r\\n\",phead[y].patternData[bc+3]);\n\t\t\t\t\tprintf(\"Effop: %i\\r\\n\",phead[y].patternData[bc+4]);\n\t\t\t\t\tgetch();*\/\n\t\t\t\t\t\n\t\t\t\t\tbc+=6;\n\t\t\t\t} \/\/ for c\n\t\t\t\t\t\n\t\t\t} \/\/ for r\n\t\t\t\t\n\t\t\tdelete[] buffer;\n\t\t}\n\t\t\t\n\t}\n\t\t\n\tif (header->ver == 0x104)\n\t{\n\t\tmp_sint32 s = 0;\n\t\tmp_sint32 e = 0;\n\t\tfor (y=0;y<header->insnum;y++) {\n\n\t\t\t\/\/ fixes MOOH.XM loading problems\n\t\t\t\/\/ seems to store more instruments in the header than in the actual file\n\t\t\tif (f.posWithBaseOffset() >= fileSize)\n\t\t\t\tbreak;\n\t\t\n\t\t\t\/\/TXMInstrument* ins = &instr[y];\n\t\t\n\t\t\tf.readDwords(&instr[y].size,1);\n\t\t\t\n\t\t\tif (instr[y].size < 29)\n\t\t\t{\n\t\t\t\tmp_ubyte buffer[29];\n\t\t\t\tmemset(buffer, 0, sizeof(buffer));\n\t\t\t\tf.read(buffer, 1, instr[y].size - 4);\n\t\t\t\tmemcpy(instr[y].name, buffer, 22);\n\t\t\t\tinstr[y].type = buffer[22];\n\t\t\t\tinstr[y].samp = LittleEndian::GET_WORD(buffer + 23);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tf.read(&instr[y].name,1,22);\t\t\n\t\t\t\tf.read(&instr[y].type,1,1);\n\t\t\t\tf.readWords(&instr[y].samp,1);\n\t\t\t}\n\t\t\tif (instr[y].samp > MP_MAXINSSAMPS)\n\t\t\t\treturn MP_LOADER_FAILED;\n\n\t\t\t\/\/printf(\"%i, %i\\n\", instr[y].size, instr[y].samp);\n\n\t\t\tif (instr[y].size <= 29)\n\t\t\t{\n#ifdef MILKYTRACKER\n\t\t\t\ts+=16;\n#endif\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tf.readDwords(&instr[y].shsize,1);\n#ifdef VERBOSE\n\t\t\tprintf(\"%i\/%i: %i, %i, %i, %s\\n\",y,header->insnum-1,instr[y].size,instr[y].shsize,instr[y].samp,instr[y].name);\t\t\t\n#endif\n\t\t\tmemset(insData, 0, 230);\n\t\t\t\n\t\t\tif (instr[y].size - 33 > 230)\n\t\t\t{\n\t\t\t\t\/\/return -7;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tf.read(insData, 1, instr[y].size - 33);\n\t\t\t\n\t\t\t\/*printf(\"%i\\r\\n\",instr[y].size);\n\t\t\tprintf(\"%s\\r\\n\",instr[y].name);\n\t\t\tprintf(\"%i\\r\\n\",instr[y].type);\n\t\t\tprintf(\"%i\\r\\n\",instr[y].samp);\n\t\t\tprintf(\"%i\\r\\n\",instr[y].shsize);*\/\n\t\t\t\/\/getch();\n\t\t\t\t\t\n\t\t\tmemset(smpReloc, 0, sizeof(smpReloc));\n\t\t\t\n\t\t\tif (instr[y].samp) {\n\t\t\t\tmp_ubyte* insDataPtr = insData;\n\t\t\t\t\n\t\t\t\t\/\/f.read(&nbu,1,96);\n\t\t\t\t\n\t\t\t\tmemcpy(nbu, insDataPtr, MP_MAXINSSAMPS);\n\t\t\t\tinsDataPtr+=MP_MAXINSSAMPS;\n\t\t\t\t\n\t\t\t\tTEnvelope venv;\n\t\t\t\tTEnvelope penv;\n\t\t\t\tmemset(&venv,0,sizeof(venv));\n\t\t\t\tmemset(&penv,0,sizeof(penv));\n\t\t\t\t\n\t\t\t\tmp_sint32 k;\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tvenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tvenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\tfor (k = 0; k < XM_ENVELOPENUMPOINTS; k++)\n\t\t\t\t{\n\t\t\t\t\tpenv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\t\tpenv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);\n\t\t\t\t\tinsDataPtr+=4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvenv.num = *insDataPtr++;\t\n\t\t\t\tif (venv.num > XM_ENVELOPENUMPOINTS) venv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tpenv.num = *insDataPtr++;\t\t\t\t\t\n\t\t\t\tif (penv.num > XM_ENVELOPENUMPOINTS) penv.num = XM_ENVELOPENUMPOINTS;\n\t\t\t\tvenv.sustain = *insDataPtr++;\n\t\t\t\tvenv.loops = *insDataPtr++;\n\t\t\t\tvenv.loope = *insDataPtr++;\n\t\t\t\tpenv.sustain = *insDataPtr++;\n\t\t\t\tpenv.loops = *insDataPtr++;\n\t\t\t\tpenv.loope = *insDataPtr++;\n\t\t\t\tvenv.type = *insDataPtr++;\n\t\t\t\tpenv.type = *insDataPtr++;\t\t\t\t\n\t\t\t\t\n\t\t\t\tmp_ubyte vibtype, vibsweep, vibdepth, vibrate;\n\t\t\t\tmp_uword volfade;\n\t\t\t\t\n\t\t\t\tvibtype = *insDataPtr++;\n\t\t\t\tvibsweep = *insDataPtr++;\n\t\t\t\tvibdepth = *insDataPtr++;\n\t\t\t\tvibrate = *insDataPtr++;\n\t\t\t\t\n\t\t\t\tvibdepth<<=1;\n\t\t\t\t\n\t\t\t\t\/\/f.readWords(&volfade,1);\n\t\t\t\tvolfade = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\tvolfade<<=1;\n\t\t\t\t\n\t\t\t\t\/\/instr[y].res = LittleEndian::GET_WORD(insDataPtr);\n\t\t\t\tinsDataPtr+=2;\n\t\t\t\t\n\t\t\t\tfor (mp_sint32 l=0;l<XM_ENVELOPENUMPOINTS;l++) {\n\t\t\t\t\tvenv.env[l][1]<<=2;\n\t\t\t\t\tpenv.env[l][1]<<=2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!module->addVolumeEnvelope(venv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\tif (!module->addPanningEnvelope(penv)) \n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t\n\t\t\t\tmp_sint32 g=0, sc;\n\t\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\t\t\t\t\t\/\/TXMSample* smpl = &smp[g+s];\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].flags=3;\n\t\t\t\t\tsmp[g+s].venvnum=e+1;\n\t\t\t\t\tsmp[g+s].penvnum=e+1;\n\t\t\t\t\t\n\t\t\t\t\tsmp[g+s].vibtype=vibtype;\n\t\t\t\t\tsmp[g+s].vibsweep=vibsweep;\n\t\t\t\t\tsmp[g+s].vibdepth=vibdepth;\n\t\t\t\t\tsmp[g+s].vibrate=vibrate;\n\t\t\t\t\tsmp[g+s].volfade=volfade;\n\t\t\t\t\t\n\t\t\t\t\t\/\/ not sure why I did that, actually doesn't make sense\n\t\t\t\t\t\/\/if (!(venv.type&1)) smp[g+s].volfade=0;\n\t\t\t\t\t\n\t\t\t\t\tf.readDwords(&smp[g+s].samplen,1);\n\t\t\t\t\t\n\t\t\t\t\tf.readDwords(&smp[g+s].loopstart,1);\n\t\t\t\t\tf.readDwords(&smp[g+s].looplen,1);\n\t\t\t\t\tsmp[g+s].vol=XModule::vol64to255(f.readByte());\n\t\t\t\t\t\/\/f.read(&smp[g+s].vol,1,1);\n\t\t\t\t\tf.read(&smp[g+s].finetune,1,1);\n\t\t\t\t\tf.read(&smp[g+s].type,1,1);\n#ifdef VERBOSE\n\t\t\t\t\tprintf(\"Before: %i, After: %i\\n\", smp[g+s].type, smp[g+s].type & (3+16));\n#endif\n\t\t\t\t\tf.read(&smp[g+s].pan,1,1);\n\t\t\t\t\tf.read(&smp[g+s].relnote,1,1);\n\t\t\t\t\tf.read(&smp[g+s].res,1,1);\n\t\t\t\t\tf.read(&smp[g+s].name,1,22);\n\n\t\t\t\t\tchar line[30];\n\t\t\t\t\tmemset(line, 0, sizeof(line));\n\t\t\t\t\tXModule::convertStr(line, smp[g+s].name, 23, false);\t\t\t\t\t\n\t\t\t\t\tif (line[0])\n\t\t\t\t\t\tmodule->addSongMessageLine(line);\n\t\t\t\t\t\n#ifndef MILKYTRACKER\n\t\t\t\t\t\/\/ ignore empty samples when not being a tracker\n\t\t\t\t\tif (smp[g+s].samplen) {\n\t\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\t\tg++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsmpReloc[sc] = -1;\n#else\n\t\t\t\t\tsmpReloc[sc] = g;\n\t\t\t\t\tg++;\n#endif\n\t\t\t\t}\n\n\t\t\t\tinstr[y].samp = g;\n\n\t\t\t\tfor (sc = 0; sc < MP_MAXINSSAMPS; sc++) {\t\t\t\t\t\n\t\t\t\t\tif (smpReloc[nbu[sc]] == -1)\n\t\t\t\t\t\tinstr[y].snum[sc] = -1;\n\t\t\t\t\telse\n\t\t\t\t\t\tinstr[y].snum[sc] = smpReloc[nbu[sc]]+s;\n\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\t\t\t\t\n\t\t\t\t\tif (smp[s].samplen)\n\t\t\t\t\t{\n\t\t\t\t\t\tbool adpcm = (smp[s].res == 0xAD);\n\t\t\t\t\t\n\t\t\t\t\t\tmp_uint32 oldSize = smp[s].samplen;\n\t\t\t\t\t\tif (smp[s].type&16) \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tmp_sint32 result = module->loadModuleSample(f, s, \n\t\t\t\t\t\t\t\t\t\t\t\t\t adpcm ? XModule::ST_PACKING_ADPCM : XModule::ST_DELTA, \n\t\t\t\t\t\t\t\t\t\t\t\t\t adpcm ? (XModule::ST_PACKING_ADPCM | XModule::ST_16BIT) : (XModule::ST_DELTA | XModule::ST_16BIT), \n\t\t\t\t\t\t\t\t\t\t\t\t\t oldSize);\n\t\t\t\t\t\tif (result != MP_OK)\n\t\t\t\t\t\t\treturn result;\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (adpcm)\n\t\t\t\t\t\t\tsmp[s].res = 0;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\ts++;\n\t\t\t\t\t\n\t\t\t\t\tif (s>=MP_MAXSAMPLES)\n\t\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\te++;\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (mp_sint32 i = 0; i < 120; i++)\n\t\t\t\t\tinstr[y].snum[i] = -1;\n\t\t\t}\n\n#ifdef MILKYTRACKER\n\t\t\ts+=16 - instr[y].samp;\n#endif\t\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\theader->smpnum=s;\n\t\theader->volenvnum=e;\n\t\theader->panenvnum=e;\t\t\n\t\t\n\t}\n\telse\n\t{\n\t\tmp_sint32 s = 0;\n\t\tfor (y=0;y<header->insnum;y++) {\n\t\t\tfor (sc=0;sc<instr[y].samp;sc++) {\n\n\t\t\t\tif (smp[s].samplen)\n\t\t\t\t{\n\t\t\t\t\tmp_uint32 oldSize = smp[s].samplen;\n\t\t\t\t\tif (smp[s].type&16) \n\t\t\t\t\t{\n\t\t\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmp_sint32 result = module->loadModuleSample(f, s, XModule::ST_DELTA, XModule::ST_DELTA | XModule::ST_16BIT, oldSize);\n\t\t\t\t\tif (result != MP_OK)\n\t\t\t\t\t\treturn result;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ts++;\n\t\t\t\t\n\t\t\t\tif (s>=MP_MAXSAMPLES)\n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\t\t\t\t\n\t\t\t}\n\t\t\t\n#ifdef MILKYTRACKER\n\t\t\ts+=16 - instr[y].samp;\n#endif\n\t\t\t\n\t\t}\t\t\n\t}\n\t\n\t\/\/ convert modplug stereo samples\n\tfor (mp_sint32 s = 0; s < header->smpnum; s++)\n\t{\n\t\tif (smp[s].type & 32)\n\t\t{\t\t\n\t\t\t\/\/ that's what's allowed, stupid modplug tracker\n\t\t\tsmp[s].type &= 3+16;\t\t\t\t\t\n\n\t\t\tif (smp[s].sample == NULL)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (!(smp[s].type&16)) {\t\t\t\n\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\n\t\t\t\tmp_sbyte* sample = (mp_sbyte*)smp[s].sample;\n\t\t\t\tmp_sint32 samplen = smp[s].samplen;\n\t\t\t\tfor (mp_sint32 i = 0; i < samplen; i++)\n\t\t\t\t{\n\t\t\t\t\tmp_sint32 s = ((mp_sint32)sample[i] + (mp_sint32)sample[i + samplen]) >> 1;\n\t\t\t\t\tif (s < -128) s = -128;\n\t\t\t\t\tif (s > 127) s = 127;\n\t\t\t\t\tsample[i] = (mp_sbyte)s;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsmp[s].samplen>>=1;\n\t\t\t\tsmp[s].loopstart>>=1;\n\t\t\t\tsmp[s].looplen>>=1;\n\t\t\t\t\n\t\t\t\tmp_sword* sample = (mp_sword*)smp[s].sample;\n\t\t\t\tmp_sint32 samplen = smp[s].samplen;\n\t\t\t\tfor (mp_sint32 i = 0; i < samplen; i++)\n\t\t\t\t{\n\t\t\t\t\tmp_sint32 s = ((mp_sint32)sample[i] + (mp_sint32)sample[i + samplen]) >> 1;\n\t\t\t\t\tif (s < -32768) s = -32768;\n\t\t\t\t\tif (s > 32767) s = 32767;\n\t\t\t\t\tsample[i] = (mp_sword)s;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\/\/ correct loop type 0x03 (undefined)\n\t\t\/\/ will become ping pong loop\n\t\t\/\/ note that FT2 will refuse to load XM files with such a loop type\n\t\tif ((smp[s].type & 0x3) == 0x3)\n\t\t\tsmp[s].type&=~1;\t\t\n\t}\n\n\t\/\/ correct number of patterns if necessary, otherwise the post processing will remove\n\t\/\/ the \"invalid\" patterns from the order list\n\tbool addPatterns = false;\n\tfor (i = 0; i < header->ordnum; i++)\n\t\tif (header->ord[i]+1 > header->patnum)\n\t\t{\n\t\t\theader->patnum = header->ord[i]+1;\t\n\t\t\taddPatterns = true;\n\t\t}\n\t\n\t\/\/ if the pattern number has been adjusted, add some empty patterns\n\tif (addPatterns)\n\t{\n\t\tfor (i = 0; i < header->patnum; i++)\n\t\t\tif (phead[i].patternData == NULL)\n\t\t\t{\n\t\t\t\tphead[i].rows = 64;\n\t\t\t\tphead[i].effnum = 2;\n\t\t\t\tphead[i].channum = (mp_ubyte)header->channum;\n\n\t\t\t\tphead[i].patternData = new mp_ubyte[phead[i].rows*header->channum*6];\n\t\t\t\n\t\t\t\t\/\/ out of memory?\n\t\t\t\tif (phead[i].patternData == NULL)\n\t\t\t\t{\n\t\t\t\t\treturn MP_OUT_OF_MEMORY;\n\t\t\t\t}\n\t\t\n\t\t\t\tmemset(phead[i].patternData,0,phead[i].rows*header->channum*6);\n\t\t\t}\n\t}\n\t\n\t\/\/ check for MODPLUG extensions\n\tif (f.posWithBaseOffset() + 8 <= fileSize)\n\t{\n\t\tchar buffer[4];\n\t\tf.read(buffer, 1, 4);\n\t\tif (memcmp(buffer, \"text\", 4) == 0)\n\t\t{\n\t\t\tmp_uint32 len = f.readDword();\n\t\t\tmodule->allocateSongMessage(len+1);\n\t\t\t\n\t\t\tmemset(module->message, 0, len+1);\n\t\t\t\n\t\t\tf.read(module->message, 1, len);\n\t\t}\n\t}\n\t\n\tmodule->postProcessSamples();\n\t\n\treturn MP_OK;\n}","target":1,"code_token_length":7140,"total_token_length":7376,"max_tokens_setting":8192}
+{"idx":202081,"func":"do_put(\n    int\t\tregname,\n    char_u\t*expr_result,\t\/\/ result for regname \"=\" when compiled\n    int\t\tdir,\t\t\/\/ BACKWARD for 'P', FORWARD for 'p'\n    long\tcount,\n    int\t\tflags)\n{\n    char_u\t*ptr;\n    char_u\t*newp, *oldp;\n    int\t\tyanklen;\n    int\t\ttotlen = 0;\t\t\/\/ init for gcc\n    linenr_T\tlnum;\n    colnr_T\tcol;\n    long\ti;\t\t\t\/\/ index in y_array[]\n    int\t\ty_type;\n    long\ty_size;\n    int\t\toldlen;\n    long\ty_width = 0;\n    colnr_T\tvcol;\n    int\t\tdelcount;\n    int\t\tincr = 0;\n    long\tj;\n    struct block_def bd;\n    char_u\t**y_array = NULL;\n    yankreg_T\t*y_current_used = NULL;\n    long\tnr_lines = 0;\n    pos_T\tnew_cursor;\n    int\t\tindent;\n    int\t\torig_indent = 0;\t\/\/ init for gcc\n    int\t\tindent_diff = 0;\t\/\/ init for gcc\n    int\t\tfirst_indent = TRUE;\n    int\t\tlendiff = 0;\n    pos_T\told_pos;\n    char_u\t*insert_string = NULL;\n    int\t\tallocated = FALSE;\n    long\tcnt;\n    pos_T\torig_start = curbuf->b_op_start;\n    pos_T\torig_end = curbuf->b_op_end;\n    unsigned int cur_ve_flags = get_ve_flags();\n\n#ifdef FEAT_CLIPBOARD\n    \/\/ Adjust register name for \"unnamed\" in 'clipboard'.\n    adjust_clip_reg(®name);\n    (void)may_get_selection(regname);\n#endif\n\n    if (flags & PUT_FIXINDENT)\n\torig_indent = get_indent();\n\n    curbuf->b_op_start = curwin->w_cursor;\t\/\/ default for '[ mark\n    curbuf->b_op_end = curwin->w_cursor;\t\/\/ default for '] mark\n\n    \/\/ Using inserted text works differently, because the register includes\n    \/\/ special characters (newlines, etc.).\n    if (regname == '.')\n    {\n\tif (VIsual_active)\n\t    stuffcharReadbuff(VIsual_mode);\n\t(void)stuff_inserted((dir == FORWARD ? (count == -1 ? 'o' : 'a') :\n\t\t\t\t    (count == -1 ? 'O' : 'i')), count, FALSE);\n\t\/\/ Putting the text is done later, so can't really move the cursor to\n\t\/\/ the next character.  Use \"l\" to simulate it.\n\tif ((flags & PUT_CURSEND) && gchar_cursor() != NUL)\n\t    stuffcharReadbuff('l');\n\treturn;\n    }\n\n    \/\/ For special registers '%' (file name), '#' (alternate file name) and\n    \/\/ ':' (last command line), etc. we have to create a fake yank register.\n    \/\/ For compiled code \"expr_result\" holds the expression result.\n    if (regname == '=' && expr_result != NULL)\n\tinsert_string = expr_result;\n    else if (get_spec_reg(regname, &insert_string, &allocated, TRUE)\n\t\t&& insert_string == NULL)\n\treturn;\n\n    \/\/ Autocommands may be executed when saving lines for undo.  This might\n    \/\/ make \"y_array\" invalid, so we start undo now to avoid that.\n    if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL)\n\tgoto end;\n\n    if (insert_string != NULL)\n    {\n\ty_type = MCHAR;\n#ifdef FEAT_EVAL\n\tif (regname == '=')\n\t{\n\t    \/\/ For the = register we need to split the string at NL\n\t    \/\/ characters.\n\t    \/\/ Loop twice: count the number of lines and save them.\n\t    for (;;)\n\t    {\n\t\ty_size = 0;\n\t\tptr = insert_string;\n\t\twhile (ptr != NULL)\n\t\t{\n\t\t    if (y_array != NULL)\n\t\t\ty_array[y_size] = ptr;\n\t\t    ++y_size;\n\t\t    ptr = vim_strchr(ptr, '\\n');\n\t\t    if (ptr != NULL)\n\t\t    {\n\t\t\tif (y_array != NULL)\n\t\t\t    *ptr = NUL;\n\t\t\t++ptr;\n\t\t\t\/\/ A trailing '\\n' makes the register linewise.\n\t\t\tif (*ptr == NUL)\n\t\t\t{\n\t\t\t    y_type = MLINE;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (y_array != NULL)\n\t\t    break;\n\t\ty_array = ALLOC_MULT(char_u *, y_size);\n\t\tif (y_array == NULL)\n\t\t    goto end;\n\t    }\n\t}\n\telse\n#endif\n\t{\n\t    y_size = 1;\t\t\/\/ use fake one-line yank register\n\t    y_array = &insert_string;\n\t}\n    }\n    else\n    {\n\tget_yank_register(regname, FALSE);\n\n\ty_type = y_current->y_type;\n\ty_width = y_current->y_width;\n\ty_size = y_current->y_size;\n\ty_array = y_current->y_array;\n\ty_current_used = y_current;\n    }\n\n    if (y_type == MLINE)\n    {\n\tif (flags & PUT_LINE_SPLIT)\n\t{\n\t    char_u *p;\n\n\t    \/\/ \"p\" or \"P\" in Visual mode: split the lines to put the text in\n\t    \/\/ between.\n\t    if (u_save_cursor() == FAIL)\n\t\tgoto end;\n\t    p = ml_get_cursor();\n\t    if (dir == FORWARD && *p != NUL)\n\t\tMB_PTR_ADV(p);\n\t    ptr = vim_strsave(p);\n\t    if (ptr == NULL)\n\t\tgoto end;\n\t    ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);\n\t    vim_free(ptr);\n\n\t    oldp = ml_get_curline();\n\t    p = oldp + curwin->w_cursor.col;\n\t    if (dir == FORWARD && *p != NUL)\n\t\tMB_PTR_ADV(p);\n\t    ptr = vim_strnsave(oldp, p - oldp);\n\t    if (ptr == NULL)\n\t\tgoto end;\n\t    ml_replace(curwin->w_cursor.lnum, ptr, FALSE);\n\t    ++nr_lines;\n\t    dir = FORWARD;\n\t}\n\tif (flags & PUT_LINE_FORWARD)\n\t{\n\t    \/\/ Must be \"p\" for a Visual block, put lines below the block.\n\t    curwin->w_cursor = curbuf->b_visual.vi_end;\n\t    dir = FORWARD;\n\t}\n\tcurbuf->b_op_start = curwin->w_cursor;\t\/\/ default for '[ mark\n\tcurbuf->b_op_end = curwin->w_cursor;\t\/\/ default for '] mark\n    }\n\n    if (flags & PUT_LINE)\t\/\/ :put command or \"p\" in Visual line mode.\n\ty_type = MLINE;\n\n    if (y_size == 0 || y_array == NULL)\n    {\n\tsemsg(_(e_nothing_in_register_str),\n\t\t  regname == 0 ? (char_u *)\"\\\"\" : transchar(regname));\n\tgoto end;\n    }\n\n    if (y_type == MBLOCK)\n    {\n\tlnum = curwin->w_cursor.lnum + y_size + 1;\n\tif (lnum > curbuf->b_ml.ml_line_count)\n\t    lnum = curbuf->b_ml.ml_line_count + 1;\n\tif (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)\n\t    goto end;\n    }\n    else if (y_type == MLINE)\n    {\n\tlnum = curwin->w_cursor.lnum;\n#ifdef FEAT_FOLDING\n\t\/\/ Correct line number for closed fold.  Don't move the cursor yet,\n\t\/\/ u_save() uses it.\n\tif (dir == BACKWARD)\n\t    (void)hasFolding(lnum, &lnum, NULL);\n\telse\n\t    (void)hasFolding(lnum, NULL, &lnum);\n#endif\n\tif (dir == FORWARD)\n\t    ++lnum;\n\t\/\/ In an empty buffer the empty line is going to be replaced, include\n\t\/\/ it in the saved lines.\n\tif ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL)\n\t    goto end;\n#ifdef FEAT_FOLDING\n\tif (dir == FORWARD)\n\t    curwin->w_cursor.lnum = lnum - 1;\n\telse\n\t    curwin->w_cursor.lnum = lnum;\n\tcurbuf->b_op_start = curwin->w_cursor;\t\/\/ for mark_adjust()\n#endif\n    }\n    else if (u_save_cursor() == FAIL)\n\tgoto end;\n\n    yanklen = (int)STRLEN(y_array[0]);\n\n    if (cur_ve_flags == VE_ALL && y_type == MCHAR)\n    {\n\tif (gchar_cursor() == TAB)\n\t{\n\t    int viscol = getviscol();\n\t    int ts = curbuf->b_p_ts;\n\n\t    \/\/ Don't need to insert spaces when \"p\" on the last position of a\n\t    \/\/ tab or \"P\" on the first position.\n\t    if (dir == FORWARD ?\n#ifdef FEAT_VARTABS\n\t\t    tabstop_padding(viscol, ts, curbuf->b_p_vts_array) != 1\n#else\n\t\t    ts - (viscol % ts) != 1\n#endif\n\t\t    : curwin->w_cursor.coladd > 0)\n\t\tcoladvance_force(viscol);\n\t    else\n\t\tcurwin->w_cursor.coladd = 0;\n\t}\n\telse if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)\n\t    coladvance_force(getviscol() + (dir == FORWARD));\n    }\n\n    lnum = curwin->w_cursor.lnum;\n    col = curwin->w_cursor.col;\n\n    \/\/ Block mode\n    if (y_type == MBLOCK)\n    {\n\tint\tc = gchar_cursor();\n\tcolnr_T\tendcol2 = 0;\n\n\tif (dir == FORWARD && c != NUL)\n\t{\n\t    if (cur_ve_flags == VE_ALL)\n\t\tgetvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);\n\t    else\n\t\tgetvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);\n\n\t    if (has_mbyte)\n\t\t\/\/ move to start of next multi-byte character\n\t\tcurwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());\n\t    else\n\t    if (c != TAB || cur_ve_flags != VE_ALL)\n\t\t++curwin->w_cursor.col;\n\t    ++col;\n\t}\n\telse\n\t    getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);\n\n\tcol += curwin->w_cursor.coladd;\n\tif (cur_ve_flags == VE_ALL\n\t\t&& (curwin->w_cursor.coladd > 0\n\t\t    || endcol2 == curwin->w_cursor.col))\n\t{\n\t    if (dir == FORWARD && c == NUL)\n\t\t++col;\n\t    if (dir != FORWARD && c != NUL && curwin->w_cursor.coladd > 0)\n\t\t++curwin->w_cursor.col;\n\t    if (c == TAB)\n\t    {\n\t\tif (dir == BACKWARD && curwin->w_cursor.col)\n\t\t    curwin->w_cursor.col--;\n\t\tif (dir == FORWARD && col - 1 == endcol2)\n\t\t    curwin->w_cursor.col++;\n\t    }\n\t}\n\tcurwin->w_cursor.coladd = 0;\n\tbd.textcol = 0;\n\tfor (i = 0; i < y_size; ++i)\n\t{\n\t    int spaces = 0;\n\t    char shortline;\n\n\t    bd.startspaces = 0;\n\t    bd.endspaces = 0;\n\t    vcol = 0;\n\t    delcount = 0;\n\n\t    \/\/ add a new line\n\t    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t    {\n\t\tif (ml_append(curbuf->b_ml.ml_line_count, (char_u *)\"\",\n\t\t\t\t\t\t   (colnr_T)1, FALSE) == FAIL)\n\t\t    break;\n\t\t++nr_lines;\n\t    }\n\t    \/\/ get the old line and advance to the position to insert at\n\t    oldp = ml_get_curline();\n\t    oldlen = (int)STRLEN(oldp);\n\t    for (ptr = oldp; vcol < col && *ptr; )\n\t    {\n\t\t\/\/ Count a tab for what it's worth (if list mode not on)\n\t\tincr = lbr_chartabsize_adv(oldp, &ptr, vcol);\n\t\tvcol += incr;\n\t    }\n\t    bd.textcol = (colnr_T)(ptr - oldp);\n\n\t    shortline = (vcol < col) || (vcol == col && !*ptr) ;\n\n\t    if (vcol < col) \/\/ line too short, padd with spaces\n\t\tbd.startspaces = col - vcol;\n\t    else if (vcol > col)\n\t    {\n\t\tbd.endspaces = vcol - col;\n\t\tbd.startspaces = incr - bd.endspaces;\n\t\t--bd.textcol;\n\t\tdelcount = 1;\n\t\tif (has_mbyte)\n\t\t    bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);\n\t\tif (oldp[bd.textcol] != TAB)\n\t\t{\n\t\t    \/\/ Only a Tab can be split into spaces.  Other\n\t\t    \/\/ characters will have to be moved to after the\n\t\t    \/\/ block, causing misalignment.\n\t\t    delcount = 0;\n\t\t    bd.endspaces = 0;\n\t\t}\n\t    }\n\n\t    yanklen = (int)STRLEN(y_array[i]);\n\n\t    if ((flags & PUT_BLOCK_INNER) == 0)\n\t    {\n\t\t\/\/ calculate number of spaces required to fill right side of\n\t\t\/\/ block\n\t\tspaces = y_width + 1;\n\t\tfor (j = 0; j < yanklen; j++)\n\t\t    spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);\n\t\tif (spaces < 0)\n\t\t    spaces = 0;\n\t    }\n\n\t    \/\/ Insert the new text.\n\t    \/\/ First check for multiplication overflow.\n\t    if (yanklen + spaces != 0\n\t\t     && count > ((INT_MAX - (bd.startspaces + bd.endspaces))\n\t\t\t\t\t\t\t\/ (yanklen + spaces)))\n\t    {\n\t\temsg(_(e_resulting_text_too_long));\n\t\tbreak;\n\t    }\n\n\t    totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;\n\t    newp = alloc(totlen + oldlen + 1);\n\t    if (newp == NULL)\n\t\tbreak;\n\n\t    \/\/ copy part up to cursor to new line\n\t    ptr = newp;\n\t    mch_memmove(ptr, oldp, (size_t)bd.textcol);\n\t    ptr += bd.textcol;\n\n\t    \/\/ may insert some spaces before the new text\n\t    vim_memset(ptr, ' ', (size_t)bd.startspaces);\n\t    ptr += bd.startspaces;\n\n\t    \/\/ insert the new text\n\t    for (j = 0; j < count; ++j)\n\t    {\n\t\tmch_memmove(ptr, y_array[i], (size_t)yanklen);\n\t\tptr += yanklen;\n\n\t\t\/\/ insert block's trailing spaces only if there's text behind\n\t\tif ((j < count - 1 || !shortline) && spaces)\n\t\t{\n\t\t    vim_memset(ptr, ' ', (size_t)spaces);\n\t\t    ptr += spaces;\n\t\t}\n\t    }\n\n\t    \/\/ may insert some spaces after the new text\n\t    vim_memset(ptr, ' ', (size_t)bd.endspaces);\n\t    ptr += bd.endspaces;\n\n\t    \/\/ move the text after the cursor to the end of the line.\n\t    mch_memmove(ptr, oldp + bd.textcol + delcount,\n\t\t\t\t(size_t)(oldlen - bd.textcol - delcount + 1));\n\t    ml_replace(curwin->w_cursor.lnum, newp, FALSE);\n\n\t    ++curwin->w_cursor.lnum;\n\t    if (i == 0)\n\t\tcurwin->w_cursor.col += bd.startspaces;\n\t}\n\n\tchanged_lines(lnum, 0, curwin->w_cursor.lnum, nr_lines);\n\n\t\/\/ Set '[ mark.\n\tcurbuf->b_op_start = curwin->w_cursor;\n\tcurbuf->b_op_start.lnum = lnum;\n\n\t\/\/ adjust '] mark\n\tcurbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;\n\tcurbuf->b_op_end.col = bd.textcol + totlen - 1;\n\tcurbuf->b_op_end.coladd = 0;\n\tif (flags & PUT_CURSEND)\n\t{\n\t    colnr_T len;\n\n\t    curwin->w_cursor = curbuf->b_op_end;\n\t    curwin->w_cursor.col++;\n\n\t    \/\/ in Insert mode we might be after the NUL, correct for that\n\t    len = (colnr_T)STRLEN(ml_get_curline());\n\t    if (curwin->w_cursor.col > len)\n\t\tcurwin->w_cursor.col = len;\n\t}\n\telse\n\t    curwin->w_cursor.lnum = lnum;\n    }\n    else\n    {\n\t\/\/ Character or Line mode\n\tif (y_type == MCHAR)\n\t{\n\t    \/\/ if type is MCHAR, FORWARD is the same as BACKWARD on the next\n\t    \/\/ char\n\t    if (dir == FORWARD && gchar_cursor() != NUL)\n\t    {\n\t\tif (has_mbyte)\n\t\t{\n\t\t    int bytelen = (*mb_ptr2len)(ml_get_cursor());\n\n\t\t    \/\/ put it on the next of the multi-byte character.\n\t\t    col += bytelen;\n\t\t    if (yanklen)\n\t\t    {\n\t\t\tcurwin->w_cursor.col += bytelen;\n\t\t\tcurbuf->b_op_end.col += bytelen;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    ++col;\n\t\t    if (yanklen)\n\t\t    {\n\t\t\t++curwin->w_cursor.col;\n\t\t\t++curbuf->b_op_end.col;\n\t\t    }\n\t\t}\n\t    }\n\t    curbuf->b_op_start = curwin->w_cursor;\n\t}\n\t\/\/ Line mode: BACKWARD is the same as FORWARD on the previous line\n\telse if (dir == BACKWARD)\n\t    --lnum;\n\tnew_cursor = curwin->w_cursor;\n\n\t\/\/ simple case: insert into one line at a time\n\tif (y_type == MCHAR && y_size == 1)\n\t{\n\t    linenr_T\tend_lnum = 0; \/\/ init for gcc\n\t    linenr_T\tstart_lnum = lnum;\n\t    int\t\tfirst_byte_off = 0;\n\n\t    if (VIsual_active)\n\t    {\n\t\tend_lnum = curbuf->b_visual.vi_end.lnum;\n\t\tif (end_lnum < curbuf->b_visual.vi_start.lnum)\n\t\t    end_lnum = curbuf->b_visual.vi_start.lnum;\n\t\tif (end_lnum > start_lnum)\n\t\t{\n\t\t    pos_T   pos;\n\n\t\t    \/\/ \"col\" is valid for the first line, in following lines\n\t\t    \/\/ the virtual column needs to be used.  Matters for\n\t\t    \/\/ multi-byte characters.\n\t\t    pos.lnum = lnum;\n\t\t    pos.col = col;\n\t\t    pos.coladd = 0;\n\t\t    getvcol(curwin, &pos, NULL, &vcol, NULL);\n\t\t}\n\t    }\n\n\t    if (count == 0 || yanklen == 0)\n\t    {\n\t\tif (VIsual_active)\n\t\t    lnum = end_lnum;\n\t    }\n\t    else if (count > INT_MAX \/ yanklen)\n\t\t\/\/ multiplication overflow\n\t\temsg(_(e_resulting_text_too_long));\n\t    else\n\t    {\n\t\ttotlen = count * yanklen;\n\t\tdo {\n\t\t    oldp = ml_get(lnum);\n\t\t    oldlen = (int)STRLEN(oldp);\n\t\t    if (lnum > start_lnum)\n\t\t    {\n\t\t\tpos_T   pos;\n\n\t\t\tpos.lnum = lnum;\n\t\t\tif (getvpos(&pos, vcol) == OK)\n\t\t\t    col = pos.col;\n\t\t\telse\n\t\t\t    col = MAXCOL;\n\t\t    }\n\t\t    if (VIsual_active && col > oldlen)\n\t\t    {\n\t\t\tlnum++;\n\t\t\tcontinue;\n\t\t    }\n\t\t    newp = alloc(totlen + oldlen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto end;\t\/\/ alloc() gave an error message\n\t\t    mch_memmove(newp, oldp, (size_t)col);\n\t\t    ptr = newp + col;\n\t\t    for (i = 0; i < count; ++i)\n\t\t    {\n\t\t\tmch_memmove(ptr, y_array[0], (size_t)yanklen);\n\t\t\tptr += yanklen;\n\t\t    }\n\t\t    STRMOVE(ptr, oldp + col);\n\t\t    ml_replace(lnum, newp, FALSE);\n\n\t\t    \/\/ compute the byte offset for the last character\n\t\t    first_byte_off = mb_head_off(newp, ptr - 1);\n\n\t\t    \/\/ Place cursor on last putted char.\n\t\t    if (lnum == curwin->w_cursor.lnum)\n\t\t    {\n\t\t\t\/\/ make sure curwin->w_virtcol is updated\n\t\t\tchanged_cline_bef_curs();\n\t\t\tcurwin->w_cursor.col += (colnr_T)(totlen - 1);\n\t\t    }\n\t\t    if (VIsual_active)\n\t\t\tlnum++;\n\t\t} while (VIsual_active && lnum <= end_lnum);\n\n\t\tif (VIsual_active) \/\/ reset lnum to the last visual line\n\t\t    lnum--;\n\t    }\n\n\t    \/\/ put '] at the first byte of the last character\n\t    curbuf->b_op_end = curwin->w_cursor;\n\t    curbuf->b_op_end.col -= first_byte_off;\n\n\t    \/\/ For \"CTRL-O p\" in Insert mode, put cursor after last char\n\t    if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))\n\t\t++curwin->w_cursor.col;\n\t    else\n\t\tcurwin->w_cursor.col -= first_byte_off;\n\t    changed_bytes(lnum, col);\n\t}\n\telse\n\t{\n\t    linenr_T\tnew_lnum = new_cursor.lnum;\n\t    size_t\tlen;\n\n\t    \/\/ Insert at least one line.  When y_type is MCHAR, break the first\n\t    \/\/ line in two.\n\t    for (cnt = 1; cnt <= count; ++cnt)\n\t    {\n\t\ti = 0;\n\t\tif (y_type == MCHAR)\n\t\t{\n\t\t    \/\/ Split the current line in two at the insert position.\n\t\t    \/\/ First insert y_array[size - 1] in front of second line.\n\t\t    \/\/ Then append y_array[0] to first line.\n\t\t    lnum = new_cursor.lnum;\n\t\t    ptr = ml_get(lnum) + col;\n\t\t    totlen = (int)STRLEN(y_array[y_size - 1]);\n\t\t    newp = alloc(STRLEN(ptr) + totlen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto error;\n\t\t    STRCPY(newp, y_array[y_size - 1]);\n\t\t    STRCAT(newp, ptr);\n\t\t    \/\/ insert second line\n\t\t    ml_append(lnum, newp, (colnr_T)0, FALSE);\n\t\t    ++new_lnum;\n\t\t    vim_free(newp);\n\n\t\t    oldp = ml_get(lnum);\n\t\t    newp = alloc(col + yanklen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto error;\n\t\t\t\t\t    \/\/ copy first part of line\n\t\t    mch_memmove(newp, oldp, (size_t)col);\n\t\t\t\t\t    \/\/ append to first line\n\t\t    mch_memmove(newp + col, y_array[0], (size_t)(yanklen + 1));\n\t\t    ml_replace(lnum, newp, FALSE);\n\n\t\t    curwin->w_cursor.lnum = lnum;\n\t\t    i = 1;\n\t\t}\n\n\t\tfor (; i < y_size; ++i)\n\t\t{\n\t\t    if (y_type != MCHAR || i < y_size - 1)\n\t\t    {\n\t\t\tif (ml_append(lnum, y_array[i], (colnr_T)0, FALSE)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t\t\t    goto error;\n\t\t\tnew_lnum++;\n\t\t    }\n\t\t    lnum++;\n\t\t    ++nr_lines;\n\t\t    if (flags & PUT_FIXINDENT)\n\t\t    {\n\t\t\told_pos = curwin->w_cursor;\n\t\t\tcurwin->w_cursor.lnum = lnum;\n\t\t\tptr = ml_get(lnum);\n\t\t\tif (cnt == count && i == y_size - 1)\n\t\t\t    lendiff = (int)STRLEN(ptr);\n\t\t\tif (*ptr == '#' && preprocs_left())\n\t\t\t    indent = 0;     \/\/ Leave # lines at start\n\t\t\telse\n\t\t\t     if (*ptr == NUL)\n\t\t\t    indent = 0;     \/\/ Ignore empty lines\n\t\t\telse if (first_indent)\n\t\t\t{\n\t\t\t    indent_diff = orig_indent - get_indent();\n\t\t\t    indent = orig_indent;\n\t\t\t    first_indent = FALSE;\n\t\t\t}\n\t\t\telse if ((indent = get_indent() + indent_diff) < 0)\n\t\t\t    indent = 0;\n\t\t\t(void)set_indent(indent, 0);\n\t\t\tcurwin->w_cursor = old_pos;\n\t\t\t\/\/ remember how many chars were removed\n\t\t\tif (cnt == count && i == y_size - 1)\n\t\t\t    lendiff -= (int)STRLEN(ml_get(lnum));\n\t\t    }\n\t\t}\n\t\tif (cnt == 1)\n\t\t    new_lnum = lnum;\n\t    }\n\nerror:\n\t    \/\/ Adjust marks.\n\t    if (y_type == MLINE)\n\t    {\n\t\tcurbuf->b_op_start.col = 0;\n\t\tif (dir == FORWARD)\n\t\t    curbuf->b_op_start.lnum++;\n\t    }\n\t    \/\/ Skip mark_adjust when adding lines after the last one, there\n\t    \/\/ can't be marks there. But still needed in diff mode.\n\t    if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines\n\t\t\t\t\t\t < curbuf->b_ml.ml_line_count\n#ifdef FEAT_DIFF\n\t\t\t\t\t\t || curwin->w_p_diff\n#endif\n\t\t\t\t\t\t )\n\t\tmark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),\n\t\t\t\t\t     (linenr_T)MAXLNUM, nr_lines, 0L);\n\n\t    \/\/ note changed text for displaying and folding\n\t    if (y_type == MCHAR)\n\t\tchanged_lines(curwin->w_cursor.lnum, col,\n\t\t\t\t\t curwin->w_cursor.lnum + 1, nr_lines);\n\t    else\n\t\tchanged_lines(curbuf->b_op_start.lnum, 0,\n\t\t\t\t\t   curbuf->b_op_start.lnum, nr_lines);\n\t    if (y_current_used != NULL && (y_current_used != y_current\n\t\t\t\t\t     || y_current->y_array != y_array))\n\t    {\n\t\t\/\/ Something invoked through changed_lines() has changed the\n\t\t\/\/ yank buffer, e.g. a GUI clipboard callback.\n\t\temsg(_(e_yank_register_changed_while_using_it));\n\t\tgoto end;\n\t    }\n\n\t    \/\/ Put the '] mark on the first byte of the last inserted character.\n\t    \/\/ Correct the length for change in indent.\n\t    curbuf->b_op_end.lnum = new_lnum;\n\t    len = STRLEN(y_array[y_size - 1]);\n\t    col = (colnr_T)len - lendiff;\n\t    if (col > 1)\n\t    {\n\t\tcurbuf->b_op_end.col = col - 1;\n\t\tif (len > 0)\n\t\t    curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],\n\t\t\t\t\t\ty_array[y_size - 1] + len - 1);\n\t    }\n\t    else\n\t\tcurbuf->b_op_end.col = 0;\n\n\t    if (flags & PUT_CURSLINE)\n\t    {\n\t\t\/\/ \":put\": put cursor on last inserted line\n\t\tcurwin->w_cursor.lnum = lnum;\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t    }\n\t    else if (flags & PUT_CURSEND)\n\t    {\n\t\t\/\/ put cursor after inserted text\n\t\tif (y_type == MLINE)\n\t\t{\n\t\t    if (lnum >= curbuf->b_ml.ml_line_count)\n\t\t\tcurwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n\t\t    else\n\t\t\tcurwin->w_cursor.lnum = lnum + 1;\n\t\t    curwin->w_cursor.col = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    curwin->w_cursor.lnum = new_lnum;\n\t\t    curwin->w_cursor.col = col;\n\t\t    curbuf->b_op_end = curwin->w_cursor;\n\t\t    if (col > 1)\n\t\t\tcurbuf->b_op_end.col = col - 1;\n\t\t}\n\t    }\n\t    else if (y_type == MLINE)\n\t    {\n\t\t\/\/ put cursor on first non-blank in first inserted line\n\t\tcurwin->w_cursor.col = 0;\n\t\tif (dir == FORWARD)\n\t\t    ++curwin->w_cursor.lnum;\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t    }\n\t    else\t\/\/ put cursor on first inserted character\n\t\tcurwin->w_cursor = new_cursor;\n\t}\n    }\n\n    msgmore(nr_lines);\n    curwin->w_set_curswant = TRUE;\n\nend:\n    if (cmdmod.cmod_flags & CMOD_LOCKMARKS)\n    {\n\tcurbuf->b_op_start = orig_start;\n\tcurbuf->b_op_end = orig_end;\n    }\n    if (allocated)\n\tvim_free(insert_string);\n    if (regname == '=')\n\tvim_free(y_array);\n\n    VIsual_active = FALSE;\n\n    \/\/ If the cursor is past the end of the line put it at the end.\n    adjust_cursor_eol();\n}","target":1,"code_token_length":6340,"total_token_length":6576,"max_tokens_setting":8192}
+{"idx":210944,"func":"do_cmdline(\n    char_u\t*cmdline,\n    char_u\t*(*fgetline)(int, void *, int, getline_opt_T),\n    void\t*cookie,\t\t\/\/ argument for fgetline()\n    int\t\tflags)\n{\n    char_u\t*next_cmdline;\t\t\/\/ next cmd to execute\n    char_u\t*cmdline_copy = NULL;\t\/\/ copy of cmd line\n    int\t\tused_getline = FALSE;\t\/\/ used \"fgetline\" to obtain command\n    static int\trecursive = 0;\t\t\/\/ recursive depth\n    int\t\tmsg_didout_before_start = 0;\n    int\t\tcount = 0;\t\t\/\/ line number count\n    int\t\tdid_inc = FALSE;\t\/\/ incremented RedrawingDisabled\n    int\t\tretval = OK;\n#ifdef FEAT_EVAL\n    cstack_T\tcstack;\t\t\t\/\/ conditional stack\n    garray_T\tlines_ga;\t\t\/\/ keep lines for \":while\"\/\":for\"\n    int\t\tcurrent_line = 0;\t\/\/ active line in lines_ga\n    int\t\tcurrent_line_before = 0;\n    char_u\t*fname = NULL;\t\t\/\/ function or script name\n    linenr_T\t*breakpoint = NULL;\t\/\/ ptr to breakpoint field in cookie\n    int\t\t*dbg_tick = NULL;\t\/\/ ptr to dbg_tick field in cookie\n    struct dbg_stuff debug_saved;\t\/\/ saved things for debug mode\n    int\t\tinitial_trylevel;\n    msglist_T\t**saved_msg_list = NULL;\n    msglist_T\t*private_msg_list = NULL;\n\n    \/\/ \"fgetline\" and \"cookie\" passed to do_one_cmd()\n    char_u\t*(*cmd_getline)(int, void *, int, getline_opt_T);\n    void\t*cmd_cookie;\n    struct loop_cookie cmd_loop_cookie;\n    void\t*real_cookie;\n    int\t\tgetline_is_func;\n#else\n# define cmd_getline fgetline\n# define cmd_cookie cookie\n#endif\n    static int\tcall_depth = 0;\t\t\/\/ recursiveness\n#ifdef FEAT_EVAL\n    \/\/ For every pair of do_cmdline()\/do_one_cmd() calls, use an extra memory\n    \/\/ location for storing error messages to be converted to an exception.\n    \/\/ This ensures that the do_errthrow() call in do_one_cmd() does not\n    \/\/ combine the messages stored by an earlier invocation of do_one_cmd()\n    \/\/ with the command name of the later one.  This would happen when\n    \/\/ BufWritePost autocommands are executed after a write error.\n    saved_msg_list = msg_list;\n    msg_list = &private_msg_list;\n#endif\n\n    \/\/ It's possible to create an endless loop with \":execute\", catch that\n    \/\/ here.  The value of 200 allows nested function calls, \":source\", etc.\n    \/\/ Allow 200 or 'maxfuncdepth', whatever is larger.\n    if (call_depth >= 200\n#ifdef FEAT_EVAL\n\t    && call_depth >= p_mfd\n#endif\n\t    )\n    {\n\temsg(_(e_command_too_recursive));\n#ifdef FEAT_EVAL\n\t\/\/ When converting to an exception, we do not include the command name\n\t\/\/ since this is not an error of the specific command.\n\tdo_errthrow((cstack_T *)NULL, (char_u *)NULL);\n\tmsg_list = saved_msg_list;\n#endif\n\treturn FAIL;\n    }\n    ++call_depth;\n\n#ifdef FEAT_EVAL\n    CLEAR_FIELD(cstack);\n    cstack.cs_idx = -1;\n    ga_init2(&lines_ga, sizeof(wcmd_T), 10);\n\n    real_cookie = getline_cookie(fgetline, cookie);\n\n    \/\/ Inside a function use a higher nesting level.\n    getline_is_func = getline_equal(fgetline, cookie, get_func_line);\n    if (getline_is_func && ex_nesting_level == func_level(real_cookie))\n\t++ex_nesting_level;\n\n    \/\/ Get the function or script name and the address where the next breakpoint\n    \/\/ line and the debug tick for a function or script are stored.\n    if (getline_is_func)\n    {\n\tfname = func_name(real_cookie);\n\tbreakpoint = func_breakpoint(real_cookie);\n\tdbg_tick = func_dbg_tick(real_cookie);\n    }\n    else if (getline_equal(fgetline, cookie, getsourceline))\n    {\n\tfname = SOURCING_NAME;\n\tbreakpoint = source_breakpoint(real_cookie);\n\tdbg_tick = source_dbg_tick(real_cookie);\n    }\n\n    \/*\n     * Initialize \"force_abort\"  and \"suppress_errthrow\" at the top level.\n     *\/\n    if (!recursive)\n    {\n\tforce_abort = FALSE;\n\tsuppress_errthrow = FALSE;\n    }\n\n    \/*\n     * If requested, store and reset the global values controlling the\n     * exception handling (used when debugging).  Otherwise clear it to avoid\n     * a bogus compiler warning when the optimizer uses inline functions...\n     *\/\n    if (flags & DOCMD_EXCRESET)\n\tsave_dbg_stuff(&debug_saved);\n    else\n\tCLEAR_FIELD(debug_saved);\n\n    initial_trylevel = trylevel;\n\n    \/*\n     * \"did_throw\" will be set to TRUE when an exception is being thrown.\n     *\/\n    did_throw = FALSE;\n#endif\n    \/*\n     * \"did_emsg\" will be set to TRUE when emsg() is used, in which case we\n     * cancel the whole command line, and any if\/endif or loop.\n     * If force_abort is set, we cancel everything.\n     *\/\n#ifdef FEAT_EVAL\n    did_emsg_cumul += did_emsg;\n#endif\n    did_emsg = FALSE;\n\n    \/*\n     * KeyTyped is only set when calling vgetc().  Reset it here when not\n     * calling vgetc() (sourced command lines).\n     *\/\n    if (!(flags & DOCMD_KEYTYPED)\n\t\t\t       && !getline_equal(fgetline, cookie, getexline))\n\tKeyTyped = FALSE;\n\n    \/*\n     * Continue executing command lines:\n     * - when inside an \":if\", \":while\" or \":for\"\n     * - for multiple commands on one line, separated with '|'\n     * - when repeating until there are no more lines (for \":source\")\n     *\/\n    next_cmdline = cmdline;\n    do\n    {\n#ifdef FEAT_EVAL\n\tgetline_is_func = getline_equal(fgetline, cookie, get_func_line);\n#endif\n\n\t\/\/ stop skipping cmds for an error msg after all endif\/while\/for\n\tif (next_cmdline == NULL\n#ifdef FEAT_EVAL\n\t\t&& !force_abort\n\t\t&& cstack.cs_idx < 0\n\t\t&& !(getline_is_func && func_has_abort(real_cookie))\n#endif\n\t\t\t\t\t\t\t)\n\t{\n#ifdef FEAT_EVAL\n\t    did_emsg_cumul += did_emsg;\n#endif\n\t    did_emsg = FALSE;\n\t}\n\n\t\/*\n\t * 1. If repeating a line in a loop, get a line from lines_ga.\n\t * 2. If no line given: Get an allocated line with fgetline().\n\t * 3. If a line is given: Make a copy, so we can mess with it.\n\t *\/\n\n#ifdef FEAT_EVAL\n\t\/\/ 1. If repeating, get a previous line from lines_ga.\n\tif (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len)\n\t{\n\t    \/\/ Each '|' separated command is stored separately in lines_ga, to\n\t    \/\/ be able to jump to it.  Don't use next_cmdline now.\n\t    VIM_CLEAR(cmdline_copy);\n\n\t    \/\/ Check if a function has returned or, unless it has an unclosed\n\t    \/\/ try conditional, aborted.\n\t    if (getline_is_func)\n\t    {\n# ifdef FEAT_PROFILE\n\t\tif (do_profiling == PROF_YES)\n\t\t    func_line_end(real_cookie);\n# endif\n\t\tif (func_has_ended(real_cookie))\n\t\t{\n\t\t    retval = FAIL;\n\t\t    break;\n\t\t}\n\t    }\n#ifdef FEAT_PROFILE\n\t    else if (do_profiling == PROF_YES\n\t\t\t    && getline_equal(fgetline, cookie, getsourceline))\n\t\tscript_line_end();\n#endif\n\n\t    \/\/ Check if a sourced file hit a \":finish\" command.\n\t    if (source_finished(fgetline, cookie))\n\t    {\n\t\tretval = FAIL;\n\t\tbreak;\n\t    }\n\n\t    \/\/ If breakpoints have been added\/deleted need to check for it.\n\t    if (breakpoint != NULL && dbg_tick != NULL\n\t\t\t\t\t\t   && *dbg_tick != debug_tick)\n\t    {\n\t\t*breakpoint = dbg_find_breakpoint(\n\t\t\t\tgetline_equal(fgetline, cookie, getsourceline),\n\t\t\t\t\t\t\tfname, SOURCING_LNUM);\n\t\t*dbg_tick = debug_tick;\n\t    }\n\n\t    next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line;\n\t    SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum;\n\n\t    \/\/ Did we encounter a breakpoint?\n\t    if (breakpoint != NULL && *breakpoint != 0\n\t\t\t\t\t      && *breakpoint <= SOURCING_LNUM)\n\t    {\n\t\tdbg_breakpoint(fname, SOURCING_LNUM);\n\t\t\/\/ Find next breakpoint.\n\t\t*breakpoint = dbg_find_breakpoint(\n\t\t\t       getline_equal(fgetline, cookie, getsourceline),\n\t\t\t\t\t\t\tfname, SOURCING_LNUM);\n\t\t*dbg_tick = debug_tick;\n\t    }\n# ifdef FEAT_PROFILE\n\t    if (do_profiling == PROF_YES)\n\t    {\n\t\tif (getline_is_func)\n\t\t    func_line_start(real_cookie, SOURCING_LNUM);\n\t\telse if (getline_equal(fgetline, cookie, getsourceline))\n\t\t    script_line_start();\n\t    }\n# endif\n\t}\n#endif\n\n\t\/\/ 2. If no line given, get an allocated line with fgetline().\n\tif (next_cmdline == NULL)\n\t{\n\t    \/*\n\t     * Need to set msg_didout for the first line after an \":if\",\n\t     * otherwise the \":if\" will be overwritten.\n\t     *\/\n\t    if (count == 1 && getline_equal(fgetline, cookie, getexline))\n\t\tmsg_didout = TRUE;\n\t    if (fgetline == NULL || (next_cmdline = fgetline(':', cookie,\n#ifdef FEAT_EVAL\n\t\t    cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2\n#else\n\t\t    0\n#endif\n\t\t    , in_vim9script() ? GETLINE_CONCAT_CONTBAR\n\t\t\t\t\t       : GETLINE_CONCAT_CONT)) == NULL)\n\t    {\n\t\t\/\/ Don't call wait_return() for aborted command line.  The NULL\n\t\t\/\/ returned for the end of a sourced file or executed function\n\t\t\/\/ doesn't do this.\n\t\tif (KeyTyped && !(flags & DOCMD_REPEAT))\n\t\t    need_wait_return = FALSE;\n\t\tretval = FAIL;\n\t\tbreak;\n\t    }\n\t    used_getline = TRUE;\n\n\t    \/*\n\t     * Keep the first typed line.  Clear it when more lines are typed.\n\t     *\/\n\t    if (flags & DOCMD_KEEPLINE)\n\t    {\n\t\tvim_free(repeat_cmdline);\n\t\tif (count == 0)\n\t\t    repeat_cmdline = vim_strsave(next_cmdline);\n\t\telse\n\t\t    repeat_cmdline = NULL;\n\t    }\n\t}\n\n\t\/\/ 3. Make a copy of the command so we can mess with it.\n\telse if (cmdline_copy == NULL)\n\t{\n\t    next_cmdline = vim_strsave(next_cmdline);\n\t    if (next_cmdline == NULL)\n\t    {\n\t\temsg(_(e_out_of_memory));\n\t\tretval = FAIL;\n\t\tbreak;\n\t    }\n\t}\n\tcmdline_copy = next_cmdline;\n\n#ifdef FEAT_EVAL\n\t\/*\n\t * Inside a while\/for loop, and when the command looks like a \":while\"\n\t * or \":for\", the line is stored, because we may need it later when\n\t * looping.\n\t *\n\t * When there is a '|' and another command, it is stored separately,\n\t * because we need to be able to jump back to it from an\n\t * :endwhile\/:endfor.\n\t *\n\t * Pass a different \"fgetline\" function to do_one_cmd() below,\n\t * that it stores lines in or reads them from \"lines_ga\".  Makes it\n\t * possible to define a function inside a while\/for loop and handles\n\t * line continuation.\n\t *\/\n\tif ((cstack.cs_looplevel > 0 || has_loop_cmd(next_cmdline)))\n\t{\n\t    cmd_getline = get_loop_line;\n\t    cmd_cookie = (void *)&cmd_loop_cookie;\n\t    cmd_loop_cookie.lines_gap = &lines_ga;\n\t    cmd_loop_cookie.current_line = current_line;\n\t    cmd_loop_cookie.getline = fgetline;\n\t    cmd_loop_cookie.cookie = cookie;\n\t    cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);\n\n\t    \/\/ Save the current line when encountering it the first time.\n\t    if (current_line == lines_ga.ga_len\n\t\t    && store_loop_line(&lines_ga, next_cmdline) == FAIL)\n\t    {\n\t\tretval = FAIL;\n\t\tbreak;\n\t    }\n\t    current_line_before = current_line;\n\t}\n\telse\n\t{\n\t    cmd_getline = fgetline;\n\t    cmd_cookie = cookie;\n\t}\n\n\tdid_endif = FALSE;\n#endif\n\n\tif (count++ == 0)\n\t{\n\t    \/*\n\t     * All output from the commands is put below each other, without\n\t     * waiting for a return. Don't do this when executing commands\n\t     * from a script or when being called recursive (e.g. for \":e\n\t     * +command file\").\n\t     *\/\n\t    if (!(flags & DOCMD_NOWAIT) && !recursive)\n\t    {\n\t\tmsg_didout_before_start = msg_didout;\n\t\tmsg_didany = FALSE; \/\/ no output yet\n\t\tmsg_start();\n\t\tmsg_scroll = TRUE;  \/\/ put messages below each other\n\t\t++no_wait_return;   \/\/ don't wait for return until finished\n\t\t++RedrawingDisabled;\n\t\tdid_inc = TRUE;\n\t    }\n\t}\n\n\tif ((p_verbose >= 15 && SOURCING_NAME != NULL) || p_verbose >= 16)\n\t    msg_verbose_cmd(SOURCING_LNUM, cmdline_copy);\n\n\t\/*\n\t * 2. Execute one '|' separated command.\n\t *    do_one_cmd() will return NULL if there is no trailing '|'.\n\t *    \"cmdline_copy\" can change, e.g. for '%' and '#' expansion.\n\t *\/\n\t++recursive;\n\tnext_cmdline = do_one_cmd(&cmdline_copy, flags,\n#ifdef FEAT_EVAL\n\t\t\t\t&cstack,\n#endif\n\t\t\t\tcmd_getline, cmd_cookie);\n\t--recursive;\n\n#ifdef FEAT_EVAL\n\tif (cmd_cookie == (void *)&cmd_loop_cookie)\n\t    \/\/ Use \"current_line\" from \"cmd_loop_cookie\", it may have been\n\t    \/\/ incremented when defining a function.\n\t    current_line = cmd_loop_cookie.current_line;\n#endif\n\n\tif (next_cmdline == NULL)\n\t{\n\t    VIM_CLEAR(cmdline_copy);\n\n\t    \/*\n\t     * If the command was typed, remember it for the ':' register.\n\t     * Do this AFTER executing the command to make :@: work.\n\t     *\/\n\t    if (getline_equal(fgetline, cookie, getexline)\n\t\t\t\t\t\t  && new_last_cmdline != NULL)\n\t    {\n\t\tvim_free(last_cmdline);\n\t\tlast_cmdline = new_last_cmdline;\n\t\tnew_last_cmdline = NULL;\n\t    }\n\t}\n\telse\n\t{\n\t    \/\/ need to copy the command after the '|' to cmdline_copy, for the\n\t    \/\/ next do_one_cmd()\n\t    STRMOVE(cmdline_copy, next_cmdline);\n\t    next_cmdline = cmdline_copy;\n\t}\n\n\n#ifdef FEAT_EVAL\n\t\/\/ reset did_emsg for a function that is not aborted by an error\n\tif (did_emsg && !force_abort\n\t\t&& getline_equal(fgetline, cookie, get_func_line)\n\t\t\t\t\t      && !func_has_abort(real_cookie))\n\t{\n\t    \/\/ did_emsg_cumul is not set here\n\t    did_emsg = FALSE;\n\t}\n\n\tif (cstack.cs_looplevel > 0)\n\t{\n\t    ++current_line;\n\n\t    \/*\n\t     * An \":endwhile\", \":endfor\" and \":continue\" is handled here.\n\t     * If we were executing commands, jump back to the \":while\" or\n\t     * \":for\".\n\t     * If we were not executing commands, decrement cs_looplevel.\n\t     *\/\n\t    if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP))\n\t    {\n\t\tcstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP);\n\n\t\t\/\/ Jump back to the matching \":while\" or \":for\".  Be careful\n\t\t\/\/ not to use a cs_line[] from an entry that isn't a \":while\"\n\t\t\/\/ or \":for\": It would make \"current_line\" invalid and can\n\t\t\/\/ cause a crash.\n\t\tif (!did_emsg && !got_int && !did_throw\n\t\t\t&& cstack.cs_idx >= 0\n\t\t\t&& (cstack.cs_flags[cstack.cs_idx]\n\t\t\t\t\t\t      & (CSF_WHILE | CSF_FOR))\n\t\t\t&& cstack.cs_line[cstack.cs_idx] >= 0\n\t\t\t&& (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE))\n\t\t{\n\t\t    current_line = cstack.cs_line[cstack.cs_idx];\n\t\t\t\t\t\t\/\/ remember we jumped there\n\t\t    cstack.cs_lflags |= CSL_HAD_LOOP;\n\t\t    line_breakcheck();\t\t\/\/ check if CTRL-C typed\n\n\t\t    \/\/ Check for the next breakpoint at or after the \":while\"\n\t\t    \/\/ or \":for\".\n\t\t    if (breakpoint != NULL)\n\t\t    {\n\t\t\t*breakpoint = dbg_find_breakpoint(\n\t\t\t       getline_equal(fgetline, cookie, getsourceline),\n\t\t\t\t\t\t\t\t\tfname,\n\t\t\t   ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);\n\t\t\t*dbg_tick = debug_tick;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ can only get here with \":endwhile\" or \":endfor\"\n\t\t    if (cstack.cs_idx >= 0)\n\t\t\trewind_conditionals(&cstack, cstack.cs_idx - 1,\n\t\t\t\t   CSF_WHILE | CSF_FOR, &cstack.cs_looplevel);\n\t\t}\n\t    }\n\n\t    \/*\n\t     * For a \":while\" or \":for\" we need to remember the line number.\n\t     *\/\n\t    else if (cstack.cs_lflags & CSL_HAD_LOOP)\n\t    {\n\t\tcstack.cs_lflags &= ~CSL_HAD_LOOP;\n\t\tcstack.cs_line[cstack.cs_idx] = current_line_before;\n\t    }\n\t}\n\n\t\/\/ Check for the next breakpoint after a watchexpression\n\tif (breakpoint != NULL && has_watchexpr())\n\t{\n\t    *breakpoint = dbg_find_breakpoint(FALSE, fname, SOURCING_LNUM);\n\t    *dbg_tick = debug_tick;\n\t}\n\n\t\/*\n\t * When not inside any \":while\" loop, clear remembered lines.\n\t *\/\n\tif (cstack.cs_looplevel == 0)\n\t{\n\t    if (lines_ga.ga_len > 0)\n\t    {\n\t\tSOURCING_LNUM =\n\t\t       ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum;\n\t\tfree_cmdlines(&lines_ga);\n\t    }\n\t    current_line = 0;\n\t}\n\n\t\/*\n\t * A \":finally\" makes did_emsg, got_int, and did_throw pending for\n\t * being restored at the \":endtry\".  Reset them here and set the\n\t * ACTIVE and FINALLY flags, so that the finally clause gets executed.\n\t * This includes the case where a missing \":endif\", \":endwhile\" or\n\t * \":endfor\" was detected by the \":finally\" itself.\n\t *\/\n\tif (cstack.cs_lflags & CSL_HAD_FINA)\n\t{\n\t    cstack.cs_lflags &= ~CSL_HAD_FINA;\n\t    report_make_pending(cstack.cs_pending[cstack.cs_idx]\n\t\t    & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW),\n\t\t    did_throw ? (void *)current_exception : NULL);\n\t    did_emsg = got_int = did_throw = FALSE;\n\t    cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY;\n\t}\n\n\t\/\/ Update global \"trylevel\" for recursive calls to do_cmdline() from\n\t\/\/ within this loop.\n\ttrylevel = initial_trylevel + cstack.cs_trylevel;\n\n\t\/*\n\t * If the outermost try conditional (across function calls and sourced\n\t * files) is aborted because of an error, an interrupt, or an uncaught\n\t * exception, cancel everything.  If it is left normally, reset\n\t * force_abort to get the non-EH compatible abortion behavior for\n\t * the rest of the script.\n\t *\/\n\tif (trylevel == 0 && !did_emsg && !got_int && !did_throw)\n\t    force_abort = FALSE;\n\n\t\/\/ Convert an interrupt to an exception if appropriate.\n\t(void)do_intthrow(&cstack);\n#endif \/\/ FEAT_EVAL\n\n    }\n    \/*\n     * Continue executing command lines when:\n     * - no CTRL-C typed, no aborting error, no exception thrown or try\n     *   conditionals need to be checked for executing finally clauses or\n     *   catching an interrupt exception\n     * - didn't get an error message or lines are not typed\n     * - there is a command after '|', inside a :if, :while, :for or :try, or\n     *   looping for \":source\" command or function call.\n     *\/\n    while (!((got_int\n#ifdef FEAT_EVAL\n\t\t    || (did_emsg && (force_abort || in_vim9script()))\n\t\t    || did_throw\n#endif\n\t     )\n#ifdef FEAT_EVAL\n\t\t&& cstack.cs_trylevel == 0\n#endif\n\t    )\n\t    && !(did_emsg\n#ifdef FEAT_EVAL\n\t\t\/\/ Keep going when inside try\/catch, so that the error can be\n\t\t\/\/ deal with, except when it is a syntax error, it may cause\n\t\t\/\/ the :endtry to be missed.\n\t\t&& (cstack.cs_trylevel == 0 || did_emsg_syntax)\n#endif\n\t\t&& used_getline\n\t\t\t    && (getline_equal(fgetline, cookie, getexmodeline)\n\t\t\t       || getline_equal(fgetline, cookie, getexline)))\n\t    && (next_cmdline != NULL\n#ifdef FEAT_EVAL\n\t\t\t|| cstack.cs_idx >= 0\n#endif\n\t\t\t|| (flags & DOCMD_REPEAT)));\n\n    vim_free(cmdline_copy);\n    did_emsg_syntax = FALSE;\n#ifdef FEAT_EVAL\n    free_cmdlines(&lines_ga);\n    ga_clear(&lines_ga);\n\n    if (cstack.cs_idx >= 0)\n    {\n\t\/*\n\t * If a sourced file or executed function ran to its end, report the\n\t * unclosed conditional.\n\t * In Vim9 script do not give a second error, executing aborts after\n\t * the first one.\n\t *\/\n\tif (!got_int && !did_throw && !aborting()\n\t\t&& !(did_emsg && in_vim9script())\n\t\t&& ((getline_equal(fgetline, cookie, getsourceline)\n\t\t\t&& !source_finished(fgetline, cookie))\n\t\t    || (getline_equal(fgetline, cookie, get_func_line)\n\t\t\t\t\t    && !func_has_ended(real_cookie))))\n\t{\n\t    if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)\n\t\temsg(_(e_missing_endtry));\n\t    else if (cstack.cs_flags[cstack.cs_idx] & CSF_WHILE)\n\t\temsg(_(e_missing_endwhile));\n\t    else if (cstack.cs_flags[cstack.cs_idx] & CSF_FOR)\n\t\temsg(_(e_missing_endfor));\n\t    else\n\t\temsg(_(e_missing_endif));\n\t}\n\n\t\/*\n\t * Reset \"trylevel\" in case of a \":finish\" or \":return\" or a missing\n\t * \":endtry\" in a sourced file or executed function.  If the try\n\t * conditional is in its finally clause, ignore anything pending.\n\t * If it is in a catch clause, finish the caught exception.\n\t * Also cleanup any \"cs_forinfo\" structures.\n\t *\/\n\tdo\n\t{\n\t    int idx = cleanup_conditionals(&cstack, 0, TRUE);\n\n\t    if (idx >= 0)\n\t\t--idx;\t    \/\/ remove try block not in its finally clause\n\t    rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR,\n\t\t\t\t\t\t\t&cstack.cs_looplevel);\n\t}\n\twhile (cstack.cs_idx >= 0);\n\ttrylevel = initial_trylevel;\n    }\n\n    \/\/ If a missing \":endtry\", \":endwhile\", \":endfor\", or \":endif\" or a memory\n    \/\/ lack was reported above and the error message is to be converted to an\n    \/\/ exception, do this now after rewinding the cstack.\n    do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)\n\t\t\t\t  ? (char_u *)\"endfunction\" : (char_u *)NULL);\n\n    if (trylevel == 0)\n    {\n\t\/\/ Just in case did_throw got set but current_exception wasn't.\n\tif (current_exception == NULL)\n\t    did_throw = FALSE;\n\n\t\/*\n\t * When an exception is being thrown out of the outermost try\n\t * conditional, discard the uncaught exception, disable the conversion\n\t * of interrupts or errors to exceptions, and ensure that no more\n\t * commands are executed.\n\t *\/\n\tif (did_throw)\n\t    handle_did_throw();\n\n\t\/*\n\t * On an interrupt or an aborting error not converted to an exception,\n\t * disable the conversion of errors to exceptions.  (Interrupts are not\n\t * converted anymore, here.) This enables also the interrupt message\n\t * when force_abort is set and did_emsg unset in case of an interrupt\n\t * from a finally clause after an error.\n\t *\/\n\telse if (got_int || (did_emsg && force_abort))\n\t    suppress_errthrow = TRUE;\n    }\n\n    \/*\n     * The current cstack will be freed when do_cmdline() returns.  An uncaught\n     * exception will have to be rethrown in the previous cstack.  If a function\n     * has just returned or a script file was just finished and the previous\n     * cstack belongs to the same function or, respectively, script file, it\n     * will have to be checked for finally clauses to be executed due to the\n     * \":return\" or \":finish\".  This is done in do_one_cmd().\n     *\/\n    if (did_throw)\n\tneed_rethrow = TRUE;\n    if ((getline_equal(fgetline, cookie, getsourceline)\n\t\t&& ex_nesting_level > source_level(real_cookie))\n\t    || (getline_equal(fgetline, cookie, get_func_line)\n\t\t&& ex_nesting_level > func_level(real_cookie) + 1))\n    {\n\tif (!did_throw)\n\t    check_cstack = TRUE;\n    }\n    else\n    {\n\t\/\/ When leaving a function, reduce nesting level.\n\tif (getline_equal(fgetline, cookie, get_func_line))\n\t    --ex_nesting_level;\n\t\/*\n\t * Go to debug mode when returning from a function in which we are\n\t * single-stepping.\n\t *\/\n\tif ((getline_equal(fgetline, cookie, getsourceline)\n\t\t    || getline_equal(fgetline, cookie, get_func_line))\n\t\t&& ex_nesting_level + 1 <= debug_break_level)\n\t    do_debug(getline_equal(fgetline, cookie, getsourceline)\n\t\t    ? (char_u *)_(\"End of sourced file\")\n\t\t    : (char_u *)_(\"End of function\"));\n    }\n\n    \/*\n     * Restore the exception environment (done after returning from the\n     * debugger).\n     *\/\n    if (flags & DOCMD_EXCRESET)\n\trestore_dbg_stuff(&debug_saved);\n\n    msg_list = saved_msg_list;\n\n    \/\/ Cleanup if \"cs_emsg_silent_list\" remains.\n    if (cstack.cs_emsg_silent_list != NULL)\n    {\n\teslist_T *elem, *temp;\n\n\tfor (elem = cstack.cs_emsg_silent_list; elem != NULL; elem = temp)\n\t{\n\t    temp = elem->next;\n\t    vim_free(elem);\n\t}\n    }\n#endif \/\/ FEAT_EVAL\n\n    \/*\n     * If there was too much output to fit on the command line, ask the user to\n     * hit return before redrawing the screen. With the \":global\" command we do\n     * this only once after the command is finished.\n     *\/\n    if (did_inc)\n    {\n\t--RedrawingDisabled;\n\t--no_wait_return;\n\tmsg_scroll = FALSE;\n\n\t\/*\n\t * When just finished an \":if\"-\":else\" which was typed, no need to\n\t * wait for hit-return.  Also for an error situation.\n\t *\/\n\tif (retval == FAIL\n#ifdef FEAT_EVAL\n\t\t|| (did_endif && KeyTyped && !did_emsg)\n#endif\n\t\t\t\t\t    )\n\t{\n\t    need_wait_return = FALSE;\n\t    msg_didany = FALSE;\t\t\/\/ don't wait when restarting edit\n\t}\n\telse if (need_wait_return)\n\t{\n\t    \/*\n\t     * The msg_start() above clears msg_didout. The wait_return() we do\n\t     * here should not overwrite the command that may be shown before\n\t     * doing that.\n\t     *\/\n\t    msg_didout |= msg_didout_before_start;\n\t    wait_return(FALSE);\n\t}\n    }\n\n#ifdef FEAT_EVAL\n    did_endif = FALSE;  \/\/ in case do_cmdline used recursively\n#else\n    \/*\n     * Reset if_level, in case a sourced script file contains more \":if\" than\n     * \":endif\" (could be \":if x | foo | endif\").\n     *\/\n    if_level = 0;\n#endif\n\n    --call_depth;\n    return retval;\n}","target":1,"code_token_length":6366,"total_token_length":6602,"max_tokens_setting":8192}
+{"idx":211699,"func":"glob (const char *pattern, int flags, int (*errfunc) (const char *, int),\n      glob_t *pglob)\n{\n  const char *filename;\n  char *dirname = NULL;\n  size_t dirlen;\n  int status;\n  size_t oldcount;\n  int meta;\n  int dirname_modified;\n  int malloc_dirname = 0;\n  glob_t dirs;\n  int retval = 0;\n  size_t alloca_used = 0;\n\n  if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)\n    {\n      __set_errno (EINVAL);\n      return -1;\n    }\n\n  \/* POSIX requires all slashes to be matched.  This means that with\n     a trailing slash we must match only directories.  *\/\n  if (pattern[0] && pattern[strlen (pattern) - 1] == '\/')\n    flags |= GLOB_ONLYDIR;\n\n  if (!(flags & GLOB_DOOFFS))\n    \/* Have to do this so 'globfree' knows where to start freeing.  It\n       also makes all the code that uses gl_offs simpler. *\/\n    pglob->gl_offs = 0;\n\n  if (!(flags & GLOB_APPEND))\n    {\n      pglob->gl_pathc = 0;\n      if (!(flags & GLOB_DOOFFS))\n        pglob->gl_pathv = NULL;\n      else\n        {\n          size_t i;\n\n          if (pglob->gl_offs >= ~((size_t) 0) \/ sizeof (char *))\n            return GLOB_NOSPACE;\n\n          pglob->gl_pathv = (char **) malloc ((pglob->gl_offs + 1)\n                                              * sizeof (char *));\n          if (pglob->gl_pathv == NULL)\n            return GLOB_NOSPACE;\n\n          for (i = 0; i <= pglob->gl_offs; ++i)\n            pglob->gl_pathv[i] = NULL;\n        }\n    }\n\n  if (flags & GLOB_BRACE)\n    {\n      const char *begin;\n\n      if (flags & GLOB_NOESCAPE)\n        begin = strchr (pattern, '{');\n      else\n        {\n          begin = pattern;\n          while (1)\n            {\n              if (*begin == '\\0')\n                {\n                  begin = NULL;\n                  break;\n                }\n\n              if (*begin == '\\\\' && begin[1] != '\\0')\n                ++begin;\n              else if (*begin == '{')\n                break;\n\n              ++begin;\n            }\n        }\n\n      if (begin != NULL)\n        {\n          \/* Allocate working buffer large enough for our work.  Note that\n             we have at least an opening and closing brace.  *\/\n          size_t firstc;\n          char *alt_start;\n          const char *p;\n          const char *next;\n          const char *rest;\n          size_t rest_len;\n          char *onealt;\n          size_t pattern_len = strlen (pattern) - 1;\n          int alloca_onealt = glob_use_alloca (alloca_used, pattern_len);\n          if (alloca_onealt)\n            onealt = alloca_account (pattern_len, alloca_used);\n          else\n            {\n              onealt = malloc (pattern_len);\n              if (onealt == NULL)\n                return GLOB_NOSPACE;\n            }\n\n          \/* We know the prefix for all sub-patterns.  *\/\n          alt_start = mempcpy (onealt, pattern, begin - pattern);\n\n          \/* Find the first sub-pattern and at the same time find the\n             rest after the closing brace.  *\/\n          next = next_brace_sub (begin + 1, flags);\n          if (next == NULL)\n            {\n              \/* It is an invalid expression.  *\/\n            illegal_brace:\n              if (__glibc_unlikely (!alloca_onealt))\n                free (onealt);\n              flags &= ~GLOB_BRACE;\n              goto no_brace;\n            }\n\n          \/* Now find the end of the whole brace expression.  *\/\n          rest = next;\n          while (*rest != '}')\n            {\n              rest = next_brace_sub (rest + 1, flags);\n              if (rest == NULL)\n                \/* It is an illegal expression.  *\/\n                goto illegal_brace;\n            }\n          \/* Please note that we now can be sure the brace expression\n             is well-formed.  *\/\n          rest_len = strlen (++rest) + 1;\n\n          \/* We have a brace expression.  BEGIN points to the opening {,\n             NEXT points past the terminator of the first element, and END\n             points past the final }.  We will accumulate result names from\n             recursive runs for each brace alternative in the buffer using\n             GLOB_APPEND.  *\/\n          firstc = pglob->gl_pathc;\n\n          p = begin + 1;\n          while (1)\n            {\n              int result;\n\n              \/* Construct the new glob expression.  *\/\n              mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);\n\n              result = glob (onealt,\n                             ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC))\n                              | GLOB_APPEND), errfunc, pglob);\n\n              \/* If we got an error, return it.  *\/\n              if (result && result != GLOB_NOMATCH)\n                {\n                  if (__glibc_unlikely (!alloca_onealt))\n                    free (onealt);\n                  if (!(flags & GLOB_APPEND))\n                    {\n                      globfree (pglob);\n                      pglob->gl_pathc = 0;\n                    }\n                  return result;\n                }\n\n              if (*next == '}')\n                \/* We saw the last entry.  *\/\n                break;\n\n              p = next + 1;\n              next = next_brace_sub (p, flags);\n              assert (next != NULL);\n            }\n\n          if (__glibc_unlikely (!alloca_onealt))\n            free (onealt);\n\n          if (pglob->gl_pathc != firstc)\n            \/* We found some entries.  *\/\n            return 0;\n          else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))\n            return GLOB_NOMATCH;\n        }\n    }\n\n no_brace:\n  oldcount = pglob->gl_pathc + pglob->gl_offs;\n\n  \/* Find the filename.  *\/\n  filename = strrchr (pattern, '\/');\n\n#if defined __MSDOS__ || defined WINDOWS32\n  \/* The case of \"d:pattern\".  Since ':' is not allowed in\n     file names, we can safely assume that wherever it\n     happens in pattern, it signals the filename part.  This\n     is so we could some day support patterns like \"[a-z]:foo\".  *\/\n  if (filename == NULL)\n    filename = strchr (pattern, ':');\n#endif \/* __MSDOS__ || WINDOWS32 *\/\n\n  dirname_modified = 0;\n  if (filename == NULL)\n    {\n      \/* This can mean two things: a simple name or \"~name\".  The latter\n         case is nothing but a notation for a directory.  *\/\n      if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')\n        {\n          dirname = (char *) pattern;\n          dirlen = strlen (pattern);\n\n          \/* Set FILENAME to NULL as a special flag.  This is ugly but\n             other solutions would require much more code.  We test for\n             this special case below.  *\/\n          filename = NULL;\n        }\n      else\n        {\n          if (__glibc_unlikely (pattern[0] == '\\0'))\n            {\n              dirs.gl_pathv = NULL;\n              goto no_matches;\n            }\n\n          filename = pattern;\n          dirname = (char *) \".\";\n          dirlen = 0;\n        }\n    }\n  else if (filename == pattern\n           || (filename == pattern + 1 && pattern[0] == '\\\\'\n               && (flags & GLOB_NOESCAPE) == 0))\n    {\n      \/* \"\/pattern\" or \"\\\\\/pattern\".  *\/\n      dirname = (char *) \"\/\";\n      dirlen = 1;\n      ++filename;\n    }\n  else\n    {\n      char *newp;\n      dirlen = filename - pattern;\n\n#if defined __MSDOS__ || defined WINDOWS32\n      if (*filename == ':'\n          || (filename > pattern + 1 && filename[-1] == ':'))\n        {\n          char *drive_spec;\n\n          ++dirlen;\n          drive_spec = __alloca (dirlen + 1);\n          *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\\0';\n          \/* For now, disallow wildcards in the drive spec, to\n             prevent infinite recursion in glob.  *\/\n          if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)))\n            return GLOB_NOMATCH;\n          \/* If this is \"d:pattern\", we need to copy ':' to DIRNAME\n             as well.  If it's \"d:\/pattern\", don't remove the slash\n             from \"d:\/\", since \"d:\" and \"d:\/\" are not the same.*\/\n        }\n#endif\n\n      if (glob_use_alloca (alloca_used, dirlen + 1))\n        newp = alloca_account (dirlen + 1, alloca_used);\n      else\n        {\n          newp = malloc (dirlen + 1);\n          if (newp == NULL)\n            return GLOB_NOSPACE;\n          malloc_dirname = 1;\n        }\n      *((char *) mempcpy (newp, pattern, dirlen)) = '\\0';\n      dirname = newp;\n      ++filename;\n\n#if defined __MSDOS__ || defined WINDOWS32\n      bool drive_root = (dirlen > 1\n                         && (dirname[dirlen - 1] == ':'\n                             || (dirlen > 2 && dirname[dirlen - 2] == ':'\n                                 && dirname[dirlen - 1] == '\/')));\n#else\n      bool drive_root = false;\n#endif\n\n      if (filename[0] == '\\0' && dirlen > 1 && !drive_root)\n        \/* \"pattern\/\".  Expand \"pattern\", appending slashes.  *\/\n        {\n          int orig_flags = flags;\n          if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\\\')\n            {\n              \/* \"pattern\\\\\/\".  Remove the final backslash if it hasn't\n                 been quoted.  *\/\n              char *p = (char *) &dirname[dirlen - 1];\n\n              while (p > dirname && p[-1] == '\\\\') --p;\n              if ((&dirname[dirlen] - p) & 1)\n                {\n                  *(char *) &dirname[--dirlen] = '\\0';\n                  flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);\n                }\n            }\n          int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);\n          if (val == 0)\n            pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)\n                               | (flags & GLOB_MARK));\n          else if (val == GLOB_NOMATCH && flags != orig_flags)\n            {\n              \/* Make sure globfree (&dirs); is a nop.  *\/\n              dirs.gl_pathv = NULL;\n              flags = orig_flags;\n              oldcount = pglob->gl_pathc + pglob->gl_offs;\n              goto no_matches;\n            }\n          retval = val;\n          goto out;\n        }\n    }\n\n  if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')\n    {\n      if (dirname[1] == '\\0' || dirname[1] == '\/'\n          || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\\\'\n              && (dirname[2] == '\\0' || dirname[2] == '\/')))\n        {\n          \/* Look up home directory.  *\/\n          char *home_dir = getenv (\"HOME\");\n          int malloc_home_dir = 0;\n          if (home_dir == NULL || home_dir[0] == '\\0')\n            {\n#ifdef WINDOWS32\n              \/* Windows NT defines HOMEDRIVE and HOMEPATH.  But give\n                 preference to HOME, because the user can change HOME.  *\/\n              const char *home_drive = getenv (\"HOMEDRIVE\");\n              const char *home_path = getenv (\"HOMEPATH\");\n\n              if (home_drive != NULL && home_path != NULL)\n                {\n                  size_t home_drive_len = strlen (home_drive);\n                  size_t home_path_len = strlen (home_path);\n                  char *mem = alloca (home_drive_len + home_path_len + 1);\n\n                  memcpy (mem, home_drive, home_drive_len);\n                  memcpy (mem + home_drive_len, home_path, home_path_len + 1);\n                  home_dir = mem;\n                }\n              else\n                home_dir = \"c:\/users\/default\"; \/* poor default *\/\n#else\n              int err;\n              struct passwd *p;\n              struct passwd pwbuf;\n              struct scratch_buffer s;\n              scratch_buffer_init (&s);\n              while (true)\n                {\n                  p = NULL;\n                  err = __getlogin_r (s.data, s.length);\n                  if (err == 0)\n                    {\n# if defined HAVE_GETPWNAM_R || defined _LIBC\n                      size_t ssize = strlen (s.data) + 1;\n                      err = getpwnam_r (s.data, &pwbuf, s.data + ssize,\n                                        s.length - ssize, &p);\n# else\n                      p = getpwnam (s.data);\n                      if (p == NULL)\n                        err = errno;\n# endif\n                    }\n                  if (err != ERANGE)\n                    break;\n                  if (!scratch_buffer_grow (&s))\n                    {\n                      retval = GLOB_NOSPACE;\n                      goto out;\n                    }\n                }\n              if (err == 0)\n                {\n                  home_dir = strdup (p->pw_dir);\n                  malloc_home_dir = 1;\n                }\n              scratch_buffer_free (&s);\n              if (err == 0 && home_dir == NULL)\n                {\n                  retval = GLOB_NOSPACE;\n                  goto out;\n                }\n#endif \/* WINDOWS32 *\/\n            }\n          if (home_dir == NULL || home_dir[0] == '\\0')\n            {\n              if (__glibc_unlikely (malloc_home_dir))\n                free (home_dir);\n              if (flags & GLOB_TILDE_CHECK)\n                {\n                  retval = GLOB_NOMATCH;\n                  goto out;\n                }\n              else\n                {\n                  home_dir = (char *) \"~\"; \/* No luck.  *\/\n                  malloc_home_dir = 0;\n                }\n            }\n          \/* Now construct the full directory.  *\/\n          if (dirname[1] == '\\0')\n            {\n              if (__glibc_unlikely (malloc_dirname))\n                free (dirname);\n\n              dirname = home_dir;\n              dirlen = strlen (dirname);\n              malloc_dirname = malloc_home_dir;\n            }\n          else\n            {\n              char *newp;\n              size_t home_len = strlen (home_dir);\n              int use_alloca = glob_use_alloca (alloca_used, home_len + dirlen);\n              if (use_alloca)\n                newp = alloca_account (home_len + dirlen, alloca_used);\n              else\n                {\n                  newp = malloc (home_len + dirlen);\n                  if (newp == NULL)\n                    {\n                      if (__glibc_unlikely (malloc_home_dir))\n                        free (home_dir);\n                      retval = GLOB_NOSPACE;\n                      goto out;\n                    }\n                }\n\n              mempcpy (mempcpy (newp, home_dir, home_len),\n                       &dirname[1], dirlen);\n\n              if (__glibc_unlikely (malloc_dirname))\n                free (dirname);\n\n              dirname = newp;\n              dirlen += home_len - 1;\n              malloc_dirname = !use_alloca;\n\n              if (__glibc_unlikely (malloc_home_dir))\n                free (home_dir);\n            }\n          dirname_modified = 1;\n        }\n      else\n        {\n#ifndef WINDOWS32\n          char *end_name = strchr (dirname, '\/');\n          char *user_name;\n          int malloc_user_name = 0;\n          char *unescape = NULL;\n\n          if (!(flags & GLOB_NOESCAPE))\n            {\n              if (end_name == NULL)\n                {\n                  unescape = strchr (dirname, '\\\\');\n                  if (unescape)\n                    end_name = strchr (unescape, '\\0');\n                }\n              else\n                unescape = memchr (dirname, '\\\\', end_name - dirname);\n            }\n          if (end_name == NULL)\n            user_name = dirname + 1;\n          else\n            {\n              char *newp;\n              if (glob_use_alloca (alloca_used, end_name - dirname))\n                newp = alloca_account (end_name - dirname, alloca_used);\n              else\n                {\n                  newp = malloc (end_name - dirname);\n                  if (newp == NULL)\n                    {\n                      retval = GLOB_NOSPACE;\n                      goto out;\n                    }\n                  malloc_user_name = 1;\n                }\n              if (unescape != NULL)\n                {\n                  char *p = mempcpy (newp, dirname + 1,\n                                     unescape - dirname - 1);\n                  char *q = unescape;\n                  while (*q != '\\0')\n                    {\n                      if (*q == '\\\\')\n                        {\n                          if (q[1] == '\\0')\n                            {\n                              \/* \"~fo\\\\o\\\\\" unescape to user_name \"foo\\\\\",\n                                 but \"~fo\\\\o\\\\\/\" unescape to user_name\n                                 \"foo\".  *\/\n                              if (filename == NULL)\n                                *p++ = '\\\\';\n                              break;\n                            }\n                          ++q;\n                        }\n                      *p++ = *q++;\n                    }\n                  *p = '\\0';\n                }\n              else\n                *((char *) mempcpy (newp, dirname + 1, end_name - dirname))\n                  = '\\0';\n              user_name = newp;\n            }\n\n          \/* Look up specific user's home directory.  *\/\n          {\n            struct passwd *p;\n            struct scratch_buffer pwtmpbuf;\n            scratch_buffer_init (&pwtmpbuf);\n\n#  if defined HAVE_GETPWNAM_R || defined _LIBC\n            struct passwd pwbuf;\n\n            while (getpwnam_r (user_name, &pwbuf,\n                               pwtmpbuf.data, pwtmpbuf.length, &p)\n                   == ERANGE)\n              {\n                if (!scratch_buffer_grow (&pwtmpbuf))\n                  {\n                    retval = GLOB_NOSPACE;\n                    goto out;\n                  }\n              }\n#  else\n            p = getpwnam (user_name);\n#  endif\n\n            if (__glibc_unlikely (malloc_user_name))\n              free (user_name);\n\n            \/* If we found a home directory use this.  *\/\n            if (p != NULL)\n              {\n                size_t home_len = strlen (p->pw_dir);\n                size_t rest_len = end_name == NULL ? 0 : strlen (end_name);\n                char *d;\n\n                if (__glibc_unlikely (malloc_dirname))\n                  free (dirname);\n                malloc_dirname = 0;\n\n                if (glob_use_alloca (alloca_used, home_len + rest_len + 1))\n                  dirname = alloca_account (home_len + rest_len + 1,\n                                            alloca_used);\n                else\n                  {\n                    dirname = malloc (home_len + rest_len + 1);\n                    if (dirname == NULL)\n                      {\n                        scratch_buffer_free (&pwtmpbuf);\n                        retval = GLOB_NOSPACE;\n                        goto out;\n                      }\n                    malloc_dirname = 1;\n                  }\n                d = mempcpy (dirname, p->pw_dir, home_len);\n                if (end_name != NULL)\n                  d = mempcpy (d, end_name, rest_len);\n                *d = '\\0';\n\n                dirlen = home_len + rest_len;\n                dirname_modified = 1;\n              }\n            else\n              {\n                if (flags & GLOB_TILDE_CHECK)\n                  {\n                    \/* We have to regard it as an error if we cannot find the\n                       home directory.  *\/\n                    retval = GLOB_NOMATCH;\n                    goto out;\n                  }\n              }\n            scratch_buffer_free (&pwtmpbuf);\n          }\n#endif \/* !WINDOWS32 *\/\n        }\n    }\n\n  \/* Now test whether we looked for \"~\" or \"~NAME\".  In this case we\n     can give the answer now.  *\/\n  if (filename == NULL)\n    {\n      size_t newcount = pglob->gl_pathc + pglob->gl_offs;\n      char **new_gl_pathv;\n\n      if (newcount > SIZE_MAX \/ sizeof (char *) - 2)\n        {\n        nospace:\n          free (pglob->gl_pathv);\n          pglob->gl_pathv = NULL;\n          pglob->gl_pathc = 0;\n          retval = GLOB_NOSPACE;\n          goto out;\n        }\n\n      new_gl_pathv = realloc (pglob->gl_pathv,\n                              (newcount + 2) * sizeof (char *));\n      if (new_gl_pathv == NULL)\n        goto nospace;\n      pglob->gl_pathv = new_gl_pathv;\n\n      if (flags & GLOB_MARK && is_dir (dirname, flags, pglob))\n        {\n          char *p;\n          pglob->gl_pathv[newcount] = malloc (dirlen + 2);\n          if (pglob->gl_pathv[newcount] == NULL)\n            goto nospace;\n          p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen);\n          p[0] = '\/';\n          p[1] = '\\0';\n          if (__glibc_unlikely (malloc_dirname))\n            free (dirname);\n        }\n      else\n        {\n          if (__glibc_unlikely (malloc_dirname))\n            pglob->gl_pathv[newcount] = dirname;\n          else\n            {\n              pglob->gl_pathv[newcount] = strdup (dirname);\n              if (pglob->gl_pathv[newcount] == NULL)\n                goto nospace;\n            }\n        }\n      pglob->gl_pathv[++newcount] = NULL;\n      ++pglob->gl_pathc;\n      pglob->gl_flags = flags;\n\n      return 0;\n    }\n\n  meta = __glob_pattern_type (dirname, !(flags & GLOB_NOESCAPE));\n  \/* meta is 1 if correct glob pattern containing metacharacters.\n     If meta has bit (1 << 2) set, it means there was an unterminated\n     [ which we handle the same, using fnmatch.  Broken unterminated\n     pattern bracket expressions ought to be rare enough that it is\n     not worth special casing them, fnmatch will do the right thing.  *\/\n  if (meta & (GLOBPAT_SPECIAL | GLOBPAT_BRACKET))\n    {\n      \/* The directory name contains metacharacters, so we\n         have to glob for the directory, and then glob for\n         the pattern in each directory found.  *\/\n      size_t i;\n\n      if (!(flags & GLOB_NOESCAPE) && dirlen > 0 && dirname[dirlen - 1] == '\\\\')\n        {\n          \/* \"foo\\\\\/bar\".  Remove the final backslash from dirname\n             if it has not been quoted.  *\/\n          char *p = (char *) &dirname[dirlen - 1];\n\n          while (p > dirname && p[-1] == '\\\\') --p;\n          if ((&dirname[dirlen] - p) & 1)\n            *(char *) &dirname[--dirlen] = '\\0';\n        }\n\n      if (__glibc_unlikely ((flags & GLOB_ALTDIRFUNC) != 0))\n        {\n          \/* Use the alternative access functions also in the recursive\n             call.  *\/\n          dirs.gl_opendir = pglob->gl_opendir;\n          dirs.gl_readdir = pglob->gl_readdir;\n          dirs.gl_closedir = pglob->gl_closedir;\n          dirs.gl_stat = pglob->gl_stat;\n          dirs.gl_lstat = pglob->gl_lstat;\n        }\n\n      status = glob (dirname,\n                     ((flags & (GLOB_ERR | GLOB_NOESCAPE\n                                | GLOB_ALTDIRFUNC))\n                      | GLOB_NOSORT | GLOB_ONLYDIR),\n                     errfunc, &dirs);\n      if (status != 0)\n        {\n          if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH)\n            {\n              retval = status;\n              goto out;\n            }\n          goto no_matches;\n        }\n\n      \/* We have successfully globbed the preceding directory name.\n         For each name we found, call glob_in_dir on it and FILENAME,\n         appending the results to PGLOB.  *\/\n      for (i = 0; i < dirs.gl_pathc; ++i)\n        {\n          size_t old_pathc;\n\n          old_pathc = pglob->gl_pathc;\n          status = glob_in_dir (filename, dirs.gl_pathv[i],\n                                ((flags | GLOB_APPEND)\n                                 & ~(GLOB_NOCHECK | GLOB_NOMAGIC)),\n                                errfunc, pglob, alloca_used);\n          if (status == GLOB_NOMATCH)\n            \/* No matches in this directory.  Try the next.  *\/\n            continue;\n\n          if (status != 0)\n            {\n              globfree (&dirs);\n              globfree (pglob);\n              pglob->gl_pathc = 0;\n              retval = status;\n              goto out;\n            }\n\n          \/* Stick the directory on the front of each name.  *\/\n          if (prefix_array (dirs.gl_pathv[i],\n                            &pglob->gl_pathv[old_pathc + pglob->gl_offs],\n                            pglob->gl_pathc - old_pathc))\n            {\n              globfree (&dirs);\n              globfree (pglob);\n              pglob->gl_pathc = 0;\n              retval = GLOB_NOSPACE;\n              goto out;\n            }\n        }\n\n      flags |= GLOB_MAGCHAR;\n\n      \/* We have ignored the GLOB_NOCHECK flag in the 'glob_in_dir' calls.\n         But if we have not found any matching entry and the GLOB_NOCHECK\n         flag was set we must return the input pattern itself.  *\/\n      if (pglob->gl_pathc + pglob->gl_offs == oldcount)\n        {\n        no_matches:\n          \/* No matches.  *\/\n          if (flags & GLOB_NOCHECK)\n            {\n              size_t newcount = pglob->gl_pathc + pglob->gl_offs;\n              char **new_gl_pathv;\n\n              if (newcount > SIZE_MAX \/ sizeof (char *) - 2)\n                {\n                nospace2:\n                  globfree (&dirs);\n                  retval = GLOB_NOSPACE;\n                  goto out;\n                }\n\n              new_gl_pathv = realloc (pglob->gl_pathv,\n                                      (newcount + 2) * sizeof (char *));\n              if (new_gl_pathv == NULL)\n                goto nospace2;\n              pglob->gl_pathv = new_gl_pathv;\n\n              pglob->gl_pathv[newcount] = strdup (pattern);\n              if (pglob->gl_pathv[newcount] == NULL)\n                {\n                  globfree (&dirs);\n                  globfree (pglob);\n                  pglob->gl_pathc = 0;\n                  retval = GLOB_NOSPACE;\n                  goto out;\n                }\n\n              ++pglob->gl_pathc;\n              ++newcount;\n\n              pglob->gl_pathv[newcount] = NULL;\n              pglob->gl_flags = flags;\n            }\n          else\n            {\n              globfree (&dirs);\n              retval = GLOB_NOMATCH;\n              goto out;\n            }\n        }\n\n      globfree (&dirs);\n    }\n  else\n    {\n      size_t old_pathc = pglob->gl_pathc;\n      int orig_flags = flags;\n\n      if (meta & GLOBPAT_BACKSLASH)\n        {\n          char *p = strchr (dirname, '\\\\'), *q;\n          \/* We need to unescape the dirname string.  It is certainly\n             allocated by alloca, as otherwise filename would be NULL\n             or dirname wouldn't contain backslashes.  *\/\n          q = p;\n          do\n            {\n              if (*p == '\\\\')\n                {\n                  *q = *++p;\n                  --dirlen;\n                }\n              else\n                *q = *p;\n              ++q;\n            }\n          while (*p++ != '\\0');\n          dirname_modified = 1;\n        }\n      if (dirname_modified)\n        flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);\n      status = glob_in_dir (filename, dirname, flags, errfunc, pglob,\n                            alloca_used);\n      if (status != 0)\n        {\n          if (status == GLOB_NOMATCH && flags != orig_flags\n              && pglob->gl_pathc + pglob->gl_offs == oldcount)\n            {\n              \/* Make sure globfree (&dirs); is a nop.  *\/\n              dirs.gl_pathv = NULL;\n              flags = orig_flags;\n              goto no_matches;\n            }\n          retval = status;\n          goto out;\n        }\n\n      if (dirlen > 0)\n        {\n          \/* Stick the directory on the front of each name.  *\/\n          if (prefix_array (dirname,\n                            &pglob->gl_pathv[old_pathc + pglob->gl_offs],\n                            pglob->gl_pathc - old_pathc))\n            {\n              globfree (pglob);\n              pglob->gl_pathc = 0;\n              retval = GLOB_NOSPACE;\n              goto out;\n            }\n        }\n    }\n\n  if (flags & GLOB_MARK)\n    {\n      \/* Append slashes to directory names.  *\/\n      size_t i;\n\n      for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)\n        if (is_dir (pglob->gl_pathv[i], flags, pglob))\n          {\n            size_t len = strlen (pglob->gl_pathv[i]) + 2;\n            char *new = realloc (pglob->gl_pathv[i], len);\n            if (new == NULL)\n              {\n                globfree (pglob);\n                pglob->gl_pathc = 0;\n                retval = GLOB_NOSPACE;\n                goto out;\n              }\n            strcpy (&new[len - 2], \"\/\");\n            pglob->gl_pathv[i] = new;\n          }\n    }\n\n  if (!(flags & GLOB_NOSORT))\n    {\n      \/* Sort the vector.  *\/\n      qsort (&pglob->gl_pathv[oldcount],\n             pglob->gl_pathc + pglob->gl_offs - oldcount,\n             sizeof (char *), collated_compare);\n    }\n\n out:\n  if (__glibc_unlikely (malloc_dirname))\n    free (dirname);\n\n  return retval;\n}","target":1,"code_token_length":6663,"total_token_length":6899,"max_tokens_setting":8192}
+{"idx":335433,"func":"do_one_cmd(\n    char_u\t**cmdlinep,\n    int\t\tflags,\n#ifdef FEAT_EVAL\n    cstack_T\t*cstack,\n#endif\n    char_u\t*(*fgetline)(int, void *, int, getline_opt_T),\n    void\t*cookie)\t\t\/\/ argument for fgetline()\n{\n    char_u\t*p;\n    linenr_T\tlnum;\n    long\tn;\n    char\t*errormsg = NULL;\t\/\/ error message\n    char_u\t*after_modifier = NULL;\n    exarg_T\tea;\t\t\t\/\/ Ex command arguments\n    cmdmod_T\tsave_cmdmod;\n    int\t\tsave_reg_executing = reg_executing;\n    int\t\tsave_pending_end_reg_executing = pending_end_reg_executing;\n    int\t\tni;\t\t\t\/\/ set when Not Implemented\n    char_u\t*cmd;\n    int\t\tstarts_with_colon = FALSE;\n#ifdef FEAT_EVAL\n    int\t\tmay_have_range;\n    int\t\tvim9script;\n    int\t\tdid_set_expr_line = FALSE;\n#endif\n    int\t\tsourcing = flags & DOCMD_VERBOSE;\n\n    CLEAR_FIELD(ea);\n    ea.line1 = 1;\n    ea.line2 = 1;\n#ifdef FEAT_EVAL\n    ++ex_nesting_level;\n#endif\n\n    \/\/ When the last file has not been edited :q has to be typed twice.\n    if (quitmore\n#ifdef FEAT_EVAL\n\t    \/\/ avoid that a function call in 'statusline' does this\n\t    && !getline_equal(fgetline, cookie, get_func_line)\n#endif\n\t    \/\/ avoid that an autocommand, e.g. QuitPre, does this\n\t    && !getline_equal(fgetline, cookie, getnextac))\n\t--quitmore;\n\n    \/*\n     * Reset browse, confirm, etc..  They are restored when returning, for\n     * recursive calls.\n     *\/\n    save_cmdmod = cmdmod;\n\n    \/\/ \"#!anything\" is handled like a comment.\n    if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!')\n\tgoto doend;\n\n\/*\n * 1. Skip comment lines and leading white space and colons.\n * 2. Handle command modifiers.\n *\/\n    \/\/ The \"ea\" structure holds the arguments that can be used.\n    ea.cmd = *cmdlinep;\n    ea.cmdlinep = cmdlinep;\n    ea.getline = fgetline;\n    ea.cookie = cookie;\n#ifdef FEAT_EVAL\n    ea.cstack = cstack;\n    starts_with_colon = *skipwhite(ea.cmd) == ':';\n#endif\n    if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)\n\tgoto doend;\n    apply_cmdmod(&cmdmod);\n#ifdef FEAT_EVAL\n    vim9script = in_vim9script();\n#endif\n    after_modifier = ea.cmd;\n\n#ifdef FEAT_EVAL\n    ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0\n\t\t\t && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE));\n#else\n    ea.skip = (if_level > 0);\n#endif\n\n\/*\n * 3. Skip over the range to find the command.  Let \"p\" point to after it.\n *\n * We need the command to know what kind of range it uses.\n *\/\n    cmd = ea.cmd;\n#ifdef FEAT_EVAL\n    \/\/ In Vim9 script a colon is required before the range.  This may also be\n    \/\/ after command modifiers.\n    if (vim9script && (flags & DOCMD_RANGEOK) == 0)\n    {\n\tmay_have_range = FALSE;\n\tfor (p = ea.cmd; p >= *cmdlinep; --p)\n\t{\n\t    if (*p == ':')\n\t\tmay_have_range = TRUE;\n\t    if (p < ea.cmd && !VIM_ISWHITE(*p))\n\t\tbreak;\n\t}\n    }\n    else\n\tmay_have_range = TRUE;\n    if (may_have_range)\n#endif\n\tea.cmd = skip_range(ea.cmd, TRUE, NULL);\n\n#ifdef FEAT_EVAL\n    if (vim9script && !may_have_range)\n    {\n\tif (ea.cmd == cmd + 1 && *cmd == '$')\n\t    \/\/ should be \"$VAR = val\"\n\t    --ea.cmd;\n\tp = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);\n\tif (ea.cmdidx == CMD_SIZE)\n\t{\n\t    char_u *ar = skip_range(ea.cmd, TRUE, NULL);\n\n\t    \/\/ If a ':' before the range is missing, give a clearer error\n\t    \/\/ message.\n\t    if (ar > ea.cmd && !ea.skip)\n\t    {\n\t\tsemsg(_(e_colon_required_before_range_str), ea.cmd);\n\t\tgoto doend;\n\t    }\n\t}\n    }\n    else\n#endif\n\tp = find_ex_command(&ea, NULL, NULL, NULL);\n\n#ifdef FEAT_EVAL\n# ifdef FEAT_PROFILE\n    \/\/ Count this line for profiling if skip is TRUE.\n    if (do_profiling == PROF_YES\n\t    && (!ea.skip || cstack->cs_idx == 0 || (cstack->cs_idx > 0\n\t\t     && (cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE))))\n    {\n\tint skip = did_emsg || got_int || did_throw;\n\n\tif (ea.cmdidx == CMD_catch)\n\t    skip = !skip && !(cstack->cs_idx >= 0\n\t\t\t  && (cstack->cs_flags[cstack->cs_idx] & CSF_THROWN)\n\t\t\t  && !(cstack->cs_flags[cstack->cs_idx] & CSF_CAUGHT));\n\telse if (ea.cmdidx == CMD_else || ea.cmdidx == CMD_elseif)\n\t    skip = skip || !(cstack->cs_idx >= 0\n\t\t\t  && !(cstack->cs_flags[cstack->cs_idx]\n\t\t\t\t\t\t  & (CSF_ACTIVE | CSF_TRUE)));\n\telse if (ea.cmdidx == CMD_finally)\n\t    skip = FALSE;\n\telse if (ea.cmdidx != CMD_endif\n\t\t&& ea.cmdidx != CMD_endfor\n\t\t&& ea.cmdidx != CMD_endtry\n\t\t&& ea.cmdidx != CMD_endwhile)\n\t    skip = ea.skip;\n\n\tif (!skip)\n\t{\n\t    if (getline_equal(fgetline, cookie, get_func_line))\n\t\tfunc_line_exec(getline_cookie(fgetline, cookie));\n\t    else if (getline_equal(fgetline, cookie, getsourceline))\n\t\tscript_line_exec();\n\t}\n    }\n# endif\n\n    \/\/ May go to debug mode.  If this happens and the \">quit\" debug command is\n    \/\/ used, throw an interrupt exception and skip the next command.\n    dbg_check_breakpoint(&ea);\n    if (!ea.skip && got_int)\n    {\n\tea.skip = TRUE;\n\t(void)do_intthrow(cstack);\n    }\n#endif\n\n\/*\n * 4. parse a range specifier of the form: addr [,addr] [;addr] ..\n *\n * where 'addr' is:\n *\n * %\t      (entire file)\n * $  [+-NUM]\n * 'x [+-NUM] (where x denotes a currently defined mark)\n * .  [+-NUM]\n * [+-NUM]..\n * NUM\n *\n * The ea.cmd pointer is updated to point to the first character following the\n * range spec. If an initial address is found, but no second, the upper bound\n * is equal to the lower.\n *\/\n\n    \/\/ ea.addr_type for user commands is set by find_ucmd\n    if (!IS_USER_CMDIDX(ea.cmdidx))\n    {\n\tif (ea.cmdidx != CMD_SIZE)\n\t    ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;\n\telse\n\t    ea.addr_type = ADDR_LINES;\n\n\t\/\/ :wincmd range depends on the argument.\n\tif (ea.cmdidx == CMD_wincmd && p != NULL)\n\t    get_wincmd_addr_type(skipwhite(p), &ea);\n#ifdef FEAT_QUICKFIX\n\t\/\/ :.cc in quickfix window uses line number\n\tif ((ea.cmdidx == CMD_cc || ea.cmdidx == CMD_ll) && bt_quickfix(curbuf))\n\t    ea.addr_type = ADDR_OTHER;\n#endif\n    }\n\n    ea.cmd = cmd;\n#ifdef FEAT_EVAL\n    if (!may_have_range)\n\tea.line1 = ea.line2 = default_address(&ea);\n    else\n#endif\n\tif (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)\n\t    goto doend;\n\n\/*\n * 5. Parse the command.\n *\/\n\n    \/*\n     * Skip ':' and any white space\n     *\/\n    ea.cmd = skipwhite(ea.cmd);\n    while (*ea.cmd == ':')\n\tea.cmd = skipwhite(ea.cmd + 1);\n\n    \/*\n     * If we got a line, but no command, then go to the line.\n     * If we find a '|' or '\\n' we set ea.nextcmd.\n     *\/\n    if (*ea.cmd == NUL || comment_start(ea.cmd, starts_with_colon)\n\t\t\t       || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL)\n    {\n\t\/*\n\t * strange vi behaviour:\n\t * \":3\"\t\tjumps to line 3\n\t * \":3|...\"\tprints line 3  (not in Vim9 script)\n\t * \":|\"\t\tprints current line  (not in Vim9 script)\n\t *\/\n\tif (ea.skip)\t    \/\/ skip this if inside :if\n\t    goto doend;\n\terrormsg = ex_range_without_command(&ea);\n\tgoto doend;\n    }\n\n    \/\/ If this looks like an undefined user command and there are CmdUndefined\n    \/\/ autocommands defined, trigger the matching autocommands.\n    if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip\n\t    && ASCII_ISUPPER(*ea.cmd)\n\t    && has_cmdundefined())\n    {\n\tint ret;\n\n\tp = ea.cmd;\n\twhile (ASCII_ISALNUM(*p))\n\t    ++p;\n\tp = vim_strnsave(ea.cmd, p - ea.cmd);\n\tret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);\n\tvim_free(p);\n\t\/\/ If the autocommands did something and didn't cause an error, try\n\t\/\/ finding the command again.\n\tp = (ret\n#ifdef FEAT_EVAL\n\t\t&& !aborting()\n#endif\n\t\t) ? find_ex_command(&ea, NULL, NULL, NULL) : ea.cmd;\n    }\n\n    if (p == NULL)\n    {\n\tif (!ea.skip)\n\t    errormsg = _(e_ambiguous_use_of_user_defined_command);\n\tgoto doend;\n    }\n    \/\/ Check for wrong commands.\n    if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78\n\t    && !IS_USER_CMDIDX(ea.cmdidx))\n    {\n\terrormsg = uc_fun_cmd();\n\tgoto doend;\n    }\n\n    if (ea.cmdidx == CMD_SIZE)\n    {\n\tif (!ea.skip)\n\t{\n\t    STRCPY(IObuff, _(e_not_an_editor_command));\n\t    if (!sourcing)\n\t    {\n\t\t\/\/ If the modifier was parsed OK the error must be in the\n\t\t\/\/ following command\n\t\tif (after_modifier != NULL)\n\t\t    append_command(after_modifier);\n\t\telse\n\t\t    append_command(*cmdlinep);\n\t    }\n\t    errormsg = (char *)IObuff;\n\t    did_emsg_syntax = TRUE;\n\t}\n\tgoto doend;\n    }\n\n    ni = (!IS_USER_CMDIDX(ea.cmdidx)\n\t    && (cmdnames[ea.cmdidx].cmd_func == ex_ni\n#ifdef HAVE_EX_SCRIPT_NI\n\t     || cmdnames[ea.cmdidx].cmd_func == ex_script_ni\n#endif\n\t     ));\n\n#ifndef FEAT_EVAL\n    \/*\n     * When the expression evaluation is disabled, recognize the \":if\" and\n     * \":endif\" commands and ignore everything in between it.\n     *\/\n    if (ea.cmdidx == CMD_if)\n\t++if_level;\n    if (if_level)\n    {\n\tif (ea.cmdidx == CMD_endif)\n\t    --if_level;\n\tgoto doend;\n    }\n\n#endif\n\n    \/\/ forced commands\n    if (*p == '!' && ea.cmdidx != CMD_substitute\n\t    && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic)\n    {\n\t++p;\n\tea.forceit = TRUE;\n    }\n    else\n\tea.forceit = FALSE;\n\n\/*\n * 6. Parse arguments.  Then check for errors.\n *\/\n    if (!IS_USER_CMDIDX(ea.cmdidx))\n\tea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;\n\n    if (!ea.skip)\n    {\n#ifdef HAVE_SANDBOX\n\tif (sandbox != 0 && !(ea.argt & EX_SBOXOK))\n\t{\n\t    \/\/ Command not allowed in sandbox.\n\t    errormsg = _(e_not_allowed_in_sandbox);\n\t    goto doend;\n\t}\n#endif\n\tif (restricted != 0 && (ea.argt & EX_RESTRICT))\n\t{\n\t    errormsg = _(e_command_not_allowed_in_rvim);\n\t    goto doend;\n\t}\n\tif (!curbuf->b_p_ma && (ea.argt & EX_MODIFY))\n\t{\n\t    \/\/ Command not allowed in non-'modifiable' buffer\n\t    errormsg = _(e_cannot_make_changes_modifiable_is_off);\n\t    goto doend;\n\t}\n\n\tif (!IS_USER_CMDIDX(ea.cmdidx))\n\t{\n#ifdef FEAT_CMDWIN\n\t    if (cmdwin_type != 0 && !(ea.argt & EX_CMDWIN))\n\t    {\n\t\t\/\/ Command not allowed in the command line window\n\t\terrormsg = _(e_invalid_in_cmdline_window);\n\t\tgoto doend;\n\t    }\n#endif\n\t    if (text_locked() && !(ea.argt & EX_LOCK_OK))\n\t    {\n\t\t\/\/ Command not allowed when text is locked\n\t\terrormsg = _(get_text_locked_msg());\n\t\tgoto doend;\n\t    }\n\t}\n\n\t\/\/ Disallow editing another buffer when \"curbuf_lock\" is set.\n\t\/\/ Do allow \":checktime\" (it is postponed).\n\t\/\/ Do allow \":edit\" (check for an argument later).\n\t\/\/ Do allow \":file\" with no arguments (check for an argument later).\n\tif (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK))\n\t\t&& ea.cmdidx != CMD_checktime\n\t\t&& ea.cmdidx != CMD_edit\n\t\t&& ea.cmdidx != CMD_file\n\t\t&& !IS_USER_CMDIDX(ea.cmdidx)\n\t\t&& curbuf_locked())\n\t    goto doend;\n\n\tif (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0)\n\t{\n\t    errormsg = _(e_no_range_allowed);\n\t    goto doend;\n\t}\n    }\n\n    if (!ni && !(ea.argt & EX_BANG) && ea.forceit)\n    {\n\terrormsg = _(e_no_bang_allowed);\n\tgoto doend;\n    }\n\n    \/*\n     * Don't complain about the range if it is not used\n     * (could happen if line_count is accidentally set to 0).\n     *\/\n    if (!ea.skip && !ni && (ea.argt & EX_RANGE))\n    {\n\t\/*\n\t * If the range is backwards, ask for confirmation and, if given, swap\n\t * ea.line1 & ea.line2 so it's forwards again.\n\t * When global command is busy, don't ask, will fail below.\n\t *\/\n\tif (!global_busy && ea.line1 > ea.line2)\n\t{\n\t    if (msg_silent == 0)\n\t    {\n\t\tif (sourcing || exmode_active)\n\t\t{\n\t\t    errormsg = _(e_backwards_range_given);\n\t\t    goto doend;\n\t\t}\n\t\tif (ask_yesno((char_u *)\n\t\t\t_(\"Backwards range given, OK to swap\"), FALSE) != 'y')\n\t\t    goto doend;\n\t    }\n\t    lnum = ea.line1;\n\t    ea.line1 = ea.line2;\n\t    ea.line2 = lnum;\n\t}\n\tif ((errormsg = invalid_range(&ea)) != NULL)\n\t    goto doend;\n    }\n\n    if ((ea.addr_type == ADDR_OTHER) && ea.addr_count == 0)\n\t\/\/ default is 1, not cursor\n\tea.line2 = 1;\n\n    correct_range(&ea);\n\n#ifdef FEAT_FOLDING\n    if (((ea.argt & EX_WHOLEFOLD) || ea.addr_count >= 2) && !global_busy\n\t    && ea.addr_type == ADDR_LINES)\n    {\n\t\/\/ Put the first line at the start of a closed fold, put the last line\n\t\/\/ at the end of a closed fold.\n\t(void)hasFolding(ea.line1, &ea.line1, NULL);\n\t(void)hasFolding(ea.line2, NULL, &ea.line2);\n    }\n#endif\n\n#ifdef FEAT_QUICKFIX\n    \/*\n     * For the \":make\" and \":grep\" commands we insert the 'makeprg'\/'grepprg'\n     * option here, so things like % get expanded.\n     *\/\n    p = replace_makeprg(&ea, p, cmdlinep);\n    if (p == NULL)\n\tgoto doend;\n#endif\n\n    \/*\n     * Skip to start of argument.\n     * Don't do this for the \":!\" command, because \":!! -l\" needs the space.\n     *\/\n    if (ea.cmdidx == CMD_bang)\n\tea.arg = p;\n    else\n\tea.arg = skipwhite(p);\n\n    \/\/ \":file\" cannot be run with an argument when \"curbuf_lock\" is set\n    if (ea.cmdidx == CMD_file && *ea.arg != NUL && curbuf_locked())\n\tgoto doend;\n\n    \/*\n     * Check for \"++opt=val\" argument.\n     * Must be first, allow \":w ++enc=utf8 !cmd\"\n     *\/\n    if (ea.argt & EX_ARGOPT)\n\twhile (ea.arg[0] == '+' && ea.arg[1] == '+')\n\t    if (getargopt(&ea) == FAIL && !ni)\n\t    {\n\t\terrormsg = _(e_invalid_argument);\n\t\tgoto doend;\n\t    }\n\n    if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update)\n    {\n\tif (*ea.arg == '>')\t\t\t\/\/ append\n\t{\n\t    if (*++ea.arg != '>')\t\t\/\/ typed wrong\n\t    {\n\t\terrormsg = _(e_use_w_or_w_gt_gt);\n\t\tgoto doend;\n\t    }\n\t    ea.arg = skipwhite(ea.arg + 1);\n\t    ea.append = TRUE;\n\t}\n\telse if (*ea.arg == '!' && ea.cmdidx == CMD_write)  \/\/ :w !filter\n\t{\n\t    ++ea.arg;\n\t    ea.usefilter = TRUE;\n\t}\n    }\n\n    if (ea.cmdidx == CMD_read)\n    {\n\tif (ea.forceit)\n\t{\n\t    ea.usefilter = TRUE;\t\t\/\/ :r! filter if ea.forceit\n\t    ea.forceit = FALSE;\n\t}\n\telse if (*ea.arg == '!')\t\t\/\/ :r !filter\n\t{\n\t    ++ea.arg;\n\t    ea.usefilter = TRUE;\n\t}\n    }\n\n    if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift)\n    {\n\tea.amount = 1;\n\twhile (*ea.arg == *ea.cmd)\t\t\/\/ count number of '>' or '<'\n\t{\n\t    ++ea.arg;\n\t    ++ea.amount;\n\t}\n\tea.arg = skipwhite(ea.arg);\n    }\n\n    \/*\n     * Check for \"+command\" argument, before checking for next command.\n     * Don't do this for \":read !cmd\" and \":write !cmd\".\n     *\/\n    if ((ea.argt & EX_CMDARG) && !ea.usefilter)\n\tea.do_ecmd_cmd = getargcmd(&ea.arg);\n\n    \/*\n     * For commands that do not use '|' inside their argument: Check for '|' to\n     * separate commands and '\"' or '#' to start comments.\n     *\n     * Otherwise: Check for <newline> to end a shell command.\n     * Also do this for \":read !cmd\", \":write !cmd\" and \":global\".\n     * Also do this inside a { - } block after :command and :autocmd.\n     * Any others?\n     *\/\n    if ((ea.argt & EX_TRLBAR) && !ea.usefilter)\n    {\n\tseparate_nextcmd(&ea, FALSE);\n    }\n    else if (ea.cmdidx == CMD_bang\n\t    || ea.cmdidx == CMD_terminal\n\t    || ea.cmdidx == CMD_global\n\t    || ea.cmdidx == CMD_vglobal\n\t    || ea.usefilter\n#ifdef FEAT_EVAL\n\t    || inside_block(&ea)\n#endif\n\t    )\n    {\n\tfor (p = ea.arg; *p; ++p)\n\t{\n\t    \/\/ Remove one backslash before a newline, so that it's possible to\n\t    \/\/ pass a newline to the shell and also a newline that is preceded\n\t    \/\/ with a backslash.  This makes it impossible to end a shell\n\t    \/\/ command in a backslash, but that doesn't appear useful.\n\t    \/\/ Halving the number of backslashes is incompatible with previous\n\t    \/\/ versions.\n\t    if (*p == '\\\\' && p[1] == '\\n')\n\t\tSTRMOVE(p, p + 1);\n\t    else if (*p == '\\n' && !(ea.argt & EX_EXPR_ARG))\n\t    {\n\t\tea.nextcmd = p + 1;\n\t\t*p = NUL;\n\t\tbreak;\n\t    }\n\t}\n    }\n\n    if ((ea.argt & EX_DFLALL) && ea.addr_count == 0)\n\taddress_default_all(&ea);\n\n    \/\/ accept numbered register only when no count allowed (:put)\n    if (       (ea.argt & EX_REGSTR)\n\t    && *ea.arg != NUL\n\t       \/\/ Do not allow register = for user commands\n\t    && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')\n\t    && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)))\n    {\n#ifndef FEAT_CLIPBOARD\n\t\/\/ check these explicitly for a more specific error message\n\tif (*ea.arg == '*' || *ea.arg == '+')\n\t{\n\t    errormsg = _(e_invalid_register_name);\n\t    goto doend;\n\t}\n#endif\n\tif (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put\n\t\t\t\t\t      && !IS_USER_CMDIDX(ea.cmdidx))))\n\t{\n\t    ea.regname = *ea.arg++;\n#ifdef FEAT_EVAL\n\t    \/\/ for '=' register: accept the rest of the line as an expression\n\t    if (ea.arg[-1] == '=' && ea.arg[0] != NUL)\n\t    {\n\t\tif (!ea.skip)\n\t\t{\n\t\t    set_expr_line(vim_strsave(ea.arg), &ea);\n\t\t    did_set_expr_line = TRUE;\n\t\t}\n\t\tea.arg += STRLEN(ea.arg);\n\t    }\n#endif\n\t    ea.arg = skipwhite(ea.arg);\n\t}\n    }\n\n    \/*\n     * Check for a count.  When accepting a EX_BUFNAME, don't use \"123foo\" as a\n     * count, it's a buffer name.\n     *\/\n    if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)\n\t    && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL\n\t\t\t\t\t\t\t  || VIM_ISWHITE(*p)))\n    {\n\tn = getdigits_quoted(&ea.arg);\n\tea.arg = skipwhite(ea.arg);\n\tif (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0)\n\t{\n\t    errormsg = _(e_positive_count_required);\n\t    goto doend;\n\t}\n\tif (ea.addr_type != ADDR_LINES)\t\/\/ e.g. :buffer 2, :sleep 3\n\t{\n\t    ea.line2 = n;\n\t    if (ea.addr_count == 0)\n\t\tea.addr_count = 1;\n\t}\n\telse\n\t{\n\t    ea.line1 = ea.line2;\n\t    if (ea.line2 >= LONG_MAX - (n - 1))\n\t        ea.line2 = LONG_MAX;  \/\/ avoid overflow\n\t    else\n\t\tea.line2 += n - 1;\n\t    ++ea.addr_count;\n\t    \/*\n\t     * Be vi compatible: no error message for out of range.\n\t     *\/\n\t    if (ea.line2 > curbuf->b_ml.ml_line_count)\n\t\tea.line2 = curbuf->b_ml.ml_line_count;\n\t}\n    }\n\n    \/*\n     * Check for flags: 'l', 'p' and '#'.\n     *\/\n    if (ea.argt & EX_FLAGS)\n\tget_flags(&ea);\n    if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL\n\t    && *ea.arg != '\"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0))\n    {\n\t\/\/ no arguments allowed but there is something\n\terrormsg = ex_errmsg(e_trailing_characters_str, ea.arg);\n\tgoto doend;\n    }\n\n    if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL)\n    {\n\terrormsg = _(e_argument_required);\n\tgoto doend;\n    }\n\n#ifdef FEAT_EVAL\n    \/*\n     * Skip the command when it's not going to be executed.\n     * The commands like :if, :endif, etc. always need to be executed.\n     * Also make an exception for commands that handle a trailing command\n     * themselves.\n     *\/\n    if (ea.skip)\n    {\n\tswitch (ea.cmdidx)\n\t{\n\t    \/\/ commands that need evaluation\n\t    case CMD_while:\n\t    case CMD_endwhile:\n\t    case CMD_for:\n\t    case CMD_endfor:\n\t    case CMD_if:\n\t    case CMD_elseif:\n\t    case CMD_else:\n\t    case CMD_endif:\n\t    case CMD_try:\n\t    case CMD_catch:\n\t    case CMD_finally:\n\t    case CMD_endtry:\n\t    case CMD_function:\n\t    case CMD_def:\n\t\t\t\tbreak;\n\n\t    \/\/ Commands that handle '|' themselves.  Check: A command should\n\t    \/\/ either have the EX_TRLBAR flag, appear in this list or appear in\n\t    \/\/ the list at \":help :bar\".\n\t    case CMD_aboveleft:\n\t    case CMD_and:\n\t    case CMD_belowright:\n\t    case CMD_botright:\n\t    case CMD_browse:\n\t    case CMD_call:\n\t    case CMD_confirm:\n\t    case CMD_const:\n\t    case CMD_delfunction:\n\t    case CMD_djump:\n\t    case CMD_dlist:\n\t    case CMD_dsearch:\n\t    case CMD_dsplit:\n\t    case CMD_echo:\n\t    case CMD_echoerr:\n\t    case CMD_echomsg:\n\t    case CMD_echon:\n\t    case CMD_eval:\n\t    case CMD_execute:\n\t    case CMD_filter:\n\t    case CMD_final:\n\t    case CMD_help:\n\t    case CMD_hide:\n\t    case CMD_ijump:\n\t    case CMD_ilist:\n\t    case CMD_isearch:\n\t    case CMD_isplit:\n\t    case CMD_keepalt:\n\t    case CMD_keepjumps:\n\t    case CMD_keepmarks:\n\t    case CMD_keeppatterns:\n\t    case CMD_leftabove:\n\t    case CMD_let:\n\t    case CMD_lockmarks:\n\t    case CMD_lockvar:\n\t    case CMD_lua:\n\t    case CMD_match:\n\t    case CMD_mzscheme:\n\t    case CMD_noautocmd:\n\t    case CMD_noswapfile:\n\t    case CMD_perl:\n\t    case CMD_psearch:\n\t    case CMD_py3:\n\t    case CMD_python3:\n\t    case CMD_python:\n\t    case CMD_return:\n\t    case CMD_rightbelow:\n\t    case CMD_ruby:\n\t    case CMD_silent:\n\t    case CMD_smagic:\n\t    case CMD_snomagic:\n\t    case CMD_substitute:\n\t    case CMD_syntax:\n\t    case CMD_tab:\n\t    case CMD_tcl:\n\t    case CMD_throw:\n\t    case CMD_tilde:\n\t    case CMD_topleft:\n\t    case CMD_unlet:\n\t    case CMD_unlockvar:\n\t    case CMD_var:\n\t    case CMD_verbose:\n\t    case CMD_vertical:\n\t    case CMD_wincmd:\n\t\t\t\tbreak;\n\n\t    default:\t\tgoto doend;\n\t}\n    }\n#endif\n\n    if (ea.argt & EX_XFILE)\n    {\n\tif (expand_filename(&ea, cmdlinep, &errormsg) == FAIL)\n\t    goto doend;\n    }\n\n    \/*\n     * Accept buffer name.  Cannot be used at the same time with a buffer\n     * number.  Don't do this for a user command.\n     *\/\n    if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0\n\t    && !IS_USER_CMDIDX(ea.cmdidx))\n    {\n\t\/*\n\t * :bdelete, :bwipeout and :bunload take several arguments, separated\n\t * by spaces: find next space (skipping over escaped characters).\n\t * The others take one argument: ignore trailing spaces.\n\t *\/\n\tif (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout\n\t\t\t\t\t\t  || ea.cmdidx == CMD_bunload)\n\t    p = skiptowhite_esc(ea.arg);\n\telse\n\t{\n\t    p = ea.arg + STRLEN(ea.arg);\n\t    while (p > ea.arg && VIM_ISWHITE(p[-1]))\n\t\t--p;\n\t}\n\tea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,\n\t\t\t\t\t\t\t\tFALSE, FALSE);\n\tif (ea.line2 < 0)\t    \/\/ failed\n\t    goto doend;\n\tea.addr_count = 1;\n\tea.arg = skipwhite(p);\n    }\n\n    \/\/ The :try command saves the emsg_silent flag, reset it here when\n    \/\/ \":silent! try\" was used, it should only apply to :try itself.\n    if (ea.cmdidx == CMD_try && cmdmod.cmod_did_esilent > 0)\n    {\n\temsg_silent -= cmdmod.cmod_did_esilent;\n\tif (emsg_silent < 0)\n\t    emsg_silent = 0;\n\tcmdmod.cmod_did_esilent = 0;\n    }\n\n\/*\n * 7. Execute the command.\n *\/\n\n    if (IS_USER_CMDIDX(ea.cmdidx))\n    {\n\t\/*\n\t * Execute a user-defined command.\n\t *\/\n\tdo_ucmd(&ea);\n    }\n    else\n    {\n\t\/*\n\t * Call the function to execute the builtin command.\n\t *\/\n\tea.errmsg = NULL;\n\t(cmdnames[ea.cmdidx].cmd_func)(&ea);\n\tif (ea.errmsg != NULL)\n\t    errormsg = ea.errmsg;\n    }\n\n#ifdef FEAT_EVAL\n    \/\/ Set flag that any command was executed, used by ex_vim9script().\n    \/\/ Not if this was a command that wasn't executed or :endif.\n    if (sourcing_a_script(&ea)\n\t    && current_sctx.sc_sid > 0\n\t    && ea.cmdidx != CMD_endif\n\t    && (cstack->cs_idx < 0\n\t\t    || (cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)))\n\tSCRIPT_ITEM(current_sctx.sc_sid)->sn_state = SN_STATE_HAD_COMMAND;\n\n    \/*\n     * If the command just executed called do_cmdline(), any throw or \":return\"\n     * or \":finish\" encountered there must also check the cstack of the still\n     * active do_cmdline() that called this do_one_cmd().  Rethrow an uncaught\n     * exception, or reanimate a returned function or finished script file and\n     * return or finish it again.\n     *\/\n    if (need_rethrow)\n\tdo_throw(cstack);\n    else if (check_cstack)\n    {\n\tif (source_finished(fgetline, cookie))\n\t    do_finish(&ea, TRUE);\n\telse if (getline_equal(fgetline, cookie, get_func_line)\n\t\t\t\t\t\t   && current_func_returned())\n\t    do_return(&ea, TRUE, FALSE, NULL);\n    }\n    need_rethrow = check_cstack = FALSE;\n#endif\n\ndoend:\n    if (curwin->w_cursor.lnum == 0)\t\/\/ can happen with zero line number\n    {\n\tcurwin->w_cursor.lnum = 1;\n\tcurwin->w_cursor.col = 0;\n    }\n\n    if (errormsg != NULL && *errormsg != NUL && !did_emsg)\n    {\n\tif (sourcing || !KeyTyped)\n\t{\n\t    if (errormsg != (char *)IObuff)\n\t    {\n\t\tSTRCPY(IObuff, errormsg);\n\t\terrormsg = (char *)IObuff;\n\t    }\n\t    append_command(*cmdlinep);\n\t}\n\temsg(errormsg);\n    }\n#ifdef FEAT_EVAL\n    do_errthrow(cstack,\n\t    (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx))\n\t\t\t? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);\n\n    if (did_set_expr_line)\n\tset_expr_line(NULL, NULL);\n#endif\n\n    undo_cmdmod(&cmdmod);\n    cmdmod = save_cmdmod;\n    reg_executing = save_reg_executing;\n    pending_end_reg_executing = save_pending_end_reg_executing;\n\n    if (ea.nextcmd && *ea.nextcmd == NUL)\t\/\/ not really a next command\n\tea.nextcmd = NULL;\n\n#ifdef FEAT_EVAL\n    --ex_nesting_level;\n    vim_free(ea.cmdline_tofree);\n#endif\n\n    return ea.nextcmd;\n}","target":0,"code_token_length":7100,"total_token_length":7336,"max_tokens_setting":8192}
+{"idx":328807,"func":"do_put(\n    int\t\tregname,\n    char_u\t*expr_result,\t\/\/ result for regname \"=\" when compiled\n    int\t\tdir,\t\t\/\/ BACKWARD for 'P', FORWARD for 'p'\n    long\tcount,\n    int\t\tflags)\n{\n    char_u\t*ptr;\n    char_u\t*newp, *oldp;\n    int\t\tyanklen;\n    int\t\ttotlen = 0;\t\t\/\/ init for gcc\n    linenr_T\tlnum;\n    colnr_T\tcol;\n    long\ti;\t\t\t\/\/ index in y_array[]\n    int\t\ty_type;\n    long\ty_size;\n    int\t\toldlen;\n    long\ty_width = 0;\n    colnr_T\tvcol;\n    int\t\tdelcount;\n    int\t\tincr = 0;\n    long\tj;\n    struct block_def bd;\n    char_u\t**y_array = NULL;\n    yankreg_T\t*y_current_used = NULL;\n    long\tnr_lines = 0;\n    pos_T\tnew_cursor;\n    int\t\tindent;\n    int\t\torig_indent = 0;\t\/\/ init for gcc\n    int\t\tindent_diff = 0;\t\/\/ init for gcc\n    int\t\tfirst_indent = TRUE;\n    int\t\tlendiff = 0;\n    pos_T\told_pos;\n    char_u\t*insert_string = NULL;\n    int\t\tallocated = FALSE;\n    long\tcnt;\n    pos_T\torig_start = curbuf->b_op_start;\n    pos_T\torig_end = curbuf->b_op_end;\n    unsigned int cur_ve_flags = get_ve_flags();\n\n#ifdef FEAT_CLIPBOARD\n    \/\/ Adjust register name for \"unnamed\" in 'clipboard'.\n    adjust_clip_reg(®name);\n    (void)may_get_selection(regname);\n#endif\n\n    if (flags & PUT_FIXINDENT)\n\torig_indent = get_indent();\n\n    curbuf->b_op_start = curwin->w_cursor;\t\/\/ default for '[ mark\n    curbuf->b_op_end = curwin->w_cursor;\t\/\/ default for '] mark\n\n    \/\/ Using inserted text works differently, because the register includes\n    \/\/ special characters (newlines, etc.).\n    if (regname == '.')\n    {\n\tif (VIsual_active)\n\t    stuffcharReadbuff(VIsual_mode);\n\t(void)stuff_inserted((dir == FORWARD ? (count == -1 ? 'o' : 'a') :\n\t\t\t\t    (count == -1 ? 'O' : 'i')), count, FALSE);\n\t\/\/ Putting the text is done later, so can't really move the cursor to\n\t\/\/ the next character.  Use \"l\" to simulate it.\n\tif ((flags & PUT_CURSEND) && gchar_cursor() != NUL)\n\t    stuffcharReadbuff('l');\n\treturn;\n    }\n\n    \/\/ For special registers '%' (file name), '#' (alternate file name) and\n    \/\/ ':' (last command line), etc. we have to create a fake yank register.\n    \/\/ For compiled code \"expr_result\" holds the expression result.\n    if (regname == '=' && expr_result != NULL)\n\tinsert_string = expr_result;\n    else if (get_spec_reg(regname, &insert_string, &allocated, TRUE)\n\t\t&& insert_string == NULL)\n\treturn;\n\n    \/\/ Autocommands may be executed when saving lines for undo.  This might\n    \/\/ make \"y_array\" invalid, so we start undo now to avoid that.\n    if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL)\n\tgoto end;\n\n    if (insert_string != NULL)\n    {\n\ty_type = MCHAR;\n#ifdef FEAT_EVAL\n\tif (regname == '=')\n\t{\n\t    \/\/ For the = register we need to split the string at NL\n\t    \/\/ characters.\n\t    \/\/ Loop twice: count the number of lines and save them.\n\t    for (;;)\n\t    {\n\t\ty_size = 0;\n\t\tptr = insert_string;\n\t\twhile (ptr != NULL)\n\t\t{\n\t\t    if (y_array != NULL)\n\t\t\ty_array[y_size] = ptr;\n\t\t    ++y_size;\n\t\t    ptr = vim_strchr(ptr, '\\n');\n\t\t    if (ptr != NULL)\n\t\t    {\n\t\t\tif (y_array != NULL)\n\t\t\t    *ptr = NUL;\n\t\t\t++ptr;\n\t\t\t\/\/ A trailing '\\n' makes the register linewise.\n\t\t\tif (*ptr == NUL)\n\t\t\t{\n\t\t\t    y_type = MLINE;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (y_array != NULL)\n\t\t    break;\n\t\ty_array = ALLOC_MULT(char_u *, y_size);\n\t\tif (y_array == NULL)\n\t\t    goto end;\n\t    }\n\t}\n\telse\n#endif\n\t{\n\t    y_size = 1;\t\t\/\/ use fake one-line yank register\n\t    y_array = &insert_string;\n\t}\n    }\n    else\n    {\n\tget_yank_register(regname, FALSE);\n\n\ty_type = y_current->y_type;\n\ty_width = y_current->y_width;\n\ty_size = y_current->y_size;\n\ty_array = y_current->y_array;\n\ty_current_used = y_current;\n    }\n\n    if (y_type == MLINE)\n    {\n\tif (flags & PUT_LINE_SPLIT)\n\t{\n\t    char_u *p;\n\n\t    \/\/ \"p\" or \"P\" in Visual mode: split the lines to put the text in\n\t    \/\/ between.\n\t    if (u_save_cursor() == FAIL)\n\t\tgoto end;\n\t    p = ml_get_cursor();\n\t    if (dir == FORWARD && *p != NUL)\n\t\tMB_PTR_ADV(p);\n\t    ptr = vim_strsave(p);\n\t    if (ptr == NULL)\n\t\tgoto end;\n\t    ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);\n\t    vim_free(ptr);\n\n\t    oldp = ml_get_curline();\n\t    p = oldp + curwin->w_cursor.col;\n\t    if (dir == FORWARD && *p != NUL)\n\t\tMB_PTR_ADV(p);\n\t    ptr = vim_strnsave(oldp, p - oldp);\n\t    if (ptr == NULL)\n\t\tgoto end;\n\t    ml_replace(curwin->w_cursor.lnum, ptr, FALSE);\n\t    ++nr_lines;\n\t    dir = FORWARD;\n\t}\n\tif (flags & PUT_LINE_FORWARD)\n\t{\n\t    \/\/ Must be \"p\" for a Visual block, put lines below the block.\n\t    curwin->w_cursor = curbuf->b_visual.vi_end;\n\t    dir = FORWARD;\n\t}\n\tcurbuf->b_op_start = curwin->w_cursor;\t\/\/ default for '[ mark\n\tcurbuf->b_op_end = curwin->w_cursor;\t\/\/ default for '] mark\n    }\n\n    if (flags & PUT_LINE)\t\/\/ :put command or \"p\" in Visual line mode.\n\ty_type = MLINE;\n\n    if (y_size == 0 || y_array == NULL)\n    {\n\tsemsg(_(e_nothing_in_register_str),\n\t\t  regname == 0 ? (char_u *)\"\\\"\" : transchar(regname));\n\tgoto end;\n    }\n\n    if (y_type == MBLOCK)\n    {\n\tlnum = curwin->w_cursor.lnum + y_size + 1;\n\tif (lnum > curbuf->b_ml.ml_line_count)\n\t    lnum = curbuf->b_ml.ml_line_count + 1;\n\tif (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)\n\t    goto end;\n    }\n    else if (y_type == MLINE)\n    {\n\tlnum = curwin->w_cursor.lnum;\n#ifdef FEAT_FOLDING\n\t\/\/ Correct line number for closed fold.  Don't move the cursor yet,\n\t\/\/ u_save() uses it.\n\tif (dir == BACKWARD)\n\t    (void)hasFolding(lnum, &lnum, NULL);\n\telse\n\t    (void)hasFolding(lnum, NULL, &lnum);\n#endif\n\tif (dir == FORWARD)\n\t    ++lnum;\n\t\/\/ In an empty buffer the empty line is going to be replaced, include\n\t\/\/ it in the saved lines.\n\tif ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL)\n\t    goto end;\n#ifdef FEAT_FOLDING\n\tif (dir == FORWARD)\n\t    curwin->w_cursor.lnum = lnum - 1;\n\telse\n\t    curwin->w_cursor.lnum = lnum;\n\tcurbuf->b_op_start = curwin->w_cursor;\t\/\/ for mark_adjust()\n#endif\n    }\n    else if (u_save_cursor() == FAIL)\n\tgoto end;\n\n    yanklen = (int)STRLEN(y_array[0]);\n\n    if (cur_ve_flags == VE_ALL && y_type == MCHAR)\n    {\n\tif (gchar_cursor() == TAB)\n\t{\n\t    int viscol = getviscol();\n\t    int ts = curbuf->b_p_ts;\n\n\t    \/\/ Don't need to insert spaces when \"p\" on the last position of a\n\t    \/\/ tab or \"P\" on the first position.\n\t    if (dir == FORWARD ?\n#ifdef FEAT_VARTABS\n\t\t    tabstop_padding(viscol, ts, curbuf->b_p_vts_array) != 1\n#else\n\t\t    ts - (viscol % ts) != 1\n#endif\n\t\t    : curwin->w_cursor.coladd > 0)\n\t\tcoladvance_force(viscol);\n\t    else\n\t\tcurwin->w_cursor.coladd = 0;\n\t}\n\telse if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)\n\t    coladvance_force(getviscol() + (dir == FORWARD));\n    }\n\n    lnum = curwin->w_cursor.lnum;\n    col = curwin->w_cursor.col;\n\n    \/\/ Block mode\n    if (y_type == MBLOCK)\n    {\n\tint\tc = gchar_cursor();\n\tcolnr_T\tendcol2 = 0;\n\n\tif (dir == FORWARD && c != NUL)\n\t{\n\t    if (cur_ve_flags == VE_ALL)\n\t\tgetvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);\n\t    else\n\t\tgetvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);\n\n\t    if (has_mbyte)\n\t\t\/\/ move to start of next multi-byte character\n\t\tcurwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());\n\t    else\n\t    if (c != TAB || cur_ve_flags != VE_ALL)\n\t\t++curwin->w_cursor.col;\n\t    ++col;\n\t}\n\telse\n\t    getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);\n\n\tcol += curwin->w_cursor.coladd;\n\tif (cur_ve_flags == VE_ALL\n\t\t&& (curwin->w_cursor.coladd > 0\n\t\t    || endcol2 == curwin->w_cursor.col))\n\t{\n\t    if (dir == FORWARD && c == NUL)\n\t\t++col;\n\t    if (dir != FORWARD && c != NUL && curwin->w_cursor.coladd > 0)\n\t\t++curwin->w_cursor.col;\n\t    if (c == TAB)\n\t    {\n\t\tif (dir == BACKWARD && curwin->w_cursor.col)\n\t\t    curwin->w_cursor.col--;\n\t\tif (dir == FORWARD && col - 1 == endcol2)\n\t\t    curwin->w_cursor.col++;\n\t    }\n\t}\n\tcurwin->w_cursor.coladd = 0;\n\tbd.textcol = 0;\n\tfor (i = 0; i < y_size; ++i)\n\t{\n\t    int spaces = 0;\n\t    char shortline;\n\n\t    bd.startspaces = 0;\n\t    bd.endspaces = 0;\n\t    vcol = 0;\n\t    delcount = 0;\n\n\t    \/\/ add a new line\n\t    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t    {\n\t\tif (ml_append(curbuf->b_ml.ml_line_count, (char_u *)\"\",\n\t\t\t\t\t\t   (colnr_T)1, FALSE) == FAIL)\n\t\t    break;\n\t\t++nr_lines;\n\t    }\n\t    \/\/ get the old line and advance to the position to insert at\n\t    oldp = ml_get_curline();\n\t    oldlen = (int)STRLEN(oldp);\n\t    for (ptr = oldp; vcol < col && *ptr; )\n\t    {\n\t\t\/\/ Count a tab for what it's worth (if list mode not on)\n\t\tincr = lbr_chartabsize_adv(oldp, &ptr, vcol);\n\t\tvcol += incr;\n\t    }\n\t    bd.textcol = (colnr_T)(ptr - oldp);\n\n\t    shortline = (vcol < col) || (vcol == col && !*ptr) ;\n\n\t    if (vcol < col) \/\/ line too short, padd with spaces\n\t\tbd.startspaces = col - vcol;\n\t    else if (vcol > col)\n\t    {\n\t\tbd.endspaces = vcol - col;\n\t\tbd.startspaces = incr - bd.endspaces;\n\t\t--bd.textcol;\n\t\tdelcount = 1;\n\t\tif (has_mbyte)\n\t\t    bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);\n\t\tif (oldp[bd.textcol] != TAB)\n\t\t{\n\t\t    \/\/ Only a Tab can be split into spaces.  Other\n\t\t    \/\/ characters will have to be moved to after the\n\t\t    \/\/ block, causing misalignment.\n\t\t    delcount = 0;\n\t\t    bd.endspaces = 0;\n\t\t}\n\t    }\n\n\t    yanklen = (int)STRLEN(y_array[i]);\n\n\t    if ((flags & PUT_BLOCK_INNER) == 0)\n\t    {\n\t\t\/\/ calculate number of spaces required to fill right side of\n\t\t\/\/ block\n\t\tspaces = y_width + 1;\n\t\tfor (j = 0; j < yanklen; j++)\n\t\t    spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);\n\t\tif (spaces < 0)\n\t\t    spaces = 0;\n\t    }\n\n\t    \/\/ Insert the new text.\n\t    \/\/ First check for multiplication overflow.\n\t    if (yanklen + spaces != 0\n\t\t     && count > ((INT_MAX - (bd.startspaces + bd.endspaces))\n\t\t\t\t\t\t\t\/ (yanklen + spaces)))\n\t    {\n\t\temsg(_(e_resulting_text_too_long));\n\t\tbreak;\n\t    }\n\n\t    totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;\n\t    newp = alloc(totlen + oldlen + 1);\n\t    if (newp == NULL)\n\t\tbreak;\n\n\t    \/\/ copy part up to cursor to new line\n\t    ptr = newp;\n\t    mch_memmove(ptr, oldp, (size_t)bd.textcol);\n\t    ptr += bd.textcol;\n\n\t    \/\/ may insert some spaces before the new text\n\t    vim_memset(ptr, ' ', (size_t)bd.startspaces);\n\t    ptr += bd.startspaces;\n\n\t    \/\/ insert the new text\n\t    for (j = 0; j < count; ++j)\n\t    {\n\t\tmch_memmove(ptr, y_array[i], (size_t)yanklen);\n\t\tptr += yanklen;\n\n\t\t\/\/ insert block's trailing spaces only if there's text behind\n\t\tif ((j < count - 1 || !shortline) && spaces)\n\t\t{\n\t\t    vim_memset(ptr, ' ', (size_t)spaces);\n\t\t    ptr += spaces;\n\t\t}\n\t\telse\n\t\t    totlen -= spaces;  \/\/ didn't use these spaces\n\t    }\n\n\t    \/\/ may insert some spaces after the new text\n\t    vim_memset(ptr, ' ', (size_t)bd.endspaces);\n\t    ptr += bd.endspaces;\n\n\t    \/\/ move the text after the cursor to the end of the line.\n\t    mch_memmove(ptr, oldp + bd.textcol + delcount,\n\t\t\t\t(size_t)(oldlen - bd.textcol - delcount + 1));\n\t    ml_replace(curwin->w_cursor.lnum, newp, FALSE);\n\n\t    ++curwin->w_cursor.lnum;\n\t    if (i == 0)\n\t\tcurwin->w_cursor.col += bd.startspaces;\n\t}\n\n\tchanged_lines(lnum, 0, curwin->w_cursor.lnum, nr_lines);\n\n\t\/\/ Set '[ mark.\n\tcurbuf->b_op_start = curwin->w_cursor;\n\tcurbuf->b_op_start.lnum = lnum;\n\n\t\/\/ adjust '] mark\n\tcurbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;\n\tcurbuf->b_op_end.col = bd.textcol + totlen - 1;\n\tcurbuf->b_op_end.coladd = 0;\n\tif (flags & PUT_CURSEND)\n\t{\n\t    colnr_T len;\n\n\t    curwin->w_cursor = curbuf->b_op_end;\n\t    curwin->w_cursor.col++;\n\n\t    \/\/ in Insert mode we might be after the NUL, correct for that\n\t    len = (colnr_T)STRLEN(ml_get_curline());\n\t    if (curwin->w_cursor.col > len)\n\t\tcurwin->w_cursor.col = len;\n\t}\n\telse\n\t    curwin->w_cursor.lnum = lnum;\n    }\n    else\n    {\n\t\/\/ Character or Line mode\n\tif (y_type == MCHAR)\n\t{\n\t    \/\/ if type is MCHAR, FORWARD is the same as BACKWARD on the next\n\t    \/\/ char\n\t    if (dir == FORWARD && gchar_cursor() != NUL)\n\t    {\n\t\tif (has_mbyte)\n\t\t{\n\t\t    int bytelen = (*mb_ptr2len)(ml_get_cursor());\n\n\t\t    \/\/ put it on the next of the multi-byte character.\n\t\t    col += bytelen;\n\t\t    if (yanklen)\n\t\t    {\n\t\t\tcurwin->w_cursor.col += bytelen;\n\t\t\tcurbuf->b_op_end.col += bytelen;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    ++col;\n\t\t    if (yanklen)\n\t\t    {\n\t\t\t++curwin->w_cursor.col;\n\t\t\t++curbuf->b_op_end.col;\n\t\t    }\n\t\t}\n\t    }\n\t    curbuf->b_op_start = curwin->w_cursor;\n\t}\n\t\/\/ Line mode: BACKWARD is the same as FORWARD on the previous line\n\telse if (dir == BACKWARD)\n\t    --lnum;\n\tnew_cursor = curwin->w_cursor;\n\n\t\/\/ simple case: insert into one line at a time\n\tif (y_type == MCHAR && y_size == 1)\n\t{\n\t    linenr_T\tend_lnum = 0; \/\/ init for gcc\n\t    linenr_T\tstart_lnum = lnum;\n\t    int\t\tfirst_byte_off = 0;\n\n\t    if (VIsual_active)\n\t    {\n\t\tend_lnum = curbuf->b_visual.vi_end.lnum;\n\t\tif (end_lnum < curbuf->b_visual.vi_start.lnum)\n\t\t    end_lnum = curbuf->b_visual.vi_start.lnum;\n\t\tif (end_lnum > start_lnum)\n\t\t{\n\t\t    pos_T   pos;\n\n\t\t    \/\/ \"col\" is valid for the first line, in following lines\n\t\t    \/\/ the virtual column needs to be used.  Matters for\n\t\t    \/\/ multi-byte characters.\n\t\t    pos.lnum = lnum;\n\t\t    pos.col = col;\n\t\t    pos.coladd = 0;\n\t\t    getvcol(curwin, &pos, NULL, &vcol, NULL);\n\t\t}\n\t    }\n\n\t    if (count == 0 || yanklen == 0)\n\t    {\n\t\tif (VIsual_active)\n\t\t    lnum = end_lnum;\n\t    }\n\t    else if (count > INT_MAX \/ yanklen)\n\t\t\/\/ multiplication overflow\n\t\temsg(_(e_resulting_text_too_long));\n\t    else\n\t    {\n\t\ttotlen = count * yanklen;\n\t\tdo {\n\t\t    oldp = ml_get(lnum);\n\t\t    oldlen = (int)STRLEN(oldp);\n\t\t    if (lnum > start_lnum)\n\t\t    {\n\t\t\tpos_T   pos;\n\n\t\t\tpos.lnum = lnum;\n\t\t\tif (getvpos(&pos, vcol) == OK)\n\t\t\t    col = pos.col;\n\t\t\telse\n\t\t\t    col = MAXCOL;\n\t\t    }\n\t\t    if (VIsual_active && col > oldlen)\n\t\t    {\n\t\t\tlnum++;\n\t\t\tcontinue;\n\t\t    }\n\t\t    newp = alloc(totlen + oldlen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto end;\t\/\/ alloc() gave an error message\n\t\t    mch_memmove(newp, oldp, (size_t)col);\n\t\t    ptr = newp + col;\n\t\t    for (i = 0; i < count; ++i)\n\t\t    {\n\t\t\tmch_memmove(ptr, y_array[0], (size_t)yanklen);\n\t\t\tptr += yanklen;\n\t\t    }\n\t\t    STRMOVE(ptr, oldp + col);\n\t\t    ml_replace(lnum, newp, FALSE);\n\n\t\t    \/\/ compute the byte offset for the last character\n\t\t    first_byte_off = mb_head_off(newp, ptr - 1);\n\n\t\t    \/\/ Place cursor on last putted char.\n\t\t    if (lnum == curwin->w_cursor.lnum)\n\t\t    {\n\t\t\t\/\/ make sure curwin->w_virtcol is updated\n\t\t\tchanged_cline_bef_curs();\n\t\t\tcurwin->w_cursor.col += (colnr_T)(totlen - 1);\n\t\t    }\n\t\t    if (VIsual_active)\n\t\t\tlnum++;\n\t\t} while (VIsual_active && lnum <= end_lnum);\n\n\t\tif (VIsual_active) \/\/ reset lnum to the last visual line\n\t\t    lnum--;\n\t    }\n\n\t    \/\/ put '] at the first byte of the last character\n\t    curbuf->b_op_end = curwin->w_cursor;\n\t    curbuf->b_op_end.col -= first_byte_off;\n\n\t    \/\/ For \"CTRL-O p\" in Insert mode, put cursor after last char\n\t    if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))\n\t\t++curwin->w_cursor.col;\n\t    else\n\t\tcurwin->w_cursor.col -= first_byte_off;\n\t    changed_bytes(lnum, col);\n\t}\n\telse\n\t{\n\t    linenr_T\tnew_lnum = new_cursor.lnum;\n\t    size_t\tlen;\n\n\t    \/\/ Insert at least one line.  When y_type is MCHAR, break the first\n\t    \/\/ line in two.\n\t    for (cnt = 1; cnt <= count; ++cnt)\n\t    {\n\t\ti = 0;\n\t\tif (y_type == MCHAR)\n\t\t{\n\t\t    \/\/ Split the current line in two at the insert position.\n\t\t    \/\/ First insert y_array[size - 1] in front of second line.\n\t\t    \/\/ Then append y_array[0] to first line.\n\t\t    lnum = new_cursor.lnum;\n\t\t    ptr = ml_get(lnum) + col;\n\t\t    totlen = (int)STRLEN(y_array[y_size - 1]);\n\t\t    newp = alloc(STRLEN(ptr) + totlen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto error;\n\t\t    STRCPY(newp, y_array[y_size - 1]);\n\t\t    STRCAT(newp, ptr);\n\t\t    \/\/ insert second line\n\t\t    ml_append(lnum, newp, (colnr_T)0, FALSE);\n\t\t    ++new_lnum;\n\t\t    vim_free(newp);\n\n\t\t    oldp = ml_get(lnum);\n\t\t    newp = alloc(col + yanklen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto error;\n\t\t\t\t\t    \/\/ copy first part of line\n\t\t    mch_memmove(newp, oldp, (size_t)col);\n\t\t\t\t\t    \/\/ append to first line\n\t\t    mch_memmove(newp + col, y_array[0], (size_t)(yanklen + 1));\n\t\t    ml_replace(lnum, newp, FALSE);\n\n\t\t    curwin->w_cursor.lnum = lnum;\n\t\t    i = 1;\n\t\t}\n\n\t\tfor (; i < y_size; ++i)\n\t\t{\n\t\t    if (y_type != MCHAR || i < y_size - 1)\n\t\t    {\n\t\t\tif (ml_append(lnum, y_array[i], (colnr_T)0, FALSE)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t\t\t    goto error;\n\t\t\tnew_lnum++;\n\t\t    }\n\t\t    lnum++;\n\t\t    ++nr_lines;\n\t\t    if (flags & PUT_FIXINDENT)\n\t\t    {\n\t\t\told_pos = curwin->w_cursor;\n\t\t\tcurwin->w_cursor.lnum = lnum;\n\t\t\tptr = ml_get(lnum);\n\t\t\tif (cnt == count && i == y_size - 1)\n\t\t\t    lendiff = (int)STRLEN(ptr);\n\t\t\tif (*ptr == '#' && preprocs_left())\n\t\t\t    indent = 0;     \/\/ Leave # lines at start\n\t\t\telse\n\t\t\t     if (*ptr == NUL)\n\t\t\t    indent = 0;     \/\/ Ignore empty lines\n\t\t\telse if (first_indent)\n\t\t\t{\n\t\t\t    indent_diff = orig_indent - get_indent();\n\t\t\t    indent = orig_indent;\n\t\t\t    first_indent = FALSE;\n\t\t\t}\n\t\t\telse if ((indent = get_indent() + indent_diff) < 0)\n\t\t\t    indent = 0;\n\t\t\t(void)set_indent(indent, 0);\n\t\t\tcurwin->w_cursor = old_pos;\n\t\t\t\/\/ remember how many chars were removed\n\t\t\tif (cnt == count && i == y_size - 1)\n\t\t\t    lendiff -= (int)STRLEN(ml_get(lnum));\n\t\t    }\n\t\t}\n\t\tif (cnt == 1)\n\t\t    new_lnum = lnum;\n\t    }\n\nerror:\n\t    \/\/ Adjust marks.\n\t    if (y_type == MLINE)\n\t    {\n\t\tcurbuf->b_op_start.col = 0;\n\t\tif (dir == FORWARD)\n\t\t    curbuf->b_op_start.lnum++;\n\t    }\n\t    \/\/ Skip mark_adjust when adding lines after the last one, there\n\t    \/\/ can't be marks there. But still needed in diff mode.\n\t    if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines\n\t\t\t\t\t\t < curbuf->b_ml.ml_line_count\n#ifdef FEAT_DIFF\n\t\t\t\t\t\t || curwin->w_p_diff\n#endif\n\t\t\t\t\t\t )\n\t\tmark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),\n\t\t\t\t\t     (linenr_T)MAXLNUM, nr_lines, 0L);\n\n\t    \/\/ note changed text for displaying and folding\n\t    if (y_type == MCHAR)\n\t\tchanged_lines(curwin->w_cursor.lnum, col,\n\t\t\t\t\t curwin->w_cursor.lnum + 1, nr_lines);\n\t    else\n\t\tchanged_lines(curbuf->b_op_start.lnum, 0,\n\t\t\t\t\t   curbuf->b_op_start.lnum, nr_lines);\n\t    if (y_current_used != NULL && (y_current_used != y_current\n\t\t\t\t\t     || y_current->y_array != y_array))\n\t    {\n\t\t\/\/ Something invoked through changed_lines() has changed the\n\t\t\/\/ yank buffer, e.g. a GUI clipboard callback.\n\t\temsg(_(e_yank_register_changed_while_using_it));\n\t\tgoto end;\n\t    }\n\n\t    \/\/ Put the '] mark on the first byte of the last inserted character.\n\t    \/\/ Correct the length for change in indent.\n\t    curbuf->b_op_end.lnum = new_lnum;\n\t    len = STRLEN(y_array[y_size - 1]);\n\t    col = (colnr_T)len - lendiff;\n\t    if (col > 1)\n\t    {\n\t\tcurbuf->b_op_end.col = col - 1;\n\t\tif (len > 0)\n\t\t    curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],\n\t\t\t\t\t\ty_array[y_size - 1] + len - 1);\n\t    }\n\t    else\n\t\tcurbuf->b_op_end.col = 0;\n\n\t    if (flags & PUT_CURSLINE)\n\t    {\n\t\t\/\/ \":put\": put cursor on last inserted line\n\t\tcurwin->w_cursor.lnum = lnum;\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t    }\n\t    else if (flags & PUT_CURSEND)\n\t    {\n\t\t\/\/ put cursor after inserted text\n\t\tif (y_type == MLINE)\n\t\t{\n\t\t    if (lnum >= curbuf->b_ml.ml_line_count)\n\t\t\tcurwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n\t\t    else\n\t\t\tcurwin->w_cursor.lnum = lnum + 1;\n\t\t    curwin->w_cursor.col = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    curwin->w_cursor.lnum = new_lnum;\n\t\t    curwin->w_cursor.col = col;\n\t\t    curbuf->b_op_end = curwin->w_cursor;\n\t\t    if (col > 1)\n\t\t\tcurbuf->b_op_end.col = col - 1;\n\t\t}\n\t    }\n\t    else if (y_type == MLINE)\n\t    {\n\t\t\/\/ put cursor on first non-blank in first inserted line\n\t\tcurwin->w_cursor.col = 0;\n\t\tif (dir == FORWARD)\n\t\t    ++curwin->w_cursor.lnum;\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t    }\n\t    else\t\/\/ put cursor on first inserted character\n\t\tcurwin->w_cursor = new_cursor;\n\t}\n    }\n\n    msgmore(nr_lines);\n    curwin->w_set_curswant = TRUE;\n\nend:\n    if (cmdmod.cmod_flags & CMOD_LOCKMARKS)\n    {\n\tcurbuf->b_op_start = orig_start;\n\tcurbuf->b_op_end = orig_end;\n    }\n    if (allocated)\n\tvim_free(insert_string);\n    if (regname == '=')\n\tvim_free(y_array);\n\n    VIsual_active = FALSE;\n\n    \/\/ If the cursor is past the end of the line put it at the end.\n    adjust_cursor_eol();\n}","target":0,"code_token_length":6357,"total_token_length":6593,"max_tokens_setting":8192}
+{"idx":240297,"func":"do_put(\n    int\t\tregname,\n    char_u\t*expr_result,\t\/\/ result for regname \"=\" when compiled\n    int\t\tdir,\t\t\/\/ BACKWARD for 'P', FORWARD for 'p'\n    long\tcount,\n    int\t\tflags)\n{\n    char_u\t*ptr;\n    char_u\t*newp, *oldp;\n    int\t\tyanklen;\n    int\t\ttotlen = 0;\t\t\/\/ init for gcc\n    linenr_T\tlnum;\n    colnr_T\tcol;\n    long\ti;\t\t\t\/\/ index in y_array[]\n    int\t\ty_type;\n    long\ty_size;\n    int\t\toldlen;\n    long\ty_width = 0;\n    colnr_T\tvcol;\n    int\t\tdelcount;\n    int\t\tincr = 0;\n    long\tj;\n    struct block_def bd;\n    char_u\t**y_array = NULL;\n    yankreg_T\t*y_current_used = NULL;\n    long\tnr_lines = 0;\n    pos_T\tnew_cursor;\n    int\t\tindent;\n    int\t\torig_indent = 0;\t\/\/ init for gcc\n    int\t\tindent_diff = 0;\t\/\/ init for gcc\n    int\t\tfirst_indent = TRUE;\n    int\t\tlendiff = 0;\n    pos_T\told_pos;\n    char_u\t*insert_string = NULL;\n    int\t\tallocated = FALSE;\n    long\tcnt;\n    pos_T\torig_start = curbuf->b_op_start;\n    pos_T\torig_end = curbuf->b_op_end;\n    unsigned int cur_ve_flags = get_ve_flags();\n\n#ifdef FEAT_CLIPBOARD\n    \/\/ Adjust register name for \"unnamed\" in 'clipboard'.\n    adjust_clip_reg(®name);\n    (void)may_get_selection(regname);\n#endif\n\n    if (flags & PUT_FIXINDENT)\n\torig_indent = get_indent();\n\n    curbuf->b_op_start = curwin->w_cursor;\t\/\/ default for '[ mark\n    curbuf->b_op_end = curwin->w_cursor;\t\/\/ default for '] mark\n\n    \/\/ Using inserted text works differently, because the register includes\n    \/\/ special characters (newlines, etc.).\n    if (regname == '.')\n    {\n\tif (VIsual_active)\n\t    stuffcharReadbuff(VIsual_mode);\n\t(void)stuff_inserted((dir == FORWARD ? (count == -1 ? 'o' : 'a') :\n\t\t\t\t    (count == -1 ? 'O' : 'i')), count, FALSE);\n\t\/\/ Putting the text is done later, so can't really move the cursor to\n\t\/\/ the next character.  Use \"l\" to simulate it.\n\tif ((flags & PUT_CURSEND) && gchar_cursor() != NUL)\n\t    stuffcharReadbuff('l');\n\treturn;\n    }\n\n    \/\/ For special registers '%' (file name), '#' (alternate file name) and\n    \/\/ ':' (last command line), etc. we have to create a fake yank register.\n    \/\/ For compiled code \"expr_result\" holds the expression result.\n    if (regname == '=' && expr_result != NULL)\n\tinsert_string = expr_result;\n    else if (get_spec_reg(regname, &insert_string, &allocated, TRUE)\n\t\t&& insert_string == NULL)\n\treturn;\n\n    \/\/ Autocommands may be executed when saving lines for undo.  This might\n    \/\/ make \"y_array\" invalid, so we start undo now to avoid that.\n    if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL)\n\tgoto end;\n\n    if (insert_string != NULL)\n    {\n\ty_type = MCHAR;\n#ifdef FEAT_EVAL\n\tif (regname == '=')\n\t{\n\t    \/\/ For the = register we need to split the string at NL\n\t    \/\/ characters.\n\t    \/\/ Loop twice: count the number of lines and save them.\n\t    for (;;)\n\t    {\n\t\ty_size = 0;\n\t\tptr = insert_string;\n\t\twhile (ptr != NULL)\n\t\t{\n\t\t    if (y_array != NULL)\n\t\t\ty_array[y_size] = ptr;\n\t\t    ++y_size;\n\t\t    ptr = vim_strchr(ptr, '\\n');\n\t\t    if (ptr != NULL)\n\t\t    {\n\t\t\tif (y_array != NULL)\n\t\t\t    *ptr = NUL;\n\t\t\t++ptr;\n\t\t\t\/\/ A trailing '\\n' makes the register linewise.\n\t\t\tif (*ptr == NUL)\n\t\t\t{\n\t\t\t    y_type = MLINE;\n\t\t\t    break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (y_array != NULL)\n\t\t    break;\n\t\ty_array = ALLOC_MULT(char_u *, y_size);\n\t\tif (y_array == NULL)\n\t\t    goto end;\n\t    }\n\t}\n\telse\n#endif\n\t{\n\t    y_size = 1;\t\t\/\/ use fake one-line yank register\n\t    y_array = &insert_string;\n\t}\n    }\n    else\n    {\n\tget_yank_register(regname, FALSE);\n\n\ty_type = y_current->y_type;\n\ty_width = y_current->y_width;\n\ty_size = y_current->y_size;\n\ty_array = y_current->y_array;\n\ty_current_used = y_current;\n    }\n\n    if (y_type == MLINE)\n    {\n\tif (flags & PUT_LINE_SPLIT)\n\t{\n\t    char_u *p;\n\n\t    \/\/ \"p\" or \"P\" in Visual mode: split the lines to put the text in\n\t    \/\/ between.\n\t    if (u_save_cursor() == FAIL)\n\t\tgoto end;\n\t    p = ml_get_cursor();\n\t    if (dir == FORWARD && *p != NUL)\n\t\tMB_PTR_ADV(p);\n\t    ptr = vim_strsave(p);\n\t    if (ptr == NULL)\n\t\tgoto end;\n\t    ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);\n\t    vim_free(ptr);\n\n\t    oldp = ml_get_curline();\n\t    p = oldp + curwin->w_cursor.col;\n\t    if (dir == FORWARD && *p != NUL)\n\t\tMB_PTR_ADV(p);\n\t    ptr = vim_strnsave(oldp, p - oldp);\n\t    if (ptr == NULL)\n\t\tgoto end;\n\t    ml_replace(curwin->w_cursor.lnum, ptr, FALSE);\n\t    ++nr_lines;\n\t    dir = FORWARD;\n\t}\n\tif (flags & PUT_LINE_FORWARD)\n\t{\n\t    \/\/ Must be \"p\" for a Visual block, put lines below the block.\n\t    curwin->w_cursor = curbuf->b_visual.vi_end;\n\t    dir = FORWARD;\n\t}\n\tcurbuf->b_op_start = curwin->w_cursor;\t\/\/ default for '[ mark\n\tcurbuf->b_op_end = curwin->w_cursor;\t\/\/ default for '] mark\n    }\n\n    if (flags & PUT_LINE)\t\/\/ :put command or \"p\" in Visual line mode.\n\ty_type = MLINE;\n\n    if (y_size == 0 || y_array == NULL)\n    {\n\tsemsg(_(e_nothing_in_register_str),\n\t\t  regname == 0 ? (char_u *)\"\\\"\" : transchar(regname));\n\tgoto end;\n    }\n\n    if (y_type == MBLOCK)\n    {\n\tlnum = curwin->w_cursor.lnum + y_size + 1;\n\tif (lnum > curbuf->b_ml.ml_line_count)\n\t    lnum = curbuf->b_ml.ml_line_count + 1;\n\tif (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)\n\t    goto end;\n    }\n    else if (y_type == MLINE)\n    {\n\tlnum = curwin->w_cursor.lnum;\n#ifdef FEAT_FOLDING\n\t\/\/ Correct line number for closed fold.  Don't move the cursor yet,\n\t\/\/ u_save() uses it.\n\tif (dir == BACKWARD)\n\t    (void)hasFolding(lnum, &lnum, NULL);\n\telse\n\t    (void)hasFolding(lnum, NULL, &lnum);\n#endif\n\tif (dir == FORWARD)\n\t    ++lnum;\n\t\/\/ In an empty buffer the empty line is going to be replaced, include\n\t\/\/ it in the saved lines.\n\tif ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL)\n\t    goto end;\n#ifdef FEAT_FOLDING\n\tif (dir == FORWARD)\n\t    curwin->w_cursor.lnum = lnum - 1;\n\telse\n\t    curwin->w_cursor.lnum = lnum;\n\tcurbuf->b_op_start = curwin->w_cursor;\t\/\/ for mark_adjust()\n#endif\n    }\n    else if (u_save_cursor() == FAIL)\n\tgoto end;\n\n    yanklen = (int)STRLEN(y_array[0]);\n\n    if (cur_ve_flags == VE_ALL && y_type == MCHAR)\n    {\n\tif (gchar_cursor() == TAB)\n\t{\n\t    int viscol = getviscol();\n\t    int ts = curbuf->b_p_ts;\n\n\t    \/\/ Don't need to insert spaces when \"p\" on the last position of a\n\t    \/\/ tab or \"P\" on the first position.\n\t    if (dir == FORWARD ?\n#ifdef FEAT_VARTABS\n\t\t    tabstop_padding(viscol, ts, curbuf->b_p_vts_array) != 1\n#else\n\t\t    ts - (viscol % ts) != 1\n#endif\n\t\t    : curwin->w_cursor.coladd > 0)\n\t\tcoladvance_force(viscol);\n\t    else\n\t\tcurwin->w_cursor.coladd = 0;\n\t}\n\telse if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)\n\t    coladvance_force(getviscol() + (dir == FORWARD));\n    }\n\n    lnum = curwin->w_cursor.lnum;\n    col = curwin->w_cursor.col;\n\n    \/\/ Block mode\n    if (y_type == MBLOCK)\n    {\n\tint\tc = gchar_cursor();\n\tcolnr_T\tendcol2 = 0;\n\n\tif (dir == FORWARD && c != NUL)\n\t{\n\t    if (cur_ve_flags == VE_ALL)\n\t\tgetvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);\n\t    else\n\t\tgetvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);\n\n\t    if (has_mbyte)\n\t\t\/\/ move to start of next multi-byte character\n\t\tcurwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());\n\t    else\n\t    if (c != TAB || cur_ve_flags != VE_ALL)\n\t\t++curwin->w_cursor.col;\n\t    ++col;\n\t}\n\telse\n\t    getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);\n\n\tcol += curwin->w_cursor.coladd;\n\tif (cur_ve_flags == VE_ALL\n\t\t&& (curwin->w_cursor.coladd > 0\n\t\t    || endcol2 == curwin->w_cursor.col))\n\t{\n\t    if (dir == FORWARD && c == NUL)\n\t\t++col;\n\t    if (dir != FORWARD && c != NUL && curwin->w_cursor.coladd > 0)\n\t\t++curwin->w_cursor.col;\n\t    if (c == TAB)\n\t    {\n\t\tif (dir == BACKWARD && curwin->w_cursor.col)\n\t\t    curwin->w_cursor.col--;\n\t\tif (dir == FORWARD && col - 1 == endcol2)\n\t\t    curwin->w_cursor.col++;\n\t    }\n\t}\n\tcurwin->w_cursor.coladd = 0;\n\tbd.textcol = 0;\n\tfor (i = 0; i < y_size; ++i)\n\t{\n\t    int spaces = 0;\n\t    char shortline;\n\n\t    bd.startspaces = 0;\n\t    bd.endspaces = 0;\n\t    vcol = 0;\n\t    delcount = 0;\n\n\t    \/\/ add a new line\n\t    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)\n\t    {\n\t\tif (ml_append(curbuf->b_ml.ml_line_count, (char_u *)\"\",\n\t\t\t\t\t\t   (colnr_T)1, FALSE) == FAIL)\n\t\t    break;\n\t\t++nr_lines;\n\t    }\n\t    \/\/ get the old line and advance to the position to insert at\n\t    oldp = ml_get_curline();\n\t    oldlen = (int)STRLEN(oldp);\n\t    for (ptr = oldp; vcol < col && *ptr; )\n\t    {\n\t\t\/\/ Count a tab for what it's worth (if list mode not on)\n\t\tincr = lbr_chartabsize_adv(oldp, &ptr, (colnr_T)vcol);\n\t\tvcol += incr;\n\t    }\n\t    bd.textcol = (colnr_T)(ptr - oldp);\n\n\t    shortline = (vcol < col) || (vcol == col && !*ptr) ;\n\n\t    if (vcol < col) \/\/ line too short, padd with spaces\n\t\tbd.startspaces = col - vcol;\n\t    else if (vcol > col)\n\t    {\n\t\tbd.endspaces = vcol - col;\n\t\tbd.startspaces = incr - bd.endspaces;\n\t\t--bd.textcol;\n\t\tdelcount = 1;\n\t\tif (has_mbyte)\n\t\t    bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);\n\t\tif (oldp[bd.textcol] != TAB)\n\t\t{\n\t\t    \/\/ Only a Tab can be split into spaces.  Other\n\t\t    \/\/ characters will have to be moved to after the\n\t\t    \/\/ block, causing misalignment.\n\t\t    delcount = 0;\n\t\t    bd.endspaces = 0;\n\t\t}\n\t    }\n\n\t    yanklen = (int)STRLEN(y_array[i]);\n\n\t    if ((flags & PUT_BLOCK_INNER) == 0)\n\t    {\n\t\t\/\/ calculate number of spaces required to fill right side of\n\t\t\/\/ block\n\t\tspaces = y_width + 1;\n\t\tfor (j = 0; j < yanklen; j++)\n\t\t    spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);\n\t\tif (spaces < 0)\n\t\t    spaces = 0;\n\t    }\n\n\t    \/\/ Insert the new text.\n\t    \/\/ First check for multiplication overflow.\n\t    if (yanklen + spaces != 0\n\t\t     && count > ((INT_MAX - (bd.startspaces + bd.endspaces))\n\t\t\t\t\t\t\t\/ (yanklen + spaces)))\n\t    {\n\t\temsg(_(e_resulting_text_too_long));\n\t\tbreak;\n\t    }\n\n\t    totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;\n\t    newp = alloc(totlen + oldlen + 1);\n\t    if (newp == NULL)\n\t\tbreak;\n\n\t    \/\/ copy part up to cursor to new line\n\t    ptr = newp;\n\t    mch_memmove(ptr, oldp, (size_t)bd.textcol);\n\t    ptr += bd.textcol;\n\n\t    \/\/ may insert some spaces before the new text\n\t    vim_memset(ptr, ' ', (size_t)bd.startspaces);\n\t    ptr += bd.startspaces;\n\n\t    \/\/ insert the new text\n\t    for (j = 0; j < count; ++j)\n\t    {\n\t\tmch_memmove(ptr, y_array[i], (size_t)yanklen);\n\t\tptr += yanklen;\n\n\t\t\/\/ insert block's trailing spaces only if there's text behind\n\t\tif ((j < count - 1 || !shortline) && spaces)\n\t\t{\n\t\t    vim_memset(ptr, ' ', (size_t)spaces);\n\t\t    ptr += spaces;\n\t\t}\n\t    }\n\n\t    \/\/ may insert some spaces after the new text\n\t    vim_memset(ptr, ' ', (size_t)bd.endspaces);\n\t    ptr += bd.endspaces;\n\n\t    \/\/ move the text after the cursor to the end of the line.\n\t    mch_memmove(ptr, oldp + bd.textcol + delcount,\n\t\t\t\t(size_t)(oldlen - bd.textcol - delcount + 1));\n\t    ml_replace(curwin->w_cursor.lnum, newp, FALSE);\n\n\t    ++curwin->w_cursor.lnum;\n\t    if (i == 0)\n\t\tcurwin->w_cursor.col += bd.startspaces;\n\t}\n\n\tchanged_lines(lnum, 0, curwin->w_cursor.lnum, nr_lines);\n\n\t\/\/ Set '[ mark.\n\tcurbuf->b_op_start = curwin->w_cursor;\n\tcurbuf->b_op_start.lnum = lnum;\n\n\t\/\/ adjust '] mark\n\tcurbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;\n\tcurbuf->b_op_end.col = bd.textcol + totlen - 1;\n\tcurbuf->b_op_end.coladd = 0;\n\tif (flags & PUT_CURSEND)\n\t{\n\t    colnr_T len;\n\n\t    curwin->w_cursor = curbuf->b_op_end;\n\t    curwin->w_cursor.col++;\n\n\t    \/\/ in Insert mode we might be after the NUL, correct for that\n\t    len = (colnr_T)STRLEN(ml_get_curline());\n\t    if (curwin->w_cursor.col > len)\n\t\tcurwin->w_cursor.col = len;\n\t}\n\telse\n\t    curwin->w_cursor.lnum = lnum;\n    }\n    else\n    {\n\t\/\/ Character or Line mode\n\tif (y_type == MCHAR)\n\t{\n\t    \/\/ if type is MCHAR, FORWARD is the same as BACKWARD on the next\n\t    \/\/ char\n\t    if (dir == FORWARD && gchar_cursor() != NUL)\n\t    {\n\t\tif (has_mbyte)\n\t\t{\n\t\t    int bytelen = (*mb_ptr2len)(ml_get_cursor());\n\n\t\t    \/\/ put it on the next of the multi-byte character.\n\t\t    col += bytelen;\n\t\t    if (yanklen)\n\t\t    {\n\t\t\tcurwin->w_cursor.col += bytelen;\n\t\t\tcurbuf->b_op_end.col += bytelen;\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    ++col;\n\t\t    if (yanklen)\n\t\t    {\n\t\t\t++curwin->w_cursor.col;\n\t\t\t++curbuf->b_op_end.col;\n\t\t    }\n\t\t}\n\t    }\n\t    curbuf->b_op_start = curwin->w_cursor;\n\t}\n\t\/\/ Line mode: BACKWARD is the same as FORWARD on the previous line\n\telse if (dir == BACKWARD)\n\t    --lnum;\n\tnew_cursor = curwin->w_cursor;\n\n\t\/\/ simple case: insert into one line at a time\n\tif (y_type == MCHAR && y_size == 1)\n\t{\n\t    linenr_T\tend_lnum = 0; \/\/ init for gcc\n\t    linenr_T\tstart_lnum = lnum;\n\t    int\t\tfirst_byte_off = 0;\n\n\t    if (VIsual_active)\n\t    {\n\t\tend_lnum = curbuf->b_visual.vi_end.lnum;\n\t\tif (end_lnum < curbuf->b_visual.vi_start.lnum)\n\t\t    end_lnum = curbuf->b_visual.vi_start.lnum;\n\t\tif (end_lnum > start_lnum)\n\t\t{\n\t\t    pos_T   pos;\n\n\t\t    \/\/ \"col\" is valid for the first line, in following lines\n\t\t    \/\/ the virtual column needs to be used.  Matters for\n\t\t    \/\/ multi-byte characters.\n\t\t    pos.lnum = lnum;\n\t\t    pos.col = col;\n\t\t    pos.coladd = 0;\n\t\t    getvcol(curwin, &pos, NULL, &vcol, NULL);\n\t\t}\n\t    }\n\n\t    if (count == 0 || yanklen == 0)\n\t    {\n\t\tif (VIsual_active)\n\t\t    lnum = end_lnum;\n\t    }\n\t    else if (count > INT_MAX \/ yanklen)\n\t\t\/\/ multiplication overflow\n\t\temsg(_(e_resulting_text_too_long));\n\t    else\n\t    {\n\t\ttotlen = count * yanklen;\n\t\tdo {\n\t\t    oldp = ml_get(lnum);\n\t\t    oldlen = (int)STRLEN(oldp);\n\t\t    if (lnum > start_lnum)\n\t\t    {\n\t\t\tpos_T   pos;\n\n\t\t\tpos.lnum = lnum;\n\t\t\tif (getvpos(&pos, vcol) == OK)\n\t\t\t    col = pos.col;\n\t\t\telse\n\t\t\t    col = MAXCOL;\n\t\t    }\n\t\t    if (VIsual_active && col > oldlen)\n\t\t    {\n\t\t\tlnum++;\n\t\t\tcontinue;\n\t\t    }\n\t\t    newp = alloc(totlen + oldlen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto end;\t\/\/ alloc() gave an error message\n\t\t    mch_memmove(newp, oldp, (size_t)col);\n\t\t    ptr = newp + col;\n\t\t    for (i = 0; i < count; ++i)\n\t\t    {\n\t\t\tmch_memmove(ptr, y_array[0], (size_t)yanklen);\n\t\t\tptr += yanklen;\n\t\t    }\n\t\t    STRMOVE(ptr, oldp + col);\n\t\t    ml_replace(lnum, newp, FALSE);\n\n\t\t    \/\/ compute the byte offset for the last character\n\t\t    first_byte_off = mb_head_off(newp, ptr - 1);\n\n\t\t    \/\/ Place cursor on last putted char.\n\t\t    if (lnum == curwin->w_cursor.lnum)\n\t\t    {\n\t\t\t\/\/ make sure curwin->w_virtcol is updated\n\t\t\tchanged_cline_bef_curs();\n\t\t\tcurwin->w_cursor.col += (colnr_T)(totlen - 1);\n\t\t    }\n\t\t    if (VIsual_active)\n\t\t\tlnum++;\n\t\t} while (VIsual_active && lnum <= end_lnum);\n\n\t\tif (VIsual_active) \/\/ reset lnum to the last visual line\n\t\t    lnum--;\n\t    }\n\n\t    \/\/ put '] at the first byte of the last character\n\t    curbuf->b_op_end = curwin->w_cursor;\n\t    curbuf->b_op_end.col -= first_byte_off;\n\n\t    \/\/ For \"CTRL-O p\" in Insert mode, put cursor after last char\n\t    if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))\n\t\t++curwin->w_cursor.col;\n\t    else\n\t\tcurwin->w_cursor.col -= first_byte_off;\n\t    changed_bytes(lnum, col);\n\t}\n\telse\n\t{\n\t    linenr_T\tnew_lnum = new_cursor.lnum;\n\t    size_t\tlen;\n\n\t    \/\/ Insert at least one line.  When y_type is MCHAR, break the first\n\t    \/\/ line in two.\n\t    for (cnt = 1; cnt <= count; ++cnt)\n\t    {\n\t\ti = 0;\n\t\tif (y_type == MCHAR)\n\t\t{\n\t\t    \/\/ Split the current line in two at the insert position.\n\t\t    \/\/ First insert y_array[size - 1] in front of second line.\n\t\t    \/\/ Then append y_array[0] to first line.\n\t\t    lnum = new_cursor.lnum;\n\t\t    ptr = ml_get(lnum) + col;\n\t\t    totlen = (int)STRLEN(y_array[y_size - 1]);\n\t\t    newp = alloc(STRLEN(ptr) + totlen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto error;\n\t\t    STRCPY(newp, y_array[y_size - 1]);\n\t\t    STRCAT(newp, ptr);\n\t\t    \/\/ insert second line\n\t\t    ml_append(lnum, newp, (colnr_T)0, FALSE);\n\t\t    ++new_lnum;\n\t\t    vim_free(newp);\n\n\t\t    oldp = ml_get(lnum);\n\t\t    newp = alloc(col + yanklen + 1);\n\t\t    if (newp == NULL)\n\t\t\tgoto error;\n\t\t\t\t\t    \/\/ copy first part of line\n\t\t    mch_memmove(newp, oldp, (size_t)col);\n\t\t\t\t\t    \/\/ append to first line\n\t\t    mch_memmove(newp + col, y_array[0], (size_t)(yanklen + 1));\n\t\t    ml_replace(lnum, newp, FALSE);\n\n\t\t    curwin->w_cursor.lnum = lnum;\n\t\t    i = 1;\n\t\t}\n\n\t\tfor (; i < y_size; ++i)\n\t\t{\n\t\t    if (y_type != MCHAR || i < y_size - 1)\n\t\t    {\n\t\t\tif (ml_append(lnum, y_array[i], (colnr_T)0, FALSE)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t\t\t    goto error;\n\t\t\tnew_lnum++;\n\t\t    }\n\t\t    lnum++;\n\t\t    ++nr_lines;\n\t\t    if (flags & PUT_FIXINDENT)\n\t\t    {\n\t\t\told_pos = curwin->w_cursor;\n\t\t\tcurwin->w_cursor.lnum = lnum;\n\t\t\tptr = ml_get(lnum);\n\t\t\tif (cnt == count && i == y_size - 1)\n\t\t\t    lendiff = (int)STRLEN(ptr);\n#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)\n\t\t\tif (*ptr == '#' && preprocs_left())\n\t\t\t    indent = 0;     \/\/ Leave # lines at start\n\t\t\telse\n#endif\n\t\t\t     if (*ptr == NUL)\n\t\t\t    indent = 0;     \/\/ Ignore empty lines\n\t\t\telse if (first_indent)\n\t\t\t{\n\t\t\t    indent_diff = orig_indent - get_indent();\n\t\t\t    indent = orig_indent;\n\t\t\t    first_indent = FALSE;\n\t\t\t}\n\t\t\telse if ((indent = get_indent() + indent_diff) < 0)\n\t\t\t    indent = 0;\n\t\t\t(void)set_indent(indent, 0);\n\t\t\tcurwin->w_cursor = old_pos;\n\t\t\t\/\/ remember how many chars were removed\n\t\t\tif (cnt == count && i == y_size - 1)\n\t\t\t    lendiff -= (int)STRLEN(ml_get(lnum));\n\t\t    }\n\t\t}\n\t\tif (cnt == 1)\n\t\t    new_lnum = lnum;\n\t    }\n\nerror:\n\t    \/\/ Adjust marks.\n\t    if (y_type == MLINE)\n\t    {\n\t\tcurbuf->b_op_start.col = 0;\n\t\tif (dir == FORWARD)\n\t\t    curbuf->b_op_start.lnum++;\n\t    }\n\t    \/\/ Skip mark_adjust when adding lines after the last one, there\n\t    \/\/ can't be marks there. But still needed in diff mode.\n\t    if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines\n\t\t\t\t\t\t < curbuf->b_ml.ml_line_count\n#ifdef FEAT_DIFF\n\t\t\t\t\t\t || curwin->w_p_diff\n#endif\n\t\t\t\t\t\t )\n\t\tmark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),\n\t\t\t\t\t     (linenr_T)MAXLNUM, nr_lines, 0L);\n\n\t    \/\/ note changed text for displaying and folding\n\t    if (y_type == MCHAR)\n\t\tchanged_lines(curwin->w_cursor.lnum, col,\n\t\t\t\t\t curwin->w_cursor.lnum + 1, nr_lines);\n\t    else\n\t\tchanged_lines(curbuf->b_op_start.lnum, 0,\n\t\t\t\t\t   curbuf->b_op_start.lnum, nr_lines);\n\t    if (y_current_used != NULL && (y_current_used != y_current\n\t\t\t\t\t     || y_current->y_array != y_array))\n\t    {\n\t\t\/\/ Something invoked through changed_lines() has changed the\n\t\t\/\/ yank buffer, e.g. a GUI clipboard callback.\n\t\temsg(_(e_yank_register_changed_while_using_it));\n\t\tgoto end;\n\t    }\n\n\t    \/\/ Put the '] mark on the first byte of the last inserted character.\n\t    \/\/ Correct the length for change in indent.\n\t    curbuf->b_op_end.lnum = new_lnum;\n\t    len = STRLEN(y_array[y_size - 1]);\n\t    col = (colnr_T)len - lendiff;\n\t    if (col > 1)\n\t\tcurbuf->b_op_end.col = col - 1\n\t\t\t\t- mb_head_off(y_array[y_size - 1],\n\t\t\t\t\t\ty_array[y_size - 1] + len - 1);\n\t    else\n\t\tcurbuf->b_op_end.col = 0;\n\n\t    if (flags & PUT_CURSLINE)\n\t    {\n\t\t\/\/ \":put\": put cursor on last inserted line\n\t\tcurwin->w_cursor.lnum = lnum;\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t    }\n\t    else if (flags & PUT_CURSEND)\n\t    {\n\t\t\/\/ put cursor after inserted text\n\t\tif (y_type == MLINE)\n\t\t{\n\t\t    if (lnum >= curbuf->b_ml.ml_line_count)\n\t\t\tcurwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;\n\t\t    else\n\t\t\tcurwin->w_cursor.lnum = lnum + 1;\n\t\t    curwin->w_cursor.col = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t    curwin->w_cursor.lnum = new_lnum;\n\t\t    curwin->w_cursor.col = col;\n\t\t    curbuf->b_op_end = curwin->w_cursor;\n\t\t    if (col > 1)\n\t\t\tcurbuf->b_op_end.col = col - 1;\n\t\t}\n\t    }\n\t    else if (y_type == MLINE)\n\t    {\n\t\t\/\/ put cursor on first non-blank in first inserted line\n\t\tcurwin->w_cursor.col = 0;\n\t\tif (dir == FORWARD)\n\t\t    ++curwin->w_cursor.lnum;\n\t\tbeginline(BL_WHITE | BL_FIX);\n\t    }\n\t    else\t\/\/ put cursor on first inserted character\n\t\tcurwin->w_cursor = new_cursor;\n\t}\n    }\n\n    msgmore(nr_lines);\n    curwin->w_set_curswant = TRUE;\n\nend:\n    if (cmdmod.cmod_flags & CMOD_LOCKMARKS)\n    {\n\tcurbuf->b_op_start = orig_start;\n\tcurbuf->b_op_end = orig_end;\n    }\n    if (allocated)\n\tvim_free(insert_string);\n    if (regname == '=')\n\tvim_free(y_array);\n\n    VIsual_active = FALSE;\n\n    \/\/ If the cursor is past the end of the line put it at the end.\n    adjust_cursor_eol();\n}","target":0,"code_token_length":6347,"total_token_length":6583,"max_tokens_setting":8192}
+{"idx":209102,"func":"do_mouse(\n    oparg_T\t*oap,\t\t\/\/ operator argument, can be NULL\n    int\t\tc,\t\t\/\/ K_LEFTMOUSE, etc\n    int\t\tdir,\t\t\/\/ Direction to 'put' if necessary\n    long\tcount,\n    int\t\tfixindent)\t\/\/ PUT_FIXINDENT if fixing indent necessary\n{\n    static int\tdo_always = FALSE;\t\/\/ ignore 'mouse' setting next time\n    static int\tgot_click = FALSE;\t\/\/ got a click some time back\n\n    int\t\twhich_button;\t\/\/ MOUSE_LEFT, _MIDDLE or _RIGHT\n    int\t\tis_click = FALSE; \/\/ If FALSE it's a drag or release event\n    int\t\tis_drag = FALSE;  \/\/ If TRUE it's a drag event\n    int\t\tjump_flags = 0;\t\/\/ flags for jump_to_mouse()\n    pos_T\tstart_visual;\n    int\t\tmoved;\t\t\/\/ Has cursor moved?\n    int\t\tin_status_line;\t\/\/ mouse in status line\n    static int\tin_tab_line = FALSE; \/\/ mouse clicked in tab line\n    int\t\tin_sep_line;\t\/\/ mouse in vertical separator line\n    int\t\tc1, c2;\n#if defined(FEAT_FOLDING)\n    pos_T\tsave_cursor;\n#endif\n    win_T\t*old_curwin = curwin;\n    static pos_T orig_cursor;\n    colnr_T\tleftcol, rightcol;\n    pos_T\tend_visual;\n    int\t\tdiff;\n    int\t\told_active = VIsual_active;\n    int\t\told_mode = VIsual_mode;\n    int\t\tregname;\n\n#if defined(FEAT_FOLDING)\n    save_cursor = curwin->w_cursor;\n#endif\n\n    \/\/ When GUI is active, always recognize mouse events, otherwise:\n    \/\/ - Ignore mouse event in normal mode if 'mouse' doesn't include 'n'.\n    \/\/ - Ignore mouse event in visual mode if 'mouse' doesn't include 'v'.\n    \/\/ - For command line and insert mode 'mouse' is checked before calling\n    \/\/\t do_mouse().\n    if (do_always)\n\tdo_always = FALSE;\n    else\n#ifdef FEAT_GUI\n\tif (!gui.in_use)\n#endif\n\t{\n\t    if (VIsual_active)\n\t    {\n\t\tif (!mouse_has(MOUSE_VISUAL))\n\t\t    return FALSE;\n\t    }\n\t    else if (State == MODE_NORMAL && !mouse_has(MOUSE_NORMAL))\n\t\treturn FALSE;\n\t}\n\n    for (;;)\n    {\n\twhich_button = get_mouse_button(KEY2TERMCAP1(c), &is_click, &is_drag);\n\tif (is_drag)\n\t{\n\t    \/\/ If the next character is the same mouse event then use that\n\t    \/\/ one. Speeds up dragging the status line.\n\t    \/\/ Note: Since characters added to the stuff buffer in the code\n\t    \/\/ below need to come before the next character, do not do this\n\t    \/\/ when the current character was stuffed.\n\t    if (!KeyStuffed && vpeekc() != NUL)\n\t    {\n\t\tint nc;\n\t\tint save_mouse_row = mouse_row;\n\t\tint save_mouse_col = mouse_col;\n\n\t\t\/\/ Need to get the character, peeking doesn't get the actual\n\t\t\/\/ one.\n\t\tnc = safe_vgetc();\n\t\tif (c == nc)\n\t\t    continue;\n\t\tvungetc(nc);\n\t\tmouse_row = save_mouse_row;\n\t\tmouse_col = save_mouse_col;\n\t    }\n\t}\n\tbreak;\n    }\n\n    if (c == K_MOUSEMOVE)\n    {\n\t\/\/ Mouse moved without a button pressed.\n#ifdef FEAT_BEVAL_TERM\n\tui_may_remove_balloon();\n\tif (p_bevalterm)\n\t{\n\t    profile_setlimit(p_bdlay, &bevalexpr_due);\n\t    bevalexpr_due_set = TRUE;\n\t}\n#endif\n#ifdef FEAT_PROP_POPUP\n\tpopup_handle_mouse_moved();\n#endif\n\treturn FALSE;\n    }\n\n#ifdef FEAT_MOUSESHAPE\n    \/\/ May have stopped dragging the status or separator line.  The pointer is\n    \/\/ most likely still on the status or separator line.\n    if (!is_drag && drag_status_line)\n    {\n\tdrag_status_line = FALSE;\n\tupdate_mouseshape(SHAPE_IDX_STATUS);\n    }\n    if (!is_drag && drag_sep_line)\n    {\n\tdrag_sep_line = FALSE;\n\tupdate_mouseshape(SHAPE_IDX_VSEP);\n    }\n#endif\n\n    \/\/ Ignore drag and release events if we didn't get a click.\n    if (is_click)\n\tgot_click = TRUE;\n    else\n    {\n\tif (!got_click)\t\t\t\/\/ didn't get click, ignore\n\t    return FALSE;\n\tif (!is_drag)\t\t\t\/\/ release, reset got_click\n\t{\n\t    got_click = FALSE;\n\t    if (in_tab_line)\n\t    {\n\t\tin_tab_line = FALSE;\n\t\treturn FALSE;\n\t    }\n\t}\n    }\n\n    \/\/ CTRL right mouse button does CTRL-T\n    if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT)\n    {\n\tif (State & MODE_INSERT)\n\t    stuffcharReadbuff(Ctrl_O);\n\tif (count > 1)\n\t    stuffnumReadbuff(count);\n\tstuffcharReadbuff(Ctrl_T);\n\tgot_click = FALSE;\t\t\/\/ ignore drag&release now\n\treturn FALSE;\n    }\n\n    \/\/ CTRL only works with left mouse button\n    if ((mod_mask & MOD_MASK_CTRL) && which_button != MOUSE_LEFT)\n\treturn FALSE;\n\n    \/\/ When a modifier is down, ignore drag and release events, as well as\n    \/\/ multiple clicks and the middle mouse button.\n    \/\/ Accept shift-leftmouse drags when 'mousemodel' is \"popup.*\".\n    if ((mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT\n\t\t\t\t\t\t\t     | MOD_MASK_META))\n\t    && (!is_click\n\t\t|| (mod_mask & MOD_MASK_MULTI_CLICK)\n\t\t|| which_button == MOUSE_MIDDLE)\n\t    && !((mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT))\n\t\t&& mouse_model_popup()\n\t\t&& which_button == MOUSE_LEFT)\n\t    && !((mod_mask & MOD_MASK_ALT)\n\t\t&& !mouse_model_popup()\n\t\t&& which_button == MOUSE_RIGHT)\n\t    )\n\treturn FALSE;\n\n    \/\/ If the button press was used as the movement command for an operator\n    \/\/ (eg \"d<MOUSE>\"), or it is the middle button that is held down, ignore\n    \/\/ drag\/release events.\n    if (!is_click && which_button == MOUSE_MIDDLE)\n\treturn FALSE;\n\n    if (oap != NULL)\n\tregname = oap->regname;\n    else\n\tregname = 0;\n\n    \/\/ Middle mouse button does a 'put' of the selected text\n    if (which_button == MOUSE_MIDDLE)\n    {\n\tif (State == MODE_NORMAL)\n\t{\n\t    \/\/ If an operator was pending, we don't know what the user wanted\n\t    \/\/ to do. Go back to normal mode: Clear the operator and beep().\n\t    if (oap != NULL && oap->op_type != OP_NOP)\n\t    {\n\t\tclearopbeep(oap);\n\t\treturn FALSE;\n\t    }\n\n\t    \/\/ If visual was active, yank the highlighted text and put it\n\t    \/\/ before the mouse pointer position.\n\t    \/\/ In Select mode replace the highlighted text with the clipboard.\n\t    if (VIsual_active)\n\t    {\n\t\tif (VIsual_select)\n\t\t{\n\t\t    stuffcharReadbuff(Ctrl_G);\n\t\t    stuffReadbuff((char_u *)\"\\\"+p\");\n\t\t}\n\t\telse\n\t\t{\n\t\t    stuffcharReadbuff('y');\n\t\t    stuffcharReadbuff(K_MIDDLEMOUSE);\n\t\t}\n\t\tdo_always = TRUE;\t\/\/ ignore 'mouse' setting next time\n\t\treturn FALSE;\n\t    }\n\t    \/\/ The rest is below jump_to_mouse()\n\t}\n\n\telse if ((State & MODE_INSERT) == 0)\n\t    return FALSE;\n\n\t\/\/ Middle click in insert mode doesn't move the mouse, just insert the\n\t\/\/ contents of a register.  '.' register is special, can't insert that\n\t\/\/ with do_put().\n\t\/\/ Also paste at the cursor if the current mode isn't in 'mouse' (only\n\t\/\/ happens for the GUI).\n\tif ((State & MODE_INSERT) || !mouse_has(MOUSE_NORMAL))\n\t{\n\t    if (regname == '.')\n\t\tinsert_reg(regname, TRUE);\n\t    else\n\t    {\n#ifdef FEAT_CLIPBOARD\n\t\tif (clip_star.available && regname == 0)\n\t\t    regname = '*';\n#endif\n\t\tif ((State & REPLACE_FLAG) && !yank_register_mline(regname))\n\t\t    insert_reg(regname, TRUE);\n\t\telse\n\t\t{\n\t\t    do_put(regname, NULL, BACKWARD, 1L,\n\t\t\t\t\t\t      fixindent | PUT_CURSEND);\n\n\t\t    \/\/ Repeat it with CTRL-R CTRL-O r or CTRL-R CTRL-P r\n\t\t    AppendCharToRedobuff(Ctrl_R);\n\t\t    AppendCharToRedobuff(fixindent ? Ctrl_P : Ctrl_O);\n\t\t    AppendCharToRedobuff(regname == 0 ? '\"' : regname);\n\t\t}\n\t    }\n\t    return FALSE;\n\t}\n    }\n\n    \/\/ When dragging or button-up stay in the same window.\n    if (!is_click)\n\tjump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE;\n\n    start_visual.lnum = 0;\n\n    \/\/ Check for clicking in the tab page line.\n    if (mouse_row == 0 && firstwin->w_winrow > 0)\n    {\n\tif (is_drag)\n\t{\n\t    if (in_tab_line)\n\t    {\n\t\tc1 = TabPageIdxs[mouse_col];\n\t\ttabpage_move(c1 <= 0 ? 9999 : c1 < tabpage_index(curtab)\n\t\t\t\t\t\t\t\t? c1 - 1 : c1);\n\t    }\n\t    return FALSE;\n\t}\n\n\t\/\/ click in a tab selects that tab page\n\tif (is_click\n# ifdef FEAT_CMDWIN\n\t\t&& cmdwin_type == 0\n# endif\n\t\t&& mouse_col < Columns)\n\t{\n\t    in_tab_line = TRUE;\n\t    c1 = TabPageIdxs[mouse_col];\n\t    if (c1 >= 0)\n\t    {\n\t\tif ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t\t{\n\t\t    \/\/ double click opens new page\n\t\t    end_visual_mode_keep_button();\n\t\t    tabpage_new();\n\t\t    tabpage_move(c1 == 0 ? 9999 : c1 - 1);\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/\/ Go to specified tab page, or next one if not clicking\n\t\t    \/\/ on a label.\n\t\t    goto_tabpage(c1);\n\n\t\t    \/\/ It's like clicking on the status line of a window.\n\t\t    if (curwin != old_curwin)\n\t\t\tend_visual_mode_keep_button();\n\t\t}\n\t    }\n\t    else\n\t    {\n\t\ttabpage_T\t*tp;\n\n\t\t\/\/ Close the current or specified tab page.\n\t\tif (c1 == -999)\n\t\t    tp = curtab;\n\t\telse\n\t\t    tp = find_tabpage(-c1);\n\t\tif (tp == curtab)\n\t\t{\n\t\t    if (first_tabpage->tp_next != NULL)\n\t\t\ttabpage_close(FALSE);\n\t\t}\n\t\telse if (tp != NULL)\n\t\t    tabpage_close_other(tp, FALSE);\n\t    }\n\t}\n\treturn TRUE;\n    }\n    else if (is_drag && in_tab_line)\n    {\n\tc1 = TabPageIdxs[mouse_col];\n\ttabpage_move(c1 <= 0 ? 9999 : c1 - 1);\n\treturn FALSE;\n    }\n\n    \/\/ When 'mousemodel' is \"popup\" or \"popup_setpos\", translate mouse events:\n    \/\/ right button up   -> pop-up menu\n    \/\/ shift-left button -> right button\n    \/\/ alt-left button   -> alt-right button\n    if (mouse_model_popup())\n    {\n\tif (which_button == MOUSE_RIGHT\n\t\t\t    && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))\n\t{\n#ifdef USE_POPUP_SETPOS\n# ifdef FEAT_GUI\n\t    if (gui.in_use)\n\t    {\n#  if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \\\n\t\t\t  || defined(FEAT_GUI_PHOTON)\n\t\tif (!is_click)\n\t\t    \/\/ Ignore right button release events, only shows the popup\n\t\t    \/\/ menu on the button down event.\n\t\t    return FALSE;\n#  endif\n#  if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU)\n\t\tif (is_click || is_drag)\n\t\t    \/\/ Ignore right button down and drag mouse events.  Windows\n\t\t    \/\/ only shows the popup menu on the button up event.\n\t\t    return FALSE;\n#  endif\n\t    }\n# endif\n# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)\n\t    else\n# endif\n# if defined(FEAT_TERM_POPUP_MENU)\n\t    if (!is_click)\n\t\t\/\/ Ignore right button release events, only shows the popup\n\t\t\/\/ menu on the button down event.\n\t\treturn FALSE;\n#endif\n\n\t    jump_flags = 0;\n\t    if (STRCMP(p_mousem, \"popup_setpos\") == 0)\n\t    {\n\t\t\/\/ First set the cursor position before showing the popup\n\t\t\/\/ menu.\n\t\tif (VIsual_active)\n\t\t{\n\t\t    pos_T    m_pos;\n\n\t\t    \/\/ set MOUSE_MAY_STOP_VIS if we are outside the\n\t\t    \/\/ selection or the current window (might have false\n\t\t    \/\/ negative here)\n\t\t    if (mouse_row < curwin->w_winrow\n\t\t\t || mouse_row\n\t\t\t\t  > (curwin->w_winrow + curwin->w_height))\n\t\t\tjump_flags = MOUSE_MAY_STOP_VIS;\n\t\t    else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER)\n\t\t\tjump_flags = MOUSE_MAY_STOP_VIS;\n\t\t    else\n\t\t    {\n\t\t\tif ((LT_POS(curwin->w_cursor, VIsual)\n\t\t\t\t    && (LT_POS(m_pos, curwin->w_cursor)\n\t\t\t\t\t|| LT_POS(VIsual, m_pos)))\n\t\t\t\t|| (LT_POS(VIsual, curwin->w_cursor)\n\t\t\t\t    && (LT_POS(m_pos, VIsual)\n\t\t\t\t      || LT_POS(curwin->w_cursor, m_pos))))\n\t\t\t{\n\t\t\t    jump_flags = MOUSE_MAY_STOP_VIS;\n\t\t\t}\n\t\t\telse if (VIsual_mode == Ctrl_V)\n\t\t\t{\n\t\t\t    getvcols(curwin, &curwin->w_cursor, &VIsual,\n\t\t\t\t\t\t     &leftcol, &rightcol);\n\t\t\t    getvcol(curwin, &m_pos, NULL, &m_pos.col, NULL);\n\t\t\t    if (m_pos.col < leftcol || m_pos.col > rightcol)\n\t\t\t\tjump_flags = MOUSE_MAY_STOP_VIS;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    jump_flags = MOUSE_MAY_STOP_VIS;\n\t    }\n\t    if (jump_flags)\n\t    {\n\t\tjump_flags = jump_to_mouse(jump_flags, NULL, which_button);\n\t\tupdate_curbuf(VIsual_active ? UPD_INVERTED : UPD_VALID);\n\t\tsetcursor();\n\t\tout_flush();    \/\/ Update before showing popup menu\n\t    }\n# ifdef FEAT_MENU\n\t    show_popupmenu();\n\t    got_click = FALSE;\t\/\/ ignore release events\n# endif\n\t    return (jump_flags & CURSOR_MOVED) != 0;\n#else\n\t    return FALSE;\n#endif\n\t}\n\tif (which_button == MOUSE_LEFT\n\t\t\t\t&& (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT)))\n\t{\n\t    which_button = MOUSE_RIGHT;\n\t    mod_mask &= ~MOD_MASK_SHIFT;\n\t}\n    }\n\n    if ((State & (MODE_NORMAL | MODE_INSERT))\n\t\t\t    && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))\n    {\n\tif (which_button == MOUSE_LEFT)\n\t{\n\t    if (is_click)\n\t    {\n\t\t\/\/ stop Visual mode for a left click in a window, but not when\n\t\t\/\/ on a status line\n\t\tif (VIsual_active)\n\t\t    jump_flags |= MOUSE_MAY_STOP_VIS;\n\t    }\n\t    else if (mouse_has(MOUSE_VISUAL))\n\t\tjump_flags |= MOUSE_MAY_VIS;\n\t}\n\telse if (which_button == MOUSE_RIGHT)\n\t{\n\t    if (is_click && VIsual_active)\n\t    {\n\t\t\/\/ Remember the start and end of visual before moving the\n\t\t\/\/ cursor.\n\t\tif (LT_POS(curwin->w_cursor, VIsual))\n\t\t{\n\t\t    start_visual = curwin->w_cursor;\n\t\t    end_visual = VIsual;\n\t\t}\n\t\telse\n\t\t{\n\t\t    start_visual = VIsual;\n\t\t    end_visual = curwin->w_cursor;\n\t\t}\n\t    }\n\t    jump_flags |= MOUSE_FOCUS;\n\t    if (mouse_has(MOUSE_VISUAL))\n\t\tjump_flags |= MOUSE_MAY_VIS;\n\t}\n    }\n\n    \/\/ If an operator is pending, ignore all drags and releases until the\n    \/\/ next mouse click.\n    if (!is_drag && oap != NULL && oap->op_type != OP_NOP)\n    {\n\tgot_click = FALSE;\n\toap->motion_type = MCHAR;\n    }\n\n    \/\/ When releasing the button let jump_to_mouse() know.\n    if (!is_click && !is_drag)\n\tjump_flags |= MOUSE_RELEASED;\n\n    \/\/ JUMP!\n    jump_flags = jump_to_mouse(jump_flags,\n\t\t\toap == NULL ? NULL : &(oap->inclusive), which_button);\n\n#ifdef FEAT_MENU\n    \/\/ A click in the window toolbar has no side effects.\n    if (jump_flags & MOUSE_WINBAR)\n\treturn FALSE;\n#endif\n    moved = (jump_flags & CURSOR_MOVED);\n    in_status_line = (jump_flags & IN_STATUS_LINE);\n    in_sep_line = (jump_flags & IN_SEP_LINE);\n\n#ifdef FEAT_NETBEANS_INTG\n    if (isNetbeansBuffer(curbuf)\n\t\t\t    && !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE)))\n    {\n\tint key = KEY2TERMCAP1(c);\n\n\tif (key == (int)KE_LEFTRELEASE || key == (int)KE_MIDDLERELEASE\n\t\t\t\t\t       || key == (int)KE_RIGHTRELEASE)\n\t    netbeans_button_release(which_button);\n    }\n#endif\n\n    \/\/ When jumping to another window, clear a pending operator.  That's a bit\n    \/\/ friendlier than beeping and not jumping to that window.\n    if (curwin != old_curwin && oap != NULL && oap->op_type != OP_NOP)\n\tclearop(oap);\n\n#ifdef FEAT_FOLDING\n    if (mod_mask == 0\n\t    && !is_drag\n\t    && (jump_flags & (MOUSE_FOLD_CLOSE | MOUSE_FOLD_OPEN))\n\t    && which_button == MOUSE_LEFT)\n    {\n\t\/\/ open or close a fold at this line\n\tif (jump_flags & MOUSE_FOLD_OPEN)\n\t    openFold(curwin->w_cursor.lnum, 1L);\n\telse\n\t    closeFold(curwin->w_cursor.lnum, 1L);\n\t\/\/ don't move the cursor if still in the same window\n\tif (curwin == old_curwin)\n\t    curwin->w_cursor = save_cursor;\n    }\n#endif\n\n#if defined(FEAT_CLIPBOARD) && defined(FEAT_CMDWIN)\n    if ((jump_flags & IN_OTHER_WIN) && !VIsual_active && clip_star.available)\n    {\n\tclip_modeless(which_button, is_click, is_drag);\n\treturn FALSE;\n    }\n#endif\n\n    \/\/ Set global flag that we are extending the Visual area with mouse\n    \/\/ dragging; temporarily minimize 'scrolloff'.\n    if (VIsual_active && is_drag && get_scrolloff_value())\n    {\n\t\/\/ In the very first line, allow scrolling one line\n\tif (mouse_row == 0)\n\t    mouse_dragging = 2;\n\telse\n\t    mouse_dragging = 1;\n    }\n\n    \/\/ When dragging the mouse above the window, scroll down.\n    if (is_drag && mouse_row < 0 && !in_status_line)\n    {\n\tscroll_redraw(FALSE, 1L);\n\tmouse_row = 0;\n    }\n\n    if (start_visual.lnum)\t\t\/\/ right click in visual mode\n    {\n       \/\/ When ALT is pressed make Visual mode blockwise.\n       if (mod_mask & MOD_MASK_ALT)\n\t   VIsual_mode = Ctrl_V;\n\n\t\/\/ In Visual-block mode, divide the area in four, pick up the corner\n\t\/\/ that is in the quarter that the cursor is in.\n\tif (VIsual_mode == Ctrl_V)\n\t{\n\t    getvcols(curwin, &start_visual, &end_visual, &leftcol, &rightcol);\n\t    if (curwin->w_curswant > (leftcol + rightcol) \/ 2)\n\t\tend_visual.col = leftcol;\n\t    else\n\t\tend_visual.col = rightcol;\n\t    if (curwin->w_cursor.lnum >=\n\t\t\t\t    (start_visual.lnum + end_visual.lnum) \/ 2)\n\t\tend_visual.lnum = start_visual.lnum;\n\n\t    \/\/ move VIsual to the right column\n\t    start_visual = curwin->w_cursor;\t    \/\/ save the cursor pos\n\t    curwin->w_cursor = end_visual;\n\t    coladvance(end_visual.col);\n\t    VIsual = curwin->w_cursor;\n\t    curwin->w_cursor = start_visual;\t    \/\/ restore the cursor\n\t}\n\telse\n\t{\n\t    \/\/ If the click is before the start of visual, change the start.\n\t    \/\/ If the click is after the end of visual, change the end.  If\n\t    \/\/ the click is inside the visual, change the closest side.\n\t    if (LT_POS(curwin->w_cursor, start_visual))\n\t\tVIsual = end_visual;\n\t    else if (LT_POS(end_visual, curwin->w_cursor))\n\t\tVIsual = start_visual;\n\t    else\n\t    {\n\t\t\/\/ In the same line, compare column number\n\t\tif (end_visual.lnum == start_visual.lnum)\n\t\t{\n\t\t    if (curwin->w_cursor.col - start_visual.col >\n\t\t\t\t    end_visual.col - curwin->w_cursor.col)\n\t\t\tVIsual = start_visual;\n\t\t    else\n\t\t\tVIsual = end_visual;\n\t\t}\n\n\t\t\/\/ In different lines, compare line number\n\t\telse\n\t\t{\n\t\t    diff = (curwin->w_cursor.lnum - start_visual.lnum) -\n\t\t\t\t(end_visual.lnum - curwin->w_cursor.lnum);\n\n\t\t    if (diff > 0)\t\t\/\/ closest to end\n\t\t\tVIsual = start_visual;\n\t\t    else if (diff < 0)\t\/\/ closest to start\n\t\t\tVIsual = end_visual;\n\t\t    else\t\t\t\/\/ in the middle line\n\t\t    {\n\t\t\tif (curwin->w_cursor.col <\n\t\t\t\t\t(start_visual.col + end_visual.col) \/ 2)\n\t\t\t    VIsual = end_visual;\n\t\t\telse\n\t\t\t    VIsual = start_visual;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n    \/\/ If Visual mode started in insert mode, execute \"CTRL-O\"\n    else if ((State & MODE_INSERT) && VIsual_active)\n\tstuffcharReadbuff(Ctrl_O);\n\n    \/\/ Middle mouse click: Put text before cursor.\n    if (which_button == MOUSE_MIDDLE)\n    {\n#ifdef FEAT_CLIPBOARD\n\tif (clip_star.available && regname == 0)\n\t    regname = '*';\n#endif\n\tif (yank_register_mline(regname))\n\t{\n\t    if (mouse_past_bottom)\n\t\tdir = FORWARD;\n\t}\n\telse if (mouse_past_eol)\n\t    dir = FORWARD;\n\n\tif (fixindent)\n\t{\n\t    c1 = (dir == BACKWARD) ? '[' : ']';\n\t    c2 = 'p';\n\t}\n\telse\n\t{\n\t    c1 = (dir == FORWARD) ? 'p' : 'P';\n\t    c2 = NUL;\n\t}\n\tprep_redo(regname, count, NUL, c1, NUL, c2, NUL);\n\n\t\/\/ Remember where the paste started, so in edit() Insstart can be set\n\t\/\/ to this position\n\tif (restart_edit != 0)\n\t    where_paste_started = curwin->w_cursor;\n\tdo_put(regname, NULL, dir, count, fixindent | PUT_CURSEND);\n    }\n\n#if defined(FEAT_QUICKFIX)\n    \/\/ Ctrl-Mouse click or double click in a quickfix window jumps to the\n    \/\/ error under the mouse pointer.\n    else if (((mod_mask & MOD_MASK_CTRL)\n\t\t|| (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t    && bt_quickfix(curbuf))\n    {\n\tif (curwin->w_llist_ref == NULL)\t\/\/ quickfix window\n\t    do_cmdline_cmd((char_u *)\".cc\");\n\telse\t\t\t\t\t\/\/ location list window\n\t    do_cmdline_cmd((char_u *)\".ll\");\n\tgot_click = FALSE;\t\t\/\/ ignore drag&release now\n    }\n#endif\n\n    \/\/ Ctrl-Mouse click (or double click in a help window) jumps to the tag\n    \/\/ under the mouse pointer.\n    else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help\n\t\t     && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK))\n    {\n\tif (State & MODE_INSERT)\n\t    stuffcharReadbuff(Ctrl_O);\n\tstuffcharReadbuff(Ctrl_RSB);\n\tgot_click = FALSE;\t\t\/\/ ignore drag&release now\n    }\n\n    \/\/ Shift-Mouse click searches for the next occurrence of the word under\n    \/\/ the mouse pointer\n    else if ((mod_mask & MOD_MASK_SHIFT))\n    {\n\tif ((State & MODE_INSERT) || (VIsual_active && VIsual_select))\n\t    stuffcharReadbuff(Ctrl_O);\n\tif (which_button == MOUSE_LEFT)\n\t    stuffcharReadbuff('*');\n\telse\t\/\/ MOUSE_RIGHT\n\t    stuffcharReadbuff('#');\n    }\n\n    \/\/ Handle double clicks, unless on status line\n    else if (in_status_line)\n    {\n#ifdef FEAT_MOUSESHAPE\n\tif ((is_drag || is_click) && !drag_status_line)\n\t{\n\t    drag_status_line = TRUE;\n\t    update_mouseshape(-1);\n\t}\n#endif\n    }\n    else if (in_sep_line)\n    {\n#ifdef FEAT_MOUSESHAPE\n\tif ((is_drag || is_click) && !drag_sep_line)\n\t{\n\t    drag_sep_line = TRUE;\n\t    update_mouseshape(-1);\n\t}\n#endif\n    }\n    else if ((mod_mask & MOD_MASK_MULTI_CLICK)\n\t\t\t\t       && (State & (MODE_NORMAL | MODE_INSERT))\n\t     && mouse_has(MOUSE_VISUAL))\n    {\n\tif (is_click || !VIsual_active)\n\t{\n\t    if (VIsual_active)\n\t\torig_cursor = VIsual;\n\t    else\n\t    {\n\t\tcheck_visual_highlight();\n\t\tVIsual = curwin->w_cursor;\n\t\torig_cursor = VIsual;\n\t\tVIsual_active = TRUE;\n\t\tVIsual_reselect = TRUE;\n\t\t\/\/ start Select mode if 'selectmode' contains \"mouse\"\n\t\tmay_start_select('o');\n\t\tsetmouse();\n\t    }\n\t    if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t    {\n\t\t\/\/ Double click with ALT pressed makes it blockwise.\n\t\tif (mod_mask & MOD_MASK_ALT)\n\t\t    VIsual_mode = Ctrl_V;\n\t\telse\n\t\t    VIsual_mode = 'v';\n\t    }\n\t    else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_3CLICK)\n\t\tVIsual_mode = 'V';\n\t    else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_4CLICK)\n\t\tVIsual_mode = Ctrl_V;\n#ifdef FEAT_CLIPBOARD\n\t    \/\/ Make sure the clipboard gets updated.  Needed because start and\n\t    \/\/ end may still be the same, and the selection needs to be owned\n\t    clip_star.vmode = NUL;\n#endif\n\t}\n\t\/\/ A double click selects a word or a block.\n\tif ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t{\n\t    pos_T\t*pos = NULL;\n\t    int\t\tgc;\n\n\t    if (is_click)\n\t    {\n\t\t\/\/ If the character under the cursor (skipping white space) is\n\t\t\/\/ not a word character, try finding a match and select a (),\n\t\t\/\/ {}, [], #if\/#endif, etc. block.\n\t\tend_visual = curwin->w_cursor;\n\t\twhile (gc = gchar_pos(&end_visual), VIM_ISWHITE(gc))\n\t\t    inc(&end_visual);\n\t\tif (oap != NULL)\n\t\t    oap->motion_type = MCHAR;\n\t\tif (oap != NULL\n\t\t\t&& VIsual_mode == 'v'\n\t\t\t&& !vim_iswordc(gchar_pos(&end_visual))\n\t\t\t&& EQUAL_POS(curwin->w_cursor, VIsual)\n\t\t\t&& (pos = findmatch(oap, NUL)) != NULL)\n\t\t{\n\t\t    curwin->w_cursor = *pos;\n\t\t    if (oap->motion_type == MLINE)\n\t\t\tVIsual_mode = 'V';\n\t\t    else if (*p_sel == 'e')\n\t\t    {\n\t\t\tif (LT_POS(curwin->w_cursor, VIsual))\n\t\t\t    ++VIsual.col;\n\t\t\telse\n\t\t\t    ++curwin->w_cursor.col;\n\t\t    }\n\t\t}\n\t    }\n\n\t    if (pos == NULL && (is_click || is_drag))\n\t    {\n\t\t\/\/ When not found a match or when dragging: extend to include\n\t\t\/\/ a word.\n\t\tif (LT_POS(curwin->w_cursor, orig_cursor))\n\t\t{\n\t\t    find_start_of_word(&curwin->w_cursor);\n\t\t    find_end_of_word(&VIsual);\n\t\t}\n\t\telse\n\t\t{\n\t\t    find_start_of_word(&VIsual);\n\t\t    if (*p_sel == 'e' && *ml_get_cursor() != NUL)\n\t\t\tcurwin->w_cursor.col +=\n\t\t\t\t\t (*mb_ptr2len)(ml_get_cursor());\n\t\t    find_end_of_word(&curwin->w_cursor);\n\t\t}\n\t    }\n\t    curwin->w_set_curswant = TRUE;\n\t}\n\tif (is_click)\n\t    redraw_curbuf_later(UPD_INVERTED);\t\/\/ update the inversion\n    }\n    else if (VIsual_active && !old_active)\n    {\n\tif (mod_mask & MOD_MASK_ALT)\n\t    VIsual_mode = Ctrl_V;\n\telse\n\t    VIsual_mode = 'v';\n    }\n\n    \/\/ If Visual mode changed show it later.\n    if ((!VIsual_active && old_active && mode_displayed)\n\t    || (VIsual_active && p_smd && msg_silent == 0\n\t\t\t\t && (!old_active || VIsual_mode != old_mode)))\n\tredraw_cmdline = TRUE;\n\n    return moved;\n}","target":1,"code_token_length":6524,"total_token_length":6760,"max_tokens_setting":8192}
+{"idx":211832,"func":"doit (struct query *z, int state)\n{\n    char key[257];\n    char misc[20], header[12];\n    char *buf = 0, *cached = 0;\n    const char *whichserver = 0;\n\n    unsigned int rcode = 0;\n    unsigned int posanswers = 0;\n    unsigned int len = 0, cachedlen = 0;\n\n    uint16 numanswers = 0;\n    uint16 numauthority = 0;\n    unsigned int posauthority = 0;\n\n    uint16 numglue = 0;\n    unsigned int posglue = 0;\n    unsigned int pos = 0, pos2 = 0;\n\n    uint16 datalen = 0;\n    char *control = 0, *d = 0;\n\n    const char *dtype = 0;\n    unsigned int dlen = 0;\n\n    int flagout = 0, flagcname = 0;\n    int flagreferral = 0, flagsoa = 0;\n\n    int i = 0, j = 0, k = 0, p = 0, q = 0;\n    uint32 ttl = 0, soattl = 0, cnamettl = 0;\n\n    errno = error_io;\n    if (state == 1)\n        goto HAVEPACKET;\n    if (state == -1)\n    {\n        if (debug_level > 1)\n            log_servfail (z->name[z->level]);\n        goto SERVFAIL;\n    }\n\n\nNEWNAME:\n    if (++z->loop == 100)\n        goto DIE;\n    d = z->name[z->level];\n    dtype = z->level ? DNS_T_A : z->type;\n    dlen = dns_domain_length (d);\n\n    if (globalip (d, misc))\n    {\n        if (z->level)\n        {\n            for (k = 0; k < 64; k += 4)\n            {\n                if (byte_equal (z->servers[z->level - 1] + k, 4, \"\\0\\0\\0\\0\"))\n                {\n                    byte_copy (z->servers[z->level - 1] + k, 4, misc);\n                    break;\n                }\n            }\n            goto LOWERLEVEL;\n        }\n        if (!rqa (z))\n            goto DIE;\n        if (typematch (DNS_T_A, dtype))\n        {\n            if (!response_rstart (d, DNS_T_A, 655360))\n                goto DIE;\n            if (!response_addbytes (misc, 4))\n                goto DIE;\n            response_rfinish (RESPONSE_ANSWER);\n        }\n        cleanup (z);\n\n        return 1;\n    }\n\n    if (dns_domain_equal (d, \"\\0011\\0010\\0010\\003127\\7in-addr\\4arpa\\0\"))\n    {\n        if (z->level)\n            goto LOWERLEVEL;\n        if (!rqa (z))\n            goto DIE;\n        if (typematch (DNS_T_PTR, dtype))\n        {\n            if (!response_rstart (d, DNS_T_PTR, 655360))\n                goto DIE;\n            if (!response_addname (\"\\011localhost\\0\"))\n                goto DIE;\n\n            response_rfinish (RESPONSE_ANSWER);\n        }\n        cleanup (z);\n        if (debug_level > 2)\n            log_stats ();\n\n        return 1;\n    }\n\n    if (dlen <= 255)\n    {\n        byte_copy (key, 2, DNS_T_ANY);\n        byte_copy (key + 2, dlen, d);\n        case_lowerb (key + 2, dlen);\n        cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n        if (cached)\n        {\n            if (debug_level > 2)\n                log_cachednxdomain (d);\n            goto NXDOMAIN;\n        }\n\n        byte_copy (key, 2, DNS_T_CNAME);\n        cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n        if (cached)\n        {\n            if (typematch (DNS_T_CNAME, dtype))\n            {\n                if (debug_level > 2)\n                    log_cachedanswer (d, DNS_T_CNAME);\n\n                if (!rqa (z))\n                    goto DIE;\n                if (!response_cname (z->name[0], cached, ttl))\n                    goto DIE;\n                cleanup (z);\n\n                return 1;\n            }\n            if (debug_level > 2)\n                log_cachedcname (d, cached);\n\n            if (!dns_domain_copy (&cname, cached))\n                goto DIE;\n\n            goto CNAME;\n        }\n\n        if (typematch (DNS_T_NS, dtype))\n        {\n            byte_copy (key, 2, DNS_T_NS);\n            cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n            if (cached && (cachedlen || byte_diff (dtype, 2, DNS_T_ANY)))\n            {\n                if (debug_level > 2)\n                    log_cachedanswer (d, DNS_T_NS);\n                if (!rqa (z))\n                    goto DIE;\n\n                pos = 0;\n                while ((pos=dns_packet_getname (cached, cachedlen, pos, &t2)))\n                {\n                    if (!response_rstart (d, DNS_T_NS, ttl))\n                        goto DIE;\n                    if (!response_addname (t2))\n                        goto DIE;\n\n                    response_rfinish (RESPONSE_ANSWER);\n                }\n                cleanup (z);\n\n                return 1;\n            }\n        }\n\n        if (typematch (DNS_T_PTR, dtype))\n        {\n            byte_copy (key, 2, DNS_T_PTR);\n            cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n            if (cached && (cachedlen || byte_diff(dtype, 2, DNS_T_ANY)))\n            {\n                if (debug_level > 2)\n                    log_cachedanswer (d, DNS_T_PTR);\n                if (!rqa (z))\n                    goto DIE;\n\n                pos = 0;\n                while ((pos=dns_packet_getname (cached, cachedlen, pos, &t2)))\n                {\n                    if (!response_rstart (d, DNS_T_PTR, ttl))\n                        goto DIE;\n                    if (!response_addname (t2))\n                        goto DIE;\n\n                    response_rfinish (RESPONSE_ANSWER);\n                }\n                cleanup(z);\n\n                return 1;\n            }\n        }\n\n        if (typematch (DNS_T_MX, dtype))\n        {\n            byte_copy (key, 2, DNS_T_MX);\n            cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n            if (cached && (cachedlen || byte_diff (dtype, 2, DNS_T_ANY)))\n            {\n                if (debug_level > 2)\n                    log_cachedanswer (d, DNS_T_MX);\n                if (!rqa (z))\n                    goto DIE;\n\n                pos = 0;\n                while ((pos=dns_packet_copy (cached, cachedlen, pos, misc, 2)))\n                {\n                    pos = dns_packet_getname (cached, cachedlen, pos, &t2);\n                    if (!pos)\n                        break;\n                    if (!response_rstart (d, DNS_T_MX, ttl))\n                        goto DIE;\n                    if (!response_addbytes (misc, 2))\n                        goto DIE;\n                    if (!response_addname (t2))\n                        goto DIE;\n\n                    response_rfinish (RESPONSE_ANSWER);\n                }\n                cleanup (z);\n\n                return 1;\n            }\n        }\n\n        if (typematch (DNS_T_A, dtype))\n        {\n            byte_copy (key,2,DNS_T_A);\n            cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n            if (cached && (cachedlen || byte_diff (dtype, 2, DNS_T_ANY)))\n            {\n                if (z->level)\n                {\n                    if (debug_level > 2)\n                        log_cachedanswer (d, DNS_T_A);\n                    while (cachedlen >= 4)\n                    {\n                        for (k = 0; k < 64; k += 4)\n                        {\n                            if (byte_equal (z->servers[z->level - 1] + k,\n                                            4, \"\\0\\0\\0\\0\"))\n                            {\n                                byte_copy (z->servers[z->level - 1] + k,\n                                            4, cached);\n                                break;\n                            }\n                        }\n                        cached += 4;\n                        cachedlen -= 4;\n                    }\n                    goto LOWERLEVEL;\n                }\n\n                if (debug_level > 2)\n                    log_cachedanswer (d, DNS_T_A);\n                if (!rqa (z))\n                    goto DIE;\n                while (cachedlen >= 4)\n                {\n                    if (!response_rstart (d, DNS_T_A, ttl))\n                        goto DIE;\n                    if (!response_addbytes (cached, 4))\n                        goto DIE;\n                    response_rfinish (RESPONSE_ANSWER);\n                    cached += 4;\n                    cachedlen -= 4;\n                }\n                cleanup (z);\n\n                return 1;\n            }\n        }\n\n        if (!typematch (DNS_T_ANY, dtype)\n            && !typematch (DNS_T_AXFR, dtype)\n            && !typematch (DNS_T_CNAME, dtype)\n            && !typematch (DNS_T_NS, dtype)\n            && !typematch (DNS_T_PTR, dtype)\n            && !typematch (DNS_T_A, dtype)\n            && !typematch (DNS_T_MX, dtype))\n        {\n            byte_copy (key, 2, dtype);\n            cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n            if (cached && (cachedlen || byte_diff (dtype, 2, DNS_T_ANY)))\n            {\n                if (debug_level > 2)\n                    log_cachedanswer (d, dtype);\n                if (!rqa (z))\n                    goto DIE;\n                while (cachedlen >= 2)\n                {\n                    uint16_unpack_big (cached, &datalen);\n                    cached += 2;\n                    cachedlen -= 2;\n                    if (datalen > cachedlen)\n                        goto DIE;\n                    if (!response_rstart (d, dtype, ttl))\n                        goto DIE;\n                    if (!response_addbytes (cached, datalen))\n                        goto DIE;\n                    response_rfinish (RESPONSE_ANSWER);\n                    cached += datalen;\n                    cachedlen -= datalen;\n                }\n                cleanup (z);\n\n                return 1;\n            }\n        }\n    }\n\n    for (;;)\n    {\n        if (roots (z->servers[z->level], d))\n        {\n            for (j = 0; j < QUERY_MAXNS; ++j)\n                dns_domain_free (&z->ns[z->level][j]);\n            z->control[z->level] = d;\n            break;\n        }\n\n        if (!flagforwardonly && (z->level < 2))\n        {\n            if (dlen < 255)\n            {\n                byte_copy (key,2,DNS_T_NS);\n                byte_copy (key + 2,dlen,d);\n                case_lowerb (key + 2,dlen);\n                cached = cache_get (key, dlen + 2, &cachedlen, &ttl);\n                if (cached && cachedlen)\n                {\n                    z->control[z->level] = d;\n                    byte_zero (z->servers[z->level],64);\n                    for (j = 0; j < QUERY_MAXNS; ++j)\n                        dns_domain_free (&z->ns[z->level][j]);\n\n                    j = pos = 0;\n                    pos = dns_packet_getname (cached, cachedlen, pos, &t1);\n                    while (pos)\n                    {\n                        if (debug_level > 2)\n                            log_cachedns (d, t1);\n                        if (j < QUERY_MAXNS)\n                            if (!dns_domain_copy (&z->ns[z->level][j++], t1))\n                                goto DIE;\n\n                        pos = dns_packet_getname (cached, cachedlen, pos, &t1);\n                    }\n                    break;\n                }\n            }\n        }\n\n        if (!*d)\n            goto DIE;\n        j = 1 + (unsigned int) (unsigned char) *d;\n        dlen -= j;\n        d += j;\n    }\n\n\nHAVENS:\n    for (j = 0; j < QUERY_MAXNS; ++j)\n    {\n        if (z->ns[z->level][j])\n        {\n            if (z->level + 1 < QUERY_MAXLEVEL)\n            {\n                int dc = dns_domain_copy (&z->name[z->level + 1],\n                                                    z->ns[z->level][j]);\n                if (!dc)\n                    goto DIE;\n\n                dns_domain_free (&z->ns[z->level][j]);\n                ++z->level;\n                goto NEWNAME;\n            }\n            dns_domain_free (&z->ns[z->level][j]);\n        }\n    }\n\n    for (j = 0; j < 64; j += 4)\n        if (byte_diff (z->servers[z->level] + j, 4, \"\\0\\0\\0\\0\"))\n            break;\n    if (j == 64)\n        goto SERVFAIL;\n\n    dns_sortip (z->servers[z->level], 64);\n    if (z->level)\n    {\n        if (debug_level > 2)\n            log_tx (z->name[z->level], DNS_T_A,\n                        z->control[z->level], z->servers[z->level],z->level);\n\n        if (dns_transmit_start (&z->dt, z->servers[z->level], flagforwardonly,\n                                z->name[z->level], DNS_T_A,z->localip) == -1)\n            goto DIE;\n    }\n    else\n    {\n        if (debug_level > 2)\n            log_tx (z->name[0], z->type, z->control[0], z->servers[0], 0);\n\n        if (dns_transmit_start (&z->dt, z->servers[0], flagforwardonly,\n                                z->name[0], z->type, z->localip) == -1)\n            goto DIE;\n    }\n    return 0;\n\n\nLOWERLEVEL:\n    dns_domain_free (&z->name[z->level]);\n    for (j = 0; j < QUERY_MAXNS; ++j)\n        dns_domain_free (&z->ns[z->level][j]);\n    --z->level;\n    goto HAVENS;\n\n\nHAVEPACKET:\n    if (++z->loop == 100)\n        goto DIE;\n    buf = z->dt.packet;\n    len = z->dt.packetlen;\n\n    whichserver = z->dt.servers + 4 * z->dt.curserver;\n    control = z->control[z->level];\n    d = z->name[z->level];\n    dtype = z->level ? DNS_T_A : z->type;\n\n    if (!(pos = dns_packet_copy (buf, len, 0, header, 12)))\n        goto DIE;\n    if (!(pos = dns_packet_skipname (buf, len, pos)))\n        goto DIE;\n    pos += 4;\n    posanswers = pos;\n\n    uint16_unpack_big (header + 6, &numanswers);\n    uint16_unpack_big (header + 8, &numauthority);\n    uint16_unpack_big (header + 10, &numglue);\n\n    rcode = header[3] & 15;\n    if (rcode && (rcode != 3))\n        goto DIE; \/* impossible; see irrelevant() *\/\n\n    flagsoa = soattl = cnamettl = 0;\n    flagout = flagcname = flagreferral = 0;\n    for (j = 0; j < numanswers; ++j)\n    {\n        pos = dns_packet_getname (buf, len, pos, &t1);\n        if (!pos)\n            goto DIE;\n        pos = dns_packet_copy (buf, len, pos, header, 10);\n        if (!pos)\n            goto DIE;\n\n        if (dns_domain_equal (t1, d))\n        {\n            if (byte_equal (header + 2, 2, DNS_C_IN))\n            {\n                \/* should always be true *\/\n                if (typematch (header, dtype))\n                    flagout = 1;\n                else if (typematch (header, DNS_T_CNAME))\n                {\n                    if (!dns_packet_getname (buf, len, pos, &cname))\n                        goto DIE;\n                    flagcname = 1;\n                    cnamettl = ttlget (header + 4);\n                }\n            }\n        }\n        uint16_unpack_big (header + 8, &datalen);\n        pos += datalen;\n    }\n    posauthority = pos;\n\n    for (j = 0; j < numauthority; ++j)\n    {\n        pos = dns_packet_getname (buf, len, pos, &t1);\n        if (!pos)\n            goto DIE;\n        pos = dns_packet_copy (buf, len, pos, header, 10);\n        if (!pos)\n            goto DIE;\n\n        if (typematch (header, DNS_T_SOA))\n        {\n            flagsoa = 1;\n            soattl = ttlget (header + 4);\n            if (soattl > 3600)\n                soattl = 3600;\n        }\n        else if (typematch (header, DNS_T_NS))\n        {\n            flagreferral = 1;\n            if (!dns_domain_copy (&referral, t1))\n                goto DIE;\n        }\n\n        uint16_unpack_big (header + 8, &datalen);\n        pos += datalen;\n    }\n    posglue = pos;\n\n    if (!flagcname && !rcode && !flagout && flagreferral && !flagsoa)\n    {\n        if (dns_domain_equal (referral, control)\n            || !dns_domain_suffix (referral, control))\n        {\n            if (debug_level > 2)\n                log_lame (whichserver, control, referral);\n            byte_zero (whichserver, 4);\n\n            goto HAVENS;\n        }\n    }\n\n    if (records)\n    {\n        alloc_free (records);\n        records = 0;\n    }\n\n    k = numanswers + numauthority + numglue;\n    records = (unsigned int *) alloc (k * sizeof (unsigned int));\n    if (!records)\n        goto DIE;\n\n    pos = posanswers;\n    for (j = 0; j < k; ++j)\n    {\n        records[j] = pos;\n        pos = dns_packet_getname (buf, len, pos, &t1);\n        if (!pos)\n            goto DIE;\n        pos = dns_packet_copy (buf, len, pos, header, 10);\n        if (!pos)\n            goto DIE;\n        uint16_unpack_big (header + 8, &datalen);\n        pos += datalen;\n    }\n\n    i = j = k;\n    while (j > 1)\n    {\n        if (i > 1)\n        {\n            --i;\n            pos = records[i - 1];\n        }\n        else\n        {\n            pos = records[j - 1];\n            records[j - 1] = records[i - 1];\n            --j;\n        }\n\n        q = i;\n        while ((p = q * 2) < j)\n        {\n            if (!smaller (buf, len, records[p], records[p - 1]))\n                ++p;\n            records[q - 1] = records[p - 1];\n            q = p;\n        }\n        if (p == j)\n        {\n            records[q - 1] = records[p - 1];\n            q = p;\n        }\n        while ((q > i) && smaller (buf, len, records[(p = q\/2) - 1], pos))\n        {\n            records[q - 1] = records[p - 1];\n            q = p;\n        }\n        records[q - 1] = pos;\n    }\n\n    i = 0;\n    while (i < k)\n    {\n        char type[2];\n\n        if (!(pos = dns_packet_getname (buf, len, records[i], &t1)))\n            goto DIE;\n        if (!(pos = dns_packet_copy (buf, len, pos, header, 10)))\n            goto DIE;\n        ttl = ttlget (header + 4);\n\n        byte_copy (type, 2, header);\n        if (byte_diff (header + 2, 2, DNS_C_IN))\n        {\n            ++i;\n            continue;\n        }\n\n        for (j = i + 1; j < k; ++j)\n        {\n            pos = dns_packet_getname (buf, len, records[j], &t2);\n            if (!pos)\n                goto DIE;\n            pos = dns_packet_copy (buf, len, pos, header, 10);\n            if (!pos)\n                goto DIE;\n            if (!dns_domain_equal (t1, t2))\n                break;\n            if (byte_diff (header, 2, type))\n                break;\n            if (byte_diff (header + 2, 2, DNS_C_IN))\n                break;\n        }\n\n        if (!dns_domain_suffix (t1, control))\n        {\n            i = j;\n            continue;\n        }\n        if (!roots_same (t1, control))\n        {\n            i = j;\n            continue;\n        }\n        if (byte_equal (type, 2, DNS_T_ANY))\n            ;\n        else if (byte_equal(type, 2, DNS_T_AXFR))\n            ;\n        else if (byte_equal (type, 2, DNS_T_SOA))\n        {\n            while (i < j)\n            {\n                pos = dns_packet_skipname (buf, len, records[i]);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_getname (buf, len, pos + 10, &t2);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_getname (buf, len, pos, &t3);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_copy (buf, len, pos, misc, 20);\n                if (!pos)\n                    goto DIE;\n                if (records[i] < posauthority && debug_level > 2)\n                      log_rrsoa (whichserver, t1, t2, t3, misc, ttl);\n                ++i;\n            }\n        }\n        else if (byte_equal (type, 2, DNS_T_CNAME))\n        {\n            pos = dns_packet_skipname (buf, len, records[j - 1]);\n            if (!pos)\n                goto DIE;\n            pos = dns_packet_getname (buf, len, pos + 10, &t2);\n            if (!pos)\n                goto DIE;\n\n            if (debug_level > 2)\n                log_rrcname (whichserver, t1, t2, ttl);\n\n            cachegeneric (DNS_T_CNAME, t1, t2, dns_domain_length (t2), ttl);\n        }\n        else if (byte_equal (type, 2, DNS_T_PTR))\n        {\n            save_start ();\n            while (i < j)\n            {\n                pos = dns_packet_skipname (buf, len, records[i]);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_getname (buf, len, pos + 10, &t2);\n                if (!pos)\n                    goto DIE;\n                if (debug_level > 2)\n                    log_rrptr (whichserver, t1, t2, ttl);\n\n                save_data (t2, dns_domain_length (t2));\n                ++i;\n            }\n            save_finish (DNS_T_PTR, t1, ttl);\n        }\n        else if (byte_equal (type, 2, DNS_T_NS))\n        {\n            save_start ();\n            while (i < j)\n            {\n                pos = dns_packet_skipname (buf, len, records[i]);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_getname (buf, len, pos + 10, &t2);\n                if (!pos)\n                    goto DIE;\n                if (debug_level > 2)\n                    log_rrns (whichserver, t1, t2, ttl);\n                save_data (t2, dns_domain_length (t2));\n                ++i;\n            }\n            save_finish (DNS_T_NS, t1, ttl);\n        }\n        else if (byte_equal (type, 2, DNS_T_MX))\n        {\n            save_start ();\n            while (i < j)\n            {\n                pos = dns_packet_skipname (buf, len, records[i]);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_copy (buf, len, pos + 10, misc, 2);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_getname (buf, len, pos, &t2);\n                if (!pos)\n                    goto DIE;\n                if (debug_level > 2)\n                    log_rrmx (whichserver, t1, t2, misc, ttl);\n                save_data (misc, 2);\n                save_data (t2, dns_domain_length (t2));\n                ++i;\n            }\n            save_finish (DNS_T_MX, t1, ttl);\n        }\n        else if (byte_equal (type, 2, DNS_T_A))\n        {\n            save_start ();\n            while (i < j)\n            {\n                pos = dns_packet_skipname (buf, len, records[i]);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_copy (buf, len, pos, header, 10);\n                if (!pos)\n                    goto DIE;\n                if (byte_equal (header + 8, 2, \"\\0\\4\"))\n                {\n                    pos = dns_packet_copy (buf, len, pos, header, 4);\n                    if (!pos)\n                        goto DIE;\n                    save_data (header, 4);\n\n                    if (debug_level > 2)\n                        log_rr (whichserver, t1, DNS_T_A, header, 4, ttl);\n                }\n                ++i;\n            }\n            save_finish (DNS_T_A, t1, ttl);\n        }\n        else\n        {\n            save_start ();\n            while (i < j)\n            {\n                pos = dns_packet_skipname (buf, len, records[i]);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_copy (buf, len, pos, header, 10);\n                if (!pos)\n                    goto DIE;\n                uint16_unpack_big (header + 8, &datalen);\n                if (datalen > len - pos)\n                    goto DIE;\n                save_data (header + 8, 2);\n                save_data (buf + pos, datalen);\n\n                if (debug_level > 2)\n                    log_rr (whichserver, t1, type, buf + pos, datalen, ttl);\n\n                ++i;\n            }\n            save_finish (type, t1, ttl);\n        }\n        i = j;\n    }\n    alloc_free (records);\n    records = 0;\n\n    if (flagcname)\n    {\n        ttl = cnamettl;\nCNAME:\n        if (!z->level)\n        {\n            if (z->alias[QUERY_MAXALIAS - 1])\n                goto DIE;\n\n            for (j = QUERY_MAXALIAS - 1; j > 0; --j)\n                z->alias[j] = z->alias[j - 1];\n            for (j = QUERY_MAXALIAS - 1; j > 0; --j)\n                z->aliasttl[j] = z->aliasttl[j - 1];\n\n            z->alias[0] = z->name[0];\n            z->aliasttl[0] = ttl;\n            z->name[0] = 0;\n        }\n        if (!dns_domain_copy (&z->name[z->level], cname))\n            goto DIE;\n\n        goto NEWNAME;\n    }\n\n    if (rcode == 3)\n    {\n        if (debug_level > 2)\n            log_nxdomain (whichserver, d, soattl);\n        cachegeneric (DNS_T_ANY, d, \"\", 0, soattl);\n\nNXDOMAIN:\n        if (z->level)\n            goto LOWERLEVEL;\n        if (!rqa (z))\n            goto DIE;\n\n        response_nxdomain ();\n        cleanup (z);\n\n        return 1;\n    }\n\n    if (!flagout && flagsoa)\n        if (byte_diff (DNS_T_ANY, 2, dtype))\n            if (byte_diff (DNS_T_AXFR, 2, dtype))\n                if (byte_diff (DNS_T_CNAME, 2, dtype))\n                {\n                    save_start ();\n                    save_finish (dtype, d, soattl);\n                    if (debug_level > 2)\n                        log_nodata (whichserver, d, dtype, soattl);\n                }\n\n    if (debug_level > 2)\n        log_stats ();\n\n    if (flagout || flagsoa || !flagreferral)\n    {\n        if (z->level)\n        {\n            pos = posanswers;\n            for (j = 0; j < numanswers; ++j)\n            {\n                pos = dns_packet_getname (buf, len, pos, &t1);\n                if (!pos)\n                    goto DIE;\n                pos = dns_packet_copy (buf, len, pos, header, 10);\n                if (!pos)\n                    goto DIE;\n                uint16_unpack_big (header + 8, &datalen);\n                if (dns_domain_equal (t1, d))\n                    if (typematch (header, DNS_T_A))\n                        if (byte_equal (header + 2, 2, DNS_C_IN))\n                            \/* should always be true *\/\n                            if (datalen == 4)\n                                for (k = 0; k < 64; k += 4)\n                                {\n                                    if (byte_equal (z->servers[z->level - 1]\n                                                     + k, 4, \"\\0\\0\\0\\0\"))\n                                    {\n                                        if (!dns_packet_copy (buf, len, pos,\n                                             z->servers[z->level - 1] + k, 4))\n                                            goto DIE;\n                                        break;\n                                    }\n                                }\n                pos += datalen;\n            }\n            goto LOWERLEVEL;\n        }\n\n        if (!rqa (z))\n            goto DIE;\n\n        pos = posanswers;\n        for (j = 0; j < numanswers; ++j)\n        {\n            pos = dns_packet_getname (buf, len, pos, &t1);\n            if (!pos)\n                goto DIE;\n            pos = dns_packet_copy (buf, len, pos, header, 10);\n            if (!pos)\n                goto DIE;\n            ttl = ttlget (header + 4);\n            uint16_unpack_big (header + 8, &datalen);\n            if (dns_domain_equal (t1, d))\n            {\n                if (byte_equal (header + 2, 2, DNS_C_IN))\n                {   \/* should always be true *\/\n                    if (typematch (header, dtype))\n                    {\n                        if (!response_rstart (t1, header, ttl))\n                            goto DIE;\n\n                        if (typematch (header, DNS_T_NS)\n                            || typematch (header, DNS_T_CNAME)\n                            || typematch (header, DNS_T_PTR))\n                        {\n                            if (!dns_packet_getname (buf, len, pos, &t2))\n                                goto DIE;\n                            if (!response_addname (t2))\n                                goto DIE;\n                        }\n                        else if (typematch (header, DNS_T_MX))\n                        {\n                            pos2 = dns_packet_copy (buf, len, pos, misc, 2);\n                            if (!pos2)\n                                goto DIE;\n                            if (!response_addbytes (misc, 2))\n                                goto DIE;\n                            if (!dns_packet_getname (buf, len, pos2, &t2))\n                                goto DIE;\n                            if (!response_addname (t2))\n                                goto DIE;\n                        }\n                        else if (typematch (header, DNS_T_SOA))\n                        {\n                            pos2 = dns_packet_getname (buf, len, pos, &t2);\n                            if (!pos2)\n                                goto DIE;\n                            if (!response_addname (t2))\n                                goto DIE;\n                            pos2 = dns_packet_getname (buf, len, pos2, &t3);\n                            if (!pos2)\n                                goto DIE;\n                            if (!response_addname (t3))\n                                goto DIE;\n                            pos2 = dns_packet_copy (buf, len, pos2, misc, 20);\n                            if (!pos2)\n                                goto DIE;\n                            if (!response_addbytes (misc, 20))\n                                goto DIE;\n                        }\n                        else\n                        {\n                            if (pos + datalen > len)\n                                goto DIE;\n                            if (!response_addbytes (buf + pos, datalen))\n                                goto DIE;\n                        }\n                        response_rfinish(RESPONSE_ANSWER);\n                    }\n                }\n            }\n            pos += datalen;\n        }\n        cleanup (z);\n\n        return 1;\n    }\n\n    if (!dns_domain_suffix (d, referral))\n        goto DIE;\n    control = d + dns_domain_suffixpos (d, referral);\n    z->control[z->level] = control;\n    byte_zero (z->servers[z->level], 64);\n    for (j = 0; j < QUERY_MAXNS; ++j)\n        dns_domain_free (&z->ns[z->level][j]);\n    k = 0;\n\n    pos = posauthority;\n    for (j = 0; j < numauthority; ++j)\n    {\n        pos = dns_packet_getname (buf, len, pos, &t1);\n        if (!pos)\n            goto DIE;\n        pos = dns_packet_copy (buf, len, pos, header, 10);\n        if (!pos)\n            goto DIE;\n\n        uint16_unpack_big (header + 8, &datalen);\n        if (dns_domain_equal (referral, t1))    \/* should always be true *\/\n            if (typematch (header, DNS_T_NS))   \/* should always be true *\/\n                \/* should always be true *\/\n                if (byte_equal (header + 2, 2, DNS_C_IN))\n                    if (k < QUERY_MAXNS)\n                        if (!dns_packet_getname (buf, len, pos,\n                                                 &z->ns[z->level][k++]))\n                            goto DIE;\n        pos += datalen;\n    }\n\n    goto HAVENS;\n\n\nSERVFAIL:\n    if (z->level)\n        goto LOWERLEVEL;\n    if (!rqa (z))\n        goto DIE;\n    response_servfail ();\n    cleanup (z);\n\n    return 1;\n\n\nDIE:\n    cleanup (z);\n    if (records)\n    {\n        alloc_free (records);\n        records = 0;\n    }\n\n    return -1;\n}","target":1,"code_token_length":7509,"total_token_length":7745,"max_tokens_setting":8192}
+{"idx":208912,"func":"getcmdline_int(\n    int\t\tfirstc,\n    long\tcount UNUSED,\t\/\/ only used for incremental search\n    int\t\tindent,\t\t\/\/ indent for inside conditionals\n    int\t\tclear_ccline)\t\/\/ clear ccline first\n{\n    static int\tdepth = 0;\t    \/\/ call depth\n    int\t\tc;\n    int\t\ti;\n    int\t\tj;\n    int\t\tgotesc = FALSE;\t\t\/\/ TRUE when <ESC> just typed\n    int\t\tdo_abbr;\t\t\/\/ when TRUE check for abbr.\n    char_u\t*lookfor = NULL;\t\/\/ string to match\n    int\t\thiscnt;\t\t\t\/\/ current history line in use\n    int\t\thistype;\t\t\/\/ history type to be used\n#ifdef FEAT_SEARCH_EXTRA\n    incsearch_state_T\tis_state;\n#endif\n    int\t\tdid_wild_list = FALSE;\t\/\/ did wild_list() recently\n    int\t\twim_index = 0;\t\t\/\/ index in wim_flags[]\n    int\t\tres;\n    int\t\tsave_msg_scroll = msg_scroll;\n    int\t\tsave_State = State;\t\/\/ remember State when called\n    int\t\tsome_key_typed = FALSE;\t\/\/ one of the keys was typed\n    \/\/ mouse drag and release events are ignored, unless they are\n    \/\/ preceded with a mouse down event\n    int\t\tignore_drag_release = TRUE;\n#ifdef FEAT_EVAL\n    int\t\tbreak_ctrl_c = FALSE;\n#endif\n    expand_T\txpc;\n    long\t*b_im_ptr = NULL;\n    cmdline_info_T save_ccline;\n    int\t\tdid_save_ccline = FALSE;\n    int\t\tcmdline_type;\n    int\t\twild_type;\n\n    \/\/ one recursion level deeper\n    ++depth;\n\n    if (ccline.cmdbuff != NULL)\n    {\n\t\/\/ Being called recursively.  Since ccline is global, we need to save\n\t\/\/ the current buffer and restore it when returning.\n\tsave_cmdline(&save_ccline);\n\tdid_save_ccline = TRUE;\n    }\n    if (clear_ccline)\n\tCLEAR_FIELD(ccline);\n\n#ifdef FEAT_EVAL\n    if (firstc == -1)\n    {\n\tfirstc = NUL;\n\tbreak_ctrl_c = TRUE;\n    }\n#endif\n#ifdef FEAT_RIGHTLEFT\n    \/\/ start without Hebrew mapping for a command line\n    if (firstc == ':' || firstc == '=' || firstc == '>')\n\tcmd_hkmap = 0;\n#endif\n\n#ifdef FEAT_SEARCH_EXTRA\n    init_incsearch_state(&is_state);\n#endif\n\n    if (init_ccline(firstc, indent) != OK)\n\tgoto theend;\t\/\/ out of memory\n\n    if (depth == 50)\n    {\n\t\/\/ Somehow got into a loop recursively calling getcmdline(), bail out.\n\temsg(_(e_command_too_recursive));\n\tgoto theend;\n    }\n\n    ExpandInit(&xpc);\n    ccline.xpc = &xpc;\n\n#ifdef FEAT_RIGHTLEFT\n    if (curwin->w_p_rl && *curwin->w_p_rlc == 's'\n\t\t\t\t\t  && (firstc == '\/' || firstc == '?'))\n\tcmdmsg_rl = TRUE;\n    else\n\tcmdmsg_rl = FALSE;\n#endif\n\n    redir_off = TRUE;\t\t\/\/ don't redirect the typed command\n    if (!cmd_silent)\n    {\n\ti = msg_scrolled;\n\tmsg_scrolled = 0;\t\t\/\/ avoid wait_return() message\n\tgotocmdline(TRUE);\n\tmsg_scrolled += i;\n\tredrawcmdprompt();\t\t\/\/ draw prompt or indent\n\tset_cmdspos();\n    }\n    xpc.xp_context = EXPAND_NOTHING;\n    xpc.xp_backslash = XP_BS_NONE;\n#ifndef BACKSLASH_IN_FILENAME\n    xpc.xp_shell = FALSE;\n#endif\n\n#if defined(FEAT_EVAL)\n    if (ccline.input_fn)\n    {\n\txpc.xp_context = ccline.xp_context;\n\txpc.xp_pattern = ccline.cmdbuff;\n\txpc.xp_arg = ccline.xp_arg;\n    }\n#endif\n\n    \/*\n     * Avoid scrolling when called by a recursive do_cmdline(), e.g. when\n     * doing \":@0\" when register 0 doesn't contain a CR.\n     *\/\n    msg_scroll = FALSE;\n\n    State = MODE_CMDLINE;\n\n    if (firstc == '\/' || firstc == '?' || firstc == '@')\n    {\n\t\/\/ Use \":lmap\" mappings for search pattern and input().\n\tif (curbuf->b_p_imsearch == B_IMODE_USE_INSERT)\n\t    b_im_ptr = &curbuf->b_p_iminsert;\n\telse\n\t    b_im_ptr = &curbuf->b_p_imsearch;\n\tif (*b_im_ptr == B_IMODE_LMAP)\n\t    State |= MODE_LANGMAP;\n#ifdef HAVE_INPUT_METHOD\n\tim_set_active(*b_im_ptr == B_IMODE_IM);\n#endif\n    }\n#ifdef HAVE_INPUT_METHOD\n    else if (p_imcmdline)\n\tim_set_active(TRUE);\n#endif\n\n    setmouse();\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n\n    \/\/ When inside an autocommand for writing \"exiting\" may be set and\n    \/\/ terminal mode set to cooked.  Need to set raw mode here then.\n    settmode(TMODE_RAW);\n\n    \/\/ Trigger CmdlineEnter autocommands.\n    cmdline_type = firstc == NUL ? '-' : firstc;\n    trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER);\n#ifdef FEAT_EVAL\n    if (!debug_mode)\n\tmay_trigger_modechanged();\n#endif\n\n    init_history();\n    hiscnt = get_hislen();\t\/\/ set hiscnt to impossible history value\n    histype = hist_char2type(firstc);\n\n#ifdef FEAT_DIGRAPHS\n    do_digraph(-1);\t\t\/\/ init digraph typeahead\n#endif\n\n    \/\/ If something above caused an error, reset the flags, we do want to type\n    \/\/ and execute commands. Display may be messed up a bit.\n    if (did_emsg)\n\tredrawcmd();\n\n#ifdef FEAT_STL_OPT\n    \/\/ Redraw the statusline in case it uses the current mode using the mode()\n    \/\/ function.\n    if (!cmd_silent && msg_scrolled == 0)\n    {\n\tint\tfound_one = FALSE;\n\twin_T\t*wp;\n\n\tFOR_ALL_WINDOWS(wp)\n\t    if (*p_stl != NUL || *wp->w_p_stl != NUL)\n\t    {\n\t\twp->w_redr_status = TRUE;\n\t\tfound_one = TRUE;\n\t    }\n\n\tif (*p_tal != NUL)\n\t{\n\t    redraw_tabline = TRUE;\n\t    found_one = TRUE;\n\t}\n\n\tif (found_one)\n\t    redraw_statuslines();\n    }\n#endif\n\n    did_emsg = FALSE;\n    got_int = FALSE;\n\n    \/*\n     * Collect the command string, handling editing keys.\n     *\/\n    for (;;)\n    {\n\tint trigger_cmdlinechanged = TRUE;\n\tint end_wildmenu;\n\n\tredir_off = TRUE;\t\/\/ Don't redirect the typed command.\n\t\t\t\t\/\/ Repeated, because a \":redir\" inside\n\t\t\t\t\/\/ completion may switch it on.\n#ifdef USE_ON_FLY_SCROLL\n\tdont_scroll = FALSE;\t\/\/ allow scrolling here\n#endif\n\tquit_more = FALSE;\t\/\/ reset after CTRL-D which had a more-prompt\n\n\tdid_emsg = FALSE;\t\/\/ There can't really be a reason why an error\n\t\t\t\t\/\/ that occurs while typing a command should\n\t\t\t\t\/\/ cause the command not to be executed.\n\n\t\/\/ Trigger SafeState if nothing is pending.\n\tmay_trigger_safestate(xpc.xp_numfiles <= 0);\n\n\t\/\/ Get a character.  Ignore K_IGNORE and K_NOP, they should not do\n\t\/\/ anything, such as stop completion.\n\tdo\n\t{\n\t    cursorcmd();\t\t\/\/ set the cursor on the right spot\n\t    c = safe_vgetc();\n\t} while (c == K_IGNORE || c == K_NOP);\n\n\tif (c == K_COMMAND || c == K_SCRIPT_COMMAND)\n\t{\n\t    int\t    clen = ccline.cmdlen;\n\n\t    if (do_cmdkey_command(c, DOCMD_NOWAIT) == OK)\n\t    {\n\t\tif (clen == ccline.cmdlen)\n\t\t    trigger_cmdlinechanged = FALSE;\n\t\tgoto cmdline_changed;\n\t    }\n\t}\n\n\tif (KeyTyped)\n\t{\n\t    some_key_typed = TRUE;\n#ifdef FEAT_RIGHTLEFT\n\t    if (cmd_hkmap)\n\t\tc = hkmap(c);\n\t    if (cmdmsg_rl && !KeyStuffed)\n\t    {\n\t\t\/\/ Invert horizontal movements and operations.  Only when\n\t\t\/\/ typed by the user directly, not when the result of a\n\t\t\/\/ mapping.\n\t\tswitch (c)\n\t\t{\n\t\t    case K_RIGHT:   c = K_LEFT; break;\n\t\t    case K_S_RIGHT: c = K_S_LEFT; break;\n\t\t    case K_C_RIGHT: c = K_C_LEFT; break;\n\t\t    case K_LEFT:    c = K_RIGHT; break;\n\t\t    case K_S_LEFT:  c = K_S_RIGHT; break;\n\t\t    case K_C_LEFT:  c = K_C_RIGHT; break;\n\t\t}\n\t    }\n#endif\n\t}\n\n\t\/*\n\t * Ignore got_int when CTRL-C was typed here.\n\t * Don't ignore it in :global, we really need to break then, e.g., for\n\t * \":g\/pat\/normal \/pat\" (without the <CR>).\n\t * Don't ignore it for the input() function.\n\t *\/\n\tif ((c == Ctrl_C\n#ifdef UNIX\n\t\t|| c == intr_char\n#endif\n\t\t\t\t)\n#if defined(FEAT_EVAL) || defined(FEAT_CRYPT)\n\t\t&& firstc != '@'\n#endif\n#ifdef FEAT_EVAL\n\t\t\/\/ do clear got_int in Ex mode to avoid infinite Ctrl-C loop\n\t\t&& (!break_ctrl_c || exmode_active)\n#endif\n\t\t&& !global_busy)\n\t    got_int = FALSE;\n\n\t\/\/ free old command line when finished moving around in the history\n\t\/\/ list\n\tif (lookfor != NULL\n\t\t&& c != K_S_DOWN && c != K_S_UP\n\t\t&& c != K_DOWN && c != K_UP\n\t\t&& c != K_PAGEDOWN && c != K_PAGEUP\n\t\t&& c != K_KPAGEDOWN && c != K_KPAGEUP\n\t\t&& c != K_LEFT && c != K_RIGHT\n\t\t&& (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N)))\n\t    VIM_CLEAR(lookfor);\n\n\t\/*\n\t * When there are matching completions to select <S-Tab> works like\n\t * CTRL-P (unless 'wc' is <S-Tab>).\n\t *\/\n\tif (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0)\n\t    c = Ctrl_P;\n\n\tif (p_wmnu)\n\t    c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list);\n\n\tif (cmdline_pum_active())\n\t{\n\t    \/\/ Ctrl-Y: Accept the current selection and close the popup menu.\n\t    \/\/ Ctrl-E: cancel the cmdline popup menu and return the original\n\t    \/\/ text.\n\t    if (c == Ctrl_E || c == Ctrl_Y)\n\t    {\n\t\twild_type = (c == Ctrl_E) ? WILD_CANCEL : WILD_APPLY;\n\t\tif (nextwild(&xpc, wild_type, WILD_NO_BEEP,\n\t\t\t\t\t\t\tfirstc != '@') == FAIL)\n\t\t    break;\n\t\tc = Ctrl_E;\n\t    }\n\t}\n\n\t\/\/ The wildmenu is cleared if the pressed key is not used for\n\t\/\/ navigating the wild menu (i.e. the key is not 'wildchar' or\n\t\/\/ 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L).\n\t\/\/ If the popup menu is displayed, then PageDown and PageUp keys are\n\t\/\/ also used to navigate the menu.\n\tend_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm\n\t\t&& c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L);\n\tend_wildmenu = end_wildmenu && (!cmdline_pum_active() ||\n\t\t\t    (c != K_PAGEDOWN && c != K_PAGEUP\n\t\t\t     && c != K_KPAGEDOWN && c != K_KPAGEUP));\n\n\t\/\/ free expanded names when finished walking through matches\n\tif (end_wildmenu)\n\t{\n\t    if (cmdline_pum_active())\n\t\tcmdline_pum_remove();\n\t    if (xpc.xp_numfiles != -1)\n\t\t(void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);\n\t    did_wild_list = FALSE;\n\t    if (!p_wmnu || (c != K_UP && c != K_DOWN))\n\t\txpc.xp_context = EXPAND_NOTHING;\n\t    wim_index = 0;\n\t    wildmenu_cleanup(&ccline);\n\t}\n\n\tif (p_wmnu)\n\t    c = wildmenu_process_key(&ccline, c, &xpc);\n\n\t\/\/ CTRL-\\ CTRL-N goes to Normal mode, CTRL-\\ CTRL-G goes to Insert\n\t\/\/ mode when 'insertmode' is set, CTRL-\\ e prompts for an expression.\n\tif (c == Ctrl_BSL)\n\t{\n\t    res = cmdline_handle_backslash_key(c, &gotesc);\n\t    if (res == CMDLINE_CHANGED)\n\t\tgoto cmdline_changed;\n\t    else if (res == CMDLINE_NOT_CHANGED)\n\t\tgoto cmdline_not_changed;\n\t    else if (res == GOTO_NORMAL_MODE)\n\t\tgoto returncmd;\t\t\/\/ back to cmd mode\n\t    c = Ctrl_BSL;\t\t\/\/ backslash key not processed by\n\t\t\t\t\t\/\/ cmdline_handle_backslash_key()\n\t}\n\n#ifdef FEAT_CMDWIN\n\tif (c == cedit_key || c == K_CMDWIN)\n\t{\n\t    \/\/ TODO: why is ex_normal_busy checked here?\n\t    if ((c == K_CMDWIN || ex_normal_busy == 0) && got_int == FALSE)\n\t    {\n\t\t\/*\n\t\t * Open a window to edit the command line (and history).\n\t\t *\/\n\t\tc = open_cmdwin();\n\t\tsome_key_typed = TRUE;\n\t    }\n\t}\n# ifdef FEAT_DIGRAPHS\n\telse\n# endif\n#endif\n#ifdef FEAT_DIGRAPHS\n\t    c = do_digraph(c);\n#endif\n\n\tif (c == '\\n' || c == '\\r' || c == K_KENTER || (c == ESC\n\t\t\t&& (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL)))\n\t{\n\t    \/\/ In Ex mode a backslash escapes a newline.\n\t    if (exmode_active\n\t\t    && c != ESC\n\t\t    && ccline.cmdpos == ccline.cmdlen\n\t\t    && ccline.cmdpos > 0\n\t\t    && ccline.cmdbuff[ccline.cmdpos - 1] == '\\\\')\n\t    {\n\t\tif (c == K_KENTER)\n\t\t    c = '\\n';\n\t    }\n\t    else\n\t    {\n\t\tgotesc = FALSE;\t\/\/ Might have typed ESC previously, don't\n\t\t\t\t\/\/ truncate the cmdline now.\n\t\tif (ccheck_abbr(c + ABBR_OFF))\n\t\t    goto cmdline_changed;\n\t\tif (!cmd_silent)\n\t\t{\n\t\t    windgoto(msg_row, 0);\n\t\t    out_flush();\n\t\t}\n\t\tbreak;\n\t    }\n\t}\n\n\t\/\/ Completion for 'wildchar' or 'wildcharm' key.\n\tif ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm)\n\t{\n\t    res = cmdline_wildchar_complete(c, firstc != '@', &did_wild_list,\n\t\t    &wim_index, &xpc, &gotesc);\n\t    if (res == CMDLINE_CHANGED)\n\t\tgoto cmdline_changed;\n\t}\n\n\tgotesc = FALSE;\n\n\t\/\/ <S-Tab> goes to last match, in a clumsy way\n\tif (c == K_S_TAB && KeyTyped)\n\t{\n\t    if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK)\n\t    {\n\t\tif (xpc.xp_numfiles > 1\n\t\t    && ((!did_wild_list && (wim_flags[wim_index] & WIM_LIST))\n\t\t\t    || p_wmnu))\n\t\t{\n\t\t    \/\/ Trigger the popup menu when wildoptions=pum\n\t\t    showmatches(&xpc, p_wmnu\n\t\t\t    && ((wim_flags[wim_index] & WIM_LIST) == 0));\n\t\t}\n\t\tif (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK\n\t\t\t&& nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK)\n\t\t    goto cmdline_changed;\n\t    }\n\t}\n\n\tif (c == NUL || c == K_ZERO)\t    \/\/ NUL is stored as NL\n\t    c = NL;\n\n\tdo_abbr = TRUE;\t\t\/\/ default: check for abbreviation\n\n\t\/*\n\t * Big switch for a typed command line character.\n\t *\/\n\tswitch (c)\n\t{\n\tcase K_BS:\n\tcase Ctrl_H:\n\tcase K_DEL:\n\tcase K_KDEL:\n\tcase Ctrl_W:\n\t    res = cmdline_erase_chars(c, indent\n#ifdef FEAT_SEARCH_EXTRA\n\t\t    , &is_state\n#endif\n\t\t    );\n\t    if (res == CMDLINE_NOT_CHANGED)\n\t\tgoto cmdline_not_changed;\n\t    else if (res == GOTO_NORMAL_MODE)\n\t\tgoto returncmd;\t\t\/\/ back to cmd mode\n\t    goto cmdline_changed;\n\n\tcase K_INS:\n\tcase K_KINS:\n\t\tccline.overstrike = !ccline.overstrike;\n#ifdef CURSOR_SHAPE\n\t\tui_cursor_shape();\t\/\/ may show different cursor shape\n#endif\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_HAT:\n\t\tcmdline_toggle_langmap(b_im_ptr);\n\t\tgoto cmdline_not_changed;\n\n\/\/\tcase '@':   only in very old vi\n\tcase Ctrl_U:\n\t\t\/\/ delete all characters left of the cursor\n\t\tj = ccline.cmdpos;\n\t\tccline.cmdlen -= j;\n\t\ti = ccline.cmdpos = 0;\n\t\twhile (i < ccline.cmdlen)\n\t\t    ccline.cmdbuff[i++] = ccline.cmdbuff[j++];\n\t\t\/\/ Truncate at the end, required for multi-byte chars.\n\t\tccline.cmdbuff[ccline.cmdlen] = NUL;\n#ifdef FEAT_SEARCH_EXTRA\n\t\tif (ccline.cmdlen == 0)\n\t\t    is_state.search_start = is_state.save_cursor;\n#endif\n\t\tredrawcmd();\n\t\tgoto cmdline_changed;\n\n#ifdef FEAT_CLIPBOARD\n\tcase Ctrl_Y:\n\t\t\/\/ Copy the modeless selection, if there is one.\n\t\tif (clip_star.state != SELECT_CLEARED)\n\t\t{\n\t\t    if (clip_star.state == SELECT_DONE)\n\t\t\tclip_copy_modeless_selection(TRUE);\n\t\t    goto cmdline_not_changed;\n\t\t}\n\t\tbreak;\n#endif\n\n\tcase ESC:\t\/\/ get here if p_wc != ESC or when ESC typed twice\n\tcase Ctrl_C:\n\t\t\/\/ In exmode it doesn't make sense to return.  Except when\n\t\t\/\/ \":normal\" runs out of characters.\n\t\tif (exmode_active\n\t\t\t       && (ex_normal_busy == 0 || typebuf.tb_len > 0))\n\t\t    goto cmdline_not_changed;\n\n\t\tgotesc = TRUE;\t\t\/\/ will free ccline.cmdbuff after\n\t\t\t\t\t\/\/ putting it in history\n\t\tgoto returncmd;\t\t\/\/ back to cmd mode\n\n\tcase Ctrl_R:\t\t\t\/\/ insert register\n\t\tres = cmdline_insert_reg(&gotesc);\n\t\tif (res == CMDLINE_NOT_CHANGED)\n\t\t    goto cmdline_not_changed;\n\t\telse if (res == GOTO_NORMAL_MODE)\n\t\t    goto returncmd;\n\t\tgoto cmdline_changed;\n\n\tcase Ctrl_D:\n\t\tif (showmatches(&xpc, FALSE) == EXPAND_NOTHING)\n\t\t    break;\t\/\/ Use ^D as normal char instead\n\n\t\tredrawcmd();\n\t\tcontinue;\t\/\/ don't do incremental search now\n\n\tcase K_RIGHT:\n\tcase K_S_RIGHT:\n\tcase K_C_RIGHT:\n\t\tdo\n\t\t{\n\t\t    if (ccline.cmdpos >= ccline.cmdlen)\n\t\t\tbreak;\n\t\t    i = cmdline_charsize(ccline.cmdpos);\n\t\t    if (KeyTyped && ccline.cmdspos + i >= Columns * Rows)\n\t\t\tbreak;\n\t\t    ccline.cmdspos += i;\n\t\t    if (has_mbyte)\n\t\t\tccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff\n\t\t\t\t\t\t\t     + ccline.cmdpos);\n\t\t    else\n\t\t\t++ccline.cmdpos;\n\t\t}\n\t\twhile ((c == K_S_RIGHT || c == K_C_RIGHT\n\t\t\t       || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))\n\t\t\t&& ccline.cmdbuff[ccline.cmdpos] != ' ');\n\t\tif (has_mbyte)\n\t\t    set_cmdspos_cursor();\n\t\tgoto cmdline_not_changed;\n\n\tcase K_LEFT:\n\tcase K_S_LEFT:\n\tcase K_C_LEFT:\n\t\tif (ccline.cmdpos == 0)\n\t\t    goto cmdline_not_changed;\n\t\tdo\n\t\t{\n\t\t    --ccline.cmdpos;\n\t\t    if (has_mbyte)\t\/\/ move to first byte of char\n\t\t\tccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,\n\t\t\t\t\t      ccline.cmdbuff + ccline.cmdpos);\n\t\t    ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);\n\t\t}\n\t\twhile (ccline.cmdpos > 0\n\t\t\t&& (c == K_S_LEFT || c == K_C_LEFT\n\t\t\t       || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))\n\t\t\t&& ccline.cmdbuff[ccline.cmdpos - 1] != ' ');\n\t\tif (has_mbyte)\n\t\t    set_cmdspos_cursor();\n\t\tgoto cmdline_not_changed;\n\n\tcase K_IGNORE:\n\t\t\/\/ Ignore mouse event or open_cmdwin() result.\n\t\tgoto cmdline_not_changed;\n\n#ifdef FEAT_GUI_MSWIN\n\t    \/\/ On MS-Windows ignore <M-F4>, we get it when closing the window\n\t    \/\/ was cancelled.\n\tcase K_F4:\n\t    if (mod_mask == MOD_MASK_ALT)\n\t    {\n\t\tredrawcmd();\t    \/\/ somehow the cmdline is cleared\n\t\tgoto cmdline_not_changed;\n\t    }\n\t    break;\n#endif\n\n\tcase K_MIDDLEDRAG:\n\tcase K_MIDDLERELEASE:\n\t\tgoto cmdline_not_changed;\t\/\/ Ignore mouse\n\n\tcase K_MIDDLEMOUSE:\n# ifdef FEAT_GUI\n\t\t\/\/ When GUI is active, also paste when 'mouse' is empty\n\t\tif (!gui.in_use)\n# endif\n\t\t    if (!mouse_has(MOUSE_COMMAND))\n\t\t\tgoto cmdline_not_changed;   \/\/ Ignore mouse\n# ifdef FEAT_CLIPBOARD\n\t\tif (clip_star.available)\n\t\t    cmdline_paste('*', TRUE, TRUE);\n\t\telse\n# endif\n\t\t    cmdline_paste(0, TRUE, TRUE);\n\t\tredrawcmd();\n\t\tgoto cmdline_changed;\n\n# ifdef FEAT_DND\n\tcase K_DROP:\n\t\tcmdline_paste('~', TRUE, FALSE);\n\t\tredrawcmd();\n\t\tgoto cmdline_changed;\n# endif\n\n\tcase K_LEFTDRAG:\n\tcase K_LEFTRELEASE:\n\tcase K_RIGHTDRAG:\n\tcase K_RIGHTRELEASE:\n\t\t\/\/ Ignore drag and release events when the button-down wasn't\n\t\t\/\/ seen before.\n\t\tif (ignore_drag_release)\n\t\t    goto cmdline_not_changed;\n\t\t\/\/ FALLTHROUGH\n\tcase K_LEFTMOUSE:\n\tcase K_RIGHTMOUSE:\n\t\tcmdline_left_right_mouse(c, &ignore_drag_release);\n\t\tgoto cmdline_not_changed;\n\n\t\/\/ Mouse scroll wheel: ignored here\n\tcase K_MOUSEDOWN:\n\tcase K_MOUSEUP:\n\tcase K_MOUSELEFT:\n\tcase K_MOUSERIGHT:\n\t\/\/ Alternate buttons ignored here\n\tcase K_X1MOUSE:\n\tcase K_X1DRAG:\n\tcase K_X1RELEASE:\n\tcase K_X2MOUSE:\n\tcase K_X2DRAG:\n\tcase K_X2RELEASE:\n\tcase K_MOUSEMOVE:\n\t\tgoto cmdline_not_changed;\n\n#ifdef FEAT_GUI\n\tcase K_LEFTMOUSE_NM:\t\/\/ mousefocus click, ignored\n\tcase K_LEFTRELEASE_NM:\n\t\tgoto cmdline_not_changed;\n\n\tcase K_VER_SCROLLBAR:\n\t\tif (msg_scrolled == 0)\n\t\t{\n\t\t    gui_do_scroll();\n\t\t    redrawcmd();\n\t\t}\n\t\tgoto cmdline_not_changed;\n\n\tcase K_HOR_SCROLLBAR:\n\t\tif (msg_scrolled == 0)\n\t\t{\n\t\t    gui_do_horiz_scroll(scrollbar_value, FALSE);\n\t\t    redrawcmd();\n\t\t}\n\t\tgoto cmdline_not_changed;\n#endif\n#ifdef FEAT_GUI_TABLINE\n\tcase K_TABLINE:\n\tcase K_TABMENU:\n\t\t\/\/ Don't want to change any tabs here.  Make sure the same tab\n\t\t\/\/ is still selected.\n\t\tif (gui_use_tabline())\n\t\t    gui_mch_set_curtab(tabpage_index(curtab));\n\t\tgoto cmdline_not_changed;\n#endif\n\n\tcase K_SELECT:\t    \/\/ end of Select mode mapping - ignore\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_B:\t    \/\/ begin of command line\n\tcase K_HOME:\n\tcase K_KHOME:\n\tcase K_S_HOME:\n\tcase K_C_HOME:\n\t\tccline.cmdpos = 0;\n\t\tset_cmdspos();\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_E:\t    \/\/ end of command line\n\tcase K_END:\n\tcase K_KEND:\n\tcase K_S_END:\n\tcase K_C_END:\n\t\tccline.cmdpos = ccline.cmdlen;\n\t\tset_cmdspos_cursor();\n\t\tgoto cmdline_not_changed;\n\n\tcase Ctrl_A:\t    \/\/ all matches\n\t\tif (cmdline_pum_active())\n\t\t    \/\/ As Ctrl-A completes all the matches, close the popup\n\t\t    \/\/ menu (if present)\n\t\t    cmdline_pum_cleanup(&ccline);\n\n\t\tif (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)\n\t\t    break;\n\t\txpc.xp_context = EXPAND_NOTHING;\n\t\tdid_wild_list = FALSE;\n\t\tgoto cmdline_changed;\n\n\tcase Ctrl_L:\n#ifdef FEAT_SEARCH_EXTRA\n\t\tif (may_add_char_to_search(firstc, &c, &is_state) == OK)\n\t\t    goto cmdline_not_changed;\n#endif\n\n\t\t\/\/ completion: longest common part\n\t\tif (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL)\n\t\t    break;\n\t\tgoto cmdline_changed;\n\n\tcase Ctrl_N:\t    \/\/ next match\n\tcase Ctrl_P:\t    \/\/ previous match\n\t\tif (xpc.xp_numfiles > 0)\n\t\t{\n\t\t    wild_type = (c == Ctrl_P) ? WILD_PREV : WILD_NEXT;\n\t\t    if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)\n\t\t\tbreak;\n\t\t    goto cmdline_not_changed;\n\t\t}\n\t\t\/\/ FALLTHROUGH\n\tcase K_UP:\n\tcase K_DOWN:\n\tcase K_S_UP:\n\tcase K_S_DOWN:\n\tcase K_PAGEUP:\n\tcase K_KPAGEUP:\n\tcase K_PAGEDOWN:\n\tcase K_KPAGEDOWN:\n\t\tif (cmdline_pum_active()\n\t\t\t&& (c == K_PAGEUP || c == K_PAGEDOWN ||\n\t\t\t    c == K_KPAGEUP || c == K_KPAGEDOWN))\n\t\t{\n\t\t    \/\/ If the popup menu is displayed, then PageUp and PageDown\n\t\t    \/\/ are used to scroll the menu.\n\t\t    wild_type = WILD_PAGEUP;\n\t\t    if (c == K_PAGEDOWN || c == K_KPAGEDOWN)\n\t\t\twild_type = WILD_PAGEDOWN;\n\t\t    if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)\n\t\t\tbreak;\n\t\t    goto cmdline_not_changed;\n\t\t}\n\t\telse\n\t\t{\n\t\t    res = cmdline_browse_history(c, firstc, &lookfor, histype,\n\t\t\t    &hiscnt, &xpc);\n\t\t    if (res == CMDLINE_CHANGED)\n\t\t\tgoto cmdline_changed;\n\t\t    else if (res == GOTO_NORMAL_MODE)\n\t\t\tgoto returncmd;\n\t\t}\n\t\tgoto cmdline_not_changed;\n\n#ifdef FEAT_SEARCH_EXTRA\n\tcase Ctrl_G:\t    \/\/ next match\n\tcase Ctrl_T:\t    \/\/ previous match\n\t\tif (may_adjust_incsearch_highlighting(\n\t\t\t\t\t  firstc, count, &is_state, c) == FAIL)\n\t\t    goto cmdline_not_changed;\n\t\tbreak;\n#endif\n\n\tcase Ctrl_V:\n\tcase Ctrl_Q:\n\t\t{\n\t\t    ignore_drag_release = TRUE;\n\t\t    putcmdline('^', TRUE);\n\n\t\t    \/\/ Get next (two) character(s).  Do not change any\n\t\t    \/\/ modifyOtherKeys ESC sequence to a normal key for\n\t\t    \/\/ CTRL-SHIFT-V.\n\t\t    c = get_literal(mod_mask & MOD_MASK_SHIFT);\n\n\t\t    do_abbr = FALSE;\t    \/\/ don't do abbreviation now\n\t\t    extra_char = NUL;\n\t\t    \/\/ may need to remove ^ when composing char was typed\n\t\t    if (enc_utf8 && utf_iscomposing(c) && !cmd_silent)\n\t\t    {\n\t\t\tdraw_cmdline(ccline.cmdpos,\n\t\t\t\t\t\tccline.cmdlen - ccline.cmdpos);\n\t\t\tmsg_putchar(' ');\n\t\t\tcursorcmd();\n\t\t    }\n\t\t}\n\n\t\tbreak;\n\n#ifdef FEAT_DIGRAPHS\n\tcase Ctrl_K:\n\t\tignore_drag_release = TRUE;\n\t\tputcmdline('?', TRUE);\n# ifdef USE_ON_FLY_SCROLL\n\t\tdont_scroll = TRUE;\t    \/\/ disallow scrolling here\n# endif\n\t\tc = get_digraph(TRUE);\n\t\textra_char = NUL;\n\t\tif (c != NUL)\n\t\t    break;\n\n\t\tredrawcmd();\n\t\tgoto cmdline_not_changed;\n#endif \/\/ FEAT_DIGRAPHS\n\n#ifdef FEAT_RIGHTLEFT\n\tcase Ctrl__:\t    \/\/ CTRL-_: switch language mode\n\t\tif (!p_ari)\n\t\t    break;\n\t\tcmd_hkmap = !cmd_hkmap;\n\t\tgoto cmdline_not_changed;\n#endif\n\n\tcase K_PS:\n\t\tbracketed_paste(PASTE_CMDLINE, FALSE, NULL);\n\t\tgoto cmdline_changed;\n\n\tdefault:\n#ifdef UNIX\n\t\tif (c == intr_char)\n\t\t{\n\t\t    gotesc = TRUE;\t\/\/ will free ccline.cmdbuff after\n\t\t\t\t\t\/\/ putting it in history\n\t\t    goto returncmd;\t\/\/ back to Normal mode\n\t\t}\n#endif\n\t\t\/*\n\t\t * Normal character with no special meaning.  Just set mod_mask\n\t\t * to 0x0 so that typing Shift-Space in the GUI doesn't enter\n\t\t * the string <S-Space>.  This should only happen after ^V.\n\t\t *\/\n\t\tif (!IS_SPECIAL(c))\n\t\t    mod_mask = 0x0;\n\t\tbreak;\n\t}\n\t\/*\n\t * End of switch on command line character.\n\t * We come here if we have a normal character.\n\t *\/\n\n\tif (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c))\n\t\t&& (ccheck_abbr(\n\t\t\t\/\/ Add ABBR_OFF for characters above 0x100, this is\n\t\t\t\/\/ what check_abbr() expects.\n\t\t\t\t(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c)\n\t\t    || c == Ctrl_RSB))\n\t    goto cmdline_changed;\n\n\t\/*\n\t * put the character in the command line\n\t *\/\n\tif (IS_SPECIAL(c) || mod_mask != 0)\n\t    put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE);\n\telse\n\t{\n\t    if (has_mbyte)\n\t    {\n\t\tj = (*mb_char2bytes)(c, IObuff);\n\t\tIObuff[j] = NUL;\t\/\/ exclude composing chars\n\t\tput_on_cmdline(IObuff, j, TRUE);\n\t    }\n\t    else\n\t    {\n\t\tIObuff[0] = c;\n\t\tput_on_cmdline(IObuff, 1, TRUE);\n\t    }\n\t}\n\tgoto cmdline_changed;\n\n\/*\n * This part implements incremental searches for \"\/\" and \"?\"\n * Jump to cmdline_not_changed when a character has been read but the command\n * line did not change. Then we only search and redraw if something changed in\n * the past.\n * Jump to cmdline_changed when the command line did change.\n * (Sorry for the goto's, I know it is ugly).\n *\/\ncmdline_not_changed:\n#ifdef FEAT_SEARCH_EXTRA\n\tif (!is_state.incsearch_postponed)\n\t    continue;\n#endif\n\ncmdline_changed:\n#ifdef FEAT_SEARCH_EXTRA\n\t\/\/ If the window changed incremental search state is not valid.\n\tif (is_state.winid != curwin->w_id)\n\t    init_incsearch_state(&is_state);\n#endif\n\tif (trigger_cmdlinechanged)\n\t    \/\/ Trigger CmdlineChanged autocommands.\n\t    trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);\n\n#ifdef FEAT_SEARCH_EXTRA\n\tif (xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL))\n\t    may_do_incsearch_highlighting(firstc, count, &is_state);\n#endif\n\n#ifdef FEAT_RIGHTLEFT\n\tif (cmdmsg_rl\n# ifdef FEAT_ARABIC\n\t\t|| (p_arshape && !p_tbidi\n\t\t\t\t       && cmdline_has_arabic(0, ccline.cmdlen))\n# endif\n\t\t)\n\t    \/\/ Always redraw the whole command line to fix shaping and\n\t    \/\/ right-left typing.  Not efficient, but it works.\n\t    \/\/ Do it only when there are no characters left to read\n\t    \/\/ to avoid useless intermediate redraws.\n\t    if (vpeekc() == NUL)\n\t\tredrawcmd();\n#endif\n    }\n\nreturncmd:\n\n#ifdef FEAT_RIGHTLEFT\n    cmdmsg_rl = FALSE;\n#endif\n\n    ExpandCleanup(&xpc);\n    ccline.xpc = NULL;\n\n#ifdef FEAT_SEARCH_EXTRA\n    finish_incsearch_highlighting(gotesc, &is_state, FALSE);\n#endif\n\n    if (ccline.cmdbuff != NULL)\n    {\n\t\/*\n\t * Put line in history buffer (\":\" and \"=\" only when it was typed).\n\t *\/\n\tif (ccline.cmdlen && firstc != NUL\n\t\t&& (some_key_typed || histype == HIST_SEARCH))\n\t{\n\t    add_to_history(histype, ccline.cmdbuff, TRUE,\n\t\t\t\t       histype == HIST_SEARCH ? firstc : NUL);\n\t    if (firstc == ':')\n\t    {\n\t\tvim_free(new_last_cmdline);\n\t\tnew_last_cmdline = vim_strsave(ccline.cmdbuff);\n\t    }\n\t}\n\n\tif (gotesc)\n\t    abandon_cmdline();\n    }\n\n    \/*\n     * If the screen was shifted up, redraw the whole screen (later).\n     * If the line is too long, clear it, so ruler and shown command do\n     * not get printed in the middle of it.\n     *\/\n    msg_check();\n    msg_scroll = save_msg_scroll;\n    redir_off = FALSE;\n\n    \/\/ When the command line was typed, no need for a wait-return prompt.\n    if (some_key_typed)\n\tneed_wait_return = FALSE;\n\n    \/\/ Trigger CmdlineLeave autocommands.\n    trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);\n\n    State = save_State;\n\n#ifdef FEAT_EVAL\n    if (!debug_mode)\n\tmay_trigger_modechanged();\n#endif\n\n#ifdef HAVE_INPUT_METHOD\n    if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP)\n\tim_save_status(b_im_ptr);\n    im_set_active(FALSE);\n#endif\n    setmouse();\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n    sb_text_end_cmdline();\n\ntheend:\n    {\n\tchar_u *p = ccline.cmdbuff;\n\n\t--depth;\n\tif (did_save_ccline)\n\t    restore_cmdline(&save_ccline);\n\telse\n\t    ccline.cmdbuff = NULL;\n\treturn p;\n    }\n}","target":1,"code_token_length":7577,"total_token_length":7813,"max_tokens_setting":8192}
+{"idx":218775,"func":"MagickExport void XListBrowserWidget(Display *display,XWindows *windows,\n  XWindowInfo *window_info,const char *const *list,const char *action,\n  const char *query,char *reply)\n{\n#define CancelButtonText  \"Cancel\"\n\n  char\n    primary_selection[MaxTextExtent];\n\n  int\n    x;\n\n  int\n    i;\n\n  static MagickStatusType\n    mask = (MagickStatusType) (CWWidth | CWHeight | CWX | CWY);\n\n  Status\n    status;\n\n  unsigned int\n    entries,\n    height,\n    text_width,\n    visible_entries,\n    width;\n\n  size_t\n    delay,\n    state;\n\n  XEvent\n    event;\n\n  XFontStruct\n    *font_info;\n\n  XTextProperty\n    window_name;\n\n  XWidgetInfo\n    action_info,\n    cancel_info,\n    expose_info,\n    list_info,\n    north_info,\n    reply_info,\n    scroll_info,\n    selection_info,\n    slider_info,\n    south_info,\n    text_info;\n\n  XWindowChanges\n    window_changes;\n\n  \/*\n    Count the number of entries in the list.\n  *\/\n  assert(display != (Display *) NULL);\n  assert(windows != (XWindows *) NULL);\n  assert(window_info != (XWindowInfo *) NULL);\n  assert(list != (const char **) NULL);\n  assert(action != (char *) NULL);\n  assert(query != (char *) NULL);\n  assert(reply != (char *) NULL);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",action);\n  XSetCursorState(display,windows,MagickTrue);\n  XCheckRefreshWindows(display,windows);\n  if (list == (const char **) NULL)\n    {\n      XNoticeWidget(display,windows,\"No text to browse:\",(char *) NULL);\n      return;\n    }\n  for (entries=0; ; entries++)\n    if (list[entries] == (char *) NULL)\n      break;\n  \/*\n    Determine Font Browser widget attributes.\n  *\/\n  font_info=window_info->font_info;\n  text_width=WidgetTextWidth(font_info,(char *) query);\n  for (i=0; i < (int) entries; i++)\n    if (WidgetTextWidth(font_info,(char *) list[i]) > text_width)\n      text_width=WidgetTextWidth(font_info,(char *) list[i]);\n  width=WidgetTextWidth(font_info,(char *) action);\n  if (WidgetTextWidth(font_info,CancelButtonText) > width)\n    width=WidgetTextWidth(font_info,CancelButtonText);\n  width+=QuantumMargin;\n  height=(unsigned int) (font_info->ascent+font_info->descent);\n  \/*\n    Position List Browser widget.\n  *\/\n  window_info->width=(unsigned int) MagickMin((int) text_width,(int)\n    MaxTextWidth)+((9*QuantumMargin) >> 1);\n  window_info->min_width=(unsigned int) (MinTextWidth+4*QuantumMargin);\n  if (window_info->width < window_info->min_width)\n    window_info->width=window_info->min_width;\n  window_info->height=(unsigned int)\n    (((81*height) >> 2)+((13*QuantumMargin) >> 1)+4);\n  window_info->min_height=(unsigned int)\n    (((23*height) >> 1)+((13*QuantumMargin) >> 1)+4);\n  if (window_info->height < window_info->min_height)\n    window_info->height=window_info->min_height;\n  XConstrainWindowPosition(display,window_info);\n  \/*\n    Map List Browser widget.\n  *\/\n  (void) CopyMagickString(window_info->name,\"Browse\",MaxTextExtent);\n  status=XStringListToTextProperty(&window_info->name,1,&window_name);\n  if (status != False)\n    {\n      XSetWMName(display,window_info->id,&window_name);\n      XSetWMIconName(display,windows->widget.id,&window_name);\n      (void) XFree((void *) window_name.value);\n    }\n  window_changes.width=(int) window_info->width;\n  window_changes.height=(int) window_info->height;\n  window_changes.x=window_info->x;\n  window_changes.y=window_info->y;\n  (void) XReconfigureWMWindow(display,window_info->id,window_info->screen,mask,\n    &window_changes);\n  (void) XMapRaised(display,window_info->id);\n  window_info->mapped=MagickFalse;\n  \/*\n    Respond to X events.\n  *\/\n  XGetWidgetInfo((char *) NULL,&slider_info);\n  XGetWidgetInfo((char *) NULL,&north_info);\n  XGetWidgetInfo((char *) NULL,&south_info);\n  XGetWidgetInfo((char *) NULL,&expose_info);\n  XGetWidgetInfo((char *) NULL,&selection_info);\n  visible_entries=0;\n  delay=SuspendTime << 2;\n  state=UpdateConfigurationState;\n  do\n  {\n    if (state & UpdateConfigurationState)\n      {\n        int\n          id;\n\n        \/*\n          Initialize button information.\n        *\/\n        XGetWidgetInfo(CancelButtonText,&cancel_info);\n        cancel_info.width=width;\n        cancel_info.height=(unsigned int) ((3*height) >> 1);\n        cancel_info.x=(int)\n          (window_info->width-cancel_info.width-QuantumMargin-2);\n        cancel_info.y=(int)\n          (window_info->height-cancel_info.height-QuantumMargin);\n        XGetWidgetInfo(action,&action_info);\n        action_info.width=width;\n        action_info.height=(unsigned int) ((3*height) >> 1);\n        action_info.x=cancel_info.x-(cancel_info.width+(QuantumMargin >> 1)+\n          (action_info.bevel_width << 1));\n        action_info.y=cancel_info.y;\n        \/*\n          Initialize reply information.\n        *\/\n        XGetWidgetInfo(reply,&reply_info);\n        reply_info.raised=MagickFalse;\n        reply_info.bevel_width--;\n        reply_info.width=window_info->width-((4*QuantumMargin) >> 1);\n        reply_info.height=height << 1;\n        reply_info.x=QuantumMargin;\n        reply_info.y=action_info.y-reply_info.height-QuantumMargin;\n        \/*\n          Initialize scroll information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&scroll_info);\n        scroll_info.bevel_width--;\n        scroll_info.width=height;\n        scroll_info.height=(unsigned int)\n          (reply_info.y-((6*QuantumMargin) >> 1)-height);\n        scroll_info.x=reply_info.x+(reply_info.width-scroll_info.width);\n        scroll_info.y=((5*QuantumMargin) >> 1)+height-reply_info.bevel_width;\n        scroll_info.raised=MagickFalse;\n        scroll_info.trough=MagickTrue;\n        north_info=scroll_info;\n        north_info.raised=MagickTrue;\n        north_info.width-=(north_info.bevel_width << 1);\n        north_info.height=north_info.width-1;\n        north_info.x+=north_info.bevel_width;\n        north_info.y+=north_info.bevel_width;\n        south_info=north_info;\n        south_info.y=scroll_info.y+scroll_info.height-scroll_info.bevel_width-\n          south_info.height;\n        id=slider_info.id;\n        slider_info=north_info;\n        slider_info.id=id;\n        slider_info.width-=2;\n        slider_info.min_y=north_info.y+north_info.height+north_info.bevel_width+\n          slider_info.bevel_width+2;\n        slider_info.height=scroll_info.height-((slider_info.min_y-\n          scroll_info.y+1) << 1)+4;\n        visible_entries=(unsigned int) (scroll_info.height*\n          PerceptibleReciprocal((double) height+(height >> 3)));\n        if (entries > visible_entries)\n          slider_info.height=(visible_entries*slider_info.height)\/entries;\n        slider_info.max_y=south_info.y-south_info.bevel_width-\n          slider_info.bevel_width-2;\n        slider_info.x=scroll_info.x+slider_info.bevel_width+1;\n        slider_info.y=slider_info.min_y;\n        expose_info=scroll_info;\n        expose_info.y=slider_info.y;\n        \/*\n          Initialize list information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&list_info);\n        list_info.raised=MagickFalse;\n        list_info.bevel_width--;\n        list_info.width=(unsigned int)\n          (scroll_info.x-reply_info.x-(QuantumMargin >> 1));\n        list_info.height=scroll_info.height;\n        list_info.x=reply_info.x;\n        list_info.y=scroll_info.y;\n        if (window_info->mapped == MagickFalse)\n          for (i=0; i < (int) entries; i++)\n            if (LocaleCompare(list[i],reply) == 0)\n              {\n                list_info.id=i;\n                slider_info.id=i-(visible_entries >> 1);\n                if (slider_info.id < 0)\n                  slider_info.id=0;\n              }\n        \/*\n          Initialize text information.\n        *\/\n        XGetWidgetInfo(query,&text_info);\n        text_info.width=reply_info.width;\n        text_info.height=height;\n        text_info.x=list_info.x-(QuantumMargin >> 1);\n        text_info.y=QuantumMargin;\n        \/*\n          Initialize selection information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&selection_info);\n        selection_info.center=MagickFalse;\n        selection_info.width=list_info.width;\n        selection_info.height=(unsigned int) ((9*height) >> 3);\n        selection_info.x=list_info.x;\n        state&=(~UpdateConfigurationState);\n      }\n    if (state & RedrawWidgetState)\n      {\n        \/*\n          Redraw List Browser window.\n        *\/\n        XDrawWidgetText(display,window_info,&text_info);\n        XDrawBeveledMatte(display,window_info,&list_info);\n        XDrawBeveledMatte(display,window_info,&scroll_info);\n        XDrawTriangleNorth(display,window_info,&north_info);\n        XDrawBeveledButton(display,window_info,&slider_info);\n        XDrawTriangleSouth(display,window_info,&south_info);\n        XDrawBeveledMatte(display,window_info,&reply_info);\n        XDrawMatteText(display,window_info,&reply_info);\n        XDrawBeveledButton(display,window_info,&action_info);\n        XDrawBeveledButton(display,window_info,&cancel_info);\n        XHighlightWidget(display,window_info,BorderOffset,BorderOffset);\n        selection_info.id=(~0);\n        state|=RedrawActionState;\n        state|=RedrawListState;\n        state&=(~RedrawWidgetState);\n      }\n    if (state & RedrawListState)\n      {\n        \/*\n          Determine slider id and position.\n        *\/\n        if (slider_info.id >= (int) (entries-visible_entries))\n          slider_info.id=(int) (entries-visible_entries);\n        if ((slider_info.id < 0) || (entries <= visible_entries))\n          slider_info.id=0;\n        slider_info.y=slider_info.min_y;\n        if (entries > 0)\n          slider_info.y+=\n            slider_info.id*(slider_info.max_y-slider_info.min_y+1)\/entries;\n        if (slider_info.id != selection_info.id)\n          {\n            \/*\n              Redraw scroll bar and file names.\n            *\/\n            selection_info.id=slider_info.id;\n            selection_info.y=list_info.y+(height >> 3)+2;\n            for (i=0; i < (int) visible_entries; i++)\n            {\n              selection_info.raised=(slider_info.id+i) != list_info.id ?\n                MagickTrue : MagickFalse;\n              selection_info.text=(char *) NULL;\n              if ((slider_info.id+i) < (int) entries)\n                selection_info.text=(char *) list[slider_info.id+i];\n              XDrawWidgetText(display,window_info,&selection_info);\n              selection_info.y+=(int) selection_info.height;\n            }\n            \/*\n              Update slider.\n            *\/\n            if (slider_info.y > expose_info.y)\n              {\n                expose_info.height=(unsigned int) slider_info.y-expose_info.y;\n                expose_info.y=slider_info.y-expose_info.height-\n                  slider_info.bevel_width-1;\n              }\n            else\n              {\n                expose_info.height=(unsigned int) expose_info.y-slider_info.y;\n                expose_info.y=slider_info.y+slider_info.height+\n                  slider_info.bevel_width+1;\n              }\n            XDrawTriangleNorth(display,window_info,&north_info);\n            XDrawMatte(display,window_info,&expose_info);\n            XDrawBeveledButton(display,window_info,&slider_info);\n            XDrawTriangleSouth(display,window_info,&south_info);\n            expose_info.y=slider_info.y;\n          }\n        state&=(~RedrawListState);\n      }\n    \/*\n      Wait for next event.\n    *\/\n    if (north_info.raised && south_info.raised)\n      (void) XIfEvent(display,&event,XScreenEvent,(char *) windows);\n    else\n      {\n        \/*\n          Brief delay before advancing scroll bar.\n        *\/\n        XDelay(display,delay);\n        delay=SuspendTime;\n        (void) XCheckIfEvent(display,&event,XScreenEvent,(char *) windows);\n        if (north_info.raised == MagickFalse)\n          if (slider_info.id > 0)\n            {\n              \/*\n                Move slider up.\n              *\/\n              slider_info.id--;\n              state|=RedrawListState;\n            }\n        if (south_info.raised == MagickFalse)\n          if (slider_info.id < (int) entries)\n            {\n              \/*\n                Move slider down.\n              *\/\n              slider_info.id++;\n              state|=RedrawListState;\n            }\n        if (event.type != ButtonRelease)\n          continue;\n      }\n    switch (event.type)\n    {\n      case ButtonPress:\n      {\n        if (MatteIsActive(slider_info,event.xbutton))\n          {\n            \/*\n              Track slider.\n            *\/\n            slider_info.active=MagickTrue;\n            break;\n          }\n        if (MatteIsActive(north_info,event.xbutton))\n          if (slider_info.id > 0)\n            {\n              \/*\n                Move slider up.\n              *\/\n              north_info.raised=MagickFalse;\n              slider_info.id--;\n              state|=RedrawListState;\n              break;\n            }\n        if (MatteIsActive(south_info,event.xbutton))\n          if (slider_info.id < (int) entries)\n            {\n              \/*\n                Move slider down.\n              *\/\n              south_info.raised=MagickFalse;\n              slider_info.id++;\n              state|=RedrawListState;\n              break;\n            }\n        if (MatteIsActive(scroll_info,event.xbutton))\n          {\n            \/*\n              Move slider.\n            *\/\n            if (event.xbutton.y < slider_info.y)\n              slider_info.id-=(visible_entries-1);\n            else\n              slider_info.id+=(visible_entries-1);\n            state|=RedrawListState;\n            break;\n          }\n        if (MatteIsActive(list_info,event.xbutton))\n          {\n            int\n              id;\n\n            \/*\n              User pressed list matte.\n            *\/\n            id=slider_info.id+(event.xbutton.y-(list_info.y+(height >> 1))+1)\/\n              selection_info.height;\n            if (id >= (int) entries)\n              break;\n            (void) CopyMagickString(reply_info.text,list[id],MaxTextExtent);\n            reply_info.highlight=MagickFalse;\n            reply_info.marker=reply_info.text;\n            reply_info.cursor=reply_info.text+Extent(reply_info.text);\n            XDrawMatteText(display,window_info,&reply_info);\n            selection_info.id=(~0);\n            if (id == list_info.id)\n              {\n                action_info.raised=MagickFalse;\n                XDrawBeveledButton(display,window_info,&action_info);\n                state|=ExitState;\n              }\n            list_info.id=id;\n            state|=RedrawListState;\n            break;\n          }\n        if (MatteIsActive(action_info,event.xbutton))\n          {\n            \/*\n              User pressed action button.\n            *\/\n            action_info.raised=MagickFalse;\n            XDrawBeveledButton(display,window_info,&action_info);\n            break;\n          }\n        if (MatteIsActive(cancel_info,event.xbutton))\n          {\n            \/*\n              User pressed Cancel button.\n            *\/\n            cancel_info.raised=MagickFalse;\n            XDrawBeveledButton(display,window_info,&cancel_info);\n            break;\n          }\n        if (MatteIsActive(reply_info,event.xbutton) == MagickFalse)\n          break;\n        if (event.xbutton.button != Button2)\n          {\n            static Time\n              click_time;\n\n            \/*\n              Move text cursor to position of button press.\n            *\/\n            x=event.xbutton.x-reply_info.x-(QuantumMargin >> 2);\n            for (i=1; i <= Extent(reply_info.marker); i++)\n              if (XTextWidth(font_info,reply_info.marker,i) > x)\n                break;\n            reply_info.cursor=reply_info.marker+i-1;\n            if (event.xbutton.time > (click_time+DoubleClick))\n              reply_info.highlight=MagickFalse;\n            else\n              {\n                \/*\n                  Become the XA_PRIMARY selection owner.\n                *\/\n                (void) CopyMagickString(primary_selection,reply_info.text,\n                  MaxTextExtent);\n                (void) XSetSelectionOwner(display,XA_PRIMARY,window_info->id,\n                  event.xbutton.time);\n                reply_info.highlight=XGetSelectionOwner(display,XA_PRIMARY) ==\n                  window_info->id ? MagickTrue : MagickFalse;\n              }\n            XDrawMatteText(display,window_info,&reply_info);\n            click_time=event.xbutton.time;\n            break;\n          }\n        \/*\n          Request primary selection.\n        *\/\n        (void) XConvertSelection(display,XA_PRIMARY,XA_STRING,XA_STRING,\n          window_info->id,event.xbutton.time);\n        break;\n      }\n      case ButtonRelease:\n      {\n        if (window_info->mapped == MagickFalse)\n          break;\n        if (north_info.raised == MagickFalse)\n          {\n            \/*\n              User released up button.\n            *\/\n            delay=SuspendTime << 2;\n            north_info.raised=MagickTrue;\n            XDrawTriangleNorth(display,window_info,&north_info);\n          }\n        if (south_info.raised == MagickFalse)\n          {\n            \/*\n              User released down button.\n            *\/\n            delay=SuspendTime << 2;\n            south_info.raised=MagickTrue;\n            XDrawTriangleSouth(display,window_info,&south_info);\n          }\n        if (slider_info.active)\n          {\n            \/*\n              Stop tracking slider.\n            *\/\n            slider_info.active=MagickFalse;\n            break;\n          }\n        if (action_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == window_info->id)\n              {\n                if (MatteIsActive(action_info,event.xbutton))\n                  {\n                    if (*reply_info.text == '\\0')\n                      (void) XBell(display,0);\n                    else\n                      state|=ExitState;\n                  }\n              }\n            action_info.raised=MagickTrue;\n            XDrawBeveledButton(display,window_info,&action_info);\n          }\n        if (cancel_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == window_info->id)\n              if (MatteIsActive(cancel_info,event.xbutton))\n                {\n                  *reply_info.text='\\0';\n                  state|=ExitState;\n                }\n            cancel_info.raised=MagickTrue;\n            XDrawBeveledButton(display,window_info,&cancel_info);\n          }\n        if (MatteIsActive(reply_info,event.xbutton) == MagickFalse)\n          break;\n        break;\n      }\n      case ClientMessage:\n      {\n        \/*\n          If client window delete message, exit.\n        *\/\n        if (event.xclient.message_type != windows->wm_protocols)\n          break;\n        if (*event.xclient.data.l == (int) windows->wm_take_focus)\n          {\n            (void) XSetInputFocus(display,event.xclient.window,RevertToParent,\n              (Time) event.xclient.data.l[1]);\n            break;\n          }\n        if (*event.xclient.data.l != (int) windows->wm_delete_window)\n          break;\n        if (event.xclient.window == window_info->id)\n          {\n            *reply_info.text='\\0';\n            state|=ExitState;\n            break;\n          }\n        break;\n      }\n      case ConfigureNotify:\n      {\n        \/*\n          Update widget configuration.\n        *\/\n        if (event.xconfigure.window != window_info->id)\n          break;\n        if ((event.xconfigure.width == (int) window_info->width) &&\n            (event.xconfigure.height == (int) window_info->height))\n          break;\n        window_info->width=(unsigned int)\n          MagickMax(event.xconfigure.width,(int) window_info->min_width);\n        window_info->height=(unsigned int)\n          MagickMax(event.xconfigure.height,(int) window_info->min_height);\n        state|=UpdateConfigurationState;\n        break;\n      }\n      case EnterNotify:\n      {\n        if (event.xcrossing.window != window_info->id)\n          break;\n        state&=(~InactiveWidgetState);\n        break;\n      }\n      case Expose:\n      {\n        if (event.xexpose.window != window_info->id)\n          break;\n        if (event.xexpose.count != 0)\n          break;\n        state|=RedrawWidgetState;\n        break;\n      }\n      case KeyPress:\n      {\n        static char\n          command[MaxTextExtent];\n\n        static int\n          length;\n\n        static KeySym\n          key_symbol;\n\n        \/*\n          Respond to a user key press.\n        *\/\n        if (event.xkey.window != window_info->id)\n          break;\n        length=XLookupString((XKeyEvent *) &event.xkey,command,\n          (int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);\n        *(command+length)='\\0';\n        if (AreaIsActive(scroll_info,event.xkey))\n          {\n            \/*\n              Move slider.\n            *\/\n            switch ((int) key_symbol)\n            {\n              case XK_Home:\n              case XK_KP_Home:\n              {\n                slider_info.id=0;\n                break;\n              }\n              case XK_Up:\n              case XK_KP_Up:\n              {\n                slider_info.id--;\n                break;\n              }\n              case XK_Down:\n              case XK_KP_Down:\n              {\n                slider_info.id++;\n                break;\n              }\n              case XK_Prior:\n              case XK_KP_Prior:\n              {\n                slider_info.id-=visible_entries;\n                break;\n              }\n              case XK_Next:\n              case XK_KP_Next:\n              {\n                slider_info.id+=visible_entries;\n                break;\n              }\n              case XK_End:\n              case XK_KP_End:\n              {\n                slider_info.id=(int) entries;\n                break;\n              }\n            }\n            state|=RedrawListState;\n            break;\n          }\n        if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))\n          {\n            \/*\n              Read new entry.\n            *\/\n            if (*reply_info.text == '\\0')\n              break;\n            action_info.raised=MagickFalse;\n            XDrawBeveledButton(display,window_info,&action_info);\n            state|=ExitState;\n            break;\n          }\n        if (key_symbol == XK_Control_L)\n          {\n            state|=ControlState;\n            break;\n          }\n        if (state & ControlState)\n          switch ((int) key_symbol)\n          {\n            case XK_u:\n            case XK_U:\n            {\n              \/*\n                Erase the entire line of text.\n              *\/\n              *reply_info.text='\\0';\n              reply_info.cursor=reply_info.text;\n              reply_info.marker=reply_info.text;\n              reply_info.highlight=MagickFalse;\n              break;\n            }\n            default:\n              break;\n          }\n        XEditText(display,&reply_info,key_symbol,command,state);\n        XDrawMatteText(display,window_info,&reply_info);\n        break;\n      }\n      case KeyRelease:\n      {\n        static char\n          command[MaxTextExtent];\n\n        static KeySym\n          key_symbol;\n\n        \/*\n          Respond to a user key release.\n        *\/\n        if (event.xkey.window != window_info->id)\n          break;\n        (void) XLookupString((XKeyEvent *) &event.xkey,command,\n          (int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);\n        if (key_symbol == XK_Control_L)\n          state&=(~ControlState);\n        break;\n      }\n      case LeaveNotify:\n      {\n        if (event.xcrossing.window != window_info->id)\n          break;\n        state|=InactiveWidgetState;\n        break;\n      }\n      case MapNotify:\n      {\n        mask&=(~CWX);\n        mask&=(~CWY);\n        break;\n      }\n      case MotionNotify:\n      {\n        \/*\n          Discard pending button motion events.\n        *\/\n        while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ;\n        if (slider_info.active)\n          {\n            \/*\n              Move slider matte.\n            *\/\n            slider_info.y=event.xmotion.y-\n              ((slider_info.height+slider_info.bevel_width) >> 1)+1;\n            if (slider_info.y < slider_info.min_y)\n              slider_info.y=slider_info.min_y;\n            if (slider_info.y > slider_info.max_y)\n              slider_info.y=slider_info.max_y;\n            slider_info.id=0;\n            if (slider_info.y != slider_info.min_y)\n              slider_info.id=(int) ((entries*(slider_info.y-\n                slider_info.min_y+1))\/(slider_info.max_y-slider_info.min_y+1));\n            state|=RedrawListState;\n            break;\n          }\n        if (state & InactiveWidgetState)\n          break;\n        if (action_info.raised == MatteIsActive(action_info,event.xmotion))\n          {\n            \/*\n              Action button status changed.\n            *\/\n            action_info.raised=action_info.raised == MagickFalse ?\n              MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,window_info,&action_info);\n            break;\n          }\n        if (cancel_info.raised == MatteIsActive(cancel_info,event.xmotion))\n          {\n            \/*\n              Cancel button status changed.\n            *\/\n            cancel_info.raised=cancel_info.raised == MagickFalse ?\n              MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,window_info,&cancel_info);\n            break;\n          }\n        break;\n      }\n      case SelectionClear:\n      {\n        reply_info.highlight=MagickFalse;\n        XDrawMatteText(display,window_info,&reply_info);\n        break;\n      }\n      case SelectionNotify:\n      {\n        Atom\n          type;\n\n        int\n          format;\n\n        unsigned char\n          *data;\n\n        unsigned long\n          after,\n          length;\n\n        \/*\n          Obtain response from primary selection.\n        *\/\n        if (event.xselection.property == (Atom) None)\n          break;\n        status=XGetWindowProperty(display,\n          event.xselection.requestor,event.xselection.property,0L,2047L,\n          MagickTrue,XA_STRING,&type,&format,&length,&after,&data);\n        if ((status != Success) || (type != XA_STRING) || (format == 32) ||\n            (length == 0))\n          break;\n        if ((Extent(reply_info.text)+length) >= (MaxTextExtent-1))\n          (void) XBell(display,0);\n        else\n          {\n            \/*\n              Insert primary selection in reply text.\n            *\/\n            *(data+length)='\\0';\n            XEditText(display,&reply_info,(KeySym) XK_Insert,(char *) data,\n              state);\n            XDrawMatteText(display,window_info,&reply_info);\n            state|=RedrawActionState;\n          }\n        (void) XFree((void *) data);\n        break;\n      }\n      case SelectionRequest:\n      {\n        XSelectionEvent\n          notify;\n\n        XSelectionRequestEvent\n          *request;\n\n        if (reply_info.highlight == MagickFalse)\n          break;\n        \/*\n          Set primary selection.\n        *\/\n        request=(&(event.xselectionrequest));\n        (void) XChangeProperty(request->display,request->requestor,\n          request->property,request->target,8,PropModeReplace,\n          (unsigned char *) primary_selection,Extent(primary_selection));\n        notify.type=SelectionNotify;\n        notify.send_event=MagickTrue;\n        notify.display=request->display;\n        notify.requestor=request->requestor;\n        notify.selection=request->selection;\n        notify.target=request->target;\n        notify.time=request->time;\n        if (request->property == None)\n          notify.property=request->target;\n        else\n          notify.property=request->property;\n        (void) XSendEvent(request->display,request->requestor,False,NoEventMask,\n          (XEvent *) ¬ify);\n      }\n      default:\n        break;\n    }\n  } while ((state & ExitState) == 0);\n  XSetCursorState(display,windows,MagickFalse);\n  (void) XWithdrawWindow(display,window_info->id,window_info->screen);\n  XCheckRefreshWindows(display,windows);\n}","target":0,"code_token_length":6146,"total_token_length":6382,"max_tokens_setting":8192}
+{"idx":208673,"func":"handle_spawn (PortalFlatpak         *object,\n              GDBusMethodInvocation *invocation,\n              GUnixFDList           *fd_list,\n              const gchar           *arg_cwd_path,\n              const gchar *const    *arg_argv,\n              GVariant              *arg_fds,\n              GVariant              *arg_envs,\n              guint                  arg_flags,\n              GVariant              *arg_options)\n{\n  g_autoptr(GError) error = NULL;\n  ChildSetupData child_setup_data = { NULL };\n  GPid pid;\n  PidData *pid_data;\n  InstanceIdReadData *instance_id_read_data = NULL;\n  gsize i, j, n_fds, n_envs;\n  const gint *fds = NULL;\n  gint fds_len = 0;\n  g_autofree FdMapEntry *fd_map = NULL;\n  gchar **env;\n  gint32 max_fd;\n  GKeyFile *app_info;\n  g_autoptr(GPtrArray) flatpak_argv = g_ptr_array_new_with_free_func (g_free);\n  g_autofree char *app_id = NULL;\n  g_autofree char *branch = NULL;\n  g_autofree char *arch = NULL;\n  g_autofree char *app_commit = NULL;\n  g_autofree char *runtime_ref = NULL;\n  g_auto(GStrv) runtime_parts = NULL;\n  g_autofree char *runtime_commit = NULL;\n  g_autofree char *instance_path = NULL;\n  g_auto(GStrv) extra_args = NULL;\n  g_auto(GStrv) shares = NULL;\n  g_auto(GStrv) sockets = NULL;\n  g_auto(GStrv) devices = NULL;\n  g_auto(GStrv) sandbox_expose = NULL;\n  g_auto(GStrv) sandbox_expose_ro = NULL;\n  g_autoptr(GVariant) sandbox_expose_fd = NULL;\n  g_autoptr(GVariant) sandbox_expose_fd_ro = NULL;\n  g_autoptr(GOutputStream) instance_id_out_stream = NULL;\n  guint sandbox_flags = 0;\n  gboolean sandboxed;\n  gboolean expose_pids;\n  gboolean share_pids;\n  gboolean notify_start;\n  gboolean devel;\n  g_autoptr(GString) env_string = g_string_new (\"\");\n\n  child_setup_data.instance_id_fd = -1;\n  child_setup_data.env_fd = -1;\n\n  if (fd_list != NULL)\n    fds = g_unix_fd_list_peek_fds (fd_list, &fds_len);\n\n  app_info = g_object_get_data (G_OBJECT (invocation), \"app-info\");\n  g_assert (app_info != NULL);\n\n  app_id = g_key_file_get_string (app_info,\n                                  FLATPAK_METADATA_GROUP_APPLICATION,\n                                  FLATPAK_METADATA_KEY_NAME, NULL);\n  g_assert (app_id != NULL);\n\n  g_debug (\"spawn() called from app: '%s'\", app_id);\n  if (*app_id == 0)\n    {\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                             G_DBUS_ERROR_INVALID_ARGS,\n                                             \"org.freedesktop.portal.Flatpak.Spawn only works in a flatpak\");\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  if (*arg_cwd_path == 0)\n    arg_cwd_path = NULL;\n\n  if (arg_argv == NULL || *arg_argv == NULL)\n    {\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                             G_DBUS_ERROR_INVALID_ARGS,\n                                             \"No command given\");\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  if ((arg_flags & ~FLATPAK_SPAWN_FLAGS_ALL) != 0)\n    {\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,\n                                             \"Unsupported flags enabled: 0x%x\", arg_flags & ~FLATPAK_SPAWN_FLAGS_ALL);\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  runtime_ref = g_key_file_get_string (app_info,\n                                       FLATPAK_METADATA_GROUP_APPLICATION,\n                                       FLATPAK_METADATA_KEY_RUNTIME, NULL);\n  if (runtime_ref == NULL)\n    {\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,\n                                             \"No runtime found\");\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  runtime_parts = g_strsplit (runtime_ref, \"\/\", -1);\n\n  branch = g_key_file_get_string (app_info,\n                                  FLATPAK_METADATA_GROUP_INSTANCE,\n                                  FLATPAK_METADATA_KEY_BRANCH, NULL);\n  instance_path = g_key_file_get_string (app_info,\n                                         FLATPAK_METADATA_GROUP_INSTANCE,\n                                         FLATPAK_METADATA_KEY_INSTANCE_PATH, NULL);\n  arch = g_key_file_get_string (app_info,\n                                FLATPAK_METADATA_GROUP_INSTANCE,\n                                FLATPAK_METADATA_KEY_ARCH, NULL);\n  extra_args = g_key_file_get_string_list (app_info,\n                                           FLATPAK_METADATA_GROUP_INSTANCE,\n                                           FLATPAK_METADATA_KEY_EXTRA_ARGS, NULL, NULL);\n  app_commit = g_key_file_get_string (app_info,\n                                      FLATPAK_METADATA_GROUP_INSTANCE,\n                                      FLATPAK_METADATA_KEY_APP_COMMIT, NULL);\n  runtime_commit = g_key_file_get_string (app_info,\n                                          FLATPAK_METADATA_GROUP_INSTANCE,\n                                          FLATPAK_METADATA_KEY_RUNTIME_COMMIT, NULL);\n  shares = g_key_file_get_string_list (app_info, FLATPAK_METADATA_GROUP_CONTEXT,\n                                       FLATPAK_METADATA_KEY_SHARED, NULL, NULL);\n  sockets = g_key_file_get_string_list (app_info, FLATPAK_METADATA_GROUP_CONTEXT,\n                                       FLATPAK_METADATA_KEY_SOCKETS, NULL, NULL);\n  devices = g_key_file_get_string_list (app_info, FLATPAK_METADATA_GROUP_CONTEXT,\n                                        FLATPAK_METADATA_KEY_DEVICES, NULL, NULL);\n\n  devel = g_key_file_get_boolean (app_info, FLATPAK_METADATA_GROUP_INSTANCE,\n                                  FLATPAK_METADATA_KEY_DEVEL, NULL);\n\n  g_variant_lookup (arg_options, \"sandbox-expose\", \"^as\", &sandbox_expose);\n  g_variant_lookup (arg_options, \"sandbox-expose-ro\", \"^as\", &sandbox_expose_ro);\n  g_variant_lookup (arg_options, \"sandbox-flags\", \"u\", &sandbox_flags);\n  sandbox_expose_fd = g_variant_lookup_value (arg_options, \"sandbox-expose-fd\", G_VARIANT_TYPE (\"ah\"));\n  sandbox_expose_fd_ro = g_variant_lookup_value (arg_options, \"sandbox-expose-fd-ro\", G_VARIANT_TYPE (\"ah\"));\n\n  if ((sandbox_flags & ~FLATPAK_SPAWN_SANDBOX_FLAGS_ALL) != 0)\n    {\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,\n                                             \"Unsupported sandbox flags enabled: 0x%x\", arg_flags & ~FLATPAK_SPAWN_SANDBOX_FLAGS_ALL);\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  if (instance_path == NULL &&\n      ((sandbox_expose != NULL && sandbox_expose[0] != NULL) ||\n       (sandbox_expose_ro != NULL && sandbox_expose_ro[0] != NULL)))\n    {\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                             G_DBUS_ERROR_INVALID_ARGS,\n                                             \"Invalid sandbox expose, caller has no instance path\");\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  for (i = 0; sandbox_expose != NULL && sandbox_expose[i] != NULL; i++)\n    {\n      const char *expose = sandbox_expose[i];\n\n      g_debug (\"exposing %s\", expose);\n      if (!is_valid_expose (expose, &error))\n        {\n          g_dbus_method_invocation_return_gerror (invocation, error);\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n    }\n\n  for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++)\n    {\n      const char *expose = sandbox_expose_ro[i];\n      g_debug (\"exposing %s\", expose);\n      if (!is_valid_expose (expose, &error))\n        {\n          g_dbus_method_invocation_return_gerror (invocation, error);\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n    }\n\n  g_debug (\"Running spawn command %s\", arg_argv[0]);\n\n  n_fds = 0;\n  if (fds != NULL)\n    n_fds = g_variant_n_children (arg_fds);\n  fd_map = g_new0 (FdMapEntry, n_fds);\n\n  child_setup_data.fd_map = fd_map;\n  child_setup_data.fd_map_len = n_fds;\n\n  max_fd = -1;\n  for (i = 0; i < n_fds; i++)\n    {\n      gint32 handle, dest_fd;\n      int handle_fd;\n\n      g_variant_get_child (arg_fds, i, \"{uh}\", &dest_fd, &handle);\n\n      if (handle >= fds_len || handle < 0)\n        {\n          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                 G_DBUS_ERROR_INVALID_ARGS,\n                                                 \"No file descriptor for handle %d\",\n                                                 handle);\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      handle_fd = fds[handle];\n\n      fd_map[i].to = dest_fd;\n      fd_map[i].from = handle_fd;\n      fd_map[i].final = fd_map[i].to;\n\n      \/* If stdin\/out\/err is a tty we try to set it as the controlling\n         tty for the app, this way we can use this to run in a terminal. *\/\n      if ((dest_fd == 0 || dest_fd == 1 || dest_fd == 2) &&\n          !child_setup_data.set_tty &&\n          isatty (handle_fd))\n        {\n          child_setup_data.set_tty = TRUE;\n          child_setup_data.tty = handle_fd;\n        }\n\n      max_fd = MAX (max_fd, fd_map[i].to);\n      max_fd = MAX (max_fd, fd_map[i].from);\n    }\n\n  \/* We make a second pass over the fds to find if any \"to\" fd index\n     overlaps an already in use fd (i.e. one in the \"from\" category\n     that are allocated randomly). If a fd overlaps \"to\" fd then its\n     a caller issue and not our fault, so we ignore that. *\/\n  for (i = 0; i < n_fds; i++)\n    {\n      int to_fd = fd_map[i].to;\n      gboolean conflict = FALSE;\n\n      \/* At this point we're fine with using \"from\" values for this\n         value (because we handle to==from in the code), or values\n         that are before \"i\" in the fd_map (because those will be\n         closed at this point when dup:ing). However, we can't\n         reuse a fd that is in \"from\" for j > i. *\/\n      for (j = i + 1; j < n_fds; j++)\n        {\n          int from_fd = fd_map[j].from;\n          if (from_fd == to_fd)\n            {\n              conflict = TRUE;\n              break;\n            }\n        }\n\n      if (conflict)\n        fd_map[i].to = ++max_fd;\n    }\n\n  \/* TODO: Ideally we should let `flatpak run` inherit the portal's\n   * environment, in case e.g. a LD_LIBRARY_PATH is needed to be able\n   * to run `flatpak run`, but tell it to start from a blank environment\n   * when running the Flatpak app; but this isn't currently possible, so\n   * for now we preserve existing behaviour. *\/\n  if (arg_flags & FLATPAK_SPAWN_FLAGS_CLEAR_ENV)\n    {\n      char *empty[] = { NULL };\n      env = g_strdupv (empty);\n    }\n  else\n    env = g_get_environ ();\n\n  \/* Let the environment variables given by the caller override the ones\n   * from extra_args. Don't add them to @env, because they are controlled\n   * by our caller, which might be trying to use them to inject code into\n   * flatpak(1); add them to the environment block instead.\n   *\n   * We don't use --env= here, so that if the values are something that\n   * should not be exposed to other uids, they can remain confidential. *\/\n  n_envs = g_variant_n_children (arg_envs);\n  for (i = 0; i < n_envs; i++)\n    {\n      const char *var = NULL;\n      const char *val = NULL;\n      g_variant_get_child (arg_envs, i, \"{&s&s}\", &var, &val);\n\n      if (var[0] == '\\0')\n        {\n          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                 G_DBUS_ERROR_INVALID_ARGS,\n                                                 \"Environment variable cannot have empty name\");\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      if (strchr (var, '=') != NULL)\n        {\n          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                 G_DBUS_ERROR_INVALID_ARGS,\n                                                 \"Environment variable name cannot contain '='\");\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      g_string_append (env_string, var);\n      g_string_append_c (env_string, '=');\n      g_string_append (env_string, val);\n      g_string_append_c (env_string, '\\0');\n    }\n\n  g_ptr_array_add (flatpak_argv, g_strdup (\"flatpak\"));\n  g_ptr_array_add (flatpak_argv, g_strdup (\"run\"));\n\n  sandboxed = (arg_flags & FLATPAK_SPAWN_FLAGS_SANDBOX) != 0;\n\n  if (sandboxed)\n    {\n      g_ptr_array_add (flatpak_argv, g_strdup (\"--sandbox\"));\n\n      if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_SHARE_DISPLAY)\n        {\n          if (sockets != NULL && g_strv_contains ((const char * const *) sockets, \"wayland\"))\n            g_ptr_array_add (flatpak_argv, g_strdup (\"--socket=wayland\"));\n          if (sockets != NULL && g_strv_contains ((const char * const *) sockets, \"fallback-x11\"))\n            g_ptr_array_add (flatpak_argv, g_strdup (\"--socket=fallback-x11\"));\n          if (sockets != NULL && g_strv_contains ((const char * const *) sockets, \"x11\"))\n            g_ptr_array_add (flatpak_argv, g_strdup (\"--socket=x11\"));\n          if (shares != NULL && g_strv_contains ((const char * const *) shares, \"ipc\") &&\n              sockets != NULL && (g_strv_contains ((const char * const *) sockets, \"fallback-x11\") ||\n                                  g_strv_contains ((const char * const *) sockets, \"x11\")))\n            g_ptr_array_add (flatpak_argv, g_strdup (\"--share=ipc\"));\n        }\n      if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_SHARE_SOUND)\n        {\n          if (sockets != NULL && g_strv_contains ((const char * const *) sockets, \"pulseaudio\"))\n            g_ptr_array_add (flatpak_argv, g_strdup (\"--socket=pulseaudio\"));\n        }\n      if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_SHARE_GPU)\n        {\n          if (devices != NULL &&\n              (g_strv_contains ((const char * const *) devices, \"dri\") ||\n               g_strv_contains ((const char * const *) devices, \"all\")))\n            g_ptr_array_add (flatpak_argv, g_strdup (\"--device=dri\"));\n        }\n      if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_ALLOW_DBUS)\n        g_ptr_array_add (flatpak_argv, g_strdup (\"--session-bus\"));\n      if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_ALLOW_A11Y)\n        g_ptr_array_add (flatpak_argv, g_strdup (\"--a11y-bus\"));\n    }\n  else\n    {\n      for (i = 0; extra_args != NULL && extra_args[i] != NULL; i++)\n        {\n          if (g_str_has_prefix (extra_args[i], \"--env=\"))\n            {\n              const char *var_val = extra_args[i] + strlen (\"--env=\");\n\n              if (var_val[0] == '\\0' || var_val[0] == '=')\n                {\n                  g_warning (\"Environment variable in extra-args has empty name\");\n                  continue;\n                }\n\n              if (strchr (var_val, '=') == NULL)\n                {\n                  g_warning (\"Environment variable in extra-args has no value\");\n                  continue;\n                }\n\n              g_string_append (env_string, var_val);\n              g_string_append_c (env_string, '\\0');\n            }\n          else\n            {\n              g_ptr_array_add (flatpak_argv, g_strdup (extra_args[i]));\n            }\n        }\n    }\n\n  if (env_string->len > 0)\n    {\n      g_auto(GLnxTmpfile) env_tmpf  = { 0, };\n\n      if (!flatpak_buffer_to_sealed_memfd_or_tmpfile (&env_tmpf, \"environ\",\n                                                      env_string->str,\n                                                      env_string->len, &error))\n        {\n          g_dbus_method_invocation_return_gerror (invocation, error);\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      child_setup_data.env_fd = glnx_steal_fd (&env_tmpf.fd);\n      g_ptr_array_add (flatpak_argv,\n                       g_strdup_printf (\"--env-fd=%d\",\n                                        child_setup_data.env_fd));\n    }\n\n  expose_pids = (arg_flags & FLATPAK_SPAWN_FLAGS_EXPOSE_PIDS) != 0;\n  share_pids = (arg_flags & FLATPAK_SPAWN_FLAGS_SHARE_PIDS) != 0;\n\n  if (expose_pids || share_pids)\n    {\n      g_autofree char *instance_id = NULL;\n      int sender_pid1 = 0;\n\n      if (!(supports & FLATPAK_SPAWN_SUPPORT_FLAGS_EXPOSE_PIDS))\n        {\n          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                 G_DBUS_ERROR_NOT_SUPPORTED,\n                                                 \"Expose pids not supported with setuid bwrap\");\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      instance_id = g_key_file_get_string (app_info,\n                                           FLATPAK_METADATA_GROUP_INSTANCE,\n                                           FLATPAK_METADATA_KEY_INSTANCE_ID, NULL);\n\n      if (instance_id)\n        {\n          g_autoptr(FlatpakInstance) instance = flatpak_instance_new_for_id (instance_id);\n          sender_pid1 = flatpak_instance_get_child_pid (instance);\n        }\n\n      if (sender_pid1 == 0)\n        {\n          g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                 G_DBUS_ERROR_INVALID_ARGS,\n                                                 \"Could not find requesting pid\");\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--parent-pid=%d\", sender_pid1));\n\n      if (share_pids)\n        g_ptr_array_add (flatpak_argv, g_strdup (\"--parent-share-pids\"));\n      else\n        g_ptr_array_add (flatpak_argv, g_strdup (\"--parent-expose-pids\"));\n    }\n\n  notify_start = (arg_flags & FLATPAK_SPAWN_FLAGS_NOTIFY_START) != 0;\n  if (notify_start)\n    {\n      int pipe_fds[2];\n      if (pipe (pipe_fds) == -1)\n        {\n          int errsv = errno;\n          g_dbus_method_invocation_return_error (invocation, G_IO_ERROR,\n                                                 g_io_error_from_errno (errsv),\n                                                 \"Failed to create instance ID pipe: %s\",\n                                                 g_strerror (errsv));\n          return G_DBUS_METHOD_INVOCATION_HANDLED;\n        }\n\n      GInputStream *in_stream = G_INPUT_STREAM (g_unix_input_stream_new (pipe_fds[0], TRUE));\n      \/* This is saved to ensure the portal's end gets closed after the exec. *\/\n      instance_id_out_stream = G_OUTPUT_STREAM (g_unix_output_stream_new (pipe_fds[1], TRUE));\n\n      instance_id_read_data = g_new0 (InstanceIdReadData, 1);\n\n      g_input_stream_read_async (in_stream, instance_id_read_data->buffer,\n                                 INSTANCE_ID_BUFFER_SIZE - 1, G_PRIORITY_DEFAULT, NULL,\n                                 instance_id_read_finish, instance_id_read_data);\n\n      g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--instance-id-fd=%d\", pipe_fds[1]));\n      child_setup_data.instance_id_fd = pipe_fds[1];\n    }\n\n  if (devel)\n    g_ptr_array_add (flatpak_argv, g_strdup (\"--devel\"));\n\n  \/* Inherit launcher network access from launcher, unless\n     NO_NETWORK set. *\/\n  if (shares != NULL && g_strv_contains ((const char * const *) shares, \"network\") &&\n      !(arg_flags & FLATPAK_SPAWN_FLAGS_NO_NETWORK))\n    g_ptr_array_add (flatpak_argv, g_strdup (\"--share=network\"));\n  else\n    g_ptr_array_add (flatpak_argv, g_strdup (\"--unshare=network\"));\n\n\n  if (instance_path)\n    {\n      for (i = 0; sandbox_expose != NULL && sandbox_expose[i] != NULL; i++)\n        g_ptr_array_add (flatpak_argv,\n                         filesystem_sandbox_arg (instance_path, sandbox_expose[i], FALSE));\n      for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++)\n        g_ptr_array_add (flatpak_argv,\n                         filesystem_sandbox_arg (instance_path, sandbox_expose_ro[i], TRUE));\n    }\n\n  for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++)\n    {\n      const char *expose = sandbox_expose_ro[i];\n      g_debug (\"exposing %s\", expose);\n    }\n\n  if (sandbox_expose_fd != NULL)\n    {\n      gsize len = g_variant_n_children (sandbox_expose_fd);\n      for (i = 0; i < len; i++)\n        {\n          gint32 handle;\n          g_variant_get_child (sandbox_expose_fd, i, \"h\", &handle);\n          if (handle >= 0 && handle < fds_len)\n            {\n              int handle_fd = fds[handle];\n              g_autofree char *path = NULL;\n              gboolean writable = FALSE;\n\n              path = get_path_for_fd (handle_fd, &writable, &error);\n\n              if (path)\n                {\n                  g_ptr_array_add (flatpak_argv, filesystem_arg (path, !writable));\n                }\n              else\n                {\n                  g_debug (\"unable to get path for sandbox-exposed fd %d, ignoring: %s\",\n                           handle_fd, error->message);\n                  g_clear_error (&error);\n                }\n            }\n          else\n            {\n              g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                     G_DBUS_ERROR_INVALID_ARGS,\n                                                     \"No file descriptor for handle %d\",\n                                                     handle);\n              return G_DBUS_METHOD_INVOCATION_HANDLED;\n            }\n        }\n    }\n\n  if (sandbox_expose_fd_ro != NULL)\n    {\n      gsize len = g_variant_n_children (sandbox_expose_fd_ro);\n      for (i = 0; i < len; i++)\n        {\n          gint32 handle;\n          g_variant_get_child (sandbox_expose_fd_ro, i, \"h\", &handle);\n          if (handle >= 0 && handle < fds_len)\n            {\n              int handle_fd = fds[handle];\n              g_autofree char *path = NULL;\n              gboolean writable = FALSE;\n\n              path = get_path_for_fd (handle_fd, &writable, &error);\n\n              if (path)\n                {\n                  g_ptr_array_add (flatpak_argv, filesystem_arg (path, TRUE));\n                }\n              else\n                {\n                  g_debug (\"unable to get path for sandbox-exposed fd %d, ignoring: %s\",\n                           handle_fd, error->message);\n                  g_clear_error (&error);\n                }\n            }\n          else\n            {\n              g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,\n                                                     G_DBUS_ERROR_INVALID_ARGS,\n                                                     \"No file descriptor for handle %d\",\n                                                     handle);\n              return G_DBUS_METHOD_INVOCATION_HANDLED;\n            }\n        }\n    }\n\n  g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--runtime=%s\", runtime_parts[1]));\n  g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--runtime-version=%s\", runtime_parts[3]));\n\n  if ((arg_flags & FLATPAK_SPAWN_FLAGS_LATEST_VERSION) == 0)\n    {\n      if (app_commit)\n        g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--commit=%s\", app_commit));\n      if (runtime_commit)\n        g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--runtime-commit=%s\", runtime_commit));\n    }\n\n  if (arg_cwd_path != NULL)\n    g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--cwd=%s\", arg_cwd_path));\n\n  if (arg_argv[0][0] != 0)\n    g_ptr_array_add (flatpak_argv, g_strdup_printf (\"--command=%s\", arg_argv[0]));\n\n  g_ptr_array_add (flatpak_argv, g_strdup_printf (\"%s\/%s\/%s\", app_id, arch ? arch : \"\", branch ? branch : \"\"));\n  for (i = 1; arg_argv[i] != NULL; i++)\n    g_ptr_array_add (flatpak_argv, g_strdup (arg_argv[i]));\n  g_ptr_array_add (flatpak_argv, NULL);\n\n  if (opt_verbose)\n    {\n      g_autoptr(GString) cmd = g_string_new (\"\");\n\n      for (i = 0; flatpak_argv->pdata[i] != NULL; i++)\n        {\n          if (i > 0)\n            g_string_append (cmd, \" \");\n          g_string_append (cmd, flatpak_argv->pdata[i]);\n        }\n\n      g_debug (\"Starting: %s\\n\", cmd->str);\n    }\n\n  \/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_fds_workaround *\/\n  if (!g_spawn_async_with_pipes (NULL,\n                                 (char **) flatpak_argv->pdata,\n                                 env,\n                                 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_LEAVE_DESCRIPTORS_OPEN,\n                                 child_setup_func, &child_setup_data,\n                                 &pid,\n                                 NULL,\n                                 NULL,\n                                 NULL,\n                                 &error))\n    {\n      gint code = G_DBUS_ERROR_FAILED;\n      if (g_error_matches (error, G_SPAWN_ERROR, G_SPAWN_ERROR_ACCES))\n        code = G_DBUS_ERROR_ACCESS_DENIED;\n      else if (g_error_matches (error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT))\n        code = G_DBUS_ERROR_FILE_NOT_FOUND;\n      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, code,\n                                             \"Failed to start command: %s\",\n                                             error->message);\n      return G_DBUS_METHOD_INVOCATION_HANDLED;\n    }\n\n  if (instance_id_read_data)\n    instance_id_read_data->pid = pid;\n\n  pid_data = g_new0 (PidData, 1);\n  pid_data->pid = pid;\n  pid_data->client = g_strdup (g_dbus_method_invocation_get_sender (invocation));\n  pid_data->watch_bus = (arg_flags & FLATPAK_SPAWN_FLAGS_WATCH_BUS) != 0;\n  pid_data->expose_or_share_pids = (expose_pids || share_pids);\n  pid_data->child_watch = g_child_watch_add_full (G_PRIORITY_DEFAULT,\n                                                  pid,\n                                                  child_watch_died,\n                                                  pid_data,\n                                                  NULL);\n\n  g_debug (\"Client Pid is %d\", pid_data->pid);\n\n  g_hash_table_replace (client_pid_data_hash, GUINT_TO_POINTER (pid_data->pid),\n                        pid_data);\n\n  portal_flatpak_complete_spawn (object, invocation, NULL, pid);\n  return G_DBUS_METHOD_INVOCATION_HANDLED;\n}","target":1,"code_token_length":6117,"total_token_length":6353,"max_tokens_setting":8192}
+{"idx":509470,"func":"static int lex_one_token(YYSTYPE *yylval, THD *thd)\n{\n  uchar UNINIT_VAR(c);\n  bool comment_closed;\n  int\ttokval, result_state;\n  uint length;\n  enum my_lex_states state;\n  Lex_input_stream *lip= & thd->m_parser_state->m_lip;\n  LEX *lex= thd->lex;\n  CHARSET_INFO *const cs= thd->charset();\n  const uchar *const state_map= cs->state_map;\n  const uchar *const ident_map= cs->ident_map;\n\n  lip->yylval=yylval;\t\t\t\/\/ The global state\n\n  lip->start_token();\n  state=lip->next_state;\n  lip->next_state=MY_LEX_OPERATOR_OR_IDENT;\n  for (;;)\n  {\n    switch (state) {\n    case MY_LEX_OPERATOR_OR_IDENT:\t\/\/ Next is operator or keyword\n    case MY_LEX_START:\t\t\t\/\/ Start of token\n      \/\/ Skip starting whitespace\n      while(state_map[c= lip->yyPeek()] == MY_LEX_SKIP)\n      {\n\tif (c == '\\n')\n\t  lip->yylineno++;\n\n        lip->yySkip();\n      }\n\n      \/* Start of real token *\/\n      lip->restart_token();\n      c= lip->yyGet();\n      state= (enum my_lex_states) state_map[c];\n      break;\n    case MY_LEX_ESCAPE:\n      if (!lip->eof() && lip->yyGet() == 'N')\n      {\t\t\t\t\t\/\/ Allow \\N as shortcut for NULL\n\tyylval->lex_str.str=(char*) \"\\\\N\";\n\tyylval->lex_str.length=2;\n\treturn NULL_SYM;\n      }\n      \/* Fall through *\/\n    case MY_LEX_CHAR:\t\t\t\/\/ Unknown or single char token\n    case MY_LEX_SKIP:\t\t\t\/\/ This should not happen\n      if (c != ')')\n\tlip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n      return((int) c);\n\n    case MY_LEX_MINUS_OR_COMMENT:\n      if (lip->yyPeek() == '-' &&\n          (my_isspace(cs,lip->yyPeekn(1)) ||\n           my_iscntrl(cs,lip->yyPeekn(1))))\n      {\n        state=MY_LEX_COMMENT;\n        break;\n      }\n      lip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n      return((int) c);\n\n    case MY_LEX_PLACEHOLDER:\n      \/*\n        Check for a placeholder: it should not precede a possible identifier\n        because of binlogging: when a placeholder is replaced with\n        its value in a query for the binlog, the query must stay\n        grammatically correct.\n      *\/\n      lip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n      if (lip->stmt_prepare_mode && !ident_map[(uchar) lip->yyPeek()])\n        return(PARAM_MARKER);\n      return((int) c);\n\n    case MY_LEX_COMMA:\n      lip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n      \/*\n        Warning:\n        This is a work around, to make the \"remember_name\" rule in\n        sql\/sql_yacc.yy work properly.\n        The problem is that, when parsing \"select expr1, expr2\",\n        the code generated by bison executes the *pre* action\n        remember_name (see select_item) *before* actually parsing the\n        first token of expr2.\n      *\/\n      lip->restart_token();\n      return((int) c);\n\n    case MY_LEX_IDENT_OR_NCHAR:\n    {\n      uint sep;\n      if (lip->yyPeek() != '\\'')\n      {\n\tstate= MY_LEX_IDENT;\n\tbreak;\n      }\n      \/* Found N'string' *\/\n      lip->yySkip();                         \/\/ Skip '\n      if (lip->get_text(&yylval->lex_str, (sep= lip->yyGetLast()), 2, 1))\n      {\n\tstate= MY_LEX_CHAR;             \/\/ Read char by char\n\tbreak;\n      }\n\n      lip->body_utf8_append(lip->m_cpp_text_start);\n      lip->body_utf8_append_escape(thd, &yylval->lex_str,\n                                   national_charset_info,\n                                   lip->m_cpp_text_end, sep);\n\n      lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1;\n      return(NCHAR_STRING);\n    }\n    case MY_LEX_IDENT_OR_HEX:\n      if (lip->yyPeek() == '\\'')\n      {\t\t\t\t\t\/\/ Found x'hex-number'\n\tstate= MY_LEX_HEX_NUMBER;\n\tbreak;\n      }\n      \/* fall through *\/\n    case MY_LEX_IDENT_OR_BIN:\n      if (lip->yyPeek() == '\\'')\n      {                                 \/\/ Found b'bin-number'\n        state= MY_LEX_BIN_NUMBER;\n        break;\n      }\n      \/* fall through *\/\n    case MY_LEX_IDENT:\n      const char *start;\n#if defined(USE_MB) && defined(USE_MB_IDENT)\n      if (use_mb(cs))\n      {\n\tresult_state= IDENT_QUOTED;\n        int char_length= my_charlen(cs, lip->get_ptr() - 1,\n                                        lip->get_end_of_query());\n        if (char_length <= 0)\n        {\n          state= MY_LEX_CHAR;\n          continue;\n        }\n        lip->skip_binary(char_length - 1);\n\n        while (ident_map[c=lip->yyGet()])\n        {\n          char_length= my_charlen(cs, lip->get_ptr() - 1,\n                                      lip->get_end_of_query());\n          if (char_length <= 0)\n            break;\n          lip->skip_binary(char_length - 1);\n        }\n      }\n      else\n#endif\n      {\n        for (result_state= c;\n             ident_map[(uchar) (c= lip->yyGet())];\n             result_state|= c)\n          ;\n        \/* If there were non-ASCII characters, mark that we must convert *\/\n        result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;\n      }\n      length= lip->yyLength();\n      start= lip->get_ptr();\n      if (lip->ignore_space)\n      {\n        \/*\n          If we find a space then this can't be an identifier. We notice this\n          below by checking start != lex->ptr.\n        *\/\n        for (; state_map[(uchar) c] == MY_LEX_SKIP ; c= lip->yyGet())\n        {\n          if (c == '\\n')\n            lip->yylineno++;\n        }\n      }\n      if (start == lip->get_ptr() && c == '.' &&\n          ident_map[(uchar) lip->yyPeek()])\n\tlip->next_state=MY_LEX_IDENT_SEP;\n      else\n      {\t\t\t\t\t\/\/ '(' must follow directly if function\n        lip->yyUnget();\n\tif ((tokval = find_keyword(lip, length, c == '(')))\n\t{\n\t  lip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n\t  return(tokval);\t\t\/\/ Was keyword\n\t}\n        lip->yySkip();                  \/\/ next state does a unget\n      }\n      yylval->lex_str=get_token(lip, 0, length);\n\n      \/*\n         Note: \"SELECT _bla AS 'alias'\"\n         _bla should be considered as a IDENT if charset haven't been found.\n         So we don't use MYF(MY_WME) with get_charset_by_csname to avoid\n         producing an error.\n      *\/\n\n      if (yylval->lex_str.str[0] == '_')\n      {\n        CHARSET_INFO *cs= get_charset_by_csname(yylval->lex_str.str + 1,\n                                                MY_CS_PRIMARY, MYF(0));\n        if (cs)\n        {\n          yylval->charset= cs;\n          lip->m_underscore_cs= cs;\n\n          lip->body_utf8_append(lip->m_cpp_text_start,\n                                lip->get_cpp_tok_start() + length);\n          return(UNDERSCORE_CHARSET);\n        }\n      }\n\n      lip->body_utf8_append(lip->m_cpp_text_start);\n\n      lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end);\n\n      return(result_state);\t\t\t\/\/ IDENT or IDENT_QUOTED\n\n    case MY_LEX_IDENT_SEP:                  \/\/ Found ident and now '.'\n      yylval->lex_str.str= (char*) lip->get_ptr();\n      yylval->lex_str.length= 1;\n      c= lip->yyGet();                          \/\/ should be '.'\n      lip->next_state= MY_LEX_IDENT_START;      \/\/ Next is ident (not keyword)\n      if (!ident_map[(uchar) lip->yyPeek()])    \/\/ Probably ` or \"\n\tlip->next_state= MY_LEX_START;\n      return((int) c);\n\n    case MY_LEX_NUMBER_IDENT:\t\t\/\/ number or ident which num-start\n      if (lip->yyGetLast() == '0')\n      {\n        c= lip->yyGet();\n        if (c == 'x')\n        {\n          while (my_isxdigit(cs,(c = lip->yyGet()))) ;\n          if ((lip->yyLength() >= 3) && !ident_map[c])\n          {\n            \/* skip '0x' *\/\n            yylval->lex_str=get_token(lip, 2, lip->yyLength()-2);\n            return (HEX_NUM);\n          }\n          lip->yyUnget();\n          state= MY_LEX_IDENT_START;\n          break;\n        }\n        else if (c == 'b')\n        {\n          while ((c= lip->yyGet()) == '0' || c == '1')\n            ;\n          if ((lip->yyLength() >= 3) && !ident_map[c])\n          {\n            \/* Skip '0b' *\/\n            yylval->lex_str= get_token(lip, 2, lip->yyLength()-2);\n            return (BIN_NUM);\n          }\n          lip->yyUnget();\n          state= MY_LEX_IDENT_START;\n          break;\n        }\n        lip->yyUnget();\n      }\n\n      while (my_isdigit(cs, (c = lip->yyGet()))) ;\n      if (!ident_map[c])\n      {\t\t\t\t\t\/\/ Can't be identifier\n\tstate=MY_LEX_INT_OR_REAL;\n\tbreak;\n      }\n      if (c == 'e' || c == 'E')\n      {\n\t\/\/ The following test is written this way to allow numbers of type 1e1\n        if (my_isdigit(cs,lip->yyPeek()) ||\n            (c=(lip->yyGet())) == '+' || c == '-')\n\t{\t\t\t\t\/\/ Allow 1E+10\n          if (my_isdigit(cs,lip->yyPeek()))     \/\/ Number must have digit after sign\n\t  {\n            lip->yySkip();\n            while (my_isdigit(cs,lip->yyGet())) ;\n            yylval->lex_str=get_token(lip, 0, lip->yyLength());\n\t    return(FLOAT_NUM);\n\t  }\n\t}\n        lip->yyUnget();\n      }\n      \/\/ fall through\n    case MY_LEX_IDENT_START:\t\t\t\/\/ We come here after '.'\n      result_state= IDENT;\n#if defined(USE_MB) && defined(USE_MB_IDENT)\n      if (use_mb(cs))\n      {\n\tresult_state= IDENT_QUOTED;\n        while (ident_map[c=lip->yyGet()])\n        {\n          int char_length= my_charlen(cs, lip->get_ptr() - 1,\n                                          lip->get_end_of_query());\n          if (char_length <= 0)\n            break;\n          lip->skip_binary(char_length - 1);\n        }\n      }\n      else\n#endif\n      {\n        for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c)\n          ;\n        \/* If there were non-ASCII characters, mark that we must convert *\/\n        result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;\n      }\n      if (c == '.' && ident_map[(uchar) lip->yyPeek()])\n\tlip->next_state=MY_LEX_IDENT_SEP;\/\/ Next is '.'\n\n      yylval->lex_str= get_token(lip, 0, lip->yyLength());\n\n      lip->body_utf8_append(lip->m_cpp_text_start);\n\n      lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end);\n\n      return(result_state);\n\n    case MY_LEX_USER_VARIABLE_DELIMITER:\t\/\/ Found quote char\n    {\n      uint double_quotes= 0;\n      char quote_char= c;                       \/\/ Used char\n      while ((c=lip->yyGet()))\n      {\n        int var_length= my_charlen(cs, lip->get_ptr() - 1,\n                                       lip->get_end_of_query());\n        if (var_length == 1)\n\t{\n\t  if (c == quote_char)\n\t  {\n            if (lip->yyPeek() != quote_char)\n\t      break;\n            c=lip->yyGet();\n\t    double_quotes++;\n\t    continue;\n\t  }\n\t}\n#ifdef USE_MB\n        else if (var_length > 1)\n        {\n          lip->skip_binary(var_length - 1);\n        }\n#endif\n      }\n      if (double_quotes)\n\tyylval->lex_str=get_quoted_token(lip, 1,\n                                         lip->yyLength() - double_quotes -1,\n\t\t\t\t\t quote_char);\n      else\n        yylval->lex_str=get_token(lip, 1, lip->yyLength() -1);\n      if (c == quote_char)\n        lip->yySkip();                  \/\/ Skip end `\n      lip->next_state= MY_LEX_START;\n\n      lip->body_utf8_append(lip->m_cpp_text_start);\n\n      lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end);\n\n      return(IDENT_QUOTED);\n    }\n    case MY_LEX_INT_OR_REAL:\t\t\/\/ Complete int or incomplete real\n      if (c != '.')\n      {\t\t\t\t\t\/\/ Found complete integer number.\n        yylval->lex_str=get_token(lip, 0, lip->yyLength());\n\treturn int_token(yylval->lex_str.str, (uint) yylval->lex_str.length);\n      }\n      \/\/ fall through\n    case MY_LEX_REAL:\t\t\t\/\/ Incomplete real number\n      while (my_isdigit(cs,c = lip->yyGet())) ;\n\n      if (c == 'e' || c == 'E')\n      {\n        c = lip->yyGet();\n\tif (c == '-' || c == '+')\n          c = lip->yyGet();                     \/\/ Skip sign\n\tif (!my_isdigit(cs,c))\n\t{\t\t\t\t\/\/ No digit after sign\n\t  state= MY_LEX_CHAR;\n\t  break;\n\t}\n        while (my_isdigit(cs,lip->yyGet())) ;\n        yylval->lex_str=get_token(lip, 0, lip->yyLength());\n\treturn(FLOAT_NUM);\n      }\n      yylval->lex_str=get_token(lip, 0, lip->yyLength());\n      return(DECIMAL_NUM);\n\n    case MY_LEX_HEX_NUMBER:\t\t\/\/ Found x'hexstring'\n      lip->yySkip();                    \/\/ Accept opening '\n      while (my_isxdigit(cs, (c= lip->yyGet()))) ;\n      if (c != '\\'')\n        return(ABORT_SYM);              \/\/ Illegal hex constant\n      lip->yySkip();                    \/\/ Accept closing '\n      length= lip->yyLength();          \/\/ Length of hexnum+3\n      if ((length % 2) == 0)\n        return(ABORT_SYM);              \/\/ odd number of hex digits\n      yylval->lex_str=get_token(lip,\n                                2,          \/\/ skip x'\n                                length-3);  \/\/ don't count x' and last '\n      return HEX_STRING;\n\n    case MY_LEX_BIN_NUMBER:           \/\/ Found b'bin-string'\n      lip->yySkip();                  \/\/ Accept opening '\n      while ((c= lip->yyGet()) == '0' || c == '1')\n        ;\n      if (c != '\\'')\n        return(ABORT_SYM);            \/\/ Illegal hex constant\n      lip->yySkip();                  \/\/ Accept closing '\n      length= lip->yyLength();        \/\/ Length of bin-num + 3\n      yylval->lex_str= get_token(lip,\n                                 2,         \/\/ skip b'\n                                 length-3); \/\/ don't count b' and last '\n      return (BIN_NUM);\n\n    case MY_LEX_CMP_OP:\t\t\t\/\/ Incomplete comparison operator\n      lip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n      if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||\n          state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)\n      {\n        lip->yySkip();\n        if ((tokval= find_keyword(lip, 2, 0)))\n          return(tokval);\n        lip->yyUnget();\n      }\n      return(c);\n\n    case MY_LEX_LONG_CMP_OP:\t\t\/\/ Incomplete comparison operator\n      lip->next_state= MY_LEX_START;\n      if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||\n          state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)\n      {\n        lip->yySkip();\n        if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP)\n        {\n          lip->yySkip();\n          if ((tokval= find_keyword(lip, 3, 0)))\n            return(tokval);\n          lip->yyUnget();\n        }\n        if ((tokval= find_keyword(lip, 2, 0)))\n          return(tokval);\n        lip->yyUnget();\n      }\n      return(c);\n\n    case MY_LEX_BOOL:\n      if (c != lip->yyPeek())\n      {\n\tstate=MY_LEX_CHAR;\n\tbreak;\n      }\n      lip->yySkip();\n      tokval = find_keyword(lip,2,0);\t\/\/ Is a bool operator\n      lip->next_state= MY_LEX_START;\t\/\/ Allow signed numbers\n      return(tokval);\n\n    case MY_LEX_STRING_OR_DELIMITER:\n      if (thd->variables.sql_mode & MODE_ANSI_QUOTES)\n      {\n\tstate= MY_LEX_USER_VARIABLE_DELIMITER;\n\tbreak;\n      }\n      \/* \" used for strings *\/\n      \/* fall through *\/\n    case MY_LEX_STRING:\t\t\t\/\/ Incomplete text string\n    {\n      uint sep;\n      if (lip->get_text(&yylval->lex_str, (sep= lip->yyGetLast()), 1, 1))\n      {\n\tstate= MY_LEX_CHAR;\t\t\/\/ Read char by char\n\tbreak;\n      }\n      CHARSET_INFO *strcs= lip->m_underscore_cs ? lip->m_underscore_cs : cs;\n      lip->body_utf8_append(lip->m_cpp_text_start);\n\n      lip->body_utf8_append_escape(thd, &yylval->lex_str, strcs,\n                                   lip->m_cpp_text_end, sep);\n      lip->m_underscore_cs= NULL;\n\n      lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1;\n      return(TEXT_STRING);\n    }\n    case MY_LEX_COMMENT:\t\t\t\/\/  Comment\n      lex->select_lex.options|= OPTION_FOUND_COMMENT;\n      while ((c = lip->yyGet()) != '\\n' && c) ;\n      lip->yyUnget();                   \/\/ Safety against eof\n      state = MY_LEX_START;\t\t\/\/ Try again\n      break;\n    case MY_LEX_LONG_COMMENT:\t\t\/* Long C comment? *\/\n      if (lip->yyPeek() != '*')\n      {\n\tstate=MY_LEX_CHAR;\t\t\/\/ Probable division\n\tbreak;\n      }\n      lex->select_lex.options|= OPTION_FOUND_COMMENT;\n      \/* Reject '\/' '*', since we might need to turn off the echo *\/\n      lip->yyUnget();\n\n      lip->save_in_comment_state();\n\n      if (lip->yyPeekn(2) == '!' ||\n          (lip->yyPeekn(2) == 'M' && lip->yyPeekn(3) == '!'))\n      {\n        bool maria_comment_syntax= lip->yyPeekn(2) == 'M';\n        lip->in_comment= DISCARD_COMMENT;\n        \/* Accept '\/' '*' '!', but do not keep this marker. *\/\n        lip->set_echo(FALSE);\n        lip->yySkipn(maria_comment_syntax ? 4 : 3);\n\n        \/*\n          The special comment format is very strict:\n          '\/' '*' '!', followed by an optional 'M' and exactly\n          1-2 digits (major), 2 digits (minor), then 2 digits (dot).\n          32302  -> 3.23.02\n          50032  -> 5.0.32\n          50114  -> 5.1.14\n          100000 -> 10.0.0\n        *\/\n        if (  my_isdigit(cs, lip->yyPeekn(0))\n           && my_isdigit(cs, lip->yyPeekn(1))\n           && my_isdigit(cs, lip->yyPeekn(2))\n           && my_isdigit(cs, lip->yyPeekn(3))\n           && my_isdigit(cs, lip->yyPeekn(4))\n           )\n        {\n          ulong version;\n          uint length= 5;\n          char *end_ptr= (char*) lip->get_ptr()+length;\n          int error;\n          if (my_isdigit(cs, lip->yyPeekn(5)))\n          {\n            end_ptr++;                          \/\/ 6 digit number\n            length++;\n          }\n\n          version= (ulong) my_strtoll10(lip->get_ptr(), &end_ptr, &error);\n\n          \/*\n            MySQL-5.7 has new features and might have new SQL syntax that\n            MariaDB-10.0 does not understand. Ignore all versioned comments\n            with MySQL versions in the range 50700-999999, but\n            do not ignore MariaDB specific comments for the same versions.\n          *\/ \n          if (version <= MYSQL_VERSION_ID &&\n              (version < 50700 || version > 99999 || maria_comment_syntax))\n          {\n            \/* Accept 'M' 'm' 'm' 'd' 'd' *\/\n            lip->yySkipn(length);\n            \/* Expand the content of the special comment as real code *\/\n            lip->set_echo(TRUE);\n            state=MY_LEX_START;\n            break;  \/* Do not treat contents as a comment.  *\/\n          }\n          else\n          {\n#ifdef WITH_WSREP\n\t    if (WSREP(thd) && version == 99997 && thd->wsrep_exec_mode == LOCAL_STATE)\n\t    {\n\t      WSREP_DEBUG(\"consistency check: %s\", thd->query());\n\t      thd->wsrep_consistency_check= CONSISTENCY_CHECK_DECLARED;\n\t      lip->yySkipn(5);\n\t      lip->set_echo(TRUE);\n\t      state=MY_LEX_START;\n\t      break;  \/* Do not treat contents as a comment.  *\/\n\t    }\n#endif \/* WITH_WSREP *\/\n            \/*\n              Patch and skip the conditional comment to avoid it\n              being propagated infinitely (eg. to a slave).\n            *\/\n            char *pcom= lip->yyUnput(' ');\n            comment_closed= ! consume_comment(lip, 1);\n            if (! comment_closed)\n            {\n              *pcom= '!';\n            }\n            \/* version allowed to have one level of comment inside. *\/\n          }\n        }\n        else\n        {\n          \/* Not a version comment. *\/\n          state=MY_LEX_START;\n          lip->set_echo(TRUE);\n          break;\n        }\n      }\n      else\n      {\n        lip->in_comment= PRESERVE_COMMENT;\n        lip->yySkip();                  \/\/ Accept \/\n        lip->yySkip();                  \/\/ Accept *\n        comment_closed= ! consume_comment(lip, 0);\n        \/* regular comments can have zero comments inside. *\/\n      }\n      \/*\n        Discard:\n        - regular '\/' '*' comments,\n        - special comments '\/' '*' '!' for a future version,\n        by scanning until we find a closing '*' '\/' marker.\n\n        Nesting regular comments isn't allowed.  The first \n        '*' '\/' returns the parser to the previous state.\n\n        \/#!VERSI oned containing \/# regular #\/ is allowed #\/\n\n\t\tInside one versioned comment, another versioned comment\n\t\tis treated as a regular discardable comment.  It gets\n\t\tno special parsing.\n      *\/\n\n      \/* Unbalanced comments with a missing '*' '\/' are a syntax error *\/\n      if (! comment_closed)\n        return (ABORT_SYM);\n      state = MY_LEX_START;             \/\/ Try again\n      lip->restore_in_comment_state();\n      break;\n    case MY_LEX_END_LONG_COMMENT:\n      if ((lip->in_comment != NO_COMMENT) && lip->yyPeek() == '\/')\n      {\n        \/* Reject '*' '\/' *\/\n        lip->yyUnget();\n        \/* Accept '*' '\/', with the proper echo *\/\n        lip->set_echo(lip->in_comment == PRESERVE_COMMENT);\n        lip->yySkipn(2);\n        \/* And start recording the tokens again *\/\n        lip->set_echo(TRUE);\n        lip->in_comment=NO_COMMENT;\n        state=MY_LEX_START;\n      }\n      else\n\tstate=MY_LEX_CHAR;\t\t\/\/ Return '*'\n      break;\n    case MY_LEX_SET_VAR:\t\t\/\/ Check if ':='\n      if (lip->yyPeek() != '=')\n      {\n\tstate=MY_LEX_CHAR;\t\t\/\/ Return ':'\n\tbreak;\n      }\n      lip->yySkip();\n      return (SET_VAR);\n    case MY_LEX_SEMICOLON:\t\t\t\/\/ optional line terminator\n      state= MY_LEX_CHAR;               \/\/ Return ';'\n      break;\n    case MY_LEX_EOL:\n      if (lip->eof())\n      {\n        lip->yyUnget();                 \/\/ Reject the last '\\0'\n        lip->set_echo(FALSE);\n        lip->yySkip();\n        lip->set_echo(TRUE);\n        \/* Unbalanced comments with a missing '*' '\/' are a syntax error *\/\n        if (lip->in_comment != NO_COMMENT)\n          return (ABORT_SYM);\n        lip->next_state=MY_LEX_END;     \/\/ Mark for next loop\n        return(END_OF_INPUT);\n      }\n      state=MY_LEX_CHAR;\n      break;\n    case MY_LEX_END:\n      lip->next_state=MY_LEX_END;\n      return(0);\t\t\t\/\/ We found end of input last time\n\n      \/* Actually real shouldn't start with . but allow them anyhow *\/\n    case MY_LEX_REAL_OR_POINT:\n      if (my_isdigit(cs,lip->yyPeek()))\n\tstate = MY_LEX_REAL;\t\t\/\/ Real\n      else\n      {\n\tstate= MY_LEX_IDENT_SEP;\t\/\/ return '.'\n        lip->yyUnget();                 \/\/ Put back '.'\n      }\n      break;\n    case MY_LEX_USER_END:\t\t\/\/ end '@' of user@hostname\n      switch (state_map[(uchar) lip->yyPeek()]) {\n      case MY_LEX_STRING:\n      case MY_LEX_USER_VARIABLE_DELIMITER:\n      case MY_LEX_STRING_OR_DELIMITER:\n\tbreak;\n      case MY_LEX_USER_END:\n\tlip->next_state=MY_LEX_SYSTEM_VAR;\n\tbreak;\n      default:\n\tlip->next_state=MY_LEX_HOSTNAME;\n\tbreak;\n      }\n      yylval->lex_str.str=(char*) lip->get_ptr();\n      yylval->lex_str.length=1;\n      return((int) '@');\n    case MY_LEX_HOSTNAME:\t\t\/\/ end '@' of user@hostname\n      for (c=lip->yyGet() ;\n\t   my_isalnum(cs,c) || c == '.' || c == '_' ||  c == '$';\n           c= lip->yyGet()) ;\n      yylval->lex_str=get_token(lip, 0, lip->yyLength());\n      return(LEX_HOSTNAME);\n    case MY_LEX_SYSTEM_VAR:\n      yylval->lex_str.str=(char*) lip->get_ptr();\n      yylval->lex_str.length=1;\n      lip->yySkip();                                    \/\/ Skip '@'\n      lip->next_state= (state_map[(uchar) lip->yyPeek()] ==\n\t\t\tMY_LEX_USER_VARIABLE_DELIMITER ?\n\t\t\tMY_LEX_OPERATOR_OR_IDENT :\n\t\t\tMY_LEX_IDENT_OR_KEYWORD);\n      return((int) '@');\n    case MY_LEX_IDENT_OR_KEYWORD:\n      \/*\n\tWe come here when we have found two '@' in a row.\n\tWe should now be able to handle:\n\t[(global | local | session) .]variable_name\n      *\/\n\n      for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c)\n        ;\n      \/* If there were non-ASCII characters, mark that we must convert *\/\n      result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;\n\n      if (c == '.')\n\tlip->next_state=MY_LEX_IDENT_SEP;\n      length= lip->yyLength();\n      if (length == 0)\n        return(ABORT_SYM);              \/\/ Names must be nonempty.\n      if ((tokval= find_keyword(lip, length,0)))\n      {\n        lip->yyUnget();                         \/\/ Put back 'c'\n\treturn(tokval);\t\t\t\t\/\/ Was keyword\n      }\n      yylval->lex_str=get_token(lip, 0, length);\n\n      lip->body_utf8_append(lip->m_cpp_text_start);\n\n      lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end);\n\n      return(result_state);\n    }\n  }\n}","target":0,"code_token_length":6429,"total_token_length":6665,"max_tokens_setting":8192}
+{"idx":449293,"func":"normal_cmd(\n    oparg_T\t*oap,\n    int\t\ttoplevel UNUSED)\t\/\/ TRUE when called from main()\n{\n    cmdarg_T\tca;\t\t\t\/\/ command arguments\n    int\t\tc;\n    int\t\tctrl_w = FALSE;\t\t\/\/ got CTRL-W command\n    int\t\told_col = curwin->w_curswant;\n#ifdef FEAT_CMDL_INFO\n    int\t\tneed_flushbuf;\t\t\/\/ need to call out_flush()\n#endif\n    pos_T\told_pos;\t\t\/\/ cursor position before command\n    int\t\tmapped_len;\n    static int\told_mapped_len = 0;\n    int\t\tidx;\n#ifdef FEAT_EVAL\n    int\t\tset_prevcount = FALSE;\n#endif\n    int\t\tsave_did_cursorhold = did_cursorhold;\n\n    CLEAR_FIELD(ca);\t\/\/ also resets ca.retval\n    ca.oap = oap;\n\n    \/\/ Use a count remembered from before entering an operator.  After typing\n    \/\/ \"3d\" we return from normal_cmd() and come back here, the \"3\" is\n    \/\/ remembered in \"opcount\".\n    ca.opcount = opcount;\n\n    \/*\n     * If there is an operator pending, then the command we take this time\n     * will terminate it. Finish_op tells us to finish the operation before\n     * returning this time (unless the operation was cancelled).\n     *\/\n#ifdef CURSOR_SHAPE\n    c = finish_op;\n#endif\n    finish_op = (oap->op_type != OP_NOP);\n#ifdef CURSOR_SHAPE\n    if (finish_op != c)\n    {\n\tui_cursor_shape();\t\t\/\/ may show different cursor shape\n# ifdef FEAT_MOUSESHAPE\n\tupdate_mouseshape(-1);\n# endif\n    }\n#endif\n    trigger_modechanged();\n\n    \/\/ When not finishing an operator and no register name typed, reset the\n    \/\/ count.\n    if (!finish_op && !oap->regname)\n    {\n\tca.opcount = 0;\n#ifdef FEAT_EVAL\n\tset_prevcount = TRUE;\n#endif\n    }\n\n    \/\/ Restore counts from before receiving K_CURSORHOLD.  This means after\n    \/\/ typing \"3\", handling K_CURSORHOLD and then typing \"2\" we get \"32\", not\n    \/\/ \"3 * 2\".\n    if (oap->prev_opcount > 0 || oap->prev_count0 > 0)\n    {\n\tca.opcount = oap->prev_opcount;\n\tca.count0 = oap->prev_count0;\n\toap->prev_opcount = 0;\n\toap->prev_count0 = 0;\n    }\n\n    mapped_len = typebuf_maplen();\n\n    State = NORMAL_BUSY;\n#ifdef USE_ON_FLY_SCROLL\n    dont_scroll = FALSE;\t\/\/ allow scrolling here\n#endif\n\n#ifdef FEAT_EVAL\n    \/\/ Set v:count here, when called from main() and not a stuffed\n    \/\/ command, so that v:count can be used in an expression mapping\n    \/\/ when there is no count. Do set it for redo.\n    if (toplevel && readbuf1_empty())\n\tset_vcount_ca(&ca, &set_prevcount);\n#endif\n\n    \/*\n     * Get the command character from the user.\n     *\/\n    c = safe_vgetc();\n    LANGMAP_ADJUST(c, get_real_state() != SELECTMODE);\n\n    \/*\n     * If a mapping was started in Visual or Select mode, remember the length\n     * of the mapping.  This is used below to not return to Insert mode for as\n     * long as the mapping is being executed.\n     *\/\n    if (restart_edit == 0)\n\told_mapped_len = 0;\n    else if (old_mapped_len\n\t\t|| (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0))\n\told_mapped_len = typebuf_maplen();\n\n    if (c == NUL)\n\tc = K_ZERO;\n\n    \/*\n     * In Select mode, typed text replaces the selection.\n     *\/\n    if (VIsual_active\n\t    && VIsual_select\n\t    && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER))\n    {\n\t\/\/ Fake a \"c\"hange command.  When \"restart_edit\" is set (e.g., because\n\t\/\/ 'insertmode' is set) fake a \"d\"elete command, Insert mode will\n\t\/\/ restart automatically.\n\t\/\/ Insert the typed character in the typeahead buffer, so that it can\n\t\/\/ be mapped in Insert mode.  Required for \":lmap\" to work.\n\tins_char_typebuf(vgetc_char, vgetc_mod_mask);\n\tif (restart_edit != 0)\n\t    c = 'd';\n\telse\n\t    c = 'c';\n\tmsg_nowait = TRUE;\t\/\/ don't delay going to insert mode\n\told_mapped_len = 0;\t\/\/ do go to Insert mode\n    }\n\n#ifdef FEAT_CMDL_INFO\n    need_flushbuf = add_to_showcmd(c);\n#endif\n\ngetcount:\n    if (!(VIsual_active && VIsual_select))\n    {\n\t\/*\n\t * Handle a count before a command and compute ca.count0.\n\t * Note that '0' is a command and not the start of a count, but it's\n\t * part of a count after other digits.\n\t *\/\n\twhile (    (c >= '1' && c <= '9')\n\t\t|| (ca.count0 != 0 && (c == K_DEL || c == K_KDEL || c == '0')))\n\t{\n\t    if (c == K_DEL || c == K_KDEL)\n\t    {\n\t\tca.count0 \/= 10;\n#ifdef FEAT_CMDL_INFO\n\t\tdel_from_showcmd(4);\t\/\/ delete the digit and ~@%\n#endif\n\t    }\n\t    else\n\t\tca.count0 = ca.count0 * 10 + (c - '0');\n\t    if (ca.count0 < 0)\t    \/\/ overflow\n\t\tca.count0 = 999999999L;\n#ifdef FEAT_EVAL\n\t    \/\/ Set v:count here, when called from main() and not a stuffed\n\t    \/\/ command, so that v:count can be used in an expression mapping\n\t    \/\/ right after the count. Do set it for redo.\n\t    if (toplevel && readbuf1_empty())\n\t\tset_vcount_ca(&ca, &set_prevcount);\n#endif\n\t    if (ctrl_w)\n\t    {\n\t\t++no_mapping;\n\t\t++allow_keys;\t\t\/\/ no mapping for nchar, but keys\n\t    }\n\t    ++no_zero_mapping;\t\t\/\/ don't map zero here\n\t    c = plain_vgetc();\n\t    LANGMAP_ADJUST(c, TRUE);\n\t    --no_zero_mapping;\n\t    if (ctrl_w)\n\t    {\n\t\t--no_mapping;\n\t\t--allow_keys;\n\t    }\n#ifdef FEAT_CMDL_INFO\n\t    need_flushbuf |= add_to_showcmd(c);\n#endif\n\t}\n\n\t\/*\n\t * If we got CTRL-W there may be a\/another count\n\t *\/\n\tif (c == Ctrl_W && !ctrl_w && oap->op_type == OP_NOP)\n\t{\n\t    ctrl_w = TRUE;\n\t    ca.opcount = ca.count0;\t\/\/ remember first count\n\t    ca.count0 = 0;\n\t    ++no_mapping;\n\t    ++allow_keys;\t\t\/\/ no mapping for nchar, but keys\n\t    c = plain_vgetc();\t\t\/\/ get next character\n\t    LANGMAP_ADJUST(c, TRUE);\n\t    --no_mapping;\n\t    --allow_keys;\n#ifdef FEAT_CMDL_INFO\n\t    need_flushbuf |= add_to_showcmd(c);\n#endif\n\t    goto getcount;\t\t\/\/ jump back\n\t}\n    }\n\n    if (c == K_CURSORHOLD)\n    {\n\t\/\/ Save the count values so that ca.opcount and ca.count0 are exactly\n\t\/\/ the same when coming back here after handling K_CURSORHOLD.\n\toap->prev_opcount = ca.opcount;\n\toap->prev_count0 = ca.count0;\n    }\n    else if (ca.opcount != 0)\n    {\n\t\/*\n\t * If we're in the middle of an operator (including after entering a\n\t * yank buffer with '\"') AND we had a count before the operator, then\n\t * that count overrides the current value of ca.count0.\n\t * What this means effectively, is that commands like \"3dw\" get turned\n\t * into \"d3w\" which makes things fall into place pretty neatly.\n\t * If you give a count before AND after the operator, they are\n\t * multiplied.\n\t *\/\n\tif (ca.count0)\n\t    ca.count0 *= ca.opcount;\n\telse\n\t    ca.count0 = ca.opcount;\n\tif (ca.count0 < 0)\t    \/\/ overflow\n\t    ca.count0 = 999999999L;\n    }\n\n    \/*\n     * Always remember the count.  It will be set to zero (on the next call,\n     * above) when there is no pending operator.\n     * When called from main(), save the count for use by the \"count\" built-in\n     * variable.\n     *\/\n    ca.opcount = ca.count0;\n    ca.count1 = (ca.count0 == 0 ? 1 : ca.count0);\n\n#ifdef FEAT_EVAL\n    \/*\n     * Only set v:count when called from main() and not a stuffed command.\n     * Do set it for redo.\n     *\/\n    if (toplevel && readbuf1_empty())\n\tset_vcount(ca.count0, ca.count1, set_prevcount);\n#endif\n\n    \/*\n     * Find the command character in the table of commands.\n     * For CTRL-W we already got nchar when looking for a count.\n     *\/\n    if (ctrl_w)\n    {\n\tca.nchar = c;\n\tca.cmdchar = Ctrl_W;\n    }\n    else\n\tca.cmdchar = c;\n    idx = find_command(ca.cmdchar);\n    if (idx < 0)\n    {\n\t\/\/ Not a known command: beep.\n\tclearopbeep(oap);\n\tgoto normal_end;\n    }\n\n    if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW))\n    {\n\t\/\/ This command is not allowed while editing a cmdline: beep.\n\tclearopbeep(oap);\n\ttext_locked_msg();\n\tgoto normal_end;\n    }\n    if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked())\n\tgoto normal_end;\n\n    \/*\n     * In Visual\/Select mode, a few keys are handled in a special way.\n     *\/\n    if (VIsual_active)\n    {\n\t\/\/ when 'keymodel' contains \"stopsel\" may stop Select\/Visual mode\n\tif (km_stopsel\n\t\t&& (nv_cmds[idx].cmd_flags & NV_STS)\n\t\t&& !(mod_mask & MOD_MASK_SHIFT))\n\t{\n\t    end_visual_mode();\n\t    redraw_curbuf_later(INVERTED);\n\t}\n\n\t\/\/ Keys that work different when 'keymodel' contains \"startsel\"\n\tif (km_startsel)\n\t{\n\t    if (nv_cmds[idx].cmd_flags & NV_SS)\n\t    {\n\t\tunshift_special(&ca);\n\t\tidx = find_command(ca.cmdchar);\n\t\tif (idx < 0)\n\t\t{\n\t\t    \/\/ Just in case\n\t\t    clearopbeep(oap);\n\t\t    goto normal_end;\n\t\t}\n\t    }\n\t    else if ((nv_cmds[idx].cmd_flags & NV_SSS)\n\t\t\t\t\t       && (mod_mask & MOD_MASK_SHIFT))\n\t\tmod_mask &= ~MOD_MASK_SHIFT;\n\t}\n    }\n\n#ifdef FEAT_RIGHTLEFT\n    if (curwin->w_p_rl && KeyTyped && !KeyStuffed\n\t\t\t\t\t  && (nv_cmds[idx].cmd_flags & NV_RL))\n    {\n\t\/\/ Invert horizontal movements and operations.  Only when typed by the\n\t\/\/ user directly, not when the result of a mapping or \"x\" translated\n\t\/\/ to \"dl\".\n\tswitch (ca.cmdchar)\n\t{\n\t    case 'l':\t    ca.cmdchar = 'h'; break;\n\t    case K_RIGHT:   ca.cmdchar = K_LEFT; break;\n\t    case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break;\n\t    case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break;\n\t    case 'h':\t    ca.cmdchar = 'l'; break;\n\t    case K_LEFT:    ca.cmdchar = K_RIGHT; break;\n\t    case K_S_LEFT:  ca.cmdchar = K_S_RIGHT; break;\n\t    case K_C_LEFT:  ca.cmdchar = K_C_RIGHT; break;\n\t    case '>':\t    ca.cmdchar = '<'; break;\n\t    case '<':\t    ca.cmdchar = '>'; break;\n\t}\n\tidx = find_command(ca.cmdchar);\n    }\n#endif\n\n    \/*\n     * Get an additional character if we need one.\n     *\/\n    if ((nv_cmds[idx].cmd_flags & NV_NCH)\n\t    && (((nv_cmds[idx].cmd_flags & NV_NCH_NOP) == NV_NCH_NOP\n\t\t    && oap->op_type == OP_NOP)\n\t\t|| (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW\n\t\t|| (ca.cmdchar == 'q'\n\t\t    && oap->op_type == OP_NOP\n\t\t    && reg_recording == 0\n\t\t    && reg_executing == 0)\n\t\t|| ((ca.cmdchar == 'a' || ca.cmdchar == 'i')\n\t\t    && (oap->op_type != OP_NOP || VIsual_active))))\n    {\n\tint\t*cp;\n\tint\trepl = FALSE;\t\/\/ get character for replace mode\n\tint\tlit = FALSE;\t\/\/ get extra character literally\n\tint\tlangmap_active = FALSE;    \/\/ using :lmap mappings\n\tint\tlang;\t\t\/\/ getting a text character\n#ifdef HAVE_INPUT_METHOD\n\tint\tsave_smd;\t\/\/ saved value of p_smd\n#endif\n\n\t++no_mapping;\n\t++allow_keys;\t\t\/\/ no mapping for nchar, but allow key codes\n\t\/\/ Don't generate a CursorHold event here, most commands can't handle\n\t\/\/ it, e.g., nv_replace(), nv_csearch().\n\tdid_cursorhold = TRUE;\n\tif (ca.cmdchar == 'g')\n\t{\n\t    \/*\n\t     * For 'g' get the next character now, so that we can check for\n\t     * \"gr\", \"g'\" and \"g`\".\n\t     *\/\n\t    ca.nchar = plain_vgetc();\n\t    LANGMAP_ADJUST(ca.nchar, TRUE);\n#ifdef FEAT_CMDL_INFO\n\t    need_flushbuf |= add_to_showcmd(ca.nchar);\n#endif\n\t    if (ca.nchar == 'r' || ca.nchar == '\\'' || ca.nchar == '`'\n\t\t\t\t\t\t       || ca.nchar == Ctrl_BSL)\n\t    {\n\t\tcp = &ca.extra_char;\t\/\/ need to get a third character\n\t\tif (ca.nchar != 'r')\n\t\t    lit = TRUE;\t\t\t\/\/ get it literally\n\t\telse\n\t\t    repl = TRUE;\t\t\/\/ get it in replace mode\n\t    }\n\t    else\n\t\tcp = NULL;\t\t\/\/ no third character needed\n\t}\n\telse\n\t{\n\t    if (ca.cmdchar == 'r')\t\t\/\/ get it in replace mode\n\t\trepl = TRUE;\n\t    cp = &ca.nchar;\n\t}\n\tlang = (repl || (nv_cmds[idx].cmd_flags & NV_LANG));\n\n\t\/*\n\t * Get a second or third character.\n\t *\/\n\tif (cp != NULL)\n\t{\n\t    if (repl)\n\t    {\n\t\tState = REPLACE;\t\/\/ pretend Replace mode\n#ifdef CURSOR_SHAPE\n\t\tui_cursor_shape();\t\/\/ show different cursor shape\n#endif\n\t    }\n\t    if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP)\n\t    {\n\t\t\/\/ Allow mappings defined with \":lmap\".\n\t\t--no_mapping;\n\t\t--allow_keys;\n\t\tif (repl)\n\t\t    State = LREPLACE;\n\t\telse\n\t\t    State = LANGMAP;\n\t\tlangmap_active = TRUE;\n\t    }\n#ifdef HAVE_INPUT_METHOD\n\t    save_smd = p_smd;\n\t    p_smd = FALSE;\t\/\/ Don't let the IM code show the mode here\n\t    if (lang && curbuf->b_p_iminsert == B_IMODE_IM)\n\t\tim_set_active(TRUE);\n#endif\n\t    if ((State & INSERT) && !p_ek)\n\t    {\n#ifdef FEAT_JOB_CHANNEL\n\t\tch_log_output = TRUE;\n#endif\n\t\t\/\/ Disable bracketed paste and modifyOtherKeys here, we won't\n\t\t\/\/ recognize the escape sequences with 'esckeys' off.\n\t\tout_str(T_BD);\n\t\tout_str(T_CTE);\n\t    }\n\n\t    *cp = plain_vgetc();\n\n\t    if ((State & INSERT) && !p_ek)\n\t    {\n#ifdef FEAT_JOB_CHANNEL\n\t\tch_log_output = TRUE;\n#endif\n\t\t\/\/ Re-enable bracketed paste mode and modifyOtherKeys\n\t\tout_str(T_BE);\n\t\tout_str(T_CTI);\n\t    }\n\n\t    if (langmap_active)\n\t    {\n\t\t\/\/ Undo the decrement done above\n\t\t++no_mapping;\n\t\t++allow_keys;\n\t\tState = NORMAL_BUSY;\n\t    }\n#ifdef HAVE_INPUT_METHOD\n\t    if (lang)\n\t    {\n\t\tif (curbuf->b_p_iminsert != B_IMODE_LMAP)\n\t\t    im_save_status(&curbuf->b_p_iminsert);\n\t\tim_set_active(FALSE);\n\t    }\n\t    p_smd = save_smd;\n#endif\n\t    State = NORMAL_BUSY;\n#ifdef FEAT_CMDL_INFO\n\t    need_flushbuf |= add_to_showcmd(*cp);\n#endif\n\n\t    if (!lit)\n\t    {\n#ifdef FEAT_DIGRAPHS\n\t\t\/\/ Typing CTRL-K gets a digraph.\n\t\tif (*cp == Ctrl_K\n\t\t\t&& ((nv_cmds[idx].cmd_flags & NV_LANG)\n\t\t\t    || cp == &ca.extra_char)\n\t\t\t&& vim_strchr(p_cpo, CPO_DIGRAPH) == NULL)\n\t\t{\n\t\t    c = get_digraph(FALSE);\n\t\t    if (c > 0)\n\t\t    {\n\t\t\t*cp = c;\n# ifdef FEAT_CMDL_INFO\n\t\t\t\/\/ Guessing how to update showcmd here...\n\t\t\tdel_from_showcmd(3);\n\t\t\tneed_flushbuf |= add_to_showcmd(*cp);\n# endif\n\t\t    }\n\t\t}\n#endif\n\n\t\t\/\/ adjust chars > 127, except after \"tTfFr\" commands\n\t\tLANGMAP_ADJUST(*cp, !lang);\n#ifdef FEAT_RIGHTLEFT\n\t\t\/\/ adjust Hebrew mapped char\n\t\tif (p_hkmap && lang && KeyTyped)\n\t\t    *cp = hkmap(*cp);\n#endif\n\t    }\n\n\t    \/*\n\t     * When the next character is CTRL-\\ a following CTRL-N means the\n\t     * command is aborted and we go to Normal mode.\n\t     *\/\n\t    if (cp == &ca.extra_char\n\t\t    && ca.nchar == Ctrl_BSL\n\t\t    && (ca.extra_char == Ctrl_N || ca.extra_char == Ctrl_G))\n\t    {\n\t\tca.cmdchar = Ctrl_BSL;\n\t\tca.nchar = ca.extra_char;\n\t\tidx = find_command(ca.cmdchar);\n\t    }\n\t    else if ((ca.nchar == 'n' || ca.nchar == 'N') && ca.cmdchar == 'g')\n\t\tca.oap->op_type = get_op_type(*cp, NUL);\n\t    else if (*cp == Ctrl_BSL)\n\t    {\n\t\tlong towait = (p_ttm >= 0 ? p_ttm : p_tm);\n\n\t\t\/\/ There is a busy wait here when typing \"f<C-\\>\" and then\n\t\t\/\/ something different from CTRL-N.  Can't be avoided.\n\t\twhile ((c = vpeekc()) <= 0 && towait > 0L)\n\t\t{\n\t\t    do_sleep(towait > 50L ? 50L : towait, FALSE);\n\t\t    towait -= 50L;\n\t\t}\n\t\tif (c > 0)\n\t\t{\n\t\t    c = plain_vgetc();\n\t\t    if (c != Ctrl_N && c != Ctrl_G)\n\t\t\tvungetc(c);\n\t\t    else\n\t\t    {\n\t\t\tca.cmdchar = Ctrl_BSL;\n\t\t\tca.nchar = c;\n\t\t\tidx = find_command(ca.cmdchar);\n\t\t    }\n\t\t}\n\t    }\n\n\t    \/\/ When getting a text character and the next character is a\n\t    \/\/ multi-byte character, it could be a composing character.\n\t    \/\/ However, don't wait for it to arrive. Also, do enable mapping,\n\t    \/\/ because if it's put back with vungetc() it's too late to apply\n\t    \/\/ mapping.\n\t    --no_mapping;\n\t    while (enc_utf8 && lang && (c = vpeekc()) > 0\n\t\t\t\t && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))\n\t    {\n\t\tc = plain_vgetc();\n\t\tif (!utf_iscomposing(c))\n\t\t{\n\t\t    vungetc(c);\t\t\/\/ it wasn't, put it back\n\t\t    break;\n\t\t}\n\t\telse if (ca.ncharC1 == 0)\n\t\t    ca.ncharC1 = c;\n\t\telse\n\t\t    ca.ncharC2 = c;\n\t    }\n\t    ++no_mapping;\n\t}\n\t--no_mapping;\n\t--allow_keys;\n    }\n\n#ifdef FEAT_CMDL_INFO\n    \/*\n     * Flush the showcmd characters onto the screen so we can see them while\n     * the command is being executed.  Only do this when the shown command was\n     * actually displayed, otherwise this will slow down a lot when executing\n     * mappings.\n     *\/\n    if (need_flushbuf)\n\tout_flush();\n#endif\n    if (ca.cmdchar != K_IGNORE)\n    {\n\tif (ex_normal_busy)\n\t    did_cursorhold = save_did_cursorhold;\n\telse\n\t    did_cursorhold = FALSE;\n    }\n\n    State = NORMAL;\n\n    if (ca.nchar == ESC)\n    {\n\tclearop(oap);\n\tif (restart_edit == 0 && goto_im())\n\t    restart_edit = 'a';\n\tgoto normal_end;\n    }\n\n    if (ca.cmdchar != K_IGNORE)\n    {\n\tmsg_didout = FALSE;    \/\/ don't scroll screen up for normal command\n\tmsg_col = 0;\n    }\n\n    old_pos = curwin->w_cursor;\t\t\/\/ remember where cursor was\n\n    \/\/ When 'keymodel' contains \"startsel\" some keys start Select\/Visual\n    \/\/ mode.\n    if (!VIsual_active && km_startsel)\n    {\n\tif (nv_cmds[idx].cmd_flags & NV_SS)\n\t{\n\t    start_selection();\n\t    unshift_special(&ca);\n\t    idx = find_command(ca.cmdchar);\n\t}\n\telse if ((nv_cmds[idx].cmd_flags & NV_SSS)\n\t\t\t\t\t   && (mod_mask & MOD_MASK_SHIFT))\n\t{\n\t    start_selection();\n\t    mod_mask &= ~MOD_MASK_SHIFT;\n\t}\n    }\n\n    \/*\n     * Execute the command!\n     * Call the command function found in the commands table.\n     *\/\n    ca.arg = nv_cmds[idx].cmd_arg;\n    (nv_cmds[idx].cmd_func)(&ca);\n\n    \/*\n     * If we didn't start or finish an operator, reset oap->regname, unless we\n     * need it later.\n     *\/\n    if (!finish_op\n\t    && !oap->op_type\n\t    && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG)))\n    {\n\tclearop(oap);\n#ifdef FEAT_EVAL\n\treset_reg_var();\n#endif\n    }\n\n    \/\/ Get the length of mapped chars again after typing a count, second\n    \/\/ character or \"z333<cr>\".\n    if (old_mapped_len > 0)\n\told_mapped_len = typebuf_maplen();\n\n    \/*\n     * If an operation is pending, handle it.  But not for K_IGNORE or\n     * K_MOUSEMOVE.\n     *\/\n    if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE)\n\tdo_pending_operator(&ca, old_col, FALSE);\n\n    \/*\n     * Wait for a moment when a message is displayed that will be overwritten\n     * by the mode message.\n     * In Visual mode and with \"^O\" in Insert mode, a short message will be\n     * overwritten by the mode message.  Wait a bit, until a key is hit.\n     * In Visual mode, it's more important to keep the Visual area updated\n     * than keeping a message (e.g. from a \/pat search).\n     * Only do this if the command was typed, not from a mapping.\n     * Don't wait when emsg_silent is non-zero.\n     * Also wait a bit after an error message, e.g. for \"^O:\".\n     * Don't redraw the screen, it would remove the message.\n     *\/\n    if (       ((p_smd\n\t\t    && msg_silent == 0\n\t\t    && (restart_edit != 0\n\t\t\t|| (VIsual_active\n\t\t\t    && old_pos.lnum == curwin->w_cursor.lnum\n\t\t\t    && old_pos.col == curwin->w_cursor.col)\n\t\t       )\n\t\t    && (clear_cmdline\n\t\t\t|| redraw_cmdline)\n\t\t    && (msg_didout || (msg_didany && msg_scroll))\n\t\t    && !msg_nowait\n\t\t    && KeyTyped)\n\t\t|| (restart_edit != 0\n\t\t    && !VIsual_active\n\t\t    && (msg_scroll\n\t\t\t|| emsg_on_display)))\n\t    && oap->regname == 0\n\t    && !(ca.retval & CA_COMMAND_BUSY)\n\t    && stuff_empty()\n\t    && typebuf_typed()\n\t    && emsg_silent == 0\n\t    && !in_assert_fails\n\t    && !did_wait_return\n\t    && oap->op_type == OP_NOP)\n    {\n\tint\tsave_State = State;\n\n\t\/\/ Draw the cursor with the right shape here\n\tif (restart_edit != 0)\n\t    State = INSERT;\n\n\t\/\/ If need to redraw, and there is a \"keep_msg\", redraw before the\n\t\/\/ delay\n\tif (must_redraw && keep_msg != NULL && !emsg_on_display)\n\t{\n\t    char_u\t*kmsg;\n\n\t    kmsg = keep_msg;\n\t    keep_msg = NULL;\n\t    \/\/ Showmode() will clear keep_msg, but we want to use it anyway.\n\t    \/\/ First update w_topline.\n\t    setcursor();\n\t    update_screen(0);\n\t    \/\/ now reset it, otherwise it's put in the history again\n\t    keep_msg = kmsg;\n\n\t    kmsg = vim_strsave(keep_msg);\n\t    if (kmsg != NULL)\n\t    {\n\t\tmsg_attr((char *)kmsg, keep_msg_attr);\n\t\tvim_free(kmsg);\n\t    }\n\t}\n\tsetcursor();\n#ifdef CURSOR_SHAPE\n\tui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n\tcursor_on();\n\tout_flush();\n\tif (msg_scroll || emsg_on_display)\n\t    ui_delay(1003L, TRUE);\t\/\/ wait at least one second\n\tui_delay(3003L, FALSE);\t\t\/\/ wait up to three seconds\n\tState = save_State;\n\n\tmsg_scroll = FALSE;\n\temsg_on_display = FALSE;\n    }\n\n    \/*\n     * Finish up after executing a Normal mode command.\n     *\/\nnormal_end:\n\n    msg_nowait = FALSE;\n\n#ifdef FEAT_EVAL\n    if (finish_op)\n\treset_reg_var();\n#endif\n\n    \/\/ Reset finish_op, in case it was set\n#ifdef CURSOR_SHAPE\n    c = finish_op;\n#endif\n    finish_op = FALSE;\n    trigger_modechanged();\n#ifdef CURSOR_SHAPE\n    \/\/ Redraw the cursor with another shape, if we were in Operator-pending\n    \/\/ mode or did a replace command.\n    if (c || ca.cmdchar == 'r')\n    {\n\tui_cursor_shape();\t\t\/\/ may show different cursor shape\n# ifdef FEAT_MOUSESHAPE\n\tupdate_mouseshape(-1);\n# endif\n    }\n#endif\n\n#ifdef FEAT_CMDL_INFO\n    if (oap->op_type == OP_NOP && oap->regname == 0\n\t    && ca.cmdchar != K_CURSORHOLD)\n\tclear_showcmd();\n#endif\n\n    checkpcmark();\t\t\/\/ check if we moved since setting pcmark\n    vim_free(ca.searchbuf);\n\n    if (has_mbyte)\n\tmb_adjust_cursor();\n\n    if (curwin->w_p_scb && toplevel)\n    {\n\tvalidate_cursor();\t\/\/ may need to update w_leftcol\n\tdo_check_scrollbind(TRUE);\n    }\n\n    if (curwin->w_p_crb && toplevel)\n    {\n\tvalidate_cursor();\t\/\/ may need to update w_leftcol\n\tdo_check_cursorbind();\n    }\n\n#ifdef FEAT_TERMINAL\n    \/\/ don't go to Insert mode if a terminal has a running job\n    if (term_job_running(curbuf->b_term))\n\trestart_edit = 0;\n#endif\n\n    \/*\n     * May restart edit(), if we got here with CTRL-O in Insert mode (but not\n     * if still inside a mapping that started in Visual mode).\n     * May switch from Visual to Select mode after CTRL-O command.\n     *\/\n    if (       oap->op_type == OP_NOP\n\t    && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0)\n\t\t|| restart_VIsual_select == 1)\n\t    && !(ca.retval & CA_COMMAND_BUSY)\n\t    && stuff_empty()\n\t    && oap->regname == 0)\n    {\n\tif (restart_VIsual_select == 1)\n\t{\n\t    VIsual_select = TRUE;\n\t    trigger_modechanged();\n\t    showmode();\n\t    restart_VIsual_select = 0;\n\t}\n\tif (restart_edit != 0 && !VIsual_active && old_mapped_len == 0)\n\t    (void)edit(restart_edit, FALSE, 1L);\n    }\n\n    if (restart_VIsual_select == 2)\n\trestart_VIsual_select = 1;\n\n    \/\/ Save count before an operator for next time.\n    opcount = ca.opcount;\n}","target":0,"code_token_length":6371,"total_token_length":6607,"max_tokens_setting":8192}
+{"idx":418795,"func":"do_mouse(\n    oparg_T\t*oap,\t\t\/\/ operator argument, can be NULL\n    int\t\tc,\t\t\/\/ K_LEFTMOUSE, etc\n    int\t\tdir,\t\t\/\/ Direction to 'put' if necessary\n    long\tcount,\n    int\t\tfixindent)\t\/\/ PUT_FIXINDENT if fixing indent necessary\n{\n    static int\tdo_always = FALSE;\t\/\/ ignore 'mouse' setting next time\n    static int\tgot_click = FALSE;\t\/\/ got a click some time back\n\n    int\t\twhich_button;\t\/\/ MOUSE_LEFT, _MIDDLE or _RIGHT\n    int\t\tis_click = FALSE; \/\/ If FALSE it's a drag or release event\n    int\t\tis_drag = FALSE;  \/\/ If TRUE it's a drag event\n    int\t\tjump_flags = 0;\t\/\/ flags for jump_to_mouse()\n    pos_T\tstart_visual;\n    int\t\tmoved;\t\t\/\/ Has cursor moved?\n    int\t\tin_status_line;\t\/\/ mouse in status line\n    static int\tin_tab_line = FALSE; \/\/ mouse clicked in tab line\n    int\t\tin_sep_line;\t\/\/ mouse in vertical separator line\n    int\t\tc1, c2;\n#if defined(FEAT_FOLDING)\n    pos_T\tsave_cursor;\n#endif\n    win_T\t*old_curwin = curwin;\n    static pos_T orig_cursor;\n    colnr_T\tleftcol, rightcol;\n    pos_T\tend_visual;\n    int\t\tdiff;\n    int\t\told_active = VIsual_active;\n    int\t\told_mode = VIsual_mode;\n    int\t\tregname;\n\n#if defined(FEAT_FOLDING)\n    save_cursor = curwin->w_cursor;\n#endif\n\n    \/\/ When GUI is active, always recognize mouse events, otherwise:\n    \/\/ - Ignore mouse event in normal mode if 'mouse' doesn't include 'n'.\n    \/\/ - Ignore mouse event in visual mode if 'mouse' doesn't include 'v'.\n    \/\/ - For command line and insert mode 'mouse' is checked before calling\n    \/\/\t do_mouse().\n    if (do_always)\n\tdo_always = FALSE;\n    else\n#ifdef FEAT_GUI\n\tif (!gui.in_use)\n#endif\n\t{\n\t    if (VIsual_active)\n\t    {\n\t\tif (!mouse_has(MOUSE_VISUAL))\n\t\t    return FALSE;\n\t    }\n\t    else if (State == MODE_NORMAL && !mouse_has(MOUSE_NORMAL))\n\t\treturn FALSE;\n\t}\n\n    for (;;)\n    {\n\twhich_button = get_mouse_button(KEY2TERMCAP1(c), &is_click, &is_drag);\n\tif (is_drag)\n\t{\n\t    \/\/ If the next character is the same mouse event then use that\n\t    \/\/ one. Speeds up dragging the status line.\n\t    \/\/ Note: Since characters added to the stuff buffer in the code\n\t    \/\/ below need to come before the next character, do not do this\n\t    \/\/ when the current character was stuffed.\n\t    if (!KeyStuffed && vpeekc() != NUL)\n\t    {\n\t\tint nc;\n\t\tint save_mouse_row = mouse_row;\n\t\tint save_mouse_col = mouse_col;\n\n\t\t\/\/ Need to get the character, peeking doesn't get the actual\n\t\t\/\/ one.\n\t\tnc = safe_vgetc();\n\t\tif (c == nc)\n\t\t    continue;\n\t\tvungetc(nc);\n\t\tmouse_row = save_mouse_row;\n\t\tmouse_col = save_mouse_col;\n\t    }\n\t}\n\tbreak;\n    }\n\n    if (c == K_MOUSEMOVE)\n    {\n\t\/\/ Mouse moved without a button pressed.\n#ifdef FEAT_BEVAL_TERM\n\tui_may_remove_balloon();\n\tif (p_bevalterm)\n\t{\n\t    profile_setlimit(p_bdlay, &bevalexpr_due);\n\t    bevalexpr_due_set = TRUE;\n\t}\n#endif\n#ifdef FEAT_PROP_POPUP\n\tpopup_handle_mouse_moved();\n#endif\n\treturn FALSE;\n    }\n\n#ifdef FEAT_MOUSESHAPE\n    \/\/ May have stopped dragging the status or separator line.  The pointer is\n    \/\/ most likely still on the status or separator line.\n    if (!is_drag && drag_status_line)\n    {\n\tdrag_status_line = FALSE;\n\tupdate_mouseshape(SHAPE_IDX_STATUS);\n    }\n    if (!is_drag && drag_sep_line)\n    {\n\tdrag_sep_line = FALSE;\n\tupdate_mouseshape(SHAPE_IDX_VSEP);\n    }\n#endif\n\n    \/\/ Ignore drag and release events if we didn't get a click.\n    if (is_click)\n\tgot_click = TRUE;\n    else\n    {\n\tif (!got_click)\t\t\t\/\/ didn't get click, ignore\n\t    return FALSE;\n\tif (!is_drag)\t\t\t\/\/ release, reset got_click\n\t{\n\t    got_click = FALSE;\n\t    if (in_tab_line)\n\t    {\n\t\tin_tab_line = FALSE;\n\t\treturn FALSE;\n\t    }\n\t}\n    }\n\n    \/\/ CTRL right mouse button does CTRL-T\n    if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT)\n    {\n\tif (State & MODE_INSERT)\n\t    stuffcharReadbuff(Ctrl_O);\n\tif (count > 1)\n\t    stuffnumReadbuff(count);\n\tstuffcharReadbuff(Ctrl_T);\n\tgot_click = FALSE;\t\t\/\/ ignore drag&release now\n\treturn FALSE;\n    }\n\n    \/\/ CTRL only works with left mouse button\n    if ((mod_mask & MOD_MASK_CTRL) && which_button != MOUSE_LEFT)\n\treturn FALSE;\n\n    \/\/ When a modifier is down, ignore drag and release events, as well as\n    \/\/ multiple clicks and the middle mouse button.\n    \/\/ Accept shift-leftmouse drags when 'mousemodel' is \"popup.*\".\n    if ((mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT\n\t\t\t\t\t\t\t     | MOD_MASK_META))\n\t    && (!is_click\n\t\t|| (mod_mask & MOD_MASK_MULTI_CLICK)\n\t\t|| which_button == MOUSE_MIDDLE)\n\t    && !((mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT))\n\t\t&& mouse_model_popup()\n\t\t&& which_button == MOUSE_LEFT)\n\t    && !((mod_mask & MOD_MASK_ALT)\n\t\t&& !mouse_model_popup()\n\t\t&& which_button == MOUSE_RIGHT)\n\t    )\n\treturn FALSE;\n\n    \/\/ If the button press was used as the movement command for an operator\n    \/\/ (eg \"d<MOUSE>\"), or it is the middle button that is held down, ignore\n    \/\/ drag\/release events.\n    if (!is_click && which_button == MOUSE_MIDDLE)\n\treturn FALSE;\n\n    if (oap != NULL)\n\tregname = oap->regname;\n    else\n\tregname = 0;\n\n    \/\/ Middle mouse button does a 'put' of the selected text\n    if (which_button == MOUSE_MIDDLE)\n    {\n\tif (State == MODE_NORMAL)\n\t{\n\t    \/\/ If an operator was pending, we don't know what the user wanted\n\t    \/\/ to do. Go back to normal mode: Clear the operator and beep().\n\t    if (oap != NULL && oap->op_type != OP_NOP)\n\t    {\n\t\tclearopbeep(oap);\n\t\treturn FALSE;\n\t    }\n\n\t    \/\/ If visual was active, yank the highlighted text and put it\n\t    \/\/ before the mouse pointer position.\n\t    \/\/ In Select mode replace the highlighted text with the clipboard.\n\t    if (VIsual_active)\n\t    {\n\t\tif (VIsual_select)\n\t\t{\n\t\t    stuffcharReadbuff(Ctrl_G);\n\t\t    stuffReadbuff((char_u *)\"\\\"+p\");\n\t\t}\n\t\telse\n\t\t{\n\t\t    stuffcharReadbuff('y');\n\t\t    stuffcharReadbuff(K_MIDDLEMOUSE);\n\t\t}\n\t\tdo_always = TRUE;\t\/\/ ignore 'mouse' setting next time\n\t\treturn FALSE;\n\t    }\n\t    \/\/ The rest is below jump_to_mouse()\n\t}\n\n\telse if ((State & MODE_INSERT) == 0)\n\t    return FALSE;\n\n\t\/\/ Middle click in insert mode doesn't move the mouse, just insert the\n\t\/\/ contents of a register.  '.' register is special, can't insert that\n\t\/\/ with do_put().\n\t\/\/ Also paste at the cursor if the current mode isn't in 'mouse' (only\n\t\/\/ happens for the GUI).\n\tif ((State & MODE_INSERT) || !mouse_has(MOUSE_NORMAL))\n\t{\n\t    if (regname == '.')\n\t\tinsert_reg(regname, TRUE);\n\t    else\n\t    {\n#ifdef FEAT_CLIPBOARD\n\t\tif (clip_star.available && regname == 0)\n\t\t    regname = '*';\n#endif\n\t\tif ((State & REPLACE_FLAG) && !yank_register_mline(regname))\n\t\t    insert_reg(regname, TRUE);\n\t\telse\n\t\t{\n\t\t    do_put(regname, NULL, BACKWARD, 1L,\n\t\t\t\t\t\t      fixindent | PUT_CURSEND);\n\n\t\t    \/\/ Repeat it with CTRL-R CTRL-O r or CTRL-R CTRL-P r\n\t\t    AppendCharToRedobuff(Ctrl_R);\n\t\t    AppendCharToRedobuff(fixindent ? Ctrl_P : Ctrl_O);\n\t\t    AppendCharToRedobuff(regname == 0 ? '\"' : regname);\n\t\t}\n\t    }\n\t    return FALSE;\n\t}\n    }\n\n    \/\/ When dragging or button-up stay in the same window.\n    if (!is_click)\n\tjump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE;\n\n    start_visual.lnum = 0;\n\n    if (TabPageIdxs != NULL)  \/\/ only when initialized\n    {\n\t\/\/ Check for clicking in the tab page line.\n\tif (mouse_row == 0 && firstwin->w_winrow > 0)\n\t{\n\t    if (is_drag)\n\t    {\n\t\tif (in_tab_line)\n\t\t{\n\t\t    c1 = TabPageIdxs[mouse_col];\n\t\t    tabpage_move(c1 <= 0 ? 9999 : c1 < tabpage_index(curtab)\n\t\t\t\t\t\t\t\t    ? c1 - 1 : c1);\n\t\t}\n\t\treturn FALSE;\n\t    }\n\n\t    \/\/ click in a tab selects that tab page\n\t    if (is_click\n# ifdef FEAT_CMDWIN\n\t\t    && cmdwin_type == 0\n# endif\n\t\t    && mouse_col < Columns)\n\t    {\n\t\tin_tab_line = TRUE;\n\t\tc1 = TabPageIdxs[mouse_col];\n\t\tif (c1 >= 0)\n\t\t{\n\t\t    if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t\t    {\n\t\t\t\/\/ double click opens new page\n\t\t\tend_visual_mode_keep_button();\n\t\t\ttabpage_new();\n\t\t\ttabpage_move(c1 == 0 ? 9999 : c1 - 1);\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\t\/\/ Go to specified tab page, or next one if not clicking\n\t\t\t\/\/ on a label.\n\t\t\tgoto_tabpage(c1);\n\n\t\t\t\/\/ It's like clicking on the status line of a window.\n\t\t\tif (curwin != old_curwin)\n\t\t\t    end_visual_mode_keep_button();\n\t\t    }\n\t\t}\n\t\telse\n\t\t{\n\t\t    tabpage_T\t*tp;\n\n\t\t    \/\/ Close the current or specified tab page.\n\t\t    if (c1 == -999)\n\t\t\ttp = curtab;\n\t\t    else\n\t\t\ttp = find_tabpage(-c1);\n\t\t    if (tp == curtab)\n\t\t    {\n\t\t\tif (first_tabpage->tp_next != NULL)\n\t\t\t    tabpage_close(FALSE);\n\t\t    }\n\t\t    else if (tp != NULL)\n\t\t\ttabpage_close_other(tp, FALSE);\n\t\t}\n\t    }\n\t    return TRUE;\n\t}\n\telse if (is_drag && in_tab_line)\n\t{\n\t    c1 = TabPageIdxs[mouse_col];\n\t    tabpage_move(c1 <= 0 ? 9999 : c1 - 1);\n\t    return FALSE;\n\t}\n    }\n\n    \/\/ When 'mousemodel' is \"popup\" or \"popup_setpos\", translate mouse events:\n    \/\/ right button up   -> pop-up menu\n    \/\/ shift-left button -> right button\n    \/\/ alt-left button   -> alt-right button\n    if (mouse_model_popup())\n    {\n\tif (which_button == MOUSE_RIGHT\n\t\t\t    && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))\n\t{\n#ifdef USE_POPUP_SETPOS\n# ifdef FEAT_GUI\n\t    if (gui.in_use)\n\t    {\n#  if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \\\n\t\t\t  || defined(FEAT_GUI_PHOTON)\n\t\tif (!is_click)\n\t\t    \/\/ Ignore right button release events, only shows the popup\n\t\t    \/\/ menu on the button down event.\n\t\t    return FALSE;\n#  endif\n#  if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU)\n\t\tif (is_click || is_drag)\n\t\t    \/\/ Ignore right button down and drag mouse events.  Windows\n\t\t    \/\/ only shows the popup menu on the button up event.\n\t\t    return FALSE;\n#  endif\n\t    }\n# endif\n# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)\n\t    else\n# endif\n# if defined(FEAT_TERM_POPUP_MENU)\n\t    if (!is_click)\n\t\t\/\/ Ignore right button release events, only shows the popup\n\t\t\/\/ menu on the button down event.\n\t\treturn FALSE;\n#endif\n\n\t    jump_flags = 0;\n\t    if (STRCMP(p_mousem, \"popup_setpos\") == 0)\n\t    {\n\t\t\/\/ First set the cursor position before showing the popup\n\t\t\/\/ menu.\n\t\tif (VIsual_active)\n\t\t{\n\t\t    pos_T    m_pos;\n\n\t\t    \/\/ set MOUSE_MAY_STOP_VIS if we are outside the\n\t\t    \/\/ selection or the current window (might have false\n\t\t    \/\/ negative here)\n\t\t    if (mouse_row < curwin->w_winrow\n\t\t\t || mouse_row\n\t\t\t\t  > (curwin->w_winrow + curwin->w_height))\n\t\t\tjump_flags = MOUSE_MAY_STOP_VIS;\n\t\t    else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER)\n\t\t\tjump_flags = MOUSE_MAY_STOP_VIS;\n\t\t    else\n\t\t    {\n\t\t\tif ((LT_POS(curwin->w_cursor, VIsual)\n\t\t\t\t    && (LT_POS(m_pos, curwin->w_cursor)\n\t\t\t\t\t|| LT_POS(VIsual, m_pos)))\n\t\t\t\t|| (LT_POS(VIsual, curwin->w_cursor)\n\t\t\t\t    && (LT_POS(m_pos, VIsual)\n\t\t\t\t      || LT_POS(curwin->w_cursor, m_pos))))\n\t\t\t{\n\t\t\t    jump_flags = MOUSE_MAY_STOP_VIS;\n\t\t\t}\n\t\t\telse if (VIsual_mode == Ctrl_V)\n\t\t\t{\n\t\t\t    getvcols(curwin, &curwin->w_cursor, &VIsual,\n\t\t\t\t\t\t     &leftcol, &rightcol);\n\t\t\t    getvcol(curwin, &m_pos, NULL, &m_pos.col, NULL);\n\t\t\t    if (m_pos.col < leftcol || m_pos.col > rightcol)\n\t\t\t\tjump_flags = MOUSE_MAY_STOP_VIS;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse\n\t\t    jump_flags = MOUSE_MAY_STOP_VIS;\n\t    }\n\t    if (jump_flags)\n\t    {\n\t\tjump_flags = jump_to_mouse(jump_flags, NULL, which_button);\n\t\tupdate_curbuf(VIsual_active ? UPD_INVERTED : UPD_VALID);\n\t\tsetcursor();\n\t\tout_flush();    \/\/ Update before showing popup menu\n\t    }\n# ifdef FEAT_MENU\n\t    show_popupmenu();\n\t    got_click = FALSE;\t\/\/ ignore release events\n# endif\n\t    return (jump_flags & CURSOR_MOVED) != 0;\n#else\n\t    return FALSE;\n#endif\n\t}\n\tif (which_button == MOUSE_LEFT\n\t\t\t\t&& (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT)))\n\t{\n\t    which_button = MOUSE_RIGHT;\n\t    mod_mask &= ~MOD_MASK_SHIFT;\n\t}\n    }\n\n    if ((State & (MODE_NORMAL | MODE_INSERT))\n\t\t\t    && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))\n    {\n\tif (which_button == MOUSE_LEFT)\n\t{\n\t    if (is_click)\n\t    {\n\t\t\/\/ stop Visual mode for a left click in a window, but not when\n\t\t\/\/ on a status line\n\t\tif (VIsual_active)\n\t\t    jump_flags |= MOUSE_MAY_STOP_VIS;\n\t    }\n\t    else if (mouse_has(MOUSE_VISUAL))\n\t\tjump_flags |= MOUSE_MAY_VIS;\n\t}\n\telse if (which_button == MOUSE_RIGHT)\n\t{\n\t    if (is_click && VIsual_active)\n\t    {\n\t\t\/\/ Remember the start and end of visual before moving the\n\t\t\/\/ cursor.\n\t\tif (LT_POS(curwin->w_cursor, VIsual))\n\t\t{\n\t\t    start_visual = curwin->w_cursor;\n\t\t    end_visual = VIsual;\n\t\t}\n\t\telse\n\t\t{\n\t\t    start_visual = VIsual;\n\t\t    end_visual = curwin->w_cursor;\n\t\t}\n\t    }\n\t    jump_flags |= MOUSE_FOCUS;\n\t    if (mouse_has(MOUSE_VISUAL))\n\t\tjump_flags |= MOUSE_MAY_VIS;\n\t}\n    }\n\n    \/\/ If an operator is pending, ignore all drags and releases until the\n    \/\/ next mouse click.\n    if (!is_drag && oap != NULL && oap->op_type != OP_NOP)\n    {\n\tgot_click = FALSE;\n\toap->motion_type = MCHAR;\n    }\n\n    \/\/ When releasing the button let jump_to_mouse() know.\n    if (!is_click && !is_drag)\n\tjump_flags |= MOUSE_RELEASED;\n\n    \/\/ JUMP!\n    jump_flags = jump_to_mouse(jump_flags,\n\t\t\toap == NULL ? NULL : &(oap->inclusive), which_button);\n\n#ifdef FEAT_MENU\n    \/\/ A click in the window toolbar has no side effects.\n    if (jump_flags & MOUSE_WINBAR)\n\treturn FALSE;\n#endif\n    moved = (jump_flags & CURSOR_MOVED);\n    in_status_line = (jump_flags & IN_STATUS_LINE);\n    in_sep_line = (jump_flags & IN_SEP_LINE);\n\n#ifdef FEAT_NETBEANS_INTG\n    if (isNetbeansBuffer(curbuf)\n\t\t\t    && !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE)))\n    {\n\tint key = KEY2TERMCAP1(c);\n\n\tif (key == (int)KE_LEFTRELEASE || key == (int)KE_MIDDLERELEASE\n\t\t\t\t\t       || key == (int)KE_RIGHTRELEASE)\n\t    netbeans_button_release(which_button);\n    }\n#endif\n\n    \/\/ When jumping to another window, clear a pending operator.  That's a bit\n    \/\/ friendlier than beeping and not jumping to that window.\n    if (curwin != old_curwin && oap != NULL && oap->op_type != OP_NOP)\n\tclearop(oap);\n\n#ifdef FEAT_FOLDING\n    if (mod_mask == 0\n\t    && !is_drag\n\t    && (jump_flags & (MOUSE_FOLD_CLOSE | MOUSE_FOLD_OPEN))\n\t    && which_button == MOUSE_LEFT)\n    {\n\t\/\/ open or close a fold at this line\n\tif (jump_flags & MOUSE_FOLD_OPEN)\n\t    openFold(curwin->w_cursor.lnum, 1L);\n\telse\n\t    closeFold(curwin->w_cursor.lnum, 1L);\n\t\/\/ don't move the cursor if still in the same window\n\tif (curwin == old_curwin)\n\t    curwin->w_cursor = save_cursor;\n    }\n#endif\n\n#if defined(FEAT_CLIPBOARD) && defined(FEAT_CMDWIN)\n    if ((jump_flags & IN_OTHER_WIN) && !VIsual_active && clip_star.available)\n    {\n\tclip_modeless(which_button, is_click, is_drag);\n\treturn FALSE;\n    }\n#endif\n\n    \/\/ Set global flag that we are extending the Visual area with mouse\n    \/\/ dragging; temporarily minimize 'scrolloff'.\n    if (VIsual_active && is_drag && get_scrolloff_value())\n    {\n\t\/\/ In the very first line, allow scrolling one line\n\tif (mouse_row == 0)\n\t    mouse_dragging = 2;\n\telse\n\t    mouse_dragging = 1;\n    }\n\n    \/\/ When dragging the mouse above the window, scroll down.\n    if (is_drag && mouse_row < 0 && !in_status_line)\n    {\n\tscroll_redraw(FALSE, 1L);\n\tmouse_row = 0;\n    }\n\n    if (start_visual.lnum)\t\t\/\/ right click in visual mode\n    {\n       \/\/ When ALT is pressed make Visual mode blockwise.\n       if (mod_mask & MOD_MASK_ALT)\n\t   VIsual_mode = Ctrl_V;\n\n\t\/\/ In Visual-block mode, divide the area in four, pick up the corner\n\t\/\/ that is in the quarter that the cursor is in.\n\tif (VIsual_mode == Ctrl_V)\n\t{\n\t    getvcols(curwin, &start_visual, &end_visual, &leftcol, &rightcol);\n\t    if (curwin->w_curswant > (leftcol + rightcol) \/ 2)\n\t\tend_visual.col = leftcol;\n\t    else\n\t\tend_visual.col = rightcol;\n\t    if (curwin->w_cursor.lnum >=\n\t\t\t\t    (start_visual.lnum + end_visual.lnum) \/ 2)\n\t\tend_visual.lnum = start_visual.lnum;\n\n\t    \/\/ move VIsual to the right column\n\t    start_visual = curwin->w_cursor;\t    \/\/ save the cursor pos\n\t    curwin->w_cursor = end_visual;\n\t    coladvance(end_visual.col);\n\t    VIsual = curwin->w_cursor;\n\t    curwin->w_cursor = start_visual;\t    \/\/ restore the cursor\n\t}\n\telse\n\t{\n\t    \/\/ If the click is before the start of visual, change the start.\n\t    \/\/ If the click is after the end of visual, change the end.  If\n\t    \/\/ the click is inside the visual, change the closest side.\n\t    if (LT_POS(curwin->w_cursor, start_visual))\n\t\tVIsual = end_visual;\n\t    else if (LT_POS(end_visual, curwin->w_cursor))\n\t\tVIsual = start_visual;\n\t    else\n\t    {\n\t\t\/\/ In the same line, compare column number\n\t\tif (end_visual.lnum == start_visual.lnum)\n\t\t{\n\t\t    if (curwin->w_cursor.col - start_visual.col >\n\t\t\t\t    end_visual.col - curwin->w_cursor.col)\n\t\t\tVIsual = start_visual;\n\t\t    else\n\t\t\tVIsual = end_visual;\n\t\t}\n\n\t\t\/\/ In different lines, compare line number\n\t\telse\n\t\t{\n\t\t    diff = (curwin->w_cursor.lnum - start_visual.lnum) -\n\t\t\t\t(end_visual.lnum - curwin->w_cursor.lnum);\n\n\t\t    if (diff > 0)\t\t\/\/ closest to end\n\t\t\tVIsual = start_visual;\n\t\t    else if (diff < 0)\t\/\/ closest to start\n\t\t\tVIsual = end_visual;\n\t\t    else\t\t\t\/\/ in the middle line\n\t\t    {\n\t\t\tif (curwin->w_cursor.col <\n\t\t\t\t\t(start_visual.col + end_visual.col) \/ 2)\n\t\t\t    VIsual = end_visual;\n\t\t\telse\n\t\t\t    VIsual = start_visual;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n    \/\/ If Visual mode started in insert mode, execute \"CTRL-O\"\n    else if ((State & MODE_INSERT) && VIsual_active)\n\tstuffcharReadbuff(Ctrl_O);\n\n    \/\/ Middle mouse click: Put text before cursor.\n    if (which_button == MOUSE_MIDDLE)\n    {\n#ifdef FEAT_CLIPBOARD\n\tif (clip_star.available && regname == 0)\n\t    regname = '*';\n#endif\n\tif (yank_register_mline(regname))\n\t{\n\t    if (mouse_past_bottom)\n\t\tdir = FORWARD;\n\t}\n\telse if (mouse_past_eol)\n\t    dir = FORWARD;\n\n\tif (fixindent)\n\t{\n\t    c1 = (dir == BACKWARD) ? '[' : ']';\n\t    c2 = 'p';\n\t}\n\telse\n\t{\n\t    c1 = (dir == FORWARD) ? 'p' : 'P';\n\t    c2 = NUL;\n\t}\n\tprep_redo(regname, count, NUL, c1, NUL, c2, NUL);\n\n\t\/\/ Remember where the paste started, so in edit() Insstart can be set\n\t\/\/ to this position\n\tif (restart_edit != 0)\n\t    where_paste_started = curwin->w_cursor;\n\tdo_put(regname, NULL, dir, count, fixindent | PUT_CURSEND);\n    }\n\n#if defined(FEAT_QUICKFIX)\n    \/\/ Ctrl-Mouse click or double click in a quickfix window jumps to the\n    \/\/ error under the mouse pointer.\n    else if (((mod_mask & MOD_MASK_CTRL)\n\t\t|| (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t    && bt_quickfix(curbuf))\n    {\n\tif (curwin->w_llist_ref == NULL)\t\/\/ quickfix window\n\t    do_cmdline_cmd((char_u *)\".cc\");\n\telse\t\t\t\t\t\/\/ location list window\n\t    do_cmdline_cmd((char_u *)\".ll\");\n\tgot_click = FALSE;\t\t\/\/ ignore drag&release now\n    }\n#endif\n\n    \/\/ Ctrl-Mouse click (or double click in a help window) jumps to the tag\n    \/\/ under the mouse pointer.\n    else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help\n\t\t     && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK))\n    {\n\tif (State & MODE_INSERT)\n\t    stuffcharReadbuff(Ctrl_O);\n\tstuffcharReadbuff(Ctrl_RSB);\n\tgot_click = FALSE;\t\t\/\/ ignore drag&release now\n    }\n\n    \/\/ Shift-Mouse click searches for the next occurrence of the word under\n    \/\/ the mouse pointer\n    else if ((mod_mask & MOD_MASK_SHIFT))\n    {\n\tif ((State & MODE_INSERT) || (VIsual_active && VIsual_select))\n\t    stuffcharReadbuff(Ctrl_O);\n\tif (which_button == MOUSE_LEFT)\n\t    stuffcharReadbuff('*');\n\telse\t\/\/ MOUSE_RIGHT\n\t    stuffcharReadbuff('#');\n    }\n\n    \/\/ Handle double clicks, unless on status line\n    else if (in_status_line)\n    {\n#ifdef FEAT_MOUSESHAPE\n\tif ((is_drag || is_click) && !drag_status_line)\n\t{\n\t    drag_status_line = TRUE;\n\t    update_mouseshape(-1);\n\t}\n#endif\n    }\n    else if (in_sep_line)\n    {\n#ifdef FEAT_MOUSESHAPE\n\tif ((is_drag || is_click) && !drag_sep_line)\n\t{\n\t    drag_sep_line = TRUE;\n\t    update_mouseshape(-1);\n\t}\n#endif\n    }\n    else if ((mod_mask & MOD_MASK_MULTI_CLICK)\n\t\t\t\t       && (State & (MODE_NORMAL | MODE_INSERT))\n\t     && mouse_has(MOUSE_VISUAL))\n    {\n\tif (is_click || !VIsual_active)\n\t{\n\t    if (VIsual_active)\n\t\torig_cursor = VIsual;\n\t    else\n\t    {\n\t\tcheck_visual_highlight();\n\t\tVIsual = curwin->w_cursor;\n\t\torig_cursor = VIsual;\n\t\tVIsual_active = TRUE;\n\t\tVIsual_reselect = TRUE;\n\t\t\/\/ start Select mode if 'selectmode' contains \"mouse\"\n\t\tmay_start_select('o');\n\t\tsetmouse();\n\t    }\n\t    if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t    {\n\t\t\/\/ Double click with ALT pressed makes it blockwise.\n\t\tif (mod_mask & MOD_MASK_ALT)\n\t\t    VIsual_mode = Ctrl_V;\n\t\telse\n\t\t    VIsual_mode = 'v';\n\t    }\n\t    else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_3CLICK)\n\t\tVIsual_mode = 'V';\n\t    else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_4CLICK)\n\t\tVIsual_mode = Ctrl_V;\n#ifdef FEAT_CLIPBOARD\n\t    \/\/ Make sure the clipboard gets updated.  Needed because start and\n\t    \/\/ end may still be the same, and the selection needs to be owned\n\t    clip_star.vmode = NUL;\n#endif\n\t}\n\t\/\/ A double click selects a word or a block.\n\tif ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)\n\t{\n\t    pos_T\t*pos = NULL;\n\t    int\t\tgc;\n\n\t    if (is_click)\n\t    {\n\t\t\/\/ If the character under the cursor (skipping white space) is\n\t\t\/\/ not a word character, try finding a match and select a (),\n\t\t\/\/ {}, [], #if\/#endif, etc. block.\n\t\tend_visual = curwin->w_cursor;\n\t\twhile (gc = gchar_pos(&end_visual), VIM_ISWHITE(gc))\n\t\t    inc(&end_visual);\n\t\tif (oap != NULL)\n\t\t    oap->motion_type = MCHAR;\n\t\tif (oap != NULL\n\t\t\t&& VIsual_mode == 'v'\n\t\t\t&& !vim_iswordc(gchar_pos(&end_visual))\n\t\t\t&& EQUAL_POS(curwin->w_cursor, VIsual)\n\t\t\t&& (pos = findmatch(oap, NUL)) != NULL)\n\t\t{\n\t\t    curwin->w_cursor = *pos;\n\t\t    if (oap->motion_type == MLINE)\n\t\t\tVIsual_mode = 'V';\n\t\t    else if (*p_sel == 'e')\n\t\t    {\n\t\t\tif (LT_POS(curwin->w_cursor, VIsual))\n\t\t\t    ++VIsual.col;\n\t\t\telse\n\t\t\t    ++curwin->w_cursor.col;\n\t\t    }\n\t\t}\n\t    }\n\n\t    if (pos == NULL && (is_click || is_drag))\n\t    {\n\t\t\/\/ When not found a match or when dragging: extend to include\n\t\t\/\/ a word.\n\t\tif (LT_POS(curwin->w_cursor, orig_cursor))\n\t\t{\n\t\t    find_start_of_word(&curwin->w_cursor);\n\t\t    find_end_of_word(&VIsual);\n\t\t}\n\t\telse\n\t\t{\n\t\t    find_start_of_word(&VIsual);\n\t\t    if (*p_sel == 'e' && *ml_get_cursor() != NUL)\n\t\t\tcurwin->w_cursor.col +=\n\t\t\t\t\t (*mb_ptr2len)(ml_get_cursor());\n\t\t    find_end_of_word(&curwin->w_cursor);\n\t\t}\n\t    }\n\t    curwin->w_set_curswant = TRUE;\n\t}\n\tif (is_click)\n\t    redraw_curbuf_later(UPD_INVERTED);\t\/\/ update the inversion\n    }\n    else if (VIsual_active && !old_active)\n    {\n\tif (mod_mask & MOD_MASK_ALT)\n\t    VIsual_mode = Ctrl_V;\n\telse\n\t    VIsual_mode = 'v';\n    }\n\n    \/\/ If Visual mode changed show it later.\n    if ((!VIsual_active && old_active && mode_displayed)\n\t    || (VIsual_active && p_smd && msg_silent == 0\n\t\t\t\t && (!old_active || VIsual_mode != old_mode)))\n\tredraw_cmdline = TRUE;\n\n    return moved;\n}","target":0,"code_token_length":6548,"total_token_length":6784,"max_tokens_setting":8192}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..5b24ffe632b11559370b8babcaa739d7e1b4f956
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d063750c41c25216afa44e2877ef968082793a7b3b4a1239186c0ab0b6801e27
+size 484839
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..9a53661383b2771de592f1b64c812128246bb725
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.jsonl
@@ -0,0 +1,24 @@
+{"idx":194963,"func":"static MagickBooleanType GetEXIFProperty(const Image *image,\n  const char *property)\n{\n#define MaxDirectoryStack  16\n#define EXIF_DELIMITER  \"\\n\"\n#define EXIF_NUM_FORMATS  12\n#define EXIF_FMT_BYTE  1\n#define EXIF_FMT_STRING  2\n#define EXIF_FMT_USHORT  3\n#define EXIF_FMT_ULONG  4\n#define EXIF_FMT_URATIONAL  5\n#define EXIF_FMT_SBYTE  6\n#define EXIF_FMT_UNDEFINED  7\n#define EXIF_FMT_SSHORT  8\n#define EXIF_FMT_SLONG  9\n#define EXIF_FMT_SRATIONAL  10\n#define EXIF_FMT_SINGLE  11\n#define EXIF_FMT_DOUBLE  12\n#define TAG_EXIF_OFFSET  0x8769\n#define TAG_GPS_OFFSET  0x8825\n#define TAG_INTEROP_OFFSET  0xa005\n\n#define EXIFMultipleValues(size,format,arg) \\\n{ \\\n   ssize_t \\\n     component; \\\n \\\n   size_t \\\n     length; \\\n \\\n   unsigned char \\\n     *p1; \\\n \\\n   length=0; \\\n   p1=p; \\\n   for (component=0; component < components; component++) \\\n   { \\\n     length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \\\n       format\", \",arg); \\\n     if (length >= (MaxTextExtent-1)) \\\n       length=MaxTextExtent-1; \\\n     p1+=size; \\\n   } \\\n   if (length > 1) \\\n     buffer[length-2]='\\0'; \\\n   value=AcquireString(buffer); \\\n}\n\n#define EXIFMultipleFractions(size,format,arg1,arg2) \\\n{ \\\n   ssize_t \\\n     component; \\\n \\\n   size_t \\\n     length; \\\n \\\n   unsigned char \\\n     *p1; \\\n \\\n   length=0; \\\n   p1=p; \\\n   for (component=0; component < components; component++) \\\n   { \\\n     length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \\\n       format\", \",(arg1),(arg2)); \\\n     if (length >= (MaxTextExtent-1)) \\\n       length=MaxTextExtent-1; \\\n     p1+=size; \\\n   } \\\n   if (length > 1) \\\n     buffer[length-2]='\\0'; \\\n   value=AcquireString(buffer); \\\n}\n\n  typedef struct _DirectoryInfo\n  {\n    const unsigned char\n      *directory;\n\n    size_t\n      entry;\n\n    ssize_t\n      offset;\n  } DirectoryInfo;\n\n  typedef struct _TagInfo\n  {\n    size_t\n      tag;\n\n    const char\n      description[36];\n  } TagInfo;\n\n  static const TagInfo\n    EXIFTag[] =\n    {\n      {  0x001, \"exif:InteroperabilityIndex\" },\n      {  0x002, \"exif:InteroperabilityVersion\" },\n      {  0x100, \"exif:ImageWidth\" },\n      {  0x101, \"exif:ImageLength\" },\n      {  0x102, \"exif:BitsPerSample\" },\n      {  0x103, \"exif:Compression\" },\n      {  0x106, \"exif:PhotometricInterpretation\" },\n      {  0x10a, \"exif:FillOrder\" },\n      {  0x10d, \"exif:DocumentName\" },\n      {  0x10e, \"exif:ImageDescription\" },\n      {  0x10f, \"exif:Make\" },\n      {  0x110, \"exif:Model\" },\n      {  0x111, \"exif:StripOffsets\" },\n      {  0x112, \"exif:Orientation\" },\n      {  0x115, \"exif:SamplesPerPixel\" },\n      {  0x116, \"exif:RowsPerStrip\" },\n      {  0x117, \"exif:StripByteCounts\" },\n      {  0x11a, \"exif:XResolution\" },\n      {  0x11b, \"exif:YResolution\" },\n      {  0x11c, \"exif:PlanarConfiguration\" },\n      {  0x11d, \"exif:PageName\" },\n      {  0x11e, \"exif:XPosition\" },\n      {  0x11f, \"exif:YPosition\" },\n      {  0x118, \"exif:MinSampleValue\" },\n      {  0x119, \"exif:MaxSampleValue\" },\n      {  0x120, \"exif:FreeOffsets\" },\n      {  0x121, \"exif:FreeByteCounts\" },\n      {  0x122, \"exif:GrayResponseUnit\" },\n      {  0x123, \"exif:GrayResponseCurve\" },\n      {  0x124, \"exif:T4Options\" },\n      {  0x125, \"exif:T6Options\" },\n      {  0x128, \"exif:ResolutionUnit\" },\n      {  0x12d, \"exif:TransferFunction\" },\n      {  0x131, \"exif:Software\" },\n      {  0x132, \"exif:DateTime\" },\n      {  0x13b, \"exif:Artist\" },\n      {  0x13e, \"exif:WhitePoint\" },\n      {  0x13f, \"exif:PrimaryChromaticities\" },\n      {  0x140, \"exif:ColorMap\" },\n      {  0x141, \"exif:HalfToneHints\" },\n      {  0x142, \"exif:TileWidth\" },\n      {  0x143, \"exif:TileLength\" },\n      {  0x144, \"exif:TileOffsets\" },\n      {  0x145, \"exif:TileByteCounts\" },\n      {  0x14a, \"exif:SubIFD\" },\n      {  0x14c, \"exif:InkSet\" },\n      {  0x14d, \"exif:InkNames\" },\n      {  0x14e, \"exif:NumberOfInks\" },\n      {  0x150, \"exif:DotRange\" },\n      {  0x151, \"exif:TargetPrinter\" },\n      {  0x152, \"exif:ExtraSample\" },\n      {  0x153, \"exif:SampleFormat\" },\n      {  0x154, \"exif:SMinSampleValue\" },\n      {  0x155, \"exif:SMaxSampleValue\" },\n      {  0x156, \"exif:TransferRange\" },\n      {  0x157, \"exif:ClipPath\" },\n      {  0x158, \"exif:XClipPathUnits\" },\n      {  0x159, \"exif:YClipPathUnits\" },\n      {  0x15a, \"exif:Indexed\" },\n      {  0x15b, \"exif:JPEGTables\" },\n      {  0x15f, \"exif:OPIProxy\" },\n      {  0x200, \"exif:JPEGProc\" },\n      {  0x201, \"exif:JPEGInterchangeFormat\" },\n      {  0x202, \"exif:JPEGInterchangeFormatLength\" },\n      {  0x203, \"exif:JPEGRestartInterval\" },\n      {  0x205, \"exif:JPEGLosslessPredictors\" },\n      {  0x206, \"exif:JPEGPointTransforms\" },\n      {  0x207, \"exif:JPEGQTables\" },\n      {  0x208, \"exif:JPEGDCTables\" },\n      {  0x209, \"exif:JPEGACTables\" },\n      {  0x211, \"exif:YCbCrCoefficients\" },\n      {  0x212, \"exif:YCbCrSubSampling\" },\n      {  0x213, \"exif:YCbCrPositioning\" },\n      {  0x214, \"exif:ReferenceBlackWhite\" },\n      {  0x2bc, \"exif:ExtensibleMetadataPlatform\" },\n      {  0x301, \"exif:Gamma\" },\n      {  0x302, \"exif:ICCProfileDescriptor\" },\n      {  0x303, \"exif:SRGBRenderingIntent\" },\n      {  0x320, \"exif:ImageTitle\" },\n      {  0x5001, \"exif:ResolutionXUnit\" },\n      {  0x5002, \"exif:ResolutionYUnit\" },\n      {  0x5003, \"exif:ResolutionXLengthUnit\" },\n      {  0x5004, \"exif:ResolutionYLengthUnit\" },\n      {  0x5005, \"exif:PrintFlags\" },\n      {  0x5006, \"exif:PrintFlagsVersion\" },\n      {  0x5007, \"exif:PrintFlagsCrop\" },\n      {  0x5008, \"exif:PrintFlagsBleedWidth\" },\n      {  0x5009, \"exif:PrintFlagsBleedWidthScale\" },\n      {  0x500A, \"exif:HalftoneLPI\" },\n      {  0x500B, \"exif:HalftoneLPIUnit\" },\n      {  0x500C, \"exif:HalftoneDegree\" },\n      {  0x500D, \"exif:HalftoneShape\" },\n      {  0x500E, \"exif:HalftoneMisc\" },\n      {  0x500F, \"exif:HalftoneScreen\" },\n      {  0x5010, \"exif:JPEGQuality\" },\n      {  0x5011, \"exif:GridSize\" },\n      {  0x5012, \"exif:ThumbnailFormat\" },\n      {  0x5013, \"exif:ThumbnailWidth\" },\n      {  0x5014, \"exif:ThumbnailHeight\" },\n      {  0x5015, \"exif:ThumbnailColorDepth\" },\n      {  0x5016, \"exif:ThumbnailPlanes\" },\n      {  0x5017, \"exif:ThumbnailRawBytes\" },\n      {  0x5018, \"exif:ThumbnailSize\" },\n      {  0x5019, \"exif:ThumbnailCompressedSize\" },\n      {  0x501a, \"exif:ColorTransferFunction\" },\n      {  0x501b, \"exif:ThumbnailData\" },\n      {  0x5020, \"exif:ThumbnailImageWidth\" },\n      {  0x5021, \"exif:ThumbnailImageHeight\" },\n      {  0x5022, \"exif:ThumbnailBitsPerSample\" },\n      {  0x5023, \"exif:ThumbnailCompression\" },\n      {  0x5024, \"exif:ThumbnailPhotometricInterp\" },\n      {  0x5025, \"exif:ThumbnailImageDescription\" },\n      {  0x5026, \"exif:ThumbnailEquipMake\" },\n      {  0x5027, \"exif:ThumbnailEquipModel\" },\n      {  0x5028, \"exif:ThumbnailStripOffsets\" },\n      {  0x5029, \"exif:ThumbnailOrientation\" },\n      {  0x502a, \"exif:ThumbnailSamplesPerPixel\" },\n      {  0x502b, \"exif:ThumbnailRowsPerStrip\" },\n      {  0x502c, \"exif:ThumbnailStripBytesCount\" },\n      {  0x502d, \"exif:ThumbnailResolutionX\" },\n      {  0x502e, \"exif:ThumbnailResolutionY\" },\n      {  0x502f, \"exif:ThumbnailPlanarConfig\" },\n      {  0x5030, \"exif:ThumbnailResolutionUnit\" },\n      {  0x5031, \"exif:ThumbnailTransferFunction\" },\n      {  0x5032, \"exif:ThumbnailSoftwareUsed\" },\n      {  0x5033, \"exif:ThumbnailDateTime\" },\n      {  0x5034, \"exif:ThumbnailArtist\" },\n      {  0x5035, \"exif:ThumbnailWhitePoint\" },\n      {  0x5036, \"exif:ThumbnailPrimaryChromaticities\" },\n      {  0x5037, \"exif:ThumbnailYCbCrCoefficients\" },\n      {  0x5038, \"exif:ThumbnailYCbCrSubsampling\" },\n      {  0x5039, \"exif:ThumbnailYCbCrPositioning\" },\n      {  0x503A, \"exif:ThumbnailRefBlackWhite\" },\n      {  0x503B, \"exif:ThumbnailCopyRight\" },\n      {  0x5090, \"exif:LuminanceTable\" },\n      {  0x5091, \"exif:ChrominanceTable\" },\n      {  0x5100, \"exif:FrameDelay\" },\n      {  0x5101, \"exif:LoopCount\" },\n      {  0x5110, \"exif:PixelUnit\" },\n      {  0x5111, \"exif:PixelPerUnitX\" },\n      {  0x5112, \"exif:PixelPerUnitY\" },\n      {  0x5113, \"exif:PaletteHistogram\" },\n      {  0x1000, \"exif:RelatedImageFileFormat\" },\n      {  0x1001, \"exif:RelatedImageLength\" },\n      {  0x1002, \"exif:RelatedImageWidth\" },\n      {  0x800d, \"exif:ImageID\" },\n      {  0x80e3, \"exif:Matteing\" },\n      {  0x80e4, \"exif:DataType\" },\n      {  0x80e5, \"exif:ImageDepth\" },\n      {  0x80e6, \"exif:TileDepth\" },\n      {  0x828d, \"exif:CFARepeatPatternDim\" },\n      {  0x828e, \"exif:CFAPattern2\" },\n      {  0x828f, \"exif:BatteryLevel\" },\n      {  0x8298, \"exif:Copyright\" },\n      {  0x829a, \"exif:ExposureTime\" },\n      {  0x829d, \"exif:FNumber\" },\n      {  0x83bb, \"exif:IPTC\/NAA\" },\n      {  0x84e3, \"exif:IT8RasterPadding\" },\n      {  0x84e5, \"exif:IT8ColorTable\" },\n      {  0x8649, \"exif:ImageResourceInformation\" },\n      {  0x8769, \"exif:ExifOffset\" },  \/* specs as \"Exif IFD Pointer\"? *\/\n      {  0x8773, \"exif:InterColorProfile\" },\n      {  0x8822, \"exif:ExposureProgram\" },\n      {  0x8824, \"exif:SpectralSensitivity\" },\n      {  0x8825, \"exif:GPSInfo\" }, \/* specs as \"GPSInfo IFD Pointer\"? *\/\n      {  0x8827, \"exif:PhotographicSensitivity\" },\n      {  0x8828, \"exif:OECF\" },\n      {  0x8829, \"exif:Interlace\" },      \n      {  0x882a, \"exif:TimeZoneOffset\" },\n      {  0x882b, \"exif:SelfTimerMode\" },\n      {  0x8830, \"exif:SensitivityType\" },\n      {  0x8831, \"exif:StandardOutputSensitivity\" },\n      {  0x8832, \"exif:RecommendedExposureIndex\" },\n      {  0x8833, \"exif:ISOSpeed\" },\n      {  0x8834, \"exif:ISOSpeedLatitudeyyy\" },\n      {  0x8835, \"exif:ISOSpeedLatitudezzz\" },\n      {  0x9000, \"exif:ExifVersion\" },\n      {  0x9003, \"exif:DateTimeOriginal\" },\n      {  0x9004, \"exif:DateTimeDigitized\" },\n      {  0x9010, \"exif:OffsetTime\" },\n      {  0x9011, \"exif:OffsetTimeOriginal\" },\n      {  0x9012, \"exif:OffsetTimeDigitized\" },\n      {  0x9101, \"exif:ComponentsConfiguration\" },\n      {  0x9102, \"exif:CompressedBitsPerPixel\" },\n      {  0x9201, \"exif:ShutterSpeedValue\" },\n      {  0x9202, \"exif:ApertureValue\" },\n      {  0x9203, \"exif:BrightnessValue\" },\n      {  0x9204, \"exif:ExposureBiasValue\" },\n      {  0x9205, \"exif:MaxApertureValue\" },\n      {  0x9206, \"exif:SubjectDistance\" },\n      {  0x9207, \"exif:MeteringMode\" },\n      {  0x9208, \"exif:LightSource\" },\n      {  0x9209, \"exif:Flash\" },\n      {  0x920a, \"exif:FocalLength\" },\n      {  0x920b, \"exif:FlashEnergy\" },\n      {  0x920c, \"exif:SpatialFrequencyResponse\" },\n      {  0x920d, \"exif:Noise\" },\n      {  0x9214, \"exif:SubjectArea\" },\n      {  0x9290, \"exif:SubSecTime\" },\n      {  0x9291, \"exif:SubSecTimeOriginal\" },\n      {  0x9292, \"exif:SubSecTimeDigitized\" },    \n      {  0x9211, \"exif:ImageNumber\" },\n      {  0x9212, \"exif:SecurityClassification\" },\n      {  0x9213, \"exif:ImageHistory\" },\n      {  0x9214, \"exif:SubjectArea\" },\n      {  0x9215, \"exif:ExposureIndex\" },\n      {  0x9216, \"exif:TIFF-EPStandardID\" },\n      {  0x927c, \"exif:MakerNote\" },\n      {  0x9286, \"exif:UserComment\" },\n      {  0x9290, \"exif:SubSecTime\" },\n      {  0x9291, \"exif:SubSecTimeOriginal\" },\n      {  0x9292, \"exif:SubSecTimeDigitized\" },    \n      {  0x9400, \"exif:Temperature\" },\n      {  0x9401, \"exif:Humidity\" },\n      {  0x9402, \"exif:Pressure\" },\n      {  0x9403, \"exif:WaterDepth\" },\n      {  0x9404, \"exif:Acceleration\" },\n      {  0x9405, \"exif:CameraElevationAngle\" },    \n      {  0x9C9b, \"exif:WinXP-Title\" },\n      {  0x9C9c, \"exif:WinXP-Comments\" },\n      {  0x9C9d, \"exif:WinXP-Author\" },\n      {  0x9C9e, \"exif:WinXP-Keywords\" },\n      {  0x9C9f, \"exif:WinXP-Subject\" },      \n      {  0xa000, \"exif:FlashPixVersion\" },\n      {  0xa001, \"exif:ColorSpace\" },\n      {  0xa002, \"exif:PixelXDimension\" },\n      {  0xa003, \"exif:PixelYDimension\" },\n      {  0xa004, \"exif:RelatedSoundFile\" },\n      {  0xa005, \"exif:InteroperabilityOffset\" },\n      {  0xa20b, \"exif:FlashEnergy\" },\n      {  0xa20c, \"exif:SpatialFrequencyResponse\" },\n      {  0xa20d, \"exif:Noise\" },\n      {  0xa20e, \"exif:FocalPlaneXResolution\" },\n      {  0xa20f, \"exif:FocalPlaneYResolution\" },\n      {  0xa210, \"exif:FocalPlaneResolutionUnit\" },\n      {  0xa214, \"exif:SubjectLocation\" },\n      {  0xa215, \"exif:ExposureIndex\" },\n      {  0xa216, \"exif:TIFF\/EPStandardID\" },\n      {  0xa217, \"exif:SensingMethod\" },\n      {  0xa300, \"exif:FileSource\" },\n      {  0xa301, \"exif:SceneType\" },\n      {  0xa302, \"exif:CFAPattern\" },\n      {  0xa401, \"exif:CustomRendered\" },\n      {  0xa402, \"exif:ExposureMode\" },\n      {  0xa403, \"exif:WhiteBalance\" },\n      {  0xa404, \"exif:DigitalZoomRatio\" },\n      {  0xa405, \"exif:FocalLengthIn35mmFilm\" },\n      {  0xa406, \"exif:SceneCaptureType\" },\n      {  0xa407, \"exif:GainControl\" },\n      {  0xa408, \"exif:Contrast\" },\n      {  0xa409, \"exif:Saturation\" },\n      {  0xa40a, \"exif:Sharpness\" },\n      {  0xa40b, \"exif:DeviceSettingDescription\" },\n      {  0xa40c, \"exif:SubjectDistanceRange\" },\n      {  0xa420, \"exif:ImageUniqueID\" },\n      {  0xa430, \"exif:CameraOwnerName\" },\n      {  0xa431, \"exif:BodySerialNumber\" },\n      {  0xa432, \"exif:LensSpecification\" },\n      {  0xa433, \"exif:LensMake\" },\n      {  0xa434, \"exif:LensModel\" },\n      {  0xa435, \"exif:LensSerialNumber\" },\n      {  0xc4a5, \"exif:PrintImageMatching\" },\n      {  0xa500, \"exif:Gamma\" },\n      {  0xc640, \"exif:CR2Slice\" },\n      { 0x10000, \"exif:GPSVersionID\" },\n      { 0x10001, \"exif:GPSLatitudeRef\" },\n      { 0x10002, \"exif:GPSLatitude\" },\n      { 0x10003, \"exif:GPSLongitudeRef\" },\n      { 0x10004, \"exif:GPSLongitude\" },\n      { 0x10005, \"exif:GPSAltitudeRef\" },\n      { 0x10006, \"exif:GPSAltitude\" },\n      { 0x10007, \"exif:GPSTimeStamp\" },\n      { 0x10008, \"exif:GPSSatellites\" },\n      { 0x10009, \"exif:GPSStatus\" },\n      { 0x1000a, \"exif:GPSMeasureMode\" },\n      { 0x1000b, \"exif:GPSDop\" },\n      { 0x1000c, \"exif:GPSSpeedRef\" },\n      { 0x1000d, \"exif:GPSSpeed\" },\n      { 0x1000e, \"exif:GPSTrackRef\" },\n      { 0x1000f, \"exif:GPSTrack\" },\n      { 0x10010, \"exif:GPSImgDirectionRef\" },\n      { 0x10011, \"exif:GPSImgDirection\" },\n      { 0x10012, \"exif:GPSMapDatum\" },\n      { 0x10013, \"exif:GPSDestLatitudeRef\" },\n      { 0x10014, \"exif:GPSDestLatitude\" },\n      { 0x10015, \"exif:GPSDestLongitudeRef\" },\n      { 0x10016, \"exif:GPSDestLongitude\" },\n      { 0x10017, \"exif:GPSDestBearingRef\" },\n      { 0x10018, \"exif:GPSDestBearing\" },\n      { 0x10019, \"exif:GPSDestDistanceRef\" },\n      { 0x1001a, \"exif:GPSDestDistance\" },\n      { 0x1001b, \"exif:GPSProcessingMethod\" },\n      { 0x1001c, \"exif:GPSAreaInformation\" },\n      { 0x1001d, \"exif:GPSDateStamp\" },\n      { 0x1001e, \"exif:GPSDifferential\" },\n      { 0x1001f, \"exif:GPSHPositioningError\" },\n      { 0x00000, \"\" }\n    };  \/* http:\/\/www.cipa.jp\/std\/documents\/e\/DC-008-Translation-2016-E.pdf *\/\n\n  const StringInfo\n    *profile;\n\n  const unsigned char\n    *directory,\n    *exif;\n\n  DirectoryInfo\n    directory_stack[MaxDirectoryStack];\n\n  EndianType\n    endian;\n\n  MagickBooleanType\n    status;\n\n  ssize_t\n    i;\n\n  size_t\n    entry,\n    length,\n    number_entries,\n    tag,\n    tag_value;\n\n  SplayTreeInfo\n    *exif_resources;\n\n  ssize_t\n    all,\n    id,\n    level,\n    offset,\n    tag_offset;\n\n  static int\n    tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};\n\n  \/*\n    If EXIF data exists, then try to parse the request for a tag.\n  *\/\n  profile=GetImageProfile(image,\"exif\");\n  if (profile == (const StringInfo *) NULL)\n    return(MagickFalse);\n  if ((property == (const char *) NULL) || (*property == '\\0'))\n    return(MagickFalse);\n  while (isspace((int) ((unsigned char) *property)) != 0)\n    property++;\n  if (strlen(property) <= 5)\n    return(MagickFalse);\n  all=0;\n  tag=(~0UL);\n  switch (*(property+5))\n  {\n    case '*':\n    {\n      \/*\n        Caller has asked for all the tags in the EXIF data.\n      *\/\n      tag=0;\n      all=1; \/* return the data in description=value format *\/\n      break;\n    }\n    case '!':\n    {\n      tag=0;\n      all=2; \/* return the data in tagid=value format *\/\n      break;\n    }\n    case '#':\n    case '@':\n    {\n      int\n        c;\n\n      size_t\n        n;\n\n      \/*\n        Check for a hex based tag specification first.\n      *\/\n      tag=(*(property+5) == '@') ? 1UL : 0UL;\n      property+=6;\n      n=strlen(property);\n      if (n != 4)\n        return(MagickFalse);\n      \/*\n        Parse tag specification as a hex number.\n      *\/\n      n\/=4;\n      do\n      {\n        for (i=(ssize_t) n-1L; i >= 0; i--)\n        {\n          c=(*property++);\n          tag<<=4;\n          if ((c >= '0') && (c <= '9'))\n            tag|=(c-'0');\n          else\n            if ((c >= 'A') && (c <= 'F'))\n              tag|=(c-('A'-10));\n            else\n              if ((c >= 'a') && (c <= 'f'))\n                tag|=(c-('a'-10));\n              else\n                return(MagickFalse);\n        }\n      } while (*property != '\\0');\n      break;\n    }\n    default:\n    {\n      \/*\n        Try to match the text with a tag name instead.\n      *\/\n      for (i=0; ; i++)\n      {\n        if (EXIFTag[i].tag == 0)\n          break;\n        if (LocaleCompare(EXIFTag[i].description,property) == 0)\n          {\n            tag=(size_t) EXIFTag[i].tag;\n            break;\n          }\n      }\n      break;\n    }\n  }\n  if (tag == (~0UL))\n    return(MagickFalse);\n  length=GetStringInfoLength(profile);\n  if (length < 6)\n    return(MagickFalse);\n  exif=GetStringInfoDatum(profile);\n  while (length != 0)\n  {\n    if (ReadPropertyByte(&exif,&length) != 0x45)\n      continue;\n    if (ReadPropertyByte(&exif,&length) != 0x78)\n      continue;\n    if (ReadPropertyByte(&exif,&length) != 0x69)\n      continue;\n    if (ReadPropertyByte(&exif,&length) != 0x66)\n      continue;\n    if (ReadPropertyByte(&exif,&length) != 0x00)\n      continue;\n    if (ReadPropertyByte(&exif,&length) != 0x00)\n      continue;\n    break;\n  }\n  if (length < 16)\n    return(MagickFalse);\n  id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);\n  endian=LSBEndian;\n  if (id == 0x4949)\n    endian=LSBEndian;\n  else\n    if (id == 0x4D4D)\n      endian=MSBEndian;\n    else\n      return(MagickFalse);\n  if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)\n    return(MagickFalse);\n  \/*\n    This the offset to the first IFD.\n  *\/\n  offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);\n  if ((offset < 0) || (size_t) offset >= length)\n    return(MagickFalse);\n  \/*\n    Set the pointer to the first IFD and follow it were it leads.\n  *\/\n  status=MagickFalse;\n  directory=exif+offset;\n  level=0;\n  entry=0;\n  tag_offset=0;\n  exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,\n    (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);\n  do\n  {\n    \/*\n      If there is anything on the stack then pop it off.\n    *\/\n    if (level > 0)\n      {\n        level--;\n        directory=directory_stack[level].directory;\n        entry=directory_stack[level].entry;\n        tag_offset=directory_stack[level].offset;\n      }\n    if ((directory < exif) || (directory > (exif+length-2)))\n      break;\n    \/*\n      Determine how many entries there are in the current IFD.\n    *\/\n    number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);\n    for ( ; entry < number_entries; entry++)\n    {\n      unsigned char\n        *p,\n        *q;\n\n      size_t\n        format;\n\n      ssize_t\n        number_bytes,\n        components;\n\n      q=(unsigned char *) (directory+(12*entry)+2);\n      if (q > (exif+length-12))\n        break;  \/* corrupt EXIF *\/\n      if (GetValueFromSplayTree(exif_resources,q) == q)\n        break;\n      (void) AddValueToSplayTree(exif_resources,q,q);\n      tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;\n      format=(size_t) ReadPropertyUnsignedShort(endian,q+2);\n      if (format >= (sizeof(tag_bytes)\/sizeof(*tag_bytes)))\n        break;\n      if (format == 0)\n        break;  \/* corrupt EXIF *\/\n      components=(ssize_t) ReadPropertySignedLong(endian,q+4);\n      if (components < 0)\n        break;  \/* corrupt EXIF *\/\n      number_bytes=(size_t) components*tag_bytes[format];\n      if (number_bytes < components)\n        break;  \/* prevent overflow *\/\n      if (number_bytes <= 4)\n        p=q+8;\n      else\n        {\n          ssize_t\n            dir_offset;\n\n          \/*\n            The directory entry contains an offset.\n          *\/\n          dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);\n          if ((dir_offset < 0) || (size_t) dir_offset >= length)\n            continue;\n          if (((size_t) dir_offset+number_bytes) < (size_t) dir_offset)\n            continue;  \/* prevent overflow *\/\n          if (((size_t) dir_offset+number_bytes) > length)\n            continue;\n          p=(unsigned char *) (exif+dir_offset);\n        }\n      if ((all != 0) || (tag == (size_t) tag_value))\n        {\n          char\n            buffer[MaxTextExtent],\n            *value;\n\n          if ((p < exif) || (p > (exif+length-tag_bytes[format])))\n            break;\n          value=(char *) NULL;\n          *buffer='\\0';\n          switch (format)\n          {\n            case EXIF_FMT_BYTE:\n            case EXIF_FMT_UNDEFINED:\n            {\n              value=(char *) NULL;\n              if (~((size_t) number_bytes) >= 1)\n                value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,\n                  sizeof(*value));\n              if (value != (char *) NULL)\n                {\n                  for (i=0; i < (ssize_t) number_bytes; i++)\n                  {\n                    value[i]='.';\n                    if (isprint((int) p[i]) != 0) \n                      value[i]=(char) p[i];\n                  }\n                  value[i]='\\0';\n                }\n              break;\n            }\n            case EXIF_FMT_SBYTE:\n            {\n              EXIFMultipleValues(1,\"%.20g\",(double) (*(signed char *) p1));\n              break;\n            }\n            case EXIF_FMT_SSHORT:\n            {\n              EXIFMultipleValues(2,\"%hd\",ReadPropertySignedShort(endian,p1));\n              break;\n            }\n            case EXIF_FMT_USHORT:\n            {\n              EXIFMultipleValues(2,\"%hu\",ReadPropertyUnsignedShort(endian,p1));\n              break;\n            }\n            case EXIF_FMT_ULONG:\n            {\n              EXIFMultipleValues(4,\"%.20g\",(double)\n                ReadPropertyUnsignedLong(endian,p1));\n              break;\n            }\n            case EXIF_FMT_SLONG:\n            {\n              EXIFMultipleValues(4,\"%.20g\",(double)\n                ReadPropertySignedLong(endian,p1));\n              break;\n            }\n            case EXIF_FMT_URATIONAL:\n            {\n              EXIFMultipleFractions(8,\"%.20g\/%.20g\",(double)\n                ReadPropertyUnsignedLong(endian,p1),(double)\n                ReadPropertyUnsignedLong(endian,p1+4));\n              break;\n            }\n            case EXIF_FMT_SRATIONAL:\n            {\n              EXIFMultipleFractions(8,\"%.20g\/%.20g\",(double)\n                ReadPropertySignedLong(endian,p1),(double)\n                ReadPropertySignedLong(endian,p1+4));\n              break;\n            }\n            case EXIF_FMT_SINGLE:\n            {\n              EXIFMultipleValues(4,\"%f\",(double) *(float *) p1);\n              break;\n            }\n            case EXIF_FMT_DOUBLE:\n            {\n              EXIFMultipleValues(8,\"%f\",*(double *) p1);\n              break;\n            }\n            case EXIF_FMT_STRING:\n            default:\n            {\n              if ((p < exif) || (p > (exif+length-number_bytes)))\n                break;\n              value=(char *) NULL;\n              if (~((size_t) number_bytes) >= 1)\n                value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,\n                  sizeof(*value));\n              if (value != (char *) NULL)\n                {\n                  ssize_t\n                    i;\n\n                  for (i=0; i < (ssize_t) number_bytes; i++)\n                  {\n                    value[i]='.';\n                    if ((isprint((int) p[i]) != 0) || (p[i] == '\\0'))\n                      value[i]=(char) p[i];\n                  }\n                  value[i]='\\0';\n                }\n              break;\n            }\n          }\n          if (value != (char *) NULL)\n            {\n              char\n                *key;\n\n              const char\n                *p;\n\n              key=AcquireString(property);\n              switch (all)\n              {\n                case 1:\n                {\n                  const char\n                    *description;\n\n                  ssize_t\n                    i;\n\n                  description=\"unknown\";\n                  for (i=0; ; i++)\n                  {\n                    if (EXIFTag[i].tag == 0)\n                      break;\n                    if (EXIFTag[i].tag == tag_value)\n                      {\n                        description=EXIFTag[i].description;\n                        break;\n                      }\n                  }\n                  (void) FormatLocaleString(key,MaxTextExtent,\"%s\",\n                    description);\n                  if (level == 2)\n                    (void) SubstituteString(&key,\"exif:\",\"exif:thumbnail:\");\n                  break;\n                }\n                case 2:\n                {\n                  if (tag_value < 0x10000)\n                    (void) FormatLocaleString(key,MaxTextExtent,\"#%04lx\",\n                      (unsigned long) tag_value);\n                  else\n                    if (tag_value < 0x20000)\n                      (void) FormatLocaleString(key,MaxTextExtent,\"@%04lx\",\n                        (unsigned long) (tag_value & 0xffff));\n                    else\n                      (void) FormatLocaleString(key,MaxTextExtent,\"unknown\");\n                  break;\n                }\n                default:\n                {\n                  if (level == 2)\n                    (void) SubstituteString(&key,\"exif:\",\"exif:thumbnail:\");\n                }\n              }\n              p=(const char *) NULL;\n              if (image->properties != (void *) NULL)\n                p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)\n                  image->properties,key);\n              if (p == (const char *) NULL)\n                (void) SetImageProperty((Image *) image,key,value);\n              value=DestroyString(value);\n              key=DestroyString(key);\n              status=MagickTrue;\n            }\n        }\n        if ((tag_value == TAG_EXIF_OFFSET) ||\n            (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))\n          {\n            ssize_t\n              offset;\n\n            offset=(ssize_t) ReadPropertySignedLong(endian,p);\n            if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))\n              {\n                ssize_t\n                  tag_offset1;\n\n                tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :\n                  0);\n                directory_stack[level].directory=directory;\n                entry++;\n                directory_stack[level].entry=entry;\n                directory_stack[level].offset=tag_offset;\n                level++;\n                \/*\n                  Check for duplicate tag.\n                *\/\n                for (i=0; i < level; i++)\n                  if (directory_stack[i].directory == (exif+tag_offset1))\n                    break;\n                if (i < level)\n                  break;  \/* duplicate tag *\/\n                directory_stack[level].directory=exif+offset;\n                directory_stack[level].offset=tag_offset1;\n                directory_stack[level].entry=0;\n                level++;\n                if ((directory+2+(12*number_entries)+4) > (exif+length))\n                  break;\n                offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*\n                  number_entries));\n                if ((offset != 0) && ((size_t) offset < length) &&\n                    (level < (MaxDirectoryStack-2)))\n                  {\n                    directory_stack[level].directory=exif+offset;\n                    directory_stack[level].entry=0;\n                    directory_stack[level].offset=tag_offset1;\n                    level++;\n                  }\n              }\n            break;\n          }\n    }\n  } while (level > 0);\n  exif_resources=DestroySplayTree(exif_resources);\n  return(status);\n}","target":1,"code_token_length":9745,"total_token_length":9981,"max_tokens_setting":11000}
+{"idx":210692,"func":"static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  BMPInfo\n    bmp_info;\n\n  Image\n    *image;\n\n  IndexPacket\n    index;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    start_position;\n\n  MemoryInfo\n    *pixel_info;\n\n  register IndexPacket\n    *indexes;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *p;\n\n  size_t\n    bit,\n    bytes_per_line,\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    magick[12],\n    *pixels;\n\n  unsigned int\n    blue,\n    green,\n    offset_bits,\n    red;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Determine if this a BMP file.\n  *\/\n  (void) memset(&bmp_info,0,sizeof(bmp_info));\n  bmp_info.ba_offset=0;\n  start_position=0;\n  offset_bits=0;\n  count=ReadBlob(image,2,magick);\n  if (count != 2)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  do\n  {\n    LongPixelPacket\n      shift;\n\n    PixelPacket\n      quantum_bits;\n\n    \/*\n      Verify BMP identifier.\n    *\/\n    if (bmp_info.ba_offset == 0)\n      start_position=TellBlob(image)-2;\n    bmp_info.ba_offset=0;\n    while (LocaleNCompare((char *) magick,\"BA\",2) == 0)\n    {\n      bmp_info.file_size=ReadBlobLSBLong(image);\n      bmp_info.ba_offset=ReadBlobLSBLong(image);\n      bmp_info.offset_bits=ReadBlobLSBLong(image);\n      count=ReadBlob(image,2,magick);\n      if (count != 2)\n        break;\n    }\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  Magick: %c%c\",\n        magick[0],magick[1]);\n    if ((count != 2) || ((LocaleNCompare((char *) magick,\"BM\",2) != 0) &&\n        (LocaleNCompare((char *) magick,\"CI\",2) != 0)))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    bmp_info.file_size=ReadBlobLSBLong(image);\n    (void) ReadBlobLSBLong(image);\n\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n         \"  File_size in header:  %u bytes\",bmp_info.file_size);\n\n    bmp_info.offset_bits=ReadBlobLSBLong(image);\n    bmp_info.size=ReadBlobLSBLong(image);\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  BMP size: %u\",\n        bmp_info.size);\n    if (bmp_info.size == 12)\n      {\n        \/*\n          OS\/2 BMP image file.\n        *\/\n        (void) CopyMagickString(image->magick,\"BMP2\",MaxTextExtent);\n        bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.x_pixels=0;\n        bmp_info.y_pixels=0;\n        bmp_info.number_colors=0;\n        bmp_info.compression=BI_RGB;\n        bmp_info.image_size=0;\n        bmp_info.alpha_mask=0;\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: OS\/2 Bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n          }\n      }\n    else\n      {\n        \/*\n          Microsoft Windows BMP image file.\n        *\/\n        if (bmp_info.size < 40)\n          ThrowReaderException(CorruptImageError,\"NonOS2HeaderSizeError\");\n        bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.compression=ReadBlobLSBLong(image);\n        bmp_info.image_size=ReadBlobLSBLong(image);\n        bmp_info.x_pixels=ReadBlobLSBLong(image);\n        bmp_info.y_pixels=ReadBlobLSBLong(image);\n        bmp_info.number_colors=ReadBlobLSBLong(image);\n        if (bmp_info.number_colors > GetBlobSize(image))\n          ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n        bmp_info.colors_important=ReadBlobLSBLong(image);\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: MS Windows bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Bits per pixel: %.20g\",(double) bmp_info.bits_per_pixel);\n            switch (bmp_info.compression)\n            {\n              case BI_RGB:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RGB\");\n                break;\n              }\n              case BI_RLE4:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE4\");\n                break;\n              }\n              case BI_RLE8:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE8\");\n                break;\n              }\n              case BI_BITFIELDS:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_BITFIELDS\");\n                break;\n              }\n              case BI_PNG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_PNG\");\n                break;\n              }\n              case BI_JPEG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_JPEG\");\n                break;\n              }\n              default:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: UNKNOWN (%u)\",bmp_info.compression);\n              }\n            }\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Number of colors: %u\",bmp_info.number_colors);\n          }\n        bmp_info.red_mask=ReadBlobLSBLong(image);\n        bmp_info.green_mask=ReadBlobLSBLong(image);\n        bmp_info.blue_mask=ReadBlobLSBLong(image);\n        if (bmp_info.size > 40)\n          {\n            double\n              gamma;\n\n            \/*\n              Read color management information.\n            *\/\n            bmp_info.alpha_mask=ReadBlobLSBLong(image);\n            bmp_info.colorspace=ReadBlobLSBSignedLong(image);\n            \/*\n              Decode 2^30 fixed point formatted CIE primaries.\n            *\/\n#           define BMP_DENOM ((double) 0x40000000)\n            bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n\n            gamma=bmp_info.red_primary.x+bmp_info.red_primary.y+\n              bmp_info.red_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.red_primary.x*=gamma;\n            bmp_info.red_primary.y*=gamma;\n            image->chromaticity.red_primary.x=bmp_info.red_primary.x;\n            image->chromaticity.red_primary.y=bmp_info.red_primary.y;\n\n            gamma=bmp_info.green_primary.x+bmp_info.green_primary.y+\n              bmp_info.green_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.green_primary.x*=gamma;\n            bmp_info.green_primary.y*=gamma;\n            image->chromaticity.green_primary.x=bmp_info.green_primary.x;\n            image->chromaticity.green_primary.y=bmp_info.green_primary.y;\n\n            gamma=bmp_info.blue_primary.x+bmp_info.blue_primary.y+\n              bmp_info.blue_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.blue_primary.x*=gamma;\n            bmp_info.blue_primary.y*=gamma;\n            image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;\n            image->chromaticity.blue_primary.y=bmp_info.blue_primary.y;\n\n            \/*\n              Decode 16^16 fixed point formatted gamma_scales.\n            *\/\n            bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)\/0x10000;\n            \/*\n              Compute a single gamma from the BMP 3-channel gamma.\n            *\/\n            image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+\n              bmp_info.gamma_scale.z)\/3.0;\n          }\n        else\n          (void) CopyMagickString(image->magick,\"BMP3\",MaxTextExtent);\n\n        if (bmp_info.size > 108)\n          {\n            size_t\n              intent;\n\n            \/*\n              Read BMP Version 5 color management information.\n            *\/\n            intent=ReadBlobLSBLong(image);\n            switch ((int) intent)\n            {\n              case LCS_GM_BUSINESS:\n              {\n                image->rendering_intent=SaturationIntent;\n                break;\n              }\n              case LCS_GM_GRAPHICS:\n              {\n                image->rendering_intent=RelativeIntent;\n                break;\n              }\n              case LCS_GM_IMAGES:\n              {\n                image->rendering_intent=PerceptualIntent;\n                break;\n              }\n              case LCS_GM_ABS_COLORIMETRIC:\n              {\n                image->rendering_intent=AbsoluteIntent;\n                break;\n              }\n            }\n            (void) ReadBlobLSBLong(image);  \/* Profile data *\/\n            (void) ReadBlobLSBLong(image);  \/* Profile size *\/\n            (void) ReadBlobLSBLong(image);  \/* Reserved byte *\/\n          }\n      }\n    if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))\n      (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,\n        \"LengthAndFilesizeDoNotMatch\",\"`%s'\",image->filename);\n    else\n      if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          CorruptImageWarning,\"LengthAndFilesizeDoNotMatch\",\"`%s'\",\n          image->filename);\n    if (bmp_info.width <= 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.height == 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.planes != 1)\n      ThrowReaderException(CorruptImageError,\"StaticPlanesValueNotEqualToOne\");\n    if ((bmp_info.bits_per_pixel != 1) && (bmp_info.bits_per_pixel != 4) &&\n        (bmp_info.bits_per_pixel != 8) && (bmp_info.bits_per_pixel != 16) &&\n        (bmp_info.bits_per_pixel != 24) && (bmp_info.bits_per_pixel != 32))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if (bmp_info.bits_per_pixel < 16 &&\n        bmp_info.number_colors > (1U << bmp_info.bits_per_pixel))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedNumberOfColors\");\n    if ((bmp_info.compression == 1) && (bmp_info.bits_per_pixel != 8))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 2) && (bmp_info.bits_per_pixel != 4))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 3) && (bmp_info.bits_per_pixel < 16))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    switch (bmp_info.compression)\n    {\n      case BI_RGB:\n        image->compression=NoCompression;\n        break;\n      case BI_RLE8:\n      case BI_RLE4:\n        image->compression=RLECompression;\n        break;\n      case BI_BITFIELDS:\n        break;\n      case BI_JPEG:\n        ThrowReaderException(CoderError,\"JPEGCompressNotSupported\");\n      case BI_PNG:\n        ThrowReaderException(CoderError,\"PNGCompressNotSupported\");\n      default:\n        ThrowReaderException(CorruptImageError,\"UnrecognizedImageCompression\");\n    }\n    image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);\n    image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);\n    image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;\n    image->matte=((bmp_info.alpha_mask != 0) &&\n      (bmp_info.compression == BI_BITFIELDS)) ? MagickTrue : MagickFalse;\n    if (bmp_info.bits_per_pixel < 16)\n      {\n        size_t\n          one;\n\n        image->storage_class=PseudoClass;\n        image->colors=bmp_info.number_colors;\n        one=1;\n        if (image->colors == 0)\n          image->colors=one << bmp_info.bits_per_pixel;\n      }\n    image->x_resolution=(double) bmp_info.x_pixels\/100.0;\n    image->y_resolution=(double) bmp_info.y_pixels\/100.0;\n    image->units=PixelsPerCentimeterResolution;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    if (image->storage_class == PseudoClass)\n      {\n        unsigned char\n          *bmp_colormap;\n\n        size_t\n          packet_size;\n\n        \/*\n          Read BMP raster colormap.\n        *\/\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading colormap of %.20g colors\",(double) image->colors);\n        if (AcquireImageColormap(image,image->colors) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        bmp_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n          image->colors,4*sizeof(*bmp_colormap));\n        if (bmp_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        if ((bmp_info.size == 12) || (bmp_info.size == 64))\n          packet_size=3;\n        else\n          packet_size=4;\n        offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET);\n        if (offset < 0)\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n          }\n        count=ReadBlob(image,packet_size*image->colors,bmp_colormap);\n        if (count != (ssize_t) (packet_size*image->colors))\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n        p=bmp_colormap;\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].blue=ScaleCharToQuantum(*p++);\n          image->colormap[i].green=ScaleCharToQuantum(*p++);\n          image->colormap[i].red=ScaleCharToQuantum(*p++);\n          if (packet_size == 4)\n            p++;\n        }\n        bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n      }\n    \/*\n      Read image data.\n    *\/\n    if (bmp_info.offset_bits == offset_bits)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    offset_bits=bmp_info.offset_bits;\n    offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET);\n    if (offset < 0)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if (bmp_info.compression == BI_RLE4)\n      bmp_info.bits_per_pixel<<=1;\n    bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)\/32);\n    length=(size_t) bytes_per_line*image->rows;\n    if (((MagickSizeType) length\/8) > GetBlobSize(image))\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    if ((bmp_info.compression == BI_RGB) ||\n        (bmp_info.compression == BI_BITFIELDS))\n      {\n        pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,\n          image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading pixels (%.20g bytes)\",(double) length);\n        count=ReadBlob(image,length,pixels);\n        if (count != (ssize_t) length)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n      }\n    else\n      {\n        \/*\n          Convert run-length encoded raster pixels.\n        *\/\n        pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,\n          image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        status=DecodeImage(image,bmp_info.compression,pixels,\n          image->columns*image->rows);\n        if (status == MagickFalse)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnableToRunlengthDecodeImage\");\n          }\n      }\n    \/*\n      Convert BMP raster image to pixel packets.\n    *\/\n    if (bmp_info.compression == BI_RGB)\n      {\n        \/*\n          We should ignore the alpha value in BMP3 files but there have been\n          reports about 32 bit files with alpha. We do a quick check to see if\n          the alpha channel contains a value that is not zero (default value).\n          If we find a non zero value we asume the program that wrote the file\n          wants to use the alpha channel.\n        *\/\n        if ((image->matte == MagickFalse) && (bmp_info.size == 40) &&\n            (bmp_info.bits_per_pixel == 32))\n          {\n            bytes_per_line=4*(image->columns);\n            for (y=(ssize_t) image->rows-1; y >= 0; y--)\n            {\n              p=pixels+(image->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                if (*(p+3) != 0)\n                  {\n                    image->matte=MagickTrue;\n                    y=-1;\n                    break;\n                  }\n                p+=4;\n              }\n            }\n          }\n        bmp_info.alpha_mask=image->matte != MagickFalse ? 0xff000000U : 0U;\n        bmp_info.red_mask=0x00ff0000U;\n        bmp_info.green_mask=0x0000ff00U;\n        bmp_info.blue_mask=0x000000ffU;\n        if (bmp_info.bits_per_pixel == 16)\n          {\n            \/*\n              RGB555.\n            *\/\n            bmp_info.red_mask=0x00007c00U;\n            bmp_info.green_mask=0x000003e0U;\n            bmp_info.blue_mask=0x0000001fU;\n          }\n      }\n    (void) memset(&shift,0,sizeof(shift));\n    (void) memset(&quantum_bits,0,sizeof(quantum_bits));\n    if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))\n      {\n        register size_t\n          sample;\n\n        \/*\n          Get shift and quantum bits info from bitfield masks.\n        *\/\n        if (bmp_info.red_mask != 0)\n          while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)\n          {\n            shift.red++;\n            if (shift.red > 32U)\n              break;\n          }\n        if (bmp_info.green_mask != 0)\n          while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)\n          {\n            shift.green++;\n            if (shift.green > 32U)\n              break;\n          }\n        if (bmp_info.blue_mask != 0)\n          while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)\n          {\n            shift.blue++;\n            if (shift.blue > 32U)\n              break;\n          }\n        if (bmp_info.alpha_mask != 0)\n          while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)\n          {\n            shift.opacity++;\n            if (shift.opacity > 32U)\n              break;\n          }\n        sample=shift.red;\n        while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.red=ClampToQuantum((MagickRealType) sample-shift.red);\n        sample=shift.green;\n        while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.green=ClampToQuantum((MagickRealType) sample-shift.green);\n        sample=shift.blue;\n        while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.blue=ClampToQuantum((MagickRealType) sample-shift.blue);\n        sample=shift.opacity;\n        while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.opacity=ClampToQuantum((MagickRealType) sample-\n          shift.opacity);\n      }\n    switch (bmp_info.bits_per_pixel)\n    {\n      case 1:\n      {\n        \/*\n          Convert bitmap scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n          {\n            for (bit=0; bit < 8; bit++)\n            {\n              index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n              SetPixelIndex(indexes+x+bit,index);\n              q++;\n            }\n            p++;\n          }\n          if ((image->columns % 8) != 0)\n            {\n              for (bit=0; bit < (image->columns % 8); bit++)\n              {\n                index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n                SetPixelIndex(indexes+x+bit,index);\n              }\n              p++;\n            }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 4:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-1); x+=2)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0x0f),\n              &index,exception);\n            SetPixelIndex(indexes+x,index);\n            (void) IsValidColormapIndex(image,(ssize_t) (*p & 0x0f),&index,\n              exception);\n            SetPixelIndex(indexes+x+1,index);\n            p++;\n          }\n          if ((image->columns % 2) != 0)\n            {\n              (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0xf),\n                &index,exception);\n              SetPixelIndex(indexes+(x++),index);\n              p++;\n            }\n          if (x < (ssize_t) image->columns)\n            break;\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 8:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        if ((bmp_info.compression == BI_RLE8) ||\n            (bmp_info.compression == BI_RLE4))\n          bytes_per_line=image->columns;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=(ssize_t) image->columns; x != 0; --x)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) *p,&index,exception);\n            SetPixelIndex(indexes,index);\n            indexes++;\n            p++;\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 16:\n      {\n        unsigned int\n          alpha,\n          pixel;\n\n        \/*\n          Convert bitfield encoded 16-bit PseudoColor scanline.\n        *\/\n        if (bmp_info.compression != BI_RGB &&\n            bmp_info.compression != BI_BITFIELDS)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=2*(image->columns+image->columns % 2);\n        image->storage_class=DirectClass;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=(*p++) << 8;\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 5)\n              red|=((red & 0xe000) >> 5);\n            if (quantum_bits.red <= 8)\n              red|=((red & 0xff00) >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 5)\n              green|=((green & 0xe000) >> 5);\n            if (quantum_bits.green == 6)\n              green|=((green & 0xc000) >> 6);\n            if (quantum_bits.green <= 8)\n              green|=((green & 0xff00) >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 5)\n              blue|=((blue & 0xe000) >> 5);\n            if (quantum_bits.blue <= 8)\n              blue|=((blue & 0xff00) >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelOpacity(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity <= 8)\n                  alpha|=((alpha & 0xff00) >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 24:\n      {\n        \/*\n          Convert DirectColor scanline.\n        *\/\n        bytes_per_line=4*((image->columns*24+31)\/32);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelBlue(q,ScaleCharToQuantum(*p++));\n            SetPixelGreen(q,ScaleCharToQuantum(*p++));\n            SetPixelRed(q,ScaleCharToQuantum(*p++));\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 32:\n      {\n        \/*\n          Convert bitfield encoded DirectColor scanline.\n        *\/\n        if ((bmp_info.compression != BI_RGB) &&\n            (bmp_info.compression != BI_BITFIELDS))\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=4*(image->columns);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          unsigned int\n            alpha,\n            pixel;\n\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=((unsigned int) *p++ << 8);\n            pixel|=((unsigned int) *p++ << 16);\n            pixel|=((unsigned int) *p++ << 24);\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 8)\n              red|=(red >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 8)\n              green|=(green >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 8)\n              blue|=(blue >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelAlpha(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity == 8)\n                  alpha|=(alpha >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      default:\n      {\n        pixel_info=RelinquishVirtualMemory(pixel_info);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (y > 0)\n      break;\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    if (bmp_info.height < 0)\n      {\n        Image\n          *flipped_image;\n\n        \/*\n          Correct image orientation.\n        *\/\n        flipped_image=FlipImage(image,exception);\n        if (flipped_image != (Image *) NULL)\n          {\n            DuplicateBlob(flipped_image,image);\n            ReplaceImageInList(&image, flipped_image);\n            image=flipped_image;\n          }\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    *magick='\\0';\n    if (bmp_info.ba_offset != 0)\n      {\n        offset=SeekBlob(image,(MagickOffsetType) bmp_info.ba_offset,SEEK_SET);\n        if (offset < 0)\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    count=ReadBlob(image,2,magick);\n    if ((count == 2) && (IsBMP(magick,2) != MagickFalse))\n      {\n        \/*\n          Acquire next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (IsBMP(magick,2) != MagickFalse);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":8660,"total_token_length":8896,"max_tokens_setting":11000}
+{"idx":380956,"func":"edit(\n    int\t\tcmdchar,\n    int\t\tstartln,\t\/\/ if set, insert at start of line\n    long\tcount)\n{\n    int\t\tc = 0;\n    char_u\t*ptr;\n    int\t\tlastc = 0;\n    int\t\tmincol;\n    static linenr_T o_lnum = 0;\n    int\t\ti;\n    int\t\tdid_backspace = TRUE;\t    \/\/ previous char was backspace\n    int\t\tline_is_white = FALSE;\t    \/\/ line is empty before insert\n    linenr_T\told_topline = 0;\t    \/\/ topline before insertion\n#ifdef FEAT_DIFF\n    int\t\told_topfill = -1;\n#endif\n    int\t\tinserted_space = FALSE;     \/\/ just inserted a space\n    int\t\treplaceState = MODE_REPLACE;\n    int\t\tnomove = FALSE;\t\t    \/\/ don't move cursor on return\n#ifdef FEAT_JOB_CHANNEL\n    int\t\tcmdchar_todo = cmdchar;\n#endif\n#ifdef FEAT_CONCEAL\n    int\t\tcursor_line_was_concealed;\n#endif\n\n    \/\/ Remember whether editing was restarted after CTRL-O.\n    did_restart_edit = restart_edit;\n\n    \/\/ sleep before redrawing, needed for \"CTRL-O :\" that results in an\n    \/\/ error message\n    check_for_delay(TRUE);\n\n    \/\/ set Insstart_orig to Insstart\n    update_Insstart_orig = TRUE;\n\n#ifdef HAVE_SANDBOX\n    \/\/ Don't allow inserting in the sandbox.\n    if (sandbox != 0)\n    {\n\temsg(_(e_not_allowed_in_sandbox));\n\treturn FALSE;\n    }\n#endif\n    \/\/ Don't allow changes in the buffer while editing the cmdline.  The\n    \/\/ caller of getcmdline() may get confused.\n    \/\/ Don't allow recursive insert mode when busy with completion.\n    if (textlock != 0 || ins_compl_active() || compl_busy || pum_visible())\n    {\n\temsg(_(e_not_allowed_to_change_text_or_change_window));\n\treturn FALSE;\n    }\n    ins_compl_clear();\t    \/\/ clear stuff for CTRL-X mode\n\n    \/*\n     * Trigger InsertEnter autocommands.  Do not do this for \"r<CR>\" or \"grx\".\n     *\/\n    if (cmdchar != 'r' && cmdchar != 'v')\n    {\n\tpos_T   save_cursor = curwin->w_cursor;\n\n#ifdef FEAT_EVAL\n\tif (cmdchar == 'R')\n\t    ptr = (char_u *)\"r\";\n\telse if (cmdchar == 'V')\n\t    ptr = (char_u *)\"v\";\n\telse\n\t    ptr = (char_u *)\"i\";\n\tset_vim_var_string(VV_INSERTMODE, ptr, 1);\n\tset_vim_var_string(VV_CHAR, NULL, -1);  \/\/ clear v:char\n#endif\n\tins_apply_autocmds(EVENT_INSERTENTER);\n\n\t\/\/ Check for changed highlighting, e.g. for ModeMsg.\n\tif (need_highlight_changed)\n\t    highlight_changed();\n\n\t\/\/ Make sure the cursor didn't move.  Do call check_cursor_col() in\n\t\/\/ case the text was modified.  Since Insert mode was not started yet\n\t\/\/ a call to check_cursor_col() may move the cursor, especially with\n\t\/\/ the \"A\" command, thus set State to avoid that. Also check that the\n\t\/\/ line number is still valid (lines may have been deleted).\n\t\/\/ Do not restore if v:char was set to a non-empty string.\n\tif (!EQUAL_POS(curwin->w_cursor, save_cursor)\n#ifdef FEAT_EVAL\n\t\t&& *get_vim_var_str(VV_CHAR) == NUL\n#endif\n\t\t&& save_cursor.lnum <= curbuf->b_ml.ml_line_count)\n\t{\n\t    int save_state = State;\n\n\t    curwin->w_cursor = save_cursor;\n\t    State = MODE_INSERT;\n\t    check_cursor_col();\n\t    State = save_state;\n\t}\n    }\n\n#ifdef FEAT_CONCEAL\n    \/\/ Check if the cursor line was concealed before changing State.\n    cursor_line_was_concealed = curwin->w_p_cole > 0\n\t\t\t\t\t\t&& conceal_cursor_line(curwin);\n#endif\n\n    \/*\n     * When doing a paste with the middle mouse button, Insstart is set to\n     * where the paste started.\n     *\/\n    if (where_paste_started.lnum != 0)\n\tInsstart = where_paste_started;\n    else\n    {\n\tInsstart = curwin->w_cursor;\n\tif (startln)\n\t    Insstart.col = 0;\n    }\n    Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());\n    Insstart_blank_vcol = MAXCOL;\n    if (!did_ai)\n\tai_col = 0;\n\n    if (cmdchar != NUL && restart_edit == 0)\n    {\n\tResetRedobuff();\n\tAppendNumberToRedobuff(count);\n\tif (cmdchar == 'V' || cmdchar == 'v')\n\t{\n\t    \/\/ \"gR\" or \"gr\" command\n\t    AppendCharToRedobuff('g');\n\t    AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R');\n\t}\n\telse\n\t{\n\t    if (cmdchar == K_PS)\n\t\tAppendCharToRedobuff('a');\n\t    else\n\t\tAppendCharToRedobuff(cmdchar);\n\t    if (cmdchar == 'g')\t\t    \/\/ \"gI\" command\n\t\tAppendCharToRedobuff('I');\n\t    else if (cmdchar == 'r')\t    \/\/ \"r<CR>\" command\n\t\tcount = 1;\t\t    \/\/ insert only one <CR>\n\t}\n    }\n\n    if (cmdchar == 'R')\n    {\n\tState = MODE_REPLACE;\n    }\n    else if (cmdchar == 'V' || cmdchar == 'v')\n    {\n\tState = MODE_VREPLACE;\n\treplaceState = MODE_VREPLACE;\n\torig_line_count = curbuf->b_ml.ml_line_count;\n\tvr_lines_changed = 1;\n    }\n    else\n\tState = MODE_INSERT;\n\n    may_trigger_modechanged();\n    stop_insert_mode = FALSE;\n\n#ifdef FEAT_CONCEAL\n    \/\/ Check if the cursor line needs redrawing after changing State.  If\n    \/\/ 'concealcursor' is \"n\" it needs to be redrawn without concealing.\n    conceal_check_cursor_line(cursor_line_was_concealed);\n#endif\n\n    \/\/ need to position cursor again when on a TAB\n    if (gchar_cursor() == TAB)\n\tcurwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);\n\n    \/*\n     * Enable langmap or IME, indicated by 'iminsert'.\n     * Note that IME may enabled\/disabled without us noticing here, thus the\n     * 'iminsert' value may not reflect what is actually used.  It is updated\n     * when hitting <Esc>.\n     *\/\n    if (curbuf->b_p_iminsert == B_IMODE_LMAP)\n\tState |= MODE_LANGMAP;\n#ifdef HAVE_INPUT_METHOD\n    im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);\n#endif\n\n    setmouse();\n#ifdef FEAT_CMDL_INFO\n    clear_showcmd();\n#endif\n#ifdef FEAT_RIGHTLEFT\n    \/\/ there is no reverse replace mode\n    revins_on = (State == MODE_INSERT && p_ri);\n    if (revins_on)\n\tundisplay_dollar();\n    revins_chars = 0;\n    revins_legal = 0;\n    revins_scol = -1;\n#endif\n    if (!p_ek)\n    {\n\tMAY_WANT_TO_LOG_THIS;\n\n\t\/\/ Disable bracketed paste mode, we won't recognize the escape\n\t\/\/ sequences.\n\tout_str(T_BD);\n\n\t\/\/ Disable modifyOtherKeys, keys with modifiers would cause exiting\n\t\/\/ Insert mode.\n\tout_str(T_CTE);\n    }\n\n    \/*\n     * Handle restarting Insert mode.\n     * Don't do this for \"CTRL-O .\" (repeat an insert): In that case we get\n     * here with something in the stuff buffer.\n     *\/\n    if (restart_edit != 0 && stuff_empty())\n    {\n\t\/*\n\t * After a paste we consider text typed to be part of the insert for\n\t * the pasted text. You can backspace over the pasted text too.\n\t *\/\n\tif (where_paste_started.lnum)\n\t    arrow_used = FALSE;\n\telse\n\t    arrow_used = TRUE;\n\trestart_edit = 0;\n\n\t\/*\n\t * If the cursor was after the end-of-line before the CTRL-O and it is\n\t * now at the end-of-line, put it after the end-of-line (this is not\n\t * correct in very rare cases).\n\t * Also do this if curswant is greater than the current virtual\n\t * column.  Eg after \"^O$\" or \"^O80|\".\n\t *\/\n\tvalidate_virtcol();\n\tupdate_curswant();\n\tif (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)\n\t\t    || curwin->w_curswant > curwin->w_virtcol)\n\t\t&& *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL)\n\t{\n\t    if (ptr[1] == NUL)\n\t\t++curwin->w_cursor.col;\n\t    else if (has_mbyte)\n\t    {\n\t\ti = (*mb_ptr2len)(ptr);\n\t\tif (ptr[i] == NUL)\n\t\t    curwin->w_cursor.col += i;\n\t    }\n\t}\n\tins_at_eol = FALSE;\n    }\n    else\n\tarrow_used = FALSE;\n\n    \/\/ we are in insert mode now, don't need to start it anymore\n    need_start_insertmode = FALSE;\n\n    \/\/ Need to save the line for undo before inserting the first char.\n    ins_need_undo = TRUE;\n\n    where_paste_started.lnum = 0;\n    can_cindent = TRUE;\n#ifdef FEAT_FOLDING\n    \/\/ The cursor line is not in a closed fold, unless 'insertmode' is set or\n    \/\/ restarting.\n    if (!p_im && did_restart_edit == 0)\n\tfoldOpenCursor();\n#endif\n\n    \/*\n     * If 'showmode' is set, show the current (insert\/replace\/..) mode.\n     * A warning message for changing a readonly file is given here, before\n     * actually changing anything.  It's put after the mode, if any.\n     *\/\n    i = 0;\n    if (p_smd && msg_silent == 0)\n\ti = showmode();\n\n    if (!p_im && did_restart_edit == 0)\n\tchange_warning(i == 0 ? 0 : i + 1);\n\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n#ifdef FEAT_DIGRAPHS\n    do_digraph(-1);\t\t\/\/ clear digraphs\n#endif\n\n    \/*\n     * Get the current length of the redo buffer, those characters have to be\n     * skipped if we want to get to the inserted characters.\n     *\/\n    ptr = get_inserted();\n    if (ptr == NULL)\n\tnew_insert_skip = 0;\n    else\n    {\n\tnew_insert_skip = (int)STRLEN(ptr);\n\tvim_free(ptr);\n    }\n\n    old_indent = 0;\n\n    \/*\n     * Main loop in Insert mode: repeat until Insert mode is left.\n     *\/\n    for (;;)\n    {\n#ifdef FEAT_RIGHTLEFT\n\tif (!revins_legal)\n\t    revins_scol = -1;\t    \/\/ reset on illegal motions\n\telse\n\t    revins_legal = 0;\n#endif\n\tif (arrow_used)\t    \/\/ don't repeat insert when arrow key used\n\t    count = 0;\n\n\tif (update_Insstart_orig)\n\t    Insstart_orig = Insstart;\n\n\tif (stop_insert_mode && !ins_compl_active())\n\t{\n\t    \/\/ \":stopinsert\" used or 'insertmode' reset\n\t    count = 0;\n\t    goto doESCkey;\n\t}\n\n\t\/\/ set curwin->w_curswant for next K_DOWN or K_UP\n\tif (!arrow_used)\n\t    curwin->w_set_curswant = TRUE;\n\n\t\/\/ If there is no typeahead may check for timestamps (e.g., for when a\n\t\/\/ menu invoked a shell command).\n\tif (stuff_empty())\n\t{\n\t    did_check_timestamps = FALSE;\n\t    if (need_check_timestamps)\n\t\tcheck_timestamps(FALSE);\n\t}\n\n\t\/*\n\t * When emsg() was called msg_scroll will have been set.\n\t *\/\n\tmsg_scroll = FALSE;\n\n#ifdef FEAT_GUI\n\t\/\/ When 'mousefocus' is set a mouse movement may have taken us to\n\t\/\/ another window.  \"need_mouse_correct\" may then be set because of an\n\t\/\/ autocommand.\n\tif (need_mouse_correct)\n\t    gui_mouse_correct();\n#endif\n\n#ifdef FEAT_FOLDING\n\t\/\/ Open fold at the cursor line, according to 'foldopen'.\n\tif (fdo_flags & FDO_INSERT)\n\t    foldOpenCursor();\n\t\/\/ Close folds where the cursor isn't, according to 'foldclose'\n\tif (!char_avail())\n\t    foldCheckClose();\n#endif\n\n#ifdef FEAT_JOB_CHANNEL\n\tif (bt_prompt(curbuf))\n\t{\n\t    init_prompt(cmdchar_todo);\n\t    cmdchar_todo = NUL;\n\t}\n#endif\n\n\t\/*\n\t * If we inserted a character at the last position of the last line in\n\t * the window, scroll the window one line up. This avoids an extra\n\t * redraw.\n\t * This is detected when the cursor column is smaller after inserting\n\t * something.\n\t * Don't do this when the topline changed already, it has\n\t * already been adjusted (by insertchar() calling open_line())).\n\t *\/\n\tif (curbuf->b_mod_set\n\t\t&& curwin->w_p_wrap\n\t\t&& !did_backspace\n\t\t&& curwin->w_topline == old_topline\n#ifdef FEAT_DIFF\n\t\t&& curwin->w_topfill == old_topfill\n#endif\n\t\t)\n\t{\n\t    mincol = curwin->w_wcol;\n\t    validate_cursor_col();\n\n\t    if (\n#ifdef FEAT_VARTABS\n\t\tcurwin->w_wcol < mincol - tabstop_at(\n\t\t\t\t\t  get_nolist_virtcol(), curbuf->b_p_ts,\n\t\t\t\t\t\t\t curbuf->b_p_vts_array)\n#else\n\t\t(int)curwin->w_wcol < mincol - curbuf->b_p_ts\n#endif\n\t\t    && curwin->w_wrow == W_WINROW(curwin)\n\t\t\t\t + curwin->w_height - 1 - get_scrolloff_value()\n\t\t    && (curwin->w_cursor.lnum != curwin->w_topline\n#ifdef FEAT_DIFF\n\t\t\t|| curwin->w_topfill > 0\n#endif\n\t\t    ))\n\t    {\n#ifdef FEAT_DIFF\n\t\tif (curwin->w_topfill > 0)\n\t\t    --curwin->w_topfill;\n\t\telse\n#endif\n#ifdef FEAT_FOLDING\n\t\tif (hasFolding(curwin->w_topline, NULL, &old_topline))\n\t\t    set_topline(curwin, old_topline + 1);\n\t\telse\n#endif\n\t\t    set_topline(curwin, curwin->w_topline + 1);\n\t    }\n\t}\n\n\t\/\/ May need to adjust w_topline to show the cursor.\n\tupdate_topline();\n\n\tdid_backspace = FALSE;\n\n\tvalidate_cursor();\t\t\/\/ may set must_redraw\n\n\t\/*\n\t * Redraw the display when no characters are waiting.\n\t * Also shows mode, ruler and positions cursor.\n\t *\/\n\tins_redraw(TRUE);\n\n\tif (curwin->w_p_scb)\n\t    do_check_scrollbind(TRUE);\n\n\tif (curwin->w_p_crb)\n\t    do_check_cursorbind();\n\tupdate_curswant();\n\told_topline = curwin->w_topline;\n#ifdef FEAT_DIFF\n\told_topfill = curwin->w_topfill;\n#endif\n\n#ifdef USE_ON_FLY_SCROLL\n\tdont_scroll = FALSE;\t\t\/\/ allow scrolling here\n#endif\n\n\t\/*\n\t * Get a character for Insert mode.  Ignore K_IGNORE and K_NOP.\n\t *\/\n\tif (c != K_CURSORHOLD)\n\t    lastc = c;\t\t\/\/ remember the previous char for CTRL-D\n\n\t\/\/ After using CTRL-G U the next cursor key will not break undo.\n\tif (dont_sync_undo == MAYBE)\n\t    dont_sync_undo = TRUE;\n\telse\n\t    dont_sync_undo = FALSE;\n\tif (cmdchar == K_PS)\n\t    \/\/ Got here from normal mode when bracketed paste started.\n\t    c = K_PS;\n\telse\n\t    do\n\t    {\n\t\tc = safe_vgetc();\n\n\t\tif (stop_insert_mode\n#ifdef FEAT_TERMINAL\n\t\t\t|| (c == K_IGNORE && term_use_loop())\n#endif\n\t\t   )\n\t\t{\n\t\t    \/\/ Insert mode ended, possibly from a callback, or a timer\n\t\t    \/\/ must have opened a terminal window.\n\t\t    if (c != K_IGNORE && c != K_NOP)\n\t\t\tvungetc(c);\n\t\t    count = 0;\n\t\t    nomove = TRUE;\n\t\t    ins_compl_prep(ESC);\n\t\t    goto doESCkey;\n\t\t}\n\t    } while (c == K_IGNORE || c == K_NOP);\n\n\t\/\/ Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V.\n\tdid_cursorhold = TRUE;\n\n#ifdef FEAT_RIGHTLEFT\n\tif (p_hkmap && KeyTyped)\n\t    c = hkmap(c);\t\t\/\/ Hebrew mode mapping\n#endif\n\n\t\/\/ If the window was made so small that nothing shows, make it at least\n\t\/\/ one line and one column when typing.\n\tif (KeyTyped && !KeyStuffed)\n\t    win_ensure_size();\n\n\t\/*\n\t * Special handling of keys while the popup menu is visible or wanted\n\t * and the cursor is still in the completed word.  Only when there is\n\t * a match, skip this when no matches were found.\n\t *\/\n\tif (ins_compl_active()\n\t\t&& pum_wanted()\n\t\t&& curwin->w_cursor.col >= ins_compl_col()\n\t\t&& ins_compl_has_shown_match())\n\t{\n\t    \/\/ BS: Delete one character from \"compl_leader\".\n\t    if ((c == K_BS || c == Ctrl_H)\n\t\t\t&& curwin->w_cursor.col > ins_compl_col()\n\t\t\t&& (c = ins_compl_bs()) == NUL)\n\t\tcontinue;\n\n\t    \/\/ When no match was selected or it was edited.\n\t    if (!ins_compl_used_match())\n\t    {\n\t\t\/\/ CTRL-L: Add one character from the current match to\n\t\t\/\/ \"compl_leader\".  Except when at the original match and\n\t\t\/\/ there is nothing to add, CTRL-L works like CTRL-P then.\n\t\tif (c == Ctrl_L\n\t\t\t&& (!ctrl_x_mode_line_or_eval()\n\t\t\t    || ins_compl_long_shown_match()))\n\t\t{\n\t\t    ins_compl_addfrommatch();\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ A non-white character that fits in with the current\n\t\t\/\/ completion: Add to \"compl_leader\".\n\t\tif (ins_compl_accept_char(c))\n\t\t{\n#if defined(FEAT_EVAL)\n\t\t    \/\/ Trigger InsertCharPre.\n\t\t    char_u *str = do_insert_char_pre(c);\n\t\t    char_u *p;\n\n\t\t    if (str != NULL)\n\t\t    {\n\t\t\tfor (p = str; *p != NUL; MB_PTR_ADV(p))\n\t\t\t    ins_compl_addleader(PTR2CHAR(p));\n\t\t\tvim_free(str);\n\t\t    }\n\t\t    else\n#endif\n\t\t\tins_compl_addleader(c);\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ Pressing CTRL-Y selects the current match.  When\n\t\t\/\/ ins_compl_enter_selects() is set the Enter key does the\n\t\t\/\/ same.\n\t\tif ((c == Ctrl_Y || (ins_compl_enter_selects()\n\t\t\t\t    && (c == CAR || c == K_KENTER || c == NL)))\n\t\t\t&& stop_arrow() == OK)\n\t\t{\n\t\t    ins_compl_delete();\n\t\t    ins_compl_insert(FALSE);\n\t\t}\n\t    }\n\t}\n\n\t\/\/ Prepare for or stop CTRL-X mode.  This doesn't do completion, but\n\t\/\/ it does fix up the text when finishing completion.\n\tins_compl_init_get_longest();\n\tif (ins_compl_prep(c))\n\t    continue;\n\n\t\/\/ CTRL-\\ CTRL-N goes to Normal mode,\n\t\/\/ CTRL-\\ CTRL-G goes to mode selected with 'insertmode',\n\t\/\/ CTRL-\\ CTRL-O is like CTRL-O but without moving the cursor.\n\tif (c == Ctrl_BSL)\n\t{\n\t    \/\/ may need to redraw when no more chars available now\n\t    ins_redraw(FALSE);\n\t    ++no_mapping;\n\t    ++allow_keys;\n\t    c = plain_vgetc();\n\t    --no_mapping;\n\t    --allow_keys;\n\t    if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O)\n\t    {\n\t\t\/\/ it's something else\n\t\tvungetc(c);\n\t\tc = Ctrl_BSL;\n\t    }\n\t    else if (c == Ctrl_G && p_im)\n\t\tcontinue;\n\t    else\n\t    {\n\t\tif (c == Ctrl_O)\n\t\t{\n\t\t    ins_ctrl_o();\n\t\t    ins_at_eol = FALSE;\t\/\/ cursor keeps its column\n\t\t    nomove = TRUE;\n\t\t}\n\t\tcount = 0;\n\t\tgoto doESCkey;\n\t    }\n\t}\n\n#ifdef FEAT_DIGRAPHS\n\tc = do_digraph(c);\n#endif\n\n\tif ((c == Ctrl_V || c == Ctrl_Q) && ctrl_x_mode_cmdline())\n\t    goto docomplete;\n\tif (c == Ctrl_V || c == Ctrl_Q)\n\t{\n\t    ins_ctrl_v();\n\t    c = Ctrl_V;\t\/\/ pretend CTRL-V is last typed character\n\t    continue;\n\t}\n\n\tif (cindent_on() && ctrl_x_mode_none())\n\t{\n\t    \/\/ A key name preceded by a bang means this key is not to be\n\t    \/\/ inserted.  Skip ahead to the re-indenting below.\n\t    \/\/ A key name preceded by a star means that indenting has to be\n\t    \/\/ done before inserting the key.\n\t    line_is_white = inindent(0);\n\t    if (in_cinkeys(c, '!', line_is_white))\n\t\tgoto force_cindent;\n\t    if (can_cindent && in_cinkeys(c, '*', line_is_white)\n\t\t\t\t\t\t\t&& stop_arrow() == OK)\n\t\tdo_c_expr_indent();\n\t}\n\n#ifdef FEAT_RIGHTLEFT\n\tif (curwin->w_p_rl)\n\t    switch (c)\n\t    {\n\t\tcase K_LEFT:\tc = K_RIGHT; break;\n\t\tcase K_S_LEFT:\tc = K_S_RIGHT; break;\n\t\tcase K_C_LEFT:\tc = K_C_RIGHT; break;\n\t\tcase K_RIGHT:\tc = K_LEFT; break;\n\t\tcase K_S_RIGHT: c = K_S_LEFT; break;\n\t\tcase K_C_RIGHT: c = K_C_LEFT; break;\n\t    }\n#endif\n\n\t\/*\n\t * If 'keymodel' contains \"startsel\", may start selection.  If it\n\t * does, a CTRL-O and c will be stuffed, we need to get these\n\t * characters.\n\t *\/\n\tif (ins_start_select(c))\n\t    continue;\n\n\t\/*\n\t * The big switch to handle a character in insert mode.\n\t *\/\n\tswitch (c)\n\t{\n\tcase ESC:\t\/\/ End input mode\n\t    if (echeck_abbr(ESC + ABBR_OFF))\n\t\tbreak;\n\t    \/\/ FALLTHROUGH\n\n\tcase Ctrl_C:\t\/\/ End input mode\n#ifdef FEAT_CMDWIN\n\t    if (c == Ctrl_C && cmdwin_type != 0)\n\t    {\n\t\t\/\/ Close the cmdline window.\n\t\tcmdwin_result = K_IGNORE;\n\t\tgot_int = FALSE; \/\/ don't stop executing autocommands et al.\n\t\tnomove = TRUE;\n\t\tgoto doESCkey;\n\t    }\n#endif\n#ifdef FEAT_JOB_CHANNEL\n\t    if (c == Ctrl_C && bt_prompt(curbuf))\n\t    {\n\t\tif (invoke_prompt_interrupt())\n\t\t{\n\t\t    if (!bt_prompt(curbuf))\n\t\t\t\/\/ buffer changed to a non-prompt buffer, get out of\n\t\t\t\/\/ Insert mode\n\t\t\tgoto doESCkey;\n\t\t    break;\n\t\t}\n\t    }\n#endif\n\n#ifdef UNIX\ndo_intr:\n#endif\n\t    \/\/ when 'insertmode' set, and not halfway a mapping, don't leave\n\t    \/\/ Insert mode\n\t    if (goto_im())\n\t    {\n\t\tif (got_int)\n\t\t{\n\t\t    (void)vgetc();\t\t\/\/ flush all buffers\n\t\t    got_int = FALSE;\n\t\t}\n\t\telse\n\t\t    vim_beep(BO_IM);\n\t\tbreak;\n\t    }\ndoESCkey:\n\t    \/*\n\t     * This is the ONLY return from edit()!\n\t     *\/\n\t    \/\/ Always update o_lnum, so that a \"CTRL-O .\" that adds a line\n\t    \/\/ still puts the cursor back after the inserted text.\n\t    if (ins_at_eol && gchar_cursor() == NUL)\n\t\to_lnum = curwin->w_cursor.lnum;\n\n\t    if (ins_esc(&count, cmdchar, nomove))\n\t    {\n\t\t\/\/ When CTRL-C was typed got_int will be set, with the result\n\t\t\/\/ that the autocommands won't be executed. When mapped got_int\n\t\t\/\/ is not set, but let's keep the behavior the same.\n\t\tif (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C)\n\t\t    ins_apply_autocmds(EVENT_INSERTLEAVE);\n\t\tdid_cursorhold = FALSE;\n\t\treturn (c == Ctrl_O);\n\t    }\n\t    continue;\n\n\tcase Ctrl_Z:\t\/\/ suspend when 'insertmode' set\n\t    if (!p_im)\n\t\tgoto normalchar;\t\/\/ insert CTRL-Z as normal char\n\t    do_cmdline_cmd((char_u *)\"stop\");\n#ifdef CURSOR_SHAPE\n\t    ui_cursor_shape();\t\t\/\/ may need to update cursor shape\n#endif\n\t    continue;\n\n\tcase Ctrl_O:\t\/\/ execute one command\n#ifdef FEAT_COMPL_FUNC\n\t    if (ctrl_x_mode_omni())\n\t\tgoto docomplete;\n#endif\n\t    if (echeck_abbr(Ctrl_O + ABBR_OFF))\n\t\tbreak;\n\t    ins_ctrl_o();\n\n\t    \/\/ don't move the cursor left when 'virtualedit' has \"onemore\".\n\t    if (get_ve_flags() & VE_ONEMORE)\n\t    {\n\t\tins_at_eol = FALSE;\n\t\tnomove = TRUE;\n\t    }\n\t    count = 0;\n\t    goto doESCkey;\n\n\tcase K_INS:\t\/\/ toggle insert\/replace mode\n\tcase K_KINS:\n\t    ins_insert(replaceState);\n\t    break;\n\n\tcase K_SELECT:\t\/\/ end of Select mode mapping - ignore\n\t    break;\n\n\tcase K_HELP:\t\/\/ Help key works like <ESC> <Help>\n\tcase K_F1:\n\tcase K_XF1:\n\t    stuffcharReadbuff(K_HELP);\n\t    if (p_im)\n\t\tneed_start_insertmode = TRUE;\n\t    goto doESCkey;\n\n#ifdef FEAT_NETBEANS_INTG\n\tcase K_F21:\t\/\/ NetBeans command\n\t    ++no_mapping;\t\t\/\/ don't map the next key hits\n\t    i = plain_vgetc();\n\t    --no_mapping;\n\t    netbeans_keycommand(i);\n\t    break;\n#endif\n\n\tcase K_ZERO:\t\/\/ Insert the previously inserted text.\n\tcase NUL:\n\tcase Ctrl_A:\n\t    \/\/ For ^@ the trailing ESC will end the insert, unless there is an\n\t    \/\/ error.\n\t    if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL\n\t\t\t\t\t\t   && c != Ctrl_A && !p_im)\n\t\tgoto doESCkey;\t\t\/\/ quit insert mode\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase Ctrl_R:\t\/\/ insert the contents of a register\n\t    ins_reg();\n\t    auto_format(FALSE, TRUE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase Ctrl_G:\t\/\/ commands starting with CTRL-G\n\t    ins_ctrl_g();\n\t    break;\n\n\tcase Ctrl_HAT:\t\/\/ switch input mode and\/or langmap\n\t    ins_ctrl_hat();\n\t    break;\n\n#ifdef FEAT_RIGHTLEFT\n\tcase Ctrl__:\t\/\/ switch between languages\n\t    if (!p_ari)\n\t\tgoto normalchar;\n\t    ins_ctrl_();\n\t    break;\n#endif\n\n\tcase Ctrl_D:\t\/\/ Make indent one shiftwidth smaller.\n#if defined(FEAT_FIND_ID)\n\t    if (ctrl_x_mode_path_defines())\n\t\tgoto docomplete;\n#endif\n\t    \/\/ FALLTHROUGH\n\n\tcase Ctrl_T:\t\/\/ Make indent one shiftwidth greater.\n\t    if (c == Ctrl_T && ctrl_x_mode_thesaurus())\n\t    {\n\t\tif (has_compl_option(FALSE))\n\t\t    goto docomplete;\n\t\tbreak;\n\t    }\n\n\t    ins_shift(c, lastc);\n\t    auto_format(FALSE, TRUE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase K_DEL:\t\/\/ delete character under the cursor\n\tcase K_KDEL:\n\t    ins_del();\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase K_BS:\t\/\/ delete character before the cursor\n\tcase K_S_BS:\n\tcase Ctrl_H:\n\t    did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase Ctrl_W:\t\/\/ delete word before the cursor\n#ifdef FEAT_JOB_CHANNEL\n\t    if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0)\n\t    {\n\t\t\/\/ In a prompt window CTRL-W is used for window commands.\n\t\t\/\/ Use Shift-CTRL-W to delete a word.\n\t\tstuffcharReadbuff(Ctrl_W);\n\t\trestart_edit = 'A';\n\t\tnomove = TRUE;\n\t\tcount = 0;\n\t\tgoto doESCkey;\n\t    }\n#endif\n\t    did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase Ctrl_U:\t\/\/ delete all inserted text in current line\n# ifdef FEAT_COMPL_FUNC\n\t    \/\/ CTRL-X CTRL-U completes with 'completefunc'.\n\t    if (ctrl_x_mode_function())\n\t\tgoto docomplete;\n# endif\n\t    did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space);\n\t    auto_format(FALSE, TRUE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase K_LEFTMOUSE:   \/\/ mouse keys\n\tcase K_LEFTMOUSE_NM:\n\tcase K_LEFTDRAG:\n\tcase K_LEFTRELEASE:\n\tcase K_LEFTRELEASE_NM:\n\tcase K_MOUSEMOVE:\n\tcase K_MIDDLEMOUSE:\n\tcase K_MIDDLEDRAG:\n\tcase K_MIDDLERELEASE:\n\tcase K_RIGHTMOUSE:\n\tcase K_RIGHTDRAG:\n\tcase K_RIGHTRELEASE:\n\tcase K_X1MOUSE:\n\tcase K_X1DRAG:\n\tcase K_X1RELEASE:\n\tcase K_X2MOUSE:\n\tcase K_X2DRAG:\n\tcase K_X2RELEASE:\n\t    ins_mouse(c);\n\t    break;\n\n\tcase K_MOUSEDOWN: \/\/ Default action for scroll wheel up: scroll up\n\t    ins_mousescroll(MSCR_DOWN);\n\t    break;\n\n\tcase K_MOUSEUP:\t\/\/ Default action for scroll wheel down: scroll down\n\t    ins_mousescroll(MSCR_UP);\n\t    break;\n\n\tcase K_MOUSELEFT: \/\/ Scroll wheel left\n\t    ins_mousescroll(MSCR_LEFT);\n\t    break;\n\n\tcase K_MOUSERIGHT: \/\/ Scroll wheel right\n\t    ins_mousescroll(MSCR_RIGHT);\n\t    break;\n\n\tcase K_PS:\n\t    bracketed_paste(PASTE_INSERT, FALSE, NULL);\n\t    if (cmdchar == K_PS)\n\t\t\/\/ invoked from normal mode, bail out\n\t\tgoto doESCkey;\n\t    break;\n\tcase K_PE:\n\t    \/\/ Got K_PE without K_PS, ignore.\n\t    break;\n\n#ifdef FEAT_GUI_TABLINE\n\tcase K_TABLINE:\n\tcase K_TABMENU:\n\t    ins_tabline(c);\n\t    break;\n#endif\n\n\tcase K_IGNORE:\t\/\/ Something mapped to nothing\n\t    break;\n\n\tcase K_COMMAND:\t\t    \/\/ <Cmd>command<CR>\n\tcase K_SCRIPT_COMMAND:\t    \/\/ <ScriptCmd>command<CR>\n\t    do_cmdkey_command(c, 0);\n#ifdef FEAT_TERMINAL\n\t    if (term_use_loop())\n\t\t\/\/ Started a terminal that gets the input, exit Insert mode.\n\t\tgoto doESCkey;\n#endif\n\t    break;\n\n\tcase K_CURSORHOLD:\t\/\/ Didn't type something for a while.\n\t    ins_apply_autocmds(EVENT_CURSORHOLDI);\n\t    did_cursorhold = TRUE;\n\t    \/\/ If CTRL-G U was used apply it to the next typed key.\n\t    if (dont_sync_undo == TRUE)\n\t\tdont_sync_undo = MAYBE;\n\t    break;\n\n#ifdef FEAT_GUI_MSWIN\n\t    \/\/ On MS-Windows ignore <M-F4>, we get it when closing the window\n\t    \/\/ was cancelled.\n\tcase K_F4:\n\t    if (mod_mask != MOD_MASK_ALT)\n\t\tgoto normalchar;\n\t    break;\n#endif\n\n#ifdef FEAT_GUI\n\tcase K_VER_SCROLLBAR:\n\t    ins_scroll();\n\t    break;\n\n\tcase K_HOR_SCROLLBAR:\n\t    ins_horscroll();\n\t    break;\n#endif\n\n\tcase K_HOME:\t\/\/ <Home>\n\tcase K_KHOME:\n\tcase K_S_HOME:\n\tcase K_C_HOME:\n\t    ins_home(c);\n\t    break;\n\n\tcase K_END:\t\/\/ <End>\n\tcase K_KEND:\n\tcase K_S_END:\n\tcase K_C_END:\n\t    ins_end(c);\n\t    break;\n\n\tcase K_LEFT:\t\/\/ <Left>\n\t    if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))\n\t\tins_s_left();\n\t    else\n\t\tins_left();\n\t    break;\n\n\tcase K_S_LEFT:\t\/\/ <S-Left>\n\tcase K_C_LEFT:\n\t    ins_s_left();\n\t    break;\n\n\tcase K_RIGHT:\t\/\/ <Right>\n\t    if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))\n\t\tins_s_right();\n\t    else\n\t\tins_right();\n\t    break;\n\n\tcase K_S_RIGHT:\t\/\/ <S-Right>\n\tcase K_C_RIGHT:\n\t    ins_s_right();\n\t    break;\n\n\tcase K_UP:\t\/\/ <Up>\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    if (mod_mask & MOD_MASK_SHIFT)\n\t\tins_pageup();\n\t    else\n\t\tins_up(FALSE);\n\t    break;\n\n\tcase K_S_UP:\t\/\/ <S-Up>\n\tcase K_PAGEUP:\n\tcase K_KPAGEUP:\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    ins_pageup();\n\t    break;\n\n\tcase K_DOWN:\t\/\/ <Down>\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    if (mod_mask & MOD_MASK_SHIFT)\n\t\tins_pagedown();\n\t    else\n\t\tins_down(FALSE);\n\t    break;\n\n\tcase K_S_DOWN:\t\/\/ <S-Down>\n\tcase K_PAGEDOWN:\n\tcase K_KPAGEDOWN:\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    ins_pagedown();\n\t    break;\n\n#ifdef FEAT_DND\n\tcase K_DROP:\t\/\/ drag-n-drop event\n\t    ins_drop();\n\t    break;\n#endif\n\n\tcase K_S_TAB:\t\/\/ When not mapped, use like a normal TAB\n\t    c = TAB;\n\t    \/\/ FALLTHROUGH\n\n\tcase TAB:\t\/\/ TAB or Complete patterns along path\n#if defined(FEAT_FIND_ID)\n\t    if (ctrl_x_mode_path_patterns())\n\t\tgoto docomplete;\n#endif\n\t    inserted_space = FALSE;\n\t    if (ins_tab())\n\t\tgoto normalchar;\t\/\/ insert TAB as a normal char\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase K_KENTER:\t\/\/ <Enter>\n\t    c = CAR;\n\t    \/\/ FALLTHROUGH\n\tcase CAR:\n\tcase NL:\n#if defined(FEAT_QUICKFIX)\n\t    \/\/ In a quickfix window a <CR> jumps to the error under the\n\t    \/\/ cursor.\n\t    if (bt_quickfix(curbuf) && c == CAR)\n\t    {\n\t\tif (curwin->w_llist_ref == NULL)    \/\/ quickfix window\n\t\t    do_cmdline_cmd((char_u *)\".cc\");\n\t\telse\t\t\t\t    \/\/ location list window\n\t\t    do_cmdline_cmd((char_u *)\".ll\");\n\t\tbreak;\n\t    }\n#endif\n#ifdef FEAT_CMDWIN\n\t    if (cmdwin_type != 0)\n\t    {\n\t\t\/\/ Execute the command in the cmdline window.\n\t\tcmdwin_result = CAR;\n\t\tgoto doESCkey;\n\t    }\n#endif\n#ifdef FEAT_JOB_CHANNEL\n\t    if (bt_prompt(curbuf))\n\t    {\n\t\tinvoke_prompt_callback();\n\t\tif (!bt_prompt(curbuf))\n\t\t    \/\/ buffer changed to a non-prompt buffer, get out of\n\t\t    \/\/ Insert mode\n\t\t    goto doESCkey;\n\t\tbreak;\n\t    }\n#endif\n\t    if (ins_eol(c) == FAIL && !p_im)\n\t\tgoto doESCkey;\t    \/\/ out of memory\n\t    auto_format(FALSE, FALSE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase Ctrl_K:\t    \/\/ digraph or keyword completion\n\t    if (ctrl_x_mode_dictionary())\n\t    {\n\t\tif (has_compl_option(TRUE))\n\t\t    goto docomplete;\n\t\tbreak;\n\t    }\n#ifdef FEAT_DIGRAPHS\n\t    c = ins_digraph();\n\t    if (c == NUL)\n\t\tbreak;\n#endif\n\t    goto normalchar;\n\n\tcase Ctrl_X:\t\/\/ Enter CTRL-X mode\n\t    ins_ctrl_x();\n\t    break;\n\n\tcase Ctrl_RSB:\t\/\/ Tag name completion after ^X\n\t    if (!ctrl_x_mode_tags())\n\t\tgoto normalchar;\n\t    goto docomplete;\n\n\tcase Ctrl_F:\t\/\/ File name completion after ^X\n\t    if (!ctrl_x_mode_files())\n\t\tgoto normalchar;\n\t    goto docomplete;\n\n\tcase 's':\t\/\/ Spelling completion after ^X\n\tcase Ctrl_S:\n\t    if (!ctrl_x_mode_spell())\n\t\tgoto normalchar;\n\t    goto docomplete;\n\n\tcase Ctrl_L:\t\/\/ Whole line completion after ^X\n\t    if (!ctrl_x_mode_whole_line())\n\t    {\n\t\t\/\/ CTRL-L with 'insertmode' set: Leave Insert mode\n\t\tif (p_im)\n\t\t{\n\t\t    if (echeck_abbr(Ctrl_L + ABBR_OFF))\n\t\t\tbreak;\n\t\t    goto doESCkey;\n\t\t}\n\t\tgoto normalchar;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase Ctrl_P:\t\/\/ Do previous\/next pattern completion\n\tcase Ctrl_N:\n\t    \/\/ if 'complete' is empty then plain ^P is no longer special,\n\t    \/\/ but it is under other ^X modes\n\t    if (*curbuf->b_p_cpt == NUL\n\t\t    && (ctrl_x_mode_normal() || ctrl_x_mode_whole_line())\n\t\t    && !compl_status_local())\n\t\tgoto normalchar;\n\ndocomplete:\n\t    compl_busy = TRUE;\n#ifdef FEAT_FOLDING\n\t    disable_fold_update++;  \/\/ don't redraw folds here\n#endif\n\t    if (ins_complete(c, TRUE) == FAIL)\n\t\tcompl_status_clear();\n#ifdef FEAT_FOLDING\n\t    disable_fold_update--;\n#endif\n\t    compl_busy = FALSE;\n\t    can_si = may_do_si(); \/\/ allow smartindenting\n\t    break;\n\n\tcase Ctrl_Y:\t\/\/ copy from previous line or scroll down\n\tcase Ctrl_E:\t\/\/ copy from next line\t   or scroll up\n\t    c = ins_ctrl_ey(c);\n\t    break;\n\n\t  default:\n#ifdef UNIX\n\t    if (c == intr_char)\t\t\/\/ special interrupt char\n\t\tgoto do_intr;\n#endif\n\nnormalchar:\n\t    \/*\n\t     * Insert a normal character.\n\t     *\/\n#if defined(FEAT_EVAL)\n\t    if (!p_paste)\n\t    {\n\t\t\/\/ Trigger InsertCharPre.\n\t\tchar_u *str = do_insert_char_pre(c);\n\t\tchar_u *p;\n\n\t\tif (str != NULL)\n\t\t{\n\t\t    if (*str != NUL && stop_arrow() != FAIL)\n\t\t    {\n\t\t\t\/\/ Insert the new value of v:char literally.\n\t\t\tfor (p = str; *p != NUL; MB_PTR_ADV(p))\n\t\t\t{\n\t\t\t    c = PTR2CHAR(p);\n\t\t\t    if (c == CAR || c == K_KENTER || c == NL)\n\t\t\t\tins_eol(c);\n\t\t\t    else\n\t\t\t\tins_char(c);\n\t\t\t}\n\t\t\tAppendToRedobuffLit(str, -1);\n\t\t    }\n\t\t    vim_free(str);\n\t\t    c = NUL;\n\t\t}\n\n\t\t\/\/ If the new value is already inserted or an empty string\n\t\t\/\/ then don't insert any character.\n\t\tif (c == NUL)\n\t\t    break;\n\t    }\n#endif\n\t    \/\/ Try to perform smart-indenting.\n\t    ins_try_si(c);\n\n\t    if (c == ' ')\n\t    {\n\t\tinserted_space = TRUE;\n\t\tif (inindent(0))\n\t\t    can_cindent = FALSE;\n\t\tif (Insstart_blank_vcol == MAXCOL\n\t\t\t&& curwin->w_cursor.lnum == Insstart.lnum)\n\t\t    Insstart_blank_vcol = get_nolist_virtcol();\n\t    }\n\n\t    \/\/ Insert a normal character and check for abbreviations on a\n\t    \/\/ special character.  Let CTRL-] expand abbreviations without\n\t    \/\/ inserting it.\n\t    if (vim_iswordc(c) || (!echeck_abbr(\n\t\t\t\/\/ Add ABBR_OFF for characters above 0x100, this is\n\t\t\t\/\/ what check_abbr() expects.\n\t\t\t\t(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c)\n\t\t\t&& c != Ctrl_RSB))\n\t    {\n\t\tinsert_special(c, FALSE, FALSE);\n#ifdef FEAT_RIGHTLEFT\n\t\trevins_legal++;\n\t\trevins_chars++;\n#endif\n\t    }\n\n\t    auto_format(FALSE, TRUE);\n\n#ifdef FEAT_FOLDING\n\t    \/\/ When inserting a character the cursor line must never be in a\n\t    \/\/ closed fold.\n\t    foldOpenCursor();\n#endif\n\t    break;\n\t}   \/\/ end of switch (c)\n\n\t\/\/ If typed something may trigger CursorHoldI again.\n\tif (c != K_CURSORHOLD\n#ifdef FEAT_COMPL_FUNC\n\t\t\/\/ but not in CTRL-X mode, a script can't restore the state\n\t\t&& ctrl_x_mode_normal()\n#endif\n\t       )\n\t    did_cursorhold = FALSE;\n\n\t\/\/ If the cursor was moved we didn't just insert a space\n\tif (arrow_used)\n\t    inserted_space = FALSE;\n\n\tif (can_cindent && cindent_on() && ctrl_x_mode_normal())\n\t{\nforce_cindent:\n\t    \/*\n\t     * Indent now if a key was typed that is in 'cinkeys'.\n\t     *\/\n\t    if (in_cinkeys(c, ' ', line_is_white))\n\t    {\n\t\tif (stop_arrow() == OK)\n\t\t    \/\/ re-indent the current line\n\t\t    do_c_expr_indent();\n\t    }\n\t}\n\n    }\t\/\/ for (;;)\n    \/\/ NOTREACHED\n}","target":0,"code_token_length":9022,"total_token_length":9258,"max_tokens_setting":11000}
+{"idx":251515,"func":"static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define ThrowDCMException(exception,message) \\\n{ \\\n  RelinquishDCMMemory(&info,&map,stream_info,stack,data); \\\n  if (info_copy != (DCMInfo *) NULL) \\\n    info_copy=(DCMInfo *) RelinquishDCMInfo(info_copy); \\\n  ThrowReaderException((exception),(message)); \\\n}\n\n  char\n    explicit_vr[MagickPathExtent],\n    implicit_vr[MagickPathExtent],\n    magick[MagickPathExtent],\n    photometric[MagickPathExtent];\n\n  DCMInfo\n    info,\n    *info_copy = (DCMInfo *) NULL;\n\n  DCMMap\n    map;\n\n  DCMStreamInfo\n    *stream_info;\n\n  Image\n    *image;\n\n  int\n    datum;\n\n  LinkedListInfo\n    *stack;\n\n  MagickBooleanType\n    explicit_file,\n    explicit_retry,\n    use_explicit;\n\n  MagickOffsetType\n    blob_size,\n    offset;\n\n  unsigned char\n    *p;\n\n  ssize_t\n    i;\n\n  size_t\n    colors,\n    length,\n    number_scenes,\n    quantum,\n    status;\n\n  ssize_t\n    count,\n    scene,\n    sequence_depth;\n\n  unsigned char\n    *data;\n\n  unsigned short\n    group,\n    element;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  image->depth=8UL;\n  image->endian=LSBEndian;\n  \/*\n    Read DCM preamble.\n  *\/\n  (void) memset(&info,0,sizeof(info));\n  (void) memset(&map,0,sizeof(map));\n  data=(unsigned char *) NULL;\n  stream_info=(DCMStreamInfo *) AcquireMagickMemory(sizeof(*stream_info));\n  sequence_depth=0;\n  stack=NewLinkedList(256);\n  if (stream_info == (DCMStreamInfo *) NULL)\n    ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n  (void) memset(stream_info,0,sizeof(*stream_info));\n  count=ReadBlob(image,128,(unsigned char *) magick);\n  if (count != 128)\n    ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n  count=ReadBlob(image,4,(unsigned char *) magick);\n  if ((count != 4) || (LocaleNCompare(magick,\"DICM\",4) != 0))\n    {\n      offset=SeekBlob(image,0L,SEEK_SET);\n      if (offset < 0)\n        ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n    }\n  \/*\n    Read DCM Medical image.\n  *\/\n  (void) CopyMagickString(photometric,\"MONOCHROME1 \",MagickPathExtent);\n  info.bits_allocated=8;\n  info.bytes_per_pixel=1;\n  info.depth=8;\n  info.mask=0xffff;\n  info.max_value=255UL;\n  info.samples_per_pixel=1;\n  info.signed_data=(~0UL);\n  info.rescale_slope=1.0;\n  element=0;\n  explicit_vr[2]='\\0';\n  explicit_file=MagickFalse;\n  colors=0;\n  number_scenes=1;\n  use_explicit=MagickFalse;\n  explicit_retry=MagickFalse;\n  blob_size=(MagickOffsetType) GetBlobSize(image);\n  while (TellBlob(image) < blob_size)\n  {\n    for (group=0; (group != 0x7FE0) || (element != 0x0010) ; )\n    {\n      \/*\n        Read a group.\n      *\/\n      image->offset=(ssize_t) TellBlob(image);\n      group=ReadBlobLSBShort(image);\n      element=ReadBlobLSBShort(image);\n      if ((group == 0xfffc) && (element == 0xfffc))\n        break;\n      if ((group != 0x0002) && (image->endian == MSBEndian))\n        {\n          group=(unsigned short) ((group << 8) | ((group >> 8) & 0xFF));\n          element=(unsigned short) ((element << 8) | ((element >> 8) & 0xFF));\n        }\n      quantum=0;\n      \/*\n        Find corresponding VR for this group and element.\n      *\/\n      for (i=0; dicom_info[i].group < 0xffff; i++)\n        if ((group == dicom_info[i].group) &&\n            (element == dicom_info[i].element))\n          break;\n      (void) CopyMagickString(implicit_vr,dicom_info[i].vr,MagickPathExtent);\n      count=ReadBlob(image,2,(unsigned char *) explicit_vr);\n      if (count != 2)\n        ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n      \/*\n        Check for \"explicitness\", but meta-file headers always explicit.\n      *\/\n      if ((explicit_file == MagickFalse) && (group != 0x0002))\n        explicit_file=(isupper((int) ((unsigned char) *explicit_vr)) != 0) &&\n          (isupper((int) ((unsigned char) *(explicit_vr+1))) != 0) ?\n          MagickTrue : MagickFalse;\n      use_explicit=((group == 0x0002) && (explicit_retry == MagickFalse)) ||\n        (explicit_file != MagickFalse) ? MagickTrue : MagickFalse;\n      if ((use_explicit != MagickFalse) && (strncmp(implicit_vr,\"xs\",2) == 0))\n        (void) CopyMagickString(implicit_vr,explicit_vr,MagickPathExtent);\n      if ((use_explicit == MagickFalse) || (strncmp(implicit_vr,\"!!\",2) == 0))\n        {\n          offset=SeekBlob(image,(MagickOffsetType) -2,SEEK_CUR);\n          if (offset < 0)\n            ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n          quantum=4;\n        }\n      else\n        {\n          \/*\n            Assume explicit type.\n          *\/\n          quantum=2;\n          if ((strcmp(explicit_vr,\"OB\") == 0) ||\n              (strcmp(explicit_vr,\"OW\") == 0) ||\n              (strcmp(explicit_vr,\"OF\") == 0) ||\n              (strcmp(explicit_vr,\"SQ\") == 0) ||\n              (strcmp(explicit_vr,\"UN\") == 0) ||\n              (strcmp(explicit_vr,\"UT\") == 0))\n            {\n              (void) ReadBlobLSBShort(image);\n              quantum=4;\n            }\n        }\n      if ((group == 0xFFFE) && (element == 0xE0DD))\n        {\n          \/*\n            If we're exiting a sequence, restore the previous image parameters,\n            effectively undoing any parameter changes that happened inside the\n            sequence.\n          *\/\n          sequence_depth--;\n          info_copy=(DCMInfo *) RemoveLastElementFromLinkedList(stack);\n          if (info_copy == (DCMInfo *)NULL)\n            {\n              \/*\n                The sequence's entry and exit points don't line up (tried to\n                exit one more sequence than we entered).\n              *\/\n              ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n            }\n          if (info.scale != (Quantum *) NULL)\n            info.scale=(Quantum *) RelinquishMagickMemory(info.scale);\n          (void) memcpy(&info,info_copy,sizeof(info));\n          info_copy=(DCMInfo *) RelinquishMagickMemory(info_copy);\n        }\n      if (strcmp(explicit_vr,\"SQ\") == 0)\n        {\n          \/*\n            If we're entering a sequence, push the current image parameters\n            onto the stack, so we can restore them at the end of the sequence.\n          *\/\n          DCMInfo *clone_info = (DCMInfo *) AcquireMagickMemory(sizeof(info));\n          if (clone_info == (DCMInfo *) NULL)\n            ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n          (void) memcpy(clone_info,&info,sizeof(info));\n          clone_info->scale=(Quantum *) AcquireQuantumMemory(\n            clone_info->scale_size+1,sizeof(*clone_info->scale));\n          if (clone_info->scale == (Quantum *) NULL)\n            ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n          (void) memcpy(clone_info->scale,info.scale,clone_info->scale_size*\n            sizeof(*clone_info->scale));\n          AppendValueToLinkedList(stack,clone_info);\n          sequence_depth++;\n        }\n      datum=0;\n      if (quantum == 4)\n        {\n          if (group == 0x0002)\n            datum=ReadBlobLSBSignedLong(image);\n          else\n            datum=ReadBlobSignedLong(image);\n        }\n      else\n        if (quantum == 2)\n          {\n            if (group == 0x0002)\n              datum=ReadBlobLSBSignedShort(image);\n            else\n              datum=ReadBlobSignedShort(image);\n          }\n      quantum=0;\n      length=1;\n      if (datum != 0)\n        {\n          if ((strncmp(implicit_vr,\"OW\",2) == 0) ||\n              (strncmp(implicit_vr,\"SS\",2) == 0) ||\n              (strncmp(implicit_vr,\"US\",2) == 0))\n            quantum=2;\n          else\n            if ((strncmp(implicit_vr,\"FL\",2) == 0) ||\n                (strncmp(implicit_vr,\"OF\",2) == 0) ||\n                (strncmp(implicit_vr,\"SL\",2) == 0) ||\n                (strncmp(implicit_vr,\"UL\",2) == 0))\n              quantum=4;\n            else\n              if (strncmp(implicit_vr,\"FD\",2) == 0)\n                quantum=8;\n              else\n                quantum=1;\n          if (datum != ~0)\n            length=(size_t) datum\/quantum;\n          else\n            {\n              \/*\n                Sequence and item of undefined length.\n              *\/\n              quantum=0;\n              length=0;\n            }\n        }\n      if (image_info->verbose != MagickFalse)\n        {\n          \/*\n            Display Dicom info.\n          *\/\n          if (use_explicit == MagickFalse)\n            explicit_vr[0]='\\0';\n          for (i=0; dicom_info[i].description != (char *) NULL; i++)\n            if ((group == dicom_info[i].group) &&\n                (element == dicom_info[i].element))\n              break;\n          (void) FormatLocaleFile(stdout,\n            \"0x%04lX %4ld S%ld %s-%s (0x%04lx,0x%04lx)\",\n            (unsigned long) image->offset,(long) length,(long) sequence_depth,\n            implicit_vr,explicit_vr,(unsigned long) group,\n            (unsigned long) element);\n          if (dicom_info[i].description != (char *) NULL)\n            (void) FormatLocaleFile(stdout,\" %s\",dicom_info[i].description);\n          (void) FormatLocaleFile(stdout,\": \");\n        }\n      if ((group == 0x7FE0) && (element == 0x0010))\n        {\n          if (image_info->verbose != MagickFalse)\n            (void) FormatLocaleFile(stdout,\"\\n\");\n          break;\n        }\n      \/*\n        Allocate space and read an array.\n      *\/\n      data=(unsigned char *) NULL;\n      if ((length == 1) && (quantum == 1))\n        datum=ReadBlobByte(image);\n      else\n        if ((length == 1) && (quantum == 2))\n          {\n            if (group == 0x0002)\n              datum=ReadBlobLSBSignedShort(image);\n            else\n              datum=ReadBlobSignedShort(image);\n          }\n        else\n          if ((length == 1) && (quantum == 4))\n            {\n              if (group == 0x0002)\n                datum=ReadBlobLSBSignedLong(image);\n              else\n                datum=ReadBlobSignedLong(image);\n            }\n          else\n            if ((quantum != 0) && (length != 0))\n              {\n                if (length > (size_t) GetBlobSize(image))\n                  ThrowDCMException(CorruptImageError,\n                    \"InsufficientImageDataInFile\")\n                if (~length >= 1)\n                  data=(unsigned char *) AcquireQuantumMemory(length+1,quantum*\n                    sizeof(*data));\n                if (data == (unsigned char *) NULL)\n                  ThrowDCMException(ResourceLimitError,\n                    \"MemoryAllocationFailed\")\n                count=ReadBlob(image,(size_t) quantum*length,data);\n                if (count != (ssize_t) (quantum*length))\n                  {\n                    if (image_info->verbose != MagickFalse)\n                      (void) FormatLocaleFile(stdout,\"count=%d quantum=%d \"\n                        \"length=%d group=%d\\n\",(int) count,(int) quantum,(int)\n                        length,(int) group);\n                     ThrowDCMException(CorruptImageError,\n                       \"InsufficientImageDataInFile\")\n                  }\n                data[length*quantum]='\\0';\n              }\n      if ((((unsigned int) group << 16) | element) == 0xFFFEE0DD)\n        {\n          if (data != (unsigned char *) NULL)\n            data=(unsigned char *) RelinquishMagickMemory(data);\n          continue;\n        }\n      switch (group)\n      {\n        case 0x0002:\n        {\n          switch (element)\n          {\n            case 0x0010:\n            {\n              char\n                transfer_syntax[MagickPathExtent];\n\n              \/*\n                Transfer Syntax.\n              *\/\n              if ((datum == 0) && (explicit_retry == MagickFalse))\n                {\n                  explicit_retry=MagickTrue;\n                  (void) SeekBlob(image,(MagickOffsetType) 0,SEEK_SET);\n                  group=0;\n                  element=0;\n                  if (image_info->verbose != MagickFalse)\n                    (void) FormatLocaleFile(stdout,\n                      \"Corrupted image - trying explicit format\\n\");\n                  break;\n                }\n              *transfer_syntax='\\0';\n              if (data != (unsigned char *) NULL)\n                (void) CopyMagickString(transfer_syntax,(char *) data,\n                  MagickPathExtent);\n              if (image_info->verbose != MagickFalse)\n                (void) FormatLocaleFile(stdout,\"transfer_syntax=%s\\n\",\n                  (const char *) transfer_syntax);\n              if (strncmp(transfer_syntax,\"1.2.840.10008.1.2\",17) == 0)\n                {\n                  int\n                    subtype,\n                    type;\n\n                  type=1;\n                  subtype=0;\n                  if (strlen(transfer_syntax) > 17)\n                    {\n                      count=(ssize_t) sscanf(transfer_syntax+17,\".%d.%d\",&type,\n                        &subtype);\n                      if (count < 1)\n                        ThrowDCMException(CorruptImageError,\n                          \"ImproperImageHeader\")\n                    }\n                  switch (type)\n                  {\n                    case 1:\n                    {\n                      image->endian=LSBEndian;\n                      break;\n                    }\n                    case 2:\n                    {\n                      image->endian=MSBEndian;\n                      break;\n                    }\n                    case 4:\n                    {\n                      if ((subtype >= 80) && (subtype <= 81))\n                        image->compression=JPEGCompression;\n                      else\n                        if ((subtype >= 90) && (subtype <= 93))\n                          image->compression=JPEG2000Compression;\n                        else\n                          image->compression=JPEGCompression;\n                      break;\n                    }\n                    case 5:\n                    {\n                      image->compression=RLECompression;\n                      break;\n                    }\n                  }\n                }\n              break;\n            }\n            default:\n              break;\n          }\n          break;\n        }\n        case 0x0028:\n        {\n          switch (element)\n          {\n            case 0x0002:\n            {\n              \/*\n                Samples per pixel.\n              *\/\n              info.samples_per_pixel=(size_t) datum;\n              if ((info.samples_per_pixel == 0) || (info.samples_per_pixel > 4))\n                ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n              break;\n            }\n            case 0x0004:\n            {\n              \/*\n                Photometric interpretation.\n              *\/\n              if (data == (unsigned char *) NULL)\n                break;\n              for (i=0; i < (ssize_t) MagickMin(length,MagickPathExtent-1); i++)\n                photometric[i]=(char) data[i];\n              photometric[i]='\\0';\n              info.polarity=LocaleCompare(photometric,\"MONOCHROME1 \") == 0 ?\n                MagickTrue : MagickFalse;\n              break;\n            }\n            case 0x0006:\n            {\n              \/*\n                Planar configuration.\n              *\/\n              if (datum == 1)\n                image->interlace=PlaneInterlace;\n              break;\n            }\n            case 0x0008:\n            {\n              \/*\n                Number of frames.\n              *\/\n              if (data == (unsigned char *) NULL)\n                break;\n              number_scenes=StringToUnsignedLong((char *) data);\n              break;\n            }\n            case 0x0010:\n            {\n              \/*\n                Image rows.\n              *\/\n              info.height=(size_t) datum;\n              break;\n            }\n            case 0x0011:\n            {\n              \/*\n                Image columns.\n              *\/\n              info.width=(size_t) datum;\n              break;\n            }\n            case 0x0100:\n            {\n              \/*\n                Bits allocated.\n              *\/\n              info.bits_allocated=(size_t) datum;\n              info.bytes_per_pixel=1;\n              if (datum > 8)\n                info.bytes_per_pixel=2;\n              info.depth=info.bits_allocated;\n              if ((info.depth == 0) || (info.depth > 32))\n                ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n              info.max_value=(1UL << info.bits_allocated)-1;\n              image->depth=info.depth;\n              break;\n            }\n            case 0x0101:\n            {\n              \/*\n                Bits stored.\n              *\/\n              info.significant_bits=(size_t) datum;\n              info.bytes_per_pixel=1;\n              if (info.significant_bits > 8)\n                info.bytes_per_pixel=2;\n              info.depth=info.significant_bits;\n              if ((info.depth == 0) || (info.depth > 16))\n                ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n              info.max_value=(1UL << info.significant_bits)-1;\n              info.mask=(size_t) GetQuantumRange(info.significant_bits);\n              image->depth=info.depth;\n              break;\n            }\n            case 0x0102:\n            {\n              \/*\n                High bit.\n              *\/\n              break;\n            }\n            case 0x0103:\n            {\n              \/*\n                Pixel representation.\n              *\/\n              info.signed_data=(size_t) datum;\n              break;\n            }\n            case 0x1050:\n            {\n              \/*\n                Visible pixel range: center.\n              *\/\n              if (data != (unsigned char *) NULL)\n                info.window_center=StringToDouble((char *) data,(char **) NULL);\n              break;\n            }\n            case 0x1051:\n            {\n              \/*\n                Visible pixel range: width.\n              *\/\n              if (data != (unsigned char *) NULL)\n                info.window_width=StringToDouble((char *) data,(char **) NULL);\n              break;\n            }\n            case 0x1052:\n            {\n              \/*\n                Rescale intercept\n              *\/\n              if (data != (unsigned char *) NULL)\n                info.rescale_intercept=StringToDouble((char *) data,\n                  (char **) NULL);\n              break;\n            }\n            case 0x1053:\n            {\n              \/*\n                Rescale slope\n              *\/\n              if (data != (unsigned char *) NULL)\n                info.rescale_slope=StringToDouble((char *) data,(char **) NULL);\n              break;\n            }\n            case 0x1200:\n            case 0x3006:\n            {\n              \/*\n                Populate graymap.\n              *\/\n              if (data == (unsigned char *) NULL)\n                break;\n              colors=(size_t) (length\/info.bytes_per_pixel);\n              datum=(int) colors;\n              if (map.gray != (int *) NULL)\n                map.gray=(int *) RelinquishMagickMemory(map.gray);\n              map.gray=(int *) AcquireQuantumMemory(MagickMax(colors,65536),\n                sizeof(*map.gray));\n              if (map.gray == (int *) NULL)\n                ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n              (void) memset(map.gray,0,MagickMax(colors,65536)*\n                sizeof(*map.gray));\n              for (i=0; i < (ssize_t) colors; i++)\n                if (info.bytes_per_pixel == 1)\n                  map.gray[i]=(int) data[i];\n                else\n                  map.gray[i]=(int) ((short *) data)[i];\n              break;\n            }\n            case 0x1201:\n            {\n              unsigned short\n                index;\n\n              \/*\n                Populate redmap.\n              *\/\n              if (data == (unsigned char *) NULL)\n                break;\n              colors=(size_t) (length\/info.bytes_per_pixel);\n              datum=(int) colors;\n              if (map.red != (int *) NULL)\n                map.red=(int *) RelinquishMagickMemory(map.red);\n              map.red=(int *) AcquireQuantumMemory(MagickMax(colors,65536),\n                sizeof(*map.red));\n              if (map.red == (int *) NULL)\n                ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n              (void) memset(map.red,0,MagickMax(colors,65536)*\n                sizeof(*map.red));\n              p=data;\n              for (i=0; i < (ssize_t) colors; i++)\n              {\n                if (image->endian == MSBEndian)\n                  index=(unsigned short) ((*p << 8) | *(p+1));\n                else\n                  index=(unsigned short) (*p | (*(p+1) << 8));\n                map.red[i]=(int) index;\n                p+=2;\n              }\n              break;\n            }\n            case 0x1202:\n            {\n              unsigned short\n                index;\n\n              \/*\n                Populate greenmap.\n              *\/\n              if (data == (unsigned char *) NULL)\n                break;\n              colors=(size_t) (length\/info.bytes_per_pixel);\n              datum=(int) colors;\n              if (map.green != (int *) NULL)\n                map.green=(int *) RelinquishMagickMemory(map.green);\n              map.green=(int *) AcquireQuantumMemory(MagickMax(colors,65536),\n                sizeof(*map.green));\n              if (map.green == (int *) NULL)\n                ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n              (void) memset(map.green,0,MagickMax(colors,65536)*\n                sizeof(*map.green));\n              p=data;\n              for (i=0; i < (ssize_t) colors; i++)\n              {\n                if (image->endian == MSBEndian)\n                  index=(unsigned short) ((*p << 8) | *(p+1));\n                else\n                  index=(unsigned short) (*p | (*(p+1) << 8));\n                map.green[i]=(int) index;\n                p+=2;\n              }\n              break;\n            }\n            case 0x1203:\n            {\n              unsigned short\n                index;\n\n              \/*\n                Populate bluemap.\n              *\/\n              if (data == (unsigned char *) NULL)\n                break;\n              colors=(size_t) (length\/info.bytes_per_pixel);\n              datum=(int) colors;\n              if (map.blue != (int *) NULL)\n                map.blue=(int *) RelinquishMagickMemory(map.blue);\n              map.blue=(int *) AcquireQuantumMemory(MagickMax(colors,65536),\n                sizeof(*map.blue));\n              if (map.blue == (int *) NULL)\n                ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n              (void) memset(map.blue,0,MagickMax(colors,65536)*\n                sizeof(*map.blue));\n              p=data;\n              for (i=0; i < (ssize_t) colors; i++)\n              {\n                if (image->endian == MSBEndian)\n                  index=(unsigned short) ((*p << 8) | *(p+1));\n                else\n                  index=(unsigned short) (*p | (*(p+1) << 8));\n                map.blue[i]=(int) index;\n                p+=2;\n              }\n              break;\n            }\n            default:\n              break;\n          }\n          break;\n        }\n        case 0x2050:\n        {\n          switch (element)\n          {\n            case 0x0020:\n            {\n              if ((data != (unsigned char *) NULL) &&\n                  (strncmp((char *) data,\"INVERSE\",7) == 0))\n                info.polarity=MagickTrue;\n              break;\n            }\n            default:\n              break;\n          }\n          break;\n        }\n        default:\n          break;\n      }\n      if (data != (unsigned char *) NULL)\n        {\n          char\n            *attribute;\n\n          for (i=0; dicom_info[i].description != (char *) NULL; i++)\n            if ((group == dicom_info[i].group) &&\n                (element == dicom_info[i].element))\n              break;\n          if (dicom_info[i].description != (char *) NULL)\n            {\n              attribute=AcquireString(\"dcm:\");\n              (void) ConcatenateString(&attribute,dicom_info[i].description);\n              for (i=0; i < (ssize_t) MagickMax(length,4); i++)\n                if (isprint((int) data[i]) == 0)\n                  break;\n              if ((i == (ssize_t) length) || (length > 4))\n                {\n                  (void) SubstituteString(&attribute,\" \",\"\");\n                  (void) SetImageProperty(image,attribute,(char *) data,\n                    exception);\n                }\n              attribute=DestroyString(attribute);\n            }\n        }\n      if (image_info->verbose != MagickFalse)\n        {\n          if (data == (unsigned char *) NULL)\n            (void) FormatLocaleFile(stdout,\"%d\\n\",datum);\n          else\n            {\n              \/*\n                Display group data.\n              *\/\n              for (i=0; i < (ssize_t) MagickMax(length,4); i++)\n                if (isprint((int) data[i]) == 0)\n                  break;\n              if ((i != (ssize_t) length) && (length <= 4))\n                {\n                  ssize_t\n                    j;\n\n                  datum=0;\n                  for (j=(ssize_t) length-1; j >= 0; j--)\n                    datum=(256*datum+data[j]);\n                  (void) FormatLocaleFile(stdout,\"%d\",datum);\n                }\n              else\n                for (i=0; i < (ssize_t) length; i++)\n                  if (isprint((int) data[i]) != 0)\n                    (void) FormatLocaleFile(stdout,\"%c\",data[i]);\n                  else\n                    (void) FormatLocaleFile(stdout,\"%c\",'.');\n              (void) FormatLocaleFile(stdout,\"\\n\");\n            }\n        }\n      if (data != (unsigned char *) NULL)\n        data=(unsigned char *) RelinquishMagickMemory(data);\n      if (EOFBlob(image) != MagickFalse)\n        {\n          ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n            image->filename);\n          group=0xfffc;\n          break;\n        }\n    }\n    if ((group == 0xfffc) && (element == 0xfffc))\n      {\n        Image\n          *last;\n\n        last=RemoveLastImageFromList(&image);\n        if (last != (Image *) NULL)\n          last=DestroyImage(last);\n        break;\n      }\n    if ((info.width == 0) || (info.height == 0))\n      ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n    image->columns=info.width;\n    image->rows=info.height;\n    if (info.signed_data == 0xffff)\n      info.signed_data=(size_t) (info.significant_bits == 16 ? 1 : 0);\n    if ((image->compression == JPEGCompression) ||\n        (image->compression == JPEG2000Compression))\n      {\n        Image\n          *images;\n\n        ImageInfo\n          *read_info;\n\n        int\n          c;\n\n        \/*\n          Read offset table.\n        *\/\n        for (i=0; i < (ssize_t) stream_info->remaining; i++)\n          if (ReadBlobByte(image) == EOF)\n            break;\n        (void) (((ssize_t) ReadBlobLSBShort(image) << 16) |\n          ReadBlobLSBShort(image));\n        length=(size_t) ReadBlobLSBLong(image);\n        if (length > (size_t) GetBlobSize(image))\n          ThrowDCMException(CorruptImageError,\"InsufficientImageDataInFile\")\n        stream_info->offset_count=length >> 2;\n        if (stream_info->offset_count != 0)\n          {\n            if (stream_info->offsets != (ssize_t *) NULL)\n              stream_info->offsets=(ssize_t *) RelinquishMagickMemory(\n                stream_info->offsets);\n            stream_info->offsets=(ssize_t *) AcquireQuantumMemory(\n              stream_info->offset_count,sizeof(*stream_info->offsets));\n            if (stream_info->offsets == (ssize_t *) NULL)\n              ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n            for (i=0; i < (ssize_t) stream_info->offset_count; i++)\n              stream_info->offsets[i]=(ssize_t) ReadBlobLSBSignedLong(image);\n            offset=TellBlob(image);\n            for (i=0; i < (ssize_t) stream_info->offset_count; i++)\n              stream_info->offsets[i]+=offset;\n          }\n        \/*\n          Handle non-native image formats.\n        *\/\n        read_info=CloneImageInfo(image_info);\n        SetImageInfoBlob(read_info,(void *) NULL,0);\n        images=NewImageList();\n        for (scene=0; scene < (ssize_t) number_scenes; scene++)\n        {\n          char\n            filename[MagickPathExtent];\n\n          const char\n            *property;\n\n          FILE\n            *file;\n\n          Image\n            *jpeg_image;\n\n          int\n            unique_file;\n\n          unsigned int\n            tag;\n\n          tag=((unsigned int) ReadBlobLSBShort(image) << 16) |\n            ReadBlobLSBShort(image);\n          length=(size_t) ReadBlobLSBLong(image);\n          if (length > (size_t) GetBlobSize(image))\n            {\n              images=DestroyImageList(images);\n              read_info=DestroyImageInfo(read_info);\n              ThrowDCMException(CorruptImageError,\"InsufficientImageDataInFile\")\n            }\n          if (EOFBlob(image) != MagickFalse)\n            {\n              status=MagickFalse;\n              break;\n            }\n          if (tag == 0xFFFEE0DD)\n            break; \/* sequence delimiter tag *\/\n          if (tag != 0xFFFEE000)\n            {\n              status=MagickFalse;\n              break;\n            }\n          file=(FILE *) NULL;\n          unique_file=AcquireUniqueFileResource(filename);\n          if (unique_file != -1)\n            file=fdopen(unique_file,\"wb\");\n          if (file == (FILE *) NULL)\n            {\n              (void) RelinquishUniqueFileResource(filename);\n              ThrowFileException(exception,FileOpenError,\n                \"UnableToCreateTemporaryFile\",filename);\n              break;\n            }\n          for (c=EOF; length != 0; length--)\n          {\n            c=ReadBlobByte(image);\n            if (c == EOF)\n              {\n                ThrowFileException(exception,CorruptImageError,\n                  \"UnexpectedEndOfFile\",image->filename);\n                break;\n              }\n            if (fputc(c,file) != c)\n              break;\n          }\n          (void) fclose(file);\n          if (c == EOF)\n            break;\n          (void) FormatLocaleString(read_info->filename,MagickPathExtent,\n            \"jpeg:%s\",filename);\n          if (image->compression == JPEG2000Compression)\n            (void) FormatLocaleString(read_info->filename,MagickPathExtent,\n              \"j2k:%s\",filename);\n          jpeg_image=ReadImage(read_info,exception);\n          if (jpeg_image != (Image *) NULL)\n            {\n              ResetImagePropertyIterator(image);\n              property=GetNextImageProperty(image);\n              while (property != (const char *) NULL)\n              {\n                (void) SetImageProperty(jpeg_image,property,\n                  GetImageProperty(image,property,exception),exception);\n                property=GetNextImageProperty(image);\n              }\n              AppendImageToList(&images,jpeg_image);\n            }\n          (void) RelinquishUniqueFileResource(filename);\n        }\n        read_info=DestroyImageInfo(read_info);\n        image=DestroyImageList(image);\n        if ((status == MagickFalse) && (exception->severity < ErrorException))\n          {\n            images=DestroyImageList(images);\n            ThrowDCMException(CorruptImageError,\"CorruptImageError\")\n          }\n        else\n          RelinquishDCMMemory(&info,&map,stream_info,stack,data);\n        return(GetFirstImageInList(images));\n      }\n    if (info.depth != (1UL*MAGICKCORE_QUANTUM_DEPTH))\n      {\n        QuantumAny\n          range;\n\n        \/*\n          Compute pixel scaling table.\n        *\/\n        length=(size_t) (GetQuantumRange(info.depth)+1);\n        if (length > (size_t) GetBlobSize(image))\n          ThrowDCMException(CorruptImageError,\"InsufficientImageDataInFile\")\n        if (info.scale != (Quantum *) NULL)\n          info.scale=(Quantum *) RelinquishMagickMemory(info.scale);\n        info.scale_size=MagickMax(length,MaxMap)+1;\n        info.scale=(Quantum *) AcquireQuantumMemory(info.scale_size,\n          sizeof(*info.scale));\n        if (info.scale == (Quantum *) NULL)\n          ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n        (void) memset(info.scale,0,(MagickMax(length,MaxMap)+1)*\n          sizeof(*info.scale));\n        range=GetQuantumRange(info.depth);\n        for (i=0; i <= (ssize_t) GetQuantumRange(info.depth); i++)\n          info.scale[i]=ScaleAnyToQuantum((size_t) i,range);\n      }\n    if (image->compression == RLECompression)\n      {\n        unsigned int\n          tag;\n\n        \/*\n          Read RLE offset table.\n        *\/\n        for (i=0; i < (ssize_t) stream_info->remaining; i++)\n        {\n          int\n            c;\n\n          c=ReadBlobByte(image);\n          if (c == EOF)\n            break;\n        }\n        tag=((unsigned int) ReadBlobLSBShort(image) << 16) |\n          ReadBlobLSBShort(image);\n        (void) tag;\n        length=(size_t) ReadBlobLSBLong(image);\n        if (length > (size_t) GetBlobSize(image))\n          ThrowDCMException(CorruptImageError,\"InsufficientImageDataInFile\")\n        stream_info->offset_count=length >> 2;\n        if (stream_info->offset_count != 0)\n          {\n            if (stream_info->offsets != (ssize_t *) NULL)\n              stream_info->offsets=(ssize_t *)\n                RelinquishMagickMemory(stream_info->offsets);\n            stream_info->offsets=(ssize_t *) AcquireQuantumMemory(\n              stream_info->offset_count,sizeof(*stream_info->offsets));\n            if (stream_info->offsets == (ssize_t *) NULL)\n              ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n            for (i=0; i < (ssize_t) stream_info->offset_count; i++)\n            {\n              offset=(MagickOffsetType) ReadBlobLSBSignedLong(image);\n              if (offset > (MagickOffsetType) GetBlobSize(image))\n                ThrowDCMException(CorruptImageError,\n                  \"InsufficientImageDataInFile\")\n              stream_info->offsets[i]=(ssize_t) offset;\n              if (EOFBlob(image) != MagickFalse)\n                break;\n            }\n            offset=TellBlob(image)+8;\n            for (i=0; i < (ssize_t) stream_info->offset_count; i++)\n              stream_info->offsets[i]+=offset;\n          }\n      }\n    for (scene=0; scene < (ssize_t) number_scenes; scene++)\n    {\n      image->columns=info.width;\n      image->rows=info.height;\n      image->depth=info.depth;\n      status=SetImageExtent(image,image->columns,image->rows,exception);\n      if (status == MagickFalse)\n        break;\n      image->colorspace=RGBColorspace;\n      (void) SetImageBackgroundColor(image,exception);\n      if ((image->colormap == (PixelInfo *) NULL) &&\n          (info.samples_per_pixel == 1))\n        {\n          int\n            index;\n\n          size_t\n            one;\n\n          one=1;\n          if (colors == 0)\n            colors=one << info.depth;\n          if (AcquireImageColormap(image,colors,exception) == MagickFalse)\n            ThrowDCMException(ResourceLimitError,\"MemoryAllocationFailed\")\n          if (map.red != (int *) NULL)\n            for (i=0; i < (ssize_t) colors; i++)\n            {\n              index=map.red[i];\n              if ((info.scale != (Quantum *) NULL) && (index >= 0) &&\n                  (index <= (int) info.max_value))\n                index=(int) info.scale[index];\n              image->colormap[i].red=(MagickRealType) index;\n            }\n          if (map.green != (int *) NULL)\n            for (i=0; i < (ssize_t) colors; i++)\n            {\n              index=map.green[i];\n              if ((info.scale != (Quantum *) NULL) && (index >= 0) &&\n                  (index <= (int) info.max_value))\n                index=(int) info.scale[index];\n              image->colormap[i].green=(MagickRealType) index;\n            }\n          if (map.blue != (int *) NULL)\n            for (i=0; i < (ssize_t) colors; i++)\n            {\n              index=map.blue[i];\n              if ((info.scale != (Quantum *) NULL) && (index >= 0) &&\n                  (index <= (int) info.max_value))\n                index=(int) info.scale[index];\n              image->colormap[i].blue=(MagickRealType) index;\n            }\n          if (map.gray != (int *) NULL)\n            for (i=0; i < (ssize_t) colors; i++)\n            {\n              index=map.gray[i];\n              if ((info.scale != (Quantum *) NULL) && (index >= 0) &&\n                  (index <= (int) info.max_value))\n                index=(int) info.scale[index];\n              image->colormap[i].red=(MagickRealType) index;\n              image->colormap[i].green=(MagickRealType) index;\n              image->colormap[i].blue=(MagickRealType) index;\n            }\n        }\n      if (image->compression == RLECompression)\n        {\n          unsigned int\n            tag;\n\n          \/*\n            Read RLE segment table.\n          *\/\n          for (i=0; i < (ssize_t) stream_info->remaining; i++)\n          {\n            int\n              c;\n\n            c=ReadBlobByte(image);\n            if (c == EOF)\n              break;\n          }\n          tag=((unsigned int) ReadBlobLSBShort(image) << 16) |\n            ReadBlobLSBShort(image);\n          stream_info->remaining=(size_t) ReadBlobLSBLong(image);\n          if ((tag != 0xFFFEE000) || (stream_info->remaining <= 64) ||\n              (EOFBlob(image) != MagickFalse))\n            {\n              if (stream_info->offsets != (ssize_t *) NULL)\n                stream_info->offsets=(ssize_t *)\n                  RelinquishMagickMemory(stream_info->offsets);\n              ThrowDCMException(CorruptImageError,\"ImproperImageHeader\")\n            }\n          stream_info->count=0;\n          stream_info->segment_count=ReadBlobLSBLong(image);\n          for (i=0; i < 15; i++)\n            stream_info->segments[i]=(ssize_t) ReadBlobLSBSignedLong(image);\n          stream_info->remaining-=64;\n          if (stream_info->segment_count > 1)\n            {\n              info.bytes_per_pixel=1;\n              info.depth=8;\n              if (stream_info->offset_count > 0)\n                (void) SeekBlob(image,(MagickOffsetType)\n                  stream_info->offsets[0]+stream_info->segments[0],SEEK_SET);\n            }\n        }\n      if ((info.samples_per_pixel > 1) && (image->interlace == PlaneInterlace))\n        {\n          Quantum\n            *q;\n\n          ssize_t\n            x,\n            y;\n\n          \/*\n            Convert Planar RGB DCM Medical image to pixel packets.\n          *\/\n          for (i=0; i < (ssize_t) info.samples_per_pixel; i++)\n          {\n            for (y=0; y < (ssize_t) image->rows; y++)\n            {\n              q=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n              if (q == (Quantum *) NULL)\n                break;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                switch ((int) i)\n                {\n                  case 0:\n                  {\n                    SetPixelRed(image,ScaleCharToQuantum((unsigned char)\n                      ReadDCMByte(stream_info,image)),q);\n                    break;\n                  }\n                  case 1:\n                  {\n                    SetPixelGreen(image,ScaleCharToQuantum((unsigned char)\n                      ReadDCMByte(stream_info,image)),q);\n                    break;\n                  }\n                  case 2:\n                  {\n                    SetPixelBlue(image,ScaleCharToQuantum((unsigned char)\n                      ReadDCMByte(stream_info,image)),q);\n                    break;\n                  }\n                  case 3:\n                  {\n                    SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)\n                      ReadDCMByte(stream_info,image)),q);\n                    break;\n                  }\n                  default:\n                    break;\n                }\n                q+=GetPixelChannels(image);\n              }\n              if (SyncAuthenticPixels(image,exception) == MagickFalse)\n                break;\n              if (image->previous == (Image *) NULL)\n                {\n                  status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                    y,image->rows);\n                  if (status == MagickFalse)\n                    break;\n                }\n            }\n          }\n        }\n      else\n        {\n          const char\n            *option;\n\n          \/*\n            Convert DCM Medical image to pixel packets.\n          *\/\n          option=GetImageOption(image_info,\"dcm:display-range\");\n          if (option != (const char *) NULL)\n            {\n              if (LocaleCompare(option,\"reset\") == 0)\n                info.window_width=0;\n            }\n          option=GetImageOption(image_info,\"dcm:window\");\n          if (option != (char *) NULL)\n            {\n              GeometryInfo\n                geometry_info;\n\n              MagickStatusType\n                flags;\n\n              flags=ParseGeometry(option,&geometry_info);\n              if (flags & RhoValue)\n                info.window_center=geometry_info.rho;\n              if (flags & SigmaValue)\n                info.window_width=geometry_info.sigma;\n              info.rescale=MagickTrue;\n            }\n          option=GetImageOption(image_info,\"dcm:rescale\");\n          if (option != (char *) NULL)\n            info.rescale=IsStringTrue(option);\n          if ((info.window_center != 0) && (info.window_width == 0))\n            info.window_width=info.window_center;\n          status=ReadDCMPixels(image,&info,stream_info,MagickTrue,exception);\n          if ((status != MagickFalse) && (stream_info->segment_count > 1))\n            {\n              if (stream_info->offset_count > 0)\n                (void) SeekBlob(image,(MagickOffsetType)\n                  stream_info->offsets[0]+stream_info->segments[1],SEEK_SET);\n              (void) ReadDCMPixels(image,&info,stream_info,MagickFalse,\n                exception);\n            }\n        }\n      if (IdentifyImageCoderGray(image,exception) != MagickFalse)\n        (void) SetImageColorspace(image,GRAYColorspace,exception);\n      if (EOFBlob(image) != MagickFalse)\n        {\n          ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n            image->filename);\n          break;\n        }\n      \/*\n        Proceed to next image.\n      *\/\n      if (image_info->number_scenes != 0)\n        if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n          break;\n      if (scene < (ssize_t) (number_scenes-1))\n        {\n          \/*\n            Allocate next image structure.\n          *\/\n          AcquireNextImage(image_info,image,exception);\n          if (GetNextImageInList(image) == (Image *) NULL)\n            {\n              status=MagickFalse;\n              break;\n            }\n          image=SyncNextImageInList(image);\n          status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n            GetBlobSize(image));\n          if (status == MagickFalse)\n            break;\n        }\n    }\n    if (TellBlob(image) < (MagickOffsetType) GetBlobSize(image))\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image,exception);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n     }\n  }\n  \/*\n    Free resources.\n  *\/\n  RelinquishDCMMemory(&info,&map,stream_info,stack,data);\n  if (image == (Image *) NULL)\n    return(image);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":10206,"total_token_length":10442,"max_tokens_setting":11000}
+{"idx":400405,"func":"edit(\n    int\t\tcmdchar,\n    int\t\tstartln,\t\/\/ if set, insert at start of line\n    long\tcount)\n{\n    int\t\tc = 0;\n    char_u\t*ptr;\n    int\t\tlastc = 0;\n    int\t\tmincol;\n    static linenr_T o_lnum = 0;\n    int\t\ti;\n    int\t\tdid_backspace = TRUE;\t    \/\/ previous char was backspace\n    int\t\tline_is_white = FALSE;\t    \/\/ line is empty before insert\n    linenr_T\told_topline = 0;\t    \/\/ topline before insertion\n#ifdef FEAT_DIFF\n    int\t\told_topfill = -1;\n#endif\n    int\t\tinserted_space = FALSE;     \/\/ just inserted a space\n    int\t\treplaceState = MODE_REPLACE;\n    int\t\tnomove = FALSE;\t\t    \/\/ don't move cursor on return\n#ifdef FEAT_JOB_CHANNEL\n    int\t\tcmdchar_todo = cmdchar;\n#endif\n#ifdef FEAT_CONCEAL\n    int\t\tcursor_line_was_concealed;\n#endif\n\n    \/\/ Remember whether editing was restarted after CTRL-O.\n    did_restart_edit = restart_edit;\n\n    \/\/ sleep before redrawing, needed for \"CTRL-O :\" that results in an\n    \/\/ error message\n    check_for_delay(TRUE);\n\n    \/\/ set Insstart_orig to Insstart\n    update_Insstart_orig = TRUE;\n\n#ifdef HAVE_SANDBOX\n    \/\/ Don't allow inserting in the sandbox.\n    if (sandbox != 0)\n    {\n\temsg(_(e_not_allowed_in_sandbox));\n\treturn FALSE;\n    }\n#endif\n    \/\/ Don't allow changes in the buffer while editing the cmdline.  The\n    \/\/ caller of getcmdline() may get confused.\n    \/\/ Don't allow recursive insert mode when busy with completion.\n    if (textlock != 0 || ins_compl_active() || compl_busy || pum_visible())\n    {\n\temsg(_(e_not_allowed_to_change_text_or_change_window));\n\treturn FALSE;\n    }\n    ins_compl_clear();\t    \/\/ clear stuff for CTRL-X mode\n\n    \/*\n     * Trigger InsertEnter autocommands.  Do not do this for \"r<CR>\" or \"grx\".\n     *\/\n    if (cmdchar != 'r' && cmdchar != 'v')\n    {\n\tpos_T   save_cursor = curwin->w_cursor;\n\n#ifdef FEAT_EVAL\n\tif (cmdchar == 'R')\n\t    ptr = (char_u *)\"r\";\n\telse if (cmdchar == 'V')\n\t    ptr = (char_u *)\"v\";\n\telse\n\t    ptr = (char_u *)\"i\";\n\tset_vim_var_string(VV_INSERTMODE, ptr, 1);\n\tset_vim_var_string(VV_CHAR, NULL, -1);  \/\/ clear v:char\n#endif\n\tins_apply_autocmds(EVENT_INSERTENTER);\n\n\t\/\/ Check for changed highlighting, e.g. for ModeMsg.\n\tif (need_highlight_changed)\n\t    highlight_changed();\n\n\t\/\/ Make sure the cursor didn't move.  Do call check_cursor_col() in\n\t\/\/ case the text was modified.  Since Insert mode was not started yet\n\t\/\/ a call to check_cursor_col() may move the cursor, especially with\n\t\/\/ the \"A\" command, thus set State to avoid that. Also check that the\n\t\/\/ line number is still valid (lines may have been deleted).\n\t\/\/ Do not restore if v:char was set to a non-empty string.\n\tif (!EQUAL_POS(curwin->w_cursor, save_cursor)\n#ifdef FEAT_EVAL\n\t\t&& *get_vim_var_str(VV_CHAR) == NUL\n#endif\n\t\t&& save_cursor.lnum <= curbuf->b_ml.ml_line_count)\n\t{\n\t    int save_state = State;\n\n\t    curwin->w_cursor = save_cursor;\n\t    State = MODE_INSERT;\n\t    check_cursor_col();\n\t    State = save_state;\n\t}\n    }\n\n#ifdef FEAT_CONCEAL\n    \/\/ Check if the cursor line was concealed before changing State.\n    cursor_line_was_concealed = curwin->w_p_cole > 0\n\t\t\t\t\t\t&& conceal_cursor_line(curwin);\n#endif\n\n    \/*\n     * When doing a paste with the middle mouse button, Insstart is set to\n     * where the paste started.\n     *\/\n    if (where_paste_started.lnum != 0)\n\tInsstart = where_paste_started;\n    else\n    {\n\tInsstart = curwin->w_cursor;\n\tif (startln)\n\t    Insstart.col = 0;\n    }\n    Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());\n    Insstart_blank_vcol = MAXCOL;\n    if (!did_ai)\n\tai_col = 0;\n\n    if (cmdchar != NUL && restart_edit == 0)\n    {\n\tResetRedobuff();\n\tAppendNumberToRedobuff(count);\n\tif (cmdchar == 'V' || cmdchar == 'v')\n\t{\n\t    \/\/ \"gR\" or \"gr\" command\n\t    AppendCharToRedobuff('g');\n\t    AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R');\n\t}\n\telse\n\t{\n\t    if (cmdchar == K_PS)\n\t\tAppendCharToRedobuff('a');\n\t    else\n\t\tAppendCharToRedobuff(cmdchar);\n\t    if (cmdchar == 'g')\t\t    \/\/ \"gI\" command\n\t\tAppendCharToRedobuff('I');\n\t    else if (cmdchar == 'r')\t    \/\/ \"r<CR>\" command\n\t\tcount = 1;\t\t    \/\/ insert only one <CR>\n\t}\n    }\n\n    if (cmdchar == 'R')\n    {\n\tState = MODE_REPLACE;\n    }\n    else if (cmdchar == 'V' || cmdchar == 'v')\n    {\n\tState = MODE_VREPLACE;\n\treplaceState = MODE_VREPLACE;\n\torig_line_count = curbuf->b_ml.ml_line_count;\n\tvr_lines_changed = 1;\n    }\n    else\n\tState = MODE_INSERT;\n\n    may_trigger_modechanged();\n    stop_insert_mode = FALSE;\n\n#ifdef FEAT_CONCEAL\n    \/\/ Check if the cursor line needs redrawing after changing State.  If\n    \/\/ 'concealcursor' is \"n\" it needs to be redrawn without concealing.\n    conceal_check_cursor_line(cursor_line_was_concealed);\n#endif\n\n    \/\/ Need to position cursor again when on a TAB and when on a char with\n    \/\/ virtual text.\n    if (gchar_cursor() == TAB\n#ifdef FEAT_PROP_POPUP\n\t    || curbuf->b_has_textprop\n#endif\n       )\n\tcurwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);\n\n    \/*\n     * Enable langmap or IME, indicated by 'iminsert'.\n     * Note that IME may enabled\/disabled without us noticing here, thus the\n     * 'iminsert' value may not reflect what is actually used.  It is updated\n     * when hitting <Esc>.\n     *\/\n    if (curbuf->b_p_iminsert == B_IMODE_LMAP)\n\tState |= MODE_LANGMAP;\n#ifdef HAVE_INPUT_METHOD\n    im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);\n#endif\n\n    setmouse();\n#ifdef FEAT_CMDL_INFO\n    clear_showcmd();\n#endif\n#ifdef FEAT_RIGHTLEFT\n    \/\/ there is no reverse replace mode\n    revins_on = (State == MODE_INSERT && p_ri);\n    if (revins_on)\n\tundisplay_dollar();\n    revins_chars = 0;\n    revins_legal = 0;\n    revins_scol = -1;\n#endif\n    if (!p_ek)\n    {\n\tMAY_WANT_TO_LOG_THIS;\n\n\t\/\/ Disable bracketed paste mode, we won't recognize the escape\n\t\/\/ sequences.\n\tout_str(T_BD);\n\n\t\/\/ Disable modifyOtherKeys, keys with modifiers would cause exiting\n\t\/\/ Insert mode.\n\tout_str(T_CTE);\n    }\n\n    \/*\n     * Handle restarting Insert mode.\n     * Don't do this for \"CTRL-O .\" (repeat an insert): In that case we get\n     * here with something in the stuff buffer.\n     *\/\n    if (restart_edit != 0 && stuff_empty())\n    {\n\t\/*\n\t * After a paste we consider text typed to be part of the insert for\n\t * the pasted text. You can backspace over the pasted text too.\n\t *\/\n\tif (where_paste_started.lnum)\n\t    arrow_used = FALSE;\n\telse\n\t    arrow_used = TRUE;\n\trestart_edit = 0;\n\n\t\/*\n\t * If the cursor was after the end-of-line before the CTRL-O and it is\n\t * now at the end-of-line, put it after the end-of-line (this is not\n\t * correct in very rare cases).\n\t * Also do this if curswant is greater than the current virtual\n\t * column.  Eg after \"^O$\" or \"^O80|\".\n\t *\/\n\tvalidate_virtcol();\n\tupdate_curswant();\n\tif (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)\n\t\t    || curwin->w_curswant > curwin->w_virtcol)\n\t\t&& *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL)\n\t{\n\t    if (ptr[1] == NUL)\n\t\t++curwin->w_cursor.col;\n\t    else if (has_mbyte)\n\t    {\n\t\ti = (*mb_ptr2len)(ptr);\n\t\tif (ptr[i] == NUL)\n\t\t    curwin->w_cursor.col += i;\n\t    }\n\t}\n\tins_at_eol = FALSE;\n    }\n    else\n\tarrow_used = FALSE;\n\n    \/\/ we are in insert mode now, don't need to start it anymore\n    need_start_insertmode = FALSE;\n\n    \/\/ Need to save the line for undo before inserting the first char.\n    ins_need_undo = TRUE;\n\n    where_paste_started.lnum = 0;\n    can_cindent = TRUE;\n#ifdef FEAT_FOLDING\n    \/\/ The cursor line is not in a closed fold, unless 'insertmode' is set or\n    \/\/ restarting.\n    if (!p_im && did_restart_edit == 0)\n\tfoldOpenCursor();\n#endif\n\n    \/*\n     * If 'showmode' is set, show the current (insert\/replace\/..) mode.\n     * A warning message for changing a readonly file is given here, before\n     * actually changing anything.  It's put after the mode, if any.\n     *\/\n    i = 0;\n    if (p_smd && msg_silent == 0)\n\ti = showmode();\n\n    if (!p_im && did_restart_edit == 0)\n\tchange_warning(i == 0 ? 0 : i + 1);\n\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n#ifdef FEAT_DIGRAPHS\n    do_digraph(-1);\t\t\/\/ clear digraphs\n#endif\n\n    \/*\n     * Get the current length of the redo buffer, those characters have to be\n     * skipped if we want to get to the inserted characters.\n     *\/\n    ptr = get_inserted();\n    if (ptr == NULL)\n\tnew_insert_skip = 0;\n    else\n    {\n\tnew_insert_skip = (int)STRLEN(ptr);\n\tvim_free(ptr);\n    }\n\n    old_indent = 0;\n\n    \/*\n     * Main loop in Insert mode: repeat until Insert mode is left.\n     *\/\n    for (;;)\n    {\n#ifdef FEAT_RIGHTLEFT\n\tif (!revins_legal)\n\t    revins_scol = -1;\t    \/\/ reset on illegal motions\n\telse\n\t    revins_legal = 0;\n#endif\n\tif (arrow_used)\t    \/\/ don't repeat insert when arrow key used\n\t    count = 0;\n\n\tif (update_Insstart_orig)\n\t    Insstart_orig = Insstart;\n\n\tif (stop_insert_mode && !ins_compl_active())\n\t{\n\t    \/\/ \":stopinsert\" used or 'insertmode' reset\n\t    count = 0;\n\t    goto doESCkey;\n\t}\n\n\t\/\/ set curwin->w_curswant for next K_DOWN or K_UP\n\tif (!arrow_used)\n\t    curwin->w_set_curswant = TRUE;\n\n\t\/\/ If there is no typeahead may check for timestamps (e.g., for when a\n\t\/\/ menu invoked a shell command).\n\tif (stuff_empty())\n\t{\n\t    did_check_timestamps = FALSE;\n\t    if (need_check_timestamps)\n\t\tcheck_timestamps(FALSE);\n\t}\n\n\t\/*\n\t * When emsg() was called msg_scroll will have been set.\n\t *\/\n\tmsg_scroll = FALSE;\n\n#ifdef FEAT_GUI\n\t\/\/ When 'mousefocus' is set a mouse movement may have taken us to\n\t\/\/ another window.  \"need_mouse_correct\" may then be set because of an\n\t\/\/ autocommand.\n\tif (need_mouse_correct)\n\t    gui_mouse_correct();\n#endif\n\n#ifdef FEAT_FOLDING\n\t\/\/ Open fold at the cursor line, according to 'foldopen'.\n\tif (fdo_flags & FDO_INSERT)\n\t    foldOpenCursor();\n\t\/\/ Close folds where the cursor isn't, according to 'foldclose'\n\tif (!char_avail())\n\t    foldCheckClose();\n#endif\n\n#ifdef FEAT_JOB_CHANNEL\n\tif (bt_prompt(curbuf))\n\t{\n\t    init_prompt(cmdchar_todo);\n\t    cmdchar_todo = NUL;\n\t}\n#endif\n\n\t\/*\n\t * If we inserted a character at the last position of the last line in\n\t * the window, scroll the window one line up. This avoids an extra\n\t * redraw.\n\t * This is detected when the cursor column is smaller after inserting\n\t * something.\n\t * Don't do this when the topline changed already, it has\n\t * already been adjusted (by insertchar() calling open_line())).\n\t *\/\n\tif (curbuf->b_mod_set\n\t\t&& curwin->w_p_wrap\n\t\t&& !did_backspace\n\t\t&& curwin->w_topline == old_topline\n#ifdef FEAT_DIFF\n\t\t&& curwin->w_topfill == old_topfill\n#endif\n\t\t)\n\t{\n\t    mincol = curwin->w_wcol;\n\t    validate_cursor_col();\n\n\t    if (\n#ifdef FEAT_VARTABS\n\t\tcurwin->w_wcol < mincol - tabstop_at(\n\t\t\t\t\t  get_nolist_virtcol(), curbuf->b_p_ts,\n\t\t\t\t\t\t\t curbuf->b_p_vts_array)\n#else\n\t\t(int)curwin->w_wcol < mincol - curbuf->b_p_ts\n#endif\n\t\t    && curwin->w_wrow == W_WINROW(curwin)\n\t\t\t\t + curwin->w_height - 1 - get_scrolloff_value()\n\t\t    && (curwin->w_cursor.lnum != curwin->w_topline\n#ifdef FEAT_DIFF\n\t\t\t|| curwin->w_topfill > 0\n#endif\n\t\t    ))\n\t    {\n#ifdef FEAT_DIFF\n\t\tif (curwin->w_topfill > 0)\n\t\t    --curwin->w_topfill;\n\t\telse\n#endif\n#ifdef FEAT_FOLDING\n\t\tif (hasFolding(curwin->w_topline, NULL, &old_topline))\n\t\t    set_topline(curwin, old_topline + 1);\n\t\telse\n#endif\n\t\t    set_topline(curwin, curwin->w_topline + 1);\n\t    }\n\t}\n\n\t\/\/ May need to adjust w_topline to show the cursor.\n\tupdate_topline();\n\n\tdid_backspace = FALSE;\n\n\tvalidate_cursor();\t\t\/\/ may set must_redraw\n\n\t\/*\n\t * Redraw the display when no characters are waiting.\n\t * Also shows mode, ruler and positions cursor.\n\t *\/\n\tins_redraw(TRUE);\n\n\tif (curwin->w_p_scb)\n\t    do_check_scrollbind(TRUE);\n\n\tif (curwin->w_p_crb)\n\t    do_check_cursorbind();\n\tupdate_curswant();\n\told_topline = curwin->w_topline;\n#ifdef FEAT_DIFF\n\told_topfill = curwin->w_topfill;\n#endif\n\n#ifdef USE_ON_FLY_SCROLL\n\tdont_scroll = FALSE;\t\t\/\/ allow scrolling here\n#endif\n\n\t\/*\n\t * Get a character for Insert mode.  Ignore K_IGNORE and K_NOP.\n\t *\/\n\tif (c != K_CURSORHOLD)\n\t    lastc = c;\t\t\/\/ remember the previous char for CTRL-D\n\n\t\/\/ After using CTRL-G U the next cursor key will not break undo.\n\tif (dont_sync_undo == MAYBE)\n\t    dont_sync_undo = TRUE;\n\telse\n\t    dont_sync_undo = FALSE;\n\tif (cmdchar == K_PS)\n\t    \/\/ Got here from normal mode when bracketed paste started.\n\t    c = K_PS;\n\telse\n\t    do\n\t    {\n\t\tc = safe_vgetc();\n\n\t\tif (stop_insert_mode\n#ifdef FEAT_TERMINAL\n\t\t\t|| (c == K_IGNORE && term_use_loop())\n#endif\n\t\t   )\n\t\t{\n\t\t    \/\/ Insert mode ended, possibly from a callback, or a timer\n\t\t    \/\/ must have opened a terminal window.\n\t\t    if (c != K_IGNORE && c != K_NOP)\n\t\t\tvungetc(c);\n\t\t    count = 0;\n\t\t    nomove = TRUE;\n\t\t    ins_compl_prep(ESC);\n\t\t    goto doESCkey;\n\t\t}\n\t    } while (c == K_IGNORE || c == K_NOP);\n\n\t\/\/ Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V.\n\tdid_cursorhold = TRUE;\n\n#ifdef FEAT_RIGHTLEFT\n\tif (p_hkmap && KeyTyped)\n\t    c = hkmap(c);\t\t\/\/ Hebrew mode mapping\n#endif\n\n\t\/\/ If the window was made so small that nothing shows, make it at least\n\t\/\/ one line and one column when typing.\n\tif (KeyTyped && !KeyStuffed)\n\t    win_ensure_size();\n\n\t\/*\n\t * Special handling of keys while the popup menu is visible or wanted\n\t * and the cursor is still in the completed word.  Only when there is\n\t * a match, skip this when no matches were found.\n\t *\/\n\tif (ins_compl_active()\n\t\t&& pum_wanted()\n\t\t&& curwin->w_cursor.col >= ins_compl_col()\n\t\t&& ins_compl_has_shown_match())\n\t{\n\t    \/\/ BS: Delete one character from \"compl_leader\".\n\t    if ((c == K_BS || c == Ctrl_H)\n\t\t\t&& curwin->w_cursor.col > ins_compl_col()\n\t\t\t&& (c = ins_compl_bs()) == NUL)\n\t\tcontinue;\n\n\t    \/\/ When no match was selected or it was edited.\n\t    if (!ins_compl_used_match())\n\t    {\n\t\t\/\/ CTRL-L: Add one character from the current match to\n\t\t\/\/ \"compl_leader\".  Except when at the original match and\n\t\t\/\/ there is nothing to add, CTRL-L works like CTRL-P then.\n\t\tif (c == Ctrl_L\n\t\t\t&& (!ctrl_x_mode_line_or_eval()\n\t\t\t    || ins_compl_long_shown_match()))\n\t\t{\n\t\t    ins_compl_addfrommatch();\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ A non-white character that fits in with the current\n\t\t\/\/ completion: Add to \"compl_leader\".\n\t\tif (ins_compl_accept_char(c))\n\t\t{\n#if defined(FEAT_EVAL)\n\t\t    \/\/ Trigger InsertCharPre.\n\t\t    char_u *str = do_insert_char_pre(c);\n\t\t    char_u *p;\n\n\t\t    if (str != NULL)\n\t\t    {\n\t\t\tfor (p = str; *p != NUL; MB_PTR_ADV(p))\n\t\t\t    ins_compl_addleader(PTR2CHAR(p));\n\t\t\tvim_free(str);\n\t\t    }\n\t\t    else\n#endif\n\t\t\tins_compl_addleader(c);\n\t\t    continue;\n\t\t}\n\n\t\t\/\/ Pressing CTRL-Y selects the current match.  When\n\t\t\/\/ ins_compl_enter_selects() is set the Enter key does the\n\t\t\/\/ same.\n\t\tif ((c == Ctrl_Y || (ins_compl_enter_selects()\n\t\t\t\t    && (c == CAR || c == K_KENTER || c == NL)))\n\t\t\t&& stop_arrow() == OK)\n\t\t{\n\t\t    ins_compl_delete();\n\t\t    ins_compl_insert(FALSE);\n\t\t}\n\t    }\n\t}\n\n\t\/\/ Prepare for or stop CTRL-X mode.  This doesn't do completion, but\n\t\/\/ it does fix up the text when finishing completion.\n\tins_compl_init_get_longest();\n\tif (ins_compl_prep(c))\n\t    continue;\n\n\t\/\/ CTRL-\\ CTRL-N goes to Normal mode,\n\t\/\/ CTRL-\\ CTRL-G goes to mode selected with 'insertmode',\n\t\/\/ CTRL-\\ CTRL-O is like CTRL-O but without moving the cursor.\n\tif (c == Ctrl_BSL)\n\t{\n\t    \/\/ may need to redraw when no more chars available now\n\t    ins_redraw(FALSE);\n\t    ++no_mapping;\n\t    ++allow_keys;\n\t    c = plain_vgetc();\n\t    --no_mapping;\n\t    --allow_keys;\n\t    if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O)\n\t    {\n\t\t\/\/ it's something else\n\t\tvungetc(c);\n\t\tc = Ctrl_BSL;\n\t    }\n\t    else if (c == Ctrl_G && p_im)\n\t\tcontinue;\n\t    else\n\t    {\n\t\tif (c == Ctrl_O)\n\t\t{\n\t\t    ins_ctrl_o();\n\t\t    ins_at_eol = FALSE;\t\/\/ cursor keeps its column\n\t\t    nomove = TRUE;\n\t\t}\n\t\tcount = 0;\n\t\tgoto doESCkey;\n\t    }\n\t}\n\n#ifdef FEAT_DIGRAPHS\n\tc = do_digraph(c);\n#endif\n\n\tif ((c == Ctrl_V || c == Ctrl_Q) && ctrl_x_mode_cmdline())\n\t    goto docomplete;\n\tif (c == Ctrl_V || c == Ctrl_Q)\n\t{\n\t    ins_ctrl_v();\n\t    c = Ctrl_V;\t\/\/ pretend CTRL-V is last typed character\n\t    continue;\n\t}\n\n\tif (cindent_on() && ctrl_x_mode_none())\n\t{\n\t    \/\/ A key name preceded by a bang means this key is not to be\n\t    \/\/ inserted.  Skip ahead to the re-indenting below.\n\t    \/\/ A key name preceded by a star means that indenting has to be\n\t    \/\/ done before inserting the key.\n\t    line_is_white = inindent(0);\n\t    if (in_cinkeys(c, '!', line_is_white))\n\t\tgoto force_cindent;\n\t    if (can_cindent && in_cinkeys(c, '*', line_is_white)\n\t\t\t\t\t\t\t&& stop_arrow() == OK)\n\t\tdo_c_expr_indent();\n\t}\n\n#ifdef FEAT_RIGHTLEFT\n\tif (curwin->w_p_rl)\n\t    switch (c)\n\t    {\n\t\tcase K_LEFT:\tc = K_RIGHT; break;\n\t\tcase K_S_LEFT:\tc = K_S_RIGHT; break;\n\t\tcase K_C_LEFT:\tc = K_C_RIGHT; break;\n\t\tcase K_RIGHT:\tc = K_LEFT; break;\n\t\tcase K_S_RIGHT: c = K_S_LEFT; break;\n\t\tcase K_C_RIGHT: c = K_C_LEFT; break;\n\t    }\n#endif\n\n\t\/*\n\t * If 'keymodel' contains \"startsel\", may start selection.  If it\n\t * does, a CTRL-O and c will be stuffed, we need to get these\n\t * characters.\n\t *\/\n\tif (ins_start_select(c))\n\t    continue;\n\n\t\/*\n\t * The big switch to handle a character in insert mode.\n\t *\/\n\tswitch (c)\n\t{\n\tcase ESC:\t\/\/ End input mode\n\t    if (echeck_abbr(ESC + ABBR_OFF))\n\t\tbreak;\n\t    \/\/ FALLTHROUGH\n\n\tcase Ctrl_C:\t\/\/ End input mode\n#ifdef FEAT_CMDWIN\n\t    if (c == Ctrl_C && cmdwin_type != 0)\n\t    {\n\t\t\/\/ Close the cmdline window.\n\t\tcmdwin_result = K_IGNORE;\n\t\tgot_int = FALSE; \/\/ don't stop executing autocommands et al.\n\t\tnomove = TRUE;\n\t\tgoto doESCkey;\n\t    }\n#endif\n#ifdef FEAT_JOB_CHANNEL\n\t    if (c == Ctrl_C && bt_prompt(curbuf))\n\t    {\n\t\tif (invoke_prompt_interrupt())\n\t\t{\n\t\t    if (!bt_prompt(curbuf))\n\t\t\t\/\/ buffer changed to a non-prompt buffer, get out of\n\t\t\t\/\/ Insert mode\n\t\t\tgoto doESCkey;\n\t\t    break;\n\t\t}\n\t    }\n#endif\n\n#ifdef UNIX\ndo_intr:\n#endif\n\t    \/\/ when 'insertmode' set, and not halfway a mapping, don't leave\n\t    \/\/ Insert mode\n\t    if (goto_im())\n\t    {\n\t\tif (got_int)\n\t\t{\n\t\t    (void)vgetc();\t\t\/\/ flush all buffers\n\t\t    got_int = FALSE;\n\t\t}\n\t\telse\n\t\t    vim_beep(BO_IM);\n\t\tbreak;\n\t    }\ndoESCkey:\n\t    \/*\n\t     * This is the ONLY return from edit()!\n\t     *\/\n\t    \/\/ Always update o_lnum, so that a \"CTRL-O .\" that adds a line\n\t    \/\/ still puts the cursor back after the inserted text.\n\t    if (ins_at_eol && gchar_cursor() == NUL)\n\t\to_lnum = curwin->w_cursor.lnum;\n\n\t    if (ins_esc(&count, cmdchar, nomove))\n\t    {\n\t\t\/\/ When CTRL-C was typed got_int will be set, with the result\n\t\t\/\/ that the autocommands won't be executed. When mapped got_int\n\t\t\/\/ is not set, but let's keep the behavior the same.\n\t\tif (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C)\n\t\t    ins_apply_autocmds(EVENT_INSERTLEAVE);\n\t\tdid_cursorhold = FALSE;\n\t\treturn (c == Ctrl_O);\n\t    }\n\t    continue;\n\n\tcase Ctrl_Z:\t\/\/ suspend when 'insertmode' set\n\t    if (!p_im)\n\t\tgoto normalchar;\t\/\/ insert CTRL-Z as normal char\n\t    do_cmdline_cmd((char_u *)\"stop\");\n#ifdef CURSOR_SHAPE\n\t    ui_cursor_shape();\t\t\/\/ may need to update cursor shape\n#endif\n\t    continue;\n\n\tcase Ctrl_O:\t\/\/ execute one command\n#ifdef FEAT_COMPL_FUNC\n\t    if (ctrl_x_mode_omni())\n\t\tgoto docomplete;\n#endif\n\t    if (echeck_abbr(Ctrl_O + ABBR_OFF))\n\t\tbreak;\n\t    ins_ctrl_o();\n\n\t    \/\/ don't move the cursor left when 'virtualedit' has \"onemore\".\n\t    if (get_ve_flags() & VE_ONEMORE)\n\t    {\n\t\tins_at_eol = FALSE;\n\t\tnomove = TRUE;\n\t    }\n\t    count = 0;\n\t    goto doESCkey;\n\n\tcase K_INS:\t\/\/ toggle insert\/replace mode\n\tcase K_KINS:\n\t    ins_insert(replaceState);\n\t    break;\n\n\tcase K_SELECT:\t\/\/ end of Select mode mapping - ignore\n\t    break;\n\n\tcase K_HELP:\t\/\/ Help key works like <ESC> <Help>\n\tcase K_F1:\n\tcase K_XF1:\n\t    stuffcharReadbuff(K_HELP);\n\t    if (p_im)\n\t\tneed_start_insertmode = TRUE;\n\t    goto doESCkey;\n\n#ifdef FEAT_NETBEANS_INTG\n\tcase K_F21:\t\/\/ NetBeans command\n\t    ++no_mapping;\t\t\/\/ don't map the next key hits\n\t    i = plain_vgetc();\n\t    --no_mapping;\n\t    netbeans_keycommand(i);\n\t    break;\n#endif\n\n\tcase K_ZERO:\t\/\/ Insert the previously inserted text.\n\tcase NUL:\n\tcase Ctrl_A:\n\t    \/\/ For ^@ the trailing ESC will end the insert, unless there is an\n\t    \/\/ error.\n\t    if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL\n\t\t\t\t\t\t   && c != Ctrl_A && !p_im)\n\t\tgoto doESCkey;\t\t\/\/ quit insert mode\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase Ctrl_R:\t\/\/ insert the contents of a register\n\t    ins_reg();\n\t    auto_format(FALSE, TRUE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase Ctrl_G:\t\/\/ commands starting with CTRL-G\n\t    ins_ctrl_g();\n\t    break;\n\n\tcase Ctrl_HAT:\t\/\/ switch input mode and\/or langmap\n\t    ins_ctrl_hat();\n\t    break;\n\n#ifdef FEAT_RIGHTLEFT\n\tcase Ctrl__:\t\/\/ switch between languages\n\t    if (!p_ari)\n\t\tgoto normalchar;\n\t    ins_ctrl_();\n\t    break;\n#endif\n\n\tcase Ctrl_D:\t\/\/ Make indent one shiftwidth smaller.\n#if defined(FEAT_FIND_ID)\n\t    if (ctrl_x_mode_path_defines())\n\t\tgoto docomplete;\n#endif\n\t    \/\/ FALLTHROUGH\n\n\tcase Ctrl_T:\t\/\/ Make indent one shiftwidth greater.\n\t    if (c == Ctrl_T && ctrl_x_mode_thesaurus())\n\t    {\n\t\tif (has_compl_option(FALSE))\n\t\t    goto docomplete;\n\t\tbreak;\n\t    }\n\n\t    ins_shift(c, lastc);\n\t    auto_format(FALSE, TRUE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase K_DEL:\t\/\/ delete character under the cursor\n\tcase K_KDEL:\n\t    ins_del();\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase K_BS:\t\/\/ delete character before the cursor\n\tcase K_S_BS:\n\tcase Ctrl_H:\n\t    did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase Ctrl_W:\t\/\/ delete word before the cursor\n#ifdef FEAT_JOB_CHANNEL\n\t    if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0)\n\t    {\n\t\t\/\/ In a prompt window CTRL-W is used for window commands.\n\t\t\/\/ Use Shift-CTRL-W to delete a word.\n\t\tstuffcharReadbuff(Ctrl_W);\n\t\trestart_edit = 'A';\n\t\tnomove = TRUE;\n\t\tcount = 0;\n\t\tgoto doESCkey;\n\t    }\n#endif\n\t    did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase Ctrl_U:\t\/\/ delete all inserted text in current line\n# ifdef FEAT_COMPL_FUNC\n\t    \/\/ CTRL-X CTRL-U completes with 'completefunc'.\n\t    if (ctrl_x_mode_function())\n\t\tgoto docomplete;\n# endif\n\t    did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space);\n\t    auto_format(FALSE, TRUE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase K_LEFTMOUSE:   \/\/ mouse keys\n\tcase K_LEFTMOUSE_NM:\n\tcase K_LEFTDRAG:\n\tcase K_LEFTRELEASE:\n\tcase K_LEFTRELEASE_NM:\n\tcase K_MOUSEMOVE:\n\tcase K_MIDDLEMOUSE:\n\tcase K_MIDDLEDRAG:\n\tcase K_MIDDLERELEASE:\n\tcase K_RIGHTMOUSE:\n\tcase K_RIGHTDRAG:\n\tcase K_RIGHTRELEASE:\n\tcase K_X1MOUSE:\n\tcase K_X1DRAG:\n\tcase K_X1RELEASE:\n\tcase K_X2MOUSE:\n\tcase K_X2DRAG:\n\tcase K_X2RELEASE:\n\t    ins_mouse(c);\n\t    break;\n\n\tcase K_MOUSEDOWN: \/\/ Default action for scroll wheel up: scroll up\n\t    ins_mousescroll(MSCR_DOWN);\n\t    break;\n\n\tcase K_MOUSEUP:\t\/\/ Default action for scroll wheel down: scroll down\n\t    ins_mousescroll(MSCR_UP);\n\t    break;\n\n\tcase K_MOUSELEFT: \/\/ Scroll wheel left\n\t    ins_mousescroll(MSCR_LEFT);\n\t    break;\n\n\tcase K_MOUSERIGHT: \/\/ Scroll wheel right\n\t    ins_mousescroll(MSCR_RIGHT);\n\t    break;\n\n\tcase K_PS:\n\t    bracketed_paste(PASTE_INSERT, FALSE, NULL);\n\t    if (cmdchar == K_PS)\n\t\t\/\/ invoked from normal mode, bail out\n\t\tgoto doESCkey;\n\t    break;\n\tcase K_PE:\n\t    \/\/ Got K_PE without K_PS, ignore.\n\t    break;\n\n#ifdef FEAT_GUI_TABLINE\n\tcase K_TABLINE:\n\tcase K_TABMENU:\n\t    ins_tabline(c);\n\t    break;\n#endif\n\n\tcase K_IGNORE:\t\/\/ Something mapped to nothing\n\t    break;\n\n\tcase K_COMMAND:\t\t    \/\/ <Cmd>command<CR>\n\tcase K_SCRIPT_COMMAND:\t    \/\/ <ScriptCmd>command<CR>\n\t    do_cmdkey_command(c, 0);\n#ifdef FEAT_TERMINAL\n\t    if (term_use_loop())\n\t\t\/\/ Started a terminal that gets the input, exit Insert mode.\n\t\tgoto doESCkey;\n#endif\n\t    break;\n\n\tcase K_CURSORHOLD:\t\/\/ Didn't type something for a while.\n\t    ins_apply_autocmds(EVENT_CURSORHOLDI);\n\t    did_cursorhold = TRUE;\n\t    \/\/ If CTRL-G U was used apply it to the next typed key.\n\t    if (dont_sync_undo == TRUE)\n\t\tdont_sync_undo = MAYBE;\n\t    break;\n\n#ifdef FEAT_GUI_MSWIN\n\t    \/\/ On MS-Windows ignore <M-F4>, we get it when closing the window\n\t    \/\/ was cancelled.\n\tcase K_F4:\n\t    if (mod_mask != MOD_MASK_ALT)\n\t\tgoto normalchar;\n\t    break;\n#endif\n\n#ifdef FEAT_GUI\n\tcase K_VER_SCROLLBAR:\n\t    ins_scroll();\n\t    break;\n\n\tcase K_HOR_SCROLLBAR:\n\t    ins_horscroll();\n\t    break;\n#endif\n\n\tcase K_HOME:\t\/\/ <Home>\n\tcase K_KHOME:\n\tcase K_S_HOME:\n\tcase K_C_HOME:\n\t    ins_home(c);\n\t    break;\n\n\tcase K_END:\t\/\/ <End>\n\tcase K_KEND:\n\tcase K_S_END:\n\tcase K_C_END:\n\t    ins_end(c);\n\t    break;\n\n\tcase K_LEFT:\t\/\/ <Left>\n\t    if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))\n\t\tins_s_left();\n\t    else\n\t\tins_left();\n\t    break;\n\n\tcase K_S_LEFT:\t\/\/ <S-Left>\n\tcase K_C_LEFT:\n\t    ins_s_left();\n\t    break;\n\n\tcase K_RIGHT:\t\/\/ <Right>\n\t    if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))\n\t\tins_s_right();\n\t    else\n\t\tins_right();\n\t    break;\n\n\tcase K_S_RIGHT:\t\/\/ <S-Right>\n\tcase K_C_RIGHT:\n\t    ins_s_right();\n\t    break;\n\n\tcase K_UP:\t\/\/ <Up>\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    if (mod_mask & MOD_MASK_SHIFT)\n\t\tins_pageup();\n\t    else\n\t\tins_up(FALSE);\n\t    break;\n\n\tcase K_S_UP:\t\/\/ <S-Up>\n\tcase K_PAGEUP:\n\tcase K_KPAGEUP:\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    ins_pageup();\n\t    break;\n\n\tcase K_DOWN:\t\/\/ <Down>\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    if (mod_mask & MOD_MASK_SHIFT)\n\t\tins_pagedown();\n\t    else\n\t\tins_down(FALSE);\n\t    break;\n\n\tcase K_S_DOWN:\t\/\/ <S-Down>\n\tcase K_PAGEDOWN:\n\tcase K_KPAGEDOWN:\n\t    if (pum_visible())\n\t\tgoto docomplete;\n\t    ins_pagedown();\n\t    break;\n\n#ifdef FEAT_DND\n\tcase K_DROP:\t\/\/ drag-n-drop event\n\t    ins_drop();\n\t    break;\n#endif\n\n\tcase K_S_TAB:\t\/\/ When not mapped, use like a normal TAB\n\t    c = TAB;\n\t    \/\/ FALLTHROUGH\n\n\tcase TAB:\t\/\/ TAB or Complete patterns along path\n#if defined(FEAT_FIND_ID)\n\t    if (ctrl_x_mode_path_patterns())\n\t\tgoto docomplete;\n#endif\n\t    inserted_space = FALSE;\n\t    if (ins_tab())\n\t\tgoto normalchar;\t\/\/ insert TAB as a normal char\n\t    auto_format(FALSE, TRUE);\n\t    break;\n\n\tcase K_KENTER:\t\/\/ <Enter>\n\t    c = CAR;\n\t    \/\/ FALLTHROUGH\n\tcase CAR:\n\tcase NL:\n#if defined(FEAT_QUICKFIX)\n\t    \/\/ In a quickfix window a <CR> jumps to the error under the\n\t    \/\/ cursor.\n\t    if (bt_quickfix(curbuf) && c == CAR)\n\t    {\n\t\tif (curwin->w_llist_ref == NULL)    \/\/ quickfix window\n\t\t    do_cmdline_cmd((char_u *)\".cc\");\n\t\telse\t\t\t\t    \/\/ location list window\n\t\t    do_cmdline_cmd((char_u *)\".ll\");\n\t\tbreak;\n\t    }\n#endif\n#ifdef FEAT_CMDWIN\n\t    if (cmdwin_type != 0)\n\t    {\n\t\t\/\/ Execute the command in the cmdline window.\n\t\tcmdwin_result = CAR;\n\t\tgoto doESCkey;\n\t    }\n#endif\n#ifdef FEAT_JOB_CHANNEL\n\t    if (bt_prompt(curbuf))\n\t    {\n\t\tinvoke_prompt_callback();\n\t\tif (!bt_prompt(curbuf))\n\t\t    \/\/ buffer changed to a non-prompt buffer, get out of\n\t\t    \/\/ Insert mode\n\t\t    goto doESCkey;\n\t\tbreak;\n\t    }\n#endif\n\t    if (ins_eol(c) == FAIL && !p_im)\n\t\tgoto doESCkey;\t    \/\/ out of memory\n\t    auto_format(FALSE, FALSE);\n\t    inserted_space = FALSE;\n\t    break;\n\n\tcase Ctrl_K:\t    \/\/ digraph or keyword completion\n\t    if (ctrl_x_mode_dictionary())\n\t    {\n\t\tif (has_compl_option(TRUE))\n\t\t    goto docomplete;\n\t\tbreak;\n\t    }\n#ifdef FEAT_DIGRAPHS\n\t    c = ins_digraph();\n\t    if (c == NUL)\n\t\tbreak;\n#endif\n\t    goto normalchar;\n\n\tcase Ctrl_X:\t\/\/ Enter CTRL-X mode\n\t    ins_ctrl_x();\n\t    break;\n\n\tcase Ctrl_RSB:\t\/\/ Tag name completion after ^X\n\t    if (!ctrl_x_mode_tags())\n\t\tgoto normalchar;\n\t    goto docomplete;\n\n\tcase Ctrl_F:\t\/\/ File name completion after ^X\n\t    if (!ctrl_x_mode_files())\n\t\tgoto normalchar;\n\t    goto docomplete;\n\n\tcase 's':\t\/\/ Spelling completion after ^X\n\tcase Ctrl_S:\n\t    if (!ctrl_x_mode_spell())\n\t\tgoto normalchar;\n\t    goto docomplete;\n\n\tcase Ctrl_L:\t\/\/ Whole line completion after ^X\n\t    if (!ctrl_x_mode_whole_line())\n\t    {\n\t\t\/\/ CTRL-L with 'insertmode' set: Leave Insert mode\n\t\tif (p_im)\n\t\t{\n\t\t    if (echeck_abbr(Ctrl_L + ABBR_OFF))\n\t\t\tbreak;\n\t\t    goto doESCkey;\n\t\t}\n\t\tgoto normalchar;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase Ctrl_P:\t\/\/ Do previous\/next pattern completion\n\tcase Ctrl_N:\n\t    \/\/ if 'complete' is empty then plain ^P is no longer special,\n\t    \/\/ but it is under other ^X modes\n\t    if (*curbuf->b_p_cpt == NUL\n\t\t    && (ctrl_x_mode_normal() || ctrl_x_mode_whole_line())\n\t\t    && !compl_status_local())\n\t\tgoto normalchar;\n\ndocomplete:\n\t    compl_busy = TRUE;\n#ifdef FEAT_FOLDING\n\t    disable_fold_update++;  \/\/ don't redraw folds here\n#endif\n\t    if (ins_complete(c, TRUE) == FAIL)\n\t\tcompl_status_clear();\n#ifdef FEAT_FOLDING\n\t    disable_fold_update--;\n#endif\n\t    compl_busy = FALSE;\n\t    can_si = may_do_si(); \/\/ allow smartindenting\n\t    break;\n\n\tcase Ctrl_Y:\t\/\/ copy from previous line or scroll down\n\tcase Ctrl_E:\t\/\/ copy from next line\t   or scroll up\n\t    c = ins_ctrl_ey(c);\n\t    break;\n\n\t  default:\n#ifdef UNIX\n\t    if (c == intr_char)\t\t\/\/ special interrupt char\n\t\tgoto do_intr;\n#endif\n\nnormalchar:\n\t    \/*\n\t     * Insert a normal character.\n\t     *\/\n#if defined(FEAT_EVAL)\n\t    if (!p_paste)\n\t    {\n\t\t\/\/ Trigger InsertCharPre.\n\t\tchar_u *str = do_insert_char_pre(c);\n\t\tchar_u *p;\n\n\t\tif (str != NULL)\n\t\t{\n\t\t    if (*str != NUL && stop_arrow() != FAIL)\n\t\t    {\n\t\t\t\/\/ Insert the new value of v:char literally.\n\t\t\tfor (p = str; *p != NUL; MB_PTR_ADV(p))\n\t\t\t{\n\t\t\t    c = PTR2CHAR(p);\n\t\t\t    if (c == CAR || c == K_KENTER || c == NL)\n\t\t\t\tins_eol(c);\n\t\t\t    else\n\t\t\t\tins_char(c);\n\t\t\t}\n\t\t\tAppendToRedobuffLit(str, -1);\n\t\t    }\n\t\t    vim_free(str);\n\t\t    c = NUL;\n\t\t}\n\n\t\t\/\/ If the new value is already inserted or an empty string\n\t\t\/\/ then don't insert any character.\n\t\tif (c == NUL)\n\t\t    break;\n\t    }\n#endif\n\t    \/\/ Try to perform smart-indenting.\n\t    ins_try_si(c);\n\n\t    if (c == ' ')\n\t    {\n\t\tinserted_space = TRUE;\n\t\tif (inindent(0))\n\t\t    can_cindent = FALSE;\n\t\tif (Insstart_blank_vcol == MAXCOL\n\t\t\t&& curwin->w_cursor.lnum == Insstart.lnum)\n\t\t    Insstart_blank_vcol = get_nolist_virtcol();\n\t    }\n\n\t    \/\/ Insert a normal character and check for abbreviations on a\n\t    \/\/ special character.  Let CTRL-] expand abbreviations without\n\t    \/\/ inserting it.\n\t    if (vim_iswordc(c) || (!echeck_abbr(\n\t\t\t\/\/ Add ABBR_OFF for characters above 0x100, this is\n\t\t\t\/\/ what check_abbr() expects.\n\t\t\t\t(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c)\n\t\t\t&& c != Ctrl_RSB))\n\t    {\n\t\tinsert_special(c, FALSE, FALSE);\n#ifdef FEAT_RIGHTLEFT\n\t\trevins_legal++;\n\t\trevins_chars++;\n#endif\n\t    }\n\n\t    auto_format(FALSE, TRUE);\n\n#ifdef FEAT_FOLDING\n\t    \/\/ When inserting a character the cursor line must never be in a\n\t    \/\/ closed fold.\n\t    foldOpenCursor();\n#endif\n\t    break;\n\t}   \/\/ end of switch (c)\n\n\t\/\/ If typed something may trigger CursorHoldI again.\n\tif (c != K_CURSORHOLD\n#ifdef FEAT_COMPL_FUNC\n\t\t\/\/ but not in CTRL-X mode, a script can't restore the state\n\t\t&& ctrl_x_mode_normal()\n#endif\n\t       )\n\t    did_cursorhold = FALSE;\n\n\t\/\/ If the cursor was moved we didn't just insert a space\n\tif (arrow_used)\n\t    inserted_space = FALSE;\n\n\tif (can_cindent && cindent_on() && ctrl_x_mode_normal())\n\t{\nforce_cindent:\n\t    \/*\n\t     * Indent now if a key was typed that is in 'cinkeys'.\n\t     *\/\n\t    if (in_cinkeys(c, ' ', line_is_white))\n\t    {\n\t\tif (stop_arrow() == OK)\n\t\t    \/\/ re-indent the current line\n\t\t    do_c_expr_indent();\n\t    }\n\t}\n\n    }\t\/\/ for (;;)\n    \/\/ NOTREACHED\n}","target":0,"code_token_length":9054,"total_token_length":9290,"max_tokens_setting":11000}
+{"idx":439128,"func":"static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define ThrowPNMException(exception,message) \\\n{ \\\n  if (comment_info.comment != (char *) NULL)  \\\n    comment_info.comment=DestroyString(comment_info.comment); \\\n  ThrowReaderException((exception),(message)); \\\n}\n\n  char\n    format;\n\n  CommentInfo\n    comment_info;\n\n  double\n    quantum_scale;\n\n  Image\n    *image;\n\n  MagickBooleanType\n    status;\n\n  QuantumAny\n    max_value;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  size_t\n    depth,\n    extent,\n    packet_size;\n\n  ssize_t\n    count,\n    row,\n    y;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Read PNM image.\n  *\/\n  count=ReadBlob(image,1,(unsigned char *) &format);\n  do\n  {\n    \/*\n      Initialize image structure.\n    *\/\n   comment_info.comment=AcquireString(NULL);\n    comment_info.extent=MagickPathExtent;\n    if ((count != 1) || (format != 'P'))\n      ThrowPNMException(CorruptImageError,\"ImproperImageHeader\");\n    max_value=1;\n    quantum_type=RGBQuantum;\n    quantum_scale=1.0;\n    format=(char) ReadBlobByte(image);\n    if (format != '7')\n      {\n        \/*\n          PBM, PGM, PPM, and PNM.\n        *\/\n        image->columns=PNMInteger(image,&comment_info,10);\n        image->rows=PNMInteger(image,&comment_info,10);\n        if ((format == 'f') || (format == 'F'))\n          {\n            char\n              scale[MaxTextExtent];\n\n            if (ReadBlobString(image,scale) != (char *) NULL)\n              quantum_scale=StringToDouble(scale,(char **) NULL);\n          }\n        else\n          {\n            if ((format == '1') || (format == '4'))\n              max_value=1;  \/* bitmap *\/\n            else\n              max_value=PNMInteger(image,&comment_info,10);\n          }\n      }\n    else\n      {\n        char\n          keyword[MaxTextExtent],\n          value[MaxTextExtent];\n\n        int\n          c;\n\n        register char\n          *p;\n\n        \/*\n          PAM.\n        *\/\n        for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))\n        {\n          while (isspace((int) ((unsigned char) c)) != 0)\n            c=ReadBlobByte(image);\n          if (c == '#')\n            {\n              \/*\n                Comment.\n              *\/\n              c=PNMComment(image,&comment_info);\n              c=ReadBlobByte(image);\n              while (isspace((int) ((unsigned char) c)) != 0)\n                c=ReadBlobByte(image);\n            }\n          p=keyword;\n          do\n          {\n            if ((size_t) (p-keyword) < (MaxTextExtent-1))\n              *p++=c;\n            c=ReadBlobByte(image);\n          } while (isalnum(c));\n          *p='\\0';\n          if (LocaleCompare(keyword,\"endhdr\") == 0)\n            break;\n          while (isspace((int) ((unsigned char) c)) != 0)\n            c=ReadBlobByte(image);\n          p=value;\n          while (isalnum(c) || (c == '_'))\n          {\n            if ((size_t) (p-value) < (MaxTextExtent-1))\n              *p++=c;\n            c=ReadBlobByte(image);\n          }\n          *p='\\0';\n          \/*\n            Assign a value to the specified keyword.\n          *\/\n          if (LocaleCompare(keyword,\"depth\") == 0)\n            packet_size=StringToUnsignedLong(value);\n          (void) packet_size;\n          if (LocaleCompare(keyword,\"height\") == 0)\n            image->rows=StringToUnsignedLong(value);\n          if (LocaleCompare(keyword,\"maxval\") == 0)\n            max_value=StringToUnsignedLong(value);\n          if (LocaleCompare(keyword,\"TUPLTYPE\") == 0)\n            {\n              if (LocaleCompare(value,\"BLACKANDWHITE\") == 0)\n                {\n                  (void) SetImageColorspace(image,GRAYColorspace);\n                  quantum_type=GrayQuantum;\n                }\n              if (LocaleCompare(value,\"BLACKANDWHITE_ALPHA\") == 0)\n                {\n                  (void) SetImageColorspace(image,GRAYColorspace);\n                  image->matte=MagickTrue;\n                  quantum_type=GrayAlphaQuantum;\n                }\n              if (LocaleCompare(value,\"GRAYSCALE\") == 0)\n                {\n                  (void) SetImageColorspace(image,GRAYColorspace);\n                  quantum_type=GrayQuantum;\n                }\n              if (LocaleCompare(value,\"GRAYSCALE_ALPHA\") == 0)\n                {\n                  (void) SetImageColorspace(image,GRAYColorspace);\n                  image->matte=MagickTrue;\n                  quantum_type=GrayAlphaQuantum;\n                }\n              if (LocaleCompare(value,\"RGB_ALPHA\") == 0)\n                {\n                  quantum_type=RGBAQuantum;\n                  image->matte=MagickTrue;\n                }\n              if (LocaleCompare(value,\"CMYK\") == 0)\n                {\n                  (void) SetImageColorspace(image,CMYKColorspace);\n                  quantum_type=CMYKQuantum;\n                }\n              if (LocaleCompare(value,\"CMYK_ALPHA\") == 0)\n                {\n                  (void) SetImageColorspace(image,CMYKColorspace);\n                  image->matte=MagickTrue;\n                  quantum_type=CMYKAQuantum;\n                }\n            }\n          if (LocaleCompare(keyword,\"width\") == 0)\n            image->columns=StringToUnsignedLong(value);\n        }\n      }\n    if ((image->columns == 0) || (image->rows == 0))\n      ThrowPNMException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if ((max_value == 0) || (max_value > 4294967295U))\n      ThrowPNMException(CorruptImageError,\"ImproperImageHeader\");\n    for (depth=1; GetQuantumRange(depth) < max_value; depth++) ;\n    image->depth=depth;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    (void) SetImageBackgroundColor(image);\n    \/*\n      Convert PNM pixels.\n    *\/\n    row=0;\n    switch (format)\n    {\n      case '1':\n      {\n        \/*\n          Convert PBM image to pixel packets.\n        *\/\n        (void) SetImageColorspace(image,GRAYColorspace);\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register ssize_t\n            x;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(q,PNMInteger(image,&comment_info,2) == 0 ?\n              QuantumRange : 0);\n            if (EOFBlob(image) != MagickFalse)\n              break;\n            SetPixelGreen(q,GetPixelRed(q));\n            SetPixelBlue(q,GetPixelRed(q));\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n          if (EOFBlob(image) != MagickFalse)\n            break;\n        }\n        image->type=BilevelType;\n        break;\n      }\n      case '2':\n      {\n        size_t\n          intensity;\n\n        \/*\n          Convert PGM image to pixel packets.\n        *\/\n        (void) SetImageColorspace(image,GRAYColorspace);\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register ssize_t\n            x;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            intensity=ScaleAnyToQuantum(PNMInteger(image,&comment_info,10),\n              max_value);\n            if (EOFBlob(image) != MagickFalse)\n              break;\n            SetPixelRed(q,intensity);\n            SetPixelGreen(q,GetPixelRed(q));\n            SetPixelBlue(q,GetPixelRed(q));\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n          if (EOFBlob(image) != MagickFalse)\n            break;\n        }\n        image->type=GrayscaleType;\n        break;\n      }\n      case '3':\n      {\n        \/*\n          Convert PNM image to pixel packets.\n        *\/\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          register ssize_t\n            x;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            QuantumAny\n              pixel;\n\n            pixel=ScaleAnyToQuantum(PNMInteger(image,&comment_info,10),\n              max_value);\n            if (EOFBlob(image) != MagickFalse)\n              break;\n            SetPixelRed(q,pixel);\n            pixel=ScaleAnyToQuantum(PNMInteger(image,&comment_info,10),\n              max_value);\n            SetPixelGreen(q,pixel);\n            pixel=ScaleAnyToQuantum(PNMInteger(image,&comment_info,10),\n              max_value);\n            SetPixelBlue(q,pixel);\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n          if (EOFBlob(image) != MagickFalse)\n            break;\n        }\n        break;\n      }\n      case '4':\n      {\n        \/*\n          Convert PBM raw image to pixel packets.\n        *\/\n        (void) SetImageColorspace(image,GRAYColorspace);\n        quantum_type=GrayQuantum;\n        if (image->storage_class == PseudoClass)\n          quantum_type=IndexQuantum;\n        quantum_info=AcquireQuantumInfo(image_info,image);\n        if (quantum_info == (QuantumInfo *) NULL)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        SetQuantumMinIsWhite(quantum_info,MagickTrue);\n        extent=GetQuantumExtent(image,quantum_info,quantum_type);\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          const unsigned char\n            *pixels;\n\n          MagickBooleanType\n            sync;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          ssize_t\n            count,\n            offset;\n\n          size_t\n            length;\n\n          pixels=(unsigned char *) ReadBlobStream(image,extent,\n            GetQuantumPixels(quantum_info),&count);\n          if (count != (ssize_t) extent)\n            break;\n          if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&\n              (image->previous == (Image *) NULL))\n            {\n              MagickBooleanType\n                proceed;\n\n              proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                row,image->rows);\n              if (proceed == MagickFalse)\n                break;\n            }\n          offset=row++;\n          q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n            quantum_type,pixels,exception);\n          if (length != extent)\n            break;\n          sync=SyncAuthenticPixels(image,exception);\n          if (sync == MagickFalse)\n            break;\n        }\n        quantum_info=DestroyQuantumInfo(quantum_info);\n        SetQuantumImageType(image,quantum_type);\n        break;\n      }\n      case '5':\n      {\n        \/*\n          Convert PGM raw image to pixel packets.\n        *\/\n        (void) SetImageColorspace(image,GRAYColorspace);\n        quantum_type=GrayQuantum;\n        extent=(image->depth <= 8 ? 1 : image->depth <= 16 ? 2 : 4)*\n          image->columns;\n        quantum_info=AcquireQuantumInfo(image_info,image);\n        if (quantum_info == (QuantumInfo *) NULL)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          const unsigned char\n            *pixels;\n\n          MagickBooleanType\n            sync;\n\n          register const unsigned char\n            *magick_restrict p;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          register ssize_t\n            x;\n\n          ssize_t\n            count,\n            offset;\n\n          pixels=(unsigned char *) ReadBlobStream(image,extent,\n            GetQuantumPixels(quantum_info),&count);\n          if (count != (ssize_t) extent)\n            break;\n          if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&\n              (image->previous == (Image *) NULL))\n            {\n              MagickBooleanType\n                proceed;\n\n              proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                row,image->rows);\n              if (proceed == MagickFalse)\n                break;\n            }\n          offset=row++;\n          q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          p=pixels;\n          switch (image->depth)\n          {\n            case 8:\n            case 16:\n            case 32:\n            {\n              (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n                quantum_type,pixels,exception);\n              break;\n            }\n            default:\n            {\n              unsigned int\n                pixel;\n\n              if (image->depth <= 8)\n                {\n                  unsigned char\n                    pixel;\n\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushCharPixel(p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelGreen(q,GetPixelRed(q));\n                    SetPixelBlue(q,GetPixelRed(q));\n                    q++;\n                  }\n                  break;\n                }\n              if (image->depth <= 16)\n                {\n                  unsigned short\n                    pixel;\n\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushShortPixel(MSBEndian,p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelGreen(q,GetPixelRed(q));\n                    SetPixelBlue(q,GetPixelRed(q));\n                    q++;\n                  }\n                  break;\n                }\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                SetPixelGreen(q,GetPixelRed(q));\n                SetPixelBlue(q,GetPixelRed(q));\n                q++;\n              }\n              break;\n            }\n          }\n          sync=SyncAuthenticPixels(image,exception);\n          if (sync == MagickFalse)\n            break;\n        }\n        quantum_info=DestroyQuantumInfo(quantum_info);\n        SetQuantumImageType(image,quantum_type);\n        break;\n      }\n      case '6':\n      {\n        \/*\n          Convert PNM raster image to pixel packets.\n        *\/\n        quantum_type=RGBQuantum;\n        extent=3*(image->depth <= 8 ? 1 : image->depth <= 16 ? 2 : 4)*\n          image->columns;\n        quantum_info=AcquireQuantumInfo(image_info,image);\n        if (quantum_info == (QuantumInfo *) NULL)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) SetQuantumEndian(image,quantum_info,MSBEndian);\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          const unsigned char\n            *pixels;\n\n          MagickBooleanType\n            sync;\n\n          register const unsigned char\n            *magick_restrict p;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          register ssize_t\n            x;\n\n          ssize_t\n            count,\n            offset;\n\n          pixels=(unsigned char *) ReadBlobStream(image,extent,\n            GetQuantumPixels(quantum_info),&count);\n          if (count != (ssize_t) extent)\n            break;\n          if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&\n              (image->previous == (Image *) NULL))\n            {\n              MagickBooleanType\n                proceed;\n\n              proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                row,image->rows);\n              if (proceed == MagickFalse)\n                break;\n            }\n          offset=row++;\n          q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          p=pixels;\n          switch (image->depth)\n          {\n            case 8:\n            {\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                SetPixelRed(q,ScaleCharToQuantum(*p++));\n                SetPixelGreen(q,ScaleCharToQuantum(*p++));\n                SetPixelBlue(q,ScaleCharToQuantum(*p++));\n                q->opacity=OpaqueOpacity;\n                q++;\n              }\n              break;\n            }\n            case 16:\n            {\n              unsigned short\n                pixel;\n\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                p=PushShortPixel(MSBEndian,p,&pixel);\n                SetPixelRed(q,ScaleShortToQuantum(pixel));\n                p=PushShortPixel(MSBEndian,p,&pixel);\n                SetPixelGreen(q,ScaleShortToQuantum(pixel));\n                p=PushShortPixel(MSBEndian,p,&pixel);\n                SetPixelBlue(q,ScaleShortToQuantum(pixel));\n                SetPixelOpacity(q,OpaqueOpacity);\n                q++;\n              }\n              break;\n            }\n            case 32:\n            {\n              unsigned int\n                pixel;\n\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelRed(q,ScaleLongToQuantum(pixel));\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelGreen(q,ScaleLongToQuantum(pixel));\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelBlue(q,ScaleLongToQuantum(pixel));\n                SetPixelOpacity(q,OpaqueOpacity);\n                q++;\n              }\n              break;\n            }\n            default:\n            {\n              unsigned int\n                pixel;\n\n              if (image->depth <= 8)\n                {\n                  unsigned char\n                    pixel;\n\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushCharPixel(p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushCharPixel(p,&pixel);\n                    SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushCharPixel(p,&pixel);\n                    SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelOpacity(q,OpaqueOpacity);\n                    q++;\n                  }\n                  break;\n                }\n              if (image->depth <= 16)\n                {\n                  unsigned short\n                    pixel;\n\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushShortPixel(MSBEndian,p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushShortPixel(MSBEndian,p,&pixel);\n                    SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushShortPixel(MSBEndian,p,&pixel);\n                    SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelOpacity(q,OpaqueOpacity);\n                    q++;\n                  }\n                  break;\n                }\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                p=PushLongPixel(MSBEndian,p,&pixel);\n                SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                SetPixelOpacity(q,OpaqueOpacity);\n                q++;\n              }\n              break;\n            }\n            break;\n          }\n          sync=SyncAuthenticPixels(image,exception);\n          if (sync == MagickFalse)\n            break;\n        }\n        quantum_info=DestroyQuantumInfo(quantum_info);\n        break;\n      }\n      case '7':\n      {\n        register IndexPacket\n          *indexes;\n\n        size_t\n          channels;\n\n        \/*\n          Convert PAM raster image to pixel packets.\n        *\/\n        switch (quantum_type)\n        {\n          case GrayQuantum:\n          case GrayAlphaQuantum:\n          {\n            channels=1;\n            break;\n          }\n          case CMYKQuantum:\n          case CMYKAQuantum:\n          {\n            channels=4;\n            break;\n          }\n          default:\n          {\n            channels=3;\n            break;\n          }\n        }\n        if (image->matte != MagickFalse)\n          channels++;\n        extent=channels*(image->depth <= 8 ? 1 : image->depth <= 16 ? 2 : 4)*\n          image->columns;\n        quantum_info=AcquireQuantumInfo(image_info,image);\n        if (quantum_info == (QuantumInfo *) NULL)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          const unsigned char\n            *pixels;\n\n          MagickBooleanType\n            sync;\n\n          register const unsigned char\n            *magick_restrict p;\n\n          register ssize_t\n            x;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          ssize_t\n            count,\n            offset;\n\n          pixels=(unsigned char *) ReadBlobStream(image,extent,\n            GetQuantumPixels(quantum_info),&count);\n          if (count != (ssize_t) extent)\n            break;\n          if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&\n              (image->previous == (Image *) NULL))\n            {\n              MagickBooleanType\n                proceed;\n\n              proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                row,image->rows);\n              if (proceed == MagickFalse)\n                break;\n            }\n          offset=row++;\n          q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          p=pixels;\n          switch (image->depth)\n          {\n            case 8:\n            case 16:\n            case 32:\n            {\n              (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n                quantum_type,pixels,exception);\n              break;\n            }\n            default:\n            {\n              switch (quantum_type)\n              {\n                case GrayQuantum:\n                case GrayAlphaQuantum:\n                {\n                  unsigned int\n                    pixel;\n\n                  if (image->depth <= 8)\n                    {\n                      unsigned char\n                        pixel;\n\n                      for (x=0; x < (ssize_t) image->columns; x++)\n                      {\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                        SetPixelGreen(q,GetPixelRed(q));\n                        SetPixelBlue(q,GetPixelRed(q));\n                        SetPixelOpacity(q,OpaqueOpacity);\n                        if (image->matte != MagickFalse)\n                          {\n                            p=PushCharPixel(p,&pixel);\n                            if (image->depth != 1)\n                              SetPixelOpacity(q,ScaleAnyToQuantum(pixel,\n                                max_value));\n                            else\n                              SetPixelOpacity(q,QuantumRange-ScaleAnyToQuantum(\n                                pixel,max_value));\n                          }\n                        q++;\n                      }\n                      break;\n                    }\n                  if (image->depth <= 16)\n                    {\n                      unsigned short\n                        pixel;\n\n                      for (x=0; x < (ssize_t) image->columns; x++)\n                      {\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                        SetPixelGreen(q,GetPixelRed(q));\n                        SetPixelBlue(q,GetPixelRed(q));\n                        SetPixelOpacity(q,OpaqueOpacity);\n                        if (image->matte != MagickFalse)\n                          {\n                            p=PushShortPixel(MSBEndian,p,&pixel);\n                            SetPixelOpacity(q,ScaleAnyToQuantum(pixel,\n                              max_value));\n                          }\n                        q++;\n                      }\n                      break;\n                    }\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelGreen(q,GetPixelRed(q));\n                    SetPixelBlue(q,GetPixelRed(q));\n                    SetPixelOpacity(q,OpaqueOpacity);\n                    if (image->matte != MagickFalse)\n                      {\n                        p=PushLongPixel(MSBEndian,p,&pixel);\n                        SetPixelOpacity(q,ScaleAnyToQuantum(pixel,max_value));\n                      }\n                    q++;\n                  }\n                  break;\n                }\n                case CMYKQuantum:\n                case CMYKAQuantum:\n                {\n                  unsigned int\n                    pixel;\n\n                  if (image->depth <= 8)\n                    {\n                      unsigned char\n                        pixel;\n\n                      for (x=0; x < (ssize_t) image->columns; x++)\n                      {\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,\n                          max_value));\n                        SetPixelOpacity(q,OpaqueOpacity);\n                        if (image->matte != MagickFalse)\n                          {\n                            p=PushCharPixel(p,&pixel);\n                            SetPixelOpacity(q,ScaleAnyToQuantum(pixel,\n                              max_value));\n                          }\n                        q++;\n                      }\n                      break;\n                    }\n                  if (image->depth <= 16)\n                    {\n                      unsigned short\n                        pixel;\n\n                      for (x=0; x < (ssize_t) image->columns; x++)\n                      {\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,\n                          max_value));\n                        SetPixelOpacity(q,OpaqueOpacity);\n                        if (image->matte != MagickFalse)\n                          {\n                            p=PushShortPixel(MSBEndian,p,&pixel);\n                            SetPixelOpacity(q,ScaleAnyToQuantum(pixel,\n                              max_value));\n                          }\n                        q++;\n                      }\n                      break;\n                    }\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelOpacity(q,OpaqueOpacity);\n                    if (image->matte != MagickFalse)\n                      {\n                        p=PushLongPixel(MSBEndian,p,&pixel);\n                        SetPixelOpacity(q,ScaleAnyToQuantum(pixel,max_value));\n                      }\n                    q++;\n                  }\n                  break;\n                }\n                default:\n                {\n                  unsigned int\n                    pixel;\n\n                  if (image->depth <= 8)\n                    {\n                      unsigned char\n                        pixel;\n\n                      for (x=0; x < (ssize_t) image->columns; x++)\n                      {\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushCharPixel(p,&pixel);\n                        SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                        SetPixelOpacity(q,OpaqueOpacity);\n                        if (image->matte != MagickFalse)\n                          {\n                            p=PushCharPixel(p,&pixel);\n                            SetPixelOpacity(q,ScaleAnyToQuantum(pixel,\n                              max_value));\n                          }\n                        q++;\n                      }\n                      break;\n                    }\n                  if (image->depth <= 16)\n                    {\n                      unsigned short\n                        pixel;\n\n                      for (x=0; x < (ssize_t) image->columns; x++)\n                      {\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                        p=PushShortPixel(MSBEndian,p,&pixel);\n                        SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                        SetPixelOpacity(q,OpaqueOpacity);\n                        if (image->matte != MagickFalse)\n                          {\n                            p=PushShortPixel(MSBEndian,p,&pixel);\n                            SetPixelOpacity(q,ScaleAnyToQuantum(pixel,\n                              max_value));\n                          }\n                        q++;\n                      }\n                      break;\n                    }\n                  for (x=0; x < (ssize_t) image->columns; x++)\n                  {\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelRed(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelGreen(q,ScaleAnyToQuantum(pixel,max_value));\n                    p=PushLongPixel(MSBEndian,p,&pixel);\n                    SetPixelBlue(q,ScaleAnyToQuantum(pixel,max_value));\n                    SetPixelOpacity(q,OpaqueOpacity);\n                    if (image->matte != MagickFalse)\n                      {\n                        p=PushLongPixel(MSBEndian,p,&pixel);\n                        SetPixelOpacity(q,ScaleAnyToQuantum(pixel,max_value));\n                      }\n                    q++;\n                  }\n                  break;\n                }\n              }\n              break;\n            }\n          }\n          sync=SyncAuthenticPixels(image,exception);\n          if (sync == MagickFalse)\n            break;\n        }\n        quantum_info=DestroyQuantumInfo(quantum_info);\n        SetQuantumImageType(image,quantum_type);\n        break;\n      }\n      case 'F':\n      case 'f':\n      {\n        \/*\n          Convert PFM raster image to pixel packets.\n        *\/\n        if (format == 'f')\n          (void) SetImageColorspace(image,GRAYColorspace);\n        quantum_type=format == 'f' ? GrayQuantum : RGBQuantum;\n        image->endian=quantum_scale < 0.0 ? LSBEndian : MSBEndian;\n        image->depth=32;\n        quantum_info=AcquireQuantumInfo(image_info,image);\n        if (quantum_info == (QuantumInfo *) NULL)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        status=SetQuantumDepth(image,quantum_info,32);\n        if (status == MagickFalse)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);\n        if (status == MagickFalse)\n          ThrowPNMException(ResourceLimitError,\"MemoryAllocationFailed\");\n        SetQuantumScale(quantum_info,(MagickRealType) QuantumRange*\n          fabs(quantum_scale));\n        extent=GetQuantumExtent(image,quantum_info,quantum_type);\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          const unsigned char\n            *pixels;\n\n          MagickBooleanType\n            sync;\n\n          register PixelPacket\n            *magick_restrict q;\n\n          ssize_t\n            count,\n            offset;\n\n          size_t\n            length;\n\n          pixels=(unsigned char *) ReadBlobStream(image,extent,\n            GetQuantumPixels(quantum_info),&count);\n          if ((size_t) count != extent)\n            break;\n          if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&\n              (image->previous == (Image *) NULL))\n            {\n              MagickBooleanType\n                proceed;\n\n              proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                row,image->rows);\n              if (proceed == MagickFalse)\n                break;\n            }\n          offset=row++;\n          q=QueueAuthenticPixels(image,0,(ssize_t) (image->rows-offset-1),\n            image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,\n            quantum_type,pixels,exception);\n          if (length != extent)\n            break;\n          sync=SyncAuthenticPixels(image,exception);\n          if (sync == MagickFalse)\n            break;\n        }\n        quantum_info=DestroyQuantumInfo(quantum_info);\n        SetQuantumImageType(image,quantum_type);\n        break;\n      }\n      default:\n        ThrowPNMException(CorruptImageError,\"ImproperImageHeader\");\n    }\n    if (*comment_info.comment != '\\0')\n      (void) SetImageProperty(image,\"comment\",comment_info.comment);\n    comment_info.comment=DestroyString(comment_info.comment);\n    if (y < (ssize_t) image->rows)\n      ThrowPNMException(CorruptImageError,\"UnableToReadImageData\");\n    if (EOFBlob(image) != MagickFalse)\n      {\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          CorruptImageError,\"UnexpectedEndOfFile\",\"`%s'\",image->filename);\n        break;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    if ((format == '1') || (format == '2') || (format == '3'))\n      do\n      {\n        \/*\n          Skip to end of line.\n        *\/\n        count=ReadBlob(image,1,(unsigned char *) &format);\n        if (count != 1)\n          break;\n        if (format == 'P')\n          break;\n      } while (format != '\\n');\n    count=ReadBlob(image,1,(unsigned char *) &format);\n    if ((count == 1) && (format == 'P'))\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((count == 1) && (format == 'P'));\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":8218,"total_token_length":8454,"max_tokens_setting":11000}
+{"idx":218761,"func":"MagickExport void XColorBrowserWidget(Display *display,XWindows *windows,\n  const char *action,char *reply)\n{\n#define CancelButtonText  \"Cancel\"\n#define ColornameText  \"Name:\"\n#define ColorPatternText  \"Pattern:\"\n#define GrabButtonText  \"Grab\"\n#define ResetButtonText  \"Reset\"\n\n  char\n    **colorlist,\n    primary_selection[MaxTextExtent],\n    reset_pattern[MaxTextExtent],\n    text[MaxTextExtent];\n\n  ExceptionInfo\n    *exception;\n\n  int\n    x,\n    y;\n\n  int\n    i;\n\n  static char\n    glob_pattern[MaxTextExtent] = \"*\";\n\n  static MagickStatusType\n    mask = (MagickStatusType) (CWWidth | CWHeight | CWX | CWY);\n\n  Status\n    status;\n\n  unsigned int\n    height,\n    text_width,\n    visible_colors,\n    width;\n\n  size_t\n    colors,\n    delay,\n    state;\n\n  XColor\n    color;\n\n  XEvent\n    event;\n\n  XFontStruct\n    *font_info;\n\n  XTextProperty\n    window_name;\n\n  XWidgetInfo\n    action_info,\n    cancel_info,\n    expose_info,\n    grab_info,\n    list_info,\n    mode_info,\n    north_info,\n    reply_info,\n    reset_info,\n    scroll_info,\n    selection_info,\n    slider_info,\n    south_info,\n    text_info;\n\n  XWindowChanges\n    window_changes;\n\n  \/*\n    Get color list and sort in ascending order.\n  *\/\n  assert(display != (Display *) NULL);\n  assert(windows != (XWindows *) NULL);\n  assert(action != (char *) NULL);\n  assert(reply != (char *) NULL);\n  (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",action);\n  XSetCursorState(display,windows,MagickTrue);\n  XCheckRefreshWindows(display,windows);\n  (void) CopyMagickString(reset_pattern,\"*\",MaxTextExtent);\n  exception=AcquireExceptionInfo();\n  colorlist=GetColorList(glob_pattern,&colors,exception);\n  if (colorlist == (char **) NULL)\n    {\n      \/*\n        Pattern failed, obtain all the colors.\n      *\/\n      (void) CopyMagickString(glob_pattern,\"*\",MaxTextExtent);\n      colorlist=GetColorList(glob_pattern,&colors,exception);\n      if (colorlist == (char **) NULL)\n        {\n          XNoticeWidget(display,windows,\"Unable to obtain colors names:\",\n            glob_pattern);\n          (void) XDialogWidget(display,windows,action,\"Enter color name:\",\n            reply);\n          return;\n        }\n    }\n  \/*\n    Determine Color Browser widget attributes.\n  *\/\n  font_info=windows->widget.font_info;\n  text_width=0;\n  for (i=0; i < (int) colors; i++)\n    if (WidgetTextWidth(font_info,colorlist[i]) > text_width)\n      text_width=WidgetTextWidth(font_info,colorlist[i]);\n  width=WidgetTextWidth(font_info,(char *) action);\n  if (WidgetTextWidth(font_info,CancelButtonText) > width)\n    width=WidgetTextWidth(font_info,CancelButtonText);\n  if (WidgetTextWidth(font_info,ResetButtonText) > width)\n    width=WidgetTextWidth(font_info,ResetButtonText);\n  if (WidgetTextWidth(font_info,GrabButtonText) > width)\n    width=WidgetTextWidth(font_info,GrabButtonText);\n  width+=QuantumMargin;\n  if (WidgetTextWidth(font_info,ColorPatternText) > width)\n    width=WidgetTextWidth(font_info,ColorPatternText);\n  if (WidgetTextWidth(font_info,ColornameText) > width)\n    width=WidgetTextWidth(font_info,ColornameText);\n  height=(unsigned int) (font_info->ascent+font_info->descent);\n  \/*\n    Position Color Browser widget.\n  *\/\n  windows->widget.width=(unsigned int)\n    (width+MagickMin((int) text_width,(int) MaxTextWidth)+6*QuantumMargin);\n  windows->widget.min_width=(unsigned int)\n    (width+MinTextWidth+4*QuantumMargin);\n  if (windows->widget.width < windows->widget.min_width)\n    windows->widget.width=windows->widget.min_width;\n  windows->widget.height=(unsigned int)\n    ((81*height) >> 2)+((13*QuantumMargin) >> 1)+4;\n  windows->widget.min_height=(unsigned int)\n    (((23*height) >> 1)+((13*QuantumMargin) >> 1)+4);\n  if (windows->widget.height < windows->widget.min_height)\n    windows->widget.height=windows->widget.min_height;\n  XConstrainWindowPosition(display,&windows->widget);\n  \/*\n    Map Color Browser widget.\n  *\/\n  (void) CopyMagickString(windows->widget.name,\"Browse and Select a Color\",\n    MaxTextExtent);\n  status=XStringListToTextProperty(&windows->widget.name,1,&window_name);\n  if (status != False)\n    {\n      XSetWMName(display,windows->widget.id,&window_name);\n      XSetWMIconName(display,windows->widget.id,&window_name);\n      (void) XFree((void *) window_name.value);\n    }\n  window_changes.width=(int) windows->widget.width;\n  window_changes.height=(int) windows->widget.height;\n  window_changes.x=windows->widget.x;\n  window_changes.y=windows->widget.y;\n  (void) XReconfigureWMWindow(display,windows->widget.id,windows->widget.screen,\n    mask,&window_changes);\n  (void) XMapRaised(display,windows->widget.id);\n  windows->widget.mapped=MagickFalse;\n  \/*\n    Respond to X events.\n  *\/\n  XGetWidgetInfo((char *) NULL,&mode_info);\n  XGetWidgetInfo((char *) NULL,&slider_info);\n  XGetWidgetInfo((char *) NULL,&north_info);\n  XGetWidgetInfo((char *) NULL,&south_info);\n  XGetWidgetInfo((char *) NULL,&expose_info);\n  XGetWidgetInfo((char *) NULL,&selection_info);\n  visible_colors=0;\n  delay=SuspendTime << 2;\n  state=UpdateConfigurationState;\n  do\n  {\n    if (state & UpdateConfigurationState)\n      {\n        int\n          id;\n\n        \/*\n          Initialize button information.\n        *\/\n        XGetWidgetInfo(CancelButtonText,&cancel_info);\n        cancel_info.width=width;\n        cancel_info.height=(unsigned int) ((3*height) >> 1);\n        cancel_info.x=(int)\n          (windows->widget.width-cancel_info.width-QuantumMargin-2);\n        cancel_info.y=(int)\n          (windows->widget.height-cancel_info.height-QuantumMargin);\n        XGetWidgetInfo(action,&action_info);\n        action_info.width=width;\n        action_info.height=(unsigned int) ((3*height) >> 1);\n        action_info.x=cancel_info.x-(cancel_info.width+(QuantumMargin >> 1)+\n          (action_info.bevel_width << 1));\n        action_info.y=cancel_info.y;\n        XGetWidgetInfo(GrabButtonText,&grab_info);\n        grab_info.width=width;\n        grab_info.height=(unsigned int) ((3*height) >> 1);\n        grab_info.x=QuantumMargin;\n        grab_info.y=((5*QuantumMargin) >> 1)+height;\n        XGetWidgetInfo(ResetButtonText,&reset_info);\n        reset_info.width=width;\n        reset_info.height=(unsigned int) ((3*height) >> 1);\n        reset_info.x=QuantumMargin;\n        reset_info.y=grab_info.y+grab_info.height+QuantumMargin;\n        \/*\n          Initialize reply information.\n        *\/\n        XGetWidgetInfo(reply,&reply_info);\n        reply_info.raised=MagickFalse;\n        reply_info.bevel_width--;\n        reply_info.width=windows->widget.width-width-((6*QuantumMargin) >> 1);\n        reply_info.height=height << 1;\n        reply_info.x=(int) (width+(QuantumMargin << 1));\n        reply_info.y=action_info.y-reply_info.height-QuantumMargin;\n        \/*\n          Initialize mode information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&mode_info);\n        mode_info.active=MagickTrue;\n        mode_info.bevel_width=0;\n        mode_info.width=(unsigned int) (action_info.x-(QuantumMargin << 1));\n        mode_info.height=action_info.height;\n        mode_info.x=QuantumMargin;\n        mode_info.y=action_info.y;\n        \/*\n          Initialize scroll information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&scroll_info);\n        scroll_info.bevel_width--;\n        scroll_info.width=height;\n        scroll_info.height=(unsigned int) (reply_info.y-grab_info.y-\n          (QuantumMargin >> 1));\n        scroll_info.x=reply_info.x+(reply_info.width-scroll_info.width);\n        scroll_info.y=grab_info.y-reply_info.bevel_width;\n        scroll_info.raised=MagickFalse;\n        scroll_info.trough=MagickTrue;\n        north_info=scroll_info;\n        north_info.raised=MagickTrue;\n        north_info.width-=(north_info.bevel_width << 1);\n        north_info.height=north_info.width-1;\n        north_info.x+=north_info.bevel_width;\n        north_info.y+=north_info.bevel_width;\n        south_info=north_info;\n        south_info.y=scroll_info.y+scroll_info.height-scroll_info.bevel_width-\n          south_info.height;\n        id=slider_info.id;\n        slider_info=north_info;\n        slider_info.id=id;\n        slider_info.width-=2;\n        slider_info.min_y=north_info.y+north_info.height+north_info.bevel_width+\n          slider_info.bevel_width+2;\n        slider_info.height=scroll_info.height-((slider_info.min_y-\n          scroll_info.y+1) << 1)+4;\n        visible_colors=(unsigned int) (scroll_info.height*\n          PerceptibleReciprocal((double) height+(height >> 3)));\n        if (colors > visible_colors)\n          slider_info.height=(unsigned int) ((visible_colors*\n            slider_info.height)\/colors);\n        slider_info.max_y=south_info.y-south_info.bevel_width-\n          slider_info.bevel_width-2;\n        slider_info.x=scroll_info.x+slider_info.bevel_width+1;\n        slider_info.y=slider_info.min_y;\n        expose_info=scroll_info;\n        expose_info.y=slider_info.y;\n        \/*\n          Initialize list information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&list_info);\n        list_info.raised=MagickFalse;\n        list_info.bevel_width--;\n        list_info.width=(unsigned int)\n          (scroll_info.x-reply_info.x-(QuantumMargin >> 1));\n        list_info.height=scroll_info.height;\n        list_info.x=reply_info.x;\n        list_info.y=scroll_info.y;\n        if (windows->widget.mapped == MagickFalse)\n          state|=JumpListState;\n        \/*\n          Initialize text information.\n        *\/\n        *text='\\0';\n        XGetWidgetInfo(text,&text_info);\n        text_info.center=MagickFalse;\n        text_info.width=reply_info.width;\n        text_info.height=height;\n        text_info.x=list_info.x-(QuantumMargin >> 1);\n        text_info.y=QuantumMargin;\n        \/*\n          Initialize selection information.\n        *\/\n        XGetWidgetInfo((char *) NULL,&selection_info);\n        selection_info.center=MagickFalse;\n        selection_info.width=list_info.width;\n        selection_info.height=(unsigned int) ((9*height) >> 3);\n        selection_info.x=list_info.x;\n        state&=(~UpdateConfigurationState);\n      }\n    if (state & RedrawWidgetState)\n      {\n        \/*\n          Redraw Color Browser window.\n        *\/\n        x=QuantumMargin;\n        y=text_info.y+((text_info.height-height) >> 1)+font_info->ascent;\n        (void) XDrawString(display,windows->widget.id,\n          windows->widget.annotate_context,x,y,ColorPatternText,\n          Extent(ColorPatternText));\n        (void) CopyMagickString(text_info.text,glob_pattern,MaxTextExtent);\n        XDrawWidgetText(display,&windows->widget,&text_info);\n        XDrawBeveledButton(display,&windows->widget,&grab_info);\n        XDrawBeveledButton(display,&windows->widget,&reset_info);\n        XDrawBeveledMatte(display,&windows->widget,&list_info);\n        XDrawBeveledMatte(display,&windows->widget,&scroll_info);\n        XDrawTriangleNorth(display,&windows->widget,&north_info);\n        XDrawBeveledButton(display,&windows->widget,&slider_info);\n        XDrawTriangleSouth(display,&windows->widget,&south_info);\n        x=QuantumMargin;\n        y=reply_info.y+((reply_info.height-height) >> 1)+font_info->ascent;\n        (void) XDrawString(display,windows->widget.id,\n          windows->widget.annotate_context,x,y,ColornameText,\n          Extent(ColornameText));\n        XDrawBeveledMatte(display,&windows->widget,&reply_info);\n        XDrawMatteText(display,&windows->widget,&reply_info);\n        XDrawBeveledButton(display,&windows->widget,&action_info);\n        XDrawBeveledButton(display,&windows->widget,&cancel_info);\n        XHighlightWidget(display,&windows->widget,BorderOffset,BorderOffset);\n        selection_info.id=(~0);\n        state|=RedrawActionState;\n        state|=RedrawListState;\n        state&=(~RedrawWidgetState);\n      }\n    if (state & UpdateListState)\n      {\n        char\n          **checklist;\n\n        size_t\n          number_colors;\n\n        status=XParseColor(display,windows->widget.map_info->colormap,\n          glob_pattern,&color);\n        if ((status != False) || (strchr(glob_pattern,'-') != (char *) NULL))\n          {\n            \/*\n              Reply is a single color name-- exit.\n            *\/\n            (void) CopyMagickString(reply,glob_pattern,MaxTextExtent);\n            (void) CopyMagickString(glob_pattern,reset_pattern,MaxTextExtent);\n            action_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&action_info);\n            break;\n          }\n        \/*\n          Update color list.\n        *\/\n        checklist=GetColorList(glob_pattern,&number_colors,exception);\n        if (number_colors == 0)\n          {\n            (void) CopyMagickString(glob_pattern,reset_pattern,MaxTextExtent);\n            (void) XBell(display,0);\n          }\n        else\n          {\n            for (i=0; i < (int) colors; i++)\n              colorlist[i]=DestroyString(colorlist[i]);\n            if (colorlist != (char **) NULL)\n              colorlist=(char **) RelinquishMagickMemory(colorlist);\n            colorlist=checklist;\n            colors=number_colors;\n          }\n        \/*\n          Sort color list in ascending order.\n        *\/\n        slider_info.height=\n          scroll_info.height-((slider_info.min_y-scroll_info.y+1) << 1)+1;\n        if (colors > visible_colors)\n          slider_info.height=(unsigned int)\n            ((visible_colors*slider_info.height)\/colors);\n        slider_info.max_y=south_info.y-south_info.bevel_width-\n          slider_info.bevel_width-2;\n        slider_info.id=0;\n        slider_info.y=slider_info.min_y;\n        expose_info.y=slider_info.y;\n        selection_info.id=(~0);\n        list_info.id=(~0);\n        state|=RedrawListState;\n        \/*\n          Redraw color name & reply.\n        *\/\n        *reply_info.text='\\0';\n        reply_info.cursor=reply_info.text;\n        (void) CopyMagickString(text_info.text,glob_pattern,MaxTextExtent);\n        XDrawWidgetText(display,&windows->widget,&text_info);\n        XDrawMatteText(display,&windows->widget,&reply_info);\n        XDrawBeveledMatte(display,&windows->widget,&scroll_info);\n        XDrawTriangleNorth(display,&windows->widget,&north_info);\n        XDrawBeveledButton(display,&windows->widget,&slider_info);\n        XDrawTriangleSouth(display,&windows->widget,&south_info);\n        XHighlightWidget(display,&windows->widget,BorderOffset,BorderOffset);\n        state&=(~UpdateListState);\n      }\n    if (state & JumpListState)\n      {\n        \/*\n          Jump scroll to match user color.\n        *\/\n        list_info.id=(~0);\n        for (i=0; i < (int) colors; i++)\n          if (LocaleCompare(colorlist[i],reply) >= 0)\n            {\n              list_info.id=LocaleCompare(colorlist[i],reply) == 0 ? i : ~0;\n              break;\n            }\n        if ((i < slider_info.id) ||\n            (i >= (int) (slider_info.id+visible_colors)))\n          slider_info.id=i-(visible_colors >> 1);\n        selection_info.id=(~0);\n        state|=RedrawListState;\n        state&=(~JumpListState);\n      }\n    if (state & RedrawListState)\n      {\n        \/*\n          Determine slider id and position.\n        *\/\n        if (slider_info.id >= (int) (colors-visible_colors))\n          slider_info.id=(int) (colors-visible_colors);\n        if ((slider_info.id < 0) || (colors <= visible_colors))\n          slider_info.id=0;\n        slider_info.y=slider_info.min_y;\n        if (colors != 0)\n          slider_info.y+=((ssize_t) slider_info.id*(slider_info.max_y-\n            slider_info.min_y+1)\/colors);\n        if (slider_info.id != selection_info.id)\n          {\n            \/*\n              Redraw scroll bar and file names.\n            *\/\n            selection_info.id=slider_info.id;\n            selection_info.y=list_info.y+(height >> 3)+2;\n            for (i=0; i < (int) visible_colors; i++)\n            {\n              selection_info.raised=(slider_info.id+i) != list_info.id ?\n                MagickTrue : MagickFalse;\n              selection_info.text=(char *) NULL;\n              if ((slider_info.id+i) < (int) colors)\n                selection_info.text=colorlist[slider_info.id+i];\n              XDrawWidgetText(display,&windows->widget,&selection_info);\n              selection_info.y+=(int) selection_info.height;\n            }\n            \/*\n              Update slider.\n            *\/\n            if (slider_info.y > expose_info.y)\n              {\n                expose_info.height=(unsigned int) slider_info.y-expose_info.y;\n                expose_info.y=slider_info.y-expose_info.height-\n                  slider_info.bevel_width-1;\n              }\n            else\n              {\n                expose_info.height=(unsigned int) expose_info.y-slider_info.y;\n                expose_info.y=slider_info.y+slider_info.height+\n                  slider_info.bevel_width+1;\n              }\n            XDrawTriangleNorth(display,&windows->widget,&north_info);\n            XDrawMatte(display,&windows->widget,&expose_info);\n            XDrawBeveledButton(display,&windows->widget,&slider_info);\n            XDrawTriangleSouth(display,&windows->widget,&south_info);\n            expose_info.y=slider_info.y;\n          }\n        state&=(~RedrawListState);\n      }\n    if (state & RedrawActionState)\n      {\n        static char\n          colorname[MaxTextExtent];\n\n        \/*\n          Display the selected color in a drawing area.\n        *\/\n        color=windows->widget.pixel_info->matte_color;\n        (void) XParseColor(display,windows->widget.map_info->colormap,\n          reply_info.text,&windows->widget.pixel_info->matte_color);\n        XBestPixel(display,windows->widget.map_info->colormap,(XColor *) NULL,\n          (unsigned int) windows->widget.visual_info->colormap_size,\n          &windows->widget.pixel_info->matte_color);\n        mode_info.text=colorname;\n        (void) FormatLocaleString(mode_info.text,MaxTextExtent,\"#%02x%02x%02x\",\n          windows->widget.pixel_info->matte_color.red,\n          windows->widget.pixel_info->matte_color.green,\n          windows->widget.pixel_info->matte_color.blue);\n        XDrawBeveledButton(display,&windows->widget,&mode_info);\n        windows->widget.pixel_info->matte_color=color;\n        state&=(~RedrawActionState);\n      }\n    \/*\n      Wait for next event.\n    *\/\n    if (north_info.raised && south_info.raised)\n      (void) XIfEvent(display,&event,XScreenEvent,(char *) windows);\n    else\n      {\n        \/*\n          Brief delay before advancing scroll bar.\n        *\/\n        XDelay(display,delay);\n        delay=SuspendTime;\n        (void) XCheckIfEvent(display,&event,XScreenEvent,(char *) windows);\n        if (north_info.raised == MagickFalse)\n          if (slider_info.id > 0)\n            {\n              \/*\n                Move slider up.\n              *\/\n              slider_info.id--;\n              state|=RedrawListState;\n            }\n        if (south_info.raised == MagickFalse)\n          if (slider_info.id < (int) colors)\n            {\n              \/*\n                Move slider down.\n              *\/\n              slider_info.id++;\n              state|=RedrawListState;\n            }\n        if (event.type != ButtonRelease)\n          continue;\n      }\n    switch (event.type)\n    {\n      case ButtonPress:\n      {\n        if (MatteIsActive(slider_info,event.xbutton))\n          {\n            \/*\n              Track slider.\n            *\/\n            slider_info.active=MagickTrue;\n            break;\n          }\n        if (MatteIsActive(north_info,event.xbutton))\n          if (slider_info.id > 0)\n            {\n              \/*\n                Move slider up.\n              *\/\n              north_info.raised=MagickFalse;\n              slider_info.id--;\n              state|=RedrawListState;\n              break;\n            }\n        if (MatteIsActive(south_info,event.xbutton))\n          if (slider_info.id < (int) colors)\n            {\n              \/*\n                Move slider down.\n              *\/\n              south_info.raised=MagickFalse;\n              slider_info.id++;\n              state|=RedrawListState;\n              break;\n            }\n        if (MatteIsActive(scroll_info,event.xbutton))\n          {\n            \/*\n              Move slider.\n            *\/\n            if (event.xbutton.y < slider_info.y)\n              slider_info.id-=(visible_colors-1);\n            else\n              slider_info.id+=(visible_colors-1);\n            state|=RedrawListState;\n            break;\n          }\n        if (MatteIsActive(list_info,event.xbutton))\n          {\n            int\n              id;\n\n            \/*\n              User pressed list matte.\n            *\/\n            id=slider_info.id+(event.xbutton.y-(list_info.y+(height >> 1))+1)\/\n              selection_info.height;\n            if (id >= (int) colors)\n              break;\n            (void) CopyMagickString(reply_info.text,colorlist[id],\n              MaxTextExtent);\n            reply_info.highlight=MagickFalse;\n            reply_info.marker=reply_info.text;\n            reply_info.cursor=reply_info.text+Extent(reply_info.text);\n            XDrawMatteText(display,&windows->widget,&reply_info);\n            state|=RedrawActionState;\n            if (id == list_info.id)\n              {\n                (void) CopyMagickString(glob_pattern,reply_info.text,\n                  MaxTextExtent);\n                state|=UpdateListState;\n              }\n            selection_info.id=(~0);\n            list_info.id=id;\n            state|=RedrawListState;\n            break;\n          }\n        if (MatteIsActive(grab_info,event.xbutton))\n          {\n            \/*\n              User pressed Grab button.\n            *\/\n            grab_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&grab_info);\n            break;\n          }\n        if (MatteIsActive(reset_info,event.xbutton))\n          {\n            \/*\n              User pressed Reset button.\n            *\/\n            reset_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&reset_info);\n            break;\n          }\n        if (MatteIsActive(mode_info,event.xbutton))\n          {\n            \/*\n              User pressed mode button.\n            *\/\n            if (mode_info.text != (char *) NULL)\n              (void) CopyMagickString(reply_info.text,mode_info.text,\n                MaxTextExtent);\n            (void) CopyMagickString(primary_selection,reply_info.text,\n              MaxTextExtent);\n            (void) XSetSelectionOwner(display,XA_PRIMARY,windows->widget.id,\n              event.xbutton.time);\n            reply_info.highlight=XGetSelectionOwner(display,XA_PRIMARY) ==\n              windows->widget.id ? MagickTrue : MagickFalse;\n            reply_info.marker=reply_info.text;\n            reply_info.cursor=reply_info.text+Extent(reply_info.text);\n            XDrawMatteText(display,&windows->widget,&reply_info);\n            break;\n          }\n        if (MatteIsActive(action_info,event.xbutton))\n          {\n            \/*\n              User pressed action button.\n            *\/\n            action_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&action_info);\n            break;\n          }\n        if (MatteIsActive(cancel_info,event.xbutton))\n          {\n            \/*\n              User pressed Cancel button.\n            *\/\n            cancel_info.raised=MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&cancel_info);\n            break;\n          }\n        if (MatteIsActive(reply_info,event.xbutton) == MagickFalse)\n          break;\n        if (event.xbutton.button != Button2)\n          {\n            static Time\n              click_time;\n\n            \/*\n              Move text cursor to position of button press.\n            *\/\n            x=event.xbutton.x-reply_info.x-(QuantumMargin >> 2);\n            for (i=1; i <= Extent(reply_info.marker); i++)\n              if (XTextWidth(font_info,reply_info.marker,i) > x)\n                break;\n            reply_info.cursor=reply_info.marker+i-1;\n            if (event.xbutton.time > (click_time+DoubleClick))\n              reply_info.highlight=MagickFalse;\n            else\n              {\n                \/*\n                  Become the XA_PRIMARY selection owner.\n                *\/\n                (void) CopyMagickString(primary_selection,reply_info.text,\n                  MaxTextExtent);\n                (void) XSetSelectionOwner(display,XA_PRIMARY,windows->widget.id,\n                  event.xbutton.time);\n                reply_info.highlight=XGetSelectionOwner(display,XA_PRIMARY) ==\n                  windows->widget.id ? MagickTrue : MagickFalse;\n              }\n            XDrawMatteText(display,&windows->widget,&reply_info);\n            click_time=event.xbutton.time;\n            break;\n          }\n        \/*\n          Request primary selection.\n        *\/\n        (void) XConvertSelection(display,XA_PRIMARY,XA_STRING,XA_STRING,\n          windows->widget.id,event.xbutton.time);\n        break;\n      }\n      case ButtonRelease:\n      {\n        if (windows->widget.mapped == MagickFalse)\n          break;\n        if (north_info.raised == MagickFalse)\n          {\n            \/*\n              User released up button.\n            *\/\n            delay=SuspendTime << 2;\n            north_info.raised=MagickTrue;\n            XDrawTriangleNorth(display,&windows->widget,&north_info);\n          }\n        if (south_info.raised == MagickFalse)\n          {\n            \/*\n              User released down button.\n            *\/\n            delay=SuspendTime << 2;\n            south_info.raised=MagickTrue;\n            XDrawTriangleSouth(display,&windows->widget,&south_info);\n          }\n        if (slider_info.active)\n          {\n            \/*\n              Stop tracking slider.\n            *\/\n            slider_info.active=MagickFalse;\n            break;\n          }\n        if (grab_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              if (MatteIsActive(grab_info,event.xbutton))\n                {\n                  \/*\n                    Select a pen color from the X server.\n                  *\/\n                  (void) XGetWindowColor(display,windows,reply_info.text);\n                  reply_info.marker=reply_info.text;\n                  reply_info.cursor=reply_info.text+Extent(reply_info.text);\n                  XDrawMatteText(display,&windows->widget,&reply_info);\n                  state|=RedrawActionState;\n                }\n            grab_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&grab_info);\n          }\n        if (reset_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              if (MatteIsActive(reset_info,event.xbutton))\n                {\n                  (void) CopyMagickString(glob_pattern,reset_pattern,\n                    MaxTextExtent);\n                  state|=UpdateListState;\n                }\n            reset_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&reset_info);\n          }\n        if (action_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              {\n                if (MatteIsActive(action_info,event.xbutton))\n                  {\n                    if (*reply_info.text == '\\0')\n                      (void) XBell(display,0);\n                    else\n                      state|=ExitState;\n                  }\n              }\n            action_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&action_info);\n          }\n        if (cancel_info.raised == MagickFalse)\n          {\n            if (event.xbutton.window == windows->widget.id)\n              if (MatteIsActive(cancel_info,event.xbutton))\n                {\n                  *reply_info.text='\\0';\n                  state|=ExitState;\n                }\n            cancel_info.raised=MagickTrue;\n            XDrawBeveledButton(display,&windows->widget,&cancel_info);\n          }\n        if (MatteIsActive(reply_info,event.xbutton) == MagickFalse)\n          break;\n        break;\n      }\n      case ClientMessage:\n      {\n        \/*\n          If client window delete message, exit.\n        *\/\n        if (event.xclient.message_type != windows->wm_protocols)\n          break;\n        if (*event.xclient.data.l == (int) windows->wm_take_focus)\n          {\n            (void) XSetInputFocus(display,event.xclient.window,RevertToParent,\n              (Time) event.xclient.data.l[1]);\n            break;\n          }\n        if (*event.xclient.data.l != (int) windows->wm_delete_window)\n          break;\n        if (event.xclient.window == windows->widget.id)\n          {\n            *reply_info.text='\\0';\n            state|=ExitState;\n            break;\n          }\n        break;\n      }\n      case ConfigureNotify:\n      {\n        \/*\n          Update widget configuration.\n        *\/\n        if (event.xconfigure.window != windows->widget.id)\n          break;\n        if ((event.xconfigure.width == (int) windows->widget.width) &&\n            (event.xconfigure.height == (int) windows->widget.height))\n          break;\n        windows->widget.width=(unsigned int)\n          MagickMax(event.xconfigure.width,(int) windows->widget.min_width);\n        windows->widget.height=(unsigned int)\n          MagickMax(event.xconfigure.height,(int) windows->widget.min_height);\n        state|=UpdateConfigurationState;\n        break;\n      }\n      case EnterNotify:\n      {\n        if (event.xcrossing.window != windows->widget.id)\n          break;\n        state&=(~InactiveWidgetState);\n        break;\n      }\n      case Expose:\n      {\n        if (event.xexpose.window != windows->widget.id)\n          break;\n        if (event.xexpose.count != 0)\n          break;\n        state|=RedrawWidgetState;\n        break;\n      }\n      case KeyPress:\n      {\n        static char\n          command[MaxTextExtent];\n\n        static int\n          length;\n\n        static KeySym\n          key_symbol;\n\n        \/*\n          Respond to a user key press.\n        *\/\n        if (event.xkey.window != windows->widget.id)\n          break;\n        length=XLookupString((XKeyEvent *) &event.xkey,command,\n          (int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);\n        *(command+length)='\\0';\n        if (AreaIsActive(scroll_info,event.xkey))\n          {\n            \/*\n              Move slider.\n            *\/\n            switch ((int) key_symbol)\n            {\n              case XK_Home:\n              case XK_KP_Home:\n              {\n                slider_info.id=0;\n                break;\n              }\n              case XK_Up:\n              case XK_KP_Up:\n              {\n                slider_info.id--;\n                break;\n              }\n              case XK_Down:\n              case XK_KP_Down:\n              {\n                slider_info.id++;\n                break;\n              }\n              case XK_Prior:\n              case XK_KP_Prior:\n              {\n                slider_info.id-=visible_colors;\n                break;\n              }\n              case XK_Next:\n              case XK_KP_Next:\n              {\n                slider_info.id+=visible_colors;\n                break;\n              }\n              case XK_End:\n              case XK_KP_End:\n              {\n                slider_info.id=(int) colors;\n                break;\n              }\n            }\n            state|=RedrawListState;\n            break;\n          }\n        if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))\n          {\n            \/*\n              Read new color or glob patterm.\n            *\/\n            if (*reply_info.text == '\\0')\n              break;\n            (void) CopyMagickString(glob_pattern,reply_info.text,MaxTextExtent);\n            state|=UpdateListState;\n            break;\n          }\n        if (key_symbol == XK_Control_L)\n          {\n            state|=ControlState;\n            break;\n          }\n        if (state & ControlState)\n          switch ((int) key_symbol)\n          {\n            case XK_u:\n            case XK_U:\n            {\n              \/*\n                Erase the entire line of text.\n              *\/\n              *reply_info.text='\\0';\n              reply_info.cursor=reply_info.text;\n              reply_info.marker=reply_info.text;\n              reply_info.highlight=MagickFalse;\n              break;\n            }\n            default:\n              break;\n          }\n        XEditText(display,&reply_info,key_symbol,command,state);\n        XDrawMatteText(display,&windows->widget,&reply_info);\n        state|=JumpListState;\n        status=XParseColor(display,windows->widget.map_info->colormap,\n          reply_info.text,&color);\n        if (status != False)\n          state|=RedrawActionState;\n        break;\n      }\n      case KeyRelease:\n      {\n        static char\n          command[MaxTextExtent];\n\n        static KeySym\n          key_symbol;\n\n        \/*\n          Respond to a user key release.\n        *\/\n        if (event.xkey.window != windows->widget.id)\n          break;\n        (void) XLookupString((XKeyEvent *) &event.xkey,command,\n          (int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);\n        if (key_symbol == XK_Control_L)\n          state&=(~ControlState);\n        break;\n      }\n      case LeaveNotify:\n      {\n        if (event.xcrossing.window != windows->widget.id)\n          break;\n        state|=InactiveWidgetState;\n        break;\n      }\n      case MapNotify:\n      {\n        mask&=(~CWX);\n        mask&=(~CWY);\n        break;\n      }\n      case MotionNotify:\n      {\n        \/*\n          Discard pending button motion events.\n        *\/\n        while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ;\n        if (slider_info.active)\n          {\n            \/*\n              Move slider matte.\n            *\/\n            slider_info.y=event.xmotion.y-\n              ((slider_info.height+slider_info.bevel_width) >> 1)+1;\n            if (slider_info.y < slider_info.min_y)\n              slider_info.y=slider_info.min_y;\n            if (slider_info.y > slider_info.max_y)\n              slider_info.y=slider_info.max_y;\n            slider_info.id=0;\n            if (slider_info.y != slider_info.min_y)\n              slider_info.id=(int) ((colors*(slider_info.y-\n                slider_info.min_y+1))\/(slider_info.max_y-slider_info.min_y+1));\n            state|=RedrawListState;\n            break;\n          }\n        if (state & InactiveWidgetState)\n          break;\n        if (grab_info.raised == MatteIsActive(grab_info,event.xmotion))\n          {\n            \/*\n              Grab button status changed.\n            *\/\n            grab_info.raised=!grab_info.raised;\n            XDrawBeveledButton(display,&windows->widget,&grab_info);\n            break;\n          }\n        if (reset_info.raised == MatteIsActive(reset_info,event.xmotion))\n          {\n            \/*\n              Reset button status changed.\n            *\/\n            reset_info.raised=!reset_info.raised;\n            XDrawBeveledButton(display,&windows->widget,&reset_info);\n            break;\n          }\n        if (action_info.raised == MatteIsActive(action_info,event.xmotion))\n          {\n            \/*\n              Action button status changed.\n            *\/\n            action_info.raised=action_info.raised == MagickFalse ?\n              MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&action_info);\n            break;\n          }\n        if (cancel_info.raised == MatteIsActive(cancel_info,event.xmotion))\n          {\n            \/*\n              Cancel button status changed.\n            *\/\n            cancel_info.raised=cancel_info.raised == MagickFalse ?\n              MagickTrue : MagickFalse;\n            XDrawBeveledButton(display,&windows->widget,&cancel_info);\n            break;\n          }\n        break;\n      }\n      case SelectionClear:\n      {\n        reply_info.highlight=MagickFalse;\n        XDrawMatteText(display,&windows->widget,&reply_info);\n        break;\n      }\n      case SelectionNotify:\n      {\n        Atom\n          type;\n\n        int\n          format;\n\n        unsigned char\n          *data;\n\n        unsigned long\n          after,\n          length;\n\n        \/*\n          Obtain response from primary selection.\n        *\/\n        if (event.xselection.property == (Atom) None)\n          break;\n        status=XGetWindowProperty(display,event.xselection.requestor,\n          event.xselection.property,0L,2047L,MagickTrue,XA_STRING,&type,\n          &format,&length,&after,&data);\n        if ((status != Success) || (type != XA_STRING) || (format == 32) ||\n            (length == 0))\n          break;\n        if ((Extent(reply_info.text)+length) >= (MaxTextExtent-1))\n          (void) XBell(display,0);\n        else\n          {\n            \/*\n              Insert primary selection in reply text.\n            *\/\n            *(data+length)='\\0';\n            XEditText(display,&reply_info,(KeySym) XK_Insert,(char *) data,\n              state);\n            XDrawMatteText(display,&windows->widget,&reply_info);\n            state|=JumpListState;\n            state|=RedrawActionState;\n          }\n        (void) XFree((void *) data);\n        break;\n      }\n      case SelectionRequest:\n      {\n        XSelectionEvent\n          notify;\n\n        XSelectionRequestEvent\n          *request;\n\n        if (reply_info.highlight == MagickFalse)\n          break;\n        \/*\n          Set primary selection.\n        *\/\n        request=(&(event.xselectionrequest));\n        (void) XChangeProperty(request->display,request->requestor,\n          request->property,request->target,8,PropModeReplace,\n          (unsigned char *) primary_selection,Extent(primary_selection));\n        notify.type=SelectionNotify;\n        notify.send_event=MagickTrue;\n        notify.display=request->display;\n        notify.requestor=request->requestor;\n        notify.selection=request->selection;\n        notify.target=request->target;\n        notify.time=request->time;\n        if (request->property == None)\n          notify.property=request->target;\n        else\n          notify.property=request->property;\n        (void) XSendEvent(request->display,request->requestor,False,\n          NoEventMask,(XEvent *) ¬ify);\n      }\n      default:\n        break;\n    }\n  } while ((state & ExitState) == 0);\n  XSetCursorState(display,windows,MagickFalse);\n  (void) XWithdrawWindow(display,windows->widget.id,windows->widget.screen);\n  XCheckRefreshWindows(display,windows);\n  \/*\n    Free color list.\n  *\/\n  for (i=0; i < (int) colors; i++)\n    colorlist[i]=DestroyString(colorlist[i]);\n  if (colorlist != (char **) NULL)\n    colorlist=(char **) RelinquishMagickMemory(colorlist);\n  exception=DestroyExceptionInfo(exception);\n  if ((*reply == '\\0') || (strchr(reply,'-') != (char *) NULL))\n    return;\n  status=XParseColor(display,windows->widget.map_info->colormap,reply,&color);\n  if (status != False)\n    return;\n  XNoticeWidget(display,windows,\"Color is unknown to X server:\",reply);\n  (void) CopyMagickString(reply,\"gray\",MaxTextExtent);\n}","target":0,"code_token_length":8644,"total_token_length":8880,"max_tokens_setting":11000}
+{"idx":210669,"func":"static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  BMPInfo\n    bmp_info;\n\n  Image\n    *image;\n\n  IndexPacket\n    index;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    start_position;\n\n  MemoryInfo\n    *pixel_info;\n\n  register IndexPacket\n    *indexes;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *p;\n\n  size_t\n    bit,\n    bytes_per_line,\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    magick[12],\n    *pixels;\n\n  unsigned int\n    blue,\n    green,\n    offset_bits,\n    red;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Determine if this a BMP file.\n  *\/\n  (void) memset(&bmp_info,0,sizeof(bmp_info));\n  bmp_info.ba_offset=0;\n  start_position=0;\n  offset_bits=0;\n  count=ReadBlob(image,2,magick);\n  if (count != 2)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  do\n  {\n    LongPixelPacket\n      shift;\n\n    PixelPacket\n      quantum_bits;\n\n    \/*\n      Verify BMP identifier.\n    *\/\n    if (bmp_info.ba_offset == 0)\n      start_position=TellBlob(image)-2;\n    bmp_info.ba_offset=0;\n    while (LocaleNCompare((char *) magick,\"BA\",2) == 0)\n    {\n      bmp_info.file_size=ReadBlobLSBLong(image);\n      bmp_info.ba_offset=ReadBlobLSBLong(image);\n      bmp_info.offset_bits=ReadBlobLSBLong(image);\n      count=ReadBlob(image,2,magick);\n      if (count != 2)\n        break;\n    }\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  Magick: %c%c\",\n        magick[0],magick[1]);\n    if ((count != 2) || ((LocaleNCompare((char *) magick,\"BM\",2) != 0) &&\n        (LocaleNCompare((char *) magick,\"CI\",2) != 0)))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    bmp_info.file_size=ReadBlobLSBLong(image);\n    (void) ReadBlobLSBLong(image);\n\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n         \"  File_size in header:  %u bytes\",bmp_info.file_size);\n\n    bmp_info.offset_bits=ReadBlobLSBLong(image);\n    bmp_info.size=ReadBlobLSBLong(image);\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  BMP size: %u\",\n        bmp_info.size);\n    if (bmp_info.size == 12)\n      {\n        \/*\n          OS\/2 BMP image file.\n        *\/\n        (void) CopyMagickString(image->magick,\"BMP2\",MaxTextExtent);\n        bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.x_pixels=0;\n        bmp_info.y_pixels=0;\n        bmp_info.number_colors=0;\n        bmp_info.compression=BI_RGB;\n        bmp_info.image_size=0;\n        bmp_info.alpha_mask=0;\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: OS\/2 Bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n          }\n      }\n    else\n      {\n        \/*\n          Microsoft Windows BMP image file.\n        *\/\n        if (bmp_info.size < 40)\n          ThrowReaderException(CorruptImageError,\"NonOS2HeaderSizeError\");\n        bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.compression=ReadBlobLSBLong(image);\n        bmp_info.image_size=ReadBlobLSBLong(image);\n        bmp_info.x_pixels=ReadBlobLSBLong(image);\n        bmp_info.y_pixels=ReadBlobLSBLong(image);\n        bmp_info.number_colors=ReadBlobLSBLong(image);\n        bmp_info.colors_important=ReadBlobLSBLong(image);\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: MS Windows bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Bits per pixel: %.20g\",(double) bmp_info.bits_per_pixel);\n            switch (bmp_info.compression)\n            {\n              case BI_RGB:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RGB\");\n                break;\n              }\n              case BI_RLE4:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE4\");\n                break;\n              }\n              case BI_RLE8:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE8\");\n                break;\n              }\n              case BI_BITFIELDS:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_BITFIELDS\");\n                break;\n              }\n              case BI_PNG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_PNG\");\n                break;\n              }\n              case BI_JPEG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_JPEG\");\n                break;\n              }\n              default:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: UNKNOWN (%u)\",bmp_info.compression);\n              }\n            }\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Number of colors: %u\",bmp_info.number_colors);\n          }\n        bmp_info.red_mask=ReadBlobLSBLong(image);\n        bmp_info.green_mask=ReadBlobLSBLong(image);\n        bmp_info.blue_mask=ReadBlobLSBLong(image);\n        if (bmp_info.size > 40)\n          {\n            double\n              gamma;\n\n            \/*\n              Read color management information.\n            *\/\n            bmp_info.alpha_mask=ReadBlobLSBLong(image);\n            bmp_info.colorspace=ReadBlobLSBSignedLong(image);\n            \/*\n              Decode 2^30 fixed point formatted CIE primaries.\n            *\/\n#           define BMP_DENOM ((double) 0x40000000)\n            bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n\n            gamma=bmp_info.red_primary.x+bmp_info.red_primary.y+\n              bmp_info.red_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.red_primary.x*=gamma;\n            bmp_info.red_primary.y*=gamma;\n            image->chromaticity.red_primary.x=bmp_info.red_primary.x;\n            image->chromaticity.red_primary.y=bmp_info.red_primary.y;\n\n            gamma=bmp_info.green_primary.x+bmp_info.green_primary.y+\n              bmp_info.green_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.green_primary.x*=gamma;\n            bmp_info.green_primary.y*=gamma;\n            image->chromaticity.green_primary.x=bmp_info.green_primary.x;\n            image->chromaticity.green_primary.y=bmp_info.green_primary.y;\n\n            gamma=bmp_info.blue_primary.x+bmp_info.blue_primary.y+\n              bmp_info.blue_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.blue_primary.x*=gamma;\n            bmp_info.blue_primary.y*=gamma;\n            image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;\n            image->chromaticity.blue_primary.y=bmp_info.blue_primary.y;\n\n            \/*\n              Decode 16^16 fixed point formatted gamma_scales.\n            *\/\n            bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)\/0x10000;\n            \/*\n              Compute a single gamma from the BMP 3-channel gamma.\n            *\/\n            image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+\n              bmp_info.gamma_scale.z)\/3.0;\n          }\n        else\n          (void) CopyMagickString(image->magick,\"BMP3\",MaxTextExtent);\n\n        if (bmp_info.size > 108)\n          {\n            size_t\n              intent;\n\n            \/*\n              Read BMP Version 5 color management information.\n            *\/\n            intent=ReadBlobLSBLong(image);\n            switch ((int) intent)\n            {\n              case LCS_GM_BUSINESS:\n              {\n                image->rendering_intent=SaturationIntent;\n                break;\n              }\n              case LCS_GM_GRAPHICS:\n              {\n                image->rendering_intent=RelativeIntent;\n                break;\n              }\n              case LCS_GM_IMAGES:\n              {\n                image->rendering_intent=PerceptualIntent;\n                break;\n              }\n              case LCS_GM_ABS_COLORIMETRIC:\n              {\n                image->rendering_intent=AbsoluteIntent;\n                break;\n              }\n            }\n            (void) ReadBlobLSBLong(image);  \/* Profile data *\/\n            (void) ReadBlobLSBLong(image);  \/* Profile size *\/\n            (void) ReadBlobLSBLong(image);  \/* Reserved byte *\/\n          }\n      }\n    if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))\n      (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,\n        \"LengthAndFilesizeDoNotMatch\",\"`%s'\",image->filename);\n    else\n      if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          CorruptImageWarning,\"LengthAndFilesizeDoNotMatch\",\"`%s'\",\n          image->filename);\n    if (bmp_info.width <= 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.height == 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.planes != 1)\n      ThrowReaderException(CorruptImageError,\"StaticPlanesValueNotEqualToOne\");\n    if ((bmp_info.bits_per_pixel != 1) && (bmp_info.bits_per_pixel != 4) &&\n        (bmp_info.bits_per_pixel != 8) && (bmp_info.bits_per_pixel != 16) &&\n        (bmp_info.bits_per_pixel != 24) && (bmp_info.bits_per_pixel != 32))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if (bmp_info.bits_per_pixel < 16 &&\n        bmp_info.number_colors > (1U << bmp_info.bits_per_pixel))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedNumberOfColors\");\n    if ((bmp_info.compression == 1) && (bmp_info.bits_per_pixel != 8))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 2) && (bmp_info.bits_per_pixel != 4))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 3) && (bmp_info.bits_per_pixel < 16))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    switch (bmp_info.compression)\n    {\n      case BI_RGB:\n        image->compression=NoCompression;\n        break;\n      case BI_RLE8:\n      case BI_RLE4:\n        image->compression=RLECompression;\n        break;\n      case BI_BITFIELDS:\n        break;\n      case BI_JPEG:\n        ThrowReaderException(CoderError,\"JPEGCompressNotSupported\");\n      case BI_PNG:\n        ThrowReaderException(CoderError,\"PNGCompressNotSupported\");\n      default:\n        ThrowReaderException(CorruptImageError,\"UnrecognizedImageCompression\");\n    }\n    image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);\n    image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);\n    image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;\n    image->matte=((bmp_info.alpha_mask != 0) &&\n      (bmp_info.compression == BI_BITFIELDS)) ? MagickTrue : MagickFalse;\n    if (bmp_info.bits_per_pixel < 16)\n      {\n        size_t\n          one;\n\n        image->storage_class=PseudoClass;\n        image->colors=bmp_info.number_colors;\n        one=1;\n        if (image->colors == 0)\n          image->colors=one << bmp_info.bits_per_pixel;\n      }\n    image->x_resolution=(double) bmp_info.x_pixels\/100.0;\n    image->y_resolution=(double) bmp_info.y_pixels\/100.0;\n    image->units=PixelsPerCentimeterResolution;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    if (image->storage_class == PseudoClass)\n      {\n        unsigned char\n          *bmp_colormap;\n\n        size_t\n          packet_size;\n\n        \/*\n          Read BMP raster colormap.\n        *\/\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading colormap of %.20g colors\",(double) image->colors);\n        if (AcquireImageColormap(image,image->colors) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        bmp_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n          image->colors,4*sizeof(*bmp_colormap));\n        if (bmp_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        if ((bmp_info.size == 12) || (bmp_info.size == 64))\n          packet_size=3;\n        else\n          packet_size=4;\n        offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET);\n        if (offset < 0)\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n          }\n        count=ReadBlob(image,packet_size*image->colors,bmp_colormap);\n        if (count != (ssize_t) (packet_size*image->colors))\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n        p=bmp_colormap;\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].blue=ScaleCharToQuantum(*p++);\n          image->colormap[i].green=ScaleCharToQuantum(*p++);\n          image->colormap[i].red=ScaleCharToQuantum(*p++);\n          if (packet_size == 4)\n            p++;\n        }\n        bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n      }\n    \/*\n      Read image data.\n    *\/\n    if (bmp_info.offset_bits == offset_bits)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    offset_bits=bmp_info.offset_bits;\n    offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET);\n    if (offset < 0)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if (bmp_info.compression == BI_RLE4)\n      bmp_info.bits_per_pixel<<=1;\n    bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)\/32);\n    length=(size_t) bytes_per_line*image->rows;\n    if (((MagickSizeType) length\/8) > GetBlobSize(image))\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    if ((bmp_info.compression == BI_RGB) ||\n        (bmp_info.compression == BI_BITFIELDS))\n      {\n        pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,\n          image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading pixels (%.20g bytes)\",(double) length);\n        count=ReadBlob(image,length,pixels);\n        if (count != (ssize_t) length)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n      }\n    else\n      {\n        \/*\n          Convert run-length encoded raster pixels.\n        *\/\n        pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,\n          image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        status=DecodeImage(image,bmp_info.compression,pixels,\n          image->columns*image->rows);\n        if (status == MagickFalse)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnableToRunlengthDecodeImage\");\n          }\n      }\n    \/*\n      Convert BMP raster image to pixel packets.\n    *\/\n    if (bmp_info.compression == BI_RGB)\n      {\n        \/*\n          We should ignore the alpha value in BMP3 files but there have been\n          reports about 32 bit files with alpha. We do a quick check to see if\n          the alpha channel contains a value that is not zero (default value).\n          If we find a non zero value we asume the program that wrote the file\n          wants to use the alpha channel.\n        *\/\n        if ((image->matte == MagickFalse) && (bmp_info.size == 40) &&\n            (bmp_info.bits_per_pixel == 32))\n          {\n            bytes_per_line=4*(image->columns);\n            for (y=(ssize_t) image->rows-1; y >= 0; y--)\n            {\n              p=pixels+(image->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                if (*(p+3) != 0)\n                  {\n                    image->matte=MagickTrue;\n                    y=-1;\n                    break;\n                  }\n                p+=4;\n              }\n            }\n          }\n        bmp_info.alpha_mask=image->matte != MagickFalse ? 0xff000000U : 0U;\n        bmp_info.red_mask=0x00ff0000U;\n        bmp_info.green_mask=0x0000ff00U;\n        bmp_info.blue_mask=0x000000ffU;\n        if (bmp_info.bits_per_pixel == 16)\n          {\n            \/*\n              RGB555.\n            *\/\n            bmp_info.red_mask=0x00007c00U;\n            bmp_info.green_mask=0x000003e0U;\n            bmp_info.blue_mask=0x0000001fU;\n          }\n      }\n    (void) memset(&shift,0,sizeof(shift));\n    (void) memset(&quantum_bits,0,sizeof(quantum_bits));\n    if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))\n      {\n        register size_t\n          sample;\n\n        \/*\n          Get shift and quantum bits info from bitfield masks.\n        *\/\n        if (bmp_info.red_mask != 0)\n          while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)\n          {\n            shift.red++;\n            if (shift.red > 32U)\n              break;\n          }\n        if (bmp_info.green_mask != 0)\n          while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)\n          {\n            shift.green++;\n            if (shift.green > 32U)\n              break;\n          }\n        if (bmp_info.blue_mask != 0)\n          while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)\n          {\n            shift.blue++;\n            if (shift.blue > 32U)\n              break;\n          }\n        if (bmp_info.alpha_mask != 0)\n          while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)\n          {\n            shift.opacity++;\n            if (shift.opacity > 32U)\n              break;\n          }\n        sample=shift.red;\n        while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.red=ClampToQuantum((MagickRealType) sample-shift.red);\n        sample=shift.green;\n        while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.green=ClampToQuantum((MagickRealType) sample-shift.green);\n        sample=shift.blue;\n        while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.blue=ClampToQuantum((MagickRealType) sample-shift.blue);\n        sample=shift.opacity;\n        while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.opacity=ClampToQuantum((MagickRealType) sample-\n          shift.opacity);\n      }\n    switch (bmp_info.bits_per_pixel)\n    {\n      case 1:\n      {\n        \/*\n          Convert bitmap scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n          {\n            for (bit=0; bit < 8; bit++)\n            {\n              index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n              SetPixelIndex(indexes+x+bit,index);\n              q++;\n            }\n            p++;\n          }\n          if ((image->columns % 8) != 0)\n            {\n              for (bit=0; bit < (image->columns % 8); bit++)\n              {\n                index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n                SetPixelIndex(indexes+x+bit,index);\n              }\n              p++;\n            }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 4:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-1); x+=2)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0x0f),\n              &index,exception);\n            SetPixelIndex(indexes+x,index);\n            (void) IsValidColormapIndex(image,(ssize_t) (*p & 0x0f),&index,\n              exception);\n            SetPixelIndex(indexes+x+1,index);\n            p++;\n          }\n          if ((image->columns % 2) != 0)\n            {\n              (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0xf),\n                &index,exception);\n              SetPixelIndex(indexes+(x++),index);\n              p++;\n            }\n          if (x < (ssize_t) image->columns)\n            break;\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 8:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        if ((bmp_info.compression == BI_RLE8) ||\n            (bmp_info.compression == BI_RLE4))\n          bytes_per_line=image->columns;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=(ssize_t) image->columns; x != 0; --x)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) *p,&index,exception);\n            SetPixelIndex(indexes,index);\n            indexes++;\n            p++;\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 16:\n      {\n        unsigned int\n          alpha,\n          pixel;\n\n        \/*\n          Convert bitfield encoded 16-bit PseudoColor scanline.\n        *\/\n        if (bmp_info.compression != BI_RGB &&\n            bmp_info.compression != BI_BITFIELDS)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=2*(image->columns+image->columns % 2);\n        image->storage_class=DirectClass;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=(*p++) << 8;\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 5)\n              red|=((red & 0xe000) >> 5);\n            if (quantum_bits.red <= 8)\n              red|=((red & 0xff00) >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 5)\n              green|=((green & 0xe000) >> 5);\n            if (quantum_bits.green == 6)\n              green|=((green & 0xc000) >> 6);\n            if (quantum_bits.green <= 8)\n              green|=((green & 0xff00) >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 5)\n              blue|=((blue & 0xe000) >> 5);\n            if (quantum_bits.blue <= 8)\n              blue|=((blue & 0xff00) >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelOpacity(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity <= 8)\n                  alpha|=((alpha & 0xff00) >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 24:\n      {\n        \/*\n          Convert DirectColor scanline.\n        *\/\n        bytes_per_line=4*((image->columns*24+31)\/32);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelBlue(q,ScaleCharToQuantum(*p++));\n            SetPixelGreen(q,ScaleCharToQuantum(*p++));\n            SetPixelRed(q,ScaleCharToQuantum(*p++));\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 32:\n      {\n        \/*\n          Convert bitfield encoded DirectColor scanline.\n        *\/\n        if ((bmp_info.compression != BI_RGB) &&\n            (bmp_info.compression != BI_BITFIELDS))\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=4*(image->columns);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          unsigned int\n            alpha,\n            pixel;\n\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=((unsigned int) *p++ << 8);\n            pixel|=((unsigned int) *p++ << 16);\n            pixel|=((unsigned int) *p++ << 24);\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 8)\n              red|=(red >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 8)\n              green|=(green >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 8)\n              blue|=(blue >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelAlpha(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity == 8)\n                  alpha|=(alpha >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      default:\n      {\n        pixel_info=RelinquishVirtualMemory(pixel_info);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (y > 0)\n      break;\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    if (bmp_info.height < 0)\n      {\n        Image\n          *flipped_image;\n\n        \/*\n          Correct image orientation.\n        *\/\n        flipped_image=FlipImage(image,exception);\n        if (flipped_image != (Image *) NULL)\n          {\n            DuplicateBlob(flipped_image,image);\n            ReplaceImageInList(&image, flipped_image);\n            image=flipped_image;\n          }\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    *magick='\\0';\n    if (bmp_info.ba_offset != 0)\n      {\n        offset=SeekBlob(image,(MagickOffsetType) bmp_info.ba_offset,SEEK_SET);\n        if (offset < 0)\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    count=ReadBlob(image,2,magick);\n    if ((count == 2) && (IsBMP(magick,2) != MagickFalse))\n      {\n        \/*\n          Acquire next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            image=DestroyImageList(image);\n            return((Image *) NULL);\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (IsBMP(magick,2) != MagickFalse);\n  (void) CloseBlob(image);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":8620,"total_token_length":8856,"max_tokens_setting":11000}
+{"idx":234203,"func":"display_debug_frames (struct dwarf_section *section,\n\t\t      void *file ATTRIBUTE_UNUSED)\n{\n  unsigned char *start = section->start;\n  unsigned char *end = start + section->size;\n  unsigned char *section_start = start;\n  Frame_Chunk *chunks = NULL, *forward_refs = NULL;\n  Frame_Chunk *remembered_state = NULL;\n  Frame_Chunk *rs;\n  bool is_eh = strcmp (section->name, \".eh_frame\") == 0;\n  unsigned int max_regs = 0;\n  const char *bad_reg = _(\"bad register: \");\n  unsigned int saved_eh_addr_size = eh_addr_size;\n\n  introduce (section, false);\n\n  while (start < end)\n    {\n      unsigned char *saved_start;\n      unsigned char *block_end;\n      dwarf_vma length;\n      dwarf_vma cie_id;\n      Frame_Chunk *fc;\n      Frame_Chunk *cie;\n      int need_col_headers = 1;\n      unsigned char *augmentation_data = NULL;\n      bfd_size_type augmentation_data_len = 0;\n      unsigned int encoded_ptr_size = saved_eh_addr_size;\n      unsigned int offset_size;\n      bool all_nops;\n      static Frame_Chunk fde_fc;\n\n      saved_start = start;\n\n      SAFE_BYTE_GET_AND_INC (length, start, 4, end);\n\n      if (length == 0)\n\t{\n\t  printf (\"\\n%08lx ZERO terminator\\n\\n\",\n\t\t    (unsigned long)(saved_start - section_start));\n\t  \/* Skip any zero terminators that directly follow.\n\t     A corrupt section size could have loaded a whole\n\t     slew of zero filled memory bytes.  eg\n\t     PR 17512: file: 070-19381-0.004.  *\/\n\t  while (start < end && * start == 0)\n\t    ++ start;\n\t  continue;\n\t}\n\n      if (length == 0xffffffff)\n\t{\n\t  SAFE_BYTE_GET_AND_INC (length, start, 8, end);\n\t  offset_size = 8;\n\t}\n      else\n\toffset_size = 4;\n\n      if (length > (size_t) (end - start))\n\t{\n\t  warn (\"Invalid length 0x%s in FDE at %#08lx\\n\",\n\t\tdwarf_vmatoa_1 (NULL, length, offset_size),\n\t\t(unsigned long) (saved_start - section_start));\n\t  block_end = end;\n\t}\n      else\n\tblock_end = start + length;\n\n      SAFE_BYTE_GET_AND_INC (cie_id, start, offset_size, block_end);\n\n      if (is_eh ? (cie_id == 0) : ((offset_size == 4 && cie_id == DW_CIE_ID)\n\t\t\t\t   || (offset_size == 8 && cie_id == DW64_CIE_ID)))\n\t{\n\t  int version;\n\t  unsigned int mreg;\n\n\t  start = read_cie (start, block_end, &cie, &version,\n\t\t\t    &augmentation_data_len, &augmentation_data);\n\t  \/* PR 17512: file: 027-135133-0.005.  *\/\n\t  if (cie == NULL)\n\t    break;\n\n\t  fc = cie;\n\t  fc->next = chunks;\n\t  chunks = fc;\n\t  fc->chunk_start = saved_start;\n\t  mreg = max_regs > 0 ? max_regs - 1 : 0;\n\t  if (mreg < fc->ra)\n\t    mreg = fc->ra;\n\t  if (frame_need_space (fc, mreg) < 0)\n\t    break;\n\t  if (fc->fde_encoding)\n\t    encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);\n\n\t  printf (\"\\n%08lx \", (unsigned long) (saved_start - section_start));\n\t  print_dwarf_vma (length, fc->ptr_size);\n\t  print_dwarf_vma (cie_id, offset_size);\n\n\t  if (do_debug_frames_interp)\n\t    {\n\t      printf (\"CIE \\\"%s\\\" cf=%d df=%d ra=%d\\n\", fc->augmentation,\n\t\t      fc->code_factor, fc->data_factor, fc->ra);\n\t    }\n\t  else\n\t    {\n\t      printf (\"CIE\\n\");\n\t      printf (\"  Version:               %d\\n\", version);\n\t      printf (\"  Augmentation:          \\\"%s\\\"\\n\", fc->augmentation);\n\t      if (version >= 4)\n\t\t{\n\t\t  printf (\"  Pointer Size:          %u\\n\", fc->ptr_size);\n\t\t  printf (\"  Segment Size:          %u\\n\", fc->segment_size);\n\t\t}\n\t      printf (\"  Code alignment factor: %u\\n\", fc->code_factor);\n\t      printf (\"  Data alignment factor: %d\\n\", fc->data_factor);\n\t      printf (\"  Return address column: %d\\n\", fc->ra);\n\n\t      if (augmentation_data_len)\n\t\tdisplay_augmentation_data (augmentation_data, augmentation_data_len);\n\n\t      putchar ('\\n');\n\t    }\n\t}\n      else\n\t{\n\t  unsigned char *look_for;\n\t  unsigned long segment_selector;\n\t  dwarf_vma cie_off;\n\n\t  cie_off = cie_id;\n\t  if (is_eh)\n\t    {\n\t      dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1);\n\t      cie_off = (cie_off ^ sign) - sign;\n\t      cie_off = start - 4 - section_start - cie_off;\n\t    }\n\n\t  look_for = section_start + cie_off;\n\t  if (cie_off <= (dwarf_vma) (saved_start - section_start))\n\t    {\n\t      for (cie = chunks; cie ; cie = cie->next)\n\t\tif (cie->chunk_start == look_for)\n\t\t  break;\n\t    }\n\t  else if (cie_off >= section->size)\n\t    cie = NULL;\n\t  else\n\t    {\n\t      for (cie = forward_refs; cie ; cie = cie->next)\n\t\tif (cie->chunk_start == look_for)\n\t\t  break;\n\t      if (!cie)\n\t\t{\n\t\t  unsigned int off_size;\n\t\t  unsigned char *cie_scan;\n\n\t\t  cie_scan = look_for;\n\t\t  off_size = 4;\n\t\t  SAFE_BYTE_GET_AND_INC (length, cie_scan, 4, end);\n\t\t  if (length == 0xffffffff)\n\t\t    {\n\t\t      SAFE_BYTE_GET_AND_INC (length, cie_scan, 8, end);\n\t\t      off_size = 8;\n\t\t    }\n\t\t  if (length != 0 && length <= (size_t) (end - cie_scan))\n\t\t    {\n\t\t      dwarf_vma c_id;\n\t\t      unsigned char *cie_end = cie_scan + length;\n\n\t\t      SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size,\n\t\t\t\t\t     cie_end);\n\t\t      if (is_eh\n\t\t\t  ? c_id == 0\n\t\t\t  : ((off_size == 4 && c_id == DW_CIE_ID)\n\t\t\t     || (off_size == 8 && c_id == DW64_CIE_ID)))\n\t\t\t{\n\t\t\t  int version;\n\t\t\t  unsigned int mreg;\n\n\t\t\t  read_cie (cie_scan, cie_end, &cie, &version,\n\t\t\t\t    &augmentation_data_len, &augmentation_data);\n\t\t\t  \/* PR 17512: file: 3450-2098-0.004.  *\/\n\t\t\t  if (cie == NULL)\n\t\t\t    {\n\t\t\t      warn (_(\"Failed to read CIE information\\n\"));\n\t\t\t      break;\n\t\t\t    }\n\t\t\t  cie->next = forward_refs;\n\t\t\t  forward_refs = cie;\n\t\t\t  cie->chunk_start = look_for;\n\t\t\t  mreg = max_regs > 0 ? max_regs - 1 : 0;\n\t\t\t  if (mreg < cie->ra)\n\t\t\t    mreg = cie->ra;\n\t\t\t  if (frame_need_space (cie, mreg) < 0)\n\t\t\t    {\n\t\t\t      warn (_(\"Invalid max register\\n\"));\n\t\t\t      break;\n\t\t\t    }\n\t\t\t  if (cie->fde_encoding)\n\t\t\t    encoded_ptr_size\n\t\t\t      = size_of_encoded_value (cie->fde_encoding);\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\n\t  fc = &fde_fc;\n\t  memset (fc, 0, sizeof (Frame_Chunk));\n\n\t  if (!cie)\n\t    {\n\t      fc->ncols = 0;\n\t      fc->col_type = (short int *) xmalloc (sizeof (short int));\n\t      fc->col_offset = (int *) xmalloc (sizeof (int));\n\t      if (frame_need_space (fc, max_regs > 0 ? max_regs - 1 : 0) < 0)\n\t\t{\n\t\t  warn (_(\"Invalid max register\\n\"));\n\t\t  break;\n\t\t}\n\t      cie = fc;\n\t      fc->augmentation = \"\";\n\t      fc->fde_encoding = 0;\n\t      fc->ptr_size = eh_addr_size;\n\t      fc->segment_size = 0;\n\t    }\n\t  else\n\t    {\n\t      fc->ncols = cie->ncols;\n\t      fc->col_type = (short int *) xcmalloc (fc->ncols, sizeof (short int));\n\t      fc->col_offset =  (int *) xcmalloc (fc->ncols, sizeof (int));\n\t      memcpy (fc->col_type, cie->col_type, fc->ncols * sizeof (short int));\n\t      memcpy (fc->col_offset, cie->col_offset, fc->ncols * sizeof (int));\n\t      fc->augmentation = cie->augmentation;\n\t      fc->ptr_size = cie->ptr_size;\n\t      eh_addr_size = cie->ptr_size;\n\t      fc->segment_size = cie->segment_size;\n\t      fc->code_factor = cie->code_factor;\n\t      fc->data_factor = cie->data_factor;\n\t      fc->cfa_reg = cie->cfa_reg;\n\t      fc->cfa_offset = cie->cfa_offset;\n\t      fc->ra = cie->ra;\n\t      if (frame_need_space (fc, max_regs > 0 ? max_regs - 1: 0) < 0)\n\t\t{\n\t\t  warn (_(\"Invalid max register\\n\"));\n\t\t  break;\n\t\t}\n\t      fc->fde_encoding = cie->fde_encoding;\n\t    }\n\n\t  if (fc->fde_encoding)\n\t    encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);\n\n\t  segment_selector = 0;\n\t  if (fc->segment_size)\n\t    {\n\t      if (fc->segment_size > sizeof (segment_selector))\n\t\t{\n\t\t  \/* PR 17512: file: 9e196b3e.  *\/\n\t\t  warn (_(\"Probably corrupt segment size: %d - using 4 instead\\n\"), fc->segment_size);\n\t\t  fc->segment_size = 4;\n\t\t}\n\t      SAFE_BYTE_GET_AND_INC (segment_selector, start,\n\t\t\t\t     fc->segment_size, block_end);\n\t    }\n\n\t  fc->pc_begin = get_encoded_value (&start, fc->fde_encoding, section,\n\t\t\t\t\t    block_end);\n\n\t  \/* FIXME: It appears that sometimes the final pc_range value is\n\t     encoded in less than encoded_ptr_size bytes.  See the x86_64\n\t     run of the \"objcopy on compressed debug sections\" test for an\n\t     example of this.  *\/\n\t  SAFE_BYTE_GET_AND_INC (fc->pc_range, start, encoded_ptr_size,\n\t\t\t\t block_end);\n\n\t  if (cie->augmentation[0] == 'z')\n\t    {\n\t      READ_ULEB (augmentation_data_len, start, block_end);\n\t      augmentation_data = start;\n\t      \/* PR 17512 file: 722-8446-0.004 and PR 22386.  *\/\n\t      if (augmentation_data_len > (bfd_size_type) (block_end - start))\n\t\t{\n\t\t  warn (_(\"Augmentation data too long: 0x%s, \"\n\t\t\t  \"expected at most %#lx\\n\"),\n\t\t\tdwarf_vmatoa (\"x\", augmentation_data_len),\n\t\t\t(unsigned long) (block_end - start));\n\t\t  start = block_end;\n\t\t  augmentation_data = NULL;\n\t\t  augmentation_data_len = 0;\n\t\t}\n\t      start += augmentation_data_len;\n\t    }\n\n\t  printf (\"\\n%08lx %s %s FDE \",\n\t\t  (unsigned long)(saved_start - section_start),\n\t\t  dwarf_vmatoa_1 (NULL, length, fc->ptr_size),\n\t\t  dwarf_vmatoa_1 (NULL, cie_id, offset_size));\n\n\t  if (cie->chunk_start)\n\t    printf (\"cie=%08lx\",\n\t\t    (unsigned long) (cie->chunk_start - section_start));\n\t  else\n\t    \/* Ideally translate \"invalid \" to 8 chars, trailing space\n\t       is optional.  *\/\n\t    printf (_(\"cie=invalid \"));\n\n\t  printf (\" pc=\");\n\t  if (fc->segment_size)\n\t    printf (\"%04lx:\", segment_selector);\n\n\t  printf (\"%s..%s\\n\",\n\t\t  dwarf_vmatoa_1 (NULL, fc->pc_begin, fc->ptr_size),\n\t\t  dwarf_vmatoa_1 (NULL, fc->pc_begin + fc->pc_range, fc->ptr_size));\n\n\t  if (! do_debug_frames_interp && augmentation_data_len)\n\t    {\n\t      display_augmentation_data (augmentation_data, augmentation_data_len);\n\t      putchar ('\\n');\n\t    }\n\t}\n\n      \/* At this point, fc is the current chunk, cie (if any) is set, and\n\t we're about to interpret instructions for the chunk.  *\/\n      \/* ??? At present we need to do this always, since this sizes the\n\t fc->col_type and fc->col_offset arrays, which we write into always.\n\t We should probably split the interpreted and non-interpreted bits\n\t into two different routines, since there's so much that doesn't\n\t really overlap between them.  *\/\n      if (1 || do_debug_frames_interp)\n\t{\n\t  \/* Start by making a pass over the chunk, allocating storage\n\t     and taking note of what registers are used.  *\/\n\t  unsigned char *tmp = start;\n\n\t  while (start < block_end)\n\t    {\n\t      unsigned int reg, op, opa;\n\t      unsigned long temp;\n\n\t      op = *start++;\n\t      opa = op & 0x3f;\n\t      if (op & 0xc0)\n\t\top &= 0xc0;\n\n\t      \/* Warning: if you add any more cases to this switch, be\n\t\t sure to add them to the corresponding switch below.  *\/\n\t      reg = -1u;\n\t      switch (op)\n\t\t{\n\t\tcase DW_CFA_advance_loc:\n\t\t  break;\n\t\tcase DW_CFA_offset:\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  reg = opa;\n\t\t  break;\n\t\tcase DW_CFA_restore:\n\t\t  reg = opa;\n\t\t  break;\n\t\tcase DW_CFA_set_loc:\n\t\t  if ((size_t) (block_end - start) < encoded_ptr_size)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += encoded_ptr_size;\n\t\t  break;\n\t\tcase DW_CFA_advance_loc1:\n\t\t  if ((size_t) (block_end - start) < 1)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += 1;\n\t\t  break;\n\t\tcase DW_CFA_advance_loc2:\n\t\t  if ((size_t) (block_end - start) < 2)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += 2;\n\t\t  break;\n\t\tcase DW_CFA_advance_loc4:\n\t\t  if ((size_t) (block_end - start) < 4)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += 4;\n\t\t  break;\n\t\tcase DW_CFA_offset_extended:\n\t\tcase DW_CFA_val_offset:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_restore_extended:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_undefined:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_same_value:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_register:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_def_cfa:\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_def_cfa_register:\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_def_cfa_offset:\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_def_cfa_expression:\n\t\t  READ_ULEB (temp, start, block_end);\n\t\t  if ((size_t) (block_end - start) < temp)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += temp;\n\t\t  break;\n\t\tcase DW_CFA_expression:\n\t\tcase DW_CFA_val_expression:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  READ_ULEB (temp, start, block_end);\n\t\t  if ((size_t) (block_end - start) < temp)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += temp;\n\t\t  break;\n\t\tcase DW_CFA_offset_extended_sf:\n\t\tcase DW_CFA_val_offset_sf:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  SKIP_SLEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_def_cfa_sf:\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  SKIP_SLEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_def_cfa_offset_sf:\n\t\t  SKIP_SLEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_MIPS_advance_loc8:\n\t\t  if ((size_t) (block_end - start) < 8)\n\t\t    start = block_end;\n\t\t  else\n\t\t    start += 8;\n\t\t  break;\n\t\tcase DW_CFA_GNU_args_size:\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tcase DW_CFA_GNU_negative_offset_extended:\n\t\t  READ_ULEB (reg, start, block_end);\n\t\t  SKIP_ULEB (start, block_end);\n\t\t  break;\n\t\tdefault:\n\t\t  break;\n\t\t}\n\t      if (reg != -1u && frame_need_space (fc, reg) >= 0)\n\t\t{\n\t\t  \/* Don't leave any reg as DW_CFA_unreferenced so\n\t\t     that frame_display_row prints name of regs in\n\t\t     header, and all referenced regs in each line.  *\/\n\t\t  if (reg >= cie->ncols\n\t\t      || cie->col_type[reg] == DW_CFA_unreferenced)\n\t\t    fc->col_type[reg] = DW_CFA_undefined;\n\t\t  else\n\t\t    fc->col_type[reg] = cie->col_type[reg];\n\t\t}\n\t    }\n\t  start = tmp;\n\t}\n\n      all_nops = true;\n\n      \/* Now we know what registers are used, make a second pass over\n\t the chunk, this time actually printing out the info.  *\/\n\n      while (start < block_end)\n\t{\n\t  unsigned op, opa;\n\t  unsigned long ul, roffs;\n\t  \/* Note: It is tempting to use an unsigned long for 'reg' but there\n\t     are various functions, notably frame_space_needed() that assume that\n\t     reg is an unsigned int.  *\/\n\t  unsigned int reg;\n\t  dwarf_signed_vma l;\n\t  dwarf_vma ofs;\n\t  dwarf_vma vma;\n\t  const char *reg_prefix = \"\";\n\n\t  op = *start++;\n\t  opa = op & 0x3f;\n\t  if (op & 0xc0)\n\t    op &= 0xc0;\n\n\t  \/* Make a note if something other than DW_CFA_nop happens.  *\/\n\t  if (op != DW_CFA_nop)\n\t    all_nops = false;\n\n\t  \/* Warning: if you add any more cases to this switch, be\n\t     sure to add them to the corresponding switch above.  *\/\n\t  switch (op)\n\t    {\n\t    case DW_CFA_advance_loc:\n\t      if (do_debug_frames_interp)\n\t\tframe_display_row (fc, &need_col_headers, &max_regs);\n\t      else\n\t\tprintf (\"  DW_CFA_advance_loc: %d to %s\\n\",\n\t\t\topa * fc->code_factor,\n\t\t\tdwarf_vmatoa_1 (NULL,\n\t\t\t\t\tfc->pc_begin + opa * fc->code_factor,\n\t\t\t\t\tfc->ptr_size));\n\t      fc->pc_begin += opa * fc->code_factor;\n\t      break;\n\n\t    case DW_CFA_offset:\n\t      READ_ULEB (roffs, start, block_end);\n\t      if (opa >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_offset: %s%s at cfa%+ld\\n\",\n\t\t\treg_prefix, regname (opa, 0),\n\t\t\troffs * fc->data_factor);\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[opa] = DW_CFA_offset;\n\t\t  fc->col_offset[opa] = roffs * fc->data_factor;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_restore:\n\t      if (opa >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_restore: %s%s\\n\",\n\t\t\treg_prefix, regname (opa, 0));\n\t      if (*reg_prefix != '\\0')\n\t\tbreak;\n\n\t      if (opa >= cie->ncols\n\t\t  || cie->col_type[opa] == DW_CFA_unreferenced)\n\t\t{\n\t\t  fc->col_type[opa] = DW_CFA_undefined;\n\t\t  fc->col_offset[opa] = 0;\n\t\t}\n\t      else\n\t\t{\n\t\t  fc->col_type[opa] = cie->col_type[opa];\n\t\t  fc->col_offset[opa] = cie->col_offset[opa];\n\t\t}\n\t      break;\n\n\t    case DW_CFA_set_loc:\n\t      vma = get_encoded_value (&start, fc->fde_encoding, section,\n\t\t\t\t       block_end);\n\t      if (do_debug_frames_interp)\n\t\tframe_display_row (fc, &need_col_headers, &max_regs);\n\t      else\n\t\tprintf (\"  DW_CFA_set_loc: %s\\n\",\n\t\t\tdwarf_vmatoa_1 (NULL, vma, fc->ptr_size));\n\t      fc->pc_begin = vma;\n\t      break;\n\n\t    case DW_CFA_advance_loc1:\n\t      SAFE_BYTE_GET_AND_INC (ofs, start, 1, block_end);\n\t      if (do_debug_frames_interp)\n\t\tframe_display_row (fc, &need_col_headers, &max_regs);\n\t      else\n\t\tprintf (\"  DW_CFA_advance_loc1: %ld to %s\\n\",\n\t\t\t(unsigned long) (ofs * fc->code_factor),\n\t\t\tdwarf_vmatoa_1 (NULL,\n\t\t\t\t\tfc->pc_begin + ofs * fc->code_factor,\n\t\t\t\t\tfc->ptr_size));\n\t      fc->pc_begin += ofs * fc->code_factor;\n\t      break;\n\n\t    case DW_CFA_advance_loc2:\n\t      SAFE_BYTE_GET_AND_INC (ofs, start, 2, block_end);\n\t      if (do_debug_frames_interp)\n\t\tframe_display_row (fc, &need_col_headers, &max_regs);\n\t      else\n\t\tprintf (\"  DW_CFA_advance_loc2: %ld to %s\\n\",\n\t\t\t(unsigned long) (ofs * fc->code_factor),\n\t\t\tdwarf_vmatoa_1 (NULL,\n\t\t\t\t\tfc->pc_begin + ofs * fc->code_factor,\n\t\t\t\t\tfc->ptr_size));\n\t      fc->pc_begin += ofs * fc->code_factor;\n\t      break;\n\n\t    case DW_CFA_advance_loc4:\n\t      SAFE_BYTE_GET_AND_INC (ofs, start, 4, block_end);\n\t      if (do_debug_frames_interp)\n\t\tframe_display_row (fc, &need_col_headers, &max_regs);\n\t      else\n\t\tprintf (\"  DW_CFA_advance_loc4: %ld to %s\\n\",\n\t\t\t(unsigned long) (ofs * fc->code_factor),\n\t\t\tdwarf_vmatoa_1 (NULL,\n\t\t\t\t\tfc->pc_begin + ofs * fc->code_factor,\n\t\t\t\t\tfc->ptr_size));\n\t      fc->pc_begin += ofs * fc->code_factor;\n\t      break;\n\n\t    case DW_CFA_offset_extended:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_ULEB (roffs, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_offset_extended: %s%s at cfa%+ld\\n\",\n\t\t\treg_prefix, regname (reg, 0),\n\t\t\troffs * fc->data_factor);\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_offset;\n\t\t  fc->col_offset[reg] = roffs * fc->data_factor;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_val_offset:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_ULEB (roffs, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_val_offset: %s%s is cfa%+ld\\n\",\n\t\t\treg_prefix, regname (reg, 0),\n\t\t\troffs * fc->data_factor);\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_val_offset;\n\t\t  fc->col_offset[reg] = roffs * fc->data_factor;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_restore_extended:\n\t      READ_ULEB (reg, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_restore_extended: %s%s\\n\",\n\t\t\treg_prefix, regname (reg, 0));\n\t      if (*reg_prefix != '\\0')\n\t\tbreak;\n\n\t      if (reg >= cie->ncols\n\t\t  || cie->col_type[reg] == DW_CFA_unreferenced)\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_undefined;\n\t\t  fc->col_offset[reg] = 0;\n\t\t}\n\t      else\n\t\t{\n\t\t  fc->col_type[reg] = cie->col_type[reg];\n\t\t  fc->col_offset[reg] = cie->col_offset[reg];\n\t\t}\n\t      break;\n\n\t    case DW_CFA_undefined:\n\t      READ_ULEB (reg, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_undefined: %s%s\\n\",\n\t\t\treg_prefix, regname (reg, 0));\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_undefined;\n\t\t  fc->col_offset[reg] = 0;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_same_value:\n\t      READ_ULEB (reg, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_same_value: %s%s\\n\",\n\t\t\treg_prefix, regname (reg, 0));\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_same_value;\n\t\t  fc->col_offset[reg] = 0;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_register:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_ULEB (roffs, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\t{\n\t\t  printf (\"  DW_CFA_register: %s%s in \",\n\t\t\t  reg_prefix, regname (reg, 0));\n\t\t  puts (regname (roffs, 0));\n\t\t}\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_register;\n\t\t  fc->col_offset[reg] = roffs;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_remember_state:\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_remember_state\\n\");\n\t      rs = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));\n\t      rs->cfa_offset = fc->cfa_offset;\n\t      rs->cfa_reg = fc->cfa_reg;\n\t      rs->ra = fc->ra;\n\t      rs->cfa_exp = fc->cfa_exp;\n\t      rs->ncols = fc->ncols;\n\t      rs->col_type = (short int *) xcmalloc (rs->ncols,\n\t\t\t\t\t\t     sizeof (* rs->col_type));\n\t      rs->col_offset = (int *) xcmalloc (rs->ncols, sizeof (* rs->col_offset));\n\t      memcpy (rs->col_type, fc->col_type, rs->ncols * sizeof (* fc->col_type));\n\t      memcpy (rs->col_offset, fc->col_offset, rs->ncols * sizeof (* fc->col_offset));\n\t      rs->next = remembered_state;\n\t      remembered_state = rs;\n\t      break;\n\n\t    case DW_CFA_restore_state:\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_restore_state\\n\");\n\t      rs = remembered_state;\n\t      if (rs)\n\t\t{\n\t\t  remembered_state = rs->next;\n\t\t  fc->cfa_offset = rs->cfa_offset;\n\t\t  fc->cfa_reg = rs->cfa_reg;\n\t\t  fc->ra = rs->ra;\n\t\t  fc->cfa_exp = rs->cfa_exp;\n\t\t  if (frame_need_space (fc, rs->ncols - 1) < 0)\n\t\t    {\n\t\t      warn (_(\"Invalid column number in saved frame state\\n\"));\n\t\t      fc->ncols = 0;\n\t\t      break;\n\t\t    }\n\t\t  memcpy (fc->col_type, rs->col_type, rs->ncols * sizeof (* rs->col_type));\n\t\t  memcpy (fc->col_offset, rs->col_offset,\n\t\t\t  rs->ncols * sizeof (* rs->col_offset));\n\t\t  free (rs->col_type);\n\t\t  free (rs->col_offset);\n\t\t  free (rs);\n\t\t}\n\t      else if (do_debug_frames_interp)\n\t\tprintf (\"Mismatched DW_CFA_restore_state\\n\");\n\t      break;\n\n\t    case DW_CFA_def_cfa:\n\t      READ_ULEB (fc->cfa_reg, start, block_end);\n\t      READ_ULEB (fc->cfa_offset, start, block_end);\n\t      fc->cfa_exp = 0;\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_def_cfa: %s ofs %d\\n\",\n\t\t\tregname (fc->cfa_reg, 0), (int) fc->cfa_offset);\n\t      break;\n\n\t    case DW_CFA_def_cfa_register:\n\t      READ_ULEB (fc->cfa_reg, start, block_end);\n\t      fc->cfa_exp = 0;\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_def_cfa_register: %s\\n\",\n\t\t\tregname (fc->cfa_reg, 0));\n\t      break;\n\n\t    case DW_CFA_def_cfa_offset:\n\t      READ_ULEB (fc->cfa_offset, start, block_end);\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_def_cfa_offset: %d\\n\", (int) fc->cfa_offset);\n\t      break;\n\n\t    case DW_CFA_nop:\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_nop\\n\");\n\t      break;\n\n\t    case DW_CFA_def_cfa_expression:\n\t      READ_ULEB (ul, start, block_end);\n\t      if (ul > (size_t) (block_end - start))\n\t\t{\n\t\t  printf (_(\"  DW_CFA_def_cfa_expression: <corrupt len %lu>\\n\"), ul);\n\t\t  break;\n\t\t}\n\t      if (! do_debug_frames_interp)\n\t\t{\n\t\t  printf (\"  DW_CFA_def_cfa_expression (\");\n\t\t  decode_location_expression (start, eh_addr_size, 0, -1,\n\t\t\t\t\t      ul, 0, section);\n\t\t  printf (\")\\n\");\n\t\t}\n\t      fc->cfa_exp = 1;\n\t      start += ul;\n\t      break;\n\n\t    case DW_CFA_expression:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_ULEB (ul, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      \/* PR 17512: file: 069-133014-0.006.  *\/\n\t      \/* PR 17512: file: 98c02eb4.  *\/\n\t      if (ul > (size_t) (block_end - start))\n\t\t{\n\t\t  printf (_(\"  DW_CFA_expression: <corrupt len %lu>\\n\"), ul);\n\t\t  break;\n\t\t}\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\t{\n\t\t  printf (\"  DW_CFA_expression: %s%s (\",\n\t\t\t  reg_prefix, regname (reg, 0));\n\t\t  decode_location_expression (start, eh_addr_size, 0, -1,\n\t\t\t\t\t      ul, 0, section);\n\t\t  printf (\")\\n\");\n\t\t}\n\t      if (*reg_prefix == '\\0')\n\t\tfc->col_type[reg] = DW_CFA_expression;\n\t      start += ul;\n\t      break;\n\n\t    case DW_CFA_val_expression:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_ULEB (ul, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (ul > (size_t) (block_end - start))\n\t\t{\n\t\t  printf (\"  DW_CFA_val_expression: <corrupt len %lu>\\n\", ul);\n\t\t  break;\n\t\t}\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\t{\n\t\t  printf (\"  DW_CFA_val_expression: %s%s (\",\n\t\t\t  reg_prefix, regname (reg, 0));\n\t\t  decode_location_expression (start, eh_addr_size, 0, -1,\n\t\t\t\t\t      ul, 0, section);\n\t\t  printf (\")\\n\");\n\t\t}\n\t      if (*reg_prefix == '\\0')\n\t\tfc->col_type[reg] = DW_CFA_val_expression;\n\t      start += ul;\n\t      break;\n\n\t    case DW_CFA_offset_extended_sf:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_SLEB (l, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_offset_extended_sf: %s%s at cfa%+ld\\n\",\n\t\t\treg_prefix, regname (reg, 0),\n\t\t\t(long)(l * fc->data_factor));\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_offset;\n\t\t  fc->col_offset[reg] = l * fc->data_factor;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_val_offset_sf:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_SLEB (l, start, block_end);\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_val_offset_sf: %s%s is cfa%+ld\\n\",\n\t\t\treg_prefix, regname (reg, 0),\n\t\t\t(long)(l * fc->data_factor));\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_val_offset;\n\t\t  fc->col_offset[reg] = l * fc->data_factor;\n\t\t}\n\t      break;\n\n\t    case DW_CFA_def_cfa_sf:\n\t      READ_ULEB (fc->cfa_reg, start, block_end);\n\t      READ_SLEB (l, start, block_end);\n\t      l *= fc->data_factor;\n\t      fc->cfa_offset = l;\n\t      fc->cfa_exp = 0;\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_def_cfa_sf: %s ofs %ld\\n\",\n\t\t\tregname (fc->cfa_reg, 0), (long) l);\n\t      break;\n\n\t    case DW_CFA_def_cfa_offset_sf:\n\t      READ_SLEB (l, start, block_end);\n\t      l *= fc->data_factor;\n\t      fc->cfa_offset = l;\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_def_cfa_offset_sf: %ld\\n\", (long) l);\n\t      break;\n\n\t    case DW_CFA_MIPS_advance_loc8:\n\t      SAFE_BYTE_GET_AND_INC (ofs, start, 8, block_end);\n\t      if (do_debug_frames_interp)\n\t\tframe_display_row (fc, &need_col_headers, &max_regs);\n\t      else\n\t\tprintf (\"  DW_CFA_MIPS_advance_loc8: %ld to %s\\n\",\n\t\t\t(unsigned long) (ofs * fc->code_factor),\n\t\t\tdwarf_vmatoa_1 (NULL,\n\t\t\t\t\tfc->pc_begin + ofs * fc->code_factor,\n\t\t\t\t\tfc->ptr_size));\n\t      fc->pc_begin += ofs * fc->code_factor;\n\t      break;\n\n\t    case DW_CFA_GNU_window_save:\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_GNU_window_save\\n\");\n\t      break;\n\n\t    case DW_CFA_GNU_args_size:\n\t      READ_ULEB (ul, start, block_end);\n\t      if (! do_debug_frames_interp)\n\t\tprintf (\"  DW_CFA_GNU_args_size: %ld\\n\", ul);\n\t      break;\n\n\t    case DW_CFA_GNU_negative_offset_extended:\n\t      READ_ULEB (reg, start, block_end);\n\t      READ_SLEB (l, start, block_end);\n\t      l = - l;\n\t      if (reg >= fc->ncols)\n\t\treg_prefix = bad_reg;\n\t      if (! do_debug_frames_interp || *reg_prefix != '\\0')\n\t\tprintf (\"  DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\\n\",\n\t\t\treg_prefix, regname (reg, 0),\n\t\t\t(long)(l * fc->data_factor));\n\t      if (*reg_prefix == '\\0')\n\t\t{\n\t\t  fc->col_type[reg] = DW_CFA_offset;\n\t\t  fc->col_offset[reg] = l * fc->data_factor;\n\t\t}\n\t      break;\n\n\t    default:\n\t      if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user)\n\t\tprintf (_(\"  DW_CFA_??? (User defined call frame op: %#x)\\n\"), op);\n\t      else\n\t\twarn (_(\"Unsupported or unknown Dwarf Call Frame Instruction number: %#x\\n\"), op);\n\t      start = block_end;\n\t    }\n\t}\n\n      \/* Interpret the CFA - as long as it is not completely full of NOPs.  *\/\n      if (do_debug_frames_interp && ! all_nops)\n\tframe_display_row (fc, &need_col_headers, &max_regs);\n\n      if (fde_fc.col_type != NULL)\n\t{\n\t  free (fde_fc.col_type);\n\t  fde_fc.col_type = NULL;\n\t}\n      if (fde_fc.col_offset != NULL)\n\t{\n\t  free (fde_fc.col_offset);\n\t  fde_fc.col_offset = NULL;\n\t}\n\n      start = block_end;\n      eh_addr_size = saved_eh_addr_size;\n    }\n\n  printf (\"\\n\");\n\n  while (remembered_state != NULL)\n    {\n      rs = remembered_state;\n      remembered_state = rs->next;\n      free (rs->col_type);\n      free (rs->col_offset);\n      rs->next = NULL; \/* Paranoia.  *\/\n      free (rs);\n    }\n\n  while (chunks != NULL)\n    {\n      rs = chunks;\n      chunks = rs->next;\n      free (rs->col_type);\n      free (rs->col_offset);\n      rs->next = NULL; \/* Paranoia.  *\/\n      free (rs);\n    }\n\n  while (forward_refs != NULL)\n    {\n      rs = forward_refs;\n      forward_refs = rs->next;\n      free (rs->col_type);\n      free (rs->col_offset);\n      rs->next = NULL; \/* Paranoia.  *\/\n      free (rs);\n    }\n\n  return 1;\n}","target":0,"code_token_length":8816,"total_token_length":9052,"max_tokens_setting":11000}
+{"idx":213076,"func":"static void compile_xclass_matchingpath(compiler_common *common, PCRE2_SPTR cc, jump_list **backtracks)\n{\nDEFINE_COMPILER;\njump_list *found = NULL;\njump_list **list = (cc[0] & XCL_NOT) == 0 ? &found : backtracks;\nsljit_uw c, charoffset, max = 256, min = READ_CHAR_MAX;\nstruct sljit_jump *jump = NULL;\nPCRE2_SPTR ccbegin;\nint compares, invertcmp, numberofcmps;\n#if defined SUPPORT_UNICODE && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16)\nBOOL utf = common->utf;\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == [8|16] *\/\n\n#ifdef SUPPORT_UNICODE\nsljit_u32 unicode_status = 0;\nint typereg = TMP1;\nconst sljit_u32 *other_cases;\nsljit_uw typeoffset;\n#endif \/* SUPPORT_UNICODE *\/\n\n\/* Scanning the necessary info. *\/\ncc++;\nccbegin = cc;\ncompares = 0;\n\nif (cc[-1] & XCL_MAP)\n  {\n  min = 0;\n  cc += 32 \/ sizeof(PCRE2_UCHAR);\n  }\n\nwhile (*cc != XCL_END)\n  {\n  compares++;\n  if (*cc == XCL_SINGLE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n    if (c > max) max = c;\n    if (c < min) min = c;\n#ifdef SUPPORT_UNICODE\n    unicode_status |= XCLASS_SAVE_CHAR;\n#endif \/* SUPPORT_UNICODE *\/\n    }\n  else if (*cc == XCL_RANGE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n    if (c < min) min = c;\n    GETCHARINCTEST(c, cc);\n    if (c > max) max = c;\n#ifdef SUPPORT_UNICODE\n    unicode_status |= XCLASS_SAVE_CHAR;\n#endif \/* SUPPORT_UNICODE *\/\n    }\n#ifdef SUPPORT_UNICODE\n  else\n    {\n    SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n    cc++;\n    if (*cc == PT_CLIST)\n      {\n      other_cases = PRIV(ucd_caseless_sets) + cc[1];\n      while (*other_cases != NOTACHAR)\n        {\n        if (*other_cases > max) max = *other_cases;\n        if (*other_cases < min) min = *other_cases;\n        other_cases++;\n        }\n      }\n    else\n      {\n      max = READ_CHAR_MAX;\n      min = 0;\n      }\n\n    switch(*cc)\n      {\n      case PT_ANY:\n      \/* Any either accepts everything or ignored. *\/\n      if (cc[-1] == XCL_PROP)\n        {\n        compile_char1_matchingpath(common, OP_ALLANY, cc, backtracks, FALSE);\n        if (list == backtracks)\n          add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n        return;\n        }\n      break;\n\n      case PT_LAMP:\n      case PT_GC:\n      case PT_PC:\n      case PT_ALNUM:\n      unicode_status |= XCLASS_HAS_TYPE;\n      break;\n\n      case PT_SCX:\n      unicode_status |= XCLASS_HAS_SCRIPT_EXTENSION;\n      if (cc[-1] == XCL_NOTPROP)\n        {\n        unicode_status |= XCLASS_SCRIPT_EXTENSION_NOTPROP;\n        break;\n        }\n      compares++;\n      \/* Fall through *\/ \n\n      case PT_SC:\n      unicode_status |= XCLASS_HAS_SCRIPT;\n      break;\n\n      case PT_SPACE:\n      case PT_PXSPACE:\n      case PT_WORD:\n      case PT_PXGRAPH:\n      case PT_PXPRINT:\n      case PT_PXPUNCT:\n      unicode_status |= XCLASS_SAVE_CHAR | XCLASS_HAS_TYPE;\n      break;\n\n      case PT_CLIST:\n      case PT_UCNC:\n      unicode_status |= XCLASS_SAVE_CHAR;\n      break;\n\n      case PT_BOOL:\n      unicode_status |= XCLASS_HAS_BOOL;\n      break;\n\n      case PT_BIDICL:\n      unicode_status |= XCLASS_HAS_BIDICL;\n      break;\n\n      default:\n      SLJIT_UNREACHABLE();\n      break;\n      }\n    cc += 2;\n    }\n#endif \/* SUPPORT_UNICODE *\/\n  }\nSLJIT_ASSERT(compares > 0);\n\n\/* We are not necessary in utf mode even in 8 bit mode. *\/\ncc = ccbegin;\nif ((cc[-1] & XCL_NOT) != 0)\n  read_char(common, min, max, backtracks, READ_CHAR_UPDATE_STR_PTR);\nelse\n  {\n#ifdef SUPPORT_UNICODE\n  read_char(common, min, max, (unicode_status & XCLASS_NEEDS_UCD) ? backtracks : NULL, 0);\n#else \/* !SUPPORT_UNICODE *\/\n  read_char(common, min, max, NULL, 0);\n#endif \/* SUPPORT_UNICODE *\/\n  }\n\nif ((cc[-1] & XCL_HASPROP) == 0)\n  {\n  if ((cc[-1] & XCL_MAP) != 0)\n    {\n    jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);\n    if (!optimize_class(common, (const sljit_u8 *)cc, (((const sljit_u8 *)cc)[31] & 0x80) != 0, TRUE, &found))\n      {\n      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);\n      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);\n      OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);\n      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);\n      OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);\n      add_jump(compiler, &found, JUMP(SLJIT_NOT_ZERO));\n      }\n\n    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n    JUMPHERE(jump);\n\n    cc += 32 \/ sizeof(PCRE2_UCHAR);\n    }\n  else\n    {\n    OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, min);\n    add_jump(compiler, (cc[-1] & XCL_NOT) == 0 ? backtracks : &found, CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, max - min));\n    }\n  }\nelse if ((cc[-1] & XCL_MAP) != 0)\n  {\n  OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);\n#ifdef SUPPORT_UNICODE\n  unicode_status |= XCLASS_CHAR_SAVED;\n#endif \/* SUPPORT_UNICODE *\/\n  if (!optimize_class(common, (const sljit_u8 *)cc, FALSE, TRUE, list))\n    {\n#if PCRE2_CODE_UNIT_WIDTH == 8\n    jump = NULL;\n    if (common->utf)\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 8 *\/\n      jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);\n\n    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);\n    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);\n    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);\n    OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);\n    add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO));\n\n#if PCRE2_CODE_UNIT_WIDTH == 8\n    if (common->utf)\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 8 *\/\n      JUMPHERE(jump);\n    }\n\n  OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);\n  cc += 32 \/ sizeof(PCRE2_UCHAR);\n  }\n\n#ifdef SUPPORT_UNICODE\nif (unicode_status & XCLASS_NEEDS_UCD)\n  {\n  if ((unicode_status & (XCLASS_SAVE_CHAR | XCLASS_CHAR_SAVED)) == XCLASS_SAVE_CHAR)\n    OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);\n\n#if PCRE2_CODE_UNIT_WIDTH == 32\n  if (!common->utf)\n    {\n    jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1);\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, UNASSIGNED_UTF_CHAR);\n    JUMPHERE(jump);\n    }\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 32 *\/\n\n  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);\n  OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));\n  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\n  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\n  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));\n  OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);\n  OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);\n  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);\n\n  ccbegin = cc;\n\n  if (unicode_status & XCLASS_HAS_BIDICL)\n    {\n    OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, scriptx_bidiclass));\n    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BIDICLASS_SHIFT);\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        if (*cc == PT_BIDICL)\n          {\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n          if (cc[-1] == XCL_NOTPROP)\n            invertcmp ^= 0x1;\n          jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1]);\n          add_jump(compiler, compares > 0 ? list : backtracks, jump);\n          }\n        cc += 2;\n        }\n      }\n\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_HAS_BOOL)\n    {\n    OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, bprops));\n    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BPROPS_MASK);\n    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2);\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        if (*cc == PT_BOOL)\n          {\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n          if (cc[-1] == XCL_NOTPROP)\n            invertcmp ^= 0x1;\n\n          OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), (sljit_sw)(PRIV(ucd_boolprop_sets) + (cc[1] >> 5)), SLJIT_IMM, (sljit_sw)1 << (cc[1] & 0x1f));\n          add_jump(compiler, compares > 0 ? list : backtracks, JUMP(SLJIT_NOT_ZERO ^ invertcmp));\n          }\n        cc += 2;\n        }\n      }\n\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_HAS_SCRIPT)\n    {\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        switch (*cc)\n          {\n          case PT_SCX:\n          if (cc[-1] == XCL_NOTPROP)\n            break;\n          \/* Fall through *\/ \n\n          case PT_SC:\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n          if (cc[-1] == XCL_NOTPROP)\n            invertcmp ^= 0x1;\n\n          add_jump(compiler, compares > 0 ? list : backtracks, CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1]));\n          }\n        cc += 2;\n        }\n      }\n\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_HAS_SCRIPT_EXTENSION)\n    {\n    OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, scriptx_bidiclass));\n    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_SCRIPTX_MASK);\n    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2);\n\n    if (unicode_status & XCLASS_SCRIPT_EXTENSION_NOTPROP)\n      {\n      if (unicode_status & XCLASS_HAS_TYPE)\n        {\n        if (unicode_status & XCLASS_SAVE_CHAR)\n          {\n          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, TMP2, 0);\n          unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0;\n          }\n        else\n          {\n          OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP2, 0);\n          unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR;\n          }\n        }\n      OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));\n      }\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        if (*cc == PT_SCX)\n          {\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n\n          jump = NULL;\n          if (cc[-1] == XCL_NOTPROP)\n            {\n            jump = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, (int)cc[1]);\n            if (invertcmp)\n              {\n              add_jump(compiler, backtracks, jump);\n              jump = NULL;\n              }\n            invertcmp ^= 0x1;\n            }\n\n          OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), (sljit_sw)(PRIV(ucd_script_sets) + (cc[1] >> 5)), SLJIT_IMM, (sljit_sw)1 << (cc[1] & 0x1f));\n          add_jump(compiler, compares > 0 ? list : backtracks, JUMP(SLJIT_NOT_ZERO ^ invertcmp));\n\n          if (jump != NULL)\n            JUMPHERE(jump);\n          }\n        cc += 2;\n        }\n      }\n\n    if (unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0)\n      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);\n    else if (unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR)\n      OP1(SLJIT_MOV, TMP2, 0, RETURN_ADDR, 0);\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_SAVE_CHAR)\n    OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);\n\n  if (unicode_status & XCLASS_HAS_TYPE)\n    {\n    if (unicode_status & XCLASS_SAVE_CHAR)\n      typereg = RETURN_ADDR;\n\n    OP1(SLJIT_MOV_U8, typereg, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));\n    }\n  }\n#endif \/* SUPPORT_UNICODE *\/\n\n\/* Generating code. *\/\ncharoffset = 0;\nnumberofcmps = 0;\n#ifdef SUPPORT_UNICODE\ntypeoffset = 0;\n#endif \/* SUPPORT_UNICODE *\/\n\nwhile (*cc != XCL_END)\n  {\n  compares--;\n  invertcmp = (compares == 0 && list != backtracks);\n  jump = NULL;\n\n  if (*cc == XCL_SINGLE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n\n    if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n      numberofcmps++;\n      }\n    else if (numberofcmps > 0)\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      numberofcmps = 0;\n      }\n    else\n      {\n      jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      numberofcmps = 0;\n      }\n    }\n  else if (*cc == XCL_RANGE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n    SET_CHAR_OFFSET(c);\n    GETCHARINCTEST(c, cc);\n\n    if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);\n      numberofcmps++;\n      }\n    else if (numberofcmps > 0)\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      numberofcmps = 0;\n      }\n    else\n      {\n      jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      numberofcmps = 0;\n      }\n    }\n#ifdef SUPPORT_UNICODE\n  else\n    {\n    SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n    if (*cc == XCL_NOTPROP)\n      invertcmp ^= 0x1;\n    cc++;\n    switch(*cc)\n      {\n      case PT_ANY:\n      if (!invertcmp)\n        jump = JUMP(SLJIT_JUMP);\n      break;\n\n      case PT_LAMP:\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Lu - typeoffset);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Ll - typeoffset);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Lt - typeoffset);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_GC:\n      c = PRIV(ucp_typerange)[(int)cc[1] * 2];\n      SET_TYPE_OFFSET(c);\n      jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, PRIV(ucp_typerange)[(int)cc[1] * 2 + 1] - c);\n      break;\n\n      case PT_PC:\n      jump = CMP(SLJIT_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, (int)cc[1] - typeoffset);\n      break;\n\n      case PT_SC:\n      case PT_SCX:\n      case PT_BOOL:\n      case PT_BIDICL:\n      compares++;\n      \/* Do nothing. *\/\n      break;\n\n      case PT_SPACE:\n      case PT_PXSPACE:\n      SET_CHAR_OFFSET(9);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0xd - 0x9);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x85 - 0x9);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x9);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      SET_TYPE_OFFSET(ucp_Zl);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Zl);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_WORD:\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_UNDERSCORE - charoffset));\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n      \/* Fall through. *\/\n\n      case PT_ALNUM:\n      SET_TYPE_OFFSET(ucp_Ll);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);\n      OP_FLAGS((*cc == PT_ALNUM) ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);\n      SET_TYPE_OFFSET(ucp_Nd);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_No - ucp_Nd);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_CLIST:\n      other_cases = PRIV(ucd_caseless_sets) + cc[1];\n\n      \/* At least three characters are required.\n         Otherwise this case would be handled by the normal code path. *\/\n      SLJIT_ASSERT(other_cases[0] != NOTACHAR && other_cases[1] != NOTACHAR && other_cases[2] != NOTACHAR);\n      SLJIT_ASSERT(other_cases[0] < other_cases[1] && other_cases[1] < other_cases[2]);\n\n      \/* Optimizing character pairs, if their difference is power of 2. *\/\n      if (is_powerof2(other_cases[1] ^ other_cases[0]))\n        {\n        if (charoffset == 0)\n          OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);\n        else\n          {\n          OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);\n          OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);\n          }\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, other_cases[1]);\n        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n        other_cases += 2;\n        }\n      else if (is_powerof2(other_cases[2] ^ other_cases[1]))\n        {\n        if (charoffset == 0)\n          OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);\n        else\n          {\n          OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);\n          OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);\n          }\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, other_cases[2]);\n        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(other_cases[0] - charoffset));\n        OP_FLAGS(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_Z : 0), TMP2, 0, SLJIT_EQUAL);\n\n        other_cases += 3;\n        }\n      else\n        {\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset));\n        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n        }\n\n      while (*other_cases != NOTACHAR)\n        {\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset));\n        OP_FLAGS(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_Z : 0), TMP2, 0, SLJIT_EQUAL);\n        }\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_UCNC:\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_DOLLAR_SIGN - charoffset));\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_COMMERCIAL_AT - charoffset));\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_GRAVE_ACCENT - charoffset));\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      SET_CHAR_OFFSET(0xa0);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(0xd7ff - charoffset));\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);\n      SET_CHAR_OFFSET(0);\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xe000 - 0);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_GREATER_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_PXGRAPH:\n      \/* C and Z groups are the farthest two groups. *\/\n      SET_TYPE_OFFSET(ucp_Ll);\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_GREATER);\n\n      jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);\n\n      \/* In case of ucp_Cf, we overwrite the result. *\/\n      SET_CHAR_OFFSET(0x2066);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      JUMPHERE(jump);\n      jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);\n      break;\n\n      case PT_PXPRINT:\n      \/* C and Z groups are the farthest two groups. *\/\n      SET_TYPE_OFFSET(ucp_Ll);\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_GREATER);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Ll);\n      OP_FLAGS(SLJIT_AND, TMP2, 0, SLJIT_NOT_EQUAL);\n\n      jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);\n\n      \/* In case of ucp_Cf, we overwrite the result. *\/\n      SET_CHAR_OFFSET(0x2066);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      JUMPHERE(jump);\n      jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);\n      break;\n\n      case PT_PXPUNCT:\n      SET_TYPE_OFFSET(ucp_Sc);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_So - ucp_Sc);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      SET_CHAR_OFFSET(0);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x7f);\n      OP_FLAGS(SLJIT_AND, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      SET_TYPE_OFFSET(ucp_Pc);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Ps - ucp_Pc);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      default:\n      SLJIT_UNREACHABLE();\n      break;\n      }\n    cc += 2;\n    }\n#endif \/* SUPPORT_UNICODE *\/\n\n  if (jump != NULL)\n    add_jump(compiler, compares > 0 ? list : backtracks, jump);\n  }\n\nif (found != NULL)\n  set_jumps(found, LABEL());\n}","target":1,"code_token_length":8095,"total_token_length":8331,"max_tokens_setting":11000}
+{"idx":269507,"func":"static Image *ReadTIFFImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n#define ThrowTIFFException(severity,message) \\\n{ \\\n  if (pixel_info != (MemoryInfo *) NULL) \\\n    pixel_info=RelinquishVirtualMemory(pixel_info); \\\n  if (quantum_info != (QuantumInfo *) NULL) \\\n    quantum_info=DestroyQuantumInfo(quantum_info); \\\n  TIFFClose(tiff); \\\n  ThrowReaderException(severity,message); \\\n}\n\n  float\n    *chromaticity = (float *) NULL,\n    x_position,\n    y_position,\n    x_resolution,\n    y_resolution;\n\n  Image\n    *image;\n\n  int\n    tiff_status = 0;\n\n  MagickBooleanType\n    more_frames;\n\n  MagickSizeType\n    number_pixels;\n\n  MagickStatusType\n    status;\n\n  MemoryInfo\n    *pixel_info = (MemoryInfo *) NULL;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  ssize_t\n    i,\n    scanline_size,\n    y;\n\n  TIFF\n    *tiff;\n\n  TIFFMethodType\n    method;\n\n  uint16\n    compress_tag = 0,\n    bits_per_sample = 0,\n    endian = 0,\n    extra_samples = 0,\n    interlace = 0,\n    max_sample_value = 0,\n    min_sample_value = 0,\n    orientation = 0,\n    pages = 0,\n    photometric = 0,\n    *sample_info = NULL,\n    sample_format = 0,\n    samples_per_pixel = 0,\n    units = 0,\n    value = 0;\n\n  uint32\n    height,\n    rows_per_strip,\n    width;\n\n  unsigned char\n    *pixels;\n\n  void\n    *sans[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };\n\n  \/*\n    Open image.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info,exception);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  (void) SetMagickThreadValue(tiff_exception,exception);\n  tiff=TIFFClientOpen(image->filename,\"rb\",(thandle_t) image,TIFFReadBlob,\n    TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob,\n    TIFFUnmapBlob);\n  if (tiff == (TIFF *) NULL)\n    {\n      if (exception->severity == UndefinedException)\n        ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (exception->severity > ErrorException)\n    {\n      TIFFClose(tiff);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (image_info->number_scenes != 0)\n    {\n      \/*\n        Generate blank images for subimage specification (e.g. image.tif[4].\n        We need to check the number of directores because it is possible that\n        the subimage(s) are stored in the photoshop profile.\n      *\/\n      if (image_info->scene < (size_t) TIFFNumberOfDirectories(tiff))\n        {\n          for (i=0; i < (ssize_t) image_info->scene; i++)\n          {\n            status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n            if (status == MagickFalse)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            AcquireNextImage(image_info,image,exception);\n            if (GetNextImageInList(image) == (Image *) NULL)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            image=SyncNextImageInList(image);\n          }\n      }\n  }\n  more_frames=MagickTrue;\n  do\n  {\n    \/* TIFFPrintDirectory(tiff,stdout,MagickFalse); *\/\n    photometric=PHOTOMETRIC_RGB;\n    if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) ||\n        (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value,sans) != 1))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    if (((sample_format != SAMPLEFORMAT_IEEEFP) || (bits_per_sample != 64)) &&\n        ((bits_per_sample <= 0) || (bits_per_sample > 32)))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"UnsupportedBitsPerPixel\");\n      }\n    if (samples_per_pixel > MaxPixelChannels)\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"MaximumChannelsExceeded\");\n      }\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      (void) SetImageProperty(image,\"quantum:format\",\"floating-point\",\n        exception);\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-black\",\n          exception);\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-white\",\n          exception);\n        break;\n      }\n      case PHOTOMETRIC_PALETTE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"palette\",exception);\n        break;\n      }\n      case PHOTOMETRIC_RGB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"RGB\",exception);\n        break;\n      }\n      case PHOTOMETRIC_CIELAB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIELAB\",exception);\n        break;\n      }\n      case PHOTOMETRIC_LOGL:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIE Log2(L)\",\n          exception);\n        break;\n      }\n      case PHOTOMETRIC_LOGLUV:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"LOGLUV\",exception);\n        break;\n      }\n#if defined(PHOTOMETRIC_MASK)\n      case PHOTOMETRIC_MASK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"MASK\",exception);\n        break;\n      }\n#endif\n      case PHOTOMETRIC_SEPARATED:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"separated\",exception);\n        break;\n      }\n      case PHOTOMETRIC_YCBCR:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"YCBCR\",exception);\n        break;\n      }\n      default:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"unknown\",exception);\n        break;\n      }\n    }\n    if (image->debug != MagickFalse)\n      {\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Geometry: %ux%u\",\n          (unsigned int) width,(unsigned int) height);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Interlace: %u\",\n          interlace);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Bits per sample: %u\",bits_per_sample);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Min sample value: %u\",min_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Max sample value: %u\",max_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Photometric \"\n          \"interpretation: %s\",GetImageProperty(image,\"tiff:photometric\",\n          exception));\n      }\n    image->columns=(size_t) width;\n    image->rows=(size_t) height;\n    image->depth=(size_t) bits_per_sample;\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Image depth: %.20g\",\n        (double) image->depth);\n    image->endian=MSBEndian;\n    if (endian == FILLORDER_LSB2MSB)\n      image->endian=LSBEndian;\n#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN)\n    if (TIFFIsBigEndian(tiff) == 0)\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"lsb\",exception);\n        image->endian=LSBEndian;\n      }\n    else\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"msb\",exception);\n        image->endian=MSBEndian;\n      }\n#endif\n    if ((photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      (void) SetImageColorspace(image,GRAYColorspace,exception);\n    if (photometric == PHOTOMETRIC_SEPARATED)\n      (void) SetImageColorspace(image,CMYKColorspace,exception);\n    if (photometric == PHOTOMETRIC_CIELAB)\n      (void) SetImageColorspace(image,LabColorspace,exception);\n    if ((photometric == PHOTOMETRIC_YCBCR) &&\n        (compress_tag != COMPRESSION_OJPEG) &&\n        (compress_tag != COMPRESSION_JPEG))\n      (void) SetImageColorspace(image,YCbCrColorspace,exception);\n    status=TIFFGetProfiles(tiff,image,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        return(DestroyImageList(image));\n      }\n    status=TIFFGetProperties(tiff,image,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        return(DestroyImageList(image));\n      }\n    TIFFGetEXIFProperties(tiff,image,image_info,exception);\n    TIFFGetGPSProperties(tiff,image,image_info,exception);\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution,sans) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution,sans) == 1))\n      {\n        image->resolution.x=x_resolution;\n        image->resolution.y=y_resolution;\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units,sans,sans) == 1)\n      {\n        if (units == RESUNIT_INCH)\n          image->units=PixelsPerInchResolution;\n        if (units == RESUNIT_CENTIMETER)\n          image->units=PixelsPerCentimeterResolution;\n      }\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))\n      {\n        image->page.x=CastDoubleToLong(ceil(x_position*\n          image->resolution.x-0.5));\n        image->page.y=CastDoubleToLong(ceil(y_position*\n          image->resolution.y-0.5));\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)\n      image->orientation=(OrientationType) orientation;\n    if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1)\n      {\n        if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0))\n          {\n            image->chromaticity.white_point.x=chromaticity[0];\n            image->chromaticity.white_point.y=chromaticity[1];\n          }\n      }\n    if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1)\n      {\n        if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0))\n          {\n            image->chromaticity.red_primary.x=chromaticity[0];\n            image->chromaticity.red_primary.y=chromaticity[1];\n            image->chromaticity.green_primary.x=chromaticity[2];\n            image->chromaticity.green_primary.y=chromaticity[3];\n            image->chromaticity.blue_primary.x=chromaticity[4];\n            image->chromaticity.blue_primary.y=chromaticity[5];\n          }\n      }\n#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)\n    if ((compress_tag != COMPRESSION_NONE) &&\n        (TIFFIsCODECConfigured(compress_tag) == 0))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CoderError,\"CompressNotSupported\");\n      }\n#endif\n    switch (compress_tag)\n    {\n      case COMPRESSION_NONE: image->compression=NoCompression; break;\n      case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break;\n      case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break;\n      case COMPRESSION_JPEG:\n      {\n         image->compression=JPEGCompression;\n#if defined(JPEG_SUPPORT)\n         {\n           char\n             sampling_factor[MagickPathExtent];\n\n           uint16\n             horizontal,\n             vertical;\n\n           tiff_status=TIFFGetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal,\n             &vertical);\n           if (tiff_status == 1)\n             {\n               (void) FormatLocaleString(sampling_factor,MagickPathExtent,\n                 \"%dx%d\",horizontal,vertical);\n               (void) SetImageProperty(image,\"jpeg:sampling-factor\",\n                 sampling_factor,exception);\n               (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                 \"Sampling Factors: %s\",sampling_factor);\n             }\n         }\n#endif\n        break;\n      }\n      case COMPRESSION_OJPEG: image->compression=JPEGCompression; break;\n#if defined(COMPRESSION_LZMA)\n      case COMPRESSION_LZMA: image->compression=LZMACompression; break;\n#endif\n      case COMPRESSION_LZW: image->compression=LZWCompression; break;\n      case COMPRESSION_DEFLATE: image->compression=ZipCompression; break;\n      case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break;\n#if defined(COMPRESSION_WEBP)\n      case COMPRESSION_WEBP: image->compression=WebPCompression; break;\n#endif\n#if defined(COMPRESSION_ZSTD)\n      case COMPRESSION_ZSTD: image->compression=ZstdCompression; break;\n#endif\n      default: image->compression=RLECompression; break;\n    }\n    quantum_info=(QuantumInfo *) NULL;\n    if ((photometric == PHOTOMETRIC_PALETTE) &&\n        (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))\n      {\n        size_t\n          colors;\n\n        colors=(size_t) GetQuantumRange(bits_per_sample)+1;\n        if (AcquireImageColormap(image,colors,exception) == MagickFalse)\n          {\n            TIFFClose(tiff);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    value=(unsigned short) image->scene;\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages,sans) == 1)\n      image->scene=value;\n    if (image->storage_class == PseudoClass)\n      {\n        size_t\n          range;\n\n        uint16\n          *blue_colormap = (uint16 *) NULL,\n          *green_colormap = (uint16 *) NULL,\n          *red_colormap = (uint16 *) NULL;\n\n        \/*\n          Initialize colormap.\n        *\/\n        tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,\n          &green_colormap,&blue_colormap);\n        if (tiff_status == 1)\n          {\n            if ((red_colormap != (uint16 *) NULL) &&\n                (green_colormap != (uint16 *) NULL) &&\n                (blue_colormap != (uint16 *) NULL))\n              {\n                range=255;  \/* might be old style 8-bit colormap *\/\n                for (i=0; i < (ssize_t) image->colors; i++)\n                  if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||\n                      (blue_colormap[i] >= 256))\n                    {\n                      range=65535;\n                      break;\n                    }\n                for (i=0; i < (ssize_t) image->colors; i++)\n                {\n                  image->colormap[i].red=ClampToQuantum(((double)\n                    QuantumRange*red_colormap[i])\/range);\n                  image->colormap[i].green=ClampToQuantum(((double)\n                    QuantumRange*green_colormap[i])\/range);\n                  image->colormap[i].blue=ClampToQuantum(((double)\n                    QuantumRange*blue_colormap[i])\/range);\n                }\n              }\n          }\n      }\n    if (image_info->ping != MagickFalse)\n      {\n        if (image_info->number_scenes != 0)\n          if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n            break;\n        goto next_tiff_frame;\n      }\n    status=SetImageExtent(image,image->columns,image->rows,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        return(DestroyImageList(image));\n      }\n    status=SetImageColorspace(image,image->colorspace,exception);\n    status&=ResetImagePixels(image,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        return(DestroyImageList(image));\n      }\n    \/*\n      Allocate memory for the image and pixel buffer.\n    *\/\n    quantum_info=AcquireQuantumInfo(image_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (sample_format == SAMPLEFORMAT_UINT)\n      status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_INT)\n      status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);\n    if (status == MagickFalse)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    status=MagickTrue;\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        quantum_info->min_is_white=MagickFalse;\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        quantum_info->min_is_white=MagickTrue;\n        break;\n      }\n      default:\n        break;\n    }\n    extra_samples=0;\n    tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,\n      &sample_info,sans);\n    if (tiff_status == 1)\n      {\n        (void) SetImageProperty(image,\"tiff:alpha\",\"unspecified\",exception);\n        if (extra_samples == 0)\n          {\n            if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))\n              image->alpha_trait=BlendPixelTrait;\n          }\n        else\n          for (i=0; i < extra_samples; i++)\n          {\n            image->alpha_trait=BlendPixelTrait;\n            if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)\n              {\n                SetQuantumAlphaType(quantum_info,AssociatedQuantumAlpha);\n                (void) SetImageProperty(image,\"tiff:alpha\",\"associated\",\n                  exception);\n              }\n            else\n              if (sample_info[i] == EXTRASAMPLE_UNASSALPHA)\n                {\n                  SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);\n                  (void) SetImageProperty(image,\"tiff:alpha\",\"unassociated\",\n                    exception);\n                }\n          }\n      }\n    if (image->alpha_trait != UndefinedPixelTrait)\n      (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);\n    method=ReadGenericMethod;\n    rows_per_strip=(uint32) image->rows;\n    if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1)\n      {\n        char\n          buffer[MagickPathExtent];\n\n        (void) FormatLocaleString(buffer,MagickPathExtent,\"%u\",\n          (unsigned int) rows_per_strip);\n        (void) SetImageProperty(image,\"tiff:rows-per-strip\",buffer,exception);\n        method=ReadStripMethod;\n        if (rows_per_strip > (uint32) image->rows)\n          rows_per_strip=(uint32) image->rows;\n      }\n    if (TIFFIsTiled(tiff) != MagickFalse)\n      {\n        uint32\n          columns,\n          rows;\n\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        if ((AcquireMagickResource(WidthResource,columns) == MagickFalse) ||\n            (AcquireMagickResource(HeightResource,rows) == MagickFalse))\n          ThrowTIFFException(ImageError,\"WidthOrHeightExceedsLimit\");\n        method=ReadTileMethod;\n      }\n    if ((photometric == PHOTOMETRIC_LOGLUV) ||\n        (compress_tag == COMPRESSION_CCITTFAX3))\n      method=ReadGenericMethod;\n    if (image->compression == JPEGCompression)\n      method=GetJPEGMethod(image,tiff,photometric,bits_per_sample,\n        samples_per_pixel);\n    quantum_info->endian=LSBEndian;\n    scanline_size=TIFFScanlineSize(tiff);\n    if (scanline_size <= 0)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    number_pixels=MagickMax((MagickSizeType) image->columns*samples_per_pixel*\n      pow(2.0,ceil(log(bits_per_sample)\/log(2.0))),image->columns*\n      rows_per_strip);\n    if ((double) scanline_size > 1.5*number_pixels)\n      ThrowTIFFException(CorruptImageError,\"CorruptImage\");\n    number_pixels=MagickMax((MagickSizeType) scanline_size,number_pixels);\n    pixel_info=AcquireVirtualMemory(number_pixels,sizeof(uint32));\n    if (pixel_info == (MemoryInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    (void) memset(pixels,0,number_pixels*sizeof(uint32));\n    quantum_type=GrayQuantum;\n    if (image->storage_class == PseudoClass)\n      quantum_type=IndexQuantum;\n    if (interlace != PLANARCONFIG_SEPARATE)\n      {\n        size_t\n          pad;\n\n        pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0);\n        if (image->alpha_trait != UndefinedPixelTrait)\n          {\n            if (image->storage_class == PseudoClass)\n              quantum_type=IndexAlphaQuantum;\n            else\n              quantum_type=samples_per_pixel == 1 ? AlphaQuantum :\n                GrayAlphaQuantum;\n          }\n        if ((samples_per_pixel > 2) && (interlace != PLANARCONFIG_SEPARATE))\n          {\n            quantum_type=RGBQuantum;\n            pad=(size_t) MagickMax((size_t) samples_per_pixel-3,0);\n            if (image->alpha_trait != UndefinedPixelTrait)\n              {\n                quantum_type=RGBAQuantum;\n                pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0);\n              }\n            if (image->colorspace == CMYKColorspace)\n              {\n                quantum_type=CMYKQuantum;\n                pad=(size_t) MagickMax((size_t) samples_per_pixel-4,0);\n                if (image->alpha_trait != UndefinedPixelTrait)\n                  {\n                    quantum_type=CMYKAQuantum;\n                    pad=(size_t) MagickMax((size_t) samples_per_pixel-5,0);\n                  }\n              }\n            status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >>\n              3));\n            if (status == MagickFalse)\n              ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    switch (method)\n    {\n      case ReadYCCKMethod:\n      {\n        \/*\n          Convert YCC TIFF image.\n        *\/\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          Quantum\n            *magick_restrict q;\n\n          ssize_t\n            x;\n\n          unsigned char\n            *p;\n\n          tiff_status=TIFFReadPixels(tiff,0,y,(char *) pixels);\n          if (tiff_status == -1)\n            break;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          p=pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelCyan(image,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.402*(double) *(p+2))-179.456)),q);\n            SetPixelMagenta(image,ScaleCharToQuantum(ClampYCC((double) *p-\n              (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+\n              135.45984)),q);\n            SetPixelYellow(image,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.772*(double) *(p+1))-226.816)),q);\n            SetPixelBlack(image,ScaleCharToQuantum((unsigned char) *(p+3)),q);\n            q+=GetPixelChannels(image);\n            p+=4;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadStripMethod:\n      {\n        unsigned char\n          *p;\n\n        size_t\n          extent;\n\n        ssize_t\n          stride,\n          strip_id;\n\n        tsize_t\n          strip_size;\n\n        unsigned char\n          *strip_pixels;\n\n        \/*\n          Convert stripped TIFF image.\n        *\/\n        extent=(samples_per_pixel+1)*TIFFStripSize(tiff);\n#if defined(TIFF_VERSION_BIG)\n        extent+=image->columns*sizeof(uint64);\n#else\n        extent+=image->columns*sizeof(uint32);\n#endif\n        strip_pixels=(unsigned char *) AcquireQuantumMemory(extent,\n          sizeof(*strip_pixels));\n        if (strip_pixels == (unsigned char *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(strip_pixels,0,extent*sizeof(*strip_pixels));\n        stride=TIFFVStripSize(tiff,1);\n        strip_id=0;\n        p=strip_pixels;\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          size_t\n            rows_remaining;\n\n          switch (i)\n          {\n            case 0: break;\n            case 1: quantum_type=GreenQuantum; break;\n            case 2: quantum_type=BlueQuantum; break;\n            case 3:\n            {\n              quantum_type=AlphaQuantum;\n              if (image->colorspace == CMYKColorspace)\n                quantum_type=BlackQuantum;\n              break;\n            }\n            case 4: quantum_type=AlphaQuantum; break;\n            default: break;\n          }\n          rows_remaining=0;\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            Quantum\n              *magick_restrict q;\n\n            q=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (Quantum *) NULL)\n              break;\n            if (rows_remaining == 0)\n              {\n                strip_size=TIFFReadEncodedStrip(tiff,strip_id,strip_pixels,\n                  TIFFStripSize(tiff));\n                if (strip_size == -1)\n                  break;\n                rows_remaining=rows_per_strip;\n                if ((y+rows_per_strip) > (ssize_t) image->rows)\n                  rows_remaining=(rows_per_strip-(y+rows_per_strip-\n                    image->rows));\n                p=strip_pixels;\n                strip_id++;\n              }\n            (void) ImportQuantumPixels(image,(CacheView *) NULL,\n              quantum_info,quantum_type,p,exception);\n            p+=stride;\n            rows_remaining--;\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                  image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n          if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE))\n            break;\n        }\n        strip_pixels=(unsigned char *) RelinquishMagickMemory(strip_pixels);\n        break;\n      }\n      case ReadTileMethod:\n      {\n        unsigned char\n          *p;\n\n        size_t\n          extent;\n\n        uint32\n          columns,\n          rows;\n\n        unsigned char\n          *tile_pixels;\n\n        \/*\n          Convert tiled TIFF image.\n        *\/\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        number_pixels=(MagickSizeType) columns*rows;\n        if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        extent=4*MagickMax(rows*TIFFTileRowSize(tiff),TIFFTileSize(tiff));\n#if defined(TIFF_VERSION_BIG)\n        extent+=image->columns*sizeof(uint64);\n#else\n        extent+=image->columns*sizeof(uint32);\n#endif\n        tile_pixels=(unsigned char *) AcquireQuantumMemory(extent,\n          sizeof(*tile_pixels));\n        if (tile_pixels == (unsigned char *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(tile_pixels,0,extent*sizeof(*tile_pixels));\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          switch (i)\n          {\n            case 0: break;\n            case 1: quantum_type=GreenQuantum; break;\n            case 2: quantum_type=BlueQuantum; break;\n            case 3:\n            {\n              quantum_type=AlphaQuantum;\n              if (image->colorspace == CMYKColorspace)\n                quantum_type=BlackQuantum;\n              break;\n            }\n            case 4: quantum_type=AlphaQuantum; break;\n            default: break;\n          }\n          for (y=0; y < (ssize_t) image->rows; y+=rows)\n          {\n            ssize_t\n              x;\n\n            size_t\n              rows_remaining;\n\n            rows_remaining=image->rows-y;\n            if ((ssize_t) (y+rows) < (ssize_t) image->rows)\n              rows_remaining=rows;\n            for (x=0; x < (ssize_t) image->columns; x+=columns)\n            {\n              size_t\n                columns_remaining,\n                row;\n\n              columns_remaining=image->columns-x;\n              if ((ssize_t) (x+columns) < (ssize_t) image->columns)\n                columns_remaining=columns;\n              tiff_status=TIFFReadTile(tiff,tile_pixels,(uint32) x,(uint32) y,\n                0,i);\n              if (tiff_status == -1)\n                break;\n              p=tile_pixels;\n              for (row=0; row < rows_remaining; row++)\n              {\n                Quantum\n                  *magick_restrict q;\n\n                q=GetAuthenticPixels(image,x,y+row,columns_remaining,1,\n                  exception);\n                if (q == (Quantum *) NULL)\n                  break;\n                (void) ImportQuantumPixels(image,(CacheView *) NULL,\n                  quantum_info,quantum_type,p,exception);\n                p+=TIFFTileRowSize(tiff);\n                if (SyncAuthenticPixels(image,exception) == MagickFalse)\n                  break;\n              }\n            }\n          }\n          if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE))\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) i,\n                samples_per_pixel);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        tile_pixels=(unsigned char *) RelinquishMagickMemory(tile_pixels);\n        break;\n      }\n      case ReadGenericMethod:\n      default:\n      {\n        MemoryInfo\n          *generic_info = (MemoryInfo * ) NULL;\n\n        uint32\n          *p;\n\n        \/*\n          Convert generic TIFF image.\n        *\/\n        if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        number_pixels=(MagickSizeType) image->columns*image->rows;\n#if defined(TIFF_VERSION_BIG)\n        number_pixels+=image->columns*sizeof(uint64);\n#else\n        number_pixels+=image->columns*sizeof(uint32);\n#endif\n        generic_info=AcquireVirtualMemory(number_pixels,sizeof(uint32));\n        if (generic_info == (MemoryInfo *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        p=(uint32 *) GetVirtualMemoryBlob(generic_info);\n        tiff_status=TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32)\n          image->rows,(uint32 *) p,0);\n        if (tiff_status == -1)\n          {\n            generic_info=RelinquishVirtualMemory(generic_info);\n            break;\n          }\n        p+=(image->columns*image->rows)-1;\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          ssize_t\n            x;\n\n          Quantum\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (Quantum *) NULL)\n            break;\n          q+=GetPixelChannels(image)*(image->columns-1);\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(image,ScaleCharToQuantum((unsigned char)\n              TIFFGetR(*p)),q);\n            SetPixelGreen(image,ScaleCharToQuantum((unsigned char)\n              TIFFGetG(*p)),q);\n            SetPixelBlue(image,ScaleCharToQuantum((unsigned char)\n              TIFFGetB(*p)),q);\n            if (image->alpha_trait != UndefinedPixelTrait)\n              SetPixelAlpha(image,ScaleCharToQuantum((unsigned char)\n                TIFFGetA(*p)),q);\n            p--;\n            q-=GetPixelChannels(image);\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        generic_info=RelinquishVirtualMemory(generic_info);\n        break;\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    SetQuantumImageType(image,quantum_type);\n  next_tiff_frame:\n    if (quantum_info != (QuantumInfo *) NULL)\n      quantum_info=DestroyQuantumInfo(quantum_info);\n    if (tiff_status == -1)\n      {\n        status=MagickFalse;\n        break;\n      }\n    if (photometric == PHOTOMETRIC_CIELAB)\n      DecodeLabImage(image,exception);\n    if ((photometric == PHOTOMETRIC_LOGL) ||\n        (photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      {\n        image->type=GrayscaleType;\n        if (bits_per_sample == 1)\n          image->type=BilevelType;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    more_frames=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n    if (more_frames != MagickFalse)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image,exception);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,image->scene-1,\n          image->scene);\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((status != MagickFalse) && (more_frames != MagickFalse));\n  TIFFClose(tiff);\n  if (status != MagickFalse)\n    TIFFReadPhotoshopLayers(image_info,image,exception);\n  if ((image_info->number_scenes != 0) &&\n      (image_info->scene >= GetImageListLength(image)))\n    status=MagickFalse;\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":8643,"total_token_length":8879,"max_tokens_setting":11000}
+{"idx":242663,"func":"proto_register_sysdig_event(void)\n{\n    \/* XXX Match up with Sysdig's names. *\/\n    static hf_register_info hf[] = {\n        { &hf_se_cpu_id,\n          { \"CPU ID\", \"sysdig.cpu_id\",\n            FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }\n        },\n        { &hf_se_thread_id,\n          { \"Thread ID\", \"sysdig.thread_id\",\n            FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL }\n        },\n        { &hf_se_event_length,\n          { \"Event length\", \"sysdig.event_len\",\n            FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }\n        },\n        { &hf_se_nparams,\n          { \"Number of parameters\", \"sysdig.nparams\",\n            FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }\n        },\n        { &hf_se_event_type,\n          { \"Event type\", \"sysdig.event_type\",\n            FT_UINT16, BASE_DEC, VALS(event_type_vals), 0, NULL, HFILL }\n        },\n        { &hf_se_param_lens,\n          { \"Parameter lengths\", \"sysdig.param.lens\",\n            FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }\n        },\n        { &hf_se_param_len,\n          { \"Parameter length\", \"sysdig.param.len\",\n            FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }\n        },\n\n\/* Header field registration. Automatically generated by tools\/generate-sysdig-event.py *\/\n        { &hf_param_ID_bytes, { \"ID\", \"sysdig.param.syscall.ID\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_action_uint32, { \"action\", \"sysdig.param.cpu_hotplug.action\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_addr_bytes, { \"addr\", \"sysdig.param.ptrace.addr\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_addr_uint64, { \"addr\", \"sysdig.param.page_fault.addr\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_args_string, { \"Program arguments\", \"sysdig.param.execve.args\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_argument_uint64, { \"I\/O control: argument\", \"sysdig.param.ioctl.argument\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_backlog_uint32, { \"backlog\", \"sysdig.param.listen.backlog\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cgroups_bytes, { \"cgroups\", \"sysdig.param.execve.cgroups\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_clockid_uint8, { \"clockid\", \"sysdig.param.timerfd_create.clockid\", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cmd_bytes, { \"cmd\", \"sysdig.param.semctl.cmd\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_cmd_int64, { \"cmd\", \"sysdig.param.bpf.cmd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_comm_string, { \"Command\", \"sysdig.param.execve.comm\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_core_uint8, { \"core\", \"sysdig.param.procexit.core\", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cpu_sys_uint64, { \"cpu_sys\", \"sysdig.param.procinfo.cpu_sys\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cpu_uint32, { \"cpu\", \"sysdig.param.cpu_hotplug.cpu\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cpu_usr_uint64, { \"cpu_usr\", \"sysdig.param.procinfo.cpu_usr\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cur_int64, { \"cur\", \"sysdig.param.setrlimit.cur\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_cwd_string, { \"Current working directory\", \"sysdig.param.execve.cwd\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_data_bytes, { \"data\", \"sysdig.param.ptrace.data\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_desc_string, { \"desc\", \"sysdig.param.notification.desc\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_description_string, { \"description\", \"sysdig.param.infra.description\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dev_string, { \"dev\", \"sysdig.param.mount.dev\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dev_uint32, { \"dev\", \"sysdig.param.openat.dev\", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_dir_string, { \"dir\", \"sysdig.param.mount.dir\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dirfd_int64, { \"dirfd\", \"sysdig.param.openat2.dirfd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_domain_bytes, { \"domain\", \"sysdig.param.socketpair.domain\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dpid_bytes, { \"dpid\", \"sysdig.param.signaldeliver.dpid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_bhardlimit_uint64, { \"dqb_bhardlimit\", \"sysdig.param.quotactl.dqb_bhardlimit\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_bsoftlimit_uint64, { \"dqb_bsoftlimit\", \"sysdig.param.quotactl.dqb_bsoftlimit\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_btime_bytes, { \"dqb_btime\", \"sysdig.param.quotactl.dqb_btime\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_curspace_uint64, { \"dqb_curspace\", \"sysdig.param.quotactl.dqb_curspace\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_ihardlimit_uint64, { \"dqb_ihardlimit\", \"sysdig.param.quotactl.dqb_ihardlimit\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_isoftlimit_uint64, { \"dqb_isoftlimit\", \"sysdig.param.quotactl.dqb_isoftlimit\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqb_itime_bytes, { \"dqb_itime\", \"sysdig.param.quotactl.dqb_itime\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqi_bgrace_bytes, { \"dqi_bgrace\", \"sysdig.param.quotactl.dqi_bgrace\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqi_flags_bytes, { \"dqi_flags\", \"sysdig.param.quotactl.dqi_flags\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_dqi_igrace_bytes, { \"dqi_igrace\", \"sysdig.param.quotactl.dqi_igrace\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_egid_bytes, { \"egid\", \"sysdig.param.getresgid.egid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_env_string, { \"env\", \"sysdig.param.execve.env\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_error_bytes, { \"error\", \"sysdig.param.page_fault.error\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_euid_bytes, { \"euid\", \"sysdig.param.getresuid.euid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_event_data_bytes, { \"event_data\", \"sysdig.param.pluginevent.event_data\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_event_data_uint64, { \"event_data\", \"sysdig.param.sysdigevent.event_data\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_event_type_uint32, { \"event_type\", \"sysdig.param.sysdigevent.event_type\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_exe_string, { \"exe\", \"sysdig.param.execve.exe\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_fd1_int64, { \"fd1\", \"sysdig.param.pipe.fd1\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fd2_int64, { \"fd2\", \"sysdig.param.pipe.fd2\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fd_in_int64, { \"fd_in\", \"sysdig.param.splice.fd_in\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fd_int64, { \"fd\", \"sysdig.param.openat2.fd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fd_out_int64, { \"fd_out\", \"sysdig.param.splice.fd_out\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fdlimit_int64, { \"fdlimit\", \"sysdig.param.vfork.fdlimit\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fdlimit_uint64, { \"fdlimit\", \"sysdig.param.execve.fdlimit\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_fds_bytes, { \"fds\", \"sysdig.param.ppoll.fds\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_filename_bytes, { \"filename\", \"sysdig.param.fchmodat.filename\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_filename_string, { \"filename\", \"sysdig.param.chmod.filename\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_flags_bytes, { \"flags\", \"sysdig.param.openat2.flags\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_flags_uint32, { \"flags\", \"sysdig.param.accept.flags\", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_gid_bytes, { \"gid\", \"sysdig.param.getgid.gid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_gid_uint32, { \"gid\", \"sysdig.param.vfork.gid\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_how_bytes, { \"how\", \"sysdig.param.shutdown.how\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_id_int64, { \"id\", \"sysdig.param.tracer.id\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_id_string, { \"id\", \"sysdig.param.notification.id\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_id_uint32, { \"id\", \"sysdig.param.quotactl.id\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_image_string, { \"image\", \"sysdig.param.container.image\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_in_fd_int64, { \"in_fd\", \"sysdig.param.sendfile.in_fd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_initval_uint64, { \"initval\", \"sysdig.param.eventfd.initval\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_ino_uint64, { \"ino\", \"sysdig.param.pipe.ino\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_interval_bytes, { \"interval\", \"sysdig.param.nanosleep.interval\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_ip_uint64, { \"ip\", \"sysdig.param.page_fault.ip\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_json_string, { \"json\", \"sysdig.param.container.json\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_key_int32, { \"key\", \"sysdig.param.semget.key\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_length_uint64, { \"length\", \"sysdig.param.munmap.length\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_level_bytes, { \"level\", \"sysdig.param.getsockopt.level\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_linkdirfd_int64, { \"linkdirfd\", \"sysdig.param.symlinkat.linkdirfd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_linkpath_bytes, { \"linkpath\", \"sysdig.param.symlinkat.linkpath\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_linkpath_string, { \"linkpath\", \"sysdig.param.symlink.linkpath\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_loginuid_int32, { \"loginuid\", \"sysdig.param.execve.loginuid\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_mask_uint32, { \"mask\", \"sysdig.param.signalfd.mask\", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_max_int64, { \"max\", \"sysdig.param.setrlimit.max\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_maxevents_bytes, { \"maxevents\", \"sysdig.param.epoll_wait.maxevents\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_mode_bytes, { \"mode\", \"sysdig.param.fchmod.mode\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_mode_uint32, { \"mode\", \"sysdig.param.openat2.mode\", FT_UINT32, BASE_OCT, NULL, 0, NULL, HFILL } },\n        { &hf_param_name_bytes, { \"name\", \"sysdig.param.openat2.name\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_name_string, { \"name\", \"sysdig.param.infra.name\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_nativeID_uint16, { \"nativeID\", \"sysdig.param.syscall.nativeID\", FT_UINT16, BASE_DEC, VALS(nativeID_uint16_vals), 0, NULL, HFILL } },\n        { &hf_param_newcur_int64, { \"newcur\", \"sysdig.param.prlimit.newcur\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_newdir_int64, { \"newdir\", \"sysdig.param.linkat.newdir\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_newdirfd_int64, { \"newdirfd\", \"sysdig.param.renameat2.newdirfd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_newmax_int64, { \"newmax\", \"sysdig.param.prlimit.newmax\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_newpath_bytes, { \"newpath\", \"sysdig.param.renameat2.newpath\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_newpath_string, { \"newpath\", \"sysdig.param.link.newpath\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_next_bytes, { \"next\", \"sysdig.param.switch.next\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_nsems_int32, { \"nsems\", \"sysdig.param.semget.nsems\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_nsops_uint32, { \"nsops\", \"sysdig.param.semop.nsops\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_nstype_bytes, { \"nstype\", \"sysdig.param.setns.nstype\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_offset_uint64, { \"offset\", \"sysdig.param.sendfile.offset\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_oldcur_int64, { \"oldcur\", \"sysdig.param.prlimit.oldcur\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_olddir_int64, { \"olddir\", \"sysdig.param.linkat.olddir\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_olddirfd_int64, { \"olddirfd\", \"sysdig.param.renameat2.olddirfd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_oldmax_int64, { \"oldmax\", \"sysdig.param.prlimit.oldmax\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_oldpath_bytes, { \"oldpath\", \"sysdig.param.renameat2.oldpath\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_oldpath_string, { \"oldpath\", \"sysdig.param.link.oldpath\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_op_bytes, { \"op\", \"sysdig.param.futex.op\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_op_uint64, { \"op\", \"sysdig.param.seccomp.op\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_operation_bytes, { \"operation\", \"sysdig.param.flock.operation\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_optlen_uint32, { \"optlen\", \"sysdig.param.getsockopt.optlen\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_optname_bytes, { \"optname\", \"sysdig.param.getsockopt.optname\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_out_fd_int64, { \"out_fd\", \"sysdig.param.sendfile.out_fd\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_path_bytes, { \"path\", \"sysdig.param.mkdirat.path\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_path_string, { \"path\", \"sysdig.param.unlink.path\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_peer_uint64, { \"peer\", \"sysdig.param.socketpair.peer\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_pgft_maj_uint64, { \"pgft_maj\", \"sysdig.param.execve.pgft_maj\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_pgft_min_uint64, { \"pgft_min\", \"sysdig.param.execve.pgft_min\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_pgid_bytes, { \"pgid\", \"sysdig.param.setpgid.pgid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_pgoffset_uint64, { \"pgoffset\", \"sysdig.param.mmap2.pgoffset\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_pid_bytes, { \"pid\", \"sysdig.param.setpgid.pid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_plugin_ID_uint32, { \"plugin_ID\", \"sysdig.param.pluginevent.plugin_ID\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_pos_uint64, { \"pos\", \"sysdig.param.pwritev.pos\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_prot_bytes, { \"prot\", \"sysdig.param.mmap2.prot\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_proto_uint32, { \"proto\", \"sysdig.param.socketpair.proto\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_ptid_bytes, { \"ptid\", \"sysdig.param.execve.ptid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_queuelen_uint32, { \"queuelen\", \"sysdig.param.accept.queuelen\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_queuemax_uint32, { \"queuemax\", \"sysdig.param.accept.queuemax\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_queuepct_uint8, { \"Accept queue per connection\", \"sysdig.param.accept.queuepct\", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_quota_fmt_bytes, { \"quota_fmt\", \"sysdig.param.quotactl.quota_fmt\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_quota_fmt_out_bytes, { \"quota_fmt_out\", \"sysdig.param.quotactl.quota_fmt_out\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_quotafilepath_string, { \"quotafilepath\", \"sysdig.param.quotactl.quotafilepath\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_ratio_uint32, { \"ratio\", \"sysdig.param.drop.ratio\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_request_bytes, { \"request\", \"sysdig.param.ptrace.request\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_request_uint64, { \"I\/O control: request\", \"sysdig.param.ioctl.request\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_res_bytes, { \"res\", \"sysdig.param.userfaultfd.res\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_res_int64, { \"res\", \"sysdig.param.fcntl.res\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_res_or_fd_bytes, { \"res_or_fd\", \"sysdig.param.bpf.res_or_fd\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_res_uint64, { \"res\", \"sysdig.param.mmap2.res\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_resolve_bytes, { \"resolve\", \"sysdig.param.openat2.resolve\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_resource_bytes, { \"resource\", \"sysdig.param.prlimit.resource\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_ret_bytes, { \"ret\", \"sysdig.param.procexit.ret\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_rgid_bytes, { \"rgid\", \"sysdig.param.getresgid.rgid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_ruid_bytes, { \"ruid\", \"sysdig.param.getresuid.ruid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_scope_string, { \"scope\", \"sysdig.param.infra.scope\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_sem_flg_0_bytes, { \"sem_flg_0\", \"sysdig.param.semop.sem_flg_0\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_sem_flg_1_bytes, { \"sem_flg_1\", \"sysdig.param.semop.sem_flg_1\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_sem_num_0_uint16, { \"sem_num_0\", \"sysdig.param.semop.sem_num_0\", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_sem_num_1_uint16, { \"sem_num_1\", \"sysdig.param.semop.sem_num_1\", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_sem_op_0_int16, { \"sem_op_0\", \"sysdig.param.semop.sem_op_0\", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_sem_op_1_int16, { \"sem_op_1\", \"sysdig.param.semop.sem_op_1\", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_semflg_bytes, { \"semflg\", \"sysdig.param.semget.semflg\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_semid_int32, { \"semid\", \"sysdig.param.semctl.semid\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_semnum_int32, { \"semnum\", \"sysdig.param.semctl.semnum\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_sgid_bytes, { \"sgid\", \"sysdig.param.getresgid.sgid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_sig_bytes, { \"sig\", \"sysdig.param.signaldeliver.sig\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_sigmask_bytes, { \"sigmask\", \"sysdig.param.ppoll.sigmask\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_size_uint32, { \"size\", \"sysdig.param.pwritev.size\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_size_uint64, { \"size\", \"sysdig.param.sendfile.size\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_source_string, { \"source\", \"sysdig.param.infra.source\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_source_uint64, { \"source\", \"sysdig.param.socketpair.source\", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },\n        { &hf_param_special_string, { \"special\", \"sysdig.param.quotactl.special\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_spid_bytes, { \"spid\", \"sysdig.param.signaldeliver.spid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_status_bytes, { \"status\", \"sysdig.param.procexit.status\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_suid_bytes, { \"suid\", \"sysdig.param.getresuid.suid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_tags_bytes, { \"tags\", \"sysdig.param.tracer.tags\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_target_string, { \"target\", \"sysdig.param.symlinkat.target\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_tid_bytes, { \"tid\", \"sysdig.param.execve.tid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_timeout_bytes, { \"timeout\", \"sysdig.param.ppoll.timeout\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_timeout_int64, { \"timeout\", \"sysdig.param.poll.timeout\", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_tty_int32, { \"tty\", \"sysdig.param.execve.tty\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_tuple_bytes, { \"tuple\", \"sysdig.param.accept.tuple\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_type_bytes, { \"type\", \"sysdig.param.quotactl.type\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_type_string, { \"type\", \"sysdig.param.mount.type\", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_type_uint32, { \"type\", \"sysdig.param.container.type\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_uid_bytes, { \"uid\", \"sysdig.param.getuid.uid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_uid_uint32, { \"uid\", \"sysdig.param.vfork.uid\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_val_bytes, { \"val\", \"sysdig.param.getsockopt.val\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_val_int32, { \"val\", \"sysdig.param.semctl.val\", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_val_uint64, { \"val\", \"sysdig.param.futex.val\", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_vm_rss_uint32, { \"vm_rss\", \"sysdig.param.execve.vm_rss\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_vm_size_uint32, { \"vm_size\", \"sysdig.param.execve.vm_size\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_vm_swap_uint32, { \"vm_swap\", \"sysdig.param.execve.vm_swap\", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },\n        { &hf_param_vpid_bytes, { \"vpid\", \"sysdig.param.vfork.vpid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_vtid_bytes, { \"vtid\", \"sysdig.param.vfork.vtid\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n        { &hf_param_whence_bytes, { \"whence\", \"sysdig.param.llseek.whence\", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },\n    };\n\n    \/* Setup protocol subtree array *\/\n    static gint *ett[] = {\n        &ett_sysdig_event,\n        &ett_sysdig_parm_lens,\n        &ett_sysdig_syscall\n    };\n\n    \/* Register the protocol name and description *\/\n    proto_sysdig_event = proto_register_protocol(\"Sysdig System Call\",\n            \"Sysdig Event\", \"sysdig\");\n\n    \/* Required function calls to register the header fields and subtrees *\/\n    proto_register_field_array(proto_sysdig_event, hf, array_length(hf));\n    proto_register_subtree_array(ett, array_length(ett));\n\n    register_dissector(\"sysdig\", dissect_sysdig_event, proto_sysdig_event);\n}","target":0,"code_token_length":8057,"total_token_length":8293,"max_tokens_setting":11000}
+{"idx":442779,"func":"operate(struct Configurable *config, int argc, argv_item_t argv[])\n{\n  char errorbuffer[CURL_ERROR_SIZE];\n  char useragent[128]; \/* buah, we don't want a larger default user agent *\/\n  struct ProgressData progressbar;\n  struct getout *urlnode;\n  struct getout *nextnode;\n\n  struct OutStruct outs;\n  struct OutStruct heads;\n  struct InStruct input;\n\n  URLGlob *urls=NULL;\n  URLGlob *inglob=NULL;\n  int urlnum;\n  int infilenum;\n  char *uploadfile=NULL; \/* a single file, never a glob *\/\n\n  FILE *infd = stdin;\n  bool infdfopen;\n  FILE *headerfilep = NULL;\n  curl_off_t uploadfilesize; \/* -1 means unknown *\/\n  bool stillflags=TRUE;\n\n  bool allocuseragent=FALSE;\n\n  char *httpgetfields=NULL;\n\n  CURL *curl;\n  int res = 0;\n  int i;\n  long retry_sleep_default;\n  long retry_sleep;\n\n  char *env;\n#ifdef CURLDEBUG\n  \/* this sends all memory debug messages to a logfile named memdump *\/\n  env = curlx_getenv(\"CURL_MEMDEBUG\");\n  if(env) {\n    \/* use the value as file name *\/\n    char *s = strdup(env);\n    curl_free(env);\n    curl_memdebug(s);\n    free(s);\n    \/* this weird strdup() and stuff here is to make the curl_free() get\n       called before the memdebug() as otherwise the memdebug tracing will\n       with tracing a free() without an alloc! *\/\n  }\n  env = curlx_getenv(\"CURL_MEMLIMIT\");\n  if(env) {\n    curl_memlimit(atoi(env));\n    curl_free(env);\n  }\n#endif\n\n  memset(&outs,0,sizeof(outs));\n\n  config->outs = &outs;\n\n  \/* we get libcurl info right away *\/\n  curlinfo = curl_version_info(CURLVERSION_NOW);\n\n  errorbuffer[0]=0; \/* prevent junk from being output *\/\n\n  \/* setup proper locale from environment *\/\n#ifdef HAVE_SETLOCALE\n  setlocale(LC_ALL, \"\");\n#endif\n\n  \/* inits *\/\n  if (main_init() != CURLE_OK) {\n    helpf(\"error initializing curl library\\n\");\n    return CURLE_FAILED_INIT;\n  }\n  config->postfieldsize = -1;\n  config->showerror=TRUE;\n  config->conf=CONF_DEFAULT;\n  config->use_httpget=FALSE;\n  config->create_dirs=FALSE;\n  config->lastrecvtime = cutil_tvnow();\n  config->lastsendtime = cutil_tvnow();\n  config->maxredirs = DEFAULT_MAXREDIRS;\n\n  if(argc>1 &&\n     (!curlx_strnequal(\"--\", argv[1], 2) && (argv[1][0] == '-')) &&\n     strchr(argv[1], 'q')) {\n    \/*\n     * The first flag, that is not a verbose name, but a shortname\n     * and it includes the 'q' flag!\n     *\/\n    ;\n  }\n  else {\n    parseconfig(NULL, config); \/* ignore possible failure *\/\n  }\n\n  if ((argc < 2)  && !config->url_list) {\n    helpf(NULL);\n    return CURLE_FAILED_INIT;\n  }\n\n  \/* Parse options *\/\n  for (i = 1; i < argc; i++) {\n    if(stillflags &&\n       ('-' == argv[i][0])) {\n      char *nextarg;\n      bool passarg;\n      char *origopt=argv[i];\n\n      char *flag = argv[i];\n\n      if(curlx_strequal(\"--\", argv[i]))\n        \/* this indicates the end of the flags and thus enables the\n           following (URL) argument to start with -. *\/\n        stillflags=FALSE;\n      else {\n        nextarg= (i < argc - 1)? argv[i+1]: NULL;\n\n        res = getparameter(flag, nextarg, &passarg, config);\n        if(res) {\n          const char *reason = param2text(res);\n          if(res != PARAM_HELP_REQUESTED)\n            helpf(\"option %s: %s\\n\", origopt, reason);\n          clean_getout(config);\n          return CURLE_FAILED_INIT;\n        }\n\n        if(passarg) \/* we're supposed to skip this *\/\n          i++;\n      }\n    }\n    else {\n      bool used;\n      \/* just add the URL please *\/\n      res = getparameter((char *)\"--url\", argv[i], &used, config);\n      if(res)\n        return res;\n    }\n  }\n\n  retry_sleep_default = config->retry_delay?\n    config->retry_delay*1000:RETRY_SLEEP_DEFAULT; \/* ms *\/\n  retry_sleep = retry_sleep_default;\n\n  if((!config->url_list || !config->url_list->url) && !config->list_engines) {\n    clean_getout(config);\n    helpf(\"no URL specified!\\n\");\n    return CURLE_FAILED_INIT;\n  }\n  if(NULL == config->useragent) {\n    \/* set non-zero default values: *\/\n    snprintf(useragent, sizeof(useragent),\n             CURL_NAME \"\/\" CURL_VERSION \" (\" OS \") \" \"%s\", curl_version());\n    config->useragent= useragent;\n  }\n  else\n    allocuseragent = TRUE;\n\n  \/* On WIN32 we can't set the path to curl-ca-bundle.crt\n   * at compile time. So we look here for the file in two ways:\n   * 1: look at the environment variable CURL_CA_BUNDLE for a path\n   * 2: if #1 isn't found, use the windows API function SearchPath()\n   *    to find it along the app's path (includes app's dir and CWD)\n   *\n   * We support the environment variable thing for non-Windows platforms\n   * too. Just for the sake of it.\n   *\/\n  if (!config->cacert &&\n      !config->capath &&\n      !config->insecure_ok) {\n    env = curlx_getenv(\"CURL_CA_BUNDLE\");\n    if(env)\n      GetStr(&config->cacert, env);\n    else {\n      env = curlx_getenv(\"SSL_CERT_DIR\");\n      if(env)\n        GetStr(&config->capath, env);\n      else {\n        env = curlx_getenv(\"SSL_CERT_FILE\");\n        if(env)\n          GetStr(&config->cacert, env);\n      }\n    }\n\n    if(env)\n      curl_free(env);\n#ifdef WIN32\n    else\n      FindWin32CACert(config, \"curl-ca-bundle.crt\");\n#endif\n  }\n\n  if (config->postfields) {\n    if (config->use_httpget) {\n      \/* Use the postfields data for a http get *\/\n      httpgetfields = strdup(config->postfields);\n      free(config->postfields);\n      config->postfields = NULL;\n      if(SetHTTPrequest(config,\n                        (config->conf&CONF_NOBODY?HTTPREQ_HEAD:HTTPREQ_GET),\n                        &config->httpreq)) {\n        free(httpgetfields);\n        return PARAM_BAD_USE;\n      }\n    }\n    else {\n      if(SetHTTPrequest(config, HTTPREQ_SIMPLEPOST, &config->httpreq))\n        return PARAM_BAD_USE;\n    }\n  }\n\n  \/*\n   * Get a curl handle to use for all forthcoming curl transfers.  Cleanup\n   * when all transfers are done.\n   *\/\n  curl = curl_easy_init();\n  if(!curl) {\n    clean_getout(config);\n    return CURLE_FAILED_INIT;\n  }\n\n  \/* This is the first entry added to easycode and it initializes the slist *\/\n  easycode = curl_slist_append(easycode, \"CURL *hnd = curl_easy_init();\");\n  if(!easycode) {\n    clean_getout(config);\n    res = CURLE_OUT_OF_MEMORY;\n    goto quit_curl;\n  }\n\n  if (config->list_engines) {\n    struct curl_slist *engines = NULL;\n\n    curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);\n    list_engines(engines);\n    curl_slist_free_all(engines);\n    res = CURLE_OK;\n    goto quit_curl;\n  }\n\n  \/* After this point, we should call curl_easy_cleanup() if we decide to bail\n   * out from this function! *\/\n\n  urlnode = config->url_list;\n\n  if(config->headerfile) {\n    \/* open file for output: *\/\n    if(strcmp(config->headerfile,\"-\")) {\n      heads.filename = config->headerfile;\n      headerfilep=NULL;\n    }\n    else\n      headerfilep=stdout;\n    heads.stream = headerfilep;\n    heads.config = config;\n  }\n\n  \/* loop through the list of given URLs *\/\n  while(urlnode) {\n    int up; \/* upload file counter within a single upload glob *\/\n    char *dourl;\n    char *url;\n    char *infiles; \/* might be a glob pattern *\/\n    char *outfiles=NULL;\n\n    \/* get the full URL (it might be NULL) *\/\n    dourl=urlnode->url;\n\n    url = dourl;\n\n    if(NULL == url) {\n      \/* This node had no URL, skip it and continue to the next *\/\n      if(urlnode->outfile)\n        free(urlnode->outfile);\n\n      \/* move on to the next URL *\/\n      nextnode=urlnode->next;\n      free(urlnode); \/* free the node *\/\n      urlnode = nextnode;\n      continue; \/* next please *\/\n    }\n\n    \/* default output stream is stdout *\/\n    outs.stream = stdout;\n    outs.config = config;\n    outs.bytes = 0; \/* nothing written yet *\/\n\n    \/* save outfile pattern before expansion *\/\n    if (urlnode->outfile) {\n      outfiles = strdup(urlnode->outfile);\n      if (!outfiles) {\n        clean_getout(config);\n        break;\n      }\n    } \n\n    infiles = urlnode->infile;\n\n    if(!config->globoff && infiles) {\n      \/* Unless explicitly shut off *\/\n      res = glob_url(&inglob, infiles, &infilenum,\n                     config->showerror?\n                     (config->errors?config->errors:stderr):NULL);\n      if(res != CURLE_OK) {\n        clean_getout(config);\n        if(outfiles)\n          free(outfiles);\n        break;\n      }\n    }\n\n    \/* Here's the loop for uploading multiple files within the same\n       single globbed string. If no upload, we enter the loop once anyway. *\/\n    for(up = 0;\n        (!up && !infiles) ||\n          (uploadfile = inglob?\n           glob_next_url(inglob):\n           (!up?strdup(infiles):NULL));\n        up++) {\n      int separator = 0;\n      long retry_numretries;\n      uploadfilesize=-1;\n\n      if(!config->globoff) {\n        \/* Unless explicitly shut off, we expand '{...}' and '[...]'\n           expressions and return total number of URLs in pattern set *\/\n        res = glob_url(&urls, dourl, &urlnum,\n                       config->showerror?\n                       (config->errors?config->errors:stderr):NULL);\n        if(res != CURLE_OK) {\n          break;\n        }\n      }\n      else\n        urlnum = 1; \/* without globbing, this is a single URL *\/\n\n      \/* if multiple files extracted to stdout, insert separators! *\/\n      separator= ((!outfiles || curlx_strequal(outfiles, \"-\")) && urlnum > 1);\n\n      \/* Here's looping around each globbed URL *\/\n      for(i = 0;\n          (url = urls?glob_next_url(urls):(i?NULL:strdup(url)));\n          i++) {\n        char *outfile;\n        struct timeval retrystart;\n        outfile = outfiles?strdup(outfiles):NULL;\n\n        if((urlnode->flags&GETOUT_USEREMOTE) ||\n           (outfile && !curlx_strequal(\"-\", outfile)) ) {\n\n          \/*\n           * We have specified a file name to store the result in, or we have\n           * decided we want to use the remote file name.\n           *\/\n\n          if(!outfile) {\n            \/* Find and get the remote file name *\/\n            char * pc =strstr(url, \":\/\/\");\n            if(pc)\n              pc+=3;\n            else\n              pc=url;\n            pc = strrchr(pc, '\/');\n\n            if(pc) {\n              \/* duplicate the string beyond the slash *\/\n              pc++;\n              outfile = *pc ? strdup(pc): NULL;\n            }\n            if(!outfile || !*outfile) {\n              helpf(\"Remote file name has no length!\\n\");\n              res = CURLE_WRITE_ERROR;\n              free(url);\n              break;\n            }\n#if defined(MSDOS)\n            {\n              \/* This is for DOS, and then we do some major replacing of\n                 bad characters in the file name before using it *\/\n              char file1 [PATH_MAX];\n\n              strcpy(file1, msdosify(outfile));\n              free (outfile);\n              outfile = strdup (rename_if_dos_device_name(file1));\n            }\n#endif \/* MSDOS *\/\n          }\n          else if(urls) {\n            \/* fill '#1' ... '#9' terms from URL pattern *\/\n            char *storefile = outfile;\n            outfile = glob_match_url(storefile, urls);\n            free(storefile);\n            if(!outfile) {\n              \/* bad globbing *\/\n              warnf(config, \"bad output glob!\\n\");\n              free(url);\n              res = CURLE_FAILED_INIT;\n              break;\n            }\n          }\n\n          \/* Create the directory hierarchy, if not pre-existant to a multiple\n             file output call *\/\n\n          if(config->create_dirs &&\n             (-1 == create_dir_hierarchy(outfile)))\n            return CURLE_WRITE_ERROR;\n\n          if(config->resume_from_current) {\n            \/* We're told to continue from where we are now. Get the\n               size of the file as it is now and open it for append instead *\/\n\n            struct_stat fileinfo;\n\n            \/* VMS -- Danger, the filesize is only valid for stream files *\/\n            if(0 == stat(outfile, &fileinfo))\n              \/* set offset to current file size: *\/\n              config->resume_from = fileinfo.st_size;\n            else\n              \/* let offset be 0 *\/\n              config->resume_from = 0;\n          }\n\n          outs.filename = outfile;\n\n          if(config->resume_from) {\n            outs.init = config->resume_from;\n            \/* open file for output: *\/\n            outs.stream=(FILE *) fopen(outfile, config->resume_from?\"ab\":\"wb\");\n            if (!outs.stream) {\n              helpf(\"Can't open '%s'!\\n\", outfile);\n              return CURLE_WRITE_ERROR;\n            }\n          }\n          else {\n            outs.stream = NULL; \/* open when needed *\/\n          }\n        }\n        infdfopen=FALSE;\n        if(uploadfile && !curlx_strequal(uploadfile, \"-\")) {\n          \/*\n           * We have specified a file to upload and it isn't \"-\".\n           *\/\n          struct_stat fileinfo;\n\n          \/* If no file name part is given in the URL, we add this file name *\/\n          char *ptr=strstr(url, \":\/\/\");\n          if(ptr)\n            ptr+=3;\n          else\n            ptr=url;\n          ptr = strrchr(ptr, '\/');\n          if(!ptr || !strlen(++ptr)) {\n            \/* The URL has no file name part, add the local file name. In order\n               to be able to do so, we have to create a new URL in another\n               buffer.*\/\n\n            \/* We only want the part of the local path that is on the right\n               side of the rightmost slash and backslash. *\/\n            char *filep = strrchr(uploadfile, '\/');\n            char *file2 = strrchr(filep?filep:uploadfile, '\\\\');\n\n            if(file2)\n              filep = file2+1;\n            else if(filep)\n              filep++;\n            else\n              filep = uploadfile;\n\n            \/* URL encode the file name *\/\n            filep = curl_easy_escape(curl, filep, 0 \/* use strlen *\/);\n\n            if(filep) {\n              char *urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);\n              if(!urlbuffer) {\n                helpf(\"out of memory\\n\");\n                return CURLE_OUT_OF_MEMORY;\n              }\n              if(ptr)\n                \/* there is a trailing slash on the URL *\/\n                sprintf(urlbuffer, \"%s%s\", url, filep);\n              else\n                \/* thers is no trailing slash on the URL *\/\n                sprintf(urlbuffer, \"%s\/%s\", url, filep);\n\n              curl_free(filep);\n\n              free(url);\n              url = urlbuffer; \/* use our new URL instead! *\/\n            }\n          }\n          \/* VMS Note:\n           *\n           * Reading binary from files can be a problem...  Only FIXED, VAR\n           * etc WITHOUT implied CC will work Others need a \\n appended to a\n           * line\n           *\n           * - Stat gives a size but this is UNRELIABLE in VMS As a f.e. a\n           * fixed file with implied CC needs to have a byte added for every\n           * record processed, this can by derived from Filesize & recordsize\n           * for VARiable record files the records need to be counted!  for\n           * every record add 1 for linefeed and subtract 2 for the record\n           * header for VARIABLE header files only the bare record data needs\n           * to be considered with one appended if implied CC\n           *\/\n\n          infd=(FILE *) fopen(uploadfile, \"rb\");\n          if (!infd || stat(uploadfile, &fileinfo)) {\n            helpf(\"Can't open '%s'!\\n\", uploadfile);\n            if(infd)\n              fclose(infd);\n            return CURLE_READ_ERROR;\n          }\n          infdfopen=TRUE;\n          uploadfilesize=fileinfo.st_size;\n\n        }\n        else if(uploadfile && curlx_strequal(uploadfile, \"-\")) {\n          SET_BINMODE(stdin);\n          infd = stdin;\n        }\n\n        if(uploadfile && config->resume_from_current)\n          config->resume_from = -1; \/* -1 will then force get-it-yourself *\/\n\n        if(output_expected(url, uploadfile)\n           && outs.stream && isatty(fileno(outs.stream)))\n          \/* we send the output to a tty, therefore we switch off the progress\n             meter *\/\n          config->conf |= CONF_NOPROGRESS|CONF_ISATTY;\n\n        if (urlnum > 1 && !(config->conf&CONF_MUTE)) {\n          fprintf(stderr, \"\\n[%d\/%d]: %s --> %s\\n\",\n                  i+1, urlnum, url, outfile ? outfile : \"<stdout>\");\n          if (separator)\n            printf(\"%s%s\\n\", CURLseparator, url);\n        }\n        if (httpgetfields) {\n          char *urlbuffer;\n          \/* Find out whether the url contains a file name *\/\n          const char *pc =strstr(url, \":\/\/\");\n          char sep='?';\n          if(pc)\n            pc+=3;\n          else\n            pc=url;\n\n          pc = strrchr(pc, '\/'); \/* check for a slash *\/\n\n          if(pc) {\n            \/* there is a slash present in the URL *\/\n\n            if(strchr(pc, '?'))\n              \/* Ouch, there's already a question mark in the URL string, we\n                 then append the data with an ampersand separator instead! *\/\n              sep='&';\n          }\n          \/*\n           * Then append ? followed by the get fields to the url.\n           *\/\n          urlbuffer=(char *)malloc(strlen(url) + strlen(httpgetfields) + 3);\n          if(!urlbuffer) {\n            helpf(\"out of memory\\n\");\n            return CURLE_OUT_OF_MEMORY;\n          }\n          if (pc)\n            sprintf(urlbuffer, \"%s%c%s\", url, sep, httpgetfields);\n          else\n            \/* Append  \/ before the ? to create a well-formed url\n               if the url contains a hostname only\n            *\/\n            sprintf(urlbuffer, \"%s\/?%s\", url, httpgetfields);\n\n          free(url); \/* free previous URL *\/\n          url = urlbuffer; \/* use our new URL instead! *\/\n        }\n\n        if(!config->errors)\n          config->errors = stderr;\n\n        if(!outfile && !(config->conf & CONF_GETTEXT)) {\n          \/* We get the output to stdout and we have not got the ASCII\/text flag,\n             then set stdout to be binary *\/\n          SET_BINMODE(stdout);\n        }\n\n        if(1 == config->tcp_nodelay)\n          my_setopt(curl, CURLOPT_TCP_NODELAY, 1);\n\n        \/* where to store *\/\n        my_setopt(curl, CURLOPT_WRITEDATA, (FILE *)&outs);\n        \/* what call to write *\/\n        my_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);\n\n        \/* for uploads *\/\n        input.stream = infd;\n        input.config = config;\n        my_setopt(curl, CURLOPT_READDATA, &input);\n        \/* what call to read *\/\n        my_setopt(curl, CURLOPT_READFUNCTION, my_fread);\n\n        \/* libcurl 7.12.3 business: *\/\n        my_setopt(curl, CURLOPT_IOCTLDATA, &input);\n        my_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl);\n\n        if(config->recvpersecond)\n          \/* tell libcurl to use a smaller sized buffer as it allows us to\n             make better sleeps! 7.9.9 stuff! *\/\n          my_setopt(curl, CURLOPT_BUFFERSIZE, config->recvpersecond);\n\n        \/* size of uploaded file: *\/\n        my_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadfilesize);\n        my_setopt(curl, CURLOPT_URL, url);     \/* what to fetch *\/\n        my_setopt(curl, CURLOPT_PROXY, config->proxy); \/* proxy to use *\/\n        my_setopt(curl, CURLOPT_HEADER, config->conf&CONF_HEADER);\n        my_setopt(curl, CURLOPT_NOPROGRESS, config->conf&CONF_NOPROGRESS);\n        my_setopt(curl, CURLOPT_NOBODY, config->conf&CONF_NOBODY);\n        my_setopt(curl, CURLOPT_FAILONERROR,\n                  config->conf&CONF_FAILONERROR);\n        my_setopt(curl, CURLOPT_UPLOAD, uploadfile?TRUE:FALSE);\n        my_setopt(curl, CURLOPT_FTPLISTONLY,\n                  config->conf&CONF_FTPLISTONLY);\n        my_setopt(curl, CURLOPT_FTPAPPEND, config->conf&CONF_FTPAPPEND);\n\n        if (config->conf&CONF_NETRC_OPT)\n          my_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n        else if (config->conf&CONF_NETRC)\n          my_setopt(curl, CURLOPT_NETRC, CURL_NETRC_REQUIRED);\n        else\n          my_setopt(curl, CURLOPT_NETRC, CURL_NETRC_IGNORED);\n\n        my_setopt(curl, CURLOPT_FOLLOWLOCATION,\n                  config->conf&CONF_FOLLOWLOCATION);\n        my_setopt(curl, CURLOPT_UNRESTRICTED_AUTH,\n                  config->conf&CONF_UNRESTRICTED_AUTH);\n        my_setopt(curl, CURLOPT_TRANSFERTEXT, config->conf&CONF_GETTEXT);\n        my_setopt(curl, CURLOPT_USERPWD, config->userpwd);\n        my_setopt(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);\n        my_setopt(curl, CURLOPT_RANGE, config->range);\n        my_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer);\n        my_setopt(curl, CURLOPT_TIMEOUT, config->timeout);\n\n        switch(config->httpreq) {\n        case HTTPREQ_SIMPLEPOST:\n          my_setopt(curl, CURLOPT_POSTFIELDS, config->postfields);\n          my_setopt(curl, CURLOPT_POSTFIELDSIZE, config->postfieldsize);\n          break;\n        case HTTPREQ_POST:\n          my_setopt(curl, CURLOPT_HTTPPOST, config->httppost);\n          break;\n        default:\n          break;\n        }\n        my_setopt(curl, CURLOPT_REFERER, config->referer);\n        my_setopt(curl, CURLOPT_AUTOREFERER,\n                  config->conf&CONF_AUTO_REFERER);\n        my_setopt(curl, CURLOPT_USERAGENT, config->useragent);\n        my_setopt(curl, CURLOPT_FTPPORT, config->ftpport);\n        my_setopt(curl, CURLOPT_LOW_SPEED_LIMIT,\n                  config->low_speed_limit);\n        my_setopt(curl, CURLOPT_LOW_SPEED_TIME, config->low_speed_time);\n        my_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE,\n                  config->sendpersecond);\n        my_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE,\n                  config->recvpersecond);\n        my_setopt(curl, CURLOPT_RESUME_FROM_LARGE,\n                  config->use_resume?config->resume_from:0);\n        my_setopt(curl, CURLOPT_COOKIE, config->cookie);\n        my_setopt(curl, CURLOPT_HTTPHEADER, config->headers);\n        my_setopt(curl, CURLOPT_SSLCERT, config->cert);\n        my_setopt(curl, CURLOPT_SSLCERTTYPE, config->cert_type);\n        my_setopt(curl, CURLOPT_SSLKEY, config->key);\n        my_setopt(curl, CURLOPT_SSLKEYTYPE, config->key_type);\n        my_setopt(curl, CURLOPT_SSLKEYPASSWD, config->key_passwd);\n\n\t\/* SSH private key uses the same command-line option as SSL private key *\/\n        my_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, config->key);\n        my_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, config->pubkey);\n\n        \/* default to strict verifyhost *\/\n        my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);\n        if(config->cacert || config->capath) {\n          if (config->cacert)\n            my_setopt(curl, CURLOPT_CAINFO, config->cacert);\n\n          if (config->capath)\n            my_setopt(curl, CURLOPT_CAPATH, config->capath);\n          my_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);\n        }\n        if(config->insecure_ok) {\n          \/* new stuff needed for libcurl 7.10 *\/\n          my_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);\n          my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1);\n        }\n\n        if((config->conf&CONF_NOBODY) ||\n           config->remote_time) {\n          \/* no body or use remote time *\/\n          my_setopt(curl, CURLOPT_FILETIME, TRUE);\n        }\n\n        my_setopt(curl, CURLOPT_MAXREDIRS, config->maxredirs);\n        my_setopt(curl, CURLOPT_CRLF, config->crlf);\n        my_setopt(curl, CURLOPT_QUOTE, config->quote);\n        my_setopt(curl, CURLOPT_POSTQUOTE, config->postquote);\n        my_setopt(curl, CURLOPT_PREQUOTE, config->prequote);\n        my_setopt(curl, CURLOPT_WRITEHEADER,\n                  config->headerfile?&heads:NULL);\n        my_setopt(curl, CURLOPT_COOKIEFILE, config->cookiefile);\n        \/* cookie jar was added in 7.9 *\/\n        if(config->cookiejar)\n          my_setopt(curl, CURLOPT_COOKIEJAR, config->cookiejar);\n        \/* cookie session added in 7.9.7 *\/\n        my_setopt(curl, CURLOPT_COOKIESESSION, config->cookiesession);\n\n        my_setopt(curl, CURLOPT_SSLVERSION, config->ssl_version);\n        my_setopt(curl, CURLOPT_TIMECONDITION, config->timecond);\n        my_setopt(curl, CURLOPT_TIMEVALUE, config->condtime);\n        my_setopt(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);\n        my_setopt(curl, CURLOPT_STDERR, config->errors);\n\n        \/* three new ones in libcurl 7.3: *\/\n        my_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config->proxytunnel);\n        my_setopt(curl, CURLOPT_INTERFACE, config->iface);\n        my_setopt(curl, CURLOPT_KRB4LEVEL, config->krb4level);\n\n        progressbarinit(&progressbar, config);\n        if((config->progressmode == CURL_PROGRESS_BAR) &&\n           !(config->conf&(CONF_NOPROGRESS|CONF_MUTE))) {\n          \/* we want the alternative style, then we have to implement it\n             ourselves! *\/\n          my_setopt(curl, CURLOPT_PROGRESSFUNCTION, myprogress);\n          my_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);\n        }\n\n        \/* new in libcurl 7.6.2: *\/\n        my_setopt(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);\n\n        \/* new in libcurl 7.7: *\/\n        my_setopt(curl, CURLOPT_RANDOM_FILE, config->random_file);\n        my_setopt(curl, CURLOPT_EGDSOCKET, config->egd_file);\n        my_setopt(curl, CURLOPT_CONNECTTIMEOUT, config->connecttimeout);\n\n        if(config->cipher_list)\n          my_setopt(curl, CURLOPT_SSL_CIPHER_LIST, config->cipher_list);\n\n        if(config->httpversion)\n          my_setopt(curl, CURLOPT_HTTP_VERSION, config->httpversion);\n\n        \/* new in libcurl 7.9.2: *\/\n        if(config->disable_epsv)\n          \/* disable it *\/\n          my_setopt(curl, CURLOPT_FTP_USE_EPSV, FALSE);\n\n        \/* new in libcurl 7.10.5 *\/\n        if(config->disable_eprt)\n          \/* disable it *\/\n          my_setopt(curl, CURLOPT_FTP_USE_EPRT, FALSE);\n\n        \/* new in libcurl 7.10.6 (default is Basic) *\/\n        if(config->authtype)\n          my_setopt(curl, CURLOPT_HTTPAUTH, config->authtype);\n\n        \/* new in curl 7.9.7 *\/\n        if(config->trace_dump) {\n          my_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);\n          my_setopt(curl, CURLOPT_DEBUGDATA, config);\n          my_setopt(curl, CURLOPT_VERBOSE, TRUE);\n        }\n\n        res = CURLE_OK;\n\n        \/* new in curl ?? *\/\n        if (config->engine) {\n          res = my_setopt(curl, CURLOPT_SSLENGINE, config->engine);\n          my_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1);\n        }\n\n        if (res != CURLE_OK)\n           goto show_error;\n\n        \/* new in curl 7.10 *\/\n        my_setopt(curl, CURLOPT_ENCODING,\n                         (config->encoding) ? \"\" : NULL);\n\n        \/* new in curl 7.10.7 *\/\n        my_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,\n                         config->ftp_create_dirs);\n        if(config->proxyanyauth)\n          my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);\n        else if(config->proxyntlm)\n          my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);\n        else if(config->proxydigest)\n          my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);\n        else if(config->proxybasic)\n          my_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);\n\n        \/* new in curl 7.10.8 *\/\n        if(config->max_filesize)\n          my_setopt(curl, CURLOPT_MAXFILESIZE_LARGE,\n                           config->max_filesize);\n\n        if(4 == config->ip_version)\n          my_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);\n        else if(6 == config->ip_version)\n          my_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);\n        else\n          my_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);\n\n        \/* new in curl 7.15.5 *\/\n        if(config->ftp_ssl_reqd)\n          my_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_ALL);\n\n        \/* new in curl 7.11.0 *\/\n        else if(config->ftp_ssl)\n          my_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_TRY);\n\n        \/* new in curl 7.16.0 *\/\n        else if(config->ftp_ssl_control)\n          my_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_CONTROL);\n\n        \/* new in curl 7.16.1 *\/\n        if(config->ftp_ssl_ccc)\n            my_setopt(curl, CURLOPT_FTP_SSL_CCC, config->ftp_ssl_ccc_mode);\n\n        \/* new in curl 7.11.1, modified in 7.15.2 *\/\n        if(config->socksproxy) {\n          my_setopt(curl, CURLOPT_PROXY, config->socksproxy);\n          my_setopt(curl, CURLOPT_PROXYTYPE, config->socksver);\n        }\n\n        \/* curl 7.13.0 *\/\n        my_setopt(curl, CURLOPT_FTP_ACCOUNT, config->ftp_account);\n\n        my_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, config->ignorecl);\n\n        \/* curl 7.14.2 *\/\n        my_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, config->ftp_skip_ip);\n\n        \/* curl 7.15.1 *\/\n        my_setopt(curl, CURLOPT_FTP_FILEMETHOD, config->ftp_filemethod);\n\n        \/* curl 7.15.2 *\/\n        if(config->localport) {\n          my_setopt(curl, CURLOPT_LOCALPORT, config->localport);\n          my_setopt(curl, CURLOPT_LOCALPORTRANGE,\n                    config->localportrange);\n        }\n\n        \/* curl 7.15.5 *\/\n        my_setopt(curl, CURLOPT_FTP_ALTERNATIVE_TO_USER,\n                  config->ftp_alternative_to_user);\n\n        \/* curl 7.16.0 *\/\n        my_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE,\n                  !config->disable_sessionid);\n\n        \/* curl 7.16.2 *\/\n        if(config->raw) {\n          my_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, FALSE);\n          my_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, FALSE);\n        }\n\n        retry_numretries = config->req_retry;\n\n        retrystart = cutil_tvnow();\n\n        do {\n          res = curl_easy_perform(curl);\n          if (!curl_slist_append(easycode, \"ret = curl_easy_perform(hnd);\")) {\n            res = CURLE_OUT_OF_MEMORY;\n            break;\n          }\n\n          \/* if retry-max-time is non-zero, make sure we haven't exceeded the\n             time *\/\n          if(retry_numretries &&\n             (!config->retry_maxtime ||\n              (cutil_tvdiff(cutil_tvnow(), retrystart)<\n               config->retry_maxtime*1000)) ) {\n            enum {\n              RETRY_NO,\n              RETRY_TIMEOUT,\n              RETRY_HTTP,\n              RETRY_FTP,\n              RETRY_LAST \/* not used *\/\n            } retry = RETRY_NO;\n            long response;\n            if(CURLE_OPERATION_TIMEDOUT == res)\n              \/* retry timeout always *\/\n              retry = RETRY_TIMEOUT;\n            else if(CURLE_OK == res) {\n              \/* Check for HTTP transient errors *\/\n              char *this_url=NULL;\n              curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &this_url);\n              if(this_url &&\n                 curlx_strnequal(this_url, \"http\", 4)) {\n                \/* This was HTTP(S) *\/\n                curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);\n\n                switch(response) {\n                case 500: \/* Internal Server Error *\/\n                case 502: \/* Bad Gateway *\/\n                case 503: \/* Service Unavailable *\/\n                case 504: \/* Gateway Timeout *\/\n                  retry = RETRY_HTTP;\n                  \/*\n                   * At this point, we have already written data to the output\n                   * file (or terminal). If we write to a file, we must rewind\n                   * or close\/re-open the file so that the next attempt starts\n                   * over from the beginning.\n                   *\n                   * TODO: similar action for the upload case. We might need\n                   * to start over reading from a previous point if we have\n                   * uploaded something when this was returned.\n                   *\/\n                  break;\n                }\n              }\n            } \/* if CURLE_OK *\/\n            else if(CURLE_LOGIN_DENIED == res) {\n              curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);\n\n              if(response\/100 == 5)\n                \/*\n                 * This is typically when the FTP server only allows a certain\n                 * amount of users and we are not one of them. It mostly\n                 * returns 530 in this case, but all 5xx codes are transient.\n                 *\/\n                retry = RETRY_FTP;\n            }\n\n            if(retry) {\n              static const char * const m[]={NULL,\n                                             \"timeout\",\n                                             \"HTTP error\",\n                                             \"FTP error\"\n              };\n              warnf(config, \"Transient problem: %s \"\n                    \"Will retry in %ld seconds. \"\n                    \"%ld retries left.\\n\",\n                    m[retry],\n                    retry_sleep\/1000,\n                    retry_numretries);\n\n              go_sleep(retry_sleep);\n              retry_numretries--;\n              if(!config->retry_delay) {\n                retry_sleep *= 2;\n                if(retry_sleep > RETRY_SLEEP_MAX)\n                  retry_sleep = RETRY_SLEEP_MAX;\n              }\n              if(outs.bytes && outs.filename) {\n                \/* We have written data to a output file, we truncate file\n                 *\/\n                if(!(config->conf&CONF_MUTE))\n                  fprintf(stderr, \"Throwing away %Od bytes\\n\", outs.bytes);\n                fflush(outs.stream);\n                \/* truncate file at the position where we started appending *\/\n#ifdef HAVE_FTRUNCATE\n                ftruncate( fileno(outs.stream), outs.init);\n                \/* now seek to the end of the file, the position where we\n                   just truncated the file in a large file-safe way *\/\n                fseek(outs.stream, 0, SEEK_END);\n#else\n                \/* ftruncate is not available, so just reposition the file\n                   to the location we would have truncated it. This won't\n                   work properly with large files on 32-bit systems, but\n                   most of those will have ftruncate. *\/\n                fseek(outs.stream, (long)outs.init, SEEK_SET);\n#endif\n                outs.bytes = 0; \/* clear for next round *\/\n              }\n              continue;\n            }\n          } \/* if retry_numretries *\/\n\n          \/* In all ordinary cases, just break out of loop here *\/\n          retry_sleep = retry_sleep_default;\n          break;\n\n        } while(1);\n\n        if((config->progressmode == CURL_PROGRESS_BAR) &&\n           progressbar.calls) {\n          \/* if the custom progress bar has been displayed, we output a\n             newline here *\/\n          fputs(\"\\n\", progressbar.out);\n        }\n\n        if(config->writeout) {\n          ourWriteOut(curl, config->writeout);\n        }\n#ifdef USE_ENVIRONMENT\n        if (config->writeenv)\n          ourWriteEnv(curl);\n#endif\n\nshow_error:\n\n#ifdef  VMS\n        if (!config->showerror)  {\n          vms_show = VMSSTS_HIDE;\n        }\n#else\n        if((res!=CURLE_OK) && config->showerror) {\n          fprintf(config->errors, \"curl: (%d) %s\\n\", (int)res,\n                  errorbuffer[0]? errorbuffer:\n                  curl_easy_strerror((CURLcode)res));\n          if(CURLE_SSL_CACERT == res) {\n#define CURL_CA_CERT_ERRORMSG1 \\\n\"More details here: http:\/\/curl.haxx.se\/docs\/sslcerts.html\\n\\n\" \\\n\"curl performs SSL certificate verification by default, using a \\\"bundle\\\"\\n\" \\\n\" of Certificate Authority (CA) public keys (CA certs). The default\\n\" \\\n\" bundle is named curl-ca-bundle.crt; you can specify an alternate file\\n\" \\\n\" using the --cacert option.\\n\"\n\n#define CURL_CA_CERT_ERRORMSG2 \\\n\"If this HTTPS server uses a certificate signed by a CA represented in\\n\" \\\n\" the bundle, the certificate verification probably failed due to a\\n\" \\\n\" problem with the certificate (it might be expired, or the name might\\n\" \\\n\" not match the domain name in the URL).\\n\" \\\n\"If you'd like to turn off curl's verification of the certificate, use\\n\" \\\n\" the -k (or --insecure) option.\\n\"\n\n            fprintf(config->errors, \"%s%s\",\n                    CURL_CA_CERT_ERRORMSG1,\n                    CURL_CA_CERT_ERRORMSG2 );\n          }\n        }\n#endif\n\n        if (outfile && !curlx_strequal(outfile, \"-\") && outs.stream)\n          fclose(outs.stream);\n\n#ifdef HAVE_UTIME\n        \/* Important that we set the time _after_ the file has been\n           closed, as is done above here *\/\n        if(config->remote_time && outs.filename) {\n          \/* ask libcurl if we got a time. Pretty please *\/\n          long filetime;\n          curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);\n          if(filetime >= 0) {\n            struct utimbuf times;\n            times.actime = (time_t)filetime;\n            times.modtime = (time_t)filetime;\n            utime(outs.filename, ×); \/* set the time we got *\/\n          }\n        }\n#endif\n#ifdef __AMIGA__\n        \/* Set the url as comment for the file. (up to 80 chars are allowed)\n         *\/\n        if( strlen(url) > 78 )\n          url[79] = '\\0';\n\n        SetComment( outs.filename, url);\n#endif\n\n        if(headerfilep)\n          fclose(headerfilep);\n\n        if(url)\n          free(url);\n\n        if(outfile)\n          free(outfile);\n\n        if(infdfopen)\n          fclose(infd);\n\n      } \/* loop to the next URL *\/\n\n      if(urls)\n        \/* cleanup memory used for URL globbing patterns *\/\n        glob_cleanup(urls);\n\n      if(uploadfile)\n        free(uploadfile);\n\n    } \/* loop to the next globbed upload file *\/\n\n    if(inglob) {\n      glob_cleanup(inglob);\n      inglob = NULL;\n    }\n\n    if(outfiles)\n      free(outfiles);\n\n    \/* empty this urlnode struct *\/\n    if(urlnode->url)\n      free(urlnode->url);\n    if(urlnode->outfile)\n      free(urlnode->outfile);\n    if(urlnode->infile)\n      free(urlnode->infile);\n\n    \/* move on to the next URL *\/\n    nextnode=urlnode->next;\n    free(urlnode); \/* free the node *\/\n    urlnode = nextnode;\n\n  } \/* while-loop through all URLs *\/\n\nquit_curl:\n  if (httpgetfields)\n    free(httpgetfields);\n\n  if (config->engine)\n    free(config->engine);\n\n  \/* cleanup the curl handle! *\/\n  curl_easy_cleanup(curl);\n  if (easycode)\n    curl_slist_append(easycode, \"curl_easy_cleanup(hnd);\");\n\n  if(config->headerfile && !headerfilep && heads.stream)\n    fclose(heads.stream);\n\n  if(allocuseragent)\n    free(config->useragent);\n\n  if(config->trace_fopened && config->trace_stream)\n    fclose(config->trace_stream);\n\n  if(config->errors_fopened)\n    fclose(config->errors);\n\n  main_free(); \/* cleanup *\/\n\n  dumpeasycode(config);\n\n  return res;\n}","target":0,"code_token_length":8978,"total_token_length":9214,"max_tokens_setting":11000}
+{"idx":452391,"func":"static Image *ReadTIFFImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n#define MaxPixelChannels  32\n#define ThrowTIFFException(severity,message) \\\n{ \\\n  if (pixel_info != (MemoryInfo *) NULL) \\\n    pixel_info=RelinquishVirtualMemory(pixel_info); \\\n  if (quantum_info != (QuantumInfo *) NULL) \\\n    quantum_info=DestroyQuantumInfo(quantum_info); \\\n  TIFFClose(tiff); \\\n  ThrowReaderException(severity,message); \\\n}\n\n  const char\n    *option;\n\n  float\n    *chromaticity = (float *) NULL,\n    x_position,\n    y_position,\n    x_resolution,\n    y_resolution;\n\n  Image\n    *image;\n\n  int\n    tiff_status = 0;\n\n  MagickBooleanType\n    more_frames;\n\n  MagickStatusType\n    status;\n\n  MemoryInfo\n    *pixel_info = (MemoryInfo *) NULL;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  size_t\n    number_pixels;\n\n  ssize_t\n    i,\n    scanline_size,\n    y;\n\n  TIFF\n    *tiff;\n\n  TIFFMethodType\n    method;\n\n  uint16\n    compress_tag = 0,\n    bits_per_sample = 0,\n    endian = 0,\n    extra_samples = 0,\n    interlace = 0,\n    max_sample_value = 0,\n    min_sample_value = 0,\n    orientation = 0,\n    pages = 0,\n    photometric = 0,\n    *sample_info = NULL,\n    sample_format = 0,\n    samples_per_pixel = 0,\n    units = 0,\n    value = 0;\n\n  uint32\n    height,\n    rows_per_strip,\n    width;\n\n  unsigned char\n    *pixels;\n\n  void\n    *sans[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };\n\n  \/*\n    Open image.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  if (IsEventLogging() != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  (void) SetMagickThreadValue(tiff_exception,exception);\n  tiff=TIFFClientOpen(image->filename,\"rb\",(thandle_t) image,TIFFReadBlob,\n    TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob,\n    TIFFUnmapBlob);\n  if (tiff == (TIFF *) NULL)\n    {\n      if (exception->severity == UndefinedException)\n        ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (exception->severity > ErrorException)\n    {\n      TIFFClose(tiff);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (image_info->number_scenes != 0)\n    {\n      \/*\n        Generate blank images for subimage specification (e.g. image.tif[4].\n        We need to check the number of directores because it is possible that\n        the subimage(s) are stored in the photoshop profile.\n      *\/\n      if (image_info->scene < (size_t)TIFFNumberOfDirectories(tiff))\n        {\n          for (i=0; i < (ssize_t) image_info->scene; i++)\n          {\n            status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n            if (status == MagickFalse)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            AcquireNextImage(image_info,image);\n            if (GetNextImageInList(image) == (Image *) NULL)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            image=SyncNextImageInList(image);\n          }\n        }\n    }\n  more_frames=MagickTrue;\n  do\n  {\n    \/* TIFFPrintDirectory(tiff,stdout,MagickFalse); *\/\n    photometric=PHOTOMETRIC_RGB;\n    if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) ||\n        (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value,sans) != 1))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    if (((sample_format != SAMPLEFORMAT_IEEEFP) || (bits_per_sample != 64)) &&\n        ((bits_per_sample <= 0) || (bits_per_sample > 32)))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"UnsupportedBitsPerPixel\");\n      }\n    if (samples_per_pixel > MaxPixelChannels)\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"MaximumChannelsExceeded\");\n      }\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      (void) SetImageProperty(image,\"quantum:format\",\"floating-point\");\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-black\");\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-white\");\n        break;\n      }\n      case PHOTOMETRIC_PALETTE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"palette\");\n        break;\n      }\n      case PHOTOMETRIC_RGB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"RGB\");\n        break;\n      }\n      case PHOTOMETRIC_CIELAB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIELAB\");\n        break;\n      }\n      case PHOTOMETRIC_LOGL:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIE Log2(L)\");\n        break;\n      }\n      case PHOTOMETRIC_LOGLUV:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"LOGLUV\");\n        break;\n      }\n#if defined(PHOTOMETRIC_MASK)\n      case PHOTOMETRIC_MASK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"MASK\");\n        break;\n      }\n#endif\n      case PHOTOMETRIC_SEPARATED:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"separated\");\n        break;\n      }\n      case PHOTOMETRIC_YCBCR:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"YCBCR\");\n        break;\n      }\n      default:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"unknown\");\n        break;\n      }\n    }\n    if (image->debug != MagickFalse)\n      {\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Geometry: %ux%u\",\n          (unsigned int) width,(unsigned int) height);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Interlace: %u\",\n          interlace);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Bits per sample: %u\",bits_per_sample);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Min sample value: %u\",min_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Max sample value: %u\",max_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Photometric \"\n          \"interpretation: %s\",GetImageProperty(image,\"tiff:photometric\"));\n      }\n    image->columns=(size_t) width;\n    image->rows=(size_t) height;\n    image->depth=(size_t) bits_per_sample;\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Image depth: %.20g\",\n        (double) image->depth);\n    image->endian=MSBEndian;\n    if (endian == FILLORDER_LSB2MSB)\n      image->endian=LSBEndian;\n#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN)\n    if (TIFFIsBigEndian(tiff) == 0)\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"lsb\");\n        image->endian=LSBEndian;\n      }\n    else\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"msb\");\n        image->endian=MSBEndian;\n      }\n#endif\n    if ((photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      image->colorspace=GRAYColorspace;\n    if (photometric == PHOTOMETRIC_SEPARATED)\n      image->colorspace=CMYKColorspace;\n    if (photometric == PHOTOMETRIC_CIELAB)\n      image->colorspace=LabColorspace;\n    if ((photometric == PHOTOMETRIC_YCBCR) &&\n        (compress_tag != COMPRESSION_OJPEG) &&\n        (compress_tag != COMPRESSION_JPEG))\n      image->colorspace=YCbCrColorspace;\n    status=TIFFGetProfiles(tiff,image);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    status=TIFFGetProperties(tiff,image);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    option=GetImageOption(image_info,\"tiff:exif-properties\");\n    if ((option == (const char *) NULL) ||\n        (IsMagickTrue(option) != MagickFalse))\n      (void) TIFFGetEXIFProperties(tiff,image);\n    option=GetImageOption(image_info,\"tiff:gps-properties\");\n    if ((option == (const char *) NULL) ||\n        (IsMagickTrue(option) != MagickFalse))\n      (void) TIFFGetGPSProperties(tiff,image);\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution,sans) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution,sans) == 1))\n      {\n        image->x_resolution=x_resolution;\n        image->y_resolution=y_resolution;\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units,sans,sans) == 1)\n      {\n        if (units == RESUNIT_INCH)\n          image->units=PixelsPerInchResolution;\n        if (units == RESUNIT_CENTIMETER)\n          image->units=PixelsPerCentimeterResolution;\n      }\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))\n      {\n        image->page.x=CastDoubleToLong(ceil(x_position*\n          image->x_resolution-0.5));\n        image->page.y=CastDoubleToLong(ceil(y_position*\n          image->y_resolution-0.5));\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)\n      image->orientation=(OrientationType) orientation;\n    if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1)\n      {\n        if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0))\n          {\n            image->chromaticity.white_point.x=chromaticity[0];\n            image->chromaticity.white_point.y=chromaticity[1];\n          }\n      }\n    if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1)\n      {\n        if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0))\n          {\n            image->chromaticity.red_primary.x=chromaticity[0];\n            image->chromaticity.red_primary.y=chromaticity[1];\n            image->chromaticity.green_primary.x=chromaticity[2];\n            image->chromaticity.green_primary.y=chromaticity[3];\n            image->chromaticity.blue_primary.x=chromaticity[4];\n            image->chromaticity.blue_primary.y=chromaticity[5];\n          }\n      }\n#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)\n    if ((compress_tag != COMPRESSION_NONE) &&\n        (TIFFIsCODECConfigured(compress_tag) == 0))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CoderError,\"CompressNotSupported\");\n      }\n#endif\n    switch (compress_tag)\n    {\n      case COMPRESSION_NONE: image->compression=NoCompression; break;\n      case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break;\n      case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break;\n      case COMPRESSION_JPEG:\n      {\n         image->compression=JPEGCompression;\n#if defined(JPEG_SUPPORT)\n         {\n           char\n             sampling_factor[MaxTextExtent];\n\n           int\n             tiff_status;\n\n           uint16\n             horizontal,\n             vertical;\n\n           tiff_status=TIFFGetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal,\n             &vertical);\n           if (tiff_status == 1)\n             {\n               (void) FormatLocaleString(sampling_factor,MaxTextExtent,\"%dx%d\",\n                 horizontal,vertical);\n               (void) SetImageProperty(image,\"jpeg:sampling-factor\",\n                 sampling_factor);\n               (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                 \"Sampling Factors: %s\",sampling_factor);\n             }\n         }\n#endif\n        break;\n      }\n      case COMPRESSION_OJPEG: image->compression=JPEGCompression; break;\n#if defined(COMPRESSION_LZMA)\n      case COMPRESSION_LZMA: image->compression=LZMACompression; break;\n#endif\n      case COMPRESSION_LZW: image->compression=LZWCompression; break;\n      case COMPRESSION_DEFLATE: image->compression=ZipCompression; break;\n      case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break;\n#if defined(COMPRESSION_WEBP)\n      case COMPRESSION_WEBP: image->compression=WebPCompression; break;\n#endif\n#if defined(COMPRESSION_ZSTD)\n      case COMPRESSION_ZSTD: image->compression=ZstdCompression; break;\n#endif\n      default: image->compression=RLECompression; break;\n    }\n    quantum_info=(QuantumInfo *) NULL;\n    if ((photometric == PHOTOMETRIC_PALETTE) &&\n        (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))\n      {\n        size_t\n          colors;\n\n        colors=(size_t) GetQuantumRange(bits_per_sample)+1;\n        if (AcquireImageColormap(image,colors) == MagickFalse)\n          {\n            TIFFClose(tiff);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages,sans) == 1)\n      image->scene=value;\n    if (image->storage_class == PseudoClass)\n      {\n        int\n          tiff_status;\n\n        size_t\n          range;\n\n        uint16\n          *blue_colormap = (uint16 *) NULL,\n          *green_colormap = (uint16 *) NULL,\n          *red_colormap = (uint16 *) NULL;\n\n        \/*\n          Initialize colormap.\n        *\/\n        tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,\n          &green_colormap,&blue_colormap);\n        if (tiff_status == 1)\n          {\n            if ((red_colormap != (uint16 *) NULL) &&\n                (green_colormap != (uint16 *) NULL) &&\n                (blue_colormap != (uint16 *) NULL))\n              {\n                range=255;  \/* might be old style 8-bit colormap *\/\n                for (i=0; i < (ssize_t) image->colors; i++)\n                  if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||\n                      (blue_colormap[i] >= 256))\n                    {\n                      range=65535;\n                      break;\n                    }\n                for (i=0; i < (ssize_t) image->colors; i++)\n                {\n                  image->colormap[i].red=ClampToQuantum(((double)\n                    QuantumRange*red_colormap[i])\/range);\n                  image->colormap[i].green=ClampToQuantum(((double)\n                    QuantumRange*green_colormap[i])\/range);\n                  image->colormap[i].blue=ClampToQuantum(((double)\n                    QuantumRange*blue_colormap[i])\/range);\n                }\n              }\n          }\n      }\n    if (image_info->ping != MagickFalse)\n      {\n        if (image_info->number_scenes != 0)\n          if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n            break;\n        goto next_tiff_frame;\n      }\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    status=SetImageColorspace(image,image->colorspace);\n    status&=ResetImagePixels(image,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    \/*\n      Allocate memory for the image and pixel buffer.\n    *\/\n    quantum_info=AcquireQuantumInfo(image_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (sample_format == SAMPLEFORMAT_UINT)\n      status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_INT)\n      status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);\n    if (status == MagickFalse)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    status=MagickTrue;\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        quantum_info->min_is_white=MagickFalse;\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        quantum_info->min_is_white=MagickTrue;\n        break;\n      }\n      default:\n        break;\n    }\n    extra_samples=0;\n    tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,\n      &sample_info,sans);\n    if (tiff_status == 1)\n      {\n        (void) SetImageProperty(image,\"tiff:alpha\",\"unspecified\");\n        if (extra_samples == 0)\n          {\n            if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))\n              image->matte=MagickTrue;\n          }\n        else\n          for (i=0; i < extra_samples; i++)\n          {\n            image->matte=MagickTrue;\n            if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)\n              {\n                SetQuantumAlphaType(quantum_info,AssociatedQuantumAlpha);\n                (void) SetImageProperty(image,\"tiff:alpha\",\"associated\");\n              }\n            else\n              if (sample_info[i] == EXTRASAMPLE_UNASSALPHA)\n                {\n                  SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);\n                  (void) SetImageProperty(image,\"tiff:alpha\",\"unassociated\");\n                }\n          }\n      }\n    if (image->matte != MagickFalse)\n      (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);\n    method=ReadGenericMethod;\n    rows_per_strip=(uint32) image->rows;\n    if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1)\n      {\n        char\n          value[MaxTextExtent];\n\n        (void) FormatLocaleString(value,MaxTextExtent,\"%u\",(unsigned int)\n          rows_per_strip);\n        (void) SetImageProperty(image,\"tiff:rows-per-strip\",value);\n        method=ReadStripMethod;\n        if (rows_per_strip > (uint32) image->rows)\n          rows_per_strip=(uint32) image->rows;\n      }\n    if (TIFFIsTiled(tiff) != MagickFalse)\n      {\n        uint32\n          columns,\n          rows;\n\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        if ((AcquireMagickResource(WidthResource,columns) == MagickFalse) ||\n            (AcquireMagickResource(HeightResource,rows) == MagickFalse))\n          ThrowTIFFException(ImageError,\"WidthOrHeightExceedsLimit\");\n        method=ReadTileMethod;\n      }\n    if ((photometric == PHOTOMETRIC_LOGLUV) ||\n        (compress_tag == COMPRESSION_CCITTFAX3))\n      method=ReadGenericMethod;\n    if (image->compression == JPEGCompression)\n      method=GetJPEGMethod(image,tiff,photometric,bits_per_sample,\n        samples_per_pixel);\n    quantum_info->endian=LSBEndian;\n    scanline_size=TIFFScanlineSize(tiff);\n    if (scanline_size <= 0)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    number_pixels=MagickMax((MagickSizeType) image->columns*samples_per_pixel*\n      pow(2.0,ceil(log(bits_per_sample)\/log(2.0))),image->columns*\n      rows_per_strip);\n    if ((double) scanline_size > 1.5*number_pixels)\n      ThrowTIFFException(CorruptImageError,\"CorruptImage\");\n    number_pixels=MagickMax((MagickSizeType) scanline_size,number_pixels);\n    pixel_info=AcquireVirtualMemory(number_pixels,sizeof(uint32));\n    if (pixel_info == (MemoryInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    (void) ResetMagickMemory(pixels,0,number_pixels*sizeof(uint32));\n    quantum_type=GrayQuantum;\n    if (image->storage_class == PseudoClass)\n      quantum_type=IndexQuantum;\n    if (interlace != PLANARCONFIG_SEPARATE)\n      {\n        size_t\n          pad;\n\n        pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0);\n        if (image->matte != MagickFalse)\n          {\n            if (image->storage_class == PseudoClass)\n              quantum_type=IndexAlphaQuantum;\n            else\n              quantum_type=samples_per_pixel == 1 ? AlphaQuantum :\n                GrayAlphaQuantum;\n          }\n        if ((samples_per_pixel > 2) && (interlace != PLANARCONFIG_SEPARATE))\n          {\n            quantum_type=RGBQuantum;\n            pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n              extra_samples-3,0);\n            if (image->matte != MagickFalse)\n              {\n                quantum_type=RGBAQuantum;\n                pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n                  extra_samples-4,0);\n              }\n            if (image->colorspace == CMYKColorspace)\n              {\n                quantum_type=CMYKQuantum;\n                pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n                  extra_samples-4,0);\n                if (image->matte != MagickFalse)\n                  {\n                    quantum_type=CMYKAQuantum;\n                    pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n                      extra_samples-5,0);\n                  }\n              }\n            status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >>\n              3));\n            if (status == MagickFalse)\n              ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    switch (method)\n    {\n      case ReadYCCKMethod:\n      {\n        \/*\n          Convert YCC TIFF image.\n        *\/\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          int\n            status;\n\n          IndexPacket\n            *indexes;\n\n          PixelPacket\n            *magick_restrict q;\n\n          ssize_t\n            x;\n\n          unsigned char\n            *p;\n\n          status=TIFFReadPixels(tiff,0,y,(char *) pixels);\n          if (status == -1)\n            break;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          p=pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelCyan(q,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.402*(double) *(p+2))-179.456)));\n            SetPixelMagenta(q,ScaleCharToQuantum(ClampYCC((double) *p-\n              (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+\n              135.45984)));\n            SetPixelYellow(q,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.772*(double) *(p+1))-226.816)));\n            SetPixelBlack(indexes+x,ScaleCharToQuantum((unsigned char)*(p+3)));\n            q++;\n            p+=4;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadStripMethod:\n      {\n        unsigned char\n          *p;\n\n        size_t\n          extent;\n\n        ssize_t\n          stride,\n          strip_id;\n\n        tsize_t\n          strip_size;\n\n        unsigned char\n          *strip_pixels;\n\n        \/*\n          Convert stripped TIFF image.\n        *\/\n        extent=4*((image->depth+7)\/8)*(samples_per_pixel+1)*TIFFStripSize(tiff);\n        strip_pixels=(unsigned char *) AcquireQuantumMemory(extent,\n          sizeof(*strip_pixels));\n        if (strip_pixels == (unsigned char *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(strip_pixels,0,extent*sizeof(*strip_pixels));\n        stride=TIFFVStripSize(tiff,1);\n        strip_id=0;\n        p=strip_pixels;\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          size_t\n            rows_remaining;\n\n          switch (i)\n          {\n            case 0: break;\n            case 1: quantum_type=GreenQuantum; break;\n            case 2: quantum_type=BlueQuantum; break;\n            case 3:\n            {\n              quantum_type=AlphaQuantum;\n              if (image->colorspace == CMYKColorspace)\n                quantum_type=BlackQuantum;\n              break;\n            }\n            case 4: quantum_type=AlphaQuantum; break;\n            default: break;\n          }\n          rows_remaining=0;\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            PixelPacket\n              *magick_restrict q;\n\n            q=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (PixelPacket *) NULL)\n              break;\n            if (rows_remaining == 0)\n              {\n                strip_size=TIFFReadEncodedStrip(tiff,strip_id,strip_pixels,\n                  TIFFStripSize(tiff));\n                if (strip_size == -1)\n                  break;\n                rows_remaining=rows_per_strip;\n                if ((y+rows_per_strip) > (ssize_t) image->rows)\n                  rows_remaining=(rows_per_strip-(y+rows_per_strip-\n                    image->rows));\n                p=strip_pixels;\n                strip_id++;\n              }\n            (void) ImportQuantumPixels(image,(CacheView *) NULL,\n              quantum_info,quantum_type,p,exception);\n            p+=stride;\n            rows_remaining--;\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                  image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n         if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE))\n            break;\n        }\n        strip_pixels=(unsigned char *) RelinquishMagickMemory(strip_pixels);\n        break;\n      }\n      case ReadTileMethod:\n      {\n        unsigned char\n          *p;\n\n        size_t\n          extent;\n\n        uint32\n          columns,\n          rows;\n\n        unsigned char\n          *tile_pixels;\n\n        \/*\n          Convert tiled TIFF image.\n        *\/\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        number_pixels=(MagickSizeType) columns*rows;\n        if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        extent=4*(samples_per_pixel+1)*MagickMax(rows*TIFFTileRowSize(tiff),\n          TIFFTileSize(tiff));\n        tile_pixels=(unsigned char *) AcquireQuantumMemory(extent,\n          sizeof(*tile_pixels));\n        if (tile_pixels == (unsigned char *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(tile_pixels,0,extent*sizeof(*tile_pixels));\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          switch (i)\n          {\n            case 0: break;\n            case 1: quantum_type=GreenQuantum; break;\n            case 2: quantum_type=BlueQuantum; break;\n            case 3:\n            {\n              quantum_type=AlphaQuantum;\n              if (image->colorspace == CMYKColorspace)\n                quantum_type=BlackQuantum;\n              break;\n            }\n            case 4: quantum_type=AlphaQuantum; break;\n            default: break;\n          }\n          for (y=0; y < (ssize_t) image->rows; y+=rows)\n          {\n            ssize_t\n              x;\n\n            size_t\n              rows_remaining;\n\n            rows_remaining=image->rows-y;\n            if ((ssize_t) (y+rows) < (ssize_t) image->rows)\n              rows_remaining=rows;\n            for (x=0; x < (ssize_t) image->columns; x+=columns)\n            {\n              size_t\n                columns_remaining,\n                row;\n\n              columns_remaining=image->columns-x;\n              if ((ssize_t) (x+columns) < (ssize_t) image->columns)\n                columns_remaining=columns;\n              tiff_status=TIFFReadTile(tiff,tile_pixels,(uint32) x,(uint32) y,\n                0,i);\n              if (tiff_status == -1)\n                break;\n              p=tile_pixels;\n              for (row=0; row < rows_remaining; row++)\n              {\n                PixelPacket\n                  *magick_restrict q;\n\n                q=GetAuthenticPixels(image,x,y+row,columns_remaining,1,\n                  exception);\n                if (q == (PixelPacket *) NULL)\n                  break;\n                (void) ImportQuantumPixels(image,(CacheView *) NULL,\n                  quantum_info,quantum_type,p,exception);\n                p+=TIFFTileRowSize(tiff);\n                if (SyncAuthenticPixels(image,exception) == MagickFalse)\n                  break;\n              }\n            }\n          }\n          if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE))\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) i,\n                samples_per_pixel);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        tile_pixels=(unsigned char *) RelinquishMagickMemory(tile_pixels);\n        break;\n      }\n      case ReadGenericMethod:\n      default:\n      {\n        MemoryInfo\n          *generic_info = (MemoryInfo *) NULL;\n\n        uint32\n          *p;\n\n        uint32\n          *pixels;\n\n        \/*\n          Convert generic TIFF image.\n        *\/\n        if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        number_pixels=(MagickSizeType) image->columns*image->rows;\n        generic_info=AcquireVirtualMemory(number_pixels,sizeof(*pixels));\n        if (generic_info == (MemoryInfo *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(uint32 *) GetVirtualMemoryBlob(generic_info);\n        tiff_status=TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32)\n          image->rows,(uint32 *) pixels,0);\n        if (tiff_status == -1)\n          {\n            generic_info=RelinquishVirtualMemory(generic_info);\n            break;\n          }\n        p=pixels+(image->columns*image->rows)-1;\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          ssize_t\n            x;\n\n          PixelPacket\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          q+=image->columns-1;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(q,ScaleCharToQuantum((unsigned char) TIFFGetR(*p)));\n            SetPixelGreen(q,ScaleCharToQuantum((unsigned char) TIFFGetG(*p)));\n            SetPixelBlue(q,ScaleCharToQuantum((unsigned char) TIFFGetB(*p)));\n            if (image->matte == MagickFalse)\n              SetPixelOpacity(q,OpaqueOpacity);\n            else\n              SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) TIFFGetA(*p)));\n            p--;\n            q--;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        generic_info=RelinquishVirtualMemory(generic_info);\n        break;\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    SetQuantumImageType(image,quantum_type);\n  next_tiff_frame:\n    if (quantum_info != (QuantumInfo *) NULL)\n      quantum_info=DestroyQuantumInfo(quantum_info);\n    if (tiff_status == -1)\n      {\n        status=MagickFalse;\n        break;\n      }\n    if (photometric == PHOTOMETRIC_CIELAB)\n      DecodeLabImage(image,exception);\n    if ((photometric == PHOTOMETRIC_LOGL) ||\n        (photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      {\n        image->type=GrayscaleType;\n        if (bits_per_sample == 1)\n          image->type=BilevelType;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    more_frames=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n    if (more_frames != MagickFalse)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,image->scene-1,\n          image->scene);\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((status != MagickFalse) && (more_frames != MagickFalse));\n  TIFFClose(tiff);\n  if ((image_info->number_scenes != 0) &&\n      (image_info->scene >= GetImageListLength(image)))\n    status=MagickFalse;\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  TIFFReadPhotoshopLayers(image_info,image,exception);\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":8620,"total_token_length":8856,"max_tokens_setting":11000}
+{"idx":211845,"func":"static Image *ReadTIFFImage(const ImageInfo *image_info,\n  ExceptionInfo *exception)\n{\n#define MaxPixelChannels  32\n#define ThrowTIFFException(severity,message) \\\n{ \\\n  if (pixel_info != (MemoryInfo *) NULL) \\\n    pixel_info=RelinquishVirtualMemory(pixel_info); \\\n  if (quantum_info != (QuantumInfo *) NULL) \\\n    quantum_info=DestroyQuantumInfo(quantum_info); \\\n  TIFFClose(tiff); \\\n  ThrowReaderException(severity,message); \\\n}\n\n  const char\n    *option;\n\n  float\n    *chromaticity = (float *) NULL,\n    x_position,\n    y_position,\n    x_resolution,\n    y_resolution;\n\n  Image\n    *image;\n\n  int\n    tiff_status = 0;\n\n  MagickBooleanType\n    more_frames;\n\n  MagickStatusType\n    status;\n\n  MemoryInfo\n    *pixel_info = (MemoryInfo *) NULL;\n\n  QuantumInfo\n    *quantum_info;\n\n  QuantumType\n    quantum_type;\n\n  size_t\n    number_pixels;\n\n  ssize_t\n    i,\n    scanline_size,\n    y;\n\n  TIFF\n    *tiff;\n\n  TIFFMethodType\n    method;\n\n  uint16\n    compress_tag = 0,\n    bits_per_sample = 0,\n    endian = 0,\n    extra_samples = 0,\n    interlace = 0,\n    max_sample_value = 0,\n    min_sample_value = 0,\n    orientation = 0,\n    pages = 0,\n    photometric = 0,\n    *sample_info = NULL,\n    sample_format = 0,\n    samples_per_pixel = 0,\n    units = 0,\n    value = 0;\n\n  uint32\n    height,\n    rows_per_strip,\n    width;\n\n  unsigned char\n    *pixels;\n\n  void\n    *sans[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };\n\n  \/*\n    Open image.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  if (IsEventLogging() != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  (void) SetMagickThreadValue(tiff_exception,exception);\n  tiff=TIFFClientOpen(image->filename,\"rb\",(thandle_t) image,TIFFReadBlob,\n    TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,TIFFGetBlobSize,TIFFMapBlob,\n    TIFFUnmapBlob);\n  if (tiff == (TIFF *) NULL)\n    {\n      if (exception->severity == UndefinedException)\n        ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (exception->severity > ErrorException)\n    {\n      TIFFClose(tiff);\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  if (image_info->number_scenes != 0)\n    {\n      \/*\n        Generate blank images for subimage specification (e.g. image.tif[4].\n        We need to check the number of directores because it is possible that\n        the subimage(s) are stored in the photoshop profile.\n      *\/\n      if (image_info->scene < (size_t)TIFFNumberOfDirectories(tiff))\n        {\n          for (i=0; i < (ssize_t) image_info->scene; i++)\n          {\n            status=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n            if (status == MagickFalse)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            AcquireNextImage(image_info,image);\n            if (GetNextImageInList(image) == (Image *) NULL)\n              {\n                TIFFClose(tiff);\n                image=DestroyImageList(image);\n                return((Image *) NULL);\n              }\n            image=SyncNextImageInList(image);\n          }\n        }\n    }\n  more_frames=MagickTrue;\n  do\n  {\n    \/* TIFFPrintDirectory(tiff,stdout,MagickFalse); *\/\n    photometric=PHOTOMETRIC_RGB;\n    if ((TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH,&width) != 1) ||\n        (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&height) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_COMPRESSION,&compress_tag,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&endian,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_PLANARCONFIG,&interlace,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,&samples_per_pixel,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,&bits_per_sample,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLEFORMAT,&sample_format,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MINSAMPLEVALUE,&min_sample_value,sans) != 1) ||\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_MAXSAMPLEVALUE,&max_sample_value,sans) != 1))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    if (((sample_format != SAMPLEFORMAT_IEEEFP) || (bits_per_sample != 64)) &&\n        ((bits_per_sample <= 0) || (bits_per_sample > 32)))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"UnsupportedBitsPerPixel\");\n      }\n    if (samples_per_pixel > MaxPixelChannels)\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CorruptImageError,\"MaximumChannelsExceeded\");\n      }\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      (void) SetImageProperty(image,\"quantum:format\",\"floating-point\");\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-black\");\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"min-is-white\");\n        break;\n      }\n      case PHOTOMETRIC_PALETTE:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"palette\");\n        break;\n      }\n      case PHOTOMETRIC_RGB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"RGB\");\n        break;\n      }\n      case PHOTOMETRIC_CIELAB:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIELAB\");\n        break;\n      }\n      case PHOTOMETRIC_LOGL:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"CIE Log2(L)\");\n        break;\n      }\n      case PHOTOMETRIC_LOGLUV:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"LOGLUV\");\n        break;\n      }\n#if defined(PHOTOMETRIC_MASK)\n      case PHOTOMETRIC_MASK:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"MASK\");\n        break;\n      }\n#endif\n      case PHOTOMETRIC_SEPARATED:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"separated\");\n        break;\n      }\n      case PHOTOMETRIC_YCBCR:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"YCBCR\");\n        break;\n      }\n      default:\n      {\n        (void) SetImageProperty(image,\"tiff:photometric\",\"unknown\");\n        break;\n      }\n    }\n    if (image->debug != MagickFalse)\n      {\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Geometry: %ux%u\",\n          (unsigned int) width,(unsigned int) height);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Interlace: %u\",\n          interlace);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Bits per sample: %u\",bits_per_sample);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Min sample value: %u\",min_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n          \"Max sample value: %u\",max_sample_value);\n        (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Photometric \"\n          \"interpretation: %s\",GetImageProperty(image,\"tiff:photometric\"));\n      }\n    image->columns=(size_t) width;\n    image->rows=(size_t) height;\n    image->depth=(size_t) bits_per_sample;\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"Image depth: %.20g\",\n        (double) image->depth);\n    image->endian=MSBEndian;\n    if (endian == FILLORDER_LSB2MSB)\n      image->endian=LSBEndian;\n#if defined(MAGICKCORE_HAVE_TIFFISBIGENDIAN)\n    if (TIFFIsBigEndian(tiff) == 0)\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"lsb\");\n        image->endian=LSBEndian;\n      }\n    else\n      {\n        (void) SetImageProperty(image,\"tiff:endian\",\"msb\");\n        image->endian=MSBEndian;\n      }\n#endif\n    if ((photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      image->colorspace=GRAYColorspace;\n    if (photometric == PHOTOMETRIC_SEPARATED)\n      image->colorspace=CMYKColorspace;\n    if (photometric == PHOTOMETRIC_CIELAB)\n      image->colorspace=LabColorspace;\n    if ((photometric == PHOTOMETRIC_YCBCR) &&\n        (compress_tag != COMPRESSION_OJPEG) &&\n        (compress_tag != COMPRESSION_JPEG))\n      image->colorspace=YCbCrColorspace;\n    status=TIFFGetProfiles(tiff,image);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    status=TIFFGetProperties(tiff,image);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    option=GetImageOption(image_info,\"tiff:exif-properties\");\n    if ((option == (const char *) NULL) ||\n        (IsMagickTrue(option) != MagickFalse))\n      (void) TIFFGetEXIFProperties(tiff,image);\n    option=GetImageOption(image_info,\"tiff:gps-properties\");\n    if ((option == (const char *) NULL) ||\n        (IsMagickTrue(option) != MagickFalse))\n      (void) TIFFGetGPSProperties(tiff,image);\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution,sans) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution,sans) == 1))\n      {\n        image->x_resolution=x_resolution;\n        image->y_resolution=y_resolution;\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units,sans,sans) == 1)\n      {\n        if (units == RESUNIT_INCH)\n          image->units=PixelsPerInchResolution;\n        if (units == RESUNIT_CENTIMETER)\n          image->units=PixelsPerCentimeterResolution;\n      }\n    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&\n        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))\n      {\n        image->page.x=CastDoubleToLong(ceil(x_position*\n          image->x_resolution-0.5));\n        image->page.y=CastDoubleToLong(ceil(y_position*\n          image->y_resolution-0.5));\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)\n      image->orientation=(OrientationType) orientation;\n    if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1)\n      {\n        if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0))\n          {\n            image->chromaticity.white_point.x=chromaticity[0];\n            image->chromaticity.white_point.y=chromaticity[1];\n          }\n      }\n    if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1)\n      {\n        if ((chromaticity != (float *) NULL) && (*chromaticity != 0.0))\n          {\n            image->chromaticity.red_primary.x=chromaticity[0];\n            image->chromaticity.red_primary.y=chromaticity[1];\n            image->chromaticity.green_primary.x=chromaticity[2];\n            image->chromaticity.green_primary.y=chromaticity[3];\n            image->chromaticity.blue_primary.x=chromaticity[4];\n            image->chromaticity.blue_primary.y=chromaticity[5];\n          }\n      }\n#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)\n    if ((compress_tag != COMPRESSION_NONE) &&\n        (TIFFIsCODECConfigured(compress_tag) == 0))\n      {\n        TIFFClose(tiff);\n        ThrowReaderException(CoderError,\"CompressNotSupported\");\n      }\n#endif\n    switch (compress_tag)\n    {\n      case COMPRESSION_NONE: image->compression=NoCompression; break;\n      case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break;\n      case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break;\n      case COMPRESSION_JPEG:\n      {\n         image->compression=JPEGCompression;\n#if defined(JPEG_SUPPORT)\n         {\n           char\n             sampling_factor[MaxTextExtent];\n\n           int\n             tiff_status;\n\n           uint16\n             horizontal,\n             vertical;\n\n           tiff_status=TIFFGetField(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal,\n             &vertical);\n           if (tiff_status == 1)\n             {\n               (void) FormatLocaleString(sampling_factor,MaxTextExtent,\"%dx%d\",\n                 horizontal,vertical);\n               (void) SetImageProperty(image,\"jpeg:sampling-factor\",\n                 sampling_factor);\n               (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                 \"Sampling Factors: %s\",sampling_factor);\n             }\n         }\n#endif\n        break;\n      }\n      case COMPRESSION_OJPEG: image->compression=JPEGCompression; break;\n#if defined(COMPRESSION_LZMA)\n      case COMPRESSION_LZMA: image->compression=LZMACompression; break;\n#endif\n      case COMPRESSION_LZW: image->compression=LZWCompression; break;\n      case COMPRESSION_DEFLATE: image->compression=ZipCompression; break;\n      case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break;\n#if defined(COMPRESSION_WEBP)\n      case COMPRESSION_WEBP: image->compression=WebPCompression; break;\n#endif\n#if defined(COMPRESSION_ZSTD)\n      case COMPRESSION_ZSTD: image->compression=ZstdCompression; break;\n#endif\n      default: image->compression=RLECompression; break;\n    }\n    quantum_info=(QuantumInfo *) NULL;\n    if ((photometric == PHOTOMETRIC_PALETTE) &&\n        (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))\n      {\n        size_t\n          colors;\n\n        colors=(size_t) GetQuantumRange(bits_per_sample)+1;\n        if (AcquireImageColormap(image,colors) == MagickFalse)\n          {\n            TIFFClose(tiff);\n            ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages,sans) == 1)\n      image->scene=value;\n    if (image->storage_class == PseudoClass)\n      {\n        int\n          tiff_status;\n\n        size_t\n          range;\n\n        uint16\n          *blue_colormap = (uint16 *) NULL,\n          *green_colormap = (uint16 *) NULL,\n          *red_colormap = (uint16 *) NULL;\n\n        \/*\n          Initialize colormap.\n        *\/\n        tiff_status=TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,\n          &green_colormap,&blue_colormap);\n        if (tiff_status == 1)\n          {\n            if ((red_colormap != (uint16 *) NULL) &&\n                (green_colormap != (uint16 *) NULL) &&\n                (blue_colormap != (uint16 *) NULL))\n              {\n                range=255;  \/* might be old style 8-bit colormap *\/\n                for (i=0; i < (ssize_t) image->colors; i++)\n                  if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||\n                      (blue_colormap[i] >= 256))\n                    {\n                      range=65535;\n                      break;\n                    }\n                for (i=0; i < (ssize_t) image->colors; i++)\n                {\n                  image->colormap[i].red=ClampToQuantum(((double)\n                    QuantumRange*red_colormap[i])\/range);\n                  image->colormap[i].green=ClampToQuantum(((double)\n                    QuantumRange*green_colormap[i])\/range);\n                  image->colormap[i].blue=ClampToQuantum(((double)\n                    QuantumRange*blue_colormap[i])\/range);\n                }\n              }\n          }\n      }\n    if (image_info->ping != MagickFalse)\n      {\n        if (image_info->number_scenes != 0)\n          if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n            break;\n        goto next_tiff_frame;\n      }\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    status=SetImageColorspace(image,image->colorspace);\n    status&=ResetImagePixels(image,exception);\n    if (status == MagickFalse)\n      {\n        TIFFClose(tiff);\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    \/*\n      Allocate memory for the image and pixel buffer.\n    *\/\n    quantum_info=AcquireQuantumInfo(image_info,image);\n    if (quantum_info == (QuantumInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    if (sample_format == SAMPLEFORMAT_UINT)\n      status=SetQuantumFormat(image,quantum_info,UnsignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_INT)\n      status=SetQuantumFormat(image,quantum_info,SignedQuantumFormat);\n    if (sample_format == SAMPLEFORMAT_IEEEFP)\n      status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);\n    if (status == MagickFalse)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    status=MagickTrue;\n    switch (photometric)\n    {\n      case PHOTOMETRIC_MINISBLACK:\n      {\n        quantum_info->min_is_white=MagickFalse;\n        break;\n      }\n      case PHOTOMETRIC_MINISWHITE:\n      {\n        quantum_info->min_is_white=MagickTrue;\n        break;\n      }\n      default:\n        break;\n    }\n    extra_samples=0;\n    tiff_status=TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,\n      &sample_info,sans);\n    if (tiff_status == 1)\n      {\n        (void) SetImageProperty(image,\"tiff:alpha\",\"unspecified\");\n        if (extra_samples == 0)\n          {\n            if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))\n              image->matte=MagickTrue;\n          }\n        else\n          for (i=0; i < extra_samples; i++)\n          {\n            image->matte=MagickTrue;\n            if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)\n              {\n                SetQuantumAlphaType(quantum_info,AssociatedQuantumAlpha);\n                (void) SetImageProperty(image,\"tiff:alpha\",\"associated\");\n              }\n            else\n              if (sample_info[i] == EXTRASAMPLE_UNASSALPHA)\n                {\n                  SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);\n                  (void) SetImageProperty(image,\"tiff:alpha\",\"unassociated\");\n                }\n          }\n      }\n    if (image->matte != MagickFalse)\n      (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);\n    method=ReadGenericMethod;\n    rows_per_strip=(uint32) image->rows;\n    if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1)\n      {\n        char\n          value[MaxTextExtent];\n\n        (void) FormatLocaleString(value,MaxTextExtent,\"%u\",(unsigned int)\n          rows_per_strip);\n        (void) SetImageProperty(image,\"tiff:rows-per-strip\",value);\n        method=ReadStripMethod;\n        if (rows_per_strip > (uint32) image->rows)\n          rows_per_strip=(uint32) image->rows;\n      }\n    if (TIFFIsTiled(tiff) != MagickFalse)\n      {\n        uint32\n          columns,\n          rows;\n\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        if ((AcquireMagickResource(WidthResource,columns) == MagickFalse) ||\n            (AcquireMagickResource(HeightResource,rows) == MagickFalse))\n          ThrowTIFFException(ImageError,\"WidthOrHeightExceedsLimit\");\n        method=ReadTileMethod;\n      }\n    if ((photometric == PHOTOMETRIC_LOGLUV) ||\n        (compress_tag == COMPRESSION_CCITTFAX3))\n      method=ReadGenericMethod;\n    if (image->compression == JPEGCompression)\n      method=GetJPEGMethod(image,tiff,photometric,bits_per_sample,\n        samples_per_pixel);\n    quantum_info->endian=LSBEndian;\n    scanline_size=TIFFScanlineSize(tiff);\n    if (scanline_size <= 0)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    number_pixels=MagickMax((MagickSizeType) image->columns*samples_per_pixel*\n      pow(2.0,ceil(log(bits_per_sample)\/log(2.0))),image->columns*\n      rows_per_strip);\n    if ((double) scanline_size > 1.5*number_pixels)\n      ThrowTIFFException(CorruptImageError,\"CorruptImage\");\n    number_pixels=MagickMax((MagickSizeType) scanline_size,number_pixels);\n    pixel_info=AcquireVirtualMemory(number_pixels,sizeof(uint32));\n    if (pixel_info == (MemoryInfo *) NULL)\n      ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n    pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n    (void) ResetMagickMemory(pixels,0,number_pixels*sizeof(uint32));\n    quantum_type=GrayQuantum;\n    if (image->storage_class == PseudoClass)\n      quantum_type=IndexQuantum;\n    if (interlace != PLANARCONFIG_SEPARATE)\n      {\n        size_t\n          pad;\n\n        pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0);\n        if (image->matte != MagickFalse)\n          {\n            if (image->storage_class == PseudoClass)\n              quantum_type=IndexAlphaQuantum;\n            else\n              quantum_type=samples_per_pixel == 1 ? AlphaQuantum :\n                GrayAlphaQuantum;\n          }\n        if ((samples_per_pixel > 2) && (interlace != PLANARCONFIG_SEPARATE))\n          {\n            quantum_type=RGBQuantum;\n            pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n              extra_samples-3,0);\n            if (image->matte != MagickFalse)\n              {\n                quantum_type=RGBAQuantum;\n                pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n                  extra_samples-4,0);\n              }\n            if (image->colorspace == CMYKColorspace)\n              {\n                quantum_type=CMYKQuantum;\n                pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n                  extra_samples-4,0);\n                if (image->matte != MagickFalse)\n                  {\n                    quantum_type=CMYKAQuantum;\n                    pad=(size_t) MagickMax((ssize_t) samples_per_pixel+\n                      extra_samples-5,0);\n                  }\n              }\n            status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >>\n              3));\n            if (status == MagickFalse)\n              ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n          }\n      }\n    switch (method)\n    {\n      case ReadYCCKMethod:\n      {\n        \/*\n          Convert YCC TIFF image.\n        *\/\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          int\n            status;\n\n          IndexPacket\n            *indexes;\n\n          PixelPacket\n            *magick_restrict q;\n\n          ssize_t\n            x;\n\n          unsigned char\n            *p;\n\n          status=TIFFReadPixels(tiff,0,y,(char *) pixels);\n          if (status == -1)\n            break;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          p=pixels;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelCyan(q,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.402*(double) *(p+2))-179.456)));\n            SetPixelMagenta(q,ScaleCharToQuantum(ClampYCC((double) *p-\n              (0.34414*(double) *(p+1))-(0.71414*(double ) *(p+2))+\n              135.45984)));\n            SetPixelYellow(q,ScaleCharToQuantum(ClampYCC((double) *p+\n              (1.772*(double) *(p+1))-226.816)));\n            SetPixelBlack(indexes+x,ScaleCharToQuantum((unsigned char)*(p+3)));\n            q++;\n            p+=4;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case ReadStripMethod:\n      {\n        unsigned char\n          *p;\n\n        size_t\n          extent;\n\n        ssize_t\n          stride,\n          strip_id;\n\n        tsize_t\n          strip_size;\n\n        unsigned char\n          *strip_pixels;\n\n        \/*\n          Convert stripped TIFF image.\n        *\/\n        extent=4*(samples_per_pixel+1)*TIFFStripSize(tiff);\n        strip_pixels=(unsigned char *) AcquireQuantumMemory(extent,\n          sizeof(*strip_pixels));\n        if (strip_pixels == (unsigned char *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(strip_pixels,0,extent*sizeof(*strip_pixels));\n        stride=TIFFVStripSize(tiff,1);\n        strip_id=0;\n        p=strip_pixels;\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          size_t\n            rows_remaining;\n\n          switch (i)\n          {\n            case 0: break;\n            case 1: quantum_type=GreenQuantum; break;\n            case 2: quantum_type=BlueQuantum; break;\n            case 3:\n            {\n              quantum_type=AlphaQuantum;\n              if (image->colorspace == CMYKColorspace)\n                quantum_type=BlackQuantum;\n              break;\n            }\n            case 4: quantum_type=AlphaQuantum; break;\n            default: break;\n          }\n          rows_remaining=0;\n          for (y=0; y < (ssize_t) image->rows; y++)\n          {\n            PixelPacket\n              *magick_restrict q;\n\n            q=GetAuthenticPixels(image,0,y,image->columns,1,exception);\n            if (q == (PixelPacket *) NULL)\n              break;\n            if (rows_remaining == 0)\n              {\n                strip_size=TIFFReadEncodedStrip(tiff,strip_id,strip_pixels,\n                  TIFFStripSize(tiff));\n                if (strip_size == -1)\n                  break;\n                rows_remaining=rows_per_strip;\n                if ((y+rows_per_strip) > (ssize_t) image->rows)\n                  rows_remaining=(rows_per_strip-(y+rows_per_strip-\n                    image->rows));\n                p=strip_pixels;\n                strip_id++;\n              }\n            (void) ImportQuantumPixels(image,(CacheView *) NULL,\n              quantum_info,quantum_type,p,exception);\n            p+=stride;\n            rows_remaining--;\n            if (SyncAuthenticPixels(image,exception) == MagickFalse)\n              break;\n            if (image->previous == (Image *) NULL)\n              {\n                status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                  image->rows);\n                if (status == MagickFalse)\n                  break;\n              }\n          }\n         if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE))\n            break;\n        }\n        strip_pixels=(unsigned char *) RelinquishMagickMemory(strip_pixels);\n        break;\n      }\n      case ReadTileMethod:\n      {\n        unsigned char\n          *p;\n\n        size_t\n          extent;\n\n        uint32\n          columns,\n          rows;\n\n        unsigned char\n          *tile_pixels;\n\n        \/*\n          Convert tiled TIFF image.\n        *\/\n        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||\n            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))\n          ThrowTIFFException(CoderError,\"ImageIsNotTiled\");\n        number_pixels=(MagickSizeType) columns*rows;\n        if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        extent=4*(samples_per_pixel+1)*MagickMax(rows*TIFFTileRowSize(tiff),\n          TIFFTileSize(tiff));\n        tile_pixels=(unsigned char *) AcquireQuantumMemory(extent,\n          sizeof(*tile_pixels));\n        if (tile_pixels == (unsigned char *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        (void) memset(tile_pixels,0,extent*sizeof(*tile_pixels));\n        for (i=0; i < (ssize_t) samples_per_pixel; i++)\n        {\n          switch (i)\n          {\n            case 0: break;\n            case 1: quantum_type=GreenQuantum; break;\n            case 2: quantum_type=BlueQuantum; break;\n            case 3:\n            {\n              quantum_type=AlphaQuantum;\n              if (image->colorspace == CMYKColorspace)\n                quantum_type=BlackQuantum;\n              break;\n            }\n            case 4: quantum_type=AlphaQuantum; break;\n            default: break;\n          }\n          for (y=0; y < (ssize_t) image->rows; y+=rows)\n          {\n            ssize_t\n              x;\n\n            size_t\n              rows_remaining;\n\n            rows_remaining=image->rows-y;\n            if ((ssize_t) (y+rows) < (ssize_t) image->rows)\n              rows_remaining=rows;\n            for (x=0; x < (ssize_t) image->columns; x+=columns)\n            {\n              size_t\n                columns_remaining,\n                row;\n\n              columns_remaining=image->columns-x;\n              if ((ssize_t) (x+columns) < (ssize_t) image->columns)\n                columns_remaining=columns;\n              tiff_status=TIFFReadTile(tiff,tile_pixels,(uint32) x,(uint32) y,\n                0,i);\n              if (tiff_status == -1)\n                break;\n              p=tile_pixels;\n              for (row=0; row < rows_remaining; row++)\n              {\n                PixelPacket\n                  *magick_restrict q;\n\n                q=GetAuthenticPixels(image,x,y+row,columns_remaining,1,\n                  exception);\n                if (q == (PixelPacket *) NULL)\n                  break;\n                (void) ImportQuantumPixels(image,(CacheView *) NULL,\n                  quantum_info,quantum_type,p,exception);\n                p+=TIFFTileRowSize(tiff);\n                if (SyncAuthenticPixels(image,exception) == MagickFalse)\n                  break;\n              }\n            }\n          }\n          if ((samples_per_pixel > 1) && (interlace != PLANARCONFIG_SEPARATE))\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) i,\n                samples_per_pixel);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        tile_pixels=(unsigned char *) RelinquishMagickMemory(tile_pixels);\n        break;\n      }\n      case ReadGenericMethod:\n      default:\n      {\n        MemoryInfo\n          *generic_info = (MemoryInfo *) NULL;\n\n        uint32\n          *p;\n\n        uint32\n          *pixels;\n\n        \/*\n          Convert generic TIFF image.\n        *\/\n        if (HeapOverflowSanityCheck(image->rows,sizeof(*pixels)) != MagickFalse)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        number_pixels=(MagickSizeType) image->columns*image->rows;\n        generic_info=AcquireVirtualMemory(number_pixels,sizeof(*pixels));\n        if (generic_info == (MemoryInfo *) NULL)\n          ThrowTIFFException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(uint32 *) GetVirtualMemoryBlob(generic_info);\n        tiff_status=TIFFReadRGBAImage(tiff,(uint32) image->columns,(uint32)\n          image->rows,(uint32 *) pixels,0);\n        if (tiff_status == -1)\n          {\n            generic_info=RelinquishVirtualMemory(generic_info);\n            break;\n          }\n        p=pixels+(image->columns*image->rows)-1;\n        for (y=0; y < (ssize_t) image->rows; y++)\n        {\n          ssize_t\n            x;\n\n          PixelPacket\n            *magick_restrict q;\n\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          q+=image->columns-1;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelRed(q,ScaleCharToQuantum((unsigned char) TIFFGetR(*p)));\n            SetPixelGreen(q,ScaleCharToQuantum((unsigned char) TIFFGetG(*p)));\n            SetPixelBlue(q,ScaleCharToQuantum((unsigned char) TIFFGetB(*p)));\n            if (image->matte == MagickFalse)\n              SetPixelOpacity(q,OpaqueOpacity);\n            else\n              SetPixelAlpha(q,ScaleCharToQuantum((unsigned char) TIFFGetA(*p)));\n            p--;\n            q--;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n                image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        generic_info=RelinquishVirtualMemory(generic_info);\n        break;\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    SetQuantumImageType(image,quantum_type);\n  next_tiff_frame:\n    if (quantum_info != (QuantumInfo *) NULL)\n      quantum_info=DestroyQuantumInfo(quantum_info);\n    if (tiff_status == -1)\n      {\n        status=MagickFalse;\n        break;\n      }\n    if (photometric == PHOTOMETRIC_CIELAB)\n      DecodeLabImage(image,exception);\n    if ((photometric == PHOTOMETRIC_LOGL) ||\n        (photometric == PHOTOMETRIC_MINISBLACK) ||\n        (photometric == PHOTOMETRIC_MINISWHITE))\n      {\n        image->type=GrayscaleType;\n        if (bits_per_sample == 1)\n          image->type=BilevelType;\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    more_frames=TIFFReadDirectory(tiff) != 0 ? MagickTrue : MagickFalse;\n    if (more_frames != MagickFalse)\n      {\n        \/*\n          Allocate next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,image->scene-1,\n          image->scene);\n        if (status == MagickFalse)\n          break;\n      }\n  } while ((status != MagickFalse) && (more_frames != MagickFalse));\n  TIFFClose(tiff);\n  if ((image_info->number_scenes != 0) &&\n      (image_info->scene >= GetImageListLength(image)))\n    status=MagickFalse;\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  TIFFReadPhotoshopLayers(image_info,image,exception);\n  return(GetFirstImageInList(image));\n}","target":1,"code_token_length":8612,"total_token_length":8848,"max_tokens_setting":11000}
+{"idx":195264,"func":"static void compile_xclass_matchingpath(compiler_common *common, PCRE2_SPTR cc, jump_list **backtracks)\n{\nDEFINE_COMPILER;\njump_list *found = NULL;\njump_list **list = (cc[0] & XCL_NOT) == 0 ? &found : backtracks;\nsljit_uw c, charoffset, max = 256, min = READ_CHAR_MAX;\nstruct sljit_jump *jump = NULL;\nPCRE2_SPTR ccbegin;\nint compares, invertcmp, numberofcmps;\n#if defined SUPPORT_UNICODE && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16)\nBOOL utf = common->utf;\n#endif \/* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == [8|16] *\/\n\n#ifdef SUPPORT_UNICODE\nsljit_u32 unicode_status = 0;\nint typereg = TMP1;\nconst sljit_u32 *other_cases;\nsljit_uw typeoffset;\n#endif \/* SUPPORT_UNICODE *\/\n\n\/* Scanning the necessary info. *\/\ncc++;\nccbegin = cc;\ncompares = 0;\n\nif (cc[-1] & XCL_MAP)\n  {\n  min = 0;\n  cc += 32 \/ sizeof(PCRE2_UCHAR);\n  }\n\nwhile (*cc != XCL_END)\n  {\n  compares++;\n  if (*cc == XCL_SINGLE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n    if (c > max) max = c;\n    if (c < min) min = c;\n#ifdef SUPPORT_UNICODE\n    unicode_status |= XCLASS_SAVE_CHAR;\n#endif \/* SUPPORT_UNICODE *\/\n    }\n  else if (*cc == XCL_RANGE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n    if (c < min) min = c;\n    GETCHARINCTEST(c, cc);\n    if (c > max) max = c;\n#ifdef SUPPORT_UNICODE\n    unicode_status |= XCLASS_SAVE_CHAR;\n#endif \/* SUPPORT_UNICODE *\/\n    }\n#ifdef SUPPORT_UNICODE\n  else\n    {\n    SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n    cc++;\n    if (*cc == PT_CLIST && *cc == XCL_PROP)\n      {\n      other_cases = PRIV(ucd_caseless_sets) + cc[1];\n      while (*other_cases != NOTACHAR)\n        {\n        if (*other_cases > max) max = *other_cases;\n        if (*other_cases < min) min = *other_cases;\n        other_cases++;\n        }\n      }\n    else\n      {\n      max = READ_CHAR_MAX;\n      min = 0;\n      }\n\n    switch(*cc)\n      {\n      case PT_ANY:\n      \/* Any either accepts everything or ignored. *\/\n      if (cc[-1] == XCL_PROP)\n        {\n        compile_char1_matchingpath(common, OP_ALLANY, cc, backtracks, FALSE);\n        if (list == backtracks)\n          add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n        return;\n        }\n      break;\n\n      case PT_LAMP:\n      case PT_GC:\n      case PT_PC:\n      case PT_ALNUM:\n      unicode_status |= XCLASS_HAS_TYPE;\n      break;\n\n      case PT_SCX:\n      unicode_status |= XCLASS_HAS_SCRIPT_EXTENSION;\n      if (cc[-1] == XCL_NOTPROP)\n        {\n        unicode_status |= XCLASS_SCRIPT_EXTENSION_NOTPROP;\n        break;\n        }\n      compares++;\n      \/* Fall through *\/ \n\n      case PT_SC:\n      unicode_status |= XCLASS_HAS_SCRIPT;\n      break;\n\n      case PT_SPACE:\n      case PT_PXSPACE:\n      case PT_WORD:\n      case PT_PXGRAPH:\n      case PT_PXPRINT:\n      case PT_PXPUNCT:\n      unicode_status |= XCLASS_SAVE_CHAR | XCLASS_HAS_TYPE;\n      break;\n\n      case PT_CLIST:\n      case PT_UCNC:\n      unicode_status |= XCLASS_SAVE_CHAR;\n      break;\n\n      case PT_BOOL:\n      unicode_status |= XCLASS_HAS_BOOL;\n      break;\n\n      case PT_BIDICL:\n      unicode_status |= XCLASS_HAS_BIDICL;\n      break;\n\n      default:\n      SLJIT_UNREACHABLE();\n      break;\n      }\n    cc += 2;\n    }\n#endif \/* SUPPORT_UNICODE *\/\n  }\nSLJIT_ASSERT(compares > 0);\n\n\/* We are not necessary in utf mode even in 8 bit mode. *\/\ncc = ccbegin;\nif ((cc[-1] & XCL_NOT) != 0)\n  read_char(common, min, max, backtracks, READ_CHAR_UPDATE_STR_PTR);\nelse\n  {\n#ifdef SUPPORT_UNICODE\n  read_char(common, min, max, (unicode_status & XCLASS_NEEDS_UCD) ? backtracks : NULL, 0);\n#else \/* !SUPPORT_UNICODE *\/\n  read_char(common, min, max, NULL, 0);\n#endif \/* SUPPORT_UNICODE *\/\n  }\n\nif ((cc[-1] & XCL_HASPROP) == 0)\n  {\n  if ((cc[-1] & XCL_MAP) != 0)\n    {\n    jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);\n    if (!optimize_class(common, (const sljit_u8 *)cc, (((const sljit_u8 *)cc)[31] & 0x80) != 0, TRUE, &found))\n      {\n      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);\n      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);\n      OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);\n      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);\n      OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);\n      add_jump(compiler, &found, JUMP(SLJIT_NOT_ZERO));\n      }\n\n    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));\n    JUMPHERE(jump);\n\n    cc += 32 \/ sizeof(PCRE2_UCHAR);\n    }\n  else\n    {\n    OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, min);\n    add_jump(compiler, (cc[-1] & XCL_NOT) == 0 ? backtracks : &found, CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, max - min));\n    }\n  }\nelse if ((cc[-1] & XCL_MAP) != 0)\n  {\n  OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);\n#ifdef SUPPORT_UNICODE\n  unicode_status |= XCLASS_CHAR_SAVED;\n#endif \/* SUPPORT_UNICODE *\/\n  if (!optimize_class(common, (const sljit_u8 *)cc, FALSE, TRUE, list))\n    {\n#if PCRE2_CODE_UNIT_WIDTH == 8\n    jump = NULL;\n    if (common->utf)\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 8 *\/\n      jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);\n\n    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);\n    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);\n    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);\n    OP2U(SLJIT_AND | SLJIT_SET_Z, TMP1, 0, TMP2, 0);\n    add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO));\n\n#if PCRE2_CODE_UNIT_WIDTH == 8\n    if (common->utf)\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 8 *\/\n      JUMPHERE(jump);\n    }\n\n  OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);\n  cc += 32 \/ sizeof(PCRE2_UCHAR);\n  }\n\n#ifdef SUPPORT_UNICODE\nif (unicode_status & XCLASS_NEEDS_UCD)\n  {\n  if ((unicode_status & (XCLASS_SAVE_CHAR | XCLASS_CHAR_SAVED)) == XCLASS_SAVE_CHAR)\n    OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);\n\n#if PCRE2_CODE_UNIT_WIDTH == 32\n  if (!common->utf)\n    {\n    jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1);\n    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, UNASSIGNED_UTF_CHAR);\n    JUMPHERE(jump);\n    }\n#endif \/* PCRE2_CODE_UNIT_WIDTH == 32 *\/\n\n  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);\n  OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));\n  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);\n  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);\n  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));\n  OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);\n  OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3);\n  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);\n  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);\n\n  ccbegin = cc;\n\n  if (unicode_status & XCLASS_HAS_BIDICL)\n    {\n    OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, scriptx_bidiclass));\n    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BIDICLASS_SHIFT);\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        if (*cc == PT_BIDICL)\n          {\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n          if (cc[-1] == XCL_NOTPROP)\n            invertcmp ^= 0x1;\n          jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1]);\n          add_jump(compiler, compares > 0 ? list : backtracks, jump);\n          }\n        cc += 2;\n        }\n      }\n\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_HAS_BOOL)\n    {\n    OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, bprops));\n    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BPROPS_MASK);\n    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2);\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        if (*cc == PT_BOOL)\n          {\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n          if (cc[-1] == XCL_NOTPROP)\n            invertcmp ^= 0x1;\n\n          OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), (sljit_sw)(PRIV(ucd_boolprop_sets) + (cc[1] >> 5)), SLJIT_IMM, (sljit_sw)1 << (cc[1] & 0x1f));\n          add_jump(compiler, compares > 0 ? list : backtracks, JUMP(SLJIT_NOT_ZERO ^ invertcmp));\n          }\n        cc += 2;\n        }\n      }\n\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_HAS_SCRIPT)\n    {\n    OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        switch (*cc)\n          {\n          case PT_SCX:\n          if (cc[-1] == XCL_NOTPROP)\n            break;\n          \/* Fall through *\/ \n\n          case PT_SC:\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n          if (cc[-1] == XCL_NOTPROP)\n            invertcmp ^= 0x1;\n\n          add_jump(compiler, compares > 0 ? list : backtracks, CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (int)cc[1]));\n          }\n        cc += 2;\n        }\n      }\n\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_HAS_SCRIPT_EXTENSION)\n    {\n    OP1(SLJIT_MOV_U16, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, scriptx_bidiclass));\n    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_SCRIPTX_MASK);\n    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2);\n\n    if (unicode_status & XCLASS_SCRIPT_EXTENSION_NOTPROP)\n      {\n      if (unicode_status & XCLASS_HAS_TYPE)\n        {\n        if (unicode_status & XCLASS_SAVE_CHAR)\n          {\n          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, TMP2, 0);\n          unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0;\n          }\n        else\n          {\n          OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP2, 0);\n          unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR;\n          }\n        }\n      OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));\n      }\n\n    while (*cc != XCL_END)\n      {\n      if (*cc == XCL_SINGLE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        }\n      else if (*cc == XCL_RANGE)\n        {\n        cc ++;\n        GETCHARINCTEST(c, cc);\n        GETCHARINCTEST(c, cc);\n        }\n      else\n        {\n        SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n        cc++;\n        if (*cc == PT_SCX)\n          {\n          compares--;\n          invertcmp = (compares == 0 && list != backtracks);\n\n          jump = NULL;\n          if (cc[-1] == XCL_NOTPROP)\n            {\n            jump = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, (int)cc[1]);\n            if (invertcmp)\n              {\n              add_jump(compiler, backtracks, jump);\n              jump = NULL;\n              }\n            invertcmp ^= 0x1;\n            }\n\n          OP2U(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_MEM1(TMP1), (sljit_sw)(PRIV(ucd_script_sets) + (cc[1] >> 5)), SLJIT_IMM, (sljit_sw)1 << (cc[1] & 0x1f));\n          add_jump(compiler, compares > 0 ? list : backtracks, JUMP(SLJIT_NOT_ZERO ^ invertcmp));\n\n          if (jump != NULL)\n            JUMPHERE(jump);\n          }\n        cc += 2;\n        }\n      }\n\n    if (unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0)\n      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);\n    else if (unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR)\n      OP1(SLJIT_MOV, TMP2, 0, RETURN_ADDR, 0);\n    cc = ccbegin;\n    }\n\n  if (unicode_status & XCLASS_SAVE_CHAR)\n    OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);\n\n  if (unicode_status & XCLASS_HAS_TYPE)\n    {\n    if (unicode_status & XCLASS_SAVE_CHAR)\n      typereg = RETURN_ADDR;\n\n    OP1(SLJIT_MOV_U8, typereg, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));\n    }\n  }\n#endif \/* SUPPORT_UNICODE *\/\n\n\/* Generating code. *\/\ncharoffset = 0;\nnumberofcmps = 0;\n#ifdef SUPPORT_UNICODE\ntypeoffset = 0;\n#endif \/* SUPPORT_UNICODE *\/\n\nwhile (*cc != XCL_END)\n  {\n  compares--;\n  invertcmp = (compares == 0 && list != backtracks);\n  jump = NULL;\n\n  if (*cc == XCL_SINGLE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n\n    if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n      numberofcmps++;\n      }\n    else if (numberofcmps > 0)\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      numberofcmps = 0;\n      }\n    else\n      {\n      jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      numberofcmps = 0;\n      }\n    }\n  else if (*cc == XCL_RANGE)\n    {\n    cc ++;\n    GETCHARINCTEST(c, cc);\n    SET_CHAR_OFFSET(c);\n    GETCHARINCTEST(c, cc);\n\n    if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);\n      numberofcmps++;\n      }\n    else if (numberofcmps > 0)\n      {\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      numberofcmps = 0;\n      }\n    else\n      {\n      jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));\n      numberofcmps = 0;\n      }\n    }\n#ifdef SUPPORT_UNICODE\n  else\n    {\n    SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);\n    if (*cc == XCL_NOTPROP)\n      invertcmp ^= 0x1;\n    cc++;\n    switch(*cc)\n      {\n      case PT_ANY:\n      if (!invertcmp)\n        jump = JUMP(SLJIT_JUMP);\n      break;\n\n      case PT_LAMP:\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Lu - typeoffset);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Ll - typeoffset);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Lt - typeoffset);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_GC:\n      c = PRIV(ucp_typerange)[(int)cc[1] * 2];\n      SET_TYPE_OFFSET(c);\n      jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, PRIV(ucp_typerange)[(int)cc[1] * 2 + 1] - c);\n      break;\n\n      case PT_PC:\n      jump = CMP(SLJIT_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, (int)cc[1] - typeoffset);\n      break;\n\n      case PT_SC:\n      case PT_SCX:\n      case PT_BOOL:\n      case PT_BIDICL:\n      compares++;\n      \/* Do nothing. *\/\n      break;\n\n      case PT_SPACE:\n      case PT_PXSPACE:\n      SET_CHAR_OFFSET(9);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0xd - 0x9);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x85 - 0x9);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x9);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      SET_TYPE_OFFSET(ucp_Zl);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Zl);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_WORD:\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_UNDERSCORE - charoffset));\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n      \/* Fall through. *\/\n\n      case PT_ALNUM:\n      SET_TYPE_OFFSET(ucp_Ll);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);\n      OP_FLAGS((*cc == PT_ALNUM) ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);\n      SET_TYPE_OFFSET(ucp_Nd);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_No - ucp_Nd);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_CLIST:\n      other_cases = PRIV(ucd_caseless_sets) + cc[1];\n\n      \/* At least three characters are required.\n         Otherwise this case would be handled by the normal code path. *\/\n      SLJIT_ASSERT(other_cases[0] != NOTACHAR && other_cases[1] != NOTACHAR && other_cases[2] != NOTACHAR);\n      SLJIT_ASSERT(other_cases[0] < other_cases[1] && other_cases[1] < other_cases[2]);\n\n      \/* Optimizing character pairs, if their difference is power of 2. *\/\n      if (is_powerof2(other_cases[1] ^ other_cases[0]))\n        {\n        if (charoffset == 0)\n          OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);\n        else\n          {\n          OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);\n          OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);\n          }\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, other_cases[1]);\n        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n        other_cases += 2;\n        }\n      else if (is_powerof2(other_cases[2] ^ other_cases[1]))\n        {\n        if (charoffset == 0)\n          OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);\n        else\n          {\n          OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);\n          OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);\n          }\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, other_cases[2]);\n        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(other_cases[0] - charoffset));\n        OP_FLAGS(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_Z : 0), TMP2, 0, SLJIT_EQUAL);\n\n        other_cases += 3;\n        }\n      else\n        {\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset));\n        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n        }\n\n      while (*other_cases != NOTACHAR)\n        {\n        OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset));\n        OP_FLAGS(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_Z : 0), TMP2, 0, SLJIT_EQUAL);\n        }\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_UCNC:\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_DOLLAR_SIGN - charoffset));\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_COMMERCIAL_AT - charoffset));\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_GRAVE_ACCENT - charoffset));\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      SET_CHAR_OFFSET(0xa0);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw)(0xd7ff - charoffset));\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);\n      SET_CHAR_OFFSET(0);\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xe000 - 0);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_GREATER_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      case PT_PXGRAPH:\n      \/* C and Z groups are the farthest two groups. *\/\n      SET_TYPE_OFFSET(ucp_Ll);\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_GREATER);\n\n      jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);\n\n      \/* In case of ucp_Cf, we overwrite the result. *\/\n      SET_CHAR_OFFSET(0x2066);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      JUMPHERE(jump);\n      jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);\n      break;\n\n      case PT_PXPRINT:\n      \/* C and Z groups are the farthest two groups. *\/\n      SET_TYPE_OFFSET(ucp_Ll);\n      OP2U(SLJIT_SUB | SLJIT_SET_GREATER, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_GREATER);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Ll);\n      OP_FLAGS(SLJIT_AND, TMP2, 0, SLJIT_NOT_EQUAL);\n\n      jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);\n\n      \/* In case of ucp_Cf, we overwrite the result. *\/\n      SET_CHAR_OFFSET(0x2066);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);\n      OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);\n\n      JUMPHERE(jump);\n      jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);\n      break;\n\n      case PT_PXPUNCT:\n      SET_TYPE_OFFSET(ucp_Sc);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_So - ucp_Sc);\n      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      SET_CHAR_OFFSET(0);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x7f);\n      OP_FLAGS(SLJIT_AND, TMP2, 0, SLJIT_LESS_EQUAL);\n\n      SET_TYPE_OFFSET(ucp_Pc);\n      OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, typereg, 0, SLJIT_IMM, ucp_Ps - ucp_Pc);\n      OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_LESS_EQUAL);\n      jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);\n      break;\n\n      default:\n      SLJIT_UNREACHABLE();\n      break;\n      }\n    cc += 2;\n    }\n#endif \/* SUPPORT_UNICODE *\/\n\n  if (jump != NULL)\n    add_jump(compiler, compares > 0 ? list : backtracks, jump);\n  }\n\nif (found != NULL)\n  set_jumps(found, LABEL());\n}","target":1,"code_token_length":8102,"total_token_length":8338,"max_tokens_setting":11000}
+{"idx":294626,"func":"Init_date_core(void)\n{\n    #ifdef HAVE_RB_EXT_RACTOR_SAFE\n\tRB_EXT_RACTOR_SAFE(true);\n    #endif\n    id_cmp = rb_intern_const(\"<=>\");\n    id_le_p = rb_intern_const(\"<=\");\n    id_ge_p = rb_intern_const(\">=\");\n    id_eqeq_p = rb_intern_const(\"==\");\n\n    half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2));\n\n#if (LONG_MAX \/ DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS\n    day_in_nanoseconds = LONG2NUM((long)DAY_IN_SECONDS *\n\t\t\t\t  SECOND_IN_NANOSECONDS);\n#elif defined HAVE_LONG_LONG\n    day_in_nanoseconds = LL2NUM((LONG_LONG)DAY_IN_SECONDS *\n\t\t\t\tSECOND_IN_NANOSECONDS);\n#else\n    day_in_nanoseconds = f_mul(INT2FIX(DAY_IN_SECONDS),\n\t\t\t       INT2FIX(SECOND_IN_NANOSECONDS));\n#endif\n\n    rb_gc_register_mark_object(half_days_in_day);\n    rb_gc_register_mark_object(day_in_nanoseconds);\n\n    positive_inf = +INFINITY;\n    negative_inf = -INFINITY;\n\n    \/*\n     * date and datetime class - Tadayoshi Funaba 1998-2011\n     *\n     * 'date' provides two classes: Date and DateTime.\n     *\n     * == Terms and Definitions\n     *\n     * Some terms and definitions are based on ISO 8601 and JIS X 0301.\n     *\n     * === Calendar Date\n     *\n     * The calendar date is a particular day of a calendar year,\n     * identified by its ordinal number within a calendar month within\n     * that year.\n     *\n     * In those classes, this is so-called \"civil\".\n     *\n     * === Ordinal Date\n     *\n     * The ordinal date is a particular day of a calendar year identified\n     * by its ordinal number within the year.\n     *\n     * In those classes, this is so-called \"ordinal\".\n     *\n     * === Week Date\n     *\n     * The week date is a date identified by calendar week and day numbers.\n     *\n     * The calendar week is a seven day period within a calendar year,\n     * starting on a Monday and identified by its ordinal number within\n     * the year; the first calendar week of the year is the one that\n     * includes the first Thursday of that year. In the Gregorian\n     * calendar, this is equivalent to the week which includes January 4.\n     *\n     * In those classes, this is so-called \"commercial\".\n     *\n     * === Julian Day Number\n     *\n     * The Julian day number is in elapsed days since noon (Greenwich Mean\n     * Time) on January 1, 4713 BCE (in the Julian calendar).\n     *\n     * In this document, the astronomical Julian day number is the same as\n     * the original Julian day number. And the chronological Julian day\n     * number is a variation of the Julian day number. Its days begin at\n     * midnight on local time.\n     *\n     * In this document, when the term \"Julian day number\" simply appears,\n     * it just refers to \"chronological Julian day number\", not the\n     * original.\n     *\n     * In those classes, those are so-called \"ajd\" and \"jd\".\n     *\n     * === Modified Julian Day Number\n     *\n     * The modified Julian day number is in elapsed days since midnight\n     * (Coordinated Universal Time) on November 17, 1858 CE (in the\n     * Gregorian calendar).\n     *\n     * In this document, the astronomical modified Julian day number is\n     * the same as the original modified Julian day number. And the\n     * chronological modified Julian day number is a variation of the\n     * modified Julian day number. Its days begin at midnight on local\n     * time.\n     *\n     * In this document, when the term \"modified Julian day number\" simply\n     * appears, it just refers to \"chronological modified Julian day\n     * number\", not the original.\n     *\n     * In those classes, those are so-called \"amjd\" and \"mjd\".\n     *\n     * == Date\n     *\n     * A subclass of Object that includes the Comparable module and\n     * easily handles date.\n     *\n     * A Date object is created with Date::new, Date::jd, Date::ordinal,\n     * Date::commercial, Date::parse, Date::strptime, Date::today,\n     * Time#to_date, etc.\n     *\n     *     require 'date'\n     *\n     *     Date.new(2001,2,3)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.jd(2451944)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.ordinal(2001,34)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.commercial(2001,5,6)\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.parse('2001-02-03')\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Date.strptime('03-02-2001', '%d-%m-%Y')\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *     Time.new(2001,2,3).to_date\n     *\t    #=> #<Date: 2001-02-03 ...>\n     *\n     * All date objects are immutable; hence cannot modify themselves.\n     *\n     * The concept of a date object can be represented as a tuple\n     * of the day count, the offset and the day of calendar reform.\n     *\n     * The day count denotes the absolute position of a temporal\n     * dimension. The offset is relative adjustment, which determines\n     * decoded local time with the day count. The day of calendar\n     * reform denotes the start day of the new style. The old style\n     * of the West is the Julian calendar which was adopted by\n     * Caesar. The new style is the Gregorian calendar, which is the\n     * current civil calendar of many countries.\n     *\n     * The day count is virtually the astronomical Julian day number.\n     * The offset in this class is usually zero, and cannot be\n     * specified directly.\n     *\n     * A Date object can be created with an optional argument,\n     * the day of calendar reform as a Julian day number, which\n     * should be 2298874 to 2426355 or negative\/positive infinity.\n     * The default value is +Date::ITALY+ (2299161=1582-10-15).\n     * See also sample\/cal.rb.\n     *\n     *     $ ruby sample\/cal.rb -c it 10 1582\n     *         October 1582\n     *      S  M Tu  W Th  F  S\n     *         1  2  3  4 15 16\n     *     17 18 19 20 21 22 23\n     *     24 25 26 27 28 29 30\n     *     31\n     *\n     *     $ ruby sample\/cal.rb -c gb  9 1752\n     *        September 1752\n     *      S  M Tu  W Th  F  S\n     *            1  2 14 15 16\n     *     17 18 19 20 21 22 23\n     *     24 25 26 27 28 29 30\n     *\n     * A Date object has various methods. See each reference.\n     *\n     *     d = Date.parse('3rd Feb 2001')\n     *\t\t\t\t\t#=> #<Date: 2001-02-03 ...>\n     *     d.year\t\t\t#=> 2001\n     *     d.mon\t\t\t#=> 2\n     *     d.mday\t\t\t#=> 3\n     *     d.wday\t\t\t#=> 6\n     *     d += 1\t\t\t#=> #<Date: 2001-02-04 ...>\n     *     d.strftime('%a %d %b %Y')\t#=> \"Sun 04 Feb 2001\"\n     *\n     *\/\n    cDate = rb_define_class(\"Date\", rb_cObject);\n    eDateError = rb_define_class_under(cDate, \"Error\", rb_eArgError);\n\n    rb_include_module(cDate, rb_mComparable);\n\n    \/* An array of strings of full month names in English.  The first\n     * element is nil.\n     *\/\n    rb_define_const(cDate, \"MONTHNAMES\", mk_ary_of_str(13, monthnames));\n\n    \/* An array of strings of abbreviated month names in English.  The\n     * first element is nil.\n     *\/\n    rb_define_const(cDate, \"ABBR_MONTHNAMES\",\n\t\t    mk_ary_of_str(13, abbr_monthnames));\n\n    \/* An array of strings of the full names of days of the week in English.\n     * The first is \"Sunday\".\n     *\/\n    rb_define_const(cDate, \"DAYNAMES\", mk_ary_of_str(7, daynames));\n\n    \/* An array of strings of abbreviated day names in English.  The\n     * first is \"Sun\".\n     *\/\n    rb_define_const(cDate, \"ABBR_DAYNAMES\", mk_ary_of_str(7, abbr_daynames));\n\n    \/* The Julian day number of the day of calendar reform for Italy\n     * and some catholic countries.\n     *\/\n    rb_define_const(cDate, \"ITALY\", INT2FIX(ITALY));\n\n    \/* The Julian day number of the day of calendar reform for England\n     * and her colonies.\n     *\/\n    rb_define_const(cDate, \"ENGLAND\", INT2FIX(ENGLAND));\n\n    \/* The Julian day number of the day of calendar reform for the\n     * proleptic Julian calendar.\n     *\/\n    rb_define_const(cDate, \"JULIAN\", DBL2NUM(JULIAN));\n\n    \/* The Julian day number of the day of calendar reform for the\n     * proleptic Gregorian calendar.\n     *\/\n    rb_define_const(cDate, \"GREGORIAN\", DBL2NUM(GREGORIAN));\n\n    rb_define_alloc_func(cDate, d_lite_s_alloc_simple);\n\n#ifndef NDEBUG\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_jd?\",\n\t\t\t     date_s__valid_jd_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_ordinal?\",\n\t\t\t     date_s__valid_ordinal_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_civil?\",\n\t\t\t     date_s__valid_civil_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_date?\",\n\t\t\t     date_s__valid_civil_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_commercial?\",\n\t\t\t     date_s__valid_commercial_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_weeknum?\",\n\t\t\t     date_s__valid_weeknum_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"_valid_nth_kday?\",\n\t\t\t     date_s__valid_nth_kday_p, -1);\n#endif\n\n    rb_define_singleton_method(cDate, \"valid_jd?\", date_s_valid_jd_p, -1);\n    rb_define_singleton_method(cDate, \"valid_ordinal?\",\n\t\t\t       date_s_valid_ordinal_p, -1);\n    rb_define_singleton_method(cDate, \"valid_civil?\", date_s_valid_civil_p, -1);\n    rb_define_singleton_method(cDate, \"valid_date?\", date_s_valid_civil_p, -1);\n    rb_define_singleton_method(cDate, \"valid_commercial?\",\n\t\t\t       date_s_valid_commercial_p, -1);\n\n#ifndef NDEBUG\n    rb_define_private_method(CLASS_OF(cDate), \"valid_weeknum?\",\n\t\t\t     date_s_valid_weeknum_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"valid_nth_kday?\",\n\t\t\t     date_s_valid_nth_kday_p, -1);\n    rb_define_private_method(CLASS_OF(cDate), \"zone_to_diff\",\n\t\t\t     date_s_zone_to_diff, 1);\n#endif\n\n    rb_define_singleton_method(cDate, \"julian_leap?\", date_s_julian_leap_p, 1);\n    rb_define_singleton_method(cDate, \"gregorian_leap?\",\n\t\t\t       date_s_gregorian_leap_p, 1);\n    rb_define_singleton_method(cDate, \"leap?\",\n\t\t\t       date_s_gregorian_leap_p, 1);\n\n#ifndef NDEBUG\n    rb_define_singleton_method(cDate, \"new!\", date_s_new_bang, -1);\n    rb_define_alias(rb_singleton_class(cDate), \"new_l!\", \"new\");\n#endif\n\n    rb_define_singleton_method(cDate, \"jd\", date_s_jd, -1);\n    rb_define_singleton_method(cDate, \"ordinal\", date_s_ordinal, -1);\n    rb_define_singleton_method(cDate, \"civil\", date_s_civil, -1);\n    rb_define_singleton_method(cDate, \"commercial\", date_s_commercial, -1);\n\n#ifndef NDEBUG\n    rb_define_singleton_method(cDate, \"weeknum\", date_s_weeknum, -1);\n    rb_define_singleton_method(cDate, \"nth_kday\", date_s_nth_kday, -1);\n#endif\n\n    rb_define_singleton_method(cDate, \"today\", date_s_today, -1);\n    rb_define_singleton_method(cDate, \"_strptime\", date_s__strptime, -1);\n    rb_define_singleton_method(cDate, \"strptime\", date_s_strptime, -1);\n    rb_define_singleton_method(cDate, \"_parse\", date_s__parse, -1);\n    rb_define_singleton_method(cDate, \"parse\", date_s_parse, -1);\n    rb_define_singleton_method(cDate, \"_iso8601\", date_s__iso8601, -1);\n    rb_define_singleton_method(cDate, \"iso8601\", date_s_iso8601, -1);\n    rb_define_singleton_method(cDate, \"_rfc3339\", date_s__rfc3339, -1);\n    rb_define_singleton_method(cDate, \"rfc3339\", date_s_rfc3339, -1);\n    rb_define_singleton_method(cDate, \"_xmlschema\", date_s__xmlschema, -1);\n    rb_define_singleton_method(cDate, \"xmlschema\", date_s_xmlschema, -1);\n    rb_define_singleton_method(cDate, \"_rfc2822\", date_s__rfc2822, -1);\n    rb_define_singleton_method(cDate, \"_rfc822\", date_s__rfc2822, -1);\n    rb_define_singleton_method(cDate, \"rfc2822\", date_s_rfc2822, -1);\n    rb_define_singleton_method(cDate, \"rfc822\", date_s_rfc2822, -1);\n    rb_define_singleton_method(cDate, \"_httpdate\", date_s__httpdate, -1);\n    rb_define_singleton_method(cDate, \"httpdate\", date_s_httpdate, -1);\n    rb_define_singleton_method(cDate, \"_jisx0301\", date_s__jisx0301, -1);\n    rb_define_singleton_method(cDate, \"jisx0301\", date_s_jisx0301, -1);\n\n    rb_define_method(cDate, \"initialize\", date_initialize, -1);\n    rb_define_method(cDate, \"initialize_copy\", d_lite_initialize_copy, 1);\n\n#ifndef NDEBUG\n    rb_define_method(cDate, \"fill\", d_lite_fill, 0);\n#endif\n\n    rb_define_method(cDate, \"ajd\", d_lite_ajd, 0);\n    rb_define_method(cDate, \"amjd\", d_lite_amjd, 0);\n    rb_define_method(cDate, \"jd\", d_lite_jd, 0);\n    rb_define_method(cDate, \"mjd\", d_lite_mjd, 0);\n    rb_define_method(cDate, \"ld\", d_lite_ld, 0);\n\n    rb_define_method(cDate, \"year\", d_lite_year, 0);\n    rb_define_method(cDate, \"yday\", d_lite_yday, 0);\n    rb_define_method(cDate, \"mon\", d_lite_mon, 0);\n    rb_define_method(cDate, \"month\", d_lite_mon, 0);\n    rb_define_method(cDate, \"mday\", d_lite_mday, 0);\n    rb_define_method(cDate, \"day\", d_lite_mday, 0);\n    rb_define_method(cDate, \"day_fraction\", d_lite_day_fraction, 0);\n\n    rb_define_method(cDate, \"cwyear\", d_lite_cwyear, 0);\n    rb_define_method(cDate, \"cweek\", d_lite_cweek, 0);\n    rb_define_method(cDate, \"cwday\", d_lite_cwday, 0);\n\n#ifndef NDEBUG\n    rb_define_private_method(cDate, \"wnum0\", d_lite_wnum0, 0);\n    rb_define_private_method(cDate, \"wnum1\", d_lite_wnum1, 0);\n#endif\n\n    rb_define_method(cDate, \"wday\", d_lite_wday, 0);\n\n    rb_define_method(cDate, \"sunday?\", d_lite_sunday_p, 0);\n    rb_define_method(cDate, \"monday?\", d_lite_monday_p, 0);\n    rb_define_method(cDate, \"tuesday?\", d_lite_tuesday_p, 0);\n    rb_define_method(cDate, \"wednesday?\", d_lite_wednesday_p, 0);\n    rb_define_method(cDate, \"thursday?\", d_lite_thursday_p, 0);\n    rb_define_method(cDate, \"friday?\", d_lite_friday_p, 0);\n    rb_define_method(cDate, \"saturday?\", d_lite_saturday_p, 0);\n\n#ifndef NDEBUG\n    rb_define_method(cDate, \"nth_kday?\", d_lite_nth_kday_p, 2);\n#endif\n\n    rb_define_private_method(cDate, \"hour\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"min\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"minute\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"sec\", d_lite_zero, 0);\n    rb_define_private_method(cDate, \"second\", d_lite_zero, 0);\n\n    rb_define_method(cDate, \"julian?\", d_lite_julian_p, 0);\n    rb_define_method(cDate, \"gregorian?\", d_lite_gregorian_p, 0);\n    rb_define_method(cDate, \"leap?\", d_lite_leap_p, 0);\n\n    rb_define_method(cDate, \"start\", d_lite_start, 0);\n    rb_define_method(cDate, \"new_start\", d_lite_new_start, -1);\n    rb_define_method(cDate, \"italy\", d_lite_italy, 0);\n    rb_define_method(cDate, \"england\", d_lite_england, 0);\n    rb_define_method(cDate, \"julian\", d_lite_julian, 0);\n    rb_define_method(cDate, \"gregorian\", d_lite_gregorian, 0);\n\n    rb_define_method(cDate, \"+\", d_lite_plus, 1);\n    rb_define_method(cDate, \"-\", d_lite_minus, 1);\n\n    rb_define_method(cDate, \"next_day\", d_lite_next_day, -1);\n    rb_define_method(cDate, \"prev_day\", d_lite_prev_day, -1);\n    rb_define_method(cDate, \"next\", d_lite_next, 0);\n    rb_define_method(cDate, \"succ\", d_lite_next, 0);\n\n    rb_define_method(cDate, \">>\", d_lite_rshift, 1);\n    rb_define_method(cDate, \"<<\", d_lite_lshift, 1);\n\n    rb_define_method(cDate, \"next_month\", d_lite_next_month, -1);\n    rb_define_method(cDate, \"prev_month\", d_lite_prev_month, -1);\n    rb_define_method(cDate, \"next_year\", d_lite_next_year, -1);\n    rb_define_method(cDate, \"prev_year\", d_lite_prev_year, -1);\n\n    rb_define_method(cDate, \"step\", d_lite_step, -1);\n    rb_define_method(cDate, \"upto\", d_lite_upto, 1);\n    rb_define_method(cDate, \"downto\", d_lite_downto, 1);\n\n    rb_define_method(cDate, \"<=>\", d_lite_cmp, 1);\n    rb_define_method(cDate, \"===\", d_lite_equal, 1);\n    rb_define_method(cDate, \"eql?\", d_lite_eql_p, 1);\n    rb_define_method(cDate, \"hash\", d_lite_hash, 0);\n\n    rb_define_method(cDate, \"to_s\", d_lite_to_s, 0);\n#ifndef NDEBUG\n    rb_define_method(cDate, \"inspect_raw\", d_lite_inspect_raw, 0);\n#endif\n    rb_define_method(cDate, \"inspect\", d_lite_inspect, 0);\n\n    rb_define_method(cDate, \"strftime\", d_lite_strftime, -1);\n\n    rb_define_method(cDate, \"asctime\", d_lite_asctime, 0);\n    rb_define_method(cDate, \"ctime\", d_lite_asctime, 0);\n    rb_define_method(cDate, \"iso8601\", d_lite_iso8601, 0);\n    rb_define_method(cDate, \"xmlschema\", d_lite_iso8601, 0);\n    rb_define_method(cDate, \"rfc3339\", d_lite_rfc3339, 0);\n    rb_define_method(cDate, \"rfc2822\", d_lite_rfc2822, 0);\n    rb_define_method(cDate, \"rfc822\", d_lite_rfc2822, 0);\n    rb_define_method(cDate, \"httpdate\", d_lite_httpdate, 0);\n    rb_define_method(cDate, \"jisx0301\", d_lite_jisx0301, 0);\n\n#ifndef NDEBUG\n    rb_define_method(cDate, \"marshal_dump_old\", d_lite_marshal_dump_old, 0);\n#endif\n    rb_define_method(cDate, \"marshal_dump\", d_lite_marshal_dump, 0);\n    rb_define_method(cDate, \"marshal_load\", d_lite_marshal_load, 1);\n    rb_define_singleton_method(cDate, \"_load\", date_s__load, 1);\n\n    \/*\n     * == DateTime\n     *\n     * A subclass of Date that easily handles date, hour, minute, second,\n     * and offset.\n     *\n     * DateTime class is considered deprecated. Use Time class.\n     *\n     * DateTime does not consider any leap seconds, does not track\n     * any summer time rules.\n     *\n     * A DateTime object is created with DateTime::new, DateTime::jd,\n     * DateTime::ordinal, DateTime::commercial, DateTime::parse,\n     * DateTime::strptime, DateTime::now, Time#to_datetime, etc.\n     *\n     *     require 'date'\n     *\n     *     DateTime.new(2001,2,3,4,5,6)\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>\n     *\n     * The last element of day, hour, minute, or second can be a\n     * fractional number. The fractional number's precision is assumed\n     * at most nanosecond.\n     *\n     *     DateTime.new(2001,2,3.5)\n     *                         #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>\n     *\n     * An optional argument, the offset, indicates the difference\n     * between the local time and UTC. For example, <tt>Rational(3,24)<\/tt>\n     * represents ahead of 3 hours of UTC, <tt>Rational(-5,24)<\/tt> represents\n     * behind of 5 hours of UTC. The offset should be -1 to +1, and\n     * its precision is assumed at most second. The default value is\n     * zero (equals to UTC).\n     *\n     *     DateTime.new(2001,2,3,4,5,6,Rational(3,24))\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>\n     *\n     * The offset also accepts string form:\n     *\n     *     DateTime.new(2001,2,3,4,5,6,'+03:00')\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>\n     *\n     * An optional argument, the day of calendar reform (+start+), denotes\n     * a Julian day number, which should be 2298874 to 2426355 or\n     * negative\/positive infinity.\n     * The default value is +Date::ITALY+ (2299161=1582-10-15).\n     *\n     * A DateTime object has various methods. See each reference.\n     *\n     *     d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')\n     *                         #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>\n     *     d.hour              #=> 4\n     *     d.min               #=> 5\n     *     d.sec               #=> 6\n     *     d.offset            #=> (7\/48)\n     *     d.zone              #=> \"+03:30\"\n     *     d += Rational('1.5')\n     *                         #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...>\n     *     d = d.new_offset('+09:00')\n     *                         #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...>\n     *     d.strftime('%I:%M:%S %p')\n     *                         #=> \"09:35:06 PM\"\n     *     d > DateTime.new(1999)\n     *                         #=> true\n     *\n     * === When should you use DateTime and when should you use Time?\n     *\n     * It's a common misconception that\n     * {William Shakespeare}[https:\/\/en.wikipedia.org\/wiki\/William_Shakespeare]\n     * and\n     * {Miguel de Cervantes}[https:\/\/en.wikipedia.org\/wiki\/Miguel_de_Cervantes]\n     * died on the same day in history -\n     * so much so that UNESCO named April 23 as\n     * {World Book Day because of this fact}[https:\/\/en.wikipedia.org\/wiki\/World_Book_Day].\n     * However, because England hadn't yet adopted the\n     * {Gregorian Calendar Reform}[https:\/\/en.wikipedia.org\/wiki\/Gregorian_calendar#Gregorian_reform]\n     * (and wouldn't until {1752}[https:\/\/en.wikipedia.org\/wiki\/Calendar_(New_Style)_Act_1750])\n     * their deaths are actually 10 days apart.\n     * Since Ruby's Time class implements a\n     * {proleptic Gregorian calendar}[https:\/\/en.wikipedia.org\/wiki\/Proleptic_Gregorian_calendar]\n     * and has no concept of calendar reform there's no way\n     * to express this with Time objects. This is where DateTime steps in:\n     *\n     *     shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)\n     *      #=> Tue, 23 Apr 1616 00:00:00 +0000\n     *     cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)\n     *      #=> Sat, 23 Apr 1616 00:00:00 +0000\n     *\n     * Already you can see something is weird - the days of the week\n     * are different. Taking this further:\n     *\n     *     cervantes == shakespeare\n     *      #=> false\n     *     (shakespeare - cervantes).to_i\n     *      #=> 10\n     *\n     * This shows that in fact they died 10 days apart (in reality\n     * 11 days since Cervantes died a day earlier but was buried on\n     * the 23rd). We can see the actual date of Shakespeare's death by\n     * using the #gregorian method to convert it:\n     *\n     *     shakespeare.gregorian\n     *      #=> Tue, 03 May 1616 00:00:00 +0000\n     *\n     * So there's an argument that all the celebrations that take\n     * place on the 23rd April in Stratford-upon-Avon are actually\n     * the wrong date since England is now using the Gregorian calendar.\n     * You can see why when we transition across the reform\n     * date boundary:\n     *\n     *     # start off with the anniversary of Shakespeare's birth in 1751\n     *     shakespeare = DateTime.iso8601('1751-04-23', Date::ENGLAND)\n     *      #=> Tue, 23 Apr 1751 00:00:00 +0000\n     *\n     *     # add 366 days since 1752 is a leap year and April 23 is after February 29\n     *     shakespeare + 366\n     *      #=> Thu, 23 Apr 1752 00:00:00 +0000\n     *\n     *     # add another 365 days to take us to the anniversary in 1753\n     *     shakespeare + 366 + 365\n     *      #=> Fri, 04 May 1753 00:00:00 +0000\n     *\n     * As you can see, if we're accurately tracking the number of\n     * {solar years}[https:\/\/en.wikipedia.org\/wiki\/Tropical_year]\n     * since Shakespeare's birthday then the correct anniversary date\n     * would be the 4th May and not the 23rd April.\n     *\n     * So when should you use DateTime in Ruby and when should\n     * you use Time? Almost certainly you'll want to use Time\n     * since your app is probably dealing with current dates and\n     * times. However, if you need to deal with dates and times in a\n     * historical context you'll want to use DateTime to avoid\n     * making the same mistakes as UNESCO. If you also have to deal\n     * with timezones then best of luck - just bear in mind that\n     * you'll probably be dealing with\n     * {local solar times}[https:\/\/en.wikipedia.org\/wiki\/Solar_time],\n     * since it wasn't until the 19th century that the introduction\n     * of the railways necessitated the need for\n     * {Standard Time}[https:\/\/en.wikipedia.org\/wiki\/Standard_time#Great_Britain]\n     * and eventually timezones.\n     *\/\n\n    cDateTime = rb_define_class(\"DateTime\", cDate);\n    rb_define_alloc_func(cDateTime, d_lite_s_alloc_complex);\n\n    rb_define_singleton_method(cDateTime, \"jd\", datetime_s_jd, -1);\n    rb_define_singleton_method(cDateTime, \"ordinal\", datetime_s_ordinal, -1);\n    rb_define_singleton_method(cDateTime, \"civil\", datetime_s_civil, -1);\n    rb_define_singleton_method(cDateTime, \"new\", datetime_s_civil, -1);\n    rb_define_singleton_method(cDateTime, \"commercial\",\n\t\t\t       datetime_s_commercial, -1);\n\n#ifndef NDEBUG\n    rb_define_singleton_method(cDateTime, \"weeknum\",\n\t\t\t       datetime_s_weeknum, -1);\n    rb_define_singleton_method(cDateTime, \"nth_kday\",\n\t\t\t       datetime_s_nth_kday, -1);\n#endif\n\n    rb_undef_method(CLASS_OF(cDateTime), \"today\");\n\n    rb_define_singleton_method(cDateTime, \"now\", datetime_s_now, -1);\n    rb_define_singleton_method(cDateTime, \"_strptime\",\n\t\t\t       datetime_s__strptime, -1);\n    rb_define_singleton_method(cDateTime, \"strptime\",\n\t\t\t       datetime_s_strptime, -1);\n    rb_define_singleton_method(cDateTime, \"parse\",\n\t\t\t       datetime_s_parse, -1);\n    rb_define_singleton_method(cDateTime, \"iso8601\",\n\t\t\t       datetime_s_iso8601, -1);\n    rb_define_singleton_method(cDateTime, \"rfc3339\",\n\t\t\t       datetime_s_rfc3339, -1);\n    rb_define_singleton_method(cDateTime, \"xmlschema\",\n\t\t\t       datetime_s_xmlschema, -1);\n    rb_define_singleton_method(cDateTime, \"rfc2822\",\n\t\t\t       datetime_s_rfc2822, -1);\n    rb_define_singleton_method(cDateTime, \"rfc822\",\n\t\t\t       datetime_s_rfc2822, -1);\n    rb_define_singleton_method(cDateTime, \"httpdate\",\n\t\t\t       datetime_s_httpdate, -1);\n    rb_define_singleton_method(cDateTime, \"jisx0301\",\n\t\t\t       datetime_s_jisx0301, -1);\n\n    rb_define_method(cDateTime, \"hour\", d_lite_hour, 0);\n    rb_define_method(cDateTime, \"min\", d_lite_min, 0);\n    rb_define_method(cDateTime, \"minute\", d_lite_min, 0);\n    rb_define_method(cDateTime, \"sec\", d_lite_sec, 0);\n    rb_define_method(cDateTime, \"second\", d_lite_sec, 0);\n    rb_define_method(cDateTime, \"sec_fraction\", d_lite_sec_fraction, 0);\n    rb_define_method(cDateTime, \"second_fraction\", d_lite_sec_fraction, 0);\n    rb_define_method(cDateTime, \"offset\", d_lite_offset, 0);\n    rb_define_method(cDateTime, \"zone\", d_lite_zone, 0);\n    rb_define_method(cDateTime, \"new_offset\", d_lite_new_offset, -1);\n\n    rb_define_method(cDateTime, \"to_s\", dt_lite_to_s, 0);\n\n    rb_define_method(cDateTime, \"strftime\", dt_lite_strftime, -1);\n\n    rb_define_method(cDateTime, \"iso8601\", dt_lite_iso8601, -1);\n    rb_define_method(cDateTime, \"xmlschema\", dt_lite_iso8601, -1);\n    rb_define_method(cDateTime, \"rfc3339\", dt_lite_rfc3339, -1);\n    rb_define_method(cDateTime, \"jisx0301\", dt_lite_jisx0301, -1);\n\n    \/* conversions *\/\n\n    rb_define_method(rb_cTime, \"to_time\", time_to_time, 0);\n    rb_define_method(rb_cTime, \"to_date\", time_to_date, 0);\n    rb_define_method(rb_cTime, \"to_datetime\", time_to_datetime, 0);\n\n    rb_define_method(cDate, \"to_time\", date_to_time, 0);\n    rb_define_method(cDate, \"to_date\", date_to_date, 0);\n    rb_define_method(cDate, \"to_datetime\", date_to_datetime, 0);\n\n    rb_define_method(cDateTime, \"to_time\", datetime_to_time, 0);\n    rb_define_method(cDateTime, \"to_date\", datetime_to_date, 0);\n    rb_define_method(cDateTime, \"to_datetime\", datetime_to_datetime, 0);\n\n#ifndef NDEBUG\n    \/* tests *\/\n\n    rb_define_singleton_method(cDate, \"test_civil\", date_s_test_civil, 0);\n    rb_define_singleton_method(cDate, \"test_ordinal\", date_s_test_ordinal, 0);\n    rb_define_singleton_method(cDate, \"test_commercial\",\n\t\t\t       date_s_test_commercial, 0);\n    rb_define_singleton_method(cDate, \"test_weeknum\", date_s_test_weeknum, 0);\n    rb_define_singleton_method(cDate, \"test_nth_kday\", date_s_test_nth_kday, 0);\n    rb_define_singleton_method(cDate, \"test_unit_conv\",\n\t\t\t       date_s_test_unit_conv, 0);\n    rb_define_singleton_method(cDate, \"test_all\", date_s_test_all, 0);\n#endif\n}","target":0,"code_token_length":8172,"total_token_length":8408,"max_tokens_setting":11000}
+{"idx":199984,"func":"ex_substitute(exarg_T *eap)\n{\n    linenr_T\tlnum;\n    long\ti = 0;\n    regmmatch_T regmatch;\n    static subflags_T subflags = {FALSE, FALSE, FALSE, TRUE, FALSE,\n\t\t\t\t\t\t\t      FALSE, FALSE, 0};\n#ifdef FEAT_EVAL\n    subflags_T\tsubflags_save;\n#endif\n    int\t\tsave_do_all;\t\t\/\/ remember user specified 'g' flag\n    int\t\tsave_do_ask;\t\t\/\/ remember user specified 'c' flag\n    char_u\t*pat = NULL, *sub = NULL;\t\/\/ init for GCC\n    int\t\tdelimiter;\n    int\t\tsublen;\n    int\t\tgot_quit = FALSE;\n    int\t\tgot_match = FALSE;\n    int\t\ttemp;\n    int\t\twhich_pat;\n    char_u\t*cmd;\n    int\t\tsave_State;\n    linenr_T\tfirst_line = 0;\t\t\/\/ first changed line\n    linenr_T\tlast_line= 0;\t\t\/\/ below last changed line AFTER the\n\t\t\t\t\t\/\/ change\n    linenr_T\told_line_count = curbuf->b_ml.ml_line_count;\n    linenr_T\tline2;\n    long\tnmatch;\t\t\t\/\/ number of lines in match\n    char_u\t*sub_firstline;\t\t\/\/ allocated copy of first sub line\n    int\t\tendcolumn = FALSE;\t\/\/ cursor in last column when done\n    pos_T\told_cursor = curwin->w_cursor;\n    int\t\tstart_nsubs;\n#ifdef FEAT_EVAL\n    int\t\tsave_ma = 0;\n#endif\n\n    cmd = eap->arg;\n    if (!global_busy)\n    {\n\tsub_nsubs = 0;\n\tsub_nlines = 0;\n    }\n    start_nsubs = sub_nsubs;\n\n    if (eap->cmdidx == CMD_tilde)\n\twhich_pat = RE_LAST;\t\/\/ use last used regexp\n    else\n\twhich_pat = RE_SUBST;\t\/\/ use last substitute regexp\n\n\t\t\t\t\/\/ new pattern and substitution\n    if (eap->cmd[0] == 's' && *cmd != NUL && !VIM_ISWHITE(*cmd)\n\t\t&& vim_strchr((char_u *)\"0123456789cegriIp|\\\"\", *cmd) == NULL)\n    {\n\t\t\t\t\/\/ don't accept alphanumeric for separator\n\tif (check_regexp_delim(*cmd) == FAIL)\n\t    return;\n#ifdef FEAT_EVAL\n\tif (in_vim9script() && check_global_and_subst(eap->cmd, eap->arg)\n\t\t\t\t\t\t\t\t      == FAIL)\n\t    return;\n#endif\n\n\t\/*\n\t * undocumented vi feature:\n\t *  \"\\\/sub\/\" and \"\\?sub?\" use last used search pattern (almost like\n\t *  \/\/sub\/r).  \"\\&sub&\" use last substitute pattern (like \/\/sub\/).\n\t *\/\n\tif (*cmd == '\\\\')\n\t{\n\t    ++cmd;\n\t    if (vim_strchr((char_u *)\"\/?&\", *cmd) == NULL)\n\t    {\n\t\temsg(_(e_backslash_should_be_followed_by));\n\t\treturn;\n\t    }\n\t    if (*cmd != '&')\n\t\twhich_pat = RE_SEARCH;\t    \/\/ use last '\/' pattern\n\t    pat = (char_u *)\"\";\t\t    \/\/ empty search pattern\n\t    delimiter = *cmd++;\t\t    \/\/ remember delimiter character\n\t}\n\telse\t\t\/\/ find the end of the regexp\n\t{\n\t    which_pat = RE_LAST;\t    \/\/ use last used regexp\n\t    delimiter = *cmd++;\t\t    \/\/ remember delimiter character\n\t    pat = cmd;\t\t\t    \/\/ remember start of search pat\n\t    cmd = skip_regexp_ex(cmd, delimiter, magic_isset(),\n\t\t\t\t\t\t\t&eap->arg, NULL, NULL);\n\t    if (cmd[0] == delimiter)\t    \/\/ end delimiter found\n\t\t*cmd++ = NUL;\t\t    \/\/ replace it with a NUL\n\t}\n\n\t\/*\n\t * Small incompatibility: vi sees '\\n' as end of the command, but in\n\t * Vim we want to use '\\n' to find\/substitute a NUL.\n\t *\/\n\tsub = cmd;\t    \/\/ remember the start of the substitution\n\tcmd = skip_substitute(cmd, delimiter);\n\n\tif (!eap->skip)\n\t{\n\t    \/\/ In POSIX vi \":s\/pat\/%\/\" uses the previous subst. string.\n\t    if (STRCMP(sub, \"%\") == 0\n\t\t\t\t && vim_strchr(p_cpo, CPO_SUBPERCENT) != NULL)\n\t    {\n\t\tif (old_sub == NULL)\t\/\/ there is no previous command\n\t\t{\n\t\t    emsg(_(e_no_previous_substitute_regular_expression));\n\t\t    return;\n\t\t}\n\t\tsub = old_sub;\n\t    }\n\t    else\n\t    {\n\t\tvim_free(old_sub);\n\t\told_sub = vim_strsave(sub);\n\t    }\n\t}\n    }\n    else if (!eap->skip)\t\/\/ use previous pattern and substitution\n    {\n\tif (old_sub == NULL)\t\/\/ there is no previous command\n\t{\n\t    emsg(_(e_no_previous_substitute_regular_expression));\n\t    return;\n\t}\n\tpat = NULL;\t\t\/\/ search_regcomp() will use previous pattern\n\tsub = old_sub;\n\n\t\/\/ Vi compatibility quirk: repeating with \":s\" keeps the cursor in the\n\t\/\/ last column after using \"$\".\n\tendcolumn = (curwin->w_curswant == MAXCOL);\n    }\n\n    \/\/ Recognize \":%s\/\\n\/\/\" and turn it into a join command, which is much\n    \/\/ more efficient.\n    \/\/ TODO: find a generic solution to make line-joining operations more\n    \/\/ efficient, avoid allocating a string that grows in size.\n    if (pat != NULL && STRCMP(pat, \"\\\\n\") == 0\n\t    && *sub == NUL\n\t    && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'\n\t\t\t\t\t     || *cmd == 'p' || *cmd == '#'))))\n    {\n\tlinenr_T    joined_lines_count;\n\n\tif (eap->skip)\n\t    return;\n\tcurwin->w_cursor.lnum = eap->line1;\n\tif (*cmd == 'l')\n\t    eap->flags = EXFLAG_LIST;\n\telse if (*cmd == '#')\n\t    eap->flags = EXFLAG_NR;\n\telse if (*cmd == 'p')\n\t    eap->flags = EXFLAG_PRINT;\n\n\t\/\/ The number of lines joined is the number of lines in the range plus\n\t\/\/ one.  One less when the last line is included.\n\tjoined_lines_count = eap->line2 - eap->line1 + 1;\n\tif (eap->line2 < curbuf->b_ml.ml_line_count)\n\t    ++joined_lines_count;\n\tif (joined_lines_count > 1)\n\t{\n\t    (void)do_join(joined_lines_count, FALSE, TRUE, FALSE, TRUE);\n\t    sub_nsubs = joined_lines_count - 1;\n\t    sub_nlines = 1;\n\t    (void)do_sub_msg(FALSE);\n\t    ex_may_print(eap);\n\t}\n\n\tif ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0)\n\t    save_re_pat(RE_SUBST, pat, magic_isset());\n\t\/\/ put pattern in history\n\tadd_to_history(HIST_SEARCH, pat, TRUE, NUL);\n\n\treturn;\n    }\n\n    \/*\n     * Find trailing options.  When '&' is used, keep old options.\n     *\/\n    if (*cmd == '&')\n\t++cmd;\n    else\n    {\n#ifdef FEAT_EVAL\n\tif (in_vim9script())\n\t{\n\t    \/\/ ignore 'gdefault' and 'edcompatible'\n\t    subflags.do_all = FALSE;\n\t    subflags.do_ask = FALSE;\n\t}\n\telse\n#endif\n\tif (!p_ed)\n\t{\n\t    if (p_gd)\t\t\/\/ default is global on\n\t\tsubflags.do_all = TRUE;\n\t    else\n\t\tsubflags.do_all = FALSE;\n\t    subflags.do_ask = FALSE;\n\t}\n\tsubflags.do_error = TRUE;\n\tsubflags.do_print = FALSE;\n\tsubflags.do_list = FALSE;\n\tsubflags.do_count = FALSE;\n\tsubflags.do_number = FALSE;\n\tsubflags.do_ic = 0;\n    }\n    while (*cmd)\n    {\n\t\/*\n\t * Note that 'g' and 'c' are always inverted, also when p_ed is off.\n\t * 'r' is never inverted.\n\t *\/\n\tif (*cmd == 'g')\n\t    subflags.do_all = !subflags.do_all;\n\telse if (*cmd == 'c')\n\t    subflags.do_ask = !subflags.do_ask;\n\telse if (*cmd == 'n')\n\t    subflags.do_count = TRUE;\n\telse if (*cmd == 'e')\n\t    subflags.do_error = !subflags.do_error;\n\telse if (*cmd == 'r')\t    \/\/ use last used regexp\n\t    which_pat = RE_LAST;\n\telse if (*cmd == 'p')\n\t    subflags.do_print = TRUE;\n\telse if (*cmd == '#')\n\t{\n\t    subflags.do_print = TRUE;\n\t    subflags.do_number = TRUE;\n\t}\n\telse if (*cmd == 'l')\n\t{\n\t    subflags.do_print = TRUE;\n\t    subflags.do_list = TRUE;\n\t}\n\telse if (*cmd == 'i')\t    \/\/ ignore case\n\t    subflags.do_ic = 'i';\n\telse if (*cmd == 'I')\t    \/\/ don't ignore case\n\t    subflags.do_ic = 'I';\n\telse\n\t    break;\n\t++cmd;\n    }\n    if (subflags.do_count)\n\tsubflags.do_ask = FALSE;\n\n    save_do_all = subflags.do_all;\n    save_do_ask = subflags.do_ask;\n\n    \/*\n     * check for a trailing count\n     *\/\n    cmd = skipwhite(cmd);\n    if (VIM_ISDIGIT(*cmd))\n    {\n\ti = getdigits(&cmd);\n\tif (i <= 0 && !eap->skip && subflags.do_error)\n\t{\n\t    emsg(_(e_positive_count_required));\n\t    return;\n\t}\n\teap->line1 = eap->line2;\n\teap->line2 += i - 1;\n\tif (eap->line2 > curbuf->b_ml.ml_line_count)\n\t    eap->line2 = curbuf->b_ml.ml_line_count;\n    }\n\n    \/*\n     * check for trailing command or garbage\n     *\/\n    cmd = skipwhite(cmd);\n    if (*cmd && *cmd != '\"')\t    \/\/ if not end-of-line or comment\n    {\n\tset_nextcmd(eap, cmd);\n\tif (eap->nextcmd == NULL)\n\t{\n\t    semsg(_(e_trailing_characters_str), cmd);\n\t    return;\n\t}\n    }\n\n    if (eap->skip)\t    \/\/ not executing commands, only parsing\n\treturn;\n\n    if (!subflags.do_count && !curbuf->b_p_ma)\n    {\n\t\/\/ Substitution is not allowed in non-'modifiable' buffer\n\temsg(_(e_cannot_make_changes_modifiable_is_off));\n\treturn;\n    }\n\n    if (search_regcomp(pat, RE_SUBST, which_pat, SEARCH_HIS, ®match) == FAIL)\n    {\n\tif (subflags.do_error)\n\t    emsg(_(e_invalid_command));\n\treturn;\n    }\n\n    \/\/ the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase'\n    if (subflags.do_ic == 'i')\n\tregmatch.rmm_ic = TRUE;\n    else if (subflags.do_ic == 'I')\n\tregmatch.rmm_ic = FALSE;\n\n    sub_firstline = NULL;\n\n    \/*\n     * ~ in the substitute pattern is replaced with the old pattern.\n     * We do it here once to avoid it to be replaced over and over again.\n     * But don't do it when it starts with \"\\=\", then it's an expression.\n     *\/\n    if (!(sub[0] == '\\\\' && sub[1] == '='))\n\tsub = regtilde(sub, magic_isset());\n\n    \/*\n     * Check for a match on each line.\n     *\/\n    line2 = eap->line2;\n    for (lnum = eap->line1; lnum <= line2 && !(got_quit\n#if defined(FEAT_EVAL)\n\t\t|| aborting()\n#endif\n\t\t); ++lnum)\n    {\n\tnmatch = vim_regexec_multi(®match, curwin, curbuf, lnum,\n\t\t\t\t\t\t       (colnr_T)0, NULL, NULL);\n\tif (nmatch)\n\t{\n\t    colnr_T\tcopycol;\n\t    colnr_T\tmatchcol;\n\t    colnr_T\tprev_matchcol = MAXCOL;\n\t    char_u\t*new_end, *new_start = NULL;\n\t    unsigned\tnew_start_len = 0;\n\t    char_u\t*p1;\n\t    int\t\tdid_sub = FALSE;\n\t    int\t\tlastone;\n\t    int\t\tlen, copy_len, needed_len;\n\t    long\tnmatch_tl = 0;\t\/\/ nr of lines matched below lnum\n\t    int\t\tdo_again;\t\/\/ do it again after joining lines\n\t    int\t\tskip_match = FALSE;\n\t    linenr_T\tsub_firstlnum;\t\/\/ nr of first sub line\n#ifdef FEAT_PROP_POPUP\n\t    int\t\tapc_flags = APC_SAVE_FOR_UNDO | APC_SUBSTITUTE;\n\t    colnr_T\ttotal_added =  0;\n#endif\n\n\t    \/*\n\t     * The new text is build up step by step, to avoid too much\n\t     * copying.  There are these pieces:\n\t     * sub_firstline\tThe old text, unmodified.\n\t     * copycol\t\tColumn in the old text where we started\n\t     *\t\t\tlooking for a match; from here old text still\n\t     *\t\t\tneeds to be copied to the new text.\n\t     * matchcol\t\tColumn number of the old text where to look\n\t     *\t\t\tfor the next match.  It's just after the\n\t     *\t\t\tprevious match or one further.\n\t     * prev_matchcol\tColumn just after the previous match (if any).\n\t     *\t\t\tMostly equal to matchcol, except for the first\n\t     *\t\t\tmatch and after skipping an empty match.\n\t     * regmatch.*pos\tWhere the pattern matched in the old text.\n\t     * new_start\tThe new text, all that has been produced so\n\t     *\t\t\tfar.\n\t     * new_end\t\tThe new text, where to append new text.\n\t     *\n\t     * lnum\t\tThe line number where we found the start of\n\t     *\t\t\tthe match.  Can be below the line we searched\n\t     *\t\t\twhen there is a \\n before a \\zs in the\n\t     *\t\t\tpattern.\n\t     * sub_firstlnum\tThe line number in the buffer where to look\n\t     *\t\t\tfor a match.  Can be different from \"lnum\"\n\t     *\t\t\twhen the pattern or substitute string contains\n\t     *\t\t\tline breaks.\n\t     *\n\t     * Special situations:\n\t     * - When the substitute string contains a line break, the part up\n\t     *   to the line break is inserted in the text, but the copy of\n\t     *   the original line is kept.  \"sub_firstlnum\" is adjusted for\n\t     *   the inserted lines.\n\t     * - When the matched pattern contains a line break, the old line\n\t     *   is taken from the line at the end of the pattern.  The lines\n\t     *   in the match are deleted later, \"sub_firstlnum\" is adjusted\n\t     *   accordingly.\n\t     *\n\t     * The new text is built up in new_start[].  It has some extra\n\t     * room to avoid using alloc()\/free() too often.  new_start_len is\n\t     * the length of the allocated memory at new_start.\n\t     *\n\t     * Make a copy of the old line, so it won't be taken away when\n\t     * updating the screen or handling a multi-line match.  The \"old_\"\n\t     * pointers point into this copy.\n\t     *\/\n\t    sub_firstlnum = lnum;\n\t    copycol = 0;\n\t    matchcol = 0;\n\n\t    \/\/ At first match, remember current cursor position.\n\t    if (!got_match)\n\t    {\n\t\tsetpcmark();\n\t\tgot_match = TRUE;\n\t    }\n\n\t    \/*\n\t     * Loop until nothing more to replace in this line.\n\t     * 1. Handle match with empty string.\n\t     * 2. If do_ask is set, ask for confirmation.\n\t     * 3. substitute the string.\n\t     * 4. if do_all is set, find next match\n\t     * 5. break if there isn't another match in this line\n\t     *\/\n\t    for (;;)\n\t    {\n\t\t\/\/ Advance \"lnum\" to the line where the match starts.  The\n\t\t\/\/ match does not start in the first line when there is a line\n\t\t\/\/ break before \\zs.\n\t\tif (regmatch.startpos[0].lnum > 0)\n\t\t{\n\t\t    lnum += regmatch.startpos[0].lnum;\n\t\t    sub_firstlnum += regmatch.startpos[0].lnum;\n\t\t    nmatch -= regmatch.startpos[0].lnum;\n\t\t    VIM_CLEAR(sub_firstline);\n\t\t}\n\n\t\t\/\/ Match might be after the last line for \"\\n\\zs\" matching at\n\t\t\/\/ the end of the last line.\n\t\tif (lnum > curbuf->b_ml.ml_line_count)\n\t\t    break;\n\n\t\tif (sub_firstline == NULL)\n\t\t{\n\t\t    sub_firstline = vim_strsave(ml_get(sub_firstlnum));\n\t\t    if (sub_firstline == NULL)\n\t\t    {\n\t\t\tvim_free(new_start);\n\t\t\tgoto outofmem;\n\t\t    }\n\t\t}\n\n\t\t\/\/ Save the line number of the last change for the final\n\t\t\/\/ cursor position (just like Vi).\n\t\tcurwin->w_cursor.lnum = lnum;\n\t\tdo_again = FALSE;\n\n\t\t\/*\n\t\t * 1. Match empty string does not count, except for first\n\t\t * match.  This reproduces the strange vi behaviour.\n\t\t * This also catches endless loops.\n\t\t *\/\n\t\tif (matchcol == prev_matchcol\n\t\t\t&& regmatch.endpos[0].lnum == 0\n\t\t\t&& matchcol == regmatch.endpos[0].col)\n\t\t{\n\t\t    if (sub_firstline[matchcol] == NUL)\n\t\t\t\/\/ We already were at the end of the line.  Don't look\n\t\t\t\/\/ for a match in this line again.\n\t\t\tskip_match = TRUE;\n\t\t    else\n\t\t    {\n\t\t\t \/\/ search for a match at next column\n\t\t\tif (has_mbyte)\n\t\t\t    matchcol += mb_ptr2len(sub_firstline + matchcol);\n\t\t\telse\n\t\t\t    ++matchcol;\n\t\t    }\n\t\t    goto skip;\n\t\t}\n\n\t\t\/\/ Normally we continue searching for a match just after the\n\t\t\/\/ previous match.\n\t\tmatchcol = regmatch.endpos[0].col;\n\t\tprev_matchcol = matchcol;\n\n\t\t\/*\n\t\t * 2. If do_count is set only increase the counter.\n\t\t *    If do_ask is set, ask for confirmation.\n\t\t *\/\n\t\tif (subflags.do_count)\n\t\t{\n\t\t    \/\/ For a multi-line match, put matchcol at the NUL at\n\t\t    \/\/ the end of the line and set nmatch to one, so that\n\t\t    \/\/ we continue looking for a match on the next line.\n\t\t    \/\/ Avoids that \":s\/\\nB\\@=\/\/gc\" get stuck.\n\t\t    if (nmatch > 1)\n\t\t    {\n\t\t\tmatchcol = (colnr_T)STRLEN(sub_firstline);\n\t\t\tnmatch = 1;\n\t\t\tskip_match = TRUE;\n\t\t    }\n\t\t    sub_nsubs++;\n\t\t    did_sub = TRUE;\n#ifdef FEAT_EVAL\n\t\t    \/\/ Skip the substitution, unless an expression is used,\n\t\t    \/\/ then it is evaluated in the sandbox.\n\t\t    if (!(sub[0] == '\\\\' && sub[1] == '='))\n#endif\n\t\t\tgoto skip;\n\t\t}\n\n\t\tif (subflags.do_ask)\n\t\t{\n\t\t    int typed = 0;\n\n\t\t    \/\/ change State to CONFIRM, so that the mouse works\n\t\t    \/\/ properly\n\t\t    save_State = State;\n\t\t    State = CONFIRM;\n\t\t    setmouse();\t\t\/\/ disable mouse in xterm\n\t\t    curwin->w_cursor.col = regmatch.startpos[0].col;\n\t\t    if (curwin->w_p_crb)\n\t\t\tdo_check_cursorbind();\n\n\t\t    \/\/ When 'cpoptions' contains \"u\" don't sync undo when\n\t\t    \/\/ asking for confirmation.\n\t\t    if (vim_strchr(p_cpo, CPO_UNDO) != NULL)\n\t\t\t++no_u_sync;\n\n\t\t    \/*\n\t\t     * Loop until 'y', 'n', 'q', CTRL-E or CTRL-Y typed.\n\t\t     *\/\n\t\t    while (subflags.do_ask)\n\t\t    {\n\t\t\tif (exmode_active)\n\t\t\t{\n\t\t\t    char_u\t*resp;\n\t\t\t    colnr_T\tsc, ec;\n\n\t\t\t    print_line_no_prefix(lnum,\n\t\t\t\t\t subflags.do_number, subflags.do_list);\n\n\t\t\t    getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);\n\t\t\t    curwin->w_cursor.col = regmatch.endpos[0].col - 1;\n\t\t\t    if (curwin->w_cursor.col < 0)\n\t\t\t\tcurwin->w_cursor.col = 0;\n\t\t\t    getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);\n\t\t\t    curwin->w_cursor.col = regmatch.startpos[0].col;\n\t\t\t    if (subflags.do_number || curwin->w_p_nu)\n\t\t\t    {\n\t\t\t\tint numw = number_width(curwin) + 1;\n\t\t\t\tsc += numw;\n\t\t\t\tec += numw;\n\t\t\t    }\n\t\t\t    msg_start();\n\t\t\t    for (i = 0; i < (long)sc; ++i)\n\t\t\t\tmsg_putchar(' ');\n\t\t\t    for ( ; i <= (long)ec; ++i)\n\t\t\t\tmsg_putchar('^');\n\n\t\t\t    resp = getexmodeline('?', NULL, 0, TRUE);\n\t\t\t    if (resp != NULL)\n\t\t\t    {\n\t\t\t\ttyped = *resp;\n\t\t\t\tvim_free(resp);\n\t\t\t    }\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    char_u *orig_line = NULL;\n\t\t\t    int    len_change = 0;\n\t\t\t    int\t   save_p_lz = p_lz;\n#ifdef FEAT_FOLDING\n\t\t\t    int save_p_fen = curwin->w_p_fen;\n\n\t\t\t    curwin->w_p_fen = FALSE;\n#endif\n\t\t\t    \/\/ Invert the matched string.\n\t\t\t    \/\/ Remove the inversion afterwards.\n\t\t\t    temp = RedrawingDisabled;\n\t\t\t    RedrawingDisabled = 0;\n\n\t\t\t    \/\/ avoid calling update_screen() in vgetorpeek()\n\t\t\t    p_lz = FALSE;\n\n\t\t\t    if (new_start != NULL)\n\t\t\t    {\n\t\t\t\t\/\/ There already was a substitution, we would\n\t\t\t\t\/\/ like to show this to the user.  We cannot\n\t\t\t\t\/\/ really update the line, it would change\n\t\t\t\t\/\/ what matches.  Temporarily replace the line\n\t\t\t\t\/\/ and change it back afterwards.\n\t\t\t\torig_line = vim_strsave(ml_get(lnum));\n\t\t\t\tif (orig_line != NULL)\n\t\t\t\t{\n\t\t\t\t    char_u *new_line = concat_str(new_start,\n\t\t\t\t\t\t     sub_firstline + copycol);\n\n\t\t\t\t    if (new_line == NULL)\n\t\t\t\t\tVIM_CLEAR(orig_line);\n\t\t\t\t    else\n\t\t\t\t    {\n\t\t\t\t\t\/\/ Position the cursor relative to the\n\t\t\t\t\t\/\/ end of the line, the previous\n\t\t\t\t\t\/\/ substitute may have inserted or\n\t\t\t\t\t\/\/ deleted characters before the\n\t\t\t\t\t\/\/ cursor.\n\t\t\t\t\tlen_change = (int)STRLEN(new_line)\n\t\t\t\t\t\t     - (int)STRLEN(orig_line);\n\t\t\t\t\tcurwin->w_cursor.col += len_change;\n\t\t\t\t\tml_replace(lnum, new_line, FALSE);\n\t\t\t\t    }\n\t\t\t\t}\n\t\t\t    }\n\n\t\t\t    search_match_lines = regmatch.endpos[0].lnum\n\t\t\t\t\t\t  - regmatch.startpos[0].lnum;\n\t\t\t    search_match_endcol = regmatch.endpos[0].col\n\t\t\t\t\t\t\t\t + len_change;\n\t\t\t    highlight_match = TRUE;\n\n\t\t\t    update_topline();\n\t\t\t    validate_cursor();\n\t\t\t    update_screen(SOME_VALID);\n\t\t\t    highlight_match = FALSE;\n\t\t\t    redraw_later(SOME_VALID);\n\n#ifdef FEAT_FOLDING\n\t\t\t    curwin->w_p_fen = save_p_fen;\n#endif\n\t\t\t    if (msg_row == Rows - 1)\n\t\t\t\tmsg_didout = FALSE;\t\/\/ avoid a scroll-up\n\t\t\t    msg_starthere();\n\t\t\t    i = msg_scroll;\n\t\t\t    msg_scroll = 0;\t\t\/\/ truncate msg when\n\t\t\t\t\t\t\t\/\/ needed\n\t\t\t    msg_no_more = TRUE;\n\t\t\t    \/\/ write message same highlighting as for\n\t\t\t    \/\/ wait_return\n\t\t\t    smsg_attr(HL_ATTR(HLF_R),\n\t\t\t\t_(\"replace with %s (y\/n\/a\/q\/l\/^E\/^Y)?\"), sub);\n\t\t\t    msg_no_more = FALSE;\n\t\t\t    msg_scroll = i;\n\t\t\t    showruler(TRUE);\n\t\t\t    windgoto(msg_row, msg_col);\n\t\t\t    RedrawingDisabled = temp;\n\n#ifdef USE_ON_FLY_SCROLL\n\t\t\t    dont_scroll = FALSE; \/\/ allow scrolling here\n#endif\n\t\t\t    ++no_mapping;\t\/\/ don't map this key\n\t\t\t    ++allow_keys;\t\/\/ allow special keys\n\t\t\t    typed = plain_vgetc();\n\t\t\t    --allow_keys;\n\t\t\t    --no_mapping;\n\n\t\t\t    \/\/ clear the question\n\t\t\t    msg_didout = FALSE;\t\/\/ don't scroll up\n\t\t\t    msg_col = 0;\n\t\t\t    gotocmdline(TRUE);\n\t\t\t    p_lz = save_p_lz;\n\n\t\t\t    \/\/ restore the line\n\t\t\t    if (orig_line != NULL)\n\t\t\t\tml_replace(lnum, orig_line, FALSE);\n\t\t\t}\n\n\t\t\tneed_wait_return = FALSE; \/\/ no hit-return prompt\n\t\t\tif (typed == 'q' || typed == ESC || typed == Ctrl_C\n#ifdef UNIX\n\t\t\t\t|| typed == intr_char\n#endif\n\t\t\t\t)\n\t\t\t{\n\t\t\t    got_quit = TRUE;\n\t\t\t    break;\n\t\t\t}\n\t\t\tif (typed == 'n')\n\t\t\t    break;\n\t\t\tif (typed == 'y')\n\t\t\t    break;\n\t\t\tif (typed == 'l')\n\t\t\t{\n\t\t\t    \/\/ last: replace and then stop\n\t\t\t    subflags.do_all = FALSE;\n\t\t\t    line2 = lnum;\n\t\t\t    break;\n\t\t\t}\n\t\t\tif (typed == 'a')\n\t\t\t{\n\t\t\t    subflags.do_ask = FALSE;\n\t\t\t    break;\n\t\t\t}\n\t\t\tif (typed == Ctrl_E)\n\t\t\t    scrollup_clamp();\n\t\t\telse if (typed == Ctrl_Y)\n\t\t\t    scrolldown_clamp();\n\t\t    }\n\t\t    State = save_State;\n\t\t    setmouse();\n\t\t    if (vim_strchr(p_cpo, CPO_UNDO) != NULL)\n\t\t\t--no_u_sync;\n\n\t\t    if (typed == 'n')\n\t\t    {\n\t\t\t\/\/ For a multi-line match, put matchcol at the NUL at\n\t\t\t\/\/ the end of the line and set nmatch to one, so that\n\t\t\t\/\/ we continue looking for a match on the next line.\n\t\t\t\/\/ Avoids that \":%s\/\\nB\\@=\/\/gc\" and \":%s\/\\n\/,\\r\/gc\"\n\t\t\t\/\/ get stuck when pressing 'n'.\n\t\t\tif (nmatch > 1)\n\t\t\t{\n\t\t\t    matchcol = (colnr_T)STRLEN(sub_firstline);\n\t\t\t    skip_match = TRUE;\n\t\t\t}\n\t\t\tgoto skip;\n\t\t    }\n\t\t    if (got_quit)\n\t\t\tgoto skip;\n\t\t}\n\n\t\t\/\/ Move the cursor to the start of the match, so that we can\n\t\t\/\/ use \"\\=col(\".\").\n\t\tcurwin->w_cursor.col = regmatch.startpos[0].col;\n\n\t\t\/*\n\t\t * 3. substitute the string.\n\t\t *\/\n#ifdef FEAT_EVAL\n\t\tsave_ma = curbuf->b_p_ma;\n\t\tif (subflags.do_count)\n\t\t{\n\t\t    \/\/ prevent accidentally changing the buffer by a function\n\t\t    curbuf->b_p_ma = FALSE;\n\t\t    sandbox++;\n\t\t}\n\t\t\/\/ Save flags for recursion.  They can change for e.g.\n\t\t\/\/ :s\/^\/\\=execute(\"s#^##gn\")\n\t\tsubflags_save = subflags;\n#endif\n\t\t\/\/ get length of substitution part\n\t\tsublen = vim_regsub_multi(®match,\n\t\t\t\t    sub_firstlnum - regmatch.startpos[0].lnum,\n\t\t\t       sub, sub_firstline, FALSE, magic_isset(), TRUE);\n#ifdef FEAT_EVAL\n\t\t\/\/ If getting the substitute string caused an error, don't do\n\t\t\/\/ the replacement.\n\t\t\/\/ Don't keep flags set by a recursive call.\n\t\tsubflags = subflags_save;\n\t\tif (aborting() || subflags.do_count)\n\t\t{\n\t\t    curbuf->b_p_ma = save_ma;\n\t\t    if (sandbox > 0)\n\t\t\tsandbox--;\n\t\t    goto skip;\n\t\t}\n#endif\n\n\t\t\/\/ When the match included the \"$\" of the last line it may\n\t\t\/\/ go beyond the last line of the buffer.\n\t\tif (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1)\n\t\t{\n\t\t    nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1;\n\t\t    skip_match = TRUE;\n\t\t}\n\n\t\t\/\/ Need room for:\n\t\t\/\/ - result so far in new_start (not for first sub in line)\n\t\t\/\/ - original text up to match\n\t\t\/\/ - length of substituted part\n\t\t\/\/ - original text after match\n\t\t\/\/ Adjust text properties here, since we have all information\n\t\t\/\/ needed.\n\t\tif (nmatch == 1)\n\t\t{\n\t\t    p1 = sub_firstline;\n#ifdef FEAT_PROP_POPUP\n\t\t    if (curbuf->b_has_textprop)\n\t\t    {\n\t\t\tint bytes_added = sublen - 1 - (regmatch.endpos[0].col\n\t\t\t\t\t\t   - regmatch.startpos[0].col);\n\n\t\t\t\/\/ When text properties are changed, need to save for\n\t\t\t\/\/ undo first, unless done already.\n\t\t\tif (adjust_prop_columns(lnum,\n\t\t\t\t\ttotal_added + regmatch.startpos[0].col,\n\t\t\t\t\t\t       bytes_added, apc_flags))\n\t\t\t    apc_flags &= ~APC_SAVE_FOR_UNDO;\n\t\t\t\/\/ Offset for column byte number of the text property\n\t\t\t\/\/ in the resulting buffer afterwards.\n\t\t\ttotal_added += bytes_added;\n\t\t    }\n#endif\n\t\t}\n\t\telse\n\t\t{\n\t\t    p1 = ml_get(sub_firstlnum + nmatch - 1);\n\t\t    nmatch_tl += nmatch - 1;\n\t\t}\n\t\tcopy_len = regmatch.startpos[0].col - copycol;\n\t\tneeded_len = copy_len + ((unsigned)STRLEN(p1)\n\t\t\t\t       - regmatch.endpos[0].col) + sublen + 1;\n\t\tif (new_start == NULL)\n\t\t{\n\t\t    \/*\n\t\t     * Get some space for a temporary buffer to do the\n\t\t     * substitution into (and some extra space to avoid\n\t\t     * too many calls to alloc()\/free()).\n\t\t     *\/\n\t\t    new_start_len = needed_len + 50;\n\t\t    if ((new_start = alloc(new_start_len)) == NULL)\n\t\t\tgoto outofmem;\n\t\t    *new_start = NUL;\n\t\t    new_end = new_start;\n\t\t}\n\t\telse\n\t\t{\n\t\t    \/*\n\t\t     * Check if the temporary buffer is long enough to do the\n\t\t     * substitution into.  If not, make it larger (with a bit\n\t\t     * extra to avoid too many calls to alloc()\/free()).\n\t\t     *\/\n\t\t    len = (unsigned)STRLEN(new_start);\n\t\t    needed_len += len;\n\t\t    if (needed_len > (int)new_start_len)\n\t\t    {\n\t\t\tnew_start_len = needed_len + 50;\n\t\t\tif ((p1 = alloc(new_start_len)) == NULL)\n\t\t\t{\n\t\t\t    vim_free(new_start);\n\t\t\t    goto outofmem;\n\t\t\t}\n\t\t\tmch_memmove(p1, new_start, (size_t)(len + 1));\n\t\t\tvim_free(new_start);\n\t\t\tnew_start = p1;\n\t\t    }\n\t\t    new_end = new_start + len;\n\t\t}\n\n\t\t\/*\n\t\t * copy the text up to the part that matched\n\t\t *\/\n\t\tmch_memmove(new_end, sub_firstline + copycol, (size_t)copy_len);\n\t\tnew_end += copy_len;\n\n\t\t(void)vim_regsub_multi(®match,\n\t\t\t\t    sub_firstlnum - regmatch.startpos[0].lnum,\n\t\t\t\t      sub, new_end, TRUE, magic_isset(), TRUE);\n\t\tsub_nsubs++;\n\t\tdid_sub = TRUE;\n\n\t\t\/\/ Move the cursor to the start of the line, to avoid that it\n\t\t\/\/ is beyond the end of the line after the substitution.\n\t\tcurwin->w_cursor.col = 0;\n\n\t\t\/\/ For a multi-line match, make a copy of the last matched\n\t\t\/\/ line and continue in that one.\n\t\tif (nmatch > 1)\n\t\t{\n\t\t    sub_firstlnum += nmatch - 1;\n\t\t    vim_free(sub_firstline);\n\t\t    sub_firstline = vim_strsave(ml_get(sub_firstlnum));\n\t\t    \/\/ When going beyond the last line, stop substituting.\n\t\t    if (sub_firstlnum <= line2)\n\t\t\tdo_again = TRUE;\n\t\t    else\n\t\t\tsubflags.do_all = FALSE;\n\t\t}\n\n\t\t\/\/ Remember next character to be copied.\n\t\tcopycol = regmatch.endpos[0].col;\n\n\t\tif (skip_match)\n\t\t{\n\t\t    \/\/ Already hit end of the buffer, sub_firstlnum is one\n\t\t    \/\/ less than what it ought to be.\n\t\t    vim_free(sub_firstline);\n\t\t    sub_firstline = vim_strsave((char_u *)\"\");\n\t\t    copycol = 0;\n\t\t}\n\n\t\t\/*\n\t\t * Now the trick is to replace CTRL-M chars with a real line\n\t\t * break.  This would make it impossible to insert a CTRL-M in\n\t\t * the text.  The line break can be avoided by preceding the\n\t\t * CTRL-M with a backslash.  To be able to insert a backslash,\n\t\t * they must be doubled in the string and are halved here.\n\t\t * That is Vi compatible.\n\t\t *\/\n\t\tfor (p1 = new_end; *p1; ++p1)\n\t\t{\n\t\t    if (p1[0] == '\\\\' && p1[1] != NUL)  \/\/ remove backslash\n\t\t    {\n\t\t\tSTRMOVE(p1, p1 + 1);\n#ifdef FEAT_PROP_POPUP\n\t\t\tif (curbuf->b_has_textprop)\n\t\t\t{\n\t\t\t    \/\/ When text properties are changed, need to save\n\t\t\t    \/\/ for undo first, unless done already.\n\t\t\t    if (adjust_prop_columns(lnum,\n\t\t\t\t\t(colnr_T)(p1 - new_start), -1,\n\t\t\t\t\tapc_flags))\n\t\t\t\tapc_flags &= ~APC_SAVE_FOR_UNDO;\n\t\t\t}\n#endif\n\t\t    }\n\t\t    else if (*p1 == CAR)\n\t\t    {\n\t\t\tif (u_inssub(lnum) == OK)   \/\/ prepare for undo\n\t\t\t{\n\t\t\t    colnr_T\tplen = (colnr_T)(p1 - new_start + 1);\n\n\t\t\t    *p1 = NUL;\t\t    \/\/ truncate up to the CR\n\t\t\t    ml_append(lnum - 1, new_start, plen, FALSE);\n\t\t\t    mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);\n\t\t\t    if (subflags.do_ask)\n\t\t\t\tappended_lines(lnum - 1, 1L);\n\t\t\t    else\n\t\t\t    {\n\t\t\t\tif (first_line == 0)\n\t\t\t\t    first_line = lnum;\n\t\t\t\tlast_line = lnum + 1;\n\t\t\t    }\n#ifdef FEAT_PROP_POPUP\n\t\t\t    adjust_props_for_split(lnum + 1, lnum, plen, 1);\n#endif\n\t\t\t    \/\/ all line numbers increase\n\t\t\t    ++sub_firstlnum;\n\t\t\t    ++lnum;\n\t\t\t    ++line2;\n\t\t\t    \/\/ move the cursor to the new line, like Vi\n\t\t\t    ++curwin->w_cursor.lnum;\n\t\t\t    \/\/ copy the rest\n\t\t\t    STRMOVE(new_start, p1 + 1);\n\t\t\t    p1 = new_start - 1;\n\t\t\t}\n\t\t    }\n\t\t    else if (has_mbyte)\n\t\t\tp1 += (*mb_ptr2len)(p1) - 1;\n\t\t}\n\n\t\t\/*\n\t\t * 4. If do_all is set, find next match.\n\t\t * Prevent endless loop with patterns that match empty\n\t\t * strings, e.g. :s\/$\/pat\/g or :s\/[a-z]* \/(&)\/g.\n\t\t * But \":s\/\\n\/#\/\" is OK.\n\t\t *\/\nskip:\n\t\t\/\/ We already know that we did the last subst when we are at\n\t\t\/\/ the end of the line, except that a pattern like\n\t\t\/\/ \"bar\\|\\nfoo\" may match at the NUL.  \"lnum\" can be below\n\t\t\/\/ \"line2\" when there is a \\zs in the pattern after a line\n\t\t\/\/ break.\n\t\tlastone = (skip_match\n\t\t\t|| got_int\n\t\t\t|| got_quit\n\t\t\t|| lnum > line2\n\t\t\t|| !(subflags.do_all || do_again)\n\t\t\t|| (sub_firstline[matchcol] == NUL && nmatch <= 1\n\t\t\t\t\t && !re_multiline(regmatch.regprog)));\n\t\tnmatch = -1;\n\n\t\t\/*\n\t\t * Replace the line in the buffer when needed.  This is\n\t\t * skipped when there are more matches.\n\t\t * The check for nmatch_tl is needed for when multi-line\n\t\t * matching must replace the lines before trying to do another\n\t\t * match, otherwise \"\\@<=\" won't work.\n\t\t * When the match starts below where we start searching also\n\t\t * need to replace the line first (using \\zs after \\n).\n\t\t *\/\n\t\tif (lastone\n\t\t\t|| nmatch_tl > 0\n\t\t\t|| (nmatch = vim_regexec_multi(®match, curwin,\n\t\t\t\t\t\t\tcurbuf, sub_firstlnum,\n\t\t\t\t\t\t    matchcol, NULL, NULL)) == 0\n\t\t\t|| regmatch.startpos[0].lnum > 0)\n\t\t{\n\t\t    if (new_start != NULL)\n\t\t    {\n\t\t\t\/*\n\t\t\t * Copy the rest of the line, that didn't match.\n\t\t\t * \"matchcol\" has to be adjusted, we use the end of\n\t\t\t * the line as reference, because the substitute may\n\t\t\t * have changed the number of characters.  Same for\n\t\t\t * \"prev_matchcol\".\n\t\t\t *\/\n\t\t\tSTRCAT(new_start, sub_firstline + copycol);\n\t\t\tmatchcol = (colnr_T)STRLEN(sub_firstline) - matchcol;\n\t\t\tprev_matchcol = (colnr_T)STRLEN(sub_firstline)\n\t\t\t\t\t\t\t      - prev_matchcol;\n\n\t\t\tif (u_savesub(lnum) != OK)\n\t\t\t    break;\n\t\t\tml_replace(lnum, new_start, TRUE);\n\n\t\t\tif (nmatch_tl > 0)\n\t\t\t{\n\t\t\t    \/*\n\t\t\t     * Matched lines have now been substituted and are\n\t\t\t     * useless, delete them.  The part after the match\n\t\t\t     * has been appended to new_start, we don't need\n\t\t\t     * it in the buffer.\n\t\t\t     *\/\n\t\t\t    ++lnum;\n\t\t\t    if (u_savedel(lnum, nmatch_tl) != OK)\n\t\t\t\tbreak;\n\t\t\t    for (i = 0; i < nmatch_tl; ++i)\n\t\t\t\tml_delete(lnum);\n\t\t\t    mark_adjust(lnum, lnum + nmatch_tl - 1,\n\t\t\t\t\t\t   (long)MAXLNUM, -nmatch_tl);\n\t\t\t    if (subflags.do_ask)\n\t\t\t\tdeleted_lines(lnum, nmatch_tl);\n\t\t\t    --lnum;\n\t\t\t    line2 -= nmatch_tl; \/\/ nr of lines decreases\n\t\t\t    nmatch_tl = 0;\n\t\t\t}\n\n\t\t\t\/\/ When asking, undo is saved each time, must also set\n\t\t\t\/\/ changed flag each time.\n\t\t\tif (subflags.do_ask)\n\t\t\t    changed_bytes(lnum, 0);\n\t\t\telse\n\t\t\t{\n\t\t\t    if (first_line == 0)\n\t\t\t\tfirst_line = lnum;\n\t\t\t    last_line = lnum + 1;\n\t\t\t}\n\n\t\t\tsub_firstlnum = lnum;\n\t\t\tvim_free(sub_firstline);    \/\/ free the temp buffer\n\t\t\tsub_firstline = new_start;\n\t\t\tnew_start = NULL;\n\t\t\tmatchcol = (colnr_T)STRLEN(sub_firstline) - matchcol;\n\t\t\tprev_matchcol = (colnr_T)STRLEN(sub_firstline)\n\t\t\t\t\t\t\t      - prev_matchcol;\n\t\t\tcopycol = 0;\n\t\t    }\n\t\t    if (nmatch == -1 && !lastone)\n\t\t\tnmatch = vim_regexec_multi(®match, curwin, curbuf,\n\t\t\t\t\t  sub_firstlnum, matchcol, NULL, NULL);\n\n\t\t    \/*\n\t\t     * 5. break if there isn't another match in this line\n\t\t     *\/\n\t\t    if (nmatch <= 0)\n\t\t    {\n\t\t\t\/\/ If the match found didn't start where we were\n\t\t\t\/\/ searching, do the next search in the line where we\n\t\t\t\/\/ found the match.\n\t\t\tif (nmatch == -1)\n\t\t\t    lnum -= regmatch.startpos[0].lnum;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\n\t\tline_breakcheck();\n\t    }\n\n\t    if (did_sub)\n\t\t++sub_nlines;\n\t    vim_free(new_start);\t\/\/ for when substitute was cancelled\n\t    VIM_CLEAR(sub_firstline);\t\/\/ free the copy of the original line\n\t}\n\n\tline_breakcheck();\n    }\n\n    if (first_line != 0)\n    {\n\t\/\/ Need to subtract the number of added lines from \"last_line\" to get\n\t\/\/ the line number before the change (same as adding the number of\n\t\/\/ deleted lines).\n\ti = curbuf->b_ml.ml_line_count - old_line_count;\n\tchanged_lines(first_line, 0, last_line - i, i);\n    }\n\noutofmem:\n    vim_free(sub_firstline); \/\/ may have to free allocated copy of the line\n\n    \/\/ \":s\/pat\/\/n\" doesn't move the cursor\n    if (subflags.do_count)\n\tcurwin->w_cursor = old_cursor;\n\n    if (sub_nsubs > start_nsubs)\n    {\n\tif ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)\n\t{\n\t    \/\/ Set the '[ and '] marks.\n\t    curbuf->b_op_start.lnum = eap->line1;\n\t    curbuf->b_op_end.lnum = line2;\n\t    curbuf->b_op_start.col = curbuf->b_op_end.col = 0;\n\t}\n\n\tif (!global_busy)\n\t{\n\t    \/\/ when interactive leave cursor on the match\n\t    if (!subflags.do_ask)\n\t    {\n\t\tif (endcolumn)\n\t\t    coladvance((colnr_T)MAXCOL);\n\t\telse\n\t\t    beginline(BL_WHITE | BL_FIX);\n\t    }\n\t    if (!do_sub_msg(subflags.do_count) && subflags.do_ask)\n\t\tmsg(\"\");\n\t}\n\telse\n\t    global_need_beginline = TRUE;\n\tif (subflags.do_print)\n\t    print_line(curwin->w_cursor.lnum,\n\t\t\t\t\t subflags.do_number, subflags.do_list);\n    }\n    else if (!global_busy)\n    {\n\tif (got_int)\t\t\/\/ interrupted\n\t    emsg(_(e_interrupted));\n\telse if (got_match)\t\/\/ did find something but nothing substituted\n\t    msg(\"\");\n\telse if (subflags.do_error)\t\/\/ nothing found\n\t    semsg(_(e_pattern_not_found_str), get_search_pat());\n    }\n\n#ifdef FEAT_FOLDING\n    if (subflags.do_ask && hasAnyFolding(curwin))\n\t\/\/ Cursor position may require updating\n\tchanged_window_setting();\n#endif\n\n    vim_regfree(regmatch.regprog);\n\n    \/\/ Restore the flag values, they can be used for \":&&\".\n    subflags.do_all = save_do_all;\n    subflags.do_ask = save_do_ask;\n}","target":1,"code_token_length":9333,"total_token_length":9569,"max_tokens_setting":11000}
+{"idx":208506,"func":"tgs_build_reply(astgs_request_t priv,\n\t\thdb_entry_ex *krbtgt,\n\t\tkrb5_enctype krbtgt_etype,\n\t\tconst krb5_keyblock *replykey,\n\t\tint rk_is_subkey,\n\t\tkrb5_ticket *ticket,\n\t\tconst char **e_text,\n\t\tAuthorizationData **auth_data,\n\t\tconst struct sockaddr *from_addr)\n{\n    krb5_context context = priv->context;\n    krb5_kdc_configuration *config = priv->config;\n    KDC_REQ *req = &priv->req;\n    KDC_REQ_BODY *b = &priv->req.req_body;\n    const char *from = priv->from;\n    krb5_error_code ret, ret2;\n    krb5_principal cp = NULL, sp = NULL, rsp = NULL, tp = NULL, dp = NULL;\n    krb5_principal krbtgt_out_principal = NULL;\n    char *spn = NULL, *cpn = NULL, *tpn = NULL, *dpn = NULL, *krbtgt_out_n = NULL;\n    hdb_entry_ex *server = NULL, *client = NULL, *s4u2self_impersonated_client = NULL;\n    HDB *clientdb, *s4u2self_impersonated_clientdb;\n    krb5_realm ref_realm = NULL;\n    EncTicketPart *tgt = &ticket->ticket;\n    krb5_principals spp = NULL;\n    const EncryptionKey *ekey;\n    krb5_keyblock sessionkey;\n    krb5_kvno kvno;\n    krb5_data rspac;\n    const char *tgt_realm = \/* Realm of TGT issuer *\/\n        krb5_principal_get_realm(context, krbtgt->entry.principal);\n    const char *our_realm = \/* Realm of this KDC *\/\n        krb5_principal_get_comp_string(context, krbtgt->entry.principal, 1);\n    char **capath = NULL;\n    size_t num_capath = 0;\n\n    hdb_entry_ex *krbtgt_out = NULL;\n\n    METHOD_DATA enc_pa_data;\n\n    PrincipalName *s;\n    Realm r;\n    EncTicketPart adtkt;\n    char opt_str[128];\n    int signedpath = 0;\n\n    Key *tkey_check;\n    Key *tkey_sign;\n    int flags = HDB_F_FOR_TGS_REQ;\n\n    memset(&sessionkey, 0, sizeof(sessionkey));\n    memset(&adtkt, 0, sizeof(adtkt));\n    krb5_data_zero(&rspac);\n    memset(&enc_pa_data, 0, sizeof(enc_pa_data));\n\n    s = b->sname;\n    r = b->realm;\n\n    \/*\n     * The canonicalize KDC option is passed as a hint to the backend, but\n     * can typically be ignored. Per RFC 6806, names are not canonicalized\n     * in response to a TGS request (although we make an exception, see\n     * force-canonicalize below).\n     *\/\n    if (b->kdc_options.canonicalize)\n\tflags |= HDB_F_CANON;\n\n    if(b->kdc_options.enc_tkt_in_skey){\n\tTicket *t;\n\thdb_entry_ex *uu;\n\tkrb5_principal p;\n\tKey *uukey;\n\tkrb5uint32 second_kvno = 0;\n\tkrb5uint32 *kvno_ptr = NULL;\n\n\tif(b->additional_tickets == NULL ||\n\t   b->additional_tickets->len == 0){\n\t    ret = KRB5KDC_ERR_BADOPTION; \/* ? *\/\n\t    kdc_log(context, config, 4,\n\t\t    \"No second ticket present in user-to-user request\");\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"No second ticket present in user-to-user request\");\n\t    goto out;\n\t}\n\tt = &b->additional_tickets->val[0];\n\tif(!get_krbtgt_realm(&t->sname)){\n\t    kdc_log(context, config, 4,\n\t\t    \"Additional ticket is not a ticket-granting ticket\");\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Additional ticket is not a ticket-granting ticket\");\n\t    ret = KRB5KDC_ERR_POLICY;\n\t    goto out;\n\t}\n\t_krb5_principalname2krb5_principal(context, &p, t->sname, t->realm);\n\tret = krb5_unparse_name(context, p, &tpn);\n\tif (ret)\n\t\tgoto out;\n\tif(t->enc_part.kvno){\n\t    second_kvno = *t->enc_part.kvno;\n\t    kvno_ptr = &second_kvno;\n\t}\n\tret = _kdc_db_fetch(context, config, p,\n\t\t\t    HDB_F_GET_KRBTGT, kvno_ptr,\n\t\t\t    NULL, &uu);\n\tkrb5_free_principal(context, p);\n\tif(ret){\n\t    if (ret == HDB_ERR_NOENTRY)\n\t\tret = KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN;\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"User-to-user service principal (TGS) unknown\");\n\t    goto out;\n\t}\n\tret = hdb_enctype2key(context, &uu->entry, NULL,\n\t\t\t      t->enc_part.etype, &uukey);\n\tif(ret){\n\t    _kdc_free_ent(context, uu);\n\t    ret = KRB5KDC_ERR_ETYPE_NOSUPP; \/* XXX *\/\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"User-to-user enctype not supported\");\n\t    goto out;\n\t}\n\tret = krb5_decrypt_ticket(context, t, &uukey->key, &adtkt, 0);\n\t_kdc_free_ent(context, uu);\n\tif(ret) {\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"User-to-user TGT decrypt failure\");\n\t    goto out;\n        }\n\n\tret = verify_flags(context, config, &adtkt, tpn);\n\tif (ret) {\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"User-to-user TGT expired or invalid\");\n\t    goto out;\n        }\n\n\ts = &adtkt.cname;\n\tr = adtkt.crealm;\n    }\n\n    _krb5_principalname2krb5_principal(context, &sp, *s, r);\n    ret = krb5_unparse_name(context, sp, &priv->sname);\n    if (ret)\n\tgoto out;\n    spn = priv->sname;\n    _krb5_principalname2krb5_principal(context, &cp, tgt->cname, tgt->crealm);\n    ret = krb5_unparse_name(context, cp, &priv->cname);\n    if (ret)\n\tgoto out;\n    cpn = priv->cname;\n    unparse_flags (KDCOptions2int(b->kdc_options),\n\t\t   asn1_KDCOptions_units(),\n\t\t   opt_str, sizeof(opt_str));\n    if(*opt_str)\n\tkdc_log(context, config, 4,\n\t\t\"TGS-REQ %s from %s for %s [%s]\",\n\t\tcpn, from, spn, opt_str);\n    else\n\tkdc_log(context, config, 4,\n\t\t\"TGS-REQ %s from %s for %s\", cpn, from, spn);\n\n    \/*\n     * Fetch server\n     *\/\n\nserver_lookup:\n    ret = _kdc_db_fetch(context, config, sp,\n                        HDB_F_GET_SERVER | HDB_F_DELAY_NEW_KEYS | flags,\n\t\t\tNULL, NULL, &server);\n    priv->server = server;\n    if (ret == HDB_ERR_NOT_FOUND_HERE) {\n\tkdc_log(context, config, 5, \"target %s does not have secrets at this KDC, need to proxy\", spn);\n        _kdc_audit_addreason((kdc_request_t)priv, \"Target not found here\");\n\tgoto out;\n    } else if (ret == HDB_ERR_WRONG_REALM) {\n        free(ref_realm);\n\tref_realm = strdup(server->entry.principal->realm);\n\tif (ref_realm == NULL) {\n            ret = krb5_enomem(context);\n\t    goto out;\n\t}\n\n\tkdc_log(context, config, 4,\n\t\t\"Returning a referral to realm %s for \"\n\t\t\"server %s.\",\n\t\tref_realm, spn);\n\tkrb5_free_principal(context, sp);\n\tsp = NULL;\n\tret = krb5_make_principal(context, &sp, r, KRB5_TGS_NAME,\n\t\t\t\t  ref_realm, NULL);\n\tif (ret)\n\t    goto out;\n\tfree(priv->sname);\n        priv->sname = NULL;\n\tret = krb5_unparse_name(context, sp, &priv->sname);\n\tif (ret)\n\t    goto out;\n\tspn = priv->sname;\n\n\tgoto server_lookup;\n    } else if (ret) {\n\tconst char *new_rlm, *msg;\n\tRealm req_rlm;\n\tkrb5_realm *realms;\n\n\tif ((req_rlm = get_krbtgt_realm(&sp->name)) != NULL) {\n            if (capath == NULL) {\n                \/* With referalls, hierarchical capaths are always enabled *\/\n                ret2 = _krb5_find_capath(context, tgt->crealm, our_realm,\n                                         req_rlm, TRUE, &capath, &num_capath);\n                if (ret2) {\n                    ret = ret2;\n                    _kdc_audit_addreason((kdc_request_t)priv,\n                                         \"No trusted path from client realm to ours\");\n                    goto out;\n                }\n            }\n            new_rlm = num_capath > 0 ? capath[--num_capath] : NULL;\n            if (new_rlm) {\n                kdc_log(context, config, 5, \"krbtgt from %s via %s for \"\n                        \"realm %s not found, trying %s\", tgt->crealm,\n                        our_realm, req_rlm, new_rlm);\n\n                free(ref_realm);\n                ref_realm = strdup(new_rlm);\n                if (ref_realm == NULL) {\n                    ret = krb5_enomem(context);\n                    goto out;\n                }\n\n                krb5_free_principal(context, sp);\n                sp = NULL;\n                krb5_make_principal(context, &sp, r,\n                                    KRB5_TGS_NAME, ref_realm, NULL);\n                free(priv->sname);\n                priv->sname = NULL;\n                ret = krb5_unparse_name(context, sp, &priv->sname);\n                if (ret)\n                    goto out;\n                spn = priv->sname;\n                goto server_lookup;\n            }\n\t} else if (need_referral(context, config, &b->kdc_options, sp, &realms)) {\n\t    if (strcmp(realms[0], sp->realm) != 0) {\n\t\tkdc_log(context, config, 4,\n\t\t\t\"Returning a referral to realm %s for \"\n\t\t\t\"server %s that was not found\",\n\t\t\trealms[0], spn);\n\t\tkrb5_free_principal(context, sp);\n                sp = NULL;\n\t\tkrb5_make_principal(context, &sp, r, KRB5_TGS_NAME,\n\t\t\t\t    realms[0], NULL);\n\t\tfree(priv->sname);\n                priv->sname = NULL;\n\t\tret = krb5_unparse_name(context, sp, &priv->sname);\n\t\tif (ret) {\n\t\t    krb5_free_host_realm(context, realms);\n\t\t    goto out;\n\t\t}\n\t\tspn = priv->sname;\n\n                free(ref_realm);\n\t\tref_realm = strdup(realms[0]);\n\n\t\tkrb5_free_host_realm(context, realms);\n\t\tgoto server_lookup;\n\t    }\n\t    krb5_free_host_realm(context, realms);\n\t}\n\tmsg = krb5_get_error_message(context, ret);\n\tkdc_log(context, config, 3,\n\t\t\"Server not found in database: %s: %s\", spn, msg);\n\tkrb5_free_error_message(context, msg);\n\tif (ret == HDB_ERR_NOENTRY)\n\t    ret = KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN;\n        _kdc_audit_addreason((kdc_request_t)priv,\n                             \"Service principal unknown\");\n\tgoto out;\n    }\n\n    \/*\n     * RFC 6806 notes that names MUST NOT be changed in the response to\n     * a TGS request. Hence we ignore the setting of the canonicalize\n     * KDC option. However, for legacy interoperability we do allow the\n     * backend to override this by setting the force-canonicalize HDB\n     * flag in the server entry.\n     *\/\n    if (server->entry.flags.force_canonicalize)\n\trsp = server->entry.principal;\n    else\n\trsp = sp;\n\n    \/*\n     * Select enctype, return key and kvno.\n     *\/\n\n    {\n\tkrb5_enctype etype;\n\n\tif(b->kdc_options.enc_tkt_in_skey) {\n\t    size_t i;\n\t    ekey = &adtkt.key;\n\t    for(i = 0; i < b->etype.len; i++)\n\t\tif (b->etype.val[i] == adtkt.key.keytype)\n\t\t    break;\n\t    if(i == b->etype.len) {\n\t\tkdc_log(context, config, 4,\n\t\t\t\"Addition ticket have not matching etypes\");\n\t\tkrb5_clear_error_message(context);\n\t\tret = KRB5KDC_ERR_ETYPE_NOSUPP;\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"No matching enctypes for 2nd ticket\");\n\t\tgoto out;\n\t    }\n\t    etype = b->etype.val[i];\n\t    kvno = 0;\n\t} else {\n\t    Key *skey;\n\n\t    ret = _kdc_find_etype(priv, krb5_principal_is_krbtgt(context, sp)\n\t\t\t\t\t\t\t     ? KFE_IS_TGS : 0,\n\t\t\t\t  b->etype.val, b->etype.len, &etype, NULL,\n\t\t\t\t  NULL);\n\t    if(ret) {\n\t\tkdc_log(context, config, 4,\n\t\t\t\"Server (%s) has no support for etypes\", spn);\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"Enctype not supported\");\n\t\tgoto out;\n\t    }\n\t    ret = _kdc_get_preferred_key(context, config, server, spn,\n\t\t\t\t\t NULL, &skey);\n\t    if(ret) {\n\t\tkdc_log(context, config, 4,\n\t\t\t\"Server (%s) has no supported etypes\", spn);\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"Enctype not supported\");\n\t\tgoto out;\n\t    }\n\t    ekey = &skey->key;\n\t    kvno = server->entry.kvno;\n\t}\n\n\tret = krb5_generate_random_keyblock(context, etype, &sessionkey);\n\tif (ret)\n\t    goto out;\n    }\n\n    \/*\n     * Check that service is in the same realm as the krbtgt. If it's\n     * not the same, it's someone that is using a uni-directional trust\n     * backward.\n     *\/\n\n    \/*\n     * Validate authorization data\n     *\/\n\n    ret = hdb_enctype2key(context, &krbtgt->entry, NULL, \/* XXX use the right kvno! *\/\n\t\t\t  krbtgt_etype, &tkey_check);\n    if(ret) {\n\tkdc_log(context, config, 4,\n\t\t    \"Failed to find key for krbtgt PAC check\");\n        _kdc_audit_addreason((kdc_request_t)priv,\n                             \"No key for krbtgt PAC check\");\n\tgoto out;\n    }\n\n    \/* \n     * Now refetch the primary krbtgt, and get the current kvno (the\n     * sign check may have been on an old kvno, and the server may\n     * have been an incoming trust)\n     *\/\n    \n    ret = krb5_make_principal(context,\n                              &krbtgt_out_principal,\n                              our_realm,\n                              KRB5_TGS_NAME,\n                              our_realm,\n                              NULL);\n    if (ret) {\n        kdc_log(context, config, 4,\n                \"Failed to make krbtgt principal name object for \"\n                \"authz-data signatures\");\n        goto out;\n    }\n    ret = krb5_unparse_name(context, krbtgt_out_principal, &krbtgt_out_n);\n    if (ret) {\n        kdc_log(context, config, 4,\n                \"Failed to make krbtgt principal name object for \"\n                \"authz-data signatures\");\n        goto out;\n    }\n\n    ret = _kdc_db_fetch(context, config, krbtgt_out_principal,\n\t\t\tHDB_F_GET_KRBTGT, NULL, NULL, &krbtgt_out);\n    if (ret) {\n\tchar *ktpn = NULL;\n\tret = krb5_unparse_name(context, krbtgt->entry.principal, &ktpn);\n\tkdc_log(context, config, 4,\n\t\t\"No such principal %s (needed for authz-data signature keys) \"\n\t\t\"while processing TGS-REQ for service %s with krbtg %s\",\n\t\tkrbtgt_out_n, spn, (ret == 0) ? ktpn : \"<unknown>\");\n\tfree(ktpn);\n\tret = KRB5KRB_AP_ERR_NOT_US;\n\tgoto out;\n    }\n\n    \/* \n     * The first realm is the realm of the service, the second is\n     * krbtgt\/<this>\/@REALM component of the krbtgt DN the request was\n     * encrypted to.  The redirection via the krbtgt_out entry allows\n     * the DB to possibly correct the case of the realm (Samba4 does\n     * this) before the strcmp() \n     *\/\n    if (strcmp(krb5_principal_get_realm(context, server->entry.principal),\n\t       krb5_principal_get_realm(context, krbtgt_out->entry.principal)) != 0) {\n\tchar *ktpn;\n\tret = krb5_unparse_name(context, krbtgt_out->entry.principal, &ktpn);\n\tkdc_log(context, config, 4,\n\t\t\"Request with wrong krbtgt: %s\",\n\t\t(ret == 0) ? ktpn : \"<unknown>\");\n\tif(ret == 0)\n\t    free(ktpn);\n\tret = KRB5KRB_AP_ERR_NOT_US;\n        _kdc_audit_addreason((kdc_request_t)priv, \"Request with wrong TGT\");\n\tgoto out;\n    }\n\n    ret = _kdc_get_preferred_key(context, config, krbtgt_out, krbtgt_out_n,\n\t\t\t\t NULL, &tkey_sign);\n    if (ret) {\n\tkdc_log(context, config, 4,\n\t\t    \"Failed to find key for krbtgt PAC signature\");\n        _kdc_audit_addreason((kdc_request_t)priv,\n                             \"Failed to find key for krbtgt PAC signature\");\n\tgoto out;\n    }\n    ret = hdb_enctype2key(context, &krbtgt_out->entry, NULL,\n\t\t\t  tkey_sign->key.keytype, &tkey_sign);\n    if(ret) {\n\tkdc_log(context, config, 4,\n\t\t    \"Failed to find key for krbtgt PAC signature\");\n        _kdc_audit_addreason((kdc_request_t)priv,\n                             \"Failed to find key for krbtgt PAC signature\");\n\tgoto out;\n    }\n\n    {\n        krb5_data verified_cas;\n\n        \/*\n         * If the client doesn't exist in the HDB but has a TGT and it's\n         * obtained with PKINIT then we assume it's a synthetic client -- that\n         * is, a client whose name was vouched for by a CA using a PKINIT SAN,\n         * but which doesn't exist in the HDB proper.  We'll allow such a\n         * client to do TGT requests even though normally we'd reject all\n         * clients that don't exist in the HDB.\n         *\/\n        ret = krb5_ticket_get_authorization_data_type(context, ticket,\n                                                      KRB5_AUTHDATA_INITIAL_VERIFIED_CAS,\n                                                      &verified_cas);\n        if (ret == 0) {\n            krb5_data_free(&verified_cas);\n            flags |= HDB_F_SYNTHETIC_OK;\n        }\n    }\n    ret = _kdc_db_fetch(context, config, cp, HDB_F_GET_CLIENT | flags,\n\t\t\tNULL, &clientdb, &client);\n    flags &= ~HDB_F_SYNTHETIC_OK;\n    priv->client = client;\n    if(ret == HDB_ERR_NOT_FOUND_HERE) {\n\t\/* This is OK, we are just trying to find out if they have\n\t * been disabled or deleted in the meantime, missing secrets\n\t * is OK *\/\n    } else if(ret){\n\tconst char *krbtgt_realm, *msg;\n\n\t\/*\n\t * If the client belongs to the same realm as our krbtgt, it\n\t * should exist in the local database.\n\t *\n\t *\/\n\n\tkrbtgt_realm = krb5_principal_get_realm(context, krbtgt_out->entry.principal);\n\n\tif(strcmp(krb5_principal_get_realm(context, cp), krbtgt_realm) == 0) {\n\t    if (ret == HDB_ERR_NOENTRY)\n\t\tret = KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN;\n\t    kdc_log(context, config, 4, \"Client no longer in database: %s\",\n\t\t    cpn);\n            _kdc_audit_addreason((kdc_request_t)priv, \"Client no longer in HDB\");\n\t    goto out;\n\t}\n\n\tmsg = krb5_get_error_message(context, ret);\n\tkdc_log(context, config, 4, \"Client not found in database: %s\", msg);\n        _kdc_audit_addreason((kdc_request_t)priv, \"Client does not exist\");\n\tkrb5_free_error_message(context, msg);\n    } else if (ret == 0 &&\n               (client->entry.flags.invalid || !client->entry.flags.client)) {\n        _kdc_audit_addreason((kdc_request_t)priv, \"Client has invalid bit set\");\n        kdc_log(context, config, 4, \"Client has invalid bit set\");\n        ret = KRB5KDC_ERR_POLICY;\n        goto out;\n    }\n\n    ret = check_PAC(context, config, cp, NULL,\n\t\t    client, server, krbtgt,\n\t\t    &tkey_check->key,\n\t\t    ekey, &tkey_sign->key,\n\t\t    tgt, &rspac, &signedpath);\n    if (ret) {\n\tconst char *msg = krb5_get_error_message(context, ret);\n        _kdc_audit_addreason((kdc_request_t)priv, \"PAC check failed\");\n\tkdc_log(context, config, 4,\n\t\t\"Verify PAC failed for %s (%s) from %s with %s\",\n\t\tspn, cpn, from, msg);\n\tkrb5_free_error_message(context, msg);\n\tgoto out;\n    }\n\n    \/* also check the krbtgt for signature *\/\n    ret = check_KRB5SignedPath(context,\n\t\t\t       config,\n\t\t\t       krbtgt,\n\t\t\t       cp,\n\t\t\t       tgt,\n\t\t\t       &spp,\n\t\t\t       &signedpath);\n    if (ret) {\n\tconst char *msg = krb5_get_error_message(context, ret);\n        _kdc_audit_addreason((kdc_request_t)priv, \"KRB5SignedPath check failed\");\n\tkdc_log(context, config, 4,\n\t\t\"KRB5SignedPath check failed for %s (%s) from %s with %s\",\n\t\tspn, cpn, from, msg);\n\tkrb5_free_error_message(context, msg);\n\tgoto out;\n    }\n\n    \/*\n     * Process request\n     *\/\n\n    \/* by default the tgt principal matches the client principal *\/\n    tp = cp;\n    tpn = cpn;\n\n    if (client) {\n\tconst PA_DATA *sdata;\n\tint i = 0;\n\n\tsdata = _kdc_find_padata(req, &i, KRB5_PADATA_FOR_USER);\n\tif (sdata) {\n\t    struct astgs_request_desc imp_req;\n\t    krb5_crypto crypto;\n\t    krb5_data datack;\n\t    PA_S4U2Self self;\n\t    const char *str;\n\n\t    ret = decode_PA_S4U2Self(sdata->padata_value.data,\n\t\t\t\t     sdata->padata_value.length,\n\t\t\t\t     &self, NULL);\n\t    if (ret) {\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"Failed to decode PA-S4U2Self\");\n\t\tkdc_log(context, config, 4, \"Failed to decode PA-S4U2Self\");\n\t\tgoto out;\n\t    }\n\n\t    if (!krb5_checksum_is_keyed(context, self.cksum.cksumtype)) {\n\t\tfree_PA_S4U2Self(&self);\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"PA-S4U2Self with unkeyed checksum\");\n\t\tkdc_log(context, config, 4, \"Reject PA-S4U2Self with unkeyed checksum\");\n\t\tret = KRB5KRB_AP_ERR_INAPP_CKSUM;\n\t\tgoto out;\n\t    }\n\n\t    ret = _krb5_s4u2self_to_checksumdata(context, &self, &datack);\n\t    if (ret)\n\t\tgoto out;\n\n\t    ret = krb5_crypto_init(context, &tgt->key, 0, &crypto);\n\t    if (ret) {\n\t\tconst char *msg = krb5_get_error_message(context, ret);\n\t\tfree_PA_S4U2Self(&self);\n\t\tkrb5_data_free(&datack);\n\t\tkdc_log(context, config, 4, \"krb5_crypto_init failed: %s\", msg);\n\t\tkrb5_free_error_message(context, msg);\n\t\tgoto out;\n\t    }\n\n\t    \/* Allow HMAC_MD5 checksum with any key type *\/\n\t    if (self.cksum.cksumtype == CKSUMTYPE_HMAC_MD5) {\n\t\tstruct krb5_crypto_iov iov;\n\t\tunsigned char csdata[16];\n\t\tChecksum cs;\n\n\t\tcs.checksum.length = sizeof(csdata);\n\t\tcs.checksum.data = &csdata;\n\n\t\tiov.data.data = datack.data;\n\t\tiov.data.length = datack.length;\n\t\tiov.flags = KRB5_CRYPTO_TYPE_DATA;\n\n\t\tret = _krb5_HMAC_MD5_checksum(context, NULL, &crypto->key,\n\t\t\t\t\t      KRB5_KU_OTHER_CKSUM, &iov, 1,\n\t\t\t\t\t      &cs);\n\t\tif (ret == 0 &&\n\t\t    krb5_data_ct_cmp(&cs.checksum, &self.cksum.checksum) != 0)\n\t\t    ret = KRB5KRB_AP_ERR_BAD_INTEGRITY;\n\t    }\n\t    else {\n\t\tret = krb5_verify_checksum(context,\n\t\t\t\t\t   crypto,\n\t\t\t\t\t   KRB5_KU_OTHER_CKSUM,\n\t\t\t\t\t   datack.data,\n\t\t\t\t\t   datack.length,\n\t\t\t\t\t   &self.cksum);\n\t    }\n\t    krb5_data_free(&datack);\n\t    krb5_crypto_destroy(context, crypto);\n\t    if (ret) {\n\t\tconst char *msg = krb5_get_error_message(context, ret);\n\t\tfree_PA_S4U2Self(&self);\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"S4U2Self checksum failed\");\n\t\tkdc_log(context, config, 4,\n\t\t\t\"krb5_verify_checksum failed for S4U2Self: %s\", msg);\n\t\tkrb5_free_error_message(context, msg);\n\t\tgoto out;\n\t    }\n\n\t    ret = _krb5_principalname2krb5_principal(context,\n\t\t\t\t\t\t     &tp,\n\t\t\t\t\t\t     self.name,\n\t\t\t\t\t\t     self.realm);\n\t    free_PA_S4U2Self(&self);\n\t    if (ret)\n\t\tgoto out;\n\n\t    ret = krb5_unparse_name(context, tp, &tpn);\n\t    if (ret)\n\t\tgoto out;\n\n            \/*\n             * Note no HDB_F_SYNTHETIC_OK -- impersonating non-existent clients\n             * is probably not desirable!\n             *\/\n\t    ret = _kdc_db_fetch(context, config, tp, HDB_F_GET_CLIENT | flags,\n\t\t\t\tNULL, &s4u2self_impersonated_clientdb,\n\t\t\t\t&s4u2self_impersonated_client);\n\t    if (ret) {\n\t\tconst char *msg;\n\n\t\t\/*\n\t\t * If the client belongs to the same realm as our krbtgt, it\n\t\t * should exist in the local database.\n\t\t *\n\t\t *\/\n\n\t\tif (ret == HDB_ERR_NOENTRY)\n\t\t    ret = KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN;\n\t\tmsg = krb5_get_error_message(context, ret);\n                _kdc_audit_addreason((kdc_request_t)priv,\n                                     \"S4U2Self principal to impersonate not found\");\n\t\tkdc_log(context, config, 2,\n\t\t\t\"S4U2Self principal to impersonate %s not found in database: %s\",\n\t\t\ttpn, msg);\n\t\tkrb5_free_error_message(context, msg);\n\t\tgoto out;\n\t    }\n\n\t    \/* Ignore require_pwchange and pw_end attributes (as Windows does),\n\t     * since S4U2Self is not password authentication. *\/\n\t    s4u2self_impersonated_client->entry.flags.require_pwchange = FALSE;\n\t    free(s4u2self_impersonated_client->entry.pw_end);\n\t    s4u2self_impersonated_client->entry.pw_end = NULL;\n\n\t    imp_req = *priv;\n\t    imp_req.client = s4u2self_impersonated_client;\n\t    imp_req.client_princ = tp;\n\n\t    ret = kdc_check_flags(&imp_req, FALSE);\n\t    if (ret)\n\t\tgoto out; \/* kdc_check_flags() calls _kdc_audit_addreason() *\/\n\n\t    \/* If we were about to put a PAC into the ticket, we better fix it to be the right PAC *\/\n\t    if(rspac.data) {\n\t\tkrb5_pac p = NULL;\n\t\tkrb5_data_free(&rspac);\n\t\tret = _kdc_pac_generate(context, s4u2self_impersonated_client, &p);\n\t\tif (ret) {\n                    _kdc_audit_addreason((kdc_request_t)priv,\n                                         \"KRB5SignedPath missing\");\n\t\t    kdc_log(context, config, 4, \"PAC generation failed for -- %s\",\n\t\t\t    tpn);\n\t\t    goto out;\n\t\t}\n\t\tif (p != NULL) {\n\t\t    ret = _krb5_pac_sign(context, p, ticket->ticket.authtime,\n\t\t\t\t\t s4u2self_impersonated_client->entry.principal,\n\t\t\t\t\t ekey, &tkey_sign->key,\n\t\t\t\t\t &rspac);\n\t\t    krb5_pac_free(context, p);\n\t\t    if (ret) {\n\t\t\tkdc_log(context, config, 4, \"PAC signing failed for -- %s\",\n\t\t\t\ttpn);\n\t\t\tgoto out;\n\t\t    }\n\t\t}\n\t    }\n\n\t    \/*\n\t     * Check that service doing the impersonating is\n\t     * requesting a ticket to it-self.\n\t     *\/\n\t    ret = check_s4u2self(context, config, clientdb, client, sp);\n\t    if (ret) {\n\t\tkdc_log(context, config, 4, \"S4U2Self: %s is not allowed \"\n\t\t\t\"to impersonate to service \"\n\t\t\t\"(tried for user %s to service %s)\",\n\t\t\tcpn, tpn, spn);\n\t\tgoto out;\n\t    }\n\n\t    \/*\n\t     * If the service isn't trusted for authentication to\n\t     * delegation or if the impersonate client is disallowed\n\t     * forwardable, remove the forwardable flag.\n\t     *\/\n\n\t    if (client->entry.flags.trusted_for_delegation &&\n\t\ts4u2self_impersonated_client->entry.flags.forwardable) {\n\t\tstr = \"[forwardable]\";\n\t    } else {\n\t\tb->kdc_options.forwardable = 0;\n\t\tstr = \"\";\n\t    }\n\t    kdc_log(context, config, 4, \"s4u2self %s impersonating %s to \"\n\t\t    \"service %s %s\", cpn, tpn, spn, str);\n\t}\n    }\n\n    \/*\n     * Constrained delegation\n     *\/\n\n    if (client != NULL\n\t&& b->additional_tickets != NULL\n\t&& b->additional_tickets->len != 0\n\t&& b->kdc_options.cname_in_addl_tkt\n\t&& b->kdc_options.enc_tkt_in_skey == 0)\n    {\n\tint ad_signedpath = 0;\n\tKey *clientkey;\n\tTicket *t;\n\n\t\/*\n\t * Require that the KDC have issued the service's krbtgt (not\n\t * self-issued ticket with kimpersonate(1).\n\t *\/\n\tif (!signedpath) {\n\t    ret = KRB5KDC_ERR_BADOPTION;\n            _kdc_audit_addreason((kdc_request_t)priv, \"KRB5SignedPath missing\");\n\t    kdc_log(context, config, 4,\n\t\t    \"Constrained delegation done on service ticket %s\/%s\",\n\t\t    cpn, spn);\n\t    goto out;\n\t}\n\n\tt = &b->additional_tickets->val[0];\n\n\tret = hdb_enctype2key(context, &client->entry,\n\t\t\t      hdb_kvno2keys(context, &client->entry,\n\t\t\t\t\t    t->enc_part.kvno ? * t->enc_part.kvno : 0),\n\t\t\t      t->enc_part.etype, &clientkey);\n\tif(ret){\n\t    ret = KRB5KDC_ERR_ETYPE_NOSUPP; \/* XXX *\/\n\t    goto out;\n\t}\n\n\tret = krb5_decrypt_ticket(context, t, &clientkey->key, &adtkt, 0);\n\tif (ret) {\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Failed to decrypt constrained delegation ticket\");\n\t    kdc_log(context, config, 4,\n\t\t    \"failed to decrypt ticket for \"\n\t\t    \"constrained delegation from %s to %s \", cpn, spn);\n\t    goto out;\n\t}\n\n\tret = _krb5_principalname2krb5_principal(context,\n\t\t\t\t\t\t &tp,\n\t\t\t\t\t\t adtkt.cname,\n\t\t\t\t\t\t adtkt.crealm);\n\tif (ret)\n\t    goto out;\n\n\tret = krb5_unparse_name(context, tp, &tpn);\n\tif (ret)\n\t    goto out;\n\n        _kdc_audit_addkv((kdc_request_t)priv, 0, \"impersonatee\", \"%s\", tpn);\n\n\tret = _krb5_principalname2krb5_principal(context,\n\t\t\t\t\t\t &dp,\n\t\t\t\t\t\t t->sname,\n\t\t\t\t\t\t t->realm);\n\tif (ret)\n\t    goto out;\n\n\tret = krb5_unparse_name(context, dp, &dpn);\n\tif (ret)\n\t    goto out;\n\n\t\/* check that ticket is valid *\/\n\tif (adtkt.flags.forwardable == 0) {\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Missing forwardable flag on ticket for constrained delegation\");\n\t    kdc_log(context, config, 4,\n\t\t    \"Missing forwardable flag on ticket for \"\n\t\t    \"constrained delegation from %s (%s) as %s to %s \",\n\t\t    cpn, dpn, tpn, spn);\n\t    ret = KRB5KDC_ERR_BADOPTION;\n\t    goto out;\n\t}\n\n\tret = check_constrained_delegation(context, config, clientdb,\n\t\t\t\t\t   client, server, sp);\n\tif (ret) {\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Constrained delegation not allowed\");\n\t    kdc_log(context, config, 4,\n\t\t    \"constrained delegation from %s (%s) as %s to %s not allowed\",\n\t\t    cpn, dpn, tpn, spn);\n\t    goto out;\n\t}\n\n\tret = verify_flags(context, config, &adtkt, tpn);\n\tif (ret) {\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Constrained delegation ticket expired or invalid\");\n\t    goto out;\n\t}\n\n\tkrb5_data_free(&rspac);\n\n\t\/*\n\t * generate the PAC for the user.\n\t *\n\t * TODO: pass in t->sname and t->realm and build\n\t * a S4U_DELEGATION_INFO blob to the PAC.\n\t *\/\n\tret = check_PAC(context, config, tp, dp,\n\t\t\tclient, server, krbtgt,\n\t\t\t&clientkey->key,\n\t\t\tekey, &tkey_sign->key,\n\t\t\t&adtkt, &rspac, &ad_signedpath);\n\tif (ret) {\n\t    const char *msg = krb5_get_error_message(context, ret);\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Constrained delegation ticket PAC check failed\");\n\t    kdc_log(context, config, 4,\n\t\t    \"Verify delegated PAC failed to %s for client\"\n\t\t    \"%s (%s) as %s from %s with %s\",\n\t\t    spn, cpn, dpn, tpn, from, msg);\n\t    krb5_free_error_message(context, msg);\n\t    goto out;\n\t}\n\n\t\/*\n\t * Check that the KDC issued the user's ticket.\n\t *\/\n\tret = check_KRB5SignedPath(context,\n\t\t\t\t   config,\n\t\t\t\t   krbtgt,\n\t\t\t\t   cp,\n\t\t\t\t   &adtkt,\n\t\t\t\t   NULL,\n\t\t\t\t   &ad_signedpath);\n\tif (ret) {\n\t    const char *msg = krb5_get_error_message(context, ret);\n\t    kdc_log(context, config, 4,\n\t\t    \"KRB5SignedPath check from service %s failed \"\n\t\t    \"for delegation to %s for client %s (%s)\"\n\t\t    \"from %s failed with %s\",\n\t\t    spn, tpn, dpn, cpn, from, msg);\n\t    krb5_free_error_message(context, msg);\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"KRB5SignedPath check failed\");\n\t    goto out;\n\t}\n\n\tif (!ad_signedpath) {\n\t    ret = KRB5KDC_ERR_BADOPTION;\n\t    kdc_log(context, config, 4,\n\t\t    \"Ticket not signed with PAC nor SignedPath service %s failed \"\n\t\t    \"for delegation to %s for client %s (%s)\"\n\t\t    \"from %s\",\n\t\t    spn, tpn, dpn, cpn, from);\n            _kdc_audit_addreason((kdc_request_t)priv,\n                                 \"Constrained delegation ticket not signed\");\n\t    goto out;\n\t}\n\n\tkdc_log(context, config, 4, \"constrained delegation for %s \"\n\t\t\"from %s (%s) to %s\", tpn, cpn, dpn, spn);\n    }\n\n    \/*\n     * Check flags\n     *\/\n\n    ret = kdc_check_flags(priv, FALSE);\n    if(ret)\n\tgoto out;\n\n    if((b->kdc_options.validate || b->kdc_options.renew) &&\n       !krb5_principal_compare(context,\n\t\t\t       krbtgt->entry.principal,\n\t\t\t       server->entry.principal)){\n        _kdc_audit_addreason((kdc_request_t)priv, \"Inconsistent request\");\n\tkdc_log(context, config, 4, \"Inconsistent request.\");\n\tret = KRB5KDC_ERR_SERVER_NOMATCH;\n\tgoto out;\n    }\n\n    \/* check for valid set of addresses *\/\n    if (!_kdc_check_addresses(priv, tgt->caddr, from_addr)) {\n        if (config->check_ticket_addresses) {\n            ret = KRB5KRB_AP_ERR_BADADDR;\n            _kdc_audit_addkv((kdc_request_t)priv, 0, \"wrongaddr\", \"yes\");\n            kdc_log(context, config, 4, \"Request from wrong address\");\n            _kdc_audit_addreason((kdc_request_t)priv, \"Request from wrong address\");\n            goto out;\n        } else if (config->warn_ticket_addresses) {\n            _kdc_audit_addkv((kdc_request_t)priv, 0, \"wrongaddr\", \"yes\");\n        }\n    }\n\n    \/* check local and per-principal anonymous ticket issuance policy *\/\n    if (is_anon_tgs_request_p(b, tgt)) {\n\tret = _kdc_check_anon_policy(priv);\n\tif (ret)\n\t    goto out;\n    }\n\n    \/*\n     * If this is an referral, add server referral data to the\n     * auth_data reply .\n     *\/\n    if (ref_realm) {\n\tPA_DATA pa;\n\tkrb5_crypto crypto;\n\n\tkdc_log(context, config, 3,\n\t\t\"Adding server referral to %s\", ref_realm);\n\n\tret = krb5_crypto_init(context, &sessionkey, 0, &crypto);\n\tif (ret)\n\t    goto out;\n\n\tret = build_server_referral(context, config, crypto, ref_realm,\n\t\t\t\t    NULL, s, &pa.padata_value);\n\tkrb5_crypto_destroy(context, crypto);\n\tif (ret) {\n            _kdc_audit_addreason((kdc_request_t)priv, \"Referral build failed\");\n\t    kdc_log(context, config, 4,\n\t\t    \"Failed building server referral\");\n\t    goto out;\n\t}\n\tpa.padata_type = KRB5_PADATA_SERVER_REFERRAL;\n\n\tret = add_METHOD_DATA(&enc_pa_data, &pa);\n\tkrb5_data_free(&pa.padata_value);\n\tif (ret) {\n\t    kdc_log(context, config, 4,\n\t\t    \"Add server referral METHOD-DATA failed\");\n\t    goto out;\n\t}\n    }\n\n    \/*\n     *\n     *\/\n\n    ret = tgs_make_reply(priv,\n\t\t\t tp,\n\t\t\t tgt,\n\t\t\t replykey,\n\t\t\t rk_is_subkey,\n\t\t\t ekey,\n\t\t\t &sessionkey,\n\t\t\t kvno,\n\t\t\t *auth_data,\n\t\t\t server,\n\t\t\t rsp,\n\t\t\t client,\n\t\t\t cp,\n                         tgt_realm,\n\t\t\t krbtgt_out,\n\t\t\t tkey_sign->key.keytype,\n\t\t\t spp,\n\t\t\t &rspac,\n\t\t\t &enc_pa_data);\n\nout:\n    if (tpn != cpn)\n\t    free(tpn);\n    free(dpn);\n    free(krbtgt_out_n);\n    _krb5_free_capath(context, capath);\n\n    krb5_data_free(&rspac);\n    krb5_free_keyblock_contents(context, &sessionkey);\n    if(krbtgt_out)\n\t_kdc_free_ent(context, krbtgt_out);\n    if(server)\n\t_kdc_free_ent(context, server);\n    if(client)\n\t_kdc_free_ent(context, client);\n    if(s4u2self_impersonated_client)\n\t_kdc_free_ent(context, s4u2self_impersonated_client);\n\n    if (tp && tp != cp)\n\tkrb5_free_principal(context, tp);\n    krb5_free_principal(context, cp);\n    krb5_free_principal(context, dp);\n    krb5_free_principal(context, sp);\n    krb5_free_principal(context, krbtgt_out_principal);\n    free(ref_realm);\n    free_METHOD_DATA(&enc_pa_data);\n\n    free_EncTicketPart(&adtkt);\n\n    return ret;\n}","target":1,"code_token_length":9129,"total_token_length":9365,"max_tokens_setting":11000}
+{"idx":292609,"func":"size_t puma_parser_execute(puma_parser *parser, const char *buffer, size_t len, size_t off)  {\n  const char *p, *pe;\n  int cs = parser->cs;\n\n  assert(off <= len && \"offset past end of buffer\");\n\n  p = buffer+off;\n  pe = buffer+len;\n\n  \/* assert(*pe == '\\0' && \"pointer does not end on NUL\"); *\/\n  assert((size_t) (pe - p) == len - off && \"pointers aren't same distance\");\n\n  \n#line 87 \"ext\/puma_http11\/http11_parser.c\"\n\t{\n\tif ( p == pe )\n\t\tgoto _test_eof;\n\tswitch ( cs )\n\t{\ncase 1:\n\tswitch( (*p) ) {\n\t\tcase 36: goto tr0;\n\t\tcase 95: goto tr0;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto tr0;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto tr0;\n\t} else\n\t\tgoto tr0;\n\tgoto st0;\nst0:\ncs = 0;\n\tgoto _out;\ntr0:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st2;\nst2:\n\tif ( ++p == pe )\n\t\tgoto _test_eof2;\ncase 2:\n#line 118 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st27;\n\t\tcase 95: goto st27;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st27;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st27;\n\t} else\n\t\tgoto st27;\n\tgoto st0;\ntr2:\n#line 50 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_method(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st3;\nst3:\n\tif ( ++p == pe )\n\t\tgoto _test_eof3;\ncase 3:\n#line 143 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 42: goto tr4;\n\t\tcase 43: goto tr5;\n\t\tcase 47: goto tr6;\n\t\tcase 58: goto tr7;\n\t}\n\tif ( (*p) < 65 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 57 )\n\t\t\tgoto tr5;\n\t} else if ( (*p) > 90 ) {\n\t\tif ( 97 <= (*p) && (*p) <= 122 )\n\t\t\tgoto tr5;\n\t} else\n\t\tgoto tr5;\n\tgoto st0;\ntr4:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st4;\nst4:\n\tif ( ++p == pe )\n\t\tgoto _test_eof4;\ncase 4:\n#line 167 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr8;\n\t\tcase 35: goto tr9;\n\t}\n\tgoto st0;\ntr8:\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr31:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n#line 56 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->fragment(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr33:\n#line 56 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->fragment(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr37:\n#line 69 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_path(parser, PTR_TO(mark), LEN(mark,p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr41:\n#line 60 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(query_start, p); }\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr44:\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\nst5:\n\tif ( ++p == pe )\n\t\tgoto _test_eof5;\ncase 5:\n#line 229 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 72 )\n\t\tgoto tr10;\n\tgoto st0;\ntr10:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st6;\nst6:\n\tif ( ++p == pe )\n\t\tgoto _test_eof6;\ncase 6:\n#line 241 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 84 )\n\t\tgoto st7;\n\tgoto st0;\nst7:\n\tif ( ++p == pe )\n\t\tgoto _test_eof7;\ncase 7:\n\tif ( (*p) == 84 )\n\t\tgoto st8;\n\tgoto st0;\nst8:\n\tif ( ++p == pe )\n\t\tgoto _test_eof8;\ncase 8:\n\tif ( (*p) == 80 )\n\t\tgoto st9;\n\tgoto st0;\nst9:\n\tif ( ++p == pe )\n\t\tgoto _test_eof9;\ncase 9:\n\tif ( (*p) == 47 )\n\t\tgoto st10;\n\tgoto st0;\nst10:\n\tif ( ++p == pe )\n\t\tgoto _test_eof10;\ncase 10:\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st11;\n\tgoto st0;\nst11:\n\tif ( ++p == pe )\n\t\tgoto _test_eof11;\ncase 11:\n\tif ( (*p) == 46 )\n\t\tgoto st12;\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st11;\n\tgoto st0;\nst12:\n\tif ( ++p == pe )\n\t\tgoto _test_eof12;\ncase 12:\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st13;\n\tgoto st0;\nst13:\n\tif ( ++p == pe )\n\t\tgoto _test_eof13;\ncase 13:\n\tif ( (*p) == 13 )\n\t\tgoto tr18;\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st13;\n\tgoto st0;\ntr18:\n#line 65 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->http_version(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st14;\ntr26:\n#line 46 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n#line 47 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st14;\ntr29:\n#line 47 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st14;\nst14:\n\tif ( ++p == pe )\n\t\tgoto _test_eof14;\ncase 14:\n#line 322 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 10 )\n\t\tgoto st15;\n\tgoto st0;\nst15:\n\tif ( ++p == pe )\n\t\tgoto _test_eof15;\ncase 15:\n\tswitch( (*p) ) {\n\t\tcase 13: goto st16;\n\t\tcase 33: goto tr21;\n\t\tcase 124: goto tr21;\n\t\tcase 126: goto tr21;\n\t}\n\tif ( (*p) < 45 ) {\n\t\tif ( (*p) > 39 ) {\n\t\t\tif ( 42 <= (*p) && (*p) <= 43 )\n\t\t\t\tgoto tr21;\n\t\t} else if ( (*p) >= 35 )\n\t\t\tgoto tr21;\n\t} else if ( (*p) > 46 ) {\n\t\tif ( (*p) < 65 ) {\n\t\t\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\t\t\tgoto tr21;\n\t\t} else if ( (*p) > 90 ) {\n\t\t\tif ( 94 <= (*p) && (*p) <= 122 )\n\t\t\t\tgoto tr21;\n\t\t} else\n\t\t\tgoto tr21;\n\t} else\n\t\tgoto tr21;\n\tgoto st0;\nst16:\n\tif ( ++p == pe )\n\t\tgoto _test_eof16;\ncase 16:\n\tif ( (*p) == 10 )\n\t\tgoto tr22;\n\tgoto st0;\ntr22:\n#line 73 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->body_start = p - buffer + 1;\n    parser->header_done(parser, p + 1, pe - p - 1);\n    {p++; cs = 46; goto _out;}\n  }\n\tgoto st46;\nst46:\n\tif ( ++p == pe )\n\t\tgoto _test_eof46;\ncase 46:\n#line 373 \"ext\/puma_http11\/http11_parser.c\"\n\tgoto st0;\ntr21:\n#line 40 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(field_start, p); }\n#line 41 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ snake_upcase_char((char *)p); }\n\tgoto st17;\ntr23:\n#line 41 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ snake_upcase_char((char *)p); }\n\tgoto st17;\nst17:\n\tif ( ++p == pe )\n\t\tgoto _test_eof17;\ncase 17:\n#line 389 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 33: goto tr23;\n\t\tcase 58: goto tr24;\n\t\tcase 124: goto tr23;\n\t\tcase 126: goto tr23;\n\t}\n\tif ( (*p) < 45 ) {\n\t\tif ( (*p) > 39 ) {\n\t\t\tif ( 42 <= (*p) && (*p) <= 43 )\n\t\t\t\tgoto tr23;\n\t\t} else if ( (*p) >= 35 )\n\t\t\tgoto tr23;\n\t} else if ( (*p) > 46 ) {\n\t\tif ( (*p) < 65 ) {\n\t\t\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\t\t\tgoto tr23;\n\t\t} else if ( (*p) > 90 ) {\n\t\t\tif ( 94 <= (*p) && (*p) <= 122 )\n\t\t\t\tgoto tr23;\n\t\t} else\n\t\t\tgoto tr23;\n\t} else\n\t\tgoto tr23;\n\tgoto st0;\ntr24:\n#line 42 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->field_len = LEN(field_start, p);\n  }\n\tgoto st18;\ntr27:\n#line 46 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st18;\nst18:\n\tif ( ++p == pe )\n\t\tgoto _test_eof18;\ncase 18:\n#line 428 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 9: goto tr25;\n\t\tcase 13: goto tr26;\n\t\tcase 32: goto tr27;\n\t}\n\tif ( 33 <= (*p) && (*p) <= 126 )\n\t\tgoto tr25;\n\tgoto st0;\ntr25:\n#line 46 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st19;\nst19:\n\tif ( ++p == pe )\n\t\tgoto _test_eof19;\ncase 19:\n#line 445 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 9: goto st19;\n\t\tcase 13: goto tr29;\n\t}\n\tif ( 32 <= (*p) && (*p) <= 126 )\n\t\tgoto st19;\n\tgoto st0;\ntr9:\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\ntr38:\n#line 69 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_path(parser, PTR_TO(mark), LEN(mark,p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\ntr42:\n#line 60 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(query_start, p); }\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\ntr45:\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\nst20:\n\tif ( ++p == pe )\n\t\tgoto _test_eof20;\ncase 20:\n#line 495 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr31;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( (*p) > 31 ) {\n\t\tif ( 34 <= (*p) && (*p) <= 35 )\n\t\t\tgoto st0;\n\t} else if ( (*p) >= 0 )\n\t\tgoto st0;\n\tgoto tr30;\ntr30:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st21;\nst21:\n\tif ( ++p == pe )\n\t\tgoto _test_eof21;\ncase 21:\n#line 516 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr33;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( (*p) > 31 ) {\n\t\tif ( 34 <= (*p) && (*p) <= 35 )\n\t\t\tgoto st0;\n\t} else if ( (*p) >= 0 )\n\t\tgoto st0;\n\tgoto st21;\ntr5:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st22;\nst22:\n\tif ( ++p == pe )\n\t\tgoto _test_eof22;\ncase 22:\n#line 537 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 43: goto st22;\n\t\tcase 58: goto st23;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st22;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( (*p) > 90 ) {\n\t\t\tif ( 97 <= (*p) && (*p) <= 122 )\n\t\t\t\tgoto st22;\n\t\t} else if ( (*p) >= 65 )\n\t\t\tgoto st22;\n\t} else\n\t\tgoto st22;\n\tgoto st0;\ntr7:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st23;\nst23:\n\tif ( ++p == pe )\n\t\tgoto _test_eof23;\ncase 23:\n#line 562 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr8;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr9;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto st23;\ntr6:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st24;\nst24:\n\tif ( ++p == pe )\n\t\tgoto _test_eof24;\ncase 24:\n#line 582 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr37;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr38;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 63: goto tr39;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto st24;\ntr39:\n#line 69 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_path(parser, PTR_TO(mark), LEN(mark,p));\n  }\n\tgoto st25;\nst25:\n\tif ( ++p == pe )\n\t\tgoto _test_eof25;\ncase 25:\n#line 605 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr41;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr42;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto tr40;\ntr40:\n#line 60 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(query_start, p); }\n\tgoto st26;\nst26:\n\tif ( ++p == pe )\n\t\tgoto _test_eof26;\ncase 26:\n#line 625 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr44;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr45;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto st26;\nst27:\n\tif ( ++p == pe )\n\t\tgoto _test_eof27;\ncase 27:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st28;\n\t\tcase 95: goto st28;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st28;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st28;\n\t} else\n\t\tgoto st28;\n\tgoto st0;\nst28:\n\tif ( ++p == pe )\n\t\tgoto _test_eof28;\ncase 28:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st29;\n\t\tcase 95: goto st29;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st29;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st29;\n\t} else\n\t\tgoto st29;\n\tgoto st0;\nst29:\n\tif ( ++p == pe )\n\t\tgoto _test_eof29;\ncase 29:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st30;\n\t\tcase 95: goto st30;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st30;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st30;\n\t} else\n\t\tgoto st30;\n\tgoto st0;\nst30:\n\tif ( ++p == pe )\n\t\tgoto _test_eof30;\ncase 30:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st31;\n\t\tcase 95: goto st31;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st31;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st31;\n\t} else\n\t\tgoto st31;\n\tgoto st0;\nst31:\n\tif ( ++p == pe )\n\t\tgoto _test_eof31;\ncase 31:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st32;\n\t\tcase 95: goto st32;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st32;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st32;\n\t} else\n\t\tgoto st32;\n\tgoto st0;\nst32:\n\tif ( ++p == pe )\n\t\tgoto _test_eof32;\ncase 32:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st33;\n\t\tcase 95: goto st33;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st33;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st33;\n\t} else\n\t\tgoto st33;\n\tgoto st0;\nst33:\n\tif ( ++p == pe )\n\t\tgoto _test_eof33;\ncase 33:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st34;\n\t\tcase 95: goto st34;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st34;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st34;\n\t} else\n\t\tgoto st34;\n\tgoto st0;\nst34:\n\tif ( ++p == pe )\n\t\tgoto _test_eof34;\ncase 34:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st35;\n\t\tcase 95: goto st35;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st35;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st35;\n\t} else\n\t\tgoto st35;\n\tgoto st0;\nst35:\n\tif ( ++p == pe )\n\t\tgoto _test_eof35;\ncase 35:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st36;\n\t\tcase 95: goto st36;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st36;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st36;\n\t} else\n\t\tgoto st36;\n\tgoto st0;\nst36:\n\tif ( ++p == pe )\n\t\tgoto _test_eof36;\ncase 36:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st37;\n\t\tcase 95: goto st37;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st37;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st37;\n\t} else\n\t\tgoto st37;\n\tgoto st0;\nst37:\n\tif ( ++p == pe )\n\t\tgoto _test_eof37;\ncase 37:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st38;\n\t\tcase 95: goto st38;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st38;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st38;\n\t} else\n\t\tgoto st38;\n\tgoto st0;\nst38:\n\tif ( ++p == pe )\n\t\tgoto _test_eof38;\ncase 38:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st39;\n\t\tcase 95: goto st39;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st39;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st39;\n\t} else\n\t\tgoto st39;\n\tgoto st0;\nst39:\n\tif ( ++p == pe )\n\t\tgoto _test_eof39;\ncase 39:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st40;\n\t\tcase 95: goto st40;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st40;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st40;\n\t} else\n\t\tgoto st40;\n\tgoto st0;\nst40:\n\tif ( ++p == pe )\n\t\tgoto _test_eof40;\ncase 40:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st41;\n\t\tcase 95: goto st41;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st41;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st41;\n\t} else\n\t\tgoto st41;\n\tgoto st0;\nst41:\n\tif ( ++p == pe )\n\t\tgoto _test_eof41;\ncase 41:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st42;\n\t\tcase 95: goto st42;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st42;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st42;\n\t} else\n\t\tgoto st42;\n\tgoto st0;\nst42:\n\tif ( ++p == pe )\n\t\tgoto _test_eof42;\ncase 42:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st43;\n\t\tcase 95: goto st43;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st43;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st43;\n\t} else\n\t\tgoto st43;\n\tgoto st0;\nst43:\n\tif ( ++p == pe )\n\t\tgoto _test_eof43;\ncase 43:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st44;\n\t\tcase 95: goto st44;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st44;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st44;\n\t} else\n\t\tgoto st44;\n\tgoto st0;\nst44:\n\tif ( ++p == pe )\n\t\tgoto _test_eof44;\ncase 44:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st45;\n\t\tcase 95: goto st45;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st45;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st45;\n\t} else\n\t\tgoto st45;\n\tgoto st0;\nst45:\n\tif ( ++p == pe )\n\t\tgoto _test_eof45;\ncase 45:\n\tif ( (*p) == 32 )\n\t\tgoto tr2;\n\tgoto st0;\n\t}\n\t_test_eof2: cs = 2; goto _test_eof; \n\t_test_eof3: cs = 3; goto _test_eof; \n\t_test_eof4: cs = 4; goto _test_eof; \n\t_test_eof5: cs = 5; goto _test_eof; \n\t_test_eof6: cs = 6; goto _test_eof; \n\t_test_eof7: cs = 7; goto _test_eof; \n\t_test_eof8: cs = 8; goto _test_eof; \n\t_test_eof9: cs = 9; goto _test_eof; \n\t_test_eof10: cs = 10; goto _test_eof; \n\t_test_eof11: cs = 11; goto _test_eof; \n\t_test_eof12: cs = 12; goto _test_eof; \n\t_test_eof13: cs = 13; goto _test_eof; \n\t_test_eof14: cs = 14; goto _test_eof; \n\t_test_eof15: cs = 15; goto _test_eof; \n\t_test_eof16: cs = 16; goto _test_eof; \n\t_test_eof46: cs = 46; goto _test_eof; \n\t_test_eof17: cs = 17; goto _test_eof; \n\t_test_eof18: cs = 18; goto _test_eof; \n\t_test_eof19: cs = 19; goto _test_eof; \n\t_test_eof20: cs = 20; goto _test_eof; \n\t_test_eof21: cs = 21; goto _test_eof; \n\t_test_eof22: cs = 22; goto _test_eof; \n\t_test_eof23: cs = 23; goto _test_eof; \n\t_test_eof24: cs = 24; goto _test_eof; \n\t_test_eof25: cs = 25; goto _test_eof; \n\t_test_eof26: cs = 26; goto _test_eof; \n\t_test_eof27: cs = 27; goto _test_eof; \n\t_test_eof28: cs = 28; goto _test_eof; \n\t_test_eof29: cs = 29; goto _test_eof; \n\t_test_eof30: cs = 30; goto _test_eof; \n\t_test_eof31: cs = 31; goto _test_eof; \n\t_test_eof32: cs = 32; goto _test_eof; \n\t_test_eof33: cs = 33; goto _test_eof; \n\t_test_eof34: cs = 34; goto _test_eof; \n\t_test_eof35: cs = 35; goto _test_eof; \n\t_test_eof36: cs = 36; goto _test_eof; \n\t_test_eof37: cs = 37; goto _test_eof; \n\t_test_eof38: cs = 38; goto _test_eof; \n\t_test_eof39: cs = 39; goto _test_eof; \n\t_test_eof40: cs = 40; goto _test_eof; \n\t_test_eof41: cs = 41; goto _test_eof; \n\t_test_eof42: cs = 42; goto _test_eof; \n\t_test_eof43: cs = 43; goto _test_eof; \n\t_test_eof44: cs = 44; goto _test_eof; \n\t_test_eof45: cs = 45; goto _test_eof; \n\n\t_test_eof: {}\n\t_out: {}\n\t}\n\n#line 117 \"ext\/puma_http11\/http11_parser.rl\"\n\n  if (!puma_parser_has_error(parser))\n    parser->cs = cs;\n  parser->nread += p - (buffer + off);\n\n  assert(p <= pe && \"buffer overflow after parsing execute\");\n  assert(parser->nread <= len && \"nread longer than length\");\n  assert(parser->body_start <= len && \"body starts after buffer end\");\n  assert(parser->mark < len && \"mark is after buffer end\");\n  assert(parser->field_len <= len && \"field has length longer than whole buffer\");\n  assert(parser->field_start < len && \"field starts after buffer end\");\n\n  return(parser->nread);\n}","target":0,"code_token_length":8508,"total_token_length":8744,"max_tokens_setting":11000}
+{"idx":234168,"func":"read_and_display_attr_value (unsigned long           attribute,\n\t\t\t     unsigned long           form,\n\t\t\t     dwarf_signed_vma        implicit_const,\n\t\t\t     unsigned char *         start,\n\t\t\t     unsigned char *         data,\n\t\t\t     unsigned char *         end,\n\t\t\t     dwarf_vma               cu_offset,\n\t\t\t     dwarf_vma               pointer_size,\n\t\t\t     dwarf_vma               offset_size,\n\t\t\t     int                     dwarf_version,\n\t\t\t     debug_info *            debug_info_p,\n\t\t\t     int                     do_loc,\n\t\t\t     struct dwarf_section *  section,\n\t\t\t     struct cu_tu_set *      this_set,\n\t\t\t     char                    delimiter,\n\t\t\t     int                     level)\n{\n  dwarf_signed_vma svalue;\n  dwarf_vma uvalue = 0;\n  dwarf_vma uvalue_hi = 0;\n  unsigned char *block_start = NULL;\n  unsigned char *orig_data = data;\n\n  if (data > end || (data == end && form != DW_FORM_flag_present))\n    {\n      warn (_(\"Corrupt attribute\\n\"));\n      return data;\n    }\n\n  if (do_wide && ! do_loc)\n    {\n      \/* PR 26847: Display the name of the form.  *\/\n      const char * name = get_FORM_name (form);\n\n      \/* For convenience we skip the DW_FORM_ prefix to the name.  *\/\n      if (name[0] == 'D')\n\tname += 8; \/* strlen (\"DW_FORM_\")  *\/\n      printf (\"%c(%s)\", delimiter, name);\n    }\n\n  switch (form)\n    {\n    case DW_FORM_ref_addr:\n      if (dwarf_version == 2)\n\tSAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);\n      else if (dwarf_version > 2)\n\tSAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);\n      else\n\terror (_(\"Internal error: DW_FORM_ref_addr is not supported in DWARF version 1.\\n\"));\n      break;\n\n    case DW_FORM_addr:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);\n      break;\n\n    case DW_FORM_strp_sup:\n    case DW_FORM_strp:\n    case DW_FORM_line_strp:\n    case DW_FORM_sec_offset:\n    case DW_FORM_GNU_ref_alt:\n    case DW_FORM_GNU_strp_alt:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);\n      break;\n\n    case DW_FORM_flag_present:\n      uvalue = 1;\n      break;\n\n    case DW_FORM_ref1:\n    case DW_FORM_flag:\n    case DW_FORM_data1:\n    case DW_FORM_strx1:\n    case DW_FORM_addrx1:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);\n      break;\n\n    case DW_FORM_ref2:\n    case DW_FORM_data2:\n    case DW_FORM_strx2:\n    case DW_FORM_addrx2:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end);\n      break;\n\n    case DW_FORM_strx3:\n    case DW_FORM_addrx3:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 3, end);\n      break;\n\n    case DW_FORM_ref_sup4:\n    case DW_FORM_ref4:\n    case DW_FORM_data4:\n    case DW_FORM_strx4:\n    case DW_FORM_addrx4:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);\n      break;\n\n    case DW_FORM_ref_sup8:\n    case DW_FORM_ref8:\n    case DW_FORM_data8:\n    case DW_FORM_ref_sig8:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 8, end);\n      break;\n\n    case DW_FORM_data16:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 8, end);\n      SAFE_BYTE_GET_AND_INC (uvalue_hi, data, 8, end);\n      if (byte_get != byte_get_little_endian)\n\t{\n\t  dwarf_vma utmp = uvalue;\n\t  uvalue = uvalue_hi;\n\t  uvalue_hi = utmp;\n\t}\n      break;\n\n    case DW_FORM_sdata:\n      READ_SLEB (svalue, data, end);\n      uvalue = svalue;\n      break;\n\n    case DW_FORM_GNU_str_index:\n    case DW_FORM_strx:\n    case DW_FORM_ref_udata:\n    case DW_FORM_udata:\n    case DW_FORM_GNU_addr_index:\n    case DW_FORM_addrx:\n    case DW_FORM_loclistx:\n    case DW_FORM_rnglistx:\n      READ_ULEB (uvalue, data, end);\n      break;\n\n    case DW_FORM_indirect:\n      READ_ULEB (form, data, end);\n      if (!do_loc)\n\tprintf (\"%c%s\", delimiter, get_FORM_name (form));\n      if (form == DW_FORM_implicit_const)\n\tREAD_SLEB (implicit_const, data, end);\n      return read_and_display_attr_value (attribute, form, implicit_const,\n\t\t\t\t\t  start, data, end,\n\t\t\t\t\t  cu_offset, pointer_size,\n\t\t\t\t\t  offset_size, dwarf_version,\n\t\t\t\t\t  debug_info_p, do_loc,\n\t\t\t\t\t  section, this_set, delimiter, level);\n\n    case DW_FORM_implicit_const:\n      uvalue = implicit_const;\n      break;\n\n    default:\n      break;\n    }\n\n  switch (form)\n    {\n    case DW_FORM_ref_addr:\n      if (!do_loc)\n\tprintf (\"%c<0x%s>\", delimiter, dwarf_vmatoa (\"x\", uvalue));\n      break;\n\n    case DW_FORM_GNU_ref_alt:\n      if (!do_loc)\n\t{\n\t  if (do_wide)\n\t    \/* We have already printed the form name.  *\/\n\t    printf (\"%c<0x%s>\", delimiter, dwarf_vmatoa (\"x\", uvalue));\n\t  else\n\t    printf (\"%c<alt 0x%s>\", delimiter, dwarf_vmatoa (\"x\", uvalue));\n\t}\n      \/* FIXME: Follow the reference...  *\/\n      break;\n\n    case DW_FORM_ref1:\n    case DW_FORM_ref2:\n    case DW_FORM_ref4:\n    case DW_FORM_ref_sup4:\n    case DW_FORM_ref_udata:\n      if (!do_loc)\n\tprintf (\"%c<0x%s>\", delimiter, dwarf_vmatoa (\"x\", uvalue + cu_offset));\n      break;\n\n    case DW_FORM_data4:\n    case DW_FORM_addr:\n    case DW_FORM_sec_offset:\n      if (!do_loc)\n\tprintf (\"%c0x%s\", delimiter, dwarf_vmatoa (\"x\", uvalue));\n      break;\n\n    case DW_FORM_flag_present:\n    case DW_FORM_flag:\n    case DW_FORM_data1:\n    case DW_FORM_data2:\n    case DW_FORM_sdata:\n      if (!do_loc)\n\tprintf (\"%c%s\", delimiter, dwarf_vmatoa (\"d\", uvalue));\n      break;\n\n    case DW_FORM_udata:\n      if (!do_loc)\n\tprintf (\"%c%s\", delimiter, dwarf_vmatoa (\"u\", uvalue));\n      break;\n\n    case DW_FORM_implicit_const:\n      if (!do_loc)\n\tprintf (\"%c%s\", delimiter, dwarf_vmatoa (\"d\", implicit_const));\n      break;\n\n    case DW_FORM_ref_sup8:\n    case DW_FORM_ref8:\n    case DW_FORM_data8:\n      if (!do_loc)\n\t{\n\t  dwarf_vma utmp = uvalue;\n\t  if (form == DW_FORM_ref8)\n\t    utmp += cu_offset;\n\t  printf (\"%c0x%s\", delimiter, dwarf_vmatoa (\"x\", utmp));\n\t}\n      break;\n\n    case DW_FORM_data16:\n      if (!do_loc)\n\tprintf (\" 0x%s%s\",\n\t\tuvalue_hi == 0 ? \"\" : dwarf_vmatoa (\"x\", uvalue_hi),\n\t\tdwarf_vmatoa_1 (\"x\", uvalue, uvalue_hi == 0 ? 0 : 8));\n      break;\n\n    case DW_FORM_string:\n      if (!do_loc)\n\tprintf (\"%c%.*s\", delimiter, (int) (end - data), data);\n      data += strnlen ((char *) data, end - data);\n      if (data < end)\n\tdata++;\n      break;\n\n    case DW_FORM_block:\n    case DW_FORM_exprloc:\n      READ_ULEB (uvalue, data, end);\n    do_block:\n      block_start = data;\n      if (block_start >= end)\n\t{\n\t  warn (_(\"Block ends prematurely\\n\"));\n\t  uvalue = 0;\n\t  block_start = end;\n\t}\n\n      uvalue = check_uvalue (block_start, uvalue, end);\n\n      data = block_start + uvalue;\n      if (!do_loc)\n\t{\n\t  unsigned char op;\n\n\t  SAFE_BYTE_GET (op, block_start, sizeof (op), end);\n\t  if (op != DW_OP_addrx)\n\t    data = display_block (block_start, uvalue, end, delimiter);\n\t}\n      break;\n\n    case DW_FORM_block1:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);\n      goto do_block;\n\n    case DW_FORM_block2:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end);\n      goto do_block;\n\n    case DW_FORM_block4:\n      SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);\n      goto do_block;\n\n    case DW_FORM_strp:\n      if (!do_loc)\n\t{\n\t  if (do_wide)\n\t    \/* We have already displayed the form name.  *\/\n\t    printf (_(\"%c(offset: 0x%s): %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    fetch_indirect_string (uvalue));\n\t  else\n\t    printf (_(\"%c(indirect string, offset: 0x%s): %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    fetch_indirect_string (uvalue));\n\t}\n      break;\n\n    case DW_FORM_line_strp:\n      if (!do_loc)\n\t{\n\t  if (do_wide)\n\t    \/* We have already displayed the form name.  *\/\n\t    printf (_(\"%c(offset: 0x%s): %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    fetch_indirect_line_string (uvalue));\n\t  else\n\t    printf (_(\"%c(indirect line string, offset: 0x%s): %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    fetch_indirect_line_string (uvalue));\n\t}\n      break;\n\n    case DW_FORM_GNU_str_index:\n    case DW_FORM_strx:\n    case DW_FORM_strx1:\n    case DW_FORM_strx2:\n    case DW_FORM_strx3:\n    case DW_FORM_strx4:\n      if (!do_loc)\n\t{\n\t  const char *suffix = section ? strrchr (section->name, '.') : NULL;\n\t  bool dwo = suffix && strcmp (suffix, \".dwo\") == 0;\n\t  const char *strng;\n\n\t  strng = fetch_indexed_string (uvalue, this_set, offset_size, dwo,\n\t\t\t\t\tdebug_info_p ? debug_info_p->str_offsets_base : 0);\n\t  if (do_wide)\n\t    \/* We have already displayed the form name.  *\/\n\t    printf (_(\"%c(offset: 0x%s): %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue), strng);\n\t  else\n\t    printf (_(\"%c(indexed string: 0x%s): %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue), strng);\n\t}\n      break;\n\n    case DW_FORM_GNU_strp_alt:\n      if (!do_loc)\n\t{\n\t  if (do_wide)\n\t    \/* We have already displayed the form name.  *\/\n\t    printf (_(\"%c(offset: 0x%s) %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    fetch_alt_indirect_string (uvalue));\n\t  else\n\t    printf (_(\"%c(alt indirect string, offset: 0x%s) %s\"), delimiter,\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    fetch_alt_indirect_string (uvalue));\n\t}\n      break;\n\n    case DW_FORM_indirect:\n      \/* Handled above.  *\/\n      break;\n\n    case DW_FORM_ref_sig8:\n      if (!do_loc)\n\tprintf (\"%c%s: 0x%s\", delimiter, do_wide ? \"\" : \"signature\",\n\t\tdwarf_vmatoa (\"x\", uvalue));\n      break;\n\n    case DW_FORM_GNU_addr_index:\n    case DW_FORM_addrx:\n    case DW_FORM_addrx1:\n    case DW_FORM_addrx2:\n    case DW_FORM_addrx3:\n    case DW_FORM_addrx4:\n    case DW_FORM_loclistx:\n    case DW_FORM_rnglistx:\n      if (!do_loc)\n\t{\n\t  dwarf_vma base;\n\t  dwarf_vma offset;\n\n\t  if (debug_info_p == NULL)\n\t    base = 0;\n\t  else if (debug_info_p->addr_base == DEBUG_INFO_UNAVAILABLE)\n\t    base = 0;\n\t  else\n\t    base = debug_info_p->addr_base;\n\n\t  offset = base + uvalue * pointer_size;\n\n\t  if (do_wide)\n\t    \/* We have already displayed the form name.  *\/\n\t    if (form == DW_FORM_loclistx)\n\t      printf (_(\"%c(index: 0x%s): %s\"), delimiter,\n\t              dwarf_vmatoa (\"x\", uvalue),\n\t              dwarf_vmatoa (\"x\", debug_info_p->loc_offsets [uvalue]));\n\t    else\n\t      printf (_(\"%c(index: 0x%s): %s\"), delimiter,\n\t              dwarf_vmatoa (\"x\", uvalue),\n\t              dwarf_vmatoa (\"x\", fetch_indexed_addr (offset, pointer_size)));\n\t  else\n\t    if (form == DW_FORM_loclistx)\n\t      printf (_(\"%c(addr_index: 0x%s): %s\"), delimiter,\n\t              dwarf_vmatoa (\"x\", uvalue),\n\t              dwarf_vmatoa (\"x\", debug_info_p->loc_offsets [uvalue]));\n\t    else\n\t      printf (_(\"%c(addr_index: 0x%s): %s\"), delimiter,\n\t              dwarf_vmatoa (\"x\", uvalue),\n\t              dwarf_vmatoa (\"x\", fetch_indexed_addr (offset, pointer_size)));\n\t}\n      break;\n\n    case DW_FORM_strp_sup:\n      if (!do_loc)\n\tprintf (\"%c<0x%s>\", delimiter, dwarf_vmatoa (\"x\", uvalue + cu_offset));\n      break;\n      \n    default:\n      warn (_(\"Unrecognized form: 0x%lx\\n\"), form);\n      \/* What to do?  Consume a byte maybe?  *\/\n      ++data;\n      break;\n    }\n\n  if ((do_loc || do_debug_loc || do_debug_ranges || do_debug_info)\n      && num_debug_info_entries == 0\n      && debug_info_p != NULL)\n    {\n      switch (attribute)\n\t{\n\tcase DW_AT_loclists_base:\n\t  if (debug_info_p->loclists_base)\n\t    warn (_(\"CU @ 0x%s has multiple loclists_base values\"),\n\t\t  dwarf_vmatoa (\"x\", debug_info_p->cu_offset));\n\t  debug_info_p->loclists_base = uvalue;\n\t  break;\n\tcase DW_AT_rnglists_base:\n\t  if (debug_info_p->rnglists_base)\n\t    warn (_(\"CU @ 0x%s has multiple rnglists_base values\"),\n\t          dwarf_vmatoa (\"x\", debug_info_p->cu_offset));\n\t  debug_info_p->rnglists_base = uvalue;\n\t  break;\n\tcase DW_AT_str_offsets_base:\n\t  if (debug_info_p->str_offsets_base)\n\t    warn (_(\"CU @ 0x%s has multiple str_offsets_base values\"),\n\t\t  dwarf_vmatoa (\"x\", debug_info_p->cu_offset));\n\t  debug_info_p->str_offsets_base = uvalue;\n\t  break;\n\n\tcase DW_AT_frame_base:\n\t  have_frame_base = 1;\n\t  \/* Fall through.  *\/\n\tcase DW_AT_location:\n\tcase DW_AT_GNU_locviews:\n\tcase DW_AT_string_length:\n\tcase DW_AT_return_addr:\n\tcase DW_AT_data_member_location:\n\tcase DW_AT_vtable_elem_location:\n\tcase DW_AT_segment:\n\tcase DW_AT_static_link:\n\tcase DW_AT_use_location:\n\tcase DW_AT_call_value:\n\tcase DW_AT_GNU_call_site_value:\n\tcase DW_AT_call_data_value:\n\tcase DW_AT_GNU_call_site_data_value:\n\tcase DW_AT_call_target:\n\tcase DW_AT_GNU_call_site_target:\n\tcase DW_AT_call_target_clobbered:\n\tcase DW_AT_GNU_call_site_target_clobbered:\n\t  if ((dwarf_version < 4\n\t       && (form == DW_FORM_data4 || form == DW_FORM_data8))\n\t      || form == DW_FORM_sec_offset\n\t      || form == DW_FORM_loclistx)\n\t    {\n\t      \/* Process location list.  *\/\n\t      unsigned int lmax = debug_info_p->max_loc_offsets;\n\t      unsigned int num = debug_info_p->num_loc_offsets;\n\n\t      if (lmax == 0 || num >= lmax)\n\t\t{\n\t\t  lmax += 1024;\n\t\t  debug_info_p->loc_offsets = (dwarf_vma *)\n\t\t    xcrealloc (debug_info_p->loc_offsets,\n\t\t\t       lmax, sizeof (*debug_info_p->loc_offsets));\n\t\t  debug_info_p->loc_views = (dwarf_vma *)\n\t\t    xcrealloc (debug_info_p->loc_views,\n\t\t\t       lmax, sizeof (*debug_info_p->loc_views));\n\t\t  debug_info_p->have_frame_base = (int *)\n\t\t    xcrealloc (debug_info_p->have_frame_base,\n\t\t\t       lmax, sizeof (*debug_info_p->have_frame_base));\n\t\t  debug_info_p->max_loc_offsets = lmax;\n\t\t}\n\t      if (form == DW_FORM_loclistx)\n\t\tuvalue = fetch_indexed_value (num, loclists, debug_info_p->loclists_base);\n\t      else if (this_set != NULL)\n\t\tuvalue += this_set->section_offsets [DW_SECT_LOC];\n\n\t      debug_info_p->have_frame_base [num] = have_frame_base;\n\t      if (attribute != DW_AT_GNU_locviews)\n\t\t{\n\t\t  uvalue += debug_info_p->loclists_base;\n\n\t\t  \/* Corrupt DWARF info can produce more offsets than views.\n\t\t     See PR 23062 for an example.  *\/\n\t\t  if (debug_info_p->num_loc_offsets\n\t\t      > debug_info_p->num_loc_views)\n\t\t    warn (_(\"More location offset attributes than DW_AT_GNU_locview attributes\\n\"));\n\t\t  else\n\t\t    {\n\t\t      debug_info_p->loc_offsets [num] = uvalue;\n\t\t      debug_info_p->num_loc_offsets++;\n\t\t    }\n\t\t}\n\t      else\n\t\t{\n\t\t  assert (debug_info_p->num_loc_views <= num);\n\t\t  num = debug_info_p->num_loc_views;\n\t\t  if (num > debug_info_p->num_loc_offsets)\n\t\t    warn (_(\"More DW_AT_GNU_locview attributes than location offset attributes\\n\"));\n\t\t  else\n\t\t    {\n\t\t      debug_info_p->loc_views [num] = uvalue;\n\t\t      debug_info_p->num_loc_views++;\n\t\t    }\n\t\t}\n\t    }\n\t  break;\n\n\tcase DW_AT_low_pc:\n\t  if (need_base_address)\n\t    debug_info_p->base_address = uvalue;\n\t  break;\n\n\tcase DW_AT_GNU_addr_base:\n\tcase DW_AT_addr_base:\n\t  debug_info_p->addr_base = uvalue;\n\t  break;\n\n\tcase DW_AT_GNU_ranges_base:\n\t  debug_info_p->ranges_base = uvalue;\n\t  break;\n\n\tcase DW_AT_ranges:\n\t  if ((dwarf_version < 4\n\t       && (form == DW_FORM_data4 || form == DW_FORM_data8))\n\t      || form == DW_FORM_sec_offset\n\t      || form == DW_FORM_rnglistx)\n\t    {\n\t      \/* Process range list.  *\/\n\t      unsigned int lmax = debug_info_p->max_range_lists;\n\t      unsigned int num = debug_info_p->num_range_lists;\n\n\t      if (lmax == 0 || num >= lmax)\n\t\t{\n\t\t  lmax += 1024;\n\t\t  debug_info_p->range_lists = (dwarf_vma *)\n\t\t    xcrealloc (debug_info_p->range_lists,\n\t\t\t       lmax, sizeof (*debug_info_p->range_lists));\n\t\t  debug_info_p->max_range_lists = lmax;\n\t\t}\n\n\t      if (form == DW_FORM_rnglistx)\n\t\tuvalue = fetch_indexed_value (uvalue, rnglists, 0);\n\n\t      debug_info_p->range_lists [num] = uvalue;\n\t      debug_info_p->num_range_lists++;\n\t    }\n\t  break;\n\n\tcase DW_AT_GNU_dwo_name:\n\tcase DW_AT_dwo_name:\n\t  if (need_dwo_info)\n\t    switch (form)\n\t      {\n\t      case DW_FORM_strp:\n\t\tadd_dwo_name ((const char *) fetch_indirect_string (uvalue), cu_offset);\n\t\tbreak;\n\t      case DW_FORM_GNU_strp_alt:\n\t\tadd_dwo_name ((const char *) fetch_alt_indirect_string (uvalue), cu_offset);\n\t\tbreak;\n\t      case DW_FORM_GNU_str_index:\n\t      case DW_FORM_strx:\n\t      case DW_FORM_strx1:\n\t      case DW_FORM_strx2:\n\t      case DW_FORM_strx3:\n\t      case DW_FORM_strx4:\n\t\tadd_dwo_name (fetch_indexed_string (uvalue, this_set, offset_size, false,\n\t\t                                    debug_info_p->str_offsets_base),\n\t\t\t      cu_offset);\n\t\tbreak;\n\t      case DW_FORM_string:\n\t\tadd_dwo_name ((const char *) orig_data, cu_offset);\n\t\tbreak;\n\t      default:\n\t\twarn (_(\"Unsupported form (%s) for attribute %s\\n\"),\n\t\t      get_FORM_name (form), get_AT_name (attribute));\n\t\tbreak;\n\t      }\n\t  break;\n\n\tcase DW_AT_comp_dir:\n\t  \/* FIXME: Also extract a build-id in a CU\/TU.  *\/\n\t  if (need_dwo_info)\n\t    switch (form)\n\t      {\n\t      case DW_FORM_strp:\n\t\tadd_dwo_dir ((const char *) fetch_indirect_string (uvalue), cu_offset);\n\t\tbreak;\n\t      case DW_FORM_GNU_strp_alt:\n\t\tadd_dwo_dir (fetch_alt_indirect_string (uvalue), cu_offset);\n\t\tbreak;\n\t      case DW_FORM_line_strp:\n\t\tadd_dwo_dir ((const char *) fetch_indirect_line_string (uvalue), cu_offset);\n\t\tbreak;\n\t      case DW_FORM_GNU_str_index:\n\t      case DW_FORM_strx:\n\t      case DW_FORM_strx1:\n\t      case DW_FORM_strx2:\n\t      case DW_FORM_strx3:\n\t      case DW_FORM_strx4:\n\t\tadd_dwo_dir (fetch_indexed_string (uvalue, this_set, offset_size, false,\n\t\t                                   debug_info_p->str_offsets_base),\n\t\t\t     cu_offset);\n\t\tbreak;\n\t      case DW_FORM_string:\n\t\tadd_dwo_dir ((const char *) orig_data, cu_offset);\n\t\tbreak;\n\t      default:\n\t\twarn (_(\"Unsupported form (%s) for attribute %s\\n\"),\n\t\t      get_FORM_name (form), get_AT_name (attribute));\n\t\tbreak;\n\t      }\n\t  break;\n\n\tcase DW_AT_GNU_dwo_id:\n\t  if (need_dwo_info)\n\t    switch (form)\n\t      {\n\t      case DW_FORM_data8:\n\t\t\/* FIXME: Record the length of the ID as well ?  *\/\n\t\tadd_dwo_id ((const char *) (data - 8), cu_offset);\n\t\tbreak;\n\t      default:\n\t\twarn (_(\"Unsupported form (%s) for attribute %s\\n\"),\n\t\t      get_FORM_name (form), get_AT_name (attribute));\n\t\tbreak;\n\t      }\n\t  break;\n\n\tdefault:\n\t  break;\n\t}\n    }\n\n  if (do_loc || attribute == 0)\n    return data;\n\n  \/* For some attributes we can display further information.  *\/\n  switch (attribute)\n    {\n    case DW_AT_type:\n      if (level >= 0 && level < MAX_CU_NESTING\n\t  && uvalue < (size_t) (end - start))\n\t{\n\t  bool is_signed = false;\n\t  abbrev_entry *type_abbrev;\n\t  unsigned char *type_data;\n\t  abbrev_map *map;\n\n\t  type_abbrev = get_type_abbrev_from_form (form, uvalue,\n\t\t\t\t\t\t   cu_offset, end,\n\t\t\t\t\t\t   section, NULL,\n\t\t\t\t\t\t   &type_data, &map);\n\t  if (type_abbrev != NULL)\n\t    {\n\t      get_type_signedness (type_abbrev, section, type_data,\n\t\t\t\t   map ? section->start + map->end : end,\n\t\t\t\t   map ? map->start : cu_offset,\n\t\t\t\t   pointer_size, offset_size, dwarf_version,\n\t\t\t\t   & is_signed, 0);\n\t    }\n\t  level_type_signed[level] = is_signed;\n\t}\n      break;\n\n    case DW_AT_inline:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_INL_not_inlined:\n\t  printf (_(\"(not inlined)\"));\n\t  break;\n\tcase DW_INL_inlined:\n\t  printf (_(\"(inlined)\"));\n\t  break;\n\tcase DW_INL_declared_not_inlined:\n\t  printf (_(\"(declared as inline but ignored)\"));\n\t  break;\n\tcase DW_INL_declared_inlined:\n\t  printf (_(\"(declared as inline and inlined)\"));\n\t  break;\n\tdefault:\n\t  printf (_(\"  (Unknown inline attribute value: %s)\"),\n\t\t  dwarf_vmatoa (\"x\", uvalue));\n\t  break;\n\t}\n      break;\n\n    case DW_AT_language:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\t  \/* Ordered by the numeric value of these constants.  *\/\n\tcase DW_LANG_C89:\t\tprintf (\"(ANSI C)\"); break;\n\tcase DW_LANG_C:\t\t\tprintf (\"(non-ANSI C)\"); break;\n\tcase DW_LANG_Ada83:\t\tprintf (\"(Ada)\"); break;\n\tcase DW_LANG_C_plus_plus:\tprintf (\"(C++)\"); break;\n\tcase DW_LANG_Cobol74:\t\tprintf (\"(Cobol 74)\"); break;\n\tcase DW_LANG_Cobol85:\t\tprintf (\"(Cobol 85)\"); break;\n\tcase DW_LANG_Fortran77:\t\tprintf (\"(FORTRAN 77)\"); break;\n\tcase DW_LANG_Fortran90:\t\tprintf (\"(Fortran 90)\"); break;\n\tcase DW_LANG_Pascal83:\t\tprintf (\"(ANSI Pascal)\"); break;\n\tcase DW_LANG_Modula2:\t\tprintf (\"(Modula 2)\"); break;\n\t  \/* DWARF 2.1 values.\t*\/\n\tcase DW_LANG_Java:\t\tprintf (\"(Java)\"); break;\n\tcase DW_LANG_C99:\t\tprintf (\"(ANSI C99)\"); break;\n\tcase DW_LANG_Ada95:\t\tprintf (\"(ADA 95)\"); break;\n\tcase DW_LANG_Fortran95:\t\tprintf (\"(Fortran 95)\"); break;\n\t  \/* DWARF 3 values.  *\/\n\tcase DW_LANG_PLI:\t\tprintf (\"(PLI)\"); break;\n\tcase DW_LANG_ObjC:\t\tprintf (\"(Objective C)\"); break;\n\tcase DW_LANG_ObjC_plus_plus:\tprintf (\"(Objective C++)\"); break;\n\tcase DW_LANG_UPC:\t\tprintf (\"(Unified Parallel C)\"); break;\n\tcase DW_LANG_D:\t\t\tprintf (\"(D)\"); break;\n\t  \/* DWARF 4 values.  *\/\n\tcase DW_LANG_Python:\t\tprintf (\"(Python)\"); break;\n\t  \/* DWARF 5 values.  *\/\n\tcase DW_LANG_OpenCL:\t\tprintf (\"(OpenCL)\"); break;\n\tcase DW_LANG_Go:\t\tprintf (\"(Go)\"); break;\n\tcase DW_LANG_Modula3:\t\tprintf (\"(Modula 3)\"); break;\n\tcase DW_LANG_Haskell:\t\tprintf (\"(Haskell)\"); break;\n\tcase DW_LANG_C_plus_plus_03:\tprintf (\"(C++03)\"); break;\n\tcase DW_LANG_C_plus_plus_11:\tprintf (\"(C++11)\"); break;\n\tcase DW_LANG_OCaml:\t\tprintf (\"(OCaml)\"); break;\n\tcase DW_LANG_Rust:\t\tprintf (\"(Rust)\"); break;\n\tcase DW_LANG_C11:\t\tprintf (\"(C11)\"); break;\n\tcase DW_LANG_Swift:\t\tprintf (\"(Swift)\"); break;\n\tcase DW_LANG_Julia:\t\tprintf (\"(Julia)\"); break;\n\tcase DW_LANG_Dylan:\t\tprintf (\"(Dylan)\"); break;\n\tcase DW_LANG_C_plus_plus_14:\tprintf (\"(C++14)\"); break;\n\tcase DW_LANG_Fortran03:\t\tprintf (\"(Fortran 03)\"); break;\n\tcase DW_LANG_Fortran08:\t\tprintf (\"(Fortran 08)\"); break;\n\tcase DW_LANG_RenderScript:\tprintf (\"(RenderScript)\"); break;\n\t  \/* MIPS extension.  *\/\n\tcase DW_LANG_Mips_Assembler:\tprintf (\"(MIPS assembler)\"); break;\n\t  \/* UPC extension.  *\/\n\tcase DW_LANG_Upc:\t\tprintf (\"(Unified Parallel C)\"); break;\n\tdefault:\n\t  if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user)\n\t    printf (_(\"(implementation defined: %s)\"),\n\t\t    dwarf_vmatoa (\"x\", uvalue));\n\t  else\n\t    printf (_(\"(Unknown: %s)\"), dwarf_vmatoa (\"x\", uvalue));\n\t  break;\n\t}\n      break;\n\n    case DW_AT_encoding:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_ATE_void:\t\tprintf (\"(void)\"); break;\n\tcase DW_ATE_address:\t\tprintf (\"(machine address)\"); break;\n\tcase DW_ATE_boolean:\t\tprintf (\"(boolean)\"); break;\n\tcase DW_ATE_complex_float:\tprintf (\"(complex float)\"); break;\n\tcase DW_ATE_float:\t\tprintf (\"(float)\"); break;\n\tcase DW_ATE_signed:\t\tprintf (\"(signed)\"); break;\n\tcase DW_ATE_signed_char:\tprintf (\"(signed char)\"); break;\n\tcase DW_ATE_unsigned:\t\tprintf (\"(unsigned)\"); break;\n\tcase DW_ATE_unsigned_char:\tprintf (\"(unsigned char)\"); break;\n\t  \/* DWARF 2.1 values:  *\/\n\tcase DW_ATE_imaginary_float:\tprintf (\"(imaginary float)\"); break;\n\tcase DW_ATE_decimal_float:\tprintf (\"(decimal float)\"); break;\n\t  \/* DWARF 3 values:  *\/\n\tcase DW_ATE_packed_decimal:\tprintf (\"(packed_decimal)\"); break;\n\tcase DW_ATE_numeric_string:\tprintf (\"(numeric_string)\"); break;\n\tcase DW_ATE_edited:\t\tprintf (\"(edited)\"); break;\n\tcase DW_ATE_signed_fixed:\tprintf (\"(signed_fixed)\"); break;\n\tcase DW_ATE_unsigned_fixed:\tprintf (\"(unsigned_fixed)\"); break;\n\t  \/* DWARF 4 values:  *\/\n\tcase DW_ATE_UTF:\t\tprintf (\"(unicode string)\"); break;\n\t  \/* DWARF 5 values:  *\/\n\tcase DW_ATE_UCS:\t\tprintf (\"(UCS)\"); break;\n\tcase DW_ATE_ASCII:\t\tprintf (\"(ASCII)\"); break;\n\n\t  \/* HP extensions:  *\/\n\tcase DW_ATE_HP_float80:\t\tprintf (\"(HP_float80)\"); break;\n\tcase DW_ATE_HP_complex_float80:\tprintf (\"(HP_complex_float80)\"); break;\n\tcase DW_ATE_HP_float128:\tprintf (\"(HP_float128)\"); break;\n\tcase DW_ATE_HP_complex_float128:printf (\"(HP_complex_float128)\"); break;\n\tcase DW_ATE_HP_floathpintel:\tprintf (\"(HP_floathpintel)\"); break;\n\tcase DW_ATE_HP_imaginary_float80:\tprintf (\"(HP_imaginary_float80)\"); break;\n\tcase DW_ATE_HP_imaginary_float128:\tprintf (\"(HP_imaginary_float128)\"); break;\n\n\tdefault:\n\t  if (uvalue >= DW_ATE_lo_user\n\t      && uvalue <= DW_ATE_hi_user)\n\t    printf (_(\"(user defined type)\"));\n\t  else\n\t    printf (_(\"(unknown type)\"));\n\t  break;\n\t}\n      break;\n\n    case DW_AT_accessibility:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_ACCESS_public:\t\tprintf (\"(public)\"); break;\n\tcase DW_ACCESS_protected:\tprintf (\"(protected)\"); break;\n\tcase DW_ACCESS_private:\t\tprintf (\"(private)\"); break;\n\tdefault:\n\t  printf (_(\"(unknown accessibility)\"));\n\t  break;\n\t}\n      break;\n\n    case DW_AT_visibility:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_VIS_local:\t\tprintf (\"(local)\"); break;\n\tcase DW_VIS_exported:\t\tprintf (\"(exported)\"); break;\n\tcase DW_VIS_qualified:\t\tprintf (\"(qualified)\"); break;\n\tdefault:\t\t\tprintf (_(\"(unknown visibility)\")); break;\n\t}\n      break;\n\n    case DW_AT_endianity:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_END_default:\t\tprintf (\"(default)\"); break;\n\tcase DW_END_big:\t\tprintf (\"(big)\"); break;\n\tcase DW_END_little:\t\tprintf (\"(little)\"); break;\n\tdefault:\n\t  if (uvalue >= DW_END_lo_user && uvalue <= DW_END_hi_user)\n\t    printf (_(\"(user specified)\"));\n\t  else\n\t    printf (_(\"(unknown endianity)\"));\n\t  break;\n\t}\n      break;\n\n    case DW_AT_virtuality:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_VIRTUALITY_none:\tprintf (\"(none)\"); break;\n\tcase DW_VIRTUALITY_virtual:\tprintf (\"(virtual)\"); break;\n\tcase DW_VIRTUALITY_pure_virtual:printf (\"(pure_virtual)\"); break;\n\tdefault:\t\t\tprintf (_(\"(unknown virtuality)\")); break;\n\t}\n      break;\n\n    case DW_AT_identifier_case:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_ID_case_sensitive:\tprintf (\"(case_sensitive)\"); break;\n\tcase DW_ID_up_case:\t\tprintf (\"(up_case)\"); break;\n\tcase DW_ID_down_case:\t\tprintf (\"(down_case)\"); break;\n\tcase DW_ID_case_insensitive:\tprintf (\"(case_insensitive)\"); break;\n\tdefault:\t\t\tprintf (_(\"(unknown case)\")); break;\n\t}\n      break;\n\n    case DW_AT_calling_convention:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_CC_normal:\tprintf (\"(normal)\"); break;\n\tcase DW_CC_program:\tprintf (\"(program)\"); break;\n\tcase DW_CC_nocall:\tprintf (\"(nocall)\"); break;\n\tcase DW_CC_pass_by_reference: printf (\"(pass by ref)\"); break;\n\tcase DW_CC_pass_by_value: printf (\"(pass by value)\"); break;\n\tcase DW_CC_GNU_renesas_sh: printf (\"(Rensas SH)\"); break;\n\tcase DW_CC_GNU_borland_fastcall_i386: printf (\"(Borland fastcall i386)\"); break;\n\tdefault:\n\t  if (uvalue >= DW_CC_lo_user\n\t      && uvalue <= DW_CC_hi_user)\n\t    printf (_(\"(user defined)\"));\n\t  else\n\t    printf (_(\"(unknown convention)\"));\n\t}\n      break;\n\n    case DW_AT_ordering:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase 255:\n\tcase -1: printf (_(\"(undefined)\")); break;\n\tcase 0:  printf (\"(row major)\"); break;\n\tcase 1:  printf (\"(column major)\"); break;\n\t}\n      break;\n\n    case DW_AT_decimal_sign:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_DS_unsigned:            printf (_(\"(unsigned)\")); break;\n\tcase DW_DS_leading_overpunch:   printf (_(\"(leading overpunch)\")); break;\n\tcase DW_DS_trailing_overpunch:  printf (_(\"(trailing overpunch)\")); break;\n\tcase DW_DS_leading_separate:    printf (_(\"(leading separate)\")); break;\n\tcase DW_DS_trailing_separate:   printf (_(\"(trailing separate)\")); break;\n\tdefault:                        printf (_(\"(unrecognised)\")); break;\n\t}\n      break;\n\n    case DW_AT_defaulted:\n      printf (\"\\t\");\n      switch (uvalue)\n\t{\n\tcase DW_DEFAULTED_no:           printf (_(\"(no)\")); break;\n\tcase DW_DEFAULTED_in_class:     printf (_(\"(in class)\")); break;\n\tcase DW_DEFAULTED_out_of_class: printf (_(\"(out of class)\")); break;\n\tdefault:                        printf (_(\"(unrecognised)\")); break;\n\t}\n      break;\n\n    case DW_AT_discr_list:\n      printf (\"\\t\");\n      display_discr_list (form, uvalue, data, level);\n      break;\n\n    case DW_AT_frame_base:\n      have_frame_base = 1;\n      \/* Fall through.  *\/\n    case DW_AT_location:\n    case DW_AT_loclists_base:\n    case DW_AT_rnglists_base:\n    case DW_AT_str_offsets_base:\n    case DW_AT_string_length:\n    case DW_AT_return_addr:\n    case DW_AT_data_member_location:\n    case DW_AT_vtable_elem_location:\n    case DW_AT_segment:\n    case DW_AT_static_link:\n    case DW_AT_use_location:\n    case DW_AT_call_value:\n    case DW_AT_GNU_call_site_value:\n    case DW_AT_call_data_value:\n    case DW_AT_GNU_call_site_data_value:\n    case DW_AT_call_target:\n    case DW_AT_GNU_call_site_target:\n    case DW_AT_call_target_clobbered:\n    case DW_AT_GNU_call_site_target_clobbered:\n      if ((dwarf_version < 4\n\t   && (form == DW_FORM_data4 || form == DW_FORM_data8))\n\t  || form == DW_FORM_sec_offset\n\t  || form == DW_FORM_loclistx)\n\t{\n\t  if (attribute != DW_AT_rnglists_base\n\t      && attribute != DW_AT_str_offsets_base)\n\t    printf (_(\" (location list)\"));\n\t}\n      \/* Fall through.  *\/\n    case DW_AT_allocated:\n    case DW_AT_associated:\n    case DW_AT_data_location:\n    case DW_AT_stride:\n    case DW_AT_upper_bound:\n    case DW_AT_lower_bound:\n      if (block_start)\n\t{\n\t  int need_frame_base;\n\n\t  printf (\"\\t(\");\n\t  need_frame_base = decode_location_expression (block_start,\n\t\t\t\t\t\t\tpointer_size,\n\t\t\t\t\t\t\toffset_size,\n\t\t\t\t\t\t\tdwarf_version,\n\t\t\t\t\t\t\tuvalue,\n\t\t\t\t\t\t\tcu_offset, section);\n\t  printf (\")\");\n\t  if (need_frame_base && !have_frame_base)\n\t    printf (_(\" [without DW_AT_frame_base]\"));\n\t}\n      break;\n\n    case DW_AT_data_bit_offset:\n    case DW_AT_byte_size:\n    case DW_AT_bit_size:\n    case DW_AT_string_length_byte_size:\n    case DW_AT_string_length_bit_size:\n    case DW_AT_bit_stride:\n      if (form == DW_FORM_exprloc)\n\t{\n\t  printf (\"\\t(\");\n\t  (void) decode_location_expression (block_start, pointer_size,\n\t\t\t\t\t     offset_size, dwarf_version,\n\t\t\t\t\t     uvalue, cu_offset, section);\n\t  printf (\")\");\n\t}\n      break;\n\n    case DW_AT_import:\n      {\n\tunsigned long abbrev_number;\n\tabbrev_entry *entry;\n\n\tentry = get_type_abbrev_from_form (form, uvalue, cu_offset, end,\n\t\t\t\t\t   section, & abbrev_number, NULL, NULL);\n\tif (entry == NULL)\n\t  {\n\t    if (form != DW_FORM_GNU_ref_alt)\n\t      warn (_(\"Offset %s used as value for DW_AT_import attribute of DIE at offset 0x%lx is too big.\\n\"),\n\t\t    dwarf_vmatoa (\"x\", uvalue),\n\t\t    (unsigned long) (orig_data - section->start));\n\t  }\n\telse\n\t  {\n\t    printf (_(\"\\t[Abbrev Number: %ld\"), abbrev_number);\n\t    printf (\" (%s)\", get_TAG_name (entry->tag));\n\t    printf (\"]\");\n\t  }\n      }\n      break;\n\n    default:\n      break;\n    }\n\n  return data;\n}","target":0,"code_token_length":8436,"total_token_length":8672,"max_tokens_setting":11000}
+{"idx":217551,"func":"int parse(char *elf) {\n    int fd;\n    struct stat st;\n    uint8_t *elf_map;\n    int count;\n    char *tmp;\n    char *name;\n    char flag[4];\n\n    MODE = get_elf_class(elf);\n\n    fd = open(elf, O_RDONLY);\n    if (fd < 0) {\n        perror(\"open\");\n        return -1;\n    }\n\n    if (fstat(fd, &st) < 0) {\n        perror(\"fstat\");\n        return -1;\n    }\n\n    elf_map = mmap(0, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);\n    if (elf_map == MAP_FAILED) {\n        perror(\"mmap\");\n        return -1;\n    }\n\n    \/* 32bit *\/\n    if (MODE == ELFCLASS32) {\n        \/* ELF Header Information *\/\n        Elf32_Ehdr *ehdr;\n        ehdr = (Elf32_Ehdr *)elf_map;\n\n        INFO(\"ELF Header\\n\");        \n        switch (ehdr->e_type) {\n            case ET_NONE:\n                tmp = \"An unknown type\";\n                break;\n\n            case ET_REL:\n                tmp = \"A relocatable file\";\n                break;\n\n            case ET_EXEC:\n                tmp = \"An executable file\";\n                break;\n\n            case ET_DYN:\n                tmp = \"A shared object\";\n                break;\n\n            case ET_CORE:\n                tmp = \"A core file\";\n                break;\n            \n            default:\n                tmp = \"An unknown type\";\n                break;\n        }\n        PRINT_HEADER_EXP(\"e_type:\", ehdr->e_type, tmp);\n\n        switch (ehdr->e_type) {\n            case EM_NONE:\n                tmp = \"An unknown machine\";\n                break;\n\n            case EM_M32:\n                tmp = \"AT&T WE 32100\";\n                break;\n\n            case EM_SPARC:\n                tmp = \"Sun Microsystems SPARC\";\n                break;\n\n            case EM_386:\n                tmp = \"Intel 80386\";\n                break;\n\n            case EM_68K:\n                tmp = \"Motorola 68000\";\n                break;\n            \n            case EM_88K:\n                tmp = \"Motorola 88000\";\n                break;\n\n            case EM_860:\n                tmp = \"Intel 80860\";\n                break;\n\n            case EM_MIPS:\n                tmp = \"MIPS RS3000 (big-endian only)\";\n                break;\n\n            case EM_PARISC:\n                tmp = \"HP\/PA\";\n                break;\n\n            case EM_SPARC32PLUS:\n                tmp = \"SPARC with enhanced instruction set\";\n                break;\n            \n            case EM_PPC:\n                tmp = \"PowerPC\";\n                break;\n\n            case EM_PPC64:\n                tmp = \"PowerPC 64-bit\";\n                break;\n\n            case EM_S390:\n                tmp = \"IBM S\/390\";\n                break;\n\n            case EM_ARM:\n                tmp = \"Advanced RISC Machines\";\n                break;\n\n            case EM_SH:\n                tmp = \"Renesas SuperH\";\n                break;\n            \n            case EM_SPARCV9:\n                tmp = \"SPARC v9 64-bit\";\n                break;\n\n            case EM_IA_64:\n                tmp = \"Intel Itanium\";\n                break;\n\n            case EM_X86_64:\n                tmp = \"AMD x86-64\";\n                break;\n\n            case EM_VAX:\n                tmp = \"DEC Vax\";\n                break;\n            \n            default:\n                tmp = \"An unknown machine\";\n                break;\n        }\n        PRINT_HEADER_EXP(\"e_machine:\", ehdr->e_machine, tmp);\n\n        switch (ehdr->e_version) {\n            case EV_NONE:\n                tmp = \"Invalid version\";\n                break;\n\n            case EV_CURRENT:\n                tmp = \"Current version\";\n                break;\n\n            default:\n                tmp = \"Known version\";\n                break;\n        }\n        PRINT_HEADER_EXP(\"e_version:\", ehdr->e_version, tmp);\n        PRINT_HEADER(\"e_entry:\", ehdr->e_entry);\n        PRINT_HEADER(\"e_phoff:\", ehdr->e_phoff);\n        PRINT_HEADER(\"e_shoff:\", ehdr->e_shoff);\n        PRINT_HEADER(\"e_flags:\", ehdr->e_flags);\n        PRINT_HEADER(\"e_ehsize:\", ehdr->e_ehsize);\n        PRINT_HEADER(\"e_phentsize:\", ehdr->e_phentsize);\n        PRINT_HEADER(\"e_phnum:\", ehdr->e_phnum);\n        PRINT_HEADER(\"e_shentsize:\", ehdr->e_shentsize);\n        PRINT_HEADER(\"e_shentsize:\", ehdr->e_shentsize);\n        PRINT_HEADER(\"e_shstrndx:\", ehdr->e_shstrndx);\n\n        \/* Section Information *\/\n        Elf32_Shdr *shdr;\n        Elf32_Phdr *phdr;\n        Elf32_Shdr shstrtab;\n\n        shdr = (Elf32_Shdr *)&elf_map[ehdr->e_shoff];\n        phdr = (Elf32_Phdr *)&elf_map[ehdr->e_phoff];\n        shstrtab = shdr[ehdr->e_shstrndx];\n\n        INFO(\"Section Header Table\\n\");\n        PRINT_SECTION_TITLE(\"Nr\", \"Name\", \"Type\", \"Addr\", \"Off\", \"Size\", \"Es\", \"Flg\", \"Lk\", \"Inf\", \"Al\");\n        for (int i = 0; i < ehdr->e_shnum; i++) {\n            name = elf_map + shstrtab.sh_offset + shdr[i].sh_name;\n\n            switch (shdr[i].sh_type) {\n                case SHT_NULL:\n                    tmp = \"SHT_NULL\";\n                    break;\n                \n                case SHT_PROGBITS:\n                    tmp = \"SHT_PROGBITS\";\n                    break;\n\n                case SHT_SYMTAB:\n                    tmp = \"SHT_SYMTAB\";\n                    break;\n\n                case SHT_STRTAB:\n                    tmp = \"SHT_STRTAB\";\n                    break;\n\n                case SHT_RELA:\n                    tmp = \"SHT_RELA\";\n                    break;\n\n                case SHT_HASH:\n                    tmp = \"SHT_HASH\";\n                    break;\n\n                case SHT_DYNAMIC:\n                    tmp = \"SHT_DYNAMIC\";\n                    break;\n\n                case SHT_NOTE:\n                    tmp = \"SHT_NOTE\";\n                    break;\n\n                case SHT_NOBITS:\n                    tmp = \"SHT_NOBITS\";\n                    break;\n\n                case SHT_REL:\n                    tmp = \"SHT_REL\";\n                    break;\n\n                case SHT_SHLIB:\n                    tmp = \"SHT_SHLIB\";\n                    break;\n\n                case SHT_DYNSYM:\n                    tmp = \"SHT_DYNSYM\";\n                    break;\n\n                case SHT_LOPROC:\n                    tmp = \"SHT_LOPROC\";\n                    break;\n\n                case SHT_HIPROC:\n                    tmp = \"SHT_HIPROC\";\n                    break;\n\n                case SHT_LOUSER:\n                    tmp = \"SHT_LOUSER\";\n                    break;\n\n                case SHT_HIUSER:\n                    tmp = \"SHT_HIUSER\";\n                    break;\n                \n                default:\n                    break;\n            }\n\n            if (strlen(name) > 15) {\n                strcpy(&name[15 - 6], \"[...]\");\n            }\n            strcpy(flag, \"   \");\n            flag2str_sh(shdr[i].sh_flags, flag);\n            PRINT_SECTION(i, name, tmp, shdr[i].sh_addr, shdr[i].sh_offset, shdr[i].sh_size, shdr[i].sh_entsize, \\\n                            flag, shdr[i].sh_link, shdr[i].sh_info, shdr[i].sh_addralign);\n        }\n\n        INFO(\"Program Header Table\\n\");\n        PRINT_PROGRAM_TITLE(\"Nr\", \"Type\", \"Offset\", \"Virtaddr\", \"Physaddr\", \"Filesiz\", \"Memsiz\", \"Flg\", \"Align\");\n        for (int i = 0; i < ehdr->e_phnum; i++) {\n            switch (phdr[i].p_type) {\n                case PT_NULL:\n                    tmp = \"PT_NULL\";\n                    break;\n                \n                case PT_LOAD:\n                    tmp = \"PT_LOAD\";\n                    break;\n\n                case PT_DYNAMIC:\n                    tmp = \"PT_DYNAMIC\";\n                    break;\n\n                case PT_INTERP:\n                    tmp = \"PT_INTERP\";\n                    break;\n\n                case PT_NOTE:\n                    tmp = \"PT_NOTE\";\n                    break;\n\n                case PT_SHLIB:\n                    tmp = \"PT_SHLIB\";\n                    break;\n\n                case PT_PHDR:\n                    tmp = \"PT_PHDR\";\n                    break;\n\n                case PT_LOPROC:\n                    tmp = \"PT_LOPROC\";\n                    break;\n\n                case PT_HIPROC:\n                    tmp = \"PT_HIPROC\";\n                    break;\n\n                case PT_GNU_STACK:\n                    tmp = \"PT_GNU_STACK\";\n                    break;\n                \n                default:\n                    break;\n            }\n            strcpy(flag, \"   \");\n            flag2str(phdr[i].p_flags, flag);\n            PRINT_PROGRAM(i, tmp, phdr[i].p_offset, phdr[i].p_vaddr, phdr[i].p_paddr, phdr[i].p_filesz, phdr[i].p_memsz, flag, phdr[i].p_align); \n        }\n\n        INFO(\"Section to segment mapping\\n\");\n        for (int i = 0; i < ehdr->e_phnum; i++) {\n            printf(\"     [%2d]\", i);\n            for (int j = 0; j < ehdr->e_shnum; j++) {\n                name = elf_map + shstrtab.sh_offset + shdr[j].sh_name;\n                if (shdr[j].sh_addr >= phdr[i].p_vaddr && shdr[j].sh_addr + shdr[j].sh_size <= phdr[i].p_vaddr + phdr[i].p_memsz && shdr[j].sh_type != SHT_NULL) {\n                    if (shdr[j].sh_flags >> 1 & 0x1) {\n                        printf(\" %s\", name);\n                    }\n                }    \n            }\n            printf(\"\\n\");\n        }\n\n        INFO(\"Dynamic link information\\n\");\n        int dynstr;\n        int dynamic;\n        Elf32_Dyn *dyn;\n        for (int i = 0; i < ehdr->e_shnum; i++) {\n            name = elf_map + shstrtab.sh_offset + shdr[i].sh_name;\n            if (!strcmp(name, \".dynstr\")) {\n                dynstr = i;\n            }\n            if (!strcmp(name, \".dynamic\")) {\n                dynamic = i;\n            }\n        }\n\n        char value[50];\n        name = \"\";\n        dyn = (Elf32_Dyn *)&elf_map[shdr[dynamic].sh_offset];\n        count = shdr[dynamic].sh_size \/ sizeof(Elf32_Dyn);\n        INFO(\"Dynamic section at offset 0x%x contains %d entries\\n\", shdr[dynamic].sh_offset, count);\n        PRINT_DYN_TITLE(\"Tag\", \"Type\", \"Name\/Value\");\n        \n        for(int i = 0; i < count; i++) {\n            tmp = \"\";\n            memset(value, 0, 50);\n            snprintf(value, 50, \"0x%x\", dyn[i].d_un.d_val);\n            switch (dyn[i].d_tag) {\n                \/* Legal values for d_tag (dynamic entry type).  *\/\n                case DT_NULL:\n                    tmp = \"DT_NULL\";\n                    break;\n\n                case DT_NEEDED:\n                    tmp = \"DT_NEEDED\";\n                    name = elf_map + shdr[dynstr].sh_offset + dyn[i].d_un.d_val;\n                    snprintf(value, 50, \"Shared library: [%s]\", name);\n                    break;\n                \n                case DT_PLTRELSZ:\n                    tmp = \"DT_PLTRELSZ\";\n                    break;\n\n                case DT_PLTGOT:\n                    tmp = \"DT_PLTGOT\";\n                    break;\n\n                case DT_HASH:\n                    tmp = \"DT_HASH\";\n                    break;\n\n                case DT_STRTAB:\n                    tmp = \"DT_STRTAB\";\n                    break;\n\n                case DT_SYMTAB:\n                    tmp = \"DT_SYMTAB\";\n                    break;\n\n                case DT_RELA:\n                    tmp = \"DT_RELA\";\n                    break;\n\n                case DT_RELASZ:\n                    tmp = \"DT_RELASZ\";\n                    break;\n\n                case DT_RELAENT:\n                    tmp = \"DT_RELAENT\";\n                    break;\n\n                case DT_STRSZ:\n                    tmp = \"DT_STRSZ\";\n                    break;\n\n                case DT_SYMENT:\n                    tmp = \"DT_SYMENT\";\n                    break;\n\n                case DT_INIT:\n                    tmp = \"DT_INIT\";\n                    break;\n\n                case DT_FINI:\n                    tmp = \"DT_FINI\";\n                    break;\n\n                case DT_SONAME:\n                    tmp = \"DT_SONAME\";\n                    break;\n\n                case DT_RPATH:\n                    tmp = \"DT_RPATH\";\n                    break;\n\n                case DT_SYMBOLIC:\n                    tmp = \"DT_SYMBOLIC\";\n                    break;\n\n                case DT_REL:\n                    tmp = \"DT_REL\";\n                    break;\n\n                case DT_RELSZ:\n                    tmp = \"DT_RELSZ\";\n                    break;\n\n                case DT_RELENT:\n                    tmp = \"DT_RELENT\";\n                    break;\n                    \n                case DT_PLTREL:\n                    tmp = \"DT_PLTREL\";\n                    break;\n\n                case DT_DEBUG:\n                    tmp = \"DT_DEBUG\";\n                    break;\n\n                case DT_TEXTREL:\n                    tmp = \"DT_TEXTREL\";\n                    break;\n\n                case DT_JMPREL:\n                    tmp = \"DT_JMPREL\";\n                    break;\n\n                case DT_BIND_NOW:\n                    tmp = \"DT_BIND_NOW\";\n                    break;\n\n                case DT_INIT_ARRAY:\n                    tmp = \"DT_INIT_ARRAY\";\n                    break;\n\n                case DT_FINI_ARRAY:\n                    tmp = \"DT_FINI_ARRAY\";\n                    break;\n\n                case DT_INIT_ARRAYSZ:\n                    tmp = \"DT_INIT_ARRAYSZ\";\n                    break;\n                \n                case DT_FINI_ARRAYSZ:\n                    tmp = \"DT_FINI_ARRAYSZ\";\n                    break;\n\n                case DT_RUNPATH:\n                    tmp = \"DT_RUNPATH\";\n                    break;\n\n                case DT_FLAGS:\n                    tmp = \"DT_FLAGS\";\n                    snprintf(value, 50, \"Flags: %d\", dyn[i].d_un.d_val);\n                    break;\n                \n                case DT_ENCODING:\n                    tmp = \"DT_ENCODING\";\n                    break;\n\n                case DT_PREINIT_ARRAYSZ:\n                    tmp = \"DT_PREINIT_ARRAYSZ\";\n                    break;\n\n                case DT_SYMTAB_SHNDX:\n                    tmp = \"DT_SYMTAB_SHNDX\";\n                    break;\n                \n                case DT_NUM:\n                    tmp = \"DT_NUM\";\n                    break;\n\n                case DT_LOOS:\n                    tmp = \"DT_LOOS\";\n                    break;\n\n                case DT_HIOS:\n                    tmp = \"DT_HIOS\";\n                    break;\n\n                case DT_LOPROC:\n                    tmp = \"DT_LOPROC\";\n                    break;\n\n                case DT_HIPROC:\n                    tmp = \"DT_HIPROC\";\n                    break;\n\n                case DT_PROCNUM:\n                    tmp = \"DT_LOPROC\";\n                    break;\n\n                \/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the\n                 * Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's\n                 * approach. *\/\n\n                case DT_VALRNGLO:\n                    tmp = \"DT_VALRNGLO\";\n                    break;\n\n                case DT_GNU_PRELINKED:\n                    tmp = \"DT_GNU_PRELINKED\";\n                    break;\n                \n                case DT_GNU_CONFLICTSZ:\n                    tmp = \"DT_GNU_CONFLICTSZ\";\n                    break;\n\n                case DT_GNU_LIBLISTSZ:\n                    tmp = \"DT_GNU_LIBLISTSZ\";\n                    break;\n\n                case DT_CHECKSUM:\n                    tmp = \"DT_CHECKSUM\";\n                    break;\n\n                case DT_PLTPADSZ:\n                    tmp = \"DT_PLTPADSZ\";\n                    break;\n\n                case DT_MOVEENT:\n                    tmp = \"DT_MOVEENT\";\n                    break;\n\n                case DT_MOVESZ:\n                    tmp = \"DT_MOVESZ\";\n                    break;\n\n                case DT_FEATURE_1:\n                    tmp = \"DT_FEATURE_1\";\n                    break;\n\n                case DT_POSFLAG_1:\n                    tmp = \"DT_POSFLAG_1\";\n                    break;\n\n                case DT_SYMINSZ:\n                    tmp = \"DT_SYMINSZ\";\n                    break;\n\n                case DT_SYMINENT:\n                    tmp = \"DT_SYMINENT\";\n                    break;\n\n                \/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the\n                 * Dyn.d_un.d_ptr field of the Elf*_Dyn structure.\n                 * If any adjustment is made to the ELF object after it has been\n                 * built these entries will need to be adjusted.  *\/\n                case DT_ADDRRNGLO:\n                    tmp = \"DT_ADDRRNGLO\";\n                    break;\n\n                case DT_GNU_HASH:\n                    tmp = \"DT_GNU_HASH\";\n                    break;\n\n                case DT_TLSDESC_PLT:\n                    tmp = \"DT_TLSDESC_PLT\";\n                    break;\n\n                case DT_TLSDESC_GOT:\n                    tmp = \"DT_TLSDESC_GOT\";\n                    break;\n\n                case DT_GNU_CONFLICT:\n                    tmp = \"DT_GNU_CONFLICT\";\n                    break;\n\n                case DT_GNU_LIBLIST:\n                    tmp = \"DT_GNU_LIBLIST\";\n                    break;\n\n                case DT_CONFIG:\n                    tmp = \"DT_CONFIG\";\n                    break;\n\n                case DT_DEPAUDIT:\n                    tmp = \"DT_DEPAUDIT\";\n                    break;\n\n                case DT_AUDIT:\n                    tmp = \"DT_AUDIT\";\n                    break;\n\n                case DT_PLTPAD:\n                    tmp = \"DT_PLTPAD\";\n                    break;\n\n                case DT_MOVETAB:\n                    tmp = \"DT_MOVETAB\";\n                    break;\n\n                case DT_SYMINFO:\n                    tmp = \"DT_SYMINFO\";\n                    break;\n                    \n                \/* The versioning entry types.  The next are defined as part of the\n                 * GNU extension.  *\/\n                case DT_VERSYM:\n                    tmp = \"DT_VERSYM\";\n                    break;\n\n                case DT_RELACOUNT:\n                    tmp = \"DT_RELACOUNT\";\n                    break;\n\n                case DT_RELCOUNT:\n                    tmp = \"DT_RELCOUNT\";\n                    break;\n                \n                \/* These were chosen by Sun.  *\/\n                case DT_FLAGS_1:\n                    tmp = \"DT_FLAGS_1\";\n                    switch (dyn[i].d_un.d_val) {\n                        case DF_1_PIE:\n                            snprintf(value, 50, \"Flags: %s\", \"PIE\");\n                            break;\n                        \n                        default:\n                            snprintf(value, 50, \"Flags: %d\", dyn[i].d_un.d_val);\n                            break;\n                    }\n                    \n                    break;\n\n                case DT_VERDEF:\n                    tmp = \"DT_VERDEF\";\n                    break;\n\n                case DT_VERDEFNUM:\n                    tmp = \"DT_VERDEFNUM\";\n                    break;\n\n                case DT_VERNEED:\n                    tmp = \"DT_VERNEED\";\n                    break;\n\n                case DT_VERNEEDNUM:\n                    tmp = \"DT_VERNEEDNUM\";\n                    break;\n                \n                default:\n                    break;\n            }\n            PRINT_DYN(dyn[i].d_tag, tmp, value);\n        }        \n    }\n\n    \/* 64bit *\/\n    if (MODE == ELFCLASS64) {\n        \/* ELF Header Information *\/\n        Elf64_Ehdr *ehdr;\n        ehdr = (Elf64_Ehdr *)elf_map;\n\n        INFO(\"ELF Header\\n\");        \n        switch (ehdr->e_type) {\n            case ET_NONE:\n                tmp = \"An unknown type\";\n                break;\n\n            case ET_REL:\n                tmp = \"A relocatable file\";\n                break;\n\n            case ET_EXEC:\n                tmp = \"An executable file\";\n                break;\n\n            case ET_DYN:\n                tmp = \"A shared object\";\n                break;\n\n            case ET_CORE:\n                tmp = \"A core file\";\n                break;\n            \n            default:\n                tmp = \"An unknown type\";\n                break;\n        }\n        PRINT_HEADER_EXP(\"e_type:\", ehdr->e_type, tmp);\n\n        switch (ehdr->e_type) {\n            case EM_NONE:\n                tmp = \"An unknown machine\";\n                break;\n\n            case EM_M32:\n                tmp = \"AT&T WE 32100\";\n                break;\n\n            case EM_SPARC:\n                tmp = \"Sun Microsystems SPARC\";\n                break;\n\n            case EM_386:\n                tmp = \"Intel 80386\";\n                break;\n\n            case EM_68K:\n                tmp = \"Motorola 68000\";\n                break;\n            \n            case EM_88K:\n                tmp = \"Motorola 88000\";\n                break;\n\n            case EM_860:\n                tmp = \"Intel 80860\";\n                break;\n\n            case EM_MIPS:\n                tmp = \"MIPS RS3000 (big-endian only)\";\n                break;\n\n            case EM_PARISC:\n                tmp = \"HP\/PA\";\n                break;\n\n            case EM_SPARC32PLUS:\n                tmp = \"SPARC with enhanced instruction set\";\n                break;\n            \n            case EM_PPC:\n                tmp = \"PowerPC\";\n                break;\n\n            case EM_PPC64:\n                tmp = \"PowerPC 64-bit\";\n                break;\n\n            case EM_S390:\n                tmp = \"IBM S\/390\";\n                break;\n\n            case EM_ARM:\n                tmp = \"Advanced RISC Machines\";\n                break;\n\n            case EM_SH:\n                tmp = \"Renesas SuperH\";\n                break;\n            \n            case EM_SPARCV9:\n                tmp = \"SPARC v9 64-bit\";\n                break;\n\n            case EM_IA_64:\n                tmp = \"Intel Itanium\";\n                break;\n\n            case EM_X86_64:\n                tmp = \"AMD x86-64\";\n                break;\n\n            case EM_VAX:\n                tmp = \"DEC Vax\";\n                break;\n            \n            default:\n                tmp = \"An unknown machine\";\n                break;\n        }\n        PRINT_HEADER_EXP(\"e_machine:\", ehdr->e_machine, tmp);\n\n        switch (ehdr->e_version) {\n            case EV_NONE:\n                tmp = \"Invalid version\";\n                break;\n\n            case EV_CURRENT:\n                tmp = \"Current version\";\n                break;\n\n            default:\n                tmp = \"Known version\";\n                break;\n        }\n        PRINT_HEADER_EXP(\"e_version:\", ehdr->e_version, tmp);\n        PRINT_HEADER(\"e_entry:\", ehdr->e_entry);\n        PRINT_HEADER(\"e_phoff:\", ehdr->e_phoff);\n        PRINT_HEADER(\"e_shoff:\", ehdr->e_shoff);\n        PRINT_HEADER(\"e_flags:\", ehdr->e_flags);\n        PRINT_HEADER(\"e_ehsize:\", ehdr->e_ehsize);\n        PRINT_HEADER(\"e_phentsize:\", ehdr->e_phentsize);\n        PRINT_HEADER(\"e_phnum:\", ehdr->e_phnum);\n        PRINT_HEADER(\"e_shentsize:\", ehdr->e_shentsize);\n        PRINT_HEADER(\"e_shentsize:\", ehdr->e_shentsize);\n        PRINT_HEADER(\"e_shstrndx:\", ehdr->e_shstrndx);\n\n        \/* Section Information *\/\n        Elf64_Shdr *shdr;\n        Elf64_Phdr *phdr;\n        Elf64_Shdr shstrtab;\n\n        shdr = (Elf64_Shdr *)&elf_map[ehdr->e_shoff];\n        phdr = (Elf64_Phdr *)&elf_map[ehdr->e_phoff];\n        shstrtab = shdr[ehdr->e_shstrndx];\n\n        INFO(\"Section Header Table\\n\");\n        PRINT_SECTION_TITLE(\"Nr\", \"Name\", \"Type\", \"Addr\", \"Off\", \"Size\", \"Es\", \"Flg\", \"Lk\", \"Inf\", \"Al\");\n        for (int i = 0; i < ehdr->e_shnum; i++) {\n            name = elf_map + shstrtab.sh_offset + shdr[i].sh_name;\n\n            switch (shdr[i].sh_type) {\n                case SHT_NULL:\n                    tmp = \"SHT_NULL\";\n                    break;\n                \n                case SHT_PROGBITS:\n                    tmp = \"SHT_PROGBITS\";\n                    break;\n\n                case SHT_SYMTAB:\n                    tmp = \"SHT_SYMTAB\";\n                    break;\n\n                case SHT_STRTAB:\n                    tmp = \"SHT_STRTAB\";\n                    break;\n\n                case SHT_RELA:\n                    tmp = \"SHT_RELA\";\n                    break;\n\n                case SHT_HASH:\n                    tmp = \"SHT_HASH\";\n                    break;\n\n                case SHT_DYNAMIC:\n                    tmp = \"SHT_DYNAMIC\";\n                    break;\n\n                case SHT_NOTE:\n                    tmp = \"SHT_NOTE\";\n                    break;\n\n                case SHT_NOBITS:\n                    tmp = \"SHT_NOBITS\";\n                    break;\n\n                case SHT_REL:\n                    tmp = \"SHT_REL\";\n                    break;\n\n                case SHT_SHLIB:\n                    tmp = \"SHT_SHLIB\";\n                    break;\n\n                case SHT_DYNSYM:\n                    tmp = \"SHT_DYNSYM\";\n                    break;\n\n                case SHT_LOPROC:\n                    tmp = \"SHT_LOPROC\";\n                    break;\n\n                case SHT_HIPROC:\n                    tmp = \"SHT_HIPROC\";\n                    break;\n\n                case SHT_LOUSER:\n                    tmp = \"SHT_LOUSER\";\n                    break;\n\n                case SHT_HIUSER:\n                    tmp = \"SHT_HIUSER\";\n                    break;\n                \n                default:\n                    break;\n            }\n\n            if (strlen(name) > 15) {\n                strcpy(&name[15 - 6], \"[...]\");\n            }\n            strcpy(flag, \"   \");\n            flag2str_sh(shdr[i].sh_flags, flag);\n            PRINT_SECTION(i, name, tmp, shdr[i].sh_addr, shdr[i].sh_offset, shdr[i].sh_size, shdr[i].sh_entsize, \\\n                            flag, shdr[i].sh_link, shdr[i].sh_info, shdr[i].sh_addralign);\n        }\n\n        INFO(\"Program Header Table\\n\");\n        PRINT_PROGRAM_TITLE(\"Nr\", \"Type\", \"Offset\", \"Virtaddr\", \"Physaddr\", \"Filesiz\", \"Memsiz\", \"Flg\", \"Align\");\n        for (int i = 0; i < ehdr->e_phnum; i++) {\n            switch (phdr[i].p_type) {\n                case PT_NULL:\n                    tmp = \"PT_NULL\";\n                    break;\n                \n                case PT_LOAD:\n                    tmp = \"PT_LOAD\";\n                    break;\n\n                case PT_DYNAMIC:\n                    tmp = \"PT_DYNAMIC\";\n                    break;\n\n                case PT_INTERP:\n                    tmp = \"PT_INTERP\";\n                    break;\n\n                case PT_NOTE:\n                    tmp = \"PT_NOTE\";\n                    break;\n\n                case PT_SHLIB:\n                    tmp = \"PT_SHLIB\";\n                    break;\n\n                case PT_PHDR:\n                    tmp = \"PT_PHDR\";\n                    break;\n\n                case PT_LOPROC:\n                    tmp = \"PT_LOPROC\";\n                    break;\n\n                case PT_HIPROC:\n                    tmp = \"PT_HIPROC\";\n                    break;\n\n                case PT_GNU_STACK:\n                    tmp = \"PT_GNU_STACK\";\n                    break;\n                \n                default:\n                    break;\n            }\n            strcpy(flag, \"   \");\n            flag2str(phdr[i].p_flags, flag);\n            PRINT_PROGRAM(i, tmp, phdr[i].p_offset, phdr[i].p_vaddr, phdr[i].p_paddr, phdr[i].p_filesz, phdr[i].p_memsz, flag, phdr[i].p_align); \n        }\n\n        INFO(\"Section to segment mapping\\n\");\n        for (int i = 0; i < ehdr->e_phnum; i++) {\n            printf(\"     [%2d]\", i);\n            for (int j = 0; j < ehdr->e_shnum; j++) {\n                name = elf_map + shstrtab.sh_offset + shdr[j].sh_name;\n                if (shdr[j].sh_addr >= phdr[i].p_vaddr && shdr[j].sh_addr + shdr[j].sh_size <= phdr[i].p_vaddr + phdr[i].p_memsz && shdr[j].sh_type != SHT_NULL) {\n                    if (shdr[j].sh_flags >> 1 & 0x1) {\n                        printf(\" %s\", name);\n                    }\n                }    \n            }\n            printf(\"\\n\");\n        }\n\n        INFO(\"Dynamic link information\\n\");\n        int dynstr;\n        int dynamic;\n        Elf64_Dyn *dyn;\n        for (int i = 0; i < ehdr->e_shnum; i++) {\n            name = elf_map + shstrtab.sh_offset + shdr[i].sh_name;\n            if (!strcmp(name, \".dynstr\")) {\n                dynstr = i;\n            }\n            if (!strcmp(name, \".dynamic\")) {\n                dynamic = i;\n            }\n        }\n\n        char value[50];\n        name = \"\";\n        dyn = (Elf64_Dyn *)&elf_map[shdr[dynamic].sh_offset];\n        count = shdr[dynamic].sh_size \/ sizeof(Elf64_Dyn);\n        INFO(\"Dynamic section at offset 0x%x contains %d entries\\n\", shdr[dynamic].sh_offset, count);\n        PRINT_DYN_TITLE(\"Tag\", \"Type\", \"Name\/Value\");\n        \n        for(int i = 0; i < count; i++) {\n            tmp = \"\";\n            memset(value, 0, 50);\n            snprintf(value, 50, \"0x%x\", dyn[i].d_un.d_val);\n            switch (dyn[i].d_tag) {\n                \/* Legal values for d_tag (dynamic entry type).  *\/\n                case DT_NULL:\n                    tmp = \"DT_NULL\";\n                    break;\n\n                case DT_NEEDED:\n                    tmp = \"DT_NEEDED\";\n                    name = elf_map + shdr[dynstr].sh_offset + dyn[i].d_un.d_val;\n                    snprintf(value, 50, \"Shared library: [%s]\", name);\n                    break;\n                \n                case DT_PLTRELSZ:\n                    tmp = \"DT_PLTRELSZ\";\n                    break;\n\n                case DT_PLTGOT:\n                    tmp = \"DT_PLTGOT\";\n                    break;\n\n                case DT_HASH:\n                    tmp = \"DT_HASH\";\n                    break;\n\n                case DT_STRTAB:\n                    tmp = \"DT_STRTAB\";\n                    break;\n\n                case DT_SYMTAB:\n                    tmp = \"DT_SYMTAB\";\n                    break;\n\n                case DT_RELA:\n                    tmp = \"DT_RELA\";\n                    break;\n\n                case DT_RELASZ:\n                    tmp = \"DT_RELASZ\";\n                    break;\n\n                case DT_RELAENT:\n                    tmp = \"DT_RELAENT\";\n                    break;\n\n                case DT_STRSZ:\n                    tmp = \"DT_STRSZ\";\n                    break;\n\n                case DT_SYMENT:\n                    tmp = \"DT_SYMENT\";\n                    break;\n\n                case DT_INIT:\n                    tmp = \"DT_INIT\";\n                    break;\n\n                case DT_FINI:\n                    tmp = \"DT_FINI\";\n                    break;\n\n                case DT_SONAME:\n                    tmp = \"DT_SONAME\";\n                    break;\n\n                case DT_RPATH:\n                    tmp = \"DT_RPATH\";\n                    break;\n\n                case DT_SYMBOLIC:\n                    tmp = \"DT_SYMBOLIC\";\n                    break;\n\n                case DT_REL:\n                    tmp = \"DT_REL\";\n                    break;\n\n                case DT_RELSZ:\n                    tmp = \"DT_RELSZ\";\n                    break;\n\n                case DT_RELENT:\n                    tmp = \"DT_RELENT\";\n                    break;\n                    \n                case DT_PLTREL:\n                    tmp = \"DT_PLTREL\";\n                    break;\n\n                case DT_DEBUG:\n                    tmp = \"DT_DEBUG\";\n                    break;\n\n                case DT_TEXTREL:\n                    tmp = \"DT_TEXTREL\";\n                    break;\n\n                case DT_JMPREL:\n                    tmp = \"DT_JMPREL\";\n                    break;\n\n                case DT_BIND_NOW:\n                    tmp = \"DT_BIND_NOW\";\n                    break;\n\n                case DT_INIT_ARRAY:\n                    tmp = \"DT_INIT_ARRAY\";\n                    break;\n\n                case DT_FINI_ARRAY:\n                    tmp = \"DT_FINI_ARRAY\";\n                    break;\n\n                case DT_INIT_ARRAYSZ:\n                    tmp = \"DT_INIT_ARRAYSZ\";\n                    break;\n                \n                case DT_FINI_ARRAYSZ:\n                    tmp = \"DT_FINI_ARRAYSZ\";\n                    break;\n\n                case DT_RUNPATH:\n                    tmp = \"DT_RUNPATH\";\n                    break;\n\n                case DT_FLAGS:\n                    tmp = \"DT_FLAGS\";\n                    snprintf(value, 50, \"Flags: %d\", dyn[i].d_un.d_val);\n                    break;\n                \n                case DT_ENCODING:\n                    tmp = \"DT_ENCODING\";\n                    break;\n\n                case DT_PREINIT_ARRAYSZ:\n                    tmp = \"DT_PREINIT_ARRAYSZ\";\n                    break;\n\n                case DT_SYMTAB_SHNDX:\n                    tmp = \"DT_SYMTAB_SHNDX\";\n                    break;\n                \n                case DT_NUM:\n                    tmp = \"DT_NUM\";\n                    break;\n\n                case DT_LOOS:\n                    tmp = \"DT_LOOS\";\n                    break;\n\n                case DT_HIOS:\n                    tmp = \"DT_HIOS\";\n                    break;\n\n                case DT_LOPROC:\n                    tmp = \"DT_LOPROC\";\n                    break;\n\n                case DT_HIPROC:\n                    tmp = \"DT_HIPROC\";\n                    break;\n\n                case DT_PROCNUM:\n                    tmp = \"DT_LOPROC\";\n                    break;\n\n                \/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the\n                 * Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's\n                 * approach. *\/\n\n                case DT_VALRNGLO:\n                    tmp = \"DT_VALRNGLO\";\n                    break;\n\n                case DT_GNU_PRELINKED:\n                    tmp = \"DT_GNU_PRELINKED\";\n                    break;\n                \n                case DT_GNU_CONFLICTSZ:\n                    tmp = \"DT_GNU_CONFLICTSZ\";\n                    break;\n\n                case DT_GNU_LIBLISTSZ:\n                    tmp = \"DT_GNU_LIBLISTSZ\";\n                    break;\n\n                case DT_CHECKSUM:\n                    tmp = \"DT_CHECKSUM\";\n                    break;\n\n                case DT_PLTPADSZ:\n                    tmp = \"DT_PLTPADSZ\";\n                    break;\n\n                case DT_MOVEENT:\n                    tmp = \"DT_MOVEENT\";\n                    break;\n\n                case DT_MOVESZ:\n                    tmp = \"DT_MOVESZ\";\n                    break;\n\n                case DT_FEATURE_1:\n                    tmp = \"DT_FEATURE_1\";\n                    break;\n\n                case DT_POSFLAG_1:\n                    tmp = \"DT_POSFLAG_1\";\n                    break;\n\n                case DT_SYMINSZ:\n                    tmp = \"DT_SYMINSZ\";\n                    break;\n\n                case DT_SYMINENT:\n                    tmp = \"DT_SYMINENT\";\n                    break;\n\n                \/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the\n                 * Dyn.d_un.d_ptr field of the Elf*_Dyn structure.\n                 * If any adjustment is made to the ELF object after it has been\n                 * built these entries will need to be adjusted.  *\/\n                case DT_ADDRRNGLO:\n                    tmp = \"DT_ADDRRNGLO\";\n                    break;\n\n                case DT_GNU_HASH:\n                    tmp = \"DT_GNU_HASH\";\n                    break;\n\n                case DT_TLSDESC_PLT:\n                    tmp = \"DT_TLSDESC_PLT\";\n                    break;\n\n                case DT_TLSDESC_GOT:\n                    tmp = \"DT_TLSDESC_GOT\";\n                    break;\n\n                case DT_GNU_CONFLICT:\n                    tmp = \"DT_GNU_CONFLICT\";\n                    break;\n\n                case DT_GNU_LIBLIST:\n                    tmp = \"DT_GNU_LIBLIST\";\n                    break;\n\n                case DT_CONFIG:\n                    tmp = \"DT_CONFIG\";\n                    break;\n\n                case DT_DEPAUDIT:\n                    tmp = \"DT_DEPAUDIT\";\n                    break;\n\n                case DT_AUDIT:\n                    tmp = \"DT_AUDIT\";\n                    break;\n\n                case DT_PLTPAD:\n                    tmp = \"DT_PLTPAD\";\n                    break;\n\n                case DT_MOVETAB:\n                    tmp = \"DT_MOVETAB\";\n                    break;\n\n                case DT_SYMINFO:\n                    tmp = \"DT_SYMINFO\";\n                    break;\n                    \n                \/* The versioning entry types.  The next are defined as part of the\n                 * GNU extension.  *\/\n                case DT_VERSYM:\n                    tmp = \"DT_VERSYM\";\n                    break;\n\n                case DT_RELACOUNT:\n                    tmp = \"DT_RELACOUNT\";\n                    break;\n\n                case DT_RELCOUNT:\n                    tmp = \"DT_RELCOUNT\";\n                    break;\n                \n                \/* These were chosen by Sun.  *\/\n                case DT_FLAGS_1:\n                    tmp = \"DT_FLAGS_1\";\n                    switch (dyn[i].d_un.d_val) {\n                        case DF_1_PIE:\n                            snprintf(value, 50, \"Flags: %s\", \"PIE\");\n                            break;\n                        \n                        default:\n                            snprintf(value, 50, \"Flags: %d\", dyn[i].d_un.d_val);\n                            break;\n                    }\n                    \n                    break;\n\n                case DT_VERDEF:\n                    tmp = \"DT_VERDEF\";\n                    break;\n\n                case DT_VERDEFNUM:\n                    tmp = \"DT_VERDEFNUM\";\n                    break;\n\n                case DT_VERNEED:\n                    tmp = \"DT_VERNEED\";\n                    break;\n\n                case DT_VERNEEDNUM:\n                    tmp = \"DT_VERNEEDNUM\";\n                    break;\n                \n                default:\n                    break;\n            }\n            PRINT_DYN(dyn[i].d_tag, tmp, value);\n        }        \n    }\n\n    return 0;\n}","target":1,"code_token_length":8022,"total_token_length":8258,"max_tokens_setting":11000}
+{"idx":439266,"func":"static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n  BMPInfo\n    bmp_info;\n\n  Image\n    *image;\n\n  IndexPacket\n    index;\n\n  MagickBooleanType\n    status;\n\n  MagickOffsetType\n    offset,\n    start_position;\n\n  MemoryInfo\n    *pixel_info;\n\n  register IndexPacket\n    *indexes;\n\n  register PixelPacket\n    *q;\n\n  register ssize_t\n    i,\n    x;\n\n  register unsigned char\n    *p;\n\n  size_t\n    bit,\n    bytes_per_line,\n    length;\n\n  ssize_t\n    count,\n    y;\n\n  unsigned char\n    magick[12],\n    *pixels;\n\n  unsigned int\n    blue,\n    green,\n    offset_bits,\n    red;\n\n  \/*\n    Open image file.\n  *\/\n  assert(image_info != (const ImageInfo *) NULL);\n  assert(image_info->signature == MagickCoreSignature);\n  if (image_info->debug != MagickFalse)\n    (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n      image_info->filename);\n  assert(exception != (ExceptionInfo *) NULL);\n  assert(exception->signature == MagickCoreSignature);\n  image=AcquireImage(image_info);\n  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n  if (status == MagickFalse)\n    {\n      image=DestroyImageList(image);\n      return((Image *) NULL);\n    }\n  \/*\n    Determine if this a BMP file.\n  *\/\n  (void) memset(&bmp_info,0,sizeof(bmp_info));\n  bmp_info.ba_offset=0;\n  start_position=0;\n  offset_bits=0;\n  count=ReadBlob(image,2,magick);\n  if (count != 2)\n    ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n  do\n  {\n    LongPixelPacket\n      shift;\n\n    PixelPacket\n      quantum_bits;\n\n    \/*\n      Verify BMP identifier.\n    *\/\n    start_position=TellBlob(image)-2;\n    bmp_info.ba_offset=0;\n    while (LocaleNCompare((char *) magick,\"BA\",2) == 0)\n    {\n      bmp_info.file_size=ReadBlobLSBLong(image);\n      bmp_info.ba_offset=ReadBlobLSBLong(image);\n      bmp_info.offset_bits=ReadBlobLSBLong(image);\n      count=ReadBlob(image,2,magick);\n      if (count != 2)\n        break;\n    }\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  Magick: %c%c\",\n        magick[0],magick[1]);\n    if ((count != 2) || ((LocaleNCompare((char *) magick,\"BM\",2) != 0) &&\n        (LocaleNCompare((char *) magick,\"CI\",2) != 0)))\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    bmp_info.file_size=ReadBlobLSBLong(image);\n    (void) ReadBlobLSBLong(image);\n\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n         \"  File_size in header:  %u bytes\",bmp_info.file_size);\n\n    bmp_info.offset_bits=ReadBlobLSBLong(image);\n    bmp_info.size=ReadBlobLSBLong(image);\n    if (image->debug != MagickFalse)\n      (void) LogMagickEvent(CoderEvent,GetMagickModule(),\"  BMP size: %u\",\n        bmp_info.size);\n    if (bmp_info.size == 12)\n      {\n        \/*\n          OS\/2 BMP image file.\n        *\/\n        (void) CopyMagickString(image->magick,\"BMP2\",MaxTextExtent);\n        bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image));\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.x_pixels=0;\n        bmp_info.y_pixels=0;\n        bmp_info.number_colors=0;\n        bmp_info.compression=BI_RGB;\n        bmp_info.image_size=0;\n        bmp_info.alpha_mask=0;\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: OS\/2 Bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n          }\n      }\n    else\n      {\n        \/*\n          Microsoft Windows BMP image file.\n        *\/\n        if (bmp_info.size < 40)\n          ThrowReaderException(CorruptImageError,\"NonOS2HeaderSizeError\");\n        bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image);\n        bmp_info.planes=ReadBlobLSBShort(image);\n        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);\n        bmp_info.compression=ReadBlobLSBLong(image);\n        bmp_info.image_size=ReadBlobLSBLong(image);\n        bmp_info.x_pixels=ReadBlobLSBLong(image);\n        bmp_info.y_pixels=ReadBlobLSBLong(image);\n        bmp_info.number_colors=ReadBlobLSBLong(image);\n        if (bmp_info.number_colors > GetBlobSize(image))\n          ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n        bmp_info.colors_important=ReadBlobLSBLong(image);\n        if (image->debug != MagickFalse)\n          {\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Format: MS Windows bitmap\");\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Geometry: %.20gx%.20g\",(double) bmp_info.width,(double)\n              bmp_info.height);\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Bits per pixel: %.20g\",(double) bmp_info.bits_per_pixel);\n            switch (bmp_info.compression)\n            {\n              case BI_RGB:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RGB\");\n                break;\n              }\n              case BI_RLE4:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE4\");\n                break;\n              }\n              case BI_RLE8:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_RLE8\");\n                break;\n              }\n              case BI_BITFIELDS:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_BITFIELDS\");\n                break;\n              }\n              case BI_PNG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_PNG\");\n                break;\n              }\n              case BI_JPEG:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: BI_JPEG\");\n                break;\n              }\n              default:\n              {\n                (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n                  \"  Compression: UNKNOWN (%u)\",bmp_info.compression);\n              }\n            }\n            (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n              \"  Number of colors: %u\",bmp_info.number_colors);\n          }\n        bmp_info.red_mask=ReadBlobLSBLong(image);\n        bmp_info.green_mask=ReadBlobLSBLong(image);\n        bmp_info.blue_mask=ReadBlobLSBLong(image);\n        if (bmp_info.size > 40)\n          {\n            double\n              gamma;\n\n            \/*\n              Read color management information.\n            *\/\n            bmp_info.alpha_mask=ReadBlobLSBLong(image);\n            bmp_info.colorspace=ReadBlobLSBSignedLong(image);\n            \/*\n              Decode 2^30 fixed point formatted CIE primaries.\n            *\/\n#           define BMP_DENOM ((double) 0x40000000)\n            bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n            bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)\/BMP_DENOM;\n\n            gamma=bmp_info.red_primary.x+bmp_info.red_primary.y+\n              bmp_info.red_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.red_primary.x*=gamma;\n            bmp_info.red_primary.y*=gamma;\n            image->chromaticity.red_primary.x=bmp_info.red_primary.x;\n            image->chromaticity.red_primary.y=bmp_info.red_primary.y;\n\n            gamma=bmp_info.green_primary.x+bmp_info.green_primary.y+\n              bmp_info.green_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.green_primary.x*=gamma;\n            bmp_info.green_primary.y*=gamma;\n            image->chromaticity.green_primary.x=bmp_info.green_primary.x;\n            image->chromaticity.green_primary.y=bmp_info.green_primary.y;\n\n            gamma=bmp_info.blue_primary.x+bmp_info.blue_primary.y+\n              bmp_info.blue_primary.z;\n            gamma=PerceptibleReciprocal(gamma);\n            bmp_info.blue_primary.x*=gamma;\n            bmp_info.blue_primary.y*=gamma;\n            image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;\n            image->chromaticity.blue_primary.y=bmp_info.blue_primary.y;\n\n            \/*\n              Decode 16^16 fixed point formatted gamma_scales.\n            *\/\n            bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)\/0x10000;\n            bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)\/0x10000;\n            \/*\n              Compute a single gamma from the BMP 3-channel gamma.\n            *\/\n            image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+\n              bmp_info.gamma_scale.z)\/3.0;\n          }\n        else\n          (void) CopyMagickString(image->magick,\"BMP3\",MaxTextExtent);\n\n        if (bmp_info.size > 108)\n          {\n            size_t\n              intent;\n\n            \/*\n              Read BMP Version 5 color management information.\n            *\/\n            intent=ReadBlobLSBLong(image);\n            switch ((int) intent)\n            {\n              case LCS_GM_BUSINESS:\n              {\n                image->rendering_intent=SaturationIntent;\n                break;\n              }\n              case LCS_GM_GRAPHICS:\n              {\n                image->rendering_intent=RelativeIntent;\n                break;\n              }\n              case LCS_GM_IMAGES:\n              {\n                image->rendering_intent=PerceptualIntent;\n                break;\n              }\n              case LCS_GM_ABS_COLORIMETRIC:\n              {\n                image->rendering_intent=AbsoluteIntent;\n                break;\n              }\n            }\n            (void) ReadBlobLSBLong(image);  \/* Profile data *\/\n            (void) ReadBlobLSBLong(image);  \/* Profile size *\/\n            (void) ReadBlobLSBLong(image);  \/* Reserved byte *\/\n          }\n      }\n    if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))\n      (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,\n        \"LengthAndFilesizeDoNotMatch\",\"`%s'\",image->filename);\n    else\n      if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))\n        (void) ThrowMagickException(exception,GetMagickModule(),\n          CorruptImageWarning,\"LengthAndFilesizeDoNotMatch\",\"`%s'\",\n          image->filename);\n    if (bmp_info.width <= 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.height == 0)\n      ThrowReaderException(CorruptImageError,\"NegativeOrZeroImageSize\");\n    if (bmp_info.planes != 1)\n      ThrowReaderException(CorruptImageError,\"StaticPlanesValueNotEqualToOne\");\n    if ((bmp_info.bits_per_pixel != 1) && (bmp_info.bits_per_pixel != 4) &&\n        (bmp_info.bits_per_pixel != 8) && (bmp_info.bits_per_pixel != 16) &&\n        (bmp_info.bits_per_pixel != 24) && (bmp_info.bits_per_pixel != 32))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if (bmp_info.bits_per_pixel < 16 &&\n        bmp_info.number_colors > (1U << bmp_info.bits_per_pixel))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedNumberOfColors\");\n    if ((bmp_info.compression == 1) && (bmp_info.bits_per_pixel != 8))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 2) && (bmp_info.bits_per_pixel != 4))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    if ((bmp_info.compression == 3) && (bmp_info.bits_per_pixel < 16))\n      ThrowReaderException(CorruptImageError,\"UnrecognizedBitsPerPixel\");\n    switch (bmp_info.compression)\n    {\n      case BI_RGB:\n        image->compression=NoCompression;\n        break;\n      case BI_RLE8:\n      case BI_RLE4:\n        image->compression=RLECompression;\n        break;\n      case BI_BITFIELDS:\n        break;\n      case BI_JPEG:\n        ThrowReaderException(CoderError,\"JPEGCompressNotSupported\");\n      case BI_PNG:\n        ThrowReaderException(CoderError,\"PNGCompressNotSupported\");\n      default:\n        ThrowReaderException(CorruptImageError,\"UnrecognizedImageCompression\");\n    }\n    image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);\n    image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);\n    image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;\n    image->matte=((bmp_info.alpha_mask != 0) &&\n      (bmp_info.compression == BI_BITFIELDS)) ? MagickTrue : MagickFalse;\n    if (bmp_info.bits_per_pixel < 16)\n      {\n        size_t\n          one;\n\n        image->storage_class=PseudoClass;\n        image->colors=bmp_info.number_colors;\n        one=1;\n        if (image->colors == 0)\n          image->colors=one << bmp_info.bits_per_pixel;\n      }\n    image->x_resolution=(double) bmp_info.x_pixels\/100.0;\n    image->y_resolution=(double) bmp_info.y_pixels\/100.0;\n    image->units=PixelsPerCentimeterResolution;\n    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    status=SetImageExtent(image,image->columns,image->rows);\n    if (status == MagickFalse)\n      {\n        InheritException(exception,&image->exception);\n        return(DestroyImageList(image));\n      }\n    if (image->storage_class == PseudoClass)\n      {\n        unsigned char\n          *bmp_colormap;\n\n        size_t\n          packet_size;\n\n        \/*\n          Read BMP raster colormap.\n        *\/\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading colormap of %.20g colors\",(double) image->colors);\n        if (AcquireImageColormap(image,image->colors) == MagickFalse)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        bmp_colormap=(unsigned char *) AcquireQuantumMemory((size_t)\n          image->colors,4*sizeof(*bmp_colormap));\n        if (bmp_colormap == (unsigned char *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        if ((bmp_info.size == 12) || (bmp_info.size == 64))\n          packet_size=3;\n        else\n          packet_size=4;\n        offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET);\n        if (offset < 0)\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n          }\n        count=ReadBlob(image,packet_size*image->colors,bmp_colormap);\n        if (count != (ssize_t) (packet_size*image->colors))\n          {\n            bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n        p=bmp_colormap;\n        for (i=0; i < (ssize_t) image->colors; i++)\n        {\n          image->colormap[i].blue=ScaleCharToQuantum(*p++);\n          image->colormap[i].green=ScaleCharToQuantum(*p++);\n          image->colormap[i].red=ScaleCharToQuantum(*p++);\n          if (packet_size == 4)\n            p++;\n        }\n        bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);\n      }\n    \/*\n      Read image data.\n    *\/\n    if (bmp_info.offset_bits == offset_bits)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    offset_bits=bmp_info.offset_bits;\n    offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET);\n    if (offset < 0)\n      ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n    if (bmp_info.compression == BI_RLE4)\n      bmp_info.bits_per_pixel<<=1;\n    bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)\/32);\n    length=(size_t) bytes_per_line*image->rows;\n    if (((MagickSizeType) length\/8) > GetBlobSize(image))\n      ThrowReaderException(CorruptImageError,\"InsufficientImageDataInFile\");\n    if ((bmp_info.compression == BI_RGB) ||\n        (bmp_info.compression == BI_BITFIELDS))\n      {\n        pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,\n          image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        if (image->debug != MagickFalse)\n          (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n            \"  Reading pixels (%.20g bytes)\",(double) length);\n        count=ReadBlob(image,length,pixels);\n        if (count != (ssize_t) length)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"InsufficientImageDataInFile\");\n          }\n      }\n    else\n      {\n        \/*\n          Convert run-length encoded raster pixels.\n        *\/\n        pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,\n          image->columns+256UL)*sizeof(*pixels));\n        if (pixel_info == (MemoryInfo *) NULL)\n          ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n        pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n        status=DecodeImage(image,bmp_info.compression,pixels,\n          image->columns*image->rows);\n        if (status == MagickFalse)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnableToRunlengthDecodeImage\");\n          }\n      }\n    \/*\n      Convert BMP raster image to pixel packets.\n    *\/\n    if (bmp_info.compression == BI_RGB)\n      {\n        \/*\n          We should ignore the alpha value in BMP3 files but there have been\n          reports about 32 bit files with alpha. We do a quick check to see if\n          the alpha channel contains a value that is not zero (default value).\n          If we find a non zero value we asume the program that wrote the file\n          wants to use the alpha channel.\n        *\/\n        if ((image->matte == MagickFalse) && (bmp_info.size == 40) &&\n            (bmp_info.bits_per_pixel == 32))\n          {\n            bytes_per_line=4*(image->columns);\n            for (y=(ssize_t) image->rows-1; y >= 0; y--)\n            {\n              p=pixels+(image->rows-y-1)*bytes_per_line;\n              for (x=0; x < (ssize_t) image->columns; x++)\n              {\n                if (*(p+3) != 0)\n                  {\n                    image->matte=MagickTrue;\n                    y=-1;\n                    break;\n                  }\n                p+=4;\n              }\n            }\n          }\n        bmp_info.alpha_mask=image->matte != MagickFalse ? 0xff000000U : 0U;\n        bmp_info.red_mask=0x00ff0000U;\n        bmp_info.green_mask=0x0000ff00U;\n        bmp_info.blue_mask=0x000000ffU;\n        if (bmp_info.bits_per_pixel == 16)\n          {\n            \/*\n              RGB555.\n            *\/\n            bmp_info.red_mask=0x00007c00U;\n            bmp_info.green_mask=0x000003e0U;\n            bmp_info.blue_mask=0x0000001fU;\n          }\n      }\n    (void) memset(&shift,0,sizeof(shift));\n    (void) memset(&quantum_bits,0,sizeof(quantum_bits));\n    if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))\n      {\n        register size_t\n          sample;\n\n        \/*\n          Get shift and quantum bits info from bitfield masks.\n        *\/\n        if (bmp_info.red_mask != 0)\n          while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)\n          {\n            shift.red++;\n            if (shift.red > 32U)\n              break;\n          }\n        if (bmp_info.green_mask != 0)\n          while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)\n          {\n            shift.green++;\n            if (shift.green > 32U)\n              break;\n          }\n        if (bmp_info.blue_mask != 0)\n          while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)\n          {\n            shift.blue++;\n            if (shift.blue > 32U)\n              break;\n          }\n        if (bmp_info.alpha_mask != 0)\n          while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)\n          {\n            shift.opacity++;\n            if (shift.opacity > 32U)\n              break;\n          }\n        sample=shift.red;\n        while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.red=ClampToQuantum((MagickRealType) sample-shift.red);\n        sample=shift.green;\n        while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.green=ClampToQuantum((MagickRealType) sample-shift.green);\n        sample=shift.blue;\n        while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.blue=ClampToQuantum((MagickRealType) sample-shift.blue);\n        sample=shift.opacity;\n        while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)\n        {\n          sample++;\n          if (sample > 32U)\n            break;\n        }\n        quantum_bits.opacity=ClampToQuantum((MagickRealType) sample-\n          shift.opacity);\n      }\n    switch (bmp_info.bits_per_pixel)\n    {\n      case 1:\n      {\n        \/*\n          Convert bitmap scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n          {\n            for (bit=0; bit < 8; bit++)\n            {\n              index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n              SetPixelIndex(indexes+x+bit,index);\n              q++;\n            }\n            p++;\n          }\n          if ((image->columns % 8) != 0)\n            {\n              for (bit=0; bit < (image->columns % 8); bit++)\n              {\n                index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);\n                SetPixelIndex(indexes+x+bit,index);\n              }\n              p++;\n            }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 4:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=0; x < ((ssize_t) image->columns-1); x+=2)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0x0f),\n              &index,exception);\n            SetPixelIndex(indexes+x,index);\n            (void) IsValidColormapIndex(image,(ssize_t) (*p & 0x0f),&index,\n              exception);\n            SetPixelIndex(indexes+x+1,index);\n            p++;\n          }\n          if ((image->columns % 2) != 0)\n            {\n              (void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0xf),\n                &index,exception);\n              SetPixelIndex(indexes+(x++),index);\n              p++;\n            }\n          if (x < (ssize_t) image->columns)\n            break;\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 8:\n      {\n        \/*\n          Convert PseudoColor scanline.\n        *\/\n        if ((bmp_info.compression == BI_RLE8) ||\n            (bmp_info.compression == BI_RLE4))\n          bytes_per_line=image->columns;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          indexes=GetAuthenticIndexQueue(image);\n          for (x=(ssize_t) image->columns; x != 0; --x)\n          {\n            (void) IsValidColormapIndex(image,(ssize_t) *p,&index,exception);\n            SetPixelIndex(indexes,index);\n            indexes++;\n            p++;\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        (void) SyncImage(image);\n        break;\n      }\n      case 16:\n      {\n        unsigned int\n          alpha,\n          pixel;\n\n        \/*\n          Convert bitfield encoded 16-bit PseudoColor scanline.\n        *\/\n        if (bmp_info.compression != BI_RGB &&\n            bmp_info.compression != BI_BITFIELDS)\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=2*(image->columns+image->columns % 2);\n        image->storage_class=DirectClass;\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=(*p++) << 8;\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 5)\n              red|=((red & 0xe000) >> 5);\n            if (quantum_bits.red <= 8)\n              red|=((red & 0xff00) >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 5)\n              green|=((green & 0xe000) >> 5);\n            if (quantum_bits.green == 6)\n              green|=((green & 0xc000) >> 6);\n            if (quantum_bits.green <= 8)\n              green|=((green & 0xff00) >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 5)\n              blue|=((blue & 0xe000) >> 5);\n            if (quantum_bits.blue <= 8)\n              blue|=((blue & 0xff00) >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelOpacity(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity <= 8)\n                  alpha|=((alpha & 0xff00) >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 24:\n      {\n        \/*\n          Convert DirectColor scanline.\n        *\/\n        bytes_per_line=4*((image->columns*24+31)\/32);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            SetPixelBlue(q,ScaleCharToQuantum(*p++));\n            SetPixelGreen(q,ScaleCharToQuantum(*p++));\n            SetPixelRed(q,ScaleCharToQuantum(*p++));\n            SetPixelOpacity(q,OpaqueOpacity);\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      case 32:\n      {\n        \/*\n          Convert bitfield encoded DirectColor scanline.\n        *\/\n        if ((bmp_info.compression != BI_RGB) &&\n            (bmp_info.compression != BI_BITFIELDS))\n          {\n            pixel_info=RelinquishVirtualMemory(pixel_info);\n            ThrowReaderException(CorruptImageError,\n              \"UnrecognizedImageCompression\");\n          }\n        bytes_per_line=4*(image->columns);\n        for (y=(ssize_t) image->rows-1; y >= 0; y--)\n        {\n          unsigned int\n            alpha,\n            pixel;\n\n          p=pixels+(image->rows-y-1)*bytes_per_line;\n          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n          if (q == (PixelPacket *) NULL)\n            break;\n          for (x=0; x < (ssize_t) image->columns; x++)\n          {\n            pixel=(unsigned int) (*p++);\n            pixel|=((unsigned int) *p++ << 8);\n            pixel|=((unsigned int) *p++ << 16);\n            pixel|=((unsigned int) *p++ << 24);\n            red=((pixel & bmp_info.red_mask) << shift.red) >> 16;\n            if (quantum_bits.red == 8)\n              red|=(red >> 8);\n            green=((pixel & bmp_info.green_mask) << shift.green) >> 16;\n            if (quantum_bits.green == 8)\n              green|=(green >> 8);\n            blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;\n            if (quantum_bits.blue == 8)\n              blue|=(blue >> 8);\n            SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));\n            SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));\n            SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));\n            SetPixelAlpha(q,OpaqueOpacity);\n            if (image->matte != MagickFalse)\n              {\n                alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;\n                if (quantum_bits.opacity == 8)\n                  alpha|=(alpha >> 8);\n                SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));\n              }\n            q++;\n          }\n          if (SyncAuthenticPixels(image,exception) == MagickFalse)\n            break;\n          offset=(MagickOffsetType) (image->rows-y-1);\n          if (image->previous == (Image *) NULL)\n            {\n              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)\n                (image->rows-y),image->rows);\n              if (status == MagickFalse)\n                break;\n            }\n        }\n        break;\n      }\n      default:\n      {\n        pixel_info=RelinquishVirtualMemory(pixel_info);\n        ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    }\n    pixel_info=RelinquishVirtualMemory(pixel_info);\n    if (y > 0)\n      break;\n    if (EOFBlob(image) != MagickFalse)\n      {\n        ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n          image->filename);\n        break;\n      }\n    if (bmp_info.height < 0)\n      {\n        Image\n          *flipped_image;\n\n        \/*\n          Correct image orientation.\n        *\/\n        flipped_image=FlipImage(image,exception);\n        if (flipped_image != (Image *) NULL)\n          {\n            DuplicateBlob(flipped_image,image);\n            ReplaceImageInList(&image, flipped_image);\n            image=flipped_image;\n          }\n      }\n    \/*\n      Proceed to next image.\n    *\/\n    if (image_info->number_scenes != 0)\n      if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n        break;\n    *magick='\\0';\n    if (bmp_info.ba_offset != 0)\n      {\n        offset=SeekBlob(image,(MagickOffsetType) bmp_info.ba_offset,SEEK_SET);\n        if (offset < 0)\n          ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n      }\n    count=ReadBlob(image,2,magick);\n    if ((count == 2) && (IsBMP(magick,2) != MagickFalse))\n      {\n        \/*\n          Acquire next image structure.\n        *\/\n        AcquireNextImage(image_info,image);\n        if (GetNextImageInList(image) == (Image *) NULL)\n          {\n            status=MagickFalse;\n            break;\n          }\n        image=SyncNextImageInList(image);\n        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n          GetBlobSize(image));\n        if (status == MagickFalse)\n          break;\n      }\n  } while (IsBMP(magick,2) != MagickFalse);\n  (void) CloseBlob(image);\n  if (status == MagickFalse)\n    return(DestroyImageList(image));\n  return(GetFirstImageInList(image));\n}","target":0,"code_token_length":8649,"total_token_length":8885,"max_tokens_setting":11000}
+{"idx":199778,"func":"size_t puma_parser_execute(puma_parser *parser, const char *buffer, size_t len, size_t off)  {\n  const char *p, *pe;\n  int cs = parser->cs;\n\n  assert(off <= len && \"offset past end of buffer\");\n\n  p = buffer+off;\n  pe = buffer+len;\n\n  \/* assert(*pe == '\\0' && \"pointer does not end on NUL\"); *\/\n  assert((size_t) (pe - p) == len - off && \"pointers aren't same distance\");\n\n  \n#line 87 \"ext\/puma_http11\/http11_parser.c\"\n\t{\n\tif ( p == pe )\n\t\tgoto _test_eof;\n\tswitch ( cs )\n\t{\ncase 1:\n\tswitch( (*p) ) {\n\t\tcase 36: goto tr0;\n\t\tcase 95: goto tr0;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto tr0;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto tr0;\n\t} else\n\t\tgoto tr0;\n\tgoto st0;\nst0:\ncs = 0;\n\tgoto _out;\ntr0:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st2;\nst2:\n\tif ( ++p == pe )\n\t\tgoto _test_eof2;\ncase 2:\n#line 118 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st27;\n\t\tcase 95: goto st27;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st27;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st27;\n\t} else\n\t\tgoto st27;\n\tgoto st0;\ntr2:\n#line 50 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_method(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st3;\nst3:\n\tif ( ++p == pe )\n\t\tgoto _test_eof3;\ncase 3:\n#line 143 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 42: goto tr4;\n\t\tcase 43: goto tr5;\n\t\tcase 47: goto tr6;\n\t\tcase 58: goto tr7;\n\t}\n\tif ( (*p) < 65 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 57 )\n\t\t\tgoto tr5;\n\t} else if ( (*p) > 90 ) {\n\t\tif ( 97 <= (*p) && (*p) <= 122 )\n\t\t\tgoto tr5;\n\t} else\n\t\tgoto tr5;\n\tgoto st0;\ntr4:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st4;\nst4:\n\tif ( ++p == pe )\n\t\tgoto _test_eof4;\ncase 4:\n#line 167 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr8;\n\t\tcase 35: goto tr9;\n\t}\n\tgoto st0;\ntr8:\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr31:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n#line 56 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->fragment(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr33:\n#line 56 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->fragment(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr37:\n#line 69 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_path(parser, PTR_TO(mark), LEN(mark,p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr41:\n#line 60 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(query_start, p); }\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\ntr44:\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st5;\nst5:\n\tif ( ++p == pe )\n\t\tgoto _test_eof5;\ncase 5:\n#line 229 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 72 )\n\t\tgoto tr10;\n\tgoto st0;\ntr10:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st6;\nst6:\n\tif ( ++p == pe )\n\t\tgoto _test_eof6;\ncase 6:\n#line 241 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 84 )\n\t\tgoto st7;\n\tgoto st0;\nst7:\n\tif ( ++p == pe )\n\t\tgoto _test_eof7;\ncase 7:\n\tif ( (*p) == 84 )\n\t\tgoto st8;\n\tgoto st0;\nst8:\n\tif ( ++p == pe )\n\t\tgoto _test_eof8;\ncase 8:\n\tif ( (*p) == 80 )\n\t\tgoto st9;\n\tgoto st0;\nst9:\n\tif ( ++p == pe )\n\t\tgoto _test_eof9;\ncase 9:\n\tif ( (*p) == 47 )\n\t\tgoto st10;\n\tgoto st0;\nst10:\n\tif ( ++p == pe )\n\t\tgoto _test_eof10;\ncase 10:\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st11;\n\tgoto st0;\nst11:\n\tif ( ++p == pe )\n\t\tgoto _test_eof11;\ncase 11:\n\tif ( (*p) == 46 )\n\t\tgoto st12;\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st11;\n\tgoto st0;\nst12:\n\tif ( ++p == pe )\n\t\tgoto _test_eof12;\ncase 12:\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st13;\n\tgoto st0;\nst13:\n\tif ( ++p == pe )\n\t\tgoto _test_eof13;\ncase 13:\n\tif ( (*p) == 13 )\n\t\tgoto tr18;\n\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\tgoto st13;\n\tgoto st0;\ntr18:\n#line 65 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->http_version(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st14;\ntr26:\n#line 46 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n#line 47 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st14;\ntr29:\n#line 47 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st14;\nst14:\n\tif ( ++p == pe )\n\t\tgoto _test_eof14;\ncase 14:\n#line 322 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 10 )\n\t\tgoto st15;\n\tgoto st0;\nst15:\n\tif ( ++p == pe )\n\t\tgoto _test_eof15;\ncase 15:\n\tswitch( (*p) ) {\n\t\tcase 13: goto st16;\n\t\tcase 33: goto tr21;\n\t\tcase 124: goto tr21;\n\t\tcase 126: goto tr21;\n\t}\n\tif ( (*p) < 45 ) {\n\t\tif ( (*p) > 39 ) {\n\t\t\tif ( 42 <= (*p) && (*p) <= 43 )\n\t\t\t\tgoto tr21;\n\t\t} else if ( (*p) >= 35 )\n\t\t\tgoto tr21;\n\t} else if ( (*p) > 46 ) {\n\t\tif ( (*p) < 65 ) {\n\t\t\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\t\t\tgoto tr21;\n\t\t} else if ( (*p) > 90 ) {\n\t\t\tif ( 94 <= (*p) && (*p) <= 122 )\n\t\t\t\tgoto tr21;\n\t\t} else\n\t\t\tgoto tr21;\n\t} else\n\t\tgoto tr21;\n\tgoto st0;\nst16:\n\tif ( ++p == pe )\n\t\tgoto _test_eof16;\ncase 16:\n\tif ( (*p) == 10 )\n\t\tgoto tr22;\n\tgoto st0;\ntr22:\n#line 73 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->body_start = p - buffer + 1;\n    parser->header_done(parser, p + 1, pe - p - 1);\n    {p++; cs = 46; goto _out;}\n  }\n\tgoto st46;\nst46:\n\tif ( ++p == pe )\n\t\tgoto _test_eof46;\ncase 46:\n#line 373 \"ext\/puma_http11\/http11_parser.c\"\n\tgoto st0;\ntr21:\n#line 40 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(field_start, p); }\n#line 41 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ snake_upcase_char((char *)p); }\n\tgoto st17;\ntr23:\n#line 41 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ snake_upcase_char((char *)p); }\n\tgoto st17;\nst17:\n\tif ( ++p == pe )\n\t\tgoto _test_eof17;\ncase 17:\n#line 389 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 33: goto tr23;\n\t\tcase 58: goto tr24;\n\t\tcase 124: goto tr23;\n\t\tcase 126: goto tr23;\n\t}\n\tif ( (*p) < 45 ) {\n\t\tif ( (*p) > 39 ) {\n\t\t\tif ( 42 <= (*p) && (*p) <= 43 )\n\t\t\t\tgoto tr23;\n\t\t} else if ( (*p) >= 35 )\n\t\t\tgoto tr23;\n\t} else if ( (*p) > 46 ) {\n\t\tif ( (*p) < 65 ) {\n\t\t\tif ( 48 <= (*p) && (*p) <= 57 )\n\t\t\t\tgoto tr23;\n\t\t} else if ( (*p) > 90 ) {\n\t\t\tif ( 94 <= (*p) && (*p) <= 122 )\n\t\t\t\tgoto tr23;\n\t\t} else\n\t\t\tgoto tr23;\n\t} else\n\t\tgoto tr23;\n\tgoto st0;\ntr24:\n#line 42 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->field_len = LEN(field_start, p);\n  }\n\tgoto st18;\ntr27:\n#line 46 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st18;\nst18:\n\tif ( ++p == pe )\n\t\tgoto _test_eof18;\ncase 18:\n#line 428 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 13: goto tr26;\n\t\tcase 32: goto tr27;\n\t}\n\tgoto tr25;\ntr25:\n#line 46 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st19;\nst19:\n\tif ( ++p == pe )\n\t\tgoto _test_eof19;\ncase 19:\n#line 442 \"ext\/puma_http11\/http11_parser.c\"\n\tif ( (*p) == 13 )\n\t\tgoto tr29;\n\tgoto st19;\ntr9:\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\ntr38:\n#line 69 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_path(parser, PTR_TO(mark), LEN(mark,p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\ntr42:\n#line 60 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(query_start, p); }\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\ntr45:\n#line 61 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));\n  }\n#line 53 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));\n  }\n\tgoto st20;\nst20:\n\tif ( ++p == pe )\n\t\tgoto _test_eof20;\ncase 20:\n#line 488 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr31;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( (*p) > 31 ) {\n\t\tif ( 34 <= (*p) && (*p) <= 35 )\n\t\t\tgoto st0;\n\t} else if ( (*p) >= 0 )\n\t\tgoto st0;\n\tgoto tr30;\ntr30:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st21;\nst21:\n\tif ( ++p == pe )\n\t\tgoto _test_eof21;\ncase 21:\n#line 509 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr33;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( (*p) > 31 ) {\n\t\tif ( 34 <= (*p) && (*p) <= 35 )\n\t\t\tgoto st0;\n\t} else if ( (*p) >= 0 )\n\t\tgoto st0;\n\tgoto st21;\ntr5:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st22;\nst22:\n\tif ( ++p == pe )\n\t\tgoto _test_eof22;\ncase 22:\n#line 530 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 43: goto st22;\n\t\tcase 58: goto st23;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st22;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( (*p) > 90 ) {\n\t\t\tif ( 97 <= (*p) && (*p) <= 122 )\n\t\t\t\tgoto st22;\n\t\t} else if ( (*p) >= 65 )\n\t\t\tgoto st22;\n\t} else\n\t\tgoto st22;\n\tgoto st0;\ntr7:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st23;\nst23:\n\tif ( ++p == pe )\n\t\tgoto _test_eof23;\ncase 23:\n#line 555 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr8;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr9;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto st23;\ntr6:\n#line 37 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(mark, p); }\n\tgoto st24;\nst24:\n\tif ( ++p == pe )\n\t\tgoto _test_eof24;\ncase 24:\n#line 575 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr37;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr38;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 63: goto tr39;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto st24;\ntr39:\n#line 69 \"ext\/puma_http11\/http11_parser.rl\"\n\t{\n    parser->request_path(parser, PTR_TO(mark), LEN(mark,p));\n  }\n\tgoto st25;\nst25:\n\tif ( ++p == pe )\n\t\tgoto _test_eof25;\ncase 25:\n#line 598 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr41;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr42;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto tr40;\ntr40:\n#line 60 \"ext\/puma_http11\/http11_parser.rl\"\n\t{ MARK(query_start, p); }\n\tgoto st26;\nst26:\n\tif ( ++p == pe )\n\t\tgoto _test_eof26;\ncase 26:\n#line 618 \"ext\/puma_http11\/http11_parser.c\"\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr44;\n\t\tcase 34: goto st0;\n\t\tcase 35: goto tr45;\n\t\tcase 60: goto st0;\n\t\tcase 62: goto st0;\n\t\tcase 127: goto st0;\n\t}\n\tif ( 0 <= (*p) && (*p) <= 31 )\n\t\tgoto st0;\n\tgoto st26;\nst27:\n\tif ( ++p == pe )\n\t\tgoto _test_eof27;\ncase 27:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st28;\n\t\tcase 95: goto st28;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st28;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st28;\n\t} else\n\t\tgoto st28;\n\tgoto st0;\nst28:\n\tif ( ++p == pe )\n\t\tgoto _test_eof28;\ncase 28:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st29;\n\t\tcase 95: goto st29;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st29;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st29;\n\t} else\n\t\tgoto st29;\n\tgoto st0;\nst29:\n\tif ( ++p == pe )\n\t\tgoto _test_eof29;\ncase 29:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st30;\n\t\tcase 95: goto st30;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st30;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st30;\n\t} else\n\t\tgoto st30;\n\tgoto st0;\nst30:\n\tif ( ++p == pe )\n\t\tgoto _test_eof30;\ncase 30:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st31;\n\t\tcase 95: goto st31;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st31;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st31;\n\t} else\n\t\tgoto st31;\n\tgoto st0;\nst31:\n\tif ( ++p == pe )\n\t\tgoto _test_eof31;\ncase 31:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st32;\n\t\tcase 95: goto st32;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st32;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st32;\n\t} else\n\t\tgoto st32;\n\tgoto st0;\nst32:\n\tif ( ++p == pe )\n\t\tgoto _test_eof32;\ncase 32:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st33;\n\t\tcase 95: goto st33;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st33;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st33;\n\t} else\n\t\tgoto st33;\n\tgoto st0;\nst33:\n\tif ( ++p == pe )\n\t\tgoto _test_eof33;\ncase 33:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st34;\n\t\tcase 95: goto st34;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st34;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st34;\n\t} else\n\t\tgoto st34;\n\tgoto st0;\nst34:\n\tif ( ++p == pe )\n\t\tgoto _test_eof34;\ncase 34:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st35;\n\t\tcase 95: goto st35;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st35;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st35;\n\t} else\n\t\tgoto st35;\n\tgoto st0;\nst35:\n\tif ( ++p == pe )\n\t\tgoto _test_eof35;\ncase 35:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st36;\n\t\tcase 95: goto st36;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st36;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st36;\n\t} else\n\t\tgoto st36;\n\tgoto st0;\nst36:\n\tif ( ++p == pe )\n\t\tgoto _test_eof36;\ncase 36:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st37;\n\t\tcase 95: goto st37;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st37;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st37;\n\t} else\n\t\tgoto st37;\n\tgoto st0;\nst37:\n\tif ( ++p == pe )\n\t\tgoto _test_eof37;\ncase 37:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st38;\n\t\tcase 95: goto st38;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st38;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st38;\n\t} else\n\t\tgoto st38;\n\tgoto st0;\nst38:\n\tif ( ++p == pe )\n\t\tgoto _test_eof38;\ncase 38:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st39;\n\t\tcase 95: goto st39;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st39;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st39;\n\t} else\n\t\tgoto st39;\n\tgoto st0;\nst39:\n\tif ( ++p == pe )\n\t\tgoto _test_eof39;\ncase 39:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st40;\n\t\tcase 95: goto st40;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st40;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st40;\n\t} else\n\t\tgoto st40;\n\tgoto st0;\nst40:\n\tif ( ++p == pe )\n\t\tgoto _test_eof40;\ncase 40:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st41;\n\t\tcase 95: goto st41;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st41;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st41;\n\t} else\n\t\tgoto st41;\n\tgoto st0;\nst41:\n\tif ( ++p == pe )\n\t\tgoto _test_eof41;\ncase 41:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st42;\n\t\tcase 95: goto st42;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st42;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st42;\n\t} else\n\t\tgoto st42;\n\tgoto st0;\nst42:\n\tif ( ++p == pe )\n\t\tgoto _test_eof42;\ncase 42:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st43;\n\t\tcase 95: goto st43;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st43;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st43;\n\t} else\n\t\tgoto st43;\n\tgoto st0;\nst43:\n\tif ( ++p == pe )\n\t\tgoto _test_eof43;\ncase 43:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st44;\n\t\tcase 95: goto st44;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st44;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st44;\n\t} else\n\t\tgoto st44;\n\tgoto st0;\nst44:\n\tif ( ++p == pe )\n\t\tgoto _test_eof44;\ncase 44:\n\tswitch( (*p) ) {\n\t\tcase 32: goto tr2;\n\t\tcase 36: goto st45;\n\t\tcase 95: goto st45;\n\t}\n\tif ( (*p) < 48 ) {\n\t\tif ( 45 <= (*p) && (*p) <= 46 )\n\t\t\tgoto st45;\n\t} else if ( (*p) > 57 ) {\n\t\tif ( 65 <= (*p) && (*p) <= 90 )\n\t\t\tgoto st45;\n\t} else\n\t\tgoto st45;\n\tgoto st0;\nst45:\n\tif ( ++p == pe )\n\t\tgoto _test_eof45;\ncase 45:\n\tif ( (*p) == 32 )\n\t\tgoto tr2;\n\tgoto st0;\n\t}\n\t_test_eof2: cs = 2; goto _test_eof; \n\t_test_eof3: cs = 3; goto _test_eof; \n\t_test_eof4: cs = 4; goto _test_eof; \n\t_test_eof5: cs = 5; goto _test_eof; \n\t_test_eof6: cs = 6; goto _test_eof; \n\t_test_eof7: cs = 7; goto _test_eof; \n\t_test_eof8: cs = 8; goto _test_eof; \n\t_test_eof9: cs = 9; goto _test_eof; \n\t_test_eof10: cs = 10; goto _test_eof; \n\t_test_eof11: cs = 11; goto _test_eof; \n\t_test_eof12: cs = 12; goto _test_eof; \n\t_test_eof13: cs = 13; goto _test_eof; \n\t_test_eof14: cs = 14; goto _test_eof; \n\t_test_eof15: cs = 15; goto _test_eof; \n\t_test_eof16: cs = 16; goto _test_eof; \n\t_test_eof46: cs = 46; goto _test_eof; \n\t_test_eof17: cs = 17; goto _test_eof; \n\t_test_eof18: cs = 18; goto _test_eof; \n\t_test_eof19: cs = 19; goto _test_eof; \n\t_test_eof20: cs = 20; goto _test_eof; \n\t_test_eof21: cs = 21; goto _test_eof; \n\t_test_eof22: cs = 22; goto _test_eof; \n\t_test_eof23: cs = 23; goto _test_eof; \n\t_test_eof24: cs = 24; goto _test_eof; \n\t_test_eof25: cs = 25; goto _test_eof; \n\t_test_eof26: cs = 26; goto _test_eof; \n\t_test_eof27: cs = 27; goto _test_eof; \n\t_test_eof28: cs = 28; goto _test_eof; \n\t_test_eof29: cs = 29; goto _test_eof; \n\t_test_eof30: cs = 30; goto _test_eof; \n\t_test_eof31: cs = 31; goto _test_eof; \n\t_test_eof32: cs = 32; goto _test_eof; \n\t_test_eof33: cs = 33; goto _test_eof; \n\t_test_eof34: cs = 34; goto _test_eof; \n\t_test_eof35: cs = 35; goto _test_eof; \n\t_test_eof36: cs = 36; goto _test_eof; \n\t_test_eof37: cs = 37; goto _test_eof; \n\t_test_eof38: cs = 38; goto _test_eof; \n\t_test_eof39: cs = 39; goto _test_eof; \n\t_test_eof40: cs = 40; goto _test_eof; \n\t_test_eof41: cs = 41; goto _test_eof; \n\t_test_eof42: cs = 42; goto _test_eof; \n\t_test_eof43: cs = 43; goto _test_eof; \n\t_test_eof44: cs = 44; goto _test_eof; \n\t_test_eof45: cs = 45; goto _test_eof; \n\n\t_test_eof: {}\n\t_out: {}\n\t}\n\n#line 117 \"ext\/puma_http11\/http11_parser.rl\"\n\n  if (!puma_parser_has_error(parser))\n    parser->cs = cs;\n  parser->nread += p - (buffer + off);\n\n  assert(p <= pe && \"buffer overflow after parsing execute\");\n  assert(parser->nread <= len && \"nread longer than length\");\n  assert(parser->body_start <= len && \"body starts after buffer end\");\n  assert(parser->mark < len && \"mark is after buffer end\");\n  assert(parser->field_len <= len && \"field has length longer than whole buffer\");\n  assert(parser->field_start < len && \"field starts after buffer end\");\n\n  return(parser->nread);\n}","target":1,"code_token_length":8436,"total_token_length":8672,"max_tokens_setting":11000}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..0487ca8828e547060cc0ea2e4c70ab3ed255cc7d
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3ec7dc5ea7394fb368aa503799c7d3954a40e80da234918eacccf2bd165e36dd
+size 754016
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_stats.json b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_stats.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb39edd42bb10ba05c3cfa95224172d252ded0ee
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_stats.json
@@ -0,0 +1,47 @@
+{
+  "total": 10000,
+  "processed": 10000,
+  "skipped": 0,
+  "categories": {
+    "under_512": {
+      "count": 6747,
+      "percentage": 67.47,
+      "max_tokens_setting": 512
+    },
+    "512_to_1024": {
+      "count": 2129,
+      "percentage": 21.29,
+      "max_tokens_setting": 1024
+    },
+    "1024_to_2048": {
+      "count": 768,
+      "percentage": 7.68,
+      "max_tokens_setting": 2048
+    },
+    "2048_to_4096": {
+      "count": 241,
+      "percentage": 2.41,
+      "max_tokens_setting": 4096
+    },
+    "4096_to_6144": {
+      "count": 50,
+      "percentage": 0.5,
+      "max_tokens_setting": 6144
+    },
+    "6144_to_8192": {
+      "count": 21,
+      "percentage": 0.21,
+      "max_tokens_setting": 8192
+    },
+    "8192_to_11000": {
+      "count": 24,
+      "percentage": 0.24,
+      "max_tokens_setting": 11000
+    },
+    "11000_to_28000": {
+      "count": 20,
+      "percentage": 0.2,
+      "max_tokens_setting": 28000
+    }
+  }
+}
\ No newline at end of file
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.jsonl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.jsonl
new file mode 100644
index 0000000000000000000000000000000000000000..1c841f756d9803a25116123e6e296424756ed7ee
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.jsonl
@@ -0,0 +1,6747 @@
+{"idx":328907,"func":"R_API ut64 r_bin_java_rti_annotations_attr_calc_size(RBinJavaAttrInfo *attr) {\n\tut64 size = 0;\n\tif (!attr) {\n\t\t\/\/ TODO eprintf allocation fail\n\t\treturn size;\n\t}\n\tsize += (6 + r_bin_java_annotation_array_calc_size (&(attr->info.annotation_array)));\n\treturn size;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":427176,"func":"static void block (LexState *ls) {\n  \/* block -> statlist *\/\n  FuncState *fs = ls->fs;\n  BlockCnt bl;\n  enterblock(fs, &bl, 0);\n  statlist(ls);\n  leaveblock(fs);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":328810,"func":"R_API RBinJavaBootStrapArgument *r_bin_java_bootstrap_method_argument_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 0;\n\tRBinJavaBootStrapArgument *bsm_arg = (RBinJavaBootStrapArgument *) malloc (sizeof (RBinJavaBootStrapArgument));\n\tif (!bsm_arg) {\n\t\t\/\/ TODO eprintf failed to allocate bytes for bootstrap_method.\n\t\treturn bsm_arg;\n\t}\n\tmemset (bsm_arg, 0, sizeof (RBinJavaBootStrapArgument));\n\tbsm_arg->file_offset = buf_offset;\n\tbsm_arg->argument_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tbsm_arg->argument_info_cp_obj = r_bin_java_clone_cp_idx (R_BIN_JAVA_GLOBAL_BIN, bsm_arg->argument_info_idx);\n\tbsm_arg->size = offset;\n\treturn bsm_arg;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":369281,"func":"static void io_buffer_add_list(struct io_ring_ctx *ctx,\n\t\t\t       struct io_buffer_list *bl, unsigned int bgid)\n{\n\tstruct list_head *list;\n\n\tlist = &ctx->io_buffers[hash_32(bgid, IO_BUFFERS_HASH_BITS)];\n\tINIT_LIST_HEAD(&bl->buf_list);\n\tbl->bgid = bgid;\n\tlist_add(&bl->list, list);\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":509577,"func":"int ha_maria::index_read_map(uchar * buf, const uchar * key,\n\t\t\t     key_part_map keypart_map,\n\t\t\t     enum ha_rkey_function find_flag)\n{\n  DBUG_ASSERT(inited == INDEX);\n  register_handler(file);\n  int error= maria_rkey(file, buf, active_index, key, keypart_map, find_flag);\n  return error;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":261896,"func":"njs_decode_utf8_length(const njs_str_t *src, size_t *out_size)\n{\n    njs_unicode_decode_t  ctx;\n\n    njs_utf8_decode_init(&ctx);\n\n    return njs_utf8_stream_length(&ctx, src->start, src->length, 1, 0,\n                                  out_size);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":274875,"func":"TEST(QuantizedComparisonsTest, EqualUInt8Quantized) {\n  const float kMin = -1.f;\n  const float kMax = 128.f;\n  ComparisonOpModel model({TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax},\n                          {TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax},\n                          TensorType_UINT8, BuiltinOperator_EQUAL);\n  model.QuantizeAndPopulate<uint8_t>(model.input1(), {1, 9, 7, 3});\n  model.QuantizeAndPopulate<uint8_t>(model.input2(), {1, 2, 7, 5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(true, false, true, false));\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":242131,"func":"int LuaSettings::create_object(lua_State* L)\n{\n\tNO_MAP_LOCK_REQUIRED;\n\tbool write_allowed = true;\n\tconst char* filename = luaL_checkstring(L, 1);\n\tCHECK_SECURE_PATH_POSSIBLE_WRITE(L, filename, &write_allowed);\n\tLuaSettings* o = new LuaSettings(filename, write_allowed);\n\t*(void **)(lua_newuserdata(L, sizeof(void *))) = o;\n\tluaL_getmetatable(L, className);\n\tlua_setmetatable(L, -2);\n\treturn 1;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":328913,"func":"R_API void U(copy_type_info_to_stack_frame_list)(RList * type_list, RList * sf_list) {\n\tRListIter *iter, *iter_tmp;\n\tRBinJavaVerificationObj *ver_obj, *new_ver_obj;\n\tif (!type_list || !sf_list) {\n\t\treturn;\n\t}\n\tr_list_foreach_safe (type_list, iter, iter_tmp, ver_obj) {\n\t\tnew_ver_obj = (RBinJavaVerificationObj *) malloc (sizeof (RBinJavaVerificationObj));\n\t\t\/\/ FIXME: how to handle failed memory allocation?\n\t\tif (new_ver_obj && ver_obj) {\n\t\t\tmemcpy (new_ver_obj, ver_obj, sizeof (RBinJavaVerificationObj));\n\t\t\tif (!r_list_append (sf_list, (void *) new_ver_obj)) {\n\t\t\t\tR_FREE (new_ver_obj);\n\t\t\t}\n\t\t} else {\n\t\t\tR_FREE (new_ver_obj);\n\t\t}\n\t}\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":445892,"func":"fr_clipboard_get (GtkClipboard     *clipboard,\n\t\t  GtkSelectionData *selection_data,\n\t\t  guint             info,\n\t\t  gpointer          user_data_or_owner)\n{\n\tFrWindow *window = user_data_or_owner;\n\tchar     *data;\n\n\tif (gtk_selection_data_get_target (selection_data) != FR_SPECIAL_URI_LIST)\n\t\treturn;\n\n\tdata = get_selection_data_from_clipboard_data (window, window->priv->copy_data);\n\tif (data != NULL) {\n\t\tgtk_selection_data_set (selection_data,\n\t\t\t\t\tgtk_selection_data_get_target (selection_data),\n\t\t\t\t\t8,\n\t\t\t\t\t(guchar *) data,\n\t\t\t\t\tstrlen (data));\n\t\tg_free (data);\n\t}\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":225009,"func":"PQregisterThreadLock(pgthreadlock_t newhandler)\n{\n\tpgthreadlock_t prev = pg_g_threadlock;\n\n\tif (newhandler)\n\t\tpg_g_threadlock = newhandler;\n\telse\n\t\tpg_g_threadlock = default_threadlock;\n\n\treturn prev;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":225022,"func":"PQhost(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn NULL;\n\n\tif (conn->connhost != NULL)\n\t{\n\t\t\/*\n\t\t * Return the verbatim host value provided by user, or hostaddr in its\n\t\t * lack.\n\t\t *\/\n\t\tif (conn->connhost[conn->whichhost].host != NULL &&\n\t\t\tconn->connhost[conn->whichhost].host[0] != '\\0')\n\t\t\treturn conn->connhost[conn->whichhost].host;\n\t\telse if (conn->connhost[conn->whichhost].hostaddr != NULL &&\n\t\t\t\t conn->connhost[conn->whichhost].hostaddr[0] != '\\0')\n\t\t\treturn conn->connhost[conn->whichhost].hostaddr;\n\t}\n\n\treturn \"\";\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":366283,"func":"static void namespace_unlock(void)\n{\n\tstruct hlist_head head;\n\tstruct hlist_node *p;\n\tstruct mount *m;\n\tLIST_HEAD(list);\n\n\thlist_move_list(&unmounted, &head);\n\tlist_splice_init(&ex_mountpoints, &list);\n\n\tup_write(&namespace_sem);\n\n\tshrink_dentry_list(&list);\n\n\tif (likely(hlist_empty(&head)))\n\t\treturn;\n\n\tsynchronize_rcu_expedited();\n\n\thlist_for_each_entry_safe(m, p, &head, mnt_umount) {\n\t\thlist_del(&m->mnt_umount);\n\t\tmntput(&m->mnt);\n\t}\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":294396,"func":"m_sf_in_day(union DateData *x)\n{\n    return ns_to_day(m_sf(x));\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":379660,"func":"R_API void r_anal_function_delete_all_vars(RAnalFunction *fcn) {\n\tr_return_if_fail (fcn);\n\tif (fcn->vars.v.len > 0) {\n\t\tvoid **it;\n\t\tr_pvector_foreach (&fcn->vars, it) {\n\t\t\tvar_free (*it);\n\t\t}\n\t}\n\tr_pvector_clear (&fcn->vars);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":336627,"func":"uint32_t reds_get_streaming_video(const RedsState *reds)\n{\n    return reds->config->streaming_video;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":459157,"func":"static int tcf_act_get_cookie(struct flow_action_entry *entry,\n\t\t\t      const struct tc_action *act)\n{\n\tstruct tc_cookie *cookie;\n\tint err = 0;\n\n\trcu_read_lock();\n\tcookie = rcu_dereference(act->act_cookie);\n\tif (cookie) {\n\t\tentry->cookie = flow_action_cookie_create(cookie->data,\n\t\t\t\t\t\t\t  cookie->len,\n\t\t\t\t\t\t\t  GFP_ATOMIC);\n\t\tif (!entry->cookie)\n\t\t\terr = -ENOMEM;\n\t}\n\trcu_read_unlock();\n\treturn err;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":427812,"func":"void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu)\n{\n\tstruct svm_cpu_data *sd = per_cpu(svm_data, cpu);\n\tstruct vmcb_save_area *hostsa;\n\n\t\/*\n\t * As an SEV-ES guest, hardware will restore the host state on VMEXIT,\n\t * of which one step is to perform a VMLOAD. Since hardware does not\n\t * perform a VMSAVE on VMRUN, the host savearea must be updated.\n\t *\/\n\tvmsave(__sme_page_pa(sd->save_area));\n\n\t\/* XCR0 is restored on VMEXIT, save the current host value *\/\n\thostsa = (struct vmcb_save_area *)(page_address(sd->save_area) + 0x400);\n\thostsa->xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);\n\n\t\/* PKRU is restored on VMEXIT, save the current host value *\/\n\thostsa->pkru = read_pkru();\n\n\t\/* MSR_IA32_XSS is restored on VMEXIT, save the currnet host value *\/\n\thostsa->xss = host_xss;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":317194,"func":"static int selinux_inode_removexattr(struct user_namespace *mnt_userns,\n\t\t\t\t     struct dentry *dentry, const char *name)\n{\n\tif (strcmp(name, XATTR_NAME_SELINUX)) {\n\t\tint rc = cap_inode_removexattr(mnt_userns, dentry, name);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\t\/* Not an attribute we recognize, so just check the\n\t\t   ordinary setattr permission. *\/\n\t\treturn dentry_has_perm(current_cred(), dentry, FILE__SETATTR);\n\t}\n\n\tif (!selinux_initialized(&selinux_state))\n\t\treturn 0;\n\n\t\/* No one is allowed to remove a SELinux security label.\n\t   You can change the label, but all data must be labeled. *\/\n\treturn -EACCES;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":344244,"func":"static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,\n                         StkId ra) {\n  int nup = p->sizeupvalues;\n  Upvaldesc *uv = p->upvalues;\n  int i;\n  LClosure *ncl = luaF_newLclosure(L, nup);\n  ncl->p = p;\n  setclLvalue2s(L, ra, ncl);  \/* anchor new closure in stack *\/\n  for (i = 0; i < nup; i++) {  \/* fill in its upvalues *\/\n    if (uv[i].instack)  \/* upvalue refers to local variable? *\/\n      ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);\n    else  \/* get upvalue from enclosing function *\/\n      ncl->upvals[i] = encup[uv[i].idx];\n    luaC_objbarrier(L, ncl, ncl->upvals[i]);\n  }\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":459166,"func":"static void tcf_chain_head_change_item(struct tcf_filter_chain_list_item *item,\n\t\t\t\t       struct tcf_proto *tp_head)\n{\n\tif (item->chain_head_change)\n\t\titem->chain_head_change(tp_head, item->chain_head_change_priv);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":225966,"func":"GF_Box *stsz_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleSizeBox, 0);\n\n\t\/\/type is unknown here, can be regular or compact table\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":432328,"func":"RAMBlock *qemu_ram_block_from_host(struct uc_struct *uc, void *ptr,\n                                   bool round_offset, ram_addr_t *offset)\n{\n    RAMBlock *block;\n    uint8_t *host = ptr;\n\n    block = uc->ram_list.mru_block;\n    if (block && block->host && host - block->host < block->max_length) {\n        goto found;\n    }\n\n    RAMBLOCK_FOREACH(block) {\n        \/* This case append when the block is not mapped. *\/\n        if (block->host == NULL) {\n            continue;\n        }\n        if (host - block->host < block->max_length) {\n            goto found;\n        }\n    }\n\n    return NULL;\n\nfound:\n    *offset = (host - block->host);\n    if (round_offset) {\n        *offset &= TARGET_PAGE_MASK;\n    }\n    return block;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":453020,"func":"static void nft_dup_netdev_eval(const struct nft_expr *expr,\n\t\t\t\tstruct nft_regs *regs,\n\t\t\t\tconst struct nft_pktinfo *pkt)\n{\n\tstruct nft_dup_netdev *priv = nft_expr_priv(expr);\n\tint oif = regs->data[priv->sreg_dev];\n\n\tnf_dup_netdev_egress(pkt, oif);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":234854,"func":"void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)\n{\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs;\n\tstruct btrfs_device *device;\n\n\tfs_devices->fs_info = fs_info;\n\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tlist_for_each_entry(device, &fs_devices->devices, dev_list)\n\t\tdevice->fs_info = fs_info;\n\n\tlist_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) {\n\t\tlist_for_each_entry(device, &seed_devs->devices, dev_list)\n\t\t\tdevice->fs_info = fs_info;\n\n\t\tseed_devs->fs_info = fs_info;\n\t}\n\tmutex_unlock(&fs_devices->device_list_mutex);\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":195233,"func":"  Status SetUnknownShape(const NodeDef* node, int output_port) {\n    shape_inference::ShapeHandle shape =\n        GetUnknownOutputShape(node, output_port);\n    InferenceContext* ctx = GetContext(node);\n    if (ctx == nullptr) {\n      return errors::InvalidArgument(\"Missing context\");\n    }\n    ctx->set_output(output_port, shape);\n    return Status::OK();\n  }","target":1,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":301348,"func":"static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,\n\t\t\t\tint leasetype)\n{\n\tint result = -1;\n\n\tSTART_PROFILE(syscall_linux_setlease);\n\n#ifdef HAVE_KERNEL_OPLOCKS_LINUX\n\tresult = linux_setlease(fsp->fh->fd, leasetype);\n#else\n\terrno = ENOSYS;\n#endif\n\tEND_PROFILE(syscall_linux_setlease);\n\treturn result;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":387837,"func":"static void clear_all_breakpoints(Method* m) {\n  m->clear_all_breakpoints();\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":312396,"func":"qf_setup_state(\n\tqfstate_T\t*pstate,\n\tchar_u\t\t*enc,\n\tchar_u\t\t*efile,\n\ttypval_T\t*tv,\n\tbuf_T\t\t*buf,\n\tlinenr_T\tlnumfirst,\n\tlinenr_T\tlnumlast)\n{\n    pstate->vc.vc_type = CONV_NONE;\n    if (enc != NULL && *enc != NUL)\n\tconvert_setup(&pstate->vc, enc, p_enc);\n\n    if (efile != NULL && (pstate->fd = mch_fopen((char *)efile, \"r\")) == NULL)\n    {\n\tsemsg(_(e_cant_open_errorfile_str), efile);\n\treturn FAIL;\n    }\n\n    if (tv != NULL)\n    {\n\tif (tv->v_type == VAR_STRING)\n\t    pstate->p_str = tv->vval.v_string;\n\telse if (tv->v_type == VAR_LIST)\n\t    pstate->p_li = tv->vval.v_list->lv_first;\n\tpstate->tv = tv;\n    }\n    pstate->buf = buf;\n    pstate->buflnum = lnumfirst;\n    pstate->lnumlast = lnumlast;\n\n    return OK;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":317031,"func":"static void selinux_inode_free_security(struct inode *inode)\n{\n\tinode_free_security(inode);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":463077,"func":"static uint64_t sungem_mmio_txdma_read(void *opaque, hwaddr addr, unsigned size)\n{\n    SunGEMState *s = opaque;\n    uint32_t val;\n\n    if (!(addr < 0x38) && !(addr >= 0x100 && addr <= 0x118)) {\n        qemu_log_mask(LOG_GUEST_ERROR,\n                      \"Read from unknown TXDMA register 0x%\"HWADDR_PRIx\"\\n\",\n                      addr);\n        return 0;\n    }\n\n    val = s->txdmaregs[addr >> 2];\n\n    trace_sungem_mmio_txdma_read(addr, val);\n\n    return val;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":369365,"func":"static void io_prep_async_work(struct io_kiocb *req)\n{\n\tconst struct io_op_def *def = &io_op_defs[req->opcode];\n\tstruct io_ring_ctx *ctx = req->ctx;\n\n\tif (!(req->flags & REQ_F_CREDS)) {\n\t\treq->flags |= REQ_F_CREDS;\n\t\treq->creds = get_current_cred();\n\t}\n\n\treq->work.list.next = NULL;\n\treq->work.flags = 0;\n\tif (req->flags & REQ_F_FORCE_ASYNC)\n\t\treq->work.flags |= IO_WQ_WORK_CONCURRENT;\n\n\tif (req->flags & REQ_F_ISREG) {\n\t\tif (def->hash_reg_file || (ctx->flags & IORING_SETUP_IOPOLL))\n\t\t\tio_wq_hash_work(&req->work, file_inode(req->file));\n\t} else if (!req->file || !S_ISBLK(file_inode(req->file)->i_mode)) {\n\t\tif (def->unbound_nonreg_file)\n\t\t\treq->work.flags |= IO_WQ_WORK_UNBOUND;\n\t}\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":218807,"func":"static size_t WritePascalString(Image *image,const char *value,size_t padding)\n{\n  size_t\n    count,\n    length;\n\n  ssize_t\n    i;\n\n  \/*\n    Max length is 255.\n  *\/\n  count=0;\n  length=(strlen(value) > 255UL ) ? 255UL : strlen(value);\n  if (length ==  0)\n    count+=WriteBlobByte(image,0);\n  else\n    {\n      count+=WriteBlobByte(image,(unsigned char) length);\n      count+=WriteBlob(image,length,(const unsigned char *) value);\n    }\n  length++;\n  if ((length % padding) == 0)\n    return(count);\n  for (i=0; i < (ssize_t) (padding-(length % padding)); i++)\n    count+=WriteBlobByte(image,0);\n  return(count);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":244050,"func":"void mvcg_box_del(GF_Box *s)\n{\n\tGF_MultiviewGroupBox *ptr = (GF_MultiviewGroupBox *) s;\n\tif (ptr->entries) gf_free(ptr->entries);\n\tgf_free(ptr);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":376340,"func":"next_token (const gchar *in,\n            gchar **token)\n{\n\tconst gchar *start, *inptr = in;\n\n\twhile (*inptr == ' ')\n\t\tinptr++;\n\n\tif (*inptr == '\\0' || *inptr == '\\n') {\n\t\tif (token)\n\t\t\t*token = NULL;\n\t\treturn inptr;\n\t}\n\n\tstart = inptr;\n\twhile (*inptr && *inptr != ' ' && *inptr != '\\n')\n\t\tinptr++;\n\n\tif (token)\n\t\t*token = g_strndup (start, inptr - start);\n\n\treturn inptr;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":380945,"func":"ins_down(\n    int\t\tstartcol)\t\/\/ when TRUE move to Insstart.col\n{\n    pos_T\ttpos;\n    linenr_T\told_topline = curwin->w_topline;\n#ifdef FEAT_DIFF\n    int\t\told_topfill = curwin->w_topfill;\n#endif\n\n    undisplay_dollar();\n    tpos = curwin->w_cursor;\n    if (cursor_down(1L, TRUE) == OK)\n    {\n\tif (startcol)\n\t    coladvance(getvcol_nolist(&Insstart));\n\tif (old_topline != curwin->w_topline\n#ifdef FEAT_DIFF\n\t\t|| old_topfill != curwin->w_topfill\n#endif\n\t\t)\n\t    redraw_later(VALID);\n\tstart_arrow(&tpos);\n\tcan_cindent = TRUE;\n    }\n    else\n\tvim_beep(BO_CRSR);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":234232,"func":"init_dwarf_regnames_aarch64 (void)\n{\n  dwarf_regnames = dwarf_regnames_aarch64;\n  dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64);\n  dwarf_regnames_lookup_func = regname_internal_by_table_only;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":442586,"func":"static void init_meminfo(RedMemSlotInfo *mem_info)\n{\n    memslot_info_init(mem_info, 1 \/* groups *\/, 1 \/* slots *\/, 1, 1, 0);\n    memslot_info_add_slot(mem_info, 0, 0, 0 \/* delta *\/, 0 \/* start *\/, ~0ul \/* end *\/, 0 \/* generation *\/);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":261251,"func":"int MqttClient_PropsFree(MqttProp *head)\n{\n    return MqttProps_Free(head);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":230383,"func":"PJ_DEF(pj_xml_node*) pj_xml_find_node_rec(const pj_xml_node *parent, \n\t\t\t\t\t  const pj_str_t *name)\n{\n    const pj_xml_node *node = parent->node_head.next;\n\n    PJ_CHECK_STACK();\n\n    while (node != (void*)&parent->node_head) {\n\tpj_xml_node *found;\n\tif (pj_stricmp(&node->name, name) == 0)\n\t    return (pj_xml_node*)node;\n\tfound = pj_xml_find_node_rec(node, name);\n\tif (found)\n\t    return (pj_xml_node*)found;\n\tnode = node->next;\n    }\n    return NULL;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":369201,"func":"static inline void io_req_set_rsrc_node(struct io_kiocb *req,\n\t\t\t\t\tstruct io_ring_ctx *ctx,\n\t\t\t\t\tunsigned int issue_flags)\n{\n\tif (!req->fixed_rsrc_refs) {\n\t\treq->fixed_rsrc_refs = &ctx->rsrc_node->refs;\n\n\t\tif (!(issue_flags & IO_URING_F_UNLOCKED)) {\n\t\t\tlockdep_assert_held(&ctx->uring_lock);\n\t\t\tctx->rsrc_cached_refs--;\n\t\t\tif (unlikely(ctx->rsrc_cached_refs < 0))\n\t\t\t\tio_rsrc_refs_refill(ctx);\n\t\t} else {\n\t\t\tpercpu_ref_get(req->fixed_rsrc_refs);\n\t\t}\n\t}\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":338132,"func":"void WasmBinaryBuilder::visitLocalGet(LocalGet* curr) {\n  BYN_TRACE(\"zz node: LocalGet \" << pos << std::endl);\n  requireFunctionContext(\"local.get\");\n  curr->index = getAbsoluteLocalIndex(getU32LEB());\n  if (curr->index >= currFunction->getNumLocals()) {\n    throwError(\"bad local.get index\");\n  }\n  curr->type = currFunction->getLocalType(curr->index);\n  curr->finalize();\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":293777,"func":"static RKextIndex *r_kext_index_new(RList *kexts) {\n\tif (!kexts) {\n\t\treturn NULL;\n\t}\n\n\tint length = r_list_length (kexts);\n\tif (!length) {\n\t\treturn NULL;\n\t}\n\n\tRKextIndex *index = R_NEW0 (RKextIndex);\n\tif (!index) {\n\t\treturn NULL;\n\t}\n\n\tindex->entries = malloc (length *sizeof(RKext*));\n\tif (!index->entries) {\n\t\tR_FREE (index);\n\t\treturn NULL;\n\t}\n\n\tRListIter *iter;\n\tRKext *kext;\n\tint i = 0;\n\tr_list_foreach (kexts, iter, kext) {\n\t\tindex->entries[i++] = kext;\n\t}\n\tindex->length = i;\n\n\treturn index;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":409472,"func":"term_cursor_color(char_u *color)\n{\n    if (*T_CSC != NUL)\n    {\n\tout_str(T_CSC);\t\t\/\/ set cursor color start\n\tout_str_nf(color);\n\tout_str(T_CEC);\t\t\/\/ set cursor color end\n\tout_flush();\n    }\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":380953,"func":"ins_up(\n    int\t\tstartcol)\t\/\/ when TRUE move to Insstart.col\n{\n    pos_T\ttpos;\n    linenr_T\told_topline = curwin->w_topline;\n#ifdef FEAT_DIFF\n    int\t\told_topfill = curwin->w_topfill;\n#endif\n\n    undisplay_dollar();\n    tpos = curwin->w_cursor;\n    if (cursor_up(1L, TRUE) == OK)\n    {\n\tif (startcol)\n\t    coladvance(getvcol_nolist(&Insstart));\n\tif (old_topline != curwin->w_topline\n#ifdef FEAT_DIFF\n\t\t|| old_topfill != curwin->w_topfill\n#endif\n\t\t)\n\t    redraw_later(VALID);\n\tstart_arrow(&tpos);\n\tcan_cindent = TRUE;\n    }\n    else\n\tvim_beep(BO_CRSR);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":349530,"func":"static int virtbt_setup_zephyr(struct hci_dev *hdev)\n{\n\tstruct sk_buff *skb;\n\n\t\/* Read Build Information *\/\n\tskb = __hci_cmd_sync(hdev, 0xfc08, 0, NULL, HCI_INIT_TIMEOUT);\n\tif (IS_ERR(skb))\n\t\treturn PTR_ERR(skb);\n\n\tbt_dev_info(hdev, \"%s\", (char *)(skb->data + 1));\n\n\thci_set_fw_info(hdev, \"%s\", skb->data + 1);\n\n\tkfree_skb(skb);\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":369239,"func":"\nstatic void io_wait_rsrc_data(struct io_rsrc_data *data)\n{\n\tif (data && !atomic_dec_and_test(&data->refs))\n\t\twait_for_completion(&data->done);","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":336151,"func":"static int ip6gre_tap_init(struct net_device *dev)\n{\n\tstruct ip6_tnl *tunnel;\n\tint ret;\n\n\tret = ip6gre_tunnel_init_common(dev);\n\tif (ret)\n\t\treturn ret;\n\n\tdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;\n\n\ttunnel = netdev_priv(dev);\n\n\tip6gre_tnl_link_config(tunnel, 1);\n\n\treturn 0;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":409456,"func":"init_term_props(int all)\n{\n    int i;\n\n    term_props[TPR_CURSOR_STYLE].tpr_name = \"cursor_style\";\n    term_props[TPR_CURSOR_STYLE].tpr_set_by_termresponse = FALSE;\n    term_props[TPR_CURSOR_BLINK].tpr_name = \"cursor_blink_mode\";\n    term_props[TPR_CURSOR_BLINK].tpr_set_by_termresponse = FALSE;\n    term_props[TPR_UNDERLINE_RGB].tpr_name = \"underline_rgb\";\n    term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE;\n    term_props[TPR_MOUSE].tpr_name = \"mouse\";\n    term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE;\n\n    for (i = 0; i < TPR_COUNT; ++i)\n\tif (all || term_props[i].tpr_set_by_termresponse)\n\t    term_props[i].tpr_status = TPR_UNKNOWN;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":247560,"func":"  TestUtilOptions& setExpectedSha256Digest(const std::string& expected_sha256_digest) {\n    expected_sha256_digest_ = expected_sha256_digest;\n    return *this;\n  }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":417070,"func":"void PlayerGeneric::restart(mp_uint32 startPosition\/* = 0*\/, mp_uint32 startRow\/* = 0*\/, bool resetMixer\/* = true*\/, const mp_ubyte* customPanningTable\/* = NULL*\/, bool playOneRowOnly\/* = false*\/)\n{\n\tif (player)\n\t\tplayer->restart(startPosition, startRow, resetMixer, customPanningTable, playOneRowOnly);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":313733,"func":"nv_regname(cmdarg_T *cap)\n{\n    if (checkclearop(cap->oap))\n\treturn;\n#ifdef FEAT_EVAL\n    if (cap->nchar == '=')\n\tcap->nchar = get_expr_register();\n#endif\n    if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE))\n    {\n\tcap->oap->regname = cap->nchar;\n\tcap->opcount = cap->count0;\t\/\/ remember count before '\"'\n#ifdef FEAT_EVAL\n\tset_reg_var(cap->oap->regname);\n#endif\n    }\n    else\n\tclearopbeep(cap->oap);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":218995,"func":"bool PackedValuesNotEqual(float a, float b) {\n  return reinterpret_cast<int32_t&>(a) != reinterpret_cast<int32_t&>(b);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":424968,"func":"static ssize_t iwl_dbgfs_csr_write(struct file *file,\n\t\t\t\t   const char __user *user_buf,\n\t\t\t\t   size_t count, loff_t *ppos)\n{\n\tstruct iwl_trans *trans = file->private_data;\n\n\tiwl_pcie_dump_csr(trans);\n\n\treturn count;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":521497,"func":"ZipFile::ZipFile (InputStream* stream, bool deleteStreamWhenDestroyed)\r\n   : inputStream (stream)\r\n{\r\n    if (deleteStreamWhenDestroyed)\r\n        streamToDelete.reset (inputStream);\r\n\r\n    init();\r\n}\r","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":275491,"func":"njs_vm_prop_name(njs_vm_t *vm, njs_object_prop_t *prop, njs_str_t *dst)\n{\n    if (njs_slow_path(!njs_is_string(&prop->name))) {\n        njs_type_error(vm, \"property name is not a string\");\n        return NJS_ERROR;\n    }\n\n    njs_string_get(&prop->name, dst);\n\n    return NJS_OK;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":386576,"func":"void DL_Dxf::writeCircle(DL_WriterA& dw,\n                         const DL_CircleData& data,\n                         const DL_Attributes& attrib) {\n    dw.entity(\"CIRCLE\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbCircle\");\n    }\n    dw.coord(10, data.cx, data.cy, data.cz);\n    dw.dxfReal(40, data.radius);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":261761,"func":"void RtmpProtocol::startClientSession(const function<void()> &func) {\n    \/\/\u53d1\u9001 C0C1\n    char handshake_head = HANDSHAKE_PLAINTEXT;\n    onSendRawData(obtainBuffer(&handshake_head, 1));\n    RtmpHandshake c1(0);\n    c1.create_complex_c0c1();\n    onSendRawData(obtainBuffer((char *) (&c1), sizeof(c1)));\n    _next_step_func = [this, func](const char *data, size_t len) {\n        \/\/\u7b49\u5f85 S0+S1+S2\n        return handle_S0S1S2(data, len, func);\n    };\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":508848,"func":"void Lex_input_stream::body_utf8_start(THD *thd, const char *begin_ptr)\n{\n  DBUG_ASSERT(begin_ptr);\n  DBUG_ASSERT(m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length);\n\n  uint body_utf8_length= get_body_utf8_maximum_length(thd);\n\n  m_body_utf8= (char *) thd->alloc(body_utf8_length + 1);\n  m_body_utf8_ptr= m_body_utf8;\n  *m_body_utf8_ptr= 0;\n\n  m_cpp_utf8_processed_ptr= begin_ptr;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":326114,"func":"regstack_pop(char_u **scan)\n{\n    regitem_T\t*rp;\n\n    rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;\n    *scan = rp->rs_scan;\n\n    regstack.ga_len -= sizeof(regitem_T);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":441804,"func":"SProcXkbGetControls(ClientPtr client)\n{\n    REQUEST(xkbGetControlsReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbGetControlsReq);\n    swaps(&stuff->deviceSpec);\n    return ProcXkbGetControls(client);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":281090,"func":"static unsigned long xfrm_new_hash_mask(unsigned int old_hmask)\n{\n\treturn ((old_hmask + 1) << 1) - 1;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":442567,"func":"void memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id)\n{\n    spice_return_if_fail(info->num_memslots_groups > slot_group_id);\n    spice_return_if_fail(info->num_memslots > slot_id);\n\n    info->mem_slots[slot_group_id][slot_id].virt_start_addr = 0;\n    info->mem_slots[slot_group_id][slot_id].virt_end_addr = 0;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":294687,"func":"c_valid_julian_p(int y, int m, int d, int *rm, int *rd)\n{\n    int last;\n\n    if (m < 0)\n\tm += 13;\n    if (m < 1 || m > 12)\n\treturn 0;\n    last = c_julian_last_day_of_month(y, m);\n    if (d < 0)\n\td = last + d + 1;\n    if (d < 1 || d > last)\n\treturn 0;\n    *rm = m;\n    *rd = d;\n    return 1;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":326590,"func":"archive_write_disk_set_user_lookup(struct archive *_a,\n    void *private_data,\n    int64_t (*lookup_uid)(void *private, const char *uname, int64_t uid),\n    void (*cleanup_uid)(void *private))\n{\n\tstruct archive_write_disk *a = (struct archive_write_disk *)_a;\n\tarchive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,\n\t    ARCHIVE_STATE_ANY, \"archive_write_disk_set_user_lookup\");\n\n\tif (a->cleanup_uid != NULL && a->lookup_uid_data != NULL)\n\t\t(a->cleanup_uid)(a->lookup_uid_data);\n\n\ta->lookup_uid = lookup_uid;\n\ta->cleanup_uid = cleanup_uid;\n\ta->lookup_uid_data = private_data;\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":236134,"func":"GF_Err tsel_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_TrackSelectionBox *ptr = (GF_TrackSelectionBox *) s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs,ptr->switchGroup);\n\n\tfor (i = 0; i < ptr->attributeListCount; i++ ) {\n\t\tgf_bs_write_u32(bs, ptr->attributeList[i]);\n\t}\n\n\treturn GF_OK;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":458919,"func":"find_start_rawstring(int ind_maxcomment)\t\/\/ XXX\n{\n    pos_T\t*pos;\n    char_u\t*line;\n    char_u\t*p;\n    int\t\tcur_maxcomment = ind_maxcomment;\n\n    for (;;)\n    {\n\tpos = findmatchlimit(NULL, 'R', FM_BACKWARD, cur_maxcomment);\n\tif (pos == NULL)\n\t    break;\n\n\t\/\/ Check if the raw string start we found is inside a string.\n\t\/\/ If it is then restrict the search to below this line and try again.\n\tline = ml_get(pos->lnum);\n\tfor (p = line; *p && (colnr_T)(p - line) < pos->col; ++p)\n\t    p = skip_string(p);\n\tif ((colnr_T)(p - line) <= pos->col)\n\t    break;\n\tcur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1;\n\tif (cur_maxcomment <= 0)\n\t{\n\t    pos = NULL;\n\t    break;\n\t}\n    }\n    return pos;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":413593,"func":"static int __addrs_cmp(void *_a, void *_b) {\n\tut64 a = r_num_get (NULL, _a);\n\tut64 b = r_num_get (NULL, _b);\n\tif (a > b) {\n\t\treturn 1;\n\t}\n\tif (a < b) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":359394,"func":"community_list_show (struct vty *vty, struct community_list *list)\n{\n  struct community_entry *entry;\n\n  for (entry = list->head; entry; entry = entry->next)\n    {\n      if (entry == list->head)\n\t{\n\t  if (all_digit (list->name))\n\t    vty_out (vty, \"Community %s list %s%s\",\n\t\t     entry->style == COMMUNITY_LIST_STANDARD ?\n\t\t     \"standard\" : \"(expanded) access\",\n\t\t     list->name, VTY_NEWLINE);\n\t  else\n\t    vty_out (vty, \"Named Community %s list %s%s\",\n\t\t     entry->style == COMMUNITY_LIST_STANDARD ?\n\t\t     \"standard\" : \"expanded\",\n\t\t     list->name, VTY_NEWLINE);\n\t}\n      if (entry->any)\n\tvty_out (vty, \"    %s%s\",\n\t\t community_direct_str (entry->direct), VTY_NEWLINE);\n      else\n\tvty_out (vty, \"    %s %s%s\",\n\t\t community_direct_str (entry->direct),\n\t\t entry->style == COMMUNITY_LIST_STANDARD\n\t\t ? community_str (entry->u.com) : entry->config,\n\t\t VTY_NEWLINE);\n    }\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":413594,"func":"static char *get_title(ut64 addr) {\n\treturn r_str_newf (\"0x%\"PFMT64x, addr);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":368800,"func":"gs_setdevice(gs_gstate * pgs, gx_device * dev)\n{\n    int code = gs_setdevice_no_erase(pgs, dev);\n\n    if (code == 1)\n        code = gs_erasepage(pgs);\n    return code;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":313853,"func":"set_vcount_ca(cmdarg_T *cap, int *set_prevcount)\n{\n    long count = cap->count0;\n\n    \/\/ multiply with cap->opcount the same way as above\n    if (cap->opcount != 0)\n\tcount = cap->opcount * (count == 0 ? 1 : count);\n    set_vcount(count, count == 0 ? 1 : count, *set_prevcount);\n    *set_prevcount = FALSE;  \/\/ only set v:prevcount once\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":231707,"func":"  void triggerCryptoEvent() {\n    onCryptoEventAvailable();\n  }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":291815,"func":"static void fail_all_outstanding_reqs(struct rtrs_clt_path *clt_path)\n{\n\tstruct rtrs_clt_sess *clt = clt_path->clt;\n\tstruct rtrs_clt_io_req *req;\n\tint i, err;\n\n\tif (!clt_path->reqs)\n\t\treturn;\n\tfor (i = 0; i < clt_path->queue_depth; ++i) {\n\t\treq = &clt_path->reqs[i];\n\t\tif (!req->in_use)\n\t\t\tcontinue;\n\n\t\t\/*\n\t\t * Safely (without notification) complete failed request.\n\t\t * After completion this request is still useble and can\n\t\t * be failovered to another path.\n\t\t *\/\n\t\tcomplete_rdma_req(req, -ECONNABORTED, false, true);\n\n\t\terr = rtrs_clt_failover_req(clt, req);\n\t\tif (err)\n\t\t\t\/* Failover failed, notify anyway *\/\n\t\t\treq->conf(req->priv, err);\n\t}\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":90829,"func":"  StorageType type() const { return type_; }\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":317189,"func":"static int selinux_add_mnt_opt(const char *option, const char *val, int len,\n\t\t\t       void **mnt_opts)\n{\n\tint token = Opt_error;\n\tint rc, i;\n\n\tfor (i = 0; i < ARRAY_SIZE(tokens); i++) {\n\t\tif (strcmp(option, tokens[i].name) == 0) {\n\t\t\ttoken = tokens[i].opt;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (token == Opt_error)\n\t\treturn -EINVAL;\n\n\tif (token != Opt_seclabel) {\n\t\tval = kmemdup_nul(val, len, GFP_KERNEL);\n\t\tif (!val) {\n\t\t\trc = -ENOMEM;\n\t\t\tgoto free_opt;\n\t\t}\n\t}\n\trc = selinux_add_opt(token, val, mnt_opts);\n\tif (unlikely(rc)) {\n\t\tkfree(val);\n\t\tgoto free_opt;\n\t}\n\treturn rc;\n\nfree_opt:\n\tif (*mnt_opts) {\n\t\tselinux_free_mnt_opts(*mnt_opts);\n\t\t*mnt_opts = NULL;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":508791,"func":"void lex_unlock_plugins(LEX *lex)\n{\n  DBUG_ENTER(\"lex_unlock_plugins\");\n\n  \/* release used plugins *\/\n  if (lex->plugins.elements) \/* No function call and no mutex if no plugins. *\/\n  {\n    plugin_unlock_list(0, (plugin_ref*)lex->plugins.buffer, \n                       lex->plugins.elements);\n  }\n  reset_dynamic(&lex->plugins);\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":221639,"func":"  explicit SymbolicShapeOptimizationPass(bool constraints_only) {\n    this->optimize_only_constraints = constraints_only;\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":238460,"func":"static void __mark_reg_unbounded(struct bpf_reg_state *reg)\n{\n\treg->smin_value = S64_MIN;\n\treg->smax_value = S64_MAX;\n\treg->umin_value = 0;\n\treg->umax_value = U64_MAX;\n\n\treg->s32_min_value = S32_MIN;\n\treg->s32_max_value = S32_MAX;\n\treg->u32_min_value = 0;\n\treg->u32_max_value = U32_MAX;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":221687,"func":"bool Socket::breadyForOutput(int timeout)\n{\n    \/\/if (!isssl) {\n        return BaseSocket::breadyForOutput(timeout);\n    \/\/}\n    \/\/return true;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":401551,"func":"int del_timer_sync(struct timer_list *timer)\n{\n\tint ret;\n\n#ifdef CONFIG_LOCKDEP\n\tunsigned long flags;\n\n\t\/*\n\t * If lockdep gives a backtrace here, please reference\n\t * the synchronization rules above.\n\t *\/\n\tlocal_irq_save(flags);\n\tlock_map_acquire(&timer->lockdep_map);\n\tlock_map_release(&timer->lockdep_map);\n\tlocal_irq_restore(flags);\n#endif\n\t\/*\n\t * don't use it in hardirq context, because it\n\t * could lead to deadlock.\n\t *\/\n\tWARN_ON(in_irq() && !(timer->flags & TIMER_IRQSAFE));\n\n\tdo {\n\t\tret = try_to_del_timer_sync(timer);\n\n\t\tif (unlikely(ret < 0)) {\n\t\t\tdel_timer_wait_running(timer);\n\t\t\tcpu_relax();\n\t\t}\n\t} while (ret < 0);\n\n\treturn ret;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":364733,"func":"parse_tag_line(\n    char_u\t*lbuf,\t\t\/\/ line to be parsed\n#ifdef FEAT_EMACS_TAGS\n    int\t\tis_etag,\n#endif\n    tagptrs_T\t*tagp)\n{\n    char_u\t*p;\n\n#ifdef FEAT_EMACS_TAGS\n    if (is_etag)\n\t\/\/ emacs-style tag file\n\treturn emacs_tags_parse_line(lbuf, tagp);\n#endif\n\n    \/\/ Isolate the tagname, from lbuf up to the first white\n    tagp->tagname = lbuf;\n    p = vim_strchr(lbuf, TAB);\n    if (p == NULL)\n\treturn FAIL;\n    tagp->tagname_end = p;\n\n    \/\/ Isolate file name, from first to second white space\n    if (*p != NUL)\n\t++p;\n    tagp->fname = p;\n    p = vim_strchr(p, TAB);\n    if (p == NULL)\n\treturn FAIL;\n    tagp->fname_end = p;\n\n    \/\/ find start of search command, after second white space\n    if (*p != NUL)\n\t++p;\n    if (*p == NUL)\n\treturn FAIL;\n    tagp->command = p;\n\n    return OK;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":329944,"func":"lerp8x4 (uint32_t src, uint8_t a, uint32_t dst)\n{\n    return (add8x2_8x2 (mul8x2_8 (src, a),\n\t\t\tmul8x2_8 (dst, ~a)) |\n\t    add8x2_8x2 (mul8x2_8 (src >> G_SHIFT, a),\n\t\t\tmul8x2_8 (dst >> G_SHIFT, ~a)) << G_SHIFT);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":273917,"func":"static char *time_to_str(time_t mtime)\n{\n\tstruct tm *t = localtime(&mtime);\n\tstatic char str[20];\n\n\tsetlocale(LC_TIME, \"C\");\n\tstrftime(str, sizeof(str), \"%b %e %H:%M\", t);\n\n\treturn str;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":196316,"func":"int digest_generic_verify(struct digest *d, const unsigned char *md)\n{\n\tint ret;\n\tint len = digest_length(d);\n\tunsigned char *tmp;\n\n\ttmp = xmalloc(len);\n\n\tret = digest_final(d, tmp);\n\tif (ret)\n\t\tgoto end;\n\n\tret = memcmp(md, tmp, len);\n\tret = ret ? -EINVAL : 0;\nend:\n\tfree(tmp);\n\treturn ret;\n}","target":1,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":498099,"func":"void cgit_tree_link(const char *name, const char *title, const char *class,\n\t\t    const char *head, const char *rev, const char *path)\n{\n\treporevlink(\"tree\", name, title, class, head, rev, path);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":326616,"func":"archive_write_disk_vtable(void)\n{\n\tstatic struct archive_vtable av;\n\tstatic int inited = 0;\n\n\tif (!inited) {\n\t\tav.archive_close = _archive_write_disk_close;\n\t\tav.archive_filter_bytes = _archive_write_disk_filter_bytes;\n\t\tav.archive_free = _archive_write_disk_free;\n\t\tav.archive_write_header = _archive_write_disk_header;\n\t\tav.archive_write_finish_entry\n\t\t    = _archive_write_disk_finish_entry;\n\t\tav.archive_write_data = _archive_write_disk_data;\n\t\tav.archive_write_data_block = _archive_write_disk_data_block;\n\t\tinited = 1;\n\t}\n\treturn (&av);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":196889,"func":"int pgpPrtParams(const uint8_t * pkts, size_t pktlen, unsigned int pkttype,\n\t\t pgpDigParams * ret)\n{\n    const uint8_t *p = pkts;\n    const uint8_t *pend = pkts + pktlen;\n    pgpDigParams digp = NULL;\n    struct pgpPkt pkt;\n    int rc = -1; \/* assume failure *\/\n\n    while (p < pend) {\n\tif (decodePkt(p, (pend - p), &pkt))\n\t    break;\n\n\tif (digp == NULL) {\n\t    if (pkttype && pkt.tag != pkttype) {\n\t\tbreak;\n\t    } else {\n\t\tdigp = pgpDigParamsNew(pkt.tag);\n\t    }\n\t}\n\n\tif (pgpPrtPkt(&pkt, digp))\n\t    break;\n\n\tp += (pkt.body - pkt.head) + pkt.blen;\n\tif (pkttype == PGPTAG_SIGNATURE)\n\t    break;\n    }\n\n    rc = (digp && (p == pend)) ? 0 : -1;\n\n    if (ret && rc == 0) {\n\t*ret = digp;\n    } else {\n\tpgpDigParamsFree(digp);\n    }\n    return rc;\n}","target":1,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":301014,"func":"pcx256_print_page(gx_device_printer * pdev, gp_file * file)\n{\n    pcx_header header;\n    int code;\n\n    header = pcx_header_prototype;\n    header.version = version_3_0;\n    header.bpp = 8;\n    header.nplanes = 1;\n    assign_ushort(header.palinfo,\n                  (pdev->color_info.num_components > 1 ?\n                   palinfo_color : palinfo_gray));\n    code = pcx_write_page(pdev, file, &header, false);\n    if (code >= 0) {\t\t\/* Write out the palette. *\/\n        gp_fputc(0x0c, file);\n        code = pc_write_palette((gx_device *) pdev, 256, file);\n    }\n    return code;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":261406,"func":"bool advanceCtbAddr(thread_context* tctx)\n{\n    tctx->CtbAddrInTS++;\n\n    return setCtbAddrFromTS(tctx);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":225109,"func":"bool IsSubsetOf(const T& sub, const T& super) {\n  for (const auto& o : sub) {\n    bool found = false;\n    for (const auto& n : super) {\n      if (o == n) {\n        found = true;\n        break;\n      }\n    }\n    if (!found) return false;\n  }\n  return true;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":427797,"func":"void sev_es_create_vcpu(struct vcpu_svm *svm)\n{\n\t\/*\n\t * Set the GHCB MSR value as per the GHCB specification when creating\n\t * a vCPU for an SEV-ES guest.\n\t *\/\n\tset_ghcb_msr(svm, GHCB_MSR_SEV_INFO(GHCB_VERSION_MAX,\n\t\t\t\t\t    GHCB_VERSION_MIN,\n\t\t\t\t\t    sev_enc_bit));\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":333093,"func":"append(Ptrlist *l1, Ptrlist *l2)\n{\n    Ptrlist *oldl1;\n\n    oldl1 = l1;\n    while (l1->next)\n\tl1 = l1->next;\n    l1->next = l2;\n    return oldl1;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":466140,"func":"static int em_idiv_ex(struct x86_emulate_ctxt *ctxt)\n{\n\tu8 de = 0;\n\n\temulate_1op_rax_rdx(ctxt, \"idiv\", de);\n\tif (de)\n\t\treturn emulate_de(ctxt);\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":225787,"func":"}\nstatic u32 ctrn_ctts_to_index(GF_TrackFragmentRunBox *ctrn, s32 ctts)\n{\n\tif (!(ctrn->flags & GF_ISOM_TRUN_CTS_OFFSET))\n\t\treturn 0;\n\n\tif (!ctts) return 0;\n\n\tif (ctrn->version) {\n\t\tif (ctrn->ctso_multiplier) return ctrn_s32_to_index(ctts \/ ctrn->ctso_multiplier);\n\t\treturn ctrn_s32_to_index(ctts);\n\t}\n\tassert(ctts>0);\n\tif (ctrn->ctso_multiplier) return ctrn_u32_to_index((u32)ctts \/ ctrn->ctso_multiplier);\n\treturn ctrn_s32_to_index((u32)ctts);","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":276996,"func":"fiber_resume(mrb_state *mrb, mrb_value self)\n{\n  const mrb_value *a;\n  mrb_int len;\n  mrb_bool vmexec = FALSE;\n\n  mrb_get_args(mrb, \"*!\", &a, &len);\n  if (mrb->c->ci->cci > 0) {\n    vmexec = TRUE;\n  }\n  return fiber_switch(mrb, self, len, a, TRUE, vmexec);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":238441,"func":"static int pop_stack(struct bpf_verifier_env *env, int *prev_insn_idx,\n\t\t     int *insn_idx, bool pop_log)\n{\n\tstruct bpf_verifier_state *cur = env->cur_state;\n\tstruct bpf_verifier_stack_elem *elem, *head = env->head;\n\tint err;\n\n\tif (env->head == NULL)\n\t\treturn -ENOENT;\n\n\tif (cur) {\n\t\terr = copy_verifier_state(cur, &head->st);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\tif (pop_log)\n\t\tbpf_vlog_reset(&env->log, head->log_pos);\n\tif (insn_idx)\n\t\t*insn_idx = head->insn_idx;\n\tif (prev_insn_idx)\n\t\t*prev_insn_idx = head->prev_insn_idx;\n\telem = head->next;\n\tfree_verifier_state(&head->st, false);\n\tkfree(head);\n\tenv->head = elem;\n\tenv->stack_size--;\n\treturn 0;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":90203,"func":"  virtual bool cellular_connected() const {\n    return cellular_ ? cellular_->connected() : false;\n  }\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":432206,"func":"void cpu_address_space_init(CPUState *cpu, int asidx, MemoryRegion *mr)\n{\n    \/* Target code should have set num_ases before calling us *\/\n    assert(asidx < cpu->num_ases);\n\n    if (!cpu->cpu_ases) {\n        cpu->cpu_ases = g_new0(CPUAddressSpace, cpu->num_ases);\n        cpu->cpu_ases[0].cpu = cpu;\n        cpu->cpu_ases[0].as = &(cpu->uc->address_space_memory);\n        cpu->cpu_ases[0].tcg_as_listener.commit = tcg_commit;\n        memory_listener_register(&(cpu->cpu_ases[0].tcg_as_listener), cpu->cpu_ases[0].as);\n    }\n    \/* arm security memory *\/\n    if (asidx > 0) {\n        cpu->cpu_ases[asidx].cpu = cpu;\n        cpu->cpu_ases[asidx].as = &(cpu->uc->address_space_memory);\n        cpu->cpu_ases[asidx].tcg_as_listener.commit = tcg_commit;\n        memory_listener_register(&(cpu->cpu_ases[asidx].tcg_as_listener), cpu->cpu_ases[asidx].as);\n    }\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":512620,"func":"  bool set_limit_clause_param(longlong nr)\n  {\n    value.set_handler(&type_handler_longlong);\n    set_int(nr, MY_INT64_NUM_DECIMAL_DIGITS);\n    return !unsigned_flag && value.integer < 0;\n  }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":261950,"func":"njs_encode_base64_length(const njs_str_t *src, size_t *out_size)\n{\n    size_t  size;\n\n    size = (src->length == 0) ? 0 : njs_base64_encoded_length(src->length);\n\n    if (out_size != NULL) {\n        *out_size = size;\n    }\n\n    return size;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":466152,"func":"static int em_bt(struct x86_emulate_ctxt *ctxt)\n{\n\t\/* Disable writeback. *\/\n\tctxt->dst.type = OP_NONE;\n\t\/* only subword offset *\/\n\tctxt->src.val &= (ctxt->dst.bytes << 3) - 1;\n\n\temulate_2op_SrcV_nobyte(ctxt, \"bt\");\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":261993,"func":"void Curl_conncache_remove_conn(struct Curl_easy *data,\n                                struct connectdata *conn, bool lock)\n{\n  struct connectbundle *bundle = conn->bundle;\n  struct conncache *connc = data->state.conn_cache;\n\n  \/* The bundle pointer can be NULL, since this function can be called\n     due to a failed connection attempt, before being added to a bundle *\/\n  if(bundle) {\n    if(lock) {\n      CONNCACHE_LOCK(data);\n    }\n    bundle_remove_conn(bundle, conn);\n    if(bundle->num_connections == 0)\n      conncache_remove_bundle(connc, bundle);\n    conn->bundle = NULL; \/* removed from it *\/\n    if(connc) {\n      connc->num_conn--;\n      DEBUGF(infof(data, \"The cache now contains %zu members\",\n                   connc->num_conn));\n    }\n    if(lock) {\n      CONNCACHE_UNLOCK(data);\n    }\n  }\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":463221,"func":"static int annotation_set_mailboxopt(annotate_state_t *state,\n                                     struct annotate_entry_list *entry,\n                                     int maywrite)\n{\n    struct mailbox *mailbox = state->mailbox;\n    uint32_t flag = (unsigned long)entry->desc->rock;\n    unsigned long newopts;\n\n    assert(mailbox);\n\n    newopts = mailbox->i.options;\n\n    if (entry->shared.s &&\n        !strcmp(entry->shared.s, \"true\")) {\n        newopts |= flag;\n    } else {\n        newopts &= ~flag;\n    }\n\n    \/* only mark dirty if there's been a change *\/\n    if (mailbox->i.options != newopts) {\n        if (!maywrite) return IMAP_PERMISSION_DENIED;\n        mailbox_index_dirty(mailbox);\n        mailbox_modseq_dirty(mailbox);\n        mailbox->i.options = newopts;\n        mboxlist_update_foldermodseq(mailbox->name, mailbox->i.highestmodseq);\n    }\n\n    return 0;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":446101,"func":"static int atusb_get_and_clear_error(struct atusb *atusb)\n{\n\tint err = atusb->err;\n\n\tatusb->err = 0;\n\treturn err;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":508827,"func":"void st_select_lex_node::include_neighbour(st_select_lex_node *before)\n{\n  if ((next= before->next))\n    next->prev= &next;\n  prev= &before->next;\n  before->next= this;\n  master= before->master;\n  slave= 0;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":253600,"func":"smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)\n{\n\tstruct TCP_Server_Info *server = tcon->ses->server;\n\tunsigned int wsize;\n\n\t\/* start with specified wsize, or default *\/\n\twsize = ctx->wsize ? ctx->wsize : CIFS_DEFAULT_IOSIZE;\n\twsize = min_t(unsigned int, wsize, server->max_write);\n\tif (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))\n\t\twsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);\n\n\treturn wsize;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":517431,"func":"static void printFavicon(HttpResponse res) {\n        static size_t l;\n        Socket_T S = res->S;\n        static unsigned char *favicon = NULL;\n\n        if (! favicon) {\n                favicon = CALLOC(sizeof(unsigned char), strlen(FAVICON_ICO));\n                l = decode_base64(favicon, FAVICON_ICO);\n        }\n        if (l) {\n                res->is_committed = true;\n                Socket_print(S, \"HTTP\/1.0 200 OK\\r\\n\");\n                Socket_print(S, \"Content-length: %lu\\r\\n\", (unsigned long)l);\n                Socket_print(S, \"Content-Type: image\/x-icon\\r\\n\");\n                Socket_print(S, \"Connection: close\\r\\n\\r\\n\");\n                if (Socket_write(S, favicon, l) < 0) {\n                        LogError(\"Error sending favicon data -- %s\\n\", STRERROR);\n                }\n        }\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":226332,"func":"}\nstatic u32 ctrn_read_flags(GF_BitStream *bs, u32 nbbits)\n{\n\tu32 val = gf_bs_read_int(bs, nbbits);\n\tif (nbbits==16) val <<= 16;\n\telse if (nbbits==8) val <<= 24;\n\treturn val;","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":409446,"func":"free_cur_term()\n{\n# ifdef HAVE_DEL_CURTERM\n    if (cur_term)\n\tdel_curterm(cur_term);\n# endif\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":389748,"func":"check_for_opt_chan_or_job_arg(typval_T *args, int idx)\n{\n    return (args[idx].v_type == VAR_UNKNOWN\n\t    || check_for_chan_or_job_arg(args, idx) != FAIL);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":512473,"func":"bool Item_func_case_simple::fix_length_and_dec()\n{\n  THD *thd= current_thd;\n  return (aggregate_then_and_else_arguments(thd, when_count() + 1) ||\n          aggregate_switch_and_when_arguments(thd, false));\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":512609,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_date_literal>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":462225,"func":"PJ_DEF(pj_status_t) pj_stun_msg_create( pj_pool_t *pool,\n\t\t\t\t\tunsigned msg_type,\n\t\t\t\t\tpj_uint32_t magic,\n\t\t\t\t\tconst pj_uint8_t tsx_id[12],\n\t\t\t\t\tpj_stun_msg **p_msg)\n{\n    pj_stun_msg *msg;\n\n    PJ_ASSERT_RETURN(pool && msg_type && p_msg, PJ_EINVAL);\n\n    msg = PJ_POOL_ZALLOC_T(pool, pj_stun_msg);\n    *p_msg = msg;\n    return pj_stun_msg_init(msg, msg_type, magic, tsx_id);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":225935,"func":"GF_Err tpay_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TPAYBox *ptr = (GF_TPAYBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->nbBytes = gf_bs_read_u32(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":483510,"func":"static __init int efivar_ssdt_iter(efi_char16_t *name, efi_guid_t vendor,\n\t\t\t\t   unsigned long name_size, void *data)\n{\n\tstruct efivar_entry *entry;\n\tstruct list_head *list = data;\n\tchar utf8_name[EFIVAR_SSDT_NAME_MAX];\n\tint limit = min_t(unsigned long, EFIVAR_SSDT_NAME_MAX, name_size);\n\n\tucs2_as_utf8(utf8_name, name, limit - 1);\n\tif (strncmp(utf8_name, efivar_ssdt, limit) != 0)\n\t\treturn 0;\n\n\tentry = kmalloc(sizeof(*entry), GFP_KERNEL);\n\tif (!entry)\n\t\treturn 0;\n\n\tmemcpy(entry->var.VariableName, name, name_size);\n\tmemcpy(&entry->var.VendorGuid, &vendor, sizeof(efi_guid_t));\n\n\tefivar_entry_add(entry, list);\n\n\treturn 0;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":229324,"func":"bool IntArgsAndRetvalsOnDevice(EagerOperation* op) {\n  \/\/ Most TF ops expect and generate int32 tensors on the host (or a TPU\/XLA\n  \/\/ device). This is not the case with IteratorGetNext since it is possible to\n  \/\/ build int32 datasets that produce outputs on device when using\n  \/\/ prefetch_to_device.\n  \/\/ When running call ops, by default we assume that the int32 outputs are on a\n  \/\/ host (except for the XLA\/TPU case). So we need to special case\n  \/\/ IteratorGetNext such that its eager behavior matches the wrapped one.\n  \/\/ TODO(b\/208435025): Remove this if we end up deciding that int32 outputs\n  \/\/ from IteratorGetNext should indeed live on host.\n  return op->Name() == \"IteratorGetNext\";\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":252364,"func":"mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits,\n                                                int strategy) {\n  mz_uint comp_flags =\n      s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] |\n      ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0);\n  if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER;\n\n  if (!level)\n    comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS;\n  else if (strategy == MZ_FILTERED)\n    comp_flags |= TDEFL_FILTER_MATCHES;\n  else if (strategy == MZ_HUFFMAN_ONLY)\n    comp_flags &= ~TDEFL_MAX_PROBES_MASK;\n  else if (strategy == MZ_FIXED)\n    comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS;\n  else if (strategy == MZ_RLE)\n    comp_flags |= TDEFL_RLE_MATCHES;\n\n  return comp_flags;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":353207,"func":"void SplashOutputDev::updateLineCap(GfxState *state) {\n  splash->setLineCap(state->getLineCap());\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":473953,"func":"utf16le_get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t\t\t   const OnigUChar* p, const OnigUChar* end,\n\t\t\t\t   OnigCaseFoldCodeItem items[],\n\t\t\t\t   OnigEncoding enc)\n{\n  return onigenc_unicode_get_case_fold_codes_by_str(enc,\n\t\t\t\t\t\t    flag, p, end, items);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":359609,"func":"peer_update_source_vty (struct vty *vty, const char *peer_str, \n                        const char *source_str)\n{\n  struct peer *peer;\n  union sockunion *su;\n\n  peer = peer_and_group_lookup_vty (vty, peer_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  if (source_str)\n    {\n      su = sockunion_str2su (source_str);\n      if (su)\n\t{\n\t  peer_update_source_addr_set (peer, su);\n\t  sockunion_free (su);\n\t}\n      else\n\tpeer_update_source_if_set (peer, source_str);\n    }\n  else\n    peer_update_source_unset (peer);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":226060,"func":"\nGF_Err txtc_box_size(GF_Box *s)\n{\n\tGF_TextConfigBox *ptr = (GF_TextConfigBox *)s;\n\tif (ptr->config)\n\t\tptr->size += strlen(ptr->config);\n\tptr->size++;\n\treturn GF_OK;","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":308196,"func":"static void fastrpc_context_get(struct fastrpc_invoke_ctx *ctx)\n{\n\tkref_get(&ctx->refcount);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":512460,"func":"  virtual bool val_bool()\n  {\n    return type_handler()->Item_val_bool(this);\n  }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":224564,"func":"Status MaxPoolShapeWithExplicitPadding(shape_inference::InferenceContext* c) {\n  return MaxPoolShapeImpl(c, \/*supports_explicit_padding=*\/true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":293938,"func":"fix_indent(void)\n{\n    if (p_paste)\n\treturn;\n# ifdef FEAT_LISP\n    if (curbuf->b_p_lisp && curbuf->b_p_ai)\n\tfixthisline(get_lisp_indent);\n# endif\n# if defined(FEAT_LISP) && defined(FEAT_CINDENT)\n    else\n# endif\n# ifdef FEAT_CINDENT\n\tif (cindent_on())\n\t    do_c_expr_indent();\n# endif\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":224561,"func":"Status DimensionsFromShape(ShapeHandle shape, TensorFormat format,\n                           DimensionHandle* batch_dim,\n                           gtl::MutableArraySlice<DimensionHandle> spatial_dims,\n                           DimensionHandle* filter_dim,\n                           InferenceContext* context) {\n  const int32_t rank =\n      GetTensorDimsFromSpatialDims(spatial_dims.size(), format);\n  \/\/ Batch.\n  *batch_dim = context->Dim(shape, GetTensorBatchDimIndex(rank, format));\n  \/\/ Spatial.\n  for (int spatial_dim_index = 0, end = spatial_dims.size();\n       spatial_dim_index < end; ++spatial_dim_index) {\n    spatial_dims[spatial_dim_index] = context->Dim(\n        shape, GetTensorSpatialDimIndex(rank, format, spatial_dim_index));\n  }\n  \/\/ Channel.\n  *filter_dim = context->Dim(shape, GetTensorFeatureDimIndex(rank, format));\n  if (format == FORMAT_NCHW_VECT_C) {\n    TF_RETURN_IF_ERROR(context->Multiply(\n        *filter_dim,\n        context->Dim(shape, GetTensorInnerFeatureDimIndex(rank, format)),\n        filter_dim));\n  }\n  return Status::OK();\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":443162,"func":"static void jfs_write_failed(struct address_space *mapping, loff_t to)\n{\n\tstruct inode *inode = mapping->host;\n\n\tif (to > inode->i_size) {\n\t\ttruncate_pagecache(inode, inode->i_size);\n\t\tjfs_truncate(inode);\n\t}\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":226228,"func":"\nGF_Box *ssix_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SubsegmentIndexBox, GF_ISOM_BOX_TYPE_SSIX);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":488424,"func":"static inline int is_cow_mapping(unsigned int flags)\n{\n\treturn (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":336531,"func":"SPICE_GNUC_VISIBLE int spice_server_init(SpiceServer *reds, SpiceCoreInterface *core)\n{\n    int ret;\n\n    ret = do_spice_init(reds, core);\n    if (reds->config->renderers->len == 0) {\n        reds_add_renderer(reds, default_renderer);\n    }\n    if (reds->config->video_codecs->len == 0) {\n        reds_set_video_codecs_from_string(reds, default_video_codecs, NULL);\n    }\n    return ret;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":395092,"func":"redraw_buf_and_status_later(buf_T *buf, int type)\n{\n    win_T\t*wp;\n\n#ifdef FEAT_WILDMENU\n    if (wild_menu_showing != 0)\n\t\/\/ Don't redraw while the command line completion is displayed, it\n\t\/\/ would disappear.\n\treturn;\n#endif\n    FOR_ALL_WINDOWS(wp)\n    {\n\tif (wp->w_buffer == buf)\n\t{\n\t    redraw_win_later(wp, type);\n\t    wp->w_redr_status = TRUE;\n\t}\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":253727,"func":"static void ccp_process_data(struct ccp_data *src, struct ccp_data *dst,\n\t\t\t     struct ccp_op *op)\n{\n\top->init = 0;\n\n\tif (dst) {\n\t\tif (op->dst.u.dma.address == dst->dm_wa.dma.address)\n\t\t\tccp_empty_queue_buf(dst);\n\t\telse\n\t\t\tccp_update_sg_workarea(&dst->sg_wa,\n\t\t\t\t\t       op->dst.u.dma.length);\n\t}\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":484054,"func":"teardown_secureChannel(void) {\n    UA_SecureChannel_close(&testChannel);\n    dummyPolicy.clear(&dummyPolicy);\n    testingConnection.close(&testingConnection);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":213998,"func":"FindEmptyObjectSlot(\n\t\t    TPMI_DH_OBJECT  *handle         \/\/ OUT: (optional)\n\t\t    )\n{\n    UINT32               i;\n    OBJECT              *object;\n    for(i = 0; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    object = &s_objects[i];\n\t    if(object->attributes.occupied == CLEAR)\n\t\t{\n\t\t    if(handle)\n\t\t\t*handle = i + TRANSIENT_FIRST;\n\t\t    \/\/ Initialize the object attributes\n\t\t    MemorySet(&object->attributes, 0, sizeof(OBJECT_ATTRIBUTES));\n\t\t    return object;\n\t\t}\n\t}\n    return NULL;\n}","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":380954,"func":"ins_shift(int c, int lastc)\n{\n    if (stop_arrow() == FAIL)\n\treturn;\n    AppendCharToRedobuff(c);\n\n    \/*\n     * 0^D and ^^D: remove all indent.\n     *\/\n    if (c == Ctrl_D && (lastc == '0' || lastc == '^')\n\t\t\t\t\t\t  && curwin->w_cursor.col > 0)\n    {\n\t--curwin->w_cursor.col;\n\t(void)del_char(FALSE);\t\t\/\/ delete the '^' or '0'\n\t\/\/ In Replace mode, restore the characters that '^' or '0' replaced.\n\tif (State & REPLACE_FLAG)\n\t    replace_pop_ins();\n\tif (lastc == '^')\n\t    old_indent = get_indent();\t\/\/ remember curr. indent\n\tchange_indent(INDENT_SET, 0, TRUE, 0, TRUE);\n    }\n    else\n\tchange_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE);\n\n    if (did_ai && *skipwhite(ml_get_curline()) != NUL)\n\tdid_ai = FALSE;\n    did_si = FALSE;\n    can_si = FALSE;\n    can_si_back = FALSE;\n    can_cindent = FALSE;\t\/\/ no cindenting after ^D or ^T\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":409484,"func":"term_fg_rgb_color(guicolor_T rgb)\n{\n    term_rgb_color(T_8F, rgb);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":206555,"func":"static int dynamicGetbuf (gdIOCtxPtr ctx, void *buf, int len)\n{\n\tint rlen, remain;\n\tdpIOCtxPtr dctx;\n\tdynamicPtr *dp;\n\n\tdctx = (dpIOCtxPtr) ctx;\n\tdp = dctx->dp;\n\n\tremain = dp->logicalSize - dp->pos;\n\tif (remain >= len) {\n\t\trlen = len;\n\t} else {\n\t\tif (remain == 0) {\n\t\t\treturn EOF;\n\t\t}\n\t\trlen = remain;\n\t}\n\n\tmemcpy(buf, (void *) ((char *) dp->data + dp->pos), rlen);\n\tdp->pos += rlen;\n\n\treturn rlen;\n}","target":1,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":459111,"func":"static int __tcf_qdisc_cl_find(struct Qdisc *q, u32 parent, unsigned long *cl,\n\t\t\t       int ifindex, struct netlink_ext_ack *extack)\n{\n\tif (ifindex == TCM_IFINDEX_MAGIC_BLOCK)\n\t\treturn 0;\n\n\t\/* Do we search for filter, attached to class? *\/\n\tif (TC_H_MIN(parent)) {\n\t\tconst struct Qdisc_class_ops *cops = q->ops->cl_ops;\n\n\t\t*cl = cops->find(q, parent);\n\t\tif (*cl == 0) {\n\t\t\tNL_SET_ERR_MSG(extack, \"Specified class doesn't exist\");\n\t\t\treturn -ENOENT;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":300782,"func":"static u16 tsk_blocks(int len)\n{\n\treturn ((len \/ FLOWCTL_BLK_SZ) + 1);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":253594,"func":"void close_cached_dir_lease_locked(struct cached_fid *cfid)\n{\n\tif (cfid->has_lease) {\n\t\tcfid->has_lease = false;\n\t\tkref_put(&cfid->refcount, smb2_close_cached_fid);\n\t}\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":274652,"func":"static void show_no_layers_warning (void) {\n\tgchar *str = g_new(gchar, MAX_DISTLEN);\n\tutf8_strncpy(str, _(\"No layers are currently loaded. A layer must be loaded first.\"), MAX_DISTLEN - 7);\n\tutf8_snprintf(screen.statusbar.diststr, MAX_DISTLEN, \"<b>%s<\/b>\", str);\n\tg_free(str);\n\t\t\n\tcallbacks_update_statusbar();\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":386484,"func":"bool DL_Dxf::handleXData(DL_CreationInterface* creationInterface) {\n    if (groupCode==1001) {\n        creationInterface->addXDataApp(groupValue);\n        return true;\n    }\n    else if (groupCode>=1000 && groupCode<=1009) {\n        creationInterface->addXDataString(groupCode, groupValue);\n        return true;\n    }\n    else if (groupCode>=1010 && groupCode<=1059) {\n        creationInterface->addXDataReal(groupCode, toReal(groupValue));\n        return true;\n    }\n    else if (groupCode>=1060 && groupCode<=1070) {\n        creationInterface->addXDataInt(groupCode, toInt(groupValue));\n        return true;\n    }\n    else if (groupCode==1071) {\n        creationInterface->addXDataInt(groupCode, toInt(groupValue));\n        return true;\n    }\n\n    return false;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":225467,"func":"bool CanDedupControlWithRegularInput(const MutableGraphView& graph,\n                                     absl::string_view control_node_name) {\n  NodeDef* control_node = graph.GetNode(control_node_name);\n  if (control_node == nullptr) {\n    return false;\n  }\n  return CanDedupControlWithRegularInput(graph, *control_node);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":476095,"func":"static void composite_unbind(struct usb_gadget *gadget)\n{\n\t__composite_unbind(gadget, true);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":446117,"func":"static int atusb_read_reg(struct atusb *atusb, u8 reg)\n{\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\tint ret;\n\tu8 *buffer;\n\tu8 value;\n\n\tbuffer = kmalloc(1, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\tdev_dbg(&usb_dev->dev, \"%s: reg = 0x%x\\n\", __func__, reg);\n\tret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),\n\t\t\t\tATUSB_REG_READ, ATUSB_REQ_FROM_DEV,\n\t\t\t\t0, reg, buffer, 1, 1000);\n\n\tif (ret >= 0) {\n\t\tvalue = buffer[0];\n\t\tkfree(buffer);\n\t\treturn value;\n\t} else {\n\t\tkfree(buffer);\n\t\treturn ret;\n\t}\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":512341,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_field_row>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":293768,"func":"static RBinAddr *newEntry(ut64 haddr, ut64 vaddr, int type) {\n\tRBinAddr *ptr = R_NEW0 (RBinAddr);\n\tif (!ptr) {\n\t\treturn NULL;\n\t}\n\tptr->paddr = haddr;\n\tptr->vaddr = vaddr;\n\tptr->hpaddr = haddr;\n\tptr->bits = 64;\n\tptr->type = type;\n\treturn ptr;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":432303,"func":"void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,\n                         bool is_write, hwaddr access_len)\n{\n    if (buffer != as->uc->bounce.buffer) {\n        MemoryRegion *mr;\n        ram_addr_t addr1;\n\n        mr = memory_region_from_host(as->uc, buffer, &addr1);\n        assert(mr != NULL);\n        if (is_write) {\n            invalidate_and_set_dirty(mr, addr1, access_len);\n        }\n        return;\n    }\n    if (is_write) {\n        address_space_write(as, as->uc->bounce.addr, MEMTXATTRS_UNSPECIFIED,\n                            as->uc->bounce.buffer, access_len);\n    }\n    qemu_vfree(as->uc->bounce.buffer);\n    as->uc->bounce.buffer = NULL;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":90757,"func":"void QuotaManager::DidGetGlobalQuotaForEviction(\n    QuotaStatusCode status,\n    StorageType type,\n    int64 quota) {\n  DCHECK_EQ(type, kStorageTypeTemporary);\n  if (status != kQuotaStatusOk) {\n    eviction_context_.get_usage_and_quota_callback->Run(\n        status, 0, 0, 0, 0);\n    eviction_context_.get_usage_and_quota_callback.reset();\n    return;\n  }\n\n  eviction_context_.quota = quota;\n  GetAvailableSpace(callback_factory_.\n      NewCallback(&QuotaManager::DidGetAvailableSpaceForEviction));\n}\n","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":482488,"func":"addBackwardRuleWithMultipleCells(widechar *cells, int dotslen,\n\t\tTranslationTableOffset ruleOffset, TranslationTableRule *rule,\n\t\tTranslationTableHeader *table) {\n\t\/* direction = 1, dotslen > 1 *\/\n\tTranslationTableOffset *backRule = &table->backRules[_lou_stringHash(cells, 0, NULL)];\n\tif (rule->opcode == CTO_SwapCc) return;\n\tint ruleLength = dotslen + rule->charslen;\n\twhile (*backRule) {\n\t\tTranslationTableRule *r = (TranslationTableRule *)&table->ruleArea[*backRule];\n\t\tint rLength = r->dotslen + r->charslen;\n\t\tif (ruleLength > rLength) break;\n\t\tif (rLength == ruleLength)\n\t\t\tif ((r->opcode == CTO_Always) && (rule->opcode != CTO_Always)) break;\n\t\tbackRule = &r->dotsnext;\n\t}\n\trule->dotsnext = *backRule;\n\t*backRule = ruleOffset;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":249953,"func":"file_accessible (char const *file)\n{\n# if defined _LIBC || HAVE_FACCESSAT\n  return __faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) == 0;\n# else\n  struct stat st;\n  return __stat (file, &st) == 0 || errno == EOVERFLOW;\n# endif\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":247728,"func":"  TestUtilOptionsV2& setExpectedServerStats(const std::string& expected_server_stats) {\n    TestUtilOptionsBase::setExpectedServerStats(expected_server_stats);\n    return *this;\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":310335,"func":"connection_dirserv_flushed_some(dir_connection_t *conn)\n{\n  tor_assert(conn->_base.state == DIR_CONN_STATE_SERVER_WRITING);\n\n  if (buf_datalen(conn->_base.outbuf) >= DIRSERV_BUFFER_MIN)\n    return 0;\n\n  switch (conn->dir_spool_src) {\n    case DIR_SPOOL_EXTRA_BY_DIGEST:\n    case DIR_SPOOL_EXTRA_BY_FP:\n    case DIR_SPOOL_SERVER_BY_DIGEST:\n    case DIR_SPOOL_SERVER_BY_FP:\n      return connection_dirserv_add_servers_to_outbuf(conn);\n    case DIR_SPOOL_MICRODESC:\n      return connection_dirserv_add_microdescs_to_outbuf(conn);\n    case DIR_SPOOL_CACHED_DIR:\n      return connection_dirserv_add_dir_bytes_to_outbuf(conn);\n    case DIR_SPOOL_NETWORKSTATUS:\n      return connection_dirserv_add_networkstatus_bytes_to_outbuf(conn);\n    case DIR_SPOOL_NONE:\n    default:\n      return 0;\n  }\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":448926,"func":"int ZEXPORT inflateGetHeader(strm, head)\nz_streamp strm;\ngz_headerp head;\n{\n    struct inflate_state FAR *state;\n\n    \/* check state *\/\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;\n\n    \/* save header structure *\/\n    state->head = head;\n    head->done = 0;\n    return Z_OK;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":231047,"func":"static BaseType_t prvIsQueueEmpty( const Queue_t * pxQueue )\r\n{\r\n    BaseType_t xReturn;\r\n\r\n    taskENTER_CRITICAL();\r\n    {\r\n        if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )\r\n        {\r\n            xReturn = pdTRUE;\r\n        }\r\n        else\r\n        {\r\n            xReturn = pdFALSE;\r\n        }\r\n    }\r\n    taskEXIT_CRITICAL();\r\n\r\n    return xReturn;\r\n}\r","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":240592,"func":"  explicit ResourceGatherNdOp(OpKernelConstruction* c) : OpKernel(c) {}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":474447,"func":"ObjectGetPublicAttributes(\n\t\t\t  TPM_HANDLE       handle\n\t\t\t  )\n{\n    return HandleToObject(handle)->publicArea.objectAttributes;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":293532,"func":"PJ_DEF(int) pj_scan_peek_n( pj_scanner *scanner,\n\t\t\t     pj_size_t len, pj_str_t *out)\n{\n    char *endpos = scanner->curptr + len;\n\n    if (endpos > scanner->end) {\n\tpj_scan_syntax_err(scanner);\n\treturn -1;\n    }\n\n    pj_strset(out, scanner->curptr, len);\n    return *endpos;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":247739,"func":"  TestUtilOptions& setExpectedSha1Digest(const std::string& expected_sha1_digest) {\n    expected_sha1_digest_ = expected_sha1_digest;\n    return *this;\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":384804,"func":"transchar_hex(char_u *buf, int c)\n{\n    int\t\ti = 0;\n\n    buf[0] = '<';\n    if (c > 255)\n    {\n\tbuf[++i] = nr2hex((unsigned)c >> 12);\n\tbuf[++i] = nr2hex((unsigned)c >> 8);\n    }\n    buf[++i] = nr2hex((unsigned)c >> 4);\n    buf[++i] = nr2hex((unsigned)c);\n    buf[++i] = '>';\n    buf[++i] = NUL;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":445898,"func":"archive_extraction_ready_for_encryption_cb (GObject      *source_object,\n\t\t\t\t\t    GAsyncResult *result,\n\t\t\t\t\t    gpointer      user_data)\n{\n\tEncryptData *edata = user_data;\n\tFrWindow    *window = edata->window;\n\tGList       *list;\n\tGError      *error = NULL;\n\n\tif (! fr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error)) {\n\t\t_encrypt_operation_completed_with_error (window, FR_ACTION_ENCRYPTING_ARCHIVE, error);\n\t\treturn;\n\t}\n\n\tfr_archive_action_started (window->archive, FR_ACTION_ENCRYPTING_ARCHIVE);\n\n\tlist = g_list_prepend (NULL, edata->temp_extraction_dir);\n\tfr_archive_add_files (edata->new_archive,\n\t\t\t      list,\n\t\t\t      edata->temp_extraction_dir,\n\t\t\t      NULL,\n\t\t\t      FALSE,\n\t\t\t      FALSE,\n\t\t\t      edata->password,\n\t\t\t      edata->encrypt_header,\n\t\t\t      window->priv->compression,\n\t\t\t      0,\n\t\t\t      window->priv->cancellable,\n\t\t\t      archive_add_ready_for_encryption_cb,\n\t\t\t      edata);\n\n\tg_list_free (list);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":222512,"func":"Status FunctionCallFrame::SetRetval(int index, const Tensor& val) {\n  if (index < 0 || static_cast<size_t>(index) >= rets_.size()) {\n    return errors::InvalidArgument(\"SetRetval \", index, \" is not within [0, \",\n                                   rets_.size(), \")\");\n  }\n  if (val.dtype() != ret_types_[index]) {\n    return errors::InvalidArgument(\n        \"Expects ret[\", index, \"] to be \", DataTypeString(ret_types_[index]),\n        \", but \", DataTypeString(val.dtype()), \" is provided.\");\n  }\n  Retval* item = &rets_[index];\n  if (!item->has_val) {\n    item->has_val = true;\n    item->val = val;\n  } else {\n    return errors::Internal(\"Retval[\", index, \"] has already been set.\");\n  }\n  return Status::OK();\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":310160,"func":"drv_release(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED)\n{\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":328926,"func":"R_API RList *r_bin_java_get_lib_names(RBinJavaObj *bin) {\n\tRList *lib_names = r_list_newf (free);\n\tRListIter *iter;\n\tRBinJavaCPTypeObj *cp_obj = NULL;\n\tif (!bin) {\n\t\treturn lib_names;\n\t}\n\tr_list_foreach (bin->cp_list, iter, cp_obj) {\n\t\tif (cp_obj && cp_obj->tag == R_BIN_JAVA_CP_CLASS &&\n\t\t(bin->cf2.this_class != cp_obj->info.cp_class.name_idx || !is_class_interface (bin, cp_obj))) {\n\t\t\tchar *name = r_bin_java_get_item_name_from_bin_cp_list (bin, cp_obj);\n\t\t\tif (name) {\n\t\t\t\tr_list_append (lib_names, name);\n\t\t\t}\n\t\t}\n\t}\n\treturn lib_names;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":263492,"func":"static struct sock *sco_sock_alloc(struct net *net, struct socket *sock,\n\t\t\t\t   int proto, gfp_t prio, int kern)\n{\n\tstruct sock *sk;\n\n\tsk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto, kern);\n\tif (!sk)\n\t\treturn NULL;\n\n\tsock_init_data(sock, sk);\n\tINIT_LIST_HEAD(&bt_sk(sk)->accept_q);\n\n\tsk->sk_destruct = sco_sock_destruct;\n\tsk->sk_sndtimeo = SCO_CONN_TIMEOUT;\n\n\tsock_reset_flag(sk, SOCK_ZAPPED);\n\n\tsk->sk_protocol = proto;\n\tsk->sk_state    = BT_OPEN;\n\n\tsco_pi(sk)->setting = BT_VOICE_CVSD_16BIT;\n\n\tbt_sock_link(&sco_sk_list, sk);\n\treturn sk;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":430405,"func":"bool ovs_nla_get_ufid(struct sw_flow_id *sfid, const struct nlattr *attr,\n\t\t      bool log)\n{\n\tsfid->ufid_len = get_ufid_len(attr, log);\n\tif (sfid->ufid_len)\n\t\tmemcpy(sfid->ufid, nla_data(attr), sfid->ufid_len);\n\n\treturn sfid->ufid_len;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":466178,"func":"static int em_adc(struct x86_emulate_ctxt *ctxt)\n{\n\temulate_2op_SrcV(ctxt, \"adc\");\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":359528,"func":"DEFUN (no_neighbor_send_community,\n       no_neighbor_send_community_cmd,\n       NO_NEIGHBOR_CMD2 \"send-community\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Send Community attribute to this neighbor\\n\")\n{\n  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t bgp_node_safi (vty),\n\t\t\t\t PEER_FLAG_SEND_COMMUNITY);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":455175,"func":"MOBI_RET mobi_load_filename(MOBIData *m, const char *path) {\n    FILE *file = fopen(path, \"rb\");\n    if (file == NULL) {\n        debug_print(\"%s\", \"File not found\\n\");\n        return MOBI_FILE_NOT_FOUND;\n    }\n    const MOBI_RET ret = mobi_load_file(m, file);\n    fclose(file);\n    return ret;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":289289,"func":"static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)\n{\n\tstruct snd_pcm_substream *substream;\n\tstruct snd_pcm_runtime *runtime;\n\tint i;\n\n\tfor (i = 0; i < 2; i++) { \n\t\tsubstream = pcm_oss_file->streams[i];\n\t\tif (!substream)\n\t\t\tcontinue;\n\t\truntime = substream->runtime;\n\t\tsnd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);\n\t\tmutex_lock(&runtime->oss.params_lock);\n\t\truntime->oss.prepare = 1;\n\t\truntime->oss.buffer_used = 0;\n\t\truntime->oss.prev_hw_ptr_period = 0;\n\t\truntime->oss.period_ptr = 0;\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":234727,"func":"static void update_dev_time(const char *path_name)\n{\n\tstruct file *filp;\n\n\tfilp = filp_open(path_name, O_RDWR, 0);\n\tif (IS_ERR(filp))\n\t\treturn;\n\tfile_update_time(filp);\n\tfilp_close(filp, NULL);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":459525,"func":"static int stack_map_update_elem(struct bpf_map *map, void *key, void *value,\n\t\t\t\t u64 map_flags)\n{\n\treturn -EINVAL;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":244007,"func":"GF_Err fecr_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tFECReservoirBox *ptr = (FECReservoirBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_int(bs, ptr->nb_entries, ptr->version ? 32 : 16);\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tgf_bs_write_int(bs, ptr->entries[i].item_id, ptr->version ? 32 : 16);\n\t\tgf_bs_write_u32(bs, ptr->entries[i].symbol_count);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":463176,"func":"EXPORTED size_t sizeentryatts(const struct entryattlist *l)\n{\n    size_t sz = 0;\n    struct attvaluelist *av;\n\n    for ( ; l ; l = l->next)\n        for (av = l->attvalues ; av ; av = av->next)\n            sz += av->value.len;\n    return sz;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":473954,"func":"euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,\n                    UChar* lower, OnigEncoding enc)\n{\n  return onigenc_mbn_mbc_case_fold(enc, flag,\n                                   pp, end, lower);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":379658,"func":"R_API int r_anal_var_count_all(RAnalFunction *fcn) {\n\tr_return_val_if_fail (fcn, 0);\n\treturn r_pvector_len (&fcn->vars);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":377483,"func":"static void r_coresym_cache_element_lined_symbol_fini(RCoreSymCacheElementLinedSymbol *sym) {\n\tif (sym) {\n\t\tr_coresym_cache_element_symbol_fini (&sym->sym);\n\t\tr_coresym_cache_element_flc_fini (&sym->flc);\n\t}\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":222845,"func":"  Status Merge(DimensionHandle d1, DimensionHandle d2, int64_t* result) {\n    const int64_t dim1 = InferenceContext::Value(d1);\n    const int64_t dim2 = InferenceContext::Value(d2);\n\n    if (dim1 >= 0 && dim2 >= 0) {\n      CHECK_EQ(dim1, dim2);\n      return RefineDim(dim1, result);\n    } else if (dim1 >= 0 && dim2 < 0) {\n      return RefineDim(dim1, result);\n    } else if (dim1 < 0 && dim2 >= 0) {\n      return RefineDim(dim2, result);\n    } else if (dim1 < -1) {\n      return RefineDim(dim1, result);\n    } else if (dim2 < -1) {\n      return RefineDim(dim2, result);\n    } else {\n      CHECK_EQ(dim1, dim2);\n      CHECK_EQ(-1, dim1);\n      return RefineDim(-1, result);\n    }\n    return Status::OK();\n  }","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":500067,"func":"static krb5_deltat get_rc_clockskew(krb5_context context)\n\t{\n\tkrb5_rcache \trc;\n\tkrb5_deltat \tclockskew;\n\n\tif (krb5_rc_default(context, &rc))  return KSSL_CLOCKSKEW;\n\tif (krb5_rc_initialize(context, rc, 0))  return KSSL_CLOCKSKEW;\n\tif (krb5_rc_get_lifespan(context, rc, &clockskew))  {\n\t\tclockskew = KSSL_CLOCKSKEW;\n\t\t}\n\t(void) krb5_rc_destroy(context, rc);\n\treturn clockskew;\n\t}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":338200,"func":"bool WasmBinaryBuilder::maybeVisitAtomicNotify(Expression*& out, uint8_t code) {\n  if (code != BinaryConsts::AtomicNotify) {\n    return false;\n  }\n  auto* curr = allocator.alloc<AtomicNotify>();\n  BYN_TRACE(\"zz node: AtomicNotify\\n\");\n\n  curr->type = Type::i32;\n  curr->notifyCount = popNonVoidExpression();\n  curr->ptr = popNonVoidExpression();\n  Address readAlign;\n  readMemoryAccess(readAlign, curr->offset);\n  if (readAlign != curr->type.getByteSize()) {\n    throwError(\"Align of AtomicNotify must match size\");\n  }\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":450404,"func":"static void vnc_tight_cleanup(Notifier *n, void *value)\n{\n    g_free(color_count_palette);\n    color_count_palette = NULL;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":473987,"func":"big5_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)\n{\n  return onigenc_mb2_code_to_mbc(enc, code, buf);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":430375,"func":"char *mangle_path(char *s, const char *p, const char *esc)\n{\n\twhile (s <= p) {\n\t\tchar c = *p++;\n\t\tif (!c) {\n\t\t\treturn s;\n\t\t} else if (!strchr(esc, c)) {\n\t\t\t*s++ = c;\n\t\t} else if (s + 4 > p) {\n\t\t\tbreak;\n\t\t} else {\n\t\t\t*s++ = '\\\\';\n\t\t\t*s++ = '0' + ((c & 0300) >> 6);\n\t\t\t*s++ = '0' + ((c & 070) >> 3);\n\t\t\t*s++ = '0' + (c & 07);\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":225545,"func":"void TfLiteTensorFree(TfLiteTensor* t) {\n  TfLiteTensorDataFree(t);\n  if (t->dims) TfLiteIntArrayFree(t->dims);\n  t->dims = NULL;\n\n  if (t->dims_signature) {\n    TfLiteIntArrayFree((TfLiteIntArray *) t->dims_signature);\n  }\n  t->dims_signature = NULL;\n\n  TfLiteQuantizationFree(&t->quantization);\n  TfLiteSparsityFree(t->sparsity);\n  t->sparsity = NULL;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":387806,"func":"void InstanceKlass::deallocate_interfaces(ClassLoaderData* loader_data,\n                                          const Klass* super_klass,\n                                          Array<Klass*>* local_interfaces,\n                                          Array<Klass*>* transitive_interfaces) {\n  \/\/ Only deallocate transitive interfaces if not empty, same as super class\n  \/\/ or same as local interfaces.  See code in parseClassFile.\n  Array<Klass*>* ti = transitive_interfaces;\n  if (ti != Universe::the_empty_klass_array() && ti != local_interfaces) {\n    \/\/ check that the interfaces don't come from super class\n    Array<Klass*>* sti = (super_klass == NULL) ? NULL :\n                    InstanceKlass::cast(super_klass)->transitive_interfaces();\n    if (ti != sti && ti != NULL && !ti->is_shared()) {\n      MetadataFactory::free_array<Klass*>(loader_data, ti);\n    }\n  }\n\n  \/\/ local interfaces can be empty\n  if (local_interfaces != Universe::the_empty_klass_array() &&\n      local_interfaces != NULL && !local_interfaces->is_shared()) {\n    MetadataFactory::free_array<Klass*>(loader_data, local_interfaces);\n  }\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":462283,"func":"PJ_DEF(const char*) pj_stun_get_method_name(unsigned msg_type)\n{\n    unsigned method = PJ_STUN_GET_METHOD(msg_type);\n\n    if (method >= PJ_ARRAY_SIZE(stun_method_names))\n\treturn \"???\";\n\n    return stun_method_names[method];\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":503877,"func":"SCM_DEFINE (scm_opendir, \"opendir\", 1, 0, 0,\n\t    (SCM dirname),\n\t    \"Open the directory specified by @var{dirname} and return a directory\\n\"\n\t    \"stream.\")\n#define FUNC_NAME s_scm_opendir\n{\n  DIR *ds;\n  STRING_SYSCALL (dirname, c_dirname, ds = opendir (c_dirname));\n  if (ds == NULL)\n    SCM_SYSERROR;\n  SCM_RETURN_NEWSMOB (scm_tc16_dir | (SCM_DIR_FLAG_OPEN<<16), ds);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":246489,"func":"static RBinWasmTypeEntry *parse_type_entry(RBinWasmObj *bin, ut64 bound, ut32 index) {\n\tRBuffer *b = bin->buf;\n\tRBinWasmTypeEntry *type = R_NEW0 (RBinWasmTypeEntry);\n\tif (!type) {\n\t\treturn NULL;\n\t}\n\ttype->sec_i = index;\n\ttype->file_offset = r_buf_tell (b);\n\tif (!consume_u7_r (b, bound, &type->form)) {\n\t\tgoto beach;\n\t}\n\tif (type->form != R_BIN_WASM_VALUETYPE_FUNC) {\n\t\tR_LOG_WARN (\"Halting types section parsing at invalid type 0x%02x at offset: 0x%\" PFMTSZx \"\\n\", type->form, type->file_offset);\n\t\tgoto beach;\n\t}\n\n\ttype->args = parse_type_vector (b, bound);\n\tif (!type->args) {\n\t\tgoto beach;\n\t}\n\n\ttype->rets = parse_type_vector (b, bound);\n\tif (!type->rets) {\n\t\tgoto beach;\n\t}\n\tr_bin_wasm_type_entry_to_string (type);\n\n\treturn type;\n\nbeach:\n\tfree_type_entry (type);\n\treturn NULL;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":261960,"func":"njs_decode_hex(njs_str_t *dst, const njs_str_t *src)\n{\n    u_char        *p;\n    size_t        len;\n    njs_int_t     c;\n    njs_uint_t    i, n;\n    const u_char  *start;\n\n    n = 0;\n    p = dst->start;\n\n    start = src->start;\n    len = src->length;\n\n    for (i = 0; i < len; i++) {\n        c = njs_char_to_hex(start[i]);\n        if (njs_slow_path(c < 0)) {\n            break;\n        }\n\n        n = n * 16 + c;\n\n        if ((i & 1) != 0) {\n            *p++ = (u_char) n;\n            n = 0;\n        }\n    }\n\n    dst->length -= (dst->start + dst->length) - p;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":317198,"func":"static unsigned int selinux_ipv4_forward(void *priv,\n\t\t\t\t\t struct sk_buff *skb,\n\t\t\t\t\t const struct nf_hook_state *state)\n{\n\treturn selinux_ip_forward(skb, state->in, PF_INET);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":369145,"func":"static int io_provide_buffers(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_provide_buf *p = &req->pbuf;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct io_buffer_list *bl;\n\tint ret = 0;\n\tbool needs_lock = issue_flags & IO_URING_F_UNLOCKED;\n\n\tio_ring_submit_lock(ctx, needs_lock);\n\n\tlockdep_assert_held(&ctx->uring_lock);\n\n\tbl = io_buffer_get_list(ctx, p->bgid);\n\tif (unlikely(!bl)) {\n\t\tbl = kmalloc(sizeof(*bl), GFP_KERNEL);\n\t\tif (!bl) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto err;\n\t\t}\n\t\tio_buffer_add_list(ctx, bl, p->bgid);\n\t}\n\n\tret = io_add_buffers(ctx, p, bl);\nerr:\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\t\/* complete before unlock, IOPOLL may need the lock *\/\n\t__io_req_complete(req, issue_flags, ret, 0);\n\tio_ring_submit_unlock(ctx, needs_lock);\n\treturn 0;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":238503,"func":"static void __reg_assign_32_into_64(struct bpf_reg_state *reg)\n{\n\treg->umin_value = reg->u32_min_value;\n\treg->umax_value = reg->u32_max_value;\n\n\t\/* Attempt to pull 32-bit signed bounds into 64-bit bounds but must\n\t * be positive otherwise set to worse case bounds and refine later\n\t * from tnum.\n\t *\/\n\tif (__reg32_bound_s64(reg->s32_min_value) &&\n\t    __reg32_bound_s64(reg->s32_max_value)) {\n\t\treg->smin_value = reg->s32_min_value;\n\t\treg->smax_value = reg->s32_max_value;\n\t} else {\n\t\treg->smin_value = 0;\n\t\treg->smax_value = U32_MAX;\n\t}\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":509549,"func":"int ha_maria::end_bulk_insert()\n{\n  int first_error, error;\n  my_bool abort= file->s->deleting;\n  DBUG_ENTER(\"ha_maria::end_bulk_insert\");\n\n  if ((first_error= maria_end_bulk_insert(file, abort)))\n    abort= 1;\n\n  if ((error= maria_extra(file, HA_EXTRA_NO_CACHE, 0)))\n  {\n    first_error= first_error ? first_error : error;\n    abort= 1;\n  }\n\n  if (!abort && can_enable_indexes)\n    if ((error= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)))\n      first_error= first_error ? first_error : error;\n\n  if (bulk_insert_single_undo != BULK_INSERT_NONE)\n  {\n    \/*\n      Table was transactional just before start_bulk_insert().\n      No need to flush pages if we did a repair (which already flushed).\n    *\/\n    if ((error= _ma_reenable_logging_for_table(file,\n                                               bulk_insert_single_undo ==\n                                               BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR)))\n      first_error= first_error ? first_error : error;\n    bulk_insert_single_undo= BULK_INSERT_NONE;  \/\/ Safety\n  }\n  can_enable_indexes= 0;\n  DBUG_RETURN(first_error);\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":398534,"func":"RZ_API void rz_bin_dwarf_line_header_free_file_cache(const RzBinDwarfLineHeader *hdr, RzBinDwarfLineFileCache fnc) {\n\tif (!fnc) {\n\t\treturn;\n\t}\n\tfor (size_t i = 0; i < hdr->file_names_count; i++) {\n\t\tfree(fnc[i]);\n\t}\n\tfree(fnc);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":291793,"func":"int rtrs_clt_reconnect_from_sysfs(struct rtrs_clt_path *clt_path)\n{\n\tenum rtrs_clt_state old_state;\n\tint err = -EBUSY;\n\tbool changed;\n\n\tchanged = rtrs_clt_change_state_get_old(clt_path,\n\t\t\t\t\t\t RTRS_CLT_RECONNECTING,\n\t\t\t\t\t\t &old_state);\n\tif (changed) {\n\t\tclt_path->reconnect_attempts = 0;\n\t\tqueue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 0);\n\t}\n\tif (changed || old_state == RTRS_CLT_RECONNECTING) {\n\t\t\/*\n\t\t * flush_delayed_work() queues pending work for immediate\n\t\t * execution, so do the flush if we have queued something\n\t\t * right now or work is pending.\n\t\t *\/\n\t\tflush_delayed_work(&clt_path->reconnect_dwork);\n\t\terr = (READ_ONCE(clt_path->state) ==\n\t\t       RTRS_CLT_CONNECTED ? 0 : -ENOTCONN);\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":512481,"func":"longlong Item_func_bit_and::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  ulonglong arg1= (ulonglong) args[0]->val_int();\n  if (args[0]->null_value)\n  {\n    null_value=1; \/* purecov: inspected *\/\n    return 0; \/* purecov: inspected *\/\n  }\n  ulonglong arg2= (ulonglong) args[1]->val_int();\n  if (args[1]->null_value)\n  {\n    null_value=1; \/* purecov: inspected *\/\n    return 0; \/* purecov: inspected *\/\n  }\n  null_value=0;\n  return (longlong) (arg1 & arg2);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":404713,"func":"SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)\n{\n\treturn ksys_dup3(oldfd, newfd, flags);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":233851,"func":"void fmtutil_handle_plist(deark *c, dbuf *f, i64 pos, i64 len,\n\tde_finfo *fi, unsigned int flags)\n{\n\tif(de_get_ext_option_bool(c, \"extractplist\", 0)) {\n\t\tdbuf_create_file_from_slice(f, pos, len,\n\t\t\tfi?NULL:\"plist\", fi, DE_CREATEFLAG_IS_AUX);\n\t\treturn;\n\t}\n\n\tde_run_module_by_id_on_slice(c, \"plist\", NULL, f, pos, len);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":473833,"func":"us_ascii_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc)\n{\n    if (*p & 0x80)\n        return ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n    return ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":244248,"func":"GF_Err hnti_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":446410,"func":"static void rebase_info1_free(RzDyldRebaseInfo1 *rebase_info) {\n\tif (!rebase_info) {\n\t\treturn;\n\t}\n\tfree(rebase_info->toc);\n\tfree(rebase_info->entries);\n\tfree(rebase_info);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":459029,"func":"http_isfiltered(const struct http *fm, unsigned u, unsigned how)\n{\n\tconst char *e;\n\tconst struct http_hdrflg *f;\n\n\tif (fm->hdf[u] & HDF_FILTER)\n\t\treturn (1);\n\tif (u < HTTP_HDR_FIRST)\n\t\treturn (0);\n\te = strchr(fm->hd[u].b, ':');\n\tif (e == NULL)\n\t\treturn (0);\n\tf = http_hdr_flags(fm->hd[u].b, e);\n\treturn (f != NULL && f->flag & how);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":273932,"func":"static void handle_MLSD(ctrl_t *ctrl, char *arg)\n{\n\tlist(ctrl, arg, 3);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":273106,"func":"clock_gettime(clockid_t clock_id, struct timespec *tp)\n{\n  static int clock_init = 0;\n  static clock_serv_t clock;\n\n  mach_timespec_t mts;\n  int ret;\n\n  if (! clock_init) {\n    clock_init = 1;\n    if (host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &clock))\n      abort(); \/* unlikely *\/\n  }\n\n  if(! tp)\n    return -1;\n\n  switch (clock_id) {\n\n  case CLOCK_REALTIME:\n\n    \/* query mach for calendar time *\/\n    ret = clock_get_time(clock, &mts);\n    if (! ret) {\n      tp->tv_sec = mts.tv_sec;\n      tp->tv_nsec = mts.tv_nsec;\n    }\n    break;\n\n  case CLOCK_MONOTONIC:\n\n    \/* query mach for monotinic time *\/\n    ret = clock_get_time(clock_port, &mts);\n    if (! ret) {\n      tp->tv_sec = mts.tv_sec;\n      tp->tv_nsec = mts.tv_nsec;\n    }\n    break;\n\n  default:\n    ret = -1;\n    break;\n  }\n\n  return ret;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":387581,"func":"static int snd_ctl_elem_list_user(struct snd_card *card,\n\t\t\t\t  struct snd_ctl_elem_list __user *_list)\n{\n\tstruct snd_ctl_elem_list list;\n\tint err;\n\n\tif (copy_from_user(&list, _list, sizeof(list)))\n\t\treturn -EFAULT;\n\terr = snd_ctl_elem_list(card, &list);\n\tif (err)\n\t\treturn err;\n\tif (copy_to_user(_list, &list, sizeof(list)))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":235251,"func":"static bool check_buffer(struct torture_context *tctx,\n\t\t\t uint8_t *buf, unsigned int seed, int len, const char *location)\n{\n\tint i;\n\tsrandom(seed);\n\tfor (i=0;i<len;i++) {\n\t\tuint8_t v = random();\n\t\tif (buf[i] != v) {\n\t\t\ttorture_fail(tctx, talloc_asprintf(tctx, \"Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\\n\",\n\t\t\t       location, i, buf[i], v));\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":338238,"func":"uint16_t WasmBinaryBuilder::getInt16() {\n  BYN_TRACE(\"<==\\n\");\n  auto ret = uint16_t(getInt8());\n  ret |= uint16_t(getInt8()) << 8;\n  BYN_TRACE(\"getInt16: \" << ret << \"\/0x\" << std::hex << ret << std::dec\n                         << \" ==>\\n\");\n  return ret;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":247130,"func":"static Bool gf_fsess_get_user_pass(void *usr_cbk, const char *site_url, char *usr_name, char *password)\n{\n\tGF_Event evt;\n\tGF_FilterSession *fsess = (GF_FilterSession *)usr_cbk;\n\tevt.type = GF_EVENT_AUTHORIZATION;\n\tevt.auth.site_url = site_url;\n\tevt.auth.user = usr_name;\n\tevt.auth.password = password;\n\treturn gf_fs_forward_gf_event(fsess, &evt, GF_FALSE, GF_FALSE);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":386569,"func":"void DL_Dxf::addDimLinear(DL_CreationInterface* creationInterface) {\n    DL_DimensionData d = getDimData();\n\n    \/\/ horizontal \/ vertical \/ rotated dimension:\n    DL_DimLinearData dl(\n        \/\/ definition point 1\n        getRealValue(13, 0.0),\n        getRealValue(23, 0.0),\n        getRealValue(33, 0.0),\n        \/\/ definition point 2\n        getRealValue(14, 0.0),\n        getRealValue(24, 0.0),\n        getRealValue(34, 0.0),\n        \/\/ angle\n        getRealValue(50, 0.0),\n        \/\/ oblique\n        getRealValue(52, 0.0));\n    creationInterface->addDimLinear(d, dl);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":90874,"func":"  const GURL& lru_origin() const { return lru_origin_; }\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":455317,"func":"set_bash_input ()\n{\n  \/* Make sure the fd from which we are reading input is not in\n     no-delay mode. *\/\n#if defined (BUFFERED_INPUT)\n  if (interactive == 0)\n    sh_unset_nodelay_mode (default_buffered_input);\n  else\n#endif \/* !BUFFERED_INPUT *\/\n    sh_unset_nodelay_mode (fileno (stdin));\n\n  \/* with_input_from_stdin really means `with_input_from_readline' *\/\n  if (interactive && no_line_editing == 0)\n    with_input_from_stdin ();\n#if defined (BUFFERED_INPUT)\n  else if (interactive == 0)\n    with_input_from_buffered_stream (default_buffered_input, dollar_vars[0]);\n#endif \/* BUFFERED_INPUT *\/\n  else\n    with_input_from_stream (default_input, dollar_vars[0]);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":236128,"func":"GF_Err styl_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_TextStyleBox*ptr = (GF_TextStyleBox*)s;\n\tISOM_DECREASE_SIZE(ptr, 2);\n\tptr->entry_count = gf_bs_read_u16(bs);\n\n\tif (ptr->size \/ GPP_STYLE_SIZE < ptr->entry_count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tif (ptr->entry_count) {\n\t\tptr->styles = (GF_StyleRecord*)gf_malloc(sizeof(GF_StyleRecord)*ptr->entry_count);\n\t\tif (!ptr->styles) return GF_OUT_OF_MEM;\n\t\tfor (i=0; i<ptr->entry_count; i++) {\n\t\t\tISOM_DECREASE_SIZE(ptr, GPP_STYLE_SIZE);\n\t\t\tgpp_read_style(bs, &ptr->styles[i]);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":294548,"func":"d_lite_friday_p(VALUE self)\n{\n    get_d1(self);\n    return f_boolcast(m_wday(dat) == 5);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":246238,"func":"inline float randRange(float min, float max) {\n  return min+((float)rand()\/(float)RAND_MAX)*(max-min);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":264718,"func":"void FindConstantFoldableNodes(\n    const Graph* graph, const ConstantFoldingOptions& opts,\n    std::vector<Node*>* nodes,\n    std::unordered_map<const Node*, gtl::FlatSet<Node*>>* constant_control_deps,\n    std::unordered_map<const Node*, std::vector<Tensor>>*\n        shape_replacement_map) {\n  bool internal_node_inserted = false;\n  \/\/ Walk the nodes in data flow order.\n  ReverseDFS(\n      *graph, nullptr,\n      [nodes, constant_control_deps, shape_replacement_map,\n       &internal_node_inserted, &opts](Node* n) {\n        ConsiderConstantFoldableNode(n, opts, nodes, constant_control_deps,\n                                     shape_replacement_map,\n                                     &internal_node_inserted);\n      },\n      NodeComparatorName());\n  \/\/ If we have inserted just leaf level nodes, then there is nothing to fold.\n  if (!internal_node_inserted) {\n    nodes->clear();\n    constant_control_deps->clear();\n  }\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":462261,"func":"static pj_status_t decode_unknown_attr(pj_pool_t *pool, \n\t\t\t\t       const pj_uint8_t *buf, \n\t\t\t\t       const pj_stun_msg_hdr *msghdr, \n\t\t\t\t       void **p_attr)\n{\n    pj_stun_unknown_attr *attr;\n    const pj_uint16_t *punk_attr;\n    unsigned i;\n\n    PJ_UNUSED_ARG(msghdr);\n\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_unknown_attr);\n    GETATTRHDR(buf, &attr->hdr);\n \n    attr->attr_count = (attr->hdr.length >> 1);\n    if (attr->attr_count > PJ_STUN_MAX_ATTR)\n\treturn PJ_ETOOMANY;\n\n    punk_attr = (const pj_uint16_t*)(buf + ATTR_HDR_LEN);\n    for (i=0; i<attr->attr_count; ++i) {\n\tattr->attrs[i] = pj_ntohs(punk_attr[i]);\n    }\n\n    \/* Done *\/\n    *p_attr = attr;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":294619,"func":"c_valid_start_p(double sg)\n{\n    if (isnan(sg))\n\treturn 0;\n    if (isinf(sg))\n\treturn 1;\n    if (sg < REFORM_BEGIN_JD || sg > REFORM_END_JD)\n\treturn 0;\n    return 1;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":498135,"func":"void html_hidden(const char *name, const char *value)\n{\n\thtml(\"<input type='hidden' name='\");\n\thtml_attr(name);\n\thtml(\"' value='\");\n\thtml_attr(value);\n\thtml(\"'\/>\");\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":308181,"func":"static struct fastrpc_session_ctx *fastrpc_session_alloc(\n\t\t\t\t\tstruct fastrpc_channel_ctx *cctx)\n{\n\tstruct fastrpc_session_ctx *session = NULL;\n\tunsigned long flags;\n\tint i;\n\n\tspin_lock_irqsave(&cctx->lock, flags);\n\tfor (i = 0; i < cctx->sesscount; i++) {\n\t\tif (!cctx->session[i].used && cctx->session[i].valid) {\n\t\t\tcctx->session[i].used = true;\n\t\t\tsession = &cctx->session[i];\n\t\t\tbreak;\n\t\t}\n\t}\n\tspin_unlock_irqrestore(&cctx->lock, flags);\n\n\treturn session;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":512752,"func":"  int save_in_field(Field *field_arg, bool no_conversions)\n  {\n    return field_arg->save_in_field_ignore_value(false);\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":256999,"func":"static void route4_bind_class(void *fh, u32 classid, unsigned long cl, void *q,\n\t\t\t      unsigned long base)\n{\n\tstruct route4_filter *f = fh;\n\n\tif (f && f->res.classid == classid) {\n\t\tif (cl)\n\t\t\t__tcf_bind_filter(q, &f->res, base);\n\t\telse\n\t\t\t__tcf_unbind_filter(q, &f->res);\n\t}\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":225780,"func":"\nGF_Box *fiin_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(FDItemInformationBox, GF_ISOM_BOX_TYPE_FIIN);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":401573,"func":"static void __init init_std_data(struct entropy_store *r)\n{\n\tint i;\n\tktime_t now = ktime_get_real();\n\tunsigned long rv;\n\n\tmix_pool_bytes(r, &now, sizeof(now));\n\tfor (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) {\n\t\tif (!arch_get_random_seed_long(&rv) &&\n\t\t    !arch_get_random_long(&rv))\n\t\t\trv = random_get_entropy();\n\t\tmix_pool_bytes(r, &rv, sizeof(rv));\n\t}\n\tmix_pool_bytes(r, utsname(), sizeof(*(utsname())));\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":222910,"func":"  NodeContext* GetNodeContext(const NodeDef* node) {\n    auto it = node_to_context_.find(node);\n    if (it == node_to_context_.end()) {\n      return nullptr;\n    }\n    return &it->second;\n  }","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":437281,"func":"set_optimize_map(regex_t* reg, OptMap* m)\n{\n  int i;\n\n  for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)\n    reg->map[i] = m->map[i];\n\n  reg->optimize   = OPTIMIZE_MAP;\n  reg->dmin       = m->mmd.min;\n  reg->dmax       = m->mmd.max;\n\n  if (reg->dmin != INFINITE_LEN) {\n    reg->threshold_len = reg->dmin + 1;\n  }\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":247549,"func":"TEST_P(SslSocketTest, GetNoUriWithDnsSan) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_dns_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n)EOF\";\n\n  \/\/ The SAN field only has DNS, expect \"\" for uriSanPeerCertificate().\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedSerialNumber(TEST_SAN_DNS_CERT_SERIAL));\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":474001,"func":"mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end ARG_UNUSED,\n\t      UChar* lower, OnigEncoding enc ARG_UNUSED)\n{\n  const UChar* p = *pp;\n\n  if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    *lower++ = 's';\n    *lower   = 's';\n    (*pp)++;\n    return 2;\n  }\n\n  *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p);\n  (*pp)++;\n  return 1;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":455307,"func":"history_completion_generator (hint_text, state)\n     const char *hint_text;\n     int state;\n{\n  static int local_index, len;\n  static const char *text;\n\n  \/* If this is the first call to the generator, then initialize the\n     list of strings to complete over. *\/\n  if (state == 0)\n    {\n      if (dabbrev_expand_active)\t\/* This is kind of messy *\/\n\trl_completion_suppress_append = 1;\n      local_index = 0;\n      build_history_completion_array ();\n      text = hint_text;\n      len = strlen (text);\n    }\n\n  while (history_completion_array && history_completion_array[local_index])\n    {\n      \/* XXX - should this use completion-ignore-case? *\/\n      if (strncmp (text, history_completion_array[local_index++], len) == 0)\n\treturn (savestring (history_completion_array[local_index - 1]));\n    }\n  return ((char *)NULL);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":259290,"func":"static int64_t get_stream_info_time(MOVFragmentStreamInfo * frag_stream_info)\n{\n    av_assert0(frag_stream_info);\n    if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)\n        return frag_stream_info->sidx_pts;\n    if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE)\n        return frag_stream_info->first_tfra_pts;\n    return frag_stream_info->tfdt_dts;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":487636,"func":"asmlinkage long sys_setfsuid(uid_t uid)\n{\n\tint old_fsuid;\n\n\told_fsuid = current->fsuid;\n\tif (security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS))\n\t\treturn old_fsuid;\n\n\tif (uid == current->uid || uid == current->euid ||\n\t    uid == current->suid || uid == current->fsuid || \n\t    capable(CAP_SETUID)) {\n\t\tif (uid != old_fsuid) {\n\t\t\tcurrent->mm->dumpable = suid_dumpable;\n\t\t\tsmp_wmb();\n\t\t}\n\t\tcurrent->fsuid = uid;\n\t}\n\n\tkey_fsuid_changed(current);\n\tproc_id_connector(current, PROC_EVENT_UID);\n\n\tsecurity_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);\n\n\treturn old_fsuid;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":359347,"func":"DEFUN (clear_bgp_peer_in_prefix_filter,\n       clear_bgp_peer_in_prefix_filter_cmd,\n       \"clear bgp (A.B.C.D|X:X::X:X) in prefix-filter\",\n       CLEAR_STR\n       BGP_STR\n       \"BGP neighbor address to clear\\n\"\n       \"BGP IPv6 neighbor to clear\\n\"\n       \"Soft reconfig inbound update\\n\"\n       \"Push out the existing ORF prefix-list\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,\n\t\t\tBGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":508784,"func":"static int rr_index(READ_RECORD *info)\n{\n  int tmp= info->table->file->ha_index_next(info->record);\n  if (tmp)\n    tmp= rr_handle_error(info, tmp);\n  return tmp;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":274872,"func":"TEST(ComparisonsTest, GreaterQuantizedSmallRange) {\n  ComparisonOpModel model({TensorType_UINT8, {1, 2, 2, 1}, 0.0, 1.0},\n                          {TensorType_UINT8, {1, 2, 2, 1}, 0.0, 2.0},\n                          TensorType_UINT8, BuiltinOperator_GREATER);\n  model.QuantizeAndPopulate<uint8_t>(model.input1(), {1.0, 0.5, 0.35, 0.1});\n  model.QuantizeAndPopulate<uint8_t>(model.input2(), {1.01, 0.25, 0.3, 0.4});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, true, false));\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":436125,"func":" *\/\nstatic int io_timeout_remove(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_timeout_rem *tr = &req->timeout_rem;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tint ret;\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tif (!(req->timeout_rem.flags & IORING_TIMEOUT_UPDATE))\n\t\tret = io_timeout_cancel(ctx, tr->addr);\n\telse\n\t\tret = io_timeout_update(ctx, tr->addr, &tr->ts,\n\t\t\t\t\tio_translate_timeout_mode(tr->flags));\n\n\tio_cqring_fill_event(ctx, req->user_data, ret, 0);\n\tio_commit_cqring(ctx);\n\tspin_unlock_irq(&ctx->completion_lock);\n\tio_cqring_ev_posted(ctx);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_put_req(req);\n\treturn 0;","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":359513,"func":"DEFUN (no_bgp_log_neighbor_changes,\n       no_bgp_log_neighbor_changes_cmd,\n       \"no bgp log-neighbor-changes\",\n       NO_STR\n       \"BGP specific commands\\n\"\n       \"Log neighbor up\/down and reset reason\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":512408,"func":"  virtual void make_send_field(THD *thd, Send_field *field)\n  { orig_item->make_send_field(thd, field); }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":450386,"func":"static void vnc_zrle_start(VncState *vs)\n{\n    buffer_reset(&vs->zrle->zrle);\n\n    \/* make the output buffer be the zlib buffer, so we can compress it later *\/\n    vs->zrle->tmp = vs->output;\n    vs->output = vs->zrle->zrle;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":229309,"func":"std::unique_ptr<cql_server::response> cql_server::connection::make_unavailable_error(int16_t stream, exceptions::exception_code err, sstring msg, db::consistency_level cl, int32_t required, int32_t alive, const tracing::trace_state_ptr& tr_state) const\n{\n    auto response = std::make_unique<cql_server::response>(stream, cql_binary_opcode::ERROR, tr_state);\n    response->write_int(static_cast<int32_t>(err));\n    response->write_string(msg);\n    response->write_consistency(cl);\n    response->write_int(required);\n    response->write_int(alive);\n    return response;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":462574,"func":"void controller::mark_all_read(unsigned int pos) {\n\tif (pos < feeds.size()) {\n\t\tscope_measure m(\"controller::mark_all_read\");\n\t\tstd::lock_guard<std::mutex> feedslock(feeds_mutex);\n\t\tstd::shared_ptr<rss_feed> feed = feeds[pos];\n\t\tif (feed->rssurl().substr(0,6) == \"query:\") {\n\t\t\trsscache->mark_all_read(feed);\n\t\t} else {\n\t\t\trsscache->mark_all_read(feed->rssurl());\n\t\t\tif (api) {\n\t\t\t\tapi->mark_all_read(feed->rssurl());\n\t\t\t}\n\t\t}\n\t\tm.stopover(\"after rsscache->mark_all_read, before iteration over items\");\n\t\tstd::lock_guard<std::mutex> lock(feed->item_mutex);\n\t\tstd::vector<std::shared_ptr<rss_item>>& items = feed->items();\n\t\tif (items.size() > 0) {\n\t\t\tbool notify = items[0]->feedurl() != feed->rssurl();\n\t\t\tLOG(level::DEBUG, \"controller::mark_all_read: notify = %s\", notify ? \"yes\" : \"no\");\n\t\t\tfor (auto item : items) {\n\t\t\t\titem->set_unread_nowrite_notify(false, notify);\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":353162,"func":"void SplashOutputDev::endType3Char(GfxState *state) {\n  T3GlyphStack *t3gs;\n\n  if (t3GlyphStack->cacheTag) {\n    --nestCount;\n    memcpy(t3GlyphStack->cacheData, bitmap->getDataPtr(),\n\t   t3GlyphStack->cache->glyphSize);\n    delete bitmap;\n    delete splash;\n    bitmap = t3GlyphStack->origBitmap;\n    splash = t3GlyphStack->origSplash;\n    const double *ctm = state->getCTM();\n    state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3],\n\t\t  t3GlyphStack->origCTM4, t3GlyphStack->origCTM5);\n    updateCTM(state, 0, 0, 0, 0, 0, 0);\n    drawType3Glyph(state, t3GlyphStack->cache,\n\t\t   t3GlyphStack->cacheTag, t3GlyphStack->cacheData);\n  }\n  t3gs = t3GlyphStack;\n  t3GlyphStack = t3gs->next;\n  delete t3gs;\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":427186,"func":"static int searchvar (FuncState *fs, TString *n, expdesc *var) {\n  int i;\n  for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) {\n    Vardesc *vd = getlocalvardesc(fs, i);\n    if (eqstr(n, vd->vd.name)) {  \/* found? *\/\n      if (vd->vd.kind == RDKCTC)  \/* compile-time constant? *\/\n        init_exp(var, VCONST, fs->firstlocal + i);\n      else  \/* real variable *\/\n        init_var(fs, var, i);\n      return var->k;\n    }\n  }\n  return -1;  \/* not found *\/\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":218799,"func":"static void XDrawBeveledMatte(Display *display,const XWindowInfo *window_info,\n  const XWidgetInfo *matte_info)\n{\n  \/*\n    Draw matte.\n  *\/\n  XDrawBevel(display,window_info,matte_info);\n  XDrawMatte(display,window_info,matte_info);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":447073,"func":"    long FileIo::read(byte* buf, long rcount)\n    {\n        assert(p_->fp_ != 0);\n        if (p_->switchMode(Impl::opRead) != 0) return 0;\n        return (long)std::fread(buf, 1, rcount, p_->fp_);\n    }","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":254720,"func":"njs_typed_array_prototype_byte_offset(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    size_t             byte_offset;\n    njs_value_t        *this;\n    njs_typed_array_t  *array;\n\n    this = njs_argument(args, 0);\n    if (!njs_is_typed_array(this) && !njs_is_data_view(this)) {\n        njs_type_error(vm, \"Method TypedArray.prototype.byteOffset called \"\n                       \"on incompatible receiver\");\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(this);\n    byte_offset = njs_typed_array_offset(array);\n\n    if (njs_slow_path(njs_is_detached_buffer(array->buffer))) {\n        if (njs_is_data_view(this)) {\n            njs_type_error(vm, \"detached buffer\");\n            return NJS_ERROR;\n        }\n\n        byte_offset = 0;\n    }\n\n    njs_set_number(&vm->retval, byte_offset);\n\n    return NJS_OK;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":346432,"func":"sourcing_a_script(exarg_T *eap)\n{\n    return (getline_equal(eap->getline, eap->cookie, getsourceline));\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":384294,"func":"gs_heap_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,\n                         client_name_t cname)\n{\n    ulong lsize = (ulong) num_elements * elt_size;\n\n    if (lsize != (uint) lsize)\n        return 0;\n    return gs_heap_alloc_bytes(mem, (uint) lsize, cname);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":270395,"func":"void ok_inflater_free(ok_inflater *inflater) {\n    if (inflater) {\n        ok_png_allocator allocator = inflater->allocator;\n        void *allocator_user_data = inflater->allocator_user_data;\n        allocator.free(allocator_user_data, inflater->buffer);\n        allocator.free(allocator_user_data, inflater->code_length_huffman);\n        allocator.free(allocator_user_data, inflater->literal_huffman);\n        allocator.free(allocator_user_data, inflater->distance_huffman);\n        allocator.free(allocator_user_data, inflater->fixed_literal_huffman);\n        allocator.free(allocator_user_data, inflater->fixed_distance_huffman);\n        allocator.free(allocator_user_data, inflater);\n    }\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":337796,"func":"static void *sctp_addto_param(struct sctp_chunk *chunk, int len,\n\t\t\t      const void *data)\n{\n\tint chunklen = ntohs(chunk->chunk_hdr->length);\n\tvoid *target;\n\n\ttarget = skb_put(chunk->skb, len);\n\n\tif (data)\n\t\tmemcpy(target, data, len);\n\telse\n\t\tmemset(target, 0, len);\n\n\t\/* Adjust the chunk length field.  *\/\n\tchunk->chunk_hdr->length = htons(chunklen + len);\n\tchunk->chunk_end = skb_tail_pointer(chunk->skb);\n\n\treturn target;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":455323,"func":"_cygwin32_check_tmp ()\n{\n  struct stat sb;\n\n  if (stat (\"\/tmp\", &sb) < 0)\n    internal_warning (_(\"could not find \/tmp, please create!\"));\n  else\n    {\n      if (S_ISDIR (sb.st_mode) == 0)\n\tinternal_warning (_(\"\/tmp must be a valid directory name\"));\n    }\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":222573,"func":"  string Name(int node_index, int output_index) const {\n    if (output_index == 0) {\n      return Name(node_index);\n    } else {\n      return strings::StrCat(Name(node_index), \":\", output_index);\n    }\n  }","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":289328,"func":"static int _snd_pcm_hw_param_max(struct snd_pcm_hw_params *params,\n\t\t\t\t snd_pcm_hw_param_t var, unsigned int val,\n\t\t\t\t int dir)\n{\n\tint changed;\n\tint open = 0;\n\tif (dir) {\n\t\tif (dir < 0) {\n\t\t\topen = 1;\n\t\t} else if (dir > 0) {\n\t\t\topen = 1;\n\t\t\tval++;\n\t\t}\n\t}\n\tif (hw_is_mask(var)) {\n\t\tif (val == 0 && open) {\n\t\t\tsnd_mask_none(hw_param_mask(params, var));\n\t\t\tchanged = -EINVAL;\n\t\t} else\n\t\t\tchanged = snd_mask_refine_max(hw_param_mask(params, var),\n\t\t\t\t\t\t      val - !!open);\n\t} else if (hw_is_interval(var))\n\t\tchanged = snd_interval_refine_max(hw_param_interval(params, var),\n\t\t\t\t\t\t  val, open);\n\telse\n\t\treturn -EINVAL;\n\tif (changed > 0) {\n\t\tparams->cmask |= 1 << var;\n\t\tparams->rmask |= 1 << var;\n\t}\n\treturn changed;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":231738,"func":"  virtual void initializeServerHandshake() {\n    fakeHandshake = new FakeServerHandshake(\n        server->getNonConstConn(), getFizzServerContext());\n  }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":234250,"func":"print_dwarf_view (dwarf_vma value, unsigned num_bytes, int force)\n{\n  int len;\n  if (!num_bytes)\n    len = 4;\n  else\n    len = num_bytes * 2;\n\n  assert (value == (unsigned long) value);\n  if (value || force)\n    printf (\"v%0*lx \", len - 1, (unsigned long) value);\n  else\n    printf (\"%*s\", len + 1, \"\");\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":245178,"func":"parse_show_engine_innodb_status(MYSQL *connection)\n{\n\tMYSQL_RES *mysql_result;\n\tMYSQL_ROW row;\n\n\tmysql_result = xb_mysql_query(connection, \"SHOW ENGINE INNODB STATUS\",\n\t\t\t\t      true);\n\n\tut_ad(mysql_num_fields(mysql_result) == 3);\n\n\tif ((row = mysql_fetch_row(mysql_result))) {\n\t\tstd::stringstream data(row[2]);\n\t\tstd::string line;\n\n\t\twhile (std::getline(data, line)) {\n\t\t\tlsn_t lsn;\n\t\t\tif (sscanf(line.c_str(), \"Log flushed up to \" LSN_PF,\n\t\t\t\t   &lsn) == 1) {\n\t\t\t\tbackup_redo_log_flushed_lsn = lsn;\n\t\t\t}\n\t\t}\n\t}\n\n\tmysql_free_result(mysql_result);\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":294612,"func":"c_gregorian_last_day_of_month(int y, int m)\n{\n    assert(m >= 1 && m <= 12);\n    return monthtab[c_gregorian_leap_p(y) ? 1 : 0][m];\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":317260,"func":"static void smack_task_getsecid_obj(struct task_struct *p, u32 *secid)\n{\n\tstruct smack_known *skp = smk_of_task_struct_obj(p);\n\n\t*secid = skp->smk_secid;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":226957,"func":"IRC_PROTOCOL_CALLBACK(error)\n{\n    char *ptr_args;\n\n    IRC_PROTOCOL_MIN_ARGS(2);\n\n    ptr_args = (argv_eol[1][0] == ':') ? argv_eol[1] + 1 : argv_eol[1];\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, NULL, NULL, NULL),\n        \"%s%s\",\n        weechat_prefix (\"error\"),\n        ptr_args);\n\n    if (strncmp (ptr_args, \"Closing Link\", 12) == 0)\n    {\n        irc_server_disconnect (server, !server->is_connected, 1);\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":476139,"func":"static int fill_ext_compat(struct usb_configuration *c, u8 *buf)\n{\n\tint i, count;\n\n\tcount = 16;\n\tbuf += 16;\n\tfor (i = 0; i < c->next_interface_id; ++i) {\n\t\tstruct usb_function *f;\n\t\tint j;\n\n\t\tf = c->interface[i];\n\t\tfor (j = 0; j < f->os_desc_n; ++j) {\n\t\t\tstruct usb_os_desc *d;\n\n\t\t\tif (i != f->os_desc_table[j].if_id)\n\t\t\t\tcontinue;\n\t\t\td = f->os_desc_table[j].os_desc;\n\t\t\tif (d && d->ext_compat_id) {\n\t\t\t\t*buf++ = i;\n\t\t\t\t*buf++ = 0x01;\n\t\t\t\tmemcpy(buf, d->ext_compat_id, 16);\n\t\t\t\tbuf += 22;\n\t\t\t} else {\n\t\t\t\t++buf;\n\t\t\t\t*buf = 0x01;\n\t\t\t\tbuf += 23;\n\t\t\t}\n\t\t\tcount += 24;\n\t\t\tif (count + 24 >= USB_COMP_EP0_OS_DESC_BUFSIZ)\n\t\t\t\treturn count;\n\t\t}\n\t}\n\n\treturn count;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":312591,"func":"incr_quickfix_busy(void)\n{\n    quickfix_busy++;\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":455311,"func":"unset_bash_input (check_zero)\n     int check_zero;\n{\n#if defined (BUFFERED_INPUT)\n  if ((check_zero && default_buffered_input >= 0) ||\n      (check_zero == 0 && default_buffered_input > 0))\n    {\n      close_buffered_fd (default_buffered_input);\n      default_buffered_input = bash_input.location.buffered_fd = -1;\n      bash_input.type = st_none;\t\t\/* XXX *\/\n    }\n#else \/* !BUFFERED_INPUT *\/\n  if (default_input)\n    {\n      fclose (default_input);\n      default_input = (FILE *)NULL;\n    }\n#endif \/* !BUFFERED_INPUT *\/\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":421381,"func":"static void slist(int d, js_Ast *list)\n{\n\tpc('[');\n\twhile (list) {\n\t\tassert(list->type == AST_LIST);\n\t\tsnode(d, list->a);\n\t\tlist = list->b;\n\t\tif (list)\n\t\t\tpc(' ');\n\t}\n\tpc(']');\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":247339,"func":"static int pgpPrtSigParams(pgpTag tag, uint8_t pubkey_algo,\n\t\tconst uint8_t *p, const uint8_t *h, size_t hlen,\n\t\tpgpDigParams sigp)\n{\n    int rc = 1; \/* assume failure *\/\n    const uint8_t * pend = h + hlen;\n    int i;\n    pgpDigAlg sigalg = pgpSignatureNew(pubkey_algo);\n\n    for (i = 0; i < sigalg->mpis && pend - p >= 2; i++) {\n\tint mpil = pgpMpiLen(p);\n\tif (pend - p < mpil)\n\t    break;\n\tif (sigalg->setmpi(sigalg, i, p))\n\t    break;\n\tp += mpil;\n    }\n\n    \/* Does the size and number of MPI's match our expectations? *\/\n    if (p == pend && i == sigalg->mpis)\n\trc = 0;\n    \n    \/* We can't handle more than one sig at a time *\/\n    if (rc == 0 && sigp->alg == NULL && sigp->tag == PGPTAG_SIGNATURE)\n\tsigp->alg = sigalg;\n    else\n\tpgpDigAlgFree(sigalg);\n\n    return rc;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":337780,"func":"static struct sctp_chunk *sctp_make_op_error_space(\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst struct sctp_chunk *chunk,\n\t\t\t\t\tsize_t size)\n{\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_control(asoc, SCTP_CID_ERROR, 0,\n\t\t\t\t   sizeof(struct sctp_errhdr) + size,\n\t\t\t\t   GFP_ATOMIC);\n\tif (!retval)\n\t\tgoto nodata;\n\n\t\/* RFC 2960 6.4 Multi-homed SCTP Endpoints\n\t *\n\t * An endpoint SHOULD transmit reply chunks (e.g., SACK,\n\t * HEARTBEAT ACK, etc.) to the same destination transport\n\t * address from which it received the DATA or control chunk\n\t * to which it is replying.\n\t *\n\t *\/\n\tif (chunk)\n\t\tretval->transport = chunk->transport;\n\nnodata:\n\treturn retval;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":434102,"func":"get_arglist(garray_T *gap, char_u *str, int escaped)\n{\n    ga_init2(gap, (int)sizeof(char_u *), 20);\n    while (*str != NUL)\n    {\n\tif (ga_grow(gap, 1) == FAIL)\n\t{\n\t    ga_clear(gap);\n\t    return FAIL;\n\t}\n\t((char_u **)gap->ga_data)[gap->ga_len++] = str;\n\n\t\/\/ If str is escaped, don't handle backslashes or spaces\n\tif (!escaped)\n\t    return OK;\n\n\t\/\/ Isolate one argument, change it in-place, put a NUL after it.\n\tstr = do_one_arg(str);\n    }\n    return OK;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":309951,"func":"mypair(int fg, int bg)\n{\n    int result;\n#if HAVE_ALLOC_PAIR\n    if (x_option) {\n\tresult = alloc_pair(fg, bg);\n    } else\n#endif\n    {\n\tint pair = (fg * COLORS) + bg;\n\tresult = (pair >= COLOR_PAIRS) ? -1 : pair;\n    }\n    return result;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":359571,"func":"DEFUN (no_bgp_redistribute_ipv6_metric,\n       no_bgp_redistribute_ipv6_metric_cmd,\n       \"no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>\",\n       NO_STR\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPFv3)\\n\"\n       \"Routing Information Protocol (RIPng)\\n\"\n       \"Static routes\\n\"\n       \"Metric for redistributed routes\\n\"\n       \"Default metric\\n\")\n{\n  int type;\n\n  type = bgp_str2route_type (AFI_IP6, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":387607,"func":"int snd_ctl_request_layer(const char *module_name)\n{\n\tstruct snd_ctl_layer_ops *lops;\n\n\tif (module_name == NULL)\n\t\treturn 0;\n\tdown_read(&snd_ctl_layer_rwsem);\n\tfor (lops = snd_ctl_layer; lops; lops = lops->next)\n\t\tif (strcmp(lops->module_name, module_name) == 0)\n\t\t\tbreak;\n\tup_read(&snd_ctl_layer_rwsem);\n\tif (lops)\n\t\treturn 0;\n\treturn request_module(module_name);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":254746,"func":"njs_typed_array_compare_u16(const void *a, const void *b, void *c)\n{\n    return *((const uint16_t *) a) - *((const uint16_t *) b);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":348443,"func":"static int ax_set_mac_address(struct net_device *dev, void *addr)\n{\n\tstruct sockaddr_ax25 *sa = addr;\n\n\tnetif_tx_lock_bh(dev);\n\tnetif_addr_lock(dev);\n\t__dev_addr_set(dev, &sa->sax25_call, AX25_ADDR_LEN);\n\tnetif_addr_unlock(dev);\n\tnetif_tx_unlock_bh(dev);\n\n\treturn 0;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":466101,"func":"static unsigned seg_override(struct x86_emulate_ctxt *ctxt)\n{\n\tif (!ctxt->has_seg_override)\n\t\treturn 0;\n\n\treturn ctxt->seg_override;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":353155,"func":"void SplashOutputDev::updateCTM(GfxState *state, double m11, double m12,\n\t\t\t\tdouble m21, double m22,\n\t\t\t\tdouble m31, double m32) {\n  SplashCoord mat[6];\n\n  const double *ctm = state->getCTM();\n  mat[0] = (SplashCoord)ctm[0];\n  mat[1] = (SplashCoord)ctm[1];\n  mat[2] = (SplashCoord)ctm[2];\n  mat[3] = (SplashCoord)ctm[3];\n  mat[4] = (SplashCoord)ctm[4];\n  mat[5] = (SplashCoord)ctm[5];\n  splash->setMatrix(mat);\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":384817,"func":"f_tempname(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    static int\tx = 'A';\n\n    rettv->v_type = VAR_STRING;\n    rettv->vval.v_string = vim_tempname(x, FALSE);\n\n    \/\/ Advance 'x' to use A-Z and 0-9, so that there are at least 34 different\n    \/\/ names.  Skip 'I' and 'O', they are used for shell redirection.\n    do\n    {\n\tif (x == 'Z')\n\t    x = '0';\n\telse if (x == '9')\n\t    x = 'A';\n\telse\n\t    ++x;\n    } while (x == 'I' || x == 'O');\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":293530,"func":"PJ_DEF(void) pj_scan_get_until_ch( pj_scanner *scanner, \n\t\t\t\t   int until_char, pj_str_t *out)\n{\n    register char *s = scanner->curptr;\n\n    if (s >= scanner->end) {\n\tpj_scan_syntax_err(scanner);\n\treturn;\n    }\n\n    while (PJ_SCAN_CHECK_EOF(s) && *s != until_char) {\n\t++s;\n    }\n\n    pj_strset3(out, scanner->curptr, s);\n\n    scanner->curptr = s;\n\n    if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {\n\tpj_scan_skip_whitespace(scanner);\n    }\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":261398,"func":"void initialize_CABAC_models(thread_context* tctx)\n{\n  const int QPY = tctx->shdr->SliceQPY;\n  const int initType = tctx->shdr->initType;\n  assert(initType >= 0 && initType <= 2);\n\n  tctx->ctx_model.init(initType, QPY);\n\n  for (int i=0;i<4;i++) {\n    tctx->StatCoeff[i] = 0;\n  }\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":337795,"func":"static int sctp_process_missing_param(const struct sctp_association *asoc,\n\t\t\t\t      enum sctp_param paramtype,\n\t\t\t\t      struct sctp_chunk *chunk,\n\t\t\t\t      struct sctp_chunk **errp)\n{\n\tstruct __sctp_missing report;\n\t__u16 len;\n\n\tlen = SCTP_PAD4(sizeof(report));\n\n\t\/* Make an ERROR chunk, preparing enough room for\n\t * returning multiple unknown parameters.\n\t *\/\n\tif (!*errp)\n\t\t*errp = sctp_make_op_error_space(asoc, chunk, len);\n\n\tif (*errp) {\n\t\treport.num_missing = htonl(1);\n\t\treport.type = paramtype;\n\t\tsctp_init_cause(*errp, SCTP_ERROR_MISS_PARAM,\n\t\t\t\tsizeof(report));\n\t\tsctp_addto_chunk(*errp, sizeof(report), &report);\n\t}\n\n\t\/* Stop processing this chunk. *\/\n\treturn 0;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":90793,"func":"void QuotaManagerProxy::NotifyOriginInUse(\n    const GURL& origin) {\n  if (!io_thread_->BelongsToCurrentThread()) {\n    io_thread_->PostTask(FROM_HERE, NewRunnableMethod(\n        this, &QuotaManagerProxy::NotifyOriginInUse, origin));\n    return;\n  }\n  if (manager_)\n    manager_->NotifyOriginInUse(origin);\n}\n","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":373532,"func":"ipf_expiry_list_add(struct ovs_list *frag_exp_list, struct ipf_list *ipf_list,\n                    long long now)\n   \/* OVS_REQUIRES(ipf->ipf_lock) *\/\n{\n    enum {\n        IPF_FRAG_LIST_TIMEOUT = 15000,\n    };\n\n    ipf_list->expiration = now + IPF_FRAG_LIST_TIMEOUT;\n    ovs_list_push_back(frag_exp_list, &ipf_list->list_node);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":224996,"func":"PQreset(PGconn *conn)\n{\n\tif (conn)\n\t{\n\t\tclosePGconn(conn);\n\n\t\tif (connectDBStart(conn) && connectDBComplete(conn))\n\t\t{\n\t\t\t\/*\n\t\t\t * Notify event procs of successful reset.  We treat an event proc\n\t\t\t * failure as disabling the connection ... good idea?\n\t\t\t *\/\n\t\t\tint\t\t\ti;\n\n\t\t\tfor (i = 0; i < conn->nEvents; i++)\n\t\t\t{\n\t\t\t\tPGEventConnReset evt;\n\n\t\t\t\tevt.conn = conn;\n\t\t\t\tif (!conn->events[i].proc(PGEVT_CONNRESET, &evt,\n\t\t\t\t\t\t\t\t\t\t  conn->events[i].passThrough))\n\t\t\t\t{\n\t\t\t\t\tconn->status = CONNECTION_BAD;\n\t\t\t\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t\t\t\t  libpq_gettext(\"PGEventProc \\\"%s\\\" failed during PGEVT_CONNRESET event\\n\"),\n\t\t\t\t\t\t\t\t\t  conn->events[i].name);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":512475,"func":"  Item_datetime_literal_for_invalid_dates(THD *thd,\n                                          const Datetime *ltime, uint dec_arg)\n   :Item_datetime_literal(thd, ltime, dec_arg)\n  {\n    maybe_null= false;\n  }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":224992,"func":"PQparameterStatus(const PGconn *conn, const char *paramName)\n{\n\tconst pgParameterStatus *pstatus;\n\n\tif (!conn || !paramName)\n\t\treturn NULL;\n\tfor (pstatus = conn->pstatus; pstatus != NULL; pstatus = pstatus->next)\n\t{\n\t\tif (strcmp(pstatus->name, paramName) == 0)\n\t\t\treturn pstatus->value;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":234189,"func":"parse_gnu_debuglink (struct dwarf_section * section, void * data)\n{\n  const char *     name;\n  unsigned int     crc_offset;\n  unsigned long *  crc32 = (unsigned long *) data;\n\n  \/* The name is first.\n     The CRC value is stored after the filename, aligned up to 4 bytes.  *\/\n  name = (const char *) section->start;\n\n  crc_offset = strnlen (name, section->size) + 1;\n  if (crc_offset == 1)\n    return NULL;\n  crc_offset = (crc_offset + 3) & ~3;\n  if (crc_offset + 4 > section->size)\n    return NULL;\n\n  * crc32 = byte_get (section->start + crc_offset, 4);\n  return name;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":294630,"func":"d_lite_next(VALUE self)\n{\n    return d_lite_next_day(0, (VALUE *)NULL, self);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":214948,"func":"static int qh_help(int sd, char *buf, unsigned int len)\n{\n\tstruct query_handler *qh = NULL;\n\n\tif (!*buf || !strcmp(buf, \"help\")) {\n\t\tnsock_printf_nul(sd,\n\t\t\t\"  help <name>   show help for handler <name>\\n\"\n\t\t\t\"  help list     list registered handlers\\n\");\n\t\treturn 0;\n\t}\n\n\tif (!strcmp(buf, \"list\")) {\n\n\t\tfor (qh = qhandlers; qh != NULL; qh = qh->next_qh) {\n\t\t\tnsock_printf(sd, \"%-10s %s\\n\", qh->name, qh->description ? qh->description : \"(No description available)\");\n\t\t}\n\n\t\tnsock_printf(sd, \"%c\", 0);\n\t\treturn 0;\n\t}\n\n\tqh = qh_find_handler(buf);\n\tif (qh == NULL) {\n\n\t\tnsock_printf_nul(sd, \"No handler named '%s' is registered\\n\", buf);\n\n\t} else if (qh->handler(sd, \"help\", 4) > 200) {\n\n\t\tnsock_printf_nul(sd, \"The handler %s doesn't have any help yet.\", buf);\n\t}\n\n\treturn 0;\n}","target":1,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":404746,"func":"static inline void __range_cloexec(struct files_struct *cur_fds,\n\t\t\t\t   unsigned int fd, unsigned int max_fd)\n{\n\tstruct fdtable *fdt;\n\n\t\/* make sure we're using the correct maximum value *\/\n\tspin_lock(&cur_fds->file_lock);\n\tfdt = files_fdtable(cur_fds);\n\tmax_fd = min(last_fd(fdt), max_fd);\n\tif (fd <= max_fd)\n\t\tbitmap_set(fdt->close_on_exec, fd, max_fd - fd + 1);\n\tspin_unlock(&cur_fds->file_lock);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":267860,"func":"void MultiplySum(const size_t xsize,\n                 const pixel_type* const JXL_RESTRICT row_in,\n                 const pixel_type* const JXL_RESTRICT row_in_Y,\n                 const float factor, float* const JXL_RESTRICT row_out) {\n  const HWY_FULL(float) df;\n  const Rebind<pixel_type, HWY_FULL(float)> di;  \/\/ assumes pixel_type <= float\n  const auto factor_v = Set(df, factor);\n  for (size_t x = 0; x < xsize; x += Lanes(di)) {\n    const auto in = Load(di, row_in + x) + Load(di, row_in_Y + x);\n    const auto out = ConvertTo(df, in) * factor_v;\n    Store(out, df, row_out + x);\n  }\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":355628,"func":"partial_free(partial_T *pt)\n{\n    int i;\n\n    for (i = 0; i < pt->pt_argc; ++i)\n\tclear_tv(&pt->pt_argv[i]);\n    vim_free(pt->pt_argv);\n    dict_unref(pt->pt_dict);\n    if (pt->pt_name != NULL)\n    {\n\tfunc_unref(pt->pt_name);\n\tvim_free(pt->pt_name);\n    }\n    else\n\tfunc_ptr_unref(pt->pt_func);\n\n    \/\/ \"out_up\" is no longer used, decrement refcount on partial that owns it.\n    partial_unref(pt->pt_outer.out_up_partial);\n\n    \/\/ Decrease the reference count for the context of a closure.  If down\n    \/\/ to the minimum it may be time to free it.\n    if (pt->pt_funcstack != NULL)\n    {\n\t--pt->pt_funcstack->fs_refcount;\n\tfuncstack_check_refcount(pt->pt_funcstack);\n    }\n\n    vim_free(pt);\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":328835,"func":"R_API void r_bin_java_print_methodhandle_cp_summary(RBinJavaCPTypeObj *obj) {\n\tut8 ref_kind;\n\tif (!obj) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaCPTypeObj*  RBinJavaCPTypeMethodHandle.\\n\");\n\t\treturn;\n\t}\n\tref_kind = obj->info.cp_method_handle.reference_kind;\n\teprintf (\"MethodHandle ConstantPool Type (%d) \", obj->metas->ord);\n\teprintf (\"\tOffset: 0x%08\"PFMT64x\"\", obj->file_offset);\n\teprintf (\"\tReference Kind = (0x%02x) %s\\n\", ref_kind, R_BIN_JAVA_REF_METAS[ref_kind].name);\n\teprintf (\"\tReference Index = %d\\n\", obj->info.cp_method_handle.reference_index);\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":208987,"func":"PlayerGeneric::~PlayerGeneric()\n{\n\tif (mixer)\n\t\tdelete mixer;\n\n\tif (player)\n\t{\n\t\tif (mixer->isActive() && !mixer->isDeviceRemoved(player))\n\t\t\tmixer->removeDevice(player);\n\t\tdelete player;\n\t}\n\n\tdelete[] audioDriverName;\n\t\n\tdelete listener;\n}","target":1,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":261764,"func":"void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const std::string &buffer, uint32_t stamp, int chunk_id) {\n    sendRtmp(type, stream_index, std::make_shared<BufferString>(buffer), stamp, chunk_id);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":226260,"func":"GF_Err ccst_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_CodingConstraintsBox *ptr = (GF_CodingConstraintsBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->all_ref_pics_intra = gf_bs_read_int(bs, 1);\n\tptr->intra_pred_used = gf_bs_read_int(bs, 1);\n\tptr->max_ref_per_pic = gf_bs_read_int(bs, 4);\n\tptr->reserved = gf_bs_read_int(bs, 26);\n\treturn GF_OK;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":328987,"func":"R_API void r_bin_java_print_methodtype_cp_summary(RBinJavaCPTypeObj *obj) {\n\tif (!obj) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaCPTypeObj*  RBinJavaCPTypeMethodType.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"MethodType ConstantPool Type (%d) \", obj->metas->ord);\n\tprintf (\"  Offset: 0x%08\"PFMT64x \"\", obj->file_offset);\n\tprintf (\"  Descriptor Index = 0x%02x\\n\", obj->info.cp_method_type.descriptor_index);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":349527,"func":"static void virtbt_tx_done(struct virtqueue *vq)\n{\n\tstruct sk_buff *skb;\n\tunsigned int len;\n\n\twhile ((skb = virtqueue_get_buf(vq, &len)))\n\t\tkfree_skb(skb);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":244093,"func":"GF_Box *tsro_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TimeOffHintEntryBox, GF_ISOM_BOX_TYPE_TSRO);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":336513,"func":"SPICE_GNUC_VISIBLE int spice_server_add_ssl_client(SpiceServer *reds, int socket, int skip_auth)\n{\n    RedLinkInfo *link;\n\n    if (!(link = reds_init_client_ssl_connection(reds, socket))) {\n        return -1;\n    }\n\n    link->skip_auth = skip_auth;\n    return 0;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":244060,"func":"GF_Err paen_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":508909,"func":"static LEX_STRING get_quoted_token(Lex_input_stream *lip,\n                                   uint skip,\n                                   uint length, char quote)\n{\n  LEX_STRING tmp;\n  const char *from, *end;\n  char *to;\n  lip->yyUnget();                       \/\/ ptr points now after last token char\n  tmp.length= length;\n  tmp.str=(char*) lip->m_thd->alloc(tmp.length+1);\n  from= lip->get_tok_start() + skip;\n  to= tmp.str;\n  end= to+length;\n\n  lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;\n  lip->m_cpp_text_end= lip->m_cpp_text_start + length;\n\n  for ( ; to != end; )\n  {\n    if ((*to++= *from++) == quote)\n    {\n      from++;\t\t\t\t\t\/\/ Skip double quotes\n      lip->m_cpp_text_start++;\n    }\n  }\n  *to= 0;\t\t\t\t\t\/\/ End null for safety\n  return tmp;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":226318,"func":"\nGF_Box *fecr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(FECReservoirBox, GF_ISOM_BOX_TYPE_FECR);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":224481,"func":"GF_Err txtin_initialize(GF_Filter *filter)\n{\n\tchar data[1];\n\tGF_TXTIn *ctx = gf_filter_get_udta(filter);\n\tctx->bs_w = gf_bs_new(data, 1, GF_BITSTREAM_WRITE);\n\n\treturn GF_OK;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":409439,"func":"cursor_off(void)\n{\n    if (full_screen && !cursor_is_off)\n    {\n\tout_str(T_VI);\t    \/\/ disable cursor\n\tcursor_is_off = TRUE;\n    }\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":364786,"func":"matching_line_len(char_u *lbuf)\n{\n    char_u\t*p = lbuf + 1;\n\n    \/\/ does the same thing as parse_match()\n    p += STRLEN(p) + 1;\n#ifdef FEAT_EMACS_TAGS\n    p += STRLEN(p) + 1;\n#endif\n    return (p - lbuf) + STRLEN(p);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":247335,"func":"static int getKeyID(const uint8_t *h, size_t hlen, pgpKeyID_t keyid)\n{\n    uint8_t *fp = NULL;\n    size_t fplen = 0;\n    int rc = pgpPubkeyFingerprint(h, hlen, &fp, &fplen);\n    if (fp && fplen > 8) {\n\tmemcpy(keyid, (fp + (fplen-8)), 8);\n\tfree(fp);\n    }\n    return rc;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":404191,"func":"static BOOL recurse_check_bit(compiler_common *common, sljit_sw bit_index)\n{\nuint8_t *byte;\nuint8_t mask;\n\nSLJIT_ASSERT((bit_index & (sizeof(sljit_sw) - 1)) == 0);\n\nbit_index >>= SLJIT_WORD_SHIFT;\n\nmask = 1 << (bit_index & 0x7);\nbyte = common->recurse_bitset + (bit_index >> 3);\n\nif (*byte & mask)\n  return FALSE;\n\n*byte |= mask;\nreturn TRUE;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":242928,"func":"  Index operator()(const CPUDevice &d,\n                   typename TTypes<Index>::ConstMatrix indices,\n                   typename TTypes<T>::ConstFlat updates,\n                   typename TTypes<T, NDIMS>::Tensor out) {\n    Eigen::array<Eigen::DenseIndex, NDIMS> idx;\n    const int num_nnz = static_cast<int>(indices.dimension(0));\n    for (int i = 0; i < num_nnz; ++i) {\n      for (int d = 0; d < NDIMS; ++d) {\n        idx[d] = internal::SubtleMustCopy(indices(i, d));\n        if (!FastBoundsCheck(idx[d], out.dimension(d))) {\n          return d;  \/\/ on failure: d nonnegative\n        }\n      }\n      out(idx) += updates(i);\n    }\n    return -1;  \/\/ on success\n  }","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":326088,"func":"regoptail(char_u *p, char_u *val)\n{\n    \/\/ When op is neither BRANCH nor BRACE_COMPLEX0-9, it is \"operandless\"\n    if (p == NULL || p == JUST_CALC_SIZE\n\t    || (OP(p) != BRANCH\n\t\t&& (OP(p) < BRACE_COMPLEX || OP(p) > BRACE_COMPLEX + 9)))\n\treturn;\n    regtail(OPERAND(p), val);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":359245,"func":"DEFUN (clear_ip_bgp_all_vpnv4_soft_out,\n       clear_ip_bgp_all_vpnv4_soft_out_cmd,\n       \"clear ip bgp * vpnv4 unicast soft out\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Address family\\n\"\n       \"Address Family Modifier\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,\n\t\t\tBGP_CLEAR_SOFT_OUT, NULL);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":413353,"func":"PHP_FUNCTION(snmp_set_valueretrieval)\n{\n\tlong method;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &method) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (method >= 0 && method <= (SNMP_VALUE_LIBRARY|SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT)) {\n\t\t\tSNMP_G(valueretrieval) = method;\n\t\t\tRETURN_TRUE;\n\t} else {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unknown SNMP value retrieval method '%ld'\", method);\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":139239,"func":"  explicit OverlayWindowFrameView(views::Widget* widget) : widget_(widget) {}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":446098,"func":"static void atusb_work_urbs(struct work_struct *work)\n{\n\tstruct atusb *atusb =\n\t    container_of(to_delayed_work(work), struct atusb, work);\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\tstruct urb *urb;\n\tint ret;\n\n\tif (atusb->shutdown)\n\t\treturn;\n\n\tdo {\n\t\turb = usb_get_from_anchor(&atusb->idle_urbs);\n\t\tif (!urb)\n\t\t\treturn;\n\t\tret = atusb_submit_rx_urb(atusb, urb);\n\t} while (!ret);\n\n\tusb_anchor_urb(urb, &atusb->idle_urbs);\n\tdev_warn_ratelimited(&usb_dev->dev,\n\t\t\t     \"atusb_in: can't allocate\/submit URB (%d)\\n\", ret);\n\tschedule_delayed_work(&atusb->work,\n\t\t\t      msecs_to_jiffies(ATUSB_ALLOC_DELAY_MS) + 1);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":387565,"func":"int snd_ctl_create(struct snd_card *card)\n{\n\tstatic const struct snd_device_ops ops = {\n\t\t.dev_free = snd_ctl_dev_free,\n\t\t.dev_register =\tsnd_ctl_dev_register,\n\t\t.dev_disconnect = snd_ctl_dev_disconnect,\n\t};\n\tint err;\n\n\tif (snd_BUG_ON(!card))\n\t\treturn -ENXIO;\n\tif (snd_BUG_ON(card->number < 0 || card->number >= SNDRV_CARDS))\n\t\treturn -ENXIO;\n\n\tsnd_device_initialize(&card->ctl_dev, card);\n\tdev_set_name(&card->ctl_dev, \"controlC%d\", card->number);\n\n\terr = snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops);\n\tif (err < 0)\n\t\tput_device(&card->ctl_dev);\n\treturn err;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":336637,"func":"static RedClient *reds_get_client(RedsState *reds)\n{\n    spice_assert(reds->clients.size() <= 1);\n\n    if (reds->clients.empty()) {\n        return NULL;\n    }\n\n    return *reds->clients.begin();\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":508875,"func":"void st_select_lex::print_order(String *str,\n                                ORDER *order,\n                                enum_query_type query_type)\n{\n  for (; order; order= order->next)\n  {\n    if (order->counter_used)\n    {\n      char buffer[20];\n      size_t length= my_snprintf(buffer, 20, \"%d\", order->counter);\n      str->append(buffer, (uint) length);\n    }\n    else\n    {\n      \/* replace numeric reference with equivalent for ORDER constant *\/\n      if (order->item[0]->type() == Item::INT_ITEM &&\n          order->item[0]->basic_const_item())\n      {\n        \/* make it expression instead of integer constant *\/\n        str->append(STRING_WITH_LEN(\"''\"));\n      }\n      else\n        (*order->item)->print(str, query_type);\n    }\n    if (order->direction == ORDER::ORDER_DESC)\n       str->append(STRING_WITH_LEN(\" desc\"));\n    if (order->next)\n      str->append(',');\n  }\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":226276,"func":"GF_Err payt_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 len;\n\tGF_Err e;\n\tGF_PAYTBox *ptr = (GF_PAYTBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->payloadCode);\n    len = ptr->payloadString ? (u32) strlen(ptr->payloadString) : 0;\n\tgf_bs_write_u8(bs, len);\n\tif (len) gf_bs_write_data(bs, ptr->payloadString, len);\n\treturn GF_OK;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":241312,"func":"mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *argv)\n{\n  mrb_value obj;\n  mrb_sym mid;\n\n  obj = mrb_instance_alloc(mrb, mrb_obj_value(c));\n  mid = MRB_SYM(initialize);\n  if (!mrb_func_basic_p(mrb, obj, mid, mrb_do_nothing)) {\n    mrb_funcall_argv(mrb, obj, mid, argc, argv);\n  }\n  return obj;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":313824,"func":"nv_search(cmdarg_T *cap)\n{\n    oparg_T\t*oap = cap->oap;\n    pos_T\tsave_cursor = curwin->w_cursor;\n\n    if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13)\n    {\n\t\/\/ Translate \"g??\" to \"g?g?\"\n\tcap->cmdchar = 'g';\n\tcap->nchar = '?';\n\tnv_operator(cap);\n\treturn;\n    }\n\n    \/\/ When using 'incsearch' the cursor may be moved to set a different search\n    \/\/ start position.\n    cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, 0);\n\n    if (cap->searchbuf == NULL)\n    {\n\tclearop(oap);\n\treturn;\n    }\n\n    (void)normal_search(cap, cap->cmdchar, cap->searchbuf,\n\t\t\t(cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor))\n\t\t\t\t\t\t      ? 0 : SEARCH_MARK, NULL);\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":337812,"func":"int sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,\n\t\t    size_t paylen)\n{\n\tstruct sctp_errhdr err;\n\t__u16 len;\n\n\t\/* Cause code constants are now defined in network order.  *\/\n\terr.cause = cause_code;\n\tlen = sizeof(err) + paylen;\n\terr.length = htons(len);\n\n\tif (skb_tailroom(chunk->skb) < len)\n\t\treturn -ENOSPC;\n\n\tchunk->subh.err_hdr = sctp_addto_chunk(chunk, sizeof(err), &err);\n\n\treturn 0;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":345216,"func":"unsigned short *set_translate(int m, struct vc_data *vc)\n{\n\tinv_translate[vc->vc_num] = m;\n\treturn translations[m];\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":238396,"func":"njs_function_rest_parameters_init(njs_vm_t *vm, njs_native_frame_t *frame)\n{\n    uint32_t     length;\n    njs_uint_t   nargs, n, i;\n    njs_array_t  *array;\n    njs_value_t  *rest_arguments;\n\n    nargs = frame->nargs;\n    n = frame->function->u.lambda->nargs;\n    length = (nargs >= n) ? (nargs - n + 1) : 0;\n\n    array = njs_array_alloc(vm, 1, length, 0);\n    if (njs_slow_path(array == NULL)) {\n        return NJS_ERROR;\n    }\n\n    for (i = 0; i < length; i++) {\n        array->start[i] = frame->arguments[i + n - 1];\n    }\n\n    rest_arguments = njs_mp_alloc(vm->mem_pool, sizeof(njs_value_t));\n    if (njs_slow_path(rest_arguments == NULL)) {\n        return NJS_ERROR;\n    }\n\n    \/* GC: retain. *\/\n    njs_set_array(rest_arguments, array);\n\n    vm->top_frame->local[n] = rest_arguments;\n\n    return NJS_OK;\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":329902,"func":"_cairo_image_mask_compositor_get (void)\n{\n    static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;\n    static cairo_mask_compositor_t compositor;\n\n    if (_cairo_atomic_init_once_enter(&once)) {\n\t_cairo_mask_compositor_init (&compositor,\n\t\t\t\t     _cairo_image_traps_compositor_get ());\n\tcompositor.acquire = acquire;\n\tcompositor.release = release;\n\tcompositor.set_clip_region = set_clip_region;\n\tcompositor.pattern_to_surface = _cairo_image_source_create_for_pattern;\n\tcompositor.draw_image_boxes = draw_image_boxes;\n\tcompositor.fill_rectangles = fill_rectangles;\n\tcompositor.fill_boxes = fill_boxes;\n\tcompositor.check_composite = check_composite;\n\tcompositor.composite = composite;\n\t\/\/compositor.lerp = lerp;\n\t\/\/compositor.check_composite_boxes = check_composite_boxes;\n\tcompositor.composite_boxes = composite_boxes;\n\tcompositor.check_composite_glyphs = check_composite_glyphs;\n\tcompositor.composite_glyphs = composite_glyphs;\n\n\t_cairo_atomic_init_once_leave(&once);\n    }\n\n    return &compositor.base;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":455308,"func":"maybe_make_readline_line (new_line)\n     char *new_line;\n{\n  if (new_line && strcmp (new_line, rl_line_buffer) != 0)\n    {\n      rl_point = rl_end;\n\n      rl_add_undo (UNDO_BEGIN, 0, 0, 0);\n      rl_delete_text (0, rl_point);\n      rl_point = rl_end = rl_mark = 0;\n      rl_insert_text (new_line);\n      rl_add_undo (UNDO_END, 0, 0, 0);\n    }\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":312537,"func":"qf_free_fields(qffields_T *pfields)\n{\n    vim_free(pfields->namebuf);\n    vim_free(pfields->module);\n    vim_free(pfields->errmsg);\n    vim_free(pfields->pattern);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":343121,"func":"static int esp_output_tcp_finish(struct xfrm_state *x, struct sk_buff *skb)\n{\n\tstruct sock *sk;\n\tint err;\n\n\trcu_read_lock();\n\n\tsk = esp_find_tcp_sk(x);\n\terr = PTR_ERR_OR_ZERO(sk);\n\tif (err)\n\t\tgoto out;\n\n\tbh_lock_sock(sk);\n\tif (sock_owned_by_user(sk))\n\t\terr = espintcp_queue_out(sk, skb);\n\telse\n\t\terr = espintcp_push_skb(sk, skb);\n\tbh_unlock_sock(sk);\n\nout:\n\trcu_read_unlock();\n\treturn err;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":243987,"func":"GF_Box *saio_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleAuxiliaryInfoOffsetBox, GF_ISOM_BOX_TYPE_SAIO);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":225835,"func":"void mdhd_box_del(GF_Box *s)\n{\n\tGF_MediaHeaderBox *ptr = (GF_MediaHeaderBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":513160,"func":"static double *mysql_sys_var_double(THD* thd, int offset)\n{\n  return (double *) intern_sys_var_ptr(thd, offset, true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":384190,"func":"static bool nft_setelem_valid_key_end(const struct nft_set *set,\n\t\t\t\t      struct nlattr **nla, u32 flags)\n{\n\tif ((set->flags & (NFT_SET_CONCAT | NFT_SET_INTERVAL)) ==\n\t\t\t  (NFT_SET_CONCAT | NFT_SET_INTERVAL)) {\n\t\tif (flags & NFT_SET_ELEM_INTERVAL_END)\n\t\t\treturn false;\n\t\tif (!nla[NFTA_SET_ELEM_KEY_END] &&\n\t\t    !(flags & NFT_SET_ELEM_CATCHALL))\n\t\t\treturn false;\n\t} else {\n\t\tif (nla[NFTA_SET_ELEM_KEY_END])\n\t\t\treturn false;\n\t}\n\n\treturn true;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":432242,"func":"MemoryRegionSection memory_region_find(MemoryRegion *mr,\n                                       hwaddr addr, uint64_t size)\n{\n    MemoryRegionSection ret;\n\n    ret = memory_region_find_rcu(mr, addr, size);\n    return ret;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":458297,"func":"int ioprio_best(unsigned short aprio, unsigned short bprio)\n{\n\tunsigned short aclass;\n\tunsigned short bclass;\n\n\tif (!ioprio_valid(aprio))\n\t\taprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);\n\tif (!ioprio_valid(bprio))\n\t\tbprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);\n\n\taclass = IOPRIO_PRIO_CLASS(aprio);\n\tbclass = IOPRIO_PRIO_CLASS(bprio);\n\tif (aclass == bclass)\n\t\treturn min(aprio, bprio);\n\tif (aclass > bclass)\n\t\treturn bprio;\n\telse\n\t\treturn aprio;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":366177,"func":"bool path_is_under(const struct path *path1, const struct path *path2)\n{\n\tbool res;\n\tread_seqlock_excl(&mount_lock);\n\tres = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2);\n\tread_sequnlock_excl(&mount_lock);\n\treturn res;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":225734,"func":"void srpp_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":385855,"func":"static int complete_walk(struct nameidata *nd)\n{\n\tstruct dentry *dentry = nd->path.dentry;\n\tint status;\n\n\tif (nd->flags & LOOKUP_RCU) {\n\t\tnd->flags &= ~LOOKUP_RCU;\n\t\tif (!(nd->flags & LOOKUP_ROOT))\n\t\t\tnd->root.mnt = NULL;\n\t\tspin_lock(&dentry->d_lock);\n\t\tif (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) {\n\t\t\tspin_unlock(&dentry->d_lock);\n\t\t\tunlock_rcu_walk();\n\t\t\treturn -ECHILD;\n\t\t}\n\t\tBUG_ON(nd->inode != dentry->d_inode);\n\t\tspin_unlock(&dentry->d_lock);\n\t\tmntget(nd->path.mnt);\n\t\tunlock_rcu_walk();\n\t}\n\n\tif (likely(!(nd->flags & LOOKUP_JUMPED)))\n\t\treturn 0;\n\n\tif (likely(!(dentry->d_flags & DCACHE_OP_WEAK_REVALIDATE)))\n\t\treturn 0;\n\n\tstatus = dentry->d_op->d_weak_revalidate(dentry, nd->flags);\n\tif (status > 0)\n\t\treturn 0;\n\n\tif (!status)\n\t\tstatus = -ESTALE;\n\n\tpath_put(&nd->path);\n\treturn status;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":307863,"func":"ciInstance* ciEnv::ClassCastException_instance() {\n  if (_ClassCastException_instance == NULL) {\n    _ClassCastException_instance\n          = get_or_create_exception(_ClassCastException_handle,\n          vmSymbols::java_lang_ClassCastException());\n  }\n  return _ClassCastException_instance;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":359664,"func":"DEFUN (no_neighbor_route_map,\n       no_neighbor_route_map_cmd,\n       NO_NEIGHBOR_CMD2 \"route-map WORD (in|out|import|export)\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Apply route map to neighbor\\n\"\n       \"Name of route map\\n\"\n       \"Apply map to incoming routes\\n\"\n       \"Apply map to outbound routes\\n\"\n       \"Apply map to routes going into a Route-Server client's table\\n\"\n       \"Apply map to routes coming from a Route-Server client\")\n{\n  return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t   bgp_node_safi (vty), argv[2]);\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":344747,"func":"monotime_ts(struct timespec *ts)\n{\n\tstruct timeval tv;\n#if defined(HAVE_CLOCK_GETTIME) && (defined(CLOCK_BOOTTIME) || \\\n    defined(CLOCK_MONOTONIC) || defined(CLOCK_REALTIME))\n\tstatic int gettime_failed = 0;\n\n\tif (!gettime_failed) {\n# ifdef CLOCK_BOOTTIME\n\t\tif (clock_gettime(CLOCK_BOOTTIME, ts) == 0)\n\t\t\treturn;\n# endif \/* CLOCK_BOOTTIME *\/\n# ifdef CLOCK_MONOTONIC\n\t\tif (clock_gettime(CLOCK_MONOTONIC, ts) == 0)\n\t\t\treturn;\n# endif \/* CLOCK_MONOTONIC *\/\n# ifdef CLOCK_REALTIME\n\t\t\/* Not monotonic, but we're almost out of options here. *\/\n\t\tif (clock_gettime(CLOCK_REALTIME, ts) == 0)\n\t\t\treturn;\n# endif \/* CLOCK_REALTIME *\/\n\t\tdebug3(\"clock_gettime: %s\", strerror(errno));\n\t\tgettime_failed = 1;\n\t}\n#endif \/* HAVE_CLOCK_GETTIME && (BOOTTIME || MONOTONIC || REALTIME) *\/\n\tgettimeofday(&tv, NULL);\n\tts->tv_sec = tv.tv_sec;\n\tts->tv_nsec = (long)tv.tv_usec * 1000;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":488431,"func":"static int fallback_migrate_page(struct address_space *mapping,\n\tstruct page *newpage, struct page *page)\n{\n\tif (PageDirty(page))\n\t\treturn writeout(mapping, page);\n\n\t\/*\n\t * Buffers may be managed in a filesystem specific way.\n\t * We must have no buffers or drop them.\n\t *\/\n\tif (PagePrivate(page) &&\n\t    !try_to_release_page(page, GFP_KERNEL))\n\t\treturn -EAGAIN;\n\n\treturn migrate_page(mapping, newpage, page);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":285147,"func":"static void __free_resource_entry(void *entry) {\n\tr_ne_resource_entry *en = (r_ne_resource_entry *)entry;\n\tfree (en->name);\n\tfree (en);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":220221,"func":"AttrValue* Node::AddAttrHelper(const std::string& name) {\n  MaybeCopyOnWrite();\n  return &((*props_->node_def.mutable_attr())[name]);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":336598,"func":"static void reds_cleanup_net(SpiceServer *reds)\n{\n    if (reds->listen_socket != -1) {\n       red_watch_remove(reds->listen_watch);\n       if (reds->config->spice_listen_socket_fd != reds->listen_socket) {\n          socket_close(reds->listen_socket);\n       }\n       reds->listen_watch = NULL;\n       reds->listen_socket = -1;\n    }\n    if (reds->secure_listen_socket != -1) {\n       red_watch_remove(reds->secure_listen_watch);\n       socket_close(reds->secure_listen_socket);\n       reds->secure_listen_watch = NULL;\n       reds->secure_listen_socket = -1;\n    }\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":257003,"func":"static void route4_delete_filter_work(struct work_struct *work)\n{\n\tstruct route4_filter *f = container_of(to_rcu_work(work),\n\t\t\t\t\t       struct route4_filter,\n\t\t\t\t\t       rwork);\n\trtnl_lock();\n\t__route4_delete_filter(f);\n\trtnl_unlock();\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":244112,"func":"GF_Err jp2h_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":436056,"func":"\nstatic int __io_uring_add_tctx_node(struct io_ring_ctx *ctx)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\tstruct io_tctx_node *node;\n\tint ret;\n\n\tif (unlikely(!tctx)) {\n\t\tret = io_uring_alloc_task_context(current, ctx);\n\t\tif (unlikely(ret))\n\t\t\treturn ret;\n\t\ttctx = current->io_uring;\n\t}\n\tif (!xa_load(&tctx->xa, (unsigned long)ctx)) {\n\t\tnode = kmalloc(sizeof(*node), GFP_KERNEL);\n\t\tif (!node)\n\t\t\treturn -ENOMEM;\n\t\tnode->ctx = ctx;\n\t\tnode->task = current;\n\n\t\tret = xa_err(xa_store(&tctx->xa, (unsigned long)ctx,\n\t\t\t\t\tnode, GFP_KERNEL));\n\t\tif (ret) {\n\t\t\tkfree(node);\n\t\t\treturn ret;\n\t\t}\n\n\t\tmutex_lock(&ctx->uring_lock);\n\t\tlist_add(&node->ctx_node, &ctx->tctx_list);\n\t\tmutex_unlock(&ctx->uring_lock);\n\t}\n\ttctx->last = ctx;\n\treturn 0;","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":253529,"func":"smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)\n{\n\tswitch (optype) {\n\tcase CIFS_ECHO_OP:\n\t\treturn &server->echo_credits;\n\tcase CIFS_OBREAK_OP:\n\t\treturn &server->oplock_credits;\n\tdefault:\n\t\treturn &server->credits;\n\t}\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":338220,"func":"Type WasmBinaryBuilder::getType() { return getType(getS32LEB()); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":512503,"func":"  Tmp_field_src()\n   :m_field(0),\n    m_default_field(0),\n    m_item_result_field(0)\n  { }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":225056,"func":"PQsocket(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn -1;\n\treturn (conn->sock != PGINVALID_SOCKET) ? conn->sock : -1;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":513030,"func":"  Item_args(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e)\n  {\n    arg_count= 5;\n    if (likely((args= (Item**) thd_alloc(thd, sizeof(Item*) * 5))))\n    {\n      arg_count= 5;\n      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;\n    }\n  }","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":312424,"func":"qf_get_nth_valid_entry(qf_list_T *qfl, int n, int fdo)\n{\n    qfline_T\t*qfp;\n    int\t\ti, eidx;\n    int\t\tprev_fnum = 0;\n\n    \/\/ check if the list has valid errors\n    if (!qf_list_has_valid_entries(qfl))\n\treturn 1;\n\n    eidx = 0;\n    FOR_ALL_QFL_ITEMS(qfl, qfp, i)\n    {\n\tif (qfp->qf_valid)\n\t{\n\t    if (fdo)\n\t    {\n\t\tif (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum)\n\t\t{\n\t\t    \/\/ Count the number of files\n\t\t    eidx++;\n\t\t    prev_fnum = qfp->qf_fnum;\n\t\t}\n\t    }\n\t    else\n\t\teidx++;\n\t}\n\n\tif (eidx == n)\n\t    break;\n    }\n\n    if (i <= qfl->qf_count)\n\treturn i;\n    else\n\treturn 1;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":216812,"func":"int setup_tests(void)\n{\n    ADD_ALL_TESTS(call_run_cert, OSSL_NELEM(name_fns));\n    return 1;\n}","target":1,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":442818,"func":"output_expected(const char* url, const char* uploadfile)\n{\n  if(!uploadfile)\n    return TRUE;  \/* download *\/\n  if(checkprefix(\"http:\/\/\", url) || checkprefix(\"https:\/\/\", url))\n    return TRUE;   \/* HTTP(S) upload *\/\n\n  return FALSE; \/* non-HTTP upload, probably no output should be expected *\/\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":512623,"func":"  Item *grouping_field_transformer_for_where(THD *thd, uchar *arg)\n  { return convert_to_basic_const_item(thd); }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":292244,"func":"find_unused_session (server *serv)\n{\n\tsession *sess;\n\tGSList *list = sess_list;\n\twhile (list)\n\t{\n\t\tsess = (session *) list->data;\n\t\tif (sess->type == SESS_CHANNEL && sess->channel[0] == 0 &&\n\t\t\t sess->server == serv)\n\t\t{\n\t\t\tif (sess->waitchannel[0] == 0)\n\t\t\t\treturn sess;\n\t\t}\n\t\tlist = list->next;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":255030,"func":"static int adts_write_header(AVFormatContext *s)\n{\n    ADTSContext *adts = s->priv_data;\n\n    if (adts->id3v2tag)\n        ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC);\n\n    return 0;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":508785,"func":"int rr_sequential(READ_RECORD *info)\n{\n  int tmp;\n  while ((tmp= info->table->file->ha_rnd_next(info->record)))\n  {\n    \/*\n      rnd_next can return RECORD_DELETED for MyISAM when one thread is\n      reading and another deleting without locks.\n    *\/\n    if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED))\n    {\n      tmp= rr_handle_error(info, tmp);\n      break;\n    }\n  }\n  return tmp;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":263501,"func":"static void sco_conn_del(struct hci_conn *hcon, int err)\n{\n\tstruct sco_conn *conn = hcon->sco_data;\n\tstruct sock *sk;\n\n\tif (!conn)\n\t\treturn;\n\n\tBT_DBG(\"hcon %p conn %p, err %d\", hcon, conn, err);\n\n\t\/* Kill socket *\/\n\tsco_conn_lock(conn);\n\tsk = conn->sk;\n\tsco_conn_unlock(conn);\n\n\tif (sk) {\n\t\tsock_hold(sk);\n\t\tlock_sock(sk);\n\t\tsco_sock_clear_timer(sk);\n\t\tsco_chan_del(sk, err);\n\t\trelease_sock(sk);\n\t\tsock_put(sk);\n\n\t\t\/* Ensure no more work items will run before freeing conn. *\/\n\t\tcancel_delayed_work_sync(&conn->timeout_work);\n\t}\n\n\thcon->sco_data = NULL;\n\tkfree(conn);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":220454,"func":"  static bool Run(OpKernelContext* ctx, const Tensor& input,\n                  const Tensor& filter, int batch, int input_rows,\n                  int input_cols, int in_depth, int filter_rows,\n                  int filter_cols, int pad_rows, int pad_cols, int out_rows,\n                  int \/*out_cols*\/, int \/*out_depth*\/, int \/*dilation_rows*\/,\n                  int \/*dilation_cols*\/, int \/*stride_rows*\/,\n                  int \/*stride_cols*\/, Tensor* \/*output*\/,\n                  TensorFormat \/*data_format*\/) {\n    return false;\n  }","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":310313,"func":"dirserv_router_get_status(const routerinfo_t *router, const char **msg)\n{\n  char d[DIGEST_LEN];\n\n  if (crypto_pk_get_digest(router->identity_pkey, d)) {\n    log_warn(LD_BUG,\"Error computing fingerprint\");\n    if (msg)\n      *msg = \"Bug: Error computing fingerprint\";\n    return FP_REJECT;\n  }\n\n  return dirserv_get_status_impl(d, router->nickname,\n                                 router->address,\n                                 router->addr, router->or_port,\n                                 router->platform, router->contact_info,\n                                 msg, 1);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":513014,"func":"  Item *remove_item_direct_ref()\n  { return (*ref)->remove_item_direct_ref(); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":309982,"func":"main(void)\n{\n    printf(\"This program requires the wide-ncurses library\\n\");\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":253610,"func":"fill_transform_hdr(struct smb2_transform_hdr *tr_hdr, unsigned int orig_len,\n\t\t   struct smb_rqst *old_rq, __le16 cipher_type)\n{\n\tstruct smb2_hdr *shdr =\n\t\t\t(struct smb2_hdr *)old_rq->rq_iov[0].iov_base;\n\n\tmemset(tr_hdr, 0, sizeof(struct smb2_transform_hdr));\n\ttr_hdr->ProtocolId = SMB2_TRANSFORM_PROTO_NUM;\n\ttr_hdr->OriginalMessageSize = cpu_to_le32(orig_len);\n\ttr_hdr->Flags = cpu_to_le16(0x01);\n\tif ((cipher_type == SMB2_ENCRYPTION_AES128_GCM) ||\n\t    (cipher_type == SMB2_ENCRYPTION_AES256_GCM))\n\t\tget_random_bytes(&tr_hdr->Nonce, SMB3_AES_GCM_NONCE);\n\telse\n\t\tget_random_bytes(&tr_hdr->Nonce, SMB3_AES_CCM_NONCE);\n\tmemcpy(&tr_hdr->SessionId, &shdr->SessionId, 8);\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":233870,"func":" *\/\nstatic void php_wddx_serialize_unset(wddx_packet *packet)\n{\n\tphp_wddx_add_chunk_static(packet, WDDX_NULL);","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":313814,"func":"nv_hat(cmdarg_T *cap)\n{\n    if (!checkclearopq(cap->oap))\n\t(void)buflist_getfile((int)cap->count0, (linenr_T)0,\n\t\t\t\t\t\tGETF_SETMARK|GETF_ALT, FALSE);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":261218,"func":"    int wm_SemInit(wm_Sem *s){\n        \/* dispatch_release() fails hard, with Trace\/BPT trap signal, if the\n         * sem's internal count is less than the value passed in with\n         * dispatch_semaphore_create().  work around this by initing\n         * with 0, then incrementing it afterwards.\n         *\/\n        *s = dispatch_semaphore_create(0);\n        if (*s == NULL)\n            return MQTT_CODE_ERROR_MEMORY;\n        if (dispatch_semaphore_signal(*s) < 0) {\n            dispatch_release(*s);\n            return MQTT_CODE_ERROR_SYSTEM;\n        }\n\n        return 0;\n    }","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":224184,"func":"  void Compute(OpKernelContext* ctx) override {\n    StagingMap<Ordered>* map = nullptr;\n    OP_REQUIRES_OK(ctx, GetStagingMap(ctx, def(), &map));\n    core::ScopedUnref scope(map);\n\n    \/\/ Allocate size output tensor\n    Tensor* size = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({}), &size));\n\n    \/\/ Set it to the actual size\n    size->scalar<int32>().setConstant(map->size());\n  }","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":276989,"func":"    virtual AP4_Result ReadPartial(void* , AP4_Size, AP4_Size&) {\n        return AP4_ERROR_NOT_SUPPORTED;\n    }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":222884,"func":"  std::size_t operator()(const Handle& h) const { return h.Handle(); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":254897,"func":"intrusive_ptr<Expression> parseIdExpression(const intrusive_ptr<ExpressionContext>& expCtx,\n                                            BSONElement groupField,\n                                            const VariablesParseState& vps) {\n    if (groupField.type() == Object) {\n        \/\/ {_id: {}} is treated as grouping on a constant, not an expression\n        if (groupField.Obj().isEmpty()) {\n            return ExpressionConstant::create(expCtx, Value(groupField));\n        }\n\n        const BSONObj idKeyObj = groupField.Obj();\n        if (idKeyObj.firstElementFieldName()[0] == '$') {\n            \/\/ grouping on a $op expression\n            return Expression::parseObject(expCtx, idKeyObj, vps);\n        } else {\n            for (auto&& field : idKeyObj) {\n                uassert(17390,\n                        \"$group does not support inclusion-style expressions\",\n                        !field.isNumber() && field.type() != Bool);\n            }\n            return ExpressionObject::parse(expCtx, idKeyObj, vps);\n        }\n    } else {\n        return Expression::parseOperand(expCtx, groupField, vps);\n    }\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":289248,"func":"static int __init alsa_pcm_oss_init(void)\n{\n\tint i;\n\tint err;\n\n\t\/* check device map table *\/\n\tfor (i = 0; i < SNDRV_CARDS; i++) {\n\t\tif (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_PCM_DEVICES) {\n\t\t\tpr_err(\"ALSA: pcm_oss: invalid dsp_map[%d] = %d\\n\",\n\t\t\t\t   i, dsp_map[i]);\n\t\t\tdsp_map[i] = 0;\n\t\t}\n\t\tif (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_PCM_DEVICES) {\n\t\t\tpr_err(\"ALSA: pcm_oss: invalid adsp_map[%d] = %d\\n\",\n\t\t\t\t   i, adsp_map[i]);\n\t\t\tadsp_map[i] = 1;\n\t\t}\n\t}\n\terr = snd_pcm_notify(&snd_pcm_oss_notify, 0);\n\tif (err < 0)\n\t\treturn err;\n\treturn 0;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":219022,"func":"void ConstantFolding::ReplaceDivisionOfOnesByReciprocal(NodeDef* node,\n                                                        GraphDef* graph) {\n  node->set_op(\"Reciprocal\");\n  node->mutable_input()->SwapElements(0, 1);\n  const string ctrl_dep =\n      AddControlDependency(node->input(1), graph, node_map_.get());\n  node_map_->UpdateInput(node->name(), node->input(1), ctrl_dep);\n  node->set_input(1, ctrl_dep);\n  graph_modified_ = true;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":273879,"func":"static int close_data_connection(ctrl_t *ctrl)\n{\n\tint ret = 0;\n\n\tDBG(\"Closing data connection ...\");\n\n\t\/* PASV server listening socket *\/\n\tif (ctrl->data_listen_sd > 0) {\n\t\tshutdown(ctrl->data_listen_sd, SHUT_RDWR);\n\t\tclose(ctrl->data_listen_sd);\n\t\tctrl->data_listen_sd = -1;\n\t\tret++;\n\t}\n\n\t\/* PASV client socket *\/\n\tif (ctrl->data_sd > 0) {\n\t\tshutdown(ctrl->data_sd, SHUT_RDWR);\n\t\tclose(ctrl->data_sd);\n\t\tctrl->data_sd = -1;\n\t\tret++;\n\t}\n\n\t\/* PORT *\/\n\tif (ctrl->data_address[0]) {\n\t\tctrl->data_address[0] = 0;\n\t\tctrl->data_port = 0;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":289295,"func":"static int snd_interval_refine_min(struct snd_interval *i, unsigned int min, int openmin)\n{\n\tint changed = 0;\n\tif (i->min < min) {\n\t\ti->min = min;\n\t\ti->openmin = openmin;\n\t\tchanged = 1;\n\t} else if (i->min == min && !i->openmin && openmin) {\n\t\ti->openmin = 1;\n\t\tchanged = 1;\n\t}\n\tif (i->integer) {\n\t\tif (i->openmin) {\n\t\t\ti->min++;\n\t\t\ti->openmin = 0;\n\t\t}\n\t}\n\tif (snd_interval_checkempty(i)) {\n\t\tsnd_interval_none(i);\n\t\treturn -EINVAL;\n\t}\n\treturn changed;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":344809,"func":"get_rdomain(int fd)\n{\n#if defined(HAVE_SYS_GET_RDOMAIN)\n\treturn sys_get_rdomain(fd);\n#elif defined(__OpenBSD__)\n\tint rtable;\n\tchar *ret;\n\tsocklen_t len = sizeof(rtable);\n\n\tif (getsockopt(fd, SOL_SOCKET, SO_RTABLE, &rtable, &len) == -1) {\n\t\terror(\"Failed to get routing domain for fd %d: %s\",\n\t\t    fd, strerror(errno));\n\t\treturn NULL;\n\t}\n\txasprintf(&ret, \"%d\", rtable);\n\treturn ret;\n#else \/* defined(__OpenBSD__) *\/\n\treturn NULL;\n#endif\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":409449,"func":"scroll_region_reset(void)\n{\n    OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0));\n    if (*T_CSV != NUL)\n\tOUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0));\n    screen_start();\t\t    \/\/ don't know where cursor is now\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":509501,"func":"bool ha_maria::auto_repair(int error) const\n{\n  \/* Always auto-repair moved tables (error == HA_ERR_OLD_FILE) *\/\n  return ((MY_TEST(maria_recover_options & HA_RECOVER_ANY) &&\n           error == HA_ERR_CRASHED_ON_USAGE) ||\n          error == HA_ERR_OLD_FILE);\n\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":301414,"func":"static int vfswrap_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)\n{\n\tint result;\n\n\tSTART_PROFILE(syscall_lchown);\n\tresult = lchown(path, uid, gid);\n\tEND_PROFILE(syscall_lchown);\n\treturn result;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":95909,"func":"void AppendUninstallCommandLineFlags(const InstallerState& installer_state,\n                                     const Product& product,\n                                     CommandLine* uninstall_cmd) {\n  DCHECK(uninstall_cmd);\n\n  uninstall_cmd->AppendSwitch(installer::switches::kUninstall);\n\n  product.AppendUninstallFlags(uninstall_cmd);\n  if (installer_state.is_msi()) {\n    uninstall_cmd->AppendSwitch(installer::switches::kMsi);\n    if (product.is_chrome_frame()) {\n      uninstall_cmd->AppendSwitch(installer::switches::kDeleteProfile);\n    }\n  }\n  if (installer_state.system_install())\n    uninstall_cmd->AppendSwitch(installer::switches::kSystemLevel);\n  if (installer_state.verbose_logging())\n    uninstall_cmd->AppendSwitch(installer::switches::kVerboseLogging);\n}\n","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":317348,"func":"static int selinux_task_getioprio(struct task_struct *p)\n{\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    current_sid(), task_sid_obj(p), SECCLASS_PROCESS,\n\t\t\t    PROCESS__GETSCHED, NULL);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":307846,"func":"ciKlass* ciEnv::get_klass_by_index(constantPoolHandle cpool,\n                                   int index,\n                                   bool& is_accessible,\n                                   ciInstanceKlass* accessor) {\n  GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":379703,"func":"R_API void r_anal_function_vars_cache_fini(RAnalFcnVarsCache *cache) {\n\tif (!cache) {\n\t\treturn;\n\t}\n\tr_list_free (cache->bvars);\n\tr_list_free (cache->rvars);\n\tr_list_free (cache->svars);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":459010,"func":"http_findhdr(const struct http *hp, unsigned l, const char *hdr)\n{\n\tunsigned u;\n\n\tfor (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {\n\t\tTcheck(hp->hd[u]);\n\t\tif (hp->hd[u].e < hp->hd[u].b + l + 1)\n\t\t\tcontinue;\n\t\tif (hp->hd[u].b[l] != ':')\n\t\t\tcontinue;\n\t\tif (!http_hdr_at(hdr, hp->hd[u].b, l))\n\t\t\tcontinue;\n\t\treturn (u);\n\t}\n\treturn (0);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":247355,"func":"pgpArmor pgpReadPkts(const char * fn, uint8_t ** pkt, size_t * pktlen)\n{\n    uint8_t * b = NULL;\n    ssize_t blen;\n    pgpArmor ec = PGPARMOR_ERR_NO_BEGIN_PGP;\t\/* XXX assume failure *\/\n    int rc = rpmioSlurp(fn, &b, &blen);\n    if (rc == 0 && b != NULL && blen > 0) {\n\tec = decodePkts(b, pkt, pktlen);\n    }\n    free(b);\n    return ec;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":317042,"func":"static int selinux_mmap_file(struct file *file, unsigned long reqprot,\n\t\t\t     unsigned long prot, unsigned long flags)\n{\n\tstruct common_audit_data ad;\n\tint rc;\n\n\tif (file) {\n\t\tad.type = LSM_AUDIT_DATA_FILE;\n\t\tad.u.file = file;\n\t\trc = inode_has_perm(current_cred(), file_inode(file),\n\t\t\t\t    FILE__MAP, &ad);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tif (checkreqprot_get(&selinux_state))\n\t\tprot = reqprot;\n\n\treturn file_map_prot_check(file, prot,\n\t\t\t\t   (flags & MAP_TYPE) == MAP_SHARED);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":230381,"func":"PJ_DEF(pj_xml_node*) pj_xml_clone( pj_pool_t *pool, const pj_xml_node *rhs)\n{\n    pj_xml_node *node;\n    const pj_xml_attr *r_attr;\n    const pj_xml_node *child;\n\n    node = alloc_node(pool);\n\n    pj_strdup(pool, &node->name, &rhs->name);\n    pj_strdup(pool, &node->content, &rhs->content);\n\n    \/* Clone all attributes *\/\n    r_attr = rhs->attr_head.next;\n    while (r_attr != &rhs->attr_head) {\n\n\tpj_xml_attr *attr;\n\n\tattr = alloc_attr(pool);\n\tpj_strdup(pool, &attr->name, &r_attr->name);\n\tpj_strdup(pool, &attr->value, &r_attr->value);\n\n\tpj_list_push_back(&node->attr_head, attr);\n\n\tr_attr = r_attr->next;\n    }\n\n    \/* Clone all child nodes. *\/\n    child = rhs->node_head.next;\n    while (child != (pj_xml_node*) &rhs->node_head) {\n\tpj_xml_node *new_child;\n\n\tnew_child = pj_xml_clone(pool, child);\n\tpj_list_push_back(&node->node_head, new_child);\n\n\tchild = child->next;\n    }\n\n    return node;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":359665,"func":"DEFUN (show_ip_bgp_community_info, \n       show_ip_bgp_community_info_cmd,\n       \"show ip bgp community-info\",\n       SHOW_STR\n       IP_STR\n       BGP_STR\n       \"List all bgp community information\\n\")\n{\n  vty_out (vty, \"Address Refcnt Community%s\", VTY_NEWLINE);\n\n  hash_iterate (community_hash (), \n\t\t(void (*) (struct hash_backet *, void *))\n\t\tcommunity_show_all_iterator,\n\t\tvty);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":238632,"func":"void bpf_free_kfunc_btf_tab(struct bpf_kfunc_btf_tab *tab)\n{\n\tif (!tab)\n\t\treturn;\n\n\twhile (tab->nr_descs--) {\n\t\tmodule_put(tab->descs[tab->nr_descs].module);\n\t\tbtf_put(tab->descs[tab->nr_descs].btf);\n\t}\n\tkfree(tab);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":513345,"func":"static void clear_tables(JOIN *join)\n{\n  \/* \n    must clear only the non-const tables, as const tables\n    are not re-calculated.\n  *\/\n  for (uint i= 0 ; i < join->table_count ; i++)\n  {\n    if (!(join->table[i]->map & join->const_table_map))\n      mark_as_null_row(join->table[i]);\t\t\/\/ All fields are NULL\n  }\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":386530,"func":"void DL_Dxf::writeKnot(DL_WriterA& dw,\n                       const DL_KnotData& data) {\n\n    dw.dxfReal(40, data.k);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":488354,"func":"static void remove_anon_migration_ptes(struct page *old, struct page *new)\n{\n\tstruct anon_vma *anon_vma;\n\tstruct vm_area_struct *vma;\n\tunsigned long mapping;\n\n\tmapping = (unsigned long)new->mapping;\n\n\tif (!mapping || (mapping & PAGE_MAPPING_ANON) == 0)\n\t\treturn;\n\n\t\/*\n\t * We hold the mmap_sem lock. So no need to call page_lock_anon_vma.\n\t *\/\n\tanon_vma = (struct anon_vma *) (mapping - PAGE_MAPPING_ANON);\n\tspin_lock(&anon_vma->lock);\n\n\tlist_for_each_entry(vma, &anon_vma->head, anon_vma_node)\n\t\tremove_migration_pte(vma, old, new);\n\n\tspin_unlock(&anon_vma->lock);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":225938,"func":"GF_Box *tfhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackFragmentHeaderBox, GF_ISOM_BOX_TYPE_TFHD);\n\t\/\/NO FLAGS SET BY DEFAULT\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":331763,"func":"void QPaintEngineEx::drawLines(const QLineF *lines, int lineCount)\n{\n    int elementCount = lineCount << 1;\n    while (elementCount > 0) {\n        int count = qMin(elementCount, 32);\n\n        QVectorPath path((const qreal *) lines, count, qpaintengineex_line_types_16,\n                         QVectorPath::LinesHint);\n        stroke(path, state()->pen);\n\n        elementCount -= 32;\n        lines += 16;\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":294604,"func":"d_complex_new_internal(VALUE klass,\n\t\t       VALUE nth, int jd,\n\t\t       int df, VALUE sf,\n\t\t       int of, double sg,\n\t\t       int y, int m, int d,\n\t\t       int h, int min, int s,\n\t\t       unsigned flags)\n{\n    struct ComplexDateData *dat;\n    VALUE obj;\n\n    obj = TypedData_Make_Struct(klass, struct ComplexDateData,\n\t\t\t\t&d_lite_type, dat);\n    set_to_complex(obj, dat, nth, jd, df, sf, of, sg,\n\t\t   y, m, d, h, min, s, flags);\n\n    assert(have_jd_p(dat) || have_civil_p(dat));\n    assert(have_df_p(dat) || have_time_p(dat));\n\n    return obj;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":446079,"func":"static void atusb_xmit_complete(struct urb *urb)\n{\n\tdev_dbg(&urb->dev->dev, \"atusb_xmit urb completed\");\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":309850,"func":"compare_part(const char *part, const char *full)\n{\n    const char *next_part;\n    const char *next_full;\n    unsigned used_full = 0;\n    unsigned used_delay = 0;\n\n    while (*part != 0) {\n\tif (*part != *full) {\n\t    used_full = 0;\n\t    break;\n\t}\n\n\t\/*\n\t * Adjust the return-value to allow the rare case of\n\t *      string<delay>string\n\t * to remove the whole piece.  The most common case is a delay at the\n\t * end of the string.  The adjusted string will retain the delay, which\n\t * is conservative.\n\t *\/\n\tif (used_delay != 0) {\n\t    used_full += used_delay;\n\t    used_delay = 0;\n\t}\n\tif (*part == '$' && *full == '$') {\n\t    next_part = skip_delay(part);\n\t    next_full = skip_delay(full);\n\t    if (next_part != part && next_full != full) {\n\t\tused_delay += (unsigned) (next_full - full);\n\t\tfull = next_full;\n\t\tpart = next_part;\n\t\tcontinue;\n\t    }\n\t}\n\t++used_full;\n\t++part;\n\t++full;\n    }\n    return used_full;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":484044,"func":"START_TEST(SecureChannel_sendAsymmetricOPNMessage_withoutConnection) {\n    UA_OpenSecureChannelResponse dummyResponse;\n    createDummyResponse(&dummyResponse);\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_NONE;\n\n    \/\/ Remove connection to provoke error\n    UA_Connection_detachSecureChannel(testChannel.connection);\n    testChannel.connection = NULL;\n\n    UA_StatusCode retval =\n        UA_SecureChannel_sendAsymmetricOPNMessage(&testChannel, 42, &dummyResponse,\n                                                  &UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);\n\n    ck_assert_msg(retval != UA_STATUSCODE_GOOD, \"Expected failure without a connection\");\n}END_TEST","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":294573,"func":"test_civil(int from, int to, double sg)\n{\n    int j;\n\n    fprintf(stderr, \"test_civil: %d...%d (%d) - %.0f\\n\",\n\t    from, to, to - from, sg);\n    for (j = from; j <= to; j++) {\n\tint y, m, d, rj, ns;\n\n\tc_jd_to_civil(j, sg, &y, &m, &d);\n\tc_civil_to_jd(y, m, d, sg, &rj, &ns);\n\tif (j != rj) {\n\t    fprintf(stderr, \"%d != %d\\n\", j, rj);\n\t    return 0;\n\t}\n    }\n    return 1;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":317135,"func":"static void smack_cred_transfer(struct cred *new, const struct cred *old)\n{\n\tstruct task_smack *old_tsp = smack_cred(old);\n\tstruct task_smack *new_tsp = smack_cred(new);\n\n\tnew_tsp->smk_task = old_tsp->smk_task;\n\tnew_tsp->smk_forked = old_tsp->smk_task;\n\tmutex_init(&new_tsp->smk_rules_lock);\n\tINIT_LIST_HEAD(&new_tsp->smk_rules);\n\n\t\/* cbs copy rule list *\/\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":400731,"func":"size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,\n\t\t\t       struct iov_iter *i)\n{\n\t__wsum sum, next;\n\tsum = *csum;\n\tif (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {\n\t\tWARN_ON(1);\n\t\treturn 0;\n\t}\n\titerate_and_advance(i, bytes, base, len, off, ({\n\t\tnext = csum_and_copy_from_user(base, addr + off, len);\n\t\tsum = csum_block_add(sum, next, off);\n\t\tnext ? 0 : len;\n\t}), ({\n\t\tsum = csum_and_memcpy(addr + off, base, len, sum, off);\n\t})\n\t)\n\t*csum = sum;\n\treturn bytes;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":474049,"func":"murmur(st_index_t h, st_index_t k, int r)\n{\n    const st_index_t m = MurmurMagic;\n#if MURMUR == 1\n    h += k;\n    h *= m;\n    h ^= h >> r;\n#elif MURMUR == 2\n    k *= m;\n    k ^= k >> r;\n    k *= m;\n\n    h *= m;\n    h ^= k;\n#endif\n    return h;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":314510,"func":"static void parse_connection_info(pj_scanner *scanner, pjmedia_sdp_conn *conn,\n\t\t\t\t  volatile parse_context *ctx)\n{\n    ctx->last_error = PJMEDIA_SDP_EINCONN;\n\n    \/* c= *\/\n    pj_scan_advance_n(scanner, 2, SKIP_WS);\n\n    \/* network-type *\/\n    pj_scan_get_until_ch(scanner, ' ', &conn->net_type);\n    pj_scan_get_char(scanner);\n\n    \/* addr-type *\/\n    pj_scan_get_until_ch(scanner, ' ', &conn->addr_type);\n    pj_scan_get_char(scanner);\n\n    \/* address. *\/\n    pj_scan_get_until_chr(scanner, \"\/ \\t\\r\\n\", &conn->addr);\n    PJ_TODO(PARSE_SDP_CONN_ADDRESS_SUBFIELDS);\n\n    \/* We've got what we're looking for, skip anything until newline *\/\n    pj_scan_skip_line(scanner);\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":462433,"func":"lstnActivity(ptcplstn_t *pLstn)\n{\n\tint newSock = -1;\n\tprop_t *peerName;\n\tprop_t *peerIP;\n\trsRetVal localRet;\n\tDEFiRet;\n\n\tDBGPRINTF(\"imptcp: new connection on listen socket %d\\n\", pLstn->sock);\n\twhile(glbl.GetGlobalInputTermState() == 0) {\n\t\tlocalRet = AcceptConnReq(pLstn, &newSock, &peerName, &peerIP);\n\t\tif(localRet == RS_RET_NO_MORE_DATA || glbl.GetGlobalInputTermState() == 1) {\n\t\t\tbreak;\n\t\t}\n\t\tCHKiRet(localRet);\n\t\tlocalRet = addSess(pLstn, newSock, peerName, peerIP);\n\t\tif(localRet != RS_RET_OK) {\n\t\t\tclose(newSock);\n\t\t\tprop.Destruct(&peerName);\n\t\t\tprop.Destruct(&peerIP);\n\t\t\tABORT_FINALIZE(localRet);\n\t\t}\n\t}\n\nfinalize_it:\n\tRETiRet;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":344813,"func":"lowercase(char *s)\n{\n\tfor (; *s; s++)\n\t\t*s = tolower((u_char)*s);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":234717,"func":"int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,\n\t\t       fmode_t flags, void *holder)\n{\n\tint ret;\n\n\tlockdep_assert_held(&uuid_mutex);\n\t\/*\n\t * The device_list_mutex cannot be taken here in case opening the\n\t * underlying device takes further locks like open_mutex.\n\t *\n\t * We also don't need the lock here as this is called during mount and\n\t * exclusion is provided by uuid_mutex\n\t *\/\n\n\tif (fs_devices->opened) {\n\t\tfs_devices->opened++;\n\t\tret = 0;\n\t} else {\n\t\tlist_sort(NULL, &fs_devices->devices, devid_cmp);\n\t\tret = open_fs_devices(fs_devices, flags, holder);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":226045,"func":"void mp4s_box_del(GF_Box *s)\n{\n\tGF_MPEGSampleEntryBox *ptr = (GF_MPEGSampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\tif (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);\n\tgf_free(ptr);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":236139,"func":"GF_Box *gppc_box_new()\n{\n\t\/\/default type is amr but overwritten by box constructor\n\tISOM_DECL_BOX_ALLOC(GF_3GPPConfigBox, GF_ISOM_BOX_TYPE_DAMR);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":413648,"func":"R_API bool r_core_anal_bb_seek(RCore *core, ut64 addr) {\n\tut64 bbaddr = r_anal_get_bbaddr (core->anal, addr);\n\tif (bbaddr != UT64_MAX) {\n\t\tr_core_seek (core, bbaddr, false);\n\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":219960,"func":"int callback_glewlwyd_get_user_middleware_module (const struct _u_request * request, struct _u_response * response, void * user_middleware_data) {\n  struct config_elements * config = (struct config_elements *)user_middleware_data;\n  json_t * j_module;\n  \n  j_module = get_user_middleware_module(config, u_map_get(request->map_url, \"name\"));\n  if (check_result_value(j_module, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module, \"module\"));\n  } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_user_middleware_module - Error get_user_middleware_module\");\n    response->status = 500;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":462279,"func":"PJ_DEF(pj_status_t) pj_stun_msg_add_string_attr(pj_pool_t *pool,\n\t\t\t\t\t\tpj_stun_msg *msg,\n\t\t\t\t\t\tint attr_type,\n\t\t\t\t\t\tconst pj_str_t *value)\n{\n    pj_stun_string_attr *attr = NULL;\n    pj_status_t status;\n\n    status = pj_stun_string_attr_create(pool, attr_type, value, \n\t\t\t\t\t\t&attr);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    return pj_stun_msg_add_attr(msg, &attr->hdr);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":450821,"func":"readdir_result_type (struct readdir_result d)\n{\n#if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE\n# define D_TYPE_TO_RESULT(source) (source)->d_type,\n  return d.type;\n#else\n# define D_TYPE_TO_RESULT(source)\n  return DT_UNKNOWN;\n#endif\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":161841,"func":"int64 ClientUsageTracker::GetCachedHostUsage(const std::string& host) {\nint64 ClientUsageTracker::GetCachedHostUsage(const std::string& host) const {\n   HostUsageMap::const_iterator found = cached_usage_.find(host);\n   if (found == cached_usage_.end())\n     return 0;\n\n  int64 usage = 0;\n  const UsageMap& map = found->second;\n  for (UsageMap::const_iterator iter = map.begin();\n       iter != map.end(); ++iter) {\n    usage += iter->second;\n  }\n  return usage;\n}\n","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":226953,"func":"IRC_PROTOCOL_CALLBACK(whowas_nick_msg)\n{\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (\n            server, argv[3], command, \"whowas\", NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s[%s%s%s] %s%s\",\n        weechat_prefix (\"network\"),\n        IRC_COLOR_CHAT_DELIMITERS,\n        irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n        argv[3],\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_RESET,\n        (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":274846,"func":"  std::vector<bool> GetOutput() { return ExtractVector<bool>(output_); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":508362,"func":"bool Alter_table_prelocking_strategy::\nhandle_view(THD *thd, Query_tables_list *prelocking_ctx,\n            TABLE_LIST *table_list, bool *need_prelocking)\n{\n  return FALSE;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":300814,"func":"int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb,\n\t\t    int (*skb_handler)(struct sk_buff *skb,\n\t\t\t\t       struct netlink_callback *cb,\n\t\t\t\t       struct tipc_sock *tsk))\n{\n\tstruct rhashtable_iter *iter = (void *)cb->args[4];\n\tstruct tipc_sock *tsk;\n\tint err;\n\n\trhashtable_walk_start(iter);\n\twhile ((tsk = rhashtable_walk_next(iter)) != NULL) {\n\t\tif (IS_ERR(tsk)) {\n\t\t\terr = PTR_ERR(tsk);\n\t\t\tif (err == -EAGAIN) {\n\t\t\t\terr = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tsock_hold(&tsk->sk);\n\t\trhashtable_walk_stop(iter);\n\t\tlock_sock(&tsk->sk);\n\t\terr = skb_handler(skb, cb, tsk);\n\t\tif (err) {\n\t\t\trelease_sock(&tsk->sk);\n\t\t\tsock_put(&tsk->sk);\n\t\t\tgoto out;\n\t\t}\n\t\trelease_sock(&tsk->sk);\n\t\trhashtable_walk_start(iter);\n\t\tsock_put(&tsk->sk);\n\t}\n\trhashtable_walk_stop(iter);\nout:\n\treturn skb->len;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":482505,"func":"getCharForDots(widechar d, const DisplayTableHeader *table) {\n\tCharDotsMapping *cdPtr;\n\tconst TranslationTableOffset bucket = table->dotsToChar[_lou_charHash(d)];\n\tTranslationTableOffset offset = bucket;\n\twhile (offset) {\n\t\tcdPtr = (CharDotsMapping *)&table->ruleArea[offset];\n\t\tif (cdPtr->lookFor == d) return cdPtr;\n\t\toffset = cdPtr->next;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":234720,"func":"static void init_alloc_chunk_ctl(struct btrfs_fs_devices *fs_devices,\n\t\t\t\t struct alloc_chunk_ctl *ctl)\n{\n\tint index = btrfs_bg_flags_to_raid_index(ctl->type);\n\n\tctl->sub_stripes = btrfs_raid_array[index].sub_stripes;\n\tctl->dev_stripes = btrfs_raid_array[index].dev_stripes;\n\tctl->devs_max = btrfs_raid_array[index].devs_max;\n\tif (!ctl->devs_max)\n\t\tctl->devs_max = BTRFS_MAX_DEVS(fs_devices->fs_info);\n\tctl->devs_min = btrfs_raid_array[index].devs_min;\n\tctl->devs_increment = btrfs_raid_array[index].devs_increment;\n\tctl->ncopies = btrfs_raid_array[index].ncopies;\n\tctl->nparity = btrfs_raid_array[index].nparity;\n\tctl->ndevs = 0;\n\n\tswitch (fs_devices->chunk_alloc_policy) {\n\tcase BTRFS_CHUNK_ALLOC_REGULAR:\n\t\tinit_alloc_chunk_ctl_policy_regular(fs_devices, ctl);\n\t\tbreak;\n\tcase BTRFS_CHUNK_ALLOC_ZONED:\n\t\tinit_alloc_chunk_ctl_policy_zoned(fs_devices, ctl);\n\t\tbreak;\n\tdefault:\n\t\tBUG();\n\t}\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":387870,"func":"void JNIid::verify(Klass* holder) {\n  int first_field_offset  = InstanceMirrorKlass::offset_of_static_fields();\n  int end_field_offset;\n  end_field_offset = first_field_offset + (InstanceKlass::cast(holder)->static_field_size() * wordSize);\n\n  JNIid* current = this;\n  while (current != NULL) {\n    guarantee(current->holder() == holder, \"Invalid klass in JNIid\");\n#ifdef ASSERT\n    int o = current->offset();\n    if (current->is_static_field_id()) {\n      guarantee(o >= first_field_offset  && o < end_field_offset,  \"Invalid static field offset in JNIid\");\n    }\n#endif\n    current = current->next();\n  }\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":500641,"func":"int sftp_close(sftp_file file){\n  int err = SSH_NO_ERROR;\n\n  SAFE_FREE(file->name);\n  if (file->handle){\n    err = sftp_handle_close(file->sftp,file->handle);\n    ssh_string_free(file->handle);\n  }\n  \/* FIXME: check server response and implement errno *\/\n  SAFE_FREE(file);\n\n  return err;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":101660,"func":"bool WebProcessProxy::checkURLReceivedFromWebProcess(const String& urlString)\n{\n    return checkURLReceivedFromWebProcess(KURL(KURL(), urlString));\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":487619,"func":"void kernel_shutdown_prepare(enum system_states state)\n{\n\tblocking_notifier_call_chain(&reboot_notifier_list,\n\t\t(state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);\n\tsystem_state = state;\n\tdevice_shutdown();\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":384894,"func":"vim_strnsize(char_u *s, int len)\n{\n    int\t\tsize = 0;\n\n    while (*s != NUL && --len >= 0)\n\tif (has_mbyte)\n\t{\n\t    int\t    l = (*mb_ptr2len)(s);\n\n\t    size += ptr2cells(s);\n\t    s += l;\n\t    len -= l - 1;\n\t}\n\telse\n\t    size += byte2cells(*s++);\n\n    return size;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":512893,"func":"  Item_ref_null_helper(THD *thd, Name_resolution_context *context_arg,\n                       Item_in_subselect* master, Item **item,\n\t\t       const char *table_name_arg,\n                       const LEX_CSTRING *field_name_arg):\n    Item_ref(thd, context_arg, item, table_name_arg, field_name_arg),\n    owner(master) {}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":417112,"func":"PlayerBase*\tPlayerGeneric::getPreferredPlayer(XModule* module) const\n{\n\tswitch (getPreferredPlayerType(module))\n\t{\n#ifndef MILKYTRACKER\n\t\tcase PlayerBase::PlayerType_FAR:\n\t\t\treturn new PlayerFAR(frequency);\n\t\tcase PlayerBase::PlayerType_IT:\n\t\t\treturn new PlayerIT(frequency);\n#endif\n\t\tcase PlayerBase::PlayerType_Generic:\n\t\t\treturn new PlayerSTD(frequency);\n\t\t\t\n\t\tdefault:\n\t\t\treturn NULL;\n\t}\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":473836,"func":"euctw_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)\n{\n  int firstbyte = *p++;\n  state_t s = trans[0][firstbyte];\n#define RETURN(n) \\\n    return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) : \\\n                         ONIGENC_CONSTRUCT_MBCLEN_INVALID()\n  if (s < 0) RETURN(1);\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_EUCTW[firstbyte]-1);\n  s = trans[s][*p++];\n  if (s < 0) RETURN(2);\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(4-2);\n  s = trans[s][*p++];\n  if (s < 0) RETURN(3);\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(4-3);\n  s = trans[s][*p++];\n  RETURN(4);\n#undef RETURN\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":274721,"func":"static double line_length(double x0, double y0, double x1, double y1)\n{\n\tdouble dx = x0 - x1;\n\tdouble dy = y0 - y1;\n\n\treturn hypot(dx, dy);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":90215,"func":"  virtual bool ethernet_enabled() const {\n    return enabled_devices_ & (1 << TYPE_ETHERNET);\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":225914,"func":"GF_Err tmax_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TMAXBox *ptr = (GF_TMAXBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 4)\n\tptr->maxTime = gf_bs_read_u32(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":338046,"func":"void WasmBinaryWriter::writeInlineBuffer(const char* data, size_t size) {\n  o << U32LEB(size);\n  writeData(data, size);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":236117,"func":"GF_Err ftab_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_FontTableBox *ptr = (GF_FontTableBox *)s;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u16(bs, ptr->entry_count);\n\tfor (i=0; i<ptr->entry_count; i++) {\n\t\tgf_bs_write_u16(bs, ptr->fonts[i].fontID);\n\t\tif (ptr->fonts[i].fontName) {\n\t\t\tu32 len = (u32) strlen(ptr->fonts[i].fontName);\n\t\t\tgf_bs_write_u8(bs, len);\n\t\t\tgf_bs_write_data(bs, ptr->fonts[i].fontName, len);\n\t\t} else {\n\t\t\tgf_bs_write_u8(bs, 0);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":229276,"func":"std::unique_ptr<cql_server::response> cql_server::connection::make_ready(int16_t stream, const tracing::trace_state_ptr& tr_state) const\n{\n    return std::make_unique<cql_server::response>(stream, cql_binary_opcode::READY, tr_state);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":294466,"func":"test_weeknum(int from, int to, int f, double sg)\n{\n    int j;\n\n    fprintf(stderr, \"test_weeknum: %d...%d (%d) - %.0f\\n\",\n\t    from, to, to - from, sg);\n    for (j = from; j <= to; j++) {\n\tint y, w, d, rj, ns;\n\n\tc_jd_to_weeknum(j, f, sg, &y, &w, &d);\n\tc_weeknum_to_jd(y, w, d, f, sg, &rj, &ns);\n\tif (j != rj) {\n\t    fprintf(stderr, \"%d != %d\\n\", j, rj);\n\t    return 0;\n\t}\n    }\n    return 1;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":484769,"func":"static void xennet_destroy_queues(struct netfront_info *info)\n{\n\tunsigned int i;\n\n\tfor (i = 0; i < info->netdev->real_num_tx_queues; i++) {\n\t\tstruct netfront_queue *queue = &info->queues[i];\n\n\t\tif (netif_running(info->netdev))\n\t\t\tnapi_disable(&queue->napi);\n\t\tnetif_napi_del(&queue->napi);\n\t}\n\n\tkfree(info->queues);\n\tinfo->queues = NULL;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":225374,"func":"static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);\n\treturn v4l2loopback_set_ctrl(dev, c->id, c->value);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":257004,"func":"static int __init init_route4(void)\n{\n\treturn register_tcf_proto_ops(&cls_route4_ops);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":242665,"func":"static inline const gchar *format_param_str(tvbuff_t *tvb, int offset, int len) {\n    char *param_str;\n\n    param_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_UTF_8|ENC_NA);\n\n    if (len < 2) {\n        return param_str;\n    }\n    return format_text_chr(wmem_packet_scope(), param_str, len - 1, ' '); \/* Leave terminating NULLs alone. *\/\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":400740,"func":"static void pipe_advance(struct iov_iter *i, size_t size)\n{\n\tstruct pipe_inode_info *pipe = i->pipe;\n\tif (size) {\n\t\tstruct pipe_buffer *buf;\n\t\tunsigned int p_mask = pipe->ring_size - 1;\n\t\tunsigned int i_head = i->head;\n\t\tsize_t off = i->iov_offset, left = size;\n\n\t\tif (off) \/* make it relative to the beginning of buffer *\/\n\t\t\tleft += off - pipe->bufs[i_head & p_mask].offset;\n\t\twhile (1) {\n\t\t\tbuf = &pipe->bufs[i_head & p_mask];\n\t\t\tif (left <= buf->len)\n\t\t\t\tbreak;\n\t\t\tleft -= buf->len;\n\t\t\ti_head++;\n\t\t}\n\t\ti->head = i_head;\n\t\ti->iov_offset = buf->offset + left;\n\t}\n\ti->count -= size;\n\t\/* ... and discard everything past that point *\/\n\tpipe_truncate(i);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":517447,"func":"static void print_service_rules_fsflags(HttpResponse res, Service_T s) {\n        for (FsFlag_T l = s->fsflaglist; l; l = l->next) {\n                StringBuffer_append(res->outputbuffer, \"<tr class='rule'><td>Filesystem flags<\/td><td>\");\n                Util_printRule(res->outputbuffer, l->action, \"If changed\");\n                StringBuffer_append(res->outputbuffer, \"<\/td><\/tr>\");\n        }\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":90207,"func":"  virtual bool cellular_enabled() const {\n    return enabled_devices_ & (1 << TYPE_CELLULAR);\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":437725,"func":"static inline u16 ns_to_clock_divider(unsigned int ns)\n{\n\treturn count_to_clock_divider(\n\t\tDIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ \/ 1000000 * ns, 1000));\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":343209,"func":"static unsigned int open_max(void)\n{\n    long z;\n\n    if ((z = (long) sysconf(_SC_OPEN_MAX)) < 0L) {\n        perror(\"_SC_OPEN_MAX\");\n        _EXIT(EXIT_FAILURE);\n    }\n    return (unsigned int) z;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":275507,"func":"njs_vm_array_length(njs_vm_t *vm, njs_value_t *value, int64_t *length)\n{\n    if (njs_fast_path(njs_is_array(value))) {\n        *length = njs_array(value)->length;\n    }\n\n    return njs_object_length(vm, value, length);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":220400,"func":"ary_subseq(mrb_state *mrb, struct RArray *a, mrb_int beg, mrb_int len)\n{\n  struct RArray *b;\n\n  if (!ARY_SHARED_P(a) && len <= ARY_SHIFT_SHARED_MIN) {\n    return mrb_ary_new_from_values(mrb, len, ARY_PTR(a)+beg);\n  }\n  ary_make_shared(mrb, a);\n  b  = MRB_OBJ_ALLOC(mrb, MRB_TT_ARRAY, mrb->array_class);\n  b->as.heap.ptr = a->as.heap.ptr + beg;\n  b->as.heap.len = len;\n  b->as.heap.aux.shared = a->as.heap.aux.shared;\n  b->as.heap.aux.shared->refcnt++;\n  ARY_SET_SHARED_FLAG(b);\n\n  return mrb_obj_value(b);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":473922,"func":"gbk_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)\n{\n  return onigenc_mbn_mbc_to_code(enc, p, end);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":366286,"func":"void __detach_mounts(struct dentry *dentry)\n{\n\tstruct mountpoint *mp;\n\tstruct mount *mnt;\n\n\tnamespace_lock();\n\tlock_mount_hash();\n\tmp = lookup_mountpoint(dentry);\n\tif (!mp)\n\t\tgoto out_unlock;\n\n\tevent++;\n\twhile (!hlist_empty(&mp->m_list)) {\n\t\tmnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);\n\t\tif (mnt->mnt.mnt_flags & MNT_UMOUNT) {\n\t\t\tumount_mnt(mnt);\n\t\t\thlist_add_head(&mnt->mnt_umount, &unmounted);\n\t\t}\n\t\telse umount_tree(mnt, UMOUNT_CONNECTED);\n\t}\n\tput_mountpoint(mp);\nout_unlock:\n\tunlock_mount_hash();\n\tnamespace_unlock();\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":341818,"func":"zstring(i_ctx_t *i_ctx_p)\n{\n    os_ptr op = osp;\n    byte *sbody;\n    uint size;\n\n    check_type(*op, t_integer);\n    if (op->value.intval < 0 )\n        return_error(gs_error_rangecheck);\n    if (op->value.intval > max_string_size )\n        return_error(gs_error_limitcheck); \/* to match Distiller *\/\n    size = op->value.intval;\n    sbody = ialloc_string(size, \"string\");\n    if (sbody == 0)\n        return_error(gs_error_VMerror);\n    make_string(op, a_all | icurrent_space, size, sbody);\n    memset(sbody, 0, size);\n    return 0;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":432726,"func":"static void draw_stroke_color_rgb( wmfAPI* API, const wmfRGB* rgb )\n{\n  PixelWand\n    *stroke_color;\n\n  stroke_color=NewPixelWand();\n  PixelSetRedQuantum(stroke_color,ScaleCharToQuantum(rgb->r));\n  PixelSetGreenQuantum(stroke_color,ScaleCharToQuantum(rgb->g));\n  PixelSetBlueQuantum(stroke_color,ScaleCharToQuantum(rgb->b));\n  PixelSetAlphaQuantum(stroke_color,OpaqueAlpha);\n  DrawSetStrokeColor(WmfDrawingWand,stroke_color);\n  stroke_color=DestroyPixelWand(stroke_color);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":236162,"func":"void dlay_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":225628,"func":"\nGF_Err pdin_box_size(GF_Box *s)\n{\n\tGF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox *)s;\n\tptr->size += 8*ptr->count;\n\treturn GF_OK;","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":512447,"func":"  bool pushable_cond_checker_for_subquery(uchar *arg)\n  {\n    return excl_dep_on_in_subq_left_part((Item_in_subselect *)arg);\n  }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":101674,"func":"void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)\n{\n    if (m_messageReceiverMap.dispatchMessage(connection, messageID, decoder))\n        return;\n\n    if (m_context->dispatchMessage(connection, messageID, decoder))\n        return;\n\n    if (decoder.messageReceiverName() == Messages::WebProcessProxy::messageReceiverName()) {\n        didReceiveWebProcessProxyMessage(connection, messageID, decoder);\n        return;\n    }\n\n#if ENABLE(CUSTOM_PROTOCOLS)\n    if (decoder.messageReceiverName() == Messages::CustomProtocolManagerProxy::messageReceiverName()) {\n#if ENABLE(NETWORK_PROCESS)\n        ASSERT(!context()->usesNetworkProcess());\n#endif\n        m_customProtocolManagerProxy.didReceiveMessage(connection, messageID, decoder);\n        return;\n    }\n#endif\n\n    uint64_t pageID = decoder.destinationID();\n    if (!pageID)\n        return;\n\n    WebPageProxy* pageProxy = webPage(pageID);\n    if (!pageProxy)\n        return;\n    \n    pageProxy->didReceiveMessage(connection, messageID, decoder);\n}\n","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":462259,"func":"static void* clone_uint64_attr(pj_pool_t *pool, const void *src)\n{\n    pj_stun_uint64_attr *dst = PJ_POOL_ALLOC_T(pool, pj_stun_uint64_attr);\n\n    pj_memcpy(dst, src, sizeof(pj_stun_uint64_attr));\n\n    return (void*)dst;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":355631,"func":"check_can_index(typval_T *rettv, int evaluate, int verbose)\n{\n    switch (rettv->v_type)\n    {\n\tcase VAR_FUNC:\n\tcase VAR_PARTIAL:\n\t    if (verbose)\n\t\temsg(_(e_cannot_index_a_funcref));\n\t    return FAIL;\n\tcase VAR_FLOAT:\n#ifdef FEAT_FLOAT\n\t    if (verbose)\n\t\temsg(_(e_using_float_as_string));\n\t    return FAIL;\n#endif\n\tcase VAR_BOOL:\n\tcase VAR_SPECIAL:\n\tcase VAR_JOB:\n\tcase VAR_CHANNEL:\n\tcase VAR_INSTR:\n\t    if (verbose)\n\t\temsg(_(e_cannot_index_special_variable));\n\t    return FAIL;\n\tcase VAR_UNKNOWN:\n\tcase VAR_ANY:\n\tcase VAR_VOID:\n\t    if (evaluate)\n\t    {\n\t\temsg(_(e_cannot_index_special_variable));\n\t\treturn FAIL;\n\t    }\n\t    \/\/ FALLTHROUGH\n\n\tcase VAR_STRING:\n\tcase VAR_LIST:\n\tcase VAR_DICT:\n\tcase VAR_BLOB:\n\t    break;\n\tcase VAR_NUMBER:\n\t    if (in_vim9script())\n\t\temsg(_(e_cannot_index_number));\n\t    break;\n    }\n    return OK;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":310016,"func":"reset_flush(void)\n{\n    if (my_file != 0)\n\tfflush(my_file);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":317024,"func":"static struct inode_security_struct *inode_security_rcu(struct inode *inode, bool rcu)\n{\n\tint error;\n\n\terror = __inode_security_revalidate(inode, NULL, !rcu);\n\tif (error)\n\t\treturn ERR_PTR(error);\n\treturn selinux_inode(inode);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":262074,"func":"static void AddInstanceStatsToMap(\n    const int32_t instance, const int32_t feature_dim, const int32_t bucket_id,\n    const int32_t logits_dims, const int32_t stats_dims,\n    StatsPartitionMap* stats_map, const TTypes<float>::ConstMatrix& gradients,\n    const TTypes<float>::ConstMatrix& hessians,\n    const TTypes<int32>::ConstVec& node_ids) {\n  const int32_t node_id = node_ids(instance);\n  const auto key = StatsPartitionKey(node_id, feature_dim, bucket_id);\n  std::pair<StatsPartitionIterator, bool> const& insert_result =\n      stats_map->insert(StatsPartitionIterator::value_type(\n          key, std::vector<float>(stats_dims, 0.0f)));\n  auto& stats = insert_result.first->second;\n  for (int stat_dim = 0; stat_dim < logits_dims; ++stat_dim) {\n    stats[stat_dim] += gradients(instance, stat_dim);\n  }\n  for (int stat_dim = logits_dims; stat_dim < stats_dims; ++stat_dim) {\n    stats[stat_dim] += hessians(instance, stat_dim - logits_dims);\n  }\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":400767,"func":"static ssize_t iter_xarray_get_pages(struct iov_iter *i,\n\t\t\t\t     struct page **pages, size_t maxsize,\n\t\t\t\t     unsigned maxpages, size_t *_start_offset)\n{\n\tunsigned nr, offset;\n\tpgoff_t index, count;\n\tsize_t size = maxsize, actual;\n\tloff_t pos;\n\n\tif (!size || !maxpages)\n\t\treturn 0;\n\n\tpos = i->xarray_start + i->iov_offset;\n\tindex = pos >> PAGE_SHIFT;\n\toffset = pos & ~PAGE_MASK;\n\t*_start_offset = offset;\n\n\tcount = 1;\n\tif (size > PAGE_SIZE - offset) {\n\t\tsize -= PAGE_SIZE - offset;\n\t\tcount += size >> PAGE_SHIFT;\n\t\tsize &= ~PAGE_MASK;\n\t\tif (size)\n\t\t\tcount++;\n\t}\n\n\tif (count > maxpages)\n\t\tcount = maxpages;\n\n\tnr = iter_xarray_populate_pages(pages, i->xarray, index, count);\n\tif (nr == 0)\n\t\treturn 0;\n\n\tactual = PAGE_SIZE * nr;\n\tactual -= offset;\n\tif (nr == count && size > 0) {\n\t\tunsigned last_offset = (nr > 1) ? 0 : offset;\n\t\tactual -= PAGE_SIZE - (last_offset + size);\n\t}\n\treturn actual;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":293771,"func":"static ut64 r_ptr(ut8 *buf, RKernelCacheObj *obj) {\n\tut64 decorated_addr = r_read_le64 (buf);\n\treturn K_PPTR (decorated_addr);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":508771,"func":"void free_cache(READ_RECORD *info)\n{\n  if (info->cache)\n  {\n    my_free_lock(info->cache);\n    info->cache=0;\n  }\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":314751,"func":"cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)\n{\n\tsize_t i;\n\n\tfor (i = 0; i < __arraycount(vn); i++)\n\t\tif (vn[i].v == p)\n\t\t\treturn snprintf(buf, bufsiz, \"%s\", vn[i].n);\n\treturn snprintf(buf, bufsiz, \"0x%x\", p);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":473929,"func":"is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)\n{\n  if (code < 256)\n    return ENC_IS_ISO_8859_6_CTYPE(code, ctype);\n  else\n    return FALSE;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":236194,"func":"void gpp_write_rgba(GF_BitStream *bs, u32 col)\n{\n\tgf_bs_write_u8(bs, (col>>16) & 0xFF);\n\tgf_bs_write_u8(bs, (col>>8) & 0xFF);\n\tgf_bs_write_u8(bs, (col) & 0xFF);\n\tgf_bs_write_u8(bs, (col>>24) & 0xFF);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":222863,"func":"Status GraphProperties::AnnotateOutputShapes(GraphDef* output_graph_def) const {\n  *output_graph_def = item_.graph;\n  for (int i = 0; i < output_graph_def->node_size(); i++) {\n    auto node = output_graph_def->mutable_node(i);\n    AttrValue attr_output_shape;\n    auto tensor_properties = GetOutputProperties(node->name());\n    for (const auto& tensor_property : tensor_properties) {\n      TensorShapeProto* proto = attr_output_shape.mutable_list()->add_shape();\n      *proto = tensor_property.shape();\n      NormalizeShapeForOutput(proto);\n    }\n    (*node->mutable_attr())[\"_output_shapes\"] = std::move(attr_output_shape);\n  }\n  return Status::OK();\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":293769,"func":"static int kexts_sort_vaddr_func(const void *a, const void *b) {\n\tRKext *A = (RKext *) a;\n\tRKext *B = (RKext *) b;\n\tint vaddr_compare = A->vaddr - B->vaddr;\n\tif (vaddr_compare == 0) {\n\t\treturn A->text_range.size - B->text_range.size;\n\t}\n\treturn vaddr_compare;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":234223,"func":"regname (unsigned int regno, int name_only_p)\n{\n  static char reg[64];\n\n  const char *name = NULL;\n\n  if (dwarf_regnames_lookup_func != NULL)\n    name = dwarf_regnames_lookup_func (regno);\n\n  if (name != NULL)\n    {\n      if (name_only_p)\n\treturn name;\n      snprintf (reg, sizeof (reg), \"r%d (%s)\", regno, name);\n    }\n  else\n    snprintf (reg, sizeof (reg), \"r%d\", regno);\n  return reg;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":317222,"func":"static int smack_inode_alloc_security(struct inode *inode)\n{\n\tstruct smack_known *skp = smk_of_current();\n\n\tinit_inode_smack(inode, skp);\n\treturn 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":294528,"func":"d_lite_s_alloc_complex(VALUE klass)\n{\n    return d_complex_new_internal(klass,\n\t\t\t\t  INT2FIX(0), 0,\n\t\t\t\t  0, INT2FIX(0),\n\t\t\t\t  0, DEFAULT_SG,\n\t\t\t\t  0, 0, 0,\n\t\t\t\t  0, 0, 0,\n\t\t\t\t  HAVE_JD | HAVE_DF);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":90161,"func":"  NetworkLibraryImpl()\n      : network_manager_monitor_(NULL),\n        data_plan_monitor_(NULL),\n        ethernet_(NULL),\n        wifi_(NULL),\n        cellular_(NULL),\n        available_devices_(0),\n        enabled_devices_(0),\n        connected_devices_(0),\n        offline_mode_(false) {\n    if (EnsureCrosLoaded()) {\n      Init();\n      network_manager_monitor_ =\n          MonitorNetworkManager(&NetworkManagerStatusChangedHandler,\n                                this);\n      data_plan_monitor_ = MonitorCellularDataPlan(&DataPlanUpdateHandler,\n                                                   this);\n    } else {\n      InitTestData();\n    }\n  }\n","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":417115,"func":"const char*\tPlayerGeneric::getCurrentAudioDriverName() const\n{\n\tif (mixer)\n\t\treturn mixer->getCurrentAudioDriverName();\n\n\treturn audioDriverName;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":415187,"func":"has_option (const char *line, const char *name)\n{\n  const char *s;\n  int n = strlen (name);\n\n  s = strstr (line, name);\n  return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n)));\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":512917,"func":"Item *in_decimal::create_item(THD *thd)\n{ \n  return new (thd->mem_root) Item_decimal(thd, 0, FALSE);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":344806,"func":"exited_cleanly(pid_t pid, const char *tag, const char *cmd, int quiet)\n{\n\tint status;\n\n\twhile (waitpid(pid, &status, 0) == -1) {\n\t\tif (errno != EINTR) {\n\t\t\terror(\"%s waitpid: %s\", tag, strerror(errno));\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (WIFSIGNALED(status)) {\n\t\terror(\"%s %s exited on signal %d\", tag, cmd, WTERMSIG(status));\n\t\treturn -1;\n\t} else if (WEXITSTATUS(status) != 0) {\n\t\tdo_log2(quiet ? SYSLOG_LEVEL_DEBUG1 : SYSLOG_LEVEL_INFO,\n\t\t    \"%s %s failed, status %d\", tag, cmd, WEXITSTATUS(status));\n\t\treturn -1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":238605,"func":"static int check_tp_buffer_access(struct bpf_verifier_env *env,\n\t\t\t\t  const struct bpf_reg_state *reg,\n\t\t\t\t  int regno, int off, int size)\n{\n\tint err;\n\n\terr = __check_buffer_access(env, \"tracepoint\", reg, regno, off, size);\n\tif (err)\n\t\treturn err;\n\n\tif (off + size > env->prog->aux->max_tp_access)\n\t\tenv->prog->aux->max_tp_access = off + size;\n\n\treturn 0;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":312451,"func":"wipe_qf_buffer(qf_info_T *qi)\n{\n    buf_T\t*qfbuf;\n\n    if (qi->qf_bufnr != INVALID_QFBUFNR)\n    {\n\tqfbuf = buflist_findnr(qi->qf_bufnr);\n\tif (qfbuf != NULL && qfbuf->b_nwindows == 0)\n\t{\n\t    \/\/ If the quickfix buffer is not loaded in any window, then\n\t    \/\/ wipe the buffer.\n\t    close_buffer(NULL, qfbuf, DOBUF_WIPE, FALSE, FALSE);\n\t    qi->qf_bufnr = INVALID_QFBUFNR;\n\t}\n    }\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":455179,"func":"MOBI_RET mobi_load_rec(MOBIData *m, FILE *file) {\n    MOBI_RET ret;\n    if (m == NULL) {\n        debug_print(\"%s\", \"Mobi structure not initialized\\n\");\n        return MOBI_INIT_FAILED;\n    }\n    MOBIPdbRecord *curr = m->rec;\n    while (curr != NULL) {\n        MOBIPdbRecord *next;\n        size_t size;\n        if (curr->next != NULL) {\n            next = curr->next;\n            size = next->offset - curr->offset;\n        } else {\n            fseek(file, 0, SEEK_END);\n            long diff = ftell(file) - curr->offset;\n            if (diff <= 0) {\n                debug_print(\"Wrong record size: %li\\n\", diff);\n                return MOBI_DATA_CORRUPT;\n            }\n            size = (size_t) diff;\n            next = NULL;\n        }\n\n        curr->size = size;\n        ret = mobi_load_recdata(curr, file);\n        if (ret  != MOBI_SUCCESS) {\n            debug_print(\"Error loading record uid %i data\\n\", curr->uid);\n            mobi_free_rec(m);\n            return ret;\n        }\n        curr = next;\n    }\n    return MOBI_SUCCESS;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":338053,"func":"Name WasmBinaryBuilder::getInlineString() {\n  BYN_TRACE(\"<==\\n\");\n  auto len = getU32LEB();\n\n  auto data = getByteView(len);\n\n  std::string str(data.first, data.second);\n  if (str.find('\\0') != std::string::npos) {\n    throwError(\n      \"inline string contains NULL (0). that is technically valid in wasm, \"\n      \"but you shouldn't do it, and it's not supported in binaryen\");\n  }\n  BYN_TRACE(\"getInlineString: \" << str << \" ==>\\n\");\n  return Name(str);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":432234,"func":"static MemTxResult flatview_write(struct uc_struct *uc, FlatView *fv, hwaddr addr, MemTxAttrs attrs,\n                                  const void *buf, hwaddr len)\n{\n    hwaddr l;\n    hwaddr addr1;\n    MemoryRegion *mr;\n    MemTxResult result = MEMTX_OK;\n\n    l = len;\n    mr = flatview_translate(uc, fv, addr, &addr1, &l, true, attrs);\n    result = flatview_write_continue(uc, fv, addr, attrs, buf, len,\n                                     addr1, l, mr);\n\n    return result;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":281169,"func":"xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl,\n\t\t  struct xfrm_state **xfrm, unsigned short family)\n{\n\tstruct xfrm_state *tp[XFRM_MAX_DEPTH];\n\tstruct xfrm_state **tpp = (npols > 1) ? tp : xfrm;\n\tint cnx = 0;\n\tint error;\n\tint ret;\n\tint i;\n\n\tfor (i = 0; i < npols; i++) {\n\t\tif (cnx + pols[i]->xfrm_nr >= XFRM_MAX_DEPTH) {\n\t\t\terror = -ENOBUFS;\n\t\t\tgoto fail;\n\t\t}\n\n\t\tret = xfrm_tmpl_resolve_one(pols[i], fl, &tpp[cnx], family);\n\t\tif (ret < 0) {\n\t\t\terror = ret;\n\t\t\tgoto fail;\n\t\t} else\n\t\t\tcnx += ret;\n\t}\n\n\t\/* found states are sorted for outbound processing *\/\n\tif (npols > 1)\n\t\txfrm_state_sort(xfrm, tpp, cnx, family);\n\n\treturn cnx;\n\n fail:\n\tfor (cnx--; cnx >= 0; cnx--)\n\t\txfrm_state_put(tpp[cnx]);\n\treturn error;\n\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":292214,"func":"inbound_cap_nak (server *serv, const message_tags_data *tags_data)\n{\n\tserv->sent_capend = TRUE;\n\ttcp_send_len (serv, \"CAP END\\r\\n\", 9);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":313778,"func":"nv_nop(cmdarg_T *cap UNUSED)\n{\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":314478,"func":"static gfn_t gpte_to_gfn_lvl(pt_element_t gpte, int lvl)\n{\n\treturn (gpte & PT_LVL_ADDR_MASK(lvl)) >> PAGE_SHIFT;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":226321,"func":"\nGF_Err prhd_box_size(GF_Box *s)\n{\n\ts->size += 12;\n\treturn GF_OK;","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":244109,"func":"void saiz_box_del(GF_Box *s)\n{\n\tGF_SampleAuxiliaryInfoSizeBox*ptr = (GF_SampleAuxiliaryInfoSizeBox*)s;\n\tif (ptr == NULL) return;\n\tif (ptr->sample_info_size) gf_free(ptr->sample_info_size);\n\tgf_free(ptr);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":244164,"func":"void bloc_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":258080,"func":"  explicit ReverseOp(OpKernelConstruction* context) : OpKernel(context) {}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":333073,"func":"nfa_regcomp_start(\n    char_u\t*expr,\n    int\t\tre_flags)\t    \/\/ see vim_regcomp()\n{\n    size_t\tpostfix_size;\n    int\t\tnstate_max;\n\n    nstate = 0;\n    istate = 0;\n    \/\/ A reasonable estimation for maximum size\n    nstate_max = (int)(STRLEN(expr) + 1) * 25;\n\n    \/\/ Some items blow up in size, such as [A-z].  Add more space for that.\n    \/\/ When it is still not enough realloc_post_list() will be used.\n    nstate_max += 1000;\n\n    \/\/ Size for postfix representation of expr.\n    postfix_size = sizeof(int) * nstate_max;\n\n    post_start = alloc(postfix_size);\n    if (post_start == NULL)\n\treturn FAIL;\n    post_ptr = post_start;\n    post_end = post_start + nstate_max;\n    wants_nfa = FALSE;\n    rex.nfa_has_zend = FALSE;\n    rex.nfa_has_backref = FALSE;\n\n    \/\/ shared with BT engine\n    regcomp_start(expr, re_flags);\n\n    return OK;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":446407,"func":"RZ_API ut64 rz_dyldcache_get_slide(RzDyldCache *cache) {\n\trz_return_val_if_fail(cache, 0);\n\tif (!cache->rebase_infos || !cache->rebase_infos->length) {\n\t\treturn 0;\n\t}\n\n\tsize_t i;\n\tfor (i = 0; i < cache->rebase_infos->length; i++) {\n\t\tif (cache->rebase_infos->entries[i].info) {\n\t\t\treturn cache->rebase_infos->entries[i].info->slide;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":231754,"func":"  void initializeServerHandshake() override {\n    fakeHandshake = new FakeServerHandshake(\n        server->getNonConstConn(),\n        FizzServerQuicHandshakeContext::Builder().build(),\n        GetParam().chloSync,\n        GetParam().cfinSync);\n    if (GetParam().acceptZeroRtt) {\n      fakeHandshake->allowZeroRttKeys();\n    }\n  }","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":443149,"func":"static int jfs_write_begin(struct file *file, struct address_space *mapping,\n\t\t\t\tloff_t pos, unsigned len, unsigned flags,\n\t\t\t\tstruct page **pagep, void **fsdata)\n{\n\tint ret;\n\n\tret = nobh_write_begin(mapping, pos, len, flags, pagep, fsdata,\n\t\t\t\tjfs_get_block);\n\tif (unlikely(ret))\n\t\tjfs_write_failed(mapping, pos + len);\n\n\treturn ret;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":301400,"func":"static int vfswrap_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode)\n{\n#ifdef HAVE_NO_ACL\n\terrno = ENOSYS;\n\treturn -1;\n#else\n\tint result;\n\n\tSTART_PROFILE(chmod_acl);\n\tresult = chmod_acl(handle->conn, name, mode);\n\tEND_PROFILE(chmod_acl);\n\treturn result;\n#endif\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":366338,"func":"static inline void mnt_unhold_writers(struct mount *mnt)\n{\n\t\/*\n\t * MNT_READONLY must become visible before ~MNT_WRITE_HOLD, so writers\n\t * that become unheld will see MNT_READONLY.\n\t *\/\n\tsmp_wmb();\n\tmnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":263490,"func":"static void sco_connect_cfm(struct hci_conn *hcon, __u8 status)\n{\n\tif (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)\n\t\treturn;\n\n\tBT_DBG(\"hcon %p bdaddr %pMR status %u\", hcon, &hcon->dst, status);\n\n\tif (!status) {\n\t\tstruct sco_conn *conn;\n\n\t\tconn = sco_conn_add(hcon);\n\t\tif (conn)\n\t\t\tsco_conn_ready(conn);\n\t} else\n\t\tsco_conn_del(hcon, bt_to_errno(status));\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":247736,"func":"TEST_P(SslSocketTest, FailedClientCertAllowExpiredBadHashVerification) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n\n  OptionalServerConfig server_config;\n  server_config.allow_expired_cert = true;\n  server_config.cert_hash = \"0000000000000000000000000000000000000000000000000000000000000000\";\n  configureServerAndExpiredClientCertificate(listener, client, server_config);\n\n  TestUtilOptionsV2 test_options(listener, client, false, GetParam());\n  testUtilV2(test_options.setExpectedServerStats(\"ssl.fail_verify_cert_hash\")\n                 .setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedTransportFailureReasonContains(\"SSLV3_ALERT_CERTIFICATE_EXPIRED\"));\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":512592,"func":"int Arg_comparator::compare_e_row()\n{\n  (*a)->bring_value();\n  (*b)->bring_value();\n  uint n= (*a)->cols();\n  for (uint i= 0; i<n; i++)\n  {\n    if (!comparators[i].compare())\n      return 0;\n  }\n  return 1;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":317268,"func":"static void selinux_inode_getsecid(struct inode *inode, u32 *secid)\n{\n\tstruct inode_security_struct *isec = inode_security_novalidate(inode);\n\t*secid = isec->sid;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":359411,"func":"DEFUN (neighbor_attr_unchanged4,\n       neighbor_attr_unchanged4_cmd,\n       NEIGHBOR_CMD2 \"attribute-unchanged med (as-path|next-hop)\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"BGP attribute is propagated unchanged to this neighbor\\n\"\n       \"Med attribute\\n\"\n       \"As-path attribute\\n\"\n       \"Nexthop attribute\\n\")\n{\n  u_int16_t flags = PEER_FLAG_MED_UNCHANGED;\n\n  if (strncmp (argv[1], \"as-path\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);\n  else if (strncmp (argv[1], \"next-hop\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);\n\n  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t       bgp_node_safi (vty), flags);\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":512739,"func":"in_double::in_double(THD *thd, uint elements)\n  :in_vector(thd, elements, sizeof(double), (qsort2_cmp) cmp_double, 0)\n{}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":464941,"func":"static inline int is_in_cp950_pua(int c1, int c) {\n\tif ((c1 >= 0xfa && c1 <= 0xfe) || (c1 >= 0x8e && c1 <= 0xa0) ||\n\t\t\t(c1 >= 0x81 && c1 <= 0x8d) || (c1 >= 0xc7 && c1 <= 0xc8)) {\n\t\treturn (c >=0x40 && c <= 0x7e) || (c >= 0xa1 && c <= 0xfe);\n\t}\n\tif (c1 == 0xc6) {\n\t\treturn c >= 0xa1 && c <= 0xfe;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":195294,"func":"  void Compute(OpKernelContext* ctx) override {\n    StagingMap<Ordered>* map = nullptr;\n    OP_REQUIRES_OK(ctx, GetStagingMap(ctx, def(), &map));\n    core::ScopedUnref scope(map);\n    typename StagingMap<Ordered>::OptionalTuple tuple;\n\n    const Tensor* key_tensor;\n    const Tensor* indices_tensor;\n    OpInputList values_tensor;\n\n    OP_REQUIRES_OK(ctx, ctx->input(\"key\", &key_tensor));\n    OP_REQUIRES_OK(ctx, ctx->input(\"indices\", &indices_tensor));\n    OP_REQUIRES_OK(ctx, ctx->input_list(\"values\", &values_tensor));\n    OP_REQUIRES(ctx, key_tensor->NumElements() > 0,\n                errors::InvalidArgument(\"key must not be empty\"));\n\n    \/\/ Create copy for insertion into Staging Area\n    Tensor key(*key_tensor);\n\n    \/\/ Create the tuple to store\n    for (std::size_t i = 0; i < values_tensor.size(); ++i) {\n      tuple.push_back(values_tensor[i]);\n    }\n\n    \/\/ Store the tuple in the map\n    OP_REQUIRES_OK(ctx, map->put(&key, indices_tensor, &tuple));\n  }","target":1,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":289277,"func":"static long snd_pcm_oss_ioctl_compat(struct file *file, unsigned int cmd,\n\t\t\t\t     unsigned long arg)\n{\n\t\/*\n\t * Everything is compatbile except SNDCTL_DSP_MAPINBUF\/SNDCTL_DSP_MAPOUTBUF,\n\t * which are not implemented for the native case either\n\t *\/\n\treturn snd_pcm_oss_ioctl(file, cmd, (unsigned long)compat_ptr(arg));\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":222575,"func":"std::map<string, AttrValue> GetSetAttrs(const FunctionDef& fdef) {\n  std::map<string, AttrValue> set_attrs;\n  for (const auto& pair : fdef.attr()) {\n    if (pair.second.value_case() != AttrValue::VALUE_NOT_SET) {\n      set_attrs[pair.first] = pair.second;\n    }\n  }\n  return set_attrs;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":381879,"func":"udf_pblk_t udf_block_map(struct inode *inode, sector_t block)\n{\n\tstruct kernel_lb_addr eloc;\n\tuint32_t elen;\n\tsector_t offset;\n\tstruct extent_position epos = {};\n\tudf_pblk_t ret;\n\n\tdown_read(&UDF_I(inode)->i_data_sem);\n\n\tif (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) ==\n\t\t\t\t\t\t(EXT_RECORDED_ALLOCATED >> 30))\n\t\tret = udf_get_lb_pblock(inode->i_sb, &eloc, offset);\n\telse\n\t\tret = 0;\n\n\tup_read(&UDF_I(inode)->i_data_sem);\n\tbrelse(epos.bh);\n\n\tif (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_VARCONV))\n\t\treturn udf_fixed_to_variable(ret);\n\telse\n\t\treturn ret;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":328866,"func":"R_API RList *retrieve_all_field_access_string_and_value(void) {\n\treturn retrieve_all_access_string_and_value (FIELD_ACCESS_FLAGS);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":476127,"func":"static u8 encode_bMaxPower(enum usb_device_speed speed,\n\t\tstruct usb_configuration *c)\n{\n\tunsigned val;\n\n\tif (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))\n\t\tval = c->MaxPower;\n\telse\n\t\tval = CONFIG_USB_GADGET_VBUS_DRAW;\n\tif (!val)\n\t\treturn 0;\n\tif (speed < USB_SPEED_SUPER)\n\t\treturn min(val, 500U) \/ 2;\n\telse\n\t\t\/*\n\t\t * USB 3.x supports up to 900mA, but since 900 isn't divisible\n\t\t * by 8 the integral division will effectively cap to 896mA.\n\t\t *\/\n\t\treturn min(val, 900U) \/ 8;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":314757,"func":"cdf_tole4(uint32_t sv)\n{\n\treturn CDF_TOLE4(sv);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":502706,"func":"X509 *SSL_SESSION_get0_peer(SSL_SESSION *s)\n{\n    return s->peer;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":508831,"func":"void LEX::link_first_table_back(TABLE_LIST *first,\n\t\t\t\t   bool link_to_local)\n{\n  if (first)\n  {\n    if ((first->next_global= query_tables))\n      query_tables->prev_global= &first->next_global;\n    else\n      query_tables_last= &first->next_global;\n    query_tables= first;\n\n    if (link_to_local)\n    {\n      first->next_local= select_lex.table_list.first;\n      select_lex.context.table_list= first;\n      select_lex.table_list.first= first;\n      select_lex.table_list.elements++;\t\/\/safety\n    }\n  }\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":462309,"func":"stprintf(stream * s, const char *fmt, ...)\n{\n    int count;\n    va_list args;\n    char buf[1024];\n\n    va_start(args, fmt);\n    count = gs_vsprintf(buf, fmt, args);\n    if (count >= 0) {\n        unsigned count_u = count;\n        sputs(s, (const byte *)buf, count_u, &count_u);\n    }\n    va_end(args);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":338157,"func":"static int decodeHexNibble(char ch) {\n  return ch <= '9' ? ch & 15 : (ch & 15) + 9;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":247647,"func":"TEST_P(SslSocketTest, FailedClientCertificateHashVerificationWrongClientCertificate) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = absl::StrCat(R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      verify_certificate_hash: \")EOF\",\n                                                   TEST_SAN_URI_CERT_256_HASH, \"\\\"\");\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.fail_verify_cert_hash\"));\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":229299,"func":"cql_server::connection::init_cql_serialization_format() {\n    _cql_serialization_format = cql_serialization_format(_version);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":248318,"func":"DLLIMPORT cfg_t *cfg_getsec(cfg_t *cfg, const char *name)\n{\n\tcfg_opt_t *opt;\n\tlong int index;\n\n\topt = cfg_getopt_secidx(cfg, name, &index);\n\treturn cfg_opt_getnsec(opt, index);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":437715,"func":"static u64 pulse_width_count_to_ns(u16 count, u16 divider)\n{\n\tu64 n;\n\tu32 rem;\n\n\t\/*\n\t * The 2 lsb's of the pulse width timer count are not readable, hence\n\t * the (count << 2) | 0x3\n\t *\/\n\tn = (((u64) count << 2) | 0x3) * (divider + 1) * 1000; \/* millicycles *\/\n\trem = do_div(n, CX23888_IR_REFCLK_FREQ \/ 1000000);     \/* \/ MHz => ns *\/\n\tif (rem >= CX23888_IR_REFCLK_FREQ \/ 1000000 \/ 2)\n\t\tn++;\n\treturn n;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":369184,"func":"static int io_statx(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_statx *ctx = &req->statx;\n\tint ret;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask,\n\t\t       ctx->buffer);\n\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":506432,"func":"rpa_add_realm(string_t *realms, const char *realm, const char *service)\n{\n\tstr_append(realms, service);\t\n\tstr_append_c(realms, '@');\n\tstr_append(realms, realm);\n\tstr_append_c(realms, ' ');\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":338233,"func":"static char formatNibble(int nibble) {\n  return nibble < 10 ? '0' + nibble : 'a' - 10 + nibble;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":225472,"func":"void MutableGraphView::UpdateMaxRegularOutputPortForAddedFanin(\n    const OutputPort& fanin) {\n  if (max_regular_output_port()[fanin.node] < fanin.port_id) {\n    max_regular_output_port()[fanin.node] = fanin.port_id;\n  }\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":393509,"func":"static SQInteger closure_getroot(HSQUIRRELVM v)\n{\n    if(SQ_FAILED(sq_getclosureroot(v,-1)))\n        return SQ_ERROR;\n    return 1;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":424931,"func":"int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)\n{\n\tint ret;\n\tint t = 0;\n\tint iter;\n\n\tIWL_DEBUG_INFO(trans, \"iwl_trans_prepare_card_hw enter\\n\");\n\n\tret = iwl_pcie_set_hw_ready(trans);\n\t\/* If the card is ready, exit 0 *\/\n\tif (ret >= 0)\n\t\treturn 0;\n\n\tiwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,\n\t\t    CSR_RESET_LINK_PWR_MGMT_DISABLED);\n\tusleep_range(1000, 2000);\n\n\tfor (iter = 0; iter < 10; iter++) {\n\t\t\/* If HW is not ready, prepare the conditions to check again *\/\n\t\tiwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,\n\t\t\t    CSR_HW_IF_CONFIG_REG_PREPARE);\n\n\t\tdo {\n\t\t\tret = iwl_pcie_set_hw_ready(trans);\n\t\t\tif (ret >= 0)\n\t\t\t\treturn 0;\n\n\t\t\tusleep_range(200, 1000);\n\t\t\tt += 200;\n\t\t} while (t < 150000);\n\t\tmsleep(25);\n\t}\n\n\tIWL_ERR(trans, \"Couldn't prepare the card\\n\");\n\n\treturn ret;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":316990,"func":"static int selinux_dentry_init_security(struct dentry *dentry, int mode,\n\t\t\t\t\tconst struct qstr *name, void **ctx,\n\t\t\t\t\tu32 *ctxlen)\n{\n\tu32 newsid;\n\tint rc;\n\n\trc = selinux_determine_inode_label(selinux_cred(current_cred()),\n\t\t\t\t\t   d_inode(dentry->d_parent), name,\n\t\t\t\t\t   inode_mode_to_security_class(mode),\n\t\t\t\t\t   &newsid);\n\tif (rc)\n\t\treturn rc;\n\n\treturn security_sid_to_context(&selinux_state, newsid, (char **)ctx,\n\t\t\t\t       ctxlen);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":292157,"func":"void CallInfo::set_common(Klass* resolved_klass,\n                          Klass* selected_klass,\n                          const methodHandle& resolved_method,\n                          const methodHandle& selected_method,\n                          CallKind kind,\n                          int index,\n                          TRAPS) {\n  assert(resolved_method->signature() == selected_method->signature(), \"signatures must correspond\");\n  _resolved_klass  = resolved_klass;\n  _selected_klass  = selected_klass;\n  _resolved_method = resolved_method;\n  _selected_method = selected_method;\n  _call_kind       = kind;\n  _call_index      = index;\n  _resolved_appendix = Handle();\n  DEBUG_ONLY(verify());  \/\/ verify before making side effects\n\n  CompilationPolicy::compile_if_required(selected_method, THREAD);\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":244042,"func":"GF_Box *dOps_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_OpusSpecificBox, GF_ISOM_BOX_TYPE_DOPS);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":232333,"func":"void gf_isom_box_array_reset_parent(GF_List **child_boxes, GF_List *boxlist)\n{\n\tu32 count, i;\n\tif (!boxlist) return;\n\tcount = gf_list_count(boxlist);\n\tfor (i = 0; i < count; i++) {\n\t\tGF_Box *a = (GF_Box *)gf_list_get(boxlist, i);\n\t\tif (a) gf_isom_box_del_parent(child_boxes, a);\n\t}\n\tgf_list_reset(boxlist);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":387856,"func":"void InstanceKlass::set_source_debug_extension(const char* array, int length) {\n  if (array == NULL) {\n    _source_debug_extension = NULL;\n  } else {\n    \/\/ Adding one to the attribute length in order to store a null terminator\n    \/\/ character could cause an overflow because the attribute length is\n    \/\/ already coded with an u4 in the classfile, but in practice, it's\n    \/\/ unlikely to happen.\n    assert((length+1) > length, \"Overflow checking\");\n    char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass);\n    for (int i = 0; i < length; i++) {\n      sde[i] = array[i];\n    }\n    sde[length] = '\\0';\n    _source_debug_extension = sde;\n  }\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":508859,"func":"Lex_input_stream::reset(char *buffer, unsigned int length)\n{\n  yylineno= 1;\n  yylval= NULL;\n  lookahead_token= -1;\n  lookahead_yylval= NULL;\n  m_ptr= buffer;\n  m_tok_start= NULL;\n  m_tok_end= NULL;\n  m_end_of_query= buffer + length;\n  m_tok_start_prev= NULL;\n  m_buf= buffer;\n  m_buf_length= length;\n  m_echo= TRUE;\n  m_cpp_tok_start= NULL;\n  m_cpp_tok_start_prev= NULL;\n  m_cpp_tok_end= NULL;\n  m_body_utf8= NULL;\n  m_cpp_utf8_processed_ptr= NULL;\n  next_state= MY_LEX_START;\n  found_semicolon= NULL;\n  ignore_space= MY_TEST(m_thd->variables.sql_mode & MODE_IGNORE_SPACE);\n  stmt_prepare_mode= FALSE;\n  multi_statements= TRUE;\n  in_comment=NO_COMMENT;\n  m_underscore_cs= NULL;\n  m_cpp_ptr= m_cpp_buf;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":246466,"func":"static void wasm_sec_free(RBinWasmSection *sec) {\n\tif (sec) {\n\t\tfree (sec->name);\n\t\tfree (sec);\n\t}\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":90788,"func":"  QuotaCallback* NewWaitableGlobalQuotaCallback() {\n    ++waiting_callbacks_;\n    return callback_factory_.NewCallback(\n            &UsageAndQuotaDispatcherTask::DidGetGlobalQuota);\n  }\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":220230,"func":"const NodeDef& Node::def() const { return props_->node_def; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":231703,"func":"TEST_F(QuicServerTransportTest, TimeoutsNotSetAfterClose) {\n  StreamId streamId = server->createBidirectionalStream().value();\n\n  auto expected = IOBuf::copyBuffer(\"hello\");\n  auto packet = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      streamId,\n      *expected,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n  server->close(std::make_pair(\n      QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),\n      std::string(\"how about no\")));\n  server->idleTimeout().cancelTimeout();\n  ASSERT_FALSE(server->idleTimeout().isScheduled());\n\n  deliverDataWithoutErrorCheck(packet->clone());\n  ASSERT_FALSE(server->idleTimeout().isScheduled());\n  ASSERT_FALSE(server->lossTimeout().isScheduled());\n  ASSERT_FALSE(server->ackTimeout().isScheduled());\n  ASSERT_TRUE(server->drainTimeout().isScheduled());\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":313544,"func":"\t__acquires(rose_neigh_list_lock)\n{\n\tstruct rose_neigh *rose_neigh;\n\tint i = 1;\n\n\tspin_lock_bh(&rose_neigh_list_lock);\n\tif (*pos == 0)\n\t\treturn SEQ_START_TOKEN;\n\n\tfor (rose_neigh = rose_neigh_list; rose_neigh && i < *pos;\n\t     rose_neigh = rose_neigh->next, ++i);\n\n\treturn (i == *pos) ? rose_neigh : NULL;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":218764,"func":"static void XHighlightWidget(Display *display,const XWindowInfo *window_info,\n  const int x,const int y)\n{\n  \/*\n    Draw the widget highlighting rectangle.\n  *\/\n  XSetBevelColor(display,window_info,MagickTrue);\n  (void) XDrawRectangle(display,window_info->id,window_info->widget_context,x,y,\n    window_info->width-(x << 1),window_info->height-(y << 1));\n  (void) XDrawRectangle(display,window_info->id,window_info->widget_context,\n    x-1,y-1,window_info->width-(x << 1)+1,window_info->height-(y << 1)+1);\n  XSetBevelColor(display,window_info,MagickFalse);\n  (void) XDrawRectangle(display,window_info->id,window_info->widget_context,\n    x-1,y-1,window_info->width-(x << 1),window_info->height-(y << 1));\n  (void) XSetFillStyle(display,window_info->widget_context,FillSolid);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":274714,"func":"callbacks_save_project_activate                       (GtkMenuItem     *menuitem,\n                                        gpointer         user_data)\n{\n  if (mainProject->project)\n    main_save_project_from_filename (mainProject, mainProject->project);\n  else\n    callbacks_generic_save_activate (menuitem, (gpointer) CALLBACKS_SAVE_PROJECT_AS);\n  callbacks_update_layer_tree();\n  return;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":226010,"func":"GF_Err hinf_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":438654,"func":"u_undofile_reset_and_delete(buf_T *buf)\n{\n    char_u *file_name;\n\n    if (!buf->b_p_udf)\n\treturn;\n\n    file_name = u_get_undo_file_name(buf->b_ffname, TRUE);\n    if (file_name != NULL)\n    {\n\tmch_remove(file_name);\n\tvim_free(file_name);\n    }\n\n    set_option_value((char_u *)\"undofile\", 0L, NULL, OPT_LOCAL);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":225782,"func":"GF_Err def_parent_full_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":312468,"func":"qf_find_help_win(void)\n{\n    win_T *wp;\n\n    FOR_ALL_WINDOWS(wp)\n\tif (bt_help(wp->w_buffer))\n\t    return wp;\n\n    return NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":243008,"func":"static int mbedtls_ssl_dtls_record_replay_check( mbedtls_ssl_context *ssl, uint8_t *record_in_ctr )\n{\n    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;\n    unsigned char *original_in_ctr;\n\n    \/\/ save original in_ctr\n    original_in_ctr = ssl->in_ctr;\n\n    \/\/ use counter from record\n    ssl->in_ctr = record_in_ctr;\n\n    ret = mbedtls_ssl_dtls_replay_check( (mbedtls_ssl_context const *) ssl );\n\n    \/\/ restore the counter\n    ssl->in_ctr = original_in_ctr;\n\n    return ret;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":207700,"func":"TerminalUserInfo UserTerminalRouter::getInfoForId(const string &id) {\n  auto it = idInfoMap.find(id);\n  if (it == idInfoMap.end()) {\n    STFATAL << \" Tried to read from an id that no longer exists\";\n  }\n  return it->second;\n}","target":1,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":353235,"func":"void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) {\n  screenParams.size = -1;\n  screenParams.dotRadius = -1;\n  screenParams.gamma = (SplashCoord)1.0;\n  screenParams.blackThreshold = (SplashCoord)0.0;\n  screenParams.whiteThreshold = (SplashCoord)1.0;\n\n  \/\/ use clustered dithering for resolution >= 300 dpi\n  \/\/ (compare to 299.9 to avoid floating point issues)\n  if (hDPI > 299.9 && vDPI > 299.9) {\n    screenParams.type = splashScreenStochasticClustered;\n    if (screenParams.size < 0) {\n      screenParams.size = 64;\n    }\n    if (screenParams.dotRadius < 0) {\n      screenParams.dotRadius = 2;\n    }\n  } else {\n    screenParams.type = splashScreenDispersed;\n    if (screenParams.size < 0) {\n      screenParams.size = 4;\n    }\n  }\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":430369,"func":"struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos)\n{\n\tstruct list_head *lh;\n\n\tlh = ((struct list_head *)v)->next;\n\t++*ppos;\n\treturn lh == head ? NULL : lh;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":432164,"func":"getSortAndGroupStagesFromPipeline(const Pipeline::SourceContainer& sources) {\n    boost::intrusive_ptr<DocumentSourceSort> sortStage = nullptr;\n    boost::intrusive_ptr<DocumentSourceGroup> groupStage = nullptr;\n\n    auto sourcesIt = sources.begin();\n    if (sourcesIt != sources.end()) {\n        sortStage = dynamic_cast<DocumentSourceSort*>(sourcesIt->get());\n        if (sortStage) {\n            if (!sortStage->hasLimit()) {\n                ++sourcesIt;\n            } else {\n                \/\/ This $sort stage was previously followed by a $limit stage.\n                sourcesIt = sources.end();\n            }\n        }\n    }\n\n    if (sourcesIt != sources.end()) {\n        groupStage = dynamic_cast<DocumentSourceGroup*>(sourcesIt->get());\n    }\n\n    return std::make_pair(sortStage, groupStage);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":432255,"func":"static int subpage_register(struct uc_struct *uc, subpage_t *mmio, uint32_t start, uint32_t end,\n                            uint16_t section)\n{\n    int idx, eidx;\n\n    if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE)\n        return -1;\n    idx = SUBPAGE_IDX(start);\n    eidx = SUBPAGE_IDX(end);\n#if defined(DEBUG_SUBPAGE)\n    printf(\"%s: %p start %08x end %08x idx %08x eidx %08x section %d\\n\",\n           __func__, mmio, start, end, idx, eidx, section);\n#endif\n    for (; idx <= eidx; idx++) {\n        mmio->sub_section[idx] = section;\n    }\n\n    return 0;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":254706,"func":"njs_typed_array_prototype_iterator_obj(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t kind)\n{\n    njs_value_t        *this;\n    njs_typed_array_t  *array;\n\n    this = njs_argument(args, 0);\n    if (njs_slow_path(!njs_is_typed_array(this))) {\n        njs_type_error(vm, \"this is not a typed array\");\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(this);\n    if (njs_slow_path(njs_is_detached_buffer(array->buffer))) {\n        njs_type_error(vm, \"detached buffer\");\n        return NJS_ERROR;\n    }\n\n    return njs_array_iterator_create(vm, this, &vm->retval, kind);\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":222495,"func":"FunctionCallFrame::FunctionCallFrame(DataTypeSlice arg_types,\n                                     DataTypeSlice ret_types)\n    : arg_types_(arg_types.begin(), arg_types.end()),\n      ret_types_(ret_types.begin(), ret_types.end()) {\n  args_.resize(arg_types_.size());\n  rets_.resize(ret_types_.size());\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":310054,"func":"extended_pair_content(int pair, int *f, int *b)\n{\n    return NCURSES_SP_NAME(extended_pair_content) (CURRENT_SCREEN, pair, f, b);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":386499,"func":"void DL_Dxf::addDictionaryEntry(DL_CreationInterface* creationInterface) {\n    creationInterface->addDictionaryEntry(DL_DictionaryEntryData(getStringValue(3, \"\"), getStringValue(350, \"\")));\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":231708,"func":"void recoverOrResetCongestionAndRttState(\n    QuicServerConnectionState& conn,\n    const folly::SocketAddress& peerAddress) {\n  auto& lastState = conn.migrationState.lastCongestionAndRtt;\n  if (lastState && lastState->peerAddress == peerAddress &&\n      (Clock::now() - lastState->recordTime <=\n       kTimeToRetainLastCongestionAndRttState)) {\n    \/\/ recover from matched non-stale state\n    conn.congestionController = std::move(lastState->congestionController);\n    conn.lossState.srtt = lastState->srtt;\n    conn.lossState.lrtt = lastState->lrtt;\n    conn.lossState.rttvar = lastState->rttvar;\n    conn.lossState.mrtt = lastState->mrtt;\n    conn.migrationState.lastCongestionAndRtt = folly::none;\n  } else {\n    resetCongestionAndRttState(conn);\n  }\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":226064,"func":"\nGF_Err stsg_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->grouping_type);\n\tgf_bs_write_u16(bs, ptr->nb_groups);\n\tfor (i = 0; i < ptr->nb_groups; i++) {\n\t\tgf_bs_write_u32(bs, ptr->group_description_index[i]);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":292160,"func":"void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {\n  LinkInfo link_info(pool, index, method, CHECK);\n  resolve_field(fd, link_info, byte, true, CHECK);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":386593,"func":"void DL_Dxf::addTrace(DL_CreationInterface* creationInterface) {\n    DL_TraceData td;\n    \n    for (int k = 0; k < 4; k++) {\n       td.x[k] = getRealValue(10 + k, 0.0);\n       td.y[k] = getRealValue(20 + k, 0.0);\n       td.z[k] = getRealValue(30 + k, 0.0);\n    }\n    creationInterface->addTrace(td);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":272354,"func":"digest_get_digest_oid(cms_context *cms)\n{\n\tint i = cms->selected_digest;\n\treturn digest_params[i].digest_tag;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":359436,"func":"DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,\n       clear_ip_bgp_peer_group_in_prefix_filter_cmd,\n       \"clear ip bgp peer-group WORD in prefix-filter\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all members of peer-group\\n\"\n       \"BGP peer-group name\\n\"\n       \"Soft reconfig inbound update\\n\"\n       \"Push out prefix-list ORF and do inbound soft reconfig\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,\n\t\t\tBGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":412335,"func":"static RzList *relocs(RzBinFile *bf) {\n\trz_return_val_if_fail(bf && bf->o, NULL);\n\tQnxObj *qo = bf->o->bin_obj;\n\tRzBinReloc *reloc = NULL;\n\tRzListIter *it = NULL;\n\tRzList *relocs = rz_list_newf(free);\n\tif (!relocs) {\n\t\treturn NULL;\n\t}\n\n\trz_list_foreach (qo->fixups, it, reloc) {\n\t\tRzBinReloc *copy = RZ_NEW0(RzBinReloc);\n\t\tif (!copy) {\n\t\t\tbreak;\n\t\t}\n\t\tcopy->vaddr = reloc->vaddr;\n\t\tcopy->paddr = reloc->paddr;\n\t\tcopy->type = reloc->type;\n\t\trz_list_append(relocs, copy);\n\t}\n\treturn relocs;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":223398,"func":"static void * pcre2_jit_malloc(size_t size, void *allocator_data)\n{\npcre2_memctl *allocator = ((pcre2_memctl*)allocator_data);\nreturn allocator->malloc(size, allocator->memory_data);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":508761,"func":"int _ma_initialize_data_file(MARIA_SHARE *share, File dfile)\n{\n  if (share->data_file_type == BLOCK_RECORD)\n  {\n    share->bitmap.block_size= share->base.block_size;\n    share->bitmap.file.file = dfile;\n    return _ma_bitmap_create_first(share);\n  }\n  return 0;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":292178,"func":"int LinkResolver::resolve_virtual_vtable_index(Klass* receiver_klass,\n                                               const LinkInfo& link_info) {\n  EXCEPTION_MARK;\n  CallInfo info;\n  resolve_virtual_call(info, Handle(), receiver_klass, link_info,\n                       \/*check_null_or_abstract*\/false, THREAD);\n  if (HAS_PENDING_EXCEPTION) {\n    CLEAR_PENDING_EXCEPTION;\n    return Method::invalid_vtable_index;\n  }\n  return info.vtable_index();\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":300774,"func":"static void tipc_sk_check_probing_state(struct sock *sk,\n\t\t\t\t\tstruct sk_buff_head *list)\n{\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tu32 pnode = tsk_peer_node(tsk);\n\tu32 pport = tsk_peer_port(tsk);\n\tu32 self = tsk_own_node(tsk);\n\tu32 oport = tsk->portid;\n\tstruct sk_buff *skb;\n\n\tif (tsk->probe_unacked) {\n\t\ttipc_set_sk_state(sk, TIPC_DISCONNECTING);\n\t\tsk->sk_err = ECONNABORTED;\n\t\ttipc_node_remove_conn(sock_net(sk), pnode, pport);\n\t\tsk->sk_state_change(sk);\n\t\treturn;\n\t}\n\t\/* Prepare new probe *\/\n\tskb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 0,\n\t\t\t      pnode, self, pport, oport, TIPC_OK);\n\tif (skb)\n\t\t__skb_queue_tail(list, skb);\n\ttsk->probe_unacked = true;\n\tsk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV);\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":252407,"func":"int mz_compress(unsigned char *pDest, mz_ulong *pDest_len,\n                const unsigned char *pSource, mz_ulong source_len) {\n  return mz_compress2(pDest, pDest_len, pSource, source_len,\n                      MZ_DEFAULT_COMPRESSION);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":430439,"func":"static void ovs_nla_free_set_action(const struct nlattr *a)\n{\n\tconst struct nlattr *ovs_key = nla_data(a);\n\tstruct ovs_tunnel_info *ovs_tun;\n\n\tswitch (nla_type(ovs_key)) {\n\tcase OVS_KEY_ATTR_TUNNEL_INFO:\n\t\tovs_tun = nla_data(ovs_key);\n\t\tdst_release((struct dst_entry *)ovs_tun->tun_dst);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":481272,"func":"static int mlx5_fpga_conn_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,\n\t\t\t\t      struct mlx5_core_mkey *mkey)\n{\n\tint inlen = MLX5_ST_SZ_BYTES(create_mkey_in);\n\tvoid *mkc;\n\tu32 *in;\n\tint err;\n\n\tin = kvzalloc(inlen, GFP_KERNEL);\n\tif (!in)\n\t\treturn -ENOMEM;\n\n\tmkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);\n\tMLX5_SET(mkc, mkc, access_mode_1_0, MLX5_MKC_ACCESS_MODE_PA);\n\tMLX5_SET(mkc, mkc, lw, 1);\n\tMLX5_SET(mkc, mkc, lr, 1);\n\n\tMLX5_SET(mkc, mkc, pd, pdn);\n\tMLX5_SET(mkc, mkc, length64, 1);\n\tMLX5_SET(mkc, mkc, qpn, 0xffffff);\n\n\terr = mlx5_core_create_mkey(mdev, mkey, in, inlen);\n\n\tkvfree(in);\n\treturn err;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":502694,"func":"long SSL_CTX_get_timeout(const SSL_CTX *s)\n{\n    if (s == NULL)\n        return (0);\n    return (s->session_timeout);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":445897,"func":"ecryption_copy_ready_cb (GObject      *source_object,\n\t\t\t GAsyncResult *result,\n\t\t\t gpointer      user_data)\n{\n\tEncryptData *edata = user_data;\n\tFrWindow    *window = edata->window;\n\tGError      *error = NULL;\n\n\t_fr_window_stop_activity_mode (window);\n\tclose_progress_dialog (window, FALSE);\n\n\tif (! g_file_copy_finish (G_FILE (source_object), result, &error)) {\n\t\t_handle_archive_operation_error (window,\n\t\t\t\t\t\t edata->new_archive,\n\t\t\t\t\t\t FR_ACTION_CREATING_NEW_ARCHIVE,\n\t\t\t\t\t\t error,\n\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t NULL);\n\t\tfr_window_stop_batch (window);\n\n\t\tg_error_free (error);\n\t\treturn;\n\t}\n\n\tfr_window_set_password (window, edata->password);\n\tfr_window_set_encrypt_header (window, edata->encrypt_header);\n\twindow->priv->reload_archive = TRUE;\n\tfr_window_exec_next_batch_action (window);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":257006,"func":"static void *route4_get(struct tcf_proto *tp, u32 handle)\n{\n\tstruct route4_head *head = rtnl_dereference(tp->root);\n\tstruct route4_bucket *b;\n\tstruct route4_filter *f;\n\tunsigned int h1, h2;\n\n\th1 = to_hash(handle);\n\tif (h1 > 256)\n\t\treturn NULL;\n\n\th2 = from_hash(handle >> 16);\n\tif (h2 > 32)\n\t\treturn NULL;\n\n\tb = rtnl_dereference(head->table[h1]);\n\tif (b) {\n\t\tfor (f = rtnl_dereference(b->ht[h2]);\n\t\t     f;\n\t\t     f = rtnl_dereference(f->next))\n\t\t\tif (f->handle == handle)\n\t\t\t\treturn f;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":229221,"func":"cql_server::connection::process_batch(uint16_t stream, request_reader in, service::client_state& client_state, service_permit permit,\n        tracing::trace_state_ptr trace_state) {\n    ++_server._stats.batch_requests;\n    return process(stream, in, client_state, permit, std::move(trace_state), process_batch_internal);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":513154,"func":"static SHOW_COMP_OPTION plugin_status(const LEX_STRING *name, int type)\n{\n  SHOW_COMP_OPTION rc= SHOW_OPTION_NO;\n  struct st_plugin_int *plugin;\n  DBUG_ENTER(\"plugin_is_ready\");\n  mysql_mutex_lock(&LOCK_plugin);\n  if ((plugin= plugin_find_internal(name, type)))\n  {\n    rc= SHOW_OPTION_DISABLED;\n    if (plugin->state == PLUGIN_IS_READY)\n      rc= SHOW_OPTION_YES;\n  }\n  mysql_mutex_unlock(&LOCK_plugin);\n  DBUG_RETURN(rc);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":512302,"func":"  Item_date_literal(THD *thd, const Date *ltime)\n    :Item_temporal_literal(thd),\n     cached_time(*ltime)\n  {\n    DBUG_ASSERT(cached_time.is_valid_date());\n    max_length= MAX_DATE_WIDTH;\n    \/*\n      If date has zero month or day, it can return NULL in case of\n      NO_ZERO_DATE or NO_ZERO_IN_DATE.\n      If date is `February 30`, it can return NULL in case if\n      no ALLOW_INVALID_DATES is set.\n      We can't set null_value using the current sql_mode here in constructor,\n      because sql_mode can change in case of prepared statements\n      between PREPARE and EXECUTE.\n      Here we only set maybe_null to true if the value has such anomalies.\n      Later (during execution time), if maybe_null is true, then the value\n      will be checked per row, according to the execution time sql_mode.\n      The check_date() below call should cover all cases mentioned.\n    *\/\n    maybe_null= cached_time.check_date(TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE);\n  }","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":274696,"func":"callbacks_show_sidepane_toggled (GtkMenuItem *menuitem, gpointer user_data)\n{\n\tgtk_widget_set_visible (user_data, GTK_CHECK_MENU_ITEM(menuitem)->active);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":244291,"func":"GF_Err prft_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_ProducerReferenceTimeBox *ptr = (GF_ProducerReferenceTimeBox *) s;\n\n\tISOM_DECREASE_SIZE(ptr, 12);\n\tptr->refTrackID = gf_bs_read_u32(bs);\n\tptr->ntp = gf_bs_read_u64(bs);\n\tif (ptr->version==0) {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->timestamp = gf_bs_read_u32(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->timestamp = gf_bs_read_u64(bs);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":225899,"func":"\nGF_Box *sdtp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleDependencyTypeBox, GF_ISOM_BOX_TYPE_SDTP);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":221640,"func":"CstrBroadcastableOpLowering::CstrBroadcastableOpLowering(MLIRContext* ctx)\n    : Base(ctx) {}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":301358,"func":"static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)\n{\n\treturn listxattr(path, list, size);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":376318,"func":"camel_gpg_context_get_always_trust (CamelGpgContext *context)\n{\n\tg_return_val_if_fail (CAMEL_IS_GPG_CONTEXT (context), FALSE);\n\n\treturn context->priv->always_trust;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":369126,"func":"static void io_req_map_rw(struct io_kiocb *req, const struct iovec *iovec,\n\t\t\t  const struct iovec *fast_iov, struct iov_iter *iter)\n{\n\tstruct io_async_rw *rw = req->async_data;\n\n\tmemcpy(&rw->s.iter, iter, sizeof(*iter));\n\trw->free_iovec = iovec;\n\trw->bytes_done = 0;\n\t\/* can only be fixed buffers, no need to do anything *\/\n\tif (iov_iter_is_bvec(iter))\n\t\treturn;\n\tif (!iovec) {\n\t\tunsigned iov_off = 0;\n\n\t\trw->s.iter.iov = rw->s.fast_iov;\n\t\tif (iter->iov != fast_iov) {\n\t\t\tiov_off = iter->iov - fast_iov;\n\t\t\trw->s.iter.iov += iov_off;\n\t\t}\n\t\tif (rw->s.fast_iov != fast_iov)\n\t\t\tmemcpy(rw->s.fast_iov + iov_off, fast_iov + iov_off,\n\t\t\t       sizeof(struct iovec) * iter->nr_segs);\n\t} else {\n\t\treq->flags |= REQ_F_NEED_CLEANUP;\n\t}\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":359630,"func":"DEFUN (clear_bgp_peer_group_soft_out,\n       clear_bgp_peer_group_soft_out_cmd,\n       \"clear bgp peer-group WORD soft out\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all members of peer-group\\n\"\n       \"BGP peer-group name\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,\n\t\t\tBGP_CLEAR_SOFT_OUT, argv[0]);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":309887,"func":"drv_getsize(TERMINAL_CONTROL_BLOCK * TCB, int *l, int *c)\n{\n    AssertTCB();\n    assert(l != 0 && c != 0);\n    *l = lines;\n    *c = columns;\n    return OK;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":309983,"func":"_nc_mouse_wrap(SCREEN *sp)\n\/* release mouse -- called by endwin() before shellout\/exit *\/\n{\n    TR(MY_TRACE, (\"_nc_mouse_wrap() called\"));\n\n    switch (sp->_mouse_type) {\n    case M_XTERM:\n\tif (sp->_mouse_mask)\n\t    mouse_activate(sp, FALSE);\n\tbreak;\n#if USE_GPM_SUPPORT\n\t\/* GPM: pass all mouse events to next client *\/\n    case M_GPM:\n\tif (sp->_mouse_mask)\n\t    mouse_activate(sp, FALSE);\n\tbreak;\n#endif\n#if USE_SYSMOUSE\n    case M_SYSMOUSE:\n\tmouse_activate(sp, FALSE);\n\tbreak;\n#endif\n#ifdef USE_TERM_DRIVER\n    case M_TERM_DRIVER:\n\tmouse_activate(sp, FALSE);\n\tbreak;\n#endif\n    case M_NONE:\n\tbreak;\n    }\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":398520,"func":"static int init_die(RzBinDwarfDie *die, ut64 abbr_code, ut64 attr_count) {\n\tif (!die) {\n\t\treturn -1;\n\t}\n\tif (attr_count) {\n\t\tdie->attr_values = calloc(sizeof(RzBinDwarfAttrValue), attr_count);\n\t\tif (!die->attr_values) {\n\t\t\treturn -1;\n\t\t}\n\t} else {\n\t\tdie->attr_values = NULL;\n\t}\n\tdie->abbrev_code = abbr_code;\n\tdie->capacity = attr_count;\n\tdie->count = 0;\n\treturn 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":261986,"func":"static int bundle_remove_conn(struct connectbundle *bundle,\n                              struct connectdata *conn)\n{\n  struct Curl_llist_element *curr;\n\n  curr = bundle->conn_list.head;\n  while(curr) {\n    if(curr->ptr == conn) {\n      Curl_llist_remove(&bundle->conn_list, curr, NULL);\n      bundle->num_connections--;\n      conn->bundle = NULL;\n      return 1; \/* we removed a handle *\/\n    }\n    curr = curr->next;\n  }\n  DEBUGASSERT(0);\n  return 0;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":309991,"func":"_nc_captoinfo_leaks(void)\n{\n    if (my_string != 0) {\n\tFreeAndNull(my_string);\n    }\n    my_length = 0;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":238449,"func":"static void mark_pkt_end(struct bpf_verifier_state *vstate, int regn, bool range_open)\n{\n\tstruct bpf_func_state *state = vstate->frame[vstate->curframe];\n\tstruct bpf_reg_state *reg = &state->regs[regn];\n\n\tif (reg->type != PTR_TO_PACKET)\n\t\t\/* PTR_TO_PACKET_META is not supported yet *\/\n\t\treturn;\n\n\t\/* The 'reg' is pkt > pkt_end or pkt >= pkt_end.\n\t * How far beyond pkt_end it goes is unknown.\n\t * if (!range_open) it's the case of pkt >= pkt_end\n\t * if (range_open) it's the case of pkt > pkt_end\n\t * hence this pointer is at least 1 byte bigger than pkt_end\n\t *\/\n\tif (range_open)\n\t\treg->range = BEYOND_PKT_END;\n\telse\n\t\treg->range = AT_PKT_END;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":317335,"func":"static int selinux_sem_semctl(struct kern_ipc_perm *sma, int cmd)\n{\n\tint err;\n\tu32 perms;\n\n\tswitch (cmd) {\n\tcase IPC_INFO:\n\tcase SEM_INFO:\n\t\t\/* No specific object, just general system-wide information. *\/\n\t\treturn avc_has_perm(&selinux_state,\n\t\t\t\t    current_sid(), SECINITSID_KERNEL,\n\t\t\t\t    SECCLASS_SYSTEM, SYSTEM__IPC_INFO, NULL);\n\tcase GETPID:\n\tcase GETNCNT:\n\tcase GETZCNT:\n\t\tperms = SEM__GETATTR;\n\t\tbreak;\n\tcase GETVAL:\n\tcase GETALL:\n\t\tperms = SEM__READ;\n\t\tbreak;\n\tcase SETVAL:\n\tcase SETALL:\n\t\tperms = SEM__WRITE;\n\t\tbreak;\n\tcase IPC_RMID:\n\t\tperms = SEM__DESTROY;\n\t\tbreak;\n\tcase IPC_SET:\n\t\tperms = SEM__SETATTR;\n\t\tbreak;\n\tcase IPC_STAT:\n\tcase SEM_STAT:\n\tcase SEM_STAT_ANY:\n\t\tperms = SEM__GETATTR | SEM__ASSOCIATE;\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\terr = ipc_has_perm(sma, perms);\n\treturn err;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":328856,"func":"R_API void r_bin_java_print_enclosing_methods_attr_summary(RBinJavaAttrInfo *attr) {\n\tif (!attr) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaAttrInfo *Deperecated.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"Enclosing Method Attribute Information:\\n\");\n\tprintf (\"  Attribute Offset: 0x%08\"PFMT64x \"\\n\", attr->file_offset);\n\tprintf (\"  Attribute Name Index: %d (%s)\\n\", attr->name_idx, attr->name);\n\tprintf (\"  Attribute Length: %d\\n\", attr->length);\n\tprintf (\"  Class Info Index : 0x%02x\\n\", attr->info.enclosing_method_attr.class_idx);\n\tprintf (\"  Method Name and Type Index : 0x%02x\\n\", attr->info.enclosing_method_attr.method_idx);\n\tprintf (\"  Class Name : %s\\n\", attr->info.enclosing_method_attr.class_name);\n\tprintf (\"  Method Name and Desc : %s %s\\n\", attr->info.enclosing_method_attr.method_name, attr->info.enclosing_method_attr.method_descriptor);\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":359672,"func":"DEFUN (neighbor_remote_as,\n       neighbor_remote_as_cmd,\n       NEIGHBOR_CMD2 \"remote-as <1-65535>\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Specify a BGP neighbor\\n\"\n       AS_STR)\n{\n  return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":359333,"func":"DEFUN (clear_ip_bgp_all_soft_out,\n       clear_ip_bgp_all_soft_out_cmd,\n       \"clear ip bgp * soft out\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,\n                          BGP_CLEAR_SOFT_OUT, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_OUT, NULL);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":256454,"func":"JANET_CORE_FN(cfun_array_pop,\n              \"(array\/pop arr)\",\n              \"Remove the last element of the array and return it. If the array is empty, will return nil. Modifies \"\n              \"the input array.\") {\n    janet_fixarity(argc, 1);\n    JanetArray *array = janet_getarray(argv, 0);\n    return janet_array_pop(array);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":231670,"func":"TEST_F(QuicServerTransportTest, IdleTimeoutExpired) {\n  server->idleTimeout().timeoutExpired();\n\n  EXPECT_FALSE(server->idleTimeout().isScheduled());\n  EXPECT_TRUE(server->isDraining());\n  EXPECT_TRUE(server->isClosed());\n  auto serverReadCodec = makeClientEncryptedCodec();\n  EXPECT_FALSE(verifyFramePresent(\n      serverWrites, *serverReadCodec, QuicFrame::Type::ConnectionCloseFrame));\n  EXPECT_FALSE(verifyFramePresent(\n      serverWrites, *serverReadCodec, QuicFrame::Type::ConnectionCloseFrame));\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":436068,"func":"static void __io_commit_cqring_flush(struct io_ring_ctx *ctx)\n{\n\tif (ctx->off_timeout_used)\n\t\tio_flush_timeouts(ctx);\n\tif (ctx->drain_active)\n\t\tio_queue_deferred(ctx);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":463180,"func":"EXPORTED int annotate_state_set_mailbox_mbe(annotate_state_t *state,\n                                   const mbentry_t *mbentry)\n{\n    return annotate_state_set_scope(state, mbentry, NULL, 0);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":508353,"func":"close_mysql_tables(THD *thd)\n{\n  if (! thd->in_sub_stmt)\n    trans_commit_stmt(thd);\n  close_thread_tables(thd);\n  thd->release_transactional_locks();\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":498128,"func":"static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)\n{\n\tchar *delim = \"?\";\n\n\tif (always_root || page)\n\t\thtml_attr(cgit_rooturl());\n\telse {\n\t\tchar *currenturl = cgit_currenturl();\n\t\thtml_attr(currenturl);\n\t\tfree(currenturl);\n\t}\n\n\tif (page) {\n\t\thtmlf(\"?p=%s\", page);\n\t\tdelim = \"&\";\n\t}\n\tif (search) {\n\t\thtml(delim);\n\t\thtml(\"q=\");\n\t\thtml_attr(search);\n\t\tdelim = \"&\";\n\t}\n\tif (sort) {\n\t\thtml(delim);\n\t\thtml(\"s=\");\n\t\thtml_attr(sort);\n\t\tdelim = \"&\";\n\t}\n\tif (ofs) {\n\t\thtml(delim);\n\t\thtmlf(\"ofs=%d\", ofs);\n\t}\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":417105,"func":"mp_sint32 PlayerGeneric::getSampleShift() const\n{\n\tif (mixer)\n\t\treturn mixer->getSampleShift();\n\t\n\treturn sampleShift;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":333075,"func":"has_state_with_pos(\n    nfa_list_T\t\t*l,\t\/\/ runtime state list\n    nfa_state_T\t\t*state,\t\/\/ state to update\n    regsubs_T\t\t*subs,\t\/\/ pointers to subexpressions\n    nfa_pim_T\t\t*pim)\t\/\/ postponed match or NULL\n{\n    nfa_thread_T\t*thread;\n    int\t\t\ti;\n\n    for (i = 0; i < l->n; ++i)\n    {\n\tthread = &l->t[i];\n\tif (thread->state->id == state->id\n\t\t&& sub_equal(&thread->subs.norm, &subs->norm)\n#ifdef FEAT_SYN_HL\n\t\t&& (!rex.nfa_has_zsubexpr\n\t\t\t\t|| sub_equal(&thread->subs.synt, &subs->synt))\n#endif\n\t\t&& pim_equal(&thread->pim, pim))\n\t    return TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":204814,"func":"static void sixpack_close(struct tty_struct *tty)\n{\n\tstruct sixpack *sp;\n\n\twrite_lock_irq(&disc_data_lock);\n\tsp = tty->disc_data;\n\ttty->disc_data = NULL;\n\twrite_unlock_irq(&disc_data_lock);\n\tif (!sp)\n\t\treturn;\n\n\t\/*\n\t * We have now ensured that nobody can start using ap from now on, but\n\t * we have to wait for all existing users to finish.\n\t *\/\n\tif (!refcount_dec_and_test(&sp->refcnt))\n\t\twait_for_completion(&sp->dead);\n\n\t\/* We must stop the queue to avoid potentially scribbling\n\t * on the free buffers. The sp->dead completion is not sufficient\n\t * to protect us from sp->xbuff access.\n\t *\/\n\tnetif_stop_queue(sp->dev);\n\n\tdel_timer_sync(&sp->tx_t);\n\tdel_timer_sync(&sp->resync_t);\n\n\tunregister_netdev(sp->dev);\n\n\t\/* Free all 6pack frame buffers after unreg. *\/\n\tkfree(sp->rbuff);\n\tkfree(sp->xbuff);\n\n\tfree_netdev(sp->dev);\n}","target":1,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":233894,"func":"   Serializes given variables and adds them to packet given by packet_id *\/\nPHP_FUNCTION(wddx_add_vars)\n{\n\tint num_args, i;\n\tzval *args = NULL;\n\tzval *packet_id;\n\twddx_packet *packet = NULL;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"r+\", &packet_id, &args, &num_args) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif ((packet = (wddx_packet *)zend_fetch_resource(Z_RES_P(packet_id), \"WDDX packet ID\", le_wddx)) == NULL) {\n\t\tRETURN_FALSE;\n\t}\n\n\tfor (i=0; i<num_args; i++) {\n\t\tzval *arg;\n\t\tif (!Z_ISREF(args[i])) {\n\t\t\targ = &args[i];\n\t\t} else {\n\t\t\targ = Z_REFVAL(args[i]);\n\t\t}\n\t\tif (Z_TYPE_P(arg) != IS_ARRAY && Z_TYPE_P(arg) != IS_OBJECT) {\n\t\t\tconvert_to_string_ex(arg);\n\t\t}\n\t\tphp_wddx_add_var(packet, arg);\n\t}\n\n\tRETURN_TRUE;","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":384131,"func":"raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer,\n                                  const unsigned char *s, unsigned int len)\n{\n  XML_WRITER_FLUSH_CLOSE_BRACKET(xml_writer);\n  \n  raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)\"<!-- \", 5);\n  raptor_xml_writer_cdata_counted(xml_writer, s, len);\n  raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)\" -->\", 4);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":472370,"func":"void ciEnv::cache_dtrace_flags() {\n  \/\/ Need lock?\n  _dtrace_extended_probes = ExtendedDTraceProbes;\n  if (_dtrace_extended_probes) {\n    _dtrace_method_probes   = true;\n    _dtrace_alloc_probes    = true;\n  } else {\n    _dtrace_method_probes   = DTraceMethodProbes;\n    _dtrace_alloc_probes    = DTraceAllocProbes;\n  }\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":274733,"func":"callbacks_render_type_changed () {\n\tstatic gboolean isChanging = FALSE;\n\tif (isChanging)\n\t\treturn;\n\n\tisChanging = TRUE;\n\tgerbv_render_types_t type = screenRenderInfo.renderType;\n\tGtkCheckMenuItem *check_item = screen.win.menu_view_render_group[type];\n\tdprintf (\"%s():  type = %d, check_item = %p\\n\", __FUNCTION__, type, check_item);\n\tgtk_check_menu_item_set_active (check_item, TRUE);\n\tgtk_combo_box_set_active (screen.win.sidepaneRenderComboBox, type);\n\n\trender_refresh_rendered_image_on_screen();\n\tisChanging = FALSE;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":236179,"func":"GF_Box *text_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextSampleEntryBox, GF_ISOM_BOX_TYPE_TEXT);\n\tgf_isom_sample_entry_init((GF_SampleEntryBox *)tmp);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":483486,"func":"bool efi_is_table_address(unsigned long phys_addr)\n{\n\tunsigned int i;\n\n\tif (phys_addr == EFI_INVALID_TABLE_ADDR)\n\t\treturn false;\n\n\tfor (i = 0; i < ARRAY_SIZE(efi_tables); i++)\n\t\tif (*(efi_tables[i]) == phys_addr)\n\t\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":364240,"func":"void rds_inc_info_copy(struct rds_incoming *inc,\n\t\t       struct rds_info_iterator *iter,\n\t\t       __be32 saddr, __be32 daddr, int flip)\n{\n\tstruct rds_info_message minfo;\n\n\tminfo.seq = be64_to_cpu(inc->i_hdr.h_sequence);\n\tminfo.len = be32_to_cpu(inc->i_hdr.h_len);\n\n\tif (flip) {\n\t\tminfo.laddr = daddr;\n\t\tminfo.faddr = saddr;\n\t\tminfo.lport = inc->i_hdr.h_dport;\n\t\tminfo.fport = inc->i_hdr.h_sport;\n\t} else {\n\t\tminfo.laddr = saddr;\n\t\tminfo.faddr = daddr;\n\t\tminfo.lport = inc->i_hdr.h_sport;\n\t\tminfo.fport = inc->i_hdr.h_dport;\n\t}\n\n\tminfo.flags = 0;\n\n\trds_info_copy(iter, &minfo, sizeof(minfo));\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":353110,"func":"T3FontCache::~T3FontCache() {\n  gfree(cacheData);\n  gfree(cacheTags);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":202688,"func":"lprn_is_black(gx_device_printer * pdev, int r, int h, int bx)\n{\n    gx_device_lprn *const lprn = (gx_device_lprn *) pdev;\n\n    int bh = lprn->nBh;\n    int bpl = gdev_mem_bytes_per_scan_line(pdev);\n    int x, y, y0;\n    byte *p;\n    int maxY = lprn->BlockLine \/ lprn->nBh * lprn->nBh;\n\n    y0 = (r + h - bh) % maxY;\n    for (y = 0; y < bh; y++) {\n        p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw];\n        for (x = 0; x < lprn->nBw; x++)\n            if (p[x] != 0)\n                return 1;\n    }\n    return 0;\n}","target":1,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":226392,"func":"void esds_box_del(GF_Box *s)\n{\n\tGF_ESDBox *ptr = (GF_ESDBox *)s;\n\tif (ptr == NULL)\treturn;\n\tif (ptr->desc) gf_odf_desc_del((GF_Descriptor *)ptr->desc);\n\tgf_free(ptr);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":229154,"func":"static void set_status(VirtIODevice *vdev, uint8_t status)\n{\n    VirtIOSerial *vser;\n    VirtIOSerialPort *port;\n\n    vser = VIRTIO_SERIAL(vdev);\n    port = find_port_by_id(vser, 0);\n\n    if (port && !use_multiport(port->vser)\n        && (status & VIRTIO_CONFIG_S_DRIVER_OK)) {\n        \/*\n         * Non-multiport guests won't be able to tell us guest\n         * open\/close status.  Such guests can only have a port at id\n         * 0, so set guest_connected for such ports as soon as guest\n         * is up.\n         *\/\n        port->guest_connected = true;\n    }\n    if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {\n        guest_reset(vser);\n    }\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":512527,"func":"  Field *create_tmp_field_ex(TABLE *table, Tmp_field_src *src,\n                             const Tmp_field_param *param)\n  {\n    return Item_type_holder::real_type_handler()->\n           make_and_init_table_field(&name, Record_addr(maybe_null),\n                                     *this, table);\n  }","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":313541,"func":"static void rose_remove_node(struct rose_node *rose_node)\n{\n\tstruct rose_node *s;\n\n\tif ((s = rose_node_list) == rose_node) {\n\t\trose_node_list = rose_node->next;\n\t\tkfree(rose_node);\n\t\treturn;\n\t}\n\n\twhile (s != NULL && s->next != NULL) {\n\t\tif (s->next == rose_node) {\n\t\t\ts->next = rose_node->next;\n\t\t\tkfree(rose_node);\n\t\t\treturn;\n\t\t}\n\n\t\ts = s->next;\n\t}\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":231793,"func":"TEST_F(QuicServerTransportTest, IdleTimerNotResetOnDuplicatePacket) {\n  EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(1);\n  StreamId streamId = server->createBidirectionalStream().value();\n\n  auto expected = IOBuf::copyBuffer(\"hello\");\n  auto packet = recvEncryptedStream(streamId, *expected);\n  ASSERT_TRUE(server->idleTimeout().isScheduled());\n\n  server->idleTimeout().cancelTimeout();\n  ASSERT_FALSE(server->idleTimeout().isScheduled());\n  \/\/ Try delivering the same packet again\n  deliverData(packet->clone(), false);\n  ASSERT_FALSE(server->idleTimeout().isScheduled());\n  EXPECT_CALL(*transportInfoCb_, onQuicStreamClosed());\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":90179,"func":"  virtual void RemoveObserverForAllNetworks(NetworkObserver* observer) {}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":404740,"func":"\t__acquires(files->file_lock)\n{\n\tstruct fdtable *new_fdt, *cur_fdt;\n\n\tspin_unlock(&files->file_lock);\n\tnew_fdt = alloc_fdtable(nr);\n\n\t\/* make sure all fd_install() have seen resize_in_progress\n\t * or have finished their rcu_read_lock_sched() section.\n\t *\/\n\tif (atomic_read(&files->count) > 1)\n\t\tsynchronize_rcu();\n\n\tspin_lock(&files->file_lock);\n\tif (!new_fdt)\n\t\treturn -ENOMEM;\n\t\/*\n\t * extremely unlikely race - sysctl_nr_open decreased between the check in\n\t * caller and alloc_fdtable().  Cheaper to catch it here...\n\t *\/\n\tif (unlikely(new_fdt->max_fds <= nr)) {\n\t\t__free_fdtable(new_fdt);\n\t\treturn -EMFILE;\n\t}\n\tcur_fdt = files_fdtable(files);\n\tBUG_ON(nr < cur_fdt->max_fds);\n\tcopy_fdtable(new_fdt, cur_fdt);\n\trcu_assign_pointer(files->fdt, new_fdt);\n\tif (cur_fdt != &files->fdtab)\n\t\tcall_rcu(&cur_fdt->rcu, free_fdtable_rcu);\n\t\/* coupled with smp_rmb() in fd_install() *\/\n\tsmp_wmb();\n\treturn 1;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":434104,"func":"do_one_arg(char_u *str)\n{\n    char_u\t*p;\n    int\t\tinbacktick;\n\n    inbacktick = FALSE;\n    for (p = str; *str; ++str)\n    {\n\t\/\/ When the backslash is used for escaping the special meaning of a\n\t\/\/ character we need to keep it until wildcard expansion.\n\tif (rem_backslash(str))\n\t{\n\t    *p++ = *str++;\n\t    *p++ = *str;\n\t}\n\telse\n\t{\n\t    \/\/ An item ends at a space not in backticks\n\t    if (!inbacktick && vim_isspace(*str))\n\t\tbreak;\n\t    if (*str == '`')\n\t\tinbacktick ^= TRUE;\n\t    *p++ = *str;\n\t}\n    }\n    str = skipwhite(str);\n    *p = NUL;\n\n    return str;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":338231,"func":"void WasmBinaryWriter::writeField(const Field& field) {\n  if (field.type == Type::i32 && field.packedType != Field::not_packed) {\n    if (field.packedType == Field::i8) {\n      o << S32LEB(BinaryConsts::EncodedType::i8);\n    } else if (field.packedType == Field::i16) {\n      o << S32LEB(BinaryConsts::EncodedType::i16);\n    } else {\n      WASM_UNREACHABLE(\"invalid packed type\");\n    }\n  } else {\n    writeType(field.type);\n  }\n  o << U32LEB(field.mutable_);\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":463055,"func":"static void sungem_mmio_txdma_write(void *opaque, hwaddr addr, uint64_t val,\n                                    unsigned size)\n{\n    SunGEMState *s = opaque;\n\n    if (!(addr < 0x38) && !(addr >= 0x100 && addr <= 0x118)) {\n        qemu_log_mask(LOG_GUEST_ERROR,\n                      \"Write to unknown TXDMA register 0x%\"HWADDR_PRIx\"\\n\",\n                      addr);\n        return;\n    }\n\n    trace_sungem_mmio_txdma_write(addr, val);\n\n    \/* Pre-write filter *\/\n    switch (addr) {\n    \/* Read only registers *\/\n    case TXDMA_TXDONE:\n    case TXDMA_PCNT:\n    case TXDMA_SMACHINE:\n    case TXDMA_DPLOW:\n    case TXDMA_DPHI:\n    case TXDMA_FSZ:\n    case TXDMA_FTAG:\n        return; \/* No actual write *\/\n    }\n\n    s->txdmaregs[addr >> 2] = val;\n\n    \/* Post write action *\/\n    switch (addr) {\n    case TXDMA_KICK:\n        sungem_tx_kick(s);\n        break;\n    case TXDMA_CFG:\n        sungem_update_masks(s);\n        break;\n    }\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":411903,"func":"_find_by_keyword(smartlist_t *s, directory_keyword keyword,\n                 const char *keyword_as_string)\n{\n  directory_token_t *tok = find_opt_by_keyword(s, keyword);\n  if (PREDICT_UNLIKELY(!tok)) {\n    log_err(LD_BUG, \"Missing %s [%d] in directory object that should have \"\n         \"been validated. Internal error.\", keyword_as_string, (int)keyword);\n    tor_assert(tok);\n  }\n  return tok;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":225828,"func":"GF_Err edts_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_EditBox *ptr = (GF_EditBox *)s;\n\n\t\/\/here we have a trick: if editList is empty, skip the box\n\tif (ptr->editList && gf_list_count(ptr->editList->entryList)) {\n\t\treturn gf_isom_box_write_header(s, bs);\n\t} else {\n\t\ts->size = 0;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":248282,"func":"DLLIMPORT char *cfg_getstr(cfg_t *cfg, const char *name)\n{\n\treturn cfg_getnstr(cfg, name, 0);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":317102,"func":"static int smack_ipc_alloc_security(struct kern_ipc_perm *isp)\n{\n\tstruct smack_known **blob = smack_ipc(isp);\n\n\t*blob = smk_of_current();\n\treturn 0;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":220832,"func":"inline int SubscriptToIndex(const NdArrayDesc<4>& desc, int i0, int i1, int i2,\n                            int i3) {\n  TFLITE_DCHECK(i0 >= 0 && i0 < desc.extents[0]);\n  TFLITE_DCHECK(i1 >= 0 && i1 < desc.extents[1]);\n  TFLITE_DCHECK(i2 >= 0 && i2 < desc.extents[2]);\n  TFLITE_DCHECK(i3 >= 0 && i3 < desc.extents[3]);\n  return i0 * desc.strides[0] + i1 * desc.strides[1] + i2 * desc.strides[2] +\n         i3 * desc.strides[3];\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":225718,"func":"GF_Err gen_sample_entry_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)s, bs);\n\tif (e) return e;\n\tISOM_DECREASE_SIZE(s, 8);\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":455312,"func":"bash_progcomp_ignore_filenames (names)\n     char **names;\n{\n  _ignore_completion_names (names, test_for_canon_directory);\n  return 0;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":361747,"func":"static void em28xx_release_resources(struct em28xx *dev)\n{\n\tstruct usb_device *udev = interface_to_usbdev(dev->intf);\n\n\t\/*FIXME: I2C IR should be disconnected *\/\n\n\tmutex_lock(&dev->lock);\n\n\tem28xx_unregister_media_device(dev);\n\n\tif (dev->def_i2c_bus)\n\t\tem28xx_i2c_unregister(dev, 1);\n\tem28xx_i2c_unregister(dev, 0);\n\n\tif (dev->ts == PRIMARY_TS)\n\t\tusb_put_dev(udev);\n\n\t\/* Mark device as unused *\/\n\tclear_bit(dev->devno, em28xx_devused);\n\n\tmutex_unlock(&dev->lock);\n};","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":274678,"func":"callbacks_layer_tree_visibility_toggled (gint index)\n{\n\tmainProject->file[index]->isVisible =\n\t\t!mainProject->file[index]->isVisible;\n\n\tcallbacks_update_layer_tree ();\n\tif (screenRenderInfo.renderType <= GERBV_RENDER_TYPE_GDK_XOR) {\n\t\trender_refresh_rendered_image_on_screen ();\n\t} else {\n\t\trender_recreate_composite_surface (screen.drawing_area);\n\t\tcallbacks_force_expose_event_for_screen ();\n\t}\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":353145,"func":"void SplashOutputDev::saveState(GfxState *state) {\n  splash->saveState();\n  if (t3GlyphStack && !t3GlyphStack->haveDx) {\n    t3GlyphStack->doNotCache = true;\n    error(errSyntaxWarning, -1,\n\t  \"Save (q) operator before d0\/d1 in Type 3 glyph\");\n  }\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":453034,"func":"void nft_immediate_eval(const struct nft_expr *expr,\n\t\t\tstruct nft_regs *regs,\n\t\t\tconst struct nft_pktinfo *pkt)\n{\n\tconst struct nft_immediate_expr *priv = nft_expr_priv(expr);\n\n\tnft_data_copy(®s->data[priv->dreg], &priv->data, priv->dlen);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":474073,"func":"cp949_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,\n                    UChar* lower, OnigEncoding enc)\n{\n  return onigenc_mbn_mbc_case_fold(enc, flag,\n                                   pp, end, lower);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":220901,"func":"bool RemoveControlInput(NodeDef* node, const string& control_input_to_remove,\n                        NodeMap* node_map) {\n  for (int pos = node->input_size() - 1; pos >= 0; --pos) {\n    const string& input = node->input(pos);\n    if (input[0] != '^') break;\n    if (input == control_input_to_remove) {\n      node->mutable_input()->SwapElements(pos, node->input_size() - 1);\n      node->mutable_input()->RemoveLast();\n      node_map->RemoveOutput(NodeName(input), node->name());\n      return true;\n    }\n  }\n  return false;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":369275,"func":"static ssize_t io_iov_buffer_select(struct io_kiocb *req, struct iovec *iov,\n\t\t\t\t    unsigned int issue_flags)\n{\n\tif (req->flags & REQ_F_BUFFER_SELECTED) {\n\t\tstruct io_buffer *kbuf = req->kbuf;\n\n\t\tiov[0].iov_base = u64_to_user_ptr(kbuf->addr);\n\t\tiov[0].iov_len = kbuf->len;\n\t\treturn 0;\n\t}\n\tif (req->rw.len != 1)\n\t\treturn -EINVAL;\n\n#ifdef CONFIG_COMPAT\n\tif (req->ctx->compat)\n\t\treturn io_compat_import(req, iov, issue_flags);\n#endif\n\n\treturn __io_iov_buffer_select(req, iov, issue_flags);\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":487674,"func":"static int notifier_chain_unregister(struct notifier_block **nl,\n\t\tstruct notifier_block *n)\n{\n\twhile ((*nl) != NULL) {\n\t\tif ((*nl) == n) {\n\t\t\trcu_assign_pointer(*nl, n->next);\n\t\t\treturn 0;\n\t\t}\n\t\tnl = &((*nl)->next);\n\t}\n\treturn -ENOENT;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":261198,"func":"    int wm_SemFree(wm_Sem *s){\n        if ((s == NULL) ||\n            (*s == NULL))\n            return MQTT_CODE_ERROR_BAD_ARG;\n        dispatch_release(*s);\n        *s = NULL;\n        return 0;\n    }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":466136,"func":"static int em_cmpxchg8b(struct x86_emulate_ctxt *ctxt)\n{\n\tu64 old = ctxt->dst.orig_val64;\n\n\tif (((u32) (old >> 0) != (u32) ctxt->regs[VCPU_REGS_RAX]) ||\n\t    ((u32) (old >> 32) != (u32) ctxt->regs[VCPU_REGS_RDX])) {\n\t\tctxt->regs[VCPU_REGS_RAX] = (u32) (old >> 0);\n\t\tctxt->regs[VCPU_REGS_RDX] = (u32) (old >> 32);\n\t\tctxt->eflags &= ~EFLG_ZF;\n\t} else {\n\t\tctxt->dst.val64 = ((u64)ctxt->regs[VCPU_REGS_RCX] << 32) |\n\t\t\t(u32) ctxt->regs[VCPU_REGS_RBX];\n\n\t\tctxt->eflags |= EFLG_ZF;\n\t}\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":318959,"func":"prepare_assert_error(garray_T *gap)\n{\n    char    buf[NUMBUFLEN];\n    char_u  *sname = estack_sfile(ESTACK_NONE);\n\n    ga_init2(gap, 1, 100);\n    if (sname != NULL)\n    {\n\tga_concat(gap, sname);\n\tif (SOURCING_LNUM > 0)\n\t    ga_concat(gap, (char_u *)\" \");\n    }\n    if (SOURCING_LNUM > 0)\n    {\n\tsprintf(buf, \"line %ld\", (long)SOURCING_LNUM);\n\tga_concat(gap, (char_u *)buf);\n    }\n    if (sname != NULL || SOURCING_LNUM > 0)\n\tga_concat(gap, (char_u *)\": \");\n    vim_free(sname);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":384300,"func":"heap_available()\n{\n    long avail = 0;\n    void *probes[max_malloc_probes];\n    uint n;\n\n    for (n = 0; n < max_malloc_probes; n++) {\n        if ((probes[n] = malloc(malloc_probe_size)) == 0)\n            break;\n        if_debug2('a', \"[a]heap_available probe[%d]=0x%lx\\n\",\n                  n, (ulong) probes[n]);\n        avail += malloc_probe_size;\n    }\n    while (n)\n        free(probes[--n]);\n    return avail;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":259196,"func":"static int mov_try_read_block(AVIOContext *pb, size_t size, uint8_t **data)\n{\n    const unsigned int block_size = 1024 * 1024;\n    uint8_t *buffer = NULL;\n    unsigned int alloc_size = 0, offset = 0;\n    while (offset < size) {\n        unsigned int new_size =\n            alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + block_size;\n        uint8_t *new_buffer = av_fast_realloc(buffer, &alloc_size, new_size);\n        unsigned int to_read = FFMIN(size, alloc_size) - offset;\n        if (!new_buffer) {\n            av_free(buffer);\n            return AVERROR(ENOMEM);\n        }\n        buffer = new_buffer;\n\n        if (avio_read(pb, buffer + offset, to_read) != to_read) {\n            av_free(buffer);\n            return AVERROR_INVALIDDATA;\n        }\n        offset += to_read;\n    }\n\n    *data = buffer;\n    return 0;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":307850,"func":"ciEnv::~ciEnv() {\n  CompilerThread* current_thread = CompilerThread::current();\n  _factory->remove_symbols();\n  \/\/ Need safepoint to clear the env on the thread.  RedefineClasses might\n  \/\/ be reading it.\n  GUARDED_VM_ENTRY(current_thread->set_env(NULL);)\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":336613,"func":"static gpointer openssl_global_init_once(gpointer arg)\n{\n    SSL_library_init();\n    SSL_load_error_strings();\n\n    openssl_thread_setup();\n\n    return NULL;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":212347,"func":"append_command(char_u *cmd)\n{\n    char_u *s = cmd;\n    char_u *d;\n\n    STRCAT(IObuff, \": \");\n    d = IObuff + STRLEN(IObuff);\n    while (*s != NUL && d - IObuff + 5 < IOSIZE)\n    {\n\tif (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0)\n\t{\n\t    s += enc_utf8 ? 2 : 1;\n\t    STRCPY(d, \"<a0>\");\n\t    d += 4;\n\t}\n\telse if (d - IObuff + (*mb_ptr2len)(s) + 1 >= IOSIZE)\n\t    break;\n\telse\n\t    MB_COPY_CHAR(s, d);\n    }\n    *d = NUL;\n}","target":1,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":443704,"func":"utf16be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)\n{\n  const UChar* p = *pp;\n\n  (*pp) += EncLen_UTF16[*p];\n\n  if (*p == 0) {\n    int c, v;\n\n    p++;\n    if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n      return TRUE;\n    }\n\n    c = *p;\n    v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,\n\t\t(BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));\n\n    if ((v | BIT_CTYPE_LOWER) != 0) {\n      \/* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. *\/\n      if (c >= 0xaa && c <= 0xba)\n        return FALSE;\n      else\n        return TRUE;\n    }\n    return (v != 0 ? TRUE : FALSE);\n  }\n\n  return FALSE;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":372354,"func":"static char *sdb_find_arg(char *p)\n{\n  p++;\n  while (*p==' ') p++;\n  char *pp=p;\n  while (*pp>' ') pp++;\n  *pp='\\0';\n  return p;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":226437,"func":"  Status CheckExternalState() const override { return Status::OK(); }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":393518,"func":"static SQInteger array_insert(HSQUIRRELVM v)\n{\n    SQObject &o=stack_get(v,1);\n    SQObject &idx=stack_get(v,2);\n    SQObject &val=stack_get(v,3);\n    if(!_array(o)->Insert(tointeger(idx),val))\n        return sq_throwerror(v,_SC(\"index out of range\"));\n    sq_pop(v,2);\n    return 1;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":359337,"func":"DEFUN (clear_bgp_peer_group_soft,\n       clear_bgp_peer_group_soft_cmd,\n       \"clear bgp peer-group WORD soft\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all members of peer-group\\n\"\n       \"BGP peer-group name\\n\"\n       \"Soft reconfig\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,\n\t\t\tBGP_CLEAR_SOFT_BOTH, argv[0]);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":225825,"func":"void sdp_box_del(GF_Box *s)\n{\n\tGF_SDPBox *ptr = (GF_SDPBox *)s;\n\tif (ptr->sdpText) gf_free(ptr->sdpText);\n\tgf_free(ptr);\n\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":336498,"func":"static void reds_handle_auth_mechanism(void *opaque)\n{\n    RedLinkInfo *link = (RedLinkInfo *)opaque;\n    RedsState *reds = link->reds;\n\n    spice_debug(\"Auth method: %d\", link->auth_mechanism.auth_mechanism);\n\n    link->auth_mechanism.auth_mechanism = GUINT32_FROM_LE(link->auth_mechanism.auth_mechanism);\n    if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SPICE\n        && !reds->config->sasl_enabled\n        ) {\n        reds_get_spice_ticket(link);\n#if HAVE_SASL\n    } else if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SASL) {\n        spice_debug(\"Starting SASL\");\n        reds_start_auth_sasl(link);\n#endif\n    } else {\n        spice_warning(\"Unknown auth method, disconnecting\");\n        if (reds->config->sasl_enabled) {\n            spice_warning(\"Your client doesn't handle SASL?\");\n        }\n        reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);\n        reds_link_free(link);\n    }\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":432244,"func":"void memory_listener_unregister(MemoryListener *listener)\n{\n    if (!listener->address_space) {\n        return;\n    }\n\n    listener_del_address_space(listener, listener->address_space);\n    QTAILQ_REMOVE(&listener->address_space->uc->memory_listeners, listener, link);\n    QTAILQ_REMOVE(&listener->address_space->listeners, listener, link_as);\n    listener->address_space = NULL;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":416363,"func":"f_getcmdscreenpos(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    cmdline_info_T *p = get_ccline_ptr();\n\n    rettv->vval.v_number = p != NULL ? p->cmdspos + 1 : 0;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":459152,"func":"static int tcf_block_insert(struct tcf_block *block, struct net *net,\n\t\t\t    struct netlink_ext_ack *extack)\n{\n\tstruct tcf_net *tn = net_generic(net, tcf_net_id);\n\tint err;\n\n\tidr_preload(GFP_KERNEL);\n\tspin_lock(&tn->idr_lock);\n\terr = idr_alloc_u32(&tn->idr, block, &block->index, block->index,\n\t\t\t    GFP_NOWAIT);\n\tspin_unlock(&tn->idr_lock);\n\tidr_preload_end();\n\n\treturn err;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":482534,"func":"getNumber(widechar *string, widechar *number) {\n\t\/* Convert a string of wide character digits to an integer *\/\n\tint k = 0;\n\t*number = 0;\n\twhile (string[k] >= '0' && string[k] <= '9')\n\t\t*number = 10 * *number + (string[k++] - '0');\n\treturn k;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":381853,"func":"void udf_evict_inode(struct inode *inode)\n{\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\tint want_delete = 0;\n\n\tif (!is_bad_inode(inode)) {\n\t\tif (!inode->i_nlink) {\n\t\t\twant_delete = 1;\n\t\t\tudf_setsize(inode, 0);\n\t\t\tudf_update_inode(inode, IS_SYNC(inode));\n\t\t}\n\t\tif (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB &&\n\t\t    inode->i_size != iinfo->i_lenExtents) {\n\t\t\tudf_warn(inode->i_sb,\n\t\t\t\t \"Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\\n\",\n\t\t\t\t inode->i_ino, inode->i_mode,\n\t\t\t\t (unsigned long long)inode->i_size,\n\t\t\t\t (unsigned long long)iinfo->i_lenExtents);\n\t\t}\n\t}\n\ttruncate_inode_pages_final(&inode->i_data);\n\tinvalidate_inode_buffers(inode);\n\tclear_inode(inode);\n\tkfree(iinfo->i_data);\n\tiinfo->i_data = NULL;\n\tudf_clear_extent_cache(inode);\n\tif (want_delete) {\n\t\tudf_free_inode(inode);\n\t}\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":299908,"func":"retry_arg(uschar **paddr, int type)\n{\nuschar *p = *paddr;\nuschar *pp;\n\nif (*p++ != ',') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"comma expected\");\n\nwhile (isspace(*p)) p++;\npp = p;\nwhile (isalnum(*p) || (type == 1 && *p == '.')) p++;\n\nif (*p != 0 && !isspace(*p) && *p != ',' && *p != ';')\n  log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"comma or semicolon expected\");\n\n*paddr = p;\nswitch (type)\n  {\n  case 0:\n  return readconf_readtime(pp, *p, FALSE);\n  case 1:\n  return readconf_readfixed(pp, *p);\n  }\nreturn 0;    \/* Keep picky compilers happy *\/\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":328917,"func":"R_API char *r_bin_java_get_bin_obj_json(RBinJavaObj *bin) {\n\tPJ *pj = pj_new ();\n\n\t\/\/ this is a class dictionary\n\tpj_o (pj);\n\n\t\/\/ get the initial class dict data\n\tr_bin_java_get_class_info_json (bin, pj);\n\n\t\/\/ add named lists\n\tr_bin_java_get_method_json_definitions (bin, pj);\n\tr_bin_java_get_field_json_definitions (bin, pj);\n\tr_bin_java_get_import_json_definitions (bin, pj);\n\t\/\/r_bin_java_get_interface_json_definitions (bin, pj);\n\n\tpj_end (pj);\n\n\treturn pj_drain (pj);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":272351,"func":"PK11_DestroySlotListElement(PK11SlotList *slots, PK11SlotListElement **psle)\n{\n\twhile (psle && *psle)\n\t\t*psle = PK11_GetNextSafe(slots, *psle, PR_FALSE);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":442776,"func":"static int ftpcccmethod(struct Configurable *config, char *str)\n{\n  if(curlx_strequal(\"passive\", str))\n    return CURLFTPSSL_CCC_PASSIVE;\n  if(curlx_strequal(\"active\", str))\n    return CURLFTPSSL_CCC_ACTIVE;\n  warnf(config, \"unrecognized ftp CCC method '%s', using default\\n\", str);\n  return CURLFTPSSL_CCC_PASSIVE;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":512876,"func":"  const double *const_ptr_double() const { return &value; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":486818,"func":"static inline void rx_desc_set_eof(uint32_t *desc)\n{\n    desc[1] |= DESC_1_RX_EOF;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":238489,"func":"static int grow_stack_state(struct bpf_func_state *state, int size)\n{\n\tsize_t old_n = state->allocated_stack \/ BPF_REG_SIZE, n = size \/ BPF_REG_SIZE;\n\n\tif (old_n >= n)\n\t\treturn 0;\n\n\tstate->stack = realloc_array(state->stack, old_n, n, sizeof(struct bpf_stack_state));\n\tif (!state->stack)\n\t\treturn -ENOMEM;\n\n\tstate->allocated_stack = size;\n\treturn 0;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":204101,"func":"R_API RBinJavaAttrInfo *r_bin_java_constant_value_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 6;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_CONST_VALUE_ATTR;\n\t\tattr->info.constant_value_attr.constantvalue_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\tattr->size = offset;\n\t}\n\t\/\/ IFDBG r_bin_java_print_constant_value_attr_summary(attr);\n\treturn attr;\n}","target":1,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":417098,"func":"mp_sint32 PlayerGeneric::adjustFrequency(mp_uint32 frequency)\n{\n\tthis->frequency = frequency;\n\t\n\tmp_sint32 res = MP_OK;\n\t\n\tif (mixer)\n\t\tres = mixer->setSampleRate(frequency);\n\t\n\treturn res;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":90799,"func":"void QuotaManager::NotifyStorageModified(\n    QuotaClient::ID client_id,\n    const GURL& origin, StorageType type, int64 delta) {\n  NotifyStorageModifiedInternal(client_id, origin, type, delta,\n                                base::Time::Now());\n}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":225462,"func":"Status MutableGraphView::RemoveRegularFanin(absl::string_view node_name,\n                                            const TensorId& fanin) {\n  auto error_status = [node_name, fanin](absl::string_view msg) {\n    string params = absl::Substitute(\"node_name='$0', fanin='$1'\", node_name,\n                                     fanin.ToString());\n    return MutationError(\"RemoveRegularFanin\", params, msg);\n  };\n\n  TF_RETURN_IF_ERROR(CheckFaninIsRegular(fanin, error_status));\n  TF_RETURN_IF_ERROR(\n      CheckRemovingFaninFromSelf(node_name, fanin, error_status));\n  NodeDef* node = GetNode(node_name);\n  TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));\n  NodeDef* fanin_node = GetNode(fanin.node());\n  TF_RETURN_IF_ERROR(CheckNodeExists(fanin.node(), fanin_node, error_status));\n\n  RemoveRegularFaninInternal(node, {fanin_node, fanin.index()});\n  return Status::OK();\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":246637,"func":"static u64 naludmx_next_start_code(GF_BitStream *bs, u64 offset, u64 fsize, u32 *sc_size)\n{\n\tu32 pos=0, nb_zeros=0;\n\twhile (offset+pos<fsize) {\n\t\tu8 b = gf_bs_read_u8(bs);\n\t\tpos++;\n\t\tswitch (b) {\n\t\tcase 1:\n\t\t\t\/\/break at first 0xXX000001 or 0x00000001\n\t\t\tif (nb_zeros>=2) {\n\t\t\t\t*sc_size = (nb_zeros==2) ? 3 : 4;\n\t\t\t\treturn offset+pos;\n\t\t\t}\n\t\t\tnb_zeros = 0;\n\t\t\tbreak;\n\t\tcase 0:\n\t\t\tnb_zeros++;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tnb_zeros=0;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\/\/eof\n\treturn 0;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":316987,"func":"static int selinux_file_fcntl(struct file *file, unsigned int cmd,\n\t\t\t      unsigned long arg)\n{\n\tconst struct cred *cred = current_cred();\n\tint err = 0;\n\n\tswitch (cmd) {\n\tcase F_SETFL:\n\t\tif ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) {\n\t\t\terr = file_has_perm(cred, file, FILE__WRITE);\n\t\t\tbreak;\n\t\t}\n\t\tfallthrough;\n\tcase F_SETOWN:\n\tcase F_SETSIG:\n\tcase F_GETFL:\n\tcase F_GETOWN:\n\tcase F_GETSIG:\n\tcase F_GETOWNER_UIDS:\n\t\t\/* Just check FD__USE permission *\/\n\t\terr = file_has_perm(cred, file, 0);\n\t\tbreak;\n\tcase F_GETLK:\n\tcase F_SETLK:\n\tcase F_SETLKW:\n\tcase F_OFD_GETLK:\n\tcase F_OFD_SETLK:\n\tcase F_OFD_SETLKW:\n#if BITS_PER_LONG == 32\n\tcase F_GETLK64:\n\tcase F_SETLK64:\n\tcase F_SETLKW64:\n#endif\n\t\terr = file_has_perm(cred, file, FILE__LOCK);\n\t\tbreak;\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":477817,"func":"static void kvm_rtas_int_on(struct kvm_vcpu *vcpu, struct rtas_args *args)\n{\n\tu32 irq;\n\tint rc;\n\n\tif (be32_to_cpu(args->nargs) != 1 || be32_to_cpu(args->nret) != 1) {\n\t\trc = -3;\n\t\tgoto out;\n\t}\n\n\tirq = be32_to_cpu(args->args[0]);\n\n\tif (xics_on_xive())\n\t\trc = kvmppc_xive_int_on(vcpu->kvm, irq);\n\telse\n\t\trc = kvmppc_xics_int_on(vcpu->kvm, irq);\n\tif (rc)\n\t\trc = -3;\nout:\n\targs->rets[0] = cpu_to_be32(rc);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":509521,"func":"static int maria_rollback(handlerton *hton, THD *thd, bool all)\n{\n  TRN *trn= THD_TRN;\n  DBUG_ENTER(\"maria_rollback\");\n  if (!trn)\n    DBUG_RETURN(0);\n  if (trn->undo_lsn)\n    push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,\n                        ER_DATA_WAS_COMMITED_UNDER_ROLLBACK,\n                        ER_THD(thd, ER_DATA_WAS_COMMITED_UNDER_ROLLBACK),\n                        \"Aria\");\n  if (all)\n    DBUG_RETURN(maria_commit(hton, thd, all));\n  \/* Statement rollbacks are ignored. Commit will happen in external_lock *\/\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":353130,"func":"void SplashOutputDev::clearPatternOpacity(GfxState *state) {\n  splash->clearPatternAlpha();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":90134,"func":"  virtual void EnableWifiNetworkDevice(bool enable) {\n    EnableNetworkDeviceType(TYPE_WIFI, enable);\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":412145,"func":"dnscrypt_pad(uint8_t *buf, const size_t len, const size_t max_len,\n             const uint8_t *nonce, const uint8_t *secretkey)\n{\n    uint8_t *buf_padding_area = buf + len;\n    size_t padded_len;\n    uint32_t rnd;\n\n    \/\/ no padding\n    if (max_len < len + DNSCRYPT_MIN_PAD_LEN)\n        return len;\n\n    assert(nonce[crypto_box_HALF_NONCEBYTES] == nonce[0]);\n\n    crypto_stream((unsigned char *)&rnd, (unsigned long long)sizeof(rnd), nonce,\n                  secretkey);\n    padded_len =\n        len + DNSCRYPT_MIN_PAD_LEN + rnd % (max_len - len -\n                                            DNSCRYPT_MIN_PAD_LEN + 1);\n    padded_len += DNSCRYPT_BLOCK_SIZE - padded_len % DNSCRYPT_BLOCK_SIZE;\n    if (padded_len > max_len)\n        padded_len = max_len;\n\n    memset(buf_padding_area, 0, padded_len - len);\n    *buf_padding_area = 0x80;\n\n    return padded_len;\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":226121,"func":"GF_Err tmin_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TMINBox *ptr = (GF_TMINBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 4)\n\tptr->minTime = gf_bs_read_u32(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":487650,"func":"void emergency_restart(void)\n{\n\tmachine_emergency_restart();\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":402649,"func":"generate_empty_sequence(cms_context *cms, SECItem *encoded)\n{\n\tSECItem empty = {.type = SEC_ASN1_SEQUENCE,\n\t\t\t .data = NULL,\n\t\t\t .len = 0\n\t};\n\tvoid *ret;\n\tret = SEC_ASN1EncodeItem(cms->arena, encoded, &empty,\n\t\t\t\t\t\t\tEmptySequenceTemplate);\n\tif (ret == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode empty sequence\");\n\treturn 0;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":387597,"func":"static __poll_t snd_ctl_poll(struct file *file, poll_table * wait)\n{\n\t__poll_t mask;\n\tstruct snd_ctl_file *ctl;\n\n\tctl = file->private_data;\n\tif (!ctl->subscribed)\n\t\treturn 0;\n\tpoll_wait(file, &ctl->change_sleep, wait);\n\n\tmask = 0;\n\tif (!list_empty(&ctl->events))\n\t\tmask |= EPOLLIN | EPOLLRDNORM;\n\n\treturn mask;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":473975,"func":"init_property_list(void)\n{\n  int r;\n\n  PROPERTY_LIST_ADD_PROP(\"hiragana\", CR_Hiragana);\n  PROPERTY_LIST_ADD_PROP(\"katakana\", CR_Katakana);\n  PropertyInited = 1;\n\n end:\n  return r;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":434903,"func":"move_landscape_buffer(ht_landscape_info_t *ht_landscape, byte *contone_align,\n                       int data_length)\n{\n    int k;\n    int position_curr, position_new;\n\n    if (ht_landscape->index < 0) {\n        \/* Moving right to left, move column to far right *\/\n        position_curr = ht_landscape->curr_pos + 1;\n        position_new = LAND_BITS-1;\n    } else {\n        \/* Moving left to right, move column to far left *\/\n        position_curr = ht_landscape->curr_pos - 1;\n        position_new = 0;\n    }\n    if (position_curr != position_new) {\n        for (k = 0; k < data_length; k++) {\n                contone_align[position_new] = contone_align[position_curr];\n                position_curr += LAND_BITS;\n                position_new += LAND_BITS;\n        }\n    }\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":401597,"func":"static inline void timer_sync_wait_running(struct timer_base *base) { }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":432698,"func":"ModuleExport size_t RegisterWMFImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry = AcquireMagickInfo(\"WMF\",\"WMZ\",\"Compressed Windows Meta File\");\n#if defined(MAGICKCORE_SANS_DELEGATE) || defined(MAGICKCORE_WMF_DELEGATE)\n  entry->decoder=ReadWMFImage;\n#endif\n  entry->flags|=CoderDecoderSeekableStreamFlag;\n  (void) RegisterMagickInfo(entry);\n  entry=AcquireMagickInfo(\"WMF\",\"WMF\",\"Windows Meta File\");\n#if defined(MAGICKCORE_SANS_DELEGATE) || defined(MAGICKCORE_WMF_DELEGATE)\n  entry->decoder=ReadWMFImage;\n#endif\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":226240,"func":"\nGF_Err stsg_box_size(GF_Box *s)\n{\n\tGF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s;\n\tptr->size += 6 + 4 * ptr->nb_groups;\n\treturn GF_OK;","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":437006,"func":"static void mcba_usb_write_bulk_callback(struct urb *urb)\n{\n\tstruct mcba_usb_ctx *ctx = urb->context;\n\tstruct net_device *netdev;\n\n\tWARN_ON(!ctx);\n\n\tnetdev = ctx->priv->netdev;\n\n\t\/* free up our allocated buffer *\/\n\tusb_free_coherent(urb->dev, urb->transfer_buffer_length,\n\t\t\t  urb->transfer_buffer, urb->transfer_dma);\n\n\tif (ctx->can) {\n\t\tif (!netif_device_present(netdev))\n\t\t\treturn;\n\n\t\tnetdev->stats.tx_packets++;\n\t\tnetdev->stats.tx_bytes += can_get_echo_skb(netdev, ctx->ndx,\n\t\t\t\t\t\t\t   NULL);\n\n\t\tcan_led_event(netdev, CAN_LED_EVENT_TX);\n\t}\n\n\tif (urb->status)\n\t\tnetdev_info(netdev, \"Tx URB aborted (%d)\\n\", urb->status);\n\n\t\/* Release the context *\/\n\tmcba_usb_free_ctx(ctx);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":384783,"func":"vim_islower(int c)\n{\n    if (c <= '@')\n\treturn FALSE;\n    if (c >= 0x80)\n    {\n\tif (enc_utf8)\n\t    return utf_islower(c);\n\tif (c >= 0x100)\n\t{\n#ifdef HAVE_ISWLOWER\n\t    if (has_mbyte)\n\t\treturn iswlower(c);\n#endif\n\t    \/\/ islower() can't handle these chars and may crash\n\t    return FALSE;\n\t}\n\tif (enc_latin1like)\n\t    return (latin1flags[c] & LATIN1LOWER) == LATIN1LOWER;\n    }\n    return islower(c);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":505649,"func":"smtp_command_parse_data_with_size(struct smtp_command_parser *parser,\n\tuoff_t size)\n{\n\ti_assert(parser->data == NULL);\n\tif (size > parser->limits.max_data_size) {\n\t\t\/* not supposed to happen; command should check size *\/\n\t\tparser->data = i_stream_create_error_str(EMSGSIZE, \n\t\t\t\"Command data size exceeds maximum \"\n\t\t\t\"(%\"PRIuUOFF_T\" > %\"PRIuUOFF_T\")\",\n\t\t\tsize, parser->limits.max_data_size);\n\t} else {\n\t\t\/\/ FIXME: make exact_size stream type\n\t\tstruct istream *limit_input =\n\t\t\ti_stream_create_limit(parser->input, size);\n\t\tparser->data = i_stream_create_min_sized(limit_input, size);\n\t\ti_stream_unref(&limit_input);\n\t}\n\ti_stream_ref(parser->data);\n\treturn parser->data;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":224538,"func":"Status QuantizedConv2DShape(InferenceContext* c) {\n  TF_RETURN_IF_ERROR(shape_inference::Conv2DShape(c));\n  ShapeHandle unused;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused));\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &unused));\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &unused));\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(5), 0, &unused));\n  c->set_output(1, c->Scalar());\n  c->set_output(2, c->Scalar());\n  return Status::OK();\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":215374,"func":"static int sctp_setsockopt_auth_key(struct sock *sk,\n\t\t\t\t    char __user *optval,\n\t\t\t\t    int optlen)\n{\n\tstruct sctp_authkey *authkey;\n\tstruct sctp_association *asoc;\n\tint ret;\n\n\tif (!sctp_auth_enable)\n\t\treturn -EACCES;\n\n\tif (optlen <= sizeof(struct sctp_authkey))\n\t\treturn -EINVAL;\n\n\tauthkey = kmalloc(optlen, GFP_KERNEL);\n\tif (!authkey)\n\t\treturn -ENOMEM;\n\n\tif (copy_from_user(authkey, optval, optlen)) {\n\t\tret = -EFAULT;\n\t\tgoto out;\n\t}\n\n\tif (authkey->sca_keylength > optlen) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tasoc = sctp_id2assoc(sk, authkey->sca_assoc_id);\n\tif (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\tret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey);\nout:\n\tkfree(authkey);\n\treturn ret;\n}","target":1,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":424959,"func":"static void iwl_trans_pcie_write_shr(struct iwl_trans *trans, u32 reg, u32 val)\n{\n\tiwl_write32(trans, HEEP_CTRL_WRD_PCIEX_DATA_REG, val);\n\tiwl_write32(trans, HEEP_CTRL_WRD_PCIEX_CTRL_REG,\n\t\t    ((reg & 0x0000ffff) | (3 << 28)));\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":432287,"func":"static MemTxResult  memory_region_read_accessor(struct uc_struct *uc, MemoryRegion *mr,\n                                                hwaddr addr,\n                                                uint64_t *value,\n                                                unsigned size,\n                                                signed shift,\n                                                uint64_t mask,\n                                                MemTxAttrs attrs)\n{\n    uint64_t tmp;\n\n    tmp = mr->ops->read(uc, mr->opaque, addr, size);\n    memory_region_shift_read_access(value, shift, mask, tmp);\n    return MEMTX_OK;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":312525,"func":"qf_set_title_var(qf_list_T *qfl)\n{\n    if (qfl->qf_title != NULL)\n\tset_internal_string_var((char_u *)\"w:quickfix_title\", qfl->qf_title);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":229292,"func":"std::unique_ptr<cql_server::response> cql_server::connection::make_auth_success(int16_t stream, bytes b, const tracing::trace_state_ptr& tr_state) const {\n    auto response = std::make_unique<cql_server::response>(stream, cql_binary_opcode::AUTH_SUCCESS, tr_state);\n    response->write_bytes(std::move(b));\n    return response;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":447066,"func":"    SshIo::SshImpl::SshImpl(const std::string& url, size_t blockSize):Impl(url, blockSize)\n    {\n        hostInfo_ = Exiv2::Uri::Parse(url);\n        Exiv2::Uri::Decode(hostInfo_);\n\n        \/\/ remove \/ at the beginning of the path\n        if (hostInfo_.Path[0] == '\/') {\n            hostInfo_.Path = hostInfo_.Path.substr(1);\n        }\n        ssh_ = new SSH(hostInfo_.Host, hostInfo_.Username, hostInfo_.Password, hostInfo_.Port);\n\n        if (protocol_ == pSftp) {\n            ssh_->getFileSftp(hostInfo_.Path, fileHandler_);\n            if (fileHandler_ == NULL) throw Error(1, \"Unable to open the file\");\n        } else {\n            fileHandler_ = NULL;\n        }\n    }","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":512990,"func":"  virtual bool set_extraction_flag_processor(void *arg)\n  {\n    set_extraction_flag(*(int*)arg);\n    return 0;\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":442786,"func":"static const char *param2text(int res)\n{\n  ParameterError error = (ParameterError)res;\n  switch(error) {\n  case PARAM_GOT_EXTRA_PARAMETER:\n    return \"had unsupported trailing garbage\";\n  case PARAM_OPTION_UNKNOWN:\n    return \"is unknown\";\n  case PARAM_OPTION_AMBIGUOUS:\n    return \"is ambiguous\";\n  case PARAM_REQUIRES_PARAMETER:\n    return \"requires parameter\";\n  case PARAM_BAD_USE:\n    return \"is badly used here\";\n  case PARAM_BAD_NUMERIC:\n    return \"expected a proper numerical parameter\";\n  case PARAM_LIBCURL_DOESNT_SUPPORT:\n    return \"the installed libcurl version doesn't support this\";\n  case PARAM_NO_MEM:\n    return \"out of memory\";\n  default:\n    return \"unknown error\";\n  }\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":512959,"func":"  bool with_sum_func() const { return m_with_sum_func; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":225959,"func":"GF_Err padb_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tGF_PaddingBitsBox *ptr = (GF_PaddingBitsBox *) s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_int(bs, ptr->SampleCount, 32);\n\n\tfor (i=0 ; i<ptr->SampleCount; i += 2) {\n\t\tgf_bs_write_int(bs, 0, 1);\n\t\tif (i+1 < ptr->SampleCount) {\n\t\t\tgf_bs_write_int(bs, ptr->padbits[i+1], 3);\n\t\t} else {\n\t\t\tgf_bs_write_int(bs, 0, 3);\n\t\t}\n\t\tgf_bs_write_int(bs, 0, 1);\n\t\tgf_bs_write_int(bs, ptr->padbits[i], 3);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":317178,"func":"static void selinux_inet_conn_established(struct sock *sk, struct sk_buff *skb)\n{\n\tu16 family = sk->sk_family;\n\tstruct sk_security_struct *sksec = sk->sk_security;\n\n\t\/* handle mapped IPv4 packets arriving via IPv6 sockets *\/\n\tif (family == PF_INET6 && skb->protocol == htons(ETH_P_IP))\n\t\tfamily = PF_INET;\n\n\tselinux_skb_peerlbl_sid(skb, family, &sksec->peer_sid);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":225946,"func":"\nGF_Err prft_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_ProducerReferenceTimeBox *ptr = (GF_ProducerReferenceTimeBox *) s;\n\n\tISOM_DECREASE_SIZE(ptr, 12);\n\tptr->refTrackID = gf_bs_read_u32(bs);\n\tptr->ntp = gf_bs_read_u64(bs);\n\tif (ptr->version==0) {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->timestamp = gf_bs_read_u32(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->timestamp = gf_bs_read_u64(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":252369,"func":"void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,\n                                              int num_chans, size_t *pLen_out) {\n  \/\/ Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we\n  \/\/ can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's\n  \/\/ where #defined out)\n  return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans,\n                                                    pLen_out, 6, MZ_FALSE);\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":236196,"func":"void gppc_box_del(GF_Box *s)\n{\n\tGF_3GPPConfigBox *ptr = (GF_3GPPConfigBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":294562,"func":"datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n    if (!NIL_P(opt)) argc--;\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"-4712-01-01T00:00:00+00:00\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        argv2[1] = opt;\n        if (!NIL_P(opt)) argc2++;\n\tVALUE hash = date_s__xmlschema(argc2, argv2, klass);\n\treturn dt_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":424924,"func":"static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tbool was_in_rfkill;\n\n\tmutex_lock(&trans_pcie->mutex);\n\ttrans_pcie->opmode_down = true;\n\twas_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status);\n\t_iwl_trans_pcie_stop_device(trans);\n\tiwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill);\n\tmutex_unlock(&trans_pcie->mutex);\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":245188,"func":"select_history()\n{\n\tif (opt_incremental_history_name || opt_incremental_history_uuid) {\n\t\tif (!select_incremental_lsn_from_history(\n\t\t\t&incremental_lsn)) {\n\t\t\treturn(false);\n\t\t}\n\t}\n\treturn(true);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":279937,"func":"get_old_sub(void)\n{\n    return old_sub;\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":369241,"func":"\nstatic __poll_t io_uring_poll(struct file *file, poll_table *wait)\n{\n\tstruct io_ring_ctx *ctx = file->private_data;\n\t__poll_t mask = 0;\n\n\tpoll_wait(file, &ctx->cq_wait, wait);\n\t\/*\n\t * synchronizes with barrier from wq_has_sleeper call in\n\t * io_commit_cqring\n\t *\/\n\tsmp_rmb();\n\tif (!io_sqring_full(ctx))\n\t\tmask |= EPOLLOUT | EPOLLWRNORM;\n\n\t\/*\n\t * Don't flush cqring overflow list here, just do a simple check.\n\t * Otherwise there could possible be ABBA deadlock:\n\t *      CPU0                    CPU1\n\t *      ----                    ----\n\t * lock(&ctx->uring_lock);\n\t *                              lock(&ep->mtx);\n\t *                              lock(&ctx->uring_lock);\n\t * lock(&ep->mtx);\n\t *\n\t * Users may get EPOLLIN meanwhile seeing nothing in cqring, this\n\t * pushs them to do the flush.\n\t *\/\n\tif (io_cqring_events(ctx) || test_bit(0, &ctx->check_cq_overflow))\n\t\tmask |= EPOLLIN | EPOLLRDNORM;\n\n\treturn mask;","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":484804,"func":"static bool xennet_can_sg(struct net_device *dev)\n{\n\treturn dev->features & NETIF_F_SG;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":443708,"func":"is_valid_mbc_string(const UChar* p, const UChar* end)\n{\n  const UChar* end1 = end - 1;\n\n  while (p < end1) {\n    p += utf16le_mbc_enc_len(p);\n  }\n\n  if (p != end)\n    return FALSE;\n  else\n    return TRUE;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":389680,"func":"check_for_opt_lnum_arg(typval_T *args, int idx)\n{\n    return (args[idx].v_type == VAR_UNKNOWN\n\t    || check_for_lnum_arg(args, idx));\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":492695,"func":"_vte_terminal_clear_current_line (VteTerminal *terminal)\n{\n\tVteRowData *rowdata;\n\tVteScreen *screen;\n\n\tscreen = terminal->pvt->screen;\n\n\t\/* If the cursor is actually on the screen, clear data in the row\n\t * which corresponds to the cursor. *\/\n\tif (_vte_ring_next(screen->row_data) > screen->cursor_current.row) {\n\t\t\/* Get the data for the row which the cursor points to. *\/\n\t\trowdata = _vte_ring_index_writable (screen->row_data, screen->cursor_current.row);\n\t\tg_assert(rowdata != NULL);\n\t\t\/* Remove it. *\/\n\t\t_vte_row_data_shrink (rowdata, 0);\n\t\t\/* Add enough cells to the end of the line to fill out the row. *\/\n\t\t_vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count);\n\t\trowdata->attr.soft_wrapped = 0;\n\t\t\/* Repaint this row. *\/\n\t\t_vte_invalidate_cells(terminal,\n\t\t\t\t      0, terminal->column_count,\n\t\t\t\t      screen->cursor_current.row, 1);\n\t}\n\n\t\/* We've modified the display.  Make a note of it. *\/\n\tterminal->pvt->text_deleted_flag = TRUE;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":343240,"func":"void client_fflush(void)\n{\n    if (replybuf_pos == replybuf) {\n        return;\n    }\n    safe_write(clientfd, replybuf, (size_t) (replybuf_pos - replybuf), -1);\n    client_init_reply_buf();\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":400752,"func":"struct iovec *iovec_from_user(const struct iovec __user *uvec,\n\t\tunsigned long nr_segs, unsigned long fast_segs,\n\t\tstruct iovec *fast_iov, bool compat)\n{\n\tstruct iovec *iov = fast_iov;\n\tint ret;\n\n\t\/*\n\t * SuS says \"The readv() function *may* fail if the iovcnt argument was\n\t * less than or equal to 0, or greater than {IOV_MAX}.  Linux has\n\t * traditionally returned zero for zero segments, so...\n\t *\/\n\tif (nr_segs == 0)\n\t\treturn iov;\n\tif (nr_segs > UIO_MAXIOV)\n\t\treturn ERR_PTR(-EINVAL);\n\tif (nr_segs > fast_segs) {\n\t\tiov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL);\n\t\tif (!iov)\n\t\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\n\tif (compat)\n\t\tret = copy_compat_iovec_from_user(iov, uvec, nr_segs);\n\telse\n\t\tret = copy_iovec_from_user(iov, uvec, nr_segs);\n\tif (ret) {\n\t\tif (iov != fast_iov)\n\t\t\tkfree(iov);\n\t\treturn ERR_PTR(ret);\n\t}\n\n\treturn iov;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":503981,"func":"escape_none(const char *string,\n\t    const struct auth_request *request ATTR_UNUSED)\n{\n\treturn string;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":437314,"func":"comp_opt_exact_or_map(OptExact* e, OptMap* m)\n{\n#define COMP_EM_BASE  20\n  int ae, am;\n\n  if (m->value <= 0) return -1;\n\n  ae = COMP_EM_BASE * e->len * (e->ignore_case ? 1 : 2);\n  am = COMP_EM_BASE * 5 * 2 \/ m->value;\n  return comp_distance_value(&e->mmd, &m->mmd, ae, am);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":218991,"func":"Status ConstantFolding::SimplifyPad(const GraphProperties& properties,\n                                    bool use_shape_info,\n                                    GraphDef* optimized_graph, NodeDef* node) {\n  if (!use_shape_info || !IsPad(*node)) return Status::OK();\n\n  Tensor paddings;\n  if (GetTensorFromConstNode(node->input(1), &paddings)) {\n    \/\/ The node is replaceable iff all values in paddings are 0.\n    bool replaceable = true;\n    if (paddings.dtype() == DT_INT32) {\n      const auto flatten = paddings.flat<int32>();\n      for (int j = 0; replaceable && j < flatten.size(); ++j) {\n        replaceable &= flatten(j) == 0;\n      }\n    } else {\n      const auto flatten = paddings.flat<int64_t>();\n      for (int j = 0; replaceable && j < flatten.size(); ++j) {\n        replaceable &= flatten(j) == 0;\n      }\n    }\n    if (replaceable) {\n      ReplaceOperationWithIdentity(0, properties, node, optimized_graph);\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":236125,"func":"GF_Err diST_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;\n\n\tp->content_script_types = gf_malloc(sizeof(char) * (s->size+1));\n\tif (!p->content_script_types) return GF_OUT_OF_MEM;\n\tgf_bs_read_data(bs, p->content_script_types, s->size);\n\tp->content_script_types[s->size] = 0;\n\treturn GF_OK;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":244010,"func":"GF_Box *leva_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_LevelAssignmentBox, GF_ISOM_BOX_TYPE_LEVA);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":313727,"func":"nv_suspend(cmdarg_T *cap)\n{\n    clearop(cap->oap);\n    if (VIsual_active)\n\tend_visual_mode();\t\t\/\/ stop Visual mode\n    do_cmdline_cmd((char_u *)\"stop\");\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":244255,"func":"GF_Err fiin_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tFDItemInformationBox *ptr = (FDItemInformationBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 2);\n\tgf_bs_read_u16(bs);\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":221520,"func":"flatpak_ensure_data_dir (GFile        *app_id_dir,\n                         GCancellable *cancellable,\n                         GError      **error)\n{\n  g_autoptr(GFile) data_dir = g_file_get_child (app_id_dir, \"data\");\n  g_autoptr(GFile) cache_dir = g_file_get_child (app_id_dir, \"cache\");\n  g_autoptr(GFile) fontconfig_cache_dir = g_file_get_child (cache_dir, \"fontconfig\");\n  g_autoptr(GFile) tmp_dir = g_file_get_child (cache_dir, \"tmp\");\n  g_autoptr(GFile) config_dir = g_file_get_child (app_id_dir, \"config\");\n\n  if (!flatpak_mkdir_p (data_dir, cancellable, error))\n    return FALSE;\n\n  if (!flatpak_mkdir_p (cache_dir, cancellable, error))\n    return FALSE;\n\n  if (!flatpak_mkdir_p (fontconfig_cache_dir, cancellable, error))\n    return FALSE;\n\n  if (!flatpak_mkdir_p (tmp_dir, cancellable, error))\n    return FALSE;\n\n  if (!flatpak_mkdir_p (config_dir, cancellable, error))\n    return FALSE;\n\n  return TRUE;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":427789,"func":"void sev_free_vcpu(struct kvm_vcpu *vcpu)\n{\n\tstruct vcpu_svm *svm;\n\n\tif (!sev_es_guest(vcpu->kvm))\n\t\treturn;\n\n\tsvm = to_svm(vcpu);\n\n\tif (vcpu->arch.guest_state_protected)\n\t\tsev_flush_guest_memory(svm, svm->vmsa, PAGE_SIZE);\n\t__free_page(virt_to_page(svm->vmsa));\n\n\tif (svm->ghcb_sa_free)\n\t\tkfree(svm->ghcb_sa);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":336127,"func":"static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)\n{\n\tconst struct ipv6hdr *ipv6h;\n\tstruct ip6_tnl *tunnel;\n\n\tipv6h = ipv6_hdr(skb);\n\ttunnel = ip6gre_tunnel_lookup(skb->dev,\n\t\t\t\t      &ipv6h->saddr, &ipv6h->daddr, tpi->key,\n\t\t\t\t      tpi->proto);\n\tif (tunnel) {\n\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, false);\n\n\t\treturn PACKET_RCVD;\n\t}\n\n\treturn PACKET_REJECT;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":317359,"func":"static void selinux_secmark_refcount_dec(void)\n{\n\tatomic_dec(&selinux_secmark_refcount);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":240279,"func":"get_expr_register(void)\n{\n    char_u\t*new_line;\n\n    new_line = getcmdline('=', 0L, 0, 0);\n    if (new_line == NULL)\n\treturn NUL;\n    if (*new_line == NUL)\t\/\/ use previous line\n\tvim_free(new_line);\n    else\n\tset_expr_line(new_line, NULL);\n    return '=';\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":255773,"func":"svn_repos_authz_read4(svn_authz_t **authz_p,\n                      const char *path,\n                      const char *groups_path,\n                      svn_boolean_t must_exist,\n                      svn_repos_t *repos_hint,\n                      svn_repos_authz_warning_func_t warning_func,\n                      void *warning_baton,\n                      apr_pool_t *result_pool,\n                      apr_pool_t *scratch_pool)\n{\n  svn_authz_t *authz = apr_pcalloc(result_pool, sizeof(*authz));\n  authz->pool = result_pool;\n\n  SVN_ERR(authz_read(&authz->full, &authz->authz_id, path, groups_path,\n                     must_exist, repos_hint, warning_func, warning_baton,\n                     result_pool, scratch_pool));\n\n  *authz_p = authz;\n  return SVN_NO_ERROR;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":366328,"func":"vfs_submount(const struct dentry *mountpoint, struct file_system_type *type,\n\t     const char *name, void *data)\n{\n\t\/* Until it is worked out how to pass the user namespace\n\t * through from the parent mount to the submount don't support\n\t * unprivileged mounts with submounts.\n\t *\/\n\tif (mountpoint->d_sb->s_user_ns != &init_user_ns)\n\t\treturn ERR_PTR(-EPERM);\n\n\treturn vfs_kern_mount(type, SB_SUBMOUNT, name, data);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":211567,"func":"static char *getsistring(FILE *f, uint32_t ptr, uint32_t len) {\n  char *name;\n  uint32_t i;\n\n  if (!len) return NULL;\n  if (len>400) len=400;\n  name = cli_malloc(len);\n  if (!name) {\n    cli_dbgmsg(\"SIS: OOM\\n\");\n    return NULL;\n  }\n  fseek(f, ptr, SEEK_SET);\n  if (fread(name, len, 1, f)!=1) {\n    cli_dbgmsg(\"SIS: Unable to read string\\n\");\n    free(name);\n    return NULL;\n  }\n  for (i = 0 ; i < len; i+=2) name[i\/2] = name[i];\n  name[i\/2]='\\0';\n  return name;\n}","target":1,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":259620,"func":"void HierarchicalBitmapRequester::DefineRegion(LONG x,const struct Line *const *line,\n                                               const LONG *buffer,UBYTE comp)\n{\n  int cnt = 8;\n  \n  assert(comp < m_ucCount);\n  NOREF(comp);\n\n  x <<= 3;\n  \n  do {\n    if (*line) memcpy((*line)->m_pData + x,buffer,8 * sizeof(LONG));\n    buffer += 8;\n    line++;\n  } while(--cnt);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":512256,"func":"Item_func_nullif::decimal_op(my_decimal * decimal_value)\n{\n  DBUG_ASSERT(fixed == 1);\n  my_decimal *res;\n  if (!compare())\n  {\n    null_value=1;\n    return 0;\n  }\n  res= args[2]->val_decimal(decimal_value);\n  null_value= args[2]->null_value;\n  return res;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":275973,"func":"static void HMAC_init(const uECC_HashContext *hash_context, const uint8_t *K) {\n    uint8_t *pad = hash_context->tmp + 2 * hash_context->result_size;\n    unsigned i;\n    for (i = 0; i < hash_context->result_size; ++i)\n        pad[i] = K[i] ^ 0x36;\n    for (; i < hash_context->block_size; ++i)\n        pad[i] = 0x36;\n\n    hash_context->init_hash(hash_context);\n    hash_context->update_hash(hash_context, pad, hash_context->block_size);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":244353,"func":"GF_Err st3d_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_Stereo3DBox *ptr = (GF_Stereo3DBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u8(bs, ptr->stereo_type);\n\treturn GF_OK;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":245705,"func":"static void handle_connection_failure(struct conn_s *connptr, int got_headers)\n{\n        \/*\n         * First, get the body if there is one.\n         * If we don't read all there is from the socket first,\n         * it is still marked for reading and we won't be able\n         * to send our data properly.\n         *\/\n        if (!got_headers && get_request_entity (connptr) < 0) {\n                log_message (LOG_WARNING,\n                             \"Could not retrieve request entity\");\n                indicate_http_error (connptr, 400, \"Bad Request\",\n                                     \"detail\",\n                                     \"Could not retrieve the request entity \"\n                                     \"the client.\", NULL);\n                update_stats (STAT_BADCONN);\n        }\n\n        if (connptr->error_variables) {\n                send_http_error_message (connptr);\n        } else if (connptr->show_stats) {\n                showstats (connptr);\n        }\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":195984,"func":"GF_Err diST_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tchar str[1024];\n\tGF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;\n\n\ti=0;\n\tstr[0]=0;\n\twhile (1) {\n\t\tstr[i] = gf_bs_read_u8(bs);\n\t\tif (!str[i]) break;\n\t\ti++;\n\t}\n\tISOM_DECREASE_SIZE(p, i);\n\n\tp->content_script_types = gf_strdup(str);\n\treturn GF_OK;\n}","target":1,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":233850,"func":"static double pict_read_fixed(dbuf *f, i64 pos)\n{\n\ti64 n;\n\n\t\/\/ I think QuickDraw's \"Fixed point\" numbers are signed, but I don't know\n\t\/\/ how negative numbers are handled.\n\tn = dbuf_geti32be(f, pos);\n\treturn ((double)n)\/65536.0;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":346439,"func":"add_pack_start_dirs(void)\n{\n    do_in_path(p_pp, (char_u *)\"pack\/*\/start\/*\", DIP_ALL + DIP_DIR,\n\t\t\t\t\t       add_pack_plugin, &APP_ADD_DIR);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":289291,"func":"static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file)\n{\n\tstruct snd_pcm_substream *substream;\n\tint err;\n\t\n\terr = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);\n\tif (err < 0)\n\t\treturn err;\n\treturn substream->runtime->oss.period_bytes;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":255078,"func":"void ompl::geometric::VFRRT::updateExplorationEfficiency(Motion *m)\n{\n    Motion *near = nn_->nearest(m);\n    if (distanceFunction(m, near) < si_->getStateValidityCheckingResolution())\n        inefficientCount_++;\n    else\n        efficientCount_++;\n    explorationInefficiency_ = inefficientCount_ \/ (double)(efficientCount_ + inefficientCount_);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":336504,"func":"static void reds_start_auth_sasl(RedLinkInfo *link)\n{\n    if (!red_sasl_start_auth(link->stream, reds_handle_sasl_result, link)) {\n        reds_link_free(link);\n    }\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":204830,"func":"struct vfsmount *clone_private_mount(const struct path *path)\n{\n\tstruct mount *old_mnt = real_mount(path->mnt);\n\tstruct mount *new_mnt;\n\n\tif (IS_MNT_UNBINDABLE(old_mnt))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tnew_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);\n\tif (IS_ERR(new_mnt))\n\t\treturn ERR_CAST(new_mnt);\n\n\t\/* Longterm mount to be removed by kern_unmount*() *\/\n\tnew_mnt->mnt_ns = MNT_NS_INTERNAL;\n\n\treturn &new_mnt->mnt;\n}","target":1,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":221686,"func":"unsigned long int Socket::getPeerSourceAddr() {\n    return (unsigned long int) ntohl(peer_adr.sin_addr.s_addr);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":329946,"func":"__fill_reduces_to_source (cairo_operator_t op,\n\t\t\t  const cairo_color_t *color,\n\t\t\t  const cairo_image_surface_t *dst)\n{\n    if (op == CAIRO_OPERATOR_SOURCE || op == CAIRO_OPERATOR_CLEAR)\n\treturn TRUE;\n    if (op == CAIRO_OPERATOR_OVER && CAIRO_COLOR_IS_OPAQUE (color))\n\treturn TRUE;\n    if (dst->base.is_clear)\n\treturn op == CAIRO_OPERATOR_OVER || op == CAIRO_OPERATOR_ADD;\n\n    return FALSE;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":486798,"func":"static void gem_get_rx_desc(CadenceGEMState *s, int q)\n{\n    hwaddr desc_addr = gem_get_rx_desc_addr(s, q);\n\n    DB_PRINT(\"read descriptor 0x%\" HWADDR_PRIx \"\\n\", desc_addr);\n\n    \/* read current descriptor *\/\n    address_space_read(&s->dma_as, desc_addr, MEMTXATTRS_UNSPECIFIED,\n                       s->rx_desc[q],\n                       sizeof(uint32_t) * gem_get_desc_len(s, true));\n\n    \/* Descriptor owned by software ? *\/\n    if (rx_desc_get_ownership(s->rx_desc[q]) == 1) {\n        DB_PRINT(\"descriptor 0x%\" HWADDR_PRIx \" owned by sw.\\n\", desc_addr);\n        s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF;\n        gem_set_isr(s, q, GEM_INT_RXUSED);\n        \/* Handle interrupt consequences *\/\n        gem_update_int_status(s);\n    }\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":512414,"func":"longlong Item_func_not_all::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  bool value= args[0]->val_bool();\n\n  \/*\n    return TRUE if there was records in underlying select in max\/min\n    optimization (ALL subquery)\n  *\/\n  if (empty_underlying_subquery())\n    return 1;\n\n  null_value= args[0]->null_value;\n  return ((!null_value && value == 0) ? 1 : 0);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":225481,"func":"absl::flat_hash_set<MutableGraphView::OutputPort> MutableGraphView::GetFanin(\n    const GraphView::InputPort& port) const {\n  return GetFanin(MutableGraphView::InputPort(const_cast<NodeDef*>(port.node),\n                                              port.port_id));\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":405713,"func":"static int xemaclite_of_remove(struct platform_device *of_dev)\n{\n\tstruct net_device *ndev = platform_get_drvdata(of_dev);\n\n\tstruct net_local *lp = netdev_priv(ndev);\n\n\t\/* Un-register the mii_bus, if configured *\/\n\tif (lp->mii_bus) {\n\t\tmdiobus_unregister(lp->mii_bus);\n\t\tmdiobus_free(lp->mii_bus);\n\t\tlp->mii_bus = NULL;\n\t}\n\n\tunregister_netdev(ndev);\n\n\tof_node_put(lp->phy_node);\n\tlp->phy_node = NULL;\n\n\tfree_netdev(ndev);\n\n\treturn 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":309942,"func":"_nc_locked_tracef(const char *fmt, ...)\n{\n    va_list ap;\n\n    va_start(ap, fmt);\n    _nc_va_tracef(fmt, ap);\n    va_end(ap);\n\n    if (--(MyNested) == 0) {\n\t_nc_unlock_global(tracef);\n    }\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":512612,"func":"Item_func_ifnull::int_op()\n{\n  DBUG_ASSERT(fixed == 1);\n  longlong value=args[0]->val_int();\n  if (!args[0]->null_value)\n  {\n    null_value=0;\n    return value;\n  }\n  value=args[1]->val_int();\n  if ((null_value=args[1]->null_value))\n    return 0;\n  return value;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":353127,"func":"  bool matches(const Ref *idA, double m11A, double m12A,\n\t\tdouble m21A, double m22A)\n    { return fontID == *idA &&\n\t     m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; }","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":512846,"func":"  bool is_order_clause_position() const\n  {\n    return state == SHORT_DATA_VALUE &&\n           type_handler()->is_order_clause_position_type();\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":365617,"func":"_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len)\n{\n  int len2;\n  void *temp;\n\n  if (node == NULL)\n    return node;\n\n  asn1_length_der (len, NULL, &len2);\n  temp = malloc (len + len2);\n  if (temp == NULL)\n    return NULL;\n\n  asn1_octet_der (value, len, temp, &len2);\n  return _asn1_set_value_m (node, temp, len2);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":294476,"func":"d_lite_min(VALUE self)\n{\n    get_d1(self);\n    return INT2FIX(m_min(dat));\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":273057,"func":"safe_hextou64(const char *str, uint64_t *val)\n{\n  char *end;\n  unsigned long long intval;\n\n  *val = 0;\n\n  errno = 0;\n  intval = strtoull(str, &end, 16);\n\n  if (((errno == ERANGE) && (intval == ULLONG_MAX))\n      || ((errno != 0) && (intval == 0)))\n    {\n      DPRINTF(E_DBG, L_MISC, \"Invalid integer in string (%s): %s\\n\", str, strerror(errno));\n\n      return -1;\n    }\n\n  if (end == str)\n    {\n      DPRINTF(E_DBG, L_MISC, \"No integer found in string (%s)\\n\", str);\n\n      return -1;\n    }\n\n  if (intval > UINT64_MAX)\n    {\n      DPRINTF(E_DBG, L_MISC, \"Integer value too large (%s)\\n\", str);\n\n      return -1;\n    }\n\n  *val = (uint64_t)intval;\n\n  return 0;\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":264254,"func":"static void set_pixel_conversion(VncState *vs)\n{\n    pixman_format_code_t fmt = qemu_pixman_get_format(&vs->client_pf);\n\n    if (fmt == VNC_SERVER_FB_FORMAT) {\n        vs->write_pixels = vnc_write_pixels_copy;\n        vnc_hextile_set_pixel_conversion(vs, 0);\n    } else {\n        vs->write_pixels = vnc_write_pixels_generic;\n        vnc_hextile_set_pixel_conversion(vs, 1);\n    }\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":489212,"func":"static int hfsplus_fill_cat_thread(struct super_block *sb,\n\t\t\t\t   hfsplus_cat_entry *entry, int type,\n\t\t\t\t   u32 parentid, struct qstr *str)\n{\n\tentry->type = cpu_to_be16(type);\n\tentry->thread.reserved = 0;\n\tentry->thread.parentID = cpu_to_be32(parentid);\n\thfsplus_asc2uni(sb, &entry->thread.nodeName, str->name, str->len);\n\treturn 10 + be16_to_cpu(entry->thread.nodeName.length) * 2;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":270382,"func":"static int ok_inflater_decode_length(ok_inflater *inflater, int value) {\n    if (value < 8) {\n        return value + 3;\n    } else {\n        int len = OK_INFLATER_LENGTH_TABLE[value];\n        unsigned int extra_bits = (unsigned int)((value >> 2) - 1);\n        if (extra_bits <= 5) {\n            if (!ok_inflater_load_bits(inflater, extra_bits)) {\n                return -1;\n            }\n            len += ok_inflater_read_bits(inflater, extra_bits);\n        }\n        return len;\n    }\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":445934,"func":"archive_add_ready_for_conversion_cb (GObject      *source_object,\n\t\t\t\t     GAsyncResult *result,\n\t\t\t\t     gpointer      user_data)\n{\n\tConvertData *cdata = user_data;\n\tFrWindow    *window = cdata->window;\n\tGError      *error = NULL;\n\n\tfr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error);\n\n\t_fr_window_stop_activity_mode (window);\n\tclose_progress_dialog (window, FALSE);\n\n\tif (error != NULL) {\n\t\t_handle_archive_operation_error (window,\n\t\t\t\t\t\t cdata->new_archive,\n\t\t\t\t\t\t FR_ACTION_ADDING_FILES,\n\t\t\t\t\t\t error,\n\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t NULL);\n\t\tfr_window_stop_batch (window);\n\t\tg_error_free (error);\n\t\treturn;\n\t}\n\n\topen_progress_dialog_with_open_archive (window);\n\tfr_window_exec_next_batch_action (window);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":224224,"func":"R_API void r_io_bank_drain(RIO *io, const ut32 bankid) {\n\tr_return_if_fail (io);\n\tRIOBank *bank = r_io_bank_get (io, bankid);\n\tif (!bank) {\n\t\treturn;\n\t}\n\tbank->last_used = NULL;\n\tRRBNode *node = r_crbtree_first_node (bank->submaps);\n\tRRBNode *next = NULL;\n\twhile (node) {\n\t\tnext = r_rbnode_next (node);\n\t\tif (next) {\n\t\t\tRIOSubMap *bd = (RIOSubMap *)node->data;\n\t\t\tRIOSubMap *sm = (RIOSubMap *)next->data;\n\t\t\tif (!memcmp (&bd->mapref, &sm->mapref, sizeof (RIOMapRef))) {\n\t\t\t\tr_io_submap_set_to (bd, r_io_submap_to (sm));\n\t\t\t\tr_crbtree_delete (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tnode = next;\n\t}\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":225662,"func":"GF_Box *ctts_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_CompositionOffsetBox, GF_ISOM_BOX_TYPE_CTTS);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":463135,"func":"static void annotation_get_pop3showafter(annotate_state_t *state,\n                                         struct annotate_entry_list *entry)\n{\n    struct mailbox *mailbox = state->mailbox;\n    char valuebuf[RFC3501_DATETIME_MAX+1];\n    struct buf value = BUF_INITIALIZER;\n\n    assert(mailbox);\n\n    if (mailbox->i.pop3_show_after)\n    {\n        time_to_rfc3501(mailbox->i.pop3_show_after, valuebuf, sizeof(valuebuf));\n        buf_appendcstr(&value, valuebuf);\n    }\n\n    output_entryatt(state, entry->name, \"\", &value);\n    buf_free(&value);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":512950,"func":"  bool is_string() const { return m_type == DYN_COL_STRING; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":317063,"func":"static int smack_ipc_permission(struct kern_ipc_perm *ipp, short flag)\n{\n\tstruct smack_known **blob = smack_ipc(ipp);\n\tstruct smack_known *iskp = *blob;\n\tint may = smack_flags_to_may(flag);\n\tstruct smk_audit_info ad;\n\tint rc;\n\n#ifdef CONFIG_AUDIT\n\tsmk_ad_init(&ad, __func__, LSM_AUDIT_DATA_IPC);\n\tad.a.u.ipc_id = ipp->id;\n#endif\n\trc = smk_curacc(iskp, may, &ad);\n\trc = smk_bu_current(\"svipc\", iskp, may, rc);\n\treturn rc;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":442794,"func":"static void GetStr(char **string,\n                   char *value)\n{\n  if(*string)\n    free(*string);\n  if(value)\n    *string = strdup(value);\n  else\n    *string = NULL;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":255761,"func":"add_if_prefix_matches(lookup_state_t *state,\n                      const sorted_pattern_t *prefix,\n                      const svn_stringbuf_t *segment)\n{\n  node_t *node = prefix->node;\n  if (   node->segment.len <= segment->len\n      && !memcmp(node->segment.data, segment->data, node->segment.len))\n    add_next_node(state, node);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":238482,"func":"struct btf *bpf_get_btf_vmlinux(void)\n{\n\tif (!btf_vmlinux && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {\n\t\tmutex_lock(&bpf_verifier_lock);\n\t\tif (!btf_vmlinux)\n\t\t\tbtf_vmlinux = btf_parse_vmlinux();\n\t\tmutex_unlock(&bpf_verifier_lock);\n\t}\n\treturn btf_vmlinux;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":225801,"func":"GF_Err mvex_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":512614,"func":"  With_sum_func_cache(const Item *a)\n   :m_with_sum_func(a->with_sum_func())\n  { }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":509534,"func":"void _ma_check_print_info(HA_CHECK *param, const char *fmt, ...)\n{\n  va_list args;\n  DBUG_ENTER(\"_ma_check_print_info\");\n  va_start(args, fmt);\n  _ma_check_print_msg(param, MA_CHECK_INFO, fmt, args);\n  va_end(args);\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":273915,"func":"static void handle_RMD(ctrl_t *ctrl, char *arg)\n{\n\thandle_DELE(ctrl, arg);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":310113,"func":"legal_tab_list(const char *tab_list)\n{\n    bool result = TRUE;\n\n    if (tab_list != 0 && *tab_list != '\\0') {\n\tif (comma_is_needed(tab_list)) {\n\t    int n, ch;\n\t    for (n = 0; tab_list[n] != '\\0'; ++n) {\n\t\tch = UChar(tab_list[n]);\n\t\tif (!(isdigit(ch) || ch == ',' || ch == '+')) {\n\t\t    fprintf(stderr,\n\t\t\t    \"%s: unexpected character found '%c'\\n\",\n\t\t\t    _nc_progname, ch);\n\t\t    result = FALSE;\n\t\t    break;\n\t\t}\n\t    }\n\t} else {\n\t    fprintf(stderr, \"%s: trailing comma found '%s'\\n\", _nc_progname, tab_list);\n\t    result = FALSE;\n\t}\n    } else {\n\tfprintf(stderr, \"%s: no tab-list given\\n\", _nc_progname);\n\tresult = FALSE;\n    }\n    return result;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":366196,"func":"bool __is_local_mountpoint(struct dentry *dentry)\n{\n\tstruct mnt_namespace *ns = current->nsproxy->mnt_ns;\n\tstruct mount *mnt;\n\tbool is_covered = false;\n\n\tdown_read(&namespace_sem);\n\tlock_ns_list(ns);\n\tlist_for_each_entry(mnt, &ns->list, mnt_list) {\n\t\tif (mnt_is_cursor(mnt))\n\t\t\tcontinue;\n\t\tis_covered = (mnt->mnt_mountpoint == dentry);\n\t\tif (is_covered)\n\t\t\tbreak;\n\t}\n\tunlock_ns_list(ns);\n\tup_read(&namespace_sem);\n\n\treturn is_covered;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":244215,"func":"GF_Box *bloc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_BaseLocationBox, GF_ISOM_BOX_TYPE_BLOC);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":486794,"func":"static void gem_update_int_status(CadenceGEMState *s)\n{\n    int i;\n\n    qemu_set_irq(s->irq[0], !!s->regs[GEM_ISR]);\n\n    for (i = 1; i < s->num_priority_queues; ++i) {\n        qemu_set_irq(s->irq[i], !!s->regs[GEM_INT_Q1_STATUS + i - 1]);\n    }\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":230279,"func":"njs_array_handler_index_of(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    if (njs_values_strict_equal(args->argument, entry)) {\n        njs_set_number(&vm->retval, n);\n\n        return NJS_DONE;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":139233,"func":"bool OverlayWindowViews::IsVisible() const {\n  return views::Widget::IsVisible();\n}\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":225114,"func":"string DefaultAttrStr(const OpDef::AttrDef& attr) {\n  if (!attr.has_default_value()) return \"no default\";\n  return SummarizeAttrValue(attr.default_value());\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":436119,"func":"static void __io_complete_rw(struct io_kiocb *req, long res, long res2,\n\t\t\t     unsigned int issue_flags)\n{\n\tint cflags = 0;\n\n\tif (req->rw.kiocb.ki_flags & IOCB_WRITE)\n\t\tkiocb_end_write(req);\n\tif (res != req->result) {\n\t\tif ((res == -EAGAIN || res == -EOPNOTSUPP) &&\n\t\t    io_rw_should_reissue(req)) {\n\t\t\treq->flags |= REQ_F_REISSUE;\n\t\t\treturn;\n\t\t}\n\t\treq_set_fail(req);\n\t}\n\tif (req->flags & REQ_F_BUFFER_SELECTED)\n\t\tcflags = io_put_rw_kbuf(req);\n\t__io_req_complete(req, issue_flags, res, cflags);\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":343179,"func":"static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqihlen)\n{\n\tunsigned int len;\n\n\tlen = seqihlen;\n\n\tlen += crypto_aead_ivsize(aead);\n\n\tif (len) {\n\t\tlen += crypto_aead_alignmask(aead) &\n\t\t       ~(crypto_tfm_ctx_alignment() - 1);\n\t\tlen = ALIGN(len, crypto_tfm_ctx_alignment());\n\t}\n\n\tlen += sizeof(struct aead_request) + crypto_aead_reqsize(aead);\n\tlen = ALIGN(len, __alignof__(struct scatterlist));\n\n\tlen += sizeof(struct scatterlist) * nfrags;\n\n\treturn kmalloc(len, GFP_ATOMIC);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":336141,"func":"static void ip6gre_dellink(struct net_device *dev, struct list_head *head)\n{\n\tstruct net *net = dev_net(dev);\n\tstruct ip6gre_net *ign = net_generic(net, ip6gre_net_id);\n\n\tif (dev != ign->fb_tunnel_dev)\n\t\tunregister_netdevice_queue(dev, head);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":269317,"func":"static av_always_inline void snow_interleave_line_footer(int * i, IDWTELEM * low, IDWTELEM * high){\n    for (; (*i)>=0; (*i)-=2){\n        low[(*i)+1] = high[(*i)>>1];\n        low[*i] = low[(*i)>>1];\n    }\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":247144,"func":"u32 gf_fs_get_filters_count(GF_FilterSession *session)\n{\n\treturn session ? gf_list_count(session->filters) : 0;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":512692,"func":"longlong Item_func_between::val_int_cmp_time()\n{\n  THD *thd= current_thd;\n  longlong value= args[0]->val_time_packed(thd), a, b;\n  if ((null_value= args[0]->null_value))\n    return 0;\n  a= args[1]->val_time_packed(thd);\n  b= args[2]->val_time_packed(thd);\n  return val_int_cmp_int_finalize(value, a, b);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":228442,"func":"static String HHVM_FUNCTION(wddx_packet_end, const Resource& packet_id) {\n  return cast<WddxPacket>(packet_id)->packet_end();\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":359247,"func":"DEFUN (ip_community_list_name_expanded,\n       ip_community_list_name_expanded_cmd,\n       \"ip community-list expanded WORD (deny|permit) .LINE\",\n       IP_STR\n       COMMUNITY_LIST_STR\n       \"Add an expanded community-list entry\\n\"\n       \"Community list name\\n\"\n       \"Specify community to reject\\n\"\n       \"Specify community to accept\\n\"\n       \"An ordered list as a regular-expression\\n\")\n{\n  return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":234728,"func":"bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr)\n{\n\tstruct btrfs_swapfile_pin *sp;\n\tstruct rb_node *node;\n\n\tspin_lock(&fs_info->swapfile_pins_lock);\n\tnode = fs_info->swapfile_pins.rb_node;\n\twhile (node) {\n\t\tsp = rb_entry(node, struct btrfs_swapfile_pin, node);\n\t\tif (ptr < sp->ptr)\n\t\t\tnode = node->rb_left;\n\t\telse if (ptr > sp->ptr)\n\t\t\tnode = node->rb_right;\n\t\telse\n\t\t\tbreak;\n\t}\n\tspin_unlock(&fs_info->swapfile_pins_lock);\n\treturn node != NULL;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":336144,"func":"static inline bool ip6gre_tnl_addr_conflict(const struct ip6_tnl *t,\n\tconst struct ipv6hdr *hdr)\n{\n\treturn ipv6_addr_equal(&t->parms.raddr, &hdr->saddr);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":463136,"func":"EXPORTED void freestrlist(struct strlist *l)\n{\n    struct strlist *n;\n\n    while (l) {\n        n = l->next;\n        free(l->s);\n        if (l->p) charset_freepat(l->p);\n        free((char *)l);\n        l = n;\n    }\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":409443,"func":"invoke_tgetent(char_u *tbuf, char_u *term)\n{\n    int\t    i;\n\n    \/\/ Note: Valgrind may report a leak here, because the library keeps one\n    \/\/ buffer around that we can't ever free.\n    i = TGETENT(tbuf, term);\n    if (i < 0\t\t    \/\/ -1 is always an error\n# ifdef TGETENT_ZERO_ERR\n\t    || i == 0\t    \/\/ sometimes zero is also an error\n# endif\n       )\n    {\n\t\/\/ On FreeBSD tputs() gets a SEGV after a tgetent() which fails.  Call\n\t\/\/ tgetent() with the always existing \"dumb\" entry to avoid a crash or\n\t\/\/ hang.\n\t(void)TGETENT(tbuf, \"dumb\");\n\n\tif (i < 0)\n# ifdef TGETENT_ZERO_ERR\n\t    return _(e_cannot_open_termcap_file);\n\tif (i == 0)\n# endif\n#ifdef TERMINFO\n\t    return _(e_terminal_entry_not_found_in_terminfo);\n#else\n\t    return _(e_terminal_entry_not_found_in_termcap);\n#endif\n    }\n    return NULL;\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":253638,"func":"smb2_cached_lease_break(struct work_struct *work)\n{\n\tstruct cached_fid *cfid = container_of(work,\n\t\t\t\tstruct cached_fid, lease_break);\n\n\tclose_cached_dir_lease(cfid);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":232331,"func":"GF_EdtsEntry *CreateEditEntry(u64 EditDuration, u64 MediaTime, u32 MediaRate, u8 EditMode)\n{\n\tGF_EdtsEntry *ent;\n\n\tent = (GF_EdtsEntry*)gf_malloc(sizeof(GF_EdtsEntry));\n\tif (!ent) return NULL;\n\n\tswitch (EditMode) {\n\tcase GF_ISOM_EDIT_EMPTY:\n\t\tent->mediaRate = 0x10000;\n\t\tent->mediaTime = -1;\n\t\tbreak;\n\n\tcase GF_ISOM_EDIT_DWELL:\n\t\tent->mediaRate = 0;\n\t\tent->mediaTime = MediaTime;\n\t\tbreak;\n\tdefault:\n\t\tent->mediaRate = MediaRate;\n\t\tent->mediaTime = MediaTime;\n\t\tbreak;\n\t}\n\tent->segmentDuration = EditDuration;\n\treturn ent;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":395086,"func":"redraw_win_later(\n    win_T\t*wp,\n    int\t\ttype)\n{\n    if (!exiting && wp->w_redr_type < type)\n    {\n\twp->w_redr_type = type;\n\tif (type >= NOT_VALID)\n\t    wp->w_lines_valid = 0;\n\tif (must_redraw < type)\t\/\/ must_redraw is the maximum of all windows\n\t    must_redraw = type;\n    }\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":224993,"func":"PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)\n{\n\tPGContextVisibility old;\n\n\tif (!conn)\n\t\treturn PQSHOW_CONTEXT_ERRORS;\n\told = conn->show_context;\n\tconn->show_context = show_context;\n\treturn old;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":359514,"func":"peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,\n\t\t\t       safi_t safi)\n{\n  int ret;\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  ret = peer_unsuppress_map_unset (peer, afi, safi);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":455423,"func":"xfs_iflag_for_tag(\n\tint\t\ttag)\n{\n\tswitch (tag) {\n\tcase XFS_ICI_EOFBLOCKS_TAG:\n\t\treturn XFS_IEOFBLOCKS;\n\tcase XFS_ICI_COWBLOCKS_TAG:\n\t\treturn XFS_ICOWBLOCKS;\n\tdefault:\n\t\tASSERT(0);\n\t\treturn 0;\n\t}\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":90761,"func":"  void DidGetHostUsage(const std::string& host,\n                       StorageType type,\n                       int64 usage) {\n    DCHECK_EQ(host_, host);\n    DCHECK_EQ(type_, type);\n    host_usage_ = usage;\n    CheckCompleted();\n  }\n","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":262006,"func":"int Curl_conncache_init(struct conncache *connc, int size)\n{\n  \/* allocate a new easy handle to use when closing cached connections *\/\n  connc->closure_handle = curl_easy_init();\n  if(!connc->closure_handle)\n    return 1; \/* bad *\/\n\n  Curl_hash_init(&connc->hash, size, Curl_hash_str,\n                 Curl_str_key_compare, free_bundle_hash_entry);\n  connc->closure_handle->state.conn_cache = connc;\n\n  return 0; \/* good *\/\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":90870,"func":"  void SetUp() {\n    ASSERT_TRUE(data_dir_.CreateUniqueTempDir());\n    mock_special_storage_policy_ = new MockSpecialStoragePolicy;\n    quota_manager_ = new QuotaManager(\n        false \/* is_incognito *\/,\n        data_dir_.path(),\n        MessageLoopProxy::current(),\n        MessageLoopProxy::current(),\n        mock_special_storage_policy_);\n    quota_manager_->eviction_disabled_ = true;\n    additional_callback_count_ = 0;\n  }\n","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":222921,"func":"  bool operator()(const Handle& h1, const Handle& h2) const {\n    return h1.SameHandle(h2);\n  }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":331784,"func":"static void qpaintengineex_moveTo(qreal x, qreal y, void *data) {\n    ((StrokeHandler *) data)->pts.add(x);\n    ((StrokeHandler *) data)->pts.add(y);\n    ((StrokeHandler *) data)->types.add(QPainterPath::MoveToElement);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":270394,"func":"ok_png ok_png_read(FILE *file, ok_png_decode_flags decode_flags) {\n    return ok_png_read_with_allocator(file, decode_flags, OK_PNG_DEFAULT_ALLOCATOR, NULL);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":247724,"func":"TEST_P(SslSocketTest, ClientSessionResumptionEnabledTls12) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      tls_minimum_protocol_version: TLSv1_0\n      tls_maximum_protocol_version: TLSv1_2\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      tls_minimum_protocol_version: TLSv1_0\n      tls_maximum_protocol_version: TLSv1_2\n  max_session_keys: 2\n)EOF\";\n\n  testClientSessionResumption(server_ctx_yaml, client_ctx_yaml, true, GetParam());\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":246698,"func":"u32 parse_cryp(char *arg_val, u32 opt)\n{\n\topen_edit = GF_TRUE;\n\tif (!opt) {\n\t\tcrypt = 1;\n\t\tdrm_file = arg_val;\n\t\topen_edit = GF_TRUE;\n\t\treturn 0;\n\t}\n\tcrypt = 2;\n\tif (arg_val && get_file_type_by_ext(arg_val) != 1) {\n\t\tdrm_file = arg_val;\n\t\treturn 0;\n\t}\n\treturn 3;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":313801,"func":"nv_ctrlo(cmdarg_T *cap)\n{\n    if (VIsual_active && VIsual_select)\n    {\n\tVIsual_select = FALSE;\n\tmay_trigger_modechanged();\n\tshowmode();\n\trestart_VIsual_select = 2;\t\/\/ restart Select mode later\n    }\n    else\n    {\n\tcap->count1 = -cap->count1;\n\tnv_pcmark(cap);\n    }\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":225017,"func":"PQconninfo(PGconn *conn)\n{\n\tPQExpBufferData errorBuf;\n\tPQconninfoOption *connOptions;\n\n\tif (conn == NULL)\n\t\treturn NULL;\n\n\t\/*\n\t * We don't actually report any errors here, but callees want a buffer,\n\t * and we prefer not to trash the conn's errorMessage.\n\t *\/\n\tinitPQExpBuffer(&errorBuf);\n\tif (PQExpBufferDataBroken(errorBuf))\n\t\treturn NULL;\t\t\t\/* out of memory already :-( *\/\n\n\tconnOptions = conninfo_init(&errorBuf);\n\n\tif (connOptions != NULL)\n\t{\n\t\tconst internalPQconninfoOption *option;\n\n\t\tfor (option = PQconninfoOptions; option->keyword; option++)\n\t\t{\n\t\t\tchar\t  **connmember;\n\n\t\t\tif (option->connofs < 0)\n\t\t\t\tcontinue;\n\n\t\t\tconnmember = (char **) ((char *) conn + option->connofs);\n\n\t\t\tif (*connmember)\n\t\t\t\tconninfo_storeval(connOptions, option->keyword, *connmember,\n\t\t\t\t\t\t\t\t  &errorBuf, true, false);\n\t\t}\n\t}\n\n\ttermPQExpBuffer(&errorBuf);\n\n\treturn connOptions;\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":275985,"func":"uECC_VLI_API uECC_word_t uECC_vli_sub(uECC_word_t *result,\n                                      const uECC_word_t *left,\n                                      const uECC_word_t *right,\n                                      wordcount_t num_words) {\n    uECC_word_t borrow = 0;\n    wordcount_t i;\n    for (i = 0; i < num_words; ++i) {\n        uECC_word_t diff = left[i] - right[i] - borrow;\n        if (diff != left[i]) {\n            borrow = (diff > left[i]);\n        }\n        result[i] = diff;\n    }\n    return borrow;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":222923,"func":"    std::string StringifyShapeHandle(ShapeHandle s) {\n      auto* ic = inference_context.get();\n      if (ic->RankKnown(s)) {\n        std::vector<std::string> vals;\n        for (int i = 0; i < ic->Rank(s); i++) {\n          DimensionHandle d = ic->Dim(s, i);\n          if (ic->ValueKnown(d) && ic->Value(d) == kUnknownDimFromConst) {\n            vals.push_back(\"?(Const)\");\n          } else {\n            vals.push_back(ic->DebugString(d));\n          }\n        }\n        return strings::StrCat(\"[\", absl::StrJoin(vals, \",\"), \"]\");\n      } else {\n        return \"?\";\n      }\n    }","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":265420,"func":"static std::string getDescription(const std::string &fulltext, int line)\n{\n\tif (line < 1) return \"\";\n\n\tunsigned int start = 0;\n\tfor (; start<fulltext.length() ; ++start) {\n\t\tif (line <= 1) break;\n\t\tif (fulltext[start] == '\\n') line--;\n\t}\n\n\t\/\/ not a valid description\n\tif (fulltext.compare(start, 2, \"\/\/\") != 0) return \"\";\n\n\t\/\/ Jump over the two forward slashes\n\tstart = start+2;\n\n\t\/\/Jump over all the spaces\n\twhile (fulltext[start] == ' ' || fulltext[start] == '\\t') start++;\n\tstd::string retString = \"\";\n\n\t\/\/ go till the end of the line\n\twhile (fulltext[start] != '\\n') {\n\t\t\/\/ replace \/\/ with space\n\t\tif (fulltext.compare(start, 2, \"\/\/\") == 0) {\n\t\t\tretString += \" \";\n\t\t\tstart++;\n\t\t} else {\n\t\t\tretString += fulltext[start];\n\t\t}\n\t\tstart++;\n\t}\n\treturn retString;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":459112,"func":"static int tc_setup_offload_act(struct tc_action *act,\n\t\t\t\tstruct flow_action_entry *entry,\n\t\t\t\tu32 *index_inc)\n{\n#ifdef CONFIG_NET_CLS_ACT\n\tif (act->ops->offload_act_setup)\n\t\treturn act->ops->offload_act_setup(act, entry, index_inc, true);\n\telse\n\t\treturn -EOPNOTSUPP;\n#else\n\treturn 0;\n#endif\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":351180,"func":"static double area2d_polygon (int n, const double *x, const double *y) {\n  double area = 0;\n  for (int i = 1; i < n; i++) {\n    area += (x[i-1] + x[i]) * (y[i] - y[i-1]);\n  }\n  return area \/ 2.0;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":265432,"func":"TfLiteStatus Gather(TfLiteContext* context, const TfLiteGatherParams& params,\n                    const TfLiteTensor* input, const TfLiteTensor* positions,\n                    TfLiteTensor* output) {\n  const PositionsT* indexes = GetTensorData<PositionsT>(positions);\n  bool indices_has_only_positive_elements = true;\n  const size_t num_indices = positions->bytes \/ sizeof(PositionsT);\n  for (size_t i = 0; i < num_indices; i++) {\n    if (indexes[i] < 0) {\n      indices_has_only_positive_elements = false;\n      break;\n    }\n  }\n  TF_LITE_ENSURE(context, indices_has_only_positive_elements);\n\n  tflite::GatherParams op_params;\n  op_params.axis = params.axis;\n  op_params.batch_dims = params.batch_dims;\n  optimized_ops::Gather(op_params, GetTensorShape(input),\n                        GetTensorData<InputT>(input), GetTensorShape(positions),\n                        GetTensorData<PositionsT>(positions),\n                        GetTensorShape(output), GetTensorData<InputT>(output));\n  return kTfLiteOk;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":223387,"func":"static SLJIT_INLINE void match_script_run_common(compiler_common *common, int private_data_ptr, backtrack_common *parent)\n{\nDEFINE_COMPILER;\n\nSLJIT_ASSERT(TMP1 == SLJIT_R0 && STR_PTR == SLJIT_R1);\n\nOP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);\n#ifdef SUPPORT_UNICODE\nsljit_emit_icall(compiler, SLJIT_CALL, SLJIT_ARGS2(W, W, W), SLJIT_IMM,\n  common->utf ? SLJIT_FUNC_ADDR(do_script_run_utf) : SLJIT_FUNC_ADDR(do_script_run));\n#else\nsljit_emit_icall(compiler, SLJIT_CALL, SLJIT_ARGS2(W, W, W), SLJIT_IMM, SLJIT_FUNC_ADDR(do_script_run));\n#endif\n\nOP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0);\nadd_jump(compiler, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":241073,"func":"static void client_dead(int ci)\n{\n\tstruct client *c = clients + ci;\n\n\tif (c->fd != -1) {\n\t\tlog_debug(\"removing client %d\", c->fd);\n\t\tclose(c->fd);\n\t}\n\n\tc->fd = -1;\n\tc->workfn = NULL;\n\n\tif (c->msg) {\n\t\tfree(c->msg);\n\t\tc->msg = NULL;\n\t\tc->offset = 0;\n\t}\n\n\tpollfds[ci].fd = -1;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":326614,"func":"archive_write_disk_set_acls(struct archive *a, int fd, const char *name,\n    struct archive_acl *abstract_acl, __LA_MODE_T mode)\n{\n\t(void)a; \/* UNUSED *\/\n\t(void)fd; \/* UNUSED *\/\n\t(void)name; \/* UNUSED *\/\n\t(void)abstract_acl; \/* UNUSED *\/\n\t(void)mode; \/* UNUSED *\/\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":443160,"func":"int jfs_write_inode(struct inode *inode, struct writeback_control *wbc)\n{\n\tint wait = wbc->sync_mode == WB_SYNC_ALL;\n\n\tif (inode->i_nlink == 0)\n\t\treturn 0;\n\t\/*\n\t * If COMMIT_DIRTY is not set, the inode isn't really dirty.\n\t * It has been committed since the last change, but was still\n\t * on the dirty inode list.\n\t *\/\n\tif (!test_cflag(COMMIT_Dirty, inode)) {\n\t\t\/* Make sure committed changes hit the disk *\/\n\t\tjfs_flush_journal(JFS_SBI(inode->i_sb)->log, wait);\n\t\treturn 0;\n\t}\n\n\tif (jfs_commit_inode(inode, wait)) {\n\t\tjfs_err(\"jfs_write_inode: jfs_commit_inode failed!\");\n\t\treturn -EIO;\n\t} else\n\t\treturn 0;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":442815,"func":"static void warnf(struct Configurable *config, const char *fmt, ...)\n{\n  if(!(config->conf & CONF_MUTE)) {\n    va_list ap;\n    int len;\n    char *ptr;\n    char print_buffer[256];\n\n    va_start(ap, fmt);\n    va_start(ap, fmt);\n    len = vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);\n    va_end(ap);\n\n    ptr = print_buffer;\n    while(len > 0) {\n      fputs(WARN_PREFIX, config->errors);\n\n      if(len > (int)WARN_TEXTWIDTH) {\n        int cut = WARN_TEXTWIDTH-1;\n\n        while(!ISSPACE(ptr[cut]) && cut) {\n          cut--;\n        }\n        if(0 == cut)\n          \/* not a single cutting position was found, just cut it at the\n             max text width then! *\/\n          cut = WARN_TEXTWIDTH-1;\n\n        fwrite(ptr, cut + 1, 1, config->errors);\n        fputs(\"\\n\", config->errors);\n        ptr += cut+1; \/* skip the space too *\/\n        len -= cut;\n      }\n      else {\n        fputs(ptr, config->errors);\n        len = 0;\n      }\n    }\n  }\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":236204,"func":"GF_Err href_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 len;\n\tGF_TextHyperTextBox*ptr = (GF_TextHyperTextBox*)s;\n\tISOM_DECREASE_SIZE(ptr, 6) \/\/including 2 length fields\n\tptr->startcharoffset = gf_bs_read_u16(bs);\n\tptr->endcharoffset = gf_bs_read_u16(bs);\n\tlen = gf_bs_read_u8(bs);\n\tif (len) {\n\t\tISOM_DECREASE_SIZE(ptr, len)\n\t\tptr->URL = (char *) gf_malloc(sizeof(char) * (len+1));\n\t\tif (!ptr->URL) return GF_OUT_OF_MEM;\n\t\tgf_bs_read_data(bs, ptr->URL, len);\n\t\tptr->URL[len] = 0;\n\t}\n\tlen = gf_bs_read_u8(bs);\n\tif (len) {\n\t\tISOM_DECREASE_SIZE(ptr, len)\n\t\tptr->URL_hint = (char *) gf_malloc(sizeof(char) * (len+1));\n\t\tif (!ptr->URL_hint) return GF_OUT_OF_MEM;\n\t\tgf_bs_read_data(bs, ptr->URL_hint, len);\n\t\tptr->URL_hint[len]= 0;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":373541,"func":"ipf_is_first_v6_frag(ovs_be16 ip6f_offlg)\n{\n    if (!(ip6f_offlg & IP6F_OFF_MASK) &&\n        ip6f_offlg & IP6F_MORE_FRAG) {\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":90232,"func":"  virtual const WifiNetworkVector& wifi_networks() const {\n    return wifi_networks_;\n  }\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":252436,"func":"inline void outputBits(int nBits, long long bits, long long &c, int &lc,\n                       char *&out) {\n  c <<= nBits;\n  lc += nBits;\n\n  c |= bits;\n\n  while (lc >= 8) *out++ = static_cast<char>((c >> (lc -= 8)));\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":233938,"func":"void validateUnionWithCollectionlessPipeline(\n    const boost::optional<std::vector<mongo::BSONObj>>& pipeline) {\n    uassert(ErrorCodes::FailedToParse,\n            \"$unionWith stage without explicit collection must have a pipeline with $documents as \"\n            \"first stage\",\n            pipeline && pipeline->size() > 0 &&\n                !(*pipeline)[0].getField(DocumentSourceDocuments::kStageName).eoo());\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":366310,"func":"void mark_mounts_for_expiry(struct list_head *mounts)\n{\n\tstruct mount *mnt, *next;\n\tLIST_HEAD(graveyard);\n\n\tif (list_empty(mounts))\n\t\treturn;\n\n\tnamespace_lock();\n\tlock_mount_hash();\n\n\t\/* extract from the expiration list every vfsmount that matches the\n\t * following criteria:\n\t * - only referenced by its parent vfsmount\n\t * - still marked for expiry (marked on the last call here; marks are\n\t *   cleared by mntput())\n\t *\/\n\tlist_for_each_entry_safe(mnt, next, mounts, mnt_expire) {\n\t\tif (!xchg(&mnt->mnt_expiry_mark, 1) ||\n\t\t\tpropagate_mount_busy(mnt, 1))\n\t\t\tcontinue;\n\t\tlist_move(&mnt->mnt_expire, &graveyard);\n\t}\n\twhile (!list_empty(&graveyard)) {\n\t\tmnt = list_first_entry(&graveyard, struct mount, mnt_expire);\n\t\ttouch_mnt_namespace(mnt->mnt_ns);\n\t\tumount_tree(mnt, UMOUNT_PROPAGATE|UMOUNT_SYNC);\n\t}\n\tunlock_mount_hash();\n\tnamespace_unlock();\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":508802,"func":"Lex_input_stream::unescape(CHARSET_INFO *cs, char *to,\n                           const char *str, const char *end,\n                           int sep)\n{\n  return my_unescape(cs, to, str, end, sep, m_thd->backslash_escapes());\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":512919,"func":"  my_decimal *val_decimal(my_decimal *to)\n  {\n    return update_null() ? 0 : cached_time.to_decimal(to);\n  }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":483513,"func":"static __init int match_config_table(efi_guid_t *guid,\n\t\t\t\t     unsigned long table,\n\t\t\t\t     efi_config_table_type_t *table_types)\n{\n\tint i;\n\n\tif (table_types) {\n\t\tfor (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) {\n\t\t\tif (!efi_guidcmp(*guid, table_types[i].guid)) {\n\t\t\t\t*(table_types[i].ptr) = table;\n\t\t\t\tif (table_types[i].name)\n\t\t\t\t\tpr_cont(\" %s=0x%lx \",\n\t\t\t\t\t\ttable_types[i].name, table);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":238420,"func":"static bool is_cmpxchg_insn(const struct bpf_insn *insn)\n{\n\treturn BPF_CLASS(insn->code) == BPF_STX &&\n\t       BPF_MODE(insn->code) == BPF_ATOMIC &&\n\t       insn->imm == BPF_CMPXCHG;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":512386,"func":"bool Item_func_case_simple::prepare_predicant_and_values(THD *thd,\n                                                         uint *found_types,\n                                                         bool nulls_equal)\n{\n  bool have_null= false;\n  uint type_cnt;\n  Type_handler_hybrid_field_type tmp;\n  uint ncases= when_count();\n  add_predicant(this, 0);\n  for (uint i= 0 ; i < ncases; i++)\n  {\n    if (nulls_equal ?\n        add_value(\"case..when\", this, i + 1) :\n        add_value_skip_null(\"case..when\", this, i + 1, &have_null))\n      return true;\n  }\n  all_values_added(&tmp, &type_cnt, &m_found_types);\n#ifndef DBUG_OFF\n  Predicant_to_list_comparator::debug_print(thd);\n#endif\n  return false;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":264282,"func":"static void vnc_colordepth(VncState *vs)\n{\n    if (vnc_has_feature(vs, VNC_FEATURE_WMVI)) {\n        \/* Sending a WMVi message to notify the client*\/\n        vnc_lock_output(vs);\n        vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);\n        vnc_write_u8(vs, 0);\n        vnc_write_u16(vs, 1); \/* number of rects *\/\n        vnc_framebuffer_update(vs, 0, 0,\n                               surface_width(vs->vd->ds),\n                               surface_height(vs->vd->ds),\n                               VNC_ENCODING_WMVi);\n        pixel_format_message(vs);\n        vnc_unlock_output(vs);\n        vnc_flush(vs);\n    } else {\n        set_pixel_conversion(vs);\n    }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":369112,"func":"static void io_req_task_queue_fail(struct io_kiocb *req, int ret)\n{\n\treq->result = ret;\n\treq->io_task_work.func = io_req_task_cancel;\n\tio_req_task_work_add(req, false);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":450816,"func":"convert_dirent (const struct dirent *source)\n{\n  if (source == NULL)\n    {\n      struct readdir_result result = { NULL, };\n      return result;\n    }\n  struct readdir_result result = READDIR_RESULT_INITIALIZER (source);\n  return result;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":371181,"func":"static pyc_object *get_dict_object(RzBinPycObj *pyc, RzBuffer *buffer) {\n\tpyc_object *ret = NULL,\n\t\t   *key = NULL,\n\t\t   *val = NULL;\n\n\tret = RZ_NEW0(pyc_object);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tret->data = rz_list_newf((RzListFree)free_object);\n\tif (!ret->data) {\n\t\tRZ_FREE(ret);\n\t\treturn NULL;\n\t}\n\tfor (;;) {\n\t\tkey = get_object(pyc, buffer);\n\t\tif (!key) {\n\t\t\tbreak;\n\t\t}\n\t\tif (!rz_list_append(ret->data, key)) {\n\t\t\trz_list_free(ret->data);\n\t\t\tRZ_FREE(ret);\n\t\t\tfree_object(key);\n\t\t\treturn NULL;\n\t\t}\n\t\tval = get_object(pyc, buffer);\n\t\tif (!val) {\n\t\t\tbreak;\n\t\t}\n\t\tif (!rz_list_append(ret->data, val)) {\n\t\t\trz_list_free(ret->data);\n\t\t\tRZ_FREE(ret);\n\t\t\tfree_object(val);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\tret->type = TYPE_DICT;\n\treturn ret;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":230614,"func":"void decode_prediction_unit(base_context* ctx,\n                            const slice_segment_header* shdr,\n                            de265_image* img,\n                            const PBMotionCoding& motion,\n                            int xC,int yC, int xB,int yB, int nCS, int nPbW,int nPbH, int partIdx)\n{\n  logtrace(LogMotion,\"decode_prediction_unit POC=%d %d;%d %dx%d\\n\",\n           img->PicOrderCntVal, xC+xB,yC+yB, nPbW,nPbH);\n\n  \/\/slice_segment_header* shdr = tctx->shdr;\n\n  \/\/ 1.\n\n  PBMotion vi;\n  motion_vectors_and_ref_indices(ctx, shdr, img, motion,\n                                 xC,yC, xB,yB, nCS, nPbW,nPbH, partIdx, &vi);\n\n  \/\/ 2.\n\n  generate_inter_prediction_samples(ctx,shdr, img, xC,yC, xB,yB, nCS, nPbW,nPbH, &vi);\n\n\n  img->set_mv_info(xC+xB,yC+yB,nPbW,nPbH, vi);\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":90894,"func":" void UsageTracker::GetCachedOrigins(std::set<GURL>* origins) const {\n   DCHECK(origins);\n   origins->clear();\n  for (ClientTrackerMap::const_iterator iter = client_tracker_map_.begin();\n       iter != client_tracker_map_.end(); ++iter) {\n    iter->second->GetCachedOrigins(origins);\n  }\n}\n","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":352941,"func":"int octetStringFilter(\n\tslap_mask_t use,\n\tslap_mask_t flags,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *prefix,\n\tvoid * assertedValue,\n\tBerVarray *keysp,\n\tvoid *ctx )\n{\n\tBerVarray keys;\n\tHASH_CONTEXT HASHcontext;\n\tunsigned char HASHdigest[HASH_BYTES];\n\tstruct berval *value = (struct berval *) assertedValue;\n\tstruct berval digest;\n\tdigest.bv_val = (char *)HASHdigest;\n\tdigest.bv_len = HASH_LEN;\n\n\tkeys = slap_sl_malloc( sizeof( struct berval ) * 2, ctx );\n\n\thashPreset( &HASHcontext, prefix, 0, syntax, mr );\n\thashIter( &HASHcontext, HASHdigest,\n\t\t(unsigned char *)value->bv_val, value->bv_len );\n\n\tber_dupbv_x( keys, &digest, ctx );\n\tBER_BVZERO( &keys[1] );\n\n\t*keysp = keys;\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":385820,"func":"SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length)\n{\n\treturn do_sys_ftruncate(fd, length, 0);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":369398,"func":"static int io_tee(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_splice *sp = &req->splice;\n\tstruct file *out = sp->file_out;\n\tunsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;\n\tstruct file *in;\n\tlong ret = 0;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tif (sp->flags & SPLICE_F_FD_IN_FIXED)\n\t\tin = io_file_get_fixed(req, sp->splice_fd_in, issue_flags);\n\telse\n\t\tin = io_file_get_normal(req, sp->splice_fd_in);\n\tif (!in) {\n\t\tret = -EBADF;\n\t\tgoto done;\n\t}\n\n\tif (sp->len)\n\t\tret = do_tee(in, out, sp->len, flags);\n\n\tif (!(sp->flags & SPLICE_F_FD_IN_FIXED))\n\t\tio_put_file(in);\ndone:\n\tif (ret != sp->len)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":413849,"func":"Method* LinkResolver::resolve_interface_call_or_null(\n                                                 Klass* receiver_klass,\n                                                 const LinkInfo& link_info) {\n  EXCEPTION_MARK;\n  CallInfo info;\n  resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD);\n  if (HAS_PENDING_EXCEPTION) {\n    CLEAR_PENDING_EXCEPTION;\n    return NULL;\n  }\n  return info.selected_method();\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":247713,"func":"TEST_P(SslSocketTest, TestConnectionFailsOnStapleRequiredAndOcspExpired) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/good_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/good_key.pem\"\n      ocsp_staple:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/unknown_ocsp_resp.der\"\n  ocsp_staple_policy: must_staple\n  )EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites:\n      - TLS_RSA_WITH_AES_128_GCM_SHA256\n)EOF\";\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.ocsp_staple_failed\").enableOcspStapling());\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":262795,"func":"static bool needs_escape(unsigned char c)\n{\n\treturn c == BYTE_ESC || c == BYTE_FRAME;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":400739,"func":"size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate,\n\t\t\t     struct iov_iter *i)\n{\n\tstruct csum_state *csstate = _csstate;\n\t__wsum sum, next;\n\n\tif (unlikely(iov_iter_is_discard(i))) {\n\t\tWARN_ON(1);\t\/* for now *\/\n\t\treturn 0;\n\t}\n\n\tsum = csum_shift(csstate->csum, csstate->off);\n\tif (unlikely(iov_iter_is_pipe(i)))\n\t\tbytes = csum_and_copy_to_pipe_iter(addr, bytes, i, &sum);\n\telse iterate_and_advance(i, bytes, base, len, off, ({\n\t\tnext = csum_and_copy_to_user(addr + off, base, len);\n\t\tsum = csum_block_add(sum, next, off);\n\t\tnext ? 0 : len;\n\t}), ({\n\t\tsum = csum_and_memcpy(base, addr + off, len, sum, off);\n\t})\n\t)\n\tcsstate->csum = csum_shift(sum, csstate->off);\n\tcsstate->off += bytes;\n\treturn bytes;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":225653,"func":"GF_Err kind_box_size(GF_Box *s)\n{\n\tGF_KindBox *ptr = (GF_KindBox *)s;\n\n    ptr->size += (ptr->schemeURI ? strlen(ptr->schemeURI) : 0) + 1;\n\tif (ptr->value) {\n\t\tptr->size += strlen(ptr->value) + 1;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":459123,"func":"static void tcf_proto_put(struct tcf_proto *tp, bool rtnl_held,\n\t\t\t  struct netlink_ext_ack *extack)\n{\n\tif (refcount_dec_and_test(&tp->refcnt))\n\t\ttcf_proto_destroy(tp, rtnl_held, true, extack);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":316984,"func":"static int selinux_tun_dev_attach(struct sock *sk, void *security)\n{\n\tstruct tun_security_struct *tunsec = security;\n\tstruct sk_security_struct *sksec = sk->sk_security;\n\n\t\/* we don't currently perform any NetLabel based labeling here and it\n\t * isn't clear that we would want to do so anyway; while we could apply\n\t * labeling without the support of the TUN user the resulting labeled\n\t * traffic from the other end of the connection would almost certainly\n\t * cause confusion to the TUN user that had no idea network labeling\n\t * protocols were being used *\/\n\n\tsksec->sid = tunsec->sid;\n\tsksec->sclass = SECCLASS_TUN_SOCKET;\n\n\treturn 0;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":221426,"func":"static void svm_inject_page_fault_nested(struct kvm_vcpu *vcpu, struct x86_exception *fault)\n{\n       struct vcpu_svm *svm = to_svm(vcpu);\n       WARN_ON(!is_guest_mode(vcpu));\n\n       if (vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_EXCEPTION_OFFSET + PF_VECTOR) &&\n\t   !svm->nested.nested_run_pending) {\n               svm->vmcb->control.exit_code = SVM_EXIT_EXCP_BASE + PF_VECTOR;\n               svm->vmcb->control.exit_code_hi = 0;\n               svm->vmcb->control.exit_info_1 = fault->error_code;\n               svm->vmcb->control.exit_info_2 = fault->address;\n               nested_svm_vmexit(svm);\n       } else {\n               kvm_inject_page_fault(vcpu, fault);\n       }\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":484776,"func":"static struct sk_buff *xennet_get_rx_skb(struct netfront_queue *queue,\n\t\t\t\t\t RING_IDX ri)\n{\n\tint i = xennet_rxidx(ri);\n\tstruct sk_buff *skb = queue->rx_skbs[i];\n\tqueue->rx_skbs[i] = NULL;\n\treturn skb;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":369194,"func":"static inline void __io_req_set_refcount(struct io_kiocb *req, int nr)\n{\n\tif (!(req->flags & REQ_F_REFCOUNT)) {\n\t\treq->flags |= REQ_F_REFCOUNT;\n\t\tatomic_set(&req->refs, nr);\n\t}\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":294525,"func":"date_s_ordinal(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vd, vsg, y, fr, fr2, ret;\n    int d;\n    double sg;\n\n    rb_scan_args(argc, argv, \"03\", &vy, &vd, &vsg);\n\n    y = INT2FIX(-4712);\n    d = 1;\n    fr2 = INT2FIX(0);\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 3:\n\tval2sg(vsg, sg);\n      case 2:\n        check_numeric(vd, \"yday\");\n\tnum2int_with_frac(d, positive_inf);\n      case 1:\n        check_numeric(vy, \"year\");\n\ty = vy;\n    }\n\n    {\n\tVALUE nth;\n\tint ry, rd, rjd, ns;\n\n\tif (!valid_ordinal_p(y, d, sg,\n\t\t\t     &nth, &ry,\n\t\t\t     &rd, &rjd,\n\t\t\t     &ns))\n\t    rb_raise(eDateError, \"invalid date\");\n\n\tret = d_simple_new_internal(klass,\n\t\t\t\t     nth, rjd,\n\t\t\t\t     sg,\n\t\t\t\t     0, 0, 0,\n\t\t\t\t     HAVE_JD);\n    }\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":245196,"func":"is_update_query(const char *query)\n{\n\tconst char *query_list[] = {\"insert\", \"update\", \"delete\", \"replace\",\n\t\t\t\t\t\"alter\", \"load\", NULL};\n\n\treturn is_query_from_list(query, query_list);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":353010,"func":"nameUIDValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tint rc;\n\tstruct berval dn, uid;\n\n\tif( BER_BVISEMPTY( in ) ) return LDAP_SUCCESS;\n\n\tber_dupbv( &dn, in );\n\tif( !dn.bv_val ) return LDAP_OTHER;\n\n\t\/* if there's a \"#\", try bitStringValidate()... *\/\n\tuid.bv_val = strrchr( dn.bv_val, '#' );\n\tif ( !BER_BVISNULL( &uid ) ) {\n\t\tuid.bv_val++;\n\t\tuid.bv_len = dn.bv_len - ( uid.bv_val - dn.bv_val );\n\n\t\trc = bitStringValidate( NULL, &uid );\n\t\tif ( rc == LDAP_SUCCESS ) {\n\t\t\t\/* in case of success, trim the UID,\n\t\t\t * otherwise treat it as part of the DN *\/\n\t\t\tdn.bv_len -= uid.bv_len + 1;\n\t\t\tuid.bv_val[-1] = '\\0';\n\t\t}\n\t}\n\n\trc = dnValidate( NULL, &dn );\n\n\tber_memfree( dn.bv_val );\n\treturn rc;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":310317,"func":"lookup_cached_dir_by_fp(const char *fp)\n{\n  cached_dir_t *d = NULL;\n  if (tor_digest_is_zero(fp) && cached_consensuses)\n    d = strmap_get(cached_consensuses, \"ns\");\n  else if (memchr(fp, '\\0', DIGEST_LEN) && cached_consensuses &&\n           (d = strmap_get(cached_consensuses, fp))) {\n    \/* this here interface is a nasty hack XXXX023 *\/;\n  } else if (router_digest_is_me(fp) && the_v2_networkstatus)\n    d = the_v2_networkstatus;\n  else if (cached_v2_networkstatus)\n    d = digestmap_get(cached_v2_networkstatus, fp);\n  return d;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":226101,"func":"\/*this is using chpl format according to some NeroRecode samples*\/\nGF_Err tfdt_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_TFBaseMediaDecodeTimeBox *ptr = (GF_TFBaseMediaDecodeTimeBox *)s;\n\n\tif (ptr->version==1) {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->baseMediaDecodeTime = gf_bs_read_u64(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->baseMediaDecodeTime = (u32) gf_bs_read_u32(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":450399,"func":"static int tight_fill_palette(VncState *vs, int x, int y,\n                              size_t count, uint32_t *bg, uint32_t *fg,\n                              VncPalette *palette)\n{\n    int max;\n\n    max = count \/ tight_conf[vs->tight->compression].idx_max_colors_divisor;\n    if (max < 2 &&\n        count >= tight_conf[vs->tight->compression].mono_min_rect_size) {\n        max = 2;\n    }\n    if (max >= 256) {\n        max = 256;\n    }\n\n    switch (vs->client_pf.bytes_per_pixel) {\n    case 4:\n        return tight_fill_palette32(vs, x, y, max, count, bg, fg, palette);\n    case 2:\n        return tight_fill_palette16(vs, x, y, max, count, bg, fg, palette);\n    default:\n        max = 2;\n        return tight_fill_palette8(vs, x, y, max, count, bg, fg, palette);\n    }\n    return 0;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":254065,"func":"        char* get(const std::string& name) const\n        {\n            char* ret = qs_k2v(name.c_str(), key_value_pairs_.data(), key_value_pairs_.size());\n            return ret;\n        }","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":294422,"func":"rt_rewrite_frags(VALUE hash)\n{\n    VALUE seconds;\n\n    seconds = del_hash(\"seconds\");\n    if (!NIL_P(seconds)) {\n\tVALUE offset, d, h, min, s, fr;\n\n\toffset = ref_hash(\"offset\");\n\tif (!NIL_P(offset))\n\t    seconds = f_add(seconds, offset);\n\n\td = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));\n\tfr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));\n\n\th = f_idiv(fr, INT2FIX(HOUR_IN_SECONDS));\n\tfr = f_mod(fr, INT2FIX(HOUR_IN_SECONDS));\n\n\tmin = f_idiv(fr, INT2FIX(MINUTE_IN_SECONDS));\n\tfr = f_mod(fr, INT2FIX(MINUTE_IN_SECONDS));\n\n\ts = f_idiv(fr, INT2FIX(1));\n\tfr = f_mod(fr, INT2FIX(1));\n\n\tset_hash(\"jd\", f_add(UNIX_EPOCH_IN_CJD, d));\n\tset_hash(\"hour\", h);\n\tset_hash(\"min\", min);\n\tset_hash(\"sec\", s);\n\tset_hash(\"sec_fraction\", fr);\n    }\n    return hash;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":222844,"func":"bool IsNumericType(const DataType dtype) {\n  static const gtl::FlatSet<DataType>* const kRealNumberTypes =\n      CHECK_NOTNULL((new gtl::FlatSet<DataType>{\n          \/\/ Floating point.\n          DT_BFLOAT16,\n          DT_HALF,\n          DT_FLOAT,\n          DT_DOUBLE,\n          \/\/ Int \/ UInt.\n          DT_INT8,\n          DT_INT16,\n          DT_INT32,\n          DT_INT64,\n          DT_UINT8,\n          DT_UINT16,\n          DT_UINT32,\n          DT_UINT64,\n          \/\/ Quantized Int.\n          DT_QINT8,\n          DT_QUINT8,\n          DT_QINT16,\n          DT_QUINT16,\n          DT_QINT32,\n          \/\/ Bool.\n          DT_BOOL,\n      }));\n  return kRealNumberTypes->find(dtype) != kRealNumberTypes->end();\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":462227,"func":"PJ_DEF(pj_status_t) pj_stun_msg_add_msgint_attr(pj_pool_t *pool,\n\t\t\t\t\t\tpj_stun_msg *msg)\n{\n    pj_stun_msgint_attr *attr = NULL;\n    pj_status_t status;\n\n    status = pj_stun_msgint_attr_create(pool, &attr);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    return pj_stun_msg_add_attr(msg, &attr->hdr);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":337841,"func":"struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc,\n\t\t\t\t  __u16 key_id)\n{\n\tstruct sctp_authhdr auth_hdr;\n\tstruct sctp_hmac *hmac_desc;\n\tstruct sctp_chunk *retval;\n\n\t\/* Get the first hmac that the peer told us to use *\/\n\thmac_desc = sctp_auth_asoc_get_hmac(asoc);\n\tif (unlikely(!hmac_desc))\n\t\treturn NULL;\n\n\tretval = sctp_make_control(asoc, SCTP_CID_AUTH, 0,\n\t\t\t\t   hmac_desc->hmac_len + sizeof(auth_hdr),\n\t\t\t\t   GFP_ATOMIC);\n\tif (!retval)\n\t\treturn NULL;\n\n\tauth_hdr.hmac_id = htons(hmac_desc->hmac_id);\n\tauth_hdr.shkey_id = htons(key_id);\n\n\tretval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(auth_hdr),\n\t\t\t\t\t\t &auth_hdr);\n\n\tskb_put_zero(retval->skb, hmac_desc->hmac_len);\n\n\t\/* Adjust the chunk header to include the empty MAC *\/\n\tretval->chunk_hdr->length =\n\t\thtons(ntohs(retval->chunk_hdr->length) + hmac_desc->hmac_len);\n\tretval->chunk_end = skb_tail_pointer(retval->skb);\n\n\treturn retval;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":291800,"func":"static int init_path(struct rtrs_clt_path *clt_path)\n{\n\tint err;\n\tchar str[NAME_MAX];\n\tstruct rtrs_addr path = {\n\t\t.src = &clt_path->s.src_addr,\n\t\t.dst = &clt_path->s.dst_addr,\n\t};\n\n\trtrs_addr_to_str(&path, str, sizeof(str));\n\n\tmutex_lock(&clt_path->init_mutex);\n\terr = init_conns(clt_path);\n\tif (err) {\n\t\trtrs_err(clt_path->clt,\n\t\t\t \"init_conns() failed: err=%d path=%s [%s:%u]\\n\", err,\n\t\t\t str, clt_path->hca_name, clt_path->hca_port);\n\t\tgoto out;\n\t}\n\terr = rtrs_send_path_info(clt_path);\n\tif (err) {\n\t\trtrs_err(clt_path->clt,\n\t\t\t \"rtrs_send_path_info() failed: err=%d path=%s [%s:%u]\\n\",\n\t\t\t err, str, clt_path->hca_name, clt_path->hca_port);\n\t\tgoto out;\n\t}\n\trtrs_clt_path_up(clt_path);\nout:\n\tmutex_unlock(&clt_path->init_mutex);\n\n\treturn err;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":310091,"func":"TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew)\n{\n    int rc;\n    rc = _nc_real_mvcur(NCURSES_SP_ARGx\n\t\t\tyold, xold,\n\t\t\tynew, xnew,\n\t\t\tNCURSES_SP_NAME(_nc_outch),\n\t\t\tTRUE);\n    if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))\n\tNCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);\n    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);\n    return rc;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":262798,"func":"static int next_chunk_len(struct mctp_serial *dev)\n{\n\tint i;\n\n\t\/* either we have no bytes to send ... *\/\n\tif (dev->txpos == dev->txlen)\n\t\treturn 0;\n\n\t\/* ... or the next byte to send is an escaped byte; requiring a\n\t * single-byte chunk...\n\t *\/\n\tif (needs_escape(dev->txbuf[dev->txpos]))\n\t\treturn 1;\n\n\t\/* ... or we have one or more bytes up to the next escape - this chunk\n\t * will be those non-escaped bytes, and does not include the escaped\n\t * byte.\n\t *\/\n\tfor (i = 1; i + dev->txpos + 1 < dev->txlen; i++) {\n\t\tif (needs_escape(dev->txbuf[dev->txpos + i + 1]))\n\t\t\tbreak;\n\t}\n\n\treturn i;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":225774,"func":"GF_Err tmax_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TMAXBox *ptr = (GF_TMAXBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->maxTime);\n\treturn GF_OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":252355,"func":"static MZ_FORCEINLINE int mz_zip_reader_filename_compare(\n    const mz_zip_array *pCentral_dir_array,\n    const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR,\n    mz_uint r_len) {\n  const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(\n                     pCentral_dir_array, mz_uint8,\n                     MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32,\n                                          l_index)),\n                 *pE;\n  mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);\n  mz_uint8 l = 0, r = 0;\n  pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;\n  pE = pL + MZ_MIN(l_len, r_len);\n  while (pL < pE) {\n    if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break;\n    pL++;\n    pR++;\n  }\n  return (pL == pE) ? (int)(l_len - r_len) : (l - r);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":317311,"func":"static inline u32 open_file_to_av(struct file *file)\n{\n\tu32 av = file_to_av(file);\n\tstruct inode *inode = file_inode(file);\n\n\tif (selinux_policycap_openperm() &&\n\t    inode->i_sb->s_magic != SOCKFS_MAGIC)\n\t\tav |= FILE__OPEN;\n\n\treturn av;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":438686,"func":"static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev)\n{\n\tstruct virtproc_info *vrp = vdev->priv;\n\tstruct virtio_rpmsg_channel *vch;\n\tstruct rpmsg_device *rpdev_ctrl;\n\tint err = 0;\n\n\tvch = kzalloc(sizeof(*vch), GFP_KERNEL);\n\tif (!vch)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\t\/* Link the channel to the vrp *\/\n\tvch->vrp = vrp;\n\n\t\/* Assign public information to the rpmsg_device *\/\n\trpdev_ctrl = &vch->rpdev;\n\trpdev_ctrl->ops = &virtio_rpmsg_ops;\n\n\trpdev_ctrl->dev.parent = &vrp->vdev->dev;\n\trpdev_ctrl->dev.release = virtio_rpmsg_release_device;\n\trpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev);\n\n\terr = rpmsg_ctrldev_register_device(rpdev_ctrl);\n\tif (err) {\n\t\t\/* vch will be free in virtio_rpmsg_release_device() *\/\n\t\treturn ERR_PTR(err);\n\t}\n\n\treturn rpdev_ctrl;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":301430,"func":"static const char *vfswrap_connectpath(struct vfs_handle_struct *handle,\n\t\t\t\t       const char *fname)\n{\n\treturn handle->conn->connectpath;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":226215,"func":"GF_Err nump_box_size(GF_Box *s)\n{\n\ts->size += 8;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":366192,"func":"int count_mounts(struct mnt_namespace *ns, struct mount *mnt)\n{\n\tunsigned int max = READ_ONCE(sysctl_mount_max);\n\tunsigned int mounts = 0, old, pending, sum;\n\tstruct mount *p;\n\n\tfor (p = mnt; p; p = next_mnt(p, mnt))\n\t\tmounts++;\n\n\told = ns->mounts;\n\tpending = ns->pending_mounts;\n\tsum = old + pending;\n\tif ((old > sum) ||\n\t    (pending > sum) ||\n\t    (max < sum) ||\n\t    (mounts > (max - sum)))\n\t\treturn -ENOSPC;\n\n\tns->pending_mounts = pending + mounts;\n\treturn 0;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":253620,"func":"static inline void smb2_sg_set_buf(struct scatterlist *sg, const void *buf,\n\t\t\t\t   unsigned int buflen)\n{\n\tvoid *addr;\n\t\/*\n\t * VMAP_STACK (at least) puts stack into the vmalloc address space\n\t *\/\n\tif (is_vmalloc_addr(buf))\n\t\taddr = vmalloc_to_page(buf);\n\telse\n\t\taddr = virt_to_page(buf);\n\tsg_set_page(sg, addr, buflen, offset_in_page(buf));\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":365760,"func":"static void sixpack_close(struct tty_struct *tty)\n{\n\tstruct sixpack *sp;\n\n\twrite_lock_irq(&disc_data_lock);\n\tsp = tty->disc_data;\n\ttty->disc_data = NULL;\n\twrite_unlock_irq(&disc_data_lock);\n\tif (!sp)\n\t\treturn;\n\n\t\/*\n\t * We have now ensured that nobody can start using ap from now on, but\n\t * we have to wait for all existing users to finish.\n\t *\/\n\tif (!refcount_dec_and_test(&sp->refcnt))\n\t\twait_for_completion(&sp->dead);\n\n\t\/* We must stop the queue to avoid potentially scribbling\n\t * on the free buffers. The sp->dead completion is not sufficient\n\t * to protect us from sp->xbuff access.\n\t *\/\n\tnetif_stop_queue(sp->dev);\n\n\tunregister_netdev(sp->dev);\n\n\tdel_timer_sync(&sp->tx_t);\n\tdel_timer_sync(&sp->resync_t);\n\n\t\/* Free all 6pack frame buffers after unreg. *\/\n\tkfree(sp->rbuff);\n\tkfree(sp->xbuff);\n\n\tfree_netdev(sp->dev);\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":366315,"func":"void mnt_release_group_id(struct mount *mnt)\n{\n\tida_free(&mnt_group_ida, mnt->mnt_group_id);\n\tmnt->mnt_group_id = 0;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":317067,"func":"static int smk_ipv4_check(struct sock *sk, struct sockaddr_in *sap)\n{\n\tstruct smack_known *skp;\n\tint rc = 0;\n\tstruct smack_known *hkp;\n\tstruct socket_smack *ssp = sk->sk_security;\n\tstruct smk_audit_info ad;\n\n\trcu_read_lock();\n\thkp = smack_ipv4host_label(sap);\n\tif (hkp != NULL) {\n#ifdef CONFIG_AUDIT\n\t\tstruct lsm_network_audit net;\n\n\t\tsmk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);\n\t\tad.a.u.net->family = sap->sin_family;\n\t\tad.a.u.net->dport = sap->sin_port;\n\t\tad.a.u.net->v4info.daddr = sap->sin_addr.s_addr;\n#endif\n\t\tskp = ssp->smk_out;\n\t\trc = smk_access(skp, hkp, MAY_WRITE, &ad);\n\t\trc = smk_bu_note(\"IPv4 host check\", skp, hkp, MAY_WRITE, rc);\n\t\t\/*\n\t\t * Clear the socket netlabel if it's set.\n\t\t *\/\n\t\tif (!rc)\n\t\t\tsmack_netlbl_delete(sk);\n\t}\n\trcu_read_unlock();\n\n\treturn rc;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":366294,"func":"void kern_unmount_array(struct vfsmount *mnt[], unsigned int num)\n{\n\tunsigned int i;\n\n\tfor (i = 0; i < num; i++)\n\t\tif (mnt[i])\n\t\t\treal_mount(mnt[i])->mnt_ns = NULL;\n\tsynchronize_rcu_expedited();\n\tfor (i = 0; i < num; i++)\n\t\tmntput(mnt[i]);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":312483,"func":"qf_goto_cwindow(qf_info_T *qi, int resize, int sz, int vertsplit)\n{\n    win_T\t*win;\n\n    win = qf_find_win(qi);\n    if (win == NULL)\n\treturn FAIL;\n\n    win_goto(win);\n    if (resize)\n    {\n\tif (vertsplit)\n\t{\n\t    if (sz != win->w_width)\n\t\twin_setwidth(sz);\n\t}\n\telse if (sz != win->w_height && win->w_height\n\t\t       + win->w_status_height + tabline_height() < cmdline_row)\n\t    win_setheight(sz);\n    }\n\n    return OK;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":498110,"func":"const char *cgit_rooturl(void)\n{\n\tif (ctx.cfg.virtual_root)\n\t\treturn ctx.cfg.virtual_root;\n\telse\n\t\treturn ctx.cfg.script_name;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":236182,"func":"GF_Err krok_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_TextKaraokeBox*ptr = (GF_TextKaraokeBox*)s;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->highlight_starttime);\n\tgf_bs_write_u16(bs, ptr->nb_entries);\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tgf_bs_write_u32(bs, ptr->records[i].highlight_endtime);\n\t\tgf_bs_write_u16(bs, ptr->records[i].start_charoffset);\n\t\tgf_bs_write_u16(bs, ptr->records[i].end_charoffset);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":221422,"func":"void nested_sync_control_from_vmcb02(struct vcpu_svm *svm)\n{\n\tu32 mask;\n\tsvm->nested.ctl.event_inj      = svm->vmcb->control.event_inj;\n\tsvm->nested.ctl.event_inj_err  = svm->vmcb->control.event_inj_err;\n\n\t\/* Only a few fields of int_ctl are written by the processor.  *\/\n\tmask = V_IRQ_MASK | V_TPR_MASK;\n\tif (!(svm->nested.ctl.int_ctl & V_INTR_MASKING_MASK) &&\n\t    svm_is_intercept(svm, INTERCEPT_VINTR)) {\n\t\t\/*\n\t\t * In order to request an interrupt window, L0 is usurping\n\t\t * svm->vmcb->control.int_ctl and possibly setting V_IRQ\n\t\t * even if it was clear in L1's VMCB.  Restoring it would be\n\t\t * wrong.  However, in this case V_IRQ will remain true until\n\t\t * interrupt_window_interception calls svm_clear_vintr and\n\t\t * restores int_ctl.  We can just leave it aside.\n\t\t *\/\n\t\tmask &= ~V_IRQ_MASK;\n\t}\n\tsvm->nested.ctl.int_ctl        &= ~mask;\n\tsvm->nested.ctl.int_ctl        |= svm->vmcb->control.int_ctl & mask;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":226119,"func":"GF_Err minf_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":225094,"func":"void FillAttrMap(const OpDef& op_def, AttrMap* attr_map) {\n  for (const auto& attr : op_def.attr()) {\n    (*attr_map)[attr.name()] = &attr;\n  }\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":459513,"func":"get_callchain_entry_for_task(struct task_struct *task, u32 init_nr)\n{\n#ifdef CONFIG_STACKTRACE\n\tstruct perf_callchain_entry *entry;\n\tint rctx;\n\n\tentry = get_callchain_entry(&rctx);\n\n\tif (!entry)\n\t\treturn NULL;\n\n\tentry->nr = init_nr +\n\t\tstack_trace_save_tsk(task, (unsigned long *)(entry->ip + init_nr),\n\t\t\t\t     sysctl_perf_event_max_stack - init_nr, 0);\n\n\t\/* stack_trace_save_tsk() works on unsigned long array, while\n\t * perf_callchain_entry uses u64 array. For 32-bit systems, it is\n\t * necessary to fix this mismatch.\n\t *\/\n\tif (__BITS_PER_LONG != 64) {\n\t\tunsigned long *from = (unsigned long *) entry->ip;\n\t\tu64 *to = entry->ip;\n\t\tint i;\n\n\t\t\/* copy data from the end to avoid using extra buffer *\/\n\t\tfor (i = entry->nr - 1; i >= (int)init_nr; i--)\n\t\t\tto[i] = (u64)(from[i]);\n\t}\n\n\tput_callchain_entry(rctx);\n\n\treturn entry;\n#else \/* CONFIG_STACKTRACE *\/\n\treturn NULL;\n#endif\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":247757,"func":"bool InvertibleRWFunction::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const\n{\n\treturn GetValueHelper<RWFunction>(this, name, valueType, pValue).Assignable()\n\t\tCRYPTOPP_GET_FUNCTION_ENTRY(Prime1)\n\t\tCRYPTOPP_GET_FUNCTION_ENTRY(Prime2)\n\t\tCRYPTOPP_GET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)\n\t\t;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":421387,"func":"static void sblock(int d, js_Ast *list)\n{\n\tps(\"[\\n\");\n\tin(d+1);\n\twhile (list) {\n\t\tassert(list->type == AST_LIST);\n\t\tsnode(d+1, list->a);\n\t\tlist = list->b;\n\t\tif (list) {\n\t\t\tnl();\n\t\t\tin(d+1);\n\t\t}\n\t}\n\tnl(); in(d); pc(']');\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":252403,"func":"static void swap8(tinyexr::tinyexr_uint64 *val) {\n#ifdef MINIZ_LITTLE_ENDIAN\n  (void)val;\n#else\n  tinyexr::tinyexr_uint64 tmp = (*val);\n  unsigned char *dst = reinterpret_cast<unsigned char *>(val);\n  unsigned char *src = reinterpret_cast<unsigned char *>(&tmp);\n\n  dst[0] = src[7];\n  dst[1] = src[6];\n  dst[2] = src[5];\n  dst[3] = src[4];\n  dst[4] = src[3];\n  dst[5] = src[2];\n  dst[6] = src[1];\n  dst[7] = src[0];\n#endif\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":439073,"func":"ModuleExport size_t RegisterFLIFImage(void)\n{\n  char\n    version[MaxTextExtent];\n\n  MagickInfo\n    *entry;\n\n  *version='\\0';\n  entry=SetMagickInfo(\"FLIF\");\n#if defined(MAGICKCORE_FLIF_DELEGATE)\n  entry->decoder=(DecodeImageHandler *) ReadFLIFImage;\n  entry->encoder=(EncodeImageHandler *) WriteFLIFImage;\n  (void) FormatLocaleString(version,MaxTextExtent,\"libflif %d.%d.%d [%04X]\",\n    (FLIF_VERSION >> 16) & 0xff,\n    (FLIF_VERSION  >> 8) & 0xff,\n    (FLIF_VERSION  >> 0) & 0xff,FLIF_ABI_VERSION);\n#endif\n  entry->description=ConstantString(\"Free Lossless Image Format\");\n  entry->adjoin=MagickTrue;\n  entry->module=ConstantString(\"FLIF\");\n  entry->mime_type=ConstantString(\"image\/flif\");\n  entry->magick=(IsImageFormatHandler *) IsFLIF;\n  if (*version != '\\0')\n    entry->version=ConstantString(version);\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":220186,"func":"void Graph::ReleaseNode(Node* node) {\n  TF_DCHECK_OK(IsValidNode(node)) << node->DebugString();\n  nodes_[node->id()] = nullptr;\n  free_nodes_.push_back(node);\n  --num_nodes_;\n  node->Clear();\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":225438,"func":"static void free_buffers(struct v4l2_loopback_device *dev)\n{\n\tMARK();\n\tdprintk(\"freeing image@%p for dev:%p\\n\", dev ? dev->image : NULL, dev);\n\tif (dev->image) {\n\t\tvfree(dev->image);\n\t\tdev->image = NULL;\n\t}\n\tif (dev->timeout_image) {\n\t\tvfree(dev->timeout_image);\n\t\tdev->timeout_image = NULL;\n\t}\n\tdev->imagesize = 0;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":278274,"func":"tabstop_first(int *ts)\n{\n    return ts != NULL ? ts[1] : 8;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":294366,"func":"tmx_m_secs(union DateData *x)\n{\n    VALUE s;\n    int df;\n\n    s = day_to_sec(f_sub(m_real_jd(x),\n\t\t\t UNIX_EPOCH_IN_CJD));\n    if (simple_dat_p(x))\n\treturn s;\n    df = m_df(x);\n    if (df)\n\ts = f_add(s, INT2FIX(df));\n    return s;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":413651,"func":"R_API RList *r_core_anal_fcn_get_calls(RCore *core, RAnalFunction *fcn) {\n\tRAnalRef *refi;\n\tRListIter *iter, *iter2;\n\n\t\/\/ get all references from this function\n\tRList *refs = r_anal_function_get_refs (fcn);\n\t\/\/ sanity check\n\tif (!r_list_empty (refs)) {\n\t\t\/\/ iterate over all the references and remove these which aren't of type call\n\t\tr_list_foreach_safe (refs, iter, iter2, refi) {\n\t\t\tif (refi->type != R_ANAL_REF_TYPE_CALL) {\n\t\t\t\tr_list_delete (refs, iter);\n\t\t\t}\n\t\t}\n\t}\n\treturn refs;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":346429,"func":"ex_finish(exarg_T *eap)\n{\n    if (sourcing_a_script(eap))\n\tdo_finish(eap, FALSE);\n    else\n\temsg(_(e_finish_used_outside_of_sourced_file));\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":512308,"func":"void Item_func_like::cleanup()\n{\n  canDoTurboBM= FALSE;\n  Item_bool_func2::cleanup();\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":398488,"func":"static inline ut64 dwarf_read_offset(bool is_64bit, bool big_endian, const ut8 **buf, const ut8 *buf_end) {\n\tut64 result;\n\tif (is_64bit) {\n\t\tresult = READ64(*buf);\n\t} else {\n\t\tresult = READ32(*buf);\n\t}\n\treturn result;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":267978,"func":"static bool __isDataSection(RBinFile *a, RBinSection *s) {\n\tif (s->has_strings || s->is_data) {\n\t\treturn true;\n\t}\n \t\/\/ Rust\n\treturn strstr (s->name, \"_const\");\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":344254,"func":"static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {\n  \/* calling function is a known function? *\/\n  if (ci != NULL && !(ci->callstatus & CIST_TAIL))\n    return funcnamefromcall(L, ci->previous, name);\n  else return NULL;  \/* no way to find a name *\/\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":430351,"func":"int seq_release_private(struct inode *inode, struct file *file)\n{\n\tstruct seq_file *seq = file->private_data;\n\n\tkfree(seq->private);\n\tseq->private = NULL;\n\treturn seq_release(inode, file);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":223460,"func":"static void detect_partial_match_to(compiler_common *common, struct sljit_label *label)\n{\nDEFINE_COMPILER;\n\nCMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, label);\nprocess_partial_match(common);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":343234,"func":"void usleep2(const unsigned long microsec)\n{\n    disablesignals();\n    usleep(microsec);\n    enablesignals();\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":276962,"func":"OpenOutput(const char* filename_pattern, unsigned int segment_number)\n{\n    AP4_ByteStream* output = NULL;\n    char filename[4096];\n    sprintf(filename, filename_pattern, segment_number);\n    AP4_Result result = AP4_FileByteStream::Create(filename, AP4_FileByteStream::STREAM_MODE_WRITE, output);\n    if (AP4_FAILED(result)) {\n        fprintf(stderr, \"ERROR: cannot open output (%d)\\n\", result);\n        return NULL;\n    }\n    \n    return output;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":225451,"func":"string GeneratedNameForIdentityConsumingSwitch(\n    const MutableGraphView::OutputPort& fanin) {\n  return AddPrefixToNodeName(\n      absl::StrCat(fanin.node->name(), \"_\", fanin.port_id),\n      kMutableGraphViewCtrl);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":241365,"func":"  int64 GetCostPerUnit(const TensorShapes& input_matrix_shapes) const final {\n    double rows = static_cast<double>(input_matrix_shapes[0].dim_size(0));\n    double num_rhss = static_cast<double>(input_matrix_shapes[1].dim_size(1));\n    double cost = rows * rows * (rows + num_rhss);\n    return cost >= static_cast<double>(kint64max) ? kint64max\n                                                  : static_cast<int64>(cost);\n  }","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":226440,"func":"  std::unique_ptr<IteratorBase> MakeIteratorInternal(\n      const string& prefix) const override {\n    return absl::make_unique<Iterator>(typename Iterator::Params{\n        this, strings::StrCat(prefix, \"::SparseTensorSlice\")});\n  }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":343125,"func":"static void esp_output_done_esn(struct crypto_async_request *base, int err)\n{\n\tstruct sk_buff *skb = base->data;\n\n\tesp_output_restore_header(skb);\n\tesp_output_done(base, err);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":263514,"func":"static int sco_sock_shutdown(struct socket *sock, int how)\n{\n\tstruct sock *sk = sock->sk;\n\tint err = 0;\n\n\tBT_DBG(\"sock %p, sk %p\", sock, sk);\n\n\tif (!sk)\n\t\treturn 0;\n\n\tsock_hold(sk);\n\tlock_sock(sk);\n\n\tif (!sk->sk_shutdown) {\n\t\tsk->sk_shutdown = SHUTDOWN_MASK;\n\t\tsco_sock_clear_timer(sk);\n\t\t__sco_sock_close(sk);\n\n\t\tif (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&\n\t\t    !(current->flags & PF_EXITING))\n\t\t\terr = bt_sock_wait_state(sk, BT_CLOSED,\n\t\t\t\t\t\t sk->sk_lingertime);\n\t}\n\n\trelease_sock(sk);\n\tsock_put(sk);\n\n\treturn err;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":234169,"func":"display_block (unsigned char *data,\n\t       dwarf_vma length,\n\t       const unsigned char * const end, char delimiter)\n{\n  dwarf_vma maxlen;\n\n  printf (_(\"%c%s byte block: \"), delimiter, dwarf_vmatoa (\"u\", length));\n  if (data > end)\n    return (unsigned char *) end;\n\n  maxlen = (dwarf_vma) (end - data);\n  length = length > maxlen ? maxlen : length;\n\n  while (length --)\n    printf (\"%lx \", (unsigned long) byte_get (data++, 1));\n\n  return data;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":256158,"func":"ALWAYS_INLINE void LoadSingleScalar(const bfloat16** data, Packet* l) {\n  auto tmp = ConvertBfloat16ToFloat(*data);\n  *l = Eigen::internal::pset1<Packet>(tmp);\n  ++*data;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":432289,"func":"static bool memory_region_big_endian(MemoryRegion *mr)\n{\n#ifdef TARGET_WORDS_BIGENDIAN\n    return mr->ops->endianness != DEVICE_LITTLE_ENDIAN;\n#else\n    return mr->ops->endianness == DEVICE_BIG_ENDIAN;\n#endif\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":463162,"func":"EXPORTED void appendattvalue(struct attvaluelist **l,\n                    const char *attrib,\n                    const struct buf *value)\n{\n    struct attvaluelist **tail = l;\n\n    while (*tail) tail = &(*tail)->next;\n\n    *tail = xzmalloc(sizeof(struct attvaluelist));\n    (*tail)->attrib = xstrdup(attrib);\n    buf_copy(&(*tail)->value, value);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":359611,"func":"DEFUN (no_neighbor_interface,\n       no_neighbor_interface_cmd,\n       NO_NEIGHBOR_CMD \"interface WORD\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR\n       \"Interface\\n\"\n       \"Interface name\\n\")\n{\n  return peer_interface_vty (vty, argv[0], NULL);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":384118,"func":"raptor_xml_writer_nsd_compare(const void *a, const void *b)\n{\n  struct nsd* nsd_a = (struct nsd*)a;\n  struct nsd* nsd_b = (struct nsd*)b;\n  return strcmp((const char*)nsd_a->declaration, (const char*)nsd_b->declaration);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":450370,"func":"int vnc_tight_send_framebuffer_update(VncState *vs, int x, int y,\n                                      int w, int h)\n{\n    vs->tight->type = VNC_ENCODING_TIGHT;\n    return tight_send_framebuffer_update(vs, x, y, w, h);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":226063,"func":"void stsd_box_del(GF_Box *s)\n{\n\tGF_SampleDescriptionBox *ptr = (GF_SampleDescriptionBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":402621,"func":"daemon_logger(cms_context *cms, int priority, char *fmt, ...)\n{\n\tcontext *ctx = (context *)cms->log_priv;\n\tva_list ap;\n\tint rc = 0;\n\n\tif (ctx->errstr)\n\t\txfree(ctx->errstr);\n\n\tva_start(ap, fmt);\n\tif (priority & LOG_ERR) {\n\t\tva_list aq;\n\n\t\tva_copy(aq, ap);\n\t\trc = vasprintf(&ctx->errstr, fmt, aq);\n\t\tva_end(aq);\n\t}\n\n\tvsyslog(ctx->priority | priority, fmt, ap);\n\tva_end(ap);\n\treturn rc;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":384208,"func":"static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx,\n\t\t\t\t\t     int msg_type, u32 size, gfp_t gfp)\n{\n\tstruct nft_trans *trans;\n\n\ttrans = kzalloc(sizeof(struct nft_trans) + size, gfp);\n\tif (trans == NULL)\n\t\treturn NULL;\n\n\tINIT_LIST_HEAD(&trans->list);\n\ttrans->msg_type = msg_type;\n\ttrans->ctx\t= *ctx;\n\n\treturn trans;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":338152,"func":"bool WasmBinaryBuilder::maybeVisitArrayCopy(Expression*& out, uint32_t code) {\n  if (code != BinaryConsts::ArrayCopy) {\n    return false;\n  }\n  auto destHeapType = getIndexedHeapType();\n  auto srcHeapType = getIndexedHeapType();\n  auto* length = popNonVoidExpression();\n  auto* srcIndex = popNonVoidExpression();\n  auto* srcRef = popNonVoidExpression();\n  auto* destIndex = popNonVoidExpression();\n  auto* destRef = popNonVoidExpression();\n  validateHeapTypeUsingChild(destRef, destHeapType);\n  validateHeapTypeUsingChild(srcRef, srcHeapType);\n  out =\n    Builder(wasm).makeArrayCopy(destRef, destIndex, srcRef, srcIndex, length);\n  return true;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":226389,"func":"\nGF_Err dvvC_box_size(GF_Box *s)\n{\n\treturn dvcC_box_size(s);","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":245203,"func":"bool format_time(time_t time, char *dest, size_t max_size)\n{\n\ttm tm;\n\tlocaltime_r(&time, &tm);\n\treturn strftime(dest, max_size,\n\t\t \"%Y-%m-%d %H:%M:%S\", &tm) != 0;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":462437,"func":"destroyIoQ(void)\n{\n\tio_req_t *n;\n\tif (io_q.stats != NULL) {\n\t\tstatsobj.Destruct(&io_q.stats);\n\t}\n\tpthread_mutex_lock(&io_q.mut);\n\twhile (!STAILQ_EMPTY(&io_q.q)) {\n\t\tn = STAILQ_FIRST(&io_q.q);\n\t\tSTAILQ_REMOVE_HEAD(&io_q.q, link);\n\t\terrmsg.LogError(0, RS_RET_INTERNAL_ERROR, \"imptcp: discarded enqueued io-work to allow shutdown - ignored\");\n\t\tfree(n);\n\t}\n\tio_q.sz = 0;\n\tpthread_mutex_unlock(&io_q.mut);\n\tpthread_cond_destroy(&io_q.wakeup_worker);\n\tpthread_mutex_destroy(&io_q.mut);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":361757,"func":"static int em28xx_usb_suspend(struct usb_interface *intf,\n\t\t\t      pm_message_t message)\n{\n\tstruct em28xx *dev;\n\n\tdev = usb_get_intfdata(intf);\n\tif (!dev)\n\t\treturn 0;\n\tem28xx_suspend_extension(dev);\n\treturn 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":400746,"func":"const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags)\n{\n\t*new = *old;\n\tif (unlikely(iov_iter_is_pipe(new))) {\n\t\tWARN_ON(1);\n\t\treturn NULL;\n\t}\n\tif (unlikely(iov_iter_is_discard(new) || iov_iter_is_xarray(new)))\n\t\treturn NULL;\n\tif (iov_iter_is_bvec(new))\n\t\treturn new->bvec = kmemdup(new->bvec,\n\t\t\t\t    new->nr_segs * sizeof(struct bio_vec),\n\t\t\t\t    flags);\n\telse\n\t\t\/* iovec and kvec have identical layout *\/\n\t\treturn new->iov = kmemdup(new->iov,\n\t\t\t\t   new->nr_segs * sizeof(struct iovec),\n\t\t\t\t   flags);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":503988,"func":"t_auth_request_var_expand(const char *str,\n\t\t\t  const struct auth_request *auth_request,\n\t\t\t  auth_request_escape_func_t *escape_func)\n{\n\tstring_t *dest = t_str_new(128);\n\tauth_request_var_expand(dest, str, auth_request, escape_func);\n\treturn str_c(dest);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":476144,"func":"int usb_composite_probe(struct usb_composite_driver *driver)\n{\n\tstruct usb_gadget_driver *gadget_driver;\n\n\tif (!driver || !driver->dev || !driver->bind)\n\t\treturn -EINVAL;\n\n\tif (!driver->name)\n\t\tdriver->name = \"composite\";\n\n\tdriver->gadget_driver = composite_driver_template;\n\tgadget_driver = &driver->gadget_driver;\n\n\tgadget_driver->function =  (char *) driver->name;\n\tgadget_driver->driver.name = driver->name;\n\tgadget_driver->max_speed = driver->max_speed;\n\n\treturn usb_gadget_probe_driver(gadget_driver);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":240303,"func":"dnd_yank_drag_data(char_u *str, long len)\n{\n    yankreg_T *curr;\n\n    curr = y_current;\n    y_current = &y_regs[TILDE_REGISTER];\n    free_yank_all();\n    str_to_reg(y_current, MCHAR, str, len, 0L, FALSE);\n    y_current = curr;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":220434,"func":"ary_fill_with_nil(mrb_value *ptr, mrb_int size)\n{\n  mrb_value nil = mrb_nil_value();\n\n  while (size--) {\n    *ptr++ = nil;\n  }\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":486825,"func":"static inline void rx_desc_set_ownership(uint32_t *desc)\n{\n    desc[0] |= DESC_0_RX_OWNERSHIP;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":274722,"func":"callbacks_begin_print (GtkPrintOperation *operation, GtkPrintContext   *context,\n\t\tgpointer user_data) {\n\tgtk_print_operation_set_n_pages     (operation, 1);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":437702,"func":"inline int cx23888_ir_write4(struct cx23885_dev *dev, u32 addr, u32 value)\n{\n\tcx_write(addr, value);\n\treturn 0;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":487638,"func":"int blocking_notifier_call_chain(struct blocking_notifier_head *nh,\n\t\tunsigned long val, void *v)\n{\n\tint ret = NOTIFY_DONE;\n\n\t\/*\n\t * We check the head outside the lock, but if this access is\n\t * racy then it does not matter what the result of the test\n\t * is, we re-check the list after having taken the lock anyway:\n\t *\/\n\tif (rcu_dereference(nh->head)) {\n\t\tdown_read(&nh->rwsem);\n\t\tret = notifier_call_chain(&nh->head, val, v);\n\t\tup_read(&nh->rwsem);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":508846,"func":"st_select_lex_node *st_select_lex_node:: insert_chain_before(\n\t\t\t\t         st_select_lex_node **ptr_pos_to_insert,\n                                         st_select_lex_node *end_chain_node)\n{\n  end_chain_node->link_next= *ptr_pos_to_insert;\n  (*ptr_pos_to_insert)->link_prev= &end_chain_node->link_next;\n  this->link_prev= ptr_pos_to_insert;\n  return this;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":244339,"func":"void trgt_box_del(GF_Box *s)\n{\n\tGF_TrackGroupTypeBox *ptr = (GF_TrackGroupTypeBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":233831,"func":"void fmtutil_generate_bmpfileheader(deark *c, dbuf *outf, const struct de_bmpinfo *bi,\n\ti64 file_size_override)\n{\n\ti64 file_size_to_write;\n\n\tdbuf_write(outf, (const u8*)\"BM\", 2);\n\n\tif(file_size_override)\n\t\tfile_size_to_write = file_size_override;\n\telse\n\t\tfile_size_to_write = 14 + bi->total_size;\n\tdbuf_writeu32le(outf, file_size_to_write);\n\n\tdbuf_write_zeroes(outf, 4);\n\tdbuf_writeu32le(outf, 14 + bi->size_of_headers_and_pal);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":348438,"func":"static int ax_open_dev(struct net_device *dev)\n{\n\tstruct mkiss *ax = netdev_priv(dev);\n\n\tif (ax->tty == NULL)\n\t\treturn -ENODEV;\n\n\treturn 0;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":337807,"func":"struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc,\n\t\t\t\t      const struct sctp_chunk *chunk)\n{\n\tstruct sctp_shutdownhdr shut;\n\tstruct sctp_chunk *retval;\n\t__u32 ctsn;\n\n\tctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);\n\tshut.cum_tsn_ack = htonl(ctsn);\n\n\tretval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN, 0,\n\t\t\t\t   sizeof(shut), GFP_ATOMIC);\n\tif (!retval)\n\t\tgoto nodata;\n\n\tretval->subh.shutdown_hdr =\n\t\tsctp_addto_chunk(retval, sizeof(shut), &shut);\n\n\tif (chunk)\n\t\tretval->transport = chunk->transport;\nnodata:\n\treturn retval;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":512727,"func":"  double val_real() { return cached_time.to_double(); }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":264707,"func":"void AddShapeNodeToConstantGraph(\n    Node* n,\n    const std::unordered_map<const Node*, std::vector<Tensor>>&\n        shape_replacement_map,\n    std::unordered_map<Node*, std::vector<Node*>>* node_map,\n    const ConstantFoldNameGenerator& generate_new_name, Graph* constant_graph) {\n  std::vector<Node*>& added = (*node_map)[n];\n  const string& node_name = n->name();\n  for (const Tensor& t : shape_replacement_map.at(n)) {\n    auto builder =\n        NodeDefBuilder(generate_new_name(constant_graph, node_name), \"Const\")\n            .Attr(\"dtype\", t.dtype())\n            .Attr(\"value\", t);\n    NodeDef def;\n    CHECK(builder.Finalize(&def).ok());\n    Node* constant_node;\n    CHECK(NodeBuilder(builder).Finalize(constant_graph, &constant_node).ok());\n    added.push_back(constant_node);\n  }\n  \/\/ Don't copy incoming edges to shape nodes that are being replaced.\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":317026,"func":"static int selinux_shm_shmctl(struct kern_ipc_perm *shp, int cmd)\n{\n\tint perms;\n\tint err;\n\n\tswitch (cmd) {\n\tcase IPC_INFO:\n\tcase SHM_INFO:\n\t\t\/* No specific object, just general system-wide information. *\/\n\t\treturn avc_has_perm(&selinux_state,\n\t\t\t\t    current_sid(), SECINITSID_KERNEL,\n\t\t\t\t    SECCLASS_SYSTEM, SYSTEM__IPC_INFO, NULL);\n\tcase IPC_STAT:\n\tcase SHM_STAT:\n\tcase SHM_STAT_ANY:\n\t\tperms = SHM__GETATTR | SHM__ASSOCIATE;\n\t\tbreak;\n\tcase IPC_SET:\n\t\tperms = SHM__SETATTR;\n\t\tbreak;\n\tcase SHM_LOCK:\n\tcase SHM_UNLOCK:\n\t\tperms = SHM__LOCK;\n\t\tbreak;\n\tcase IPC_RMID:\n\t\tperms = SHM__DESTROY;\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\terr = ipc_has_perm(shp, perms);\n\treturn err;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":226268,"func":"\nGF_Err svhd_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_SphericalVideoInfoBox *ptr = (GF_SphericalVideoInfoBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tif (ptr->string)\n\t\tgf_bs_write_data(bs, ptr->string, (u32) strlen(ptr->string));\n\tgf_bs_write_u8(bs, 0);\n\treturn GF_OK;","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":247652,"func":"  TestUtilOptions& enableOcspStapling() {\n    ocsp_stapling_enabled_ = true;\n    return *this;\n  }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":206845,"func":"static unsigned long get_ctl_id_hash(const struct snd_ctl_elem_id *id)\n{\n\tint i;\n\tunsigned long h;\n\n\th = id->iface;\n\th = MULTIPLIER * h + id->device;\n\th = MULTIPLIER * h + id->subdevice;\n\tfor (i = 0; id->name[i] && i < SNDRV_CTL_ELEM_ID_NAME_MAXLEN; i++)\n\t\th = MULTIPLIER * h + id->name[i];\n\th = MULTIPLIER * h + id->index;\n\th &= LONG_MAX;\n\treturn h;\n}","target":1,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":355014,"func":"static void parse_rtcp_bye(pjmedia_rtcp_session *sess,\n\t\t\t   const void *pkt,\n\t\t\t   pj_size_t size)\n{\n    pj_str_t reason = {\"-\", 1};\n\n    \/* Check and get BYE reason *\/\n    if (size > 8) {\n    \t\/* Make sure the BYE reason does not exceed:\n    \t * - the size of the available buffer\n    \t * - the declared reason's length\n    \t * - the actual packet size\n    \t *\/\n\treason.slen = PJ_MIN(sizeof(sess->stat.peer_sdes_buf_),\n                             *((pj_uint8_t*)pkt+8));\n        reason.slen = PJ_MIN(reason.slen, size-9);\n\n\tpj_memcpy(sess->stat.peer_sdes_buf_, ((pj_uint8_t*)pkt+9),\n\t\t  reason.slen);\n\treason.ptr = sess->stat.peer_sdes_buf_;\n    }\n\n    \/* Just print RTCP BYE log *\/\n    PJ_LOG(5, (sess->name, \"Received RTCP BYE, reason: %.*s\",\n\t       reason.slen, reason.ptr));\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":261224,"func":"int MqttClient_Ping(MqttClient *client)\n{\n    MqttPing ping;\n    XMEMSET(&ping, 0, sizeof(ping));\n    return MqttClient_Ping_ex(client, &ping);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":338203,"func":"Name WasmBinaryBuilder::getTableName(Index index) {\n  if (index >= wasm.tables.size()) {\n    throwError(\"invalid table index\");\n  }\n  return wasm.tables[index]->name;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":232404,"func":"  Status AsGraphDefInternal(SerializationContext* ctx,\n                            DatasetGraphDefBuilder* b,\n                            Node** output) const override {\n    Node* indices_node;\n    TF_RETURN_IF_ERROR(b->AddTensor(sparse_tensor_.indices(), &indices_node));\n    Node* value_node;\n    TF_RETURN_IF_ERROR(b->AddTensor(sparse_tensor_.values(), &value_node));\n    Node* dense_shape_node;\n    std::vector<int64> dense_shape;\n    dense_shape.reserve(sparse_tensor_.shape().size());\n    for (int i = 0; i < sparse_tensor_.shape().size(); i++)\n      dense_shape.emplace_back(sparse_tensor_.shape()[i]);\n    TF_RETURN_IF_ERROR(b->AddVector(dense_shape, &dense_shape_node));\n    AttrValue val_dtype;\n    b->BuildAttrValue(sparse_tensor_.dtype(), &val_dtype);\n    TF_RETURN_IF_ERROR(\n        b->AddDataset(this, {indices_node, value_node, dense_shape_node},\n                      {{\"Tvalues\", val_dtype}}, output));\n    return Status::OK();\n  }","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":201343,"func":"static int selinux_ptrace_traceme(struct task_struct *parent)\n{\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    task_sid_subj(parent), task_sid_obj(current),\n\t\t\t    SECCLASS_PROCESS, PROCESS__PTRACE, NULL);\n}","target":1,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":314746,"func":"cdf_dump_sat(const char *prefix, const cdf_sat_t *sat, size_t size)\n{\n\tsize_t i, j, s = size \/ sizeof(cdf_secid_t);\n\n\tfor (i = 0; i < sat->sat_len; i++) {\n\t\t(void)fprintf(stderr, \"%s[%\" SIZE_T_FORMAT \"u]:\\n%.6\"\n\t\t    SIZE_T_FORMAT \"u: \", prefix, i, i * s);\n\t\tfor (j = 0; j < s; j++) {\n\t\t\t(void)fprintf(stderr, \"%5d, \",\n\t\t\t    CDF_TOLE4(sat->sat_tab[s * i + j]));\n\t\t\tif ((j + 1) % 10 == 0)\n\t\t\t\t(void)fprintf(stderr, \"\\n%.6\" SIZE_T_FORMAT\n\t\t\t\t    \"u: \", i * s + j + 1);\n\t\t}\n\t\t(void)fprintf(stderr, \"\\n\");\n\t}\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":333050,"func":"nfa_get_match_text(nfa_state_T *start)\n{\n    nfa_state_T *p = start;\n    int\t\tlen = 0;\n    char_u\t*ret;\n    char_u\t*s;\n\n    if (p->c != NFA_MOPEN)\n\treturn NULL; \/\/ just in case\n    p = p->out;\n    while (p->c > 0)\n    {\n\tlen += MB_CHAR2LEN(p->c);\n\tp = p->out;\n    }\n    if (p->c != NFA_MCLOSE || p->out->c != NFA_MATCH)\n\treturn NULL;\n\n    ret = alloc(len);\n    if (ret != NULL)\n    {\n\tp = start->out->out; \/\/ skip first char, it goes into regstart\n\ts = ret;\n\twhile (p->c > 0)\n\t{\n\t    if (has_mbyte)\n\t\ts += (*mb_char2bytes)(p->c, s);\n\t    else\n\t\t*s++ = p->c;\n\t    p = p->out;\n\t}\n\t*s = NUL;\n    }\n    return ret;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":96950,"func":"bool decode(ArgumentDecoder* decoder, RetainPtr<SecKeychainItemRef>& result)\n{\n    RetainPtr<CFDataRef> data;\n    if (!CoreIPC::decode(decoder, data))\n        return false;\n\n    SecKeychainItemRef item;\n    if (SecKeychainItemCopyFromPersistentReference(data.get(), &item) != errSecSuccess || !item)\n        return false;\n    \n    result.adoptCF(item);\n    return true;\n}\n","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":359502,"func":"hex_append(char *s, int len, u_long x)\n{\n  char buf[30];\n  char *t;\n\n  if (!x)\n    return str_append(s,len,\"0\");\n  *(t = &buf[sizeof(buf)-1]) = '\\0';\n  while (x && (t > buf))\n    {\n      u_int cc = (x % 16);\n      *--t = ((cc < 10) ? ('0'+cc) : ('a'+cc-10));\n      x \/= 16;\n    }\n  return str_append(s,len,t);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":244356,"func":"GF_Err tref_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\/\/\tGF_TrackReferenceBox *ptr = (GF_TrackReferenceBox *)s;\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":261916,"func":"njs_string_decode_utf8(njs_vm_t *vm, njs_value_t *value, const njs_str_t *src)\n{\n    size_t     length;\n    njs_str_t  dst;\n\n    length = njs_decode_utf8_length(src, &dst.length);\n    dst.start = njs_string_alloc(vm, value, dst.length, length);\n\n    if (njs_fast_path(dst.start != NULL)) {\n        njs_decode_utf8(&dst, src);\n        return NJS_OK;\n    }\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":281129,"func":"static void xfrm_byidx_resize(struct net *net, int total)\n{\n\tunsigned int hmask = net->xfrm.policy_idx_hmask;\n\tunsigned int nhashmask = xfrm_new_hash_mask(hmask);\n\tunsigned int nsize = (nhashmask + 1) * sizeof(struct hlist_head);\n\tstruct hlist_head *oidx = net->xfrm.policy_byidx;\n\tstruct hlist_head *nidx = xfrm_hash_alloc(nsize);\n\tint i;\n\n\tif (!nidx)\n\t\treturn;\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\n\tfor (i = hmask; i >= 0; i--)\n\t\txfrm_idx_hash_transfer(oidx + i, nidx, nhashmask);\n\n\tnet->xfrm.policy_byidx = nidx;\n\tnet->xfrm.policy_idx_hmask = nhashmask;\n\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\n\txfrm_hash_free(oidx, (hmask + 1) * sizeof(struct hlist_head));\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":404741,"func":"struct file *fget_task(struct task_struct *task, unsigned int fd)\n{\n\tstruct file *file = NULL;\n\n\ttask_lock(task);\n\tif (task->files)\n\t\tfile = __fget_files(task->files, fd, 0, 1);\n\ttask_unlock(task);\n\n\treturn file;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":277488,"func":"bool mobi_indx_has_tag(const MOBIIndx *indx, const size_t tagid) {\n    if (indx) {\n        for (size_t i = 0; i < indx->entries_count; i++) {\n            MOBIIndexEntry entry = indx->entries[i];\n            for(size_t j = 0; j < entry.tags_count; j++) {\n                if (entry.tags[j].tagid == tagid) {\n                    return true;\n                }\n            }\n        }\n    }\n    return false;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":357669,"func":"SQInstance::SQInstance(SQSharedState *ss, SQInstance *i, SQInteger memsize)\n{\n    _memsize = memsize;\n    _class = i->_class;\n    SQUnsignedInteger nvalues = _class->_defaultvalues.size();\n    for(SQUnsignedInteger n = 0; n < nvalues; n++) {\n        new (&_values[n]) SQObjectPtr(i->_values[n]);\n    }\n    Init(ss);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":243988,"func":"GF_Err fecr_box_size(GF_Box *s)\n{\n\tFECReservoirBox *ptr = (FECReservoirBox *)s;\n\tptr->size += (ptr->version ? 4 : 2) +  ptr->nb_entries * (ptr->version ? 8 : 6);\n\treturn GF_OK;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":513047,"func":"  Item_float(THD *thd, const char *str, double val_arg, uint decimal_par,\n             uint length): Item_num(thd), value(val_arg)\n  {\n    presentation= name.str= str;\n    name.length= safe_strlen(str);\n    decimals=(uint8) decimal_par;\n    max_length= length;\n  }","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":336004,"func":"static int sr_read_eeprom_word(struct usbnet *dev, u8 offset, void *value)\n{\n\treturn sr_share_read_word(dev, 0, offset, value);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":412119,"func":"dnsc_nonces_compfunc(void *m1, void *m2)\n{\n    struct nonce_cache_key *k1 = m1, *k2 = m2;\n    return\n        sodium_memcmp(\n            k1->nonce,\n            k2->nonce,\n            crypto_box_HALF_NONCEBYTES) != 0 ||\n        sodium_memcmp(\n            k1->magic_query,\n            k2->magic_query,\n            DNSCRYPT_MAGIC_HEADER_LEN) != 0 ||\n        sodium_memcmp(\n            k1->client_publickey, k2->client_publickey,\n            crypto_box_PUBLICKEYBYTES) != 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":226037,"func":"GF_Err elst_box_size(GF_Box *s)\n{\n\tu32 durtimebytes;\n\tu32 i, nb_entries;\n\tGF_EditListBox *ptr = (GF_EditListBox *)s;\n\n\t\/\/entry count\n\tptr->size += 4;\n\tnb_entries = gf_list_count(ptr->entryList);\n\tptr->version = 0;\n\tfor (i=0; i<nb_entries; i++) {\n\t\tGF_EdtsEntry *p = (GF_EdtsEntry*)gf_list_get(ptr->entryList, i);\n\t\tif ((p->segmentDuration>0xFFFFFFFF) || (p->mediaTime>0xFFFFFFFF)) {\n\t\t\tptr->version = 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tdurtimebytes = (ptr->version == 1 ? 16 : 8) + 4;\n\tptr->size += (nb_entries * durtimebytes);\n\treturn GF_OK;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":336560,"func":"static void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitors_config)\n{\n    FOREACH_QXL_INSTANCE(reds, qxl) {\n        if (!red_qxl_client_monitors_config(qxl, monitors_config)) {\n            \/* this is a normal condition, some qemu devices might not implement it *\/\n            spice_debug(\"QXLInterface::client_monitors_config failed\");\n        }\n    }\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":337804,"func":"struct sctp_chunk *sctp_make_abort_no_data(\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst struct sctp_chunk *chunk,\n\t\t\t\t\t__u32 tsn)\n{\n\tstruct sctp_chunk *retval;\n\t__be32 payload;\n\n\tretval = sctp_make_abort(asoc, chunk,\n\t\t\t\t sizeof(struct sctp_errhdr) + sizeof(tsn));\n\n\tif (!retval)\n\t\tgoto no_mem;\n\n\t\/* Put the tsn back into network byte order.  *\/\n\tpayload = htonl(tsn);\n\tsctp_init_cause(retval, SCTP_ERROR_NO_DATA, sizeof(payload));\n\tsctp_addto_chunk(retval, sizeof(payload), (const void *)&payload);\n\n\t\/* RFC 2960 6.4 Multi-homed SCTP Endpoints\n\t *\n\t * An endpoint SHOULD transmit reply chunks (e.g., SACK,\n\t * HEARTBEAT ACK, * etc.) to the same destination transport\n\t * address from which it * received the DATA or control chunk\n\t * to which it is replying.\n\t *\n\t * [ABORT back to where the offender came from.]\n\t *\/\n\tif (chunk)\n\t\tretval->transport = chunk->transport;\n\nno_mem:\n\treturn retval;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":383340,"func":"gdImageSetThickness (gdImagePtr im, int thickness)\n{\n  im->thick = thickness;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":210636,"func":"static void mkiss_close(struct tty_struct *tty)\n{\n\tstruct mkiss *ax;\n\n\twrite_lock_irq(&disc_data_lock);\n\tax = tty->disc_data;\n\ttty->disc_data = NULL;\n\twrite_unlock_irq(&disc_data_lock);\n\n\tif (!ax)\n\t\treturn;\n\n\t\/*\n\t * We have now ensured that nobody can start using ap from now on, but\n\t * we have to wait for all existing users to finish.\n\t *\/\n\tif (!refcount_dec_and_test(&ax->refcnt))\n\t\twait_for_completion(&ax->dead);\n\t\/*\n\t * Halt the transmit queue so that a new transmit cannot scribble\n\t * on our buffers\n\t *\/\n\tnetif_stop_queue(ax->dev);\n\n\tax->tty = NULL;\n\n\tunregister_netdev(ax->dev);\n\n\t\/* Free all AX25 frame buffers after unreg. *\/\n\tkfree(ax->rbuff);\n\tkfree(ax->xbuff);\n\n\tfree_netdev(ax->dev);\n}","target":1,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":401493,"func":"static ssize_t _extract_entropy(struct entropy_store *r, void *buf,\n\t\t\t\tsize_t nbytes, int fips)\n{\n\tssize_t ret = 0, i;\n\t__u8 tmp[EXTRACT_SIZE];\n\tunsigned long flags;\n\n\twhile (nbytes) {\n\t\textract_buf(r, tmp);\n\n\t\tif (fips) {\n\t\t\tspin_lock_irqsave(&r->lock, flags);\n\t\t\tif (!memcmp(tmp, r->last_data, EXTRACT_SIZE))\n\t\t\t\tpanic(\"Hardware RNG duplicated output!\\n\");\n\t\t\tmemcpy(r->last_data, tmp, EXTRACT_SIZE);\n\t\t\tspin_unlock_irqrestore(&r->lock, flags);\n\t\t}\n\t\ti = min_t(int, nbytes, EXTRACT_SIZE);\n\t\tmemcpy(buf, tmp, i);\n\t\tnbytes -= i;\n\t\tbuf += i;\n\t\tret += i;\n\t}\n\n\t\/* Wipe data just returned from memory *\/\n\tmemzero_explicit(tmp, sizeof(tmp));\n\n\treturn ret;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":226194,"func":"void elng_box_del(GF_Box *s)\n{\n\tGF_ExtendedLanguageBox *ptr = (GF_ExtendedLanguageBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->extended_language) gf_free(ptr->extended_language);\n\tgf_free(ptr);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":226383,"func":"\nGF_Box *jp2h_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_J2KHeaderBox, GF_ISOM_BOX_TYPE_JP2H);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":455352,"func":"operate_and_get_next (count, c)\n     int count, c;\n{\n  int where;\n\n  \/* Accept the current line. *\/\n  rl_newline (1, c);\n\n  \/* Find the current line, and find the next line to use. *\/\n  where = rl_explicit_arg ? count : where_history ();\n\n  if (HISTORY_FULL () || (where >= history_length - 1) || rl_explicit_arg)\n    saved_history_line_to_use = where;\n  else\n    saved_history_line_to_use = where + 1;\n\n  old_rl_startup_hook = rl_startup_hook;\n  rl_startup_hook = set_saved_history;\n\n  return 0;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":513048,"func":"static int cmp_row_type(Item* item1, Item* item2)\n{\n  uint n= item1->cols();\n  if (item2->check_cols(n))\n    return 1;\n  for (uint i=0; i<n; i++)\n  {\n    if (item2->element_index(i)->check_cols(item1->element_index(i)->cols()) ||\n        (item1->element_index(i)->result_type() == ROW_RESULT &&\n         cmp_row_type(item1->element_index(i), item2->element_index(i))))\n      return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":240296,"func":"get_y_current(void)\n{\n    return y_current;\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":512284,"func":"bool Item_func_regexp_instr::fix_fields(THD *thd, Item **ref)\n{\n  re.set_recursion_limit(thd);\n  return Item_int_func::fix_fields(thd, ref);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":175778,"func":"  CallbackList& unlimited_callbacks() { return unlimited_callbacks_; }\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":226074,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nGF_Err sbgp_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tGF_SampleGroupBox *p = (GF_SampleGroupBox*)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, p->grouping_type);\n\tif (p->version==1)\n\t\tgf_bs_write_u32(bs, p->grouping_type_parameter);\n\n\tgf_bs_write_u32(bs, p->entry_count);\n\tfor (i = 0; i<p->entry_count; i++ ) {\n\t\tgf_bs_write_u32(bs, p->sample_entries[i].sample_count);\n\t\tgf_bs_write_u32(bs, p->sample_entries[i].group_description_index);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":369226,"func":"\nstatic __cold bool io_uring_try_cancel_iowq(struct io_ring_ctx *ctx)\n{\n\tstruct io_tctx_node *node;\n\tenum io_wq_cancel cret;\n\tbool ret = false;\n\n\tmutex_lock(&ctx->uring_lock);\n\tlist_for_each_entry(node, &ctx->tctx_list, ctx_node) {\n\t\tstruct io_uring_task *tctx = node->task->io_uring;\n\n\t\t\/*\n\t\t * io_wq will stay alive while we hold uring_lock, because it's\n\t\t * killed after ctx nodes, which requires to take the lock.\n\t\t *\/\n\t\tif (!tctx || !tctx->io_wq)\n\t\t\tcontinue;\n\t\tcret = io_wq_cancel_cb(tctx->io_wq, io_cancel_ctx_cb, ctx, true);\n\t\tret |= (cret != IO_WQ_CANCEL_NOTFOUND);\n\t}\n\tmutex_unlock(&ctx->uring_lock);\n\n\treturn ret;","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":238549,"func":"static bool type_is_rdonly_mem(u32 type)\n{\n\treturn type & MEM_RDONLY;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":391668,"func":"bool is_deferred_open_async(const void *ptr)\n{\n\tconst struct deferred_open_record *state = (const struct deferred_open_record *)ptr;\n\n\treturn state->async_open;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":312479,"func":"free_efm_list(efm_T **efm_first)\n{\n    efm_T *efm_ptr;\n\n    for (efm_ptr = *efm_first; efm_ptr != NULL; efm_ptr = *efm_first)\n    {\n\t*efm_first = efm_ptr->next;\n\tvim_regfree(efm_ptr->prog);\n\tvim_free(efm_ptr);\n    }\n    fmt_start = NULL;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":430358,"func":"seq_hlist_start_percpu(struct hlist_head __percpu *head, int *cpu, loff_t pos)\n{\n\tstruct hlist_node *node;\n\n\tfor_each_possible_cpu(*cpu) {\n\t\thlist_for_each(node, per_cpu_ptr(head, *cpu)) {\n\t\t\tif (pos-- == 0)\n\t\t\t\treturn node;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":389722,"func":"check_for_opt_dict_arg(typval_T *args, int idx)\n{\n    return (args[idx].v_type == VAR_UNKNOWN\n\t    || check_for_dict_arg(args, idx) != FAIL);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":246464,"func":"const char *r_bin_wasm_get_function_name(RBinWasmObj *bin, ut32 idx) {\n\tif (!(bin && bin->g_names)) {\n\t\treturn NULL;\n\t};\n\n\tRListIter *iter;\n\tRBinWasmCustomNameEntry *nam;\n\tr_list_foreach (bin->g_names, iter, nam) {\n\t\tif (nam->type == R_BIN_WASM_NAMETYPE_Function) {\n\t\t\tconst char *n = r_id_storage_get (nam->func->names, idx);\n\t\t\tif (n) {\n\t\t\t\treturn n;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":521472,"func":"    bool writeDirectoryEntry (OutputStream& target)\r\n    {\r\n        target.writeInt (0x02014b50);\r\n        target.writeShort (symbolicLink ? 0x0314 : 0x0014);\r\n        writeFlagsAndSizes (target);\r\n        target.writeShort (0); \/\/ comment length\r\n        target.writeShort (0); \/\/ start disk num\r\n        target.writeShort (0); \/\/ internal attributes\r\n        target.writeInt ((int) (symbolicLink ? 0xA1ED0000 : 0)); \/\/ external attributes\r\n        target.writeInt ((int) (uint32) headerStart);\r\n        target << storedPathname;\r\n\r\n        return true;\r\n    }\r","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":232961,"func":"void Curl_unencode_cleanup(struct Curl_easy *data)\n{\n  (void) data;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":343308,"func":"void setprocessname(const char * const title)\n{\n#ifndef NO_PROCNAME_CHANGE\n# ifdef HAVE_SETPROCTITLE\n    setproctitle(\"-%s\", title);\n# elif defined(__linux__)\n    if (argv0 != NULL && argv_lth > strlen(title) - 2) {\n        memset(argv0[0], 0, argv_lth);\n        strncpy(argv0[0], title, argv_lth - 2);\n        argv0[1] = NULL;\n    }\n# elif defined(__hpux__)\n    union pstun pst;\n\n    pst.pst_command = title;\n    pstat(PSTAT_SETCMD, pst, strlen(title), 0, 0);\n# endif\n#endif\n    (void) title;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":316973,"func":"static int selinux_inode_copy_up_xattr(const char *name)\n{\n\t\/* The copy_up hook above sets the initial context on an inode, but we\n\t * don't then want to overwrite it by blindly copying all the lower\n\t * xattrs up.  Instead, we have to filter out SELinux-related xattrs.\n\t *\/\n\tif (strcmp(name, XATTR_NAME_SELINUX) == 0)\n\t\treturn 1; \/* Discard *\/\n\t\/*\n\t * Any other attribute apart from SELINUX is not claimed, supported\n\t * by selinux.\n\t *\/\n\treturn -EOPNOTSUPP;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":359654,"func":"DEFUN (no_bgp_fast_external_failover,\n       no_bgp_fast_external_failover_cmd,\n       \"no bgp fast-external-failover\",\n       NO_STR\n       BGP_STR\n       \"Immediately reset session if a link to a directly connected external peer goes down\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":297212,"func":"static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)\n{\n\txp_field->tag = tag;\n\txp_field->value = NULL;\n\t\/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX   *\/\n\tif (zend_multibyte_encoding_converter(\n\t\t\t(unsigned char**)&xp_field->value,\n\t\t\t&xp_field->size,\n\t\t\t(unsigned char*)szValuePtr,\n\t\t\tByteCount,\n\t\t\tzend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),\n\t\t\tzend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo->decode_unicode_le TSRMLS_CC)\n\t\t\tTSRMLS_CC) == (size_t)-1) {\n\t\txp_field->size = exif_process_string_raw(&xp_field->value, szValuePtr, ByteCount);\n\t}\n\treturn xp_field->size;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":498623,"func":"upsample (guchar       *dest,\n          const guchar *src,\n          guint         width,\n          guint         bytes,\n          guint         alpha)\n{\n  guint x;\n\n  for (x = 0; x < width; x++)\n    {\n      dest[0] =  ((src[1] << 1) & 0xf8);\n      dest[0] += (dest[0] >> 5);\n\n      dest[1] =  ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6);\n      dest[1] += (dest[1] >> 5);\n\n      dest[2] =  ((src[0] << 3) & 0xf8);\n      dest[2] += (dest[2] >> 5);\n\n      if (alpha)\n        {\n          dest[3] = (src[1] & 0x80) ? 255 : 0;\n          dest += 4;\n        }\n      else\n        {\n          dest += 3;\n        }\n\n      src += bytes;\n    }\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":292243,"func":"set_default_modes (server *serv)\n{\n\tchar modes[8];\n\n\tmodes[0] = '+';\n\tmodes[1] = '\\0';\n\n\tif (prefs.hex_irc_wallops)\n\t\tstrcat (modes, \"w\");\n\tif (prefs.hex_irc_servernotice)\n\t\tstrcat (modes, \"s\");\n\tif (prefs.hex_irc_invisible)\n\t\tstrcat (modes, \"i\");\n\tif (prefs.hex_irc_hidehost)\n\t\tstrcat (modes, \"x\");\n\n\tif (modes[1] != '\\0')\n\t{\n\t\tserv->p_mode (serv, serv->nick, modes);\n\t}\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":244152,"func":"void svhd_box_del(GF_Box *s)\n{\n\tGF_SphericalVideoInfoBox *ptr = (GF_SphericalVideoInfoBox *)s;\n\tif (ptr->string) gf_free(ptr->string);\n\tgf_free(s);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":294583,"func":"h_trunc(VALUE h, VALUE *fr)\n{\n    VALUE rh;\n\n    if (wholenum_p(h)) {\n\trh = to_integer(h);\n\t*fr = INT2FIX(0);\n    }\n    else {\n\trh = f_idiv(h, INT2FIX(1));\n\t*fr = f_mod(h, INT2FIX(1));\n\t*fr = f_quo(*fr, INT2FIX(24));\n    }\n    return rh;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":404702,"func":"int __receive_fd(struct file *file, int __user *ufd, unsigned int o_flags)\n{\n\tint new_fd;\n\tint error;\n\n\terror = security_file_receive(file);\n\tif (error)\n\t\treturn error;\n\n\tnew_fd = get_unused_fd_flags(o_flags);\n\tif (new_fd < 0)\n\t\treturn new_fd;\n\n\tif (ufd) {\n\t\terror = put_user(new_fd, ufd);\n\t\tif (error) {\n\t\t\tput_unused_fd(new_fd);\n\t\t\treturn error;\n\t\t}\n\t}\n\n\tfd_install(new_fd, get_file(file));\n\t__receive_sock(file);\n\treturn new_fd;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":301355,"func":"static int vfswrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)\n{\n\treturn setxattr(path, name, value, size, flags);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":486823,"func":"static unsigned get_bit(const uint8_t *mac, unsigned bit)\n{\n    unsigned byte;\n\n    byte = mac[bit \/ 8];\n    byte >>= (bit & 0x7);\n    byte &= 1;\n\n    return byte;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":387859,"func":"static int binary_search(const Array<Method*>* methods, const Symbol* name) {\n  int len = methods->length();\n  \/\/ methods are sorted, so do binary search\n  int l = 0;\n  int h = len - 1;\n  while (l <= h) {\n    int mid = (l + h) >> 1;\n    Method* m = methods->at(mid);\n    assert(m->is_method(), \"must be method\");\n    int res = m->name()->fast_compare(name);\n    if (res == 0) {\n      return mid;\n    } else if (res < 0) {\n      l = mid + 1;\n    } else {\n      h = mid - 1;\n    }\n  }\n  return -1;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":221137,"func":"void ResetTextConfig(GF_TextConfig *desc)\n{\n\tGF_List *bck;\n\twhile (gf_list_count(desc->sample_descriptions)) {\n\t\tGF_TextSampleDescriptor *sd = (GF_TextSampleDescriptor *)gf_list_get(desc->sample_descriptions, 0);\n\t\tgf_list_rem(desc->sample_descriptions, 0);\n\t\tgf_odf_del_tx3g(sd);\n\t}\n\tbck = desc->sample_descriptions;\n\tmemset(desc, 0, sizeof(GF_TextConfig));\n\tdesc->tag = GF_ODF_TEXT_CFG_TAG;\n\tdesc->sample_descriptions = bck;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":369325,"func":"\nstatic int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,\n\t\t\t\t   unsigned size, unsigned type)\n{\n\tstruct io_uring_rsrc_update2 up;\n\n\tif (size != sizeof(up))\n\t\treturn -EINVAL;\n\tif (copy_from_user(&up, arg, sizeof(up)))\n\t\treturn -EFAULT;\n\tif (!up.nr || up.resv || up.resv2)\n\t\treturn -EINVAL;\n\treturn __io_register_rsrc_update(ctx, type, &up, up.nr);","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":317163,"func":"static int smack_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)\n{\n\treturn smack_inode_setsecurity(inode, XATTR_SMACK_SUFFIX, ctx,\n\t\t\t\t       ctxlen, 0);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":387590,"func":"int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type)\n{\n\tstruct snd_ctl_file *kctl;\n\tint subdevice = -1;\n\tunsigned long flags;\n\n\tread_lock_irqsave(&card->ctl_files_rwlock, flags);\n\tlist_for_each_entry(kctl, &card->ctl_files, list) {\n\t\tif (kctl->pid == task_pid(current)) {\n\t\t\tsubdevice = kctl->preferred_subdevice[type];\n\t\t\tif (subdevice != -1)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tread_unlock_irqrestore(&card->ctl_files_rwlock, flags);\n\treturn subdevice;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":313137,"func":"testCleanupImages(void)\n{\n    VIR_FREE(qemuimg);\n    VIR_FREE(absraw);\n    VIR_FREE(absqcow2);\n    VIR_FREE(abswrap);\n    VIR_FREE(absqed);\n    VIR_FREE(absdir);\n    VIR_FREE(abslink2);\n\n    if (chdir(abs_builddir) < 0) {\n        fprintf(stderr, \"unable to return to correct directory, refusing to \"\n                \"clean up %s\\n\", datadir);\n        return;\n    }\n\n    virFileDeleteTree(datadir);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":401535,"func":"void add_timer(struct timer_list *timer)\n{\n\tBUG_ON(timer_pending(timer));\n\t__mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":401552,"func":"static void do_numa_crng_init(struct work_struct *work)\n{\n\tint i;\n\tstruct crng_state *crng;\n\tstruct crng_state **pool;\n\n\tpool = kcalloc(nr_node_ids, sizeof(*pool), GFP_KERNEL|__GFP_NOFAIL);\n\tfor_each_online_node(i) {\n\t\tcrng = kmalloc_node(sizeof(struct crng_state),\n\t\t\t\t    GFP_KERNEL | __GFP_NOFAIL, i);\n\t\tspin_lock_init(&crng->lock);\n\t\tcrng_initialize_secondary(crng);\n\t\tpool[i] = crng;\n\t}\n\tmb();\n\tif (cmpxchg(&crng_node_pool, NULL, pool)) {\n\t\tfor_each_node(i)\n\t\t\tkfree(pool[i]);\n\t\tkfree(pool);\n\t}\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":343217,"func":"static void updatepidfile(void)\n{\n    int fd;\n    char buf[42];\n    size_t buf_len;\n\n    if (SNCHECK(snprintf(buf, sizeof buf, \"%lu\\n\",\n                         (unsigned long) getpid()), sizeof buf)) {\n        return;\n    }\n    if (unlink(pid_file) != 0 && errno != ENOENT) {\n        return;\n    }\n    if ((fd = open(pid_file, O_CREAT | O_WRONLY | O_TRUNC |\n                   O_NOFOLLOW, (mode_t) 0644)) == -1) {\n        return;\n    }\n    buf_len = strlen(buf);\n    if (safe_write(fd, buf, buf_len, -1) != (ssize_t) buf_len) {\n        (void) ftruncate(fd, (off_t) 0);\n    }\n    (void) close(fd);\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":226029,"func":"\nvoid gitn_box_del(GF_Box *s)\n{\n\tu32 i;\n\tGroupIdToNameBox *ptr = (GroupIdToNameBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->entries) {\n\t\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\t\tif (ptr->entries[i].name) gf_free(ptr->entries[i].name);\n\t\t}\n\t\tgf_free(ptr->entries);\n\t}\n\tgf_free(ptr);","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":294588,"func":"sec_to_ns(VALUE s)\n{\n    if (safe_mul_p(s, SECOND_IN_NANOSECONDS))\n\treturn LONG2FIX(FIX2LONG(s) * SECOND_IN_NANOSECONDS);\n    return f_mul(s, INT2FIX(SECOND_IN_NANOSECONDS));\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":226081,"func":"void edts_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":308163,"func":"static int fastrpc_dma_buf_attach(struct dma_buf *dmabuf,\n\t\t\t\t  struct dma_buf_attachment *attachment)\n{\n\tstruct fastrpc_dma_buf_attachment *a;\n\tstruct fastrpc_buf *buffer = dmabuf->priv;\n\tint ret;\n\n\ta = kzalloc(sizeof(*a), GFP_KERNEL);\n\tif (!a)\n\t\treturn -ENOMEM;\n\n\tret = dma_get_sgtable(buffer->dev, &a->sgt, buffer->virt,\n\t\t\t      FASTRPC_PHYS(buffer->phys), buffer->size);\n\tif (ret < 0) {\n\t\tdev_err(buffer->dev, \"failed to get scatterlist from DMA API\\n\");\n\t\tkfree(a);\n\t\treturn -EINVAL;\n\t}\n\n\ta->dev = attachment->dev;\n\tINIT_LIST_HEAD(&a->node);\n\tattachment->priv = a;\n\n\tmutex_lock(&buffer->lock);\n\tlist_add(&a->node, &buffer->attachments);\n\tmutex_unlock(&buffer->lock);\n\n\treturn 0;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":344766,"func":"sock_set_v6only(int s)\n{\n#if defined(IPV6_V6ONLY) && !defined(__OpenBSD__)\n\tint on = 1;\n\n\tdebug3(\"%s: set socket %d IPV6_V6ONLY\", __func__, s);\n\tif (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1)\n\t\terror(\"setsockopt IPV6_V6ONLY: %s\", strerror(errno));\n#endif\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":417131,"func":"bool PlayerGeneric::getPowerOfTwoCompensationFlag() const\n{\n\treturn compensateBufferFlag;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":369274,"func":"\nstatic int io_ring_add_registered_fd(struct io_uring_task *tctx, int fd,\n\t\t\t\t     int start, int end)\n{\n\tstruct file *file;\n\tint offset;\n\n\tfor (offset = start; offset < end; offset++) {\n\t\toffset = array_index_nospec(offset, IO_RINGFD_REG_MAX);\n\t\tif (tctx->registered_rings[offset])\n\t\t\tcontinue;\n\n\t\tfile = fget(fd);\n\t\tif (!file) {\n\t\t\treturn -EBADF;\n\t\t} else if (file->f_op != &io_uring_fops) {\n\t\t\tfput(file);\n\t\t\treturn -EOPNOTSUPP;\n\t\t}\n\t\ttctx->registered_rings[offset] = file;\n\t\treturn offset;\n\t}\n\n\treturn -EBUSY;","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":445997,"func":"_remove_files_begin (SaveData *save_data,\n\t\t     gpointer  user_data)\n{\n\tLoadData   *load_data = LOAD_DATA (save_data);\n\tRemoveData *remove_data = user_data;\n\n\tfr_archive_progress_set_total_files (load_data->archive, remove_data->n_files_to_remove);\n\tfr_archive_progress_set_total_bytes (load_data->archive,\n\t\t\t\tFR_ARCHIVE_LIBARCHIVE (load_data->archive)->priv->uncompressed_size);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":234745,"func":"void btrfs_free_device(struct btrfs_device *device)\n{\n\tWARN_ON(!list_empty(&device->post_commit_list));\n\trcu_string_free(device->name);\n\textent_io_tree_release(&device->alloc_state);\n\tbio_put(device->flush_bio);\n\tbtrfs_destroy_dev_zone_info(device);\n\tkfree(device);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":244088,"func":"GF_Box *chnl_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ChannelLayoutBox, GF_ISOM_BOX_TYPE_CHNL);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":301345,"func":"static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)\n{\n\treturn flistxattr(fsp->fh->fd, list, size);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":462232,"func":"PJ_DEF(pj_status_t) pj_stun_sockaddr_attr_create(pj_pool_t *pool,\n\t\t\t\t\t\t int attr_type,\n\t\t\t\t\t\t pj_bool_t xor_ed,\n\t\t\t\t\t\t const pj_sockaddr_t *addr,\n\t\t\t\t\t\t unsigned addr_len,\n\t\t\t\t\t\t pj_stun_sockaddr_attr **p_attr)\n{\n    pj_stun_sockaddr_attr *attr;\n\n    PJ_ASSERT_RETURN(pool && p_attr, PJ_EINVAL);\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr);\n    *p_attr = attr;\n    return pj_stun_sockaddr_attr_init(attr, attr_type, xor_ed, \n\t\t\t\t      addr, addr_len);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":244100,"func":"GF_Err clap_box_size(GF_Box *s)\n{\n\ts->size += 32;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":139241,"func":"void OverlayWindowViews::SetAlwaysHidePlayPauseButton(bool is_visible) {\n  always_hide_play_pause_button_ = !is_visible;\n}\n","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":462308,"func":"status_fonts_extended(stream * s, pcl_state_t * pcs,\n                      pcl_data_storage_t storage)\n{\n    return status_do_fonts(s, pcs, storage, true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":229287,"func":"void cql_server::response::write_value(std::optional<query::result_bytes_view> value)\n{\n    if (!value) {\n        write_int(-1);\n        return;\n    }\n\n    write_int(value->size_bytes());\n    using boost::range::for_each;\n    for_each(*value, [&] (bytes_view fragment) {\n        _body.write(fragment);\n    });\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":317216,"func":"static int selinux_socket_create(int family, int type,\n\t\t\t\t int protocol, int kern)\n{\n\tconst struct task_security_struct *tsec = selinux_cred(current_cred());\n\tu32 newsid;\n\tu16 secclass;\n\tint rc;\n\n\tif (kern)\n\t\treturn 0;\n\n\tsecclass = socket_type_to_security_class(family, type, protocol);\n\trc = socket_sockcreate_sid(tsec, secclass, &newsid);\n\tif (rc)\n\t\treturn rc;\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    tsec->sid, newsid, secclass, SOCKET__CREATE, NULL);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":90217,"func":"  virtual EthernetNetwork* ethernet_network() { return ethernet_; }\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":521464,"func":"ZipFile::Builder::Builder() {}\r","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":473870,"func":"utf16be_mbc_case_fold(OnigCaseFoldType flag,\n\t\t      const UChar** pp, const UChar* end, UChar* fold,\n\t\t      OnigEncoding enc)\n{\n  const UChar* p = *pp;\n\n  if (ONIGENC_IS_ASCII_CODE(*(p+1)) && *p == 0) {\n    p++;\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n    if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {\n      if (*p == 0x49) {\n\t*fold++ = 0x01;\n\t*fold   = 0x31;\n\t(*pp) += 2;\n\treturn 2;\n      }\n    }\n#endif\n\n    *fold++ = 0;\n    *fold   = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);\n    *pp += 2;\n    return 2;\n  }\n  else\n    return onigenc_unicode_mbc_case_fold(enc, flag,\n\t\t\t\t\t pp, end, fold);\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":318106,"func":"static int rsi_usb_host_intf_write_pkt(struct rsi_hw *adapter,\n\t\t\t\t       u8 *pkt,\n\t\t\t\t       u32 len)\n{\n\tu32 queueno = ((pkt[1] >> 4) & 0x7);\n\tu8 endpoint;\n\n\tendpoint = ((queueno == RSI_WIFI_MGMT_Q || queueno == RSI_WIFI_DATA_Q ||\n\t\t     queueno == RSI_COEX_Q) ? WLAN_EP : BT_EP);\n\n\treturn rsi_write_multiple(adapter,\n\t\t\t\t  endpoint,\n\t\t\t\t  (u8 *)pkt,\n\t\t\t\t  len);\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":244165,"func":"GF_Err fdsa_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_HintSample *ptr = (GF_HintSample *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\te = gf_isom_box_array_write(s, ptr->packetTable, bs);\n\tif (e) return e;\n\tif (ptr->extra_data) {\n\t\te = gf_isom_box_write((GF_Box *)ptr->extra_data, bs);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":381877,"func":"int8_t udf_next_aext(struct inode *inode, struct extent_position *epos,\n\t\t     struct kernel_lb_addr *eloc, uint32_t *elen, int inc)\n{\n\tint8_t etype;\n\tunsigned int indirections = 0;\n\n\twhile ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) ==\n\t       (EXT_NEXT_EXTENT_ALLOCDESCS >> 30)) {\n\t\tudf_pblk_t block;\n\n\t\tif (++indirections > UDF_MAX_INDIR_EXTS) {\n\t\t\tudf_err(inode->i_sb,\n\t\t\t\t\"too many indirect extents in inode %lu\\n\",\n\t\t\t\tinode->i_ino);\n\t\t\treturn -1;\n\t\t}\n\n\t\tepos->block = *eloc;\n\t\tepos->offset = sizeof(struct allocExtDesc);\n\t\tbrelse(epos->bh);\n\t\tblock = udf_get_lb_pblock(inode->i_sb, &epos->block, 0);\n\t\tepos->bh = udf_tread(inode->i_sb, block);\n\t\tif (!epos->bh) {\n\t\t\tudf_debug(\"reading block %u failed!\\n\", block);\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn etype;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":387796,"func":"Method* InstanceKlass::find_method(const Symbol* name,\n                                   const Symbol* signature) const {\n  return find_method_impl(name, signature, find_overpass, find_static, find_private);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":273052,"func":"uuid_make(char *str)\n{\n  uuid_t uu;\n\n  uuid_generate_random(uu);\n  uuid_unparse_upper(uu, str);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":516254,"func":"static bool virtio_net_set_vnet_endian(VirtIODevice *vdev, NetClientState *ncs,\n                                       int queues, bool enable)\n{\n    int i;\n\n    for (i = 0; i < queues; i++) {\n        if (virtio_net_set_vnet_endian_one(vdev, ncs[i].peer, enable) < 0 &&\n            enable) {\n            while (--i >= 0) {\n                virtio_net_set_vnet_endian_one(vdev, ncs[i].peer, false);\n            }\n\n            return true;\n        }\n    }\n\n    return false;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":273087,"func":"safe_snreplace(char *s, size_t sz, const char *pattern, const char *replacement)\n{\n  char *ptr;\n  char *src;\n  char *dst;\n  size_t num;\n\n  if (!s)\n    return -1;\n\n  if (!pattern || !replacement)\n    return 0;\n\n  size_t p_len = strlen(pattern);\n  size_t r_len = strlen(replacement);\n  size_t s_len = strlen(s) + 1; \/\/ Incl terminator\n\n  ptr = s;\n  while ((ptr = strstr(ptr, pattern)))\n    {\n      \/\/ We will move the part of the string after the pattern from src to dst\n      src = ptr + p_len;\n      dst = ptr + r_len;\n\n      num = s_len - (src - s); \/\/ Number of bytes w\/terminator we need to move\n      if (dst + num > s + sz)\n\treturn -1; \/\/ Not enough room\n\n      \/\/ Shift everything after the pattern to the right, use memmove since\n      \/\/ there might be an overlap\n      memmove(dst, src, num);\n\n      \/\/ Write replacement, no null terminater\n      memcpy(ptr, replacement, r_len);\n\n      \/\/ Advance ptr to avoid infinite looping\n      ptr = dst;\n    }\n\n  return 0;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":522354,"func":"static void ScaWrd(GmfMshSct *msh, void *ptr)\n{\n#ifdef WITH_GMF_AIO\n   if(read(msh->FilDes, ptr, WrdSiz) != WrdSiz)\n#else\n   if(fread(ptr, WrdSiz, 1, msh->hdl) != 1)\n#endif\n      longjmp(msh->err, -26);\n\n   if(msh->cod != 1)\n      SwpWrd((char *)ptr, WrdSiz);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":274727,"func":"static double arc_length(double dia, double angle)\n{\n\treturn M_PI*dia*(angle\/360.0);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":263515,"func":"static void sco_sock_clear_timer(struct sock *sk)\n{\n\tif (!sco_pi(sk)->conn)\n\t\treturn;\n\n\tBT_DBG(\"sock %p state %d\", sk, sk->sk_state);\n\tcancel_delayed_work(&sco_pi(sk)->conn->timeout_work);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":390540,"func":"_XkbCheckTypeName(Atom name,int typeNdx)\n{\nchar *\tstr;\n\n    str= NameForAtom(name);\n    if ((strcmp(str,\"ONE_LEVEL\")==0)||(strcmp(str,\"TWO_LEVEL\")==0)||\n\t(strcmp(str,\"ALPHABETIC\")==0)||(strcmp(str,\"KEYPAD\")==0))\n\treturn False;\n    return True;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":265460,"func":"static int sqfs_join(char **strings, char *dest, int start, int end,\n\t\t     char separator)\n{\n\tint i, offset = 0;\n\n\tfor (i = start; i < end; i++) {\n\t\tstrcpy(dest + offset, strings[i]);\n\t\toffset += strlen(strings[i]);\n\t\tif (i < end - 1)\n\t\t\tdest[offset++] = separator;\n\t}\n\n\treturn offset;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":512335,"func":"  virtual longlong val_int_unsigned_typecast()\n  {\n    return cast_to_int_type_handler()->Item_val_int_unsigned_typecast(this);\n  }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":267837,"func":"vm_run_module (ecma_module_t *module_p) \/**< module to be executed *\/\n{\n  const ecma_value_t module_init_result = ecma_module_initialize (module_p);\n\n  if (ECMA_IS_VALUE_ERROR (module_init_result))\n  {\n    return module_init_result;\n  }\n\n  vm_frame_ctx_shared_t shared;\n  shared.bytecode_header_p = module_p->u.compiled_code_p;\n  shared.function_object_p = &module_p->header.object;\n  shared.status_flags = 0;\n\n  return vm_run (&shared, ECMA_VALUE_UNDEFINED, module_p->scope_p);\n} \/* vm_run_module *\/","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":225947,"func":"GF_Err mehd_box_size(GF_Box *s)\n{\n\tGF_MovieExtendsHeaderBox *ptr = (GF_MovieExtendsHeaderBox *)s;\n\tptr->version = (ptr->fragment_duration>0xFFFFFFFF) ? 1 : 0;\n\ts->size += (ptr->version == 1) ? 8 : 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":248758,"func":"static char *get_netscape_format(const struct Cookie *co)\n{\n  return aprintf(\n    \"%s\"     \/* httponly preamble *\/\n    \"%s%s\\t\" \/* domain *\/\n    \"%s\\t\"   \/* tailmatch *\/\n    \"%s\\t\"   \/* path *\/\n    \"%s\\t\"   \/* secure *\/\n    \"%\" CURL_FORMAT_CURL_OFF_T \"\\t\"   \/* expires *\/\n    \"%s\\t\"   \/* name *\/\n    \"%s\",    \/* value *\/\n    co->httponly?\"#HttpOnly_\":\"\",\n    \/*\n     * Make sure all domains are prefixed with a dot if they allow\n     * tailmatching. This is Mozilla-style.\n     *\/\n    (co->tailmatch && co->domain && co->domain[0] != '.')? \".\":\"\",\n    co->domain?co->domain:\"unknown\",\n    co->tailmatch?\"TRUE\":\"FALSE\",\n    co->path?co->path:\"\/\",\n    co->secure?\"TRUE\":\"FALSE\",\n    co->expires,\n    co->name,\n    co->value?co->value:\"\");\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":448927,"func":"int ZEXPORT inflateResetKeep(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    strm->total_in = strm->total_out = state->total = 0;\n    strm->msg = Z_NULL;\n    if (state->wrap)        \/* to support ill-conceived Java test suite *\/\n        strm->adler = state->wrap & 1;\n    state->mode = HEAD;\n    state->last = 0;\n    state->havedict = 0;\n    state->flags = -1;\n    state->dmax = 32768U;\n    state->head = Z_NULL;\n    state->hold = 0;\n    state->bits = 0;\n    state->lencode = state->distcode = state->next = state->codes;\n    state->sane = 1;\n    state->back = -1;\n    Tracev((stderr, \"inflate: reset\\n\"));\n    return Z_OK;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":252379,"func":"int mz_inflateInit(mz_streamp pStream) {\n  return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":486833,"func":"static void gem_register_types(void)\n{\n    type_register_static(&gem_info);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":487609,"func":"asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist)\n{\n\tint i = 0;\n\n\t\/*\n\t *\tSMP: Nobody else can change our grouplist. Thus we are\n\t *\tsafe.\n\t *\/\n\n\tif (gidsetsize < 0)\n\t\treturn -EINVAL;\n\n\t\/* no need to grab task_lock here; it cannot change *\/\n\ti = current->group_info->ngroups;\n\tif (gidsetsize) {\n\t\tif (i > gidsetsize) {\n\t\t\ti = -EINVAL;\n\t\t\tgoto out;\n\t\t}\n\t\tif (groups_to_user(grouplist, current->group_info)) {\n\t\t\ti = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\t}\nout:\n\treturn i;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":225735,"func":"GF_Err stco_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 entries;\n\tGF_ChunkOffsetBox *ptr = (GF_ChunkOffsetBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->nb_entries = gf_bs_read_u32(bs);\n\tif (ptr->nb_entries > ptr->size \/ 4 || (u64)ptr->nb_entries > (u64)SIZE_MAX\/sizeof(u32)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of entries %d in stco\\n\", ptr->nb_entries));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tif (ptr->nb_entries) {\n\t\tptr->offsets = (u32 *) gf_malloc(ptr->nb_entries * sizeof(u32) );\n\t\tif (ptr->offsets == NULL) return GF_OUT_OF_MEM;\n\t\tptr->alloc_size = ptr->nb_entries;\n\n\t\tfor (entries = 0; entries < ptr->nb_entries; entries++) {\n\t\t\tptr->offsets[entries] = gf_bs_read_u32(bs);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":281099,"func":"void xfrm_garbage_collect(struct net *net)\n{\n\tflow_cache_flush(net);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":244136,"func":"GF_Err trep_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TrackExtensionPropertiesBox *ptr = (GF_TrackExtensionPropertiesBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->trackID);\n\treturn GF_OK;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":247632,"func":"bool DefaultCertValidator::verifyCertificateHashList(\n    X509* cert, const std::vector<std::vector<uint8_t>>& expected_hashes) {\n  std::vector<uint8_t> computed_hash(SHA256_DIGEST_LENGTH);\n  unsigned int n;\n  X509_digest(cert, EVP_sha256(), computed_hash.data(), &n);\n  RELEASE_ASSERT(n == computed_hash.size(), \"\");\n\n  for (const auto& expected_hash : expected_hashes) {\n    if (computed_hash == expected_hash) {\n      return true;\n    }\n  }\n  return false;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":359286,"func":"DEFUN (neighbor_local_as,\n       neighbor_local_as_cmd,\n       NEIGHBOR_CMD2 \"local-as <1-65535>\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Specify a local-as number\\n\"\n       \"AS number used as local AS\\n\")\n{\n  struct peer *peer;\n  int ret;\n\n  peer = peer_and_group_lookup_vty (vty, argv[0]);\n  if (! peer)\n    return CMD_WARNING;\n\n  ret = peer_local_as_set (peer, atoi (argv[1]), 0);\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":294652,"func":"m_real_jd(union DateData *x)\n{\n    VALUE nth, rjd;\n    int jd;\n\n    nth = m_nth(x);\n    jd = m_jd(x);\n\n    encode_jd(nth, jd, &rjd);\n    return rjd;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":245725,"func":"static long get_content_length (orderedmap hashofheaders)\n{\n        char *data;\n        long content_length = -1;\n\n        data = orderedmap_find (hashofheaders, \"content-length\");\n\n        if (data)\n                content_length = atol (data);\n\n        return content_length;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":466104,"func":"static int em_and(struct x86_emulate_ctxt *ctxt)\n{\n\temulate_2op_SrcV(ctxt, \"and\");\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":346450,"func":"source_level(void *cookie)\n{\n    return ((source_cookie_T *)cookie)->level;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":442806,"func":"static CURLcode main_init(void)\n{\n#ifdef DJGPP\n  \/* stop stat() wasting time *\/\n  _djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE;\n#endif\n  return curl_global_init(CURL_GLOBAL_DEFAULT);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":459099,"func":"static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain,\n\t\t\t\t\t   struct tcf_chain_info *chain_info,\n\t\t\t\t\t   u32 protocol, u32 prio,\n\t\t\t\t\t   bool prio_allocate)\n{\n\tstruct tcf_proto **pprev;\n\tstruct tcf_proto *tp;\n\n\t\/* Check the chain for existence of proto-tcf with this priority *\/\n\tfor (pprev = &chain->filter_chain;\n\t     (tp = tcf_chain_dereference(*pprev, chain));\n\t     pprev = &tp->next) {\n\t\tif (tp->prio >= prio) {\n\t\t\tif (tp->prio == prio) {\n\t\t\t\tif (prio_allocate ||\n\t\t\t\t    (tp->protocol != protocol && protocol))\n\t\t\t\t\treturn ERR_PTR(-EINVAL);\n\t\t\t} else {\n\t\t\t\ttp = NULL;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tchain_info->pprev = pprev;\n\tif (tp) {\n\t\tchain_info->next = tp->next;\n\t\ttcf_proto_get(tp);\n\t} else {\n\t\tchain_info->next = NULL;\n\t}\n\treturn tp;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":369185,"func":"static int io_fallocate_prep(struct io_kiocb *req,\n\t\t\t     const struct io_uring_sqe *sqe)\n{\n\tif (sqe->ioprio || sqe->buf_index || sqe->rw_flags ||\n\t    sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\n\treq->sync.off = READ_ONCE(sqe->off);\n\treq->sync.len = READ_ONCE(sqe->addr);\n\treq->sync.mode = READ_ONCE(sqe->len);\n\treturn 0;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":338084,"func":"bool WasmBinaryBuilder::maybeVisitAtomicFence(Expression*& out, uint8_t code) {\n  if (code != BinaryConsts::AtomicFence) {\n    return false;\n  }\n  auto* curr = allocator.alloc<AtomicFence>();\n  BYN_TRACE(\"zz node: AtomicFence\\n\");\n  curr->order = getU32LEB();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":226960,"func":"IRC_PROTOCOL_CALLBACK(numeric)\n{\n    char *pos_args;\n\n    IRC_PROTOCOL_MIN_ARGS(3);\n\n    if (irc_server_strcasecmp (server, server->nick, argv[2]) == 0)\n    {\n        pos_args = (argc > 3) ?\n            ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;\n    }\n    else\n    {\n        pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];\n    }\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s\",\n        weechat_prefix (\"network\"),\n        pos_args);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":359544,"func":"zlog (struct zlog *zl, int priority, const char *format, ...)\n{\n  va_list args;\n\n  va_start(args, format);\n  vzlog (zl, priority, format, args);\n  va_end (args);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":450824,"func":"static void st21nfca_se_activation_timeout(struct timer_list *t)\n{\n\tstruct st21nfca_hci_info *info = from_timer(info, t,\n\t\t\t\t\t\t    se_info.se_active_timer);\n\n\tinfo->se_info.se_active = false;\n\n\tcomplete(&info->se_info.req_completion);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":317076,"func":"static int selinux_ismaclabel(const char *name)\n{\n\treturn (strcmp(name, XATTR_SELINUX_SUFFIX) == 0);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":195341,"func":"int64_t OpLevelCostEstimator::CalculateOutputSize(const OpInfo& op_info,\n                                                  bool* found_unknown_shapes) {\n  int64_t total_output_size = 0;\n  \/\/ Use float as default for calculations.\n  for (const auto& output : op_info.outputs()) {\n    DataType dt = output.dtype();\n    const auto& original_output_shape = output.shape();\n    int64_t output_size = DataTypeSize(BaseType(dt));\n    int num_dims = std::max(1, original_output_shape.dim_size());\n    auto output_shape = MaybeGetMinimumShape(original_output_shape, num_dims,\n                                             found_unknown_shapes);\n    for (const auto& dim : output_shape.dim()) {\n      output_size *= dim.size();\n    }\n    total_output_size += output_size;\n    VLOG(1) << \"Output Size: \" << output_size\n            << \" Total Output Size:\" << total_output_size;\n  }\n  return total_output_size;\n}","target":1,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":371188,"func":"ut64 get_code_object_addr(RzBinPycObj *pyc, RzBuffer *buffer, ut32 magic) {\n\tpyc->magic_int = magic;\n\tpyc_object *co = get_code_object(pyc, buffer);\n\tut64 result = 0;\n\tif (!co) {\n\t\treturn 0;\n\t}\n\n\tpyc_code_object *cobj = co->data;\n\tresult = cobj->start_offset;\n\tfree_object(co);\n\n\treturn result;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":273892,"func":"static void handle_CDUP(ctrl_t *ctrl, char *path)\n{\n\thandle_CWD(ctrl, \"..\");\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":248316,"func":"static int cfg_print_pff_indent(cfg_t *cfg, FILE *fp,\n\t\t\t\tcfg_print_filter_func_t fb_pff, int indent)\n{\n\tint i, result = CFG_SUCCESS;\n\n\tfor (i = 0; cfg->opts[i].name; i++) {\n\t\tcfg_print_filter_func_t pff = cfg->pff ? cfg->pff : fb_pff;\n\t\tif (pff && pff(cfg, &cfg->opts[i]))\n\t\t\tcontinue;\n\t\tresult += cfg_opt_print_pff_indent(&cfg->opts[i], fp, pff, indent);\n\t}\n\n\treturn result;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":219917,"func":"static void ReorderSDP(char *sdp_text, Bool is_movie_sdp)\n{\n\tchar *cur;\n\tGF_List *lines = gf_list_new();\n\tcur = sdp_text;\n\twhile (cur) {\n\t\tchar b;\n\t\tchar *st = strstr(cur, \"\\r\\n\");\n\t\tassert(st);\n\t\tst += 2;\n\t\tif (!st[0]) {\n\t\t\tAddSDPLine(lines, gf_strdup(cur), is_movie_sdp);\n\t\t\tbreak;\n\t\t}\n\t\tb = st[0];\n\t\tst[0] = 0;\n\t\tAddSDPLine(lines, gf_strdup(cur), is_movie_sdp);\n\t\tst[0] = b;\n\t\tcur = st;\n\t}\n\tstrcpy(sdp_text, \"\");\n\twhile (gf_list_count(lines)) {\n\t\tcur = (char *)gf_list_get(lines, 0);\n\t\tgf_list_rem(lines, 0);\n\t\tstrcat(sdp_text, cur);\n\t\tgf_free(cur);\n\t}\n\tgf_list_del(lines);\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":462228,"func":"PJ_DEF(pj_status_t) pj_stun_msg_add_errcode_attr(pj_pool_t *pool,\n\t\t\t\t\t\t pj_stun_msg *msg,\n\t\t\t\t\t\t int err_code,\n\t\t\t\t\t\t const pj_str_t *err_reason)\n{\n    pj_stun_errcode_attr *err_attr = NULL;\n    pj_status_t status;\n\n    status = pj_stun_errcode_attr_create(pool, err_code, err_reason,\n\t\t\t\t\t &err_attr);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    return pj_stun_msg_add_attr(msg, &err_attr->hdr);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":366308,"func":"static void mount_setattr_commit(struct mount_kattr *kattr,\n\t\t\t\t struct mount *mnt, struct mount *last,\n\t\t\t\t int err)\n{\n\tstruct mount *m = mnt;\n\n\tdo {\n\t\tif (!err) {\n\t\t\tunsigned int flags;\n\n\t\t\tdo_idmap_mount(kattr, m);\n\t\t\tflags = recalc_flags(kattr, m);\n\t\t\tWRITE_ONCE(m->mnt.mnt_flags, flags);\n\t\t}\n\n\t\t\/*\n\t\t * We either set MNT_READONLY above so make it visible\n\t\t * before ~MNT_WRITE_HOLD or we failed to recursively\n\t\t * apply mount options.\n\t\t *\/\n\t\tif ((kattr->attr_set & MNT_READONLY) &&\n\t\t    (m->mnt.mnt_flags & MNT_WRITE_HOLD))\n\t\t\tmnt_unhold_writers(m);\n\n\t\tif (!err && kattr->propagation)\n\t\t\tchange_mnt_propagation(m, kattr->propagation);\n\n\t\t\/*\n\t\t * On failure, only cleanup until we found the first mount\n\t\t * we failed to handle.\n\t\t *\/\n\t\tif (err && m == last)\n\t\t\tbreak;\n\t} while (kattr->recurse && (m = next_mnt(m, mnt)));\n\n\tif (!err)\n\t\ttouch_mnt_namespace(mnt->mnt_ns);\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":309881,"func":"NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL)\n{\n    int result = FALSE;\n\n    T((T_CALLED(\"can_change_color(%p)\"), (void *) SP_PARM));\n\n    if (HasTerminal(SP_PARM) && (CanChange != 0)) {\n\tresult = TRUE;\n    }\n\n    returnCode(result);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":369311,"func":"\nstatic __cold int io_unregister_iowq_aff(struct io_ring_ctx *ctx)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\n\tif (!tctx || !tctx->io_wq)\n\t\treturn -EINVAL;\n\n\treturn io_wq_cpu_affinity(tctx->io_wq, NULL);","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":221692,"func":"void Socket::cleanSsl() {  \/\/ called when failure in ssl set up functions and from stopSsl\n    if (ssl != NULL) {\n        SSL_free(ssl);\n        ssl = NULL;\n    }\n    if (ctx != NULL ) {\n        SSL_CTX_free(ctx);\n        ctx = NULL;\n    }\n    issslserver = false;\n    isssl = false;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":229320,"func":"Status ValidateOp(EagerOperation* op) {\n  const NodeDef& node_def = op->MutableAttrs()->BuildNodeDef();\n  const OpDef* op_def;\n  TF_RETURN_IF_ERROR(OpRegistry::Global()->LookUpOpDef(node_def.op(), &op_def));\n  return ValidateNodeDef(node_def, *op_def);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":252343,"func":"static mz_bool mz_zip_get_file_modified_time(const char *pFilename,\n                                             mz_uint16 *pDOS_time,\n                                             mz_uint16 *pDOS_date) {\n#ifdef MINIZ_NO_TIME\n  (void)pFilename;\n  *pDOS_date = *pDOS_time = 0;\n#else\n  struct MZ_FILE_STAT_STRUCT file_stat;\n  \/\/ On Linux with x86 glibc, this call will fail on large files (>= 0x80000000\n  \/\/ bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh.\n  if (MZ_FILE_STAT(pFilename, &file_stat) != 0) return MZ_FALSE;\n  mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date);\n#endif  \/\/ #ifdef MINIZ_NO_TIME\n  return MZ_TRUE;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":513185,"func":"static const char *item_val_str(struct st_mysql_value *value,\n                                char *buffer, int *length)\n{\n  String str(buffer, *length, system_charset_info), *res;\n  if (!(res= ((st_item_value_holder*)value)->item->val_str(&str)))\n    return NULL;\n  *length= res->length();\n  if (res->c_ptr_quick() == buffer)\n    return buffer;\n\n  \/*\n    Lets be nice and create a temporary string since the\n    buffer was too small\n  *\/\n  return current_thd->strmake(res->ptr(), res->length());\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":261410,"func":"static int decode_intra_chroma_pred_mode(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# intra_chroma_pred_mode\\n\");\n\n  int prefix = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE]);\n\n  int mode;\n  if (prefix==0) {\n    mode=4;\n  }\n  else {\n    mode = decode_CABAC_FL_bypass(&tctx->cabac_decoder, 2);\n  }\n\n  logtrace(LogSlice,\"> intra_chroma_pred_mode = %d\\n\",mode);\n  logtrace(LogSymbols,\"$1 intra_chroma_pred_mode=%d\\n\",mode);\n\n  return mode;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":294381,"func":"commercial_to_jd(VALUE y, int w, int d, double sg,\n\t\t VALUE *nth, int *ry,\n\t\t int *rjd,\n\t\t int *ns)\n{\n    double style = guess_style(y, sg);\n\n    if (style == 0) {\n\tint jd;\n\n\tc_commercial_to_jd(FIX2INT(y), w, d, sg, &jd, ns);\n\tdecode_jd(INT2FIX(jd), nth, rjd);\n\tif (f_zero_p(*nth))\n\t    *ry = FIX2INT(y);\n\telse {\n\t    VALUE nth2;\n\t    decode_year(y, *ns ? -1 : +1, &nth2, ry);\n\t}\n    }\n    else {\n\tdecode_year(y, style, nth, ry);\n\tc_commercial_to_jd(*ry, w, d, style, rjd, ns);\n    }\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":447063,"func":"    DataBuf readFile(const std::wstring& wpath)\n    {\n        FileIo file(wpath);\n        if (file.open(\"rb\") != 0) {\n            throw WError(10, wpath, \"rb\", strError().c_str());\n        }\n        struct _stat st;\n        if (0 != ::_wstat(wpath.c_str(), &st)) {\n            throw WError(2, wpath, strError().c_str(), \"::_wstat\");\n        }\n        DataBuf buf(st.st_size);\n        long len = file.read(buf.pData_, buf.size_);\n        if (len != buf.size_) {\n            throw WError(2, wpath, strError().c_str(), \"FileIo::read\");\n        }\n        return buf;\n    }","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":484047,"func":"setup_key_sizes(void) {\n    memset(&keySizes, 0, sizeof(struct key_sizes));\n\n    keySizes.sym_sig_keyLen = DEFAULT_SYM_SIGNING_KEY_LENGTH;\n    keySizes.sym_enc_blockSize = DEFAULT_SYM_ENCRYPTION_BLOCK_SIZE;\n    keySizes.sym_enc_keyLen = DEFAULT_SYM_ENCRYPTION_KEY_LENGTH;\n    keySizes.sym_sig_size = DEFAULT_SYM_SIGNATURE_SIZE;\n\n    keySizes.asym_lcl_sig_size = DEFAULT_ASYM_LOCAL_SIGNATURE_SIZE;\n    keySizes.asym_rmt_sig_size = DEFAULT_ASYM_REMOTE_SIGNATURE_SIZE;\n\n    keySizes.asym_rmt_ptext_blocksize = DEFAULT_ASYM_REMOTE_PLAINTEXT_BLOCKSIZE;\n    keySizes.asym_rmt_blocksize = DEFAULT_ASYM_REMOTE_BLOCKSIZE;\n    keySizes.asym_rmt_enc_key_size = 2048;\n    keySizes.asym_lcl_enc_key_size = 1024;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":309940,"func":"parse_delay_value(const char *src, double *delays, int *always)\n{\n    int star = 0;\n\n    *delays = 0.0;\n    if (always)\n\t*always = 0;\n\n    while (isdigit(UChar(*src))) {\n\t(*delays) = (*delays) * 10 + (*src++ - '0');\n    }\n    if (*src == '.') {\n\tint gotdot = 1;\n\n\t++src;\n\twhile (isdigit(UChar(*src))) {\n\t    gotdot *= 10;\n\t    (*delays) += (*src++ - '0') \/ gotdot;\n\t}\n    }\n    while (*src == '*' || *src == '\/') {\n\tif (always == 0 && *src == '\/')\n\t    break;\n\tif (*src++ == '*') {\n\t    star = 1;\n\t} else {\n\t    *always = 1;\n\t}\n    }\n    if (star)\n\t*delays = -(*delays);\n    return src;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":226209,"func":"GF_Box *url_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DataEntryURLBox, GF_ISOM_BOX_TYPE_URL);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":453010,"func":"static int nft_flow_block_chain(struct nft_base_chain *basechain,\n\t\t\t\tconst struct net_device *this_dev,\n\t\t\t\tenum flow_block_command cmd)\n{\n\tstruct net_device *dev;\n\tstruct nft_hook *hook;\n\tint err, i = 0;\n\n\tlist_for_each_entry(hook, &basechain->hook_list, list) {\n\t\tdev = hook->ops.dev;\n\t\tif (this_dev && this_dev != dev)\n\t\t\tcontinue;\n\n\t\terr = nft_chain_offload_cmd(basechain, dev, cmd);\n\t\tif (err < 0 && cmd == FLOW_BLOCK_BIND) {\n\t\t\tif (!this_dev)\n\t\t\t\tgoto err_flow_block;\n\n\t\t\treturn err;\n\t\t}\n\t\ti++;\n\t}\n\n\treturn 0;\n\nerr_flow_block:\n\tlist_for_each_entry(hook, &basechain->hook_list, list) {\n\t\tif (i-- <= 0)\n\t\t\tbreak;\n\n\t\tdev = hook->ops.dev;\n\t\tnft_chain_offload_cmd(basechain, dev, FLOW_BLOCK_UNBIND);\n\t}\n\treturn err;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":432280,"func":"int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len)\n{\n#if 0\n    CPUWatchpoint *wp;\n    int ret = 0;\n\n    QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {\n        if (watchpoint_address_matches(wp, addr, TARGET_PAGE_SIZE)) {\n            ret |= wp->flags;\n        }\n    }\n    return ret;\n#endif\n    return 0;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":512365,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_float>(thd, this); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":336561,"func":"static void reds_update_agent_properties(RedsState *reds)\n{\n    if (!reds->agent_dev || reds->config == NULL) {\n        return;\n    }\n    \/* copy & paste *\/\n    reds->agent_dev->priv->write_filter.copy_paste_enabled = reds->config->agent_copypaste;\n    reds->agent_dev->priv->read_filter.copy_paste_enabled = reds->config->agent_copypaste;\n    \/* file transfer *\/\n    reds->agent_dev->priv->write_filter.file_xfer_enabled = reds->config->agent_file_xfer;\n    reds->agent_dev->priv->read_filter.file_xfer_enabled = reds->config->agent_file_xfer;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":366287,"func":"static void delayed_mntput(struct work_struct *unused)\n{\n\tstruct llist_node *node = llist_del_all(&delayed_mntput_list);\n\tstruct mount *m, *t;\n\n\tllist_for_each_entry_safe(m, t, node, mnt_llist)\n\t\tcleanup_mnt(m);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":253710,"func":"static int ccp_copy_to_from_sb(struct ccp_cmd_queue *cmd_q,\n\t\t\t       struct ccp_dm_workarea *wa, u32 jobid, u32 sb,\n\t\t\t       u32 byte_swap, bool from)\n{\n\tstruct ccp_op op;\n\n\tmemset(&op, 0, sizeof(op));\n\n\top.cmd_q = cmd_q;\n\top.jobid = jobid;\n\top.eom = 1;\n\n\tif (from) {\n\t\top.soc = 1;\n\t\top.src.type = CCP_MEMTYPE_SB;\n\t\top.src.u.sb = sb;\n\t\top.dst.type = CCP_MEMTYPE_SYSTEM;\n\t\top.dst.u.dma.address = wa->dma.address;\n\t\top.dst.u.dma.length = wa->length;\n\t} else {\n\t\top.src.type = CCP_MEMTYPE_SYSTEM;\n\t\top.src.u.dma.address = wa->dma.address;\n\t\top.src.u.dma.length = wa->length;\n\t\top.dst.type = CCP_MEMTYPE_SB;\n\t\top.dst.u.sb = sb;\n\t}\n\n\top.u.passthru.byte_swap = byte_swap;\n\n\treturn cmd_q->ccp->vdata->perform->passthru(&op);\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":309885,"func":"skip_DECSCNM(const char *value, int *flag)\n{\n    *flag = -1;\n    if (value != 0) {\n\tint skip = csi_length(value);\n\tif (skip > 0 &&\n\t    value[skip++] == '?' &&\n\t    value[skip++] == '5') {\n\t    if (value[skip] == 'h') {\n\t\t*flag = 1;\n\t    } else if (value[skip] == 'l') {\n\t\t*flag = 0;\n\t    }\n\t    value += skip + 1;\n\t}\n    }\n    return value;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":226055,"func":"void gnra_box_del(GF_Box *s)\n{\n\tGF_GenericAudioSampleEntryBox *ptr = (GF_GenericAudioSampleEntryBox *)s;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)ptr);\n\tif (ptr->data) gf_free(ptr->data);\n\tgf_free(ptr);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":424897,"func":"static void iwl_pcie_alloc_fw_monitor_block(struct iwl_trans *trans,\n\t\t\t\t\t    u8 max_power, u8 min_power)\n{\n\tvoid *cpu_addr = NULL;\n\tdma_addr_t phys = 0;\n\tu32 size = 0;\n\tu8 power;\n\n\tfor (power = max_power; power >= min_power; power--) {\n\t\tsize = BIT(power);\n\t\tcpu_addr = dma_alloc_coherent(trans->dev, size, &phys,\n\t\t\t\t\t      GFP_KERNEL | __GFP_NOWARN);\n\t\tif (!cpu_addr)\n\t\t\tcontinue;\n\n\t\tIWL_INFO(trans,\n\t\t\t \"Allocated 0x%08x bytes for firmware monitor.\\n\",\n\t\t\t size);\n\t\tbreak;\n\t}\n\n\tif (WARN_ON_ONCE(!cpu_addr))\n\t\treturn;\n\n\tif (power != max_power)\n\t\tIWL_ERR(trans,\n\t\t\t\"Sorry - debug buffer is only %luK while you requested %luK\\n\",\n\t\t\t(unsigned long)BIT(power - 10),\n\t\t\t(unsigned long)BIT(max_power - 10));\n\n\ttrans->dbg.fw_mon[trans->dbg.num_blocks].block = cpu_addr;\n\ttrans->dbg.fw_mon[trans->dbg.num_blocks].physical = phys;\n\ttrans->dbg.fw_mon[trans->dbg.num_blocks].size = size;\n\ttrans->dbg.num_blocks++;\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":225779,"func":"GF_Err srpp_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_SRTPProcessBox *ptr = (GF_SRTPProcessBox *)s;\n\tswitch(a->type) {\n\tcase GF_ISOM_BOX_TYPE_SCHI:\n\t\tBOX_FIELD_ASSIGN(info, GF_SchemeInformationBox)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_SCHM:\n\t\tBOX_FIELD_ASSIGN(scheme_type, GF_SchemeTypeBox)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":293733,"func":"static void r_rebase_info_free(RRebaseInfo *info) {\n\tif (!info) {\n\t\treturn;\n\t}\n\n\tif (info->ranges) {\n\t\tR_FREE (info->ranges);\n\t\tinfo->ranges = NULL;\n\t}\n\n\tR_FREE (info);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":432263,"func":"static bool addrrange_contains(AddrRange range, Int128 addr)\n{\n    return int128_ge(addr, range.start)\n        && int128_lt(addr, addrrange_end(range));\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":343294,"func":"void doallo(const off_t size)\n{\n    int ret = -1;\n#ifdef QUOTAS\n    Quota quota;\n#endif\n\n    if (size <= 0) {\n        ret = 0;\n    } else if (ul_check_free_space(wd, (double) size) != 0) {\n        ret = 0;\n    }\n#ifdef QUOTAS\n    if (quota_update("a, 0LL, 0LL, NULL) == 0) {\n        if (quota.files >= user_quota_files ||\n            quota.size >= user_quota_size ||\n            (unsigned long long) size > user_quota_size - quota.size) {\n            ret = -1;\n        }\n    }\n#endif\n    if (ret == 0) {\n#ifdef DISABLE_HUMOR\n        addreply_noformat(200, \"OK\");\n#else\n        addreply_noformat(200, \"A L'HUILE\");\n#endif\n    } else {\n        addreply_noformat(552, MSG_NO_DISK_SPACE);\n    }\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":508337,"func":"static my_bool close_cached_tables_callback(TDC_element *element,\n                                            close_cached_tables_arg *arg)\n{\n  mysql_mutex_lock(&element->LOCK_table_share);\n  if (element->share && element->flushed &&\n      element->version < arg->refresh_version)\n  {\n    \/* wait_for_old_version() will unlock mutex and free share *\/\n    arg->element= element;\n    return TRUE;\n  }\n  mysql_mutex_unlock(&element->LOCK_table_share);\n  return FALSE;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":252412,"func":"size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len,\n                                 const void *pSrc_buf, size_t src_buf_len,\n                                 int flags) {\n  tdefl_output_buffer out_buf;\n  MZ_CLEAR_OBJ(out_buf);\n  if (!pOut_buf) return 0;\n  out_buf.m_pBuf = (mz_uint8 *)pOut_buf;\n  out_buf.m_capacity = out_buf_len;\n  if (!tdefl_compress_mem_to_output(\n          pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags))\n    return 0;\n  return out_buf.m_size;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":432209,"func":"AddressSpaceDispatch *address_space_dispatch_new(struct uc_struct *uc, FlatView *fv)\n{\n    AddressSpaceDispatch *d = g_new0(AddressSpaceDispatch, 1);\n#ifndef NDEBUG\n    uint16_t n;\n\n    n = dummy_section(uc, &d->map, fv, &(uc->io_mem_unassigned));\n    assert(n == PHYS_SECTION_UNASSIGNED);\n#else\n    dummy_section(uc, &d->map, fv, &(uc->io_mem_unassigned));\n#endif\n\n    d->phys_map  = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .skip = 1 };\n    d->uc = uc;\n\n    return d;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":294437,"func":"c_find_fdoy(int y, double sg, int *rjd, int *ns)\n{\n    int d, rm, rd;\n\n    for (d = 1; d < 31; d++)\n\tif (c_valid_civil_p(y, 1, d, sg, &rm, &rd, rjd, ns))\n\t    return 1;\n    return 0;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":452991,"func":"static int nft_flow_offload_bind(struct flow_block_offload *bo,\n\t\t\t\t struct nft_base_chain *basechain)\n{\n\tlist_splice(&bo->cb_list, &basechain->flow_block.cb_list);\n\treturn 0;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":336124,"func":"static int ip6gre_tunnel_init_common(struct net_device *dev)\n{\n\tstruct ip6_tnl *tunnel;\n\tint ret;\n\tint t_hlen;\n\n\ttunnel = netdev_priv(dev);\n\n\ttunnel->dev = dev;\n\ttunnel->net = dev_net(dev);\n\tstrcpy(tunnel->parms.name, dev->name);\n\n\tdev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);\n\tif (!dev->tstats)\n\t\treturn -ENOMEM;\n\n\tret = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);\n\tif (ret) {\n\t\tfree_percpu(dev->tstats);\n\t\tdev->tstats = NULL;\n\t\treturn ret;\n\t}\n\n\ttunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags);\n\ttunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen;\n\tt_hlen = tunnel->hlen + sizeof(struct ipv6hdr);\n\n\tdev->hard_header_len = LL_MAX_HEADER + t_hlen;\n\tdev->mtu = ETH_DATA_LEN - t_hlen;\n\tif (dev->type == ARPHRD_ETHER)\n\t\tdev->mtu -= ETH_HLEN;\n\tif (!(tunnel->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))\n\t\tdev->mtu -= 8;\n\n\treturn 0;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":405697,"func":"static void xemaclite_tx_handler(struct net_device *dev)\n{\n\tstruct net_local *lp = netdev_priv(dev);\n\n\tdev->stats.tx_packets++;\n\n\tif (!lp->deferred_skb)\n\t\treturn;\n\n\tif (xemaclite_send_data(lp, (u8 *)lp->deferred_skb->data,\n\t\t\t\tlp->deferred_skb->len))\n\t\treturn;\n\n\tdev->stats.tx_bytes += lp->deferred_skb->len;\n\tdev_consume_skb_irq(lp->deferred_skb);\n\tlp->deferred_skb = NULL;\n\tnetif_trans_update(dev); \/* prevent tx timeout *\/\n\tnetif_wake_queue(dev);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":275971,"func":"uECC_VLI_API void uECC_vli_modSquare(uECC_word_t *result,\n                                     const uECC_word_t *left,\n                                     const uECC_word_t *mod,\n                                     wordcount_t num_words) {\n    uECC_vli_modMult(result, left, left, mod, num_words);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":369430,"func":" *\/\nstatic void io_submit_state_start(struct io_submit_state *state,\n\t\t\t\t  unsigned int max_ios)\n{\n\tstate->plug_started = false;\n\tstate->need_plug = max_ios > 2;\n\tstate->submit_nr = max_ios;\n\t\/* set only head, no need to init link_last in advance *\/\n\tstate->link.head = NULL;","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":473943,"func":"utf16be_get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t\t\t   const OnigUChar* p, const OnigUChar* end,\n\t\t\t\t   OnigCaseFoldCodeItem items[],\n\t\t\t\t   OnigEncoding enc)\n{\n  return onigenc_unicode_get_case_fold_codes_by_str(enc,\n\t\t\t\t\t\t    flag, p, end, items);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":397645,"func":"static long ToL(unsigned char *puffer)\n{\n  return (puffer[0] | puffer[1] << 8 | puffer[2] << 16 | puffer[3] << 24);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":301377,"func":"static void vfswrap_rewinddir(vfs_handle_struct *handle, DIR *dirp)\n{\n\tSTART_PROFILE(syscall_rewinddir);\n\trewinddir(dirp);\n\tEND_PROFILE(syscall_rewinddir);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":212403,"func":"find_start_brace(void)\t    \/\/ XXX\n{\n    pos_T\tcursor_save;\n    pos_T\t*trypos;\n    pos_T\t*pos;\n    static pos_T\tpos_copy;\n\n    cursor_save = curwin->w_cursor;\n    while ((trypos = findmatchlimit(NULL, '{', FM_BLOCKSTOP, 0)) != NULL)\n    {\n\tpos_copy = *trypos;\t\/\/ copy pos_T, next findmatch will change it\n\ttrypos = &pos_copy;\n\tcurwin->w_cursor = *trypos;\n\tpos = NULL;\n\t\/\/ ignore the { if it's in a \/\/ or \/ *  * \/ comment\n\tif ((colnr_T)cin_skip2pos(trypos) == trypos->col\n\t\t       && (pos = ind_find_start_CORS(NULL)) == NULL) \/\/ XXX\n\t    break;\n\tif (pos != NULL)\n\t    curwin->w_cursor.lnum = pos->lnum;\n    }\n    curwin->w_cursor = cursor_save;\n    return trypos;\n}","target":1,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":220840,"func":"inline void CopyDimsToDesc(const RuntimeShape& input_shape,\n                           NdArrayDesc<N>* desc_out) {\n  int desc_stride = 1;\n  for (int i = N - 1; i >= 0; --i) {\n    desc_out->extents[i] = input_shape.Dims(i);\n    desc_out->strides[i] = desc_stride;\n    desc_stride *= input_shape.Dims(i);\n  }\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":328853,"func":"R_API void r_bin_java_print_double_cp_summary(RBinJavaCPTypeObj *obj) {\n\tut8 *b = NULL;\n\tif (!obj) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaCPTypeObj*  Double.\\n\");\n\t\treturn;\n\t}\n\tb = obj->info.cp_double.bytes.raw;\n\tprintf (\"Double ConstantPool Type (%d) \", obj->metas->ord);\n\tprintf (\"  Offset: 0x%08\"PFMT64x \"\", obj->file_offset);\n\tprintf (\"  High-Bytes = %02x %02x %02x %02x\\n\", b[0], b[1], b[2], b[3]);\n\tprintf (\"  Low-Bytes = %02x %02x %02x %02x\\n\", b[4], b[5], b[6], b[7]);\n\tprintf (\"  Double = %f\\n\", r_bin_java_raw_to_double (obj->info.cp_double.bytes.raw, 0));\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":317339,"func":"static int selinux_inode_copy_up(struct dentry *src, struct cred **new)\n{\n\tu32 sid;\n\tstruct task_security_struct *tsec;\n\tstruct cred *new_creds = *new;\n\n\tif (new_creds == NULL) {\n\t\tnew_creds = prepare_creds();\n\t\tif (!new_creds)\n\t\t\treturn -ENOMEM;\n\t}\n\n\ttsec = selinux_cred(new_creds);\n\t\/* Get label from overlay inode and set it in create_sid *\/\n\tselinux_inode_getsecid(d_inode(src), &sid);\n\ttsec->create_sid = sid;\n\t*new = new_creds;\n\treturn 0;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":356703,"func":"void Statement::Work_Run(napi_env e, void* data) {\n    STATEMENT_INIT(RunBaton);\n\n    STATEMENT_MUTEX(mtx);\n    sqlite3_mutex_enter(mtx);\n\n    \/\/ Make sure that we also reset when there are no parameters.\n    if (!baton->parameters.size()) {\n        sqlite3_reset(stmt->_handle);\n    }\n\n    if (stmt->Bind(baton->parameters)) {\n        stmt->status = sqlite3_step(stmt->_handle);\n\n        if (!(stmt->status == SQLITE_ROW || stmt->status == SQLITE_DONE)) {\n            stmt->message = std::string(sqlite3_errmsg(stmt->db->_handle));\n        }\n        else {\n            baton->inserted_id = sqlite3_last_insert_rowid(stmt->db->_handle);\n            baton->changes = sqlite3_changes(stmt->db->_handle);\n        }\n    }\n\n    sqlite3_mutex_leave(mtx);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":255936,"func":"Status ShapeRefiner::EvaluateConstantTensorForEdge(\n    const Node* node, int dst_idx, bool* evaluated, Tensor* result,\n    InferenceContext* outer_context) {\n  *evaluated = false;\n  const Edge* input_edge;\n  TF_RETURN_IF_ERROR(node->input_edge(dst_idx, &input_edge));\n  OutputTensor tensor(input_edge->src(), input_edge->src_output());\n  return EvaluateConstantTensor(\n      tensor, *this, *ops_registry_, graph_def_version_, evaluated, result,\n      &graph_runner_, &const_tensor_map_, kMaxTensorSize,\n      disable_constant_propagation_, outer_context);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":256442,"func":"JANET_CORE_FN(cfun_array_new_filled,\n              \"(array\/new-filled count &opt value)\",\n              \"Creates a new array of `count` elements, all set to `value`, which defaults to nil. Returns the new array.\") {\n    janet_arity(argc, 1, 2);\n    int32_t count = janet_getinteger(argv, 0);\n    if (count < 0) janet_panic(\"expected positive integer\");\n    Janet x = (argc == 2) ? argv[1] : janet_wrap_nil();\n    JanetArray *array = janet_array(count);\n    for (int32_t i = 0; i < count; i++) {\n        array->data[i] = x;\n    }\n    array->count = count;\n    return janet_wrap_array(array);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":455328,"func":"glob_testdir (dir, flags)\n     char *dir;\n     int flags;\n{\n  struct stat finfo;\n  int r;\n\n\/*itrace(\"glob_testdir: testing %s\" flags = %d, dir, flags);*\/\n#if defined (HAVE_LSTAT)\n  r = (flags & GX_ALLDIRS) ? lstat (dir, &finfo) : stat (dir, &finfo);\n#else\n  r = stat (dir, &finfo);\n#endif\n  if (r < 0)\n    return (-1);\n\n#if defined (S_ISLNK)\n  if (S_ISLNK (finfo.st_mode))\n    return (-2);\n#endif\n\n  if (S_ISDIR (finfo.st_mode) == 0)\n    return (-1);\n\n  return (0);\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":404725,"func":"void fd_install(unsigned int fd, struct file *file)\n{\n\tstruct files_struct *files = current->files;\n\tstruct fdtable *fdt;\n\n\trcu_read_lock_sched();\n\n\tif (unlikely(files->resize_in_progress)) {\n\t\trcu_read_unlock_sched();\n\t\tspin_lock(&files->file_lock);\n\t\tfdt = files_fdtable(files);\n\t\tBUG_ON(fdt->fd[fd] != NULL);\n\t\trcu_assign_pointer(fdt->fd[fd], file);\n\t\tspin_unlock(&files->file_lock);\n\t\treturn;\n\t}\n\t\/* coupled with smp_wmb() in expand_fdtable() *\/\n\tsmp_rmb();\n\tfdt = rcu_dereference_sched(files->fdt);\n\tBUG_ON(fdt->fd[fd] != NULL);\n\trcu_assign_pointer(fdt->fd[fd], file);\n\trcu_read_unlock_sched();\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":366268,"func":"struct ns_common *from_mnt_ns(struct mnt_namespace *mnt)\n{\n\treturn &mnt->ns;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":247136,"func":"struct _gf_ft_mgr *gf_filter_get_font_manager(GF_Filter *filter)\n{\n\tif (!filter) return NULL;\n\treturn gf_fs_get_font_manager(filter->session);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":369425,"func":"static void io_eventfd_signal(struct io_ring_ctx *ctx)\n{\n\tstruct io_ev_fd *ev_fd;\n\n\trcu_read_lock();\n\t\/*\n\t * rcu_dereference ctx->io_ev_fd once and use it for both for checking\n\t * and eventfd_signal\n\t *\/\n\tev_fd = rcu_dereference(ctx->io_ev_fd);\n\n\t\/*\n\t * Check again if ev_fd exists incase an io_eventfd_unregister call\n\t * completed between the NULL check of ctx->io_ev_fd at the start of\n\t * the function and rcu_read_lock.\n\t *\/\n\tif (unlikely(!ev_fd))\n\t\tgoto out;\n\tif (READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_EVENTFD_DISABLED)\n\t\tgoto out;\n\n\tif (!ev_fd->eventfd_async || io_wq_current_is_worker())\n\t\teventfd_signal(ev_fd->cq_ev_fd, 1);\nout:\n\trcu_read_unlock();\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":139242,"func":"void OverlayWindowViews::SetPictureInPictureCustomControls(\n    const std::vector<blink::PictureInPictureControlInfo>& controls) {\n  first_custom_controls_view_.reset();\n  second_custom_controls_view_.reset();\n\n  if (controls.size() > 0)\n    CreateCustomControl(first_custom_controls_view_, controls[0],\n                        ControlPosition::kLeft);\n  if (controls.size() > 1)\n    CreateCustomControl(second_custom_controls_view_, controls[1],\n                        ControlPosition::kRight);\n}\n","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":436159,"func":"\nstatic int io_uring_alloc_task_context(struct task_struct *task,\n\t\t\t\t       struct io_ring_ctx *ctx)\n{\n\tstruct io_uring_task *tctx;\n\tint ret;\n\n\ttctx = kzalloc(sizeof(*tctx), GFP_KERNEL);\n\tif (unlikely(!tctx))\n\t\treturn -ENOMEM;\n\n\tret = percpu_counter_init(&tctx->inflight, 0, GFP_KERNEL);\n\tif (unlikely(ret)) {\n\t\tkfree(tctx);\n\t\treturn ret;\n\t}\n\n\ttctx->io_wq = io_init_wq_offload(ctx, task);\n\tif (IS_ERR(tctx->io_wq)) {\n\t\tret = PTR_ERR(tctx->io_wq);\n\t\tpercpu_counter_destroy(&tctx->inflight);\n\t\tkfree(tctx);\n\t\treturn ret;\n\t}\n\n\txa_init(&tctx->xa);\n\tinit_waitqueue_head(&tctx->wait);\n\tatomic_set(&tctx->in_idle, 0);\n\tatomic_set(&tctx->inflight_tracked, 0);\n\ttask->io_uring = tctx;\n\tspin_lock_init(&tctx->task_lock);\n\tINIT_WQ_LIST(&tctx->task_list);\n\tinit_task_work(&tctx->task_work, tctx_task_work);\n\treturn 0;","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":245720,"func":"static int strip_return_port (char *host)\n{\n        char *ptr1;\n        char *ptr2;\n        int port;\n\n        ptr1 = strrchr (host, ':');\n        if (ptr1 == NULL)\n                return 0;\n\n        \/* Check for IPv6 style literals *\/\n        ptr2 = strchr (ptr1, ']');\n        if (ptr2 != NULL)\n                return 0;\n\n        *ptr1++ = '\\0';\n        if (sscanf (ptr1, \"%d\", &port) != 1)    \/* one conversion required *\/\n                return 0;\n        return port;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":282976,"func":"LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg)\n{\n  TValue *frame = L->base-1;\n  TValue *pframe = NULL;\n  if (frame_islua(frame)) {\n    pframe = frame_prevl(frame);\n  } else if (frame_iscont(frame)) {\n#if LJ_HASFFI\n    if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) {\n      pframe = frame;\n      frame = NULL;\n    } else\n#endif\n    {\n      pframe = frame_prevd(frame);\n#if LJ_HASFFI\n      \/* Remove frame for FFI metamethods. *\/\n      if (frame_func(frame)->c.ffid >= FF_ffi_meta___index &&\n\t  frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) {\n\tL->base = pframe+1;\n\tL->top = frame;\n\tsetcframe_pc(cframe_raw(L->cframe), frame_contpc(frame));\n      }\n#endif\n    }\n  }\n  lj_debug_addloc(L, msg, pframe, frame);\n  lj_err_run(L);\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":312508,"func":"vgr_qflist_valid(\n\twin_T\t    *wp,\n\tqf_info_T   *qi,\n\tint_u\t    qfid,\n\tchar_u\t    *title)\n{\n    \/\/ Verify that the quickfix\/location list was not freed by an autocmd\n    if (!qflist_valid(wp, qfid))\n    {\n\tif (wp != NULL)\n\t{\n\t    \/\/ An autocmd has freed the location list.\n\t    emsg(_(e_current_location_list_was_changed));\n\t    return FALSE;\n\t}\n\telse\n\t{\n\t    \/\/ Quickfix list is not found, create a new one.\n\t    qf_new_list(qi, title);\n\t    return TRUE;\n\t}\n    }\n\n    if (qf_restore_list(qi, qfid) == FAIL)\n\treturn FALSE;\n\n    return TRUE;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":442805,"func":"static void main_free(void)\n{\n  curl_global_cleanup();\n#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)\n  \/* close iconv conversion descriptor *\/\n  if(inbound_cd != (iconv_t)-1)\n    iconv_close(inbound_cd);\n  if(outbound_cd != (iconv_t)-1)\n    iconv_close(outbound_cd);\n#endif \/* CURL_DOES_CONVERSIONS && HAVE_ICONV *\/\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":512349,"func":"  Field *create_table_field_from_handler(TABLE *table)\n  {\n    const Type_handler *h= type_handler();\n    return h->make_and_init_table_field(&name, Record_addr(maybe_null),\n                                        *this, table);\n  }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":405326,"func":"static unsigned int xfrm_mtu(const struct dst_entry *dst)\n{\n\tunsigned int mtu = dst_metric_raw(dst, RTAX_MTU);\n\n\treturn mtu ? : dst_mtu(xfrm_dst_path(dst));\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":462273,"func":"PJ_DEF(pj_status_t) pj_stun_sockaddr_attr_init( pj_stun_sockaddr_attr *attr,\n\t\t\t\t\t\tint attr_type, \n\t\t\t\t\t\tpj_bool_t xor_ed,\n\t\t\t\t\t\tconst pj_sockaddr_t *addr,\n\t\t\t\t\t\tunsigned addr_len)\n{\n    unsigned attr_len;\n\n    PJ_ASSERT_RETURN(attr && addr_len && addr, PJ_EINVAL);\n    PJ_ASSERT_RETURN(addr_len == sizeof(pj_sockaddr_in) ||\n\t\t     addr_len == sizeof(pj_sockaddr_in6), PJ_EINVAL);\n\n    attr_len = pj_sockaddr_get_addr_len(addr) + 4;\n    INIT_ATTR(attr, attr_type, attr_len);\n\n    pj_memcpy(&attr->sockaddr, addr, addr_len);\n    attr->xor_ed = xor_ed;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":225544,"func":"void TfLiteFloatArrayFree(TfLiteFloatArray* a) { free(a); }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":472121,"func":"int cgroup1_get_tree(struct fs_context *fc)\n{\n\tstruct cgroup_fs_context *ctx = cgroup_fc2context(fc);\n\tint ret;\n\n\t\/* Check if the caller has permission to mount. *\/\n\tif (!ns_capable(ctx->ns->user_ns, CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\tcgroup_lock_and_drain_offline(&cgrp_dfl_root.cgrp);\n\n\tret = cgroup1_root_to_use(fc);\n\tif (!ret && !percpu_ref_tryget_live(&ctx->root->cgrp.self.refcnt))\n\t\tret = 1;\t\/* restart *\/\n\n\tmutex_unlock(&cgroup_mutex);\n\n\tif (!ret)\n\t\tret = cgroup_do_get_tree(fc);\n\n\tif (!ret && percpu_ref_is_dying(&ctx->root->cgrp.self.refcnt)) {\n\t\tstruct super_block *sb = fc->root->d_sb;\n\t\tdput(fc->root);\n\t\tdeactivate_locked_super(sb);\n\t\tret = 1;\n\t}\n\n\tif (unlikely(ret > 0)) {\n\t\tmsleep(10);\n\t\treturn restart_syscall();\n\t}\n\treturn ret;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":369859,"func":"static int proc_exe_link(struct dentry *dentry, struct path *exe_path)\n{\n\tstruct task_struct *task;\n\tstruct mm_struct *mm;\n\tstruct file *exe_file;\n\n\ttask = get_proc_task(dentry->d_inode);\n\tif (!task)\n\t\treturn -ENOENT;\n\tmm = get_task_mm(task);\n\tput_task_struct(task);\n\tif (!mm)\n\t\treturn -ENOENT;\n\texe_file = get_mm_exe_file(mm);\n\tmmput(mm);\n\tif (exe_file) {\n\t\t*exe_path = exe_file->f_path;\n\t\tpath_get(&exe_file->f_path);\n\t\tfput(exe_file);\n\t\treturn 0;\n\t} else\n\t\treturn -ENOENT;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":281067,"func":"static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir)\n{\n\tstruct xfrm_policy *newp = xfrm_policy_alloc(xp_net(old), GFP_ATOMIC);\n\tstruct net *net = xp_net(old);\n\n\tif (newp) {\n\t\tnewp->selector = old->selector;\n\t\tif (security_xfrm_policy_clone(old->security,\n\t\t\t\t\t       &newp->security)) {\n\t\t\tkfree(newp);\n\t\t\treturn NULL;  \/* ENOMEM *\/\n\t\t}\n\t\tnewp->lft = old->lft;\n\t\tnewp->curlft = old->curlft;\n\t\tnewp->mark = old->mark;\n\t\tnewp->action = old->action;\n\t\tnewp->flags = old->flags;\n\t\tnewp->xfrm_nr = old->xfrm_nr;\n\t\tnewp->index = old->index;\n\t\tnewp->type = old->type;\n\t\tmemcpy(newp->xfrm_vec, old->xfrm_vec,\n\t\t       newp->xfrm_nr*sizeof(struct xfrm_tmpl));\n\t\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\t\txfrm_sk_policy_link(newp, dir);\n\t\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\t\txfrm_pol_put(newp);\n\t}\n\treturn newp;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":437678,"func":"static u32 txclk_tx_s_max_pulse_width(struct cx23885_dev *dev, u32 ns,\n\t\t\t\t      u16 *divider)\n{\n\tu64 pulse_clocks;\n\n\tif (ns > IR_MAX_DURATION)\n\t\tns = IR_MAX_DURATION;\n\tpulse_clocks = ns_to_pulse_clocks(ns);\n\t*divider = pulse_clocks_to_clock_divider(pulse_clocks);\n\tcx23888_ir_write4(dev, CX23888_IR_TXCLK_REG, *divider);\n\treturn (u32) pulse_width_count_to_ns(FIFO_RXTX, *divider);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":450322,"func":"void vnc_zlib_clear(VncState *vs)\n{\n    if (vs->zlib.stream.opaque) {\n        deflateEnd(&vs->zlib.stream);\n    }\n    buffer_free(&vs->zlib.zlib);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":309961,"func":"parse_ti_delay(const char *ti, double *delays)\n{\n    *delays = 0.0;\n    while (*ti != '\\0') {\n\tif (*ti == '\\\\') {\n\t    ++ti;\n\t}\n\tif (ti[0] == '$'\n\t    && ti[1] == '<'\n\t    && IsDelay(UChar(ti[2]))) {\n\t    int ignored;\n\t    const char *last = parse_delay_value(ti + 2, delays, &ignored);\n\t    if (*last == '>') {\n\t\tti = last;\n\t    }\n\t} else {\n\t    ++ti;\n\t}\n    }\n    return ti;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":299986,"func":"static void elo_remove(struct hid_device *hdev)\n{\n\tstruct elo_priv *priv = hid_get_drvdata(hdev);\n\n\tusb_put_dev(priv->usbdev);\n\n\thid_hw_stop(hdev);\n\tcancel_delayed_work_sync(&priv->work);\n\tkfree(priv);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":452387,"func":"static MagickBooleanType ReadProfile(Image *image,const char *name,\n  const unsigned char *datum,ssize_t length)\n{\n  MagickBooleanType\n    status;\n\n  StringInfo\n    *profile;\n\n  if (length < 4)\n    return(MagickFalse);\n  profile=BlobToStringInfo(datum,(size_t) length);\n  if (profile == (StringInfo *) NULL)\n    ThrowBinaryImageException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  status=SetImageProfile(image,name,profile);\n  profile=DestroyStringInfo(profile);\n  return(status);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":256955,"func":"  static void MapToLabels(const string& subscript, Labels* labels,\n                          absl::flat_hash_map<char, int>* label_mapping) {\n    for (int i = 0; i < subscript.size(); ++i) {\n      const char label_char = subscript[i];\n      if (label_char == '.') {\n        labels->push_back(kEllipsisLabel);\n        i += 2;  \/\/ Skip next 2 characters as well.\n        continue;\n      }\n      if (!label_mapping->contains(label_char)) {\n        const int next_label = label_mapping->size();\n        (*label_mapping)[label_char] = next_label;\n      }\n      const int mapped_label = (*label_mapping)[label_char];\n      labels->push_back(mapped_label);\n    }\n  }","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":437333,"func":"swap_node(Node* a, Node* b)\n{\n  Node c;\n\n  c = *a; *a = *b; *b = c;\n\n  if (NODE_TYPE(a) == NODE_STRING) {\n    StrNode* sn = STR_(a);\n    if (sn->capa == 0) {\n      int len = (int )(sn->end - sn->s);\n      sn->s   = sn->buf;\n      sn->end = sn->s + len;\n    }\n  }\n\n  if (NODE_TYPE(b) == NODE_STRING) {\n    StrNode* sn = STR_(b);\n    if (sn->capa == 0) {\n      int len = (int )(sn->end - sn->s);\n      sn->s   = sn->buf;\n      sn->end = sn->s + len;\n    }\n  }\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":225392,"func":"static char *fourcc2str(unsigned int fourcc, char buf[4])\n{\n\tbuf[0] = (fourcc >> 0) & 0xFF;\n\tbuf[1] = (fourcc >> 8) & 0xFF;\n\tbuf[2] = (fourcc >> 16) & 0xFF;\n\tbuf[3] = (fourcc >> 24) & 0xFF;\n\n\treturn buf;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":369895,"func":"static struct dentry *proc_pident_instantiate(struct inode *dir,\n\tstruct dentry *dentry, struct task_struct *task, const void *ptr)\n{\n\tconst struct pid_entry *p = ptr;\n\tstruct inode *inode;\n\tstruct proc_inode *ei;\n\tstruct dentry *error = ERR_PTR(-ENOENT);\n\n\tinode = proc_pid_make_inode(dir->i_sb, task);\n\tif (!inode)\n\t\tgoto out;\n\n\tei = PROC_I(inode);\n\tinode->i_mode = p->mode;\n\tif (S_ISDIR(inode->i_mode))\n\t\tset_nlink(inode, 2);\t\/* Use getattr to fix if necessary *\/\n\tif (p->iop)\n\t\tinode->i_op = p->iop;\n\tif (p->fop)\n\t\tinode->i_fop = p->fop;\n\tei->op = p->op;\n\td_set_d_op(dentry, &pid_dentry_operations);\n\td_add(dentry, inode);\n\t\/* Close the race of the process dying before we return the dentry *\/\n\tif (pid_revalidate(dentry, NULL))\n\t\terror = NULL;\nout:\n\treturn error;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":314758,"func":"cdf_swap_dir(cdf_directory_t *d)\n{\n\td->d_namelen = CDF_TOLE2(d->d_namelen);\n\td->d_left_child = CDF_TOLE4((uint32_t)d->d_left_child);\n\td->d_right_child = CDF_TOLE4((uint32_t)d->d_right_child);\n\td->d_storage = CDF_TOLE4((uint32_t)d->d_storage);\n\td->d_storage_uuid[0] = CDF_TOLE8(d->d_storage_uuid[0]);\n\td->d_storage_uuid[1] = CDF_TOLE8(d->d_storage_uuid[1]);\n\td->d_flags = CDF_TOLE4(d->d_flags);\n\td->d_created = CDF_TOLE8((uint64_t)d->d_created);\n\td->d_modified = CDF_TOLE8((uint64_t)d->d_modified);\n\td->d_stream_first_sector = CDF_TOLE4((uint32_t)d->d_stream_first_sector);\n\td->d_size = CDF_TOLE4(d->d_size);\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":432267,"func":"void cpu_flush_icache_range(AddressSpace *as, hwaddr start, hwaddr len)\n{\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":386522,"func":"bool DL_Dxf::stripWhiteSpace(char** s, bool stripSpace) {\n    \/\/ last non-NULL char:\n    int lastChar = strlen(*s) - 1;\n\n    \/\/ Is last character CR or LF?\n    while ( (lastChar >= 0) &&\n            (((*s)[lastChar] == 10) || ((*s)[lastChar] == 13) ||\n             (stripSpace && ((*s)[lastChar] == ' ' || ((*s)[lastChar] == '\\t')))) ) {\n        (*s)[lastChar] = '\\0';\n        lastChar--;\n    }\n\n    \/\/ Skip whitespace, excluding \\n, at beginning of line\n    if (stripSpace) {\n        while ((*s)[0]==' ' || (*s)[0]=='\\t') {\n            ++(*s);\n        }\n    }\n    \n    return ((*s) ? true : false);\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":384879,"func":"vim_tolower(int c)\n{\n    if (c <= '@')\n\treturn c;\n    if (c >= 0x80 || !(cmp_flags & CMP_KEEPASCII))\n    {\n\tif (enc_utf8)\n\t    return utf_tolower(c);\n\tif (c >= 0x100)\n\t{\n#ifdef HAVE_TOWLOWER\n\t    if (has_mbyte)\n\t\treturn towlower(c);\n#endif\n\t    \/\/ tolower() can't handle these chars and may crash\n\t    return c;\n\t}\n\tif (enc_latin1like)\n\t    return latin1lower[c];\n    }\n    if (c < 0x80 && (cmp_flags & CMP_KEEPASCII))\n\treturn TOLOWER_ASC(c);\n    return TOLOWER_LOC(c);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":289270,"func":"static int snd_pcm_oss_set_subdivide(struct snd_pcm_oss_file *pcm_oss_file, int subdivide)\n{\n\tint err = -EINVAL, idx;\n\n\tfor (idx = 1; idx >= 0; --idx) {\n\t\tstruct snd_pcm_substream *substream = pcm_oss_file->streams[idx];\n\t\tstruct snd_pcm_runtime *runtime;\n\n\t\tif (substream == NULL)\n\t\t\tcontinue;\n\t\truntime = substream->runtime;\n\t\terr = lock_params(runtime);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\terr = snd_pcm_oss_set_subdivide1(substream, subdivide);\n\t\tunlock_params(runtime);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn err;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":221689,"func":"int Socket::bind(const std::string &ip, int port) {\n    int len = sizeof my_adr;\n    int i = 1;\n\n    setsockopt(sck, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));\n\n    my_adr.sin_port = htons(port);\n    my_adr.sin_addr.s_addr = inet_addr(ip.c_str());\n    my_port = port;\n\n    return ::bind(sck, (struct sockaddr *) &my_adr, len);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":291846,"func":"int rtrs_clt_remove_path_from_sysfs(struct rtrs_clt_path *clt_path,\n\t\t\t\t     const struct attribute *sysfs_self)\n{\n\tenum rtrs_clt_state old_state;\n\tbool changed;\n\n\t\/*\n\t * Continue stopping path till state was changed to DEAD or\n\t * state was observed as DEAD:\n\t * 1. State was changed to DEAD - we were fast and nobody\n\t *    invoked rtrs_clt_reconnect(), which can again start\n\t *    reconnecting.\n\t * 2. State was observed as DEAD - we have someone in parallel\n\t *    removing the path.\n\t *\/\n\tdo {\n\t\trtrs_clt_close_conns(clt_path, true);\n\t\tchanged = rtrs_clt_change_state_get_old(clt_path,\n\t\t\t\t\t\t\tRTRS_CLT_DEAD,\n\t\t\t\t\t\t\t&old_state);\n\t} while (!changed && old_state != RTRS_CLT_DEAD);\n\n\tif (changed) {\n\t\trtrs_clt_remove_path_from_arr(clt_path);\n\t\trtrs_clt_destroy_path_files(clt_path, sysfs_self);\n\t\tkobject_put(&clt_path->kobj);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":90842,"func":"  void DidGetHostQuota(QuotaStatusCode status,\n                       const std::string& host,\n                       StorageType type,\n                       int64 quota) {\n    quota_status_ = status;\n    host_ = host;\n    type_ = type;\n    quota_ = quota;\n  }\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":242116,"func":"int LuaSettings::gc_object(lua_State* L)\n{\n\tLuaSettings* o = *(LuaSettings **)(lua_touserdata(L, 1));\n\tdelete o;\n\treturn 0;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":463167,"func":"static void annotate_state_finish(annotate_state_t *state)\n{\n    \/* Free the entry list *\/\n    while (state->entry_list) {\n        struct annotate_entry_list *ee = state->entry_list;\n        state->entry_list = ee->next;\n        buf_free(&ee->shared);\n        buf_free(&ee->priv);\n        free(ee->name);\n        free(ee);\n    }\n\n    free_hash_table(&state->entry_table, NULL);\n    free_hash_table(&state->server_table, NULL);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":393521,"func":"static SQInteger class_instance(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_createinstance(v,-1))?1:SQ_ERROR;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":252430,"func":"static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip,\n                                                   const char *pFilename) {\n  mz_zip_internal_state *pState = pZip->m_pState;\n  const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;\n  const mz_zip_array *pCentral_dir = &pState->m_central_dir;\n  mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(\n      &pState->m_sorted_central_dir_offsets, mz_uint32, 0);\n  const int size = pZip->m_total_files;\n  const mz_uint filename_len = (mz_uint)strlen(pFilename);\n  int l = 0, h = size - 1;\n  while (l <= h) {\n    int m = (l + h) >> 1, file_index = pIndices[m],\n        comp =\n            mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets,\n                                           file_index, pFilename, filename_len);\n    if (!comp)\n      return file_index;\n    else if (comp < 0)\n      l = m + 1;\n    else\n      h = m - 1;\n  }\n  return -1;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":221475,"func":"check_sudo (GError **error)\n{\n  const char *sudo_command_env = g_getenv (\"SUDO_COMMAND\");\n  g_auto(GStrv) split_command = NULL;\n\n  \/* This check exists to stop accidental usage of `sudo flatpak run`\n     and is not to prevent running as root.\n   *\/\n\n  if (!sudo_command_env)\n    return TRUE;\n\n  \/* SUDO_COMMAND could be a value like `\/usr\/bin\/flatpak run foo` *\/\n  split_command = g_strsplit (sudo_command_env, \" \", 2);\n  if (g_str_has_suffix (split_command[0], \"flatpak\"))\n    return flatpak_fail_error (error, FLATPAK_ERROR, _(\"\\\"flatpak run\\\" is not intended to be run as `sudo flatpak run`, use `sudo -i` or `su -l` instead and invoke \\\"flatpak run\\\" from inside the new shell\"));\n\n  return TRUE;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":445872,"func":"name_column_sort_func (GtkTreeModel *model,\n\t\t       GtkTreeIter  *a,\n\t\t       GtkTreeIter  *b,\n\t\t       gpointer      user_data)\n{\n\tFileData    *fdata1;\n\tFileData    *fdata2;\n\tGtkSortType  sort_order;\n\tint          result;\n\n\tgtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), NULL, &sort_order);\n\n\tgtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);\n\tgtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);\n\n\tif (file_data_is_dir (fdata1) == file_data_is_dir (fdata2)) {\n\t\tresult = strcmp (fdata1->sort_key, fdata2->sort_key);\n\t}\n\telse {\n        \tresult = file_data_is_dir (fdata1) ? -1 : 1;\n        \tif (sort_order == GTK_SORT_DESCENDING)\n        \t\tresult = -1 * result;\n\t}\n\n\treturn result;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":309960,"func":"_nc_outch(int ch)\n{\n    putc(ch, stdout);\n    return OK;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":233822,"func":"void fmtutil_read_boxes_format(deark *c, struct de_boxesctx *bctx)\n{\n\tif(!bctx->f || !bctx->handle_box_fn) return; \/\/ Internal error\n\tif(bctx->curbox) return; \/\/ Internal error\n\tdo_box_sequence(c, bctx, 0, bctx->f->len, -1, 0);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":338070,"func":"void WasmBinaryWriter::initializeDebugInfo() {\n  lastDebugLocation = {0, \/* lineNumber = *\/ 1, 0};\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":369147,"func":"static inline bool io_alloc_req_refill(struct io_ring_ctx *ctx)\n{\n\tif (unlikely(!ctx->submit_state.free_list.next))\n\t\treturn __io_alloc_req_refill(ctx);\n\treturn true;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":400123,"func":"PortForwardHandler::PortForwardHandler(\n    shared_ptr<SocketHandler> _networkSocketHandler,\n    shared_ptr<SocketHandler> _pipeSocketHandler)\n    : networkSocketHandler(_networkSocketHandler),\n      pipeSocketHandler(_pipeSocketHandler) {}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":261994,"func":"static void bundle_add_conn(struct connectbundle *bundle,\n                            struct connectdata *conn)\n{\n  Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn,\n                         &conn->bundle_node);\n  conn->bundle = bundle;\n  bundle->num_connections++;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":413583,"func":"R_API void r_core_recover_vars(RCore *core, RAnalFunction *fcn, bool argonly) {\n\tr_return_if_fail (core && core->anal && fcn);\n\tif (core->anal->opt.bb_max_size < 1) {\n\t\treturn;\n\t}\n\tBlockRecurseCtx ctx = { 0, {{ 0 }}, argonly, fcn, core };\n\tr_pvector_init (&ctx.reg_set, free);\n\tint *reg_set = R_NEWS0 (int, REG_SET_SIZE);\n\tr_pvector_push (&ctx.reg_set, reg_set);\n\tint saved_stack = fcn->stack;\n\tRAnalBlock *first_bb = r_anal_get_block_at (fcn->anal, fcn->addr);\n\tr_anal_block_recurse_depth_first (first_bb, (RAnalBlockCb)anal_block_cb, (RAnalBlockCb)anal_block_on_exit, &ctx);\n\tr_pvector_fini (&ctx.reg_set);\n\tfcn->stack = saved_stack;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":468359,"func":"on_timer (GCancellable *cancel)\n{\n  g_cancellable_cancel (cancel);\n  return G_SOURCE_REMOVE;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":247132,"func":"Bool gf_fs_is_supported_mime(GF_FilterSession *fsess, const char *mime)\n{\n\tu32 i, count;\n\t\/\/first pass on explicit mimes\n\tcount = gf_list_count(fsess->registry);\n\tfor (i=0; i<count; i++) {\n\t\tu32 j;\n\t\tconst GF_FilterRegister *freg = gf_list_get(fsess->registry, i);\n\t\tfor (j=0; j<freg->nb_caps; j++) {\n\t\t\tconst GF_FilterCapability *acap = &freg->caps[j];\n\t\t\tif (!(acap->flags & GF_CAPFLAG_INPUT)) continue;\n\t\t\tif (acap->code == GF_PROP_PID_MIME) {\n\t\t\t\tif (acap->val.value.string && strstr(acap->val.value.string, mime)) return GF_TRUE;\n\t\t\t}\n\t\t}\n\t}\n\treturn GF_FALSE;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":333088,"func":"list1(\n    nfa_state_T\t**outp)\n{\n    Ptrlist *l;\n\n    l = (Ptrlist *)outp;\n    l->next = NULL;\n    return l;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":468339,"func":"g_socket_client_get_property (GObject    *object,\n\t\t\t      guint       prop_id,\n\t\t\t      GValue     *value,\n\t\t\t      GParamSpec *pspec)\n{\n  GSocketClient *client = G_SOCKET_CLIENT (object);\n\n  switch (prop_id)\n    {\n      case PROP_FAMILY:\n\tg_value_set_enum (value, client->priv->family);\n\tbreak;\n\n      case PROP_TYPE:\n\tg_value_set_enum (value, client->priv->type);\n\tbreak;\n\n      case PROP_PROTOCOL:\n\tg_value_set_enum (value, client->priv->protocol);\n\tbreak;\n\n      case PROP_LOCAL_ADDRESS:\n\tg_value_set_object (value, client->priv->local_address);\n\tbreak;\n\n      case PROP_TIMEOUT:\n\tg_value_set_uint (value, client->priv->timeout);\n\tbreak;\n\n      case PROP_ENABLE_PROXY:\n\tg_value_set_boolean (value, client->priv->enable_proxy);\n\tbreak;\n\n      case PROP_TLS:\n\tg_value_set_boolean (value, g_socket_client_get_tls (client));\n\tbreak;\n\n      case PROP_TLS_VALIDATION_FLAGS:\n\tg_value_set_flags (value, g_socket_client_get_tls_validation_flags (client));\n\tbreak;\n\n      case PROP_PROXY_RESOLVER:\n\tg_value_set_object (value, g_socket_client_get_proxy_resolver (client));\n\tbreak;\n\n      default:\n\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);\n    }\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":292193,"func":"inbound_open_dialog (server *serv, char *from,\n\t\t\t\t\t\t\tconst message_tags_data *tags_data)\n{\n\tsession *sess;\n\n\tsess = new_ircwindow (serv, from, SESS_DIALOG, 0);\n\t\/* for playing sounds *\/\n\tEMIT_SIGNAL_TIMESTAMP (XP_TE_OPENDIALOG, sess, NULL, NULL, NULL, NULL, 0,\n\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\n\treturn sess;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":222671,"func":"static int check_owned_directory_mode(const char *path, mode_t expected_mode)\n{\n\tstruct stat stat;\n\tif (lstat(path, &stat))\n\t\treturn -1;\n\n\tif (!S_ISDIR(stat.st_mode))\n\t\treturn -1;\n\n\tif (stat.st_uid != getuid())\n\t\treturn -1;\n\n\tif ((stat.st_mode & 07777) != expected_mode)\n\t\treturn -1;\n\n\treturn 0;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":512452,"func":"void in_double::set(uint pos,Item *item)\n{\n  ((double*) base)[pos]= item->val_real();\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":273895,"func":"static void handle_OPTS(ctrl_t *ctrl, char *arg)\n{\n\t\/* OPTS MLST type;size;modify;perm; *\/\n\tif (strstr(arg, \"MLST\")) {\n\t\tsize_t i = 0;\n\t\tchar *ptr;\n\t\tchar buf[42] = \"200 MLST OPTS \";\n\t\tchar facts[10] = { 0 };\n\n\t\tptr = strtok(arg + 4, \" \\t;\");\n\t\twhile (ptr && i < sizeof(facts) - 1) {\n\t\t\tif (!strcmp(ptr, \"modify\") ||\n\t\t\t    !strcmp(ptr, \"perm\")   ||\n\t\t\t    !strcmp(ptr, \"size\")   ||\n\t\t\t    !strcmp(ptr, \"type\")) {\n\t\t\t\tfacts[i++] = ptr[0];\n\t\t\t\tstrlcat(buf, ptr, sizeof(buf));\n\t\t\t\tstrlcat(buf, \";\", sizeof(buf));\n\t\t\t}\n\n\t\t\tptr = strtok(NULL, \";\");\n\t\t}\n\t\tstrlcat(buf, \"\\r\\n\", sizeof(buf));\n\n\t\tDBG(\"New MLSD facts: %s\", facts);\n\t\tstrlcpy(ctrl->facts, facts, sizeof(ctrl->facts));\n\t\tsend_msg(ctrl->sd, buf);\n\t} else\n\t\tsend_msg(ctrl->sd, \"200 UTF8 OPTS ON\\r\\n\");\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":393485,"func":"static SQInteger default_delegate_tofloat(HSQUIRRELVM v)\n{\n    SQObjectPtr &o=stack_get(v,1);\n    switch(sq_type(o)){\n    case OT_STRING:{\n        SQObjectPtr res;\n        if(str2num(_stringval(o),res,10)){\n            v->Push(SQObjectPtr(tofloat(res)));\n            break;\n        }}\n        return sq_throwerror(v, _SC(\"cannot convert the string\"));\n        break;\n    case OT_INTEGER:case OT_FLOAT:\n        v->Push(SQObjectPtr(tofloat(o)));\n        break;\n    case OT_BOOL:\n        v->Push(SQObjectPtr((SQFloat)(_integer(o)?1:0)));\n        break;\n    default:\n        v->PushNull();\n        break;\n    }\n    return 1;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":338065,"func":"void WasmBinaryBuilder::readDataSegments() {\n  BYN_TRACE(\"== readDataSegments\\n\");\n  auto num = getU32LEB();\n  for (size_t i = 0; i < num; i++) {\n    Memory::Segment curr;\n    uint32_t flags = getU32LEB();\n    if (flags > 2) {\n      throwError(\"bad segment flags, must be 0, 1, or 2, not \" +\n                 std::to_string(flags));\n    }\n    curr.isPassive = flags & BinaryConsts::IsPassive;\n    if (flags & BinaryConsts::HasIndex) {\n      auto memIndex = getU32LEB();\n      if (memIndex != 0) {\n        throwError(\"nonzero memory index\");\n      }\n    }\n    if (!curr.isPassive) {\n      curr.offset = readExpression();\n    }\n    auto size = getU32LEB();\n    auto data = getByteView(size);\n    curr.data = {data.first, data.second};\n    wasm.memory.segments.push_back(std::move(curr));\n  }\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":387722,"func":"void InstanceKlass::remove_java_mirror() {\n  Klass::remove_java_mirror();\n\n  \/\/ do array classes also.\n  if (array_klasses() != NULL) {\n    array_klasses()->remove_java_mirror();\n  }\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":445970,"func":"extract_data_new (FrWindow    *window,\n\t\t  GList       *file_list,\n\t\t  GFile       *destination,\n\t\t  const char  *base_dir,\n\t\t  gboolean     skip_older,\n\t\t  FrOverwrite  overwrite,\n\t\t  gboolean     junk_paths,\n\t\t  gboolean     extract_here,\n\t\t  gboolean     ask_to_open_destination)\n{\n\tExtractData *edata;\n\n\tedata = g_new0 (ExtractData, 1);\n\tedata->window = window;\n\tedata->file_list = _g_string_list_dup (file_list);\n\tedata->destination = _g_object_ref (destination);\n\tedata->skip_older = skip_older;\n\tedata->overwrite = overwrite;\n\tedata->junk_paths = junk_paths;\n\tif (base_dir != NULL)\n\t\tedata->base_dir = g_strdup (base_dir);\n\tedata->ask_to_open_destination = ask_to_open_destination;\n\n\treturn edata;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":227027,"func":"IRC_PROTOCOL_CALLBACK(345)\n{\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, NULL, command, \"reop\", NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s%s%s: %s\",\n        weechat_prefix (\"network\"),\n        IRC_COLOR_CHAT_CHANNEL,\n        argv[3],\n        IRC_COLOR_RESET,\n        (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":219021,"func":"bool MaybeRemoveControlInput(const string& old_input, NodeDef* node,\n                             GraphDef* graph, NodeMap* node_map) {\n  bool removed_input = false;\n  bool update_node_map = true;\n  const string old_input_ctrl_dep = AsControlDependency(NodeName(old_input));\n  for (int i = 0; i < node->input_size(); ++i) {\n    const string& input = node->input(i);\n    if (old_input_ctrl_dep == input) {\n      if (IsControlInput(input)) {\n        node->mutable_input()->SwapElements(i, node->input_size() - 1);\n        node->mutable_input()->RemoveLast();\n        removed_input = true;\n      } else {\n        \/\/ There is a non-control input from the same node.\n        \/\/ Don't remove the output from the NodeMap.\n        update_node_map = false;\n      }\n    }\n  }\n  if (update_node_map) {\n    node_map->RemoveOutput(NodeName(old_input), node->name());\n  }\n  return removed_input;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":221139,"func":"GF_VPConfig *gf_odf_vp_cfg_read_bs(GF_BitStream *bs, Bool is_v0)\n{\n\tGF_VPConfig *cfg = gf_odf_vp_cfg_new();\n\n\tcfg->profile = gf_bs_read_int(bs, 8);\n\tcfg->level = gf_bs_read_int(bs, 8);\n\n\tcfg->bit_depth = gf_bs_read_int(bs, 4);\n\tcfg->chroma_subsampling = gf_bs_read_int(bs, 3);\n\tcfg->video_fullRange_flag = gf_bs_read_int(bs, 1);\n\n\tcfg->colour_primaries = gf_bs_read_int(bs, 8);\n\tcfg->transfer_characteristics = gf_bs_read_int(bs, 8);\n\tcfg->matrix_coefficients = gf_bs_read_int(bs, 8);\n\n\tif (is_v0)\n\t\treturn cfg;\n\n\tcfg->codec_initdata_size = gf_bs_read_int(bs, 16);\n\n\t\/\/ must be 0 according to spec\n\tif (cfg->codec_initdata_size) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] VP Configuration Box: invalid data, codec_initdata_size must be 0, was %d\\n\", cfg->codec_initdata_size));\n\t\tgf_odf_vp_cfg_del(cfg);\n\t\treturn NULL;\n\t}\n\n\treturn cfg;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":283748,"func":"static uint64_t zynq_slcr_read(void *opaque, hwaddr offset,\n    unsigned size)\n{\n    ZynqSLCRState *s = opaque;\n    offset \/= 4;\n    uint32_t ret = s->regs[offset];\n\n    if (!zynq_slcr_check_offset(offset, true)) {\n        qemu_log_mask(LOG_GUEST_ERROR, \"zynq_slcr: Invalid read access to \"\n                      \" addr %\" HWADDR_PRIx \"\\n\", offset * 4);\n    }\n\n    DB_PRINT(\"addr: %08\" HWADDR_PRIx \" data: %08\" PRIx32 \"\\n\", offset * 4, ret);\n    return ret;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":413631,"func":"static int fcn_list_json(RCore *core, RList *fcns, bool quiet) {\n\tRListIter *iter;\n\tRAnalFunction *fcn;\n\tPJ *pj = r_core_pj_new (core);\n\tif (!pj) {\n\t\tr_cons_println (\"[]\");\n\t\treturn -1;\n\t}\n\tpj_a (pj);\n\tr_list_foreach (fcns, iter, fcn) {\n\t\tif (quiet) {\n\t\t\tpj_n (pj, fcn->addr);\n\t\t} else {\n\t\t\tfcn_print_json (core, fcn, pj);\n\t\t}\n\t}\n\tpj_end (pj);\n\tr_cons_println (pj_string (pj));\n\tpj_free (pj);\n\treturn 0;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":508833,"func":"void st_select_lex_node::init_query()\n{\n  options= 0;\n  sql_cache= SQL_CACHE_UNSPECIFIED;\n  linkage= UNSPECIFIED_TYPE;\n  no_table_names_allowed= 0;\n  uncacheable= 0;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":445915,"func":"fr_window_close (FrWindow *window)\n{\n\tif (window->priv->activity_ref > 0)\n\t\treturn;\n\n\tif (window->priv->closing)\n\t\treturn;\n\n\twindow->priv->closing = TRUE;\n\n\tif (gtk_widget_get_realized (GTK_WIDGET (window))) {\n\t\tint width, height;\n\n\t\twidth = gtk_widget_get_allocated_width (GTK_WIDGET (window));\n\t\theight = gtk_widget_get_allocated_height (GTK_WIDGET (window));\n\t\tg_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH, width);\n\t\tg_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT, height);\n\n\t\twidth = gtk_paned_get_position (GTK_PANED (window->priv->paned));\n\t\tif (width > 0)\n\t\t\tg_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH, width);\n\n\t\twidth = gtk_tree_view_column_get_width (window->priv->filename_column);\n\t\tif (width > 0)\n\t\t\tg_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH, width);\n\t}\n\n\tgtk_widget_destroy (GTK_WIDGET (window));\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":229260,"func":"    const char* what() const throw () override {\n        return \"bad cql binary frame\";\n    }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":308194,"func":"static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)\n{\n\tstruct fastrpc_invoke_args *args = NULL;\n\tstruct fastrpc_invoke inv;\n\tu32 nscalars;\n\tint err;\n\n\tif (copy_from_user(&inv, argp, sizeof(inv)))\n\t\treturn -EFAULT;\n\n\t\/* nscalars is truncated here to max supported value *\/\n\tnscalars = REMOTE_SCALARS_LENGTH(inv.sc);\n\tif (nscalars) {\n\t\targs = kcalloc(nscalars, sizeof(*args), GFP_KERNEL);\n\t\tif (!args)\n\t\t\treturn -ENOMEM;\n\n\t\tif (copy_from_user(args, (void __user *)(uintptr_t)inv.args,\n\t\t\t\t   nscalars * sizeof(*args))) {\n\t\t\tkfree(args);\n\t\t\treturn -EFAULT;\n\t\t}\n\t}\n\n\terr = fastrpc_internal_invoke(fl, false, inv.handle, inv.sc, args);\n\tkfree(args);\n\n\treturn err;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":462317,"func":"pcl_echo(pcl_args_t * pargs, pcl_state_t * pcs)\n{\n    stream st;\n\n    status_begin(&st, pcs);\n    stprintf(&st, \"ECHO %d\\r\\n\", int_arg(pargs));\n    status_end(&st, pcs);\n    return 0;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":218770,"func":"static size_t WriteCompressionStart(const PSDInfo *psd_info,Image *image,\n  const Image *next_image,const ssize_t channels)\n{\n  ssize_t\n    i,\n    offset,\n    y;\n\n  if (next_image->compression == RLECompression)\n    {\n      offset=WriteBlobMSBShort(image,RLE);\n      for (i=0; i < channels; i++)\n        for (y=0; y < (ssize_t) next_image->rows; y++)\n          offset+=SetPSDOffset(psd_info,image,0);\n    }\n#ifdef MAGICKCORE_ZLIB_DELEGATE\n  else if (next_image->compression == ZipCompression)\n    offset=WriteBlobMSBShort(image,ZipWithoutPrediction);\n#endif\n  else\n    offset=WriteBlobMSBShort(image,Raw);\n  return((size_t) offset);\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":286730,"func":"size_t SWTPM_NVRAM_MigrationKey_Size(void)\n{\n    return migrationkey.symkey.userKeyLength;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":369216,"func":"\nstatic int io_rsrc_node_switch_start(struct io_ring_ctx *ctx)\n{\n\tif (ctx->rsrc_backup_node)\n\t\treturn 0;\n\tctx->rsrc_backup_node = io_rsrc_node_alloc();\n\treturn ctx->rsrc_backup_node ? 0 : -ENOMEM;","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":317051,"func":"static int file_has_perm(const struct cred *cred,\n\t\t\t struct file *file,\n\t\t\t u32 av)\n{\n\tstruct file_security_struct *fsec = selinux_file(file);\n\tstruct inode *inode = file_inode(file);\n\tstruct common_audit_data ad;\n\tu32 sid = cred_sid(cred);\n\tint rc;\n\n\tad.type = LSM_AUDIT_DATA_FILE;\n\tad.u.file = file;\n\n\tif (sid != fsec->sid) {\n\t\trc = avc_has_perm(&selinux_state,\n\t\t\t\t  sid, fsec->sid,\n\t\t\t\t  SECCLASS_FD,\n\t\t\t\t  FD__USE,\n\t\t\t\t  &ad);\n\t\tif (rc)\n\t\t\tgoto out;\n\t}\n\n#ifdef CONFIG_BPF_SYSCALL\n\trc = bpf_fd_pass(file, cred_sid(cred));\n\tif (rc)\n\t\treturn rc;\n#endif\n\n\t\/* av is zero if only checking access to the descriptor. *\/\n\trc = 0;\n\tif (av)\n\t\trc = inode_has_perm(cred, inode, av, &ad);\n\nout:\n\treturn rc;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":273062,"func":"keyval_add(struct keyval *kv, const char *name, const char *value)\n{\n  return keyval_add_size(kv, name, value, strlen(value));\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":387787,"func":"void InstanceKlass::clean_method_data() {\n  for (int m = 0; m < methods()->length(); m++) {\n    MethodData* mdo = methods()->at(m)->method_data();\n    if (mdo != NULL) {\n      MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : mdo->extra_data_lock());\n      mdo->clean_method_data(\/*always_clean*\/false);\n    }\n  }\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":415184,"func":"scd_update_reader_status_file (void)\n{\n  int err;\n  err = npth_mutex_lock (&status_file_update_lock);\n  if (err)\n    return; \/* locked - give up. *\/\n  update_reader_status_file (1);\n  err = npth_mutex_unlock (&status_file_update_lock);\n  if (err)\n    log_error (\"failed to release status_file_update lock: %s\\n\",\n\t       strerror (err));\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":359839,"func":"static inline void ReadTIM2ImageHeader(Image *image,TIM2ImageHeader *header)\n{\n  header->total_size=ReadBlobLSBLong(image);\n  header->clut_size=ReadBlobLSBLong(image);\n  header->image_size=ReadBlobLSBLong(image);\n  header->header_size=ReadBlobLSBShort(image);\n\n  header->clut_color_count=ReadBlobLSBShort(image);\n  header->img_format=(unsigned char) ReadBlobByte(image);\n  header->mipmap_count=(unsigned char) ReadBlobByte(image);\n  header->clut_type=(unsigned char) ReadBlobByte(image);\n  header->bpp_type=(unsigned char) ReadBlobByte(image);\n\n  header->width=ReadBlobLSBShort(image);\n  header->height=ReadBlobLSBShort(image);\n\n  header->GsTex0=ReadBlobMSBLongLong(image);\n  header->GsTex1=ReadBlobMSBLongLong(image);\n  header->GsRegs=ReadBlobMSBLong(image);\n  header->GsTexClut=ReadBlobMSBLong(image);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":252301,"func":"mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf,\n                                            size_t *pSize) {\n  if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) return MZ_FALSE;\n  if (pZip->m_pWrite != mz_zip_heap_write_func) return MZ_FALSE;\n  if (!mz_zip_writer_finalize_archive(pZip)) return MZ_FALSE;\n\n  *pBuf = pZip->m_pState->m_pMem;\n  *pSize = pZip->m_pState->m_mem_size;\n  pZip->m_pState->m_pMem = NULL;\n  pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0;\n  return MZ_TRUE;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":500643,"func":"void sftp_free(sftp_session sftp){\n  sftp_request_queue ptr;\n\n  if (sftp == NULL) {\n    return;\n  }\n\n  ssh_channel_send_eof(sftp->channel);\n  ptr = sftp->queue;\n  while(ptr) {\n    sftp_request_queue old;\n    sftp_message_free(ptr->message);\n    old = ptr->next;\n    SAFE_FREE(ptr);\n    ptr = old;\n  }\n\n  ssh_channel_free(sftp->channel);\n  sftp_ext_free(sftp->ext);\n  ZERO_STRUCTP(sftp);\n\n  SAFE_FREE(sftp);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":212688,"func":"int hci_conn_check_link_mode(struct hci_conn *conn)\n{\n\tBT_DBG(\"hcon %p\", conn);\n\n\t\/* In Secure Connections Only mode, it is required that Secure\n\t * Connections is used and the link is encrypted with AES-CCM\n\t * using a P-256 authenticated combination key.\n\t *\/\n\tif (hci_dev_test_flag(conn->hdev, HCI_SC_ONLY)) {\n\t\tif (!hci_conn_sc_enabled(conn) ||\n\t\t    !test_bit(HCI_CONN_AES_CCM, &conn->flags) ||\n\t\t    conn->key_type != HCI_LK_AUTH_COMBINATION_P256)\n\t\t\treturn 0;\n\t}\n\n\tif (hci_conn_ssp_enabled(conn) &&\n\t    !test_bit(HCI_CONN_ENCRYPT, &conn->flags))\n\t\treturn 0;\n\n\treturn 1;\n}","target":1,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":472371,"func":"bool ciEnv::cache_jvmti_state() {\n  VM_ENTRY_MARK;\n  \/\/ Get Jvmti capabilities under lock to get consistant values.\n  MutexLocker mu(JvmtiThreadState_lock);\n  _jvmti_redefinition_count             = JvmtiExport::redefinition_count();\n  _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();\n  _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();\n  _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();\n  _jvmti_can_pop_frame                  = JvmtiExport::can_pop_frame();\n  _jvmti_can_get_owned_monitor_info     = JvmtiExport::can_get_owned_monitor_info();\n  _jvmti_can_walk_any_space             = JvmtiExport::can_walk_any_space();\n  return _task != NULL && _task->method()->is_old();\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":512709,"func":"void in_datetime::set(uint pos,Item *item)\n{\n  struct packed_longlong *buff= &((packed_longlong*) base)[pos];\n\n  buff->val= item->val_datetime_packed(current_thd);\n  buff->unsigned_flag= 1L;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":453027,"func":"static void nft_indr_block_cleanup(struct flow_block_cb *block_cb)\n{\n\tstruct nft_base_chain *basechain = block_cb->indr.data;\n\tstruct net_device *dev = block_cb->indr.dev;\n\tstruct netlink_ext_ack extack = {};\n\tstruct nftables_pernet *nft_net;\n\tstruct net *net = dev_net(dev);\n\tstruct flow_block_offload bo;\n\n\tnft_flow_block_offload_init(&bo, dev_net(dev), FLOW_BLOCK_UNBIND,\n\t\t\t\t    basechain, &extack);\n\tnft_net = nft_pernet(net);\n\tmutex_lock(&nft_net->commit_mutex);\n\tlist_del(&block_cb->driver_list);\n\tlist_move(&block_cb->list, &bo.cb_list);\n\tnft_flow_offload_unbind(&bo, basechain);\n\tmutex_unlock(&nft_net->commit_mutex);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":274675,"func":"analyze_window_size_restore(GtkWidget *win)\n{\n\tGVariant *var;\n\tconst gint32 *xy;\n\tgsize num;\n\n\tif (!screen.settings)\n\t\treturn;\n\n\tvar = g_settings_get_value (screen.settings, \"analyze-window-size\");\n\txy = g_variant_get_fixed_array (var, &num, sizeof (*xy));\n\tif (num == 2)\n\t\tgtk_window_set_default_size (GTK_WINDOW (win), xy[0], xy[1]);\n\tg_variant_unref (var);\n\n\tvar = g_settings_get_value (screen.settings, \"analyze-window-position\");\n\txy = g_variant_get_fixed_array (var, &num, sizeof (*xy));\n\tif (num == 2)\n\t\tgtk_window_move (GTK_WINDOW (win), xy[0], xy[1]);\n\tg_variant_unref (var);\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":513174,"func":"static st_bookmark *find_bookmark(const char *plugin, const char *name,\n                                  int flags)\n{\n  st_bookmark *result= NULL;\n  uint namelen, length, pluginlen= 0;\n  char *varname, *p;\n\n  if (!(flags & PLUGIN_VAR_THDLOCAL))\n    return NULL;\n\n  namelen= strlen(name);\n  if (plugin)\n    pluginlen= strlen(plugin) + 1;\n  length= namelen + pluginlen + 2;\n  varname= (char*) my_alloca(length);\n\n  if (plugin)\n  {\n    strxmov(varname + 1, plugin, \"_\", name, NullS);\n    for (p= varname + 1; *p; p++)\n      if (*p == '-')\n        *p= '_';\n  }\n  else\n    memcpy(varname + 1, name, namelen + 1);\n\n  varname[0]= plugin_var_bookmark_key(flags);\n\n  result= (st_bookmark*) my_hash_search(&bookmark_hash,\n                                        (const uchar*) varname, length - 1);\n\n  my_afree(varname);\n  return result;\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":256954,"func":"  static Status RecordLabelToDimension(const int label, const int axis,\n                                       const Tensor& input,\n                                       LabelToDimSizes* label_to_dim_sizes) {\n    const int64_t input_dim = input.dim_size(axis);\n    \/\/ We know that label_to_dim_sizes has the size to accommodate named labels.\n    if (label_to_dim_sizes->at(label) != 0 &&\n        label_to_dim_sizes->at(label) != input_dim) {\n      return errors::InvalidArgument(\n          \"Expected dimension \", label_to_dim_sizes->at(label), \" at axis \",\n          axis, \" of the input shaped \", input.shape().DebugString(),\n          \" but got dimension \", input_dim);\n    }\n    (*label_to_dim_sizes)[label] = input_dim;\n    return Status::OK();\n  }","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":256456,"func":"Janet janet_array_pop(JanetArray *array) {\n    if (array->count) {\n        return array->data[--array->count];\n    } else {\n        return janet_wrap_nil();\n    }\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":229266,"func":"cql_server::response::placeholder<int32_t> cql_server::response::write_int_placeholder() {\n    return placeholder<int32_t>(_body.write_place_holder(sizeof(int32_t)));\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":459508,"func":"static inline bool stack_map_use_build_id(struct bpf_map *map)\n{\n\treturn (map->map_flags & BPF_F_STACK_BUILD_ID);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":409500,"func":"term_cursor_shape(int shape, int blink)\n{\n    if (*T_CSH != NUL)\n    {\n\tOUT_STR(tgoto((char *)T_CSH, 0, shape * 2 - blink));\n\tout_flush();\n    }\n    else\n    {\n\tint do_blink = blink;\n\n\t\/\/ t_SH is empty: try setting just the blink state.\n\t\/\/ The blink flags are XORed together, if the initial blinking from\n\t\/\/ style and shape differs, we need to invert the flag here.\n\tif (blink_state_is_inverted())\n\t    do_blink = !blink;\n\n\tif (do_blink && *T_VS != NUL)\n\t{\n\t    out_str(T_VS);\n\t    out_flush();\n\t}\n\telse if (!do_blink && *T_CVS != NUL)\n\t{\n\t    out_str(T_CVS);\n\t    out_flush();\n\t}\n    }\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":310064,"func":"is_sgr_string(char *value)\n{\n    bool result = FALSE;\n\n    if (VALID_STRING(value)) {\n\tint skip = csi_length(value);\n\n\tif (skip) {\n\t    int ch;\n\n\t    result = TRUE;\n\t    value += skip;\n\t    while ((ch = UChar(*value++)) != '\\0') {\n\t\tif (isdigit(ch) || ch == ';') {\n\t\t    ;\n\t\t} else if (ch == 'm' && *value == '\\0') {\n\t\t    ;\n\t\t} else {\n\t\t    result = FALSE;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n    }\n    return result;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":254731,"func":"njs_typed_array_prototype_buffer(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    njs_value_t        *this;\n    njs_typed_array_t  *array;\n\n    this = njs_argument(args, 0);\n    if (!njs_is_typed_array(this) && !njs_is_data_view(this)) {\n        njs_type_error(vm, \"Method TypedArray.prototype.buffer called \"\n                       \"on incompatible receiver\");\n        return NJS_ERROR;\n    }\n\n    array = njs_typed_array(this);\n\n    njs_set_array_buffer(&vm->retval, njs_typed_array_buffer(array));\n\n    return NJS_OK;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":226234,"func":"GF_Box *tssy_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TimeStampSynchronyBox, GF_ISOM_BOX_TYPE_TSSY);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":359419,"func":"DEFUN (clear_ip_bgp_peer_group_soft_out,\n       clear_ip_bgp_peer_group_soft_out_cmd, \n       \"clear ip bgp peer-group WORD soft out\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all members of peer-group\\n\"\n       \"BGP peer-group name\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,\n\t\t\tBGP_CLEAR_SOFT_OUT, argv[0]);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":359407,"func":"DEFUN (no_ip_extcommunity_list_name_expanded_all,\n       no_ip_extcommunity_list_name_expanded_all_cmd,\n       \"no ip extcommunity-list expanded WORD\",\n       NO_STR\n       IP_STR\n       EXTCOMMUNITY_LIST_STR\n       \"Specify expanded extcommunity-list\\n\"\n       \"Extended Community list name\\n\")\n{\n  return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":240610,"func":"  explicit VarIsInitializedOp(OpKernelConstruction* c) : OpKernel(c) {}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":397643,"func":"static short ToS(unsigned char *puffer)\n{\n  return ((short)(puffer[0] | puffer[1] << 8));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":225499,"func":"const MutableGraphView::OutputPort MutableGraphView::GetRegularFanin(\n    const GraphView::InputPort& port) const {\n  return GetRegularFanin(MutableGraphView::InputPort(\n      const_cast<NodeDef*>(port.node), port.port_id));\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":432199,"func":"uint64_t memory_region_size(MemoryRegion *mr)\n{\n    if (int128_eq(mr->size, int128_2_64())) {\n        return UINT64_MAX;\n    }\n    return int128_get64(mr->size);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":500651,"func":"static sftp_request_queue request_queue_new(sftp_message msg) {\n  sftp_request_queue queue = NULL;\n\n  queue = malloc(sizeof(struct sftp_request_queue_struct));\n  if (queue == NULL) {\n    ssh_set_error_oom(msg->sftp->session);\n    return NULL;\n  }\n  ZERO_STRUCTP(queue);\n\n  queue->message = msg;\n\n  return queue;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":281133,"func":"static void xfrm_init_pmtu(struct dst_entry *dst)\n{\n\tdo {\n\t\tstruct xfrm_dst *xdst = (struct xfrm_dst *)dst;\n\t\tu32 pmtu, route_mtu_cached;\n\n\t\tpmtu = dst_mtu(dst->child);\n\t\txdst->child_mtu_cached = pmtu;\n\n\t\tpmtu = xfrm_state_mtu(dst->xfrm, pmtu);\n\n\t\troute_mtu_cached = dst_mtu(xdst->route);\n\t\txdst->route_mtu_cached = route_mtu_cached;\n\n\t\tif (pmtu > route_mtu_cached)\n\t\t\tpmtu = route_mtu_cached;\n\n\t\tdst_metric_set(dst, RTAX_MTU, pmtu);\n\t} while ((dst = dst->next));\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":336505,"func":"static void reds_set_one_channel_security(RedsState *reds, int id, uint32_t security)\n{\n    ChannelSecurityOptions *security_options;\n\n    if ((security_options = reds_find_channel_security(reds, id))) {\n        security_options->options = security;\n        return;\n    }\n    security_options = g_new(ChannelSecurityOptions, 1);\n    security_options->channel_id = id;\n    security_options->options = security;\n    security_options->next = reds->config->channels_security;\n    reds->config->channels_security = security_options;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":508852,"func":"void lex_end(LEX *lex)\n{\n  DBUG_ENTER(\"lex_end\");\n  DBUG_PRINT(\"enter\", (\"lex: %p\", lex));\n\n  lex_unlock_plugins(lex);\n  lex_end_nops(lex);\n\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":259083,"func":"  bool should_run_in_pool(BundleReader* reader) const {\n    TensorShape restored_full_shape;\n\n    \/\/ Ignore status here; we'll catch the error later.\n    if (!reader->LookupTensorShape(tensor_name, &restored_full_shape).ok()) {\n      return false;\n    }\n\n    return restored_full_shape.num_elements() > kLargeShapeThreshold;\n  }","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":338101,"func":"bool WasmBinaryBuilder::maybeVisitMemoryFill(Expression*& out, uint32_t code) {\n  if (code != BinaryConsts::MemoryFill) {\n    return false;\n  }\n  auto* curr = allocator.alloc<MemoryFill>();\n  curr->size = popNonVoidExpression();\n  curr->value = popNonVoidExpression();\n  curr->dest = popNonVoidExpression();\n  if (getInt8() != 0) {\n    throwError(\"Unexpected nonzero memory index\");\n  }\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":512267,"func":"int Arg_comparator::compare_e_str_json()\n{\n  return compare_e_json_str_basic(*b, *a);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":409441,"func":"req_codes_from_term(void)\n{\n    xt_index_out = 0;\n    xt_index_in = 0;\n    req_more_codes_from_term();\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":255939,"func":"ShapeRefiner::ShapeRefiner(int graph_def_version,\n                           const OpRegistryInterface* ops)\n    : graph_def_version_(graph_def_version),\n      ops_registry_(ops),\n      graph_runner_(Env::Default()) {}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":317329,"func":"static void smack_file_set_fowner(struct file *file)\n{\n\tstruct smack_known **blob = smack_file(file);\n\n\t*blob = smk_of_current();\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":430437,"func":"static void __ovs_nla_free_flow_actions(struct rcu_head *head)\n{\n\tovs_nla_free_flow_actions(container_of(head, struct sw_flow_actions, rcu));\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":226120,"func":"\nvoid extr_box_del(GF_Box *s)\n{\n\tGF_ExtraDataBox *ptr = (GF_ExtraDataBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->feci) gf_isom_box_del((GF_Box*)ptr->feci);\n\tif (ptr->data) gf_free(ptr->data);\n\tgf_free(ptr);","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":513101,"func":"void Item_func_not::print(String *str, enum_query_type query_type)\n{\n  str->append('!');\n  args[0]->print_parenthesised(str, query_type, precedence());\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":387644,"func":"static inline void add_hash_entries(struct snd_card *card,\n\t\t\t\t    struct snd_kcontrol *kcontrol)\n{\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":436152,"func":"\nvoid __io_uring_cancel(struct files_struct *files)\n{\n\tio_uring_cancel_generic(!files, NULL);","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":224173,"func":"  std::size_t get_tuple_bytes(const OptionalTuple& tuple) {\n    return std::accumulate(\n        tuple.begin(), tuple.end(), static_cast<std::size_t>(0),\n        [](const std::size_t& lhs, const OptionalTensor& rhs) {\n          return (lhs + rhs.has_value()) ? rhs.value().TotalBytes() : 0;\n        });\n  }","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":247340,"func":"pgpDig pgpFreeDig(pgpDig dig)\n{\n    if (dig != NULL) {\n\n\t\/* DUmp the signature\/pubkey data. *\/\n\tpgpCleanDig(dig);\n\tdig = _free(dig);\n    }\n    return dig;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":253560,"func":"smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)\n{\n\tstruct TCP_Server_Info *server = tcon->ses->server;\n\tunsigned int rsize;\n\n\t\/* start with specified rsize, or default *\/\n\trsize = ctx->rsize ? ctx->rsize : CIFS_DEFAULT_IOSIZE;\n\trsize = min_t(unsigned int, rsize, server->max_read);\n\n\tif (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))\n\t\trsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);\n\n\treturn rsize;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":463066,"func":"static void sungem_eval_irq(SunGEMState *s)\n{\n    uint32_t stat, mask;\n\n    mask = s->gregs[GREG_IMASK >> 2];\n    stat = s->gregs[GREG_STAT >> 2] & ~GREG_STAT_TXNR;\n    if (stat & ~mask) {\n        pci_set_irq(PCI_DEVICE(s), 1);\n    } else {\n        pci_set_irq(PCI_DEVICE(s), 0);\n    }\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":221414,"func":"void svm_free_nested(struct vcpu_svm *svm)\n{\n\tif (!svm->nested.initialized)\n\t\treturn;\n\n\tsvm_vcpu_free_msrpm(svm->nested.msrpm);\n\tsvm->nested.msrpm = NULL;\n\n\t__free_page(virt_to_page(svm->nested.vmcb02.ptr));\n\tsvm->nested.vmcb02.ptr = NULL;\n\n\t\/*\n\t * When last_vmcb12_gpa matches the current vmcb12 gpa,\n\t * some vmcb12 fields are not loaded if they are marked clean\n\t * in the vmcb12, since in this case they are up to date already.\n\t *\n\t * When the vmcb02 is freed, this optimization becomes invalid.\n\t *\/\n\tsvm->nested.last_vmcb12_gpa = INVALID_GPA;\n\n\tsvm->nested.initialized = false;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":220447,"func":"ary_dup(mrb_state *mrb, struct RArray *a)\n{\n  return ary_new_from_values(mrb, ARY_LEN(a), ARY_PTR(a));\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":232941,"func":"char *Curl_all_content_encodings(void)\n{\n  return strdup(CONTENT_ENCODING_DEFAULT);  \/* Satisfy caller. *\/\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":233935,"func":"void DocumentSourceUnionWith::recordPlanSummaryStats(const Pipeline& pipeline) {\n    for (auto&& source : pipeline.getSources()) {\n        if (auto specificStats = source->getSpecificStats()) {\n            specificStats->accumulate(_stats.planSummaryStats);\n        }\n    }\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":240288,"func":"get_expr_line_src(void)\n{\n    if (expr_line == NULL)\n\treturn NULL;\n    return vim_strsave(expr_line);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":275514,"func":"njs_vm_retval_set(njs_vm_t *vm, const njs_value_t *value)\n{\n    vm->retval = *value;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":222513,"func":"uint64 FunctionDefHash(const FunctionDef& fdef) {\n  \/\/ signature\n  uint64 h = OpDefHash(fdef.signature());\n\n  \/\/ attrs\n  std::map<string, AttrValue> attrs = GetSetAttrs(fdef);\n  for (const auto& p : attrs) {\n    h = Hash64(p.first.data(), p.first.size(), h);\n    h = Hash64Combine(AttrValueHash(p.second), h);\n  }\n\n  \/\/ node defs\n  h = Hash64Combine(RepeatedNodeDefHash(fdef.node_def()), h);\n\n  \/\/ output names\n  std::map<string, string> ret(fdef.ret().begin(), fdef.ret().end());\n  for (const auto& p : ret) {\n    h = Hash64(p.first.data(), p.first.size(), h);\n    h = Hash64(p.second.data(), p.second.size(), h);\n  }\n\n  \/\/ control output names\n  std::map<string, string> control_ret(fdef.control_ret().begin(),\n                                       fdef.control_ret().end());\n  for (const auto& p : control_ret) {\n    h = Hash64(p.first.data(), p.first.size(), h);\n    h = Hash64(p.second.data(), p.second.size(), h);\n  }\n\n  return h;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":224157,"func":"  Status pop(const KeyType* key, const Tensor* indices, Tuple* tuple) {\n    tensorflow::mutex_lock lock(mu_);\n\n    \/\/ Sanity check the indices\n    TF_RETURN_IF_ERROR(check_index_ordering(*indices));\n\n    typename MapType::iterator it;\n\n    \/\/ Wait until the element with the requested key is present\n    while ((it = map_.find(*key)) == map_.end()) {\n      not_empty_.wait(lock);\n    }\n\n    TF_RETURN_IF_ERROR(\n        copy_or_move_tensors(&it->second, *key, *indices, tuple));\n\n    \/\/ Remove entry if all the values have been consumed\n    if (!std::any_of(\n            it->second.begin(), it->second.end(),\n            [](const OptionalTensor& tensor) { return tensor.has_value(); })) {\n      map_.erase(it);\n    }\n\n    \/\/ Update bytes in the Staging Area\n    current_bytes_ -= get_tuple_bytes(*tuple);\n\n    notify_inserters_if_bounded();\n\n    return Status::OK();\n  }","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":436150,"func":"\nstatic int io_files_update(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct io_uring_rsrc_update2 up;\n\tint ret;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tup.offset = req->rsrc_update.offset;\n\tup.data = req->rsrc_update.arg;\n\tup.nr = 0;\n\tup.tags = 0;\n\tup.resv = 0;\n\n\tmutex_lock(&ctx->uring_lock);\n\tret = __io_register_rsrc_update(ctx, IORING_RSRC_FILE,\n\t\t\t\t\t&up, req->rsrc_update.nr_args);\n\tmutex_unlock(&ctx->uring_lock);\n\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":230386,"func":"static void on_syntax_error(struct pj_scanner *scanner)\n{\n    PJ_UNUSED_ARG(scanner);\n    PJ_THROW(EX_SYNTAX_ERROR);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":395076,"func":"redraw_later(int type)\n{\n    redraw_win_later(curwin, type);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":326107,"func":"regnext(char_u *p)\n{\n    int\t    offset;\n\n    if (p == JUST_CALC_SIZE || reg_toolong)\n\treturn NULL;\n\n    offset = NEXT(p);\n    if (offset == 0)\n\treturn NULL;\n\n    if (OP(p) == BACK)\n\treturn p - offset;\n    else\n\treturn p + offset;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":225406,"func":"static void buffer_written(struct v4l2_loopback_device *dev,\n\t\t\t   struct v4l2l_buffer *buf)\n{\n\tdel_timer_sync(&dev->sustain_timer);\n\tdel_timer_sync(&dev->timeout_timer);\n\tspin_lock_bh(&dev->lock);\n\n\tdev->bufpos2index[dev->write_position % dev->used_buffers] =\n\t\tbuf->buffer.index;\n\tlist_move_tail(&buf->list_head, &dev->outbufs_list);\n\t++dev->write_position;\n\tdev->reread_count = 0;\n\n\tcheck_timers(dev);\n\tspin_unlock_bh(&dev->lock);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":312402,"func":"qf_process_qftf_option(void)\n{\n    return option_set_callback_func(p_qftf, &qftf_cb);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":385838,"func":"COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, compat_off_t, length)\n{\n\treturn do_sys_truncate(path, length);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":312425,"func":"qf_parse_fmt_l(regmatch_T *rmp, int midx, qffields_T *fields)\n{\n    if (rmp->startp[midx] == NULL)\n\treturn QF_FAIL;\n    fields->lnum = atol((char *)rmp->startp[midx]);\n    return QF_OK;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":341821,"func":"zstringmatch(i_ctx_t *i_ctx_p)\n{\n    os_ptr op = osp;\n    os_ptr op1 = op - 1;\n    bool result;\n\n    check_read_type(*op, t_string);\n    switch (r_type(op1)) {\n        case t_string:\n            check_read(*op1);\n            goto cmp;\n        case t_name:\n            name_string_ref(imemory, op1, op1);\t\/* can't fail *\/\ncmp:\n            result = string_match(op1->value.const_bytes, r_size(op1),\n                                  op->value.const_bytes, r_size(op),\n                                  NULL);\n            break;\n        default:\n            result = (r_size(op) == 1 && *op->value.bytes == '*');\n    }\n    make_bool(op1, result);\n    pop(1);\n    return 0;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":310274,"func":"dirserv_get_name_status(const char *id_digest, const char *nickname)\n{\n  char fp[HEX_DIGEST_LEN+1];\n  char *fp_by_name;\n\n  base16_encode(fp, sizeof(fp), id_digest, DIGEST_LEN);\n\n  if ((fp_by_name =\n       strmap_get_lc(fingerprint_list->fp_by_name, nickname))) {\n    if (!strcasecmp(fp, fp_by_name)) {\n      return FP_NAMED;\n    } else {\n      return FP_UNNAMED; \/* Wrong fingerprint. *\/\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":508847,"func":"void Lex_input_stream::body_utf8_append(const char *ptr,\n                                        const char *end_ptr)\n{\n  DBUG_ASSERT(m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length);\n  DBUG_ASSERT(m_cpp_buf <= end_ptr && end_ptr <= m_cpp_buf + m_buf_length);\n\n  if (!m_body_utf8)\n    return;\n\n  if (m_cpp_utf8_processed_ptr >= ptr)\n    return;\n\n  size_t bytes_to_copy= ptr - m_cpp_utf8_processed_ptr;\n\n  memcpy(m_body_utf8_ptr, m_cpp_utf8_processed_ptr, bytes_to_copy);\n  m_body_utf8_ptr += bytes_to_copy;\n  *m_body_utf8_ptr= 0;\n\n  m_cpp_utf8_processed_ptr= end_ptr;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":345122,"func":"static void pxa3xx_gcu_debug_timedout(struct timer_list *unused)\n{\n\tstruct pxa3xx_gcu_priv *priv = debug_timer_priv;\n\n\tQERROR(\"Timer DUMP\");\n\n\tmod_timer(&pxa3xx_gcu_debug_timer, jiffies + 5 * HZ);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":473937,"func":"get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t\t\t       const OnigUChar* p, const OnigUChar* end,\n\t\t\t\t       OnigCaseFoldCodeItem items[],\n\t\t\t\t       OnigEncoding enc ARG_UNUSED)\n{\n  return onigenc_get_case_fold_codes_by_str_with_map(\n\t     sizeof(CaseFoldMap)\/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,\n\t     flag, p, end, items);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":366215,"func":"bool legitimize_mnt(struct vfsmount *bastard, unsigned seq)\n{\n\tint res = __legitimize_mnt(bastard, seq);\n\tif (likely(!res))\n\t\treturn true;\n\tif (unlikely(res < 0)) {\n\t\trcu_read_unlock();\n\t\tmntput(bastard);\n\t\trcu_read_lock();\n\t}\n\treturn false;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":386582,"func":"bool DL_Dxf::getStrippedLine(std::string& s, unsigned int size, FILE *fp, bool stripSpace) {\n    if (!feof(fp)) {\n        \/\/ The whole line in the file.  Includes space for NULL.\n        char* wholeLine = new char[size];\n        \/\/ Only the useful part of the line\n        char* line;\n\n        line = fgets(wholeLine, size, fp);\n\n        if (line!=NULL && line[0] != '\\0') { \/\/ Evaluates to fgets() retval\n            \/\/ line == wholeLine at this point.\n            \/\/ Both guaranteed to be NULL terminated.\n\n            \/\/ Strip leading whitespace and trailing CR\/LF.\n            stripWhiteSpace(&line, stripSpace);\n\n            s = line;\n            assert(size > s.length());\n        }\n\n        delete[] wholeLine; \/\/ Done with wholeLine\n\n        return true;\n    } else {\n        s = \"\";\n        return false;\n    }\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":276964,"func":"    ~EncryptingStream() {\n        m_Output->Release();\n        delete m_StreamCipher;\n    }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":259218,"func":"static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, unsigned int* allocated_size,\n                              int count, int duration)\n{\n    MOVCtts *ctts_buf_new;\n    const size_t min_size_needed = (*ctts_count + 1) * sizeof(MOVCtts);\n    const size_t requested_size =\n        min_size_needed > *allocated_size ?\n        FFMAX(min_size_needed, 2 * (*allocated_size)) :\n        min_size_needed;\n\n    if ((unsigned)(*ctts_count) >= UINT_MAX \/ sizeof(MOVCtts) - 1)\n        return -1;\n\n    ctts_buf_new = av_fast_realloc(*ctts_data, allocated_size, requested_size);\n\n    if (!ctts_buf_new)\n        return -1;\n\n    *ctts_data = ctts_buf_new;\n\n    ctts_buf_new[*ctts_count].count = count;\n    ctts_buf_new[*ctts_count].duration = duration;\n\n    *ctts_count = (*ctts_count) + 1;\n    return *ctts_count;\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":220173,"func":"uint64 InputTensor::Hash::operator()(InputTensor const& s) const {\n  return Hash64Combine(std::hash<const Node*>()(s.node),\n                       std::hash<int>()(s.index));\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":274724,"func":"callbacks_change_layer_color_clicked  (GtkButton *button, gpointer   user_data) {\n\tgint index=callbacks_get_selected_row_index();\n\tif (index < 0) {\n\t\tshow_no_layers_warning ();\n\t\treturn;\n\t}\n\tcallbacks_show_color_picker_dialog (index);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":462316,"func":"pcl_status_read(byte * data, uint max_data, pcl_state_t * pcs)\n{\n    uint count = min(max_data,\n                     pcs->status.write_pos - pcs->status.read_pos);\n\n    if (count)\n        memcpy(data, pcs->status.buffer + pcs->status.read_pos, count);\n    pcs->status.read_pos += count;\n    if (pcs->status.read_pos == pcs->status.write_pos) {\n        gs_free_object(pcs->memory, pcs->status.buffer, \"status buffer\");\n        pcs->status.buffer = NULL;\n        pcs->status.write_pos = pcs->status.read_pos = 0;\n    }\n    return count;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":309938,"func":"csi_length(const char *value)\n{\n    int result = 0;\n\n    if (value[0] == '\\033' && value[1] == '[') {\n\tresult = 2;\n    } else if (UChar(value[0]) == 0x9a) {\n\tresult = 1;\n    }\n    return result;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":473863,"func":"big5_uao_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)\n{\n    return big5_mbc_enc_len0(p, e, 2, EncLen_BIG5_UAO);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":513136,"func":"static void update_func_int(THD *thd, struct st_mysql_sys_var *var,\n                             void *tgt, const void *save)\n{\n  *(int *)tgt= *(int *) save;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":294459,"func":"c_jd_to_nth_kday(int jd, double sg, int *ry, int *rm, int *rn, int *rk)\n{\n    int rd, rjd, ns2;\n\n    c_jd_to_civil(jd, sg, ry, rm, &rd);\n    c_find_fdom(*ry, *rm, sg, &rjd, &ns2);\n    *rn = DIV(jd - rjd, 7) + 1;\n    *rk = c_jd_to_wday(jd);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":512295,"func":"  virtual void quick_fix_field()\n  {\n    DBUG_ASSERT(0);\n  }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":486799,"func":"static void gem_init(Object *obj)\n{\n    CadenceGEMState *s = CADENCE_GEM(obj);\n    DeviceState *dev = DEVICE(obj);\n\n    DB_PRINT(\"\\n\");\n\n    gem_init_register_masks(s);\n    memory_region_init_io(&s->iomem, OBJECT(s), &gem_ops, s,\n                          \"enet\", sizeof(s->regs));\n\n    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);\n\n    object_property_add_link(obj, \"dma\", TYPE_MEMORY_REGION,\n                             (Object **)&s->dma_mr,\n                             qdev_prop_allow_set_link_before_realize,\n                             OBJ_PROP_LINK_STRONG);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":508820,"func":"bool LEX::save_prep_leaf_tables()\n{\n  if (!thd->save_prep_leaf_list)\n    return FALSE;\n\n  Query_arena *arena= thd->stmt_arena, backup;\n  arena= thd->activate_stmt_arena_if_needed(&backup);\n  \/\/It is used for DETETE\/UPDATE so top level has only one SELECT\n  DBUG_ASSERT(select_lex.next_select() == NULL);\n  bool res= select_lex.save_prep_leaf_tables(thd);\n\n  if (arena)\n    thd->restore_active_arena(arena, &backup);\n\n  if (res)\n    return TRUE;\n\n  thd->save_prep_leaf_list= FALSE;\n  return FALSE;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":413856,"func":"Method* LinkResolver::linktime_resolve_interface_method_or_null(\n                                                 const LinkInfo& link_info) {\n  EXCEPTION_MARK;\n  Method* method_result = linktime_resolve_interface_method(link_info, THREAD);\n  if (HAS_PENDING_EXCEPTION) {\n    CLEAR_PENDING_EXCEPTION;\n    return NULL;\n  } else {\n    return method_result;\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":459126,"func":"static void tcf_block_owner_del(struct tcf_block *block,\n\t\t\t\tstruct Qdisc *q,\n\t\t\t\tenum flow_block_binder_type binder_type)\n{\n\tstruct tcf_block_owner_item *item;\n\n\tlist_for_each_entry(item, &block->owner_list, list) {\n\t\tif (item->q == q && item->binder_type == binder_type) {\n\t\t\tlist_del(&item->list);\n\t\t\tkfree(item);\n\t\t\treturn;\n\t\t}\n\t}\n\tWARN_ON(1);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":387727,"func":"bool InstanceKlass::is_dependent_nmethod(nmethod* nm) {\n  return dependencies().is_dependent_nmethod(nm);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":506696,"func":"int setup_tests(void)\n{\n    ADD_ALL_TESTS(call_run_cert, OSSL_NELEM(name_fns));\n    ADD_TEST(test_GENERAL_NAME_cmp);\n    return 1;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":248272,"func":"DLLIMPORT int cfg_parse(cfg_t *cfg, const char *filename)\n{\n\tint ret;\n\tchar *fn;\n\tFILE *fp;\n\n\tif (!cfg || !filename) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FILE_ERROR;\n\t}\n\n\tif (cfg->path)\n\t\tfn = cfg_searchpath(cfg->path, filename);\n\telse\n\t\tfn = cfg_tilde_expand(filename);\n\tif (!fn)\n\t\treturn CFG_FILE_ERROR;\n\n\tfree(cfg->filename);\n\tcfg->filename = fn;\n\n\tfp = fopen(cfg->filename, \"r\");\n\tif (!fp)\n\t\treturn CFG_FILE_ERROR;\n\n\tret = cfg_parse_fp(cfg, fp);\n\tfclose(fp);\n\n\treturn ret;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":432186,"func":"static MemTxResult subpage_read(struct uc_struct *uc, void *opaque, hwaddr addr, uint64_t *data,\n                                unsigned len, MemTxAttrs attrs)\n{\n    subpage_t *subpage = opaque;\n    uint8_t buf[8];\n    MemTxResult res;\n\n#if defined(DEBUG_SUBPAGE)\n    printf(\"%s: subpage %p len %u addr \" TARGET_FMT_plx \"\\n\", __func__,\n           subpage, len, addr);\n#endif\n    res = flatview_read(uc, subpage->fv, addr + subpage->base, attrs, buf, len);\n    if (res) {\n        return res;\n    }\n    *data = ldn_p(buf, len);\n    return MEMTX_OK;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":226343,"func":"GF_Err tfxd_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_MSSTimeExtBox *ptr = (GF_MSSTimeExtBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->version = gf_bs_read_u8(bs);\n\tptr->flags = gf_bs_read_u24(bs);\n\n\tif (ptr->version == 0x01) {\n\t\tISOM_DECREASE_SIZE(ptr, 16);\n\t\tptr->absolute_time_in_track_timescale = gf_bs_read_u64(bs);\n\t\tptr->fragment_duration_in_track_timescale = gf_bs_read_u64(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 8);\n\t\tptr->absolute_time_in_track_timescale = gf_bs_read_u32(bs);\n\t\tptr->fragment_duration_in_track_timescale = gf_bs_read_u32(bs);\n\t}\n\n\treturn GF_OK;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":281054,"func":"static void xfrm_statistics_fini(struct net *net)\n{\n\txfrm_proc_fini(net);\n\tfree_percpu(net->mib.xfrm_statistics);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":225952,"func":"void tfrf_box_del(GF_Box *s)\n{\n\tGF_MSSTimeRefBox *ptr = (GF_MSSTimeRefBox *)s;\n\tif (ptr->frags) gf_free(ptr->frags);\n\tgf_free(s);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":512995,"func":"  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)\n  {\n    cached_time.copy_to_mysql_time(ltime);\n    return (null_value= false);\n  }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":466125,"func":"static int em_bsf(struct x86_emulate_ctxt *ctxt)\n{\n\tu8 zf;\n\n\t__asm__ (\"bsf %2, %0; setz %1\"\n\t\t : \"=r\"(ctxt->dst.val), \"=q\"(zf)\n\t\t : \"r\"(ctxt->src.val));\n\n\tctxt->eflags &= ~X86_EFLAGS_ZF;\n\tif (zf) {\n\t\tctxt->eflags |= X86_EFLAGS_ZF;\n\t\t\/* Disable writeback. *\/\n\t\tctxt->dst.type = OP_NONE;\n\t}\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":261227,"func":"static inline int MqttIsPubRespPacket(int packet_type)\n{\n    return (packet_type == MQTT_PACKET_TYPE_PUBLISH_ACK \/* Acknowledgment *\/ ||\n            packet_type == MQTT_PACKET_TYPE_PUBLISH_REC \/* Received *\/ ||\n            packet_type == MQTT_PACKET_TYPE_PUBLISH_REL \/* Release *\/ ||\n            packet_type == MQTT_PACKET_TYPE_PUBLISH_COMP \/* Complete *\/);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":292137,"func":"void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv,\n                             const methodHandle& attached_method,\n                             Bytecodes::Code byte, TRAPS) {\n  Klass* defc = attached_method->method_holder();\n  Symbol* name = attached_method->name();\n  Symbol* type = attached_method->signature();\n  LinkInfo link_info(defc, name, type);\n  switch(byte) {\n    case Bytecodes::_invokevirtual:\n      resolve_virtual_call(result, recv, recv->klass(), link_info,\n                           \/*check_null_and_abstract=*\/true, CHECK);\n      break;\n    case Bytecodes::_invokeinterface:\n      resolve_interface_call(result, recv, recv->klass(), link_info,\n                             \/*check_null_and_abstract=*\/true, CHECK);\n      break;\n    case Bytecodes::_invokestatic:\n      resolve_static_call(result, link_info, \/*initialize_class=*\/false, CHECK);\n      break;\n    case Bytecodes::_invokespecial:\n      resolve_special_call(result, recv, link_info, CHECK);\n      break;\n    default:\n      fatal(\"bad call: %s\", Bytecodes::name(byte));\n      break;\n  }\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":508341,"func":"bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,\n                                LEX_STRING *table, thr_lock_type lock_type)\n{\n  for (; tl; tl= tl->next_global )\n  {\n    if (tl->lock_type >= lock_type &&\n        tl->prelocking_placeholder == TABLE_LIST::FK &&\n        strcmp(tl->db, db->str) == 0 &&\n        strcmp(tl->table_name, table->str) == 0)\n      return true;\n  }\n  return false;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":513051,"func":"  void print(String *str, enum_query_type query_type)\n  {\n    str->append(STRING_WITH_LEN(\"ignore\"));\n  }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":221154,"func":"void gf_odf_vp_cfg_del(GF_VPConfig *cfg)\n{\n\tif (!cfg) return;\n\n\tif (cfg->codec_initdata) {\n\t\tgf_free(cfg->codec_initdata);\n\t\tcfg->codec_initdata = NULL;\n\t}\n\n\tgf_free(cfg);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":359481,"func":"peer_lookup_vty (struct vty *vty, const char *ip_str)\n{\n  int ret;\n  struct bgp *bgp;\n  union sockunion su;\n  struct peer *peer;\n\n  bgp = vty->index;\n\n  ret = str2sockunion (ip_str, &su);\n  if (ret < 0)\n    {\n      vty_out (vty, \"%% Malformed address: %s%s\", ip_str, VTY_NEWLINE);\n      return NULL;\n    }\n\n  peer = peer_lookup (bgp, &su);\n  if (! peer)\n    {\n      vty_out (vty, \"%% Specify remote-as or peer-group commands first%s\", VTY_NEWLINE);\n      return NULL;\n    }\n  return peer;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":353180,"func":"SplashGouraudPattern::~SplashGouraudPattern() {\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":384799,"func":"f_finddir(typval_T *argvars, typval_T *rettv)\n{\n    findfilendir(argvars, rettv, FINDFILE_DIR);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":336583,"func":"void reds_on_vm_stop(RedsState *reds)\n{\n    FOREACH_QXL_INSTANCE(reds, qxl) {\n        red_qxl_stop(qxl);\n    }\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":432179,"func":"static void test_map_big_memory(void)\n{\n    uc_engine *uc;\n\n    OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));\n\n    uc_assert_err(UC_ERR_NOMEM,\n                  uc_mem_map(uc, 0x0, 0xfffffffffffff000, UC_PROT_ALL));\n\n    OK(uc_close(uc));\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":413852,"func":"void CallInfo::set_interface(Klass* resolved_klass,\n                             const methodHandle& resolved_method,\n                             const methodHandle& selected_method,\n                             int itable_index, TRAPS) {\n  \/\/ This is only called for interface methods. If the resolved_method\n  \/\/ comes from java\/lang\/Object, it can be the subject of a virtual call, so\n  \/\/ we should pick the vtable index from the resolved method.\n  \/\/ In that case, the caller must call set_virtual instead of set_interface.\n  assert(resolved_method->method_holder()->is_interface(), \"\");\n  assert(itable_index == resolved_method()->itable_index(), \"\");\n  set_common(resolved_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK);\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":312387,"func":"ex_cwindow(exarg_T *eap)\n{\n    qf_info_T\t*qi;\n    qf_list_T\t*qfl;\n    win_T\t*win;\n\n    if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL)\n\treturn;\n\n    qfl = qf_get_curlist(qi);\n\n    \/\/ Look for an existing quickfix window.\n    win = qf_find_win(qi);\n\n    \/\/ If a quickfix window is open but we have no errors to display,\n    \/\/ close the window.  If a quickfix window is not open, then open\n    \/\/ it if we have errors; otherwise, leave it closed.\n    if (qf_stack_empty(qi)\n\t    || qfl->qf_nonevalid\n\t    || qf_list_empty(qfl))\n    {\n\tif (win != NULL)\n\t    ex_cclose(eap);\n    }\n    else if (win == NULL)\n\tex_copen(eap);\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":434098,"func":"ex_argedit(exarg_T *eap)\n{\n    int i = eap->addr_count ? (int)eap->line2 : curwin->w_arg_idx + 1;\n    \/\/ Whether curbuf will be reused, curbuf->b_ffname will be set.\n    int curbuf_is_reusable = curbuf_reusable();\n\n    if (do_arglist(eap->arg, AL_ADD, i, TRUE) == FAIL)\n\treturn;\n    maketitle();\n\n    if (curwin->w_arg_idx == 0\n\t    && (curbuf->b_ml.ml_flags & ML_EMPTY)\n\t    && (curbuf->b_ffname == NULL || curbuf_is_reusable))\n\ti = 0;\n    \/\/ Edit the argument.\n    if (i < ARGCOUNT)\n\tdo_argfile(eap, i);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":487654,"func":"int raw_notifier_chain_unregister(struct raw_notifier_head *nh,\n\t\tstruct notifier_block *n)\n{\n\treturn notifier_chain_unregister(&nh->head, n);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":229334,"func":"inline tensorflow::Fprint128 FingerprintCat128(const tensorflow::Fprint128& a,\n                                               const tensorflow::Fprint128& b) {\n  return {tensorflow::FingerprintCat64(a.low64, b.low64),\n          tensorflow::FingerprintCat64(a.high64, b.high64)};\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":225755,"func":"void stdp_box_del(GF_Box *s)\n{\n\tGF_DegradationPriorityBox *ptr = (GF_DegradationPriorityBox *)s;\n\tif (ptr == NULL ) return;\n\tif (ptr->priorities) gf_free(ptr->priorities);\n\tgf_free(ptr);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":359208,"func":"BPF_CALL_2(bpf_ringbuf_discard, void *, sample, u64, flags)\n{\n\tbpf_ringbuf_commit(sample, flags, true \/* discard *\/);\n\treturn 0;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":225891,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nGF_Err sgpd_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i, nb_descs;\n\tGF_SampleGroupDescriptionBox *p = (GF_SampleGroupDescriptionBox *)s;\n\tGF_Err e;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, p->grouping_type);\n\tif (p->version>=1) gf_bs_write_u32(bs, p->default_length);\n\tif (p->version>=2) gf_bs_write_u32(bs, p->default_description_index);\n\tnb_descs = gf_list_count(p->group_descriptions);\n\tgf_bs_write_u32(bs, nb_descs);\n\n\tfor (i=0; i<nb_descs; i++) {\n\t\tvoid *ptr = gf_list_get(p->group_descriptions, i);\n\t\tif ((p->version >= 1) && !p->default_length) {\n\t\t\tu32 size = sgpd_size_entry(p->grouping_type, ptr);\n\t\t\tgf_bs_write_u32(bs, size);\n\t\t}\n\t\tsgpd_write_entry(p->grouping_type, ptr, bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":238798,"func":"get_spat_last_idx(void)\n{\n    return last_idx;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":345133,"func":"static int pxa3xx_gcu_remove(struct platform_device *pdev)\n{\n\tstruct pxa3xx_gcu_priv *priv = platform_get_drvdata(pdev);\n\tstruct device *dev = &pdev->dev;\n\n\tpxa3xx_gcu_wait_idle(priv);\n\tmisc_deregister(&priv->misc_dev);\n\tdma_free_coherent(dev, SHARED_SIZE, priv->shared, priv->shared_phys);\n\tclk_disable_unprepare(priv->clk);\n\tpxa3xx_gcu_free_buffers(dev, priv);\n\n\treturn 0;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":484798,"func":"static void __exit netif_exit(void)\n{\n\txenbus_unregister_driver(&netfront_driver);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":222503,"func":"FunctionLibraryDefinition::FindHelper(const string& func) const {\n  auto iter = function_defs_.find(func);\n  if (iter == function_defs_.end()) {\n    return nullptr;\n  } else {\n    return iter->second;\n  }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":459509,"func":"BPF_CALL_4(bpf_get_stack, struct pt_regs *, regs, void *, buf, u32, size,\n\t   u64, flags)\n{\n\treturn __bpf_get_stack(regs, NULL, NULL, buf, size, flags);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":440874,"func":"LogSetParameter(LogParameter param, int value)\n{\n    switch (param) {\n    case XLOG_FLUSH:\n        logFlush = value ? TRUE : FALSE;\n        return TRUE;\n    case XLOG_SYNC:\n        logSync = value ? TRUE : FALSE;\n        return TRUE;\n    case XLOG_VERBOSITY:\n        logVerbosity = value;\n        return TRUE;\n    case XLOG_FILE_VERBOSITY:\n        logFileVerbosity = value;\n        return TRUE;\n    default:\n        return FALSE;\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":244285,"func":"GF_Err jp2h_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_J2KHeaderBox *ptr = (GF_J2KHeaderBox *)s;\n\tswitch(a->type) {\n\tcase GF_ISOM_BOX_TYPE_IHDR:\n\t\tBOX_FIELD_ASSIGN(ihdr, GF_J2KImageHeaderBox)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_COLR:\n\t\tBOX_FIELD_ASSIGN(colr, GF_ColourInformationBox)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":256945,"func":"  static Status ReshapeToRank3(const Tensor& input, int batch_size,\n                               Tensor* output) {\n    const int rank = input.dims();\n    TensorShape output_shape = {batch_size, input.dim_size(rank - 2),\n                                input.dim_size(rank - 1)};\n    return CopyFrom(input, output_shape, output);\n  }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":484761,"func":"static int xennet_change_mtu(struct net_device *dev, int mtu)\n{\n\tint max = xennet_can_sg(dev) ? XEN_NETIF_MAX_TX_SIZE : ETH_DATA_LEN;\n\n\tif (mtu > max)\n\t\treturn -EINVAL;\n\tdev->mtu = mtu;\n\treturn 0;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":248763,"func":"static const char *get_top_domain(const char * const domain, size_t *outlen)\n{\n  size_t len = 0;\n  const char *first = NULL, *last;\n\n  if(domain) {\n    len = strlen(domain);\n    last = memrchr(domain, '.', len);\n    if(last) {\n      first = memrchr(domain, '.', (last - domain));\n      if(first)\n        len -= (++first - domain);\n    }\n  }\n\n  if(outlen)\n    *outlen = len;\n\n  return first? first: domain;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":219990,"func":"int callback_glewlwyd_scheme_check_forbid_profile (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_scheme = get_user_auth_scheme_module(config, json_string_value(json_object_get(j_param, \"scheme_name\")));\n  int ret = U_CALLBACK_CONTINUE;\n  \n  if (check_result_value(j_scheme, G_OK)) {\n    if (json_object_get(json_object_get(j_scheme, \"module\"), \"forbid_user_profile\") == json_true()) {\n      response->status = 403;\n      ret = U_CALLBACK_COMPLETE;\n    }\n  } else if (check_result_value(j_scheme, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_scheme_check_forbid_profile - Error auth_register_get_user_scheme\");\n    response->status = 500;\n  }\n  json_decref(j_param);\n  json_decref(j_scheme);\n  return ret;\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":294557,"func":"ns_to_day(VALUE n)\n{\n    if (FIXNUM_P(n))\n\treturn rb_rational_new2(n, day_in_nanoseconds);\n    return f_quo(n, day_in_nanoseconds);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":349281,"func":"void squashfs_closedir(struct dir *dir)\n{\n\tstruct dir_ent *ent = dir->dirs;\n\n\twhile(ent) {\n\t\tstruct dir_ent *tmp = ent;\n\n\t\tent = ent->next;\n\t\tfree(tmp->name);\n\t\tfree(tmp);\n\t}\n\n\tfree(dir);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":487669,"func":"asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *rlim)\n{\n\tstruct rlimit x;\n\tif (resource >= RLIM_NLIMITS)\n\t\treturn -EINVAL;\n\n\ttask_lock(current->group_leader);\n\tx = current->signal->rlim[resource];\n\ttask_unlock(current->group_leader);\n\tif (x.rlim_cur > 0x7FFFFFFF)\n\t\tx.rlim_cur = 0x7FFFFFFF;\n\tif (x.rlim_max > 0x7FFFFFFF)\n\t\tx.rlim_max = 0x7FFFFFFF;\n\treturn copy_to_user(rlim, &x, sizeof(x))?-EFAULT:0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":294542,"func":"d_new_by_frags(VALUE klass, VALUE hash, VALUE sg)\n{\n    VALUE jd;\n\n    if (!c_valid_start_p(NUM2DBL(sg))) {\n\tsg = INT2FIX(DEFAULT_SG);\n\trb_warning(\"invalid start is ignored\");\n    }\n\n    if (NIL_P(hash))\n\trb_raise(eDateError, \"invalid date\");\n\n    if (NIL_P(ref_hash(\"jd\")) &&\n\tNIL_P(ref_hash(\"yday\")) &&\n\t!NIL_P(ref_hash(\"year\")) &&\n\t!NIL_P(ref_hash(\"mon\")) &&\n\t!NIL_P(ref_hash(\"mday\")))\n\tjd = rt__valid_civil_p(ref_hash(\"year\"),\n\t\t\t       ref_hash(\"mon\"),\n\t\t\t       ref_hash(\"mday\"), sg);\n    else {\n\thash = rt_rewrite_frags(hash);\n\thash = rt_complete_frags(klass, hash);\n\tjd = rt__valid_date_frags_p(hash, sg);\n    }\n\n    if (NIL_P(jd))\n\trb_raise(eDateError, \"invalid date\");\n    {\n\tVALUE nth;\n\tint rjd;\n\n\tdecode_jd(jd, &nth, &rjd);\n\treturn d_simple_new_internal(klass,\n\t\t\t\t     nth, rjd,\n\t\t\t\t     NUM2DBL(sg),\n\t\t\t\t     0, 0, 0,\n\t\t\t\t     HAVE_JD);\n    }\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":226189,"func":"\nGF_Err stvi_box_size(GF_Box *s)\n{\n\tGF_StereoVideoBox *ptr = (GF_StereoVideoBox *)s;\n\n\tptr->size+= 12 + ptr->sit_len;\n\treturn GF_OK;","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":359332,"func":"DEFUN (clear_ip_bgp_external_in_prefix_filter,\n       clear_ip_bgp_external_in_prefix_filter_cmd,\n       \"clear ip bgp external in prefix-filter\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all external peers\\n\"\n       \"Soft reconfig inbound update\\n\"\n       \"Push out prefix-list ORF and do inbound soft reconfig\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,\n\t\t\tBGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":175700,"func":"  virtual bool ethernet_available() const {\n    return available_devices_ & (1 << TYPE_ETHERNET);\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":450833,"func":"int st21nfca_hci_se_io(struct nfc_hci_dev *hdev, u32 se_idx,\n\t\t\tu8 *apdu, size_t apdu_length,\n\t\t\tse_io_cb_t cb, void *cb_context)\n{\n\tstruct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);\n\n\tpr_debug(\"se_io %x\\n\", se_idx);\n\n\tswitch (se_idx) {\n\tcase ST21NFCA_ESE_HOST_ID:\n\t\tinfo->se_info.cb = cb;\n\t\tinfo->se_info.cb_context = cb_context;\n\t\tmod_timer(&info->se_info.bwi_timer, jiffies +\n\t\t\t  msecs_to_jiffies(info->se_info.wt_timeout));\n\t\tinfo->se_info.bwi_active = true;\n\t\treturn nfc_hci_send_event(hdev, ST21NFCA_APDU_READER_GATE,\n\t\t\t\t\tST21NFCA_EVT_TRANSMIT_DATA,\n\t\t\t\t\tapdu, apdu_length);\n\tdefault:\n\t\treturn -ENODEV;\n\t}\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":226399,"func":"\nvoid fiin_box_del(GF_Box *s)\n{\n\tFDItemInformationBox *ptr = (FDItemInformationBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->partition_entries) gf_list_del(ptr->partition_entries);\n\tgf_free(ptr);","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":359636,"func":"DEFUN (show_ip_community_list,\n       show_ip_community_list_cmd,\n       \"show ip community-list\",\n       SHOW_STR\n       IP_STR\n       \"List community-list\\n\")\n{\n  struct community_list *list;\n  struct community_list_master *cm;\n\n  cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);\n  if (! cm)\n    return CMD_SUCCESS;\n\n  for (list = cm->num.head; list; list = list->next)\n    community_list_show (vty, list);\n\n  for (list = cm->str.head; list; list = list->next)\n    community_list_show (vty, list);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":252297,"func":"mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) {\n  return pZip ? pZip->m_total_files : 0;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":254879,"func":"Value DocumentSourceGroup::expandId(const Value& val) {\n    \/\/ _id doesn't get wrapped in a document\n    if (_idFieldNames.empty())\n        return val;\n\n    \/\/ _id is a single-field document containing val\n    if (_idFieldNames.size() == 1)\n        return Value(DOC(_idFieldNames[0] << val));\n\n    \/\/ _id is a multi-field document containing the elements of val\n    const vector<Value>& vals = val.getArray();\n    invariant(_idFieldNames.size() == vals.size());\n    MutableDocument md(vals.size());\n    for (size_t i = 0; i < vals.size(); i++) {\n        md[_idFieldNames[i]] = vals[i];\n    }\n    return md.freezeToValue();\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":338102,"func":"void WasmBinaryBuilder::visitThrow(Throw* curr) {\n  BYN_TRACE(\"zz node: Throw\\n\");\n  auto index = getU32LEB();\n  if (index >= wasm.tags.size()) {\n    throwError(\"bad tag index\");\n  }\n  auto* tag = wasm.tags[index].get();\n  curr->tag = tag->name;\n  size_t num = tag->sig.params.size();\n  curr->operands.resize(num);\n  for (size_t i = 0; i < num; i++) {\n    curr->operands[num - i - 1] = popNonVoidExpression();\n  }\n  curr->finalize();\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":275995,"func":"void uECC_point_mult(uECC_word_t *result,\n                     const uECC_word_t *point,\n                     const uECC_word_t *scalar,\n                     uECC_Curve curve) {\n    uECC_word_t tmp1[uECC_MAX_WORDS];\n    uECC_word_t tmp2[uECC_MAX_WORDS];\n    uECC_word_t *p2[2] = {tmp1, tmp2};\n    uECC_word_t carry = regularize_k(scalar, tmp1, tmp2, curve);\n\n    EccPoint_mult(result, point, p2[!carry], 0, curve->num_n_bits + 1, curve);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":294608,"func":"d_lite_yday(VALUE self)\n{\n    get_d1(self);\n    return INT2FIX(m_yday(dat));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":441827,"func":"SProcXkbGetKbdByName(ClientPtr client)\n{\n    REQUEST(xkbGetKbdByNameReq);\n\n    swaps(&stuff->length);\n    REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);\n    swaps(&stuff->deviceSpec);\n    swaps(&stuff->want);\n    swaps(&stuff->need);\n    return ProcXkbGetKbdByName(client);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":253630,"func":"smb2_dump_detail(void *buf, struct TCP_Server_Info *server)\n{\n#ifdef CONFIG_CIFS_DEBUG2\n\tstruct smb2_hdr *shdr = (struct smb2_hdr *)buf;\n\n\tcifs_server_dbg(VFS, \"Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\\n\",\n\t\t shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId,\n\t\t shdr->Id.SyncId.ProcessId);\n\tcifs_server_dbg(VFS, \"smb buf %p len %u\\n\", buf,\n\t\t server->ops->calc_smb_size(buf, server));\n#endif\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":225596,"func":"\nGF_Box *leva_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_LevelAssignmentBox, GF_ISOM_BOX_TYPE_LEVA);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":512325,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_cache_datetime>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":294572,"func":"jd_to_nth_kday(VALUE jd, double sg,\n\t       VALUE *nth, int *rjd,\n\t       int *ry, int *rm, int *rn, int *rk)\n{\n    decode_jd(jd, nth, rjd);\n    c_jd_to_nth_kday(*rjd, sg, ry, rm, rn, rk);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":512949,"func":"  Item_type_holder(THD *thd, Item *item)\n   :Item(thd, item),\n    Type_handler_hybrid_field_type(item->real_type_handler()),\n    enum_set_typelib(0)\n  {\n    DBUG_ASSERT(item->is_fixed());\n    maybe_null= item->maybe_null;\n  }","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":281056,"func":"void xfrm_policy_hash_rebuild(struct net *net)\n{\n\tschedule_work(&net->xfrm.policy_hthresh.work);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":262016,"func":"ProtoRequestTypeText(ProtoRequestType t)\n{\n   switch (t) {\n   case PROTO_REQUEST_UNKNOWN:\n      return \"UNKNOWN\";\n   case PROTO_REQUEST_SESSION_REQ:\n      return \"SESSION\";\n   case PROTO_REQUEST_CONN:\n      return \"CONNECT\";\n   case PROTO_REQUEST_ADDALIAS:\n      return \"ADDALIAS\";\n   case PROTO_REQUEST_REMOVEALIAS:\n      return \"REMOVEALIAS\";\n   case PROTO_REQUEST_QUERYALIASES:\n      return \"QUERYALIASES\";\n   case PROTO_REQUEST_QUERYMAPPEDALIASES:\n      return \"QUERYMAPPEDALIASES\";\n   case PROTO_REQUEST_CREATETICKET:\n      return \"CREATETICKET\";\n   case PROTO_REQUEST_VALIDATETICKET:\n      return \"VALIDATETICKET\";\n   case PROTO_REQUEST_REVOKETICKET:\n      return \"REVOKETICKET\";\n   case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:\n      return \"VALIDATE_SAML_BEARER_TOKEN\";\n   default:\n      return \"INVALID\";\n   }\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":300746,"func":"static int tipc_set_sk_state(struct sock *sk, int state)\n{\n\tint oldsk_state = sk->sk_state;\n\tint res = -EINVAL;\n\n\tswitch (state) {\n\tcase TIPC_OPEN:\n\t\tres = 0;\n\t\tbreak;\n\tcase TIPC_LISTEN:\n\tcase TIPC_CONNECTING:\n\t\tif (oldsk_state == TIPC_OPEN)\n\t\t\tres = 0;\n\t\tbreak;\n\tcase TIPC_ESTABLISHED:\n\t\tif (oldsk_state == TIPC_CONNECTING ||\n\t\t    oldsk_state == TIPC_OPEN)\n\t\t\tres = 0;\n\t\tbreak;\n\tcase TIPC_DISCONNECTING:\n\t\tif (oldsk_state == TIPC_CONNECTING ||\n\t\t    oldsk_state == TIPC_ESTABLISHED)\n\t\t\tres = 0;\n\t\tbreak;\n\t}\n\n\tif (!res)\n\t\tsk->sk_state = state;\n\n\treturn res;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":463075,"func":"static uint64_t sungem_mmio_rxdma_read(void *opaque, hwaddr addr, unsigned size)\n{\n    SunGEMState *s = opaque;\n    uint32_t val;\n\n    if (!(addr <= 0x28) && !(addr >= 0x100 && addr <= 0x120)) {\n        qemu_log_mask(LOG_GUEST_ERROR,\n                      \"Read from unknown RXDMA register 0x%\"HWADDR_PRIx\"\\n\",\n                      addr);\n        return 0;\n    }\n\n    val = s->rxdmaregs[addr >> 2];\n\n    trace_sungem_mmio_rxdma_read(addr, val);\n\n    return val;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":248321,"func":"static cfg_value_t *cfg_opt_getval(cfg_opt_t *opt, unsigned int index)\n{\n\tcfg_value_t *val = NULL;\n\n\tif (index != 0 && !is_set(CFGF_LIST, opt->flags) && !is_set(CFGF_MULTI, opt->flags)) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tif (opt->simple_value.ptr)\n\t\tval = (cfg_value_t *)opt->simple_value.ptr;\n\telse {\n\t\tif (is_set(CFGF_RESET, opt->flags)) {\n\t\t\tcfg_free_value(opt);\n\t\t\topt->flags &= ~CFGF_RESET;\n\t\t}\n\n\t\tif (index >= opt->nvalues)\n\t\t\tval = cfg_addval(opt);\n\t\telse\n\t\t\tval = opt->values[index];\n\t}\n\n\treturn val;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":450369,"func":"static void zrle_write_u16(VncState *vs, uint16_t value)\n{\n    vnc_write(vs, (uint8_t *)&value, 2);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":473948,"func":"cp949_is_mbc_ambiguous(OnigCaseFoldType flag,\n\t\t       const UChar** pp, const UChar* end, OnigEncoding enc)\n{\n  return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":254034,"func":"static ssize_t attr_show_buffers(struct device *cd,\n\t\tstruct device_attribute *attr, char *buf)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);\n\n\treturn sprintf(buf, \"%d\\n\", dev->used_buffers);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":369296,"func":"static inline void io_req_complete_state(struct io_kiocb *req, s32 res,\n\t\t\t\t\t u32 cflags)\n{\n\treq->result = res;\n\treq->cflags = cflags;\n\treq->flags |= REQ_F_COMPLETE_INLINE;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":336615,"func":"SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16])\n{\n    memcpy(s->config->spice_uuid, uuid, sizeof(s->config->spice_uuid));\n    s->config->spice_uuid_is_set = TRUE;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":225079,"func":"PQprotocolVersion(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn 0;\n\tif (conn->status == CONNECTION_BAD)\n\t\treturn 0;\n\treturn PG_PROTOCOL_MAJOR(conn->pversion);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":413656,"func":"static void core_anal_color_curr_node(RCore *core, RAnalBlock *bbi) {\n\tbool color_current = r_config_get_i (core->config, \"graph.gv.current\");\n\tchar *pal_curr = palColorFor (\"graph.current\");\n\tbool current = r_anal_block_contains (bbi, core->offset);\n\n\tif (current && color_current) {\n\t\tr_cons_printf (\"\\t\\\"0x%08\"PFMT64x\"\\\" \", bbi->addr);\n\t\tr_cons_printf (\"\\t[fillcolor=%s style=filled shape=box];\\n\", pal_curr);\n\t}\n\tfree (pal_curr);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":252314,"func":"  bool operator()(long long *a, long long *b) { return *a > *b; }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":455279,"func":"posix_readline_initialize (on_or_off)\n     int on_or_off;\n{\n  static char kseq[2] = { CTRL ('I'), 0 };\t\t\/* TAB *\/\n\n  if (on_or_off)\n    rl_variable_bind (\"comment-begin\", \"#\");\n#if defined (VI_MODE)\n  if (on_or_off)\n    {\n      vi_tab_binding = rl_function_of_keyseq (kseq, vi_insertion_keymap, (int *)NULL);\n      rl_bind_key_in_map (CTRL ('I'), rl_insert, vi_insertion_keymap);\n    }\n  else\n    {\n      if (rl_function_of_keyseq (kseq, vi_insertion_keymap, (int *)NULL) == rl_insert)\n        rl_bind_key_in_map (CTRL ('I'), vi_tab_binding, vi_insertion_keymap);\n    }\n#endif\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":445983,"func":"fr_window_get_password_for_second_archive (FrWindow *window)\n{\n\tg_return_val_if_fail (window != NULL, NULL);\n\n\treturn window->priv->second_password;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":459134,"func":"struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struct sk_buff *skb,\n\t\t\t\t  struct sk_buff **to_free, int *ret)\n{\n\tstruct tcf_result cl_res;\n\tstruct tcf_proto *fl;\n\n\tif (!qe->info.block_index)\n\t\treturn skb;\n\n\tfl = rcu_dereference_bh(qe->filter_chain);\n\n\tswitch (tcf_classify(skb, NULL, fl, &cl_res, false)) {\n\tcase TC_ACT_SHOT:\n\t\tqdisc_qstats_drop(sch);\n\t\t__qdisc_drop(skb, to_free);\n\t\t*ret = __NET_XMIT_BYPASS;\n\t\treturn NULL;\n\tcase TC_ACT_STOLEN:\n\tcase TC_ACT_QUEUED:\n\tcase TC_ACT_TRAP:\n\t\t__qdisc_drop(skb, to_free);\n\t\t*ret = __NET_XMIT_STOLEN;\n\t\treturn NULL;\n\tcase TC_ACT_REDIRECT:\n\t\tskb_do_redirect(skb);\n\t\t*ret = __NET_XMIT_STOLEN;\n\t\treturn NULL;\n\t}\n\n\treturn skb;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":366326,"func":"struct vfsmount *lookup_mnt(const struct path *path)\n{\n\tstruct mount *child_mnt;\n\tstruct vfsmount *m;\n\tunsigned seq;\n\n\trcu_read_lock();\n\tdo {\n\t\tseq = read_seqbegin(&mount_lock);\n\t\tchild_mnt = __lookup_mnt(path->mnt, path->dentry);\n\t\tm = child_mnt ? &child_mnt->mnt : NULL;\n\t} while (!legitimize_mnt(m, seq));\n\trcu_read_unlock();\n\treturn m;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":238382,"func":"njs_function_property_prototype_set(njs_vm_t *vm, njs_lvlhsh_t *hash,\n    njs_value_t *prototype)\n{\n    njs_int_t           ret;\n    njs_object_prop_t   *prop;\n    njs_lvlhsh_query_t  lhq;\n\n    const njs_value_t  proto_string = njs_string(\"prototype\");\n\n    prop = njs_object_prop_alloc(vm, &proto_string, prototype, 0);\n    if (njs_slow_path(prop == NULL)) {\n        return NULL;\n    }\n\n    prop->writable = 1;\n\n    lhq.value = prop;\n    lhq.key_hash = NJS_PROTOTYPE_HASH;\n    lhq.key = njs_str_value(\"prototype\");\n    lhq.replace = 1;\n    lhq.pool = vm->mem_pool;\n    lhq.proto = &njs_object_hash_proto;\n\n    ret = njs_lvlhsh_insert(hash, &lhq);\n\n    if (njs_fast_path(ret == NJS_OK)) {\n        return &prop->value;\n    }\n\n    njs_internal_error(vm, \"lvlhsh insert failed\");\n\n    return NULL;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":233940,"func":"bool DocumentSourceUnionWith::usedDisk() {\n    if (_pipeline) {\n        _stats.planSummaryStats.usedDisk =\n            _stats.planSummaryStats.usedDisk || _pipeline->usedDisk();\n    }\n    return _stats.planSummaryStats.usedDisk;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":364780,"func":"set_buflocal_tfu_callback(buf_T *buf UNUSED)\n{\n    free_callback(&buf->b_tfu_cb);\n    if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL)\n\tcopy_callback(&buf->b_tfu_cb, &tfu_cb);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":424944,"func":"static int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue,\n\t\t\t\t       struct iwl_trans_rxq_dma_data *data)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\n\tif (queue >= trans->num_rx_queues || !trans_pcie->rxq)\n\t\treturn -EINVAL;\n\n\tdata->fr_bd_cb = trans_pcie->rxq[queue].bd_dma;\n\tdata->urbd_stts_wrptr = trans_pcie->rxq[queue].rb_stts_dma;\n\tdata->ur_bd_cb = trans_pcie->rxq[queue].used_bd_dma;\n\tdata->fr_bd_wid = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":220027,"func":"  explicit SparseTensorsMap(const string& name) : name_(name), counter_(0) {}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":224568,"func":"Status UnknownShape(shape_inference::InferenceContext* c) {\n  for (int i = 0; i < c->num_outputs(); ++i) {\n    c->set_output(i, c->UnknownShape());\n  }\n  return Status::OK();\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":236205,"func":"GF_Err diST_box_size(GF_Box *s)\n{\n\tGF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;\n\ts->size += p->content_script_types ? (strlen(p->content_script_types)+1) : 1;\n\treturn GF_OK;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":331757,"func":"QPainterState *QPaintEngineEx::createState(QPainterState *orig) const\n{\n    if (!orig)\n        return new QPainterState;\n    return new QPainterState(orig);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":246448,"func":"static void wasm_custom_name_free(RBinWasmCustomNameEntry *cust) {\n\tif (cust) {\n\t\tswitch (cust->type) {\n\t\tcase R_BIN_WASM_NAMETYPE_Module:\n\t\t\tR_FREE (cust->mod_name);\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_NAMETYPE_Function:\n\t\t\tif (cust->func) {\n\t\t\t\tr_id_storage_free (cust->func->names);\n\t\t\t\tR_FREE (cust->func);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_NAMETYPE_Local:\n\t\t\twasm_custom_local_names_free (cust->local);\n\t\t\tbreak;\n\t\tcase R_BIN_WASM_NAMETYPE_None:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\teprintf (\"Unkown type: 0x%x\\n\", cust->type);\n\t\t\tr_warn_if_reached ();\n\t\t}\n\t\tR_FREE (cust);\n\t}\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":225446,"func":"static inline void set_queued(struct v4l2l_buffer *buffer)\n{\n\tbuffer->buffer.flags &= ~V4L2_BUF_FLAG_DONE;\n\tbuffer->buffer.flags |= V4L2_BUF_FLAG_QUEUED;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":452992,"func":"static bool nft_dup_netdev_offload_action(const struct nft_expr *expr)\n{\n\treturn true;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":90889,"func":"  void DidGetUsage(int64 usage) {\n    DCHECK(original_message_loop()->BelongsToCurrentThread());\n    DCHECK(!pending_origins_.empty());\n    DCHECK(client_tracker_);\n\n    DCHECK_GE(usage, 0);\n    if (usage < 0)\n      usage = 0;\n\n    const GURL& origin = pending_origins_.front();\n    std::string host = net::GetHostOrSpecFromURL(origin);\n    client_tracker_->AddCachedOrigin(origin, usage);\n\n    pending_origins_.pop_front();\n    if (pending_origins_.empty() ||\n        host != net::GetHostOrSpecFromURL(pending_origins_.front())) {\n      client_tracker_->AddCachedHost(host);\n    }\n\n    if (pending_origins_.empty()) {\n      CallCompleted();\n      DeleteSoon();\n    }\n  }\n","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":359570,"func":"DEFUN (no_neighbor_disable_connected_check,\n       no_neighbor_disable_connected_check_cmd,\n       NO_NEIGHBOR_CMD2 \"disable-connected-check\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"one-hop away EBGP peer using loopback address\\n\")\n{\n  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":512610,"func":"  longlong val_int()\n  {\n    return longlong_from_string_with_check(&str_value);\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":522344,"func":"int GmfCloseMesh(int64_t MshIdx)\n{\n   int i, res = 1;\n   GmfMshSct *msh = (GmfMshSct *)MshIdx;\n\n   RecBlk(msh, msh->buf, 0);\n\n   \/\/ In write down the \"End\" kw in write mode\n   if(msh->mod == GmfWrite)\n   {\n      if(msh->typ & Asc)\n         fprintf(msh->hdl, \"\\n%s\\n\", GmfKwdFmt[ GmfEnd ][0]);\n      else\n         GmfSetKwd(MshIdx, GmfEnd, 0);\n   }\n\n   \/\/ Close the file and free the mesh structure\n   if(msh->typ & Bin)\n#ifdef WITH_GMF_AIO\n      close(msh->FilDes);\n#else\n      fclose(msh->hdl);\n#endif\n   else if(fclose(msh->hdl))\n      res = 0;\n\n   \/\/ Free optional H.O. renumbering tables\n   for(i=0;i<GmfLastKeyword;i++)\n      if(msh->KwdTab[i].OrdTab)\n         free(msh->KwdTab[i].OrdTab);\n\n   free(msh);\n\n   return(res);\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":309867,"func":"skip_delay(const char *s)\n{\n    if (s[0] == '$' && s[1] == '<') {\n\ts += 2;\n\twhile (isdigit(UChar(*s)) || *s == '\/')\n\t    ++s;\n\tif (*s == '>')\n\t    ++s;\n    }\n    return s;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":309904,"func":"termattrs(void)\n{\n    return NCURSES_SP_NAME(termattrs) (CURRENT_SCREEN);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":225664,"func":"GF_Box *edts_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_EditBox, GF_ISOM_BOX_TYPE_EDTS);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":398542,"func":"static void free_loc_table_list(RzBinDwarfLocList *loc_list) {\n\tRzListIter *iter;\n\tRzBinDwarfLocRange *range;\n\trz_list_foreach (loc_list->list, iter, range) {\n\t\tfree(range->expression->data);\n\t\tfree(range->expression);\n\t\tfree(range);\n\t}\n\trz_list_free(loc_list->list);\n\tfree(loc_list);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":244294,"func":"GF_Err strk_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":101688,"func":"static WebProcessProxy::WebPageProxyMap& globalPageMap()\n{\n    ASSERT(isMainThread());\n    DEFINE_STATIC_LOCAL(WebProcessProxy::WebPageProxyMap, pageMap, ());\n    return pageMap;\n}\n","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":343232,"func":"void dorest(const char *name)\n{\n    char *endptr;\n\n    restartat = (off_t) strtoull(name, &endptr, 10);\n    if (*endptr != 0 || restartat < (off_t) 0) {\n        restartat = 0;\n        addreply(554, MSG_REST_NOT_NUMERIC \"\\n\" MSG_REST_RESET);\n    } else {\n        if (type == 1 && restartat != 0) {\n#ifdef STRICT_REST\n            addreply_noformat(504, MSG_REST_ASCII_STRICT);\n#else\n            addreply(350, MSG_REST_ASCII_WORKAROUND,\n                     (long long) restartat);\n#endif\n        } else {\n            if (restartat != 0) {\n                logfile(LOG_NOTICE, MSG_REST_SUCCESS, (long long) restartat);\n            }\n            addreply(350, MSG_REST_SUCCESS, (long long) restartat);\n        }\n    }\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":421388,"func":"static void in(int d)\n{\n\tif (minify < 1)\n\t\twhile (d-- > 0)\n\t\t\tputchar('\\t');\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":424926,"func":"void iwl_pcie_synchronize_irqs(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\n\tif (trans_pcie->msix_enabled) {\n\t\tint i;\n\n\t\tfor (i = 0; i < trans_pcie->alloc_vecs; i++)\n\t\t\tsynchronize_irq(trans_pcie->msix_entries[i].vector);\n\t} else {\n\t\tsynchronize_irq(trans_pcie->pci_dev->irq);\n\t}\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":301424,"func":"static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)\n{\n\tNTSTATUS result;\n\n\tSTART_PROFILE(fset_nt_acl);\n\tresult = set_nt_acl(fsp, security_info_sent, psd);\n\tEND_PROFILE(fset_nt_acl);\n\treturn result;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":374043,"func":"static RBinInfo *info(RBinFile *bf) {\n\tSymbolsMetadata sm = parseMetadata (bf->buf, 0x40);\n\tRBinInfo *ret = R_NEW0 (RBinInfo);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tret->file = strdup (bf->file);\n\tret->bclass = strdup (\"symbols\");\n\tret->os = strdup (\"unknown\");\n\tret->arch = sm.arch ? strdup (sm.arch) : NULL;\n\tret->bits = sm.bits;\n\tret->type = strdup (\"Symbols file\");\n\tret->subsystem = strdup (\"llvm\");\n\tret->has_va = true;\n\n\treturn ret;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":411790,"func":"on_name_acquired (GDBusConnection *connection,\n                  const gchar     *name,\n                  gpointer         user_data)\n{\n  g_bus_watch_name (G_BUS_TYPE_SESSION,\n                    \"org.gnome.SessionManager\",\n                    G_BUS_NAME_WATCHER_FLAGS_NONE,\n                    name_appeared_handler, NULL,\n                    user_data, NULL);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":336511,"func":"void reds_unregister_channel(RedsState *reds, RedChannel *channel)\n{\n    reds->channels.remove(red::shared_ptr<RedChannel>(channel));\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":226304,"func":"\nGF_Err gitn_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tGroupIdToNameBox *ptr = (GroupIdToNameBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 2);\n\tptr->nb_entries = gf_bs_read_u16(bs);\n\tif (ptr->size \/ 4 < ptr->nb_entries)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tGF_SAFE_ALLOC_N(ptr->entries, ptr->nb_entries, GroupIdNameEntry);\n\tif (!ptr->entries) return GF_OUT_OF_MEM;\n\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tISOM_DECREASE_SIZE(ptr, 4);\n\t\tptr->entries[i].group_id = gf_bs_read_u32(bs);\n\n\t\te = gf_isom_read_null_terminated_string(s, bs, ptr->size, &ptr->entries[i].name);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":404736,"func":"static inline unsigned last_fd(struct fdtable *fdt)\n{\n\treturn fdt->max_fds - 1;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":310199,"func":"reset_scroll_region(NCURSES_SP_DCL0)\n\/* Set the scroll-region to a known state (the default) *\/\n{\n    if (change_scroll_region) {\n\tNCURSES_PUTP2(\"change_scroll_region\",\n\t\t      TIPARM_2(change_scroll_region,\n\t\t\t       0, screen_lines(SP_PARM) - 1));\n    }\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":234212,"func":"init_dwarf_regnames_iamcu (void)\n{\n  dwarf_regnames = dwarf_regnames_iamcu;\n  dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_iamcu);\n  dwarf_regnames_lookup_func = regname_internal_by_table_only;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":512480,"func":"  Item** addr(uint i) { return arg_count ? args + i : NULL; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":244303,"func":"GF_Err fdpa_box_size(GF_Box *s)\n{\n\tu32 i;\n\tGF_FDpacketBox *ptr = (GF_FDpacketBox *)s;\n\n\tptr->size += 5;\n\n\tfor (i=0; i<ptr->header_ext_count; i++) {\n\t\tptr->size += 1;\n\t\tif (ptr->headers[i].header_extension_type > 127) {\n\t\t\tptr->size += 3;\n\t\t} else {\n\t\t\tptr->size += 1 + ptr->headers[i].data_length;\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":441826,"func":"SProcXkbSetIndicatorMap(ClientPtr client)\n{\n    REQUEST(xkbSetIndicatorMapReq);\n\n    swaps(&stuff->length);\n    REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);\n    swaps(&stuff->deviceSpec);\n    swapl(&stuff->which);\n    return ProcXkbSetIndicatorMap(client);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":389674,"func":"tv_get_bool(typval_T *varp)\n{\n    return tv_get_bool_or_number_chk(varp, NULL, TRUE);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":401526,"func":"static __init void timer_base_init_expiry_lock(struct timer_base *base)\n{\n\tspin_lock_init(&base->expiry_lock);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":405336,"func":"static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,\n\t\t\t\t\t\tint tos, int oif,\n\t\t\t\t\t\txfrm_address_t *prev_saddr,\n\t\t\t\t\t\txfrm_address_t *prev_daddr,\n\t\t\t\t\t\tint family, u32 mark)\n{\n\tstruct net *net = xs_net(x);\n\txfrm_address_t *saddr = &x->props.saddr;\n\txfrm_address_t *daddr = &x->id.daddr;\n\tstruct dst_entry *dst;\n\n\tif (x->type->flags & XFRM_TYPE_LOCAL_COADDR) {\n\t\tsaddr = x->coaddr;\n\t\tdaddr = prev_daddr;\n\t}\n\tif (x->type->flags & XFRM_TYPE_REMOTE_COADDR) {\n\t\tsaddr = prev_saddr;\n\t\tdaddr = x->coaddr;\n\t}\n\n\tdst = __xfrm_dst_lookup(net, tos, oif, saddr, daddr, family, mark);\n\n\tif (!IS_ERR(dst)) {\n\t\tif (prev_saddr != saddr)\n\t\t\tmemcpy(prev_saddr, saddr,  sizeof(*prev_saddr));\n\t\tif (prev_daddr != daddr)\n\t\t\tmemcpy(prev_daddr, daddr,  sizeof(*prev_daddr));\n\t}\n\n\treturn dst;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":220466,"func":"XlaCompiler::Options GenerateCompilerOptions(\n    const XlaCompilationCache& cache,\n    const FunctionLibraryRuntime& function_library, DeviceBase* device,\n    se::Stream* stream, const XlaPlatformInfo& platform_info,\n    bool has_ref_vars) {\n  XlaCompiler::Options options;\n  options.client = static_cast<xla::LocalClient*>(cache.client());\n  if (stream != nullptr) {\n    options.device_ordinal = stream->parent()->device_ordinal();\n  }\n  options.device_type = cache.device_type();\n  options.flib_def = function_library.GetFunctionLibraryDefinition();\n  options.graph_def_version = function_library.graph_def_version();\n  options.allow_cpu_custom_calls =\n      (platform_info.platform_id() == se::host::kHostPlatformId);\n  options.device_allocator = GetAllocator(device, stream, platform_info);\n  if (platform_info.xla_device_metadata()) {\n    options.shape_determination_fns =\n        platform_info.xla_device_metadata()->default_shape_determination_fns();\n  }\n  \/\/ If reference variables are not present in the graph, we can safely alias\n  \/\/ passthrough parameters without performing a copy.\n  options.alias_passthrough_params =\n      !has_ref_vars && !platform_info.is_on_xla_device();\n  return options;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":385851,"func":"int finish_open(struct file *file, struct dentry *dentry,\n\t\tint (*open)(struct inode *, struct file *),\n\t\tint *opened)\n{\n\tint error;\n\tBUG_ON(*opened & FILE_OPENED); \/* once it's opened, it's opened *\/\n\n\tfile->f_path.dentry = dentry;\n\terror = do_dentry_open(file, open, current_cred());\n\tif (!error)\n\t\t*opened |= FILE_OPENED;\n\n\treturn error;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":221385,"func":"static u64 nested_svm_get_tdp_pdptr(struct kvm_vcpu *vcpu, int index)\n{\n\tstruct vcpu_svm *svm = to_svm(vcpu);\n\tu64 cr3 = svm->nested.ctl.nested_cr3;\n\tu64 pdpte;\n\tint ret;\n\n\tret = kvm_vcpu_read_guest_page(vcpu, gpa_to_gfn(cr3), &pdpte,\n\t\t\t\t       offset_in_page(cr3) + index * 8, 8);\n\tif (ret)\n\t\treturn 0;\n\treturn pdpte;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":225678,"func":"\nGF_Err xtra_box_size(GF_Box *s)\n{\n\tGF_XtraBox *ptr = (GF_XtraBox *)s;\n\tu32 i, count = gf_list_count(ptr->tags);\n\tfor (i=0; i<count; i++) {\n\t\tGF_XtraTag *tag = gf_list_get(ptr->tags, i);\n\t\tptr->size += 18 + (u32) strlen(tag->name) + tag->prop_size;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":273925,"func":"static void handle_RNTO(ctrl_t *ctrl, char *arg)\n{\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":90123,"func":"  bool Connected() const { return true; }\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":262092,"func":"  explicit BoostedTreesSparseCalculateBestFeatureSplitOp(\n      OpKernelConstruction* const context)\n      : OpKernel(context) {\n    \/\/ TODO(crawles): Using logits_dim_ for multi-class split.\n    OP_REQUIRES_OK(context, context->GetAttr(\"logits_dimension\", &logits_dim_));\n    \/\/ TODO(tanzheny): Using this for equality split.\n    OP_REQUIRES_OK(context, context->GetAttr(\"split_type\", &split_type_));\n  }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":294509,"func":"d_lite_next_year(int argc, VALUE *argv, VALUE self)\n{\n    VALUE n;\n\n    rb_scan_args(argc, argv, \"01\", &n);\n    if (argc < 1)\n\tn = INT2FIX(1);\n    return d_lite_rshift(self, f_mul(n, INT2FIX(12)));\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":387880,"func":"bool InstanceKlass::has_stored_fingerprint() const {\n#if INCLUDE_AOT\n  return should_store_fingerprint() || is_shared();\n#else\n  return false;\n#endif\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":226341,"func":"GF_Err pmax_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_PMAXBox *ptr = (GF_PMAXBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->maxSize);\n\treturn GF_OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":401556,"func":"static inline void timer_base_init_expiry_lock(struct timer_base *base) { }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":199836,"func":"PJ_DEF(int) pj_scan_get_char( pj_scanner *scanner )\n{\n    int chr = *scanner->curptr;\n\n    if (!chr) {\n\tpj_scan_syntax_err(scanner);\n\treturn 0;\n    }\n\n    ++scanner->curptr;\n\n    if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {\n\tpj_scan_skip_whitespace(scanner);\n    }\n    return chr;\n}","target":1,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":226245,"func":"\nGF_Err tref_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read_ex(s, bs, s->type);","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":317363,"func":"static void smack_cred_getsecid(const struct cred *cred, u32 *secid)\n{\n\tstruct smack_known *skp;\n\n\trcu_read_lock();\n\tskp = smk_of_task(smack_cred(cred));\n\t*secid = skp->smk_secid;\n\trcu_read_unlock();\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":442797,"func":"int main(int argc, char *argv[])\n{\n  int res;\n  struct Configurable config;\n\n  memset(&config, 0, sizeof(struct Configurable));\n\n  config.errors = stderr; \/* default errors to stderr *\/\n\n  checkfds();\n\n  res = operate(&config, argc, argv);\n  free_config_fields(&config);\n\n#ifdef __NOVELL_LIBC__\n  pressanykey();\n#endif\n#ifdef  VMS\n  if (res > CURL_LAST) res = CURL_LAST; \/* If CURL_LAST exceeded then *\/\n  return (vms_cond[res]|vms_show);      \/* curlmsg.h is out of sync.  *\/\n#else\n  return res;\n#endif\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":430391,"func":"static void nlattr_set(struct nlattr *attr, u8 val,\n\t\t       const struct ovs_len_tbl *tbl)\n{\n\tstruct nlattr *nla;\n\tint rem;\n\n\t\/* The nlattr stream should already have been validated *\/\n\tnla_for_each_nested(nla, attr, rem) {\n\t\tif (tbl[nla_type(nla)].len == OVS_ATTR_NESTED)\n\t\t\tnlattr_set(nla, val, tbl[nla_type(nla)].next ? : tbl);\n\t\telse\n\t\t\tmemset(nla_data(nla), val, nla_len(nla));\n\n\t\tif (nla_type(nla) == OVS_KEY_ATTR_CT_STATE)\n\t\t\t*(u32 *)nla_data(nla) &= CT_SUPPORTED_MASK;\n\t}\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":281162,"func":"void __init xfrm_init(void)\n{\n\tflow_cache_hp_init();\n\tregister_pernet_subsys(&xfrm_net_ops);\n\tseqcount_init(&xfrm_policy_hash_generation);\n\txfrm_input_init();\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":512458,"func":"my_decimal *Item_func_coalesce::decimal_op(my_decimal *decimal_value)\n{\n  DBUG_ASSERT(fixed == 1);\n  null_value= 0;\n  for (uint i= 0; i < arg_count; i++)\n  {\n    my_decimal *res= args[i]->val_decimal(decimal_value);\n    if (!args[i]->null_value)\n      return res;\n  }\n  null_value=1;\n  return 0;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":245192,"func":"xb_mysql_numrows(MYSQL *connection, const char *query, bool die_on_error)\n{\n\tmy_ulonglong rows_count = 0;\n\tMYSQL_RES *result = xb_mysql_query(connection, query, true,\n\t\tdie_on_error);\n\tif (result) {\n\t\trows_count = mysql_num_rows(result);\n\t\tmysql_free_result(result);\n\t}\n\treturn rows_count;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":483485,"func":"static int generic_ops_register(void)\n{\n\tgeneric_ops.get_variable = efi.get_variable;\n\tgeneric_ops.set_variable = efi.set_variable;\n\tgeneric_ops.set_variable_nonblocking = efi.set_variable_nonblocking;\n\tgeneric_ops.get_next_variable = efi.get_next_variable;\n\tgeneric_ops.query_variable_store = efi_query_variable_store;\n\n\treturn efivars_register(&generic_efivars, &generic_ops, efi_kobj);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":401577,"func":"void get_random_bytes(void *buf, int nbytes)\n{\n\tstatic void *previous;\n\n\twarn_unseeded_randomness(&previous);\n\t_get_random_bytes(buf, nbytes);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":231799,"func":"TEST_F(QuicServerTransportTest, DestroyWithoutClosing) {\n  StreamId streamId = server->createBidirectionalStream().value();\n\n  MockReadCallback readCb;\n  server->setReadCallback(streamId, &readCb);\n\n  EXPECT_CALL(connCallback, onConnectionError(_)).Times(0);\n  EXPECT_CALL(connCallback, onConnectionEnd()).Times(0);\n  MockDeliveryCallback deliveryCallback;\n  auto write = IOBuf::copyBuffer(\"no\");\n  server->writeChain(streamId, write->clone(), true, &deliveryCallback);\n\n  EXPECT_CALL(deliveryCallback, onCanceled(_, _));\n  EXPECT_CALL(readCb, readError(_, _));\n\n  server.reset();\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":274632,"func":"ctcompare(const char *a,\t\t\/* I - First string *\/\n          const char *b)\t\t\/* I - Second string *\/\n{\n  int\tresult = 0;\t\t\t\/* Result *\/\n\n\n  while (*a && *b)\n  {\n    result |= *a ^ *b;\n    a ++;\n    b ++;\n  }\n\n  \/\/ either both *a and *b == '\\0', or one points inside a string,\n  \/\/ so factor that in.\n  result |= (*a ^ *b);\n\n  return (result);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":432248,"func":"CPUState *qemu_get_cpu(struct uc_struct *uc, int index)\n{\n    CPUState *cpu = uc->cpu;\n    if (cpu->cpu_index == index) {\n        return cpu;\n    }\n\n    return NULL;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":289296,"func":"static int snd_pcm_oss_capture_position_fixup(struct snd_pcm_substream *substream, snd_pcm_sframes_t *delay)\n{\n\tstruct snd_pcm_runtime *runtime;\n\tsnd_pcm_uframes_t frames;\n\tint err = 0;\n\n\twhile (1) {\n\t\terr = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, delay);\n\t\tif (err < 0)\n\t\t\tbreak;\n\t\truntime = substream->runtime;\n\t\tif (*delay <= (snd_pcm_sframes_t)runtime->buffer_size)\n\t\t\tbreak;\n\t\t\/* in case of overrun, skip whole periods like OSS\/Linux driver does *\/\n\t\t\/* until avail(delay) <= buffer_size *\/\n\t\tframes = (*delay - runtime->buffer_size) + runtime->period_size - 1;\n\t\tframes \/= runtime->period_size;\n\t\tframes *= runtime->period_size;\n\t\terr = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_FORWARD, &frames);\n\t\tif (err < 0)\n\t\t\tbreak;\n\t}\n\treturn err;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":512572,"func":"  Field *create_tmp_field_ex(TABLE *table, Tmp_field_src *src,\n                             const Tmp_field_param *param)\n  {\n    \/*\n      We can get to here when using a CURSOR for a query with NAME_CONST():\n        DECLARE c CURSOR FOR SELECT NAME_CONST('x','y') FROM t1;\n        OPEN c;\n    *\/\n    return tmp_table_field_from_field_type_maybe_null(table, src, param,\n                                              type() == Item::NULL_ITEM);\n  }","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":409493,"func":"scroll_start(void)\n{\n    if (*T_VS != NUL && *T_CVS != NUL)\n    {\n\tMAY_WANT_TO_LOG_THIS;\n\tout_str(T_VS);\n\tout_str(T_CVS);\n\tscreen_start();\t\t\/\/ don't know where cursor is now\n    }\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":450429,"func":"static int send_solid_rect(VncState *vs)\n{\n    size_t bytes;\n\n    vnc_write_u8(vs, VNC_TIGHT_FILL << 4); \/* no flushing, no filter *\/\n\n    if (vs->tight->pixel24) {\n        tight_pack24(vs, vs->tight->tight.buffer, 1, &vs->tight->tight.offset);\n        bytes = 3;\n    } else {\n        bytes = vs->client_pf.bytes_per_pixel;\n    }\n\n    vnc_write(vs, vs->tight->tight.buffer, bytes);\n    return 1;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":226345,"func":"\nGF_Err trex_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TrackExtendsBox *ptr = (GF_TrackExtendsBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->trackID);\n\t\/\/we always write 1 in trex default sample desc as using 0 breaks chrome\/opera\/...\n\tgf_bs_write_u32(bs, ptr->def_sample_desc_index ? ptr->def_sample_desc_index : 1);\n\tgf_bs_write_u32(bs, ptr->def_sample_duration);\n\tgf_bs_write_u32(bs, ptr->def_sample_size);\n\tgf_bs_write_u32(bs, ptr->def_sample_flags);\n\treturn GF_OK;","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":503871,"func":"SCM_DEFINE (scm_lstat, \"lstat\", 1, 0, 0, \n            (SCM str),\n\t    \"Similar to @code{stat}, but does not follow symbolic links, i.e.,\\n\"\n\t    \"it will return information about a symbolic link itself, not the\\n\"\n\t    \"file it points to.  @var{str} must be a string.\")\n#define FUNC_NAME s_scm_lstat\n{\n  int rv;\n  struct stat_or_stat64 stat_temp;\n\n  STRING_SYSCALL (str, c_str, rv = lstat_or_lstat64 (c_str, &stat_temp));\n  if (rv != 0)\n    {\n      int en = errno;\n\n      SCM_SYSERROR_MSG (\"~A: ~S\",\n\t\t\tscm_list_2 (scm_strerror (scm_from_int (en)), str),\n\t\t\ten);\n    }\n  return scm_stat2scm (&stat_temp);\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":261217,"func":"int SN_Client_WaitMessage(MqttClient *client, int timeout_ms)\n{\n    if (client == NULL)\n        return MQTT_CODE_ERROR_BAD_ARG;\n    return SN_Client_WaitMessage_ex(client, &client->msgSN, timeout_ms);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":333068,"func":"skip_to_start(int c, colnr_T *colp)\n{\n    char_u *s;\n\n    \/\/ Used often, do some work to avoid call overhead.\n    if (!rex.reg_ic && !has_mbyte)\n\ts = vim_strbyte(rex.line + *colp, c);\n    else\n\ts = cstrchr(rex.line + *colp, c);\n    if (s == NULL)\n\treturn FAIL;\n    *colp = (int)(s - rex.line);\n    return OK;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":246491,"func":"RList *r_bin_wasm_get_custom_names(RBinWasmObj *bin) {\n\tRList *customs = NULL;\n\n\tr_return_val_if_fail (bin && bin->g_sections, NULL);\n\n\tif (bin->g_names) {\n\t\treturn bin->g_names;\n\t}\n\tif (!(customs = r_bin_wasm_get_sections_by_id (bin->g_sections, R_BIN_WASM_SECTION_CUSTOM))) {\n\t\treturn r_list_new ();\n\t}\n\t\/\/ support for multiple \"name\" sections against spec\n\tRBinWasmSection *cust = (RBinWasmSection *)r_list_first (customs);\n\tif (!cust || !cust->name) {\n\t\tr_list_free (customs);\n\t\treturn r_list_new ();\n\t}\n\tif (strcmp (cust->name, \"name\")) {\n\t\tr_list_free (customs);\n\t\treturn r_list_new ();\n\t}\n\tbin->g_names = r_bin_wasm_get_custom_name_entries (bin, cust);\n\tr_list_free (customs);\n\treturn bin->g_names;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":459104,"func":"static struct tcf_chain *tcf_chain_lookup_rcu(const struct tcf_block *block,\n\t\t\t\t\t      u32 chain_index)\n{\n\tstruct tcf_chain *chain;\n\n\tlist_for_each_entry_rcu(chain, &block->chain_list, list) {\n\t\tif (chain->index == chain_index)\n\t\t\treturn chain;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":336579,"func":"void RedCharDeviceVDIPort::send_msg_to_client(RedPipeItem *msg, RedCharDeviceClientOpaque *opaque)\n{\n    RedClient *client = (RedClient *) opaque;\n    RedVDIReadBuf *agent_data_buf = static_cast<RedVDIReadBuf*>(msg);\n\n    client->get_main()->push_agent_data(red::shared_ptr<RedAgentDataPipeItem>(agent_data_buf));\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":238444,"func":"static int is_branch_taken(struct bpf_reg_state *reg, u64 val, u8 opcode,\n\t\t\t   bool is_jmp32)\n{\n\tif (__is_pointer_value(false, reg)) {\n\t\tif (!reg_type_not_null(reg->type))\n\t\t\treturn -1;\n\n\t\t\/* If pointer is valid tests against zero will fail so we can\n\t\t * use this to direct branch taken.\n\t\t *\/\n\t\tif (val != 0)\n\t\t\treturn -1;\n\n\t\tswitch (opcode) {\n\t\tcase BPF_JEQ:\n\t\t\treturn 0;\n\t\tcase BPF_JNE:\n\t\t\treturn 1;\n\t\tdefault:\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (is_jmp32)\n\t\treturn is_branch32_taken(reg, val, opcode);\n\treturn is_branch64_taken(reg, val, opcode);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":418796,"func":"mouse_model_popup(void)\n{\n    return (p_mousem[0] == 'p');\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":294607,"func":"m_wnumx(union DateData *x, int f)\n{\n    int ry, rw, rd;\n\n    c_jd_to_weeknum(m_local_jd(x), f, m_virtual_sg(x), \/* !=m_sg() *\/\n\t\t    &ry, &rw, &rd);\n    return rw;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":261942,"func":"njs_string_decode_base64_core(njs_vm_t *vm, njs_value_t *value,\n    const njs_str_t *src, njs_bool_t url)\n{\n    size_t     length;\n    const u_char *basis;\n    njs_str_t  dst;\n\n    basis = (url) ? njs_basis64url : njs_basis64;\n\n    length = njs_decode_base64_length_core(src, basis, &dst.length);\n\n    if (njs_slow_path(dst.length == 0)) {\n        vm->retval = njs_string_empty;\n        return NJS_OK;\n    }\n\n    dst.start = njs_string_alloc(vm, value, dst.length, length);\n    if (njs_slow_path(dst.start == NULL)) {\n        return NJS_ERROR;\n    }\n\n    njs_decode_base64_core(&dst, src, basis);\n\n    return NJS_OK;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":413610,"func":"static void cccb(void *u) {\n\tesil_anal_stop = true;\n\teprintf (\"^C\\n\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":512501,"func":"void Item_equal::merge(THD *thd, Item_equal *item)\n{\n  Item *c= item->get_const();\n  if (c)\n    item->equal_items.pop();\n  equal_items.append(&item->equal_items);\n  if (c)\n  {\n    \/* \n      The flag cond_false will be set to TRUE after this if \n      the multiple equality already contains a constant and its \n      value is not equal to the value of c.\n    *\/\n    add_const(thd, c);\n  }\n  cond_false|= item->cond_false;\n} ","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":222569,"func":"Status FunctionLibraryDefinition::RemoveFunctionHelper(const string& func) {\n  const auto& i = function_defs_.find(func);\n  if (i == function_defs_.end()) {\n    return errors::InvalidArgument(\"Tried to remove non-existent function '\",\n                                   func, \"'.\");\n  }\n  function_defs_.erase(i);\n  return Status::OK();\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":372350,"func":"int sdb_checkline(char f)\n{\n  int i;\n  char ff=f>>1;\n  for(i=0;i<7;i++)\n  {\n    if((ff & 1) && (yylineno==sdb_lines[i]))\n      return i+1;\n    ff>>=1;\n    if (ff==0) return 0;\n  }\n  return 0;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":369438,"func":"static void io_req_task_queue(struct io_kiocb *req)\n{\n\treq->io_task_work.func = io_req_task_submit;\n\tio_req_task_work_add(req, false);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":450319,"func":"static void vnc_listen_io(QIONetListener *listener,\n                          QIOChannelSocket *cioc,\n                          void *opaque)\n{\n    VncDisplay *vd = opaque;\n    bool isWebsock = listener == vd->wslistener;\n\n    qio_channel_set_name(QIO_CHANNEL(cioc),\n                         isWebsock ? \"vnc-ws-server\" : \"vnc-server\");\n    qio_channel_set_delay(QIO_CHANNEL(cioc), false);\n    vnc_connect(vd, cioc, false, isWebsock);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":364773,"func":"free_tag_stuff(void)\n{\n    ga_clear_strings(&tag_fnames);\n    if (curwin != NULL)\n\tdo_tag(NULL, DT_FREE, 0, 0, 0);\n    tag_freematch();\n\n# if defined(FEAT_QUICKFIX)\n    tagstack_clear_entry(&ptag_entry);\n# endif\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":473978,"func":"utf32le_is_mbc_newline(const UChar* p, const UChar* end,\n\t\t       OnigEncoding enc ARG_UNUSED)\n{\n  if (p + 3 < end) {\n    if (*p == 0x0a && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0)\n      return 1;\n#ifdef USE_UNICODE_ALL_LINE_TERMINATORS\n    if ((\n#ifndef USE_CRNL_AS_LINE_TERMINATOR\n\t *p == 0x0d ||\n#endif\n\t *p == 0x85)\n\t&& *(p+1) == 0x00 && (p+2) == 0x00 && *(p+3) == 0x00)\n      return 1;\n    if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28)\n\t&& *(p+2) == 0x00 && *(p+3) == 0x00)\n      return 1;\n#endif\n  }\n  return 0;\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":344762,"func":"opt_dequote(const char **sp, const char **errstrp)\n{\n\tconst char *s = *sp;\n\tchar *ret;\n\tsize_t i;\n\n\t*errstrp = NULL;\n\tif (*s != '\"') {\n\t\t*errstrp = \"missing start quote\";\n\t\treturn NULL;\n\t}\n\ts++;\n\tif ((ret = malloc(strlen((s)) + 1)) == NULL) {\n\t\t*errstrp = \"memory allocation failed\";\n\t\treturn NULL;\n\t}\n\tfor (i = 0; *s != '\\0' && *s != '\"';) {\n\t\tif (s[0] == '\\\\' && s[1] == '\"')\n\t\t\ts++;\n\t\tret[i++] = *s++;\n\t}\n\tif (*s == '\\0') {\n\t\t*errstrp = \"missing end quote\";\n\t\tfree(ret);\n\t\treturn NULL;\n\t}\n\tret[i] = '\\0';\n\ts++;\n\t*sp = s;\n\treturn ret;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":294701,"func":"ns_to_sec(VALUE n)\n{\n    if (FIXNUM_P(n))\n\treturn rb_rational_new2(n, INT2FIX(SECOND_IN_NANOSECONDS));\n    return f_quo(n, INT2FIX(SECOND_IN_NANOSECONDS));\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":263314,"func":"char *_q_makeword(char *str, char stop)\n{\n    char *word;\n    int  len, i;\n\n    for (len = 0; ((str[len] != stop) && (str[len])); len++);\n    word = (char *)malloc(sizeof(char) * (len + 1));\n\n    for (i = 0; i < len; i++) word[i] = str[i];\n    word[i] = '\\0';\n\n    if (str[len])len++;\n    for (i = len; str[i]; i++) str[i - len] = str[i];\n    str[i - len] = '\\0';\n\n    return word;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":244249,"func":"void lsr1_box_del(GF_Box *s)\n{\n\tGF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\tif (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);\n\tgf_free(ptr);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":336676,"func":"SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *reds,\n                                               const char *passwd, int lifetime,\n                                               int fail_if_connected,\n                                               int disconnect_if_connected)\n{\n    if (reds_main_channel_connected(reds)) {\n        if (fail_if_connected) {\n            return -1;\n        }\n        if (disconnect_if_connected) {\n            reds_disconnect(reds);\n        }\n    }\n\n    on_activating_ticketing(reds);\n    reds->config->ticketing_enabled = TRUE;\n    if (lifetime == 0) {\n        reds->config->taTicket.expiration_time = INT_MAX;\n    } else {\n        time_t now = spice_get_monotonic_time_ns() \/ NSEC_PER_SEC;\n        reds->config->taTicket.expiration_time = now + lifetime;\n    }\n    if (passwd != NULL) {\n        if (strlen(passwd) > SPICE_MAX_PASSWORD_LENGTH)\n            return -1;\n        g_strlcpy(reds->config->taTicket.password, passwd, sizeof(reds->config->taTicket.password));\n    } else {\n        memset(reds->config->taTicket.password, 0, sizeof(reds->config->taTicket.password));\n        reds->config->taTicket.expiration_time = 0;\n    }\n    return 0;\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":261393,"func":"static enum InterPredIdc  decode_inter_pred_idc(thread_context* tctx,\n                                               int x0, int y0,\n                                               int nPbW, int nPbH,\n                                               int ctDepth)\n{\n  logtrace(LogSlice,\"# inter_pred_idc\\n\");\n\n  int value;\n\n  context_model* model = &tctx->ctx_model[CONTEXT_MODEL_INTER_PRED_IDC];\n\n  if (nPbW+nPbH==12) {\n    value = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &model[4]);\n  }\n  else {\n    int bit0 = decode_CABAC_bit(&tctx->cabac_decoder,\n                                &model[ctDepth]);\n    if (bit0==0) {\n      value = decode_CABAC_bit(&tctx->cabac_decoder,\n                               &model[4]);\n    }\n    else {\n      value = 2;\n    }\n  }\n\n  logtrace(LogSlice,\"> inter_pred_idc = %d (%s)\\n\",value,\n           value==0 ? \"L0\" : (value==1 ? \"L1\" : \"BI\"));\n\n  logtrace(LogSymbols,\"$1 decode_inter_pred_idx=%d\\n\",value+1);\n\n  return (enum InterPredIdc) (value+1);\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":226208,"func":"void nump_box_del(GF_Box *s)\n{\n\tgf_free((GF_NUMPBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":225607,"func":"GF_Box *stdp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DegradationPriorityBox, GF_ISOM_BOX_TYPE_STDP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":508902,"func":"int my_wc_mb_utf8_escape_single_quote(CHARSET_INFO *cs, my_wc_t wc,\n                                      uchar *str, uchar *end)\n{\n  return my_wc_mb_utf8_escape(cs, wc, str, end, '\\'', 0);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":438669,"func":"static void virtio_rpmsg_release_device(struct device *dev)\n{\n\tstruct rpmsg_device *rpdev = to_rpmsg_device(dev);\n\tstruct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);\n\n\tkfree(vch);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":294590,"func":"d_lite_saturday_p(VALUE self)\n{\n    get_d1(self);\n    return f_boolcast(m_wday(dat) == 6);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":413821,"func":"Method* LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) {\n\n  Klass* resolved_klass = link_info.resolved_klass();\n  Method* resolved_method;\n  if (!resolved_klass->is_interface()) {\n    resolved_method = resolve_method(link_info, Bytecodes::_invokestatic, CHECK_NULL);\n  } else {\n    resolved_method = resolve_interface_method(link_info, Bytecodes::_invokestatic, CHECK_NULL);\n  }\n  assert(resolved_method->name() != vmSymbols::class_initializer_name(), \"should have been checked in verifier\");\n\n  \/\/ check if static\n  if (!resolved_method->is_static()) {\n    ResourceMark rm(THREAD);\n    stringStream ss;\n    ss.print(\"Expected static method '\");\n    resolved_method->print_external_name(&ss);\n    ss.print(\"'\");\n    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());\n  }\n  return resolved_method;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":125909,"func":"v8::Handle<v8::Value> V8ThrowException::throwTypeError(v8::Isolate* isolate, const String& message)\n{\n    v8::Handle<v8::Value> exception = V8ThrowException::createTypeError(isolate, message);\n    return V8ThrowException::throwException(exception, isolate);\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":359670,"func":"DEFUN (bgp_confederation_identifier,\n       bgp_confederation_identifier_cmd,\n       \"bgp confederation identifier <1-65535>\",\n       \"BGP specific commands\\n\"\n       \"AS confederation parameters\\n\"\n       \"AS number\\n\"\n       \"Set routing domain confederation AS\\n\")\n{\n  struct bgp *bgp;\n  as_t as;\n\n  bgp = vty->index;\n\n  VTY_GET_INTEGER (\"AS\", as, argv[0]);\n\n  bgp_confederation_id_set (bgp, as);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":481255,"func":"static int mlx5_fpga_conn_post_recv_buf(struct mlx5_fpga_conn *conn)\n{\n\tstruct mlx5_fpga_dma_buf *buf;\n\tint err;\n\n\tbuf = kzalloc(sizeof(*buf) + MLX5_FPGA_RECV_SIZE, 0);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tbuf->sg[0].data = (void *)(buf + 1);\n\tbuf->sg[0].size = MLX5_FPGA_RECV_SIZE;\n\tbuf->dma_dir = DMA_FROM_DEVICE;\n\n\terr = mlx5_fpga_conn_post_recv(conn, buf);\n\tif (err)\n\t\tkfree(buf);\n\n\treturn err;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":386536,"func":"void DL_Dxf::addDimAngular3P(DL_CreationInterface* creationInterface) {\n    DL_DimensionData d = getDimData();\n\n    \/\/ angular dimension (3P):\n    DL_DimAngular3PData da(\n        \/\/ definition point 1\n        getRealValue(13, 0.0),\n        getRealValue(23, 0.0),\n        getRealValue(33, 0.0),\n        \/\/ definition point 2\n        getRealValue(14, 0.0),\n        getRealValue(24, 0.0),\n        getRealValue(34, 0.0),\n        \/\/ definition point 3\n        getRealValue(15, 0.0),\n        getRealValue(25, 0.0),\n        getRealValue(35, 0.0));\n    creationInterface->addDimAngular3P(d, da);\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":282970,"func":"LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em)\n{\n  err_argmsg(L, narg, err2msg(em));\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":338036,"func":"void WasmBinaryBuilder::readMemory() {\n  BYN_TRACE(\"== readMemory\\n\");\n  auto numMemories = getU32LEB();\n  if (!numMemories) {\n    return;\n  }\n  if (numMemories != 1) {\n    throwError(\"Must be exactly 1 memory\");\n  }\n  if (wasm.memory.exists) {\n    throwError(\"Memory cannot be both imported and defined\");\n  }\n  wasm.memory.exists = true;\n  getResizableLimits(wasm.memory.initial,\n                     wasm.memory.max,\n                     wasm.memory.shared,\n                     wasm.memory.indexType,\n                     Memory::kUnlimitedSize);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":273887,"func":"static void handle_FEAT(ctrl_t *ctrl, char *arg)\n{\n\tsnprintf(ctrl->buf, ctrl->bufsz, \"211-Features:\\r\\n\"\n\t\t \" EPSV\\r\\n\"\n\t\t \" PASV\\r\\n\"\n\t\t \" SIZE\\r\\n\"\n\t\t \" UTF8\\r\\n\"\n\t\t \" REST STREAM\\r\\n\"\n\t\t \" MLST modify*;perm*;size*;type*;\\r\\n\"\n\t\t \"211 End\\r\\n\");\n\tsend_msg(ctrl->sd, ctrl->buf);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":247141,"func":"GF_Err gf_filter_post_task(GF_Filter *filter, Bool (*task_execute) (GF_Filter *filter, void *callback, u32 *reschedule_ms), void *udta, const char *task_name)\n{\n\tGF_UserTask *utask;\n\tif (!filter || !task_execute) return GF_BAD_PARAM;\n\tGF_SAFEALLOC(utask, GF_UserTask);\n\tif (!utask) return GF_OUT_OF_MEM;\n\tutask->callback = udta;\n\tutask->task_execute_filter = task_execute;\n\tutask->fsess = filter->session;\n\tgf_fs_post_task(filter->session, gf_fs_user_task, filter, NULL, task_name ? task_name : \"user_task\", utask);\n\treturn GF_OK;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":225461,"func":"NodeDef* MutableGraphView::AddNode(NodeDef&& node) {\n  auto* node_in_graph = graph()->add_node();\n  *node_in_graph = std::move(node);\n\n  AddUniqueNodeOrDie(node_in_graph);\n\n  AddAndDedupFanouts(node_in_graph);\n  return node_in_graph;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":329900,"func":"_cairo_image_spans_compositor_get (void)\n{\n    static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;\n    static cairo_spans_compositor_t spans;\n    static cairo_compositor_t shape;\n\n    if (_cairo_atomic_init_once_enter(&once)) {\n\t_cairo_shape_mask_compositor_init (&shape,\n\t\t\t\t\t   _cairo_image_traps_compositor_get());\n\tshape.glyphs = NULL;\n\n\t_cairo_spans_compositor_init (&spans, &shape);\n\n\tspans.flags = 0;\n#if PIXMAN_HAS_OP_LERP\n\tspans.flags |= CAIRO_SPANS_COMPOSITOR_HAS_LERP;\n#endif\n\n\t\/\/spans.acquire = acquire;\n\t\/\/spans.release = release;\n\tspans.fill_boxes = fill_boxes;\n\tspans.draw_image_boxes = draw_image_boxes;\n\t\/\/spans.copy_boxes = copy_boxes;\n\tspans.pattern_to_surface = _cairo_image_source_create_for_pattern;\n\t\/\/spans.check_composite_boxes = check_composite_boxes;\n\tspans.composite_boxes = composite_boxes;\n\t\/\/spans.check_span_renderer = check_span_renderer;\n\tspans.renderer_init = span_renderer_init;\n\tspans.renderer_fini = span_renderer_fini;\n\n\t_cairo_atomic_init_once_leave(&once);\n    }\n\n    return &spans.base;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":300736,"func":"static int tipc_bind(struct socket *sock, struct sockaddr *skaddr, int alen)\n{\n\tstruct tipc_uaddr *ua = (struct tipc_uaddr *)skaddr;\n\tu32 atype = ua->addrtype;\n\n\tif (alen) {\n\t\tif (!tipc_uaddr_valid(ua, alen))\n\t\t\treturn -EINVAL;\n\t\tif (atype == TIPC_SOCKET_ADDR)\n\t\t\treturn -EAFNOSUPPORT;\n\t\tif (ua->sr.type < TIPC_RESERVED_TYPES) {\n\t\t\tpr_warn_once(\"Can't bind to reserved service type %u\\n\",\n\t\t\t\t     ua->sr.type);\n\t\t\treturn -EACCES;\n\t\t}\n\t}\n\treturn tipc_sk_bind(sock, skaddr, alen);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":337782,"func":"struct sctp_chunk *sctp_make_strreset_tsnreq(\n\t\t\t\t\tconst struct sctp_association *asoc)\n{\n\tstruct sctp_strreset_tsnreq tsnreq;\n\t__u16 length = sizeof(tsnreq);\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_reconf(asoc, length);\n\tif (!retval)\n\t\treturn NULL;\n\n\ttsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;\n\ttsnreq.param_hdr.length = htons(length);\n\ttsnreq.request_seq = htonl(asoc->strreset_outseq);\n\n\tsctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);\n\n\treturn retval;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":294595,"func":"m_zone(union DateData *x)\n{\n    if (simple_dat_p(x))\n\treturn rb_usascii_str_new2(\"+00:00\");\n    return of2str(m_of(x));\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":292194,"func":"dns_name_callback (GObject *obj, GAsyncResult *result, gpointer user_data)\n{\n\tGResolver *resolver = G_RESOLVER(obj);\n\tsession *sess = (session*)user_data;\n\tGList* addrs;\n\tgchar* addr;\n\tGList* list;\n\n\tg_return_if_fail (is_session (sess));\n\n\taddrs = g_resolver_lookup_by_name_finish (resolver, result, NULL);\n\tif (addrs)\n\t{\n\t\tPrintText (sess, _(\"Resolved to:\"));\n\n\t\tfor (list = g_list_first (addrs); list; list = g_list_next (list))\n\t\t{\n\t\t\taddr = g_inet_address_to_string (list->data);\n\t\t\tPrintTextf (sess, \"    %s\", addr);\n\t\t}\n\n\t\tg_resolver_free_addresses (addrs);\n\t}\n\telse\n\t\tPrintText (sess, _(\"Not found\"));\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":436153,"func":"static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx)\n{\n\t\/* see waitqueue_active() comment *\/\n\tsmp_mb();\n\n\tif (ctx->flags & IORING_SETUP_SQPOLL) {\n\t\tif (waitqueue_active(&ctx->cq_wait))\n\t\t\twake_up(&ctx->cq_wait);\n\t}\n\tif (io_should_trigger_evfd(ctx))\n\t\teventfd_signal(ctx->cq_ev_fd, 1);\n\tif (waitqueue_active(&ctx->poll_wait)) {\n\t\twake_up_interruptible(&ctx->poll_wait);\n\t\tkill_fasync(&ctx->cq_fasync, SIGIO, POLL_IN);\n\t}\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":483493,"func":"static int __init parse_efi_cmdline(char *str)\n{\n\tif (!str) {\n\t\tpr_warn(\"need at least one option\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (parse_option_str(str, \"debug\"))\n\t\tset_bit(EFI_DBG, &efi.flags);\n\n\tif (parse_option_str(str, \"noruntime\"))\n\t\tdisable_runtime = true;\n\n\treturn 0;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":432161,"func":"BSONObj PipelineD::getPostBatchResumeToken(const Pipeline* pipeline) {\n    if (auto docSourceCursor =\n            dynamic_cast<DocumentSourceCursor*>(pipeline->_sources.front().get())) {\n        return docSourceCursor->getPostBatchResumeToken();\n    }\n    return BSONObj{};\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":353147,"func":"void SplashOutputDev::restoreState(GfxState *state) {\n  splash->restoreState();\n  needFontUpdate = true;\n  if (t3GlyphStack && !t3GlyphStack->haveDx) {\n    t3GlyphStack->doNotCache = true;\n    error(errSyntaxWarning, -1,\n\t  \"Restore (Q) operator before d0\/d1 in Type 3 glyph\");\n  }\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":312564,"func":"qf_winid(qf_info_T *qi)\n{\n    win_T\t*win;\n\n    \/\/ The quickfix window can be opened even if the quickfix list is not set\n    \/\/ using \":copen\". This is not true for location lists.\n    if (qi == NULL)\n\treturn 0;\n    win = qf_find_win(qi);\n    if (win != NULL)\n\treturn win->w_id;\n    return 0;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":387871,"func":"void InstanceKlass::notify_unload_class(InstanceKlass* ik) {\n  \/\/ notify the debugger\n  if (JvmtiExport::should_post_class_unload()) {\n    JvmtiExport::post_class_unload(ik);\n  }\n\n  \/\/ notify ClassLoadingService of class unload\n  ClassLoadingService::notify_class_unloaded(ik);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":369231,"func":"\t\t\t\t    struct timespec64 *ts, enum hrtimer_mode mode)\n\t__must_hold(&ctx->timeout_lock)\n{\n\tstruct io_timeout_data *io;\n\tstruct io_kiocb *req;\n\tbool found = false;\n\n\tlist_for_each_entry(req, &ctx->ltimeout_list, timeout.list) {\n\t\tfound = user_data == req->user_data;\n\t\tif (found)\n\t\t\tbreak;\n\t}\n\tif (!found)\n\t\treturn -ENOENT;\n\n\tio = req->async_data;\n\tif (hrtimer_try_to_cancel(&io->timer) == -1)\n\t\treturn -EALREADY;\n\thrtimer_init(&io->timer, io_timeout_get_clock(io), mode);\n\tio->timer.function = io_link_timeout_fn;\n\thrtimer_start(&io->timer, timespec64_to_ktime(*ts), mode);\n\treturn 0;","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":256392,"func":"static int bio_uncopy_user(struct bio *bio)\n{\n\tstruct bio_map_data *bmd = bio->bi_private;\n\tint ret = 0;\n\n\tif (!bmd->is_null_mapped) {\n\t\t\/*\n\t\t * if we're in a workqueue, the request is orphaned, so\n\t\t * don't copy into a random user address space, just free\n\t\t * and return -EINTR so user space doesn't expect any data.\n\t\t *\/\n\t\tif (!current->mm)\n\t\t\tret = -EINTR;\n\t\telse if (bio_data_dir(bio) == READ)\n\t\t\tret = bio_copy_to_iter(bio, bmd->iter);\n\t\tif (bmd->is_our_pages)\n\t\t\tbio_free_pages(bio);\n\t}\n\tkfree(bmd);\n\treturn ret;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":369263,"func":"\nstatic void io_fixed_file_set(struct io_fixed_file *file_slot, struct file *file)\n{\n\tunsigned long file_ptr = (unsigned long) file;\n\n\tfile_ptr |= io_file_get_flags(file);\n\tfile_slot->file_ptr = file_ptr;","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":294571,"func":"jd_to_ordinal(VALUE jd, double sg,\n\t      VALUE *nth, int *rjd,\n\t      int *ry, int *rd)\n{\n    decode_jd(jd, nth, rjd);\n    c_jd_to_ordinal(*rjd, sg, ry, rd);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":294659,"func":"jd_to_commercial(VALUE jd, double sg,\n\t\t VALUE *nth, int *rjd,\n\t\t int *ry, int *rw, int *rd)\n{\n    decode_jd(jd, nth, rjd);\n    c_jd_to_commercial(*rjd, sg, ry, rw, rd);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":238536,"func":"static struct bpf_prog *bpf_patch_insn_data(struct bpf_verifier_env *env, u32 off,\n\t\t\t\t\t    const struct bpf_insn *patch, u32 len)\n{\n\tstruct bpf_prog *new_prog;\n\tstruct bpf_insn_aux_data *new_data = NULL;\n\n\tif (len > 1) {\n\t\tnew_data = vzalloc(array_size(env->prog->len + len - 1,\n\t\t\t\t\t      sizeof(struct bpf_insn_aux_data)));\n\t\tif (!new_data)\n\t\t\treturn NULL;\n\t}\n\n\tnew_prog = bpf_patch_insn_single(env->prog, off, patch, len);\n\tif (IS_ERR(new_prog)) {\n\t\tif (PTR_ERR(new_prog) == -ERANGE)\n\t\t\tverbose(env,\n\t\t\t\t\"insn %d cannot be patched due to 16-bit range\\n\",\n\t\t\t\tenv->insn_aux_data[off].orig_idx);\n\t\tvfree(new_data);\n\t\treturn NULL;\n\t}\n\tadjust_insn_aux_data(env, new_data, new_prog, off, len);\n\tadjust_subprog_starts(env, off, len);\n\tadjust_poke_descs(new_prog, off, len);\n\treturn new_prog;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":437376,"func":"add_mode(regex_t* reg, ModeType mode)\n{\n  BB_ADD(reg, &mode, SIZE_MODE);\n  return 0;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":275513,"func":"njs_vm_retval_dump(njs_vm_t *vm, njs_str_t *dst, njs_uint_t indent)\n{\n    if (vm->top_frame == NULL) {\n        \/* An exception was thrown during compilation. *\/\n\n        njs_vm_init(vm);\n    }\n\n    return njs_vm_value_dump(vm, dst, &vm->retval, 0, 1);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":345213,"func":"int conv_uni_to_8bit(u32 uni)\n{\n\tint c;\n\tfor (c = 0; c < 0x100; c++)\n\t\tif (translations[USER_MAP][c] == uni ||\n\t\t   (translations[USER_MAP][c] == (c | 0xf000) && uni == c))\n\t\t\treturn c;\n\treturn -1;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":237874,"func":"qeh_out_on_write (struct lsquic_stream *stream, lsquic_stream_ctx_t *ctx)\n{\n    struct qpack_enc_hdl *const qeh = (void *) ctx;\n    struct lsquic_reader reader = {\n        .lsqr_read  = lsquic_frab_list_read,\n        .lsqr_size  = lsquic_frab_list_size,\n        .lsqr_ctx   = &qeh->qeh_fral,\n    };\n    ssize_t nw;\n\n    nw = lsquic_stream_writef(stream, &reader);\n    if (nw >= 0)\n    {\n        LSQ_DEBUG(\"wrote %zd bytes to stream\", nw);\n        (void) lsquic_stream_flush(stream);\n        if (lsquic_frab_list_empty(&qeh->qeh_fral))\n            lsquic_stream_wantwrite(stream, 0);\n    }\n    else\n    {\n        qeh->qeh_conn->cn_if->ci_internal_error(qeh->qeh_conn,\n                                            \"cannot write to stream\");\n        LSQ_WARN(\"cannot write to stream: %s\", strerror(errno));\n        lsquic_stream_wantwrite(stream, 0);\n    }\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":294704,"func":"set_tmx(VALUE self, struct tmx *tmx)\n{\n    get_d1(self);\n    tmx->dat = (void *)dat;\n    tmx->funcs = &tmx_funcs;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":230389,"func":"PJ_DEF(void) pj_xml_add_node( pj_xml_node *parent, pj_xml_node *node )\n{\n    pj_list_push_back(&parent->node_head, node);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":448924,"func":"int ZEXPORT inflateSyncPoint(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    return state->mode == STORED && state->bits == 0;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":247581,"func":"TestUtilOptionsV2 createProtocolTestOptions(\n    const envoy::config::listener::v3::Listener& listener,\n    const envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext& client_ctx,\n    Network::Address::IpVersion version, std::string protocol) {\n  std::string stats = \"ssl.versions.\" + protocol;\n  TestUtilOptionsV2 options(listener, client_ctx, true, version);\n  options.setExpectedServerStats(stats).setExpectedClientStats(stats);\n  return options.setExpectedProtocolVersion(protocol);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":439118,"func":"static inline void CopyFitsRecord(char *buffer,const char *data,\n  const ssize_t offset)\n{\n  size_t\n    length;\n\n  if (data == (char *) NULL)\n    return;\n  length=MagickMin(strlen(data),80);\n  if (length > (size_t) (FITSBlocksize-offset))\n    length=FITSBlocksize-offset;\n  (void) strncpy(buffer+offset,data,length);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":459168,"func":"int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,\n\t\t      struct nlattr *rate_tlv, struct tcf_exts *exts,\n\t\t      u32 flags, struct netlink_ext_ack *extack)\n{\n\treturn tcf_exts_validate_ex(net, tp, tb, rate_tlv, exts,\n\t\t\t\t    flags, 0, extack);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":252360,"func":"const char *mz_error(int err) {\n  static struct {\n    int m_err;\n    const char *m_pDesc;\n  } s_error_descs[] = {{MZ_OK, \"\"},\n                       {MZ_STREAM_END, \"stream end\"},\n                       {MZ_NEED_DICT, \"need dictionary\"},\n                       {MZ_ERRNO, \"file error\"},\n                       {MZ_STREAM_ERROR, \"stream error\"},\n                       {MZ_DATA_ERROR, \"data error\"},\n                       {MZ_MEM_ERROR, \"out of memory\"},\n                       {MZ_BUF_ERROR, \"buf error\"},\n                       {MZ_VERSION_ERROR, \"version error\"},\n                       {MZ_PARAM_ERROR, \"parameter error\"}};\n  mz_uint i;\n  for (i = 0; i < sizeof(s_error_descs) \/ sizeof(s_error_descs[0]); ++i)\n    if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc;\n  return NULL;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":312512,"func":"qf_find_first_entry_on_line(qfline_T *entry, int *errornr)\n{\n    while (!got_int\n\t    && entry->qf_prev != NULL\n\t    && entry->qf_fnum == entry->qf_prev->qf_fnum\n\t    && entry->qf_lnum == entry->qf_prev->qf_lnum)\n    {\n\tentry = entry->qf_prev;\n\t--*errornr;\n    }\n\n    return entry;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":247636,"func":"  const std::string& expectedSha256Digest() const { return expected_sha256_digest_; }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":487647,"func":"int set_current_groups(struct group_info *group_info)\n{\n\tint retval;\n\tstruct group_info *old_info;\n\n\tretval = security_task_setgroups(group_info);\n\tif (retval)\n\t\treturn retval;\n\n\tgroups_sort(group_info);\n\tget_group_info(group_info);\n\n\ttask_lock(current);\n\told_info = current->group_info;\n\tcurrent->group_info = group_info;\n\ttask_unlock(current);\n\n\tput_group_info(old_info);\n\n\treturn 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":512330,"func":"  bool pushable_cond_checker_for_derived(uchar *arg)\n  {\n    return excl_dep_on_table(*((table_map *)arg));\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":512269,"func":"bool Item_func_interval::fix_fields(THD *thd, Item **ref)\n{\n  if (Item_long_func::fix_fields(thd, ref))\n    return true;\n  for (uint i= 0 ; i < row->cols(); i++)\n  {\n    if (row->element_index(i)->check_cols(1))\n      return true;\n  }\n  return false;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":353109,"func":"bool SplashOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading)\n{\n  GfxColorSpaceMode shadingMode = shading->getColorSpace()->getMode();\n  bool bDirectColorTranslation = false; \/\/ triggers an optimization.\n  switch (colorMode) {\n    case splashModeRGB8:\n      bDirectColorTranslation = (shadingMode == csDeviceRGB);\n    break;\n#ifdef SPLASH_CMYK\n    case splashModeCMYK8:\n    case splashModeDeviceN8:\n      bDirectColorTranslation = (shadingMode == csDeviceCMYK);\n    break;\n#endif\n    default:\n    break;\n  }\n  \/\/ restore vector antialias because we support it here\n  if (shading->isParameterized()) {\n    SplashGouraudColor *splashShading = new SplashGouraudPattern(bDirectColorTranslation, state, shading);\n    bool vaa = getVectorAntialias();\n    bool retVal = false;\n    setVectorAntialias(true);\n    retVal = splash->gouraudTriangleShadedFill(splashShading);\n    setVectorAntialias(vaa);\n    delete splashShading;\n    return retVal;\n  }\n  return false;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":309944,"func":"drv_setcolor(TERMINAL_CONTROL_BLOCK * TCB,\n\t     int fore,\n\t     int color,\n\t     NCURSES_SP_OUTC outc)\n{\n    SCREEN *sp;\n\n    AssertTCB();\n    SetSP();\n\n    if (fore) {\n\tif (set_a_foreground) {\n\t    TPUTS_TRACE(\"set_a_foreground\");\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_1(set_a_foreground, color), 1, outc);\n\t} else {\n\t    TPUTS_TRACE(\"set_foreground\");\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_1(set_foreground,\n\t\t\t\t\t     toggled_colors(color)), 1, outc);\n\t}\n    } else {\n\tif (set_a_background) {\n\t    TPUTS_TRACE(\"set_a_background\");\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_1(set_a_background, color), 1, outc);\n\t} else {\n\t    TPUTS_TRACE(\"set_background\");\n\t    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\t    TIPARM_1(set_background,\n\t\t\t\t\t     toggled_colors(color)), 1, outc);\n\t}\n    }\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":336675,"func":"static inline void openssl_global_init(void)\n{\n    static GOnce openssl_once = G_ONCE_INIT;\n    g_once(&openssl_once, openssl_global_init_once, NULL);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":389694,"func":"tv_get_string_buf(typval_T *varp, char_u *buf)\n{\n    char_u\t*res = tv_get_string_buf_chk(varp, buf);\n\n    return res != NULL ? res : (char_u *)\"\";\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":398485,"func":"static void store_line_sample(RzBinSourceLineInfoBuilder *bob, const RzBinDwarfLineHeader *hdr, RzBinDwarfSMRegisters *regs,\n\tRZ_NULLABLE RzBinDwarfDebugInfo *info, RZ_NULLABLE RzBinDwarfLineFileCache fnc) {\n\tconst char *file = NULL;\n\tif (regs->file) {\n\t\tfile = get_full_file_path(info, hdr, fnc, regs->file - 1);\n\t}\n\trz_bin_source_line_info_builder_push_sample(bob, regs->address, (ut32)regs->line, (ut32)regs->column, file);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":314501,"func":"static int print_connection_info( pjmedia_sdp_conn *c, char *buf, int len)\n{\n    int printed;\n\n    printed = pj_ansi_snprintf(buf, len, \"c=%.*s %.*s %.*s\\r\\n\",\n\t\t\t       (int)c->net_type.slen,\n\t\t\t       c->net_type.ptr,\n\t\t\t       (int)c->addr_type.slen,\n\t\t\t       c->addr_type.ptr,\n\t\t\t       (int)c->addr.slen,\n\t\t\t       c->addr.ptr);\n    if (printed < 1 || printed >= len)\n\treturn -1;\n\n    return printed;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":226084,"func":"\nGF_Err fdsa_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_HintSample *ptr = (GF_HintSample *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\te = gf_isom_box_array_write(s, ptr->packetTable, bs);\n\tif (e) return e;\n\tif (ptr->extra_data) {\n\t\te = gf_isom_box_write((GF_Box *)ptr->extra_data, bs);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":238424,"func":"static bool check_btf_id_ok(const struct bpf_func_proto *fn)\n{\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(fn->arg_type); i++) {\n\t\tif (fn->arg_type[i] == ARG_PTR_TO_BTF_ID && !fn->arg_btf_id[i])\n\t\t\treturn false;\n\n\t\tif (fn->arg_type[i] != ARG_PTR_TO_BTF_ID && fn->arg_btf_id[i])\n\t\t\treturn false;\n\t}\n\n\treturn true;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":225884,"func":"\nvoid mvcg_box_del(GF_Box *s)\n{\n\tGF_MultiviewGroupBox *ptr = (GF_MultiviewGroupBox *) s;\n\tif (ptr->entries) gf_free(ptr->entries);\n\tgf_free(ptr);","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":226006,"func":"GF_Err elng_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_ExtendedLanguageBox *ptr = (GF_ExtendedLanguageBox *)s;\n\n\tif (ptr->size) {\n\t\tptr->extended_language = (char*)gf_malloc((u32) ptr->size);\n\t\tif (ptr->extended_language == NULL) return GF_OUT_OF_MEM;\n\t\tgf_bs_read_data(bs, ptr->extended_language, (u32) ptr->size);\n\t\t\/*safety check in case the string is not null-terminated*\/\n\t\tif (ptr->extended_language[ptr->size-1]) {\n\t\t\tchar *str = (char*)gf_malloc((u32) ptr->size + 1);\n\t\t\tif (!str) return GF_OUT_OF_MEM;\n\t\t\tmemcpy(str, ptr->extended_language, (u32) ptr->size);\n\t\t\tstr[ptr->size] = 0;\n\t\t\tgf_free(ptr->extended_language);\n\t\t\tptr->extended_language = str;\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":401593,"func":"void add_hwgenerator_randomness(const char *buffer, size_t count,\n\t\t\t\tsize_t entropy)\n{\n\tstruct entropy_store *poolp = &input_pool;\n\n\tif (unlikely(crng_init == 0)) {\n\t\tcrng_fast_load(buffer, count);\n\t\treturn;\n\t}\n\n\t\/* Suspend writing if we're above the trickle threshold.\n\t * We'll be woken up again once below random_write_wakeup_thresh,\n\t * or when the calling thread is about to terminate.\n\t *\/\n\twait_event_interruptible(random_write_wait, kthread_should_stop() ||\n\t\t\tENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);\n\tmix_pool_bytes(poolp, buffer, count);\n\tcredit_entropy_bits(poolp, entropy);\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":234129,"func":"init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine)\n{\n  dwarf_regnames_lookup_func = NULL;\n\n  switch (e_machine)\n    {\n    case EM_386:\n      init_dwarf_regnames_i386 ();\n      break;\n\n    case EM_IAMCU:\n      init_dwarf_regnames_iamcu ();\n      break;\n\n    case EM_X86_64:\n    case EM_L1OM:\n    case EM_K1OM:\n      init_dwarf_regnames_x86_64 ();\n      break;\n\n    case EM_AARCH64:\n      init_dwarf_regnames_aarch64 ();\n      break;\n\n    case EM_S390:\n      init_dwarf_regnames_s390 ();\n      break;\n\n    case EM_RISCV:\n      init_dwarf_regnames_riscv ();\n      break;\n\n    default:\n      break;\n    }\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":440898,"func":"LogVWrite(int verb, const char *f, va_list args)\n{\n    return LogVMessageVerb(X_NONE, verb, f, args);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":225716,"func":"\nGF_Err rvcc_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_RVCConfigurationBox *ptr = (GF_RVCConfigurationBox*)s;\n\tISOM_DECREASE_SIZE(ptr, 2);\n\tptr->predefined_rvc_config = gf_bs_read_u16(bs);\n\tif (!ptr->predefined_rvc_config) {\n\t\tISOM_DECREASE_SIZE(ptr, 2);\n\t\tptr->rvc_meta_idx = gf_bs_read_u16(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":224719,"func":"GF_Err iref_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_full_box_write(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":226072,"func":"GF_Err stbl_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":265049,"func":"match_named_colour(const char **teststrp)\n{\n    const char *teststr = *teststrp, *end, **cptr;\n    int len;\n\n    for (end = teststr; ialpha(*end); end++)\n\t;\n    len = end - teststr;\n    *teststrp = end;\n\n    for (cptr = ansi_colours; *cptr; cptr++) {\n\tif (!strncmp(teststr, *cptr, len))\n\t    return cptr - ansi_colours;\n    }\n\n    return -1;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":359372,"func":"DEFUN (exit_address_family,\n       exit_address_family_cmd,\n       \"exit-address-family\",\n       \"Exit from Address Family configuration mode\\n\")\n{\n  if (vty->node == BGP_IPV4_NODE\n      || vty->node == BGP_IPV4M_NODE\n      || vty->node == BGP_VPNV4_NODE\n      || vty->node == BGP_IPV6_NODE\n      || vty->node == BGP_IPV6M_NODE)\n    vty->node = BGP_NODE;\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":226017,"func":"\nvoid chnl_box_del(GF_Box *s)\n{\n\tgf_free(s);","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":226409,"func":"GF_Box *dimm_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DIMMBox, GF_ISOM_BOX_TYPE_DIMM);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":401543,"func":"randomize_page(unsigned long start, unsigned long range)\n{\n\tif (!PAGE_ALIGNED(start)) {\n\t\trange -= PAGE_ALIGN(start) - start;\n\t\tstart = PAGE_ALIGN(start);\n\t}\n\n\tif (start > ULONG_MAX - range)\n\t\trange = ULONG_MAX - start;\n\n\trange >>= PAGE_SHIFT;\n\n\tif (range == 0)\n\t\treturn start;\n\n\treturn start + (get_random_long() % range << PAGE_SHIFT);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":359655,"func":"DEFUN (no_bgp_bestpath_compare_router_id,\n       no_bgp_bestpath_compare_router_id_cmd,\n       \"no bgp bestpath compare-routerid\",\n       NO_STR\n       \"BGP specific commands\\n\"\n       \"Change the default bestpath selection\\n\"\n       \"Compare router-id for identical EBGP paths\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":386555,"func":"void DL_Dxf::writeRay(DL_WriterA& dw,\n                        const DL_RayData& data,\n                        const DL_Attributes& attrib) {\n    dw.entity(\"RAY\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbLine\");\n    }\n    dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz);\n    dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":521459,"func":"ZipFile::ZipFile (InputSource* source)  : inputSource (source)\r\n{\r\n    init();\r\n}\r","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":247624,"func":"TEST_P(SslSocketTest, ClientSessionResumptionDefault) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n)EOF\";\n\n  testClientSessionResumption(server_ctx_yaml, client_ctx_yaml, true, GetParam());\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":512931,"func":"Item *in_temporal::create_item(THD *thd)\n{ \n  return new (thd->mem_root) Item_datetime(thd);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":225939,"func":"\nstatic u32 ctrn_field_size(u32 field_idx)\n{\n\tif (field_idx==3) return 4;\n\treturn field_idx;","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":366208,"func":"static void lock_mnt_tree(struct mount *mnt)\n{\n\tstruct mount *p;\n\n\tfor (p = mnt; p; p = next_mnt(p, mnt)) {\n\t\tint flags = p->mnt.mnt_flags;\n\t\t\/* Don't allow unprivileged users to change mount flags *\/\n\t\tflags |= MNT_LOCK_ATIME;\n\n\t\tif (flags & MNT_READONLY)\n\t\t\tflags |= MNT_LOCK_READONLY;\n\n\t\tif (flags & MNT_NODEV)\n\t\t\tflags |= MNT_LOCK_NODEV;\n\n\t\tif (flags & MNT_NOSUID)\n\t\t\tflags |= MNT_LOCK_NOSUID;\n\n\t\tif (flags & MNT_NOEXEC)\n\t\t\tflags |= MNT_LOCK_NOEXEC;\n\t\t\/* Don't allow unprivileged users to reveal what is under a mount *\/\n\t\tif (list_empty(&p->mnt_expire))\n\t\t\tflags |= MNT_LOCKED;\n\t\tp->mnt.mnt_flags = flags;\n\t}\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":343161,"func":"static void __exit esp6_fini(void)\n{\n\tif (xfrm6_protocol_deregister(&esp6_protocol, IPPROTO_ESP) < 0)\n\t\tpr_info(\"%s: can't remove protocol\\n\", __func__);\n\txfrm_unregister_type(&esp6_type, AF_INET6);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":261902,"func":"njs_string_to_c_string(njs_vm_t *vm, njs_value_t *value)\n{\n    u_char  *p, *data, *start;\n    size_t  size;\n\n    if (value->short_string.size != NJS_STRING_LONG) {\n        start = value->short_string.start;\n        size = value->short_string.size;\n\n        if (size < NJS_STRING_SHORT) {\n            start[size] = '\\0';\n            return (const char *) start;\n        }\n\n    } else {\n        start = value->long_string.data->start;\n        size = value->long_string.size;\n    }\n\n    data = njs_mp_alloc(vm->mem_pool, size + 1);\n    if (njs_slow_path(data == NULL)) {\n        njs_memory_error(vm);\n        return NULL;\n    }\n\n    p = njs_cpymem(data, start, size);\n    *p++ = '\\0';\n\n    return (const char *) data;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":434091,"func":"alist_check_arg_idx(void)\n{\n    win_T\t*win;\n    tabpage_T\t*tp;\n\n    FOR_ALL_TAB_WINDOWS(tp, win)\n\tif (win->w_alist == curwin->w_alist)\n\t    check_arg_idx(win);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":391645,"func":"static void schedule_async_open(struct timeval request_time,\n\t\t\t\tstruct smb_request *req)\n{\n\tstruct deferred_open_record state;\n\tstruct timeval timeout;\n\n\ttimeout = timeval_set(20, 0);\n\n\tZERO_STRUCT(state);\n\tstate.delayed_for_oplocks = false;\n\tstate.async_open = true;\n\n\tif (!request_timed_out(request_time, timeout)) {\n\t\tdefer_open(NULL, request_time, timeout, req, &state);\n\t}\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":336538,"func":"static bool reds_send_link_error(RedLinkInfo *link, uint32_t error)\n{\n    struct {\n        SpiceLinkHeader header;\n        SpiceLinkReply reply;\n    } msg;\n    SPICE_VERIFY(sizeof(msg) == sizeof(SpiceLinkHeader) + sizeof(SpiceLinkReply));\n\n    msg.header.magic = SPICE_MAGIC;\n    msg.header.size = GUINT32_TO_LE(sizeof(msg.reply));\n    msg.header.major_version = GUINT32_TO_LE(SPICE_VERSION_MAJOR);\n    msg.header.minor_version = GUINT32_TO_LE(SPICE_VERSION_MINOR);\n    memset(&msg.reply, 0, sizeof(msg.reply));\n    msg.reply.error = GUINT32_TO_LE(error);\n    return red_stream_write_all(link->stream, &msg, sizeof(msg));\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":440881,"func":"FreeAuditTimer(void)\n{\n    if (auditTimer != NULL) {\n        \/* Force output of pending messages *\/\n        TimerForce(auditTimer);\n        TimerFree(auditTimer);\n        auditTimer = NULL;\n    }\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":310172,"func":"cleanup(void)\n{\n    int rc;\n\n#if NO_LEAKS\n    free_namelist(namelst);\n    _nc_leaks_dump_entry();\n#endif\n    if (tmp_fp != 0)\n\tfclose(tmp_fp);\n    if (to_remove != 0) {\n#if HAVE_REMOVE\n\trc = remove(to_remove);\n#else\n\trc = unlink(to_remove);\n#endif\n\tif (rc != 0)\n\t    perror(to_remove);\n    }\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":405712,"func":"static void xemaclite_disable_interrupts(struct net_local *drvdata)\n{\n\tu32 reg_data;\n\n\t\/* Disable the Global Interrupt Enable *\/\n\txemaclite_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET);\n\n\t\/* Disable the Tx interrupts for the first buffer *\/\n\treg_data = xemaclite_readl(drvdata->base_addr + XEL_TSR_OFFSET);\n\txemaclite_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK),\n\t\t\t drvdata->base_addr + XEL_TSR_OFFSET);\n\n\t\/* Disable the Rx interrupts for the first buffer *\/\n\treg_data = xemaclite_readl(drvdata->base_addr + XEL_RSR_OFFSET);\n\txemaclite_writel(reg_data & (~XEL_RSR_RECV_IE_MASK),\n\t\t\t drvdata->base_addr + XEL_RSR_OFFSET);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":283753,"func":"static void zynq_slcr_register_types(void)\n{\n    type_register_static(&zynq_slcr_info);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":313760,"func":"nv_ver_scrollbar(cmdarg_T *cap)\n{\n    if (cap->oap->op_type != OP_NOP)\n\tclearopbeep(cap->oap);\n\n    \/\/ Even if an operator was pending, we still want to scroll\n    gui_do_scroll();\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":253585,"func":"smb2_get_next_mid(struct TCP_Server_Info *server)\n{\n\t__u64 mid;\n\t\/* for SMB2 we need the current value *\/\n\tspin_lock(&GlobalMid_Lock);\n\tmid = server->CurrentMid++;\n\tspin_unlock(&GlobalMid_Lock);\n\treturn mid;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":256153,"func":"void wrapper_libxsmm_spmdm_compute_generic_thread(\n    empty_type_wrapper<bfloat16>, const libxsmm_spmdm_handle* handle,\n    char transA, char transB, const bfloat16* alpha,\n    libxsmm_CSR_sparseslice* A_sparse, const bfloat16* B, char transC,\n    const bfloat16* beta, float* C, int block_id, int tid, int nthreads) {\n  return libxsmm_spmdm_compute_bfloat16_thread(\n      handle, transA, transB, reinterpret_cast<const libxsmm_bfloat16*>(alpha),\n      A_sparse, reinterpret_cast<const libxsmm_bfloat16*>(B), transC,\n      reinterpret_cast<const libxsmm_bfloat16*>(beta), C, block_id, tid,\n      nthreads);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":225638,"func":"GF_Err rtpo_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":453006,"func":"static int nft_fwd_validate(const struct nft_ctx *ctx,\n\t\t\t    const struct nft_expr *expr,\n\t\t\t    const struct nft_data **data)\n{\n\treturn nft_chain_validate_hooks(ctx->chain, (1 << NF_NETDEV_INGRESS) |\n\t\t\t\t\t\t    (1 << NF_NETDEV_EGRESS));\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":261392,"func":"static int decode_sao_type_idx(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# sao_type_idx_luma\/chroma\\n\");\n\n  int bit0 = decode_CABAC_bit(&tctx->cabac_decoder,\n                              &tctx->ctx_model[CONTEXT_MODEL_SAO_TYPE_IDX]);\n\n  if (bit0==0) {\n    logtrace(LogSymbols,\"$1 sao_type_idx=%d\\n\",0);\n    return 0;\n  }\n  else {\n    int bit1 = decode_CABAC_bypass(&tctx->cabac_decoder);\n    if (bit1==0) {\n      logtrace(LogSymbols,\"$1 sao_type_idx=%d\\n\",1);\n      return 1;\n    }\n    else {\n      logtrace(LogSymbols,\"$1 sao_type_idx=%d\\n\",2);\n      return 2;\n    }\n  }\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":427705,"func":"cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)\n{\n\tsize_t siz = CAST(size_t, off + len);\n\n\tif (CAST(off_t, off + len) != CAST(off_t, siz))\n\t\tgoto out;\n\n\tif (info->i_buf != NULL && info->i_len >= siz) {\n\t\t(void)memcpy(buf, &info->i_buf[off], len);\n\t\treturn CAST(ssize_t, len);\n\t}\n\n\tif (info->i_fd == -1)\n\t\tgoto out;\n\n\tif (pread(info->i_fd, buf, len, off) != CAST(ssize_t, len))\n\t\treturn -1;\n\n\treturn CAST(ssize_t, len);\nout:\n\terrno = EINVAL;\n\treturn -1;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":281636,"func":"void CLASS nokia_load_raw()\n{\n  uchar  *data,  *dp;\n  int rev, dwide, row, col, c;\n\n  rev = 3 * (order == 0x4949);\n  dwide = (raw_width * 5 + 1) \/ 4;\n  data = (uchar *) malloc (dwide*2);\n  merror (data, \"nokia_load_raw()\");\n#ifdef LIBRAW_LIBRARY_BUILD\n  try {\n#endif\n  for (row=0; row < raw_height; row++) {\n#ifdef LIBRAW_LIBRARY_BUILD\n    checkCancel();\n#endif\n    if (fread (data+dwide, 1, dwide, ifp) < dwide) derror();\n    FORC(dwide) data[c] = data[dwide+(c ^ rev)];\n    for (dp=data, col=0; col < raw_width; dp+=5, col+=4)\n      FORC4 RAW(row,col+c) = (dp[c] << 2) | (dp[4] >> (c << 1) & 3);\n  }\n#ifdef LIBRAW_LIBRARY_BUILD\n  } catch (...){\n    free (data);\n    throw;\n  }\n#endif\n  free (data);\n  maximum = 0x3ff;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":314519,"func":"static void parse_bandwidth_info(pj_scanner *scanner, pjmedia_sdp_bandw *bandw,\n\t\t\t\t volatile parse_context *ctx)\n{\n    pj_str_t str;\n\n    ctx->last_error = PJMEDIA_SDP_EINBANDW;\n\n    \/* b= *\/\n    pj_scan_advance_n(scanner, 2, SKIP_WS);\n\n    \/* modifier *\/\n    pj_scan_get_until_ch(scanner, ':', &bandw->modifier);\n    pj_scan_get_char(scanner);\n\n    \/* value *\/\n    pj_scan_get_until_chr(scanner, \" \\t\\r\\n\", &str);\n    bandw->value = pj_strtoul(&str);\n\n    \/* We've got what we're looking for, skip anything until newline *\/\n    pj_scan_skip_line(scanner);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":248241,"func":"DLLIMPORT cfg_t *cfg_getnsec(cfg_t *cfg, const char *name, unsigned int index)\n{\n\treturn cfg_opt_getnsec(cfg_getopt(cfg, name), index);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":225813,"func":"GF_Err stss_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_SyncSampleBox *ptr = (GF_SyncSampleBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->nb_entries);\n\tfor (i = 0; i < ptr->nb_entries; i++) {\n\t\tgf_bs_write_u32(bs, ptr->sampleNumbers[i]);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":359277,"func":"DEFUN (no_neighbor_peer_group,\n       no_neighbor_peer_group_cmd,\n       \"no neighbor WORD peer-group\",\n       NO_STR\n       NEIGHBOR_STR\n       \"Neighbor tag\\n\"\n       \"Configure peer-group\\n\")\n{\n  struct peer_group *group;\n\n  group = peer_group_lookup (vty->index, argv[0]);\n  if (group)\n    peer_group_delete (group);\n  else\n    {\n      vty_out (vty, \"%% Create the peer-group first%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":488418,"func":"static __init void vdso_setup_trampolines(struct lib32_elfinfo *v32,\n\t\t\t\t\t  struct lib64_elfinfo *v64)\n{\n\t\/*\n\t * Find signal trampolines\n\t *\/\n\n#ifdef CONFIG_PPC64\n\tvdso64_rt_sigtramp = find_function64(v64, \"__kernel_sigtramp_rt64\");\n#endif\n\tvdso32_sigtramp\t   = find_function32(v32, \"__kernel_sigtramp32\");\n\tvdso32_rt_sigtramp = find_function32(v32, \"__kernel_sigtramp_rt32\");\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":273894,"func":"static void handle_CLNT(ctrl_t *ctrl, char *arg)\n{\n\tsend_msg(ctrl->sd, \"200 CLNT\\r\\n\");\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":261209,"func":"MqttProp* MqttClient_PropsAdd(MqttProp **head)\n{\n    return MqttProps_Add(head);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":248326,"func":"DLLIMPORT unsigned int cfg_opt_size(cfg_opt_t *opt)\n{\n\tif (opt)\n\t\treturn opt->nvalues;\n\treturn 0;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":473993,"func":"st_init_strcasetable_with_size(st_index_t size)\n{\n    return st_init_table_with_size(&type_strcasehash, size);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":244038,"func":"GF_Err trik_box_size(GF_Box *s)\n{\n\tGF_TrickPlayBox *ptr = (GF_TrickPlayBox *) s;\n\tptr->size += 8 * ptr->entry_count;\n\treturn GF_OK;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":261947,"func":"njs_encode_hex(njs_str_t *dst, const njs_str_t *src)\n{\n    u_char        *p, c;\n    size_t        i, len;\n    const u_char  *start;\n\n    static const u_char  hex[16] = \"0123456789abcdef\";\n\n    len = src->length;\n    start = src->start;\n\n    p = dst->start;\n\n    for (i = 0; i < len; i++) {\n        c = start[i];\n        *p++ = hex[c >> 4];\n        *p++ = hex[c & 0x0f];\n    }\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":346455,"func":"source_runtime(char_u *name, int flags)\n{\n    return source_in_path(p_rtp, name, flags, NULL);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":90151,"func":"  WifiNetwork* GetWifiNetworkByName(const std::string& name) {\n    for (size_t i = 0; i < wifi_networks_.size(); ++i) {\n      if (wifi_networks_[i]->name().compare(name) == 0) {\n        return wifi_networks_[i];\n      }\n    }\n    return NULL;\n  }\n","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":221175,"func":"GF_HEVCConfig *gf_odf_hevc_cfg_read(u8 *dsi, u32 dsi_size, Bool is_lhvc)\n{\n\tGF_BitStream *bs = gf_bs_new(dsi, dsi_size, GF_BITSTREAM_READ);\n\tGF_HEVCConfig *cfg = gf_odf_hevc_cfg_read_bs(bs, is_lhvc);\n\tgf_bs_del(bs);\n\treturn cfg;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":252374,"func":"void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip,\n                                         const char *pFilename, size_t *pSize,\n                                         mz_uint flags) {\n  int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);\n  if (file_index < 0) {\n    if (pSize) *pSize = 0;\n    return MZ_FALSE;\n  }\n  return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":310006,"func":"set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc)\n{\n#ifdef USE_TERM_DRIVER\n    CallDriver_3(SP_PARM, td_color, FALSE, bg, outc);\n#else\n    if (set_a_background) {\n\tTPUTS_TRACE(\"set_a_background\");\n\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\tTIPARM_1(set_a_background, bg),\n\t\t\t\t1, outc);\n    } else {\n\tTPUTS_TRACE(\"set_background\");\n\tNCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t\tTIPARM_1(set_background, toggled_colors(bg)),\n\t\t\t\t1, outc);\n    }\n#endif\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":440879,"func":"LogMessageVerb(MessageType type, int verb, const char *format, ...)\n{\n    va_list ap;\n\n    va_start(ap, format);\n    LogVMessageVerb(type, verb, format, ap);\n    va_end(ap);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":224237,"func":"R_API ut32 r_io_bank_first(RIO *io) {\n\tut32 bankid = -1;\n\tr_id_storage_get_lowest (io->banks, &bankid);\n\treturn bankid;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":366174,"func":"static struct ns_common *mntns_get(struct task_struct *task)\n{\n\tstruct ns_common *ns = NULL;\n\tstruct nsproxy *nsproxy;\n\n\ttask_lock(task);\n\tnsproxy = task->nsproxy;\n\tif (nsproxy) {\n\t\tns = &nsproxy->mnt_ns->ns;\n\t\tget_mnt_ns(to_mnt_ns(ns));\n\t}\n\ttask_unlock(task);\n\n\treturn ns;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":310171,"func":"is_csi(const char *s)\n{\n    int result = 0;\n    if (s != 0) {\n\tif (UChar(s[0]) == CSI)\n\t    result = 1;\n\telse if (s[0] == ESC && s[1] == L_BRACK)\n\t    result = 2;\n    }\n    return result;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":244133,"func":"GF_Err ihdr_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tGF_J2KImageHeaderBox *ptr = (GF_J2KImageHeaderBox *) s;\n\n\tISOM_DECREASE_SIZE(s, 14)\n\n\tptr->height = gf_bs_read_u32(bs);\n\tptr->width = gf_bs_read_u32(bs);\n\tptr->nb_comp = gf_bs_read_u16(bs);\n\tptr->bpc = gf_bs_read_u8(bs);\n\tptr->Comp = gf_bs_read_u8(bs);\n\tptr->UnkC = gf_bs_read_u8(bs);\n\tptr->IPR = gf_bs_read_u8(bs);\n\n\treturn GF_OK;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":389702,"func":"alloc_tv(void)\n{\n    return ALLOC_CLEAR_ONE(typval_T);\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":244076,"func":"GF_Err fiin_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tFDItemInformationBox *ptr = (FDItemInformationBox *)s;\n\tswitch(a->type) {\n\tcase GF_ISOM_BOX_TYPE_PAEN:\n\t\tBOX_FIELD_LIST_ASSIGN(partition_entries)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_SEGR:\n\t\tBOX_FIELD_ASSIGN(session_info, FDSessionGroupBox)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_GITN:\n\t\tBOX_FIELD_ASSIGN(group_id_to_name, GroupIdToNameBox)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":332373,"func":"free_operatorfunc_option(void)\n{\n# ifdef FEAT_EVAL\n    free_callback(&opfunc_cb);\n# endif\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":244012,"func":"GF_Err rvcc_box_size(GF_Box *s)\n{\n\tGF_RVCConfigurationBox *ptr = (GF_RVCConfigurationBox *)s;\n\tptr->size += 2;\n\tif (! ptr->predefined_rvc_config) ptr->size += 2;\n\treturn GF_OK;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":512883,"func":"  longlong val_datetime_packed(THD *thd)\n  {\n    Datetime::Options_cmp opt(thd);\n    return has_value() ? Datetime(thd, this, opt).to_packed() : 0;\n  }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":385853,"func":"SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user,\n\t\tgid_t, group, int, flag)\n{\n\tstruct path path;\n\tint error = -EINVAL;\n\tint lookup_flags;\n\n\tif ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)\n\t\tgoto out;\n\n\tlookup_flags = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;\n\tif (flag & AT_EMPTY_PATH)\n\t\tlookup_flags |= LOOKUP_EMPTY;\nretry:\n\terror = user_path_at(dfd, filename, lookup_flags, &path);\n\tif (error)\n\t\tgoto out;\n\terror = mnt_want_write(path.mnt);\n\tif (error)\n\t\tgoto out_release;\n\terror = chown_common(&path, user, group);\n\tmnt_drop_write(path.mnt);\nout_release:\n\tpath_put(&path);\n\tif (retry_estale(error, lookup_flags)) {\n\t\tlookup_flags |= LOOKUP_REVAL;\n\t\tgoto retry;\n\t}\nout:\n\treturn error;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":241364,"func":"  TensorShapes GetOutputMatrixShapes(\n      const TensorShapes& input_matrix_shapes) const final {\n    return TensorShapes({TensorShape({input_matrix_shapes[0].dim_size(1),\n                                      input_matrix_shapes[1].dim_size(1)})});\n  }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":312465,"func":"qf_goto_tabwin_with_file(int fnum)\n{\n    tabpage_T\t*tp;\n    win_T\t*wp;\n\n    FOR_ALL_TAB_WINDOWS(tp, wp)\n\tif (wp->w_buffer->b_fnum == fnum)\n\t{\n\t    goto_tabpage_win(tp, wp);\n\t    return TRUE;\n\t}\n\n    return FALSE;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":337817,"func":"struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,\n\t\t\t\t\t  const struct sctp_chunk *chunk)\n{\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_ACK, 0, 0,\n\t\t\t\t   GFP_ATOMIC);\n\n\t\/* RFC 2960 6.4 Multi-homed SCTP Endpoints\n\t *\n\t * An endpoint SHOULD transmit reply chunks (e.g., SACK,\n\t * HEARTBEAT ACK, * etc.) to the same destination transport\n\t * address from which it * received the DATA or control chunk\n\t * to which it is replying.\n\t *\n\t * [ACK back to where the SHUTDOWN came from.]\n\t *\/\n\tif (retval && chunk)\n\t\tretval->transport = chunk->transport;\n\n\treturn retval;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":463182,"func":"static void annotate_state_unset_scope(annotate_state_t *state)\n{\n    init_internal();\n\n    if (state->ourmailbox)\n        mailbox_close(&state->ourmailbox);\n    state->mailbox = NULL;\n\n    if (state->ourmbentry)\n        mboxlist_entry_free(&state->ourmbentry);\n    state->mbentry = NULL;\n\n    state->uid = 0;\n    state->which = ANNOTATION_SCOPE_UNKNOWN;\n    annotate_putdb(&state->d);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":261191,"func":"const char* MqttClient_GetProtocolVersionString(MqttClient *client)\n{\n    const char* str = NULL;\n    int ver = MqttClient_GetProtocolVersion(client);\n    switch (ver) {\n        case MQTT_CONNECT_PROTOCOL_LEVEL_4:\n            return \"v3.1.1\";\n    #ifdef WOLFMQTT_V5\n        case MQTT_CONNECT_PROTOCOL_LEVEL_5:\n            return \"v5\";\n    #endif\n        default:\n            break;\n    }\n    return str;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":220241,"func":"Status Graph::AddWhileContext(StringPiece frame_name,\n                              std::vector<Node*> enter_nodes,\n                              std::vector<Node*> exit_nodes,\n                              OutputTensor cond_output,\n                              std::vector<OutputTensor> body_inputs,\n                              std::vector<OutputTensor> body_outputs,\n                              WhileContext** result) {\n  auto pair = while_ctxs_.insert(std::pair<std::string, WhileContext>(\n      std::string(frame_name),\n      WhileContext(frame_name, std::move(enter_nodes), std::move(exit_nodes),\n                   cond_output, std::move(body_inputs),\n                   std::move(body_outputs))));\n  if (!pair.second) {\n    *result = nullptr;\n    return errors::InvalidArgument(\"WhileContext with frame name '\", frame_name,\n                                   \"' already exists\");\n  }\n  *result = &pair.first->second;\n  return Status::OK();\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":462250,"func":"static void* clone_sockaddr_attr(pj_pool_t *pool, const void *src)\n{\n    pj_stun_sockaddr_attr *dst = PJ_POOL_ALLOC_T(pool, pj_stun_sockaddr_attr);\n    pj_memcpy(dst, src, sizeof(pj_stun_sockaddr_attr));\n    return (void*)dst;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":220847,"func":"inline void GetActivationMinMax(FusedActivationFunctionType ac,\n                                float* output_activation_min,\n                                float* output_activation_max) {\n  switch (ac) {\n    case FusedActivationFunctionType::kNone:\n      *output_activation_min = std::numeric_limits<float>::lowest();\n      *output_activation_max = std::numeric_limits<float>::max();\n      break;\n    case FusedActivationFunctionType::kRelu:\n      *output_activation_min = 0.f;\n      *output_activation_max = std::numeric_limits<float>::max();\n      break;\n    case FusedActivationFunctionType::kRelu1:\n      *output_activation_min = -1.f;\n      *output_activation_max = 1.f;\n      break;\n    case FusedActivationFunctionType::kRelu6:\n      *output_activation_min = 0.f;\n      *output_activation_max = 6.f;\n      break;\n  }\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":474460,"func":"HandleToObject(\n\t       TPMI_DH_OBJECT   handle         \/\/ IN: handle of the object\n\t       )\n{\n    UINT32              index;\n    \/\/ Return NULL if the handle references a permanent handle because there is no\n    \/\/ associated OBJECT.\n    if(HandleGetType(handle) == TPM_HT_PERMANENT)\n\treturn NULL;\n    \/\/ In this implementation, the handle is determined by the slot occupied by the\n    \/\/ object.\n    index = handle - TRANSIENT_FIRST;\n    pAssert(index < MAX_LOADED_OBJECTS);\n    pAssert(s_objects[index].attributes.occupied);\n    return &s_objects[index];\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":262034,"func":"Proto_ConcatXMLStrings(gchar *str1,\n                       gchar *str2)\n{\n   gchar *newStr;\n\n   if (NULL == str2) {\n      return str1;\n   }\n   newStr = g_strdup_printf(\"%s%s\", str1, str2);\n   g_free(str1);\n   g_free(str2);\n\n   return newStr;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":221636,"func":"std::unique_ptr<FunctionPass> CreateSymbolicShapeOptimizationPass(\n    bool constraints_only) {\n  return std::make_unique<SymbolicShapeOptimizationPass>(constraints_only);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":139223,"func":"gfx::Rect OverlayWindowViews::GetPlayPauseControlsBounds() {\n  return play_pause_controls_view_->GetMirroredBounds();\n}\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":90810,"func":"  UpdateAccessTimeTask(\n      QuotaManager* manager,\n      const GURL& origin,\n      StorageType type,\n      base::Time accessed_time)\n      : DatabaseTaskBase(manager),\n        origin_(origin),\n        type_(type),\n        accessed_time_(accessed_time) {}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":487649,"func":"static int set_one_prio(struct task_struct *p, int niceval, int error)\n{\n\tint no_nice;\n\n\tif (p->uid != current->euid &&\n\t\tp->euid != current->euid && !capable(CAP_SYS_NICE)) {\n\t\terror = -EPERM;\n\t\tgoto out;\n\t}\n\tif (niceval < task_nice(p) && !can_nice(p, niceval)) {\n\t\terror = -EACCES;\n\t\tgoto out;\n\t}\n\tno_nice = security_task_setnice(p, niceval);\n\tif (no_nice) {\n\t\terror = no_nice;\n\t\tgoto out;\n\t}\n\tif (error == -ESRCH)\n\t\terror = 0;\n\tset_user_nice(p, niceval);\nout:\n\treturn error;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":508856,"func":"void unsafe_mixed_statement(LEX::enum_stmt_accessed_table a,\n                            LEX::enum_stmt_accessed_table b, uint condition)\n{\n  int type= 0;\n  int index= (1U << a) | (1U << b);\n  \n  \n  for (type= 0; type < 256; type++)\n  {\n    if ((type & index) == index)\n    {\n      binlog_unsafe_map[type] |= condition;\n    }\n  }\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":225112,"func":"bool OpDefEqual(const OpDef& o1, const OpDef& o2) {\n  \/\/ attr order doesn't matter.\n  \/\/ Compare it separately here instead of serializing below.\n  if (!RepeatedAttrDefEqual(o1.attr(), o2.attr())) return false;\n\n  \/\/ `control_output` order doesn't matter.\n  std::set<string> control_output1(o1.control_output().begin(),\n                                   o1.control_output().end());\n  std::set<string> control_output2(o2.control_output().begin(),\n                                   o2.control_output().end());\n  if (control_output1 != control_output2) return false;\n\n  \/\/ Clear `attr` and `control_output` fields, serialize, and compare serialized\n  \/\/ strings.\n  OpDef o1_copy = o1;\n  OpDef o2_copy = o2;\n  o1_copy.clear_attr();\n  o1_copy.clear_control_output();\n  o2_copy.clear_attr();\n  o2_copy.clear_control_output();\n\n  return AreSerializedProtosEqual(o1_copy, o2_copy);\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":317295,"func":"static void selinux_sock_graft(struct sock *sk, struct socket *parent)\n{\n\tstruct inode_security_struct *isec =\n\t\tinode_security_novalidate(SOCK_INODE(parent));\n\tstruct sk_security_struct *sksec = sk->sk_security;\n\n\tif (sk->sk_family == PF_INET || sk->sk_family == PF_INET6 ||\n\t    sk->sk_family == PF_UNIX)\n\t\tisec->sid = sksec->sid;\n\tsksec->sclass = isec->sclass;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":223422,"func":"static SLJIT_INLINE unsigned int char_othercase(compiler_common *common, unsigned int c)\n{\n\/* Returns with the othercase. *\/\n#ifdef SUPPORT_UNICODE\nif ((common->utf || common->ucp) && c > 127)\n  return UCD_OTHERCASE(c);\n#endif\nreturn TABLE_GET(c, common->fcc, c);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":359301,"func":"DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,\n       clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,\n       \"clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Soft reconfig inbound update\\n\"\n       \"Push out prefix-list ORF and do inbound soft reconfig\\n\")\n{\n  if (strncmp (argv[1], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,\n                          BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);\n\n  return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,\n                        BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":384286,"func":"gs_heap_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num,\n                      client_name_t cname)\n{\n    if (gs_heap_object_type(mem, data) != &st_bytes)\n        lprintf2(\"%s: resizing non-string 0x%lx!\\n\",\n                 client_name_string(cname), (ulong) data);\n    return gs_heap_resize_object(mem, data, new_num, cname);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":238314,"func":"static void dummy_free(struct digest *d) {}","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":240271,"func":"shift_delete_registers()\n{\n    int\t\tn;\n\n    y_current = &y_regs[9];\n    free_yank_all();\t\t\t\/\/ free register nine\n    for (n = 9; n > 1; --n)\n\ty_regs[n] = y_regs[n - 1];\n    y_current = &y_regs[1];\n    if (!y_append)\n\ty_previous = y_current;\n    y_regs[1].y_array = NULL;\t\t\/\/ set register one to empty\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":508895,"func":"LEX::LEX()\n  : explain(NULL),\n    result(0), arena_for_set_stmt(0), mem_root_for_set_stmt(0),\n    option_type(OPT_DEFAULT), context_analysis_only(0), sphead(0),\n    is_lex_started(0), limit_rows_examined_cnt(ULONGLONG_MAX)\n{\n\n  init_dynamic_array2(&plugins, sizeof(plugin_ref), plugins_static_buffer,\n                      INITIAL_LEX_PLUGIN_LIST_SIZE,\n                      INITIAL_LEX_PLUGIN_LIST_SIZE, 0);\n  reset_query_tables_list(TRUE);\n  mi.init();\n  init_dynamic_array2(&delete_gtid_domain, sizeof(uint32),\n                      gtid_domain_static_buffer,\n                      initial_gtid_domain_buffer_size,\n                      initial_gtid_domain_buffer_size, 0);\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":312507,"func":"qf_view_result(int split)\n{\n    qf_info_T   *qi = &ql_info;\n\n    if (IS_LL_WINDOW(curwin))\n\tqi = GET_LOC_LIST(curwin);\n\n    if (qf_list_empty(qf_get_curlist(qi)))\n    {\n\temsg(_(e_no_errors));\n\treturn;\n    }\n\n    if (split)\n    {\n\t\/\/ Open the selected entry in a new window\n\tqf_jump_newwin(qi, 0, (long)curwin->w_cursor.lnum, FALSE, TRUE);\n\tdo_cmdline_cmd((char_u *) \"clearjumps\");\n\treturn;\n    }\n\n    do_cmdline_cmd((char_u *)(IS_LL_WINDOW(curwin) ? \".ll\" : \".cc\"));\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":294597,"func":"dt_lite_strftime(int argc, VALUE *argv, VALUE self)\n{\n    return date_strftime_internal(argc, argv, self,\n\t\t\t\t  \"%Y-%m-%dT%H:%M:%S%:z\", set_tmx);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":253586,"func":"smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,\n\t       struct cifs_fid *fid)\n{\n\treturn SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":198736,"func":"static int rsi_send_beacon(struct rsi_common *common)\n{\n\tstruct sk_buff *skb = NULL;\n\tu8 dword_align_bytes = 0;\n\n\tskb = dev_alloc_skb(MAX_MGMT_PKT_SIZE);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\n\tmemset(skb->data, 0, MAX_MGMT_PKT_SIZE);\n\n\tdword_align_bytes = ((unsigned long)skb->data & 0x3f);\n\tif (dword_align_bytes)\n\t\tskb_pull(skb, (64 - dword_align_bytes));\n\tif (rsi_prepare_beacon(common, skb)) {\n\t\trsi_dbg(ERR_ZONE, \"Failed to prepare beacon\\n\");\n\t\treturn -EINVAL;\n\t}\n\tskb_queue_tail(&common->tx_queue[MGMT_BEACON_Q], skb);\n\trsi_set_event(&common->tx_thread.event);\n\trsi_dbg(DATA_TX_ZONE, \"%s: Added to beacon queue\\n\", __func__);\n\n\treturn 0;\n}","target":1,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":252323,"func":"size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len,\n                                   const void *pSrc_buf, size_t src_buf_len,\n                                   int flags) {\n  tinfl_decompressor decomp;\n  tinfl_status status;\n  tinfl_init(&decomp);\n  status =\n      tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf, &src_buf_len,\n                       (mz_uint8 *)pOut_buf, (mz_uint8 *)pOut_buf, &out_buf_len,\n                       (flags & ~TINFL_FLAG_HAS_MORE_INPUT) |\n                           TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);\n  return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED\n                                       : out_buf_len;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":259317,"func":"static void fix_index_entry_timestamps(AVStream* st, int end_index, int64_t end_ts,\n                                       int64_t* frame_duration_buffer,\n                                       int frame_duration_buffer_size) {\n    FFStream *const sti = ffstream(st);\n    int i = 0;\n    av_assert0(end_index >= 0 && end_index <= sti->nb_index_entries);\n    for (i = 0; i < frame_duration_buffer_size; i++) {\n        end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i];\n        sti->index_entries[end_index - 1 - i].timestamp = end_ts;\n    }\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":90771,"func":"void QuotaManager::GetCachedOrigins(\n    StorageType type, std::set<GURL>* origins) {\n  DCHECK(origins);\n  LazyInitialize();\n  switch (type) {\n    case kStorageTypeTemporary:\n      DCHECK(temporary_usage_tracker_.get());\n      temporary_usage_tracker_->GetCachedOrigins(origins);\n      return;\n    case kStorageTypePersistent:\n      DCHECK(persistent_usage_tracker_.get());\n      persistent_usage_tracker_->GetCachedOrigins(origins);\n      return;\n    default:\n      NOTREACHED();\n  }\n}\n","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":220024,"func":"  explicit AddManySparseToTensorsMapOp(OpKernelConstruction* context)\n      : SparseTensorAccessingOp(context) {}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":273084,"func":"uuid_make(char *str)\n{\n  uint16_t uuid[8];\n  time_t now;\n  int i;\n\n  now = time(NULL);\n\n  srand((unsigned int)now);\n\n  for (i = 0; i < ARRAY_SIZE(uuid); i++)\n    {\n      uuid[i] = (uint16_t)rand();\n\n      \/\/ time_hi_and_version, set version to 4 (=random)\n      if (i == 3)\n\tuuid[i] = (uuid[i] & 0x0FFF) | 0x4000;\n      \/\/ clock_seq, variant 1\n      if (i == 4)\n\tuuid[i] = (uuid[i] & 0x3FFF) | 0x8000;\n\n\n      if (i == 2 || i == 3 || i == 4 || i == 5)\n\tstr += sprintf(str, \"-\");\n\n      str += sprintf(str, \"%04\" PRIX16, uuid[i]);\n    }\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":336631,"func":"static void reds_mig_cleanup(RedsState *reds)\n{\n    if (reds->mig_inprogress) {\n\n        if (reds->mig_wait_connect || reds->mig_wait_disconnect) {\n            SpiceMigrateInterface *sif;\n            spice_assert(reds->migration_interface);\n            sif = SPICE_UPCAST(SpiceMigrateInterface, reds->migration_interface->base.sif);\n            if (reds->mig_wait_connect) {\n                sif->migrate_connect_complete(reds->migration_interface);\n            } else {\n                if (sif->migrate_end_complete) {\n                    sif->migrate_end_complete(reds->migration_interface);\n                }\n            }\n        }\n        reds->mig_inprogress = FALSE;\n        reds->mig_wait_connect = FALSE;\n        reds->mig_wait_disconnect = FALSE;\n        red_timer_cancel(reds->mig_timer);\n        reds_mig_cleanup_wait_disconnect(reds);\n    }\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":329887,"func":"span_renderer_fini (cairo_abstract_span_renderer_t *_r,\n\t\t    cairo_int_status_t status)\n{\n    cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *) _r;\n\n    TRACE ((stderr, \"%s\\n\", __FUNCTION__));\n\n    if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {\n\tif (r->base.finish)\n\t    r->base.finish (r);\n    }\n    if (likely (status == CAIRO_INT_STATUS_SUCCESS && r->bpp == 0)) {\n\tconst cairo_composite_rectangles_t *composite = r->composite;\n\n\tpixman_image_composite32 (r->op, r->src, r->mask,\n\t\t\t\t  to_pixman_image (composite->surface),\n\t\t\t\t  composite->unbounded.x + r->u.mask.src_x,\n\t\t\t\t  composite->unbounded.y + r->u.mask.src_y,\n\t\t\t\t  0, 0,\n\t\t\t\t  composite->unbounded.x,\n\t\t\t\t  composite->unbounded.y,\n\t\t\t\t  composite->unbounded.width,\n\t\t\t\t  composite->unbounded.height);\n    }\n\n    if (r->src)\n\tpixman_image_unref (r->src);\n    if (r->mask)\n\tpixman_image_unref (r->mask);\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":482471,"func":"atEndOfLine(const FileInfo *file) {\n\treturn file->linepos >= file->linelen;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":384853,"func":"vim_strsize(char_u *s)\n{\n    return vim_strnsize(s, (int)MAXCOL);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":234194,"func":"init_dwarf_regnames_x86_64 (void)\n{\n  dwarf_regnames = dwarf_regnames_x86_64;\n  dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);\n  dwarf_regnames_lookup_func = regname_internal_by_table_only;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":437723,"func":"static int cx23888_ir_rx_g_parameters(struct v4l2_subdev *sd,\n\t\t\t\t      struct v4l2_subdev_ir_parameters *p)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tmutex_lock(&state->rx_params_lock);\n\tmemcpy(p, &state->rx_params, sizeof(struct v4l2_subdev_ir_parameters));\n\tmutex_unlock(&state->rx_params_lock);\n\treturn 0;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":424911,"func":"static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,\n\t\t\t\t     char __user *user_buf,\n\t\t\t\t     size_t count, loff_t *ppos)\n{\n\tstruct iwl_trans *trans = file->private_data;\n\tchar *buf = NULL;\n\tssize_t ret;\n\n\tret = iwl_dump_fh(trans, &buf);\n\tif (ret < 0)\n\t\treturn ret;\n\tif (!buf)\n\t\treturn -EINVAL;\n\tret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);\n\tkfree(buf);\n\treturn ret;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":313843,"func":"restore_visual_mode(void)\n{\n    if (VIsual_mode_orig != NUL)\n    {\n\tcurbuf->b_visual.vi_mode = VIsual_mode_orig;\n\tVIsual_mode_orig = NUL;\n    }\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":309897,"func":"getmouse(MEVENT * aevent)\n{\n    return NCURSES_SP_NAME(getmouse) (CURRENT_SCREEN, aevent);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":424929,"func":"static int iwl_pcie_nic_init(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tint ret;\n\n\t\/* nic_init *\/\n\tspin_lock(&trans_pcie->irq_lock);\n\tret = iwl_pcie_apm_init(trans);\n\tspin_unlock(&trans_pcie->irq_lock);\n\n\tif (ret)\n\t\treturn ret;\n\n\tiwl_pcie_set_pwr(trans, false);\n\n\tiwl_op_mode_nic_config(trans->op_mode);\n\n\t\/* Allocate the RX queue, or reset if it is already allocated *\/\n\tiwl_pcie_rx_init(trans);\n\n\t\/* Allocate or reset and init all Tx and Command queues *\/\n\tif (iwl_pcie_tx_init(trans))\n\t\treturn -ENOMEM;\n\n\tif (trans->trans_cfg->base_params->shadow_reg_enable) {\n\t\t\/* enable shadow regs in HW *\/\n\t\tiwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL, 0x800FFFFF);\n\t\tIWL_DEBUG_INFO(trans, \"Enabling shadow registers in device\\n\");\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":459199,"func":"static struct tc_action *tcf_exts_first_act(struct tcf_exts *exts)\n{\n\tif (exts->nr_actions == 0)\n\t\treturn NULL;\n\telse\n\t\treturn exts->actions[0];\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":513089,"func":"  Item_hex_constant(THD *thd): Item_literal(thd)\n  {\n    hex_string_init(thd, \"\", 0);\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":468348,"func":"connection_attempt_unref (gpointer pointer)\n{\n  ConnectionAttempt *attempt = pointer;\n  if (g_ref_count_dec (&attempt->ref))\n    {\n      g_clear_object (&attempt->address);\n      g_clear_object (&attempt->socket);\n      g_clear_object (&attempt->connection);\n      g_clear_object (&attempt->cancellable);\n      if (attempt->timeout_source)\n        {\n          g_source_destroy (attempt->timeout_source);\n          g_source_unref (attempt->timeout_source);\n        }\n      g_free (attempt);\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":312539,"func":"qf_parse_fmt_t(regmatch_T *rmp, int midx, qffields_T *fields)\n{\n    if (rmp->startp[midx] == NULL)\n\treturn QF_FAIL;\n    fields->type = *rmp->startp[midx];\n    return QF_OK;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":236165,"func":"void gpp_read_style(GF_BitStream *bs, GF_StyleRecord *rec)\n{\n\trec->startCharOffset = gf_bs_read_u16(bs);\n\trec->endCharOffset = gf_bs_read_u16(bs);\n\trec->fontID = gf_bs_read_u16(bs);\n\trec->style_flags = gf_bs_read_u8(bs);\n\trec->font_size = gf_bs_read_u8(bs);\n\trec->text_color = gpp_read_rgba(bs);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":401576,"func":"int __must_check get_random_bytes_arch(void *buf, int nbytes)\n{\n\tint left = nbytes;\n\tchar *p = buf;\n\n\ttrace_get_random_bytes_arch(left, _RET_IP_);\n\twhile (left) {\n\t\tunsigned long v;\n\t\tint chunk = min_t(int, left, sizeof(unsigned long));\n\n\t\tif (!arch_get_random_long(&v))\n\t\t\tbreak;\n\n\t\tmemcpy(p, &v, chunk);\n\t\tp += chunk;\n\t\tleft -= chunk;\n\t}\n\n\treturn nbytes - left;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":359850,"func":"static inline Quantum GetAlpha(unsigned int word,TIM2ColorEncoding ce)\n{\n  switch(ce)\n  {\n    case RGBA16:\n      return ScaleCharToQuantum((word>>3*5&0x1F)==0?0:0xFF);\n    case RGBA32:\n      \/* 0x80 -> 1.0 alpha. Multiply by 2 and clamp to 0xFF *\/\n      return ScaleCharToQuantum(MagickMin((word>>3*8&0xFF)<<1,0xFF));\n    default:\n      return 0xFF;\n  }\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":512272,"func":"longlong Item_func_dyncol_check::val_int()\n{\n  char buff[STRING_BUFFER_USUAL_SIZE];\n  String tmp(buff, sizeof(buff), &my_charset_bin);\n  DYNAMIC_COLUMN col;\n  String *str;\n  enum enum_dyncol_func_result rc;\n\n  str= args[0]->val_str(&tmp);\n  if (args[0]->null_value)\n    goto null;\n  col.length= str->length();\n  \/* We do not change the string, so could do this trick *\/\n  col.str= (char *)str->ptr();\n  rc= mariadb_dyncol_check(&col);\n  if (rc < 0 && rc != ER_DYNCOL_FORMAT)\n  {\n    dynamic_column_error_message(rc);\n    goto null;\n  }\n  null_value= FALSE;\n  return rc == ER_DYNCOL_OK;\n\nnull:\n  null_value= TRUE;\n  return 0;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":353237,"func":"void SplashOutputDev::eoClip(GfxState *state) {\n  SplashPath path = convertPath(state, state->getPath(), true);\n  splash->clipToPath(&path, true);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":512582,"func":"longlong Item_func_isnotnull::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  return args[0]->is_null() ? 0 : 1;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":226348,"func":"void audio_sample_entry_box_del(GF_Box *s)\n{\n\tGF_MPEGAudioSampleEntryBox *ptr = (GF_MPEGAudioSampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\tif (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);\n\tgf_free(ptr);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":513147,"func":"static void unlock_variables(THD *thd, struct system_variables *vars)\n{\n  intern_plugin_unlock(NULL, vars->table_plugin);\n  intern_plugin_unlock(NULL, vars->tmp_table_plugin);\n  intern_plugin_unlock(NULL, vars->enforced_table_plugin);\n  vars->table_plugin= vars->tmp_table_plugin= vars->enforced_table_plugin= NULL;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":338182,"func":"WasmBinaryBuilder::getByteView(size_t size) {\n  if (size > input.size() || pos > input.size() - size) {\n    throwError(\"unexpected end of input\");\n  }\n  pos += size;\n  return {input.data() + (pos - size), input.data() + pos};\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":344257,"func":"int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode) {\n  TValue v;\n  if (l_strton(obj, &v))  \/* does 'obj' point to a numerical string? *\/\n    obj = &v;  \/* change it to point to its corresponding number *\/\n  return luaV_tointegerns(obj, p, mode);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":498089,"func":"char *fmtalloc(const char *format, ...)\n{\n\tstruct strbuf sb = STRBUF_INIT;\n\tva_list args;\n\n\tva_start(args, format);\n\tstrbuf_vaddf(&sb, format, args);\n\tva_end(args);\n\n\treturn strbuf_detach(&sb, NULL);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":90220,"func":"  virtual bool offline_mode() const { return offline_mode_; }\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":312555,"func":"qf_store_title(qf_list_T *qfl, char_u *title)\n{\n    VIM_CLEAR(qfl->qf_title);\n\n    if (title != NULL)\n    {\n\tchar_u *p = alloc_id(STRLEN(title) + 2, aid_qf_title);\n\n\tqfl->qf_title = p;\n\tif (p != NULL)\n\t    STRCPY(p, title);\n    }\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":234130,"func":"regname_internal_by_table_only (unsigned int regno)\n{\n  if (dwarf_regnames != NULL\n      && regno < dwarf_regnames_count\n      && dwarf_regnames [regno] != NULL)\n    return dwarf_regnames [regno];\n\n  return NULL;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":512761,"func":"Item_bool_rowready_func2* Lt_creator::create_swap(THD *thd, Item *a, Item *b) const\n{\n  return new(thd->mem_root) Item_func_gt(thd, b, a);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":291806,"func":"int rtrs_clt_get_max_reconnect_attempts(const struct rtrs_clt_sess *clt)\n{\n\treturn (int)clt->max_reconnect_attempts;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":234252,"func":"dwarf_select_sections_all (void)\n{\n  do_debug_info = 1;\n  do_debug_abbrevs = 1;\n  do_debug_lines = FLAG_DEBUG_LINES_RAW;\n  do_debug_pubnames = 1;\n  do_debug_pubtypes = 1;\n  do_debug_aranges = 1;\n  do_debug_ranges = 1;\n  do_debug_frames = 1;\n  do_debug_macinfo = 1;\n  do_debug_str = 1;\n  do_debug_loc = 1;\n  do_gdb_index = 1;\n  do_trace_info = 1;\n  do_trace_abbrevs = 1;\n  do_trace_aranges = 1;\n  do_debug_addr = 1;\n  do_debug_cu_index = 1;\n  do_follow_links = 1;\n  do_debug_links = 1;\n  do_debug_str_offsets = 1;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":344770,"func":"set_rdomain(int fd, const char *name)\n{\n#if defined(HAVE_SYS_SET_RDOMAIN)\n\treturn sys_set_rdomain(fd, name);\n#elif defined(__OpenBSD__)\n\tint rtable;\n\tconst char *errstr;\n\n\tif (name == NULL)\n\t\treturn 0; \/* default table *\/\n\n\trtable = (int)strtonum(name, 0, 255, &errstr);\n\tif (errstr != NULL) {\n\t\t\/* Shouldn't happen *\/\n\t\terror(\"Invalid routing domain \\\"%s\\\": %s\", name, errstr);\n\t\treturn -1;\n\t}\n\tif (setsockopt(fd, SOL_SOCKET, SO_RTABLE,\n\t    &rtable, sizeof(rtable)) == -1) {\n\t\terror(\"Failed to set routing domain %d on fd %d: %s\",\n\t\t    rtable, fd, strerror(errno));\n\t\treturn -1;\n\t}\n\treturn 0;\n#else \/* defined(__OpenBSD__) *\/\n\terror(\"Setting routing domain is not supported on this platform\");\n\treturn -1;\n#endif\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":438660,"func":"static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev)\n{\n\tstruct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);\n\tstruct virtproc_info *vrp = vch->vrp;\n\tstruct device *dev = &rpdev->dev;\n\tint err = 0;\n\n\t\/* need to tell remote processor's name service about this channel ? *\/\n\tif (rpdev->announce && rpdev->ept &&\n\t    virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) {\n\t\tstruct rpmsg_ns_msg nsm;\n\n\t\tstrncpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE);\n\t\tnsm.addr = cpu_to_rpmsg32(rpdev, rpdev->ept->addr);\n\t\tnsm.flags = cpu_to_rpmsg32(rpdev, RPMSG_NS_CREATE);\n\n\t\terr = rpmsg_sendto(rpdev->ept, &nsm, sizeof(nsm), RPMSG_NS_ADDR);\n\t\tif (err)\n\t\t\tdev_err(dev, \"failed to announce service %d\\n\", err);\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":338071,"func":"bool WasmBinaryBuilder::maybeVisitMemoryInit(Expression*& out, uint32_t code) {\n  if (code != BinaryConsts::MemoryInit) {\n    return false;\n  }\n  auto* curr = allocator.alloc<MemoryInit>();\n  curr->size = popNonVoidExpression();\n  curr->offset = popNonVoidExpression();\n  curr->dest = popNonVoidExpression();\n  curr->segment = getU32LEB();\n  if (getInt8() != 0) {\n    throwError(\"Unexpected nonzero memory index\");\n  }\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":207719,"func":"display_dollar(colnr_T col)\n{\n    colnr_T save_col;\n\n    if (!redrawing())\n\treturn;\n\n    cursor_off();\n    save_col = curwin->w_cursor.col;\n    curwin->w_cursor.col = col;\n    if (has_mbyte)\n    {\n\tchar_u *p;\n\n\t\/\/ If on the last byte of a multi-byte move to the first byte.\n\tp = ml_get_curline();\n\tcurwin->w_cursor.col -= (*mb_head_off)(p, p + col);\n    }\n    curs_columns(FALSE);\t    \/\/ recompute w_wrow and w_wcol\n    if (curwin->w_wcol < curwin->w_width)\n    {\n\tedit_putchar('$', FALSE);\n\tdollar_vcol = curwin->w_virtcol;\n    }\n    curwin->w_cursor.col = save_col;\n}","target":1,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":240307,"func":"put_reedit_in_typebuf(int silent)\n{\n    char_u\tbuf[3];\n\n    if (restart_edit != NUL)\n    {\n\tif (restart_edit == 'V')\n\t{\n\t    buf[0] = 'g';\n\t    buf[1] = 'R';\n\t    buf[2] = NUL;\n\t}\n\telse\n\t{\n\t    buf[0] = restart_edit == 'I' ? 'i' : restart_edit;\n\t    buf[1] = NUL;\n\t}\n\tif (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK)\n\t    restart_edit = NUL;\n    }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":226187,"func":"GF_Err edts_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_EditBox *ptr = (GF_EditBox *)s;\n\tif (a->type == GF_ISOM_BOX_TYPE_ELST) {\n\t\tBOX_FIELD_ASSIGN(editList, GF_EditListBox)\n\t\treturn GF_OK;\n\t} else {\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":230989,"func":"mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p)\n{\n  mrb_callinfo *ci = mrb->c->ci;\n  if (ci->cci == CINFO_NONE) {\n    return exec_irep(mrb, self, p);\n  }\n  else {\n    mrb_value ret;\n    if (MRB_PROC_CFUNC_P(p)) {\n      if (MRB_PROC_NOARG_P(p)) {\n        check_method_noarg(mrb, ci);\n      }\n      cipush(mrb, 0, CINFO_DIRECT, mrb_vm_ci_target_class(ci), p, ci->mid, ci->n|(ci->nk<<4));\n      ret = MRB_PROC_CFUNC(p)(mrb, self);\n      cipop(mrb);\n    }\n    else {\n      mrb_int keep = mrb_ci_bidx(ci) + 1; \/* receiver + block *\/\n      ret = mrb_top_run(mrb, p, self, keep);\n    }\n    if (mrb->exc && mrb->jmp) {\n      mrb_exc_raise(mrb, mrb_obj_value(mrb->exc));\n    }\n    return ret;\n  }\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":224478,"func":"\nconst GF_FilterRegister *txtin_register(GF_FilterSession *session)\n{\n\treturn &TXTInRegister;","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":432324,"func":"MemoryRegion *flatview_translate(struct uc_struct *uc, FlatView *fv, hwaddr addr, hwaddr *xlat,\n                                 hwaddr *plen, bool is_write,\n                                 MemTxAttrs attrs)\n{\n    MemoryRegion *mr;\n    MemoryRegionSection section;\n    AddressSpace *as = NULL;\n\n    \/* This can be MMIO, so setup MMIO bit. *\/\n    section = flatview_do_translate(uc, fv, addr, xlat, plen, NULL,\n                                    is_write, true, &as, attrs);\n    mr = section.mr;\n\n    return mr;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":473857,"func":"mbc_case_fold(OnigCaseFoldType flag,\n\t      const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower,\n\t      OnigEncoding enc ARG_UNUSED)\n{\n  const UChar* p = *pp;\n\n  if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    *lower++ = 's';\n    *lower   = 's';\n    (*pp)++;\n    return 2;\n  }\n\n  *lower = ENC_ISO_8859_4_TO_LOWER_CASE(*p);\n  (*pp)++;\n  return 1; \/* return byte length of converted char to lower *\/\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":512694,"func":"  void set_with_sum_func() { m_with_sum_func= true; }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":513100,"func":"  my_decimal *val_decimal(my_decimal *to) { return cached_time.to_decimal(to); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":238788,"func":"findmatch(oparg_T *oap, int initc)\n{\n    return findmatchlimit(oap, initc, 0, 0);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":310158,"func":"test_tparm(const char *name, int *number)\n{\n    char *format = tigetstr(name);\n    if ((format = validate(name)) != 0) {\n\tchar *result = tparm(format,\n\t\t\t     number[0],\n\t\t\t     number[1],\n\t\t\t     number[2],\n\t\t\t     number[3],\n\t\t\t     number[4],\n\t\t\t     number[5],\n\t\t\t     number[6],\n\t\t\t     number[7],\n\t\t\t     number[8]);\n\tif (v_opt > 1)\n\t    printf(\".. %2d = %2d %2d %2d %2d %2d %2d %2d %2d %2d %s\\n\",\n\t\t   result != 0 ? (int) strlen(result) : -1,\n\t\t   number[0],\n\t\t   number[1],\n\t\t   number[2],\n\t\t   number[3],\n\t\t   number[4],\n\t\t   number[5],\n\t\t   number[6],\n\t\t   number[7],\n\t\t   number[8],\n\t\t   name);\n    }\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":513288,"func":"join_read_next_same_or_null(READ_RECORD *info)\n{\n  int error;\n  if ((error= join_read_next_same(info)) >= 0)\n    return error;\n  JOIN_TAB *tab= info->table->reginfo.join_tab;\n\n  \/* Test if we have already done a read after null key *\/\n  if (*tab->ref.null_ref_key)\n    return -1;\t\t\t\t\t\/\/ All keys read\n  *tab->ref.null_ref_key= 1;\t\t\t\/\/ Set null byte\n  return safe_index_read(tab);\t\t\t\/\/ then read null keys\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":332370,"func":"get_op_type(int char1, int char2)\n{\n    int\t\ti;\n\n    if (char1 == 'r')\t\t\/\/ ignore second character\n\treturn OP_REPLACE;\n    if (char1 == '~')\t\t\/\/ when tilde is an operator\n\treturn OP_TILDE;\n    if (char1 == 'g' && char2 == Ctrl_A)\t\/\/ add\n\treturn OP_NR_ADD;\n    if (char1 == 'g' && char2 == Ctrl_X)\t\/\/ subtract\n\treturn OP_NR_SUB;\n    if (char1 == 'z' && char2 == 'y')\t\/\/ OP_YANK\n\treturn OP_YANK;\n    for (i = 0; ; ++i)\n    {\n\tif (opchars[i][0] == char1 && opchars[i][1] == char2)\n\t    break;\n\tif (i == (int)ARRAY_LENGTH(opchars) - 1)\n\t{\n\t    internal_error(\"get_op_type()\");\n\t    break;\n\t}\n    }\n    return i;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":328984,"func":"R_API RBinJavaAttrInfo *r_bin_java_unknown_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\treturn r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":318100,"func":"static int rsi_resume(struct usb_interface *intf)\n{\n\t\/* Not yet implemented *\/\n\treturn -ENOSYS;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":508873,"func":"Lex_input_stream::get_escape_func(THD *thd, my_wc_t sep) const\n{\n  return thd->backslash_escapes() ?\n         (sep == '\"' ? my_wc_mb_utf8_escape_double_quote_and_backslash:\n                       my_wc_mb_utf8_escape_single_quote_and_backslash) :\n         (sep == '\"' ? my_wc_mb_utf8_escape_double_quote:\n                       my_wc_mb_utf8_escape_single_quote);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":513217,"func":"bool check_valid_path(const char *path, size_t len)\n{\n  size_t prefix= my_strcspn(files_charset_info, path, path + len, FN_DIRSEP);\n  return  prefix < len;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":509561,"func":"static handler *maria_create_handler(handlerton *hton,\n                                     TABLE_SHARE * table,\n                                     MEM_ROOT *mem_root)\n{\n  return new (mem_root) ha_maria(hton, table);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":488330,"func":"int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)\n{\n\tstruct address_space *mapping = inode->i_mapping;\n\n\t\/*\n\t * If the underlying filesystem is not going to provide\n\t * a way to truncate a range of blocks (punch a hole) -\n\t * we should return failure right now.\n\t *\/\n\tif (!inode->i_op || !inode->i_op->truncate_range)\n\t\treturn -ENOSYS;\n\n\tmutex_lock(&inode->i_mutex);\n\tdown_write(&inode->i_alloc_sem);\n\tunmap_mapping_range(mapping, offset, (end - offset), 1);\n\ttruncate_inode_pages_range(mapping, offset, end);\n\tunmap_mapping_range(mapping, offset, (end - offset), 1);\n\tinode->i_op->truncate_range(inode, offset, end);\n\tup_write(&inode->i_alloc_sem);\n\tmutex_unlock(&inode->i_mutex);\n\n\treturn 0;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":292139,"func":"void LinkResolver::resolve_invokespecial(CallInfo& result, Handle recv,\n                                         const constantPoolHandle& pool, int index, TRAPS) {\n  LinkInfo link_info(pool, index, CHECK);\n  resolve_special_call(result, recv, link_info, CHECK);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":231800,"func":"  Buf getCryptoStreamData() {\n    CHECK(!serverWrites.empty());\n    auto cryptoBuf = IOBuf::create(0);\n    AckStates ackStates;\n    for (auto& serverWrite : serverWrites) {\n      auto packetQueue = bufToQueue(serverWrite->clone());\n      auto result = clientReadCodec->parsePacket(packetQueue, ackStates);\n      auto& parsedPacket = *result.regularPacket();\n      for (auto& frame : parsedPacket.frames) {\n        if (frame.type() != QuicFrame::Type::ReadCryptoFrame) {\n          continue;\n        }\n        cryptoBuf->prependChain(frame.asReadCryptoFrame()->data->clone());\n      }\n    }\n    return cryptoBuf;\n  }","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":90206,"func":"  virtual bool cellular_connecting() const { return false; }\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":498103,"func":"void html_attrf(const char *fmt, ...)\n{\n\tva_list ap;\n\tstruct strbuf sb = STRBUF_INIT;\n\n\tva_start(ap, fmt);\n\tstrbuf_vaddf(&sb, fmt, ap);\n\tva_end(ap);\n\n\thtml_attr(sb.buf);\n\tstrbuf_release(&sb);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":369143,"func":"\nstatic int io_eventfd_register(struct io_ring_ctx *ctx, void __user *arg,\n\t\t\t       unsigned int eventfd_async)\n{\n\tstruct io_ev_fd *ev_fd;\n\t__s32 __user *fds = arg;\n\tint fd;\n\n\tev_fd = rcu_dereference_protected(ctx->io_ev_fd,\n\t\t\t\t\tlockdep_is_held(&ctx->uring_lock));\n\tif (ev_fd)\n\t\treturn -EBUSY;\n\n\tif (copy_from_user(&fd, fds, sizeof(*fds)))\n\t\treturn -EFAULT;\n\n\tev_fd = kmalloc(sizeof(*ev_fd), GFP_KERNEL);\n\tif (!ev_fd)\n\t\treturn -ENOMEM;\n\n\tev_fd->cq_ev_fd = eventfd_ctx_fdget(fd);\n\tif (IS_ERR(ev_fd->cq_ev_fd)) {\n\t\tint ret = PTR_ERR(ev_fd->cq_ev_fd);\n\t\tkfree(ev_fd);\n\t\treturn ret;\n\t}\n\tev_fd->eventfd_async = eventfd_async;\n\tctx->has_evfd = true;\n\trcu_assign_pointer(ctx->io_ev_fd, ev_fd);\n\treturn 0;","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":427220,"func":"static void codestring (expdesc *e, TString *s) {\n  e->f = e->t = NO_JUMP;\n  e->k = VKSTR;\n  e->u.strval = s;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":177175,"func":"WebFrameProxy* WebProcessProxy::webFrame(uint64_t frameID) const\n{\n    return isGoodKey<WebFrameProxyMap>(frameID) ? m_frameMap.get(frameID).get() : 0;\n}\n","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":369356,"func":"static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)\n{\n\tswitch (ret) {\n\tcase -EIOCBQUEUED:\n\t\tbreak;\n\tcase -ERESTARTSYS:\n\tcase -ERESTARTNOINTR:\n\tcase -ERESTARTNOHAND:\n\tcase -ERESTART_RESTARTBLOCK:\n\t\t\/*\n\t\t * We can't just restart the syscall, since previously\n\t\t * submitted sqes may already be in progress. Just fail this\n\t\t * IO with EINTR.\n\t\t *\/\n\t\tret = -EINTR;\n\t\tfallthrough;\n\tdefault:\n\t\tkiocb->ki_complete(kiocb, ret);\n\t}\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":437354,"func":"concat_opt_exact_str(OptExact* to, UChar* s, UChar* end, OnigEncoding enc)\n{\n  int i, j, len;\n  UChar *p;\n\n  for (i = to->len, p = s; p < end && i < OPT_EXACT_MAXLEN; ) {\n    len = enclen(enc, p);\n    if (i + len > OPT_EXACT_MAXLEN) break;\n    for (j = 0; j < len && p < end; j++)\n      to->s[i++] = *p++;\n  }\n\n  to->len = i;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":244005,"func":"void vmhd_box_del(GF_Box *s)\n{\n\tGF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":220391,"func":"mrb_ary_rindex_m(mrb_state *mrb, mrb_value self)\n{\n  mrb_value obj = mrb_get_arg1(mrb);\n  mrb_int i, len;\n\n  for (i = RARRAY_LEN(self) - 1; i >= 0; i--) {\n    if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {\n      return mrb_int_value(mrb, i);\n    }\n    if (i > (len = RARRAY_LEN(self))) {\n      i = len;\n    }\n  }\n  return mrb_nil_value();\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":269315,"func":"static av_always_inline void snow_horizontal_compose_lift_lead_out(int i, IDWTELEM * dst, IDWTELEM * src, IDWTELEM * ref, int width, int w, int lift_high, int mul, int add, int shift){\n    for(; i<w; i++){\n        dst[i] = src[i] - ((mul * (ref[i] + ref[i + 1]) + add) >> shift);\n    }\n\n    if((width^lift_high)&1){\n        dst[w] = src[w] - ((mul * 2 * ref[w] + add) >> shift);\n    }\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":226018,"func":"\nGF_Box *svhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SphericalVideoInfoBox, GF_ISOM_BOX_TYPE_SVHD);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":225831,"func":"\nvoid vmhd_box_del(GF_Box *s)\n{\n\tGF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":226426,"func":"    explicit Iterator(const typename Iterator::Params& params)\n        : DatasetIterator<Dataset<T>>(params),\n          num_elements_(params.dataset->sparse_tensor_.shape()[0]),\n          dense_shape_(DT_INT64, {params.dataset->sparse_tensor_.dims() - 1}),\n          group_iterable_(params.dataset->sparse_tensor_.group({0})),\n          iter_(group_iterable_.begin()) {\n      for (size_t i = 0; i < dense_shape_.NumElements(); ++i) {\n        dense_shape_.vec<int64_t>()(i) =\n            params.dataset->sparse_tensor_.shape()[i + 1];\n      }\n    }","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":230293,"func":"njs_array_handler_includes(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    if (!njs_is_valid(entry)) {\n        entry = njs_value_arg(&njs_value_undefined);\n    }\n\n    if (njs_values_same_zero(args->argument, entry)) {\n        njs_set_true(&vm->retval);\n\n        return NJS_DONE;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":317243,"func":"static void ipc_init_security(struct ipc_security_struct *isec, u16 sclass)\n{\n\tisec->sclass = sclass;\n\tisec->sid = current_sid();\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":512401,"func":"  Item_hex_constant(THD *thd, const char *str, size_t str_length):\n    Item_literal(thd)\n  {\n    hex_string_init(thd, str, str_length);\n  }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":432243,"func":"static void flatview_insert(FlatView *view, unsigned pos, FlatRange *range)\n{\n    if (view->nr == view->nr_allocated) {\n        view->nr_allocated = MAX(2 * view->nr, 10);\n        view->ranges = g_realloc(view->ranges,\n                                    view->nr_allocated * sizeof(*view->ranges));\n    }\n    memmove(view->ranges + pos + 1, view->ranges + pos,\n            (view->nr - pos) * sizeof(FlatRange));\n    view->ranges[pos] = *range;\n    ++view->nr;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":242949,"func":"void mbedtls_ssl_dtls_replay_reset( mbedtls_ssl_context *ssl )\n{\n    ssl->in_window_top = 0;\n    ssl->in_window = 0;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":294447,"func":"d_trunc(VALUE d, VALUE *fr)\n{\n    VALUE rd;\n\n    if (wholenum_p(d)) {\n\trd = to_integer(d);\n\t*fr = INT2FIX(0);\n    }\n    else {\n\trd = f_idiv(d, INT2FIX(1));\n\t*fr = f_mod(d, INT2FIX(1));\n    }\n    return rd;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":234870,"func":"struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,\n\t\t\t\t       u64 logical, u64 length)\n{\n\tstruct extent_map_tree *em_tree;\n\tstruct extent_map *em;\n\n\tem_tree = &fs_info->mapping_tree;\n\tread_lock(&em_tree->lock);\n\tem = lookup_extent_mapping(em_tree, logical, length);\n\tread_unlock(&em_tree->lock);\n\n\tif (!em) {\n\t\tbtrfs_crit(fs_info, \"unable to find logical %llu length %llu\",\n\t\t\t   logical, length);\n\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\tif (em->start > logical || em->start + em->len < logical) {\n\t\tbtrfs_crit(fs_info,\n\t\t\t   \"found a bad mapping, wanted %llu-%llu, found %llu-%llu\",\n\t\t\t   logical, length, em->start, em->start + em->len);\n\t\tfree_extent_map(em);\n\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\t\/* callers are responsible for dropping em's ref. *\/\n\treturn em;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":477288,"func":"static struct tipc_aead *tipc_aead_get(struct tipc_aead __rcu *aead)\n{\n\tstruct tipc_aead *tmp;\n\n\trcu_read_lock();\n\ttmp = rcu_dereference(aead);\n\tif (unlikely(!tmp || !refcount_inc_not_zero(&tmp->refcnt)))\n\t\ttmp = NULL;\n\trcu_read_unlock();\n\n\treturn tmp;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":244346,"func":"GF_Box *sbgp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleGroupBox, GF_ISOM_BOX_TYPE_SBGP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":226253,"func":"GF_Box *mfra_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MovieFragmentRandomAccessBox, GF_ISOM_BOX_TYPE_MFRA);\n\ttmp->tfra_list = gf_list_new();\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":473972,"func":"mbc_case_fold(OnigCaseFoldType flag,\n\t      const UChar** pp, const UChar* end, UChar* lower,\n\t      OnigEncoding enc)\n{\n  int len;\n  const UChar* p = *pp;\n\n  if (ONIGENC_IS_MBC_ASCII(p)) {\n    *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);\n    (*pp)++;\n    return 1;\n  }\n  else {\n    int i;\n\n    len = mbc_enc_len(p, end, enc);\n    for (i = 0; i < len; i++) {\n      *lower++ = *p++;\n    }\n    (*pp) += len;\n    return len; \/* return byte length of converted char to lower *\/\n  }\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":226353,"func":"\nGF_UserDataMap *udta_getEntry(GF_UserDataBox *ptr, u32 box_type, bin128 *uuid)\n{\n\tu32 i;\n\tGF_UserDataMap *map;\n\tif (ptr == NULL) return NULL;\n\ti=0;\n\twhile ((map = (GF_UserDataMap *)gf_list_enum(ptr->recordList, &i))) {\n\t\tif (map->boxType == box_type) {\n\t\t\tif ((box_type != GF_ISOM_BOX_TYPE_UUID) || !uuid) return map;\n\t\t\tif (!memcmp(map->uuid, *uuid, 16)) return map;\n\t\t}\n\t}\n\treturn NULL;","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":398550,"func":"static inline ut64 dwarf_read_initial_length(RZ_OUT bool *is_64bit, bool big_endian, const ut8 **buf, const ut8 *buf_end) {\n\tut64 r = READ32(*buf);\n\tif (r == DWARF_INIT_LEN_64) {\n\t\tr = READ64(*buf);\n\t\t*is_64bit = true;\n\t} else {\n\t\t*is_64bit = false;\n\t}\n\treturn r;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":338055,"func":"void WasmBinaryWriter::writeData(const char* data, size_t size) {\n  for (size_t i = 0; i < size; i++) {\n    o << int8_t(data[i]);\n  }\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":459185,"func":"int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp,\n\t\t\t  bool add, flow_setup_cb_t *cb,\n\t\t\t  enum tc_setup_type type, void *type_data,\n\t\t\t  void *cb_priv, u32 *flags, unsigned int *in_hw_count)\n{\n\tint err = cb(type, type_data, cb_priv);\n\n\tif (err) {\n\t\tif (add && tc_skip_sw(*flags))\n\t\t\treturn err;\n\t} else {\n\t\ttc_cls_offload_cnt_update(block, tp, in_hw_count, flags, 1,\n\t\t\t\t\t  add);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":369377,"func":" *\/\nstatic int io_timeout_remove(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_timeout_rem *tr = &req->timeout_rem;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tint ret;\n\n\tif (!(req->timeout_rem.flags & IORING_TIMEOUT_UPDATE)) {\n\t\tspin_lock(&ctx->completion_lock);\n\t\tspin_lock_irq(&ctx->timeout_lock);\n\t\tret = io_timeout_cancel(ctx, tr->addr);\n\t\tspin_unlock_irq(&ctx->timeout_lock);\n\t\tspin_unlock(&ctx->completion_lock);\n\t} else {\n\t\tenum hrtimer_mode mode = io_translate_timeout_mode(tr->flags);\n\n\t\tspin_lock_irq(&ctx->timeout_lock);\n\t\tif (tr->ltimeout)\n\t\t\tret = io_linked_timeout_update(ctx, tr->addr, &tr->ts, mode);\n\t\telse\n\t\t\tret = io_timeout_update(ctx, tr->addr, &tr->ts, mode);\n\t\tspin_unlock_irq(&ctx->timeout_lock);\n\t}\n\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete_post(req, ret, 0);\n\treturn 0;","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":359369,"func":"DEFUN (no_neighbor_attr_unchanged2,\n       no_neighbor_attr_unchanged2_cmd,\n       NO_NEIGHBOR_CMD2 \"attribute-unchanged as-path (next-hop|med)\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"BGP attribute is propagated unchanged to this neighbor\\n\"\n       \"As-path attribute\\n\"\n       \"Nexthop attribute\\n\"\n       \"Med attribute\\n\")\n{\n  u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;\n\n  if (strncmp (argv[1], \"next-hop\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);\n  else if (strncmp (argv[1], \"med\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);\n\n  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t       bgp_node_safi (vty), flags);\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":274891,"func":"TEST(QuantizedComparisonsTest, EqualInt8Quantized) {\n  const float kMin = -127.f;\n  const float kMax = 127.f;\n  ComparisonOpModel model({TensorType_INT8, {1, 2, 2, 1}, kMin, kMax},\n                          {TensorType_INT8, {1, 2, 2, 1}, kMin, kMax},\n                          TensorType_INT8, BuiltinOperator_EQUAL);\n  model.QuantizeAndPopulate<int8_t>(model.input1(), {1, -9, 7, 3});\n  model.QuantizeAndPopulate<int8_t>(model.input2(), {-1, 2, 7, 5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, false, true, false));\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":273883,"func":"static void handle_QUIT(ctrl_t *ctrl, char *arg)\n{\n\tsend_msg(ctrl->sd, \"221 Goodbye.\\r\\n\");\n\tuev_exit(ctrl->ctx);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":225965,"func":"\nGF_Err dmlp_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TrueHDConfigBox *ptr = (GF_TrueHDConfigBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 10)\n\tptr->format_info = gf_bs_read_u32(bs);\n\tptr->peak_data_rate = gf_bs_read_int(bs, 15);\n\tgf_bs_read_int(bs, 1);\n\tgf_bs_read_u32(bs);\n\treturn GF_OK;","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":427211,"func":"static void setvararg (FuncState *fs, int nparams) {\n  fs->f->is_vararg = 1;\n  luaK_codeABC(fs, OP_VARARGPREP, nparams, 0, 0);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":359663,"func":"DEFUN (bgp_router_id,\n       bgp_router_id_cmd,\n       \"bgp router-id A.B.C.D\",\n       BGP_STR\n       \"Override configured router identifier\\n\"\n       \"Manually configured router identifier\\n\")\n{\n  int ret;\n  struct in_addr id;\n  struct bgp *bgp;\n\n  bgp = vty->index;\n\n  ret = inet_aton (argv[0], &id);\n  if (! ret)\n    {\n      vty_out (vty, \"%% Malformed bgp router identifier%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  bgp->router_id_static = id;\n  bgp_router_id_set (bgp, &id);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":509570,"func":"bool maria_flush_logs(handlerton *hton)\n{\n  return MY_TEST(translog_purge_at_flush());\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":472373,"func":"bool ciEnv::jvmti_state_changed() const {\n  \/\/ Some classes were redefined\n  if (_jvmti_redefinition_count != JvmtiExport::redefinition_count()) {\n    return true;\n  }\n\n  if (!_jvmti_can_access_local_variables &&\n      JvmtiExport::can_access_local_variables()) {\n    return true;\n  }\n  if (!_jvmti_can_hotswap_or_post_breakpoint &&\n      JvmtiExport::can_hotswap_or_post_breakpoint()) {\n    return true;\n  }\n  if (!_jvmti_can_post_on_exceptions &&\n      JvmtiExport::can_post_on_exceptions()) {\n    return true;\n  }\n  if (!_jvmti_can_pop_frame &&\n      JvmtiExport::can_pop_frame()) {\n    return true;\n  }\n  if (!_jvmti_can_get_owned_monitor_info &&\n      JvmtiExport::can_get_owned_monitor_info()) {\n    return true;\n  }\n  if (!_jvmti_can_walk_any_space &&\n      JvmtiExport::can_walk_any_space()) {\n    return true;\n  }\n\n  return false;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":230286,"func":"njs_array_handler_map(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    njs_int_t    ret;\n    njs_array_t  *retval;\n    njs_value_t  this;\n\n    retval = args->data;\n\n    if (retval->object.fast_array) {\n        njs_set_invalid(&retval->start[n]);\n    }\n\n    if (njs_is_valid(entry)) {\n        ret = njs_array_iterator_call(vm, args, entry, n);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (njs_is_valid(&vm->retval)) {\n            if (retval->object.fast_array) {\n                retval->start[n] = vm->retval;\n\n            } else {\n                njs_set_array(&this, retval);\n\n                ret = njs_value_property_i64_set(vm, &this, n, &vm->retval);\n                if (njs_slow_path(ret != NJS_OK)) {\n                    return ret;\n                }\n            }\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":294370,"func":"k_numeric_p(VALUE x)\n{\n    return f_kind_of_p(x, rb_cNumeric);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":508817,"func":"void st_select_lex_node::fast_exclude()\n{\n  if (link_prev)\n  {\n    if ((*link_prev= link_next))\n      link_next->link_prev= link_prev;\n  }\n  \/\/ Remove slave structure\n  for (; slave; slave= slave->next)\n    slave->fast_exclude();\n  \n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":243995,"func":"GF_Box *prhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ProjectionHeaderBox, GF_ISOM_BOX_TYPE_PRHD);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":369387,"func":"static __cold void io_uring_drop_tctx_refs(struct task_struct *task)\n{\n\tstruct io_uring_task *tctx = task->io_uring;\n\tunsigned int refs = tctx->cached_refs;\n\n\tif (refs) {\n\t\ttctx->cached_refs = 0;\n\t\tpercpu_counter_sub(&tctx->inflight, refs);\n\t\tput_task_struct_many(task, refs);\n\t}\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":364737,"func":"emacs_tags_file_eof(findtags_state_T *st)\n{\n    if (!incstack_idx)\t\/\/ reached end of file. stop processing.\n\treturn FALSE;\n\n    \/\/ reached the end of an included tags file. pop it.\n    --incstack_idx;\n    fclose(st->fp);\t\/\/ end of this file ...\n    st->fp = incstack[incstack_idx].fp;\n    STRCPY(st->tag_fname, incstack[incstack_idx].etag_fname);\n    vim_free(incstack[incstack_idx].etag_fname);\n    st->is_etag = TRUE;\t\/\/ (only etags can include)\n\n    return TRUE;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":219025,"func":"float QuantizedTypeMinAsFloat(DataType data_type) {\n  switch (data_type) {\n    case DT_QINT8:\n      return Eigen::NumTraits<qint8>::lowest();\n    case DT_QUINT8:\n      return Eigen::NumTraits<quint8>::lowest();\n    case DT_QINT16:\n      return Eigen::NumTraits<qint16>::lowest();\n    case DT_QUINT16:\n      return Eigen::NumTraits<quint16>::lowest();\n    case DT_QINT32:\n      return Eigen::NumTraits<qint32>::lowest();\n    default:\n      return 0.0f;\n  }\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":263306,"func":"char *_q_fgets(char *str, size_t size, FILE *fp)\n{\n    int c;\n    char *ptr;\n\n    for (ptr = str; size > 1; size--) {\n        c = fgetc(fp);\n        if (c == EOF) break;\n        *ptr++ = (char)c;\n        if (c == '\\n') break;\n    }\n\n    *ptr = '\\0';\n    if (strlen(str) == 0) return NULL;\n\n    return str;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":244023,"func":"GF_Box *trep_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackExtensionPropertiesBox, GF_ISOM_BOX_TYPE_TREP);\n\ttmp->child_boxes = gf_list_new();\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":345132,"func":"dump_whole_state(struct pxa3xx_gcu_priv *priv)\n{\n\tstruct pxa3xx_gcu_shared *sh = priv->shared;\n\tu32 base = gc_readl(priv, REG_GCRBBR);\n\n\tQDUMP(\"DUMP\");\n\n\tprintk(KERN_DEBUG \"== PXA3XX-GCU DUMP ==\\n\"\n\t\t\"%s, STATUS 0x%02lx, B 0x%08lx [%ld], E %5ld, H %5ld, T %5ld\\n\",\n\t\tsh->hw_running ? \"running\" : \"idle   \",\n\t\tgc_readl(priv, REG_GCISCR),\n\t\tgc_readl(priv, REG_GCRBBR),\n\t\tgc_readl(priv, REG_GCRBLR),\n\t\t(gc_readl(priv, REG_GCRBEXHR) - base) \/ 4,\n\t\t(gc_readl(priv, REG_GCRBHR) - base) \/ 4,\n\t\t(gc_readl(priv, REG_GCRBTR) - base) \/ 4);\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":312589,"func":"trigger_cexpr_autocmd(int cmdidx)\n{\n    char_u\t*au_name = cexpr_get_auname(cmdidx);\n\n    if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,\n\t\t\t\t\t       curbuf->b_fname, TRUE, curbuf))\n    {\n\tif (aborting())\n\t    return FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":230631,"func":"  const PBMotion& get_mv_info(int x,int y) const override { return img->get_mv_info(x,y); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":308167,"func":"static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,\n\t\t\t\t unsigned long arg)\n{\n\tstruct fastrpc_user *fl = (struct fastrpc_user *)file->private_data;\n\tchar __user *argp = (char __user *)arg;\n\tint err;\n\n\tswitch (cmd) {\n\tcase FASTRPC_IOCTL_INVOKE:\n\t\terr = fastrpc_invoke(fl, argp);\n\t\tbreak;\n\tcase FASTRPC_IOCTL_INIT_ATTACH:\n\t\terr = fastrpc_init_attach(fl);\n\t\tbreak;\n\tcase FASTRPC_IOCTL_INIT_CREATE:\n\t\terr = fastrpc_init_create_process(fl, argp);\n\t\tbreak;\n\tcase FASTRPC_IOCTL_ALLOC_DMA_BUFF:\n\t\terr = fastrpc_dmabuf_alloc(fl, argp);\n\t\tbreak;\n\tdefault:\n\t\terr = -ENOTTY;\n\t\tbreak;\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":312511,"func":"qf_open_new_file_win(qf_info_T *ll_ref)\n{\n    int\t\tflags;\n\n    flags = WSP_ABOVE;\n    if (ll_ref != NULL)\n\tflags |= WSP_NEWLOC;\n    if (win_split(0, flags) == FAIL)\n\treturn FAIL;\t\t\/\/ not enough room for window\n    p_swb = empty_option;\t\/\/ don't split again\n    swb_flags = 0;\n    RESET_BINDING(curwin);\n    if (ll_ref != NULL)\n\t\/\/ The new window should use the location list from the\n\t\/\/ location list window\n\twin_set_loclist(curwin, ll_ref);\n    return OK;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":273067,"func":"quality_is_equal(struct media_quality *a, struct media_quality *b)\n{\n  return (a->sample_rate == b->sample_rate && a->bits_per_sample == b->bits_per_sample && a->channels == b->channels && a->bit_rate == b->bit_rate);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":195399,"func":"bool IsIdentityConsumingSwitch(const MutableGraphView& graph,\n                               const NodeDef& node) {\n  if ((IsIdentity(node) || IsIdentityNSingleInput(node)) &&\n      node.input_size() > 0) {\n    TensorId tensor_id = ParseTensorName(node.input(0));\n    if (IsTensorIdControlling(tensor_id)) {\n      return false;\n    }\n\n    NodeDef* input_node = graph.GetNode(tensor_id.node());\n    return IsSwitch(*input_node);\n  }\n  return false;\n}","target":1,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":466165,"func":"static int decode_imm(struct x86_emulate_ctxt *ctxt, struct operand *op,\n\t\t      unsigned size, bool sign_extension)\n{\n\tint rc = X86EMUL_CONTINUE;\n\n\top->type = OP_IMM;\n\top->bytes = size;\n\top->addr.mem.ea = ctxt->_eip;\n\t\/* NB. Immediates are sign-extended as necessary. *\/\n\tswitch (op->bytes) {\n\tcase 1:\n\t\top->val = insn_fetch(s8, ctxt);\n\t\tbreak;\n\tcase 2:\n\t\top->val = insn_fetch(s16, ctxt);\n\t\tbreak;\n\tcase 4:\n\t\top->val = insn_fetch(s32, ctxt);\n\t\tbreak;\n\t}\n\tif (!sign_extension) {\n\t\tswitch (op->bytes) {\n\t\tcase 1:\n\t\t\top->val &= 0xff;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\top->val &= 0xffff;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\top->val &= 0xffffffff;\n\t\t\tbreak;\n\t\t}\n\t}\ndone:\n\treturn rc;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":294569,"func":"m_mon(union DateData *x)\n{\n    if (simple_dat_p(x)) {\n\tget_s_civil(x);\n#ifndef USE_PACK\n\treturn x->s.mon;\n#else\n\treturn EX_MON(x->s.pc);\n#endif\n    }\n    else {\n\tget_c_civil(x);\n#ifndef USE_PACK\n\treturn x->c.mon;\n#else\n\treturn EX_MON(x->c.pc);\n#endif\n    }\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":463120,"func":"static void annotation_get_partition(annotate_state_t *state,\n                                     struct annotate_entry_list *entry)\n{\n    struct buf value = BUF_INITIALIZER;\n    int r;\n\n    assert(state);\n    assert(state->which == ANNOTATION_SCOPE_MAILBOX);\n    r = annotate_state_need_mbentry(state);\n    assert(r == 0);\n\n    \/* Make sure its a local mailbox *\/\n    if (state->mbentry->server) goto out;\n\n    \/* Check ACL *\/\n    if (!state->isadmin &&\n        (!state->mbentry->acl ||\n         !(cyrus_acl_myrights(state->auth_state, state->mbentry->acl) & ACL_LOOKUP)))\n        goto out;\n\n    buf_appendcstr(&value, state->mbentry->partition);\n\n    output_entryatt(state, entry->name, \"\", &value);\nout:\n    buf_free(&value);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":443700,"func":"is_valid_mbc_string(const UChar* s, const UChar* end)\n{\n  return onigenc_length_check_is_valid_mbc_string(ONIG_ENCODING_UTF32_LE, s, end);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":459203,"func":"tcf_chain0_head_change_cb_del(struct tcf_block *block,\n\t\t\t      struct tcf_block_ext_info *ei)\n{\n\tstruct tcf_filter_chain_list_item *item;\n\n\tmutex_lock(&block->lock);\n\tlist_for_each_entry(item, &block->chain0.filter_chain_list, list) {\n\t\tif ((!ei->chain_head_change && !ei->chain_head_change_priv) ||\n\t\t    (item->chain_head_change == ei->chain_head_change &&\n\t\t     item->chain_head_change_priv == ei->chain_head_change_priv)) {\n\t\t\tif (block->chain0.chain)\n\t\t\t\ttcf_chain_head_change_item(item, NULL);\n\t\t\tlist_del(&item->list);\n\t\t\tmutex_unlock(&block->lock);\n\n\t\t\tkfree(item);\n\t\t\treturn;\n\t\t}\n\t}\n\tmutex_unlock(&block->lock);\n\tWARN_ON(1);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":234859,"func":"static u64 btrfs_dev_stats_value(const struct extent_buffer *eb,\n\t\t\t\t const struct btrfs_dev_stats_item *ptr,\n\t\t\t\t int index)\n{\n\tu64 val;\n\n\tread_extent_buffer(eb, &val,\n\t\t\t   offsetof(struct btrfs_dev_stats_item, values) +\n\t\t\t    ((unsigned long)ptr) + (index * sizeof(u64)),\n\t\t\t   sizeof(val));\n\treturn val;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":230311,"func":"njs_is_concat_spreadable(njs_vm_t *vm, njs_value_t *value)\n{\n    njs_int_t    ret;\n    njs_value_t  retval;\n\n    static const njs_value_t  key =\n                         njs_wellknown_symbol(NJS_SYMBOL_IS_CONCAT_SPREADABLE);\n\n    if (njs_slow_path(!njs_is_object(value))) {\n        return NJS_DECLINED;\n    }\n\n    ret = njs_value_property(vm, value, njs_value_arg(&key), &retval);\n    if (njs_slow_path(ret == NJS_ERROR)) {\n        return NJS_ERROR;\n    }\n\n    if (njs_is_defined(&retval)) {\n        return njs_bool(&retval) ? NJS_OK : NJS_DECLINED;\n    }\n\n    return njs_is_array(value) ? NJS_OK : NJS_DECLINED;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":247092,"func":"void gf_filter_get_session_caps(GF_Filter *filter, GF_FilterSessionCaps *caps)\n{\n\tif (caps) {\n\t\tif (filter) {\n\t\t\t(*caps) = filter->session->caps;\n\t\t} else {\n\t\t\tmemset(caps, 0, sizeof(GF_FilterSessionCaps));\n\t\t}\n\t}\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":232926,"func":"static CURLcode client_init_writer(struct Curl_easy *data,\n                                   struct contenc_writer *writer)\n{\n  (void) data;\n  return writer->downstream? CURLE_WRITE_ERROR: CURLE_OK;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":229352,"func":"const string& DeviceNameOrUnspecified(Device* device) {\n  static string* unspecified_string = new string(\"<unspecified>\");\n  return (device == nullptr) ? *unspecified_string : device->name();\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":513115,"func":"static int check_func_long(THD *thd, struct st_mysql_sys_var *var,\n                          void *save, st_mysql_value *value)\n{\n  my_bool fixed1, fixed2;\n  long long orig, val;\n  struct my_option options;\n  value->val_int(value, &orig);\n  val= orig;\n  plugin_opt_set_limits(&options, var);\n\n  if (var->flags & PLUGIN_VAR_UNSIGNED)\n  {\n    if ((fixed1= (!value->is_unsigned(value) && val < 0)))\n      val=0;\n    *(ulong *)save= (ulong) getopt_ull_limit_value((ulonglong) val, &options,\n                                                   &fixed2);\n  }\n  else\n  {\n    if ((fixed1= (value->is_unsigned(value) && val < 0)))\n      val=LONGLONG_MAX;\n    *(long *)save= (long) getopt_ll_limit_value(val, &options, &fixed2);\n  }\n\n  return throw_bounds_warning(thd, var->name, fixed1 || fixed2,\n                              value->is_unsigned(value), (longlong) orig);\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":238594,"func":"static void convert_pseudo_ld_imm64(struct bpf_verifier_env *env)\n{\n\tstruct bpf_insn *insn = env->prog->insnsi;\n\tint insn_cnt = env->prog->len;\n\tint i;\n\n\tfor (i = 0; i < insn_cnt; i++, insn++) {\n\t\tif (insn->code != (BPF_LD | BPF_IMM | BPF_DW))\n\t\t\tcontinue;\n\t\tif (insn->src_reg == BPF_PSEUDO_FUNC)\n\t\t\tcontinue;\n\t\tinsn->src_reg = 0;\n\t}\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":294650,"func":"d_lite_ld(VALUE self)\n{\n    get_d1(self);\n    return f_sub(m_real_local_jd(dat), INT2FIX(2299160));\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":252354,"func":"static int hufCompress(const unsigned short raw[], int nRaw,\n                       char compressed[]) {\n  if (nRaw == 0) return 0;\n\n  std::vector<long long> freq(HUF_ENCSIZE);\n\n  countFrequencies(freq, raw, nRaw);\n\n  int im = 0;\n  int iM = 0;\n  hufBuildEncTable(freq.data(), &im, &iM);\n\n  char *tableStart = compressed + 20;\n  char *tableEnd = tableStart;\n  hufPackEncTable(freq.data(), im, iM, &tableEnd);\n  int tableLength = tableEnd - tableStart;\n\n  char *dataStart = tableEnd;\n  int nBits = hufEncode(freq.data(), raw, nRaw, iM, dataStart);\n  int data_length = (nBits + 7) \/ 8;\n\n  writeUInt(compressed, im);\n  writeUInt(compressed + 4, iM);\n  writeUInt(compressed + 8, tableLength);\n  writeUInt(compressed + 12, nBits);\n  writeUInt(compressed + 16, 0);  \/\/ room for future extensions\n\n  return dataStart + data_length - compressed;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":275975,"func":"unsigned uECC_curve_num_n_bytes(uECC_Curve curve) {\n    return BITS_TO_BYTES(curve->num_n_bits);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":221395,"func":"static int nested_svm_exit_handled_msr(struct vcpu_svm *svm)\n{\n\tu32 offset, msr, value;\n\tint write, mask;\n\n\tif (!(vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))\n\t\treturn NESTED_EXIT_HOST;\n\n\tmsr    = svm->vcpu.arch.regs[VCPU_REGS_RCX];\n\toffset = svm_msrpm_offset(msr);\n\twrite  = svm->vmcb->control.exit_info_1 & 1;\n\tmask   = 1 << ((2 * (msr & 0xf)) + write);\n\n\tif (offset == MSR_INVALID)\n\t\treturn NESTED_EXIT_DONE;\n\n\t\/* Offset is in 32 bit units but need in 8 bit units *\/\n\toffset *= 4;\n\n\tif (kvm_vcpu_read_guest(&svm->vcpu, svm->nested.ctl.msrpm_base_pa + offset, &value, 4))\n\t\treturn NESTED_EXIT_DONE;\n\n\treturn (value & mask) ? NESTED_EXIT_DONE : NESTED_EXIT_HOST;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":411798,"func":"on_sigterm_pipe (GIOChannel  *channel,\n                 GIOCondition condition,\n                 gpointer     data)\n{\n  A11yBusLauncher *app = data;\n  \n  g_main_loop_quit (app->loop);\n\n  return FALSE;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":387759,"func":"int InstanceKlass::mark_dependent_nmethods(KlassDepChange& changes) {\n  return dependencies().mark_dependent_nmethods(changes);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":274880,"func":"TEST(ComparisonsTest, GreaterInt) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 4}, TensorType_INT32,\n                          BuiltinOperator_GREATER);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3});\n  model.PopulateTensor<int>(model.input2(), {1, 2, 7, 5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, false, false));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":259161,"func":"static inline int mov_stsc_index_valid(unsigned int index, unsigned int count)\n{\n    return index < count - 1;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":244340,"func":"GF_Err pdin_box_size(GF_Box *s)\n{\n\tGF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox *)s;\n\tptr->size += 8*ptr->count;\n\treturn GF_OK;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":336515,"func":"static inline void openssl_global_init(void)\n{\n}","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":220208,"func":"Node::Node()\n    : id_(-1),\n      cost_id_(-1),\n      class_(NC_UNINITIALIZED),\n      props_(nullptr),\n      assigned_device_name_index_(0),\n      while_ctx_(nullptr) {}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":328897,"func":"R_API char *r_bin_java_get_desc_from_cp_item_list(RList *cp_list, ut64 idx) {\n\t\/*\n\tGiven a constant pool object FieldRef, MethodRef, or InterfaceMethodRef\n\treturn the actual descriptor string.\n\t@rvalue ut8* (user frees) or NULL\n\t*\/\n\tRBinJavaCPTypeObj *obj = r_bin_java_get_item_from_cp_item_list (cp_list, idx);\n\tif (!cp_list) {\n\t\treturn NULL;\n\t}\n\treturn r_bin_java_get_item_desc_from_cp_item_list (cp_list, obj, MAX_CPITEMS);\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":498116,"func":"const char *cgit_httpscheme(void)\n{\n\tif (ctx.env.https && !strcmp(ctx.env.https, \"on\"))\n\t\treturn \"https:\/\/\";\n\telse\n\t\treturn \"http:\/\/\";\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":317252,"func":"static int selinux_mmap_addr(unsigned long addr)\n{\n\tint rc = 0;\n\n\tif (addr < CONFIG_LSM_MMAP_MIN_ADDR) {\n\t\tu32 sid = current_sid();\n\t\trc = avc_has_perm(&selinux_state,\n\t\t\t\t  sid, sid, SECCLASS_MEMPROTECT,\n\t\t\t\t  MEMPROTECT__MMAP_ZERO, NULL);\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":310093,"func":"putp(const char *string)\n{\n    return (tputs(string, 1, _nc_outch));\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":242935,"func":"void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform )\n{\n    if( transform == NULL )\n        return;\n\n#if defined(MBEDTLS_ZLIB_SUPPORT)\n    deflateEnd( &transform->ctx_deflate );\n    inflateEnd( &transform->ctx_inflate );\n#endif\n\n    mbedtls_cipher_free( &transform->cipher_ctx_enc );\n    mbedtls_cipher_free( &transform->cipher_ctx_dec );\n\n#if defined(MBEDTLS_SSL_SOME_MODES_USE_MAC)\n    mbedtls_md_free( &transform->md_ctx_enc );\n    mbedtls_md_free( &transform->md_ctx_dec );\n#endif\n\n    mbedtls_platform_zeroize( transform, sizeof( mbedtls_ssl_transform ) );\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":317233,"func":"static int __inode_security_revalidate(struct inode *inode,\n\t\t\t\t       struct dentry *dentry,\n\t\t\t\t       bool may_sleep)\n{\n\tstruct inode_security_struct *isec = selinux_inode(inode);\n\n\tmight_sleep_if(may_sleep);\n\n\tif (selinux_initialized(&selinux_state) &&\n\t    isec->initialized != LABEL_INITIALIZED) {\n\t\tif (!may_sleep)\n\t\t\treturn -ECHILD;\n\n\t\t\/*\n\t\t * Try reloading the inode security label.  This will fail if\n\t\t * @opt_dentry is NULL and no dentry for this inode can be\n\t\t * found; in that case, continue using the old label.\n\t\t *\/\n\t\tinode_doinit_with_dentry(inode, dentry);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":361750,"func":"int em28xx_tuner_callback(void *ptr, int component, int command, int arg)\n{\n\tstruct em28xx_i2c_bus *i2c_bus = ptr;\n\tstruct em28xx *dev = i2c_bus->dev;\n\tint rc = 0;\n\n\tif (dev->tuner_type != TUNER_XC2028 && dev->tuner_type != TUNER_XC5000)\n\t\treturn 0;\n\n\tif (command != XC2028_TUNER_RESET && command != XC5000_TUNER_RESET)\n\t\treturn 0;\n\n\trc = em28xx_gpio_set(dev, dev->board.tuner_gpio);\n\n\treturn rc;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":336683,"func":"SPICE_GNUC_VISIBLE void spice_server_set_seamless_migration(SpiceServer *reds, int enable)\n{\n    \/* seamless migration is not supported with multiple clients *\/\n    reds->seamless_migration_enabled = enable && !reds->allow_multiple_clients;\n    spice_debug(\"seamless migration enabled=%d\", enable);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":254887,"func":"StringMap<boost::intrusive_ptr<Expression>> DocumentSourceGroup::getIdFields() const {\n    if (_idFieldNames.empty()) {\n        invariant(_idExpressions.size() == 1);\n        return {{\"_id\", _idExpressions[0]}};\n    } else {\n        invariant(_idFieldNames.size() == _idExpressions.size());\n        StringMap<boost::intrusive_ptr<Expression>> result;\n        for (std::size_t i = 0; i < _idFieldNames.size(); ++i) {\n            result[\"_id.\" + _idFieldNames[i]] = _idExpressions[i];\n        }\n        return result;\n    }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":225810,"func":"void gen_sample_entry_box_del(GF_Box *s)\n{\n\tGF_SampleEntryBox *ptr = (GF_SampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\tgf_free(ptr);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":424534,"func":"static const char* video_command_name(BYTE cmd)\n{\n\tswitch (cmd)\n\t{\n\t\tcase TSMM_START_PRESENTATION:\n\t\t\treturn \"start\";\n\t\tcase TSMM_STOP_PRESENTATION:\n\t\t\treturn \"stop\";\n\t\tdefault:\n\t\t\treturn \"<unknown>\";\n\t}\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":242609,"func":"  void Compute(OpKernelContext* ctx) override {\n    Buffer* buf = nullptr;\n    OP_REQUIRES_OK(ctx, GetBuffer(ctx, def(), &buf));\n    core::ScopedUnref scope(buf);\n    Buffer::Tuple tuple;\n    tuple.reserve(ctx->num_inputs());\n    for (int i = 0; i < ctx->num_inputs(); ++i) {\n      tuple.push_back(ctx->input(i));\n    }\n    OP_REQUIRES_OK(ctx, buf->Put(&tuple));\n  }","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":437712,"func":"static inline u16 ns_to_lpf_count(unsigned int ns)\n{\n\treturn count_to_lpf_count(\n\t\tDIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ \/ 1000000 * ns, 1000));\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":312493,"func":"win_set_loclist(win_T *wp, qf_info_T *qi)\n{\n    wp->w_llist = qi;\n    qi->qf_refcount++;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":317098,"func":"static int selinux_task_setpgid(struct task_struct *p, pid_t pgid)\n{\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    current_sid(), task_sid_obj(p), SECCLASS_PROCESS,\n\t\t\t    PROCESS__SETPGID, NULL);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":261925,"func":"njs_string_split_part_add(njs_vm_t *vm, njs_array_t *array, njs_utf8_t utf8,\n    const u_char *start, size_t size)\n{\n    ssize_t  length;\n\n    length = njs_string_calc_length(utf8, start, size);\n\n    return njs_array_string_add(vm, array, start, size, length);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":309873,"func":"default_fg(NCURSES_SP_DCL0)\n{\n    return (SP_PARM != 0) ? SP_PARM->_default_fg : COLOR_WHITE;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":421372,"func":"static void pvar(int d, js_Ast *var)\n{\n\tassert(var->type == EXP_VAR);\n\tpexp(d, var->a);\n\tif (var->b) {\n\t\tsp(); pc('='); sp();\n\t\tpexp(d, var->b);\n\t}\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":221477,"func":"add_dconf_key_to_keyfile (GKeyFile      *keyfile,\n                          DConfClient   *client,\n                          const char    *key,\n                          DConfReadFlags flags)\n{\n  g_autofree char *group = g_path_get_dirname (key);\n  g_autofree char *k = g_path_get_basename (key);\n  GVariant *value = dconf_client_read_full (client, key, flags, NULL);\n\n  if (value)\n    {\n      g_autofree char *val = g_variant_print (value, TRUE);\n      g_key_file_set_value (keyfile, group + 1, k, val);\n    }\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":224168,"func":"  std::size_t operator()(const Tensor& key) const {\n    return std::hash<int64_t>{}(key.scalar<int64_t>()());\n  }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":443707,"func":"utf16be_mbc_case_fold(OnigCaseFoldType flag,\n\t\t      const UChar** pp, const UChar* end, UChar* fold)\n{\n  const UChar* p = *pp;\n\n  if (ONIGENC_IS_ASCII_CODE(*(p+1)) && *p == 0) {\n    p++;\n#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI\n    if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {\n      if (*p == 0x49) {\n        *fold++ = 0x01;\n        *fold   = 0x31;\n        (*pp) += 2;\n        return 2;\n      }\n    }\n#endif\n\n    *fold++ = 0;\n    *fold   = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);\n    *pp += 2;\n    return 2;\n  }\n  else\n    return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF16_BE, flag,\n\t\t\t\t\t pp, end, fold);\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":445889,"func":"archive_extraction_ready_for_convertion_cb (GObject      *source_object,\n\t\t\t\t\t    GAsyncResult *result,\n\t\t\t\t\t    gpointer      user_data)\n{\n\tConvertData *cdata = user_data;\n\tFrWindow    *window = cdata->window;\n\tGList       *list;\n\tGError      *error = NULL;\n\n\tif (! fr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error)) {\n\t\t_convertion_completed_with_error (window, FR_ACTION_EXTRACTING_FILES, error);\n\t\treturn;\n\t}\n\n\tlist = g_list_prepend (NULL, cdata->temp_extraction_dir);\n\tfr_archive_add_files (cdata->new_archive,\n\t\t\t      list,\n\t\t\t      cdata->temp_extraction_dir,\n\t\t\t      NULL,\n\t\t\t      FALSE,\n\t\t\t      FALSE,\n\t\t\t      cdata->password,\n\t\t\t      cdata->encrypt_header,\n\t\t\t      window->priv->compression,\n\t\t\t      cdata->volume_size,\n\t\t\t      window->priv->cancellable,\n\t\t\t      archive_add_ready_for_conversion_cb,\n\t\t\t      cdata);\n\n\tg_list_free (list);\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":317027,"func":"static int selinux_socket_unix_may_send(struct socket *sock,\n\t\t\t\t\tstruct socket *other)\n{\n\tstruct sk_security_struct *ssec = sock->sk->sk_security;\n\tstruct sk_security_struct *osec = other->sk->sk_security;\n\tstruct common_audit_data ad;\n\tstruct lsm_network_audit net = {0,};\n\n\tad.type = LSM_AUDIT_DATA_NET;\n\tad.u.net = &net;\n\tad.u.net->sk = other->sk;\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    ssec->sid, osec->sid, osec->sclass, SOCKET__SENDTO,\n\t\t\t    &ad);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":352942,"func":"utcTimeValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tint parts[9];\n\treturn check_time_syntax(in, 1, parts, NULL);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":310138,"func":"_nc_mouse_resume(SCREEN *sp)\n\/* re-connect to mouse -- called by doupdate() after shellout *\/\n{\n    TR(MY_TRACE, (\"_nc_mouse_resume() called\"));\n\n    switch (sp->_mouse_type) {\n    case M_XTERM:\n\t\/* xterm: re-enable reporting *\/\n\tif (sp->_mouse_mask)\n\t    mouse_activate(sp, TRUE);\n\tbreak;\n\n#if USE_GPM_SUPPORT\n    case M_GPM:\n\t\/* GPM: reclaim our event set *\/\n\tif (sp->_mouse_mask)\n\t    mouse_activate(sp, TRUE);\n\tbreak;\n#endif\n\n#if USE_SYSMOUSE\n    case M_SYSMOUSE:\n\tmouse_activate(sp, TRUE);\n\tbreak;\n#endif\n\n#ifdef USE_TERM_DRIVER\n    case M_TERM_DRIVER:\n\tmouse_activate(sp, TRUE);\n\tbreak;\n#endif\n\n    case M_NONE:\n\tbreak;\n    }\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":445957,"func":"fr_archive_libarchive_init (FrArchiveLibarchive *self)\n{\n\tFrArchive *base = FR_ARCHIVE (self);\n\n\tself->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FR_TYPE_ARCHIVE_LIBARCHIVE, FrArchiveLibarchivePrivate);\n\n\tbase->propAddCanReplace = TRUE;\n\tbase->propAddCanUpdate = TRUE;\n\tbase->propAddCanStoreFolders = TRUE;\n\tbase->propAddCanStoreLinks = TRUE;\n\tbase->propExtractCanAvoidOverwrite = TRUE;\n\tbase->propExtractCanSkipOlder = TRUE;\n\tbase->propExtractCanJunkPaths = TRUE;\n\tbase->propCanExtractAll = TRUE;\n\tbase->propCanDeleteNonEmptyFolders = TRUE;\n\tbase->propCanExtractNonEmptyFolders = TRUE;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":225934,"func":"void payt_box_del(GF_Box *s)\n{\n\tGF_PAYTBox *payt = (GF_PAYTBox *)s;\n\tif (payt->payloadString) gf_free(payt->payloadString);\n\tgf_free(payt);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":432326,"func":"static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)\n{\n    \/*\n     * There may not be a virtual to physical translation for the pc\n     * right now, but there may exist cached TB for this pc.\n     * Flush the whole TB cache to force re-translation of such TBs.\n     * This is heavyweight, but we're debugging anyway.\n     *\/\n    tb_flush(cpu);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":195768,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Only create one, if one does not exist already. Report status for all\n    \/\/ other exceptions. If one already exists, it unrefs the new one.\n    \/\/ An epsilon value of zero could cause performance issues and is therefore,\n    \/\/ disallowed.\n    const Tensor* epsilon_t;\n    OP_REQUIRES_OK(context, context->input(kEpsilonName, &epsilon_t));\n    float epsilon = epsilon_t->scalar<float>()();\n    OP_REQUIRES(\n        context, epsilon > 0,\n        errors::InvalidArgument(\"An epsilon value of zero is not allowed.\"));\n\n    const Tensor* num_streams_t;\n    OP_REQUIRES_OK(context, context->input(kNumStreamsName, &num_streams_t));\n    int64_t num_streams = num_streams_t->scalar<int64>()();\n\n    auto result =\n        new QuantileStreamResource(epsilon, max_elements_, num_streams);\n    auto status = CreateResource(context, HandleFromInput(context, 0), result);\n    if (!status.ok() && status.code() != tensorflow::error::ALREADY_EXISTS) {\n      OP_REQUIRES(context, false, status);\n    }\n  }","target":1,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":349274,"func":"static void read_fragment(unsigned int fragment, long long *start_block, int *size)\n{\n\tTRACE(\"read_fragment: reading fragment %d\\n\", fragment);\n\n\tstruct squashfs_fragment_entry *fragment_entry;\n\n\tfragment_entry = &fragment_table[fragment];\n\t*start_block = fragment_entry->start_block;\n\t*size = fragment_entry->size;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":225082,"func":"defaultNoticeReceiver(void *arg, const PGresult *res)\n{\n\t(void) arg;\t\t\t\t\t\/* not used *\/\n\tif (res->noticeHooks.noticeProc != NULL)\n\t\tres->noticeHooks.noticeProc(res->noticeHooks.noticeProcArg,\n\t\t\t\t\t\t\t\t\tPQresultErrorMessage(res));\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":210555,"func":"vhost_backend_cleanup(struct virtio_net *dev)\n{\n\tif (dev->mem) {\n\t\tfree_mem_region(dev);\n\t\trte_free(dev->mem);\n\t\tdev->mem = NULL;\n\t}\n\n\tfree(dev->guest_pages);\n\tdev->guest_pages = NULL;\n\n\tif (dev->log_addr) {\n\t\tmunmap((void *)(uintptr_t)dev->log_addr, dev->log_size);\n\t\tdev->log_addr = 0;\n\t}\n\n\tif (dev->slave_req_fd >= 0) {\n\t\tclose(dev->slave_req_fd);\n\t\tdev->slave_req_fd = -1;\n\t}\n\n\tif (dev->postcopy_ufd >= 0) {\n\t\tclose(dev->postcopy_ufd);\n\t\tdev->postcopy_ufd = -1;\n\t}\n\n\tdev->postcopy_listening = 0;\n}","target":1,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":219007,"func":"bool ConstantFolding::ReplaceReductionWithIdentity(NodeDef* node) const {\n  \/\/ Replace the reduction node with an identity node, that can be further\n  \/\/ optimized by other passes.\n  DataType output_type;\n  if (node->attr().count(\"T\") != 0) {\n    output_type = node->attr().at(\"T\").type();\n  } else if (IsAny(*node) || IsAll(*node)) {\n    output_type = DT_BOOL;\n  } else {\n    return false;\n  }\n  node->set_op(\"Identity\");\n  EraseRegularNodeAttributes(node);\n  (*node->mutable_attr())[\"T\"].set_type(output_type);\n  *node->mutable_input(1) = AsControlDependency(node->input(1));\n  return true;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":233941,"func":"DepsTracker::State DocumentSourceUnionWith::getDependencies(DepsTracker* deps) const {\n    \/\/ Since the $unionWith stage is a simple passthrough, we *could* report SEE_NEXT here in an\n    \/\/ attempt to get a covered plan for the base collection. The ideal solution would involve\n    \/\/ pushing down any dependencies to the inner pipeline as well.\n    return DepsTracker::State::NOT_SUPPORTED;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":237891,"func":"lsquic_qeh_cleanup (struct qpack_enc_hdl *qeh)\n{\n    if (qeh->qeh_flags & QEH_INITIALIZED)\n    {\n        LSQ_DEBUG(\"cleanup\");\n        if (qeh->qeh_exp_rec)\n            qeh_log_and_clean_exp_rec(qeh);\n        lsqpack_enc_cleanup(&qeh->qeh_encoder);\n        lsquic_frab_list_cleanup(&qeh->qeh_fral);\n        memset(qeh, 0, sizeof(*qeh));\n    }\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":345141,"func":"static void pxa3xx_gcu_init_debug_timer(struct pxa3xx_gcu_priv *priv)\n{\n\t\/* init the timer structure *\/\n\tdebug_timer_priv = priv;\n\ttimer_setup(&pxa3xx_gcu_debug_timer, pxa3xx_gcu_debug_timedout, 0);\n\tpxa3xx_gcu_debug_timedout(NULL);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":227007,"func":"irc_protocol_nick_address (struct t_irc_server *server,\n                           int server_message,\n                           struct t_irc_nick *nick,\n                           const char *nickname,\n                           const char *address)\n{\n    static char string[1024];\n\n    string[0] = '\\0';\n\n    if (nickname && address && (strcmp (nickname, address) != 0))\n    {\n        \/* display nick and address if they are different *\/\n        snprintf (string, sizeof (string),\n                  \"%s%s %s(%s%s%s)%s\",\n                  irc_nick_color_for_msg (server, server_message, nick,\n                                          nickname),\n                  nickname,\n                  IRC_COLOR_CHAT_DELIMITERS,\n                  IRC_COLOR_CHAT_HOST,\n                  address,\n                  IRC_COLOR_CHAT_DELIMITERS,\n                  IRC_COLOR_RESET);\n    }\n    else if (nickname)\n    {\n        \/* display only nick if no address or if nick == address *\/\n        snprintf (string, sizeof (string),\n                  \"%s%s%s\",\n                  irc_nick_color_for_msg (server, server_message, nick,\n                                          nickname),\n                  nickname,\n                  IRC_COLOR_RESET);\n    }\n\n    return string;\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":459167,"func":"static void tcf_proto_signal_destroying(struct tcf_chain *chain,\n\t\t\t\t\tstruct tcf_proto *tp)\n{\n\tstruct tcf_block *block = chain->block;\n\n\tmutex_lock(&block->proto_destroy_lock);\n\thash_add_rcu(block->proto_destroy_ht, &tp->destroy_ht_node,\n\t\t     destroy_obj_hashfn(tp));\n\tmutex_unlock(&block->proto_destroy_lock);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":512927,"func":"  Item_cache_timestamp(THD *thd)\n   :Item_cache(thd, &type_handler_timestamp2) { }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":386604,"func":"void DL_Dxf::addBlock(DL_CreationInterface* creationInterface) {\n    std::string name = getStringValue(2, \"\");\n    if (name.length()==0) {\n        return;\n    }\n\n    DL_BlockData d(\n        \/\/ Name:\n        name,\n        \/\/ flags:\n        getIntValue(70, 0),\n        \/\/ base point:\n        getRealValue(10, 0.0),\n        getRealValue(20, 0.0),\n        getRealValue(30, 0.0));\n\n    creationInterface->addBlock(d);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":273096,"func":"two_str_hash(const char *a, const char *b)\n{\n  char hashbuf[2048];\n  int64_t hash;\n  int i;\n  int ret;\n\n  ret = snprintf(hashbuf, sizeof(hashbuf), \"%s==%s\", (a) ? a : \"\", (b) ? b : \"\");\n  if (ret < 0 || ret == sizeof(hashbuf))\n    {\n      DPRINTF(E_LOG, L_MISC, \"Buffer too large to calculate hash: '%s==%s'\\n\", a, b);\n      return 999999; \/\/ Stand-in hash...\n    }\n\n  for (i = 0; hashbuf[i]; i++)\n    hashbuf[i] = tolower(hashbuf[i]);\n\n  \/\/ Limit hash length to 63 bits, due to signed type in sqlite\n  hash = murmur_hash64(hashbuf, strlen(hashbuf), 0) >> 1;\n\n  return hash;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":225764,"func":"GF_Err cprt_box_size(GF_Box *s)\n{\n\tGF_CopyrightBox *ptr = (GF_CopyrightBox *)s;\n\n\tptr->size += 2;\n\tif (ptr->notice)\n\t\tptr->size += strlen(ptr->notice) + 1;\n\treturn GF_OK;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":259209,"func":"static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    while (atom.size > 8) {\n        uint32_t tag;\n        if (avio_feof(pb))\n            return AVERROR_EOF;\n        tag = avio_rl32(pb);\n        atom.size -= 4;\n        if (tag == MKTAG('h','d','l','r')) {\n            int ret;\n            avio_seek(pb, -8, SEEK_CUR);\n            atom.size += 8;\n            if ((ret = mov_read_default(c, pb, atom)) < 0)\n                return ret;\n            if (c->is_still_picture_avif) {\n                int ret;\n                \/\/ Add a stream for the YUV planes (primary item).\n                if ((ret = avif_add_stream(c, c->primary_item_id)) < 0)\n                    return ret;\n                \/\/ For still AVIF images, the meta box contains all the\n                \/\/ necessary information that would generally be provided by the\n                \/\/ moov box. So simply mark that we have found the moov box so\n                \/\/ that parsing can continue.\n                c->found_moov = 1;\n            }\n            return ret;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":416357,"func":"finish_incsearch_highlighting(\n\tint gotesc,\n\tincsearch_state_T *is_state,\n\tint call_update_screen)\n{\n    if (is_state->did_incsearch)\n    {\n\tis_state->did_incsearch = FALSE;\n\tif (gotesc)\n\t    curwin->w_cursor = is_state->save_cursor;\n\telse\n\t{\n\t    if (!EQUAL_POS(is_state->save_cursor, is_state->search_start))\n\t    {\n\t\t\/\/ put the '\" mark at the original position\n\t\tcurwin->w_cursor = is_state->save_cursor;\n\t\tsetpcmark();\n\t    }\n\t    curwin->w_cursor = is_state->search_start;\n\t}\n\trestore_viewstate(&is_state->old_viewstate);\n\thighlight_match = FALSE;\n\n\t\/\/ by default search all lines\n\tsearch_first_line = 0;\n\tsearch_last_line = MAXLNUM;\n\n\tmagic_overruled = is_state->magic_overruled_save;\n\n\tvalidate_cursor();\t\/\/ needed for TAB\n\tredraw_all_later(UPD_SOME_VALID);\n\tif (call_update_screen)\n\t    update_screen(UPD_SOME_VALID);\n    }\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":269310,"func":"static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){\n    int i;\n    int r= log2>=0 ? 1<<log2 : 1;\n    int v=0;\n\n    av_assert2(log2>=-4);\n\n    while(log2<28 && get_rac(c, state+4+log2)){\n        v+= r;\n        log2++;\n        if(log2>0) r+=r;\n    }\n\n    for(i=log2-1; i>=0; i--){\n        v+= get_rac(c, state+31-i)<<i;\n    }\n\n    return v;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":389689,"func":"check_for_opt_buffer_arg(typval_T *args, int idx)\n{\n    return (args[idx].v_type == VAR_UNKNOWN\n\t    || check_for_buffer_arg(args, idx));\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":432273,"func":"static void flatview_destroy(FlatView *view)\n{\n    if (view->dispatch) {\n        address_space_dispatch_free(view->dispatch);\n    }\n    g_free(view->ranges);\n    g_free(view);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":230380,"func":"static pj_xml_attr *alloc_attr( pj_pool_t *pool )\n{\n    return PJ_POOL_ZALLOC_T(pool, pj_xml_attr);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":225971,"func":"\nGF_Err ihdr_box_size(GF_Box *s)\n{\n\ts->size += 14;\n\treturn GF_OK;","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":513124,"func":"static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)\n{\n  uint i;\n  struct st_plugin_int *tmp;\n  DBUG_ENTER(\"plugin_insert_or_reuse\");\n  for (i= 0; i < plugin_array.elements; i++)\n  {\n    tmp= *dynamic_element(&plugin_array, i, struct st_plugin_int **);\n    if (tmp->state == PLUGIN_IS_FREED)\n    {\n      memcpy(tmp, plugin, sizeof(struct st_plugin_int));\n      DBUG_RETURN(tmp);\n    }\n  }\n  if (insert_dynamic(&plugin_array, (uchar*)&plugin))\n    DBUG_RETURN(0);\n  tmp= *dynamic_element(&plugin_array, plugin_array.elements - 1,\n                        struct st_plugin_int **)=\n       (struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)plugin,\n                                            sizeof(struct st_plugin_int));\n  DBUG_RETURN(tmp);\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":387839,"func":"bool InstanceKlass::can_be_primary_super_slow() const {\n  if (is_interface())\n    return false;\n  else\n    return Klass::can_be_primary_super_slow();\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":359500,"func":"DEFUN (no_neighbor_ebgp_multihop,\n       no_neighbor_ebgp_multihop_cmd,\n       NO_NEIGHBOR_CMD2 \"ebgp-multihop\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Allow EBGP neighbors not on directly connected networks\\n\")\n{\n  return peer_ebgp_multihop_unset_vty (vty, argv[0]);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":411910,"func":"router_append_dirobj_signature(char *buf, size_t buf_len, const char *digest,\n                               size_t digest_len, crypto_pk_env_t *private_key)\n{\n  char *signature;\n  size_t i, keysize;\n  int siglen;\n\n  keysize = crypto_pk_keysize(private_key);\n  signature = tor_malloc(keysize);\n  siglen = crypto_pk_private_sign(private_key, signature, keysize,\n                                  digest, digest_len);\n  if (siglen < 0) {\n    log_warn(LD_BUG,\"Couldn't sign digest.\");\n    goto err;\n  }\n  if (strlcat(buf, \"-----BEGIN SIGNATURE-----\\n\", buf_len) >= buf_len)\n    goto truncated;\n\n  i = strlen(buf);\n  if (base64_encode(buf+i, buf_len-i, signature, siglen) < 0) {\n    log_warn(LD_BUG,\"couldn't base64-encode signature\");\n    goto err;\n  }\n\n  if (strlcat(buf, \"-----END SIGNATURE-----\\n\", buf_len) >= buf_len)\n    goto truncated;\n\n  tor_free(signature);\n  return 0;\n\n truncated:\n  log_warn(LD_BUG,\"tried to exceed string length.\");\n err:\n  tor_free(signature);\n  return -1;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":312438,"func":"qf_cmd_get_stack(exarg_T *eap, int print_emsg)\n{\n    qf_info_T\t*qi = &ql_info;\n\n    if (is_loclist_cmd(eap->cmdidx))\n    {\n\tqi = GET_LOC_LIST(curwin);\n\tif (qi == NULL)\n\t{\n\t    if (print_emsg)\n\t\temsg(_(e_no_location_list));\n\t    return NULL;\n\t}\n    }\n\n    return qi;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":90859,"func":"   void GetUsageAndQuota(const GURL& origin, StorageType type) {\n     quota_status_ = kQuotaStatusUnknown;\n     usage_ = -1;\n    quota_ = -1;\n    quota_manager_->GetUsageAndQuota(origin, type,\n        callback_factory_.NewCallback(\n            &QuotaManagerTest::DidGetUsageAndQuota));\n  }\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":310258,"func":"directory_set_dirty(void)\n{\n  time_t now = time(NULL);\n  int set_v1_dirty=0;\n\n  \/* Regenerate stubs only every 8 hours.\n   * XXXX It would be nice to generate less often, but these are just\n   * stubs: it doesn't matter. *\/\n#define STUB_REGENERATE_INTERVAL (8*60*60)\n  if (!the_directory || !the_runningrouters.dir)\n    set_v1_dirty = 1;\n  else if (the_directory->published < now - STUB_REGENERATE_INTERVAL ||\n           the_runningrouters.published < now - STUB_REGENERATE_INTERVAL)\n    set_v1_dirty = 1;\n\n  if (set_v1_dirty) {\n    if (!the_directory_is_dirty)\n      the_directory_is_dirty = now;\n    if (!runningrouters_is_dirty)\n      runningrouters_is_dirty = now;\n  }\n  if (!the_v2_networkstatus_is_dirty)\n    the_v2_networkstatus_is_dirty = now;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":432257,"func":"static void mmio_write_wrapper(struct uc_struct *uc, void *opaque, hwaddr addr, uint64_t data, unsigned size)\n{\n    mmio_cbs* cbs = (mmio_cbs*)opaque;\n    \n    \/\/ We have to care about 32bit target.\n    addr = addr & ( (target_ulong)(-1) );\n    if (cbs->write) {\n        cbs->write(uc, addr, size, data, cbs->user_data_write);\n    }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":473894,"func":"cp949_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)\n{\n  int firstbyte = *p++;\n  state_t s = trans[0][firstbyte];\n#define RETURN(n) \\\n    return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) : \\\n                         ONIGENC_CONSTRUCT_MBCLEN_INVALID()\n  if (s < 0) RETURN(1);\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_CP949[firstbyte]-1);\n  s = trans[s][*p++];\n  RETURN(2);\n#undef RETURN\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":244179,"func":"GF_Box *st3d_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_Stereo3DBox, GF_ISOM_BOX_TYPE_ST3D);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":257454,"func":"void AutoParallel::AddSharedNodes(GraphDef* graph) {\n  string prefix = strings::StrCat(kAutoParallelPrefix, \"-Replica-\", 0);\n  for (const auto& node : shared_nodes_) {\n    auto new_node = graph->add_node();\n    *new_node = *all_nodes_[node];\n    for (int i = 0; i < new_node->input_size(); i++) {\n      if (NotSharedNode(NodeName(new_node->input(i)))) {\n        string new_name = AddPrefixToNodeName(new_node->input(i), prefix);\n        *new_node->mutable_input(i) = new_name;\n      }\n    }\n  }\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":196621,"func":"mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym mid)\n{\n  mt_tbl *h;\n\n  MRB_CLASS_ORIGIN(c);\n  h = c->mt;\n\n  if (h && mt_del(mrb, h, mid)) return;\n  mrb_name_error(mrb, mid, \"method '%n' not defined in %C\", mid, c);\n}","target":1,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":473838,"func":"count_collision(const struct st_hash_type *type)\n{\n    collision.all++;\n    if (type == &type_numhash) {\n\tcollision.num++;\n    }\n    else if (type == &type_strhash) {\n\tcollision.strcase++;\n    }\n    else if (type == &type_strcasehash) {\n\tcollision.str++;\n    }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":252417,"func":"static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip,\n                                                     mz_zip_array *pArray,\n                                                     const void *pElements,\n                                                     size_t n) {\n  size_t orig_size = pArray->m_size;\n  if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE))\n    return MZ_FALSE;\n  memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size,\n         pElements, n * pArray->m_element_size);\n  return MZ_TRUE;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":328928,"func":"static void delete_obj(RBinJavaCPTypeObj *obj) {\n\tif (obj && obj->metas && obj->metas->type_info) {\n\t\tRBinJavaCPTypeMetas *ti = obj->metas->type_info;\n\t\tif (ti && ti->allocs && ti->allocs->delete_obj) {\n\t\t\tti->allocs->delete_obj (obj);\n\t\t}\n\t}\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":424532,"func":"static void VideoClientContextPriv_free(VideoClientContextPriv* priv)\n{\n\tEnterCriticalSection(&priv->framesLock);\n\twhile (Queue_Count(priv->frames))\n\t{\n\t\tVideoFrame* frame = Queue_Dequeue(priv->frames);\n\t\tif (frame)\n\t\t\tVideoFrame_free(&frame);\n\t}\n\n\tQueue_Free(priv->frames);\n\tLeaveCriticalSection(&priv->framesLock);\n\n\tDeleteCriticalSection(&priv->framesLock);\n\n\tif (priv->currentPresentation)\n\t\tPresentationContext_unref(priv->currentPresentation);\n\n\tBufferPool_Free(priv->surfacePool);\n\tfree(priv);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":225426,"func":"static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type type)\n{\n\tstruct v4l2_loopback_device *dev;\n\tstruct v4l2_loopback_opener *opener;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\topener = fh_to_opener(fh);\n\n\tswitch (type) {\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n\t\tif (!dev->ready_for_capture) {\n\t\t\tint ret = allocate_buffers(dev);\n\t\t\tif (ret < 0)\n\t\t\t\treturn ret;\n\t\t}\n\t\topener->type = WRITER;\n\t\tdev->ready_for_output = 0;\n\t\tdev->ready_for_capture++;\n\t\treturn 0;\n\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n\t\tif (!dev->ready_for_capture)\n\t\t\treturn -EIO;\n\t\topener->type = READER;\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":278260,"func":"tabstop_at(colnr_T col, int ts, int *vts)\n{\n    int\t\ttabcount;\n    colnr_T\ttabcol = 0;\n    int\t\tt;\n    int\t\ttab_size = 0;\n\n    if (vts == 0 || vts[0] == 0)\n\treturn ts;\n\n    tabcount = vts[0];\n    for (t = 1; t <= tabcount; ++t)\n    {\n\ttabcol += vts[t];\n\tif (tabcol > col)\n\t{\n\t    tab_size = vts[t];\n\t    break;\n\t}\n    }\n    if (t > tabcount)\n\ttab_size = vts[tabcount];\n\n    return tab_size;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":369945,"func":"static struct mm_struct *__check_mem_permission(struct task_struct *task)\n{\n\tstruct mm_struct *mm;\n\n\tmm = get_task_mm(task);\n\tif (!mm)\n\t\treturn ERR_PTR(-EINVAL);\n\n\t\/*\n\t * A task can always look at itself, in case it chooses\n\t * to use system calls instead of load instructions.\n\t *\/\n\tif (task == current)\n\t\treturn mm;\n\n\t\/*\n\t * If current is actively ptrace'ing, and would also be\n\t * permitted to freshly attach with ptrace now, permit it.\n\t *\/\n\tif (task_is_stopped_or_traced(task)) {\n\t\tint match;\n\t\trcu_read_lock();\n\t\tmatch = (ptrace_parent(task) == current);\n\t\trcu_read_unlock();\n\t\tif (match && ptrace_may_access(task, PTRACE_MODE_ATTACH))\n\t\t\treturn mm;\n\t}\n\n\t\/*\n\t * No one else is allowed.\n\t *\/\n\tmmput(mm);\n\treturn ERR_PTR(-EPERM);\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":438662,"func":"static int virtio_rpmsg_release_channel(struct rpmsg_device *rpdev,\n\t\t\t\t\tstruct rpmsg_channel_info *chinfo)\n{\n\tstruct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);\n\tstruct virtproc_info *vrp = vch->vrp;\n\n\treturn rpmsg_unregister_device(&vrp->vdev->dev, chinfo);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":255081,"func":"Eigen::VectorXd ompl::geometric::VFRRT::getNewDirection(const base::State *qnear, const base::State *qrand)\n{\n    \/\/ Set vrand to be the normalized vector from qnear to qrand\n    Eigen::VectorXd vrand(vfdim_);\n    for (unsigned int i = 0; i < vfdim_; i++)\n        vrand[i] = *si_->getStateSpace()->getValueAddressAtIndex(qrand, i) -\n                   *si_->getStateSpace()->getValueAddressAtIndex(qnear, i);\n    vrand \/= si_->distance(qnear, qrand);\n\n    \/\/ Get the vector at qnear, and normalize\n    Eigen::VectorXd vfield = vf_(qnear);\n    const double lambdaScale = vfield.norm();\n    \/\/ In the case where there is no vector field present, vfield.norm() == 0,\n    \/\/ return the direction of the random state.\n    if (lambdaScale < std::numeric_limits<float>::epsilon())\n        return vrand;\n    vfield \/= lambdaScale;\n    \/\/ Sample a weight from the distribution\n    const double omega = biasedSampling(vrand, vfield, lambdaScale);\n    \/\/ Determine updated direction\n    return computeAlphaBeta(omega, vrand, vfield);\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":253716,"func":"static int ccp_copy_to_sb(struct ccp_cmd_queue *cmd_q,\n\t\t\t  struct ccp_dm_workarea *wa, u32 jobid, u32 sb,\n\t\t\t  u32 byte_swap)\n{\n\treturn ccp_copy_to_from_sb(cmd_q, wa, jobid, sb, byte_swap, false);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":90233,"func":"CellularNetwork::~CellularNetwork() {\n}\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":393462,"func":"static SQInteger class_getattributes(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_getattributes(v,-2))?1:SQ_ERROR;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":353121,"func":"void SplashOutputDev::updateFont(GfxState * \/*state*\/) {\n  needFontUpdate = true;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":247117,"func":"GF_Err gf_fs_post_user_task(GF_FilterSession *fsess, Bool (*task_execute) (GF_FilterSession *fsess, void *callback, u32 *reschedule_ms), void *udta_callback, const char *log_name)\n{\n\tGF_UserTask *utask;\n\tchar *_log_name;\n\tif (!fsess || !task_execute) return GF_BAD_PARAM;\n\tGF_SAFEALLOC(utask, GF_UserTask);\n\tif (!utask) return GF_OUT_OF_MEM;\n\tutask->fsess = fsess;\n\tutask->callback = udta_callback;\n\tutask->task_execute = task_execute;\n\t\/\/dup mem for user task\n\t_log_name = gf_strdup(log_name ? log_name : \"user_task\");\n\tgf_fs_post_task(fsess, gf_fs_user_task, NULL, NULL, _log_name, utask);\n\treturn GF_OK;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":512354,"func":"static inline int cmp_longs (longlong a_val, longlong b_val)\n{\n  return a_val < b_val ? -1 : a_val == b_val ? 0 : 1;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":236191,"func":"GF_Err href_box_size(GF_Box *s)\n{\n\tGF_TextHyperTextBox*ptr = (GF_TextHyperTextBox*)s;\n\ts->size += 6;\n\tif (ptr->URL) s->size += strlen(ptr->URL);\n\tif (ptr->URL_hint) s->size += strlen(ptr->URL_hint);\n\treturn GF_OK;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":344821,"func":"get_u32(const void *vp)\n{\n\tconst u_char *p = (const u_char *)vp;\n\tu_int32_t v;\n\n\tv  = (u_int32_t)p[0] << 24;\n\tv |= (u_int32_t)p[1] << 16;\n\tv |= (u_int32_t)p[2] << 8;\n\tv |= (u_int32_t)p[3];\n\n\treturn (v);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":432311,"func":"AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx)\n{\n    \/* only one AddressSpace. *\/\n    return cpu->cpu_ases[0].as;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":432159,"func":"Timestamp PipelineD::getLatestOplogTimestamp(const Pipeline* pipeline) {\n    if (auto docSourceCursor =\n            dynamic_cast<DocumentSourceCursor*>(pipeline->_sources.front().get())) {\n        return docSourceCursor->getLatestOplogTimestamp();\n    }\n    return Timestamp();\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":477364,"func":"R_API RBinJavaAttrInfo *r_bin_java_signature_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 6;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_SIGNATURE_ATTR;\n\t\/\/ attr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\/\/ offset += 2;\n\tattr->info.signature_attr.signature_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.signature_attr.signature = r_bin_java_get_utf8_from_bin_cp_list (\n\t\tR_BIN_JAVA_GLOBAL_BIN, attr->info.signature_attr.signature_idx);\n\tif (!attr->info.signature_attr.signature) {\n\t\teprintf (\"r_bin_java_signature_attr_new: Unable to resolve the \"\n\t\t\t\"Signature UTF8 String Index: 0x%02x\\n\", attr->info.signature_attr.signature_idx);\n\t}\n\tattr->size = offset;\n\t\/\/ IFDBG r_bin_java_print_source_code_file_attr_summary(attr);\n\treturn attr;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":230395,"func":"PJ_DEF(pj_xml_attr*) pj_xml_attr_new( pj_pool_t *pool, const pj_str_t *name,\n\t\t\t\t      const pj_str_t *value)\n{\n    pj_xml_attr *attr = alloc_attr(pool);\n    pj_strdup( pool, &attr->name, name);\n    pj_strdup( pool, &attr->value, value);\n    return attr;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":336492,"func":"SPICE_GNUC_VISIBLE SpiceImageCompression spice_server_get_image_compression(SpiceServer *s)\n{\n    return s->config->image_compression;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":329937,"func":"draw (cairo_t *cr, int width, int height)\n{\n    cairo_set_source_rgb (cr, 0., 0., 0.);\n    cairo_paint (cr);\n\n    cairo_set_source_rgb (cr, 1., 1., 1.);\n    cairo_set_line_width (cr, 1.);\n\n    cairo_pattern_t *p = cairo_pattern_create_linear (0, 0, width, height);\n    cairo_pattern_add_color_stop_rgb (p, 0, 0.99, 1, 1);\n    cairo_pattern_add_color_stop_rgb (p, 1, 1, 1, 1);\n    cairo_set_source (cr, p);\n\n    cairo_move_to (cr, 0.5, -1);\n    for (int i = 0; i < width; i+=3) {\n\tcairo_rel_line_to (cr, 2, 2);\n\tcairo_rel_line_to (cr, 1, -2);\n    }\n\n    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);\n    cairo_stroke (cr);\n\n    cairo_pattern_destroy(p);\n\n    return CAIRO_TEST_SUCCESS;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":373546,"func":"ipf_expiry_list_remove(struct ipf_list *ipf_list)\n    \/* OVS_REQUIRES(ipf_lock) *\/\n{\n    ovs_list_remove(&ipf_list->list_node);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":244293,"func":"GF_Err sdtp_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_SampleDependencyTypeBox *ptr = (GF_SampleDependencyTypeBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_data(bs, (char*)ptr->sample_info, ptr->sampleCount);\n\treturn GF_OK;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":401590,"func":"static int proc_do_entropy(struct ctl_table *table, int write,\n\t\t\t   void *buffer, size_t *lenp, loff_t *ppos)\n{\n\tstruct ctl_table fake_table;\n\tint entropy_count;\n\n\tentropy_count = *(int *)table->data >> ENTROPY_SHIFT;\n\n\tfake_table.data = &entropy_count;\n\tfake_table.maxlen = sizeof(entropy_count);\n\n\treturn proc_dointvec(&fake_table, write, buffer, lenp, ppos);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":244289,"func":"void strk_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":224178,"func":"  std::size_t incomplete_size() {\n    tensorflow::mutex_lock lock(mu_);\n    return incomplete_.size();\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":522341,"func":"int APIF77(gmfsetkwd)(  int64_t *MshIdx, int *KwdIdx, int *NmbLin,\n                        int *NmbTyp, int *TypTab, int *deg, int *NmbNod)\n{\n   if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], \"hr\"))\n      return(GmfSetKwd(*MshIdx, *KwdIdx, *NmbLin, *NmbTyp, TypTab, *deg, *NmbNod));\n   else if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], \"sr\"))\n      return(GmfSetKwd(*MshIdx, *KwdIdx, *NmbLin, *NmbTyp, TypTab));\n   else\n      return(GmfSetKwd(*MshIdx, *KwdIdx, *NmbLin));\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":338079,"func":"void WasmBinaryWriter::writeLegacyDylinkSection() {\n  if (!wasm->dylinkSection) {\n    return;\n  }\n\n  auto start = startSection(BinaryConsts::User);\n  writeInlineString(BinaryConsts::UserSections::Dylink);\n  o << U32LEB(wasm->dylinkSection->memorySize);\n  o << U32LEB(wasm->dylinkSection->memoryAlignment);\n  o << U32LEB(wasm->dylinkSection->tableSize);\n  o << U32LEB(wasm->dylinkSection->tableAlignment);\n  o << U32LEB(wasm->dylinkSection->neededDynlibs.size());\n  for (auto& neededDynlib : wasm->dylinkSection->neededDynlibs) {\n    writeInlineString(neededDynlib.c_str());\n  }\n  finishSection(start);\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":345139,"func":"static inline struct pxa3xx_gcu_priv *to_pxa3xx_gcu_priv(struct file *file)\n{\n\tstruct miscdevice *dev = file->private_data;\n\treturn container_of(dev, struct pxa3xx_gcu_priv, misc_dev);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":244159,"func":"void ihdr_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":512282,"func":"  my_decimal *val_decimal(my_decimal *to)\n  {\n    return has_value() ? Date(this).to_decimal(to) : NULL;\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":269311,"func":"static av_always_inline void predict_plane(SnowContext *s, IDWTELEM *buf, int plane_index, int add){\n    const int mb_h= s->b_height << s->block_max_depth;\n    int mb_y;\n    for(mb_y=0; mb_y<=mb_h; mb_y++)\n        predict_slice(s, buf, plane_index, add, mb_y);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":299976,"func":"static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)\n{\n\tstruct elo_priv *priv;\n\tint ret;\n\tstruct usb_device *udev;\n\n\tif (!hid_is_usb(hdev))\n\t\treturn -EINVAL;\n\n\tpriv = kzalloc(sizeof(*priv), GFP_KERNEL);\n\tif (!priv)\n\t\treturn -ENOMEM;\n\n\tINIT_DELAYED_WORK(&priv->work, elo_work);\n\tudev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));\n\tpriv->usbdev = usb_get_dev(udev);\n\n\thid_set_drvdata(hdev, priv);\n\n\tret = hid_parse(hdev);\n\tif (ret) {\n\t\thid_err(hdev, \"parse failed\\n\");\n\t\tgoto err_free;\n\t}\n\n\tret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);\n\tif (ret) {\n\t\thid_err(hdev, \"hw start failed\\n\");\n\t\tgoto err_free;\n\t}\n\n\tif (elo_broken_firmware(priv->usbdev)) {\n\t\thid_info(hdev, \"broken firmware found, installing workaround\\n\");\n\t\tqueue_delayed_work(wq, &priv->work, ELO_PERIODIC_READ_INTERVAL);\n\t}\n\n\treturn 0;\nerr_free:\n\tusb_put_dev(udev);\n\tkfree(priv);\n\treturn ret;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":294641,"func":"date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vjd, vsg;\n    VALUE argv2[2];\n\n    rb_scan_args(argc, argv, \"11\", &vjd, &vsg);\n\n    argv2[0] = vjd;\n    if (argc < 2)\n\targv2[1] = DBL2NUM(GREGORIAN);\n    else\n\targv2[1] = vsg;\n\n    return valid_jd_sub(2, argv2, klass, 1);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":445902,"func":"archive_is_encrypted (FrWindow *window,\n\t\t      GList    *file_list)\n{\n\tgboolean encrypted = FALSE;\n\n\tif (file_list == NULL) {\n\t\tint i;\n\n\t\tfor (i = 0; ! encrypted && i < window->archive->files->len; i++) {\n\t\t\tFileData *fdata = g_ptr_array_index (window->archive->files, i);\n\n\t\t\tif (fdata->encrypted)\n\t\t\t\tencrypted = TRUE;\n\t\t}\n\t}\n\telse {\n\t\tGList *scan;\n\n\t\tfor (scan = file_list; ! encrypted && scan; scan = scan->next) {\n\t\t\tchar     *filename = scan->data;\n\t\t\tFileData *fdata;\n\n\t\t\tfdata = g_hash_table_lookup (window->archive->files_hash, filename);\n\t\t\tg_return_val_if_fail (fdata != NULL, FALSE);\n\n\t\t\tif (fdata->encrypted)\n\t\t\t\tencrypted = TRUE;\n\t\t}\n\t}\n\n\treturn encrypted;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":448554,"func":"bool bgp_notify_send_hard_reset(struct peer *peer, uint8_t code,\n\t\t\t\tuint8_t subcode)\n{\n\t\/* When the \"N\" bit has been exchanged, a Hard Reset message is used to\n\t * indicate to the peer that the session is to be fully terminated.\n\t *\/\n\tif (!bgp_has_graceful_restart_notification(peer))\n\t\treturn false;\n\n\t\/*\n\t * https:\/\/datatracker.ietf.org\/doc\/html\/rfc8538#section-5.1\n\t *\/\n\tif (code == BGP_NOTIFY_CEASE) {\n\t\tswitch (subcode) {\n\t\tcase BGP_NOTIFY_CEASE_MAX_PREFIX:\n\t\tcase BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN:\n\t\tcase BGP_NOTIFY_CEASE_PEER_UNCONFIG:\n\t\tcase BGP_NOTIFY_CEASE_HARD_RESET:\n\t\tcase BGP_NOTIFY_CEASE_BFD_DOWN:\n\t\t\treturn true;\n\t\tcase BGP_NOTIFY_CEASE_ADMIN_RESET:\n\t\t\t\/* Provide user control:\n\t\t\t * `bgp hard-adminstrative-reset`\n\t\t\t *\/\n\t\t\tif (CHECK_FLAG(peer->bgp->flags,\n\t\t\t\t       BGP_FLAG_HARD_ADMIN_RESET))\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn false;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":215073,"func":"static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,\n\t\t\t\t\t  char *buf, size_t nbytes, loff_t off)\n{\n\tstruct cgroup *cgrp;\n\n\tBUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);\n\n\tcgrp = cgroup_kn_lock_live(of->kn, false);\n\tif (!cgrp)\n\t\treturn -ENODEV;\n\tspin_lock(&release_agent_path_lock);\n\tstrlcpy(cgrp->root->release_agent_path, strstrip(buf),\n\t\tsizeof(cgrp->root->release_agent_path));\n\tspin_unlock(&release_agent_path_lock);\n\tcgroup_kn_unlock(of->kn);\n\treturn nbytes;\n}","target":1,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":359308,"func":"DEFUN (show_ip_community_list_arg,\n       show_ip_community_list_arg_cmd,\n       \"show ip community-list (<1-500>|WORD)\",\n       SHOW_STR\n       IP_STR\n       \"List community-list\\n\"\n       \"Community-list number\\n\"\n       \"Community-list name\\n\")\n{\n  struct community_list *list;\n\n  list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);\n  if (! list)\n    {\n      vty_out (vty, \"%% Can't find communit-list%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  community_list_show (vty, list);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":253519,"func":"smb3_handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid)\n{\n\tchar *buf = server->large_buf ? server->bigbuf : server->smallbuf;\n\n\treturn handle_read_data(server, mid, buf, server->pdu_size,\n\t\t\t\tNULL, 0, 0, false);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":221145,"func":"GF_Err gf_odf_avc_cfg_write(GF_AVCConfig *cfg, u8 **outData, u32 *outSize)\n{\n\tGF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\tgf_odf_avc_cfg_write_bs(cfg, bs);\n\t*outSize = 0;\n\t*outData = NULL;\n\tgf_bs_get_content(bs, outData, outSize);\n\tgf_bs_del(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":486784,"func":"static inline unsigned tx_desc_get_length(uint32_t *desc)\n{\n    return desc[1] & DESC_1_LENGTH;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":220004,"func":"int callback_glewlwyd_get_module_type_list (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  UNUSED(request);\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_module_type;\n  \n  j_module_type = get_module_type_list(config);\n  if (check_result_value(j_module_type, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module_type, \"module\"));\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_module_type_list - Error get_module_type_list\");\n    response->status = 500;\n  }\n  json_decref(j_module_type);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":310150,"func":"cleanup(void)\n{\n    outs(t_me);\n    if (!outs(t_oc))\n\touts(t_op);\n    outs(t_cl);\n    outs(t_ve);\n\n    fflush(stdout);\n    fprintf(stderr, \"\\n\\n%ld total cells, rate %.2f\/sec\\n\",\n\t    total_chars,\n\t    ((double) (total_chars) \/ (double) (time((time_t *) 0) - started)));\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":209801,"func":"void jsP_dumpsyntax(js_State *J, js_Ast *prog, int dominify)\n{\n\tminify = dominify;\n\tif (prog->type == AST_LIST)\n\t\tpstmlist(-1, prog);\n\telse {\n\t\tpstm(0, prog);\n\t\tnl();\n\t}\n\tif (minify > 1)\n\t\tputchar('\\n');\n}","target":1,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":463178,"func":"EXPORTED void annotate_state_set_auth(annotate_state_t *state,\n                             int isadmin, const char *userid,\n                             const struct auth_state *auth_state)\n{\n    \/* Note: lmtpd sometimes calls through the append code with\n     * auth_state=NULL, so we cannot rely on it being non-NULL *\/\n    state->userid = userid;\n    state->isadmin = isadmin;\n    state->auth_state = auth_state;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":387877,"func":"void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,\n                                       Array<Method*>* methods) {\n  if (methods != NULL && methods != Universe::the_empty_method_array() &&\n      !methods->is_shared()) {\n    for (int i = 0; i < methods->length(); i++) {\n      Method* method = methods->at(i);\n      if (method == NULL) continue;  \/\/ maybe null if error processing\n      \/\/ Only want to delete methods that are not executing for RedefineClasses.\n      \/\/ The previous version will point to them so they're not totally dangling\n      assert (!method->on_stack(), \"shouldn't be called with methods on stack\");\n      MetadataFactory::free_metadata(loader_data, method);\n    }\n    MetadataFactory::free_array<Method*>(loader_data, methods);\n  }\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":294484,"func":"test_nth_kday(int from, int to, double sg)\n{\n    int j;\n\n    fprintf(stderr, \"test_nth_kday: %d...%d (%d) - %.0f\\n\",\n\t    from, to, to - from, sg);\n    for (j = from; j <= to; j++) {\n\tint y, m, n, k, rj, ns;\n\n\tc_jd_to_nth_kday(j, sg, &y, &m, &n, &k);\n\tc_nth_kday_to_jd(y, m, n, k, sg, &rj, &ns);\n\tif (j != rj) {\n\t    fprintf(stderr, \"%d != %d\\n\", j, rj);\n\t    return 0;\n\t}\n    }\n    return 1;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":421375,"func":"static void pargs(int d, js_Ast *list)\n{\n\twhile (list) {\n\t\tassert(list->type == AST_LIST);\n\t\tpexpi(d, COMMA, list->a);\n\t\tlist = list->b;\n\t\tif (list)\n\t\t\tcomma();\n\t}\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":247567,"func":"TEST_P(SslSocketTest, FailedClientAuthCaVerification) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/selfsigned_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.fail_verify_error\")\n               .setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY));\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":474051,"func":"rehash(register st_table *table)\n{\n    register st_table_entry *ptr, **new_bins;\n    st_index_t i, new_num_bins, hash_val;\n\n    new_num_bins = new_size(table->num_bins+1);\n    new_bins = (st_table_entry**)\n\txrealloc(table->bins, new_num_bins * sizeof(st_table_entry*));\n    for (i = 0; i < new_num_bins; ++i) new_bins[i] = 0;\n    table->num_bins = new_num_bins;\n    table->bins = new_bins;\n\n    if ((ptr = table->head) != 0) {\n\tdo {\n\t    hash_val = ptr->hash % new_num_bins;\n\t    ptr->next = new_bins[hash_val];\n\t    new_bins[hash_val] = ptr;\n\t} while ((ptr = ptr->fore) != 0);\n    }\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":233844,"func":"void fmtutil_macbitmap_read_baseaddr(deark *c, dbuf *f, struct fmtutil_macbitmap_info *bi, i64 pos)\n{\n\ti64 n;\n\tde_dbg(c, \"baseAddr part of PixMap, at %d\", (int)pos);\n\tde_dbg_indent(c, 1);\n\tn = dbuf_getu32be(f, pos);\n\tde_dbg(c, \"baseAddr: 0x%08x\", (unsigned int)n);\n\tde_dbg_indent(c, -1);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":483512,"func":"static int register_update_efi_random_seed(void)\n{\n\tif (efi.rng_seed == EFI_INVALID_TABLE_ADDR)\n\t\treturn 0;\n\treturn register_reboot_notifier(&efi_random_seed_nb);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":234236,"func":"load_debug_section_with_follow (enum dwarf_section_display_enum sec_enum,\n\t\t\t\tvoid * handle)\n{\n  if (load_debug_section (sec_enum, handle))\n    {\n      if (debug_displays[sec_enum].section.filename == NULL)\n\t{\n\t  \/* See if we can associate a filename with this section.  *\/\n\t  separate_info * i;\n\n\t  for (i = first_separate_info; i != NULL; i = i->next)\n\t    if (i->handle == handle)\n\t      {\n\t\tdebug_displays[sec_enum].section.filename = i->filename;\n\t\tbreak;\n\t      }\n\t}\n\n      return true;\n    }\n\n  if (do_follow_links)\n    {\n      separate_info * i;\n\n      for (i = first_separate_info; i != NULL; i = i->next)\n\t{\n\t  if (load_debug_section (sec_enum, i->handle))\n\t    {\n\t      debug_displays[sec_enum].section.filename = i->filename;\n\n\t      \/* FIXME: We should check to see if any of the remaining debug info\n\t\t files also contain this section, and, umm, do something about it.  *\/\n\t      return true;\n\t    }\n\t}\n    }\n\n  return false;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":369307,"func":"\nstatic int io_files_update(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tbool needs_lock = issue_flags & IO_URING_F_UNLOCKED;\n\tstruct io_uring_rsrc_update2 up;\n\tint ret;\n\n\tup.offset = req->rsrc_update.offset;\n\tup.data = req->rsrc_update.arg;\n\tup.nr = 0;\n\tup.tags = 0;\n\tup.resv = 0;\n\tup.resv2 = 0;\n\n\tio_ring_submit_lock(ctx, needs_lock);\n\tret = __io_register_rsrc_update(ctx, IORING_RSRC_FILE,\n\t\t\t\t\t&up, req->rsrc_update.nr_args);\n\tio_ring_submit_unlock(ctx, needs_lock);\n\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":463064,"func":"static bool sungem_rx_full(SunGEMState *s, uint32_t kick, uint32_t done)\n{\n    return kick == ((done + 1) & s->rx_mask);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":313861,"func":"may_clear_cmdline(void)\n{\n    if (mode_displayed)\n\tclear_cmdline = TRUE;   \/\/ unshow visual mode later\n#ifdef FEAT_CMDL_INFO\n    else\n\tclear_showcmd();\n#endif\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":275953,"func":"uECC_VLI_API void uECC_vli_modSub(uECC_word_t *result,\n                                  const uECC_word_t *left,\n                                  const uECC_word_t *right,\n                                  const uECC_word_t *mod,\n                                  wordcount_t num_words) {\n    uECC_word_t l_borrow = uECC_vli_sub(result, left, right, num_words);\n    if (l_borrow) {\n        \/* In this case, result == -diff == (max int) - diff. Since -x % d == d - x,\n           we can get the correct result from result + mod (with overflow). *\/\n        uECC_vli_add(result, result, mod, num_words);\n    }\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":244247,"func":"void moof_box_del(GF_Box *s)\n{\n\tGF_MovieFragmentBox *ptr = (GF_MovieFragmentBox *)s;\n\tif (ptr == NULL) return;\n\n\tgf_list_del(ptr->TrackList);\n\tif (ptr->PSSHs) gf_list_del(ptr->PSSHs);\n\tif (ptr->mdat) gf_free(ptr->mdat);\n\t\/\/happens if error while fragmenting, the emsg boxes are not part of the moof hierarchy !\n\tif (ptr->emsgs) {\n\t\twhile (1) {\n\t\t\tGF_Box *emsg = gf_list_pop_front(ptr->emsgs);\n\t\t\tif (!emsg) break;\n\t\t\tgf_isom_box_del(emsg);\n\t\t}\n\t\tgf_list_del(ptr->emsgs);\n\t}\n\tgf_free(ptr);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":273089,"func":"net_address_get(char *addr, size_t addr_len, union net_sockaddr *naddr)\n{\n  const char *s;\n\n  memset(addr, 0, addr_len); \/\/ Just in case caller doesn't check for errors\n\n  if (naddr->sa.sa_family == AF_INET6)\n     s = inet_ntop(AF_INET6, &naddr->sin6.sin6_addr, addr, addr_len);\n  else\n     s = inet_ntop(AF_INET, &naddr->sin.sin_addr, addr, addr_len);\n\n  if (!s)\n    return -1;\n\n  return 0;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":231802,"func":"TEST_F(QuicServerTransportTest, TestAckStopSending) {\n  auto streamId = server->createBidirectionalStream().value();\n  server->getNonConstConn().streamManager->getStream(streamId);\n  server->stopSending(streamId, GenericApplicationErrorCode::UNKNOWN);\n  loopForWrites();\n  auto match = findFrameInPacketFunc<QuicSimpleFrame::Type::StopSendingFrame>();\n\n  auto op = findOutstandingPacket(server->getNonConstConn(), match);\n  ASSERT_TRUE(op != nullptr);\n  PacketNum packetNum = op->packet.header.getPacketSequenceNum();\n  AckBlocks acks = {{packetNum, packetNum}};\n  auto packet1 = createAckPacket(\n      server->getNonConstConn(),\n      ++clientNextAppDataPacketNum,\n      acks,\n      PacketNumberSpace::AppData);\n  deliverData(packetToBuf(packet1));\n  op = findOutstandingPacket(server->getNonConstConn(), match);\n  EXPECT_TRUE(op == nullptr);\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":244062,"func":"GF_Box *sidx_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SegmentIndexBox, GF_ISOM_BOX_TYPE_SIDX);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":226186,"func":"void tpyl_box_del(GF_Box *s)\n{\n\tgf_free((GF_NTYLBox *)s);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":401559,"func":"static inline void timer_base_lock_expiry(struct timer_base *base)\n{\n\tspin_lock(&base->expiry_lock);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":225423,"func":"static void init_capture_param(struct v4l2_captureparm *capture_param)\n{\n\tMARK();\n\tcapture_param->capability = 0;\n\tcapture_param->capturemode = 0;\n\tcapture_param->extendedmode = 0;\n\tcapture_param->readbuffers = max_buffers;\n\tcapture_param->timeperframe.numerator = 1;\n\tcapture_param->timeperframe.denominator = 30;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":244314,"func":"GF_Err csgp_box_size(GF_Box *s)\n{\n\tu32 i, bits;\n\tGF_CompactSampleGroupBox *ptr = (GF_CompactSampleGroupBox*)s;\n\tu32 pattern_size = get_size_by_code( ((ptr->flags>>4) & 0x3) );\n\tu32 scount_size = get_size_by_code( ((ptr->flags>>2) & 0x3) );\n\tu32 index_size = get_size_by_code( (ptr->flags & 0x3) );\n\n\tptr->size += 12; \/\/v, flags , grouping_type, pattern_length\n\tif (ptr->flags & (1<<6))\n\t\tptr->size+=4;\n\n\tptr->size += ptr->pattern_count * (pattern_size + scount_size) \/ 8;\n\tbits=0;\n\tfor (i=0; i<ptr->pattern_count; i++)\n\t\tbits += ptr->patterns[i].length * index_size;\n\tptr->size += bits\/8;\n\tif (bits % 8) ptr->size++;\n\treturn GF_OK;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":232332,"func":"\nBool gf_box_valid_in_parent(GF_Box *a, const char *parent_4cc)\n{\n\tif (!a || !a->registry || !a->registry->parents_4cc) return GF_FALSE;\n\tif (strstr(a->registry->parents_4cc, parent_4cc) != NULL) return GF_TRUE;\n\treturn GF_FALSE;","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":233821,"func":"void fmtutil_handle_exif(deark *c, i64 pos, i64 len)\n{\n\tfmtutil_handle_exif2(c, pos, len, NULL, NULL, NULL);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":473931,"func":"mbc_case_fold(OnigCaseFoldType flag,\n\t      const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower,\n\t      OnigEncoding enc ARG_UNUSED)\n{\n  const UChar* p = *pp;\n\n  if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    *lower++ = 's';\n    *lower   = 's';\n    (*pp)++;\n    return 2;\n  }\n\n  *lower = ENC_ISO_8859_9_TO_LOWER_CASE(*p);\n  (*pp)++;\n  return 1;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":244202,"func":"void clap_box_del(GF_Box *s)\n{\n\tGF_CleanApertureBox *ptr = (GF_CleanApertureBox*)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":307834,"func":"bool ciEnv::system_dictionary_modification_counter_changed() {\n  return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":498153,"func":"void cgit_print_docend(void)\n{\n\thtml(\"<\/div> <!-- class=content -->\\n\");\n\tif (ctx.cfg.embedded) {\n\t\thtml(\"<\/div> <!-- id=cgit -->\\n\");\n\t\tif (ctx.cfg.footer)\n\t\t\thtml_include(ctx.cfg.footer);\n\t\treturn;\n\t}\n\tif (ctx.cfg.footer)\n\t\thtml_include(ctx.cfg.footer);\n\telse {\n\t\thtmlf(\"<div class='footer'>generated by <a href='http:\/\/git.zx2c4.com\/cgit\/about\/'>cgit %s<\/a> at \",\n\t\t\tcgit_version);\n\t\tcgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time);\n\t\thtml(\"<\/div>\\n\");\n\t}\n\thtml(\"<\/div> <!-- id=cgit -->\\n\");\n\thtml(\"<\/body>\\n<\/html>\\n\");\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":237878,"func":"qeh_in_on_new (void *stream_if_ctx, struct lsquic_stream *stream)\n{\n    struct qpack_enc_hdl *const qeh = stream_if_ctx;\n    qeh->qeh_dec_sm_in = stream;\n    if (qeh->qeh_flags & QEH_INITIALIZED)\n        lsquic_stream_wantread(qeh->qeh_dec_sm_in, 1);\n    else\n        qeh->qeh_conn = lsquic_stream_conn(stream);   \/* Or NULL deref in log *\/\n    LSQ_DEBUG(\"initialized incoming decoder stream\");\n    return (void *) qeh;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":249516,"func":"inline unsigned int read_chunk(Reader* r, CHUNK* pChunk) {\n  unsigned char len[4];\n  pChunk->size = 0;\n  pChunk->p = 0;\n  if (r->Read(&len, 4)) {\n    const auto size = png_get_uint_32(len);\n    \/\/ Check first, to avoid overflow.\n    if (size > kMaxPNGChunkSize) {\n      JXL_WARNING(\"APNG chunk size is too big\");\n      return 0;\n    }\n    pChunk->size = size + 12;\n    pChunk->p = new unsigned char[pChunk->size];\n    memcpy(pChunk->p, len, 4);\n    if (r->Read(pChunk->p + 4, pChunk->size - 4)) {\n      return *(unsigned int*)(pChunk->p + 4);\n    }\n  }\n  return 0;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":337819,"func":"static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc,\n\t\t\t\t\t       __u32 serial, int vparam_len)\n{\n\tstruct sctp_addiphdr asconf;\n\tstruct sctp_chunk *retval;\n\tint length = sizeof(asconf) + vparam_len;\n\n\t\/* Create the chunk.  *\/\n\tretval = sctp_make_control(asoc, SCTP_CID_ASCONF_ACK, 0, length,\n\t\t\t\t   GFP_ATOMIC);\n\tif (!retval)\n\t\treturn NULL;\n\n\tasconf.serial = htonl(serial);\n\n\tretval->subh.addip_hdr =\n\t\tsctp_addto_chunk(retval, sizeof(asconf), &asconf);\n\n\treturn retval;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":227019,"func":"IRC_PROTOCOL_CALLBACK(341)\n{\n    char *pos_channel;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    pos_channel = (argv[4][0] == ':') ? argv[4] + 1 : argv[4];\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, argv[2], command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", argv[2], address),\n        _(\"%s%s%s%s has invited %s%s%s to %s%s%s\"),\n        weechat_prefix (\"network\"),\n        irc_nick_color_for_msg (server, 1, NULL, argv[2]),\n        argv[2],\n        IRC_COLOR_RESET,\n        irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n        argv[3],\n        IRC_COLOR_RESET,\n        IRC_COLOR_CHAT_CHANNEL,\n        pos_channel,\n        IRC_COLOR_RESET);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":313844,"func":"nv_dollar(cmdarg_T *cap)\n{\n    cap->oap->motion_type = MCHAR;\n    cap->oap->inclusive = TRUE;\n    \/\/ In virtual mode when off the edge of a line and an operator\n    \/\/ is pending (whew!) keep the cursor where it is.\n    \/\/ Otherwise, send it to the end of the line.\n    if (!virtual_active() || gchar_cursor() != NUL\n\t\t\t\t\t       || cap->oap->op_type == OP_NOP)\n\tcurwin->w_curswant = MAXCOL;\t\/\/ so we stay at the end\n    if (cursor_down((long)(cap->count1 - 1),\n\t\t\t\t\t cap->oap->op_type == OP_NOP) == FAIL)\n\tclearopbeep(cap->oap);\n#ifdef FEAT_FOLDING\n    else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)\n\tfoldOpenCursor();\n#endif\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":512889,"func":"uchar *in_timestamp::get_value(Item *item)\n{\n  Timestamp_or_zero_datetime_native_null native(current_thd, item, true);\n  if (native.is_null())\n    return 0;\n  tmp= Timestamp_or_zero_datetime(native);\n  return (uchar*) &tmp;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":248233,"func":"DLLIMPORT int cfg_setlist(cfg_t *cfg, const char *name, unsigned int nvalues, ...)\n{\n\tva_list ap;\n\tcfg_opt_t *opt = cfg_getopt(cfg, name);\n\n\tif (!opt || !is_set(CFGF_LIST, opt->flags)) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\tcfg_free_value(opt);\n\tva_start(ap, nvalues);\n\tcfg_addlist_internal(opt, nvalues, ap);\n\tva_end(ap);\n\n\treturn CFG_SUCCESS;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":462565,"func":"void controller::update_flags(std::shared_ptr<rss_item> item) {\n\tif (api) {\n\t\tapi->update_article_flags(item->oldflags(), item->flags(), item->guid());\n\t}\n\titem->update_flags();\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":417078,"func":"\tvirtual void mix(mp_sint32* buffer, mp_uint32 bufferSize)\n\t{\n\t\tconst mp_sint32* buffer32 = buffer;\n\t\t\n\t\tfor (mp_uint32 i = 0; i < bufferSize*MP_NUMCHANNELS; i++)\n\t\t{\n\t\t\tmp_sint32 b = *buffer32++;\n\t\t\t\n\t\t\tif (abs(b) > lastPeakValue)\n\t\t\t\tlastPeakValue = abs(b);\t\t\t\t\t\n\t\t}\n\t}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":338169,"func":"void WasmBinaryBuilder::readGlobals() {\n  BYN_TRACE(\"== readGlobals\\n\");\n  size_t num = getU32LEB();\n  BYN_TRACE(\"num: \" << num << std::endl);\n  for (size_t i = 0; i < num; i++) {\n    BYN_TRACE(\"read one\\n\");\n    auto type = getConcreteType();\n    auto mutable_ = getU32LEB();\n    if (mutable_ & ~1) {\n      throwError(\"Global mutability must be 0 or 1\");\n    }\n    auto* init = readExpression();\n    globals.push_back(\n      Builder::makeGlobal(\"global$\" + std::to_string(i),\n                          type,\n                          init,\n                          mutable_ ? Builder::Mutable : Builder::Immutable));\n  }\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":359562,"func":"DEFUN (show_ip_extcommunity_list_arg,\n       show_ip_extcommunity_list_arg_cmd,\n       \"show ip extcommunity-list (<1-500>|WORD)\",\n       SHOW_STR\n       IP_STR\n       \"List extended-community list\\n\"\n       \"Extcommunity-list number\\n\"\n       \"Extcommunity-list name\\n\")\n{\n  struct community_list *list;\n\n  list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);\n  if (! list)\n    {\n      vty_out (vty, \"%% Can't find extcommunit-list%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  extcommunity_list_show (vty, list);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":274879,"func":"TEST(ComparisonsTest, LessInt) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 4}, TensorType_INT32,\n                          BuiltinOperator_LESS);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3});\n  model.PopulateTensor<int>(model.input2(), {1, 2, 6, 5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(true, false, false, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":474018,"func":"utf16be_mbc_enc_len(const UChar* p, const OnigUChar* e ARG_UNUSED,\n\t\t    OnigEncoding enc ARG_UNUSED)\n{\n  int byte = p[0];\n  if (!UTF16_IS_SURROGATE(byte)) {\n    if (2 <= e-p)\n      return ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2);\n    else\n      return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1);\n  }\n  if (UTF16_IS_SURROGATE_FIRST(byte)) {\n    switch (e-p) {\n      case 1: return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(3);\n      case 2: return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(2);\n      case 3:\n        if (UTF16_IS_SURROGATE_SECOND(p[2]))\n          return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1);\n        break;\n      default:\n        if (UTF16_IS_SURROGATE_SECOND(p[2]))\n          return ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4);\n        break;\n    }\n  }\n  return ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":346469,"func":"add_pack_plugin(char_u *fname, void *cookie)\n{\n    if (cookie != &APP_LOAD)\n    {\n\tchar_u\t*buf = alloc(MAXPATHL);\n\tchar_u\t*p;\n\tint\tfound = FALSE;\n\n\tif (buf == NULL)\n\t    return;\n\tp = p_rtp;\n\twhile (*p != NUL)\n\t{\n\t    copy_option_part(&p, buf, MAXPATHL, \",\");\n\t    if (pathcmp((char *)buf, (char *)fname, -1) == 0)\n\t    {\n\t\tfound = TRUE;\n\t\tbreak;\n\t    }\n\t}\n\tvim_free(buf);\n\tif (!found)\n\t    \/\/ directory is not yet in 'runtimepath', add it\n\t    if (add_pack_dir_to_rtp(fname) == FAIL)\n\t\treturn;\n    }\n\n    if (cookie != &APP_ADD_DIR)\n\tload_pack_plugin(fname);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":488425,"func":"static unsigned long __init find_function64(struct lib64_elfinfo *lib,\n\t\t\t\t\t    const char *symname)\n{\n\tElf64_Sym *sym = find_symbol64(lib, symname);\n\n\tif (sym == NULL) {\n\t\tprintk(KERN_WARNING \"vDSO64: function %s not found !\\n\",\n\t\t       symname);\n\t\treturn 0;\n\t}\n#ifdef VDS64_HAS_DESCRIPTORS\n\treturn *((u64 *)(vdso64_kbase + sym->st_value - VDSO64_LBASE)) -\n\t\tVDSO64_LBASE;\n#else\n\treturn sym->st_value - VDSO64_LBASE;\n#endif\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":90891,"func":"void ClientUsageTracker::GatherHostUsageComplete(const std::string& host) {\n  DCHECK(host_usage_tasks_.find(host) != host_usage_tasks_.end());\n  host_usage_tasks_.erase(host);\n   host_usage_callbacks_.Run(host, host, type_, GetCachedHostUsage(host));\n }\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":512299,"func":"  Item_args(THD *thd, Item *a, Item *b, Item *c, Item *d)\n  {\n    arg_count= 0;\n    if (likely((args= (Item**) thd_alloc(thd, sizeof(Item*) * 4))))\n    {\n      arg_count= 4;\n      args[0]= a; args[1]= b; args[2]= c; args[3]= d;\n    }\n  }","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":328903,"func":"R_API void r_bin_java_reset_bin_info(RBinJavaObj *bin) {\n\tfree (bin->cf2.flags_str);\n\tfree (bin->cf2.this_class_name);\n\tr_list_free (bin->imports_list);\n\tr_list_free (bin->methods_list);\n\tr_list_free (bin->fields_list);\n\tr_list_free (bin->attrs_list);\n\tr_list_free (bin->cp_list);\n\tr_list_free (bin->interfaces_list);\n\tr_str_constpool_fini (&bin->constpool);\n\tr_str_constpool_init (&bin->constpool);\n\tbin->cf2.flags_str = strdup (\"unknown\");\n\tbin->cf2.this_class_name = strdup (\"unknown\");\n\tbin->imports_list = r_list_newf (free);\n\tbin->methods_list = r_list_newf (r_bin_java_fmtype_free);\n\tbin->fields_list = r_list_newf (r_bin_java_fmtype_free);\n\tbin->attrs_list = r_list_newf (r_bin_java_attribute_free);\n\tbin->cp_list = r_list_newf (r_bin_java_constant_pool);\n\tbin->interfaces_list = r_list_newf (r_bin_java_interface_free);\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":374048,"func":"static const char *subtypeString(int n) {\n\tif (n == 9) { \/\/ CPU_SUBTYPE_ARM_V7) {\n\t\treturn \"armv7\";\n\t}\n\treturn \"?\";\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":317215,"func":"static int selinux_is_genfs_special_handling(struct super_block *sb)\n{\n\t\/* Special handling. Genfs but also in-core setxattr handler *\/\n\treturn\t!strcmp(sb->s_type->name, \"sysfs\") ||\n\t\t!strcmp(sb->s_type->name, \"pstore\") ||\n\t\t!strcmp(sb->s_type->name, \"debugfs\") ||\n\t\t!strcmp(sb->s_type->name, \"tracefs\") ||\n\t\t!strcmp(sb->s_type->name, \"rootfs\") ||\n\t\t(selinux_policycap_cgroupseclabel() &&\n\t\t (!strcmp(sb->s_type->name, \"cgroup\") ||\n\t\t  !strcmp(sb->s_type->name, \"cgroup2\")));\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":139238,"func":"void OverlayWindowViews::OnNativeWidgetWorkspaceChanged() {\n}\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":512324,"func":"  double val_real() { return (double) value; }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":512493,"func":"  my_decimal *val_decimal_from_item(Item *item, my_decimal *decimal_value)\n  {\n    DBUG_ASSERT(is_fixed());\n    my_decimal *value= item->val_decimal(decimal_value);\n    if ((null_value= item->null_value))\n      value= NULL;\n    return value;\n  }","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":224529,"func":"Status ValidateVariableResourceHandle(\n    InferenceContext* c, std::vector<ShapeAndType>* shape_and_type) {\n  auto* handle_data = c->input_handle_shapes_and_types(0);\n  if (handle_data == nullptr || handle_data->empty()) {\n    shape_and_type->emplace_back(c->UnknownShape(), DT_INVALID);\n  } else {\n    *shape_and_type = *handle_data;\n    DataType value_dtype;\n    TF_RETURN_IF_ERROR(c->GetAttr(\"dtype\", &value_dtype));\n    if (shape_and_type->at(0).dtype != value_dtype) {\n      return errors::InvalidArgument(\n          \"Trying to read variable with wrong dtype. \"\n          \"Expected \",\n          DataTypeString(shape_and_type->at(0).dtype), \" got \",\n          DataTypeString(value_dtype));\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":359415,"func":"DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,\n       clear_ip_bgp_peer_vpnv4_soft_in_cmd,\n       \"clear ip bgp A.B.C.D vpnv4 unicast soft in\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"BGP neighbor address to clear\\n\"\n       \"Address family\\n\"\n       \"Address Family Modifier\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,\n\t\t\tBGP_CLEAR_SOFT_IN, argv[0]);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":262077,"func":"  explicit BoostedTreesCalculateBestGainsPerFeatureOp(\n      OpKernelConstruction* const context)\n      : OpKernel(context) {\n    OP_REQUIRES_OK(context, context->GetAttr(\"max_splits\", &max_splits_));\n    OP_REQUIRES_OK(context, context->GetAttr(\"num_features\", &num_features_));\n  }","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":369136,"func":"\nstatic clockid_t io_timeout_get_clock(struct io_timeout_data *data)\n{\n\tswitch (data->flags & IORING_TIMEOUT_CLOCK_MASK) {\n\tcase IORING_TIMEOUT_BOOTTIME:\n\t\treturn CLOCK_BOOTTIME;\n\tcase IORING_TIMEOUT_REALTIME:\n\t\treturn CLOCK_REALTIME;\n\tdefault:\n\t\t\/* can't happen, vetted at prep time *\/\n\t\tWARN_ON_ONCE(1);\n\t\tfallthrough;\n\tcase 0:\n\t\treturn CLOCK_MONOTONIC;\n\t}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":281068,"func":"xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family,\n\t\t   u8 dir, struct flow_cache_object *old_obj, void *ctx)\n{\n\tstruct xfrm_policy *pol;\n\n\tif (old_obj)\n\t\txfrm_pol_put(container_of(old_obj, struct xfrm_policy, flo));\n\n\tpol = __xfrm_policy_lookup(net, fl, family, flow_to_policy_dir(dir));\n\tif (IS_ERR_OR_NULL(pol))\n\t\treturn ERR_CAST(pol);\n\n\t\/* Resolver returns two references:\n\t * one for cache and one for caller of flow_cache_lookup() *\/\n\txfrm_pol_hold(pol);\n\n\treturn &pol->flo;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":225848,"func":"GF_Err gnra_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":482469,"func":"compileSwapDots(const FileInfo *file, CharsString *source, CharsString *dest) {\n\tint k = 0;\n\tint kk = 0;\n\tCharsString dotsSource;\n\tCharsString dotsDest;\n\tdest->length = 0;\n\tdotsSource.length = 0;\n\twhile (k <= source->length) {\n\t\tif (source->chars[k] != ',' && k != source->length)\n\t\t\tdotsSource.chars[dotsSource.length++] = source->chars[k];\n\t\telse {\n\t\t\tif (!parseDots(file, &dotsDest, &dotsSource)) return 0;\n\t\t\tdest->chars[dest->length++] = dotsDest.length + 1;\n\t\t\tfor (kk = 0; kk < dotsDest.length; kk++)\n\t\t\t\tdest->chars[dest->length++] = dotsDest.chars[kk];\n\t\t\tdotsSource.length = 0;\n\t\t}\n\t\tk++;\n\t}\n\treturn 1;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":308182,"func":"static u64 fastrpc_get_payload_size(struct fastrpc_invoke_ctx *ctx, int metalen)\n{\n\tu64 size = 0;\n\tint i;\n\n\tsize = ALIGN(metalen, FASTRPC_ALIGN);\n\tfor (i = 0; i < ctx->nscalars; i++) {\n\t\tif (ctx->args[i].fd == 0 || ctx->args[i].fd == -1) {\n\n\t\t\tif (ctx->olaps[i].offset == 0)\n\t\t\t\tsize = ALIGN(size, FASTRPC_ALIGN);\n\n\t\t\tsize += (ctx->olaps[i].mend - ctx->olaps[i].mstart);\n\t\t}\n\t}\n\n\treturn size;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":424966,"func":"static void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans,\n\t\t\t\t\t      unsigned long *flags)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\n\tlockdep_assert_held(&trans_pcie->reg_lock);\n\n\t\/*\n\t * Fool sparse by faking we acquiring the lock - sparse will\n\t * track nic_access anyway.\n\t *\/\n\t__acquire(&trans_pcie->reg_lock);\n\n\tif (trans_pcie->cmd_hold_nic_awake)\n\t\tgoto out;\n\n\t__iwl_trans_pcie_clear_bit(trans, CSR_GP_CNTRL,\n\t\t\t\t   BIT(trans->trans_cfg->csr->flag_mac_access_req));\n\t\/*\n\t * Above we read the CSR_GP_CNTRL register, which will flush\n\t * any previous writes, but we need the write that clears the\n\t * MAC_ACCESS_REQ bit to be performed before any other writes\n\t * scheduled on different CPUs (after we drop reg_lock).\n\t *\/\nout:\n\tspin_unlock_irqrestore(&trans_pcie->reg_lock, *flags);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":344253,"func":"lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {\n  if (y < 0) {  \/* shift right? *\/\n    if (y <= -NBITS) return 0;\n    else return intop(>>, x, -y);\n  }\n  else {  \/* shift left *\/\n    if (y >= NBITS) return 0;\n    else return intop(<<, x, y);\n  }\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":270772,"func":"static unsigned char to_hexa(unsigned char c)\n{\n\tif (c < 10)\n\t\tc += '0';\n\telse\n\t\tc += 'a' - 10;\n\n\treturn c;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":238812,"func":"set_csearch_until(int t_cmd)\n{\n    last_t_cmd = t_cmd;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":289249,"func":"static int snd_pcm_oss_make_ready_locked(struct snd_pcm_substream *substream)\n{\n\tstruct snd_pcm_runtime *runtime;\n\tint err;\n\n\truntime = substream->runtime;\n\tif (runtime->oss.params) {\n\t\terr = snd_pcm_oss_change_params_locked(substream);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\tif (runtime->oss.prepare) {\n\t\terr = snd_pcm_oss_prepare(substream);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":175699,"func":"  virtual bool cellular_enabled() const { return false; }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":231770,"func":"TEST_F(QuicUnencryptedServerTransportTest, TestBadPacketProtectionLevel) {\n  \/\/ Version negotiation has no protection level.\n  auto packet = VersionNegotiationPacketBuilder(\n                    *clientConnectionId \/* src *\/,\n                    getTestConnectionId(1) \/* dest *\/,\n                    {QuicVersion::MVFST})\n                    .buildPacket();\n  EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));\n  deliverData(packet.second->clone());\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":317049,"func":"static int smack_socket_post_create(struct socket *sock, int family,\n\t\t\t\t    int type, int protocol, int kern)\n{\n\tstruct socket_smack *ssp;\n\n\tif (sock->sk == NULL)\n\t\treturn 0;\n\n\t\/*\n\t * Sockets created by kernel threads receive web label.\n\t *\/\n\tif (unlikely(current->flags & PF_KTHREAD)) {\n\t\tssp = sock->sk->sk_security;\n\t\tssp->smk_in = &smack_known_web;\n\t\tssp->smk_out = &smack_known_web;\n\t}\n\n\tif (family != PF_INET)\n\t\treturn 0;\n\t\/*\n\t * Set the outbound netlbl.\n\t *\/\n\treturn smack_netlbl_add(sock->sk);\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":500042,"func":"valid_cksumtype(krb5_cksumtype ctype)\n        {\n        if (!krb5_loaded)\n                load_krb5_dll();\n\n        if ( p_valid_cksumtype )\n                return(p_valid_cksumtype(ctype));\n        else\n                return KRB5KRB_ERR_GENERIC;\n        }","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":446104,"func":"static int atusb_command(struct atusb *atusb, u8 cmd, u8 arg)\n{\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\n\tdev_dbg(&usb_dev->dev, \"%s: cmd = 0x%x\\n\", __func__, cmd);\n\treturn atusb_control_msg(atusb, usb_sndctrlpipe(usb_dev, 0),\n\t\t\t\t cmd, ATUSB_REQ_TO_DEV, arg, 0, NULL, 0, 1000);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":462323,"func":"status_add_symbol_id(ushort * idlist, int nid, ushort new_id)\n{\n    int i;\n    ushort *idp;\n    ushort t1, t2;\n\n    for (i = 0, idp = idlist; i < nid; i++)\n        if (new_id <= *idp)\n            break;\n    if (new_id == *idp)         \/* duplicate item *\/\n        return nid;\n    \/* insert new_id in front of *idp *\/\n    for (t1 = new_id; i < nid; i++) {\n        t2 = *idp;\n        *idp++ = t1;\n        t1 = t2;\n    }\n    *idp = t1;\n    return nid + 1;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":508300,"func":"static bool not_null_fields_have_null_values(TABLE *table)\n{\n  Field **orig_field= table->field;\n  Field **filled_field= table->field_to_fill();\n\n  if (filled_field != orig_field)\n  {\n    THD *thd=table->in_use;\n    for (uint i=0; i < table->s->fields; i++)\n    {\n      Field *of= orig_field[i];\n      Field *ff= filled_field[i];\n      if (ff != of)\n      {\n        \/\/ copy after-update flags to of, copy before-update flags to ff\n        swap_variables(uint32, of->flags, ff->flags);\n        if (ff->is_real_null())\n        {\n          ff->set_notnull(); \/\/ for next row WHERE condition in UPDATE\n          if (convert_null_to_field_value_or_error(of) || thd->is_error())\n            return true;\n        }\n      }\n    }\n  }\n\n  return false;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":252442,"func":"mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip,\n                                        mz_uint file_index) {\n  mz_uint m_bit_flag;\n  const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);\n  if (!p) return MZ_FALSE;\n  m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);\n  return (m_bit_flag & 1);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":381860,"func":"static struct buffer_head *udf_getblk(struct inode *inode, udf_pblk_t block,\n\t\t\t\t      int create, int *err)\n{\n\tstruct buffer_head *bh;\n\tstruct buffer_head dummy;\n\n\tdummy.b_state = 0;\n\tdummy.b_blocknr = -1000;\n\t*err = udf_get_block(inode, block, &dummy, create);\n\tif (!*err && buffer_mapped(&dummy)) {\n\t\tbh = sb_getblk(inode->i_sb, dummy.b_blocknr);\n\t\tif (buffer_new(&dummy)) {\n\t\t\tlock_buffer(bh);\n\t\t\tmemset(bh->b_data, 0x00, inode->i_sb->s_blocksize);\n\t\t\tset_buffer_uptodate(bh);\n\t\t\tunlock_buffer(bh);\n\t\t\tmark_buffer_dirty_inode(bh, inode);\n\t\t}\n\t\treturn bh;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":359495,"func":"DEFUN (show_ip_bgp_ipv4_rsclient_summary,\n      show_ip_bgp_ipv4_rsclient_summary_cmd,\n      \"show ip bgp ipv4 (unicast|multicast) rsclient summary\",\n       SHOW_STR\n       IP_STR\n       BGP_STR\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Information about Route Server Clients\\n\"\n       \"Summary of all Route Server Clients\\n\")\n{\n  if (strncmp (argv[0], \"m\", 1) == 0)\n    return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);\n\n  return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":318979,"func":"f_assert_exception(typval_T *argvars, typval_T *rettv)\n{\n    garray_T\tga;\n    char_u\t*error;\n\n    if (in_vim9script()\n\t    && (check_for_string_arg(argvars, 0) == FAIL\n\t\t|| check_for_opt_string_arg(argvars, 1) == FAIL))\n\treturn;\n\n    error = tv_get_string_chk(&argvars[0]);\n    if (*get_vim_var_str(VV_EXCEPTION) == NUL)\n    {\n\tprepare_assert_error(&ga);\n\tga_concat(&ga, (char_u *)\"v:exception is not set\");\n\tassert_error(&ga);\n\tga_clear(&ga);\n\trettv->vval.v_number = 1;\n    }\n    else if (error != NULL\n\t&& strstr((char *)get_vim_var_str(VV_EXCEPTION), (char *)error) == NULL)\n    {\n\tprepare_assert_error(&ga);\n\tfill_assert_error(&ga, &argvars[1], NULL, &argvars[0],\n\t\t\t\t  get_vim_var_tv(VV_EXCEPTION), ASSERT_OTHER);\n\tassert_error(&ga);\n\tga_clear(&ga);\n\trettv->vval.v_number = 1;\n    }\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":369346,"func":"static int io_mkdirat_prep(struct io_kiocb *req,\n\t\t\t    const struct io_uring_sqe *sqe)\n{\n\tstruct io_mkdir *mkd = &req->mkdir;\n\tconst char __user *fname;\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->off || sqe->rw_flags || sqe->buf_index ||\n\t    sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\tif (unlikely(req->flags & REQ_F_FIXED_FILE))\n\t\treturn -EBADF;\n\n\tmkd->dfd = READ_ONCE(sqe->fd);\n\tmkd->mode = READ_ONCE(sqe->len);\n\n\tfname = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\tmkd->filename = getname(fname);\n\tif (IS_ERR(mkd->filename))\n\t\treturn PTR_ERR(mkd->filename);\n\n\treq->flags |= REQ_F_NEED_CLEANUP;\n\treturn 0;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":338190,"func":"bool WasmBinaryBuilder::maybeVisitRefTest(Expression*& out, uint32_t code) {\n  if (code == BinaryConsts::RefTest) {\n    auto* rtt = popNonVoidExpression();\n    auto* ref = popNonVoidExpression();\n    out = Builder(wasm).makeRefTest(ref, rtt);\n    return true;\n  } else if (code == BinaryConsts::RefTestStatic) {\n    auto intendedType = getIndexedHeapType();\n    auto* ref = popNonVoidExpression();\n    out = Builder(wasm).makeRefTest(ref, intendedType);\n    return true;\n  }\n  return false;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":300797,"func":"bool tipc_sk_overlimit2(struct sock *sk, struct sk_buff *skb)\n{\n\tunsigned int lim = rcvbuf_limit(sk, skb);\n\tunsigned int qsize = sk_rmem_alloc_get(sk);\n\n\treturn (qsize > lim * 90 \/ 100);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":443695,"func":"utf32be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)\n{\n  const UChar* p = *pp;\n\n  (*pp) += 4;\n\n  if (*(p+2) == 0 && *(p+1) == 0 && *p == 0) {\n    int c, v;\n\n    p += 3;\n    if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n      return TRUE;\n    }\n\n    c = *p;\n    v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,\n                       (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));\n    if ((v | BIT_CTYPE_LOWER) != 0) {\n      \/* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. *\/\n      if (c >= 0xaa && c <= 0xba)\n        return FALSE;\n      else\n        return TRUE;\n    }\n    return (v != 0 ? TRUE : FALSE);\n  }\n\n  return FALSE;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":222559,"func":"void FunctionDefHelper::AttrValueWrapper::InitFromString(StringPiece val) {\n  if (val.size() >= 2 && val[0] == '$') {\n    proto.set_placeholder(val.data() + 1, val.size() - 1);\n  } else {\n    SetAttrValue(val, &proto);\n  }\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":272347,"func":"cms_context_init(cms_context *cms)\n{\n\tmemset(cms, '\\0', sizeof (*cms));\n\n\tcms->log = cms_common_log;\n\n\tcms->arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);\n\tif (!cms->arena)\n\t\tcnreterr(-1, cms, \"could not create cryptographic arena\");\n\n\tcms->selected_digest = -1;\n\n\tINIT_LIST_HEAD(&cms->pk12_ins);\n\tcms->pk12_out.fd = -1;\n\tcms->db_out = cms->dbx_out = cms->dbt_out = -1;\n\n\treturn 0;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":512729,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_null>(thd, this); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":412337,"func":"static ut64 baddr(RzBinFile *bf) {\n\tQnxObj *qo = bf->o->bin_obj;\n\treturn qo ? qo->lmfh.image_base : 0;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":196689,"func":"  void Compute(OpKernelContext* ctx) override {\n    Buffer* buf = nullptr;\n    OP_REQUIRES_OK(ctx, GetBuffer(ctx, def(), &buf));\n    core::ScopedUnref scope(buf);\n    Buffer::Tuple tuple;\n\n    std::size_t index = ctx->input(0).scalar<int>()();\n\n    OP_REQUIRES_OK(ctx, buf->Peek(index, &tuple));\n\n    OP_REQUIRES(\n        ctx, tuple.size() == (size_t)ctx->num_outputs(),\n        errors::InvalidArgument(\"Mismatch stage\/unstage: \", tuple.size(),\n                                \" vs. \", ctx->num_outputs()));\n\n    for (size_t i = 0; i < tuple.size(); ++i) {\n      ctx->set_output(i, tuple[i]);\n    }\n  }","target":1,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":262087,"func":"  bool operator==(const InstanceFeatureDimKey& other) const {\n    return (instance == other.instance) && (feature_dim == other.feature_dim);\n  }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":409431,"func":"term_get_fg_color(char_u *r, char_u *g, char_u *b)\n{\n    if (rfg_status.tr_progress == STATUS_GOT)\n    {\n\t*r = fg_r;\n\t*g = fg_g;\n\t*b = fg_b;\n    }\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":231007,"func":"envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t oldsize)\n{\n  mrb_callinfo *ci = mrb->c->cibase;\n\n  if (newbase == oldbase) return;\n  while (ci <= mrb->c->ci) {\n    struct REnv *e = mrb_vm_ci_env(ci);\n    mrb_value *st;\n\n    if (e && MRB_ENV_ONSTACK_P(e) &&\n        (st = e->stack) && oldbase <= st && st < oldbase+oldsize) {\n      ptrdiff_t off = e->stack - oldbase;\n\n      e->stack = newbase + off;\n    }\n\n    if (ci->proc && MRB_PROC_ENV_P(ci->proc) && e != MRB_PROC_ENV(ci->proc)) {\n      e = MRB_PROC_ENV(ci->proc);\n\n      if (e && MRB_ENV_ONSTACK_P(e) &&\n          (st = e->stack) && oldbase <= st && st < oldbase+oldsize) {\n        ptrdiff_t off = e->stack - oldbase;\n\n        e->stack = newbase + off;\n      }\n    }\n\n    ci->stack = newbase + (ci->stack - oldbase);\n    ci++;\n  }\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":365618,"func":"_asn1_set_name (asn1_node node, const char *name)\n{\n  unsigned int nsize;\n\n  if (node == NULL)\n    return node;\n\n  if (name == NULL)\n    {\n      node->name[0] = 0;\n      node->name_hash = hash_pjw_bare (node->name, 0);\n      return node;\n    }\n\n  nsize = _asn1_str_cpy (node->name, sizeof (node->name), name);\n  node->name_hash = hash_pjw_bare (node->name, nsize);\n\n  return node;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":503889,"func":"SCM_DEFINE (scm_basename, \"basename\", 1, 1, 0, \n            (SCM filename, SCM suffix),\n\t    \"Return the base name of the file name @var{filename}. The\\n\"\n\t    \"base name is the file name without any directory components.\\n\"\n\t    \"If @var{suffix} is provided, and is equal to the end of\\n\"\n\t    \"@var{filename}, it is removed also.\")\n#define FUNC_NAME s_scm_basename\n{\n  char *c_filename, *c_last_component;\n  SCM res;\n\n  scm_dynwind_begin (0);\n  c_filename = scm_to_utf8_string (filename);\n  scm_dynwind_free (c_filename);\n\n  c_last_component = last_component (c_filename);\n  if (!c_last_component)\n    res = filename;\n  else\n    res = scm_from_utf8_string (c_last_component);\n  scm_dynwind_end ();\n\n  if (!SCM_UNBNDP (suffix) &&\n      scm_is_true (scm_string_suffix_p (suffix, filename,\n                                        SCM_UNDEFINED, SCM_UNDEFINED,\n                                        SCM_UNDEFINED, SCM_UNDEFINED)))\n    res = scm_c_substring\n      (res, 0, scm_c_string_length (res) - scm_c_string_length (suffix));\n\n  return res;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":248236,"func":"static char *strndup(const char *s, size_t n)\n{\n\tchar *r;\n\n\tr = malloc(n + 1);\n\tif (!r)\n\t\treturn NULL;\n\n\tstrncpy(r, s, n);\n\tr[n] = 0;\n\n\treturn r;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":236187,"func":"void diST_box_del(GF_Box *s)\n{\n\tGF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;\n\tif (p->content_script_types) gf_free(p->content_script_types);\n\tgf_free(p);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":243989,"func":"void trgr_box_del(GF_Box *s)\n{\n\tGF_TrackGroupBox *ptr = (GF_TrackGroupBox *)s;\n\tif (ptr == NULL) return;\n\tgf_list_del(ptr->groups);\n\tgf_free(ptr);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":344759,"func":"put_u16(void *vp, u_int16_t v)\n{\n\tu_char *p = (u_char *)vp;\n\n\tp[0] = (u_char)(v >> 8) & 0xff;\n\tp[1] = (u_char)v & 0xff;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":90779,"func":"  GetPersistentHostQuotaTask(\n      QuotaManager* manager,\n      const std::string& host,\n      HostQuotaCallback* callback)\n      : DatabaseTaskBase(manager),\n        host_(host),\n        quota_(-1),\n        callback_(callback) {\n  }\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":273922,"func":"static void handle_ABOR(ctrl_t *ctrl, char *arg)\n{\n\tDBG(\"Aborting any current transfer ...\");\n\tif (do_abort(ctrl))\n\t\tsend_msg(ctrl->sd, \"426 Connection closed; transfer aborted.\\r\\n\");\n\n\tsend_msg(ctrl->sd, \"226 Closing data connection.\\r\\n\");\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":254891,"func":"DepsTracker::State GroupFromFirstDocumentTransformation::addDependencies(DepsTracker* deps) const {\n    for (auto&& expr : _accumulatorExprs) {\n        expr.second->addDependencies(deps);\n    }\n\n    \/\/ This stage will replace the entire document with a new document, so any existing fields\n    \/\/ will be replaced and cannot be required as dependencies. We use EXHAUSTIVE_ALL here\n    \/\/ instead of EXHAUSTIVE_FIELDS, as in ReplaceRootTransformation, because the stages that\n    \/\/ follow a $group stage should not depend on document metadata.\n    return DepsTracker::State::EXHAUSTIVE_ALL;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":294683,"func":"equal_gen(VALUE self, VALUE other)\n{\n    get_d1(self);\n\n    if (k_numeric_p(other))\n\treturn f_eqeq_p(m_real_local_jd(dat), other);\n    else if (k_date_p(other))\n\treturn f_eqeq_p(m_real_local_jd(dat), f_jd(other));\n    return rb_num_coerce_cmp(self, other, id_eqeq_p);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":484809,"func":"static u16 xennet_select_queue(struct net_device *dev, struct sk_buff *skb,\n\t\t\t       struct net_device *sb_dev)\n{\n\tunsigned int num_queues = dev->real_num_tx_queues;\n\tu32 hash;\n\tu16 queue_idx;\n\n\t\/* First, check if there is only one queue *\/\n\tif (num_queues == 1) {\n\t\tqueue_idx = 0;\n\t} else {\n\t\thash = skb_get_hash(skb);\n\t\tqueue_idx = hash % num_queues;\n\t}\n\n\treturn queue_idx;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":248335,"func":"static void cfg_indent(FILE *fp, int indent)\n{\n\twhile (indent--)\n\t\tfprintf(fp, \"  \");\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":512664,"func":"bool in_vector::find(Item *item)\n{\n  uchar *result=get_value(item);\n  if (!result || !used_count)\n    return false;\t\t\t\t\/\/ Null value\n\n  uint start,end;\n  start=0; end=used_count-1;\n  while (start != end)\n  {\n    uint mid=(start+end+1)\/2;\n    int res;\n    if ((res=(*compare)(collation, base+mid*size, result)) == 0)\n      return true;\n    if (res < 0)\n      start=mid;\n    else\n      end=mid-1;\n  }\n  return ((*compare)(collation, base+start*size, result) == 0);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":195409,"func":"\nvoid gitn_box_del(GF_Box *s)\n{\n\tu32 i;\n\tGroupIdToNameBox *ptr = (GroupIdToNameBox *)s;\n\tif (ptr == NULL) return;\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tif (ptr->entries[i].name) gf_free(ptr->entries[i].name);\n\t}\n\tif (ptr->entries) gf_free(ptr->entries);\n\tgf_free(ptr);","target":1,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":513093,"func":"  With_subquery_cache(): m_with_subquery(false) { }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":344742,"func":"colon(char *cp)\n{\n\tint flag = 0;\n\n\tif (*cp == ':')\t\t\/* Leading colon is part of file name. *\/\n\t\treturn NULL;\n\tif (*cp == '[')\n\t\tflag = 1;\n\n\tfor (; *cp; ++cp) {\n\t\tif (*cp == '@' && *(cp+1) == '[')\n\t\t\tflag = 1;\n\t\tif (*cp == ']' && *(cp+1) == ':' && flag)\n\t\t\treturn (cp+1);\n\t\tif (*cp == ':' && !flag)\n\t\t\treturn (cp);\n\t\tif (*cp == '\/')\n\t\t\treturn NULL;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":300751,"func":"static bool tipc_sockaddr_is_sane(struct sockaddr_tipc *addr)\n{\n\tif (addr->family != AF_TIPC)\n\t\treturn false;\n\tif (addr->addrtype == TIPC_SERVICE_RANGE)\n\t\treturn (addr->addr.nameseq.lower <= addr->addr.nameseq.upper);\n\treturn (addr->addrtype == TIPC_SERVICE_ADDR ||\n\t\taddr->addrtype == TIPC_SOCKET_ADDR);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":484709,"func":"void mobi_buffer_free(MOBIBuffer *buf) {\n\tif (buf == NULL) { return; }\n\tif (buf->data != NULL) {\n\t\tfree(buf->data);\n\t}\n\tfree(buf);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":281149,"func":"void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, bool task_valid)\n{\n\tstruct audit_buffer *audit_buf;\n\n\taudit_buf = xfrm_audit_start(\"SPD-add\");\n\tif (audit_buf == NULL)\n\t\treturn;\n\txfrm_audit_helper_usrinfo(task_valid, audit_buf);\n\taudit_log_format(audit_buf, \" res=%u\", result);\n\txfrm_audit_common_policyinfo(xp, audit_buf);\n\taudit_log_end(audit_buf);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":369267,"func":"\nstatic __cold bool io_cancel_ctx_cb(struct io_wq_work *work, void *data)\n{\n\tstruct io_kiocb *req = container_of(work, struct io_kiocb, work);\n\n\treturn req->ctx == data;","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":313845,"func":"end_visual_mode()\n{\n    end_visual_mode_keep_button();\n    reset_held_button();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":466121,"func":"static int em_mul_ex(struct x86_emulate_ctxt *ctxt)\n{\n\tu8 ex = 0;\n\n\temulate_1op_rax_rdx(ctxt, \"mul\", ex);\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":338161,"func":"void WasmBinaryWriter::writeExports() {\n  if (wasm->exports.size() == 0) {\n    return;\n  }\n  BYN_TRACE(\"== writeexports\\n\");\n  auto start = startSection(BinaryConsts::Section::Export);\n  o << U32LEB(wasm->exports.size());\n  for (auto& curr : wasm->exports) {\n    BYN_TRACE(\"write one\\n\");\n    writeInlineString(curr->name.str);\n    o << U32LEB(int32_t(curr->kind));\n    switch (curr->kind) {\n      case ExternalKind::Function:\n        o << U32LEB(getFunctionIndex(curr->value));\n        break;\n      case ExternalKind::Table:\n        o << U32LEB(0);\n        break;\n      case ExternalKind::Memory:\n        o << U32LEB(0);\n        break;\n      case ExternalKind::Global:\n        o << U32LEB(getGlobalIndex(curr->value));\n        break;\n      case ExternalKind::Tag:\n        o << U32LEB(getTagIndex(curr->value));\n        break;\n      default:\n        WASM_UNREACHABLE(\"unexpected extern kind\");\n    }\n  }\n  finishSection(start);\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":90108,"func":"  virtual void AddNetworkObserver(const std::string& service_path,\n                                  NetworkObserver* observer) {\n    DCHECK(observer);\n    if (!EnsureCrosLoaded())\n      return;\n    NetworkObserverMap::iterator iter = network_observers_.find(service_path);\n    NetworkObserverList* oblist;\n    if (iter != network_observers_.end()) {\n      oblist = iter->second;\n    } else {\n      std::pair<NetworkObserverMap::iterator, bool> inserted =\n        network_observers_.insert(\n            std::make_pair<std::string, NetworkObserverList*>(\n                service_path,\n                new NetworkObserverList(this, service_path)));\n      oblist = inserted.first->second;\n    }\n    if (!oblist->HasObserver(observer))\n      oblist->AddObserver(observer);\n  }\n","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":459511,"func":"static int __init stack_map_init(void)\n{\n\tint cpu;\n\tstruct stack_map_irq_work *work;\n\n\tfor_each_possible_cpu(cpu) {\n\t\twork = per_cpu_ptr(&up_read_work, cpu);\n\t\tinit_irq_work(&work->irq_work, do_up_read);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":355640,"func":"fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip)\n{\n    init_evalarg(evalarg);\n    evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE;\n    if (eap != NULL)\n    {\n\tevalarg->eval_cstack = eap->cstack;\n\tif (getline_equal(eap->getline, eap->cookie, getsourceline))\n\t{\n\t    evalarg->eval_getline = eap->getline;\n\t    evalarg->eval_cookie = eap->cookie;\n\t}\n    }\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":351183,"func":"static double shp_length (SHPObject *feat) {\n  double length = 0.0;\n  if (feat->nParts == 0) {\n    length = length2d_polyline(feat->nVertices, feat->padfX, feat->padfY);\n  }\n  else {\n    for (int part = 0; part < feat->nParts; part++) {\n      int n;\n      if (part < feat->nParts - 1) {\n\tn = feat->panPartStart[part+1] - feat->panPartStart[part];\n      }\n      else {\n\tn = feat->nVertices - feat->panPartStart[part];\n      }\n      length += length2d_polyline (n,\n\t\t\t\t   &(feat->padfX[feat->panPartStart[part]]),\n\t\t\t\t   &(feat->padfY[feat->panPartStart[part]]));\n    }\n  }\n  return length;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":369375,"func":"\nvoid __io_uring_cancel(bool cancel_all)\n{\n\tio_uring_cancel_generic(cancel_all, NULL);","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":234841,"func":"int btrfs_map_sblock(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,\n\t\t     u64 logical, u64 *length,\n\t\t     struct btrfs_bio **bbio_ret)\n{\n\treturn __btrfs_map_block(fs_info, op, logical, length, bbio_ret, 0, 1);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":400112,"func":"void LogHandler::setupStdoutLogger() {\n  el::Logger *stdoutLogger = el::Loggers::getLogger(\"stdout\");\n  \/\/ Easylogging configurations\n  el::Configurations stdoutConf;\n  stdoutConf.setToDefault();\n  \/\/ Values are always std::string\n  stdoutConf.setGlobally(el::ConfigurationType::Format, \"%msg\");\n  stdoutConf.setGlobally(el::ConfigurationType::ToStandardOutput, \"true\");\n  stdoutConf.setGlobally(el::ConfigurationType::ToFile, \"false\");\n  el::Loggers::reconfigureLogger(stdoutLogger, stdoutConf);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":336129,"func":"static struct ip6_tnl *ip6gre_tunnel_find(struct net *net,\n\t\t\t\t\t   const struct __ip6_tnl_parm *parms,\n\t\t\t\t\t   int type)\n{\n\tconst struct in6_addr *remote = &parms->raddr;\n\tconst struct in6_addr *local = &parms->laddr;\n\t__be32 key = parms->i_key;\n\tint link = parms->link;\n\tstruct ip6_tnl *t;\n\tstruct ip6_tnl __rcu **tp;\n\tstruct ip6gre_net *ign = net_generic(net, ip6gre_net_id);\n\n\tfor (tp = __ip6gre_bucket(ign, parms);\n\t     (t = rtnl_dereference(*tp)) != NULL;\n\t     tp = &t->next)\n\t\tif (ipv6_addr_equal(local, &t->parms.laddr) &&\n\t\t    ipv6_addr_equal(remote, &t->parms.raddr) &&\n\t\t    key == t->parms.i_key &&\n\t\t    link == t->parms.link &&\n\t\t    type == t->dev->type)\n\t\t\tbreak;\n\n\treturn t;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":505657,"func":"void smtp_command_parser_deinit(struct smtp_command_parser **_parser)\n{\n\tstruct smtp_command_parser *parser = *_parser;\n\n\ti_stream_unref(&parser->data);\n\ti_free(parser->state.cmd_name);\n\ti_free(parser->state.cmd_params);\n\ti_free(parser->error);\n\ti_stream_unref(&parser->input);\n\ti_free(parser);\n\t*_parser = NULL;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":261957,"func":"njs_string_object_validate(njs_vm_t *vm, njs_value_t *object)\n{\n    njs_int_t  ret;\n\n    if (njs_slow_path(njs_is_null_or_undefined(object))) {\n        njs_type_error(vm, \"cannot convert undefined to object\");\n        return NJS_ERROR;\n    }\n\n    if (njs_slow_path(!njs_is_string(object))) {\n        ret = njs_value_to_string(vm, object, object);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":281089,"func":"bool xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,\n\t\t\t unsigned short family)\n{\n\tswitch (family) {\n\tcase AF_INET:\n\t\treturn __xfrm4_selector_match(sel, fl);\n\tcase AF_INET6:\n\t\treturn __xfrm6_selector_match(sel, fl);\n\t}\n\treturn false;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":473850,"func":"is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc ARG_UNUSED)\n{\n  const UChar c = *s;\n  if (c <= 0x7e || c == 0x8e || c == 0x8f)\n    return TRUE;\n  else\n    return FALSE;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":234869,"func":"static inline void btrfs_end_bbio(struct btrfs_bio *bbio, struct bio *bio)\n{\n\tbio->bi_private = bbio->private;\n\tbio->bi_end_io = bbio->end_io;\n\tbio_endio(bio);\n\n\tbtrfs_put_bbio(bbio);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":248277,"func":"DLLIMPORT cfg_t *cfg_opt_gettsec(cfg_opt_t *opt, const char *title)\n{\n\tlong int i;\n\n\tif (!opt || !title) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tif (!is_set(CFGF_TITLE, opt->flags)) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\ti = cfg_opt_gettsecidx(opt, title);\n\tif (i >= 0)\n\t\treturn cfg_opt_getnsec(opt, i);\n\n\terrno = ENOENT;\n\treturn NULL;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":307867,"func":"char *ciEnv::name_buffer(int req_len) {\n  if (_name_buffer_len < req_len) {\n    if (_name_buffer == NULL) {\n      _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);\n      _name_buffer_len = req_len;\n    } else {\n      _name_buffer =\n        (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);\n      _name_buffer_len = req_len;\n    }\n  }\n  return _name_buffer;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":387757,"func":"bool InstanceKlass::has_redefined_this_or_super() const {\n  const Klass* klass = this;\n  while (klass != NULL) {\n    if (InstanceKlass::cast(klass)->has_been_redefined()) {\n      return true;\n    }\n    klass = klass->super();\n  }\n  return false;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":101668,"func":"void WebProcessProxy::didDestroyFrame(uint64_t frameID)\n{\n    ASSERT(isGoodKey<WebFrameProxyMap>(frameID));\n    m_frameMap.remove(frameID);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":512824,"func":"Item_equal::Item_equal(THD *thd, const Type_handler *handler,\n                       Item *f1, Item *f2, bool with_const_item):\n  Item_bool_func(thd), eval_item(0), cond_false(0), cond_true(0),\n  context_field(NULL), link_equal_fields(FALSE),\n  m_compare_handler(handler),\n  m_compare_collation(f2->collation.collation)\n{\n  const_item_cache= 0;\n  with_const= with_const_item;\n  equal_items.push_back(f1, thd->mem_root);\n  equal_items.push_back(f2, thd->mem_root);\n  upper_levels= NULL;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":310175,"func":"has_colors(void)\n{\n    return NCURSES_SP_NAME(has_colors) (CURRENT_SCREEN);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":225036,"func":"setKeepalivesCount(PGconn *conn)\n{\n\tint\t\t\tcount;\n\n\tif (conn->keepalives_count == NULL)\n\t\treturn 1;\n\n\tif (!parse_int_param(conn->keepalives_count, &count, conn,\n\t\t\t\t\t\t \"keepalives_count\"))\n\t\treturn 0;\n\tif (count < 0)\n\t\tcount = 0;\n\n#ifdef TCP_KEEPCNT\n\tif (setsockopt(conn->sock, IPPROTO_TCP, TCP_KEEPCNT,\n\t\t\t\t   (char *) &count, sizeof(count)) < 0)\n\t{\n\t\tchar\t\tsebuf[PG_STRERROR_R_BUFLEN];\n\n\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"%s(%s) failed: %s\\n\"),\n\t\t\t\t\t\t  \"setsockopt\",\n\t\t\t\t\t\t  \"TCP_KEEPCNT\",\n\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\treturn 0;\n\t}\n#endif\n\n\treturn 1;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":200163,"func":"static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)\n{\n\tstruct elo_priv *priv;\n\tint ret;\n\tstruct usb_device *udev;\n\n\tif (!hid_is_usb(hdev))\n\t\treturn -EINVAL;\n\n\tpriv = kzalloc(sizeof(*priv), GFP_KERNEL);\n\tif (!priv)\n\t\treturn -ENOMEM;\n\n\tINIT_DELAYED_WORK(&priv->work, elo_work);\n\tudev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));\n\tpriv->usbdev = usb_get_dev(udev);\n\n\thid_set_drvdata(hdev, priv);\n\n\tret = hid_parse(hdev);\n\tif (ret) {\n\t\thid_err(hdev, \"parse failed\\n\");\n\t\tgoto err_free;\n\t}\n\n\tret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);\n\tif (ret) {\n\t\thid_err(hdev, \"hw start failed\\n\");\n\t\tgoto err_free;\n\t}\n\n\tif (elo_broken_firmware(priv->usbdev)) {\n\t\thid_info(hdev, \"broken firmware found, installing workaround\\n\");\n\t\tqueue_delayed_work(wq, &priv->work, ELO_PERIODIC_READ_INTERVAL);\n\t}\n\n\treturn 0;\nerr_free:\n\tkfree(priv);\n\treturn ret;\n}","target":1,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":473886,"func":"utf32be_get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t\t\t   const OnigUChar* p, const OnigUChar* end,\n\t\t\t\t   OnigCaseFoldCodeItem items[],\n\t\t\t\t   OnigEncoding enc)\n{\n  return onigenc_unicode_get_case_fold_codes_by_str(enc,\n\t\t\t\t\t\t    flag, p, end, items);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":101658,"func":"void WebProcessProxy::addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver* messageReceiver)\n{\n    m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":401574,"func":"void add_disk_randomness(struct gendisk *disk)\n{\n\tif (!disk || !disk->random)\n\t\treturn;\n\t\/* first major is 1, so we get >= 0x200 here *\/\n\tadd_timer_randomness(disk->random, 0x100 + disk_devt(disk));\n\ttrace_add_disk_randomness(disk_devt(disk), ENTROPY_BITS(&input_pool));\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":508316,"func":"set_new_item_local_context(THD *thd, Item_ident *item, TABLE_LIST *table_ref)\n{\n  Name_resolution_context *context;\n  if (!(context= new (thd->mem_root) Name_resolution_context))\n    return TRUE;\n  context->init();\n  context->first_name_resolution_table=\n    context->last_name_resolution_table= table_ref;\n  item->context= context;\n  return FALSE;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":509545,"func":"int ha_maria::index_prev(uchar * buf)\n{\n  DBUG_ASSERT(inited == INDEX);\n  register_handler(file);\n  int error= maria_rprev(file, buf, active_index);\n  return error;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":338106,"func":"Name WasmBinaryBuilder::escape(Name name) {\n  bool allIdChars = true;\n  for (const char* p = name.str; allIdChars && *p; p++) {\n    allIdChars = isIdChar(*p);\n  }\n  if (allIdChars) {\n    return name;\n  }\n  \/\/ encode name, if at least one non-idchar (per WebAssembly spec) was found\n  std::string escaped;\n  for (const char* p = name.str; *p; p++) {\n    char ch = *p;\n    if (isIdChar(ch)) {\n      escaped.push_back(ch);\n      continue;\n    }\n    \/\/ replace non-idchar with `\\xx` escape\n    escaped.push_back('\\\\');\n    escaped.push_back(formatNibble(ch >> 4));\n    escaped.push_back(formatNibble(ch & 15));\n  }\n  return escaped;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":292150,"func":"LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {\n   \/\/ resolve klass\n  _resolved_klass = pool->klass_ref_at(index, CHECK);\n\n  \/\/ Get name, signature, and static klass\n  _name          = pool->name_ref_at(index);\n  _signature     = pool->signature_ref_at(index);\n  _tag           = pool->tag_ref_at(index);\n  _current_klass = pool->pool_holder();\n  _current_method = methodHandle();\n\n  \/\/ Coming from the constant pool always checks access\n  _check_access  = true;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":101656,"func":"void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& originalURL, const String& url, const String& title, const CoreIPC::DataReference& backForwardData)\n{\n    MESSAGE_CHECK_URL(originalURL);\n    MESSAGE_CHECK_URL(url);\n\n    WebBackForwardListItemMap::AddResult result = m_backForwardListItemMap.add(itemID, 0);\n    if (result.isNewEntry) {\n        result.iterator->value = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID);\n        return;\n    }\n\n    result.iterator->value->setOriginalURL(originalURL);\n    result.iterator->value->setURL(url);\n    result.iterator->value->setTitle(title);\n    result.iterator->value->setBackForwardData(backForwardData.data(), backForwardData.size());\n}\n","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":281082,"func":"__xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir)\n{\n#ifdef CONFIG_XFRM_SUB_POLICY\n\tstruct xfrm_policy *pol;\n\n\tpol = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_SUB, fl, family, dir);\n\tif (pol != NULL)\n\t\treturn pol;\n#endif\n\treturn xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family, dir);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":386514,"func":"void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, const std::string& value) {\n    dw.dxfString(  0, \"XRECORD\");\n    dw.dxfHex(5, handle);\n    dw.dxfHex(330, appDictionaryHandle);\n    dw.dxfString(100, \"AcDbXrecord\");\n    dw.dxfInt(280, 1);\n    dw.dxfString(1000, value);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":314512,"func":"PJ_DEF(unsigned) pjmedia_sdp_attr_remove_all(unsigned *count,\n\t\t\t\t\t     pjmedia_sdp_attr *attr_array[],\n\t\t\t\t\t     const char *name)\n{\n    unsigned i, removed = 0;\n    pj_str_t attr_name;\n\n    PJ_ASSERT_RETURN(count && attr_array && name, PJ_EINVAL);\n    PJ_ASSERT_RETURN(*count <= PJMEDIA_MAX_SDP_ATTR, PJ_ETOOMANY);\n\n    attr_name.ptr = (char*)name;\n    attr_name.slen = pj_ansi_strlen(name);\n\n    for (i=0; i<*count; ) {\n\tif (pj_strcmp(&attr_array[i]->name, &attr_name)==0) {\n\t    pj_array_erase(attr_array, sizeof(pjmedia_sdp_attr*),\n\t\t\t   *count, i);\n\t    --(*count);\n\t    ++removed;\n\t} else {\n\t    ++i;\n\t}   \n    }\n\n    return removed;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":286719,"func":"SWTPM_CheckHash(const unsigned char *in, uint32_t in_length,\n                unsigned char **out, uint32_t *out_length)\n{\n    TPM_RESULT rc = 0;\n    unsigned char *dest = NULL;\n    unsigned char hashbuf[SHA256_DIGEST_LENGTH];\n    const unsigned char *data = &in[sizeof(hashbuf)];\n    uint32_t data_length = in_length - sizeof(hashbuf);\n\n    \/* hash the data *\/\n    SHA256(data, data_length, hashbuf);\n\n    if (memcmp(in, hashbuf, sizeof(hashbuf))) {\n        logprintf(STDOUT_FILENO, \"Verification of hash failed. \"\n                  \"Data integrity is compromised\\n\");\n        rc = TPM_FAIL;\n    }\n\n    if (rc == 0) {\n        dest = malloc(data_length);\n        if (dest) {\n            *out = dest;\n            *out_length = data_length;\n            memcpy(dest, data, data_length);\n        } else {\n            logprintf(STDOUT_FILENO,\n                      \"Could not allocated %u bytes.\\n\", data_length);\n            rc = TPM_FAIL;\n        }\n    }\n\n    return rc;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":210834,"func":"LogFilePrep(const char *fname, const char *backup, const char *idstring)\n{\n    char *logFileName = NULL;\n\n    if (asprintf(&logFileName, fname, idstring) == -1)\n        FatalError(\"Cannot allocate space for the log file name\\n\");\n\n    if (backup && *backup) {\n        struct stat buf;\n\n        if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {\n            char *suffix;\n            char *oldLog;\n\n            if ((asprintf(&suffix, backup, idstring) == -1) ||\n                (asprintf(&oldLog, \"%s%s\", logFileName, suffix) == -1)) {\n                FatalError(\"Cannot allocate space for the log file name\\n\");\n            }\n            free(suffix);\n\n            if (rename(logFileName, oldLog) == -1) {\n                FatalError(\"Cannot move old log file \\\"%s\\\" to \\\"%s\\\"\\n\",\n                           logFileName, oldLog);\n            }\n            free(oldLog);\n        }\n    }\n    else {\n        if (remove(logFileName) != 0 && errno != ENOENT) {\n            FatalError(\"Cannot remove old log file \\\"%s\\\": %s\\n\",\n                       logFileName, strerror(errno));\n        }\n    }\n\n    return logFileName;\n}","target":1,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":291828,"func":"static void destroy_cm(struct rtrs_clt_con *con)\n{\n\trdma_destroy_id(con->c.cm_id);\n\tcon->c.cm_id = NULL;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":389704,"func":"eval_env_var(char_u **arg, typval_T *rettv, int evaluate)\n{\n    char_u\t*string = NULL;\n    int\t\tlen;\n    int\t\tcc;\n    char_u\t*name;\n    int\t\tmustfree = FALSE;\n\n    ++*arg;\n    name = *arg;\n    len = get_env_len(arg);\n    if (evaluate)\n    {\n\tif (len == 0)\n\t    return FAIL; \/\/ invalid empty name\n\n\tcc = name[len];\n\tname[len] = NUL;\n\t\/\/ first try vim_getenv(), fast for normal environment vars\n\tstring = vim_getenv(name, &mustfree);\n\tif (string != NULL && *string != NUL)\n\t{\n\t    if (!mustfree)\n\t\tstring = vim_strsave(string);\n\t}\n\telse\n\t{\n\t    if (mustfree)\n\t\tvim_free(string);\n\n\t    \/\/ next try expanding things like $VIM and ${HOME}\n\t    string = expand_env_save(name - 1);\n\t    if (string != NULL && *string == '$')\n\t\tVIM_CLEAR(string);\n\t}\n\tname[len] = cc;\n\n\trettv->v_type = VAR_STRING;\n\trettv->vval.v_string = string;\n\trettv->v_lock = 0;\n    }\n\n    return OK;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":289287,"func":"static void snd_pcm_oss_proc_init(struct snd_pcm *pcm)\n{\n\tint stream;\n\tfor (stream = 0; stream < 2; ++stream) {\n\t\tstruct snd_info_entry *entry;\n\t\tstruct snd_pcm_str *pstr = &pcm->streams[stream];\n\t\tif (pstr->substream_count == 0)\n\t\t\tcontinue;\n\t\tentry = snd_info_create_card_entry(pcm->card, \"oss\", pstr->proc_root);\n\t\tif (entry) {\n\t\t\tentry->content = SNDRV_INFO_CONTENT_TEXT;\n\t\t\tentry->mode = S_IFREG | 0644;\n\t\t\tentry->c.text.read = snd_pcm_oss_proc_read;\n\t\t\tentry->c.text.write = snd_pcm_oss_proc_write;\n\t\t\tentry->private_data = pstr;\n\t\t\tif (snd_info_register(entry) < 0) {\n\t\t\t\tsnd_info_free_entry(entry);\n\t\t\t\tentry = NULL;\n\t\t\t}\n\t\t}\n\t\tpstr->oss.proc_entry = entry;\n\t}\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":225418,"func":"static int vidioc_s_fmt_cap(struct file *file, void *priv,\n\t\t\t    struct v4l2_format *fmt)\n{\n\treturn vidioc_try_fmt_cap(file, priv, fmt);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":402614,"func":"get_password_passthrough(PK11SlotInfo *slot UNUSED,\n\t\t\t PRBool retry, void *arg)\n{\n\tif (retry || !arg)\n\t\treturn NULL;\n\n\tchar *ret = strdup(arg);\n\tif (!ret)\n\t\terr(1, \"Could not allocate memory\");\n\n\treturn ret;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":301352,"func":"static int vfswrap_asys_int_recv(struct tevent_req *req, int *err)\n{\n\tstruct vfswrap_asys_state *state = tevent_req_data(\n\t\treq, struct vfswrap_asys_state);\n\n\tif (tevent_req_is_unix_error(req, err)) {\n\t\treturn -1;\n\t}\n\t*err = state->err;\n\treturn state->ret;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":436121,"func":"static void io_req_complete_failed(struct io_kiocb *req, long res)\n{\n\treq_set_fail(req);\n\tio_put_req(req);\n\tio_req_complete_post(req, res, 0);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":328818,"func":"R_API RList *retrieve_all_method_access_string_and_value(void) {\n\treturn retrieve_all_access_string_and_value (METHOD_ACCESS_FLAGS);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":244140,"func":"GF_Err extr_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ExtraDataBox *ptr = (GF_ExtraDataBox *)s;\n\n\te = gf_isom_box_parse((GF_Box**) &ptr->feci, bs);\n\tif (e) return e;\n\tif (!ptr->feci || ptr->feci->size > ptr->size) return GF_ISOM_INVALID_MEDIA;\n\tptr->data_length = (u32) (ptr->size - ptr->feci->size);\n\tptr->data = gf_malloc(sizeof(char)*ptr->data_length);\n\tif (!ptr->data) return GF_OUT_OF_MEM;\n\tgf_bs_read_data(bs, ptr->data, ptr->data_length);\n\n\treturn GF_OK;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":228444,"func":"String WddxPacket::packet_end() {\n  if (!m_packetClosed) {\n    if (m_manualPacketCreation) {\n      m_packetString.append(\"<\/struct>\");\n    }\n    m_packetString.append(\"<\/data><\/wddxPacket>\");\n  }\n  m_packetClosed = true;\n  return m_packetString.detach();\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":459183,"func":"void tcf_block_netif_keep_dst(struct tcf_block *block)\n{\n\tstruct tcf_block_owner_item *item;\n\n\tblock->keep_dst = true;\n\tlist_for_each_entry(item, &block->owner_list, list)\n\t\ttcf_block_owner_netif_keep_dst(block, item->q,\n\t\t\t\t\t       item->binder_type);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":512898,"func":"  bool excl_dep_on_in_subq_left_part(Item_in_subselect *subq_pred)\n  {\n    for (uint i= 0; i < arg_count; i++)\n    {\n      if (args[i]->const_item())\n        continue;\n      if (!args[i]->excl_dep_on_in_subq_left_part(subq_pred))\n        return false;\n    }\n    return true;\n  }","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":387873,"func":"bool InstanceKlass::is_same_or_direct_interface(Klass *k) const {\n  \/\/ Verify direct super interface\n  if (this == k) return true;\n  assert(k->is_interface(), \"should be an interface class\");\n  for (int i = 0; i < local_interfaces()->length(); i++) {\n    if (local_interfaces()->at(i) == k) {\n      return true;\n    }\n  }\n  return false;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":207068,"func":"static ssize_t remove_slot_store(struct kobject *kobj,\n\t\t\t\t struct kobj_attribute *attr,\n\t\t\t\t const char *buf, size_t nbytes)\n{\n\tchar drc_name[MAX_DRC_NAME_LEN];\n\tint rc;\n\tchar *end;\n\n\tif (nbytes >= MAX_DRC_NAME_LEN)\n\t\treturn 0;\n\n\tmemcpy(drc_name, buf, nbytes);\n\n\tend = strchr(drc_name, '\\n');\n\tif (!end)\n\t\tend = &drc_name[nbytes];\n\t*end = '\\0';\n\n\trc = dlpar_remove_slot(drc_name);\n\tif (rc)\n\t\treturn rc;\n\n\treturn nbytes;\n}","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":403478,"func":"int __init ecryptfs_init_kthread(void)\n{\n\tint rc = 0;\n\n\tmutex_init(&ecryptfs_kthread_ctl.mux);\n\tinit_waitqueue_head(&ecryptfs_kthread_ctl.wait);\n\tINIT_LIST_HEAD(&ecryptfs_kthread_ctl.req_list);\n\tecryptfs_kthread = kthread_run(&ecryptfs_threadfn, NULL,\n\t\t\t\t       \"ecryptfs-kthread\");\n\tif (IS_ERR(ecryptfs_kthread)) {\n\t\trc = PTR_ERR(ecryptfs_kthread);\n\t\tprintk(KERN_ERR \"%s: Failed to create kernel thread; rc = [%d]\"\n\t\t       \"\\n\", __func__, rc);\n\t}\n\treturn rc;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":427244,"func":"static int funcname (LexState *ls, expdesc *v) {\n  \/* funcname -> NAME {fieldsel} [':' NAME] *\/\n  int ismethod = 0;\n  singlevar(ls, v);\n  while (ls->t.token == '.')\n    fieldsel(ls, v);\n  if (ls->t.token == ':') {\n    ismethod = 1;\n    fieldsel(ls, v);\n  }\n  return ismethod;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":221684,"func":"int Socket::getPort() {\n    return my_port;\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":376339,"func":"add_signers (CamelCipherValidity *validity,\n             const GString *signers)\n{\n\tCamelInternetAddress *address;\n\tgint i, count;\n\n\tg_return_if_fail (validity != NULL);\n\n\tif (!signers || !signers->str || !*signers->str)\n\t\treturn;\n\n\taddress = camel_internet_address_new ();\n\tg_return_if_fail (address != NULL);\n\n\tcount = camel_address_decode (CAMEL_ADDRESS (address), signers->str);\n\tfor (i = 0; i < count; i++) {\n\t\tconst gchar *name = NULL, *email = NULL;\n\n\t\tif (!camel_internet_address_get (address, i, &name, &email))\n\t\t\tbreak;\n\n\t\tcamel_cipher_validity_add_certinfo (validity, CAMEL_CIPHER_VALIDITY_SIGN, name, email);\n\t}\n\n\tg_object_unref (address);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":336571,"func":"RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id)\n{\n    for (auto channel: reds->channels) {\n        if (channel->type() == type && channel->id() == id) {\n            return channel.get();\n        }\n    }\n    return NULL;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":245709,"func":"static int add_xtinyproxy_header (struct conn_s *connptr)\n{\n        assert (connptr && connptr->server_fd >= 0);\n        return write_message (connptr->server_fd,\n                              \"X-Tinyproxy: %s\\r\\n\", connptr->client_ip_addr);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":90173,"func":"  virtual void RemoveCellularDataPlanObserver(\n      CellularDataPlanObserver* observer) {}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":482549,"func":"freeTranslationTable(TranslationTableHeader *t) {\n\tfor (int i = 0; i < MAX_EMPH_CLASSES && t->emphClassNames[i]; i++)\n\t\tfree(t->emphClassNames[i]);\n\tfor (int i = 0; t->sourceFiles[i]; i++) free(t->sourceFiles[i]);\n\tif (t->characterClasses) deallocateCharacterClasses(t);\n\tif (t->ruleNames) deallocateRuleNames(t);\n\tfree(t);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":276986,"func":"    ~SampleEncrypter() {\n        delete m_StreamCipher;\n    }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":359505,"func":"DEFUN (clear_bgp_as_soft,\n       clear_bgp_as_soft_cmd,\n       \"clear bgp <1-65535> soft\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear peers with the AS number\\n\"\n       \"Soft reconfig\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,\n\t\t\tBGP_CLEAR_SOFT_BOTH, argv[0]);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":292206,"func":"inbound_login_start (session *sess, char *nick, char *servname,\n\t\t\t\t\t\t\tconst message_tags_data *tags_data)\n{\n\tinbound_newnick (sess->server, sess->server->nick, nick, TRUE, tags_data);\n\tserver_set_name (sess->server, servname);\n\tif (sess->type == SESS_SERVER)\n\t\tlog_open_or_close (sess);\n\t\/* reset our away status *\/\n\tif (sess->server->reconnect_away)\n\t{\n\t\thandle_command (sess->server->server_session, \"away\", FALSE);\n\t\tsess->server->reconnect_away = FALSE;\n\t}\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":139251,"func":"void OverlayWindowViews::UpdateCustomControlsSize(\n    views::ControlImageButton* control_button) {\n  if (!control_button)\n    return;\n  UpdateButtonSize();\n  control_button->SetSize(button_size_);\n  if (control_button == first_custom_controls_view_.get()) {\n    first_custom_controls_view_->SetImage(\n        views::Button::STATE_NORMAL,\n        gfx::CreateVectorIcon(vector_icons::kPlayArrowIcon,\n                              button_size_.width() \/ 2, kControlIconColor));\n  }\n  if (control_button == second_custom_controls_view_.get()) {\n    second_custom_controls_view_->SetImage(\n        views::Button::STATE_NORMAL,\n        gfx::CreateVectorIcon(vector_icons::kPauseIcon,\n                              button_size_.width() \/ 2, kControlIconColor));\n  }\n  const gfx::ImageSkia control_background = gfx::CreateVectorIcon(\n      kPictureInPictureControlBackgroundIcon, button_size_.width(), kBgColor);\n  control_button->SetBackgroundImage(kBgColor, &control_background,\n                                     &control_background);\n}\n","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":512262,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_direct_ref>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":272357,"func":"digest_get_encryption_oid(cms_context *cms)\n{\n\tint i = cms->selected_digest;\n\treturn digest_params[i].digest_encryption_tag;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":513107,"func":"Item_bool_rowready_func2 *Eq_creator::create(THD *thd, Item *a, Item *b) const\n{\n  return new(thd->mem_root) Item_func_eq(thd, a, b);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":245199,"func":"get_table_name_from_tablespace(std::string &tablespace)\n{\n\tstd::size_t pos = tablespace.find(\"`.`\"); \/\/`db`.`table` separator\n\tif (pos != std::string::npos) {\n\t\ttablespace = tablespace.substr(pos+3);\n\t\ttablespace.erase(tablespace.size()-1); \/\/remove leading `\n\t}\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":401584,"func":"static void numa_crng_init(void)\n{\n\tschedule_work(&numa_crng_init_work);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":432214,"func":"static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)\n{\n    unsigned access_size_max = mr->ops->valid.max_access_size;\n\n    \/* Regions are assumed to support 1-4 byte accesses unless\n       otherwise specified.  *\/\n    if (access_size_max == 0) {\n        access_size_max = 4;\n    }\n\n    \/* Bound the maximum access by the alignment of the address.  *\/\n    if (!mr->ops->impl.unaligned) {\n#ifdef _MSC_VER\n        unsigned align_size_max = addr & (0ULL - addr);\n#else\n        unsigned align_size_max = addr & -addr;\n#endif\n        if (align_size_max != 0 && align_size_max < access_size_max) {\n            access_size_max = align_size_max;\n        }\n    }\n\n    \/* Don't attempt accesses larger than the maximum.  *\/\n    if (l > access_size_max) {\n        l = access_size_max;\n    }\n    l = pow2floor(l);\n\n    return l;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":333080,"func":"match_zref(\n    int\t\tsubidx,\n    int\t\t*bytelen)   \/\/ out: length of match in bytes\n{\n    int\t\tlen;\n\n    cleanup_zsubexpr();\n    if (re_extmatch_in == NULL || re_extmatch_in->matches[subidx] == NULL)\n    {\n\t\/\/ backref was not set, match an empty string\n\t*bytelen = 0;\n\treturn TRUE;\n    }\n\n    len = (int)STRLEN(re_extmatch_in->matches[subidx]);\n    if (cstrncmp(re_extmatch_in->matches[subidx], rex.input, &len) == 0)\n    {\n\t*bytelen = len;\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":462254,"func":"PJ_DEF(pj_status_t) pj_stun_msg_create_response(pj_pool_t *pool,\n\t\t\t\t\t\tconst pj_stun_msg *req_msg,\n\t\t\t\t\t\tunsigned err_code,\n\t\t\t\t\t\tconst pj_str_t *err_msg,\n\t\t\t\t\t\tpj_stun_msg **p_response)\n{\n    unsigned msg_type = req_msg->hdr.type;\n    pj_stun_msg *response = NULL;\n    pj_status_t status;\n\n    PJ_ASSERT_RETURN(pool && p_response, PJ_EINVAL);\n\n    PJ_ASSERT_RETURN(PJ_STUN_IS_REQUEST(msg_type), \n\t\t     PJNATH_EINSTUNMSGTYPE);\n\n    \/* Create response or error response *\/\n    if (err_code)\n\tmsg_type |= PJ_STUN_ERROR_RESPONSE_BIT;\n    else\n\tmsg_type |= PJ_STUN_SUCCESS_RESPONSE_BIT;\n\n    status = pj_stun_msg_create(pool, msg_type, req_msg->hdr.magic, \n\t\t\t\treq_msg->hdr.tsx_id, &response);\n    if (status != PJ_SUCCESS) {\n\treturn status;\n    }\n\n    \/* Add error code attribute *\/\n    if (err_code) {\n\tstatus = pj_stun_msg_add_errcode_attr(pool, response, \n\t\t\t\t\t      err_code, err_msg);\n\tif (status != PJ_SUCCESS) {\n\t    return status;\n\t}\n    }\n\n    *p_response = response;\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":336626,"func":"SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s)\n{\n    memset(s->config->taTicket.password, 0, sizeof(s->config->taTicket.password));\n    s->config->ticketing_enabled = FALSE;\n    return 0;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":463145,"func":"static int annotate_state_need_mbentry(annotate_state_t *state)\n{\n    int r = 0;\n\n    if (!state->mbentry && state->mailbox) {\n        r = mboxlist_lookup(state->mailbox->name, &state->ourmbentry, NULL);\n        if (r) {\n            syslog(LOG_ERR, \"Failed to lookup mbentry for %s: %s\",\n                    state->mailbox->name, error_message(r));\n            goto out;\n        }\n        state->mbentry = state->ourmbentry;\n    }\n\nout:\n    return r;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":281097,"func":"static void __xfrm_policy_link(struct xfrm_policy *pol, int dir)\n{\n\tstruct net *net = xp_net(pol);\n\n\tlist_add(&pol->walk.all, &net->xfrm.policy_all);\n\tnet->xfrm.policy_count[dir]++;\n\txfrm_pol_hold(pol);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":418781,"func":"mouse_has(int c)\n{\n    char_u\t*p;\n\n    for (p = p_mouse; *p; ++p)\n\tswitch (*p)\n\t{\n\t    case 'a': if (vim_strchr((char_u *)MOUSE_A, c) != NULL)\n\t\t\t  return TRUE;\n\t\t      break;\n\t    case MOUSE_HELP: if (c != MOUSE_RETURN && curbuf->b_help)\n\t\t\t\t return TRUE;\n\t\t\t     break;\n\t    default: if (c == *p) return TRUE; break;\n\t}\n    return FALSE;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":513153,"func":"sys_var *find_plugin_sysvar(st_plugin_int *plugin, st_mysql_sys_var *plugin_var)\n{\n  for (sys_var *var= plugin->system_vars; var; var= var->next)\n  {\n    sys_var_pluginvar *pvar=var->cast_pluginvar();\n    if (pvar->plugin_var == plugin_var)\n      return var;\n  }\n  return 0;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":225054,"func":"PQhostaddr(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn NULL;\n\n\t\/* Return the parsed IP address *\/\n\tif (conn->connhost != NULL && conn->connip != NULL)\n\t\treturn conn->connip;\n\n\treturn \"\";\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":348439,"func":"static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc,\n\tint len)\n{\n\tunsigned char *ptr = d;\n\tunsigned char c=0;\n\n\t*ptr++ = END;\n\twhile (len > 0) {\n\t\tif (len > 2)\n\t\t\tc = *s++;\n\t\telse if (len > 1)\n\t\t\tc = crc >> 8;\n\t\telse\n\t\t\tc = crc & 0xff;\n\n\t\tlen--;\n\n\t\tswitch (c) {\n\t\tcase END:\n\t\t\t*ptr++ = ESC;\n\t\t\t*ptr++ = ESC_END;\n\t\t\tbreak;\n\t\tcase ESC:\n\t\t\t*ptr++ = ESC;\n\t\t\t*ptr++ = ESC_ESC;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t*ptr++ = c;\n\t\t\tbreak;\n\t\t}\n\t}\n\t*ptr++ = END;\n\n\treturn ptr - d;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":385795,"func":"unsigned int full_name_hash(const unsigned char *name, unsigned int len)\n{\n\tunsigned long a, mask;\n\tunsigned long hash = 0;\n\n\tfor (;;) {\n\t\ta = load_unaligned_zeropad(name);\n\t\tif (len < sizeof(unsigned long))\n\t\t\tbreak;\n\t\thash += a;\n\t\thash *= 9;\n\t\tname += sizeof(unsigned long);\n\t\tlen -= sizeof(unsigned long);\n\t\tif (!len)\n\t\t\tgoto done;\n\t}\n\tmask = ~(~0ul << len*8);\n\thash += mask & a;\ndone:\n\treturn fold_hash(hash);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":450818,"func":"next_brace_sub (const char *cp, int flags)\n{\n  size_t depth = 0;\n  while (*cp != '\\0')\n    if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\\\')\n      {\n        if (*++cp == '\\0')\n          break;\n        ++cp;\n      }\n    else\n      {\n        if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0))\n          break;\n\n        if (*cp++ == '{')\n          depth++;\n      }\n\n  return *cp != '\\0' ? cp : NULL;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":278258,"func":"get_indent(void)\n{\n#ifdef FEAT_VARTABS\n    return get_indent_str_vtab(ml_get_curline(), (int)curbuf->b_p_ts,\n\t\t\t\t\t\t curbuf->b_p_vts_array, FALSE);\n#else\n    return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts, FALSE);\n#endif\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":234752,"func":"static void warn_32bit_meta_chunk(struct btrfs_fs_info *fs_info,\n\t\t\t\t  u64 logical, u64 length, u64 type)\n{\n\tif (!(type & BTRFS_BLOCK_GROUP_METADATA))\n\t\treturn;\n\n\tif (logical + length < BTRFS_32BIT_EARLY_WARN_THRESHOLD)\n\t\treturn;\n\n\tbtrfs_warn_32bit_limit(fs_info);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":225450,"func":"static inline void v4l2l_get_timestamp(struct v4l2_buffer *b)\n{\n\t\/* ktime_get_ts is considered deprecated, so use ktime_get_ts64 if possible *\/\n#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)\n\tstruct timespec ts;\n\tktime_get_ts(&ts);\n#else\n\tstruct timespec64 ts;\n\tktime_get_ts64(&ts);\n#endif\n\n\tb->timestamp.tv_sec = ts.tv_sec;\n\tb->timestamp.tv_usec = (ts.tv_nsec \/ NSEC_PER_USEC);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":220218,"func":"void Node::set_original_node_names(const std::vector<std::string>& names) {\n  MaybeCopyOnWrite();\n  props_->node_def.mutable_experimental_debug_info()\n      ->clear_original_node_names();\n  if (!names.empty()) {\n    *props_->node_def.mutable_experimental_debug_info()\n         ->mutable_original_node_names() = {names.begin(), names.end()};\n  }\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":226108,"func":"\nGF_Box *tref_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackReferenceBox, GF_ISOM_BOX_TYPE_TREF);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":448930,"func":"void arch_pick_mmap_layout(struct mm_struct *mm)\n{\n\t\/*\n\t * Fall back to the standard layout if the personality bit is set, or\n\t * if the expected stack growth is unlimited:\n\t *\/\n\tif (mmap_is_legacy()) {\n\t\tmm->mmap_base = TASK_UNMAPPED_BASE;\n\t\tmm->get_unmapped_area = arch_get_unmapped_area;\n\t} else {\n\t\tmm->mmap_base = mmap_base();\n\t\tmm->get_unmapped_area = arch_get_unmapped_area_topdown;\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":413660,"func":"static ut64 delta_for_access(RAnalOp *op, RAnalVarAccessType type) {\n\tif (type == R_ANAL_VAR_ACCESS_TYPE_WRITE) {\n\t\tif (op->dst) {\n\t\t\treturn op->dst->imm + op->dst->delta;\n\t\t}\n\t} else {\n\t\tif (op->src[1] && (op->src[1]->imm || op->src[1]->delta)) {\n\t\t\treturn op->src[1]->imm + op->src[1]->delta;\n\t\t}\n\t\tif (op->src[0]) {\n\t\t\treturn op->src[0]->imm + op->src[0]->delta;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":219978,"func":"int callback_glewlwyd_get_plugin_module (const struct _u_request * request, struct _u_response * response, void * plugin_data) {\n  struct config_elements * config = (struct config_elements *)plugin_data;\n  json_t * j_module;\n  \n  j_module = get_plugin_module(config, u_map_get(request->map_url, \"name\"));\n  if (check_result_value(j_module, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module, \"module\"));\n  } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_plugin_module - Error get_plugin_module\");\n    response->status = 500;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":513131,"func":"static int check_func_str(THD *thd, struct st_mysql_sys_var *var,\n                          void *save, st_mysql_value *value)\n{\n  char buff[STRING_BUFFER_USUAL_SIZE];\n  const char *str;\n  int length;\n\n  length= sizeof(buff);\n  if ((str= value->val_str(value, buff, &length)))\n    str= thd->strmake(str, length);\n  *(const char**)save= str;\n  return 0;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":508403,"func":"bool restart_trans_for_tables(THD *thd, TABLE_LIST *table)\n{\n  DBUG_ENTER(\"restart_trans_for_tables\");\n\n  for (; table; table= table->next_global)\n  {\n    if (table->placeholder())\n      continue;\n\n    if (check_lock_and_start_stmt(thd, thd->lex, table))\n    {\n      DBUG_ASSERT(0);                           \/\/ Should never happen\n      DBUG_RETURN(TRUE);\n    }\n  }\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":292133,"func":"void LinkResolver::resolve_invokehandle(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {\n  \/\/ This guy is reached from InterpreterRuntime::resolve_invokehandle.\n  LinkInfo link_info(pool, index, CHECK);\n  if (TraceMethodHandles) {\n    ResourceMark rm(THREAD);\n    tty->print_cr(\"resolve_invokehandle %s %s\", link_info.name()->as_C_string(),\n                  link_info.signature()->as_C_string());\n  }\n  resolve_handle_call(result, link_info, CHECK);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":220825,"func":"inline std::int32_t SaturatingAddNonGemmlowp(std::int32_t a, std::int32_t b) {\n  std::int64_t a64 = a;\n  std::int64_t b64 = b;\n  std::int64_t sum = a64 + b64;\n  return static_cast<std::int32_t>(std::min(\n      static_cast<std::int64_t>(std::numeric_limits<std::int32_t>::max()),\n      std::max(\n          static_cast<std::int64_t>(std::numeric_limits<std::int32_t>::min()),\n          sum)));\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":359621,"func":"DEFUN (clear_ip_bgp_as_soft_out,\n       clear_ip_bgp_as_soft_out_cmd,\n       \"clear ip bgp <1-65535> soft out\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear peers with the AS number\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,\n\t\t\tBGP_CLEAR_SOFT_OUT, argv[0]);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":292152,"func":"LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS) {\n   \/\/ resolve klass\n  _resolved_klass = pool->klass_ref_at(index, CHECK);\n\n  \/\/ Get name, signature, and static klass\n  _name          = pool->name_ref_at(index);\n  _signature     = pool->signature_ref_at(index);\n  _tag           = pool->tag_ref_at(index);\n  _current_klass = pool->pool_holder();\n  _current_method = current_method;\n\n  \/\/ Coming from the constant pool always checks access\n  _check_access  = true;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":226044,"func":"GF_Err pmax_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":252423,"func":"static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh(\n    mz_zip_archive *pZip, mz_uint file_index) {\n  if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) ||\n      (pZip->m_zip_mode != MZ_ZIP_MODE_READING))\n    return NULL;\n  return &MZ_ZIP_ARRAY_ELEMENT(\n      &pZip->m_pState->m_central_dir, mz_uint8,\n      MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32,\n                           file_index));\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":424520,"func":"static UINT video_data_on_close(IWTSVirtualChannelCallback* pChannelCallback)\n{\n\tfree(pChannelCallback);\n\treturn CHANNEL_RC_OK;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":448472,"func":"vg_resource_attach_backing(VuGpu *g,\n                           struct virtio_gpu_ctrl_command *cmd)\n{\n    struct virtio_gpu_simple_resource *res;\n    struct virtio_gpu_resource_attach_backing ab;\n    int ret;\n\n    VUGPU_FILL_CMD(ab);\n    virtio_gpu_bswap_32(&ab, sizeof(ab));\n\n    res = virtio_gpu_find_resource(g, ab.resource_id);\n    if (!res) {\n        g_critical(\"%s: illegal resource specified %d\",\n                   __func__, ab.resource_id);\n        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;\n        return;\n    }\n\n    if (res->iov) {\n        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;\n        return;\n    }\n\n    ret = vg_create_mapping_iov(g, &ab, cmd, &res->iov);\n    if (ret != 0) {\n        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;\n        return;\n    }\n\n    res->iov_cnt = ab.nr_entries;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":236124,"func":"GF_Box *tx3g_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_Tx3gSampleEntryBox, GF_ISOM_BOX_TYPE_TX3G);\n\tgf_isom_sample_entry_init((GF_SampleEntryBox *)tmp);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":273080,"func":"safe_atoi64(const char *str, int64_t *val)\n{\n  char *end;\n  long long intval;\n\n  *val = 0;\n\n  errno = 0;\n  intval = strtoll(str, &end, 10);\n\n  if (((errno == ERANGE) && ((intval == LLONG_MAX) || (intval == LLONG_MIN)))\n      || ((errno != 0) && (intval == 0)))\n    {\n      DPRINTF(E_DBG, L_MISC, \"Invalid integer in string (%s): %s\\n\", str, strerror(errno));\n\n      return -1;\n    }\n\n  if (end == str)\n    {\n      DPRINTF(E_DBG, L_MISC, \"No integer found in string (%s)\\n\", str);\n\n      return -1;\n    }\n\n  if (intval > INT64_MAX)\n    {\n      DPRINTF(E_DBG, L_MISC, \"Integer value too large (%s)\\n\", str);\n\n      return -1;\n    }\n\n  *val = (int64_t)intval;\n\n  return 0;\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":247666,"func":"  TestUtilOptionsV2& setExpectedALPNProtocol(const std::string& expected_alpn_protocol) {\n    expected_alpn_protocol_ = expected_alpn_protocol;\n    return *this;\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":223419,"func":"static void jumpto_if_not_utf_char_start(struct sljit_compiler *compiler, sljit_s32 reg, struct sljit_label *label)\n{\n#if PCRE2_CODE_UNIT_WIDTH == 8\nOP2(SLJIT_AND, reg, 0, reg, 0, SLJIT_IMM, 0xc0);\nCMPTO(SLJIT_EQUAL, reg, 0, SLJIT_IMM, 0x80, label);\n#elif PCRE2_CODE_UNIT_WIDTH == 16\nOP2(SLJIT_AND, reg, 0, reg, 0, SLJIT_IMM, 0xfc00);\nCMPTO(SLJIT_EQUAL, reg, 0, SLJIT_IMM, 0xdc00, label);\n#else\n#error \"Unknown code width\"\n#endif\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":244182,"func":"u32 gf_isom_ctrn_field_size_bits(u32 field_idx)\n{\n\tif (field_idx==3) return 32;\n\treturn field_idx*8;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":245182,"func":"has_innodb_buffer_pool_dump_pct()\n{\n\tif ((server_flavor == FLAVOR_PERCONA_SERVER ||\n\t\tserver_flavor == FLAVOR_MYSQL) &&\n\t\tmysql_server_version >= 50702) {\n\t\treturn(true);\n\t}\n\n\tif (server_flavor == FLAVOR_MARIADB && mysql_server_version >= 10110) {\n\t\treturn(true);\n\t}\n\n\treturn(false);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":279942,"func":"free_prev_shellcmd(void)\n{\n    vim_free(prevcmd);\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":307847,"func":"void ciEnv::dump_inline_data(int compile_id) {\n  static char buffer[O_BUFLEN];\n  int ret = jio_snprintf(buffer, O_BUFLEN, \"inline_pid%p_compid%d.log\", os::current_process_id(), compile_id);\n  if (ret > 0) {\n    int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);\n    if (fd != -1) {\n      FILE* inline_data_file = os::open(fd, \"w\");\n      if (inline_data_file != NULL) {\n        fileStream replay_data_stream(inline_data_file, \/*need_close=*\/true);\n        GUARDED_VM_ENTRY(\n          MutexLocker ml(Compile_lock);\n          dump_compile_data(&replay_data_stream);\n        )\n        replay_data_stream.flush();\n        tty->print(\"# Compiler inline data is saved as: \");\n        tty->print_cr(\"%s\", buffer);\n      } else {\n        tty->print_cr(\"# Can't open file to dump inline data.\");\n      }\n    }\n  }\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":361300,"func":"stl_match_neighbors_exact(stl_file *stl,\n                          stl_hash_edge *edge_a, stl_hash_edge *edge_b) {\n  if (stl->error) return;\n  stl_record_neighbors(stl, edge_a, edge_b);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":96958,"func":"void encode(ArgumentEncoder* encoder, CFURLRef url)\n{\n    CFURLRef baseURL = CFURLGetBaseURL(url);\n    encoder->encodeBool(baseURL);\n    if (baseURL)\n        encode(encoder, baseURL);\n\n    encode(encoder, CFURLGetString(url));\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":226296,"func":"void maxr_box_del(GF_Box *s)\n{\n\tgf_free((GF_MAXRBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":294617,"func":"valid_civil_sub(int argc, VALUE *argv, VALUE klass, int need_jd)\n{\n    VALUE nth, y;\n    int m, d, ry, rm, rd;\n    double sg;\n\n    y = argv[0];\n    m = NUM2INT(argv[1]);\n    d = NUM2INT(argv[2]);\n    sg = NUM2DBL(argv[3]);\n\n    valid_sg(sg);\n\n    if (!need_jd && (guess_style(y, sg) < 0)) {\n\tif (!valid_gregorian_p(y, m, d,\n\t\t\t       &nth, &ry,\n\t\t\t       &rm, &rd))\n\t    return Qnil;\n\treturn INT2FIX(0); \/* dummy *\/\n    }\n    else {\n\tint rjd, ns;\n\tVALUE rjd2;\n\n\tif (!valid_civil_p(y, m, d, sg,\n\t\t\t   &nth, &ry,\n\t\t\t   &rm, &rd, &rjd,\n\t\t\t   &ns))\n\t    return Qnil;\n\tif (!need_jd)\n\t    return INT2FIX(0); \/* dummy *\/\n\tencode_jd(nth, rjd, &rjd2);\n\treturn rjd2;\n    }\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":294625,"func":"m_df_in_day(union DateData *x)\n{\n    return isec_to_day(m_df(x));\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":512350,"func":"bool Item_func_between::eval_not_null_tables(void *opt_arg)\n{\n  if (Item_func_opt_neg::eval_not_null_tables(NULL))\n    return 1;\n\n  \/* not_null_tables_cache == union(T1(e),T1(e1),T1(e2)) *\/\n  if (pred_level && !negated)\n    return 0;\n\n  \/* not_null_tables_cache == union(T1(e), intersection(T1(e1),T1(e2))) *\/\n  not_null_tables_cache= (args[0]->not_null_tables() |\n                          (args[1]->not_null_tables() &\n                           args[2]->not_null_tables()));\n  return 0;\n}  ","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":307836,"func":"ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool,\n                                     int index, Bytecodes::Code bc,\n                                     ciInstanceKlass* accessor) {\n  GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":236161,"func":"void styl_box_del(GF_Box *s)\n{\n\tGF_TextStyleBox*ptr = (GF_TextStyleBox*)s;\n\tif (ptr->styles) gf_free(ptr->styles);\n\tgf_free(ptr);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":438661,"func":"static void __exit rpmsg_fini(void)\n{\n\tunregister_virtio_driver(&virtio_ipc_driver);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":241065,"func":"static void client_alloc(void)\n{\n\tint i;\n\n\tif (!(clients = realloc(\n\t\tclients, (client_size + CLIENT_NALLOC) * sizeof(*clients))\n\t) || !(pollfds = realloc(\n\t\tpollfds, (client_size + CLIENT_NALLOC) * sizeof(*pollfds))\n\t)) {\n\t\tlog_error(\"can't alloc for client array\");\n\t\texit(1);\n\t}\n\n\tfor (i = client_size; i < client_size + CLIENT_NALLOC; i++) {\n\t\tclients[i].workfn = NULL;\n\t\tclients[i].deadfn = NULL;\n\t\tclients[i].fd = -1;\n\t\tpollfds[i].fd = -1;\n\t\tpollfds[i].revents = 0;\n\t}\n\tclient_size += CLIENT_NALLOC;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":225992,"func":"GF_Err tfhd_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TrackFragmentHeaderBox *ptr = (GF_TrackFragmentHeaderBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->trackID);\n\n\t\/\/The rest depends on the flags\n\tif (ptr->flags & GF_ISOM_TRAF_BASE_OFFSET) {\n\t\tgf_bs_write_u64(bs, ptr->base_data_offset);\n\t}\n\tif (ptr->flags & GF_ISOM_TRAF_SAMPLE_DESC) {\n\t\tgf_bs_write_u32(bs, ptr->sample_desc_index);\n\t}\n\tif (ptr->flags & GF_ISOM_TRAF_SAMPLE_DUR) {\n\t\tgf_bs_write_u32(bs, ptr->def_sample_duration);\n\t}\n\tif (ptr->flags & GF_ISOM_TRAF_SAMPLE_SIZE) {\n\t\tgf_bs_write_u32(bs, ptr->def_sample_size);\n\t}\n\tif (ptr->flags & GF_ISOM_TRAF_SAMPLE_FLAGS) {\n\t\tgf_bs_write_u32(bs, ptr->def_sample_flags);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":308159,"func":"static void fastrpc_context_put_wq(struct work_struct *work)\n{\n\tstruct fastrpc_invoke_ctx *ctx =\n\t\t\tcontainer_of(work, struct fastrpc_invoke_ctx, put_work);\n\n\tfastrpc_context_put(ctx);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":253617,"func":"smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)\n{\n\tstruct TCP_Server_Info *server = tcon->ses->server;\n\tunsigned int rsize;\n\n\t\/* start with specified rsize, or default *\/\n\trsize = ctx->rsize ? ctx->rsize : SMB3_DEFAULT_IOSIZE;\n\trsize = min_t(unsigned int, rsize, server->max_read);\n#ifdef CONFIG_CIFS_SMB_DIRECT\n\tif (server->rdma) {\n\t\tif (server->sign)\n\t\t\t\/*\n\t\t\t * Account for SMB2 data transfer packet header and\n\t\t\t * possible encryption header\n\t\t\t *\/\n\t\t\trsize = min_t(unsigned int,\n\t\t\t\trsize,\n\t\t\t\tserver->smbd_conn->max_fragmented_recv_size -\n\t\t\t\t\tSMB2_READWRITE_PDU_HEADER_SIZE -\n\t\t\t\t\tsizeof(struct smb2_transform_hdr));\n\t\telse\n\t\t\trsize = min_t(unsigned int,\n\t\t\t\trsize, server->smbd_conn->max_readwrite_size);\n\t}\n#endif\n\n\tif (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))\n\t\trsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);\n\n\treturn rsize;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":400709,"func":"int import_single_range(int rw, void __user *buf, size_t len,\n\t\t struct iovec *iov, struct iov_iter *i)\n{\n\tif (len > MAX_RW_COUNT)\n\t\tlen = MAX_RW_COUNT;\n\tif (unlikely(!access_ok(buf, len)))\n\t\treturn -EFAULT;\n\n\tiov->iov_base = buf;\n\tiov->iov_len = len;\n\tiov_iter_init(i, rw, iov, 1, len);\n\treturn 0;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":225720,"func":"\nGF_Err tfdt_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TFBaseMediaDecodeTimeBox *ptr = (GF_TFBaseMediaDecodeTimeBox *) s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tif (ptr->version==1) {\n\t\tgf_bs_write_u64(bs, ptr->baseMediaDecodeTime);\n\t} else {\n\t\tgf_bs_write_u32(bs, (u32) ptr->baseMediaDecodeTime);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":228448,"func":"bool WddxPacket::recursiveAddVar(const String& varName,\n                                 const Variant& varVariant,\n                                 bool hasVarTag) {\n  SeenContainers seen;\n  return recursiveAddVarImpl(varName, varVariant, hasVarTag, seen);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":409414,"func":"req_more_codes_from_term(void)\n{\n    char\tbuf[23];  \/\/ extra size to shut up LGTM\n    int\t\told_idx = xt_index_out;\n\n    \/\/ Don't do anything when going to exit.\n    if (exiting)\n\treturn;\n\n    \/\/ Send up to 10 more requests out than we received.  Avoid sending too\n    \/\/ many, there can be a buffer overflow somewhere.\n    while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL)\n    {\n\tchar *key_name = key_names[xt_index_out];\n\n\tMAY_WANT_TO_LOG_THIS;\n\tLOG_TR((\"Requesting XT %d: %s\", xt_index_out, key_name));\n\tsprintf(buf, \"\\033P+q%02x%02x\\033\\\\\", key_name[0], key_name[1]);\n\tout_str_nf((char_u *)buf);\n\t++xt_index_out;\n    }\n\n    \/\/ Send the codes out right away.\n    if (xt_index_out != old_idx)\n\tout_flush();\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":90110,"func":"CellularNetwork::CellularNetwork()\n    : WirelessNetwork(),\n      activation_state_(ACTIVATION_STATE_UNKNOWN),\n      network_technology_(NETWORK_TECHNOLOGY_UNKNOWN),\n      roaming_state_(ROAMING_STATE_UNKNOWN),\n      restricted_pool_(false),\n      prl_version_(0) {\n  type_ = TYPE_CELLULAR;\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":247761,"func":"void InvertibleRWFunction::DEREncode(BufferedTransformation &bt) const\n{\n\tDERSequenceEncoder seq(bt);\n\tm_n.DEREncode(seq);\n\tm_p.DEREncode(seq);\n\tm_q.DEREncode(seq);\n\tm_u.DEREncode(seq);\n\tseq.MessageEnd();\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":474021,"func":"st_hash_end(st_index_t h)\n{\n    h = murmur_step(h, 10);\n    h = murmur_step(h, 17);\n    return h;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":228443,"func":"void find_var_recursive(const TypedValue* tv,\n                        const req::ptr<WddxPacket>& wddxPacket) {\n  if (tvIsString(tv)) {\n    String var_name{tvCastToString(tv)};\n    wddxPacket->add_var(var_name, true);\n  }\n  if (isArrayType(tv->m_type)) {\n    for (ArrayIter iter(tv->m_data.parr); iter; ++iter) {\n      find_var_recursive(iter.secondRef().asTypedValue(), wddxPacket);\n    }\n  }\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":289246,"func":"static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tif (atomic_read(&substream->mmap_count))\n\t\treturn runtime->oss.prev_hw_ptr_period !=\n\t\t\t\t\t\tget_hw_ptr_period(runtime);\n\telse\n\t\treturn snd_pcm_capture_avail(runtime) >=\n\t\t\t\t\t\truntime->oss.period_frames;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":299900,"func":"local_scan_init(void)\n{\n#ifndef LOCAL_SCAN_HAS_OPTIONS\nlog_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, \"local_scan() options not supported: \"\n  \"(LOCAL_SCAN_HAS_OPTIONS not defined in Local\/Makefile)\");\n#else\n\nuschar *p;\nwhile ((p = get_config_line()) != NULL)\n  {\n  (void) readconf_handle_option(p, local_scan_options, local_scan_options_count,\n    NULL, US\"local_scan option \\\"%s\\\" unknown\");\n  }\n#endif\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":220816,"func":"inline int SubscriptToIndex(const NdArrayDesc<5>& desc, int indexes[5]) {\n  return indexes[0] * desc.strides[0] + indexes[1] * desc.strides[1] +\n         indexes[2] * desc.strides[2] + indexes[3] * desc.strides[3] +\n         indexes[4] * desc.strides[4];\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":244113,"func":"GF_Err pcmC_box_size(GF_Box *s)\n{\n\ts->size += 2;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":521465,"func":"    int64 getPosition() override\r\n    {\r\n        return pos;\r\n    }\r","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":226202,"func":"void chpl_box_del(GF_Box *s)\n{\n\tGF_ChapterListBox *ptr = (GF_ChapterListBox *) s;\n\tif (ptr == NULL) return;\n\twhile (gf_list_count(ptr->list)) {\n\t\tGF_ChapterEntry *ce = (GF_ChapterEntry *)gf_list_get(ptr->list, 0);\n\t\tif (ce->name) gf_free(ce->name);\n\t\tgf_free(ce);\n\t\tgf_list_rem(ptr->list, 0);\n\t}\n\tgf_list_del(ptr->list);\n\tgf_free(ptr);\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":232833,"func":"  explicit BoostedTreesQuantileStreamResourceFlushOp(\n      OpKernelConstruction* const context)\n      : OpKernel(context) {\n    OP_REQUIRES_OK(context,\n                   context->GetAttr(kGenerateQuantiles, &generate_quantiles_));\n  }","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":513320,"func":"Item_func_trig_cond::add_key_fields(JOIN *join, KEY_FIELD **key_fields,\n                                    uint *and_level, table_map usable_tables,\n                                    SARGABLE_PARAM **sargables)\n{\n  \/* \n    Subquery optimization: Conditions that are pushed down into subqueries\n    are wrapped into Item_func_trig_cond. We process the wrapped condition\n    but need to set cond_guard for KEYUSE elements generated from it.\n  *\/\n  if (!join->group_list && !join->order &&\n      join->unit->item && \n      join->unit->item->substype() == Item_subselect::IN_SUBS &&\n      !join->unit->is_union())\n  {\n    KEY_FIELD *save= *key_fields;\n    args[0]->add_key_fields(join, key_fields, and_level, usable_tables,\n                            sargables);\n    \/\/ Indicate that this ref access candidate is for subquery lookup:\n    for (; save != *key_fields; save++)\n      save->cond_guard= get_trig_var();\n  }\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":333049,"func":"nfa_print_state(FILE *debugf, nfa_state_T *state)\n{\n    garray_T indent;\n\n    ga_init2(&indent, 1, 64);\n    ga_append(&indent, '\\0');\n    nfa_print_state2(debugf, state, &indent);\n    ga_clear(&indent);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":432264,"func":"static bool addrrange_intersects(AddrRange r1, AddrRange r2)\n{\n    return addrrange_contains(r1, r2.start)\n        || addrrange_contains(r2, r1.start);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":409522,"func":"term_rgb_color(char_u *s, guicolor_T rgb)\n{\n#define MAX_COLOR_STR_LEN 100\n    char\tbuf[MAX_COLOR_STR_LEN];\n\n    if (*s == NUL)\n\treturn;\n    vim_snprintf(buf, MAX_COLOR_STR_LEN,\n\t\t\t\t  (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb));\n#ifdef FEAT_VTP\n    if (use_wt())\n    {\n\tout_flush();\n\tbuf[1] = '[';\n\tvtp_printf(buf);\n    }\n    else\n#endif\n\tOUT_STR(buf);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":437693,"func":"int cx23888_ir_remove(struct cx23885_dev *dev)\n{\n\tstruct v4l2_subdev *sd;\n\tstruct cx23888_ir_state *state;\n\n\tsd = cx23885_find_hw(dev, CX23885_HW_888_IR);\n\tif (sd == NULL)\n\t\treturn -ENODEV;\n\n\tcx23888_ir_rx_shutdown(sd);\n\tcx23888_ir_tx_shutdown(sd);\n\n\tstate = to_state(sd);\n\tv4l2_device_unregister_subdev(sd);\n\tkfifo_free(&state->rx_kfifo);\n\tkfree(state);\n\t\/* Nothing more to free() as state held the actual v4l2_subdev object *\/\n\treturn 0;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":474092,"func":"gbk_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)\n{\n  int firstbyte = *p++;\n  state_t s = trans[0][firstbyte];\n#define RETURN(n) \\\n    return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) : \\\n                         ONIGENC_CONSTRUCT_MBCLEN_INVALID()\n  if (s < 0) RETURN(1);\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_GBK[firstbyte]-1);\n  s = trans[s][*p++];\n  RETURN(2);\n#undef RETURN\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":513221,"func":"bool sys_var_pluginvar::session_is_default(THD *thd)\n{\n  uchar *value= plugin_var->flags & PLUGIN_VAR_THDLOCAL\n                ? intern_sys_var_ptr(thd, *(int*) (plugin_var+1), true)\n                : *(uchar**) (plugin_var+1);\n\n    real_value_ptr(thd, OPT_SESSION);\n\n  switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {\n  case PLUGIN_VAR_BOOL:\n    return option.def_value == *(my_bool*)value;\n  case PLUGIN_VAR_INT:\n    return option.def_value == *(int*)value;\n  case PLUGIN_VAR_LONG:\n  case PLUGIN_VAR_ENUM:\n    return option.def_value == *(long*)value;\n  case PLUGIN_VAR_LONGLONG:\n  case PLUGIN_VAR_SET:\n    return option.def_value == *(longlong*)value;\n  case PLUGIN_VAR_STR:\n    {\n      const char *a=(char*)option.def_value;\n      const char *b=(char*)value;\n      return (!a && !b) || (a && b && strcmp(a,b));\n    }\n  case PLUGIN_VAR_DOUBLE:\n    return getopt_ulonglong2double(option.def_value) == *(double*)value;\n  }\n  DBUG_ASSERT(0);\n  return 0;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":400768,"func":"static ssize_t iter_xarray_get_pages_alloc(struct iov_iter *i,\n\t\t\t\t\t   struct page ***pages, size_t maxsize,\n\t\t\t\t\t   size_t *_start_offset)\n{\n\tstruct page **p;\n\tunsigned nr, offset;\n\tpgoff_t index, count;\n\tsize_t size = maxsize, actual;\n\tloff_t pos;\n\n\tif (!size)\n\t\treturn 0;\n\n\tpos = i->xarray_start + i->iov_offset;\n\tindex = pos >> PAGE_SHIFT;\n\toffset = pos & ~PAGE_MASK;\n\t*_start_offset = offset;\n\n\tcount = 1;\n\tif (size > PAGE_SIZE - offset) {\n\t\tsize -= PAGE_SIZE - offset;\n\t\tcount += size >> PAGE_SHIFT;\n\t\tsize &= ~PAGE_MASK;\n\t\tif (size)\n\t\t\tcount++;\n\t}\n\n\tp = get_pages_array(count);\n\tif (!p)\n\t\treturn -ENOMEM;\n\t*pages = p;\n\n\tnr = iter_xarray_populate_pages(p, i->xarray, index, count);\n\tif (nr == 0)\n\t\treturn 0;\n\n\tactual = PAGE_SIZE * nr;\n\tactual -= offset;\n\tif (nr == count && size > 0) {\n\t\tunsigned last_offset = (nr > 1) ? 0 : offset;\n\t\tactual -= PAGE_SIZE - (last_offset + size);\n\t}\n\treturn actual;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":379670,"func":"R_API int r_anal_var_get_argnum(RAnalVar *var) {\n\tr_return_val_if_fail (var, -1);\n\tRAnal *anal = var->fcn->anal;\n\tif (!var->isarg || var->kind != R_ANAL_VAR_KIND_REG) { \/\/ TODO: support bp and sp too\n\t\treturn -1;\n\t}\n\tif (!var->regname) {\n\t\treturn -1;\n\t}\n\tRRegItem *reg = r_reg_get (anal->reg, var->regname, -1);\n\tif (!reg) {\n\t\treturn -1;\n\t}\n\tint i;\n\tint arg_max = var->fcn->cc ? r_anal_cc_max_arg (anal, var->fcn->cc) : 0;\n\tfor (i = 0; i < arg_max; i++) {\n\t\tconst char *reg_arg = r_anal_cc_arg (anal, var->fcn->cc, i);\n\t\tif (reg_arg && !strcmp (reg->name, reg_arg)) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":254729,"func":"njs_typed_array_get_i32(const void *a)\n{\n    return *(const int32_t *) a;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":275922,"func":"const uECC_word_t *uECC_curve_b(uECC_Curve curve) {\n    return curve->b;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":212810,"func":"regional_alloc(struct regional *r, size_t size)\n{\n\tsize_t a = ALIGN_UP(size, ALIGNMENT);\n\tvoid *s;\n\t\/* large objects *\/\n\tif(a > REGIONAL_LARGE_OBJECT_SIZE) {\n\t\ts = malloc(ALIGNMENT + size);\n\t\tif(!s) return NULL;\n\t\tr->total_large += ALIGNMENT+size;\n\t\t*(char**)s = r->large_list;\n\t\tr->large_list = (char*)s;\n\t\treturn (char*)s+ALIGNMENT;\n\t}\n\t\/* create a new chunk *\/\n\tif(a > r->available) {\n\t\ts = malloc(REGIONAL_CHUNK_SIZE);\n\t\tif(!s) return NULL;\n\t\t*(char**)s = r->next;\n\t\tr->next = (char*)s;\n\t\tr->data = (char*)s + ALIGNMENT;\n\t\tr->available = REGIONAL_CHUNK_SIZE - ALIGNMENT;\n\t}\n\t\/* put in this chunk *\/\n\tr->available -= a;\n\ts = r->data;\n\tr->data += a;\n\treturn s;\n}","target":1,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":512964,"func":"longlong Item_func_ge::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  int value= cmp.compare();\n  return value >= 0 ? 1 : 0;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":445930,"func":"encrypt_data_free (EncryptData *edata)\n{\n\tif (edata == NULL)\n\t\treturn;\n\n\tif (edata->temp_new_file != NULL) {\n\t\tGFile *parent = g_file_get_parent (edata->temp_new_file);\n\t\tif (parent != NULL)\n\t\t\t_g_file_remove_directory (parent, NULL, NULL);\n\t\t_g_object_unref (parent);\n\t}\n\t_g_object_unref (edata->temp_new_file);\n\t_g_object_unref (edata->new_archive);\n\t_g_file_remove_directory (edata->temp_extraction_dir, NULL, NULL);\n\t_g_object_unref (edata->temp_extraction_dir);\n\tg_free (edata->password);\n\tg_free (edata);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":445976,"func":"fr_window_action_new_archive (FrWindow *window)\n{\n\tGtkWidget *dialog;\n\n\tif (fr_window_present_dialog_if_created (window, \"new_archive\"))\n\t\treturn;\n\n\tdialog = fr_new_archive_dialog_new (_(\"New Archive\"),\n\t\t\t\t\t    GTK_WINDOW (window),\n\t\t\t\t\t    FR_NEW_ARCHIVE_ACTION_NEW_MANY_FILES,\n\t\t\t\t\t    fr_window_get_open_default_dir (window),\n\t\t\t\t\t    NULL,\n\t\t\t\t\t    NULL);\n\tif ((fr_window_archive_is_present (window) && ! fr_window_is_batch_mode (window) ? NULL : GTK_WINDOW (window)))\n\t\tgtk_window_set_modal (GTK_WINDOW (dialog), TRUE);\n\tg_signal_connect (G_OBJECT (dialog),\n\t\t\t  \"response\",\n\t\t\t  G_CALLBACK (new_archive_dialog_response_cb),\n\t\t\t  window);\n\tfr_window_set_dialog (window, \"new_archive\", dialog);\n\tgtk_window_present (GTK_WINDOW (dialog));\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":336145,"func":"static int ip6gre_tunnel_init(struct net_device *dev)\n{\n\tstruct ip6_tnl *tunnel;\n\tint ret;\n\n\tret = ip6gre_tunnel_init_common(dev);\n\tif (ret)\n\t\treturn ret;\n\n\ttunnel = netdev_priv(dev);\n\n\tmemcpy(dev->dev_addr, &tunnel->parms.laddr, sizeof(struct in6_addr));\n\tmemcpy(dev->broadcast, &tunnel->parms.raddr, sizeof(struct in6_addr));\n\n\tif (ipv6_addr_any(&tunnel->parms.raddr))\n\t\tdev->header_ops = &ip6gre_header_ops;\n\n\treturn 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":521468,"func":"    void runTest() override\r\n    {\r\n        beginTest (\"ZIP\");\r\n\r\n        StringArray entryNames { \"first\", \"second\", \"third\" };\r\n        auto data = createZipMemoryBlock (entryNames);\r\n        MemoryInputStream mi (data, false);\r\n        ZipFile zip (mi);\r\n\r\n        expectEquals (zip.getNumEntries(), entryNames.size());\r\n\r\n        for (auto& entryName : entryNames)\r\n        {\r\n            auto* entry = zip.getEntry (entryName);\r\n            std::unique_ptr<InputStream> input (zip.createStreamForEntry (*entry));\r\n            expectEquals (input->readEntireStreamAsString(), entryName);\r\n        }\r\n\r\n        beginTest (\"ZipSlip\");\r\n        runZipSlipTest();\r\n    }\r","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":409486,"func":"find_first_tcap(\n    char_u *name,\n    int\t    code)\n{\n    struct builtin_term *p;\n\n    for (p = find_builtin_term(name); p->bt_string != NULL; ++p)\n\tif (p->bt_entry == code)\n\t    return p;\n    return NULL;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":234224,"func":"get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind)\n{\n  \/* See gdb\/gdb-index.h.  *\/\n  static const char * const kinds[] =\n  {\n    N_ (\"no info\"),\n    N_ (\"type\"),\n    N_ (\"variable\"),\n    N_ (\"function\"),\n    N_ (\"other\"),\n    N_ (\"unused5\"),\n    N_ (\"unused6\"),\n    N_ (\"unused7\")\n  };\n\n  return _ (kinds[kind]);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":484788,"func":"static int xennet_open(struct net_device *dev)\n{\n\tstruct netfront_info *np = netdev_priv(dev);\n\tunsigned int num_queues = dev->real_num_tx_queues;\n\tunsigned int i = 0;\n\tstruct netfront_queue *queue = NULL;\n\n\tif (!np->queues || np->broken)\n\t\treturn -ENODEV;\n\n\tfor (i = 0; i < num_queues; ++i) {\n\t\tqueue = &np->queues[i];\n\t\tnapi_enable(&queue->napi);\n\n\t\tspin_lock_bh(&queue->rx_lock);\n\t\tif (netif_carrier_ok(dev)) {\n\t\t\txennet_alloc_rx_buffers(queue);\n\t\t\tqueue->rx.sring->rsp_event = queue->rx.rsp_cons + 1;\n\t\t\tif (RING_HAS_UNCONSUMED_RESPONSES(&queue->rx))\n\t\t\t\tnapi_schedule(&queue->napi);\n\t\t}\n\t\tspin_unlock_bh(&queue->rx_lock);\n\t}\n\n\tnetif_tx_start_all_queues(dev);\n\n\treturn 0;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":229223,"func":"void cql_server::response::write_long(int64_t n)\n{\n    auto u = htonq(n);\n    auto *s = reinterpret_cast<const int8_t*>(&u);\n    _body.write(bytes_view(s, sizeof(u)));\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":261737,"func":"BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, size_t len) {\n    auto buffer = _packet_pool.obtain2();\n    if (data && len) {\n        buffer->assign((const char *) data, len);\n    }\n    return buffer;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":273885,"func":"static void handle_SYST(ctrl_t *ctrl, char *arg)\n{\n\tchar system[] = \"215 UNIX Type: L8\\r\\n\";\n\n\tsend_msg(ctrl->sd, system);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":225552,"func":"TfLiteIntArray* TfLiteIntArrayCreate(int size) {\n  size_t alloc_size = TfLiteIntArrayGetSizeInBytes(size);\n  if (alloc_size <= 0) return NULL;\n  TfLiteIntArray* ret = (TfLiteIntArray*)malloc(alloc_size);\n  if (!ret) return ret;\n  ret->size = size;\n  return ret;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":245166,"func":"read_mysql_variables(MYSQL *connection, const char *query, mysql_variable *vars,\n\tbool vertical_result)\n{\n\tMYSQL_RES *mysql_result = xb_mysql_query(connection, query, true);\n\tread_mysql_variables_from_result(mysql_result, vars, vertical_result);\n\tmysql_free_result(mysql_result);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":229339,"func":"bool KernelCacheEnabled(const OpDef& op_def) {\n  if (data::DatasetOpKernel::IsDatasetOp(op_def)) {\n    return false;\n  }\n  \/\/ TODO(b\/162540360): Revisit a way to mark kernels as uncachable once we have\n  \/\/ 5+ kernels to exclude.\n  return true;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":225842,"func":"GF_Err dmed_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_DMEDBox *ptr = (GF_DMEDBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u64(bs, ptr->nbBytes);\n\treturn GF_OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":389714,"func":"check_for_opt_buffer_or_dict_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_UNKNOWN\n\t    && args[idx].v_type != VAR_STRING\n\t    && args[idx].v_type != VAR_NUMBER\n\t    && args[idx].v_type != VAR_DICT)\n    {\n\tsemsg(_(e_string_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":261931,"func":"njs_string_prototype_from_utf8(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    ssize_t            length;\n    njs_int_t          ret;\n    njs_slice_prop_t   slice;\n    njs_string_prop_t  string;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_string_slice_prop(vm, &string, &slice, args, nargs);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (string.length != 0) {\n        \/* ASCII or UTF8 string. *\/\n        return njs_string_slice(vm, &vm->retval, &string, &slice);\n    }\n\n    string.start += slice.start;\n\n    length = njs_utf8_length(string.start, slice.length);\n\n    if (length >= 0) {\n        return njs_string_new(vm, &vm->retval, string.start, slice.length,\n                              length);\n    }\n\n    vm->retval = njs_value_null;\n\n    return NJS_OK;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":336678,"func":"static red::shared_ptr<RedVDIReadBuf> vdi_port_get_read_buf(RedCharDeviceVDIPort *dev)\n{\n    if (dev->priv->num_read_buf >= REDS_VDI_PORT_NUM_RECEIVE_BUFFS) {\n        return red::shared_ptr<RedVDIReadBuf>();\n    }\n\n    dev->priv->num_read_buf++;\n    return vdi_read_buf_new(dev);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":101676,"func":"void WebProcessProxy::didUpdateHistoryTitle(uint64_t pageID, const String& title, const String& url, uint64_t frameID)\n{\n    WebPageProxy* page = webPage(pageID);\n    if (!page)\n        return;\n\n    WebFrameProxy* frame = webFrame(frameID);\n    MESSAGE_CHECK(frame);\n    MESSAGE_CHECK(frame->page() == page);\n    MESSAGE_CHECK_URL(url);\n\n    m_context->historyClient().didUpdateHistoryTitle(m_context.get(), page, title, url, frame);\n}\n","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":463198,"func":"static int rw_cb(const char *mailbox __attribute__((unused)),\n                 uint32_t uid __attribute__((unused)),\n                 const char *entry, const char *userid,\n                 const struct buf *value,\n                 const struct annotate_metadata *mdata __attribute__((unused)),\n                 void *rock)\n{\n    annotate_state_t *state = (annotate_state_t *)rock;\n\n    if (!userid[0] || !strcmp(userid, state->userid)) {\n        output_entryatt(state, entry, userid, value);\n    }\n\n    return 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":436065,"func":"static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n{\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->buf_index)\n\t\treturn -EINVAL;\n\tif (req->flags & REQ_F_FIXED_FILE)\n\t\treturn -EBADF;\n\n\treq->statx.dfd = READ_ONCE(sqe->fd);\n\treq->statx.mask = READ_ONCE(sqe->len);\n\treq->statx.filename = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\treq->statx.buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2));\n\treq->statx.flags = READ_ONCE(sqe->statx_flags);\n\n\treturn 0;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":328880,"func":"R_API char *r_bin_java_build_obj_key(RBinJavaObj *bin) {\n\tchar *cname = r_bin_java_get_this_class_name (bin);\n\tchar *jvcname = cname?\n\t\tr_str_newf (\"%d.%s.class\", bin->id, cname)\n\t\t: r_str_newf (\"%d._unknown_.class\", bin->id);\n\tfree (cname);\n\treturn jvcname;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":513363,"func":"join_read_last_key(JOIN_TAB *tab)\n{\n  int error;\n  TABLE *table= tab->table;\n\n  if (!table->file->inited &&\n      (error= table->file->ha_index_init(tab->ref.key, tab->sorted)))\n  {\n    (void) report_error(table, error);\n    return 1;\n  }\n\n  if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))\n    return -1;\n  if ((error= table->file->prepare_index_key_scan_map(tab->ref.key_buff, make_prev_keypart_map(tab->ref.key_parts)))) \n  {\n    report_error(table,error);\n    return -1;\n  }\n  if ((error= table->file->ha_index_read_map(table->record[0],\n                                            tab->ref.key_buff,\n                                     make_prev_keypart_map(tab->ref.key_parts),\n                                            HA_READ_PREFIX_LAST)))\n  {\n    if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)\n      return report_error(table, error);\n    return -1; \/* purecov: inspected *\/\n  }\n  return 0;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":253998,"func":"static int vidioc_s_std(struct file *file, void *private_data, v4l2_std_id *_std)\n{\n\tv4l2_std_id req_std = 0, supported_std = 0;\n\tconst v4l2_std_id all_std = V4L2_STD_ALL, no_std = 0;\n\n\tif (_std) {\n\t\treq_std = *_std;\n\t\t*_std = all_std;\n\t}\n\n\t\/* we support everything in V4L2_STD_ALL, but not more... *\/\n\tsupported_std = (all_std & req_std);\n\tif (no_std == supported_std)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":477383,"func":"R_API RBinJavaAttrInfo *r_bin_java_deprecated_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaAttrInfo *attr = NULL;\n\tut64 offset = 0;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_DEPRECATED_ATTR;\n\t\tattr->size = offset;\n\t}\n\t\/\/ IFDBG r_bin_java_print_deprecated_attr_summary(attr);\n\treturn attr;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":508899,"func":"bool st_select_lex::add_gorder_to_list(THD *thd, Item *item, bool asc)\n{\n  return add_to_list(thd, gorder_list, item, asc);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":317131,"func":"static int selinux_capset(struct cred *new, const struct cred *old,\n\t\t\t  const kernel_cap_t *effective,\n\t\t\t  const kernel_cap_t *inheritable,\n\t\t\t  const kernel_cap_t *permitted)\n{\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    cred_sid(old), cred_sid(new), SECCLASS_PROCESS,\n\t\t\t    PROCESS__SETCAP, NULL);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":326106,"func":"reginsert_nr(int op, long val, char_u *opnd)\n{\n    char_u\t*src;\n    char_u\t*dst;\n    char_u\t*place;\n\n    if (regcode == JUST_CALC_SIZE)\n    {\n\tregsize += 7;\n\treturn;\n    }\n    src = regcode;\n    regcode += 7;\n    dst = regcode;\n    while (src > opnd)\n\t*--dst = *--src;\n\n    place = opnd;\t\t\/\/ Op node, where operand used to be.\n    *place++ = op;\n    *place++ = NUL;\n    *place++ = NUL;\n    re_put_long(place, (long_u)val);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":225797,"func":"void dimm_box_del(GF_Box *s)\n{\n\tgf_free((GF_DIMMBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":512376,"func":"  Field *default_field() const { return m_default_field; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":344268,"func":"static l_noret typeerror (lua_State *L, const TValue *o, const char *op,\n                          const char *extra) {\n  const char *t = luaT_objtypename(L, o);\n  luaG_runerror(L, \"attempt to %s a %s value%s\", op, t, extra);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":139258,"func":"gfx::Point OverlayWindowViews::resize_handle_position_for_testing() const {\n  return resize_handle_view_->origin();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":181944,"func":"gfx::Point OverlayWindowViews::close_image_position_for_testing() const {\n  return close_controls_view_->origin();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":276904,"func":"static int do_i2c_nm(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t     char *const argv[])\n{\n\treturn mod_i2c_mem (cmdtp, 0, flag, argc, argv);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":256951,"func":"  static bool ShouldTranspose(const TensorShape& input_shape,\n                              const std::vector<int>& permutation) {\n    if (input_shape.dims() < 2) return false;\n    for (int i = 0; i < permutation.size(); ++i) {\n      if (permutation[i] != i) return true;\n    }\n    return false;\n  }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":221128,"func":"GF_VVCConfig *gf_odf_vvc_cfg_read(u8 *dsi, u32 dsi_size)\n{\n\tGF_BitStream *bs = gf_bs_new(dsi, dsi_size, GF_BITSTREAM_READ);\n\tGF_VVCConfig *cfg = gf_odf_vvc_cfg_read_bs(bs);\n\tgf_bs_del(bs);\n\treturn cfg;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":236138,"func":"GF_Err text_box_size(GF_Box *s)\n{\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\ts->size += 8;\n\t\/*base + this + string length*\/\n\ts->size += 43 + 1;\n\tif (ptr->textName)\n\t\ts->size += strlen(ptr->textName);\n\treturn GF_OK;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":225691,"func":"\nGF_Err dfla_box_size(GF_Box *s)\n{\n\tGF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s;\n\tptr->size += ptr->dataSize;\n\treturn GF_OK;","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":466148,"func":"static int em_mov(struct x86_emulate_ctxt *ctxt)\n{\n\tctxt->dst.val = ctxt->src.val;\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512579,"func":"int cmp_item_time::cmp_not_null(const Value *val)\n{\n  DBUG_ASSERT(!val->is_null());\n  DBUG_ASSERT(val->is_temporal());\n  return value != pack_time(&val->value.m_time);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":90786,"func":"  InitializeTemporaryOriginsInfoTask(\n      QuotaManager* manager,\n      UsageTracker* temporary_usage_tracker)\n      : DatabaseTaskBase(manager),\n        has_registered_origins_(false) {\n    DCHECK(temporary_usage_tracker);\n    temporary_usage_tracker->GetCachedOrigins(&origins_);\n  }\n","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":326099,"func":"save_se_one(save_se_T *savep, char_u **pp)\n{\n    savep->se_u.ptr = *pp;\n    *pp = rex.input;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":241309,"func":"mrb_instance_new(mrb_state *mrb, mrb_value cv)\n{\n  mrb_value obj, blk;\n  const mrb_value *argv;\n  mrb_int argc;\n  mrb_sym init;\n\n  mrb_get_args(mrb, \"*!&\", &argv, &argc, &blk);\n  obj = mrb_instance_alloc(mrb, cv);\n  init = MRB_SYM(initialize);\n  if (!mrb_func_basic_p(mrb, obj, init, mrb_do_nothing)) {\n    mrb_funcall_with_block(mrb, obj, init, argc, argv, blk);\n  }\n  return obj;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":393536,"func":"static SQInteger base_dummy(HSQUIRRELVM SQ_UNUSED_ARG(v))\n{\n    return 0;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":265537,"func":"int mempool_reserved_space(MemoryPoolHandle handle, size_t *free_bytes) {\n  struct mempool *pool = (struct mempool *)handle;\n\n  if ((pool == NULL) || (free_bytes == NULL)) {\n    return S3_MEMPOOL_INVALID_ARG;\n  }\n\n  if (pool->flags & ENABLE_LOCKING) {\n    pthread_mutex_lock(&pool->lock);\n  }\n\n  *free_bytes = pool->mempool_item_size * pool->free_bufs_in_pool;\n\n  if ((pool->flags & ENABLE_LOCKING) != 0) {\n    pthread_mutex_unlock(&pool->lock);\n  }\n\n  return 0;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":272356,"func":"teardown_digests(cms_context *ctx)\n{\n\tstruct digest *digests = ctx->digests;\n\n\tif (!digests)\n\t\treturn;\n\n\tfor (int i = 0; i < n_digest_params; i++) {\n\t\tif (digests[i].pk11ctx) {\n\t\t\tPK11_Finalize(digests[i].pk11ctx);\n\t\t\tPK11_DestroyContext(digests[i].pk11ctx, PR_TRUE);\n\t\t}\n\t\tif (digests[i].pe_digest) {\n\t\t\t\/* XXX sure seems like we should be freeing it here,\n\t\t\t * but that's segfaulting, and we know it'll get\n\t\t\t * cleaned up with PORT_FreeArena a couple of lines\n\t\t\t * down.\n\t\t\t *\/\n\t\t\tdigests[i].pe_digest = NULL;\n\t\t}\n\t}\n\tPORT_Free(digests);\n\tctx->digests = NULL;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":430335,"func":"static void *seq_buf_alloc(unsigned long size)\n{\n\tif (unlikely(size > MAX_RW_COUNT))\n\t\treturn NULL;\n\n\treturn kvmalloc(size, GFP_KERNEL_ACCOUNT);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":294554,"func":"dup_obj_as_complex(VALUE self)\n{\n    get_d1a(self);\n\n    if (simple_dat_p(adat)) {\n\tVALUE new = d_lite_s_alloc_complex(rb_obj_class(self));\n\t{\n\t    get_d1b(new);\n\t    copy_simple_to_complex(new, &bdat->c, &adat->s);\n\t    bdat->c.flags |= HAVE_DF | COMPLEX_DAT;\n\t    return new;\n\t}\n    }\n    else {\n\tVALUE new = d_lite_s_alloc_complex(rb_obj_class(self));\n\t{\n\t    get_d1b(new);\n\t    bdat->c = adat->c;\n\t    RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);\n\t    RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);\n\t    return new;\n\t}\n    }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":513104,"func":"  uint decimal_scale() const\n  {\n    return type_handler()->Item_decimal_scale(this);\n  }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":432307,"func":"static inline void flatview_ref(FlatView *view)\n{\n    view->ref++;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":301433,"func":"static SMB_ACL_T vfswrap_sys_acl_get_file(vfs_handle_struct *handle,\n\t\t\t\t\t  const char *path_p,\n\t\t\t\t\t  SMB_ACL_TYPE_T type,\n\t\t\t\t\t  TALLOC_CTX *mem_ctx)\n{\n\treturn sys_acl_get_file(handle, path_p, type, mem_ctx);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":254719,"func":"njs_typed_array_compare_i8(const void *a, const void *b, void *c)\n{\n    return *((const int8_t *) a) - *((const int8_t *) b);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":275474,"func":"njs_vm_memory_error(njs_vm_t *vm)\n{\n    njs_memory_error_set(vm, &vm->retval);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":279933,"func":"ex_write(exarg_T *eap)\n{\n    if (eap->cmdidx == CMD_saveas)\n    {\n\t\/\/ :saveas does not take a range, uses all lines.\n\teap->line1 = 1;\n\teap->line2 = curbuf->b_ml.ml_line_count;\n    }\n\n    if (eap->usefilter)\t\t\/\/ input lines to shell command\n\tdo_bang(1, eap, FALSE, TRUE, FALSE);\n    else\n\t(void)do_write(eap);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":393522,"func":"static SQInteger base_print(HSQUIRRELVM v)\n{\n    const SQChar *str;\n    if(SQ_SUCCEEDED(sq_tostring(v,2)))\n    {\n        if(SQ_SUCCEEDED(sq_getstring(v,-1,&str))) {\n            if(_ss(v)->_printfunc) _ss(v)->_printfunc(v,_SC(\"%s\"),str);\n            return 0;\n        }\n    }\n    return SQ_ERROR;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":242608,"func":"  Status Peek(std::size_t index, Tuple* tuple) {\n    std::unique_lock<std::mutex> lock(mu_);\n\n    \/\/ Wait if the requested index is not available\n    non_empty_cond_var_.wait(\n        lock, [index, this]() { return index < this->buf_.size(); });\n\n    \/\/ Place tensors in the output tuple\n    for (const auto& tensor : buf_[index]) {\n      tuple->push_back(tensor);\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":343243,"func":"void dostru(const char *arg)\n{\n    if (arg == NULL || !*arg) {\n        addreply_noformat(501, MSG_MISSING_ARG);\n    } else if (strcasecmp(arg, \"F\")) {\n        addreply_noformat(504, MSG_STRU_FAILURE);\n    } else {\n        addreply_noformat(200, \"F OK\");\n    }\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":221407,"func":"static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)\n{\n\t\/*\n\t * This function merges the msr permission bitmaps of kvm and the\n\t * nested vmcb. It is optimized in that it only merges the parts where\n\t * the kvm msr permission bitmap may contain zero bits\n\t *\/\n\tint i;\n\n\tif (!(vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))\n\t\treturn true;\n\n\tfor (i = 0; i < MSRPM_OFFSETS; i++) {\n\t\tu32 value, p;\n\t\tu64 offset;\n\n\t\tif (msrpm_offsets[i] == 0xffffffff)\n\t\t\tbreak;\n\n\t\tp      = msrpm_offsets[i];\n\t\toffset = svm->nested.ctl.msrpm_base_pa + (p * 4);\n\n\t\tif (kvm_vcpu_read_guest(&svm->vcpu, offset, &value, 4))\n\t\t\treturn false;\n\n\t\tsvm->nested.msrpm[p] = svm->msrpm[p] | value;\n\t}\n\n\tsvm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm));\n\n\treturn true;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":509477,"func":"static enum data_file_type maria_row_type(HA_CREATE_INFO *info)\n{\n  if (info->transactional == HA_CHOICE_YES)\n    return BLOCK_RECORD;\n  switch (info->row_type) {\n  case ROW_TYPE_FIXED:   return STATIC_RECORD;\n  case ROW_TYPE_DYNAMIC: return DYNAMIC_RECORD;\n  default:               return BLOCK_RECORD;\n  }\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":224236,"func":"static int _find_sm_by_from_vaddr_cb(void *incoming, void *in, void *user) {\n\tRIOSubMap *bd = (RIOSubMap *)incoming, *sm = (RIOSubMap *)in;\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm)) {\n\t\treturn -1;\n\t}\n\tif (r_io_submap_from (bd) > r_io_submap_from (sm)) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":231795,"func":"  Buf recvEncryptedStream(\n      StreamId streamId,\n      folly::IOBuf& data,\n      uint64_t offset = 0,\n      bool eof = false) {\n    PacketNum packetNum = clientNextAppDataPacketNum++;\n    auto packetData = packetToBuf(createStreamPacket(\n        clientConnectionId.value_or(getTestConnectionId()),\n        *server->getConn().serverConnectionId,\n        packetNum,\n        streamId,\n        data,\n        0 \/* cipherOverhead *\/,\n        0 \/* largestAcked *\/,\n        folly::none \/* longHeaderOverride *\/,\n        eof,\n        folly::none,\n        offset));\n    deliverData(packetData->clone());\n    return packetData;\n  }","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":446427,"func":"static cache_accel_t *read_cache_accel(RzBuffer *cache_buf, cache_hdr_t *hdr, cache_map_t *maps) {\n\tif (!cache_buf || !hdr || !hdr->accelerateInfoSize || !hdr->accelerateInfoAddr) {\n\t\treturn NULL;\n\t}\n\n\tut64 offset = va2pa(hdr->accelerateInfoAddr, hdr->mappingCount, maps, cache_buf, 0, NULL, NULL);\n\tif (!offset) {\n\t\treturn NULL;\n\t}\n\n\tut64 size = sizeof(cache_accel_t);\n\tcache_accel_t *accel = RZ_NEW0(cache_accel_t);\n\tif (!accel) {\n\t\treturn NULL;\n\t}\n\n\tif (rz_buf_fread_at(cache_buf, offset, (ut8 *)accel, \"16il\", 1) != size) {\n\t\tRZ_FREE(accel);\n\t\treturn NULL;\n\t}\n\n\taccel->imagesExtrasOffset += offset;\n\taccel->bottomUpListOffset += offset;\n\taccel->dylibTrieOffset += offset;\n\taccel->initializersOffset += offset;\n\taccel->dofSectionsOffset += offset;\n\taccel->reExportListOffset += offset;\n\taccel->depListOffset += offset;\n\taccel->rangeTableOffset += offset;\n\n\treturn accel;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":344245,"func":"lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {\n  if (l_unlikely(l_castS2U(n) + 1u <= 1u)) {  \/* special cases: -1 or 0 *\/\n    if (n == 0)\n      luaG_runerror(L, \"attempt to perform 'n%%0'\");\n    return 0;   \/* m % -1 == 0; avoid overflow with 0x80000...%-1 *\/\n  }\n  else {\n    lua_Integer r = m % n;\n    if (r != 0 && (r ^ n) < 0)  \/* 'm\/n' would be non-integer negative? *\/\n      r += n;  \/* correct result for different rounding *\/\n    return r;\n  }\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":229172,"func":"static void virtio_serial_post_load_timer_cb(void *opaque)\n{\n    uint32_t i;\n    VirtIOSerial *s = VIRTIO_SERIAL(opaque);\n    VirtIOSerialPort *port;\n    uint8_t host_connected;\n    VirtIOSerialPortClass *vsc;\n\n    if (!s->post_load) {\n        return;\n    }\n    for (i = 0 ; i < s->post_load->nr_active_ports; ++i) {\n        port = s->post_load->connected[i].port;\n        host_connected = s->post_load->connected[i].host_connected;\n        if (host_connected != port->host_connected) {\n            \/*\n             * We have to let the guest know of the host connection\n             * status change\n             *\/\n            send_control_event(s, port->id, VIRTIO_CONSOLE_PORT_OPEN,\n                               port->host_connected);\n        }\n        vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n        if (vsc->set_guest_connected) {\n            vsc->set_guest_connected(port, port->guest_connected);\n        }\n    }\n    g_free(s->post_load->connected);\n    timer_free(s->post_load->timer);\n    g_free(s->post_load);\n    s->post_load = NULL;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":459154,"func":"tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain)\n{\n\tstruct tcf_chain *chain_next = __tcf_get_next_chain(block, chain);\n\n\tif (chain)\n\t\ttcf_chain_put(chain);\n\n\treturn chain_next;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":301018,"func":"pcxcmyk_print_page(gx_device_printer * pdev, gp_file * file)\n{\n    pcx_header header;\n\n    header = pcx_header_prototype;\n    header.version = 2;\n    header.bpp = 4;\n    header.nplanes = 1;\n    \/* Fill the palette appropriately. *\/\n    memcpy((byte *) header.palette, pcx_cmyk_palette,\n           sizeof(pcx_cmyk_palette));\n    return pcx_write_page(pdev, file, &header, false);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":484065,"func":"START_TEST(SecureChannel_sendSymmetricMessage_modeNone) {\n    \/\/ initialize dummy message\n    UA_ReadRequest dummyMessage;\n    UA_ReadRequest_init(&dummyMessage);\n    UA_DataType dummyType = UA_TYPES[UA_TYPES_READREQUEST];\n\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_NONE;\n\n    UA_StatusCode retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42, UA_MESSAGETYPE_MSG,\n                                                                 &dummyMessage, &dummyType);\n    ck_assert_msg(retval == UA_STATUSCODE_GOOD, \"Expected success\");\n    ck_assert_msg(!fCalled.sym_sign, \"Expected message to not have been signed\");\n    ck_assert_msg(!fCalled.sym_enc, \"Expected message to not have been encrypted\");\n} END_TEST","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":366186,"func":"static inline struct hlist_head *mp_hash(struct dentry *dentry)\n{\n\tunsigned long tmp = ((unsigned long)dentry \/ L1_CACHE_BYTES);\n\ttmp = tmp + (tmp >> mp_hash_shift);\n\treturn &mountpoint_hashtable[tmp & mp_hash_mask];\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":389551,"func":"xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,\n              xmlInputCloseCallback ioclose, void *ioctx,\n\t      const char *URL,\n              const char *encoding, int options)\n{\n    xmlParserInputBufferPtr input;\n    xmlParserInputPtr stream;\n\n    if (ioread == NULL)\n        return (NULL);\n    if (ctxt == NULL)\n        return (NULL);\n\n    xmlCtxtReset(ctxt);\n\n    input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,\n                                         XML_CHAR_ENCODING_NONE);\n    if (input == NULL)\n        return (NULL);\n    stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);\n    if (stream == NULL) {\n        xmlFreeParserInputBuffer(input);\n        return (NULL);\n    }\n    inputPush(ctxt, stream);\n    return (xmlDoRead(ctxt, URL, encoding, options, 1));\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":436109,"func":"\t__must_hold(&req->ctx->completion_lock)\n{\n\tbool posted = false;\n\n\tif (likely(req->flags & REQ_F_LINK_TIMEOUT))\n\t\tposted = io_kill_linked_timeout(req);\n\tif (unlikely((req->flags & REQ_F_FAIL) &&\n\t\t     !(req->flags & REQ_F_HARDLINK))) {\n\t\tposted |= (req->link != NULL);\n\t\tio_fail_links(req);\n\t}\n\treturn posted;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":432221,"func":"static void flatview_simplify(FlatView *view)\n{\n    unsigned i, j;\n\n    i = 0;\n    while (i < view->nr) {\n        j = i + 1;\n        while (j < view->nr\n               && can_merge(&view->ranges[j-1], &view->ranges[j])) {\n            int128_addto(&view->ranges[i].addr.size, view->ranges[j].addr.size);\n            ++j;\n        }\n        ++i;\n        memmove(&view->ranges[i], &view->ranges[j],\n                (view->nr - j) * sizeof(view->ranges[j]));\n        view->nr -= j - i;\n    }\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":301409,"func":"static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)\n{\n\treturn false;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":500647,"func":"unsigned long sftp_tell(sftp_file file) {\n  return (unsigned long)file->offset;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":278280,"func":"preprocs_left(void)\n{\n    return\n\t(curbuf->b_p_si && !curbuf->b_p_cin) ||\n\t(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE)\n\t\t\t\t\t   && curbuf->b_ind_hash_comment == 0)\n\t;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":455398,"func":"xfs_icache_inode_is_allocated(\n\tstruct xfs_mount\t*mp,\n\tstruct xfs_trans\t*tp,\n\txfs_ino_t\t\tino,\n\tbool\t\t\t*inuse)\n{\n\tstruct xfs_inode\t*ip;\n\tint\t\t\terror;\n\n\terror = xfs_iget(mp, tp, ino, XFS_IGET_INCORE, 0, &ip);\n\tif (error)\n\t\treturn error;\n\n\t*inuse = !!(VFS_I(ip)->i_mode);\n\tIRELE(ip);\n\treturn 0;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":225097,"func":"void RemoveDescriptionsFromOpDef(OpDef* op_def) {\n  RemoveNonDeprecationDescriptionsFromOpDef(op_def);\n  if (op_def->has_deprecation()) {\n    op_def->mutable_deprecation()->clear_explanation();\n  }\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":223439,"func":"static PCRE2_SPTR SLJIT_FUNC do_script_run_utf(PCRE2_SPTR ptr, PCRE2_SPTR endptr)\n{\n  if (PRIV(script_run)(ptr, endptr, TRUE))\n    return endptr;\n  return NULL;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":359446,"func":"zlog_rotate (struct zlog *zl)\n{\n  int level;\n\n  if (zl == NULL)\n    zl = zlog_default;\n\n  if (zl->fp)\n    fclose (zl->fp);\n  zl->fp = NULL;\n  logfile_fd = -1;\n  level = zl->maxlvl[ZLOG_DEST_FILE];\n  zl->maxlvl[ZLOG_DEST_FILE] = ZLOG_DISABLED;\n\n  if (zl->filename)\n    {\n      mode_t oldumask;\n      int save_errno;\n\n      oldumask = umask (0777 & ~LOGFILE_MASK);\n      zl->fp = fopen (zl->filename, \"a\");\n      save_errno = errno;\n      umask(oldumask);\n      if (zl->fp == NULL)\n        {\n\t  zlog_err(\"Log rotate failed: cannot open file %s for append: %s\",\n\t  \t   zl->filename, safe_strerror(save_errno));\n\t  return -1;\n        }\t\n      logfile_fd = fileno(zl->fp);\n      zl->maxlvl[ZLOG_DEST_FILE] = level;\n    }\n\n  return 1;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":380958,"func":"ins_pagedown(void)\n{\n    pos_T\ttpos;\n\n    undisplay_dollar();\n\n    if (mod_mask & MOD_MASK_CTRL)\n    {\n\t\/\/ <C-PageDown>: tab page forward\n\tif (first_tabpage->tp_next != NULL)\n\t{\n\t    start_arrow(&curwin->w_cursor);\n\t    goto_tabpage(0);\n\t}\n\treturn;\n    }\n\n    tpos = curwin->w_cursor;\n    if (onepage(FORWARD, 1L) == OK)\n    {\n\tstart_arrow(&tpos);\n\tcan_cindent = TRUE;\n    }\n    else\n\tvim_beep(BO_CRSR);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":446096,"func":"static void atusb_disconnect(struct usb_interface *interface)\n{\n\tstruct atusb *atusb = usb_get_intfdata(interface);\n\n\tdev_dbg(&atusb->usb_dev->dev, \"%s\\n\", __func__);\n\n\tatusb->shutdown = 1;\n\tcancel_delayed_work_sync(&atusb->work);\n\n\tusb_kill_anchored_urbs(&atusb->rx_urbs);\n\tatusb_free_urbs(atusb);\n\tusb_kill_urb(atusb->tx_urb);\n\tusb_free_urb(atusb->tx_urb);\n\n\tieee802154_unregister_hw(atusb->hw);\n\n\tusb_put_dev(atusb->usb_dev);\n\n\tieee802154_free_hw(atusb->hw);\n\n\tusb_set_intfdata(interface, NULL);\n\n\tpr_debug(\"%s done\\n\", __func__);\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":90133,"func":"  virtual void EnableOfflineMode(bool enable) {}\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":521455,"func":"bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progress) const\r\n{\r\n    auto fileStart = target.getPosition();\r\n\r\n    for (int i = 0; i < items.size(); ++i)\r\n    {\r\n        if (progress != nullptr)\r\n            *progress = (i + 0.5) \/ items.size();\r\n\r\n        if (! items.getUnchecked (i)->writeData (target, fileStart))\r\n            return false;\r\n    }\r\n\r\n    auto directoryStart = target.getPosition();\r\n\r\n    for (auto* item : items)\r\n        if (! item->writeDirectoryEntry (target))\r\n            return false;\r\n\r\n    auto directoryEnd = target.getPosition();\r\n\r\n    target.writeInt (0x06054b50);\r\n    target.writeShort (0);\r\n    target.writeShort (0);\r\n    target.writeShort ((short) items.size());\r\n    target.writeShort ((short) items.size());\r\n    target.writeInt ((int) (directoryEnd - directoryStart));\r\n    target.writeInt ((int) (directoryStart - fileStart));\r\n    target.writeShort (0);\r\n\r\n    if (progress != nullptr)\r\n        *progress = 1.0;\r\n\r\n    return true;\r\n}\r","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":336623,"func":"void reds_enable_mm_time(RedsState *reds)\n{\n    reds->mm_time_enabled = TRUE;\n    reds->mm_time_latency = MM_TIME_DELTA;\n    reds_send_mm_time(reds);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":369404,"func":"static inline void io_get_task_refs(int nr)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\n\ttctx->cached_refs -= nr;\n\tif (unlikely(tctx->cached_refs < 0))\n\t\tio_task_refs_refill(tctx);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":415194,"func":"cmd_checkpin (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  char *idstr;\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  if (!ctrl->app_ctx)\n    return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);\n\n  \/* We have to use a copy of the key ID because the function may use\n     the pin_cb which in turn uses the assuan line buffer and thus\n     overwriting the original line with the keyid. *\/\n  idstr = xtrystrdup (line);\n  if (!idstr)\n    return out_of_core ();\n\n  rc = app_check_pin (ctrl->app_ctx, idstr, pin_cb, ctx);\n  xfree (idstr);\n  if (rc)\n    log_error (\"app_check_pin failed: %s\\n\", gpg_strerror (rc));\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":445942,"func":"notify_action_open_archive_cb (NotifyNotification *notification,\n\t\t\t       char               *action,\n\t\t\t       gpointer            user_data)\n{\n\tNotifyData *notify_data = user_data;\n\tFrWindow   *window = notify_data->window;\n\tGtkWidget  *new_window;\n\n\tnew_window = fr_window_new ();\n\tgtk_widget_show (new_window);\n\tfr_window_archive_open (FR_WINDOW (new_window),\n\t\t\t\twindow->priv->saving_file,\n\t\t\t\tGTK_WINDOW (new_window));\n\n\tnotify_data->window_closed = TRUE;\n\t_fr_window_close_after_notification (window);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":221130,"func":"GF_Err gf_odf_ac3_config_parse(u8 *dsi, u32 dsi_len, Bool is_ec3, GF_AC3Config *cfg)\n{\n\tGF_BitStream *bs;\n\tGF_Err e;\n\tif (!cfg || !dsi) return GF_BAD_PARAM;\n\tbs = gf_bs_new(dsi, dsi_len, GF_BITSTREAM_READ);\n\te = gf_odf_ac3_config_parse_bs(bs, is_ec3, cfg);\n\tgf_bs_del(bs);\n\treturn e;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":222490,"func":"  const NameInfoItem* GetItemOrNull(const string& name) const {\n    return gtl::FindOrNull(index_, name);\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":90805,"func":"void QuotaManager::RegisterClient(QuotaClient* client) {\n  DCHECK(io_thread_->BelongsToCurrentThread());\n  DCHECK(!database_.get());\n  clients_.push_back(client);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":369402,"func":"\nstatic inline void io_poll_execute(struct io_kiocb *req, int res, int events)\n{\n\tif (io_poll_get_ownership(req))\n\t\t__io_poll_execute(req, res, events);","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":226273,"func":"\nvoid lsr1_box_del(GF_Box *s)\n{\n\tGF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\tif (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);\n\tgf_free(ptr);","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":270766,"func":"static int write_env_passwd(unsigned char *sum, size_t length)\n{\n\tint fd;\n\tunsigned char c;\n\tint ret = 0;\n\n\tif (!sum && length < 1)\n\t\treturn -EINVAL;\n\n\tfd = open(PASSWD_DIR, O_RDONLY);\n\n\tif (fd < 0)\n\t\tmkdir(PASSWD_DIR, 644);\n\n\tclose(fd);\n\n\tfd = open(PASSWD_FILE, O_WRONLY | O_CREAT, 600);\n\n\tif (fd < 0)\n\t\treturn fd;\n\n\tdo {\n\t\tc = to_hexa(*sum >> 4 & 0xf);\n\n\t\tret = write(fd, &c, sizeof(unsigned char));\n\n\t\tif (ret < 0)\n\t\t\tgoto exit;\n\n\t\tc = to_hexa(*sum & 0xf);\n\n\t\tret = write(fd, &c, sizeof(unsigned char));\n\n\t\tif (ret < 0)\n\t\t\tgoto exit;\n\n\t\tsum++;\n\t\tlength--;\n\t} while(length > 0);\n\n\tret = 0;\n\nexit:\n\tclose(fd);\n\n\treturn ret;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":225932,"func":"GF_Err gnrm_box_size(GF_Box *s)\n{\n\tGF_GenericSampleEntryBox *ptr = (GF_GenericSampleEntryBox *)s;\n\ts->type = GF_ISOM_BOX_TYPE_GNRM;\n\tptr->size += 8+ptr->data_size;\n\treturn GF_OK;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":224567,"func":"Status AvgPoolGradShape(shape_inference::InferenceContext* c) {\n  ShapeHandle s;\n  TF_RETURN_IF_ERROR(c->MakeShapeFromShapeTensor(0, &s));\n  TF_RETURN_IF_ERROR(c->WithRank(s, 4, &s));\n  c->set_output(0, s);\n  return Status::OK();\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":445949,"func":"fr_window_free_batch_data (FrWindow *window)\n{\n\tGList *scan;\n\n\tfor (scan = window->priv->batch_action_list; scan; scan = scan->next) {\n\t\tFrBatchAction *adata = scan->data;\n\n\t\tif ((adata->data != NULL) && (adata->free_func != NULL))\n\t\t\t(*adata->free_func) (adata->data);\n\t\tg_free (adata);\n\t}\n\n\tg_list_free (window->priv->batch_action_list);\n\twindow->priv->batch_action_list = NULL;\n\twindow->priv->batch_action = NULL;\n\n\tfr_window_reset_current_batch_action (window);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":289326,"func":"static int _snd_pcm_hw_param_mask(struct snd_pcm_hw_params *params,\n\t\t\t\t  snd_pcm_hw_param_t var,\n\t\t\t\t  const struct snd_mask *val)\n{\n\tint changed;\n\tchanged = snd_mask_refine(hw_param_mask(params, var), val);\n\tif (changed > 0) {\n\t\tparams->cmask |= 1 << var;\n\t\tparams->rmask |= 1 << var;\n\t}\n\treturn changed;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":512722,"func":"static int cmp_decimal(void *cmp_arg, my_decimal *a, my_decimal *b)\n{\n  \/*\n    We need call of fixing buffer pointer, because fast sort just copy\n    decimal buffers in memory and pointers left pointing on old buffer place\n  *\/\n  a->fix_buffer_pointer();\n  b->fix_buffer_pointer();\n  return my_decimal_cmp(a, b);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":512930,"func":"void in_timestamp::value_to_item(uint pos, Item *item)\n{\n  const Timestamp_or_zero_datetime &buff= (((Timestamp_or_zero_datetime*) base)[pos]);\n  static_cast<Item_timestamp_literal*>(item)->set_value(buff);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":359306,"func":"DEFUN (bgp_redistribute_ipv4_metric,\n       bgp_redistribute_ipv4_metric_cmd,\n       \"redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>\",\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPF)\\n\"\n       \"Routing Information Protocol (RIP)\\n\"\n       \"Static routes\\n\"\n       \"Metric for redistributed routes\\n\"\n       \"Default metric\\n\")\n{\n  int type;\n  u_int32_t metric;\n\n  type = bgp_str2route_type (AFI_IP, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n  VTY_GET_INTEGER (\"metric\", metric, argv[1]);\n\n  bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);\n  return bgp_redistribute_set (vty->index, AFI_IP, type);\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":238608,"func":"static void __mark_reg32_known(struct bpf_reg_state *reg, u64 imm)\n{\n\treg->var_off = tnum_const_subreg(reg->var_off, imm);\n\treg->s32_min_value = (s32)imm;\n\treg->s32_max_value = (s32)imm;\n\treg->u32_min_value = (u32)imm;\n\treg->u32_max_value = (u32)imm;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":265047,"func":"set_colour_code(char *str, char **var)\n{\n    char *keyseq;\n    int len;\n\n    zsfree(*var);\n    keyseq = getkeystring(str, &len, GETKEYS_BINDKEY, NULL);\n    *var = metafy(keyseq, len, META_DUP);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":294559,"func":"jd_utc_to_local(int jd, int df, int of)\n{\n    df += of;\n    if (df < 0)\n\tjd -= 1;\n    else if (df >= DAY_IN_SECONDS)\n\tjd += 1;\n    return jd;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":162322,"func":"bool decode(ArgumentDecoder* decoder, RetainPtr<CFURLRef>& result)\n{\n    RetainPtr<CFURLRef> baseURL;\n    bool hasBaseURL;\n    if (!decoder->decodeBool(hasBaseURL))\n        return false;\n    if (hasBaseURL) {\n        if (!decode(decoder, baseURL))\n            return false;\n    }\n\n    RetainPtr<CFStringRef> string;\n     if (!decode(decoder, string))\n         return false;\n \n#if PLATFORM(MAC)\n    \/\/ FIXME: Move this to ArgumentCodersCFMac.mm and change this file back to be C++\n    \/\/ instead of Objective-C++.\n    if (!CFStringGetLength(string.get())) {\n        \/\/ CFURL can't hold an empty URL, unlike NSURL.\n        result = reinterpret_cast<CFURLRef>([NSURL URLWithString:@\"\"]);\n        return true;\n    }\n#endif\n                    \n     CFURLRef url = CFURLCreateWithString(0, string.get(), baseURL.get());\n     if (!url)\n         return false;\n\n    result.adoptCF(url);\n    return true;\n}\n","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":513197,"func":"plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type)\n{\n  LEX *lex= thd ? thd->lex : 0;\n  plugin_ref rc= NULL;\n  st_plugin_int *plugin;\n  DBUG_ENTER(\"plugin_lock_by_name\");\n  mysql_mutex_lock(&LOCK_plugin);\n  if ((plugin= plugin_find_internal(name, type)))\n    rc= intern_plugin_lock(lex, plugin_int_to_ref(plugin));\n  mysql_mutex_unlock(&LOCK_plugin);\n  DBUG_RETURN(rc);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":434089,"func":"ex_previous(exarg_T *eap)\n{\n    \/\/ If past the last one already, go to the last one.\n    if (curwin->w_arg_idx - (int)eap->line2 >= ARGCOUNT)\n\tdo_argfile(eap, ARGCOUNT - 1);\n    else\n\tdo_argfile(eap, curwin->w_arg_idx - (int)eap->line2);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":267355,"func":"append_env (const char *arg)\n{\n  exec_options.env = realloc (exec_options.env, (exec_options.env_size + 2) * sizeof (*exec_options.env));\n  if (exec_options.env == NULL)\n    error (EXIT_FAILURE, errno, \"cannot allocate memory\");\n  exec_options.env[exec_options.env_size + 1] = NULL;\n  exec_options.env[exec_options.env_size] = xstrdup (arg);\n  exec_options.env_size++;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":509524,"func":"void _ma_report_progress(HA_CHECK *param, ulonglong progress,\n                         ulonglong max_progress)\n{\n  thd_progress_report((THD*)param->thd,\n                      progress + max_progress * param->stage,\n                      max_progress * param->max_stage);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":512457,"func":"  const Type_handler *type_handler() const { return &type_handler_row; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":248289,"func":"static char *strdup(const char *str)\n{\n\tsize_t len;\n\tchar *dup;\n\n\tlen = strlen(str) + 1;\n\tdup = calloc(len, sizeof(char));\n\tif (!dup)\n\t\treturn NULL;\n\n\tmemcpy(dup, str, len);\n\n\treturn dup;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":220811,"func":"SaturatingRoundingMultiplyByPOTParam(\n    gemmlowp::FixedPoint<tRawType, tIntegerBits> a, int exponent) {\n  return gemmlowp::FixedPoint<tRawType, tIntegerBits>::FromRaw(\n      SaturatingRoundingMultiplyByPOTParam(a.raw(), exponent));\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":225817,"func":"GF_Err stdp_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 entry;\n\tGF_DegradationPriorityBox *ptr = (GF_DegradationPriorityBox *)s;\n\n\t\/*out-of-order stdp, assume no padding at the end and take the entire remaining data for entries*\/\n\tif (!ptr->nb_entries) ptr->nb_entries = (u32) ptr->size \/ 2;\n\telse if (ptr->nb_entries > ptr->size \/ 2) return GF_ISOM_INVALID_FILE;\n\n\tptr->priorities = (u16 *) gf_malloc(ptr->nb_entries * sizeof(u16));\n\tif (ptr->priorities == NULL) return GF_OUT_OF_MEM;\n\tfor (entry = 0; entry < ptr->nb_entries; entry++) {\n\t\tptr->priorities[entry] = gf_bs_read_u16(bs);\n\t}\n\tISOM_DECREASE_SIZE(ptr, (2*ptr->nb_entries) );\n\treturn GF_OK;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":336557,"func":"void reds_on_client_seamless_migrate_complete(RedsState *reds, RedClient *client)\n{\n    spice_debug(\"trace\");\n    if (!reds_find_client(reds, client)) {\n        spice_debug(\"client no longer exists\");\n        return;\n    }\n    client->get_main()->migrate_dst_complete();\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":437312,"func":"compile_string_raw_node(StrNode* sn, regex_t* reg)\n{\n  if (sn->end <= sn->s)\n    return 0;\n\n  return add_compile_string(sn->s, 1 \/* sb *\/, (int )(sn->end - sn->s), reg, 0);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":101692,"func":"void WebProcessProxy::pageVisibilityChanged(WebKit::WebPageProxy *page)\n{\n#if PLATFORM(MAC)\n    if (pageIsProcessSuppressible(page))\n        m_processSuppressiblePages.add(page->pageID());\n    else\n        m_processSuppressiblePages.remove(page->pageID());\n    updateProcessSuppressionState();\n#else\n    UNUSED_PARAM(page);\n#endif\n}\n","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":509532,"func":"int ha_maria::update_row(const uchar * old_data, const uchar * new_data)\n{\n  CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONING(\"UPDATE in WRITE CONCURRENT\");\n  return maria_update(file, old_data, new_data);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":247714,"func":"  const std::string& expectedLocalSubject() const { return expected_local_subject_; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":387775,"func":"jmethodID InstanceKlass::jmethod_id_or_null(Method* method) {\n  size_t idnum = (size_t)method->method_idnum();\n  jmethodID* jmeths = methods_jmethod_ids_acquire();\n  size_t length;                                \/\/ length assigned as debugging crumb\n  jmethodID id = NULL;\n  if (jmeths != NULL &&                         \/\/ If there is a cache\n      (length = (size_t)jmeths[0]) > idnum) {   \/\/ and if it is long enough,\n    id = jmeths[idnum+1];                       \/\/ Look up the id (may be NULL)\n  }\n  return id;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":226192,"func":"\nGF_Err dac3_box_size(GF_Box *s)\n{\n\tGF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;\n\n\tif (ptr->cfg.is_ec3) {\n\t\tu32 i;\n\t\ts->size += 2;\n\t\tfor (i=0; i<ptr->cfg.nb_streams; i++) {\n\t\t\ts->size += 3;\n\t\t\tif (ptr->cfg.streams[i].nb_dep_sub)\n\t\t\t\ts->size += 1;\n\t\t}\n\t} else {\n\t\ts->size += 3;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":300808,"func":"static void tipc_data_ready(struct sock *sk)\n{\n\tstruct socket_wq *wq;\n\n\trcu_read_lock();\n\twq = rcu_dereference(sk->sk_wq);\n\tif (skwq_has_sleeper(wq))\n\t\twake_up_interruptible_sync_poll(&wq->wait, EPOLLIN |\n\t\t\t\t\t\tEPOLLRDNORM | EPOLLRDBAND);\n\trcu_read_unlock();\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":359546,"func":"DEFUN (no_bgp_always_compare_med,\n       no_bgp_always_compare_med_cmd,\n       \"no bgp always-compare-med\",\n       NO_STR\n       \"BGP specific commands\\n\"\n       \"Allow comparing MED from different neighbors\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":236190,"func":"GF_Err tbox_box_size(GF_Box *s)\n{\n\ts->size += 8;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":482541,"func":"addForwardPassRule(TranslationTableOffset ruleOffset, TranslationTableRule *rule,\n\t\tTranslationTableHeader *table) {\n\tTranslationTableOffset *forPassRule;\n\tswitch (rule->opcode) {\n\tcase CTO_Correct:\n\t\tforPassRule = &table->forPassRules[0];\n\t\tbreak;\n\tcase CTO_Context:\n\t\tforPassRule = &table->forPassRules[1];\n\t\tbreak;\n\tcase CTO_Pass2:\n\t\tforPassRule = &table->forPassRules[2];\n\t\tbreak;\n\tcase CTO_Pass3:\n\t\tforPassRule = &table->forPassRules[3];\n\t\tbreak;\n\tcase CTO_Pass4:\n\t\tforPassRule = &table->forPassRules[4];\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\twhile (*forPassRule) {\n\t\tTranslationTableRule *r = (TranslationTableRule *)&table->ruleArea[*forPassRule];\n\t\tif (rule->charslen > r->charslen) break;\n\t\tforPassRule = &r->charsnext;\n\t}\n\trule->charsnext = *forPassRule;\n\t*forPassRule = ruleOffset;\n\treturn 1;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":335104,"func":"static int skcipher_recvmsg_nokey(struct kiocb *unused, struct socket *sock,\n\t\t\t\t  struct msghdr *msg, size_t ignored, int flags)\n{\n\tint err;\n\n\terr = skcipher_check_key(sock);\n\tif (err)\n\t\treturn err;\n\n\treturn skcipher_recvmsg(NULL, sock, msg, ignored, flags);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":248275,"func":"DLLIMPORT int cfg_setnfloat(cfg_t *cfg, const char *name, double value, unsigned int index)\n{\n\tcfg_opt_t *opt;\n\n\topt = cfg_getopt(cfg, name);\n\tif (opt && opt->validcb2 && (*opt->validcb2)(cfg, opt, (void *)&value) != 0)\n\t\treturn CFG_FAIL;\n\n\treturn cfg_opt_setnfloat(opt, value, index);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":437346,"func":"compile_length_option_node(EnclosureNode* node, regex_t* reg)\n{\n  int tlen;\n  OnigOptionType prev = reg->options;\n\n  reg->options = node->o.options;\n  tlen = compile_length_tree(NODE_ENCLOSURE_BODY(node), reg);\n  reg->options = prev;\n\n  return tlen;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":513038,"func":"bool Item_in_optimizer::eval_not_null_tables(void *opt_arg)\n{\n  not_null_tables_cache= 0;\n  if (is_top_level_item())\n  {\n    \/*\n      It is possible to determine NULL-rejectedness of the left arguments\n      of IN only if it is a top-level predicate.\n    *\/\n    not_null_tables_cache= args[0]->not_null_tables();\n  }\n  return FALSE;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":240274,"func":"write_reg_contents_lst(\n    int\t\tname,\n    char_u\t**strings,\n    int\t\tmaxlen UNUSED,\n    int\t\tmust_append,\n    int\t\tyank_type,\n    long\tblock_len)\n{\n    yankreg_T  *old_y_previous, *old_y_current;\n\n    if (name == '\/' || name == '=')\n    {\n\tchar_u\t*s;\n\n\tif (strings[0] == NULL)\n\t    s = (char_u *)\"\";\n\telse if (strings[1] != NULL)\n\t{\n\t    emsg(_(e_search_pattern_and_expression_register_may_not_contain_two_or_more_lines));\n\t    return;\n\t}\n\telse\n\t    s = strings[0];\n\twrite_reg_contents_ex(name, s, -1, must_append, yank_type, block_len);\n\treturn;\n    }\n\n    if (name == '_')\t    \/\/ black hole: nothing to do\n\treturn;\n\n    if (init_write_reg(name, &old_y_previous, &old_y_current, must_append,\n\t\t&yank_type) == FAIL)\n\treturn;\n\n    str_to_reg(y_current, yank_type, (char_u *)strings, -1, block_len, TRUE);\n\n    finish_write_reg(name, old_y_previous, old_y_current);\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":274757,"func":"void ntfs_attr_close(ntfs_attr *na)\n{\n\tif (!na)\n\t\treturn;\n\tif (NAttrNonResident(na) && na->rl)\n\t\tfree(na->rl);\n\t\/* Don't release if using an internal constant. *\/\n\tif (na->name != AT_UNNAMED && na->name != NTFS_INDEX_I30\n\t\t\t\t&& na->name != STREAM_SDS)\n\t\tfree(na->name);\n\tfree(na);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":359294,"func":"DEFUN (no_neighbor_unsuppress_map,\n       no_neighbor_unsuppress_map_cmd,\n       NO_NEIGHBOR_CMD2 \"unsuppress-map WORD\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Route-map to selectively unsuppress suppressed routes\\n\"\n       \"Name of route map\\n\")\n{\n  return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t\tbgp_node_safi (vty));\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":221679,"func":"int Socket::loopChunk(int timeout)    \/\/ reads chunks and sends back until 0 len chunk or timeout\n{\n    char buff[32000];\n    int tot_size = 0;\n    int csize = 1;\n    while (csize > 0) {\n        csize = readChunk(buff,32000, timeout);\n        if (csize == 0)     \/\/ end chunk\n        {\n            if (!writeChunkTrailer(chunked_trailer))\n            {\n#ifdef CHUNKDEBUG\n                std::cerr << thread_id << \"loopChunk - error in writing chunk trailer\" << std::endl;\n#endif\n                return -1;\n\n            };\n#ifdef CHUNKDEBUG\n            std::cerr << thread_id << \"loopChunk  tot_size=\" << tot_size << std::endl;\n#endif\n            return tot_size;\n        }\n        if (!(csize > 0 && writeChunk(buff,csize,timeout))) {\n#ifdef CHUNKDEBUG\n            std::cerr << thread_id << \"loopChunk - error\" << std::endl;\n#endif\n            return -1;\n        }\n        tot_size += csize;\n    }\n    return -1;  \/\/ should never get here!\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":413667,"func":"static void function_rename(RFlag *flags, RAnalFunction *fcn) {\n\tconst char *locname = \"loc.\";\n\tconst size_t locsize = strlen (locname);\n\tchar *fcnname = fcn->name;\n\n\tif (strncmp (fcn->name, locname, locsize) == 0) {\n\t\tconst char *fcnpfx, *restofname;\n\t\tRFlagItem *f;\n\n\t\tfcn->type = R_ANAL_FCN_TYPE_FCN;\n\t\tfcnpfx = r_anal_functiontype_tostring (fcn->type);\n\t\trestofname = fcn->name + locsize;\n\t\tfcn->name = r_str_newf (\"%s.%s\", fcnpfx, restofname);\n\n\t\tf = r_flag_get_i (flags, fcn->addr);\n\t\tr_flag_rename (flags, f, fcn->name);\n\n\t\tfree (fcnname);\n\t}\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":214336,"func":"static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr, void * const *ext_hdrs)\n{\n\tstruct pfkey_sock *pfk = pfkey_sk(sk);\n\tstruct sk_buff *supp_skb;\n\n\tif (hdr->sadb_msg_satype > SADB_SATYPE_MAX)\n\t\treturn -EINVAL;\n\n\tif (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC) {\n\t\tif (pfk->registered&(1<<hdr->sadb_msg_satype))\n\t\t\treturn -EEXIST;\n\t\tpfk->registered |= (1<<hdr->sadb_msg_satype);\n\t}\n\n\txfrm_probe_algs();\n\n\tsupp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO);\n\tif (!supp_skb) {\n\t\tif (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC)\n\t\t\tpfk->registered &= ~(1<<hdr->sadb_msg_satype);\n\n\t\treturn -ENOBUFS;\n\t}\n\n\tpfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk,\n\t\t\tsock_net(sk));\n\treturn 0;\n}","target":1,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":261238,"func":"    int wm_SemLock(wm_Sem *s){\n        dispatch_semaphore_wait(*s, DISPATCH_TIME_FOREVER);\n        return 0;\n    }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":507765,"func":"int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)\n{\n    if (r == NULL || s == NULL)\n        return 0;\n    BN_clear_free(sig->r);\n    BN_clear_free(sig->s);\n    sig->r = r;\n    sig->s = s;\n    return 1;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":90145,"func":"  virtual NetworkIPConfigVector GetIPConfigs(const std::string& device_path,\n                                             std::string* hardware_address) {\n    hardware_address->clear();\n    return NetworkIPConfigVector();\n  }\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":265437,"func":"int sqfs_exists(const char *filename)\n{\n\tstruct fs_dir_stream *dirsp = NULL;\n\tstruct squashfs_dir_stream *dirs;\n\tchar *dir, *file;\n\tstruct fs_dirent *dent;\n\tint ret;\n\n\tsqfs_split_path(&file, &dir, filename);\n\t\/*\n\t * sqfs_opendir will uncompress inode and directory tables, and will\n\t * return a pointer to the directory that contains the requested file.\n\t *\/\n\tret = sqfs_opendir(dir, &dirsp);\n\tif (ret) {\n\t\tret = -EINVAL;\n\t\tgoto free_strings;\n\t}\n\n\tdirs = (struct squashfs_dir_stream *)dirsp;\n\n\twhile (!sqfs_readdir(dirsp, &dent)) {\n\t\tret = strcmp(dent->name, file);\n\t\tif (!ret)\n\t\t\tbreak;\n\t\tfree(dirs->entry);\n\t\tdirs->entry = NULL;\n\t}\n\n\tsqfs_closedir(dirsp);\n\nfree_strings:\n\tfree(dir);\n\tfree(file);\n\n\treturn ret == 0;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":312517,"func":"qf_clean_dir_stack(struct dir_stack_T **stackptr)\n{\n    struct dir_stack_T  *ds_ptr;\n\n    while ((ds_ptr = *stackptr) != NULL)\n    {\n\t*stackptr = (*stackptr)->next;\n\tvim_free(ds_ptr->dirname);\n\tvim_free(ds_ptr);\n    }\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":294467,"func":"time_to_date(VALUE self)\n{\n    VALUE y, nth, ret;\n    int ry, m, d;\n\n    y = f_year(self);\n    m = FIX2INT(f_mon(self));\n    d = FIX2INT(f_mday(self));\n\n    decode_year(y, -1, &nth, &ry);\n\n    ret = d_simple_new_internal(cDate,\n\t\t\t\tnth, 0,\n\t\t\t\tGREGORIAN,\n\t\t\t\try, m, d,\n\t\t\t\tHAVE_CIVIL);\n    {\n\tget_d1(ret);\n\tset_sg(dat, DEFAULT_SG);\n    }\n    return ret;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":247135,"func":"GF_Filter *gf_fs_get_filter(GF_FilterSession *session, u32 idx)\n{\n\treturn session ? gf_list_get(session->filters, idx) : NULL;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":314503,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_validate(const pjmedia_sdp_session *sdp)\n{\n    return pjmedia_sdp_validate2(sdp, PJ_TRUE);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":405410,"func":"static inline bool xfrm_policy_mark_match(const struct xfrm_mark *mark,\n\t\t\t\t\t  struct xfrm_policy *pol)\n{\n\treturn mark->v == pol->mark.v && mark->m == pol->mark.m;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":476118,"func":"void composite_suspend(struct usb_gadget *gadget)\n{\n\tstruct usb_composite_dev\t*cdev = get_gadget_data(gadget);\n\tstruct usb_function\t\t*f;\n\n\t\/* REVISIT:  should we have config level\n\t * suspend\/resume callbacks?\n\t *\/\n\tDBG(cdev, \"suspend\\n\");\n\tif (cdev->config) {\n\t\tlist_for_each_entry(f, &cdev->config->functions, list) {\n\t\t\tif (f->suspend)\n\t\t\t\tf->suspend(f);\n\t\t}\n\t}\n\tif (cdev->driver->suspend)\n\t\tcdev->driver->suspend(cdev);\n\n\tcdev->suspended = 1;\n\n\tusb_gadget_set_selfpowered(gadget);\n\tusb_gadget_vbus_draw(gadget, 2);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":473901,"func":"utf32le_code_to_mbc(OnigCodePoint code, UChar *buf,\n\t\t    OnigEncoding enc ARG_UNUSED)\n{\n  UChar* p = buf;\n\n  *p++ = (UChar ) (code & 0xff);\n  *p++ = (UChar )((code & 0xff00)     >> 8);\n  *p++ = (UChar )((code & 0xff0000)   >>16);\n  *p++ = (UChar )((code & 0xff000000) >>24);\n  return 4;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":224744,"func":"GF_Err meta_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_full_box_write(s, bs);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":310111,"func":"ClrUpdate(NCURSES_SP_DCL0)\n{\n    TR(TRACE_UPDATE, (T_CALLED(\"ClrUpdate\")));\n    if (0 != SP_PARM) {\n\tint i;\n\tNCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));\n\tint nonempty = min(screen_lines(SP_PARM),\n\t\t\t   NewScreen(SP_PARM)->_maxy + 1);\n\n\tClearScreen(NCURSES_SP_ARGx blank);\n\n\tTR(TRACE_UPDATE, (\"updating screen from scratch\"));\n\n\tnonempty = ClrBottom(NCURSES_SP_ARGx nonempty);\n\n\tfor (i = 0; i < nonempty; i++)\n\t    TransformLine(NCURSES_SP_ARGx i);\n    }\n    TR(TRACE_UPDATE, (T_RETURN(\"\")));\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":317125,"func":"static int selinux_vm_enough_memory(struct mm_struct *mm, long pages)\n{\n\tint rc, cap_sys_admin = 0;\n\n\trc = cred_has_capability(current_cred(), CAP_SYS_ADMIN,\n\t\t\t\t CAP_OPT_NOAUDIT, true);\n\tif (rc == 0)\n\t\tcap_sys_admin = 1;\n\n\treturn cap_sys_admin;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":308189,"func":"static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach,\n\t\t\t\t  struct sg_table *table,\n\t\t\t\t  enum dma_data_direction dir)\n{\n\tdma_unmap_sg(attach->dev, table->sgl, table->nents, dir);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":244266,"func":"GF_Err gitn_box_size(GF_Box *s)\n{\n\tu32 i;\n\tGroupIdToNameBox *ptr = (GroupIdToNameBox *)s;\n\tptr->size += 2;\n\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tptr->size += 5;\n\t\tif (ptr->entries[i].name) ptr->size += strlen(ptr->entries[i].name);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":242997,"func":"static size_t ssl_get_maximum_datagram_size( mbedtls_ssl_context const *ssl )\n{\n    size_t mtu = mbedtls_ssl_get_current_mtu( ssl );\n#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)\n    size_t out_buf_len = ssl->out_buf_len;\n#else\n    size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN;\n#endif\n\n    if( mtu != 0 && mtu < out_buf_len )\n        return( mtu );\n\n    return( out_buf_len );\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":386529,"func":"void DL_Dxf::writeXLine(DL_WriterA& dw,\n                       const DL_XLineData& data,\n                       const DL_Attributes& attrib) {\n    dw.entity(\"XLINE\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbLine\");\n    }\n    dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz);\n    dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":326593,"func":"check_symlinks(struct archive_write_disk *a)\n{\n\tstruct archive_string error_string;\n\tint error_number;\n\tint rc;\n\tarchive_string_init(&error_string);\n\trc = check_symlinks_fsobj(a->name, &error_number, &error_string,\n\t    a->flags, 0);\n\tif (rc != ARCHIVE_OK) {\n\t\tarchive_set_error(&a->archive, error_number, \"%s\",\n\t\t    error_string.s);\n\t}\n\tarchive_string_free(&error_string);\n\ta->pst = NULL;\t\/* to be safe *\/\n\treturn rc;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":211113,"func":"static void atusb_disconnect(struct usb_interface *interface)\n{\n\tstruct atusb *atusb = usb_get_intfdata(interface);\n\n\tdev_dbg(&atusb->usb_dev->dev, \"%s\\n\", __func__);\n\n\tatusb->shutdown = 1;\n\tcancel_delayed_work_sync(&atusb->work);\n\n\tusb_kill_anchored_urbs(&atusb->rx_urbs);\n\tatusb_free_urbs(atusb);\n\tusb_kill_urb(atusb->tx_urb);\n\tusb_free_urb(atusb->tx_urb);\n\n\tieee802154_unregister_hw(atusb->hw);\n\n\tieee802154_free_hw(atusb->hw);\n\n\tusb_set_intfdata(interface, NULL);\n\tusb_put_dev(atusb->usb_dev);\n\n\tpr_debug(\"%s done\\n\", __func__);\n}","target":1,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":448553,"func":"struct bgp_notify bgp_notify_decapsulate_hard_reset(struct bgp_notify *notify)\n{\n\tstruct bgp_notify bn = {};\n\n\tbn.code = notify->raw_data[0];\n\tbn.subcode = notify->raw_data[1];\n\tbn.length = notify->length - 2;\n\n\tbn.raw_data = XMALLOC(MTYPE_BGP_NOTIFICATION, bn.length);\n\tmemcpy(bn.raw_data, notify->raw_data + 2, bn.length);\n\n\treturn bn;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":500088,"func":"print_krb5_data(char *label, krb5_data *kdata)\n        {\n\tint i;\n\n\tprintf(\"%s[%d] \", label, kdata->length);\n\tfor (i=0; i < (int)kdata->length; i++)\n                {\n\t\tif (0 &&  isprint((int) kdata->data[i]))\n                        printf(\t\"%c \",  kdata->data[i]);\n\t\telse\n                        printf(\t\"%02x \", (unsigned char) kdata->data[i]);\n\t\t}\n\tprintf(\"\\n\");\n        }","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":220415,"func":"mrb_ary_new(mrb_state *mrb)\n{\n  return mrb_ary_new_capa(mrb, 0);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":234767,"func":"static bool is_block_group_to_copy(struct btrfs_fs_info *fs_info, u64 logical)\n{\n\tstruct btrfs_block_group *cache;\n\tbool ret;\n\n\t\/* Non zoned filesystem does not use \"to_copy\" flag *\/\n\tif (!btrfs_is_zoned(fs_info))\n\t\treturn false;\n\n\tcache = btrfs_lookup_block_group(fs_info, logical);\n\n\tspin_lock(&cache->lock);\n\tret = cache->to_copy;\n\tspin_unlock(&cache->lock);\n\n\tbtrfs_put_block_group(cache);\n\treturn ret;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":281668,"func":"fill_input_buffer (j_decompress_ptr cinfo)\n{\n#ifndef LIBRAW_NOTHREADS\n#define jpeg_buffer tls->jpeg_buffer\n#else\n  static uchar jpeg_buffer[4096];\n#endif\n  size_t nbytes;\n\n  nbytes = fread (jpeg_buffer, 1, 4096, ifp);\n  swab (jpeg_buffer, jpeg_buffer, nbytes);\n  cinfo->src->next_input_byte = jpeg_buffer;\n  cinfo->src->bytes_in_buffer = nbytes;\n  return TRUE;\n#ifndef LIBRAW_NOTHREADS\n#undef jpeg_buffer\n#endif\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":261394,"func":"static inline int decode_mpm_idx(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# mpm_idx (TU:2)\\n\");\n  int mpm = decode_CABAC_TU_bypass(&tctx->cabac_decoder, 2);\n  logtrace(LogSlice,\"> mpm_idx = %d\\n\",mpm);\n  logtrace(LogSymbols,\"$1 mpm_idx=%d\\n\",mpm);\n  return mpm;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":139237,"func":"void OverlayWindowViews::OnNativeWidgetMove() {\n  if (is_initialized_)\n    UpdateControlsVisibility(false);\n\n  window_bounds_ = GetBounds();\n\n#if defined(OS_CHROMEOS)\n  WindowQuadrant quadrant = GetCurrentWindowQuadrant(GetBounds(), controller_);\n  close_controls_view_->SetPosition(GetBounds().size(), quadrant);\n  resize_handle_view_->SetPosition(GetBounds().size(), quadrant);\n#endif\n}\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":247732,"func":"TEST_P(SslReadBufferLimitTest, SomeLimit) {\n  readBufferLimitTest(32 * 1024, 32 * 1024, 256 * 1024, 1, false);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":452986,"func":"static int nft_fwd_neigh_dump(struct sk_buff *skb, const struct nft_expr *expr)\n{\n\tstruct nft_fwd_neigh *priv = nft_expr_priv(expr);\n\n\tif (nft_dump_register(skb, NFTA_FWD_SREG_DEV, priv->sreg_dev) ||\n\t    nft_dump_register(skb, NFTA_FWD_SREG_ADDR, priv->sreg_addr) ||\n\t    nla_put_be32(skb, NFTA_FWD_NFPROTO, htonl(priv->nfproto)))\n\t\tgoto nla_put_failure;\n\n\treturn 0;\n\nnla_put_failure:\n\treturn -1;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":310180,"func":"drv_initpair(TERMINAL_CONTROL_BLOCK * TCB, int pair, int f, int b)\n{\n    SCREEN *sp;\n\n    AssertTCB();\n    SetSP();\n\n    if ((initialize_pair != NULL) && InPalette(f) && InPalette(b)) {\n\tconst color_t *tp = InfoOf(sp).defaultPalette;\n\n\tTR(TRACE_ATTRS,\n\t   (\"initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)\",\n\t    pair,\n\t    tp[f].red, tp[f].green, tp[f].blue,\n\t    tp[b].red, tp[b].green, tp[b].blue));\n\n\tNCURSES_PUTP2(\"initialize_pair\",\n\t\t      TIPARM_7(initialize_pair,\n\t\t\t       pair,\n\t\t\t       tp[f].red, tp[f].green, tp[f].blue,\n\t\t\t       tp[b].red, tp[b].green, tp[b].blue));\n    }\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":272334,"func":"make_context_specific(cms_context *cms, int ctxt, SECItem *encoded,\n\t\t\tSECItem *original)\n{\n\tvoid *rv;\n\tContextSpecificSequence[0].kind = SEC_ASN1_EXPLICIT |\n\t\t\t\t\t  SEC_ASN1_CONTEXT_SPECIFIC | ctxt;\n\n\trv = SEC_ASN1EncodeItem(cms->arena, encoded, original,\n\t\t\t\tContextSpecificSequence);\n\tif (rv == NULL)\n\t\tcnreterr(-1, cms, \"could not encode context specific data\");\n\treturn 0;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":357667,"func":"bool SQInstance::GetMetaMethod(SQVM* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPtr &res)\n{\n    if(sq_type(_class->_metamethods[mm]) != OT_NULL) {\n        res = _class->_metamethods[mm];\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":309869,"func":"load_term(void)\n{\n    (void) setupterm(tname, STDOUT_FILENO, NULL);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":483495,"func":"u64 efi_mem_attributes(unsigned long phys_addr)\n{\n\tefi_memory_desc_t *md;\n\n\tif (!efi_enabled(EFI_MEMMAP))\n\t\treturn 0;\n\n\tfor_each_efi_memory_desc(md) {\n\t\tif ((md->phys_addr <= phys_addr) &&\n\t\t    (phys_addr < (md->phys_addr +\n\t\t    (md->num_pages << EFI_PAGE_SHIFT))))\n\t\t\treturn md->attribute;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":294518,"func":"d_lite_amjd(VALUE self)\n{\n    get_d1(self);\n    return m_amjd(dat);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":344737,"func":"monotime_double(void)\n{\n\tstruct timespec ts;\n\n\tmonotime_ts(&ts);\n\treturn ts.tv_sec + ((double)ts.tv_nsec \/ 1000000000);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":389688,"func":"tv_get_number(typval_T *varp)\n{\n    int\t\terror = FALSE;\n\n    return tv_get_number_chk(varp, &error);\t\/\/ return 0L on error\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":512646,"func":"cmp_item *cmp_item_datetime::make_same()\n{\n  return new cmp_item_datetime();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":225688,"func":"\nGF_Err trgt_box_size(GF_Box *s)\n{\n\tGF_TrackGroupBox *ptr = (GF_TrackGroupBox *)s;\n\n\tptr->size+= 4;\n\treturn GF_OK;","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":224283,"func":"    GopherStateData(FwdState *aFwd) :\n        entry(aFwd->entry),\n        conversion(NORMAL),\n        HTML_header_added(0),\n        HTML_pre(0),\n        type_id(GOPHER_FILE \/* '0' *\/),\n        overflowed(false),\n        cso_recno(0),\n        len(0),\n        buf(NULL),\n        fwd(aFwd)\n    {\n        *request = 0;\n        buf = (char *)memAllocate(MEM_4K_BUF);\n        entry->lock(\"gopherState\");\n        *replybuf = 0;\n    }","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":244040,"func":"GF_Box *dmlp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrueHDConfigBox, GF_ISOM_BOX_TYPE_DMLP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":498624,"func":"flip_line (guchar   *buf,\n           tga_info *info)\n{\n  guchar  temp;\n  guchar *alt;\n  gint    x, s;\n\n  alt = buf + (info->bytes * (info->width - 1));\n\n  for (x = 0; x * 2 < info->width; x++)\n    {\n      for (s = 0; s < info->bytes; ++s)\n        {\n          temp = buf[s];\n          buf[s] = alt[s];\n          alt[s] = temp;\n        }\n\n      buf += info->bytes;\n      alt -= info->bytes;\n    }\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":500080,"func":"kssl_krb5_kt_default(krb5_context con,\n                    krb5_keytab * kt)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_kt_default )\n\t\treturn(p_krb5_kt_default(con,kt));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":512801,"func":"  longlong val_int() { return cached_time.to_longlong(); }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":409437,"func":"cursor_unsleep(void)\n{\n    cursor_is_asleep = FALSE;\n    cursor_on();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":463130,"func":"static void store_proxy(const char *server, void *data __attribute__((unused)),\n                        void *rock)\n{\n    struct proxy_rock *prock = (struct proxy_rock *) rock;\n\n    proxy_store_func(server, prock->mbox_pat, prock->entryatts);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":294633,"func":"d_lite_england(VALUE self)\n{\n    return dup_obj_with_new_start(self, ENGLAND);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":226262,"func":"GF_Box *dref_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DataReferenceBox, GF_ISOM_BOX_TYPE_DREF);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":247342,"func":"int pgpDigParamsCmp(pgpDigParams p1, pgpDigParams p2)\n{\n    int rc = 1; \/* assume different, eg if either is NULL *\/\n    if (p1 && p2) {\n\t\/* XXX Should we compare something else too? *\/\n\tif (p1->tag != p2->tag)\n\t    goto exit;\n\tif (p1->hash_algo != p2->hash_algo)\n\t    goto exit;\n\tif (p1->pubkey_algo != p2->pubkey_algo)\n\t    goto exit;\n\tif (p1->version != p2->version)\n\t    goto exit;\n\tif (p1->sigtype != p2->sigtype)\n\t    goto exit;\n\tif (memcmp(p1->signid, p2->signid, sizeof(p1->signid)) != 0)\n\t    goto exit;\n\tif (p1->userid && p2->userid && strcmp(p1->userid, p2->userid) != 0)\n\t    goto exit;\n\n\t\/* Parameters match ... at least for our purposes *\/\n\trc = 0;\n    }\nexit:\n    return rc;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":369158,"func":"\nstatic int io_register_personality(struct io_ring_ctx *ctx)\n{\n\tconst struct cred *creds;\n\tu32 id;\n\tint ret;\n\n\tcreds = get_current_cred();\n\n\tret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)creds,\n\t\t\tXA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);\n\tif (ret < 0) {\n\t\tput_cred(creds);\n\t\treturn ret;\n\t}\n\treturn id;","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":452996,"func":"static void nft_immediate_destroy(const struct nft_ctx *ctx,\n\t\t\t\t  const struct nft_expr *expr)\n{\n\tconst struct nft_immediate_expr *priv = nft_expr_priv(expr);\n\tconst struct nft_data *data = &priv->data;\n\tstruct nft_rule *rule, *n;\n\tstruct nft_ctx chain_ctx;\n\tstruct nft_chain *chain;\n\n\tif (priv->dreg != NFT_REG_VERDICT)\n\t\treturn;\n\n\tswitch (data->verdict.code) {\n\tcase NFT_JUMP:\n\tcase NFT_GOTO:\n\t\tchain = data->verdict.chain;\n\n\t\tif (!nft_chain_is_bound(chain))\n\t\t\tbreak;\n\n\t\tchain_ctx = *ctx;\n\t\tchain_ctx.chain = chain;\n\n\t\tlist_for_each_entry_safe(rule, n, &chain->rules, list)\n\t\t\tnf_tables_rule_release(&chain_ctx, rule);\n\n\t\tnf_tables_chain_destroy(&chain_ctx);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":222530,"func":"string DebugStringWhole(const GraphDef& gdef) {\n  string ret;\n  for (const auto& fdef : gdef.library().function()) {\n    strings::StrAppend(&ret, Print(fdef));\n  }\n  strings::StrAppend(&ret, \"\\n\");\n  for (const auto& ndef : gdef.node()) {\n    strings::StrAppend(&ret, Print(ndef), \"\\n\");\n  }\n  return ret;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":393474,"func":"static SQInteger closure_bindenv(HSQUIRRELVM v)\n{\n    if(SQ_FAILED(sq_bindenv(v,1)))\n        return SQ_ERROR;\n    return 1;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":437388,"func":"renumber_node_backref(Node* node, GroupNumRemap* map)\n{\n  int i, pos, n, old_num;\n  int *backs;\n  BackRefNode* bn = BACKREF_(node);\n\n  if (! NODE_IS_BY_NAME(node))\n    return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;\n\n  old_num = bn->back_num;\n  if (IS_NULL(bn->back_dynamic))\n    backs = bn->back_static;\n  else\n    backs = bn->back_dynamic;\n\n  for (i = 0, pos = 0; i < old_num; i++) {\n    n = map[backs[i]].new_val;\n    if (n > 0) {\n      backs[pos] = n;\n      pos++;\n    }\n  }\n\n  bn->back_num = pos;\n  return 0;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":90192,"func":"  void UpdateSystemInfo() {\n    if (EnsureCrosLoaded()) {\n      UpdateNetworkManagerStatus();\n    }\n  }\n","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":500068,"func":"kssl_krb5_get_credentials(krb5_context CO,\n                         krb5_const krb5_flags F,\n                         krb5_ccache CC,\n                         krb5_creds  * pCR,\n                         krb5_creds  ** ppCR)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_get_credentials )\n\t\treturn(p_krb5_get_credentials(CO,F,CC,pCR,ppCR));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":355630,"func":"partial_unref(partial_T *pt)\n{\n    if (pt != NULL)\n    {\n\tif (--pt->pt_refcount <= 0)\n\t    partial_free(pt);\n\n\t\/\/ If the reference count goes down to one, the funcstack may be the\n\t\/\/ only reference and can be freed if no other partials reference it.\n\telse if (pt->pt_refcount == 1 && pt->pt_funcstack != NULL)\n\t    funcstack_check_refcount(pt->pt_funcstack);\n    }\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":437688,"func":"static inline int cx23888_ir_and_or4(struct cx23885_dev *dev, u32 addr,\n\t\t\t\t     u32 and_mask, u32 or_value)\n{\n\tcx_andor(addr, ~and_mask, or_value);\n\treturn 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":462436,"func":"processWorkItem(epolld_t *epd)\n{\n\tint continue_polling = 1;\n\n\tswitch(epd->typ) {\n\tcase epolld_lstn:\n\t\t\/* listener never stops polling (except server shutdown) *\/\n\t\tlstnActivity((ptcplstn_t *) epd->ptr);\n\t\tbreak;\n\tcase epolld_sess:\n\t\tsessActivity((ptcpsess_t *) epd->ptr, &continue_polling);\n\t\tbreak;\n\tdefault:\n\t\terrmsg.LogError(0, RS_RET_INTERNAL_ERROR,\n\t\t\t\t\t\t\"error: invalid epolld_type_t %d after epoll\", epd->typ);\n\t\tbreak;\n\t}\n\tif (continue_polling == 1) {\n\t\tepoll_ctl(epollfd, EPOLL_CTL_MOD, epd->sock, &(epd->ev));\n\t}\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":248259,"func":"DLLIMPORT void *cfg_getnptr(cfg_t *cfg, const char *name, unsigned int index)\n{\n\treturn cfg_opt_getnptr(cfg_getopt(cfg, name), index);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":437716,"func":"static inline u16 count_to_clock_divider(unsigned int d)\n{\n\tif (d > RXCLK_RCD + 1)\n\t\td = RXCLK_RCD;\n\telse if (d < 2)\n\t\td = 1;\n\telse\n\t\td--;\n\treturn (u16) d;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":233897,"func":" *\/\nstatic int wddx_stack_destroy(wddx_stack *stack)\n{\n\tregister int i;\n\n\tif (stack->elements) {\n\t\tfor (i = 0; i < stack->top; i++) {\n\t\t\tzval_ptr_dtor(&((st_entry *)stack->elements[i])->data);\n\t\t\tif (((st_entry *)stack->elements[i])->varname) {\n\t\t\t\tefree(((st_entry *)stack->elements[i])->varname);\n\t\t\t}\n\t\t\tefree(stack->elements[i]);\n\t\t}\n\t\tefree(stack->elements);\n\t}\n\treturn SUCCESS;","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":256457,"func":"void janet_lib_array(JanetTable *env) {\n    JanetRegExt array_cfuns[] = {\n        JANET_CORE_REG(\"array\/new\", cfun_array_new),\n        JANET_CORE_REG(\"array\/new-filled\", cfun_array_new_filled),\n        JANET_CORE_REG(\"array\/fill\", cfun_array_fill),\n        JANET_CORE_REG(\"array\/pop\", cfun_array_pop),\n        JANET_CORE_REG(\"array\/peek\", cfun_array_peek),\n        JANET_CORE_REG(\"array\/push\", cfun_array_push),\n        JANET_CORE_REG(\"array\/ensure\", cfun_array_ensure),\n        JANET_CORE_REG(\"array\/slice\", cfun_array_slice),\n        JANET_CORE_REG(\"array\/concat\", cfun_array_concat),\n        JANET_CORE_REG(\"array\/insert\", cfun_array_insert),\n        JANET_CORE_REG(\"array\/remove\", cfun_array_remove),\n        JANET_CORE_REG(\"array\/trim\", cfun_array_trim),\n        JANET_CORE_REG(\"array\/clear\", cfun_array_clear),\n        JANET_REG_END\n    };\n    janet_core_cfuns_ext(env, NULL, array_cfuns);\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":335434,"func":"one_letter_cmd(char_u *p, cmdidx_T *idx)\n{\n    if (in_vim9script())\n\treturn FALSE;\n    if (*p == 'k')\n    {\n\t*idx = CMD_k;\n\treturn TRUE;\n    }\n    if (p[0] == 's'\n\t    && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'\n\t\t\t&& (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))\n\t\t|| p[1] == 'g'\n\t\t|| (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')\n\t\t|| p[1] == 'I'\n\t\t|| (p[1] == 'r' && p[2] != 'e')))\n    {\n\t*idx = CMD_substitute;\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":294460,"func":"set_of(union DateData *x, int of)\n{\n    assert(complex_dat_p(x));\n    get_c_jd(x);\n    get_c_df(x);\n    clear_civil(x);\n    x->c.of = of;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":225103,"func":"Status AllowedTypeValue(DataType dt, const OpDef::AttrDef& attr) {\n  const AttrValue& allowed_values(attr.allowed_values());\n  for (auto allowed : allowed_values.list().type()) {\n    if (dt == allowed) {\n      return Status::OK();\n    }\n  }\n  string allowed_str;\n  for (int i = 0; i < allowed_values.list().type_size(); ++i) {\n    if (!allowed_str.empty()) {\n      strings::StrAppend(&allowed_str, \", \");\n    }\n    strings::StrAppend(&allowed_str,\n                       DataTypeString(allowed_values.list().type(i)));\n  }\n  return errors::InvalidArgument(\n      \"Value for attr '\", attr.name(), \"' of \", DataTypeString(dt),\n      \" is not in the list of allowed values: \", allowed_str);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":512640,"func":"Item *Item_func_ne::negated_item(THD *thd) \/* a != b  ->  a = b *\/\n{\n  return new (thd->mem_root) Item_func_eq(thd, args[0], args[1]);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":344267,"func":"static const char *varinfo (lua_State *L, const TValue *o) {\n  CallInfo *ci = L->ci;\n  const char *name = NULL;  \/* to avoid warnings *\/\n  const char *kind = NULL;\n  if (isLua(ci)) {\n    kind = getupvalname(ci, o, &name);  \/* check whether 'o' is an upvalue *\/\n    if (!kind && isinstack(ci, o))  \/* no? try a register *\/\n      kind = getobjname(ci_func(ci)->p, currentpc(ci),\n                        cast_int(cast(StkId, o) - (ci->func + 1)), &name);\n  }\n  return formatvarinfo(L, kind, name);\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":462559,"func":"void controller::mark_deleted(const std::string& guid, bool b) {\n\trsscache->mark_item_deleted(guid, b);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":221694,"func":"Socket *Socket::accept() {\n    peer_adr_length = sizeof(struct sockaddr_in);\n    s_errno = 0;\n    errno = 0;\n\/\/    int newfd = this->baseAccept((struct sockaddr *)&peer_adr, &peer_adr_length);\n    int newfd = ::accept(sck, (struct sockaddr *) &peer_adr, &peer_adr_length);\n\n    if (newfd > 0) {\n        Socket *s = new Socket(newfd, my_adr, peer_adr);\n        s->setPort(my_port);\n        return s;\n    } else {\n        s_errno = errno;\n        return NULL;\n    }\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":386550,"func":"void DL_Dxf::addLeader(DL_CreationInterface* creationInterface) {\n    \/\/ leader (arrow)\n    DL_LeaderData le(\n        \/\/ arrow head flag\n        getIntValue(71, 1),\n        \/\/ leader path type\n        getIntValue(72, 0),\n        \/\/ Leader creation flag\n        getIntValue(73, 3),\n        \/\/ Hookline direction flag\n        getIntValue(74, 1),\n        \/\/ Hookline flag\n        getIntValue(75, 0),\n        \/\/ Text annotation height\n        getRealValue(40, 1.0),\n        \/\/ Text annotation width\n        getRealValue(41, 1.0),\n        \/\/ Number of vertices in leader\n        getIntValue(76, 0)\n    );\n    creationInterface->addLeader(le);\n\n    for (int i=0; i<maxLeaderVertices; i++) {\n        DL_LeaderVertexData d(leaderVertices[i*3],\n                              leaderVertices[i*3+1],\n                              leaderVertices[i*3+2]);\n\n        creationInterface->addLeaderVertex(d);\n    }\n    creationInterface->endEntity();\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":292605,"func":"int puma_parser_has_error(puma_parser *parser) {\n  return parser->cs == puma_parser_error;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":484754,"func":"static void xennet_poll_controller(struct net_device *dev)\n{\n\t\/* Poll each queue *\/\n\tstruct netfront_info *info = netdev_priv(dev);\n\tunsigned int num_queues = dev->real_num_tx_queues;\n\tunsigned int i;\n\n\tif (info->broken)\n\t\treturn;\n\n\tfor (i = 0; i < num_queues; ++i)\n\t\txennet_interrupt(0, &info->queues[i]);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":246207,"func":"Status SparseCountSparseOutputShapeFn(InferenceContext *c) {\n  ShapeHandle unused;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &unused));\n  auto rank = c->Dim(c->input(0), 1);\n  auto nvals = c->UnknownDim();\n  c->set_output(0, c->Matrix(nvals, rank));  \/\/ out.indices\n  c->set_output(1, c->Vector(nvals));        \/\/ out.values\n  c->set_output(2, c->Vector(rank));         \/\/ out.dense_shape\n  return Status::OK();\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":349253,"func":"static void read_block_list(unsigned int *block_list, long long start,\n\t\t\t\t\tunsigned int offset, int blocks)\n{\n\tint res;\n\n\tTRACE(\"read_block_list: blocks %d\\n\", blocks);\n\n\tif(swap) {\n\t\tchar *block_ptr = malloc(blocks * sizeof(unsigned int));\n\t\tif(block_ptr == NULL)\n\t\t\tMEM_ERROR();\n\t\tres = read_inode_data(block_ptr, &start, &offset, blocks * sizeof(unsigned int));\n\t\tif(res == FALSE)\n\t\t\tEXIT_UNSQUASH(\"read_block_list: failed to read \"\n\t\t\t\t\"inode index %lld:%d\\n\", start, offset);\n\t\tSQUASHFS_SWAP_INTS_3(block_list, block_ptr, blocks);\n\t\tfree(block_ptr);\n\t} else {\n\t\tres = read_inode_data(block_list, &start, &offset, blocks * sizeof(unsigned int));\n\t\tif(res == FALSE)\n\t\t\tEXIT_UNSQUASH(\"read_block_list: failed to read \"\n\t\t\t\t\"inode index %lld:%d\\n\", start, offset);\n\t}\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":254906,"func":"intrusive_ptr<DocumentSource> DocumentSourceGroup::optimize() {\n    \/\/ TODO: If all _idExpressions are ExpressionConstants after optimization, then we know there\n    \/\/ will be only one group. We should take advantage of that to avoid going through the hash\n    \/\/ table.\n    for (size_t i = 0; i < _idExpressions.size(); i++) {\n        _idExpressions[i] = _idExpressions[i]->optimize();\n    }\n\n    for (auto&& accumulatedField : _accumulatedFields) {\n        accumulatedField.expr.initializer = accumulatedField.expr.initializer->optimize();\n        accumulatedField.expr.argument = accumulatedField.expr.argument->optimize();\n    }\n\n    return this;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":312410,"func":"make_get_auname(cmdidx_T cmdidx)\n{\n    switch (cmdidx)\n    {\n\tcase CMD_make:\t    return (char_u *)\"make\";\n\tcase CMD_lmake:\t    return (char_u *)\"lmake\";\n\tcase CMD_grep:\t    return (char_u *)\"grep\";\n\tcase CMD_lgrep:\t    return (char_u *)\"lgrep\";\n\tcase CMD_grepadd:   return (char_u *)\"grepadd\";\n\tcase CMD_lgrepadd:  return (char_u *)\"lgrepadd\";\n\tdefault: return NULL;\n    }\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":252295,"func":"mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) {\n  (void)pStream;\n  \/\/ This is really over conservative. (And lame, but it's actually pretty\n  \/\/ tricky to compute a true upper bound given the way tdefl's blocking works.)\n  return MZ_MAX(128 + (source_len * 110) \/ 100,\n                128 + source_len + ((source_len \/ (31 * 1024)) + 1) * 5);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":482531,"func":"create_macro(const char *name, const widechar *definition, int definition_length,\n\t\tconst int *substitutions, int substitution_count, int argument_count) {\n\tMacro *m = malloc(sizeof(Macro));\n\tm->name = strdup(name);\n\twidechar *definition_copy = malloc(definition_length * sizeof(widechar));\n\tmemcpy(definition_copy, definition, definition_length * sizeof(widechar));\n\tm->definition = definition_copy;\n\tm->definition_length = definition_length;\n\tint *substitutions_copy = malloc(2 * substitution_count * sizeof(int));\n\tmemcpy(substitutions_copy, substitutions, 2 * substitution_count * sizeof(int));\n\tm->substitutions = substitutions_copy;\n\tm->substitution_count = substitution_count;\n\tm->argument_count = argument_count;\n\treturn m;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":487626,"func":"int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,\n\t\tstruct notifier_block *n)\n{\n\tint ret;\n\n\t\/*\n\t * This code gets used during boot-up, when task switching is\n\t * not yet working and interrupts must remain disabled.  At\n\t * such times we must not call mutex_lock().\n\t *\/\n\tif (unlikely(system_state == SYSTEM_BOOTING))\n\t\treturn notifier_chain_unregister(&nh->head, n);\n\n\tmutex_lock(&nh->mutex);\n\tret = notifier_chain_unregister(&nh->head, n);\n\tmutex_unlock(&nh->mutex);\n\tsynchronize_srcu(&nh->srcu);\n\treturn ret;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":265044,"func":"free_colour_buffer(void)\n{\n    if (--colseq_buf_allocs)\n\treturn;\n\n    DPUTS(!colseq_buf, \"Freeing colour sequence buffer without alloc\");\n    \/* Free buffer for colour code composition *\/\n    free(colseq_buf);\n    colseq_buf = NULL;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":336643,"func":"static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel)\n{\n    RedsState *reds = link->reds;\n    if (reds->config->sasl_enabled && !link->skip_auth) {\n        channel->set_common_cap(SPICE_COMMON_CAP_AUTH_SASL);\n    } else {\n        channel->set_common_cap(SPICE_COMMON_CAP_AUTH_SPICE);\n    }\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":512745,"func":"void Item_is_not_null_test::update_used_tables()\n{\n  if (!args[0]->maybe_null)\n    used_tables_cache= 0;\t\t\t\/* is always true *\/\n  else\n    args[0]->update_used_tables();\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":225430,"func":"static int v4l2_loopback_close(struct file *file)\n{\n\tstruct v4l2_loopback_opener *opener;\n\tstruct v4l2_loopback_device *dev;\n\tint iswriter = 0;\n\tMARK();\n\n\topener = fh_to_opener(file->private_data);\n\tdev = v4l2loopback_getdevice(file);\n\n\tif (WRITER == opener->type)\n\t\tiswriter = 1;\n\n\tatomic_dec(&dev->open_count);\n\tif (dev->open_count.counter == 0) {\n\t\tdel_timer_sync(&dev->sustain_timer);\n\t\tdel_timer_sync(&dev->timeout_timer);\n\t}\n\ttry_free_buffers(dev);\n\n\tv4l2_fh_del(&opener->fh);\n\tv4l2_fh_exit(&opener->fh);\n\n\tkfree(opener);\n\tif (iswriter) {\n\t\tdev->ready_for_output = 1;\n\t}\n\tMARK();\n\treturn 0;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":455302,"func":"init_unix_command_map ()\n{\n  emacs_std_cmd_xmap = rl_make_bare_keymap ();\n\n  emacs_std_cmd_xmap[CTRL('X')].type = ISKMAP;\n  emacs_std_cmd_xmap[CTRL('X')].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap ());\n  emacs_std_cmd_xmap[ESC].type = ISKMAP;\n  emacs_std_cmd_xmap[ESC].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap ());\n\n#if defined (VI_MODE)  \n  vi_insert_cmd_xmap = rl_make_bare_keymap ();\n  vi_movement_cmd_xmap = rl_make_bare_keymap ();\n#endif\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":222881,"func":"GraphProperties::GetOutputProperties(const string& node_name) const {\n  auto it = output_properties_.find(node_name);\n  if (it != output_properties_.end()) {\n    return it->second;\n  }\n  return missing_properties_;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":401530,"func":"int timer_reduce(struct timer_list *timer, unsigned long expires)\n{\n\treturn __mod_timer(timer, expires, MOD_TIMER_REDUCE);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":432197,"func":"void memory_listener_register(MemoryListener *listener, AddressSpace *as)\n{\n    listener->address_space = as;\n    QTAILQ_INSERT_TAIL(&as->uc->memory_listeners, listener, link);\n    QTAILQ_INSERT_TAIL(&as->listeners, listener, link_as);\n\n    listener_add_address_space(listener, as);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":474040,"func":"gbk_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)\n{\n  const UChar *p;\n  int len;\n\n  if (s <= start) return (UChar* )s;\n  p = s;\n\n  if (GBK_ISMB_TRAIL(*p)) {\n    while (p > start) {\n      if (! GBK_ISMB_FIRST(*--p)) {\n\tp++;\n\tbreak;\n      }\n    }\n  }\n  len = enclen(enc, p, end);\n  if (p + len > s) return (UChar* )p;\n  p += len;\n  return (UChar* )(p + ((s - p) & ~1));\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":308158,"func":"static void *fastrpc_kmap(struct dma_buf *dmabuf, unsigned long pgnum)\n{\n\tstruct fastrpc_buf *buf = dmabuf->priv;\n\n\treturn buf->virt ? buf->virt + pgnum * PAGE_SIZE : NULL;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":221645,"func":"llvh::Optional<NumericOrder> getNumericOrder(Literal *LHS, Literal *RHS) {\n  auto *L = llvh::dyn_cast<LiteralNumber>(LHS);\n  auto *R = llvh::dyn_cast<LiteralNumber>(RHS);\n\n  if (!L || !R)\n    return llvh::None;\n\n  double l = L->getValue();\n  double r = R->getValue();\n\n  if (l < r)\n    return NumericOrder::LessThan;\n  if (l > r)\n    return NumericOrder::GreaterThan;\n  if (std::isnan(l) || std::isnan(r))\n    return NumericOrder::Unordered;\n  return NumericOrder::Equal;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":273905,"func":"static int check_user_pass(ctrl_t *ctrl)\n{\n\tif (!ctrl->name[0])\n\t\treturn -1;\n\n\tif (!strcmp(\"anonymous\", ctrl->name))\n\t\treturn 1;\n\n\treturn 0;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":508823,"func":"TABLE_LIST *LEX::unlink_first_table(bool *link_to_local)\n{\n  TABLE_LIST *first;\n  if ((first= query_tables))\n  {\n    \/*\n      Exclude from global table list\n    *\/\n    if ((query_tables= query_tables->next_global))\n      query_tables->prev_global= &query_tables;\n    else\n      query_tables_last= &query_tables;\n    first->next_global= 0;\n\n    \/*\n      and from local list if it is not empty\n    *\/\n    if ((*link_to_local= MY_TEST(select_lex.table_list.first)))\n    {\n      select_lex.context.table_list= \n        select_lex.context.first_name_resolution_table= first->next_local;\n      select_lex.table_list.first= first->next_local;\n      select_lex.table_list.elements--;\t\/\/safety\n      first->next_local= 0;\n      \/*\n        Ensure that the global list has the same first table as the local\n        list.\n      *\/\n      first_lists_tables_same();\n    }\n  }\n  return first;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":226126,"func":"\nGF_Err reftype_box_size(GF_Box *s)\n{\n\tGF_TrackReferenceTypeBox *ptr = (GF_TrackReferenceTypeBox *)s;\n\tif (ptr->trackIDCount)\n\t\tptr->size += (ptr->trackIDCount * sizeof(u32));\n\treturn GF_OK;","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":225640,"func":"void rssr_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":443694,"func":"is_valid_mbc_string(const UChar* s, const UChar* end)\n{\n  return onigenc_length_check_is_valid_mbc_string(ONIG_ENCODING_UTF16_BE, s, end);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":241042,"func":"static int setup_transport(void)\n{\n\tint rv;\n\n\trv = transport()->init(message_recv);\n\tif (rv < 0) {\n\t\tlog_error(\"failed to init booth_transport %s\", transport()->name);\n\t\tgoto out;\n\t}\n\n\trv = booth_transport[TCP].init(NULL);\n\tif (rv < 0) {\n\t\tlog_error(\"failed to init booth_transport[TCP]\");\n\t\tgoto out;\n\t}\n\nout:\n\treturn rv;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":313800,"func":"nv_bck_word(cmdarg_T *cap)\n{\n    cap->oap->motion_type = MCHAR;\n    cap->oap->inclusive = FALSE;\n    curwin->w_set_curswant = TRUE;\n    if (bck_word(cap->count1, cap->arg, FALSE) == FAIL)\n\tclearopbeep(cap->oap);\n#ifdef FEAT_FOLDING\n    else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)\n\tfoldOpenCursor();\n#endif\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":462435,"func":"DataRcvd(ptcpsess_t *pThis, char *pData, size_t iLen)\n{\n\tstruct syslogTime stTime;\n\tDEFiRet;\n\tpThis->pLstn->rcvdBytes += iLen;\n\tif(pThis->compressionMode >= COMPRESS_STREAM_ALWAYS)\n\t\tiRet =  DataRcvdCompressed(pThis, pData, iLen);\n\telse\n\t\tiRet =  DataRcvdUncompressed(pThis, pData, iLen, &stTime, 0);\n\tRETiRet;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":299981,"func":"static void __exit elo_driver_exit(void)\n{\n\thid_unregister_driver(&elo_driver);\n\tdestroy_workqueue(wq);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":512520,"func":"  TYPELIB *get_typelib() const { return NULL; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":225627,"func":"GF_Err mfro_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_MovieFragmentRandomAccessOffsetBox *ptr = (GF_MovieFragmentRandomAccessOffsetBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->container_size);\n\treturn GF_OK;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":512914,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_copy_string>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":275983,"func":"int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve) {\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    uECC_word_t *_public = (uECC_word_t *)public_key;\n#else\n    uECC_word_t _public[uECC_MAX_WORDS * 2];\n#endif\n\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0\n    uECC_vli_bytesToNative(_public, public_key, curve->num_bytes);\n    uECC_vli_bytesToNative(\n        _public + curve->num_words, public_key + curve->num_bytes, curve->num_bytes);\n#endif\n    return uECC_valid_point(_public, curve);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":436133,"func":"static void io_submit_flush_completions(struct io_ring_ctx *ctx)\n{\n\tstruct io_comp_state *cs = &ctx->submit_state.comp;\n\tint i, nr = cs->nr;\n\tstruct req_batch rb;\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tfor (i = 0; i < nr; i++) {\n\t\tstruct io_kiocb *req = cs->reqs[i];\n\n\t\t__io_cqring_fill_event(ctx, req->user_data, req->result,\n\t\t\t\t\treq->compl.cflags);\n\t}\n\tio_commit_cqring(ctx);\n\tspin_unlock_irq(&ctx->completion_lock);\n\tio_cqring_ev_posted(ctx);\n\n\tio_init_req_batch(&rb);\n\tfor (i = 0; i < nr; i++) {\n\t\tstruct io_kiocb *req = cs->reqs[i];\n\n\t\t\/* submission and completion refs *\/\n\t\tif (req_ref_sub_and_test(req, 2))\n\t\t\tio_req_free_batch(&rb, req, &ctx->submit_state);\n\t}\n\n\tio_req_free_batch_finish(ctx, &rb);\n\tcs->nr = 0;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":509536,"func":"ha_maria::ha_maria(handlerton *hton, TABLE_SHARE *table_arg):\nhandler(hton, table_arg), file(0),\nint_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |\n                HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |\n                HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |\n                HA_FILE_BASED | HA_CAN_GEOMETRY | TRANSACTION_STATE |\n                HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS | HA_CAN_REPAIR |\n                HA_CAN_VIRTUAL_COLUMNS | HA_CAN_EXPORT |\n                HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT |\n                HA_CAN_TABLES_WITHOUT_ROLLBACK),\ncan_enable_indexes(0), bulk_insert_single_undo(BULK_INSERT_NONE)\n{}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":508842,"func":"bool st_select_lex::add_item_to_list(THD *thd, Item *item)\n{\n  DBUG_ENTER(\"st_select_lex::add_item_to_list\");\n  DBUG_PRINT(\"info\", (\"Item: %p\", item));\n  DBUG_RETURN(item_list.push_back(item, thd->mem_root));\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":509522,"func":"FT_INFO *ha_maria::ft_init_ext(uint flags, uint inx, String * key)\n{\n  return maria_ft_init_search(flags, file, inx,\n                              (uchar *) key->ptr(), key->length(),\n                              key->charset(), table->record[0]);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":488360,"func":"static inline int copy_pud_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,\n\t\tpgd_t *dst_pgd, pgd_t *src_pgd, struct vm_area_struct *vma,\n\t\tunsigned long addr, unsigned long end)\n{\n\tpud_t *src_pud, *dst_pud;\n\tunsigned long next;\n\n\tdst_pud = pud_alloc(dst_mm, dst_pgd, addr);\n\tif (!dst_pud)\n\t\treturn -ENOMEM;\n\tsrc_pud = pud_offset(src_pgd, addr);\n\tdo {\n\t\tnext = pud_addr_end(addr, end);\n\t\tif (pud_none_or_clear_bad(src_pud))\n\t\t\tcontinue;\n\t\tif (copy_pmd_range(dst_mm, src_mm, dst_pud, src_pud,\n\t\t\t\t\t\tvma, addr, next))\n\t\t\treturn -ENOMEM;\n\t} while (dst_pud++, src_pud++, addr = next, addr != end);\n\treturn 0;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":405717,"func":"static void xemaclite_update_address(struct net_local *drvdata,\n\t\t\t\t     u8 *address_ptr)\n{\n\tvoid __iomem *addr;\n\tu32 reg_data;\n\n\t\/* Determine the expected Tx buffer address *\/\n\taddr = drvdata->base_addr + drvdata->next_tx_buf_to_use;\n\n\txemaclite_aligned_write(address_ptr, (u32 __force *)addr, ETH_ALEN);\n\n\txemaclite_writel(ETH_ALEN, addr + XEL_TPLR_OFFSET);\n\n\t\/* Update the MAC address in the EmacLite *\/\n\treg_data = xemaclite_readl(addr + XEL_TSR_OFFSET);\n\txemaclite_writel(reg_data | XEL_TSR_PROG_MAC_ADDR, addr + XEL_TSR_OFFSET);\n\n\t\/* Wait for EmacLite to finish with the MAC address update *\/\n\twhile ((xemaclite_readl(addr + XEL_TSR_OFFSET) &\n\t\tXEL_TSR_PROG_MAC_ADDR) != 0)\n\t\t;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":294412,"func":"date_s_xmlschema(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n    if (!NIL_P(opt)) argc--;\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"-4712-01-01\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        if (!NIL_P(opt)) argv2[argc2++] = opt;\n\tVALUE hash = date_s__xmlschema(argc2, argv2, klass);\n\treturn d_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":214272,"func":"find_next_quote(\n    char_u\t*line,\n    int\t\tcol,\n    int\t\tquotechar,\n    char_u\t*escape)\t\/\/ escape characters, can be NULL\n{\n    int\t\tc;\n\n    for (;;)\n    {\n\tc = line[col];\n\tif (c == NUL)\n\t    return -1;\n\telse if (escape != NULL && vim_strchr(escape, c))\n\t    ++col;\n\telse if (c == quotechar)\n\t    break;\n\tif (has_mbyte)\n\t    col += (*mb_ptr2len)(line + col);\n\telse\n\t    ++col;\n    }\n    return col;\n}","target":1,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":336624,"func":"static void reds_send_link_result(RedLinkInfo *link, uint32_t error)\n{\n    error = GUINT32_TO_LE(error);\n    red_stream_write_all(link->stream, &error, sizeof(error));\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":439081,"func":"ModuleExport size_t RegisterDPXImage(void)\n{\n  MagickInfo\n    *entry;\n\n  static const char\n    *DPXNote =\n    {\n      \"Digital Moving Picture Exchange Bitmap, Version 2.0.\\n\"\n      \"See SMPTE 268M-2003 specification at http:\/\/www.smtpe.org\\n\"\n    };\n\n  entry=SetMagickInfo(\"DPX\");\n  entry->decoder=(DecodeImageHandler *) ReadDPXImage;\n  entry->encoder=(EncodeImageHandler *) WriteDPXImage;\n  entry->magick=(IsImageFormatHandler *) IsDPX;\n  entry->seekable_stream=MagickTrue;\n  entry->adjoin=MagickFalse;\n  entry->description=ConstantString(\"SMPTE 268M-2003 (DPX 2.0)\");\n  entry->note=ConstantString(DPXNote);\n  entry->module=ConstantString(\"DPX\");\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":247702,"func":"  const std::string& expectedPeerCert() const { return expected_peer_cert_; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":246653,"func":"static void naludmx_end_access_unit(GF_NALUDmxCtx *ctx)\n{\n\t\/\/finalize current fram flags - we will flush(send) later on\n\tnaludmx_finalize_au_flags(ctx);\n\n\tctx->has_islice = GF_FALSE;\n\tctx->first_slice_in_au = GF_TRUE;\n\tctx->sei_recovery_frame_count = -1;\n\tctx->au_sap = GF_FILTER_SAP_NONE;\n\tctx->au_sap2_poc_reset = GF_FALSE;\n\tctx->bottom_field_flag = GF_FALSE;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":273069,"func":"mutex_init(pthread_mutex_t *mutex)\n{\n  pthread_mutexattr_t mattr;\n  int err;\n\n  CHECK_ERR(L_MISC, pthread_mutexattr_init(&mattr));\n  CHECK_ERR(L_MISC, pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ERRORCHECK));\n  err = pthread_mutex_init(mutex, &mattr);\n  CHECK_ERR(L_MISC, pthread_mutexattr_destroy(&mattr));\n\n  return err;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":453003,"func":"static int nft_immediate_offload(struct nft_offload_ctx *ctx,\n\t\t\t\t struct nft_flow_rule *flow,\n\t\t\t\t const struct nft_expr *expr)\n{\n\tconst struct nft_immediate_expr *priv = nft_expr_priv(expr);\n\n\tif (priv->dreg == NFT_REG_VERDICT)\n\t\treturn nft_immediate_offload_verdict(ctx, flow, priv);\n\n\tmemcpy(&ctx->regs[priv->dreg].data, &priv->data, sizeof(priv->data));\n\n\treturn 0;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":256401,"func":"static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter)\n{\n\tstruct bio_vec *bvec;\n\tstruct bvec_iter_all iter_all;\n\n\tbio_for_each_segment_all(bvec, bio, iter_all) {\n\t\tssize_t ret;\n\n\t\tret = copy_page_from_iter(bvec->bv_page,\n\t\t\t\t\t  bvec->bv_offset,\n\t\t\t\t\t  bvec->bv_len,\n\t\t\t\t\t  iter);\n\n\t\tif (!iov_iter_count(iter))\n\t\t\tbreak;\n\n\t\tif (ret < bvec->bv_len)\n\t\t\treturn -EFAULT;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":459188,"func":"static void __tcf_block_put(struct tcf_block *block, struct Qdisc *q,\n\t\t\t    struct tcf_block_ext_info *ei, bool rtnl_held)\n{\n\tif (refcount_dec_and_mutex_lock(&block->refcnt, &block->lock)) {\n\t\t\/* Flushing\/putting all chains will cause the block to be\n\t\t * deallocated when last chain is freed. However, if chain_list\n\t\t * is empty, block has to be manually deallocated. After block\n\t\t * reference counter reached 0, it is no longer possible to\n\t\t * increment it or add new chains to block.\n\t\t *\/\n\t\tbool free_block = list_empty(&block->chain_list);\n\n\t\tmutex_unlock(&block->lock);\n\t\tif (tcf_block_shared(block))\n\t\t\ttcf_block_remove(block, block->net);\n\n\t\tif (q)\n\t\t\ttcf_block_offload_unbind(block, q, ei);\n\n\t\tif (free_block)\n\t\t\ttcf_block_destroy(block);\n\t\telse\n\t\t\ttcf_block_flush_all_chains(block, rtnl_held);\n\t} else if (q) {\n\t\ttcf_block_offload_unbind(block, q, ei);\n\t}\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":513158,"func":"  uchar* global_value_ptr(THD *thd, const LEX_STRING *base)\n  { return do_value_ptr(thd, OPT_GLOBAL, base); }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":230271,"func":"njs_array_destroy(njs_vm_t *vm, njs_array_t *array)\n{\n    if (array->data != NULL) {\n        njs_mp_free(vm->mem_pool, array->data);\n    }\n\n    \/* TODO: destroy keys. *\/\n\n    njs_mp_free(vm->mem_pool, array);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":252325,"func":"static bool ComputeChannelLayout(std::vector<size_t> *channel_offset_list,\n                                 int *pixel_data_size, size_t *channel_offset,\n                                 int num_channels,\n                                 const EXRChannelInfo *channels) {\n  channel_offset_list->resize(static_cast<size_t>(num_channels));\n\n  (*pixel_data_size) = 0;\n  (*channel_offset) = 0;\n\n  for (size_t c = 0; c < static_cast<size_t>(num_channels); c++) {\n    (*channel_offset_list)[c] = (*channel_offset);\n    if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) {\n      (*pixel_data_size) += sizeof(unsigned short);\n      (*channel_offset) += sizeof(unsigned short);\n    } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) {\n      (*pixel_data_size) += sizeof(float);\n      (*channel_offset) += sizeof(float);\n    } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) {\n      (*pixel_data_size) += sizeof(unsigned int);\n      (*channel_offset) += sizeof(unsigned int);\n    } else {\n      \/\/ ???\n      return false;\n    }\n  }\n  return true;\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":508811,"func":"bool is_keyword(const char *name, uint len)\n{\n  DBUG_ASSERT(len != 0);\n  return get_hash_symbol(name,len,0)!=0;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":225775,"func":"GF_Err moof_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_MovieFragmentBox *ptr = (GF_MovieFragmentBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\t\/\/Header First\n\tgf_isom_check_position(s, (GF_Box *)ptr->mfhd, &pos);\n\t\/\/then PSSH\n\tgf_isom_check_position_list(s, ptr->PSSHs, &pos);\n\t\/\/then the track list\n\tgf_isom_check_position_list(s, ptr->TrackList, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":248759,"func":"static void strstore(char **str, const char *newstr)\n{\n  free(*str);\n  *str = strdup(newstr);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":247668,"func":"  const std::string& expectedServerCertDigest() const { return expected_server_cert_digest_; }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":317014,"func":"static int selinux_peerlbl_enabled(void)\n{\n\treturn (selinux_policycap_alwaysnetwork() ||\n\t\tnetlbl_enabled() || selinux_xfrm_enabled());\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":436059,"func":"static bool io_match_task(struct io_kiocb *head, struct task_struct *task,\n\t\t\t  bool cancel_all)\n{\n\tstruct io_kiocb *req;\n\n\tif (task && head->task != task)\n\t\treturn false;\n\tif (cancel_all)\n\t\treturn true;\n\n\tio_for_each_link(req, head) {\n\t\tif (req->flags & REQ_F_INFLIGHT)\n\t\t\treturn true;\n\t}\n\treturn false;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":275992,"func":"void uECC_compress(const uint8_t *public_key, uint8_t *compressed, uECC_Curve curve) {\n    wordcount_t i;\n    for (i = 0; i < curve->num_bytes; ++i) {\n        compressed[i+1] = public_key[i];\n    }\n#if uECC_VLI_NATIVE_LITTLE_ENDIAN\n    compressed[0] = 2 + (public_key[curve->num_bytes] & 0x01);\n#else\n    compressed[0] = 2 + (public_key[curve->num_bytes * 2 - 1] & 0x01);\n#endif\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":294640,"func":"mk_ary_of_str(long len, const char *a[])\n{\n    VALUE o;\n    long i;\n\n    o = rb_ary_new2(len);\n    for (i = 0; i < len; i++) {\n\tVALUE e;\n\n\tif (!a[i])\n\t    e = Qnil;\n\telse {\n\t    e = rb_usascii_str_new2(a[i]);\n\t    rb_obj_freeze(e);\n\t}\n\trb_ary_push(o, e);\n    }\n    rb_obj_freeze(o);\n    return o;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":336610,"func":"bool reds_config_get_playback_compression(RedsState *reds)\n{\n    return reds->config->playback_compression;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":384806,"func":"mkdir_recurse(char_u *dir, int prot)\n{\n    char_u\t*p;\n    char_u\t*updir;\n    int\t\tr = FAIL;\n\n    \/\/ Get end of directory name in \"dir\".\n    \/\/ We're done when it's \"\/\" or \"c:\/\".\n    p = gettail_sep(dir);\n    if (p <= get_past_head(dir))\n\treturn OK;\n\n    \/\/ If the directory exists we're done.  Otherwise: create it.\n    updir = vim_strnsave(dir, p - dir);\n    if (updir == NULL)\n\treturn FAIL;\n    if (mch_isdir(updir))\n\tr = OK;\n    else if (mkdir_recurse(updir, prot) == OK)\n\tr = vim_mkdir_emsg(updir, prot);\n    vim_free(updir);\n    return r;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":443301,"func":"ex_find(exarg_T *eap)\n{\n    char_u\t*fname;\n    int\t\tcount;\n\n    fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS,\n\t\t\t\t\t\t      TRUE, curbuf->b_ffname);\n    if (eap->addr_count > 0)\n    {\n\t\/\/ Repeat finding the file \"count\" times.  This matters when it\n\t\/\/ appears several times in the path.\n\tcount = eap->line2;\n\twhile (fname != NULL && --count > 0)\n\t{\n\t    vim_free(fname);\n\t    fname = find_file_in_path(NULL, 0, FNAME_MESS,\n\t\t\t\t\t\t     FALSE, curbuf->b_ffname);\n\t}\n    }\n\n    if (fname != NULL)\n    {\n\teap->arg = fname;\n\tdo_exedit(eap, NULL);\n\tvim_free(fname);\n    }\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":264373,"func":"inline protobuf::RepeatedField<int32>* MutableTensorProtoData<Eigen::half>(\n    TensorProto* t) {\n  return t->mutable_half_val();\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":413695,"func":"static const char *reg_name_for_access(RAnalOp* op, RAnalVarAccessType type) {\n\tif (type == R_ANAL_VAR_ACCESS_TYPE_WRITE) {\n\t\tif (op->dst && op->dst->reg) {\n\t\t\treturn op->dst->reg->name;\n\t\t}\n\t} else {\n\t\tif (op->src[0] && op->src[0]->reg) {\n\t\t\treturn op->src[0]->reg->name;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":424934,"func":"static void iwl_pcie_set_pwr(struct iwl_trans *trans, bool vaux)\n{\n\tif (trans->cfg->apmg_not_supported)\n\t\treturn;\n\n\tif (vaux && pci_pme_capable(to_pci_dev(trans->dev), PCI_D3cold))\n\t\tiwl_set_bits_mask_prph(trans, APMG_PS_CTRL_REG,\n\t\t\t\t       APMG_PS_CTRL_VAL_PWR_SRC_VAUX,\n\t\t\t\t       ~APMG_PS_CTRL_MSK_PWR_SRC);\n\telse\n\t\tiwl_set_bits_mask_prph(trans, APMG_PS_CTRL_REG,\n\t\t\t\t       APMG_PS_CTRL_VAL_PWR_SRC_VMAIN,\n\t\t\t\t       ~APMG_PS_CTRL_MSK_PWR_SRC);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":401487,"func":"static ssize_t extract_entropy(struct entropy_store *r, void *buf,\n\t\t\t\t size_t nbytes, int min, int reserved)\n{\n\t__u8 tmp[EXTRACT_SIZE];\n\tunsigned long flags;\n\n\t\/* if last_data isn't primed, we need EXTRACT_SIZE extra bytes *\/\n\tif (fips_enabled) {\n\t\tspin_lock_irqsave(&r->lock, flags);\n\t\tif (!r->last_data_init) {\n\t\t\tr->last_data_init = 1;\n\t\t\tspin_unlock_irqrestore(&r->lock, flags);\n\t\t\ttrace_extract_entropy(r->name, EXTRACT_SIZE,\n\t\t\t\t\t      ENTROPY_BITS(r), _RET_IP_);\n\t\t\textract_buf(r, tmp);\n\t\t\tspin_lock_irqsave(&r->lock, flags);\n\t\t\tmemcpy(r->last_data, tmp, EXTRACT_SIZE);\n\t\t}\n\t\tspin_unlock_irqrestore(&r->lock, flags);\n\t}\n\n\ttrace_extract_entropy(r->name, nbytes, ENTROPY_BITS(r), _RET_IP_);\n\tnbytes = account(r, nbytes, min, reserved);\n\n\treturn _extract_entropy(r, buf, nbytes, fips_enabled);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":318967,"func":"f_test_option_not_set(typval_T *argvars, typval_T *rettv UNUSED)\n{\n    char_u *name = (char_u *)\"\";\n\n    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)\n\treturn;\n\n    if (argvars[0].v_type != VAR_STRING)\n\temsg(_(e_invalid_argument));\n    else\n    {\n\tname = tv_get_string(&argvars[0]);\n\tif (reset_option_was_set(name) == FAIL)\n\t    semsg(_(e_invalid_argument_str), name);\n    }\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":256156,"func":"ALWAYS_INLINE void LoadTwoScalars(const bfloat16** data, Packet* l1,\n                                  Packet* l2) {\n  if (kNumOperands >= 2) {\n    auto tmp = ConvertTwoBfloat16ToFloat(*data);\n    *l1 = Eigen::internal::pbroadcast_first<Packet>(tmp);\n    *l2 = Eigen::internal::pbroadcast_second<Packet>(tmp);\n    *data += 2;\n  } else {\n    LoadSingleScalar(data, l1);\n    LoadSingleScalar(data, l2);\n  }\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":247602,"func":"  const std::string& expectedRequestedServerName() const { return expected_requested_server_name_; }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":294522,"func":"d_lite_new_start(int argc, VALUE *argv, VALUE self)\n{\n    VALUE vsg;\n    double sg;\n\n    rb_scan_args(argc, argv, \"01\", &vsg);\n\n    sg = DEFAULT_SG;\n    if (argc >= 1)\n\tval2sg(vsg, sg);\n\n    return dup_obj_with_new_start(self, sg);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":477304,"func":"static inline void tipc_crypto_key_set_state(struct tipc_crypto *c,\n\t\t\t\t\t     u8 new_passive,\n\t\t\t\t\t     u8 new_active,\n\t\t\t\t\t     u8 new_pending)\n{\n\tstruct tipc_key old = c->key;\n\tchar buf[32];\n\n\tc->key.keys = ((new_passive & KEY_MASK) << (KEY_BITS * 2)) |\n\t\t      ((new_active  & KEY_MASK) << (KEY_BITS)) |\n\t\t      ((new_pending & KEY_MASK));\n\n\tpr_debug(\"%s: key changing %s ::%pS\\n\", c->name,\n\t\t tipc_key_change_dump(old, c->key, buf),\n\t\t __builtin_return_address(0));\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":489169,"func":"struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,\n\t\t\t\t  const struct sctp_transport *transport,\n\t\t\t\t  const void *payload, const size_t paylen)\n{\n\tstruct sctp_chunk *retval = sctp_make_chunk(asoc, SCTP_CID_HEARTBEAT,\n\t\t\t\t\t\t    0, paylen);\n\n\tif (!retval)\n\t\tgoto nodata;\n\n\t\/* Cast away the 'const', as this is just telling the chunk\n\t * what transport it belongs to.\n\t *\/\n\tretval->transport = (struct sctp_transport *) transport;\n\tretval->subh.hbs_hdr = sctp_addto_chunk(retval, paylen, payload);\n\nnodata:\n\treturn retval;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":274654,"func":"callbacks_get_col_num_from_tree_view_col (GtkTreeViewColumn *col)\n{\n\tGList *cols;\n\tgint   num;\n\t\n\tg_return_val_if_fail ( col != NULL, -1 );\n\tg_return_val_if_fail ( col->tree_view != NULL, -1 );\n\tcols = gtk_tree_view_get_columns(GTK_TREE_VIEW(col->tree_view));\n\tnum = g_list_index(cols, (gpointer) col);\n\tg_list_free(cols);\n\treturn num;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":263393,"func":"Status GetAxisForPackAndUnpack(InferenceContext* c, int32_t rank_after_pack,\n                               int32* axis) {\n  TF_RETURN_IF_ERROR(c->GetAttr(\"axis\", axis));\n  if (*axis < -1 * rank_after_pack || *axis >= rank_after_pack) {\n    return errors::InvalidArgument(\"Invalid axis: \", *axis, \"; must be in [\",\n                                   -1 * rank_after_pack, \",\", rank_after_pack,\n                                   \")\");\n  }\n  if (*axis < 0) *axis = (rank_after_pack + *axis);\n  return Status::OK();\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":248256,"func":"DLLIMPORT unsigned int cfg_num(cfg_t *cfg)\n{\n\tif (!cfg)\n\t\treturn 0;\n\n\treturn (unsigned int)cfg_numopts(cfg->opts);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":222892,"func":"static void NormalizeShapeForOutput(TensorShapeProto* shape) {\n  for (int i = 0; i < shape->dim_size(); i++) {\n    if (shape->dim(i).size() < -1) {\n      VLOG(2) << \"Normalizing dimension: \" << i << \" from \"\n              << shape->dim(i).size() << \" to -1\";\n      shape->mutable_dim(i)->set_size(-1);\n    }\n  }\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":246478,"func":"static inline RBinWasmCustomNameLocalNames *parse_custom_names_local(RBuffer *b, ut64 bound) {\n\tRBinWasmCustomNameLocalNames *local = R_NEW0 (RBinWasmCustomNameLocalNames);\n\tif (!local) {\n\t\treturn NULL;\n\t}\n\tif (!consume_u32_r (b, bound, &local->count)) {\n\t\tgoto beach;\n\t}\n\n\tlocal->locals = r_list_newf ((RListFree)wasm_custom_name_local_free);\n\tif (local->locals) {\n\t\tsize_t i;\n\t\tfor (i = 0; i < local->count; i++) {\n\t\t\tRBinWasmCustomNameLocalName *local_name = parse_local_name (b, bound);\n\t\t\tif (!local_name || !r_list_append (local->locals, local_name)) {\n\t\t\t\twasm_custom_name_local_free (local_name);\n\t\t\t\tgoto beach;\n\t\t\t}\n\t\t}\n\t\treturn local;\n\t}\n\nbeach:\n\twasm_custom_local_names_free (local);\n\treturn NULL;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":314748,"func":"cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)\n{\n\tsize_t siz = (size_t)off + len;\n\n\tif ((off_t)(off + len) != (off_t)siz) {\n\t\terrno = EINVAL;\n\t\treturn -1;\n\t}\n\n\tif (info->i_buf != NULL && info->i_len >= siz) {\n\t\t(void)memcpy(buf, &info->i_buf[off], len);\n\t\treturn (ssize_t)len;\n\t}\n\n\tif (info->i_fd == -1)\n\t\treturn -1;\n\n\tif (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (off_t)-1)\n\t\treturn -1;\n\n\tif (FINFO_READ_FUNC(info->i_fd, buf, len) != (ssize_t)len)\n\t\treturn -1;\n\n\treturn (ssize_t)len;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":294501,"func":"date_s_gregorian_leap_p(VALUE klass, VALUE y)\n{\n    VALUE nth;\n    int ry;\n\n    check_numeric(y, \"year\");\n    decode_year(y, -1, &nth, &ry);\n    return f_boolcast(c_gregorian_leap_p(ry));\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":253639,"func":"smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,\n\t\tstruct cifs_fid *fid)\n{\n\tSMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":417099,"func":"mp_sint32 PlayerGeneric::getPanningSeparation() const\n{\n\tif (player)\n\t\treturn player->getPanningSeparation();\n\t\t\n\treturn panningSeparation;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":218854,"func":"ImmutableExecutorState::FrameInfo* ImmutableExecutorState::EnsureFrameInfo(\n    const string& fname) {\n  auto iter = frame_info_.find(fname);\n  if (iter != frame_info_.end()) {\n    return iter->second.get();\n  } else {\n    auto frame_info = absl::make_unique<FrameInfo>(fname);\n    absl::string_view fname_view = frame_info->name;\n    auto emplace_result =\n        frame_info_.emplace(fname_view, std::move(frame_info));\n    return emplace_result.first->second.get();\n  }\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":369878,"func":"static bool has_pid_permissions(struct pid_namespace *pid,\n\t\t\t\t struct task_struct *task,\n\t\t\t\t int hide_pid_min)\n{\n\tif (pid->hide_pid < hide_pid_min)\n\t\treturn true;\n\tif (in_group_p(pid->pid_gid))\n\t\treturn true;\n\treturn ptrace_may_access(task, PTRACE_MODE_READ);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":409401,"func":"term_7to8bit(char_u *p)\n{\n    if (*p == ESC)\n    {\n\tif (p[1] == '[')\n\t    return CSI;\n\tif (p[1] == ']')\n\t    return OSC;\n\tif (p[1] == 'O')\n\t    return 0x8f;\n    }\n    return 0;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":357663,"func":"void SQClass::Finalize() {\n    _attributes.Null();\n    _NULL_SQOBJECT_VECTOR(_defaultvalues,_defaultvalues.size());\n    _methods.resize(0);\n    _NULL_SQOBJECT_VECTOR(_metamethods,MT_LAST);\n    __ObjRelease(_members);\n    if(_base) {\n        __ObjRelease(_base);\n    }\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":455422,"func":"xfs_inode_free_quota_cowblocks(\n\tstruct xfs_inode *ip)\n{\n\treturn __xfs_inode_free_quota_eofblocks(ip, xfs_icache_free_cowblocks);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":247685,"func":"  const std::string& expectedPeerSubject() const { return expected_peer_subject_; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":212818,"func":"static pj_status_t decode_errcode_attr(pj_pool_t *pool, \n\t\t\t\t       const pj_uint8_t *buf,\n\t\t\t\t       const pj_stun_msg_hdr *msghdr, \n\t\t\t\t       void **p_attr)\n{\n    pj_stun_errcode_attr *attr;\n    pj_str_t value;\n\n    PJ_UNUSED_ARG(msghdr);\n\n    \/* Create the attribute *\/\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_errcode_attr);\n    GETATTRHDR(buf, &attr->hdr);\n\n    attr->err_code = buf[6] * 100 + buf[7];\n\n    \/* Get pointer to the string in the message *\/\n    value.ptr = ((char*)buf + ATTR_HDR_LEN + 4);\n    value.slen = attr->hdr.length - 4;\n\n    \/* Copy the string to the attribute *\/\n    pj_strdup(pool, &attr->reason, &value);\n\n    \/* Done *\/\n    *p_attr = attr;\n\n    return PJ_SUCCESS;\n}","target":1,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":413622,"func":"R_API char *r_core_anal_fcn_autoname(RCore *core, ut64 addr, int dump, int mode) {\n\tRAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, 0);\n\treturn fcn? anal_fcn_autoname (core, fcn, dump, mode): NULL;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":229295,"func":"void cql_server::response::write_inet(socket_address inet)\n{\n    auto addr = inet.addr();\n    write_byte(uint8_t(addr.size()));\n    auto * p = static_cast<const int8_t*>(addr.data());\n    _body.write(bytes_view(p, addr.size()));\n    write_int(inet.port());\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":222562,"func":"bool RegisterOp(const string& op, Creator func) {\n  CHECK(GetOpGradFactory()->insert({op, func}).second)\n      << \"Duplicated gradient for \" << op;\n  return true;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":244316,"func":"static u32 ctrn_ctts_to_index(GF_TrackFragmentRunBox *ctrn, s32 ctts)\n{\n\tif (!(ctrn->flags & GF_ISOM_TRUN_CTS_OFFSET))\n\t\treturn 0;\n\n\tif (!ctts) return 0;\n\n\tif (ctrn->version) {\n\t\tif (ctrn->ctso_multiplier) return ctrn_s32_to_index(ctts \/ ctrn->ctso_multiplier);\n\t\treturn ctrn_s32_to_index(ctts);\n\t}\n\tassert(ctts>0);\n\tif (ctrn->ctso_multiplier) return ctrn_u32_to_index((u32)ctts \/ ctrn->ctso_multiplier);\n\treturn ctrn_s32_to_index((u32)ctts);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":225876,"func":"GF_Err urn_box_size(GF_Box *s)\n{\n\tGF_DataEntryURNBox *ptr = (GF_DataEntryURNBox *)s;\n\n\tif ( !(ptr->flags & 1)) {\n\t\tif (ptr->nameURN) ptr->size += 1 + strlen(ptr->nameURN);\n\t\tif (ptr->location) ptr->size += 1 + strlen(ptr->location);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":344750,"func":"hpdelim2(char **cp, char *delim)\n{\n\tchar *s, *old;\n\n\tif (cp == NULL || *cp == NULL)\n\t\treturn NULL;\n\n\told = s = *cp;\n\tif (*s == '[') {\n\t\tif ((s = strchr(s, ']')) == NULL)\n\t\t\treturn NULL;\n\t\telse\n\t\t\ts++;\n\t} else if ((s = strpbrk(s, \":\/\")) == NULL)\n\t\ts = *cp + strlen(*cp); \/* skip to end (see first case below) *\/\n\n\tswitch (*s) {\n\tcase '\\0':\n\t\t*cp = NULL;\t\/* no more fields*\/\n\t\tbreak;\n\n\tcase ':':\n\tcase '\/':\n\t\tif (delim != NULL)\n\t\t\t*delim = *s;\n\t\t*s = '\\0';\t\/* terminate *\/\n\t\t*cp = s + 1;\n\t\tbreak;\n\n\tdefault:\n\t\treturn NULL;\n\t}\n\n\treturn old;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":384292,"func":"gs_malloc_release(gs_memory_t *mem)\n{\n    gs_malloc_memory_t * malloc_memory_default;\n\n    if (mem == NULL)\n        return;\n\n    \/* Use gs_debug['a'] if gs_debug[':'] is set to dump the heap stats *\/\n    if (gs_debug[':']) {\n        void *temp;\n        char save_debug_a = gs_debug['a'];\n\n        gs_debug['a'] = 1;\n        temp = (char *)gs_alloc_bytes_immovable(mem, 8, \"gs_malloc_release\");\n        gs_debug['a'] = save_debug_a;\n        gs_free_object(mem, temp, \"gs_malloc_release\");\n    }\n\n#ifdef USE_RETRY_MEMORY_WRAPPER\n    malloc_memory_default = gs_malloc_unwrap(mem);\n#else\n    malloc_memory_default = (gs_malloc_memory_t *)mem;\n#endif\n    gs_lib_ctx_fin((gs_memory_t *)malloc_memory_default);\n\n    gs_malloc_memory_release(malloc_memory_default);\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":90156,"func":"  void Init() {\n    VLOG(1) << \"Getting initial CrOS network info.\";\n    UpdateSystemInfo();\n  }\n","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":265457,"func":"static int sqfs_tokenize(char **tokens, int count, const char *str)\n{\n\tint i, j, ret = 0;\n\tchar *aux, *strc;\n\n\tstrc = strdup(str);\n\tif (!strc)\n\t\treturn -ENOMEM;\n\n\tif (!strcmp(strc, \"\/\")) {\n\t\ttokens[0] = strdup(strc);\n\t\tif (!tokens[0]) {\n\t\t\tret = -ENOMEM;\n\t\t\tgoto free_strc;\n\t\t}\n\t} else {\n\t\tfor (j = 0; j < count; j++) {\n\t\t\taux = strtok(!j ? strc : NULL, \"\/\");\n\t\t\ttokens[j] = strdup(aux);\n\t\t\tif (!tokens[j]) {\n\t\t\t\tfor (i = 0; i < j; i++)\n\t\t\t\t\tfree(tokens[i]);\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto free_strc;\n\t\t\t}\n\t\t}\n\t}\n\nfree_strc:\n\tfree(strc);\n\n\treturn ret;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":244003,"func":"GF_Err st3d_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Stereo3DBox *ptr = (GF_Stereo3DBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 1)\n\tptr->stereo_type = gf_bs_read_u8(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":221164,"func":"GF_Err gf_odf_write_descriptor_list_filter(GF_BitStream *bs, GF_List *descList, u8 only_tag)\n{\n\tGF_Err e;\n\tu32 count, i;\n\n\tif (! descList) return GF_OK;\n\tcount = gf_list_count(descList);\n\tfor ( i = 0; i < count; i++ ) {\n\t\tGF_Descriptor *tmp = (GF_Descriptor*)gf_list_get(descList, i);\n\t\tif (tmp && (tmp->tag==only_tag) ) {\n\t\t\te = gf_odf_write_descriptor(bs, tmp);\n\t\t\tif (e) return e;\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":359331,"func":"DEFUN (ip_community_list_expanded,\n       ip_community_list_expanded_cmd,\n       \"ip community-list <100-500> (deny|permit) .LINE\",\n       IP_STR\n       COMMUNITY_LIST_STR\n       \"Community list number (expanded)\\n\"\n       \"Specify community to reject\\n\"\n       \"Specify community to accept\\n\"\n       \"An ordered list as a regular-expression\\n\")\n{\n  return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":312391,"func":"qf_get_nth_below_entry(qfline_T *entry_arg, int n, int linewise, int *errornr)\n{\n    qfline_T *entry = entry_arg;\n\n    while (n-- > 0 && !got_int)\n    {\n\tint\t\tfirst_errornr = *errornr;\n\n\tif (linewise)\n\t    \/\/ Treat all the entries on the same line in this file as one\n\t    entry = qf_find_last_entry_on_line(entry, errornr);\n\n\tif (entry->qf_next == NULL\n\t\t|| entry->qf_next->qf_fnum != entry->qf_fnum)\n\t{\n\t    if (linewise)\n\t\t*errornr = first_errornr;\n\t    break;\n\t}\n\n\tentry = entry->qf_next;\n\t++*errornr;\n    }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":410078,"func":"void hid_dump_report(struct hid_device *hid, int type, u8 *data,\n\t\tint size)\n{\n\tstruct hid_report_enum *report_enum;\n\tchar *buf;\n\tunsigned int i;\n\n\tbuf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);\n\n\tif (!buf)\n\t\treturn;\n\n\treport_enum = hid->report_enum + type;\n\n\t\/* dump the report *\/\n\tsnprintf(buf, HID_DEBUG_BUFSIZE - 1,\n\t\t\t\"\\nreport (size %u) (%snumbered) = \", size,\n\t\t\treport_enum->numbered ? \"\" : \"un\");\n\thid_debug_event(hid, buf);\n\n\tfor (i = 0; i < size; i++) {\n\t\tsnprintf(buf, HID_DEBUG_BUFSIZE - 1,\n\t\t\t\t\" %02x\", data[i]);\n\t\thid_debug_event(hid, buf);\n\t}\n\thid_debug_event(hid, \"\\n\");\n\tkfree(buf);\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":277667,"func":"get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n\/* This version is for reading text-format PGM files with any maxval *\/\n{\n  ppm_source_ptr source = (ppm_source_ptr) sinfo;\n  FILE * infile = source->pub.input_file;\n  register JSAMPROW ptr;\n  register JSAMPLE *rescale = source->rescale;\n  JDIMENSION col;\n  int maxval = source->maxval;\n\n  ptr = source->pub.buffer[0];\n  for (col = cinfo->image_width; col > 0; col--) {\n    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];\n  }\n  return 1;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":294392,"func":"datetime_s__strptime(int argc, VALUE *argv, VALUE klass)\n{\n    return date_s__strptime_internal(argc, argv, klass, \"%FT%T%z\");\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":225908,"func":"\nGF_Err dac3_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;\n\n\tif (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DEC3;\n\te = gf_isom_box_write_header(s, bs);\n\tif (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DAC3;\n\tif (e) return e;\n\t\n\treturn gf_odf_ac3_cfg_write_bs(&ptr->cfg, bs);","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":242972,"func":"static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl )\n{\n    return( ( ssl->in_msg[1] << 16 ) |\n            ( ssl->in_msg[2] << 8  ) |\n              ssl->in_msg[3] );\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":275478,"func":"njs_vm_init(njs_vm_t *vm)\n{\n    njs_int_t    ret;\n    njs_frame_t  *frame;\n\n    frame = (njs_frame_t *) njs_function_frame_alloc(vm, NJS_FRAME_SIZE);\n    if (njs_slow_path(frame == NULL)) {\n        njs_memory_error(vm);\n        return NJS_ERROR;\n    }\n\n    frame->exception.catch = NULL;\n    frame->exception.next = NULL;\n    frame->previous_active_frame = NULL;\n\n    vm->active_frame = frame;\n\n    ret = njs_regexp_init(vm);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    ret = njs_builtin_objects_clone(vm, &vm->global_value);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return NJS_ERROR;\n    }\n\n    njs_lvlhsh_init(&vm->values_hash);\n    njs_lvlhsh_init(&vm->keywords_hash);\n    njs_lvlhsh_init(&vm->modules_hash);\n    njs_lvlhsh_init(&vm->events_hash);\n\n    njs_queue_init(&vm->posted_events);\n    njs_queue_init(&vm->promise_events);\n\n    return NJS_OK;\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":224169,"func":"  explicit MapUnstageNoKeyOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":255101,"func":"int unit_name_path_escape(const char *f, char **ret) {\n        _cleanup_free_ char *p = NULL;\n        char *s;\n\n        assert(f);\n        assert(ret);\n\n        p = strdup(f);\n        if (!p)\n                return -ENOMEM;\n\n        path_simplify(p, false);\n\n        if (empty_or_root(p))\n                s = strdup(\"-\");\n        else {\n                if (!path_is_normalized(p))\n                        return -EINVAL;\n\n                \/* Truncate trailing slashes and skip leading slashes *\/\n                delete_trailing_chars(p, \"\/\");\n                s = unit_name_escape(skip_leading_chars(p, \"\/\"));\n        }\n        if (!s)\n                return -ENOMEM;\n\n        *ret = s;\n        return 0;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":462576,"func":"void controller::set_view(view * vv) {\n\tv = vv;\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":226067,"func":"GF_Box *enca_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MPEGAudioSampleEntryBox, GF_ISOM_BOX_TYPE_ENCA);\n\tgf_isom_audio_sample_entry_init((GF_AudioSampleEntryBox*)tmp);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":264376,"func":"  int num_files() const { return sss_.size(); }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":225032,"func":"pqFreeCommandQueue(PGcmdQueueEntry *queue)\n{\n\twhile (queue != NULL)\n\t{\n\t\tPGcmdQueueEntry *cur = queue;\n\n\t\tqueue = cur->next;\n\t\tif (cur->query)\n\t\t\tfree(cur->query);\n\t\tfree(cur);\n\t}\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":225031,"func":"PQclientEncoding(const PGconn *conn)\n{\n\tif (!conn || conn->status != CONNECTION_OK)\n\t\treturn -1;\n\treturn conn->client_encoding;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":393526,"func":"static SQInteger table_getdelegate(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_getdelegate(v,-1))?1:SQ_ERROR;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":445996,"func":"encryption_copy_progress_cb (goffset  current_num_bytes,\n\t\t\t     goffset  total_num_bytes,\n\t\t\t     gpointer user_data)\n{\n\tEncryptData *edata = user_data;\n\n\tfr_archive_progress (edata->new_archive, (double) current_num_bytes \/ total_num_bytes);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":443705,"func":"utf32le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)\n{\n  const UChar* p = *pp;\n\n  (*pp) += 4;\n\n  if (*(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) {\n    int c, v;\n\n    if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n      return TRUE;\n    }\n\n    c = *p;\n    v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,\n                       (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));\n    if ((v | BIT_CTYPE_LOWER) != 0) {\n      \/* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. *\/\n      if (c >= 0xaa && c <= 0xba)\n        return FALSE;\n      else\n        return TRUE;\n    }\n    return (v != 0 ? TRUE : FALSE);\n  }\n\n  return FALSE;\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":317232,"func":"static int smack_audit_rule_known(struct audit_krule *krule)\n{\n\tstruct audit_field *f;\n\tint i;\n\n\tfor (i = 0; i < krule->field_count; i++) {\n\t\tf = &krule->fields[i];\n\n\t\tif (f->type == AUDIT_SUBJ_USER || f->type == AUDIT_OBJ_USER)\n\t\t\treturn 1;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":95901,"func":"void AddProductSpecificWorkItems(const InstallationState& original_state,\n                                 const InstallerState& installer_state,\n                                 const FilePath& setup_path,\n                                 const Version& new_version,\n                                 WorkItemList* list) {\n  const Products& products = installer_state.products();\n  for (size_t i = 0; i < products.size(); ++i) {\n    const Product& p = *products[i];\n    if (p.is_chrome_frame()) {\n      AddChromeFrameWorkItems(original_state, installer_state, setup_path,\n                              new_version, p, list);\n    }\n  }\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":261766,"func":"void RtmpProtocol::sendPingResponse(uint32_t time_stamp) {\n    sendUserControl(CONTROL_PING_RESPONSE, time_stamp);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":468376,"func":"g_socket_client_connect_to_host_finish (GSocketClient  *client,\n\t\t\t\t\tGAsyncResult   *result,\n\t\t\t\t\tGError        **error)\n{\n  return g_socket_client_connect_finish (client, result, error);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":225561,"func":"  explicit FractionalMaxPoolGradOp(OpKernelConstruction* context)\n      : OpKernel(context) {\n    OP_REQUIRES_OK(context, context->GetAttr(\"overlapping\", &overlapping_));\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":292608,"func":"int puma_parser_finish(puma_parser *parser)\n{\n  if (puma_parser_has_error(parser) ) {\n    return -1;\n  } else if (puma_parser_is_finished(parser) ) {\n    return 1;\n  } else {\n    return 0;\n  }\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":247356,"func":"static void pgpPrtVal(const char * pre, pgpValTbl vs, uint8_t val)\n{\n    if (!_print) return;\n    if (pre && *pre)\n\tfprintf(stderr, \"%s\", pre);\n    fprintf(stderr, \"%s(%u)\", pgpValStr(vs, val), (unsigned)val);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":317030,"func":"static int selinux_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode)\n{\n\treturn may_create(dir, dentry, SECCLASS_FILE);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":445871,"func":"_window_started_loading_file (FrWindow *window,\n\t\t\t      GFile    *file)\n{\n\tchar *description;\n\n\tdescription = get_action_description (window, FR_ACTION_LOADING_ARCHIVE, file);\n\tfr_archive_message_cb (NULL, description, window);\n\n\tg_free (description);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":234795,"func":"static int chunk_devid_filter(struct extent_buffer *leaf,\n\t\t\t      struct btrfs_chunk *chunk,\n\t\t\t      struct btrfs_balance_args *bargs)\n{\n\tstruct btrfs_stripe *stripe;\n\tint num_stripes = btrfs_chunk_num_stripes(leaf, chunk);\n\tint i;\n\n\tfor (i = 0; i < num_stripes; i++) {\n\t\tstripe = btrfs_stripe_nr(chunk, i);\n\t\tif (btrfs_stripe_devid(leaf, stripe) == bargs->devid)\n\t\t\treturn 0;\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":197760,"func":"TfLiteStatus EvalGatherNd(TfLiteContext* context, const TfLiteTensor* params,\n                          const TfLiteTensor* indices, TfLiteTensor* output) {\n  switch (params->type) {\n    case kTfLiteFloat32:\n      return GatherNd<float, IndicesT>(params, indices, output);\n    case kTfLiteUInt8:\n      return GatherNd<uint8_t, IndicesT>(params, indices, output);\n    case kTfLiteInt8:\n      return GatherNd<int8_t, IndicesT>(params, indices, output);\n    case kTfLiteInt16:\n      return GatherNd<int16_t, IndicesT>(params, indices, output);\n    case kTfLiteInt32:\n      return GatherNd<int32_t, IndicesT>(params, indices, output);\n    case kTfLiteInt64:\n      return GatherNd<int64_t, IndicesT>(params, indices, output);\n    case kTfLiteString:\n      return GatherNdString<IndicesT>(params, indices, output);\n    default:\n      context->ReportError(context,\n                           \"Params type '%s' are not supported by gather_nd.\",\n                           TfLiteTypeGetName(params->type));\n      return kTfLiteError;\n  }\n}","target":1,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":317200,"func":"static int __net_init selinux_nf_register(struct net *net)\n{\n\treturn nf_register_net_hooks(net, selinux_nf_ops,\n\t\t\t\t     ARRAY_SIZE(selinux_nf_ops));\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":244147,"func":"GF_Err vmhd_box_size(GF_Box *s)\n{\n\tGF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s;\n\tptr->size += 8;\n\treturn GF_OK;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":404731,"func":"void put_files_struct(struct files_struct *files)\n{\n\tif (atomic_dec_and_test(&files->count)) {\n\t\tstruct fdtable *fdt = close_files(files);\n\n\t\t\/* free the arrays if they are not embedded *\/\n\t\tif (fdt != &files->fdtab)\n\t\t\t__free_fdtable(fdt);\n\t\tkmem_cache_free(files_cachep, files);\n\t}\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":309884,"func":"_nc_screen_resume(void)\n{\n    NCURSES_SP_NAME(_nc_screen_resume) (CURRENT_SCREEN);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":90862,"func":"  void NotifyOriginInUse(const GURL& origin) {\n    quota_manager_->NotifyOriginInUse(origin);\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":481280,"func":"static int mlx5_fpga_conn_create_wq(struct mlx5_fpga_conn *conn, void *qpc)\n{\n\tstruct mlx5_fpga_device *fdev = conn->fdev;\n\tstruct mlx5_core_dev *mdev = fdev->mdev;\n\tstruct mlx5_wq_param wqp;\n\n\twqp.buf_numa_node = mdev->priv.numa_node;\n\twqp.db_numa_node  = mdev->priv.numa_node;\n\n\treturn mlx5_wq_qp_create(mdev, &wqp, qpc, &conn->qp.wq,\n\t\t\t\t &conn->qp.wq_ctrl);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":362313,"func":"static void usb_audio_make_shortname(struct usb_device *dev,\n\t\t\t\t     struct snd_usb_audio *chip,\n\t\t\t\t     const struct snd_usb_audio_quirk *quirk)\n{\n\tstruct snd_card *card = chip->card;\n\n\tif (quirk && quirk->product_name && *quirk->product_name) {\n\t\tstrlcpy(card->shortname, quirk->product_name,\n\t\t\tsizeof(card->shortname));\n\t\treturn;\n\t}\n\n\t\/* retrieve the device string as shortname *\/\n\tif (!dev->descriptor.iProduct ||\n\t    usb_string(dev, dev->descriptor.iProduct,\n\t\t       card->shortname, sizeof(card->shortname)) <= 0) {\n\t\t\/* no name available from anywhere, so use ID *\/\n\t\tsprintf(card->shortname, \"USB Device %#04x:%#04x\",\n\t\t\tUSB_ID_VENDOR(chip->usb_id),\n\t\t\tUSB_ID_PRODUCT(chip->usb_id));\n\t}\n\n\tstrim(card->shortname);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":90154,"func":"  const std::string& IPAddress() const {\n    const Network* active = active_network();\n    if (active != NULL)\n      return active->ip_address();\n    if (ethernet_)\n      return ethernet_->ip_address();\n    static std::string null_address(\"0.0.0.0\");\n    return null_address;\n  }\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":468384,"func":"connection_attempt_ref (ConnectionAttempt *attempt)\n{\n  g_ref_count_inc (&attempt->ref);\n  return attempt;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":244278,"func":"GF_Err tsro_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":310152,"func":"has_mouse(void)\n{\n    return _nc_has_mouse(CURRENT_SCREEN);\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":301383,"func":"static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,\n\t\t\t\t   const char *name,\n\t\t\t\t   uint32 security_info,\n\t\t\t\t   TALLOC_CTX *mem_ctx,\n\t\t\t\t   struct security_descriptor **ppdesc)\n{\n\tNTSTATUS result;\n\n\tSTART_PROFILE(get_nt_acl);\n\tresult = posix_get_nt_acl(handle->conn, name, security_info,\n\t\t\t\t  mem_ctx, ppdesc);\n\tEND_PROFILE(get_nt_acl);\n\treturn result;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":384841,"func":"trans_characters(\n    char_u\t*buf,\n    int\t\tbufsize)\n{\n    int\t\tlen;\t\t\/\/ length of string needing translation\n    int\t\troom;\t\t\/\/ room in buffer after string\n    char_u\t*trs;\t\t\/\/ translated character\n    int\t\ttrs_len;\t\/\/ length of trs[]\n\n    len = (int)STRLEN(buf);\n    room = bufsize - len;\n    while (*buf != 0)\n    {\n\t\/\/ Assume a multi-byte character doesn't need translation.\n\tif (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)\n\t    len -= trs_len;\n\telse\n\t{\n\t    trs = transchar_byte(*buf);\n\t    trs_len = (int)STRLEN(trs);\n\t    if (trs_len > 1)\n\t    {\n\t\troom -= trs_len - 1;\n\t\tif (room <= 0)\n\t\t    return;\n\t\tmch_memmove(buf + trs_len, buf + 1, (size_t)len);\n\t    }\n\t    mch_memmove(buf, trs, (size_t)trs_len);\n\t    --len;\n\t}\n\tbuf += trs_len;\n    }\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":512781,"func":"  Item_cache(THD *thd, const Type_handler *handler):\n    Item(thd),\n    Type_handler_hybrid_field_type(handler),\n    example(0), cached_field(0),\n    value_cached(0),\n    used_table_map(0)\n  {\n    maybe_null= 1;\n    null_value= 1;\n    null_value_inside= true;\n  }","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":225827,"func":"GF_Err tims_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":427158,"func":"static void localfunc (LexState *ls) {\n  expdesc b;\n  FuncState *fs = ls->fs;\n  int fvar = fs->nactvar;  \/* function's variable index *\/\n  new_localvar(ls, str_checkname(ls));  \/* new local variable *\/\n  adjustlocalvars(ls, 1);  \/* enter its scope *\/\n  body(ls, &b, 0, ls->linenumber);  \/* function created in next register *\/\n  \/* debug information will only see the variable after this point! *\/\n  localdebuginfo(fs, fvar)->startpc = fs->pc;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":512448,"func":"void Item_func_decode_oracle::print(String *str, enum_query_type query_type)\n{\n  str->append(func_name());\n  str->append('(');\n  args[0]->print(str, query_type);\n  for (uint i= 1, count= when_count() ; i <= count; i++)\n  {\n    str->append(',');\n    args[i]->print(str, query_type);\n    str->append(',');\n    args[i+count]->print(str, query_type);\n  }\n  Item **else_expr= Item_func_case_simple::else_expr_addr();\n  if (else_expr)\n  {\n    str->append(',');\n    (*else_expr)->print(str, query_type);\n  }\n  str->append(')');\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":402663,"func":"handle_kill_daemon(context *ctx UNUSED,\n\t\t   struct pollfd *pollfd UNUSED,\n\t\t   socklen_t size UNUSED)\n{\n\tshould_exit = 1;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":424973,"func":"static int iwl_pcie_load_firmware_chunk(struct iwl_trans *trans,\n\t\t\t\t\tu32 dst_addr, dma_addr_t phy_addr,\n\t\t\t\t\tu32 byte_cnt)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tunsigned long flags;\n\tint ret;\n\n\ttrans_pcie->ucode_write_complete = false;\n\n\tif (!iwl_trans_grab_nic_access(trans, &flags))\n\t\treturn -EIO;\n\n\tiwl_pcie_load_firmware_chunk_fh(trans, dst_addr, phy_addr,\n\t\t\t\t\tbyte_cnt);\n\tiwl_trans_release_nic_access(trans, &flags);\n\n\tret = wait_event_timeout(trans_pcie->ucode_write_waitq,\n\t\t\t\t trans_pcie->ucode_write_complete, 5 * HZ);\n\tif (!ret) {\n\t\tIWL_ERR(trans, \"Failed to load firmware chunk!\\n\");\n\t\tiwl_trans_pcie_dump_regs(trans);\n\t\treturn -ETIMEDOUT;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":221398,"func":"int svm_allocate_nested(struct vcpu_svm *svm)\n{\n\tstruct page *vmcb02_page;\n\n\tif (svm->nested.initialized)\n\t\treturn 0;\n\n\tvmcb02_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);\n\tif (!vmcb02_page)\n\t\treturn -ENOMEM;\n\tsvm->nested.vmcb02.ptr = page_address(vmcb02_page);\n\tsvm->nested.vmcb02.pa = __sme_set(page_to_pfn(vmcb02_page) << PAGE_SHIFT);\n\n\tsvm->nested.msrpm = svm_vcpu_alloc_msrpm();\n\tif (!svm->nested.msrpm)\n\t\tgoto err_free_vmcb02;\n\tsvm_vcpu_init_msrpm(&svm->vcpu, svm->nested.msrpm);\n\n\tsvm->nested.initialized = true;\n\treturn 0;\n\nerr_free_vmcb02:\n\t__free_page(vmcb02_page);\n\treturn -ENOMEM;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":409509,"func":"starttermcap(void)\n{\n    if (full_screen && !termcap_active)\n    {\n\tMAY_WANT_TO_LOG_THIS;\n\n\tout_str(T_TI);\t\t\t\/\/ start termcap mode\n\tout_str(T_CTI);\t\t\t\/\/ start \"raw\" mode\n\tout_str(T_KS);\t\t\t\/\/ start \"keypad transmit\" mode\n\tout_str(T_BE);\t\t\t\/\/ enable bracketed paste mode\n\n#if defined(UNIX) || defined(VMS)\n\t\/\/ Enable xterm's focus reporting mode when 'esckeys' is set.\n\tif (p_ek && *T_FE != NUL)\n\t    out_str(T_FE);\n#endif\n\n\tout_flush();\n\ttermcap_active = TRUE;\n\tscreen_start();\t\t\t\/\/ don't know where cursor is now\n#ifdef FEAT_TERMRESPONSE\n# ifdef FEAT_GUI\n\tif (!gui.in_use && !gui.starting)\n# endif\n\t{\n\t    may_req_termresponse();\n\t    \/\/ Immediately check for a response.  If t_Co changes, we don't\n\t    \/\/ want to redraw with wrong colors first.\n\t    if (crv_status.tr_progress == STATUS_SENT)\n\t\tcheck_for_codes_from_term();\n\t}\n#endif\n    }\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":512688,"func":"int Arg_comparator::compare_time()\n{\n  THD *thd= current_thd;\n  longlong val1= (*a)->val_time_packed(thd);\n  if (!(*a)->null_value)\n  {\n    longlong val2= (*b)->val_time_packed(thd);\n    if (!(*b)->null_value)\n      return compare_not_null_values(val1, val2);\n  }\n  if (set_null)\n    owner->null_value= true;\n  return -1;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":338038,"func":"uint32_t WasmBinaryBuilder::getInt32() {\n  BYN_TRACE(\"<==\\n\");\n  auto ret = uint32_t(getInt16());\n  ret |= uint32_t(getInt16()) << 16;\n  BYN_TRACE(\"getInt32: \" << ret << \"\/0x\" << std::hex << ret << std::dec\n                         << \" ==>\\n\");\n  return ret;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":244274,"func":"GF_Box *fecr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(FECReservoirBox, GF_ISOM_BOX_TYPE_FECR);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":436034,"func":"static int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_provide_buf *p = &req->pbuf;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tstruct io_buffer *head;\n\tint ret = 0;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tio_ring_submit_lock(ctx, !force_nonblock);\n\n\tlockdep_assert_held(&ctx->uring_lock);\n\n\tret = -ENOENT;\n\thead = xa_load(&ctx->io_buffers, p->bgid);\n\tif (head)\n\t\tret = __io_remove_buffers(ctx, head, p->bgid, p->nbufs);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\n\t\/* complete before unlock, IOPOLL may need the lock *\/\n\t__io_req_complete(req, issue_flags, ret, 0);\n\tio_ring_submit_unlock(ctx, !force_nonblock);\n\treturn 0;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":462245,"func":"PJ_DEF(pj_status_t) pj_stun_msg_init( pj_stun_msg *msg,\n\t\t\t\t      unsigned msg_type,\n\t\t\t\t      pj_uint32_t magic,\n\t\t\t\t      const pj_uint8_t tsx_id[12])\n{\n    PJ_ASSERT_RETURN(msg && msg_type, PJ_EINVAL);\n\n    msg->hdr.type = (pj_uint16_t) msg_type;\n    msg->hdr.length = 0;\n    msg->hdr.magic = magic;\n    msg->attr_count = 0;\n\n    if (tsx_id) {\n\tpj_memcpy(&msg->hdr.tsx_id, tsx_id, sizeof(msg->hdr.tsx_id));\n    } else {\n\tstruct transaction_id\n\t{\n\t    pj_uint32_t\t    proc_id;\n\t    pj_uint32_t\t    random;\n\t    pj_uint32_t\t    counter;\n\t} id;\n\tstatic pj_uint32_t pj_stun_tsx_id_counter;\n\n\tif (!pj_stun_tsx_id_counter)\n\t    pj_stun_tsx_id_counter = pj_rand();\n\n\tid.proc_id = pj_getpid();\n\tid.random = pj_rand();\n\tid.counter = pj_stun_tsx_id_counter++;\n\n\tpj_memcpy(&msg->hdr.tsx_id, &id, sizeof(msg->hdr.tsx_id));\n    }\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":316963,"func":"static int selinux_inode_getxattr(struct dentry *dentry, const char *name)\n{\n\tconst struct cred *cred = current_cred();\n\n\treturn dentry_has_perm(cred, dentry, FILE__GETATTR);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":502717,"func":"int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,\n                                                 EVP_PKEY **pkey) {\n    return ctx->client_cert_cb;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":312417,"func":"qf_get_next_str_line(qfstate_T *state)\n{\n    \/\/ Get the next line from the supplied string\n    char_u\t*p_str = state->p_str;\n    char_u\t*p;\n    int\t\tlen;\n\n    if (*p_str == NUL) \/\/ Reached the end of the string\n\treturn QF_END_OF_INPUT;\n\n    p = vim_strchr(p_str, '\\n');\n    if (p != NULL)\n\tlen = (int)(p - p_str) + 1;\n    else\n\tlen = (int)STRLEN(p_str);\n\n    if (len > IOSIZE - 2)\n    {\n\tstate->linebuf = qf_grow_linebuf(state, len);\n\tif (state->linebuf == NULL)\n\t    return QF_NOMEM;\n    }\n    else\n    {\n\tstate->linebuf = IObuff;\n\tstate->linelen = len;\n    }\n    vim_strncpy(state->linebuf, p_str, state->linelen);\n\n    \/\/ Increment using len in order to discard the rest of the\n    \/\/ line if it exceeds LINE_MAXLEN.\n    p_str += len;\n    state->p_str = p_str;\n\n    return QF_OK;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":226277,"func":"#ifdef GF_ENABLE_CTRN\nstatic void ctrn_write_sample_flags(GF_BitStream *bs, u32 flags, u32 field_size)\n{\n\tif (!field_size) return;\n\n\tif (field_size==8) flags = flags>>24;\n\telse if (field_size==16) flags = flags>>16;\n\tgf_bs_write_int(bs, flags, field_size);","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":353138,"func":"void SplashOutputDev::fill(GfxState *state) {\n  if (state->getFillColorSpace()->isNonMarking()) {\n    return;\n  }\n  setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(),\n\t\t   state->getOverprintMode(), state->getFillColor());\n  SplashPath path = convertPath(state, state->getPath(), true);\n  splash->fill(&path, false);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":512691,"func":"bool cmp_item_row::alloc_comparators(THD *thd, uint cols)\n{\n  if (comparators)\n  {\n    DBUG_ASSERT(cols == n);\n    return false;\n  }\n  return\n    !(comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *) * (n= cols)));\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":230969,"func":"mrb_env_unshare(mrb_state *mrb, struct REnv *e)\n{\n  if (e == NULL) return;\n  else {\n    size_t len = (size_t)MRB_ENV_LEN(e);\n    mrb_value *p;\n\n    if (!MRB_ENV_ONSTACK_P(e)) return;\n    if (e->cxt != mrb->c) return;\n    if (e == mrb_vm_ci_env(mrb->c->cibase)) return; \/* for mirb *\/\n    p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);\n    if (len > 0) {\n      stack_copy(p, e->stack, len);\n    }\n    e->stack = p;\n    MRB_ENV_CLOSE(e);\n    mrb_write_barrier(mrb, (struct RBasic *)e);\n  }\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":261989,"func":"static void conncache_remove_bundle(struct conncache *connc,\n                                    struct connectbundle *bundle)\n{\n  struct Curl_hash_iterator iter;\n  struct Curl_hash_element *he;\n\n  if(!connc)\n    return;\n\n  Curl_hash_start_iterate(&connc->hash, &iter);\n\n  he = Curl_hash_next_element(&iter);\n  while(he) {\n    if(he->ptr == bundle) {\n      \/* The bundle is destroyed by the hash destructor function,\n         free_bundle_hash_entry() *\/\n      Curl_hash_delete(&connc->hash, he->key, he->key_len);\n      return;\n    }\n\n    he = Curl_hash_next_element(&iter);\n  }\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":236183,"func":"GF_Err hclr_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TextHighlightColorBox*ptr = (GF_TextHighlightColorBox*)s;\n\tISOM_DECREASE_SIZE(ptr, 4)\n\tptr->hil_color = gpp_read_rgba(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":224985,"func":"parse_int_param(const char *value, int *result, PGconn *conn,\n\t\t\t\tconst char *context)\n{\n\tchar\t   *end;\n\tlong\t\tnumval;\n\n\tAssert(value != NULL);\n\n\t*result = 0;\n\n\t\/* strtol(3) skips leading whitespaces *\/\n\terrno = 0;\n\tnumval = strtol(value, &end, 10);\n\n\t\/*\n\t * If no progress was done during the parsing or an error happened, fail.\n\t * This tests properly for overflows of the result.\n\t *\/\n\tif (value == end || errno != 0 || numval != (int) numval)\n\t\tgoto error;\n\n\t\/*\n\t * Skip any trailing whitespace; if anything but whitespace remains before\n\t * the terminating character, fail\n\t *\/\n\twhile (*end != '\\0' && isspace((unsigned char) *end))\n\t\tend++;\n\n\tif (*end != '\\0')\n\t\tgoto error;\n\n\t*result = numval;\n\treturn true;\n\nerror:\n\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t  libpq_gettext(\"invalid integer value \\\"%s\\\" for connection option \\\"%s\\\"\\n\"),\n\t\t\t\t\t  value, context);\n\treturn false;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":272337,"func":"generate_common_name(cms_context *cms, SECItem *der, char *cn_str)\n{\n\tCommonName cn;\n\tSECItem cn_item;\n\tint rc;\n\n\trc = generate_object_id(cms, &cn.oid, SEC_OID_AVA_COMMON_NAME);\n\tif (rc < 0)\n\t\treturn rc;\n\trc = generate_string(cms, &cn.string, cn_str);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tvoid *ret;\n\tret = SEC_ASN1EncodeItem(cms->arena, &cn_item, &cn, CommonNameTemplate);\n\tif (ret == NULL)\n\t\tcnreterr(-1, cms, \"could not encode common name\");\n\n\tSECItem cn_set;\n\tSECItem *items[2] = {&cn_item, NULL};\n\trc = wrap_in_set(cms, &cn_set, items);\n\tif (rc < 0)\n\t\treturn rc;\n\trc = wrap_in_seq(cms, der, &cn_set, 1);\n\tif (rc < 0)\n\t\treturn rc;\n\treturn 0;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":448583,"func":"next_int (FILE *fstream)\n{\n\tint ch;\n\tint value = 0;\n\tint gotone = 0;\n\tint done = 0;\n    \n\t\/* loop, accumulate hex value until find delimiter \n\t   skip any initial delimiters found in read stream *\/\n\n\twhile (!done) {\n\t\tch = getc (fstream);\n\t\tif (ch == EOF) {\n\t\t\tvalue = -1;\n\t\t\tdone++;\n\t\t} else {\n\t\t\t\/* trim high bits, check type and accumulate *\/\n\t\t\tch &= 0xff;\n\t\t\tif (g_ascii_isxdigit (ch)) {\n\t\t\t\tvalue = (value << 4) + g_ascii_xdigit_value (ch);\n\t\t\t\tgotone++;\n\t\t\t} else if ((hex_table[ch]) < 0 && gotone) {\n\t\t\t\tdone++;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":389682,"func":"tv_get_string_strict(typval_T *varp)\n{\n    static char_u   mybuf[NUMBUFLEN];\n    char_u\t    *res =  tv_get_string_buf_chk_strict(\n\t\t\t\t\t\t varp, mybuf, in_vim9script());\n\n    return res != NULL ? res : (char_u *)\"\";\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":474023,"func":"st_hash_start(st_index_t h)\n{\n    return h;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":430390,"func":"static void update_range(struct sw_flow_match *match,\n\t\t\t size_t offset, size_t size, bool is_mask)\n{\n\tstruct sw_flow_key_range *range;\n\tsize_t start = rounddown(offset, sizeof(long));\n\tsize_t end = roundup(offset + size, sizeof(long));\n\n\tif (!is_mask)\n\t\trange = &match->range;\n\telse\n\t\trange = &match->mask->range;\n\n\tif (range->start == range->end) {\n\t\trange->start = start;\n\t\trange->end = end;\n\t\treturn;\n\t}\n\n\tif (range->start > start)\n\t\trange->start = start;\n\n\tif (range->end < end)\n\t\trange->end = end;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":384910,"func":"vim_isblankline(char_u *lbuf)\n{\n    char_u\t*p;\n\n    p = skipwhite(lbuf);\n    return (*p == NUL || *p == '\\r' || *p == '\\n');\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":300744,"func":"int tsk_set_importance(struct sock *sk, int imp)\n{\n\tif (imp > TIPC_CRITICAL_IMPORTANCE)\n\t\treturn -EINVAL;\n\tmsg_set_importance(&tipc_sk(sk)->phdr, (u32)imp);\n\treturn 0;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":385896,"func":"int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,\n\t       struct inode *new_dir, struct dentry *new_dentry)\n{\n\tint error;\n\tint is_dir = S_ISDIR(old_dentry->d_inode->i_mode);\n\tconst unsigned char *old_name;\n\n\tif (old_dentry->d_inode == new_dentry->d_inode)\n \t\treturn 0;\n \n\terror = may_delete(old_dir, old_dentry, is_dir);\n\tif (error)\n\t\treturn error;\n\n\tif (!new_dentry->d_inode)\n\t\terror = may_create(new_dir, new_dentry);\n\telse\n\t\terror = may_delete(new_dir, new_dentry, is_dir);\n\tif (error)\n\t\treturn error;\n\n\tif (!old_dir->i_op->rename)\n\t\treturn -EPERM;\n\n\told_name = fsnotify_oldname_init(old_dentry->d_name.name);\n\n\tif (is_dir)\n\t\terror = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);\n\telse\n\t\terror = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);\n\tif (!error)\n\t\tfsnotify_move(old_dir, new_dir, old_name, is_dir,\n\t\t\t      new_dentry->d_inode, old_dentry);\n\tfsnotify_oldname_free(old_name);\n\n\treturn error;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":359412,"func":"DEFUN (show_ip_bgp_attr_info, \n       show_ip_bgp_attr_info_cmd,\n       \"show ip bgp attribute-info\",\n       SHOW_STR\n       IP_STR\n       BGP_STR\n       \"List all bgp attribute information\\n\")\n{\n  attr_show_all (vty);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":313554,"func":"void rose_add_loopback_neigh(void)\n{\n\tstruct rose_neigh *sn;\n\n\trose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), GFP_KERNEL);\n\tif (!rose_loopback_neigh)\n\t\treturn;\n\tsn = rose_loopback_neigh;\n\n\tsn->callsign  = null_ax25_address;\n\tsn->digipeat  = NULL;\n\tsn->ax25      = NULL;\n\tsn->dev       = NULL;\n\tsn->count     = 0;\n\tsn->use       = 0;\n\tsn->dce_mode  = 1;\n\tsn->loopback  = 1;\n\tsn->number    = rose_neigh_no++;\n\tsn->restarted = 1;\n\n\tskb_queue_head_init(&sn->queue);\n\n\ttimer_setup(&sn->ftimer, NULL, 0);\n\ttimer_setup(&sn->t0timer, NULL, 0);\n\n\tspin_lock_bh(&rose_neigh_list_lock);\n\tsn->next = rose_neigh_list;\n\trose_neigh_list           = sn;\n\tspin_unlock_bh(&rose_neigh_list_lock);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":292131,"func":"methodHandle LinkResolver::resolve_virtual_call_or_null(\n                                                 Klass* receiver_klass,\n                                                 const LinkInfo& link_info) {\n  EXCEPTION_MARK;\n  CallInfo info;\n  resolve_virtual_call(info, Handle(), receiver_klass, link_info, false, THREAD);\n  if (HAS_PENDING_EXCEPTION) {\n    CLEAR_PENDING_EXCEPTION;\n    return methodHandle();\n  }\n  return info.selected_method();\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":463059,"func":"static void sungem_do_tx_csum(SunGEMState *s)\n{\n    uint16_t start, off;\n    uint32_t csum;\n\n    start = (s->tx_first_ctl & TXDCTRL_CSTART) >> 15;\n    off = (s->tx_first_ctl & TXDCTRL_COFF) >> 21;\n\n    trace_sungem_tx_checksum(start, off);\n\n    if (start > (s->tx_size - 2) || off > (s->tx_size - 2)) {\n        trace_sungem_tx_checksum_oob();\n        return;\n    }\n\n    csum = net_raw_checksum(s->tx_data + start, s->tx_size - start);\n    stw_be_p(s->tx_data + off, csum);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":226265,"func":"\nvoid reftype_box_del(GF_Box *s)\n{\n\tGF_TrackReferenceTypeBox *ptr = (GF_TrackReferenceTypeBox *)s;\n\tif (!ptr) return;\n\tif (ptr->trackIDs) gf_free(ptr->trackIDs);\n\tgf_free(ptr);","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":373519,"func":"ipf_is_first_v4_frag(const struct dp_packet *pkt)\n{\n    const struct ip_header *l3 = dp_packet_l3(pkt);\n    if (!(l3->ip_frag_off & htons(IP_FRAG_OFF_MASK)) &&\n        l3->ip_frag_off & htons(IP_MORE_FRAGMENTS)) {\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":489161,"func":"static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\t\tvoid *arg,\n\t\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tunsigned len;\n\t__be16 error = SCTP_ERROR_NO_ERROR;\n\n\t\/* See if we have an error cause code in the chunk.  *\/\n\tlen = ntohs(chunk->chunk_hdr->length);\n\tif (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr))\n\t\terror = ((sctp_errhdr_t *)chunk->skb->data)->cause;\n\n\tsctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));\n\t\/* ASSOC_FAILED will DELETE_TCB. *\/\n\tsctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error));\n\tSCTP_INC_STATS(SCTP_MIB_ABORTEDS);\n\tSCTP_DEC_STATS(SCTP_MIB_CURRESTAB);\n\n\treturn SCTP_DISPOSITION_ABORT;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":294394,"func":"get_limit(VALUE opt)\n{\n    if (!NIL_P(opt)) {\n        VALUE limit = rb_hash_aref(opt, ID2SYM(rb_intern(\"limit\")));\n        if (NIL_P(limit)) return SIZE_MAX;\n        return NUM2SIZET(limit);\n    }\n    return 128;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":508839,"func":"bool st_select_lex::save_prep_leaf_tables(THD *thd)\n{\n  if (prep_leaf_list_state == SAVED)\n    return FALSE;\n\n  List_iterator_fast<TABLE_LIST> li(leaf_tables);\n  TABLE_LIST *table;\n\n  \/*\n    Check that the SELECT_LEX was really prepared and so tables are setup.\n\n    It can be subquery in SET clause of UPDATE which was not prepared yet, so\n    its tables are not yet setup and ready for storing.\n  *\/\n  if (prep_leaf_list_state != READY)\n    return FALSE;\n\n  while ((table= li++))\n  {\n    if (leaf_tables_prep.push_back(table))\n      return TRUE;\n  }\n  prep_leaf_list_state= SAVED;\n  for (SELECT_LEX_UNIT *u= first_inner_unit(); u; u= u->next_unit())\n  {\n    for (SELECT_LEX *sl= u->first_select(); sl; sl= sl->next_select())\n    {\n      if (sl->save_prep_leaf_tables(thd))\n        return TRUE;\n    }\n  }\n\n  return FALSE;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":508806,"func":"bool st_select_lex::is_merged_child_of(st_select_lex *ancestor)\n{\n  bool all_merged= TRUE;\n  for (SELECT_LEX *sl= this; sl && sl!=ancestor;\n       sl=sl->outer_select())\n  {\n    Item *subs= sl->master_unit()->item;\n    if (subs && subs->type() == Item::SUBSELECT_ITEM && \n        ((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS &&\n        ((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN))\n    {\n      continue;\n    }\n\n    if (sl->master_unit()->derived &&\n      sl->master_unit()->derived->is_merged_derived())\n    {\n      continue;\n    }\n    all_merged= FALSE;\n    break;\n  }\n  return all_merged;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":513175,"func":"static size_t var_storage_size(int flags)\n{\n  switch (flags & PLUGIN_VAR_TYPEMASK) {\n  case PLUGIN_VAR_BOOL:         return sizeof(my_bool);\n  case PLUGIN_VAR_INT:          return sizeof(int);\n  case PLUGIN_VAR_LONG:         return sizeof(long);\n  case PLUGIN_VAR_ENUM:         return sizeof(long);\n  case PLUGIN_VAR_LONGLONG:     return sizeof(ulonglong);\n  case PLUGIN_VAR_SET:          return sizeof(ulonglong);\n  case PLUGIN_VAR_STR:          return sizeof(char*);\n  case PLUGIN_VAR_DOUBLE:       return sizeof(double);\n  default: DBUG_ASSERT(0);      return 0;\n  }\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":376324,"func":"gpg_ctx_get_executable_name (void)\n{\n\tstatic gint index = -1;\n\tconst gchar *names[] = {\n\t\t\"gpg\",\n\t\t\"gpg2\",\n\t\tNULL\n\t};\n\n\tif (index == -1) {\n\t\tfor (index = 0; names[index]; index++) {\n\t\t\tgchar *path = g_find_program_in_path (names[index]);\n\n\t\t\tif (path) {\n\t\t\t\tg_free (path);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!names[index])\n\t\t\tindex = 0;\n\t}\n\n\treturn names[index];\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":253563,"func":"void close_cached_dir_lease(struct cached_fid *cfid)\n{\n\tmutex_lock(&cfid->fid_mutex);\n\tclose_cached_dir_lease_locked(cfid);\n\tmutex_unlock(&cfid->fid_mutex);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":254071,"func":"inline char * qs_k2v(const char * key, char * const * qs_kv, int qs_kv_size, int nth = 0)\n{\n    int i;\n    size_t key_len, skip;\n\n    key_len = strlen(key);\n\n#ifdef _qsSORTING\n\/\/ TODO: binary search for key in the sorted qs_kv\n#else  \/\/ _qsSORTING\n    for(i=0; i<qs_kv_size; i++)\n    {\n        \/\/ we rely on the unambiguous '=' to find the value in our k\/v pair\n        if ( qs_strncmp(key, qs_kv[i], key_len) == 0 )\n        {\n            skip = strcspn(qs_kv[i], \"=\");\n            if ( qs_kv[i][skip] == '=' )\n                skip++;\n            \/\/ return (zero-char value) ? ptr to trailing '\\0' : ptr to value\n            if(nth == 0)\n                return qs_kv[i] + skip;\n            else\n                --nth;\n        }\n    }\n#endif  \/\/ _qsSORTING\n\n    return nullptr;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":432218,"func":"void *cpu_physical_memory_map(AddressSpace *as, hwaddr addr,\n                              hwaddr *plen,\n                              bool is_write)\n{\n    return address_space_map(as, addr, plen, is_write,\n                             MEMTXATTRS_UNSPECIFIED);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":512651,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_cache_int>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":438655,"func":"static int rpmsg_remove_device(struct device *dev, void *data)\n{\n\tdevice_unregister(dev);\n\n\treturn 0;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":395077,"func":"update_prepare(void)\n{\n    cursor_off();\n    updating_screen = TRUE;\n#ifdef FEAT_GUI\n    \/\/ Remove the cursor before starting to do anything, because scrolling may\n    \/\/ make it difficult to redraw the text under it.\n    if (gui.in_use)\n\tgui_undraw_cursor();\n#endif\n#ifdef FEAT_SEARCH_EXTRA\n    start_search_hl();\n#endif\n#ifdef FEAT_PROP_POPUP\n    \/\/ Update popup_mask if needed.\n    may_update_popup_mask(must_redraw);\n#endif\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":242611,"func":"  explicit UnstageOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":474078,"func":"strhash(st_data_t arg)\n{\n    register const char *string = (const char *)arg;\n    register st_index_t hval = FNV1_32A_INIT;\n\n    \/*\n     * FNV-1a hash each octet in the buffer\n     *\/\n    while (*string) {\n\t\/* xor the bottom with the current octet *\/\n\thval ^= (unsigned int)*string++;\n\n\t\/* multiply by the 32 bit FNV magic prime mod 2^32 *\/\n\thval *= FNV_32_PRIME;\n    }\n    return hval;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":244032,"func":"GF_Err mhac_box_size(GF_Box *s)\n{\n\tGF_MHAConfigBox *ptr = (GF_MHAConfigBox *) s;\n\ts->size += 5;\n\tif (ptr->mha_config_size && ptr->mha_config) s->size += ptr->mha_config_size;\n\treturn GF_OK;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":513001,"func":"Item *Item_func_eq::negated_item(THD *thd) \/* a = b  ->  a != b *\/\n{\n  return new (thd->mem_root) Item_func_ne(thd, args[0], args[1]);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":486831,"func":"static inline unsigned rx_desc_get_wrap(uint32_t *desc)\n{\n    return desc[0] & DESC_0_RX_WRAP ? 1 : 0;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":393501,"func":"static SQInteger table_map(HSQUIRRELVM v)\n{\n\tSQObject &o = stack_get(v, 1);\n\tSQTable *tbl = _table(o);\n\tSQInteger nitr, n = 0;\n\tSQInteger nitems = tbl->CountUsed();\n\tSQObjectPtr ret = SQArray::Create(_ss(v), nitems);\n\tSQObjectPtr itr, key, val;\n\twhile ((nitr = tbl->Next(false, itr, key, val)) != -1) {\n\t\titr = (SQInteger)nitr;\n\n\t\tv->Push(o);\n\t\tv->Push(key);\n\t\tv->Push(val);\n\t\tif (SQ_FAILED(sq_call(v, 3, SQTrue, SQFalse))) {\n\t\t\treturn SQ_ERROR;\n\t\t}\n\t\t_array(ret)->Set(n, v->GetUp(-1));\n\t\tv->Pop();\n\t\tn++;\n\t}\n\n\tv->Push(ret);\n\treturn 1;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":286724,"func":"TPM_RESULT SWTPM_NVRAM_Init(void)\n{\n    const char  *backend_uri;\n    TPM_RESULT  rc = 0;\n    TPM_DEBUG(\" SWTPM_NVRAM_Init:\\n\");\n\n    backend_uri = tpmstate_get_backend_uri();\n    if (!backend_uri) {\n        logprintf(STDERR_FILENO,\n                  \"SWTPM_NVRAM_Init: Missing backend URI.\\n\");\n        rc = TPM_FAIL;\n    } else if (strncmp(backend_uri, \"dir:\/\/\", 6) == 0) {\n        g_nvram_backend_ops = &nvram_dir_ops;\n    } else if (strncmp(backend_uri, \"file:\/\/\", 7) == 0) {\n        g_nvram_backend_ops = &nvram_linear_ops;\n    } else {\n        logprintf(STDERR_FILENO,\n                  \"SWTPM_NVRAM_Init: Unsupported backend.\\n\");\n        rc = TPM_FAIL;\n    }\n\n    if (rc == 0)\n        rc = g_nvram_backend_ops->prepare(backend_uri);\n\n    return rc;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":225968,"func":"\nGF_Err proj_type_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ProjectionTypeBox *ptr = (GF_ProjectionTypeBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tif (ptr->type==GF_ISOM_BOX_TYPE_CBMP) {\n\t\tgf_bs_write_u32(bs, ptr->layout);\n\t\tgf_bs_write_u32(bs, ptr->padding);\n\t}\n\telse if (ptr->type==GF_ISOM_BOX_TYPE_EQUI) {\n\t\tgf_bs_write_u32(bs, ptr->bounds_top);\n\t\tgf_bs_write_u32(bs, ptr->bounds_bottom);\n\t\tgf_bs_write_u32(bs, ptr->bounds_left);\n\t\tgf_bs_write_u32(bs, ptr->bounds_right);\n\t} else {\n\t\tgf_bs_write_u32(bs, ptr->crc);\n\t\tgf_bs_write_u32(bs, ptr->encoding_4cc);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":231024,"func":"    static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue )\r\n    {\r\n        UBaseType_t uxHighestPriorityOfWaitingTasks;\r\n\r\n        \/* If a task waiting for a mutex causes the mutex holder to inherit a\r\n         * priority, but the waiting task times out, then the holder should\r\n         * disinherit the priority - but only down to the highest priority of any\r\n         * other tasks that are waiting for the same mutex.  For this purpose,\r\n         * return the priority of the highest priority task that is waiting for the\r\n         * mutex. *\/\r\n        if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U )\r\n        {\r\n            uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );\r\n        }\r\n        else\r\n        {\r\n            uxHighestPriorityOfWaitingTasks = tskIDLE_PRIORITY;\r\n        }\r\n\r\n        return uxHighestPriorityOfWaitingTasks;\r\n    }\r","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":226432,"func":"  const std::vector<PartialTensorShape>& output_shapes() const override {\n    return shapes_;\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":398509,"func":"RZ_API const char *rz_bin_dwarf_get_tag_name(ut64 tag) {\n\tif (tag >= DW_TAG_LAST) {\n\t\treturn NULL;\n\t}\n\treturn dwarf_tag_name_encodings[tag];\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":486812,"func":"static inline uint32_t gem_get_tx_queue_base_addr(CadenceGEMState *s, int q)\n{\n    return gem_get_queue_base_addr(s, true, q);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":459204,"func":"static void tcf_block_flush_all_chains(struct tcf_block *block, bool rtnl_held)\n{\n\tstruct tcf_chain *chain;\n\n\t\/* Last reference to block. At this point chains cannot be added or\n\t * removed concurrently.\n\t *\/\n\tfor (chain = tcf_get_next_chain(block, NULL);\n\t     chain;\n\t     chain = tcf_get_next_chain(block, chain)) {\n\t\ttcf_chain_put_explicitly_created(chain);\n\t\ttcf_chain_flush(chain, rtnl_held);\n\t}\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":450353,"func":"static int send_sub_rect_nojpeg(VncState *vs, int x, int y, int w, int h,\n                                int bg, int fg, int colors, VncPalette *palette)\n{\n    int ret;\n\n    if (colors == 0) {\n        if (tight_detect_smooth_image(vs, w, h)) {\n            ret = send_gradient_rect(vs, x, y, w, h);\n        } else {\n            ret = send_full_color_rect(vs, x, y, w, h);\n        }\n    } else if (colors == 1) {\n        ret = send_solid_rect(vs);\n    } else if (colors == 2) {\n        ret = send_mono_rect(vs, x, y, w, h, bg, fg);\n    } else if (colors <= 256) {\n        ret = send_palette_rect(vs, x, y, w, h, palette);\n    } else {\n        ret = 0;\n    }\n    return ret;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":90121,"func":"  virtual void ConnectToWifiNetwork(ConnectionSecurity security,\n                                    const std::string& ssid,\n                                    const std::string& password,\n                                    const std::string& identity,\n                                    const std::string& certpath,\n                                    bool auto_connect) {}\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":459208,"func":"struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, u32 chain_index)\n{\n\treturn __tcf_chain_get(block, chain_index, true, true);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":230387,"func":"PJ_DEF(pj_xml_node*) pj_xml_find_node(const pj_xml_node *parent, \n\t\t\t\t      const pj_str_t *name)\n{\n    const pj_xml_node *node = parent->node_head.next;\n\n    PJ_CHECK_STACK();\n\n    while (node != (void*)&parent->node_head) {\n\tif (pj_stricmp(&node->name, name) == 0)\n\t    return (pj_xml_node*)node;\n\tnode = node->next;\n    }\n    return NULL;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":308198,"func":"static void fastrpc_notify_users(struct fastrpc_user *user)\n{\n\tstruct fastrpc_invoke_ctx *ctx;\n\n\tspin_lock(&user->lock);\n\tlist_for_each_entry(ctx, &user->pending, node)\n\t\tcomplete(&ctx->work);\n\tspin_unlock(&user->lock);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":512784,"func":"  Item_direct_ref_to_ident(THD *thd, Item_ident *item):\n    Item_direct_ref(thd, item->context, (Item**)&item, item->table_name,\n                    &item->field_name, FALSE)\n  {\n    ident= item;\n    ref= (Item**)&ident;\n  }","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":281057,"func":"static bool xfrm_policy_mark_match(struct xfrm_policy *policy,\n\t\t\t\t   struct xfrm_policy *pol)\n{\n\tu32 mark = policy->mark.v & policy->mark.m;\n\n\tif (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m)\n\t\treturn true;\n\n\tif ((mark & pol->mark.m) == pol->mark.v &&\n\t    policy->priority == pol->priority)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":369187,"func":"static inline unsigned int io_put_kbuf_comp(struct io_kiocb *req)\n{\n\tlockdep_assert_held(&req->ctx->completion_lock);\n\n\tif (likely(!(req->flags & REQ_F_BUFFER_SELECTED)))\n\t\treturn 0;\n\treturn __io_put_kbuf(req, &req->ctx->io_buffers_comp);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":439145,"func":"ModuleExport size_t RegisterIPLImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=SetMagickInfo(\"IPL\");\n  entry->decoder=(DecodeImageHandler *) ReadIPLImage;\n  entry->encoder=(EncodeImageHandler *) WriteIPLImage;\n  entry->magick=(IsImageFormatHandler *) IsIPL;\n  entry->adjoin=MagickTrue;\n  entry->description=ConstantString(\"IPL Image Sequence\");\n  entry->module=ConstantString(\"IPL\");\n  entry->endian_support=MagickTrue;\n  entry->seekable_stream=MagickTrue;\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":369160,"func":"static int io_sync_file_range(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tint ret;\n\n\t\/* sync_file_range always requires a blocking context *\/\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tret = sync_file_range(req->file, req->sync.off, req->sync.len,\n\t\t\t\treq->sync.flags);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":238777,"func":"last_csearch(void)\n{\n    return lastc_bytes;\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":242121,"func":"int LuaSettings::l_set(lua_State* L)\n{\n\tNO_MAP_LOCK_REQUIRED;\n\tLuaSettings* o = checkobject(L, 1);\n\n\tstd::string key = std::string(luaL_checkstring(L, 2));\n\tconst char* value = luaL_checkstring(L, 3);\n\n\tCHECK_SETTING_SECURITY(L, key);\n\n\tif (!o->m_settings->set(key, value))\n\t\tthrow LuaError(\"Invalid sequence found in setting parameters\");\n\n\treturn 0;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":336596,"func":"SPICE_GNUC_VISIBLE int spice_server_migrate_switch(SpiceServer *reds)\n{\n    spice_debug(\"trace\");\n    if (reds->clients.empty()) {\n       return 0;\n    }\n    reds->expect_migrate = FALSE;\n    if (!reds->config->mig_spice) {\n        spice_warning(\"spice_server_migrate_switch called without migrate_info set\");\n        return 0;\n    }\n    reds->main_channel->migrate_switch(reds->config->mig_spice);\n    reds_mig_release(reds->config);\n    return 0;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":318962,"func":"ga_concat_shorten_esc(garray_T *gap, char_u *str)\n{\n    char_u  *p;\n    char_u  *s;\n    int\t    c;\n    int\t    clen;\n    char_u  buf[NUMBUFLEN];\n    int\t    same_len;\n\n    if (str == NULL)\n    {\n\tga_concat(gap, (char_u *)\"NULL\");\n\treturn;\n    }\n\n    for (p = str; *p != NUL; ++p)\n    {\n\tsame_len = 1;\n\ts = p;\n\tc = mb_cptr2char_adv(&s);\n\tclen = s - p;\n\twhile (*s != NUL && c == mb_ptr2char(s))\n\t{\n\t    ++same_len;\n\t    s += clen;\n\t}\n\tif (same_len > 20)\n\t{\n\t    ga_concat(gap, (char_u *)\"\\\\[\");\n\t    ga_concat_esc(gap, p, clen);\n\t    ga_concat(gap, (char_u *)\" occurs \");\n\t    vim_snprintf((char *)buf, NUMBUFLEN, \"%d\", same_len);\n\t    ga_concat(gap, buf);\n\t    ga_concat(gap, (char_u *)\" times]\");\n\t    p = s - 1;\n\t}\n\telse\n\t    ga_concat_esc(gap, p, clen);\n    }\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":483515,"func":"int __init efi_config_init(efi_config_table_type_t *arch_tables)\n{\n\tvoid *config_tables;\n\tint sz, ret;\n\n\tif (efi.systab->nr_tables == 0)\n\t\treturn 0;\n\n\tif (efi_enabled(EFI_64BIT))\n\t\tsz = sizeof(efi_config_table_64_t);\n\telse\n\t\tsz = sizeof(efi_config_table_32_t);\n\n\t\/*\n\t * Let's see what config tables the firmware passed to us.\n\t *\/\n\tconfig_tables = early_memremap(efi.systab->tables,\n\t\t\t\t       efi.systab->nr_tables * sz);\n\tif (config_tables == NULL) {\n\t\tpr_err(\"Could not map Configuration table!\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\tret = efi_config_parse_tables(config_tables, efi.systab->nr_tables, sz,\n\t\t\t\t      arch_tables);\n\n\tearly_memunmap(config_tables, efi.systab->nr_tables * sz);\n\treturn ret;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":512404,"func":"  Item_string(THD *thd, const char *str, uint length, CHARSET_INFO *cs,\n              Derivation dv, uint repertoire)\n   :Item_literal(thd)\n  {\n    str_value.set_or_copy_aligned(str, length, cs);\n    fix_and_set_name_from_value(thd, dv, Metadata(&str_value, repertoire));\n  }","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":301367,"func":"static struct tevent_req *vfswrap_fsync_send(struct vfs_handle_struct *handle,\n\t\t\t\t\t     TALLOC_CTX *mem_ctx,\n\t\t\t\t\t     struct tevent_context *ev,\n\t\t\t\t\t     struct files_struct *fsp)\n{\n\tstruct tevent_req *req;\n\tstruct vfswrap_asys_state *state;\n\tint ret;\n\n\treq = tevent_req_create(mem_ctx, &state, struct vfswrap_asys_state);\n\tif (req == NULL) {\n\t\treturn NULL;\n\t}\n\tif (!vfswrap_init_asys_ctx(handle->conn->sconn->conn)) {\n\t\ttevent_req_oom(req);\n\t\treturn tevent_req_post(req, ev);\n\t}\n\tstate->asys_ctx = handle->conn->sconn->conn->asys_ctx;\n\tstate->req = req;\n\n\tret = asys_fsync(state->asys_ctx, fsp->fh->fd, req);\n\tif (ret != 0) {\n\t\ttevent_req_error(req, ret);\n\t\treturn tevent_req_post(req, ev);\n\t}\n\ttalloc_set_destructor(state, vfswrap_asys_state_destructor);\n\n\treturn req;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":432223,"func":"static FlatRange *flatview_lookup(FlatView *view, AddrRange addr)\n{\n    return bsearch(&addr, view->ranges, view->nr,\n                   sizeof(FlatRange), cmp_flatrange_addr);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":512715,"func":"Item_bool_rowready_func2::value_depends_on_sql_mode() const\n{\n  if (compare_collation()->state & MY_CS_NOPAD)\n    return Item_func::value_depends_on_sql_mode();\n  return ((args[0]->value_depends_on_sql_mode() |\n           args[1]->value_depends_on_sql_mode()) &\n          Sql_mode_dependency(~0, ~MODE_PAD_CHAR_TO_FULL_LENGTH)).\n         soft_to_hard();\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":301426,"func":"static int vfswrap_closedir(vfs_handle_struct *handle, DIR *dirp)\n{\n\tint result;\n\n\tSTART_PROFILE(syscall_closedir);\n\tresult = closedir(dirp);\n\tEND_PROFILE(syscall_closedir);\n\treturn result;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":241066,"func":"void list_peers(int fd)\n{\n\tchar *data;\n\tunsigned int olen;\n\tstruct boothc_hdr_msg hdr;\n\n\tif (format_peers(&data, &olen) < 0)\n\t\tgoto out;\n\n\tinit_header(&hdr.header, CL_LIST, 0, 0, RLT_SUCCESS, 0, sizeof(hdr) + olen);\n\t(void)send_header_plus(fd, &hdr, data, olen);\n\nout:\n\tif (data)\n\t\tfree(data);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":366254,"func":"static inline struct hlist_head *m_hash(struct vfsmount *mnt, struct dentry *dentry)\n{\n\tunsigned long tmp = ((unsigned long)mnt \/ L1_CACHE_BYTES);\n\ttmp += ((unsigned long)dentry \/ L1_CACHE_BYTES);\n\ttmp = tmp + (tmp >> m_hash_shift);\n\treturn &mount_hashtable[tmp & m_hash_mask];\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":283742,"func":"static void zynq_slcr_compute_clocks(ZynqSLCRState *s)\n{\n    uint64_t ps_clk = clock_get(s->ps_clk);\n\n    \/* consider outputs clocks are disabled while in reset *\/\n    if (device_is_in_reset(DEVICE(s))) {\n        ps_clk = 0;\n    }\n\n    uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]);\n    uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]);\n    uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]);\n\n    uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll};\n\n    \/* compute uartX reference clocks *\/\n    clock_set(s->uart0_ref_clk,\n              ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0));\n    clock_set(s->uart1_ref_clk,\n              ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1));\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":344748,"func":"argv_next(int *argcp, char ***argvp)\n{\n\tchar *ret = (*argvp)[0];\n\n\tif (*argcp > 0 && ret != NULL) {\n\t\t(*argcp)--;\n\t\t(*argvp)++;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":244148,"func":"GF_Err udta_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_UserDataMap *map;\n\tGF_UserDataBox *ptr = (GF_UserDataBox *)s;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\ti=0;\n\twhile ((map = (GF_UserDataMap *)gf_list_enum(ptr->recordList, &i))) {\n\t\t\/\/warning: here we are not passing the actual \"parent\" of the list\n\t\t\/\/but the UDTA box. The parent itself is not an box, we don't care about it\n\t\te = gf_isom_box_array_write(s, map->boxes, bs);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":369221,"func":"static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n{\n\tstruct open_how __user *how;\n\tsize_t len;\n\tint ret;\n\n\thow = u64_to_user_ptr(READ_ONCE(sqe->addr2));\n\tlen = READ_ONCE(sqe->len);\n\tif (len < OPEN_HOW_SIZE_VER0)\n\t\treturn -EINVAL;\n\n\tret = copy_struct_from_user(&req->open.how, sizeof(req->open.how), how,\n\t\t\t\t\tlen);\n\tif (ret)\n\t\treturn ret;\n\n\treturn __io_openat_prep(req, sqe);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":90868,"func":"  void SetPersistentHostQuota(const std::string& host, int64 new_quota) {\n    quota_status_ = kQuotaStatusUnknown;\n    host_.clear();\n    type_ = kStorageTypeUnknown;\n    quota_ = -1;\n    quota_manager_->SetPersistentHostQuota(host, new_quota,\n        callback_factory_.NewCallback(\n            &QuotaManagerTest::DidGetHostQuota));\n  }\n","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":313810,"func":"nv_operator(cmdarg_T *cap)\n{\n    int\t    op_type;\n\n    op_type = get_op_type(cap->cmdchar, cap->nchar);\n#ifdef FEAT_JOB_CHANNEL\n    if (bt_prompt(curbuf) && op_is_change(op_type) && !prompt_curpos_editable())\n    {\n\tclearopbeep(cap->oap);\n\treturn;\n    }\n#endif\n\n    if (op_type == cap->oap->op_type)\t    \/\/ double operator works on lines\n\tnv_lineop(cap);\n    else if (!checkclearop(cap->oap))\n    {\n\tcap->oap->start = curwin->w_cursor;\n\tcap->oap->op_type = op_type;\n#ifdef FEAT_EVAL\n\tset_op_var(op_type);\n#endif\n    }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":225987,"func":"GF_Err stsd_box_size(GF_Box *s)\n{\n\tGF_SampleDescriptionBox *ptr = (GF_SampleDescriptionBox *)s;\n\tptr->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":218965,"func":"ConstantFolding::ConstantFolding(DeviceBase* cpu_device,\n                                 bool disable_compressed_tensor_optimization,\n                                 bool fold_quantization_ops)\n    : ConstantFolding(RewriterConfig::ON, cpu_device,\n                      disable_compressed_tensor_optimization,\n                      fold_quantization_ops) {}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":398522,"func":"static int init_comp_unit(RzBinDwarfCompUnit *cu) {\n\tif (!cu) {\n\t\treturn -EINVAL;\n\t}\n\tcu->dies = calloc(sizeof(RzBinDwarfDie), COMP_UNIT_CAPACITY);\n\tif (!cu->dies) {\n\t\treturn -ENOMEM;\n\t}\n\tcu->capacity = COMP_UNIT_CAPACITY;\n\tcu->count = 0;\n\treturn 0;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":212407,"func":"http_isfiltered(const struct http *fm, unsigned u, unsigned how)\n{\n\tconst char *e;\n\tconst struct http_hdrflg *f;\n\n\tif (fm->hdf[u] & HDF_FILTER)\n\t\treturn (1);\n\te = strchr(fm->hd[u].b, ':');\n\tif (e == NULL)\n\t\treturn (0);\n\tf = http_hdr_flags(fm->hd[u].b, e);\n\treturn (f != NULL && f->flag & how);\n}","target":1,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":317060,"func":"static int selinux_socket_post_create(struct socket *sock, int family,\n\t\t\t\t      int type, int protocol, int kern)\n{\n\tconst struct task_security_struct *tsec = selinux_cred(current_cred());\n\tstruct inode_security_struct *isec = inode_security_novalidate(SOCK_INODE(sock));\n\tstruct sk_security_struct *sksec;\n\tu16 sclass = socket_type_to_security_class(family, type, protocol);\n\tu32 sid = SECINITSID_KERNEL;\n\tint err = 0;\n\n\tif (!kern) {\n\t\terr = socket_sockcreate_sid(tsec, sclass, &sid);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\tisec->sclass = sclass;\n\tisec->sid = sid;\n\tisec->initialized = LABEL_INITIALIZED;\n\n\tif (sock->sk) {\n\t\tsksec = sock->sk->sk_security;\n\t\tsksec->sclass = sclass;\n\t\tsksec->sid = sid;\n\t\t\/* Allows detection of the first association on this socket *\/\n\t\tif (sksec->sclass == SECCLASS_SCTP_SOCKET)\n\t\t\tsksec->sctp_assoc_state = SCTP_ASSOC_UNSET;\n\n\t\terr = selinux_netlbl_socket_post_create(sock->sk, family);\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":229247,"func":"static inline cql_server::result_with_foreign_response_ptr convert_error_message_to_coordinator_result(messages::result_message* msg) {\n    return std::move(*dynamic_cast<messages::result_message::exception*>(msg)).get_exception();\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":224464,"func":"static GF_Err txtin_process(GF_Filter *filter)\n{\n\tGF_TXTIn *ctx = gf_filter_get_udta(filter);\n\tGF_FilterPacket *pck;\n\tGF_Err e;\n\tBool start, end;\n\tpck = gf_filter_pid_get_packet(ctx->ipid);\n\tif (!pck) {\n\t\treturn GF_OK;\n\t}\n\tgf_filter_pck_get_framing(pck, &start, &end);\n\tif (!end) {\n\t\tgf_filter_pid_drop_packet(ctx->ipid);\n\t\treturn GF_OK;\n\t}\n\t\/\/file is loaded\n\n\te = ctx->text_process(filter, ctx);\n\n\n\tif (e==GF_EOS) {\n\t\t\/\/keep input alive until end of stream, so that we keep getting called\n\t\tgf_filter_pid_drop_packet(ctx->ipid);\n\t\tif (gf_filter_pid_is_eos(ctx->ipid))\n\t\t\tgf_filter_pid_set_eos(ctx->opid);\n\t}\n\treturn e;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":359597,"func":"peer_weight_unset_vty (struct vty *vty, const char *ip_str)\n{\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  peer_weight_unset (peer);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":245143,"func":"void Examples::RandomShuffle() {\n  std::iota(sampled_index_.begin(), sampled_index_.end(), 0);\n\n  std::random_device rd;\n  std::mt19937 rng(rd());\n  std::shuffle(sampled_index_.begin(), sampled_index_.end(), rng);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":247112,"func":"GF_Filter *gf_fs_load_destination(GF_FilterSession *fsess, const char *url, const char *args, const char *parent_url, GF_Err *err)\n{\n\treturn gf_fs_load_source_dest_internal(fsess, url, args, parent_url, err, NULL, NULL, GF_FALSE, GF_FALSE, NULL);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":210050,"func":"static void singlevar (LexState *ls, expdesc *var) {\n  TString *varname = str_checkname(ls);\n  FuncState *fs = ls->fs;\n  singlevaraux(fs, varname, var, 1);\n  if (var->k == VVOID) {  \/* global name? *\/\n    expdesc key;\n    singlevaraux(fs, ls->envn, var, 1);  \/* get environment variable *\/\n    lua_assert(var->k != VVOID);  \/* this one must exist *\/\n    codestring(&key, varname);  \/* key is variable name *\/\n    luaK_indexed(fs, var, &key);  \/* env[varname] *\/\n  }\n}","target":1,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":318965,"func":"assert_equal_common(typval_T *argvars, assert_type_T atype)\n{\n    garray_T\tga;\n\n    if (tv_equal(&argvars[0], &argvars[1], FALSE, FALSE)\n\t\t\t\t\t\t   != (atype == ASSERT_EQUAL))\n    {\n\tprepare_assert_error(&ga);\n\tfill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1],\n\t\t\t\t\t\t\t\t       atype);\n\tassert_error(&ga);\n\tga_clear(&ga);\n\treturn 1;\n    }\n    return 0;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":240615,"func":"  explicit ResourceGatherOp(OpKernelConstruction* c) : OpKernel(c) {\n    OP_REQUIRES_OK(c, c->GetAttr(\"batch_dims\", &batch_dims_));\n  }","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":503881,"func":"is_file_name_separator (SCM c)\n{\n  if (scm_is_eq (c, SCM_MAKE_CHAR ('\/')))\n    return 1;\n#ifdef __MINGW32__\n  if (scm_is_eq (c, SCM_MAKE_CHAR ('\\\\')))\n    return 1;\n#endif\n  return 0;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":390550,"func":"_GetCountedString(char **wire_inout,Bool swap)\n{\nchar *\twire,*str;\nCARD16\tlen,*plen;\n\n    wire= *wire_inout;\n    plen= (CARD16 *)wire;\n    if (swap) {\n\tregister int n;\n\tswaps(plen,n);\n    }\n    len= *plen;\n    str= (char *)_XkbAlloc(len+1);\n    if (str) {\n\tmemcpy(str,&wire[2],len);\n\tstr[len]= '\\0';\n    }\n    wire+= XkbPaddedSize(len+2);\n    *wire_inout= wire;\n    return str;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":473970,"func":"big5_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)\n{\n  return onigenc_mbn_mbc_to_code(enc, p, end);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":486824,"func":"static void gem_phy_write(CadenceGEMState *s, unsigned reg_num, uint16_t val)\n{\n    DB_PRINT(\"reg: %d value: 0x%04x\\n\", reg_num, val);\n\n    switch (reg_num) {\n    case PHY_REG_CONTROL:\n        if (val & PHY_REG_CONTROL_RST) {\n            \/* Phy reset *\/\n            gem_phy_reset(s);\n            val &= ~(PHY_REG_CONTROL_RST | PHY_REG_CONTROL_LOOP);\n            s->phy_loop = 0;\n        }\n        if (val & PHY_REG_CONTROL_ANEG) {\n            \/* Complete autonegotiation immediately *\/\n            val &= ~(PHY_REG_CONTROL_ANEG | PHY_REG_CONTROL_ANRESTART);\n            s->phy_regs[PHY_REG_STATUS] |= PHY_REG_STATUS_ANEGCMPL;\n        }\n        if (val & PHY_REG_CONTROL_LOOP) {\n            DB_PRINT(\"PHY placed in loopback\\n\");\n            s->phy_loop = 1;\n        } else {\n            s->phy_loop = 0;\n        }\n        break;\n    }\n    s->phy_regs[reg_num] = val;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":398547,"func":"static int expand_cu(RzBinDwarfCompUnit *cu) {\n\tRzBinDwarfDie *tmp;\n\n\tif (!cu || cu->capacity == 0 || cu->capacity != cu->count) {\n\t\treturn -EINVAL;\n\t}\n\n\ttmp = (RzBinDwarfDie *)realloc(cu->dies,\n\t\tcu->capacity * 2 * sizeof(RzBinDwarfDie));\n\tif (!tmp) {\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset((ut8 *)tmp + cu->capacity * sizeof(RzBinDwarfDie),\n\t\t0, cu->capacity * sizeof(RzBinDwarfDie));\n\tcu->dies = tmp;\n\tcu->capacity *= 2;\n\n\treturn 0;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":503849,"func":"SCM_DEFINE (scm_symlink, \"symlink\", 2, 0, 0,\n            (SCM oldpath, SCM newpath),\n\t    \"Create a symbolic link named @var{newpath} with the value\\n\"\n\t    \"(i.e., pointing to) @var{oldpath}.  The return value is\\n\"\n\t    \"unspecified.\")\n#define FUNC_NAME s_scm_symlink\n{\n  int val;\n\n  STRING2_SYSCALL (oldpath, c_oldpath,\n\t\t   newpath, c_newpath,\n\t\t   val = symlink (c_oldpath, c_newpath));\n  if (val != 0)\n    SCM_SYSERROR;\n  return SCM_UNSPECIFIED;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":413706,"func":"static int fcnlist_gather_metadata(RAnal *anal, RList *fcns) {\n\tRListIter *iter;\n\tRAnalFunction *fcn;\n\tRList *xrefs;\n\n\tr_list_foreach (fcns, iter, fcn) {\n\t\t\/\/ Count the number of references and number of calls\n\t\tRListIter *callrefiter;\n\t\tRAnalRef *ref;\n\t\tRList *refs = r_anal_function_get_refs (fcn);\n\t\tint numcallrefs = 0;\n\t\tr_list_foreach (refs, callrefiter, ref) {\n\t\t\tif (ref->type == R_ANAL_REF_TYPE_CALL) {\n\t\t\t\tnumcallrefs++;\n\t\t\t}\n\t\t}\n\t\tr_list_free (refs);\n\t\tfcn->meta.numcallrefs = numcallrefs;\n\t\txrefs = r_anal_xrefs_get (anal, fcn->addr);\n\t\tfcn->meta.numrefs = xrefs? xrefs->length: 0;\n\t\tr_list_free (xrefs);\n\t}\n\t\/\/ TODO: Determine sgnc, sgec\n\treturn 0;\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":326640,"func":"clear_nochange_fflags(struct archive_write_disk *a)\n{\n\tmode_t\t\tmode = archive_entry_mode(a->entry);\n\tconst int nochange_flags = 0\n#ifdef SF_IMMUTABLE\n\t    | SF_IMMUTABLE\n#endif\n#ifdef UF_IMMUTABLE\n\t    | UF_IMMUTABLE\n#endif\n#ifdef SF_APPEND\n\t    | SF_APPEND\n#endif\n#ifdef UF_APPEND\n\t    | UF_APPEND\n#endif\n#ifdef EXT2_APPEND_FL\n\t    | EXT2_APPEND_FL\n#endif\n#ifdef EXT2_IMMUTABLE_FL\n\t    | EXT2_IMMUTABLE_FL\n#endif\n\t;\n\n\treturn (set_fflags_platform(a, a->fd, a->name, mode, 0,\n\t    nochange_flags));\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":220814,"func":"Integer CeilQuotient(Integer a, Integer b) {\n  return (a + b - 1) \/ b;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":274864,"func":"  void ConfigureBuiltinOp(BuiltinOperator op) {\n    switch (op) {\n      case BuiltinOperator_EQUAL: {\n        SetBuiltinOp(op, BuiltinOptions_EqualOptions,\n                     CreateEqualOptions(builder_).Union());\n        break;\n      }\n      case BuiltinOperator_NOT_EQUAL: {\n        SetBuiltinOp(op, BuiltinOptions_NotEqualOptions,\n                     CreateNotEqualOptions(builder_).Union());\n        break;\n      }\n      case BuiltinOperator_GREATER: {\n        SetBuiltinOp(op, BuiltinOptions_GreaterOptions,\n                     CreateGreaterOptions(builder_).Union());\n        break;\n      }\n      case BuiltinOperator_GREATER_EQUAL: {\n        SetBuiltinOp(op, BuiltinOptions_GreaterEqualOptions,\n                     CreateGreaterEqualOptions(builder_).Union());\n        break;\n      }\n      case BuiltinOperator_LESS: {\n        SetBuiltinOp(op, BuiltinOptions_LessOptions,\n                     CreateLessOptions(builder_).Union());\n        break;\n      }\n      case BuiltinOperator_LESS_EQUAL: {\n        SetBuiltinOp(op, BuiltinOptions_LessEqualOptions,\n                     CreateLessEqualOptions(builder_).Union());\n        break;\n      }\n      default: { FAIL() << \"We shouldn't get here.\"; }\n    }\n  }","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":382784,"func":"gdIOCtx * gdNewDynamicCtxEx (int initialSize, void *data, int freeOKFlag)\n{\n\tdpIOCtx *ctx;\n\tdynamicPtr *dp;\n\n\tctx = (dpIOCtx *) gdMalloc (sizeof (dpIOCtx));\n\n\tdp = newDynamic(initialSize, data, freeOKFlag);\n\n\tctx->dp = dp;\n\n\tctx->ctx.getC = dynamicGetchar;\n\tctx->ctx.putC = dynamicPutchar;\n\n\tctx->ctx.getBuf = dynamicGetbuf;\n\tctx->ctx.putBuf = dynamicPutbuf;\n\n\tctx->ctx.seek = dynamicSeek;\n\tctx->ctx.tell = dynamicTell;\n\n\tctx->ctx.gd_free = gdFreeDynamicCtx;\n\n\treturn (gdIOCtx *) ctx;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":234209,"func":"add_abbrev (unsigned long  number,\n\t    unsigned long  tag,\n\t    int            children,\n\t    abbrev_list *  list)\n{\n  abbrev_entry *  entry;\n\n  entry = (abbrev_entry *) xmalloc (sizeof (*entry));\n\n  entry->number     = number;\n  entry->tag        = tag;\n  entry->children   = children;\n  entry->first_attr = NULL;\n  entry->last_attr  = NULL;\n  entry->next       = NULL;\n\n  assert (list != NULL);\n\n  if (list->first_abbrev == NULL)\n    list->first_abbrev = entry;\n  else\n    list->last_abbrev->next = entry;\n\n  list->last_abbrev = entry;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":273070,"func":"ringbuffer_write(struct ringbuffer *buf, const void* src, size_t srclen)\n{\n  int remaining;\n\n  if (buf->write_avail == 0 || srclen == 0)\n    return 0;\n\n  if (srclen > buf->write_avail)\n   srclen = buf->write_avail;\n\n  remaining = buf->size - buf->write_pos;\n  if (srclen > remaining)\n    {\n      memcpy(buf->buffer + buf->write_pos, src, remaining);\n      memcpy(buf->buffer, src + remaining, srclen - remaining);\n    }\n  else\n    {\n      memcpy(buf->buffer + buf->write_pos, src, srclen);\n    }\n\n  buf->write_pos = (buf->write_pos + srclen) % buf->size;\n\n  buf->write_avail -= srclen;\n  buf->read_avail += srclen;\n\n  return srclen;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":313791,"func":"nv_put(cmdarg_T *cap)\n{\n    nv_put_opt(cap, FALSE);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":401525,"func":"void update_process_times(int user_tick)\n{\n\tstruct task_struct *p = current;\n\n\t\/* Note: this timer irq context must be accounted for as well. *\/\n\taccount_process_tick(p, user_tick);\n\trun_local_timers();\n\trcu_sched_clock_irq(user_tick);\n#ifdef CONFIG_IRQ_WORK\n\tif (in_irq())\n\t\tirq_work_tick();\n#endif\n\tscheduler_tick();\n\tif (IS_ENABLED(CONFIG_POSIX_TIMERS))\n\t\trun_posix_cpu_timers();\n\n\t\/* The current CPU might make use of net randoms without receiving IRQs\n\t * to renew them often enough. Let's update the net_rand_state from a\n\t * non-constant value that's not affine to the number of calls to make\n\t * sure it's updated when there's some activity (we don't care in idle).\n\t *\/\n\tthis_cpu_add(net_rand_state.s1, rol32(jiffies, 24) + user_tick);\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":253601,"func":"smb2_get_credits(struct mid_q_entry *mid)\n{\n\treturn mid->credits_received;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":328918,"func":"R_API RBinJavaAttrInfo *r_bin_java_annotation_default_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 0;\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr && sz >= offset) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_ANNOTATION_DEFAULT_ATTR;\n\t\tattr->info.annotation_default_attr.default_value = r_bin_java_element_value_new (buffer + offset, sz - offset, buf_offset + offset);\n\t\tif (attr->info.annotation_default_attr.default_value) {\n\t\t\toffset += attr->info.annotation_default_attr.default_value->size;\n\t\t}\n\t}\n\tr_bin_java_print_annotation_default_attr_summary (attr);\n\treturn attr;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":269303,"func":"static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){\n    SnowContext *s = c->avctx->priv_data;\n    const int offset[3]= {\n          y*c->  stride + x,\n        ((y*c->uvstride + x)>>s->chroma_h_shift),\n        ((y*c->uvstride + x)>>s->chroma_h_shift),\n    };\n    int i;\n    for(i=0; i<3; i++){\n        c->src[0][i]= src [i];\n        c->ref[0][i]= ref [i] + offset[i];\n    }\n    av_assert2(!ref_index);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":468377,"func":"g_socket_client_connect_to_host_async (GSocketClient        *client,\n\t\t\t\t       const gchar          *host_and_port,\n\t\t\t\t       guint16               default_port,\n\t\t\t\t       GCancellable         *cancellable,\n\t\t\t\t       GAsyncReadyCallback   callback,\n\t\t\t\t       gpointer              user_data)\n{\n  GSocketConnectable *connectable;\n  GError *error;\n\n  error = NULL;\n  connectable = g_network_address_parse (host_and_port, default_port,\n\t\t\t\t\t &error);\n  if (connectable == NULL)\n    {\n      g_task_report_error (client, callback, user_data,\n                           g_socket_client_connect_to_host_async,\n                           error);\n    }\n  else\n    {\n      g_socket_client_connect_async (client,\n\t\t\t\t     connectable, cancellable,\n\t\t\t\t     callback, user_data);\n      g_object_unref (connectable);\n    }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":139226,"func":"gfx::Rect OverlayWindowViews::GetVideoBounds() {\n  return video_bounds_;\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":300812,"func":"static void tsk_advance_rx_queue(struct sock *sk)\n{\n\ttrace_tipc_sk_advance_rx(sk, NULL, TIPC_DUMP_SK_RCVQ, \" \");\n\tkfree_skb(__skb_dequeue(&sk->sk_receive_queue));\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":387879,"func":"bool InstanceKlass::is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS) {\n   \/\/ Private methods can not be overridden\n   if (super_method->is_private()) {\n     return false;\n   }\n   \/\/ If super method is accessible, then override\n   if ((super_method->is_protected()) ||\n       (super_method->is_public())) {\n     return true;\n   }\n   \/\/ Package-private methods are not inherited outside of package\n   assert(super_method->is_package_private(), \"must be package private\");\n   return(is_same_class_package(targetclassloader(), targetclassname));\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":401489,"func":"void timers_update_nohz(void)\n{\n\tschedule_work(&timer_update_work);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":424896,"func":"static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tint err;\n\n\tlockdep_assert_held(&trans_pcie->mutex);\n\n\terr = iwl_pcie_prepare_card_hw(trans);\n\tif (err) {\n\t\tIWL_ERR(trans, \"Error while preparing HW: %d\\n\", err);\n\t\treturn err;\n\t}\n\n\terr = iwl_trans_pcie_clear_persistence_bit(trans);\n\tif (err)\n\t\treturn err;\n\n\tiwl_trans_pcie_sw_reset(trans);\n\n\terr = iwl_pcie_apm_init(trans);\n\tif (err)\n\t\treturn err;\n\n\tiwl_pcie_init_msix(trans_pcie);\n\n\t\/* From now on, the op_mode will be kept updated about RF kill state *\/\n\tiwl_enable_rfkill_int(trans);\n\n\ttrans_pcie->opmode_down = false;\n\n\t\/* Set is_down to false here so that...*\/\n\ttrans_pcie->is_down = false;\n\n\t\/* ...rfkill can call stop_device and set it false if needed *\/\n\tiwl_pcie_check_hw_rf_kill(trans);\n\n\treturn 0;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":353126,"func":"void SplashGouraudPattern::getParameterizedColor(double colorinterp, SplashColorMode mode, SplashColorPtr dest) {\n  GfxColor src;\n  GfxColorSpace* srcColorSpace = shading->getColorSpace();\n  int colorComps = 3;\n#ifdef SPLASH_CMYK\n  if (mode == splashModeCMYK8)\n    colorComps=4;\n  else if (mode == splashModeDeviceN8)\n    colorComps=4 + SPOT_NCOMPS;\n#endif\n\n  shading->getParameterizedColor(colorinterp, &src);\n\n  if (bDirectColorTranslation) {\n    for (int m = 0; m < colorComps; ++m)\n      dest[m] = colToByte(src.c[m]);\n  } else {\n    convertGfxShortColor(dest, mode, srcColorSpace, &src);\n  }\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":377475,"func":"static RCoreSymCacheElementHdr *r_coresym_cache_element_header_new(RBuffer *buf, size_t off, int bits) {\n\tRCoreSymCacheElementHdr *hdr = R_NEW0 (RCoreSymCacheElementHdr);\n\tif (hdr && r_buf_fread_at (buf, off, (ut8 *)hdr, \"13i16c5i\", 1) == sizeof (RCoreSymCacheElementHdr)) {\n\t\treturn hdr;\n\t}\n\tfree (hdr);\n\treturn NULL;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":482649,"func":"static inline u_int8_t xt_family(const struct xt_action_param *par)\n{\n\treturn par->state->pf;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":474089,"func":"st_cleanup_safe(st_table *table, st_data_t never)\n{\n    st_table_entry *ptr, **last, *tmp;\n    st_index_t i;\n\n    if (table->entries_packed) {\n\tst_index_t i = 0, j = 0;\n\twhile ((st_data_t)table->bins[i*2] != never) {\n\t    if (i++ == table->num_entries) return;\n\t}\n\tfor (j = i; ++i < table->num_entries;) {\n\t    if ((st_data_t)table->bins[i*2] == never) continue;\n\t    table->bins[j*2] = table->bins[i*2];\n\t    table->bins[j*2+1] = table->bins[i*2+1];\n\t    j++;\n\t}\n\ttable->num_entries = j;\n\treturn;\n    }\n\n    for (i = 0; i < table->num_bins; i++) {\n\tptr = *(last = &table->bins[i]);\n\twhile (ptr != 0) {\n\t    if (ptr->key == never) {\n\t\ttmp = ptr;\n\t\t*last = ptr = ptr->next;\n\t\tfree(tmp);\n\t    }\n\t    else {\n\t\tptr = *(last = &ptr->next);\n\t    }\n\t}\n    }\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":224161,"func":"  void Compute(OpKernelContext* ctx) override {\n    StagingMap<Ordered>* map = nullptr;\n    OP_REQUIRES_OK(ctx, GetStagingMap(ctx, def(), &map));\n    core::ScopedUnref scope(map);\n\n    OP_REQUIRES_OK(ctx, map->clear());\n  }","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":353178,"func":"static int getLum(int r, int g, int b) {\n  return (int)(0.3 * r + 0.59 * g + 0.11 * b);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":413596,"func":"static void fcn_list_bbs(RAnalFunction *fcn) {\n\tRAnalBlock *bbi;\n\tRListIter *iter;\n\n\tr_list_foreach (fcn->bbs, iter, bbi) {\n\t\tr_cons_printf (\"afb+ 0x%08\" PFMT64x \" 0x%08\" PFMT64x \" %\" PFMT64u \" \",\n\t\t\t\t   fcn->addr, bbi->addr, bbi->size);\n\t\tr_cons_printf (\"0x%08\"PFMT64x\" \", bbi->jump);\n\t\tr_cons_printf (\"0x%08\"PFMT64x, bbi->fail);\n\t\tif (bbi->diff) {\n\t\t\tif (bbi->diff->type == R_ANAL_DIFF_TYPE_MATCH) {\n\t\t\t\tr_cons_printf (\" m\");\n\t\t\t} else if (bbi->diff->type == R_ANAL_DIFF_TYPE_UNMATCH) {\n\t\t\t\tr_cons_printf (\" u\");\n\t\t\t} else {\n\t\t\t\tr_cons_printf (\" n\");\n\t\t\t}\n\t\t}\n\t\tr_cons_printf (\"\\n\");\n\t}\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":318949,"func":"f_test_null_function(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    rettv->v_type = VAR_FUNC;\n    rettv->vval.v_string = NULL;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":248245,"func":"DLLIMPORT int cfg_setnbool(cfg_t *cfg, const char *name, cfg_bool_t value, unsigned int index)\n{\n\treturn cfg_opt_setnbool(cfg_getopt(cfg, name), value, index);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":293536,"func":"PJ_DEF(int) pj_scan_stricmp( pj_scanner *scanner, const char *s, int len)\n{\n    if (scanner->curptr + len > scanner->end) {\n\tpj_scan_syntax_err(scanner);\n\treturn -1;\n    }\n    return pj_ansi_strnicmp(scanner->curptr, s, len);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":345212,"func":"static void set_inverse_transl(struct vc_data *conp, struct uni_pagedir *p, int i)\n{\n\tint j, glyph;\n\tunsigned short *t = translations[i];\n\tunsigned char *q;\n\t\n\tif (!p) return;\n\tq = p->inverse_translations[i];\n\n\tif (!q) {\n\t\tq = p->inverse_translations[i] = kmalloc(MAX_GLYPH, GFP_KERNEL);\n\t\tif (!q) return;\n\t}\n\tmemset(q, 0, MAX_GLYPH);\n\n\tfor (j = 0; j < E_TABSZ; j++) {\n\t\tglyph = conv_uni_to_pc(conp, t[j]);\n\t\tif (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) {\n\t\t\t\/* prefer '-' above SHY etc. *\/\n\t\t  \tq[glyph] = j;\n\t\t}\n\t}\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":369111,"func":"static void kiocb_done(struct io_kiocb *req, ssize_t ret,\n\t\t       unsigned int issue_flags)\n{\n\tstruct io_async_rw *io = req->async_data;\n\n\t\/* add previously done IO, if any *\/\n\tif (req_has_async_data(req) && io->bytes_done > 0) {\n\t\tif (ret < 0)\n\t\t\tret = io->bytes_done;\n\t\telse\n\t\t\tret += io->bytes_done;\n\t}\n\n\tif (req->flags & REQ_F_CUR_POS)\n\t\treq->file->f_pos = req->rw.kiocb.ki_pos;\n\tif (ret >= 0 && (req->rw.kiocb.ki_complete == io_complete_rw))\n\t\t__io_complete_rw(req, ret, issue_flags);\n\telse\n\t\tio_rw_done(&req->rw.kiocb, ret);\n\n\tif (req->flags & REQ_F_REISSUE) {\n\t\treq->flags &= ~REQ_F_REISSUE;\n\t\tif (io_resubmit_prep(req))\n\t\t\tio_req_task_queue_reissue(req);\n\t\telse\n\t\t\tio_req_task_queue_fail(req, ret);\n\t}\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":225833,"func":"void ftyp_box_del(GF_Box *s)\n{\n\tGF_FileTypeBox *ptr = (GF_FileTypeBox *) s;\n\tif (ptr->altBrand) gf_free(ptr->altBrand);\n\tgf_free(ptr);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":452262,"func":"static char *php_xsl_xslt_string_to_xpathexpr(const char *str TSRMLS_DC)\n{\n\tconst xmlChar *string = (const xmlChar *)str;\n\n\txmlChar *value;\n\tint str_len;\n\n\tstr_len = xmlStrlen(string) + 3;\n\n\tif (xmlStrchr(string, '\"')) {\n\t\tif (xmlStrchr(string, '\\'')) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Cannot create XPath expression (string contains both quote and double-quotes)\");\n\t\t\treturn NULL;\n\t\t}\n\t\tvalue = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0);\n\t\tsnprintf(value, str_len, \"'%s'\", string);\n\t} else {\n\t\tvalue = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0);\n\t\tsnprintf(value, str_len, \"\\\"%s\\\"\", string);\n\t}\n\treturn (char *) value;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":412099,"func":"resp_addr_get_action(const struct resp_addr* addr)\n{\n\treturn addr ? addr->action : respip_none;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":463155,"func":"static void annotate_state_free(annotate_state_t **statep)\n{\n    annotate_state_t *state = *statep;\n\n    if (!state)\n        return;\n\n    annotate_state_finish(state);\n    annotate_state_unset_scope(state);\n    free(state);\n    *statep = NULL;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":436094,"func":"\nstatic enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer)\n{\n\tstruct io_timeout_data *data = container_of(timer,\n\t\t\t\t\t\tstruct io_timeout_data, timer);\n\tstruct io_kiocb *prev, *req = data->req;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&ctx->completion_lock, flags);\n\tprev = req->timeout.head;\n\treq->timeout.head = NULL;\n\n\t\/*\n\t * We don't expect the list to be empty, that will only happen if we\n\t * race with the completion of the linked work.\n\t *\/\n\tif (prev) {\n\t\tio_remove_next_linked(prev);\n\t\tif (!req_ref_inc_not_zero(prev))\n\t\t\tprev = NULL;\n\t}\n\tspin_unlock_irqrestore(&ctx->completion_lock, flags);\n\n\tif (prev) {\n\t\tio_async_find_and_cancel(ctx, req, prev->user_data, -ETIME);\n\t\tio_put_req_deferred(prev, 1);\n\t\tio_put_req_deferred(req, 1);\n\t} else {\n\t\tio_req_complete_post(req, -ETIME, 0);\n\t}\n\treturn HRTIMER_NORESTART;","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":512564,"func":"  bool get_time(THD *thd, MYSQL_TIME *ltime)\n  { return get_date(thd, ltime, Time::Options(thd)); }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512547,"func":"  Item_string(THD *thd, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE):\n    Item_literal(thd)\n  {\n    collation.set(cs, dv);\n    max_length= 0;\n    set_name(thd, NULL, 0, system_charset_info);\n    decimals= NOT_FIXED_DEC;\n  }","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":346472,"func":"do_in_runtimepath(\n    char_u\t*name,\n    int\t\tflags,\n    void\t(*callback)(char_u *fname, void *ck),\n    void\t*cookie)\n{\n    return do_in_path_and_pp(p_rtp, name, flags, callback, cookie);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":443157,"func":"static sector_t jfs_bmap(struct address_space *mapping, sector_t block)\n{\n\treturn generic_block_bmap(mapping, block, jfs_get_block);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":253703,"func":"static unsigned int ccp_empty_queue_buf(struct ccp_data *data)\n{\n\treturn ccp_queue_buf(data, 1);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":487610,"func":"int __kprobes atomic_notifier_call_chain(struct atomic_notifier_head *nh,\n\t\tunsigned long val, void *v)\n{\n\tint ret;\n\n\trcu_read_lock();\n\tret = notifier_call_chain(&nh->head, val, v);\n\trcu_read_unlock();\n\treturn ret;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":458992,"func":"HTTP_create(void *p, uint16_t nhttp, unsigned len)\n{\n\tstruct http *hp;\n\n\thp = p;\n\thp->magic = HTTP_MAGIC;\n\thp->hd = (void*)(hp + 1);\n\thp->shd = nhttp;\n\thp->hdf = (void*)(hp->hd + nhttp);\n\tassert((unsigned char*)p + len == hp->hdf + PRNDUP(nhttp));\n\treturn (hp);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":307869,"func":"void ciEnv::dump_replay_data(outputStream* out) {\n  GUARDED_VM_ENTRY(\n    MutexLocker ml(Compile_lock);\n    dump_replay_data_unsafe(out);\n  )\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":487625,"func":"asmlinkage long sys_getrlimit(unsigned int resource, struct rlimit __user *rlim)\n{\n\tif (resource >= RLIM_NLIMITS)\n\t\treturn -EINVAL;\n\telse {\n\t\tstruct rlimit value;\n\t\ttask_lock(current->group_leader);\n\t\tvalue = current->signal->rlim[resource];\n\t\ttask_unlock(current->group_leader);\n\t\treturn copy_to_user(rlim, &value, sizeof(*rlim)) ? -EFAULT : 0;\n\t}\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":498105,"func":"void cgit_snapshot_link(const char *name, const char *title, const char *class,\n\t\t\tconst char *head, const char *rev,\n\t\t\tconst char *archivename)\n{\n\treporevlink(\"snapshot\", name, title, class, head, rev, archivename);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":384125,"func":"raptor_xml_writer_set_option(raptor_xml_writer *xml_writer, \n                             raptor_option option, char* string, int integer)\n{\n  return raptor_object_options_set_option(&xml_writer->options, option,\n                                          string, integer);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":387609,"func":"static inline void remove_hash_entries(struct snd_card *card,\n\t\t\t\t       struct snd_kcontrol *kcontrol)\n{\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":326085,"func":"coll_get_char(void)\n{\n    long\tnr = -1;\n\n    switch (*regparse++)\n    {\n\tcase 'd': nr = getdecchrs(); break;\n\tcase 'o': nr = getoctchrs(); break;\n\tcase 'x': nr = gethexchrs(2); break;\n\tcase 'u': nr = gethexchrs(4); break;\n\tcase 'U': nr = gethexchrs(8); break;\n    }\n    if (nr < 0 || nr > INT_MAX)\n    {\n\t\/\/ If getting the number fails be backwards compatible: the character\n\t\/\/ is a backslash.\n\t--regparse;\n\tnr = '\\\\';\n    }\n    return nr;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":275976,"func":"uECC_VLI_API void uECC_vli_modAdd(uECC_word_t *result,\n                                  const uECC_word_t *left,\n                                  const uECC_word_t *right,\n                                  const uECC_word_t *mod,\n                                  wordcount_t num_words) {\n    uECC_word_t carry = uECC_vli_add(result, left, right, num_words);\n    if (carry || uECC_vli_cmp_unsafe(mod, result, num_words) != 1) {\n        \/* result > mod (result = mod + remainder), so subtract mod to get remainder. *\/\n        uECC_vli_sub(result, result, mod, num_words);\n    }\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":369206,"func":"static inline void __io_req_complete(struct io_kiocb *req, unsigned issue_flags,\n\t\t\t\t     s32 res, u32 cflags)\n{\n\tif (issue_flags & IO_URING_F_COMPLETE_DEFER)\n\t\tio_req_complete_state(req, res, cflags);\n\telse\n\t\tio_req_complete_post(req, res, cflags);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":241048,"func":"static int host_convert(char *hostname, char *ip_str, size_t ip_size)\n{\n\tstruct addrinfo *result = NULL, hints = {0};\n\tint re = -1;\n\n\tmemset(&hints, 0, sizeof(hints));\n\thints.ai_family = AF_INET;\n\thints.ai_socktype = SOCK_DGRAM;\n\n\tre = getaddrinfo(hostname, NULL, &hints, &result);\n\n\tif (re == 0) {\n\t\tstruct in_addr addr = ((struct sockaddr_in *)result->ai_addr)->sin_addr;\n\t\tconst char *re_ntop = inet_ntop(AF_INET, &addr, ip_str, ip_size);\n\t\tif (re_ntop == NULL) {\n\t\t\tre = -1;\n\t\t}\n\t}\n\n\tfreeaddrinfo(result);\n\treturn re;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":246475,"func":"static ut32 r_bin_wasm_get_start(RBinWasmObj *bin) {\n\tif (bin->g_start == UT32_MAX) {\n\t\tRBinWasmSection *sec = section_by_id_unique (bin->g_sections, R_BIN_WASM_SECTION_START);\n\t\tif (sec) {\n\t\t\tRBuffer *b = bin->buf;\n\t\t\tr_buf_seek (b, sec->payload_data, R_BUF_SET);\n\t\t\tut64 bound = r_buf_tell (b) + sec->payload_len - 1;\n\t\t\tif (!consume_u32_r (b, bound, &bin->g_start)) {\n\t\t\t\tbin->g_start = UT32_MAX;\n\t\t\t}\n\t\t}\n\t}\n\treturn bin->g_start;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":437690,"func":"static inline u16 carrier_freq_to_clock_divider(unsigned int freq)\n{\n\treturn count_to_clock_divider(\n\t\t\t  DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, freq * 16));\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":225738,"func":"GF_Box *smhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SoundMediaHeaderBox, GF_ISOM_BOX_TYPE_SMHD);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":226236,"func":"GF_Box *elng_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MediaBox, GF_ISOM_BOX_TYPE_ELNG);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":276917,"func":"static int i2c_get_cur_bus(struct udevice **busp)\n{\n#ifdef CONFIG_I2C_SET_DEFAULT_BUS_NUM\n\tif (!i2c_cur_bus) {\n\t\tif (cmd_i2c_set_bus_num(CONFIG_I2C_DEFAULT_BUS_NUMBER)) {\n\t\t\tprintf(\"Default I2C bus %d not found\\n\",\n\t\t\t       CONFIG_I2C_DEFAULT_BUS_NUMBER);\n\t\t\treturn -ENODEV;\n\t\t}\n\t}\n#endif\n\n\tif (!i2c_cur_bus) {\n\t\tputs(\"No I2C bus selected\\n\");\n\t\treturn -ENODEV;\n\t}\n\t*busp = i2c_cur_bus;\n\n\treturn 0;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":349900,"func":"static u32 hw_atl_utils_mif_addr_get(struct aq_hw_s *self)\n{\n\treturn aq_hw_read_reg(self, HW_ATL_MIF_ADDR);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":462310,"func":"status_do_fonts(stream * s, pcl_state_t * pcs,\n                pcl_data_storage_t storage, bool extended)\n{\n    gs_const_string key;\n    void *value;\n    pl_dict_enum_t denum;\n    int res;\n\n    pl_dict_enum_begin(&pcs->soft_fonts, &denum);\n    while (pl_dict_enum_next(&denum, &key, &value)) {\n        uint id = (key.data[0] << 8) + key.data[1];\n\n        if ((((pl_font_t *) value)->storage & storage) != 0 ||\n            (storage == 0 && pcs->font == (pl_font_t *) value)\n            ) {\n            res = status_put_font(s, pcs, id, id, (pl_font_t *) value,\n                                  (storage != 0 ? -1 : pcs->font_selected),\n                                  extended);\n            if (res != 0)\n                return res;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":326599,"func":"set_xattrs(struct archive_write_disk *a)\n{\n\tstatic int warning_done = 0;\n\n\t\/* If there aren't any extended attributes, then it's okay not\n\t * to extract them, otherwise, issue a single warning. *\/\n\tif (archive_entry_xattr_count(a->entry) != 0 && !warning_done) {\n\t\twarning_done = 1;\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,\n\t\t    \"Cannot restore extended attributes on this system\");\n\t\treturn (ARCHIVE_WARN);\n\t}\n\t\/* Warning was already emitted; suppress further warnings. *\/\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":225548,"func":"void TfLiteTensorRealloc(size_t num_bytes, TfLiteTensor* tensor) {\n  if (tensor->allocation_type != kTfLiteDynamic &&\n      tensor->allocation_type != kTfLitePersistentRo) {\n    return;\n  }\n  \/\/ TODO(b\/145340303): Tensor data should be aligned.\n  if (!tensor->data.raw) {\n    tensor->data.raw = (char*)malloc(num_bytes);\n  } else if (num_bytes > tensor->bytes) {\n    tensor->data.raw = (char*)realloc(tensor->data.raw, num_bytes);\n  }\n  tensor->bytes = num_bytes;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":384536,"func":"static ut64 read_uleb128(ut8 **p, ut8 *end) {\n\tconst char *error = NULL;\n\tut64 v;\n\t*p = (ut8 *)r_uleb128 (*p, end - *p, &v, &error);\n\tif (error) {\n\t\teprintf (\"%s\", error);\n\t\tR_FREE (error);\n\t\treturn UT64_MAX;\n\t}\n\treturn v;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":405338,"func":"struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,\n\t\t\t\t    const struct flowi *fl,\n\t\t\t\t    const struct sock *sk, int flags)\n{\n\tstruct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk,\n\t\t\t\t\t    flags | XFRM_LOOKUP_QUEUE |\n\t\t\t\t\t    XFRM_LOOKUP_KEEP_DST_REF);\n\n\tif (PTR_ERR(dst) == -EREMOTE)\n\t\treturn make_blackhole(net, dst_orig->ops->family, dst_orig);\n\n\tif (IS_ERR(dst))\n\t\tdst_release(dst_orig);\n\n\treturn dst;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":369381,"func":"\nstatic int io_rsrc_update_prep(struct io_kiocb *req,\n\t\t\t\tconst struct io_uring_sqe *sqe)\n{\n\tif (unlikely(req->flags & (REQ_F_FIXED_FILE | REQ_F_BUFFER_SELECT)))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->rw_flags || sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\n\treq->rsrc_update.offset = READ_ONCE(sqe->off);\n\treq->rsrc_update.nr_args = READ_ONCE(sqe->len);\n\tif (!req->rsrc_update.nr_args)\n\t\treturn -EINVAL;\n\treq->rsrc_update.arg = READ_ONCE(sqe->addr);\n\treturn 0;","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":430360,"func":"static void single_stop(struct seq_file *p, void *v)\n{\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":484746,"func":"static ssize_t show_rxbuf(struct device *dev,\n\t\t\t  struct device_attribute *attr, char *buf)\n{\n\treturn sprintf(buf, \"%lu\\n\", NET_RX_RING_SIZE);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":359334,"func":"bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,\n\t\t     safi_t safi, int error)\n{\n  switch (error)\n    {\n    case BGP_ERR_AF_UNCONFIGURED:\n      vty_out (vty,\n\t       \"%%BGP: Enable %s %s address family for the neighbor %s%s\",\n\t       afi == AFI_IP6 ? \"IPv6\" : safi == SAFI_MPLS_VPN ? \"VPNv4\" : \"IPv4\",\n\t       safi == SAFI_MULTICAST ? \"Multicast\" : \"Unicast\",\n\t       peer->host, VTY_NEWLINE);\n      break;\n    case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:\n      vty_out (vty, \"%%BGP: Inbound soft reconfig for %s not possible as it%s      has neither refresh capability, nor inbound soft reconfig%s\", peer->host, VTY_NEWLINE, VTY_NEWLINE);\n      break;\n    default:\n      break;\n    }\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":459218,"func":"static void tcf_chain_head_change_dflt(struct tcf_proto *tp_head, void *priv)\n{\n\tstruct tcf_proto __rcu **p_filter_chain = priv;\n\n\trcu_assign_pointer(*p_filter_chain, tp_head);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":226280,"func":"void video_sample_entry_box_del(GF_Box *s)\n{\n\tGF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\n\tif (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);\n\t\/*for publishing*\/\n\tif (ptr->emul_esd) gf_odf_desc_del((GF_Descriptor *)ptr->emul_esd);\n\tgf_free(ptr);\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":245171,"func":"read_mysql_one_value(MYSQL *connection, const char *query)\n{\n\tMYSQL_RES *mysql_result;\n\tMYSQL_ROW row;\n\tchar *result = NULL;\n\n\tmysql_result = xb_mysql_query(connection, query, true);\n\n\tut_ad(mysql_num_fields(mysql_result) == 1);\n\n\tif ((row = mysql_fetch_row(mysql_result))) {\n\t\tresult = strdup(row[0]);\n\t}\n\n\tmysql_free_result(mysql_result);\n\n\treturn(result);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":454747,"func":"static irqreturn_t ismt_handle_isr(struct ismt_priv *priv)\n{\n\tcomplete(&priv->cmp);\n\n\treturn IRQ_HANDLED;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":294713,"func":"c_gregorian_to_yday(int y, int m, int d)\n{\n    assert(m >= 1 && m <= 12);\n    return yeartab[c_gregorian_leap_p(y) ? 1 : 0][m] + d;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":220406,"func":"mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other)\n{\n  struct RArray *a1 = mrb_ary_ptr(self);\n  struct RArray *a2 = mrb_ary_ptr(other);\n\n  if (a1 != a2) {\n    ary_replace(mrb, a1, a2);\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":366189,"func":"static struct mountpoint *lock_mount(struct path *path)\n{\n\tstruct vfsmount *mnt;\n\tstruct dentry *dentry = path->dentry;\nretry:\n\tinode_lock(dentry->d_inode);\n\tif (unlikely(cant_mount(dentry))) {\n\t\tinode_unlock(dentry->d_inode);\n\t\treturn ERR_PTR(-ENOENT);\n\t}\n\tnamespace_lock();\n\tmnt = lookup_mnt(path);\n\tif (likely(!mnt)) {\n\t\tstruct mountpoint *mp = get_mountpoint(dentry);\n\t\tif (IS_ERR(mp)) {\n\t\t\tnamespace_unlock();\n\t\t\tinode_unlock(dentry->d_inode);\n\t\t\treturn mp;\n\t\t}\n\t\treturn mp;\n\t}\n\tnamespace_unlock();\n\tinode_unlock(path->dentry->d_inode);\n\tpath_put(path);\n\tpath->mnt = mnt;\n\tdentry = path->dentry = dget(mnt->mnt_root);\n\tgoto retry;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":175785,"func":"  void set_quota_manager(QuotaManager* quota_manager) {\n    quota_manager_ = quota_manager;\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":498094,"func":"void cgit_vprint_error(const char *fmt, va_list ap)\n{\n\tva_list cp;\n\thtml(\"<div class='error'>\");\n\tva_copy(cp, ap);\n\thtml_vtxtf(fmt, cp);\n\tva_end(cp);\n\thtml(\"<\/div>\\n\");\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":489126,"func":"sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep,\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst sctp_subtype_t type,\n\t\t\t\t\tvoid *arg,\n\t\t\t\t\tsctp_cmd_seq_t *commands)\n{\n\tstruct sctp_chunk *chunk = arg;\n\tstruct sctp_ulpevent *ev;\n\n\tif (!sctp_vtag_verify(chunk, asoc))\n\t\treturn sctp_sf_pdiscard(ep, asoc, type, arg, commands);\n\n\t\/* Make sure that the ERROR chunk has a valid length. *\/\n\tif (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t)))\n\t\treturn sctp_sf_violation_chunklen(ep, asoc, type, arg,\n\t\t\t\t\t\t  commands);\n\n\twhile (chunk->chunk_end > chunk->skb->data) {\n\t\tev = sctp_ulpevent_make_remote_error(asoc, chunk, 0,\n\t\t\t\t\t\t     GFP_ATOMIC);\n\t\tif (!ev)\n\t\t\tgoto nomem;\n\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,\n\t\t\t\tSCTP_ULPEVENT(ev));\n\t\tsctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,\n\t\t\t\tSCTP_CHUNK(chunk));\n\t}\n\treturn SCTP_DISPOSITION_CONSUME;\n\nnomem:\n\treturn SCTP_DISPOSITION_NOMEM;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":336690,"func":"SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(void)\n{\n    return (const char **) spice_server_char_device_recognized_subtypes_list;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":218754,"func":"static wchar_t *ConvertUTF8ToUTF16(const unsigned char *source)\n{\n  size_t\n    length;\n\n  wchar_t\n    *utf16;\n\n  length=UTF8ToUTF16(source,(wchar_t *) NULL);\n  if (length == 0)\n    {\n      ssize_t\n        i;\n\n      \/*\n        Not UTF-8, just copy.\n      *\/\n      length=strlen((char *) source);\n      utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));\n      if (utf16 == (wchar_t *) NULL)\n        return((wchar_t *) NULL);\n      for (i=0; i <= (ssize_t) length; i++)\n        utf16[i]=source[i];\n      return(utf16);\n    }\n  utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));\n  if (utf16 == (wchar_t *) NULL)\n    return((wchar_t *) NULL);\n  length=UTF8ToUTF16(source,utf16);\n  return(utf16);\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":387852,"func":"jint InstanceKlass::jvmti_class_status() const {\n  jint result = 0;\n\n  if (is_linked()) {\n    result |= JVMTI_CLASS_STATUS_VERIFIED | JVMTI_CLASS_STATUS_PREPARED;\n  }\n\n  if (is_initialized()) {\n    assert(is_linked(), \"Class status is not consistent\");\n    result |= JVMTI_CLASS_STATUS_INITIALIZED;\n  }\n  if (is_in_error_state()) {\n    result |= JVMTI_CLASS_STATUS_ERROR;\n  }\n  return result;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":455286,"func":"shell_is_restricted (name)\n     char *name;\n{\n  char *temp;\n\n  if (restricted)\n    return 1;\n  temp = base_pathname (name);\n  if (*temp == '-')\n    temp++;\n  return (STREQ (temp, RESTRICTED_SHELL_NAME));\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":226056,"func":"\nvoid metx_box_del(GF_Box *s)\n{\n\tGF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox*)s;\n\tif (ptr == NULL) return;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\n\tif (ptr->content_encoding) gf_free(ptr->content_encoding);\n\tif (ptr->xml_namespace) gf_free(ptr->xml_namespace);\n\tif (ptr->xml_schema_loc) gf_free(ptr->xml_schema_loc);\n\tif (ptr->mime_type) gf_free(ptr->mime_type);\n\tgf_free(ptr);","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":482653,"func":"static inline unsigned long ifname_compare_aligned(const char *_a,\n\t\t\t\t\t\t   const char *_b,\n\t\t\t\t\t\t   const char *_mask)\n{\n\tconst unsigned long *a = (const unsigned long *)_a;\n\tconst unsigned long *b = (const unsigned long *)_b;\n\tconst unsigned long *mask = (const unsigned long *)_mask;\n\tunsigned long ret;\n\n\tret = (a[0] ^ b[0]) & mask[0];\n\tif (IFNAMSIZ > sizeof(unsigned long))\n\t\tret |= (a[1] ^ b[1]) & mask[1];\n\tif (IFNAMSIZ > 2 * sizeof(unsigned long))\n\t\tret |= (a[2] ^ b[2]) & mask[2];\n\tif (IFNAMSIZ > 3 * sizeof(unsigned long))\n\t\tret |= (a[3] ^ b[3]) & mask[3];\n\tBUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long));\n\treturn ret;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":225954,"func":"\/* SimpleTextSampleEntry *\/\nGF_Box *txtc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextConfigBox, GF_ISOM_BOX_TYPE_TXTC);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":432195,"func":"void memory_region_init_io(struct uc_struct *uc,\n                           MemoryRegion *mr,\n                           const MemoryRegionOps *ops,\n                           void *opaque,\n                           uint64_t size)\n{\n    memory_region_init(uc, mr, size);\n    mr->ops = ops ? ops : &unassigned_mem_ops;\n    mr->opaque = opaque;\n    mr->terminates = true;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":252352,"func":"int mz_deflateInit(mz_streamp pStream, int level) {\n  return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9,\n                         MZ_DEFAULT_STRATEGY);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":512849,"func":"  void set_typelib(TYPELIB *typelib)\n  {\n    \/\/ Non-field Items (e.g. hybrid functions) never have ENUM\/SET types yet.\n    DBUG_ASSERT(0);\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":402640,"func":"wrap_in_set(cms_context *cms, SECItem *der, SECItem **items)\n{\n\tvoid *ret;\n\n\tret = SEC_ASN1EncodeItem(cms->arena, der, &items, &SetTemplate);\n\tif (ret == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode set\");\n\treturn 0;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":226008,"func":"\nvoid dac3_box_del(GF_Box *s)\n{\n\tGF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;\n\tgf_free(ptr);","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":359209,"func":"static __poll_t ringbuf_map_poll(struct bpf_map *map, struct file *filp,\n\t\t\t\t struct poll_table_struct *pts)\n{\n\tstruct bpf_ringbuf_map *rb_map;\n\n\trb_map = container_of(map, struct bpf_ringbuf_map, map);\n\tpoll_wait(filp, &rb_map->rb->waitq, pts);\n\n\tif (ringbuf_avail_data_sz(rb_map->rb))\n\t\treturn EPOLLIN | EPOLLRDNORM;\n\treturn 0;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":343324,"func":"static void addreply_newline(const char * const str, const size_t size)\n{\n    struct reply *newline;\n\n    if ((newline = (struct reply *) malloc(offsetof(struct reply, line) +\n                                           size)) == NULL) {\n        die_mem();\n    }\n    if (firstreply == NULL) {\n        firstreply = newline;\n    } else {\n        lastreply->next = newline;\n    }\n    newline->next = NULL;\n    lastreply = newline;\n    memcpy(newline->line, str, size);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":432347,"func":"static void i2c_ddc_class_init(ObjectClass *oc, void *data)\n{\n    DeviceClass *dc = DEVICE_CLASS(oc);\n    I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);\n\n    dc->reset = i2c_ddc_reset;\n    dc->vmsd = &vmstate_i2c_ddc;\n    dc->props = i2c_ddc_properties;\n    isc->event = i2c_ddc_event;\n    isc->recv = i2c_ddc_rx;\n    isc->send = i2c_ddc_tx;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":353169,"func":"void SplashOutputDev::clipToStrokePath(GfxState *state) {\n  SplashPath *path2;\n\n  SplashPath path = convertPath(state, state->getPath(), false);\n  path2 = splash->makeStrokePath(&path, state->getLineWidth());\n  splash->clipToPath(path2, false);\n  delete path2;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":195402,"func":"int TfLiteIntArrayGetSizeInBytes(int size) {\n  static TfLiteIntArray dummy;\n\n  int computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;\n#if defined(_MSC_VER)\n  \/\/ Context for why this is needed is in http:\/\/b\/189926408#comment21\n  computed_size -= sizeof(dummy.data[0]);\n#endif\n  return computed_size;\n}","target":1,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":225408,"func":"static int vidioc_enum_frameintervals(struct file *file, void *fh,\n\t\t\t\t      struct v4l2_frmivalenum *argp)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);\n\tstruct v4l2_loopback_opener *opener = fh_to_opener(fh);\n\n\tif (dev->ready_for_capture) {\n\t\tif (opener->vidioc_enum_frameintervals_calls > 0)\n\t\t\treturn -EINVAL;\n\t\tif (argp->width == dev->pix_format.width &&\n\t\t    argp->height == dev->pix_format.height) {\n\t\t\targp->type = V4L2_FRMIVAL_TYPE_DISCRETE;\n\t\t\targp->discrete = dev->capture_param.timeperframe;\n\t\t\topener->vidioc_enum_frameintervals_calls++;\n\t\t\treturn 0;\n\t\t}\n\t\treturn -EINVAL;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":486810,"func":"static inline unsigned tx_desc_get_last(uint32_t *desc)\n{\n    return (desc[1] & DESC_1_TX_LAST) ? 1 : 0;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":252344,"func":"mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip,\n                                           const char *pArchive_filename,\n                                           const char *pDst_filename,\n                                           mz_uint flags) {\n  int file_index =\n      mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags);\n  if (file_index < 0) return MZ_FALSE;\n  return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":513086,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_ref>(thd, this); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":273054,"func":"ringbuffer_read(uint8_t **dst, size_t dstlen, struct ringbuffer *buf)\n{\n  int remaining;\n\n  *dst = buf->buffer + buf->read_pos;\n\n  if (buf->read_avail == 0 || dstlen == 0)\n    return 0;\n\n  remaining = buf->size - buf->read_pos;\n\n  \/\/ The number of bytes we will return will be MIN(dstlen, remaining, read_avail)\n  if (dstlen > remaining)\n    dstlen = remaining;\n  if (dstlen > buf->read_avail)\n    dstlen = buf->read_avail;\n\n  buf->read_pos = (buf->read_pos + dstlen) % buf->size;\n\n  buf->write_avail += dstlen;\n  buf->read_avail -= dstlen;\n\n  return dstlen;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":232337,"func":"\nvoid gf_isom_box_del_parent(GF_List **child_boxes, GF_Box*b)\n{\n\tif (child_boxes) {\n\t\tgf_list_del_item(*child_boxes, b);\n\t\tif (!gf_list_count(*child_boxes)) {\n\t\t\tgf_list_del(*child_boxes);\n\t\t\t*child_boxes = NULL;\n\t\t}\n\t}\n\tgf_isom_box_del(b);","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":364789,"func":"tagstack_set_curidx(win_T *wp, int curidx)\n{\n    wp->w_tagstackidx = curidx;\n    if (wp->w_tagstackidx < 0)\t\t\t\/\/ sanity check\n\twp->w_tagstackidx = 0;\n    if (wp->w_tagstackidx > wp->w_tagstacklen)\n\twp->w_tagstackidx = wp->w_tagstacklen;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":234200,"func":"add_shndx_to_cu_tu_entry (unsigned int shndx)\n{\n  if (shndx_pool_used >= shndx_pool_size)\n    {\n      error (_(\"Internal error: out of space in the shndx pool.\\n\"));\n      return;\n    }\n  shndx_pool [shndx_pool_used++] = shndx;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":270406,"func":"static bool ok_inflater_stored_block_header(ok_inflater *inflater) {\n    ok_inflater_skip_byte_align(inflater);\n    if (!ok_inflater_load_bits(inflater, 32)) {\n        return false;\n    } else {\n        uint32_t len = ok_inflater_read_bits(inflater, 16);\n        uint32_t clen = ok_inflater_read_bits(inflater, 16);\n        if ((len & 0xffff) != ((~clen) & 0xffff)) {\n            ok_inflater_error(inflater, \"Invalid stored block\");\n            return false;\n        } else if (len == 0) {\n            inflater->state = OK_INFLATER_STATE_READY_FOR_NEXT_BLOCK;\n            return true;\n        } else {\n            inflater->state = OK_INFLATER_STATE_READING_STORED_BLOCK;\n            inflater->state_count = (int)len;\n            return true;\n        }\n    }\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":393520,"func":"static SQInteger array_append(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_arrayappend(v,-2)) ? 1 : SQ_ERROR;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":222540,"func":"FunctionDefLibrary FunctionLibraryDefinition::ToProto() const {\n  FunctionDefLibrary lib;\n  tf_shared_lock l(mu_);\n  for (const auto& f : function_defs_) {\n    *lib.add_function() = f.second->fdef;\n  }\n  for (const auto& g : func_grad_) {\n    GradientDef* gd = lib.add_gradient();\n    gd->set_function_name(g.first);\n    gd->set_gradient_func(g.second);\n  }\n  return lib;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":473860,"func":"is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)\n{\n  if (code < 256)\n    return ENC_IS_ISO_8859_8_CTYPE(code, ctype);\n  else\n    return FALSE;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":90198,"func":"static std::string WrapWithTH(std::string text) {\n  return \"<th>\" + text + \"<\/th>\";\n}\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":512298,"func":"void Item_func_case_simple::print(String *str, enum_query_type query_type)\n{\n  Item **pos;\n  str->append(STRING_WITH_LEN(\"case \"));\n  args[0]->print_parenthesised(str, query_type, precedence());\n  str->append(' ');\n  print_when_then_arguments(str, query_type, &args[1], when_count());\n  if ((pos= Item_func_case_simple::else_expr_addr()))\n    print_else_argument(str, query_type, pos[0]);\n  str->append(STRING_WITH_LEN(\"end\"));\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":473927,"func":"mbc_case_fold(OnigCaseFoldType flag,\n\t      const UChar** pp, const UChar* end, UChar* lower,\n\t      OnigEncoding enc)\n{\n  int len;\n  const UChar* p = *pp;\n\n  if (ONIGENC_IS_MBC_ASCII(p)) {\n    *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);\n    (*pp)++;\n    return 1;\n  }\n  else {\n    int i;\n\n    len = enclen(enc, p, end);\n    for (i = 0; i < len; i++) {\n      *lower++ = *p++;\n    }\n    (*pp) += len;\n    return len; \/* return byte length of converted char to lower *\/\n  }\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":336532,"func":"static void reds_config_set_image_compression(RedsState *reds, SpiceImageCompression image_compression)\n{\n    if (image_compression == reds->config->image_compression) {\n        return;\n    }\n    switch (image_compression) {\n    case SPICE_IMAGE_COMPRESSION_AUTO_LZ:\n        spice_debug(\"ic auto_lz\");\n        break;\n    case SPICE_IMAGE_COMPRESSION_AUTO_GLZ:\n        spice_debug(\"ic auto_glz\");\n        break;\n    case SPICE_IMAGE_COMPRESSION_QUIC:\n        spice_debug(\"ic quic\");\n        break;\n#ifdef USE_LZ4\n    case SPICE_IMAGE_COMPRESSION_LZ4:\n        spice_debug(\"ic lz4\");\n        break;\n#endif\n    case SPICE_IMAGE_COMPRESSION_LZ:\n        spice_debug(\"ic lz\");\n        break;\n    case SPICE_IMAGE_COMPRESSION_GLZ:\n        spice_debug(\"ic glz\");\n        break;\n    case SPICE_IMAGE_COMPRESSION_OFF:\n        spice_debug(\"ic off\");\n        break;\n    default:\n        spice_warning(\"ic invalid\");\n        return;\n    }\n    reds->config->image_compression = image_compression;\n    reds_on_ic_change(reds);\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":336523,"func":"static void reds_set_mouse_mode(RedsState *reds, SpiceMouseMode mode)\n{\n    if (reds->mouse_mode == mode) {\n        return;\n    }\n    reds->mouse_mode = mode;\n\n    FOREACH_QXL_INSTANCE(reds, qxl) {\n        red_qxl_set_mouse_mode(qxl, mode);\n    }\n\n    reds->main_channel->push_mouse_mode(reds->mouse_mode,\n                                        reds->is_client_mouse_allowed);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":242123,"func":"int LuaSettings::l_remove(lua_State* L)\n{\n\tNO_MAP_LOCK_REQUIRED;\n\tLuaSettings* o = checkobject(L, 1);\n\n\tstd::string key = std::string(luaL_checkstring(L, 2));\n\n\tCHECK_SETTING_SECURITY(L, key);\n\n\tbool success = o->m_settings->remove(key);\n\tlua_pushboolean(L, success);\n\n\treturn 1;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":273068,"func":"b64_decode(int *dstlen, const char *src)\n{\n  uint8_t *out;\n  int len;\n  int ret;\n\n  len = AV_BASE64_DECODE_SIZE(strlen(src));\n\n  \/\/ Add a extra zero byte just in case we are decoding a string without null\n  \/\/ termination\n  CHECK_NULL(L_MISC, out = calloc(1, len + 1));\n\n  ret = av_base64_decode(out, src, len);\n  if (ret < 0)\n    {\n      free(out);\n      return NULL;\n    }\n\n  if (dstlen)\n    *dstlen = ret;\n\n  return out;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":310028,"func":"drv_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf)\n{\n    SCREEN *sp = TCB->csp;\n    TERMINAL *_term = (TERMINAL *) TCB;\n    int result = OK;\n\n    AssertTCB();\n    if (setFlag) {\n\tfor (;;) {\n\t    if (SET_TTY(_term->Filedes, buf) != 0) {\n\t\tif (errno == EINTR)\n\t\t    continue;\n\t\tif (errno == ENOTTY) {\n\t\t    if (sp)\n\t\t\tsp->_notty = TRUE;\n\t\t}\n\t\tresult = ERR;\n\t    }\n\t    break;\n\t}\n    } else {\n\tfor (;;) {\n\t    if (GET_TTY(_term->Filedes, buf) != 0) {\n\t\tif (errno == EINTR)\n\t\t    continue;\n\t\tresult = ERR;\n\t    }\n\t    break;\n\t}\n    }\n    return result;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":454750,"func":"static void ismt_desc_dump(struct ismt_priv *priv)\n{\n\tstruct device *dev = &priv->pci_dev->dev;\n\tstruct ismt_desc *desc = &priv->hw[priv->head];\n\n\tdev_dbg(dev, \"Dump of the descriptor struct:  0x%X\\n\", priv->head);\n\t__ismt_desc_dump(dev, desc);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":369369,"func":"static inline void io_cqring_ev_posted(struct io_ring_ctx *ctx)\n{\n\tif (unlikely(ctx->off_timeout_used || ctx->drain_active ||\n\t\t     ctx->has_evfd))\n\t\t__io_commit_cqring_flush(ctx);\n\n\tio_cqring_wake(ctx);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":291837,"func":"static int post_recv_path(struct rtrs_clt_path *clt_path)\n{\n\tsize_t q_size = 0;\n\tint err, cid;\n\n\tfor (cid = 0; cid < clt_path->s.con_num; cid++) {\n\t\tif (cid == 0)\n\t\t\tq_size = SERVICE_CON_QUEUE_DEPTH;\n\t\telse\n\t\t\tq_size = clt_path->queue_depth;\n\n\t\t\/*\n\t\t * x2 for RDMA read responses + FR key invalidations,\n\t\t * RDMA writes do not require any FR registrations.\n\t\t *\/\n\t\tq_size *= 2;\n\n\t\terr = post_recv_io(to_clt_con(clt_path->s.con[cid]), q_size);\n\t\tif (err) {\n\t\t\trtrs_err(clt_path->clt, \"post_recv_io(), err: %d\\n\",\n\t\t\t\t err);\n\t\t\treturn err;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":310042,"func":"outs(char *s)\n{\n    if (VALID_STRING(s)) {\n\ttputs(s, 1, outc);\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":474007,"func":"is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)\n{\n  if (ctype <= ONIGENC_MAX_STD_CTYPE) {\n    if (code < 128)\n      return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);\n    else {\n      if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {\n\treturn (code_to_mbclen(code, enc) > 1 ? TRUE : FALSE);\n      }\n    }\n  }\n  else {\n    PROPERTY_LIST_INIT_CHECK;\n\n    ctype -= (ONIGENC_MAX_STD_CTYPE + 1);\n    if (ctype >= (unsigned int )PropertyListNum)\n      return ONIGERR_TYPE_BUG;\n\n    return onig_is_in_code_range((UChar* )PropertyList[ctype], code);\n  }\n\n  return FALSE;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":294709,"func":"d_lite_mjd(VALUE self)\n{\n    get_d1(self);\n    return f_sub(m_real_local_jd(dat), INT2FIX(2400001));\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":275518,"func":"njs_vm_opt_init(njs_vm_opt_t *options)\n{\n    njs_memzero(options, sizeof(njs_vm_opt_t));\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":455287,"func":"mbskipname (pat, dname, flags)\n     char *pat, *dname;\n     int flags;\n{\n  int ret, ext;\n  wchar_t *pat_wc, *dn_wc;\n  size_t pat_n, dn_n;\n\n  if (mbsmbchar (dname) == 0 && mbsmbchar (pat) == 0)\n    return (skipname (pat, dname, flags));\n\n  ext = 0;\n#if EXTENDED_GLOB\n  ext = extglob_pattern_p (pat);\n#endif\n\n  pat_wc = dn_wc = (wchar_t *)NULL;\n\n  pat_n = xdupmbstowcs (&pat_wc, NULL, pat);\n  if (pat_n != (size_t)-1)\n    dn_n = xdupmbstowcs (&dn_wc, NULL, dname);\n\n  ret = 0;\n  if (pat_n != (size_t)-1 && dn_n !=(size_t)-1)\n    ret = ext ? wextglob_skipname (pat_wc, dn_wc, flags) : wskipname (pat_wc, dn_wc, flags);\n  else\n    ret = skipname (pat, dname, flags);\n\n  FREE (pat_wc);\n  FREE (dn_wc);\n\n  return ret;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":488434,"func":"pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,\n\t\t\tspinlock_t **ptl)\n{\n\tpgd_t * pgd = pgd_offset(mm, addr);\n\tpud_t * pud = pud_alloc(mm, pgd, addr);\n\tif (pud) {\n\t\tpmd_t * pmd = pmd_alloc(mm, pud, addr);\n\t\tif (pmd)\n\t\t\treturn pte_alloc_map_lock(mm, pmd, addr, ptl);\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":262086,"func":"  explicit BoostedTreesCalculateBestFeatureSplitV2(\n      OpKernelConstruction* const context)\n      : OpKernel(context) {\n    OP_REQUIRES_OK(context, context->GetAttr(\"logits_dimension\", &logits_dim_));\n    OP_REQUIRES_OK(context, context->GetAttr(\"num_features\", &num_features_));\n  }","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":230987,"func":"mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const mrb_value *argv)\n{\n  struct RProc *p;\n  mrb_callinfo *ci;\n\n  check_block(mrb, b);\n  p = mrb_proc_ptr(b);\n  ci = mrb->c->ci;\n\n  mrb_stack_extend(mrb, 4);\n  mrb->c->ci->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);\n  mrb->c->ci->stack[2] = mrb_nil_value();\n  mrb->c->ci->stack[3] = mrb_nil_value();\n  ci->n = 15;\n  ci->nk = 0;\n  return exec_irep(mrb, self, p);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":317285,"func":"static int selinux_perf_event_read(struct perf_event *event)\n{\n\tstruct perf_event_security_struct *perfsec = event->security;\n\tu32 sid = current_sid();\n\n\treturn avc_has_perm(&selinux_state, sid, perfsec->sid,\n\t\t\t    SECCLASS_PERF_EVENT, PERF_EVENT__READ, NULL);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":359533,"func":"DEFUN (no_neighbor_filter_list,\n       no_neighbor_filter_list_cmd,\n       NO_NEIGHBOR_CMD2 \"filter-list WORD (in|out)\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Establish BGP filters\\n\"\n       \"AS path access-list name\\n\"\n       \"Filter incoming routes\\n\"\n       \"Filter outgoing routes\\n\")\n{\n  return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\tbgp_node_safi (vty), argv[2]);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":247556,"func":"  TestUtilOptionsV2& setExpectedProtocolVersion(const std::string& expected_protocol_version) {\n    expected_protocol_version_ = expected_protocol_version;\n    return *this;\n  }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":484795,"func":"static int netfront_probe(struct xenbus_device *dev,\n\t\t\t  const struct xenbus_device_id *id)\n{\n\tint err;\n\tstruct net_device *netdev;\n\tstruct netfront_info *info;\n\n\tnetdev = xennet_create_dev(dev);\n\tif (IS_ERR(netdev)) {\n\t\terr = PTR_ERR(netdev);\n\t\txenbus_dev_fatal(dev, err, \"creating netdev\");\n\t\treturn err;\n\t}\n\n\tinfo = netdev_priv(netdev);\n\tdev_set_drvdata(&dev->dev, info);\n#ifdef CONFIG_SYSFS\n\tinfo->netdev->sysfs_groups[0] = &xennet_dev_group;\n#endif\n\n\treturn 0;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":383324,"func":"gdImageCharUp (gdImagePtr im, gdFontPtr f,\n\t       int x, int y, int c, int color)\n{\n  int cx, cy;\n  int px, py;\n  int fline;\n  cx = 0;\n  cy = 0;\n#ifdef CHARSET_EBCDIC\n  c = ASC (c);\n#endif \/*CHARSET_EBCDIC *\/\n  if ((c < f->offset) || (c >= (f->offset + f->nchars)))\n    {\n      return;\n    }\n  fline = (c - f->offset) * f->h * f->w;\n  for (py = y; (py > (y - f->w)); py--)\n    {\n      for (px = x; (px < (x + f->h)); px++)\n\t{\n\t  if (f->data[fline + cy * f->w + cx])\n\t    {\n\t      gdImageSetPixel (im, px, py, color);\n\t    }\n\t  cy++;\n\t}\n      cy = 0;\n      cx++;\n    }\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":247657,"func":"bool DefaultCertValidator::matchSubjectAltName(\n    X509* cert, const std::vector<SanMatcherPtr>& subject_alt_name_matchers) {\n  bssl::UniquePtr<GENERAL_NAMES> san_names(\n      static_cast<GENERAL_NAMES*>(X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr)));\n  if (san_names == nullptr) {\n    return false;\n  }\n  for (const auto& config_san_matcher : subject_alt_name_matchers) {\n    for (const GENERAL_NAME* general_name : san_names.get()) {\n      if (config_san_matcher->match(general_name)) {\n        return true;\n      }\n    }\n  }\n  return false;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":222668,"func":"char *get_socket_path(const char *_token)\n{\n\tchar *path;\n\tchar *token = xstrdup(_token);\n\n\tfor (char *c = token; *c; c++) {\n\t\tif (*c == '\/' || *c == '.')\n\t\t\t*c = '=';\n\t}\n\n\txasprintf(&path, TMATE_WORKDIR \"\/sessions\/%s\", token);\n\tfree(token);\n\treturn path;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":231736,"func":"TEST_F(QuicServerTransportTest, TestRegisterPMTUZeroBlackholeDetection) {\n  server->handleKnobParams(\n      {{static_cast<uint64_t>(\n            TransportKnobParamId::ZERO_PMTU_BLACKHOLE_DETECTION),\n        1}});\n  EXPECT_TRUE(server->getConn().d6d.noBlackholeDetection);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":232311,"func":"GF_ISOFile *gf_isom_new_movie()\n{\n\tGF_ISOFile *mov = (GF_ISOFile*)gf_malloc(sizeof(GF_ISOFile));\n\tif (mov == NULL) {\n\t\tgf_isom_set_last_error(NULL, GF_OUT_OF_MEM);\n\t\treturn NULL;\n\t}\n\tmemset(mov, 0, sizeof(GF_ISOFile));\n\n\t\/*init the boxes*\/\n\tmov->TopBoxes = gf_list_new();\n\tif (!mov->TopBoxes) {\n\t\tgf_isom_set_last_error(NULL, GF_OUT_OF_MEM);\n\t\tgf_free(mov);\n\t\treturn NULL;\n\t}\n\n\t\/*default storage mode is flat*\/\n\tmov->storageMode = GF_ISOM_STORE_FLAT;\n\tmov->es_id_default_sync = -1;\n\treturn mov;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":234190,"func":"display_debug_info (struct dwarf_section *section, void *file)\n{\n  return process_debug_info (section, file, section->abbrev_sec, false, false);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":401500,"func":"static void timers_update_migration(void)\n{\n\tif (sysctl_timer_migration && tick_nohz_active)\n\t\tstatic_branch_enable(&timers_migration_enabled);\n\telse\n\t\tstatic_branch_disable(&timers_migration_enabled);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":476126,"func":"static int len_ext_prop(struct usb_configuration *c, int interface)\n{\n\tstruct usb_function *f;\n\tstruct usb_os_desc *d;\n\tint j, res;\n\n\tres = 10; \/* header length *\/\n\tf = c->interface[interface];\n\tfor (j = 0; j < f->os_desc_n; ++j) {\n\t\tif (interface != f->os_desc_table[j].if_id)\n\t\t\tcontinue;\n\t\td = f->os_desc_table[j].os_desc;\n\t\tif (d)\n\t\t\treturn min(res + d->ext_prop_len, 4096);\n\t}\n\treturn res;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":250680,"func":"string_view HttpFile::getFileExtension() const\n{\n    return implPtr_->getFileExtension();\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":432323,"func":"static RAMBlock *qemu_get_ram_block(struct uc_struct *uc, ram_addr_t addr)\n{\n    RAMBlock *block;\n\n    block = uc->ram_list.mru_block;\n    if (block && addr - block->offset < block->max_length) {\n        return block;\n    }\n    RAMBLOCK_FOREACH(block) {\n        if (addr - block->offset < block->max_length) {\n            goto found;\n        }\n    }\n\n    fprintf(stderr, \"Bad ram offset %\" PRIx64 \"\\n\", (uint64_t)addr);\n    abort();\n\nfound:\n    uc->ram_list.mru_block = block;\n    return block;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":275933,"func":"static void apply_z(uECC_word_t * X1,\n                    uECC_word_t * Y1,\n                    const uECC_word_t * const Z,\n                    uECC_Curve curve) {\n    uECC_word_t t1[uECC_MAX_WORDS];\n\n    uECC_vli_modSquare_fast(t1, Z, curve);    \/* z^2 *\/\n    uECC_vli_modMult_fast(X1, X1, t1, curve); \/* x1 * z^2 *\/\n    uECC_vli_modMult_fast(t1, t1, Z, curve);  \/* z^3 *\/\n    uECC_vli_modMult_fast(Y1, Y1, t1, curve); \/* y1 * z^3 *\/\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":247095,"func":"GF_Err gf_fs_set_separators(GF_FilterSession *session, const char *separator_set)\n{\n\tif (!session) return GF_BAD_PARAM;\n\tif (separator_set && (strlen(separator_set)<5)) return GF_BAD_PARAM;\n\n\tif (separator_set) {\n\t\tsession->sep_args = separator_set[0];\n\t\tsession->sep_name = separator_set[1];\n\t\tsession->sep_frag = separator_set[2];\n\t\tsession->sep_list = separator_set[3];\n\t\tsession->sep_neg = separator_set[4];\n\t} else {\n\t\tsession->sep_args = ':';\n\t\tsession->sep_name = '=';\n\t\tsession->sep_frag = '#';\n\t\tsession->sep_list = ',';\n\t\tsession->sep_neg = '!';\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":207804,"func":"void update_process_times(int user_tick)\n{\n\tstruct task_struct *p = current;\n\n\t\/* Note: this timer irq context must be accounted for as well. *\/\n\taccount_process_tick(p, user_tick);\n\trun_local_timers();\n\trcu_sched_clock_irq(user_tick);\n#ifdef CONFIG_IRQ_WORK\n\tif (in_irq())\n\t\tirq_work_tick();\n#endif\n\tscheduler_tick();\n\tif (IS_ENABLED(CONFIG_POSIX_TIMERS))\n\t\trun_posix_cpu_timers();\n}","target":1,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":338209,"func":"void WasmBinaryBuilder::visitGlobalSet(GlobalSet* curr) {\n  BYN_TRACE(\"zz node: GlobalSet\\n\");\n  auto index = getU32LEB();\n  if (index < globalImports.size()) {\n    auto* import = globalImports[index];\n    curr->name = import->name;\n  } else {\n    Index adjustedIndex = index - globalImports.size();\n    if (adjustedIndex >= globals.size()) {\n      throwError(\"invalid global index\");\n    }\n    curr->name = globals[adjustedIndex]->name;\n  }\n  curr->value = popNonVoidExpression();\n  globalRefs[index].push_back(curr); \/\/ we don't know the final name yet\n  curr->finalize();\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":101666,"func":"void WebProcessProxy::didClearPluginSiteData(uint64_t callbackID)\n{\n    m_context->pluginSiteDataManager()->didClearSiteData(callbackID);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":432300,"func":"static void flatviews_init(struct uc_struct *uc)\n{\n    if (uc->flat_views) {\n        return;\n    }\n\n    uc->flat_views = g_hash_table_new_full(NULL, NULL, NULL,\n                                       (GDestroyNotify) flatview_unref);\n\n    if (!uc->empty_view) {\n        uc->empty_view = generate_memory_topology(uc, NULL);\n        \/* We keep it alive forever in the global variable.  *\/\n        flatview_ref(uc->empty_view);\n        g_hash_table_replace(uc->flat_views, NULL, uc->empty_view);\n    }\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":256953,"func":"  string TraceString(const OpKernelContext& ctx, bool verbose) const override {\n    string op = profiler::TraceMeOp(name_view(), type_string_view());\n    string equation = strings::StrCat(\"(\", equation_, \")\");\n    if (verbose) {\n      string shape = ShapeTraceString(ctx);\n      if (!shape.empty()) {\n        return profiler::TraceMeEncode(\n            std::move(op), {{\"equation\", equation}, {\"shape\", shape}});\n      }\n    }\n    return profiler::TraceMeEncode(std::move(op), {{\"equation\", equation}});\n  }","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":498092,"func":"void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)\n{\n\tva_list ap;\n\tctx.page.expires = ctx.cfg.cache_dynamic_ttl;\n\tctx.page.status = code;\n\tctx.page.statusmsg = msg;\n\tcgit_print_http_headers();\n\tcgit_print_docstart();\n\tcgit_print_pageheader();\n\tva_start(ap, fmt);\n\tcgit_vprint_error(fmt, ap);\n\tva_end(ap);\n\tcgit_print_docend();\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":326110,"func":"use_multibytecode(int c)\n{\n    return has_mbyte && (*mb_char2len)(c) > 1\n\t\t     && (re_multi_type(peekchr()) != NOT_MULTI\n\t\t\t     || (enc_utf8 && utf_iscomposing(c)));\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":225390,"func":"static void vm_open(struct vm_area_struct *vma)\n{\n\tstruct v4l2l_buffer *buf;\n\tMARK();\n\n\tbuf = vma->vm_private_data;\n\tbuf->use_count++;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":513216,"func":"sys_var *find_sys_var(THD *thd, const char *str, size_t length)\n{\n  return find_sys_var_ex(thd, str, length, false, false);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":512956,"func":"  longlong val_int()\n  {\n    return to_datetime(current_thd).to_longlong();\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":224465,"func":"static void ttxt_dom_progress(void *cbk, u64 cur_samp, u64 count)\n{\n\tGF_TXTIn *ctx = (GF_TXTIn *)cbk;\n\tctx->end = count;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":513096,"func":"  void set_geometry_type(uint type)\n  {\n    DBUG_ASSERT(type <= m_geometry_type_unknown);\n    m_geometry_type= type;\n  }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":282857,"func":"static bool rsi_map_rates(u16 rate, int *offset)\n{\n\tint kk;\n\tfor (kk = 0; kk < ARRAY_SIZE(rsi_mcsrates); kk++) {\n\t\tif (rate == mcs[kk]) {\n\t\t\t*offset = kk;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfor (kk = 0; kk < ARRAY_SIZE(rsi_rates); kk++) {\n\t\tif (rate == rsi_rates[kk].bitrate \/ 5) {\n\t\t\t*offset = kk;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn true;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":508826,"func":"void st_select_lex_node::include_global(st_select_lex_node **plink)\n{\n  if ((link_next= *plink))\n    link_next->link_prev= &link_next;\n  link_prev= plink;\n  *plink= this;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":424945,"func":"static int iwl_trans_pcie_clear_persistence_bit(struct iwl_trans *trans)\n{\n\tu32 hpm, wprot;\n\n\tswitch (trans->trans_cfg->device_family) {\n\tcase IWL_DEVICE_FAMILY_9000:\n\t\twprot = PREG_PRPH_WPROT_9000;\n\t\tbreak;\n\tcase IWL_DEVICE_FAMILY_22000:\n\t\twprot = PREG_PRPH_WPROT_22000;\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\thpm = iwl_read_umac_prph_no_grab(trans, HPM_DEBUG);\n\tif (hpm != 0xa5a5a5a0 && (hpm & PERSISTENCE_BIT)) {\n\t\tu32 wprot_val = iwl_read_umac_prph_no_grab(trans, wprot);\n\n\t\tif (wprot_val & PREG_WFPM_ACCESS) {\n\t\t\tIWL_ERR(trans,\n\t\t\t\t\"Error, can not clear persistence bit\\n\");\n\t\t\treturn -EPERM;\n\t\t}\n\t\tiwl_write_umac_prph_no_grab(trans, HPM_DEBUG,\n\t\t\t\t\t    hpm & ~PERSISTENCE_BIT);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":413653,"func":"R_API void r_core_anal_coderefs(RCore *core, ut64 addr) {\n\tRAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, -1);\n\tif (fcn) {\n\t\tconst char *me = fcn->name;\n\t\tRListIter *iter;\n\t\tRAnalRef *ref;\n\t\tRList *refs = r_anal_function_get_refs (fcn);\n\t\tr_cons_printf (\"agn %s\\n\", me);\n\t\tr_list_foreach (refs, iter, ref) {\n\t\t\tr_strf_buffer (32);\n\t\t\tRFlagItem *item = r_flag_get_i (core->flags, ref->addr);\n\t\t\tconst char *dst = item? item->name: r_strf (\"0x%08\"PFMT64x, ref->addr);\n\t\t\tr_cons_printf (\"agn %s\\n\", dst);\n\t\t\tr_cons_printf (\"age %s %s\\n\", me, dst);\n\t\t}\n\t\tr_list_free (refs);\n\t} else {\n\t\teprintf(\"Not in a function. Use 'df' to define it.\\n\");\n\t}\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":508925,"func":"void st_select_lex::collect_grouping_fields(THD *thd) \n{\n  grouping_tmp_fields.empty();\n  List_iterator<Item> li(join->fields_list);\n  Item *item= li++;\n  for (uint i= 0; i < master_unit()->derived->table->s->fields; i++, (item=li++))\n  {\n    for (ORDER *ord= join->group_list; ord; ord= ord->next)\n    {\n      if ((*ord->item)->eq((Item*)item, 0))\n      {\n\tGrouping_tmp_field *grouping_tmp_field= \n\t  new Grouping_tmp_field(master_unit()->derived->table->field[i], item);\n\tgrouping_tmp_fields.push_back(grouping_tmp_field);\n      }\n    }\n  }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":225674,"func":"\nGF_Box *pasp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_PixelAspectRatioBox, GF_ISOM_BOX_TYPE_PASP);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":362306,"func":"static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)\n{\n\tstruct snd_usb_audio *chip = usb_get_intfdata(intf);\n\tstruct snd_usb_stream *as;\n\tstruct usb_mixer_interface *mixer;\n\tstruct list_head *p;\n\n\tif (chip == (void *)-1L)\n\t\treturn 0;\n\n\tchip->autosuspended = !!PMSG_IS_AUTO(message);\n\tif (!chip->autosuspended)\n\t\tsnd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);\n\tif (!chip->num_suspended_intf++) {\n\t\tlist_for_each_entry(as, &chip->pcm_list, list) {\n\t\t\tsnd_pcm_suspend_all(as->pcm);\n\t\t\tsnd_usb_pcm_suspend(as);\n\t\t\tas->substream[0].need_setup_ep =\n\t\t\t\tas->substream[1].need_setup_ep = true;\n\t\t}\n\t\tlist_for_each(p, &chip->midi_list)\n\t\t\tsnd_usbmidi_suspend(p);\n\t\tlist_for_each_entry(mixer, &chip->mixer_list, list)\n\t\t\tsnd_usb_mixer_suspend(mixer);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":275986,"func":"uECC_VLI_API void uECC_vli_nativeToBytes(uint8_t *bytes,\n                                         int num_bytes,\n                                         const uECC_word_t *native) {\n    wordcount_t i;\n    for (i = 0; i < num_bytes; ++i) {\n        unsigned b = num_bytes - 1 - i;\n        bytes[i] = native[b \/ uECC_WORD_SIZE] >> (8 * (b % uECC_WORD_SIZE));\n    }\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":438666,"func":"static void rpmsg_upref_sleepers(struct virtproc_info *vrp)\n{\n\t\/* support multiple concurrent senders *\/\n\tmutex_lock(&vrp->tx_lock);\n\n\t\/* are we the first sleeping context waiting for tx buffers ? *\/\n\tif (atomic_inc_return(&vrp->sleepers) == 1)\n\t\t\/* enable \"tx-complete\" interrupts before dozing off *\/\n\t\tvirtqueue_enable_cb(vrp->svq);\n\n\tmutex_unlock(&vrp->tx_lock);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":244245,"func":"GF_Err proj_type_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ProjectionTypeBox *ptr = (GF_ProjectionTypeBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tif (ptr->type==GF_ISOM_BOX_TYPE_CBMP) {\n\t\tgf_bs_write_u32(bs, ptr->layout);\n\t\tgf_bs_write_u32(bs, ptr->padding);\n\t}\n\telse if (ptr->type==GF_ISOM_BOX_TYPE_EQUI) {\n\t\tgf_bs_write_u32(bs, ptr->bounds_top);\n\t\tgf_bs_write_u32(bs, ptr->bounds_bottom);\n\t\tgf_bs_write_u32(bs, ptr->bounds_left);\n\t\tgf_bs_write_u32(bs, ptr->bounds_right);\n\t} else {\n\t\tgf_bs_write_u32(bs, ptr->crc);\n\t\tgf_bs_write_u32(bs, ptr->encoding_4cc);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":225852,"func":"\nGF_Box *trgt_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackGroupTypeBox, GF_ISOM_BOX_TYPE_TRGT);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":310065,"func":"usage(void)\n{\n    static const char *msg[] =\n    {\n\t\"Usage: dots_termcap [options]\"\n\t,\"\"\n\t,\"Options:\"\n\t,\" -T TERM  override $TERM\"\n#if HAVE_USE_ENV\n\t,\" -e       allow environment $LINES \/ $COLUMNS\"\n#endif\n\t,\" -f       use tigetnum rather than <term.h> mapping\"\n\t,\" -m SIZE  set margin (default: 2)\"\n\t,\" -r SECS  self-interrupt\/exit after specified number of seconds\"\n\t,\" -s MSECS delay 1% of the time (default: 1 msecs)\"\n    };\n    size_t n;\n\n    for (n = 0; n < SIZEOF(msg); n++)\n\tfprintf(stderr, \"%s\\n\", msg[n]);\n\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":294724,"func":"f_kind_of_p(VALUE x, VALUE c)\n{\n    return rb_obj_is_kind_of(x, c);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":205736,"func":"static inline void fuse_make_bad(struct inode *inode)\n{\n\tset_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);\n}","target":1,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":513080,"func":"  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)\n  {\n    return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);\n  }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":336130,"func":"static void __net_exit ip6gre_exit_net(struct net *net)\n{\n\tLIST_HEAD(list);\n\n\trtnl_lock();\n\tip6gre_destroy_tunnels(net, &list);\n\tunregister_netdevice_many(&list);\n\trtnl_unlock();\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":275510,"func":"njs_vm_memory_pool(njs_vm_t *vm)\n{\n    return vm->mem_pool;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":364756,"func":"tagstack_push_item(\n\twin_T\t*wp,\n\tchar_u\t*tagname,\n\tint\tcur_fnum,\n\tint\tcur_match,\n\tpos_T\tmark,\n\tint\tfnum,\n\tchar_u  *user_data)\n{\n    taggy_T\t*tagstack = wp->w_tagstack;\n    int\t\tidx = wp->w_tagstacklen;\t\/\/ top of the stack\n\n    \/\/ if the tagstack is full: remove the oldest entry\n    if (idx >= TAGSTACKSIZE)\n    {\n\ttagstack_shift(wp);\n\tidx = TAGSTACKSIZE - 1;\n    }\n\n    wp->w_tagstacklen++;\n    tagstack[idx].tagname = tagname;\n    tagstack[idx].cur_fnum = cur_fnum;\n    tagstack[idx].cur_match = cur_match;\n    if (tagstack[idx].cur_match < 0)\n\ttagstack[idx].cur_match = 0;\n    tagstack[idx].fmark.mark = mark;\n    tagstack[idx].fmark.fnum = fnum;\n    tagstack[idx].user_data = user_data;\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":506440,"func":"static struct auth_request *mech_rpa_auth_new(void)\n{\n\tstruct rpa_auth_request *request;\n\tpool_t pool;\n\n\tpool = pool_alloconly_create(MEMPOOL_GROWING\"rpa_auth_request\", 2048);\n\trequest = p_new(pool, struct rpa_auth_request, 1);\n\trequest->pool = pool;\n\trequest->phase = 0;\n\n\trequest->auth_request.pool = pool;\n\treturn &request->auth_request;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":463197,"func":"static int annotation_set_todb(annotate_state_t *state,\n                               struct annotate_entry_list *entry,\n                               int maywrite)\n{\n    int r = 0;\n\n    if (entry->have_shared)\n        r = write_entry(state->mailbox, state->uid,\n                        entry->name, \"\",\n                        &entry->shared, 0, state->silent, NULL, maywrite);\n    if (!r && entry->have_priv)\n        r = write_entry(state->mailbox, state->uid,\n                        entry->name, state->userid,\n                        &entry->priv, 0, state->silent, NULL, maywrite);\n\n    return r;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":484729,"func":"void mobi_buffer_resize(MOBIBuffer *buf, const size_t newlen) {\n    unsigned char *tmp = realloc(buf->data, newlen);\n    if (tmp == NULL) {\n        debug_print(\"%s\", \"Buffer allocation failed\\n\");\n        buf->error = MOBI_MALLOC_FAILED;\n        return;\n    }\n    buf->data = tmp;\n    buf->maxlen = newlen;\n    if (buf->offset >= newlen) {\n        buf->offset = newlen - 1;\n    }\n    debug_print(\"Buffer successfully resized to %zu\\n\", newlen);\n    buf->error = MOBI_SUCCESS;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":385925,"func":"static inline int check_sticky(struct inode *dir, struct inode *inode)\n{\n\tkuid_t fsuid = current_fsuid();\n\n\tif (!(dir->i_mode & S_ISVTX))\n\t\treturn 0;\n\tif (uid_eq(inode->i_uid, fsuid))\n\t\treturn 0;\n\tif (uid_eq(dir->i_uid, fsuid))\n\t\treturn 0;\n\treturn !inode_capable(inode, CAP_FOWNER);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":281053,"func":"static const void *xfrm_get_dst_nexthop(const struct dst_entry *dst,\n\t\t\t\t\tconst void *daddr)\n{\n\tconst struct dst_entry *path = dst->path;\n\n\tfor (; dst != path; dst = dst->child) {\n\t\tconst struct xfrm_state *xfrm = dst->xfrm;\n\n\t\tif (xfrm->props.mode == XFRM_MODE_TRANSPORT)\n\t\t\tcontinue;\n\t\tif (xfrm->type->flags & XFRM_TYPE_REMOTE_COADDR)\n\t\t\tdaddr = xfrm->coaddr;\n\t\telse if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR))\n\t\t\tdaddr = &xfrm->id.daddr;\n\t}\n\treturn daddr;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":293525,"func":"PJ_DEF(void) pj_cis_add_num(pj_cis_t *cis)\n{\n    pj_cis_add_range( cis, '0', '9'+1);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":225118,"func":"uint64 RepeatedAttrDefHash(\n    const protobuf::RepeatedPtrField<OpDef::AttrDef>& a) {\n  \/\/ Insert AttrDefs into map to deterministically sort by name\n  std::map<string, const OpDef::AttrDef*> a_set;\n  for (const OpDef::AttrDef& def : a) {\n    a_set[def.name()] = &def;\n  }\n  \/\/ Iterate and combines hashes of keys and values\n  uint64 h = 0xDECAFCAFFE;\n  for (const auto& pair : a_set) {\n    h = Hash64(pair.first.data(), pair.first.size(), h);\n    h = Hash64Combine(AttrDefHash(*pair.second), h);\n  }\n  return h;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":383331,"func":"gdImageColorDeallocate (gdImagePtr im, int color)\n{\n  if (im->trueColor)\n    {\n      return;\n    }\n  \/* Mark it open. *\/\n  im->open[color] = 1;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":398539,"func":"static inline RzBinDwarfLocRange *create_loc_range(ut64 start, ut64 end, RzBinDwarfBlock *block) {\n\tRzBinDwarfLocRange *range = RZ_NEW0(RzBinDwarfLocRange);\n\tif (range) {\n\t\trange->start = start;\n\t\trange->end = end;\n\t\trange->expression = block;\n\t}\n\treturn range;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":294369,"func":"d_lite_zero(VALUE x)\n{\n    return INT2FIX(0);\n}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":317144,"func":"static void smack_task_getsecid_subj(struct task_struct *p, u32 *secid)\n{\n\tstruct smack_known *skp = smk_of_task_struct_subj(p);\n\n\t*secid = skp->smk_secid;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":238598,"func":"static void mark_stack_slot_scratched(struct bpf_verifier_env *env, u32 spi)\n{\n\tenv->scratched_stack_slots |= 1ULL << spi;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":474458,"func":"IsObjectPresent(\n\t\tTPMI_DH_OBJECT   handle         \/\/ IN: handle to be checked\n\t\t)\n{\n    UINT32          slotIndex = handle - TRANSIENT_FIRST;\n    \/\/ Since the handle is just an index into the array that is zero based, any\n    \/\/ handle value outsize of the range of:\n    \/\/    TRANSIENT_FIRST -- (TRANSIENT_FIRST + MAX_LOADED_OBJECT - 1)\n    \/\/ will now be greater than or equal to MAX_LOADED_OBJECTS\n    if(slotIndex >= MAX_LOADED_OBJECTS)\n\treturn FALSE;\n    \/\/ Indicate if the slot is occupied\n    return (s_objects[slotIndex].attributes.occupied == TRUE);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":440876,"func":"LogWrite(int verb, const char *f, ...)\n{\n    va_list args;\n\n    va_start(args, f);\n    LogVWrite(verb, f, args);\n    va_end(args);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":301379,"func":"static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf)\n{\n\treturn sys_statvfs(path, statbuf);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":225631,"func":"\nvoid proj_type_box_del(GF_Box *s)\n{\n\tgf_free(s);","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":421398,"func":"const char *jsP_aststring(enum js_AstType type)\n{\n\tif (type < nelem(astname)-1)\n\t\treturn astname[type];\n\treturn \"<unknown>\";\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":259184,"func":"static int mov_read_schm(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    MOVStreamContext *sc;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n    sc = st->priv_data;\n\n    if (sc->pseudo_stream_id != 0) {\n        av_log(c->fc, AV_LOG_ERROR, \"schm boxes are only supported in first sample descriptor\\n\");\n        return AVERROR_PATCHWELCOME;\n    }\n\n    if (atom.size < 8)\n        return AVERROR_INVALIDDATA;\n\n    avio_rb32(pb); \/* version and flags *\/\n\n    if (!sc->cenc.default_encrypted_sample) {\n        sc->cenc.default_encrypted_sample = av_encryption_info_alloc(0, 16, 16);\n        if (!sc->cenc.default_encrypted_sample) {\n            return AVERROR(ENOMEM);\n        }\n    }\n\n    sc->cenc.default_encrypted_sample->scheme = avio_rb32(pb);\n    return 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":300822,"func":"static int tipc_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk;\n\n\t\/*\n\t * Exit if socket isn't fully initialized (occurs when a failed accept()\n\t * releases a pre-allocated child socket that was never used)\n\t *\/\n\tif (sk == NULL)\n\t\treturn 0;\n\n\ttsk = tipc_sk(sk);\n\tlock_sock(sk);\n\n\ttrace_tipc_sk_release(sk, NULL, TIPC_DUMP_ALL, \" \");\n\t__tipc_shutdown(sock, TIPC_ERR_NO_PORT);\n\tsk->sk_shutdown = SHUTDOWN_MASK;\n\ttipc_sk_leave(tsk);\n\ttipc_sk_withdraw(tsk, NULL);\n\t__skb_queue_purge(&tsk->mc_method.deferredq);\n\tsk_stop_timer(sk, &sk->sk_timer);\n\ttipc_sk_remove(tsk);\n\n\tsock_orphan(sk);\n\t\/* Reject any messages that accumulated in backlog queue *\/\n\trelease_sock(sk);\n\ttipc_dest_list_purge(&tsk->cong_links);\n\ttsk->cong_link_cnt = 0;\n\tcall_rcu(&tsk->rcu, tipc_sk_callback);\n\tsock->sk = NULL;\n\n\treturn 0;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":281077,"func":"static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,\n\t\t\t\t\t\t const struct flowi *fl, u16 family)\n{\n\tstruct xfrm_policy *pol;\n\n\trcu_read_lock();\n again:\n\tpol = rcu_dereference(sk->sk_policy[dir]);\n\tif (pol != NULL) {\n\t\tbool match = xfrm_selector_match(&pol->selector, fl, family);\n\t\tint err = 0;\n\n\t\tif (match) {\n\t\t\tif ((sk->sk_mark & pol->mark.m) != pol->mark.v) {\n\t\t\t\tpol = NULL;\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\terr = security_xfrm_policy_lookup(pol->security,\n\t\t\t\t\t\t      fl->flowi_secid,\n\t\t\t\t\t\t      policy_to_flow_dir(dir));\n\t\t\tif (!err) {\n\t\t\t\tif (!xfrm_pol_hold_rcu(pol))\n\t\t\t\t\tgoto again;\n\t\t\t} else if (err == -ESRCH) {\n\t\t\t\tpol = NULL;\n\t\t\t} else {\n\t\t\t\tpol = ERR_PTR(err);\n\t\t\t}\n\t\t} else\n\t\t\tpol = NULL;\n\t}\nout:\n\trcu_read_unlock();\n\treturn pol;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":248306,"func":"static void cfg_handle_deprecated(cfg_t *cfg, cfg_opt_t *opt)\n{\n\tif (is_set(CFGF_DROP, opt->flags)) {\n\t\tcfg_error(cfg, _(\"dropping deprecated configuration option '%s'\"), opt->name);\n\t\tcfg_free_value(opt);\n\t} else {\n\t\tcfg_error(cfg, _(\"found deprecated option '%s', please update configuration file.\"), opt->name);\n\t}\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":473957,"func":"koi8_u_get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t  const OnigUChar* p, const OnigUChar* end,\n\t\t  OnigCaseFoldCodeItem items[], OnigEncoding enc ARG_UNUSED)\n{\n  return onigenc_get_case_fold_codes_by_str_with_map(\n\t     sizeof(CaseFoldMap)\/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,\n\t     flag, p, end, items);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":244292,"func":"GF_Box *emsg_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_EventMessageBox, GF_ISOM_BOX_TYPE_EMSG);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":477272,"func":"void tipc_crypto_msg_rcv(struct net *net, struct sk_buff *skb)\n{\n\tstruct tipc_crypto *rx;\n\tstruct tipc_msg *hdr;\n\n\tif (unlikely(skb_linearize(skb)))\n\t\tgoto exit;\n\n\thdr = buf_msg(skb);\n\trx = tipc_node_crypto_rx_by_addr(net, msg_prevnode(hdr));\n\tif (unlikely(!rx))\n\t\tgoto exit;\n\n\tswitch (msg_type(hdr)) {\n\tcase KEY_DISTR_MSG:\n\t\tif (tipc_crypto_key_rcv(rx, hdr))\n\t\t\tgoto exit;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\ttipc_node_put(rx->node);\n\nexit:\n\tkfree_skb(skb);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":336491,"func":"static void reds_mig_target_client_disconnect_all(RedsState *reds)\n{\n    RedsMigTargetClient *mig_client;\n\n    GLIST_FOREACH(reds->mig_target_clients, RedsMigTargetClient, mig_client) {\n        reds_client_disconnect(reds, mig_client->client);\n    }\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":413841,"func":"void CallInfo::set_resolved_method_name(TRAPS) {\n  assert(_resolved_method() != NULL, \"Should already have a Method*\");\n  oop rmethod_name = java_lang_invoke_ResolvedMethodName::find_resolved_method(_resolved_method, CHECK);\n  _resolved_method_name = Handle(THREAD, rmethod_name);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":463114,"func":"static void annotation_get_freespace_total(annotate_state_t *state,\n                     struct annotate_entry_list *entry)\n{\n    uint64_t tavail = 0;\n    uint64_t ttotal = 0;\n    struct buf value = BUF_INITIALIZER;\n\n    (void) partlist_local_find_freespace_most(0, NULL, NULL, &tavail, &ttotal);\n    buf_printf(&value, \"%\" PRIuMAX \";%\" PRIuMAX, (uintmax_t)tavail, (uintmax_t)ttotal);\n    output_entryatt(state, entry->name, \"\", &value);\n    buf_free(&value);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":249957,"func":"__old_realpath (const char *name, char *resolved)\n{\n  if (resolved == NULL)\n    {\n      __set_errno (EINVAL);\n      return NULL;\n    }\n\n  return __realpath (name, resolved);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":450420,"func":"static void audio_capture(void *opaque, void *buf, int size)\n{\n    VncState *vs = opaque;\n\n    assert(vs->magic == VNC_MAGIC);\n    vnc_lock_output(vs);\n    if (vs->output.offset < vs->throttle_output_offset) {\n        vnc_write_u8(vs, VNC_MSG_SERVER_QEMU);\n        vnc_write_u8(vs, VNC_MSG_SERVER_QEMU_AUDIO);\n        vnc_write_u16(vs, VNC_MSG_SERVER_QEMU_AUDIO_DATA);\n        vnc_write_u32(vs, size);\n        vnc_write(vs, buf, size);\n    } else {\n        trace_vnc_client_throttle_audio(vs, vs->ioc, vs->output.offset);\n    }\n    vnc_unlock_output(vs);\n    vnc_flush(vs);\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":222522,"func":"Status AddDefaultAttrs(const string& op,\n                       const GetFunctionSignature& get_function,\n                       AttrValueMap* attrs) {\n  const OpDef* op_def = nullptr;\n  TF_RETURN_IF_ERROR(get_function(op, &op_def));\n  AttrSlice attr_slice(attrs);\n  for (const auto& attr_def : op_def->attr()) {\n    if (attr_def.has_default_value() && !attr_slice.Find(attr_def.name())) {\n      if (!attrs->insert({attr_def.name(), attr_def.default_value()}).second) {\n        return errors::Internal(\"Somehow duplicated: \", attr_def.name());\n      }\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":366285,"func":"static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)\n{\n\tif (mnt->mnt.mnt_sb->s_flags & SB_NOUSER)\n\t\treturn -EINVAL;\n\n\tif (d_is_dir(mp->m_dentry) !=\n\t      d_is_dir(mnt->mnt.mnt_root))\n\t\treturn -ENOTDIR;\n\n\treturn attach_recursive_mnt(mnt, p, mp, false);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":462434,"func":"destructSess(ptcpsess_t *pSess)\n{\n\tfree(pSess->pMsg);\n\tfree(pSess->epd);\n\tprop.Destruct(&pSess->peerName);\n\tprop.Destruct(&pSess->peerIP);\n\t\/* TODO: make these inits compile-time switch depending: *\/\n\tpSess->pMsg = NULL;\n\tpSess->epd = NULL;\n\tfree(pSess);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":376349,"func":"camel_gpg_context_set_always_trust (CamelGpgContext *context,\n                                    gboolean always_trust)\n{\n\tg_return_if_fail (CAMEL_IS_GPG_CONTEXT (context));\n\n\tif (context->priv->always_trust == always_trust)\n\t\treturn;\n\n\tcontext->priv->always_trust = always_trust;\n\n\tg_object_notify (G_OBJECT (context), \"always-trust\");\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":369127,"func":"static void ctx_flush_and_put(struct io_ring_ctx *ctx, bool *locked)\n{\n\tif (!ctx)\n\t\treturn;\n\tif (*locked) {\n\t\tio_submit_flush_completions(ctx);\n\t\tmutex_unlock(&ctx->uring_lock);\n\t\t*locked = false;\n\t}\n\tpercpu_ref_put(&ctx->refs);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":344260,"func":"l_noret luaG_callerror (lua_State *L, const TValue *o) {\n  CallInfo *ci = L->ci;\n  const char *name = NULL;  \/* to avoid warnings *\/\n  const char *kind = funcnamefromcall(L, ci, &name);\n  const char *extra = kind ? formatvarinfo(L, kind, name) : varinfo(L, o);\n  typeerror(L, o, \"call\", extra);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":512677,"func":"    Print(Item *item, enum_query_type type)\n    {\n      item->print(this, type);\n    }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":289237,"func":"static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file)\n{\n\tstruct snd_pcm_substream *substream;\n\tint err;\n\t\n\terr = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);\n\tif (err < 0)\n\t\treturn err;\n\treturn substream->runtime->oss.rate;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":328953,"func":"R_API RBinJavaCPTypeObj *r_bin_java_clone_cp_item(RBinJavaCPTypeObj *obj) {\n\tRBinJavaCPTypeObj *clone_obj = NULL;\n\tif (!obj) {\n\t\treturn clone_obj;\n\t}\n\tclone_obj = R_NEW0 (RBinJavaCPTypeObj);\n\tif (clone_obj) {\n\t\tmemcpy (clone_obj, obj, sizeof (RBinJavaCPTypeObj));\n\t\tclone_obj->metas = (RBinJavaMetaInfo *) R_NEW0 (RBinJavaMetaInfo);\n\t\tclone_obj->metas->type_info = (void *) &R_BIN_JAVA_CP_METAS[clone_obj->tag];\n\t\tclone_obj->name = strdup (obj->name? obj->name: \"unk\");\n\t\tif (obj->tag == R_BIN_JAVA_CP_UTF8) {\n\t\t\tclone_obj->info.cp_utf8.bytes = (ut8 *) malloc (obj->info.cp_utf8.length + 1);\n\t\t\tif (clone_obj->info.cp_utf8.bytes) {\n\t\t\t\tmemcpy (clone_obj->info.cp_utf8.bytes, obj->info.cp_utf8.bytes, clone_obj->info.cp_utf8.length);\n\t\t\t} else {\n\t\t\t\t\/\/ TODO: eprintf allocation error\n\t\t\t}\n\t\t}\n\t}\n\treturn clone_obj;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":459016,"func":"http_TimeHeader(struct http *to, const char *fmt, vtim_real now)\n{\n\tchar *p;\n\n\tCHECK_OBJ_NOTNULL(to, HTTP_MAGIC);\n\tif (to->nhd >= to->shd) {\n\t\tVSLbs(to->vsl, SLT_LostHeader, TOSTRAND(fmt));\n\t\thttp_fail(to);\n\t\treturn;\n\t}\n\tp = WS_Alloc(to->ws, strlen(fmt) + VTIM_FORMAT_SIZE);\n\tif (p == NULL) {\n\t\thttp_fail(to);\n\t\tVSLbs(to->vsl, SLT_LostHeader, TOSTRAND(fmt));\n\t\treturn;\n\t}\n\tstrcpy(p, fmt);\n\tVTIM_format(now, strchr(p, '\\0'));\n\thttp_SetH(to, to->nhd++, p);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":512786,"func":"  uint32 max_display_length() const { return field->max_display_length(); }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":301420,"func":"static bool vfswrap_is_offline(struct vfs_handle_struct *handle,\n\t\t\t       const struct smb_filename *fname,\n\t\t\t       SMB_STRUCT_STAT *sbuf)\n{\n\tNTSTATUS status;\n\tchar *path;\n\tbool offline = false;\n\n        if (ISDOT(fname->base_name) || ISDOTDOT(fname->base_name)) {\n\t\treturn false;\n\t}\n\n\tif (!lp_dmapi_support(SNUM(handle->conn)) || !dmapi_have_session()) {\n#if defined(ENOTSUP)\n\t\terrno = ENOTSUP;\n#endif\n\t\treturn false;\n\t}\n\n        status = get_full_smb_filename(talloc_tos(), fname, &path);\n        if (!NT_STATUS_IS_OK(status)) {\n                errno = map_errno_from_nt_status(status);\n                return false;\n        }\n\n\toffline = (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0;\n\n\tTALLOC_FREE(path);\n\n\treturn offline;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":482504,"func":"compileString(const char *inString, TranslationTableHeader **table,\n\t\tDisplayTableHeader **displayTable) {\n\t\/* This function can be used to make changes to tables on the fly. *\/\n\tint k;\n\tFileInfo file;\n\tif (inString == NULL) return 0;\n\tmemset(&file, 0, sizeof(file));\n\tfile.fileName = inString;\n\tfile.encoding = noEncoding;\n\tfile.lineNumber = 1;\n\tfile.status = 0;\n\tfile.linepos = 0;\n\tfor (k = 0; inString[k]; k++) file.line[k] = inString[k];\n\tfile.line[k] = 0;\n\tfile.linelen = k;\n\tif (table && *table && (*table)->finalized) {\n\t\tcompileError(&file, \"Table is finalized\");\n\t\treturn 0;\n\t}\n\treturn compileRule(&file, table, displayTable, NULL);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":274862,"func":"TEST(ComparisonsTest, LessFloat) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 4}, TensorType_FLOAT32,\n                          BuiltinOperator_LESS);\n  model.PopulateTensor<float>(model.input1(), {0.1, 0.9, 0.7, 0.3});\n  model.PopulateTensor<float>(model.input2(), {0.1, 0.2, 0.6, 0.5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, false, false, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":329920,"func":"_cairo_image_scaled_glyph_fini (cairo_scaled_font_t *scaled_font,\n\t\t\t\tcairo_scaled_glyph_t *scaled_glyph)\n{\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":503989,"func":"auth_request_get_var_expand_table(const struct auth_request *auth_request,\n\t\t\t\t  auth_request_escape_func_t *escape_func)\n{\n\tunsigned int count = 0;\n\n\treturn auth_request_get_var_expand_table_full(auth_request, escape_func,\n\t\t\t\t\t\t      &count);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":312437,"func":"qf_entry_on_or_before_pos(qfline_T *qfp, pos_T *pos, int linewise)\n{\n    if (linewise)\n\treturn qfp->qf_lnum <= pos->lnum;\n    else\n\treturn (qfp->qf_lnum < pos->lnum ||\n\t\t(qfp->qf_lnum == pos->lnum && qfp->qf_col <= pos->col));\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":348434,"func":"static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,\n\tconst char *fp, int count)\n{\n\tstruct mkiss *ax = mkiss_get(tty);\n\n\tif (!ax)\n\t\treturn;\n\n\t\/*\n\t * Argh! mtu change time! - costs us the packet part received\n\t * at the change\n\t *\/\n\tif (ax->mtu != ax->dev->mtu + 73)\n\t\tax_changedmtu(ax);\n\n\t\/* Read the characters out of the buffer *\/\n\twhile (count--) {\n\t\tif (fp != NULL && *fp++) {\n\t\t\tif (!test_and_set_bit(AXF_ERROR, &ax->flags))\n\t\t\t\tax->dev->stats.rx_errors++;\n\t\t\tcp++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tkiss_unesc(ax, *cp++);\n\t}\n\n\tmkiss_put(ax);\n\ttty_unthrottle(tty);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":359289,"func":"DEFUN (clear_ip_bgp_peer,\n       clear_ip_bgp_peer_cmd, \n       \"clear ip bgp (A.B.C.D|X:X::X:X)\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"BGP neighbor IP address to clear\\n\"\n       \"BGP IPv6 neighbor to clear\\n\")\n{\n  return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":234797,"func":"void btrfs_close_devices(struct btrfs_fs_devices *fs_devices)\n{\n\tLIST_HEAD(list);\n\tstruct btrfs_fs_devices *tmp;\n\n\tmutex_lock(&uuid_mutex);\n\tclose_fs_devices(fs_devices);\n\tif (!fs_devices->opened)\n\t\tlist_splice_init(&fs_devices->seed_list, &list);\n\n\tlist_for_each_entry_safe(fs_devices, tmp, &list, seed_list) {\n\t\tclose_fs_devices(fs_devices);\n\t\tlist_del(&fs_devices->seed_list);\n\t\tfree_fs_devices(fs_devices);\n\t}\n\tmutex_unlock(&uuid_mutex);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":226322,"func":"GF_Err gnrm_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":225630,"func":"\nGF_Err pcmC_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_PCMConfigBox *ptr = (GF_PCMConfigBox *) s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u8(bs, ptr->format_flags);\n\tgf_bs_write_u8(bs, ptr->PCM_sample_size);\n\treturn GF_OK;","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":405396,"func":"xfrm_pol_inexact_node_alloc(const xfrm_address_t *addr, u8 prefixlen)\n{\n\tstruct xfrm_pol_inexact_node *node;\n\n\tnode = kzalloc(sizeof(*node), GFP_ATOMIC);\n\tif (node)\n\t\txfrm_pol_inexact_node_init(node, addr, prefixlen);\n\n\treturn node;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":336506,"func":"static void reds_handle_ssl_accept(int fd, int event, void *data)\n{\n    RedLinkInfo *link = (RedLinkInfo *)data;\n    RedStreamSslStatus return_code = red_stream_ssl_accept(link->stream);\n\n    switch (return_code) {\n        case RED_STREAM_SSL_STATUS_ERROR:\n            reds_link_free(link);\n            return;\n        case RED_STREAM_SSL_STATUS_WAIT_FOR_READ:\n            red_watch_update_mask(link->stream->watch, SPICE_WATCH_EVENT_READ);\n            return;\n        case RED_STREAM_SSL_STATUS_WAIT_FOR_WRITE:\n            red_watch_update_mask(link->stream->watch, SPICE_WATCH_EVENT_WRITE);\n            return;\n        case RED_STREAM_SSL_STATUS_OK:\n            red_stream_remove_watch(link->stream);\n            reds_handle_new_link(link);\n    }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":332392,"func":"set_ref_in_opfunc(int copyID UNUSED)\n{\n    int abort = FALSE;\n\n    abort = set_ref_in_callback(&opfunc_cb, copyID);\n\n    return abort;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":314776,"func":"cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,\n    const cdf_header_t *h, cdf_secid_t id)\n{\n\tsize_t ss = CDF_SEC_SIZE(h);\n\tsize_t pos = CDF_SEC_POS(h, id);\n\tassert(ss == len);\n\treturn cdf_read(info, (off_t)pos, ((char *)buf) + offs, len);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":369210,"func":"\nstatic struct file *io_file_get_normal(struct io_kiocb *req, int fd)\n{\n\tstruct file *file = fget(fd);\n\n\ttrace_io_uring_file_get(req->ctx, req, req->user_data, fd);\n\n\t\/* we don't allow fixed io_uring files *\/\n\tif (file && file->f_op == &io_uring_fops)\n\t\treq->flags |= REQ_F_INFLIGHT;\n\treturn file;","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":259601,"func":"void HierarchicalBitmapRequester::PostImageHeight(ULONG lines)\n{\n  BitmapCtrl::PostImageHeight(lines);\n#if ACCUSOFT_CODE\n  assert(m_pulHeight);\n\n  if (m_pLargestScale)\n    m_pLargestScale->PostImageHeight(lines);\n  \n  for(UBYTE i = 0;i < m_ucCount;i++) {\n    class Component *comp = m_pFrame->ComponentOf(i);\n    UBYTE suby            = comp->SubYOf();\n    m_pulHeight[i]        = (m_ulPixelHeight + suby - 1) \/ suby;\n  }\n#endif\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":474065,"func":"st_insert(register st_table *table, register st_data_t key, st_data_t value)\n{\n    st_index_t hash_val, bin_pos;\n    register st_table_entry *ptr;\n\n    if (table->entries_packed) {\n        st_index_t i;\n        for (i = 0; i < table->num_entries; i++) {\n            if ((st_data_t)table->bins[i*2] == key) {\n                table->bins[i*2+1] = (struct st_table_entry*)value;\n                return 1;\n            }\n        }\n        if (MORE_PACKABLE_P(table)) {\n            i = table->num_entries++;\n            table->bins[i*2] = (struct st_table_entry*)key;\n            table->bins[i*2+1] = (struct st_table_entry*)value;\n            return 0;\n        }\n        else {\n            unpack_entries(table);\n        }\n    }\n\n    hash_val = do_hash(key, table);\n    FIND_ENTRY(table, ptr, hash_val, bin_pos);\n\n    if (ptr == 0) {\n\tADD_DIRECT(table, key, value, hash_val, bin_pos);\n\treturn 0;\n    }\n    else {\n\tptr->record = value;\n\treturn 1;\n    }\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":225115,"func":"void AddComma(string* s, bool* add_comma) {\n  if (*add_comma) {\n    strings::StrAppend(s, \", \");\n  } else {\n    *add_comma = true;\n  }\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":309824,"func":"NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx\n\t\t\t   attr_t newmode,\n\t\t\t   NCURSES_PAIRS_T pair_arg,\n\t\t\t   void *opts)\n{\n    T((T_CALLED(\"vid_attr(%s,%d)\"), _traceattr(newmode), (int) pair_arg));\n    returnCode(NCURSES_SP_NAME(vid_puts) (NCURSES_SP_ARGx\n\t\t\t\t\t  newmode,\n\t\t\t\t\t  pair_arg,\n\t\t\t\t\t  opts,\n\t\t\t\t\t  NCURSES_SP_NAME(_nc_putchar)));\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":512703,"func":"  virtual const char *full_name() const { return name.str ? name.str : \"???\"; }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":459213,"func":"int tcf_qevent_validate_change(struct tcf_qevent *qe, struct nlattr *block_index_attr,\n\t\t\t       struct netlink_ext_ack *extack)\n{\n\tu32 block_index;\n\tint err;\n\n\tif (!block_index_attr)\n\t\treturn 0;\n\n\terr = tcf_qevent_parse_block_index(block_index_attr, &block_index, extack);\n\tif (err)\n\t\treturn err;\n\n\t\/* Bounce newly-configured block or change in block. *\/\n\tif (block_index != qe->info.block_index) {\n\t\tNL_SET_ERR_MSG(extack, \"Change of blocks is not supported\");\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":344256,"func":"static int l_strcmp (const TString *ls, const TString *rs) {\n  const char *l = getstr(ls);\n  size_t ll = tsslen(ls);\n  const char *r = getstr(rs);\n  size_t lr = tsslen(rs);\n  for (;;) {  \/* for each segment *\/\n    int temp = strcoll(l, r);\n    if (temp != 0)  \/* not equal? *\/\n      return temp;  \/* done *\/\n    else {  \/* strings are equal up to a '\\0' *\/\n      size_t len = strlen(l);  \/* index of first '\\0' in both strings *\/\n      if (len == lr)  \/* 'rs' is finished? *\/\n        return (len == ll) ? 0 : 1;  \/* check 'ls' *\/\n      else if (len == ll)  \/* 'ls' is finished? *\/\n        return -1;  \/* 'ls' is less than 'rs' ('rs' is not finished) *\/\n      \/* both strings longer than 'len'; go on comparing after the '\\0' *\/\n      len++;\n      l += len; ll -= len; r += len; lr -= len;\n    }\n  }\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":262022,"func":"Proto_RequestNameToType(const gchar *name)\n{\n   int i;\n\n   for (i = 0; i < G_N_ELEMENTS(reqNameList); i++) {\n      if (g_strcmp0(name, reqNameList[i].reqName) == 0) {\n         return reqNameList[i].type;\n      }\n   }\n\n   return PROTO_REQUEST_UNKNOWN;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":264673,"func":"lexer_token_is_identifier (parser_context_t *context_p, \/**< context *\/\n                           const char *identifier_p, \/**< identifier *\/\n                           size_t identifier_length) \/**< identifier length *\/\n{\n  \/* Checking has_escape is unnecessary because memcmp will fail if escape sequences are present. *\/\n  return (context_p->token.type == LEXER_LITERAL && context_p->token.lit_location.type == LEXER_IDENT_LITERAL\n          && context_p->token.lit_location.length == identifier_length\n          && memcmp (context_p->token.lit_location.char_p, identifier_p, identifier_length) == 0);\n} \/* lexer_token_is_identifier *\/","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":221515,"func":"flatpak_run_get_pulse_runtime_dir (void)\n{\n  const char *val = NULL;\n\n  val = g_getenv (\"PULSE_RUNTIME_PATH\");\n\n  if (val != NULL)\n    return realpath (val, NULL);\n\n  {\n    const char *user_runtime_dir = g_get_user_runtime_dir ();\n\n    if (user_runtime_dir != NULL)\n      {\n        g_autofree char *dir = g_build_filename (user_runtime_dir, \"pulse\", NULL);\n\n        if (g_file_test (dir, G_FILE_TEST_IS_DIR))\n          return realpath (dir, NULL);\n      }\n  }\n\n  {\n    g_autofree char *pulse_home = flatpak_run_get_pulse_home ();\n    g_autofree char *machine_id = flatpak_run_get_pulse_machine_id ();\n\n    if (pulse_home != NULL && machine_id != NULL)\n      {\n        \/* This is usually a symlink, but we take its realpath() anyway *\/\n        g_autofree char *dir = g_strdup_printf (\"%s\/%s-runtime\", pulse_home, machine_id);\n\n        if (g_file_test (dir, G_FILE_TEST_IS_DIR))\n          return realpath (dir, NULL);\n      }\n  }\n\n  return NULL;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":301500,"func":"prof_init(void)\n{\n    for (int i = 0; i <= STATE_FINAL; ++i)\n    {\n\tprofile_zero(×[i]);\n\tcounts[i] = 0;\n    }\n    profile_start(¤t);\n    profile_start(&total);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":366204,"func":"static bool check_for_nsfs_mounts(struct mount *subtree)\n{\n\tstruct mount *p;\n\tbool ret = false;\n\n\tlock_mount_hash();\n\tfor (p = subtree; p; p = next_mnt(p, subtree))\n\t\tif (mnt_ns_loop(p->mnt.mnt_root))\n\t\t\tgoto out;\n\n\tret = true;\nout:\n\tunlock_mount_hash();\n\treturn ret;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":231635,"func":"  auto& idleTimeout() {\n    return idleTimeout_;\n  }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":254064,"func":"        char* pop(const std::string& name)\n        {\n            char* ret = get(name);\n            if (ret != nullptr)\n            {\n                for (unsigned int i = 0; i < key_value_pairs_.size(); i++)\n                {\n                    std::string str_item(key_value_pairs_[i]);\n                    if (str_item.substr(0, name.size() + 1) == name + '=')\n                    {\n                        key_value_pairs_.erase(key_value_pairs_.begin() + i);\n                        break;\n                    }\n                }\n            }\n            return ret;\n        }","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":359458,"func":"DEFUN (clear_bgp_all_rsclient,\n       clear_bgp_all_rsclient_cmd,\n       \"clear bgp * rsclient\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Soft reconfig for rsclient RIB\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,\n                          BGP_CLEAR_SOFT_RSCLIENT, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,\n                        BGP_CLEAR_SOFT_RSCLIENT, NULL);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":513106,"func":"  const Type_handler *type_handler() const { return (*ref)->type_handler(); }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":474436,"func":"GetQualifiedName(\n\t\t TPMI_DH_OBJECT   handle,        \/\/ IN: handle of the object\n\t\t TPM2B_NAME      *qualifiedName  \/\/ OUT: qualified name of the object\n\t\t )\n{\n    OBJECT      *object;\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n\t    qualifiedName->t.size = sizeof(TPM_HANDLE);\n\t    UINT32_TO_BYTE_ARRAY(handle, qualifiedName->t.name);\n\t    break;\n\t  case TPM_HT_TRANSIENT:\n\t    object = HandleToObject(handle);\n\t    if(object == NULL || object->publicArea.nameAlg == TPM_ALG_NULL)\n\t\tqualifiedName->t.size = 0;\n\t    else\n\t\t\/\/ Copy the name\n\t\t*qualifiedName = object->qualifiedName;\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n    return;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":512364,"func":"  Item_bool(THD *thd, bool i) :Item_int(thd, (longlong) i, 1) { }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":393470,"func":"static SQInteger get_slice_params(HSQUIRRELVM v,SQInteger &sidx,SQInteger &eidx,SQObjectPtr &o)\n{\n    SQInteger top = sq_gettop(v);\n    sidx=0;\n    eidx=0;\n    o=stack_get(v,1);\n    if(top>1){\n        SQObjectPtr &start=stack_get(v,2);\n        if(sq_type(start)!=OT_NULL && sq_isnumeric(start)){\n            sidx=tointeger(start);\n        }\n    }\n    if(top>2){\n        SQObjectPtr &end=stack_get(v,3);\n        if(sq_isnumeric(end)){\n            eidx=tointeger(end);\n        }\n    }\n    else {\n        eidx = sq_getsize(v,1);\n    }\n    return 1;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":508908,"func":"void LEX::cleanup_lex_after_parse_error(THD *thd)\n{\n  \/*\n    Delete sphead for the side effect of restoring of the original\n    LEX state, thd->lex, thd->mem_root and thd->free_list if they\n    were replaced when parsing stored procedure statements.  We\n    will never use sphead object after a parse error, so it's okay\n    to delete it only for the sake of the side effect.\n    TODO: make this functionality explicit in sp_head class.\n    Sic: we must nullify the member of the main lex, not the\n    current one that will be thrown away\n  *\/\n  if (thd->lex->sphead)\n  {\n    thd->lex->sphead->restore_thd_mem_root(thd);\n    sp_head::destroy(thd->lex->sphead);\n    thd->lex->sphead= NULL;\n  }\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":221498,"func":"add_ld_so_conf (FlatpakBwrap *bwrap,\n                GError      **error)\n{\n  const char *contents =\n    \"include \/run\/flatpak\/ld.so.conf.d\/app-*.conf\\n\"\n    \"include \/app\/etc\/ld.so.conf\\n\"\n    \"\/app\/lib\\n\"\n    \"include \/run\/flatpak\/ld.so.conf.d\/runtime-*.conf\\n\";\n\n  return flatpak_bwrap_add_args_data (bwrap, \"ld-so-conf\",\n                                      contents, -1, \"\/etc\/ld.so.conf\", error);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":226027,"func":"\nGF_Err void_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tgf_bs_write_u32(bs, 0);\n\treturn GF_OK;","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":226361,"func":"\nGF_Box *tsro_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TimeOffHintEntryBox, GF_ISOM_BOX_TYPE_TSRO);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":448560,"func":"static uint8_t *bgp_notify_encapsulate_hard_reset(uint8_t code, uint8_t subcode,\n\t\t\t\t\t\t  uint8_t *data, size_t datalen)\n{\n\tuint8_t *message = XCALLOC(MTYPE_BGP_NOTIFICATION, datalen + 2);\n\n\t\/* ErrCode *\/\n\tmessage[0] = code;\n\t\/* Subcode *\/\n\tmessage[1] = subcode;\n\t\/* Data *\/\n\tif (datalen)\n\t\tmemcpy(message + 2, data, datalen);\n\n\treturn message;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":255928,"func":"ShapeRefiner::~ShapeRefiner() {\n  \/\/ The lifetime of the tensors are bound to the GraphRunner, so the tensors\n  \/\/ should be deleted before it.\n  const_tensor_map_.clear();\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":484724,"func":"void mobi_buffer_getraw(void *data, MOBIBuffer *buf, const size_t len) {\n    if (!data) {\n        buf->error = MOBI_PARAM_ERR;\n        return;\n    }\n    if (buf->offset + len > buf->maxlen) {\n        debug_print(\"%s\", \"End of buffer\\n\");\n        buf->error = MOBI_BUFFER_END;\n        return;\n    }\n    memcpy(data, buf->data + buf->offset, len);\n    buf->offset += len;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":238635,"func":"int check_ptr_off_reg(struct bpf_verifier_env *env,\n\t\t      const struct bpf_reg_state *reg, int regno)\n{\n\treturn __check_ptr_off_reg(env, reg, regno, false);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":512945,"func":"  void fix_charset_and_length(CHARSET_INFO *cs,\n                              Derivation dv, Metadata metadata)\n  {\n    \/*\n      We have to have a different max_length than 'length' here to\n      ensure that we get the right length if we do use the item\n      to create a new table. In this case max_length must be the maximum\n      number of chars for a string of this type because we in Create_field::\n      divide the max_length with mbmaxlen).\n    *\/\n    collation.set(cs, dv, metadata.repertoire());\n    fix_char_length(metadata.char_length());\n    decimals= NOT_FIXED_DEC;\n  }","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":502724,"func":"SSL_SESSION *SSL_get1_session(SSL *ssl)\n\/* variant of SSL_get_session: caller really gets something *\/\n{\n    SSL_SESSION *sess;\n    \/*\n     * Need to lock this all up rather than just use CRYPTO_add so that\n     * somebody doesn't free ssl->session between when we check it's non-null\n     * and when we up the reference count.\n     *\/\n    CRYPTO_w_lock(CRYPTO_LOCK_SSL_SESSION);\n    sess = ssl->session;\n    if (sess)\n        sess->references++;\n    CRYPTO_w_unlock(CRYPTO_LOCK_SSL_SESSION);\n    return (sess);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":512371,"func":"  Item_int(THD *thd, longlong i,size_t length= MY_INT64_NUM_DECIMAL_DIGITS):\n    Item_num(thd), value(i)\n    { max_length=(uint32)length; }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":390559,"func":"_XkbFindNamedIndicatorMap(XkbSrvLedInfoPtr sli, Atom indicator,\n                          int *led_return)\n{\n    XkbIndicatorMapPtr  map;\n    int                 led;\n\n    \/* search for the right indicator *\/\n    map = NULL;\n    if (sli->names && sli->maps) {\n\tfor (led = 0; (led < XkbNumIndicators) && (map == NULL); led++) {\n\t    if (sli->names[led] == indicator) {\n\t\tmap= &sli->maps[led];\n\t\tbreak;\n\t    }\n\t}\n    }\n\n    *led_return = led;\n    return map;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":503857,"func":"SCM_DEFINE (scm_open_fdes, \"open-fdes\", 2, 1, 0, \n            (SCM path, SCM flags, SCM mode),\n\t    \"Similar to @code{open} but return a file descriptor instead of\\n\"\n\t    \"a port.\")\n#define FUNC_NAME s_scm_open_fdes\n{\n  int fd;\n  int iflags;\n  int imode;\n\n  iflags = SCM_NUM2INT (2, flags);\n  imode = SCM_NUM2INT_DEF (3, mode, 0666);\n  STRING_SYSCALL (path, c_path, fd = open_or_open64 (c_path, iflags, imode));\n  if (fd == -1)\n    SCM_SYSERROR;\n  return scm_from_int (fd);\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":477972,"func":"void simplestring_clear(simplestring* string) {\n   if(string->str) {\n      string->str[0] = 0;\n   }\n   string->len = 0;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":468381,"func":"g_socket_client_init (GSocketClient *client)\n{\n  client->priv = g_socket_client_get_instance_private (client);\n  client->priv->type = G_SOCKET_TYPE_STREAM;\n  client->priv->app_proxies = g_hash_table_new_full (g_str_hash,\n\t\t\t\t\t\t     g_str_equal,\n\t\t\t\t\t\t     g_free,\n\t\t\t\t\t\t     NULL);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":224762,"func":"void iref_box_del(GF_Box *s)\n{\n\tGF_ItemReferenceBox *ptr = (GF_ItemReferenceBox *)s;\n\tif (ptr == NULL) return;\n\tgf_list_del(ptr->references);\n\tgf_free(ptr);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":359368,"func":"DEFUN (show_bgp_summary, \n       show_bgp_summary_cmd,\n       \"show bgp summary\",\n       SHOW_STR\n       BGP_STR\n       \"Summary of BGP neighbor status\\n\")\n{\n  return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":275958,"func":"static uECC_word_t regularize_k(const uECC_word_t * const k,\n                                uECC_word_t *k0,\n                                uECC_word_t *k1,\n                                uECC_Curve curve) {\n    wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits);\n    bitcount_t num_n_bits = curve->num_n_bits;\n    uECC_word_t carry = uECC_vli_add(k0, k, curve->n, num_n_words) ||\n        (num_n_bits < ((bitcount_t)num_n_words * uECC_WORD_SIZE * 8) &&\n         uECC_vli_testBit(k0, num_n_bits));\n    uECC_vli_add(k1, k0, curve->n, num_n_words);\n    return carry;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":241056,"func":"static void trim_key()\n{\n\tchar *p;\n\tint i;\n\n\tfor (i=0, p=booth_conf->authkey; i < booth_conf->authkey_len; i++, p++)\n\t\tif (!isascii(*p))\n\t\t\treturn;\n\n\tp = booth_conf->authkey;\n\twhile (booth_conf->authkey_len > 0 && isspace(*p)) {\n\t\tp++;\n\t\tbooth_conf->authkey_len--;\n\t}\n\tmemmove(booth_conf->authkey, p, booth_conf->authkey_len);\n\n\tp = booth_conf->authkey + booth_conf->authkey_len - 1;\n\twhile (booth_conf->authkey_len > 0 && isspace(*p)) {\n\t\tbooth_conf->authkey_len--;\n\t\tp--;\n\t}\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":275492,"func":"njs_vm_value_string_set(njs_vm_t *vm, njs_value_t *value, const u_char *start,\n    uint32_t size)\n{\n    return njs_string_set(vm, value, start, size);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":317209,"func":"static int smack_msg_msg_alloc_security(struct msg_msg *msg)\n{\n\tstruct smack_known **blob = smack_msg_msg(msg);\n\n\t*blob = smk_of_current();\n\treturn 0;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":331783,"func":"QPaintEngineEx::QPaintEngineEx()\n    : QPaintEngine(*new QPaintEngineExPrivate, AllFeatures)\n{\n    extended = true;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":307868,"func":"uint ciEnv::compile_id() {\n  if (task() == NULL)  return 0;\n  return task()->compile_id();\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":264261,"func":"void buffer_reset(Buffer *buffer)\n{\n        buffer->offset = 0;\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":226235,"func":"GF_Err stdp_box_size(GF_Box *s)\n{\n\tGF_DegradationPriorityBox *ptr = (GF_DegradationPriorityBox *)s;\n\n\tptr->size += (2 * ptr->nb_entries);\n\treturn GF_OK;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":512556,"func":"  Item_hex_string(THD *thd, const char *str, size_t str_length):\n    Item_hex_constant(thd, str, str_length) {}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":236151,"func":"GF_Box *hclr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextHighlightColorBox, GF_ISOM_BOX_TYPE_HCLR);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":308192,"func":"static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)\n{\n\tstruct device *dev = ctx->fl->sctx->dev;\n\tint i, err;\n\n\tfor (i = 0; i < ctx->nscalars; ++i) {\n\t\t\/* Make sure reserved field is set to 0 *\/\n\t\tif (ctx->args[i].reserved)\n\t\t\treturn -EINVAL;\n\n\t\tif (ctx->args[i].fd == 0 || ctx->args[i].fd == -1 ||\n\t\t    ctx->args[i].length == 0)\n\t\t\tcontinue;\n\n\t\terr = fastrpc_map_create(ctx->fl, ctx->args[i].fd,\n\t\t\t\t\t ctx->args[i].length, &ctx->maps[i]);\n\t\tif (err) {\n\t\t\tdev_err(dev, \"Error Creating map %d\\n\", err);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t}\n\treturn 0;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":225547,"func":"size_t TfLiteIntArrayGetSizeInBytes(int size) {\n  static TfLiteIntArray dummy;\n\n  size_t computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;\n#if defined(_MSC_VER)\n  \/\/ Context for why this is needed is in http:\/\/b\/189926408#comment21\n  computed_size -= sizeof(dummy.data[0]);\n#endif\n  return computed_size;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":516257,"func":"static int virtio_net_max_tx_queue_size(VirtIONet *n)\n{\n    NetClientState *peer = n->nic_conf.peers.ncs[0];\n\n    \/*\n     * Backends other than vhost-user don't support max queue size.\n     *\/\n    if (!peer) {\n        return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;\n    }\n\n    if (peer->info->type != NET_CLIENT_DRIVER_VHOST_USER) {\n        return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;\n    }\n\n    return VIRTQUEUE_MAX_SIZE;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":369302,"func":"\t__must_hold(&ctx->completion_lock)\n{\n\tu32 seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);\n\tstruct io_kiocb *req, *tmp;\n\n\tspin_lock_irq(&ctx->timeout_lock);\n\tlist_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) {\n\t\tu32 events_needed, events_got;\n\n\t\tif (io_is_timeout_noseq(req))\n\t\t\tbreak;\n\n\t\t\/*\n\t\t * Since seq can easily wrap around over time, subtract\n\t\t * the last seq at which timeouts were flushed before comparing.\n\t\t * Assuming not more than 2^31-1 events have happened since,\n\t\t * these subtractions won't have wrapped, so we can check if\n\t\t * target is in [last_seq, current_seq] by comparing the two.\n\t\t *\/\n\t\tevents_needed = req->timeout.target_seq - ctx->cq_last_tm_flush;\n\t\tevents_got = seq - ctx->cq_last_tm_flush;\n\t\tif (events_got < events_needed)\n\t\t\tbreak;\n\n\t\tio_kill_timeout(req, 0);\n\t}\n\tctx->cq_last_tm_flush = seq;\n\tspin_unlock_irq(&ctx->timeout_lock);\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":269511,"func":"static MagickBooleanType ReadProfile(Image *image,const char *name,\n  const unsigned char *datum,ssize_t length,ExceptionInfo *exception)\n{\n  MagickBooleanType\n    status;\n\n  StringInfo\n    *profile;\n\n  if (length < 4)\n    return(MagickFalse);\n  profile=BlobToStringInfo(datum,(size_t) length);\n  if (profile == (StringInfo *) NULL)\n    ThrowBinaryException(ResourceLimitError,\"MemoryAllocationFailed\",\n      image->filename);\n  status=SetImageProfile(image,name,profile,exception);\n  profile=DestroyStringInfo(profile);\n  return(status);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":224186,"func":"  bool operator()(const Tensor& lhs, const Tensor& rhs) const {\n    return std::equal_to<int64_t>{}(lhs.scalar<int64_t>()(),\n                                    rhs.scalar<int64_t>()());\n  }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":401498,"func":"static int crng_slow_load(const char *cp, size_t len)\n{\n\tunsigned long\t\tflags;\n\tstatic unsigned char\tlfsr = 1;\n\tunsigned char\t\ttmp;\n\tunsigned\t\ti, max = CHACHA_KEY_SIZE;\n\tconst char *\t\tsrc_buf = cp;\n\tchar *\t\t\tdest_buf = (char *) &primary_crng.state[4];\n\n\tif (!spin_trylock_irqsave(&primary_crng.lock, flags))\n\t\treturn 0;\n\tif (crng_init != 0) {\n\t\tspin_unlock_irqrestore(&primary_crng.lock, flags);\n\t\treturn 0;\n\t}\n\tif (len > max)\n\t\tmax = len;\n\n\tfor (i = 0; i < max ; i++) {\n\t\ttmp = lfsr;\n\t\tlfsr >>= 1;\n\t\tif (tmp & 1)\n\t\t\tlfsr ^= 0xE1;\n\t\ttmp = dest_buf[i % CHACHA_KEY_SIZE];\n\t\tdest_buf[i % CHACHA_KEY_SIZE] ^= src_buf[i % len] ^ lfsr;\n\t\tlfsr += (tmp << 3) | (tmp >> 5);\n\t}\n\tspin_unlock_irqrestore(&primary_crng.lock, flags);\n\treturn 1;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":286744,"func":"size_t SWTPM_NVRAM_FileKey_Size(void)\n{\n    return filekey.symkey.userKeyLength;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":230992,"func":"prepare_tagged_break(mrb_state *mrb, uint32_t tag, const struct RProc *proc, mrb_value val)\n{\n  if (break_tag_p((struct RBreak*)mrb->exc, tag)) {\n    mrb_break_tag_set((struct RBreak*)mrb->exc, tag);\n  }\n  else {\n    mrb->exc = (struct RObject*)break_new(mrb, tag, proc, val);\n  }\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":234142,"func":"get_TAG_name (unsigned long tag)\n{\n  const char *name = get_DW_TAG_name ((unsigned int) tag);\n\n  if (name == NULL)\n    {\n      static char buffer[100];\n\n      if (tag >= DW_TAG_lo_user && tag <= DW_TAG_hi_user)\n\tsnprintf (buffer, sizeof (buffer), _(\"User TAG value: %#lx\"), tag);\n      else\n\tsnprintf (buffer, sizeof (buffer), _(\"Unknown TAG value: %#lx\"), tag);\n      return buffer;\n    }\n\n  return name;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":432246,"func":"static bool prepare_mmio_access(MemoryRegion *mr)\n{\n    return true;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":384792,"func":"getvcol_nolist(pos_T *posp)\n{\n    int\t\tlist_save = curwin->w_p_list;\n    colnr_T\tvcol;\n\n    curwin->w_p_list = FALSE;\n    if (posp->coladd)\n\tgetvvcol(curwin, posp, NULL, &vcol, NULL);\n    else\n\tgetvcol(curwin, posp, NULL, &vcol, NULL);\n    curwin->w_p_list = list_save;\n    return vcol;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":226344,"func":"GF_Err tmin_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":301486,"func":"similar_chars(slang_T *slang, int c1, int c2)\n{\n    int\t\tm1, m2;\n    char_u\tbuf[MB_MAXBYTES + 1];\n    hashitem_T  *hi;\n\n    if (c1 >= 256)\n    {\n\tbuf[mb_char2bytes(c1, buf)] = 0;\n\thi = hash_find(&slang->sl_map_hash, buf);\n\tif (HASHITEM_EMPTY(hi))\n\t    m1 = 0;\n\telse\n\t    m1 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);\n    }\n    else\n\tm1 = slang->sl_map_array[c1];\n    if (m1 == 0)\n\treturn FALSE;\n\n\n    if (c2 >= 256)\n    {\n\tbuf[mb_char2bytes(c2, buf)] = 0;\n\thi = hash_find(&slang->sl_map_hash, buf);\n\tif (HASHITEM_EMPTY(hi))\n\t    m2 = 0;\n\telse\n\t    m2 = mb_ptr2char(hi->hi_key + STRLEN(hi->hi_key) + 1);\n    }\n    else\n\tm2 = slang->sl_map_array[c2];\n\n    return m1 == m2;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":380946,"func":"ins_del(void)\n{\n    int\t    temp;\n\n    if (stop_arrow() == FAIL)\n\treturn;\n    if (gchar_cursor() == NUL)\t\t\/\/ delete newline\n    {\n\ttemp = curwin->w_cursor.col;\n\tif (!can_bs(BS_EOL)\t\t\/\/ only if \"eol\" included\n\t\t|| do_join(2, FALSE, TRUE, FALSE, FALSE) == FAIL)\n\t    vim_beep(BO_BS);\n\telse\n\t{\n\t    curwin->w_cursor.col = temp;\n\t    \/\/ Adjust orig_line_count in case more lines have been deleted than\n\t    \/\/ have been added. That makes sure, that open_line() later\n\t    \/\/ can access all buffer lines correctly\n\t    if (State & VREPLACE_FLAG &&\n\t\t    orig_line_count > curbuf->b_ml.ml_line_count)\n\t\torig_line_count = curbuf->b_ml.ml_line_count;\n\t}\n    }\n    else if (del_char(FALSE) == FAIL)  \/\/ delete char under cursor\n\tvim_beep(BO_BS);\n    did_ai = FALSE;\n    did_si = FALSE;\n    can_si = FALSE;\n    can_si_back = FALSE;\n    AppendCharToRedobuff(K_DEL);\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":246699,"func":"u32 parse_store_mode(char *arg_val, u32 opt)\n{\n\tdo_save = GF_TRUE;\n\tif ((opt == 0) || (opt == 1)) {\n\t\tinterleaving_time = atof(arg_val) \/ 1000;\n\t\tif (!interleaving_time) do_flat = 2;\n\t\topen_edit = GF_TRUE;\n\t\tno_inplace = GF_TRUE;\n\t\tif (opt==1) old_interleave = 1;\n\t} else if (opt==2) {\n\t\tinterleaving_time = atof(arg_val);\n\t\tdo_frag = GF_TRUE;\n\t} else {\n\t\tforce_new = 2;\n\t\tinterleaving_time = 0.5;\n\t\tdo_flat = 1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":473906,"func":"strhash(st_data_t arg)\n{\n    register const char *string = (const char *)arg;\n    return st_hash(string, strlen(string), FNV1_32A_INIT);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":369914,"func":"static int proc_fd_permission(struct inode *inode, int mask)\n{\n\tint rv = generic_permission(inode, mask);\n\tif (rv == 0)\n\t\treturn 0;\n\tif (task_pid(current) == proc_pid(inode))\n\t\trv = 0;\n\treturn rv;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":224210,"func":"    ~TopicTree() {\n        delete root;\n    }","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":233948,"func":"void DocumentSourceUnionWith::reattachToOperationContext(OperationContext* opCtx) {\n    \/\/ We have a pipeline we're going to be executing across multiple calls to getNext(), so we\n    \/\/ use Pipeline::reattachToOperationContext() to take care of updating the Pipeline's\n    \/\/ ExpressionContext.\n    if (_pipeline) {\n        _pipeline->reattachToOperationContext(opCtx);\n    }\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":312443,"func":"qf_free_all(win_T *wp)\n{\n    int\t\ti;\n    qf_info_T\t*qi = &ql_info;\n\n    if (wp != NULL)\n    {\n\t\/\/ location list\n\tll_free_all(&wp->w_llist);\n\tll_free_all(&wp->w_llist_ref);\n    }\n    else\n\t\/\/ quickfix list\n\tfor (i = 0; i < qi->qf_listcount; ++i)\n\t    qf_free(qf_get_list(qi, i));\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":473946,"func":"get_case_fold_codes_by_str(OnigCaseFoldType flag,\n    const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[],\n    OnigEncoding enc)\n{\n  return onigenc_unicode_get_case_fold_codes_by_str(enc, flag, p, end, items);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":229302,"func":"void cql_server::response::write_short_bytes(bytes b)\n{\n    write_short(cast_if_fits<uint16_t>(b.size()));\n    _body.write(b);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":436134,"func":" *\/\nstatic void io_uring_del_tctx_node(unsigned long index)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\tstruct io_tctx_node *node;\n\n\tif (!tctx)\n\t\treturn;\n\tnode = xa_erase(&tctx->xa, index);\n\tif (!node)\n\t\treturn;\n\n\tWARN_ON_ONCE(current != node->task);\n\tWARN_ON_ONCE(list_empty(&node->ctx_node));\n\n\tmutex_lock(&node->ctx->uring_lock);\n\tlist_del(&node->ctx_node);\n\tmutex_unlock(&node->ctx->uring_lock);\n\n\tif (tctx->last == node->ctx)\n\t\ttctx->last = NULL;\n\tkfree(node);","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":294397,"func":"date_s__jisx0301(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, opt;\n\n    rb_scan_args(argc, argv, \"1:\", &str, &opt);\n    check_limit(str, opt);\n\n    return date__jisx0301(str);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":421400,"func":"static void nl(void)\n{\n\tif (minify < 2)\n\t\tputchar('\\n');\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":279920,"func":"append_redir(\n    char_u\t*buf,\n    int\t\tbuflen,\n    char_u\t*opt,\n    char_u\t*fname)\n{\n    char_u\t*p;\n    char_u\t*end;\n\n    end = buf + STRLEN(buf);\n    \/\/ find \"%s\"\n    for (p = opt; (p = vim_strchr(p, '%')) != NULL; ++p)\n    {\n\tif (p[1] == 's') \/\/ found %s\n\t    break;\n\tif (p[1] == '%') \/\/ skip %%\n\t    ++p;\n    }\n    if (p != NULL)\n    {\n#ifdef MSWIN\n\t*end++ = ' '; \/\/ not really needed? Not with sh, ksh or bash\n#endif\n\tvim_snprintf((char *)end, (size_t)(buflen - (end - buf)),\n\t\t\t\t\t\t  (char *)opt, (char *)fname);\n    }\n    else\n\tvim_snprintf((char *)end, (size_t)(buflen - (end - buf)),\n#ifdef FEAT_QUICKFIX\n\t\t\" %s %s\",\n#else\n\t\t\" %s%s\",\t\/\/ \" > %s\" causes problems on Amiga\n#endif\n\t\t(char *)opt, (char *)fname);\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":244350,"func":"GF_Err fpar_box_size(GF_Box *s)\n{\n\tFilePartitionBox *ptr = (FilePartitionBox *)s;\n\n\tptr->size += 13 + (ptr->version ? 8 : 4);\n\tif (ptr->scheme_specific_info)\n\t\tptr->size += strlen(ptr->scheme_specific_info);\n\n\tptr->size+= ptr->nb_entries * 6;\n\treturn GF_OK;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":275937,"func":"unsigned uECC_curve_num_bytes(uECC_Curve curve) {\n    return curve->num_bytes;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":503864,"func":"SCM_DEFINE (scm_umask, \"umask\", 0, 1, 0, \n            (SCM mode),\n\t    \"If @var{mode} is omitted, returns a decimal number representing the current\\n\"\n\t    \"file creation mask.  Otherwise the file creation mask is set to\\n\"\n\t    \"@var{mode} and the previous value is returned.\\n\\n\"\n\t    \"E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18.\")\n#define FUNC_NAME s_scm_umask\n{\n  mode_t mask;\n  if (SCM_UNBNDP (mode))\n    {\n      mask = umask (0);\n      umask (mask);\n    }\n  else\n    {\n      mask = umask (scm_to_uint (mode));\n    }\n  return scm_from_uint (mask);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":430401,"func":"static int __parse_vlan_from_nlattrs(struct sw_flow_match *match,\n\t\t\t\t     u64 *key_attrs, bool inner,\n\t\t\t\t     const struct nlattr **a, bool is_mask,\n\t\t\t\t     bool log)\n{\n\tint err;\n\tconst struct nlattr *encap;\n\n\tif (!is_mask)\n\t\terr = validate_vlan_from_nlattrs(match, *key_attrs, inner,\n\t\t\t\t\t\t a, log);\n\telse\n\t\terr = validate_vlan_mask_from_nlattrs(match, *key_attrs, inner,\n\t\t\t\t\t\t      a, log);\n\tif (err <= 0)\n\t\treturn err;\n\n\terr = encode_vlan_from_nlattrs(match, a, is_mask, inner);\n\tif (err)\n\t\treturn err;\n\n\t*key_attrs &= ~(1 << OVS_KEY_ATTR_ENCAP);\n\t*key_attrs &= ~(1 << OVS_KEY_ATTR_VLAN);\n\t*key_attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);\n\n\tencap = a[OVS_KEY_ATTR_ENCAP];\n\n\tif (!is_mask)\n\t\terr = parse_flow_nlattrs(encap, a, key_attrs, log);\n\telse\n\t\terr = parse_flow_mask_nlattrs(encap, a, key_attrs, log);\n\n\treturn err;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":434094,"func":"alist_new(void)\n{\n    curwin->w_alist = ALLOC_ONE(alist_T);\n    if (curwin->w_alist == NULL)\n    {\n\tcurwin->w_alist = &global_alist;\n\t++global_alist.al_refcount;\n    }\n    else\n    {\n\tcurwin->w_alist->al_refcount = 1;\n\tcurwin->w_alist->id = ++max_alist_id;\n\talist_init(curwin->w_alist);\n    }\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":247692,"func":"  const std::string& clientSession() const { return client_session_; }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":337853,"func":"struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,\n\t\t\t\t const struct sctp_association *asoc,\n\t\t\t\t struct sock *sk, gfp_t gfp)\n{\n\tstruct sctp_chunk *retval;\n\n\tretval = kmem_cache_zalloc(sctp_chunk_cachep, gfp);\n\n\tif (!retval)\n\t\tgoto nodata;\n\tif (!sk)\n\t\tpr_debug(\"%s: chunkifying skb:%p w\/o an sk\\n\", __func__, skb);\n\n\tINIT_LIST_HEAD(&retval->list);\n\tretval->skb\t\t= skb;\n\tretval->asoc\t\t= (struct sctp_association *)asoc;\n\tretval->singleton\t= 1;\n\n\tretval->fast_retransmit = SCTP_CAN_FRTX;\n\n\t\/* Polish the bead hole.  *\/\n\tINIT_LIST_HEAD(&retval->transmitted_list);\n\tINIT_LIST_HEAD(&retval->frag_list);\n\tSCTP_DBG_OBJCNT_INC(chunk);\n\trefcount_set(&retval->refcnt, 1);\n\nnodata:\n\treturn retval;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":488408,"func":"static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,\n\t\t\t\t     unsigned long addr, unsigned long end,\n\t\t\t\t     pte_fn_t fn, void *data)\n{\n\tpud_t *pud;\n\tunsigned long next;\n\tint err;\n\n\tpud = pud_alloc(mm, pgd, addr);\n\tif (!pud)\n\t\treturn -ENOMEM;\n\tdo {\n\t\tnext = pud_addr_end(addr, end);\n\t\terr = apply_to_pmd_range(mm, pud, addr, next, fn, data);\n\t\tif (err)\n\t\t\tbreak;\n\t} while (pud++, addr = next, addr != end);\n\treturn err;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":338112,"func":"void WasmBinaryWriter::writeGlobals() {\n  if (importInfo->getNumDefinedGlobals() == 0) {\n    return;\n  }\n  BYN_TRACE(\"== writeglobals\\n\");\n  auto start = startSection(BinaryConsts::Section::Global);\n  \/\/ Count and emit the total number of globals after tuple globals have been\n  \/\/ expanded into their constituent parts.\n  Index num = 0;\n  ModuleUtils::iterDefinedGlobals(\n    *wasm, [&num](Global* global) { num += global->type.size(); });\n  o << U32LEB(num);\n  ModuleUtils::iterDefinedGlobals(*wasm, [&](Global* global) {\n    BYN_TRACE(\"write one\\n\");\n    size_t i = 0;\n    for (const auto& t : global->type) {\n      writeType(t);\n      o << U32LEB(global->mutable_);\n      if (global->type.size() == 1) {\n        writeExpression(global->init);\n      } else {\n        writeExpression(global->init->cast<TupleMake>()->operands[i]);\n      }\n      o << int8_t(BinaryConsts::End);\n      ++i;\n    }\n  });\n  finishSection(start);\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":244092,"func":"static void ctrn_write_ctso(GF_TrackFragmentRunBox *ctrn, GF_BitStream *bs, u32 ctso, u32 field_size)\n{\n\tif (!field_size) return;\n\n\tif (ctrn->ctso_multiplier) {\n\t\tgf_bs_write_int(bs, ctso \/ ctrn->ctso_multiplier, field_size);\n\t} else {\n\t\tgf_bs_write_int(bs, ctso, field_size);\n\t}\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":379686,"func":"R_API RAnalVar *r_anal_var_get_dst_var(RAnalVar *var) {\n\tr_return_val_if_fail (var, NULL);\n\tRAnalVarAccess *acc;\n\tr_vector_foreach (&var->accesses, acc) {\n\t\tif (!(acc->type & R_ANAL_VAR_ACCESS_TYPE_READ)) {\n\t\t\tcontinue;\n\t\t}\n\t\tut64 addr = var->fcn->addr + acc->offset;\n\t\tRPVector *used_vars = r_anal_function_get_vars_used_at (var->fcn, addr);\n\t\tvoid **it;\n\t\tr_pvector_foreach (used_vars, it) {\n\t\t\tRAnalVar *used_var = *it;\n\t\t\tif (used_var == var) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tRAnalVarAccess *other_acc = r_anal_var_get_access_at (used_var, addr);\n\t\t\tif (other_acc && other_acc->type & R_ANAL_VAR_ACCESS_TYPE_WRITE) {\n\t\t\t\treturn used_var;\n\t\t\t}\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":293739,"func":"static RList *entries(RBinFile *bf) {\n\tRList *ret;\n\tRBinObject *obj = bf ? bf->o : NULL;\n\n\tif (!obj || !obj->bin_obj || !(ret = r_list_newf (free))) {\n\t\treturn NULL;\n\t}\n\n\tRKernelCacheObj *kobj = (RKernelCacheObj*) obj->bin_obj;\n\tut64 entry_vaddr = kobj->mach0->entry;\n\tif (kobj->pa2va_exec <= entry_vaddr) {\n\t\tut64 entry_paddr = entry_vaddr - kobj->pa2va_exec;\n\t\tRBinAddr *ba = newEntry (entry_paddr, entry_vaddr, 0);\n\t\tif (ba) {\n\t\t\tr_list_append (ret, ba);\n\t\t}\n\t}\n\n\tprocess_constructors (kobj, kobj->mach0, ret, 0, true, R_K_CONSTRUCTOR_TO_ENTRY, NULL);\n\n\treturn ret;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":459148,"func":"static void tcf_block_offload_init(struct flow_block_offload *bo,\n\t\t\t\t   struct net_device *dev, struct Qdisc *sch,\n\t\t\t\t   enum flow_block_command command,\n\t\t\t\t   enum flow_block_binder_type binder_type,\n\t\t\t\t   struct flow_block *flow_block,\n\t\t\t\t   bool shared, struct netlink_ext_ack *extack)\n{\n\tbo->net = dev_net(dev);\n\tbo->command = command;\n\tbo->binder_type = binder_type;\n\tbo->block = flow_block;\n\tbo->block_shared = shared;\n\tbo->extack = extack;\n\tbo->sch = sch;\n\tbo->cb_list_head = &flow_block->cb_list;\n\tINIT_LIST_HEAD(&bo->cb_list);\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":455283,"func":"subshell_exit (s)\n     int s;\n{\n  fflush (stdout);\n  fflush (stderr);\n\n  \/* Do trap[0] if defined.  Allow it to override the exit status\n     passed to us. *\/\n  if (signal_is_trapped (0))\n    s = run_exit_trap ();\n\n  sh_exit (s);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":386566,"func":"void DL_Dxf::addDimAngular(DL_CreationInterface* creationInterface) {\n    DL_DimensionData d = getDimData();\n\n    \/\/ angular dimension:\n    DL_DimAngular2LData da(\n        \/\/ definition point 1\n        getRealValue(13, 0.0),\n        getRealValue(23, 0.0),\n        getRealValue(33, 0.0),\n        \/\/ definition point 2\n        getRealValue(14, 0.0),\n        getRealValue(24, 0.0),\n        getRealValue(34, 0.0),\n        \/\/ definition point 3\n        getRealValue(15, 0.0),\n        getRealValue(25, 0.0),\n        getRealValue(35, 0.0),\n        \/\/ definition point 4\n        getRealValue(16, 0.0),\n        getRealValue(26, 0.0),\n        getRealValue(36, 0.0));\n    creationInterface->addDimAngular(d, da);\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":409504,"func":"termgui_mch_get_color(char_u *name)\n{\n    return gui_get_color_cmn(name);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":270370,"func":"static inline void ok_png_premultiply(uint8_t *dst) {\n    const uint8_t a = dst[3];\n    if (a == 0) {\n        dst[0] = 0;\n        dst[1] = 0;\n        dst[2] = 0;\n    } else if (a < 255) {\n        dst[0] = (a * dst[0] + 127) \/ 255;\n        dst[1] = (a * dst[1] + 127) \/ 255;\n        dst[2] = (a * dst[2] + 127) \/ 255;\n    }\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":346445,"func":"estack_init(void)\n{\n    estack_T *entry;\n\n    if (ga_grow(&exestack, 10) == FAIL)\n\tmch_exit(0);\n    entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;\n    entry->es_type = ETYPE_TOP;\n    entry->es_name = NULL;\n    entry->es_lnum = 0;\n#ifdef FEAT_EVAL\n    entry->es_info.ufunc = NULL;\n#endif\n    ++exestack.ga_len;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":308162,"func":"static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)\n{\n\tint size = 0;\n\n\tsize = (sizeof(struct fastrpc_remote_arg) +\n\t\tsizeof(struct fastrpc_invoke_buf) +\n\t\tsizeof(struct fastrpc_phy_page)) * ctx->nscalars +\n\t\tsizeof(u64) * FASTRPC_MAX_FDLIST +\n\t\tsizeof(u32) * FASTRPC_MAX_CRCLIST;\n\n\treturn size;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":366221,"func":"static int flags_to_propagation_type(int ms_flags)\n{\n\tint type = ms_flags & ~(MS_REC | MS_SILENT);\n\n\t\/* Fail if any non-propagation flags are set *\/\n\tif (type & ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))\n\t\treturn 0;\n\t\/* Only one propagation flag should be set *\/\n\tif (!is_power_of_2(type))\n\t\treturn 0;\n\treturn type;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":139224,"func":"ui::Layer* OverlayWindowViews::GetResizeHandleLayer() {\n  return resize_handle_view_->layer();\n}\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":346466,"func":"load_start_packages(void)\n{\n    did_source_packages = TRUE;\n    do_in_path(p_pp, (char_u *)\"pack\/*\/start\/*\", DIP_ALL + DIP_DIR,\n\t\t\t\t\t\t  add_pack_plugin, &APP_LOAD);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":384809,"func":"getftypest(stat_T *st)\n{\n    char    *t;\n\n    if (S_ISREG(st->st_mode))\n\tt = \"file\";\n    else if (S_ISDIR(st->st_mode))\n\tt = \"dir\";\n    else if (S_ISLNK(st->st_mode))\n\tt = \"link\";\n    else if (S_ISBLK(st->st_mode))\n\tt = \"bdev\";\n    else if (S_ISCHR(st->st_mode))\n\tt = \"cdev\";\n    else if (S_ISFIFO(st->st_mode))\n\tt = \"fifo\";\n    else if (S_ISSOCK(st->st_mode))\n\tt = \"socket\";\n    else\n\tt = \"other\";\n    return (char_u*)t;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":200379,"func":"RList *r_bin_ne_get_segments(r_bin_ne_obj_t *bin) {\n\tint i;\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_list_newf (free);\n\tfor (i = 0; i < bin->ne_header->SegCount; i++) {\n\t\tRBinSection *bs = R_NEW0 (RBinSection);\n\t\tif (!bs) {\n\t\t\treturn segments;\n\t\t}\n\t\tNE_image_segment_entry *se = &bin->segment_entries[i];\n\t\tbs->size = se->length;\n\t\tbs->vsize = se->minAllocSz ? se->minAllocSz : 64000;\n\t\tbs->bits = R_SYS_BITS_16;\n\t\tbs->is_data = se->flags & IS_DATA;\n\t\tbs->perm = __translate_perms (se->flags);\n\t\tbs->paddr = (ut64)se->offset * bin->alignment;\n\t\tbs->name = r_str_newf (\"%s.%\" PFMT64d, se->flags & IS_MOVEABLE ? \"MOVEABLE\" : \"FIXED\", bs->paddr);\n\t\tbs->is_segment = true;\n\t\tr_list_append (segments, bs);\n\t}\n\tbin->segments = segments;\n\treturn segments;\n}","target":1,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":292199,"func":"inbound_identified (server *serv)\t\/* 'MODE +e MYSELF' on freenode *\/\n{\n\tif (serv->joindelay_tag)\n\t{\n\t\t\/* stop waiting, just auto JOIN now *\/\n\t\tfe_timeout_remove (serv->joindelay_tag);\n\t\tserv->joindelay_tag = 0;\n\t\tcheck_autojoin_channels (serv);\n\t}\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":317097,"func":"static int smack_socket_socketpair(struct socket *socka,\n\t\t                   struct socket *sockb)\n{\n\tstruct socket_smack *asp = socka->sk->sk_security;\n\tstruct socket_smack *bsp = sockb->sk->sk_security;\n\n\tasp->smk_packet = bsp->smk_out;\n\tbsp->smk_packet = asp->smk_out;\n\n\treturn 0;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":421395,"func":"static void pblock(int d, js_Ast *block)\n{\n\tassert(block->type == STM_BLOCK);\n\tpc('{'); nl();\n\tpstmlist(d, block->a);\n\tin(d); pc('}');\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":241310,"func":"mrb_class_inherited(mrb_state *mrb, struct RClass *super, struct RClass *klass)\n{\n  mrb_value s;\n  mrb_sym mid;\n\n  if (!super)\n    super = mrb->object_class;\n  super->flags |= MRB_FL_CLASS_IS_INHERITED;\n  s = mrb_obj_value(super);\n  mrb_mc_clear_by_class(mrb, klass);\n  mid = MRB_SYM(inherited);\n  if (!mrb_func_basic_p(mrb, s, mid, mrb_do_nothing)) {\n    mrb_value c = mrb_obj_value(klass);\n    mrb_funcall_argv(mrb, s, mid, 1, &c);\n  }\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":404699,"func":"void set_close_on_exec(unsigned int fd, int flag)\n{\n\tstruct files_struct *files = current->files;\n\tstruct fdtable *fdt;\n\tspin_lock(&files->file_lock);\n\tfdt = files_fdtable(files);\n\tif (flag)\n\t\t__set_close_on_exec(fd, fdt);\n\telse\n\t\t__clear_close_on_exec(fd, fdt);\n\tspin_unlock(&files->file_lock);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":313144,"func":"testStorageFileGetMetadata(const char *path,\n                           int format,\n                           uid_t uid, gid_t gid)\n{\n    struct stat st;\n    g_autoptr(virStorageSource) def = NULL;\n\n    if (!(def = virStorageSourceNew()))\n        return NULL;\n\n    def->type = VIR_STORAGE_TYPE_FILE;\n    def->format = format;\n\n    if (stat(path, &st) == 0) {\n        if (S_ISDIR(st.st_mode)) {\n            def->type = VIR_STORAGE_TYPE_DIR;\n        } else if (S_ISBLK(st.st_mode)) {\n            def->type = VIR_STORAGE_TYPE_BLOCK;\n        }\n    }\n\n    def->path = g_strdup(path);\n\n    if (virStorageFileGetMetadata(def, uid, gid, true) < 0)\n        return NULL;\n\n    return g_steal_pointer(&def);\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":453033,"func":"static int nft_chain_offload_cmd(struct nft_base_chain *basechain,\n\t\t\t\t struct net_device *dev,\n\t\t\t\t enum flow_block_command cmd)\n{\n\tint err;\n\n\tif (dev->netdev_ops->ndo_setup_tc)\n\t\terr = nft_block_offload_cmd(basechain, dev, cmd);\n\telse\n\t\terr = nft_indr_block_offload_cmd(basechain, dev, cmd);\n\n\treturn err;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":229147,"func":"static size_t write_to_port(VirtIOSerialPort *port,\n                            const uint8_t *buf, size_t size)\n{\n    VirtQueueElement elem;\n    VirtQueue *vq;\n    size_t offset;\n\n    vq = port->ivq;\n    if (!virtio_queue_ready(vq)) {\n        return 0;\n    }\n\n    offset = 0;\n    while (offset < size) {\n        size_t len;\n\n        if (!virtqueue_pop(vq, &elem)) {\n            break;\n        }\n\n        len = iov_from_buf(elem.in_sg, elem.in_num, 0,\n                           buf + offset, size - offset);\n        offset += len;\n\n        virtqueue_push(vq, &elem, len);\n    }\n\n    virtio_notify(VIRTIO_DEVICE(port->vser), vq);\n    return offset;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":333053,"func":"state_in_list(\n    nfa_list_T\t\t*l,\t\/\/ runtime state list\n    nfa_state_T\t\t*state,\t\/\/ state to update\n    regsubs_T\t\t*subs)\t\/\/ pointers to subexpressions\n{\n    if (state->lastlist[nfa_ll_index] == l->id)\n    {\n\tif (!rex.nfa_has_backref || has_state_with_pos(l, state, subs, NULL))\n\t    return TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":364775,"func":"findtags_state_free(findtags_state_T *st)\n{\n    vim_free(st->tag_fname);\n    vim_free(st->lbuf);\n    vim_regfree(st->orgpat->regmatch.regprog);\n    vim_free(st->orgpat);\n#ifdef FEAT_EMACS_TAGS\n    vim_free(st->ebuf);\n#endif\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":229226,"func":"std::tuple<net::inet_address, int, client_type> cql_server::connection::make_client_key(const service::client_state& cli_state) {\n    return std::make_tuple(cli_state.get_client_address().addr(),\n            cli_state.get_client_port(),\n            cli_state.is_thrift() ? client_type::thrift : client_type::cql);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":204073,"func":"static char ** split(const char *arg, const char *delim) {\n  char *copy = dupstr(arg);\n  char **result = NULL;\n  int i = 0;\n\n  for (char *cptr = strtok(copy, delim); cptr; cptr = strtok(NULL, delim)) {\n    char **tmp = realloc (result, sizeof *result * (i + 1));\n    if (!tmp && result) {\n      while (i > 0) {\n\tfree(result[--i]);\n      }\n      free(result);\n      free(copy);\n      return NULL;\n    }\n    result = tmp;\n    result[i++] = dupstr(cptr);\n  }\n\n  free(copy);\n\n  if (i) {\n    char **tmp = realloc(result, sizeof *result * (i + 1));\n    if (!tmp) {\n      while (i > 0) {\n\tfree(result[--i]);\n      }\n      free(result);\n      free(copy);\n      return NULL;\n    }\n    result = tmp;\n    result[i++] = NULL;\n  }\n\n  return result;\n}","target":1,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":265442,"func":"static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,\n\t\t\t\t  const char *base_path)\n{\n\tchar *resolved, *target;\n\tu32 sz;\n\n\tsz = get_unaligned_le32(&sym->symlink_size);\n\ttarget = malloc(sz + 1);\n\tif (!target)\n\t\treturn NULL;\n\n\t\/*\n\t * There is no trailling null byte in the symlink's target path, so a\n\t * copy is made and a '\\0' is added at its end.\n\t *\/\n\ttarget[sz] = '\\0';\n\t\/* Get target name (relative path) *\/\n\tstrncpy(target, sym->symlink, sz);\n\n\t\/* Relative -> absolute path conversion *\/\n\tresolved = sqfs_get_abs_path(base_path, target);\n\n\tfree(target);\n\n\treturn resolved;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":335415,"func":"restore_current_state(save_state_T *sst)\n{\n    \/\/ Restore the previous typeahead.\n    restore_typeahead(&sst->tabuf, FALSE);\n\n    msg_scroll = sst->save_msg_scroll;\n    restart_edit = sst->save_restart_edit;\n    p_im = sst->save_insertmode;\n    finish_op = sst->save_finish_op;\n    opcount = sst->save_opcount;\n    reg_executing = sst->save_reg_executing;\n    pending_end_reg_executing = sst->save_pending_end_reg_executing;\n    msg_didout |= sst->save_msg_didout;\t\/\/ don't reset msg_didout now\n    current_sctx.sc_version = sst->save_script_version;\n\n    \/\/ Restore the state (needed when called from a function executed for\n    \/\/ 'indentexpr'). Update the mouse and cursor, they may have changed.\n    State = sst->save_State;\n#ifdef CURSOR_SHAPE\n    ui_cursor_shape();\t\t\/\/ may show different cursor shape\n#endif\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":502692,"func":"int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)\n{\n    return remove_session_lock(ctx, c, 1);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":225554,"func":"TfLiteStatus TfLiteTensorCopy(const TfLiteTensor* src, TfLiteTensor* dst) {\n  if (!src || !dst)\n    return kTfLiteOk;\n  if (src->bytes != dst->bytes)\n    return kTfLiteError;\n  if (src == dst)\n    return kTfLiteOk;\n\n  dst->type = src->type;\n  if (dst->dims)\n    TfLiteIntArrayFree(dst->dims);\n  dst->dims = TfLiteIntArrayCopy(src->dims);\n  memcpy(dst->data.raw, src->data.raw, src->bytes);\n  dst->buffer_handle = src->buffer_handle;\n  dst->data_is_stale = src->data_is_stale;\n  dst->delegate = src->delegate;\n\n  return kTfLiteOk;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":384913,"func":"skipwhite_and_nl(char_u *q)\n{\n    char_u\t*p = q;\n\n    while (VIM_ISWHITE(*p) || *p == NL)\n\t++p;\n    return p;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":336612,"func":"static void reds_handle_sasl_result(void *opaque, RedSaslError status)\n{\n    RedLinkInfo *link = (RedLinkInfo *)opaque;\n\n    switch (status) {\n    case RED_SASL_ERROR_OK:\n        reds_handle_link(link);\n        break;\n    case RED_SASL_ERROR_INVALID_DATA:\n        reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);\n        reds_link_free(link);\n        break;\n    default:\n        \/\/ in these cases error was reported using SASL protocol\n        \/\/ (RED_SASL_ERROR_AUTH_FAILED) or we just need to close the\n        \/\/ connection\n        reds_link_free(link);\n        break;\n    }\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":309806,"func":"bcd_expression(const char *str)\n{\n    \/* leave this non-const for HPUX *\/\n    static char fmt[] = \"%%p%c%%{10}%%\/%%{16}%%*%%p%c%%{10}%%m%%+\";\n    int len = 0;\n    char ch1, ch2;\n\n    if (sscanf(str, fmt, &ch1, &ch2) == 2\n\t&& isdigit(UChar(ch1))\n\t&& isdigit(UChar(ch2))\n\t&& (ch1 == ch2)) {\n\tlen = 28;\n#ifndef NDEBUG\n\t{\n\t    char buffer[80];\n\t    int tst;\n\t    _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) fmt, ch1, ch2);\n\t    tst = strlen(buffer) - 1;\n\t    assert(len == tst);\n\t}\n#endif\n    }\n    return len;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":225806,"func":"GF_Box *tfrf_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MSSTimeRefBox, GF_ISOM_BOX_TYPE_UUID);\n\ttmp->internal_4cc = GF_ISOM_BOX_UUID_TFRF;\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":352935,"func":"csnPretty(\n\tSyntax *syntax,\n\tstruct berval *val,\n\tstruct berval *out,\n\tvoid *ctx )\n{\n\treturn csnNormalize( SLAP_MR_VALUE_OF_SYNTAX, NULL, NULL, val, out, ctx );\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":400756,"func":"static unsigned long iov_iter_alignment_bvec(const struct iov_iter *i)\n{\n\tunsigned res = 0;\n\tsize_t size = i->count;\n\tunsigned skip = i->iov_offset;\n\tunsigned k;\n\n\tfor (k = 0; k < i->nr_segs; k++, skip = 0) {\n\t\tsize_t len = i->bvec[k].bv_len - skip;\n\t\tres |= (unsigned long)i->bvec[k].bv_offset + skip;\n\t\tif (len > size)\n\t\t\tlen = size;\n\t\tres |= len;\n\t\tsize -= len;\n\t\tif (!size)\n\t\t\tbreak;\n\t}\n\treturn res;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":409473,"func":"term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len)\n{\n    int\t\ti;\n    int\t\tc;\n\n    for (i = ta_len; i < ta_len + len; ++i)\n    {\n\tif (ta_buf[i] == CSI && len - i > 2)\n\t{\n\t    c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]);\n\t    if (c == K_DEL || c == K_KDEL || c == K_BS)\n\t    {\n\t\tmch_memmove(ta_buf + i + 1, ta_buf + i + 3,\n\t\t\t(size_t)(len - i - 2));\n\t\tif (c == K_DEL || c == K_KDEL)\n\t\t    ta_buf[i] = DEL;\n\t\telse\n\t\t    ta_buf[i] = Ctrl_H;\n\t\tlen -= 2;\n\t    }\n\t}\n\telse if (ta_buf[i] == '\\r')\n\t    ta_buf[i] = '\\n';\n\tif (has_mbyte)\n\t    i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1;\n    }\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":453025,"func":"static void nft_flow_block_offload_init(struct flow_block_offload *bo,\n\t\t\t\t\tstruct net *net,\n\t\t\t\t\tenum flow_block_command cmd,\n\t\t\t\t\tstruct nft_base_chain *basechain,\n\t\t\t\t\tstruct netlink_ext_ack *extack)\n{\n\tmemset(bo, 0, sizeof(*bo));\n\tbo->net\t\t= net;\n\tbo->block\t= &basechain->flow_block;\n\tbo->command\t= cmd;\n\tbo->binder_type\t= FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;\n\tbo->extack\t= extack;\n\tbo->cb_list_head = &basechain->flow_block.cb_list;\n\tINIT_LIST_HEAD(&bo->cb_list);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":240257,"func":"copy_yank_reg(yankreg_T *reg)\n{\n    yankreg_T\t*curr = y_current;\n    long\tj;\n\n    y_current = reg;\n    free_yank_all();\n    *y_current = *curr;\n    y_current->y_array = lalloc_clear(\n\t\t\t\t    sizeof(char_u *) * y_current->y_size, TRUE);\n    if (y_current->y_array == NULL)\n\ty_current->y_size = 0;\n    else\n\tfor (j = 0; j < y_current->y_size; ++j)\n\t    if ((y_current->y_array[j] = vim_strsave(curr->y_array[j])) == NULL)\n\t    {\n\t\tfree_yank(j);\n\t\ty_current->y_size = 0;\n\t\tbreak;\n\t    }\n    y_current = curr;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":247363,"func":"static int pgpVersion(const uint8_t *h, size_t hlen, uint8_t *version)\n{\n    if (hlen < 1)\n\treturn -1;\n\n    *version = h[0];\n    return 0;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":231026,"func":"    void vQueueSetQueueNumber( QueueHandle_t xQueue,\r\n                               UBaseType_t uxQueueNumber )\r\n    {\r\n        ( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber;\r\n    }\r","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":175783,"func":"  FilePath profile_path() const { return data_dir_.path(); }\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":248264,"func":"DLLIMPORT char *cfg_searchpath(cfg_searchpath_t *p, const char *file)\n{\n\tchar *fullpath;\n#ifdef HAVE_SYS_STAT_H\n\tstruct stat st;\n\tint err;\n#endif\n\n\tif (!p || !file) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tif (file[0] == '\/') {\n\t\tfullpath = strdup(file);\n\t\tif (!fullpath)\n\t\t\treturn NULL;\n\t\tgoto check;\n\t}\n\n\tif ((fullpath = cfg_searchpath(p->next, file)) != NULL)\n\t\treturn fullpath;\n\n\tif ((fullpath = cfg_make_fullpath(p->dir, file)) == NULL)\n\t\treturn NULL;\n\ncheck:\n#ifdef HAVE_SYS_STAT_H\n\terr = stat((const char *)fullpath, &st);\n\tif ((!err) && S_ISREG(st.st_mode))\n\t\treturn fullpath;\n#else\n\t\/* needs an alternative check here for win32 *\/\n#endif\n\n\tfree(fullpath);\n\treturn NULL;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":413618,"func":"static bool block_flags_stat(RFlagItem *fi, void *user) {\n\tstruct block_flags_stat_t *u = (struct block_flags_stat_t *)user;\n\tint piece = (fi->offset - u->from) \/ u->step;\n\tu->as->block[piece].flags++;\n\treturn true;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":226981,"func":"IRC_PROTOCOL_CALLBACK(900)\n{\n    IRC_PROTOCOL_MIN_ARGS(6);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, argv[3], command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s %s(%s%s%s)\",\n        weechat_prefix (\"network\"),\n        (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_CHAT_HOST,\n        argv[3],\n        IRC_COLOR_CHAT_DELIMITERS);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":273891,"func":"static int list_printf(ctrl_t *ctrl, char *buf, size_t len, char *path, char *name)\n{\n\tint dirs;\n\tint mode = ctrl->list_mode;\n\tstruct stat st;\n\n\tif (stat(path, &st))\n\t\treturn -1;\n\n\tdirs = mode & 0xF0;\n\tmode = mode & 0x0F;\n\n\tif (dirs && !S_ISDIR(st.st_mode))\n\t\treturn 1;\n\tif (!dirs && S_ISDIR(st.st_mode))\n\t\treturn 1;\n\n\tswitch (mode) {\n\tcase 3:\t\t\t\/* MLSD *\/\n\t\t\/* fallthrough *\/\n\tcase 2:\t\t\t\/* MLST *\/\n\t\tmlsd_printf(ctrl, buf, len, path, name, &st);\n\t\tbreak;\n\n\tcase 1:\t\t\t\/* NLST *\/\n\t\tsnprintf(buf, len, \"%s\\r\\n\", name);\n\t\tbreak;\n\n\tcase 0:\t\t\t\/* LIST *\/\n\t\tsnprintf(buf, len, \"%s 1 %5d %5d %12\" PRIu64 \" %s %s\\r\\n\",\n\t\t\t mode_to_str(st.st_mode),\n\t\t\t 0, 0, (uint64_t)st.st_size,\n\t\t\t time_to_str(st.st_mtime), name);\n\t\tbreak;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":437307,"func":"onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,\n         OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,\n         OnigErrorInfo* einfo)\n{\n  int r;\n\n  *reg = (regex_t* )xmalloc(sizeof(regex_t));\n  if (IS_NULL(*reg)) return ONIGERR_MEMORY;\n\n  r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);\n  if (r != 0) goto err;\n\n  r = onig_compile(*reg, pattern, pattern_end, einfo);\n  if (r != 0) {\n  err:\n    onig_free(*reg);\n    *reg = NULL;\n  }\n  return r;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":508866,"func":"void st_select_lex_node::exclude()\n{\n  \/* exclude from global list *\/\n  fast_exclude();\n  \/* exclude from other structures *\/\n  exclude_from_tree();\n  \/* \n     We do not need following statements, because prev pointer of first \n     list element point to master->slave\n     if (master->slave == this)\n       master->slave= next;\n  *\/\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":508800,"func":"void LEX::reset_arena_for_set_stmt(Query_arena *backup)\n{\n  DBUG_ENTER(\"LEX::reset_arena_for_set_stmt\");\n  DBUG_ASSERT(arena_for_set_stmt);\n  thd->restore_active_arena(arena_for_set_stmt, backup);\n  DBUG_PRINT(\"info\", (\"mem_root: %p  arena: %p\",\n                      arena_for_set_stmt->mem_root,\n                      arena_for_set_stmt));\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":246470,"func":"static RList *r_bin_wasm_get_sections_by_id(RList *sections, ut8 id) {\n\tRList *ret = r_list_newf (NULL);\n\tif (ret) {\n\t\tRBinWasmSection *sec;\n\t\tRListIter *iter;\n\t\tr_list_foreach (sections, iter, sec) {\n\t\t\tif (sec->id == id) {\n\t\t\t\tr_list_append (ret, sec);\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":293765,"func":"static void r_kext_free(RKext *kext) {\n\tif (!kext) {\n\t\treturn;\n\t}\n\n\tif (kext->mach0) {\n\t\tMACH0_(mach0_free) (kext->mach0);\n\t\tkext->mach0 = NULL;\n\t}\n\n\tif (kext->own_name && kext->name) {\n\t\tR_FREE (kext->name);\n\t\tkext->name = NULL;\n\t}\n\n\tR_FREE (kext);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":437341,"func":"add_length(regex_t* reg, int len)\n{\n  LengthType l = (LengthType )len;\n\n  BB_ADD(reg, &l, SIZE_LENGTH);\n  return 0;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":274863,"func":"TEST(ComparisonsTest,\n     QuantizedInt8GreaterWithBroadcastMultiplierGreaterThanOne) {\n  const float kMin = -127.f;\n  const float kMax = 127.f;\n  std::vector<std::vector<int>> test_shapes = {\n      {6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};\n  for (int i = 0; i < test_shapes.size(); ++i) {\n    ComparisonOpModel model({TensorType_INT8, test_shapes[i], kMin, kMax},\n                            {TensorType_INT8, {}, kMin, kMax}, TensorType_INT8,\n                            BuiltinOperator_GREATER);\n    model.QuantizeAndPopulate<int8_t>(model.input1(),\n                                      {572, -2, -71, 8, 11, 20});\n    model.QuantizeAndPopulate<int8_t>(model.input2(), {8});\n    model.Invoke();\n    EXPECT_THAT(model.GetOutput(),\n                ElementsAre(true, false, false, false, true, true))\n        << \"With shape number \" << i;\n  }\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":500059,"func":"kssl_ctx_show(KSSL_CTX *kssl_ctx)\n        {\n\tint \ti;\n\n\tprintf(\"kssl_ctx: \");\n\tif (kssl_ctx == NULL)\n                {\n\t\tprintf(\"NULL\\n\");\n\t\treturn;\n\t\t}\n\telse\n\t\tprintf(\"%p\\n\", (void *)kssl_ctx);\n\n\tprintf(\"\\tservice:\\t%s\\n\",\n                (kssl_ctx->service_name)? kssl_ctx->service_name: \"NULL\");\n\tprintf(\"\\tclient:\\t%s\\n\",\n                (kssl_ctx->client_princ)? kssl_ctx->client_princ: \"NULL\");\n\tprintf(\"\\tserver:\\t%s\\n\",\n                (kssl_ctx->service_host)? kssl_ctx->service_host: \"NULL\");\n\tprintf(\"\\tkeytab:\\t%s\\n\",\n                (kssl_ctx->keytab_file)? kssl_ctx->keytab_file: \"NULL\");\n\tprintf(\"\\tkey [%d:%d]:\\t\",\n                kssl_ctx->enctype, kssl_ctx->length);\n\n\tfor (i=0; i < kssl_ctx->length  &&  kssl_ctx->key; i++)\n                {\n\t\tprintf(\"%02x\", kssl_ctx->key[i]);\n\t\t}\n\tprintf(\"\\n\");\n\treturn;\n        }","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":312575,"func":"f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)\n{\n# ifdef FEAT_QUICKFIX\n    win_T\t*wp;\n\n    if (in_vim9script()\n\t    && (check_for_number_arg(argvars, 0) == FAIL\n\t\t|| check_for_opt_dict_arg(argvars, 1) == FAIL))\n\treturn;\n\n    wp = find_win_by_nr_or_id(&argvars[0]);\n    get_qf_loc_list(FALSE, wp, &argvars[1], rettv);\n# endif\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":281109,"func":"static u32 xfrm_gen_index(struct net *net, int dir, u32 index)\n{\n\tstatic u32 idx_generator;\n\n\tfor (;;) {\n\t\tstruct hlist_head *list;\n\t\tstruct xfrm_policy *p;\n\t\tu32 idx;\n\t\tint found;\n\n\t\tif (!index) {\n\t\t\tidx = (idx_generator | dir);\n\t\t\tidx_generator += 8;\n\t\t} else {\n\t\t\tidx = index;\n\t\t\tindex = 0;\n\t\t}\n\n\t\tif (idx == 0)\n\t\t\tidx = 8;\n\t\tlist = net->xfrm.policy_byidx + idx_hash(net, idx);\n\t\tfound = 0;\n\t\thlist_for_each_entry(p, list, byidx) {\n\t\t\tif (p->index == idx) {\n\t\t\t\tfound = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!found)\n\t\t\treturn idx;\n\t}\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":231722,"func":"  void setSourceTokens(std::vector<folly::IPAddress> srcAddrs) {\n    sourceAddrs_ = srcAddrs;\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":512799,"func":"  longlong val_int()\n  {\n    if (value <= (double) LONGLONG_MIN)\n    {\n       return LONGLONG_MIN;\n    }\n    else if (value >= (double) (ulonglong) LONGLONG_MAX)\n    {\n      return LONGLONG_MAX;\n    }\n    return (longlong) rint(value);\n  }","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":255769,"func":"create_lookup_state(apr_pool_t *result_pool)\n{\n  lookup_state_t *state = apr_pcalloc(result_pool, sizeof(*state));\n\n  state->next = apr_array_make(result_pool, 4, sizeof(node_t *));\n  state->current = apr_array_make(result_pool, 4, sizeof(node_t *));\n\n  \/* Virtually all path segments should fit into this buffer.  If they\n   * don't, the buffer gets automatically reallocated.\n   *\n   * Using a smaller initial size would be fine as well but does not\n   * buy us much for the increased risk of being expanded anyway - at\n   * some extra cost. *\/\n  state->scratch_pad = svn_stringbuf_create_ensure(200, result_pool);\n\n  \/* Most paths should fit into this buffer.  The same rationale as\n   * above applies. *\/\n  state->parent_path = svn_stringbuf_create_ensure(200, result_pool);\n\n  return state;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":512667,"func":"  virtual void print(String *str, enum_query_type query_type)\n  {\n    decimal_value.to_string(&str_value);\n    str->append(str_value);\n  }","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":405398,"func":"static int xfrm_policy_match(const struct xfrm_policy *pol,\n\t\t\t     const struct flowi *fl,\n\t\t\t     u8 type, u16 family, int dir, u32 if_id)\n{\n\tconst struct xfrm_selector *sel = &pol->selector;\n\tint ret = -ESRCH;\n\tbool match;\n\n\tif (pol->family != family ||\n\t    pol->if_id != if_id ||\n\t    (fl->flowi_mark & pol->mark.m) != pol->mark.v ||\n\t    pol->type != type)\n\t\treturn ret;\n\n\tmatch = xfrm_selector_match(sel, fl, family);\n\tif (match)\n\t\tret = security_xfrm_policy_lookup(pol->security, fl->flowi_secid);\n\treturn ret;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":247683,"func":"TEST_P(SslSocketTest, TestConnectionFailsWhenRejectOnExpiredAndResponseExpired) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/good_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/good_key.pem\"\n      ocsp_staple:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/unknown_ocsp_resp.der\"\n  ocsp_staple_policy: strict_stapling\n  )EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites:\n      - TLS_RSA_WITH_AES_128_GCM_SHA256\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.ocsp_staple_failed\").enableOcspStapling());\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":512742,"func":"Item_func_if::fix_fields(THD *thd, Item **ref)\n{\n  DBUG_ASSERT(fixed == 0);\n  args[0]->top_level_item();\n\n  if (Item_func::fix_fields(thd, ref))\n    return 1;\n\n  return 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":402643,"func":"handle_sign_detached_with_file_type(context *ctx, struct pollfd *pollfd, socklen_t size)\n{\n\thandle_sign_helper(ctx, pollfd, size, 0, true);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":359212,"func":"static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr)\n{\n\tstruct bpf_ringbuf_map *rb_map;\n\n\tif (attr->map_flags & ~RINGBUF_CREATE_FLAG_MASK)\n\t\treturn ERR_PTR(-EINVAL);\n\n\tif (attr->key_size || attr->value_size ||\n\t    !is_power_of_2(attr->max_entries) ||\n\t    !PAGE_ALIGNED(attr->max_entries))\n\t\treturn ERR_PTR(-EINVAL);\n\n#ifdef CONFIG_64BIT\n\t\/* on 32-bit arch, it's impossible to overflow record's hdr->pgoff *\/\n\tif (attr->max_entries > RINGBUF_MAX_DATA_SZ)\n\t\treturn ERR_PTR(-E2BIG);\n#endif\n\n\trb_map = kzalloc(sizeof(*rb_map), GFP_USER | __GFP_ACCOUNT);\n\tif (!rb_map)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tbpf_map_init_from_attr(&rb_map->map, attr);\n\n\trb_map->rb = bpf_ringbuf_alloc(attr->max_entries, rb_map->map.numa_node);\n\tif (!rb_map->rb) {\n\t\tkfree(rb_map);\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\n\treturn &rb_map->map;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":466141,"func":"static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned seg,\n\t\t\t    int reg, struct operand *op)\n{\n\tint df = (ctxt->eflags & EFLG_DF) ? -1 : 1;\n\n\tregister_address_increment(ctxt, &ctxt->regs[reg], df * op->bytes);\n\top->addr.mem.ea = register_address(ctxt, ctxt->regs[reg]);\n\top->addr.mem.seg = seg;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":437683,"func":"static unsigned int txclk_tx_s_carrier(struct cx23885_dev *dev,\n\t\t\t\t       unsigned int freq,\n\t\t\t\t       u16 *divider)\n{\n\t*divider = carrier_freq_to_clock_divider(freq);\n\tcx23888_ir_write4(dev, CX23888_IR_TXCLK_REG, *divider);\n\treturn clock_divider_to_carrier_freq(*divider);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":215142,"func":"setup_secureChannel(void) {\n    TestingPolicy(&dummyPolicy, dummyCertificate, &fCalled, &keySizes);\n    UA_SecureChannel_init(&testChannel, &UA_ConnectionConfig_default);\n    UA_SecureChannel_setSecurityPolicy(&testChannel, &dummyPolicy, &dummyCertificate);\n\n    testingConnection = createDummyConnection(65535, &sentData);\n    UA_Connection_attachSecureChannel(&testingConnection, &testChannel);\n    testChannel.connection = &testingConnection;\n\n    testChannel.state = UA_SECURECHANNELSTATE_OPEN;\n}","target":1,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":312550,"func":"qf_parse_fmt_c(regmatch_T *rmp, int midx, qffields_T *fields)\n{\n    if (rmp->startp[midx] == NULL)\n\treturn QF_FAIL;\n    fields->col = (int)atol((char *)rmp->startp[midx]);\n    return QF_OK;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":238613,"func":"static int acquire_reference_state(struct bpf_verifier_env *env, int insn_idx)\n{\n\tstruct bpf_func_state *state = cur_func(env);\n\tint new_ofs = state->acquired_refs;\n\tint id, err;\n\n\terr = resize_reference_state(state, state->acquired_refs + 1);\n\tif (err)\n\t\treturn err;\n\tid = ++env->id_gen;\n\tstate->refs[new_ofs].id = id;\n\tstate->refs[new_ofs].insn_idx = insn_idx;\n\n\treturn id;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":359288,"func":"peer_aslist_unset_vty (struct vty *vty, const char *ip_str, \n                       afi_t afi, safi_t safi,\n\t\t       const char *direct_str)\n{\n  int ret;\n  struct peer *peer;\n  int direct = FILTER_IN;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  \/* Check filter direction. *\/\n  if (strncmp (direct_str, \"i\", 1) == 0)\n    direct = FILTER_IN;\n  else if (strncmp (direct_str, \"o\", 1) == 0)\n    direct = FILTER_OUT;\n\n  ret = peer_aslist_unset (peer, afi, safi, direct);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":232930,"func":"static void zstd_close_writer(struct Curl_easy *data,\n                              struct contenc_writer *writer)\n{\n  struct zstd_params *zp = (struct zstd_params *)&writer->params;\n  (void)data;\n\n  if(zp->decomp) {\n    free(zp->decomp);\n    zp->decomp = NULL;\n  }\n  if(zp->zds) {\n    ZSTD_freeDStream(zp->zds);\n    zp->zds = NULL;\n  }\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":512656,"func":"void Item_func_in::print(String *str, enum_query_type query_type)\n{\n  args[0]->print_parenthesised(str, query_type, precedence());\n  if (negated)\n    str->append(STRING_WITH_LEN(\" not\"));\n  str->append(STRING_WITH_LEN(\" in (\"));\n  print_args(str, 1, query_type);\n  str->append(STRING_WITH_LEN(\")\"));\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":409506,"func":"report_default_term(char_u *term)\n{\n    mch_errmsg(_(\"defaulting to '\"));\n    mch_errmsg((char *)term);\n    mch_errmsg(\"'\\r\\n\");\n    if (emsg_silent == 0 && !in_assert_fails)\n    {\n\tscreen_start();\t\/\/ don't know where cursor is now\n\tout_flush();\n\tif (!is_not_a_term())\n\t    ui_delay(2007L, TRUE);\n    }\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":462551,"func":"std::string controller::prepare_message(unsigned int pos, unsigned int max) {\n\tif (max > 0) {\n\t\treturn strprintf::fmt(\"(%u\/%u) \", pos, max);\n\t}\n\treturn \"\";\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":90188,"func":"static std::string ToHtmlTableHeader(Network* network) {\n  std::string str;\n  if (network->type() == TYPE_WIFI || network->type() == TYPE_CELLULAR) {\n    str += WrapWithTH(\"Name\") + WrapWithTH(\"Auto-Connect\") +\n        WrapWithTH(\"Strength\");\n    if (network->type() == TYPE_WIFI)\n      str += WrapWithTH(\"Encryption\") + WrapWithTH(\"Passphrase\") +\n          WrapWithTH(\"Identity\") + WrapWithTH(\"Certificate\");\n  }\n  str += WrapWithTH(\"State\") + WrapWithTH(\"Error\") + WrapWithTH(\"IP Address\");\n  return str;\n}\n","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":269322,"func":"  static void Run(OpKernelContext *ctx, typename TTypes<T>::Scalar &s, const typename TTypes<T>::UnalignedVec &v) {\n      s.device(ctx->eigen_cpu_device()) = v.maximum();\n  }","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":369228,"func":"\nstatic bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tif (req->file || !io_op_defs[req->opcode].needs_file)\n\t\treturn true;\n\n\tif (req->flags & REQ_F_FIXED_FILE)\n\t\treq->file = io_file_get_fixed(req, req->fd, issue_flags);\n\telse\n\t\treq->file = io_file_get_normal(req, req->fd);\n\tif (req->file)\n\t\treturn true;\n\n\treq_set_fail(req);\n\treq->result = -EBADF;\n\treturn false;","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":333065,"func":"nfa_regfree(regprog_T *prog)\n{\n    if (prog != NULL)\n    {\n\tvim_free(((nfa_regprog_T *)prog)->match_text);\n\tvim_free(((nfa_regprog_T *)prog)->pattern);\n\tvim_free(prog);\n    }\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":359596,"func":"DEFUN (clear_ip_bgp_peer_soft,\n       clear_ip_bgp_peer_soft_cmd,\n       \"clear ip bgp A.B.C.D soft\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"BGP neighbor address to clear\\n\"\n       \"Soft reconfig\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,\n\t\t\tBGP_CLEAR_SOFT_BOTH, argv[0]);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":294440,"func":"date_s_valid_weeknum_p(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vw, vd, vf, vsg;\n    VALUE argv2[5];\n\n    rb_scan_args(argc, argv, \"41\", &vy, &vw, &vd, &vf, &vsg);\n\n    argv2[0] = vy;\n    argv2[1] = vw;\n    argv2[2] = vd;\n    argv2[3] = vf;\n    if (argc < 5)\n\targv2[4] = INT2FIX(DEFAULT_SG);\n    else\n\targv2[4] = vsg;\n\n    if (NIL_P(valid_weeknum_sub(5, argv2, klass, 0)))\n\treturn Qfalse;\n    return Qtrue;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":336682,"func":"SPICE_GNUC_VISIBLE int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag)\n{\n    s->config->exit_on_disconnect = !!flag;\n    return 0;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":276443,"func":"  explicit BoostedTreesGetEnsembleStatesOp(OpKernelConstruction* context)\n      : OpKernel(context) {}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":90792,"func":"void QuotaManager::NotifyOriginInUse(const GURL& origin) {\n  DCHECK(io_thread_->BelongsToCurrentThread());\n  origins_in_use_[origin]++;\n}\n","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":353234,"func":"bool SplashOutputDev::checkTransparencyGroup(GfxState *state, bool knockout) {\n  if (state->getFillOpacity() != 1 || \n    state->getStrokeOpacity() != 1 ||\n    state->getAlphaIsShape() ||\n    state->getBlendMode() != gfxBlendNormal ||\n    splash->getSoftMask() != nullptr ||\n    knockout) \n    return true;\n  return transpGroupStack != nullptr && transpGroupStack->shape != nullptr;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":90750,"func":"void QuotaManager::DeleteOnCorrectThread() const {\n  if (!io_thread_->BelongsToCurrentThread()) {\n    io_thread_->DeleteSoon(FROM_HERE, this);\n    return;\n  }\n  delete this;\n}\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":247748,"func":"void updateFilterChain(\n    const envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext& tls_context,\n    envoy::config::listener::v3::FilterChain& filter_chain) {\n  filter_chain.mutable_transport_socket()->mutable_typed_config()->PackFrom(tls_context);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":473820,"func":"onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,\n\t\t\t\t  OnigApplyAllCaseFoldFunc f, void* arg,\n\t\t\t\t  OnigEncoding enc ARG_UNUSED)\n{\n  OnigCodePoint code;\n  int i, r;\n\n  for (i = 0;\n       i < (int )(sizeof(OnigAsciiLowerMap)\/sizeof(OnigPairCaseFoldCodes));\n       i++) {\n    code = OnigAsciiLowerMap[i].to;\n    r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);\n    if (r != 0) return r;\n\n    code = OnigAsciiLowerMap[i].from;\n    r = (*f)(OnigAsciiLowerMap[i].to, &code, 1, arg);\n    if (r != 0) return r;\n  }\n\n  return 0;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":244359,"func":"GF_Err tsro_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TimeOffHintEntryBox *ptr = (GF_TimeOffHintEntryBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->TimeOffset);\n\treturn GF_OK;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":247610,"func":"TEST_P(SslReadBufferLimitTest, WritesLargerThanBufferLimit) { singleWriteTest(1024, 5 * 1024); }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":338124,"func":"void WasmBinaryBuilder::throwError(std::string text) {\n  throw ParseException(text, 0, pos);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":473849,"func":"cp1251_apply_all_case_fold(OnigCaseFoldType flag,\n\t\t\t       OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc ARG_UNUSED)\n{\n  return onigenc_apply_all_case_fold_with_map(\n             sizeof(CaseFoldMap)\/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,\n             flag, f, arg);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":225067,"func":"PQserverVersion(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn 0;\n\tif (conn->status == CONNECTION_BAD)\n\t\treturn 0;\n\treturn conn->sversion;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":220233,"func":"NodeDef* Node::mutable_def() { return &props_->node_def; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":450337,"func":"gboolean vnc_client_io(QIOChannel *ioc G_GNUC_UNUSED,\n                       GIOCondition condition, void *opaque)\n{\n    VncState *vs = opaque;\n\n    assert(vs->magic == VNC_MAGIC);\n    if (condition & G_IO_IN) {\n        if (vnc_client_read(vs) < 0) {\n            \/* vs is free()ed here *\/\n            return TRUE;\n        }\n    }\n    if (condition & G_IO_OUT) {\n        vnc_client_write(vs);\n    }\n\n    if (vs->disconnecting) {\n        if (vs->ioc_tag != 0) {\n            g_source_remove(vs->ioc_tag);\n        }\n        vs->ioc_tag = 0;\n    }\n    return TRUE;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":90791,"func":"  HostUsageCallback* NewWaitableHostUsageCallback() {\n    ++waiting_callbacks_;\n    return callback_factory_.NewCallback(\n            &UsageAndQuotaDispatcherTask::DidGetHostUsage);\n  }\n","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":442579,"func":"static void test_memslot_invalid_addresses(void)\n{\n    g_test_trap_subprocess(\"\/server\/memslot-invalid-addresses\/subprocess\/group_id\", 0, 0);\n    g_test_trap_assert_stderr(\"*group_id too big*\");\n\n    g_test_trap_subprocess(\"\/server\/memslot-invalid-addresses\/subprocess\/slot_id\", 0, 0);\n    g_test_trap_assert_stderr(\"*slot_id 1 too big*\");\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":254066,"func":"        std::vector<std::string> keys() const\n        {\n            std::vector<std::string> ret;\n            for (auto element : key_value_pairs_)\n            {\n                std::string str_element(element);\n                ret.emplace_back(str_element.substr(0, str_element.find('=')));\n            }\n            return ret;\n        }","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":222492,"func":"Status FunctionLibraryDefinition::AddFunctionDef(\n    const FunctionDef& fdef, const StackTracesMap& stack_traces) {\n  mutex_lock l(mu_);\n  bool added;\n  return AddFunctionDefHelper(fdef, stack_traces, &added);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":345209,"func":"console_map_init(void)\n{\n\tint i;\n\t\n\tfor (i = 0; i < MAX_NR_CONSOLES; i++)\n\t\tif (vc_cons_allocated(i) && !*vc_cons[i].d->vc_uni_pagedir_loc)\n\t\t\tcon_set_default_unimap(vc_cons[i].d);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":509547,"func":"int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)\n{\n  int error;\n  HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);\n\n  if (!file || !param)\n    return HA_ADMIN_INTERNAL_ERROR;\n\n  maria_chk_init(param);\n  param->thd= thd;\n  param->op_name= \"optimize\";\n  param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |\n                   T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);\n  param->orig_sort_buffer_length= THDVAR(thd, sort_buffer_size);\n  thd_progress_init(thd, 1);\n  if ((error= repair(thd, param, 1)) && param->retry_repair)\n  {\n    sql_print_warning(\"Warning: Optimize table got errno %d on %s.%s, retrying\",\n                      my_errno, param->db_name, param->table_name);\n    param->testflag &= ~T_REP_BY_SORT;\n    error= repair(thd, param, 0);\n  }\n  thd_progress_end(thd);\n  return error;\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":90835,"func":"  void DeleteClientOriginData(QuotaClient* client,\n                        const GURL& origin,\n                        StorageType type) {\n    DCHECK(client);\n    quota_status_ = kQuotaStatusUnknown;\n    client->DeleteOriginData(origin, type,\n        callback_factory_.NewCallback(\n            &QuotaManagerTest::StatusCallback));\n  }\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":512355,"func":"  bool check_is_evaluable_expression_or_error()\n  {\n    if (is_evaluable_expression())\n      return false; \/\/ Ok\n    raise_error_not_evaluable();\n    return true;    \/\/ Error\n  }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":275961,"func":"unsigned uECC_curve_num_words(uECC_Curve curve) {\n    return curve->num_words;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":413632,"func":"R_API RGraph *r_core_anal_importxrefs(RCore *core) {\n\tRBinInfo *info = r_bin_get_info (core->bin);\n\tRBinObject *obj = r_bin_cur_object (core->bin);\n\tbool lit = info? info->has_lit: false;\n\tbool va = core->io->va || r_config_get_b (core->config, \"cfg.debug\");\n\n\tRListIter *iter;\n\tRBinImport *imp;\n\tif (!obj) {\n\t\treturn NULL;\n\t}\n\tRGraph *graph = r_graph_new ();\n\tif (!graph) {\n\t\treturn NULL;\n\t}\n\tr_list_foreach (obj->imports, iter, imp) {\n\t\tut64 addr = lit ? r_core_bin_impaddr (core->bin, va, imp->name): 0;\n\t\tif (addr) {\n\t\t\tadd_single_addr_xrefs (core, addr, graph);\n\t\t} else {\n\t\t\tr_graph_add_node_info (graph, imp->name, NULL, 0);\n\t\t}\n\t}\n\treturn graph;\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":274851,"func":"  int input2() { return input2_; }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":344807,"func":"sanitise_stdfd(void)\n{\n\tint nullfd, dupfd;\n\n\tif ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) {\n\t\tfprintf(stderr, \"Couldn't open \/dev\/null: %s\\n\",\n\t\t    strerror(errno));\n\t\texit(1);\n\t}\n\twhile (++dupfd <= STDERR_FILENO) {\n\t\t\/* Only populate closed fds. *\/\n\t\tif (fcntl(dupfd, F_GETFL) == -1 && errno == EBADF) {\n\t\t\tif (dup2(nullfd, dupfd) == -1) {\n\t\t\t\tfprintf(stderr, \"dup2: %s\\n\", strerror(errno));\n\t\t\t\texit(1);\n\t\t\t}\n\t\t}\n\t}\n\tif (nullfd > STDERR_FILENO)\n\t\tclose(nullfd);\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":488333,"func":"const char *arch_vma_name(struct vm_area_struct *vma)\n{\n\tif (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso_base)\n\t\treturn \"[vdso]\";\n\treturn NULL;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":232306,"func":"void gf_isom_box_array_del(GF_List *boxlist)\n{\n\tgf_isom_box_array_reset(boxlist);\n\tgf_list_del(boxlist);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":384126,"func":"raptor_xml_writer_get_depth(raptor_xml_writer *xml_writer)\n{\n  return xml_writer->depth;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":261736,"func":"void RtmpProtocol::sendInvoke(const string &cmd, const AMFValue &val) {\n    AMFEncoder enc;\n    enc << cmd << ++_send_req_id << val;\n    sendRequest(MSG_CMD, enc.data());\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":225629,"func":"\nvoid xtra_box_del(GF_Box *s)\n{\n\tGF_XtraBox *ptr = (GF_XtraBox *)s;\n\twhile (gf_list_count(ptr->tags)) {\n\t\tGF_XtraTag *tag = gf_list_pop_back(ptr->tags);\n\t\tif (tag->name) gf_free(tag->name);\n\t\tif (tag->prop_value) gf_free(tag->prop_value);\n\t\tgf_free(tag);\n\t}\n\tgf_list_del(ptr->tags);\n\tgf_free(s);","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":385804,"func":"int finish_no_open(struct file *file, struct dentry *dentry)\n{\n\tfile->f_path.dentry = dentry;\n\treturn 1;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":318780,"func":"new_state(drill_state_t *state)\n{\n    state = g_new0(drill_state_t, 1);\n    if (state != NULL) {\n\t\/* Init structure *\/\n\tstate->curr_section = DRILL_NONE;\n\tstate->coordinate_mode = DRILL_MODE_ABSOLUTE;\n\tstate->origin_x = 0.0;\n\tstate->origin_y = 0.0;\n\tstate->unit = GERBV_UNIT_UNSPECIFIED;\n\tstate->backup_number_format = FMT_000_000; \/* only used for METRIC *\/\n\tstate->header_number_format = state->number_format = FMT_00_0000; \/* i. e. INCH *\/\n\tstate->autod = 1;\n\tstate->decimals = 4;\n    }\n\n    return state;\n} \/* new_state *\/","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":310099,"func":"drv_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms)\n{\n#if HAVE_NANOSLEEP\n    {\n\tstruct timespec request, remaining;\n\trequest.tv_sec = ms \/ 1000;\n\trequest.tv_nsec = (ms % 1000) * 1000000;\n\twhile (nanosleep(&request, &remaining) == -1\n\t       && errno == EINTR) {\n\t    request = remaining;\n\t}\n    }\n#else\n    _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));\n#endif\n    return OK;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":513263,"func":"bool instantiate_tmp_table(TABLE *table, KEY *keyinfo, \n                           TMP_ENGINE_COLUMNDEF *start_recinfo,\n                           TMP_ENGINE_COLUMNDEF **recinfo,\n                           ulonglong options)\n{\n  if (table->s->db_type() == TMP_ENGINE_HTON)\n  {\n    if (create_internal_tmp_table(table, keyinfo, start_recinfo, recinfo,\n                                  options))\n      return TRUE;\n    \/\/ Make empty record so random data is not written to disk\n    empty_record(table);\n    table->status= STATUS_NO_RECORD;\n  }\n  if (open_tmp_table(table))\n    return TRUE;\n\n  return FALSE;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":226328,"func":"GF_Box *drep_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DREPBox, GF_ISOM_BOX_TYPE_DREP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":383355,"func":"gdImageAntialias (gdImagePtr im, int antialias)\n{\n\tif (im->trueColor){\n\t\tim->antialias = antialias;\n\t}\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":234784,"func":"static bool contains_pending_extent(struct btrfs_device *device, u64 *start,\n\t\t\t\t    u64 len)\n{\n\tu64 physical_start, physical_end;\n\n\tlockdep_assert_held(&device->fs_info->chunk_mutex);\n\n\tif (!find_first_extent_bit(&device->alloc_state, *start,\n\t\t\t\t   &physical_start, &physical_end,\n\t\t\t\t   CHUNK_ALLOCATED, NULL)) {\n\n\t\tif (in_range(physical_start, *start, len) ||\n\t\t    in_range(*start, physical_start,\n\t\t\t     physical_end - physical_start)) {\n\t\t\t*start = physical_end + 1;\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":402586,"func":"void cms_set_pw_data(cms_context *cms, secuPWData *pwdata)\n{\n\tingress();\n\n\tswitch (cms->pwdata.source) {\n\tcase PW_SOURCE_INVALID:\n\tcase PW_PROMPT:\n\tcase PW_DEVICE:\n\tcase PW_SOURCE_MAX:\n\t\tbreak;\n\n\tcase PW_FROMENV:\n\tcase PW_FROMFILEDB:\n\tcase PW_PLAINTEXT:\n\t\tmemset(cms->pwdata.data, 0, strlen(cms->pwdata.data));\n\t\txfree(cms->pwdata.data);\n\t\tbreak;\n\n\tcase PW_DATABASE:\n\t\txfree(cms->pwdata.data);\n\t\tbreak;\n\t}\n\tmemmove(&cms->pwdata, pwdata, sizeof(*pwdata));\n\n\tdprintf(\"pwdata:%p\", pwdata);\n\tdprintf(\"pwdata->source:%d\", pwdata->source);\n\tdprintf(\"pwdata->data:%p (\\\"%s\\\")\", pwdata->data,\n\t\tpwdata->data ? pwdata->data : \"(null)\");\n\tegress();\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":512937,"func":"Item_func_regexp_instr::fix_length_and_dec()\n{\n  if (agg_arg_charsets_for_comparison(cmp_collation, args, 2))\n    return TRUE;\n\n  re.init(cmp_collation.collation, 0);\n  re.fix_owner(this, args[0], args[1]);\n  max_length= MY_INT32_NUM_DECIMAL_DIGITS; \/\/ See also Item_func_locate\n  return FALSE;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":506439,"func":"mech_rpa_build_token4(struct rpa_auth_request *request, size_t *size)\n{\n\tbuffer_t *buf;\n\tunsigned char server_response[MD5_RESULTLEN];\n\tunsigned int length = sizeof(rpa_oid) +\n\t\tsizeof(server_response) + 1 +\n\t\tsizeof(request->session_key) + 1 + 1;\n\n\tbuf = buffer_create_dynamic(request->pool, length + 4);\n\n\tbuffer_append_c(buf, ASN1_APPLICATION);\n\tbuffer_append_asn1_length(buf, length);\n\tbuffer_append(buf, rpa_oid, sizeof(rpa_oid));\n\n\t\/* Generate random session key *\/\n\trandom_fill(request->session_key, sizeof(request->session_key));\n\n\t\/* Server authentication response *\/\n\trpa_server_response(request, server_response);\n\tbuffer_append_c(buf, sizeof(server_response));\n\tbuffer_append(buf, server_response, sizeof(server_response));\n\n\tbuffer_append_c(buf, sizeof(request->session_key));\n\tbuffer_append(buf, request->session_key, sizeof(request->session_key));\n\n\t\/* Status, 0 - success *\/\n\tbuffer_append_c(buf, 0);\n\n\t*size = buf->used;\n\treturn buffer_free_without_data(&buf);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":462307,"func":"stputs(stream * s, const char *str)\n{\n    uint ignore_count;\n\n    sputs(s, (const byte *)str, strlen(str), &ignore_count);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":401589,"func":"static inline struct timer_base *get_timer_this_cpu_base(u32 tflags)\n{\n\tstruct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);\n\n\t\/*\n\t * If the timer is deferrable and NO_HZ_COMMON is set then we need\n\t * to use the deferrable base.\n\t *\/\n\tif (IS_ENABLED(CONFIG_NO_HZ_COMMON) && (tflags & TIMER_DEFERRABLE))\n\t\tbase = this_cpu_ptr(&timer_bases[BASE_DEF]);\n\treturn base;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":309984,"func":"usage(void)\n{\n    static const char *msg[] =\n    {\n\t\"Usage: dots [options]\"\n\t,\"\"\n\t,\"Options:\"\n\t,\" -T TERM  override $TERM\"\n#if HAVE_USE_ENV\n\t,\" -e       allow environment $LINES \/ $COLUMNS\"\n#endif\n\t,\" -f       use tigetnum rather than <term.h> mapping\"\n\t,\" -m SIZE  set margin (default: 2)\"\n\t,\" -r SECS  self-interrupt\/exit after specified number of seconds\"\n\t,\" -s MSECS delay 1% of the time (default: 1 msecs)\"\n    };\n    size_t n;\n\n    for (n = 0; n < SIZEOF(msg); n++)\n\tfprintf(stderr, \"%s\\n\", msg[n]);\n\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":101675,"func":"void WebProcessProxy::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, bool& didHandleMessage)\n{\n    if (decoder.messageReceiverName() == Messages::WebProcessProxy::messageReceiverName())\n        didReceiveWebProcessProxyMessageOnConnectionWorkQueue(connection, messageID, decoder, didHandleMessage);\n}\n","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":430465,"func":"    ~GopherStateData() {if(buf) swanSong();}","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":225635,"func":"GF_Err hnti_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":474085,"func":"is_mbc_newline(const UChar* p, const UChar* end, OnigEncoding enc)\n{\n  if (p < end) {\n    if (*p == 0x0a) return 1;\n\n#ifdef USE_UNICODE_ALL_LINE_TERMINATORS\n#ifndef USE_CRNL_AS_LINE_TERMINATOR\n    if (*p == 0x0d) return 1;\n#endif\n    if (p + 1 < end) {\n      if (*(p+1) == 0x85 && *p == 0xc2) \/* U+0085 *\/\n\treturn 1;\n      if (p + 2 < end) {\n\tif ((*(p+2) == 0xa8 || *(p+2) == 0xa9)\n\t    && *(p+1) == 0x80 && *p == 0xe2)  \/* U+2028, U+2029 *\/\n\t  return 1;\n      }\n    }\n#endif\n  }\n\n  return 0;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":234780,"func":"struct list_head * __attribute_const__ btrfs_get_fs_uuids(void)\n{\n\treturn &fs_uuids;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":369247,"func":"static int io_async_buf_func(struct wait_queue_entry *wait, unsigned mode,\n\t\t\t     int sync, void *arg)\n{\n\tstruct wait_page_queue *wpq;\n\tstruct io_kiocb *req = wait->private;\n\tstruct wait_page_key *key = arg;\n\n\twpq = container_of(wait, struct wait_page_queue, wait);\n\n\tif (!wake_page_match(wpq, key))\n\t\treturn 0;\n\n\treq->rw.kiocb.ki_flags &= ~IOCB_WAITQ;\n\tlist_del_init(&wait->entry);\n\tio_req_task_queue(req);\n\treturn 1;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":343222,"func":"void domlst(const char * const file)\n{\n    char line[PATH_MAX + 256U] = MLST_BEGIN;\n\n    if (modernformat(file, line + (sizeof MLST_BEGIN - 1U),\n                     sizeof line - (sizeof MLST_BEGIN - 1U), \" \") < 0) {\n        addreply_noformat(550, MSG_STAT_FAILURE2);\n        return;\n    }\n    addreply_noformat(0, line);\n    addreply_noformat(250, \"End.\");\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":313750,"func":"nv_ignore(cmdarg_T *cap)\n{\n    cap->retval |= CA_COMMAND_BUSY;\t\/\/ don't call edit() now\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":289261,"func":"static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,\n\t\t\t\t     bool trylock)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tint err;\n\n\tif (trylock) {\n\t\tif (!(mutex_trylock(&runtime->oss.params_lock)))\n\t\t\treturn -EAGAIN;\n\t} else if (mutex_lock_interruptible(&runtime->oss.params_lock))\n\t\treturn -ERESTARTSYS;\n\n\terr = snd_pcm_oss_change_params_locked(substream);\n\tmutex_unlock(&runtime->oss.params_lock);\n\treturn err;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":445869,"func":"fr_window_set_password_for_second_archive (FrWindow   *window,\n\t\t\t\t\t   const char *password)\n{\n\tg_return_if_fail (window != NULL);\n\n\tif (window->priv->second_password != NULL) {\n\t\tg_free (window->priv->second_password);\n\t\twindow->priv->second_password = NULL;\n\t}\n\n\tif ((password != NULL) && (password[0] != '\\0'))\n\t\twindow->priv->second_password = g_strdup (password);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":387745,"func":"instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {\n  if (TraceFinalizerRegistration) {\n    tty->print(\"Registered \");\n    i->print_value_on(tty);\n    tty->print_cr(\" (\" INTPTR_FORMAT \") as finalizable\", p2i(i));\n  }\n  instanceHandle h_i(THREAD, i);\n  \/\/ Pass the handle as argument, JavaCalls::call expects oop as jobjects\n  JavaValue result(T_VOID);\n  JavaCallArguments args(h_i);\n  methodHandle mh (THREAD, Universe::finalizer_register_method());\n  JavaCalls::call(&result, mh, &args, CHECK_NULL);\n  return h_i();\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":432148,"func":"SkipThenLimit extractSkipAndLimitForPushdown(Pipeline* pipeline) {\n    \/\/ If the disablePipelineOptimization failpoint is enabled, then do not attempt the limit and\n    \/\/ skip pushdown optimization.\n    if (MONGO_unlikely(disablePipelineOptimization.shouldFail())) {\n        return {boost::none, boost::none};\n    }\n    auto&& sources = pipeline->getSources();\n\n    \/\/ It is important to call 'extractLimitForPushdown' before 'extractSkipForPushdown'. Otherwise\n    \/\/ there could be a situation when $limit stages in pipeline would prevent\n    \/\/ 'extractSkipForPushdown' from extracting all $skip stages.\n    auto limit = extractLimitForPushdown(sources.begin(), &sources);\n    auto skip = extractSkipForPushdown(sources.begin(), &sources);\n    auto skipThenLimit = LimitThenSkip(limit, skip).flip();\n    if (skipThenLimit.getSkip() || skipThenLimit.getLimit()) {\n        \/\/ Removing stages may have produced the opportunity for additional optimizations.\n        pipeline->optimizePipeline();\n    }\n    return skipThenLimit;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":400411,"func":"ins_down(\n    int\t\tstartcol)\t\/\/ when TRUE move to Insstart.col\n{\n    pos_T\ttpos;\n    linenr_T\told_topline = curwin->w_topline;\n#ifdef FEAT_DIFF\n    int\t\told_topfill = curwin->w_topfill;\n#endif\n\n    undisplay_dollar();\n    tpos = curwin->w_cursor;\n    if (cursor_down(1L, TRUE) == OK)\n    {\n\tif (startcol)\n\t    coladvance(getvcol_nolist(&Insstart));\n\tif (old_topline != curwin->w_topline\n#ifdef FEAT_DIFF\n\t\t|| old_topfill != curwin->w_topfill\n#endif\n\t\t)\n\t    redraw_later(UPD_VALID);\n\tstart_arrow(&tpos);\n\tcan_cindent = TRUE;\n    }\n    else\n\tvim_beep(BO_CRSR);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":312505,"func":"qf_get_valid_size(exarg_T *eap)\n{\n    qf_info_T\t*qi;\n    qf_list_T\t*qfl;\n    qfline_T\t*qfp;\n    int\t\ti, sz = 0;\n    int\t\tprev_fnum = 0;\n\n    if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL)\n\treturn 0;\n\n    qfl = qf_get_curlist(qi);\n    FOR_ALL_QFL_ITEMS(qfl, qfp, i)\n    {\n\tif (qfp->qf_valid)\n\t{\n\t    if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)\n\t\tsz++;\t\/\/ Count all valid entries\n\t    else if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum)\n\t    {\n\t\t\/\/ Count the number of files\n\t\tsz++;\n\t\tprev_fnum = qfp->qf_fnum;\n\t    }\n\t}\n    }\n\n    return sz;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":417085,"func":"bool PlayerGeneric::isEnabled(PlayModeOptions option) const\n{\n\tASSERT(option>=PlayModeOptionFirst && option<PlayModeOptionLast);\n\t\n\tif (!player)\n\t\treturn options[option];\n\telse \n\t\treturn player->isEnabled(option);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":310188,"func":"NCURSES_SP_NAME(has_mouse) (NCURSES_SP_DCL0)\n{\n    return _nc_has_mouse(SP_PARM);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":508782,"func":"void end_read_record(READ_RECORD *info)\n{\n  \/* free cache if used *\/\n  free_cache(info);\n  if (info->table)\n  {\n    if (info->table->db_stat) \/\/ if opened\n      (void) info->table->file->extra(HA_EXTRA_NO_CACHE);\n    if (info->read_record != rr_quick) \/\/ otherwise quick_range does it\n      (void) info->table->file->ha_index_or_rnd_end();\n    info->table=0;\n  }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":508877,"func":"List<Item>* st_select_lex::get_item_list()\n{\n  return &item_list;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":253524,"func":"smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,\n\t       __u64 length, __u32 type, int lock, int unlock, bool wait)\n{\n\tif (unlock && !lock)\n\t\ttype = SMB2_LOCKFLAG_UNLOCK;\n\treturn SMB2_lock(xid, tlink_tcon(cfile->tlink),\n\t\t\t cfile->fid.persistent_fid, cfile->fid.volatile_fid,\n\t\t\t current->tgid, length, offset, type, wait);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":359547,"func":"DEFUN (no_neighbor_allowas_in,\n       no_neighbor_allowas_in_cmd,\n       NO_NEIGHBOR_CMD2 \"allowas-in\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"allow local ASN appears in aspath attribute\\n\")\n{\n  int ret;\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, argv[0]);\n  if (! peer)\n    return CMD_WARNING;\n\n  ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":513010,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_uint>(thd, this); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":247155,"func":"u32 gf_fs_get_http_rate(GF_FilterSession *fs)\n{\n\tif (!fs->download_manager) {\n\t\tgf_fs_get_download_manager(fs);\n\t\tif (!fs->download_manager) return 0;\n\t}\n\treturn gf_dm_get_global_rate(fs->download_manager);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":224540,"func":"Status GetWindowedOutputSizeFromDims(\n    shape_inference::InferenceContext* c,\n    shape_inference::DimensionHandle input_size,\n    shape_inference::DimensionOrConstant filter_size, int64_t stride,\n    Padding padding_type, shape_inference::DimensionHandle* output_size) {\n  if (padding_type == Padding::EXPLICIT) {\n    return errors::Internal(\n        \"GetWindowedOutputSizeFromDims does not handle EXPLICIT padding; call \"\n        \"GetWindowedOutputSizeFromDimsV2 instead\");\n  }\n  return GetWindowedOutputSizeFromDimsV2(c, input_size, filter_size,\n                                         \/*dilation_rate=*\/1, stride,\n                                         padding_type,\n                                         \/\/ Give dummy values of -1 to\n                                         \/\/ padding_before and padding_after,\n                                         \/\/ since explicit padding is not used.\n                                         -1, -1, output_size);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":512860,"func":"  virtual void update_null_value ()\n  {\n    return type_handler()->Item_update_null_value(this);\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":231634,"func":"TEST_F(QuicServerTransportTest, RecvNewConnectionIdValid) {\n  auto& conn = server->getNonConstConn();\n  conn.transportSettings.selfActiveConnectionIdLimit = 2;\n\n  ShortHeader header(ProtectionType::KeyPhaseZero, *conn.clientConnectionId, 1);\n  RegularQuicPacketBuilder builder(\n      conn.udpSendPacketLen, std::move(header), 0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  ASSERT_TRUE(builder.canBuildPacket());\n  NewConnectionIdFrame newConnId(\n      1, 0, ConnectionId({2, 4, 2, 3}), StatelessResetToken{9, 8, 7, 6});\n  writeSimpleFrame(QuicSimpleFrame(newConnId), builder);\n\n  auto packet = std::move(builder).buildPacket();\n\n  EXPECT_EQ(conn.peerConnectionIds.size(), 1);\n  deliverData(packetToBuf(packet), false);\n  EXPECT_EQ(conn.peerConnectionIds.size(), 2);\n  EXPECT_EQ(conn.peerConnectionIds[1].connId, newConnId.connectionId);\n  EXPECT_EQ(conn.peerConnectionIds[1].sequenceNumber, newConnId.sequenceNumber);\n  EXPECT_EQ(conn.peerConnectionIds[1].token, newConnId.token);\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":225811,"func":"GF_Box *stss_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SyncSampleBox, GF_ISOM_BOX_TYPE_STSS);\n\treturn (GF_Box*)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":398552,"func":"static size_t std_opcode_args_count(const RzBinDwarfLineHeader *hdr, ut8 opcode) {\n\tif (!opcode || opcode > hdr->opcode_base - 1 || !hdr->std_opcode_lengths) {\n\t\treturn 0;\n\t}\n\treturn hdr->std_opcode_lengths[opcode - 1];\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":482526,"func":"getNextAttribute(TranslationTableHeader *table) {\n\t\/* Get the next attribute value, or 0 if there is no more space in the table. *\/\n\tTranslationTableCharacterAttributes next = table->nextCharacterClassAttribute;\n\tif (next) {\n\t\tif (next == CTC_LitDigit)\n\t\t\ttable->nextCharacterClassAttribute = CTC_UserDefined9;\n\t\telse\n\t\t\ttable->nextCharacterClassAttribute <<= 1;\n\t\treturn next;\n\t} else\n\t\treturn getNextNumberedAttribute(table);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":344232,"func":"static int lessthanothers (lua_State *L, const TValue *l, const TValue *r) {\n  lua_assert(!ttisnumber(l) || !ttisnumber(r));\n  if (ttisstring(l) && ttisstring(r))  \/* both are strings? *\/\n    return l_strcmp(tsvalue(l), tsvalue(r)) < 0;\n  else\n    return luaT_callorderTM(L, l, r, TM_LT);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":404749,"func":"static void copy_fd_bitmaps(struct fdtable *nfdt, struct fdtable *ofdt,\n\t\t\t    unsigned int count)\n{\n\tunsigned int cpy, set;\n\n\tcpy = count \/ BITS_PER_BYTE;\n\tset = (nfdt->max_fds - count) \/ BITS_PER_BYTE;\n\tmemcpy(nfdt->open_fds, ofdt->open_fds, cpy);\n\tmemset((char *)nfdt->open_fds + cpy, 0, set);\n\tmemcpy(nfdt->close_on_exec, ofdt->close_on_exec, cpy);\n\tmemset((char *)nfdt->close_on_exec + cpy, 0, set);\n\n\tcpy = BITBIT_SIZE(count);\n\tset = BITBIT_SIZE(nfdt->max_fds) - cpy;\n\tmemcpy(nfdt->full_fds_bits, ofdt->full_fds_bits, cpy);\n\tmemset((char *)nfdt->full_fds_bits + cpy, 0, set);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":90227,"func":"  virtual bool wifi_connecting() const {\n    return wifi_ ? wifi_->connecting() : false;\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":387592,"func":"static int snd_ctl_dev_disconnect(struct snd_device *device)\n{\n\tstruct snd_card *card = device->device_data;\n\tstruct snd_ctl_file *ctl;\n\tstruct snd_ctl_layer_ops *lops;\n\tunsigned long flags;\n\n\tread_lock_irqsave(&card->ctl_files_rwlock, flags);\n\tlist_for_each_entry(ctl, &card->ctl_files, list) {\n\t\twake_up(&ctl->change_sleep);\n\t\tsnd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR);\n\t}\n\tread_unlock_irqrestore(&card->ctl_files_rwlock, flags);\n\n\tdown_read(&card->controls_rwsem);\n\tdown_read(&snd_ctl_layer_rwsem);\n\tfor (lops = snd_ctl_layer; lops; lops = lops->next)\n\t\tlops->ldisconnect(card);\n\tup_read(&snd_ctl_layer_rwsem);\n\tup_read(&card->controls_rwsem);\n\n\treturn snd_unregister_device(&card->ctl_dev);\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":506687,"func":"static int check_message(const struct set_name_fn *fn, const char *op,\n                         const char *nameincert, int match, const char *name)\n{\n    char msg[1024];\n\n    if (match < 0)\n        return 1;\n    BIO_snprintf(msg, sizeof(msg), \"%s: %s: [%s] %s [%s]\",\n                 fn->name, op, nameincert,\n                 match ? \"matches\" : \"does not match\", name);\n    if (is_exception(msg))\n        return 1;\n    TEST_error(\"%s\", msg);\n    return 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":343172,"func":"static int __init esp6_init(void)\n{\n\tif (xfrm_register_type(&esp6_type, AF_INET6) < 0) {\n\t\tpr_info(\"%s: can't add xfrm type\\n\", __func__);\n\t\treturn -EAGAIN;\n\t}\n\tif (xfrm6_protocol_register(&esp6_protocol, IPPROTO_ESP) < 0) {\n\t\tpr_info(\"%s: can't add protocol\\n\", __func__);\n\t\txfrm_unregister_type(&esp6_type, AF_INET6);\n\t\treturn -EAGAIN;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":213075,"func":"void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)\n{\n\tstruct nci_dev *ndev = priv->ndev;\n\n\tif (priv->ndev->nfc_dev->fw_download_in_progress)\n\t\tnfcmrvl_fw_dnld_abort(priv);\n\n\tnfcmrvl_fw_dnld_deinit(priv);\n\n\tif (gpio_is_valid(priv->config.reset_n_io))\n\t\tgpio_free(priv->config.reset_n_io);\n\n\tnci_unregister_device(ndev);\n\tnci_free_device(ndev);\n\tkfree(priv);\n}","target":1,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":220033,"func":"  ~SparseTensorAccessingOp() override {\n    if (sparse_tensors_map_) sparse_tensors_map_->Unref();\n  }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":328842,"func":"R_API RBinJavaStackMapFrame *r_bin_java_default_stack_frame(void) {\n\tRBinJavaStackMapFrame *sf = R_NEW0 (RBinJavaStackMapFrame);\n\tif (!sf) {\n\t\treturn NULL;\n\t}\n\tsf->metas = R_NEW0 (RBinJavaMetaInfo);\n\tif (!sf->metas) {\n\t\tfree (sf);\n\t\treturn NULL;\n\t}\n\tsf->metas->type_info = (void *) &R_BIN_JAVA_STACK_MAP_FRAME_METAS[R_BIN_JAVA_STACK_FRAME_IMPLICIT];\n\tsf->type = ((RBinJavaStackMapFrameMetas *) sf->metas->type_info)->type;\n\tsf->local_items = r_list_newf (r_bin_java_verification_info_free);\n\tsf->stack_items = r_list_newf (r_bin_java_verification_info_free);\n\tsf->number_of_stack_items = 0;\n\tsf->number_of_locals = 0;\n\treturn sf;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":513075,"func":"  String *val_str(String *to)\n  {\n    return m_value.to_datetime(current_thd).to_string(to, decimals);\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":247147,"func":"static Bool fsess_on_event(void *cbk, GF_Event *evt)\n{\n\treturn GF_TRUE;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":294457,"func":"date_s_valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vm, vn, vk, vsg;\n    VALUE argv2[5];\n\n    rb_scan_args(argc, argv, \"41\", &vy, &vm, &vn, &vk, &vsg);\n\n    argv2[0] = vy;\n    argv2[1] = vm;\n    argv2[2] = vn;\n    argv2[3] = vk;\n    if (argc < 5)\n\targv2[4] = INT2FIX(DEFAULT_SG);\n    else\n\targv2[4] = vsg;\n\n    if (NIL_P(valid_nth_kday_sub(5, argv2, klass, 0)))\n\treturn Qfalse;\n    return Qtrue;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":267987,"func":"R_API bool r_bin_file_delete(RBin *bin, ut32 bin_id) {\n\tr_return_val_if_fail (bin, false);\n\n\tRListIter *iter;\n\tRBinFile *bf, *cur = r_bin_cur (bin);\n\n\tr_list_foreach (bin->binfiles, iter, bf) {\n\t\tif (bf && bf->id == bin_id) {\n\t\t\tif (cur && cur->id == bin_id) {\n\t\t\t\t\/\/ avoiding UaF due to dead reference\n\t\t\t\tbin->cur = NULL;\n\t\t\t}\n\t\t\tr_list_delete (bin->binfiles, iter);\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":310085,"func":"write_tabs(int *tab_list)\n{\n    int stop;\n\n    while ((stop = *tab_list++) > 0 && stop <= max_cols) {\n\tfputs((stop == 1) ? \"*\" : \"\\t*\", stdout);\n    };\n    \/* also show a tab _past_ the stops *\/\n    if (stop < max_cols)\n\tfputs(\"\\t+\", stdout);\n    putchar('\\n');\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":366203,"func":"static void shrink_submounts(struct mount *mnt)\n{\n\tLIST_HEAD(graveyard);\n\tstruct mount *m;\n\n\t\/* extract submounts of 'mountpoint' from the expiration list *\/\n\twhile (select_submounts(mnt, &graveyard)) {\n\t\twhile (!list_empty(&graveyard)) {\n\t\t\tm = list_first_entry(&graveyard, struct mount,\n\t\t\t\t\t\tmnt_expire);\n\t\t\ttouch_mnt_namespace(m->mnt_ns);\n\t\t\tumount_tree(m, UMOUNT_PROPAGATE|UMOUNT_SYNC);\n\t\t}\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":291823,"func":"static void rtrs_clt_init_hb(struct rtrs_clt_path *clt_path)\n{\n\trtrs_init_hb(&clt_path->s, &io_comp_cqe,\n\t\t      RTRS_HB_INTERVAL_MS,\n\t\t      RTRS_HB_MISSED_MAX,\n\t\t      rtrs_clt_hb_err_handler,\n\t\t      rtrs_wq);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":265447,"func":"static char *sqfs_basename(char *path)\n{\n\tchar *fname;\n\n\tfname = path + strlen(path) - 1;\n\twhile (fname >= path) {\n\t\tif (*fname == '\/') {\n\t\t\tfname++;\n\t\t\tbreak;\n\t\t}\n\n\t\tfname--;\n\t}\n\n\treturn fname;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":313761,"func":"clearopbeep(oparg_T *oap)\n{\n    clearop(oap);\n    beep_flush();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":448581,"func":"gdk_pixbuf__xbm_image_load (FILE    *f, \n\t\t\t    GError **error)\n{\n\treturn gdk_pixbuf__xbm_image_load_real (f, NULL, error);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":361752,"func":"static inline void em28xx_set_model(struct em28xx *dev)\n{\n\tdev->board = em28xx_boards[dev->model];\n\tdev->has_msp34xx = dev->board.has_msp34xx;\n\tdev->is_webcam = dev->board.is_webcam;\n\n\tem28xx_set_xclk_i2c_speed(dev);\n\n\t\/* Should be initialized early, for I2C to work *\/\n\tdev->def_i2c_bus = dev->board.def_i2c_bus;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":90807,"func":"void QuotaManager::SetPersistentHostQuota(const std::string& host,\n                                          int64 new_quota,\n                                          HostQuotaCallback* callback_ptr) {\n  scoped_ptr<HostQuotaCallback> callback(callback_ptr);\n  LazyInitialize();\n  if (host.empty()) {\n    callback->Run(kQuotaErrorNotSupported, host, kStorageTypePersistent, 0);\n    return;\n  }\n  if (new_quota < 0) {\n    callback->Run(kQuotaErrorInvalidModification,\n                  host, kStorageTypePersistent, -1);\n    return;\n  }\n\n  if (!db_disabled_) {\n    scoped_refptr<UpdatePersistentHostQuotaTask> task(\n        new UpdatePersistentHostQuotaTask(\n            this, host, new_quota, callback.release()));\n    task->Start();\n  } else {\n    callback->Run(kQuotaErrorInvalidAccess,\n                  host, kStorageTypePersistent, -1);\n  }\n}\n","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":318109,"func":"static void rsi_deinit_usb_interface(struct rsi_hw *adapter)\n{\n\tstruct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;\n\n\trsi_kill_thread(&dev->rx_thread);\n\n\tusb_free_urb(dev->rx_cb[0].rx_urb);\n\tif (adapter->priv->coex_mode > 1)\n\t\tusb_free_urb(dev->rx_cb[1].rx_urb);\n\n\tkfree(dev->tx_buffer);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":220214,"func":"void Graph::ToGraphDef(GraphDef* graph_def) const {\n  ToGraphDefSubRange(graph_def, 0);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":369308,"func":"static bool req_need_defer(struct io_kiocb *req, u32 seq)\n{\n\tif (unlikely(req->flags & REQ_F_IO_DRAIN)) {\n\t\tstruct io_ring_ctx *ctx = req->ctx;\n\n\t\treturn seq + READ_ONCE(ctx->cq_extra) != ctx->cached_cq_tail;\n\t}\n\n\treturn false;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":229274,"func":"void cql_server::response::write(const cql3::prepared_metadata& m, uint8_t version)\n{\n    bool global_tables_spec = m.flags().contains<cql3::prepared_metadata::flag::GLOBAL_TABLES_SPEC>();\n\n    write_int(m.flags().mask());\n    write_int(m.names().size());\n\n    if (version >= 4) {\n        if (!global_tables_spec) {\n            write_int(0);\n        } else {\n            write_int(m.partition_key_bind_indices().size());\n            for (uint16_t bind_index : m.partition_key_bind_indices()) {\n                write_short(bind_index);\n            }\n        }\n    }\n\n    if (global_tables_spec) {\n        write_string(m.names()[0]->ks_name);\n        write_string(m.names()[0]->cf_name);\n    }\n\n    for (auto const& name : m.names()) {\n        if (!global_tables_spec) {\n            write_string(name->ks_name);\n            write_string(name->cf_name);\n        }\n        write_string(name->name->text());\n        type_codec::encode(*this, name->type);\n    }\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":508837,"func":"void LEX::cleanup_after_one_table_open()\n{\n  \/*\n    thd->lex->derived_tables & additional units may be set if we open\n    a view. It is necessary to clear thd->lex->derived_tables flag\n    to prevent processing of derived tables during next open_and_lock_tables\n    if next table is a real table and cleanup & remove underlying units\n    NOTE: all units will be connected to thd->lex->select_lex, because we\n    have not UNION on most upper level.\n    *\/\n  if (all_selects_list != &select_lex)\n  {\n    derived_tables= 0;\n    select_lex.exclude_from_table_unique_test= false;\n    \/* cleunup underlying units (units of VIEW) *\/\n    for (SELECT_LEX_UNIT *un= select_lex.first_inner_unit();\n         un;\n         un= un->next_unit())\n      un->cleanup();\n    \/* reduce all selects list to default state *\/\n    all_selects_list= &select_lex;\n    \/* remove underlying units (units of VIEW) subtree *\/\n    select_lex.cut_subtree();\n  }\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":225788,"func":"GF_Box *stco_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ChunkOffsetBox, GF_ISOM_BOX_TYPE_STCO);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":274886,"func":"TEST(ComparisonsTest, QuantizedUInt8NotEqualWithBroadcast) {\n  const float kMin = -1.f;\n  const float kMax = 128.f;\n  std::vector<std::vector<int>> test_shapes = {\n      {6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};\n  for (int i = 0; i < test_shapes.size(); ++i) {\n    ComparisonOpModel model({TensorType_UINT8, test_shapes[i], kMin, kMax},\n                            {TensorType_UINT8, {}, kMin, kMax},\n                            TensorType_UINT8, BuiltinOperator_NOT_EQUAL);\n    model.QuantizeAndPopulate<uint8_t>(model.input1(), {20, 2, 7, 8, 11, 20});\n    model.QuantizeAndPopulate<uint8_t>(model.input2(), {2});\n    model.Invoke();\n    EXPECT_THAT(model.GetOutput(),\n                ElementsAre(true, false, true, true, true, true))\n        << \"With shape number \" << i;\n  }\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":379706,"func":"R_API const char *r_anal_function_get_var_reg_at(RAnalFunction *fcn, st64 delta, ut64 addr) {\n\tst64 offset = addr - fcn->addr;\n\tRPVector *inst_accesses = ht_up_find (fcn->inst_vars, offset, NULL);\n\tif (!inst_accesses) {\n\t\treturn NULL;\n\t}\n\tRAnalVar *var = NULL;\n\tvoid **it;\n\tr_pvector_foreach (inst_accesses, it) {\n\t\tRAnalVar *v = *it;\n\t\tif (v->delta == delta) {\n\t\t\tvar = v;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!var) {\n\t\treturn NULL;\n\t}\n\tsize_t index;\n\tr_vector_lower_bound (&var->accesses, offset, index, ACCESS_CMP);\n\tRAnalVarAccess *acc = NULL;\n\tif (index < var->accesses.len) {\n\t\tacc = r_vector_index_ptr (&var->accesses, index);\n\t}\n\tif (!acc || acc->offset != offset) {\n\t\treturn NULL;\n\t}\n\treturn acc->reg;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":294535,"func":"c_julian_leap_p(int y)\n{\n    return MOD(y, 4) == 0;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":512255,"func":"  double val_real()\n  {\n    return m_value.to_datetime(current_thd).to_double();\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":432247,"func":"void qemu_ram_free(struct uc_struct *uc, RAMBlock *block)\n{\n    if (!block) {\n        return;\n    }\n\n    \/\/if (block->host) {\n    \/\/    ram_block_notify_remove(block->host, block->max_length);\n    \/\/}\n\n    QLIST_REMOVE_RCU(block, next);\n    uc->ram_list.mru_block = NULL;\n    \/* Write list before version *\/\n    \/\/smp_wmb();\n    \/\/ call_rcu(block, reclaim_ramblock, rcu);\n    reclaim_ramblock(uc, block);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":220433,"func":"mrb_ary_join_m(mrb_state *mrb, mrb_value ary)\n{\n  mrb_value sep = mrb_nil_value();\n\n  mrb_get_args(mrb, \"|S!\", &sep);\n  return mrb_ary_join(mrb, ary, sep);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":220440,"func":"mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals)\n{\n  struct RArray *a = ary_new_from_values(mrb, size, vals);\n  return mrb_obj_value(a);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":424893,"func":"static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state)\n{\n\tif (state)\n\t\tset_bit(STATUS_TPOWER_PMI, &trans->status);\n\telse\n\t\tclear_bit(STATUS_TPOWER_PMI, &trans->status);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":205747,"func":"static void sixpack_close(struct tty_struct *tty)\n{\n\tstruct sixpack *sp;\n\n\twrite_lock_irq(&disc_data_lock);\n\tsp = tty->disc_data;\n\ttty->disc_data = NULL;\n\twrite_unlock_irq(&disc_data_lock);\n\tif (!sp)\n\t\treturn;\n\n\t\/*\n\t * We have now ensured that nobody can start using ap from now on, but\n\t * we have to wait for all existing users to finish.\n\t *\/\n\tif (!refcount_dec_and_test(&sp->refcnt))\n\t\twait_for_completion(&sp->dead);\n\n\t\/* We must stop the queue to avoid potentially scribbling\n\t * on the free buffers. The sp->dead completion is not sufficient\n\t * to protect us from sp->xbuff access.\n\t *\/\n\tnetif_stop_queue(sp->dev);\n\n\tdel_timer_sync(&sp->tx_t);\n\tdel_timer_sync(&sp->resync_t);\n\n\t\/* Free all 6pack frame buffers. *\/\n\tkfree(sp->rbuff);\n\tkfree(sp->xbuff);\n\n\tunregister_netdev(sp->dev);\n}","target":1,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":365615,"func":"_asn1_find_up (asn1_node node)\n{\n  asn1_node p;\n\n  if (node == NULL)\n    return NULL;\n\n  p = node;\n\n  while ((p->left != NULL) && (p->left->right == p))\n    p = p->left;\n\n  return p->left;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":229143,"func":"static bool use_multiport(VirtIOSerial *vser)\n{\n    VirtIODevice *vdev = VIRTIO_DEVICE(vser);\n    return virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":487651,"func":"asmlinkage long sys_getpgrp(void)\n{\n\t\/* SMP - assuming writes are word atomic this is fine *\/\n\treturn process_group(current);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":404743,"func":"static struct file *pick_file(struct files_struct *files, unsigned fd)\n{\n\tstruct file *file;\n\tstruct fdtable *fdt;\n\n\tspin_lock(&files->file_lock);\n\tfdt = files_fdtable(files);\n\tif (fd >= fdt->max_fds) {\n\t\tfile = ERR_PTR(-EINVAL);\n\t\tgoto out_unlock;\n\t}\n\tfile = fdt->fd[fd];\n\tif (!file) {\n\t\tfile = ERR_PTR(-EBADF);\n\t\tgoto out_unlock;\n\t}\n\trcu_assign_pointer(fdt->fd[fd], NULL);\n\t__put_unused_fd(files, fd);\n\nout_unlock:\n\tspin_unlock(&files->file_lock);\n\treturn file;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":310319,"func":"should_generate_v2_networkstatus(void)\n{\n  return authdir_mode_v2(get_options()) &&\n    the_v2_networkstatus_is_dirty &&\n    the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":246485,"func":"static inline RBinWasmTypeVec *parse_type_vector(RBuffer *b, ut64 bound) {\n\tRBinWasmTypeVec *vec = R_NEW0 (RBinWasmTypeVec);\n\t\/\/ types are all ut8, so leb128 shouldn't be needed, we can reuse consume_str_new\n\tif (vec && !consume_str_new (b, bound, &vec->count, (char **)&vec->types)) {\n\t\tfree_type_vec (vec);\n\t\treturn NULL;\n\t}\n\treturn vec;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":359375,"func":"DEFUN (bgp_bestpath_aspath_ignore,\n       bgp_bestpath_aspath_ignore_cmd,\n       \"bgp bestpath as-path ignore\",\n       \"BGP specific commands\\n\"\n       \"Change the default bestpath selection\\n\"\n       \"AS-path attribute\\n\"\n       \"Ignore as-path length in selecting a route\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":254748,"func":"njs_typed_array_compare_u8(const void *a, const void *b, void *c)\n{\n    return *((const uint8_t *) a) - *((const uint8_t *) b);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":230275,"func":"njs_array_handler_filter(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    njs_int_t    ret;\n    njs_value_t  copy;\n\n    if (njs_is_valid(entry)) {\n        copy = *entry;\n\n        ret = njs_array_iterator_call(vm, args, ©, n);\n        if (njs_slow_path(ret != NJS_OK)) {\n            return ret;\n        }\n\n        if (njs_is_true(&vm->retval)) {\n            ret = njs_array_add(vm, args->data, ©);\n            if (njs_slow_path(ret != NJS_OK)) {\n                return ret;\n            }\n        }\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":512348,"func":"void Regexp_processor_pcre::set_recursion_limit(THD *thd)\n{\n  long stack_used;\n  DBUG_ASSERT(thd == current_thd);\n  stack_used= available_stack_size(thd->thread_stack, &stack_used);\n  m_pcre_extra.match_limit_recursion=\n    (ulong)((my_thread_stack_size - STACK_MIN_SIZE - stack_used)\/my_pcre_frame_size);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":309852,"func":"_nc_retrace_char(int code)\n{\n    T((T_RETURN(\"%c\"), code));\n    return (char) code;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":484736,"func":"uint16_t mobi_buffer_get16(MOBIBuffer *buf) {\n    if (buf->offset + 2 > buf->maxlen) {\n        debug_print(\"%s\", \"End of buffer\\n\");\n        buf->error = MOBI_BUFFER_END;\n        return 0;\n    }\n    uint16_t val;\n    val = (uint16_t)((uint16_t) buf->data[buf->offset] << 8 | (uint16_t) buf->data[buf->offset + 1]);\n    buf->offset += 2;\n    return val;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":513322,"func":"bool Virtual_tmp_table::add(List<Column_definition> &field_list)\n{\n  \/* Create all fields and calculate the total length of record *\/\n  Column_definition *cdef;            \/* column definition *\/\n  List_iterator_fast<Column_definition> it(field_list);\n  for ( ; (cdef= it++); )\n  {\n    Field *tmp;\n    if (!(tmp= cdef->make_field(s, in_use->mem_root, 0,\n                             (uchar*) (f_maybe_null(cdef->pack_flag) ? \"\" : 0),\n                             f_maybe_null(cdef->pack_flag) ? 1 : 0,\n                             cdef->field_name)))\n      return true;\n    add(tmp);\n  }\n  return false;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":220420,"func":"mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr)\n{\n  struct RArray *a;\n\n  a = ary_new_capa(mrb, 2);\n  ARY_PTR(a)[0] = car;\n  ARY_PTR(a)[1] = cdr;\n  ARY_SET_LEN(a, 2);\n  return mrb_obj_value(a);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":405703,"func":"static int xemaclite_set_mac_address(struct net_device *dev, void *address)\n{\n\tstruct net_local *lp = netdev_priv(dev);\n\tstruct sockaddr *addr = address;\n\n\tif (netif_running(dev))\n\t\treturn -EBUSY;\n\n\tmemcpy(dev->dev_addr, addr->sa_data, dev->addr_len);\n\txemaclite_update_address(lp, dev->dev_addr);\n\treturn 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":90194,"func":"WifiNetwork::WifiNetwork(const WifiNetwork& network)\n    : WirelessNetwork(network) {\n  encryption_ = network.encryption();\n  passphrase_ = network.passphrase();\n  identity_ = network.identity();\n  cert_path_ = network.cert_path();\n}\n","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":482650,"func":"static inline const char *xt_outname(const struct xt_action_param *par)\n{\n\treturn par->state->out->name;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":491957,"func":"static void fuse_write_update_size(struct inode *inode, loff_t pos)\n{\n\tstruct fuse_conn *fc = get_fuse_conn(inode);\n\tstruct fuse_inode *fi = get_fuse_inode(inode);\n\n\tspin_lock(&fc->lock);\n\tfi->attr_version = ++fc->attr_version;\n\tif (pos > inode->i_size)\n\t\ti_size_write(inode, pos);\n\tspin_unlock(&fc->lock);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":432229,"func":"void cpu_exec_initfn(CPUState *cpu)\n{\n    cpu->num_ases = 1;\n    cpu->as = &(cpu->uc->address_space_memory);\n    cpu->memory = cpu->uc->system_memory;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":226034,"func":"\nGF_Err fiin_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tFDItemInformationBox *ptr = (FDItemInformationBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u16(bs, gf_list_count(ptr->partition_entries) );\n\treturn GF_OK;","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":300799,"func":"void tipc_sk_reinit(struct net *net)\n{\n\tstruct tipc_net *tn = net_generic(net, tipc_net_id);\n\tstruct rhashtable_iter iter;\n\tstruct tipc_sock *tsk;\n\tstruct tipc_msg *msg;\n\n\trhashtable_walk_enter(&tn->sk_rht, &iter);\n\n\tdo {\n\t\trhashtable_walk_start(&iter);\n\n\t\twhile ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) {\n\t\t\tsock_hold(&tsk->sk);\n\t\t\trhashtable_walk_stop(&iter);\n\t\t\tlock_sock(&tsk->sk);\n\t\t\tmsg = &tsk->phdr;\n\t\t\tmsg_set_prevnode(msg, tipc_own_addr(net));\n\t\t\tmsg_set_orignode(msg, tipc_own_addr(net));\n\t\t\trelease_sock(&tsk->sk);\n\t\t\trhashtable_walk_start(&iter);\n\t\t\tsock_put(&tsk->sk);\n\t\t}\n\n\t\trhashtable_walk_stop(&iter);\n\t} while (tsk == ERR_PTR(-EAGAIN));\n\n\trhashtable_walk_exit(&iter);\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":231746,"func":"TEST_F(QuicUnencryptedServerTransportTest, TestEncryptedDataBeforeCFIN) {\n  getFakeHandshakeLayer()->allowZeroRttKeys();\n  \/\/ This should trigger derivation of keys.\n  recvClientHello();\n\n  StreamId streamId = 4;\n  recvEncryptedStream(streamId, *IOBuf::copyBuffer(\"hello\"));\n\n  auto stream = server->getNonConstConn().streamManager->getStream(streamId);\n  ASSERT_TRUE(stream->readBuffer.empty());\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":275962,"func":"unsigned uECC_curve_num_bits(uECC_Curve curve) {\n    return curve->num_bytes * 8;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":404735,"func":"struct file *fget_many(unsigned int fd, unsigned int refs)\n{\n\treturn __fget(fd, FMODE_PATH, refs);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":221666,"func":"bool Socket::writeString(const char *line) \/\/throw(std::exception)\n{\n    int l = strlen(line);\n    return writeToSocket(line, l, 0, timeout);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":450398,"func":"static void zrle_write_u32(VncState *vs, uint32_t value)\n{\n    vnc_write(vs, (uint8_t *)&value, 4);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":338160,"func":"bool WasmBinaryBuilder::maybeVisitArrayInit(Expression*& out, uint32_t code) {\n  if (code == BinaryConsts::ArrayInitStatic) {\n    auto heapType = getIndexedHeapType();\n    auto size = getU32LEB();\n    std::vector<Expression*> values(size);\n    for (size_t i = 0; i < size; i++) {\n      values[size - i - 1] = popNonVoidExpression();\n    }\n    out = Builder(wasm).makeArrayInit(heapType, values);\n    return true;\n  } else if (code == BinaryConsts::ArrayInit) {\n    auto heapType = getIndexedHeapType();\n    auto size = getU32LEB();\n    auto* rtt = popNonVoidExpression();\n    validateHeapTypeUsingChild(rtt, heapType);\n    std::vector<Expression*> values(size);\n    for (size_t i = 0; i < size; i++) {\n      values[size - i - 1] = popNonVoidExpression();\n    }\n    out = Builder(wasm).makeArrayInit(rtt, values);\n    return true;\n  }\n  return false;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":312460,"func":"mark_quickfix_ctx(qf_info_T *qi, int copyID)\n{\n    int\t\ti;\n    int\t\tabort = FALSE;\n    typval_T\t*ctx;\n    callback_T\t*cb;\n\n    for (i = 0; i < LISTCOUNT && !abort; ++i)\n    {\n\tctx = qi->qf_lists[i].qf_ctx;\n\tif (ctx != NULL && ctx->v_type != VAR_NUMBER\n\t\t&& ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT)\n\t    abort = abort || set_ref_in_item(ctx, copyID, NULL, NULL);\n\n\tcb = &qi->qf_lists[i].qf_qftf_cb;\n\tabort = abort || set_ref_in_callback(cb, copyID);\n    }\n\n    return abort;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":247669,"func":"TEST_P(SslSocketTest, Ipv6San) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/config\/integration\/certs\/upstreamcacert.pem\"\n      match_typed_subject_alt_names:\n      - san_type: IP_ADDRESS\n        matcher:\n          exact: \"::1\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/config\/integration\/certs\/upstreamlocalhostcert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/config\/integration\/certs\/upstreamlocalhostkey.pem\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":328908,"func":"R_API void r_bin_java_print_synthetic_attr_summary(RBinJavaAttrInfo *attr) {\n\tif (attr == NULL) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaAttrInfo *Synthetic.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"Synthetic Attribute Information:\\n\");\n\tprintf (\"  Attribute Offset: 0x%08\"PFMT64x \"\\n\", attr->file_offset);\n\tprintf (\"  Attribute Name Index: %d (%s)\\n\", attr->name_idx, attr->name);\n\tprintf (\"  Attribute Length: %d\\n\", attr->length);\n\tprintf (\"  Attribute Index: %d\\n\", attr->info.source_file_attr.sourcefile_idx);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":309870,"func":"reset_color_pair(NCURSES_SP_DCL0)\n{\n#ifdef USE_TERM_DRIVER\n    return CallDriver(SP_PARM, td_rescol);\n#else\n    bool result = FALSE;\n\n    (void) SP_PARM;\n    if (orig_pair != 0) {\n\t(void) NCURSES_PUTP2(\"orig_pair\", orig_pair);\n\tresult = TRUE;\n    }\n    return result;\n#endif\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":225915,"func":"\nGF_Err fdsa_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_HintSample *ptr = (GF_HintSample *)s;\n\tswitch(a->type) {\n\tcase GF_ISOM_BOX_TYPE_FDPA:\n\t\tBOX_FIELD_LIST_ASSIGN(packetTable)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_EXTR:\n\t\tBOX_FIELD_ASSIGN(extra_data, GF_ExtraDataBox)\n\t\tbreak;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":401586,"func":"static void crng_backtrack_protect(__u8 tmp[CHACHA_BLOCK_SIZE], int used)\n{\n\tstruct crng_state *crng = NULL;\n\n#ifdef CONFIG_NUMA\n\tif (crng_node_pool)\n\t\tcrng = crng_node_pool[numa_node_id()];\n\tif (crng == NULL)\n#endif\n\t\tcrng = &primary_crng;\n\t_crng_backtrack_protect(crng, tmp, used);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":369180,"func":"static inline void __io_queue_sqe(struct io_kiocb *req)\n\t__must_hold(&req->ctx->uring_lock)\n{\n\tstruct io_kiocb *linked_timeout;\n\tint ret;\n\n\tret = io_issue_sqe(req, IO_URING_F_NONBLOCK|IO_URING_F_COMPLETE_DEFER);\n\n\tif (req->flags & REQ_F_COMPLETE_INLINE) {\n\t\tio_req_add_compl_list(req);\n\t\treturn;\n\t}\n\t\/*\n\t * We async punt it if the file wasn't marked NOWAIT, or if the file\n\t * doesn't support non-blocking read\/write attempts\n\t *\/\n\tif (likely(!ret)) {\n\t\tlinked_timeout = io_prep_linked_timeout(req);\n\t\tif (linked_timeout)\n\t\t\tio_queue_linked_timeout(linked_timeout);\n\t} else if (ret == -EAGAIN && !(req->flags & REQ_F_NOWAIT)) {\n\t\tio_queue_sqe_arm_apoll(req);\n\t} else {\n\t\tio_req_complete_failed(req, ret);\n\t}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":225417,"func":"static int vidioc_streamoff(struct file *file, void *fh,\n\t\t\t    enum v4l2_buf_type type)\n{\n\tstruct v4l2_loopback_device *dev;\n\tMARK();\n\tdprintk(\"%d\\n\", type);\n\n\tdev = v4l2loopback_getdevice(file);\n\n\tswitch (type) {\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n\t\tif (dev->ready_for_capture > 0)\n\t\t\tdev->ready_for_capture--;\n\t\treturn 0;\n\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":238438,"func":"static const char *kernel_type_name(const struct btf* btf, u32 id)\n{\n\treturn btf_name_by_offset(btf, btf_type_by_id(btf, id)->name_off);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":513028,"func":"int Arg_comparator::compare_e_time()\n{\n  THD *thd= current_thd;\n  longlong val1= (*a)->val_time_packed(thd);\n  longlong val2= (*b)->val_time_packed(thd);\n  if ((*a)->null_value || (*b)->null_value)\n    return MY_TEST((*a)->null_value && (*b)->null_value);\n  return MY_TEST(val1 == val2);\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":283749,"func":"static void zynq_slcr_reset_hold(Object *obj)\n{\n    ZynqSLCRState *s = ZYNQ_SLCR(obj);\n\n    \/* will disable all output clocks *\/\n    zynq_slcr_compute_clocks(s);\n    zynq_slcr_propagate_clocks(s);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":432169,"func":"void address_space_destroy(AddressSpace *as)\n{\n    MemoryRegion *root = as->root;\n\n    \/* Flush out anything from MemoryListeners listening in on this *\/\n    memory_region_transaction_begin();\n    as->root = NULL;\n    memory_region_transaction_commit(root);\n    QTAILQ_REMOVE(&as->uc->address_spaces, as, address_spaces_link);\n\n    \/* At this point, as->dispatch and as->current_map are dummy\n     * entries that the guest should never use.  Wait for the old\n     * values to expire before freeing the data.\n     *\/\n    as->root = root;\n    flatview_unref(as->current_map);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":250686,"func":"std::string HttpFile::getMd5() const\n{\n    return implPtr_->getMd5();\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":291764,"func":"static void destroy_con(struct rtrs_clt_con *con)\n{\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\n\tclt_path->s.con[con->c.cid] = NULL;\n\tmutex_destroy(&con->con_mutex);\n\tkfree(con);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":424531,"func":"static UINT video_control_on_close(IWTSVirtualChannelCallback* pChannelCallback)\n{\n\tfree(pChannelCallback);\n\treturn CHANNEL_RC_OK;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":473912,"func":"euckr_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)\n{\n  return onigenc_mb2_is_code_ctype(enc, code, ctype);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":226398,"func":"void def_parent_full_box_del(GF_Box *s)\n{\n\tif (s) gf_free(s);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":279916,"func":"set_old_sub(char_u *val)\n{\n    vim_free(old_sub);\n    old_sub = val;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":391667,"func":"static void defer_open_done(struct tevent_req *req)\n{\n\tstruct defer_open_state *state = tevent_req_callback_data(\n\t\treq, struct defer_open_state);\n\tNTSTATUS status;\n\tbool ret;\n\n\tstatus = dbwrap_record_watch_recv(req, talloc_tos(), NULL);\n\tTALLOC_FREE(req);\n\tif (!NT_STATUS_IS_OK(status)) {\n\t\tDEBUG(5, (\"dbwrap_record_watch_recv returned %s\\n\",\n\t\t\t  nt_errstr(status)));\n\t\t\/*\n\t\t * Even if it failed, retry anyway. TODO: We need a way to\n\t\t * tell a re-scheduled open about that error.\n\t\t *\/\n\t}\n\n\tDEBUG(10, (\"scheduling mid %llu\\n\", (unsigned long long)state->mid));\n\n\tret = schedule_deferred_open_message_smb(state->sconn, state->mid);\n\tSMB_ASSERT(ret);\n\tTALLOC_FREE(state);\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":459003,"func":"HTTP_Clone(struct http *to, const struct http * const fm)\n{\n\n\tHTTP_Dup(to, fm);\n\tto->vsl = fm->vsl;\n\tto->ws = fm->ws;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":247677,"func":"TEST_P(SslSocketTest, GetUriWithLocalUriSan) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/san_uri_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedLocalUri(\"spiffe:\/\/lyft.com\/test-team\")\n               .setExpectedSerialNumber(TEST_NO_SAN_CERT_SERIAL));\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":308202,"func":"fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,\n\t\t    enum dma_data_direction dir)\n{\n\tstruct fastrpc_dma_buf_attachment *a = attachment->priv;\n\tstruct sg_table *table;\n\n\ttable = &a->sgt;\n\n\tif (!dma_map_sg(attachment->dev, table->sgl, table->nents, dir))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\treturn table;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":369128,"func":"\t__must_hold(&req->ctx->timeout_lock)\n{\n\tstruct io_timeout_data *io = req->async_data;\n\n\tif (hrtimer_try_to_cancel(&io->timer) != -1) {\n\t\tif (status)\n\t\t\treq_set_fail(req);\n\t\tatomic_set(&req->ctx->cq_timeouts,\n\t\t\tatomic_read(&req->ctx->cq_timeouts) + 1);\n\t\tlist_del_init(&req->timeout.list);\n\t\tio_fill_cqe_req(req, status, 0);\n\t\tio_put_req_deferred(req);\n\t}\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":238569,"func":"static int check_stack_access_for_ptr_arithmetic(\n\t\t\t\tstruct bpf_verifier_env *env,\n\t\t\t\tint regno,\n\t\t\t\tconst struct bpf_reg_state *reg,\n\t\t\t\tint off)\n{\n\tif (!tnum_is_const(reg->var_off)) {\n\t\tchar tn_buf[48];\n\n\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\tverbose(env, \"R%d variable stack access prohibited for !root, var_off=%s off=%d\\n\",\n\t\t\tregno, tn_buf, off);\n\t\treturn -EACCES;\n\t}\n\n\tif (off >= 0 || off < -MAX_BPF_STACK) {\n\t\tverbose(env, \"R%d stack pointer arithmetic goes out of range, \"\n\t\t\t\"prohibited for !root; off=%d\\n\", regno, off);\n\t\treturn -EACCES;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":225894,"func":"GF_Box *moov_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MovieBox, GF_ISOM_BOX_TYPE_MOOV);\n\ttmp->trackList = gf_list_new();\n\tif (!tmp->trackList) {\n\t\tgf_free(tmp);\n\t\treturn NULL;\n\t}\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":226257,"func":"GF_Err sdp_box_size(GF_Box *s)\n{\n\tGF_SDPBox *ptr = (GF_SDPBox *)s;\n\t\/\/don't count the NULL char!!!\n\tif (ptr->sdpText)\n\t\tptr->size += strlen(ptr->sdpText);\n\treturn GF_OK;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":473996,"func":"left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc ARG_UNUSED)\n{\n  const UChar *p;\n\n  if (s <= start) return (UChar* )s;\n  p = s;\n\n  while (!utf8_islead(*p) && p > start) p--;\n  return (UChar* )p;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":274738,"func":"gchar *utf8_strncpy(gchar *dst, const gchar *src, gsize byte_len)\n{\n\t\/* -1 for '\\0' in buffer *\/\n\tglong char_len = g_utf8_strlen(src, byte_len - 1);\n\treturn g_utf8_strncpy(dst, src, char_len);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":459215,"func":"static void tcf_proto_mark_delete(struct tcf_proto *tp)\n{\n\tspin_lock(&tp->lock);\n\ttp->deleting = true;\n\tspin_unlock(&tp->lock);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":384779,"func":"getwhitecols(char_u *p)\n{\n    return skipwhite(p) - p;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":225620,"func":"GF_Box *stsh_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ShadowSyncBox, GF_ISOM_BOX_TYPE_STSH);\n\n\ttmp->entries = gf_list_new();\n\tif (!tmp->entries) {\n\t\tgf_free(tmp);\n\t\treturn NULL;\n\t}\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":336552,"func":"RedCharDeviceVDIPort::RedCharDeviceVDIPort(RedsState *reds):\n    RedCharDevice(reds, nullptr, REDS_TOKENS_TO_SEND, REDS_NUM_INTERNAL_AGENT_MESSAGES)\n{\n    priv->read_state = VDI_PORT_READ_STATE_READ_HEADER;\n    priv->receive_pos = (uint8_t *)&priv->vdi_chunk_header;\n    priv->receive_len = sizeof(priv->vdi_chunk_header);\n\n    RedCharDeviceVDIPort *dev = this;\n\n    agent_msg_filter_init(&dev->priv->write_filter, reds->config->agent_copypaste,\n                          reds->config->agent_file_xfer,\n                          reds_use_client_monitors_config(reds),\n                          TRUE);\n    agent_msg_filter_init(&dev->priv->read_filter, reds->config->agent_copypaste,\n                          reds->config->agent_file_xfer,\n                          reds_use_client_monitors_config(reds),\n                          TRUE);\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":96946,"func":"bool decode(ArgumentDecoder* decoder, RetainPtr<CFDateRef>& result)\n{\n    double absoluteTime;\n    if (!decoder->decodeDouble(absoluteTime))\n        return false;\n\n    result.adoptCF(CFDateCreate(0, absoluteTime));\n    return true;\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":513314,"func":"pick_table_access_method(JOIN_TAB *tab)\n{\n  switch (tab->type) \n  {\n  case JT_REF:\n    tab->read_first_record= join_read_always_key;\n    tab->read_record.read_record= join_read_next_same;\n    break;\n\n  case JT_REF_OR_NULL:\n    tab->read_first_record= join_read_always_key_or_null;\n    tab->read_record.read_record= join_read_next_same_or_null;\n    break;\n\n  case JT_CONST:\n    tab->read_first_record= join_read_const;\n    tab->read_record.read_record= join_no_more_records;\n    break;\n\n  case JT_EQ_REF:\n    tab->read_first_record= join_read_key;\n    tab->read_record.read_record= join_no_more_records;\n    break;\n\n  case JT_FT:\n    tab->read_first_record= join_ft_read_first;\n    tab->read_record.read_record= join_ft_read_next;\n    break;\n\n  case JT_SYSTEM:\n    tab->read_first_record= join_read_system;\n    tab->read_record.read_record= join_no_more_records;\n    break;\n\n  \/* keep gcc happy *\/  \n  default:\n    break;  \n  }\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":301443,"func":"static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)\n{\n\tint result;\n\n\tSTART_PROFILE(syscall_fstat);\n\tresult = sys_fstat(fsp->fh->fd,\n\t\t\t   sbuf, lp_fake_dir_create_times(SNUM(handle->conn)));\n\tEND_PROFILE(syscall_fstat);\n\treturn result;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":301412,"func":"static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr,\n\t\t\toff_t offset, size_t n)\n{\n\tssize_t result;\n\n\tSTART_PROFILE_BYTES(syscall_sendfile, n);\n\tresult = sys_sendfile(tofd, fromfsp->fh->fd, hdr, offset, n);\n\tEND_PROFILE(syscall_sendfile);\n\treturn result;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":242268,"func":"  PamData(BareosSocket* UA_sock, const std::string& passwd)\n      : UA_sock_(UA_sock), passwd_(passwd)\n  {\n  }","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":503855,"func":"SCM_DEFINE (scm_close_fdes, \"close-fdes\", 1, 0, 0, \n            (SCM fd),\n\t    \"A simple wrapper for the @code{close} system call.\\n\"\n\t    \"Close file descriptor @var{fd}, which must be an integer.\\n\"\n\t    \"Unlike close (@pxref{Ports and File Descriptors, close}),\\n\"\n\t    \"the file descriptor will be closed even if a port is using it.\\n\"\n\t    \"The return value is unspecified.\")\n#define FUNC_NAME s_scm_close_fdes\n{\n  int c_fd;\n  int rv;\n\n  c_fd = scm_to_int (fd);\n  SCM_SYSCALL (rv = close (c_fd));\n  if (rv < 0)\n    SCM_SYSERROR;\n  return SCM_UNSPECIFIED;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":261423,"func":"static int decode_sao_offset_sign(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# sao_offset_sign\\n\");\n  int value = decode_CABAC_bypass(&tctx->cabac_decoder);\n  logtrace(LogSymbols,\"$1 sao_offset_sign=%d\\n\",value);\n  return value;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":244014,"func":"GF_Err trex_box_size(GF_Box *s)\n{\n\tGF_TrackExtendsBox *ptr = (GF_TrackExtendsBox *)s;\n\tptr->size += 20;\n\treturn GF_OK;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":225475,"func":"string SwapNodeNamesSwitchControlErrorMsg(absl::string_view node_name) {\n  return absl::Substitute(\n      \"can't swap node name '$0' as it will become a Switch control dependency\",\n      node_name);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":225441,"func":"static int vidioc_g_fmt_cap(struct file *file, void *priv,\n\t\t\t    struct v4l2_format *fmt)\n{\n\tstruct v4l2_loopback_device *dev;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\n\tif (!dev->ready_for_capture)\n\t\treturn -EINVAL;\n\n\tfmt->fmt.pix = dev->pix_format;\n\tMARK();\n\treturn 0;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":398525,"func":"RZ_API void rz_bin_dwarf_debug_abbrev_free(RzBinDwarfDebugAbbrev *da) {\n\tsize_t i;\n\tif (!da) {\n\t\treturn;\n\t}\n\tfor (i = 0; i < da->count; i++) {\n\t\tRZ_FREE(da->decls[i].defs);\n\t}\n\tRZ_FREE(da->decls);\n\tfree(da);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":247682,"func":"  void setExpectedClientCertUri(const std::string& expected_client_cert_uri) {\n    expected_client_cert_uri_ = {expected_client_cert_uri};\n  }","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":401511,"func":"static inline void timers_update_migration(void) { }","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":261214,"func":"    int wm_SemInit(wm_Sem *s) {\n        *s = xSemaphoreCreateBinary();\n        xSemaphoreGive(*s);\n        return 0;\n    }","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":195626,"func":"static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)\n{\n    VirtQueueElement elem;\n    VirtQueue *vq;\n\n    vq = vser->c_ivq;\n    if (!virtio_queue_ready(vq)) {\n        return 0;\n    }\n    if (!virtqueue_pop(vq, &elem)) {\n        return 0;\n    }\n\n    memcpy(elem.in_sg[0].iov_base, buf, len);\n\n    virtqueue_push(vq, &elem, len);\n    virtio_notify(VIRTIO_DEVICE(vser), vq);\n    return len;\n}","target":1,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":384908,"func":"vim_FullName(\n    char_u\t*fname,\n    char_u\t*buf,\n    int\t\tlen,\n    int\t\tforce)\t    \/\/ force expansion even when already absolute\n{\n    int\t\tretval = OK;\n    int\t\turl;\n\n    *buf = NUL;\n    if (fname == NULL)\n\treturn FAIL;\n\n    url = path_with_url(fname);\n    if (!url)\n\tretval = mch_FullName(fname, buf, len, force);\n    if (url || retval == FAIL)\n    {\n\t\/\/ something failed; use the file name (truncate when too long)\n\tvim_strncpy(buf, fname, len - 1);\n    }\n#if defined(MSWIN)\n    slash_adjust(buf);\n#endif\n    return retval;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":244172,"func":"void tfdt_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":343269,"func":"char *skip_telnet_controls(const char *str)\n{\n    if (str == NULL) {\n        return NULL;\n    }\n    while (*str != 0 && (unsigned char) *str >= 240U) {\n        str++;\n    }\n    return (char *) str;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":259613,"func":"bool HierarchicalBitmapRequester::isNextMCULineReady(void) const\n{\n#if ACCUSOFT_CODE\n  \/\/ MCUs can only be written if the smallest scale, which is written first,\n  \/\/ is ready.\n  return m_pSmallestScale->isNextMCULineReady();\n#else\n  return false;\n#endif\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":282988,"func":"LJ_NOINLINE void lj_err_callerv(lua_State *L, ErrMsg em, ...)\n{\n  const char *msg;\n  va_list argp;\n  va_start(argp, em);\n  msg = lj_str_pushvf(L, err2msg(em), argp);\n  va_end(argp);\n  lj_err_callermsg(L, msg);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":338080,"func":"uint32_t WasmBinaryWriter::getFunctionIndex(Name name) const {\n  auto it = indexes.functionIndexes.find(name);\n  assert(it != indexes.functionIndexes.end());\n  return it->second;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":234772,"func":"static int chunk_profiles_filter(u64 chunk_type,\n\t\t\t\t struct btrfs_balance_args *bargs)\n{\n\tchunk_type = chunk_to_extended(chunk_type) &\n\t\t\t\tBTRFS_EXTENDED_PROFILE_MASK;\n\n\tif (bargs->profiles & chunk_type)\n\t\treturn 0;\n\n\treturn 1;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":281116,"func":"static struct hlist_head *policy_hash_bysel(struct net *net,\n\t\t\t\t\t    const struct xfrm_selector *sel,\n\t\t\t\t\t    unsigned short family, int dir)\n{\n\tunsigned int hmask = net->xfrm.policy_bydst[dir].hmask;\n\tunsigned int hash;\n\tu8 dbits;\n\tu8 sbits;\n\n\t__get_hash_thresh(net, family, dir, &dbits, &sbits);\n\thash = __sel_hash(sel, family, hmask, dbits, sbits);\n\n\tif (hash == hmask + 1)\n\t\treturn &net->xfrm.policy_inexact[dir];\n\n\treturn rcu_dereference_check(net->xfrm.policy_bydst[dir].table,\n\t\t     lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":462258,"func":"static void* clone_empty_attr(pj_pool_t *pool, const void *src)\n{\n    pj_stun_empty_attr *dst = PJ_POOL_ALLOC_T(pool, pj_stun_empty_attr);\n\n    pj_memcpy(dst, src, sizeof(pj_stun_empty_attr));\n\n    return (void*) dst;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":267951,"func":"static RBinSymbol *__getMethod(RBinFile *bf, const char *klass, const char *method) {\n\tr_return_val_if_fail (bf && bf->o && bf->o->methods_ht && klass && method, NULL);\n\tr_strf_var (name, 128, \"%s::%s\", klass, method);\n\treturn ht_pp_find (bf->o->methods_ht, name, NULL);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":462237,"func":"static void GETATTRHDR(const pj_uint8_t *buf, pj_stun_attr_hdr *hdr)\n{\n    hdr->type = GETVAL16H(buf, 0);\n    hdr->length = GETVAL16H(buf, 2);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":474017,"func":"big5_mbc_enc_len0(const UChar* p, const UChar* e, int tridx, const int tbl[])\n{\n  int firstbyte = *p++;\n  state_t s = trans[tridx][firstbyte];\n#define RETURN(n) \\\n    return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) : \\\n                         ONIGENC_CONSTRUCT_MBCLEN_INVALID()\n  if (s < 0) RETURN(1);\n  if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(tbl[firstbyte]-1);\n  s = trans[s][*p++];\n  RETURN(2);\n#undef RETURN\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":234791,"func":"int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)\n{\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs;\n\tstruct btrfs_device *device;\n\tstruct btrfs_path *path = NULL;\n\tint ret = 0;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tmutex_lock(&fs_devices->device_list_mutex);\n\tlist_for_each_entry(device, &fs_devices->devices, dev_list) {\n\t\tret = btrfs_device_init_dev_stats(device, path);\n\t\tif (ret)\n\t\t\tgoto out;\n\t}\n\tlist_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) {\n\t\tlist_for_each_entry(device, &seed_devs->devices, dev_list) {\n\t\t\tret = btrfs_device_init_dev_stats(device, path);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t}\n\t}\nout:\n\tmutex_unlock(&fs_devices->device_list_mutex);\n\n\tbtrfs_free_path(path);\n\treturn ret;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":357673,"func":"bool SQClass::SetAttributes(const SQObjectPtr &key,const SQObjectPtr &val)\n{\n    SQObjectPtr idx;\n    if(_members->Get(key,idx)) {\n        if(_isfield(idx))\n            _defaultvalues[_member_idx(idx)].attrs = val;\n        else\n            _methods[_member_idx(idx)].attrs = val;\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":289307,"func":"static int snd_pcm_oss_make_ready(struct snd_pcm_substream *substream)\n{\n\tstruct snd_pcm_runtime *runtime;\n\tint err;\n\n\truntime = substream->runtime;\n\tif (runtime->oss.params) {\n\t\terr = snd_pcm_oss_change_params(substream, false);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\tif (runtime->oss.prepare) {\n\t\tif (mutex_lock_interruptible(&runtime->oss.params_lock))\n\t\t\treturn -ERESTARTSYS;\n\t\terr = snd_pcm_oss_prepare(substream);\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":261910,"func":"njs_string_bytes_from_string(njs_vm_t *vm, const njs_value_t *string,\n    const njs_value_t *encoding)\n{\n    njs_str_t  enc, str;\n\n    if (!njs_is_string(encoding)) {\n        njs_type_error(vm, \"\\\"encoding\\\" must be a string\");\n        return NJS_ERROR;\n    }\n\n    njs_string_get(encoding, &enc);\n    njs_string_get(string, &str);\n\n    if (enc.length == 3 && memcmp(enc.start, \"hex\", 3) == 0) {\n        return njs_string_decode_hex(vm, &vm->retval, &str);\n\n    } else if (enc.length == 6 && memcmp(enc.start, \"base64\", 6) == 0) {\n        return njs_string_decode_base64(vm, &vm->retval, &str);\n\n    } else if (enc.length == 9 && memcmp(enc.start, \"base64url\", 9) == 0) {\n        return njs_string_decode_base64url(vm, &vm->retval, &str);\n    }\n\n    njs_type_error(vm, \"Unknown encoding: \\\"%V\\\"\", &enc);\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":476121,"func":"static void update_unchanged_dev_desc(struct usb_device_descriptor *new,\n\t\tconst struct usb_device_descriptor *old)\n{\n\t__le16 idVendor;\n\t__le16 idProduct;\n\t__le16 bcdDevice;\n\tu8 iSerialNumber;\n\tu8 iManufacturer;\n\tu8 iProduct;\n\n\t\/*\n\t * these variables may have been set in\n\t * usb_composite_overwrite_options()\n\t *\/\n\tidVendor = new->idVendor;\n\tidProduct = new->idProduct;\n\tbcdDevice = new->bcdDevice;\n\tiSerialNumber = new->iSerialNumber;\n\tiManufacturer = new->iManufacturer;\n\tiProduct = new->iProduct;\n\n\t*new = *old;\n\tif (idVendor)\n\t\tnew->idVendor = idVendor;\n\tif (idProduct)\n\t\tnew->idProduct = idProduct;\n\tif (bcdDevice)\n\t\tnew->bcdDevice = bcdDevice;\n\telse\n\t\tnew->bcdDevice = cpu_to_le16(get_default_bcdDevice());\n\tif (iSerialNumber)\n\t\tnew->iSerialNumber = iSerialNumber;\n\tif (iManufacturer)\n\t\tnew->iManufacturer = iManufacturer;\n\tif (iProduct)\n\t\tnew->iProduct = iProduct;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":90904,"func":"bool SortByHost(const GURL& lhs, const GURL& rhs) {\n  return net::GetHostOrSpecFromURL(lhs) > net::GetHostOrSpecFromURL(rhs);\n}\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":263508,"func":"static int sco_sock_create(struct net *net, struct socket *sock, int protocol,\n\t\t\t   int kern)\n{\n\tstruct sock *sk;\n\n\tBT_DBG(\"sock %p\", sock);\n\n\tsock->state = SS_UNCONNECTED;\n\n\tif (sock->type != SOCK_SEQPACKET)\n\t\treturn -ESOCKTNOSUPPORT;\n\n\tsock->ops = &sco_sock_ops;\n\n\tsk = sco_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);\n\tif (!sk)\n\t\treturn -ENOMEM;\n\n\tsco_sock_init(sk, NULL);\n\treturn 0;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":232350,"func":"void gf_isom_box_array_del_parent(GF_List **child_boxes, GF_List *boxlist)\n{\n\tif (!boxlist) return;\n\tgf_isom_box_array_reset_parent(child_boxes, boxlist);\n\tgf_list_del(boxlist);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":385898,"func":"struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt,\n\t\t\t    const char *filename, int flags)\n{\n\tstruct open_flags op;\n\tint err = build_open_flags(flags, 0, &op);\n\tif (err)\n\t\treturn ERR_PTR(err);\n\tif (flags & O_CREAT)\n\t\treturn ERR_PTR(-EINVAL);\n\tif (!filename && (flags & O_DIRECTORY))\n\t\tif (!dentry->d_inode->i_op->lookup)\n\t\t\treturn ERR_PTR(-ENOTDIR);\n\treturn do_file_open_root(dentry, mnt, filename, &op);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":226407,"func":"GF_Err tpyl_box_size(GF_Box *s)\n{\n\ts->size += 8;\n\treturn GF_OK;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":225425,"func":"static int vidioc_querystd(struct file *file, void *fh, v4l2_std_id *norm)\n{\n\tif (norm)\n\t\t*norm = V4L2_STD_ALL;\n\treturn 0;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":522439,"func":"int flag2str_sh(int flag, char *flag_str) {\n    if (flag & 0x1)\n        flag_str[2] = 'W';\n    if (flag >> 1 & 0x1)\n        flag_str[1] = 'A';\n    if (flag >> 2 & 0x1)\n        flag_str[0] = 'E';\n    \n    return 0;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":459151,"func":"static int tcf_block_owner_add(struct tcf_block *block,\n\t\t\t       struct Qdisc *q,\n\t\t\t       enum flow_block_binder_type binder_type)\n{\n\tstruct tcf_block_owner_item *item;\n\n\titem = kmalloc(sizeof(*item), GFP_KERNEL);\n\tif (!item)\n\t\treturn -ENOMEM;\n\titem->q = q;\n\titem->binder_type = binder_type;\n\tlist_add(&item->list, &block->owner_list);\n\treturn 0;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":224164,"func":"  explicit MapPeekOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":512557,"func":"uchar *in_row::get_value(Item *item)\n{\n  tmp.store_value(item);\n  if (item->is_null())\n    return 0;\n  return (uchar *)&tmp;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":197024,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& in0 = ctx->input(0);\n    const Tensor& in1 = ctx->input(1);\n    auto in0_flat = in0.flat<Tin>();\n    auto in1_flat = in1.flat<Tin>();\n    const Device& eigen_device = ctx->eigen_device<Device>();\n\n    Tensor* out = nullptr;\n    if (std::is_same<Tin, Tout>::value) {\n      OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(\n                              {0, 1}, 0, in0.shape(), &out));\n    } else {\n      OP_REQUIRES_OK(ctx, ctx->allocate_output(0, in0.shape(), &out));\n    }\n    auto out_flat = out->flat<Tout>();\n    functor::SimpleBinaryFunctor<Device, Functor>()(eigen_device, out_flat,\n                                                    in0_flat, in1_flat);\n  }","target":1,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":242933,"func":"static int ssl_next_record_is_in_datagram( mbedtls_ssl_context *ssl )\n{\n    if( ssl->in_left > ssl->next_record_offset )\n        return( 1 );\n\n    return( 0 );\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":452254,"func":"PHP_FUNCTION(xsl_xsltprocessor_set_security_prefs)\n{\n\tzval *id;\n\txsl_object *intern;\n\tlong securityPrefs, oldSecurityPrefs;\n\n\tDOM_GET_THIS(id);\n \tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &securityPrefs) == FAILURE) {\n\t\treturn;\n\t}\n\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\toldSecurityPrefs = intern->securityPrefs;\n\tintern->securityPrefs = securityPrefs;\n\t\/* set this to 1 so that we know, it was set through this method. Can be removed, when we remove the ini setting *\/\n\tintern->securityPrefsSet = 1;\n\tRETURN_LONG(oldSecurityPrefs);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":513163,"func":"static unsigned long *mysql_sys_var_ulong(THD* thd, int offset)\n{\n  return (unsigned long *) intern_sys_var_ptr(thd, offset, true);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":369362,"func":"static inline void io_req_set_refcount(struct io_kiocb *req)\n{\n\t__io_req_set_refcount(req, 1);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":415180,"func":"cmd_random (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  size_t nbytes;\n  unsigned char *buffer;\n\n  if (!*line)\n    return set_error (GPG_ERR_ASS_PARAMETER,\n                      \"number of requested bytes missing\");\n  nbytes = strtoul (line, NULL, 0);\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  if (!ctrl->app_ctx)\n    return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);\n\n  buffer = xtrymalloc (nbytes);\n  if (!buffer)\n    return out_of_core ();\n\n  rc = app_get_challenge (ctrl->app_ctx, nbytes, buffer);\n  if (!rc)\n    {\n      rc = assuan_send_data (ctx, buffer, nbytes);\n      xfree (buffer);\n      return rc; \/* that is already an assuan error code *\/\n    }\n  xfree (buffer);\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":274874,"func":"TEST(ComparisonsTest, QuantizedUInt8GreaterWithBroadcast) {\n  const float kMin = -1.f;\n  const float kMax = 128.f;\n  std::vector<std::vector<int>> test_shapes = {\n      {6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};\n  for (int i = 0; i < test_shapes.size(); ++i) {\n    ComparisonOpModel model({TensorType_UINT8, test_shapes[i], kMin, kMax},\n                            {TensorType_UINT8, {}, kMin, kMax},\n                            TensorType_UINT8, BuiltinOperator_GREATER);\n    model.QuantizeAndPopulate<uint8_t>(model.input1(), {20, 2, 7, 8, 11, 20});\n    model.QuantizeAndPopulate<uint8_t>(model.input2(), {8});\n    model.Invoke();\n    EXPECT_THAT(model.GetOutput(),\n                ElementsAre(true, false, false, false, true, true))\n        << \"With shape number \" << i;\n  }\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":291841,"func":"static void free_permits(struct rtrs_clt_sess *clt)\n{\n\tif (clt->permits_map) {\n\t\tsize_t sz = clt->queue_depth;\n\n\t\twait_event(clt->permits_wait,\n\t\t\t   find_first_bit(clt->permits_map, sz) >= sz);\n\t}\n\tkfree(clt->permits_map);\n\tclt->permits_map = NULL;\n\tkfree(clt->permits);\n\tclt->permits = NULL;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":459097,"func":"static void tc_cls_offload_cnt_update(struct tcf_block *block,\n\t\t\t\t      struct tcf_proto *tp, u32 *cnt,\n\t\t\t\t      u32 *flags, u32 diff, bool add)\n{\n\tlockdep_assert_held(&block->cb_lock);\n\n\tspin_lock(&tp->lock);\n\tif (add) {\n\t\tif (!*cnt)\n\t\t\ttcf_block_offload_inc(block, flags);\n\t\t*cnt += diff;\n\t} else {\n\t\t*cnt -= diff;\n\t\tif (!*cnt)\n\t\t\ttcf_block_offload_dec(block, flags);\n\t}\n\tspin_unlock(&tp->lock);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":406209,"func":"static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)),\n\t\t\tconst char *filename, int line)\n{\n\tif (filename)\n\t\twarnx(_(\"%s: parse error: ignore entry at line %d.\"),\n\t\t\t\t\t\t\tfilename, line);\n\treturn 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":222831,"func":"void GraphProperties::ClearInputProperties(const string& node_name) {\n  input_properties_.erase(node_name);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":225609,"func":"GF_Box *audio_sample_entry_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MPEGAudioSampleEntryBox, GF_ISOM_BOX_TYPE_MP4A);\n\tgf_isom_audio_sample_entry_init((GF_AudioSampleEntryBox*)tmp);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":301434,"func":"static NTSTATUS vfswrap_durable_cookie(struct vfs_handle_struct *handle,\n\t\t\t\t       struct files_struct *fsp,\n\t\t\t\t       TALLOC_CTX *mem_ctx,\n\t\t\t\t       DATA_BLOB *cookie)\n{\n\treturn vfs_default_durable_cookie(fsp, mem_ctx, cookie);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":498113,"func":"void cgit_index_link(const char *name, const char *title, const char *class,\n\t\t     const char *pattern, const char *sort, int ofs, int always_root)\n{\n\tsite_link(NULL, name, title, class, pattern, sort, ofs, always_root);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":484708,"func":"void mobi_buffer_getstring(char *str, MOBIBuffer *buf, const size_t len) {\n    if (!str) {\n        buf->error = MOBI_PARAM_ERR;\n        return;\n    }\n    if (buf->offset + len > buf->maxlen) {\n        debug_print(\"%s\", \"End of buffer\\n\");\n        buf->error = MOBI_BUFFER_END;\n        str[0] = '\\0';\n        return;\n    }\n    memcpy(str, buf->data + buf->offset, len);\n    str[len] = '\\0';\n    buf->offset += len;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":359459,"func":"DEFUN (neighbor_description,\n       neighbor_description_cmd,\n       NEIGHBOR_CMD2 \"description .LINE\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Neighbor specific description\\n\"\n       \"Up to 80 characters describing this neighbor\\n\")\n{\n  struct peer *peer;\n  char *str;\n\n  peer = peer_and_group_lookup_vty (vty, argv[0]);\n  if (! peer)\n    return CMD_WARNING;\n\n  if (argc == 1)\n    return CMD_SUCCESS;\n\n  str = argv_concat(argv, argc, 1);\n\n  peer_description_set (peer, str);\n\n  XFREE (MTYPE_TMP, str);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":488682,"func":"void __cpuinit check_efer(void)\n{\n\tunsigned long efer;\n\n\trdmsrl(MSR_EFER, efer); \n        if (!(efer & EFER_NX) || do_not_nx) { \n                __supported_pte_mask &= ~_PAGE_NX; \n        }       \n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":484794,"func":"static int checksum_setup(struct net_device *dev, struct sk_buff *skb)\n{\n\tbool recalculate_partial_csum = false;\n\n\t\/*\n\t * A GSO SKB must be CHECKSUM_PARTIAL. However some buggy\n\t * peers can fail to set NETRXF_csum_blank when sending a GSO\n\t * frame. In this case force the SKB to CHECKSUM_PARTIAL and\n\t * recalculate the partial checksum.\n\t *\/\n\tif (skb->ip_summed != CHECKSUM_PARTIAL && skb_is_gso(skb)) {\n\t\tstruct netfront_info *np = netdev_priv(dev);\n\t\tatomic_inc(&np->rx_gso_checksum_fixup);\n\t\tskb->ip_summed = CHECKSUM_PARTIAL;\n\t\trecalculate_partial_csum = true;\n\t}\n\n\t\/* A non-CHECKSUM_PARTIAL SKB does not require setup. *\/\n\tif (skb->ip_summed != CHECKSUM_PARTIAL)\n\t\treturn 0;\n\n\treturn skb_checksum_setup(skb, recalculate_partial_csum);\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":313731,"func":"clearop(oparg_T *oap)\n{\n    oap->op_type = OP_NOP;\n    oap->regname = 0;\n    oap->motion_force = NUL;\n    oap->use_reg_one = FALSE;\n    motion_force = NUL;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":359593,"func":"DEFUN (clear_bgp_all_soft,\n       clear_bgp_all_soft_cmd,\n       \"clear bgp * soft\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Soft reconfig\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,\n                        BGP_CLEAR_SOFT_BOTH, argv[0]);\n \n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_BOTH, argv[0]);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":359449,"func":"DEFUN (clear_ip_bgp_peer_group_ipv4_soft,\n       clear_ip_bgp_peer_group_ipv4_soft_cmd,\n       \"clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all members of peer-group\\n\"\n       \"BGP peer-group name\\n\"\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Soft reconfig\\n\")\n{\n  if (strncmp (argv[1], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,\n\t\t\t  BGP_CLEAR_SOFT_BOTH, argv[0]);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,\n\t\t\tBGP_CLEAR_SOFT_BOTH, argv[0]);\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":369342,"func":"static inline bool req_ref_inc_not_zero(struct io_kiocb *req)\n{\n\tWARN_ON_ONCE(!(req->flags & REQ_F_REFCOUNT));\n\treturn atomic_inc_not_zero(&req->refs);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":432288,"func":"bool cpu_physical_memory_is_io(AddressSpace *as, hwaddr phys_addr)\n{\n    MemoryRegion*mr;\n    hwaddr l = 1;\n    bool res;\n\n    mr = address_space_translate(as,\n                                 phys_addr, &phys_addr, &l, false,\n                                 MEMTXATTRS_UNSPECIFIED);\n\n    res = !memory_region_is_ram(mr);\n    return res;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":222500,"func":"FunctionDefHelper::AttrValueWrapper FunctionDefHelper::FunctionRef(\n    const string& name,\n    gtl::ArraySlice<std::pair<string, AttrValueWrapper>> attrs) {\n  AttrValueWrapper ret;\n  ret.proto.mutable_func()->set_name(name);\n  for (const auto& a : attrs) {\n    ret.proto.mutable_func()->mutable_attr()->insert({a.first, a.second.proto});\n  }\n  return ret;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":204535,"func":"stl_update_connects_remove_1(stl_file *stl, int facet_num) {\n  int j;\n\n  if (stl->error) return;\n  \/* Update list of connected edges *\/\n  j = ((stl->neighbors_start[facet_num].neighbor[0] == -1) +\n       (stl->neighbors_start[facet_num].neighbor[1] == -1) +\n       (stl->neighbors_start[facet_num].neighbor[2] == -1));\n  if(j == 0) {\t\t       \/* Facet has 3 neighbors *\/\n    stl->stats.connected_facets_3_edge -= 1;\n  } else if(j == 1) {\t     \/* Facet has 2 neighbors *\/\n    stl->stats.connected_facets_2_edge -= 1;\n  } else if(j == 2) {\t     \/* Facet has 1 neighbor  *\/\n    stl->stats.connected_facets_1_edge -= 1;\n  }\n}","target":1,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":244167,"func":"GF_Err strk_box_size(GF_Box *s)\n{\n\treturn GF_OK;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":465857,"func":"static int nfcmrvl_nci_send(struct nci_dev *ndev, struct sk_buff *skb)\n{\n\tstruct nfcmrvl_private *priv = nci_get_drvdata(ndev);\n\n\tnfc_info(priv->dev, \"send entry, len %d\\n\", skb->len);\n\n\tskb->dev = (void *)ndev;\n\n\tif (priv->config.hci_muxed) {\n\t\tunsigned char *hdr;\n\t\tunsigned char len = skb->len;\n\n\t\thdr = skb_push(skb, NFCMRVL_HCI_EVENT_HEADER_SIZE);\n\t\thdr[0] = NFCMRVL_HCI_COMMAND_CODE;\n\t\thdr[1] = NFCMRVL_HCI_OGF;\n\t\thdr[2] = NFCMRVL_HCI_OCF;\n\t\thdr[3] = len;\n\t}\n\n\treturn priv->if_ops->nci_send(priv, skb);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":242614,"func":"  explicit StageSizeOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":353022,"func":"sidNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tif ( val->bv_len != 3 ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\treturn hexNormalize( 0, NULL, NULL, val, normalized, ctx );\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":224457,"func":"static GF_Err gf_text_process_swf(GF_Filter *filter, GF_TXTIn *ctx)\n{\n\tGF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, (\"Warning: GPAC was compiled without SWF import support, can't import file.\\n\"));\n\treturn GF_NOT_SUPPORTED;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":386520,"func":"bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size,\n                            std::istream& stream, bool stripSpace) {\n\n    if (!stream.eof()) {\n        \/\/ Only the useful part of the line\n        char* line = new char[size+1];\n        char* oriLine = line;\n        stream.getline(line, size);\n        stripWhiteSpace(&line, stripSpace);\n        s = line;\n        assert(size > s.length());\n        delete[] oriLine;\n        return true;\n    } else {\n        s[0] = '\\0';\n        return false;\n    }\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":360822,"func":"static int __io_async_cancel(struct io_cancel_data *cd,\n\t\t\t     struct io_uring_task *tctx,\n\t\t\t     unsigned int issue_flags)\n{\n\tbool all = cd->flags & (IORING_ASYNC_CANCEL_ALL|IORING_ASYNC_CANCEL_ANY);\n\tstruct io_ring_ctx *ctx = cd->ctx;\n\tstruct io_tctx_node *node;\n\tint ret, nr = 0;\n\n\tdo {\n\t\tret = io_try_cancel(tctx, cd, issue_flags);\n\t\tif (ret == -ENOENT)\n\t\t\tbreak;\n\t\tif (!all)\n\t\t\treturn ret;\n\t\tnr++;\n\t} while (1);\n\n\t\/* slow path, try all io-wq's *\/\n\tio_ring_submit_lock(ctx, issue_flags);\n\tret = -ENOENT;\n\tlist_for_each_entry(node, &ctx->tctx_list, ctx_node) {\n\t\tstruct io_uring_task *tctx = node->task->io_uring;\n\n\t\tret = io_async_cancel_one(tctx, cd);\n\t\tif (ret != -ENOENT) {\n\t\t\tif (!all)\n\t\t\t\tbreak;\n\t\t\tnr++;\n\t\t}\n\t}\n\tio_ring_submit_unlock(ctx, issue_flags);\n\treturn all ? nr : ret;\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":344270,"func":"static int getbaseline (const Proto *f, int pc, int *basepc) {\n  if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) {\n    *basepc = -1;  \/* start from the beginning *\/\n    return f->linedefined;\n  }\n  else {\n    int i = cast_uint(pc) \/ MAXIWTHABS - 1;  \/* get an estimate *\/\n    \/* estimate must be a lower bound of the correct base *\/\n    lua_assert(i < 0 ||\n              (i < f->sizeabslineinfo && f->abslineinfo[i].pc <= pc));\n    while (i + 1 < f->sizeabslineinfo && pc >= f->abslineinfo[i + 1].pc)\n      i++;  \/* low estimate; adjust it *\/\n    *basepc = f->abslineinfo[i].pc;\n    return f->abslineinfo[i].line;\n  }\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":468371,"func":"on_connection_attempt_timeout (gpointer data)\n{\n  ConnectionAttempt *attempt = data;\n\n  enumerator_next_async (attempt->data, TRUE);\n\n  g_clear_pointer (&attempt->timeout_source, g_source_unref);\n  return G_SOURCE_REMOVE;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":234851,"func":"static int verify_chunk_dev_extent_mapping(struct btrfs_fs_info *fs_info)\n{\n\tstruct extent_map_tree *em_tree = &fs_info->mapping_tree;\n\tstruct extent_map *em;\n\tstruct rb_node *node;\n\tint ret = 0;\n\n\tread_lock(&em_tree->lock);\n\tfor (node = rb_first_cached(&em_tree->map); node; node = rb_next(node)) {\n\t\tem = rb_entry(node, struct extent_map, rb_node);\n\t\tif (em->map_lookup->num_stripes !=\n\t\t    em->map_lookup->verified_stripes) {\n\t\t\tbtrfs_err(fs_info,\n\t\t\t\"chunk %llu has missing dev extent, have %d expect %d\",\n\t\t\t\t  em->start, em->map_lookup->verified_stripes,\n\t\t\t\t  em->map_lookup->num_stripes);\n\t\t\tret = -EUCLEAN;\n\t\t\tgoto out;\n\t\t}\n\t}\nout:\n\tread_unlock(&em_tree->lock);\n\treturn ret;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":482528,"func":"compileError(const FileInfo *file, const char *format, ...) {\n#ifndef __SYMBIAN32__\n\tchar buffer[MAXSTRING];\n\tva_list arguments;\n\tva_start(arguments, format);\n\tvsnprintf(buffer, sizeof(buffer), format, arguments);\n\tva_end(arguments);\n\tif (file)\n\t\t_lou_logMessage(LOU_LOG_ERROR, \"%s:%d: error: %s\", file->fileName,\n\t\t\t\tfile->lineNumber, buffer);\n\telse\n\t\t_lou_logMessage(LOU_LOG_ERROR, \"error: %s\", buffer);\n\terrorCount++;\n#endif\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":231788,"func":"  FizzHandshakeParam(bool argCHLOSync, bool argCFINSync, bool argAcceptZeroRtt)\n      : chloSync(argCHLOSync),\n        cfinSync(argCFINSync),\n        acceptZeroRtt(argAcceptZeroRtt) {}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":231640,"func":"  ~QuicServerTransportHandshakeTest() override {\n    \/\/ We need an extra pump here for some reason.\n    loopForWrites();\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":338236,"func":"void WasmBinaryBuilder::validateBinary() {\n  if (hasDataCount && wasm.memory.segments.size() != dataCount) {\n    throwError(\"Number of segments does not agree with DataCount section\");\n  }\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":475984,"func":"static lzw_result lzw__block_advance(struct lzw_read_ctx *ctx)\n{\n\tuint64_t block_size;\n\tuint64_t next_block_pos = ctx->data_sb_next;\n\tconst uint8_t *data_next = ctx->data + next_block_pos;\n\n\tif (next_block_pos >= ctx->data_len) {\n\t\treturn LZW_NO_DATA;\n\t}\n\n\tblock_size = *data_next;\n\n\tif ((next_block_pos + block_size) >= ctx->data_len) {\n\t\treturn LZW_NO_DATA;\n\t}\n\n\tctx->sb_bit = 0;\n\tctx->sb_bit_count = block_size * 8;\n\n\tif (block_size == 0) {\n\t\tctx->data_sb_next += 1;\n\t\treturn LZW_OK_EOD;\n\t}\n\n\tctx->sb_data = data_next + 1;\n\tctx->data_sb_next += block_size + 1;\n\n\treturn LZW_OK;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":248320,"func":"DLLIMPORT int cfg_setnstr(cfg_t *cfg, const char *name, const char *value, unsigned int index)\n{\n\tcfg_opt_t *opt;\n\n\topt = cfg_getopt(cfg, name);\n\tif (opt && opt->validcb2 && (*opt->validcb2)(cfg, opt, (void *)value) != 0)\n\t\treturn CFG_FAIL;\n\n\treturn cfg_opt_setnstr(opt, value, index);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":244033,"func":"GF_Err saiz_box_size(GF_Box *s)\n{\n\tGF_SampleAuxiliaryInfoSizeBox *ptr = (GF_SampleAuxiliaryInfoSizeBox*)s;\n\n\tif (ptr->aux_info_type || ptr->aux_info_type_parameter) {\n\t\tptr->flags |= 1;\n\t}\n\tif (ptr->flags & 1) ptr->size += 8;\n\tptr->size += 5;\n\tif (ptr->default_sample_info_size==0)  ptr->size += ptr->sample_count;\n\treturn GF_OK;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":219043,"func":"void ConstantFolding::ReplaceOperationWithIdentity(\n    int input_to_forward, const GraphProperties& properties, NodeDef* node,\n    GraphDef* graph) {\n  if (input_to_forward < 0 || input_to_forward >= node->input_size()) return;\n  const DataType dtype = GetDataTypeFromNodeOrProps(*node, properties);\n  if (dtype == DT_INVALID) return;\n\n  node->set_op(\"Identity\");\n  EraseRegularNodeAttributes(node);\n  (*node->mutable_attr())[\"T\"].set_type(dtype);\n  \/\/ Propagate the designated input through the identity.\n  node->mutable_input()->SwapElements(0, input_to_forward);\n  \/\/ Add all other inputs as control dependencies.\n  for (int i = 1; i < node->input_size(); ++i) {\n    if (IsControlInput(node->input(i))) {\n      break;\n    }\n    const string ctrl_dep =\n        AddControlDependency(node->input(i), graph, node_map_.get());\n    node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep);\n    node->set_input(i, ctrl_dep);\n  }\n  graph_modified_ = true;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":236142,"func":"GF_Err krok_box_size(GF_Box *s)\n{\n\tGF_TextKaraokeBox*ptr = (GF_TextKaraokeBox*)s;\n\ts->size += 6 + 8*ptr->nb_entries;\n\treturn GF_OK;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":225778,"func":"\nvoid svhd_box_del(GF_Box *s)\n{\n\tGF_SphericalVideoInfoBox *ptr = (GF_SphericalVideoInfoBox *)s;\n\tif (ptr->string) gf_free(ptr->string);\n\tgf_free(s);","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":274741,"func":"callbacks_fullscreen_toggled (GtkMenuItem *menuitem, gpointer user_data)\n{\n\t\/\/struct GtkWindow *win = (struct GtkWindow *)(screen.win.topLevelWindow);\n\tGdkWindowState state = gdk_window_get_state (gtk_widget_get_window(screen.win.topLevelWindow));\n\tif(state & GDK_WINDOW_STATE_FULLSCREEN)\n\t\tgtk_window_unfullscreen (GTK_WINDOW(screen.win.topLevelWindow));\n\telse\n\t\tgtk_window_fullscreen (GTK_WINDOW(screen.win.topLevelWindow));\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":393488,"func":"static SQInteger base_collectgarbage(HSQUIRRELVM v)\n{\n    sq_pushinteger(v, sq_collectgarbage(v));\n    return 1;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":226054,"func":"\nGF_Err dOps_box_size(GF_Box *s)\n{\n\tGF_OpusSpecificBox *ptr = (GF_OpusSpecificBox *)s;\n\tptr->size += 11;\n\tif (ptr->ChannelMappingFamily)\n\t\tptr->size += 2 + ptr->OutputChannelCount;\n\n\treturn GF_OK;","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":484753,"func":"static bool xennet_handle_rx(struct netfront_queue *queue, unsigned int *eoi)\n{\n\tunsigned int work_queued;\n\tunsigned long flags;\n\n\tif (unlikely(queue->info->broken))\n\t\treturn false;\n\n\tspin_lock_irqsave(&queue->rx_cons_lock, flags);\n\twork_queued = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx);\n\tif (work_queued > queue->rx_rsp_unconsumed) {\n\t\tqueue->rx_rsp_unconsumed = work_queued;\n\t\t*eoi = 0;\n\t} else if (unlikely(work_queued < queue->rx_rsp_unconsumed)) {\n\t\tconst struct device *dev = &queue->info->netdev->dev;\n\n\t\tspin_unlock_irqrestore(&queue->rx_cons_lock, flags);\n\t\tdev_alert(dev, \"RX producer index going backwards\\n\");\n\t\tdev_alert(dev, \"Disabled for further use\\n\");\n\t\tqueue->info->broken = true;\n\t\treturn false;\n\t}\n\tspin_unlock_irqrestore(&queue->rx_cons_lock, flags);\n\n\tif (likely(netif_carrier_ok(queue->info->netdev) && work_queued))\n\t\tnapi_schedule(&queue->napi);\n\n\treturn true;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":232309,"func":"\nGF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs)\n{\n\tif (!a) return GF_BAD_PARAM;\n\tif (!a->registry) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Read invalid box type %s without registry\\n\", gf_4cc_to_str(a->type) ));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\treturn a->registry->read_fn(a, bs);","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":482514,"func":"_lou_getDotsForChar(widechar c, const DisplayTableHeader *table) {\n\tCharDotsMapping *cdPtr = getDotsForChar(c, table);\n\tif (cdPtr) return cdPtr->found;\n\treturn LOU_DOTS;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":292177,"func":"void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) {\n  LinkInfo link_info(pool, index, CHECK);\n  Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass();\n  resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":450390,"func":"static int send_rect_simple(VncState *vs, int x, int y, int w, int h,\n                            bool split)\n{\n    int max_size, max_width;\n    int max_sub_width, max_sub_height;\n    int dx, dy;\n    int rw, rh;\n    int n = 0;\n\n    max_size = tight_conf[vs->tight->compression].max_rect_size;\n    max_width = tight_conf[vs->tight->compression].max_rect_width;\n\n    if (split && (w > max_width || w * h > max_size)) {\n        max_sub_width = (w > max_width) ? max_width : w;\n        max_sub_height = max_size \/ max_sub_width;\n\n        for (dy = 0; dy < h; dy += max_sub_height) {\n            for (dx = 0; dx < w; dx += max_width) {\n                rw = MIN(max_sub_width, w - dx);\n                rh = MIN(max_sub_height, h - dy);\n                n += send_sub_rect(vs, x+dx, y+dy, rw, rh);\n            }\n        }\n    } else {\n        n += send_sub_rect(vs, x, y, w, h);\n    }\n\n    return n;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":512750,"func":"Item_cond::used_tables() const\n{\t\t\t\t\t\t\/\/ This caches used_tables\n  return used_tables_cache;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":348441,"func":"static void __exit mkiss_exit_driver(void)\n{\n\ttty_unregister_ldisc(&ax_ldisc);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":222550,"func":"Status FunctionCallFrame::ConsumeRetvals(std::vector<Tensor>* rets,\n                                         bool allow_dead_tensors) {\n  rets->clear();\n  rets->reserve(rets_.size());\n  for (size_t i = 0; i < rets_.size(); ++i) {\n    if (rets_[i].has_val) {\n      rets->emplace_back(std::move(rets_[i].val));\n    } else if (allow_dead_tensors) {\n      rets->emplace_back();\n    } else {\n      return errors::Internal(\"Retval[\", i, \"] does not have value\");\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":359468,"func":"DEFUN (neighbor_allowas_in,\n       neighbor_allowas_in_cmd,\n       NEIGHBOR_CMD2 \"allowas-in\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Accept as-path with my AS present in it\\n\")\n{\n  int ret;\n  struct peer *peer;\n  unsigned int allow_num;\n\n  peer = peer_and_group_lookup_vty (vty, argv[0]);\n  if (! peer)\n    return CMD_WARNING;\n\n  if (argc == 1)\n    allow_num = 3;\n  else\n    VTY_GET_INTEGER_RANGE (\"AS number\", allow_num, argv[1], 1, 10);\n\n  ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),\n\t\t\t     allow_num);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":498157,"func":"void cgit_print_snapshot_links(const char *repo, const char *head,\n\t\t\t       const char *hex, int snapshots)\n{\n\tconst struct cgit_snapshot_format* f;\n\tstruct strbuf filename = STRBUF_INIT;\n\tsize_t prefixlen;\n\tunsigned char sha1[20];\n\n\tif (get_sha1(fmt(\"refs\/tags\/%s\", hex), sha1) == 0 &&\n\t    (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))\n\t\thex++;\n\tstrbuf_addf(&filename, \"%s-%s\", cgit_repobasename(repo), hex);\n\tprefixlen = filename.len;\n\tfor (f = cgit_snapshot_formats; f->suffix; f++) {\n\t\tif (!(snapshots & f->bit))\n\t\t\tcontinue;\n\t\tstrbuf_setlen(&filename, prefixlen);\n\t\tstrbuf_addstr(&filename, f->suffix);\n\t\tcgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL,\n\t\t\t\t   filename.buf);\n\t\thtml(\"<br\/>\");\n\t}\n\tstrbuf_release(&filename);\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":246747,"func":"u32 parse_multi_rtp(char *arg_val, u32 opt)\n{\n\thint_flags |= GP_RTP_PCK_USE_MULTI;\n\tif (arg_val)\n\t\tmax_ptime = atoi(arg_val);\n\treturn 0;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":390599,"func":"XkbWriteVirtualModMap(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,\n\t\t\t\t\t\t\tClientPtr client)\n{\nunsigned\t\ti;\nxkbVModMapWireDesc *\twire;\nunsigned short *\tpMap;\n\n    wire= (xkbVModMapWireDesc *)buf;\n    pMap= &xkb->server->vmodmap[rep->firstVModMapKey];\n    for (i=0;i<rep->nVModMapKeys-1;i++,pMap++) {\n\tif (*pMap!=0) {\n\t    wire->key= i+rep->firstVModMapKey;\n\t    wire->vmods= *pMap;\n\t    wire++;\n\t}\n    }\n    return (char *)wire;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":253522,"func":"smb2_close_cached_fid(struct kref *ref)\n{\n\tstruct cached_fid *cfid = container_of(ref, struct cached_fid,\n\t\t\t\t\t       refcount);\n\n\tif (cfid->is_valid) {\n\t\tcifs_dbg(FYI, \"clear cached root file handle\\n\");\n\t\tSMB2_close(0, cfid->tcon, cfid->fid->persistent_fid,\n\t\t\t   cfid->fid->volatile_fid);\n\t}\n\n\t\/*\n\t * We only check validity above to send SMB2_close,\n\t * but we still need to invalidate these entries\n\t * when this function is called\n\t *\/\n\tcfid->is_valid = false;\n\tcfid->file_all_info_is_valid = false;\n\tcfid->has_lease = false;\n\tif (cfid->dentry) {\n\t\tdput(cfid->dentry);\n\t\tcfid->dentry = NULL;\n\t}\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":231781,"func":"TEST_F(QuicUnencryptedServerTransportTest, TestSendHandshakeDone) {\n  getFakeHandshakeLayer()->allowZeroRttKeys();\n  setupClientReadCodec();\n  recvClientHello(true, QuicVersion::QUIC_DRAFT);\n  recvClientFinished(true, nullptr, QuicVersion::QUIC_DRAFT);\n  auto& packets = server->getConn().outstandings.packets;\n  ASSERT_FALSE(packets.empty());\n  int numHandshakeDone = 0;\n  for (auto& p : packets) {\n    for (auto& f : p.packet.frames) {\n      auto s = f.asQuicSimpleFrame();\n      if (s) {\n        if (s->asHandshakeDoneFrame()) {\n          numHandshakeDone++;\n        }\n      }\n    }\n  }\n  EXPECT_EQ(numHandshakeDone, 1);\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":369276,"func":"\nstatic void io_init_poll_iocb(struct io_poll_iocb *poll, __poll_t events,\n\t\t\t      wait_queue_func_t wake_func)\n{\n\tpoll->head = NULL;\n#define IO_POLL_UNMASK\t(EPOLLERR|EPOLLHUP|EPOLLNVAL|EPOLLRDHUP)\n\t\/* mask in events that we always want\/need *\/\n\tpoll->events = events | IO_POLL_UNMASK;\n\tINIT_LIST_HEAD(&poll->wait.entry);\n\tinit_waitqueue_func_entry(&poll->wait, wake_func);","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":261219,"func":"    int wm_SemInit(wm_Sem *s) {\n        *s = CreateSemaphore( NULL, 0, 1, NULL);\n        return 0;\n    }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":462583,"func":"void controller::mark_article_read(const std::string& guid, bool read) {\n\tif (api) {\n\t\tapi->mark_article_read(guid, read);\n\t}\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":384128,"func":"raptor_xml_writer_end_element_common(raptor_xml_writer* xml_writer,\n                                     raptor_xml_element *element,\n                                     int is_empty)\n{\n  raptor_iostream* iostr = xml_writer->iostr;\n\n  if(is_empty)\n    raptor_iostream_write_byte('\/', iostr);\n  else {\n    \n    raptor_iostream_write_byte('<', iostr);\n\n    raptor_iostream_write_byte('\/', iostr);\n\n    if(element->name->nspace && element->name->nspace->prefix_length > 0) {\n      raptor_iostream_counted_string_write((const char*)element->name->nspace->prefix, \n                                           element->name->nspace->prefix_length,\n                                           iostr);\n      raptor_iostream_write_byte(':', iostr);\n    }\n    raptor_iostream_counted_string_write((const char*)element->name->local_name,\n                                         element->name->local_name_length,\n                                         iostr);\n  }\n  \n  raptor_iostream_write_byte('>', iostr);\n\n  return 0;\n  \n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":432173,"func":"static void memory_region_update_container_subregions(MemoryRegion *subregion)\n{\n    MemoryRegion *mr = subregion->container;\n    MemoryRegion *other;\n\n    memory_region_transaction_begin();\n\n    QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {\n        QTAILQ_INSERT_BEFORE(other, subregion, subregions_link);\n        goto done;\n    }\n    QTAILQ_INSERT_TAIL(&mr->subregions, subregion, subregions_link);\n\ndone:\n    mr->uc->memory_region_update_pending = true;\n    memory_region_transaction_commit(mr);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":359494,"func":"DEFUN (clear_bgp_all_soft_out,\n       clear_bgp_all_soft_out_cmd,\n       \"clear bgp * soft out\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,\n                          BGP_CLEAR_SOFT_OUT, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_OUT, NULL);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":226369,"func":"GF_Err padb_box_size(GF_Box *s)\n{\n\tGF_PaddingBitsBox *ptr = (GF_PaddingBitsBox *)s;\n\tptr->size += 4;\n\tif (ptr->SampleCount) ptr->size += (ptr->SampleCount + 1) \/ 2;\n\n\treturn GF_OK;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":230132,"func":"static int generate_fake_user_id(json_t * j_params, const char * username, unsigned char * user_id) {\n  char * seed;\n  unsigned char seed_hash[32];\n  size_t seed_hash_len = 32, seed_hash_b64_len;\n  int ret;\n\n  if ((seed = msprintf(\"%s%s-user_id\", username, json_string_value(json_object_get(j_params, \"seed\")))) != NULL) {\n    if (generate_digest_raw(digest_SHA256, (unsigned char *)seed, o_strlen(seed), seed_hash, &seed_hash_len)) {\n      if (o_base64_encode(seed_hash, seed_hash_len, user_id, &seed_hash_b64_len)) {\n        ret = G_OK;\n      } else {\n        y_log_message(Y_LOG_LEVEL_ERROR, \"generate_credential_fake_from_seed - Error o_base64_encode\");\n        ret = G_ERROR;\n      }\n    } else {\n      y_log_message(Y_LOG_LEVEL_ERROR, \"generate_credential_fake_from_seed - Error generate_digest_raw\");\n      ret = G_ERROR;\n    }\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"generate_credential_fake_from_seed - Error allocating resources for seed\");\n    ret = G_ERROR_MEMORY;\n  }\n  o_free(seed);\n  return ret;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":252397,"func":"static void WriteAttributeToMemory(std::vector<unsigned char> *out,\n                                   const char *name, const char *type,\n                                   const unsigned char *data, int len) {\n  out->insert(out->end(), name, name + strlen(name) + 1);\n  out->insert(out->end(), type, type + strlen(type) + 1);\n\n  int outLen = len;\n  tinyexr::swap4(reinterpret_cast<unsigned int *>(&outLen));\n  out->insert(out->end(), reinterpret_cast<unsigned char *>(&outLen),\n              reinterpret_cast<unsigned char *>(&outLen) + sizeof(int));\n  out->insert(out->end(), data, data + len);\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":256391,"func":"static void bio_copy_kern_endio_read(struct bio *bio)\n{\n\tchar *p = bio->bi_private;\n\tstruct bio_vec *bvec;\n\tstruct bvec_iter_all iter_all;\n\n\tbio_for_each_segment_all(bvec, bio, iter_all) {\n\t\tmemcpy_from_bvec(p, bvec);\n\t\tp += bvec->bv_len;\n\t}\n\n\tbio_copy_kern_endio(bio);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":430444,"func":"static int masked_set_action_to_set_action_attr(const struct nlattr *a,\n\t\t\t\t\t\tstruct sk_buff *skb)\n{\n\tconst struct nlattr *ovs_key = nla_data(a);\n\tstruct nlattr *nla;\n\tsize_t key_len = nla_len(ovs_key) \/ 2;\n\n\t\/* Revert the conversion we did from a non-masked set action to\n\t * masked set action.\n\t *\/\n\tnla = nla_nest_start_noflag(skb, OVS_ACTION_ATTR_SET);\n\tif (!nla)\n\t\treturn -EMSGSIZE;\n\n\tif (nla_put(skb, nla_type(ovs_key), key_len, nla_data(ovs_key)))\n\t\treturn -EMSGSIZE;\n\n\tnla_nest_end(skb, nla);\n\treturn 0;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":343129,"func":"static int esp_output_tcp_encap_cb(struct net *net, struct sock *sk,\n\t\t\t\t   struct sk_buff *skb)\n{\n\tstruct dst_entry *dst = skb_dst(skb);\n\tstruct xfrm_state *x = dst->xfrm;\n\n\treturn esp_output_tcp_finish(x, skb);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":234704,"func":"static void free_fs_devices(struct btrfs_fs_devices *fs_devices)\n{\n\tstruct btrfs_device *device;\n\tWARN_ON(fs_devices->opened);\n\twhile (!list_empty(&fs_devices->devices)) {\n\t\tdevice = list_entry(fs_devices->devices.next,\n\t\t\t\t    struct btrfs_device, dev_list);\n\t\tlist_del(&device->dev_list);\n\t\tbtrfs_free_device(device);\n\t}\n\tkfree(fs_devices);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":246735,"func":"u32 parse_cp_loc(char *arg_val, u32 opt)\n{\n\tif (!strcmp(arg_val, \"both\")) cp_location_mode = GF_DASH_CPMODE_BOTH;\n\telse if (!strcmp(arg_val, \"as\")) cp_location_mode = GF_DASH_CPMODE_ADAPTATION_SET;\n\telse if (!strcmp(arg_val, \"rep\")) cp_location_mode = GF_DASH_CPMODE_REPRESENTATION;\n\telse {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Unrecognized ContentProtection loction mode \\\"%s\\\" - please check usage\\n\", arg_val));\n\t\treturn 2;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":336680,"func":"SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd)\n{\n    s->config->spice_listen_socket_fd = listen_fd;\n    return 0;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":512412,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_int>(thd, this); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":229268,"func":"    virtual void visit(const messages::result_message::set_keyspace& m) override {\n        _response.write_int(0x0003);\n        _response.write_string(m.get_keyspace());\n    }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":175774,"func":"void QuotaManager::DidOriginDataEvicted(\n    QuotaStatusCode status) {\n  DCHECK(io_thread_->BelongsToCurrentThread());\n\n  if (status != kQuotaStatusOk)\n    origins_in_error_[eviction_context_.evicted_origin]++;\n\n  eviction_context_.evict_origin_data_callback->Run(status);\n  eviction_context_.evict_origin_data_callback.reset();\n}\n","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":482652,"func":"xt_get_per_cpu_counter(struct xt_counters *cnt, unsigned int cpu)\n{\n\tif (nr_cpu_ids > 1)\n\t\treturn per_cpu_ptr((void __percpu *) (unsigned long) cnt->pcnt, cpu);\n\n\treturn cnt;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":453043,"func":"static int nft_flow_offload_chain(struct nft_chain *chain, u8 *ppolicy,\n\t\t\t\t  enum flow_block_command cmd)\n{\n\tstruct nft_base_chain *basechain;\n\tu8 policy;\n\n\tif (!nft_is_base_chain(chain))\n\t\treturn -EOPNOTSUPP;\n\n\tbasechain = nft_base_chain(chain);\n\tpolicy = ppolicy ? *ppolicy : basechain->policy;\n\n\t\/* Only default policy to accept is supported for now. *\/\n\tif (cmd == FLOW_BLOCK_BIND && policy == NF_DROP)\n\t\treturn -EOPNOTSUPP;\n\n\treturn nft_flow_block_chain(basechain, NULL, cmd);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":356701,"func":"Napi::Value Statement::Bind(const Napi::CallbackInfo& info) {\n    Napi::Env env = info.Env();\n    Statement* stmt = this;\n\n    Baton* baton = stmt->Bind<Baton>(info);\n    if (baton == NULL) {\n        Napi::TypeError::New(env, \"Data type is not supported\").ThrowAsJavaScriptException();\n        return env.Null();\n    }\n    else {\n        stmt->Schedule(Work_BeginBind, baton);\n        return info.This();\n    }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":462276,"func":"static pj_status_t encode_msgint_attr(const void *a, pj_uint8_t *buf, \n\t\t\t\t      unsigned len, \n\t\t\t\t      const pj_stun_msg_hdr *msghdr,\n\t\t\t\t      unsigned *printed)\n{\n    const pj_stun_msgint_attr *ca = (const pj_stun_msgint_attr*)a;\n\n    PJ_CHECK_STACK();\n    \n    PJ_UNUSED_ARG(msghdr);\n\n    if (len < 24) \n\treturn PJ_ETOOSMALL;\n\n    \/* Copy and convert attribute to network byte order *\/\n    PUTVAL16H(buf, 0, ca->hdr.type);\n    PUTVAL16H(buf, 2, ca->hdr.length);\n\n    pj_memcpy(buf+4, ca->hmac, 20);\n\n    \/* Done *\/\n    *printed = 24;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":282883,"func":"static int rsi_send_internal_mgmt_frame(struct rsi_common *common,\n\t\t\t\t\tstruct sk_buff *skb)\n{\n\tstruct skb_info *tx_params;\n\tstruct rsi_cmd_desc *desc;\n\n\tif (skb == NULL) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Unable to allocate skb\\n\", __func__);\n\t\treturn -ENOMEM;\n\t}\n\tdesc = (struct rsi_cmd_desc *)skb->data;\n\tdesc->desc_dword0.len_qno |= cpu_to_le16(DESC_IMMEDIATE_WAKEUP);\n\tskb->priority = MGMT_SOFT_Q;\n\ttx_params = (struct skb_info *)&IEEE80211_SKB_CB(skb)->driver_data;\n\ttx_params->flags |= INTERNAL_MGMT_PKT;\n\tskb_queue_tail(&common->tx_queue[MGMT_SOFT_Q], skb);\n\trsi_set_event(&common->tx_thread.event);\n\treturn 0;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":221509,"func":"apply_exports (char            **envp,\n               const ExportData *exports,\n               gsize             n_exports)\n{\n  int i;\n\n  for (i = 0; i < n_exports; i++)\n    {\n      const char *value = exports[i].val;\n\n      if (value)\n        envp = g_environ_setenv (envp, exports[i].env, value, TRUE);\n      else\n        envp = g_environ_unsetenv (envp, exports[i].env);\n    }\n\n  return envp;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":393508,"func":"static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger SQ_UNUSED_ARG(l), SQInteger SQ_UNUSED_ARG(r),SQInteger func)\n{\n    SQArray *a = _array(arr);\n    SQInteger i;\n    SQInteger array_size = a->Size();\n    for (i = (array_size \/ 2); i >= 0; i--) {\n        if(!_hsort_sift_down(v,a, i, array_size - 1,func)) return false;\n    }\n\n    for (i = array_size-1; i >= 1; i--)\n    {\n        _Swap(a->_values[0],a->_values[i]);\n        if(!_hsort_sift_down(v,a, 0, i-1,func)) return false;\n    }\n    return true;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":274648,"func":"void callbacks_force_expose_event_for_screen (void)\n{\n\tGdkRectangle update_rect;\n\t\n\tupdate_rect.x = 0;\n\tupdate_rect.y = 0;\n\tupdate_rect.width = screenRenderInfo.displayWidth;\n\tupdate_rect.height = screenRenderInfo.displayHeight;\n\n\t\/* Calls expose_event *\/\n\tgdk_window_invalidate_rect (screen.drawing_area->window, &update_rect, FALSE);\n\t\n\t\/* update other gui things that could have changed *\/\n\tcallbacks_update_ruler_scales ();\n\tcallbacks_update_scrollbar_limits ();\n\tcallbacks_update_scrollbar_positions ();\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":229281,"func":"cql_server::unadvertise_connection(shared_ptr<generic_server::connection> raw_conn) {\n    --_stats.connections;\n    if (auto conn = dynamic_pointer_cast<connection>(raw_conn)) {\n        const auto ip = conn->get_client_state().get_client_address().addr();\n        const auto port = conn->get_client_state().get_client_port();\n        clogger.trace(\"Advertising disconnection of CQL client {}:{}\", ip, port);\n    }\n    return make_ready_future<>();\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":253558,"func":"get_smb2_acl(struct cifs_sb_info *cifs_sb,\n\t     struct inode *inode, const char *path,\n\t     u32 *pacllen, u32 info)\n{\n\tstruct cifs_ntsd *pntsd = NULL;\n\tstruct cifsFileInfo *open_file = NULL;\n\n\tif (inode && !(info & SACL_SECINFO))\n\t\topen_file = find_readable_file(CIFS_I(inode), true);\n\tif (!open_file || (info & SACL_SECINFO))\n\t\treturn get_smb2_acl_by_path(cifs_sb, path, pacllen, info);\n\n\tpntsd = get_smb2_acl_by_fid(cifs_sb, &open_file->fid, pacllen, info);\n\tcifsFileInfo_put(open_file);\n\treturn pntsd;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":466131,"func":"static int em_push(struct x86_emulate_ctxt *ctxt)\n{\n\tstruct segmented_address addr;\n\n\tregister_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -ctxt->op_bytes);\n\taddr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]);\n\taddr.seg = VCPU_SREG_SS;\n\n\t\/* Disable writeback. *\/\n\tctxt->dst.type = OP_NONE;\n\treturn segmented_write(ctxt, addr, &ctxt->src.val, ctxt->op_bytes);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":450361,"func":"static int tight_init_stream(VncState *vs, int stream_id,\n                             int level, int strategy)\n{\n    z_streamp zstream = &vs->tight->stream[stream_id];\n\n    if (zstream->opaque == NULL) {\n        int err;\n\n        VNC_DEBUG(\"VNC: TIGHT: initializing zlib stream %d\\n\", stream_id);\n        VNC_DEBUG(\"VNC: TIGHT: opaque = %p | vs = %p\\n\", zstream->opaque, vs);\n        zstream->zalloc = vnc_zlib_zalloc;\n        zstream->zfree = vnc_zlib_zfree;\n\n        err = deflateInit2(zstream, level, Z_DEFLATED, MAX_WBITS,\n                           MAX_MEM_LEVEL, strategy);\n\n        if (err != Z_OK) {\n            fprintf(stderr, \"VNC: error initializing zlib\\n\");\n            return -1;\n        }\n\n        vs->tight->levels[stream_id] = level;\n        zstream->opaque = vs;\n    }\n\n    if (vs->tight->levels[stream_id] != level) {\n        if (deflateParams(zstream, level, strategy) != Z_OK) {\n            return -1;\n        }\n        vs->tight->levels[stream_id] = level;\n    }\n    return 0;\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":252466,"func":"static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len,\n                                                  void *pUser) {\n  mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser;\n  if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque,\n                                    pState->m_cur_archive_file_ofs, pBuf,\n                                    len) != len)\n    return MZ_FALSE;\n  pState->m_cur_archive_file_ofs += len;\n  pState->m_comp_size += len;\n  return MZ_TRUE;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":337786,"func":"struct sctp_chunk *sctp_make_abort_violation(\n\t\t\t\t\tconst struct sctp_association *asoc,\n\t\t\t\t\tconst struct sctp_chunk *chunk,\n\t\t\t\t\tconst __u8 *payload,\n\t\t\t\t\tconst size_t paylen)\n{\n\tstruct sctp_chunk  *retval;\n\tstruct sctp_paramhdr phdr;\n\n\tretval = sctp_make_abort(asoc, chunk, sizeof(struct sctp_errhdr) +\n\t\t\t\t\t      paylen + sizeof(phdr));\n\tif (!retval)\n\t\tgoto end;\n\n\tsctp_init_cause(retval, SCTP_ERROR_PROTO_VIOLATION, paylen +\n\t\t\t\t\t\t\t    sizeof(phdr));\n\n\tphdr.type = htons(chunk->chunk_hdr->type);\n\tphdr.length = chunk->chunk_hdr->length;\n\tsctp_addto_chunk(retval, paylen, payload);\n\tsctp_addto_param(retval, sizeof(phdr), &phdr);\n\nend:\n\treturn retval;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":309918,"func":"my_napms(int ms)\n{\n    if (ms > 0) {\n#if defined(_WIN32) || !HAVE_GETTIMEOFDAY\n\tSleep((DWORD) ms);\n#else\n\tstruct timeval data;\n\tdata.tv_sec = 0;\n\tdata.tv_usec = ms * 1000;\n\tselect(0, NULL, NULL, NULL, &data);\n#endif\n    }\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":226035,"func":"\nGF_Err dmlp_box_size(GF_Box *s)\n{\n\ts->size += 10;\n\treturn GF_OK;","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":247331,"func":"int pgpPubKeyCertLen(const uint8_t *pkts, size_t pktslen, size_t *certlen)\n{\n    const uint8_t *p = pkts;\n    const uint8_t *pend = pkts + pktslen;\n    struct pgpPkt pkt;\n\n    while (p < pend) {\n\tif (decodePkt(p, (pend - p), &pkt))\n\t    return -1;\n\n\tif (pkt.tag == PGPTAG_PUBLIC_KEY && pkts != p) {\n\t    *certlen = p - pkts;\n\t    return 0;\n\t}\n\n\tp += (pkt.body - pkt.head) + pkt.blen;\n    }\n\n    *certlen = pktslen;\n\n    return 0;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":512795,"func":"  String *val_str(String*)\n  {\n    return (String*) &str_value;\n  }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":226435,"func":"  string DebugString() const override {\n    return \"SparseTensorSliceDatasetOp::Dataset\";\n  }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":427717,"func":"cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)\n{\n\tint len = 0;\n\tint days, hours, mins, secs;\n\n\tts \/= CDF_TIME_PREC;\n\tsecs = CAST(int, ts % 60);\n\tts \/= 60;\n\tmins = CAST(int, ts % 60);\n\tts \/= 60;\n\thours = CAST(int, ts % 24);\n\tts \/= 24;\n\tdays = CAST(int, ts);\n\n\tif (days) {\n\t\tlen += snprintf(buf + len, bufsiz - len, \"%dd+\", days);\n\t\tif (CAST(size_t, len) >= bufsiz)\n\t\t\treturn len;\n\t}\n\n\tif (days || hours) {\n\t\tlen += snprintf(buf + len, bufsiz - len, \"%.2d:\", hours);\n\t\tif (CAST(size_t, len) >= bufsiz)\n\t\t\treturn len;\n\t}\n\n\tlen += snprintf(buf + len, bufsiz - len, \"%.2d:\", mins);\n\tif (CAST(size_t, len) >= bufsiz)\n\t\treturn len;\n\n\tlen += snprintf(buf + len, bufsiz - len, \"%.2d\", secs);\n\treturn len;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":231022,"func":"    TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )\r\n    {\r\n        TaskHandle_t pxReturn;\r\n\r\n        configASSERT( xSemaphore );\r\n\r\n        \/* Mutexes cannot be used in interrupt service routines, so the mutex\r\n         * holder should not change in an ISR, and therefore a critical section is\r\n         * not required here. *\/\r\n        if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r\n        {\r\n            pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder;\r\n        }\r\n        else\r\n        {\r\n            pxReturn = NULL;\r\n        }\r\n\r\n        return pxReturn;\r\n    } \/*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. *\/\r","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":219956,"func":"int callback_glewlwyd_get_client_module_list (const struct _u_request * request, struct _u_response * response, void * client_data) {\n  UNUSED(request);\n  struct config_elements * config = (struct config_elements *)client_data;\n  json_t * j_module;\n  \n  j_module = get_client_module_list(config);\n  if (check_result_value(j_module, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module, \"module\"));\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_client_module_list - Error get_client_module_list\");\n    response->status = 500;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":345127,"func":"static inline void pxa3xx_gcu_init_debug_timer(struct pxa3xx_gcu_priv *priv) {}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":481794,"func":"void qh_deinit(const char *path)\n{\n\tstruct query_handler *qh   = NULL;\n\n\tfor (qh = qhandlers; qh != NULL; qh = qh->next_qh) {\n\n\t\tqh_deregister_handler(qh->name);\n\t}\n\n\tdkhash_destroy(qh_table);\n\tqh_table = NULL;\n\tqhandlers = NULL;\n\n\tif (path == NULL) {\n\t\treturn;\n\t}\n\n\tunlink(path);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":274713,"func":"callbacks_window_key_release_event (GtkWidget *widget, GdkEventKey *event)\n{\n\treturn TRUE;\n} \/* key_release_event *\/","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":513004,"func":"void cmp_item_decimal::store_value(Item *item)\n{\n  my_decimal *val= item->val_decimal(&value);\n  \/* val may be zero if item is nnull *\/\n  if (val && val != &value)\n    my_decimal2decimal(val, &value);\n  m_null_value= item->null_value;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":512697,"func":"int cmp_item_timestamp::cmp(Item *arg)\n{\n  THD *thd= current_thd;\n  Timestamp_or_zero_datetime_native_null tmp(thd, arg, true);\n  return m_null_value || tmp.is_null() ? UNKNOWN :\n         type_handler_timestamp2.cmp_native(m_native, tmp) != 0;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":234177,"func":"fetch_indirect_line_string (dwarf_vma offset)\n{\n  struct dwarf_section *section = &debug_displays [line_str].section;\n  const unsigned char * ret;\n\n  if (section->start == NULL)\n    return (const unsigned char *) _(\"<no .debug_line_str section>\");\n\n  if (offset >= section->size)\n    {\n      warn (_(\"DW_FORM_line_strp offset too big: 0x%s\\n\"),\n\t    dwarf_vmatoa (\"x\", offset));\n      return (const unsigned char *) _(\"<offset is too big>\");\n    }\n\n  ret = section->start + offset;\n  \/* Unfortunately we cannot rely upon the .debug_line_str section ending\n     with a NUL byte.  Since our caller is expecting to receive a well formed\n     C string we test for the lack of a terminating byte here.  *\/\n  if (strnlen ((const char *) ret, section->size - offset)\n      == section->size - offset)\n    ret = (const unsigned char *)\n      _(\"<no NUL byte at end of .debug_line_str section>\");\n\n  return ret;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":313768,"func":"reset_VIsual_and_resel(void)\n{\n    if (VIsual_active)\n    {\n\tend_visual_mode();\n\tredraw_curbuf_later(INVERTED);\t\/\/ delete the inversion later\n    }\n    VIsual_reselect = FALSE;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":225053,"func":"parse_connection_string(const char *connstr, PQExpBuffer errorMessage,\n\t\t\t\t\t\tbool use_defaults)\n{\n\t\/* Parse as URI if connection string matches URI prefix *\/\n\tif (uri_prefix_length(connstr) != 0)\n\t\treturn conninfo_uri_parse(connstr, errorMessage, use_defaults);\n\n\t\/* Parse as default otherwise *\/\n\treturn conninfo_parse(connstr, errorMessage, use_defaults);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":226206,"func":"\nGF_Err vmhd_box_size(GF_Box *s)\n{\n\tGF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s;\n\tptr->size += 8;\n\treturn GF_OK;","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":409478,"func":"termcode_star(char_u *code, int len)\n{\n    \/\/ Shortest is <M-O>*X.  With ; shortest is <CSI>@;*X\n    if (len >= 3 && code[len - 2] == '*')\n    {\n\tif (len >= 5 && code[len - 3] == ';')\n\t    return 2;\n\telse\n\t    return 1;\n    }\n    return 0;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":512984,"func":"Item *Item_cond_or::neg_transformer(THD *thd)\t\/* NOT(a OR b OR ...)  -> *\/\n\t\t\t\t\t\/* NOT a AND NOT b AND ... *\/\n{\n  neg_arguments(thd);\n  Item *item= new (thd->mem_root) Item_cond_and(thd, list);\n  return item;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":277478,"func":"uint32_t mobi_get_orth_entry_length(const MOBIIndexEntry *entry) {\n\n    uint32_t entry_textlen;\n    MOBI_RET ret = mobi_get_indxentry_tagvalue(&entry_textlen, entry, INDX_TAG_ORTH_LENGTH);\n    if (ret != MOBI_SUCCESS) {\n        return MOBI_NOTSET;\n    }\n\n    return entry_textlen;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":513112,"func":"bool Item_func_in::fix_for_row_comparison_using_bisection(THD *thd)\n{\n  if (unlikely(!(array= new (thd->mem_root) in_row(thd, arg_count-1, 0))))\n    return true;\n  cmp_item_row *cmp= &((in_row*)array)->tmp;\n  if (cmp->prepare_comparators(thd, func_name(), this, 0))\n    return true;\n  fix_in_vector();\n  return false;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":244002,"func":"GF_Box *txtc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextConfigBox, GF_ISOM_BOX_TYPE_TXTC);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":225073,"func":"PQtransactionStatus(const PGconn *conn)\n{\n\tif (!conn || conn->status != CONNECTION_OK)\n\t\treturn PQTRANS_UNKNOWN;\n\tif (conn->asyncStatus != PGASYNC_IDLE)\n\t\treturn PQTRANS_ACTIVE;\n\treturn conn->xactStatus;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":254873,"func":"int DocumentSourceGroup::freeMemory() {\n    invariant(_groups);\n    int totalMemorySaved = 0;\n    for (auto&& group : *_groups) {\n        for (auto&& groupObj : group.second) {\n            auto prevMemUsage = groupObj->memUsageForSorter();\n            groupObj->reduceMemoryConsumptionIfAble();\n\n            \/\/ Update the memory usage for this group.\n            totalMemorySaved += (prevMemUsage - groupObj->memUsageForSorter());\n        }\n    }\n    return totalMemorySaved;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":488419,"func":"static inline int remap_pmd_range(struct mm_struct *mm, pud_t *pud,\n\t\t\tunsigned long addr, unsigned long end,\n\t\t\tunsigned long pfn, pgprot_t prot)\n{\n\tpmd_t *pmd;\n\tunsigned long next;\n\n\tpfn -= addr >> PAGE_SHIFT;\n\tpmd = pmd_alloc(mm, pud, addr);\n\tif (!pmd)\n\t\treturn -ENOMEM;\n\tdo {\n\t\tnext = pmd_addr_end(addr, end);\n\t\tif (remap_pte_range(mm, pmd, addr, next,\n\t\t\t\tpfn + (addr >> PAGE_SHIFT), prot))\n\t\t\treturn -ENOMEM;\n\t} while (pmd++, addr = next, addr != end);\n\treturn 0;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":432254,"func":"static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr addr)\n{\n#ifdef TARGET_ARM\n    struct uc_struct *uc = d->uc;\n#endif\n    PhysPageEntry lp = d->phys_map, *p;\n    Node *nodes = d->map.nodes;\n    MemoryRegionSection *sections = d->map.sections;\n    hwaddr index = addr >> TARGET_PAGE_BITS;\n    int i;\n\n    for (i = P_L2_LEVELS; lp.skip && (i -= lp.skip) >= 0;) {\n        if (lp.ptr == PHYS_MAP_NODE_NIL) {\n            return §ions[PHYS_SECTION_UNASSIGNED];\n        }\n        p = nodes[lp.ptr];\n        lp = p[(index >> (i * P_L2_BITS)) & (P_L2_SIZE - 1)];\n    }\n\n    if (section_covers_addr(§ions[lp.ptr], addr)) {\n        return §ions[lp.ptr];\n    } else {\n        return §ions[PHYS_SECTION_UNASSIGNED];\n    }\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":289242,"func":"static inline void snd_pcm_oss_proc_init(struct snd_pcm *pcm)\n{\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":309878,"func":"drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)\n{\n    SCREEN *sp;\n    unsigned char c2 = 0;\n    int n;\n\n    AssertTCB();\n    assert(buf);\n    SetSP();\n\n# if USE_PTHREADS_EINTR\n    if ((pthread_self) && (pthread_kill) && (pthread_equal))\n\t_nc_globals.read_thread = pthread_self();\n# endif\n    n = (int) read(sp->_ifd, &c2, (size_t) 1);\n#if USE_PTHREADS_EINTR\n    _nc_globals.read_thread = 0;\n#endif\n    *buf = (int) c2;\n    return n;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":264375,"func":"  const std::unordered_map<string, TensorSliceSet*>& Tensors() const {\n    return tensors_;\n  }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":230122,"func":"json_t * user_auth_scheme_module_load(struct config_module * config) {\n  UNUSED(config);\n  return json_pack(\"{si ss ss ss }\",\n                   \"result\", G_OK,\n                   \"name\", \"webauthn\",\n                   \"display_name\", \"WebAuthn\",\n                   \"description\", \"WebAuthn scheme module\");\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":261760,"func":"void RtmpProtocol::sendPeerBandwidth(uint32_t size) {\n    size = htonl(size);\n    std::string set_peerBandwidth((char *) &size, 4);\n    set_peerBandwidth.push_back((char) 0x02);\n    sendRequest(MSG_SET_PEER_BW, set_peerBandwidth);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":437711,"func":"static inline unsigned int clock_divider_to_freq(unsigned int divider,\n\t\t\t\t\t\t unsigned int rollovers)\n{\n\treturn DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ,\n\t\t\t\t (divider + 1) * rollovers);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":318090,"func":"static int rsi_write_multiple(struct rsi_hw *adapter,\n\t\t\t      u8 endpoint,\n\t\t\t      u8 *data,\n\t\t\t      u32 count)\n{\n\tstruct rsi_91x_usbdev *dev;\n\n\tif (!adapter)\n\t\treturn -ENODEV;\n\n\tif (endpoint == 0)\n\t\treturn -EINVAL;\n\n\tdev = (struct rsi_91x_usbdev *)adapter->rsi_dev;\n\tif (dev->write_fail)\n\t\treturn -ENETDOWN;\n\n\treturn rsi_usb_card_write(adapter, data, count, endpoint);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":459159,"func":"static void tcf_act_put_cookie(struct flow_action_entry *entry)\n{\n\tflow_action_cookie_destroy(entry->cookie);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":281131,"func":"xfrm_secpath_reject(int idx, struct sk_buff *skb, const struct flowi *fl)\n{\n\tstruct xfrm_state *x;\n\n\tif (!skb->sp || idx < 0 || idx >= skb->sp->len)\n\t\treturn 0;\n\tx = skb->sp->xvec[idx];\n\tif (!x->type->reject)\n\t\treturn 0;\n\treturn x->type->reject(x, skb, fl);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":226013,"func":"void tpay_box_del(GF_Box *s)\n{\n\tgf_free((GF_TPAYBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":228439,"func":"    size_t operator()(const ArrayOrObject data) const {\n      return data.toOpaque();\n    }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":250689,"func":"std::string HttpFileImpl::getMd5() const\n{\n    return utils::getMd5(fileContent_.data(), fileContent_.size());\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":476140,"func":"static int composite_ep0_queue(struct usb_composite_dev *cdev,\n\t\tstruct usb_request *req, gfp_t gfp_flags)\n{\n\tint ret;\n\n\tret = usb_ep_queue(cdev->gadget->ep0, req, gfp_flags);\n\tif (ret == 0) {\n\t\tif (cdev->req == req)\n\t\t\tcdev->setup_pending = true;\n\t\telse if (cdev->os_desc_req == req)\n\t\t\tcdev->os_desc_pending = true;\n\t\telse\n\t\t\tWARN(1, \"unknown request %p\\n\", req);\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":244365,"func":"GF_Err fdsa_box_size(GF_Box *s)\n{\n\treturn GF_OK;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":418785,"func":"time_diff_ms(struct timeval *t1, struct timeval *t2)\n{\n    \/\/ This handles wrapping of tv_usec correctly without any special case.\n    \/\/ Example of 2 pairs (tv_sec, tv_usec) with a duration of 5 ms:\n    \/\/\t   t1 = (1, 998000) t2 = (2, 3000) gives:\n    \/\/\t   (2 - 1) * 1000 + (3000 - 998000) \/ 1000 -> 5 ms.\n    return (t2->tv_sec - t1->tv_sec) * 1000\n\t + (t2->tv_usec - t1->tv_usec) \/ 1000;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":359560,"func":"DEFUN (bgp_redistribute_ipv4_rmap,\n       bgp_redistribute_ipv4_rmap_cmd,\n       \"redistribute (connected|kernel|ospf|rip|static) route-map WORD\",\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPF)\\n\"\n       \"Routing Information Protocol (RIP)\\n\"\n       \"Static routes\\n\"\n       \"Route map reference\\n\"\n       \"Pointer to route-map entries\\n\")\n{\n  int type;\n\n  type = bgp_str2route_type (AFI_IP, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);\n  return bgp_redistribute_set (vty->index, AFI_IP, type);\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":220192,"func":"const Edge* FindEdge(const Node* dst, int index) {\n  for (const Edge* e : dst->in_edges()) {\n    if (e->dst_input() == index) return e;\n  }\n  return nullptr;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":226330,"func":"\nGF_Err pcrb_box_size(GF_Box *s)\n{\n\tGF_PcrInfoBox *ptr = (GF_PcrInfoBox*) s;\n\n\tptr->size += 4;\n\tptr->size += ptr->subsegment_count * 6;\n\n\treturn GF_OK;","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":247078,"func":"struct _gf_ft_mgr *gf_fs_get_font_manager(GF_FilterSession *fsess)\n{\n#ifdef GPAC_DISABLE_PLAYER\n\treturn NULL;\n#else\n\tif (!fsess->font_manager) {\n\t\tfsess->font_manager = gf_font_manager_new();\n\t}\n\treturn fsess->font_manager;\n#endif\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":512840,"func":"cmp_item* cmp_item_row::make_same()\n{\n  return new cmp_item_row();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":473992,"func":"st_init_numtable_with_size(st_index_t size)\n{\n    return st_init_table_with_size(&type_numhash, size);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":226150,"func":"\nvoid ssix_box_del(GF_Box *s)\n{\n\tu32 i;\n\tGF_SubsegmentIndexBox *ptr = (GF_SubsegmentIndexBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->subsegments) {\n\t\tfor (i = 0; i < ptr->subsegment_alloc; i++) {\n\t\t\tGF_SubsegmentInfo *subsegment = &ptr->subsegments[i];\n\t\t\tif (subsegment->ranges) gf_free(subsegment->ranges);\n\t\t}\n\t\tgf_free(ptr->subsegments);\n\t}\n\tgf_free(ptr);","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":409501,"func":"blink_state_is_inverted()\n{\n#ifdef FEAT_TERMRESPONSE\n    return rbm_status.tr_progress == STATUS_GOT\n\t&& rcs_status.tr_progress == STATUS_GOT\n\t\t&& initial_cursor_blink != initial_cursor_shape_blink;\n#else\n    return FALSE;\n#endif\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":262727,"func":"njs_iterator_object_handler(njs_vm_t *vm, njs_iterator_handler_t handler,\n    njs_iterator_args_t *args, njs_value_t *key, int64_t i)\n{\n    njs_int_t    ret;\n    njs_value_t  prop, *entry;\n\n    if (key != NULL) {\n        ret = njs_value_property(vm, args->value, key, &prop);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n\n    } else {\n        ret = njs_value_property_i64(vm, args->value, i, &prop);\n        if (njs_slow_path(ret == NJS_ERROR)) {\n            return ret;\n        }\n    }\n\n    entry = (ret == NJS_OK) ? &prop : njs_value_arg(&njs_value_invalid);\n\n    ret = handler(vm, args, entry, i);\n    if (njs_slow_path(ret != NJS_OK)) {\n        if (ret == NJS_DONE) {\n            return NJS_DONE;\n        }\n\n        return NJS_ERROR;\n    }\n\n    return ret;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":220101,"func":"static int nfs4_setlease(struct file *file, long arg, struct file_lock **lease,\n\t\t\t void **priv)\n{\n\treturn nfs4_proc_setlease(file, arg, lease, priv);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":226078,"func":"GF_Box *ftyp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_FileTypeBox, GF_ISOM_BOX_TYPE_FTYP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":314756,"func":"cdf_tole2(uint16_t sv)\n{\n\treturn CDF_TOLE2(sv);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":90219,"func":"bool CellularNetwork::is_gsm() const {\n  return network_technology_ != NETWORK_TECHNOLOGY_EVDO &&\n      network_technology_ != NETWORK_TECHNOLOGY_1XRTT &&\n      network_technology_ != NETWORK_TECHNOLOGY_UNKNOWN;\n}\n","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":335421,"func":"excmd_get_cmdidx(char_u *cmd, int len)\n{\n    cmdidx_T idx;\n\n    if (!one_letter_cmd(cmd, &idx))\n\tfor (idx = (cmdidx_T)0; (int)idx < (int)CMD_SIZE;\n\t\tidx = (cmdidx_T)((int)idx + 1))\n\t    if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0)\n\t\tbreak;\n\n    return idx;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":247082,"func":"Bool gf_fs_ui_event(GF_FilterSession *session, GF_Event *uievt)\n{\n\tBool ret;\n\tgf_mx_p(session->ui_mx);\n\tret = session->ui_event_proc(session->ui_opaque, uievt);\n\tgf_mx_v(session->ui_mx);\n\treturn ret;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":335089,"func":"static int skcipher_alloc_sgl(struct sock *sk)\n{\n\tstruct alg_sock *ask = alg_sk(sk);\n\tstruct skcipher_ctx *ctx = ask->private;\n\tstruct skcipher_sg_list *sgl;\n\tstruct scatterlist *sg = NULL;\n\n\tsgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);\n\tif (!list_empty(&ctx->tsgl))\n\t\tsg = sgl->sg;\n\n\tif (!sg || sgl->cur >= MAX_SGL_ENTS) {\n\t\tsgl = sock_kmalloc(sk, sizeof(*sgl) +\n\t\t\t\t       sizeof(sgl->sg[0]) * (MAX_SGL_ENTS + 1),\n\t\t\t\t   GFP_KERNEL);\n\t\tif (!sgl)\n\t\t\treturn -ENOMEM;\n\n\t\tsg_init_table(sgl->sg, MAX_SGL_ENTS + 1);\n\t\tsgl->cur = 0;\n\n\t\tif (sg) {\n\t\t\tscatterwalk_sg_chain(sg, MAX_SGL_ENTS + 1, sgl->sg);\n\t\t\tsg_unmark_end(sg + (MAX_SGL_ENTS - 1));\n\t\t}\n\n\t\tlist_add_tail(&sgl->list, &ctx->tsgl);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":317229,"func":"static int smk_curacc_msq(struct kern_ipc_perm *isp, int access)\n{\n\tstruct smack_known *msp = smack_of_ipc(isp);\n\tstruct smk_audit_info ad;\n\tint rc;\n\n#ifdef CONFIG_AUDIT\n\tsmk_ad_init(&ad, __func__, LSM_AUDIT_DATA_IPC);\n\tad.a.u.ipc_id = isp->id;\n#endif\n\trc = smk_curacc(msp, access, &ad);\n\trc = smk_bu_current(\"msq\", msp, access, rc);\n\treturn rc;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":310135,"func":"drv_setfilter(TERMINAL_CONTROL_BLOCK * TCB)\n{\n    AssertTCB();\n\n    \/* *INDENT-EQLS* *\/\n    clear_screen     = ABSENT_STRING;\n    cursor_address   = ABSENT_STRING;\n    cursor_down      = ABSENT_STRING;\n    cursor_up        = ABSENT_STRING;\n    parm_down_cursor = ABSENT_STRING;\n    parm_up_cursor   = ABSENT_STRING;\n    row_address      = ABSENT_STRING;\n    cursor_home      = carriage_return;\n\n    if (back_color_erase)\n\tclr_eos = ABSENT_STRING;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":412125,"func":"dnsc_shared_secrets_cache_key(uint8_t* key,\n                              uint8_t esversion,\n                              uint8_t* pk,\n                              uint8_t* sk)\n{\n    key[0] = esversion;\n    memcpy(key + 1, pk, crypto_box_PUBLICKEYBYTES);\n    memcpy(key + 1 + crypto_box_PUBLICKEYBYTES, sk, crypto_box_SECRETKEYBYTES);\n    return hashlittle(key, DNSCRYPT_SHARED_SECRET_KEY_LENGTH, 0);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":333052,"func":"st_pop(Frag_T **p, Frag_T *stack)\n{\n    Frag_T *stackp;\n\n    *p = *p - 1;\n    stackp = *p;\n    if (stackp < stack)\n\treturn empty;\n    return **p;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":424939,"func":"static int iwl_dbgfs_monitor_data_release(struct inode *inode,\n\t\t\t\t\t  struct file *file)\n{\n\tstruct iwl_trans_pcie *trans_pcie =\n\t\tIWL_TRANS_GET_PCIE_TRANS(inode->i_private);\n\n\tif (trans_pcie->fw_mon_data.state == IWL_FW_MON_DBGFS_STATE_OPEN)\n\t\ttrans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED;\n\treturn 0;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":482509,"func":"passGetVariableNumber(\n\t\tconst FileInfo *file, CharsString *passLine, int *passLinepos, widechar *number) {\n\tif (!passGetNumber(passLine, passLinepos, number)) {\n\t\tcompileError(file, \"missing variable number\");\n\t\treturn 0;\n\t}\n\tif ((*number >= 0) && (*number < NUMVAR)) return 1;\n\tcompileError(file, \"variable number out of range\");\n\treturn 0;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":509520,"func":"int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key,\n\t\t\t\t key_part_map keypart_map,\n\t\t\t\t enum ha_rkey_function find_flag)\n{\n  int error;\n  register_handler(file);\n\n  \/* Use the pushed index condition if it matches the index we're scanning *\/\n  end_range= NULL;\n  if (index == pushed_idx_cond_keyno)\n    ma_set_index_cond_func(file, handler_index_cond_check, this);\n\n  error= maria_rkey(file, buf, index, key, keypart_map, find_flag);\n\n  ma_set_index_cond_func(file, NULL, 0);\n  return error;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":389723,"func":"check_for_string_or_list_or_blob_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_STRING\n\t    && args[idx].v_type != VAR_LIST\n\t    && args[idx].v_type != VAR_BLOB)\n    {\n\tsemsg(_(e_string_list_or_blob_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":313557,"func":"static int rose_dev_exists(rose_address *addr)\n{\n\tstruct net_device *dev;\n\n\trcu_read_lock();\n\tfor_each_netdev_rcu(&init_net, dev) {\n\t\tif ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE &&\n\t\t    rosecmp(addr, (const rose_address *)dev->dev_addr) == 0)\n\t\t\tgoto out;\n\t}\n\tdev = NULL;\nout:\n\trcu_read_unlock();\n\treturn dev != NULL;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":261951,"func":"njs_string_create(njs_vm_t *vm, njs_value_t *value, const char *src,\n    size_t size)\n{\n    njs_str_t  str;\n\n    str.start = (u_char *) src;\n    str.length = size;\n\n    return njs_string_decode_utf8(vm, value, &str);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":317314,"func":"static int selinux_msg_msg_alloc_security(struct msg_msg *msg)\n{\n\tstruct msg_security_struct *msec;\n\n\tmsec = selinux_msg_msg(msg);\n\tmsec->sid = SECINITSID_UNLABELED;\n\n\treturn 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":221424,"func":"static inline bool nested_npt_enabled(struct vcpu_svm *svm)\n{\n\treturn svm->nested.ctl.nested_ctl & SVM_NESTED_CTL_NP_ENABLE;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":238555,"func":"static int check_func_proto(const struct bpf_func_proto *fn, int func_id)\n{\n\treturn check_raw_mode_ok(fn) &&\n\t       check_arg_pair_ok(fn) &&\n\t       check_btf_id_ok(fn) &&\n\t       check_refcount_ok(fn, func_id) ? 0 : -EINVAL;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":439170,"func":"static MagickBooleanType IsFITS(const unsigned char *magick,const size_t length)\n{\n  if (length < 6)\n    return(MagickFalse);\n  if (LocaleNCompare((const char *) magick,\"IT0\",3) == 0)\n    return(MagickTrue);\n  if (LocaleNCompare((const char *) magick,\"SIMPLE\",6) == 0)\n    return(MagickTrue);\n  return(MagickFalse);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":238325,"func":"void digest_algo_prints(const char *prefix)\n{\n\tstruct digest_algo* d;\n\n\tprintf(\"%s%-15s\\t%-20s\\t%-15s\\n\", prefix, \"name\", \"driver\", \"priority\");\n\tprintf(\"%s--------------------------------------------------\\n\", prefix);\n\tlist_for_each_entry(d, &digests, list) {\n\t\tprintf(\"%s%-15s\\t%-20s\\t%d\\n\", prefix, d->base.name,\n\t\t\td->base.driver_name, d->base.priority);\n\t}\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":487658,"func":"static void kernel_restart_prepare(char *cmd)\n{\n\tblocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);\n\tsystem_state = SYSTEM_RESTART;\n\tdevice_shutdown();\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":236141,"func":"GF_Err hlit_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":226094,"func":"GF_Box *tfra_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackFragmentRandomAccessBox, GF_ISOM_BOX_TYPE_TFRA);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":252465,"func":"static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len,\n                                          void *pUser) {\n  tdefl_output_buffer *p = (tdefl_output_buffer *)pUser;\n  size_t new_size = p->m_size + len;\n  if (new_size > p->m_capacity) {\n    size_t new_capacity = p->m_capacity;\n    mz_uint8 *pNew_buf;\n    if (!p->m_expandable) return MZ_FALSE;\n    do {\n      new_capacity = MZ_MAX(128U, new_capacity << 1U);\n    } while (new_size > new_capacity);\n    pNew_buf = (mz_uint8 *)MZ_REALLOC(p->m_pBuf, new_capacity);\n    if (!pNew_buf) return MZ_FALSE;\n    p->m_pBuf = pNew_buf;\n    p->m_capacity = new_capacity;\n  }\n  memcpy((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len);\n  p->m_size = new_size;\n  return MZ_TRUE;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":512495,"func":"void Item_in_optimizer::restore_first_argument()\n{\n  if (!invisible_mode())\n  {\n    args[0]= ((Item_in_subselect *)args[1])->left_expr;\n  }\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":437689,"func":"static inline void irqenable_tx(struct cx23885_dev *dev, u32 mask)\n{\n\tmask &= IRQEN_TSE;\n\tcx23888_ir_and_or4(dev, CX23888_IR_IRQEN_REG, ~IRQEN_TSE, mask);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":139211,"func":"gfx::Rect OverlayWindowViews::CalculateControlsBounds(int x,\n                                                      const gfx::Size& size) {\n  return gfx::Rect(\n      gfx::Point(x, (GetBounds().size().height() - size.height()) \/ 2), size);\n}\n","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":473964,"func":"compile_string_node(Node* node, regex_t* reg)\n{\n  int r, len, prev_len, slen, ambig;\n  OnigEncoding enc = reg->enc;\n  UChar *p, *prev, *end;\n  StrNode* sn;\n\n  sn = NSTR(node);\n  if (sn->end <= sn->s)\n    return 0;\n\n  end = sn->end;\n  ambig = NSTRING_IS_AMBIG(node);\n\n  p = prev = sn->s;\n  prev_len = enclen(enc, p, end);\n  p += prev_len;\n  slen = 1;\n\n  for (; p < end; ) {\n    len = enclen(enc, p, end);\n    if (len == prev_len) {\n      slen++;\n    }\n    else {\n      r = add_compile_string(prev, prev_len, slen, reg, ambig);\n      if (r) return r;\n\n      prev  = p;\n      slen  = 1;\n      prev_len = len;\n    }\n\n    p += len;\n  }\n  return add_compile_string(prev, prev_len, slen, reg, ambig);\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":401514,"func":"static void invalidate_batched_entropy(void)\n{\n\tint cpu;\n\tunsigned long flags;\n\n\tfor_each_possible_cpu (cpu) {\n\t\tstruct batched_entropy *batched_entropy;\n\n\t\tbatched_entropy = per_cpu_ptr(&batched_entropy_u32, cpu);\n\t\tspin_lock_irqsave(&batched_entropy->batch_lock, flags);\n\t\tbatched_entropy->position = 0;\n\t\tspin_unlock(&batched_entropy->batch_lock);\n\n\t\tbatched_entropy = per_cpu_ptr(&batched_entropy_u64, cpu);\n\t\tspin_lock(&batched_entropy->batch_lock);\n\t\tbatched_entropy->position = 0;\n\t\tspin_unlock_irqrestore(&batched_entropy->batch_lock, flags);\n\t}\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":259543,"func":"static CURLUcode parseurl_and_replace(const char *url, CURLU *u,\n                                      unsigned int flags)\n{\n  CURLUcode result;\n  CURLU tmpurl;\n  memset(&tmpurl, 0, sizeof(tmpurl));\n  result = parseurl(url, &tmpurl, flags);\n  if(!result) {\n    free_urlhandle(u);\n    *u = tmpurl;\n  }\n  else\n    free_urlhandle(&tmpurl);\n  return result;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":487627,"func":"asmlinkage long sys_newuname(struct new_utsname __user * name)\n{\n\tint errno = 0;\n\n\tdown_read(&uts_sem);\n\tif (copy_to_user(name, utsname(), sizeof *name))\n\t\terrno = -EFAULT;\n\tup_read(&uts_sem);\n\treturn errno;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":233876,"func":" *\/\nstatic int wddx_stack_is_empty(wddx_stack *stack)\n{\n\tif (stack->top == 0) {\n\t\treturn 1;\n\t} else {\n\t\treturn 0;\n\t}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":437383,"func":"copy_opt_exact(OptExact* to, OptExact* from)\n{\n  *to = *from;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":329904,"func":"mul8_8 (uint8_t a, uint8_t b)\n{\n    uint16_t t = a * (uint16_t)b + ONE_HALF;\n    return ((t >> G_SHIFT) + t) >> G_SHIFT;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":229272,"func":"future<utils::chunked_vector<client_data>> cql_server::get_client_data() {\n    utils::chunked_vector<client_data> ret;\n    co_await for_each_gently([&ret] (const generic_server::connection& c) {\n        const connection& conn = dynamic_cast<const connection&>(c);\n        ret.emplace_back(conn.make_client_data());\n    });\n    co_return ret;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":225744,"func":"\nGF_Box *stvi_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_StereoVideoBox, GF_ISOM_BOX_TYPE_STVI);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":274674,"func":"callbacks_window_scroll_event(GtkWidget *widget, GdkEventScroll *event)\n{\n\tswitch (event->direction) {\n\t\tcase GDK_SCROLL_UP:\n\t\t\trender_zoom_display (ZOOM_IN_CMOUSE, 0, event->x, event->y);\n\t\t\tbreak;\n\t\tcase GDK_SCROLL_DOWN:\n\t\t\trender_zoom_display (ZOOM_OUT_CMOUSE, 0, event->x, event->y);\n\t\t\tbreak;\n\t\tcase GDK_SCROLL_LEFT: \n\t\t\t\/* Ignore *\/\n\t\tcase GDK_SCROLL_RIGHT:\n\t\t\t\/* Ignore *\/\n\t\tdefault:\n\t\t\treturn TRUE;\n\t}\n\treturn TRUE;\n} \/* scroll_event *\/","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":336607,"func":"static int reds_set_migration_dest_info(RedsState *reds,\n                                        const char* dest,\n                                        int port, int secure_port,\n                                        const char* cert_subject)\n{\n    RedsMigSpice *spice_migration = NULL;\n\n    reds_mig_release(reds->config);\n    if ((port == -1 && secure_port == -1) || !dest) {\n        return FALSE;\n    }\n\n    spice_migration = g_new0(RedsMigSpice, 1);\n    spice_migration->port = port;\n    spice_migration->sport = secure_port;\n    spice_migration->host = g_strdup(dest);\n    if (cert_subject) {\n        spice_migration->cert_subject = g_strdup(cert_subject);\n    }\n\n    reds->config->mig_spice = spice_migration;\n\n    return TRUE;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":369250,"func":"static inline int io_rw_prep_async(struct io_kiocb *req, int rw)\n{\n\tstruct io_async_rw *iorw = req->async_data;\n\tstruct iovec *iov;\n\tint ret;\n\n\t\/* submission path, ->uring_lock should already be taken *\/\n\tret = io_import_iovec(rw, req, &iov, &iorw->s, 0);\n\tif (unlikely(ret < 0))\n\t\treturn ret;\n\n\tiorw->bytes_done = 0;\n\tiorw->free_iovec = iov;\n\tif (iov)\n\t\treq->flags |= REQ_F_NEED_CLEANUP;\n\treturn 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":455391,"func":"xfs_inode_clear_reclaim_tag(\n\tstruct xfs_perag\t*pag,\n\txfs_ino_t\t\tino)\n{\n\tradix_tree_tag_clear(&pag->pag_ici_root,\n\t\t\t     XFS_INO_TO_AGINO(pag->pag_mount, ino),\n\t\t\t     XFS_ICI_RECLAIM_TAG);\n\txfs_perag_clear_reclaim_tag(pag);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":261928,"func":"njs_string_prototype_iterator_obj(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t kind)\n{\n    njs_int_t    ret;\n    njs_value_t  *this;\n\n    this = njs_argument(args, 0);\n\n    ret = njs_string_object_validate(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    return njs_array_iterator_create(vm, this, &vm->retval, kind);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":488344,"func":"void print_vma_addr(char *prefix, unsigned long ip)\n{\n\tstruct mm_struct *mm = current->mm;\n\tstruct vm_area_struct *vma;\n\n\t\/*\n\t * Do not print if we are in atomic\n\t * contexts (in exception stacks, etc.):\n\t *\/\n\tif (preempt_count())\n\t\treturn;\n\n\tdown_read(&mm->mmap_sem);\n\tvma = find_vma(mm, ip);\n\tif (vma && vma->vm_file) {\n\t\tstruct file *f = vma->vm_file;\n\t\tchar *buf = (char *)__get_free_page(GFP_KERNEL);\n\t\tif (buf) {\n\t\t\tchar *p, *s;\n\n\t\t\tp = d_path(&f->f_path, buf, PAGE_SIZE);\n\t\t\tif (IS_ERR(p))\n\t\t\t\tp = \"?\";\n\t\t\ts = strrchr(p, '\/');\n\t\t\tif (s)\n\t\t\t\tp = s+1;\n\t\t\tprintk(\"%s%s[%lx+%lx]\", prefix, p,\n\t\t\t\t\tvma->vm_start,\n\t\t\t\t\tvma->vm_end - vma->vm_start);\n\t\t\tfree_page((unsigned long)buf);\n\t\t}\n\t}\n\tup_read(¤t->mm->mmap_sem);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":328906,"func":"R_API void r_bin_java_get_import_json_definitions(RBinJavaObj *bin, PJ *pj) {\n\tr_return_if_fail (pj);\n\tRList *the_list;\n\tRListIter *iter = NULL;\n\tchar *new_str;\n\n\tpj_ka (pj, \"imports\");\n\n\tif (!bin || !(the_list = r_bin_java_get_lib_names (bin))) {\n\t\tpj_end (pj);\n\t\treturn;\n\t}\n\n\tr_list_foreach (the_list, iter, new_str) {\n\t\tchar *tmp = new_str;\n\t\twhile (*tmp) {\n\t\t\tif (*tmp == '\/') {\n\t\t\t\t*tmp = '.';\n\t\t\t}\n\t\t\ttmp++;\n\t\t}\n\t\tpj_s (pj, new_str);\n\t}\n\tr_list_free (the_list);\n\tpj_end (pj);\n\treturn;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":335998,"func":"static int sr9700_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)\n{\n\tstruct usbnet *dev = netdev_priv(netdev);\n\n\treturn generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":450357,"func":"void vnc_display_init(const char *id, Error **errp)\n{\n    VncDisplay *vd;\n\n    if (vnc_display_find(id) != NULL) {\n        return;\n    }\n    vd = g_malloc0(sizeof(*vd));\n\n    vd->id = strdup(id);\n    QTAILQ_INSERT_TAIL(&vnc_displays, vd, next);\n\n    QTAILQ_INIT(&vd->clients);\n    vd->expires = TIME_MAX;\n\n    if (keyboard_layout) {\n        trace_vnc_key_map_init(keyboard_layout);\n        vd->kbd_layout = init_keyboard_layout(name2keysym,\n                                              keyboard_layout, errp);\n    } else {\n        vd->kbd_layout = init_keyboard_layout(name2keysym, \"en-us\", errp);\n    }\n\n    if (!vd->kbd_layout) {\n        return;\n    }\n\n    vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;\n    vd->connections_limit = 32;\n\n    qemu_mutex_init(&vd->mutex);\n    vnc_start_worker_thread();\n\n    vd->dcl.ops = &dcl_ops;\n    register_displaychangelistener(&vd->dcl);\n    vd->kbd = qkbd_state_init(vd->dcl.con);\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":409460,"func":"get_long_from_buf(char_u *buf, long_u *val)\n{\n    int\t    len;\n    char_u  bytes[sizeof(long_u)];\n    int\t    i;\n    int\t    shift;\n\n    *val = 0;\n    len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u));\n    if (len != -1)\n    {\n\tfor (i = 0; i < (int)sizeof(long_u); i++)\n\t{\n\t    shift = 8 * (sizeof(long_u) - 1 - i);\n\t    *val += (long_u)bytes[i] << shift;\n\t}\n    }\n    return len;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":90231,"func":"  virtual WifiNetwork* wifi_network() { return wifi_; }\n","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":247630,"func":"TEST_P(SslSocketTest, TestConnectionSucceedsWhenRejectOnExpiredNoOcspResponse) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n    - certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/good_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/ocsp\/test_data\/good_key.pem\"\n  ocsp_staple_policy: strict_stapling\n  )EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      cipher_suites:\n      - TLS_RSA_WITH_AES_128_GCM_SHA256\n)EOF\";\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.ocsp_staple_omitted\").enableOcspStapling());\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":243012,"func":"static void ssl_free_buffered_record( mbedtls_ssl_context *ssl )\n{\n    mbedtls_ssl_handshake_params * const hs = ssl->handshake;\n    if( hs == NULL )\n        return;\n\n    if( hs->buffering.future_record.data != NULL )\n    {\n        hs->buffering.total_bytes_buffered -=\n            hs->buffering.future_record.len;\n\n        mbedtls_free( hs->buffering.future_record.data );\n        hs->buffering.future_record.data = NULL;\n    }\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":455419,"func":"xfs_inode_ag_iterator_tag(\n\tstruct xfs_mount\t*mp,\n\tint\t\t\t(*execute)(struct xfs_inode *ip, int flags,\n\t\t\t\t\t   void *args),\n\tint\t\t\tflags,\n\tvoid\t\t\t*args,\n\tint\t\t\ttag)\n{\n\tstruct xfs_perag\t*pag;\n\tint\t\t\terror = 0;\n\tint\t\t\tlast_error = 0;\n\txfs_agnumber_t\t\tag;\n\n\tag = 0;\n\twhile ((pag = xfs_perag_get_tag(mp, ag, tag))) {\n\t\tag = pag->pag_agno + 1;\n\t\terror = xfs_inode_ag_walk(mp, pag, execute, flags, args, tag,\n\t\t\t\t\t  0);\n\t\txfs_perag_put(pag);\n\t\tif (error) {\n\t\t\tlast_error = error;\n\t\t\tif (error == -EFSCORRUPTED)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn last_error;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":369891,"func":"static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)\n{\n\tstruct dentry *dentry, *leader, *dir;\n\tchar buf[PROC_NUMBUF];\n\tstruct qstr name;\n\n\tname.name = buf;\n\tname.len = snprintf(buf, sizeof(buf), \"%d\", pid);\n\tdentry = d_hash_and_lookup(mnt->mnt_root, &name);\n\tif (dentry) {\n\t\tshrink_dcache_parent(dentry);\n\t\td_drop(dentry);\n\t\tdput(dentry);\n\t}\n\n\tname.name = buf;\n\tname.len = snprintf(buf, sizeof(buf), \"%d\", tgid);\n\tleader = d_hash_and_lookup(mnt->mnt_root, &name);\n\tif (!leader)\n\t\tgoto out;\n\n\tname.name = \"task\";\n\tname.len = strlen(name.name);\n\tdir = d_hash_and_lookup(leader, &name);\n\tif (!dir)\n\t\tgoto out_put_leader;\n\n\tname.name = buf;\n\tname.len = snprintf(buf, sizeof(buf), \"%d\", pid);\n\tdentry = d_hash_and_lookup(dir, &name);\n\tif (dentry) {\n\t\tshrink_dcache_parent(dentry);\n\t\td_drop(dentry);\n\t\tdput(dentry);\n\t}\n\n\tdput(dir);\nout_put_leader:\n\tdput(leader);\nout:\n\treturn;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":459117,"func":"static struct tcf_block *tcf_block_create(struct net *net, struct Qdisc *q,\n\t\t\t\t\t  u32 block_index,\n\t\t\t\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct tcf_block *block;\n\n\tblock = kzalloc(sizeof(*block), GFP_KERNEL);\n\tif (!block) {\n\t\tNL_SET_ERR_MSG(extack, \"Memory allocation for block failed\");\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\tmutex_init(&block->lock);\n\tmutex_init(&block->proto_destroy_lock);\n\tinit_rwsem(&block->cb_lock);\n\tflow_block_init(&block->flow_block);\n\tINIT_LIST_HEAD(&block->chain_list);\n\tINIT_LIST_HEAD(&block->owner_list);\n\tINIT_LIST_HEAD(&block->chain0.filter_chain_list);\n\n\trefcount_set(&block->refcnt, 1);\n\tblock->net = net;\n\tblock->index = block_index;\n\n\t\/* Don't store q pointer for blocks which are shared *\/\n\tif (!tcf_block_shared(block))\n\t\tblock->q = q;\n\treturn block;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":386489,"func":"void DL_Dxf::writeView(DL_WriterA& dw) {\n    dw.dxfString(  0, \"TABLE\");\n    dw.dxfString(  2, \"VIEW\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfHex(5, 6);\n    }\n    \/\/dw.dxfHex(330, 0);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbSymbolTable\");\n    }\n    dw.dxfInt( 70, 0);\n    dw.dxfString(  0, \"ENDTAB\");\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":512975,"func":"  Item_ref(THD *thd, Item_ref *item)\n    :Item_ident(thd, item), With_sum_func_cache(*item),\n     set_properties_only(0), ref(item->ref) {}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":314769,"func":"cdf_namecmp(const char *d, const uint16_t *s, size_t l)\n{\n\tfor (; l--; d++, s++)\n\t\tif (*d != CDF_TOLE2(*s))\n\t\t\treturn (unsigned char)*d - CDF_TOLE2(*s);\n\treturn 0;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":366239,"func":"static int do_loopback(struct path *path, const char *old_name,\n\t\t\t\tint recurse)\n{\n\tstruct path old_path;\n\tstruct mount *mnt = NULL, *parent;\n\tstruct mountpoint *mp;\n\tint err;\n\tif (!old_name || !*old_name)\n\t\treturn -EINVAL;\n\terr = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path);\n\tif (err)\n\t\treturn err;\n\n\terr = -EINVAL;\n\tif (mnt_ns_loop(old_path.dentry))\n\t\tgoto out;\n\n\tmp = lock_mount(path);\n\tif (IS_ERR(mp)) {\n\t\terr = PTR_ERR(mp);\n\t\tgoto out;\n\t}\n\n\tparent = real_mount(path->mnt);\n\tif (!check_mnt(parent))\n\t\tgoto out2;\n\n\tmnt = __do_loopback(&old_path, recurse);\n\tif (IS_ERR(mnt)) {\n\t\terr = PTR_ERR(mnt);\n\t\tgoto out2;\n\t}\n\n\terr = graft_tree(mnt, parent, mp);\n\tif (err) {\n\t\tlock_mount_hash();\n\t\tumount_tree(mnt, UMOUNT_SYNC);\n\t\tunlock_mount_hash();\n\t}\nout2:\n\tunlock_mount(mp);\nout:\n\tpath_put(&old_path);\n\treturn err;\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":389740,"func":"tv_get_string_chk(typval_T *varp)\n{\n    static char_u   mybuf[NUMBUFLEN];\n\n    return tv_get_string_buf_chk(varp, mybuf);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":273105,"func":"timespec_add(struct timespec time1, struct timespec time2)\n{\n  struct timespec result;\n\n  result.tv_sec = time1.tv_sec + time2.tv_sec;\n  result.tv_nsec = time1.tv_nsec + time2.tv_nsec;\n  if (result.tv_nsec >= 1000000000L)\n    {\n      result.tv_sec++;\n      result.tv_nsec -= 1000000000L;\n    }\n  return result;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":384117,"func":"raptor_xml_writer_comment(raptor_xml_writer* xml_writer,\n                          const unsigned char *s)\n{\n  XML_WRITER_FLUSH_CLOSE_BRACKET(xml_writer);\n  \n  raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)\"<!-- \", 5);\n  raptor_xml_writer_cdata(xml_writer, s);\n  raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)\" -->\", 4);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":513039,"func":"  void copy()\n  {\n    Timestamp_or_zero_datetime_native_null tmp(current_thd, item, false);\n    null_value= tmp.is_null();\n    m_value= tmp.is_null() ? Timestamp_or_zero_datetime() :\n                             Timestamp_or_zero_datetime(tmp);\n  }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":233819,"func":"void fmtutil_atari_help_palbits(deark *c)\n{\n\tde_msg(c, \"-opt atari:palbits=<9|12|15> : Numer of significant bits \"\n\t\t\"per palette color\");\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":249987,"func":"u64 GetMoovAndMetaSize(GF_ISOFile *movie, GF_List *writers)\n{\n\tu32 i;\n\tu64 size;\n\n\tsize = 0;\n\tif (movie->moov) {\n\t\tTrackWriter *writer;\n\t\tgf_isom_box_size((GF_Box *)movie->moov);\n\t\tsize = movie->moov->size;\n\t\tif (size > 0xFFFFFFFF) size += 8;\n\n\t\ti=0;\n\t\twhile ((writer = (TrackWriter*)gf_list_enum(writers, &i))) {\n\t\t\tsize -= writer->stbl->ChunkOffset->size;\n\t\t\tsize -= writer->stbl->SampleToChunk->size;\n\t\t\tgf_isom_box_size((GF_Box *)writer->stsc);\n\t\t\tgf_isom_box_size(writer->stco);\n\t\t\tsize += writer->stsc->size;\n\t\t\tsize += writer->stco->size;\n\t\t}\n\t}\n\tif (movie->meta) {\n\t\tu64 msize;\n\t\tgf_isom_box_size((GF_Box *)movie->meta);\n\t\tmsize = movie->meta->size;\n\t\tif (msize > 0xFFFFFFFF) msize += 8;\n\t\tsize += msize;\n\t}\n\treturn size;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":466160,"func":"static int em_pop_sreg(struct x86_emulate_ctxt *ctxt)\n{\n\tint seg = ctxt->src2.val;\n\tunsigned long selector;\n\tint rc;\n\n\trc = emulate_pop(ctxt, &selector, ctxt->op_bytes);\n\tif (rc != X86EMUL_CONTINUE)\n\t\treturn rc;\n\n\trc = load_segment_descriptor(ctxt, (u16)selector, seg);\n\treturn rc;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":353011,"func":"printableStringValidate(\n\tSyntax *syntax,\n\tstruct berval *val )\n{\n\tber_len_t i;\n\n\tif( BER_BVISEMPTY( val ) ) return LDAP_INVALID_SYNTAX;\n\n\tfor(i=0; i < val->bv_len; i++) {\n\t\tif( !SLAP_PRINTABLE(val->bv_val[i]) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":294527,"func":"c_nth_kday_to_jd(int y, int m, int n, int k, double sg, int *rjd, int *ns)\n{\n    int rjd2, ns2;\n\n    if (n > 0) {\n\tc_find_fdom(y, m, sg, &rjd2, &ns2);\n\trjd2 -= 1;\n    }\n    else {\n\tc_find_ldom(y, m, sg, &rjd2, &ns2);\n\trjd2 += 7;\n    }\n    *rjd = (rjd2 - MOD((rjd2 - k) + 1, 7)) + 7 * n;\n    *ns = (*rjd < sg) ? 0 : 1;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":427164,"func":"static void check_match (LexState *ls, int what, int who, int where) {\n  if (l_unlikely(!testnext(ls, what))) {\n    if (where == ls->linenumber)  \/* all in the same line? *\/\n      error_expected(ls, what);  \/* do not need a complex message *\/\n    else {\n      luaX_syntaxerror(ls, luaO_pushfstring(ls->L,\n             \"%s expected (to close %s at line %d)\",\n              luaX_token2str(ls, what), luaX_token2str(ls, who), where));\n    }\n  }\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":409461,"func":"termrequest_any_pending()\n{\n    int\t    i;\n    time_t  now = time(NULL);\n\n    for (i = 0; all_termrequests[i] != NULL; ++i)\n    {\n\tif (all_termrequests[i]->tr_progress == STATUS_SENT)\n\t{\n\t    if (all_termrequests[i]->tr_start > 0 && now > 0\n\t\t\t\t    && all_termrequests[i]->tr_start + 2 < now)\n\t\t\/\/ Sent the request more than 2 seconds ago and didn't get a\n\t\t\/\/ response, assume it failed.\n\t\tall_termrequests[i]->tr_progress = STATUS_FAIL;\n\t    else\n\t\treturn TRUE;\n\t}\n    }\n    return FALSE;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":432182,"func":"MemTxResult memory_region_dispatch_read(struct uc_struct *uc, MemoryRegion *mr,\n                                        hwaddr addr,\n                                        uint64_t *pval,\n                                        MemOp op,\n                                        MemTxAttrs attrs)\n{\n    unsigned size = memop_size(op);\n    MemTxResult r;\n\n    if (!memory_region_access_valid(uc, mr, addr, size, false, attrs)) {\n        *pval = unassigned_mem_read(mr, addr, size);\n        return MEMTX_DECODE_ERROR;\n    }\n\n    r = memory_region_dispatch_read1(uc, mr, addr, pval, size, attrs);\n    adjust_endianness(mr, pval, op);\n    return r;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":90833,"func":"  virtual ~UsageAndQuotaDispatcherTask() {\n    STLDeleteContainerPointers(callbacks_.begin(), callbacks_.end());\n    STLDeleteContainerPointers(unlimited_callbacks_.begin(),\n                               unlimited_callbacks_.end());\n  }\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":382798,"func":"static int dynamicSeek (struct gdIOCtx *ctx, const int pos)\n{\n\tint bytesNeeded;\n\tdynamicPtr *dp;\n\tdpIOCtx *dctx;\n\n\tdctx = (dpIOCtx *) ctx;\n\tdp = dctx->dp;\n\n\tif (!dp->dataGood) {\n\t\treturn FALSE;\n\t}\n\n\tbytesNeeded = pos;\n\tif (bytesNeeded > dp->realSize) {\n\t\t\/* 2.0.21 *\/\n\t\tif (!dp->freeOK) {\n\t\t\treturn FALSE;\n\t\t}\n\t\tgdReallocDynamic (dp, dp->realSize * 2);\n\t}\n\n\t\/* if we get here, we can be sure that we have enough bytes to copy safely *\/\n\n\t\/* Extend the logical size if we seek beyond EOF. *\/\n\tif (pos > dp->logicalSize) {\n\t\tdp->logicalSize = pos;\n\t}\n\n\tdp->pos = pos;\n\n\treturn TRUE;\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":225815,"func":"\nGF_Err trgt_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TrackGroupTypeBox *ptr = (GF_TrackGroupTypeBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 4);\n\tptr->track_group_id = gf_bs_read_u32(bs);\n\treturn GF_OK;","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":229291,"func":"sstring to_string(const event::schema_change::target_type t) {\n    switch (t) {\n    case event::schema_change::target_type::KEYSPACE: return \"KEYSPACE\";\n    case event::schema_change::target_type::TABLE:    return \"TABLE\";\n    case event::schema_change::target_type::TYPE:     return \"TYPE\";\n    case event::schema_change::target_type::FUNCTION: return \"FUNCTION\";\n    case event::schema_change::target_type::AGGREGATE:return \"AGGREGATE\";\n    }\n    assert(false && \"unreachable\");\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":275942,"func":"uECC_RNG_Function uECC_get_rng(void) {\n    return g_rng_function;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":513290,"func":"join_read_next(READ_RECORD *info)\n{\n  int error;\n  if ((error= info->table->file->ha_index_next(info->record)))\n    return report_error(info->table, error);\n\n  return 0;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":417120,"func":"mp_sint32 PlayerGeneric::getRow() const\n{\n\tif (player)\n\t{\n\t\tmp_uint32 index = player->getBeatIndexFromSamplePos(getCurrentSamplePosition());\n\t\treturn player->getRow(index);\n\t}\n\t\n\treturn 0;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":219926,"func":"Bool CheckHintFormat(GF_TrackBox *trak, u32 HintType)\n{\n\tif (!IsHintTrack(trak)) return GF_FALSE;\n\tif (GetHintFormat(trak) != HintType) return GF_FALSE;\n\treturn GF_TRUE;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":309941,"func":"extended_color_content(int color, int *r, int *g, int *b)\n{\n    return NCURSES_SP_NAME(extended_color_content) (CURRENT_SCREEN,\n\t\t\t\t\t\t    color,\n\t\t\t\t\t\t    r, g, b);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":242981,"func":"static size_t ssl_compute_padding_length( size_t len,\n                                          size_t granularity )\n{\n    return( ( granularity - ( len + 1 ) % granularity ) % granularity );\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":221390,"func":"int nested_svm_exit_handled(struct vcpu_svm *svm)\n{\n\tint vmexit;\n\n\tvmexit = nested_svm_intercept(svm);\n\n\tif (vmexit == NESTED_EXIT_DONE)\n\t\tnested_svm_vmexit(svm);\n\n\treturn vmexit;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":459025,"func":"http_EstimateWS(const struct http *fm, unsigned how)\n{\n\tunsigned u, l;\n\n\tl = 4;\n\tCHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);\n\tfor (u = 0; u < fm->nhd; u++) {\n\t\tif (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL)\n\t\t\tcontinue;\n\t\tTcheck(fm->hd[u]);\n\t\tif (http_isfiltered(fm, u, how))\n\t\t\tcontinue;\n\t\tl += Tlen(fm->hd[u]) + 1L;\n\t}\n\treturn (PRNDUP(l + 1L));\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":229234,"func":"void cql_server::response::compress_snappy()\n{\n    using namespace compression_buffers;\n    auto view = input_buffer.get_linearized_view(_body);\n    const char* input = reinterpret_cast<const char*>(view.data());\n    size_t input_len = view.size();\n\n    size_t output_len = snappy_max_compressed_length(input_len);\n    _body = output_buffer.make_buffer(output_len, [&] (bytes_mutable_view output_view) {\n        char* output = reinterpret_cast<char*>(output_view.data());\n        if (snappy_compress(input, input_len, output, &output_len) != SNAPPY_OK) {\n            throw std::runtime_error(\"CQL frame Snappy compression failure\");\n        }\n        return output_len;\n    });\n    on_compression_buffer_use();\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":445920,"func":"pref_list_mode_changed (GSettings  *settings,\n\t\t\tconst char *key,\n\t\t\tgpointer    user_data)\n{\n\tFrWindow *window = user_data;\n\n\tfr_window_set_list_mode (window, g_settings_get_enum (settings, key));\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":230306,"func":"njs_array_indices(njs_vm_t *vm, njs_value_t *object)\n{\n    double       idx;\n    uint32_t     i;\n    njs_array_t  *keys;\n\n    keys = njs_array_keys(vm, object, 1);\n    if (njs_slow_path(keys == NULL)) {\n        return NULL;\n    }\n\n    for (i = 0; i < keys->length; i++) {\n        idx = njs_string_to_index(&keys->start[i]);\n\n        if (isnan(idx)) {\n            keys->length = i;\n            break;\n        }\n    }\n\n    return keys;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":430429,"func":"static void ovs_nla_free_check_pkt_len_action(const struct nlattr *action)\n{\n\tconst struct nlattr *a;\n\tint rem;\n\n\tnla_for_each_nested(a, action, rem) {\n\t\tswitch (nla_type(a)) {\n\t\tcase OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL:\n\t\tcase OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER:\n\t\t\tovs_nla_free_nested_actions(nla_data(a), nla_len(a));\n\t\t\tbreak;\n\t\t}\n\t}\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":237821,"func":"static char const *acurite_getChannelAndType(uint8_t byte, uint8_t mtype)\n{\n    static char const *channel_strs[] = {\"CR\", \"ER\", \"BR\", \"AR\", \"CF\", \"EF\", \"BF\", \"AF\"}; \/\/ 'E' stands for error\n\n    int channel = ((mtype & 0x01) << 2) | ((byte & 0xC0) >> 6);\n    return channel_strs[channel];\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":412336,"func":"static RzBinInfo *info(RzBinFile *bf) {\n\trz_return_val_if_fail(bf && bf->o && bf->o->bin_obj, NULL);\n\tRzBinInfo *ret = RZ_NEW0(RzBinInfo);\n\tif (!ret) {\n\t\treturn NULL;\n\t}\n\tret->file = bf->file ? strdup(bf->file) : NULL;\n\tret->type = strdup(\"QNX Executable\");\n\tret->bclass = strdup(\"qnx\");\n\tret->machine = strdup(\"i386\");\n\tret->rclass = strdup(\"QNX\");\n\tret->arch = strdup(\"x86\");\n\tret->os = strdup(\"any\");\n\tret->subsystem = strdup(\"any\");\n\tret->lang = \"C\/C++\";\n\tret->signature = true;\n\treturn ret;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":90166,"func":"static NetworkTechnology ParseNetworkTechnology(\n    const std::string& technology) {\n    if (technology == kNetworkTechnology1Xrtt)\n    return NETWORK_TECHNOLOGY_1XRTT;\n  if (technology == kNetworkTechnologyEvdo)\n    return NETWORK_TECHNOLOGY_EVDO;\n  if (technology == kNetworkTechnologyGprs)\n    return NETWORK_TECHNOLOGY_GPRS;\n  if (technology == kNetworkTechnologyEdge)\n    return NETWORK_TECHNOLOGY_EDGE;\n  if (technology == kNetworkTechnologyUmts)\n    return NETWORK_TECHNOLOGY_UMTS;\n  if (technology == kNetworkTechnologyHspa)\n    return NETWORK_TECHNOLOGY_HSPA;\n  if (technology == kNetworkTechnologyHspaPlus)\n    return NETWORK_TECHNOLOGY_HSPA_PLUS;\n  if (technology == kNetworkTechnologyLte)\n    return NETWORK_TECHNOLOGY_LTE;\n  if (technology == kNetworkTechnologyLteAdvanced)\n    return NETWORK_TECHNOLOGY_LTE_ADVANCED;\n  return NETWORK_TECHNOLOGY_UNKNOWN;\n}\n","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":512464,"func":"  Item_basic_constant(THD *thd): Item_basic_value(thd) {};","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":489145,"func":"static void *sctp_addto_param(struct sctp_chunk *chunk, int len,\n\t\t\t      const void *data)\n{\n\tvoid *target;\n\tint chunklen = ntohs(chunk->chunk_hdr->length);\n\n\ttarget = skb_put(chunk->skb, len);\n\n\tmemcpy(target, data, len);\n\n\t\/* Adjust the chunk length field.  *\/\n\tchunk->chunk_hdr->length = htons(chunklen + len);\n\tchunk->chunk_end = skb_tail_pointer(chunk->skb);\n\n\treturn target;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":233866,"func":"static void fourcc_clear(struct de_fourcc *fourcc)\n{\n\tde_zeromem(fourcc, sizeof(struct de_fourcc));\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":262790,"func":"static void mctp_serial_tty_write_wakeup(struct tty_struct *tty)\n{\n\tstruct mctp_serial *dev = tty->disc_data;\n\n\tschedule_work(&dev->tx_work);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":90768,"func":"  DumpQuotaTableTask(\n      QuotaManager* manager,\n      Callback* callback)\n      : DatabaseTaskBase(manager),\n        callback_(callback) {\n  }\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":481257,"func":"static void mlx5_fpga_conn_cq_tasklet(unsigned long data)\n{\n\tstruct mlx5_fpga_conn *conn = (void *)data;\n\n\tif (unlikely(!conn->qp.active))\n\t\treturn;\n\tmlx5_fpga_conn_cqes(conn, MLX5_FPGA_CQ_BUDGET);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":512933,"func":"  Item_copy(THD *thd, Item *i): Item(thd)\n  {\n    DBUG_ASSERT(i->is_fixed());\n    item= i;\n    null_value=maybe_null=item->maybe_null;\n    Type_std_attributes::set(item);\n    name= item->name;\n    set_handler(item->type_handler());\n  }","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":512662,"func":"int Arg_comparator::compare_native()\n{\n  THD *thd= current_thd;\n  if (!(*a)->val_native_with_conversion(thd, &m_native1,\n                                        compare_type_handler()))\n  {\n    if (!(*b)->val_native_with_conversion(thd, &m_native2,\n                                          compare_type_handler()))\n    {\n      if (set_null)\n        owner->null_value= 0;\n      return compare_type_handler()->cmp_native(m_native1, m_native2);\n    }\n  }\n  if (set_null)\n    owner->null_value= 1;\n  return -1;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":384206,"func":"static int nft_value_init(const struct nft_ctx *ctx,\n\t\t\t  struct nft_data *data, struct nft_data_desc *desc,\n\t\t\t  const struct nlattr *nla)\n{\n\tunsigned int len;\n\n\tlen = nla_len(nla);\n\tif (len == 0)\n\t\treturn -EINVAL;\n\tif (len > desc->size)\n\t\treturn -EOVERFLOW;\n\tif (desc->len) {\n\t\tif (len != desc->len)\n\t\t\treturn -EINVAL;\n\t} else {\n\t\tdesc->len = len;\n\t}\n\n\tnla_memcpy(data->data, nla, len);\n\n\treturn 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":267870,"func":"void ModularFrameDecoder::MaybeDropFullImage() {\n  if (full_image.transform.empty() && !have_something) {\n    use_full_image = false;\n    for (auto& ch : full_image.channel) {\n      \/\/ keep metadata on channels around, but dealloc their planes\n      ch.plane = Plane<pixel_type>();\n    }\n  }\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":139220,"func":"gfx::Rect OverlayWindowViews::GetFirstCustomControlsBounds() {\n  if (!first_custom_controls_view_)\n    return gfx::Rect();\n  return first_custom_controls_view_->GetMirroredBounds();\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":452248,"func":"PHP_FUNCTION(xsl_xsltprocessor_transform_to_xml)\n{\n\tzval *id, *docp = NULL;\n\txmlDoc *newdocp;\n\txsltStylesheetPtr sheetp;\n\tint ret;\n\txmlChar *doc_txt_ptr;\n\tint doc_txt_len;\n\txsl_object *intern;\n\n\tid = getThis();\n\tintern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);\n\tsheetp = (xsltStylesheetPtr) intern->ptr;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"o\", &docp) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tnewdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);\n\n\tret = -1;\n\tif (newdocp) {\n\t\tret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);\n\t\tif (doc_txt_ptr && doc_txt_len) {\n\t\t\tRETVAL_STRINGL(doc_txt_ptr, doc_txt_len, 1);\n\t\t\txmlFree(doc_txt_ptr);\n\t\t}\n\t\txmlFreeDoc(newdocp);\n\t}\n\n\tif (ret < 0) {\n\t\tRETURN_FALSE;\n\t}\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":489168,"func":"struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,\n\t\t\t\t const struct sctp_chunk *chunk,\n\t\t\t\t __be16 cause_code, const void *payload,\n\t\t\t\t size_t paylen)\n{\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_op_error_space(asoc, chunk, paylen);\n\tif (!retval)\n\t\tgoto nodata;\n\n\tsctp_init_cause(retval, cause_code, paylen);\n\tsctp_addto_chunk(retval, paylen, payload);\n\nnodata:\n\treturn retval;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":310304,"func":"dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,\n                            cached_dir_t *auth_src,\n                            time_t dirty, cached_dir_t *(*regenerate)(void),\n                            const char *name,\n                            authority_type_t auth_type)\n{\n  or_options_t *options = get_options();\n  int authority = (auth_type == V1_AUTHORITY && authdir_mode_v1(options)) ||\n                  (auth_type == V2_AUTHORITY && authdir_mode_v2(options));\n\n  if (!authority || authdir_mode_bridge(options)) {\n    return cache_src;\n  } else {\n    \/* We're authoritative. *\/\n    if (regenerate != NULL) {\n      if (dirty && dirty + DIR_REGEN_SLACK_TIME < time(NULL)) {\n        if (!(auth_src = regenerate())) {\n          log_err(LD_BUG, \"Couldn't generate %s?\", name);\n          exit(1);\n        }\n      } else {\n        log_info(LD_DIRSERV, \"The %s is still clean; reusing.\", name);\n      }\n    }\n    return auth_src ? auth_src : cache_src;\n  }\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":220839,"func":"void optimized_ops_prefetch_write_l1_keep(const T* ptr) {\n#ifdef __GNUC__\n  \/\/ builtin offered by GCC-compatible compilers including clang\n  __builtin_prefetch(ptr, \/* 1 means write *\/ 1, \/* 3 means high locality *\/ 3);\n#else\n  (void)ptr;\n#endif\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":463058,"func":"static uint16_t sungem_mii_read(SunGEMState *s, uint8_t phy_addr,\n                                uint8_t reg_addr)\n{\n    uint16_t val;\n\n    val = __sungem_mii_read(s, phy_addr, reg_addr);\n\n    trace_sungem_mii_read(phy_addr, reg_addr, val);\n\n    return val;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":512300,"func":"  void set_geometry_type(uint type)\n  { Type_geometry_attributes::set_geometry_type(type); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":437302,"func":"select_opt_exact(OnigEncoding enc, OptExact* now, OptExact* alt)\n{\n  int vn, va;\n\n  vn = now->len;\n  va = alt->len;\n\n  if (va == 0) {\n    return ;\n  }\n  else if (vn == 0) {\n    copy_opt_exact(now, alt);\n    return ;\n  }\n  else if (vn <= 2 && va <= 2) {\n    \/* ByteValTable[x] is big value --> low price *\/\n    va = map_position_value(enc, now->s[0]);\n    vn = map_position_value(enc, alt->s[0]);\n\n    if (now->len > 1) vn += 5;\n    if (alt->len > 1) va += 5;\n  }\n\n  if (now->ignore_case == 0) vn *= 2;\n  if (alt->ignore_case == 0) va *= 2;\n\n  if (comp_distance_value(&now->mmd, &alt->mmd, vn, va) > 0)\n    copy_opt_exact(now, alt);\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":207703,"func":"set<int> PipeSocketHandler::listen(const SocketEndpoint& endpoint) {\n  lock_guard<std::recursive_mutex> guard(globalMutex);\n\n  string pipePath = endpoint.name();\n  if (pipeServerSockets.find(pipePath) != pipeServerSockets.end()) {\n    throw runtime_error(\"Tried to listen twice on the same path\");\n  }\n\n  sockaddr_un local;\n\n  int fd = socket(AF_UNIX, SOCK_STREAM, 0);\n  FATAL_FAIL(fd);\n  initServerSocket(fd);\n  local.sun_family = AF_UNIX; \/* local is declared before socket() ^ *\/\n  strcpy(local.sun_path, pipePath.c_str());\n  unlink(local.sun_path);\n\n  FATAL_FAIL(::bind(fd, (struct sockaddr*)&local, sizeof(sockaddr_un)));\n  ::listen(fd, 5);\n#ifndef WIN32\n  FATAL_FAIL(::chmod(local.sun_path, S_IRUSR | S_IWUSR | S_IXUSR));\n#endif\n\n  pipeServerSockets[pipePath] = set<int>({fd});\n  return pipeServerSockets[pipePath];\n}","target":1,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":517458,"func":"static void do_foot(HttpResponse res) {\n        StringBuffer_append(res->outputbuffer,\n                            \"<\/center><\/div><\/div>\"\n                            \"<div id='footer'>\"\n                            \"Copyright © 2001-2018 <a href=\\\"http:\/\/tildeslash.com\/\\\">Tildeslash<\/a>. All rights reserved. \"\n                            \"<span style='margin-left:5px;'><\/span>\"\n                            \"<a href=\\\"http:\/\/mmonit.com\/monit\/\\\">Monit web site<\/a> | \"\n                            \"<a href=\\\"http:\/\/mmonit.com\/wiki\/\\\">Monit Wiki<\/a> | \"\n                            \"<a href=\\\"http:\/\/mmonit.com\/\\\">M\/Monit<\/a>\"\n                            \"<\/div><\/body><\/html>\");\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":404742,"func":"unsigned long __fdget_pos(unsigned int fd)\n{\n\tunsigned long v = __fdget(fd);\n\tstruct file *file = (struct file *)(v & ~3);\n\n\tif (file && (file->f_mode & FMODE_ATOMIC_POS)) {\n\t\tif (file_count(file) > 1) {\n\t\t\tv |= FDPUT_POS_UNLOCK;\n\t\t\tmutex_lock(&file->f_pos_lock);\n\t\t}\n\t}\n\treturn v;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":219016,"func":"bool ConstantFolding::SimplifyReshape(const GraphProperties& properties,\n                                      bool use_shape_info, NodeDef* node) {\n  if (!use_shape_info || node->attr().count(\"T\") == 0 ||\n      !IsSimplifiableReshape(*node, properties).ok()) {\n    return false;\n  }\n  DataType output_type = node->attr().at(\"T\").type();\n  node->set_op(\"Identity\");\n  EraseRegularNodeAttributes(node);\n  (*node->mutable_attr())[\"T\"].set_type(output_type);\n  *node->mutable_input(1) = AsControlDependency(node->input(1));\n  return true;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":333048,"func":"nfa_regexec_nl(\n    regmatch_T\t*rmp,\n    char_u\t*line,\t\/\/ string to match against\n    colnr_T\tcol,\t\/\/ column to start looking for match\n    int\t\tline_lbr)\n{\n    rex.reg_match = rmp;\n    rex.reg_mmatch = NULL;\n    rex.reg_maxline = 0;\n    rex.reg_line_lbr = line_lbr;\n    rex.reg_buf = curbuf;\n    rex.reg_win = NULL;\n    rex.reg_ic = rmp->rm_ic;\n    rex.reg_icombine = FALSE;\n    rex.reg_maxcol = 0;\n    return nfa_regexec_both(line, col, NULL, NULL);\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":514316,"func":"void Multiupdate_prelocking_strategy::reset(THD *thd)\n{\n  done= false;\n  has_prelocking_list= thd->lex->requires_prelocking();\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":293754,"func":"static void handle_data_sections(RBinSection *sect) {\n\tif (strstr (sect->name, \"_cstring\")) {\n\t\tsect->is_data = true;\n\t} else if (strstr (sect->name, \"_os_log\")) {\n\t\tsect->is_data = true;\n\t} else if (strstr (sect->name, \"_objc_methname\")) {\n\t\tsect->is_data = true;\n\t} else if (strstr (sect->name, \"_objc_classname\")) {\n\t\tsect->is_data = true;\n\t} else if (strstr (sect->name, \"_objc_methtype\")) {\n\t\tsect->is_data = true;\n\t}\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":226365,"func":"\nGF_Err strk_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":386597,"func":"void DL_Dxf::writeControlPoint(DL_WriterA& dw,\n                               const DL_ControlPointData& data) {\n\n    dw.dxfReal(10, data.x);\n    dw.dxfReal(20, data.y);\n    dw.dxfReal(30, data.z);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":242950,"func":"void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl )\n{\n    \/* We won't need to resend that one any more *\/\n    mbedtls_ssl_flight_free( ssl->handshake->flight );\n    ssl->handshake->flight = NULL;\n    ssl->handshake->cur_msg = NULL;\n\n    \/* The next incoming flight will start with this msg_seq *\/\n    ssl->handshake->in_flight_start_seq = ssl->handshake->in_msg_seq;\n\n    \/* We don't want to remember CCS's across flight boundaries. *\/\n    ssl->handshake->buffering.seen_ccs = 0;\n\n    \/* Clear future message buffering structure. *\/\n    mbedtls_ssl_buffering_free( ssl );\n\n    \/* Cancel timer *\/\n    mbedtls_ssl_set_timer( ssl, 0 );\n\n    if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE &&\n        ssl->in_msg[0] == MBEDTLS_SSL_HS_FINISHED )\n    {\n        ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_FINISHED;\n    }\n    else\n        ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_PREPARING;\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":369413,"func":"\t__must_hold(&ctx->completion_lock)\n\t__must_hold(&ctx->timeout_lock)\n{\n\tstruct io_kiocb *req = io_timeout_extract(ctx, user_data);\n\n\tif (IS_ERR(req))\n\t\treturn PTR_ERR(req);\n\tio_req_task_queue_fail(req, -ECANCELED);\n\treturn 0;","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":437002,"func":"static void mcba_usb_process_rx(struct mcba_priv *priv,\n\t\t\t\tstruct mcba_usb_msg *msg)\n{\n\tswitch (msg->cmd_id) {\n\tcase MBCA_CMD_I_AM_ALIVE_FROM_CAN:\n\t\tmcba_usb_process_ka_can(priv,\n\t\t\t\t\t(struct mcba_usb_msg_ka_can *)msg);\n\t\tbreak;\n\n\tcase MBCA_CMD_I_AM_ALIVE_FROM_USB:\n\t\tmcba_usb_process_ka_usb(priv,\n\t\t\t\t\t(struct mcba_usb_msg_ka_usb *)msg);\n\t\tbreak;\n\n\tcase MBCA_CMD_RECEIVE_MESSAGE:\n\t\tmcba_usb_process_can(priv, (struct mcba_usb_msg_can *)msg);\n\t\tbreak;\n\n\tcase MBCA_CMD_NOTHING_TO_SEND:\n\t\t\/* Side effect of communication between PIC_USB and PIC_CAN.\n\t\t * PIC_CAN is telling us that it has nothing to send\n\t\t *\/\n\t\tbreak;\n\n\tcase MBCA_CMD_TRANSMIT_MESSAGE_RSP:\n\t\t\/* Transmission response from the device containing timestamp *\/\n\t\tbreak;\n\n\tdefault:\n\t\tnetdev_warn(priv->netdev, \"Unsupported msg (0x%X)\",\n\t\t\t    msg->cmd_id);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":398501,"func":"static int expand_info(RzBinDwarfDebugInfo *info) {\n\trz_return_val_if_fail(info && info->capacity == info->count, -1);\n\n\tRzBinDwarfCompUnit *tmp = realloc(info->comp_units,\n\t\tinfo->capacity * 2 * sizeof(RzBinDwarfCompUnit));\n\tif (!tmp) {\n\t\treturn -1;\n\t}\n\n\tmemset((ut8 *)tmp + info->capacity * sizeof(RzBinDwarfCompUnit),\n\t\t0, info->capacity * sizeof(RzBinDwarfCompUnit));\n\n\tinfo->comp_units = tmp;\n\tinfo->capacity *= 2;\n\n\treturn 0;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":261411,"func":"static int decode_log2_res_scale_abs_plus1(thread_context* tctx, int cIdxMinus1)\n{\n  \/\/const int context = (cIdx==0) ? 0 : 1;\n\n  logtrace(LogSlice,\"# log2_res_scale_abs_plus1 (c=%d)\\n\",cIdxMinus1);\n\n  int value = 0;\n  int cMax  = 4;\n  for (int binIdx=0;binIdx<cMax;binIdx++)\n    {\n      int ctxIdxInc = 4*cIdxMinus1 + binIdx;\n\n      int bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                                 &tctx->ctx_model[CONTEXT_MODEL_LOG2_RES_SCALE_ABS_PLUS1+ctxIdxInc]);\n      if (!bit) break;\n      value++;\n    }\n\n  logtrace(LogSymbols,\"$1 log2_res_scale_abs_plus1=%d\\n\",value);\n\n  return value;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":359623,"func":"DEFUN (bgp_redistribute_ipv6_rmap,\n       bgp_redistribute_ipv6_rmap_cmd,\n       \"redistribute (connected|kernel|ospf6|ripng|static) route-map WORD\",\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPFv3)\\n\"\n       \"Routing Information Protocol (RIPng)\\n\"\n       \"Static routes\\n\"\n       \"Route map reference\\n\"\n       \"Pointer to route-map entries\\n\")\n{\n  int type;\n\n  type = bgp_str2route_type (AFI_IP6, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);\n  return bgp_redistribute_set (vty->index, AFI_IP6, type);\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":328936,"func":"static char *convert_string(const char *bytes, ut32 len) {\n\tut32 idx = 0, pos = 0;\n\tut32 str_sz = 32 * len + 1;\n\tchar *cpy_buffer = len > 0 ? malloc (str_sz) : NULL;\n\tif (!cpy_buffer) {\n\t\treturn cpy_buffer;\n\t}\n\t\/\/ 4x is the increase from byte to \\xHH where HH represents hexed byte\n\tmemset (cpy_buffer, 0, str_sz);\n\twhile (idx < len && pos < len) {\n\t\tif (char_must_be_escaped (bytes[idx])) {\n\t\t\tif (pos + 2 < len) {\n\t\t\t\tfree (cpy_buffer);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tsprintf (cpy_buffer + pos, \"\\\\x%02x\", bytes[idx]);\n\t\t\tpos += 4;\n\t\t} else {\n\t\t\tcpy_buffer[pos] = bytes[idx];\n\t\t\tpos++;\n\t\t}\n\t\tidx++;\n\t}\n\treturn cpy_buffer;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":436079,"func":"\nstatic int io_unregister_iowq_aff(struct io_ring_ctx *ctx)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\n\tif (!tctx || !tctx->io_wq)\n\t\treturn -EINVAL;\n\n\treturn io_wq_cpu_affinity(tctx->io_wq, NULL);","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":482474,"func":"cons_macro(const Macro *head, const MacroList *tail) {\n\tMacroList *list = malloc(sizeof(MacroList));\n\tlist->head = head;\n\tlist->tail = tail;\n\treturn list;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":224555,"func":"Status AvgPool3DGradShape(shape_inference::InferenceContext* c) {\n  ShapeHandle s;\n  TF_RETURN_IF_ERROR(c->MakeShapeFromShapeTensor(0, &s));\n  TF_RETURN_IF_ERROR(c->WithRank(s, 5, &s));\n  c->set_output(0, s);\n  return Status::OK();\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":359281,"func":"zroute_lookup(u_int zroute)\n{\n  u_int i;\n\n  if (zroute >= sizeof(route_types)\/sizeof(route_types[0]))\n    {\n      zlog_err(\"unknown zebra route type: %u\", zroute);\n      return &unknown;\n    }\n  if (zroute == route_types[zroute].type)\n    return &route_types[zroute];\n  for (i = 0; i < sizeof(route_types)\/sizeof(route_types[0]); i++)\n    {\n      if (zroute == route_types[i].type)\n        {\n\t  zlog_warn(\"internal error: route type table out of order \"\n\t\t    \"while searching for %u, please notify developers\", zroute);\n\t  return &route_types[i];\n        }\n    }\n  zlog_err(\"internal error: cannot find route type %u in table!\", zroute);\n  return &unknown;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":247107,"func":"static GF_DownloadManager *gf_fs_get_download_manager(GF_FilterSession *fs)\n{\n\tif (!fs->download_manager) {\n\t\tfs->download_manager = gf_dm_new(fs);\n\n\t\tgf_dm_set_auth_callback(fs->download_manager, gf_fsess_get_user_pass, fs);\n\t}\n\treturn fs->download_manager;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":231801,"func":"  virtual void setupClientReadCodec() {\n    FizzCryptoFactory cryptoFactory;\n    clientReadCodec = std::make_unique<QuicReadCodec>(QuicNodeType::Client);\n    clientReadCodec->setClientConnectionId(*clientConnectionId);\n    clientReadCodec->setInitialReadCipher(cryptoFactory.getServerInitialCipher(\n        *initialDestinationConnectionId, QuicVersion::MVFST));\n    clientReadCodec->setInitialHeaderCipher(\n        cryptoFactory.makeServerInitialHeaderCipher(\n            *initialDestinationConnectionId, QuicVersion::MVFST));\n    clientReadCodec->setCodecParameters(\n        CodecParameters(kDefaultAckDelayExponent, QuicVersion::MVFST));\n  }","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":261992,"func":"void Curl_conncache_close_all_connections(struct conncache *connc)\n{\n  struct connectdata *conn;\n  char buffer[READBUFFER_MIN + 1];\n  SIGPIPE_VARIABLE(pipe_st);\n  if(!connc->closure_handle)\n    return;\n  connc->closure_handle->state.buffer = buffer;\n  connc->closure_handle->set.buffer_size = READBUFFER_MIN;\n\n  conn = conncache_find_first_connection(connc);\n  while(conn) {\n    sigpipe_ignore(connc->closure_handle, &pipe_st);\n    \/* This will remove the connection from the cache *\/\n    connclose(conn, \"kill all\");\n    Curl_conncache_remove_conn(connc->closure_handle, conn, TRUE);\n    Curl_disconnect(connc->closure_handle, conn, FALSE);\n    sigpipe_restore(&pipe_st);\n\n    conn = conncache_find_first_connection(connc);\n  }\n\n  connc->closure_handle->state.buffer = NULL;\n  sigpipe_ignore(connc->closure_handle, &pipe_st);\n\n  Curl_hostcache_clean(connc->closure_handle,\n                       connc->closure_handle->dns.hostcache);\n  Curl_close(&connc->closure_handle);\n  sigpipe_restore(&pipe_st);\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":484765,"func":"static int xennet_rxidx(RING_IDX idx)\n{\n\treturn idx & (NET_RX_RING_SIZE - 1);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":369212,"func":"static ssize_t __io_iov_buffer_select(struct io_kiocb *req, struct iovec *iov,\n\t\t\t\t      unsigned int issue_flags)\n{\n\tstruct iovec __user *uiov = u64_to_user_ptr(req->rw.addr);\n\tvoid __user *buf;\n\tssize_t len;\n\n\tif (copy_from_user(iov, uiov, sizeof(*uiov)))\n\t\treturn -EFAULT;\n\n\tlen = iov[0].iov_len;\n\tif (len < 0)\n\t\treturn -EINVAL;\n\tbuf = io_rw_buffer_select(req, &len, issue_flags);\n\tif (IS_ERR(buf))\n\t\treturn PTR_ERR(buf);\n\tiov[0].iov_base = buf;\n\tiov[0].iov_len = len;\n\treturn 0;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":225468,"func":"bool IsTensorIdRegular(const TensorId& tensor_id) {\n  return tensor_id.index() > Graph::kControlSlot;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":238428,"func":"static bool is_spilled_reg(const struct bpf_stack_state *stack)\n{\n\treturn stack->slot_type[BPF_REG_SIZE - 1] == STACK_SPILL;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":301417,"func":"static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp)\n{\n\tint result;\n\n\tSTART_PROFILE(syscall_close);\n\tresult = fd_close_posix(fsp);\n\tEND_PROFILE(syscall_close);\n\treturn result;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":261998,"func":"bool Curl_conncache_foreach(struct Curl_easy *data,\n                            struct conncache *connc,\n                            void *param,\n                            int (*func)(struct Curl_easy *data,\n                                        struct connectdata *conn, void *param))\n{\n  struct Curl_hash_iterator iter;\n  struct Curl_llist_element *curr;\n  struct Curl_hash_element *he;\n\n  if(!connc)\n    return FALSE;\n\n  CONNCACHE_LOCK(data);\n  Curl_hash_start_iterate(&connc->hash, &iter);\n\n  he = Curl_hash_next_element(&iter);\n  while(he) {\n    struct connectbundle *bundle;\n\n    bundle = he->ptr;\n    he = Curl_hash_next_element(&iter);\n\n    curr = bundle->conn_list.head;\n    while(curr) {\n      \/* Yes, we need to update curr before calling func(), because func()\n         might decide to remove the connection *\/\n      struct connectdata *conn = curr->ptr;\n      curr = curr->next;\n\n      if(1 == func(data, conn, param)) {\n        CONNCACHE_UNLOCK(data);\n        return TRUE;\n      }\n    }\n  }\n  CONNCACHE_UNLOCK(data);\n  return FALSE;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":413702,"func":"static int cmpnbbs(const void *_a, const void *_b) {\n\tconst RAnalFunction *a = _a, *b = _b;\n\tut64 as = r_list_length (a->bbs);\n\tut64 bs = r_list_length (b->bbs);\n\treturn (as> bs)? 1: (as< bs)? -1: 0;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":369416,"func":"static inline bool io_req_ffs_set(struct io_kiocb *req)\n{\n\treturn req->flags & REQ_F_FIXED_FILE;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":276992,"func":"mrb_mruby_fiber_gem_init(mrb_state* mrb)\n{\n  struct RClass *c;\n\n  c = mrb_define_class(mrb, \"Fiber\", mrb->object_class);\n  MRB_SET_INSTANCE_TT(c, MRB_TT_FIBER);\n\n  mrb_define_method(mrb, c, \"initialize\", fiber_init,    MRB_ARGS_NONE()|MRB_ARGS_BLOCK());\n  mrb_define_method(mrb, c, \"resume\",     fiber_resume,  MRB_ARGS_ANY());\n  mrb_define_method(mrb, c, \"transfer\",   fiber_transfer, MRB_ARGS_ANY());\n  mrb_define_method(mrb, c, \"alive?\",     fiber_alive_p, MRB_ARGS_NONE());\n  mrb_define_method(mrb, c, \"==\",         fiber_eq,      MRB_ARGS_REQ(1));\n\n  mrb_define_class_method(mrb, c, \"yield\", fiber_yield, MRB_ARGS_ANY());\n  mrb_define_class_method(mrb, c, \"current\", fiber_current, MRB_ARGS_NONE());\n\n  mrb_define_class(mrb, \"FiberError\", mrb->eStandardError_class);\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":228445,"func":"static TypedValue* add_vars_helper(ActRec* ar) {\n  int start_index = 1;\n  Resource packet_id{getArg<KindOfResource>(ar, 0)};\n  auto wddxPacket = cast<WddxPacket>(packet_id);\n\n  for (int i = start_index; i < ar->numArgs(); i++) {\n    auto const tv = getArg(ar, i);\n    find_var_recursive(tv, wddxPacket);\n  }\n  return arReturn(ar, true);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":226406,"func":"GF_Err tims_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TSHintEntryBox *ptr = (GF_TSHintEntryBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->timeScale);\n\treturn GF_OK;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":273901,"func":"static void ftp_command(ctrl_t *ctrl)\n{\n\tuev_t sigterm_watcher;\n\n\tctrl->bufsz = BUFFER_SIZE * sizeof(char);\n\tctrl->buf   = malloc(ctrl->bufsz);\n\tif (!ctrl->buf) {\n                WARN(errno, \"FTP session failed allocating buffer\");\n                exit(1);\n\t}\n\n\tsnprintf(ctrl->buf, ctrl->bufsz, \"220 %s (%s) ready.\\r\\n\", prognm, VERSION);\n\tsend_msg(ctrl->sd, ctrl->buf);\n\n\tuev_signal_init(ctrl->ctx, &sigterm_watcher, child_exit, NULL, SIGTERM);\n\tuev_io_init(ctrl->ctx, &ctrl->io_watcher, read_client_command, ctrl, ctrl->sd, UEV_READ);\n\tuev_run(ctrl->ctx, 0);\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":414926,"func":" *\/\nvoid\nxmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {\n#ifdef XPATH_STREAMING\n    xmlXPathCompExprPtr comp;\n#endif\n\n    if (ctxt == NULL) return;\n\n#ifdef XPATH_STREAMING\n    comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base);\n    if (comp != NULL) {\n        if (ctxt->comp != NULL)\n\t    xmlXPathFreeCompExpr(ctxt->comp);\n        ctxt->comp = comp;\n\tif (ctxt->cur != NULL)\n\t    while (*ctxt->cur != 0) ctxt->cur++;\n    } else\n#endif\n    {\n\txmlXPathCompileExpr(ctxt, 1);\n\tif ((ctxt->error == XPATH_EXPRESSION_OK) &&\n\t    (ctxt->comp != NULL) &&\n\t    (ctxt->comp->nbStep > 1) &&\n\t    (ctxt->comp->last >= 0))\n\t{\n\t    xmlXPathOptimizeExpression(ctxt->comp,\n\t\t&ctxt->comp->steps[ctxt->comp->last]);\n\t}\n    }\n    CHECK_ERROR;","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":317054,"func":"static inline int opt_len(const char *s)\n{\n\tbool open_quote = false;\n\tint len;\n\tchar c;\n\n\tfor (len = 0; (c = s[len]) != '\\0'; len++) {\n\t\tif (c == '\"')\n\t\t\topen_quote = !open_quote;\n\t\tif (c == ',' && !open_quote)\n\t\t\tbreak;\n\t}\n\treturn len;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":261386,"func":"static int decode_cu_qp_delta_abs(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# cu_qp_delta_abs\\n\");\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &tctx->ctx_model[CONTEXT_MODEL_CU_QP_DELTA_ABS + 0]);\n  if (bit==0) {\n    logtrace(LogSymbols,\"$1 cu_qp_delta_abs=%d\\n\",0);\n    return 0;\n  }\n\n  int prefix=1;\n  for (int i=0;i<4;i++) {\n    bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                           &tctx->ctx_model[CONTEXT_MODEL_CU_QP_DELTA_ABS + 1]);\n    if (bit==0) { break; }\n    else { prefix++; }\n  }\n\n  if (prefix==5) {\n    int value = decode_CABAC_EGk_bypass(&tctx->cabac_decoder, 0);\n    logtrace(LogSymbols,\"$1 cu_qp_delta_abs=%d\\n\",value+5);\n    return value + 5;\n  }\n  else {\n    logtrace(LogSymbols,\"$1 cu_qp_delta_abs=%d\\n\",prefix);\n    return prefix;\n  }\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":244121,"func":"void pcmC_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":359588,"func":"DEFUN (clear_ip_bgp_external,\n       clear_ip_bgp_external_cmd,\n       \"clear ip bgp external\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all external peers\\n\")\n{\n  return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":512687,"func":"  virtual Item_func *get_item_func() { return NULL; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":338226,"func":"Name WasmBinaryBuilder::getNextLabel() {\n  requireFunctionContext(\"getting a label\");\n  return Name(\"label$\" + std::to_string(nextLabel++));\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":274876,"func":"TEST(ComparisonsTest, LessEqualBroadcast) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 1}, TensorType_INT32,\n                          BuiltinOperator_LESS_EQUAL);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3});\n  model.PopulateTensor<int>(model.input2(), {7});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(true, false, true, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":513326,"func":"JOIN::destroy()\n{\n  DBUG_ENTER(\"JOIN::destroy\");\n  select_lex->join= 0;\n\n  cond_equal= 0;\n  having_equal= 0;\n\n  cleanup(1);\n\n  if (join_tab)\n  {\n    for (JOIN_TAB *tab= first_linear_tab(this, WITH_BUSH_ROOTS,\n                                         WITH_CONST_TABLES);\n         tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))\n    {\n      if (tab->aggr)\n      {\n        free_tmp_table(thd, tab->table);\n        delete tab->tmp_table_param;\n        tab->tmp_table_param= NULL;\n        tab->aggr= NULL;\n      }\n      tab->table= NULL;\n    }\n  }\n\n  \/* Cleanup items referencing temporary table columns *\/\n  cleanup_item_list(tmp_all_fields1);\n  cleanup_item_list(tmp_all_fields3);\n  destroy_sj_tmp_tables(this);\n  delete_dynamic(&keyuse); \n  delete procedure;\n  DBUG_RETURN(error);\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":230113,"func":"int user_auth_scheme_module_unload(struct config_module * config) {\n  UNUSED(config);\n  return G_OK;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":430350,"func":"void seq_put_decimal_ull(struct seq_file *m, const char *delimiter,\n\t\t\t unsigned long long num)\n{\n\treturn seq_put_decimal_ull_width(m, delimiter, num, 0);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":222876,"func":"  Status Merge(DimensionHandle d1, DimensionHandle d2) {\n    if (!d1.IsSet() || !d2.IsSet()) {\n      return Status::OK();\n    }\n    return dims_.Merge(d1, d2);\n  }","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":411784,"func":"get_schema (const gchar *name)\n{\n  const char * const *schemas = NULL;\n  gint i;\n\n  schemas = g_settings_list_schemas ();\n  for (i = 0; schemas[i]; i++)\n  {\n    if (!strcmp (schemas[i], name))\n      return g_settings_new (schemas[i]);\n  }\n\n  return NULL;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":289235,"func":"snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tint ret;\n\twhile (1) {\n\t\tif (runtime->status->state == SNDRV_PCM_STATE_XRUN ||\n\t\t    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {\n#ifdef OSS_DEBUG\n\t\t\tpcm_dbg(substream->pcm,\n\t\t\t\t\"pcm_oss: writev: recovering from %s\\n\",\n\t\t\t\truntime->status->state == SNDRV_PCM_STATE_XRUN ?\n\t\t\t\t\"XRUN\" : \"SUSPEND\");\n#endif\n\t\t\tret = snd_pcm_oss_prepare(substream);\n\t\t\tif (ret < 0)\n\t\t\t\tbreak;\n\t\t}\n\t\tret = snd_pcm_kernel_writev(substream, bufs, frames);\n\t\tif (ret != -EPIPE && ret != -ESTRPIPE)\n\t\t\tbreak;\n\n\t\t\/* test, if we can't store new data, because the stream *\/\n\t\t\/* has not been started *\/\n\t\tif (runtime->status->state == SNDRV_PCM_STATE_PREPARED)\n\t\t\treturn -EAGAIN;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":442580,"func":"int memslot_validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id,\n                          uint32_t add_size, uint32_t group_id)\n{\n    MemSlot *slot;\n\n    slot = &info->mem_slots[group_id][slot_id];\n    if ((virt + add_size) < virt) {\n        spice_critical(\"virtual address overlap\");\n        return 0;\n    }\n\n    if (virt < slot->virt_start_addr || (virt + add_size) > slot->virt_end_addr) {\n        print_memslots(info);\n        spice_warning(\"virtual address out of range\"\n              \"    virt=0x%lx+0x%x slot_id=%d group_id=%d\\n\"\n              \"    slot=0x%lx-0x%lx delta=0x%lx\",\n              virt, add_size, slot_id, group_id,\n              slot->virt_start_addr, slot->virt_end_addr, slot->address_delta);\n        return 0;\n    }\n    return 1;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":512943,"func":"  Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):\n    Item_basic_constant(thd)\n  {\n    maybe_null= null_value= TRUE;\n    max_length= 0;\n    name.str= name_par ? name_par : \"NULL\";\n    name.length= strlen(name.str);\n    collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII);\n  }","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":221644,"func":"bool hermes::evalIsTrue(IRBuilder &builder, Literal *operand) {\n  if (auto *lit = evalToBoolean(builder, operand))\n    return lit->getValue();\n  return false;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":427714,"func":"cdf_grow_info(cdf_property_info_t **info, size_t *maxcount, size_t incr)\n{\n\tcdf_property_info_t *inp;\n\tsize_t newcount = *maxcount + incr;\n\n\tif (newcount > CDF_PROP_LIMIT) {\n\t\tDPRINTF((\"exceeded property limit %\" SIZE_T_FORMAT \"u > %\"\n\t\t    SIZE_T_FORMAT \"u\\n\", newcount, CDF_PROP_LIMIT));\n\t\tgoto out;\n\t}\n\tinp = CAST(cdf_property_info_t *,\n\t    CDF_REALLOC(*info, newcount * sizeof(*inp)));\n\tif (inp == NULL)\n\t\tgoto out;\n\n\t*info = inp;\n\t*maxcount = newcount;\n\treturn inp;\nout:\n\tfree(*info);\n\t*maxcount = 0;\n\t*info = NULL;\n\treturn NULL;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":512807,"func":"  const Item_const *get_item_const() const\n  {\n    switch (state) {\n    case SHORT_DATA_VALUE:\n    case LONG_DATA_VALUE:\n    case NULL_VALUE:\n      return this;\n    case IGNORE_VALUE:\n    case DEFAULT_VALUE:\n    case NO_VALUE:\n      break;\n    }\n    return NULL;\n  }","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":366183,"func":"static void free_vfsmnt(struct mount *mnt)\n{\n\tstruct user_namespace *mnt_userns;\n\n\tmnt_userns = mnt_user_ns(&mnt->mnt);\n\tif (mnt_userns != &init_user_ns)\n\t\tput_user_ns(mnt_userns);\n\tkfree_const(mnt->mnt_devname);\n#ifdef CONFIG_SMP\n\tfree_percpu(mnt->mnt_pcp);\n#endif\n\tkmem_cache_free(mnt_cache, mnt);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":269316,"func":"static inline void pred_mv(SnowContext *s, int *mx, int *my, int ref,\n                           const BlockNode *left, const BlockNode *top, const BlockNode *tr){\n    if(s->ref_frames == 1){\n        *mx = mid_pred(left->mx, top->mx, tr->mx);\n        *my = mid_pred(left->my, top->my, tr->my);\n    }else{\n        const int *scale = ff_scale_mv_ref[ref];\n        *mx = mid_pred((left->mx * scale[left->ref] + 128) >>8,\n                       (top ->mx * scale[top ->ref] + 128) >>8,\n                       (tr  ->mx * scale[tr  ->ref] + 128) >>8);\n        *my = mid_pred((left->my * scale[left->ref] + 128) >>8,\n                       (top ->my * scale[top ->ref] + 128) >>8,\n                       (tr  ->my * scale[tr  ->ref] + 128) >>8);\n    }\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":294403,"func":"d_lite_marshal_dump(VALUE self)\n{\n    VALUE a;\n\n    get_d1(self);\n\n    a = rb_ary_new3(6,\n\t\t    m_nth(dat),\n\t\t    INT2FIX(m_jd(dat)),\n\t\t    INT2FIX(m_df(dat)),\n\t\t    m_sf(dat),\n\t\t    INT2FIX(m_of(dat)),\n\t\t    DBL2NUM(m_sg(dat)));\n\n    if (FL_TEST(self, FL_EXIVAR)) {\n\trb_copy_generic_ivar(a, self);\n\tFL_SET(a, FL_EXIVAR);\n    }\n\n    return a;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":466143,"func":"static int em_or(struct x86_emulate_ctxt *ctxt)\n{\n\temulate_2op_SrcV(ctxt, \"or\");\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":500096,"func":"kssl_krb5_kt_resolve(krb5_context con,\n                    krb5_const char * sz,\n                    krb5_keytab * kt)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_kt_resolve )\n\t\treturn(p_krb5_kt_resolve(con,sz,kt));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":277676,"func":"get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n\/* This version is for reading raw-byte-format PPM files with any maxval *\/\n{\n  ppm_source_ptr source = (ppm_source_ptr) sinfo;\n  register JSAMPROW ptr;\n  register U_CHAR * bufferptr;\n  register JSAMPLE *rescale = source->rescale;\n  JDIMENSION col;\n\n  if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))\n    ERREXIT(cinfo, JERR_INPUT_EOF);\n  ptr = source->pub.buffer[0];\n  bufferptr = source->iobuffer;\n  for (col = cinfo->image_width; col > 0; col--) {\n    *ptr++ = rescale[UCH(*bufferptr++)];\n    *ptr++ = rescale[UCH(*bufferptr++)];\n    *ptr++ = rescale[UCH(*bufferptr++)];\n  }\n  return 1;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":227032,"func":"IRC_PROTOCOL_CALLBACK(008)\n{\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (server, argv[2], command, NULL, NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, address),\n        _(\"%sServer notice mask for %s%s%s: %s\"),\n        weechat_prefix (\"network\"),\n        irc_nick_color_for_msg (server, 1, NULL, argv[2]),\n        argv[2],\n        IRC_COLOR_RESET,\n        (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":139221,"func":"ui::Layer* OverlayWindowViews::GetLayer() {\n  return views::Widget::GetLayer();\n}\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":301374,"func":"static int vfswrap_lstat(vfs_handle_struct *handle,\n\t\t\t struct smb_filename *smb_fname)\n{\n\tint result = -1;\n\n\tSTART_PROFILE(syscall_lstat);\n\n\tif (smb_fname->stream_name) {\n\t\terrno = ENOENT;\n\t\tgoto out;\n\t}\n\n\tresult = sys_lstat(smb_fname->base_name, &smb_fname->st,\n\t\t\t   lp_fake_dir_create_times(SNUM(handle->conn)));\n out:\n\tEND_PROFILE(syscall_lstat);\n\treturn result;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":317156,"func":"static int inode_has_perm(const struct cred *cred,\n\t\t\t  struct inode *inode,\n\t\t\t  u32 perms,\n\t\t\t  struct common_audit_data *adp)\n{\n\tstruct inode_security_struct *isec;\n\tu32 sid;\n\n\tvalidate_creds(cred);\n\n\tif (unlikely(IS_PRIVATE(inode)))\n\t\treturn 0;\n\n\tsid = cred_sid(cred);\n\tisec = selinux_inode(inode);\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    sid, isec->sid, isec->sclass, perms, adp);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":300821,"func":"int tipc_nl_sk_dump(struct sk_buff *skb, struct netlink_callback *cb)\n{\n\treturn tipc_nl_sk_walk(skb, cb, __tipc_nl_add_sk);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":244024,"func":"void xtra_box_del(GF_Box *s)\n{\n\tGF_XtraBox *ptr = (GF_XtraBox *)s;\n\twhile (gf_list_count(ptr->tags)) {\n\t\tGF_XtraTag *tag = gf_list_pop_back(ptr->tags);\n\t\tif (tag->name) gf_free(tag->name);\n\t\tif (tag->prop_value) gf_free(tag->prop_value);\n\t\tgf_free(tag);\n\t}\n\tgf_list_del(ptr->tags);\n\tgf_free(s);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":275512,"func":"njs_vm_array_alloc(njs_vm_t *vm, njs_value_t *retval, uint32_t spare)\n{\n    njs_array_t  *array;\n\n    array = njs_array_alloc(vm, 1, 0, spare);\n\n    if (njs_slow_path(array == NULL)) {\n        return NJS_ERROR;\n    }\n\n    njs_set_array(retval, array);\n\n    return NJS_OK;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":445866,"func":"paste_from_archive_list_ready_cb (GObject      *source_object,\n\t\t\t\t  GAsyncResult *result,\n\t\t\t\t  gpointer      user_data)\n{\n\tFrWindow *window = user_data;\n\tGError   *error = NULL;\n\n\tif (! fr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error)) {\n\t\t_paste_from_archive_operation_completed (window, FR_ACTION_PASTING_FILES, error);\n\t\tg_error_free (error);\n\t\treturn;\n\t}\n\n\tfr_archive_action_started (window->priv->copy_from_archive, FR_ACTION_EXTRACTING_FILES);\n\tfr_archive_extract (window->priv->copy_from_archive,\n\t\t\t    window->priv->clipboard_data->files,\n\t\t\t    window->priv->clipboard_data->tmp_dir,\n\t\t\t    NULL,\n\t\t\t    FALSE,\n\t\t\t    TRUE,\n\t\t\t    FALSE,\n\t\t\t    window->priv->clipboard_data->password,\n\t\t\t    window->priv->cancellable,\n\t\t\t    paste_from_archive_extract_ready_cb,\n\t\t\t    window);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":402610,"func":"can_prompt_again(secuPWData *pwdata)\n{\n\tif (pwdata->orig_source == PW_PROMPT)\n\t\treturn true;\n\n\tif (pwdata->source == PW_DEVICE)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":430345,"func":"int single_release(struct inode *inode, struct file *file)\n{\n\tconst struct seq_operations *op = ((struct seq_file *)file->private_data)->op;\n\tint res = seq_release(inode, file);\n\tkfree(op);\n\treturn res;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":312481,"func":"qf_free(qf_list_T *qfl)\n{\n    qf_free_items(qfl);\n\n    VIM_CLEAR(qfl->qf_title);\n    free_tv(qfl->qf_ctx);\n    qfl->qf_ctx = NULL;\n    free_callback(&qfl->qf_qftf_cb);\n    qfl->qf_id = 0;\n    qfl->qf_changedtick = 0L;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":430445,"func":"static int sample_action_to_attr(const struct nlattr *attr,\n\t\t\t\t struct sk_buff *skb)\n{\n\tstruct nlattr *start, *ac_start = NULL, *sample_arg;\n\tint err = 0, rem = nla_len(attr);\n\tconst struct sample_arg *arg;\n\tstruct nlattr *actions;\n\n\tstart = nla_nest_start_noflag(skb, OVS_ACTION_ATTR_SAMPLE);\n\tif (!start)\n\t\treturn -EMSGSIZE;\n\n\tsample_arg = nla_data(attr);\n\targ = nla_data(sample_arg);\n\tactions = nla_next(sample_arg, &rem);\n\n\tif (nla_put_u32(skb, OVS_SAMPLE_ATTR_PROBABILITY, arg->probability)) {\n\t\terr = -EMSGSIZE;\n\t\tgoto out;\n\t}\n\n\tac_start = nla_nest_start_noflag(skb, OVS_SAMPLE_ATTR_ACTIONS);\n\tif (!ac_start) {\n\t\terr = -EMSGSIZE;\n\t\tgoto out;\n\t}\n\n\terr = ovs_nla_put_actions(actions, rem, skb);\n\nout:\n\tif (err) {\n\t\tnla_nest_cancel(skb, ac_start);\n\t\tnla_nest_cancel(skb, start);\n\t} else {\n\t\tnla_nest_end(skb, ac_start);\n\t\tnla_nest_end(skb, start);\n\t}\n\n\treturn err;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":508361,"func":"bool setup_tables_and_check_access(THD *thd, Name_resolution_context *context,\n                                   List<TABLE_LIST> *from_clause,\n                                   TABLE_LIST *tables, List<TABLE_LIST> &leaves,\n                                   bool select_insert, ulong want_access_first,\n                                   ulong want_access, bool full_table_list)\n{\n  DBUG_ENTER(\"setup_tables_and_check_access\");\n\n  if (setup_tables(thd, context, from_clause, tables,\n                   leaves, select_insert, full_table_list))\n    DBUG_RETURN(TRUE);\n\n  List_iterator<TABLE_LIST> ti(leaves);\n  TABLE_LIST *table_list;\n  ulong access= want_access_first;\n  while ((table_list= ti++))\n  {\n    if (table_list->belong_to_view && !table_list->view && \n        check_single_table_access(thd, access, table_list, FALSE))\n    {\n      tables->hide_view_error(thd);\n      DBUG_RETURN(TRUE);\n    }\n    access= want_access;\n  }\n  DBUG_RETURN(FALSE);\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":384800,"func":"gettail(char_u *fname)\n{\n    char_u  *p1, *p2;\n\n    if (fname == NULL)\n\treturn (char_u *)\"\";\n    for (p1 = p2 = get_past_head(fname); *p2; )\t\/\/ find last part of path\n    {\n\tif (vim_ispathsep_nocolon(*p2))\n\t    p1 = p2 + 1;\n\tMB_PTR_ADV(p2);\n    }\n    return p1;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":417119,"func":"mp_int64 PlayerGeneric::getSyncCount() const\n{\n\tif (player)\n\t\treturn player->getSyncCount();\n\t\t\n\treturn 0;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":282877,"func":"int rsi_set_antenna(struct rsi_common *common, u8 antenna)\n{\n\tstruct rsi_ant_sel_frame *ant_sel_frame;\n\tstruct sk_buff *skb;\n\n\tskb = dev_alloc_skb(FRAME_DESC_SZ);\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, FRAME_DESC_SZ);\n\n\tant_sel_frame = (struct rsi_ant_sel_frame *)skb->data;\n\tant_sel_frame->desc_dword0.frame_type = ANT_SEL_FRAME;\n\tant_sel_frame->sub_frame_type = ANTENNA_SEL_TYPE;\n\tant_sel_frame->ant_value = cpu_to_le16(antenna & ANTENNA_MASK_VALUE);\n\trsi_set_len_qno(&ant_sel_frame->desc_dword0.len_qno,\n\t\t\t0, RSI_WIFI_MGMT_Q);\n\tskb_put(skb, FRAME_DESC_SZ);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":359454,"func":"DEFUN (no_bgp_graceful_restart_stalepath_time,\n       no_bgp_graceful_restart_stalepath_time_cmd,\n       \"no bgp graceful-restart stalepath-time\",\n       NO_STR\n       \"BGP specific commands\\n\"\n       \"Graceful restart capability parameters\\n\"\n       \"Set the max time to hold onto restarting peer's stale paths\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  if (! bgp)\n    return CMD_WARNING;\n\n  bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":225689,"func":"void gnrm_box_del(GF_Box *s)\n{\n\tGF_GenericSampleEntryBox *ptr = (GF_GenericSampleEntryBox *)s;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)ptr);\n\tif (ptr->data) gf_free(ptr->data);\n\tgf_free(ptr);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":238469,"func":"static void scrub_spilled_slot(u8 *stype)\n{\n\tif (*stype != STACK_INVALID)\n\t\t*stype = STACK_MISC;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":294445,"func":"date_s__xmlschema(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, opt;\n\n    rb_scan_args(argc, argv, \"1:\", &str, &opt);\n    check_limit(str, opt);\n\n    return date__xmlschema(str);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":310071,"func":"NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_DCL0)\n\/* what to do at initialization time and after each shellout *\/\n{\n    if (!SP_PARM || !IsTermInfo(SP_PARM))\n\treturn;\n\n    \/* initialize screen for cursor access *\/\n    if (enter_ca_mode) {\n\tNCURSES_PUTP2(\"enter_ca_mode\", enter_ca_mode);\n    }\n\n    \/*\n     * Doing this here rather than in _nc_mvcur_wrap() ensures that\n     * ncurses programs will see a reset scroll region even if a\n     * program that messed with it died ungracefully.\n     *\n     * This also undoes the effects of terminal init strings that assume\n     * they know the screen size.  This is useful when you're running\n     * a vt100 emulation through xterm.\n     *\/\n    reset_scroll_region(NCURSES_SP_ARG);\n    SP_PARM->_cursrow = SP_PARM->_curscol = -1;\n\n    \/* restore cursor shape *\/\n    if (SP_PARM->_cursor != -1) {\n\tint cursor = SP_PARM->_cursor;\n\tSP_PARM->_cursor = -1;\n\tNCURSES_SP_NAME(curs_set) (NCURSES_SP_ARGx cursor);\n    }\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":312496,"func":"qf_list_empty(qf_list_T *qfl)\n{\n    return qfl == NULL || qfl->qf_count <= 0;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":238498,"func":"static bool insn_has_def32(struct bpf_verifier_env *env, struct bpf_insn *insn)\n{\n\tint dst_reg = insn_def_regno(insn);\n\n\tif (dst_reg == -1)\n\t\treturn false;\n\n\treturn !is_reg64(env, insn, dst_reg, NULL, DST_OP);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":349887,"func":"void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,\n\t\t\t\t struct hw_atl_utils_mbox *pmbox)\n{\n\tint err = 0;\n\n\terr = hw_atl_utils_fw_downld_dwords(self,\n\t\t\t\t\t    self->mbox_addr,\n\t\t\t\t\t    (u32 *)(void *)pmbox,\n\t\t\t\t\t    sizeof(*pmbox) \/ sizeof(u32));\n\tif (err < 0)\n\t\tgoto err_exit;\n\n\tif (ATL_HW_IS_CHIP_FEATURE(self, REVISION_A0)) {\n\t\tunsigned int mtu = self->aq_nic_cfg ?\n\t\t\t\t\tself->aq_nic_cfg->mtu : 1514U;\n\t\tpmbox->stats.ubrc = pmbox->stats.uprc * mtu;\n\t\tpmbox->stats.ubtc = pmbox->stats.uptc * mtu;\n\t\tpmbox->stats.dpc = atomic_read(&self->dpc);\n\t} else {\n\t\tpmbox->stats.dpc = hw_atl_rpb_rx_dma_drop_pkt_cnt_get(self);\n\t}\n\nerr_exit:;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":248762,"func":"static struct Cookie *dup_cookie(struct Cookie *src)\n{\n  struct Cookie *d = calloc(sizeof(struct Cookie), 1);\n  if(d) {\n    CLONE(expirestr);\n    CLONE(domain);\n    CLONE(path);\n    CLONE(spath);\n    CLONE(name);\n    CLONE(value);\n    CLONE(maxage);\n    CLONE(version);\n    d->expires = src->expires;\n    d->tailmatch = src->tailmatch;\n    d->secure = src->secure;\n    d->livecookie = src->livecookie;\n    d->httponly = src->httponly;\n    d->creationtime = src->creationtime;\n  }\n  return d;\n\n  fail:\n  freecookie(d);\n  return NULL;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":359258,"func":"DEFUN (bgp_bestpath_med2,\n       bgp_bestpath_med2_cmd,\n       \"bgp bestpath med confed missing-as-worst\",\n       \"BGP specific commands\\n\"\n       \"Change the default bestpath selection\\n\"\n       \"MED attribute\\n\"\n       \"Compare MED among confederation paths\\n\"\n       \"Treat missing MED as the least preferred one\\n\")\n{\n  struct bgp *bgp;\n  \n  bgp = vty->index;\n  bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);\n  bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":308203,"func":"static int fastrpc_init(void)\n{\n\tint ret;\n\n\tret = platform_driver_register(&fastrpc_cb_driver);\n\tif (ret < 0) {\n\t\tpr_err(\"fastrpc: failed to register cb driver\\n\");\n\t\treturn ret;\n\t}\n\n\tret = register_rpmsg_driver(&fastrpc_driver);\n\tif (ret < 0) {\n\t\tpr_err(\"fastrpc: failed to register rpmsg driver\\n\");\n\t\tplatform_driver_unregister(&fastrpc_cb_driver);\n\t\treturn ret;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":466155,"func":"static int em_popa(struct x86_emulate_ctxt *ctxt)\n{\n\tint rc = X86EMUL_CONTINUE;\n\tint reg = VCPU_REGS_RDI;\n\n\twhile (reg >= VCPU_REGS_RAX) {\n\t\tif (reg == VCPU_REGS_RSP) {\n\t\t\tregister_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP],\n\t\t\t\t\t\t\tctxt->op_bytes);\n\t\t\t--reg;\n\t\t}\n\n\t\trc = emulate_pop(ctxt, &ctxt->regs[reg], ctxt->op_bytes);\n\t\tif (rc != X86EMUL_CONTINUE)\n\t\t\tbreak;\n\t\t--reg;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":242625,"func":"  bool WouldExceedMemoryLimit(std::size_t bytes) const {\n    return bytes + current_bytes_ > memory_limit_;\n  }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":512665,"func":"void Item_equal::update_used_tables()\n{\n  not_null_tables_cache= used_tables_cache= 0;\n  if ((const_item_cache= cond_false || cond_true))\n    return;\n  Item_equal_fields_iterator it(*this);\n  Item *item;\n  const_item_cache= 1;\n  while ((item= it++))\n  {\n    item->update_used_tables();\n    used_tables_cache|= item->used_tables();\n    \/* see commentary at Item_equal::update_const() *\/\n    const_item_cache&= item->const_item() && !item->is_outer_field();\n  }\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":275506,"func":"njs_vm_prop_magic32(njs_object_prop_t *prop)\n{\n    return prop->value.data.magic32;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":352970,"func":"issuerAndThisUpdateValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tint rc;\n\tstruct berval i, tu;\n\n\tDebug( LDAP_DEBUG_TRACE, \">>> issuerAndThisUpdateValidate: <%s>\\n\",\n\t\tin->bv_val );\n\n\trc = issuerAndThisUpdateCheck( in, &i, &tu, NULL );\n\tif ( rc ) {\n\t\tgoto done;\n\t}\n\n\t\/* validate DN -- doesn't handle double dquote *\/ \n\trc = dnValidate( NULL, &i );\n\tif ( rc ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\n\t} else if ( checkTime( &tu, NULL ) ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) {\n\t\tslap_sl_free( i.bv_val, NULL );\n\t}\n\n\tDebug( LDAP_DEBUG_TRACE, \"<<< issuerAndThisUpdateValidate: <%s> err=%d\\n\",\n\t\tin->bv_val, rc );\n\ndone:;\n\treturn rc;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":274849,"func":"TEST(ComparisonsTest, GreaterEqualQuantized) {\n  const float kMin = -1.f;\n  const float kMax = 128.f;\n  ComparisonOpModel model({TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax},\n                          {TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax},\n                          TensorType_UINT8, BuiltinOperator_GREATER_EQUAL);\n  model.QuantizeAndPopulate<uint8_t>(model.input1(), {1, 9, 7, 3});\n  model.QuantizeAndPopulate<uint8_t>(model.input2(), {1, 2, 6, 5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(true, true, true, false));\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":484755,"func":"static void rx_refill_timeout(struct timer_list *t)\n{\n\tstruct netfront_queue *queue = from_timer(queue, t, rx_refill_timer);\n\tnapi_schedule(&queue->napi);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":450423,"func":"static void framebuffer_update_request(VncState *vs, int incremental,\n                                       int x, int y, int w, int h)\n{\n    if (incremental) {\n        if (vs->update != VNC_STATE_UPDATE_FORCE) {\n            vs->update = VNC_STATE_UPDATE_INCREMENTAL;\n        }\n    } else {\n        vs->update = VNC_STATE_UPDATE_FORCE;\n        vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h);\n    }\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":221074,"func":"OpTypeConstructor UnaryTensorContainer(FullTypeId t, FullTypeId dtype) {\n  return [t, dtype](OpDef* op_def) {\n    FullTypeDef* tdef =\n        op_def->mutable_output_arg(0)->mutable_experimental_full_type();\n    tdef->set_type_id(t);\n\n    FullTypeDef* arg = tdef->add_args();\n    arg->set_type_id(TFT_TENSOR);\n    FullTypeDef* targ = arg->add_args();\n    targ->set_type_id(dtype);\n\n    return Status::OK();\n  };\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":508350,"func":"uint get_table_def_key(const TABLE_LIST *table_list, const char **key)\n{\n  \/*\n    This call relies on the fact that TABLE_LIST::mdl_request::key object\n    is properly initialized, so table definition cache can be produced\n    from key used by MDL subsystem.\n  *\/\n  DBUG_ASSERT(!strcmp(table_list->get_db_name(),\n                      table_list->mdl_request.key.db_name()) &&\n              !strcmp(table_list->get_table_name(),\n                      table_list->mdl_request.key.name()));\n\n  *key= (const char*)table_list->mdl_request.key.ptr() + 1;\n  return table_list->mdl_request.key.length() - 1;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":218996,"func":"void ConstantFolding::ReplaceOperationWithNoOp(NodeDef* node,\n                                               GraphProperties* properties,\n                                               GraphDef* graph) {\n  if (HasRegularOutputs(*node, *node_map_)) return;\n  node->set_op(\"NoOp\");\n  EraseRegularNodeAttributes(node);\n  EraseNodeOutputAttributes(node);\n  \/\/ Erase attributes that describe output properties.\n  properties->ClearOutputProperties(node->name());\n  \/\/ Change all inputs to control dependencies.\n  for (int i = 0; i < node->input_size(); ++i) {\n    if (IsControlInput(node->input(i))) {\n      break;\n    }\n    const string ctrl_dep =\n        AddControlDependency(node->input(i), graph, node_map_.get());\n    node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep);\n    node->set_input(i, ctrl_dep);\n  }\n  DedupControlInputs(node);\n  graph_modified_ = true;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":247638,"func":"TEST_P(SslSocketTest, TicketSessionResumption) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  testTicketSessionResumption(server_ctx_yaml, {}, server_ctx_yaml, {}, client_ctx_yaml, true,\n                              GetParam());\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":512546,"func":"void in_string::set(uint pos,Item *item)\n{\n  String *str=((String*) base)+pos;\n  String *res=item->val_str(str);\n  if (res && res != str)\n  {\n    if (res->uses_buffer_owned_by(str))\n      res->copy();\n    if (item->type() == Item::FUNC_ITEM)\n      str->copy(*res);\n    else\n      *str= *res;\n  }\n  if (!str->charset())\n  {\n    CHARSET_INFO *cs;\n    if (!(cs= item->collation.collation))\n      cs= &my_charset_bin;\t\t\/\/ Should never happen for STR items\n    str->set_charset(cs);\n  }\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":512563,"func":"  const Type_handler *real_type_handler() const\n  { return (*ref)->real_type_handler(); }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":338137,"func":"void WasmBinaryBuilder::visitNop(Nop* curr) { BYN_TRACE(\"zz node: Nop\\n\"); }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":488413,"func":"void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,\n\t\t\t\tunsigned long address)\n{\n\tpte_t *ptep, pte;\n\tspinlock_t *ptl;\n\tswp_entry_t entry;\n\tstruct page *page;\n\n\tptep = pte_offset_map_lock(mm, pmd, address, &ptl);\n\tpte = *ptep;\n\tif (!is_swap_pte(pte))\n\t\tgoto out;\n\n\tentry = pte_to_swp_entry(pte);\n\tif (!is_migration_entry(entry))\n\t\tgoto out;\n\n\tpage = migration_entry_to_page(entry);\n\n\tget_page(page);\n\tpte_unmap_unlock(ptep, ptl);\n\twait_on_page_locked(page);\n\tput_page(page);\n\treturn;\nout:\n\tpte_unmap_unlock(ptep, ptl);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":224462,"func":"static GF_Err swf_svg_add_iso_sample(void *user, const u8 *data, u32 length, u64 timestamp, Bool isRap)\n{\n\tGF_FilterPacket *pck;\n\tu8 *pck_data;\n\tGF_TXTIn *ctx = (GF_TXTIn *)user;\n\n\tif (ctx->seek_state==2) {\n\t\tDouble ts = (Double) timestamp;\n\t\tts\/=1000;\n\t\tif (ts<ctx->start_range) return GF_OK;\n\t\tctx->seek_state = 0;\n\t}\n\n\tpck = gf_filter_pck_new_alloc(ctx->opid, length, &pck_data);\n\tif (pck) {\n\t\tmemcpy(pck_data, data, length);\n\t\tgf_filter_pck_set_cts(pck, (u64) (ctx->timescale*timestamp\/1000) );\n\t\tgf_filter_pck_set_sap(pck, isRap ? GF_FILTER_SAP_1 : GF_FILTER_SAP_NONE);\n\t\tgf_filter_pck_set_framing(pck, GF_TRUE, GF_FALSE);\n\n\t\tgf_filter_pck_send(pck);\n\t}\n\n\tif (gf_filter_pid_would_block(ctx->opid))\n\t\tctx->do_suspend = GF_TRUE;\n\treturn GF_OK;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":232939,"func":"new_unencoding_writer(struct Curl_easy *data,\n                      const struct content_encoding *handler,\n                      struct contenc_writer *downstream)\n{\n  size_t sz = offsetof(struct contenc_writer, params) + handler->paramsize;\n  struct contenc_writer *writer = (struct contenc_writer *)calloc(1, sz);\n\n  if(writer) {\n    writer->handler = handler;\n    writer->downstream = downstream;\n    if(handler->init_writer(data, writer)) {\n      free(writer);\n      writer = NULL;\n    }\n  }\n\n  return writer;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":384828,"func":"rem_backslash(char_u *str)\n{\n#ifdef BACKSLASH_IN_FILENAME\n    return (str[0] == '\\\\'\n\t    && str[1] < 0x80\n\t    && (str[1] == ' '\n\t\t|| (str[1] != NUL\n\t\t    && str[1] != '*'\n\t\t    && str[1] != '?'\n\t\t    && !vim_isfilec(str[1]))));\n#else\n    return (str[0] == '\\\\' && str[1] != NUL);\n#endif\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":310026,"func":"_nc_retrace_void_ptr(void *code)\n{\n    T((T_RETURN(\"%p\"), code));\n    return code;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":273398,"func":"  explicit LSTMBlockCellOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"forget_bias\", &forget_bias_));\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"cell_clip\", &cell_clip_));\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"use_peephole\", &use_peephole_));\n  }","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":226178,"func":"GF_Err moov_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":312440,"func":"qf_win_pos_update(\n    qf_info_T\t*qi,\n    int\t\told_qf_index)\t\/\/ previous qf_index or zero\n{\n    win_T\t*win;\n    int\t\tqf_index = qf_get_curlist(qi)->qf_index;\n\n    \/\/ Put the cursor on the current error in the quickfix window, so that\n    \/\/ it's viewable.\n    win = qf_find_win(qi);\n    if (win != NULL\n\t    && qf_index <= win->w_buffer->b_ml.ml_line_count\n\t    && old_qf_index != qf_index)\n    {\n\tif (qf_index > old_qf_index)\n\t{\n\t    win->w_redraw_top = old_qf_index;\n\t    win->w_redraw_bot = qf_index;\n\t}\n\telse\n\t{\n\t    win->w_redraw_top = qf_index;\n\t    win->w_redraw_bot = old_qf_index;\n\t}\n\tqf_win_goto(win, qf_index);\n    }\n    return win != NULL;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":462278,"func":"static pj_status_t decode_errcode_attr(pj_pool_t *pool, \n\t\t\t\t       const pj_uint8_t *buf,\n\t\t\t\t       const pj_stun_msg_hdr *msghdr, \n\t\t\t\t       void **p_attr)\n{\n    pj_stun_errcode_attr *attr;\n    pj_str_t value;\n\n    PJ_UNUSED_ARG(msghdr);\n\n    \/* Create the attribute *\/\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_errcode_attr);\n    GETATTRHDR(buf, &attr->hdr);\n\n    attr->err_code = buf[6] * 100 + buf[7];\n\n    \/* Get pointer to the string in the message *\/\n    value.ptr = ((char*)buf + ATTR_HDR_LEN + 4);\n    value.slen = attr->hdr.length - 4;\n    \/* Make sure the length is never negative *\/\n    if (value.slen < 0)\n    \tvalue.slen = 0;\n\n    \/* Copy the string to the attribute *\/\n    pj_strdup(pool, &attr->reason, &value);\n\n    \/* Done *\/\n    *p_attr = attr;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":90223,"func":"  virtual const WifiNetworkVector& remembered_wifi_networks() const {\n    return wifi_networks_;\n  }\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":307840,"func":"ciInstance* ciEnv::unloaded_ciinstance() {\n  GUARDED_VM_ENTRY(return _factory->get_unloaded_object_constant();)\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":218997,"func":"static Status PutValueIntoTensor(const int64_t value, const DataType& type,\n                                 const int index, Tensor* tensor) {\n  if (type == DT_INT32) {\n    if (value >= INT_MAX) {\n      return Status(error::INVALID_ARGUMENT, \"int32 overflow\");\n    }\n    tensor->flat<int32>()(index) = static_cast<int32>(value);\n  } else {\n    tensor->flat<int64_t>()(index) = value;\n  }\n  return Status::OK();\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":384848,"func":"lbr_chartabsize(\n    char_u\t\t*line UNUSED, \/\/ start of the line\n    unsigned char\t*s,\n    colnr_T\t\tcol)\n{\n#ifdef FEAT_LINEBREAK\n    if (!curwin->w_p_lbr && *get_showbreak_value(curwin) == NUL\n\t\t\t\t\t\t\t   && !curwin->w_p_bri)\n    {\n#endif\n\tif (curwin->w_p_wrap)\n\t    return win_nolbr_chartabsize(curwin, s, col, NULL);\n\tRET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)\n#ifdef FEAT_LINEBREAK\n    }\n    return win_lbr_chartabsize(curwin, line == NULL ? s : line, s, col, NULL);\n#endif\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":238474,"func":"static int __check_ptr_off_reg(struct bpf_verifier_env *env,\n\t\t\t       const struct bpf_reg_state *reg, int regno,\n\t\t\t       bool fixed_off_ok)\n{\n\t\/* Access to this pointer-typed register or passing it to a helper\n\t * is only allowed in its original, unmodified form.\n\t *\/\n\n\tif (!fixed_off_ok && reg->off) {\n\t\tverbose(env, \"dereference of modified %s ptr R%d off=%d disallowed\\n\",\n\t\t\treg_type_str(env, reg->type), regno, reg->off);\n\t\treturn -EACCES;\n\t}\n\n\tif (!tnum_is_const(reg->var_off) || reg->var_off.value) {\n\t\tchar tn_buf[48];\n\n\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);\n\t\tverbose(env, \"variable %s access var_off=%s disallowed\\n\",\n\t\t\treg_type_str(env, reg->type), tn_buf);\n\t\treturn -EACCES;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":261954,"func":"njs_string_prototype_to_utf8(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    njs_int_t          ret;\n    njs_slice_prop_t   slice;\n    njs_string_prop_t  string;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    (void) njs_string_prop(&string, njs_argument(args, 0));\n\n    string.length = 0;\n    slice.string_length = string.size;\n\n    ret = njs_string_slice_args(vm, &slice, args, nargs);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    return njs_string_slice(vm, &vm->retval, &string, &slice);\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":220432,"func":"mrb_ary_concat_m(mrb_state *mrb, mrb_value self)\n{\n  mrb_value ary;\n\n  mrb_get_args(mrb, \"A\", &ary);\n  mrb_ary_concat(mrb, self, ary);\n  return self;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":448538,"func":"int bgp_nlri_parse(struct peer *peer, struct attr *attr,\n\t\t   struct bgp_nlri *packet, int mp_withdraw)\n{\n\tswitch (packet->safi) {\n\tcase SAFI_UNICAST:\n\tcase SAFI_MULTICAST:\n\t\treturn bgp_nlri_parse_ip(peer, mp_withdraw ? NULL : attr,\n\t\t\t\t\t packet);\n\tcase SAFI_LABELED_UNICAST:\n\t\treturn bgp_nlri_parse_label(peer, mp_withdraw ? NULL : attr,\n\t\t\t\t\t    packet);\n\tcase SAFI_MPLS_VPN:\n\t\treturn bgp_nlri_parse_vpn(peer, mp_withdraw ? NULL : attr,\n\t\t\t\t\t  packet);\n\tcase SAFI_EVPN:\n\t\treturn bgp_nlri_parse_evpn(peer, attr, packet, mp_withdraw);\n\tcase SAFI_FLOWSPEC:\n\t\treturn bgp_nlri_parse_flowspec(peer, attr, packet, mp_withdraw);\n\t}\n\treturn BGP_NLRI_PARSE_ERROR;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":516237,"func":"static bool virtio_net_can_receive(NetClientState *nc)\n{\n    VirtIONet *n = qemu_get_nic_opaque(nc);\n    VirtIODevice *vdev = VIRTIO_DEVICE(n);\n    VirtIONetQueue *q = virtio_net_get_subqueue(nc);\n\n    if (!vdev->vm_running) {\n        return false;\n    }\n\n    if (nc->queue_index >= n->curr_queues) {\n        return false;\n    }\n\n    if (!virtio_queue_ready(q->rx_vq) ||\n        !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {\n        return false;\n    }\n\n    return true;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":307870,"func":"ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) {\n  \/\/ For the case of <array>.clone(), the method holder can be a ciArrayKlass\n  \/\/ instead of a ciInstanceKlass.  For that case simply pretend that the\n  \/\/ declared holder is Object.clone since that's where the call will bottom out.\n  \/\/ A more correct fix would trickle out through many interfaces in CI,\n  \/\/ requiring ciInstanceKlass* to become ciKlass* and many more places would\n  \/\/ require checks to make sure the expected type was found.  Given that this\n  \/\/ only occurs for clone() the more extensive fix seems like overkill so\n  \/\/ instead we simply smear the array type into Object.\n  guarantee(method_holder != NULL, \"no method holder\");\n  if (method_holder->is_instance_klass()) {\n    return method_holder->as_instance_klass();\n  } else if (method_holder->is_array_klass()) {\n    return current()->Object_klass();\n  } else {\n    ShouldNotReachHere();\n  }\n  return NULL;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":221517,"func":"flatpak_run_parse_pulse_server (const char *value)\n{\n  g_auto(GStrv) servers = g_strsplit (value, \" \", 0);\n  gsize i;\n\n  for (i = 0; servers[i] != NULL; i++)\n    {\n      const char *server = servers[i];\n      if (g_str_has_prefix (server, \"{\"))\n        {\n          const char * closing = strstr (server, \"}\");\n          if (closing == NULL)\n            continue;\n          server = closing + 1;\n        }\n      if (g_str_has_prefix (server, \"unix:\"))\n        return g_strdup (server + 5);\n    }\n\n  return NULL;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":383306,"func":"gdAlphaOverlayColor( int src, int dst, int max )\n{\n\t\/* this function implements the algorithm\n\t * \n\t * for dst[rgb] < 0.5,\n\t *   c[rgb] = 2.src[rgb].dst[rgb]\n\t * and for dst[rgb] > 0.5,\n\t *   c[rgb] = -2.src[rgb].dst[rgb] + 2.dst[rgb] + 2.src[rgb] - 1\n\t *   \n\t *\/\n\n\tdst = dst << 1;\n\tif( dst > max ) {\n\t\t\/* in the \"light\" zone *\/\n\t\treturn dst + (src << 1) - (dst * src \/ max) - max;\n\t} else {\n\t\t\/* in the \"dark\" zone *\/\n\t\treturn dst * src \/ max;\n\t}\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":359527,"func":"DEFUN (no_neighbor_shutdown,\n       no_neighbor_shutdown_cmd,\n       NO_NEIGHBOR_CMD2 \"shutdown\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Administratively shut down this neighbor\\n\")\n{\n  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":312527,"func":"copy_nonerror_line(char_u *linebuf, int linelen, qffields_T *fields)\n{\n    char_u\t*p;\n\n    if (linelen >= fields->errmsglen)\n    {\n\t\/\/ linelen + null terminator\n\tif ((p = vim_realloc(fields->errmsg, linelen + 1)) == NULL)\n\t    return QF_NOMEM;\n\tfields->errmsg = p;\n\tfields->errmsglen = linelen + 1;\n    }\n    \/\/ copy whole line to error message\n    vim_strncpy(fields->errmsg, linebuf, linelen);\n\n    return QF_OK;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":252345,"func":"static unsigned int readUInt(const char buf[4]) {\n  const unsigned char *b = (const unsigned char *)buf;\n\n  return (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) |\n         ((b[2] << 16) & 0x00ff0000) | ((b[3] << 24) & 0xff000000);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":90865,"func":"  QuotaManagerTest()\n      : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),\n        mock_time_counter_(0) {\n  }\n","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":309969,"func":"_nc_mouse_init(SCREEN *sp)\n\/* initialize the mouse *\/\n{\n    bool result = FALSE;\n\n    if (sp != 0) {\n\tif (!sp->_mouse_initialized) {\n\t    int i;\n\n\t    sp->_mouse_initialized = TRUE;\n\n\t    TR(MY_TRACE, (\"_nc_mouse_init() called\"));\n\n\t    sp->_mouse_eventp = FirstEV(sp);\n\t    for (i = 0; i < EV_MAX; i++)\n\t\tInvalidate(sp->_mouse_events + i);\n\n\t    initialize_mousetype(sp);\n\n\t    T((\"_nc_mouse_init() set mousetype to %d\", sp->_mouse_type));\n\t}\n\tresult = sp->_mouse_initialized;\n    }\n    return result;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":430341,"func":"ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)\n{\n\tstruct iovec iov = { .iov_base = buf, .iov_len = size};\n\tstruct kiocb kiocb;\n\tstruct iov_iter iter;\n\tssize_t ret;\n\n\tinit_sync_kiocb(&kiocb, file);\n\tiov_iter_init(&iter, READ, &iov, 1, size);\n\n\tkiocb.ki_pos = *ppos;\n\tret = seq_read_iter(&kiocb, &iter);\n\t*ppos = kiocb.ki_pos;\n\treturn ret;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":487615,"func":"void kernel_halt(void)\n{\n\tkernel_shutdown_prepare(SYSTEM_HALT);\n\tprintk(KERN_EMERG \"System halted.\\n\");\n\tmachine_halt();\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":225400,"func":"static int vidioc_enum_fmt_cap(struct file *file, void *fh,\n\t\t\t       struct v4l2_fmtdesc *f)\n{\n\tstruct v4l2_loopback_device *dev;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\n\tif (f->index)\n\t\treturn -EINVAL;\n\tif (dev->ready_for_capture) {\n\t\tconst __u32 format = dev->pix_format.pixelformat;\n\n\t\tsnprintf(f->description, sizeof(f->description), \"[%c%c%c%c]\",\n\t\t\t (format >> 0) & 0xFF, (format >> 8) & 0xFF,\n\t\t\t (format >> 16) & 0xFF, (format >> 24) & 0xFF);\n\n\t\tf->pixelformat = dev->pix_format.pixelformat;\n\t} else {\n\t\treturn -EINVAL;\n\t}\n\tf->flags = 0;\n\tMARK();\n\treturn 0;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":389733,"func":"check_for_string_or_dict_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_STRING && args[idx].v_type != VAR_DICT)\n    {\n\tsemsg(_(e_string_or_dict_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":226113,"func":"\nGF_Err sbgp_box_size(GF_Box *s)\n{\n\tGF_SampleGroupBox *p = (GF_SampleGroupBox*)s;\n\n\tp->size += 8;\n\tif (p->grouping_type_parameter) p->version=1;\n\n\tif (p->version==1) p->size += 4;\n\tp->size += 8*p->entry_count;\n\treturn GF_OK;","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":372349,"func":"void sdb_show_bp()\n{\n  for(int i=0; i<7;i++)\n    if (sdb_lines[i]!= -1)\n      Print(\"Breakpoint %d: %s::%d\\n\",i+1,sdb_files[i],sdb_lines[i]);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":512440,"func":"double Item_func_case::real_op()\n{\n  DBUG_ASSERT(fixed == 1);\n  Item *item= find_item();\n  double res;\n\n  if (!item)\n  {\n    null_value=1;\n    return 0;\n  }\n  res= item->val_real();\n  null_value=item->null_value;\n  return res;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":512720,"func":"void Item_func_if::fix_after_pullout(st_select_lex *new_parent,\n                                     Item **ref, bool merge)\n{\n  \/* This will re-calculate attributes of the arguments *\/\n  Item_func::fix_after_pullout(new_parent, ref, merge);\n  \/* Then, re-calculate not_null_tables_cache according to our special rules *\/\n  eval_not_null_tables(NULL);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":243001,"func":"static void ssl_build_record_nonce( unsigned char *dst_iv,\n                                    size_t dst_iv_len,\n                                    unsigned char const *fixed_iv,\n                                    size_t fixed_iv_len,\n                                    unsigned char const *dynamic_iv,\n                                    size_t dynamic_iv_len )\n{\n    size_t i;\n\n    \/* Start with Fixed IV || 0 *\/\n    memset( dst_iv, 0, dst_iv_len );\n    memcpy( dst_iv, fixed_iv, fixed_iv_len );\n\n    dst_iv += dst_iv_len - dynamic_iv_len;\n    for( i = 0; i < dynamic_iv_len; i++ )\n        dst_iv[i] ^= dynamic_iv[i];\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":522322,"func":"static void RecWrd(GmfMshSct *msh, const void *wrd)\n{\n   \/\/ [Bruno] added error control\n#ifdef WITH_GMF_AIO\n   if(write(msh->FilDes, wrd, WrdSiz) != WrdSiz)\n#else\n   if(fwrite(wrd, WrdSiz, 1, msh->hdl) != 1)\n#endif\n      longjmp(msh->err,-28);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":379667,"func":"static RAnalVar *get_stack_var(RAnalFunction *fcn, int delta) {\n\tvoid **it;\n\tr_pvector_foreach (&fcn->vars, it) {\n\t\tRAnalVar *var = *it;\n\t\tbool is_stack = var->kind == R_ANAL_VAR_KIND_SPV || var->kind == R_ANAL_VAR_KIND_BPV;\n\t\tif (is_stack && var->delta == delta) {\n\t\t\treturn var;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":401483,"func":"int wait_for_random_bytes(void)\n{\n\tif (likely(crng_ready()))\n\t\treturn 0;\n\n\tdo {\n\t\tint ret;\n\t\tret = wait_event_interruptible_timeout(crng_init_wait, crng_ready(), HZ);\n\t\tif (ret)\n\t\t\treturn ret > 0 ? 0 : ret;\n\n\t\ttry_to_generate_entropy();\n\t} while (!crng_ready());\n\n\treturn 0;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":437699,"func":"static int cx23888_ir_tx_shutdown(struct v4l2_subdev *sd)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tstruct cx23885_dev *dev = state->dev;\n\n\tmutex_lock(&state->tx_params_lock);\n\n\t\/* Disable or slow down all IR Tx circuits and counters *\/\n\tirqenable_tx(dev, 0);\n\tcontrol_tx_enable(dev, false);\n\tcontrol_tx_modulation_enable(dev, false);\n\tcx23888_ir_write4(dev, CX23888_IR_TXCLK_REG, TXCLK_TCD);\n\n\tstate->tx_params.shutdown = true;\n\n\tmutex_unlock(&state->tx_params_lock);\n\treturn 0;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":223402,"func":"static SLJIT_INLINE BOOL assert_needs_str_ptr_saving(PCRE2_SPTR cc)\n{\nwhile (TRUE)\n  {\n  switch (*cc)\n    {\n    case OP_CALLOUT_STR:\n    cc += GET(cc, 1 + 2*LINK_SIZE);\n    break;\n\n    case OP_NOT_WORD_BOUNDARY:\n    case OP_WORD_BOUNDARY:\n    case OP_CIRC:\n    case OP_CIRCM:\n    case OP_DOLL:\n    case OP_DOLLM:\n    case OP_CALLOUT:\n    case OP_ALT:\n    cc += PRIV(OP_lengths)[*cc];\n    break;\n\n    case OP_KET:\n    return FALSE;\n\n    default:\n    return TRUE;\n    }\n  }\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":512288,"func":"Item_func_if::eval_not_null_tables(void *opt_arg)\n{\n  if (Item_func::eval_not_null_tables(NULL))\n    return 1;\n\n  not_null_tables_cache= (args[1]->not_null_tables() &\n                          args[2]->not_null_tables());\n\n  return 0;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":468329,"func":"on_connected_cancelled (GObject      *source_object,\n                        GAsyncResult *result,\n                        gpointer      user_data)\n{\n  GSocketConnection *conn;\n  GError *error = NULL;\n\n  conn = g_socket_client_connect_to_uri_finish (G_SOCKET_CLIENT (source_object), result, &error);\n  g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);\n  g_assert_null (conn);\n\n  g_error_free (error);\n  g_main_loop_quit (user_data);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":387720,"func":"Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) {\n  if (name == NULL) {\n    return NULL;\n  } else {\n    if (name->utf8_length() <= 0) {\n      return NULL;\n    }\n    ResourceMark rm;\n    const char* package_name = ClassLoader::package_from_name((const char*) name->as_C_string());\n    if (package_name == NULL) {\n      return NULL;\n    }\n    Symbol* pkg_name = SymbolTable::new_symbol(package_name, THREAD);\n    return pkg_name;\n  }\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":256986,"func":"static void route4_queue_work(struct route4_filter *f)\n{\n\ttcf_queue_work(&f->rwork, route4_delete_filter_work);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":412101,"func":"respip_addr_lookup(const struct reply_info *rep, struct rbtree_type* iptree,\n\tsize_t* rrset_id)\n{\n\tsize_t i;\n\tstruct resp_addr* ra;\n\tstruct sockaddr_storage ss;\n\tsocklen_t addrlen;\n\n\tfor(i=0; i<rep->an_numrrsets; i++) {\n\t\tsize_t j;\n\t\tconst struct packed_rrset_data* rd;\n\t\tuint16_t rtype = ntohs(rep->rrsets[i]->rk.type);\n\n\t\tif(rtype != LDNS_RR_TYPE_A && rtype != LDNS_RR_TYPE_AAAA)\n\t\t\tcontinue;\n\t\trd = rep->rrsets[i]->entry.data;\n\t\tfor(j = 0; j < rd->count; j++) {\n\t\t\tif(!rdata2sockaddr(rd, rtype, j, &ss, &addrlen))\n\t\t\t\tcontinue;\n\t\t\tra = (struct resp_addr*)addr_tree_lookup(iptree, &ss,\n\t\t\t\taddrlen);\n\t\t\tif(ra) {\n\t\t\t\t*rrset_id = i;\n\t\t\t\treturn ra;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":259175,"func":"static int mov_read_pitm(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    avio_rb32(pb);  \/\/ version & flags.\n    c->primary_item_id = avio_rb16(pb);\n    return atom.size;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":483494,"func":"static int __init __find_uefi_params(unsigned long node,\n\t\t\t\t     struct param_info *info,\n\t\t\t\t     struct params *params)\n{\n\tconst void *prop;\n\tvoid *dest;\n\tu64 val;\n\tint i, len;\n\n\tfor (i = 0; i < EFI_FDT_PARAMS_SIZE; i++) {\n\t\tprop = of_get_flat_dt_prop(node, params[i].propname, &len);\n\t\tif (!prop) {\n\t\t\tinfo->missing = params[i].name;\n\t\t\treturn 0;\n\t\t}\n\n\t\tdest = info->params + params[i].offset;\n\t\tinfo->found++;\n\n\t\tval = of_read_number(prop, len \/ sizeof(u32));\n\n\t\tif (params[i].size == sizeof(u32))\n\t\t\t*(u32 *)dest = val;\n\t\telse\n\t\t\t*(u64 *)dest = val;\n\n\t\tif (efi_enabled(EFI_DBG))\n\t\t\tpr_info(\"  %s: 0x%0*llx\\n\", params[i].name,\n\t\t\t\tparams[i].size * 2, val);\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":512334,"func":"void Item_func_in::mark_as_condition_AND_part(TABLE_LIST *embedding)\n{\n  THD *thd= current_thd;\n\n  Query_arena *arena, backup;\n  arena= thd->activate_stmt_arena_if_needed(&backup);\n\n  if (!transform_into_subq_checked)\n  {\n    if ((transform_into_subq= to_be_transformed_into_in_subq(thd)))\n      thd->lex->current_select->in_funcs.push_back(this, thd->mem_root);\n    transform_into_subq_checked= true;\n  }\n\n  if (arena)\n    thd->restore_active_arena(arena, &backup);\n\n  emb_on_expr_nest= embedding;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":238414,"func":"static void __mark_reg_unknown(const struct bpf_verifier_env *env,\n\t\t\t       struct bpf_reg_state *reg)\n{\n\t\/*\n\t * Clear type, id, off, and union(map_ptr, range) and\n\t * padding between 'type' and union\n\t *\/\n\tmemset(reg, 0, offsetof(struct bpf_reg_state, var_off));\n\treg->type = SCALAR_VALUE;\n\treg->var_off = tnum_unknown;\n\treg->frameno = 0;\n\treg->precise = env->subprog_cnt > 1 || !env->bpf_capable;\n\t__mark_reg_unbounded(reg);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":355648,"func":"eval_to_string_safe(\n    char_u\t*arg,\n    int\t\tuse_sandbox,\n    int\t\tkeep_script_version)\n{\n    char_u\t*retval;\n    funccal_entry_T funccal_entry;\n    int\t\tsave_sc_version = current_sctx.sc_version;\n    int\t\tsave_garbage = may_garbage_collect;\n\n    if (!keep_script_version)\n\tcurrent_sctx.sc_version = 1;\n    save_funccal(&funccal_entry);\n    if (use_sandbox)\n\t++sandbox;\n    ++textwinlock;\n    may_garbage_collect = FALSE;\n    retval = eval_to_string(arg, FALSE);\n    if (use_sandbox)\n\t--sandbox;\n    --textwinlock;\n    may_garbage_collect = save_garbage;\n    restore_funccal();\n    current_sctx.sc_version = save_sc_version;\n    return retval;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":344239,"func":"lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) {\n  lua_Number r;\n  luai_nummod(L, m, n, r);\n  return r;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":221646,"func":"bool hermes::evalIsFalse(IRBuilder &builder, Literal *operand) {\n  if (auto *lit = evalToBoolean(builder, operand))\n    return !lit->getValue();\n  return false;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":448911,"func":"unsigned long ZEXPORT inflateCodesUsed(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n    if (inflateStateCheck(strm)) return (unsigned long)-1;\n    state = (struct inflate_state FAR *)strm->state;\n    return (unsigned long)(state->next - state->codes);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":231669,"func":"void updateWritableByteLimitOnRecvPacket(QuicServerConnectionState& conn) {\n  \/\/ When we receive a packet we increase the limit again. The reasoning this is\n  \/\/ that a peer can do the same by opening a new connection.\n  if (conn.writableBytesLimit) {\n    conn.writableBytesLimit = *conn.writableBytesLimit +\n        conn.transportSettings.limitedCwndInMss * conn.udpSendPacketLen;\n  }\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":221394,"func":"static bool nested_vmcb_check_cr3_cr4(struct kvm_vcpu *vcpu,\n\t\t\t\t      struct vmcb_save_area *save)\n{\n\t\/*\n\t * These checks are also performed by KVM_SET_SREGS,\n\t * except that EFER.LMA is not checked by SVM against\n\t * CR0.PG && EFER.LME.\n\t *\/\n\tif ((save->efer & EFER_LME) && (save->cr0 & X86_CR0_PG)) {\n\t\tif (CC(!(save->cr4 & X86_CR4_PAE)) ||\n\t\t    CC(!(save->cr0 & X86_CR0_PE)) ||\n\t\t    CC(kvm_vcpu_is_illegal_gpa(vcpu, save->cr3)))\n\t\t\treturn false;\n\t}\n\n\tif (CC(!kvm_is_valid_cr4(vcpu, save->cr4)))\n\t\treturn false;\n\n\treturn true;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":473851,"func":"st_init_table_with_size(const struct st_hash_type *type, st_index_t size)\n{\n    st_table *tbl;\n\n#ifdef HASH_LOG\n# if HASH_LOG+0 < 0\n    {\n\tconst char *e = getenv(\"ST_HASH_LOG\");\n\tif (!e || !*e) init_st = 1;\n    }\n# endif\n    if (init_st == 0) {\n\tinit_st = 1;\n\tatexit(stat_col);\n    }\n#endif\n\n    size = new_size(size);\t\/* round up to prime number *\/\n\n    tbl = alloc(st_table);\n    tbl->type = type;\n    tbl->num_entries = 0;\n    tbl->entries_packed = type == &type_numhash && size\/2 <= MAX_PACKED_NUMHASH;\n    tbl->num_bins = size;\n    tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*));\n    tbl->head = 0;\n    tbl->tail = 0;\n\n    return tbl;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":229293,"func":"    virtual void visit(const messages::result_message::schema_change& m) override {\n        auto change = m.get_change();\n        switch (change->type) {\n        case event::event_type::SCHEMA_CHANGE: {\n            auto sc = static_pointer_cast<event::schema_change>(change);\n            _response.write_int(0x0005);\n            _response.serialize(*sc, _version);\n            break;\n        }\n        default:\n            assert(0);\n        }\n    }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":445888,"func":"open_files_extract_ready_cb (GObject      *source_object,\n\t\t\t     GAsyncResult *result,\n\t\t\t     gpointer      user_data)\n{\n\tOpenFilesData *odata = user_data;\n\tGError        *error = NULL;\n\n\topen_files_data_ref (odata);\n\tfr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error);\n\t_archive_operation_completed (odata->window, FR_ACTION_EXTRACTING_FILES, error);\n\n\tif (error == NULL)\n\t\tfr_window_open_extracted_files (odata);\n\n\topen_files_data_unref (odata);\n\t_g_error_free (error);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":257698,"func":"static int wstunnel_check_request(request_st * const r, handler_ctx * const hctx) {\n    const buffer * const vers =\n      http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN(\"Sec-WebSocket-Version\"));\n    const long hybivers = (NULL != vers)\n      ? light_isdigit(*vers->ptr) ? strtol(vers->ptr, NULL, 10) : -1\n      : 0;\n    if (hybivers < 0 || hybivers > INT_MAX) {\n        DEBUG_LOG_ERR(\"%s\", \"invalid Sec-WebSocket-Version\");\n        r->http_status = 400; \/* Bad Request *\/\n        return -1;\n    }\n\n    \/*(redundant since HTTP\/1.1 required in mod_wstunnel_check_extension())*\/\n    if (!r->http_host || buffer_is_blank(r->http_host)) {\n        DEBUG_LOG_ERR(\"%s\", \"Host header does not exist\");\n        r->http_status = 400; \/* Bad Request *\/\n        return -1;\n    }\n\n    if (!wstunnel_is_allowed_origin(r, hctx)) {\n        return -1;\n    }\n\n    return (int)hybivers;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":473961,"func":"code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED)\n{\n  if      ((code & 0xffffff80) == 0) return 1;\n  else if ((code & 0xfffff800) == 0) return 2;\n  else if ((code & 0xffff0000) == 0) return 3;\n  else if ((code & 0xffe00000) == 0) return 4;\n  else if ((code & 0xfc000000) == 0) return 5;\n  else if ((code & 0x80000000) == 0) return 6;\n#ifdef USE_INVALID_CODE_SCHEME\n  else if (code == INVALID_CODE_FE) return 1;\n  else if (code == INVALID_CODE_FF) return 1;\n#endif\n  else\n    return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":411940,"func":"is_anon_tgs_request_p(const KDC_REQ_BODY *b,\n\t\t      const EncTicketPart *tgt)\n{\n    KDCOptions f = b->kdc_options;\n\n    \/*\n     * Versions of Heimdal from 1.0 to 7.6, inclusive, send both the\n     * request-anonymous and cname-in-addl-tkt flags for constrained\n     * delegation requests. A true anonymous TGS request will only\n     * have the request-anonymous flag set. (A corollary of this is\n     * that it is not possible to support anonymous constrained\n     * delegation requests, although they would be of limited utility.)\n     *\/\n    return tgt->flags.anonymous ||\n\t(f.request_anonymous && !f.cname_in_addl_tkt && !b->additional_tickets);\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":401532,"func":"void add_input_randomness(unsigned int type, unsigned int code,\n\t\t\t\t unsigned int value)\n{\n\tstatic unsigned char last_value;\n\n\t\/* ignore autorepeat and the like *\/\n\tif (value == last_value)\n\t\treturn;\n\n\tlast_value = value;\n\tadd_timer_randomness(&input_timer_state,\n\t\t\t     (type << 4) ^ code ^ (code >> 4) ^ value);\n\ttrace_add_input_randomness(ENTROPY_BITS(&input_pool));\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":329927,"func":"_cairo_image_compositor_reset_static_data (void)\n{\n    CAIRO_MUTEX_LOCK (_cairo_glyph_cache_mutex);\n\n    if (global_glyph_cache)\n\tpixman_glyph_cache_destroy (global_glyph_cache);\n    global_glyph_cache = NULL;\n\n    CAIRO_MUTEX_UNLOCK (_cairo_glyph_cache_mutex);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":513165,"func":"static void free_plugin_mem(struct st_plugin_dl *p)\n{\n#ifdef HAVE_DLOPEN\n  if (p->ptr_backup)\n  {\n    DBUG_ASSERT(p->nbackups);\n    DBUG_ASSERT(p->handle);\n    restore_ptr_backup(p->nbackups, p->ptr_backup);\n    my_free(p->ptr_backup);\n  }\n  if (p->handle)\n    dlclose(p->handle);\n#endif\n  my_free(p->dl.str);\n  if (p->allocated)\n    my_free(p->plugins);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":238466,"func":"static int kfunc_desc_cmp_by_id_off(const void *a, const void *b)\n{\n\tconst struct bpf_kfunc_desc *d0 = a;\n\tconst struct bpf_kfunc_desc *d1 = b;\n\n\t\/* func_id is not greater than BTF_MAX_TYPE *\/\n\treturn d0->func_id - d1->func_id ?: d0->offset - d1->offset;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":225095,"func":"const OpDef::ArgDef* FindInputArg(StringPiece name, const OpDef& op_def) {\n  for (int i = 0; i < op_def.input_arg_size(); ++i) {\n    if (op_def.input_arg(i).name() == name) {\n      return &op_def.input_arg(i);\n    }\n  }\n  return nullptr;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":277669,"func":"get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n\/* This version is for reading raw-word-format PGM files with any maxval *\/\n{\n  ppm_source_ptr source = (ppm_source_ptr) sinfo;\n  register JSAMPROW ptr;\n  register U_CHAR * bufferptr;\n  register JSAMPLE *rescale = source->rescale;\n  JDIMENSION col;\n\n  if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))\n    ERREXIT(cinfo, JERR_INPUT_EOF);\n  ptr = source->pub.buffer[0];\n  bufferptr = source->iobuffer;\n  for (col = cinfo->image_width; col > 0; col--) {\n    register int temp;\n    temp  = UCH(*bufferptr++) << 8;\n    temp |= UCH(*bufferptr++);\n    *ptr++ = rescale[temp];\n  }\n  return 1;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":508298,"func":"TABLE *find_locked_table(TABLE *list, const char *db, const char *table_name)\n{\n  char\tkey[MAX_DBKEY_LENGTH];\n  uint key_length= tdc_create_key(key, db, table_name);\n\n  for (TABLE *table= list; table ; table=table->next)\n  {\n    if (table->s->table_cache_key.length == key_length &&\n\t!memcmp(table->s->table_cache_key.str, key, key_length))\n      return table;\n  }\n  return(0);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":294635,"func":"d_lite_jd(VALUE self)\n{\n    get_d1(self);\n    return m_real_local_jd(dat);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":238454,"func":"static int sanitize_check_bounds(struct bpf_verifier_env *env,\n\t\t\t\t const struct bpf_insn *insn,\n\t\t\t\t const struct bpf_reg_state *dst_reg)\n{\n\tu32 dst = insn->dst_reg;\n\n\t\/* For unprivileged we require that resulting offset must be in bounds\n\t * in order to be able to sanitize access later on.\n\t *\/\n\tif (env->bypass_spec_v1)\n\t\treturn 0;\n\n\tswitch (dst_reg->type) {\n\tcase PTR_TO_STACK:\n\t\tif (check_stack_access_for_ptr_arithmetic(env, dst, dst_reg,\n\t\t\t\t\tdst_reg->off + dst_reg->var_off.value))\n\t\t\treturn -EACCES;\n\t\tbreak;\n\tcase PTR_TO_MAP_VALUE:\n\t\tif (check_map_access(env, dst, dst_reg->off, 1, false)) {\n\t\t\tverbose(env, \"R%d pointer arithmetic of map value goes out of range, \"\n\t\t\t\t\"prohibited for !root\\n\", dst);\n\t\t\treturn -EACCES;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":512500,"func":"  bool eq(const Item_args *other, bool binary_cmp) const\n  {\n    for (uint i= 0; i < arg_count ; i++)\n    {\n      if (!args[i]->eq(other->args[i], binary_cmp))\n        return false;\n    }\n    return true;\n  }","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":139222,"func":"gfx::Size OverlayWindowViews::GetMaximumSize() const {\n  return max_size_;\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":445994,"func":"_encrypt_operation_completed_with_error (FrWindow *window,\n\t\t\t\t\t FrAction  action,\n\t\t\t\t\t GError   *error)\n{\n\tgboolean opens_dialog;\n\n\tg_return_if_fail (error != NULL);\n\n#ifdef DEBUG\n\tdebug (DEBUG_INFO, \"%s [DONE] (FR::Window)\\n\", action_names[action]);\n#endif\n\n\t_fr_window_stop_activity_mode (window);\n\t_handle_archive_operation_error (window, window->archive, action, error, NULL, &opens_dialog);\n\tif (opens_dialog)\n\t\treturn;\n\n\tclose_progress_dialog (window, FALSE);\n\tfr_window_stop_batch (window);\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":261452,"func":"void free_significant_coeff_ctxIdx_lookupTable()\n{\n  free(ctxIdxLookup[0][0][0][0]);\n  ctxIdxLookup[0][0][0][0]=NULL;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":369309,"func":"static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n{\n\tstruct io_connect *conn = &req->connect;\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags ||\n\t    sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\n\tconn->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\tconn->addr_len =  READ_ONCE(sqe->addr2);\n\treturn 0;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":484723,"func":"void mobi_buffer_free_null(MOBIBuffer *buf) {\n\tif (buf == NULL) { return; }\n\tfree(buf);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":220430,"func":"mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item)\n{\n  struct RArray *a = mrb_ary_ptr(self);\n  mrb_int len = ARY_LEN(a);\n\n  if (ARY_SHARED_P(a)\n      && a->as.heap.aux.shared->refcnt == 1 \/* shared only referenced from this array *\/\n      && a->as.heap.ptr - a->as.heap.aux.shared->ptr >= 1) \/* there's room for unshifted item *\/ {\n    a->as.heap.ptr--;\n    a->as.heap.ptr[0] = item;\n  }\n  else {\n    mrb_value *ptr;\n\n    ary_modify(mrb, a);\n    if (ARY_CAPA(a) < len + 1)\n      ary_expand_capa(mrb, a, len + 1);\n    ptr = ARY_PTR(a);\n    value_move(ptr + 1, ptr, len);\n    ptr[0] = item;\n  }\n  ARY_SET_LEN(a, len+1);\n  mrb_field_write_barrier_value(mrb, (struct RBasic*)a, item);\n\n  return self;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":225440,"func":"static const struct v4l2l_format *format_by_fourcc(int fourcc)\n{\n\tunsigned int i;\n\n\tfor (i = 0; i < FORMATS; i++) {\n\t\tif (formats[i].fourcc == fourcc)\n\t\t\treturn formats + i;\n\t}\n\n\tdprintk(\"unsupported format '%c%c%c%c'\\n\", (fourcc >> 0) & 0xFF,\n\t\t(fourcc >> 8) & 0xFF, (fourcc >> 16) & 0xFF,\n\t\t(fourcc >> 24) & 0xFF);\n\treturn NULL;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":468337,"func":"main (int argc, char *argv[])\n{\n  g_test_init (&argc, &argv, NULL);\n\n  g_test_add_func (\"\/socket-client\/happy-eyeballs\/slow\", test_happy_eyeballs);\n  g_test_add_func (\"\/socket-client\/happy-eyeballs\/cancellation\", test_happy_eyeballs_cancel);\n\n  return g_test_run ();\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":220031,"func":"  string DebugString() const override { return \"A SparseTensorsMap\"; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":244047,"func":"void proj_type_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":224174,"func":"      TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {\n    if (index >= dtypes_.size()) {\n      return Status(errors::InvalidArgument(\n          \"Index '\", index, \"' for key '\", key.scalar<int64_t>()(),\n          \"' was out of bounds '\", dtypes_.size(), \"'.\"));\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":421399,"func":"static void pvarlist(int d, js_Ast *list)\n{\n\twhile (list) {\n\t\tassert(list->type == AST_LIST);\n\t\tpvar(d, list->a);\n\t\tlist = list->b;\n\t\tif (list)\n\t\t\tcomma();\n\t}\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":242666,"func":"dissect_header_lens_v2(tvbuff_t *tvb, wtap_syscall_header* syscall_header, int offset, proto_tree *tree, int encoding)\n{\n    guint32 param_count;\n    proto_item *ti;\n    proto_tree *len_tree;\n\n    ti = proto_tree_add_item(tree, hf_se_param_lens, tvb, offset, syscall_header->nparams * SYSDIG_PARAM_SIZE_V2, ENC_NA);\n    len_tree = proto_item_add_subtree(ti, ett_sysdig_parm_lens);\n\n    for (param_count = 0; param_count < syscall_header->nparams; param_count++) {\n        proto_tree_add_item(len_tree, hf_se_param_len, tvb, offset + (param_count * SYSDIG_PARAM_SIZE_V2), SYSDIG_PARAM_SIZE_V2, encoding);\n    }\n\n    proto_item_set_len(ti, syscall_header->nparams * SYSDIG_PARAM_SIZE_V2);\n    return syscall_header->nparams * SYSDIG_PARAM_SIZE_V2;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":196829,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& val = ctx->input(0);\n    int64 id = ctx->session_state()->GetNewId();\n    TensorStore::TensorAndKey tk{val, id, requested_device()};\n    OP_REQUIRES_OK(ctx, ctx->tensor_store()->AddTensor(name(), tk));\n\n    Tensor* handle = nullptr;\n    OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({}), &handle));\n    if (ctx->expected_output_dtype(0) == DT_RESOURCE) {\n      ResourceHandle resource_handle = MakeResourceHandle<Tensor>(\n          ctx, SessionState::kTensorHandleResourceTypeName,\n          tk.GetHandle(name()));\n      resource_handle.set_maybe_type_name(\n          SessionState::kTensorHandleResourceTypeName);\n      handle->scalar<ResourceHandle>()() = resource_handle;\n    } else {\n      \/\/ Legacy behavior in V1.\n      handle->flat<tstring>().setConstant(tk.GetHandle(name()));\n    }\n  }","target":1,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":328978,"func":"R_API char *r_bin_java_print_unknown_cp_stringify(RBinJavaCPTypeObj *obj) {\n\treturn r_str_newf (\"%d.0x%04\"PFMT64x \".%s\", obj->metas->ord,\n\t\tobj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":512682,"func":"bool Item_func_in::prepare_predicant_and_values(THD *thd, uint *found_types)\n{\n  uint type_cnt;\n  have_null= false;\n\n  add_predicant(this, 0);\n  for (uint i= 1 ; i < arg_count; i++)\n  {\n    if (add_value_skip_null(Item_func_in::func_name(), this, i, &have_null))\n      return true;\n  }\n  all_values_added(&m_comparator, &type_cnt, found_types);\n  arg_types_compatible= type_cnt < 2;\n\n#ifndef DBUG_OFF\n  Predicant_to_list_comparator::debug_print(thd);\n#endif\n  return false;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":310163,"func":"init_extended_pair(int pair, int f, int b)\n{\n    return NCURSES_SP_NAME(init_extended_pair) (CURRENT_SCREEN, pair, f, b);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":473910,"func":"next_state_class(CClassNode* cc, OnigCodePoint* vs, enum CCVALTYPE* type,\n\t\t enum CCSTATE* state, ScanEnv* env)\n{\n  int r;\n\n  if (*state == CCS_RANGE)\n    return ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE;\n\n  if (*state == CCS_VALUE && *type != CCV_CLASS) {\n    if (*type == CCV_SB)\n      BITSET_SET_BIT_CHKDUP(cc->bs, (int )(*vs));\n    else if (*type == CCV_CODE_POINT) {\n      r = add_code_range(&(cc->mbuf), env, *vs, *vs);\n      if (r < 0) return r;\n    }\n  }\n\n  *state = CCS_VALUE;\n  *type  = CCV_CLASS;\n  return 0;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":344778,"func":"set_nodelay(int fd)\n{\n\tint opt;\n\tsocklen_t optlen;\n\n\toptlen = sizeof opt;\n\tif (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen) == -1) {\n\t\tdebug(\"getsockopt TCP_NODELAY: %.100s\", strerror(errno));\n\t\treturn;\n\t}\n\tif (opt == 1) {\n\t\tdebug2(\"fd %d is TCP_NODELAY\", fd);\n\t\treturn;\n\t}\n\topt = 1;\n\tdebug2(\"fd %d setting TCP_NODELAY\", fd);\n\tif (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof opt) == -1)\n\t\terror(\"setsockopt TCP_NODELAY: %.100s\", strerror(errno));\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":512339,"func":"  bool is_bool_literal() const { return true; }","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":336582,"func":"SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *reds, int enable)\n{\n    reds->config->playback_compression = !!enable;\n    snd_set_playback_compression(enable);\n    return 0;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":225909,"func":"void ccst_box_del(GF_Box *s)\n{\n\tGF_CodingConstraintsBox *ptr = (GF_CodingConstraintsBox *)s;\n\tif (ptr) gf_free(ptr);\n\treturn;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":277474,"func":"MOBI_RET mobi_get_indxentry_tagvalue(uint32_t *tagvalue, const MOBIIndexEntry *entry, const unsigned tag_arr[]) {\n    if (entry == NULL) {\n        debug_print(\"%s\", \"INDX entry not initialized\\n\");\n        return MOBI_INIT_FAILED;\n    }\n    size_t i = 0;\n    while (i < entry->tags_count) {\n        if (entry->tags[i].tagid == tag_arr[0]) {\n            if (entry->tags[i].tagvalues_count > tag_arr[1]) {\n                *tagvalue = entry->tags[i].tagvalues[tag_arr[1]];\n                return MOBI_SUCCESS;\n            }\n            break;\n        }\n        i++;\n    }\n    \/\/debug_print(\"tag[%i][%i] not found in entry: %s\\n\", tag_arr[0], tag_arr[1], entry->label);\n    return MOBI_DATA_CORRUPT;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":273060,"func":"clock_getres(clockid_t clock_id, struct timespec *res)\n{\n  if (! res)\n    return -1;\n\n  \/* hardcode ms resolution *\/\n  res->tv_sec = 0;\n  res->tv_nsec = 1000;\n\n  return 0;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":244296,"func":"GF_Err dac3_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\treturn gf_odf_ac3_config_parse_bs(bs, ptr->cfg.is_ec3, &ptr->cfg);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":317185,"func":"static int bpf_fd_pass(struct file *file, u32 sid)\n{\n\tstruct bpf_security_struct *bpfsec;\n\tstruct bpf_prog *prog;\n\tstruct bpf_map *map;\n\tint ret;\n\n\tif (file->f_op == &bpf_map_fops) {\n\t\tmap = file->private_data;\n\t\tbpfsec = map->security;\n\t\tret = avc_has_perm(&selinux_state,\n\t\t\t\t   sid, bpfsec->sid, SECCLASS_BPF,\n\t\t\t\t   bpf_map_fmode_to_av(file->f_mode), NULL);\n\t\tif (ret)\n\t\t\treturn ret;\n\t} else if (file->f_op == &bpf_prog_fops) {\n\t\tprog = file->private_data;\n\t\tbpfsec = prog->aux->security;\n\t\tret = avc_has_perm(&selinux_state,\n\t\t\t\t   sid, bpfsec->sid, SECCLASS_BPF,\n\t\t\t\t   BPF__PROG_RUN, NULL);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":513040,"func":"bool Item_equal::fix_length_and_dec()\n{\n  Item *item= get_first(NO_PARTICULAR_TAB, NULL);\n  const Type_handler *handler= item->type_handler();\n  eval_item= handler->make_cmp_item(current_thd, item->collation.collation);\n  return eval_item == NULL;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":90863,"func":"  void NotifyOriginNoLongerInUse(const GURL& origin) {\n    quota_manager_->NotifyOriginNoLongerInUse(origin);\n  }\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":312467,"func":"qf_init(win_T\t    *wp,\n\tchar_u\t    *efile,\n\tchar_u\t    *errorformat,\n\tint\t    newlist,\t\t\/\/ TRUE: start a new error list\n\tchar_u\t    *qf_title,\n\tchar_u\t    *enc)\n{\n    qf_info_T\t    *qi = &ql_info;\n\n    if (wp != NULL)\n    {\n\tqi = ll_get_or_alloc_list(wp);\n\tif (qi == NULL)\n\t    return FAIL;\n    }\n\n    return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat,\n\t    newlist, (linenr_T)0, (linenr_T)0, qf_title, enc);\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":180235,"func":"v8::Handle<v8::Value> V8ThrowException::throwGeneralError(v8::Isolate* isolate, const String& message)\n{\n    v8::Handle<v8::Value> exception = V8ThrowException::createGeneralError(isolate, message);\n    return V8ThrowException::throwException(exception, isolate);\n}\n","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":250690,"func":"int HttpFile::saveAs(const std::string &fileName) const\n{\n    return implPtr_->saveAs(fileName);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":387866,"func":"Method* InstanceKlass::method_with_orig_idnum(int idnum) {\n  if (idnum >= methods()->length()) {\n    return NULL;\n  }\n  Method* m = methods()->at(idnum);\n  if (m != NULL && m->orig_method_idnum() == idnum) {\n    return m;\n  }\n  \/\/ Obsolete method idnum does not match the original idnum\n  for (int index = 0; index < methods()->length(); ++index) {\n    m = methods()->at(index);\n    if (m->orig_method_idnum() == idnum) {\n      return m;\n    }\n  }\n  \/\/ None found, return null for the caller to handle.\n  return NULL;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":384823,"func":"f_browsedir(typval_T *argvars UNUSED, typval_T *rettv)\n{\n# ifdef FEAT_BROWSE\n    char_u\t*title;\n    char_u\t*initdir;\n    char_u\tbuf[NUMBUFLEN];\n\n    if (in_vim9script()\n\t    && (check_for_string_arg(argvars, 0) == FAIL\n\t\t|| check_for_string_arg(argvars, 1) == FAIL))\n\treturn;\n\n    title = tv_get_string_chk(&argvars[0]);\n    initdir = tv_get_string_buf_chk(&argvars[1], buf);\n\n    if (title == NULL || initdir == NULL)\n\trettv->vval.v_string = NULL;\n    else\n\trettv->vval.v_string = do_browse(BROWSE_DIR,\n\t\t\t\t    title, NULL, NULL, initdir, NULL, curbuf);\n# else\n    rettv->vval.v_string = NULL;\n# endif\n    rettv->v_type = VAR_STRING;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":333091,"func":"report_state(char *action,\n\t     regsub_T *sub,\n\t     nfa_state_T *state,\n\t     int lid,\n\t     nfa_pim_T *pim)\n{\n    int col;\n\n    if (sub->in_use <= 0)\n\tcol = -1;\n    else if (REG_MULTI)\n\tcol = sub->list.multi[0].start_col;\n    else\n\tcol = (int)(sub->list.line[0].start - rex.line);\n    nfa_set_code(state->c);\n    fprintf(log_fd, \"> %s state %d to list %d. char %d: %s (start col %d)%s\\n\",\n\t    action, abs(state->id), lid, state->c, code, col,\n\t    pim_info(pim));\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":236207,"func":"void dims_box_del(GF_Box *s)\n{\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\tgf_free(s);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":430344,"func":"struct hlist_node *seq_hlist_start(struct hlist_head *head, loff_t pos)\n{\n\tstruct hlist_node *node;\n\n\thlist_for_each(node, head)\n\t\tif (pos-- == 0)\n\t\t\treturn node;\n\treturn NULL;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":261885,"func":"njs_string_hex(njs_vm_t *vm, njs_value_t *value, const njs_str_t *src)\n{\n    size_t     length;\n    njs_str_t  dst;\n\n    length = njs_encode_hex_length(src, &dst.length);\n\n    dst.start = njs_string_alloc(vm, value, dst.length, length);\n    if (njs_fast_path(dst.start != NULL)) {\n        njs_encode_hex(&dst, src);\n        return NJS_OK;\n    }\n\n    return NJS_ERROR;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":294544,"func":"rt__valid_commercial_p(VALUE y, VALUE w, VALUE d, VALUE sg)\n{\n    VALUE nth, rjd2;\n    int ry, rw, rd, rjd, ns;\n\n    if (!valid_commercial_p(y, NUM2INT(w), NUM2INT(d), NUM2DBL(sg),\n\t\t\t    &nth, &ry,\n\t\t\t    &rw, &rd, &rjd,\n\t\t\t    &ns))\n\treturn Qnil;\n    encode_jd(nth, rjd, &rjd2);\n    return rjd2;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":220407,"func":"mrb_ary_splat(mrb_state *mrb, mrb_value v)\n{\n  mrb_value ary;\n  struct RArray *a;\n\n  if (mrb_array_p(v)) {\n    a = ary_dup(mrb, mrb_ary_ptr(v));\n    return mrb_obj_value(a);\n  }\n\n  if (!mrb_respond_to(mrb, v, MRB_SYM(to_a))) {\n    return mrb_ary_new_from_values(mrb, 1, &v);\n  }\n\n  ary = mrb_funcall_id(mrb, v, MRB_SYM(to_a), 0);\n  if (mrb_nil_p(ary)) {\n    return mrb_ary_new_from_values(mrb, 1, &v);\n  }\n  mrb_ensure_array_type(mrb, ary);\n  a = mrb_ary_ptr(ary);\n  a = ary_dup(mrb, a);\n  return mrb_obj_value(a);\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":222528,"func":"string FunctionLibraryRuntime::ExecutorType(const InstantiateOptions& options,\n                                            AttrSlice attrs) {\n  if (!options.executor_type.empty()) {\n    return options.executor_type;\n  } else if (const AttrValue* executor_attr = attrs.Find(kExecutorAttr)) {\n    return executor_attr->s();\n  } else {\n    return string();\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":301501,"func":"suggest_try_soundalike_prep(void)\n{\n    langp_T\t*lp;\n    int\t\tlpi;\n    slang_T\t*slang;\n\n    \/\/ Do this for all languages that support sound folding and for which a\n    \/\/ .sug file has been loaded.\n    for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)\n    {\n\tlp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);\n\tslang = lp->lp_slang;\n\tif (slang->sl_sal.ga_len > 0 && slang->sl_sbyts != NULL)\n\t    \/\/ prepare the hashtable used by add_sound_suggest()\n\t    hash_init(&slang->sl_sounddone);\n    }\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":256394,"func":"static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter)\n{\n\tstruct bio_vec *bvec;\n\tstruct bvec_iter_all iter_all;\n\n\tbio_for_each_segment_all(bvec, bio, iter_all) {\n\t\tssize_t ret;\n\n\t\tret = copy_page_to_iter(bvec->bv_page,\n\t\t\t\t\tbvec->bv_offset,\n\t\t\t\t\tbvec->bv_len,\n\t\t\t\t\t&iter);\n\n\t\tif (!iov_iter_count(&iter))\n\t\t\tbreak;\n\n\t\tif (ret < bvec->bv_len)\n\t\t\treturn -EFAULT;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":301411,"func":"static int vfswrap_stat(vfs_handle_struct *handle,\n\t\t\tstruct smb_filename *smb_fname)\n{\n\tint result = -1;\n\n\tSTART_PROFILE(syscall_stat);\n\n\tif (smb_fname->stream_name) {\n\t\terrno = ENOENT;\n\t\tgoto out;\n\t}\n\n\tresult = sys_stat(smb_fname->base_name, &smb_fname->st,\n\t\t\t  lp_fake_dir_create_times(SNUM(handle->conn)));\n out:\n\tEND_PROFILE(syscall_stat);\n\treturn result;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":381857,"func":"static void udf_update_extent_cache(struct inode *inode, loff_t estart,\n\t\t\t\t    struct extent_position *pos)\n{\n\tstruct udf_inode_info *iinfo = UDF_I(inode);\n\n\tspin_lock(&iinfo->i_extent_cache_lock);\n\t\/* Invalidate previously cached extent *\/\n\t__udf_clear_extent_cache(inode);\n\tif (pos->bh)\n\t\tget_bh(pos->bh);\n\tmemcpy(&iinfo->cached_extent.epos, pos, sizeof(*pos));\n\tiinfo->cached_extent.lstart = estart;\n\tswitch (iinfo->i_alloc_type) {\n\tcase ICBTAG_FLAG_AD_SHORT:\n\t\tiinfo->cached_extent.epos.offset -= sizeof(struct short_ad);\n\t\tbreak;\n\tcase ICBTAG_FLAG_AD_LONG:\n\t\tiinfo->cached_extent.epos.offset -= sizeof(struct long_ad);\n\t\tbreak;\n\t}\n\tspin_unlock(&iinfo->i_extent_cache_lock);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":386556,"func":"void DL_Dxf::writeArc(DL_WriterA& dw,\n                      const DL_ArcData& data,\n                      const DL_Attributes& attrib) {\n    dw.entity(\"ARC\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbCircle\");\n    }\n    dw.coord(10, data.cx, data.cy, data.cz);\n    dw.dxfReal(40, data.radius);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbArc\");\n    }\n    dw.dxfReal(50, data.angle1);\n    dw.dxfReal(51, data.angle2);\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":222900,"func":"  static int64_t Unknown() { return -1; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":263512,"func":"static int sco_sock_release(struct socket *sock)\n{\n\tstruct sock *sk = sock->sk;\n\tint err = 0;\n\n\tBT_DBG(\"sock %p, sk %p\", sock, sk);\n\n\tif (!sk)\n\t\treturn 0;\n\n\tsco_sock_close(sk);\n\n\tif (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&\n\t    !(current->flags & PF_EXITING)) {\n\t\tlock_sock(sk);\n\t\terr = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime);\n\t\trelease_sock(sk);\n\t}\n\n\tsock_orphan(sk);\n\tsco_sock_kill(sk);\n\treturn err;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":222568,"func":"string FunctionLibraryDefinition::FindGradient(const string& func) const {\n  tf_shared_lock l(mu_);\n  return gtl::FindWithDefault(func_grad_, func, \"\");\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":359631,"func":"DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,\n       clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,\n       \"clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"BGP neighbor address to clear\\n\"\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Soft reconfig inbound update\\n\"\n       \"Push out the existing ORF prefix-list\\n\")\n{\n  if (strncmp (argv[1], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,\n\t\t\t  BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,\n\t\t\tBGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":512947,"func":"  double val_real_from_item(Item *item)\n  {\n    DBUG_ASSERT(is_fixed());\n    double value= item->val_real();\n    null_value= item->null_value;\n    return value;\n  }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":359651,"func":"DEFUN (clear_bgp_all_soft_in,\n       clear_bgp_all_soft_in_cmd,\n       \"clear bgp * soft in\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,\n                        BGP_CLEAR_SOFT_IN, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_IN, NULL);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":359214,"func":"BPF_CALL_3(bpf_ringbuf_reserve, struct bpf_map *, map, u64, size, u64, flags)\n{\n\tstruct bpf_ringbuf_map *rb_map;\n\n\tif (unlikely(flags))\n\t\treturn 0;\n\n\trb_map = container_of(map, struct bpf_ringbuf_map, map);\n\treturn (unsigned long)__bpf_ringbuf_reserve(rb_map->rb, size);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":225879,"func":"\nGF_Box *fdsa_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_HintSample, GF_ISOM_BOX_TYPE_FDSA);\n\tif (!tmp) return NULL;\n\ttmp->packetTable = gf_list_new();\n\ttmp->hint_subtype = GF_ISOM_BOX_TYPE_FDP_STSD;\n\treturn (GF_Box*)tmp;","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":437703,"func":"static u64 ns_to_pulse_clocks(u32 ns)\n{\n\tu64 clocks;\n\tu32 rem;\n\tclocks = CX23888_IR_REFCLK_FREQ \/ 1000000 * (u64) ns; \/* millicycles  *\/\n\trem = do_div(clocks, 1000);                         \/* \/1000 = cycles *\/\n\tif (rem >= 1000 \/ 2)\n\t\tclocks++;\n\treturn clocks;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":231534,"func":"getcwd_nothrow (char *buf, size_t size)\n{\n  char *result;\n\n  TRY_MSVC_INVAL\n    {\n      result = _getcwd (buf, size);\n    }\n  CATCH_MSVC_INVAL\n    {\n      result = NULL;\n      errno = ERANGE;\n    }\n  DONE_MSVC_INVAL;\n\n  return result;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":509558,"func":"int ha_maria::extra_opt(enum ha_extra_function operation, ulong cache_size)\n{\n  if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_WRITE_CACHE)\n    return 0;\n  return maria_extra(file, operation, (void*) &cache_size);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":301380,"func":"static DIR *vfswrap_fdopendir(vfs_handle_struct *handle,\n\t\t\tfiles_struct *fsp,\n\t\t\tconst char *mask,\n\t\t\tuint32 attr)\n{\n\tDIR *result;\n\n\tSTART_PROFILE(syscall_fdopendir);\n\tresult = sys_fdopendir(fsp->fh->fd);\n\tEND_PROFILE(syscall_fdopendir);\n\treturn result;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":293542,"func":"PJ_DEF(void) pj_cis_del_str( pj_cis_t *cis, const char *str)\n{\n    while (*str) {\n        PJ_CIS_CLR(cis, *str);\n\t++str;\n    }\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":307831,"func":"void ciEnv::cache_jvmti_state() {\n  VM_ENTRY_MARK;\n  \/\/ Get Jvmti capabilities under lock to get consistant values.\n  MutexLocker mu(JvmtiThreadState_lock);\n  _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();\n  _jvmti_can_access_local_variables     = JvmtiExport::can_access_local_variables();\n  _jvmti_can_post_on_exceptions         = JvmtiExport::can_post_on_exceptions();\n  _jvmti_can_pop_frame                  = JvmtiExport::can_pop_frame();\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":259611,"func":"void HierarchicalBitmapRequester::Push8Lines(UBYTE c)\n{\n  int cnt;\n  ULONG y = m_pulY[c];\n  \/\/\n  for(cnt = 0;cnt < 8 && y < m_pulHeight[c];cnt++) {\n    assert(m_ppEncodingMCU[cnt | (c << 3)]);\n    m_pLargestScale->PushLine(m_ppEncodingMCU[cnt | (c << 3)],c);\n    m_ppEncodingMCU[cnt | (c << 3)] = NULL;\n    y++;\n  }\n\n  m_pulY[c] = y;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":383372,"func":"gdImageColorExact (gdImagePtr im, int r, int g, int b)\n{\n  return gdImageColorExactAlpha (im, r, g, b, gdAlphaOpaque);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":247100,"func":"void *gf_filter_claim_opengl_provider(GF_Filter *filter)\n{\n\treturn NULL;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":359290,"func":"DEFUN (no_neighbor_strict_capability,\n       no_neighbor_strict_capability_cmd,\n       NO_NEIGHBOR_CMD \"strict-capability-match\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR\n       \"Strict capability negotiation match\\n\")\n{\n  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":359498,"func":"DEFUN (clear_ip_bgp_all_ipv4_soft_out,\n       clear_ip_bgp_all_ipv4_soft_out_cmd,\n       \"clear ip bgp * ipv4 (unicast|multicast) soft out\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig outbound update\\n\")\n{\n  if (strncmp (argv[0], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,\n\t\t\t  BGP_CLEAR_SOFT_OUT, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_OUT, NULL);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":359350,"func":"DEFUN (neighbor_passive,\n       neighbor_passive_cmd,\n       NEIGHBOR_CMD2 \"passive\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Don't send open messages to this neighbor\\n\")\n{\n  return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":222902,"func":"bool HasAnyUnknownDimensions(const TensorShapeProto& proto) {\n  if (proto.unknown_rank()) {\n    return true;\n  }\n  for (const auto& dim : proto.dim()) {\n    if (dim.size() < 0) {\n      return true;\n    }\n  }\n  return false;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":248332,"func":"DLLIMPORT double cfg_opt_getnfloat(cfg_opt_t *opt, unsigned int index)\n{\n\tif (!opt || opt->type != CFGT_FLOAT) {\n\t\terrno = EINVAL;\n\t\treturn 0;\n\t}\n\n\tif (opt->values && index < opt->nvalues)\n\t\treturn opt->values[index]->fpnumber;\n\tif (opt->simple_value.fpnumber)\n\t\treturn *opt->simple_value.fpnumber;\n\n\treturn 0;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":225656,"func":"\nGF_Box *paen_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(FDPartitionEntryBox, GF_ISOM_BOX_TYPE_PAEN);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":430426,"func":"static int set_action_to_attr(const struct nlattr *a, struct sk_buff *skb)\n{\n\tconst struct nlattr *ovs_key = nla_data(a);\n\tint key_type = nla_type(ovs_key);\n\tstruct nlattr *start;\n\tint err;\n\n\tswitch (key_type) {\n\tcase OVS_KEY_ATTR_TUNNEL_INFO: {\n\t\tstruct ovs_tunnel_info *ovs_tun = nla_data(ovs_key);\n\t\tstruct ip_tunnel_info *tun_info = &ovs_tun->tun_dst->u.tun_info;\n\n\t\tstart = nla_nest_start_noflag(skb, OVS_ACTION_ATTR_SET);\n\t\tif (!start)\n\t\t\treturn -EMSGSIZE;\n\n\t\terr =  ip_tun_to_nlattr(skb, &tun_info->key,\n\t\t\t\t\tip_tunnel_info_opts(tun_info),\n\t\t\t\t\ttun_info->options_len,\n\t\t\t\t\tip_tunnel_info_af(tun_info), tun_info->mode);\n\t\tif (err)\n\t\t\treturn err;\n\t\tnla_nest_end(skb, start);\n\t\tbreak;\n\t}\n\tdefault:\n\t\tif (nla_put(skb, OVS_ACTION_ATTR_SET, nla_len(a), ovs_key))\n\t\t\treturn -EMSGSIZE;\n\t\tbreak;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":294657,"func":"c_julian_to_yday(int y, int m, int d)\n{\n    assert(m >= 1 && m <= 12);\n    return yeartab[c_julian_leap_p(y) ? 1 : 0][m] + d;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":463183,"func":"HIDDEN int annotate_state_set_message(annotate_state_t *state,\n                               struct mailbox *mailbox,\n                               unsigned int uid)\n{\n    return annotate_state_set_scope(state, NULL, mailbox, uid);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":247167,"func":"static void gf_fs_print_not_connected_filters(GF_FilterSession *fsess, GF_List *filters_done, Bool ignore_sinks)\n{\n\tu32 i, count;\n\tBool has_unconnected=GF_FALSE;\n\tcount=gf_list_count(fsess->filters);\n\tfor (i=0; i<count; i++) {\n\t\tGF_Filter *f = gf_list_get(fsess->filters, i);\n\t\t\/\/only dump not connected ones\n\t\tif (f->num_input_pids || f->num_output_pids || f->multi_sink_target || f->nb_tasks_done) continue;\n\t\tif (ignore_sinks) {\n\t\t\tBool has_outputs;\n\t\t\tif (f->forced_caps)\n\t\t\t\thas_outputs = gf_filter_has_out_caps(f->forced_caps, f->nb_forced_caps);\n\t\t\telse\n\t\t\t\thas_outputs = gf_filter_has_out_caps(f->freg->caps, f->freg->nb_caps);\n\t\t\tif (!has_outputs) continue;\n\t\t}\n\n\t\tif (!has_unconnected) {\n\t\t\thas_unconnected = GF_TRUE;\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_APP, (\"Filters not connected:\\n\"));\n\t\t}\n\t\tgf_fs_print_filter_outputs(f, filters_done, 0, NULL, NULL, 0, GF_FALSE);\n\t}\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":245712,"func":"static int read_request_line (struct conn_s *connptr)\n{\n        ssize_t len;\n\nretry:\n        len = readline (connptr->client_fd, &connptr->request_line);\n        if (len <= 0) {\n                log_message (LOG_ERR,\n                             \"read_request_line: Client (file descriptor: %d) \"\n                             \"closed socket before read.\", connptr->client_fd);\n\n                return -1;\n        }\n\n        \/*\n         * Strip the new line and carriage return from the string.\n         *\/\n        if (chomp (connptr->request_line, len) == len) {\n                \/*\n                 * If the number of characters removed is the same as the\n                 * length then it was a blank line. Free the buffer and\n                 * try again (since we're looking for a request line.)\n                 *\/\n                safefree (connptr->request_line);\n                goto retry;\n        }\n\n        log_message (LOG_CONN, \"Request (file descriptor %d): %s\",\n                     connptr->client_fd, connptr->request_line);\n\n        return 0;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":275964,"func":"uECC_VLI_API int uECC_generate_random_int(uECC_word_t *random,\n                                          const uECC_word_t *top,\n                                          wordcount_t num_words) {\n    uECC_word_t mask = (uECC_word_t)-1;\n    uECC_word_t tries;\n    bitcount_t num_bits = uECC_vli_numBits(top, num_words);\n\n    if (!g_rng_function) {\n        return 0;\n    }\n\n    for (tries = 0; tries < uECC_RNG_MAX_TRIES; ++tries) {\n        if (!g_rng_function((uint8_t *)random, num_words * uECC_WORD_SIZE)) {\n            return 0;\n\t    }\n        random[num_words - 1] &= mask >> ((bitcount_t)(num_words * uECC_WORD_SIZE * 8 - num_bits));\n        if (!uECC_vli_isZero(random, num_words) &&\n\t\t        uECC_vli_cmp(top, random, num_words) == 1) {\n            return 1;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":389671,"func":"check_for_list_or_dict_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_LIST\n\t    && args[idx].v_type != VAR_DICT)\n    {\n\tsemsg(_(e_list_or_dict_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":276960,"func":"WriteAc4Header(AP4_ByteStream& output,\n                unsigned int    frame_size)\n{\n    unsigned char bits[7];\n\n    bits[0] = 0xac;\n    bits[1] = 0x40;\n    bits[2] = 0xff;\n    bits[3] = 0xff;\n    bits[4] = (frame_size>>16)&0xFF;\n    bits[5] = (frame_size>>8 )&0xFF;\n    bits[6] = (frame_size    )&0xFF;\n\n    return output.Write(bits, 7);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":373529,"func":"ipf_addr_hash_add(uint32_t hash, const union ipf_addr *addr)\n{\n    BUILD_ASSERT_DECL(sizeof *addr % 4 == 0);\n    return hash_add_bytes32(hash, (const uint32_t *) addr, sizeof *addr);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":385865,"func":"static int may_delete(struct inode *dir,struct dentry *victim,int isdir)\n{\n\tint error;\n\n\tif (!victim->d_inode)\n\t\treturn -ENOENT;\n\n\tBUG_ON(victim->d_parent->d_inode != dir);\n\taudit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);\n\n\terror = inode_permission(dir, MAY_WRITE | MAY_EXEC);\n\tif (error)\n\t\treturn error;\n\tif (IS_APPEND(dir))\n\t\treturn -EPERM;\n\tif (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||\n\t    IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))\n\t\treturn -EPERM;\n\tif (isdir) {\n\t\tif (!S_ISDIR(victim->d_inode->i_mode))\n\t\t\treturn -ENOTDIR;\n\t\tif (IS_ROOT(victim))\n\t\t\treturn -EBUSY;\n\t} else if (S_ISDIR(victim->d_inode->i_mode))\n\t\treturn -EISDIR;\n\tif (IS_DEADDIR(dir))\n\t\treturn -ENOENT;\n\tif (victim->d_flags & DCACHE_NFSFS_RENAMED)\n\t\treturn -EBUSY;\n\treturn 0;\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":482482,"func":"lou_getEmphClasses(const char *tableList) {\n\tconst char *names[MAX_EMPH_CLASSES + 1];\n\tunsigned int count = 0;\n\tconst TranslationTableHeader *table = _lou_getTranslationTable(tableList);\n\tif (!table) return NULL;\n\n\twhile (count < MAX_EMPH_CLASSES) {\n\t\tchar const *name = table->emphClassNames[count];\n\t\tif (!name) break;\n\t\tnames[count++] = name;\n\t}\n\tnames[count++] = NULL;\n\n\t{\n\t\tunsigned int size = count * sizeof(names[0]);\n\t\tchar const **result = malloc(size);\n\t\tif (!result) return NULL;\n\t\t\/* The void* cast is necessary to stop MSVC from warning about\n\t\t * different 'const' qualifiers (C4090). *\/\n\t\tmemcpy((void *)result, names, size);\n\t\treturn result;\n\t}\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":500090,"func":"kssl_ctx_free(KSSL_CTX *kssl_ctx)\n        {\n\tif (kssl_ctx == NULL)  return kssl_ctx;\n\n\tif (kssl_ctx->key)  \t\tOPENSSL_cleanse(kssl_ctx->key,\n\t\t\t\t\t\t\t      kssl_ctx->length);\n\tif (kssl_ctx->key)  \t\tkssl_free(kssl_ctx->key);\n\tif (kssl_ctx->client_princ) \tkssl_free(kssl_ctx->client_princ);\n\tif (kssl_ctx->service_host) \tkssl_free(kssl_ctx->service_host);\n\tif (kssl_ctx->service_name) \tkssl_free(kssl_ctx->service_name);\n\tif (kssl_ctx->keytab_file) \tkssl_free(kssl_ctx->keytab_file);\n\n\tkssl_free(kssl_ctx);\n\treturn (KSSL_CTX *) NULL;\n        }","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":221630,"func":"DynamicBroadcastInDimOpLowering::DynamicBroadcastInDimOpLowering(\n    MLIRContext* ctx)\n    : Base(ctx) {}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":442790,"func":"convert_from_network(char *buffer, size_t length)\n{\n  CURLcode rc;\n\n  \/* translate from the network encoding to the host encoding *\/\n  char *input_ptr, *output_ptr;\n  size_t in_bytes, out_bytes;\n\n  \/* open an iconv conversion descriptor if necessary *\/\n  if(inbound_cd == (iconv_t)-1) {\n    inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,\n                            CURL_ICONV_CODESET_OF_NETWORK);\n    if(inbound_cd == (iconv_t)-1) {\n      return CURLE_CONV_FAILED;\n    }\n  }\n  \/* call iconv *\/\n  input_ptr = output_ptr = buffer;\n  in_bytes = out_bytes = length;\n  rc = iconv(inbound_cd, &input_ptr,  &in_bytes,\n                         &output_ptr, &out_bytes);\n  if ((rc == -1) || (in_bytes != 0)) {\n    return CURLE_CONV_FAILED;\n  }\n\n  return CURLE_OK;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":484050,"func":"START_TEST(SecureChannel_sendAsymmetricOPNMessage_SecurityModeSign) {\n    \/\/ Configure our channel correctly for OPN messages and setup dummy message\n    UA_OpenSecureChannelResponse dummyResponse;\n    createDummyResponse(&dummyResponse);\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_SIGN;\n\n    UA_StatusCode retval =\n        UA_SecureChannel_sendAsymmetricOPNMessage(&testChannel, 42, &dummyResponse,\n                                                  &UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);\n    ck_assert_msg(retval == UA_STATUSCODE_GOOD, \"Expected function to succeed\");\n    ck_assert_msg(fCalled.asym_enc, \"Expected message to have been encrypted but it was not\");\n    ck_assert_msg(fCalled.asym_sign, \"Expected message to have been signed but it was not\");\n}END_TEST","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":301482,"func":"sug_compare(const void *s1, const void *s2)\n{\n    suggest_T\t*p1 = (suggest_T *)s1;\n    suggest_T\t*p2 = (suggest_T *)s2;\n    int\t\tn = p1->st_score - p2->st_score;\n\n    if (n == 0)\n    {\n\tn = p1->st_altscore - p2->st_altscore;\n\tif (n == 0)\n\t    n = STRICMP(p1->st_word, p2->st_word);\n    }\n    return n;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":238433,"func":"static int copy_func_state(struct bpf_func_state *dst,\n\t\t\t   const struct bpf_func_state *src)\n{\n\tint err;\n\n\tmemcpy(dst, src, offsetof(struct bpf_func_state, acquired_refs));\n\terr = copy_reference_state(dst, src);\n\tif (err)\n\t\treturn err;\n\treturn copy_stack_state(dst, src);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":274860,"func":"TEST(ComparisonsTest, QuantizedInt8LessEqualWithBroadcast) {\n  const float kMin = -127.f;\n  const float kMax = 127.f;\n  std::vector<std::vector<int>> test_shapes = {\n      {6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};\n  for (int i = 0; i < test_shapes.size(); ++i) {\n    ComparisonOpModel model({TensorType_INT8, test_shapes[i], kMin, kMax},\n                            {TensorType_INT8, {}, kMin, kMax}, TensorType_INT8,\n                            BuiltinOperator_LESS_EQUAL);\n    model.QuantizeAndPopulate<int8_t>(model.input1(), {20, -2, -71, 8, 11, 20});\n    model.QuantizeAndPopulate<int8_t>(model.input2(), {8});\n    model.Invoke();\n    EXPECT_THAT(model.GetOutput(),\n                ElementsAre(false, true, true, true, false, false))\n        << \"With shape number \" << i;\n  }\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":442572,"func":"static unsigned long __get_clean_virt(RedMemSlotInfo *info, QXLPHYSICAL addr)\n{\n    return addr & info->memslot_clean_virt_mask;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":317174,"func":"static void selinux_nf_ip_exit(void)\n{\n\tpr_debug(\"SELinux:  Unregistering netfilter hooks\\n\");\n\n\tunregister_pernet_subsys(&selinux_net_ops);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":261447,"func":"static void read_cross_comp_pred(thread_context* tctx, int cIdxMinus1)\n{\n  int log2_res_scale_abs_plus1 = decode_log2_res_scale_abs_plus1(tctx,cIdxMinus1);\n  int ResScaleVal;\n\n  if (log2_res_scale_abs_plus1 != 0) {\n    int res_scale_sign_flag = decode_res_scale_sign_flag(tctx,cIdxMinus1);\n\n    ResScaleVal = 1 << (log2_res_scale_abs_plus1 - 1);\n    ResScaleVal *= 1 - 2 * res_scale_sign_flag;\n  }\n  else {\n    ResScaleVal = 0;\n  }\n\n  tctx->ResScaleVal = ResScaleVal;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":310083,"func":"drv_hwlabel(TERMINAL_CONTROL_BLOCK * TCB, int labnum, char *text)\n{\n    SCREEN *sp = TCB->csp;\n\n    AssertTCB();\n    if (labnum > 0 && labnum <= num_labels) {\n\tNCURSES_PUTP2(\"plab_norm\",\n\t\t      TPARM_2(plab_norm, labnum, text));\n    }\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":389743,"func":"check_for_blob_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_BLOB)\n    {\n\tsemsg(_(e_blob_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":308174,"func":"static void fastrpc_dma_buf_detatch(struct dma_buf *dmabuf,\n\t\t\t\t    struct dma_buf_attachment *attachment)\n{\n\tstruct fastrpc_dma_buf_attachment *a = attachment->priv;\n\tstruct fastrpc_buf *buffer = dmabuf->priv;\n\n\tmutex_lock(&buffer->lock);\n\tlist_del(&a->node);\n\tmutex_unlock(&buffer->lock);\n\tsg_free_table(&a->sgt);\n\tkfree(a);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":246452,"func":"static inline RPVector *parse_vec(RBinWasmObj *bin, ut64 bound, ParseEntryFcn parse_entry, RPVectorFree free_entry) {\n\tRBuffer *buf = bin->buf;\n\n\tut32 count;\n\tif (!consume_u32_r (buf, bound, &count)) {\n\t\treturn NULL;\n\t}\n\n\tRPVector *vec = r_pvector_new (free_entry);\n\tif (vec) {\n\t\tr_pvector_reserve (vec, count);\n\t\tut32 i;\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tut64 start = r_buf_tell (buf);\n\t\t\tvoid *e = parse_entry (bin, bound, i);\n\t\t\tif (!e || !r_pvector_push (vec, e)) {\n\t\t\t\teprintf (\"[wasm] Failed to parse entry %u\/%u of vec at 0x%\" PFMT64x \"\\n\", i, count, start);\n\t\t\t\tfree_entry (e);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn vec;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":220807,"func":"int GetOutputSize(int max_seen, int max_length, int min_length) {\n  return max_length > 0 ? max_length : std::max((max_seen + 1), min_length);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":242642,"func":"void isor_reader_release_sample(ISOMChannel *ch)\n{\n\tif (ch->sample)\n\t\tch->au_seq_num++;\n\tch->sample = NULL;\n\tch->sai_buffer_size = 0;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":246462,"func":"static void wasm_custom_name_local_free(RBinWasmCustomNameLocalName *name) {\n\tif (name) {\n\t\tr_id_storage_free (name->names);\n\t\tR_FREE (name);\n\t}\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":247574,"func":"  void setExpectedServerStats(const std::string& expected_server_stats) {\n    expected_server_stats_ = expected_server_stats;\n  }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":313565,"func":"\t__acquires(rose_route_list_lock)\n{\n\tstruct rose_route *rose_route;\n\tint i = 1;\n\n\tspin_lock_bh(&rose_route_list_lock);\n\tif (*pos == 0)\n\t\treturn SEQ_START_TOKEN;\n\n\tfor (rose_route = rose_route_list; rose_route && i < *pos;\n\t     rose_route = rose_route->next, ++i);\n\n\treturn (i == *pos) ? rose_route : NULL;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":252307,"func":"static void swap2(unsigned short *val) {\n#ifdef MINIZ_LITTLE_ENDIAN\n  (void)val;\n#else\n  unsigned short tmp = *val;\n  unsigned char *dst = reinterpret_cast<unsigned char *>(val);\n  unsigned char *src = reinterpret_cast<unsigned char *>(&tmp);\n\n  dst[0] = src[1];\n  dst[1] = src[0];\n#endif\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":309880,"func":"init_color(NCURSES_COLOR_T color,\n\t   NCURSES_COLOR_T r,\n\t   NCURSES_COLOR_T g,\n\t   NCURSES_COLOR_T b)\n{\n    return NCURSES_SP_NAME(init_color) (CURRENT_SCREEN, color, r, g, b);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":276899,"func":"static int do_i2c(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n{\n\tstruct cmd_tbl *c;\n\n#ifdef CONFIG_NEEDS_MANUAL_RELOC\n\ti2c_reloc();\n#endif\n\n\tif (argc < 2)\n\t\treturn CMD_RET_USAGE;\n\n\t\/* Strip off leading 'i2c' command argument *\/\n\targc--;\n\targv++;\n\n\tc = find_cmd_tbl(argv[0], &cmd_i2c_sub[0], ARRAY_SIZE(cmd_i2c_sub));\n\n\tif (c)\n\t\treturn c->cmd(cmdtp, flag, argc, argv);\n\telse\n\t\treturn CMD_RET_USAGE;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":505656,"func":"static int smtp_command_parse_identifier(struct smtp_command_parser *parser)\n{\n\tconst unsigned char *p;\n\n\t\/* The commands themselves are alphabetic characters.\n\t *\/\n\tp = parser->cur + parser->state.poff;\n\ti_assert(p <= parser->end);\n\twhile (p < parser->end && i_isalpha(*p))\n\t\tp++;\n\tif ((p - parser->cur) > SMTP_COMMAND_PARSER_MAX_COMMAND_LENGTH) {\n\t\tsmtp_command_parser_error(parser,\n\t\t\tSMTP_COMMAND_PARSE_ERROR_BAD_COMMAND,\n\t\t\t\"Command name is too long\");\n\t\treturn -1;\n\t}\n\tparser->state.poff = p - parser->cur;\n\tif (p == parser->end)\n\t\treturn 0;\n\tparser->state.cmd_name = str_ucase(i_strdup_until(parser->cur, p));\n\tparser->cur = p;\n\tparser->state.poff = 0;\n\treturn 1;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":90150,"func":"  virtual bool GetWifiAccessPoints(WifiAccessPointVector* result) {\n    return false;\n  }\n","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":474094,"func":"utf16le_mbc_enc_len(const UChar* p, const OnigUChar* e,\n\t\t    OnigEncoding enc ARG_UNUSED)\n{\n  int len = (int)(e - p);\n  UChar byte;\n  if (len < 2)\n    return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1);\n  byte = p[1];\n  if (!UTF16_IS_SURROGATE(byte)) {\n    return ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2);\n  }\n  if (UTF16_IS_SURROGATE_FIRST(byte)) {\n    if (len < 4)\n      return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(4-len);\n    if (UTF16_IS_SURROGATE_SECOND(p[3]))\n      return ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4);\n  }\n  return ONIGENC_CONSTRUCT_MBCLEN_INVALID();\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":427214,"func":"static void forstat (LexState *ls, int line) {\n  \/* forstat -> FOR (fornum | forlist) END *\/\n  FuncState *fs = ls->fs;\n  TString *varname;\n  BlockCnt bl;\n  enterblock(fs, &bl, 1);  \/* scope for loop and control variables *\/\n  luaX_next(ls);  \/* skip 'for' *\/\n  varname = str_checkname(ls);  \/* first variable name *\/\n  switch (ls->t.token) {\n    case '=': fornum(ls, varname, line); break;\n    case ',': case TK_IN: forlist(ls, varname); break;\n    default: luaX_syntaxerror(ls, \"'=' or 'in' expected\");\n  }\n  check_match(ls, TK_END, TK_FOR, line);\n  leaveblock(fs);  \/* loop scope ('break' jumps to this point) *\/\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":465847,"func":"static int nfcmrvl_nci_fw_download(struct nci_dev *ndev,\n\t\t\t\t   const char *firmware_name)\n{\n\treturn nfcmrvl_fw_dnld_start(ndev, firmware_name);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":389693,"func":"typval_tostring(typval_T *arg, int quotes)\n{\n    char_u\t*tofree;\n    char_u\tnumbuf[NUMBUFLEN];\n    char_u\t*ret = NULL;\n\n    if (arg == NULL)\n\treturn vim_strsave((char_u *)\"(does not exist)\");\n    if (!quotes && arg->v_type == VAR_STRING)\n    {\n\tret = vim_strsave(arg->vval.v_string == NULL ? (char_u *)\"\"\n\t\t\t\t\t\t\t : arg->vval.v_string);\n    }\n    else\n    {\n\tret = tv2string(arg, &tofree, numbuf, 0);\n\t\/\/ Make a copy if we have a value but it's not in allocated memory.\n\tif (ret != NULL && tofree == NULL)\n\t    ret = vim_strsave(ret);\n    }\n    return ret;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":353150,"func":"void SplashOutputDev::updateStrokeOverprint(GfxState *state) {\n  splash->setStrokeOverprint(state->getStrokeOverprint());\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":317191,"func":"static __init void init_smack_known_list(void)\n{\n\t\/*\n\t * Initialize rule list locks\n\t *\/\n\tmutex_init(&smack_known_huh.smk_rules_lock);\n\tmutex_init(&smack_known_hat.smk_rules_lock);\n\tmutex_init(&smack_known_floor.smk_rules_lock);\n\tmutex_init(&smack_known_star.smk_rules_lock);\n\tmutex_init(&smack_known_web.smk_rules_lock);\n\t\/*\n\t * Initialize rule lists\n\t *\/\n\tINIT_LIST_HEAD(&smack_known_huh.smk_rules);\n\tINIT_LIST_HEAD(&smack_known_hat.smk_rules);\n\tINIT_LIST_HEAD(&smack_known_star.smk_rules);\n\tINIT_LIST_HEAD(&smack_known_floor.smk_rules);\n\tINIT_LIST_HEAD(&smack_known_web.smk_rules);\n\t\/*\n\t * Create the known labels list\n\t *\/\n\tsmk_insert_entry(&smack_known_huh);\n\tsmk_insert_entry(&smack_known_hat);\n\tsmk_insert_entry(&smack_known_star);\n\tsmk_insert_entry(&smack_known_floor);\n\tsmk_insert_entry(&smack_known_web);\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":256155,"func":"    TensorInfoCache() : lock(), entries() {}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":328844,"func":"R_API void r_bin_java_print_float_cp_summary(RBinJavaCPTypeObj *obj) {\n\tut8 *b = NULL;\n\tif (!obj) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaCPTypeObj*  Double.\\n\");\n\t\treturn;\n\t}\n\tb = obj->info.cp_float.bytes.raw;\n\tprintf (\"Float ConstantPool Type (%d) \", obj->metas->ord);\n\tprintf (\"  Offset: 0x%08\"PFMT64x \"\", obj->file_offset);\n\tprintf (\"  Bytes = %02x %02x %02x %02x\\n\", b[0], b[1], b[2], b[3]);\n\tprintf (\"  Float = %f\\n\", R_BIN_JAVA_FLOAT (obj->info.cp_float.bytes.raw, 0));\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":225030,"func":"PQfreeCancel(PGcancel *cancel)\n{\n\tif (cancel)\n\t\tfree(cancel);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":281058,"func":"int __xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk)\n{\n\tconst struct xfrm_policy *p;\n\tstruct xfrm_policy *np;\n\tint i, ret = 0;\n\n\trcu_read_lock();\n\tfor (i = 0; i < 2; i++) {\n\t\tp = rcu_dereference(osk->sk_policy[i]);\n\t\tif (p) {\n\t\t\tnp = clone_policy(p, i);\n\t\t\tif (unlikely(!np)) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\trcu_assign_pointer(sk->sk_policy[i], np);\n\t\t}\n\t}\n\trcu_read_unlock();\n\treturn ret;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":512321,"func":"longlong Item_func_like::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  DBUG_ASSERT(escape != ESCAPE_NOT_INITIALIZED);\n  String* res= args[0]->val_str(&cmp_value1);\n  if (args[0]->null_value)\n  {\n    null_value=1;\n    return 0;\n  }\n  String* res2= args[1]->val_str(&cmp_value2);\n  if (args[1]->null_value)\n  {\n    null_value=1;\n    return 0;\n  }\n  null_value=0;\n  if (canDoTurboBM)\n    return turboBM_matches(res->ptr(), res->length()) ? !negated : negated;\n  return my_wildcmp(cmp_collation.collation,\n\t\t    res->ptr(),res->ptr()+res->length(),\n\t\t    res2->ptr(),res2->ptr()+res2->length(),\n\t\t    escape,wild_one,wild_many) ? negated : !negated;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":225669,"func":"GF_Box *padb_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_PaddingBitsBox, GF_ISOM_BOX_TYPE_PADB);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":247359,"func":"rpmRC pgpVerifySig(pgpDig dig, DIGEST_CTX hashctx)\n{\n    if (dig == NULL || hashctx == NULL)\n\treturn RPMRC_FAIL;\n\n    return pgpVerifySignature(pgpDigGetParams(dig, PGPTAG_PUBLIC_KEY),\n\t\t\t      pgpDigGetParams(dig, PGPTAG_SIGNATURE), hashctx);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":274890,"func":"TEST(ComparisonsTest, QuantizedInt8LessWithBroadcast) {\n  const float kMin = -127.f;\n  const float kMax = 127.f;\n  std::vector<std::vector<int>> test_shapes = {\n      {6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};\n  for (int i = 0; i < test_shapes.size(); ++i) {\n    ComparisonOpModel model({TensorType_INT8, test_shapes[i], kMin, kMax},\n                            {TensorType_INT8, {}, kMin, kMax}, TensorType_INT8,\n                            BuiltinOperator_LESS);\n    model.QuantizeAndPopulate<int8_t>(model.input1(), {20, -2, -71, 8, 11, 20});\n    model.QuantizeAndPopulate<int8_t>(model.input2(), {8});\n    model.Invoke();\n    EXPECT_THAT(model.GetOutput(),\n                ElementsAre(false, true, true, false, false, false))\n        << \"With shape number \" << i;\n  }\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":256449,"func":"JANET_CORE_FN(cfun_array_new,\n              \"(array\/new capacity)\",\n              \"Creates a new empty array with a pre-allocated capacity. The same as \"\n              \"`(array)` but can be more efficient if the maximum size of an array is known.\") {\n    janet_fixarity(argc, 1);\n    int32_t cap = janet_getinteger(argv, 0);\n    JanetArray *array = janet_array(cap);\n    return janet_wrap_array(array);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":484757,"func":"static void netback_changed(struct xenbus_device *dev,\n\t\t\t    enum xenbus_state backend_state)\n{\n\tstruct netfront_info *np = dev_get_drvdata(&dev->dev);\n\tstruct net_device *netdev = np->netdev;\n\n\tdev_dbg(&dev->dev, \"%s\\n\", xenbus_strstate(backend_state));\n\n\twake_up_all(&module_wq);\n\n\tswitch (backend_state) {\n\tcase XenbusStateInitialising:\n\tcase XenbusStateInitialised:\n\tcase XenbusStateReconfiguring:\n\tcase XenbusStateReconfigured:\n\tcase XenbusStateUnknown:\n\t\tbreak;\n\n\tcase XenbusStateInitWait:\n\t\tif (dev->state != XenbusStateInitialising)\n\t\t\tbreak;\n\t\tif (xennet_connect(netdev) != 0)\n\t\t\tbreak;\n\t\txenbus_switch_state(dev, XenbusStateConnected);\n\t\tbreak;\n\n\tcase XenbusStateConnected:\n\t\tnetdev_notify_peers(netdev);\n\t\tbreak;\n\n\tcase XenbusStateClosed:\n\t\tif (dev->state == XenbusStateClosed)\n\t\t\tbreak;\n\t\tfallthrough;\t\/* Missed the backend's CLOSING state *\/\n\tcase XenbusStateClosing:\n\t\txenbus_frontend_closed(dev);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":512811,"func":"  uint cols() const { return arg_count; }","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":513350,"func":"bool Item_func_eq::check_equality(THD *thd, COND_EQUAL *cond_equal,\n                                  List<Item> *eq_list)\n{\n  Item *left_item= arguments()[0];\n  Item *right_item= arguments()[1];\n\n  if (left_item->type() == Item::ROW_ITEM &&\n      right_item->type() == Item::ROW_ITEM)\n  {\n    return check_row_equality(thd,\n                              cmp.subcomparators(),\n                              (Item_row *) left_item,\n                              (Item_row *) right_item,\n                              cond_equal, eq_list);\n  }\n  return check_simple_equality(thd,\n                               Context(ANY_SUBST,\n                                       compare_type(),\n                                       compare_collation()),\n                               left_item, right_item, cond_equal);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":216800,"func":"rpa_read_buffer(pool_t pool, const unsigned char **data,\n\t\tconst unsigned char *end, unsigned char **buffer)\n{\n\tconst unsigned char *p = *data;\n\tunsigned int len;\n\n\tif (p > end)\n\t\treturn 0;\n\n\tlen = *p++;\n\tif (p + len > end)\n\t\treturn 0;\n\n\t*buffer = p_malloc(pool, len);\n\tmemcpy(*buffer, p, len);\n\n\t*data += 1 + len;\n\n\treturn len;\n}","target":1,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":294717,"func":"c_weeknum_to_jd(int y, int w, int d, int f, double sg, int *rjd, int *ns)\n{\n    int rjd2, ns2;\n\n    c_find_fdoy(y, sg, &rjd2, &ns2);\n    rjd2 += 6;\n    *rjd = (rjd2 - MOD(((rjd2 - f) + 1), 7) - 7) + 7 * w + d;\n    *ns = (*rjd < sg) ? 0 : 1;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":244151,"func":"void chnl_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":432212,"func":"void cpu_watchpoint_remove_all(CPUState *cpu, int mask)\n{\n#if 0\n    CPUWatchpoint *wp, *next;\n\n    QTAILQ_FOREACH_SAFE(wp, &cpu->watchpoints, entry, next) {\n        if (wp->flags & mask) {\n            cpu_watchpoint_remove_by_ref(cpu, wp);\n        }\n    }\n#endif\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":175685,"func":"  virtual void ConnectToCellularNetwork(const CellularNetwork* network) {}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":359518,"func":"DEFUN (bgp_bestpath_compare_router_id,\n       bgp_bestpath_compare_router_id_cmd,\n       \"bgp bestpath compare-routerid\",\n       \"BGP specific commands\\n\"\n       \"Change the default bestpath selection\\n\"\n       \"Compare router-id for identical EBGP paths\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":313797,"func":"handle_tabmenu(void)\n{\n    switch (current_tabmenu)\n    {\n\tcase TABLINE_MENU_CLOSE:\n\t    if (current_tab == 0)\n\t\tdo_cmdline_cmd((char_u *)\"tabclose\");\n\t    else\n\t    {\n\t\tvim_snprintf((char *)IObuff, IOSIZE, \"tabclose %d\",\n\t\t\t\t\t\t\t\t current_tab);\n\t\tdo_cmdline_cmd(IObuff);\n\t    }\n\t    break;\n\n\tcase TABLINE_MENU_NEW:\n\t    if (current_tab == 0)\n\t\tdo_cmdline_cmd((char_u *)\"$tabnew\");\n\t    else\n\t    {\n\t\tvim_snprintf((char *)IObuff, IOSIZE, \"%dtabnew\",\n\t\t\t\t\t\t\t     current_tab - 1);\n\t\tdo_cmdline_cmd(IObuff);\n\t    }\n\t    break;\n\n\tcase TABLINE_MENU_OPEN:\n\t    if (current_tab == 0)\n\t\tdo_cmdline_cmd((char_u *)\"browse $tabnew\");\n\t    else\n\t    {\n\t\tvim_snprintf((char *)IObuff, IOSIZE, \"browse %dtabnew\",\n\t\t\t\t\t\t\t     current_tab - 1);\n\t\tdo_cmdline_cmd(IObuff);\n\t    }\n\t    break;\n    }\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":276896,"func":"static int cmd_i2c_set_bus_num(unsigned int busnum)\n{\n\tstruct udevice *bus;\n\tint ret;\n\n\tret = uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus);\n\tif (ret) {\n\t\tdebug(\"%s: No bus %d\\n\", __func__, busnum);\n\t\treturn ret;\n\t}\n\ti2c_cur_bus = bus;\n\n\treturn 0;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":273077,"func":"log_fatal_err(int domain, const char *func, int line, int err)\n{\n  DPRINTF(E_FATAL, domain, \"%s failed at line %d, error %d (%s)\\n\", func, line, err, strerror(err));\n  abort();\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":221667,"func":"long Socket::checkCertValid(String &hostname)\n{\n    \/\/check we have a certificate\n    X509 *peerCert = SSL_get_peer_certificate(ssl);\n    if (peerCert == NULL) {\n        return -1;\n    }\n    X509_free(peerCert);\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n#else\n\/\/ section for openssl1.1\nX509_VERIFY_PARAM *param;\nparam = X509_VERIFY_PARAM_new() ;\nX509_VERIFY_PARAM_set1_host(param,hostname.c_str(), hostname.length());\nSSL_CTX_set1_param(ctx,param);\nX509_VERIFY_PARAM_free(param);\n#endif\n    return SSL_get_verify_result(ssl);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":248252,"func":"DLLIMPORT void *cfg_getptr(cfg_t *cfg, const char *name)\n{\n\treturn cfg_getnptr(cfg, name, 0);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":418780,"func":"is_mouse_key(int c)\n{\n    return c == K_LEFTMOUSE\n\t|| c == K_LEFTMOUSE_NM\n\t|| c == K_LEFTDRAG\n\t|| c == K_LEFTRELEASE\n\t|| c == K_LEFTRELEASE_NM\n\t|| c == K_MOUSEMOVE\n\t|| c == K_MIDDLEMOUSE\n\t|| c == K_MIDDLEDRAG\n\t|| c == K_MIDDLERELEASE\n\t|| c == K_RIGHTMOUSE\n\t|| c == K_RIGHTDRAG\n\t|| c == K_RIGHTRELEASE\n\t|| c == K_MOUSEDOWN\n\t|| c == K_MOUSEUP\n\t|| c == K_MOUSELEFT\n\t|| c == K_MOUSERIGHT\n\t|| c == K_X1MOUSE\n\t|| c == K_X1DRAG\n\t|| c == K_X1RELEASE\n\t|| c == K_X2MOUSE\n\t|| c == K_X2DRAG\n\t|| c == K_X2RELEASE;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":317149,"func":"static int smack_kernel_create_files_as(struct cred *new,\n\t\t\t\t\tstruct inode *inode)\n{\n\tstruct inode_smack *isp = smack_inode(inode);\n\tstruct task_smack *tsp = smack_cred(new);\n\n\ttsp->smk_forked = isp->smk_inode;\n\ttsp->smk_task = tsp->smk_forked;\n\treturn 0;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":462540,"func":"void controller::update_visible_feeds() {\n\tstd::lock_guard<std::mutex> feedslock(feeds_mutex);\n\tv->update_visible_feeds(feeds);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":230972,"func":"mrb_ci_bidx(mrb_callinfo *ci)\n{\n  return mrb_bidx(ci->n|(ci->nk<<4));\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":417059,"func":"mp_sint32 PlayerGeneric::getNumMaxVirChannels() const\n{\n#ifndef MILKYTRACKER\n\tif (player)\n\t{\n\t\tif (player->getType() == PlayerBase::PlayerType_IT)\n\t\t{\n\t\t\treturn static_cast<PlayerIT*>(player)->getNumMaxVirChannels();\n\t\t}\n\t}\n#endif\n\treturn numMaxVirChannels;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":498618,"func":"bgr2rgb (guchar       *dest,\n         const guchar *src,\n         guint         width,\n         guint         bytes,\n         guint         alpha)\n{\n  guint x;\n\n  if (alpha)\n    {\n      for (x = 0; x < width; x++)\n        {\n          *(dest++) = src[2];\n          *(dest++) = src[1];\n          *(dest++) = src[0];\n          *(dest++) = src[3];\n\n          src += bytes;\n        }\n    }\n  else\n    {\n      for (x = 0; x < width; x++)\n        {\n          *(dest++) = src[2];\n          *(dest++) = src[1];\n          *(dest++) = src[0];\n\n          src += bytes;\n        }\n    }\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":272333,"func":"encode_algorithm_id(cms_context *cms, SECItem *der, SECOidTag tag)\n{\n\tSECAlgorithmID id;\n\n\tint rc = generate_algorithm_id(cms, &id, tag);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tvoid *ret;\n\tret = SEC_ASN1EncodeItem(cms->arena, der, &id,\n\t\t\t\t\t\tSECOID_AlgorithmIDTemplate);\n\tif (ret == NULL)\n\t\tcnreterr(-1, cms, \"could not encode Algorithm ID\");\n\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":175787,"func":"  GatherGlobalUsageTask(\n      UsageTracker* tracker,\n      QuotaClient* client)\n      : GatherUsageTaskBase(tracker, client),\n        client_(client),\n        callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {\n    DCHECK(tracker);\n    DCHECK(client);\n  }\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":225385,"func":"static inline void set_done(struct v4l2l_buffer *buffer)\n{\n\tbuffer->buffer.flags &= ~V4L2_BUF_FLAG_QUEUED;\n\tbuffer->buffer.flags |= V4L2_BUF_FLAG_DONE;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":294556,"func":"c_valid_weeknum_p(int y, int w, int d, int f, double sg,\n\t\t  int *rw, int *rd, int *rjd, int *ns)\n{\n    int ns2, ry2, rw2, rd2;\n\n    if (d < 0)\n\td += 7;\n    if (w < 0) {\n\tint rjd2;\n\n\tc_weeknum_to_jd(y + 1, 1, f, f, sg, &rjd2, &ns2);\n\tc_jd_to_weeknum(rjd2 + w * 7, f, sg, &ry2, &rw2, &rd2);\n\tif (ry2 != y)\n\t    return 0;\n\tw = rw2;\n    }\n    c_weeknum_to_jd(y, w, d, f, sg, rjd, ns);\n    c_jd_to_weeknum(*rjd, f, sg, &ry2, rw, rd);\n    if (y != ry2 || w != *rw || d != *rd)\n\treturn 0;\n    return 1;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":400724,"func":"void iov_iter_pipe(struct iov_iter *i, unsigned int direction,\n\t\t\tstruct pipe_inode_info *pipe,\n\t\t\tsize_t count)\n{\n\tBUG_ON(direction != READ);\n\tWARN_ON(pipe_full(pipe->head, pipe->tail, pipe->ring_size));\n\t*i = (struct iov_iter){\n\t\t.iter_type = ITER_PIPE,\n\t\t.data_source = false,\n\t\t.pipe = pipe,\n\t\t.head = pipe->head,\n\t\t.start_head = pipe->head,\n\t\t.iov_offset = 0,\n\t\t.count = count\n\t};\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":376345,"func":"gpg_import_keys_sync (CamelCipherContext *context,\n                      CamelStream *istream,\n                      GCancellable *cancellable,\n                      GError **error)\n{\n\tstruct _GpgCtx *gpg;\n\tgboolean success = FALSE;\n\n\tgpg = gpg_ctx_new (context);\n\tgpg_ctx_set_mode (gpg, GPG_CTX_MODE_IMPORT);\n\tgpg_ctx_set_istream (gpg, istream);\n\n\tif (!gpg_ctx_op_start (gpg, error))\n\t\tgoto fail;\n\n\twhile (!gpg_ctx_op_complete (gpg)) {\n\t\tif (gpg_ctx_op_step (gpg, cancellable, error) == -1) {\n\t\t\tgpg_ctx_op_cancel (gpg);\n\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tif (gpg_ctx_op_wait (gpg) != 0) {\n\t\tconst gchar *diagnostics;\n\n\t\tdiagnostics = gpg_ctx_get_diagnostics (gpg);\n\t\tg_set_error (\n\t\t\terror, CAMEL_ERROR, CAMEL_ERROR_GENERIC, \"%s\",\n\t\t\t(diagnostics != NULL && *diagnostics != '\\0') ?\n\t\t\tdiagnostics : _(\"Failed to execute gpg.\"));\n\t\tgoto fail;\n\t}\n\n\tsuccess = TRUE;\nfail:\n\tgpg_ctx_free (gpg);\n\n\treturn success;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":234805,"func":"int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,\n\t\t\t u64 *start, u64 *len)\n{\n\t\/* FIXME use last free of some kind *\/\n\treturn find_free_dev_extent_start(device, num_bytes, 0, start, len);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":282969,"func":"LJ_NOINLINE void lj_err_lex(lua_State *L, GCstr *src, const char *tok,\n\t\t\t    BCLine line, ErrMsg em, va_list argp)\n{\n  char buff[LUA_IDSIZE];\n  const char *msg;\n  lj_debug_shortname(buff, src);\n  msg = lj_str_pushvf(L, err2msg(em), argp);\n  msg = lj_str_pushf(L, \"%s:%d: %s\", buff, line, msg);\n  if (tok)\n    lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok);\n  lj_err_throw(L, LUA_ERRSYNTAX);\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":139212,"func":"void OverlayWindowViews::Close() {\n  views::Widget::Close();\n}\n","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":231743,"func":"TEST_F(QuicServerTransportTest, TestRegisterAndHandleTransportKnobParams) {\n  int flag = 0;\n  server->registerKnobParamHandler(\n      199, [&](QuicServerConnectionState* \/* server_conn *\/, uint64_t val) {\n        EXPECT_EQ(val, 10);\n        flag = 1;\n      });\n  server->registerKnobParamHandler(\n      200,\n      [&](QuicServerConnectionState* \/* server_conn *\/, uint64_t \/* val *\/) {\n        flag = 2;\n      });\n  server->handleKnobParams({\n      {199, 10},\n      {201, 20},\n  });\n\n  EXPECT_EQ(flag, 1);\n\n  \/\/ ovewrite will fail, the new handler won't be called\n  server->registerKnobParamHandler(\n      199, [&](QuicServerConnectionState* \/* server_conn *\/, uint64_t val) {\n        EXPECT_EQ(val, 30);\n        flag = 3;\n      });\n\n  server->handleKnobParams({\n      {199, 10},\n      {201, 20},\n  });\n  EXPECT_EQ(flag, 1);\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":512372,"func":"bool Item_func_not::fix_fields(THD *thd, Item **ref)\n{\n  args[0]->under_not(this);\n  if (args[0]->type() == FIELD_ITEM)\n  {\n    \/* replace  \"NOT <field>\" with \"<field> == 0\" *\/\n    Query_arena backup, *arena;\n    Item *new_item;\n    bool rc= TRUE;\n    arena= thd->activate_stmt_arena_if_needed(&backup);\n    if ((new_item= new (thd->mem_root) Item_func_eq(thd, args[0], new (thd->mem_root) Item_int(thd, 0, 1))))\n    {\n      new_item->name= name;\n      rc= (*ref= new_item)->fix_fields(thd, ref);\n    }\n    if (arena)\n      thd->restore_active_arena(arena, &backup);\n    return rc;\n  }\n  return Item_func::fix_fields(thd, ref);\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":270386,"func":"static inline uint32_t ok_inflater_read_bits(ok_inflater *inflater, unsigned int num_bits) {\n    uint32_t ans = inflater->input_buffer & ((1 << num_bits) - 1);\n    inflater->input_buffer >>= num_bits;\n    inflater->input_buffer_bits -= num_bits;\n    return ans;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":294600,"func":"m_local_df_in_day(union DateData *x)\n{\n    return isec_to_day(m_local_df(x));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":512337,"func":"  Item *in_subq_field_transformer_for_having(THD *thd, uchar *arg)\n  { return convert_to_basic_const_item(thd); }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512940,"func":"  virtual bool is_fixed() const { return true; }","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":329880,"func":"_pixman_image_add_tristrip (pixman_image_t *image,\n\t\t\t    int dst_x, int dst_y,\n\t\t\t    cairo_tristrip_t *strip)\n{\n    pixman_triangle_t tri;\n    pixman_point_fixed_t *p[3] = {&tri.p1, &tri.p2, &tri.p3 };\n    int n;\n\n    set_point (p[0], &strip->points[0]);\n    set_point (p[1], &strip->points[1]);\n    set_point (p[2], &strip->points[2]);\n    pixman_add_triangles (image, -dst_x, -dst_y, 1, &tri);\n    for (n = 3; n < strip->num_points; n++) {\n\tset_point (p[n%3], &strip->points[n]);\n\tpixman_add_triangles (image, -dst_x, -dst_y, 1, &tri);\n    }\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":219989,"func":"int callback_glewlwyd_get_user_middleware_module_list (const struct _u_request * request, struct _u_response * response, void * user_middleware_data) {\n  UNUSED(request);\n  struct config_elements * config = (struct config_elements *)user_middleware_data;\n  json_t * j_module;\n  \n  j_module = get_user_middleware_module_list(config);\n  if (check_result_value(j_module, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module, \"module\"));\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_user_middleware_module_list - Error get_user_middleware_module_list\");\n    response->status = 500;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":219972,"func":"int callback_glewlwyd_server_configuration (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  UNUSED(request);\n  \n  json_t * json_body = json_pack(\"{ssssssss}\", \n                                 \"api_prefix\", \n                                 ((struct config_elements *)user_data)->api_prefix,\n                                 \"admin_scope\",\n                                 ((struct config_elements *)user_data)->admin_scope,\n                                 \"profile_scope\",\n                                 ((struct config_elements *)user_data)->profile_scope,\n                                 \"delete_profile\",\n                                 ((struct config_elements *)user_data)->delete_profile==GLEWLWYD_PROFILE_DELETE_UNAUTHORIZED?\"no\":\"yes\");\n  ulfius_set_json_body_response(response, 200, json_body);\n  json_decref(json_body);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":282990,"func":"static void err_raise_ext(int errcode)\n{\n  RaiseException(LJ_EXCODE_MAKE(errcode), 1 \/* EH_NONCONTINUABLE *\/, 0, NULL);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":359508,"func":"DEFUN (no_bgp_bestpath_aspath_ignore,\n       no_bgp_bestpath_aspath_ignore_cmd,\n       \"no bgp bestpath as-path ignore\",\n       NO_STR\n       \"BGP specific commands\\n\"\n       \"Change the default bestpath selection\\n\"\n       \"AS-path attribute\\n\"\n       \"Ignore as-path length in selecting a route\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":291779,"func":"int rtrs_clt_rdma_cq_direct(struct rtrs_clt_sess *clt, unsigned int index)\n{\n\t\/* If no path, return -1 for block layer not to try again *\/\n\tint cnt = -1;\n\tstruct rtrs_con *con;\n\tstruct rtrs_clt_path *clt_path;\n\tstruct path_it it;\n\n\trcu_read_lock();\n\tfor (path_it_init(&it, clt);\n\t     (clt_path = it.next_path(&it)) && it.i < it.clt->paths_num; it.i++) {\n\t\tif (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED)\n\t\t\tcontinue;\n\n\t\tcon = clt_path->s.con[index + 1];\n\t\tcnt = ib_process_cq_direct(con->cq, -1);\n\t\tif (cnt)\n\t\t\tbreak;\n\t}\n\tpath_it_deinit(&it);\n\trcu_read_unlock();\n\n\treturn cnt;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":513325,"func":"int safe_index_read(JOIN_TAB *tab)\n{\n  int error;\n  TABLE *table= tab->table;\n  if ((error= table->file->ha_index_read_map(table->record[0],\n                                             tab->ref.key_buff,\n                                             make_prev_keypart_map(tab->ref.key_parts),\n                                             HA_READ_KEY_EXACT)))\n    return report_error(table, error);\n  return 0;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":384802,"func":"hex2nr(int c)\n{\n    if (c >= 'a' && c <= 'f')\n\treturn c - 'a' + 10;\n    if (c >= 'A' && c <= 'F')\n\treturn c - 'A' + 10;\n    return c - '0';\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":310181,"func":"_nc_do_color(int old_pair, int pair, int reverse, NCURSES_OUTC outc)\n{\n    SetSafeOutcWrapper(outc);\n    NCURSES_SP_NAME(_nc_do_color) (CURRENT_SCREEN,\n\t\t\t\t   old_pair,\n\t\t\t\t   pair,\n\t\t\t\t   reverse,\n\t\t\t\t   _nc_outc_wrapper);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":244120,"func":"GF_Err emsg_box_size(GF_Box *s)\n{\n\tGF_EventMessageBox *ptr = (GF_EventMessageBox*) s;\n\n\tif (ptr->version) {\n\t\tptr->size += 20;\n\t} else {\n\t\tptr->size += 16;\n\t}\n\tptr->size+=2; \/\/1 NULL-terminated strings\n\tif (ptr->scheme_id_uri) ptr->size += strlen(ptr->scheme_id_uri);\n\tif (ptr->value) ptr->size += strlen(ptr->value);\n\tif (ptr->message_data)\n\t\tptr->size += ptr->message_data_size;\n\n\treturn GF_OK;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":385887,"func":"SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode)\n{\n\treturn sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":404711,"func":"\t__acquires(files->file_lock)\n{\n\tstruct fdtable *fdt;\n\tint expanded = 0;\n\nrepeat:\n\tfdt = files_fdtable(files);\n\n\t\/* Do we need to expand? *\/\n\tif (nr < fdt->max_fds)\n\t\treturn expanded;\n\n\t\/* Can we expand? *\/\n\tif (nr >= sysctl_nr_open)\n\t\treturn -EMFILE;\n\n\tif (unlikely(files->resize_in_progress)) {\n\t\tspin_unlock(&files->file_lock);\n\t\texpanded = 1;\n\t\twait_event(files->resize_wait, !files->resize_in_progress);\n\t\tspin_lock(&files->file_lock);\n\t\tgoto repeat;\n\t}\n\n\t\/* All good, so we try *\/\n\tfiles->resize_in_progress = true;\n\texpanded = expand_fdtable(files, nr);\n\tfiles->resize_in_progress = false;\n\n\twake_up_all(&files->resize_wait);\n\treturn expanded;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":238615,"func":"static struct btf *find_kfunc_desc_btf(struct bpf_verifier_env *env,\n\t\t\t\t       u32 func_id, s16 offset,\n\t\t\t\t       struct module **btf_modp)\n{\n\tif (offset) {\n\t\tif (offset < 0) {\n\t\t\t\/* In the future, this can be allowed to increase limit\n\t\t\t * of fd index into fd_array, interpreted as u16.\n\t\t\t *\/\n\t\t\tverbose(env, \"negative offset disallowed for kernel module function call\\n\");\n\t\t\treturn ERR_PTR(-EINVAL);\n\t\t}\n\n\t\treturn __find_kfunc_desc_btf(env, offset, btf_modp);\n\t}\n\treturn btf_vmlinux ?: ERR_PTR(-ENOENT);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":316980,"func":"static int selinux_lsm_notifier_avc_callback(u32 event)\n{\n\tif (event == AVC_CALLBACK_RESET) {\n\t\tsel_ib_pkey_flush();\n\t\tcall_blocking_lsm_notifier(LSM_POLICY_CHANGE, NULL);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":513149,"func":"void plugin_mutex_init()\n{\n#ifdef HAVE_PSI_INTERFACE\n  init_plugin_psi_keys();\n#endif\n  mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":317172,"func":"static void selinux_d_instantiate(struct dentry *dentry, struct inode *inode)\n{\n\tif (inode)\n\t\tinode_doinit_with_dentry(inode, dentry);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":338216,"func":"Expression* WasmBinaryBuilder::getBlockOrSingleton(Type type) {\n  Name label = getNextLabel();\n  breakStack.push_back({label, type});\n  auto start = expressionStack.size();\n\n  processExpressions();\n  size_t end = expressionStack.size();\n  if (end < start) {\n    throwError(\"block cannot pop from outside\");\n  }\n  breakStack.pop_back();\n  auto* block = allocator.alloc<Block>();\n  pushBlockElements(block, type, start);\n  block->name = label;\n  block->finalize(type);\n  \/\/ maybe we don't need a block here?\n  if (breakTargetNames.find(block->name) == breakTargetNames.end() &&\n      exceptionTargetNames.find(block->name) == exceptionTargetNames.end()) {\n    block->name = Name();\n    if (block->list.size() == 1) {\n      return block->list[0];\n    }\n  }\n  breakTargetNames.erase(block->name);\n  return block;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":253538,"func":"smb2_is_read_op(__u32 oplock)\n{\n\treturn oplock == SMB2_OPLOCK_LEVEL_II;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":226156,"func":"\nGF_Box *trun_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackFragmentRunBox, GF_ISOM_BOX_TYPE_TRUN);\n\t\/\/NO FLAGS SET BY DEFAULT\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":226237,"func":"GF_Err sdp_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 length;\n\tGF_SDPBox *ptr = (GF_SDPBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\n\tlength = (u32) (ptr->size);\n\n\tif (length >= (u32)0xFFFFFFFF) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid length %lu in sdp box\\n\", length));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\t\/\/sdp text has no delimiter !!!\n\tptr->sdpText = (char*)gf_malloc(sizeof(char) * (length+1));\n\tif (!ptr->sdpText) return GF_OUT_OF_MEM;\n\n\tgf_bs_read_data(bs, ptr->sdpText, length);\n\tptr->sdpText[length] = 0;\n\treturn GF_OK;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":281126,"func":"struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp)\n{\n\tstruct xfrm_policy *policy;\n\n\tpolicy = kzalloc(sizeof(struct xfrm_policy), gfp);\n\n\tif (policy) {\n\t\twrite_pnet(&policy->xp_net, net);\n\t\tINIT_LIST_HEAD(&policy->walk.all);\n\t\tINIT_HLIST_NODE(&policy->bydst);\n\t\tINIT_HLIST_NODE(&policy->byidx);\n\t\trwlock_init(&policy->lock);\n\t\trefcount_set(&policy->refcnt, 1);\n\t\tskb_queue_head_init(&policy->polq.hold_queue);\n\t\tsetup_timer(&policy->timer, xfrm_policy_timer,\n\t\t\t\t(unsigned long)policy);\n\t\tsetup_timer(&policy->polq.hold_timer, xfrm_policy_queue_process,\n\t\t\t    (unsigned long)policy);\n\t\tpolicy->flo.ops = &xfrm_policy_fc_ops;\n\t}\n\treturn policy;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":222841,"func":"  bool SameShapes(ShapeHandle inferred_shape,\n                  ShapeHandle annotated_shape) const {\n    if (inferred_shape.SameHandle(annotated_shape)) {\n      return true;\n    }\n    if (InferenceContext::Rank(inferred_shape) !=\n        InferenceContext::Rank(annotated_shape)) {\n      return false;\n    }\n    const int rank = InferenceContext::Rank(inferred_shape);\n    for (int i = 0; i < rank; ++i) {\n      int64_t val1 = InferenceContext::Value(\n          InferenceContext::DimKnownRank(inferred_shape, i));\n      int64_t val2 = InferenceContext::Value(\n          InferenceContext::DimKnownRank(annotated_shape, i));\n      if (val1 != val2) {\n        return false;\n      }\n    }\n    return true;\n  }","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":437386,"func":"add_opcode(regex_t* reg, int opcode)\n{\n  BB_ADD1(reg, opcode);\n  return 0;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":259597,"func":"void HierarchicalBitmapRequester::CropEncodingRegion(RectAngle<LONG> ®ion,const struct RectangleRequest *)\n{ \n#if ACCUSOFT_CODE\n  int i;\n\n  ClipToImage(region);\n\n  \/\/ Find the region to request.\n  for(i = 0;i < m_ucCount;i++) {\n    if (m_pulReadyLines[i] < ULONG(region.ra_MinY))\n      region.ra_MinY = m_pulReadyLines[i];\n  }\n#else\n  NOREF(region);\n#endif\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":468350,"func":"g_socket_client_add_application_proxy (GSocketClient *client,\n\t\t\t               const gchar   *protocol)\n{\n  g_hash_table_add (client->priv->app_proxies, g_strdup (protocol));\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":139236,"func":"void OverlayWindowViews::OnNativeWidgetDestroyed() {\n  controller_->OnWindowDestroyed();\n}\n","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":90225,"func":"  virtual bool wifi_available() const { return false; }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":512504,"func":"  void set_geometry_type(uint type)\n  {\n    DBUG_ASSERT(0);\n  }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":276977,"func":"    void AddReference() {\n        ++m_ReferenceCount;\n    }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":240588,"func":"  void Compute(OpKernelContext* context) override {\n    core::RefCountPtr<Var> variable;\n    OP_REQUIRES_OK(context, LookupResource(context, HandleFromInput(context, 0),\n                                           &variable));\n\n    const Tensor& value = context->input(1);\n    \/\/ TODO(apassos): We could possibly avoid the copy done by\n    \/\/ PrepareToUpdateVariable() for commutative operations like Op ==\n    \/\/ ADD if value's refcount was 1.\n    mutex_lock ml(*variable->mu());\n    Tensor* var_tensor = variable->tensor();\n    OP_REQUIRES(context, var_tensor->shape().IsSameSize(value.shape()),\n                errors::InvalidArgument(\"Cannot update variable with shape \",\n                                        var_tensor->shape().DebugString(),\n                                        \" using a Tensor with shape \",\n                                        value.shape().DebugString(),\n                                        \", shapes must be equal.\"));\n    OP_REQUIRES_OK(\n        context, PrepareToUpdateVariable<Device, T>(\n                     context, var_tensor, variable->copy_on_read_mode.load()));\n    functor::DenseUpdate<Device, T, Op> update_functor;\n    update_functor(context->eigen_device<Device>(), var_tensor->flat<T>(),\n                   value.flat<T>());\n  }","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":512461,"func":"  ValueBuffer()\n  {\n    reset_buffer();\n  }","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":267981,"func":"R_API bool r_bin_file_set_cur_by_fd(RBin *bin, ut32 bin_fd) {\n\tRBinFile *bf = r_bin_file_find_by_fd (bin, bin_fd);\n\treturn bf? r_bin_file_set_cur_binfile (bin, bf): false;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":90139,"func":"std::string CellularNetwork::GetActivationStateString() const {\n  return ActivationStateToString(this->activation_state_);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":441806,"func":"SProcXkbGetNamedIndicator(ClientPtr client)\n{\n    REQUEST(xkbGetNamedIndicatorReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq);\n    swaps(&stuff->deviceSpec);\n    swaps(&stuff->ledClass);\n    swaps(&stuff->ledID);\n    swapl(&stuff->indicator);\n    return ProcXkbGetNamedIndicator(client);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":356695,"func":"void Statement::Work_BeginRun(Baton* baton) {\n    STATEMENT_BEGIN(Run);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":317142,"func":"static void selinux_cred_getsecid(const struct cred *c, u32 *secid)\n{\n\t*secid = cred_sid(c);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":101696,"func":"void WebProcessProxy::removeMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID)\n{\n    m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);\n}\n","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":387808,"func":"void InstanceKlass::rewrite_class(TRAPS) {\n  assert(is_loaded(), \"must be loaded\");\n  if (is_rewritten()) {\n    assert(is_shared(), \"rewriting an unshared class?\");\n    return;\n  }\n  Rewriter::rewrite(this, CHECK);\n  set_rewritten();\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":384113,"func":"raptor_free_xml_writer(raptor_xml_writer* xml_writer)\n{\n  if(!xml_writer)\n    return;\n\n  if(xml_writer->nstack && xml_writer->my_nstack)\n    raptor_free_namespaces(xml_writer->nstack);\n\n  raptor_object_options_clear(&xml_writer->options);\n  \n  RAPTOR_FREE(raptor_xml_writer, xml_writer);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":379664,"func":"R_API void r_anal_function_delete_unused_vars(RAnalFunction *fcn) {\n\tr_return_if_fail (fcn);\n\tvoid **v;\n\tRPVector *vars_clone = (RPVector *)r_vector_clone ((RVector *)&fcn->vars);\n\tr_pvector_foreach (vars_clone, v) {\n\t\tRAnalVar *var = *v;\n\t\tif (r_vector_empty (&var->accesses)) {\n\t\t\tr_anal_function_delete_var (fcn, var);\n\t\t}\n\t}\n\tr_pvector_free (vars_clone);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":427200,"func":"static void whilestat (LexState *ls, int line) {\n  \/* whilestat -> WHILE cond DO block END *\/\n  FuncState *fs = ls->fs;\n  int whileinit;\n  int condexit;\n  BlockCnt bl;\n  luaX_next(ls);  \/* skip WHILE *\/\n  whileinit = luaK_getlabel(fs);\n  condexit = cond(ls);\n  enterblock(fs, &bl, 1);\n  checknext(ls, TK_DO);\n  block(ls);\n  luaK_jumpto(fs, whileinit);\n  check_match(ls, TK_END, TK_WHILE, line);\n  leaveblock(fs);\n  luaK_patchtohere(fs, condexit);  \/* false conditions finish the loop *\/\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":196834,"func":"Status SparseCountSparseOutputShapeFn(InferenceContext *c) {\n  auto rank = c->Dim(c->input(0), 1);\n  auto nvals = c->UnknownDim();\n  c->set_output(0, c->Matrix(nvals, rank));  \/\/ out.indices\n  c->set_output(1, c->Vector(nvals));        \/\/ out.values\n  c->set_output(2, c->Vector(rank));         \/\/ out.dense_shape\n  return Status::OK();\n}","target":1,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":512260,"func":"Item *Item_bool_rowready_func2::neg_transformer(THD *thd)\n{\n  Item *item= negated_item(thd);\n  return item;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":359379,"func":"DEFUN (no_neighbor_capability_dynamic,\n       no_neighbor_capability_dynamic_cmd,\n       NO_NEIGHBOR_CMD2 \"capability dynamic\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Advertise capability to the peer\\n\"\n       \"Advertise dynamic capability to this neighbor\\n\")\n{\n  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":214364,"func":"void simplestring_addn(simplestring* target, const char* source, int add_len) {\n   if(target && source) {\n      if(!target->str) {\n         simplestring_init_str(target);\n      }\n      if(target->len + add_len + 1 > target->size) {\n         \/* newsize is current length + new length *\/\n         int newsize = target->len + add_len + 1;\n         int incr = target->size * 2;\n\n         \/* align to SIMPLESTRING_INCR increments *\/\n         newsize = newsize - (newsize % incr) + incr;\n         target->str = (char*)realloc(target->str, newsize);\n\n         target->size = target->str ? newsize : 0;\n      }\n\n      if(target->str) {\n         if(add_len) {\n            memcpy(target->str + target->len, source, add_len);\n         }\n         target->len += add_len;\n         target->str[target->len] = 0; \/* null terminate *\/\n      }\n   }\n}","target":1,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":508869,"func":"static int find_keyword(Lex_input_stream *lip, uint len, bool function)\n{\n  const char *tok= lip->get_tok_start();\n\n  SYMBOL *symbol= get_hash_symbol(tok, len, function);\n  if (symbol)\n  {\n    lip->yylval->symbol.symbol=symbol;\n    lip->yylval->symbol.str= (char*) tok;\n    lip->yylval->symbol.length=len;\n\n    if ((symbol->tok == NOT_SYM) &&\n        (lip->m_thd->variables.sql_mode & MODE_HIGH_NOT_PRECEDENCE))\n      return NOT2_SYM;\n    if ((symbol->tok == OR_OR_SYM) &&\n\t!(lip->m_thd->variables.sql_mode & MODE_PIPES_AS_CONCAT))\n      return OR2_SYM;\n\n    return symbol->tok;\n  }\n  return 0;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":224167,"func":"  std::size_t size() {\n    tensorflow::mutex_lock lock(mu_);\n    return map_.size();\n  }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":233813,"func":"int fmtutil_is_standard_iff_chunk(deark *c, struct de_iffctx *ictx,\n\tu32 ct)\n{\n\tswitch(ct) {\n\tcase CODE__c_:\n\tcase CODE_ANNO:\n\tcase CODE_AUTH:\n\tcase CODE_NAME:\n\tcase CODE_TEXT:\n\t\treturn 1;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":516252,"func":"static int virtio_net_tx_waiting_pre_load(void *opaque)\n{\n    struct VirtIONetMigTmp *tmp = opaque;\n\n    \/* Reuse the pointer setup from save *\/\n    virtio_net_tx_waiting_pre_save(opaque);\n\n    if (tmp->parent->curr_queues > tmp->parent->max_queues) {\n        error_report(\"virtio-net: curr_queues %x > max_queues %x\",\n            tmp->parent->curr_queues, tmp->parent->max_queues);\n\n        return -EINVAL;\n    }\n\n    return 0; \/* all good *\/\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":427730,"func":"cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)\n{\n\tsize_t i;\n\n\tfor (i = 0; i < __arraycount(vn); i++)\n\t\tif (vn[i].v == p)\n\t\t\treturn snprintf(buf, bufsiz, \"%s\", vn[i].n);\n\treturn snprintf(buf, bufsiz, \"%#x\", p);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":484814,"func":"static void xennet_bus_close(struct xenbus_device *dev)\n{\n\tint ret;\n\n\tif (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed)\n\t\treturn;\n\tdo {\n\t\txenbus_switch_state(dev, XenbusStateClosing);\n\t\tret = wait_event_timeout(module_wq,\n\t\t\t\t   xenbus_read_driver_state(dev->otherend) ==\n\t\t\t\t   XenbusStateClosing ||\n\t\t\t\t   xenbus_read_driver_state(dev->otherend) ==\n\t\t\t\t   XenbusStateClosed ||\n\t\t\t\t   xenbus_read_driver_state(dev->otherend) ==\n\t\t\t\t   XenbusStateUnknown,\n\t\t\t\t   XENNET_TIMEOUT);\n\t} while (!ret);\n\n\tif (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed)\n\t\treturn;\n\n\tdo {\n\t\txenbus_switch_state(dev, XenbusStateClosed);\n\t\tret = wait_event_timeout(module_wq,\n\t\t\t\t   xenbus_read_driver_state(dev->otherend) ==\n\t\t\t\t   XenbusStateClosed ||\n\t\t\t\t   xenbus_read_driver_state(dev->otherend) ==\n\t\t\t\t   XenbusStateUnknown,\n\t\t\t\t   XENNET_TIMEOUT);\n\t} while (!ret);\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":226355,"func":"\nGF_Box *stri_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SubTrackInformationBox, GF_ISOM_BOX_TYPE_STRI);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":244261,"func":"GF_Err trik_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_TrickPlayBox *ptr = (GF_TrickPlayBox *) s;\n\tptr->entry_count = (u32) ptr->size;\n\tif ((u64)ptr->entry_count > (u64)SIZE_MAX\/sizeof(GF_TrickPlayBoxEntry)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid size %llu in trik\\n\", ptr->size));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tptr->entries = (GF_TrickPlayBoxEntry *) gf_malloc(ptr->entry_count * sizeof(GF_TrickPlayBoxEntry) );\n\tif (!ptr->entries) return GF_OUT_OF_MEM;\n\n\tfor (i=0; i< ptr->entry_count; i++) {\n\t\tptr->entries[i].pic_type = gf_bs_read_int(bs, 2);\n\t\tptr->entries[i].dependency_level = gf_bs_read_int(bs, 6);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":401585,"func":"static int proc_do_uuid(struct ctl_table *table, int write,\n\t\t\tvoid *buffer, size_t *lenp, loff_t *ppos)\n{\n\tstruct ctl_table fake_table;\n\tunsigned char buf[64], tmp_uuid[16], *uuid;\n\n\tuuid = table->data;\n\tif (!uuid) {\n\t\tuuid = tmp_uuid;\n\t\tgenerate_random_uuid(uuid);\n\t} else {\n\t\tstatic DEFINE_SPINLOCK(bootid_spinlock);\n\n\t\tspin_lock(&bootid_spinlock);\n\t\tif (!uuid[8])\n\t\t\tgenerate_random_uuid(uuid);\n\t\tspin_unlock(&bootid_spinlock);\n\t}\n\n\tsprintf(buf, \"%pU\", uuid);\n\n\tfake_table.data = buf;\n\tfake_table.maxlen = sizeof(buf);\n\n\treturn proc_dostring(&fake_table, write, buffer, lenp, ppos);\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":329915,"func":"_cairo_image_spans (void *abstract_renderer,\n\t\t    int y, int height,\n\t\t    const cairo_half_open_span_t *spans,\n\t\t    unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n    uint8_t *mask, *row;\n    int len;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    mask = r->u.mask.data + (y - r->u.mask.extents.y) * r->u.mask.stride;\n    mask += spans[0].x - r->u.mask.extents.x;\n    row = mask;\n\n    do {\n\tlen = spans[1].x - spans[0].x;\n\tif (spans[0].coverage) {\n\t    *row++ = r->opacity * spans[0].coverage;\n\t    if (--len)\n\t\tmemset (row, row[-1], len);\n\t}\n\trow += len;\n\tspans++;\n    } while (--num_spans > 1);\n\n    len = row - mask;\n    row = mask;\n    while (--height) {\n\tmask += r->u.mask.stride;\n\tmemcpy (mask, row, len);\n    }\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":292211,"func":"inbound_upart (server *serv, char *chan, char *ip, char *reason,\n\t\t\t\t\tconst message_tags_data *tags_data)\n{\n\tsession *sess = find_channel (serv, chan);\n\tif (sess)\n\t{\n\t\tif (*reason)\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_UPARTREASON, sess, serv->nick, ip, chan,\n\t\t\t\t\t\t\t\t\t\t  reason, 0, tags_data->timestamp);\n\t\telse\n\t\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_UPART, sess, serv->nick, ip, chan, NULL,\n\t\t\t\t\t\t\t\t\t\t  0, tags_data->timestamp);\n\t\tclear_channel (sess);\n\t}\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":222494,"func":"  Status AddItem(const string& name, const NameInfoItem& item) {\n    if (!index_.insert({name, item}).second) {\n      return errors::InvalidArgument(\n          strings::StrCat(\"Duplicated \", item.is_func_arg ? \"arg\" : \"ret\",\n                          \" name: \"),\n          name);\n    }\n    return Status::OK();\n  }","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":482473,"func":"_lou_getCharForDots(widechar d, const DisplayTableHeader *table) {\n\tCharDotsMapping *cdPtr = getCharForDots(d, table);\n\tif (cdPtr) return cdPtr->found;\n\treturn '\\0';\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":369270,"func":"\nstatic struct io_rsrc_node *io_rsrc_node_alloc(void)\n{\n\tstruct io_rsrc_node *ref_node;\n\n\tref_node = kzalloc(sizeof(*ref_node), GFP_KERNEL);\n\tif (!ref_node)\n\t\treturn NULL;\n\n\tif (percpu_ref_init(&ref_node->refs, io_rsrc_node_ref_zero,\n\t\t\t    0, GFP_KERNEL)) {\n\t\tkfree(ref_node);\n\t\treturn NULL;\n\t}\n\tINIT_LIST_HEAD(&ref_node->node);\n\tINIT_LIST_HEAD(&ref_node->rsrc_list);\n\tref_node->done = false;\n\treturn ref_node;","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":491961,"func":"__acquires(&fc->lock)\n{\n\tstruct fuse_inode *fi = get_fuse_inode(req->inode);\n\tloff_t size = i_size_read(req->inode);\n\tstruct fuse_write_in *inarg = &req->misc.write.in;\n\n\tif (!fc->connected)\n\t\tgoto out_free;\n\n\tif (inarg->offset + PAGE_CACHE_SIZE <= size) {\n\t\tinarg->size = PAGE_CACHE_SIZE;\n\t} else if (inarg->offset < size) {\n\t\tinarg->size = size & (PAGE_CACHE_SIZE - 1);\n\t} else {\n\t\t\/* Got truncated off completely *\/\n\t\tgoto out_free;\n\t}\n\n\treq->in.args[1].size = inarg->size;\n\tfi->writectr++;\n\tfuse_request_send_background_locked(fc, req);\n\treturn;\n\n out_free:\n\tfuse_writepage_finish(fc, req);\n\tspin_unlock(&fc->lock);\n\tfuse_writepage_free(fc, req);\n\tfuse_put_request(fc, req);\n\tspin_lock(&fc->lock);\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":252332,"func":"int IsEXR(const char *filename) {\n  EXRVersion exr_version;\n\n  int ret = ParseEXRVersionFromFile(&exr_version, filename);\n  if (ret != TINYEXR_SUCCESS) {\n    return TINYEXR_ERROR_INVALID_HEADER;\n  }\n\n  return TINYEXR_SUCCESS;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":369233,"func":"static int io_msg_ring_prep(struct io_kiocb *req,\n\t\t\t    const struct io_uring_sqe *sqe)\n{\n\tif (unlikely(sqe->addr || sqe->ioprio || sqe->rw_flags ||\n\t\t     sqe->splice_fd_in || sqe->buf_index || sqe->personality))\n\t\treturn -EINVAL;\n\n\treq->msg.user_data = READ_ONCE(sqe->off);\n\treq->msg.len = READ_ONCE(sqe->len);\n\treturn 0;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":393538,"func":"static SQInteger base_callee(HSQUIRRELVM v)\n{\n    if(v->_callsstacksize > 1)\n    {\n        v->Push(v->_callsstack[v->_callsstacksize - 2]._closure);\n        return 1;\n    }\n    return sq_throwerror(v,_SC(\"no closure in the calls stack\"));\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":219012,"func":"Status ConstantFolding::EvaluateNode(const NodeDef& node,\n                                     const TensorVector& inputs,\n                                     TensorVector* output) const {\n  return ::tensorflow::grappler::EvaluateNode(node, inputs, cpu_device_,\n                                              resource_mgr_.get(), output);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":455393,"func":"xfs_inode_ag_iterator_flags(\n\tstruct xfs_mount\t*mp,\n\tint\t\t\t(*execute)(struct xfs_inode *ip, int flags,\n\t\t\t\t\t   void *args),\n\tint\t\t\tflags,\n\tvoid\t\t\t*args,\n\tint\t\t\titer_flags)\n{\n\tstruct xfs_perag\t*pag;\n\tint\t\t\terror = 0;\n\tint\t\t\tlast_error = 0;\n\txfs_agnumber_t\t\tag;\n\n\tag = 0;\n\twhile ((pag = xfs_perag_get(mp, ag))) {\n\t\tag = pag->pag_agno + 1;\n\t\terror = xfs_inode_ag_walk(mp, pag, execute, flags, args, -1,\n\t\t\t\t\t  iter_flags);\n\t\txfs_perag_put(pag);\n\t\tif (error) {\n\t\t\tlast_error = error;\n\t\t\tif (error == -EFSCORRUPTED)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn last_error;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":336593,"func":"void RedCharDeviceVDIPort::send_tokens_to_client(RedCharDeviceClientOpaque *opaque, uint32_t tokens)\n{\n    RedClient *client = (RedClient *) opaque;\n    client->get_main()->push_agent_tokens(tokens);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":253613,"func":"smb2_can_echo(struct TCP_Server_Info *server)\n{\n\treturn server->echoes;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":313823,"func":"nv_open(cmdarg_T *cap)\n{\n#ifdef FEAT_DIFF\n    \/\/ \"do\" is \":diffget\"\n    if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'o')\n    {\n\tclearop(cap->oap);\n\tnv_diffgetput(FALSE, cap->opcount);\n    }\n    else\n#endif\n    if (VIsual_active)  \/\/ switch start and end of visual\n\tv_swap_corners(cap->cmdchar);\n#ifdef FEAT_JOB_CHANNEL\n    else if (bt_prompt(curbuf))\n\tclearopbeep(cap->oap);\n#endif\n    else\n\tn_opencmd(cap);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":476143,"func":"void composite_disconnect(struct usb_gadget *gadget)\n{\n\tusb_gadget_vbus_draw(gadget, 0);\n\t__composite_disconnect(gadget);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":313746,"func":"nv_ctrlh(cmdarg_T *cap)\n{\n    if (VIsual_active && VIsual_select)\n    {\n\tcap->cmdchar = 'x';\t\/\/ BS key behaves like 'x' in Select mode\n\tv_visop(cap);\n    }\n    else\n\tnv_left(cap);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":389745,"func":"check_for_opt_string_or_number_arg(typval_T *args, int idx)\n{\n    return (args[idx].v_type == VAR_UNKNOWN\n\t    || check_for_string_or_number_arg(args, idx) != FAIL);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":244170,"func":"GF_Box *ssix_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SubsegmentIndexBox, GF_ISOM_BOX_TYPE_SSIX);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":310025,"func":"_nc_screen_init(void)\n{\n    NCURSES_SP_NAME(_nc_screen_init) (CURRENT_SCREEN);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":243983,"func":"GF_Err sdtp_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_SampleDependencyTypeBox *ptr = (GF_SampleDependencyTypeBox*)s;\n\n\t\/*out-of-order sdtp, assume no padding at the end*\/\n\tif (!ptr->sampleCount) ptr->sampleCount = (u32) ptr->size;\n\telse if (ptr->sampleCount > (u32) ptr->size) return GF_ISOM_INVALID_FILE;\n\n\tptr->sample_info = (u8 *) gf_malloc(sizeof(u8)*ptr->sampleCount);\n\tif (!ptr->sample_info) return GF_OUT_OF_MEM;\n\tptr->sample_alloc = ptr->sampleCount;\n\tgf_bs_read_data(bs, (char*)ptr->sample_info, ptr->sampleCount);\n\tISOM_DECREASE_SIZE(ptr, ptr->sampleCount);\n\treturn GF_OK;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":224172,"func":"      TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {\n    if (tuple[index].has_value()) {\n      return errors::InvalidArgument(\"The tensor for index '\", index,\n                                     \"' for key '\", key.scalar<int64_t>()(),\n                                     \"' was already initialized '\",\n                                     dtypes_.size(), \"'.\");\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":404719,"func":"int receive_fd(struct file *file, unsigned int o_flags)\n{\n\treturn __receive_fd(file, NULL, o_flags);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":226375,"func":"GF_Err unkn_box_size(GF_Box *s)\n{\n\tGF_UnknownBox *ptr = (GF_UnknownBox *)s;\n\n\tif (ptr->dataSize && ptr->data) {\n\t\tptr->size += ptr->dataSize;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":275484,"func":"njs_vm_value_buffer_set(njs_vm_t *vm, njs_value_t *value, const u_char *start,\n    uint32_t size)\n{\n    return njs_buffer_set(vm, value, start, size);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":401534,"func":"static void process_random_ready_list(void)\n{\n\tunsigned long flags;\n\tstruct random_ready_callback *rdy, *tmp;\n\n\tspin_lock_irqsave(&random_ready_list_lock, flags);\n\tlist_for_each_entry_safe(rdy, tmp, &random_ready_list, list) {\n\t\tstruct module *owner = rdy->owner;\n\n\t\tlist_del_init(&rdy->list);\n\t\trdy->func(rdy);\n\t\tmodule_put(owner);\n\t}\n\tspin_unlock_irqrestore(&random_ready_list_lock, flags);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":357677,"func":"SQClass::SQClass(SQSharedState *ss,SQClass *base)\n{\n    _base = base;\n    _typetag = 0;\n    _hook = NULL;\n    _udsize = 0;\n    _locked = false;\n    _constructoridx = -1;\n    if(_base) {\n        _constructoridx = _base->_constructoridx;\n        _udsize = _base->_udsize;\n        _defaultvalues.copy(base->_defaultvalues);\n        _methods.copy(base->_methods);\n        _COPY_VECTOR(_metamethods,base->_metamethods,MT_LAST);\n        __ObjAddRef(_base);\n    }\n    _members = base?base->_members->Clone() : SQTable::Create(ss,0);\n    __ObjAddRef(_members);\n\n    INIT_CHAIN();\n    ADD_TO_CHAIN(&_sharedstate->_gc_chain, this);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":317325,"func":"static inline u16 inode_mode_to_security_class(umode_t mode)\n{\n\tswitch (mode & S_IFMT) {\n\tcase S_IFSOCK:\n\t\treturn SECCLASS_SOCK_FILE;\n\tcase S_IFLNK:\n\t\treturn SECCLASS_LNK_FILE;\n\tcase S_IFREG:\n\t\treturn SECCLASS_FILE;\n\tcase S_IFBLK:\n\t\treturn SECCLASS_BLK_FILE;\n\tcase S_IFDIR:\n\t\treturn SECCLASS_DIR;\n\tcase S_IFCHR:\n\t\treturn SECCLASS_CHR_FILE;\n\tcase S_IFIFO:\n\t\treturn SECCLASS_FIFO_FILE;\n\n\t}\n\n\treturn SECCLASS_FILE;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":263297,"func":"off_t _q_iosend(FILE *outfp, FILE *infp, off_t nbytes) {\n    if (nbytes == 0) return 0;\n\n    unsigned char buf[QIOSEND_CHUNK_SIZE];\n    off_t total = 0; \/\/ total size sent\n    while (total < nbytes) {\n        size_t chunksize; \/\/ this time sending size\n        if (nbytes - total <= sizeof(buf)) chunksize = nbytes - total;\n        else chunksize = sizeof(buf);\n\n        \/\/ read\n        size_t rsize = fread(buf, 1, chunksize, infp);\n        if (rsize == 0) break;\n        DEBUG(\"read %zu\", rsize);\n\n        \/\/ write\n        size_t wsize = fwrite(buf, 1, rsize, outfp);\n        if (wsize == 0) break;\n        DEBUG(\"write %zu\", wsize);\n\n        total += wsize;\n        if (rsize != wsize) {\n            DEBUG(\"size mismatch. read:%zu, write:%zu\", rsize, wsize);\n            break;\n        }\n    }\n\n    if (total > 0) return total;\n    return -1;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":393497,"func":"static SQInteger closure_acall(HSQUIRRELVM v)\n{\n    return _closure_acall(v,SQTrue);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":90176,"func":"  virtual void RemoveNetworkObserver(const std::string& service_path,\n                                     NetworkObserver* observer) {\n    DCHECK(observer);\n    DCHECK(service_path.size());\n    NetworkObserverMap::iterator map_iter =\n        network_observers_.find(service_path);\n    if (map_iter != network_observers_.end()) {\n      map_iter->second->RemoveObserver(observer);\n      if (!map_iter->second->size()) {\n        delete map_iter->second;\n        network_observers_.erase(map_iter++);\n      }\n    }\n  }\n","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":376335,"func":"gpg_ctx_set_ostream (struct _GpgCtx *gpg,\n                     CamelStream *ostream)\n{\n\tg_object_ref (ostream);\n\tif (gpg->ostream)\n\t\tg_object_unref (gpg->ostream);\n\tgpg->ostream = ostream;\n\tgpg->seen_eof1 = FALSE;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":226181,"func":"\nGF_Err strk_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_SubTrackBox *ptr = (GF_SubTrackBox *)s;\n\te = gf_isom_box_array_read(s, bs);\n\tif (e) return e;\n\n\tif (!ptr->info) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing SubTrackInformationBox\\n\"));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":384679,"func":"check_string (uint32_t option, char *buf, uint32_t len, uint32_t maxlen,\n              const char *name)\n{\n  if (len > NBD_MAX_STRING || len > maxlen) {\n    nbdkit_error (\"%s: %s too long\", name_of_nbd_opt (option), name);\n    return -1;\n  }\n  if (strnlen (buf, len) != len) {\n    nbdkit_error (\"%s: %s may not include NUL bytes\",\n                  name_of_nbd_opt (option), name);\n    return -1;\n  }\n  \/* TODO: Check for valid UTF-8? *\/\n  return 0;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":509527,"func":"int ha_maria::multi_range_read_explain_info(uint mrr_mode, char *str,\n                                            size_t size)\n{\n  return ds_mrr.dsmrr_explain_info(mrr_mode, str, size);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":483491,"func":"u64 __init efi_mem_desc_end(efi_memory_desc_t *md)\n{\n\tu64 size = md->num_pages << EFI_PAGE_SHIFT;\n\tu64 end = md->phys_addr + size;\n\treturn end;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":412330,"func":"static Sdb *get_sdb(RzBinFile *bf) {\n\tRzBinObject *o = bf->o;\n\tif (!o) {\n\t\treturn NULL;\n\t}\n\tQnxObj *qo = o->bin_obj;\n\treturn qo ? qo->kv : NULL;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":401564,"func":"static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs)\n{\n\t__u32 *ptr = (__u32 *) regs;\n\tunsigned int idx;\n\n\tif (regs == NULL)\n\t\treturn 0;\n\tidx = READ_ONCE(f->reg_idx);\n\tif (idx >= sizeof(struct pt_regs) \/ sizeof(__u32))\n\t\tidx = 0;\n\tptr += idx++;\n\tWRITE_ONCE(f->reg_idx, idx);\n\treturn *ptr;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":291838,"func":"static int rtrs_clt_ib_dev_init(struct rtrs_ib_dev *dev)\n{\n\tif (!(dev->ib_dev->attrs.device_cap_flags &\n\t      IB_DEVICE_MEM_MGT_EXTENSIONS)) {\n\t\tpr_err(\"Memory registrations not supported.\\n\");\n\t\treturn -ENOTSUPP;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":225448,"func":"static ssize_t attr_show_format(struct device *cd,\n\t\t\t\tstruct device_attribute *attr, char *buf)\n{\n\t\/* gets the current format as \"FOURCC:WxH@f\/s\", e.g. \"YUYV:320x240@1000\/30\" *\/\n\tstruct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd);\n\tconst struct v4l2_fract *tpf;\n\tchar buf4cc[5], buf_fps[32];\n\n\tif (!dev || !dev->ready_for_capture)\n\t\treturn 0;\n\ttpf = &dev->capture_param.timeperframe;\n\n\tfourcc2str(dev->pix_format.pixelformat, buf4cc);\n\tbuf4cc[4] = 0;\n\tif (tpf->numerator == 1)\n\t\tsnprintf(buf_fps, sizeof(buf_fps), \"%d\", tpf->denominator);\n\telse\n\t\tsnprintf(buf_fps, sizeof(buf_fps), \"%d\/%d\", tpf->denominator,\n\t\t\t tpf->numerator);\n\treturn sprintf(buf, \"%4s:%dx%d@%s\\n\", buf4cc, dev->pix_format.width,\n\t\t       dev->pix_format.height, buf_fps);\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":294471,"func":"datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n    if (!NIL_P(opt)) argc--;\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"Mon, 01 Jan -4712 00:00:00 GMT\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        argv2[1] = opt;\n        if (!NIL_P(opt)) argc2++;\n\tVALUE hash = date_s__httpdate(argc2, argv2, klass);\n\treturn dt_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":462257,"func":"PJ_DEF(pj_status_t) pj_stun_msg_add_attr(pj_stun_msg *msg,\n\t\t\t\t\t pj_stun_attr_hdr *attr)\n{\n    PJ_ASSERT_RETURN(msg && attr, PJ_EINVAL);\n    PJ_ASSERT_RETURN(msg->attr_count < PJ_STUN_MAX_ATTR, PJ_ETOOMANY);\n\n    msg->attr[msg->attr_count++] = attr;\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":195389,"func":"bool RepeatedAttrDefEqual(\n    const protobuf::RepeatedPtrField<OpDef::AttrDef>& a1,\n    const protobuf::RepeatedPtrField<OpDef::AttrDef>& a2) {\n  std::unordered_map<string, const OpDef::AttrDef*> a1_set;\n  for (const OpDef::AttrDef& def : a1) {\n    DCHECK(a1_set.find(def.name()) == a1_set.end())\n        << \"AttrDef names must be unique, but '\" << def.name()\n        << \"' appears more than once\";\n    a1_set[def.name()] = &def;\n  }\n  for (const OpDef::AttrDef& def : a2) {\n    auto iter = a1_set.find(def.name());\n    if (iter == a1_set.end()) return false;\n    if (!AttrDefEqual(*iter->second, def)) return false;\n    a1_set.erase(iter);\n  }\n  if (!a1_set.empty()) return false;\n  return true;\n}","target":1,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":484747,"func":"static void xennet_get_ethtool_stats(struct net_device *dev,\n\t\t\t\t     struct ethtool_stats *stats, u64 * data)\n{\n\tvoid *np = netdev_priv(dev);\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(xennet_stats); i++)\n\t\tdata[i] = atomic_read((atomic_t *)(np + xennet_stats[i].offset));\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":277481,"func":"uint32_t mobi_get_orth_entry_offset(const MOBIIndexEntry *entry) {\n\n    uint32_t entry_startpos;\n    MOBI_RET ret = mobi_get_indxentry_tagvalue(&entry_startpos, entry, INDX_TAG_ORTH_POSITION);\n    if (ret != MOBI_SUCCESS) {\n        return MOBI_NOTSET;\n    }\n    \n    return entry_startpos;\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":252443,"func":"static int rleUncompress(int inLength, int maxLength, const signed char in[],\n                         char out[]) {\n  char *outStart = out;\n\n  while (inLength > 0) {\n    if (*in < 0) {\n      int count = -(static_cast<int>(*in++));\n      inLength -= count + 1;\n\n      \/\/ Fixes #116: Add bounds check to in buffer.\n      if ((0 > (maxLength -= count)) || (inLength < 0)) return 0;\n\n      memcpy(out, in, count);\n      out += count;\n      in += count;\n    } else {\n      int count = *in++;\n      inLength -= 2;\n\n      if (0 > (maxLength -= count + 1)) return 0;\n\n      memset(out, *reinterpret_cast<const char *>(in), count + 1);\n      out += count + 1;\n\n      in++;\n    }\n  }\n\n  return static_cast<int>(out - outStart);\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":424923,"func":"void iwl_pcie_apm_stop_master(struct iwl_trans *trans)\n{\n\tint ret;\n\n\t\/* stop device's busmaster DMA activity *\/\n\tiwl_set_bit(trans, trans->trans_cfg->csr->addr_sw_reset,\n\t\t    BIT(trans->trans_cfg->csr->flag_stop_master));\n\n\tret = iwl_poll_bit(trans, trans->trans_cfg->csr->addr_sw_reset,\n\t\t\t   BIT(trans->trans_cfg->csr->flag_master_dis),\n\t\t\t   BIT(trans->trans_cfg->csr->flag_master_dis), 100);\n\tif (ret < 0)\n\t\tIWL_WARN(trans, \"Master Disable Timed Out, 100 usec\\n\");\n\n\tIWL_DEBUG_INFO(trans, \"stop master\\n\");\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":310265,"func":"format_versions_list(config_line_t *ln)\n{\n  smartlist_t *versions;\n  char *result;\n  versions = smartlist_create();\n  for ( ; ln; ln = ln->next) {\n    smartlist_split_string(versions, ln->value, \",\",\n                           SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);\n  }\n  sort_version_list(versions, 1);\n  result = smartlist_join_strings(versions,\",\",0,NULL);\n  SMARTLIST_FOREACH(versions,char *,s,tor_free(s));\n  smartlist_free(versions);\n  return result;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":234715,"func":"void __exit btrfs_cleanup_fs_uuids(void)\n{\n\tstruct btrfs_fs_devices *fs_devices;\n\n\twhile (!list_empty(&fs_uuids)) {\n\t\tfs_devices = list_entry(fs_uuids.next,\n\t\t\t\t\tstruct btrfs_fs_devices, fs_list);\n\t\tlist_del(&fs_devices->fs_list);\n\t\tfree_fs_devices(fs_devices);\n\t}\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":400101,"func":"PipeSocketHandler::PipeSocketHandler() {}","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":313560,"func":"void rose_del_loopback_node(const rose_address *address)\n{\n\tstruct rose_node *rose_node;\n\n\tspin_lock_bh(&rose_node_list_lock);\n\n\trose_node = rose_node_list;\n\twhile (rose_node != NULL) {\n\t\tif ((rose_node->mask == 10) &&\n\t\t    (rosecmpm(address, &rose_node->address, 10) == 0) &&\n\t\t    rose_node->loopback)\n\t\t\tbreak;\n\t\trose_node = rose_node->next;\n\t}\n\n\tif (rose_node == NULL)\n\t\tgoto out;\n\n\trose_remove_node(rose_node);\n\n\trose_loopback_neigh->count--;\n\nout:\n\tspin_unlock_bh(&rose_node_list_lock);\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":312418,"func":"vgr_jump_to_match(\n\tqf_info_T   *qi,\n\tint\t    forceit,\n\tint\t    *redraw_for_dummy,\n\tbuf_T\t    *first_match_buf,\n\tchar_u\t    *target_dir)\n{\n    buf_T\t*buf;\n\n    buf = curbuf;\n    qf_jump(qi, 0, 0, forceit);\n    if (buf != curbuf)\n\t\/\/ If we jumped to another buffer redrawing will already be\n\t\/\/ taken care of.\n\t*redraw_for_dummy = FALSE;\n\n    \/\/ Jump to the directory used after loading the buffer.\n    if (curbuf == first_match_buf && target_dir != NULL)\n    {\n\texarg_T ea;\n\n\tCLEAR_FIELD(ea);\n\tea.arg = target_dir;\n\tea.cmdidx = CMD_lcd;\n\tex_cd(&ea);\n    }\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":222570,"func":"Status GetOpGradientCreator(const string& op, Creator* creator) {\n  auto fac = GetOpGradFactory();\n  auto iter = fac->find(op);\n  if (iter == fac->end()) {\n    return errors::NotFound(\"No gradient defined for op: \", op);\n  }\n  *creator = iter->second;\n  return Status::OK();\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":366167,"func":"static struct mountpoint *unhash_mnt(struct mount *mnt)\n{\n\tstruct mountpoint *mp;\n\tmnt->mnt_parent = mnt;\n\tmnt->mnt_mountpoint = mnt->mnt.mnt_root;\n\tlist_del_init(&mnt->mnt_child);\n\thlist_del_init_rcu(&mnt->mnt_hash);\n\thlist_del_init(&mnt->mnt_mp_list);\n\tmp = mnt->mnt_mp;\n\tmnt->mnt_mp = NULL;\n\treturn mp;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":418776,"func":"get_fpos_of_mouse(pos_T *mpos)\n{\n    win_T\t*wp;\n    int\t\trow = mouse_row;\n    int\t\tcol = mouse_col;\n\n    if (row < 0 || col < 0)\t\t\/\/ check if it makes sense\n\treturn IN_UNKNOWN;\n\n    \/\/ find the window where the row is in\n    wp = mouse_find_win(&row, &col, FAIL_POPUP);\n    if (wp == NULL)\n\treturn IN_UNKNOWN;\n    \/\/ winpos and height may change in win_enter()!\n    if (row >= wp->w_height)\t\/\/ In (or below) status line\n\treturn IN_STATUS_LINE;\n    if (col >= wp->w_width)\t\/\/ In vertical separator line\n\treturn IN_SEP_LINE;\n\n    if (wp != curwin)\n\treturn IN_UNKNOWN;\n\n    \/\/ compute the position in the buffer line from the posn on the screen\n    if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL))\n\treturn IN_STATUS_LINE; \/\/ past bottom\n\n    mpos->col = vcol2col(wp, mpos->lnum, col);\n\n    if (mpos->col > 0)\n\t--mpos->col;\n    mpos->coladd = 0;\n    return IN_BUFFER;\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":348436,"func":"static unsigned short calc_crc_flex(unsigned char *cp, int size)\n{\n\tunsigned short crc = 0xffff;\n\n\twhile (size--)\n\t\tcrc = (crc << 8) ^ crc_flex_table[((crc >> 8) ^ *cp++) & 0xff];\n\n\treturn crc;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":450817,"func":"is_dir (char const *filename, int flags, glob_t const *pglob)\n{\n  struct stat st;\n  struct_stat64 st64;\n  return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)\n          ? pglob->gl_stat (filename, &st) == 0 && S_ISDIR (st.st_mode)\n          : __stat64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":246432,"func":"static void free_import_entry(RBinWasmImportEntry *entry) {\n\tif (entry) {\n\t\tfree (entry->module_str);\n\t\tfree (entry->field_str);\n\t\tfree (entry);\n\t}\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":448555,"func":"void bgp_notify_send(struct peer *peer, uint8_t code, uint8_t sub_code)\n{\n\tbgp_notify_send_with_data(peer, code, sub_code, NULL, 0);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":254063,"func":"        query_string(std::string params, bool url = true):\n          url_(std::move(params))\n        {\n            if (url_.empty())\n                return;\n\n            key_value_pairs_.resize(MAX_KEY_VALUE_PAIRS_COUNT);\n\n            int count = qs_parse(&url_[0], &key_value_pairs_[0], MAX_KEY_VALUE_PAIRS_COUNT, url);\n            key_value_pairs_.resize(count);\n        }","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":384904,"func":"vim_isodigit(int c)\n{\n    return (c >= '0' && c <= '7');\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":522330,"func":"int APIF77(gmfstatkwd)( int64_t *MshIdx, int *KwdIdx, int *NmbTyp,\n                        int *SolSiz, int *TypTab,  int *deg, int *NmbNod)\n{\n   if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], \"hr\"))\n      return(GmfStatKwd(*MshIdx, *KwdIdx, NmbTyp, SolSiz, TypTab, deg, NmbNod));\n   else if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], \"sr\"))\n      return(GmfStatKwd(*MshIdx, *KwdIdx, NmbTyp, SolSiz, TypTab));\n   else\n      return(GmfStatKwd(*MshIdx, *KwdIdx));\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":264243,"func":"static void vnc_write_pixels_generic(VncState *vs,\n                                     void *pixels1, int size)\n{\n    uint8_t buf[4];\n\n    if (VNC_SERVER_FB_BYTES == 4) {\n        uint32_t *pixels = pixels1;\n        int n, i;\n        n = size >> 2;\n        for (i = 0; i < n; i++) {\n            vnc_convert_pixel(vs, buf, pixels[i]);\n            vnc_write(vs, buf, vs->client_pf.bytes_per_pixel);\n        }\n    }\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":317003,"func":"static int smack_sem_semctl(struct kern_ipc_perm *isp, int cmd)\n{\n\tint may;\n\n\tswitch (cmd) {\n\tcase GETPID:\n\tcase GETNCNT:\n\tcase GETZCNT:\n\tcase GETVAL:\n\tcase GETALL:\n\tcase IPC_STAT:\n\tcase SEM_STAT:\n\tcase SEM_STAT_ANY:\n\t\tmay = MAY_READ;\n\t\tbreak;\n\tcase SETVAL:\n\tcase SETALL:\n\tcase IPC_RMID:\n\tcase IPC_SET:\n\t\tmay = MAY_READWRITE;\n\t\tbreak;\n\tcase IPC_INFO:\n\tcase SEM_INFO:\n\t\t\/*\n\t\t * System level information\n\t\t *\/\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\treturn smk_curacc_sem(isp, may);\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":219030,"func":"Status ConstantFolding::SimplifyTile(const GraphProperties& properties,\n                                     bool use_shape_info,\n                                     GraphDef* optimized_graph, NodeDef* node) {\n  Tensor multiplies;\n  if (use_shape_info && IsTile(*node) &&\n      GetTensorFromConstNode(node->input(1), &multiplies)) {\n    \/\/ The node is replaceable iff all values in multiplies are 1.\n    bool replaceable = true;\n    if (multiplies.dtype() == DT_INT32) {\n      for (int j = 0; replaceable && j < multiplies.vec<int>().size(); ++j) {\n        replaceable &= multiplies.vec<int>()(j) == 1;\n      }\n    } else {\n      for (int j = 0; replaceable && j < multiplies.vec<int64_t>().size();\n           ++j) {\n        replaceable &= multiplies.vec<int64_t>()(j) == 1;\n      }\n    }\n    if (replaceable) {\n      ReplaceOperationWithIdentity(0, properties, node, optimized_graph);\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":477278,"func":"static void *tipc_aead_mem_alloc(struct crypto_aead *tfm,\n\t\t\t\t unsigned int crypto_ctx_size,\n\t\t\t\t u8 **iv, struct aead_request **req,\n\t\t\t\t struct scatterlist **sg, int nsg)\n{\n\tunsigned int iv_size, req_size;\n\tunsigned int len;\n\tu8 *mem;\n\n\tiv_size = crypto_aead_ivsize(tfm);\n\treq_size = sizeof(**req) + crypto_aead_reqsize(tfm);\n\n\tlen = crypto_ctx_size;\n\tlen += iv_size;\n\tlen += crypto_aead_alignmask(tfm) & ~(crypto_tfm_ctx_alignment() - 1);\n\tlen = ALIGN(len, crypto_tfm_ctx_alignment());\n\tlen += req_size;\n\tlen = ALIGN(len, __alignof__(struct scatterlist));\n\tlen += nsg * sizeof(**sg);\n\n\tmem = kmalloc(len, GFP_ATOMIC);\n\tif (!mem)\n\t\treturn NULL;\n\n\t*iv = (u8 *)PTR_ALIGN(mem + crypto_ctx_size,\n\t\t\t      crypto_aead_alignmask(tfm) + 1);\n\t*req = (struct aead_request *)PTR_ALIGN(*iv + iv_size,\n\t\t\t\t\t\tcrypto_tfm_ctx_alignment());\n\t*sg = (struct scatterlist *)PTR_ALIGN((u8 *)*req + req_size,\n\t\t\t\t\t      __alignof__(struct scatterlist));\n\n\treturn (void *)mem;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":343292,"func":"static int doinitsupgroups(const char *user, const uid_t uid, const gid_t gid)\n{\n#ifndef NON_ROOT_FTP\n# ifdef HAVE_SETGROUPS\n    if (setgroups(1U, &gid) != 0) {\n        return -1;\n    }\n# else\n    (void) gid;\n# endif\n# ifdef HAVE_INITGROUPS\n    if (user == NULL) {\n        const struct passwd * const lpwd = getpwuid(uid);\n\n        if (lpwd != NULL && lpwd->pw_name != NULL) {\n            user = lpwd->pw_name;\n        } else {\n            return 0;\n        }\n    }\n    initgroups(user, gid);\n# else\n    (void) user;\n    (void) uid;\n# endif\n#else\n    (void) user;\n    (void) uid;\n    (void) gid;\n#endif\n    return 0;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":309835,"func":"NCURSES_PUBLIC_VAR(_nc_tputs_trace) (void)\n{\n    return CURRENT_SCREEN ? CURRENT_SCREEN->_tputs_trace : _nc_prescreen._tputs_trace;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":275956,"func":"uECC_VLI_API uECC_word_t uECC_vli_add(uECC_word_t *result,\n                                      const uECC_word_t *left,\n                                      const uECC_word_t *right,\n                                      wordcount_t num_words) {\n    uECC_word_t carry = 0;\n    wordcount_t i;\n    for (i = 0; i < num_words; ++i) {\n        uECC_word_t sum = left[i] + right[i] + carry;\n        if (sum != left[i]) {\n            carry = (sum < left[i]);\n        }\n        result[i] = sum;\n    }\n    return carry;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":294603,"func":"date_s_iso8601(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n    if (!NIL_P(opt)) argc--;\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"-4712-01-01\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        if (!NIL_P(opt)) argv2[argc2++] = opt;\n\tVALUE hash = date_s__iso8601(argc2, argv2, klass);\n\treturn d_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":432349,"func":"static void i2c_ddc_init(Object *obj)\n{\n    I2CDDCState *s = I2CDDC(obj);\n\n    qemu_edid_generate(s->edid_blob, sizeof(s->edid_blob), &s->edid_info);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":218972,"func":"bool ConstantFolding::IsReductionWithConstantIndices(\n    const NodeDef& node, bool* indices_is_empty) const {\n  \/\/ Ensure its an appropriate Reduce node.\n  if (!IsReduction(node) || node.input_size() < 2) {\n    return false;\n  }\n  \/\/ Ensure that the axes to reduce by are constant.\n  NodeDef* reductions_indices = node_map_->GetNode(node.input(1));\n  if (!IsReallyConstant(*reductions_indices) ||\n      !reductions_indices->attr().count(\"value\")) {\n    return false;\n  }\n  const TensorShapeProto& reduction_indices_shape =\n      reductions_indices->attr().at(\"value\").tensor().tensor_shape();\n  *indices_is_empty = TensorShape(reduction_indices_shape).num_elements() == 0;\n  return true;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":463057,"func":"static void sungem_update_masks(SunGEMState *s)\n{\n    uint32_t sz;\n\n    sz = 1 << (((s->rxdmaregs[RXDMA_CFG >> 2] & RXDMA_CFG_RINGSZ) >> 1) + 5);\n    s->rx_mask = sz - 1;\n\n    sz = 1 << (((s->txdmaregs[TXDMA_CFG >> 2] & TXDMA_CFG_RINGSZ) >> 1) + 5);\n    s->tx_mask = sz - 1;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":256398,"func":"int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,\n\t\t    unsigned int len, gfp_t gfp_mask)\n{\n\tint reading = rq_data_dir(rq) == READ;\n\tunsigned long addr = (unsigned long) kbuf;\n\tstruct bio *bio;\n\tint ret;\n\n\tif (len > (queue_max_hw_sectors(q) << 9))\n\t\treturn -EINVAL;\n\tif (!len || !kbuf)\n\t\treturn -EINVAL;\n\n\tif (!blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf) ||\n\t    blk_queue_may_bounce(q))\n\t\tbio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);\n\telse\n\t\tbio = bio_map_kern(q, kbuf, len, gfp_mask);\n\n\tif (IS_ERR(bio))\n\t\treturn PTR_ERR(bio);\n\n\tbio->bi_opf &= ~REQ_OP_MASK;\n\tbio->bi_opf |= req_op(rq);\n\n\tret = blk_rq_append_bio(rq, bio);\n\tif (unlikely(ret))\n\t\tbio_put(bio);\n\treturn ret;\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":398516,"func":"RZ_API void rz_bin_dwarf_line_header_reset_regs(const RzBinDwarfLineHeader *hdr, RzBinDwarfSMRegisters *regs) {\n\trz_return_if_fail(hdr && regs);\n\tregs->address = 0;\n\tregs->file = 1;\n\tregs->line = 1;\n\tregs->column = 0;\n\tregs->is_stmt = hdr->default_is_stmt;\n\tregs->basic_block = DWARF_FALSE;\n\tregs->end_sequence = DWARF_FALSE;\n\tregs->prologue_end = DWARF_FALSE;\n\tregs->epilogue_begin = DWARF_FALSE;\n\tregs->isa = 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":424916,"func":"static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val)\n{\n\twriteb(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":481271,"func":"static void mlx5_fpga_conn_arm_cq(struct mlx5_fpga_conn *conn)\n{\n\tmlx5_cq_arm(&conn->cq.mcq, MLX5_CQ_DB_REQ_NOT,\n\t\t    conn->fdev->conn_res.uar->map, conn->cq.wq.cc);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":226303,"func":"void minf_box_del(GF_Box *s)\n{\n\tGF_MediaInformationBox *ptr = (GF_MediaInformationBox *)s;\n\tif (ptr == NULL) return;\n\n\t\/\/if we have a Handler not self-contained, delete it (the self-contained belongs to the movie)\n\tif (ptr->dataHandler) {\n\t\tgf_isom_datamap_close(ptr);\n\t}\n\tgf_free(ptr);\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":234820,"func":"static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices,\n\t\t\t\t\t    u64 devid, u8 *dev_uuid)\n{\n\tstruct btrfs_device *device;\n\tunsigned int nofs_flag;\n\n\t\/*\n\t * We call this under the chunk_mutex, so we want to use NOFS for this\n\t * allocation, however we don't want to change btrfs_alloc_device() to\n\t * always do NOFS because we use it in a lot of other GFP_KERNEL safe\n\t * places.\n\t *\/\n\tnofs_flag = memalloc_nofs_save();\n\tdevice = btrfs_alloc_device(NULL, &devid, dev_uuid);\n\tmemalloc_nofs_restore(nofs_flag);\n\tif (IS_ERR(device))\n\t\treturn device;\n\n\tlist_add(&device->dev_list, &fs_devices->devices);\n\tdevice->fs_devices = fs_devices;\n\tfs_devices->num_devices++;\n\n\tset_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state);\n\tfs_devices->missing_devices++;\n\n\treturn device;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":359317,"func":"DEFUN (bgp_graceful_restart_stalepath_time,\n       bgp_graceful_restart_stalepath_time_cmd,\n       \"bgp graceful-restart stalepath-time <1-3600>\",\n       \"BGP specific commands\\n\"\n       \"Graceful restart capability parameters\\n\"\n       \"Set the max time to hold onto restarting peer's stale paths\\n\"\n       \"Delay value (seconds)\\n\")\n{\n  struct bgp *bgp;\n  u_int32_t stalepath;\n\n  bgp = vty->index;\n  if (! bgp)\n    return CMD_WARNING;\n\n  VTY_GET_INTEGER_RANGE (\"stalepath-time\", stalepath, argv[0], 1, 3600);\n  bgp->stalepath_time = stalepath;\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":405356,"func":"static struct xfrm_policy *xfrm_policy_lookup(struct net *net,\n\t\t\t\t\t      const struct flowi *fl,\n\t\t\t\t\t      u16 family, u8 dir, u32 if_id)\n{\n#ifdef CONFIG_XFRM_SUB_POLICY\n\tstruct xfrm_policy *pol;\n\n\tpol = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_SUB, fl, family,\n\t\t\t\t\tdir, if_id);\n\tif (pol != NULL)\n\t\treturn pol;\n#endif\n\treturn xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family,\n\t\t\t\t\t dir, if_id);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":175688,"func":"  virtual void EnableWifiNetworkDevice(bool enable) {}\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":244074,"func":"GF_Err sbgp_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tGF_SampleGroupBox *p = (GF_SampleGroupBox*)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, p->grouping_type);\n\tif (p->version==1)\n\t\tgf_bs_write_u32(bs, p->grouping_type_parameter);\n\n\tgf_bs_write_u32(bs, p->entry_count);\n\tfor (i = 0; i<p->entry_count; i++ ) {\n\t\tgf_bs_write_u32(bs, p->sample_entries[i].sample_count);\n\t\tgf_bs_write_u32(bs, p->sample_entries[i].group_description_index);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":369225,"func":"static bool io_cqring_event_overflow(struct io_ring_ctx *ctx, u64 user_data,\n\t\t\t\t     s32 res, u32 cflags)\n{\n\tstruct io_overflow_cqe *ocqe;\n\n\tocqe = kmalloc(sizeof(*ocqe), GFP_ATOMIC | __GFP_ACCOUNT);\n\tif (!ocqe) {\n\t\t\/*\n\t\t * If we're in ring overflow flush mode, or in task cancel mode,\n\t\t * or cannot allocate an overflow entry, then we need to drop it\n\t\t * on the floor.\n\t\t *\/\n\t\tio_account_cq_overflow(ctx);\n\t\treturn false;\n\t}\n\tif (list_empty(&ctx->cq_overflow_list)) {\n\t\tset_bit(0, &ctx->check_cq_overflow);\n\t\tWRITE_ONCE(ctx->rings->sq_flags,\n\t\t\t   ctx->rings->sq_flags | IORING_SQ_CQ_OVERFLOW);\n\n\t}\n\tocqe->cqe.user_data = user_data;\n\tocqe->cqe.res = res;\n\tocqe->cqe.flags = cflags;\n\tlist_add_tail(&ocqe->list, &ctx->cq_overflow_list);\n\treturn true;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":232288,"func":"void SampleInterleavedLSScan::FindComponentDimensions(void)\n{ \n#if ACCUSOFT_CODE\n  UBYTE cx;\n  \n  JPEGLSScan::FindComponentDimensions();\n\n  \/\/\n  \/\/ Check that all MCU dimensions are 1.\n  for(cx = 0;cx < m_ucCount;cx++) {\n    class Component *comp = ComponentOf(cx);\n    if (comp->MCUHeightOf() != 1 || comp->MCUWidthOf() != 1)\n      JPG_THROW(INVALID_PARAMETER,\"SampleInterleavedLSScan::FindComponentDimensions\",\n                \"sample interleaved JPEG LS does not support subsampling\");\n  }\n#endif\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":272353,"func":"match_subject(CERTCertificate *cert, void *cbdatap)\n{\n\tif (!cert->subjectName)\n\t\treturn 0;\n\n\tif (!strcmp(cert->subjectName, (char *)cbdatap))\n\t\treturn 1;\n\n\treturn 0;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":231652,"func":"TEST_F(QuicUnencryptedServerTransportTest, TestUnencryptedStream) {\n  auto data = IOBuf::copyBuffer(\"bad data\");\n  PacketNum nextPacket = clientNextInitialPacketNum++;\n  StreamId streamId = 3;\n  auto initialCipher = getInitialCipher();\n  auto headerCipher = getInitialHeaderCipher();\n  auto packetData = packetToBufCleartext(\n      createStreamPacket(\n          *clientConnectionId,\n          *initialDestinationConnectionId,\n          nextPacket,\n          streamId,\n          *data,\n          initialCipher->getCipherOverhead(),\n          0 \/* largestAcked *\/,\n          std::make_pair(LongHeader::Types::Initial, QuicVersion::MVFST)),\n      *initialCipher,\n      *headerCipher,\n      nextPacket);\n  EXPECT_THROW(deliverData(std::move(packetData)), std::runtime_error);\n  EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":455421,"func":"xfs_reclaim_inodes_count(\n\tstruct xfs_mount\t*mp)\n{\n\tstruct xfs_perag\t*pag;\n\txfs_agnumber_t\t\tag = 0;\n\tint\t\t\treclaimable = 0;\n\n\twhile ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {\n\t\tag = pag->pag_agno + 1;\n\t\treclaimable += pag->pag_ici_reclaimable;\n\t\txfs_perag_put(pag);\n\t}\n\treturn reclaimable;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":487665,"func":"asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid)\n{\n\tint retval;\n\n\tif (!(retval = put_user(current->gid, rgid)) &&\n\t    !(retval = put_user(current->egid, egid)))\n\t\tretval = put_user(current->sgid, sgid);\n\n\treturn retval;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":417055,"func":"mp_sint32 PlayerGeneric::setBufferSize(mp_uint32 bufferSize)\n{\n\tmp_sint32 res = 0;\n\t\n\tthis->bufferSize = bufferSize;\n\t\n\tif (mixer)\n\t{\n\t\t\/\/ If we're told to compensate the samples until we \n\t\t\/\/ we reached 2^n buffer sizes\n\t\tif (compensateBufferFlag)\n\t\t{\n\t\t\tfor (mp_uint32 i = 0; i < 16; i++)\n\t\t\t{\n\t\t\t\tif ((unsigned)(1 << i) >= (unsigned)bufferSize)\n\t\t\t\t{\n\t\t\t\t\tbufferSize = 1 << i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\t\n\t\n\t\tres = mixer->setBufferSize(bufferSize);\n\t}\n\t\n\treturn res;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":328970,"func":"R_API char *r_bin_java_get_item_desc_from_bin_cp_list(RBinJavaObj *bin, RBinJavaCPTypeObj *obj) {\n\t\/*\n\tGiven a constant pool object Class, FieldRef, MethodRef, or InterfaceMethodRef\n\treturn the actual descriptor string.\n\t@param cp_list: RList of RBinJavaCPTypeObj *\n\t@param obj object to look up the name for\n\t@rvalue char* (user frees) or NULL\n\t*\/\n\treturn bin? r_bin_java_get_item_desc_from_cp_item_list (bin->cp_list, obj, MAX_CPITEMS): NULL;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":402588,"func":"print_flag_name(FILE *f, int flag)\n{\n\tfor (int i = 0; flag_names[i].flag != FLAG_LIST_END; i++) {\n\t\tif (flag_names[i].flag == flag)\n\t\t\tfprintf(f, \"%s \", flag_names[i].name);\n\t}\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":409481,"func":"decode_modifiers(int n)\n{\n    int\t    code = n - 1;\n    int\t    modifiers = 0;\n\n    if (code & 1)\n\tmodifiers |= MOD_MASK_SHIFT;\n    if (code & 2)\n\tmodifiers |= MOD_MASK_ALT;\n    if (code & 4)\n\tmodifiers |= MOD_MASK_CTRL;\n    if (code & 8)\n\tmodifiers |= MOD_MASK_META;\n    return modifiers;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":101684,"func":"void WebProcessProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy)\n{\n    MESSAGE_CHECK_URL(urlString);\n\n    String newMimeType = mimeType.lower();\n\n    pluginLoadPolicy = PluginModuleLoadNormally;\n    PluginModuleInfo plugin = m_context->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));\n    if (!plugin.path)\n        return;\n\n    pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin);\n    if (pluginLoadPolicy != PluginModuleLoadNormally)\n        return;\n\n    pluginPath = plugin.path;\n}\n","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":225413,"func":"static int vidioc_g_output(struct file *file, void *fh, unsigned int *i)\n{\n\tstruct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);\n\tif (!dev->announce_all_caps && !dev->ready_for_output)\n\t\treturn -ENOTTY;\n\tif (i)\n\t\t*i = 0;\n\treturn 0;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":224761,"func":"GF_Err ireftype_box_size(GF_Box *s)\n{\n\tGF_ItemReferenceTypeBox *ptr = (GF_ItemReferenceTypeBox *)s;\n\tptr->size += 4 + (ptr->reference_count * sizeof(u16));\n\treturn GF_OK;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":487616,"func":"asmlinkage long sys_getsid(pid_t pid)\n{\n\tif (!pid)\n\t\treturn process_session(current);\n\telse {\n\t\tint retval;\n\t\tstruct task_struct *p;\n\n\t\tread_lock(&tasklist_lock);\n\t\tp = find_task_by_pid(pid);\n\n\t\tretval = -ESRCH;\n\t\tif (p) {\n\t\t\tretval = security_task_getsid(p);\n\t\t\tif (!retval)\n\t\t\t\tretval = process_session(p);\n\t\t}\n\t\tread_unlock(&tasklist_lock);\n\t\treturn retval;\n\t}\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":488328,"func":"static void __init vdso_setup_syscall_map(void)\n{\n\tunsigned int i;\n\textern unsigned long *sys_call_table;\n\textern unsigned long sys_ni_syscall;\n\n\n\tfor (i = 0; i < __NR_syscalls; i++) {\n#ifdef CONFIG_PPC64\n\t\tif (sys_call_table[i*2] != sys_ni_syscall)\n\t\t\tvdso_data->syscall_map_64[i >> 5] |=\n\t\t\t\t0x80000000UL >> (i & 0x1f);\n\t\tif (sys_call_table[i*2+1] != sys_ni_syscall)\n\t\t\tvdso_data->syscall_map_32[i >> 5] |=\n\t\t\t\t0x80000000UL >> (i & 0x1f);\n#else \/* CONFIG_PPC64 *\/\n\t\tif (sys_call_table[i] != sys_ni_syscall)\n\t\t\tvdso_data->syscall_map_32[i >> 5] |=\n\t\t\t\t0x80000000UL >> (i & 0x1f);\n#endif \/* CONFIG_PPC64 *\/\n\t}\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":254033,"func":"static int v4l2_loopback_close(struct file *file)\n{\n\tstruct v4l2_loopback_opener *opener;\n\tstruct v4l2_loopback_device *dev;\n\tint iswriter=0;\n\tMARK();\n\n\n\topener = file->private_data;\n\tdev    = v4l2loopback_getdevice(file);\n\n\tif(WRITER == opener->type)\n\t\tiswriter = 1;\n\n\tatomic_dec(&dev->open_count);\n\tif (dev->open_count.counter == 0) {\n\t\tdel_timer_sync(&dev->sustain_timer);\n\t\tdel_timer_sync(&dev->timeout_timer);\n\t}\n\ttry_free_buffers(dev);\n\tkfree(opener);\n\tif(iswriter) {\n\t\tdev->ready_for_output = 1;\n\t}\n\tMARK();\n\treturn 0;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":468340,"func":"g_socket_client_set_enable_proxy (GSocketClient *client,\n\t\t\t\t  gboolean       enable)\n{\n  enable = !!enable;\n  if (client->priv->enable_proxy == enable)\n    return;\n\n  client->priv->enable_proxy = enable;\n  g_object_notify (G_OBJECT (client), \"enable-proxy\");\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":409494,"func":"add_long_to_buf(long_u val, char_u *dst)\n{\n    int\t    i;\n    int\t    shift;\n\n    for (i = 1; i <= (int)sizeof(long_u); i++)\n    {\n\tshift = 8 * (sizeof(long_u) - i);\n\tdst[i - 1] = (char_u) ((val >> shift) & 0xff);\n    }\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":338100,"func":"WasmBinaryBuilder::WasmBinaryBuilder(Module& wasm,\n                                     FeatureSet features,\n                                     const std::vector<char>& input)\n  : wasm(wasm), allocator(wasm.allocator), input(input), sourceMap(nullptr),\n    nextDebugLocation(0, {0, 0, 0}), debugLocation() {\n  wasm.features = features;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":294710,"func":"d_lite_fill(VALUE self)\n{\n    get_d1(self);\n\n    if (simple_dat_p(dat)) {\n\tget_s_jd(dat);\n\tget_s_civil(dat);\n    }\n    else {\n\tget_c_jd(dat);\n\tget_c_civil(dat);\n\tget_c_df(dat);\n\tget_c_time(dat);\n    }\n    return self;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":233848,"func":"static int de_fmtutil_default_iff_chunk_handler(deark *c, struct de_iffctx *ictx)\n{\n\ti64 dpos = ictx->chunkctx->dpos;\n\ti64 dlen = ictx->chunkctx->dlen;\n\tu32 chunktype = ictx->chunkctx->chunk4cc.id;\n\n\tswitch(chunktype) {\n\t\t\/\/ Note that chunks appearing here should also be listed below,\n\t\t\/\/ in de_fmtutil_is_standard_iff_chunk().\n\tcase CODE__c_:\n\t\tdo_iff_text_chunk(c, ictx, dpos, dlen, \"copyright\");\n\t\tbreak;\n\tcase CODE_ANNO:\n\t\tdo_iff_anno(c, ictx, dpos, dlen);\n\t\tbreak;\n\tcase CODE_AUTH:\n\t\tdo_iff_text_chunk(c, ictx, dpos, dlen, \"author\");\n\t\tbreak;\n\tcase CODE_NAME:\n\t\tdo_iff_text_chunk(c, ictx, dpos, dlen, \"name\");\n\t\tbreak;\n\tcase CODE_TEXT:\n\t\tdo_iff_text_chunk(c, ictx, dpos, dlen, \"text\");\n\t\tbreak;\n\t}\n\n\t\/\/ Note we do not set ictx->handled. The caller is responsible for that.\n\treturn 1;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":473979,"func":"unpack_entries(register st_table *table)\n{\n    st_index_t i;\n    struct st_table_entry *packed_bins[MAX_PACKED_NUMHASH*2];\n    st_table tmp_table = *table;\n\n    memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * table->num_entries*2);\n    table->bins = packed_bins;\n    tmp_table.entries_packed = 0;\n    tmp_table.num_entries = 0;\n    memset(tmp_table.bins, 0, sizeof(struct st_table_entry *) * tmp_table.num_bins);\n    for (i = 0; i < table->num_entries; i++) {\n        st_insert(&tmp_table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]);\n    }\n    *table = tmp_table;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":221485,"func":"extract_unix_path_from_dbus_address (const char *address)\n{\n  const char *path, *path_end;\n\n  if (address == NULL)\n    return NULL;\n\n  if (!g_str_has_prefix (address, \"unix:\"))\n    return NULL;\n\n  path = strstr (address, \"path=\");\n  if (path == NULL)\n    return NULL;\n  path += strlen (\"path=\");\n  path_end = path;\n  while (*path_end != 0 && *path_end != ',')\n    path_end++;\n\n  return g_strndup (path, path_end - path);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":294658,"func":"c_jd_to_wday(int jd)\n{\n    return MOD(jd + 1, 7);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":404730,"func":"static struct file *__fget_files(struct files_struct *files, unsigned int fd,\n\t\t\t\t fmode_t mask, unsigned int refs)\n{\n\tstruct file *file;\n\n\trcu_read_lock();\nloop:\n\tfile = files_lookup_fd_rcu(files, fd);\n\tif (file) {\n\t\t\/* File object ref couldn't be taken.\n\t\t * dup2() atomicity guarantee is the reason\n\t\t * we loop to catch the new file (or NULL pointer)\n\t\t *\/\n\t\tif (file->f_mode & mask)\n\t\t\tfile = NULL;\n\t\telse if (!get_file_rcu_many(file, refs))\n\t\t\tgoto loop;\n\t\telse if (files_lookup_fd_raw(files, fd) != file) {\n\t\t\tfput_many(file, refs);\n\t\t\tgoto loop;\n\t\t}\n\t}\n\trcu_read_unlock();\n\n\treturn file;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":238384,"func":"njs_function_prototype_thrower(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    njs_type_error(vm, \"\\\"caller\\\", \\\"callee\\\", \\\"arguments\\\" \"\n                   \"properties may not be accessed\");\n    return NJS_ERROR;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":417129,"func":"void PlayerGeneric::nextPattern()\n{\n\tif (player)\n\t\tplayer->nextPattern();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":252299,"func":"static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) {\n  if (static_block)\n    tdefl_start_static_block(d);\n  else\n    tdefl_start_dynamic_block(d);\n  return tdefl_compress_lz_codes(d);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":336581,"func":"SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *reds, const char *addr, int flags)\n{\n    g_strlcpy(reds->config->spice_addr, addr, sizeof(reds->config->spice_addr));\n\n    if (flags == SPICE_ADDR_FLAG_IPV4_ONLY) {\n        reds->config->spice_family = PF_INET;\n    } else if (flags == SPICE_ADDR_FLAG_IPV6_ONLY) {\n        reds->config->spice_family = PF_INET6;\n    } else if (flags == SPICE_ADDR_FLAG_UNIX_ONLY) {\n        reds->config->spice_family = AF_UNIX;\n    } else if (flags != 0) {\n        spice_warning(\"unknown address flag: 0x%X\", flags);\n    }\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":413347,"func":"static HashTable *php_snmp_get_properties(zval *object TSRMLS_DC)\n{\n\tphp_snmp_object *obj;\n\tphp_snmp_prop_handler *hnd;\n\tHashTable *props;\n\tzval *val;\n\tchar *key;\n\tuint key_len;\n\tHashPosition pos;\n\tulong num_key;\n\n\tobj = (php_snmp_object *)zend_objects_get_address(object TSRMLS_CC);\n\tprops = zend_std_get_properties(object TSRMLS_CC);\n\n\tzend_hash_internal_pointer_reset_ex(&php_snmp_properties, &pos);\n\n\twhile (zend_hash_get_current_data_ex(&php_snmp_properties, (void**)&hnd, &pos) == SUCCESS) {\n\t\tzend_hash_get_current_key_ex(&php_snmp_properties, &key, &key_len, &num_key, 0, &pos);\n\t\tif (!hnd->read_func || hnd->read_func(obj, &val TSRMLS_CC) != SUCCESS) {\n\t\t\tval = EG(uninitialized_zval_ptr);\n\t\t\tZ_ADDREF_P(val);\n\t\t}\n\t\tzend_hash_update(props, key, key_len, (void *)&val, sizeof(zval *), NULL);\n\t\tzend_hash_move_forward_ex(&php_snmp_properties, &pos);\n\t}\n\treturn obj->zo.properties;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":387738,"func":"JvmtiCachedClassFileData* InstanceKlass::get_archived_class_data() {\n  if (DumpSharedSpaces) {\n    return _cached_class_file;\n  } else {\n    assert(this->is_shared(), \"class should be shared\");\n    if (MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {\n      return _cached_class_file;\n    } else {\n      return NULL;\n    }\n  }\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":359579,"func":"peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) \n{\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  peer_ebgp_multihop_unset (peer);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":387813,"func":"static bool method_matches(const Method* m,\n                           const Symbol* signature,\n                           bool skipping_overpass,\n                           bool skipping_static,\n                           bool skipping_private) {\n  return ((m->signature() == signature) &&\n    (!skipping_overpass || !m->is_overpass()) &&\n    (!skipping_static || !m->is_static()) &&\n    (!skipping_private || !m->is_private()));\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":274718,"func":"static const char *screen_units_str(void)\n{\n\t\/* NOTE: in order of gerbv_gui_unit_t *\/\n\tconst char *units_str[] = {N_(\"mil\"), N_(\"mm\"), N_(\"in\")};\n\n\treturn _(units_str[screen.unit]);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":509491,"func":"int ha_maria::index_end()\n{\n  active_index=MAX_KEY;\n  ma_set_index_cond_func(file, NULL, 0);\n  in_range_check_pushed_down= FALSE;\n  ds_mrr.dsmrr_close();\n  return 0;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":409489,"func":"termgui_mch_get_rgb(guicolor_T color)\n{\n    return color;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":247591,"func":"TEST_P(SslSocketTest, FailedClientCertificateExpirationVerification) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n\n  OptionalServerConfig server_config;\n  server_config.allow_expired_cert = false;\n  configureServerAndExpiredClientCertificate(listener, client, server_config);\n\n  TestUtilOptionsV2 test_options(listener, client, false, GetParam());\n  testUtilV2(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedTransportFailureReasonContains(\"SSLV3_ALERT_CERTIFICATE_EXPIRED\"));\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":328860,"func":"R_API void r_bin_java_get_method_json_definitions(RBinJavaObj *bin, PJ *pj) {\n\tr_return_if_fail (pj);\n\tRBinJavaField *fm_type = NULL;\n\tRListIter *iter = NULL;\n\n\tpj_ka (pj, \"methods\");\n\tif (!bin) {\n\t\tpj_end (pj);\n\t\treturn;\n\t}\n\n\tr_list_foreach (bin->methods_list, iter, fm_type) {\n\t\tr_bin_java_get_method_json_definition (bin, fm_type, pj);\n\t}\n\tpj_end (pj);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":430352,"func":"void seq_escape_mem(struct seq_file *m, const char *src, size_t len,\n\t\t    unsigned int flags, const char *esc)\n{\n\tchar *buf;\n\tsize_t size = seq_get_buf(m, &buf);\n\tint ret;\n\n\tret = string_escape_mem(src, len, buf, size, flags, esc);\n\tseq_commit(m, ret < size ? ret : -1);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":225690,"func":"GF_Err maxr_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_MAXRBox *ptr = (GF_MAXRBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->granularity);\n\tgf_bs_write_u32(bs, ptr->maxDataRate);\n\treturn GF_OK;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":389697,"func":"tv_get_string(typval_T *varp)\n{\n    static char_u   mybuf[NUMBUFLEN];\n\n    return tv_get_string_buf(varp, mybuf);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":232928,"func":"static void deflate_close_writer(struct Curl_easy *data,\n                                 struct contenc_writer *writer)\n{\n  struct zlib_params *zp = (struct zlib_params *) &writer->params;\n  z_stream *z = &zp->z;     \/* zlib state structure *\/\n\n  exit_zlib(data, z, &zp->zlib_init, CURLE_OK);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":225414,"func":"void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)\n{\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":226346,"func":"GF_Err iods_box_size(GF_Box *s)\n{\n\tGF_ObjectDescriptorBox *ptr = (GF_ObjectDescriptorBox *)s;\n\n\tptr->size += gf_odf_desc_size(ptr->descriptor);\n\treturn GF_OK;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":264371,"func":"inline const string* const* TensorProtoData<tstring>(const TensorProto& t) {\n  static_assert(SaveTypeTraits<tstring>::supported,\n                \"Specified type tstring not supported for Restore\");\n  return t.string_val().data();\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":294671,"func":"valid_commercial_sub(int argc, VALUE *argv, VALUE klass, int need_jd)\n{\n    VALUE nth, y;\n    int w, d, ry, rw, rd;\n    double sg;\n\n    y = argv[0];\n    w = NUM2INT(argv[1]);\n    d = NUM2INT(argv[2]);\n    sg = NUM2DBL(argv[3]);\n\n    valid_sg(sg);\n\n    {\n\tint rjd, ns;\n\tVALUE rjd2;\n\n\tif (!valid_commercial_p(y, w, d, sg,\n\t\t\t\t&nth, &ry,\n\t\t\t\t&rw, &rd, &rjd,\n\t\t\t\t&ns))\n\t    return Qnil;\n\tif (!need_jd)\n\t    return INT2FIX(0); \/* dummy *\/\n\tencode_jd(nth, rjd, &rjd2);\n\treturn rjd2;\n    }\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":387804,"func":"  template <class T> void do_oop_work(T* p) {\n    oop obj = RawAccess<>::oop_load(p);\n    if (!oopDesc::is_oop_or_null(obj)) {\n      tty->print_cr(\"Failed: \" PTR_FORMAT \" -> \" PTR_FORMAT, p2i(p), p2i(obj));\n      Universe::print_on(tty);\n      guarantee(false, \"boom\");\n    }\n  }","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":244209,"func":"void void_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":332376,"func":"is_ex_cmdchar(cmdarg_T *cap)\n{\n    return cap->cmdchar == ':'\n\t|| cap->cmdchar == K_COMMAND\n\t|| cap->cmdchar == K_SCRIPT_COMMAND;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":387747,"func":"bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {\n\n  assert(this != k, \"this should be handled by higher-level code\");\n\n  \/\/ Per JVMS 5.4.4 we first resolve and validate the current class, then\n  \/\/ the target class k. Resolution exceptions will be passed on by upper\n  \/\/ layers. IncompatibleClassChangeErrors from membership validation failures\n  \/\/ will also be passed through.\n\n  Symbol* icce = vmSymbols::java_lang_IncompatibleClassChangeError();\n  InstanceKlass* cur_host = nest_host(icce, CHECK_false);\n  if (cur_host == NULL) {\n    return false;\n  }\n\n  Klass* k_nest_host = k->nest_host(icce, CHECK_false);\n  if (k_nest_host == NULL) {\n    return false;\n  }\n\n  bool access = (cur_host == k_nest_host);\n\n  if (log_is_enabled(Trace, class, nestmates)) {\n    ResourceMark rm(THREAD);\n    log_trace(class, nestmates)(\"Class %s does %shave nestmate access to %s\",\n                                this->external_name(),\n                                access ? \"\" : \"NOT \",\n                                k->external_name());\n  }\n\n  return access;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":222838,"func":"    std::size_t operator()(const DimId& dim) const {\n      return std::hash<const NodeDef*>{}(dim.node) + dim.port_id +\n             dim.dim_index;\n    }","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":412094,"func":"add_server_nonce(uint8_t *nonce)\n{\n    uint64_t ts;\n    uint64_t tsn;\n    uint32_t suffix;\n    ts = dnscrypt_hrtime();\n    \/\/ TODO? dnscrypt-wrapper does some logic with context->nonce_ts_last\n    \/\/ unclear if we really need it, so skipping it for now.\n    tsn = (ts << 10) | (randombytes_random() & 0x3ff);\n#if (BYTE_ORDER == LITTLE_ENDIAN)\n    tsn =\n        (((uint64_t)htonl((uint32_t)tsn)) << 32) | htonl((uint32_t)(tsn >> 32));\n#endif\n    memcpy(nonce + crypto_box_HALF_NONCEBYTES, &tsn, 8);\n    suffix = randombytes_random();\n    memcpy(nonce + crypto_box_HALF_NONCEBYTES + 8, &suffix, 4);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":427723,"func":"_cdf_tole8(uint64_t sv)\n{\n\tuint64_t rv;\n\tuint8_t *s = RCAST(uint8_t *, RCAST(void *, &sv));\n\tuint8_t *d = RCAST(uint8_t *, RCAST(void *, &rv));\n\td[0] = s[7];\n\td[1] = s[6];\n\td[2] = s[5];\n\td[3] = s[4];\n\td[4] = s[3];\n\td[5] = s[2];\n\td[6] = s[1];\n\td[7] = s[0];\n\treturn rv;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":336665,"func":"static void openssl_thread_setup(void)\n{\n    int i;\n\n    \/* Somebody else already setup threading for OpenSSL,\n     * don't do it twice to avoid possible races.\n     *\/\n    if (CRYPTO_get_locking_callback() != NULL) {\n        red_dump_openssl_errors();\n        return;\n    }\n\n    lock_cs = (pthread_mutex_t*) OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));\n\n    for (i = 0; i < CRYPTO_num_locks(); i++) {\n        pthread_mutex_init(&(lock_cs[i]), NULL);\n    }\n\n    CRYPTO_THREADID_set_callback(pthreads_thread_id);\n    CRYPTO_set_locking_callback(pthreads_locking_callback);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":246732,"func":"void PrintEncryptUsage()\n{\n\tu32 i=0;\n\tgf_sys_format_help(helpout, help_flags, \"# Encryption\/Decryption Options\\n\"\n\t\"MP4Box supports encryption and decryption of ISMA, OMA and CENC content, see [encryption filter `gpac -h cecrypt`](cecrypt).\\n\"\n\t\"It requires a specific XML file called `CryptFile`, whose syntax is available at https:\/\/wiki.gpac.io\/Common-Encryption\\n\"\n\t\"Image files (HEIF) can also be crypted \/ decrypted, using CENC only.\\n\"\n\t\"  \\n\"\n\t\"Options:\\n\"\n\t);\n\twhile (m4b_crypt_args[i].name) {\n\t\tGF_GPACArg *arg = (GF_GPACArg *) &m4b_crypt_args[i];\n\t\ti++;\n\t\tgf_sys_print_arg(helpout, help_flags, arg, \"mp4box-crypt\");\n\t}\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":445955,"func":"fr_window_open_files_with_application (FrWindow *window,\n\t\t\t\t       GList    *file_list,\n\t\t\t\t       GAppInfo *app)\n{\n\tGList               *uris;\n\tGList               *scan;\n\tGdkAppLaunchContext *context;\n\tGError              *error = NULL;\n\n\tif (window->priv->activity_ref > 0)\n\t\treturn;\n\n\turis = NULL;\n\tfor (scan = file_list; scan; scan = scan->next)\n\t\turis = g_list_prepend (uris, g_file_get_uri (G_FILE (scan->data)));\n\n\tcontext = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (window)));\n\tgdk_app_launch_context_set_screen (context, gtk_widget_get_screen (GTK_WIDGET (window)));\n\tgdk_app_launch_context_set_timestamp (context, 0);\n\n\tif (! g_app_info_launch_uris (app, uris, G_APP_LAUNCH_CONTEXT (context), &error)) {\n\t\t_gtk_error_dialog_run (GTK_WINDOW (window),\n\t\t\t\t       _(\"Could not perform the operation\"),\n\t\t\t\t       \"%s\",\n\t\t\t\t       error->message);\n\t\tg_clear_error (&error);\n\t}\n\n\tg_object_unref (context);\n\t_g_string_list_free (uris);\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":484803,"func":"static int xennet_set_features(struct net_device *dev,\n\tnetdev_features_t features)\n{\n\tif (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {\n\t\tnetdev_info(dev, \"Reducing MTU because no SG offload\");\n\t\tdev->mtu = ETH_DATA_LEN;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":475983,"func":"lzw_result lzw_context_create(struct lzw_ctx **ctx)\n{\n\tstruct lzw_ctx *c = malloc(sizeof(*c));\n\tif (c == NULL) {\n\t\treturn LZW_NO_MEM;\n\t}\n\n\t*ctx = c;\n\treturn LZW_OK;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":262078,"func":"  InstanceFeatureDimKey(const int32_t instance, const int32_t feature_dim)\n      : instance(instance), feature_dim(feature_dim) {}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":219005,"func":"void ConstantFolding::SimplifySqueeze(const GraphProperties& properties,\n                                      bool use_shape_info,\n                                      GraphDef* optimized_graph,\n                                      NodeDef* node) {\n  if (use_shape_info && IsSqueeze(*node) &&\n      !properties.GetInputProperties(node->name()).empty()) {\n    \/\/ https:\/\/www.tensorflow.org\/api_docs\/python\/tf\/squeeze mentions it's\n    \/\/ error to squeeze a dimension that is not 1, so we only need to check\n    \/\/ whether the input has > 1 size for each dimension.\n    const auto& shape = properties.GetInputProperties(node->name())[0].shape();\n    \/\/ The node is replaceable iff\n    \/\/ unknown_rank == false && (dim_size == 0 || all dims have size > 1)\n    bool replaceable = !shape.unknown_rank();\n    for (int j = 0; replaceable && j < shape.dim_size(); ++j) {\n      replaceable &= shape.dim(j).size() > 1;\n    }\n    if (replaceable) {\n      ReplaceOperationWithIdentity(0, properties, node, optimized_graph);\n    }\n  }\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":232953,"func":"static CURLcode identity_init_writer(struct Curl_easy *data,\n                                     struct contenc_writer *writer)\n{\n  (void) data;\n  return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":512701,"func":"  Item *field_transformer_for_having_pushdown(THD *thd, uchar *arg)\n  { return this; }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":226223,"func":"\nGF_Err dfla_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_data(bs, ptr->data, ptr->dataSize);\n\treturn GF_OK;","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":225597,"func":"\nGF_Err lsrc_box_size(GF_Box *s)\n{\n\tGF_LASERConfigurationBox *ptr = (GF_LASERConfigurationBox *)s;\n\tptr->size += ptr->hdr_size;\n\treturn GF_OK;","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":222891,"func":"bool IsDequeue(const NodeDef& n) {\n  return (n.op().find(\"Dequeue\") != string::npos &&\n          n.op().find(\"DequeueMany\") == string::npos);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":229246,"func":"cql_server::connection::process_register(uint16_t stream, request_reader in, service::client_state& client_state,\n        tracing::trace_state_ptr trace_state) {\n    ++_server._stats.register_requests;\n    std::vector<sstring> event_types;\n    in.read_string_list(event_types);\n    for (auto&& event_type : event_types) {\n        auto et = parse_event_type(event_type);\n        _server._notifier->register_event(et, this);\n    }\n    _ready = true;\n    return make_ready_future<std::unique_ptr<cql_server::response>>(make_ready(stream, std::move(trace_state)));\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":359453,"func":"DEFUN (neighbor_port,\n       neighbor_port_cmd,\n       NEIGHBOR_CMD \"port <0-65535>\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR\n       \"Neighbor's BGP port\\n\"\n       \"TCP port number\\n\")\n{\n  return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":387832,"func":"bool InstanceKlass::verify_code(bool throw_verifyerror, TRAPS) {\n  \/\/ 1) Verify the bytecodes\n  Verifier::Mode mode =\n    throw_verifyerror ? Verifier::ThrowException : Verifier::NoException;\n  return Verifier::verify(this, mode, should_verify_class(), THREAD);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":409418,"func":"termrequest_sent(termrequest_T *status)\n{\n    status->tr_progress = STATUS_SENT;\n    status->tr_start = time(NULL);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":359243,"func":"DEFUN (no_neighbor_remove_private_as,\n       no_neighbor_remove_private_as_cmd,\n       NO_NEIGHBOR_CMD2 \"remove-private-AS\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Remove private AS number from outbound updates\\n\")\n{\n  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t bgp_node_safi (vty),\n\t\t\t\t PEER_FLAG_REMOVE_PRIVATE_AS);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":238772,"func":"save_last_search_pattern(void)\n{\n    if (++did_save_last_search_spat != 1)\n\t\/\/ nested call, nothing to do\n\treturn;\n\n    saved_last_search_spat = spats[RE_SEARCH];\n    if (spats[RE_SEARCH].pat != NULL)\n\tsaved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat);\n    saved_last_idx = last_idx;\n    saved_no_hlsearch = no_hlsearch;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":359205,"func":"static void ringbuf_map_free(struct bpf_map *map)\n{\n\tstruct bpf_ringbuf_map *rb_map;\n\n\trb_map = container_of(map, struct bpf_ringbuf_map, map);\n\tbpf_ringbuf_free(rb_map->rb);\n\tkfree(rb_map);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":229240,"func":"scattered_message<char> cql_server::response::make_message(uint8_t version, cql_compression compression) {\n    if (compression != cql_compression::none) {\n        compress(compression);\n    }\n    scattered_message<char> msg;\n    auto frame = make_frame(version, _body.size());\n    msg.append(std::move(frame));\n    for (auto&& fragment : _body.fragments()) {\n        msg.append_static(reinterpret_cast<const char*>(fragment.data()), fragment.size());\n    }\n    return msg;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":449321,"func":"static char *getsistring(FILE *f, uint32_t ptr, uint32_t len) {\n  char *name;\n  uint32_t i;\n\n  if (!len) return NULL;\n  if (len>400) len=400;\n  name = cli_malloc(len+1);\n  if (!name) {\n    cli_dbgmsg(\"SIS: OOM\\n\");\n    return NULL;\n  }\n  fseek(f, ptr, SEEK_SET);\n  if (fread(name, len, 1, f)!=1) {\n    cli_dbgmsg(\"SIS: Unable to read string\\n\");\n    free(name);\n    return NULL;\n  }\n  for (i = 0 ; i < len; i+=2) name[i\/2] = name[i];\n  name[i\/2]='\\0';\n  return name;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":232937,"func":"static void gzip_close_writer(struct Curl_easy *data,\n                              struct contenc_writer *writer)\n{\n  struct zlib_params *zp = (struct zlib_params *) &writer->params;\n  z_stream *z = &zp->z;     \/* zlib state structure *\/\n\n  exit_zlib(data, z, &zp->zlib_init, CURLE_OK);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":491898,"func":"static void fuse_send_readpages(struct fuse_req *req, struct file *file)\n{\n\tstruct fuse_file *ff = file->private_data;\n\tstruct fuse_conn *fc = ff->fc;\n\tloff_t pos = page_offset(req->pages[0]);\n\tsize_t count = req->num_pages << PAGE_CACHE_SHIFT;\n\n\treq->out.argpages = 1;\n\treq->out.page_zeroing = 1;\n\tfuse_read_fill(req, file, pos, count, FUSE_READ);\n\treq->misc.read.attr_ver = fuse_get_attr_version(fc);\n\tif (fc->async_read) {\n\t\treq->ff = fuse_file_get(ff);\n\t\treq->end = fuse_readpages_end;\n\t\tfuse_request_send_background(fc, req);\n\t} else {\n\t\tfuse_request_send(fc, req);\n\t\tfuse_readpages_end(fc, req);\n\t\tfuse_put_request(fc, req);\n\t}\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":384896,"func":"transchar(int c)\n{\n    return transchar_buf(curbuf, c);\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":101659,"func":"void WebProcessProxy::assumeReadAccessToBaseURL(const String& urlString)\n{\n    KURL url(KURL(), urlString);\n    if (!url.isLocalFile())\n        return;\n\n    KURL baseURL(KURL(), url.baseAsString());\n    \n    m_localPathsWithAssumedReadAccess.add(baseURL.fileSystemPath());\n}\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":476112,"func":"void usb_remove_config(struct usb_composite_dev *cdev,\n\t\t      struct usb_configuration *config)\n{\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&cdev->lock, flags);\n\n\tif (cdev->config == config)\n\t\treset_config(cdev);\n\n\tspin_unlock_irqrestore(&cdev->lock, flags);\n\n\tremove_config(cdev, config);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":359540,"func":"DEFUN (no_neighbor_dont_capability_negotiate,\n       no_neighbor_dont_capability_negotiate_cmd,\n       NO_NEIGHBOR_CMD2 \"dont-capability-negotiate\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Do not perform capability negotiation\\n\")\n{\n  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":459211,"func":"static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags)\n{\n\tif (*flags & TCA_CLS_FLAGS_IN_HW)\n\t\treturn;\n\t*flags |= TCA_CLS_FLAGS_IN_HW;\n\tatomic_inc(&block->offloadcnt);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":301397,"func":"static int vfswrap_open(vfs_handle_struct *handle,\n\t\t\tstruct smb_filename *smb_fname,\n\t\t\tfiles_struct *fsp, int flags, mode_t mode)\n{\n\tint result = -1;\n\n\tSTART_PROFILE(syscall_open);\n\n\tif (smb_fname->stream_name) {\n\t\terrno = ENOENT;\n\t\tgoto out;\n\t}\n\n\tresult = open(smb_fname->base_name, flags, mode);\n out:\n\tEND_PROFILE(syscall_open);\n\treturn result;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":338172,"func":"void WasmBinaryBuilder::requireFunctionContext(const char* error) {\n  if (!currFunction) {\n    throwError(std::string(\"in a non-function context: \") + error);\n  }\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":90778,"func":"void QuotaManager::GetOriginsModifiedSince(\n    StorageType type,\n    base::Time modified_since,\n    GetOriginsCallback* callback) {\n  LazyInitialize();\n  make_scoped_refptr(new GetModifiedSinceTask(\n      this, type, modified_since, callback))->Start();\n}\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":338162,"func":"void WasmBinaryWriter::prepare() {\n  \/\/ Collect function types and their frequencies. Collect information in each\n  \/\/ function in parallel, then merge.\n  ModuleUtils::collectHeapTypes(*wasm, types, typeIndices);\n  importInfo = wasm::make_unique<ImportInfo>(*wasm);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":336138,"func":"static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],\n\t\t\t    struct nlattr *data[])\n{\n\tstruct ip6_tnl *t, *nt = netdev_priv(dev);\n\tstruct net *net = nt->net;\n\tstruct ip6gre_net *ign = net_generic(net, ip6gre_net_id);\n\tstruct __ip6_tnl_parm p;\n\tstruct ip_tunnel_encap ipencap;\n\n\tif (dev == ign->fb_tunnel_dev)\n\t\treturn -EINVAL;\n\n\tif (ip6gre_netlink_encap_parms(data, &ipencap)) {\n\t\tint err = ip6_tnl_encap_setup(nt, &ipencap);\n\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\tip6gre_netlink_parms(data, &p);\n\n\tt = ip6gre_tunnel_locate(net, &p, 0);\n\n\tif (t) {\n\t\tif (t->dev != dev)\n\t\t\treturn -EEXIST;\n\t} else {\n\t\tt = nt;\n\t}\n\n\tip6gre_tunnel_unlink(ign, t);\n\tip6gre_tnl_change(t, &p, !tb[IFLA_MTU]);\n\tip6gre_tunnel_link(ign, t);\n\treturn 0;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":234808,"func":"int btrfs_pause_balance(struct btrfs_fs_info *fs_info)\n{\n\tint ret = 0;\n\n\tmutex_lock(&fs_info->balance_mutex);\n\tif (!fs_info->balance_ctl) {\n\t\tmutex_unlock(&fs_info->balance_mutex);\n\t\treturn -ENOTCONN;\n\t}\n\n\tif (test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags)) {\n\t\tatomic_inc(&fs_info->balance_pause_req);\n\t\tmutex_unlock(&fs_info->balance_mutex);\n\n\t\twait_event(fs_info->balance_wait_q,\n\t\t\t   !test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags));\n\n\t\tmutex_lock(&fs_info->balance_mutex);\n\t\t\/* we are good with balance_ctl ripped off from under us *\/\n\t\tBUG_ON(test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags));\n\t\tatomic_dec(&fs_info->balance_pause_req);\n\t} else {\n\t\tret = -ENOTCONN;\n\t}\n\n\tmutex_unlock(&fs_info->balance_mutex);\n\treturn ret;\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":473834,"func":"concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)\n{\n  int i, j, len;\n  UChar *p, *end;\n  OptAncInfo tanc;\n\n  if (! to->ignore_case && add->ignore_case) {\n    if (to->len >= add->len) return ;  \/* avoid *\/\n\n    to->ignore_case = 1;\n  }\n\n  p = add->s;\n  end = p + add->len;\n  for (i = to->len; p < end; ) {\n    len = enclen(enc, p, end);\n    if (i + len > OPT_EXACT_MAXLEN) break;\n    for (j = 0; j < len && p < end; j++)\n      to->s[i++] = *p++;\n  }\n\n  to->len = i;\n  to->reach_end = (p == end ? add->reach_end : 0);\n\n  concat_opt_anc_info(&tanc, &to->anc, &add->anc, 1, 1);\n  if (! to->reach_end) tanc.right_anchor = 0;\n  copy_opt_anc_info(&to->anc, &tanc);\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":314495,"func":"PJ_DEF(int) pjmedia_sdp_print( const pjmedia_sdp_session *desc, \n\t\t\t       char *buf, pj_size_t size)\n{\n    return print_session(desc, buf, size);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":427225,"func":"static void removevars (FuncState *fs, int tolevel) {\n  fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel);\n  while (fs->nactvar > tolevel) {\n    LocVar *var = localdebuginfo(fs, --fs->nactvar);\n    if (var)  \/* does it have debug information? *\/\n      var->endpc = fs->pc;\n  }\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":481264,"func":"static inline void mlx5_fpga_conn_cqes(struct mlx5_fpga_conn *conn,\n\t\t\t\t       unsigned int budget)\n{\n\tstruct mlx5_cqe64 *cqe;\n\n\twhile (budget) {\n\t\tcqe = mlx5_cqwq_get_cqe(&conn->cq.wq);\n\t\tif (!cqe)\n\t\t\tbreak;\n\n\t\tbudget--;\n\t\tmlx5_cqwq_pop(&conn->cq.wq);\n\t\tmlx5_fpga_conn_handle_cqe(conn, cqe);\n\t\tmlx5_cqwq_update_db_record(&conn->cq.wq);\n\t}\n\tif (!budget) {\n\t\ttasklet_schedule(&conn->cq.tasklet);\n\t\treturn;\n\t}\n\n\tmlx5_fpga_dbg(conn->fdev, \"Re-arming CQ with cc# %u\\n\", conn->cq.wq.cc);\n\t\/* ensure cq space is freed before enabling more cqes *\/\n\twmb();\n\tmlx5_fpga_conn_arm_cq(conn);\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":331755,"func":"QPaintEngineExPrivate::QPaintEngineExPrivate()\n    : dasher(&stroker),\n      strokeHandler(nullptr),\n      activeStroker(nullptr),\n      strokerPen(Qt::NoPen)\n{\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":253573,"func":"smb2_clear_stats(struct cifs_tcon *tcon)\n{\n\tint i;\n\n\tfor (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {\n\t\tatomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);\n\t\tatomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);\n\t}\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":96956,"func":"void encode(ArgumentEncoder* encoder, CFDictionaryRef dictionary)\n{\n    CFIndex size = CFDictionaryGetCount(dictionary);\n    Vector<CFTypeRef, 32> keys(size);\n    Vector<CFTypeRef, 32> values(size);\n    \n    CFDictionaryGetKeysAndValues(dictionary, keys.data(), values.data());\n\n    encoder->encodeUInt64(size);\n\n    for (CFIndex i = 0; i < size; ++i) {\n        ASSERT(keys[i]);\n        ASSERT(CFGetTypeID(keys[i]) == CFStringGetTypeID());\n        ASSERT(values[i]);\n\n        if (typeFromCFTypeRef(values[i]) == Unknown)\n            continue;\n\n        encode(encoder, static_cast<CFStringRef>(keys[i]));\n        encode(encoder, values[i]);\n    }\n}\n","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":398513,"func":"RZ_API RzBinDwarfLineInfo *rz_bin_dwarf_parse_line(RzBinFile *binfile, RZ_NULLABLE RzBinDwarfDebugInfo *info, RzBinDwarfLineInfoMask mask) {\n\trz_return_val_if_fail(binfile, NULL);\n\tRzBinSection *section = getsection(binfile, \"debug_line\");\n\tif (!section) {\n\t\treturn NULL;\n\t}\n\tut64 len = section->size;\n\tif (len < 1) {\n\t\treturn NULL;\n\t}\n\tut8 *buf = RZ_NEWS0(ut8, len + 1);\n\tif (!buf) {\n\t\treturn NULL;\n\t}\n\tint ret = rz_buf_read_at(binfile->buf, section->paddr, buf, len);\n\tif (ret != len) {\n\t\tfree(buf);\n\t\treturn NULL;\n\t}\n\t\/\/ Actually parse the section\n\tRzBinDwarfLineInfo *r = parse_line_raw(binfile, buf, len, mask, binfile->o && binfile->o->info && binfile->o->info->big_endian, info);\n\tfree(buf);\n\treturn r;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":387645,"func":"static int read_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf,\n\t\t\t unsigned int size)\n{\n\tstruct user_element *ue = kctl->private_data;\n\n\tif (ue->tlv_data_size == 0 || ue->tlv_data == NULL)\n\t\treturn -ENXIO;\n\n\tif (size < ue->tlv_data_size)\n\t\treturn -ENOSPC;\n\n\tif (copy_to_user(buf, ue->tlv_data, ue->tlv_data_size))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":513208,"func":"static void plugin_variables_deinit(struct st_plugin_int *plugin)\n{\n\n  for (sys_var *var= plugin->system_vars; var; var= var->next)\n    (*var->test_load)= FALSE;\n  mysql_del_sys_var_chain(plugin->system_vars);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":292234,"func":"inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data)\n{\n\tstruct hostent *HostAddr;\n\n\tHostAddr = gethostbyname (ip);\n\tif (HostAddr)\n\t{\n\t\tprefs.dcc_ip = ((struct in_addr *) HostAddr->h_addr)->s_addr;\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session,\n\t\t\t\t\t\t\t\t\t  inet_ntoa (*((struct in_addr *) HostAddr->h_addr)),\n\t\t\t\t\t\t\t\t\t  NULL, NULL, NULL, 0, tags_data->timestamp);\n\t}\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":442796,"func":"convert_to_network(char *buffer, size_t length)\n{\n  CURLcode rc;\n\n  \/* translate from the host encoding to the network encoding *\/\n  char *input_ptr, *output_ptr;\n  size_t in_bytes, out_bytes;\n\n  \/* open an iconv conversion descriptor if necessary *\/\n  if(outbound_cd == (iconv_t)-1) {\n    outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,\n                             CURL_ICONV_CODESET_OF_HOST);\n    if(outbound_cd == (iconv_t)-1) {\n      return CURLE_CONV_FAILED;\n    }\n  }\n  \/* call iconv *\/\n  input_ptr = output_ptr = buffer;\n  in_bytes = out_bytes = length;\n  rc = iconv(outbound_cd, &input_ptr,  &in_bytes,\n                          &output_ptr, &out_bytes);\n  if ((rc == -1) || (in_bytes != 0)) {\n    return CURLE_CONV_FAILED;\n  }\n\n  return CURLE_OK;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":500640,"func":"int sftp_dir_eof(sftp_dir dir) {\n  return dir->eof;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":197318,"func":"  void Compute(OpKernelContext* ctx) override {\n    const Tensor& handle = ctx->input(0);\n    const string& name = handle.scalar<tstring>()();\n    auto session_state = ctx->session_state();\n    OP_REQUIRES(ctx, session_state != nullptr,\n                errors::FailedPrecondition(\n                    \"DeleteSessionTensor called on null session state\"));\n    OP_REQUIRES_OK(ctx, session_state->DeleteTensor(name));\n  }","target":1,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":234817,"func":"static void btrfs_report_missing_device(struct btrfs_fs_info *fs_info,\n\t\t\t\t\tu64 devid, u8 *uuid, bool error)\n{\n\tif (error)\n\t\tbtrfs_err_rl(fs_info, \"devid %llu uuid %pU is missing\",\n\t\t\t      devid, uuid);\n\telse\n\t\tbtrfs_warn_rl(fs_info, \"devid %llu uuid %pU is missing\",\n\t\t\t      devid, uuid);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":462302,"func":"status_end_id_list(stream * s)\n{                               \/* HACK: we know that there's at least one character in the buffer. *\/\n    if (*s->cursor.w.ptr != '\\n')\n        stputs(s, \"\\\"\\r\\n\");\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":509478,"func":"bool ha_maria::is_changed() const\n{\n  return file->state->changed;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":196817,"func":"njs_array_convert_to_slow_array(njs_vm_t *vm, njs_array_t *array)\n{\n    uint32_t           i, length;\n    njs_value_t        index, value;\n    njs_object_prop_t  *prop;\n\n    njs_set_array(&value, array);\n    array->object.fast_array = 0;\n\n    length = array->length;\n\n    for (i = 0; i < length; i++) {\n        if (njs_is_valid(&array->start[i])) {\n            njs_uint32_to_string(&index, i);\n            prop = njs_object_property_add(vm, &value, &index, 0);\n            if (njs_slow_path(prop == NULL)) {\n                return NJS_ERROR;\n            }\n\n            prop->value = array->start[i];\n        }\n    }\n\n    \/* GC: release value. *\/\n\n    njs_mp_free(vm->mem_pool, array->start);\n    array->start = NULL;\n\n    return NJS_OK;\n}","target":1,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":261988,"func":"static void free_bundle_hash_entry(void *freethis)\n{\n  struct connectbundle *b = (struct connectbundle *) freethis;\n\n  bundle_destroy(b);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":489215,"func":"int hfsplus_find_cat(struct super_block *sb, u32 cnid,\n\t\t     struct hfs_find_data *fd)\n{\n\thfsplus_cat_entry tmp;\n\tint err;\n\tu16 type;\n\n\thfsplus_cat_build_key(sb, fd->search_key, cnid, NULL);\n\terr = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry));\n\tif (err)\n\t\treturn err;\n\n\ttype = be16_to_cpu(tmp.type);\n\tif (type != HFSPLUS_FOLDER_THREAD && type != HFSPLUS_FILE_THREAD) {\n\t\tprintk(KERN_ERR \"hfs: found bad thread record in catalog\\n\");\n\t\treturn -EIO;\n\t}\n\n\tif (be16_to_cpu(tmp.thread.nodeName.length) > 255) {\n\t\tprintk(KERN_ERR \"hfs: catalog name length corrupted\\n\");\n\t\treturn -EIO;\n\t}\n\n\thfsplus_cat_build_key_uni(fd->search_key, be32_to_cpu(tmp.thread.parentID),\n\t\t\t\t &tmp.thread.nodeName);\n\treturn hfs_brec_find(fd);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":289241,"func":"static int snd_pcm_oss_nonblock(struct file * file)\n{\n\tspin_lock(&file->f_lock);\n\tfile->f_flags |= O_NONBLOCK;\n\tspin_unlock(&file->f_lock);\n\treturn 0;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":231694,"func":"  void deliverDataWithoutErrorCheck(\n      Buf data,\n      bool writes = true,\n      folly::SocketAddress* peer = nullptr) {\n    data->coalesce();\n    server->onNetworkData(\n        peer == nullptr ? clientAddr : *peer,\n        NetworkData(std::move(data), Clock::now()));\n    if (writes) {\n      loopForWrites();\n    }\n  }","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":301343,"func":"static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,\n\t\t\t\tuint32 share_mode, uint32 access_mask)\n{\n\tSTART_PROFILE(syscall_kernel_flock);\n\tkernel_flock(fsp->fh->fd, share_mode, access_mask);\n\tEND_PROFILE(syscall_kernel_flock);\n\treturn 0;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":402669,"func":"long verbosity(void)\n{\n\tif (!verbose)\n\t\treturn 0;\n\treturn *verbose;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":267864,"func":"void SingleFromSingle(const size_t xsize,\n                      const pixel_type* const JXL_RESTRICT row_in,\n                      const float factor, Image3F* decoded, size_t c, size_t y,\n                      Rect& rect) {\n  JXL_DASSERT(xsize <= rect.xsize());\n  const HWY_FULL(float) df;\n  const Rebind<pixel_type, HWY_FULL(float)> di;  \/\/ assumes pixel_type <= float\n\n  float* const JXL_RESTRICT row_out = rect.PlaneRow(decoded, c, y);\n\n  const auto factor_v = Set(df, factor);\n  for (size_t x = 0; x < xsize; x += Lanes(di)) {\n    const auto in = Load(di, row_in + x);\n    const auto out = ConvertTo(df, in) * factor_v;\n    Store(out, df, row_out + x);\n  }\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":339717,"func":"static double ratio (Bigint *a, Bigint *b)\n{\n\t_double da, db;\n\tint k, ka, kb;\n\n\tvalue(da) = b2d(a, &ka);\n\tvalue(db) = b2d(b, &kb);\n#ifdef Pack_32\n\tk = ka - kb + 32*(a->wds - b->wds);\n#else\n\tk = ka - kb + 16*(a->wds - b->wds);\n#endif\n#ifdef IBM\n\tif (k > 0) {\n\t\tword0(da) += (k >> 2)*Exp_msk1;\n\t\tif (k &= 3) {\n\t\t\tda *= 1 << k;\n\t\t}\n\t} else {\n\t\tk = -k;\n\t\tword0(db) += (k >> 2)*Exp_msk1;\n\t\tif (k &= 3)\n\t\t\tdb *= 1 << k;\n\t}\n#else\n\tif (k > 0) {\n\t\tword0(da) += k*Exp_msk1;\n\t} else {\n\t\tk = -k;\n\t\tword0(db) += k*Exp_msk1;\n\t}\n#endif\n\treturn value(da) \/ value(db);\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":267867,"func":"void RgbFromSingle(const size_t xsize,\n                   const pixel_type* const JXL_RESTRICT row_in,\n                   const float factor, Image3F* decoded, size_t \/*c*\/, size_t y,\n                   Rect& rect) {\n  JXL_DASSERT(xsize <= rect.xsize());\n  const HWY_FULL(float) df;\n  const Rebind<pixel_type, HWY_FULL(float)> di;  \/\/ assumes pixel_type <= float\n\n  float* const JXL_RESTRICT row_out_r = rect.PlaneRow(decoded, 0, y);\n  float* const JXL_RESTRICT row_out_g = rect.PlaneRow(decoded, 1, y);\n  float* const JXL_RESTRICT row_out_b = rect.PlaneRow(decoded, 2, y);\n\n  const auto factor_v = Set(df, factor);\n  for (size_t x = 0; x < xsize; x += Lanes(di)) {\n    const auto in = Load(di, row_in + x);\n    const auto out = ConvertTo(df, in) * factor_v;\n    Store(out, df, row_out_r + x);\n    Store(out, df, row_out_g + x);\n    Store(out, df, row_out_b + x);\n  }\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":244078,"func":"GF_Err stvi_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_StereoVideoBox *ptr = (GF_StereoVideoBox *)s;\n\n\tISOM_DECREASE_SIZE(ptr, 12);\n\tgf_bs_read_int(bs, 30);\n\tptr->single_view_allowed = gf_bs_read_int(bs, 2);\n\tptr->stereo_scheme = gf_bs_read_u32(bs);\n\tptr->sit_len = gf_bs_read_u32(bs);\n\tISOM_DECREASE_SIZE(ptr, ptr->sit_len);\n\n\tptr->stereo_indication_type = gf_malloc(sizeof(char)*ptr->sit_len);\n\tif (!ptr->stereo_indication_type) return GF_OUT_OF_MEM;\n\n\tgf_bs_read_data(bs, ptr->stereo_indication_type, ptr->sit_len);\n\treturn GF_OK;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":502712,"func":"int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,\n                                unsigned int sid_ctx_len)\n{\n    if (sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) {\n        SSLerr(SSL_F_SSL_SESSION_SET1_ID_CONTEXT,\n               SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG);\n        return 0;\n    }\n    s->sid_ctx_length = sid_ctx_len;\n    memcpy(s->sid_ctx, sid_ctx, sid_ctx_len);\n\n    return 1;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":328895,"func":"R_API RBinJavaField *r_bin_java_get_method_code_attribute_with_addr(RBinJavaObj *bin, ut64 addr) {\n\tRListIter *iter = NULL, *iter_tmp = NULL;\n\tRBinJavaField *fm_type, *res = NULL;\n\tif (!bin && R_BIN_JAVA_GLOBAL_BIN) {\n\t\tbin = R_BIN_JAVA_GLOBAL_BIN;\n\t}\n\tif (!bin) {\n\t\teprintf (\"Attempting to analyse function when the R_BIN_JAVA_GLOBAL_BIN has not been set.\\n\");\n\t\treturn NULL;\n\t}\n\tr_list_foreach_safe (bin->methods_list, iter, iter_tmp, fm_type) {\n\t\tut64 offset = r_bin_java_get_method_code_offset (fm_type) + bin->loadaddr,\n\t\tsize = r_bin_java_get_method_code_size (fm_type);\n\t\tif (addr >= offset && addr <= size + offset) {\n\t\t\tres = fm_type;\n\t\t}\n\t}\n\treturn res;\n}","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":512989,"func":"  const my_decimal *const_ptr_my_decimal() const { return &decimal_value; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":386509,"func":"void DL_Dxf::addSolid(DL_CreationInterface* creationInterface) {\n    DL_SolidData sd;\n    \n    for (int k = 0; k < 4; k++) {\n       sd.x[k] = getRealValue(10 + k, 0.0);\n       sd.y[k] = getRealValue(20 + k, 0.0);\n       sd.z[k] = getRealValue(30 + k, 0.0);\n    }\n    creationInterface->addSolid(sd);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":445894,"func":"file_list_drag_begin (GtkWidget          *widget,\n\t\t      GdkDragContext     *context,\n\t\t      gpointer            data)\n{\n\tFrWindow *window = data;\n\n\tdebug (DEBUG_INFO, \"::DragBegin -->\\n\");\n\n\tif (window->priv->activity_ref > 0)\n\t\treturn FALSE;\n\n\t_g_clear_object (&window->priv->drag_destination_folder);\n\n\tg_free (window->priv->drag_base_dir);\n\twindow->priv->drag_base_dir = NULL;\n\n\tgdk_property_change (gdk_drag_context_get_source_window (context),\n\t\t\t     XDS_ATOM, TEXT_ATOM,\n\t\t\t     8, GDK_PROP_MODE_REPLACE,\n\t\t\t     (guchar *) XDS_FILENAME,\n\t\t\t     strlen (XDS_FILENAME));\n\n\treturn TRUE;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":263483,"func":"static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)\n{\n\tstruct sock *sk;\n\n\tsco_conn_lock(conn);\n\tsk = conn->sk;\n\tsco_conn_unlock(conn);\n\n\tif (!sk)\n\t\tgoto drop;\n\n\tBT_DBG(\"sk %p len %u\", sk, skb->len);\n\n\tif (sk->sk_state != BT_CONNECTED)\n\t\tgoto drop;\n\n\tif (!sock_queue_rcv_skb(sk, skb))\n\t\treturn;\n\ndrop:\n\tkfree_skb(skb);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":386513,"func":"void DL_Dxf::addLayer(DL_CreationInterface* creationInterface) {\n    \/\/ correct some invalid attributes for layers:\n    attrib = creationInterface->getAttributes();\n    if (attrib.getColor()==256 || attrib.getColor()==0) {\n        attrib.setColor(7);\n    }\n    if (attrib.getWidth()<0) {\n        attrib.setWidth(1);\n    }\n\n    std::string linetype = attrib.getLinetype();\n    std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper);\n    if (linetype==\"BYLAYER\" || linetype==\"BYBLOCK\") {\n        attrib.setLinetype(\"CONTINUOUS\");\n    }\n\n    \/\/ add layer\n    std::string name = getStringValue(2, \"\");\n    if (name.length()==0) {\n        return;\n    }\n\n    creationInterface->addLayer(DL_LayerData(name, getIntValue(70, 0)));\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":398493,"func":"static inline RzBinDwarfLocList *create_loc_list(ut64 offset) {\n\tRzBinDwarfLocList *list = RZ_NEW0(RzBinDwarfLocList);\n\tif (list) {\n\t\tlist->list = rz_list_new();\n\t\tlist->offset = offset;\n\t}\n\treturn list;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":226249,"func":"\nvoid dfla_box_del(GF_Box *s)\n{\n\tGF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s;\n\tif (ptr->data) gf_free(ptr->data);\n\tgf_free(ptr);","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":459171,"func":"static void tcf_proto_destroy(struct tcf_proto *tp, bool rtnl_held,\n\t\t\t      bool sig_destroy, struct netlink_ext_ack *extack)\n{\n\ttp->ops->destroy(tp, rtnl_held, extack);\n\tif (sig_destroy)\n\t\ttcf_proto_signal_destroyed(tp->chain, tp);\n\ttcf_chain_put(tp->chain);\n\tmodule_put(tp->ops->owner);\n\tkfree_rcu(tp, rcu);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":224156,"func":"  Status check_index_ordering(const Tensor& indices) {\n    if (indices.NumElements() == 0) {\n      return errors::InvalidArgument(\"Indices are empty\");\n    }\n\n    auto findices = indices.flat<int>();\n\n    for (std::size_t i = 0; i < findices.dimension(0) - 1; ++i) {\n      if (findices(i) < findices(i + 1)) {\n        continue;\n      }\n\n      return errors::InvalidArgument(\"Indices are not strictly ordered\");\n    }\n\n    return Status::OK();\n  }","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":210278,"func":"void qemu_ram_free(struct uc_struct *uc, RAMBlock *block)\n{\n    if (!block) {\n        return;\n    }\n\n    \/\/if (block->host) {\n    \/\/    ram_block_notify_remove(block->host, block->max_length);\n    \/\/}\n\n    QLIST_REMOVE(block, next);\n    uc->ram_list.mru_block = NULL;\n    \/* Write list before version *\/\n    \/\/smp_wmb();\n    \/\/ call_rcu(block, reclaim_ramblock, rcu);\n    reclaim_ramblock(uc, block);\n}","target":1,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":301410,"func":"static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data,\n\t\t\tsize_t n, off_t offset)\n{\n\tssize_t result;\n\n#if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)\n\tSTART_PROFILE_BYTES(syscall_pwrite, n);\n\tresult = sys_pwrite(fsp->fh->fd, data, n, offset);\n\tEND_PROFILE(syscall_pwrite);\n\n\tif (result == -1 && errno == ESPIPE) {\n\t\t\/* Maintain the fiction that pipes can be sought on. *\/\n\t\tresult = SMB_VFS_WRITE(fsp, data, n);\n\t}\n\n#else \/* HAVE_PWRITE *\/\n\toff_t   curr;\n\tint         lerrno;\n\n\tcurr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);\n\tif (curr == -1) {\n\t\treturn -1;\n\t}\n\n\tif (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {\n\t\treturn -1;\n\t}\n\n\tresult = SMB_VFS_WRITE(fsp, data, n);\n\tlerrno = errno;\n\n\tSMB_VFS_LSEEK(fsp, curr, SEEK_SET);\n\terrno = lerrno;\n\n#endif \/* HAVE_PWRITE *\/\n\n\treturn result;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":301359,"func":"static int vfswrap_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)\n{\n\tint result;\n\n\tSTART_PROFILE(syscall_chmod);\n\n\t\/*\n\t * We need to do this due to the fact that the default POSIX ACL\n\t * chmod modifies the ACL *mask* for the group owner, not the\n\t * group owner bits directly. JRA.\n\t *\/\n\n\n\t{\n\t\tint saved_errno = errno; \/* We might get ENOSYS *\/\n\t\tif ((result = SMB_VFS_CHMOD_ACL(handle->conn, path, mode)) == 0) {\n\t\t\tEND_PROFILE(syscall_chmod);\n\t\t\treturn result;\n\t\t}\n\t\t\/* Error - return the old errno. *\/\n\t\terrno = saved_errno;\n\t}\n\n\tresult = chmod(path, mode);\n\tEND_PROFILE(syscall_chmod);\n\treturn result;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":229155,"func":"static void guest_reset(VirtIOSerial *vser)\n{\n    VirtIOSerialPort *port;\n    VirtIOSerialPortClass *vsc;\n\n    QTAILQ_FOREACH(port, &vser->ports, next) {\n        vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);\n        if (port->guest_connected) {\n            port->guest_connected = false;\n            if (vsc->set_guest_connected) {\n                vsc->set_guest_connected(port, false);\n            }\n        }\n    }\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":316999,"func":"static int selinux_bpf(int cmd, union bpf_attr *attr,\n\t\t\t\t     unsigned int size)\n{\n\tu32 sid = current_sid();\n\tint ret;\n\n\tswitch (cmd) {\n\tcase BPF_MAP_CREATE:\n\t\tret = avc_has_perm(&selinux_state,\n\t\t\t\t   sid, sid, SECCLASS_BPF, BPF__MAP_CREATE,\n\t\t\t\t   NULL);\n\t\tbreak;\n\tcase BPF_PROG_LOAD:\n\t\tret = avc_has_perm(&selinux_state,\n\t\t\t\t   sid, sid, SECCLASS_BPF, BPF__PROG_LOAD,\n\t\t\t\t   NULL);\n\t\tbreak;\n\tdefault:\n\t\tret = 0;\n\t\tbreak;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":225974,"func":"\nGF_Box *dOps_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_OpusSpecificBox, GF_ISOM_BOX_TYPE_DOPS);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":226388,"func":"void pmax_box_del(GF_Box *s)\n{\n\tgf_free((GF_PMAXBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":317297,"func":"static int selinux_shm_associate(struct kern_ipc_perm *shp, int shmflg)\n{\n\tstruct ipc_security_struct *isec;\n\tstruct common_audit_data ad;\n\tu32 sid = current_sid();\n\n\tisec = selinux_ipc(shp);\n\n\tad.type = LSM_AUDIT_DATA_IPC;\n\tad.u.ipc_id = shp->key;\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    sid, isec->sid, SECCLASS_SHM,\n\t\t\t    SHM__ASSOCIATE, &ad);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":391626,"func":"static ssize_t remove_slot_show(struct kobject *kobj,\n\t\t\t\tstruct kobj_attribute *attr, char *buf)\n{\n\treturn sprintf(buf, \"0\\n\");\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":241059,"func":"static int create_lockfile(void)\n{\n\tint rv, fd;\n\n\tfd = -1;\n\trv = _lockfile(O_CREAT | O_WRONLY, &fd, NULL);\n\n\tif (fd == -1) {\n\t\tlog_error(\"lockfile %s open error %d: %s\",\n\t\t\t\tcl.lockfile, rv, strerror(rv));\n\t\treturn -1;\n\t}\n\n\tif (rv < 0) {\n\t\tlog_error(\"lockfile %s setlk error %d: %s\",\n\t\t\t\tcl.lockfile, rv, strerror(rv));\n\t\tgoto fail;\n\t}\n\n\trv = write_daemon_state(fd, BOOTHD_STARTING);\n\tif (rv != 0) {\n\t\tlog_error(\"write daemon state %d to lockfile error %s: %s\",\n\t\t\t\tBOOTHD_STARTING, cl.lockfile, strerror(errno));\n\t\tgoto fail;\n\t}\n\n\tif (is_root()) {\n\t\tif (fchown(fd, booth_conf->uid, booth_conf->gid) < 0)\n\t\t\tlog_error(\"fchown() on lockfile said %d: %s\",\n\t\t\t\t\terrno, strerror(errno));\n\t}\n\n\treturn fd;\n\nfail:\n\tclose(fd);\n\treturn -1;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":359250,"func":"DEFUN (no_neighbor_route_reflector_client,\n       no_neighbor_route_reflector_client_cmd,\n       NO_NEIGHBOR_CMD2 \"route-reflector-client\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Configure a neighbor as Route Reflector client\\n\")\n{\n  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t bgp_node_safi (vty),\n\t\t\t\t PEER_FLAG_REFLECTOR_CLIENT);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":225470,"func":"bool IsTensorIdPortValid(const TensorId& tensor_id) {\n  return tensor_id.index() >= Graph::kControlSlot;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":226224,"func":"\nGF_Box *mvcg_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MultiviewGroupBox, GF_ISOM_BOX_TYPE_MVCG);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":209026,"func":"virNodeDeviceGetMdevTypesCaps(const char *sysfspath,\n                              virMediatedDeviceTypePtr **mdev_types,\n                              size_t *nmdev_types)\n{\n    virMediatedDeviceTypePtr *types = NULL;\n    size_t ntypes = 0;\n    size_t i;\n\n    \/* this could be a refresh, so clear out the old data *\/\n    for (i = 0; i < *nmdev_types; i++)\n       virMediatedDeviceTypeFree(*mdev_types[i]);\n    VIR_FREE(*mdev_types);\n    *nmdev_types = 0;\n\n    if (virMediatedDeviceGetMdevTypes(sysfspath, &types, &ntypes) < 0)\n        return -1;\n\n    *mdev_types = g_steal_pointer(&types);\n    *nmdev_types = ntypes;\n\n    return 0;\n}","target":1,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":308184,"func":"static int fastrpc_map_find(struct fastrpc_user *fl, int fd,\n\t\t\t    struct fastrpc_map **ppmap)\n{\n\tstruct fastrpc_map *map = NULL;\n\n\tmutex_lock(&fl->mutex);\n\tlist_for_each_entry(map, &fl->maps, node) {\n\t\tif (map->fd == fd) {\n\t\t\tfastrpc_map_get(map);\n\t\t\t*ppmap = map;\n\t\t\tmutex_unlock(&fl->mutex);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tmutex_unlock(&fl->mutex);\n\n\treturn -ENOENT;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":181940,"func":" void OverlayWindowViews::ButtonPressed(views::Button* sender,\n                                       const ui::Event& event) {\n  if (sender == close_controls_view_.get())\n    controller_->Close(true \/* should_pause_video *\/,\n                       true \/* should_reset_pip_player *\/);\n\n  if (sender == play_pause_controls_view_.get())\n    TogglePlayPause();\n\n  if (sender == first_custom_controls_view_.get())\n    controller_->CustomControlPressed(first_custom_controls_view_->id());\n\n  if (sender == second_custom_controls_view_.get())\n    controller_->CustomControlPressed(second_custom_controls_view_->id());\n}\n","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":411924,"func":"sort_version_list(smartlist_t *versions, int remove_duplicates)\n{\n  smartlist_sort(versions, _compare_tor_version_str_ptr);\n\n  if (remove_duplicates)\n    smartlist_uniq(versions, _compare_tor_version_str_ptr, _tor_free);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":198169,"func":"TfLiteTensor* GetVariableInput(TfLiteContext* context, const TfLiteNode* node,\n                               int index) {\n  TfLiteTensor* tensor = GetMutableInput(context, node, index);\n  return tensor->is_variable ? tensor : nullptr;\n}","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":440883,"func":"AuditPrefix(void)\n{\n    time_t tm;\n    char *autime, *s;\n    char *tmpBuf;\n    int len;\n\n    time(&tm);\n    autime = ctime(&tm);\n    if ((s = strchr(autime, '\\n')))\n        *s = '\\0';\n    len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + 1;\n    tmpBuf = malloc(len);\n    if (!tmpBuf)\n        return NULL;\n    snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long) getpid());\n    return tmpBuf;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":294631,"func":"date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vw, vd, vsg;\n    VALUE argv2[4];\n\n    rb_scan_args(argc, argv, \"31\", &vy, &vw, &vd, &vsg);\n\n    RETURN_FALSE_UNLESS_NUMERIC(vy);\n    RETURN_FALSE_UNLESS_NUMERIC(vw);\n    RETURN_FALSE_UNLESS_NUMERIC(vd);\n    argv2[0] = vy;\n    argv2[1] = vw;\n    argv2[2] = vd;\n    if (argc < 4)\n\targv2[3] = INT2FIX(DEFAULT_SG);\n    else\n\targv2[3] = vsg;\n\n    if (NIL_P(valid_commercial_sub(4, argv2, klass, 0)))\n\treturn Qfalse;\n    return Qtrue;\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":297211,"func":"PHP_MINIT_FUNCTION(exif)\n{\n\tREGISTER_INI_ENTRIES();\n\tif (zend_hash_exists(&module_registry, \"mbstring\", sizeof(\"mbstring\"))) {\n\t\tREGISTER_LONG_CONSTANT(\"EXIF_USE_MBSTRING\", 1, CONST_CS | CONST_PERSISTENT);\n\t} else {\n\t\tREGISTER_LONG_CONSTANT(\"EXIF_USE_MBSTRING\", 0, CONST_CS | CONST_PERSISTENT);\n\t}\n\treturn SUCCESS;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":263506,"func":"static void sco_sock_set_timer(struct sock *sk, long timeout)\n{\n\tif (!sco_pi(sk)->conn)\n\t\treturn;\n\n\tBT_DBG(\"sock %p state %d timeout %ld\", sk, sk->sk_state, timeout);\n\tcancel_delayed_work(&sco_pi(sk)->conn->timeout_work);\n\tschedule_delayed_work(&sco_pi(sk)->conn->timeout_work, timeout);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":482643,"func":"static inline struct net *xt_net(const struct xt_action_param *par)\n{\n\treturn par->state->net;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":326091,"func":"regcomp_start(\n    char_u\t*expr,\n    int\t\tre_flags)\t    \/\/ see vim_regcomp()\n{\n    initchr(expr);\n    if (re_flags & RE_MAGIC)\n\treg_magic = MAGIC_ON;\n    else\n\treg_magic = MAGIC_OFF;\n    reg_string = (re_flags & RE_STRING);\n    reg_strict = (re_flags & RE_STRICT);\n    get_cpo_flags();\n\n    num_complex_braces = 0;\n    regnpar = 1;\n    CLEAR_FIELD(had_endbrace);\n#ifdef FEAT_SYN_HL\n    regnzpar = 1;\n    re_has_z = 0;\n#endif\n    regsize = 0L;\n    reg_toolong = FALSE;\n    regflags = 0;\n#if defined(FEAT_SYN_HL) || defined(PROTO)\n    had_eol = FALSE;\n#endif\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":312393,"func":"qf_parse_fmt_e(regmatch_T *rmp, int midx, qffields_T *fields)\n{\n    if (rmp->startp[midx] == NULL)\n\treturn QF_FAIL;\n    fields->end_lnum = atol((char *)rmp->startp[midx]);\n    return QF_OK;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":293539,"func":"PJ_DEF(void) pj_cis_add_range(pj_cis_t *cis, int cstart, int cend)\n{\n    \/* Can not set zero. This is the requirement of the parser. *\/\n    pj_assert(cstart > 0);\n\n    while (cstart != cend) {\n        PJ_CIS_SET(cis, cstart);\n\t++cstart;\n    }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":513060,"func":"  virtual ~Item_const() {}","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":254901,"func":"DocumentSource::GetModPathsReturn GroupFromFirstDocumentTransformation::getModifiedPaths() const {\n    \/\/ Replaces the entire root, so all paths are modified.\n    return {DocumentSource::GetModPathsReturn::Type::kAllPaths, std::set<std::string>{}, {}};\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":252311,"func":"inline void wenc14(unsigned short a, unsigned short b, unsigned short &l,\n                   unsigned short &h) {\n  short as = static_cast<short>(a);\n  short bs = static_cast<short>(b);\n\n  short ms = (as + bs) >> 1;\n  short ds = as - bs;\n\n  l = static_cast<unsigned short>(ms);\n  h = static_cast<unsigned short>(ds);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":413826,"func":"void CallInfo::set_handle(Klass* resolved_klass,\n                          const methodHandle& resolved_method,\n                          Handle resolved_appendix, TRAPS) {\n  guarantee(resolved_method.not_null(), \"resolved method is null\");\n  assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic ||\n         resolved_method->is_compiled_lambda_form(),\n         \"linkMethod must return one of these\");\n  int vtable_index = Method::nonvirtual_vtable_index;\n  assert(!resolved_method->has_vtable_index(), \"\");\n  set_common(resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);\n  _resolved_appendix = resolved_appendix;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":447040,"func":"    long CurlIo::write(const byte* data, long wcount)\n    {\n        if (p_->protocol_ == pHttp || p_->protocol_ == pHttps) {\n            return RemoteIo::write(data, wcount);\n        } else {\n            throw Error(1, \"doesnt support write for this protocol.\");\n        }\n    }","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":101682,"func":"void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)\n{\n    launchOptions.processType = ProcessLauncher::WebProcess;\n    platformGetLaunchOptions(launchOptions);\n}\n","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":215188,"func":"void mobi_buffer_move(MOBIBuffer *buf, const int offset, const size_t len) {\n    size_t aoffset = (size_t) abs(offset);\n    unsigned char *source = buf->data + buf->offset;\n    if (offset >= 0) {\n        if (buf->offset + aoffset + len > buf->maxlen) {\n            debug_print(\"%s\", \"End of buffer\\n\");\n            buf->error = MOBI_BUFFER_END;\n            return;\n        }\n        source += aoffset;\n    } else {\n        if (buf->offset < aoffset) {\n            debug_print(\"%s\", \"End of buffer\\n\");\n            buf->error = MOBI_BUFFER_END;\n            return;\n        }\n        source -= aoffset;\n    }\n    memmove(buf->data + buf->offset, source, len);\n    buf->offset += len;\n}","target":1,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":446100,"func":"atusb_set_txpower(struct ieee802154_hw *hw, s32 mbm)\n{\n\tstruct atusb *atusb = hw->priv;\n\tu32 i;\n\n\tfor (i = 0; i < hw->phy->supported.tx_powers_size; i++) {\n\t\tif (hw->phy->supported.tx_powers[i] == mbm)\n\t\t\treturn atusb_write_subreg(atusb, SR_TX_PWR_23X, i);\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":294498,"func":"m_hour(union DateData *x)\n{\n    if (simple_dat_p(x))\n\treturn 0;\n    else {\n\tget_c_time(x);\n#ifndef USE_PACK\n\treturn x->c.hour;\n#else\n\treturn EX_HOUR(x->c.pc);\n#endif\n    }\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":246744,"func":"u32 parse_mpegu(char *arg_val, u32 opt)\n{\n\tpack_file = arg_val;\n\tpack_wgt = GF_TRUE;\n\treturn 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":267965,"func":"R_API bool r_bin_file_deref(RBin *bin, RBinFile *a) {\n\tr_return_val_if_fail (bin && a, false);\n\tif (!r_bin_cur_object (bin)) {\n\t\treturn false;\n\t}\n\tbin->cur = NULL;\n\treturn true;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":369260,"func":"\nstatic void io_free_file_tables(struct io_file_table *table)\n{\n\tkvfree(table->files);\n\ttable->files = NULL;","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":234173,"func":"print_addr_index (unsigned int idx, unsigned int len)\n{\n  static char buf[15];\n  snprintf (buf, sizeof (buf), \"[%d]\", idx);\n  printf (\"%*s \", len, buf);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":385832,"func":"int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,\n\tstruct file *filp)\n{\n\tint ret;\n\tstruct iattr newattrs;\n\n\t\/* Not pretty: \"inode->i_size\" shouldn't really be signed. But it is. *\/\n\tif (length < 0)\n\t\treturn -EINVAL;\n\n\tnewattrs.ia_size = length;\n\tnewattrs.ia_valid = ATTR_SIZE | time_attrs;\n\tif (filp) {\n\t\tnewattrs.ia_file = filp;\n\t\tnewattrs.ia_valid |= ATTR_FILE;\n\t}\n\n\t\/* Remove suid\/sgid on truncate too *\/\n\tret = should_remove_suid(dentry);\n\tif (ret)\n\t\tnewattrs.ia_valid |= ret | ATTR_FORCE;\n\n\tmutex_lock(&dentry->d_inode->i_mutex);\n\tret = notify_change(dentry, &newattrs);\n\tmutex_unlock(&dentry->d_inode->i_mutex);\n\treturn ret;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":345137,"func":"pxa3xx_gcu_wait_free(struct pxa3xx_gcu_priv *priv)\n{\n\tint ret = 0;\n\n\tQDUMP(\"Waiting for free...\");\n\n\t\/* Does not need to be atomic. There's a lock in user space,\n\t * but anyhow, this is just for statistics. *\/\n\tpriv->shared->num_wait_free++;\n\n\twhile (!priv->free) {\n\t\tu32 rbexhr = gc_readl(priv, REG_GCRBEXHR);\n\n\t\tret = wait_event_interruptible_timeout(priv->wait_free,\n\t\t\t\t\t\t       priv->free, HZ*4);\n\n\t\tif (ret < 0)\n\t\t\tbreak;\n\n\t\tif (ret > 0)\n\t\t\tcontinue;\n\n\t\tif (gc_readl(priv, REG_GCRBEXHR) == rbexhr) {\n\t\t\tQERROR(\"TIMEOUT\");\n\t\t\tret = -ETIMEDOUT;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tQDUMP(\"done\");\n\n\treturn ret;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":486795,"func":"static inline unsigned tx_desc_get_wrap(uint32_t *desc)\n{\n    return (desc[1] & DESC_1_TX_WRAP) ? 1 : 0;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":512541,"func":"  bool val_native(THD *thd, Native *to)\n  {\n    return m_value.to_native(to, decimals);\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":310285,"func":"dirserv_free_all(void)\n{\n  dirserv_free_fingerprint_list();\n\n  cached_dir_decref(the_directory);\n  clear_cached_dir(&the_runningrouters);\n  cached_dir_decref(the_v2_networkstatus);\n  cached_dir_decref(cached_directory);\n  clear_cached_dir(&cached_runningrouters);\n\n  digestmap_free(cached_v2_networkstatus, _free_cached_dir);\n  cached_v2_networkstatus = NULL;\n  strmap_free(cached_consensuses, _free_cached_dir);\n  cached_consensuses = NULL;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":244262,"func":"GF_Err lsrc_box_size(GF_Box *s)\n{\n\tGF_LASERConfigurationBox *ptr = (GF_LASERConfigurationBox *)s;\n\tptr->size += ptr->hdr_size;\n\treturn GF_OK;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":256145,"func":"ALWAYS_INLINE void LoadTwoScalars(const float** data, Packet* l1, Packet* l2) {\n  LoadSingleScalar(data, l1);\n  LoadSingleScalar(data, l2);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":236197,"func":"GF_Box *diST_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DIMSScriptTypesBox, GF_ISOM_BOX_TYPE_DIST);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":222670,"func":"void set_session_token(struct tmate_session *session, const char *token)\n{\n\tsession->session_token = xstrdup(token);\n\tsocket_path = get_socket_path(token);\n\n\txasprintf((char **)&session->obfuscated_session_token, \"%.4s...\",\n\t\t  session->session_token);\n\n\tsize_t size = cmdline_end - cmdline;\n\tmemset(cmdline, 0, size);\n\tsnprintf(cmdline, size-1, \"tmate-ssh-server [%s] %s %s\",\n\t\ttmate_session->obfuscated_session_token,\n\t\tsession->ssh_client.role == TMATE_ROLE_DAEMON ? \"(daemon)\" : \"(pty client)\",\n\t\tsession->ssh_client.ip_address);\n\n\tchar *log_prefix;\n\txasprintf(&log_prefix, \"[%s] \", session->obfuscated_session_token);\n\tset_log_prefix(log_prefix);\n\tfree(log_prefix);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":386480,"func":"void DL_Dxf::addDimRadial(DL_CreationInterface* creationInterface) {\n    DL_DimensionData d = getDimData();\n\n    DL_DimRadialData dr(\n        \/\/ definition point\n        getRealValue(15, 0.0),\n        getRealValue(25, 0.0),\n        getRealValue(35, 0.0),\n        \/\/ leader length:\n        getRealValue(40, 0.0));\n    creationInterface->addDimRadial(d, dr);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":512657,"func":"  Field::geometry_type get_geometry_type() const\n  {\n    return Type_geometry_attributes::get_geometry_type();\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":294524,"func":"date_s_jisx0301(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n    if (!NIL_P(opt)) argc--;\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"-4712-01-01\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        if (!NIL_P(opt)) argv2[argc2++] = opt;\n\tVALUE hash = date_s__jisx0301(argc2, argv2, klass);\n\treturn d_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":508844,"func":"bool st_select_lex_node::inc_in_sum_expr()           { return 1; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":509481,"func":"static void init_aria_psi_keys(void)\n{\n  const char* category= \"aria\";\n  int count;\n\n  count= array_elements(all_aria_mutexes);\n  mysql_mutex_register(category, all_aria_mutexes, count);\n\n  count= array_elements(all_aria_rwlocks);\n  mysql_rwlock_register(category, all_aria_rwlocks, count);\n\n  count= array_elements(all_aria_conds);\n  mysql_cond_register(category, all_aria_conds, count);\n\n  count= array_elements(all_aria_threads);\n  mysql_thread_register(category, all_aria_threads, count);\n\n  count= array_elements(all_aria_files);\n  mysql_file_register(category, all_aria_files, count);\n# ifdef HAVE_PSI_STAGE_INTERFACE\n  count= array_elements(all_aria_stages);\n  mysql_stage_register(category, all_aria_stages, count);\n# endif \/* HAVE_PSI_STAGE_INTERFACE *\/\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":512881,"func":"longlong Item_func_truth::val_int()\n{\n  return (val_bool() ? 1 : 0);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":219902,"func":"GF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber)\n{\n\tGF_TrackBox *trak;\n\tGF_UserDataMap *map;\n\tGF_HintTrackInfoBox *hnti;\n\n\ttrak = gf_isom_get_track_from_file(the_file, trackNumber);\n\tif (!trak) return GF_BAD_PARAM;\n\n\t\/\/currently, only RTP hinting supports SDP\n\tif (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM;\n\n\tmap = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);\n\tif (!map) return GF_ISOM_INVALID_FILE;\n\n\t\/\/we should have only one HNTI in the UDTA\n\tif (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE;\n\n\thnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0);\n\tif (!hnti->SDP) return GF_OK;\n\t\/\/and free the SDP\n\tgf_free(((GF_SDPBox *)hnti->SDP)->sdpText);\n\t((GF_SDPBox *)hnti->SDP)->sdpText = NULL;\n\treturn GF_OK;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":369434,"func":"\nstatic int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,\n\t\t\t\t    unsigned nr_args)\n{\n\tstruct io_uring_rsrc_update2 up;\n\n\tif (!nr_args)\n\t\treturn -EINVAL;\n\tmemset(&up, 0, sizeof(up));\n\tif (copy_from_user(&up, arg, sizeof(struct io_uring_rsrc_update)))\n\t\treturn -EFAULT;\n\tif (up.resv || up.resv2)\n\t\treturn -EINVAL;\n\treturn __io_register_rsrc_update(ctx, IORING_RSRC_FILE, &up, nr_args);","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":358128,"func":"sonmp_suite(void)\n{\n\tSuite *s = suite_create(\"SONMP\");\n\n#ifdef ENABLE_SONMP\n\tTCase *tc_send = tcase_create(\"Send SONMP packets\");\n\tTCase *tc_receive = tcase_create(\"Receive SONMP packets\");\n\n\ttcase_add_checked_fixture(tc_send, pcap_setup, pcap_teardown);\n\ttcase_add_test(tc_send, test_send_sonmp);\n\tsuite_add_tcase(s, tc_send);\n\n\ttcase_add_test(tc_receive, test_recv_sonmp);\n\tsuite_add_tcase(s, tc_receive);\n#endif\n\n\treturn s;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":247747,"func":"  TestUtilOptionsV2(\n      const envoy::config::listener::v3::Listener& listener,\n      const envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext& client_ctx_proto,\n      bool expect_success, Network::Address::IpVersion version)\n      : TestUtilOptionsBase(expect_success, version), listener_(listener),\n        client_ctx_proto_(client_ctx_proto), transport_socket_options_(nullptr) {\n    if (expect_success) {\n      setExpectedServerStats(\"ssl.handshake\").setExpectedClientStats(\"ssl.handshake\");\n    } else {\n      setExpectedServerStats(\"ssl.fail_verify_error\")\n          .setExpectedClientStats(\"ssl.connection_error\");\n    }\n  }","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":405361,"func":"void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)\n{\n\twhile ((dst = xfrm_dst_child(dst)) && dst->xfrm && dst->dev == dev) {\n\t\tdst->dev = blackhole_netdev;\n\t\tdev_hold(dst->dev);\n\t\tdev_put(dev);\n\t}\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":344255,"func":"l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {\n  typeerror(L, o, op, varinfo(L, o));\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":514294,"func":"static TABLE *item_rowid_table(Item *item)\n{\n  if (item->type() != Item::FUNC_ITEM)\n    return NULL;\n  Item_func *func= (Item_func *)item;\n  if (func->functype() != Item_func::TEMPTABLE_ROWID)\n    return NULL;\n  Item_temptable_rowid *itr= (Item_temptable_rowid *)func;\n  return itr->table;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":336521,"func":"void RedCharDeviceVDIPort::on_free_self_token()\n{\n    RedsState *reds = get_server();\n\n    if (reds->inputs_channel && reds->pending_mouse_event) {\n        spice_debug(\"pending mouse event\");\n        reds_handle_agent_mouse_event(reds, reds->inputs_channel->get_mouse_state());\n    }\n\n    if (reds->pending_device_display_info_message) {\n        spice_debug(\"pending device display info message\");\n        reds_send_device_display_info(reds);\n    }\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":365623,"func":"_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])\n{\n  long d, r;\n  char temp[LTOSTR_MAX_SIZE];\n  int count, k, start;\n\n  if (v < 0)\n    {\n      str[0] = '-';\n      start = 1;\n      v = -v;\n    }\n  else\n    start = 0;\n\n  count = 0;\n  do\n    {\n      d = v \/ 10;\n      r = v - d * 10;\n      temp[start + count] = '0' + (char) r;\n      count++;\n      v = d;\n    }\n  while (v && ((start+count) < LTOSTR_MAX_SIZE-1));\n\n  for (k = 0; k < count; k++)\n    str[k + start] = temp[start + count - k - 1];\n  str[count + start] = 0;\n  return str;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":199712,"func":"static void rtrs_clt_dev_release(struct device *dev)\n{\n\tstruct rtrs_clt_sess *clt = container_of(dev, struct rtrs_clt_sess,\n\t\t\t\t\t\t dev);\n\n\tkfree(clt);\n}","target":1,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":224995,"func":"sendTerminateConn(PGconn *conn)\n{\n\t\/*\n\t * Note that the protocol doesn't allow us to send Terminate messages\n\t * during the startup phase.\n\t *\/\n\tif (conn->sock != PGINVALID_SOCKET && conn->status == CONNECTION_OK)\n\t{\n\t\t\/*\n\t\t * Try to send \"close connection\" message to backend. Ignore any\n\t\t * error.\n\t\t *\/\n\t\tpqPutMsgStart('X', conn);\n\t\tpqPutMsgEnd(conn);\n\t\t(void) pqFlush(conn);\n\t}\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":312565,"func":"get_nth_entry(qf_list_T *qfl, int errornr, int *new_qfidx)\n{\n    qfline_T\t*qf_ptr = qfl->qf_ptr;\n    int\t\tqf_idx = qfl->qf_index;\n\n    \/\/ New error number is less than the current error number\n    while (errornr < qf_idx && qf_idx > 1 && qf_ptr->qf_prev != NULL)\n    {\n\t--qf_idx;\n\tqf_ptr = qf_ptr->qf_prev;\n    }\n    \/\/ New error number is greater than the current error number\n    while (errornr > qf_idx && qf_idx < qfl->qf_count &&\n\t\t\t\t\t\tqf_ptr->qf_next != NULL)\n    {\n\t++qf_idx;\n\tqf_ptr = qf_ptr->qf_next;\n    }\n\n    *new_qfidx = qf_idx;\n    return qf_ptr;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":225102,"func":"bool HasAttrStyleType(const OpDef::ArgDef& arg) {\n  return arg.type() != DT_INVALID || !arg.type_attr().empty() ||\n         !arg.type_list_attr().empty();\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":369384,"func":"\nstatic int io_eventfd_unregister(struct io_ring_ctx *ctx)\n{\n\tstruct io_ev_fd *ev_fd;\n\n\tev_fd = rcu_dereference_protected(ctx->io_ev_fd,\n\t\t\t\t\tlockdep_is_held(&ctx->uring_lock));\n\tif (ev_fd) {\n\t\tctx->has_evfd = false;\n\t\trcu_assign_pointer(ctx->io_ev_fd, NULL);\n\t\tcall_rcu(&ev_fd->rcu, io_eventfd_put);\n\t\treturn 0;\n\t}\n\n\treturn -ENXIO;","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":438677,"func":"static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev,\n\t\t\t\t\t\t      rpmsg_rx_cb_t cb,\n\t\t\t\t\t\t      void *priv,\n\t\t\t\t\t\t      struct rpmsg_channel_info chinfo)\n{\n\tstruct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);\n\n\treturn __rpmsg_create_ept(vch->vrp, rpdev, cb, priv, chinfo.src);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":513015,"func":"  bool val_native_from_field(Field *field, Native *to)\n  {\n    if ((null_value= field->is_null()))\n      return true;\n    return (null_value= field->val_native(to));\n  }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":346430,"func":"get_autoload_prefix(scriptitem_T *si)\n{\n    char_u *p = script_name_after_autoload(si);\n    char_u *prefix;\n\n    if (p == NULL)\n\treturn NULL;\n    prefix = vim_strsave(p);\n    if (prefix == NULL)\n\treturn NULL;\n\n    \/\/ replace all '\/' with '#' and locate \".vim\" at the end\n    for (p = prefix; *p != NUL; p += mb_ptr2len(p))\n    {\n\tif (vim_ispathsep(*p))\n\t    *p = '#';\n\telse if (STRCMP(p, \".vim\") == 0)\n\t{\n\t    p[0] = '#';\n\t    p[1] = NUL;\n\t    return prefix;\n\t}\n    }\n\n    \/\/ did not find \".vim\" at the end\n    vim_free(prefix);\n    return NULL;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":411792,"func":"setup_bus_child (gpointer data)\n{\n  A11yBusLauncher *app = data;\n  (void) app;\n\n  close (app->pipefd[0]);\n  dup2 (app->pipefd[1], 3);\n  close (app->pipefd[1]);\n\n  \/* On Linux, tell the bus process to exit if this process goes away *\/\n#ifdef __linux\n#include <sys\/prctl.h>\n  prctl (PR_SET_PDEATHSIG, 15);\n#endif  \n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":267358,"func":"append_cap (const char *arg)\n{\n  exec_options.cap = realloc (exec_options.cap, (exec_options.cap_size + 2) * sizeof (*exec_options.cap));\n  if (exec_options.cap == NULL)\n    error (EXIT_FAILURE, errno, \"cannot allocate memory\");\n  exec_options.cap[exec_options.cap_size + 1] = NULL;\n  exec_options.cap[exec_options.cap_size] = xstrdup (arg);\n  exec_options.cap_size++;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":387640,"func":"static int read_tlv_buf(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id,\n\t\t\tunsigned int __user *buf, unsigned int size)\n{\n\tstruct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)];\n\tunsigned int len;\n\n\tif (!(vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ))\n\t\treturn -ENXIO;\n\n\tif (kctl->tlv.p == NULL)\n\t\treturn -ENXIO;\n\n\tlen = sizeof(unsigned int) * 2 + kctl->tlv.p[1];\n\tif (size < len)\n\t\treturn -ENOMEM;\n\n\tif (copy_to_user(buf, kctl->tlv.p, len))\n\t\treturn -EFAULT;\n\n\treturn 0;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":253534,"func":"smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon,\n\t      struct cifs_sb_info *cifs_sb)\n{\n\tint rc;\n\t__le16 srch_path = 0; \/* Null - open root of share *\/\n\tu8 oplock = SMB2_OPLOCK_LEVEL_NONE;\n\tstruct cifs_open_parms oparms;\n\tstruct cifs_fid fid;\n\n\toparms.tcon = tcon;\n\toparms.desired_access = FILE_READ_ATTRIBUTES;\n\toparms.disposition = FILE_OPEN;\n\toparms.create_options = cifs_create_options(cifs_sb, 0);\n\toparms.fid = &fid;\n\toparms.reconnect = false;\n\n\trc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL,\n\t\t       NULL, NULL);\n\tif (rc)\n\t\treturn;\n\n\tSMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,\n\t\t\tFS_ATTRIBUTE_INFORMATION);\n\tSMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,\n\t\t\tFS_DEVICE_INFORMATION);\n\tSMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":413633,"func":"static int find_bb(ut64 *addr, RAnalBlock *bb) {\n\treturn *addr != bb->addr;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":246736,"func":"u32 parse_ttxt(char *arg_val, u32 opt)\n{\n\tif (opt) \/\/-srt\n\t\tdump_srt = GF_TRUE;\n\telse\n\t\tdump_ttxt = GF_TRUE;\n\n\timport_subtitle = 1;\n\ttrackID = 0;\n\n\tif (arg_val && (!strcmp(arg_val, \"*\") || !strcmp(arg_val, \"@\") || !strcmp(arg_val, \"all\")) ) {\n\t\ttrackID = (u32)-1;\n\t} else if (arg_val) {\n\t\tif (sscanf(arg_val, \"%u\", &trackID) == 1) {\n\t\t\tchar szTk[20];\n\t\t\tsprintf(szTk, \"%d\", trackID);\n\t\t\tif (strcmp(szTk, arg_val))\n\t\t\t\ttrackID = 0;\n\t\t}\n\t\tif (!trackID) return 3;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":310316,"func":"dirserv_have_any_serverdesc(smartlist_t *fps, int spool_src)\n{\n  time_t publish_cutoff = time(NULL)-ROUTER_MAX_AGE_TO_PUBLISH;\n  SMARTLIST_FOREACH(fps, const char *, fp, {\n      switch (spool_src)\n      {\n        case DIR_SPOOL_EXTRA_BY_DIGEST:\n          if (extrainfo_get_by_descriptor_digest(fp)) return 1;\n          break;\n        case DIR_SPOOL_SERVER_BY_DIGEST:\n          if (router_get_by_descriptor_digest(fp)) return 1;\n          break;\n        case DIR_SPOOL_EXTRA_BY_FP:\n        case DIR_SPOOL_SERVER_BY_FP:\n          if (get_signed_descriptor_by_fp(fp,\n                spool_src == DIR_SPOOL_EXTRA_BY_FP, publish_cutoff))\n            return 1;\n          break;\n      }\n  });\n  return 0;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":400719,"func":"static int copyout_mc(void __user *to, const void *from, size_t n)\n{\n\tif (access_ok(to, n)) {\n\t\tinstrument_copy_to_user(to, from, n);\n\t\tn = copy_mc_to_user((__force void *) to, from, n);\n\t}\n\treturn n;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":474002,"func":"code2_hash(OnigCodePoint* x)\n{\n  return (st_index_t )(x[0] + x[1]);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":432315,"func":"void memory_region_init(struct uc_struct *uc,\n                        MemoryRegion *mr,\n                        uint64_t size)\n{\n    memset(mr, 0, sizeof(*mr));\n    mr->uc = uc;\n    \/* memory_region_initfn *\/\n    mr->ops = &unassigned_mem_ops;\n    mr->enabled = true;\n    mr->destructor = memory_region_destructor_none;\n    QTAILQ_INIT(&mr->subregions);\n\n    mr->size = int128_make64(size);\n    if (size == UINT64_MAX) {\n        mr->size = int128_2_64();\n    }\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":487639,"func":"void kernel_power_off(void)\n{\n\tkernel_shutdown_prepare(SYSTEM_POWER_OFF);\n\tprintk(KERN_EMERG \"Power down.\\n\");\n\tmachine_power_off();\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":248286,"func":"int strcasecmp(const char *s1, const char *s2)\n{\n\tassert(s1);\n\tassert(s2);\n\n\twhile (*s1) {\n\t\tint c1 = tolower(*(const unsigned char *)s1);\n\t\tint c2 = tolower(*(const unsigned char *)s2);\n\n\t\tif (c1 < c2)\n\t\t\treturn -1;\n\t\tif (c1 > c2)\n\t\t\treturn +1;\n\n\t\t++s1;\n\t\t++s2;\n\t}\n\n\tif (*s2 != 0)\n\t\treturn -1;\n\n\treturn 0;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":369409,"func":"\nstatic enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer)\n{\n\tstruct io_timeout_data *data = container_of(timer,\n\t\t\t\t\t\tstruct io_timeout_data, timer);\n\tstruct io_kiocb *prev, *req = data->req;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&ctx->timeout_lock, flags);\n\tprev = req->timeout.head;\n\treq->timeout.head = NULL;\n\n\t\/*\n\t * We don't expect the list to be empty, that will only happen if we\n\t * race with the completion of the linked work.\n\t *\/\n\tif (prev) {\n\t\tio_remove_next_linked(prev);\n\t\tif (!req_ref_inc_not_zero(prev))\n\t\t\tprev = NULL;\n\t}\n\tlist_del(&req->timeout.list);\n\treq->timeout.prev = prev;\n\tspin_unlock_irqrestore(&ctx->timeout_lock, flags);\n\n\treq->io_task_work.func = io_req_task_link_timeout;\n\tio_req_task_work_add(req, false);\n\treturn HRTIMER_NORESTART;","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":281065,"func":"static inline unsigned int idx_hash(struct net *net, u32 index)\n{\n\treturn __idx_hash(index, net->xfrm.policy_idx_hmask);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":401557,"func":"void del_random_ready_callback(struct random_ready_callback *rdy)\n{\n\tunsigned long flags;\n\tstruct module *owner = NULL;\n\n\tspin_lock_irqsave(&random_ready_list_lock, flags);\n\tif (!list_empty(&rdy->list)) {\n\t\tlist_del_init(&rdy->list);\n\t\towner = rdy->owner;\n\t}\n\tspin_unlock_irqrestore(&random_ready_list_lock, flags);\n\n\tmodule_put(owner);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":223486,"func":"static void flush_stubs(compiler_common *common)\n{\nDEFINE_COMPILER;\nstub_list *list_item = common->stubs;\n\nwhile (list_item)\n  {\n  JUMPHERE(list_item->start);\n  add_jump(compiler, &common->stackalloc, JUMP(SLJIT_FAST_CALL));\n  JUMPTO(SLJIT_JUMP, list_item->quit);\n  list_item = list_item->next;\n  }\ncommon->stubs = NULL;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":500058,"func":"krb5_rc_destroy(krb5_context con, krb5_rcache rc)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_rc_destroy )\n\t\treturn(p_krb5_rc_destroy(con, rc));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":244142,"func":"GF_Err dac3_box_size(GF_Box *s)\n{\n\tGF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;\n\n\tif (ptr->cfg.is_ec3) {\n\t\tu32 i;\n\t\ts->size += 2;\n\t\tfor (i=0; i<ptr->cfg.nb_streams; i++) {\n\t\t\ts->size += 3;\n\t\t\tif (ptr->cfg.streams[i].nb_dep_sub)\n\t\t\t\ts->size += 1;\n\t\t}\n\t} else {\n\t\ts->size += 3;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":369316,"func":"\nstatic void io_flush_apoll_cache(struct io_ring_ctx *ctx)\n{\n\tstruct async_poll *apoll;\n\n\twhile (!list_empty(&ctx->apoll_cache)) {\n\t\tapoll = list_first_entry(&ctx->apoll_cache, struct async_poll,\n\t\t\t\t\t\tpoll.wait.entry);\n\t\tlist_del(&apoll->poll.wait.entry);\n\t\tkfree(apoll);\n\t}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":202708,"func":"fname_match(\n    regmatch_T\t*rmp,\n    char_u\t*name,\n    int\t\tignore_case)  \/\/ when TRUE ignore case, when FALSE use 'fic'\n{\n    char_u\t*match = NULL;\n    char_u\t*p;\n\n    if (name != NULL)\n    {\n\t\/\/ Ignore case when 'fileignorecase' or the argument is set.\n\trmp->rm_ic = p_fic || ignore_case;\n\tif (vim_regexec(rmp, name, (colnr_T)0))\n\t    match = name;\n\telse\n\t{\n\t    \/\/ Replace $(HOME) with '~' and try matching again.\n\t    p = home_replace_save(NULL, name);\n\t    if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))\n\t\tmatch = name;\n\t    vim_free(p);\n\t}\n    }\n\n    return match;\n}","target":1,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":356679,"func":"Napi::Value Statement::Run(const Napi::CallbackInfo& info) {\n    Napi::Env env = info.Env();\n    Statement* stmt = this;\n\n    Baton* baton = stmt->Bind<RunBaton>(info);\n    if (baton == NULL) {\n        Napi::Error::New(env, \"Data type is not supported\").ThrowAsJavaScriptException();\n        return env.Null();\n    }\n    else {\n        stmt->Schedule(Work_BeginRun, baton);\n        return info.This();\n    }\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":247571,"func":"TEST_P(SslSocketTest, StatelessSessionResumptionEnabledByDefault) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  testSupportForStatelessSessionResumption(server_ctx_yaml, client_ctx_yaml, true, GetParam());\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":204195,"func":"static void parse_rtcp_bye(pjmedia_rtcp_session *sess,\n\t\t\t   const void *pkt,\n\t\t\t   pj_size_t size)\n{\n    pj_str_t reason = {\"-\", 1};\n\n    \/* Check and get BYE reason *\/\n    if (size > 8) {\n\treason.slen = PJ_MIN(sizeof(sess->stat.peer_sdes_buf_),\n                             *((pj_uint8_t*)pkt+8));\n\tpj_memcpy(sess->stat.peer_sdes_buf_, ((pj_uint8_t*)pkt+9),\n\t\t  reason.slen);\n\treason.ptr = sess->stat.peer_sdes_buf_;\n    }\n\n    \/* Just print RTCP BYE log *\/\n    PJ_LOG(5, (sess->name, \"Received RTCP BYE, reason: %.*s\",\n\t       reason.slen, reason.ptr));\n}","target":1,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":314527,"func":"static pj_status_t validate_sdp_conn(const pjmedia_sdp_conn *c)\n{\n    CHECK( c, PJ_EINVAL);\n    CHECK( pj_strcmp2(&c->net_type, \"IN\")==0, PJMEDIA_SDP_EINCONN);\n    CHECK( pj_strcmp2(&c->addr_type, \"IP4\")==0 ||\n\t   pj_strcmp2(&c->addr_type, \"IP6\")==0, \n\t   PJMEDIA_SDP_EINCONN);\n    CHECK( c->addr.slen != 0, PJMEDIA_SDP_EINCONN);\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":487624,"func":"asmlinkage long sys_sethostname(char __user *name, int len)\n{\n\tint errno;\n\tchar tmp[__NEW_UTS_LEN];\n\n\tif (!capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\tif (len < 0 || len > __NEW_UTS_LEN)\n\t\treturn -EINVAL;\n\tdown_write(&uts_sem);\n\terrno = -EFAULT;\n\tif (!copy_from_user(tmp, name, len)) {\n\t\tmemcpy(utsname()->nodename, tmp, len);\n\t\tutsname()->nodename[len] = 0;\n\t\terrno = 0;\n\t}\n\tup_write(&uts_sem);\n\treturn errno;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":162556,"func":"void WebProcessProxy::addExistingWebPage(WebPageProxy* webPage, uint64_t pageID)\n{\n     m_pageMap.set(pageID, webPage);\n     globalPageMap().set(pageID, webPage);\n #if PLATFORM(MAC)\n    if (pageIsProcessSuppressible(webPage))\n         m_processSuppressiblePages.add(pageID);\n     updateProcessSuppressionState();\n #endif\n}\n","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":359338,"func":"DEFUN (clear_ip_bgp_as_soft_in,\n       clear_ip_bgp_as_soft_in_cmd,\n       \"clear ip bgp <1-65535> soft in\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear peers with the AS number\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,\n\t\t\tBGP_CLEAR_SOFT_IN, argv[0]);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":276966,"func":"PreventStartCodeEmulation(const AP4_UI08* payload, AP4_Size payload_size, AP4_DataBuffer& output)\n{\n    output.Reserve(payload_size*2); \/\/ more than enough\n    AP4_Size  output_size = 0;\n    AP4_UI08* buffer = output.UseData();\n    \n\tunsigned int zero_counter = 0;\n\tfor (unsigned int i = 0; i < payload_size; i++) {\n\t\tif (zero_counter == 2) {\n            if (payload[i] == 0 || payload[i] == 1 || payload[i] == 2 || payload[i] == 3) {\n                buffer[output_size++] = 3;\n                zero_counter = 0;\n            }\n\t\t}\n\n        buffer[output_size++] = payload[i];\n\n\t\tif (payload[i] == 0) {\n\t\t\t++zero_counter;\n\t\t} else {\n\t\t\tzero_counter = 0;\n        }\n\t}\n\n    output.SetDataSize(output_size);\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":175776,"func":"bool QuotaManager::ResetUsageTracker(StorageType type) {\n  switch (type) {\n    case kStorageTypeTemporary:\n      if (temporary_usage_tracker_->IsWorking())\n        return false;\n      temporary_usage_tracker_.reset(\n          new UsageTracker(clients_, kStorageTypeTemporary,\n                           special_storage_policy_));\n      return true;\n    case kStorageTypePersistent:\n      if (persistent_usage_tracker_->IsWorking())\n        return false;\n      persistent_usage_tracker_.reset(\n          new UsageTracker(clients_, kStorageTypePersistent,\n                           special_storage_policy_));\n      return true;\n    default:\n      NOTREACHED();\n  }\n  return true;\n}\n","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":508769,"func":"static int rr_unpack_from_buffer(READ_RECORD *info)\n{\n  if (info->cache_pos == info->cache_end)\n    return -1;                      \/* End of buffer *\/\n  (*info->unpack)(info->addon_field, info->cache_pos,\n                  info->cache_end);\n  info->cache_pos+= info->ref_length;\n  return 0;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":261759,"func":"void RtmpProtocol::reset() {\n    \/\/\/\/\/\/\/\/\/\/\/\/ChunkSize\/\/\/\/\/\/\/\/\/\/\/\/\n    _chunk_size_in = DEFAULT_CHUNK_LEN;\n    _chunk_size_out = DEFAULT_CHUNK_LEN;\n    \/\/\/\/\/\/\/\/\/\/\/\/Acknowledgement\/\/\/\/\/\/\/\/\/\/\/\/\n    _bytes_sent = 0;\n    _bytes_sent_last = 0;\n    _windows_size = 0;\n    \/\/\/\/\/\/\/\/\/\/\/PeerBandwidth\/\/\/\/\/\/\/\/\/\/\/\n    _bandwidth = 2500000;\n    _band_limit_type = 2;\n    \/\/\/\/\/\/\/\/\/\/\/\/Chunk\/\/\/\/\/\/\/\/\/\/\/\/\n    _map_chunk_data.clear();\n    _now_stream_index = 0;\n    _now_chunk_id = 0;\n    \/\/\/\/\/\/\/\/\/\/Invoke Request\/\/\/\/\/\/\/\/\/\/\n    _send_req_id = 0;\n    \/\/\/\/\/\/\/\/\/\/Rtmp parser\/\/\/\/\/\/\/\/\/\/\n    HttpRequestSplitter::reset();\n    _stream_index = STREAM_CONTROL;\n    _next_step_func = [this](const char *data, size_t len) {\n        return handle_C0C1(data, len);\n    };\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":247291,"func":"  explicit MklRequantizationRangePerChannelOp(OpKernelConstruction* ctx)\n      : OpKernel(ctx) {\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"clip_value_max\", &clip_value_max_));\n  }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":343145,"func":"static struct ip_esp_hdr *esp6_output_udp_encap(struct sk_buff *skb,\n\t\t\t\t\t       int encap_type,\n\t\t\t\t\t       struct esp_info *esp,\n\t\t\t\t\t       __be16 sport,\n\t\t\t\t\t       __be16 dport)\n{\n\tstruct udphdr *uh;\n\t__be32 *udpdata32;\n\tunsigned int len;\n\n\tlen = skb->len + esp->tailen - skb_transport_offset(skb);\n\tif (len > U16_MAX)\n\t\treturn ERR_PTR(-EMSGSIZE);\n\n\tuh = (struct udphdr *)esp->esph;\n\tuh->source = sport;\n\tuh->dest = dport;\n\tuh->len = htons(len);\n\tuh->check = 0;\n\n\t*skb_mac_header(skb) = IPPROTO_UDP;\n\n\tif (encap_type == UDP_ENCAP_ESPINUDP_NON_IKE) {\n\t\tudpdata32 = (__be32 *)(uh + 1);\n\t\tudpdata32[0] = udpdata32[1] = 0;\n\t\treturn (struct ip_esp_hdr *)(udpdata32 + 2);\n\t}\n\n\treturn (struct ip_esp_hdr *)(uh + 1);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":204032,"func":"static void virtbt_rx_handle(struct virtio_bluetooth *vbt, struct sk_buff *skb)\n{\n\t__u8 pkt_type;\n\n\tpkt_type = *((__u8 *) skb->data);\n\tskb_pull(skb, 1);\n\n\tswitch (pkt_type) {\n\tcase HCI_EVENT_PKT:\n\tcase HCI_ACLDATA_PKT:\n\tcase HCI_SCODATA_PKT:\n\tcase HCI_ISODATA_PKT:\n\t\thci_skb_pkt_type(skb) = pkt_type;\n\t\thci_recv_frame(vbt->hdev, skb);\n\t\tbreak;\n\t}\n}","target":1,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":409411,"func":"term_append_lines(int line_count)\n{\n    OUT_STR(tgoto((char *)T_CAL, 0, line_count));\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":312406,"func":"qf_find_first_entry_in_buf(qf_list_T *qfl, int bnr, int *errornr)\n{\n    qfline_T\t*qfp = NULL;\n    int\t\tidx = 0;\n\n    \/\/ Find the first entry in this file\n    FOR_ALL_QFL_ITEMS(qfl, qfp, idx)\n\tif (qfp->qf_fnum == bnr)\n\t    break;\n\n    *errornr = idx;\n    return qfp;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":225861,"func":"\nGF_Box *trak_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackBox, GF_ISOM_BOX_TYPE_TRAK);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":310088,"func":"NCURSES_SP_NAME(reset_color_pairs) (NCURSES_SP_DCL0)\n{\n    if (SP_PARM != 0) {\n\tif (SP_PARM->_color_pairs) {\n\t    _nc_free_ordered_pairs(SP_PARM);\n\t    free(SP_PARM->_color_pairs);\n\t    SP_PARM->_color_pairs = 0;\n\t    SP_PARM->_pair_alloc = 0;\n\t    ReservePairs(SP_PARM, 16);\n\t    clearok(CurScreen(SP_PARM), TRUE);\n\t    touchwin(StdScreen(SP_PARM));\n\t}\n    }\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":359541,"func":"DEFUN (neighbor_remove_private_as,\n       neighbor_remove_private_as_cmd,\n       NEIGHBOR_CMD2 \"remove-private-AS\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Remove private AS number from outbound updates\\n\")\n{\n  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t       bgp_node_safi (vty),\n\t\t\t       PEER_FLAG_REMOVE_PRIVATE_AS);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":349523,"func":"static void virtbt_rx_done(struct virtqueue *vq)\n{\n\tstruct virtio_bluetooth *vbt = vq->vdev->priv;\n\n\tschedule_work(&vbt->rx);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":236154,"func":"GF_Err tsel_box_size(GF_Box *s)\n{\n\tGF_TrackSelectionBox *ptr = (GF_TrackSelectionBox *) s;\n\tptr->size += 4 + (4*ptr->attributeListCount);\n\treturn GF_OK;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":316943,"func":"static inline u32 task_sid_subj(const struct task_struct *task)\n{\n\tu32 sid;\n\n\trcu_read_lock();\n\tsid = cred_sid(rcu_dereference(task->cred));\n\trcu_read_unlock();\n\treturn sid;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":234746,"func":"void __cold btrfs_assign_next_active_device(struct btrfs_device *device,\n\t\t\t\t\t    struct btrfs_device *next_device)\n{\n\tstruct btrfs_fs_info *fs_info = device->fs_info;\n\n\tif (!next_device)\n\t\tnext_device = btrfs_find_next_active_device(fs_info->fs_devices,\n\t\t\t\t\t\t\t    device);\n\tASSERT(next_device);\n\n\tif (fs_info->sb->s_bdev &&\n\t\t\t(fs_info->sb->s_bdev == device->bdev))\n\t\tfs_info->sb->s_bdev = next_device->bdev;\n\n\tif (fs_info->fs_devices->latest_bdev == device->bdev)\n\t\tfs_info->fs_devices->latest_bdev = next_device->bdev;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":226136,"func":"GF_Err esds_box_size(GF_Box *s)\n{\n\tu32 descSize = 0;\n\tGF_ESDBox *ptr = (GF_ESDBox *)s;\n\t\/\/make sure we write with no ESID and no OCRESID\n    if (ptr->desc) {\n        ptr->desc->ESID = 0;\n        ptr->desc->OCRESID = 0;\n    }\n\tdescSize = gf_odf_desc_size((GF_Descriptor *)ptr->desc);\n\tptr->size += descSize;\n\treturn GF_OK;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":336609,"func":"SPICE_GNUC_VISIBLE int spice_server_migrate_info(SpiceServer *reds, const char* dest,\n                                          int port, int secure_port,\n                                          const char* cert_subject)\n{\n    spice_debug(\"trace\");\n    spice_assert(!reds->migration_interface);\n\n    if (!reds_set_migration_dest_info(reds, dest, port, secure_port, cert_subject)) {\n        return -1;\n    }\n    return 0;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":254710,"func":"njs_typed_array_get_i8(const void *a)\n{\n    return *(const int8_t *) a;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":314754,"func":"cdf_unpack_header(cdf_header_t *h, char *buf)\n{\n\tsize_t i;\n\tsize_t len = 0;\n\n\tCDF_UNPACK(h->h_magic);\n\tCDF_UNPACKA(h->h_uuid);\n\tCDF_UNPACK(h->h_revision);\n\tCDF_UNPACK(h->h_version);\n\tCDF_UNPACK(h->h_byte_order);\n\tCDF_UNPACK(h->h_sec_size_p2);\n\tCDF_UNPACK(h->h_short_sec_size_p2);\n\tCDF_UNPACKA(h->h_unused0);\n\tCDF_UNPACK(h->h_num_sectors_in_sat);\n\tCDF_UNPACK(h->h_secid_first_directory);\n\tCDF_UNPACKA(h->h_unused1);\n\tCDF_UNPACK(h->h_min_size_standard_stream);\n\tCDF_UNPACK(h->h_secid_first_sector_in_short_sat);\n\tCDF_UNPACK(h->h_num_sectors_in_short_sat);\n\tCDF_UNPACK(h->h_secid_first_sector_in_master_sat);\n\tCDF_UNPACK(h->h_num_sectors_in_master_sat);\n\tfor (i = 0; i < __arraycount(h->h_master_sat); i++)\n\t\tCDF_UNPACK(h->h_master_sat[i]);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":401562,"func":"static void entropy_timer(struct timer_list *t)\n{\n\tcredit_entropy_bits(&input_pool, 1);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":294566,"func":"of2str(int of)\n{\n    int s, h, m;\n\n    decode_offset(of, s, h, m);\n    return rb_enc_sprintf(rb_usascii_encoding(), \"%c%02d:%02d\", s, h, m);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":387736,"func":"void FieldPrinter::do_field(fieldDescriptor* fd) {\n  _st->print(BULLET);\n   if (_obj == NULL) {\n     fd->print_on(_st);\n     _st->cr();\n   } else {\n     fd->print_on_for(_st, _obj);\n     _st->cr();\n   }\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":221652,"func":"bool disjointComparisonTypes(Type A, Type B) {\n  if (!A.isPrimitive() || !B.isPrimitive())\n    return false;\n\n  \/\/ Check if types are disjoint.\n  return Type::intersectTy(A, B).isNoType();\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":405346,"func":"struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif,\n\t\t\t\t    const xfrm_address_t *saddr,\n\t\t\t\t    const xfrm_address_t *daddr,\n\t\t\t\t    int family, u32 mark)\n{\n\tconst struct xfrm_policy_afinfo *afinfo;\n\tstruct dst_entry *dst;\n\n\tafinfo = xfrm_policy_get_afinfo(family);\n\tif (unlikely(afinfo == NULL))\n\t\treturn ERR_PTR(-EAFNOSUPPORT);\n\n\tdst = afinfo->dst_lookup(net, tos, oif, saddr, daddr, mark);\n\n\trcu_read_unlock();\n\n\treturn dst;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":437686,"func":"static inline unsigned int clock_divider_to_ns(unsigned int divider)\n{\n\t\/* Period of the Rx or Tx clock in ns *\/\n\treturn DIV_ROUND_CLOSEST((divider + 1) * 1000,\n\t\t\t\t CX23888_IR_REFCLK_FREQ \/ 1000000);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":387563,"func":"static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)\n{\n\tunsigned int iter = 100000;\n\n\twhile (snd_ctl_remove_numid_conflict(card, count)) {\n\t\tif (--iter == 0) {\n\t\t\t\/* this situation is very unlikely *\/\n\t\t\tdev_err(card->dev, \"unable to allocate new control numid\\n\");\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\treturn 0;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":459144,"func":"static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol,\n\t\t\t\t\t  u32 prio, struct tcf_chain *chain,\n\t\t\t\t\t  bool rtnl_held,\n\t\t\t\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct tcf_proto *tp;\n\tint err;\n\n\ttp = kzalloc(sizeof(*tp), GFP_KERNEL);\n\tif (!tp)\n\t\treturn ERR_PTR(-ENOBUFS);\n\n\ttp->ops = tcf_proto_lookup_ops(kind, rtnl_held, extack);\n\tif (IS_ERR(tp->ops)) {\n\t\terr = PTR_ERR(tp->ops);\n\t\tgoto errout;\n\t}\n\ttp->classify = tp->ops->classify;\n\ttp->protocol = protocol;\n\ttp->prio = prio;\n\ttp->chain = chain;\n\tspin_lock_init(&tp->lock);\n\trefcount_set(&tp->refcnt, 1);\n\n\terr = tp->ops->init(tp);\n\tif (err) {\n\t\tmodule_put(tp->ops->owner);\n\t\tgoto errout;\n\t}\n\treturn tp;\n\nerrout:\n\tkfree(tp);\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":309936,"func":"main(int argc, char *argv[])\n{\n    int c, tc = FALSE;\n\n    while ((c = getopt(argc, argv, \"c\")) != EOF)\n\tswitch (c) {\n\tcase 'c':\n\t    tc = TRUE;\n\t    break;\n\t}\n\n    curr_line = 0;\n    for (;;) {\n\tchar buf[BUFSIZ];\n\n\t++curr_line;\n\tif (fgets(buf, sizeof(buf), stdin) == 0)\n\t    break;\n\tbuf[strlen(buf) - 1] = '\\0';\n\t_nc_set_source(buf);\n\n\tif (tc) {\n\t    char *cp = _nc_infotocap(\"to termcap\", buf, 1);\n\n\t    if (cp)\n\t\t(void) fputs(cp, stdout);\n\t} else\n\t    (void) fputs(_nc_captoinfo(\"to terminfo\", buf, 1), stdout);\n\t(void) putchar('\\n');\n    }\n    return (0);\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":476104,"func":"static struct usb_gadget_strings **get_containers_gs(\n\t\tstruct usb_gadget_string_container *uc)\n{\n\treturn (struct usb_gadget_strings **)uc->stash;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":238783,"func":"get_line_and_copy(linenr_T lnum, char_u *buf)\n{\n    char_u *line = ml_get(lnum);\n\n    vim_strncpy(buf, line, LSIZE - 1);\n    return buf;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":294388,"func":"canon(VALUE x)\n{\n    if (RB_TYPE_P(x, T_RATIONAL)) {\n\tVALUE den = rb_rational_den(x);\n\tif (FIXNUM_P(den) && FIX2LONG(den) == 1)\n\t    return rb_rational_num(x);\n    }\n    return x;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":442568,"func":"from_physical(QXLPHYSICAL physical)\n{\n    return (void *)(uintptr_t) physical;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":264719,"func":"bool MaybeReplaceRankOp(const Node* n,\n                        const std::vector<PartialTensorShape>& input_shapes,\n                        std::unordered_map<const Node*, std::vector<Tensor>>*\n                            shape_replacement_map) {\n  CHECK_EQ(input_shapes.size(), 1);\n  if (input_shapes[0].unknown_rank()) {\n    return false;\n  }\n  Tensor t(DT_INT32, TensorShape({}));\n  t.scalar<int32>()() = input_shapes[0].dims();\n  shape_replacement_map->insert({n, {t}});\n  return true;\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":417125,"func":"bool PlayerGeneric::isInitialized() const\n{\n\tif (mixer)\n\t\treturn mixer->isInitialized();\n\t\t\n\treturn false;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":343163,"func":"static int esp4_err(struct sk_buff *skb, u32 info)\n{\n\tstruct net *net = dev_net(skb->dev);\n\tconst struct iphdr *iph = (const struct iphdr *)skb->data;\n\tstruct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data+(iph->ihl<<2));\n\tstruct xfrm_state *x;\n\n\tswitch (icmp_hdr(skb)->type) {\n\tcase ICMP_DEST_UNREACH:\n\t\tif (icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)\n\t\t\treturn 0;\n\t\tbreak;\n\tcase ICMP_REDIRECT:\n\t\tbreak;\n\tdefault:\n\t\treturn 0;\n\t}\n\n\tx = xfrm_state_lookup(net, skb->mark, (const xfrm_address_t *)&iph->daddr,\n\t\t\t      esph->spi, IPPROTO_ESP, AF_INET);\n\tif (!x)\n\t\treturn 0;\n\n\tif (icmp_hdr(skb)->type == ICMP_DEST_UNREACH)\n\t\tipv4_update_pmtu(skb, net, info, 0, IPPROTO_ESP);\n\telse\n\t\tipv4_redirect(skb, net, 0, IPPROTO_ESP);\n\txfrm_state_put(x);\n\n\treturn 0;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":289312,"func":"static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,\n\t\t\t\t      const char *task_name,\n\t\t\t\t      struct snd_pcm_oss_setup *rsetup)\n{\n\tstruct snd_pcm_oss_setup *setup;\n\n\tmutex_lock(&pcm->streams[stream].oss.setup_mutex);\n\tdo {\n\t\tfor (setup = pcm->streams[stream].oss.setup_list; setup;\n\t\t     setup = setup->next) {\n\t\t\tif (!strcmp(setup->task_name, task_name))\n\t\t\t\tgoto out;\n\t\t}\n\t} while ((task_name = strip_task_path(task_name)) != NULL);\n out:\n\tif (setup)\n\t\t*rsetup = *setup;\n\tmutex_unlock(&pcm->streams[stream].oss.setup_mutex);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":512631,"func":"  Item* get_copy(THD *thd) { return 0; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":357676,"func":"SQInstance *SQClass::CreateInstance()\n{\n    if(!_locked) Lock();\n    return SQInstance::Create(_opt_ss(this),this);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":236152,"func":"GF_Err blnk_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TextBlinkBox*ptr = (GF_TextBlinkBox*)s;\n\tISOM_DECREASE_SIZE(ptr, 4)\n\tptr->startcharoffset = gf_bs_read_u16(bs);\n\tptr->endcharoffset = gf_bs_read_u16(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":248295,"func":"DLLIMPORT int cfg_setfloat(cfg_t *cfg, const char *name, double value)\n{\n\treturn cfg_setnfloat(cfg, name, value, 0);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":272366,"func":"digest_get_signature_oid(cms_context *cms)\n{\n\tint i = cms->selected_digest;\n\treturn digest_params[i].signature_tag;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":329881,"func":"_mono_spans (void *abstract_renderer, int y, int h,\n\t     const cairo_half_open_span_t *spans, unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    do {\n\tif (spans[0].coverage) {\n\t    pixman_image_composite32 (r->op,\n\t\t\t\t      r->src, NULL, r->u.composite.dst,\n\t\t\t\t      spans[0].x + r->u.composite.src_x,  y + r->u.composite.src_y,\n\t\t\t\t      0, 0,\n\t\t\t\t      spans[0].x, y,\n\t\t\t\t      spans[1].x - spans[0].x, h);\n\t}\n\tspans++;\n    } while (--num_spans > 1);\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":500662,"func":"static void sftp_set_error(sftp_session sftp, int errnum) {\n  if (sftp != NULL) {\n    sftp->errnum = errnum;\n  }\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":410080,"func":"static int hid_debug_rdesc_open(struct inode *inode, struct file *file)\n{\n\treturn single_open(file, hid_debug_rdesc_show, inode->i_private);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":344735,"func":"opt_array_append2(const char *file, const int line, const char *directive,\n    char ***array, int **iarray, u_int *lp, const char *s, int i)\n{\n\n\tif (*lp >= INT_MAX)\n\t\tfatal(\"%s line %d: Too many %s entries\", file, line, directive);\n\n\tif (iarray != NULL) {\n\t\t*iarray = xrecallocarray(*iarray, *lp, *lp + 1,\n\t\t    sizeof(**iarray));\n\t\t(*iarray)[*lp] = i;\n\t}\n\n\t*array = xrecallocarray(*array, *lp, *lp + 1, sizeof(**array));\n\t(*array)[*lp] = xstrdup(s);\n\t(*lp)++;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":234863,"func":"void btrfs_commit_device_sizes(struct btrfs_transaction *trans)\n{\n\tstruct btrfs_device *curr, *next;\n\n\tASSERT(trans->state == TRANS_STATE_COMMIT_DOING);\n\n\tif (list_empty(&trans->dev_update_list))\n\t\treturn;\n\n\t\/*\n\t * We don't need the device_list_mutex here.  This list is owned by the\n\t * transaction and the transaction must complete before the device is\n\t * released.\n\t *\/\n\tmutex_lock(&trans->fs_info->chunk_mutex);\n\tlist_for_each_entry_safe(curr, next, &trans->dev_update_list,\n\t\t\t\t post_commit_list) {\n\t\tlist_del_init(&curr->post_commit_list);\n\t\tcurr->commit_total_bytes = curr->disk_total_bytes;\n\t\tcurr->commit_bytes_used = curr->bytes_used;\n\t}\n\tmutex_unlock(&trans->fs_info->chunk_mutex);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":261933,"func":"njs_encode_base64url(njs_str_t *dst, const njs_str_t *src)\n{\n    static u_char   basis64[] =\n        \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\";\n\n    njs_encode_base64_core(dst, src, basis64, 0);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":442819,"func":"static char *file2string(FILE *file)\n{\n  char buffer[256];\n  char *ptr;\n  char *string=NULL;\n  size_t len=0;\n  size_t stringlen;\n\n  if(file) {\n    while(fgets(buffer, sizeof(buffer), file)) {\n      ptr= strchr(buffer, '\\r');\n      if(ptr)\n        *ptr=0;\n      ptr= strchr(buffer, '\\n');\n      if(ptr)\n        *ptr=0;\n      stringlen=strlen(buffer);\n      if(string)\n        string = realloc(string, len+stringlen+1);\n      else\n        string = malloc(stringlen+1);\n\n      strcpy(string+len, buffer);\n\n      len+=stringlen;\n    }\n    return string;\n  }\n  else\n    return NULL; \/* no string *\/\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":387746,"func":"Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,\n                                                         Symbol* signature) const {\n  Method* m = NULL;\n  if (default_methods() != NULL) {\n    m = find_method(default_methods(), name, signature);\n  }\n  \/\/ Look up interfaces\n  if (m == NULL) {\n    m = lookup_method_in_all_interfaces(name, signature, find_defaults);\n  }\n  return m;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":437675,"func":"static int cx23888_ir_g_register(struct v4l2_subdev *sd,\n\t\t\t\t struct v4l2_dbg_register *reg)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tu32 addr = CX23888_IR_REG_BASE + (u32) reg->reg;\n\n\tif ((addr & 0x3) != 0)\n\t\treturn -EINVAL;\n\tif (addr < CX23888_IR_CNTRL_REG || addr > CX23888_IR_LEARN_REG)\n\t\treturn -EINVAL;\n\treg->size = 4;\n\treg->val = cx23888_ir_read4(state->dev, addr);\n\treturn 0;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":248301,"func":"DLLIMPORT cfg_bool_t cfg_getnbool(cfg_t *cfg, const char *name, unsigned int index)\n{\n\treturn cfg_opt_getnbool(cfg_getopt(cfg, name), index);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":262089,"func":"  StatsPartitionKey(const int32_t node_id, const int32_t feature_dim,\n                    const int32_t bucket_id)\n      : node_id(node_id), feature_dim(feature_dim), bucket_id(bucket_id) {}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":513142,"func":"static void restore_ptr_backup(uint n, st_ptr_backup *backup)\n{\n  while (n--)\n    (backup++)->restore();\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":234128,"func":"range_entry_compar (const void *ap, const void *bp)\n{\n  const struct range_entry *a_re = (const struct range_entry *) ap;\n  const struct range_entry *b_re = (const struct range_entry *) bp;\n  const dwarf_vma a = a_re->ranges_offset;\n  const dwarf_vma b = b_re->ranges_offset;\n\n  return (a > b) - (b > a);\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":221685,"func":"bool Socket::writeChunkTrailer( String &trailer) {\n    std::string hexs (\"0\\r\\n\");\n#ifdef CHUNKDEBUG\n    std::cerr << thread_id << \"writeChunk  size=\" << hexs << std::endl;\n#endif\n    if(writeString(hexs.c_str()) && writeToSocket(trailer.c_str(),trailer.length(),0,timeout) && writeString(\"\\r\\n\"))\n        return true;\n    return false;\n};","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":244336,"func":"GF_Box *vwid_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ViewIdentifierBox, GF_ISOM_BOX_TYPE_VWID);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":90885,"func":"void ClientUsageTracker::AddCachedOrigin(\n    const GURL& origin, int64 usage) {\n  std::string host = net::GetHostOrSpecFromURL(origin);\n  UsageMap::iterator iter = cached_usage_[host].\n      insert(UsageMap::value_type(origin, 0)).first;\n  int64 old_usage = iter->second;\n  iter->second = usage;\n  int64 delta = usage - old_usage;\n  if (delta) {\n    global_usage_ += delta;\n    if (global_unlimited_usage_is_valid_ && IsStorageUnlimited(origin))\n      global_unlimited_usage_ += delta;\n  }\n  DCHECK_GE(iter->second, 0);\n  DCHECK_GE(global_usage_, 0);\n}\n","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":484784,"func":"static void xennet_maybe_wake_tx(struct netfront_queue *queue)\n{\n\tstruct net_device *dev = queue->info->netdev;\n\tstruct netdev_queue *dev_queue = netdev_get_tx_queue(dev, queue->id);\n\n\tif (unlikely(netif_tx_queue_stopped(dev_queue)) &&\n\t    netfront_tx_slot_available(queue) &&\n\t    likely(netif_running(dev)))\n\t\tnetif_tx_wake_queue(netdev_get_tx_queue(dev, queue->id));\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":338170,"func":"void WasmBinaryBuilder::visitUnreachable(Unreachable* curr) {\n  BYN_TRACE(\"zz node: Unreachable\\n\");\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":231726,"func":"  virtual bool getDisableMigration() {\n    return true;\n  }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":430442,"func":"static bool validate_masked(u8 *data, int len)\n{\n\tu8 *mask = data + len;\n\n\twhile (len--)\n\t\tif (*data++ & ~*mask++)\n\t\t\treturn false;\n\n\treturn true;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":247763,"func":"void RWFunction::AssignFrom(const NameValuePairs &source)\n{\n\tAssignFromHelper(this, source)\n\t\tCRYPTOPP_SET_FUNCTION_ENTRY(Modulus)\n\t\t;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":502697,"func":"long SSL_SESSION_get_time(const SSL_SESSION *s)\n{\n    if (s == NULL)\n        return (0);\n    return (s->time);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":222529,"func":"string FunctionLibraryDefinition::UniqueFunctionName(StringPiece prefix) const {\n  tf_shared_lock l(mu_);\n  int index = 0;\n  string name = strings::StrCat(prefix, index);\n  while (function_defs_.find(name) != function_defs_.end()) {\n    ++index;\n    name = strings::StrCat(prefix, index);\n  }\n  return name;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":369271,"func":"\nstatic int io_buffer_account_pin(struct io_ring_ctx *ctx, struct page **pages,\n\t\t\t\t int nr_pages, struct io_mapped_ubuf *imu,\n\t\t\t\t struct page **last_hpage)\n{\n\tint i, ret;\n\n\timu->acct_pages = 0;\n\tfor (i = 0; i < nr_pages; i++) {\n\t\tif (!PageCompound(pages[i])) {\n\t\t\timu->acct_pages++;\n\t\t} else {\n\t\t\tstruct page *hpage;\n\n\t\t\thpage = compound_head(pages[i]);\n\t\t\tif (hpage == *last_hpage)\n\t\t\t\tcontinue;\n\t\t\t*last_hpage = hpage;\n\t\t\tif (headpage_already_acct(ctx, pages, i, hpage))\n\t\t\t\tcontinue;\n\t\t\timu->acct_pages += page_size(hpage) >> PAGE_SHIFT;\n\t\t}\n\t}\n\n\tif (!imu->acct_pages)\n\t\treturn 0;\n\n\tret = io_account_mem(ctx, imu->acct_pages);\n\tif (ret)\n\t\timu->acct_pages = 0;\n\treturn ret;","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":226172,"func":"GF_Box *stbl_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleTableBox, GF_ISOM_BOX_TYPE_STBL);\n\t\/\/maxSamplePer chunk is 10 by default\n\ttmp->MaxSamplePerChunk = 10;\n\ttmp->groupID = 1;\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":314770,"func":"cdf_dump_stream(const cdf_header_t *h, const cdf_stream_t *sst)\n{\n\tsize_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?\n\t    CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);\n\tcdf_dump(sst->sst_tab, ss * sst->sst_len);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":500684,"func":"static void sftp_ext_free(sftp_ext ext) {\n  unsigned int i;\n\n  if (ext == NULL) {\n    return;\n  }\n\n  if (ext->count) {\n    for (i = 0; i < ext->count; i++) {\n      SAFE_FREE(ext->name[i]);\n      SAFE_FREE(ext->data[i]);\n    }\n    SAFE_FREE(ext->name);\n    SAFE_FREE(ext->data);\n  }\n\n  SAFE_FREE(ext);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":336632,"func":"RedRecord *reds_get_record(RedsState *reds)\n{\n    if (reds->record) {\n        return red_record_ref(reds->record);\n    }\n\n    return NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":220397,"func":"mrb_ary_pop(mrb_state *mrb, mrb_value ary)\n{\n  struct RArray *a = mrb_ary_ptr(ary);\n  mrb_int len = ARY_LEN(a);\n\n  ary_modify_check(mrb, a);\n  if (len == 0) return mrb_nil_value();\n  ARY_SET_LEN(a, len-1);\n  return ARY_PTR(a)[len-1];\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":512237,"func":"void Item_equal::sort(Item_field_cmpfunc compare, void *arg)\n{\n  bubble_sort<Item>(&equal_items, compare, arg);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":225611,"func":"GF_Err stsh_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 count, i;\n\tGF_ShadowSyncBox *ptr = (GF_ShadowSyncBox *)s;\n\n\tISOM_DECREASE_SIZE(s, 4)\n\tcount = gf_bs_read_u32(bs);\n\tif (ptr->size \/ 8 < count)\n\t\treturn GF_ISOM_INVALID_FILE;\n\n\tfor (i = 0; i < count; i++) {\n\t\tGF_StshEntry *ent = (GF_StshEntry *) gf_malloc(sizeof(GF_StshEntry));\n\t\tif (!ent) return GF_OUT_OF_MEM;\n\t\tent->shadowedSampleNumber = gf_bs_read_u32(bs);\n\t\tent->syncSampleNumber = gf_bs_read_u32(bs);\n\t\te = gf_list_add(ptr->entries, ent);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":292213,"func":"find_session_from_type (int type, server *serv)\n{\n\tsession *sess;\n\tGSList *list = sess_list;\n\twhile (list)\n\t{\n\t\tsess = list->data;\n\t\tif (sess->type == type && serv == sess->server)\n\t\t\treturn sess;\n\t\tlist = list->next;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":250684,"func":"HttpFile::HttpFile(std::shared_ptr<HttpFileImpl> &&implPtr)\n    : implPtr_(std::move(implPtr))\n{\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":432205,"func":"static void unassigned_io_write(struct uc_struct *uc, void* opaque, hwaddr addr, uint64_t data, unsigned size)\n{\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":90794,"func":"void QuotaManager::NotifyOriginNoLongerInUse(const GURL& origin) {\n  DCHECK(io_thread_->BelongsToCurrentThread());\n  DCHECK(IsOriginInUse(origin));\n  int& count = origins_in_use_[origin];\n  if (--count == 0)\n    origins_in_use_.erase(origin);\n}\n","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":364753,"func":"get_tagstack(win_T *wp, dict_T *retdict)\n{\n    list_T\t*l;\n    int\t\ti;\n    dict_T\t*d;\n\n    dict_add_number(retdict, \"length\", wp->w_tagstacklen);\n    dict_add_number(retdict, \"curidx\", wp->w_tagstackidx + 1);\n    l = list_alloc_id(aid_tagstack_items);\n    if (l == NULL)\n\treturn;\n    dict_add_list(retdict, \"items\", l);\n\n    for (i = 0; i < wp->w_tagstacklen; i++)\n    {\n\tif ((d = dict_alloc_id(aid_tagstack_details)) == NULL)\n\t    return;\n\tlist_append_dict(l, d);\n\n\tget_tag_details(&wp->w_tagstack[i], d);\n    }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":314475,"func":"static bool FNAME(is_bad_mt_xwr)(struct rsvd_bits_validate *rsvd_check, u64 gpte)\n{\n#if PTTYPE != PTTYPE_EPT\n\treturn false;\n#else\n\treturn __is_bad_mt_xwr(rsvd_check, gpte);\n#endif\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":289298,"func":"static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,\n\t\t\t\t  struct snd_info_buffer *buffer)\n{\n\tstruct snd_pcm_str *pstr = entry->private_data;\n\tstruct snd_pcm_oss_setup *setup = pstr->oss.setup_list;\n\tmutex_lock(&pstr->oss.setup_mutex);\n\twhile (setup) {\n\t\tsnd_iprintf(buffer, \"%s %u %u%s%s%s%s%s%s\\n\",\n\t\t\t    setup->task_name,\n\t\t\t    setup->periods,\n\t\t\t    setup->period_size,\n\t\t\t    setup->disable ? \" disable\" : \"\",\n\t\t\t    setup->direct ? \" direct\" : \"\",\n\t\t\t    setup->block ? \" block\" : \"\",\n\t\t\t    setup->nonblock ? \" non-block\" : \"\",\n\t\t\t    setup->partialfrag ? \" partial-frag\" : \"\",\n\t\t\t    setup->nosilence ? \" no-silence\" : \"\");\n\t\tsetup = setup->next;\n\t}\n\tmutex_unlock(&pstr->oss.setup_mutex);\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":450349,"func":"void start_auth_vnc(VncState *vs)\n{\n    Error *err = NULL;\n\n    if (qcrypto_random_bytes(vs->challenge, sizeof(vs->challenge), &err)) {\n        trace_vnc_auth_fail(vs, vs->auth, \"cannot get random bytes\",\n                            error_get_pretty(err));\n        error_free(err);\n        authentication_failed(vs);\n        return;\n    }\n\n    \/* Send client a 'random' challenge *\/\n    vnc_write(vs, vs->challenge, sizeof(vs->challenge));\n    vnc_flush(vs);\n\n    vnc_read_when(vs, protocol_client_auth_vnc, sizeof(vs->challenge));\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":273402,"func":"  Tensor OutputSlice(Tensor* t, int pos, const string& name) {\n    Tensor res = UnalignedSlice(*t, pos);\n    if (res.IsAligned()) {\n      return res;\n    } else {\n      Tensor aligned = AlignTensor(res, name);\n      copy_out_.emplace_back(res, aligned);\n      return aligned;\n    }\n  }","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":338208,"func":"uint8_t WasmBinaryBuilder::getLaneIndex(size_t lanes) {\n  BYN_TRACE(\"<==\\n\");\n  auto ret = getInt8();\n  if (ret >= lanes) {\n    throwError(\"Illegal lane index\");\n  }\n  BYN_TRACE(\"getLaneIndex(\" << lanes << \"): \" << ret << \" ==>\" << std::endl);\n  return ret;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":508352,"func":"No_such_table_error_handler::handle_condition(THD *,\n                                              uint sql_errno,\n                                              const char*,\n                                              Sql_condition::enum_warning_level *level,\n                                              const char*,\n                                              Sql_condition ** cond_hdl)\n{\n  *cond_hdl= NULL;\n  if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE)\n  {\n    m_handled_errors++;\n    return TRUE;\n  }\n\n  if (*level == Sql_condition::WARN_LEVEL_ERROR)\n    m_unhandled_errors++;\n  return FALSE;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":513134,"func":"static bool register_builtin(struct st_maria_plugin *plugin,\n                             struct st_plugin_int *tmp,\n                             struct st_plugin_int **ptr)\n{\n  DBUG_ENTER(\"register_builtin\");\n  tmp->ref_count= 0;\n  tmp->plugin_dl= 0;\n\n  if (insert_dynamic(&plugin_array, (uchar*)&tmp))\n    DBUG_RETURN(1);\n\n  *ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1,\n                         struct st_plugin_int **)=\n        (struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)tmp,\n                                             sizeof(struct st_plugin_int));\n\n  if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr))\n    DBUG_RETURN(1);\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":274650,"func":"callbacks_show_selection_on_invisible (GtkMenuItem *menuitem, gpointer user_data)\n{\n\tmainProject->show_invisible_selection = GTK_CHECK_MENU_ITEM(menuitem)->active;\n\trender_refresh_rendered_image_on_screen();\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":477263,"func":"static void tipc_aead_free(struct rcu_head *rp)\n{\n\tstruct tipc_aead *aead = container_of(rp, struct tipc_aead, rcu);\n\tstruct tipc_tfm *tfm_entry, *head, *tmp;\n\n\tif (aead->cloned) {\n\t\ttipc_aead_put(aead->cloned);\n\t} else {\n\t\thead = *get_cpu_ptr(aead->tfm_entry);\n\t\tput_cpu_ptr(aead->tfm_entry);\n\t\tlist_for_each_entry_safe(tfm_entry, tmp, &head->list, list) {\n\t\t\tcrypto_free_aead(tfm_entry->tfm);\n\t\t\tlist_del(&tfm_entry->list);\n\t\t\tkfree(tfm_entry);\n\t\t}\n\t\t\/* Free the head *\/\n\t\tcrypto_free_aead(head->tfm);\n\t\tlist_del(&head->list);\n\t\tkfree(head);\n\t}\n\tfree_percpu(aead->tfm_entry);\n\tkfree_sensitive(aead->key);\n\tkfree(aead);\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":292239,"func":"do_dns (session *sess, char *nick, char *host,\n\t\tconst message_tags_data *tags_data)\n{\n\tGResolver *res = g_resolver_get_default ();\n\tGInetAddress *addr;\n\tchar *po;\n\n\tpo = strrchr (host, '@');\n\tif (po)\n\t\thost = po + 1;\n\n\tif (nick)\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_RESOLVINGUSER, sess, nick, host, NULL, NULL, 0,\n\t\t\t\t\t\t\t\ttags_data->timestamp);\n\n\tPrintTextf (sess, _(\"Looking up %s...\"), host);\n\n\taddr = g_inet_address_new_from_string (host);\n\tif (addr)\n\t\tg_resolver_lookup_by_address_async (res, addr, NULL, dns_addr_callback, sess);\n\telse\n\t\tg_resolver_lookup_by_name_async (res, host, NULL, dns_name_callback, sess);\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":231699,"func":"  bool getCanIgnorePathMTU() override {\n    return false;\n  }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":513016,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_cache_str_for_nullif>(thd, this); }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":344764,"func":"mktemp_proto(char *s, size_t len)\n{\n\tconst char *tmpdir;\n\tint r;\n\n\tif ((tmpdir = getenv(\"TMPDIR\")) != NULL) {\n\t\tr = snprintf(s, len, \"%s\/ssh-XXXXXXXXXXXX\", tmpdir);\n\t\tif (r > 0 && (size_t)r < len)\n\t\t\treturn;\n\t}\n\tr = snprintf(s, len, \"\/tmp\/ssh-XXXXXXXXXXXX\");\n\tif (r < 0 || (size_t)r >= len)\n\t\tfatal_f(\"template string too short\");\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":346452,"func":"source_dbg_tick(void *cookie)\n{\n    return &((source_cookie_T *)cookie)->dbg_tick;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":274885,"func":"TEST(ComparisonsTest, GreaterEqualBroadcast) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 1}, TensorType_INT32,\n                          BuiltinOperator_GREATER_EQUAL);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3});\n  model.PopulateTensor<int>(model.input2(), {7});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, true, false));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":513138,"func":"static void report_error(int where_to, uint error, ...)\n{\n  va_list args;\n  DBUG_ASSERT(where_to & (REPORT_TO_USER | REPORT_TO_LOG));\n  if (where_to & REPORT_TO_USER)\n  {\n    va_start(args, error);\n    my_printv_error(error, ER(error), MYF(0), args);\n    va_end(args);\n  }\n  if (where_to & REPORT_TO_LOG)\n  {\n    va_start(args, error);\n    error_log_print(ERROR_LEVEL, ER_DEFAULT(error), args);\n    va_end(args);\n  }\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":139235,"func":"void OverlayWindowViews::OnNativeBlur() {\n  if (is_initialized_)\n    UpdateControlsVisibility(false);\n\n  views::Widget::OnNativeBlur();\n}\n","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":254750,"func":"njs_typed_array_get_string_tag(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t unused)\n{\n    njs_value_t  *this;\n\n    static const njs_value_t  *tags[NJS_OBJ_TYPE_TYPED_ARRAY_SIZE] = {\n        &njs_typed_array_uint8_tag,\n        &njs_typed_array_uint8_clamped_tag,\n        &njs_typed_array_int8_tag,\n        &njs_typed_array_uint16_tag,\n        &njs_typed_array_int16_tag,\n        &njs_typed_array_uint32_tag,\n        &njs_typed_array_int32_tag,\n        &njs_typed_array_float32_tag,\n        &njs_typed_array_float64_tag,\n    };\n\n    this = njs_argument(args, 0);\n\n    if (!njs_is_typed_array(this)) {\n        njs_set_undefined(&vm->retval);\n        return NJS_OK;\n    }\n\n    vm->retval = *tags[njs_typed_array_index(njs_typed_array(this)->type)];\n\n    return NJS_OK;\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":247330,"func":"static void pgpPrtHex(const char *pre, const uint8_t *p, size_t plen)\n{\n    char *hex = NULL;\n    if (!_print) return;\n    if (pre && *pre)\n\tfprintf(stderr, \"%s\", pre);\n    hex = pgpHexStr(p, plen);\n    fprintf(stderr, \" %s\", hex);\n    free(hex);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":248298,"func":"DLLIMPORT double cfg_getnfloat(cfg_t *cfg, const char *name, unsigned int index)\n{\n\treturn cfg_opt_getnfloat(cfg_getopt(cfg, name), index);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":482500,"func":"deallocateRuleNames(TranslationTableHeader *table) {\n\tRuleName **ruleName = &table->ruleNames;\n\twhile (*ruleName) {\n\t\tRuleName *rn = *ruleName;\n\t\t*ruleName = rn->next;\n\t\tfree(rn);\n\t}\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":314511,"func":"static void parse_version(pj_scanner *scanner, \n                          volatile parse_context *ctx)\n{\n    ctx->last_error = PJMEDIA_SDP_EINVER;\n\n    \/* check equal sign *\/\n    if (*(scanner->curptr+1) != '=') {\n\ton_scanner_error(scanner);\n\treturn;\n    }\n\n    \/* check version is 0 *\/\n    if (*(scanner->curptr+2) != '0') {\n\ton_scanner_error(scanner);\n\treturn;\n    }\n\n    \/* We've got what we're looking for, skip anything until newline *\/\n    pj_scan_skip_line(scanner);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":223480,"func":"static void delayed_mem_copy_move(delayed_mem_copy_status *status, int load_base, sljit_sw load_offset,\n  int store_base, sljit_sw store_offset)\n{\nstruct sljit_compiler *compiler = status->compiler;\nint next_tmp_reg = status->next_tmp_reg;\nint tmp_reg = status->tmp_regs[next_tmp_reg];\n\nSLJIT_ASSERT(load_base > 0 && store_base > 0);\n\nif (status->store_bases[next_tmp_reg] == -1)\n  {\n  \/* Preserve virtual registers. *\/\n  if (sljit_get_register_index(status->saved_tmp_regs[next_tmp_reg]) < 0)\n    OP1(SLJIT_MOV, status->saved_tmp_regs[next_tmp_reg], 0, tmp_reg, 0);\n  }\nelse\n  OP1(SLJIT_MOV, SLJIT_MEM1(status->store_bases[next_tmp_reg]), status->store_offsets[next_tmp_reg], tmp_reg, 0);\n\nOP1(SLJIT_MOV, tmp_reg, 0, SLJIT_MEM1(load_base), load_offset);\nstatus->store_bases[next_tmp_reg] = store_base;\nstatus->store_offsets[next_tmp_reg] = store_offset;\n\nstatus->next_tmp_reg = (next_tmp_reg + 1) % RECURSE_TMP_REG_COUNT;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":90107,"func":"  virtual void AddNetworkManagerObserver(NetworkManagerObserver* observer) {}\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":356686,"func":"bool OtherInstanceOf(Napi::Object source, const char* object_type) {\n    if (strncmp(object_type, \"Date\", 4) == 0) {\n        return source.InstanceOf(source.Env().Global().Get(\"Date\").As<Function>());\n    } else if (strncmp(object_type, \"RegExp\", 6) == 0) {\n        return source.InstanceOf(source.Env().Global().Get(\"RegExp\").As<Function>());\n    }\n\n    return false;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":254899,"func":"Value DocumentSourceGroup::computeId(const Document& root) {\n    \/\/ If only one expression, return result directly\n    if (_idExpressions.size() == 1) {\n        Value retValue = _idExpressions[0]->evaluate(root, &pExpCtx->variables);\n        return retValue.missing() ? Value(BSONNULL) : std::move(retValue);\n    }\n\n    \/\/ Multiple expressions get results wrapped in a vector\n    vector<Value> vals;\n    vals.reserve(_idExpressions.size());\n    for (size_t i = 0; i < _idExpressions.size(); i++) {\n        vals.push_back(_idExpressions[i]->evaluate(root, &pExpCtx->variables));\n    }\n    return Value(std::move(vals));\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":301019,"func":"pcx24b_print_page(gx_device_printer * pdev, gp_file * file)\n{\n    pcx_header header;\n\n    header = pcx_header_prototype;\n    header.version = version_3_0;\n    header.bpp = 8;\n    header.nplanes = 3;\n    assign_ushort(header.palinfo, palinfo_color);\n    return pcx_write_page(pdev, file, &header, true);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":359466,"func":"DEFUN (bgp_default_local_preference,\n       bgp_default_local_preference_cmd,\n       \"bgp default local-preference <0-4294967295>\",\n       \"BGP specific commands\\n\"\n       \"Configure BGP defaults\\n\"\n       \"local preference (higher=more preferred)\\n\"\n       \"Configure default local preference value\\n\")\n{\n  struct bgp *bgp;\n  u_int32_t local_pref;\n\n  bgp = vty->index;\n\n  VTY_GET_INTEGER (\"local preference\", local_pref, argv[0]);\n\n  bgp_default_local_preference_set (bgp, local_pref);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":512618,"func":"Item_bool_rowready_func2* Le_creator::create(THD *thd, Item *a, Item *b) const\n{\n  return new(thd->mem_root) Item_func_le(thd, a, b);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":459205,"func":"void tcf_exts_destroy(struct tcf_exts *exts)\n{\n#ifdef CONFIG_NET_CLS_ACT\n\tif (exts->actions) {\n\t\ttcf_action_destroy(exts->actions, TCA_ACT_UNBIND);\n\t\tkfree(exts->actions);\n\t}\n\texts->nr_actions = 0;\n#endif\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":310076,"func":"chop_out(char *string, unsigned i, unsigned j)\n{\n    TR(TRACE_DATABASE, (\"chop_out %d..%d from %s\", i, j, _nc_visbuf(string)));\n    while (string[j] != '\\0') {\n\tstring[i++] = string[j++];\n    }\n    string[i] = '\\0';\n    return i;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":336668,"func":"SPICE_GNUC_VISIBLE int spice_server_get_peer_info(SpiceServer *reds, struct sockaddr *sa, socklen_t *salen)\n{\n    return -1;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":90879,"func":"  void reset_status_callback_count() { status_callback_count_ = 0; }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":246739,"func":"u32 parse_senc_param(char *arg_val, u32 opt)\n{\n\tswitch (opt) {\n\tcase 0: \/\/-sync\n\t\tsmenc_opts.flags |= GF_SM_ENCODE_RAP_INBAND;\n\t\tsmenc_opts.rap_freq = atoi(arg_val);\n\t\tbreak;\n\tcase 1: \/\/-shadow\n\t\tsmenc_opts.flags &= ~GF_SM_ENCODE_RAP_INBAND;\n\t\tsmenc_opts.flags |= GF_SM_ENCODE_RAP_SHADOW;\n\t\tsmenc_opts.rap_freq = atoi(arg_val);\n\t\tbreak;\n\tcase 2: \/\/-carousel\n\t\tsmenc_opts.flags &= ~(GF_SM_ENCODE_RAP_INBAND | GF_SM_ENCODE_RAP_SHADOW);\n\t\tsmenc_opts.rap_freq = atoi(arg_val);\n\t\tbreak;\n\tcase 3: \/\/-auto-quant\n\t\tsmenc_opts.resolution = atoi(arg_val);\n\t\tsmenc_opts.auto_quant = 1;\n\t\tbreak;\n\tcase 4: \/\/-global-quant\n\t\tsmenc_opts.resolution = atoi(arg_val);\n\t\tsmenc_opts.auto_quant = 2;\n\t\tbreak;\n\tcase 5: \/\/-ctx-in or -inctx\n\t\tchunk_mode = GF_TRUE;\n\t\tinput_ctx = arg_val;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":225829,"func":"GF_Err def_parent_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":522327,"func":"void GmfSetFloatPrecision(int64_t MshIdx , int FltSiz)\n{\n   GmfMshSct *msh = (GmfMshSct *)MshIdx;\n\n   if(FltSiz != 32 && FltSiz != 64)\n      return;\n\n   msh->FltSiz = FltSiz;\n   GmfSetKwd(MshIdx, GmfFloatingPointPrecision, 1);\n   GmfSetLin(MshIdx, GmfFloatingPointPrecision, FltSiz);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":224220,"func":"static RRBNode *_find_entry_submap_node(RIOBank *bank, RIOSubMap *sm) {\n\tRRBNode *node = r_crbtree_find_node (bank->submaps, sm, _find_lowest_intersection_sm_cb, NULL);\n\tif (!node) {\n\t\treturn NULL;\n\t}\n\tRRBNode *prev = r_rbnode_prev (node);\n\twhile (prev && r_io_submap_overlap (((RIOSubMap *)prev->data), sm)) {\n\t\tnode = prev;\n\t\tprev = r_rbnode_prev (node);\n\t}\n\treturn node;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":411922,"func":"dump_distinct_digest_count(int severity)\n{\n#ifdef COUNT_DISTINCT_DIGESTS\n  if (!verified_digests)\n    verified_digests = digestmap_new();\n  log(severity, LD_GENERAL, \"%d *distinct* router digests verified\",\n      digestmap_size(verified_digests));\n#else\n  (void)severity; \/* suppress \"unused parameter\" warning *\/\n#endif\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":359515,"func":"safi2str (safi_t safi)\n{\n  if (safi == SAFI_UNICAST)\n    return \"SAFI_UNICAST\";\n  else if (safi == SAFI_MULTICAST)\n    return \"SAFI_MULTICAST\";\n  else if (safi == SAFI_MPLS_VPN || safi == BGP_SAFI_VPNV4)\n    return \"SAFI_MPLS_VPN\";\n  else\n    return \"Unknown SAFI\";\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":292245,"func":"inbound_join (server *serv, char *chan, char *user, char *ip, char *account,\n\t\t\t\t  char *realname, const message_tags_data *tags_data)\n{\n\tsession *sess = find_channel (serv, chan);\n\tif (sess)\n\t{\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_JOIN, sess, user, chan, ip, account, 0,\n\t\t\t\t\t\t\t\t\t  tags_data->timestamp);\n\t\tuserlist_add (sess, user, ip, account, realname, tags_data);\n\t}\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":513220,"func":"static void update_func_str(THD *thd, struct st_mysql_sys_var *var,\n                             void *tgt, const void *save)\n{\n  char *value= *(char**) save;\n  if (var->flags & PLUGIN_VAR_MEMALLOC)\n  {\n    char *old= *(char**) tgt;\n    if (value)\n      *(char**) tgt= my_strdup(value, MYF(0));\n    else\n      *(char**) tgt= 0;\n    my_free(old);\n  }\n  else\n    *(char**) tgt= value;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":359201,"func":"BPF_CALL_4(bpf_ringbuf_output, struct bpf_map *, map, void *, data, u64, size,\n\t   u64, flags)\n{\n\tstruct bpf_ringbuf_map *rb_map;\n\tvoid *rec;\n\n\tif (unlikely(flags & ~(BPF_RB_NO_WAKEUP | BPF_RB_FORCE_WAKEUP)))\n\t\treturn -EINVAL;\n\n\trb_map = container_of(map, struct bpf_ringbuf_map, map);\n\trec = __bpf_ringbuf_reserve(rb_map->rb, size);\n\tif (!rec)\n\t\treturn -EAGAIN;\n\n\tmemcpy(rec, data, size);\n\tbpf_ringbuf_commit(rec, flags, false \/* discard *\/);\n\treturn 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":294414,"func":"expect_numeric(VALUE x)\n{\n    if (!k_numeric_p(x))\n\trb_raise(rb_eTypeError, \"expected numeric\");\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":234732,"func":"static int devid_cmp(void *priv, const struct list_head *a,\n\t\t     const struct list_head *b)\n{\n\tconst struct btrfs_device *dev1, *dev2;\n\n\tdev1 = list_entry(a, struct btrfs_device, dev_list);\n\tdev2 = list_entry(b, struct btrfs_device, dev_list);\n\n\tif (dev1->devid < dev2->devid)\n\t\treturn -1;\n\telse if (dev1->devid > dev2->devid)\n\t\treturn 1;\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":366232,"func":"static int do_umount_root(struct super_block *sb)\n{\n\tint ret = 0;\n\n\tdown_write(&sb->s_umount);\n\tif (!sb_rdonly(sb)) {\n\t\tstruct fs_context *fc;\n\n\t\tfc = fs_context_for_reconfigure(sb->s_root, SB_RDONLY,\n\t\t\t\t\t\tSB_RDONLY);\n\t\tif (IS_ERR(fc)) {\n\t\t\tret = PTR_ERR(fc);\n\t\t} else {\n\t\t\tret = parse_monolithic_mount_data(fc, NULL);\n\t\t\tif (!ret)\n\t\t\t\tret = reconfigure_super(fc);\n\t\t\tput_fs_context(fc);\n\t\t}\n\t}\n\tup_write(&sb->s_umount);\n\treturn ret;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":384278,"func":"gs_heap_free_string(gs_memory_t * mem, byte * data, uint nbytes,\n                    client_name_t cname)\n{\n    \/****** SHOULD CHECK SIZE IF DEBUGGING ******\/\n    gs_heap_free_object(mem, data, cname);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":503876,"func":"SCM_DEFINE (scm_closedir, \"closedir\", 1, 0, 0,\n\t    (SCM port),\n\t    \"Close the directory stream @var{port}.\\n\"\n\t    \"The return value is unspecified.\")\n#define FUNC_NAME s_scm_closedir\n{\n  SCM_VALIDATE_DIR (1, port);\n\n  if (SCM_DIR_OPEN_P (port))\n    {\n      int sts;\n\n      SCM_SYSCALL (sts = closedir ((DIR *) SCM_SMOB_DATA_1 (port)));\n      if (sts != 0)\n\tSCM_SYSERROR;\n\n      SCM_SET_SMOB_DATA_0 (port, scm_tc16_dir);\n    }\n\n  return SCM_UNSPECIFIED;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":317312,"func":"static void smack_netlbl_delete(struct sock *sk)\n{\n\tstruct socket_smack *ssp = sk->sk_security;\n\n\t\/*\n\t * Take the label off the socket if one is set.\n\t *\/\n\tif (ssp->smk_state != SMK_NETLBL_LABELED)\n\t\treturn;\n\n\tlocal_bh_disable();\n\tbh_lock_sock_nested(sk);\n\tnetlbl_sock_delattr(sk);\n\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\tssp->smk_state = SMK_NETLBL_UNLABELED;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":257707,"func":"int mod_wstunnel_frame_recv(handler_ctx *hctx) {\n  #ifdef _MOD_WEBSOCKET_SPEC_RFC_6455_\n    if (hctx->hybivers >= 8) return recv_rfc_6455(hctx);\n  #endif \/* _MOD_WEBSOCKET_SPEC_RFC_6455_ *\/\n  #ifdef _MOD_WEBSOCKET_SPEC_IETF_00_\n    if (0 == hctx->hybivers) return recv_ietf_00(hctx);\n  #endif \/* _MOD_WEBSOCKET_SPEC_IETF_00_ *\/\n    return -1;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":231657,"func":"TEST_P(\n    QuicServerTransportAllowMigrationTest,\n    ReceiveReorderedDataFromChangedPeerAddress) {\n  auto data = IOBuf::copyBuffer(\"bad data\");\n  auto firstPacket = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      2,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n  auto secondPacket = packetToBuf(createStreamPacket(\n      *clientConnectionId,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++,\n      6,\n      *data,\n      0 \/* cipherOverhead *\/,\n      0 \/* largestAcked *\/));\n\n  \/\/ Receive second packet first\n  deliverData(std::move(secondPacket));\n\n  auto peerAddress = server->getConn().peerAddress;\n\n  \/\/ Receive first packet later from a different address\n  folly::SocketAddress newPeer(\"100.101.102.103\", 23456);\n  deliverData(std::move(firstPacket), true, &newPeer);\n\n  \/\/ No migration for reordered packet\n  EXPECT_EQ(server->getConn().peerAddress, peerAddress);\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":432187,"func":"static void address_space_set_flatview(AddressSpace *as)\n{\n    FlatView *old_view = address_space_to_flatview(as);\n    MemoryRegion *physmr = memory_region_get_flatview_root(as->root);\n    FlatView *new_view = g_hash_table_lookup(as->uc->flat_views, physmr);\n\n    assert(new_view);\n\n    if (old_view == new_view) {\n        return;\n    }\n\n    flatview_ref(new_view);\n    if (!QTAILQ_EMPTY(&as->listeners)) {\n        FlatView tmpview = { .nr = 0 }, *old_view2 = old_view;\n\n        if (!old_view2) {\n            old_view2 = &tmpview;\n        }\n        address_space_update_topology_pass(as, old_view2, new_view, false);\n        address_space_update_topology_pass(as, old_view2, new_view, true);\n    }\n\n    as->current_map = new_view;\n    if (old_view) {\n        flatview_unref(old_view);\n    }\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":246471,"func":"RPVector *r_bin_wasm_get_types(RBinWasmObj *bin) {\n\tr_return_val_if_fail (bin && bin->g_sections, NULL);\n\treturn bin->g_types? bin->g_types: parse_unique_subsec_vec_by_id (bin, R_BIN_WASM_SECTION_TYPE);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":248273,"func":"DLLIMPORT cfg_t *cfg_gettsec(cfg_t *cfg, const char *name, const char *title)\n{\n\treturn cfg_opt_gettsec(cfg_getopt(cfg, name), title);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":226132,"func":"void npck_box_del(GF_Box *s)\n{\n\tgf_free((GF_NPCKBox *)s);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":474006,"func":"big5_hkscs_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)\n{\n    return big5_mbc_enc_len0(p, e, 2, EncLen_BIG5_HKSCS);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":264647,"func":"GF_Err BM_ParseCommand(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_list)\n{\n\tu8 go, type;\n\tGF_Err e;\n\tgo = 1;\n\te = GF_OK;\n\tGF_SceneGraph *cur_graph = codec->current_graph;\n\tGF_Proto *cur_proto = codec->pCurrentProto;\n\n\tcodec->LastError = GF_OK;\n\twhile (go) {\n\t\ttype = gf_bs_read_int(bs, 2);\n\t\tswitch (type) {\n\t\tcase 0:\n\t\t\te = BM_ParseInsert(codec, bs, com_list);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\te = BM_ParseDelete(codec, bs, com_list);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\te = BM_ParseReplace(codec, bs, com_list);\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\te = BM_SceneReplace(codec, bs, com_list);\n\t\t\tbreak;\n\t\t}\n\t\tif (e) break;\n\t\tgo = gf_bs_read_int(bs, 1);\n\t}\n\twhile (gf_list_count(codec->QPs)) {\n\t\tgf_bifs_dec_qp_remove(codec, GF_TRUE);\n\t}\n\n\tcodec->current_graph = cur_graph;\n\tcodec->pCurrentProto = cur_proto;\n\treturn e;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":263494,"func":"static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,\n\t\t\t    size_t len, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sco_pinfo *pi = sco_pi(sk);\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state == BT_CONNECT2 &&\n\t    test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {\n\t\tsco_conn_defer_accept(pi->conn->hcon, pi->setting);\n\t\tsk->sk_state = BT_CONFIG;\n\n\t\trelease_sock(sk);\n\t\treturn 0;\n\t}\n\n\trelease_sock(sk);\n\n\treturn bt_sock_recvmsg(sock, msg, len, flags);\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":225873,"func":"GF_Box *gnra_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_GenericAudioSampleEntryBox, GF_ISOM_BOX_TYPE_GNRA);\n\tgf_isom_audio_sample_entry_init((GF_AudioSampleEntryBox*) tmp);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":313534,"func":"int rose_add_loopback_node(const rose_address *address)\n{\n\tstruct rose_node *rose_node;\n\tint err = 0;\n\n\tspin_lock_bh(&rose_node_list_lock);\n\n\trose_node = rose_node_list;\n\twhile (rose_node != NULL) {\n\t\tif ((rose_node->mask == 10) &&\n\t\t     (rosecmpm(address, &rose_node->address, 10) == 0) &&\n\t\t     rose_node->loopback)\n\t\t\tbreak;\n\t\trose_node = rose_node->next;\n\t}\n\n\tif (rose_node != NULL)\n\t\tgoto out;\n\n\tif ((rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC)) == NULL) {\n\t\terr = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\trose_node->address      = *address;\n\trose_node->mask         = 10;\n\trose_node->count        = 1;\n\trose_node->loopback     = 1;\n\trose_node->neighbour[0] = rose_loopback_neigh;\n\n\t\/* Insert at the head of list. Address is always mask=10 *\/\n\trose_node->next = rose_node_list;\n\trose_node_list  = rose_node;\n\n\trose_loopback_neigh->count++;\n\nout:\n\tspin_unlock_bh(&rose_node_list_lock);\n\n\treturn err;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":222674,"func":"static void setup_locale(void)\n{\n\tconst char *s;\n\n\tif (setlocale(LC_CTYPE, \"en_US.UTF-8\") == NULL) {\n\t\tif (setlocale(LC_CTYPE, \"\") == NULL)\n\t\t\ttmate_fatal(\"invalid LC_ALL, LC_CTYPE or LANG\");\n\t\ts = nl_langinfo(CODESET);\n\t\tif (strcasecmp(s, \"UTF-8\") != 0 &&\n\t\t    strcasecmp(s, \"UTF8\") != 0)\n\t\t\ttmate_fatal(\"need UTF-8 locale (LC_CTYPE) but have %s\", s);\n\t}\n\n\tsetlocale(LC_TIME, \"\");\n\ttzset();\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":483488,"func":"int efi_mem_type(unsigned long phys_addr)\n{\n\tconst efi_memory_desc_t *md;\n\n\tif (!efi_enabled(EFI_MEMMAP))\n\t\treturn -ENOTSUPP;\n\n\tfor_each_efi_memory_desc(md) {\n\t\tif ((md->phys_addr <= phys_addr) &&\n\t\t    (phys_addr < (md->phys_addr +\n\t\t\t\t  (md->num_pages << EFI_PAGE_SHIFT))))\n\t\t\treturn md->type;\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":238764,"func":"fuzzy_match_func_compare(const void *s1, const void *s2)\n{\n    int\t\tv1 = ((fuzmatch_str_T *)s1)->score;\n    int\t\tv2 = ((fuzmatch_str_T *)s2)->score;\n    int\t\tidx1 = ((fuzmatch_str_T *)s1)->idx;\n    int\t\tidx2 = ((fuzmatch_str_T *)s2)->idx;\n    char_u\t*str1 = ((fuzmatch_str_T *)s1)->str;\n    char_u\t*str2 = ((fuzmatch_str_T *)s2)->str;\n\n    if (*str1 != '<' && *str2 == '<') return -1;\n    if (*str1 == '<' && *str2 != '<') return 1;\n    return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":220844,"func":"inline Integer FloorLog2(Integer n) {\n  static_assert(std::is_integral<Integer>::value, \"\");\n  static_assert(std::is_signed<Integer>::value, \"\");\n  static_assert(sizeof(Integer) == 4 || sizeof(Integer) == 8, \"\");\n  TFLITE_CHECK_GT(n, 0);\n  if (sizeof(Integer) == 4) {\n    return 30 - CountLeadingSignBits(n);\n  } else {\n    return 62 - CountLeadingSignBits(n);\n  }\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":343162,"func":"static void esp_output_restore_header(struct sk_buff *skb)\n{\n\tvoid *tmp = ESP_SKB_CB(skb)->tmp;\n\tstruct esp_output_extra *extra = esp_tmp_extra(tmp);\n\n\tesp_restore_header(skb, skb_transport_offset(skb) + extra->esphoff -\n\t\t\t\tsizeof(__be32));\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":226097,"func":"GF_Err hdlr_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_HandlerBox *ptr = (GF_HandlerBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->reserved1);\n\tgf_bs_write_u32(bs, ptr->handlerType);\n\tgf_bs_write_data(bs, (char*)ptr->reserved2, 12);\n\n\tif (ptr->nameUTF8) {\n\t\tu32 len = (u32)strlen(ptr->nameUTF8);\n\t\tif (ptr->store_counted_string) {\n\t\t\tgf_bs_write_u8(bs, len);\n\t\t\tgf_bs_write_data(bs, ptr->nameUTF8, len);\n\t\t} else {\n\t\t\tgf_bs_write_data(bs, ptr->nameUTF8, len);\n\t\t\tgf_bs_write_u8(bs, 0);\n\t\t}\n\t} else {\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":101698,"func":"void WebProcessProxy::sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<PluginInfo> > pluginInfos)\n{\n    ASSERT(isMainThread());\n\n    OwnPtr<Vector<PluginInfo> > plugins(pluginInfos);\n\n#if PLATFORM(MAC)\n    if (!m_context->omitPDFSupport()) {\n#if ENABLE(PDFKIT_PLUGIN)\n        plugins->append(PDFPlugin::pluginInfo());\n#endif\n        plugins->append(SimplePDFPlugin::pluginInfo());\n    }\n#endif\n\n    send(Messages::WebProcess::DidGetPlugins(requestID, *plugins), 0);\n}\n","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":331762,"func":"void QPaintEngineEx::drawEllipse(const QRectF &r)\n{\n    qreal pts[26]; \/\/ QPointF[13] without constructors...\n    union {\n        qreal *ptr;\n        QPointF *points;\n    } x;\n    x.ptr = pts;\n\n    int point_count = 0;\n    x.points[0] = qt_curves_for_arc(r, 0, -360, x.points + 1, &point_count);\n    if (point_count == 0)\n        return;\n    QVectorPath vp((qreal *) pts, point_count + 1, qpaintengineex_ellipse_types, QVectorPath::EllipseHint);\n    draw(vp);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":512973,"func":"bool Item_func_coalesce::native_op(THD *thd, Native *to)\n{\n  DBUG_ASSERT(fixed == 1);\n  for (uint i= 0; i < arg_count; i++)\n  {\n    if (!val_native_with_conversion_from_item(thd, args[i], to, type_handler()))\n      return false;\n  }\n  return (null_value= true);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":225427,"func":"static int vidioc_try_fmt_cap(struct file *file, void *priv,\n\t\t\t      struct v4l2_format *fmt)\n{\n\tstruct v4l2_loopback_device *dev;\n\tchar buf[5];\n\n\tdev = v4l2loopback_getdevice(file);\n\n\tif (0 == dev->ready_for_capture) {\n\t\tdprintk(\"setting fmt_cap not possible yet\\n\");\n\t\treturn -EBUSY;\n\t}\n\n\tif (fmt->fmt.pix.pixelformat != dev->pix_format.pixelformat)\n\t\treturn -EINVAL;\n\n\tfmt->fmt.pix = dev->pix_format;\n\n\tbuf[4] = 0;\n\tdprintk(\"capFOURCC=%s\\n\", fourcc2str(dev->pix_format.pixelformat, buf));\n\treturn 0;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":238318,"func":"static int digest_update_interruptible(struct digest *d, const void *data,\n\t\t\t\t       unsigned long len)\n{\n\tif (ctrlc())\n\t\treturn -EINTR;\n\n\treturn digest_update(d, data, len);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":215399,"func":"int hfsplus_find_cat(struct super_block *sb, u32 cnid,\n\t\t     struct hfs_find_data *fd)\n{\n\thfsplus_cat_entry tmp;\n\tint err;\n\tu16 type;\n\n\thfsplus_cat_build_key(sb, fd->search_key, cnid, NULL);\n\terr = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry));\n\tif (err)\n\t\treturn err;\n\n\ttype = be16_to_cpu(tmp.type);\n\tif (type != HFSPLUS_FOLDER_THREAD && type != HFSPLUS_FILE_THREAD) {\n\t\tprintk(KERN_ERR \"hfs: found bad thread record in catalog\\n\");\n\t\treturn -EIO;\n\t}\n\n\thfsplus_cat_build_key_uni(fd->search_key, be32_to_cpu(tmp.thread.parentID),\n\t\t\t\t &tmp.thread.nodeName);\n\treturn hfs_brec_find(fd);\n}","target":1,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":313831,"func":"push_showcmd(void)\n{\n    if (p_sc)\n\tSTRCPY(old_showcmd_buf, showcmd_buf);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":301399,"func":"static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path)\n{\n\tchar *result;\n\n\tSTART_PROFILE(syscall_realpath);\n#ifdef REALPATH_TAKES_NULL\n\tresult = realpath(path, NULL);\n#else\n\tresult = SMB_MALLOC_ARRAY(char, PATH_MAX+1);\n\tif (result) {\n\t\tchar *resolved_path = realpath(path, result);\n\t\tif (!resolved_path) {\n\t\t\tSAFE_FREE(result);\n\t\t} else {\n\t\t\t\/* SMB_ASSERT(result == resolved_path) ? *\/\n\t\t\tresult = resolved_path;\n\t\t}\n\t}\n#endif\n\tEND_PROFILE(syscall_realpath);\n\treturn result;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":230308,"func":"njs_array_handler_find_index(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    njs_int_t    ret;\n    njs_value_t  copy;\n\n    if (njs_is_valid(entry)) {\n        copy = *entry;\n\n    } else {\n        njs_set_undefined(©);\n    }\n\n    ret = njs_array_iterator_call(vm, args, ©, n);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    if (njs_is_true(&vm->retval)) {\n        njs_set_number(&vm->retval, n);\n\n        return NJS_DONE;\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":310007,"func":"_nc_retrace_int(int code)\n{\n    T((T_RETURN(\"%d\"), code));\n    return code;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":328849,"func":"R_API void r_bin_java_print_method_summary(RBinJavaField *field) {\n\tRBinJavaAttrInfo *attr;\n\tRListIter *iter, *iter_tmp;\n\tif (field == NULL) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaField* Method.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"Method Summary Information:\\n\");\n\tprintf (\"  File Offset: 0x%08\"PFMT64x \"\\n\", field->file_offset);\n\tprintf (\"  Name Index: %d (%s)\\n\", field->name_idx, field->name);\n\tprintf (\"  Descriptor Index: %d (%s)\\n\", field->descriptor_idx, field->descriptor);\n\tprintf (\"  Access Flags: 0x%02x (%s)\\n\", field->flags, field->flags_str);\n\tprintf (\"  Method Attributes Count: %d\\n\", field->attr_count);\n\tprintf (\"  Method Attributes:\\n\");\n\tr_list_foreach_safe (field->attributes, iter, iter_tmp, attr) {\n\t\tr_bin_java_print_attr_summary (attr);\n\t}\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":359390,"func":"DEFUN (no_bgp_cluster_id,\n       no_bgp_cluster_id_cmd,\n       \"no bgp cluster-id\",\n       NO_STR\n       BGP_STR\n       \"Configure Route-Reflector Cluster-id\\n\")\n{\n  int ret;\n  struct bgp *bgp;\n  struct in_addr cluster;\n\n  bgp = vty->index;\n\n  if (argc == 1)\n    {\n      ret = inet_aton (argv[0], &cluster);\n      if (! ret)\n\t{\n\t  vty_out (vty, \"%% Malformed bgp cluster identifier%s\", VTY_NEWLINE);\n\t  return CMD_WARNING;\n\t}\n    }\n\n  bgp_cluster_id_unset (bgp);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":220178,"func":"Status Node::input_edge(int idx, const Edge** e) const {\n  if (idx < 0 || idx >= num_inputs()) {\n    return errors::InvalidArgument(\"Invalid input_edge index: \", idx, \", Node \",\n                                   name(), \" only has \", num_inputs(),\n                                   \" inputs.\");\n  }\n\n  \/\/ This does a linear search over the edges.  In the common case,\n  \/\/ the number of elements is small enough that this search isn't\n  \/\/ expensive.  Should it become a bottleneck, one can make an\n  \/\/ optimization where, if the number of edges is small, we use\n  \/\/ linear iteration, and if the number of edges is large, we perform\n  \/\/ an indexing step during construction that keeps an array of Edges\n  \/\/ indexed by pointer.  This would keep the size of each Node small\n  \/\/ in the common case but make this function faster when the number\n  \/\/ of edges is large.\n  for (const Edge* edge : in_edges()) {\n    if (edge->dst_input() == idx) {\n      *e = edge;\n      return Status::OK();\n    }\n  }\n\n  return errors::NotFound(\"Could not find input edge \", idx, \" for \", name());\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":225439,"func":"static void check_timers(struct v4l2_loopback_device *dev)\n{\n\tif (!dev->ready_for_capture)\n\t\treturn;\n\n\tif (dev->timeout_jiffies > 0 && !timer_pending(&dev->timeout_timer))\n\t\tmod_timer(&dev->timeout_timer, jiffies + dev->timeout_jiffies);\n\tif (dev->sustain_framerate && !timer_pending(&dev->sustain_timer))\n\t\tmod_timer(&dev->sustain_timer,\n\t\t\t  jiffies + dev->frame_jiffies * 3 \/ 2);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":90746,"func":"  void CallCallbacksAndClear(\n      CallbackList* callbacks, QuotaStatusCode status,\n      int64 usage, int64 quota) {\n    for (CallbackList::iterator iter = callbacks->begin();\n         iter != callbacks->end(); ++iter) {\n      (*iter)->Run(status, usage, quota);\n      delete *iter;\n    }\n    callbacks->clear();\n  }\n","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":231017,"func":"    QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,\r\n                                                       const UBaseType_t uxInitialCount,\r\n                                                       StaticQueue_t * pxStaticQueue )\r\n    {\r\n        QueueHandle_t xHandle;\r\n\r\n        configASSERT( uxMaxCount != 0 );\r\n        configASSERT( uxInitialCount <= uxMaxCount );\r\n\r\n        xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r\n\r\n        if( xHandle != NULL )\r\n        {\r\n            ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount;\r\n\r\n            traceCREATE_COUNTING_SEMAPHORE();\r\n        }\r\n        else\r\n        {\r\n            traceCREATE_COUNTING_SEMAPHORE_FAILED();\r\n        }\r\n\r\n        return xHandle;\r\n    }\r","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":242991,"func":"static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl )\n{\n    if( ssl->in_msglen > 0 )\n        return( 1 );\n\n    return( 0 );\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":387794,"func":"klassItable InstanceKlass::itable() const {\n  return klassItable(const_cast<InstanceKlass*>(this));\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":225926,"func":"GF_Box *hnti_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_HintTrackInfoBox, GF_ISOM_BOX_TYPE_HNTI);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":244015,"func":"void jp2h_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":521484,"func":"    static MemoryBlock createZipMemoryBlock (const StringArray& entryNames)\r\n    {\r\n        ZipFile::Builder builder;\r\n        HashMap<String, MemoryBlock> blocks;\r\n\r\n        for (auto& entryName : entryNames)\r\n        {\r\n            auto& block = blocks.getReference (entryName);\r\n            MemoryOutputStream mo (block, false);\r\n            mo << entryName;\r\n            mo.flush();\r\n            builder.addEntry (new MemoryInputStream (block, false), 9, entryName, Time::getCurrentTime());\r\n        }\r\n\r\n        MemoryBlock data;\r\n        MemoryOutputStream mo (data, false);\r\n        builder.writeToStream (mo, nullptr);\r\n\r\n        return data;\r\n    }\r","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":229244,"func":"sstring to_string(const event::schema_change::change_type t) {\n    switch (t) {\n    case event::schema_change::change_type::CREATED: return \"CREATED\";\n    case event::schema_change::change_type::UPDATED: return \"UPDATED\";\n    case event::schema_change::change_type::DROPPED: return \"DROPPED\";\n    }\n    assert(false && \"unreachable\");\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":90841,"func":"  void DidGetGlobalUsage(StorageType type, int64 usage,\n                         int64 unlimited_usage) {\n    type_ = type;\n    usage_ = usage;\n    unlimited_usage_ = unlimited_usage;\n  }\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":224179,"func":"  void Compute(OpKernelContext* ctx) override {\n    StagingMap<Ordered>* map = nullptr;\n    OP_REQUIRES_OK(ctx, GetStagingMap(ctx, def(), &map));\n    core::ScopedUnref scope(map);\n\n    \/\/ Pop a random (key, value) off the map\n    typename StagingMap<Ordered>::KeyType key;\n    typename StagingMap<Ordered>::Tuple tuple;\n\n    const Tensor* indices_tensor;\n\n    OP_REQUIRES_OK(ctx, ctx->input(\"indices\", &indices_tensor));\n    OP_REQUIRES_OK(ctx, map->popitem(&key, indices_tensor, &tuple));\n\n    \/\/ Allocate a key tensor and assign the key as the first output\n    ctx->set_output(0, key);\n\n    \/\/ Set the rest of the outputs to the tuple Tensors\n    OP_REQUIRES(\n        ctx, tuple.size() == indices_tensor->NumElements(),\n        errors::InvalidArgument(\"output\/indices size mismatch: \", tuple.size(),\n                                \" vs. \", indices_tensor->NumElements()));\n\n    for (std::size_t i = 0; i < tuple.size(); ++i) {\n      ctx->set_output(i + 1, tuple[i]);\n    }\n  }","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":476122,"func":"next_desc(struct usb_descriptor_header **t, u8 desc_type)\n{\n\tfor (; *t; t++) {\n\t\tif ((*t)->bDescriptorType == desc_type)\n\t\t\treturn t;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":359373,"func":"DEFUN (clear_ip_bgp_all_soft_in,\n       clear_ip_bgp_all_soft_in_cmd,\n       \"clear ip bgp * soft in\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,\n                          BGP_CLEAR_SOFT_IN, NULL);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,\n\t\t\tBGP_CLEAR_SOFT_IN, NULL);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":225594,"func":"GF_Box *trpy_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TRPYBox, GF_ISOM_BOX_TYPE_TRPY);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":261749,"func":"void RtmpProtocol::sendAcknowledgementSize(uint32_t size) {\n    size = htonl(size);\n    std::string set_windowSize((char *) &size, 4);\n    sendRequest(MSG_WIN_SIZE, set_windowSize);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":338193,"func":"void WasmBinaryWriter::writeLateUserSections() {\n  for (auto& section : wasm->userSections) {\n    if (section.name != BinaryConsts::UserSections::Dylink) {\n      writeUserSection(section);\n    }\n  }\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":405373,"func":"static const void *xfrm_get_dst_nexthop(const struct dst_entry *dst,\n\t\t\t\t\tconst void *daddr)\n{\n\twhile (dst->xfrm) {\n\t\tconst struct xfrm_state *xfrm = dst->xfrm;\n\n\t\tdst = xfrm_dst_child(dst);\n\n\t\tif (xfrm->props.mode == XFRM_MODE_TRANSPORT)\n\t\t\tcontinue;\n\t\tif (xfrm->type->flags & XFRM_TYPE_REMOTE_COADDR)\n\t\t\tdaddr = xfrm->coaddr;\n\t\telse if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR))\n\t\t\tdaddr = &xfrm->id.daddr;\n\t}\n\treturn daddr;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":430339,"func":"struct hlist_node *seq_hlist_next_rcu(void *v,\n\t\t\t\t      struct hlist_head *head,\n\t\t\t\t      loff_t *ppos)\n{\n\tstruct hlist_node *node = v;\n\n\t++*ppos;\n\tif (v == SEQ_START_TOKEN)\n\t\treturn rcu_dereference(head->first);\n\telse\n\t\treturn rcu_dereference(node->next);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":281141,"func":"int xfrm_policy_delete(struct xfrm_policy *pol, int dir)\n{\n\tstruct net *net = xp_net(pol);\n\n\tspin_lock_bh(&net->xfrm.xfrm_policy_lock);\n\tpol = __xfrm_policy_unlink(pol, dir);\n\tspin_unlock_bh(&net->xfrm.xfrm_policy_lock);\n\tif (pol) {\n\t\txfrm_policy_kill(pol);\n\t\treturn 0;\n\t}\n\treturn -ENOENT;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":450834,"func":"static u8 st21nfca_se_get_bwi(struct nfc_hci_dev *hdev)\n{\n\tint i;\n\tu8 td;\n\tstruct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);\n\n\t\/* Bits 8 to 5 of the first TB for T=1 encode BWI from zero to nine *\/\n\tfor (i = 1; i < ST21NFCA_ESE_MAX_LENGTH; i++) {\n\t\ttd = ST21NFCA_ATR_GET_Y_FROM_TD(info->se_info.atr[i]);\n\t\tif (ST21NFCA_ATR_TA_PRESENT(td))\n\t\t\ti++;\n\t\tif (ST21NFCA_ATR_TB_PRESENT(td)) {\n\t\t\ti++;\n\t\t\treturn info->se_info.atr[i] >> 4;\n\t\t}\n\t}\n\treturn ST21NFCA_ATR_DEFAULT_BWI;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":224188,"func":"  explicit MapIncompleteSizeOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":261252,"func":"    int wm_SemLock(wm_Sem *s) {\n        WaitForSingleObject(*s, 0);\n        return 0;\n    }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":225557,"func":"void TfLiteQuantizationFree(TfLiteQuantization* quantization) {\n  if (quantization->type == kTfLiteAffineQuantization) {\n    TfLiteAffineQuantization* q_params =\n        (TfLiteAffineQuantization*)(quantization->params);\n    if (q_params->scale) {\n      TfLiteFloatArrayFree(q_params->scale);\n      q_params->scale = NULL;\n    }\n    if (q_params->zero_point) {\n      TfLiteIntArrayFree(q_params->zero_point);\n      q_params->zero_point = NULL;\n    }\n    free(q_params);\n  }\n  quantization->params = NULL;\n  quantization->type = kTfLiteNoQuantization;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":224739,"func":"GF_Box *iloc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ItemLocationBox, GF_ISOM_BOX_TYPE_ILOC);\n\ttmp->location_entries = gf_list_new();\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":445870,"func":"fr_window_finalize (GObject *object)\n{\n\tFrWindow *window = FR_WINDOW (object);\n\n\tfr_window_free_open_files (window);\n\n\tif (window->archive != NULL) {\n\t\tg_object_unref (window->archive);\n\t\twindow->archive = NULL;\n\t}\n\n\tif (window->priv != NULL) {\n\t\tfr_window_free_private_data (window);\n\t\tg_free (window->priv);\n\t\twindow->priv = NULL;\n\t}\n\n\tG_OBJECT_CLASS (fr_window_parent_class)->finalize (object);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":427156,"func":"static int reglevel (FuncState *fs, int nvar) {\n  while (nvar-- > 0) {\n    Vardesc *vd = getlocalvardesc(fs, nvar);  \/* get previous variable *\/\n    if (vd->vd.kind != RDKCTC)  \/* is in a register? *\/\n      return vd->vd.ridx + 1;\n  }\n  return 0;  \/* no variables in registers *\/\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":345206,"func":"void con_free_unimap(struct vc_data *vc)\n{\n\tstruct uni_pagedir *p;\n\n\tp = *vc->vc_uni_pagedir_loc;\n\tif (!p)\n\t\treturn;\n\t*vc->vc_uni_pagedir_loc = NULL;\n\tif (--p->refcount)\n\t\treturn;\n\tcon_release_unimap(p);\n\tkfree(p);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":310038,"func":"usage(void)\n{\n    static const char *msg[] =\n    {\n\t\"Usage: test_tparm [options] [capability] [value1 [value2 [...]]]\",\n\t\"\",\n\t\"Print all distinct combinations of given capability.\",\n\t\"\",\n\t\"Options:\",\n\t\" -T TERM  override $TERM; this may be a comma-separated list or \\\"-\\\"\",\n\t\"          to read a list from standard-input\",\n\t\" -a       if capability is given, test all combinations of values\",\n\t\" -r NUM   repeat tests NUM times\",\n\t\" -v       show values and results\",\n    };\n    unsigned n;\n    for (n = 0; n < SIZEOF(msg); ++n) {\n\tfprintf(stderr, \"%s\\n\", msg[n]);\n    }\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":437707,"func":"static inline void control_tx_enable(struct cx23885_dev *dev, bool enable)\n{\n\tcx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~(CNTRL_TXE | CNTRL_TFE),\n\t\t\t   enable ? (CNTRL_TXE | CNTRL_TFE) : 0);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":309821,"func":"drv_kpad(TERMINAL_CONTROL_BLOCK * TCB, int flag)\n{\n    int ret = ERR;\n    SCREEN *sp;\n\n    AssertTCB();\n\n    sp = TCB->csp;\n\n    if (sp) {\n\tif (flag) {\n\t    (void) __nc_putp_flush(sp, \"keypad_xmit\", keypad_xmit);\n\t} else if (!flag && keypad_local) {\n\t    (void) __nc_putp_flush(sp, \"keypad_local\", keypad_local);\n\t}\n\tif (flag && !sp->_tried) {\n\t    _nc_init_keytry(sp);\n\t    sp->_tried = TRUE;\n\t}\n\tret = OK;\n    }\n\n    return ret;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":488404,"func":"static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,\n\t\t\t\tunsigned long addr, unsigned long end,\n\t\t\t\tunsigned long floor, unsigned long ceiling)\n{\n\tpud_t *pud;\n\tunsigned long next;\n\tunsigned long start;\n\n\tstart = addr;\n\tpud = pud_offset(pgd, addr);\n\tdo {\n\t\tnext = pud_addr_end(addr, end);\n\t\tif (pud_none_or_clear_bad(pud))\n\t\t\tcontinue;\n\t\tfree_pmd_range(tlb, pud, addr, next, floor, ceiling);\n\t} while (pud++, addr = next, addr != end);\n\n\tstart &= PGDIR_MASK;\n\tif (start < floor)\n\t\treturn;\n\tif (ceiling) {\n\t\tceiling &= PGDIR_MASK;\n\t\tif (!ceiling)\n\t\t\treturn;\n\t}\n\tif (end - 1 > ceiling - 1)\n\t\treturn;\n\n\tpud = pud_offset(pgd, start);\n\tpgd_clear(pgd);\n\tpud_free_tlb(tlb, pud);\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":317187,"func":"static struct smack_known *smack_from_netlbl(const struct sock *sk, u16 family,\n\t\t\t\t\t     struct sk_buff *skb)\n{\n\tstruct netlbl_lsm_secattr secattr;\n\tstruct socket_smack *ssp = NULL;\n\tstruct smack_known *skp = NULL;\n\n\tnetlbl_secattr_init(&secattr);\n\n\tif (sk)\n\t\tssp = sk->sk_security;\n\n\tif (netlbl_skbuff_getattr(skb, family, &secattr) == 0) {\n\t\tskp = smack_from_secattr(&secattr, ssp);\n\t\tif (secattr.flags & NETLBL_SECATTR_CACHEABLE)\n\t\t\tnetlbl_cache_add(skb, family, &skp->smk_netlabel);\n\t}\n\n\tnetlbl_secattr_destroy(&secattr);\n\n\treturn skp;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":231693,"func":"  auto& drainTimeout() {\n    return drainTimeout_;\n  }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":317357,"func":"static int smack_shm_shmctl(struct kern_ipc_perm *isp, int cmd)\n{\n\tint may;\n\n\tswitch (cmd) {\n\tcase IPC_STAT:\n\tcase SHM_STAT:\n\tcase SHM_STAT_ANY:\n\t\tmay = MAY_READ;\n\t\tbreak;\n\tcase IPC_SET:\n\tcase SHM_LOCK:\n\tcase SHM_UNLOCK:\n\tcase IPC_RMID:\n\t\tmay = MAY_READWRITE;\n\t\tbreak;\n\tcase IPC_INFO:\n\tcase SHM_INFO:\n\t\t\/*\n\t\t * System level information.\n\t\t *\/\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\treturn smk_curacc_shm(isp, may);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":220182,"func":"std::string Graph::NewName(StringPiece prefix) {\n  return strings::StrCat(prefix, \"\/_\", name_counter_++);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":245701,"func":"add_header_to_connection (orderedmap hashofheaders, char *header, size_t len)\n{\n        char *sep;\n\n        \/* Get rid of the new line and return at the end *\/\n        len -= chomp (header, len);\n\n        sep = strchr (header, ':');\n        if (!sep)\n                return 0; \/* just skip invalid header, do not give error *\/\n\n        \/* Blank out colons, spaces, and tabs. *\/\n        while (*sep == ':' || *sep == ' ' || *sep == '\\t')\n                *sep++ = '\\0';\n\n        \/* Calculate the new length of just the data *\/\n        len -= sep - header - 1;\n\n        return orderedmap_append (hashofheaders, header, sep);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":226354,"func":"\nGF_Box *segr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(FDSessionGroupBox, GF_ISOM_BOX_TYPE_SEGR);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":225676,"func":"\nGF_Box *chnl_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ChannelLayoutBox, GF_ISOM_BOX_TYPE_CHNL);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":474431,"func":"ObjectFlush(\n\t    OBJECT          *object\n\t    )\n{\n    object->attributes.occupied = CLEAR;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":294593,"func":"strftimev(const char *fmt, VALUE self,\n\t  void (*func)(VALUE, struct tmx *))\n{\n    char buffer[SMALLBUF], *buf = buffer;\n    struct tmx tmx;\n    long len;\n    VALUE str;\n\n    (*func)(self, &tmx);\n    len = date_strftime_alloc(&buf, fmt, &tmx);\n    RB_GC_GUARD(self);\n    str = rb_usascii_str_new(buf, len);\n    if (buf != buffer) xfree(buf);\n    return str;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":442564,"func":"void memslot_info_reset(RedMemSlotInfo *info)\n{\n        uint32_t i;\n        for (i = 0; i < info->num_memslots_groups; ++i) {\n            memset(info->mem_slots[i], 0, sizeof(MemSlot) * info->num_memslots);\n        }\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":482520,"func":"free_macro(const Macro *macro) {\n\tif (macro) {\n\t\tfree((char *)macro->name);\n\t\tfree((char *)macro->definition);\n\t\tfree((int *)macro->substitutions);\n\t\tfree((Macro *)macro);\n\t}\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":274854,"func":"TEST(ComparisonsTest, NotEqualBroadcastString) {\n  if (SingleOpModel::GetForceUseNnapi()) {\n    return;\n  }\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 1}, TensorType_STRING,\n                          BuiltinOperator_NOT_EQUAL);\n  model.PopulateTensor<std::string>(model.input1(), {\"A\", \"B\", \"A\", \"B\"});\n  model.PopulateTensor<std::string>(model.input2(), {\"A\"});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, false, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":275924,"func":"unsigned uECC_curve_num_n_bits(uECC_Curve curve) {\n    return curve->num_n_bits;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":237886,"func":"lsquic_qeh_init (struct qpack_enc_hdl *qeh, struct lsquic_conn *conn)\n{\n    assert(!(qeh->qeh_flags & QEH_INITIALIZED));\n    qeh->qeh_conn = conn;\n    lsquic_frab_list_init(&qeh->qeh_fral, 0x400, NULL, NULL, NULL);\n    lsqpack_enc_preinit(&qeh->qeh_encoder, (void *) conn);\n    qeh->qeh_flags |= QEH_INITIALIZED;\n    qeh->qeh_max_prefix_size =\n                        lsqpack_enc_header_block_prefix_size(&qeh->qeh_encoder);\n    if (qeh->qeh_dec_sm_in)\n        lsquic_stream_wantread(qeh->qeh_dec_sm_in, 1);\n    LSQ_DEBUG(\"initialized\");\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":232321,"func":"GF_Err gf_isom_box_parse(GF_Box **outBox, GF_BitStream *bs)\n{\n\treturn gf_isom_box_parse_ex(outBox, bs, 0, GF_FALSE, 0);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":261196,"func":"    int wm_SemUnlock(wm_Sem *s){\n        dispatch_semaphore_signal(*s);\n        return 0;\n    }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":402629,"func":"encode_algorithm_id(cms_context *cms, SECItem *der, SECOidTag tag)\n{\n\tSECAlgorithmID id;\n\n\tint rc = generate_algorithm_id(cms, &id, tag);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tvoid *ret;\n\tret = SEC_ASN1EncodeItem(cms->arena, der, &id,\n\t\t\t\t\t\tSECOID_AlgorithmIDTemplate);\n\tif (ret == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode Algorithm ID\");\n\n\treturn 0;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":321741,"func":"static struct aspeed_lpc_ctrl *file_aspeed_lpc_ctrl(struct file *file)\n{\n\treturn container_of(file->private_data, struct aspeed_lpc_ctrl,\n\t\t\tmiscdev);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":432268,"func":"void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)\n{\n    int i;\n    hwaddr addr;\n\n    \/\/ Make sure all pages associated with the MemoryRegion are flushed\n    \/\/ Only need to do this if we are in a running state\n    if (uc->cpu) {\n        for (addr = mr->addr; addr < mr->end; addr += uc->target_page_size) {\n           tlb_flush_page(uc->cpu, addr);\n        }\n    }\n    memory_region_del_subregion(uc->system_memory, mr);\n\n    for (i = 0; i < uc->mapped_block_count; i++) {\n        if (uc->mapped_blocks[i] == mr) {\n            uc->mapped_block_count--;\n            \/\/shift remainder of array down over deleted pointer\n            memmove(&uc->mapped_blocks[i], &uc->mapped_blocks[i + 1], sizeof(MemoryRegion*) * (uc->mapped_block_count - i));\n            mr->destructor(mr);\n            g_free(mr);\n            break;\n        }\n    }\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":328938,"func":"R_API char *r_bin_java_get_name_from_cp_item_list(RList *cp_list, ut64 idx) {\n\t\/*\n\tGiven a constant pool object Class, FieldRef, MethodRef, or InterfaceMethodRef\n\treturn the actual descriptor string.\n\t@param cp_list: RList of RBinJavaCPTypeObj *\n\t@param obj object to look up the name for\n\t@rvalue ut8* (user frees) or NULL\n\t*\/\n\tRBinJavaCPTypeObj *obj = r_bin_java_get_item_from_cp_item_list (\n\t\tcp_list, idx);\n\tif (obj && cp_list) {\n\t\treturn r_bin_java_get_item_name_from_cp_item_list (\n\t\t\tcp_list, obj, MAX_CPITEMS);\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":175701,"func":"  virtual bool ethernet_connecting() const {\n    return ethernet_ ? ethernet_->connecting() : false;\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":466183,"func":"static int em_sub(struct x86_emulate_ctxt *ctxt)\n{\n\temulate_2op_SrcV(ctxt, \"sub\");\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":498096,"func":"void cgit_log_link(const char *name, const char *title, const char *class,\n\t\t   const char *head, const char *rev, const char *path,\n\t\t   int ofs, const char *grep, const char *pattern, int showmsg,\n\t\t   int follow)\n{\n\tchar *delim;\n\n\tdelim = repolink(title, class, \"log\", head, path);\n\tif (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {\n\t\thtml(delim);\n\t\thtml(\"id=\");\n\t\thtml_url_arg(rev);\n\t\tdelim = \"&\";\n\t}\n\tif (grep && pattern) {\n\t\thtml(delim);\n\t\thtml(\"qt=\");\n\t\thtml_url_arg(grep);\n\t\tdelim = \"&\";\n\t\thtml(delim);\n\t\thtml(\"q=\");\n\t\thtml_url_arg(pattern);\n\t}\n\tif (ofs > 0) {\n\t\thtml(delim);\n\t\thtml(\"ofs=\");\n\t\thtmlf(\"%d\", ofs);\n\t\tdelim = \"&\";\n\t}\n\tif (showmsg) {\n\t\thtml(delim);\n\t\thtml(\"showmsg=1\");\n\t\tdelim = \"&\";\n\t}\n\tif (follow) {\n\t\thtml(delim);\n\t\thtml(\"follow=1\");\n\t}\n\thtml(\"'>\");\n\thtml_txt(name);\n\thtml(\"<\/a>\");\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":229151,"func":"size_t virtio_serial_guest_ready(VirtIOSerialPort *port)\n{\n    VirtIODevice *vdev = VIRTIO_DEVICE(port->vser);\n    VirtQueue *vq = port->ivq;\n    unsigned int bytes;\n\n    if (!virtio_queue_ready(vq) ||\n        !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) ||\n        virtio_queue_empty(vq)) {\n        return 0;\n    }\n    if (use_multiport(port->vser) && !port->guest_connected) {\n        return 0;\n    }\n    virtqueue_get_avail_bytes(vq, &bytes, NULL, 4096, 0);\n    return bytes;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":384773,"func":"validate_virtcol_win(win_T *wp)\n{\n    check_cursor_moved(wp);\n    if (!(wp->w_valid & VALID_VIRTCOL))\n    {\n\tgetvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL);\n\twp->w_valid |= VALID_VIRTCOL;\n#ifdef FEAT_SYN_HL\n\tif (wp->w_p_cuc && !pum_visible())\n\t    redraw_win_later(wp, SOME_VALID);\n#endif\n    }\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":436117,"func":"\nstatic void io_async_task_func(struct io_kiocb *req)\n{\n\tstruct async_poll *apoll = req->apoll;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\n\ttrace_io_uring_task_run(req->ctx, req, req->opcode, req->user_data);\n\n\tif (io_poll_rewait(req, &apoll->poll)) {\n\t\tspin_unlock_irq(&ctx->completion_lock);\n\t\treturn;\n\t}\n\n\thash_del(&req->hash_node);\n\tio_poll_remove_double(req);\n\tspin_unlock_irq(&ctx->completion_lock);\n\n\tif (!READ_ONCE(apoll->poll.canceled))\n\t\tio_req_task_submit(req);\n\telse\n\t\tio_req_complete_failed(req, -ECANCELED);","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":328925,"func":"R_API RBinJavaInterfaceInfo *r_bin_java_interface_new(RBinJavaObj *bin, const ut8 *buffer, ut64 sz) {\n\tIFDBG eprintf (\"Parsing RBinJavaInterfaceInfo\\n\");\n\tRBinJavaInterfaceInfo *ifobj = R_NEW0 (RBinJavaInterfaceInfo);\n\tif (ifobj) {\n\t\tif (buffer) {\n\t\t\tifobj->class_info_idx = R_BIN_JAVA_USHORT (buffer, 0);\n\t\t\tifobj->cp_class = r_bin_java_get_item_from_bin_cp_list (bin, ifobj->class_info_idx);\n\t\t\tif (ifobj->cp_class) {\n\t\t\t\tifobj->name = r_bin_java_get_item_name_from_bin_cp_list (bin, ifobj->cp_class);\n\t\t\t} else {\n\t\t\t\tifobj->name = r_str_dup (NULL, \"NULL\");\n\t\t\t}\n\t\t\tifobj->size = 2;\n\t\t} else {\n\t\t\tifobj->class_info_idx = 0;\n\t\t\tifobj->name = r_str_dup (NULL, \"NULL\");\n\t\t}\n\t}\n\treturn ifobj;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":366290,"func":"static void set_mount_attributes(struct mount *mnt, unsigned int mnt_flags)\n{\n\tmnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK;\n\tmnt->mnt.mnt_flags = mnt_flags;\n\ttouch_mnt_namespace(mnt->mnt_ns);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":415220,"func":"cmd_readcert (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  unsigned char *cert;\n  size_t ncert;\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  line = xstrdup (line); \/* Need a copy of the line. *\/\n  rc = app_readcert (ctrl->app_ctx, line, &cert, &ncert);\n  if (rc)\n    log_error (\"app_readcert failed: %s\\n\", gpg_strerror (rc));\n  xfree (line);\n  line = NULL;\n  if (!rc)\n    {\n      rc = assuan_send_data (ctx, cert, ncert);\n      xfree (cert);\n      if (rc)\n        return rc;\n    }\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":226331,"func":"\nGF_Err lsr1_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox*)s;\n\n\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);\n\tif (e) return e;\n\n\tISOM_DECREASE_SIZE(ptr, 8);\n\n\treturn gf_isom_box_array_read(s, bs);","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":312458,"func":"qf_parse_fmt_m(regmatch_T *rmp, int midx, qffields_T *fields)\n{\n    char_u\t*p;\n    int\t\tlen;\n\n    if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL)\n\treturn QF_FAIL;\n    len = (int)(rmp->endp[midx] - rmp->startp[midx]);\n    if (len >= fields->errmsglen)\n    {\n\t\/\/ len + null terminator\n\tif ((p = vim_realloc(fields->errmsg, len + 1)) == NULL)\n\t    return QF_NOMEM;\n\tfields->errmsg = p;\n\tfields->errmsglen = len + 1;\n    }\n    vim_strncpy(fields->errmsg, rmp->startp[midx], len);\n    return QF_OK;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":253711,"func":"static void ccp_update_sg_workarea(struct ccp_sg_workarea *wa, unsigned int len)\n{\n\tunsigned int nbytes = min_t(u64, len, wa->bytes_left);\n\tunsigned int sg_combined_len = 0;\n\n\tif (!wa->sg)\n\t\treturn;\n\n\twa->sg_used += nbytes;\n\twa->bytes_left -= nbytes;\n\tif (wa->sg_used == sg_dma_len(wa->dma_sg)) {\n\t\t\/* Advance to the next DMA scatterlist entry *\/\n\t\twa->dma_sg = sg_next(wa->dma_sg);\n\n\t\t\/* In the case that the DMA mapped scatterlist has entries\n\t\t * that have been merged, the non-DMA mapped scatterlist\n\t\t * must be advanced multiple times for each merged entry.\n\t\t * This ensures that the current non-DMA mapped entry\n\t\t * corresponds to the current DMA mapped entry.\n\t\t *\/\n\t\tdo {\n\t\t\tsg_combined_len += wa->sg->length;\n\t\t\twa->sg = sg_next(wa->sg);\n\t\t} while (wa->sg_used > sg_combined_len);\n\n\t\twa->sg_used = 0;\n\t}\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":462236,"func":"static void* clone_binary_attr(pj_pool_t *pool, const void *src)\n{\n    const pj_stun_binary_attr *asrc = (const pj_stun_binary_attr*)src;\n    pj_stun_binary_attr *dst = PJ_POOL_ALLOC_T(pool, pj_stun_binary_attr);\n\n    pj_memcpy(dst, src, sizeof(pj_stun_binary_attr));\n\n    if (asrc->length) {\n\tdst->data = (pj_uint8_t*) pj_pool_alloc(pool, asrc->length);\n\tpj_memcpy(dst->data, asrc->data, asrc->length);\n    }\n\n    return (void*)dst;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":384918,"func":"skipwhite(char_u *q)\n{\n    char_u\t*p = q;\n\n    while (VIM_ISWHITE(*p))\n\t++p;\n    return p;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512418,"func":"bool Item_cond::excl_dep_on_table(table_map tab_map)\n{\n  if (used_tables() & OUTER_REF_TABLE_BIT)\n    return false;\n  if (!(used_tables() & ~tab_map))\n    return true;\n  List_iterator_fast<Item> li(list);\n  Item *item;\n  while ((item= li++))\n  {\n    if (!item->excl_dep_on_table(tab_map))\n      return false;\n  }\n  return true;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":508301,"func":"bool get_key_map_from_key_list(key_map *map, TABLE *table,\n                               List<String> *index_list)\n{\n  List_iterator_fast<String> it(*index_list);\n  String *name;\n  uint pos;\n\n  map->clear_all();\n  while ((name=it++))\n  {\n    if (table->s->keynames.type_names == 0 ||\n        (pos= find_type(&table->s->keynames, name->ptr(),\n                        name->length(), 1)) <=\n        0)\n    {\n      my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), name->c_ptr(),\n\t       table->pos_in_table_list->alias);\n      map->set_all();\n      return 1;\n    }\n    map->set_bit(pos-1);\n  }\n  return 0;\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":436047,"func":"\nstatic bool io_register_op_must_quiesce(int op)\n{\n\tswitch (op) {\n\tcase IORING_REGISTER_BUFFERS:\n\tcase IORING_UNREGISTER_BUFFERS:\n\tcase IORING_REGISTER_FILES:\n\tcase IORING_UNREGISTER_FILES:\n\tcase IORING_REGISTER_FILES_UPDATE:\n\tcase IORING_REGISTER_PROBE:\n\tcase IORING_REGISTER_PERSONALITY:\n\tcase IORING_UNREGISTER_PERSONALITY:\n\tcase IORING_REGISTER_FILES2:\n\tcase IORING_REGISTER_FILES_UPDATE2:\n\tcase IORING_REGISTER_BUFFERS2:\n\tcase IORING_REGISTER_BUFFERS_UPDATE:\n\tcase IORING_REGISTER_IOWQ_AFF:\n\tcase IORING_UNREGISTER_IOWQ_AFF:\n\t\treturn false;\n\tdefault:\n\t\treturn true;\n\t}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":338232,"func":"bool WasmBinaryBuilder::maybeVisitI31New(Expression*& out, uint32_t code) {\n  if (code != BinaryConsts::I31New) {\n    return false;\n  }\n  auto* curr = allocator.alloc<I31New>();\n  curr->value = popNonVoidExpression();\n  curr->finalize();\n  out = curr;\n  return true;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":234240,"func":"add_dwo_name (const char * name, dwarf_vma cu_offset)\n{\n  add_dwo_info (name, cu_offset, DWO_NAME);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":282978,"func":"LJ_NOINLINE static void unwindstack(lua_State *L, TValue *top)\n{\n  lj_func_closeuv(L, top);\n  if (top < L->top-1) {\n    copyTV(L, top, L->top-1);\n    L->top = top+1;\n  }\n  lj_state_relimitstack(L);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":459514,"func":"static __u64 count_kernel_ip(struct perf_callchain_entry *trace)\n{\n\t__u64 nr_kernel = 0;\n\n\twhile (nr_kernel < trace->nr) {\n\t\tif (trace->ip[nr_kernel] == PERF_CONTEXT_USER)\n\t\t\tbreak;\n\t\tnr_kernel++;\n\t}\n\treturn nr_kernel;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":317249,"func":"static int selinux_inet_sys_rcv_skb(struct net *ns, int ifindex,\n\t\t\t\t    char *addrp, u16 family, u32 peer_sid,\n\t\t\t\t    struct common_audit_data *ad)\n{\n\tint err;\n\tu32 if_sid;\n\tu32 node_sid;\n\n\terr = sel_netif_sid(ns, ifindex, &if_sid);\n\tif (err)\n\t\treturn err;\n\terr = avc_has_perm(&selinux_state,\n\t\t\t   peer_sid, if_sid,\n\t\t\t   SECCLASS_NETIF, NETIF__INGRESS, ad);\n\tif (err)\n\t\treturn err;\n\n\terr = sel_netnode_sid(addrp, family, &node_sid);\n\tif (err)\n\t\treturn err;\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    peer_sid, node_sid,\n\t\t\t    SECCLASS_NODE, NODE__RECVFROM, ad);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":294688,"func":"df_to_time(int df, int *h, int *min, int *s)\n{\n    *h = df \/ HOUR_IN_SECONDS;\n    df %= HOUR_IN_SECONDS;\n    *min = df \/ MINUTE_IN_SECONDS;\n    *s = df % MINUTE_IN_SECONDS;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":273071,"func":"log_fatal_null(int domain, const char *func, int line)\n{\n  DPRINTF(E_FATAL, domain, \"%s returned NULL at line %d\\n\", func, line);\n  abort();\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":450418,"func":"int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)\n{\n    vs->zrle->type = VNC_ENCODING_ZYWRLE;\n    return zrle_send_framebuffer_update(vs, x, y, w, h);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":314773,"func":"cdf_unpack_dir(cdf_directory_t *d, char *buf)\n{\n\tsize_t len = 0;\n\n\tCDF_UNPACKA(d->d_name);\n\tCDF_UNPACK(d->d_namelen);\n\tCDF_UNPACK(d->d_type);\n\tCDF_UNPACK(d->d_color);\n\tCDF_UNPACK(d->d_left_child);\n\tCDF_UNPACK(d->d_right_child);\n\tCDF_UNPACK(d->d_storage);\n\tCDF_UNPACKA(d->d_storage_uuid);\n\tCDF_UNPACK(d->d_flags);\n\tCDF_UNPACK(d->d_created);\n\tCDF_UNPACK(d->d_modified);\n\tCDF_UNPACK(d->d_stream_first_sector);\n\tCDF_UNPACK(d->d_size);\n\tCDF_UNPACK(d->d_unused0);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":509562,"func":"int ha_maria::index_last(uchar * buf)\n{\n  DBUG_ASSERT(inited == INDEX);\n  register_handler(file);\n  int error= maria_rlast(file, buf, active_index);\n  return error;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":242995,"func":"int mbedtls_ssl_check_timer( mbedtls_ssl_context *ssl )\n{\n    if( ssl->f_get_timer == NULL )\n        return( 0 );\n\n    if( ssl->f_get_timer( ssl->p_timer ) == 2 )\n    {\n        MBEDTLS_SSL_DEBUG_MSG( 3, ( \"timer expired\" ) );\n        return( -1 );\n    }\n\n    return( 0 );\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":459020,"func":"http_Unset(struct http *hp, hdr_t hdr)\n{\n\tuint16_t u, v;\n\n\tfor (v = u = HTTP_HDR_FIRST; u < hp->nhd; u++) {\n\t\tTcheck(hp->hd[u]);\n\t\tif (http_IsHdr(&hp->hd[u], hdr)) {\n\t\t\thttp_VSLH_del(hp, u);\n\t\t\tcontinue;\n\t\t}\n\t\tif (v != u) {\n\t\t\tmemcpy(&hp->hd[v], &hp->hd[u], sizeof *hp->hd);\n\t\t\tmemcpy(&hp->hdf[v], &hp->hdf[u], sizeof *hp->hdf);\n\t\t}\n\t\tv++;\n\t}\n\thp->nhd = v;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":348430,"func":"static void mkiss_write_wakeup(struct tty_struct *tty)\n{\n\tstruct mkiss *ax = mkiss_get(tty);\n\tint actual;\n\n\tif (!ax)\n\t\treturn;\n\n\tif (ax->xleft <= 0)  {\n\t\t\/* Now serial buffer is almost free & we can start\n\t\t * transmission of another packet\n\t\t *\/\n\t\tclear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);\n\n\t\tnetif_wake_queue(ax->dev);\n\t\tgoto out;\n\t}\n\n\tactual = tty->ops->write(tty, ax->xhead, ax->xleft);\n\tax->xleft -= actual;\n\tax->xhead += actual;\n\nout:\n\tmkiss_put(ax);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":210420,"func":"fill_threshhold_buffer(byte *dest_strip, byte *src_strip, int src_width,\n                       int left_offset, int left_width, int num_tiles,\n                       int right_width)\n{\n    byte *ptr_out_temp = dest_strip;\n    int ii;\n\n    \/* Left part *\/\n    memcpy(dest_strip, src_strip + left_offset, left_width);\n    ptr_out_temp += left_width;\n    \/* Now the full parts *\/\n    for (ii = 0; ii < num_tiles; ii++){\n        memcpy(ptr_out_temp, src_strip, src_width);\n        ptr_out_temp += src_width;\n    }\n    \/* Now the remainder *\/\n    memcpy(ptr_out_temp, src_strip, right_width);\n#ifdef PACIFY_VALGRIND\n    ptr_out_temp += right_width;\n    ii = (dest_strip-ptr_out_temp) % (LAND_BITS-1);\n    if (ii > 0)\n        memset(ptr_out_temp, 0, ii);\n#endif\n}","target":1,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":234871,"func":"void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_device *srcdev)\n{\n\tstruct btrfs_fs_devices *fs_devices;\n\n\tlockdep_assert_held(&srcdev->fs_info->fs_devices->device_list_mutex);\n\n\t\/*\n\t * in case of fs with no seed, srcdev->fs_devices will point\n\t * to fs_devices of fs_info. However when the dev being replaced is\n\t * a seed dev it will point to the seed's local fs_devices. In short\n\t * srcdev will have its correct fs_devices in both the cases.\n\t *\/\n\tfs_devices = srcdev->fs_devices;\n\n\tlist_del_rcu(&srcdev->dev_list);\n\tlist_del(&srcdev->dev_alloc_list);\n\tfs_devices->num_devices--;\n\tif (test_bit(BTRFS_DEV_STATE_MISSING, &srcdev->dev_state))\n\t\tfs_devices->missing_devices--;\n\n\tif (test_bit(BTRFS_DEV_STATE_WRITEABLE, &srcdev->dev_state))\n\t\tfs_devices->rw_devices--;\n\n\tif (srcdev->bdev)\n\t\tfs_devices->open_devices--;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":232342,"func":"Bool gf_isom_get_subsample_types(GF_ISOFile *movie, u32 track, u32 subs_index, u32 *flags)\n{\n\tGF_SubSampleInformationBox *sub_samples=NULL;\n\tGF_TrackBox *trak = gf_isom_get_track_from_file(movie, track);\n\n\tif (!track || !subs_index) return GF_FALSE;\n\tif (!trak->Media || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->sub_samples) return GF_FALSE;\n\tsub_samples = gf_list_get(trak->Media->information->sampleTable->sub_samples, subs_index-1);\n\tif (!sub_samples) return GF_FALSE;\n\t*flags = sub_samples->flags;\n\treturn GF_TRUE;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":430340,"func":"void seq_pad(struct seq_file *m, char c)\n{\n\tint size = m->pad_until - m->count;\n\tif (size > 0) {\n\t\tif (size + m->count > m->size) {\n\t\t\tseq_set_overflow(m);\n\t\t\treturn;\n\t\t}\n\t\tmemset(m->buf + m->count, ' ', size);\n\t\tm->count += size;\n\t}\n\tif (c)\n\t\tseq_putc(m, c);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":254068,"func":"        void clear()\n        {\n            key_value_pairs_.clear();\n            url_.clear();\n        }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":259177,"func":"static MOVFragmentStreamInfo * get_current_frag_stream_info(\n    MOVFragmentIndex *frag_index)\n{\n    MOVFragmentIndexItem *item;\n    if (frag_index->current < 0 ||\n        frag_index->current >= frag_index->nb_items)\n        return NULL;\n\n    item = &frag_index->item[frag_index->current];\n    if (item->current >= 0 && item->current < item->nb_stream_info)\n        return &item->stream_info[item->current];\n\n    \/\/ This shouldn't happen\n    return NULL;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":312441,"func":"make_get_fullcmd(char_u *makecmd, char_u *fname)\n{\n    char_u\t*cmd;\n    unsigned\tlen;\n\n    len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(makecmd) + 1;\n    if (*p_sp != NUL)\n\tlen += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;\n    cmd = alloc_id(len, aid_qf_makecmd);\n    if (cmd == NULL)\n\treturn NULL;\n    sprintf((char *)cmd, \"%s%s%s\", (char *)p_shq, (char *)makecmd,\n\t\t\t\t\t\t\t       (char *)p_shq);\n\n    \/\/ If 'shellpipe' empty: don't redirect to 'errorfile'.\n    if (*p_sp != NUL)\n\tappend_redir(cmd, len, p_sp, fname);\n\n    \/\/ Display the fully formed command.  Output a newline if there's something\n    \/\/ else than the :make command that was typed (in which case the cursor is\n    \/\/ in column 0).\n    if (msg_col == 0)\n\tmsg_didout = FALSE;\n    msg_start();\n    msg_puts(\":!\");\n    msg_outtrans(cmd);\t\t\/\/ show what we are doing\n\n    return cmd;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":252415,"func":"static void tdefl_start_static_block(tdefl_compressor *d) {\n  mz_uint i;\n  mz_uint8 *p = &d->m_huff_code_sizes[0][0];\n\n  for (i = 0; i <= 143; ++i) *p++ = 8;\n  for (; i <= 255; ++i) *p++ = 9;\n  for (; i <= 279; ++i) *p++ = 7;\n  for (; i <= 287; ++i) *p++ = 8;\n\n  memset(d->m_huff_code_sizes[1], 5, 32);\n\n  tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE);\n  tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE);\n\n  TDEFL_PUT_BITS(1, 2);\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":424524,"func":"static BOOL yuv_to_rgb(PresentationContext* presentation, BYTE* dest)\n{\n\tconst BYTE* pYUVPoint[3];\n\tH264_CONTEXT* h264 = presentation->h264;\n\n\tBYTE** ppYUVData;\n\tppYUVData = h264->pYUVData;\n\n\tpYUVPoint[0] = ppYUVData[0];\n\tpYUVPoint[1] = ppYUVData[1];\n\tpYUVPoint[2] = ppYUVData[2];\n\n\tif (!yuv_context_decode(presentation->yuv, pYUVPoint, h264->iStride, PIXEL_FORMAT_BGRX32, dest,\n\t                        h264->width * 4))\n\t{\n\t\tWLog_ERR(TAG, \"error in yuv_to_rgb conversion\");\n\t\treturn FALSE;\n\t}\n\n\treturn TRUE;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":243999,"func":"GF_Box *stri_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SubTrackInformationBox, GF_ISOM_BOX_TYPE_STRI);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":294614,"func":"div_day(VALUE d, VALUE *f)\n{\n    if (f)\n\t*f = f_mod(d, INT2FIX(1));\n    return f_floor(d);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":513043,"func":"Item *in_double::create_item(THD *thd)\n{ \n  return new (thd->mem_root) Item_float(thd, 0.0, 0);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":326911,"func":"static void vidtv_s302m_alloc_au(struct vidtv_encoder *e)\n{\n\tstruct vidtv_access_unit *sync_au = NULL;\n\tstruct vidtv_access_unit *temp = NULL;\n\n\tif (e->sync && e->sync->is_video_encoder) {\n\t\tsync_au = e->sync->access_units;\n\n\t\twhile (sync_au) {\n\t\t\ttemp = vidtv_s302m_access_unit_init(e->access_units);\n\t\t\tif (!e->access_units)\n\t\t\t\te->access_units = temp;\n\n\t\t\tsync_au = sync_au->next;\n\t\t}\n\n\t\treturn;\n\t}\n\n\te->access_units = vidtv_s302m_access_unit_init(NULL);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":513327,"func":"join_read_prev(READ_RECORD *info)\n{\n  int error;\n  if ((error= info->table->file->ha_index_prev(info->record)))\n    return report_error(info->table, error);\n  return 0;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":313567,"func":"static void rose_remove_neigh(struct rose_neigh *rose_neigh)\n{\n\tstruct rose_neigh *s;\n\n\tdel_timer_sync(&rose_neigh->ftimer);\n\tdel_timer_sync(&rose_neigh->t0timer);\n\n\tskb_queue_purge(&rose_neigh->queue);\n\n\tif ((s = rose_neigh_list) == rose_neigh) {\n\t\trose_neigh_list = rose_neigh->next;\n\t\tif (rose_neigh->ax25)\n\t\t\tax25_cb_put(rose_neigh->ax25);\n\t\tkfree(rose_neigh->digipeat);\n\t\tkfree(rose_neigh);\n\t\treturn;\n\t}\n\n\twhile (s != NULL && s->next != NULL) {\n\t\tif (s->next == rose_neigh) {\n\t\t\ts->next = rose_neigh->next;\n\t\t\tif (rose_neigh->ax25)\n\t\t\t\tax25_cb_put(rose_neigh->ax25);\n\t\t\tkfree(rose_neigh->digipeat);\n\t\t\tkfree(rose_neigh);\n\t\t\treturn;\n\t\t}\n\n\t\ts = s->next;\n\t}\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":229311,"func":"cql_server::connection::make_topology_change_event(const event::topology_change& event) const\n{\n    auto response = std::make_unique<cql_server::response>(-1, cql_binary_opcode::EVENT, tracing::trace_state_ptr());\n    response->write_string(\"TOPOLOGY_CHANGE\");\n    response->write_string(to_string(event.change));\n    response->write_inet(event.node);\n    return response;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":331761,"func":"QPaintEngineEx::QPaintEngineEx(QPaintEngineExPrivate &data)\n    : QPaintEngine(data, AllFeatures)\n{\n    extended = true;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":328919,"func":"R_API ut64 r_bin_java_annotation_calc_size(RBinJavaAnnotation *annotation) {\n\tut64 sz = 0;\n\tRListIter *iter, *iter_tmp;\n\tRBinJavaElementValuePair *evps = NULL;\n\tif (!annotation) {\n\t\t\/\/ TODO eprintf allocation fail\n\t\treturn sz;\n\t}\n\t\/\/ annotation->type_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\tsz += 2;\n\t\/\/ annotation->num_element_value_pairs = R_BIN_JAVA_USHORT (buffer, offset);\n\tsz += 2;\n\tr_list_foreach_safe (annotation->element_value_pairs, iter, iter_tmp, evps) {\n\t\tif (evps) {\n\t\t\tsz += r_bin_java_element_pair_calc_size (evps);\n\t\t}\n\t}\n\treturn sz;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":390528,"func":"ProcXkbGetGeometry(ClientPtr client)\n{\n    DeviceIntPtr \tdev;\n    xkbGetGeometryReply rep;\n    XkbGeometryPtr\tgeom;\n    Bool\t\tshouldFree;\n    Status\t\tstatus;\n\n    REQUEST(xkbGetGeometryReq);\n    REQUEST_SIZE_MATCH(xkbGetGeometryReq);\n\n    if (!(client->xkbClientFlags&_XkbClientInitialized))\n\treturn BadAccess;\n\n    CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);\n    CHK_ATOM_OR_NONE(stuff->name);\n\n    geom= XkbLookupNamedGeometry(dev,stuff->name,&shouldFree);\n    rep.type= X_Reply;\n    rep.deviceID= dev->id;\n    rep.sequenceNumber= client->sequence;\n    rep.length= 0;\n    status= XkbComputeGetGeometryReplySize(geom,&rep,stuff->name);\n    if (status!=Success)\n\t return status;\n    else return XkbSendGeometry(client,geom,&rep,shouldFree);\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":244195,"func":"GF_Box *saiz_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleAuxiliaryInfoSizeBox, GF_ISOM_BOX_TYPE_SAIZ);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":366231,"func":"int sb_prepare_remount_readonly(struct super_block *sb)\n{\n\tstruct mount *mnt;\n\tint err = 0;\n\n\t\/* Racy optimization.  Recheck the counter under MNT_WRITE_HOLD *\/\n\tif (atomic_long_read(&sb->s_remove_count))\n\t\treturn -EBUSY;\n\n\tlock_mount_hash();\n\tlist_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {\n\t\tif (!(mnt->mnt.mnt_flags & MNT_READONLY)) {\n\t\t\tmnt->mnt.mnt_flags |= MNT_WRITE_HOLD;\n\t\t\tsmp_mb();\n\t\t\tif (mnt_get_writers(mnt) > 0) {\n\t\t\t\terr = -EBUSY;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (!err && atomic_long_read(&sb->s_remove_count))\n\t\terr = -EBUSY;\n\n\tif (!err) {\n\t\tsb->s_readonly_remount = 1;\n\t\tsmp_wmb();\n\t}\n\tlist_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {\n\t\tif (mnt->mnt.mnt_flags & MNT_WRITE_HOLD)\n\t\t\tmnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;\n\t}\n\tunlock_mount_hash();\n\n\treturn err;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":238319,"func":"int digest_algo_register(struct digest_algo *d)\n{\n\tif (!d || !d->base.name || !d->update || !d->final || !d->verify)\n\t\treturn -EINVAL;\n\n\tif (!d->init)\n\t\td->init = dummy_init;\n\n\tif (!d->alloc)\n\t\td->alloc = dummy_init;\n\n\tif (!d->free)\n\t\td->free = dummy_free;\n\n\tlist_add_tail(&d->list, &digests);\n\n\treturn 0;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":402624,"func":"generate_time(cms_context *cms, SECItem *encoded, time_t when)\n{\n\tstatic char timebuf[32];\n\tSECItem whenitem = {.type = SEC_ASN1_UTC_TIME,\n\t\t\t .data = (unsigned char *)timebuf,\n\t\t\t .len = 0\n\t};\n\tstruct tm *tm;\n\n\ttm = gmtime(&when);\n\n\twhenitem.len = snprintf(timebuf, 32, \"%02d%02d%02d%02d%02d%02dZ\",\n\t\ttm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,\n\t\ttm->tm_hour, tm->tm_min, tm->tm_sec);\n\tif (whenitem.len == 32)\n\t\tcmsreterr(-1, cms, \"could not encode timestamp\");\n\n\tif (SEC_ASN1EncodeItem(cms->arena, encoded, &whenitem,\n\t\t\tSEC_UTCTimeTemplate) == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode timestamp\");\n\treturn 0;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":508787,"func":"void st_select_lex::alloc_index_hints (THD *thd)\n{ \n  index_hints= new (thd->mem_root) List<Index_hint>(); \n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":384880,"func":"skipbin(char_u *q)\n{\n    char_u\t*p = q;\n\n    while (vim_isbdigit(*p))\t\/\/ skip to next non-digit\n\t++p;\n    return p;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":366302,"func":"void put_mnt_ns(struct mnt_namespace *ns)\n{\n\tif (!refcount_dec_and_test(&ns->ns.count))\n\t\treturn;\n\tdrop_collected_mounts(&ns->root->mnt);\n\tfree_mnt_ns(ns);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":220852,"func":"inline int32_t MultiplyByQuantizedMultiplierSmallerThanOneExp(\n    int32_t x, int32_t quantized_multiplier, int left_shift) {\n  using gemmlowp::RoundingDivideByPOT;\n  using gemmlowp::SaturatingRoundingDoublingHighMul;\n  return RoundingDivideByPOT(\n      SaturatingRoundingDoublingHighMul(x, quantized_multiplier), -left_shift);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":212822,"func":"pcl_status_read(byte * data, uint max_data, pcl_state_t * pcs)\n{\n    uint count = min(max_data,\n                     pcs->status.write_pos - pcs->status.read_pos);\n\n    if (count)\n        memcpy(data, pcs->status.buffer + pcs->status.read_pos, count);\n    pcs->status.read_pos += count;\n    if (pcs->status.read_pos == pcs->status.write_pos) {\n        gs_free_object(pcs->memory, pcs->status.buffer, \"status buffer\");\n        pcs->status.write_pos = pcs->status.read_pos = 0;\n    }\n    return count;\n}","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":386524,"func":"void DL_Dxf::writeImageDef(DL_WriterA& dw,\n                           int handle,\n                           const DL_ImageData& data) {\n\n    \/*if (data.file.empty()) {\n        std::cerr << \"DL_Dxf::writeImage: \"\n        << \"Image file must not be empty\\n\";\n        return;\n}*\/\n\n    dw.dxfString(0, \"IMAGEDEF\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfHex(5, handle);\n    }\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbRasterImageDef\");\n        dw.dxfInt(90, 0);\n    }\n    \/\/ file name:\n    dw.dxfString(1, data.ref);\n\n    \/\/ image size in pixel\n    dw.dxfReal(10, data.width);\n    dw.dxfReal(20, data.height);\n\n    dw.dxfReal(11, 1.0);\n    dw.dxfReal(21, 1.0);\n\n    \/\/ loaded:\n    dw.dxfInt(280, 1);\n    \/\/ units:\n    dw.dxfInt(281, 0);\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":274684,"func":"callbacks_reduce_object_area_clicked  (GtkButton *button, gpointer user_data){\n\t\/* for testing, just hard code in some parameters *\/\n\tgerbv_image_reduce_area_of_selected_objects (screen.selectionInfo.selectedNodeArray, 0.20, 3, 3, 0.01);\n\tselection_clear (&screen.selectionInfo);\n\tupdate_selected_object_message (FALSE);\n\trender_refresh_rendered_image_on_screen ();\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":512588,"func":"  void copy_with_sum_func(const Item *item)\n  {\n    m_with_sum_func= item->with_sum_func();\n  }","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":265434,"func":"void sqfs_close(void)\n{\n\tsqfs_decompressor_cleanup(&ctxt);\n\tfree(ctxt.sblk);\n\tctxt.sblk = NULL;\n\tctxt.cur_dev = NULL;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":229308,"func":"client_data cql_server::connection::make_client_data() const {\n    client_data cd;\n    std::tie(cd.ip, cd.port, cd.ct) = make_client_key(_client_state);\n    cd.shard_id = this_shard_id();\n    cd.protocol_version = _version;\n    cd.driver_name = _client_state.get_driver_name();\n    cd.driver_version = _client_state.get_driver_version();\n    if (const auto user_ptr = _client_state.user(); user_ptr) {\n        cd.username = user_ptr->name;\n    }\n    if (_ready) {\n        cd.connection_stage = client_connection_stage::ready;\n    } else if (_authenticating) {\n        cd.connection_stage = client_connection_stage::authenticating;\n    }\n    return cd;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":90832,"func":"QuotaManagerProxy::~QuotaManagerProxy() {\n}\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":352989,"func":"xutcTimeNormalize(\n\tSyntax *syntax,\n\tstruct berval *val,\n\tstruct berval *normalized )\n{\n\tint parts[9], rc;\n\n\trc = check_time_syntax(val, 1, parts, NULL);\n\tif (rc != LDAP_SUCCESS) {\n\t\treturn rc;\n\t}\n\n\tnormalized->bv_val = ch_malloc( 14 );\n\tif ( normalized->bv_val == NULL ) {\n\t\treturn LBER_ERROR_MEMORY;\n\t}\n\n\tsprintf( normalized->bv_val, \"%02d%02d%02d%02d%02d%02dZ\",\n\t\tparts[1], parts[2] + 1, parts[3] + 1,\n\t\tparts[4], parts[5], parts[6] );\n\tnormalized->bv_len = 13;\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":317039,"func":"static void smack_sock_graft(struct sock *sk, struct socket *parent)\n{\n\tstruct socket_smack *ssp;\n\tstruct smack_known *skp = smk_of_current();\n\n\tif (sk == NULL ||\n\t    (sk->sk_family != PF_INET && sk->sk_family != PF_INET6))\n\t\treturn;\n\n\tssp = sk->sk_security;\n\tssp->smk_in = skp;\n\tssp->smk_out = skp;\n\t\/* cssp->smk_packet is already set in smack_inet_csk_clone() *\/\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":234748,"func":"static struct btrfs_fs_devices *find_fsid_reverted_metadata(\n\t\t\t\tstruct btrfs_super_block *disk_super)\n{\n\tstruct btrfs_fs_devices *fs_devices;\n\n\t\/*\n\t * Handle the case where the scanned device is part of an fs whose last\n\t * metadata UUID change reverted it to the original FSID. At the same\n\t * time * fs_devices was first created by another constitutent device\n\t * which didn't fully observe the operation. This results in an\n\t * btrfs_fs_devices created with metadata\/fsid different AND\n\t * btrfs_fs_devices::fsid_change set AND the metadata_uuid of the\n\t * fs_devices equal to the FSID of the disk.\n\t *\/\n\tlist_for_each_entry(fs_devices, &fs_uuids, fs_list) {\n\t\tif (memcmp(fs_devices->fsid, fs_devices->metadata_uuid,\n\t\t\t   BTRFS_FSID_SIZE) != 0 &&\n\t\t    memcmp(fs_devices->metadata_uuid, disk_super->fsid,\n\t\t\t   BTRFS_FSID_SIZE) == 0 &&\n\t\t    fs_devices->fsid_change)\n\t\t\treturn fs_devices;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":225722,"func":"void hmhd_box_del(GF_Box *s)\n{\n\tGF_HintMediaHeaderBox *ptr = (GF_HintMediaHeaderBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":359520,"func":"DEFUN (show_ip_bgp_vpnv4_all_summary,\n       show_ip_bgp_vpnv4_all_summary_cmd,\n       \"show ip bgp vpnv4 all summary\",\n       SHOW_STR\n       IP_STR\n       BGP_STR\n       \"Display VPNv4 NLRI specific information\\n\"\n       \"Display information about all VPNv4 NLRIs\\n\"\n       \"Summary of BGP neighbor status\\n\")\n{\n  return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":462414,"func":"\tfor(inst = pModConf->root ; inst != NULL ; ) {\n\t\tfree(inst->pszBindPort);\n\t\tfree(inst->pszBindPath);\n\t\tfree(inst->pszBindAddr);\n\t\tfree(inst->pszBindRuleset);\n\t\tfree(inst->pszInputName);\n\t\tfree(inst->dfltTZ);\n\t\tdel = inst;\n\t\tinst = inst->next;\n\t\tfree(del);\n\t}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":226090,"func":"GF_Err cslg_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_CompositionToDecodeBox *ptr = (GF_CompositionToDecodeBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_int(bs, ptr->compositionToDTSShift, 32);\n\tgf_bs_write_int(bs, ptr->leastDecodeToDisplayDelta, 32);\n\tgf_bs_write_int(bs, ptr->greatestDecodeToDisplayDelta, 32);\n\tgf_bs_write_int(bs, ptr->compositionStartTime, 32);\n\tgf_bs_write_int(bs, ptr->compositionEndTime, 32);\n\treturn GF_OK;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":346448,"func":"estack_push_ufunc(ufunc_T *ufunc, long lnum)\n{\n    estack_T *entry = estack_push(ETYPE_UFUNC,\n\t    ufunc->uf_name_exp != NULL\n\t\t\t\t  ? ufunc->uf_name_exp : ufunc->uf_name, lnum);\n    if (entry != NULL)\n\tentry->es_info.ufunc = ufunc;\n    return entry;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":512602,"func":"  virtual uint32 max_display_length() const\n  {\n    return type_handler()->max_display_length(this);\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":455325,"func":"bash_kill_shellword (count, key)\n     int count, key;\n{\n  int p;\n\n  if (count < 0)\n    return (bash_backward_kill_shellword (-count, key));\n\n  p = rl_point;\n  bash_forward_shellword (count, key);\n\n  if (rl_point != p)\n    rl_kill_text (p, rl_point);\n\n  rl_point = p;\n  if (rl_editing_mode == EMACS_EDITING_MODE)\t\/* 1 == emacs_mode *\/\n    rl_mark = rl_point;\n\n  return 0;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":267948,"func":"R_IPI void r_bin_class_free(RBinClass *k) {\n\tif (k) {\n\t\tfree (k->name);\n\t\tfree (k->super);\n\t\tfree (k->visibility_str);\n\t\tr_list_free (k->methods);\n\t\tr_list_free (k->fields);\n\t\tfree (k);\n\t}\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":90138,"func":"  virtual void ForgetWifiNetwork(const std::string& service_path) {\n    if (!EnsureCrosLoaded())\n      return;\n    if (DeleteRememberedService(service_path.c_str())) {\n      for (WifiNetworkVector::iterator iter =\n               remembered_wifi_networks_.begin();\n          iter != remembered_wifi_networks_.end();\n          ++iter) {\n        if ((*iter)->service_path() == service_path) {\n          delete (*iter);\n          remembered_wifi_networks_.erase(iter);\n          break;\n        }\n      }\n      NotifyNetworkManagerChanged();\n    }\n  }\n","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":281081,"func":"void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)\n{\n\twhile ((dst = dst->child) && dst->xfrm && dst->dev == dev) {\n\t\tdst->dev = dev_net(dev)->loopback_dev;\n\t\tdev_hold(dst->dev);\n\t\tdev_put(dev);\n\t}\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":386495,"func":"void DL_Dxf::writeLeader(DL_WriterA& dw,\n                         const DL_LeaderData& data,\n                         const DL_Attributes& attrib) {\n    if (version>DL_VERSION_R12) {\n        dw.entity(\"LEADER\");\n        if (version==DL_VERSION_2000) {\n            dw.dxfString(100, \"AcDbEntity\");\n        }\n        dw.entityAttributes(attrib);\n        if (version==DL_VERSION_2000) {\n            dw.dxfString(100, \"AcDbLeader\");\n        }\n        dw.dxfString(3, \"Standard\");\n        dw.dxfInt(71, data.arrowHeadFlag);\n        dw.dxfInt(72, data.leaderPathType);\n        dw.dxfInt(73, data.leaderCreationFlag);\n        dw.dxfInt(74, data.hooklineDirectionFlag);\n        dw.dxfInt(75, data.hooklineFlag);\n        dw.dxfReal(40, data.textAnnotationHeight);\n        dw.dxfReal(41, data.textAnnotationWidth);\n        dw.dxfInt(76, data.number);\n    }\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":261417,"func":"static int decode_pred_mode_flag(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# pred_mode_flag\\n\");\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &tctx->ctx_model[CONTEXT_MODEL_PRED_MODE_FLAG]);\n\n  logtrace(LogSymbols,\"$1 pred_mode=%d\\n\",bit);\n  return bit;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":466129,"func":"static int em_jcxz(struct x86_emulate_ctxt *ctxt)\n{\n\tif (address_mask(ctxt, ctxt->regs[VCPU_REGS_RCX]) == 0)\n\t\tjmp_rel(ctxt, ctxt->src.val);\n\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":294468,"func":"dup_obj(VALUE self)\n{\n    get_d1a(self);\n\n    if (simple_dat_p(adat)) {\n\tVALUE new = d_lite_s_alloc_simple(rb_obj_class(self));\n\t{\n\t    get_d1b(new);\n\t    bdat->s = adat->s;\n\t    RB_OBJ_WRITTEN(new, Qundef, bdat->s.nth);\n\t    return new;\n\t}\n    }\n    else {\n\tVALUE new = d_lite_s_alloc_complex(rb_obj_class(self));\n\t{\n\t    get_d1b(new);\n\t    bdat->c = adat->c;\n\t    RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);\n\t    RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);\n\t    return new;\n\t}\n    }\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":512577,"func":"Item *Item_func_nop_all::neg_transformer(THD *thd)\n{\n  \/* \"NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$\" ALL (SELECT ...) *\/\n  Item_func_not_all *new_item= new (thd->mem_root) Item_func_not_all(thd, args[0]);\n  Item_allany_subselect *allany= (Item_allany_subselect*)args[0];\n  allany->create_comp_func(FALSE);\n  allany->all= !allany->all;\n  allany->upper_item= new_item;\n  return new_item;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":230300,"func":"njs_array_handler_for_each(njs_vm_t *vm, njs_iterator_args_t *args,\n    njs_value_t *entry, int64_t n)\n{\n    if (njs_is_valid(entry)) {\n        return njs_array_iterator_call(vm, args, entry, n);\n    }\n\n    return NJS_OK;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":336692,"func":"SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *reds, int port)\n{\n    if (port < 0 || port > 0xffff) {\n        return -1;\n    }\n    reds->config->spice_port = port;\n    return 0;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":337802,"func":"struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,\n\t\t\t\t\tconst struct sctp_chunk *chunk)\n{\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_control(asoc, SCTP_CID_COOKIE_ACK, 0, 0, GFP_ATOMIC);\n\n\t\/* RFC 2960 6.4 Multi-homed SCTP Endpoints\n\t *\n\t * An endpoint SHOULD transmit reply chunks (e.g., SACK,\n\t * HEARTBEAT ACK, * etc.) to the same destination transport\n\t * address from which it * received the DATA or control chunk\n\t * to which it is replying.\n\t *\n\t * [COOKIE ACK back to where the COOKIE ECHO came from.]\n\t *\/\n\tif (retval && chunk && chunk->transport)\n\t\tretval->transport =\n\t\t\tsctp_assoc_lookup_paddr(asoc,\n\t\t\t\t\t\t&chunk->transport->ipaddr);\n\n\treturn retval;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":225970,"func":"\nGF_Err strk_box_size(GF_Box *s)\n{\n\treturn GF_OK;","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":317168,"func":"static int selinux_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)\n{\n\treturn security_sid_to_context(&selinux_state, secid,\n\t\t\t\t       secdata, seclen);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":450321,"func":"static void press_key(VncState *vs, QKeyCode qcode)\n{\n    qkbd_state_key_event(vs->vd->kbd, qcode, true);\n    qkbd_state_key_event(vs->vd->kbd, qcode, false);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":238455,"func":"static bool may_update_sockmap(struct bpf_verifier_env *env, int func_id)\n{\n\tenum bpf_attach_type eatype = env->prog->expected_attach_type;\n\tenum bpf_prog_type type = resolve_prog_type(env->prog);\n\n\tif (func_id != BPF_FUNC_map_update_elem)\n\t\treturn false;\n\n\t\/* It's not possible to get access to a locked struct sock in these\n\t * contexts, so updating is safe.\n\t *\/\n\tswitch (type) {\n\tcase BPF_PROG_TYPE_TRACING:\n\t\tif (eatype == BPF_TRACE_ITER)\n\t\t\treturn true;\n\t\tbreak;\n\tcase BPF_PROG_TYPE_SOCKET_FILTER:\n\tcase BPF_PROG_TYPE_SCHED_CLS:\n\tcase BPF_PROG_TYPE_SCHED_ACT:\n\tcase BPF_PROG_TYPE_XDP:\n\tcase BPF_PROG_TYPE_SK_REUSEPORT:\n\tcase BPF_PROG_TYPE_FLOW_DISSECTOR:\n\tcase BPF_PROG_TYPE_SK_LOOKUP:\n\t\treturn true;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tverbose(env, \"cannot update sockmap in this context\\n\");\n\treturn false;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":484787,"func":"static int xennet_set_skb_gso(struct sk_buff *skb,\n\t\t\t      struct xen_netif_extra_info *gso)\n{\n\tif (!gso->u.gso.size) {\n\t\tif (net_ratelimit())\n\t\t\tpr_warn(\"GSO size must not be zero\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4 &&\n\t    gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV6) {\n\t\tif (net_ratelimit())\n\t\t\tpr_warn(\"Bad GSO type %d\\n\", gso->u.gso.type);\n\t\treturn -EINVAL;\n\t}\n\n\tskb_shinfo(skb)->gso_size = gso->u.gso.size;\n\tskb_shinfo(skb)->gso_type =\n\t\t(gso->u.gso.type == XEN_NETIF_GSO_TYPE_TCPV4) ?\n\t\tSKB_GSO_TCPV4 :\n\t\tSKB_GSO_TCPV6;\n\n\t\/* Header must be checked, and gso_segs computed. *\/\n\tskb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;\n\tskb_shinfo(skb)->gso_segs = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":255774,"func":"deinit_authz(void *data)\n{\n  \/* The two object pools run their own cleanup handlers. *\/\n  authz_pool = NULL;\n  filtered_pool = NULL;\n  authz_pool_initialized = FALSE;\n  return APR_SUCCESS;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":247101,"func":"void gf_fs_set_ui_callback(GF_FilterSession *fs, Bool (*ui_event_proc)(void *opaque, GF_Event *event), void *cbk_udta)\n{\n\tif (fs) {\n\t\tfs->ui_event_proc = ui_event_proc;\n\t\tfs->ui_opaque = cbk_udta;\n\t\tif (!fs->ui_event_proc) {\n\t\t\tfs->ui_event_proc = fs_default_event_proc;\n\t\t\tfs->ui_opaque = fs;\n\t\t}\n\t}\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":444894,"func":"drop_capabilities(int parent)\n{\n\treturn 0;\n}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":409452,"func":"term_cursor_right(int i)\n{\n    OUT_STR(tgoto((char *)T_CRI, 0, i));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":369348,"func":"\nstatic bool io_cancel_task_cb(struct io_wq_work *work, void *data)\n{\n\tstruct io_kiocb *req = container_of(work, struct io_kiocb, work);\n\tstruct io_task_cancel *cancel = data;\n\n\treturn io_match_task_safe(req, cancel->task, cancel->all);","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":343148,"func":"static struct ip_esp_hdr *esp_output_set_esn(struct sk_buff *skb,\n\t\t\t\t\t     struct xfrm_state *x,\n\t\t\t\t\t     struct ip_esp_hdr *esph,\n\t\t\t\t\t     struct esp_output_extra *extra)\n{\n\t\/* For ESN we move the header forward by 4 bytes to\n\t * accomodate the high bits.  We will move it back after\n\t * encryption.\n\t *\/\n\tif ((x->props.flags & XFRM_STATE_ESN)) {\n\t\t__u32 seqhi;\n\t\tstruct xfrm_offload *xo = xfrm_offload(skb);\n\n\t\tif (xo)\n\t\t\tseqhi = xo->seq.hi;\n\t\telse\n\t\t\tseqhi = XFRM_SKB_CB(skb)->seq.output.hi;\n\n\t\textra->esphoff = (unsigned char *)esph -\n\t\t\t\t skb_transport_header(skb);\n\t\tesph = (struct ip_esp_hdr *)((unsigned char *)esph - 4);\n\t\textra->seqhi = esph->spi;\n\t\tesph->seq_no = htonl(seqhi);\n\t}\n\n\tesph->spi = x->id.spi;\n\n\treturn esph;\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":259160,"func":"static void mov_update_dts_shift(MOVStreamContext *sc, int duration, void *logctx)\n{\n    if (duration < 0) {\n        if (duration == INT_MIN) {\n            av_log(logctx, AV_LOG_WARNING, \"mov_update_dts_shift(): dts_shift set to %d\\n\", INT_MAX);\n            duration++;\n        }\n        sc->dts_shift = FFMAX(sc->dts_shift, -duration);\n    }\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":247746,"func":"TEST_P(SslSocketTest, TicketSessionResumptionWithClientCA) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n  session_ticket_keys:\n    keys:\n      filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ticket_key_a\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/no_san_key.pem\"\n)EOF\";\n\n  testTicketSessionResumption(server_ctx_yaml, {}, server_ctx_yaml, {}, client_ctx_yaml, true,\n                              GetParam());\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":226323,"func":"\nGF_Box *rvcc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_RVCConfigurationBox, GF_ISOM_BOX_TYPE_RVCC);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":506689,"func":"static int set_cn_and_email(X509 *crt, const char *name)\n{\n    return set_cn(crt, NID_commonName, name,\n                  NID_pkcs9_emailAddress, \"dummy@example.com\", 0);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":278250,"func":"f_lispindent(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    pos_T\tpos;\n    linenr_T\tlnum;\n\n    if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)\n\treturn;\n\n    pos = curwin->w_cursor;\n    lnum = tv_get_lnum(argvars);\n    if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)\n    {\n\tcurwin->w_cursor.lnum = lnum;\n\trettv->vval.v_number = get_lisp_indent();\n\tcurwin->w_cursor = pos;\n    }\n    else if (in_vim9script())\n\tsemsg(_(e_invalid_line_number_nr), lnum);\n    else\n\trettv->vval.v_number = -1;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":175782,"func":"  const OriginInfoTableEntries& origin_info_entries() const {\n    return origin_info_entries_;\n  }\n","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":309906,"func":"color_content(NCURSES_COLOR_T color,\n\t      NCURSES_COLOR_T *r,\n\t      NCURSES_COLOR_T *g,\n\t      NCURSES_COLOR_T *b)\n{\n    return NCURSES_SP_NAME(color_content) (CURRENT_SCREEN, color, r, g, b);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":301376,"func":"static NTSTATUS vfswrap_durable_disconnect(struct vfs_handle_struct *handle,\n\t\t\t\t\t   struct files_struct *fsp,\n\t\t\t\t\t   const DATA_BLOB old_cookie,\n\t\t\t\t\t   TALLOC_CTX *mem_ctx,\n\t\t\t\t\t   DATA_BLOB *new_cookie)\n{\n\treturn vfs_default_durable_disconnect(fsp, old_cookie, mem_ctx,\n\t\t\t\t\t      new_cookie);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":221170,"func":"void gf_odf_vvc_cfg_del(GF_VVCConfig *cfg)\n{\n\tif (!cfg) return;\n\twhile (gf_list_count(cfg->param_array)) {\n\t\tGF_NALUFFParamArray *pa = (GF_NALUFFParamArray*)gf_list_get(cfg->param_array, 0);\n\t\tgf_list_rem(cfg->param_array, 0);\n\n\t\twhile (gf_list_count(pa->nalus)) {\n\t\t\tGF_NALUFFParam *n = (GF_NALUFFParam*)gf_list_get(pa->nalus, 0);\n\t\t\tgf_list_rem(pa->nalus, 0);\n\t\t\tif (n->data) gf_free(n->data);\n\t\t\tgf_free(n);\n\t\t}\n\t\tgf_list_del(pa->nalus);\n\t\tgf_free(pa);\n\t}\n\tgf_list_del(cfg->param_array);\n\tif (cfg->general_constraint_info)\n\t\tgf_free(cfg->general_constraint_info);\n\tif (cfg->sub_profiles_idc)\n\t\tgf_free(cfg->sub_profiles_idc);\n\tgf_free(cfg);\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":240604,"func":"  explicit AssignVariableOp(OpKernelConstruction* c) : OpKernel(c) {\n    OP_REQUIRES_OK(c, c->GetAttr(\"dtype\", &dtype_));\n    OP_REQUIRES(c, dtype_ == DT_VARIANT,\n                errors::Internal(\"Variant kernel called with dtype: \",\n                                 DataTypeString(dtype_)));\n  }","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":301386,"func":"static int vfswrap_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)\n{\n#ifdef HAVE_NO_ACL\n\terrno = ENOSYS;\n\treturn -1;\n#else\n\tint result;\n\n\tSTART_PROFILE(fchmod_acl);\n\tresult = fchmod_acl(fsp, mode);\n\tEND_PROFILE(fchmod_acl);\n\treturn result;\n#endif\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":437356,"func":"is_good_case_fold_items_for_search(OnigEncoding enc, int slen,\n                                   int n, OnigCaseFoldCodeItem items[])\n{\n  int i, len;\n  UChar buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];\n\n  for (i = 0; i < n; i++) {\n    OnigCaseFoldCodeItem* item = items + i;\n\n    if (item->code_len != 1)    return 0;\n    if (item->byte_len != slen) return 0;\n    len = ONIGENC_CODE_TO_MBC(enc, item->code[0], buf);\n    if (len != slen) return 0;\n  }\n\n  return 1;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":352974,"func":"countryStringValidate(\n\tSyntax *syntax,\n\tstruct berval *val )\n{\n\tif( val->bv_len != 2 ) return LDAP_INVALID_SYNTAX;\n\n\tif( !SLAP_PRINTABLE(val->bv_val[0]) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\tif( !SLAP_PRINTABLE(val->bv_val[1]) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":231704,"func":"  auto& lossTimeout() {\n    return lossTimeout_;\n  }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":512794,"func":"  bool is_null() const { return m_type == DYN_COL_NULL; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":234210,"func":"try_build_id_prefix (const char * prefix, char * filename, const unsigned char * data, unsigned long id_len)\n{\n  char * f = filename;\n\n  f += sprintf (f, \"%s.build-id\/%02x\/\", prefix, (unsigned) *data++);\n  id_len --;\n  while (id_len --)\n    f += sprintf (f, \"%02x\", (unsigned) *data++);\n  strcpy (f, \".debug\");\n\n  return open_debug_file (filename);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":261996,"func":"static void bundle_destroy(struct connectbundle *bundle)\n{\n  if(!bundle)\n    return;\n\n  Curl_llist_destroy(&bundle->conn_list, NULL);\n\n  free(bundle);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":328881,"func":"R_API void r_bin_java_print_bootstrap_method_argument_summary(RBinJavaBootStrapArgument *bsm_arg) {\n\tif (!bsm_arg) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaBootStrapArgument *.\\n\");\n\t\treturn;\n\t}\n\teprintf (\"Bootstrap Method Argument Information:\\n\");\n\teprintf (\"\tOffset: 0x%08\"PFMT64x\"\", bsm_arg->file_offset);\n\teprintf (\"\tName_And_Type Index = (0x%02x)\\n\", bsm_arg->argument_info_idx);\n\tif (bsm_arg->argument_info_cp_obj) {\n\t\teprintf (\"\tBootstrap Method Argument Type and Name Info:\\n\");\n\t\t((RBinJavaCPTypeMetas *) bsm_arg->argument_info_cp_obj)->allocs->print_summary (bsm_arg->argument_info_cp_obj);\n\t} else {\n\t\teprintf (\"\tBootstrap Method Argument Type and Name Info: INVALID\\n\");\n\t}\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":427791,"func":"static bool cmd_allowed_from_miror(u32 cmd_id)\n{\n\t\/*\n\t * Allow mirrors VM to call KVM_SEV_LAUNCH_UPDATE_VMSA to enable SEV-ES\n\t * active mirror VMs. Also allow the debugging and status commands.\n\t *\/\n\tif (cmd_id == KVM_SEV_LAUNCH_UPDATE_VMSA ||\n\t    cmd_id == KVM_SEV_GUEST_STATUS || cmd_id == KVM_SEV_DBG_DECRYPT ||\n\t    cmd_id == KVM_SEV_DBG_ENCRYPT)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":225655,"func":"GF_Err tssy_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TimeStampSynchronyBox *ptr = (GF_TimeStampSynchronyBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_int(bs, 0, 6);\n\tgf_bs_write_int(bs, ptr->timestamp_sync, 2);\n\treturn GF_OK;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":313832,"func":"checkclearopq(oparg_T *oap)\n{\n    if (oap->op_type == OP_NOP && !VIsual_active)\n\treturn FALSE;\n    clearopbeep(oap);\n    return TRUE;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":225642,"func":"\nGF_Err proj_type_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_ProjectionTypeBox *ptr = (GF_ProjectionTypeBox *)s;\n\n\tif (ptr->type==GF_ISOM_BOX_TYPE_CBMP) {\n\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\tptr->layout = gf_bs_read_u32(bs);\n\t\tptr->padding = gf_bs_read_u32(bs);\n\t}\n\telse if (ptr->type==GF_ISOM_BOX_TYPE_EQUI) {\n\t\tISOM_DECREASE_SIZE(ptr, 16)\n\t\tptr->bounds_top = gf_bs_read_u32(bs);\n\t\tptr->bounds_bottom = gf_bs_read_u32(bs);\n\t\tptr->bounds_left = gf_bs_read_u32(bs);\n\t\tptr->bounds_right = gf_bs_read_u32(bs);\n\t} else {\n\t\tISOM_DECREASE_SIZE(ptr, 8)\n\t\tptr->crc = gf_bs_read_u32(bs);\n\t\tptr->encoding_4cc = gf_bs_read_u32(bs);\n\t}\n\treturn gf_isom_box_array_read(s, bs);","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":333085,"func":"log_subexpr(regsub_T *sub)\n{\n    int j;\n\n    for (j = 0; j < sub->in_use; j++)\n\tif (REG_MULTI)\n\t    fprintf(log_fd, \"*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\\n\",\n\t\t    j,\n\t\t    sub->list.multi[j].start_col,\n\t\t    (int)sub->list.multi[j].start_lnum,\n\t\t    sub->list.multi[j].end_col,\n\t\t    (int)sub->list.multi[j].end_lnum);\n\telse\n\t{\n\t    char *s = (char *)sub->list.line[j].start;\n\t    char *e = (char *)sub->list.line[j].end;\n\n\t    fprintf(log_fd, \"*** group %d, start: \\\"%s\\\", end: \\\"%s\\\"\\n\",\n\t\t    j,\n\t\t    s == NULL ? \"NULL\" : s,\n\t\t    e == NULL ? \"NULL\" : e);\n\t}\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":369211,"func":"\nstatic void io_free_page_table(void **table, size_t size)\n{\n\tunsigned i, nr_tables = DIV_ROUND_UP(size, PAGE_SIZE);\n\n\tfor (i = 0; i < nr_tables; i++)\n\t\tkfree(table[i]);\n\tkfree(table);","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":294488,"func":"test_unit_v2v_iter(VALUE (* conv1)(VALUE),\n\t\t   VALUE (* conv2)(VALUE))\n{\n    if (!test_unit_v2v_iter2(conv1, conv2))\n\treturn 0;\n    if (!test_unit_v2v_iter2(conv2, conv1))\n\treturn 0;\n    return 1;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":274844,"func":"TEST(ComparisonsTest, NotEqualBroadcastTwoD) {\n  ComparisonOpModel model({1, 1, 2, 4}, {1, 1, 1, 4}, TensorType_INT32,\n                          BuiltinOperator_NOT_EQUAL);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3, 2, 4, 2, 8});\n  model.PopulateTensor<int>(model.input2(), {7, 1, 2, 4});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(),\n              ElementsAre(true, true, true, true, true, true, false, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 2, 4));\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":301389,"func":"static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp)\n{\n#ifdef HAVE_FSYNC\n\tint result;\n\n\tSTART_PROFILE(syscall_fsync);\n\tresult = fsync(fsp->fh->fd);\n\tEND_PROFILE(syscall_fsync);\n\treturn result;\n#else\n\treturn 0;\n#endif\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":244173,"func":"GF_Box *trik_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrickPlayBox, GF_ISOM_BOX_TYPE_TRIK);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":253577,"func":"smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t   struct cifsFileInfo *cfile)\n{\n\tstruct fsctl_set_integrity_information_req integr_info;\n\tunsigned int ret_data_len;\n\n\tintegr_info.ChecksumAlgorithm = cpu_to_le16(CHECKSUM_TYPE_UNCHANGED);\n\tintegr_info.Flags = 0;\n\tintegr_info.Reserved = 0;\n\n\treturn SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,\n\t\t\tcfile->fid.volatile_fid,\n\t\t\tFSCTL_SET_INTEGRITY_INFORMATION,\n\t\t\ttrue \/* is_fsctl *\/,\n\t\t\t(char *)&integr_info,\n\t\t\tsizeof(struct fsctl_set_integrity_information_req),\n\t\t\tCIFSMaxBufSize, NULL,\n\t\t\t&ret_data_len);\n\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":343119,"func":"static void __exit esp4_fini(void)\n{\n\tif (xfrm4_protocol_deregister(&esp4_protocol, IPPROTO_ESP) < 0)\n\t\tpr_info(\"%s: can't remove protocol\\n\", __func__);\n\txfrm_unregister_type(&esp_type, AF_INET);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":236188,"func":"GF_Err blnk_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":262792,"func":"static void mctp_serial_rx(struct mctp_serial *dev)\n{\n\tstruct mctp_skb_cb *cb;\n\tstruct sk_buff *skb;\n\n\tif (dev->rxfcs != dev->rxfcs_rcvd) {\n\t\tdev->netdev->stats.rx_dropped++;\n\t\tdev->netdev->stats.rx_crc_errors++;\n\t\treturn;\n\t}\n\n\tskb = netdev_alloc_skb(dev->netdev, dev->rxlen);\n\tif (!skb) {\n\t\tdev->netdev->stats.rx_dropped++;\n\t\treturn;\n\t}\n\n\tskb->protocol = htons(ETH_P_MCTP);\n\tskb_put_data(skb, dev->rxbuf, dev->rxlen);\n\tskb_reset_network_header(skb);\n\n\tcb = __mctp_cb(skb);\n\tcb->halen = 0;\n\n\tnetif_rx_ni(skb);\n\tdev->netdev->stats.rx_packets++;\n\tdev->netdev->stats.rx_bytes += dev->rxlen;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":384793,"func":"vim_iswordp(char_u *p)\n{\n    return vim_iswordp_buf(p, curbuf);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":512798,"func":"bool Item_func_ifnull::native_op(THD *thd, Native *to)\n{\n  DBUG_ASSERT(fixed == 1);\n  if (!val_native_with_conversion_from_item(thd, args[0], to, type_handler()))\n    return false;\n  return val_native_with_conversion_from_item(thd, args[1], to, type_handler());\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":502716,"func":"void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val) {\n    return ctx->info_callback;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":236209,"func":"void gpp_read_box(GF_BitStream *bs, GF_BoxRecord *rec)\n{\n\trec->top = gf_bs_read_u16(bs);\n\trec->left = gf_bs_read_u16(bs);\n\trec->bottom = gf_bs_read_u16(bs);\n\trec->right = gf_bs_read_u16(bs);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":413830,"func":"void LinkResolver::resolve_special_call(CallInfo& result,\n                                        Handle recv,\n                                        const LinkInfo& link_info,\n                                        TRAPS) {\n  Method* resolved_method = linktime_resolve_special_method(link_info, CHECK);\n  runtime_resolve_special_method(result, link_info, methodHandle(THREAD, resolved_method), recv, CHECK);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":202783,"func":"static Bigint * Balloc(int k)\n{\n\tint x;\n\tBigint *rv;\n\n\t_THREAD_PRIVATE_MUTEX_LOCK(dtoa_mutex);\n\tif ((rv = freelist[k])) {\n\t\tfreelist[k] = rv->next;\n\t} else {\n\t\tx = 1 << k;\n\t\trv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));\n\t\trv->k = k;\n\t\trv->maxwds = x;\n\t}\n\t_THREAD_PRIVATE_MUTEX_UNLOCK(dtoa_mutex);\n\trv->sign = rv->wds = 0;\n\treturn rv;\n}","target":1,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":400747,"func":"static inline void data_start(const struct iov_iter *i,\n\t\t\t      unsigned int *iter_headp, size_t *offp)\n{\n\tunsigned int p_mask = i->pipe->ring_size - 1;\n\tunsigned int iter_head = i->head;\n\tsize_t off = i->iov_offset;\n\n\tif (off && (!allocated(&i->pipe->bufs[iter_head & p_mask]) ||\n\t\t    off == PAGE_SIZE)) {\n\t\titer_head++;\n\t\toff = 0;\n\t}\n\t*iter_headp = iter_head;\n\t*offp = off;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":427204,"func":"static void movegotosout (FuncState *fs, BlockCnt *bl) {\n  int i;\n  Labellist *gl = &fs->ls->dyd->gt;\n  \/* correct pending gotos to current block *\/\n  for (i = bl->firstgoto; i < gl->n; i++) {  \/* for each pending goto *\/\n    Labeldesc *gt = &gl->arr[i];\n    \/* leaving a variable scope? *\/\n    if (reglevel(fs, gt->nactvar) > reglevel(fs, bl->nactvar))\n      gt->close |= bl->upval;  \/* jump may need a close *\/\n    gt->nactvar = bl->nactvar;  \/* update goto level *\/\n  }\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":502733,"func":"int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len)\n{\n    if (s->version >= TLS1_VERSION) {\n        if (s->tlsext_session_ticket) {\n            OPENSSL_free(s->tlsext_session_ticket);\n            s->tlsext_session_ticket = NULL;\n        }\n\n        s->tlsext_session_ticket =\n            OPENSSL_malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len);\n        if (!s->tlsext_session_ticket) {\n            SSLerr(SSL_F_SSL_SET_SESSION_TICKET_EXT, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n\n        if (ext_data) {\n            s->tlsext_session_ticket->length = ext_len;\n            s->tlsext_session_ticket->data = s->tlsext_session_ticket + 1;\n            memcpy(s->tlsext_session_ticket->data, ext_data, ext_len);\n        } else {\n            s->tlsext_session_ticket->length = 0;\n            s->tlsext_session_ticket->data = NULL;\n        }\n\n        return 1;\n    }\n\n    return 0;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":312502,"func":"qf_entry_on_or_after_pos(qfline_T *qfp, pos_T *pos, int linewise)\n{\n    if (linewise)\n\treturn qfp->qf_lnum >= pos->lnum;\n    else\n\treturn (qfp->qf_lnum > pos->lnum ||\n\t\t(qfp->qf_lnum == pos->lnum && qfp->qf_col >= pos->col));\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":234712,"func":"int btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)\n{\n\tstruct btrfs_block_group *cache;\n\n\t\/* Do not attempt to repair in degraded state *\/\n\tif (btrfs_test_opt(fs_info, DEGRADED))\n\t\treturn 0;\n\n\tcache = btrfs_lookup_block_group(fs_info, logical);\n\tif (!cache)\n\t\treturn 0;\n\n\tspin_lock(&cache->lock);\n\tif (cache->relocating_repair) {\n\t\tspin_unlock(&cache->lock);\n\t\tbtrfs_put_block_group(cache);\n\t\treturn 0;\n\t}\n\tcache->relocating_repair = 1;\n\tspin_unlock(&cache->lock);\n\n\tkthread_run(relocating_repair_kthread, cache,\n\t\t    \"btrfs-relocating-repair\");\n\n\treturn 0;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":90745,"func":"  bool AppendEntry(const TableEntry& entry) {\n    entries_.push_back(entry);\n    return true;\n  }\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":386548,"func":"void DL_Dxf::addImage(DL_CreationInterface* creationInterface) {\n    DL_ImageData id(\/\/ pass ref insead of name we don't have yet\n        getStringValue(340, \"\"),\n        \/\/ ins point:\n        getRealValue(10, 0.0),\n        getRealValue(20, 0.0),\n        getRealValue(30, 0.0),\n        \/\/ u vector:\n        getRealValue(11, 1.0),\n        getRealValue(21, 0.0),\n        getRealValue(31, 0.0),\n        \/\/ v vector:\n        getRealValue(12, 0.0),\n        getRealValue(22, 1.0),\n        getRealValue(32, 0.0),\n        \/\/ image size (pixel):\n        getIntValue(13, 1),\n        getIntValue(23, 1),\n        \/\/ brightness, contrast, fade\n        getIntValue(281, 50),\n        getIntValue(282, 50),\n        getIntValue(283, 0));\n\n    creationInterface->addImage(id);\n    creationInterface->endEntity();\n    currentObjectType = DL_UNKNOWN;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":309946,"func":"set_colors(int fg, int bg)\n{\n    int pair = mypair(fg, bg);\n    if (pair > 0) {\n\t(void) color_set((short) pair, NewPair(pair));\n    }\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":274749,"func":"callbacks_open_activate(GtkMenuItem *menuitem, gpointer user_data)\n{\n\tGSList *fns = NULL;\n\tscreen.win.gerber = \n\t\tgtk_file_chooser_dialog_new (\n\t\t\t\t_(\"Open Gerbv project, Gerber, drill, \"\n\t\t\t\t\"or pick&place files\"),\n\t\t\tNULL, GTK_FILE_CHOOSER_ACTION_OPEN,\n\t\t\tGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,\n\t\t\tGTK_STOCK_OPEN,   GTK_RESPONSE_ACCEPT,\n\t\t\tNULL);\n\n\tgtk_file_chooser_set_select_multiple(\n\t\t\t(GtkFileChooser *)screen.win.gerber, TRUE);\n\tgtk_file_chooser_set_current_folder(\n\t\t\t(GtkFileChooser *)screen.win.gerber, mainProject->path);\n\tgtk_widget_show (screen.win.gerber);\n\tif (gtk_dialog_run ((GtkDialog*)screen.win.gerber) ==\n\t\t\tGTK_RESPONSE_ACCEPT) {\n\t\tfns = gtk_file_chooser_get_filenames(\n\t\t\t\tGTK_FILE_CHOOSER (screen.win.gerber));\n\t\t\/* Update the last folder *\/\n\t\tg_free (mainProject->path);\n\t\tmainProject->path = gtk_file_chooser_get_current_folder(\n\t\t\t\t(GtkFileChooser *)screen.win.gerber);\n\t}\n\tgtk_widget_destroy (screen.win.gerber);\n\n\topen_files (fns);\n\tg_slist_free_full (fns, g_free);\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":267977,"func":"static ut64 binobj_a2b(RBinObject *bo, ut64 addr) {\n\treturn addr + (bo ? bo->baddr_shift : 0);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":366240,"func":"int __mnt_want_write_file(struct file *file)\n{\n\tif (file->f_mode & FMODE_WRITER) {\n\t\t\/*\n\t\t * Superblock may have become readonly while there are still\n\t\t * writable fd's, e.g. due to a fs error with errors=remount-ro\n\t\t *\/\n\t\tif (__mnt_is_readonly(file->f_path.mnt))\n\t\t\treturn -EROFS;\n\t\treturn 0;\n\t}\n\treturn __mnt_want_write(file->f_path.mnt);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":512636,"func":"bool Item_bool_rowready_func2::fix_length_and_dec()\n{\n  max_length= 1;\t\t\t\t     \/\/ Function returns 0 or 1\n\n  \/*\n    As some compare functions are generated after sql_yacc,\n    we have to check for out of memory conditions here\n  *\/\n  if (!args[0] || !args[1])\n    return FALSE;\n  return setup_args_and_comparator(current_thd, &cmp);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":264287,"func":"static void send_ext_key_event_ack(VncState *vs)\n{\n    vnc_lock_output(vs);\n    vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);\n    vnc_write_u8(vs, 0);\n    vnc_write_u16(vs, 1);\n    vnc_framebuffer_update(vs, 0, 0,\n                           surface_width(vs->vd->ds),\n                           surface_height(vs->vd->ds),\n                           VNC_ENCODING_EXT_KEY_EVENT);\n    vnc_unlock_output(vs);\n    vnc_flush(vs);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":238614,"func":"static int check_stack_write(struct bpf_verifier_env *env,\n\t\t\t     int ptr_regno, int off, int size,\n\t\t\t     int value_regno, int insn_idx)\n{\n\tstruct bpf_reg_state *reg = reg_state(env, ptr_regno);\n\tstruct bpf_func_state *state = func(env, reg);\n\tint err;\n\n\tif (tnum_is_const(reg->var_off)) {\n\t\toff += reg->var_off.value;\n\t\terr = check_stack_write_fixed_off(env, state, off, size,\n\t\t\t\t\t\t  value_regno, insn_idx);\n\t} else {\n\t\t\/* Variable offset stack reads need more conservative handling\n\t\t * than fixed offset ones.\n\t\t *\/\n\t\terr = check_stack_write_var_off(env, state,\n\t\t\t\t\t\tptr_regno, off, size,\n\t\t\t\t\t\tvalue_regno, insn_idx);\n\t}\n\treturn err;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":309921,"func":"tparm_tc_compat(TPARM_DATA * data)\n{\n    bool termcap_hack = FALSE;\n\n    TPS(stack_ptr) = 0;\n\n    if (data->num_popped == 0) {\n\tint i;\n\n\ttermcap_hack = TRUE;\n\tfor (i = data->num_parsed - 1; i >= 0; i--) {\n\t    if (data->p_is_s[i])\n\t\tspush(data->p_is_s[i]);\n\t    else\n\t\tnpush((int) data->param[i]);\n\t}\n    }\n    return termcap_hack;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":474433,"func":"ObjectCreateHMACSequence(\n\t\t\t TPMI_ALG_HASH    hashAlg,       \/\/ IN: hash algorithm\n\t\t\t OBJECT          *keyObject,     \/\/ IN: the object containing the HMAC key\n\t\t\t TPM2B_AUTH      *auth,          \/\/ IN: authValue\n\t\t\t TPMI_DH_OBJECT  *newHandle      \/\/ OUT: HMAC sequence object handle\n\t\t\t )\n{\n    HASH_OBJECT         *hmacObject;\n    \/\/\n    \/\/ Try to allocate a slot for new object\n    hmacObject = AllocateSequenceSlot(newHandle, auth);\n    if(hmacObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    \/\/ Set HMAC sequence bit\n    hmacObject->attributes.hmacSeq = SET;\n#if !SMAC_IMPLEMENTED\n    if(CryptHmacStart(&hmacObject->state.hmacState, hashAlg,\n\t\t      keyObject->sensitive.sensitive.bits.b.size,\n\t\t      keyObject->sensitive.sensitive.bits.b.buffer) == 0)\n#else\n\tif(CryptMacStart(&hmacObject->state.hmacState,\n\t\t\t &keyObject->publicArea.parameters,\n\t\t\t hashAlg, &keyObject->sensitive.sensitive.any.b) == 0)\n#endif \/\/ SMAC_IMPLEMENTED\n\t    return TPM_RC_FAILURE;\n    return TPM_RC_SUCCESS;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":238427,"func":"static void __update_reg64_bounds(struct bpf_reg_state *reg)\n{\n\t\/* min signed is max(sign bit) | min(other bits) *\/\n\treg->smin_value = max_t(s64, reg->smin_value,\n\t\t\t\treg->var_off.value | (reg->var_off.mask & S64_MIN));\n\t\/* max signed is min(sign bit) | max(other bits) *\/\n\treg->smax_value = min_t(s64, reg->smax_value,\n\t\t\t\treg->var_off.value | (reg->var_off.mask & S64_MAX));\n\treg->umin_value = max(reg->umin_value, reg->var_off.value);\n\treg->umax_value = min(reg->umax_value,\n\t\t\t      reg->var_off.value | reg->var_off.mask);\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":310063,"func":"increment(int *all_parms, int *num_parms, int len_parms, int end_parms)\n{\n    int rc = 0;\n    int n;\n\n    if (len_parms > 9)\n\tlen_parms = 9;\n\n    if (end_parms < len_parms) {\n\tif (all_parms[end_parms]++ >= num_parms[end_parms]) {\n\t    all_parms[end_parms] = 0;\n\t    increment(all_parms, num_parms, len_parms, end_parms + 1);\n\t}\n    }\n    for (n = 0; n < len_parms; ++n) {\n\tif (all_parms[n] != 0) {\n\t    rc = 1;\n\t    break;\n\t}\n    }\n    \/* return 1 until the vector resets to all 0's *\/\n    return rc;\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":244018,"func":"void ssix_box_del(GF_Box *s)\n{\n\tu32 i;\n\tGF_SubsegmentIndexBox *ptr = (GF_SubsegmentIndexBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->subsegments) {\n\t\tfor (i = 0; i < ptr->subsegment_alloc; i++) {\n\t\t\tGF_SubsegmentInfo *subsegment = &ptr->subsegments[i];\n\t\t\tif (subsegment->ranges) gf_free(subsegment->ranges);\n\t\t}\n\t\tgf_free(ptr->subsegments);\n\t}\n\tgf_free(ptr);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":369151,"func":"static int io_fallocate(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tint ret;\n\n\t\/* fallocate always requiring blocking context *\/\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\tret = vfs_fallocate(req->file, req->sync.mode, req->sync.off,\n\t\t\t\treq->sync.len);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\telse\n\t\tfsnotify_modify(req->file);\n\tio_req_complete(req, ret);\n\treturn 0;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":352944,"func":"bootParameterValidate(\n\tSyntax *syntax,\n\tstruct berval *val )\n{\n\tchar *p, *e;\n\n\tif ( BER_BVISEMPTY( val ) ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tp = (char *)val->bv_val;\n\te = p + val->bv_len;\n\n\t\/* key *\/\n\tfor (; ( p < e ) && ( *p != '=' ); p++ ) {\n\t\tif ( !AD_CHAR( *p ) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\tif ( *p != '=' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* server *\/\n\tfor ( p++; ( p < e ) && ( *p != ':' ); p++ ) {\n\t\tif ( !AD_CHAR( *p ) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\tif ( *p != ':' ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\t\/* path *\/\n\tfor ( p++; p < e; p++ ) {\n\t\tif ( !SLAP_PRINTABLE( *p ) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":474014,"func":"mbc_case_fold(OnigCaseFoldType flag,\n\t\t\t  const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower,\n\t\t\t  OnigEncoding enc ARG_UNUSED)\n{\n  const UChar* p = *pp;\n\n  if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {\n    *lower++ = 's';\n    *lower   = 's';\n    (*pp)++;\n    return 2;\n  }\n\n  *lower = ENC_ISO_8859_16_TO_LOWER_CASE(*p);\n  (*pp)++;\n  return 1; \/* return byte length of converted char to lower *\/\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":225705,"func":"GF_Err def_parent_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":292162,"func":"methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info,\n                                                             TRAPS) {\n  \/\/ normal interface method resolution\n  methodHandle resolved_method = resolve_interface_method(link_info, Bytecodes::_invokeinterface, CHECK_NULL);\n  assert(resolved_method->name() != vmSymbols::object_initializer_name(), \"should have been checked in verifier\");\n  assert(resolved_method->name() != vmSymbols::class_initializer_name (), \"should have been checked in verifier\");\n\n  return resolved_method;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":427208,"func":"static int block_follow (LexState *ls, int withuntil) {\n  switch (ls->t.token) {\n    case TK_ELSE: case TK_ELSEIF:\n    case TK_END: case TK_EOS:\n      return 1;\n    case TK_UNTIL: return withuntil;\n    default: return 0;\n  }\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":220441,"func":"mrb_ary_modify(mrb_state *mrb, struct RArray* a)\n{\n  mrb_write_barrier(mrb, (struct RBasic*)a);\n  ary_modify(mrb, a);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":359629,"func":"peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,\n\t\t\t   safi_t safi, const char *direct_str)\n{\n  int ret;\n  struct peer *peer;\n  int direct = FILTER_IN;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  \/* Check filter direction. *\/\n  if (strncmp (direct_str, \"i\", 1) == 0)\n    direct = FILTER_IN;\n  else if (strncmp (direct_str, \"o\", 1) == 0)\n    direct = FILTER_OUT;\n\n  ret = peer_distribute_unset (peer, afi, safi, direct);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":477814,"func":"static int rtas_name_matches(char *s1, char *s2)\n{\n\tstruct kvm_rtas_token_args args;\n\treturn !strncmp(s1, s2, sizeof(args.name));\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":387816,"func":"void InstanceKlass::ensure_space_for_methodids(int start_offset) {\n  int new_jmeths = 0;\n  int length = methods()->length();\n  for (int index = start_offset; index < length; index++) {\n    Method* m = methods()->at(index);\n    jmethodID id = m->find_jmethod_id_or_null();\n    if (id == NULL) {\n      new_jmeths++;\n    }\n  }\n  if (new_jmeths != 0) {\n    Method::ensure_jmethod_ids(class_loader_data(), new_jmeths);\n  }\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":309901,"func":"NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx\n\t\t\t\tNCURSES_COLOR_T color,\n\t\t\t\tNCURSES_COLOR_T *r,\n\t\t\t\tNCURSES_COLOR_T *g,\n\t\t\t\tNCURSES_COLOR_T *b)\n{\n    int my_r, my_g, my_b;\n    int rc = _nc_color_content(SP_PARM, color, &my_r, &my_g, &my_b);\n    if (rc == OK) {\n\t*r = limit_COLOR(my_r);\n\t*g = limit_COLOR(my_g);\n\t*b = limit_COLOR(my_b);\n    }\n    return rc;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":231695,"func":"TEST_F(QuicServerTransportTest, RecvNewConnectionIdNoopValidDuplicate) {\n  auto& conn = server->getNonConstConn();\n  conn.transportSettings.selfActiveConnectionIdLimit = 1;\n\n  ConnectionId connId2({5, 5, 5, 5});\n  conn.peerConnectionIds.emplace_back(connId2, 1);\n\n  ShortHeader header(ProtectionType::KeyPhaseZero, *conn.clientConnectionId, 1);\n  RegularQuicPacketBuilder builder(\n      conn.udpSendPacketLen, std::move(header), 0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  ASSERT_TRUE(builder.canBuildPacket());\n  NewConnectionIdFrame newConnId(1, 0, connId2, StatelessResetToken());\n  writeSimpleFrame(QuicSimpleFrame(newConnId), builder);\n\n  auto packet = std::move(builder).buildPacket();\n\n  EXPECT_EQ(conn.peerConnectionIds.size(), 2);\n  deliverData(packetToBuf(packet), false);\n  EXPECT_EQ(conn.peerConnectionIds.size(), 2);\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":473837,"func":"utf32le_mbc_enc_len(const UChar* p ARG_UNUSED, const OnigUChar* e ARG_UNUSED,\n\t\t    OnigEncoding enc ARG_UNUSED)\n{\n  return 4;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":498097,"func":"static const char *fmt_date(time_t secs, const char *format, int local_time)\n{\n\tstatic char buf[64];\n\tstruct tm *time;\n\n\tif (!secs)\n\t\treturn \"\";\n\tif (local_time)\n\t\ttime = localtime(&secs);\n\telse\n\t\ttime = gmtime(&secs);\n\tstrftime(buf, sizeof(buf)-1, format, time);\n\treturn buf;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":307857,"func":"void ciEnv::dump_replay_data(int compile_id) {\n  static char buffer[O_BUFLEN];\n  int ret = jio_snprintf(buffer, O_BUFLEN, \"replay_pid%p_compid%d.log\", os::current_process_id(), compile_id);\n  if (ret > 0) {\n    int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);\n    if (fd != -1) {\n      FILE* replay_data_file = os::open(fd, \"w\");\n      if (replay_data_file != NULL) {\n        fileStream replay_data_stream(replay_data_file, \/*need_close=*\/true);\n        dump_replay_data(&replay_data_stream);\n        tty->print_cr(\"# Compiler replay data is saved as: %s\", buffer);\n      } else {\n        tty->print_cr(\"# Can't open file to dump replay data.\");\n      }\n    }\n  }\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":361753,"func":"void em28xx_free_device(struct kref *ref)\n{\n\tstruct em28xx *dev = kref_to_dev(ref);\n\n\tdev_info(&dev->intf->dev, \"Freeing device\\n\");\n\n\tif (!dev->disconnected)\n\t\tem28xx_release_resources(dev);\n\n\tif (dev->ts == PRIMARY_TS)\n\t\tkfree(dev->alt_max_pkt_size_isoc);\n\n\tkfree(dev);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":231016,"func":"    const char * pcQueueGetName( QueueHandle_t xQueue ) \/*lint !e971 Unqualified char types are allowed for strings and single characters only. *\/\r\n    {\r\n        UBaseType_t ux;\r\n        const char * pcReturn = NULL; \/*lint !e971 Unqualified char types are allowed for strings and single characters only. *\/\r\n\r\n        \/* Note there is nothing here to protect against another task adding or\r\n         * removing entries from the registry while it is being searched. *\/\r\n\r\n        for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )\r\n        {\r\n            if( xQueueRegistry[ ux ].xHandle == xQueue )\r\n            {\r\n                pcReturn = xQueueRegistry[ ux ].pcQueueName;\r\n                break;\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n        }\r\n\r\n        return pcReturn;\r\n    } \/*lint !e818 xQueue cannot be a pointer to const because it is a typedef. *\/\r","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":247090,"func":"Bool gf_fs_check_filter_register_cap(const GF_FilterRegister *f_reg, u32 incode, GF_PropertyValue *cap_input, u32 outcode, GF_PropertyValue *cap_output, Bool exact_match_only)\n{\n\treturn gf_fs_check_filter_register_cap_ex(f_reg, incode, cap_input, outcode, cap_output, exact_match_only, GF_FALSE);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":393457,"func":"static SQInteger base_enabledebuginfo(HSQUIRRELVM v)\n{\n    SQObjectPtr &o=stack_get(v,2);\n\n    sq_enabledebuginfo(v,SQVM::IsFalse(o)?SQFalse:SQTrue);\n    return 0;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":230378,"func":"PJ_DEF(pj_xml_node*) pj_xml_parse( pj_pool_t *pool, char *msg, pj_size_t len)\n{\n    pj_xml_node *node = NULL;\n    pj_scanner scanner;\n    PJ_USE_EXCEPTION;\n\n    if (!msg || !len || !pool)\n\treturn NULL;\n\n    pj_scan_init( &scanner, msg, len, \n\t\t  PJ_SCAN_AUTOSKIP_WS|PJ_SCAN_AUTOSKIP_NEWLINE, \n\t\t  &on_syntax_error);\n    PJ_TRY {\n\tnode =  xml_parse_node(pool, &scanner);\n    }\n    PJ_CATCH_ANY {\n\tPJ_LOG(4,(THIS_FILE, \"Syntax error parsing XML in line %d column %d\",\n\t\t  scanner.line, pj_scan_get_col(&scanner)));\n    }\n    PJ_END;\n    pj_scan_fini( &scanner );\n    return node;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":502720,"func":"void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,\n                                  int (*cb) (SSL *ssl, unsigned char *cookie,\n                                             unsigned int cookie_len))\n{\n    ctx->app_verify_cookie_cb = cb;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":395075,"func":"copy_text_attr(\n    int\t\toff,\n    char_u\t*buf,\n    int\t\tlen,\n    int\t\tattr)\n{\n    int\t\ti;\n\n    mch_memmove(ScreenLines + off, buf, (size_t)len);\n    if (enc_utf8)\n\tvim_memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len);\n    for (i = 0; i < len; ++i)\n\tScreenAttrs[off + i] = attr;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":376354,"func":"gpg_hash_str (CamelCipherHash hash)\n{\n\tswitch (hash) {\n\tcase CAMEL_CIPHER_HASH_MD2:\n\t\treturn \"--digest-algo=MD2\";\n\tcase CAMEL_CIPHER_HASH_MD5:\n\t\treturn \"--digest-algo=MD5\";\n\tcase CAMEL_CIPHER_HASH_SHA1:\n\t\treturn \"--digest-algo=SHA1\";\n\tcase CAMEL_CIPHER_HASH_SHA256:\n\t\treturn \"--digest-algo=SHA256\";\n\tcase CAMEL_CIPHER_HASH_SHA384:\n\t\treturn \"--digest-algo=SHA384\";\n\tcase CAMEL_CIPHER_HASH_SHA512:\n\t\treturn \"--digest-algo=SHA512\";\n\tcase CAMEL_CIPHER_HASH_RIPEMD160:\n\t\treturn \"--digest-algo=RIPEMD160\";\n\tdefault:\n\t\treturn NULL;\n\t}\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":344228,"func":"int luaV_tointegerns (const TValue *obj, lua_Integer *p, F2Imod mode) {\n  if (ttisfloat(obj))\n    return luaV_flttointeger(fltvalue(obj), p, mode);\n  else if (ttisinteger(obj)) {\n    *p = ivalue(obj);\n    return 1;\n  }\n  else\n    return 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":253542,"func":"smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t  struct cifs_sb_info *cifs_sb, const char *full_path,\n\t\t  u64 *uniqueid, FILE_ALL_INFO *data)\n{\n\t*uniqueid = le64_to_cpu(data->IndexNumber);\n\treturn 0;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":509544,"func":"int ha_maria::rnd_end()\n{\n  ds_mrr.dsmrr_close();\n  \/* Safe to call even if we don't have started a scan *\/\n  maria_scan_end(file);\n  return 0;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":473995,"func":"big5_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)\n{\n  return onigenc_mb2_is_code_ctype(enc, code, ctype);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":265461,"func":"static int sqfs_get_metablk_pos(u32 *pos_list, void *table, u32 offset,\n\t\t\t\tint metablks_count)\n{\n\tu32 data_size, cur_size = 0;\n\tint j, ret = 0;\n\tbool comp;\n\n\tif (!metablks_count)\n\t\treturn -EINVAL;\n\n\tfor (j = 0; j < metablks_count; j++) {\n\t\tret = sqfs_read_metablock(table, offset + cur_size, &comp,\n\t\t\t\t\t  &data_size);\n\t\tif (ret)\n\t\t\treturn -EINVAL;\n\n\t\tcur_size += data_size + SQFS_HEADER_SIZE;\n\t\tpos_list[j] = cur_size;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":313787,"func":"invoke_edit(\n    cmdarg_T\t*cap,\n    int\t\trepl,\t\t\/\/ \"r\" or \"gr\" command\n    int\t\tcmd,\n    int\t\tstartln)\n{\n    int\t\trestart_edit_save = 0;\n\n    \/\/ Complicated: When the user types \"a<C-O>a\" we don't want to do Insert\n    \/\/ mode recursively.  But when doing \"a<C-O>.\" or \"a<C-O>rx\" we do allow\n    \/\/ it.\n    if (repl || !stuff_empty())\n\trestart_edit_save = restart_edit;\n    else\n\trestart_edit_save = 0;\n\n    \/\/ Always reset \"restart_edit\", this is not a restarted edit.\n    restart_edit = 0;\n\n    if (edit(cmd, startln, cap->count1))\n\tcap->retval |= CA_COMMAND_BUSY;\n\n    if (restart_edit == 0)\n\trestart_edit = restart_edit_save;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":462412,"func":"stopWorkerPool(void)\n{\n\tint i;\n\tDBGPRINTF(\"imptcp: stoping worker pool\\n\");\n\tpthread_mutex_lock(&io_q.mut);\n\tpthread_cond_broadcast(&io_q.wakeup_worker); \/* awake wrkr if not running *\/\n\tpthread_mutex_unlock(&io_q.mut);\n\tfor(i = 0 ; i < runModConf->wrkrMax ; ++i) {\n\t\tpthread_join(wrkrInfo[i].tid, NULL);\n\t\tDBGPRINTF(\"imptcp: info: worker %d was called %llu times\\n\", i, wrkrInfo[i].numCalled);\n\t}\n    free(wrkrInfo);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":366244,"func":"static struct mount *mnt_list_next(struct mnt_namespace *ns,\n\t\t\t\t   struct list_head *p)\n{\n\tstruct mount *mnt, *ret = NULL;\n\n\tlock_ns_list(ns);\n\tlist_for_each_continue(p, &ns->list) {\n\t\tmnt = list_entry(p, typeof(*mnt), mnt_list);\n\t\tif (!mnt_is_cursor(mnt)) {\n\t\t\tret = mnt;\n\t\t\tbreak;\n\t\t}\n\t}\n\tunlock_ns_list(ns);\n\n\treturn ret;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":349884,"func":"static u32 hw_atl_utils_mif_cmd_get(struct aq_hw_s *self)\n{\n\treturn aq_hw_read_reg(self, HW_ATL_MIF_CMD);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":512760,"func":"bool Item_func_like::find_selective_predicates_list_processor(void *arg)\n{\n  find_selective_predicates_list_processor_data *data=\n    (find_selective_predicates_list_processor_data *) arg;\n  if (use_sampling && used_tables() == data->table->map)\n  {\n    THD *thd= data->table->in_use;\n    COND_STATISTIC *stat;\n    Item *arg0;\n    if (!(stat= (COND_STATISTIC *) thd->alloc(sizeof(COND_STATISTIC))))\n      return TRUE;\n    stat->cond= this;\n    arg0= args[0]->real_item();\n    if (args[1]->const_item() && arg0->type() == FIELD_ITEM)\n      stat->field_arg= ((Item_field *)arg0)->field;\n    else\n      stat->field_arg= NULL;\n    data->list.push_back(stat, thd->mem_root);\n  }\n  return FALSE;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":453005,"func":"static int nft_immediate_offload_verdict(struct nft_offload_ctx *ctx,\n\t\t\t\t\t struct nft_flow_rule *flow,\n\t\t\t\t\t const struct nft_immediate_expr *priv)\n{\n\tstruct flow_action_entry *entry;\n\tconst struct nft_data *data;\n\n\tentry = &flow->rule->action.entries[ctx->num_actions++];\n\n\tdata = &priv->data;\n\tswitch (data->verdict.code) {\n\tcase NF_ACCEPT:\n\t\tentry->id = FLOW_ACTION_ACCEPT;\n\t\tbreak;\n\tcase NF_DROP:\n\t\tentry->id = FLOW_ACTION_DROP;\n\t\tbreak;\n\tdefault:\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":387647,"func":"static int snd_ctl_add_replace(struct snd_card *card,\n\t\t\t       struct snd_kcontrol *kcontrol,\n\t\t\t       enum snd_ctl_add_mode mode)\n{\n\tint err = -EINVAL;\n\n\tif (! kcontrol)\n\t\treturn err;\n\tif (snd_BUG_ON(!card || !kcontrol->info))\n\t\tgoto error;\n\n\tdown_write(&card->controls_rwsem);\n\terr = __snd_ctl_add_replace(card, kcontrol, mode);\n\tup_write(&card->controls_rwsem);\n\tif (err < 0)\n\t\tgoto error;\n\treturn 0;\n\n error:\n\tsnd_ctl_free_one(kcontrol);\n\treturn err;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":369436,"func":"static int io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *iter,\n\t\t\t   unsigned int issue_flags)\n{\n\tstruct io_mapped_ubuf *imu = req->imu;\n\tu16 index, buf_index = req->buf_index;\n\n\tif (likely(!imu)) {\n\t\tstruct io_ring_ctx *ctx = req->ctx;\n\n\t\tif (unlikely(buf_index >= ctx->nr_user_bufs))\n\t\t\treturn -EFAULT;\n\t\tio_req_set_rsrc_node(req, ctx, issue_flags);\n\t\tindex = array_index_nospec(buf_index, ctx->nr_user_bufs);\n\t\timu = READ_ONCE(ctx->user_bufs[index]);\n\t\treq->imu = imu;\n\t}\n\treturn __io_import_fixed(req, rw, iter, imu);\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":512496,"func":"  Item_cache_date(THD *thd)\n   :Item_cache_temporal(thd, &type_handler_newdate) { }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":438680,"func":"static void *get_a_tx_buf(struct virtproc_info *vrp)\n{\n\tunsigned int len;\n\tvoid *ret;\n\n\t\/* support multiple concurrent senders *\/\n\tmutex_lock(&vrp->tx_lock);\n\n\t\/*\n\t * either pick the next unused tx buffer\n\t * (half of our buffers are used for sending messages)\n\t *\/\n\tif (vrp->last_sbuf < vrp->num_bufs \/ 2)\n\t\tret = vrp->sbufs + vrp->buf_size * vrp->last_sbuf++;\n\t\/* or recycle a used one *\/\n\telse\n\t\tret = virtqueue_get_buf(vrp->svq, &len);\n\n\tmutex_unlock(&vrp->tx_lock);\n\n\treturn ret;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":316997,"func":"static int selinux_add_opt(int token, const char *s, void **mnt_opts)\n{\n\tstruct selinux_mnt_opts *opts = *mnt_opts;\n\n\tif (token == Opt_seclabel)\t\/* eaten and completely ignored *\/\n\t\treturn 0;\n\n\tif (!opts) {\n\t\topts = kzalloc(sizeof(struct selinux_mnt_opts), GFP_KERNEL);\n\t\tif (!opts)\n\t\t\treturn -ENOMEM;\n\t\t*mnt_opts = opts;\n\t}\n\tif (!s)\n\t\treturn -ENOMEM;\n\tswitch (token) {\n\tcase Opt_context:\n\t\tif (opts->context || opts->defcontext)\n\t\t\tgoto Einval;\n\t\topts->context = s;\n\t\tbreak;\n\tcase Opt_fscontext:\n\t\tif (opts->fscontext)\n\t\t\tgoto Einval;\n\t\topts->fscontext = s;\n\t\tbreak;\n\tcase Opt_rootcontext:\n\t\tif (opts->rootcontext)\n\t\t\tgoto Einval;\n\t\topts->rootcontext = s;\n\t\tbreak;\n\tcase Opt_defcontext:\n\t\tif (opts->context || opts->defcontext)\n\t\t\tgoto Einval;\n\t\topts->defcontext = s;\n\t\tbreak;\n\t}\n\treturn 0;\nEinval:\n\tpr_warn(SEL_MOUNT_FAIL_MSG);\n\treturn -EINVAL;\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":413654,"func":"static int fcn_list_legacy(RCore *core, RList *fcns) {\n\tRListIter *iter;\n\tRAnalFunction *fcn;\n\tr_list_foreach (fcns, iter, fcn) {\n\t\tfcn_print_legacy (core, fcn);\n\t}\n\tr_cons_newline ();\n\treturn 0;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":203980,"func":"static void mkiss_close(struct tty_struct *tty)\n{\n\tstruct mkiss *ax;\n\n\twrite_lock_irq(&disc_data_lock);\n\tax = tty->disc_data;\n\ttty->disc_data = NULL;\n\twrite_unlock_irq(&disc_data_lock);\n\n\tif (!ax)\n\t\treturn;\n\n\t\/*\n\t * We have now ensured that nobody can start using ap from now on, but\n\t * we have to wait for all existing users to finish.\n\t *\/\n\tif (!refcount_dec_and_test(&ax->refcnt))\n\t\twait_for_completion(&ax->dead);\n\t\/*\n\t * Halt the transmit queue so that a new transmit cannot scribble\n\t * on our buffers\n\t *\/\n\tnetif_stop_queue(ax->dev);\n\n\t\/* Free all AX25 frame buffers. *\/\n\tkfree(ax->rbuff);\n\tkfree(ax->xbuff);\n\n\tax->tty = NULL;\n\n\tunregister_netdev(ax->dev);\n\tfree_netdev(ax->dev);\n}","target":1,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":463193,"func":"void dupentryatt(struct entryattlist **dst,\n                 const struct entryattlist *src)\n{\n    for ( ; src ; src = src->next) {\n        struct attvaluelist *attvalues = NULL;\n        dupattvalues(&attvalues, src->attvalues);\n        appendentryatt(dst, src->entry, attvalues);\n    }\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":432240,"func":"static MemTxResult subpage_write(struct uc_struct *uc, void *opaque, hwaddr addr,\n                                 uint64_t value, unsigned len, MemTxAttrs attrs)\n{\n    subpage_t *subpage = opaque;\n    uint8_t buf[8];\n\n#if defined(DEBUG_SUBPAGE)\n    printf(\"%s: subpage %p len %u addr \" TARGET_FMT_plx\n           \" value %\"PRIx64\"\\n\",\n           __func__, subpage, len, addr, value);\n#endif\n    stn_p(buf, len, value);\n    return flatview_write(uc, subpage->fv, addr + subpage->base, attrs, buf, len);\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":225616,"func":"GF_Err edts_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":512649,"func":"longlong Item_func_case::int_op()\n{\n  DBUG_ASSERT(fixed == 1);\n  Item *item= find_item();\n  longlong res;\n\n  if (!item)\n  {\n    null_value=1;\n    return 0;\n  }\n  res=item->val_int();\n  null_value=item->null_value;\n  return res;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":232305,"func":"\nGF_Err gf_isom_box_dump(void *ptr, FILE * trace)\n{\n\tGF_Box *a = (GF_Box *) ptr;\n\n\tif (!a) {\n\t\tgf_fprintf(trace, \"<!--ERROR: NULL Box Found-->\\n\");\n\t\treturn GF_OK;\n\t}\n\tif (!a->registry) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[isom] trying to dump box %s not registered\\n\", gf_4cc_to_str(a->type) ));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\ta->registry->dump_fn(a, trace);\n\treturn GF_OK;","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":234812,"func":"static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)\n{\n\tif (!(type & BTRFS_BLOCK_GROUP_RAID56_MASK))\n\t\treturn;\n\n\tbtrfs_set_fs_incompat(info, RAID56);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":226278,"func":"GF_Err nmhd_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":242956,"func":"static int ssl_check_record_type( uint8_t record_type )\n{\n    if( record_type != MBEDTLS_SSL_MSG_HANDSHAKE &&\n        record_type != MBEDTLS_SSL_MSG_ALERT &&\n        record_type != MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC &&\n        record_type != MBEDTLS_SSL_MSG_APPLICATION_DATA )\n    {\n        return( MBEDTLS_ERR_SSL_INVALID_RECORD );\n    }\n\n    return( 0 );\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":230276,"func":"njs_array_iterator_call(njs_vm_t *vm, njs_iterator_args_t *args,\n    const njs_value_t *entry, uint32_t n)\n{\n    njs_value_t  arguments[3];\n\n    \/* GC: array elt, array *\/\n\n    arguments[0] = *entry;\n    njs_set_number(&arguments[1], n);\n    arguments[2] = *args->value;\n\n    return njs_function_call(vm, args->function, args->argument, arguments, 3,\n                             &vm->retval);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":244302,"func":"void dOps_box_del(GF_Box *s)\n{\n\tGF_OpusSpecificBox *ptr = (GF_OpusSpecificBox *)s;\n\tif (ptr) gf_free(ptr);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":512273,"func":"  bool agg_arg_charsets_for_comparison(DTCollation &c,\n                                       Item **items, uint nitems,\n                                       int item_sep= 1)\n  {\n    return Type_std_attributes::\n      agg_arg_charsets_for_comparison(c, func_name(), items, nitems, item_sep);\n  }","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":506442,"func":"mech_rpa_auth_continue(struct auth_request *auth_request,\n\t\t       const unsigned char *data, size_t data_size)\n{\n\tstruct rpa_auth_request *request =\n\t\t(struct rpa_auth_request *)auth_request;\n\n\tswitch (request->phase) {\n\tcase 0:\n\t\tmech_rpa_auth_phase1(auth_request, data, data_size);\n\t\tbreak;\n\tcase 1:\n\t\tmech_rpa_auth_phase2(auth_request, data, data_size);\n\t\tbreak;\n\tcase 2:\n\t\tmech_rpa_auth_phase3(auth_request, data, data_size);\n\t\tbreak;\n\tdefault:\n\t\tauth_request_fail(auth_request);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":436126,"func":"static int io_unlinkat_prep(struct io_kiocb *req,\n\t\t\t    const struct io_uring_sqe *sqe)\n{\n\tstruct io_unlink *un = &req->unlink;\n\tconst char __user *fname;\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->off || sqe->len || sqe->buf_index)\n\t\treturn -EINVAL;\n\tif (unlikely(req->flags & REQ_F_FIXED_FILE))\n\t\treturn -EBADF;\n\n\tun->dfd = READ_ONCE(sqe->fd);\n\n\tun->flags = READ_ONCE(sqe->unlink_flags);\n\tif (un->flags & ~AT_REMOVEDIR)\n\t\treturn -EINVAL;\n\n\tfname = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\tun->filename = getname(fname);\n\tif (IS_ERR(un->filename))\n\t\treturn PTR_ERR(un->filename);\n\n\treq->flags |= REQ_F_NEED_CLEANUP;\n\treturn 0;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":238579,"func":"static int set_callee_state(struct bpf_verifier_env *env,\n\t\t\t    struct bpf_func_state *caller,\n\t\t\t    struct bpf_func_state *callee, int insn_idx)\n{\n\tint i;\n\n\t\/* copy r1 - r5 args that callee can access.  The copy includes parent\n\t * pointers, which connects us up to the liveness chain\n\t *\/\n\tfor (i = BPF_REG_1; i <= BPF_REG_5; i++)\n\t\tcallee->regs[i] = caller->regs[i];\n\treturn 0;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":254894,"func":"DocumentSource::GetNextResult DocumentSourceGroup::getNextStandard() {\n    \/\/ Not spilled, and not streaming.\n    if (_groups->empty())\n        return GetNextResult::makeEOF();\n\n    Document out = makeDocument(groupsIterator->first, groupsIterator->second, pExpCtx->needsMerge);\n\n    if (++groupsIterator == _groups->end())\n        dispose();\n\n    return std::move(out);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":226032,"func":"GF_Err uuid_box_size(GF_Box *s)\n{\n\tGF_UnknownUUIDBox*ptr = (GF_UnknownUUIDBox*)s;\n\tptr->size += ptr->dataSize;\n\treturn GF_OK;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":257704,"func":"static handler_t wstunnel_create_env(gw_handler_ctx *gwhctx) {\n    handler_ctx *hctx = (handler_ctx *)gwhctx;\n    request_st * const r = hctx->gw.r;\n    handler_t rc;\n    if (0 == r->reqbody_length || r->http_version > HTTP_VERSION_1_1) {\n        http_response_upgrade_read_body_unknown(r);\n        chunkqueue_append_chunkqueue(&r->reqbody_queue, &r->read_queue);\n    }\n    rc = mod_wstunnel_handshake_create_response(hctx);\n    if (rc != HANDLER_GO_ON) return rc;\n\n    r->http_status = (r->http_version > HTTP_VERSION_1_1)\n      ? 200  \/* OK (response status for CONNECT) *\/\n      : 101; \/* Switching Protocols *\/\n    r->resp_body_started = 1;\n\n    hctx->ping_ts = log_monotonic_secs;\n    gw_set_transparent(&hctx->gw);\n\n    return HANDLER_GO_ON;\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":225447,"func":"static int vidioc_subscribe_event(struct v4l2_fh *fh,\n\t\t\t\t  const struct v4l2_event_subscription *sub)\n{\n\tswitch (sub->type) {\n\tcase V4L2_EVENT_CTRL:\n\t\treturn v4l2_ctrl_subscribe_event(fh, sub);\n\t}\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":326620,"func":"archive_write_disk_set_skip_file(struct archive *_a, la_int64_t d, la_int64_t i)\n{\n\tstruct archive_write_disk *a = (struct archive_write_disk *)_a;\n\tarchive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,\n\t    ARCHIVE_STATE_ANY, \"archive_write_disk_set_skip_file\");\n\ta->skip_file_set = 1;\n\ta->skip_file_dev = d;\n\ta->skip_file_ino = i;\n\treturn (ARCHIVE_OK);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":393524,"func":"static SQInteger obj_clear(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_clear(v,-1)) ? 1 : SQ_ERROR;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":366233,"func":"int may_umount(struct vfsmount *mnt)\n{\n\tint ret = 1;\n\tdown_read(&namespace_sem);\n\tlock_mount_hash();\n\tif (propagate_mount_busy(real_mount(mnt), 2))\n\t\tret = 0;\n\tunlock_mount_hash();\n\tup_read(&namespace_sem);\n\treturn ret;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":281137,"func":"static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,\n\t\t\t\t\t\tint tos, int oif,\n\t\t\t\t\t\txfrm_address_t *prev_saddr,\n\t\t\t\t\t\txfrm_address_t *prev_daddr,\n\t\t\t\t\t\tint family)\n{\n\tstruct net *net = xs_net(x);\n\txfrm_address_t *saddr = &x->props.saddr;\n\txfrm_address_t *daddr = &x->id.daddr;\n\tstruct dst_entry *dst;\n\n\tif (x->type->flags & XFRM_TYPE_LOCAL_COADDR) {\n\t\tsaddr = x->coaddr;\n\t\tdaddr = prev_daddr;\n\t}\n\tif (x->type->flags & XFRM_TYPE_REMOTE_COADDR) {\n\t\tsaddr = prev_saddr;\n\t\tdaddr = x->coaddr;\n\t}\n\n\tdst = __xfrm_dst_lookup(net, tos, oif, saddr, daddr, family);\n\n\tif (!IS_ERR(dst)) {\n\t\tif (prev_saddr != saddr)\n\t\t\tmemcpy(prev_saddr, saddr,  sizeof(*prev_saddr));\n\t\tif (prev_daddr != daddr)\n\t\t\tmemcpy(prev_daddr, daddr,  sizeof(*prev_daddr));\n\t}\n\n\treturn dst;\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":241071,"func":"static int _lockfile(int mode, int *fdp, pid_t *locked_by)\n{\n\tstruct flock lock;\n\tint fd, rv;\n\n\n\t\/* After reboot the directory may not yet exist.\n\t * Try to create it, but ignore errors. *\/\n\tif (strncmp(cl.lockfile, BOOTH_RUN_DIR,\n\t\t\t\tstrlen(BOOTH_RUN_DIR)) == 0)\n\t\t(void)mkdir(BOOTH_RUN_DIR, 0775);\n\n\n\tif (locked_by)\n\t\t*locked_by = 0;\n\n\t*fdp = -1;\n\tfd = open(cl.lockfile, mode, 0664);\n\tif (fd < 0)\n\t\treturn errno;\n\n\t*fdp = fd;\n\n\tlock.l_type = F_WRLCK;\n\tlock.l_start = 0;\n\tlock.l_whence = SEEK_SET;\n\tlock.l_len = 0;\n\tlock.l_pid = 0;\n\n\n\tif (fcntl(fd, F_SETLK, &lock) == 0)\n\t\treturn 0;\n\n\trv = errno;\n\n\tif (locked_by)\n\t\tif (fcntl(fd, F_GETLK, &lock) == 0)\n\t\t\t*locked_by = lock.l_pid;\n\n\treturn rv;\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":218988,"func":"float QuantizedTypeMaxAsFloat(DataType data_type) {\n  switch (data_type) {\n    case DT_QINT8:\n      return Eigen::NumTraits<qint8>::highest();\n    case DT_QUINT8:\n      return Eigen::NumTraits<quint8>::highest();\n    case DT_QINT16:\n      return Eigen::NumTraits<qint16>::highest();\n    case DT_QUINT16:\n      return Eigen::NumTraits<quint16>::highest();\n    case DT_QINT32:\n      return Eigen::NumTraits<qint32>::highest();\n    default:\n      return 0.0f;\n  }\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":226242,"func":"GF_Err dimm_box_size(GF_Box *s)\n{\n\ts->size += 8;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":458988,"func":"http_SetH(struct http *to, unsigned n, const char *header)\n{\n\n\tassert(n < to->nhd);\n\tAN(header);\n\tto->hd[n].b = TRUST_ME(header);\n\tto->hd[n].e = strchr(to->hd[n].b, '\\0');\n\tto->hdf[n] = 0;\n\thttp_VSLH(to, n);\n\tif (n == HTTP_HDR_PROTO)\n\t\thttp_Proto(to);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":336113,"func":"static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n\tstruct net_device *dev)\n{\n\tstruct ip6_tnl *t = netdev_priv(dev);\n\tstruct net_device_stats *stats = &t->dev->stats;\n\tint ret;\n\n\tif (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))\n\t\tgoto tx_err;\n\n\tswitch (skb->protocol) {\n\tcase htons(ETH_P_IP):\n\t\tret = ip6gre_xmit_ipv4(skb, dev);\n\t\tbreak;\n\tcase htons(ETH_P_IPV6):\n\t\tret = ip6gre_xmit_ipv6(skb, dev);\n\t\tbreak;\n\tdefault:\n\t\tret = ip6gre_xmit_other(skb, dev);\n\t\tbreak;\n\t}\n\n\tif (ret < 0)\n\t\tgoto tx_err;\n\n\treturn NETDEV_TX_OK;\n\ntx_err:\n\tstats->tx_errors++;\n\tstats->tx_dropped++;\n\tkfree_skb(skb);\n\treturn NETDEV_TX_OK;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":310126,"func":"usage(void)\n{\n    static const char *msg[] =\n    {\n\t\"Usage: dots_xcurses [options]\"\n\t,\"\"\n\t,\"Options:\"\n\t,\" -T TERM  override $TERM\"\n#if HAVE_USE_DEFAULT_COLORS\n\t,\" -d       invoke use_default_colors()\"\n#endif\n#if HAVE_USE_ENV\n\t,\" -e       allow environment $LINES \/ $COLUMNS\"\n#endif\n\t,\" -m SIZE  set margin (default: 2)\"\n\t,\" -r SECS  self-interrupt\/exit after specified number of seconds\"\n\t,\" -s MSECS delay 1% of the time (default: 1 msecs)\"\n#if HAVE_ALLOC_PAIR\n\t,\" -x       use alloc_pair() rather than init_pair()\"\n#endif\n    };\n    size_t n;\n\n    for (n = 0; n < SIZEOF(msg); n++)\n\tfprintf(stderr, \"%s\\n\", msg[n]);\n\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":440892,"func":"FatalError(const char *f, ...)\n{\n    va_list args;\n    va_list args2;\n    static Bool beenhere = FALSE;\n\n    if (beenhere)\n        ErrorFSigSafe(\"\\nFatalError re-entered, aborting\\n\");\n    else\n        ErrorFSigSafe(\"\\nFatal server error:\\n\");\n\n    va_start(args, f);\n\n    \/* Make a copy for OsVendorFatalError *\/\n    va_copy(args2, args);\n\n#ifdef __APPLE__\n    {\n        va_list apple_args;\n\n        va_copy(apple_args, args);\n        (void)vsnprintf(__crashreporter_info_buff__,\n                        sizeof(__crashreporter_info_buff__), f, apple_args);\n        va_end(apple_args);\n    }\n#endif\n    VErrorFSigSafe(f, args);\n    va_end(args);\n    ErrorFSigSafe(\"\\n\");\n    if (!beenhere)\n        OsVendorFatalError(f, args2);\n    va_end(args2);\n    if (!beenhere) {\n        beenhere = TRUE;\n        AbortServer();\n    }\n    else\n        OsAbort();\n \/*NOTREACHED*\/}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":205823,"func":"ipf_extract_frags_from_batch(struct ipf *ipf, struct dp_packet_batch *pb,\n                             ovs_be16 dl_type, uint16_t zone, long long now,\n                             uint32_t hash_basis)\n{\n    const size_t pb_cnt = dp_packet_batch_size(pb);\n    int pb_idx; \/* Index in a packet batch. *\/\n    struct dp_packet *pkt;\n\n    DP_PACKET_BATCH_REFILL_FOR_EACH (pb_idx, pb_cnt, pkt, pb) {\n        if (OVS_UNLIKELY((dl_type == htons(ETH_TYPE_IP) &&\n                          ipf_is_valid_v4_frag(ipf, pkt))\n                          ||\n                          (dl_type == htons(ETH_TYPE_IPV6) &&\n                          ipf_is_valid_v6_frag(ipf, pkt)))) {\n\n            ovs_mutex_lock(&ipf->ipf_lock);\n            if (!ipf_handle_frag(ipf, pkt, dl_type, zone, now, hash_basis)) {\n                dp_packet_batch_refill(pb, pkt, pb_idx);\n            }\n            ovs_mutex_unlock(&ipf->ipf_lock);\n        } else {\n            dp_packet_batch_refill(pb, pkt, pb_idx);\n        }\n    }\n}","target":1,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":218983,"func":"Status ConstantFolding::MaterializeOutputValues(\n    NodeDef* node, const GraphProperties& properties) {\n  const std::vector<OpInfo::TensorProperties>& output =\n      properties.GetOutputProperties(node->name());\n  if (output.size() != 1 || !output[0].has_value() ||\n      !IsFoldable(*node, &properties)) {\n    return Status::OK();\n  }\n\n  \/\/ If this is a trivial Identity node with a constant input, just route the\n  \/\/ input around it.\n  if (IsIdentity(*node)) {\n    NodeDef* input = node_map_->GetNode(node->input(0));\n    if (IsReallyConstant(*input)) {\n      std::vector<int> inputs_to_forward;\n      std::iota(inputs_to_forward.begin(), inputs_to_forward.end(), 0);\n      graph_modified_ = ForwardInputs(node, inputs_to_forward);\n      return Status::OK();\n    }\n  }\n  \/\/ Repurpose the existing node to be the constant.\n  \/\/ Device placement is preserved.\n  TensorProto value_copy = output[0].value();\n  return ReplaceOperationWithConstantTensor(output[0].dtype(), &value_copy,\n                                            node, graph_);\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":210203,"func":"static void *seq_buf_alloc(unsigned long size)\n{\n\treturn kvmalloc(size, GFP_KERNEL_ACCOUNT);\n}","target":1,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":508334,"func":"void Locked_tables_list::mark_table_for_reopen(THD *thd, TABLE *table)\n{\n  TABLE_SHARE *share= table->s;\n\n    for (TABLE_LIST *table_list= m_locked_tables;\n       table_list; table_list= table_list->next_global)\n  {\n    if (table_list->table->s == share)\n      table_list->table->internal_set_needs_reopen(true);\n  }\n  \/* This is needed in the case where lock tables where not used *\/\n  table->internal_set_needs_reopen(true);\n  some_table_marked_for_reopen= 1;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":400107,"func":"UserTerminalRouter::UserTerminalRouter(\n    shared_ptr<PipeSocketHandler> _socketHandler,\n    const SocketEndpoint &_routerEndpoint)\n    : socketHandler(_socketHandler) {\n  serverFd = *(socketHandler->listen(_routerEndpoint).begin());\n  FATAL_FAIL(::chown(_routerEndpoint.name().c_str(), getuid(), getgid()));\n  FATAL_FAIL(::chmod(_routerEndpoint.name().c_str(),\n                     S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP |\n                         S_IROTH | S_IWOTH | S_IXOTH));\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":230310,"func":"njs_array_prototype_iterator_obj(njs_vm_t *vm, njs_value_t *args,\n    njs_uint_t nargs, njs_index_t kind)\n{\n    njs_int_t    ret;\n    njs_value_t  *this;\n\n    this = njs_argument(args, 0);\n\n    ret = njs_value_to_object(vm, this);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    return njs_array_iterator_create(vm, this, &vm->retval, kind);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":242117,"func":"int LuaSettings::l_get_flags(lua_State *L)\n{\n\tNO_MAP_LOCK_REQUIRED;\n\tLuaSettings *o = checkobject(L, 1);\n\tstd::string key = std::string(luaL_checkstring(L, 2));\n\n\tu32 flags = 0;\n\tauto flagdesc = o->m_settings->getFlagDescFallback(key);\n\tif (o->m_settings->getFlagStrNoEx(key, flags, flagdesc)) {\n\t\tlua_newtable(L);\n\t\tint table = lua_gettop(L);\n\t\tfor (size_t i = 0; flagdesc[i].name; ++i) {\n\t\t\tlua_pushboolean(L, flags & flagdesc[i].flag);\n\t\t\tlua_setfield(L, table, flagdesc[i].name);\n\t\t}\n\t\tlua_pushvalue(L, table);\n\t} else {\n\t\tlua_pushnil(L);\n\t}\n\n\treturn 1;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":398526,"func":"static int abbrev_cmp(const void *a, const void *b) {\n\tconst RzBinDwarfAbbrevDecl *first = a;\n\tconst RzBinDwarfAbbrevDecl *second = b;\n\n\tif (first->offset > second->offset) {\n\t\treturn 1;\n\t} else if (first->offset < second->offset) {\n\t\treturn -1;\n\t} else {\n\t\treturn 0;\n\t}\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":229144,"func":"static void flush_queued_data(VirtIOSerialPort *port)\n{\n    assert(port);\n\n    if (!virtio_queue_ready(port->ovq)) {\n        return;\n    }\n    do_flush_queued_data(port, port->ovq, VIRTIO_DEVICE(port->vser));\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":281095,"func":"static inline int xfrm_init_path(struct xfrm_dst *path, struct dst_entry *dst,\n\t\t\t\t int nfheader_len)\n{\n\tconst struct xfrm_policy_afinfo *afinfo =\n\t\txfrm_policy_get_afinfo(dst->ops->family);\n\tint err;\n\n\tif (!afinfo)\n\t\treturn -EINVAL;\n\n\terr = afinfo->init_path(path, dst, nfheader_len);\n\n\trcu_read_unlock();\n\n\treturn err;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":316970,"func":"static int selinux_inode_rename(struct inode *old_inode, struct dentry *old_dentry,\n\t\t\t\tstruct inode *new_inode, struct dentry *new_dentry)\n{\n\treturn may_rename(old_inode, old_dentry, new_inode, new_dentry);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":442577,"func":"to_physical(const void *ptr)\n{\n    return (uintptr_t) ptr;\n}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":318954,"func":"f_test_null_blob(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    rettv->v_type = VAR_BLOB;\n    rettv->vval.v_blob = NULL;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":90876,"func":"  const std::set<GURL>& modified_origins() const { return modified_origins_; }\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":427194,"func":"static void lastlistfield (FuncState *fs, ConsControl *cc) {\n  if (cc->tostore == 0) return;\n  if (hasmultret(cc->v.k)) {\n    luaK_setmultret(fs, &cc->v);\n    luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET);\n    cc->na--;  \/* do not count last expression (unknown number of elements) *\/\n  }\n  else {\n    if (cc->v.k != VVOID)\n      luaK_exp2nextreg(fs, &cc->v);\n    luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore);\n  }\n  cc->na += cc->tostore;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":225493,"func":"NodeDef* MutableGraphView::GetOrCreateIdentityConsumingSwitch(\n    const OutputPort& fanin) {\n  \/\/ We haven't found an existing node where we can anchor the control\n  \/\/ dependency: add a new identity node.\n  string identity_name = GeneratedNameForIdentityConsumingSwitch(fanin);\n  NodeDef* identity_node = GetNode(identity_name);\n  if (identity_node == nullptr) {\n    NodeDef new_node;\n    new_node.set_name(identity_name);\n    new_node.set_op(\"Identity\");\n    new_node.set_device(fanin.node->device());\n    (*new_node.mutable_attr())[\"T\"].set_type(fanin.node->attr().at(\"T\").type());\n    new_node.add_input(TensorIdToString({fanin.node->name(), fanin.port_id}));\n    identity_node = AddNode(std::move(new_node));\n  }\n  return identity_node;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":512803,"func":"void Item_func_case::reorder_args(uint start)\n{\n  \/*\n    Reorder args, to have at first the optional CASE expression, then all WHEN\n    expressions, then all THEN expressions. And the optional ELSE expression\n    at the end.\n\n    We reorder an even number of arguments, starting from start.\n  *\/\n  uint count = (arg_count - start) \/ 2;\n  const size_t size= sizeof(Item*) * count * 2;\n  Item **arg_buffer= (Item **)my_safe_alloca(size);\n  memcpy(arg_buffer, &args[start], size);\n  for (uint i= 0; i < count; i++)\n  {\n    args[start + i]= arg_buffer[i*2];\n    args[start + i + count]= arg_buffer[i*2 + 1];\n  }\n  my_safe_afree(arg_buffer, size);\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":400771,"func":"void iov_iter_xarray(struct iov_iter *i, unsigned int direction,\n\t\t     struct xarray *xarray, loff_t start, size_t count)\n{\n\tBUG_ON(direction & ~1);\n\t*i = (struct iov_iter) {\n\t\t.iter_type = ITER_XARRAY,\n\t\t.data_source = direction,\n\t\t.xarray = xarray,\n\t\t.xarray_start = start,\n\t\t.count = count,\n\t\t.iov_offset = 0\n\t};\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":254752,"func":"njs_typed_array_compare_u32(const void *a, const void *b, void *c)\n{\n    uint32_t  au, bu;\n\n    au = *(const uint32_t *) a;\n    bu = *(const uint32_t *) b;\n\n    return (au > bu) - (au < bu);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":248322,"func":"DLLIMPORT cfg_validate_callback_t cfg_set_validate_func(cfg_t *cfg, const char *name, cfg_validate_callback_t vf)\n{\n\tcfg_opt_t *opt;\n\tcfg_validate_callback_t oldvf;\n\n\topt = cfg_getopt_array(cfg->opts, cfg->flags, name);\n\tif (!opt)\n\t\treturn NULL;\n\n\toldvf = opt->validcb;\n\topt->validcb = vf;\n\n\treturn oldvf;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":459521,"func":"static void stack_map_free(struct bpf_map *map)\n{\n\tstruct bpf_stack_map *smap = container_of(map, struct bpf_stack_map, map);\n\n\tbpf_map_area_free(smap->elems);\n\tpcpu_freelist_destroy(&smap->freelist);\n\tbpf_map_area_free(smap);\n\tput_callchain_buffers();\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":468383,"func":"g_socket_client_set_timeout (GSocketClient *client,\n\t\t\t     guint          timeout)\n{\n  if (client->priv->timeout == timeout)\n    return;\n\n  client->priv->timeout = timeout;\n  g_object_notify (G_OBJECT (client), \"timeout\");\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":238443,"func":"static void scalar_min_max_lsh(struct bpf_reg_state *dst_reg,\n\t\t\t       struct bpf_reg_state *src_reg)\n{\n\tu64 umax_val = src_reg->umax_value;\n\tu64 umin_val = src_reg->umin_value;\n\n\t\/* scalar64 calc uses 32bit unshifted bounds so must be called first *\/\n\t__scalar64_min_max_lsh(dst_reg, umin_val, umax_val);\n\t__scalar32_min_max_lsh(dst_reg, umin_val, umax_val);\n\n\tdst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val);\n\t\/* We may learn something more from the var_off *\/\n\t__update_reg_bounds(dst_reg);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":502707,"func":"long SSL_CTX_set_timeout(SSL_CTX *s, long t)\n{\n    long l;\n    if (s == NULL)\n        return (0);\n    l = s->session_timeout;\n    s->session_timeout = t;\n    return (l);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":477974,"func":"static void simplestring_init_str(simplestring* string) {\n   string->str = (char*)malloc(SIMPLESTRING_INCR);\n   if(string->str) {\n      string->str[0] = 0;\n      string->len = 0;\n      string->size = SIMPLESTRING_INCR;\n   }\n   else {\n      string->size = 0;\n   }\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":386534,"func":"void DL_Dxf::writeDimStyleOverrides(DL_WriterA& dw,\n                             const DL_DimensionData& data) {\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(1001, \"ACAD\");\n        dw.dxfString(1000, \"DSTYLE\");\n        dw.dxfString(1002, \"{\");\n        if (data.type&128) {\n            \/\/ custom text position:\n            dw.dxfInt(1070, 279);\n            dw.dxfInt(1070, 2);\n        }\n        dw.dxfInt(1070, 144);\n        dw.dxfReal(1040, data.linearFactor);\n        dw.dxfInt(1070,40);\n        dw.dxfReal(1040, data.dimScale);\n        dw.dxfString(1002, \"}\");\n    }\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":241367,"func":"  void ValidateInputMatrixShapes(\n      OpKernelContext* context,\n      const TensorShapes& input_matrix_shapes) const final {\n    Base::ValidateSquareSolver(context, input_matrix_shapes);\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":391629,"func":"void dlpar_sysfs_exit(void)\n{\n\tsysfs_remove_group(dlpar_kobj, &dlpar_attr_group);\n\tkobject_put(dlpar_kobj);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":437289,"func":"compile_length_string_node(Node* node, regex_t* reg)\n{\n  int rlen, r, len, prev_len, slen, ambig;\n  UChar *p, *prev;\n  StrNode* sn;\n  OnigEncoding enc = reg->enc;\n\n  sn = STR_(node);\n  if (sn->end <= sn->s)\n    return 0;\n\n  ambig = NODE_STRING_IS_AMBIG(node);\n\n  p = prev = sn->s;\n  prev_len = enclen(enc, p);\n  p += prev_len;\n  slen = 1;\n  rlen = 0;\n\n  for (; p < sn->end; ) {\n    len = enclen(enc, p);\n    if (len == prev_len) {\n      slen++;\n    }\n    else {\n      r = add_compile_string_length(prev, prev_len, slen, reg, ambig);\n      rlen += r;\n      prev = p;\n      slen = 1;\n      prev_len = len;\n    }\n    p += len;\n  }\n\n  r = add_compile_string_length(prev, prev_len, slen, reg, ambig);\n  rlen += r;\n  return rlen;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":225999,"func":"void ctts_box_del(GF_Box *s)\n{\n\tGF_CompositionOffsetBox *ptr = (GF_CompositionOffsetBox *)s;\n\tif (ptr->entries) gf_free(ptr->entries);\n\tgf_free(ptr);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":317278,"func":"static int smack_socket_bind(struct socket *sock, struct sockaddr *address,\n\t\t\t\tint addrlen)\n{\n\tif (sock->sk != NULL && sock->sk->sk_family == PF_INET6) {\n\t\tif (addrlen < SIN6_LEN_RFC2133 ||\n\t\t    address->sa_family != AF_INET6)\n\t\t\treturn -EINVAL;\n\t\tsmk_ipv6_port_label(sock, address);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":226082,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nGF_Err dvvC_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn dvcC_box_write(s, bs);","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":225069,"func":"setKeepalivesIdle(PGconn *conn)\n{\n\tint\t\t\tidle;\n\n\tif (conn->keepalives_idle == NULL)\n\t\treturn 1;\n\n\tif (!parse_int_param(conn->keepalives_idle, &idle, conn,\n\t\t\t\t\t\t \"keepalives_idle\"))\n\t\treturn 0;\n\tif (idle < 0)\n\t\tidle = 0;\n\n#ifdef PG_TCP_KEEPALIVE_IDLE\n\tif (setsockopt(conn->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,\n\t\t\t\t   (char *) &idle, sizeof(idle)) < 0)\n\t{\n\t\tchar\t\tsebuf[PG_STRERROR_R_BUFLEN];\n\n\t\tappendPQExpBuffer(&conn->errorMessage,\n\t\t\t\t\t\t  libpq_gettext(\"%s(%s) failed: %s\\n\"),\n\t\t\t\t\t\t  \"setsockopt\",\n\t\t\t\t\t\t  PG_TCP_KEEPALIVE_IDLE_STR,\n\t\t\t\t\t\t  SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));\n\t\treturn 0;\n\t}\n#endif\n\n\treturn 1;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":234238,"func":"add_abbrev_attr (unsigned long    attribute,\n\t\t unsigned long    form,\n\t\t dwarf_signed_vma implicit_const,\n\t\t abbrev_list *    list)\n{\n  abbrev_attr *attr;\n\n  attr = (abbrev_attr *) xmalloc (sizeof (*attr));\n\n  attr->attribute      = attribute;\n  attr->form           = form;\n  attr->implicit_const = implicit_const;\n  attr->next           = NULL;\n\n  assert (list != NULL && list->last_abbrev != NULL);\n\n  if (list->last_abbrev->first_attr == NULL)\n    list->last_abbrev->first_attr = attr;\n  else\n    list->last_abbrev->last_attr->next = attr;\n\n  list->last_abbrev->last_attr = attr;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":226289,"func":"\nvoid sgpd_box_del(GF_Box *a)\n{\n\tGF_SampleGroupDescriptionBox *p = (GF_SampleGroupDescriptionBox *)a;\n\twhile (gf_list_count(p->group_descriptions)) {\n\t\tvoid *ptr = gf_list_last(p->group_descriptions);\n\t\tsgpd_del_entry(p->grouping_type, ptr);\n\t\tgf_list_rem_last(p->group_descriptions);\n\t}\n\tgf_list_del(p->group_descriptions);\n\tgf_free(p);","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":242613,"func":"Status GetBuffer(OpKernelContext* ctx, const NodeDef& ndef, Buffer** buf) {\n  auto rm = ctx->resource_manager();\n  ContainerInfo cinfo;\n\n  \/\/ Lambda for creating the Staging Area\n  auto create_fn = [&ndef](Buffer** ret) -> Status {\n    int64_t capacity;\n    int64_t memory_limit;\n    TF_RETURN_IF_ERROR(GetNodeAttr(ndef, \"capacity\", &capacity));\n    TF_RETURN_IF_ERROR(GetNodeAttr(ndef, \"memory_limit\", &memory_limit));\n    *ret = new Buffer(capacity, memory_limit);\n    return Status::OK();\n  };\n\n  TF_RETURN_IF_ERROR(cinfo.Init(rm, ndef, true \/* use name() *\/));\n  TF_RETURN_IF_ERROR(rm->LookupOrCreate<Buffer>(cinfo.container(), cinfo.name(),\n                                                buf, create_fn));\n  return Status::OK();\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":413587,"func":"static RList *recurse(RCore *core, RAnalBlock *from, RAnalBlock *dest) {\n\trecurse_bb (core, from->jump, dest);\n\trecurse_bb (core, from->fail, dest);\n\n\t\/* same for all calls *\/\n\t\/\/ TODO: RAnalBlock must contain a linked list of calls\n\treturn NULL;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":314509,"func":"PJ_DEF(unsigned) pjmedia_sdp_media_remove_all_attr(pjmedia_sdp_media *m,\n\t\t\t\t\t\t   const char *name)\n{\n    return pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, name);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":281146,"func":"static int xfrm_policy_flo_check(struct flow_cache_object *flo)\n{\n\tstruct xfrm_policy *pol = container_of(flo, struct xfrm_policy, flo);\n\n\treturn !pol->walk.dead;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":281158,"func":"static struct hlist_head *policy_hash_direct(struct net *net,\n\t\t\t\t\t     const xfrm_address_t *daddr,\n\t\t\t\t\t     const xfrm_address_t *saddr,\n\t\t\t\t\t     unsigned short family, int dir)\n{\n\tunsigned int hmask = net->xfrm.policy_bydst[dir].hmask;\n\tunsigned int hash;\n\tu8 dbits;\n\tu8 sbits;\n\n\t__get_hash_thresh(net, family, dir, &dbits, &sbits);\n\thash = __addr_hash(daddr, saddr, family, hmask, dbits, sbits);\n\n\treturn rcu_dereference_check(net->xfrm.policy_bydst[dir].table,\n\t\t     lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":281156,"func":"void xfrm_policy_unregister_afinfo(const struct xfrm_policy_afinfo *afinfo)\n{\n\tstruct dst_ops *dst_ops = afinfo->dst_ops;\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(xfrm_policy_afinfo); i++) {\n\t\tif (xfrm_policy_afinfo[i] != afinfo)\n\t\t\tcontinue;\n\t\tRCU_INIT_POINTER(xfrm_policy_afinfo[i], NULL);\n\t\tbreak;\n\t}\n\n\tsynchronize_rcu();\n\n\tdst_ops->kmem_cachep = NULL;\n\tdst_ops->check = NULL;\n\tdst_ops->negative_advice = NULL;\n\tdst_ops->link_failure = NULL;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":247727,"func":"  const std::string& expectedPeerCertChain() const { return expected_peer_cert_chain_; }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":234197,"func":"display_debug_types (struct dwarf_section *section, void *file)\n{\n  return process_debug_info (section, file, section->abbrev_sec, false, true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":404732,"func":"int close_fd_get_file(unsigned int fd, struct file **res)\n{\n\tstruct files_struct *files = current->files;\n\tint ret;\n\n\tspin_lock(&files->file_lock);\n\tret = __close_fd_get_file(fd, res);\n\tspin_unlock(&files->file_lock);\n\n\treturn ret;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":226400,"func":"\nvoid prhd_box_del(GF_Box *s)\n{\n\tgf_free(s);","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":402605,"func":"do_shutdown(context *ctx, int nsockets, struct pollfd *pollfds)\n{\n\tunlink(SOCKPATH);\n\tunlink(PIDFILE);\n\n\tfor (int i = 0; i < ctx->ntokennames; i++)\n\t\tfree(ctx->tokennames[i]);\n\tif (ctx->tokennames)\n\t\tfree(ctx->tokennames);\n\tctx->backup_cms->log(ctx->backup_cms, ctx->priority|LOG_NOTICE,\n\t\t\t\"pesignd exiting (pid %d)\", getpid());\n\n\txfree(ctx->errstr);\n\n\tfor (int i = 0; i < nsockets; i++)\n\t\tclose(pollfds[i].fd);\n\tfree(pollfds);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":513081,"func":"  virtual longlong val_time_packed(THD *thd)\n  {\n    return Time(thd, this, Time::Options_cmp(thd)).to_packed();\n  }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":317169,"func":"static struct inode_security_struct *inode_security(struct inode *inode)\n{\n\t__inode_security_revalidate(inode, NULL, true);\n\treturn selinux_inode(inode);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":308205,"func":"static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,\n\t\t\t       struct fastrpc_invoke_ctx *ctx,\n\t\t\t       u32 kernel, uint32_t handle)\n{\n\tstruct fastrpc_channel_ctx *cctx;\n\tstruct fastrpc_user *fl = ctx->fl;\n\tstruct fastrpc_msg *msg = &ctx->msg;\n\n\tcctx = fl->cctx;\n\tmsg->pid = fl->tgid;\n\tmsg->tid = current->pid;\n\n\tif (kernel)\n\t\tmsg->pid = 0;\n\n\tmsg->ctx = ctx->ctxid | fl->pd;\n\tmsg->handle = handle;\n\tmsg->sc = ctx->sc;\n\tmsg->addr = ctx->buf ? ctx->buf->phys : 0;\n\tmsg->size = roundup(ctx->msg_sz, PAGE_SIZE);\n\tfastrpc_context_get(ctx);\n\n\treturn rpmsg_send(cctx->rpdev->ept, (void *)msg, sizeof(*msg));\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":352968,"func":"UUIDValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tint i;\n\tif( in->bv_len != 36 ) {\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tfor( i=0; i<36; i++ ) {\n\t\tswitch(i) {\n\t\t\tcase 8:\n\t\t\tcase 13:\n\t\t\tcase 18:\n\t\t\tcase 23:\n\t\t\t\tif( in->bv_val[i] != '-' ) {\n\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif( !ASCII_HEX( in->bv_val[i]) ) {\n\t\t\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t\t\t}\n\t\t}\n\t}\n\t\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":387765,"func":"Method* InstanceKlass::find_method(const Array<Method*>* methods,\n                                   const Symbol* name,\n                                   const Symbol* signature) {\n  return InstanceKlass::find_method_impl(methods,\n                                         name,\n                                         signature,\n                                         find_overpass,\n                                         find_static,\n                                         find_private);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":466171,"func":"static int em_bsr(struct x86_emulate_ctxt *ctxt)\n{\n\tu8 zf;\n\n\t__asm__ (\"bsr %2, %0; setz %1\"\n\t\t : \"=r\"(ctxt->dst.val), \"=q\"(zf)\n\t\t : \"r\"(ctxt->src.val));\n\n\tctxt->eflags &= ~X86_EFLAGS_ZF;\n\tif (zf) {\n\t\tctxt->eflags |= X86_EFLAGS_ZF;\n\t\t\/* Disable writeback. *\/\n\t\tctxt->dst.type = OP_NONE;\n\t}\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":369930,"func":"static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int buflen)\n{\n\tint error = -EACCES;\n\tstruct inode *inode = dentry->d_inode;\n\tstruct path path;\n\n\t\/* Are we allowed to snoop on the tasks file descriptors? *\/\n\tif (!proc_fd_access_allowed(inode))\n\t\tgoto out;\n\n\terror = PROC_I(inode)->op.proc_get_link(dentry, &path);\n\tif (error)\n\t\tgoto out;\n\n\terror = do_proc_readlink(&path, buffer, buflen);\n\tpath_put(&path);\nout:\n\treturn error;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":359603,"func":"community_direct_str (int direct)\n{\n  switch (direct)\n    {\n    case COMMUNITY_DENY:\n      return \"deny\";\n    case COMMUNITY_PERMIT:\n      return \"permit\";\n    default:\n      return \"unknown\";\n    }\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":224591,"func":"Status MaxPool3DGradShape(shape_inference::InferenceContext* c) {\n  return UnchangedShapeWithRank(c, 5);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":463126,"func":"static char *get_token(struct parse_state *state, const char *extra)\n{\n    char *token;\n    char *p;\n\n    token = tok_next(&state->tok);\n    if (!token) {\n        parse_error(state, \"invalid annotation attributes\");\n        return NULL;\n    }\n\n    \/* check the token *\/\n    if (extra == NULL)\n        extra = \"\";\n    for (p = token ; *p && (isalnum(*p) || strchr(extra, *p)) ; p++)\n        ;\n    if (*p) {\n        state->context = p;\n        parse_error(state, \"invalid character\");\n        return NULL;\n    }\n\n    state->context = token;\n    return token;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":361754,"func":"static inline void em28xx_set_xclk_i2c_speed(struct em28xx *dev)\n{\n\tconst struct em28xx_board *board = &em28xx_boards[dev->model];\n\tu8 xclk = board->xclk, i2c_speed = board->i2c_speed;\n\n\t\/*\n\t * Those are the default values for the majority of boards\n\t * Use those values if not specified otherwise at boards entry\n\t *\/\n\tif (!xclk)\n\t\txclk = EM28XX_XCLK_IR_RC5_MODE |\n\t\t       EM28XX_XCLK_FREQUENCY_12MHZ;\n\n\tem28xx_write_reg(dev, EM28XX_R0F_XCLK, xclk);\n\n\tif (!i2c_speed)\n\t\ti2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |\n\t\t\t    EM28XX_I2C_FREQ_100_KHZ;\n\n\tdev->i2c_speed = i2c_speed & 0x03;\n\n\tif (!dev->board.is_em2800)\n\t\tem28xx_write_reg(dev, EM28XX_R06_I2C_CLK, i2c_speed);\n\tmsleep(50);\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":248323,"func":"DLLIMPORT int cfg_free_value(cfg_opt_t *opt)\n{\n\tif (!opt) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\tif (opt->comment && !is_set(CFGF_RESET, opt->flags)) {\n\t\tfree(opt->comment);\n\t\topt->comment = NULL;\n\t}\n\n\tif (opt->values) {\n\t\tunsigned int i;\n\n\t\tfor (i = 0; i < opt->nvalues; i++) {\n\t\t\tif (opt->type == CFGT_STR) {\n\t\t\t\tfree((void *)opt->values[i]->string);\n\t\t\t} else if (opt->type == CFGT_SEC) {\n\t\t\t\topt->values[i]->section->path = NULL; \/* Global search path *\/\n\t\t\t\tcfg_free(opt->values[i]->section);\n\t\t\t} else if (opt->type == CFGT_PTR && opt->freecb && opt->values[i]->ptr) {\n\t\t\t\t(opt->freecb) (opt->values[i]->ptr);\n\t\t\t}\n\t\t\tfree(opt->values[i]);\n\t\t}\n\t\tfree(opt->values);\n\t}\n\n\topt->values  = NULL;\n\topt->nvalues = 0;\n\n\treturn CFG_SUCCESS;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":254001,"func":"static void v4l2loopback_create_sysfs(struct video_device *vdev)\n{\n\tint res = 0;\n\n#define V4L2_SYSFS_CREATE(x)     res = device_create_file(&vdev->dev, &dev_attr_##x); if (res < 0) break\n\tif (!vdev)\n\t\treturn;\n\tdo {\n\t\tV4L2_SYSFS_CREATE(format);\n\t\tV4L2_SYSFS_CREATE(buffers);\n\t\tV4L2_SYSFS_CREATE(max_openers);\n\t\t\/* ... *\/\n\t} while (0);\n\n\tif (res >= 0)\n\t\treturn;\n\tdev_err(&vdev->dev, \"%s error: %d\\n\", __func__, res);\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":225402,"func":"static void pix_format_set_size(struct v4l2_pix_format *f,\n\t\t\t\tconst struct v4l2l_format *fmt,\n\t\t\t\tunsigned int width, unsigned int height)\n{\n\tf->width = width;\n\tf->height = height;\n\n\tif (fmt->flags & FORMAT_FLAGS_PLANAR) {\n\t\tf->bytesperline = width; \/* Y plane *\/\n\t\tf->sizeimage = (width * height * fmt->depth) >> 3;\n\t} else if (fmt->flags & FORMAT_FLAGS_COMPRESSED) {\n\t\t\/* doesn't make sense for compressed formats *\/\n\t\tf->bytesperline = 0;\n\t\tf->sizeimage = (width * height * fmt->depth) >> 3;\n\t} else {\n\t\tf->bytesperline = (width * fmt->depth) >> 3;\n\t\tf->sizeimage = height * f->bytesperline;\n\t}\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":356719,"func":"void Statement::Work_Bind(napi_env e, void* data) {\n    STATEMENT_INIT(Baton);\n\n    STATEMENT_MUTEX(mtx);\n    sqlite3_mutex_enter(mtx);\n    stmt->Bind(baton->parameters);\n    sqlite3_mutex_leave(mtx);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":226048,"func":"GF_Err hmhd_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_HintMediaHeaderBox *ptr = (GF_HintMediaHeaderBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u16(bs, ptr->maxPDUSize);\n\tgf_bs_write_u16(bs, ptr->avgPDUSize);\n\tgf_bs_write_u32(bs, ptr->maxBitrate);\n\tgf_bs_write_u32(bs, ptr->avgBitrate);\n\tgf_bs_write_u32(bs, ptr->slidingAverageBitrate);\n\treturn GF_OK;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":484712,"func":"uint32_t mobi_buffer_get_varlen_dec(MOBIBuffer *buf, size_t *len) {\n    return _buffer_get_varlen(buf, len, -1);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":374044,"func":"static bool check_buffer(RBinFile *bf, RBuffer *b) {\n\tut8 buf[4];\n\tr_buf_read_at (b, 0, buf, sizeof (buf));\n\treturn !memcmp (buf, \"\\x02\\xff\\x01\\xff\", 4);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":417109,"func":"void PlayerGeneric::setSampleShift(mp_sint32 shift)\n{\n\tsampleShift = shift;\n\tif (mixer)\n\t\tmixer->setSampleShift(shift);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":437337,"func":"add_rel_addr(regex_t* reg, int addr)\n{\n  RelAddrType ra = (RelAddrType )addr;\n\n  BB_ADD(reg, &ra, SIZE_RELADDR);\n  return 0;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":225849,"func":"\nGF_Err txtc_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TextConfigBox *ptr = (GF_TextConfigBox*)s;\n\tif ((u32)ptr->size >= (u32)0xFFFFFFFF) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid size %llu in txtc box\\n\", ptr->size));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\tptr->config = (char *)gf_malloc(sizeof(char)*((u32) ptr->size+1));\n\tif (!ptr->config) return GF_OUT_OF_MEM;\n\tgf_bs_read_data(bs, ptr->config, (u32) ptr->size);\n\tptr->config[ptr->size] = 0;\n\treturn GF_OK;","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":508332,"func":"check_and_update_routine_version(THD *thd, Sroutine_hash_entry *rt,\n                                 sp_head *sp)\n{\n  ulong spc_version= sp_cache_version();\n  \/* sp is NULL if there is no such routine. *\/\n  ulong version= sp ? sp->sp_cache_version() : spc_version;\n  \/*\n    If the version in the parse tree is stale,\n    or the version in the cache is stale and sp is not used,\n    we need to reprepare.\n    Sic: version != spc_version <--> sp is not NULL.\n  *\/\n  if (rt->m_sp_cache_version != version ||\n      (version != spc_version && !sp->is_invoked()))\n  {\n    if (thd->m_reprepare_observer &&\n        thd->m_reprepare_observer->report_error(thd))\n    {\n      \/*\n        Version of the sp cache is different from the\n        previous execution of the prepared statement, and it is\n        unacceptable for this SQLCOM. Error has been reported.\n      *\/\n      DBUG_ASSERT(thd->is_error());\n      return TRUE;\n    }\n    \/* Always maintain the latest cache version. *\/\n    rt->m_sp_cache_version= version;\n  }\n  return FALSE;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":512417,"func":"void Item_cond::neg_arguments(THD *thd)\n{\n  List_iterator<Item> li(list);\n  Item *item;\n  while ((item= li++))\t\t\/* Apply not transformation to the arguments *\/\n  {\n    Item *new_item= item->neg_transformer(thd);\n    if (!new_item)\n    {\n      if (!(new_item= new (thd->mem_root) Item_func_not(thd, item)))\n\treturn;\t\t\t\t\t\/\/ Fatal OEM error\n    }\n    (void) li.replace(new_item);\n  }\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":508860,"func":"int my_wc_mb_utf8_with_escape(CHARSET_INFO *cs, my_wc_t escape, my_wc_t wc,\n                              uchar *str, uchar *end)\n{\n  DBUG_ASSERT(escape > 0);\n  if (str + 1 >= end)\n    return MY_CS_TOOSMALL2;  \/\/ Not enough space, need at least two bytes.\n  *str= (uchar)escape;\n  int cnvres= my_charset_utf8_handler.wc_mb(cs, wc, str + 1, end);\n  if (cnvres > 0)\n    return cnvres + 1;       \/\/ The character was normally put\n  if (cnvres == MY_CS_ILUNI)\n    return MY_CS_ILUNI;      \/\/ Could not encode \"wc\" (e.g. non-BMP character)\n  DBUG_ASSERT(cnvres <= MY_CS_TOOSMALL);\n  return cnvres - 1;         \/\/ Not enough space\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":359478,"func":"DEFUN (clear_ip_bgp_all,\n       clear_ip_bgp_all_cmd,\n       \"clear ip bgp *\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all peers\\n\")\n{\n  if (argc == 1)\n    return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);    \n\n  return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":398530,"func":"RZ_API ut64 rz_bin_dwarf_line_header_get_spec_op_advance_pc(const RzBinDwarfLineHeader *header, ut8 opcode) {\n\trz_return_val_if_fail(header, 0);\n\tif (!header->line_range) {\n\t\t\/\/ to dodge division by zero\n\t\treturn 0;\n\t}\n\tut8 adj_opcode = rz_bin_dwarf_line_header_get_adj_opcode(header, opcode);\n\treturn (adj_opcode \/ header->line_range) * header->min_inst_len;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":263499,"func":"void sco_exit(void)\n{\n\tbt_procfs_cleanup(&init_net, \"sco\");\n\n\tdebugfs_remove(sco_debugfs);\n\n\thci_unregister_cb(&sco_cb);\n\n\tbt_sock_unregister(BTPROTO_SCO);\n\n\tproto_unregister(&sco_proto);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":421394,"func":"static void parray(int d, js_Ast *list)\n{\n\tpc('[');\n\twhile (list) {\n\t\tassert(list->type == AST_LIST);\n\t\tpexpi(d, COMMA, list->a);\n\t\tlist = list->b;\n\t\tif (list)\n\t\t\tcomma();\n\t}\n\tpc(']');\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":338214,"func":"Name WasmBinaryBuilder::getExceptionTargetName(int32_t offset) {\n  BYN_TRACE(\"getExceptionTarget \" << offset << std::endl);\n  \/\/ We always start parsing a function by creating a block label and pushing it\n  \/\/ in breakStack in getBlockOrSingleton, so if a 'delegate''s target is that\n  \/\/ block, it does not mean it targets that block; it throws to the caller.\n  if (breakStack.size() - 1 == size_t(offset)) {\n    return DELEGATE_CALLER_TARGET;\n  }\n  size_t index = breakStack.size() - 1 - offset;\n  if (index > breakStack.size()) {\n    throwError(\"bad try index (high)\");\n  }\n  BYN_TRACE(\"exception target \" << breakStack[index].name << std::endl);\n  auto& ret = breakStack[index];\n  \/\/ if the delegate\/rethrow is in literally unreachable code, then we will not\n  \/\/ emit it anyhow, so do not note that the target has a reference to it\n  if (!willBeIgnored) {\n    exceptionTargetNames.insert(ret.name);\n  }\n  return ret.name;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":432261,"func":"int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,\n                          int flags, CPUWatchpoint **watchpoint)\n{\n#if 0\n    CPUWatchpoint *wp;\n\n    \/* forbid ranges which are empty or run off the end of the address space *\/\n    if (len == 0 || (addr + len - 1) < addr) {\n        error_report(\"tried to set invalid watchpoint at %\"\n                     VADDR_PRIx \", len=%\" VADDR_PRIu, addr, len);\n        return -EINVAL;\n    }\n    wp = g_malloc(sizeof(*wp));\n\n    wp->vaddr = addr;\n    wp->len = len;\n    wp->flags = flags;\n\n    \/* keep all GDB-injected watchpoints in front *\/\n    if (flags & BP_GDB) {\n        QTAILQ_INSERT_HEAD(&cpu->watchpoints, wp, entry);\n    } else {\n        QTAILQ_INSERT_TAIL(&cpu->watchpoints, wp, entry);\n    }\n\n    tlb_flush_page(cpu, addr);\n\n    if (watchpoint)\n        *watchpoint = wp;\n#endif\n\n    return 0;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":411779,"func":"handle_get_property  (GDBusConnection       *connection,\n                      const gchar           *sender,\n                      const gchar           *object_path,\n                      const gchar           *interface_name,\n                      const gchar           *property_name,\n                    GError **error,\n                    gpointer               user_data)\n{\n  A11yBusLauncher *app = user_data;\n\n  if (g_strcmp0 (property_name, \"IsEnabled\") == 0)\n    return g_variant_new (\"b\", app->a11y_enabled);\n  else if (g_strcmp0 (property_name, \"ScreenReaderEnabled\") == 0)\n    return g_variant_new (\"b\", app->screen_reader_enabled);\n  else\n    return NULL;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":248766,"func":"static char *sanitize_cookie_path(const char *cookie_path)\n{\n  size_t len;\n  char *new_path = strdup(cookie_path);\n  if(!new_path)\n    return NULL;\n\n  \/* some stupid site sends path attribute with '\"'. *\/\n  len = strlen(new_path);\n  if(new_path[0] == '\\\"') {\n    memmove((void *)new_path, (const void *)(new_path + 1), len);\n    len--;\n  }\n  if(len && (new_path[len - 1] == '\\\"')) {\n    new_path[len - 1] = 0x0;\n    len--;\n  }\n\n  \/* RFC6265 5.2.4 The Path Attribute *\/\n  if(new_path[0] != '\/') {\n    \/* Let cookie-path be the default-path. *\/\n    strstore(&new_path, \"\/\");\n    return new_path;\n  }\n\n  \/* convert \/hoge\/ to \/hoge *\/\n  if(len && new_path[len - 1] == '\/') {\n    new_path[len - 1] = 0x0;\n  }\n\n  return new_path;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":349870,"func":"static int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed)\n{\n\tu32 val = aq_hw_read_reg(self, HW_ATL_MPI_CONTROL_ADR);\n\n\tval = val & ~HW_ATL_MPI_SPEED_MSK;\n\tval |= speed << HW_ATL_MPI_SPEED_SHIFT;\n\taq_hw_write_reg(self, HW_ATL_MPI_CONTROL_ADR, val);\n\n\treturn 0;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":222493,"func":"string DebugString(gtl::ArraySlice<NodeDef> instantiated_func_nodes) {\n  std::vector<const NodeDef*> ptrs;\n  for (const NodeDef& n : instantiated_func_nodes) {\n    ptrs.push_back(&n);\n  }\n  return Print(ptrs);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":384790,"func":"vim_isIDc(int c)\n{\n    return (c > 0 && c < 0x100 && (g_chartab[c] & CT_ID_CHAR));\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":336619,"func":"static void reds_get_spice_ticket(RedLinkInfo *link)\n{\n    red_stream_async_read(link->stream,\n                          (uint8_t *)&link->tiTicketing.encrypted_ticket.encrypted_data,\n                          link->tiTicketing.rsa_size, reds_handle_ticket, link);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":512754,"func":"  bool set_fields_as_dependent_processor(void *arg)\n  {\n    if (!(used_tables() & OUTER_REF_TABLE_BIT))\n    {\n      depended_from= (st_select_lex *) arg;\n      item_equal= NULL;\n    }\n    return 0;\n  }","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":359431,"func":"DEFUN (ip_extcommunity_list_expanded,\n       ip_extcommunity_list_expanded_cmd,\n       \"ip extcommunity-list <100-500> (deny|permit) .LINE\",\n       IP_STR\n       EXTCOMMUNITY_LIST_STR\n       \"Extended Community list number (expanded)\\n\"\n       \"Specify community to reject\\n\"\n       \"Specify community to accept\\n\"\n       \"An ordered list as a regular-expression\\n\")\n{\n  return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":224231,"func":"R_API void r_io_bank_free(RIOBank *bank) {\n\tif (bank) {\n\t\tr_queue_free (bank->todo);\n\t\tr_list_free (bank->maprefs);\n\t\tr_crbtree_free (bank->submaps);\n\t\tfree (bank->name);\n\t\tfree (bank);\n\t}\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":463051,"func":"static void sungem_send_packet(SunGEMState *s, const uint8_t *buf,\n                               int size)\n{\n    NetClientState *nc = qemu_get_queue(s->nic);\n\n    if (s->macregs[MAC_XIFCFG >> 2] & MAC_XIFCFG_LBCK) {\n        qemu_receive_packet(nc, buf, size);\n    } else {\n        qemu_send_packet(nc, buf, size);\n    }\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":221150,"func":"GF_AV1Config *gf_odf_av1_cfg_read(u8 *dsi, u32 dsi_size)\n{\n\tGF_BitStream *bs = gf_bs_new(dsi, dsi_size, GF_BITSTREAM_READ);\n\tGF_AV1Config *cfg = gf_odf_av1_cfg_read_bs(bs);\n\tgf_bs_del(bs);\n\treturn cfg;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":359574,"func":"DEFUN (neighbor_shutdown,\n       neighbor_shutdown_cmd,\n       NEIGHBOR_CMD2 \"shutdown\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Administratively shut down this neighbor\\n\")\n{\n  return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":307861,"func":"void ciEnv::record_out_of_memory_failure() {\n  \/\/ If memory is low, we stop compiling methods.\n  record_method_not_compilable(\"out of memory\");\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":432233,"func":"static bool flatview_access_valid(struct uc_struct *uc, FlatView *fv, hwaddr addr, hwaddr len,\n                                  bool is_write, MemTxAttrs attrs)\n{\n    MemoryRegion *mr;\n    hwaddr l, xlat;\n\n    while (len > 0) {\n        l = len;\n        mr = flatview_translate(uc, fv, addr, &xlat, &l, is_write, attrs);\n        if (!memory_access_is_direct(mr, is_write)) {\n            l = memory_access_size(mr, l, addr);\n            if (!memory_region_access_valid(uc, mr, xlat, l, is_write, attrs)) {\n                return false;\n            }\n        }\n\n        len -= l;\n        addr += l;\n    }\n    return true;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":234771,"func":"static void close_fs_devices(struct btrfs_fs_devices *fs_devices)\n{\n\tstruct btrfs_device *device, *tmp;\n\n\tlockdep_assert_held(&uuid_mutex);\n\n\tif (--fs_devices->opened > 0)\n\t\treturn;\n\n\tlist_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list)\n\t\tbtrfs_close_one_device(device);\n\n\tWARN_ON(fs_devices->open_devices);\n\tWARN_ON(fs_devices->rw_devices);\n\tfs_devices->opened = 0;\n\tfs_devices->seeding = false;\n\tfs_devices->fs_info = NULL;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":442789,"func":"static void FindWin32CACert(struct Configurable *config,\n                            const char *bundle_file)\n{\n  \/* only check for cert file if \"we\" support SSL *\/\n  if(curlinfo->features & CURL_VERSION_SSL) {\n    DWORD buflen;\n    char *ptr = NULL;\n    char *retval = (char *) malloc(sizeof (TCHAR) * (MAX_PATH + 1));\n    if (!retval)\n      return;\n    retval[0] = '\\0';\n    buflen = SearchPathA(NULL, bundle_file, NULL, MAX_PATH+2, retval, &ptr);\n    if (buflen > 0) {\n      GetStr(&config->cacert, retval);\n    }\n    free(retval);\n  }\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":473866,"func":"get_case_fold_codes_by_str(OnigCaseFoldType flag,\n\t\t\t   const OnigUChar* p, const OnigUChar* end,\n\t\t\t   OnigCaseFoldCodeItem items[],\n\t\t\t   OnigEncoding enc ARG_UNUSED)\n{\n  return onigenc_get_case_fold_codes_by_str_with_map(\n\t     sizeof(CaseFoldMap)\/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,\n\t     flag, p, end, items);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":344819,"func":"format_absolute_time(uint64_t t, char *buf, size_t len)\n{\n\ttime_t tt = t > SSH_TIME_T_MAX ? SSH_TIME_T_MAX : t;\n\tstruct tm tm;\n\n\tlocaltime_r(&tt, &tm);\n\tstrftime(buf, len, \"%Y-%m-%dT%H:%M:%S\", &tm);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":424930,"func":"static void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val)\n{\n\twritel(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":225977,"func":"GF_Box *stsd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SampleDescriptionBox, GF_ISOM_BOX_TYPE_STSD);\n\ttmp->child_boxes = gf_list_new();\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":359423,"func":"DEFUN (no_neighbor_nexthop_self,\n       no_neighbor_nexthop_self_cmd,\n       NO_NEIGHBOR_CMD2 \"next-hop-self\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Disable the next hop calculation for this neighbor\\n\")\n{\n  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":508351,"func":"TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,\n                                thr_lock_type lock_type, uint flags,\n                                Prelocking_strategy *prelocking_strategy)\n{\n  TABLE_LIST *save_next_global;\n  DBUG_ENTER(\"open_n_lock_single_table\");\n\n  \/* Remember old 'next' pointer. *\/\n  save_next_global= table_l->next_global;\n  \/* Break list. *\/\n  table_l->next_global= NULL;\n\n  \/* Set requested lock type. *\/\n  table_l->lock_type= lock_type;\n  \/* Allow to open real tables only. *\/\n  table_l->required_type= FRMTYPE_TABLE;\n\n  \/* Open the table. *\/\n  if (open_and_lock_tables(thd, table_l, FALSE, flags,\n                           prelocking_strategy))\n    table_l->table= NULL; \/* Just to be sure. *\/\n\n  \/* Restore list. *\/\n  table_l->next_global= save_next_global;\n\n  DBUG_RETURN(table_l->table);\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":366248,"func":"void mnt_set_mountpoint(struct mount *mnt,\n\t\t\tstruct mountpoint *mp,\n\t\t\tstruct mount *child_mnt)\n{\n\tmp->m_count++;\n\tmnt_add_count(mnt, 1);\t\/* essentially, that's mntget *\/\n\tchild_mnt->mnt_mountpoint = mp->m_dentry;\n\tchild_mnt->mnt_parent = mnt;\n\tchild_mnt->mnt_mp = mp;\n\thlist_add_head(&child_mnt->mnt_mp_list, &mp->m_list);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":275476,"func":"njs_vm_retval_string(njs_vm_t *vm, njs_str_t *dst)\n{\n    if (vm->top_frame == NULL) {\n        \/* An exception was thrown during compilation. *\/\n\n        njs_vm_init(vm);\n    }\n\n    return njs_vm_value_string(vm, dst, &vm->retval);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":224983,"func":"conninfo_getval(PQconninfoOption *connOptions,\n\t\t\t\tconst char *keyword)\n{\n\tPQconninfoOption *option;\n\n\toption = conninfo_find(connOptions, keyword);\n\n\treturn option ? option->val : NULL;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":264370,"func":"inline const int32* TensorProtoData<qint32>(const TensorProto& t) {\n  static_assert(SaveTypeTraits<qint32>::supported,\n                \"Specified type qint32 not supported for Restore\");\n  return reinterpret_cast<const int32*>(t.int_val().data());\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":427238,"func":"static void checktoclose (FuncState *fs, int level) {\n  if (level != -1) {  \/* is there a to-be-closed variable? *\/\n    marktobeclosed(fs);\n    luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0);\n  }\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":489214,"func":"void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,\n\t\t\t   u32 parent, struct qstr *str)\n{\n\tint len;\n\n\tkey->cat.parent = cpu_to_be32(parent);\n\tif (str) {\n\t\thfsplus_asc2uni(sb, &key->cat.name, str->name, str->len);\n\t\tlen = be16_to_cpu(key->cat.name.length);\n\t} else {\n\t\tkey->cat.name.length = 0;\n\t\tlen = 0;\n\t}\n\tkey->key_len = cpu_to_be16(6 + 2 * len);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":513017,"func":"  const Type_handler *type_handler() const\n  {\n    return value_item->type_handler();\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":369190,"func":"static inline void io_commit_cqring(struct io_ring_ctx *ctx)\n{\n\t\/* order cqe stores with ring update *\/\n\tsmp_store_release(&ctx->rings->cq.tail, ctx->cached_cq_tail);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":411491,"func":"copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) {\n  size_t charsRequired = 0;\n  XML_Char *result;\n\n  \/* First determine how long the string is *\/\n  while (s[charsRequired] != 0) {\n    charsRequired++;\n  }\n  \/* Include the terminator *\/\n  charsRequired++;\n\n  \/* Now allocate space for the copy *\/\n  result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char));\n  if (result == NULL)\n    return NULL;\n  \/* Copy the original into place *\/\n  memcpy(result, s, charsRequired * sizeof(XML_Char));\n  return result;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":441817,"func":"SProcXkbLatchLockState(ClientPtr client)\n{\n    REQUEST(xkbLatchLockStateReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbLatchLockStateReq);\n    swaps(&stuff->deviceSpec);\n    swaps(&stuff->groupLatch);\n    return ProcXkbLatchLockState(client);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":393530,"func":"static SQInteger array_resize(HSQUIRRELVM v)\n{\n    SQObject &o = stack_get(v, 1);\n    SQObject &nsize = stack_get(v, 2);\n    SQObjectPtr fill;\n    if(sq_isnumeric(nsize)) {\n        SQInteger sz = tointeger(nsize);\n        if (sz<0)\n          return sq_throwerror(v, _SC(\"resizing to negative length\"));\n\n        if(sq_gettop(v) > 2)\n            fill = stack_get(v, 3);\n        _array(o)->Resize(sz,fill);\n        sq_settop(v, 1);\n        return 1;\n    }\n    return sq_throwerror(v, _SC(\"size must be a number\"));\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":379672,"func":"R_API int r_anal_var_count_args(RAnalFunction *fcn) {\n\tr_return_val_if_fail (fcn, 0); \/\/ No function implies no variables, but probably mistake\n\tint args = 0;\n\tvoid **it;\n\tr_pvector_foreach (&fcn->vars, it) {\n\t\tRAnalVar *var = *it;\n\t\tif (var->isarg) {\n\t\t\targs++;\n\t\t}\n\t}\n\treturn args;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":521457,"func":"inline uint16 readUnalignedLittleEndianShort (const void* buffer)\r\n{\r\n    auto data = readUnaligned<uint16> (buffer);\r\n    return ByteOrder::littleEndianShort (&data);\r\n}\r","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":463159,"func":"EXPORTED int annotate_state_commit(annotate_state_t **statep)\n{\n    int r = 0;\n    if (*statep)\n        r = annotate_commit((*statep)->d);\n\n    annotate_state_free(statep);\n    return r;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":230289,"func":"njs_array_string_add(njs_vm_t *vm, njs_array_t *array, const u_char *start,\n    size_t size, size_t length)\n{\n    njs_int_t  ret;\n\n    ret = njs_array_expand(vm, array, 0, 1);\n\n    if (njs_fast_path(ret == NJS_OK)) {\n        return njs_string_new(vm, &array->start[array->length++], start, size,\n                              length);\n    }\n\n    return ret;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":314762,"func":"cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,\n    const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,\n    const cdf_dir_t *dir, cdf_stream_t *scn)\n{\n\tsize_t i;\n\tconst cdf_directory_t *d;\n\tstatic const char name[] = \"\\05SummaryInformation\";\n\n\tfor (i = dir->dir_len; i > 0; i--)\n\t\tif (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&\n\t\t    cdf_namecmp(name, dir->dir_tab[i - 1].d_name, sizeof(name))\n\t\t    == 0)\n\t\t\tbreak;\n\n\tif (i == 0) {\n\t\tDPRINTF((\"Cannot find summary information section\\n\"));\n\t\terrno = ESRCH;\n\t\treturn -1;\n\t}\n\td = &dir->dir_tab[i - 1];\n\treturn cdf_read_sector_chain(info, h, sat, ssat, sst,\n\t    d->d_stream_first_sector, d->d_size, scn);\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":512250,"func":"  Item_time_literal(THD *thd, const Time *ltime, uint dec_arg):\n    Item_temporal_literal(thd, dec_arg),\n    cached_time(*ltime)\n  {\n    DBUG_ASSERT(cached_time.is_valid_time());\n    max_length= MIN_TIME_WIDTH + (decimals ? decimals + 1 : 0);\n  }","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":226283,"func":"\nGF_Box *vwid_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ViewIdentifierBox, GF_ISOM_BOX_TYPE_VWID);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":512535,"func":"int cmp_item_datetime::cmp_not_null(const Value *val)\n{\n  DBUG_ASSERT(!val->is_null());\n  DBUG_ASSERT(val->is_temporal());\n  return value != pack_time(&val->value.m_time);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":353230,"func":"void SplashOutputDev::updateAll(GfxState *state) {\n  updateLineDash(state);\n  updateLineJoin(state);\n  updateLineCap(state);\n  updateLineWidth(state);\n  updateFlatness(state);\n  updateMiterLimit(state);\n  updateStrokeAdjust(state);\n  updateFillColorSpace(state);\n  updateFillColor(state);\n  updateStrokeColorSpace(state);\n  updateStrokeColor(state);\n  needFontUpdate = true;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":220861,"func":"constexpr int min_log_x_output_bits(int input_bits) {\n  return input_bits > 90   ? 7\n         : input_bits > 44 ? 6\n         : input_bits > 21 ? 5\n         : input_bits > 10 ? 4\n         : input_bits > 4  ? 3\n         : input_bits > 1  ? 2\n                           : 1;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":366284,"func":"static void umount_mnt(struct mount *mnt)\n{\n\tput_mountpoint(unhash_mnt(mnt));\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":432348,"func":"static int i2c_ddc_tx(I2CSlave *i2c, uint8_t data)\n{\n    I2CDDCState *s = I2CDDC(i2c);\n    if (s->firstbyte) {\n        s->reg = data;\n        s->firstbyte = false;\n        DPRINTF(\"[EDID] Written new pointer: %u\\n\", data);\n        return 0;\n    }\n\n    \/* Ignore all writes *\/\n    s->reg++;\n    return 0;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":503982,"func":"void auth_request_var_expand(string_t *dest, const char *str,\n\t\t\t     const struct auth_request *auth_request,\n\t\t\t     auth_request_escape_func_t *escape_func)\n{\n\tauth_request_var_expand_with_table(dest, str, auth_request,\n\t\tauth_request_get_var_expand_table(auth_request, escape_func),\n\t\tescape_func);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":387791,"func":"int InstanceKlass::mark_osr_nmethods(const Method* m) {\n  \/\/ This is a short non-blocking critical region, so the no safepoint check is ok.\n  MutexLockerEx ml(OsrList_lock, Mutex::_no_safepoint_check_flag);\n  nmethod* osr = osr_nmethods_head();\n  int found = 0;\n  while (osr != NULL) {\n    assert(osr->is_osr_method(), \"wrong kind of nmethod found in chain\");\n    if (osr->method() == m) {\n      osr->mark_for_deoptimization();\n      found++;\n    }\n    osr = osr->osr_link();\n  }\n  return found;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":513253,"func":"static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,\n\t\t\t\t      TABLE *table,\n\t\t\t\t      const key_map *keys,ha_rows limit)\n{\n  int error;\n  DBUG_ENTER(\"get_quick_record_count\");\n  uchar buff[STACK_BUFF_ALLOC];\n  if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))\n    DBUG_RETURN(0);                           \/\/ Fatal error flag is set\n  if (select)\n  {\n    select->head=table;\n    table->reginfo.impossible_range=0;\n    if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0,\n                                          limit, 0, FALSE, \n                                          TRUE \/* remove_where_parts*\/)) == 1)\n      DBUG_RETURN(select->quick->records);\n    if (error == -1)\n    {\n      table->reginfo.impossible_range=1;\n      DBUG_RETURN(0);\n    }\n    DBUG_PRINT(\"warning\",(\"Couldn't use record count on const keypart\"));\n  }\n  DBUG_RETURN(HA_POS_ERROR);\t\t\t\/* This shouldn't happend *\/\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":231653,"func":"  void registerKnobParamHandler(\n      uint64_t paramId,\n      std::function<void(QuicServerConnectionState*, uint64_t)>&& handler) {\n    registerTransportKnobParamHandler(paramId, std::move(handler));\n  }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":427181,"func":"static void exprstat (LexState *ls) {\n  \/* stat -> func | assignment *\/\n  FuncState *fs = ls->fs;\n  struct LHS_assign v;\n  suffixedexp(ls, &v.v);\n  if (ls->t.token == '=' || ls->t.token == ',') { \/* stat -> assignment ? *\/\n    v.prev = NULL;\n    restassign(ls, &v, 1);\n  }\n  else {  \/* stat -> func *\/\n    Instruction *inst;\n    check_condition(ls, v.v.k == VCALL, \"syntax error\");\n    inst = &getinstruction(fs, &v.v);\n    SETARG_C(*inst, 1);  \/* call statement uses no results *\/\n  }\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":430362,"func":"int seq_path(struct seq_file *m, const struct path *path, const char *esc)\n{\n\tchar *buf;\n\tsize_t size = seq_get_buf(m, &buf);\n\tint res = -1;\n\n\tif (size) {\n\t\tchar *p = d_path(path, buf, size);\n\t\tif (!IS_ERR(p)) {\n\t\t\tchar *end = mangle_path(buf, p, esc);\n\t\t\tif (end)\n\t\t\t\tres = end - buf;\n\t\t}\n\t}\n\tseq_commit(m, res);\n\n\treturn res;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":225711,"func":"GF_Err ctts_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_CompositionOffsetBox *ptr = (GF_CompositionOffsetBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->nb_entries);\n\tfor (i=0; i<ptr->nb_entries; i++ ) {\n\t\tgf_bs_write_u32(bs, ptr->entries[i].sampleCount);\n\t\tif (ptr->version) {\n\t\t\tgf_bs_write_int(bs, ptr->entries[i].decodingOffset, 32);\n\t\t} else {\n\t\t\tgf_bs_write_u32(bs, (u32) ptr->entries[i].decodingOffset);\n\t\t}\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":310295,"func":"clear_status_flags_on_sybil(routerstatus_t *rs)\n{\n  rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =\n    rs->is_running = rs->is_named = rs->is_valid = rs->is_v2_dir =\n    rs->is_hs_dir = rs->is_possible_guard = rs->is_bad_exit =\n    rs->is_bad_directory = 0;\n  \/* FFFF we might want some mechanism to check later on if we\n   * missed zeroing any flags: it's easy to add a new flag but\n   * forget to add it to this clause. *\/\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":207150,"func":"static SQInteger thread_call(HSQUIRRELVM v)\n{\n    SQObjectPtr o = stack_get(v,1);\n    if(sq_type(o) == OT_THREAD) {\n        SQInteger nparams = sq_gettop(v);\n        _thread(o)->Push(_thread(o)->_roottable);\n        for(SQInteger i = 2; i<(nparams+1); i++)\n            sq_move(_thread(o),v,i);\n        if(SQ_SUCCEEDED(sq_call(_thread(o),nparams,SQTrue,SQTrue))) {\n            sq_move(v,_thread(o),-1);\n            sq_pop(_thread(o),1);\n            return 1;\n        }\n        v->_lasterror = _thread(o)->_lasterror;\n        return SQ_ERROR;\n    }\n    return sq_throwerror(v,_SC(\"wrong parameter\"));\n}","target":1,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":513349,"func":"void dbug_serve_apcs(THD *thd, int n_calls)\n{\n  const char *save_proc_info= thd->proc_info;\n  \n  \/* Busy-wait for n_calls APC requests to arrive and be processed *\/\n  int n_apcs= thd->apc_target.n_calls_processed + n_calls;\n  while (thd->apc_target.n_calls_processed < n_apcs)\n  {\n    \/* This is so that mysqltest knows we're ready to serve requests: *\/\n    thd_proc_info(thd, \"show_explain_trap\");\n    my_sleep(30000);\n    thd_proc_info(thd, save_proc_info);\n    if (thd->check_killed())\n      break;\n  }\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":291809,"func":"__rtrs_get_permit(struct rtrs_clt_sess *clt, enum rtrs_clt_con_type con_type)\n{\n\tsize_t max_depth = clt->queue_depth;\n\tstruct rtrs_permit *permit;\n\tint bit;\n\n\t\/*\n\t * Adapted from null_blk get_tag(). Callers from different cpus may\n\t * grab the same bit, since find_first_zero_bit is not atomic.\n\t * But then the test_and_set_bit_lock will fail for all the\n\t * callers but one, so that they will loop again.\n\t * This way an explicit spinlock is not required.\n\t *\/\n\tdo {\n\t\tbit = find_first_zero_bit(clt->permits_map, max_depth);\n\t\tif (bit >= max_depth)\n\t\t\treturn NULL;\n\t} while (test_and_set_bit_lock(bit, clt->permits_map));\n\n\tpermit = get_permit(clt, bit);\n\tWARN_ON(permit->mem_id != bit);\n\tpermit->cpu_id = raw_smp_processor_id();\n\tpermit->con_type = con_type;\n\n\treturn permit;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":226267,"func":"}\nGF_Err jp2h_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read_ex(s, bs, s->type);","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":244364,"func":"void reftype_box_del(GF_Box *s)\n{\n\tGF_TrackReferenceTypeBox *ptr = (GF_TrackReferenceTypeBox *)s;\n\tif (!ptr) return;\n\tif (ptr->trackIDs) gf_free(ptr->trackIDs);\n\tgf_free(ptr);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":226031,"func":"GF_Box *npck_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_NPCKBox, GF_ISOM_BOX_TYPE_NPCK);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":318940,"func":"f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    rettv->v_type = VAR_STRING;\n    rettv->vval.v_string = NULL;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":389670,"func":"check_for_opt_string_or_list_arg(typval_T *args, int idx)\n{\n    return (args[idx].v_type == VAR_UNKNOWN\n\t    || check_for_string_or_list_arg(args, idx));\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":221153,"func":"void gf_odf_dovi_cfg_del(GF_DOVIDecoderConfigurationRecord *cfg)\n{\n\tgf_free(cfg);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":312383,"func":"qf_find_win(qf_info_T *qi)\n{\n    win_T\t*win;\n\n    FOR_ALL_WINDOWS(win)\n\tif (is_qf_win(win, qi))\n\t    return win;\n    return NULL;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":512591,"func":"  void fix_charset_and_length_from_str_value(const String &str, Derivation dv)\n  {\n    fix_charset_and_length(str.charset(), dv, Metadata(&str));\n  }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":356711,"func":"void Statement::Work_AfterRun(napi_env e, napi_status status, void* data) {\n    std::unique_ptr<RunBaton> baton(static_cast<RunBaton*>(data));\n    Statement* stmt = baton->stmt;\n\n    Napi::Env env = stmt->Env();\n    Napi::HandleScope scope(env);\n\n    if (stmt->status != SQLITE_ROW && stmt->status != SQLITE_DONE) {\n        Error(baton.get());\n    }\n    else {\n        \/\/ Fire callbacks.\n        Napi::Function cb = baton->callback.Value();\n        if (!cb.IsUndefined() && cb.IsFunction()) {\n            (stmt->Value()).Set(Napi::String::New(env, \"lastID\"), Napi::Number::New(env, baton->inserted_id));\n            (stmt->Value()).Set( Napi::String::New(env, \"changes\"), Napi::Number::New(env, baton->changes));\n\n            Napi::Value argv[] = { env.Null() };\n            TRY_CATCH_CALL(stmt->Value(), cb, 1, argv);\n        }\n    }\n\n    STATEMENT_END();\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":344242,"func":"l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {\n  CallInfo *ci = L->ci;\n  const char *msg;\n  va_list argp;\n  luaC_checkGC(L);  \/* error message uses memory *\/\n  va_start(argp, fmt);\n  msg = luaO_pushvfstring(L, fmt, argp);  \/* format message *\/\n  va_end(argp);\n  if (isLua(ci)) {  \/* if Lua function, add source:line information *\/\n    luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));\n    setobjs2s(L, L->top - 2, L->top - 1);  \/* remove 'msg' from the stack *\/\n    L->top--;\n  }\n  luaG_errormsg(L);\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":359532,"func":"DEFUN (neighbor_advertise_interval,\n       neighbor_advertise_interval_cmd,\n       NEIGHBOR_CMD \"advertisement-interval <0-600>\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR\n       \"Minimum interval between sending BGP routing updates\\n\"\n       \"time in seconds\\n\")\n{\n  return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":95904,"func":"void AddSetMsiMarkerWorkItem(const InstallerState& installer_state,\n                             BrowserDistribution* dist,\n                             bool set,\n                             WorkItemList* work_item_list) {\n  DCHECK(work_item_list);\n  DWORD msi_value = set ? 1 : 0;\n  WorkItem* set_msi_work_item = work_item_list->AddSetRegValueWorkItem(\n      installer_state.root_key(), dist->GetStateKey(),\n      google_update::kRegMSIField, msi_value, true);\n  DCHECK(set_msi_work_item);\n  set_msi_work_item->set_ignore_failure(true);\n  set_msi_work_item->set_log_message(\"Could not write MSI marker!\");\n}\n","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":463073,"func":"static void sungem_reset_tx(SunGEMState *s)\n{\n    trace_sungem_tx_reset();\n\n    \/* XXX Do TXCFG *\/\n    \/* XXX Check value *\/\n    s->txdmaregs[TXDMA_FSZ >> 2] = 0x90;\n    s->txdmaregs[TXDMA_TXDONE >> 2] = 0;\n    s->txdmaregs[TXDMA_KICK >> 2] = 0;\n    s->txdmaregs[TXDMA_CFG >> 2] = 0x118010;\n\n    sungem_update_masks(s);\n\n    s->tx_size = 0;\n    s->tx_first_ctl = 0;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":278252,"func":"inindent(int extra)\n{\n    char_u\t*ptr;\n    colnr_T\tcol;\n\n    for (col = 0, ptr = ml_get_curline(); VIM_ISWHITE(*ptr); ++col)\n\t++ptr;\n    if (col >= curwin->w_cursor.col + extra)\n\treturn TRUE;\n    else\n\treturn FALSE;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":224723,"func":"GF_Box *bxml_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_BinaryXMLBox, GF_ISOM_BOX_TYPE_BXML);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":401570,"func":"void init_timer_key(struct timer_list *timer,\n\t\t    void (*func)(struct timer_list *), unsigned int flags,\n\t\t    const char *name, struct lock_class_key *key)\n{\n\tdebug_init(timer);\n\tdo_init_timer(timer, func, flags, name, key);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":240265,"func":"free_yank(long n)\n{\n    if (y_current->y_array != NULL)\n    {\n\tlong\t    i;\n\n\tfor (i = n; --i >= 0; )\n\t    vim_free(y_current->y_array[i]);\n\tVIM_CLEAR(y_current->y_array);\n    }\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":238792,"func":"restore_search_patterns(void)\n{\n    if (--save_level == 0)\n    {\n\tvim_free(spats[0].pat);\n\tspats[0] = saved_spats[0];\n#if defined(FEAT_EVAL)\n\tset_vv_searchforward();\n#endif\n\tvim_free(spats[1].pat);\n\tspats[1] = saved_spats[1];\n\tvim_free(mr_pattern);\n\tmr_pattern = saved_mr_pattern;\n#ifdef FEAT_SEARCH_EXTRA\n\tlast_idx = saved_spats_last_idx;\n\tset_no_hlsearch(saved_spats_no_hlsearch);\n#endif\n    }\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":489218,"func":"static void hfsplus_cat_build_key_uni(hfsplus_btree_key *key, u32 parent,\n\t\t\t\t      struct hfsplus_unistr *name)\n{\n\tint ustrlen;\n\n\tustrlen = be16_to_cpu(name->length);\n\tkey->cat.parent = cpu_to_be32(parent);\n\tkey->cat.name.length = cpu_to_be16(ustrlen);\n\tustrlen *= 2;\n\tmemcpy(key->cat.name.unicode, name->unicode, ustrlen);\n\tkey->key_len = cpu_to_be16(6 + ustrlen);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":328961,"func":"R_API int r_bin_java_new_bin(RBinJavaObj *bin, ut64 loadaddr, Sdb *kv, const ut8 *buf, ut64 len) {\n\tR_BIN_JAVA_GLOBAL_BIN = bin;\n\tif (!r_str_constpool_init (&bin->constpool)) {\n\t\treturn false;\n\t}\n\tbin->lines.count = 0;\n\tbin->loadaddr = loadaddr;\n\tr_bin_java_get_java_null_cp ();\n\tbin->id = r_num_rand (UT32_MAX);\n\tbin->kv = kv ? kv : sdb_new (NULL, NULL, 0);\n\tbin->AllJavaBinObjs = NULL;\n\treturn r_bin_java_load_bin (bin, buf, len);\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":359582,"func":"afi2str (afi_t afi)\n{\n  if (afi == AFI_IP)\n    return \"AFI_IP\";\n  else if (afi == AFI_IP6)\n    return \"AFI_IP6\";\n  else\n    return \"Unknown AFI\";\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":409499,"func":"f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv)\n{\n# ifdef FEAT_TERMRESPONSE\n    int i;\n# endif\n\n    if (rettv_dict_alloc(rettv) == FAIL)\n\treturn;\n# ifdef FEAT_TERMRESPONSE\n    for (i = 0; i < TPR_COUNT; ++i)\n    {\n\tchar_u\tvalue[2];\n\n\tvalue[0] = term_props[i].tpr_status;\n\tvalue[1] = NUL;\n\tdict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value);\n    }\n# endif\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":309816,"func":"ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)\n{\n    int row, col;\n\n    row = SP_PARM->_cursrow;\n    col = SP_PARM->_curscol;\n\n    if (row < 0)\n\trow = 0;\n    if (col < 0)\n\tcol = 0;\n\n    UpdateAttrs(SP_PARM, blank);\n    TPUTS_TRACE(\"clr_eos\");\n    NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx\n\t\t\t    clr_eos,\n\t\t\t    screen_lines(SP_PARM) - row,\n\t\t\t    NCURSES_SP_NAME(_nc_outch));\n\n    while (col < screen_columns(SP_PARM))\n\tCurScreen(SP_PARM)->_line[row].text[col++] = blank;\n\n    for (row++; row < screen_lines(SP_PARM); row++) {\n\tfor (col = 0; col < screen_columns(SP_PARM); col++)\n\t    CurScreen(SP_PARM)->_line[row].text[col] = blank;\n    }\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":437698,"func":"static int cx23888_ir_tx_write(struct v4l2_subdev *sd, u8 *buf, size_t count,\n\t\t\t       ssize_t *num)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tstruct cx23885_dev *dev = state->dev;\n\t\/* For now enable the Tx FIFO Service interrupt & pretend we did work *\/\n\tirqenable_tx(dev, IRQEN_TSE);\n\t*num = count;\n\treturn 0;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":242634,"func":"static void isor_reset_seq_list(GF_List *list)\n{\n\twhile (gf_list_count(list)) {\n\t\tGF_NALUFFParam *sl = gf_list_pop_back(list);\n\t\tgf_free(sl->data);\n\t\tgf_free(sl);\n\t}\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":484745,"func":"static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)\n{\n\tint i;\n\n\tswitch (stringset) {\n\tcase ETH_SS_STATS:\n\t\tfor (i = 0; i < ARRAY_SIZE(xennet_stats); i++)\n\t\t\tmemcpy(data + i * ETH_GSTRING_LEN,\n\t\t\t       xennet_stats[i].name, ETH_GSTRING_LEN);\n\t\tbreak;\n\t}\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":383951,"func":"cdf_app_to_mime(const char *vbuf, const struct nv *nv)\n{\n\tsize_t i;\n\tconst char *rv = NULL;\n\tchar *old_lc_ctype;\n\n\told_lc_ctype = setlocale(LC_CTYPE, NULL);\n\tassert(old_lc_ctype != NULL);\n\told_lc_ctype = strdup(old_lc_ctype);\n\tassert(old_lc_ctype != NULL);\n\t(void)setlocale(LC_CTYPE, \"C\");\n\tfor (i = 0; nv[i].pattern != NULL; i++)\n\t\tif (strcasestr(vbuf, nv[i].pattern) != NULL) {\n\t\t\trv = nv[i].mime;\n\t\t\tbreak;\n\t\t}\n\t(void)setlocale(LC_CTYPE, old_lc_ctype);\n\tfree(old_lc_ctype);\n\treturn rv;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":507771,"func":"void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)\n{\n    if (pr != NULL)\n        *pr = sig->r;\n    if (ps != NULL)\n        *ps = sig->s;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":463125,"func":"static void annotate_begin(annotate_db_t *d)\n{\n    if (d)\n        d->in_txn = 1;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":301387,"func":"static NTSTATUS vfswrap_copy_chunk_recv(struct vfs_handle_struct *handle,\n\t\t\t\t\tstruct tevent_req *req,\n\t\t\t\t\toff_t *copied)\n{\n\tstruct vfs_cc_state *vfs_cc_state = tevent_req_data(req,\n\t\t\t\t\t\t\tstruct vfs_cc_state);\n\tNTSTATUS status;\n\n\tif (tevent_req_is_nterror(req, &status)) {\n\t\tDEBUG(2, (\"server side copy chunk failed: %s\\n\",\n\t\t\t  nt_errstr(status)));\n\t\t*copied = 0;\n\t\ttevent_req_received(req);\n\t\treturn status;\n\t}\n\n\t*copied = vfs_cc_state->copied;\n\tDEBUG(10, (\"server side copy chunk copied %lu\\n\",\n\t\t   (unsigned long)*copied));\n\ttevent_req_received(req);\n\n\treturn NT_STATUS_OK;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":247152,"func":"GF_Err gf_fs_run(GF_FilterSession *fsess)\n{\n\tu32 i, nb_threads;\n\tassert(fsess);\n\n\tfsess->run_status = GF_OK;\n\tfsess->main_th.has_seen_eot = GF_FALSE;\n\tfsess->nb_threads_stopped = 0;\n\n\tnb_threads = gf_list_count(fsess->threads);\n\tfor (i=0;i<nb_threads; i++) {\n\t\tGF_SessionThread *sess_th = gf_list_get(fsess->threads, i);\n\t\tgf_th_run(sess_th->th, (gf_thread_run) gf_fs_thread_proc, sess_th);\n\t}\n\tif (fsess->no_main_thread) return GF_OK;\n\n\tgf_fs_thread_proc(&fsess->main_th);\n\n\t\/\/wait for all threads to be done\n\twhile (nb_threads+1 != fsess->nb_threads_stopped) {\n\t\tgf_sleep(1);\n\t}\n\n\treturn fsess->run_status;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":249952,"func":"__realpath (const char *name, char *resolved)\n{\n  #ifdef GCC_BOGUS_WRETURN_LOCAL_ADDR\n   #warning \"GCC might issue a bogus -Wreturn-local-addr warning here.\"\n   #warning \"See <https:\/\/gcc.gnu.org\/bugzilla\/show_bug.cgi?id=93644>.\"\n  #endif\n  struct scratch_buffer rname_buffer;\n  return realpath_stk (name, resolved, &rname_buffer);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":248267,"func":"DLLIMPORT cfg_t *cfg_addtsec(cfg_t *cfg, const char *name, const char *title)\n{\n\tcfg_opt_t *opt;\n\tcfg_value_t *val;\n\n\tif (cfg_gettsec(cfg, name, title))\n\t\treturn NULL;\n\n\topt = cfg_getopt(cfg, name);\n\tif (!opt) {\n\t\tcfg_error(cfg, _(\"no such option '%s'\"), name);\n\t\treturn NULL;\n\t}\n\tval = cfg_setopt(cfg, opt, title);\n\tif (!val)\n\t\treturn NULL;\n\n\tval->section->path = cfg->path; \/* Remember global search path. *\/\n\tval->section->line = 1;\n\tval->section->errfunc = cfg->errfunc;\n\n\treturn val->section;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":415181,"func":"get_current_reader (void)\n{\n  struct vreader_s *vr;\n\n  \/* We only support one reader for now.  *\/\n  vr = &vreader_table[0];\n\n  \/* Initialize the vreader item if not yet done. *\/\n  if (!vr->valid)\n    {\n      vr->slot = -1;\n      vr->valid = 1;\n    }\n\n  \/* Try to open the reader. *\/\n  if (vr->slot == -1)\n    {\n      vr->slot = apdu_open_reader (opt.reader_port);\n\n      \/* If we still don't have a slot, we have no readers.\n\t Invalidate for now until a reader is attached. *\/\n      if (vr->slot == -1)\n\t{\n\t  vr->valid = 0;\n\t}\n    }\n\n  \/* Return the vreader index or -1.  *\/\n  return vr->valid ? 0 : -1;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":432291,"func":"void memory_region_init_ram(struct uc_struct *uc,\n                            MemoryRegion *mr,\n                            uint64_t size,\n                            uint32_t perms)\n{\n    memory_region_init(uc, mr, size);\n    mr->ram = true;\n    if (!(perms & UC_PROT_WRITE)) {\n        mr->readonly = true;\n    }\n    mr->perms = perms;\n    mr->terminates = true;\n    mr->destructor = memory_region_destructor_ram;\n    mr->ram_block = qemu_ram_alloc(uc, size, mr);\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":300827,"func":"static int tipc_send_packet(struct socket *sock, struct msghdr *m, size_t dsz)\n{\n\tif (dsz > TIPC_MAX_USER_MSG_SIZE)\n\t\treturn -EMSGSIZE;\n\n\treturn tipc_sendstream(sock, m, dsz);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":225011,"func":"PQerrorMessage(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn libpq_gettext(\"connection pointer is NULL\\n\");\n\n\t\/*\n\t * The errorMessage buffer might be marked \"broken\" due to having\n\t * previously failed to allocate enough memory for the message.  In that\n\t * case, tell the application we ran out of memory.\n\t *\/\n\tif (PQExpBufferBroken(&conn->errorMessage))\n\t\treturn libpq_gettext(\"out of memory\\n\");\n\n\treturn conn->errorMessage.data;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":225886,"func":"\nGF_Box *trik_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrickPlayBox, GF_ISOM_BOX_TYPE_TRIK);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":224203,"func":"    Subscriber(void *user) : user(user) {}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":294363,"func":"f_gt_p(VALUE x, VALUE y)\n{\n    if (FIXNUM_P(x) && FIXNUM_P(y))\n\treturn f_boolcast(FIX2LONG(x) > FIX2LONG(y));\n    return rb_funcall(x, '>', 1, y);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":424941,"func":"static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)\n{\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\tint ret;\n\n\tmutex_lock(&trans_pcie->mutex);\n\tret = _iwl_trans_pcie_start_hw(trans);\n\tmutex_unlock(&trans_pcie->mutex);\n\n\treturn ret;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":337816,"func":"struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep,\n\t\t\t\t\t     struct sctp_chunk *chunk,\n\t\t\t\t\t     gfp_t gfp)\n{\n\tstruct sctp_association *asoc;\n\tenum sctp_scope scope;\n\tstruct sk_buff *skb;\n\n\t\/* Create the bare association.  *\/\n\tscope = sctp_scope(sctp_source(chunk));\n\tasoc = sctp_association_new(ep, ep->base.sk, scope, gfp);\n\tif (!asoc)\n\t\tgoto nodata;\n\tasoc->temp = 1;\n\tskb = chunk->skb;\n\t\/* Create an entry for the source address of the packet.  *\/\n\tSCTP_INPUT_CB(skb)->af->from_skb(&asoc->c.peer_addr, skb, 1);\n\nnodata:\n\treturn asoc;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":512443,"func":"  void reset_buffer()\n  {\n    m_string.set(buffer, buffer_size, &my_charset_bin);\n  }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":225384,"func":"static struct v4l2_loopback_device *v4l2loopback_cd2dev(struct device *cd)\n{\n\tstruct video_device *loopdev = to_video_device(cd);\n\tstruct v4l2loopback_private *ptr =\n\t\t(struct v4l2loopback_private *)video_get_drvdata(loopdev);\n\tint nr = ptr->device_nr;\n\n\treturn idr_find(&v4l2loopback_index_idr, nr);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":244342,"func":"GF_Err metx_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_TXTC:\n\t\t\/\/we allow the config box on metx\n\t\tBOX_FIELD_ASSIGN(config, GF_TextConfigBox)\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":336541,"func":"static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)\n{\n    RedLinkInfo *link;\n\n    if (!red_socket_set_non_blocking(socket, TRUE)) {\n        return NULL;\n    }\n\n    if (!red_socket_set_no_delay(socket, TRUE)) {\n        return NULL;\n    }\n\n    red_socket_set_keepalive(socket, TRUE, KEEPALIVE_TIMEOUT);\n    red_socket_set_nosigpipe(socket, true);\n\n    link = g_new0(RedLinkInfo, 1);\n    link->reds = reds;\n    link->stream = red_stream_new(reds, socket);\n\n    \/* gather info + send event *\/\n\n    red_stream_push_channel_event(link->stream, SPICE_CHANNEL_EVENT_CONNECTED);\n\n    openssl_init(link);\n\n    return link;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":274868,"func":"TEST(ComparisonsTest, GreaterBroadcast) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 1}, TensorType_INT32,\n                          BuiltinOperator_GREATER);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3});\n  model.PopulateTensor<int>(model.input2(), {7});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, false, false));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":294700,"func":"c_find_ldom(int y, int m, double sg, int *rjd, int *ns)\n{\n    int i, rm, rd;\n\n    for (i = 0; i < 30; i++)\n\tif (c_valid_civil_p(y, m, 31 - i, sg, &rm, &rd, rjd, ns))\n\t    return 1;\n    return 0;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":352953,"func":"telephoneNumberNormalize(\n\tslap_mask_t usage,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *val,\n\tstruct berval *normalized,\n\tvoid *ctx )\n{\n\tchar *q;\n\tber_len_t c;\n\n\tassert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) != 0 );\n\n\t\/* Ensure q is big enough, though validator should have caught this *\/\n\tif ( BER_BVISEMPTY( val )) {\n\t\tBER_BVZERO( normalized );\n\t\treturn LDAP_INVALID_SYNTAX;\n\t}\n\n\tq = normalized->bv_val = slap_sl_malloc( val->bv_len + 1, ctx );\n\n\tfor( c = 0; c < val->bv_len; c++ ) {\n\t\tif ( ! ( ASCII_SPACE( val->bv_val[c] ) || val->bv_val[c] == '-' )) {\n\t\t\t*q++ = val->bv_val[c];\n\t\t}\n\t}\n\tif ( q == normalized->bv_val ) {\n\t\t*q++ = ' ';\n\t}\n\t*q = '\\0';\n\n\tnormalized->bv_len = q - normalized->bv_val;\n\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":293779,"func":"static RBinInfo *info(RBinFile *bf) {\n\tRBinInfo *ret = NULL;\n\tbool big_endian = 0;\n\tif (!(ret = R_NEW0 (RBinInfo))) {\n\t\treturn NULL;\n\t}\n\tret->file = strdup (bf->file);\n\tret->bclass = strdup (\"kernelcache\");\n\tret->rclass = strdup (\"ios\");\n\tret->os = strdup (\"iOS\");\n\tret->arch = strdup (\"arm\"); \/\/ XXX\n\tret->machine = strdup (ret->arch);\n\tret->subsystem = strdup (\"xnu\");\n\tret->type = strdup (\"kernel-cache\");\n\tret->bits = 64;\n\tret->has_va = true;\n\tret->big_endian = big_endian;\n\tret->dbg_info = 0;\n\treturn ret;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":90146,"func":"NetworkLibrary* NetworkLibrary::GetImpl(bool stub) {\n  if (stub)\n    return new NetworkLibraryStubImpl();\n  else\n    return new NetworkLibraryImpl();\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":317118,"func":"static void smack_inet_csk_clone(struct sock *sk,\n\t\t\t\t const struct request_sock *req)\n{\n\tstruct socket_smack *ssp = sk->sk_security;\n\tstruct smack_known *skp;\n\n\tif (req->peer_secid != 0) {\n\t\tskp = smack_from_secid(req->peer_secid);\n\t\tssp->smk_packet = skp;\n\t} else\n\t\tssp->smk_packet = NULL;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":344738,"func":"set_nonblock(int fd)\n{\n\tint val;\n\n\tval = fcntl(fd, F_GETFL);\n\tif (val == -1) {\n\t\terror(\"fcntl(%d, F_GETFL): %s\", fd, strerror(errno));\n\t\treturn (-1);\n\t}\n\tif (val & O_NONBLOCK) {\n\t\tdebug3(\"fd %d is O_NONBLOCK\", fd);\n\t\treturn (0);\n\t}\n\tdebug2(\"fd %d setting O_NONBLOCK\", fd);\n\tval |= O_NONBLOCK;\n\tif (fcntl(fd, F_SETFL, val) == -1) {\n\t\tdebug(\"fcntl(%d, F_SETFL, O_NONBLOCK): %s\", fd,\n\t\t    strerror(errno));\n\t\treturn (-1);\n\t}\n\treturn (0);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":387593,"func":"static unsigned long get_ctl_id_hash(const struct snd_ctl_elem_id *id)\n{\n\tint i;\n\tunsigned long h;\n\n\th = id->iface;\n\th = MULTIPLIER * h + id->device;\n\th = MULTIPLIER * h + id->subdevice;\n\tfor (i = 0; i < SNDRV_CTL_ELEM_ID_NAME_MAXLEN && id->name[i]; i++)\n\t\th = MULTIPLIER * h + id->name[i];\n\th = MULTIPLIER * h + id->index;\n\th &= LONG_MAX;\n\treturn h;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":361759,"func":"static int em28xx_wait_until_ac97_features_equals(struct em28xx *dev,\n\t\t\t\t\t\t  int expected_feat)\n{\n\tunsigned long timeout = jiffies + msecs_to_jiffies(2000);\n\tint feat, powerdown;\n\n\twhile (time_is_after_jiffies(timeout)) {\n\t\tfeat = em28xx_read_ac97(dev, AC97_RESET);\n\t\tif (feat < 0)\n\t\t\treturn feat;\n\n\t\tpowerdown = em28xx_read_ac97(dev, AC97_POWERDOWN);\n\t\tif (powerdown < 0)\n\t\t\treturn powerdown;\n\n\t\tif (feat == expected_feat && feat != powerdown)\n\t\t\treturn 0;\n\n\t\tmsleep(50);\n\t}\n\n\tdev_warn(&dev->intf->dev, \"AC97 registers access is not reliable !\\n\");\n\treturn -ETIMEDOUT;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":254905,"func":"std::unique_ptr<GroupFromFirstDocumentTransformation> GroupFromFirstDocumentTransformation::create(\n    const intrusive_ptr<ExpressionContext>& expCtx,\n    const std::string& groupId,\n    vector<pair<std::string, intrusive_ptr<Expression>>> accumulatorExprs) {\n    return std::make_unique<GroupFromFirstDocumentTransformation>(groupId,\n                                                                  std::move(accumulatorExprs));\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":344751,"func":"freeargs(arglist *args)\n{\n\tu_int i;\n\n\tif (args->list != NULL) {\n\t\tfor (i = 0; i < args->num; i++)\n\t\t\tfree(args->list[i]);\n\t\tfree(args->list);\n\t\targs->nalloc = args->num = 0;\n\t\targs->list = NULL;\n\t}\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":244119,"func":"GF_Box *csgp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_CompactSampleGroupBox, GF_ISOM_BOX_TYPE_CSGP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":259204,"func":"static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    int format_flags;\n\n    if (atom.size < 6) {\n        av_log(c->fc, AV_LOG_ERROR, \"Empty pcmC box\\n\");\n        return AVERROR_INVALIDDATA;\n    }\n\n    avio_r8(pb);    \/\/ version\n    avio_rb24(pb);  \/\/ flags\n    format_flags = avio_r8(pb);\n    if (format_flags == 1) \/\/ indicates little-endian format. If not present, big-endian format is used\n        set_last_stream_little_endian(c->fc);\n\n    return 0;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":512311,"func":"bool Item_func_in::fix_for_scalar_comparison_using_cmp_items(THD *thd,\n                                                             uint found_types)\n{\n  if (found_types & (1U << STRING_RESULT) &&\n      agg_arg_charsets_for_comparison(cmp_collation, args, arg_count))\n    return true;\n  if (make_unique_cmp_items(thd, cmp_collation.collation))\n    return true;\n  return false;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":289283,"func":"static int snd_pcm_hw_param_mask(struct snd_pcm_substream *pcm,\n\t\t\t\t struct snd_pcm_hw_params *params,\n\t\t\t\t snd_pcm_hw_param_t var,\n\t\t\t\t const struct snd_mask *val)\n{\n\tint changed = _snd_pcm_hw_param_mask(params, var, val);\n\tif (changed < 0)\n\t\treturn changed;\n\tif (params->rmask) {\n\t\tint err = snd_pcm_hw_refine(pcm, params);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":96963,"func":"static CFType typeFromCFTypeRef(CFTypeRef type)\n{\n    ASSERT(type);\n\n    if (type == tokenNullTypeRef())\n        return Null;\n\n    CFTypeID typeID = CFGetTypeID(type);\n    if (typeID == CFArrayGetTypeID())\n        return CFArray;\n    if (typeID == CFBooleanGetTypeID())\n        return CFBoolean;\n    if (typeID == CFDataGetTypeID())\n        return CFData;\n    if (typeID == CFDateGetTypeID())\n        return CFDate;\n    if (typeID == CFDictionaryGetTypeID())\n        return CFDictionary;\n    if (typeID == CFNullGetTypeID())\n        return CFNull;\n    if (typeID == CFNumberGetTypeID())\n        return CFNumber;\n    if (typeID == CFStringGetTypeID())\n        return CFString;\n    if (typeID == CFURLGetTypeID())\n        return CFURL;\n#if PLATFORM(MAC)\n    if (typeID == SecCertificateGetTypeID())\n        return SecCertificate;\n    if (typeID == SecKeychainItemGetTypeID())\n        return SecKeychainItem;\n#endif\n\n    ASSERT_NOT_REACHED();\n    return Unknown;\n}\n","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":175697,"func":"  virtual void UpdateSystemInfo() {}\n","target":0,"code_token_length":8,"total_token_length":244,"max_tokens_setting":512}
+{"idx":450342,"func":"static void key_event(VncState *vs, int down, uint32_t sym)\n{\n    int keycode;\n    int lsym = sym;\n\n    if (lsym >= 'A' && lsym <= 'Z' && qemu_console_is_graphic(NULL)) {\n        lsym = lsym - 'A' + 'a';\n    }\n\n    keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF,\n                              vs->vd->kbd, down) & SCANCODE_KEYMASK;\n    trace_vnc_key_event_map(down, sym, keycode, code2name(keycode));\n    do_key_event(vs, down, keycode, sym);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":343284,"func":"void stripctrl(char * const buf, size_t len)\n{\n    if (len <= (size_t) 0U) {\n        return;\n    }\n    do {\n        len--;\n        if (ISCTRLCODE(buf[len]) &&\n            buf[len] != 0 && buf[len] != '\\n') {\n            buf[len] = '_';\n        }\n    } while (len != (size_t) 0U);\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":387819,"func":"Klass* InstanceKlass::array_klass_impl(bool or_null, TRAPS) {\n  return array_klass_impl(or_null, 1, THREAD);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":101672,"func":"void WebProcessProxy::didPerformServerRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID)\n{\n    WebPageProxy* page = webPage(pageID);\n    if (!page)\n        return;\n    \n    if (sourceURLString.isEmpty() || destinationURLString.isEmpty())\n        return;\n    \n    WebFrameProxy* frame = webFrame(frameID);\n    MESSAGE_CHECK(frame);\n    MESSAGE_CHECK(frame->page() == page);\n    MESSAGE_CHECK_URL(sourceURLString);\n    MESSAGE_CHECK_URL(destinationURLString);\n\n    m_context->historyClient().didPerformServerRedirect(m_context.get(), page, sourceURLString, destinationURLString, frame);\n}\n","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":225723,"func":"\nGF_Err segr_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i, k;\n\tGF_Err e;\n\tFDSessionGroupBox *ptr = (FDSessionGroupBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u16(bs, ptr->num_session_groups);\n\tfor (i=0; i<ptr->num_session_groups; i++) {\n\t\tgf_bs_write_u8(bs, ptr->session_groups[i].nb_groups);\n\t\tfor (k=0; k<ptr->session_groups[i].nb_groups; k++) {\n\t\t\tgf_bs_write_u32(bs, ptr->session_groups[i].group_ids[k]);\n\t\t}\n\n\t\tgf_bs_write_u16(bs, ptr->session_groups[i].nb_channels);\n\t\tfor (k=0; k<ptr->session_groups[i].nb_channels; k++) {\n\t\t\tgf_bs_write_u32(bs, ptr->session_groups[i].channels[k]);\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":317304,"func":"static noinline int audit_inode_permission(struct inode *inode,\n\t\t\t\t\t   u32 perms, u32 audited, u32 denied,\n\t\t\t\t\t   int result)\n{\n\tstruct common_audit_data ad;\n\tstruct inode_security_struct *isec = selinux_inode(inode);\n\n\tad.type = LSM_AUDIT_DATA_INODE;\n\tad.u.inode = inode;\n\n\treturn slow_avc_audit(&selinux_state,\n\t\t\t    current_sid(), isec->sid, isec->sclass, perms,\n\t\t\t    audited, denied, result, &ad);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":226143,"func":"\nvoid mhac_box_del(GF_Box *s)\n{\n\tGF_MHAConfigBox *ptr = (GF_MHAConfigBox *) s;\n\tif (ptr->mha_config) gf_free(ptr->mha_config);\n\tgf_free(s);","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":385920,"func":"SYSCALL_DEFINE2(truncate64, const char __user *, path, loff_t, length)\n{\n\treturn do_sys_truncate(path, length);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":231636,"func":"  bool isDraining() {\n    return drainTimeout_.isScheduled();\n  }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":244114,"func":"GF_Box *vmhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_VideoMediaHeaderBox, GF_ISOM_BOX_TYPE_VMHD);\n\ttmp->flags = 1;\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":401529,"func":"static void extract_crng(__u8 out[CHACHA_BLOCK_SIZE])\n{\n\tstruct crng_state *crng = NULL;\n\n#ifdef CONFIG_NUMA\n\tif (crng_node_pool)\n\t\tcrng = crng_node_pool[numa_node_id()];\n\tif (crng == NULL)\n#endif\n\t\tcrng = &primary_crng;\n\t_extract_crng(crng, out);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":343151,"func":"static struct ip_esp_hdr *esp_output_tcp_encap(struct xfrm_state *x,\n\t\t\t\t\t\t    struct sk_buff *skb,\n\t\t\t\t\t\t    struct esp_info *esp)\n{\n\treturn ERR_PTR(-EOPNOTSUPP);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":466187,"func":"static int em_imul_ex(struct x86_emulate_ctxt *ctxt)\n{\n\tu8 ex = 0;\n\n\temulate_1op_rax_rdx(ctxt, \"imul\", ex);\n\treturn X86EMUL_CONTINUE;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":463153,"func":"static int annotation_set_tofile(annotate_state_t *state\n                                    __attribute__((unused)),\n                                 struct annotate_entry_list *entry,\n                                 int maywrite)\n{\n    const char *filename = (const char *)entry->desc->rock;\n    char path[MAX_MAILBOX_PATH+1];\n    int r;\n    FILE *f;\n\n    if (!maywrite) return IMAP_PERMISSION_DENIED;\n\n    snprintf(path, sizeof(path), \"%s\/msg\/%s\", config_dir, filename);\n\n    \/* XXX how do we do this atomically with other annotations? *\/\n    if (entry->shared.s == NULL)\n        return unlink(path);\n    else {\n        r = cyrus_mkdir(path, 0755);\n        if (r)\n            return r;\n        f = fopen(path, \"w\");\n        if (!f) {\n            syslog(LOG_ERR, \"cannot open %s for writing: %m\", path);\n            return IMAP_IOERROR;\n        }\n        fwrite(entry->shared.s, 1, entry->shared.len, f);\n        fputc('\\n', f);\n        return fclose(f);\n    }\n\n    return IMAP_IOERROR;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":90744,"func":"  bool AddCallback(GetUsageAndQuotaCallback* callback, bool unlimited) {\n    if (unlimited)\n      unlimited_callbacks_.push_back(callback);\n    else\n      callbacks_.push_back(callback);\n    return (callbacks_.size() + unlimited_callbacks_.size() == 1);\n  }\n","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":226373,"func":"GF_Err moof_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":241366,"func":"  explicit MatrixSolveOpGpu(OpKernelConstruction* context)\n      : AsyncOpKernel(context) {\n    OP_REQUIRES_OK(context, context->GetAttr(\"adjoint\", &adjoint_));\n  }","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":346451,"func":"may_prefix_autoload(char_u *name)\n{\n    if (SCRIPT_ID_VALID(current_sctx.sc_sid))\n    {\n\tscriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);\n\n\tif (si->sn_autoload_prefix != NULL)\n\t{\n\t    char_u  *basename = name;\n\t    size_t  len;\n\t    char_u  *res;\n\n\t    if (*name == K_SPECIAL)\n\t    {\n\t\tchar_u *p = vim_strchr(name, '_');\n\n\t\t\/\/ skip over \"<SNR>99_\"\n\t\tif (p != NULL)\n\t\t    basename = p + 1;\n\t    }\n\n\t    len = STRLEN(si->sn_autoload_prefix) + STRLEN(basename) + 2;\n\t    res = alloc(len);\n\t    if (res != NULL)\n\t    {\n\t\tvim_snprintf((char *)res, len, \"%s%s\",\n\t\t\t\t\t     si->sn_autoload_prefix, basename);\n\t\treturn res;\n\t    }\n\t}\n    }\n    return name;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":512243,"func":"  Item_cache_datetime(THD *thd)\n   :Item_cache_temporal(thd, &type_handler_datetime2) { }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":517429,"func":"static void print_service_rules_socket(HttpResponse res, Service_T s) {\n        for (Port_T p = s->socketlist; p; p = p->next) {\n                StringBuffer_append(res->outputbuffer, \"<tr class='rule'><td>Unix Socket<\/td><td>\");\n                if (p->retry > 1)\n                        Util_printRule(res->outputbuffer, p->action, \"If failed %s type %s protocol %s with timeout %s and retry %d time(s)\", p->target.unix.pathname, Util_portTypeDescription(p), p->protocol->name, Fmt_time2str(p->timeout, (char[11]){}), p->retry);\n                else\n                        Util_printRule(res->outputbuffer, p->action, \"If failed %s type %s protocol %s with timeout %s\", p->target.unix.pathname, Util_portTypeDescription(p), p->protocol->name, Fmt_time2str(p->timeout, (char[11]){}));\n                StringBuffer_append(res->outputbuffer, \"<\/td><\/tr>\");\n        }\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":412109,"func":"dnsc_nonces_lookup(struct slabhash* cache,\n                   const uint8_t nonce[crypto_box_HALF_NONCEBYTES],\n                   const uint8_t magic_query[DNSCRYPT_MAGIC_HEADER_LEN],\n                   const uint8_t pk[crypto_box_PUBLICKEYBYTES],\n                   uint32_t hash)\n{\n    struct nonce_cache_key k;\n    memset(&k, 0, sizeof(k));\n    k.entry.hash = hash;\n    memcpy(k.nonce, nonce, crypto_box_HALF_NONCEBYTES);\n    memcpy(k.magic_query, magic_query, DNSCRYPT_MAGIC_HEADER_LEN);\n    memcpy(k.client_publickey, pk, crypto_box_PUBLICKEYBYTES);\n\n    return slabhash_lookup(cache, hash, &k, 0);\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":448921,"func":"int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)\nz_streamp strm;\nBytef *dictionary;\nuInt *dictLength;\n{\n    struct inflate_state FAR *state;\n\n    \/* check state *\/\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n\n    \/* copy dictionary *\/\n    if (state->whave && dictionary != Z_NULL) {\n        zmemcpy(dictionary, state->window + state->wnext,\n                state->whave - state->wnext);\n        zmemcpy(dictionary + state->whave - state->wnext,\n                state->window, state->wnext);\n    }\n    if (dictLength != Z_NULL)\n        *dictLength = state->whave;\n    return Z_OK;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":240278,"func":"free_register(void *reg)\n{\n    yankreg_T tmp;\n\n    tmp = *y_current;\n    *y_current = *(yankreg_T *)reg;\n    free_yank_all();\n    vim_free(reg);\n    *y_current = tmp;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":310142,"func":"_nc_use_tracef(unsigned mask)\n{\n    bool result = FALSE;\n\n    _nc_lock_global(tst_tracef);\n    if (!MyNested++) {\n\tif ((result = (_nc_tracing & (mask))) != 0\n\t    && _nc_try_global(tracef) == 0) {\n\t    \/* we will call _nc_locked_tracef(), no nesting so far *\/\n\t} else {\n\t    \/* we will not call _nc_locked_tracef() *\/\n\t    MyNested = 0;\n\t}\n    } else {\n\t\/* we may call _nc_locked_tracef(), but with nested_tracef > 0 *\/\n\tresult = (_nc_tracing & (mask));\n    }\n    _nc_unlock_global(tst_tracef);\n    return result;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":468385,"func":"set_last_error (GSocketClientAsyncConnectData *data,\n\t\tGError *error)\n{\n  g_clear_error (&data->last_error);\n  data->last_error = error;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":264369,"func":"inline protobuf::RepeatedPtrField<string>* MutableTensorProtoData<tstring>(\n    TensorProto* t) {\n  static_assert(SaveTypeTraits<tstring>::supported,\n                \"Specified type tstring not supported for Save\");\n  return t->mutable_string_val();\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":224741,"func":"void ipro_box_del(GF_Box *s)\n{\n\tGF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s;\n\tif (ptr == NULL) return;\n\tgf_list_del(ptr->protection_information);\n\tgf_free(ptr);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":225785,"func":"\nGF_Box *void_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_Box, GF_ISOM_BOX_TYPE_VOID);\n\treturn tmp;","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":462581,"func":"controller::controller() : v(0), urlcfg(0), rsscache(0), url_file(\"urls\"), cache_file(\"cache.db\"), config_file(\"config\"), queue_file(\"queue\"), refresh_on_start(false), api(0) {\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":418792,"func":"reset_held_button()\n{\n    held_button = MOUSE_RELEASE;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":393487,"func":"static SQInteger class_getbase(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_getbase(v,-1))?1:SQ_ERROR;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":344782,"func":"argv_free(char **av, int ac)\n{\n\tint i;\n\n\tif (av == NULL)\n\t\treturn;\n\tfor (i = 0; i < ac; i++)\n\t\tfree(av[i]);\n\tfree(av);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":450367,"func":"static void vnc_client_cache_addr(VncState *client)\n{\n    Error *err = NULL;\n\n    client->info = g_malloc0(sizeof(*client->info));\n    vnc_init_basic_info_from_remote_addr(client->sioc,\n                                         qapi_VncClientInfo_base(client->info),\n                                         &err);\n    client->info->websocket = client->websocket;\n    if (err) {\n        qapi_free_VncClientInfo(client->info);\n        client->info = NULL;\n        error_free(err);\n    }\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":512756,"func":"bool Item_func_case::time_op(THD *thd, MYSQL_TIME *ltime)\n{\n  DBUG_ASSERT(fixed == 1);\n  Item *item= find_item();\n  if (!item)\n    return (null_value= true);\n  return (null_value= Time(thd, item).copy_to_mysql_time(ltime));\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":234829,"func":"void btrfs_get_bbio(struct btrfs_bio *bbio)\n{\n\tWARN_ON(!refcount_read(&bbio->refs));\n\trefcount_inc(&bbio->refs);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":309847,"func":"usage(void)\n{\n    static const char *msg[] =\n    {\n\t\"Usage: dots_termcap [options]\"\n\t,\"\"\n\t,\"Options:\"\n\t,\" -T TERM  override $TERM\"\n\t,\" -e       allow environment $LINES \/ $COLUMNS\"\n\t,\" -m SIZE  set margin (default: 2)\"\n\t,\" -r SECS  self-interrupt\/exit after specified number of seconds\"\n\t,\" -s MSECS delay 1% of the time (default: 1 msecs)\"\n    };\n    size_t n;\n\n    for (n = 0; n < SIZEOF(msg); n++)\n\tfprintf(stderr, \"%s\\n\", msg[n]);\n\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":244326,"func":"GF_Err metx_box_size(GF_Box *s)\n{\n\tGF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox *)s;\n\tptr->size += 8;\n\n\tif (ptr->type!=GF_ISOM_BOX_TYPE_STPP) {\n\t\tif (ptr->content_encoding)\n\t\t\tptr->size += strlen(ptr->content_encoding);\n\t\tptr->size++;\n\t}\n\n\tif ((ptr->type==GF_ISOM_BOX_TYPE_METX) || (ptr->type==GF_ISOM_BOX_TYPE_STPP)) {\n\n\t\tif (ptr->xml_namespace)\n\t\t\tptr->size += strlen(ptr->xml_namespace);\n\t\tptr->size++;\n\n\t\tif (ptr->xml_schema_loc)\n\t\t\tptr->size += strlen(ptr->xml_schema_loc);\n\t\tptr->size++;\n\n\t\tif (ptr->type==GF_ISOM_BOX_TYPE_STPP) {\n\t\t\tif (ptr->mime_type)\n\t\t\t\tptr->size += strlen(ptr->mime_type);\n\t\t\tptr->size++;\n\t\t}\n\n\t}\n\t\/\/mett, sbtt, stxt\n\telse {\n\t\tif (ptr->mime_type)\n\t\t\tptr->size += strlen(ptr->mime_type);\n\t\tptr->size++;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":220210,"func":"Status Node::input_node(int idx, Node** n) const {\n  const Edge* e;\n  TF_RETURN_IF_ERROR(input_edge(idx, &e));\n  if (e == nullptr) {\n    *n = nullptr;\n  } else {\n    *n = e->src();\n  }\n  return Status::OK();\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":417123,"func":"void PlayerGeneric::setRepeat(bool repeat)\n{\n\tthis->repeat = repeat;\n\tif (player)\n\t\tplayer->setRepeat(repeat);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":413647,"func":"R_API int r_core_anal_esil_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth) {\n\tconst char *esil;\n\teprintf (\"TODO\\n\");\n\twhile (1) {\n\t\t\/\/ TODO: Implement the proper logic for doing esil analysis\n\t\tRAnalOp *op = r_core_anal_op (core, at, R_ANAL_OP_MASK_ESIL);\n\t\tif (!op) {\n\t\t\tbreak;\n\t\t}\n\t\tesil = R_STRBUF_SAFEGET (&op->esil);\n\t\teprintf (\"0x%08\"PFMT64x\" %d %s\\n\", at, op->size, esil);\n\t\t\/\/ at += op->size;\n\t\t\/\/ esilIsRet()\n\t\t\/\/ esilIsCall()\n\t\t\/\/ esilIsJmp()\n\t\tr_anal_op_free (op);\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":328947,"func":"R_API char *r_bin_java_print_methodhandle_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut8 ref_kind = obj->info.cp_method_handle.reference_kind;\n\treturn r_str_newf (\"%d.0x%04\"PFMT64x \".%s.%s.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tR_BIN_JAVA_REF_METAS[ref_kind].name, obj->info.cp_method_handle.reference_index);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":427153,"func":"static void singlevar (LexState *ls, expdesc *var) {\n  TString *varname = str_checkname(ls);\n  FuncState *fs = ls->fs;\n  singlevaraux(fs, varname, var, 1);\n  if (var->k == VVOID) {  \/* global name? *\/\n    expdesc key;\n    singlevaraux(fs, ls->envn, var, 1);  \/* get environment variable *\/\n    lua_assert(var->k != VVOID);  \/* this one must exist *\/\n    luaK_exp2anyregup(fs, var);  \/* but could be a constant *\/\n    codestring(&key, varname);  \/* key is variable name *\/\n    luaK_indexed(fs, var, &key);  \/* env[varname] *\/\n  }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":468363,"func":"g_socket_client_tls_handshake_callback (GObject      *object,\n\t\t\t\t\tGAsyncResult *result,\n\t\t\t\t\tgpointer      user_data)\n{\n  GSocketClientAsyncConnectData *data = user_data;\n\n  if (g_tls_connection_handshake_finish (G_TLS_CONNECTION (object),\n\t\t\t\t\t result,\n\t\t\t\t\t &data->last_error))\n    {\n      g_object_unref (data->connection);\n      data->connection = G_IO_STREAM (object);\n\n      g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_TLS_HANDSHAKED, data->connectable, data->connection);\n      g_socket_client_async_connect_complete (data);\n    }\n  else\n    {\n      g_object_unref (object);\n      enumerator_next_async (data, FALSE);\n    }\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":413687,"func":"static int is_string(const ut8 *buf, int size, int *len) {\n\tint i, fakeLen = 0;\n\tif (size < 1) {\n\t\treturn 0;\n\t}\n\tif (!len) {\n\t\tlen = &fakeLen;\n\t}\n\tif (size > 3 && buf[0] && !buf[1] && buf[2] && !buf[3]) {\n\t\t*len = 1; \/\/ XXX: TODO: Measure wide string length\n\t\treturn 2; \/\/ is wide\n\t}\n\tfor (i = 0; i < size; i++) {\n\t\tif (!buf[i] && i > MINLEN) {\n\t\t\t*len = i;\n\t\t\treturn 1;\n\t\t}\n\t\tif (buf[i] == 10 || buf[i] == 13 || buf[i] == 9) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (buf[i] < 32 || buf[i] > 127) {\n\t\t\t\/\/ not ascii text\n\t\t\treturn 0;\n\t\t}\n\t\tif (!IS_PRINTABLE (buf[i])) {\n\t\t\t*len = i;\n\t\t\treturn 0;\n\t\t}\n\t}\n\t*len = i;\n\treturn 1;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":224175,"func":"  std::size_t get_tuple_bytes(const Tuple& tuple) {\n    return std::accumulate(tuple.begin(), tuple.end(),\n                           static_cast<std::size_t>(0),\n                           [](const std::size_t& lhs, const Tensor& rhs) {\n                             return lhs + rhs.TotalBytes();\n                           });\n  }","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":343168,"func":"static int esp4_rcv_cb(struct sk_buff *skb, int err)\n{\n\treturn 0;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":231023,"func":"    QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet )\r\n    {\r\n        QueueSetMemberHandle_t xReturn = NULL;\r\n\r\n        ( void ) xQueueReceiveFromISR( ( QueueHandle_t ) xQueueSet, &xReturn, NULL ); \/*lint !e961 Casting from one typedef to another is not redundant. *\/\r\n        return xReturn;\r\n    }\r","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":417117,"func":"void PlayerGeneric::setPlayMode(PlayModes mode)\n{\n\tplayMode = mode;\n\tif (player)\n\t\tplayer->setPlayMode(mode);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":241311,"func":"mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym mid)\n{\n  mt_tbl *h;\n\n  MRB_CLASS_ORIGIN(c);\n  h = c->mt;\n\n  if (h && mt_del(mrb, h, mid)) {\n    mrb_mc_clear_by_class(mrb, c);\n    return;\n  }\n  mrb_name_error(mrb, mid, \"method '%n' not defined in %C\", mid, c);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":400120,"func":"void LogHandler::setupLogFile(el::Configurations *defaultConf, string filename,\n                              string maxlogsize) {\n  \/\/ Enable strict log file size check\n  el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);\n  defaultConf->setGlobally(el::ConfigurationType::Filename, filename);\n  defaultConf->setGlobally(el::ConfigurationType::ToFile, \"true\");\n  defaultConf->setGlobally(el::ConfigurationType::MaxLogFileSize, maxlogsize);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":272343,"func":"generate_signature(cms_context *cms)\n{\n\tint rc = 0;\n\n\tif (cms->digests[cms->selected_digest].pe_digest == NULL)\n\t\tcnreterr(-1, cms, \"PE digest has not been allocated\");\n\n\tif (content_is_empty(cms->digests[cms->selected_digest].pe_digest->data,\n\t\t\tcms->digests[cms->selected_digest].pe_digest->len))\n\t\tcnreterr(-1, cms, \"PE binary has not been digested\");\n\n\tSECItem sd_der;\n\tmemset(&sd_der, '\\0', sizeof(sd_der));\n\trc = generate_spc_signed_data(cms, &sd_der);\n\tif (rc < 0)\n\t\tcnreterr(-1, cms, \"could not create signed data\");\n\n\tmemcpy(&cms->newsig, &sd_der, sizeof (cms->newsig));\n\tcms->newsig.data = malloc(sd_der.len);\n\tif (!cms->newsig.data)\n\t\tcnreterr(-1, cms, \"could not allocate signed data\");\n\tmemcpy(cms->newsig.data, sd_der.data, sd_der.len);\n\treturn 0;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":231686,"func":"bool verifyFramePresent(\n    std::vector<std::unique_ptr<folly::IOBuf>>& socketWrites,\n    QuicReadCodec& readCodec,\n    QuicFrame::Type frameType) {\n  AckStates ackStates;\n  for (auto& write : socketWrites) {\n    auto packetQueue = bufToQueue(write->clone());\n    auto result = readCodec.parsePacket(packetQueue, ackStates);\n    auto regularPacket = result.regularPacket();\n    if (!regularPacket) {\n      continue;\n    }\n    for (FOLLY_MAYBE_UNUSED auto& frame : regularPacket->frames) {\n      if (frame.type() != frameType) {\n        continue;\n      }\n      return true;\n    }\n  }\n  return false;\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":244081,"func":"GF_Err udta_box_size(GF_Box *s)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_UserDataMap *map;\n\tGF_UserDataBox *ptr = (GF_UserDataBox *)s;\n\n\ti=0;\n\twhile ((map = (GF_UserDataMap *)gf_list_enum(ptr->recordList, &i))) {\n\t\t\/\/warning: here we are not passing the actual \"parent\" of the list\n\t\t\/\/but the UDTA box. The parent itself is not an box, we don't care about it\n\t\te = gf_isom_box_array_size(s, map->boxes);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":387790,"func":"void InstanceKlass::process_interfaces(Thread *thread) {\n  \/\/ link this class into the implementors list of every interface it implements\n  for (int i = local_interfaces()->length() - 1; i >= 0; i--) {\n    assert(local_interfaces()->at(i)->is_klass(), \"must be a klass\");\n    InstanceKlass* interf = InstanceKlass::cast(local_interfaces()->at(i));\n    assert(interf->is_interface(), \"expected interface\");\n    interf->add_implementor(this);\n  }\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":313734,"func":"adjust_cursor(oparg_T *oap)\n{\n    \/\/ The cursor cannot remain on the NUL when:\n    \/\/ - the column is > 0\n    \/\/ - not in Visual mode or 'selection' is \"o\"\n    \/\/ - 'virtualedit' is not \"all\" and not \"onemore\".\n    if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL\n\t\t&& (!VIsual_active || *p_sel == 'o')\n\t\t&& !virtual_active() && (get_ve_flags() & VE_ONEMORE) == 0)\n    {\n\t--curwin->w_cursor.col;\n\t\/\/ prevent cursor from moving on the trail byte\n\tif (has_mbyte)\n\t    mb_adjust_cursor();\n\toap->inclusive = TRUE;\n    }\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":412331,"func":"static bool check_buffer(RzBuffer *buf) {\n\tut8 tmp[6];\n\tint r = rz_buf_read_at(buf, 0, tmp, sizeof(tmp));\n\treturn r == sizeof(tmp) && !memcmp(tmp, QNX_MAGIC, sizeof(tmp));\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":231698,"func":"void onServerCloseOpenState(QuicServerConnectionState& conn) {\n  conn.state = ServerState::Closed;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":430424,"func":"int ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,\n\t\t\t const struct sw_flow_key *key,\n\t\t\t struct sw_flow_actions **sfa, bool log)\n{\n\tint err;\n\tu32 mpls_label_count = 0;\n\n\t*sfa = nla_alloc_flow_actions(min(nla_len(attr), MAX_ACTIONS_BUFSIZE));\n\tif (IS_ERR(*sfa))\n\t\treturn PTR_ERR(*sfa);\n\n\tif (eth_p_mpls(key->eth.type))\n\t\tmpls_label_count = hweight_long(key->mpls.num_labels_mask);\n\n\t(*sfa)->orig_len = nla_len(attr);\n\terr = __ovs_nla_copy_actions(net, attr, key, sfa, key->eth.type,\n\t\t\t\t     key->eth.vlan.tci, mpls_label_count, log);\n\tif (err)\n\t\tovs_nla_free_flow_actions(*sfa);\n\n\treturn err;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":220244,"func":"const Edge* Graph::AddControlEdge(Node* source, Node* dest,\n                                  bool allow_duplicates) {\n  if (!allow_duplicates) {\n    for (const Edge* edge : dest->in_edges()) {\n      if (edge->IsControlEdge() && edge->src() == source) {\n        \/\/ The requested edge already exists.\n        return nullptr;\n      }\n    }\n  }\n  \/\/ Modify dest's NodeDef if necessary.\n  if (!source->IsSource() && !dest->IsSink() && !allow_duplicates) {\n    \/\/ Check if this input is already in dest's NodeDef.\n    const std::string new_input = strings::StrCat(\"^\", source->name());\n    bool input_exists = false;\n    for (const std::string& input : dest->props_->node_def.input()) {\n      if (input == new_input) {\n        input_exists = true;\n        break;\n      }\n    }\n    if (!input_exists) {\n      dest->MaybeCopyOnWrite();\n      dest->props_->node_def.add_input(new_input);\n    }\n  }\n  return AddEdge(source, kControlSlot, dest, kControlSlot);\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":241058,"func":"int client_add(int fd, const struct booth_transport *tpt,\n\t\tvoid (*workfn)(int ci),\n\t\tvoid (*deadfn)(int ci))\n{\n\tint i;\n\tstruct client *c;\n\n\n\tif (client_size - 1 <= client_maxi ) {\n\t\tclient_alloc();\n\t}\n\n\tfor (i = 0; i < client_size; i++) {\n\t\tc = clients + i;\n\t\tif (c->fd != -1)\n\t\t\tcontinue;\n\n\t\tc->workfn = workfn;\n\t\tif (deadfn)\n\t\t\tc->deadfn = deadfn;\n\t\telse\n\t\t\tc->deadfn = client_dead;\n\n\t\tc->transport = tpt;\n\t\tc->fd = fd;\n\t\tc->msg = NULL;\n\t\tc->offset = 0;\n\n\t\tpollfds[i].fd = fd;\n\t\tpollfds[i].events = POLLIN;\n\t\tif (i > client_maxi)\n\t\t\tclient_maxi = i;\n\n\t\treturn i;\n\t}\n\n\tassert(!\"no client\");\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":195403,"func":"TfLiteIntArray* TfLiteIntArrayCreate(int size) {\n  int alloc_size = TfLiteIntArrayGetSizeInBytes(size);\n  if (alloc_size <= 0) return NULL;\n  TfLiteIntArray* ret = (TfLiteIntArray*)malloc(alloc_size);\n  if (!ret) return ret;\n  ret->size = size;\n  return ret;\n}","target":1,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":384199,"func":"int nft_chain_validate(const struct nft_ctx *ctx, const struct nft_chain *chain)\n{\n\tstruct nft_expr *expr, *last;\n\tconst struct nft_data *data;\n\tstruct nft_rule *rule;\n\tint err;\n\n\tif (ctx->level == NFT_JUMP_STACK_SIZE)\n\t\treturn -EMLINK;\n\n\tlist_for_each_entry(rule, &chain->rules, list) {\n\t\tif (!nft_is_active_next(ctx->net, rule))\n\t\t\tcontinue;\n\n\t\tnft_rule_for_each_expr(expr, last, rule) {\n\t\t\tif (!expr->ops->validate)\n\t\t\t\tcontinue;\n\n\t\t\terr = expr->ops->validate(ctx, expr, &data);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t}\n\n\t\tcond_resched();\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":329945,"func":"_cairo_image_bounded_opaque_spans (void *abstract_renderer,\n\t\t\t\t   int y, int height,\n\t\t\t\t   const cairo_half_open_span_t *spans,\n\t\t\t\t   unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    do {\n\tif (spans[0].coverage)\n\t    pixman_image_compositor_blt (r->compositor,\n\t\t\t\t\t spans[0].x, y,\n\t\t\t\t\t spans[1].x - spans[0].x, height,\n\t\t\t\t\t spans[0].coverage);\n\tspans++;\n    } while (--num_spans > 1);\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":338061,"func":"void WasmBinaryWriter::writeDebugLocationEnd(Expression* curr, Function* func) {\n  if (func && !func->expressionLocations.empty()) {\n    auto& span = binaryLocations.expressions.at(curr);\n    span.end = o.size();\n  }\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":376315,"func":"gpg_ctx_set_istream (struct _GpgCtx *gpg,\n                     CamelStream *istream)\n{\n\tg_object_ref (istream);\n\tif (gpg->istream)\n\t\tg_object_unref (gpg->istream);\n\tgpg->istream = istream;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":292159,"func":"int LinkResolver::vtable_index_of_interface_method(Klass* klass,\n                                                   const methodHandle& resolved_method) {\n\n  int vtable_index = Method::invalid_vtable_index;\n  Symbol* name = resolved_method->name();\n  Symbol* signature = resolved_method->signature();\n  InstanceKlass* ik = InstanceKlass::cast(klass);\n\n  \/\/ First check in default method array\n  if (!resolved_method->is_abstract() && ik->default_methods() != NULL) {\n    int index = InstanceKlass::find_method_index(ik->default_methods(),\n                                                 name, signature, Klass::find_overpass,\n                                                 Klass::find_static, Klass::find_private);\n    if (index >= 0 ) {\n      vtable_index = ik->default_vtable_indices()->at(index);\n    }\n  }\n  if (vtable_index == Method::invalid_vtable_index) {\n    \/\/ get vtable_index for miranda methods\n    klassVtable vt = ik->vtable();\n    vtable_index = vt.index_of_miranda(name, signature);\n  }\n  return vtable_index;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":483504,"func":"static int __init efi_load_efivars(void)\n{\n\tstruct platform_device *pdev;\n\n\tif (!efi_enabled(EFI_RUNTIME_SERVICES))\n\t\treturn 0;\n\n\tpdev = platform_device_register_simple(\"efivars\", 0, NULL, 0);\n\treturn PTR_ERR_OR_ZERO(pdev);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":482555,"func":"verifyStringOrDots(const FileInfo *file, TranslationTableOpcode opcode, int isString,\n\t\tint actionPart, int nofor) {\n\tif (!wantsString(opcode, actionPart, nofor) == !isString) return 1;\n\n\tcompileError(file, \"%s are not allowed in the %s part of a %s translation %s rule.\",\n\t\t\tisString ? \"strings\" : \"dots\", getPartName(actionPart),\n\t\t\tnofor ? \"backward\" : \"forward\", _lou_findOpcodeName(opcode));\n\n\treturn 0;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":247604,"func":"  const envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext& clientCtxProto() const {\n    return client_ctx_proto_;\n  }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":231712,"func":"  void handleKnobParams(const TransportKnobParams& params) {\n    handleTransportKnobParams(params);\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":337799,"func":"static int sctp_process_inv_paramlength(const struct sctp_association *asoc,\n\t\t\t\t\tstruct sctp_paramhdr *param,\n\t\t\t\t\tconst struct sctp_chunk *chunk,\n\t\t\t\t\tstruct sctp_chunk **errp)\n{\n\t\/* This is a fatal error.  Any accumulated non-fatal errors are\n\t * not reported.\n\t *\/\n\tif (*errp)\n\t\tsctp_chunk_free(*errp);\n\n\t\/* Create an error chunk and fill it in with our payload. *\/\n\t*errp = sctp_make_violation_paramlen(asoc, chunk, param);\n\n\treturn 0;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":222874,"func":"bool IsEnqueue(const NodeDef& n) {\n  return (n.op().find(\"Enqueue\") != string::npos &&\n          n.op().find(\"EnqueueMany\") == string::npos);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":522441,"func":"int flag2str(int flag, char *flag_str) {\n    if (flag & 0x1)\n        flag_str[2] = 'E';\n    if (flag >> 1 & 0x1)\n        flag_str[1] = 'W';\n    if (flag >> 2 & 0x1)\n        flag_str[0] = 'R';\n    \n    return 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":476133,"func":"int usb_string_ids_n(struct usb_composite_dev *c, unsigned n)\n{\n\tunsigned next = c->next_string_id;\n\tif (unlikely(n > 254 || (unsigned)next + n > 254))\n\t\treturn -ENODEV;\n\tc->next_string_id += n;\n\treturn next + 1;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":175771,"func":"  AvailableSpaceQueryTask(\n      QuotaManager* manager,\n      scoped_refptr<base::MessageLoopProxy> db_message_loop,\n      const FilePath& profile_path,\n      AvailableSpaceCallback* callback)\n      : QuotaThreadTask(manager, db_message_loop),\n        profile_path_(profile_path),\n        space_(-1),\n        callback_(callback) {}\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":261912,"func":"njs_string_slice(njs_vm_t *vm, njs_value_t *dst,\n    const njs_string_prop_t *string, const njs_slice_prop_t *slice)\n{\n    njs_string_prop_t  prop;\n\n    njs_string_slice_string_prop(&prop, string, slice);\n\n    if (njs_fast_path(prop.size != 0)) {\n        return njs_string_new(vm, dst, prop.start, prop.size, prop.length);\n    }\n\n    *dst = njs_string_empty;\n\n    return NJS_OK;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":292215,"func":"inbound_topictime (server *serv, char *chan, char *nick, time_t stamp,\n\t\t\t\t\t\t const message_tags_data *tags_data)\n{\n\tchar *tim = ctime (&stamp);\n\tsession *sess = find_channel (serv, chan);\n\n\tif (!sess)\n\t\tsess = serv->server_session;\n\n\ttim[24] = 0;\t\/* get rid of the \\n *\/\n\tEMIT_SIGNAL_TIMESTAMP (XP_TE_TOPICDATE, sess, chan, nick, tim, NULL, 0,\n\t\t\t\t\t\t\t\t  tags_data->timestamp);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":261250,"func":"    int wm_SemUnlock(wm_Sem *s) {\n        xSemaphoreGive(*s);\n        return 0;\n    }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":225904,"func":"void totl_box_del(GF_Box *s)\n{\n\tgf_free((GF_TRPYBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":234723,"func":"static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes)\n{\n\tstruct btrfs_bio *bbio = kzalloc(\n\t\t \/* the size of the btrfs_bio *\/\n\t\tsizeof(struct btrfs_bio) +\n\t\t\/* plus the variable array for the stripes *\/\n\t\tsizeof(struct btrfs_bio_stripe) * (total_stripes) +\n\t\t\/* plus the variable array for the tgt dev *\/\n\t\tsizeof(int) * (real_stripes) +\n\t\t\/*\n\t\t * plus the raid_map, which includes both the tgt dev\n\t\t * and the stripes\n\t\t *\/\n\t\tsizeof(u64) * (total_stripes),\n\t\tGFP_NOFS|__GFP_NOFAIL);\n\n\tatomic_set(&bbio->error, 0);\n\trefcount_set(&bbio->refs, 1);\n\n\tbbio->tgtdev_map = (int *)(bbio->stripes + total_stripes);\n\tbbio->raid_map = (u64 *)(bbio->tgtdev_map + real_stripes);\n\n\treturn bbio;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":246451,"func":"RPVector *r_bin_wasm_get_elements(RBinWasmObj *bin) {\n\tr_return_val_if_fail (bin && bin->g_sections, NULL);\n\treturn bin->g_elements? bin->g_elements: parse_unique_subsec_vec_by_id (bin, R_BIN_WASM_SECTION_ELEMENT);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":281159,"func":"void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si)\n{\n\tsi->incnt = net->xfrm.policy_count[XFRM_POLICY_IN];\n\tsi->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT];\n\tsi->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD];\n\tsi->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX];\n\tsi->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX];\n\tsi->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX];\n\tsi->spdhcnt = net->xfrm.policy_idx_hmask;\n\tsi->spdhmcnt = xfrm_policy_hashmax;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":427199,"func":"static int createlabel (LexState *ls, TString *name, int line,\n                        int last) {\n  FuncState *fs = ls->fs;\n  Labellist *ll = &ls->dyd->label;\n  int l = newlabelentry(ls, ll, name, line, luaK_getlabel(fs));\n  if (last) {  \/* label is last no-op statement in the block? *\/\n    \/* assume that locals are already out of scope *\/\n    ll->arr[l].nactvar = fs->bl->nactvar;\n  }\n  if (solvegotos(ls, &ll->arr[l])) {  \/* need close? *\/\n    luaK_codeABC(fs, OP_CLOSE, luaY_nvarstack(fs), 0, 0);\n    return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":313834,"func":"nv_page(cmdarg_T *cap)\n{\n    if (!checkclearop(cap->oap))\n    {\n\tif (mod_mask & MOD_MASK_CTRL)\n\t{\n\t    \/\/ <C-PageUp>: tab page back; <C-PageDown>: tab page forward\n\t    if (cap->arg == BACKWARD)\n\t\tgoto_tabpage(-(int)cap->count1);\n\t    else\n\t\tgoto_tabpage((int)cap->count0);\n\t}\n\telse\n\t    (void)onepage(cap->arg, cap->count1);\n    }\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":369188,"func":"\nvoid __io_uring_free(struct task_struct *tsk)\n{\n\tstruct io_uring_task *tctx = tsk->io_uring;\n\n\tWARN_ON_ONCE(!xa_empty(&tctx->xa));\n\tWARN_ON_ONCE(tctx->io_wq);\n\tWARN_ON_ONCE(tctx->cached_refs);\n\n\tkfree(tctx->registered_rings);\n\tpercpu_counter_destroy(&tctx->inflight);\n\tkfree(tctx);\n\ttsk->io_uring = NULL;","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":359671,"func":"DEFUN (clear_ip_bgp_external_soft_in,\n       clear_ip_bgp_external_soft_in_cmd,\n       \"clear ip bgp external soft in\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear all external peers\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,\n\t\t\tBGP_CLEAR_SOFT_IN, NULL);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":513297,"func":"static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,\n                                         Item ***copy_func, bool modify_item)\n{\n  DBUG_ASSERT(thd == table->in_use);\n  Field *new_field= item->Item::create_tmp_field(false, table);\n\n  if (copy_func &&\n      (item->is_result_field() || \n       (item->real_item()->is_result_field())))\n    *((*copy_func)++) = item;\t\t\t\/\/ Save for copy_funcs\n  if (modify_item)\n    item->set_result_field(new_field);\n  if (item->type() == Item::NULL_ITEM)\n    new_field->is_created_from_null_item= TRUE;\n  return new_field;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":401495,"func":"static bool crng_init_try_arch(struct crng_state *crng)\n{\n\tint\t\ti;\n\tbool\t\tarch_init = true;\n\tunsigned long\trv;\n\n\tfor (i = 4; i < 16; i++) {\n\t\tif (!arch_get_random_seed_long(&rv) &&\n\t\t    !arch_get_random_long(&rv)) {\n\t\t\trv = random_get_entropy();\n\t\t\tarch_init = false;\n\t\t}\n\t\tcrng->state[i] ^= rv;\n\t}\n\n\treturn arch_init;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":248311,"func":"DLLIMPORT int cfg_setmulti(cfg_t *cfg, const char *name, unsigned int nvalues, char **values)\n{\n\tcfg_opt_t *opt;\n\n\tif (!cfg || !name || !values) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\topt = cfg_getopt(cfg, name);\n\tif (!opt) {\n\t\terrno = ENOENT;\n\t\treturn CFG_FAIL;\n\t}\n\n\treturn cfg_opt_setmulti(cfg, opt, nvalues, values);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":369936,"func":"static int proc_fd_link(struct dentry *dentry, struct path *path)\n{\n\treturn proc_fd_info(dentry->d_inode, path, NULL);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":267952,"func":"R_API RBinSymbol *r_bin_file_add_method(RBinFile *bf, const char *klass, const char *method, int nargs) {\n\tr_return_val_if_fail (bf, NULL);\n\n\tRBinClass *c = r_bin_file_add_class (bf, klass, NULL, 0);\n\tif (!c) {\n\t\teprintf (\"Cannot allocate class %s\\n\", klass);\n\t\treturn NULL;\n\t}\n\tRBinSymbol *sym = __getMethod (bf, klass, method);\n\tif (!sym) {\n\t\tsym = R_NEW0 (RBinSymbol);\n\t\tif (sym) {\n\t\t\tsym->name = strdup (method);\n\t\t\tr_list_append (c->methods, sym);\n\t\t\tchar *name = r_str_newf (\"%s::%s\", klass, method);\n\t\t\tht_pp_insert (bf->o->methods_ht, name, sym);\n\t\t\tfree (name);\n\t\t}\n\t}\n\treturn sym;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":512551,"func":"Item_func_ifnull::real_op()\n{\n  DBUG_ASSERT(fixed == 1);\n  double value= args[0]->val_real();\n  if (!args[0]->null_value)\n  {\n    null_value=0;\n    return value;\n  }\n  value= args[1]->val_real();\n  if ((null_value=args[1]->null_value))\n    return 0.0;\n  return value;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":512423,"func":"void Item_cond_and::mark_as_condition_AND_part(TABLE_LIST *embedding)\n{\n  List_iterator<Item> li(list);\n  Item *item;\n  while ((item=li++))\n  {\n    item->mark_as_condition_AND_part(embedding);\n  }\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":275481,"func":"njs_vm_prop_magic16(njs_object_prop_t *prop)\n{\n    return prop->value.data.magic16;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":248255,"func":"DLLIMPORT int cfg_numopts(cfg_opt_t *opts)\n{\n\tint n;\n\n\tfor (n = 0; opts && opts[n].name; n++)\n\t\t\/* do nothing *\/ ;\n\treturn n;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":359568,"func":"DEFUN (neighbor_filter_list,\n       neighbor_filter_list_cmd,\n       NEIGHBOR_CMD2 \"filter-list WORD (in|out)\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Establish BGP filters\\n\"\n       \"AS path access-list name\\n\"\n       \"Filter incoming routes\\n\"\n       \"Filter outgoing routes\\n\")\n{\n  return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t      bgp_node_safi (vty), argv[1], argv[2]);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":488338,"func":"static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,\n\t\t\t\tstruct vm_area_struct *vma, pud_t *pud,\n\t\t\t\tunsigned long addr, unsigned long end,\n\t\t\t\tlong *zap_work, struct zap_details *details)\n{\n\tpmd_t *pmd;\n\tunsigned long next;\n\n\tpmd = pmd_offset(pud, addr);\n\tdo {\n\t\tnext = pmd_addr_end(addr, end);\n\t\tif (pmd_none_or_clear_bad(pmd)) {\n\t\t\t(*zap_work)--;\n\t\t\tcontinue;\n\t\t}\n\t\tnext = zap_pte_range(tlb, vma, pmd, addr, next,\n\t\t\t\t\t\tzap_work, details);\n\t} while (pmd++, addr = next, (addr != end && *zap_work > 0));\n\n\treturn addr;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":210961,"func":"static int nft_set_desc_concat_parse(const struct nlattr *attr,\n\t\t\t\t     struct nft_set_desc *desc)\n{\n\tstruct nlattr *tb[NFTA_SET_FIELD_MAX + 1];\n\tu32 len;\n\tint err;\n\n\terr = nla_parse_nested_deprecated(tb, NFTA_SET_FIELD_MAX, attr,\n\t\t\t\t\t  nft_concat_policy, NULL);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (!tb[NFTA_SET_FIELD_LEN])\n\t\treturn -EINVAL;\n\n\tlen = ntohl(nla_get_be32(tb[NFTA_SET_FIELD_LEN]));\n\n\tif (len * BITS_PER_BYTE \/ 32 > NFT_REG32_COUNT)\n\t\treturn -E2BIG;\n\n\tdesc->field_len[desc->field_count++] = len;\n\n\treturn 0;\n}","target":1,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":226070,"func":"GF_Box *dmed_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_DMEDBox, GF_ISOM_BOX_TYPE_DMED);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":372355,"func":"check_limit(VALUE str, VALUE opt)\n{\n    if (NIL_P(str)) return;\n    if (SYMBOL_P(str)) str = rb_sym2str(str);\n\n    StringValue(str);\n    size_t slen = RSTRING_LEN(str);\n    size_t limit = get_limit(opt);\n    if (slen > limit) {\n\trb_raise(rb_eArgError,\n\t\t \"string length (%\"PRI_SIZE_PREFIX\"u) exceeds the limit %\"PRI_SIZE_PREFIX\"u\", slen, limit);\n    }\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":231003,"func":"argnum_error(mrb_state *mrb, mrb_int num)\n{\n  mrb_value exc;\n  mrb_value str;\n  mrb_int argc = mrb->c->ci->n;\n\n  if (argc == 15) {\n    mrb_value args = mrb->c->ci->stack[1];\n    if (mrb_array_p(args)) {\n      argc = RARRAY_LEN(args);\n    }\n  }\n  if (argc == 0 && mrb->c->ci->nk != 0 && !mrb_hash_empty_p(mrb, mrb->c->ci->stack[1])) {\n    argc++;\n  }\n  str = mrb_format(mrb, \"wrong number of arguments (given %i, expected %i)\", argc, num);\n  exc = mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str);\n  mrb_exc_set(mrb, exc);\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":446116,"func":"atusb_set_cca_mode(struct ieee802154_hw *hw, const struct wpan_phy_cca *cca)\n{\n\tstruct atusb *atusb = hw->priv;\n\tu8 val;\n\n\t\/* mapping 802.15.4 to driver spec *\/\n\tswitch (cca->mode) {\n\tcase NL802154_CCA_ENERGY:\n\t\tval = 1;\n\t\tbreak;\n\tcase NL802154_CCA_CARRIER:\n\t\tval = 2;\n\t\tbreak;\n\tcase NL802154_CCA_ENERGY_CARRIER:\n\t\tswitch (cca->opt) {\n\t\tcase NL802154_CCA_OPT_ENERGY_CARRIER_AND:\n\t\t\tval = 3;\n\t\t\tbreak;\n\t\tcase NL802154_CCA_OPT_ENERGY_CARRIER_OR:\n\t\t\tval = 0;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\treturn atusb_write_subreg(atusb, SR_CCA_MODE, val);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":349529,"func":"static int virtbt_add_inbuf(struct virtio_bluetooth *vbt)\n{\n\tstruct virtqueue *vq = vbt->vqs[VIRTBT_VQ_RX];\n\tstruct scatterlist sg[1];\n\tstruct sk_buff *skb;\n\tint err;\n\n\tskb = alloc_skb(1000, GFP_KERNEL);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\n\tsg_init_one(sg, skb->data, 1000);\n\n\terr = virtqueue_add_inbuf(vq, sg, 1, skb, GFP_KERNEL);\n\tif (err < 0) {\n\t\tkfree_skb(skb);\n\t\treturn err;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":412105,"func":"key_get_es_version(uint8_t version[2])\n{\n    struct es_version {\n        uint8_t es_version[2];\n        const char *name;\n    };\n\n    const int num_versions = 2;\n    struct es_version es_versions[] = {\n        {{0x00, 0x01}, \"X25519-XSalsa20Poly1305\"},\n        {{0x00, 0x02}, \"X25519-XChacha20Poly1305\"},\n    };\n    int i;\n    for(i=0; i < num_versions; i++){\n        if(es_versions[i].es_version[0] == version[0] &&\n           es_versions[i].es_version[1] == version[1]){\n            return es_versions[i].name;\n        }\n    }\n    return NULL;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":339710,"func":"ZEND_API int zend_shutdown_strtod(void) \/* {{{ *\/\n{\n\tdestroy_freelist();\n#ifdef ZTS\n\ttsrm_mutex_free(dtoa_mutex);\n\tdtoa_mutex = NULL;\n\n\ttsrm_mutex_free(pow5mult_mutex);\n\tpow5mult_mutex = NULL;\n#endif\n\treturn 1;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":281112,"func":"static int __net_init xfrm_statistics_init(struct net *net)\n{\n\treturn 0;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":440890,"func":"LogClose(enum ExitCode error)\n{\n    if (logFile) {\n        int msgtype = (error == EXIT_NO_ERROR) ? X_INFO : X_ERROR;\n        LogMessageVerbSigSafe(msgtype, -1,\n                \"Server terminated %s (%d). Closing log file.\\n\",\n                (error == EXIT_NO_ERROR) ? \"successfully\" : \"with error\",\n                error);\n        fclose(logFile);\n        logFile = NULL;\n        logFileFd = -1;\n    }\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":427240,"func":"static void field (LexState *ls, ConsControl *cc) {\n  \/* field -> listfield | recfield *\/\n  switch(ls->t.token) {\n    case TK_NAME: {  \/* may be 'listfield' or 'recfield' *\/\n      if (luaX_lookahead(ls) != '=')  \/* expression? *\/\n        listfield(ls, cc);\n      else\n        recfield(ls, cc);\n      break;\n    }\n    case '[': {\n      recfield(ls, cc);\n      break;\n    }\n    default: {\n      listfield(ls, cc);\n      break;\n    }\n  }\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":462265,"func":"PJ_DEF(pj_stun_attr_hdr*) pj_stun_attr_clone( pj_pool_t *pool,\n\t\t\t\t\t      const pj_stun_attr_hdr *attr)\n{\n    const struct attr_desc *adesc;\n\n    \/* Get the attribute descriptor *\/\n    adesc = find_attr_desc(attr->type);\n    if (adesc) {\n\treturn (pj_stun_attr_hdr*) (*adesc->clone_attr)(pool, attr);\n    } else {\n\t\/* Clone generic attribute *\/\n\tconst pj_stun_binary_attr *bin_attr = (const pj_stun_binary_attr*)\n\t\t\t\t\t       attr;\n\tPJ_ASSERT_RETURN(bin_attr->magic == PJ_STUN_MAGIC, NULL);\n\tif (bin_attr->magic == PJ_STUN_MAGIC) {\n\t    return (pj_stun_attr_hdr*) clone_binary_attr(pool, attr);\n\t} else {\n\t    return NULL;\n\t}\n    }\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":294434,"func":"c_julian_last_day_of_month(int y, int m)\n{\n    assert(m >= 1 && m <= 12);\n    return monthtab[c_julian_leap_p(y) ? 1 : 0][m];\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":508372,"func":"  Repair_mrg_table_error_handler()\n    : m_handled_errors(false), m_unhandled_errors(false)\n  {}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":248747,"func":"static void freecookie(struct Cookie *co)\n{\n  free(co->expirestr);\n  free(co->domain);\n  free(co->path);\n  free(co->spath);\n  free(co->name);\n  free(co->value);\n  free(co->maxage);\n  free(co->version);\n  free(co);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":359511,"func":"DEFUN (no_neighbor_route_server_client,\n       no_neighbor_route_server_client_cmd,\n       NO_NEIGHBOR_CMD2 \"route-server-client\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Configure a neighbor as Route Server client\\n\")\n{\n  return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),\n                  bgp_node_safi(vty));\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":264295,"func":"static void vnc_listen_read(void *opaque, bool websocket)\n{\n    VncDisplay *vs = opaque;\n    struct sockaddr_in addr;\n    socklen_t addrlen = sizeof(addr);\n    int csock;\n\n    \/* Catch-up *\/\n    graphic_hw_update(NULL);\n#ifdef CONFIG_VNC_WS\n    if (websocket) {\n        csock = qemu_accept(vs->lwebsock, (struct sockaddr *)&addr, &addrlen);\n    } else\n#endif \/* CONFIG_VNC_WS *\/\n    {\n        csock = qemu_accept(vs->lsock, (struct sockaddr *)&addr, &addrlen);\n    }\n\n    if (csock != -1) {\n        vnc_connect(vs, csock, false, websocket);\n    }\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":246683,"func":"void PrintLiveUsage()\n{\n\tu32 i=0;\n\tgf_sys_format_help(helpout, help_flags, \"# Live Scene Encoder Options\\n\"\n\t        \"The options shall be specified as \u00f2pt_name=opt_val.\\n\"\n\t        \"Options:\\n\"\n\t        \"\\n\"\n\t);\n\twhile (m4b_liveenc_args[i].name) {\n\t\tGF_GPACArg *arg = (GF_GPACArg *) &m4b_liveenc_args[i];\n\t\ti++;\n\t\tgf_sys_print_arg(helpout, help_flags, arg, \"mp4box-extract\");\n\t}\n\n\tgf_sys_format_help(helpout, help_flags, \"  \\n\"\n\t\t\"Runtime options:\\n\"\n\t\t\"- q: quits\\n\"\n\t\t\"- u: inputs some commands to be sent\\n\"\n\t\t\"- U: same as u but signals the updates as critical\\n\"\n\t\t\"- e: inputs some commands to be sent without being aggregated\\n\"\n\t\t\"- E: same as e but signals the updates as critical\\n\"\n\t\t\"- f: forces RAP sending\\n\"\n\t\t\"- F: forces RAP regeneration and sending\\n\"\n\t\t\"- p: dumps current scene\\n\"\n\t);\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":374041,"func":"static void destroy(RBinFile *bf) {\n\tr_coresym_cache_element_free (bf->o->bin_obj);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":277005,"func":"fiber_eq(mrb_state *mrb, mrb_value self)\n{\n  mrb_value other = mrb_get_arg1(mrb);\n\n  if (!mrb_fiber_p(other)) {\n    return mrb_false_value();\n  }\n  return mrb_bool_value(fiber_ptr(self) == fiber_ptr(other));\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":387850,"func":"int  InstanceKlass::nof_implementors() const {\n  assert_lock_strong(Compile_lock);\n  Klass* k = implementor();\n  if (k == NULL) {\n    return 0;\n  } else if (k != this) {\n    return 1;\n  } else {\n    return 2;\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":398497,"func":"RZ_API void rz_bin_dwarf_debug_info_free(RzBinDwarfDebugInfo *inf) {\n\tif (!inf) {\n\t\treturn;\n\t}\n\tfor (size_t i = 0; i < inf->count; i++) {\n\t\tfree_comp_unit(&inf->comp_units[i]);\n\t}\n\tht_up_free(inf->line_info_offset_comp_dir);\n\tht_up_free(inf->lookup_table);\n\tfree(inf->comp_units);\n\tfree(inf);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":292240,"func":"inbound_set_all_away_status (server *serv, char *nick, unsigned int status)\n{\n\tGSList *list;\n\tsession *sess;\n\n\tlist = sess_list;\n\twhile (list)\n\t{\n\t\tsess = list->data;\n\t\tif (sess->server == serv)\n\t\t\tuserlist_set_away (sess, nick, status);\n\t\tlist = list->next;\n\t}\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":212165,"func":"static int synic_set_irq(struct kvm_vcpu_hv_synic *synic, u32 sint)\n{\n\tstruct kvm_vcpu *vcpu = hv_synic_to_vcpu(synic);\n\tstruct kvm_lapic_irq irq;\n\tint ret, vector;\n\n\tif (sint >= ARRAY_SIZE(synic->sint))\n\t\treturn -EINVAL;\n\n\tvector = synic_get_sint_vector(synic_read_sint(synic, sint));\n\tif (vector < 0)\n\t\treturn -ENOENT;\n\n\tmemset(&irq, 0, sizeof(irq));\n\tirq.shorthand = APIC_DEST_SELF;\n\tirq.dest_mode = APIC_DEST_PHYSICAL;\n\tirq.delivery_mode = APIC_DM_FIXED;\n\tirq.vector = vector;\n\tirq.level = 1;\n\n\tret = kvm_irq_delivery_to_apic(vcpu->kvm, vcpu->arch.apic, &irq, NULL);\n\ttrace_kvm_hv_synic_set_irq(vcpu->vcpu_id, sint, irq.vector, ret);\n\treturn ret;\n}","target":1,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":359251,"func":"DEFUN (neighbor_attr_unchanged1,\n       neighbor_attr_unchanged1_cmd,\n       NEIGHBOR_CMD2 \"attribute-unchanged (as-path|next-hop|med)\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"BGP attribute is propagated unchanged to this neighbor\\n\"\n       \"As-path attribute\\n\"\n       \"Nexthop attribute\\n\"\n       \"Med attribute\\n\")\n{\n  u_int16_t flags = 0;\n\n  if (strncmp (argv[1], \"as-path\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);\n  else if (strncmp (argv[1], \"next-hop\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);\n  else if (strncmp (argv[1], \"med\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);\n\n  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t       bgp_node_safi (vty), flags);\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":463044,"func":"comics_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)\n{\n\tiface->get_thumbnail = comics_document_thumbnails_get_thumbnail;\n\tiface->get_dimensions = comics_document_thumbnails_get_dimensions;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":231705,"func":"TEST_F(QuicServerTransportTest, TestAckRstStream) {\n  auto streamId = server->createUnidirectionalStream().value();\n  auto stream = server->getNonConstConn().streamManager->getStream(streamId);\n  auto packetNum = rstStreamAndSendPacket(\n      server->getNonConstConn(),\n      server->getSocket(),\n      *stream,\n      GenericApplicationErrorCode::UNKNOWN);\n\n  AckBlocks acks = {{packetNum, packetNum}};\n  auto packet1 = createAckPacket(\n      server->getNonConstConn(),\n      ++clientNextAppDataPacketNum,\n      acks,\n      PacketNumberSpace::AppData);\n  deliverData(packetToBuf(packet1));\n  \/\/ Closed streams should be deleted.\n  EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":437717,"func":"static int cx23888_ir_tx_g_parameters(struct v4l2_subdev *sd,\n\t\t\t\t      struct v4l2_subdev_ir_parameters *p)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tmutex_lock(&state->tx_params_lock);\n\tmemcpy(p, &state->tx_params, sizeof(struct v4l2_subdev_ir_parameters));\n\tmutex_unlock(&state->tx_params_lock);\n\treturn 0;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":488680,"func":"static int __init nonx_setup(char *str)\n{\n\tif (!str)\n\t\treturn -EINVAL;\n\tif (!strncmp(str, \"on\", 2)) {\n                __supported_pte_mask |= _PAGE_NX; \n \t\tdo_not_nx = 0; \n\t} else if (!strncmp(str, \"off\", 3)) {\n\t\tdo_not_nx = 1;\n\t\t__supported_pte_mask &= ~_PAGE_NX;\n        }\n\treturn 0;\n} ","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":222504,"func":"Status FunctionLibraryDefinition::AddFunctionDefHelper(\n    const FunctionDef& fdef, const StackTracesMap& stack_traces, bool* added) {\n  *added = false;\n  std::shared_ptr<FunctionDefAndOpRegistration>& entry =\n      function_defs_[fdef.signature().name()];\n  if (entry) {\n    if (!FunctionDefsEqual(entry->fdef, fdef)) {\n      return errors::InvalidArgument(\n          \"Cannot add function '\", fdef.signature().name(),\n          \"' because a different function with the same name already \"\n          \"exists.\");\n    }\n    \/\/ Ignore duplicate FunctionDefs.\n    return Status::OK();\n  }\n  const OpDef* op_def;\n  if (default_registry_->LookUpOpDef(fdef.signature().name(), &op_def).ok()) {\n    return errors::InvalidArgument(\n        \"Cannot add function '\", fdef.signature().name(),\n        \"' because an op with the same name already exists.\");\n  }\n  entry = std::make_shared<FunctionDefAndOpRegistration>(fdef, stack_traces);\n  *added = true;\n  return Status::OK();\n}","target":0,"code_token_length":234,"total_token_length":470,"max_tokens_setting":512}
+{"idx":294676,"func":"date_s_httpdate(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"Mon, 01 Jan -4712 00:00:00 GMT\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        if (!NIL_P(opt)) argv2[argc2++] = opt;\n\tVALUE hash = date_s__httpdate(argc2, argv2, klass);\n\treturn d_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":352976,"func":"int slap_has64( int onoff )\n{\n\tif ( onoff < 0 )\n\t\treturn 0;\n\telse\n\t\treturn onoff ? -1 : 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":512518,"func":"void cmp_item_row::store_value(Item *item)\n{\n  DBUG_ENTER(\"cmp_item_row::store_value\");\n  DBUG_ASSERT(comparators);\n  DBUG_ASSERT(n == item->cols());\n  item->bring_value();\n  item->null_value= 0;\n  for (uint i=0; i < n; i++)\n  {\n    DBUG_ASSERT(comparators[i]);\n    comparators[i]->store_value(item->element_index(i));\n    item->null_value|= item->element_index(i)->null_value;\n  }\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":372868,"func":"static void irda_getvalue_confirm(int result, __u16 obj_id,\n\t\t\t\t  struct ias_value *value, void *priv)\n{\n\tstruct irda_sock *self;\n\n\tself = (struct irda_sock *) priv;\n\tif (!self) {\n\t\tIRDA_WARNING(\"%s: lost myself!\\n\", __func__);\n\t\treturn;\n\t}\n\n\tIRDA_DEBUG(2, \"%s(%p)\\n\", __func__, self);\n\n\t\/* We probably don't need to make any more queries *\/\n\tiriap_close(self->iriap);\n\tself->iriap = NULL;\n\n\t\/* Check if request succeeded *\/\n\tif (result != IAS_SUCCESS) {\n\t\tIRDA_DEBUG(1, \"%s(), IAS query failed! (%d)\\n\", __func__,\n\t\t\t   result);\n\n\t\tself->errno = result;\t\/* We really need it later *\/\n\n\t\t\/* Wake up any processes waiting for result *\/\n\t\twake_up_interruptible(&self->query_wait);\n\n\t\treturn;\n\t}\n\n\t\/* Pass the object to the caller (so the caller must delete it) *\/\n\tself->ias_result = value;\n\tself->errno = 0;\n\n\t\/* Wake up any processes waiting for result *\/\n\twake_up_interruptible(&self->query_wait);\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":238313,"func":"static int digest_update_from_fd(struct digest *d, int fd,\n\t\t\t\t loff_t start, loff_t size)\n{\n\tunsigned char *buf = xmalloc(PAGE_SIZE);\n\tint ret = 0;\n\n\tif (lseek(fd, start, SEEK_SET) != start) {\n\t\tperror(\"lseek\");\n\t\tret = -errno;\n\t\tgoto out_free;\n\t}\n\n\twhile (size) {\n\t\tunsigned long now = min_t(typeof(size), PAGE_SIZE, size);\n\n\t\tret = read(fd, buf, now);\n\t\tif (ret < 0) {\n\t\t\tperror(\"read\");\n\t\t\tgoto out_free;\n\t\t}\n\n\t\tif (!ret)\n\t\t\tbreak;\n\n\t\tret = digest_update_interruptible(d, buf, ret);\n\t\tif (ret)\n\t\t\tgoto out_free;\n\n\t\tsize -= now;\n\t}\n\nout_free:\n\tfree(buf);\n\treturn ret;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":247750,"func":"  void disconnect() {\n    EXPECT_CALL(client_callbacks_, onEvent(Network::ConnectionEvent::LocalClose));\n    EXPECT_CALL(server_callbacks_, onEvent(Network::ConnectionEvent::RemoteClose))\n        .WillOnce(Invoke([&](Network::ConnectionEvent) -> void { dispatcher_->exit(); }));\n\n    client_connection_->close(Network::ConnectionCloseType::NoFlush);\n    dispatcher_->run(Event::Dispatcher::RunType::Block);\n  }","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":513024,"func":"  Item_cache_time(THD *thd)\n   :Item_cache_temporal(thd, &type_handler_time2) { }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":226083,"func":"GF_Err npck_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":400737,"func":"size_t iov_iter_single_seg_count(const struct iov_iter *i)\n{\n\tif (i->nr_segs > 1) {\n\t\tif (likely(iter_is_iovec(i) || iov_iter_is_kvec(i)))\n\t\t\treturn min(i->count, i->iov->iov_len - i->iov_offset);\n\t\tif (iov_iter_is_bvec(i))\n\t\t\treturn min(i->count, i->bvec->bv_len - i->iov_offset);\n\t}\n\treturn i->count;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":409520,"func":"term_windgoto(int row, int col)\n{\n    OUT_STR(tgoto((char *)T_CM, col, row));\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":229254,"func":"void cql_server::response::write_string_list(std::vector<sstring> string_list)\n{\n    write_short(cast_if_fits<uint16_t>(string_list.size()));\n    for (auto&& s : string_list) {\n        write_string(s);\n    }\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":366312,"func":"static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool anon)\n{\n\tstruct mnt_namespace *new_ns;\n\tstruct ucounts *ucounts;\n\tint ret;\n\n\tucounts = inc_mnt_namespaces(user_ns);\n\tif (!ucounts)\n\t\treturn ERR_PTR(-ENOSPC);\n\n\tnew_ns = kzalloc(sizeof(struct mnt_namespace), GFP_KERNEL);\n\tif (!new_ns) {\n\t\tdec_mnt_namespaces(ucounts);\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\tif (!anon) {\n\t\tret = ns_alloc_inum(&new_ns->ns);\n\t\tif (ret) {\n\t\t\tkfree(new_ns);\n\t\t\tdec_mnt_namespaces(ucounts);\n\t\t\treturn ERR_PTR(ret);\n\t\t}\n\t}\n\tnew_ns->ns.ops = &mntns_operations;\n\tif (!anon)\n\t\tnew_ns->seq = atomic64_add_return(1, &mnt_ns_seq);\n\trefcount_set(&new_ns->ns.count, 1);\n\tINIT_LIST_HEAD(&new_ns->list);\n\tinit_waitqueue_head(&new_ns->poll);\n\tspin_lock_init(&new_ns->ns_lock);\n\tnew_ns->user_ns = get_user_ns(user_ns);\n\tnew_ns->ucounts = ucounts;\n\treturn new_ns;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":254738,"func":"njs_typed_array_get_u8(const void *a)\n{\n    return *(const uint8_t *) a;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":473902,"func":"st_numhash(st_data_t n)\n{\n    return (st_index_t)n;\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":389755,"func":"size_t get_default_max_mem_usage(void)\n{\n\tsize_t total_mem_size = jas_get_total_mem_size();\n\tsize_t max_mem;\n\tif (total_mem_size) {\n\t\tmax_mem = 0.90 * total_mem_size;\n\t} else {\n\t\tmax_mem = JAS_DEFAULT_MAX_MEM_USAGE;\n\t}\n\treturn max_mem;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":513108,"func":"longlong Item_func_between::val_int_cmp_datetime()\n{\n  THD *thd= current_thd;\n  longlong value= args[0]->val_datetime_packed(thd), a, b;\n  if ((null_value= args[0]->null_value))\n    return 0;\n  a= args[1]->val_datetime_packed(thd);\n  b= args[2]->val_datetime_packed(thd);\n  return val_int_cmp_int_finalize(value, a, b);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":437720,"func":"static unsigned int rxclk_rx_s_carrier(struct cx23885_dev *dev,\n\t\t\t\t       unsigned int freq,\n\t\t\t\t       u16 *divider)\n{\n\t*divider = carrier_freq_to_clock_divider(freq);\n\tcx23888_ir_write4(dev, CX23888_IR_RXCLK_REG, *divider);\n\treturn clock_divider_to_carrier_freq(*divider);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":513042,"func":"  Item_param *get_item_param() { return this; }","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":236158,"func":"u32 gpp_read_rgba(GF_BitStream *bs)\n{\n\tu8 r, g, b, a;\n\tu32 col;\n\tr = gf_bs_read_u8(bs);\n\tg = gf_bs_read_u8(bs);\n\tb = gf_bs_read_u8(bs);\n\ta = gf_bs_read_u8(bs);\n\tcol = a;\n\tcol<<=8;\n\tcol |= r;\n\tcol<<=8;\n\tcol |= g;\n\tcol<<=8;\n\tcol |= b;\n\treturn col;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":512719,"func":"  void fix_from_value(Derivation dv, const Metadata metadata)\n  {\n    fix_charset_and_length(str_value.charset(), dv, metadata);\n  }","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":175693,"func":"  NetworkLibraryStubImpl()\n      : ip_address_(\"1.1.1.1\"),\n        ethernet_(new EthernetNetwork()),\n        wifi_(NULL),\n        cellular_(NULL) {\n  }\n","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":508318,"func":"bool Locked_tables_list::restore_lock(THD *thd, TABLE_LIST *dst_table_list,\n                                      TABLE *table, MYSQL_LOCK *lock)\n{\n  MYSQL_LOCK *merged_lock;\n  DBUG_ENTER(\"restore_lock\");\n  DBUG_ASSERT(!strcmp(dst_table_list->table_name, table->s->table_name.str));\n\n  \/* Ensure we have the memory to add the table back *\/\n  if (!(merged_lock= mysql_lock_merge(thd->lock, lock)))\n    DBUG_RETURN(1);\n  thd->lock= merged_lock;\n\n  \/* Link to the new table *\/\n  dst_table_list->table= table;\n  \/*\n    The lock type may have changed (normally it should not as create\n    table will lock the table in write mode\n  *\/\n  dst_table_list->lock_type= table->reginfo.lock_type;\n  table->pos_in_locked_tables= dst_table_list;\n\n  add_back_last_deleted_lock(dst_table_list);\n\n  table->mdl_ticket->downgrade_lock(table->reginfo.lock_type >=\n                                    TL_WRITE_ALLOW_WRITE ? \n                                    MDL_SHARED_NO_READ_WRITE :\n                                    MDL_SHARED_READ);\n\n  DBUG_RETURN(0);\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":336681,"func":"static void reds_mig_finished(RedsState *reds, int completed)\n{\n    spice_debug(\"trace\");\n\n    reds->mig_inprogress = TRUE;\n\n    if (reds->src_do_seamless_migrate && completed) {\n        reds_migrate_channels_seamless(reds);\n    } else {\n        reds->main_channel->migrate_src_complete(completed);\n    }\n\n    if (completed) {\n        reds_mig_fill_wait_disconnect(reds);\n    } else {\n        reds_mig_cleanup(reds);\n    }\n    reds_mig_release(reds->config);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":273401,"func":"  explicit BlockLSTMOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n    if (ctx->HasAttr(\"forget_bias\")) {\n      OP_REQUIRES_OK(ctx, ctx->GetAttr(\"forget_bias\", &forget_bias_));\n    } else {\n      \/\/ V2 version does not have \"forget_bias\" attribute.\n      forget_bias_ = 0.0;\n    }\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"cell_clip\", &cell_clip_));\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"use_peephole\", &use_peephole_));\n  }","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":462547,"func":"void controller::execute_commands(char ** argv, unsigned int i) {\n\tif (v->formaction_stack_size() > 0)\n\t\tv->pop_current_formaction();\n\tfor (; argv[i]; ++i) {\n\t\tLOG(level::DEBUG, \"controller::execute_commands: executing `%s'\", argv[i]);\n\t\tstd::string cmd(argv[i]);\n\t\tif (cmd == \"reload\") {\n\t\t\treload_all(true);\n\t\t} else if (cmd == \"print-unread\") {\n\t\t\tstd::cout << strprintf::fmt(_(\"%u unread articles\"), rsscache->get_unread_count()) << std::endl;\n\t\t} else {\n\t\t\tstd::cerr << strprintf::fmt(_(\"%s: %s: unknown command\"), argv[0], argv[i]) << std::endl;\n\t\t\t::std::exit(EXIT_FAILURE);\n\t\t}\n\t}\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":436105,"func":"\nstatic int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll,\n\t\t\t   __poll_t mask, io_req_tw_func_t func)\n{\n\t\/* for instances that support it check for an event match first: *\/\n\tif (mask && !(mask & poll->events))\n\t\treturn 0;\n\n\ttrace_io_uring_task_add(req->ctx, req->opcode, req->user_data, mask);\n\n\tlist_del_init(&poll->wait.entry);\n\n\treq->result = mask;\n\treq->io_task_work.func = func;\n\n\t\/*\n\t * If this fails, then the task is exiting. When a task exits, the\n\t * work gets canceled, so just cancel this request as well instead\n\t * of executing it. We can't safely execute it anyway, as we may not\n\t * have the needed state needed for it anyway.\n\t *\/\n\tio_req_task_work_add(req);\n\treturn 1;","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":234135,"func":"xcrealloc (void *ptr, size_t nmemb, size_t size)\n{\n  \/* Check for overflow.  *\/\n  if (nmemb >= ~(size_t) 0 \/ size)\n    {\n      error (_(\"Attempt to re-allocate an array with an excessive number of elements: 0x%lx\\n\"),\n\t     (long) nmemb);\n      xexit (1);\n    }\n\n  return xrealloc (ptr, nmemb * size);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":244085,"func":"void tref_box_del(GF_Box *s)\n{\n\tGF_TrackReferenceBox *ptr = (GF_TrackReferenceBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":508885,"func":"void st_select_lex_node::include_down(st_select_lex_node *upper)\n{\n  if ((next= upper->slave))\n    next->prev= &next;\n  prev= &upper->slave;\n  upper->slave= this;\n  master= upper;\n  slave= 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":359274,"func":"peer_address_self_check (union sockunion *su)\n{\n  struct interface *ifp = NULL;\n\n  if (su->sa.sa_family == AF_INET)\n    ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);\n#ifdef HAVE_IPV6\n  else if (su->sa.sa_family == AF_INET6)\n    ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);\n#endif \/* HAVE IPV6 *\/\n\n  if (ifp)\n    return 1;\n\n  return 0;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":517459,"func":"static void do_home(HttpResponse res) {\n        do_head(res, \"\", \"\", Run.polltime);\n        StringBuffer_append(res->outputbuffer,\n                            \"<table id='header' width='100%%'>\"\n                            \" <tr>\"\n                            \"  <td colspan=2 valign='top' class='left' width='100%%'>\"\n                            \"  <h1>Monit Service Manager<\/h1>\"\n                            \"  <p class='center'>Monit is <a href='_runtime'>running<\/a> on %s and monitoring:<\/p><br>\"\n                            \"  <\/td>\"\n                            \" <\/tr>\"\n                            \"<\/table>\", Run.system->name);\n\n        do_home_system(res);\n        do_home_process(res);\n        do_home_program(res);\n        do_home_filesystem(res);\n        do_home_file(res);\n        do_home_fifo(res);\n        do_home_directory(res);\n        do_home_net(res);\n        do_home_host(res);\n\n        do_foot(res);\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":498150,"func":"void cgit_patch_link(const char *name, const char *title, const char *class,\n\t\t     const char *head, const char *rev, const char *path)\n{\n\treporevlink(\"patch\", name, title, class, head, rev, path);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":232360,"func":"\nGF_Err gf_isom_box_write_listing(GF_Box *a, GF_BitStream *bs)\n{\n\tif (!a) return GF_BAD_PARAM;\n\tif (!a->registry) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Write invalid box type %s without registry\\n\", gf_4cc_to_str(a->type) ));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\treturn a->registry->write_fn(a, bs);","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":488378,"func":"static int do_linear_fault(struct mm_struct *mm, struct vm_area_struct *vma,\n\t\tunsigned long address, pte_t *page_table, pmd_t *pmd,\n\t\tint write_access, pte_t orig_pte)\n{\n\tpgoff_t pgoff = (((address & PAGE_MASK)\n\t\t\t- vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;\n\tunsigned int flags = (write_access ? FAULT_FLAG_WRITE : 0);\n\n\tpte_unmap(page_table);\n\treturn __do_fault(mm, vma, address, pmd, pgoff, flags, orig_pte);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":319424,"func":"static MagickBooleanType IsCIN(const unsigned char *magick,const size_t length)\n{\n  if (length < 4)\n    return(MagickFalse);\n  if (memcmp(magick,\"\\200\\052\\137\\327\",4) == 0)\n    return(MagickTrue);\n  return(MagickFalse);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":387627,"func":"int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id,\n\t\t      struct snd_ctl_elem_id *dst_id)\n{\n\tstruct snd_kcontrol *kctl;\n\n\tdown_write(&card->controls_rwsem);\n\tkctl = snd_ctl_find_id(card, src_id);\n\tif (kctl == NULL) {\n\t\tup_write(&card->controls_rwsem);\n\t\treturn -ENOENT;\n\t}\n\tremove_hash_entries(card, kctl);\n\tkctl->id = *dst_id;\n\tkctl->id.numid = card->last_numid + 1;\n\tcard->last_numid += kctl->count;\n\tadd_hash_entries(card, kctl);\n\tup_write(&card->controls_rwsem);\n\treturn 0;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":275475,"func":"njs_value_string_get(njs_value_t *value, njs_str_t *dst)\n{\n    njs_string_get(value, dst);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":225944,"func":"void free_box_del(GF_Box *s)\n{\n\tGF_FreeSpaceBox *ptr = (GF_FreeSpaceBox *)s;\n\tif (ptr->data) gf_free(ptr->data);\n\tgf_free(ptr);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":294721,"func":"df_utc_to_local(int df, int of)\n{\n    df += of;\n    if (df < 0)\n\tdf += DAY_IN_SECONDS;\n    else if (df >= DAY_IN_SECONDS)\n\tdf -= DAY_IN_SECONDS;\n    return df;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":522351,"func":"int my_aio_write(struct aiocb *aiocbp)\n{\n   if( (MYFSEEK(aiocbp->aio_fildes, (off_t)aiocbp->aio_offset, SEEK_SET) == 0)\n   &&  (fwrite(aiocbp->aio_buf, 1, aiocbp->aio_nbytes, aiocbp->aio_fildes)\n       == aiocbp->aio_nbytes) )\n   {\n      aiocbp->aio_lio_opcode = 0;\n   }\n   else\n   {\n      aiocbp->aio_lio_opcode = -1;\n   }\n\n   return(aiocbp->aio_lio_opcode);\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":294672,"func":"m_min(union DateData *x)\n{\n    if (simple_dat_p(x))\n\treturn 0;\n    else {\n\tget_c_time(x);\n#ifndef USE_PACK\n\treturn x->c.min;\n#else\n\treturn EX_MIN(x->c.pc);\n#endif\n    }\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":310179,"func":"reset_color_pairs(void)\n{\n    NCURSES_SP_NAME(reset_color_pairs) (CURRENT_SCREEN);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":247326,"func":"int pgpPubkeyKeyID(const uint8_t * pkt, size_t pktlen, pgpKeyID_t keyid)\n{\n    struct pgpPkt p;\n\n    if (decodePkt(pkt, pktlen, &p))\n\treturn -1;\n    \n    return getKeyID(p.body, p.blen, keyid);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":369278,"func":"static unsigned int io_file_get_flags(struct file *file)\n{\n\tumode_t mode = file_inode(file)->i_mode;\n\tunsigned int res = 0;\n\n\tif (S_ISREG(mode))\n\t\tres |= FFS_ISREG;\n\tif (__io_file_supports_nowait(file, mode))\n\t\tres |= FFS_NOWAIT;\n\treturn res;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":502727,"func":"void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,\n                                    int (*cb) (SSL *ssl,\n                                               unsigned char *cookie,\n                                               unsigned int *cookie_len))\n{\n    ctx->app_gen_cookie_cb = cb;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":203622,"func":"con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)\n{\n\tint i, n;\n\tu16 **p1, *p2;\n\n\tp1 = p->uni_pgdir[n = unicode >> 11];\n\tif (!p1) {\n\t\tp1 = p->uni_pgdir[n] = kmalloc_array(32, sizeof(u16 *),\n\t\t\t\t\t\t     GFP_KERNEL);\n\t\tif (!p1) return -ENOMEM;\n\t\tfor (i = 0; i < 32; i++)\n\t\t\tp1[i] = NULL;\n\t}\n\n\tp2 = p1[n = (unicode >> 6) & 0x1f];\n\tif (!p2) {\n\t\tp2 = p1[n] = kmalloc_array(64, sizeof(u16), GFP_KERNEL);\n\t\tif (!p2) {\n\t\t\tkfree(p1);\n\t\t\tp->uni_pgdir[n] = NULL;\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tmemset(p2, 0xff, 64*sizeof(u16)); \/* No glyphs for the characters (yet) *\/\n\t}\n\n\tp2[unicode & 0x3f] = fontpos;\n\t\n\tp->sum += (fontpos << 20) + unicode;\n\n\treturn 0;\n}","target":1,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":294532,"func":"date_s__iso8601(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, opt;\n\n    rb_scan_args(argc, argv, \"1:\", &str, &opt);\n    check_limit(str, opt);\n\n    return date__iso8601(str);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":90896,"func":"ClientUsageTracker* UsageTracker::GetClientTracker(QuotaClient::ID client_id) {\n  ClientTrackerMap::iterator found = client_tracker_map_.find(client_id);\n  if (found != client_tracker_map_.end())\n    return found->second;\n  return NULL;\n}\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":221641,"func":"LiteralString *hermes::evalToString(IRBuilder &builder, Literal *operand) {\n  if (auto *str = llvh::dyn_cast<LiteralString>(operand))\n    return str;\n  if (auto *num = llvh::dyn_cast<LiteralNumber>(operand)) {\n    char buf[NUMBER_TO_STRING_BUF_SIZE];\n    auto len = numberToString(num->getValue(), buf, sizeof(buf));\n    return builder.getLiteralString(StringRef(buf, len));\n  }\n  return nullptr;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":384887,"func":"win_nolbr_chartabsize(\n    win_T\t*wp,\n    char_u\t*s,\n    colnr_T\tcol,\n    int\t\t*headp)\n{\n    int\t\tn;\n\n    if (*s == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1))\n    {\n# ifdef FEAT_VARTABS\n\treturn tabstop_padding(col, wp->w_buffer->b_p_ts,\n\t\t\t\t    wp->w_buffer->b_p_vts_array);\n# else\n\tn = wp->w_buffer->b_p_ts;\n\treturn (int)(n - (col % n));\n# endif\n    }\n    n = ptr2cells(s);\n    \/\/ Add one cell for a double-width character in the last column of the\n    \/\/ window, displayed with a \">\".\n    if (n == 2 && MB_BYTE2LEN(*s) > 1 && in_win_border(wp, col))\n    {\n\tif (headp != NULL)\n\t    *headp = 1;\n\treturn 3;\n    }\n    return n;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":427232,"func":"static void yindex (LexState *ls, expdesc *v) {\n  \/* index -> '[' expr ']' *\/\n  luaX_next(ls);  \/* skip the '[' *\/\n  expr(ls, v);\n  luaK_exp2val(ls->fs, v);\n  checknext(ls, ']');\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":513282,"func":"bool JOIN::prepare_result(List<Item> **columns_list)\n{\n  DBUG_ENTER(\"JOIN::prepare_result\");\n\n  error= 0;\n  \/* Create result tables for materialized views. *\/\n  if (!zero_result_cause &&\n      select_lex->handle_derived(thd->lex, DT_CREATE))\n    goto err;\n\n  if (result->prepare2())\n    goto err;\n\n  if ((select_lex->options & OPTION_SCHEMA_TABLE) &&\n      get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC))\n    goto err;\n\n  DBUG_RETURN(FALSE);\n\nerr:\n  error= 1;\n  DBUG_RETURN(TRUE);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":313771,"func":"nv_lineop(cmdarg_T *cap)\n{\n    cap->oap->motion_type = MLINE;\n    if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == FAIL)\n\tclearopbeep(cap->oap);\n    else if (  (cap->oap->op_type == OP_DELETE \/\/ only with linewise motions\n\t\t&& cap->oap->motion_force != 'v'\n\t\t&& cap->oap->motion_force != Ctrl_V)\n\t    || cap->oap->op_type == OP_LSHIFT\n\t    || cap->oap->op_type == OP_RSHIFT)\n\tbeginline(BL_SOL | BL_FIX);\n    else if (cap->oap->op_type != OP_YANK)\t\/\/ 'Y' does not move cursor\n\tbeginline(BL_WHITE | BL_FIX);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":417473,"func":"virNodeDeviceCapMdevTypesFormat(virBufferPtr buf,\n                                virMediatedDeviceTypePtr *mdev_types,\n                                const size_t nmdev_types)\n{\n    size_t i;\n\n    if (nmdev_types > 0) {\n        virBufferAddLit(buf, \"<capability type='mdev_types'>\\n\");\n        virBufferAdjustIndent(buf, 2);\n        for (i = 0; i < nmdev_types; i++) {\n            virMediatedDeviceTypePtr type = mdev_types[i];\n            virBufferEscapeString(buf, \"<type id='%s'>\\n\", type->id);\n            virBufferAdjustIndent(buf, 2);\n            if (type->name)\n                virBufferEscapeString(buf, \"<name>%s<\/name>\\n\",\n                                      type->name);\n            virBufferEscapeString(buf, \"<deviceAPI>%s<\/deviceAPI>\\n\",\n                                  type->device_api);\n            virBufferAsprintf(buf,\n                              \"<availableInstances>%u<\/availableInstances>\\n\",\n                              type->available_instances);\n            virBufferAdjustIndent(buf, -2);\n            virBufferAddLit(buf, \"<\/type>\\n\");\n        }\n        virBufferAdjustIndent(buf, -2);\n        virBufferAddLit(buf, \"<\/capability>\\n\");\n    }\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":316986,"func":"static int smk_bu_inode(struct inode *inode, int mode, int rc)\n{\n\tstruct task_smack *tsp = smack_cred(current_cred());\n\tstruct inode_smack *isp = smack_inode(inode);\n\tchar acc[SMK_NUM_ACCESS_TYPE + 1];\n\n\tif (isp->smk_flags & SMK_INODE_IMPURE)\n\t\tpr_info(\"Smack Unconfined Corruption: inode=(%s %ld) %s\\n\",\n\t\t\tinode->i_sb->s_id, inode->i_ino, current->comm);\n\n\tif (rc <= 0)\n\t\treturn rc;\n\tif (rc > SMACK_UNCONFINED_OBJECT)\n\t\trc = 0;\n\tif (rc == SMACK_UNCONFINED_SUBJECT &&\n\t    (mode & (MAY_WRITE | MAY_APPEND)))\n\t\tisp->smk_flags |= SMK_INODE_IMPURE;\n\n\tsmk_bu_mode(mode, acc);\n\n\tpr_info(\"Smack %s: (%s %s %s) inode=(%s %ld) %s\\n\", smk_bu_mess[rc],\n\t\ttsp->smk_task->smk_known, isp->smk_inode->smk_known, acc,\n\t\tinode->i_sb->s_id, inode->i_ino, current->comm);\n\treturn 0;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":513099,"func":"in_string::in_string(THD *thd, uint elements, qsort2_cmp cmp_func,\n                     CHARSET_INFO *cs)\n  :in_vector(thd, elements, sizeof(String), cmp_func, cs),\n   tmp(buff, sizeof(buff), &my_charset_bin)\n{}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":229286,"func":"cql_server::connection::process_query(uint16_t stream, request_reader in, service::client_state& client_state, service_permit permit, tracing::trace_state_ptr trace_state) {\n    ++_server._stats.query_requests;\n    return process(stream, in, client_state, std::move(permit), std::move(trace_state), process_query_internal);\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":244317,"func":"GF_Box *lsrc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_LASERConfigurationBox, GF_ISOM_BOX_TYPE_LSRC);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":336140,"func":"static void ip6gre_tnl_parm_to_user(struct ip6_tnl_parm2 *u,\n\tconst struct __ip6_tnl_parm *p)\n{\n\tu->proto = IPPROTO_GRE;\n\tu->laddr = p->laddr;\n\tu->raddr = p->raddr;\n\tu->flags = p->flags;\n\tu->hop_limit = p->hop_limit;\n\tu->encap_limit = p->encap_limit;\n\tu->flowinfo = p->flowinfo;\n\tu->link = p->link;\n\tu->i_key = p->i_key;\n\tu->o_key = p->o_key;\n\tu->i_flags = gre_tnl_flags_to_gre_flags(p->i_flags);\n\tu->o_flags = gre_tnl_flags_to_gre_flags(p->o_flags);\n\tmemcpy(u->name, p->name, sizeof(u->name));\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":343273,"func":"void addreply_noformat(const int code, const char * const line)\n{\n    if (code != 0) {\n        replycode = code;\n    }\n    addreply_newline(line, strlen(line) + (size_t) 1U);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":521480,"func":"    ~ZipInputStream() override\r\n    {\r\n       #if JUCE_DEBUG\r\n        if (inputStream != nullptr && inputStream == file.inputStream)\r\n            file.streamCounter.numOpenStreams--;\r\n       #endif\r\n    }\r","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":247555,"func":"TEST_P(SslSocketTest, NoCert) {\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.no_certificate\")\n               .setExpectNoCert()\n               .setExpectNoCertChain());\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":256175,"func":"ALWAYS_INLINE Packet ConvertFourBfloat16ToFloat(const bfloat16* src) {\n  return Eigen::internal::pload4bf16<Packet>(\n      reinterpret_cast<const float*>(src));\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":238505,"func":"static bool check_ids(u32 old_id, u32 cur_id, struct bpf_id_pair *idmap)\n{\n\tunsigned int i;\n\n\tfor (i = 0; i < BPF_ID_MAP_SIZE; i++) {\n\t\tif (!idmap[i].old) {\n\t\t\t\/* Reached an empty slot; haven't seen this id before *\/\n\t\t\tidmap[i].old = old_id;\n\t\t\tidmap[i].cur = cur_id;\n\t\t\treturn true;\n\t\t}\n\t\tif (idmap[i].old == old_id)\n\t\t\treturn idmap[i].cur == cur_id;\n\t}\n\t\/* We ran out of idmap slots, which should be impossible *\/\n\tWARN_ON_ONCE(1);\n\treturn false;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":226007,"func":"GF_Box *srpp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SRTPProcessBox, GF_ISOM_BOX_TYPE_SRPP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":224284,"func":"gopherStateFree(const CommCloseCbParams ¶ms)\n{\n    GopherStateData *gopherState = (GopherStateData *)params.data;\n    \/\/ Assume that FwdState is monitoring and calls noteClosure(). See XXX about\n    \/\/ Connection sharing with FwdState in gopherStart().\n    delete gopherState;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":247115,"func":"Bool gf_filter_unclaim_opengl_provider(GF_Filter *filter, void *vout)\n{\n\treturn GF_FALSE;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":310337,"func":"_free_cached_dir(void *_d)\n{\n  cached_dir_t *d;\n  if (!_d)\n    return;\n\n  d = (cached_dir_t *)_d;\n  cached_dir_decref(d);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":294493,"func":"dt_lite_iso8601(int argc, VALUE *argv, VALUE self)\n{\n    long n = 0;\n\n    rb_check_arity(argc, 0, 1);\n    if (argc >= 1)\n\tn = NUM2LONG(argv[0]);\n\n    return rb_str_append(strftimev(\"%Y-%m-%d\", self, set_tmx),\n\t\t\t iso8601_timediv(self, n));\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":276982,"func":"    virtual ~SampleReader() {}","target":0,"code_token_length":7,"total_token_length":243,"max_tokens_setting":512}
+{"idx":294416,"func":"check_numeric(VALUE obj, const char* field) {\n    if(!RTEST(rb_obj_is_kind_of(obj, rb_cNumeric))) {\n        rb_raise(rb_eTypeError, \"invalid %s (not numeric)\", field);\n    }\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":310057,"func":"safe_strdup(const char *value)\n{\n    if (value == NULL)\n\tvalue = \"\";\n    return strdup(value);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":336522,"func":"static void reds_disconnect(RedsState *reds)\n{\n    spice_debug(\"trace\");\n    for (auto client: reds->clients) {\n        reds_client_disconnect(reds, client);\n    }\n    reds_mig_cleanup(reds);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":448931,"func":"static unsigned long mmap_rnd(void)\n{\n\tunsigned long rnd = 0;\n\n\tif (current->flags & PF_RANDOMIZE)\n\t\trnd = (long)get_random_int() & STACK_RND_MASK;\n\n\treturn rnd << PAGE_SHIFT;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":219031,"func":"string ConstantFolding::OptimizedNodeName(const NodeDef& node,\n                                          StringPiece suffix) const {\n  return AddPrefixToNodeName(strings::StrCat(node.name(), suffix),\n                             kConstantFoldingConst);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":220831,"func":"gemmlowp::FixedPoint<tRawType, tIntegerBits> SaturatingAddNonGemmlowp(\n    gemmlowp::FixedPoint<tRawType, tIntegerBits> a,\n    gemmlowp::FixedPoint<tRawType, tIntegerBits> b) {\n  return gemmlowp::FixedPoint<tRawType, tIntegerBits>::FromRaw(\n      SaturatingAddNonGemmlowp(a.raw(), b.raw()));\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":247762,"func":"void InvertibleRWFunction::BERDecode(BufferedTransformation &bt)\n{\n\tBERSequenceDecoder seq(bt);\n\tm_n.BERDecode(seq);\n\tm_p.BERDecode(seq);\n\tm_q.BERDecode(seq);\n\tm_u.BERDecode(seq);\n\tseq.MessageEnd();\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":90897,"func":"void UsageTracker::GetGlobalUsage(GlobalUsageCallback* callback) {\n  if (client_tracker_map_.size() == 0) {\n    callback->Run(type_, 0, 0);\n    delete callback;\n    return;\n  }\n  if (global_usage_callbacks_.Add(callback)) {\n    global_usage_.pending_clients = client_tracker_map_.size();\n    global_usage_.usage = 0;\n    global_usage_.unlimited_usage = 0;\n    for (ClientTrackerMap::iterator iter = client_tracker_map_.begin();\n         iter != client_tracker_map_.end();\n         ++iter) {\n      iter->second->GetGlobalUsage(callback_factory_.NewCallback(\n          &UsageTracker::DidGetClientGlobalUsage));\n    }\n  }\n}\n","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":225771,"func":"\nGF_Err strk_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_SubTrackBox *ptr = (GF_SubTrackBox *)s;\n\tif (!a) return GF_OK;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_STRI:\n\t\tBOX_FIELD_ASSIGN(info, GF_SubTrackInformationBox)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_STRD:\n\t\tBOX_FIELD_ASSIGN(strd, GF_Box)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":452995,"func":"nft_fwd_select_ops(const struct nft_ctx *ctx,\n\t\t   const struct nlattr * const tb[])\n{\n\tif (tb[NFTA_FWD_SREG_ADDR])\n\t\treturn &nft_fwd_neigh_netdev_ops;\n\tif (tb[NFTA_FWD_SREG_DEV])\n\t\treturn &nft_fwd_netdev_ops;\n\n        return ERR_PTR(-EOPNOTSUPP);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":262004,"func":"Curl_conncache_find_bundle(struct Curl_easy *data,\n                           struct connectdata *conn,\n                           struct conncache *connc,\n                           const char **hostp)\n{\n  struct connectbundle *bundle = NULL;\n  CONNCACHE_LOCK(data);\n  if(connc) {\n    char key[HASHKEY_SIZE];\n    hashkey(conn, key, sizeof(key), hostp);\n    bundle = Curl_hash_pick(&connc->hash, key, strlen(key));\n  }\n\n  return bundle;\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":220803,"func":"  explicit RaggedCount(OpKernelConstruction* context) : OpKernel(context) {\n    OP_REQUIRES_OK(context, context->GetAttr(\"minlength\", &minlength_));\n    OP_REQUIRES_OK(context, context->GetAttr(\"maxlength\", &maxlength_));\n    OP_REQUIRES_OK(context, context->GetAttr(\"binary_output\", &binary_output_));\n  }","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":336567,"func":"static void reds_mig_target_client_add(RedsState *reds, RedClient *client)\n{\n    RedsMigTargetClient *mig_client;\n\n    g_return_if_fail(reds);\n    spice_debug(\"trace\");\n    mig_client = g_new0(RedsMigTargetClient, 1);\n    mig_client->client = client;\n    reds->mig_target_clients = g_list_append(reds->mig_target_clients, mig_client);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":224468,"func":"static Bool ttml_check_range(TTMLInterval *interval, s64 ts_begin, s64 ts_end)\n{\n\t\/\/if in current interval, push node\n\tif ((ts_begin != -1) && (ts_end != -1) && ((ts_begin>=interval->begin) && (ts_end<=interval->end))\n\t) {\n\t\treturn GF_TRUE;\n\t}\n\t\/\/begin not set, end set: in range if end less than interval end range\n\telse if ((ts_begin==-1) && (ts_end != -1) && (ts_end<=interval->end)) {\n\t\treturn GF_TRUE;\n\t}\n\t\/\/begin set, end not set: in range if begin greater than interval begin range\n\telse if ((ts_begin!=-1) && (ts_end==-1) && (ts_begin>=interval->begin)) {\n\t\treturn GF_TRUE;\n\t}\n\treturn GF_FALSE;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":307830,"func":"bool ciEnv::check_klass_accessibility(ciKlass* accessing_klass,\n                                      Klass* resolved_klass) {\n  if (accessing_klass == NULL || !accessing_klass->is_loaded()) {\n    return true;\n  }\n  if (accessing_klass->is_obj_array_klass()) {\n    accessing_klass = accessing_klass->as_obj_array_klass()->base_element_klass();\n  }\n  if (!accessing_klass->is_instance_klass()) {\n    return true;\n  }\n\n  if (resolved_klass->oop_is_objArray()) {\n    \/\/ Find the element klass, if this is an array.\n    resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass();\n  }\n  if (resolved_klass->oop_is_instance()) {\n    return Reflection::verify_class_access(accessing_klass->get_Klass(),\n                                           resolved_klass,\n                                           true);\n  }\n  return true;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":226148,"func":"GF_Err smhd_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_SoundMediaHeaderBox *ptr = (GF_SoundMediaHeaderBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u16(bs, ptr->balance);\n\tgf_bs_write_u16(bs, ptr->reserved);\n\treturn GF_OK;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":387637,"func":"static int snd_ctl_dev_register(struct snd_device *device)\n{\n\tstruct snd_card *card = device->device_data;\n\tstruct snd_ctl_layer_ops *lops;\n\tint err;\n\n\terr = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1,\n\t\t\t\t  &snd_ctl_f_ops, card, &card->ctl_dev);\n\tif (err < 0)\n\t\treturn err;\n\tdown_read(&card->controls_rwsem);\n\tdown_read(&snd_ctl_layer_rwsem);\n\tfor (lops = snd_ctl_layer; lops; lops = lops->next)\n\t\tlops->lregister(card);\n\tup_read(&snd_ctl_layer_rwsem);\n\tup_read(&card->controls_rwsem);\n\treturn 0;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":517428,"func":"static void doGet(HttpRequest req, HttpResponse res) {\n        set_content_type(res, \"text\/html\");\n        if (ACTION(HOME)) {\n                LOCK(Run.mutex)\n                do_home(res);\n                END_LOCK;\n        } else if (ACTION(RUNTIME)) {\n                handle_runtime(req, res);\n        } else if (ACTION(TEST)) {\n                is_monit_running(res);\n        } else if (ACTION(ABOUT)) {\n                do_about(res);\n        } else if (ACTION(FAVICON)) {\n                printFavicon(res);\n        } else if (ACTION(PING)) {\n                do_ping(res);\n        } else if (ACTION(GETID)) {\n                do_getid(res);\n        } else if (ACTION(STATUS)) {\n                print_status(req, res, 1);\n        } else if (ACTION(STATUS2)) {\n                print_status(req, res, 2);\n        } else if (ACTION(SUMMARY)) {\n                print_summary(req, res);\n        } else if (ACTION(REPORT)) {\n                _printReport(req, res);\n        } else {\n                handle_service(req, res);\n        }\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":333044,"func":"nfa_regbranch(void)\n{\n    int\t\told_post_pos;\n\n    old_post_pos = (int)(post_ptr - post_start);\n\n    \/\/ First branch, possibly the only one\n    if (nfa_regconcat() == FAIL)\n\treturn FAIL;\n\n    \/\/ Try next concats\n    while (peekchr() == Magic('&'))\n    {\n\tskipchr();\n\t\/\/ if concat is empty do emit a node\n\tif (old_post_pos == (int)(post_ptr - post_start))\n\t    EMIT(NFA_EMPTY);\n\tEMIT(NFA_NOPEN);\n\tEMIT(NFA_PREV_ATOM_NO_WIDTH);\n\told_post_pos = (int)(post_ptr - post_start);\n\tif (nfa_regconcat() == FAIL)\n\t    return FAIL;\n\t\/\/ if concat is empty do emit a node\n\tif (old_post_pos == (int)(post_ptr - post_start))\n\t    EMIT(NFA_EMPTY);\n\tEMIT(NFA_CONCAT);\n    }\n\n    \/\/ if a branch is empty, emit one node for it\n    if (old_post_pos == (int)(post_ptr - post_start))\n\tEMIT(NFA_EMPTY);\n\n    return OK;\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":226111,"func":"GF_Err tssy_box_size(GF_Box *s)\n{\n\ts->size += 1;\n\treturn GF_OK;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":252334,"func":"  void clear() {\n    channels.clear();\n    attributes.clear();\n\n    data_window[0] = 0;\n    data_window[1] = 0;\n    data_window[2] = 0;\n    data_window[3] = 0;\n    line_order = 0;\n    display_window[0] = 0;\n    display_window[1] = 0;\n    display_window[2] = 0;\n    display_window[3] = 0;\n    screen_window_center[0] = 0.0f;\n    screen_window_center[1] = 0.0f;\n    screen_window_width = 0.0f;\n    pixel_aspect_ratio = 0.0f;\n\n    chunk_count = 0;\n\n    \/\/ Tiled format\n    tile_size_x = 0;\n    tile_size_y = 0;\n    tile_level_mode = 0;\n    tile_rounding_mode = 0;\n\n    header_len = 0;\n    compression_type = 0;\n  }","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":338180,"func":"int32_t WasmBinaryBuilder::getS32LEB() {\n  BYN_TRACE(\"<==\\n\");\n  S32LEB ret;\n  ret.read([&]() { return (int8_t)getInt8(); });\n  BYN_TRACE(\"getS32LEB: \" << ret.value << \" ==>\\n\");\n  return ret.value;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":346468,"func":"source_breakpoint(void *cookie)\n{\n    return &((source_cookie_T *)cookie)->breakpoint;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":401554,"func":"static inline struct timer_base *get_timer_cpu_base(u32 tflags, u32 cpu)\n{\n\tstruct timer_base *base = per_cpu_ptr(&timer_bases[BASE_STD], cpu);\n\n\t\/*\n\t * If the timer is deferrable and NO_HZ_COMMON is set then we need\n\t * to use the deferrable base.\n\t *\/\n\tif (IS_ENABLED(CONFIG_NO_HZ_COMMON) && (tflags & TIMER_DEFERRABLE))\n\t\tbase = per_cpu_ptr(&timer_bases[BASE_DEF], cpu);\n\treturn base;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":263296,"func":"bool _q_countsave(const char *filepath, int number)\n{\n    int fd = open(filepath, O_CREAT|O_WRONLY|O_TRUNC, DEF_FILE_MODE);\n    if (fd < 0) return false;\n\n    char buf[10+1];\n    snprintf(buf, sizeof(buf), \"%d\", number);\n    ssize_t updated = write(fd, buf, strlen(buf));\n    close(fd);\n\n    if (updated > 0) return true;\n    return false;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":337811,"func":"int sctp_chunk_iif(const struct sctp_chunk *chunk)\n{\n\tstruct sk_buff *skb = chunk->skb;\n\n\treturn SCTP_INPUT_CB(skb)->af->skb_iif(skb);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":482687,"func":"gst_flxdec_dispose (GstFlxDec * flxdec)\n{\n  if (flxdec->adapter) {\n    g_object_unref (flxdec->adapter);\n    flxdec->adapter = NULL;\n  }\n\n  G_OBJECT_CLASS (parent_class)->dispose ((GObject *) flxdec);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":317177,"func":"static int smack_netlbl_add(struct sock *sk)\n{\n\tstruct socket_smack *ssp = sk->sk_security;\n\tstruct smack_known *skp = ssp->smk_out;\n\tint rc;\n\n\tlocal_bh_disable();\n\tbh_lock_sock_nested(sk);\n\n\trc = netlbl_sock_setattr(sk, sk->sk_family, &skp->smk_netlabel);\n\tswitch (rc) {\n\tcase 0:\n\t\tssp->smk_state = SMK_NETLBL_LABELED;\n\t\tbreak;\n\tcase -EDESTADDRREQ:\n\t\tssp->smk_state = SMK_NETLBL_REQSKB;\n\t\trc = 0;\n\t\tbreak;\n\t}\n\n\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\n\treturn rc;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":220858,"func":"inline int16_t lut_lookup(int8_t value, const int16_t* lut) {\n  return lut[128 + value];\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":294455,"func":"d_lite_day_fraction(VALUE self)\n{\n    get_d1(self);\n    if (simple_dat_p(dat))\n\treturn INT2FIX(0);\n    return m_fr(dat);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":314753,"func":"_cdf_tole8(uint64_t sv)\n{\n\tuint64_t rv;\n\tuint8_t *s = (uint8_t *)(void *)&sv;\n\tuint8_t *d = (uint8_t *)(void *)&rv;\n\td[0] = s[7];\n\td[1] = s[6];\n\td[2] = s[5];\n\td[3] = s[4];\n\td[4] = s[3];\n\td[5] = s[2];\n\td[6] = s[1];\n\td[7] = s[0];\n\treturn rv;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":222867,"func":"void GraphProperties::ClearOutputProperties(const string& node_name) {\n  output_properties_.erase(node_name);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":238658,"func":"static int resolve_map_arg_type(struct bpf_verifier_env *env,\n\t\t\t\t const struct bpf_call_arg_meta *meta,\n\t\t\t\t enum bpf_arg_type *arg_type)\n{\n\tif (!meta->map_ptr) {\n\t\t\/* kernel subsystem misconfigured verifier *\/\n\t\tverbose(env, \"invalid map_ptr to access map->type\\n\");\n\t\treturn -EACCES;\n\t}\n\n\tswitch (meta->map_ptr->map_type) {\n\tcase BPF_MAP_TYPE_SOCKMAP:\n\tcase BPF_MAP_TYPE_SOCKHASH:\n\t\tif (*arg_type == ARG_PTR_TO_MAP_VALUE) {\n\t\t\t*arg_type = ARG_PTR_TO_BTF_ID_SOCK_COMMON;\n\t\t} else {\n\t\t\tverbose(env, \"invalid arg_type for sockmap\/sockhash\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbreak;\n\tcase BPF_MAP_TYPE_BLOOM_FILTER:\n\t\tif (meta->func_id == BPF_FUNC_map_peek_elem)\n\t\t\t*arg_type = ARG_PTR_TO_MAP_VALUE;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":369107,"func":"\/* Returns true if we found and killed one or more timeouts *\/\nstatic __cold bool io_kill_timeouts(struct io_ring_ctx *ctx,\n\t\t\t\t    struct task_struct *tsk, bool cancel_all)\n{\n\tstruct io_kiocb *req, *tmp;\n\tint canceled = 0;\n\n\tspin_lock(&ctx->completion_lock);\n\tspin_lock_irq(&ctx->timeout_lock);\n\tlist_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) {\n\t\tif (io_match_task(req, tsk, cancel_all)) {\n\t\t\tio_kill_timeout(req, -ECANCELED);\n\t\t\tcanceled++;\n\t\t}\n\t}\n\tspin_unlock_irq(&ctx->timeout_lock);\n\tif (canceled != 0)\n\t\tio_commit_cqring(ctx);\n\tspin_unlock(&ctx->completion_lock);\n\tif (canceled != 0)\n\t\tio_cqring_ev_posted(ctx);\n\treturn canceled != 0;","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":244337,"func":"GF_Box *proj_type_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ProjectionTypeBox, GF_ISOM_BOX_TYPE_EQUI); \/\/will be overwritten\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":359637,"func":"DEFUN (neighbor_attr_unchanged,\n       neighbor_attr_unchanged_cmd,\n       NEIGHBOR_CMD2 \"attribute-unchanged\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"BGP attribute is propagated unchanged to this neighbor\\n\")\n{\n  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t       bgp_node_safi (vty),\n\t\t\t       (PEER_FLAG_AS_PATH_UNCHANGED |\n\t\t\t\tPEER_FLAG_NEXTHOP_UNCHANGED |\n\t\t\t\tPEER_FLAG_MED_UNCHANGED));\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":389712,"func":"check_for_string_or_func_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_PARTIAL\n\t    && args[idx].v_type != VAR_FUNC\n\t    && args[idx].v_type != VAR_STRING)\n    {\n\tsemsg(_(e_string_or_function_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":175691,"func":"  virtual void ForgetWifiNetwork(const std::string& service_path) {}\n","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":264682,"func":"lexer_hex_to_code_point (const uint8_t *source_p, \/**< current source position *\/\n                         parser_line_counter_t length) \/**< source length *\/\n{\n  lit_code_point_t result = 0;\n\n  do\n  {\n    uint32_t byte = *source_p++;\n\n    result <<= 4;\n\n    if (byte >= LIT_CHAR_0 && byte <= LIT_CHAR_9)\n    {\n      result += byte - LIT_CHAR_0;\n    }\n    else\n    {\n      byte = LEXER_TO_ASCII_LOWERCASE (byte);\n      if (byte >= LIT_CHAR_LOWERCASE_A && byte <= LIT_CHAR_LOWERCASE_F)\n      {\n        result += byte - (LIT_CHAR_LOWERCASE_A - 10);\n      }\n      else\n      {\n        return UINT32_MAX;\n      }\n    }\n  } while (--length > 0);\n\n  return result;\n} \/* lexer_hex_to_code_point *\/","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":317313,"func":"static int selinux_inode_readlink(struct dentry *dentry)\n{\n\tconst struct cred *cred = current_cred();\n\n\treturn dentry_has_perm(cred, dentry, FILE__READ);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":224758,"func":"GF_Err iref_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_ItemReferenceBox *ptr = (GF_ItemReferenceBox *)s;\n\tBOX_FIELD_LIST_ASSIGN(references)\n\treturn GF_OK;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":336687,"func":"GArray* reds_get_renderers(RedsState *reds)\n{\n    return reds->config->renderers;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":432723,"func":"static void ipa_device_close(wmfAPI * API)\n{\n  wmf_magick_t\n    *ddata = WMF_MAGICK_GetData(API);\n\n  if (ddata->draw_wand != (DrawingWand *) NULL)\n    {\n      DestroyDrawingWand(ddata->draw_wand);\n      ddata->draw_wand=(DrawingWand *) NULL;\n    }\n  if (ddata->draw_info != (DrawInfo *) NULL)\n    {\n      DestroyDrawInfo(ddata->draw_info);\n      ddata->draw_info=(DrawInfo *)NULL;\n    }\n  RelinquishMagickMemory(WMF_MAGICK_GetFontData(API)->ps_name);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":462572,"func":"bool controller::trylock_reload_mutex() {\n\tif (reload_mutex.try_lock()) {\n\t\tLOG(level::DEBUG, \"controller::trylock_reload_mutex succeeded\");\n\t\treturn true;\n\t}\n\tLOG(level::DEBUG, \"controller::trylock_reload_mutex failed\");\n\treturn false;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":220810,"func":"inline int32_t MultiplyByQuantizedMultiplier(int32_t x,\n                                             int32_t quantized_multiplier,\n                                             int shift) {\n  using gemmlowp::RoundingDivideByPOT;\n  using gemmlowp::SaturatingRoundingDoublingHighMul;\n  int left_shift = shift > 0 ? shift : 0;\n  int right_shift = shift > 0 ? 0 : -shift;\n  return RoundingDivideByPOT(SaturatingRoundingDoublingHighMul(\n                                 x * (1 << left_shift), quantized_multiplier),\n                             right_shift);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":317368,"func":"static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)\n{\n\tconst struct cred *cred = current_cred();\n\tstruct inode *inode = d_backing_inode(dentry);\n\tunsigned int ia_valid = iattr->ia_valid;\n\t__u32 av = FILE__WRITE;\n\n\t\/* ATTR_FORCE is just used for ATTR_KILL_S[UG]ID. *\/\n\tif (ia_valid & ATTR_FORCE) {\n\t\tia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_MODE |\n\t\t\t      ATTR_FORCE);\n\t\tif (!ia_valid)\n\t\t\treturn 0;\n\t}\n\n\tif (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |\n\t\t\tATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET))\n\t\treturn dentry_has_perm(cred, dentry, FILE__SETATTR);\n\n\tif (selinux_policycap_openperm() &&\n\t    inode->i_sb->s_magic != SOCKFS_MAGIC &&\n\t    (ia_valid & ATTR_SIZE) &&\n\t    !(ia_valid & ATTR_FILE))\n\t\tav |= FILE__OPEN;\n\n\treturn dentry_has_perm(cred, dentry, av);\n}","target":0,"code_token_length":242,"total_token_length":478,"max_tokens_setting":512}
+{"idx":261232,"func":"    int wm_SemUnlock(wm_Sem *s){\n        pthread_mutex_lock(&s->mutex);\n        s->lockCount--;\n        pthread_cond_signal(&s->cond);\n        pthread_mutex_unlock(&s->mutex);\n        return 0;\n    }","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":336535,"func":"MainDispatcher* reds_get_main_dispatcher(RedsState *reds)\n{\n    return reds->main_dispatcher.get();\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":336006,"func":"static int sr_read(struct usbnet *dev, u8 reg, u16 length, void *data)\n{\n\tint err;\n\n\terr = usbnet_read_cmd(dev, SR_RD_REGS, SR_REQ_RD_REG, 0, reg, data,\n\t\t\t      length);\n\tif ((err != length) && (err >= 0))\n\t\terr = -EINVAL;\n\treturn err;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":328937,"func":"R_API char *r_bin_java_print_methodref_cp_stringify(RBinJavaCPTypeObj *obj) {\n\treturn r_str_newf (\"%d.0x%04\"PFMT64x \".%s.%d.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tobj->info.cp_method.class_idx,\n\t\t\tobj->info.cp_method.name_and_type_idx);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":404752,"func":"struct file *fget_raw(unsigned int fd)\n{\n\treturn __fget(fd, 0, 1);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":387594,"func":"static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl,\n\t\t\t     unsigned int cmd, void __user *arg)\n{\n\tstruct snd_ctl_card_info *info;\n\n\tinfo = kzalloc(sizeof(*info), GFP_KERNEL);\n\tif (! info)\n\t\treturn -ENOMEM;\n\tdown_read(&snd_ioctl_rwsem);\n\tinfo->card = card->number;\n\tstrscpy(info->id, card->id, sizeof(info->id));\n\tstrscpy(info->driver, card->driver, sizeof(info->driver));\n\tstrscpy(info->name, card->shortname, sizeof(info->name));\n\tstrscpy(info->longname, card->longname, sizeof(info->longname));\n\tstrscpy(info->mixername, card->mixername, sizeof(info->mixername));\n\tstrscpy(info->components, card->components, sizeof(info->components));\n\tup_read(&snd_ioctl_rwsem);\n\tif (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) {\n\t\tkfree(info);\n\t\treturn -EFAULT;\n\t}\n\tkfree(info);\n\treturn 0;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":310125,"func":"get_baudrate(TERMINAL *termp)\n{\n    int my_ospeed;\n    int result;\n    if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) {\n#ifdef TERMIOS\n\ttermp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);\n#else\n\ttermp->Nttyb.sg_flags &= (unsigned) (~XTABS);\n#endif\n    }\n#ifdef USE_OLD_TTY\n    result = (int) cfgetospeed(&(termp->Nttyb));\n    my_ospeed = (NCURSES_OSPEED) _nc_ospeed(result);\n#else \/* !USE_OLD_TTY *\/\n#ifdef TERMIOS\n    my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb));\n#else\n    my_ospeed = (NCURSES_OSPEED) termp->Nttyb.sg_ospeed;\n#endif\n    result = _nc_baudrate(my_ospeed);\n#endif\n    termp->_baudrate = result;\n    ospeed = (NCURSES_OSPEED) my_ospeed;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":387770,"func":"void InstanceKlass::set_implementor(Klass* k) {\n  assert_lock_strong(Compile_lock);\n  assert(is_interface(), \"not interface\");\n  Klass** addr = adr_implementor();\n  assert(addr != NULL, \"null addr\");\n  if (addr != NULL) {\n    *addr = k;\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":436156,"func":"static int io_epoll_ctl_prep(struct io_kiocb *req,\n\t\t\t     const struct io_uring_sqe *sqe)\n{\n#if defined(CONFIG_EPOLL)\n\tif (sqe->ioprio || sqe->buf_index)\n\t\treturn -EINVAL;\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\n\treq->epoll.epfd = READ_ONCE(sqe->fd);\n\treq->epoll.op = READ_ONCE(sqe->len);\n\treq->epoll.fd = READ_ONCE(sqe->off);\n\n\tif (ep_op_has_event(req->epoll.op)) {\n\t\tstruct epoll_event __user *ev;\n\n\t\tev = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\t\tif (copy_from_user(&req->epoll.event, ev, sizeof(*ev)))\n\t\t\treturn -EFAULT;\n\t}\n\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":331786,"func":"void QPaintEngineEx::drawPath(const QPainterPath &path)\n{\n    if (!path.isEmpty())\n        draw(qtVectorPathForPath(path));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":379668,"func":"static void var_free(RAnalVar *var) {\n\tif (var) {\n\t\tr_anal_var_clear_accesses (var);\n\t\tr_vector_fini (&var->constraints);\n\t\tfree (var->name);\n\t\tfree (var->regname);\n\t\tfree (var->type);\n\t\tfree (var->comment);\n\t\tfree (var);\n\t}\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":366229,"func":"static void unlock_mount(struct mountpoint *where)\n{\n\tstruct dentry *dentry = where->m_dentry;\n\n\tread_seqlock_excl(&mount_lock);\n\tput_mountpoint(where);\n\tread_sequnlock_excl(&mount_lock);\n\n\tnamespace_unlock();\n\tinode_unlock(dentry->d_inode);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":328924,"func":"R_API void r_bin_java_annotation_array_free(void \/*RBinJavaAnnotationsArray*\/ *a) {\n\tRBinJavaAnnotationsArray *annotation_array = a;\n\tRListIter *iter = NULL, *iter_tmp = NULL;\n\tRBinJavaAnnotation *annotation;\n\tif (!annotation_array->annotations) {\n\t\t\/\/ TODO eprintf\n\t\treturn;\n\t}\n\tr_list_foreach_safe (annotation_array->annotations, iter, iter_tmp, annotation) {\n\t\tif (annotation) {\n\t\t\tr_bin_java_annotation_free (annotation);\n\t\t}\n\t\t\/\/ r_list_delete (annotation_array->annotations, iter);\n\t}\n\tr_list_free (annotation_array->annotations);\n\tfree (annotation_array);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":261381,"func":"static int  decode_explicit_rdpcm_flag(thread_context* tctx,int cIdx)\n{\n  context_model* model = &tctx->ctx_model[CONTEXT_MODEL_RDPCM_FLAG];\n  int value = decode_CABAC_bit(&tctx->cabac_decoder, &model[cIdx ? 1 : 0]);\n  return value;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":232947,"func":"exit_zlib(struct Curl_easy *data,\n          z_stream *z, zlibInitState *zlib_init, CURLcode result)\n{\n  if(*zlib_init == ZLIB_GZIP_HEADER)\n    Curl_safefree(z->next_in);\n\n  if(*zlib_init != ZLIB_UNINIT) {\n    if(inflateEnd(z) != Z_OK && result == CURLE_OK)\n      result = process_zlib_error(data, z);\n    *zlib_init = ZLIB_UNINIT;\n  }\n\n  return result;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":359198,"func":"static unsigned long ringbuf_avail_data_sz(struct bpf_ringbuf *rb)\n{\n\tunsigned long cons_pos, prod_pos;\n\n\tcons_pos = smp_load_acquire(&rb->consumer_pos);\n\tprod_pos = smp_load_acquire(&rb->producer_pos);\n\treturn prod_pos - cons_pos;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":484052,"func":"main(void) {\n    Suite *s = testSuite_SecureChannel();\n    SRunner *sr = srunner_create(s);\n    srunner_set_fork_status(sr, CK_NOFORK);\n    srunner_run_all(sr, CK_NORMAL);\n    int number_failed = srunner_ntests_failed(sr);\n    srunner_free(sr);\n    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":462324,"func":"pcstatus_do_reset(pcl_state_t * pcs, pcl_reset_type_t type)\n{\n    if (type & (pcl_reset_initial | pcl_reset_printer)) {\n        if (type & pcl_reset_initial) {\n            pcs->status.buffer = 0;\n            pcs->status.write_pos = 0;\n            pcs->status.read_pos = 0;\n        }\n        pcs->location_type = 0;\n        pcs->location_unit = 0;\n    }\n\n    return 0;\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":512534,"func":"cmp_item* cmp_item_sort_string::make_same()\n{\n  return new cmp_item_sort_string_in_static(cmp_charset);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":459150,"func":"static void tcf_block_remove(struct tcf_block *block, struct net *net)\n{\n\tstruct tcf_net *tn = net_generic(net, tcf_net_id);\n\n\tspin_lock(&tn->idr_lock);\n\tidr_remove(&tn->idr, block->index);\n\tspin_unlock(&tn->idr_lock);\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":482519,"func":"includeFile(const FileInfo *file, CharsString *includedFile,\n\t\tTranslationTableHeader **table, DisplayTableHeader **displayTable) {\n\tint k;\n\tchar includeThis[MAXSTRING];\n\tchar **tableFiles;\n\tint rv;\n\tfor (k = 0; k < includedFile->length; k++)\n\t\tincludeThis[k] = (char)includedFile->chars[k];\n\tif (k >= MAXSTRING) {\n\t\tcompileError(file, \"Include statement too long: 'include %s'\", includeThis);\n\t\treturn 0;\n\t}\n\tincludeThis[k] = 0;\n\ttableFiles = _lou_resolveTable(includeThis, file->fileName);\n\tif (tableFiles == NULL) {\n\t\terrorCount++;\n\t\treturn 0;\n\t}\n\tif (tableFiles[1] != NULL) {\n\t\tfree_tablefiles(tableFiles);\n\t\tcompileError(file, \"Table list not supported in include statement: 'include %s'\",\n\t\t\t\tincludeThis);\n\t\treturn 0;\n\t}\n\trv = compileFile(*tableFiles, table, displayTable);\n\tfree_tablefiles(tableFiles);\n\tif (!rv)\n\t\t_lou_logMessage(LOU_LOG_ERROR, \"%s:%d: Error in included file\", file->fileName,\n\t\t\t\tfile->lineNumber);\n\treturn rv;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":487662,"func":"static int __kprobes notifier_call_chain(struct notifier_block **nl,\n\t\tunsigned long val, void *v)\n{\n\tint ret = NOTIFY_DONE;\n\tstruct notifier_block *nb, *next_nb;\n\n\tnb = rcu_dereference(*nl);\n\twhile (nb) {\n\t\tnext_nb = rcu_dereference(nb->next);\n\t\tret = nb->notifier_call(nb, val, v);\n\t\tif ((ret & NOTIFY_STOP_MASK) == NOTIFY_STOP_MASK)\n\t\t\tbreak;\n\t\tnb = next_nb;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":317077,"func":"static int smack_syslog(int typefrom_file)\n{\n\tint rc = 0;\n\tstruct smack_known *skp = smk_of_current();\n\n\tif (smack_privileged(CAP_MAC_OVERRIDE))\n\t\treturn 0;\n\n\tif (smack_syslog_label != NULL && smack_syslog_label != skp)\n\t\trc = -EACCES;\n\n\treturn rc;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":309830,"func":"NCURSES_SP_NAME(mouseinterval) (NCURSES_SP_DCLx int maxclick)\n\/* set the maximum mouse interval within which to recognize a click *\/\n{\n    int oldval;\n\n    T((T_CALLED(\"mouseinterval(%p,%d)\"), (void *) SP_PARM, maxclick));\n\n    if (SP_PARM != 0) {\n\toldval = SP_PARM->_maxclick;\n\tif (maxclick >= 0)\n\t    SP_PARM->_maxclick = maxclick;\n    } else {\n\toldval = DEFAULT_MAXCLICK;\n    }\n\n    returnCode(oldval);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":313563,"func":"\t__acquires(rose_node_list_lock)\n{\n\tstruct rose_node *rose_node;\n\tint i = 1;\n\n\tspin_lock_bh(&rose_node_list_lock);\n\tif (*pos == 0)\n\t\treturn SEQ_START_TOKEN;\n\n\tfor (rose_node = rose_node_list; rose_node && i < *pos;\n\t     rose_node = rose_node->next, ++i);\n\n\treturn (i == *pos) ? rose_node : NULL;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":337843,"func":"struct sctp_chunk *sctp_make_ifwdtsn(const struct sctp_association *asoc,\n\t\t\t\t     __u32 new_cum_tsn, size_t nstreams,\n\t\t\t\t     struct sctp_ifwdtsn_skip *skiplist)\n{\n\tstruct sctp_chunk *retval = NULL;\n\tstruct sctp_ifwdtsn_hdr ftsn_hdr;\n\tsize_t hint;\n\n\thint = (nstreams + 1) * sizeof(__u32);\n\n\tretval = sctp_make_control(asoc, SCTP_CID_I_FWD_TSN, 0, hint,\n\t\t\t\t   GFP_ATOMIC);\n\tif (!retval)\n\t\treturn NULL;\n\n\tftsn_hdr.new_cum_tsn = htonl(new_cum_tsn);\n\tretval->subh.ifwdtsn_hdr =\n\t\tsctp_addto_chunk(retval, sizeof(ftsn_hdr), &ftsn_hdr);\n\n\tsctp_addto_chunk(retval, nstreams * sizeof(skiplist[0]), skiplist);\n\n\treturn retval;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":236177,"func":"GF_Err tx3g_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_Tx3gSampleEntryBox *ptr = (GF_Tx3gSampleEntryBox*)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_FTAB:\n\t\tBOX_FIELD_ASSIGN(font_table, GF_FontTableBox)\n\t\tbreak;\n\tdefault:\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":386542,"func":"void DL_Dxf::writeUcs(DL_WriterA& dw) {\n    dw.dxfString(  0, \"TABLE\");\n    dw.dxfString(  2, \"UCS\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfHex(5, 7);\n    }\n    \/\/dw.dxfHex(330, 0);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbSymbolTable\");\n    }\n    dw.dxfInt( 70, 0);\n    dw.dxfString(  0, \"ENDTAB\");\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":457872,"func":"gegl_op_class_init (GeglOpClass *klass)\n{\n  GeglOperationClass       *operation_class;\n  GObjectClass             *object_class;\n\n  operation_class = GEGL_OPERATION_CLASS (klass);\n  object_class    = G_OBJECT_CLASS (klass);\n\n  object_class->finalize = finalize;\n\n  operation_class->process = process;\n  operation_class->get_bounding_box = get_bounding_box;\n  operation_class->get_cached_region = get_cached_region;;\n\n  gegl_operation_class_set_keys (operation_class,\n        \"name\"       , \"gegl:magick-load\",\n        \"categories\" , \"hidden\",\n        \"description\",\n        _(\"Image Magick wrapper using the png op.\"),\n        NULL);\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":415205,"func":"cmd_setattr (assuan_context_t ctx, char *orig_line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n  int rc;\n  char *keyword;\n  int keywordlen;\n  size_t nbytes;\n  char *line, *linebuf;\n\n  if ( IS_LOCKED (ctrl) )\n    return gpg_error (GPG_ERR_LOCKED);\n\n  if ((rc = open_card (ctrl, NULL)))\n    return rc;\n\n  \/* We need to use a copy of LINE, because PIN_CB uses the same\n     context and thus reuses the Assuan provided LINE. *\/\n  line = linebuf = xtrystrdup (orig_line);\n  if (!line)\n    return out_of_core ();\n\n  keyword = line;\n  for (keywordlen=0; *line && !spacep (line); line++, keywordlen++)\n    ;\n  if (*line)\n      *line++ = 0;\n  while (spacep (line))\n    line++;\n  nbytes = percent_plus_unescape_inplace (line, 0);\n\n  rc = app_setattr (ctrl->app_ctx, keyword, pin_cb, ctx,\n                    (const unsigned char*)line, nbytes);\n  xfree (linebuf);\n\n  TEST_CARD_REMOVAL (ctrl, rc);\n  return rc;\n}","target":0,"code_token_length":270,"total_token_length":506,"max_tokens_setting":512}
+{"idx":236186,"func":"void text_box_del(GF_Box *s)\n{\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\tgf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);\n\n\tif (ptr->textName)\n\t\tgf_free(ptr->textName);\n\tgf_free(ptr);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":261428,"func":"static int decode_cbf_chroma(thread_context* tctx,\n\t\t\t     int trafoDepth)\n{\n  logtrace(LogSlice,\"# cbf_chroma\\n\");\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_CBF_CHROMA + trafoDepth]);\n\n  logtrace(LogSymbols,\"$1 cbf_chroma=%d\\n\",bit);\n  return bit;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":463192,"func":"static void init_internal()\n{\n    if (!annotate_initialized) {\n        annotate_init(NULL, NULL);\n        cyrus_modules_add(done_cb, NULL);\n    }\n    if (!annotatemore_dbopen) {\n        annotatemore_open();\n    }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":404701,"func":"int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)\n{\n\tint error;\n\n\terror = security_file_receive(file);\n\tif (error)\n\t\treturn error;\n\terror = replace_fd(new_fd, file, o_flags);\n\tif (error)\n\t\treturn error;\n\t__receive_sock(file);\n\treturn new_fd;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":274667,"func":"callbacks_switch_to_correct_cursor (void)\n{\n\tGdkWindow *drawing_area_window = screen.drawing_area->window;\n\tGdkCursor *cursor;\n\n\tif (screen.state == IN_MOVE) {\n\t\tcursor = gdk_cursor_new(GDK_FLEUR);\n\t\tgdk_window_set_cursor(drawing_area_window, cursor);\n\t\tgdk_cursor_destroy(cursor);\n\t\treturn;\n\t}\n\telse if (screen.state == IN_ZOOM_OUTLINE) {\n\t\tcursor = gdk_cursor_new(GDK_SIZING);\n\t\tgdk_window_set_cursor(drawing_area_window, cursor);\n\t\tgdk_cursor_destroy(cursor);\n\t\treturn;\n\t}\n\tcallbacks_switch_to_normal_tool_cursor (screen.tool);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":400119,"func":"set<int> PipeSocketHandler::getEndpointFds(const SocketEndpoint& endpoint) {\n  lock_guard<std::recursive_mutex> guard(globalMutex);\n\n  string pipePath = endpoint.name();\n  if (pipeServerSockets.find(pipePath) == pipeServerSockets.end()) {\n    STFATAL << \"Tried to getPipeFd on a pipe without calling listen() first: \"\n            << pipePath;\n  }\n  return pipeServerSockets[pipePath];\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":226066,"func":"GF_Err dref_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 count;\n\tGF_DataReferenceBox *ptr = (GF_DataReferenceBox *)s;\n\tif (!s) return GF_BAD_PARAM;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tcount = ptr->child_boxes ? gf_list_count(ptr->child_boxes) : 0;\n\tgf_bs_write_u32(bs, count);\n\treturn GF_OK;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":502691,"func":"void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,\n                                void (*cb) (SSL_CTX *ctx, SSL_SESSION *sess))\n{\n    ctx->remove_session_cb = cb;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":234145,"func":"cmalloc (size_t nmemb, size_t size)\n{\n  \/* Check for overflow.  *\/\n  if (nmemb >= ~(size_t) 0 \/ size)\n    return NULL;\n\n  return xmalloc (nmemb * size);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":236146,"func":"GF_Err dims_box_size(GF_Box *s)\n{\n\tu32 pos = 0;\n\tGF_DIMSSampleEntryBox *p = (GF_DIMSSampleEntryBox *)s;\n\ts->size += 8;\n\tgf_isom_check_position(s, (GF_Box *) p->config, &pos);\n\tgf_isom_check_position(s, (GF_Box *) p->scripts, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":424909,"func":"static void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr,\n\t\t\t\t      u32 val)\n{\n\tu32 mask = iwl_trans_pcie_prph_msk(trans);\n\n\tiwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WADDR,\n\t\t\t       ((addr & mask) | (3 << 24)));\n\tiwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WDAT, val);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":462325,"func":"pcl_set_readback_loc_unit(pcl_args_t * pargs, pcl_state_t * pcs)\n{\n    pcs->location_unit = uint_arg(pargs);\n    return 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":293533,"func":"PJ_DEF(void) pj_scan_get_newline( pj_scanner *scanner )\n{\n    if (!PJ_SCAN_IS_NEWLINE(*scanner->curptr)) {\n\tpj_scan_syntax_err(scanner);\n\treturn;\n    }\n\n    if (*scanner->curptr == '\\r') {\n\t++scanner->curptr;\n    }\n    if (*scanner->curptr == '\\n') {\n\t++scanner->curptr;\n    }\n\n    ++scanner->line;\n    scanner->start_line = scanner->curptr;\n\n    \/**\n     * This probably is a bug, see PROTOS test #2480.\n     * This would cause scanner to incorrectly eat two new lines, e.g.\n     * when parsing:\n     *   \n     *\tContent-Length: 120\\r\\n\n     *\t\\r\\n\n     *\t<space><space><space>...\n     *\n     * When pj_scan_get_newline() is called to parse the first newline\n     * in the Content-Length header, it will eat the second newline\n     * too because it thinks that it's a header continuation.\n     *\n     * if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {\n     *    pj_scan_skip_whitespace(scanner);\n     * }\n     *\/\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":481281,"func":"static void mlx5_fpga_conn_unmap_buf(struct mlx5_fpga_conn *conn,\n\t\t\t\t     struct mlx5_fpga_dma_buf *buf)\n{\n\tstruct device *dma_device;\n\n\tdma_device = &conn->fdev->mdev->pdev->dev;\n\tif (buf->sg[1].data)\n\t\tdma_unmap_single(dma_device, buf->sg[1].dma_addr,\n\t\t\t\t buf->sg[1].size, buf->dma_dir);\n\n\tif (likely(buf->sg[0].data))\n\t\tdma_unmap_single(dma_device, buf->sg[0].dma_addr,\n\t\t\t\t buf->sg[0].size, buf->dma_dir);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":424918,"func":"static int iwl_pcie_init_msix_handler(struct pci_dev *pdev,\n\t\t\t\t      struct iwl_trans_pcie *trans_pcie)\n{\n\tint i;\n\n\tfor (i = 0; i < trans_pcie->alloc_vecs; i++) {\n\t\tint ret;\n\t\tstruct msix_entry *msix_entry;\n\t\tconst char *qname = queue_name(&pdev->dev, trans_pcie, i);\n\n\t\tif (!qname)\n\t\t\treturn -ENOMEM;\n\n\t\tmsix_entry = &trans_pcie->msix_entries[i];\n\t\tret = devm_request_threaded_irq(&pdev->dev,\n\t\t\t\t\t\tmsix_entry->vector,\n\t\t\t\t\t\tiwl_pcie_msix_isr,\n\t\t\t\t\t\t(i == trans_pcie->def_irq) ?\n\t\t\t\t\t\tiwl_pcie_irq_msix_handler :\n\t\t\t\t\t\tiwl_pcie_irq_rx_msix_handler,\n\t\t\t\t\t\tIRQF_SHARED,\n\t\t\t\t\t\tqname,\n\t\t\t\t\t\tmsix_entry);\n\t\tif (ret) {\n\t\t\tIWL_ERR(trans_pcie->trans,\n\t\t\t\t\"Error allocating IRQ %d\\n\", i);\n\n\t\t\treturn ret;\n\t\t}\n\t}\n\tiwl_pcie_irq_set_affinity(trans_pcie->trans);\n\n\treturn 0;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":459184,"func":"void tc_cleanup_offload_action(struct flow_action *flow_action)\n{\n\tstruct flow_action_entry *entry;\n\tint i;\n\n\tflow_action_for_each(i, entry, flow_action) {\n\t\ttcf_act_put_cookie(entry);\n\t\tif (entry->destructor)\n\t\t\tentry->destructor(entry->destructor_priv);\n\t}\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":508364,"func":"bool close_cached_connection_tables(THD *thd, LEX_STRING *connection)\n{\n  close_cached_connection_tables_arg argument;\n  DBUG_ENTER(\"close_cached_connections\");\n  DBUG_ASSERT(thd);\n\n  argument.thd= thd;\n  argument.connection= connection;\n  argument.tables= NULL;\n\n  if (tdc_iterate(thd,\n                  (my_hash_walk_action) close_cached_connection_tables_callback,\n                  &argument))\n    DBUG_RETURN(true);\n\n  DBUG_RETURN(argument.tables ?\n              close_cached_tables(thd, argument.tables, FALSE, LONG_TIMEOUT) :\n              false);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":225896,"func":"\nGF_Err udta_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e = gf_isom_box_array_read(s, bs);\n\tif (e) return e;\n\tif (s->size==4) {\n\t\tu32 val = gf_bs_read_u32(bs);\n\t\ts->size = 0;\n\t\tif (val) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] udta has 4 remaining bytes set to %08X but they should be 0\\n\", val));\n\t\t}\n\t}\n\treturn GF_OK;","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":308180,"func":"static void fastrpc_map_put(struct fastrpc_map *map)\n{\n\tif (map)\n\t\tkref_put(&map->refcount, fastrpc_free_map);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":387748,"func":"ModuleEntry* InstanceKlass::module() const {\n  if (!in_unnamed_package()) {\n    return _package_entry->module();\n  }\n  const Klass* host = host_klass();\n  if (host == NULL) {\n    return class_loader_data()->unnamed_module();\n  }\n  return host->class_loader_data()->unnamed_module();\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":513109,"func":"inline void TABLE::mark_virtual_column_deps(Field *field)\n{\n  DBUG_ASSERT(field->vcol_info);\n  DBUG_ASSERT(field->vcol_info->expr);\n  field->vcol_info->expr->walk(&Item::register_field_in_read_map, 1, 0);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":261246,"func":"void MqttClient_DeInit(MqttClient *client)\n{\n    if (client != NULL) {\n#ifdef WOLFMQTT_MULTITHREAD\n        (void)wm_SemFree(&client->lockSend);\n        (void)wm_SemFree(&client->lockRecv);\n        (void)wm_SemFree(&client->lockClient);\n#endif\n    }\n#ifdef WOLFMQTT_V5\n    (void)MqttProps_ShutDown();\n#endif\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":225866,"func":"GF_Err tpyl_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_NTYLBox *ptr = (GF_NTYLBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\tISOM_DECREASE_SIZE(ptr, 8);\n\tptr->nbBytes = gf_bs_read_u64(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":473938,"func":"onigenc_not_support_get_ctype_code_range(OnigCtype ctype,\n                       OnigCodePoint* sb_out, const OnigCodePoint* ranges[],\n\t\t       OnigEncoding enc)\n{\n  return ONIG_NO_SUPPORT_CONFIG;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":348431,"func":"static struct mkiss *mkiss_get(struct tty_struct *tty)\n{\n\tstruct mkiss *ax;\n\n\tread_lock(&disc_data_lock);\n\tax = tty->disc_data;\n\tif (ax)\n\t\trefcount_inc(&ax->refcnt);\n\tread_unlock(&disc_data_lock);\n\n\treturn ax;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":508878,"func":"bool st_select_lex::test_limit()\n{\n  if (select_limit != 0)\n  {\n    my_error(ER_NOT_SUPPORTED_YET, MYF(0),\n             \"LIMIT & IN\/ALL\/ANY\/SOME subquery\");\n    return(1);\n  }\n  return(0);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":312469,"func":"f_getqflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)\n{\n# ifdef FEAT_QUICKFIX\n    if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL)\n\treturn;\n\n    get_qf_loc_list(TRUE, NULL, &argvars[0], rettv);\n# endif\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":225500,"func":"MutableGraphView::GetFanout(const GraphView::OutputPort& port) const {\n  return GetFanout(MutableGraphView::OutputPort(const_cast<NodeDef*>(port.node),\n                                                port.port_id));\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":359316,"func":"DEFUN (ip_community_list_name_standard,\n       ip_community_list_name_standard_cmd,\n       \"ip community-list standard WORD (deny|permit) .AA:NN\",\n       IP_STR\n       COMMUNITY_LIST_STR\n       \"Add a standard community-list entry\\n\"\n       \"Community list name\\n\"\n       \"Specify community to reject\\n\"\n       \"Specify community to accept\\n\"\n       COMMUNITY_VAL_STR)\n{\n  return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":512396,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_cache_str>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":248274,"func":"DLLIMPORT signed long cfg_getint(cfg_t *cfg, const char *name)\n{\n\treturn cfg_getnint(cfg, name, 0);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":387621,"func":"static int snd_ctl_elem_info(struct snd_ctl_file *ctl,\n\t\t\t     struct snd_ctl_elem_info *info)\n{\n\tstruct snd_card *card = ctl->card;\n\tstruct snd_kcontrol *kctl;\n\tint result;\n\n\tdown_read(&card->controls_rwsem);\n\tkctl = snd_ctl_find_id(card, &info->id);\n\tif (kctl == NULL)\n\t\tresult = -ENOENT;\n\telse\n\t\tresult = __snd_ctl_elem_info(card, kctl, info, ctl);\n\tup_read(&card->controls_rwsem);\n\treturn result;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":369310,"func":"static int io_mkdirat(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_mkdir *mkd = &req->mkdir;\n\tint ret;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tret = do_mkdirat(mkd->dfd, mkd->filename, mkd->mode);\n\n\treq->flags &= ~REQ_F_NEED_CLEANUP;\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":289317,"func":"static int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params,\n\t\t\t\t snd_pcm_hw_param_t var, unsigned int val,\n\t\t\t\t int dir)\n{\n\tint changed;\n\tint open = 0;\n\tif (dir) {\n\t\tif (dir > 0) {\n\t\t\topen = 1;\n\t\t} else if (dir < 0) {\n\t\t\tif (val > 0) {\n\t\t\t\topen = 1;\n\t\t\t\tval--;\n\t\t\t}\n\t\t}\n\t}\n\tif (hw_is_mask(var))\n\t\tchanged = snd_mask_refine_min(hw_param_mask(params, var),\n\t\t\t\t\t      val + !!open);\n\telse if (hw_is_interval(var))\n\t\tchanged = snd_interval_refine_min(hw_param_interval(params, var),\n\t\t\t\t\t\t  val, open);\n\telse\n\t\treturn -EINVAL;\n\tif (changed > 0) {\n\t\tparams->cmask |= 1 << var;\n\t\tparams->rmask |= 1 << var;\n\t}\n\treturn changed;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":384812,"func":"byte2cells(int b)\n{\n    if (enc_utf8 && b >= 0x80)\n\treturn 0;\n    return (g_chartab[b] & CT_CELL_MASK);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":522362,"func":"int GmfGotoKwd(int64_t MshIdx, int KwdCod)\n{\n   GmfMshSct   *msh = (GmfMshSct *)MshIdx;\n   KwdSct      *kwd = &msh->KwdTab[ KwdCod ];\n\n   if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) || !kwd->NmbLin )\n      return(0);\n\n   return(SetFilPos(msh, kwd->pos));\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":432165,"func":"RAMBlock *qemu_ram_alloc(struct uc_struct *uc, ram_addr_t size, MemoryRegion *mr)\n{\n    return qemu_ram_alloc_from_ptr(uc, size, NULL, mr);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":353193,"func":"bool SplashOutputDev::imageMaskSrc(void *data, SplashColorPtr line) {\n  SplashOutImageMaskData *imgMaskData = (SplashOutImageMaskData *)data;\n  unsigned char *p;\n  SplashColorPtr q;\n  int x;\n\n  if (imgMaskData->y == imgMaskData->height) {\n    return false;\n  }\n  if (!(p = imgMaskData->imgStr->getLine())) {\n    return false;\n  }\n  for (x = 0, q = line; x < imgMaskData->width; ++x) {\n    *q++ = *p++ ^ imgMaskData->invert;\n  }\n  ++imgMaskData->y;\n  return true;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":458998,"func":"http_GetHdrToken(const struct http *hp, hdr_t hdr,\n    const char *token, const char **pb, const char **pe)\n{\n\tconst char *h, *b, *e;\n\n\tif (pb != NULL)\n\t\t*pb = NULL;\n\tif (pe != NULL)\n\t\t*pe = NULL;\n\tif (!http_GetHdr(hp, hdr, &h))\n\t\treturn (0);\n\tAN(h);\n\n\twhile (http_split(&h, NULL, \",\", &b, &e))\n\t\tif (http_istoken(&b, e, token))\n\t\t\tbreak;\n\tif (b == NULL)\n\t\treturn (0);\n\tif (pb != NULL) {\n\t\tfor (; vct_islws(*b); b++)\n\t\t\tcontinue;\n\t\tif (b == e) {\n\t\t\tb = NULL;\n\t\t\te = NULL;\n\t\t}\n\t\t*pb = b;\n\t\tif (pe != NULL)\n\t\t\t*pe = e;\n\t}\n\treturn (1);\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":238412,"func":"static bool reg_type_may_be_refcounted_or_null(enum bpf_reg_type type)\n{\n\treturn base_type(type) == PTR_TO_SOCKET ||\n\t\tbase_type(type) == PTR_TO_TCP_SOCK ||\n\t\tbase_type(type) == PTR_TO_MEM;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":248246,"func":"static char *parse_title(const char *name, size_t *len)\n{\n\tconst char *escapes = \"'\\\\\";\n\tchar *title;\n\tchar *end;\n\tchar *ch;\n\n\tif (*name != '\\'') {\n\t\t*len = strcspn(name, \"|\");\n\t\tif (!*len)\n\t\t\treturn NULL;\n\t\treturn strndup(name, *len);\n\t}\n\n\ttitle = strdup(name + 1);\n\tif (!title)\n\t\treturn NULL;\n\n\t*len = 1;\n\tch = title;\n\tend = title + strlen(title);\n\twhile (ch < end) {\n\t\tsize_t l = strcspn(ch, escapes);\n\t\t*len += l + 1;\n\t\tch += l;\n\t\tswitch (*ch) {\n\t\tcase '\\'':\n\t\t\t*ch = 0;\n\t\t\treturn title;\n\t\tcase '\\\\':\n\t\t\tif (!ch[1] || strcspn(ch + 1, escapes)) {\n\t\t\t\tfree(title);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tmemmove(ch, ch + 1, strlen(ch));\n\t\t\tch++;\n\t\t\t(*len)++;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfree(title);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tfree(title);\n\treturn NULL;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":300778,"func":"static bool tipc_sk_connected(struct sock *sk)\n{\n\treturn sk->sk_state == TIPC_ESTABLISHED;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":421389,"func":"static void puna(int d, int p, js_Ast *exp, const char *pre, const char *suf)\n{\n\tps(pre);\n\tpexpi(d, p, exp->a);\n\tps(suf);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":125901,"func":"v8::Handle<v8::Value> V8ThrowException::createRangeError(v8::Isolate* isolate, const String& message)\n{\n    return v8::Exception::RangeError(v8String(isolate, message.isNull() ? \"Range error\" : message));\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":345207,"func":"int con_set_trans_old(unsigned char __user * arg)\n{\n\tint i;\n\tunsigned short inbuf[E_TABSZ];\n\tunsigned char ubuf[E_TABSZ];\n\n\tif (copy_from_user(ubuf, arg, E_TABSZ))\n\t\treturn -EFAULT;\n\n\tfor (i = 0; i < E_TABSZ ; i++)\n\t\tinbuf[i] = UNI_DIRECT_BASE | ubuf[i];\n\n\tconsole_lock();\n\tmemcpy(translations[USER_MAP], inbuf, sizeof(inbuf));\n\tupdate_user_maps();\n\tconsole_unlock();\n\treturn 0;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":238619,"func":"static int add_subprog(struct bpf_verifier_env *env, int off)\n{\n\tint insn_cnt = env->prog->len;\n\tint ret;\n\n\tif (off >= insn_cnt || off < 0) {\n\t\tverbose(env, \"call to invalid destination\\n\");\n\t\treturn -EINVAL;\n\t}\n\tret = find_subprog(env, off);\n\tif (ret >= 0)\n\t\treturn ret;\n\tif (env->subprog_cnt >= BPF_MAX_SUBPROGS) {\n\t\tverbose(env, \"too many subprograms\\n\");\n\t\treturn -E2BIG;\n\t}\n\t\/* determine subprog starts. The end is one before the next starts *\/\n\tenv->subprog_info[env->subprog_cnt++].start = off;\n\tsort(env->subprog_info, env->subprog_cnt,\n\t     sizeof(env->subprog_info[0]), cmp_subprogs, NULL);\n\treturn env->subprog_cnt - 1;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":453001,"func":"static int nft_dup_netdev_offload(struct nft_offload_ctx *ctx,\n\t\t\t\t  struct nft_flow_rule *flow,\n\t\t\t\t  const struct nft_expr *expr)\n{\n\tconst struct nft_dup_netdev *priv = nft_expr_priv(expr);\n\tint oif = ctx->regs[priv->sreg_dev].data.data[0];\n\n\treturn nft_fwd_dup_netdev_offload(ctx, flow, FLOW_ACTION_MIRRED, oif);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":310281,"func":"dirserv_should_launch_reachability_test(routerinfo_t *ri, routerinfo_t *ri_old)\n{\n  if (!authdir_mode_handles_descs(get_options(), ri->purpose))\n    return 0;\n  if (!ri_old) {\n    \/* New router: Launch an immediate reachability test, so we will have an\n     * opinion soon in case we're generating a consensus soon *\/\n    return 1;\n  }\n  if (ri_old->is_hibernating && !ri->is_hibernating) {\n    \/* It just came out of hibernation; launch a reachability test *\/\n    return 1;\n  }\n  if (! routers_have_same_or_addr(ri, ri_old)) {\n    \/* Address or port changed; launch a reachability test *\/\n    return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":445922,"func":"overwrite_dialog_response_cb (GtkDialog *dialog,\n\t\t\t      int        response_id,\n\t\t\t      gpointer   user_data)\n{\n\tOverwriteData *odata = user_data;\n\tgboolean       do_not_extract = FALSE;\n\n\tswitch (response_id) {\n\tcase _FR_RESPONSE_OVERWRITE_YES_ALL:\n\t\todata->edata->overwrite = FR_OVERWRITE_YES;\n\t\tbreak;\n\n\tcase _FR_RESPONSE_OVERWRITE_YES:\n\t\todata->current_file = odata->current_file->next;\n\t\tbreak;\n\n\tcase _FR_RESPONSE_OVERWRITE_NO:\n\t\t{\n\t\t\t\/* remove the file from the list to extract *\/\n\t\t\tGList *next = odata->current_file->next;\n\n\t\t\todata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file);\n\t\t\t_g_string_list_free (odata->current_file);\n\t\t\todata->current_file = next;\n\t\t\todata->extract_all = FALSE;\n\t\t}\n\t\tbreak;\n\n\tcase GTK_RESPONSE_DELETE_EVENT:\n\tcase GTK_RESPONSE_CANCEL:\n\t\tdo_not_extract = TRUE;\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\tgtk_widget_destroy (GTK_WIDGET (dialog));\n\n\tif (do_not_extract) {\n\t\tfr_window_stop_batch (odata->window);\n\t\tg_free (odata);\n\t\treturn;\n\t}\n\n\t_fr_window_ask_overwrite_dialog (odata);\n}","target":0,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":90760,"func":"  void DidGetHostQuota(QuotaStatusCode status,\n                       const std::string& host,\n                       StorageType type,\n                       int64 quota) {\n    DCHECK_EQ(host_, host);\n    DCHECK_EQ(type_, type);\n    quota_status_ = status;\n    quota_ = quota;\n    CheckCompleted();\n  }\n","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":225093,"func":"uint64 OpDefHash(const OpDef& o) {\n  uint64 h = RepeatedAttrDefHash(o.attr());\n\n  \/\/ Compute deterministic order-independent control outputs hash.\n  std::set<string> control_output(o.control_output().begin(),\n                                  o.control_output().end());\n  for (const auto& co : control_output) h = Hash64Combine(h, Hash64(co));\n\n  OpDef o_copy = o;\n  o_copy.clear_attr();\n  o_copy.clear_control_output();\n  return DeterministicProtoHash64(o_copy, h);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":512702,"func":"bool Item_in_optimizer::is_expensive_processor(void *arg)\n{\n  DBUG_ASSERT(fixed);\n  return args[0]->is_expensive_processor(arg) ||\n         args[1]->is_expensive_processor(arg);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":413335,"func":"PHP_FUNCTION(snmp_set_enum_print)\n{\n\tlong a1;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &a1) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tnetsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);\n\tRETURN_TRUE;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":359428,"func":"peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)\n{\n  return peer_flag_modify_vty (vty, ip_str, flag, 1);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":232325,"func":"\nvoid gf_isom_box_dump_done(const char *name, GF_Box *ptr, FILE *trace)\n{\n\tif (ptr && ptr->child_boxes) {\n\t\tgf_isom_box_array_dump(ptr->child_boxes, trace);\n\t}\n\tif (name)\n\t\tgf_fprintf(trace, \"<\/%s>\\n\", name);","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":481262,"func":"static void mlx5_fpga_conn_free_recv_bufs(struct mlx5_fpga_conn *conn)\n{\n\tint ix;\n\n\tfor (ix = 0; ix < conn->qp.rq.size; ix++) {\n\t\tif (!conn->qp.rq.bufs[ix])\n\t\t\tcontinue;\n\t\tmlx5_fpga_conn_unmap_buf(conn, conn->qp.rq.bufs[ix]);\n\t\tkfree(conn->qp.rq.bufs[ix]);\n\t\tconn->qp.rq.bufs[ix] = NULL;\n\t}\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":316951,"func":"static void delayed_superblock_init(struct super_block *sb, void *unused)\n{\n\tselinux_set_mnt_opts(sb, NULL, 0, NULL);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":509493,"func":"uint ha_maria::max_supported_key_length() const\n{\n  return maria_max_key_length();\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":238552,"func":"static bool verifier_state_scratched(const struct bpf_verifier_env *env)\n{\n\treturn env->scratched_regs || env->scratched_stack_slots;\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":442803,"func":"static size_t my_fread(void *buffer, size_t sz, size_t nmemb, void *userp)\n{\n  size_t rc;\n  struct InStruct *in=(struct InStruct *)userp;\n\n  rc = fread(buffer, sz, nmemb, in->stream);\n  return rc;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":404714,"func":"static void __free_fdtable(struct fdtable *fdt)\n{\n\tkvfree(fdt->fd);\n\tkvfree(fdt->open_fds);\n\tkfree(fdt);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":242579,"func":"shim_mem_attrs_to_uefi_mem_attrs (uint64_t attrs)\n{\n\tuint64_t ret = EFI_MEMORY_RP |\n\t\t       EFI_MEMORY_RO |\n\t\t       EFI_MEMORY_XP;\n\n\tif (attrs & MEM_ATTR_R)\n\t\tret &= ~EFI_MEMORY_RP;\n\n\tif (attrs & MEM_ATTR_W)\n\t\tret &= ~EFI_MEMORY_RO;\n\n\tif (attrs & MEM_ATTR_X)\n\t\tret &= ~EFI_MEMORY_XP;\n\n\treturn ret;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":225474,"func":"bool CanDedupControlWithRegularInput(const MutableGraphView& graph,\n                                     const NodeDef& control_node) {\n  return !IsIdentityConsumingSwitch(graph, control_node);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":225419,"func":"static int vidioc_g_fmt_out(struct file *file, void *priv,\n\t\t\t    struct v4l2_format *fmt)\n{\n\tstruct v4l2_loopback_device *dev;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\n\t\/*\n\t * LATER: this should return the currently valid format\n\t * gstreamer doesn't like it, if this returns -EINVAL, as it\n\t * then concludes that there is _no_ valid format\n\t * CHECK whether this assumption is wrong,\n\t * or whether we have to always provide a valid format\n\t *\/\n\n\tfmt->fmt.pix = dev->pix_format;\n\treturn 0;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":348426,"func":"static void mkiss_put(struct mkiss *ax)\n{\n\tif (refcount_dec_and_test(&ax->refcnt))\n\t\tcomplete(&ax->dead);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":197893,"func":"TfLiteStatus Gather(const TfLiteGatherParams& params, const TfLiteTensor* input,\n                    const TfLiteTensor* positions, TfLiteTensor* output) {\n  tflite::GatherParams op_params;\n  op_params.axis = params.axis;\n  op_params.batch_dims = params.batch_dims;\n  optimized_ops::Gather(op_params, GetTensorShape(input),\n                        GetTensorData<InputT>(input), GetTensorShape(positions),\n                        GetTensorData<PositionsT>(positions),\n                        GetTensorShape(output), GetTensorData<InputT>(output));\n  return kTfLiteOk;\n}","target":1,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":225645,"func":"void mfra_box_del(GF_Box *s)\n{\n\tGF_MovieFragmentRandomAccessBox *ptr = (GF_MovieFragmentRandomAccessBox *)s;\n\tif (ptr == NULL) return;\n\tgf_list_del(ptr->tfra_list);\n\tgf_free(ptr);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":338056,"func":"HeapType WasmBinaryBuilder::getIndexedHeapType() {\n  auto index = getU32LEB();\n  if (index >= types.size()) {\n    throwError(\"invalid heap type index: \" + std::to_string(index));\n  }\n  return types[index];\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":473983,"func":"utf32le_code_to_mbclen(OnigCodePoint code ARG_UNUSED,\n\t\t       OnigEncoding enc ARG_UNUSED)\n{\n  return 4;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":459028,"func":"http_ForceField(struct http *to, unsigned n, const char *t)\n{\n\tint i;\n\n\tCHECK_OBJ_NOTNULL(to, HTTP_MAGIC);\n\tassert(n < HTTP_HDR_FIRST);\n\tassert(n == HTTP_HDR_METHOD || n == HTTP_HDR_PROTO);\n\tAN(t);\n\n\t\/* NB: method names and protocol versions are case-sensitive. *\/\n\tif (to->hd[n].b == NULL || strcmp(to->hd[n].b, t)) {\n\t\ti = (HTTP_HDR_UNSET - HTTP_HDR_METHOD);\n\t\ti += to->logtag;\n\t\t\/* XXX: this is a dead branch *\/\n\t\tif (n >= HTTP_HDR_FIRST)\n\t\t\tVSLbt(to->vsl, (enum VSL_tag_e)i, to->hd[n]);\n\t\thttp_SetH(to, n, t);\n\t}\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":244263,"func":"void udta_box_del(GF_Box *s)\n{\n\tu32 i;\n\tGF_UserDataMap *map;\n\tGF_UserDataBox *ptr = (GF_UserDataBox *)s;\n\tif (ptr == NULL) return;\n\ti=0;\n\twhile ((map = (GF_UserDataMap *)gf_list_enum(ptr->recordList, &i))) {\n\t\tgf_isom_box_array_del(map->boxes);\n\t\tgf_free(map);\n\t}\n\tgf_list_del(ptr->recordList);\n\tgf_free(ptr);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":90858,"func":"  void GetTemporaryGlobalQuota() {\n    quota_status_ = kQuotaStatusUnknown;\n    quota_ = -1;\n    quota_manager_->GetTemporaryGlobalQuota(\n        callback_factory_.NewCallback(\n            &QuotaManagerTest::DidGetQuota));\n  }\n","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":356708,"func":"void Statement::Work_BeginReset(Baton* baton) {\n    STATEMENT_BEGIN(Reset);\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":500069,"func":"kssl_krb5_mk_req_extended (krb5_context CO,\n                          krb5_auth_context  * pACO,\n                          krb5_const krb5_flags F,\n                          krb5_data  * pD1,\n                          krb5_creds  * pC,\n                          krb5_data  * pD2)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_mk_req_extended )\n\t\treturn(p_krb5_mk_req_extended(CO,pACO,F,pD1,pC,pD2));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":503986,"func":"static const char *field_get_default(const char *data)\n{\n\tconst char *p;\n\n\tp = strchr(data, ':');\n\tif (p == NULL)\n\t\treturn \"\";\n\telse {\n\t\t\/* default value given *\/\n\t\treturn p+1;\n\t}\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":512923,"func":"  bool make_copy_field() const { return m_make_copy_field; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":231656,"func":"  void accept(std::shared_ptr<ServerTransportParametersExtension>) override {}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":427159,"func":"static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {\n  const char *varname = getstr(getlocalvardesc(ls->fs, gt->nactvar)->vd.name);\n  const char *msg = \"<goto %s> at line %d jumps into the scope of local '%s'\";\n  msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line, varname);\n  luaK_semerror(ls, msg);  \/* raise the error *\/\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":424947,"func":"void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans)\n{\n\tstruct dentry *dir = trans->dbgfs_dir;\n\n\tDEBUGFS_ADD_FILE(rx_queue, dir, 0400);\n\tDEBUGFS_ADD_FILE(tx_queue, dir, 0400);\n\tDEBUGFS_ADD_FILE(interrupt, dir, 0600);\n\tDEBUGFS_ADD_FILE(csr, dir, 0200);\n\tDEBUGFS_ADD_FILE(fh_reg, dir, 0400);\n\tDEBUGFS_ADD_FILE(rfkill, dir, 0600);\n\tDEBUGFS_ADD_FILE(monitor_data, dir, 0400);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":477291,"func":"static char *tipc_key_change_dump(struct tipc_key old, struct tipc_key new,\n\t\t\t\t  char *buf)\n{\n\tstruct tipc_key *key = &old;\n\tint k, i = 0;\n\tchar *s;\n\n\t\/* Output format: \"[%s %s %s] -> [%s %s %s]\", max len = 32 *\/\nagain:\n\ti += scnprintf(buf + i, 32 - i, \"[\");\n\tfor (k = KEY_1; k <= KEY_3; k++) {\n\t\tif (k == key->passive)\n\t\t\ts = \"pas\";\n\t\telse if (k == key->active)\n\t\t\ts = \"act\";\n\t\telse if (k == key->pending)\n\t\t\ts = \"pen\";\n\t\telse\n\t\t\ts = \"-\";\n\t\ti += scnprintf(buf + i, 32 - i,\n\t\t\t       (k != KEY_3) ? \"%s \" : \"%s\", s);\n\t}\n\tif (key != &new) {\n\t\ti += scnprintf(buf + i, 32 - i, \"] -> \");\n\t\tkey = &new;\n\t\tgoto again;\n\t}\n\ti += scnprintf(buf + i, 32 - i, \"]\");\n\treturn buf;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":269513,"func":"static void TIFFGetGPSProperties(TIFF *tiff,Image *image,\n  const ImageInfo* image_info,ExceptionInfo *exception)\n{\n#if defined(MAGICKCORE_HAVE_TIFFREADGPSDIRECTORY)\n  const char\n    *option;\n\n  tdir_t\n    directory;\n\n#if defined(TIFF_VERSION_BIG)\n  uint64\n#else\n  uint32\n#endif\n    offset;\n\n  \/*\n    Read GPS properties.\n  *\/\n  option=GetImageOption(image_info,\"tiff:gps-properties\");\n  if (IsStringFalse(option) != MagickFalse)\n    return;\n  offset=0;\n  if (TIFFGetField(tiff,TIFFTAG_GPSIFD,&offset) != 1)\n    return;\n  directory=TIFFCurrentDirectory(tiff);\n  if (TIFFReadGPSDirectory(tiff,offset) == 1)\n    TIFFSetImageProperties(tiff,image,\"exif:GPS\",exception);\n  TIFFSetDirectory(tiff,directory);\n#else\n  magick_unreferenced(tiff);\n  magick_unreferenced(image);\n  magick_unreferenced(image_info);\n  magick_unreferenced(exception);\n#endif\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":506434,"func":"mech_rpa_auth_phase3(struct auth_request *auth_request,\n\t\t     const unsigned char *data, size_t data_size)\n{\n\tstatic const unsigned char client_ack[3] = { 0x60, 0x01, 0x00 };\n\n\tif ((data_size != sizeof(client_ack)) ||\n\t    (memcmp(data, client_ack, sizeof(client_ack)) != 0)) {\n\t\te_info(auth_request->mech_event,\n\t\t       \"invalid token 5 or client rejects us\");\n\t\tauth_request_fail(auth_request);\n\t} else {\n\t\tauth_request_success(auth_request, \"\", 0);\n\t}\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":221406,"func":"static void nested_svm_triple_fault(struct kvm_vcpu *vcpu)\n{\n\tnested_svm_simple_vmexit(to_svm(vcpu), SVM_EXIT_SHUTDOWN);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":231782,"func":"TEST_F(QuicServerTransportTest, PingIsTreatedAsRetransmittable) {\n  PingFrame pingFrame;\n  ShortHeader header(\n      ProtectionType::KeyPhaseZero,\n      *server->getConn().serverConnectionId,\n      clientNextAppDataPacketNum++);\n  RegularQuicPacketBuilder builder(\n      server->getConn().udpSendPacketLen,\n      std::move(header),\n      0 \/* largestAcked *\/);\n  builder.encodePacketHeader();\n  writeFrame(pingFrame, builder);\n  auto packet = std::move(builder).buildPacket();\n  deliverData(packetToBuf(packet));\n  EXPECT_TRUE(server->getConn().pendingEvents.scheduleAckTimeout);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":259616,"func":"void HierarchicalBitmapRequester::FetchRegion(LONG x,const struct Line *const *line,LONG *buffer)\n{\n  int cnt = 8;\n  do {\n    if (*line) \n      memcpy(buffer,(*line)->m_pData + (x << 3),8 * sizeof(LONG));\n    buffer += 8;\n    line++;\n  } while(--cnt);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":498086,"func":"void html_txtf(const char *format, ...)\n{\n\tva_list args;\n\n\tva_start(args, format);\n\thtml_vtxtf(format, args);\n\tva_end(args);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":409430,"func":"set_mouse_topline(win_T *wp)\n{\n    orig_topline = wp->w_topline;\n# ifdef FEAT_DIFF\n    orig_topfill = wp->w_topfill;\n# endif\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":256450,"func":"JANET_CORE_FN(cfun_array_push,\n              \"(array\/push arr x)\",\n              \"Insert an element in the end of an array. Modifies the input array and returns it.\") {\n    janet_arity(argc, 1, -1);\n    JanetArray *array = janet_getarray(argv, 0);\n    if (INT32_MAX - argc + 1 <= array->count) {\n        janet_panic(\"array overflow\");\n    }\n    int32_t newcount = array->count - 1 + argc;\n    janet_array_ensure(array, newcount, 2);\n    if (argc > 1) memcpy(array->data + array->count, argv + 1, (size_t)(argc - 1) * sizeof(Janet));\n    array->count = newcount;\n    return argv[0];\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":415214,"func":"cmd_disconnect (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n\n  (void)line;\n\n  ctrl->server_local->disconnect_allowed = 1;\n  return 0;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":301423,"func":"static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,\n\t\t\t\t    files_struct *fsp,\n\t\t\t\t    uint32 security_info,\n\t\t\t\t    TALLOC_CTX *mem_ctx,\n\t\t\t\t    struct security_descriptor **ppdesc)\n{\n\tNTSTATUS result;\n\n\tSTART_PROFILE(fget_nt_acl);\n\tresult = posix_fget_nt_acl(fsp, security_info,\n\t\t\t\t   mem_ctx, ppdesc);\n\tEND_PROFILE(fget_nt_acl);\n\treturn result;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":310000,"func":"npop(void)\n{\n    int result = 0;\n    if (TPS(stack_ptr) > 0) {\n\tTPS(stack_ptr)--;\n\tif (TPS(stack)[TPS(stack_ptr)].num_type)\n\t    result = TPS(stack)[TPS(stack_ptr)].data.num;\n    } else {\n\tDEBUG(2, (\"npop: stack underflow: %s\", _nc_visbuf(TPS(tparam_base))));\n\t_nc_tparm_err++;\n    }\n    return result;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":224285,"func":"gopher_request_parse(const HttpRequest * req, char *type_id, char *request)\n{\n    ::Parser::Tokenizer tok(req->url.path());\n\n    if (request)\n        *request = 0;\n\n    tok.skip('\/'); \/\/ ignore failures? path could be ab-empty\n\n    if (tok.atEnd()) {\n        *type_id = GOPHER_DIRECTORY;\n        return;\n    }\n\n    static const CharacterSet anyByte(\"UTF-8\",0x00, 0xFF);\n\n    SBuf typeId;\n    (void)tok.prefix(typeId, anyByte, 1); \/\/ never fails since !atEnd()\n    *type_id = typeId[0];\n\n    if (request) {\n        SBufToCstring(request, tok.remaining().substr(0, MAX_URL-1));\n        \/* convert %xx to char *\/\n        rfc1738_unescape(request);\n    }\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":463156,"func":"static int cleanup_cb(void *rock,\n                      const char *key, size_t keylen,\n                      const char *data __attribute__((unused)),\n                      size_t datalen __attribute__((unused)))\n{\n    annotate_db_t *d = (annotate_db_t *)rock;\n\n    return cyrusdb_delete(d->db, key, keylen, tid(d), \/*force*\/1);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":246486,"func":"RPVector *r_bin_wasm_get_codes(RBinWasmObj *bin) {\n\tr_return_val_if_fail (bin && bin->g_sections, NULL);\n\treturn bin->g_codes? bin->g_codes: parse_unique_subsec_vec_by_id (bin, R_BIN_WASM_SECTION_CODE);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":488339,"func":"int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)\n{\n\tpmd_t *new = pmd_alloc_one(mm, address);\n\tif (!new)\n\t\treturn -ENOMEM;\n\n\tsmp_wmb(); \/* See comment in __pte_alloc *\/\n\n\tspin_lock(&mm->page_table_lock);\n#ifndef __ARCH_HAS_4LEVEL_HACK\n\tif (pud_present(*pud))\t\t\/* Another has populated it *\/\n\t\tpmd_free(mm, new);\n\telse\n\t\tpud_populate(mm, pud, new);\n#else\n\tif (pgd_present(*pud))\t\t\/* Another has populated it *\/\n\t\tpmd_free(mm, new);\n\telse\n\t\tpgd_populate(mm, pud, new);\n#endif \/* __ARCH_HAS_4LEVEL_HACK *\/\n\tspin_unlock(&mm->page_table_lock);\n\treturn 0;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":225956,"func":"GF_Err stsh_box_size(GF_Box *s)\n{\n\tGF_ShadowSyncBox *ptr = (GF_ShadowSyncBox *)s;\n\tptr->size += 4 + (8 * gf_list_count(ptr->entries));\n\treturn GF_OK;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":229351,"func":"Fprint128 GetDeviceCacheKey(EagerOperation* op, const EagerContext& ctx) {\n  Fprint128 device_cache_key = op->MutableAttrs()->CacheKey(op->DeviceName());\n  device_cache_key =\n      FingerprintCat128(device_cache_key, ctx.AllowSoftPlacement());\n  return device_cache_key;\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":238327,"func":"int digest_file_by_name(const char *algo, const char *filename,\n\t\t\tunsigned char *hash,\n\t\t\tconst unsigned char *sig)\n{\n\tstruct digest *d;\n\tint ret;\n\n\td = digest_alloc(algo);\n\tif (!d)\n\t\treturn -EIO;\n\n\tret = digest_file(d, filename, hash, sig);\n\tdigest_free(d);\n\treturn ret;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":238524,"func":"static int check_attach_modify_return(unsigned long addr, const char *func_name)\n{\n\tif (within_error_injection_list(addr) ||\n\t    !strncmp(SECURITY_PREFIX, func_name, sizeof(SECURITY_PREFIX) - 1))\n\t\treturn 0;\n\n\treturn -EINVAL;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":427726,"func":"cdf_calloc(const char *file __attribute__((__unused__)),\n    size_t line __attribute__((__unused__)), size_t n, size_t u)\n{\n\tDPRINTF((\"%s,%\" SIZE_T_FORMAT \"u: %s %\" SIZE_T_FORMAT \"u %\"\n\t    SIZE_T_FORMAT \"u\\n\", file, line, __func__, n, u));\n\treturn calloc(n, u);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":336509,"func":"SPICE_GNUC_VISIBLE int spice_server_is_server_mouse(SpiceServer *reds)\n{\n    return reds->mouse_mode == SPICE_MOUSE_MODE_SERVER;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":317041,"func":"static int may_create(struct inode *dir,\n\t\t      struct dentry *dentry,\n\t\t      u16 tclass)\n{\n\tconst struct task_security_struct *tsec = selinux_cred(current_cred());\n\tstruct inode_security_struct *dsec;\n\tstruct superblock_security_struct *sbsec;\n\tu32 sid, newsid;\n\tstruct common_audit_data ad;\n\tint rc;\n\n\tdsec = inode_security(dir);\n\tsbsec = selinux_superblock(dir->i_sb);\n\n\tsid = tsec->sid;\n\n\tad.type = LSM_AUDIT_DATA_DENTRY;\n\tad.u.dentry = dentry;\n\n\trc = avc_has_perm(&selinux_state,\n\t\t\t  sid, dsec->sid, SECCLASS_DIR,\n\t\t\t  DIR__ADD_NAME | DIR__SEARCH,\n\t\t\t  &ad);\n\tif (rc)\n\t\treturn rc;\n\n\trc = selinux_determine_inode_label(tsec, dir, &dentry->d_name, tclass,\n\t\t\t\t\t   &newsid);\n\tif (rc)\n\t\treturn rc;\n\n\trc = avc_has_perm(&selinux_state,\n\t\t\t  sid, newsid, tclass, FILE__CREATE, &ad);\n\tif (rc)\n\t\treturn rc;\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    newsid, sbsec->sid,\n\t\t\t    SECCLASS_FILESYSTEM,\n\t\t\t    FILESYSTEM__ASSOCIATE, &ad);\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":393532,"func":"static SQInteger base_setdebughook(HSQUIRRELVM v)\n{\n    sq_setdebughook(v);\n    return 0;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":273914,"func":"static void handle_PWD(ctrl_t *ctrl, char *arg)\n{\n\tchar buf[sizeof(ctrl->cwd) + 10];\n\n\tsnprintf(buf, sizeof(buf), \"257 \\\"%s\\\"\\r\\n\", ctrl->cwd);\n\tsend_msg(ctrl->sd, buf);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":513092,"func":"void Item_func_isnull::print(String *str, enum_query_type query_type)\n{\n  if (const_item() && !args[0]->maybe_null &&\n      !(query_type & (QT_NO_DATA_EXPANSION | QT_VIEW_INTERNAL)))\n    str->append(\"\/*always not null*\/ 1\");\n  else\n    args[0]->print_parenthesised(str, query_type, precedence());\n  str->append(STRING_WITH_LEN(\" is null\"));\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":244324,"func":"GF_Err reftype_AddRefTrack(GF_TrackReferenceTypeBox *ref, GF_ISOTrackID trackID, u16 *outRefIndex)\n{\n\tu32 i;\n\tif (!ref || !trackID) return GF_BAD_PARAM;\n\n\tif (outRefIndex) *outRefIndex = 0;\n\t\/\/don't add a dep if already here !!\n\tfor (i = 0; i < ref->trackIDCount; i++) {\n\t\tif (ref->trackIDs[i] == trackID) {\n\t\t\tif (outRefIndex) *outRefIndex = i+1;\n\t\t\treturn GF_OK;\n\t\t}\n\t}\n\n\tref->trackIDs = (GF_ISOTrackID *) gf_realloc(ref->trackIDs, (ref->trackIDCount + 1) * sizeof(GF_ISOTrackID) );\n\tif (!ref->trackIDs) return GF_OUT_OF_MEM;\n\tref->trackIDs[ref->trackIDCount] = trackID;\n\tref->trackIDCount++;\n\tif (outRefIndex) *outRefIndex = ref->trackIDCount;\n\treturn GF_OK;\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":345210,"func":"int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc)\n{\n\tstruct uni_pagedir *q;\n\n\tif (!*src_vc->vc_uni_pagedir_loc)\n\t\treturn -EINVAL;\n\tif (*dst_vc->vc_uni_pagedir_loc == *src_vc->vc_uni_pagedir_loc)\n\t\treturn 0;\n\tcon_free_unimap(dst_vc);\n\tq = *src_vc->vc_uni_pagedir_loc;\n\tq->refcount++;\n\t*dst_vc->vc_uni_pagedir_loc = q;\n\treturn 0;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":273107,"func":"buildopts_get()\n{\n  return buildopts;\n}","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":384130,"func":"raptor_new_xml_writer(raptor_world* world,\n                      raptor_namespace_stack *nstack,\n                      raptor_iostream* iostr)\n{\n  raptor_xml_writer* xml_writer;\n\n  RAPTOR_CHECK_CONSTRUCTOR_WORLD(world);\n\n  if(!iostr)\n    return NULL;\n  \n  raptor_world_open(world);\n\n  xml_writer = RAPTOR_CALLOC(raptor_xml_writer*, 1, sizeof(*xml_writer));\n  if(!xml_writer)\n    return NULL;\n\n  xml_writer->world = world;\n\n  xml_writer->nstack_depth = 0;\n\n  xml_writer->nstack = nstack;\n  if(!xml_writer->nstack) {\n    xml_writer->nstack = raptor_new_namespaces(world, 1);\n    xml_writer->my_nstack = 1;\n  }\n\n  xml_writer->iostr = iostr;\n\n  raptor_object_options_init(&xml_writer->options,\n                             RAPTOR_OPTION_AREA_XML_WRITER);\n  \n  return xml_writer;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":220862,"func":"inline int16_t lut_lookup(int16_t value, const int16_t* lut) {\n  return lut_lookup_with_interpolation(value, lut);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":244322,"func":"GF_Err paen_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tif (!s) return GF_BAD_PARAM;\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":512304,"func":"  longlong val_int_from_real()\n  {\n    DBUG_ASSERT(is_fixed());\n    return Converter_double_to_longlong_with_warn(val_real(), false).result();\n  }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":343267,"func":"static void displayopenfailure(const char * const name)\n{\n    char buffer[PATH_MAX + 42U];\n    const int e = errno;\n\n    if (SNCHECK(snprintf(buffer, sizeof buffer, MSG_OPEN_FAILURE, name),\n                sizeof buffer)) {\n        _EXIT(EXIT_FAILURE);\n    }\n    errno = e;\n    error(550, buffer);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":242990,"func":"static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl )\n{\n    size_t ep_len = mbedtls_ssl_ep_len( ssl );\n    int in_ctr_cmp;\n    int out_ctr_cmp;\n\n    if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ||\n        ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ||\n        ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED )\n    {\n        return( 0 );\n    }\n\n    in_ctr_cmp = memcmp( ssl->in_ctr + ep_len,\n                        ssl->conf->renego_period + ep_len, 8 - ep_len );\n    out_ctr_cmp = memcmp( ssl->cur_out_ctr + ep_len,\n                          ssl->conf->renego_period + ep_len, 8 - ep_len );\n\n    if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 )\n    {\n        return( 0 );\n    }\n\n    MBEDTLS_SSL_DEBUG_MSG( 1, ( \"record counter limit reached: renegotiate\" ) );\n    return( mbedtls_ssl_renegotiate( ssl ) );\n}","target":0,"code_token_length":239,"total_token_length":475,"max_tokens_setting":512}
+{"idx":482689,"func":"gst_flxdec_src_query_handler (GstPad * pad, GstObject * parent,\n    GstQuery * query)\n{\n  GstFlxDec *flxdec = (GstFlxDec *) parent;\n  gboolean ret = FALSE;\n\n  switch (GST_QUERY_TYPE (query)) {\n    case GST_QUERY_DURATION:\n    {\n      GstFormat format;\n\n      gst_query_parse_duration (query, &format, NULL);\n\n      if (format != GST_FORMAT_TIME)\n        goto done;\n\n      gst_query_set_duration (query, format, flxdec->duration);\n\n      ret = TRUE;\n    }\n    default:\n      break;\n  }\ndone:\n  if (!ret)\n    ret = gst_pad_query_default (pad, parent, query);\n\n  return ret;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":387774,"func":"bool InstanceKlass::should_be_initialized() const {\n  return !is_initialized();\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":261890,"func":"njs_string_prototype_char_at(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,\n    njs_index_t unused)\n{\n    size_t             length;\n    int64_t            start;\n    njs_int_t          ret;\n    njs_slice_prop_t   slice;\n    njs_string_prop_t  string;\n\n    ret = njs_string_object_validate(vm, njs_argument(args, 0));\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    slice.string_length = njs_string_prop(&string, njs_argument(args, 0));\n\n    ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &start);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    length = 1;\n\n    if (start < 0 || start >= (int64_t) slice.string_length) {\n        start = 0;\n        length = 0;\n    }\n\n    slice.start = start;\n    slice.length = length;\n\n    return njs_string_slice(vm, &vm->retval, &string, &slice);\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":224590,"func":"Status BiasAddGradShape(shape_inference::InferenceContext* c) {\n  ShapeHandle input_shape;\n  \/\/ Fetch the data_format attribute, which may not exist.\n  string data_format;\n  Status s = c->GetAttr(\"data_format\", &data_format);\n\n  if (s.ok() && data_format == \"NCHW\") {\n    TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 3, &input_shape));\n    c->set_output(0, c->Vector(c->Dim(input_shape, 1)));\n  } else {\n    TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 2, &input_shape));\n    c->set_output(0, c->Vector(c->Dim(input_shape, -1)));\n  }\n\n  return Status::OK();\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":401582,"func":"write_pool(struct entropy_store *r, const char __user *buffer, size_t count)\n{\n\tsize_t bytes;\n\t__u32 t, buf[16];\n\tconst char __user *p = buffer;\n\n\twhile (count > 0) {\n\t\tint b, i = 0;\n\n\t\tbytes = min(count, sizeof(buf));\n\t\tif (copy_from_user(&buf, p, bytes))\n\t\t\treturn -EFAULT;\n\n\t\tfor (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) {\n\t\t\tif (!arch_get_random_int(&t))\n\t\t\t\tbreak;\n\t\t\tbuf[i] ^= t;\n\t\t}\n\n\t\tcount -= bytes;\n\t\tp += bytes;\n\n\t\tmix_pool_bytes(r, buf, bytes);\n\t\tcond_resched();\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":225949,"func":"\nGF_Err svhd_box_size(GF_Box *s)\n{\n\tGF_SphericalVideoInfoBox *ptr = (GF_SphericalVideoInfoBox *)s;\n\tif (ptr->string)\n\t\ts->size += (u32) strlen(ptr->string);\n\ts->size += 1;\n\treturn GF_OK;","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":384281,"func":"gs_heap_stable(gs_memory_t *mem)\n{\n    return mem;\t\t\t\/* heap memory is stable *\/\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":212927,"func":"static void sungem_send_packet(SunGEMState *s, const uint8_t *buf,\n                               int size)\n{\n    NetClientState *nc = qemu_get_queue(s->nic);\n\n    if (s->macregs[MAC_XIFCFG >> 2] & MAC_XIFCFG_LBCK) {\n        nc->info->receive(nc, buf, size);\n    } else {\n        qemu_send_packet(nc, buf, size);\n    }\n}","target":1,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":244072,"func":"GF_Err prhd_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ProjectionHeaderBox *ptr = (GF_ProjectionHeaderBox *)s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->yaw);\n\tgf_bs_write_u32(bs, ptr->pitch);\n\tgf_bs_write_u32(bs, ptr->roll);\n\treturn GF_OK;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":269515,"func":"static void TIFFWarnings(const char *module,const char *format,va_list warning)\n{\n  char\n    message[MagickPathExtent];\n\n  ExceptionInfo\n    *exception;\n\n#if defined(MAGICKCORE_HAVE_VSNPRINTF)\n  (void) vsnprintf(message,MagickPathExtent-2,format,warning);\n#else\n  (void) vsprintf(message,format,warning);\n#endif\n  message[MagickPathExtent-2]='\\0';\n  (void) ConcatenateMagickString(message,\".\",MagickPathExtent);\n  exception=(ExceptionInfo *) GetMagickThreadValue(tiff_exception);\n  if (exception != (ExceptionInfo *) NULL)\n    (void) ThrowMagickException(exception,GetMagickModule(),CoderWarning,\n      message,\"`%s'\",module);\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":512732,"func":"longlong Item_func_bit_or::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  ulonglong arg1= (ulonglong) args[0]->val_int();\n  if (args[0]->null_value)\n  {\n    null_value=1; \/* purecov: inspected *\/\n    return 0; \/* purecov: inspected *\/\n  }\n  ulonglong arg2= (ulonglong) args[1]->val_int();\n  if (args[1]->null_value)\n  {\n    null_value=1;\n    return 0;\n  }\n  null_value=0;\n  return (longlong) (arg1 | arg2);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":421385,"func":"static void pc(int c)\n{\n\tputchar(c);\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":488411,"func":"static void * __init find_section64(Elf64_Ehdr *ehdr, const char *secname,\n\t\t\t\t  unsigned long *size)\n{\n\tElf64_Shdr *sechdrs;\n\tunsigned int i;\n\tchar *secnames;\n\n\t\/* Grab section headers and strings so we can tell who is who *\/\n\tsechdrs = (void *)ehdr + ehdr->e_shoff;\n\tsecnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;\n\n\t\/* Find the section they want *\/\n\tfor (i = 1; i < ehdr->e_shnum; i++) {\n\t\tif (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {\n\t\t\tif (size)\n\t\t\t\t*size = sechdrs[i].sh_size;\n\t\t\treturn (void *)ehdr + sechdrs[i].sh_offset;\n\t\t}\n\t}\n\tif (size)\n\t\t*size = 0;\n\treturn NULL;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":247641,"func":"  bool expectNoCertChain() const { return expect_no_cert_chain_; }","target":0,"code_token_length":16,"total_token_length":252,"max_tokens_setting":512}
+{"idx":387626,"func":"static int snd_ctl_elem_read_user(struct snd_card *card,\n\t\t\t\t  struct snd_ctl_elem_value __user *_control)\n{\n\tstruct snd_ctl_elem_value *control;\n\tint result;\n\n\tcontrol = memdup_user(_control, sizeof(*control));\n\tif (IS_ERR(control))\n\t\treturn PTR_ERR(control);\n\n\tdown_read(&card->controls_rwsem);\n\tresult = snd_ctl_elem_read(card, control);\n\tup_read(&card->controls_rwsem);\n\tif (result < 0)\n\t\tgoto error;\n\n\tif (copy_to_user(_control, control, sizeof(*control)))\n\t\tresult = -EFAULT;\n error:\n\tkfree(control);\n\treturn result;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":353203,"func":"SplashPattern *SplashOutputDev::getColor(GfxGray gray) {\n  SplashColor color;\n\n  if (reverseVideo) {\n    gray = gfxColorComp1 - gray;\n  }\n  color[0] = colToByte(gray);\n  return new SplashSolidColor(color);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":244357,"func":"GF_Box *svhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SphericalVideoInfoBox, GF_ISOM_BOX_TYPE_SVHD);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":481266,"func":"static void mlx5_fpga_conn_event(struct mlx5_core_qp *mqp, int event)\n{\n\tstruct mlx5_fpga_conn *conn;\n\n\tconn = container_of(mqp, struct mlx5_fpga_conn, qp.mqp);\n\tmlx5_fpga_warn(conn->fdev, \"QP event %u on QP #%u\\n\", event, mqp->qpn);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":222519,"func":"void FunctionLibraryDefinition::Clear() {\n  mutex_lock l(mu_);\n  function_defs_.clear();\n  func_grad_.clear();\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":508368,"func":"bool extend_table_list(THD *thd, TABLE_LIST *tables,\n                       Prelocking_strategy *prelocking_strategy,\n                       bool has_prelocking_list)\n{\n  bool error= false;\n  LEX *lex= thd->lex;\n\n  if (thd->locked_tables_mode <= LTM_LOCK_TABLES &&\n      ! has_prelocking_list && tables->updating &&\n      tables->lock_type >= TL_WRITE_ALLOW_WRITE)\n  {\n    bool need_prelocking= FALSE;\n    TABLE_LIST **save_query_tables_last= lex->query_tables_last;\n    \/*\n      Extend statement's table list and the prelocking set with\n      tables and routines according to the current prelocking\n      strategy.\n\n      For example, for DML statements we need to add tables and routines\n      used by triggers which are going to be invoked for this element of\n      table list and also add tables required for handling of foreign keys.\n    *\/\n    error= prelocking_strategy->handle_table(thd, lex, tables,\n                                             &need_prelocking);\n\n    if (need_prelocking && ! lex->requires_prelocking())\n      lex->mark_as_requiring_prelocking(save_query_tables_last);\n  }\n  return error;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":472120,"func":"int proc_cgroupstats_show(struct seq_file *m, void *v)\n{\n\tstruct cgroup_subsys *ss;\n\tint i;\n\n\tseq_puts(m, \"#subsys_name\\thierarchy\\tnum_cgroups\\tenabled\\n\");\n\t\/*\n\t * ideally we don't want subsystems moving around while we do this.\n\t * cgroup_mutex is also necessary to guarantee an atomic snapshot of\n\t * subsys\/hierarchy state.\n\t *\/\n\tmutex_lock(&cgroup_mutex);\n\n\tfor_each_subsys(ss, i)\n\t\tseq_printf(m, \"%s\\t%d\\t%d\\t%d\\n\",\n\t\t\t   ss->legacy_name, ss->root->hierarchy_id,\n\t\t\t   atomic_read(&ss->root->nr_cgrps),\n\t\t\t   cgroup_ssid_enabled(i));\n\n\tmutex_unlock(&cgroup_mutex);\n\treturn 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":432176,"func":"static bool addrrange_equal(AddrRange r1, AddrRange r2)\n{\n    return int128_eq(r1.start, r2.start) && int128_eq(r1.size, r2.size);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":225685,"func":"\nGF_Box *trep_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackExtensionPropertiesBox, GF_ISOM_BOX_TYPE_TREP);\n\ttmp->child_boxes = gf_list_new();\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":244168,"func":"GF_Err trgr_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_TrackGroupBox *ptr = (GF_TrackGroupBox *) s;\n\tgf_isom_check_position_list(s, ptr->groups, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":269307,"func":"static av_always_inline int same_block(BlockNode *a, BlockNode *b){\n    if((a->type&BLOCK_INTRA) && (b->type&BLOCK_INTRA)){\n        return !((a->color[0] - b->color[0]) | (a->color[1] - b->color[1]) | (a->color[2] - b->color[2]));\n    }else{\n        return !((a->mx - b->mx) | (a->my - b->my) | (a->ref - b->ref) | ((a->type ^ b->type)&BLOCK_INTRA));\n    }\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":267963,"func":"R_API RBinFile *r_bin_file_find_by_fd(RBin *bin, ut32 bin_fd) {\n\tRListIter *iter;\n\tRBinFile *bf;\n\n\tr_return_val_if_fail (bin, NULL);\n\n\tr_list_foreach (bin->binfiles, iter, bf) {\n\t\tif (bf->fd == bin_fd) {\n\t\t\treturn bf;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":437692,"func":"static int cx23888_ir_rx_shutdown(struct v4l2_subdev *sd)\n{\n\tstruct cx23888_ir_state *state = to_state(sd);\n\tstruct cx23885_dev *dev = state->dev;\n\n\tmutex_lock(&state->rx_params_lock);\n\n\t\/* Disable or slow down all IR Rx circuits and counters *\/\n\tirqenable_rx(dev, 0);\n\tcontrol_rx_enable(dev, false);\n\tcontrol_rx_demodulation_enable(dev, false);\n\tcontrol_rx_s_edge_detection(dev, CNTRL_EDG_NONE);\n\tfilter_rx_s_min_width(dev, 0);\n\tcx23888_ir_write4(dev, CX23888_IR_RXCLK_REG, RXCLK_RCD);\n\n\tstate->rx_params.shutdown = true;\n\n\tmutex_unlock(&state->rx_params_lock);\n\treturn 0;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":252280,"func":"int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len,\n                  const unsigned char *pSource, mz_ulong source_len) {\n  mz_stream stream;\n  int status;\n  memset(&stream, 0, sizeof(stream));\n\n  \/\/ In case mz_ulong is 64-bits (argh I hate longs).\n  if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR;\n\n  stream.next_in = pSource;\n  stream.avail_in = (mz_uint32)source_len;\n  stream.next_out = pDest;\n  stream.avail_out = (mz_uint32)*pDest_len;\n\n  status = mz_inflateInit(&stream);\n  if (status != MZ_OK) return status;\n\n  status = mz_inflate(&stream, MZ_FINISH);\n  if (status != MZ_STREAM_END) {\n    mz_inflateEnd(&stream);\n    return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR\n                                                            : status;\n  }\n  *pDest_len = stream.total_out;\n\n  return mz_inflateEnd(&stream);\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":244204,"func":"GF_Err trgr_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":366340,"func":"static void *m_start(struct seq_file *m, loff_t *pos)\n{\n\tstruct proc_mounts *p = m->private;\n\tstruct list_head *prev;\n\n\tdown_read(&namespace_sem);\n\tif (!*pos) {\n\t\tprev = &p->ns->list;\n\t} else {\n\t\tprev = &p->cursor.mnt_list;\n\n\t\t\/* Read after we'd reached the end? *\/\n\t\tif (list_empty(prev))\n\t\t\treturn NULL;\n\t}\n\n\treturn mnt_list_next(p->ns, prev);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":326912,"func":"static struct vidtv_access_unit *vidtv_s302m_access_unit_init(struct vidtv_access_unit *head)\n{\n\tstruct vidtv_access_unit *au;\n\n\tau = kzalloc(sizeof(*au), GFP_KERNEL);\n\tif (!au)\n\t\treturn NULL;\n\n\tif (head) {\n\t\twhile (head->next)\n\t\t\thead = head->next;\n\n\t\thead->next = au;\n\t}\n\n\treturn au;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":300735,"func":"static int tipc_wait_for_accept(struct socket *sock, long timeo)\n{\n\tstruct sock *sk = sock->sk;\n\tDEFINE_WAIT_FUNC(wait, woken_wake_function);\n\tint err;\n\n\t\/* True wake-one mechanism for incoming connections: only\n\t * one process gets woken up, not the 'whole herd'.\n\t * Since we do not 'race & poll' for established sockets\n\t * anymore, the common case will execute the loop only once.\n\t*\/\n\tfor (;;) {\n\t\tif (timeo && skb_queue_empty(&sk->sk_receive_queue)) {\n\t\t\tadd_wait_queue(sk_sleep(sk), &wait);\n\t\t\trelease_sock(sk);\n\t\t\ttimeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);\n\t\t\tlock_sock(sk);\n\t\t\tremove_wait_queue(sk_sleep(sk), &wait);\n\t\t}\n\t\terr = 0;\n\t\tif (!skb_queue_empty(&sk->sk_receive_queue))\n\t\t\tbreak;\n\t\terr = -EAGAIN;\n\t\tif (!timeo)\n\t\t\tbreak;\n\t\terr = sock_intr_errno(timeo);\n\t\tif (signal_pending(current))\n\t\t\tbreak;\n\t}\n\treturn err;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":440899,"func":"LogMessageTypeVerbString(MessageType type, int verb)\n{\n    if (type == X_ERROR)\n        verb = 0;\n\n    if (logVerbosity < verb && logFileVerbosity < verb)\n        return NULL;\n\n    switch (type) {\n    case X_PROBED:\n        return X_PROBE_STRING;\n    case X_CONFIG:\n        return X_CONFIG_STRING;\n    case X_DEFAULT:\n        return X_DEFAULT_STRING;\n    case X_CMDLINE:\n        return X_CMDLINE_STRING;\n    case X_NOTICE:\n        return X_NOTICE_STRING;\n    case X_ERROR:\n        return X_ERROR_STRING;\n    case X_WARNING:\n        return X_WARNING_STRING;\n    case X_INFO:\n        return X_INFO_STRING;\n    case X_NOT_IMPLEMENTED:\n        return X_NOT_IMPLEMENTED_STRING;\n    case X_UNKNOWN:\n        return X_UNKNOWN_STRING;\n    case X_NONE:\n        return X_NONE_STRING;\n    case X_DEBUG:\n        return X_DEBUG_STRING;\n    default:\n        return X_UNKNOWN_STRING;\n    }\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":274841,"func":"TEST(ComparisonsTest, QuantizedInt8GreaterEqualWithBroadcast) {\n  const float kMin = -127.f;\n  const float kMax = 127.f;\n  std::vector<std::vector<int>> test_shapes = {\n      {6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};\n  for (int i = 0; i < test_shapes.size(); ++i) {\n    ComparisonOpModel model({TensorType_INT8, test_shapes[i], kMin, kMax},\n                            {TensorType_INT8, {}, kMin, kMax}, TensorType_INT8,\n                            BuiltinOperator_GREATER_EQUAL);\n    model.QuantizeAndPopulate<int8_t>(model.input1(), {20, -2, -71, 8, 11, 20});\n    model.QuantizeAndPopulate<int8_t>(model.input2(), {8});\n    model.Invoke();\n    EXPECT_THAT(model.GetOutput(),\n                ElementsAre(true, false, false, true, true, true))\n        << \"With shape number \" << i;\n  }\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":247655,"func":"  TestUtilOptions& setExpectedExpirationTimePeerCert(const std::string& expected_expiration) {\n    expected_expiration_peer_cert_ = expected_expiration;\n    return *this;\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":221470,"func":"flatpak_run_get_pulse_machine_id (void)\n{\n  static const char * const machine_ids[] =\n  {\n    \"\/etc\/machine-id\",\n    \"\/var\/lib\/dbus\/machine-id\",\n  };\n  gsize i;\n\n  for (i = 0; i < G_N_ELEMENTS (machine_ids); i++)\n    {\n      g_autofree char *ret = NULL;\n\n      if (g_file_get_contents (machine_ids[i], &ret, NULL, NULL))\n        {\n          gsize j;\n\n          g_strstrip (ret);\n\n          for (j = 0; ret[j] != '\\0'; j++)\n            {\n              if (!g_ascii_isxdigit (ret[j]))\n                break;\n            }\n\n          if (ret[0] != '\\0' && ret[j] == '\\0')\n            return g_steal_pointer (&ret);\n        }\n    }\n\n  return g_strdup (g_get_host_name ());\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":244214,"func":"void pdin_box_del(GF_Box *s)\n{\n\tGF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox*)s;\n\tif (ptr == NULL) return;\n\tif (ptr->rates) gf_free(ptr->rates);\n\tif (ptr->times) gf_free(ptr->times);\n\tgf_free(ptr);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":246479,"func":"static size_t consume_limits_r(RBuffer *b, ut64 bound, struct r_bin_wasm_resizable_limits_t *out) {\n\tr_return_val_if_fail (b && out, 0);\n\tif (bound >= r_buf_size (b) || r_buf_tell (b) > bound || !out) {\n\t\treturn 0;\n\t}\n\tut32 i = r_buf_tell (b);\n\tif (!consume_u7_r (b, bound, &out->flags)) {\n\t\treturn 0;\n\t}\n\tif (!consume_u32_r (b, bound, &out->initial)) {\n\t\treturn 0;\n\t}\n\tif (out->flags && !consume_u32_r (b, bound, &out->maximum)) {\n\t\treturn 0;\n\t}\n\tint delta = r_buf_tell (b) - i;\n\treturn (delta > 0)? delta: 0;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":225048,"func":"PQconnectdbParams(const char *const *keywords,\n\t\t\t\t  const char *const *values,\n\t\t\t\t  int expand_dbname)\n{\n\tPGconn\t   *conn = PQconnectStartParams(keywords, values, expand_dbname);\n\n\tif (conn && conn->status != CONNECTION_BAD)\n\t\t(void) connectDBComplete(conn);\n\n\treturn conn;\n\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":218740,"func":"static inline ssize_t ReadPSDString(Image *image,char *p,const size_t length)\n{\n  ssize_t\n    count;\n\n  count=ReadBlob(image,length,(unsigned char *) p);\n  if ((count == (ssize_t) length) && (image->endian != MSBEndian))\n    {\n      char\n        *q;\n\n      q=p+length;\n      for(--q; p < q; ++p, --q)\n      {\n        *p = *p ^ *q,\n        *q = *p ^ *q,\n        *p = *p ^ *q;\n      }\n    }\n  return(count);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":244138,"func":"GF_Err trgr_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_TrackGroupBox *ptr = (GF_TrackGroupBox *)s;\n\n\tBOX_FIELD_LIST_ASSIGN(groups)\n\treturn gf_list_add(ptr->groups, a);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":452987,"func":"static int nft_dup_netdev_dump(struct sk_buff *skb, const struct nft_expr *expr)\n{\n\tstruct nft_dup_netdev *priv = nft_expr_priv(expr);\n\n\tif (nft_dump_register(skb, NFTA_DUP_SREG_DEV, priv->sreg_dev))\n\t\tgoto nla_put_failure;\n\n\treturn 0;\n\nnla_put_failure:\n\treturn -1;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":513182,"func":"static char *mysql_sys_var_char(THD* thd, int offset)\n{\n  return (char *) intern_sys_var_ptr(thd, offset, true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":427177,"func":"static void fornum (LexState *ls, TString *varname, int line) {\n  \/* fornum -> NAME = exp,exp[,exp] forbody *\/\n  FuncState *fs = ls->fs;\n  int base = fs->freereg;\n  new_localvarliteral(ls, \"(for state)\");\n  new_localvarliteral(ls, \"(for state)\");\n  new_localvarliteral(ls, \"(for state)\");\n  new_localvar(ls, varname);\n  checknext(ls, '=');\n  exp1(ls);  \/* initial value *\/\n  checknext(ls, ',');\n  exp1(ls);  \/* limit *\/\n  if (testnext(ls, ','))\n    exp1(ls);  \/* optional step *\/\n  else {  \/* default step = 1 *\/\n    luaK_int(fs, fs->freereg, 1);\n    luaK_reserveregs(fs, 1);\n  }\n  adjustlocalvars(ls, 3);  \/* control variables *\/\n  forbody(ls, base, line, 1, 0);\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":225034,"func":"PQconnectdb(const char *conninfo)\n{\n\tPGconn\t   *conn = PQconnectStart(conninfo);\n\n\tif (conn && conn->status != CONNECTION_BAD)\n\t\t(void) connectDBComplete(conn);\n\n\treturn conn;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":484714,"func":"MOBIBuffer * mobi_buffer_init_null(unsigned char *data, const size_t len) {\n    MOBIBuffer *buf = malloc(sizeof(MOBIBuffer));\n\tif (buf == NULL) {\n        debug_print(\"%s\", \"Buffer allocation failed\\n\");\n        return NULL;\n    }\n    buf->data = data;\n\tbuf->offset = 0;\n\tbuf->maxlen = len;\n    buf->error = MOBI_SUCCESS;\n\treturn buf;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":294483,"func":"d_lite_gc_mark(void *ptr)\n{\n    union DateData *dat = ptr;\n    if (simple_dat_p(dat))\n\trb_gc_mark(dat->s.nth);\n    else {\n\trb_gc_mark(dat->c.nth);\n\trb_gc_mark(dat->c.sf);\n    }\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":345136,"func":"pxa3xx_gcu_ioctl(struct file *file, unsigned int cmd, unsigned long arg)\n{\n\tunsigned long flags;\n\tstruct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);\n\n\tswitch (cmd) {\n\tcase PXA3XX_GCU_IOCTL_RESET:\n\t\tspin_lock_irqsave(&priv->spinlock, flags);\n\t\tpxa3xx_gcu_reset(priv);\n\t\tspin_unlock_irqrestore(&priv->spinlock, flags);\n\t\treturn 0;\n\n\tcase PXA3XX_GCU_IOCTL_WAIT_IDLE:\n\t\treturn pxa3xx_gcu_wait_idle(priv);\n\t}\n\n\treturn -ENOSYS;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":436154,"func":"static bool io_poll_rewait(struct io_kiocb *req, struct io_poll_iocb *poll)\n\t__acquires(&req->ctx->completion_lock)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\n\tif (unlikely(req->task->flags & PF_EXITING))\n\t\tWRITE_ONCE(poll->canceled, true);\n\n\tif (!req->result && !READ_ONCE(poll->canceled)) {\n\t\tstruct poll_table_struct pt = { ._key = poll->events };\n\n\t\treq->result = vfs_poll(req->file, &pt) & poll->events;\n\t}\n\n\tspin_lock_irq(&ctx->completion_lock);\n\tif (!req->result && !READ_ONCE(poll->canceled)) {\n\t\tadd_wait_queue(poll->head, &poll->wait);\n\t\treturn true;\n\t}\n\n\treturn false;","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":262079,"func":"  InstanceFeatureDimKey() : instance(-1), feature_dim(-1) {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":221674,"func":"Socket::Socket() {\n    sck = socket(AF_INET, SOCK_STREAM, 0);\n    if (sck < 0) {\n        s_errno = errno;\n    } else {\n        memset(&my_adr, 0, sizeof my_adr);\n        memset(&peer_adr, 0, sizeof peer_adr);\n        my_adr.sin_family = AF_INET;\n        peer_adr.sin_family = AF_INET;\n        peer_adr_length = sizeof(struct sockaddr_in);\n        int f = 1;\n\n        if (sck > 0)\n            setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, &f, sizeof(int));\n\n        my_port = 0;\n        chunkError = false;\n\n#ifdef __SSLMITM\n        ssl = NULL;\n        ctx = NULL;\n        isssl = false;\n        issslserver = false;\n#else\n        isssl = false;\n#endif\n    }\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":482558,"func":"passGetName(CharsString *passLine, int *passLinepos, CharsString *name) {\n\tname->length = 0;\n\t\/\/ a name is a sequence of characters in the ranges 'a'..'z' and 'A'..'Z'\n\tdo {\n\t\twidechar c = passLine->chars[*passLinepos];\n\t\tif ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {\n\t\t\tname->chars[name->length++] = c;\n\t\t\t(*passLinepos)++;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t} while (*passLinepos < passLine->length);\n\treturn 1;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":225863,"func":"GF_Box *sdp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_SDPBox, GF_ISOM_BOX_TYPE_SDP);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":294441,"func":"d_lite_hour(VALUE self)\n{\n    get_d1(self);\n    return INT2FIX(m_hour(dat));\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":261448,"func":"LIBDE265_INLINE static int luma_pos_to_ctbAddrRS(const seq_parameter_set* sps, int x,int y)\n{\n  int ctbX = x >> sps->Log2CtbSizeY;\n  int ctbY = y >> sps->Log2CtbSizeY;\n\n  return ctbY * sps->PicWidthInCtbsY + ctbX;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":450380,"func":"static void zrle_write_u8(VncState *vs, uint8_t value)\n{\n    vnc_write_u8(vs, value);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":473966,"func":"utf16le_is_mbc_newline(const UChar* p, const UChar* end,\n\t\t       OnigEncoding enc ARG_UNUSED)\n{\n  if (p + 1 < end) {\n    if (*p == 0x0a && *(p+1) == 0x00)\n      return 1;\n#ifdef USE_UNICODE_ALL_LINE_TERMINATORS\n    if ((\n#ifndef USE_CRNL_AS_LINE_TERMINATOR\n\t *p == 0x0d ||\n#endif\n\t *p == 0x85) && *(p+1) == 0x00)\n      return 1;\n    if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28))\n      return 1;\n#endif\n  }\n  return 0;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":234249,"func":"print_dwarf_vma (dwarf_vma value, unsigned num_bytes)\n{\n  printf (\"%s \", dwarf_vmatoa_1 (NULL, value, num_bytes));\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":512362,"func":"  longlong val_time_packed(THD *thd)\n  {\n    DBUG_ASSERT(0);\n    return 0;\n  }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":512276,"func":"  bool check_cols(uint c)\n  {\n    if (cols() != c)\n    {\n      my_error(ER_OPERAND_COLUMNS, MYF(0), c);\n      return true;\n    }\n    return false;\n  }","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":242969,"func":"static int ssl_get_remaining_space_in_datagram( mbedtls_ssl_context const *ssl )\n{\n    size_t const bytes_written = ssl->out_left;\n    size_t const mtu           = ssl_get_maximum_datagram_size( ssl );\n\n    \/* Double-check that the write-index hasn't gone\n     * past what we can transmit in a single datagram. *\/\n    if( bytes_written > mtu )\n    {\n        \/* Should never happen... *\/\n        return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );\n    }\n\n    return( (int) ( mtu - bytes_written ) );\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":291826,"func":"static inline void path_it_init(struct path_it *it, struct rtrs_clt_sess *clt)\n{\n\tINIT_LIST_HEAD(&it->skip_list);\n\tit->clt = clt;\n\tit->i = 0;\n\n\tif (clt->mp_policy == MP_POLICY_RR)\n\t\tit->next_path = get_next_path_rr;\n\telse if (clt->mp_policy == MP_POLICY_MIN_INFLIGHT)\n\t\tit->next_path = get_next_path_min_inflight;\n\telse\n\t\tit->next_path = get_next_path_min_latency;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":244094,"func":"void paen_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":265424,"func":"static GroupInfo createGroup(std::string comment,int lineNo)\n{\n\t\/\/store info related to group\n\tGroupInfo groupInfo;\n\tstd::string finalGroupName;\n\n\tboost::regex regex(\"\\\\[(.*?)\\\\]\");\n\tboost::match_results<std::string::const_iterator>  match;\n\twhile(boost::regex_search(comment, match, regex)) {\n\t\tstd::string groupName = match[1].str();\n\t\tif (finalGroupName.empty()) {\n\t\t\tfinalGroupName = groupName;\n\t\t} else {\n\t\t\tfinalGroupName = finalGroupName + \"-\" + groupName;\n\t\t}\n\t\tgroupName.clear();\n\t\tcomment = match.suffix();\n\t}\n\n\tgroupInfo.commentString = finalGroupName;\n\tgroupInfo.lineNo = lineNo;\n\treturn groupInfo;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":226338,"func":"\nGF_Err udta_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_UserDataMap *map;\n\tGF_UserDataBox *ptr = (GF_UserDataBox *)s;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\ti=0;\n\twhile ((map = (GF_UserDataMap *)gf_list_enum(ptr->recordList, &i))) {\n\t\t\/\/warning: here we are not passing the actual \"parent\" of the list\n\t\t\/\/but the UDTA box. The parent itself is not an box, we don't care about it\n\t\te = gf_isom_box_array_write(s, map->boxes, bs);\n\t\tif (e) return e;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":261937,"func":"njs_encode_base64(njs_str_t *dst, const njs_str_t *src)\n{\n    static u_char   basis64[] =\n        \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/\";\n\n    njs_encode_base64_core(dst, src, basis64, 1);\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":223406,"func":"static BOOL optimize_class(compiler_common *common, const sljit_u8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks)\n{\n\/* May destroy TMP1. *\/\nif (optimize_class_ranges(common, bits, nclass, invert, backtracks))\n  return TRUE;\nreturn optimize_class_chars(common, bits, nclass, invert, backtracks);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":220423,"func":"mrb_ary_size(mrb_state *mrb, mrb_value self)\n{\n  struct RArray *a = mrb_ary_ptr(self);\n\n  return mrb_int_value(mrb, ARY_LEN(a));\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":512593,"func":"  virtual bool is_evaluable_expression() const { return true; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":224201,"func":"    void unsubscribeAll(Subscriber *subscriber, bool mayFlush = true) {\n        if (subscriber) {\n            for (Topic *topic : subscriber->subscriptions) {\n\n                \/* We do not want to flush when closing a socket, it makes no sense to do so *\/\n\n                \/* If this topic is triggered, drain the tree before we leave *\/\n                if (mayFlush && topic->triggered) {\n                    drain();\n                }\n\n                \/* Remove us from the topic's set *\/\n                topic->subs.erase(subscriber);\n                trimTree(topic);\n            }\n            subscriber->subscriptions.clear();\n        }\n    }","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":512347,"func":"  const Type_handler *type_handler() const\n  {\n    return Type_handler::get_handler_by_field_type(date_time_field_type);\n  }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":338095,"func":"void WasmBinaryBuilder::getResizableLimits(Address& initial,\n                                           Address& max,\n                                           bool& shared,\n                                           Type& indexType,\n                                           Address defaultIfNoMax) {\n  auto flags = getU32LEB();\n  bool hasMax = (flags & BinaryConsts::HasMaximum) != 0;\n  bool isShared = (flags & BinaryConsts::IsShared) != 0;\n  bool is64 = (flags & BinaryConsts::Is64) != 0;\n  initial = is64 ? getU64LEB() : getU32LEB();\n  if (isShared && !hasMax) {\n    throwError(\"shared memory must have max size\");\n  }\n  shared = isShared;\n  indexType = is64 ? Type::i64 : Type::i32;\n  if (hasMax) {\n    max = is64 ? getU64LEB() : getU32LEB();\n  } else {\n    max = defaultIfNoMax;\n  }\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":240268,"func":"set_y_previous(yankreg_T *yreg)\n{\n    y_previous = yreg;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":369334,"func":"static int io_madvise(struct io_kiocb *req, unsigned int issue_flags)\n{\n#if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU)\n\tstruct io_madvise *ma = &req->madvise;\n\tint ret;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tret = do_madvise(current->mm, ma->addr, ma->len, ma->advice);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":224165,"func":"  void Compute(OpKernelContext* ctx) override {\n    StagingMap<Ordered>* map = nullptr;\n    OP_REQUIRES_OK(ctx, GetStagingMap(ctx, def(), &map));\n    core::ScopedUnref scope(map);\n    typename StagingMap<Ordered>::Tuple tuple;\n\n    const Tensor* key_tensor;\n    const Tensor* indices_tensor;\n\n    OP_REQUIRES_OK(ctx, ctx->input(\"key\", &key_tensor));\n    OP_REQUIRES_OK(ctx, ctx->input(\"indices\", &indices_tensor));\n    OP_REQUIRES_OK(ctx, map->get(key_tensor, indices_tensor, &tuple));\n\n    OP_REQUIRES(\n        ctx, tuple.size() == indices_tensor->NumElements(),\n        errors::InvalidArgument(\"output\/indices size mismatch: \", tuple.size(),\n                                \" vs. \", indices_tensor->NumElements()));\n\n    for (std::size_t i = 0; i < tuple.size(); ++i) {\n      ctx->set_output(i, tuple[i]);\n    }\n  }","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":238465,"func":"static bool register_is_bounded(struct bpf_reg_state *reg)\n{\n\treturn reg->type == SCALAR_VALUE && !__is_scalar_unbounded(reg);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":427727,"func":"cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,\n    const cdf_header_t *h, cdf_secid_t id)\n{\n\tsize_t ss = CDF_SEC_SIZE(h);\n\tsize_t pos;\n\n\tif (SIZE_T_MAX \/ ss < CAST(size_t, id))\n\t\treturn -1;\n\n\tpos = CDF_SEC_POS(h, id);\n\tassert(ss == len);\n\treturn cdf_read(info, CAST(off_t, pos), RCAST(char *, buf) + offs, len);\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":310012,"func":"TPUTS_PROTO(outc, c)\n{\n    int rc = c;\n\n    if (interrupted) {\n\tchar tmp = (char) c;\n\tif (write(STDOUT_FILENO, &tmp, (size_t) 1) == -1)\n\t    rc = EOF;\n    } else {\n\trc = putc(c, stdout);\n    }\n    TPUTS_RETURN(rc);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":267920,"func":"void ogs_nas_5gs_mobile_identity_guti_to_nas_guti(\n        ogs_nas_5gs_mobile_identity_guti_t *mobile_identity_guti,\n        ogs_nas_5gs_guti_t *nas_guti)\n{\n    ogs_assert(mobile_identity_guti);\n    ogs_assert(nas_guti);\n\n    memset(nas_guti, 0, sizeof(*nas_guti));\n\n    memcpy(&nas_guti->nas_plmn_id,\n            &mobile_identity_guti->nas_plmn_id, OGS_PLMN_ID_LEN);\n    memcpy(&nas_guti->amf_id,\n            &mobile_identity_guti->amf_id, sizeof(ogs_amf_id_t));\n    nas_guti->m_tmsi = be32toh(mobile_identity_guti->m_tmsi);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":219955,"func":"int callback_glewlwyd_get_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) {\n  struct config_elements * config = (struct config_elements *)client_data;\n  json_t * j_module;\n  \n  j_module = get_client_module(config, u_map_get(request->map_url, \"name\"));\n  if (check_result_value(j_module, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module, \"module\"));\n  } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_client_module - Error get_client_module\");\n    response->status = 500;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":359638,"func":"DEFUN (bgp_deterministic_med,\n       bgp_deterministic_med_cmd,\n       \"bgp deterministic-med\",\n       \"BGP specific commands\\n\"\n       \"Pick the best-MED path among paths advertised from the neighboring AS\\n\")\n{\n  struct bgp *bgp;\n\n  bgp = vty->index;\n  bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":412106,"func":"new_rrset(struct regional* region, uint16_t rrtype, uint16_t rrclass)\n{\n\tstruct packed_rrset_data* pd;\n\tstruct ub_packed_rrset_key* rrset = regional_alloc_zero(\n\t\tregion, sizeof(*rrset));\n\tif(!rrset) {\n\t\tlog_err(\"out of memory\");\n\t\treturn NULL;\n\t}\n\trrset->entry.key = rrset;\n\tpd = regional_alloc_zero(region, sizeof(*pd));\n\tif(!pd) {\n\t\tlog_err(\"out of memory\");\n\t\treturn NULL;\n\t}\n\tpd->trust = rrset_trust_prim_noglue;\n\tpd->security = sec_status_insecure;\n\trrset->entry.data = pd;\n\trrset->rk.dname = regional_alloc_zero(region, 1);\n\tif(!rrset->rk.dname) {\n\t\tlog_err(\"out of memory\");\n\t\treturn NULL;\n\t}\n\trrset->rk.dname_len = 1;\n\trrset->rk.type = htons(rrtype);\n\trrset->rk.rrset_class = htons(rrclass);\n\treturn rrset;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":366170,"func":"struct vfsmount *fc_mount(struct fs_context *fc)\n{\n\tint err = vfs_get_tree(fc);\n\tif (!err) {\n\t\tup_write(&fc->root->d_sb->s_umount);\n\t\treturn vfs_create_mount(fc);\n\t}\n\treturn ERR_PTR(err);\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":229163,"func":"int virtio_serial_open(VirtIOSerialPort *port)\n{\n    \/* Don't allow opening an already-open port *\/\n    if (port->host_connected) {\n        return 0;\n    }\n    \/* Send port open notification to the guest *\/\n    port->host_connected = true;\n    send_control_event(port->vser, port->id, VIRTIO_CONSOLE_PORT_OPEN, 1);\n\n    return 0;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":384786,"func":"f_exepath(typval_T *argvars, typval_T *rettv)\n{\n    char_u *p = NULL;\n\n    if (in_vim9script() && check_for_nonempty_string_arg(argvars, 0) == FAIL)\n\treturn;\n    (void)mch_can_exe(tv_get_string(&argvars[0]), &p, TRUE);\n    rettv->v_type = VAR_STRING;\n    rettv->vval.v_string = p;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":473951,"func":"code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED)\n{\n  if (ONIGENC_IS_CODE_ASCII(code)) return 1;\n  else if (code > 0xffffffff) return 0;\n  else if ((code & 0xff000000) >= 0x80000000) return 4;\n  else if ((code &   0xff0000) >= 0x800000) return 3;\n  else if ((code &     0xff00) >= 0x8000) return 2;\n  else\n    return ONIGERR_INVALID_CODE_POINT_VALUE;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":317000,"func":"static int selinux_fs_context_parse_param(struct fs_context *fc,\n\t\t\t\t\t  struct fs_parameter *param)\n{\n\tstruct fs_parse_result result;\n\tint opt, rc;\n\n\topt = fs_parse(fc, selinux_fs_parameters, param, &result);\n\tif (opt < 0)\n\t\treturn opt;\n\n\trc = selinux_add_opt(opt, param->string, &fc->security);\n\tif (!rc) {\n\t\tparam->string = NULL;\n\t\trc = 1;\n\t}\n\treturn rc;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":225508,"func":"void SwapFanoutsMapValues(FanoutsMap* fanouts,\n                          const MutableGraphView::OutputPort& from_port,\n                          const FanoutsMap::iterator& from_fanouts,\n                          const MutableGraphView::OutputPort& to_port,\n                          const FanoutsMap::iterator& to_fanouts) {\n  const bool from_exists = from_fanouts != fanouts->end();\n  const bool to_exists = to_fanouts != fanouts->end();\n\n  if (from_exists && to_exists) {\n    std::swap(from_fanouts->second, to_fanouts->second);\n  } else if (from_exists) {\n    fanouts->emplace(to_port, std::move(from_fanouts->second));\n    fanouts->erase(from_port);\n  } else if (to_exists) {\n    fanouts->emplace(from_port, std::move(to_fanouts->second));\n    fanouts->erase(to_port);\n  }\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":405332,"func":"__xfrm_policy_eval_candidates(struct hlist_head *chain,\n\t\t\t      struct xfrm_policy *prefer,\n\t\t\t      const struct flowi *fl,\n\t\t\t      u8 type, u16 family, int dir, u32 if_id)\n{\n\tu32 priority = prefer ? prefer->priority : ~0u;\n\tstruct xfrm_policy *pol;\n\n\tif (!chain)\n\t\treturn NULL;\n\n\thlist_for_each_entry_rcu(pol, chain, bydst) {\n\t\tint err;\n\n\t\tif (pol->priority > priority)\n\t\t\tbreak;\n\n\t\terr = xfrm_policy_match(pol, fl, type, family, dir, if_id);\n\t\tif (err) {\n\t\t\tif (err != -ESRCH)\n\t\t\t\treturn ERR_PTR(err);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (prefer) {\n\t\t\t\/* matches.  Is it older than *prefer? *\/\n\t\t\tif (pol->priority == priority &&\n\t\t\t    prefer->pos < pol->pos)\n\t\t\t\treturn prefer;\n\t\t}\n\n\t\treturn pol;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":310075,"func":"can_clear_with(NCURSES_SP_DCLx ARG_CH_T ch)\n{\n    if (!back_color_erase && SP_PARM->_coloron) {\n#if NCURSES_EXT_FUNCS\n\tint pair;\n\n\tif (!SP_PARM->_default_color)\n\t    return FALSE;\n\tif (!(isDefaultColor(SP_PARM->_default_fg) &&\n\t      isDefaultColor(SP_PARM->_default_bg)))\n\t    return FALSE;\n\tif ((pair = GetPair(CHDEREF(ch))) != 0) {\n\t    NCURSES_COLOR_T fg, bg;\n\t    if (NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx\n\t\t\t\t\t       (short) pair,\n\t\t\t\t\t       &fg, &bg) == ERR\n\t\t|| !(isDefaultColor(fg) && isDefaultColor(bg))) {\n\t\treturn FALSE;\n\t    }\n\t}\n#else\n\tif (AttrOfD(ch) & A_COLOR)\n\t    return FALSE;\n#endif\n    }\n    return (ISBLANK(CHDEREF(ch)) &&\n\t    (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR);\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":474440,"func":"ObjectIsSequence(\n\t\t OBJECT          *object         \/\/ IN: handle to be checked\n\t\t )\n{\n    pAssert(object != NULL);\n    return (object->attributes.hmacSeq == SET\n\t    || object->attributes.hashSeq == SET\n\t    || object->attributes.eventSeq == SET);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":333051,"func":"pim_equal(nfa_pim_T *one, nfa_pim_T *two)\n{\n    int one_unused = (one == NULL || one->result == NFA_PIM_UNUSED);\n    int two_unused = (two == NULL || two->result == NFA_PIM_UNUSED);\n\n    if (one_unused)\n\t\/\/ one is unused: equal when two is also unused\n\treturn two_unused;\n    if (two_unused)\n\t\/\/ one is used and two is not: not equal\n\treturn FALSE;\n    \/\/ compare the state id\n    if (one->state->id != two->state->id)\n\treturn FALSE;\n    \/\/ compare the position\n    if (REG_MULTI)\n\treturn one->end.pos.lnum == two->end.pos.lnum\n\t    && one->end.pos.col == two->end.pos.col;\n    return one->end.ptr == two->end.ptr;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":331780,"func":"void QPaintEngineEx::setState(QPainterState *s)\n{\n    QPaintEngine::state = s;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":462528,"func":"std::string quote_empty(const std::string& input) {\n\tif (input.empty()) {\n\t\treturn \"''\";\n\t} else {\n\t\treturn input;\n\t}\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":225081,"func":"PQuser(const PGconn *conn)\n{\n\tif (!conn)\n\t\treturn NULL;\n\treturn conn->pguser;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":412128,"func":"dnsc_shared_secrets_delkeyfunc(void *k, void* ATTR_UNUSED(arg))\n{\n    struct shared_secret_cache_key* ssk = (struct shared_secret_cache_key*)k;\n    lock_rw_destroy(&ssk->entry.lock);\n    free(ssk);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":208535,"func":"static RzList *relocs(RzBinFile *bf) {\n\trz_return_val_if_fail(bf && bf->o, NULL);\n\tQnxObj *qo = bf->o->bin_obj;\n\treturn rz_list_clone(qo->fixups);\n}","target":1,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":506437,"func":"static void rpa_user_response(struct rpa_auth_request *request,\n\t\t\t      unsigned char digest[STATIC_ARRAY MD5_RESULTLEN])\n{\n\tstruct md5_context ctx;\n\tunsigned char z[48];\n\n\tmemset(z, 0, sizeof(z));\n\n\tmd5_init(&ctx);\n\tmd5_update(&ctx, request->pwd_md5, sizeof(request->pwd_md5));\n\tmd5_update(&ctx, z, sizeof(z));\n\tmd5_update(&ctx, request->username_ucs2be, request->username_len);\n\tmd5_update(&ctx, request->service_ucs2be, request->service_len);\n\tmd5_update(&ctx, request->realm_ucs2be, request->realm_len);\n\tmd5_update(&ctx, request->user_challenge, request->user_challenge_len);\n\tmd5_update(&ctx, request->service_challenge, RPA_SCHALLENGE_LEN);\n\tmd5_update(&ctx, request->service_timestamp, RPA_TIMESTAMP_LEN);\n\tmd5_update(&ctx, request->pwd_md5, sizeof(request->pwd_md5));\n\tmd5_final(&ctx, digest);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":512847,"func":"  const Type_handler *real_type_handler() const\n  {\n    \/\/ Should not be called, Item_blob is used for SHOW purposes only.\n    DBUG_ASSERT(0);\n    return &type_handler_varchar;\n  }","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":482493,"func":"lou_readCharFromFile(const char *fileName, int *mode) {\n\t\/* Read a character from a file, whether big-endian, little-endian or\n\t * ASCII8 *\/\n\tint ch;\n\tstatic FileInfo file;\n\tif (fileName == NULL) return 0;\n\tif (*mode == 1) {\n\t\t*mode = 0;\n\t\tfile.fileName = fileName;\n\t\tfile.encoding = noEncoding;\n\t\tfile.status = 0;\n\t\tfile.lineNumber = 0;\n\t\tif (!(file.in = fopen(file.fileName, \"r\"))) {\n\t\t\t_lou_logMessage(LOU_LOG_ERROR, \"Cannot open file '%s'\", file.fileName);\n\t\t\t*mode = 1;\n\t\t\treturn EOF;\n\t\t}\n\t}\n\tif (file.in == NULL) {\n\t\t*mode = 1;\n\t\treturn EOF;\n\t}\n\tch = getAChar(&file);\n\tif (ch == EOF) {\n\t\tfclose(file.in);\n\t\tfile.in = NULL;\n\t\t*mode = 1;\n\t}\n\treturn ch;\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":500045,"func":"static void* kssl_calloc(size_t nmemb, size_t size)\n{\n\tvoid* p;\n\t\n\tp=OPENSSL_malloc(nmemb*size);\n\tif (p){\n\t\tmemset(p, 0, nmemb*size);\n\t}\n\treturn p;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":366318,"func":"long do_mount(const char *dev_name, const char __user *dir_name,\n\t\tconst char *type_page, unsigned long flags, void *data_page)\n{\n\tstruct path path;\n\tint ret;\n\n\tret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path);\n\tif (ret)\n\t\treturn ret;\n\tret = path_mount(dev_name, &path, type_page, flags, data_page);\n\tpath_put(&path);\n\treturn ret;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":409485,"func":"out_trash(void)\n{\n    out_pos = 0;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":221144,"func":"GF_Err gf_odf_hevc_cfg_write(GF_HEVCConfig *cfg, u8 **outData, u32 *outSize)\n{\n\tGF_Err e;\n\tGF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);\n\t*outSize = 0;\n\t*outData = NULL;\n\te = gf_odf_hevc_cfg_write_bs(cfg, bs);\n\tif (e==GF_OK)\n\t\tgf_bs_get_content(bs, outData, outSize);\n\n\tgf_bs_del(bs);\n\treturn e;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":450347,"func":"static bool check_solid_tile(VncState *vs, int x, int y, int w, int h,\n                             uint32_t* color, bool samecolor)\n{\n    QEMU_BUILD_BUG_ON(VNC_SERVER_FB_BYTES != 4);\n    return check_solid_tile32(vs, x, y, w, h, color, samecolor);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":512585,"func":"Item_bool_rowready_func2* Gt_creator::create_swap(THD *thd, Item *a, Item *b) const\n{\n  return new(thd->mem_root) Item_func_lt(thd, b, a);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":455348,"func":"dequote_pathname (pathname)\n     char *pathname;\n{\n  if (MB_CUR_MAX > 1)\n    wdequote_pathname (pathname);\n  else\n    udequote_pathname (pathname);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":238570,"func":"static int resize_reference_state(struct bpf_func_state *state, size_t n)\n{\n\tstate->refs = realloc_array(state->refs, state->acquired_refs, n,\n\t\t\t\t    sizeof(struct bpf_reference_state));\n\tif (!state->refs)\n\t\treturn -ENOMEM;\n\n\tstate->acquired_refs = n;\n\treturn 0;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":513277,"func":"int rr_sequential_and_unpack(READ_RECORD *info)\n{\n  int error;\n  if ((error= rr_sequential(info)))\n    return error;\n  \n  for (Copy_field *cp= info->copy_field; cp != info->copy_field_end; cp++)\n    (*cp->do_copy)(cp);\n\n  return error;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":270402,"func":"static bool ok_inflater_literal_tree(ok_inflater *inflater) {\n    bool done = ok_inflater_inflate_huffman_tree(inflater, inflater->literal_huffman,\n                                                 inflater->code_length_huffman,\n                                                 inflater->num_literal_codes);\n    if (done) {\n        inflater->state = OK_INFLATER_STATE_READING_DYNAMIC_DISTANCE_TREE;\n        inflater->huffman_code = -1;\n        inflater->state_count = 0;\n        return true;\n    } else {\n        return false;\n    }\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":273898,"func":"static void handle_LIST(ctrl_t *ctrl, char *arg)\n{\n\tlist(ctrl, arg, 0);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":442800,"func":"static char *my_get_line(FILE *fp)\n{\n   char buf[4096];\n   char *nl = NULL;\n   char *retval = NULL;\n\n   do {\n     if (NULL == fgets(buf, sizeof(buf), fp))\n       break;\n     if (NULL == retval)\n       retval = strdup(buf);\n     else {\n       if (NULL == (retval = realloc(retval,\n                                     strlen(retval) + strlen(buf) + 1)))\n         break;\n       strcat(retval, buf);\n     }\n   }\n   while (NULL == (nl = strchr(retval, '\\n')));\n\n   if (NULL != nl)\n     *nl = '\\0';\n\n   return retval;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":261901,"func":"njs_decode_base64(njs_str_t *dst, const njs_str_t *src)\n{\n    njs_decode_base64_core(dst, src, njs_basis64);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":317353,"func":"static int smack_msg_queue_associate(struct kern_ipc_perm *isp, int msqflg)\n{\n\tint may;\n\n\tmay = smack_flags_to_may(msqflg);\n\treturn smk_curacc_msq(isp, may);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":253566,"func":"static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,\n\t\t\t   loff_t off, loff_t len)\n{\n\t\/* KEEP_SIZE already checked for by do_fallocate *\/\n\tif (mode & FALLOC_FL_PUNCH_HOLE)\n\t\treturn smb3_punch_hole(file, tcon, off, len);\n\telse if (mode & FALLOC_FL_ZERO_RANGE) {\n\t\tif (mode & FALLOC_FL_KEEP_SIZE)\n\t\t\treturn smb3_zero_range(file, tcon, off, len, true);\n\t\treturn smb3_zero_range(file, tcon, off, len, false);\n\t} else if (mode == FALLOC_FL_KEEP_SIZE)\n\t\treturn smb3_simple_falloc(file, tcon, off, len, true);\n\telse if (mode == FALLOC_FL_COLLAPSE_RANGE)\n\t\treturn smb3_collapse_range(file, tcon, off, len);\n\telse if (mode == FALLOC_FL_INSERT_RANGE)\n\t\treturn smb3_insert_range(file, tcon, off, len);\n\telse if (mode == 0)\n\t\treturn smb3_simple_falloc(file, tcon, off, len, false);\n\n\treturn -EOPNOTSUPP;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":463128,"func":"EXPORTED int annotate_state_set_mailbox(annotate_state_t *state,\n                                struct mailbox *mailbox)\n{\n    return annotate_state_set_scope(state, NULL, mailbox, 0);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":317113,"func":"static int selinux_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)\n{\n\tu32 peer_secid = SECSID_NULL;\n\tu16 family;\n\tstruct inode_security_struct *isec;\n\n\tif (skb && skb->protocol == htons(ETH_P_IP))\n\t\tfamily = PF_INET;\n\telse if (skb && skb->protocol == htons(ETH_P_IPV6))\n\t\tfamily = PF_INET6;\n\telse if (sock)\n\t\tfamily = sock->sk->sk_family;\n\telse\n\t\tgoto out;\n\n\tif (sock && family == PF_UNIX) {\n\t\tisec = inode_security_novalidate(SOCK_INODE(sock));\n\t\tpeer_secid = isec->sid;\n\t} else if (skb)\n\t\tselinux_skb_peerlbl_sid(skb, family, &peer_secid);\n\nout:\n\t*secid = peer_secid;\n\tif (peer_secid == SECSID_NULL)\n\t\treturn -EINVAL;\n\treturn 0;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":256460,"func":"void janet_array_setcount(JanetArray *array, int32_t count) {\n    if (count < 0)\n        return;\n    if (count > array->count) {\n        int32_t i;\n        janet_array_ensure(array, count, 1);\n        for (i = array->count; i < count; i++) {\n            array->data[i] = janet_wrap_nil();\n        }\n    }\n    array->count = count;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":248764,"func":"void Curl_cookie_loadfiles(struct Curl_easy *data)\n{\n  struct curl_slist *list = data->state.cookielist;\n  if(list) {\n    Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);\n    while(list) {\n      struct CookieInfo *newcookies = Curl_cookie_init(data,\n                                        list->data,\n                                        data->cookies,\n                                        data->set.cookiesession);\n      if(!newcookies)\n        \/*\n         * Failure may be due to OOM or a bad cookie; both are ignored\n         * but only the first should be\n         *\/\n        infof(data, \"ignoring failed cookie_init for %s\", list->data);\n      else\n        data->cookies = newcookies;\n      list = list->next;\n    }\n    curl_slist_free_all(data->state.cookielist); \/* clean up list *\/\n    data->state.cookielist = NULL; \/* don't do this again! *\/\n    Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);\n  }\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":256140,"func":"  explicit SparseMatMulOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"transpose_a\", &transpose_a_));\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"transpose_b\", &transpose_b_));\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"a_is_sparse\", &a_is_sparse_));\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"b_is_sparse\", &b_is_sparse_));\n  }","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":512880,"func":"  String *val_str(String *to) { return cached_time.to_string(to, decimals); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":476111,"func":"function_descriptors(struct usb_function *f,\n\t\t     enum usb_device_speed speed)\n{\n\tstruct usb_descriptor_header **descriptors;\n\n\t\/*\n\t * NOTE: we try to help gadget drivers which might not be setting\n\t * max_speed appropriately.\n\t *\/\n\n\tswitch (speed) {\n\tcase USB_SPEED_SUPER_PLUS:\n\t\tdescriptors = f->ssp_descriptors;\n\t\tif (descriptors)\n\t\t\tbreak;\n\t\tfallthrough;\n\tcase USB_SPEED_SUPER:\n\t\tdescriptors = f->ss_descriptors;\n\t\tif (descriptors)\n\t\t\tbreak;\n\t\tfallthrough;\n\tcase USB_SPEED_HIGH:\n\t\tdescriptors = f->hs_descriptors;\n\t\tif (descriptors)\n\t\t\tbreak;\n\t\tfallthrough;\n\tdefault:\n\t\tdescriptors = f->fs_descriptors;\n\t}\n\n\t\/*\n\t * if we can't find any descriptors at all, then this gadget deserves to\n\t * Oops with a NULL pointer dereference\n\t *\/\n\n\treturn descriptors;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":430459,"func":"int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,\n\t\t\t   const struct sw_flow_key *key, bool log)\n{\n\tstruct sw_flow_key *new_key;\n\n\tif (ovs_nla_get_ufid(sfid, ufid, log))\n\t\treturn 0;\n\n\t\/* If UFID was not provided, use unmasked key. *\/\n\tnew_key = kmalloc(sizeof(*new_key), GFP_KERNEL);\n\tif (!new_key)\n\t\treturn -ENOMEM;\n\tmemcpy(new_key, key, sizeof(*key));\n\tsfid->unmasked_key = new_key;\n\n\treturn 0;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":317004,"func":"static struct smack_known *smk_fetch(const char *name, struct inode *ip,\n\t\t\t\t\tstruct dentry *dp)\n{\n\tint rc;\n\tchar *buffer;\n\tstruct smack_known *skp = NULL;\n\n\tif (!(ip->i_opflags & IOP_XATTR))\n\t\treturn ERR_PTR(-EOPNOTSUPP);\n\n\tbuffer = kzalloc(SMK_LONGLABEL, GFP_NOFS);\n\tif (buffer == NULL)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\trc = __vfs_getxattr(dp, ip, name, buffer, SMK_LONGLABEL);\n\tif (rc < 0)\n\t\tskp = ERR_PTR(rc);\n\telse if (rc == 0)\n\t\tskp = NULL;\n\telse\n\t\tskp = smk_import_entry(buffer, rc);\n\n\tkfree(buffer);\n\n\treturn skp;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":219910,"func":"GF_Err gf_isom_sdp_get(GF_ISOFile *movie, const char **sdp, u32 *length)\n{\n\tGF_UserDataMap *map;\n\tGF_HintTrackInfoBox *hnti;\n\tGF_RTPBox *rtp;\n\t*length = 0;\n\t*sdp = NULL;\n\tif (!movie || !movie->moov) return GF_BAD_PARAM;\n\t\/\/check if we have a udta ...\n\tif (!movie->moov->udta) return GF_OK;\n\n\t\/\/find a hnti in the udta\n\tmap = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);\n\tif (!map) return GF_OK;\n\n\t\/\/there should be one and only one hnti\n\tif (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE;\n\thnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0);\n\n\tif (!hnti->SDP) return GF_OK;\n\trtp = (GF_RTPBox *) hnti->SDP;\n\n\t*length = (u32) strlen(rtp->sdpText);\n\t*sdp = rtp->sdpText;\n\treturn GF_OK;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":387793,"func":"Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) {\n  \/\/ Need load-acquire for lock-free read\n  if (array_klasses_acquire() == NULL) {\n    if (or_null) return NULL;\n\n    ResourceMark rm;\n    JavaThread *jt = (JavaThread *)THREAD;\n    {\n      \/\/ Atomic creation of array_klasses\n      MutexLocker mc(Compile_lock, THREAD);   \/\/ for vtables\n      MutexLocker ma(MultiArray_lock, THREAD);\n\n      \/\/ Check if update has already taken place\n      if (array_klasses() == NULL) {\n        Klass*    k = ObjArrayKlass::allocate_objArray_klass(class_loader_data(), 1, this, CHECK_NULL);\n        \/\/ use 'release' to pair with lock-free load\n        release_set_array_klasses(k);\n      }\n    }\n  }\n  \/\/ _this will always be set at this point\n  ObjArrayKlass* oak = (ObjArrayKlass*)array_klasses();\n  if (or_null) {\n    return oak->array_klass_or_null(n);\n  }\n  return oak->array_klass(n, THREAD);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":335411,"func":"ex_setfiletype(exarg_T *eap)\n{\n    if (!did_filetype)\n    {\n\tchar_u *arg = eap->arg;\n\n\tif (STRNCMP(arg, \"FALLBACK \", 9) == 0)\n\t    arg += 9;\n\n\tset_option_value_give_err((char_u *)\"filetype\", 0L, arg, OPT_LOCAL);\n\tif (arg != eap->arg)\n\t    did_filetype = FALSE;\n    }\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":447055,"func":"    FileIo::~FileIo()\n    {\n        close();\n        delete p_;\n    }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":381866,"func":"static void udf_readahead(struct readahead_control *rac)\n{\n\tmpage_readahead(rac, udf_get_block);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":314483,"func":"static int FNAME(walk_addr)(struct guest_walker *walker,\n\t\t\t    struct kvm_vcpu *vcpu, gpa_t addr, u64 access)\n{\n\treturn FNAME(walk_addr_generic)(walker, vcpu, vcpu->arch.mmu, addr,\n\t\t\t\t\taccess);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":512274,"func":"  Longlong_null to_longlong_null()\n  {\n    longlong nr= val_int();\n    \/*\n      C++ does not guarantee the order of parameter evaluation,\n      so to make sure \"null_value\" is passed to the constructor\n      after the val_int() call, val_int() is caled on a separate line.\n    *\/\n    return Longlong_null(nr, null_value);\n  }","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":508380,"func":"void promote_select_describe_flag_if_needed(LEX *lex)\n{\n  if (lex->describe)\n  {\n    lex->select_lex.options |= SELECT_DESCRIBE;\n  }\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":220245,"func":"bool OutputTensor::operator==(const OutputTensor& other) const {\n  return node == other.node && index == other.index;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":458982,"func":"http_GetContentLength(const struct http *hp)\n{\n\tssize_t cl;\n\tconst char *b;\n\n\tCHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);\n\n\tif (!http_GetHdr(hp, H_Content_Length, &b))\n\t\treturn (-1);\n\tcl = VNUM_uint(b, NULL, &b);\n\tif (cl < 0)\n\t\treturn (-2);\n\twhile (vct_islws(*b))\n\t\tb++;\n\tif (*b != '\\0')\n\t\treturn (-2);\n\treturn (cl);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":219909,"func":"GF_Err AdjustHintInfo(GF_HintSampleEntryBox *entry, u32 HintSampleNumber)\n{\n\tu32 offset, count, i, size;\n\tGF_Err e;\n\n\toffset = gf_isom_hint_sample_size(entry->hint_sample) - entry->hint_sample->dataLength;\n\tcount = gf_list_count(entry->hint_sample->packetTable);\n\n\tfor (i=0; i<count; i++) {\n\t\tGF_HintPacket *pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, i);\n\t\tif (offset && entry->hint_sample->dataLength) {\n\t\t\t\/\/adjust any offset in this packet\n\t\t\te = gf_isom_hint_pck_offset(pck, offset, HintSampleNumber);\n\t\t\tif (e) return e;\n\t\t}\n\t\t\/\/adjust the max packet size for this sample entry...\n\t\tsize = gf_isom_hint_pck_length(pck);\n\t\tif (entry->MaxPacketSize < size) entry->MaxPacketSize = size;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":512575,"func":"bool Item_cond::walk(Item_processor processor, bool walk_subquery, void *arg)\n{\n  List_iterator_fast<Item> li(list);\n  Item *item;\n  while ((item= li++))\n    if (item->walk(processor, walk_subquery, arg))\n      return 1;\n  return Item_func::walk(processor, walk_subquery, arg);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":282982,"func":"LJ_NOINLINE void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...)\n{\n  const char *msg;\n  va_list argp;\n  va_start(argp, em);\n  msg = lj_str_pushvf(L, err2msg(em), argp);\n  va_end(argp);\n  err_argmsg(L, narg, msg);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":245162,"func":"lock_binlog_maybe(MYSQL *connection, int timeout, int retry_count)\n{\n\tif (have_backup_locks && !opt_no_lock && !binlog_locked) {\n\t\tif (have_lock_wait_timeout) {\n\t\t\tchar query[200];\n\n\t\t\tut_snprintf(query, sizeof(query),\n\t\t\t\t    \"SET SESSION lock_wait_timeout=%d\",\n\t\t\t\t    timeout);\n\t\t}\n\n\t\tfor (int i = 0; i <= retry_count; ++i) {\n\t\t\tmsg_ts(\"Executing LOCK BINLOG FOR BACKUP...\\n\");\n\t\t\txb_mysql_query(connection, \"LOCK BINLOG FOR BACKUP\",\n\t\t\t\t       false, false);\n\t\t\tuint err = mysql_errno(connection);\n\t\t\tif (err == ER_LOCK_WAIT_TIMEOUT) {\n\t\t\t\tos_thread_sleep(1000000);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (err == 0) {\n\t\t\t\tbinlog_locked = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (!binlog_locked) {\n\t\t\texit(EXIT_FAILURE);\n\t\t}\n\n\t\treturn(true);\n\t}\n\n\treturn(false);\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":512635,"func":"int Arg_comparator::compare_e_decimal()\n{\n  VDec val1(*a), val2(*b);\n  if (val1.is_null() || val2.is_null())\n    return MY_TEST(val1.is_null() && val2.is_null());\n  val1.round_self_if_needed((*a)->decimals, HALF_UP);\n  val2.round_self_if_needed((*b)->decimals, HALF_UP);\n  return MY_TEST(val1.cmp(val2) == 0);\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":448533,"func":"void bgp_update_implicit_eors(struct peer *peer)\n{\n\tif (!bgp_update_delay_active(peer->bgp))\n\t\treturn; \/* BGP update delay has ended *\/\n\tif (peer->update_delay_over)\n\t\treturn; \/* This peer has already been considered *\/\n\n\tif (bgp_debug_neighbor_events(peer))\n\t\tzlog_debug(\"Peer %s: Checking implicit EORs\", peer->host);\n\n\tif (peer_established(peer)) {\n\t\tpeer->update_delay_over = 1;\n\t\tpeer->bgp->implicit_eors++;\n\t\tbgp_check_update_delay(peer->bgp);\n\t}\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":261402,"func":"static int decode_rqt_root_cbf(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# rqt_root_cbf\\n\");\n\n  int bit = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &tctx->ctx_model[CONTEXT_MODEL_RQT_ROOT_CBF]);\n\n  logtrace(LogSymbols,\"$1 rqt_root_cbf=%d\\n\",bit);\n  return bit;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":270768,"func":"static int login_global_init(void)\n{\n\tlogin_fail_command = xstrdup(\"boot\");\n\n\tglobalvar_add_simple_int(\"login.timeout\", &login_timeout, \"%d\");\n\tglobalvar_add_simple_string(\"login.fail_command\", &login_fail_command);\n\n\treturn 0;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":225710,"func":"\nGF_Err dac3_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\treturn gf_odf_ac3_config_parse_bs(bs, ptr->cfg.is_ec3, &ptr->cfg);","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":343122,"func":"static void esp6_destroy(struct xfrm_state *x)\n{\n\tstruct crypto_aead *aead = x->data;\n\n\tif (!aead)\n\t\treturn;\n\n\tcrypto_free_aead(aead);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":477813,"func":"int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp)\n{\n\tstruct kvm_rtas_token_args args;\n\tint rc;\n\n\tif (copy_from_user(&args, argp, sizeof(args)))\n\t\treturn -EFAULT;\n\n\tmutex_lock(&kvm->arch.rtas_token_lock);\n\n\tif (args.token)\n\t\trc = rtas_token_define(kvm, args.name, args.token);\n\telse\n\t\trc = rtas_token_undefine(kvm, args.name);\n\n\tmutex_unlock(&kvm->arch.rtas_token_lock);\n\n\treturn rc;\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":386573,"func":"DL_Dxf::DL_Dxf() {\n    version = DL_VERSION_2000;\n\n    vertices = NULL;\n    maxVertices = 0;\n    vertexIndex = 0;\n\n    knots = NULL;\n    maxKnots = 0;\n    knotIndex = 0;\n\n    weights = NULL;\n    weightIndex = 0;\n\n    controlPoints = NULL;\n    maxControlPoints = 0;\n    controlPointIndex = 0;\n\n    fitPoints = NULL;\n    maxFitPoints = 0;\n    fitPointIndex = 0;\n\n    leaderVertices = NULL;\n    maxLeaderVertices = 0;\n    leaderVertexIndex = 0;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":498141,"func":"void html_header_arg_in_quotes(const char *txt)\n{\n\tconst char *t = txt;\n\twhile (t && *t) {\n\t\tunsigned char c = *t;\n\t\tconst char *e = NULL;\n\t\tif (c == '\\\\')\n\t\t\te = \"\\\\\\\\\";\n\t\telse if (c == '\\r')\n\t\t\te = \"\\\\r\";\n\t\telse if (c == '\\n')\n\t\t\te = \"\\\\n\";\n\t\telse if (c == '\"')\n\t\t\te = \"\\\\\\\"\";\n\t\tif (e) {\n\t\t\thtml_raw(txt, t - txt);\n\t\t\thtml(e);\n\t\t\ttxt = t + 1;\n\t\t}\n\t\tt++;\n\t}\n\tif (t != txt)\n\t\thtml(txt);\n\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":329892,"func":"_cairo_image_bounded_spans (void *abstract_renderer,\n\t\t\t    int y, int height,\n\t\t\t    const cairo_half_open_span_t *spans,\n\t\t\t    unsigned num_spans)\n{\n    cairo_image_span_renderer_t *r = abstract_renderer;\n\n    if (num_spans == 0)\n\treturn CAIRO_STATUS_SUCCESS;\n\n    do {\n\tif (spans[0].coverage) {\n\t    pixman_image_compositor_blt (r->compositor,\n\t\t\t\t\t spans[0].x, y,\n\t\t\t\t\t spans[1].x - spans[0].x, height,\n\t\t\t\t\t r->opacity * spans[0].coverage);\n\t}\n\tspans++;\n    } while (--num_spans > 1);\n\n    return CAIRO_STATUS_SUCCESS;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":226188,"func":"GF_Err rtp_hnti_box_size(GF_Box *s)\n{\n\tGF_RTPBox *ptr = (GF_RTPBox *)s;\n\tptr->size += 4 + strlen(ptr->sdpText);\n\treturn GF_OK;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":310330,"func":"dirserv_get_directory(void)\n{\n  return dirserv_pick_cached_dir_obj(cached_directory, the_directory,\n                                     the_directory_is_dirty,\n                                     dirserv_regenerate_directory,\n                                     \"v1 server directory\", V1_AUTHORITY);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":254006,"func":"static unsigned int v4l2_loopback_poll(struct file *file, struct poll_table_struct *pts)\n{\n\tstruct v4l2_loopback_opener *opener;\n\tstruct v4l2_loopback_device *dev;\n\tint ret_mask = 0;\n\tMARK();\n\n\topener = file->private_data;\n\tdev    = v4l2loopback_getdevice(file);\n\n\tswitch (opener->type) {\n\tcase WRITER:\n\t\tret_mask = POLLOUT | POLLWRNORM;\n\t\tbreak;\n\tcase READER:\n\t\tpoll_wait(file, &dev->read_event, pts);\n\t\tif (can_read(dev, opener))\n\t\t\tret_mask =  POLLIN | POLLRDNORM;\n\t\tbreak;\n\tdefault:\n\t\tret_mask = -POLLERR;\n\t}\n\tMARK();\n\n\treturn ret_mask;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":333040,"func":"re2post(void)\n{\n    if (nfa_reg(REG_NOPAREN) == FAIL)\n\treturn NULL;\n    EMIT(NFA_MOPEN);\n    return post_start;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":252416,"func":"mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem,\n                               size_t size, mz_uint32 flags) {\n  if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE;\n  pZip->m_archive_size = size;\n  pZip->m_pRead = mz_zip_mem_read_func;\n  pZip->m_pIO_opaque = pZip;\n#ifdef __cplusplus\n  pZip->m_pState->m_pMem = const_cast<void *>(pMem);\n#else\n  pZip->m_pState->m_pMem = (void *)pMem;\n#endif\n  pZip->m_pState->m_mem_size = size;\n  if (!mz_zip_reader_read_central_dir(pZip, flags)) {\n    mz_zip_reader_end(pZip);\n    return MZ_FALSE;\n  }\n  return MZ_TRUE;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":386512,"func":"void DL_Dxf::writeBlockRecord(DL_WriterA& dw, const std::string& name) {\n    dw.dxfString(  0, \"BLOCK_RECORD\");\n    if (version==DL_VERSION_2000) {\n        dw.handle();\n    }\n    \/\/dw->dxfHex(330, 1);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbSymbolTableRecord\");\n        dw.dxfString(100, \"AcDbBlockTableRecord\");\n    }\n    dw.dxfString(  2, name);\n    dw.dxfHex(340, 0);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":274861,"func":"TEST(ComparisonsTest, LessEqualFloat) {\n  ComparisonOpModel model({1, 1, 1, 4}, {1, 1, 1, 4}, TensorType_FLOAT32,\n                          BuiltinOperator_LESS_EQUAL);\n  model.PopulateTensor<float>(model.input1(), {0.1, 0.9, 0.7, 0.3});\n  model.PopulateTensor<float>(model.input2(), {0.1, 0.2, 0.6, 0.5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(true, false, false, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 1, 4));\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":294431,"func":"m_amjd(union DateData *x)\n{\n    VALUE r, sf;\n    int df;\n\n    r = m_real_jd(x);\n    if (FIXNUM_P(r) && FIX2LONG(r) >= (FIXNUM_MIN + 2400001)) {\n\tlong ir = FIX2LONG(r);\n\tir -= 2400001;\n\tr = rb_rational_new1(LONG2FIX(ir));\n    }\n    else\n\tr = rb_rational_new1(f_sub(m_real_jd(x),\n\t\t\t\t   INT2FIX(2400001)));\n\n    if (simple_dat_p(x))\n\treturn r;\n\n    df = m_df(x);\n    if (df)\n\tr = f_add(r, isec_to_day(df));\n    sf = m_sf(x);\n    if (f_nonzero_p(sf))\n\tr = f_add(r, ns_to_day(sf));\n\n    return r;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":352954,"func":"serialNumberAndIssuerValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\tint rc;\n\tstruct berval sn, i;\n\n\tDebug( LDAP_DEBUG_TRACE, \">>> serialNumberAndIssuerValidate: <%s>\\n\",\n\t\tin->bv_val );\n\n\trc = serialNumberAndIssuerCheck( in, &sn, &i, NULL );\n\tif ( rc ) {\n\t\tgoto done;\n\t}\n\n\t\/* validate DN -- doesn't handle double dquote *\/ \n\trc = dnValidate( NULL, &i );\n\tif ( rc ) {\n\t\trc = LDAP_INVALID_SYNTAX;\n\t}\n\n\tif ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) {\n\t\tslap_sl_free( i.bv_val, NULL );\n\t}\n\n\tDebug( LDAP_DEBUG_TRACE, \"<<< serialNumberAndIssuerValidate: <%s> err=%d\\n\",\n\t\tin->bv_val, rc );\n\ndone:;\n\treturn rc;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":437674,"func":"static inline void control_tx_modulation_enable(struct cx23885_dev *dev,\n\t\t\t\t\t\tbool enable)\n{\n\tcx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~CNTRL_MOD,\n\t\t\t   enable ? CNTRL_MOD : 0);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":455390,"func":"__xfs_inode_free(\n\tstruct xfs_inode\t*ip)\n{\n\t\/* asserts to verify all state is correct here *\/\n\tASSERT(atomic_read(&ip->i_pincount) == 0);\n\tXFS_STATS_DEC(ip->i_mount, vn_active);\n\n\tcall_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":238323,"func":"struct digest *digest_alloc(const char *name)\n{\n\tstruct digest *d;\n\tstruct digest_algo *algo;\n\n\talgo = digest_algo_get_by_name(name);\n\tif (!algo)\n\t\treturn NULL;\n\n\td = xzalloc(sizeof(*d));\n\td->algo = algo;\n\td->ctx = xzalloc(algo->ctx_length);\n\tif (d->algo->alloc(d)) {\n\t\tdigest_free(d);\n\t\treturn NULL;\n\t}\n\n\treturn d;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":313758,"func":"find_is_eval_item(\n    char_u\t*ptr,\n    int\t\t*colp,\n    int\t\t*bnp,\n    int\t\tdir)\n{\n    \/\/ Accept everything inside [].\n    if ((*ptr == ']' && dir == BACKWARD) || (*ptr == '[' && dir == FORWARD))\n\t++*bnp;\n    if (*bnp > 0)\n    {\n\tif ((*ptr == '[' && dir == BACKWARD) || (*ptr == ']' && dir == FORWARD))\n\t    --*bnp;\n\treturn TRUE;\n    }\n\n    \/\/ skip over \"s.var\"\n    if (*ptr == '.')\n\treturn TRUE;\n\n    \/\/ two-character item: s->var\n    if (ptr[dir == BACKWARD ? 0 : 1] == '>'\n\t    && ptr[dir == BACKWARD ? -1 : 0] == '-')\n    {\n\t*colp += dir;\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":270765,"func":"int passwd_env_disable(void)\n{\n\treturn unlink(PASSWD_FILE);\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":253552,"func":"smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)\n{\n\treturn ob1->fid.persistent_fid == ob2->fid.persistent_fid &&\n\t       ob1->fid.volatile_fid == ob2->fid.volatile_fid;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":308160,"func":"static void fastrpc_map_get(struct fastrpc_map *map)\n{\n\tif (map)\n\t\tkref_get(&map->refcount);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":267956,"func":"static RBinPlugin *get_plugin_from_buffer(RBin *bin, RBinFile *bf, const char *pluginname, RBuffer *buf) {\n\tRBinPlugin *plugin = bin->force? r_bin_get_binplugin_by_name (bin, bin->force): NULL;\n\tif (plugin) {\n\t\treturn plugin;\n\t}\n\tplugin = pluginname? r_bin_get_binplugin_by_name (bin, pluginname): NULL;\n\tif (plugin) {\n\t\treturn plugin;\n\t}\n\tplugin = r_bin_get_binplugin_by_buffer (bin, bf, buf);\n\tif (plugin) {\n\t\treturn plugin;\n\t}\n\treturn r_bin_get_binplugin_by_name (bin, \"any\");\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":247722,"func":"  const std::string& expectedCiphersuite() const { return expected_cipher_suite_; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":459515,"func":"static inline int stack_map_data_size(struct bpf_map *map)\n{\n\treturn stack_map_use_build_id(map) ?\n\t\tsizeof(struct bpf_stack_build_id) : sizeof(u64);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":244127,"func":"GF_Box *mvcg_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MultiviewGroupBox, GF_ISOM_BOX_TYPE_MVCG);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":369197,"func":"\nstatic __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *f)\n{\n\tstruct io_ring_ctx *ctx = f->private_data;\n\n\tif (percpu_ref_tryget(&ctx->refs)) {\n\t\t__io_uring_show_fdinfo(ctx, m);\n\t\tpercpu_ref_put(&ctx->refs);\n\t}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":223372,"func":"static SLJIT_INLINE void add_jump(struct sljit_compiler *compiler, jump_list **list, struct sljit_jump *jump)\n{\njump_list *list_item = sljit_alloc_memory(compiler, sizeof(jump_list));\nif (list_item)\n  {\n  list_item->next = *list;\n  list_item->jump = jump;\n  *list = list_item;\n  }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":317182,"func":"static int selinux_capable(const struct cred *cred, struct user_namespace *ns,\n\t\t\t   int cap, unsigned int opts)\n{\n\treturn cred_has_capability(cred, cap, opts, ns == &init_user_ns);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":294558,"func":"d_lite_zone(VALUE self)\n{\n    get_d1(self);\n    return m_zone(dat);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":270381,"func":"static bool ok_read(ok_png_decoder *decoder, uint8_t *buffer, size_t length) {\n    if (decoder->input.read(decoder->input_user_data, buffer, length) == length) {\n        return true;\n    } else {\n        ok_png_error(decoder->png, OK_PNG_ERROR_IO, \"Read error: error calling input function.\");\n        return false;\n    }\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":259198,"func":"static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    int little_endian = avio_rb16(pb) & 0xFF;\n    av_log(c->fc, AV_LOG_TRACE, \"enda %d\\n\", little_endian);\n    if (little_endian == 1)\n        set_last_stream_little_endian(c->fc);\n    return 0;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":226284,"func":"\nGF_Err dOps_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_OpusSpecificBox *ptr = (GF_OpusSpecificBox *)s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u8(bs, ptr->version);\n\tgf_bs_write_u8(bs, ptr->OutputChannelCount);\n\tgf_bs_write_u16(bs, ptr->PreSkip);\n\tgf_bs_write_u32(bs, ptr->InputSampleRate);\n\tgf_bs_write_u16(bs, ptr->OutputGain);\n\tgf_bs_write_u8(bs, ptr->ChannelMappingFamily);\n\tif (ptr->ChannelMappingFamily) {\n\t\tgf_bs_write_u8(bs, ptr->StreamCount);\n\t\tgf_bs_write_u8(bs, ptr->CoupledCount);\n\t\tgf_bs_write_data(bs, (char *) ptr->ChannelMapping, ptr->OutputChannelCount);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":225750,"func":"GF_Err trpy_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_TRPYBox *ptr = (GF_TRPYBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 8);\n\tptr->nbBytes = gf_bs_read_u64(bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":418797,"func":"get_pseudo_mouse_code(\n    int\t    button,\t\/\/ eg MOUSE_LEFT\n    int\t    is_click,\n    int\t    is_drag)\n{\n    int\t    i;\n\n    for (i = 0; mouse_table[i].pseudo_code; i++)\n\tif (button == mouse_table[i].button\n\t    && is_click == mouse_table[i].is_click\n\t    && is_drag == mouse_table[i].is_drag)\n\t{\n#ifdef FEAT_GUI\n\t    \/\/ Trick: a non mappable left click and release has mouse_col -1\n\t    \/\/ or added MOUSE_COLOFF.  Used for 'mousefocus' in\n\t    \/\/ gui_mouse_moved()\n\t    if (mouse_col < 0 || mouse_col > MOUSE_COLOFF)\n\t    {\n\t\tif (mouse_col < 0)\n\t\t    mouse_col = 0;\n\t\telse\n\t\t    mouse_col -= MOUSE_COLOFF;\n\t\tif (mouse_table[i].pseudo_code == (int)KE_LEFTMOUSE)\n\t\t    return (int)KE_LEFTMOUSE_NM;\n\t\tif (mouse_table[i].pseudo_code == (int)KE_LEFTRELEASE)\n\t\t    return (int)KE_LEFTRELEASE_NM;\n\t    }\n#endif\n\t    return mouse_table[i].pseudo_code;\n\t}\n    return (int)KE_IGNORE;\t    \/\/ not recognized, ignore it\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":383352,"func":"gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)\n{\n\tif( (s%360)==(e%360) ){\n\t\tgdImageEllipse(im, cx, cy, w, h, color);\n\t} else {\n\t\tgdImageFilledArc (im, cx, cy, w, h, s, e, color, gdNoFill);\n\t}\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":473823,"func":"gb18030_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED, OnigEncoding enc ARG_UNUSED)\n{\n  return GB18030_MAP[*s] == C1 ? TRUE : FALSE;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":430423,"func":"static int validate_and_copy_clone(struct net *net,\n\t\t\t\t   const struct nlattr *attr,\n\t\t\t\t   const struct sw_flow_key *key,\n\t\t\t\t   struct sw_flow_actions **sfa,\n\t\t\t\t   __be16 eth_type, __be16 vlan_tci,\n\t\t\t\t   u32 mpls_label_count, bool log, bool last)\n{\n\tint start, err;\n\tu32 exec;\n\n\tif (nla_len(attr) && nla_len(attr) < NLA_HDRLEN)\n\t\treturn -EINVAL;\n\n\tstart = add_nested_action_start(sfa, OVS_ACTION_ATTR_CLONE, log);\n\tif (start < 0)\n\t\treturn start;\n\n\texec = last || !actions_may_change_flow(attr);\n\n\terr = ovs_nla_add_action(sfa, OVS_CLONE_ATTR_EXEC, &exec,\n\t\t\t\t sizeof(exec), log);\n\tif (err)\n\t\treturn err;\n\n\terr = __ovs_nla_copy_actions(net, attr, key, sfa,\n\t\t\t\t     eth_type, vlan_tci, mpls_label_count, log);\n\tif (err)\n\t\treturn err;\n\n\tadd_nested_action_end(*sfa, start);\n\n\treturn 0;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":336691,"func":"SPICE_GNUC_VISIBLE int spice_server_migrate_start(SpiceServer *reds)\n{\n    spice_debug(\"trace\");\n    if (!reds->config->mig_spice) {\n        return -1;\n    }\n    return 0;\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":317186,"func":"static int selinux_bpf_map(struct bpf_map *map, fmode_t fmode)\n{\n\tu32 sid = current_sid();\n\tstruct bpf_security_struct *bpfsec;\n\n\tbpfsec = map->security;\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    sid, bpfsec->sid, SECCLASS_BPF,\n\t\t\t    bpf_map_fmode_to_av(fmode), NULL);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":513298,"func":"bool dbug_user_var_equals_int(THD *thd, const char *name, int value)\n{\n  user_var_entry *var;\n  LEX_STRING varname= {(char*)name, strlen(name)};\n  if ((var= get_variable(&thd->user_vars, varname, FALSE)))\n  {\n    bool null_value;\n    longlong var_value= var->val_int(&null_value);\n    if (!null_value && var_value == value)\n      return TRUE;\n  }\n  return FALSE;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":261430,"func":"const char* part_mode_name(enum PartMode pm)\n{\n  switch (pm) {\n  case PART_2Nx2N: return \"2Nx2N\";\n  case PART_2NxN:  return \"2NxN\";\n  case PART_Nx2N:  return \"Nx2N\";\n  case PART_NxN:   return \"NxN\";\n  case PART_2NxnU: return \"2NxnU\";\n  case PART_2NxnD: return \"2NxnD\";\n  case PART_nLx2N: return \"nLx2N\";\n  case PART_nRx2N: return \"nRx2N\";\n  }\n\n  return \"undefined part mode\";\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":292169,"func":"void CallInfo::set_handle(Klass* resolved_klass,\n                          const methodHandle& resolved_method,\n                          Handle resolved_appendix,\n                          Handle resolved_method_type, TRAPS) {\n  if (resolved_method.is_null()) {\n    THROW_MSG(vmSymbols::java_lang_InternalError(), \"resolved method is null\");\n  }\n  assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic ||\n         resolved_method->is_compiled_lambda_form(),\n         \"linkMethod must return one of these\");\n  int vtable_index = Method::nonvirtual_vtable_index;\n  assert(!resolved_method->has_vtable_index(), \"\");\n  set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);\n  _resolved_appendix    = resolved_appendix;\n  _resolved_method_type = resolved_method_type;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":294606,"func":"date_to_datetime(VALUE self)\n{\n    get_d1a(self);\n\n    if (simple_dat_p(adat)) {\n\tVALUE new = d_lite_s_alloc_simple(cDateTime);\n\t{\n\t    get_d1b(new);\n\t    bdat->s = adat->s;\n\t    return new;\n\t}\n    }\n    else {\n\tVALUE new = d_lite_s_alloc_complex(cDateTime);\n\t{\n\t    get_d1b(new);\n\t    bdat->c = adat->c;\n\t    bdat->c.df = 0;\n\t    RB_OBJ_WRITE(new, &bdat->c.sf, INT2FIX(0));\n#ifndef USE_PACK\n\t    bdat->c.hour = 0;\n\t    bdat->c.min = 0;\n\t    bdat->c.sec = 0;\n#else\n\t    bdat->c.pc = PACK5(EX_MON(adat->c.pc), EX_MDAY(adat->c.pc),\n\t\t\t       0, 0, 0);\n\t    bdat->c.flags |= HAVE_DF | HAVE_TIME;\n#endif\n\t    return new;\n\t}\n    }\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":90135,"func":"  virtual CellularNetwork* FindCellularNetworkByPath(\n      const std::string& path) { return NULL; }\n","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":282853,"func":"static int rsi_mgmt_pkt_to_core(struct rsi_common *common,\n\t\t\t\tu8 *msg,\n\t\t\t\ts32 msg_len)\n{\n\tstruct rsi_hw *adapter = common->priv;\n\tstruct ieee80211_tx_info *info;\n\tstruct skb_info *rx_params;\n\tu8 pad_bytes = msg[4];\n\tstruct sk_buff *skb;\n\n\tif (!adapter->sc_nvifs)\n\t\treturn -ENOLINK;\n\n\tmsg_len -= pad_bytes;\n\tif (msg_len <= 0) {\n\t\trsi_dbg(MGMT_RX_ZONE,\n\t\t\t\"%s: Invalid rx msg of len = %d\\n\",\n\t\t\t__func__, msg_len);\n\t\treturn -EINVAL;\n\t}\n\n\tskb = dev_alloc_skb(msg_len);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\n\tskb_put_data(skb,\n\t\t     (u8 *)(msg + FRAME_DESC_SZ + pad_bytes),\n\t\t     msg_len);\n\n\tinfo = IEEE80211_SKB_CB(skb);\n\trx_params = (struct skb_info *)info->driver_data;\n\trx_params->rssi = rsi_get_rssi(msg);\n\trx_params->channel = rsi_get_channel(msg);\n\trsi_indicate_pkt_to_os(common, skb);\n\n\treturn 0;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":336536,"func":"static void reds_accept(int fd, int event, void *data)\n{\n    RedsState *reds = (RedsState*) data;\n    int socket;\n\n    if ((socket = accept(fd, NULL, 0)) == -1) {\n        spice_warning(\"accept failed, %s\", strerror(errno));\n        return;\n    }\n\n    if (spice_server_add_client(reds, socket, 0) < 0) {\n        socket_close(socket);\n    }\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":462406,"func":"\tfor(i = 0 ; i < modpblk.nParams ; ++i) {\n\t\tif(!pvals[i].bUsed)\n\t\t\tcontinue;\n\t\tif(!strcmp(modpblk.descr[i].name, \"threads\")) {\n\t\t\tloadModConf->wrkrMax = (int) pvals[i].val.d.n;\n\t\t} else if(!strcmp(modpblk.descr[i].name, \"processOnPoller\")) {\n\t\t\tloadModConf->bProcessOnPoller = (int) pvals[i].val.d.n;\n\t\t} else {\n\t\t\tdbgprintf(\"imptcp: program error, non-handled \"\n\t\t\t  \"param '%s' in beginCnfLoad\\n\", modpblk.descr[i].name);\n\t\t}\n\t}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":427189,"func":"static void fixforjump (FuncState *fs, int pc, int dest, int back) {\n  Instruction *jmp = &fs->f->code[pc];\n  int offset = dest - (pc + 1);\n  if (back)\n    offset = -offset;\n  if (l_unlikely(offset > MAXARG_Bx))\n    luaX_syntaxerror(fs->ls, \"control structure too long\");\n  SETARG_Bx(*jmp, offset);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":421378,"func":"void jsP_dumpsyntax(js_State *J, js_Ast *prog, int dominify)\n{\n\tminify = dominify;\n\tif (prog) {\n\t\tif (prog->type == AST_LIST)\n\t\t\tpstmlist(-1, prog);\n\t\telse {\n\t\t\tpstm(0, prog);\n\t\t\tnl();\n\t\t}\n\t}\n\tif (minify > 1)\n\t\tputchar('\\n');\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":317090,"func":"static int __init selinux_enabled_setup(char *str)\n{\n\tunsigned long enabled;\n\tif (!kstrtoul(str, 0, &enabled))\n\t\tselinux_enabled_boot = enabled ? 1 : 0;\n\treturn 1;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":317158,"func":"static int selinux_task_getscheduler(struct task_struct *p)\n{\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    current_sid(), task_sid_obj(p), SECCLASS_PROCESS,\n\t\t\t    PROCESS__GETSCHED, NULL);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":344798,"func":"strdelimw(char **s)\n{\n\treturn strdelim_internal(s, 0);\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":328890,"func":"R_API RBinJavaObj *r_bin_java_new_buf(RBuffer *buf, ut64 loadaddr, Sdb *kv) {\n\tRBinJavaObj *bin = R_NEW0 (RBinJavaObj);\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\tut64 tmpsz;\n\tconst ut8 *tmp = r_buf_data (buf, &tmpsz);\n\tif (!r_bin_java_new_bin (bin, loadaddr, kv, tmp, tmpsz)) {\n\t\treturn r_bin_java_free (bin);\n\t}\n\treturn bin;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":224185,"func":"  explicit MapStageOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":289292,"func":"static int snd_interval_refine_set(struct snd_interval *i, unsigned int val)\n{\n\tstruct snd_interval t;\n\tt.empty = 0;\n\tt.min = t.max = val;\n\tt.openmin = t.openmax = 0;\n\tt.integer = 1;\n\treturn snd_interval_refine(i, &t);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":365614,"func":"_asn1_add_static_node (unsigned int type)\n{\n  list_type *listElement;\n  asn1_node punt;\n\n  punt = calloc (1, sizeof (struct asn1_node_st));\n  if (punt == NULL)\n    return NULL;\n\n  listElement = malloc (sizeof (list_type));\n  if (listElement == NULL)\n    {\n      free (punt);\n      return NULL;\n    }\n\n  listElement->node = punt;\n  listElement->next = firstElement;\n  firstElement = listElement;\n\n  punt->type = type;\n\n  return punt;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":384895,"func":"vim_fnamencmp(char_u *x, char_u *y, size_t len)\n{\n#ifdef BACKSLASH_IN_FILENAME\n    char_u\t*px = x;\n    char_u\t*py = y;\n    int\t\tcx = NUL;\n    int\t\tcy = NUL;\n\n    while (len > 0)\n    {\n\tcx = PTR2CHAR(px);\n\tcy = PTR2CHAR(py);\n\tif (cx == NUL || cy == NUL\n\t    || ((p_fic ? MB_TOLOWER(cx) != MB_TOLOWER(cy) : cx != cy)\n\t\t&& !(cx == '\/' && cy == '\\\\')\n\t\t&& !(cx == '\\\\' && cy == '\/')))\n\t    break;\n\tlen -= mb_ptr2len(px);\n\tpx += mb_ptr2len(px);\n\tpy += mb_ptr2len(py);\n    }\n    if (len == 0)\n\treturn 0;\n    return (cx - cy);\n#else\n    if (p_fic)\n\treturn MB_STRNICMP(x, y, len);\n    return STRNCMP(x, y, len);\n#endif\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":427795,"func":"static void sev_clflush_pages(struct page *pages[], unsigned long npages)\n{\n\tuint8_t *page_virtual;\n\tunsigned long i;\n\n\tif (this_cpu_has(X86_FEATURE_SME_COHERENT) || npages == 0 ||\n\t    pages == NULL)\n\t\treturn;\n\n\tfor (i = 0; i < npages; i++) {\n\t\tpage_virtual = kmap_atomic(pages[i]);\n\t\tclflush_cache_range(page_virtual, PAGE_SIZE);\n\t\tkunmap_atomic(page_virtual);\n\t}\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":338133,"func":"void WasmBinaryBuilder::visitLocalSet(LocalSet* curr, uint8_t code) {\n  BYN_TRACE(\"zz node: Set|LocalTee\\n\");\n  requireFunctionContext(\"local.set outside of function\");\n  curr->index = getAbsoluteLocalIndex(getU32LEB());\n  if (curr->index >= currFunction->getNumLocals()) {\n    throwError(\"bad local.set index\");\n  }\n  curr->value = popNonVoidExpression();\n  if (code == BinaryConsts::LocalTee) {\n    curr->makeTee(currFunction->getLocalType(curr->index));\n  } else {\n    curr->makeSet();\n  }\n  curr->finalize();\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":498106,"func":"void cgit_stats_link(const char *name, const char *title, const char *class,\n\t\t     const char *head, const char *path)\n{\n\treporevlink(\"stats\", name, title, class, head, NULL, path);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":333058,"func":"nfa_save_listids(nfa_regprog_T *prog, int *list)\n{\n    int\t\t    i;\n    nfa_state_T\t    *p;\n\n    \/\/ Order in the list is reverse, it's a bit faster that way.\n    p = &prog->state[0];\n    for (i = prog->nstate; --i >= 0; )\n    {\n\tlist[i] = p->lastlist[1];\n\tp->lastlist[1] = 0;\n\t++p;\n    }\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":240295,"func":"set_execreg_lastc(int lastc)\n{\n    execreg_lastc = lastc;\n}","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":226311,"func":"\nvoid trep_box_del(GF_Box *s)\n{\n\tGF_TrackExtensionPropertiesBox *ptr = (GF_TrackExtensionPropertiesBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":291769,"func":"static int alloc_permits(struct rtrs_clt_sess *clt)\n{\n\tunsigned int chunk_bits;\n\tint err, i;\n\n\tclt->permits_map = kcalloc(BITS_TO_LONGS(clt->queue_depth),\n\t\t\t\t   sizeof(long), GFP_KERNEL);\n\tif (!clt->permits_map) {\n\t\terr = -ENOMEM;\n\t\tgoto out_err;\n\t}\n\tclt->permits = kcalloc(clt->queue_depth, permit_size(clt), GFP_KERNEL);\n\tif (!clt->permits) {\n\t\terr = -ENOMEM;\n\t\tgoto err_map;\n\t}\n\tchunk_bits = ilog2(clt->queue_depth - 1) + 1;\n\tfor (i = 0; i < clt->queue_depth; i++) {\n\t\tstruct rtrs_permit *permit;\n\n\t\tpermit = get_permit(clt, i);\n\t\tpermit->mem_id = i;\n\t\tpermit->mem_off = i << (MAX_IMM_PAYL_BITS - chunk_bits);\n\t}\n\n\treturn 0;\n\nerr_map:\n\tkfree(clt->permits_map);\n\tclt->permits_map = NULL;\nout_err:\n\treturn err;\n}","target":0,"code_token_length":240,"total_token_length":476,"max_tokens_setting":512}
+{"idx":395091,"func":"update_finish(void)\n{\n    if (redraw_cmdline || redraw_mode)\n\tshowmode();\n\n# ifdef FEAT_SEARCH_EXTRA\n    end_search_hl();\n# endif\n\n    after_updating_screen(TRUE);\n\n# ifdef FEAT_GUI\n    \/\/ Redraw the cursor and update the scrollbars when all screen updating is\n    \/\/ done.\n    if (gui.in_use)\n    {\n\tout_flush_cursor(FALSE, FALSE);\n\tgui_update_scrollbars(FALSE);\n    }\n# endif\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":256163,"func":"void do_on_all_threads(const DeviceBase::CpuWorkerThreads* thread_pool,\n                       const F& f) {\n  int num_threads = thread_pool->num_threads;\n  if (num_threads == 0) {\n    LOG(FATAL) << \"Have 0 threads in thread pool\";\n  } else if (num_threads == 1) {\n    f(0);\n  } else {\n    BlockingCounter counter(num_threads - 1);\n    for (int i = 1; i < num_threads; ++i) {\n      thread_pool->workers->Schedule([&, i]() {\n        f(i);\n        counter.DecrementCount();\n      });\n    }\n    f(0);\n    counter.Wait();\n  }\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":359417,"func":"DEFUN (bgp_confederation_peers,\n       bgp_confederation_peers_cmd,\n       \"bgp confederation peers .<1-65535>\",\n       \"BGP specific commands\\n\"\n       \"AS confederation parameters\\n\"\n       \"Peer ASs in BGP confederation\\n\"\n       AS_STR)\n{\n  struct bgp *bgp;\n  as_t as;\n  int i;\n\n  bgp = vty->index;\n\n  for (i = 0; i < argc; i++)\n    {\n      VTY_GET_INTEGER_RANGE (\"AS\", as, argv[i], 1, 65535);\n\n      if (bgp->as == as)\n\t{\n\t  vty_out (vty, \"%% Local member-AS not allowed in confed peer list%s\",\n\t\t   VTY_NEWLINE);\n\t  continue;\n\t}\n\n      bgp_confederation_peers_add (bgp, as);\n    }\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":259220,"func":"static int can_seek_to_key_sample(AVStream *st, int sample, int64_t requested_pts)\n{\n    MOVStreamContext *sc = st->priv_data;\n    FFStream *const sti = ffstream(st);\n    int64_t key_sample_dts, key_sample_pts;\n\n    if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)\n        return 1;\n\n    if (sample >= sc->sample_offsets_count)\n        return 1;\n\n    key_sample_dts = sti->index_entries[sample].timestamp;\n    key_sample_pts = key_sample_dts + sc->sample_offsets[sample] + sc->dts_shift;\n\n    \/*\n     * If the sample needs to be presented before an open key sample, they may\n     * not be decodable properly, even though they come after in decoding\n     * order.\n     *\/\n    if (is_open_key_sample(sc, sample) && key_sample_pts > requested_pts)\n        return 0;\n\n    return 1;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":210620,"func":"static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev)\n{\n\tstruct virtproc_info *vrp = vdev->priv;\n\tstruct virtio_rpmsg_channel *vch;\n\tstruct rpmsg_device *rpdev_ctrl;\n\tint err = 0;\n\n\tvch = kzalloc(sizeof(*vch), GFP_KERNEL);\n\tif (!vch)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\t\/* Link the channel to the vrp *\/\n\tvch->vrp = vrp;\n\n\t\/* Assign public information to the rpmsg_device *\/\n\trpdev_ctrl = &vch->rpdev;\n\trpdev_ctrl->ops = &virtio_rpmsg_ops;\n\n\trpdev_ctrl->dev.parent = &vrp->vdev->dev;\n\trpdev_ctrl->dev.release = virtio_rpmsg_release_device;\n\trpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev);\n\n\terr = rpmsg_ctrldev_register_device(rpdev_ctrl);\n\tif (err) {\n\t\tkfree(vch);\n\t\treturn ERR_PTR(err);\n\t}\n\n\treturn rpdev_ctrl;\n}","target":1,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":225823,"func":"\nvoid fpar_box_del(GF_Box *s)\n{\n\tFilePartitionBox *ptr = (FilePartitionBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->scheme_specific_info) gf_free(ptr->scheme_specific_info);\n\tif (ptr->entries) gf_free(ptr->entries);\n\tgf_free(ptr);","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":513286,"func":"Field *Item::create_field_for_schema(THD *thd, TABLE *table)\n{\n  if (field_type() == MYSQL_TYPE_VARCHAR)\n  {\n    Field *field;\n    if (max_length > MAX_FIELD_VARCHARLENGTH)\n      field= new Field_blob(max_length, maybe_null, name, collation.collation);\n    else\n      field= new Field_varstring(max_length, maybe_null, name,\n                                 table->s, collation.collation);\n    if (field)\n      field->init(table);\n    return field;\n  }\n  return tmp_table_field_from_field_type(table, false, false);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":427802,"func":"static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp)\n{\n\tstruct kvm_vcpu *vcpu;\n\tint i, ret;\n\n\tif (!sev_es_guest(kvm))\n\t\treturn -ENOTTY;\n\n\tkvm_for_each_vcpu(i, vcpu, kvm) {\n\t\tret = mutex_lock_killable(&vcpu->mutex);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tret = __sev_launch_update_vmsa(kvm, vcpu, &argp->error);\n\n\t\tmutex_unlock(&vcpu->mutex);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":225388,"func":"static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *_std)\n{\n\tv4l2_std_id req_std = 0, supported_std = 0;\n\tconst v4l2_std_id all_std = V4L2_STD_ALL, no_std = 0;\n\n\tif (_std) {\n\t\treq_std = *_std;\n\t\t*_std = all_std;\n\t}\n\n\t\/* we support everything in V4L2_STD_ALL, but not more... *\/\n\tsupported_std = (all_std & req_std);\n\tif (no_std == supported_std)\n\t\treturn -EINVAL;\n\n\treturn 0;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":230393,"func":"PJ_DEF(pj_xml_node*) pj_xml_find_rec( const pj_xml_node *parent, \n\t\t\t\t      const pj_str_t *name,\n\t\t\t\t      const void *data, \n\t\t\t\t      pj_bool_t (*match)(const pj_xml_node*, \n\t\t\t\t\t\t\t const void*))\n{\n    const pj_xml_node *node = (const pj_xml_node *)parent->node_head.next;\n\n    if (!name && !match)\n\treturn NULL;\n\n    while (node != (const pj_xml_node*) &parent->node_head) {\n\tpj_xml_node *found;\n\n\tif (name) {\n\t    if (pj_stricmp(&node->name, name)==0) {\n\t\tif (match) {\n\t\t    if (match(node, data))\n\t\t\treturn (pj_xml_node*)node;\n\t\t} else {\n\t\t    return (pj_xml_node*)node;\n\t\t}\n\t    }\n\n\t} else if (match) {\n\t    if (match(node, data))\n\t\treturn (pj_xml_node*)node;\n\t}\n\n\tfound = pj_xml_find_rec(node, name, data, match);\n\tif (found)\n\t    return found;\n\n\tnode = node->next;\n    }\n    return NULL;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":328945,"func":"R_API void r_bin_java_get_field_json_definition(RBinJavaObj *bin, RBinJavaField *fm_type, PJ *pj) {\n\tr_bin_java_get_fm_type_definition_json (bin, fm_type, pj, 0);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":270115,"func":"inline TfLiteStatus Quantize(TfLiteContext* context, float scale,\n                             int32_t zero_point, float f, int32_t& q) {\n  const float tmp = TfLiteRound(f \/ scale);\n  const bool no_integer_overflow_from_quantization =\n      (tmp >= static_cast<float>(std::numeric_limits<int32_t>::min()) &&\n       tmp <= static_cast<float>(std::numeric_limits<int32_t>::max()));\n  TF_LITE_ENSURE(context, no_integer_overflow_from_quantization);\n  q = zero_point + static_cast<int32_t>(tmp);\n  return kTfLiteOk;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":454746,"func":"static void ismt_remove(struct pci_dev *pdev)\n{\n\tstruct ismt_priv *priv = pci_get_drvdata(pdev);\n\n\ti2c_del_adapter(&priv->adapter);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":222514,"func":"std::vector<string> FunctionLibraryDefinition::ListFunctionNames() const {\n  std::vector<string> function_names;\n  tf_shared_lock l(mu_);\n  function_names.reserve(function_defs_.size());\n  for (const auto& it : function_defs_) {\n    function_names.emplace_back(it.first);\n  }\n  return function_names;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":294534,"func":"d_lite_prev_year(int argc, VALUE *argv, VALUE self)\n{\n    VALUE n;\n\n    rb_scan_args(argc, argv, \"01\", &n);\n    if (argc < 1)\n\tn = INT2FIX(1);\n    return d_lite_lshift(self, f_mul(n, INT2FIX(12)));\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":500639,"func":"static sftp_ext sftp_ext_new(void) {\n  sftp_ext ext;\n\n  ext = malloc(sizeof(struct sftp_ext_struct));\n  if (ext == NULL) {\n    return NULL;\n  }\n  ZERO_STRUCTP(ext);\n\n  return ext;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":225601,"func":"GF_Err audio_sample_entry_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_MPEGAudioSampleEntryBox *ptr = (GF_MPEGAudioSampleEntryBox *)s;\n\tgf_isom_audio_sample_entry_size((GF_AudioSampleEntryBox*)s);\n\tif (ptr->qtff_mode)\n\t\treturn GF_OK;\n\n\tgf_isom_check_position(s, (GF_Box *)ptr->esd, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->cfg_3gpp, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->cfg_opus, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->cfg_ac3, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->cfg_flac, &pos);\n\tgf_isom_check_position(s, (GF_Box *)ptr->cfg_mlp, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":509560,"func":"int ha_maria::rename_table(const char *from, const char *to)\n{\n  THD *thd= current_thd;\n  (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY,\n                                 (uchar*) thd->query(), thd->query_length());\n  return maria_rename(from, to);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":344238,"func":"l_sinline int LTnum (const TValue *l, const TValue *r) {\n  lua_assert(ttisnumber(l) && ttisnumber(r));\n  if (ttisinteger(l)) {\n    lua_Integer li = ivalue(l);\n    if (ttisinteger(r))\n      return li < ivalue(r);  \/* both are integers *\/\n    else  \/* 'l' is int and 'r' is float *\/\n      return LTintfloat(li, fltvalue(r));  \/* l < r ? *\/\n  }\n  else {\n    lua_Number lf = fltvalue(l);  \/* 'l' must be float *\/\n    if (ttisfloat(r))\n      return luai_numlt(lf, fltvalue(r));  \/* both are float *\/\n    else  \/* 'l' is float and 'r' is int *\/\n      return LTfloatint(lf, ivalue(r));\n  }\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":336520,"func":"static RedsMigTargetClient* reds_mig_target_client_find(RedsState *reds, RedClient *client)\n{\n    GList *l;\n\n    for (l = reds->mig_target_clients; l != NULL; l = l->next) {\n        RedsMigTargetClient *mig_client = (RedsMigTargetClient*) l->data;\n\n        if (mig_client->client == client) {\n            return mig_client;\n        }\n    }\n    return NULL;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":512888,"func":"bool Item_func_in::list_contains_null()\n{\n  Item **arg,**arg_end;\n  for (arg= args + 1, arg_end= args+arg_count; arg != arg_end ; arg++)\n  {\n    if ((*arg)->null_inside())\n      return 1;\n  }\n  return 0;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":319421,"func":"static inline MagickBooleanType IsFloatDefined(const float value)\n{\n  union\n  {\n    unsigned int\n      unsigned_value;\n\n    double\n      float_value;\n  } quantum;\n\n  quantum.unsigned_value=0U;\n  quantum.float_value=value;\n  if (quantum.unsigned_value == 0U)\n    return(MagickFalse);\n  return(MagickTrue);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":513205,"func":"static int item_val_int(struct st_mysql_value *value, long long *buf)\n{\n  Item *item= ((st_item_value_holder*)value)->item;\n  *buf= item->val_int();\n  if (item->is_null())\n    return 1;\n  return 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":513005,"func":"  bool fix_fields_if_needed_for_bool(THD *thd, Item **ref)\n  {\n    return fix_fields_if_needed_for_scalar(thd, ref);\n  }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":240275,"func":"getreg_wrap_one_line(char_u *s, int flags)\n{\n    if (flags & GREG_LIST)\n    {\n\tlist_T *list = list_alloc();\n\n\tif (list != NULL)\n\t{\n\t    if (list_append_string(list, NULL, -1) == FAIL)\n\t    {\n\t\tlist_free(list);\n\t\treturn NULL;\n\t    }\n\t    list->lv_first->li_tv.vval.v_string = s;\n\t}\n\treturn (char_u *)list;\n    }\n    return s;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":312542,"func":"ex_cclose(exarg_T *eap)\n{\n    win_T\t*win = NULL;\n    qf_info_T\t*qi;\n\n    if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL)\n\treturn;\n\n    \/\/ Find existing quickfix window and close it.\n    win = qf_find_win(qi);\n    if (win != NULL)\n\twin_close(win, FALSE);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":246494,"func":"static bool append_rets(RStrBuf *sb, RBinWasmTypeVec *rets) {\n\tbool ret = true;\n\tif (!rets->count) {\n\t\tret &= r_strbuf_append (sb, \"nil\");\n\t} else if (rets->count == 1) {\n\t\tret &= r_strbuf_append (sb, r_bin_wasm_valuetype_to_string (rets->types[0]));\n\t} else {\n\t\tret &= strbuf_append_type_vec (sb, rets);\n\t}\n\treturn ret;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":313847,"func":"nv_Undo(cmdarg_T *cap)\n{\n    \/\/ In Visual mode and typing \"gUU\" triggers an operator\n    if (cap->oap->op_type == OP_UPPER || VIsual_active)\n    {\n\t\/\/ translate \"gUU\" to \"gUgU\"\n\tcap->cmdchar = 'g';\n\tcap->nchar = 'U';\n\tnv_operator(cap);\n    }\n    else if (!checkclearopq(cap->oap))\n    {\n\tu_undoline();\n\tcurwin->w_set_curswant = TRUE;\n    }\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":516253,"func":"static void failover_add_primary(VirtIONet *n, Error **errp)\n{\n    Error *err = NULL;\n    QemuOpts *opts;\n    char *id;\n    DeviceState *dev = failover_find_primary_device(n);\n\n    if (dev) {\n        return;\n    }\n\n    id = failover_find_primary_device_id(n);\n    if (!id) {\n        error_setg(errp, \"Primary device not found\");\n        error_append_hint(errp, \"Virtio-net failover will not work. Make \"\n                          \"sure primary device has parameter\"\n                          \" failover_pair_id=%s\\n\", n->netclient_name);\n        return;\n    }\n    opts = qemu_opts_find(qemu_find_opts(\"device\"), id);\n    g_assert(opts); \/* cannot be NULL because id was found using opts list *\/\n    dev = qdev_device_add(opts, &err);\n    if (err) {\n        qemu_opts_del(opts);\n    } else {\n        object_unref(OBJECT(dev));\n    }\n    error_propagate(errp, err);\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":276902,"func":"static uint get_alen(char *arg, uint default_len)\n{\n\tuint\tj;\n\tuint\talen;\n\n\talen = default_len;\n\tfor (j = 0; j < 8; j++) {\n\t\tif (arg[j] == '.') {\n\t\t\talen = arg[j+1] - '0';\n\t\t\tbreak;\n\t\t} else if (arg[j] == '\\0')\n\t\t\tbreak;\n\t}\n\treturn alen;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":417133,"func":"void PlayerGeneric::setPatternPos(mp_uint32 pos, mp_uint32 row\/* = 0*\/, bool resetChannels\/* = true*\/, bool resetFXMemory\/* = true*\/)\n{\n\tif (player)\n\t\tplayer->setPatternPos(pos, row, resetChannels, resetFXMemory);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":276972,"func":"SampleEncrypter::Create(const AP4_UI08* key, const AP4_UI08* iv, SampleEncrypter*& encrypter) {\n    encrypter = NULL;\n    AP4_BlockCipher* block_cipher = NULL;\n    AP4_Result result = AP4_DefaultBlockCipherFactory::Instance.CreateCipher(AP4_BlockCipher::AES_128,\n                                                                             AP4_BlockCipher::ENCRYPT,\n                                                                             AP4_BlockCipher::CBC,\n                                                                             NULL,\n                                                                             key,\n                                                                             16,\n                                                                             block_cipher);\n    if (AP4_FAILED(result)) return result;\n    AP4_CbcStreamCipher* stream_cipher = new AP4_CbcStreamCipher(block_cipher);\n    encrypter = new SampleEncrypter(stream_cipher, iv);\n    \n    return AP4_SUCCESS;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":314468,"func":"static bool FNAME(gpte_changed)(struct kvm_vcpu *vcpu,\n\t\t\t\tstruct guest_walker *gw, int level)\n{\n\tpt_element_t curr_pte;\n\tgpa_t base_gpa, pte_gpa = gw->pte_gpa[level - 1];\n\tu64 mask;\n\tint r, index;\n\n\tif (level == PG_LEVEL_4K) {\n\t\tmask = PTE_PREFETCH_NUM * sizeof(pt_element_t) - 1;\n\t\tbase_gpa = pte_gpa & ~mask;\n\t\tindex = (pte_gpa - base_gpa) \/ sizeof(pt_element_t);\n\n\t\tr = kvm_vcpu_read_guest_atomic(vcpu, base_gpa,\n\t\t\t\tgw->prefetch_ptes, sizeof(gw->prefetch_ptes));\n\t\tcurr_pte = gw->prefetch_ptes[index];\n\t} else\n\t\tr = kvm_vcpu_read_guest_atomic(vcpu, pte_gpa,\n\t\t\t\t  &curr_pte, sizeof(curr_pte));\n\n\treturn r || curr_pte != gw->ptes[level - 1];\n}","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":275939,"func":"uECC_VLI_API void uECC_vli_bytesToNative(uECC_word_t *native,\n                                         const uint8_t *bytes,\n                                         int num_bytes) {\n    wordcount_t i;\n    uECC_vli_clear(native, (num_bytes + (uECC_WORD_SIZE - 1)) \/ uECC_WORD_SIZE);\n    for (i = 0; i < num_bytes; ++i) {\n        unsigned b = num_bytes - 1 - i;\n        native[b \/ uECC_WORD_SIZE] |=\n            (uECC_word_t)bytes[i] << (8 * (b % uECC_WORD_SIZE));\n    }\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":512713,"func":"  const Type_handler *type_handler() const\n  {\n    return Type_handler::blob_type_handler(max_length);\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":307832,"func":"ciInstance* ciEnv::the_min_jint_string() {\n  if (_the_min_jint_string == NULL) {\n    VM_ENTRY_MARK;\n    _the_min_jint_string = get_object(Universe::the_min_jint_string())->as_instance();\n  }\n  return _the_min_jint_string;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":318972,"func":"f_test_void(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    rettv->v_type = VAR_VOID;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":413855,"func":"Method* LinkResolver::resolve_static_call_or_null(const LinkInfo& link_info) {\n  EXCEPTION_MARK;\n  CallInfo info;\n  resolve_static_call(info, link_info, \/*initialize_class*\/false, THREAD);\n  if (HAS_PENDING_EXCEPTION) {\n    CLEAR_PENDING_EXCEPTION;\n    return NULL;\n  }\n  return info.selected_method();\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":401538,"func":"static void numa_crng_init(void) {}","target":0,"code_token_length":9,"total_token_length":245,"max_tokens_setting":512}
+{"idx":226288,"func":"GF_Err drep_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_DREPBox *ptr = (GF_DREPBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u64(bs, ptr->nbBytes);\n\treturn GF_OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":482647,"func":"static inline const char *xt_inname(const struct xt_action_param *par)\n{\n\treturn par->state->in->name;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":359563,"func":"zlog_set_file (struct zlog *zl, const char *filename, int log_level)\n{\n  FILE *fp;\n  mode_t oldumask;\n\n  \/* There is opend file.  *\/\n  zlog_reset_file (zl);\n\n  \/* Set default zl. *\/\n  if (zl == NULL)\n    zl = zlog_default;\n\n  \/* Open file. *\/\n  oldumask = umask (0777 & ~LOGFILE_MASK);\n  fp = fopen (filename, \"a\");\n  umask(oldumask);\n  if (fp == NULL)\n    return 0;\n\n  \/* Set flags. *\/\n  zl->filename = strdup (filename);\n  zl->maxlvl[ZLOG_DEST_FILE] = log_level;\n  zl->fp = fp;\n  logfile_fd = fileno(fp);\n\n  return 1;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":233888,"func":" *\/\nPS_SERIALIZER_DECODE_FUNC(wddx)\n{\n\tzval retval;\n\tzval *ent;\n\tzend_string *key;\n\tzend_ulong idx;\n\tint ret;\n\n\tif (vallen == 0) {\n\t\treturn SUCCESS;\n\t}\n\n\tZVAL_UNDEF(&retval);\n\tif ((ret = php_wddx_deserialize_ex(val, vallen, &retval)) == SUCCESS) {\n\t\tif (Z_TYPE(retval) != IS_ARRAY) {\n\t\t\tzval_dtor(&retval);\n\t\t\treturn FAILURE;\n\t\t}\n\t\tZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(retval), idx, key, ent) {\n\t\t\tif (key == NULL) {\n\t\t\t\tkey = zend_long_to_str(idx);\n\t\t\t} else {\n\t\t\t\tzend_string_addref(key);\n\t\t\t}\n\t\t\tif (php_set_session_var(key, ent, NULL)) {\n\t\t\t\tif (Z_REFCOUNTED_P(ent)) Z_ADDREF_P(ent);\n\t\t\t}\n\t\t\tPS_ADD_VAR(key);\n\t\t\tzend_string_release(key);\n\t\t} ZEND_HASH_FOREACH_END();\n\t}\n\n\tzval_ptr_dtor(&retval);\n\n\treturn ret;","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":427722,"func":"cdf_namecmp(const char *d, const uint16_t *s, size_t l)\n{\n\tfor (; l--; d++, s++)\n\t\tif (*d != CDF_TOLE2(*s))\n\t\t\treturn CAST(unsigned char, *d) - CDF_TOLE2(*s);\n\treturn 0;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":513036,"func":"  virtual longlong val_int_signed_typecast()\n  {\n    return cast_to_int_type_handler()->Item_val_int_signed_typecast(this);\n  }","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":387830,"func":"bool InstanceKlass::link_class_or_fail(TRAPS) {\n  assert(is_loaded(), \"must be loaded\");\n  if (!is_linked()) {\n    link_class_impl(false, CHECK_false);\n  }\n  return is_linked();\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":90163,"func":"    static void NetworkStatusChangedHandler(void* object,\n                                            const char* path,\n                                            const char* key,\n                                            const Value* value) {\n      NetworkLibraryImpl* networklib = static_cast<NetworkLibraryImpl*>(object);\n      DCHECK(networklib);\n      networklib->UpdateNetworkStatus(path, key, value);\n    }\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":379663,"func":"R_API RAnalVarAccess *r_anal_var_get_access_at(RAnalVar *var, ut64 addr) {\n\tr_return_val_if_fail (var, NULL);\n\tst64 offset = addr - var->fcn->addr;\n\tsize_t index;\n\tr_vector_lower_bound (&var->accesses, offset, index, ACCESS_CMP);\n\tif (index >= var->accesses.len) {\n\t\treturn NULL;\n\t}\n\tRAnalVarAccess *acc = r_vector_index_ptr (&var->accesses, index);\n\tif (acc->offset == offset) {\n\t\treturn acc;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":462235,"func":"static void* clone_msgint_attr(pj_pool_t *pool, const void *src)\n{\n    pj_stun_msgint_attr *dst = PJ_POOL_ALLOC_T(pool, pj_stun_msgint_attr);\n\n    pj_memcpy(dst, src, sizeof(pj_stun_msgint_attr));\n\n    return (void*) dst;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":474443,"func":"ObjectCreateHashSequence(\n\t\t\t TPMI_ALG_HASH    hashAlg,       \/\/ IN: hash algorithm\n\t\t\t TPM2B_AUTH      *auth,          \/\/ IN: authValue\n\t\t\t TPMI_DH_OBJECT  *newHandle      \/\/ OUT: sequence object handle\n\t\t\t )\n{\n    HASH_OBJECT         *hashObject = AllocateSequenceSlot(newHandle, auth);\n    \/\/ See if slot allocated\n    if(hashObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    \/\/ Set hash sequence bit\n    hashObject->attributes.hashSeq = SET;\n    \/\/ Start hash for hash sequence\n    CryptHashStart(&hashObject->state.hashState[0], hashAlg);\n    return TPM_RC_SUCCESS;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":369234,"func":"static bool need_read_all(struct io_kiocb *req)\n{\n\treturn req->flags & REQ_F_ISREG ||\n\t\tS_ISBLK(file_inode(req->file)->i_mode);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":503880,"func":"SCM_DEFINE (scm_close, \"close\", 1, 0, 0, \n            (SCM fd_or_port),\n\t    \"Similar to close-port (@pxref{Closing, close-port}),\\n\"\n\t    \"but also works on file descriptors.  A side\\n\"\n\t    \"effect of closing a file descriptor is that any ports using that file\\n\"\n\t    \"descriptor are moved to a different file descriptor and have\\n\"\n\t    \"their revealed counts set to zero.\")\n#define FUNC_NAME s_scm_close\n{\n  int rv;\n  int fd;\n\n  fd_or_port = SCM_COERCE_OUTPORT (fd_or_port);\n\n  if (SCM_PORTP (fd_or_port))\n    return scm_close_port (fd_or_port);\n  fd = scm_to_int (fd_or_port);\n  scm_evict_ports (fd);\t\t\/* see scsh manual.  *\/\n  SCM_SYSCALL (rv = close (fd));\n  \/* following scsh, closing an already closed file descriptor is\n     not an error.  *\/\n  if (rv < 0 && errno != EBADF)\n    SCM_SYSERROR;\n  return scm_from_bool (rv >= 0);\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":462577,"func":"void controller::enqueue_items(std::shared_ptr<rss_feed> feed) {\n\tif (!cfg.get_configvalue_as_bool(\"podcast-auto-enqueue\"))\n\t\treturn;\n\tstd::lock_guard<std::mutex> lock(feed->item_mutex);\n\tfor (auto item : feed->items()) {\n\t\tif (!item->enqueued() && item->enclosure_url().length() > 0) {\n\t\t\tLOG(level::DEBUG, \"controller::enqueue_items: enclosure_url = `%s' enclosure_type = `%s'\", item->enclosure_url(), item->enclosure_type());\n\t\t\tif (is_valid_podcast_type(item->enclosure_type()) && utils::is_http_url(item->enclosure_url())) {\n\t\t\t\tLOG(level::INFO, \"controller::enqueue_items: enqueuing `%s'\", item->enclosure_url());\n\t\t\t\tenqueue_url(item->enclosure_url(), feed);\n\t\t\t\titem->set_enqueued(true);\n\t\t\t\trsscache->update_rssitem_unread_and_enqueued(item, feed->rssurl());\n\t\t\t}\n\t\t}\n\t}\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":359199,"func":"BPF_CALL_2(bpf_ringbuf_query, struct bpf_map *, map, u64, flags)\n{\n\tstruct bpf_ringbuf *rb;\n\n\trb = container_of(map, struct bpf_ringbuf_map, map)->rb;\n\n\tswitch (flags) {\n\tcase BPF_RB_AVAIL_DATA:\n\t\treturn ringbuf_avail_data_sz(rb);\n\tcase BPF_RB_RING_SIZE:\n\t\treturn rb->mask + 1;\n\tcase BPF_RB_CONS_POS:\n\t\treturn smp_load_acquire(&rb->consumer_pos);\n\tcase BPF_RB_PROD_POS:\n\t\treturn smp_load_acquire(&rb->producer_pos);\n\tdefault:\n\t\treturn 0;\n\t}\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":246459,"func":"static size_t consume_s7_r(RBuffer *b, ut64 bound, st8 *out) {\n\tsize_t n = 0;\n\tut32 tmp = consume_r (b, bound, &n, (ConsumeFcn)read_i32_leb128);\n\tif (out) {\n\t\t*out = (st8) (((tmp & 0x10000000) << 7) | (tmp & 0x7f));\n\t}\n\treturn n;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":395088,"func":"status_redraw_curbuf(void)\n{\n    win_T\t*wp;\n\n    FOR_ALL_WINDOWS(wp)\n\tif (wp->w_status_height != 0 && wp->w_buffer == curbuf)\n\t{\n\t    wp->w_redr_status = TRUE;\n\t    redraw_later(VALID);\n\t}\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":395083,"func":"updateWindow(win_T *wp)\n{\n    \/\/ return if already busy updating\n    if (updating_screen)\n\treturn;\n\n    update_prepare();\n\n#ifdef FEAT_CLIPBOARD\n    \/\/ When Visual area changed, may have to update selection.\n    if (clip_star.available && clip_isautosel_star())\n\tclip_update_selection(&clip_star);\n    if (clip_plus.available && clip_isautosel_plus())\n\tclip_update_selection(&clip_plus);\n#endif\n\n    win_update(wp);\n\n    \/\/ When the screen was cleared redraw the tab pages line.\n    if (redraw_tabline)\n\tdraw_tabline();\n\n    if (wp->w_redr_status\n# ifdef FEAT_CMDL_INFO\n\t    || p_ru\n# endif\n# ifdef FEAT_STL_OPT\n\t    || *p_stl != NUL || *wp->w_p_stl != NUL\n# endif\n\t    )\n\twin_redr_status(wp, FALSE);\n\n#ifdef FEAT_PROP_POPUP\n    \/\/ Display popup windows on top of everything.\n    update_popups(win_update);\n#endif\n\n    update_finish();\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":445936,"func":"archive_extraction_ready_cb (GObject      *source_object,\n\t\t\t     GAsyncResult *result,\n\t\t\t     gpointer      user_data)\n{\n\tExtractData *edata = user_data;\n\tFrWindow    *window = edata->window;\n\tgboolean     ask_to_open_destination;\n\tgboolean     batch_mode;\n\tGError      *error = NULL;\n\n\task_to_open_destination = edata->ask_to_open_destination;\n\tbatch_mode = window->priv->batch_mode;\n\n\t_g_clear_object (&window->priv->last_extraction_destination);\n\twindow->priv->last_extraction_destination = _g_object_ref (fr_archive_get_last_extraction_destination (window->archive));\n\n\tfr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error);\n\t_archive_operation_completed (window, FR_ACTION_EXTRACTING_FILES, error);\n\n\tif ((error == NULL) && ask_to_open_destination) {\n\t\twindow->priv->quit_with_progress_dialog = window->priv->batch_mode;\n\t\topen_progress_dialog_with_open_destination (window);\n\t}\n\telse if ((error == NULL) && ! batch_mode && ! gtk_window_has_toplevel_focus (GTK_WINDOW (window->priv->progress_dialog)))\n\t\tgtk_window_present (GTK_WINDOW (window));\n\n\t_g_error_free (error);\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":398548,"func":"static inline ut64 get_max_offset(size_t addr_size) {\n\tswitch (addr_size) {\n\tcase 2:\n\t\treturn UT16_MAX;\n\tcase 4:\n\t\treturn UT32_MAX;\n\tcase 8:\n\t\treturn UT64_MAX;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":459156,"func":"static int __init tc_filter_init(void)\n{\n\tint err;\n\n\ttc_filter_wq = alloc_ordered_workqueue(\"tc_filter_workqueue\", 0);\n\tif (!tc_filter_wq)\n\t\treturn -ENOMEM;\n\n\terr = register_pernet_subsys(&tcf_net_ops);\n\tif (err)\n\t\tgoto err_register_pernet_subsys;\n\n\trtnl_register(PF_UNSPEC, RTM_NEWTFILTER, tc_new_tfilter, NULL,\n\t\t      RTNL_FLAG_DOIT_UNLOCKED);\n\trtnl_register(PF_UNSPEC, RTM_DELTFILTER, tc_del_tfilter, NULL,\n\t\t      RTNL_FLAG_DOIT_UNLOCKED);\n\trtnl_register(PF_UNSPEC, RTM_GETTFILTER, tc_get_tfilter,\n\t\t      tc_dump_tfilter, RTNL_FLAG_DOIT_UNLOCKED);\n\trtnl_register(PF_UNSPEC, RTM_NEWCHAIN, tc_ctl_chain, NULL, 0);\n\trtnl_register(PF_UNSPEC, RTM_DELCHAIN, tc_ctl_chain, NULL, 0);\n\trtnl_register(PF_UNSPEC, RTM_GETCHAIN, tc_ctl_chain,\n\t\t      tc_dump_chain, 0);\n\n\treturn 0;\n\nerr_register_pernet_subsys:\n\tdestroy_workqueue(tc_filter_wq);\n\treturn err;\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":359661,"func":"DEFUN (neighbor_maximum_prefix_threshold_restart,\n       neighbor_maximum_prefix_threshold_restart_cmd,\n       NEIGHBOR_CMD2 \"maximum-prefix <1-4294967295> <1-100> restart <1-65535>\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Maximum number of prefix accept from this peer\\n\"\n       \"maximum no. of prefix limit\\n\"\n       \"Threshold value (%) at which to generate a warning msg\\n\"\n       \"Restart bgp connection after limit is exceeded\\n\"\n       \"Restart interval in minutes\")\n{\n  return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t      bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":339724,"func":"static char * rv_alloc(int i) {\n\tint j, k, *r;\n\n\tj = sizeof(ULong);\n\tfor(k = 0;\n\t\t\tsizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;\n\t\t\tj <<= 1) {\n\t\tk++;\n\t}\n\tr = (int*)Balloc(k);\n\t*r = k;\n\treturn (char *)(r+1);\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":473852,"func":"compile_length_string_node(Node* node, regex_t* reg)\n{\n  int rlen, r, len, prev_len, slen, ambig;\n  OnigEncoding enc = reg->enc;\n  UChar *p, *prev;\n  StrNode* sn;\n\n  sn = NSTR(node);\n  if (sn->end <= sn->s)\n    return 0;\n\n  ambig = NSTRING_IS_AMBIG(node);\n\n  p = prev = sn->s;\n  prev_len = enclen(enc, p, sn->end);\n  p += prev_len;\n  slen = 1;\n  rlen = 0;\n\n  for (; p < sn->end; ) {\n    len = enclen(enc, p, sn->end);\n    if (len == prev_len) {\n      slen++;\n    }\n    else {\n      r = add_compile_string_length(prev, prev_len, slen, reg, ambig);\n      rlen += r;\n      prev = p;\n      slen = 1;\n      prev_len = len;\n    }\n    p += len;\n  }\n  r = add_compile_string_length(prev, prev_len, slen, reg, ambig);\n  rlen += r;\n  return rlen;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":508835,"func":"Yacc_state::~Yacc_state()\n{\n  if (yacc_yyss)\n  {\n    my_free(yacc_yyss);\n    my_free(yacc_yyvs);\n  }\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":333079,"func":"copy_sub(regsub_T *to, regsub_T *from)\n{\n    to->in_use = from->in_use;\n    if (from->in_use > 0)\n    {\n\t\/\/ Copy the match start and end positions.\n\tif (REG_MULTI)\n\t    mch_memmove(&to->list.multi[0],\n\t\t\t&from->list.multi[0],\n\t\t\tsizeof(struct multipos) * from->in_use);\n\telse\n\t    mch_memmove(&to->list.line[0],\n\t\t\t&from->list.line[0],\n\t\t\tsizeof(struct linepos) * from->in_use);\n    }\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":226033,"func":"GF_Err co64_box_read(GF_Box *s,GF_BitStream *bs)\n{\n\tu32 entries;\n\tGF_ChunkLargeOffsetBox *ptr = (GF_ChunkLargeOffsetBox *) s;\n\tptr->nb_entries = gf_bs_read_u32(bs);\n\n\tISOM_DECREASE_SIZE(ptr, 4)\n\n\tif ((u64)ptr->nb_entries > ptr->size \/ 8 || (u64)ptr->nb_entries > (u64)SIZE_MAX\/sizeof(u64)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid number of entries %d in co64\\n\", ptr->nb_entries));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tptr->offsets = (u64 *) gf_malloc(ptr->nb_entries * sizeof(u64) );\n\tif (ptr->offsets == NULL) return GF_OUT_OF_MEM;\n\tptr->alloc_size = ptr->nb_entries;\n\tfor (entries = 0; entries < ptr->nb_entries; entries++) {\n\t\tptr->offsets[entries] = gf_bs_read_u64(bs);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":405705,"func":"static int xemaclite_close(struct net_device *dev)\n{\n\tstruct net_local *lp = netdev_priv(dev);\n\n\tnetif_stop_queue(dev);\n\txemaclite_disable_interrupts(lp);\n\tfree_irq(dev->irq, dev);\n\n\tif (lp->phy_dev)\n\t\tphy_disconnect(lp->phy_dev);\n\tlp->phy_dev = NULL;\n\n\treturn 0;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":243991,"func":"GF_Err saiz_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_SampleAuxiliaryInfoSizeBox*ptr = (GF_SampleAuxiliaryInfoSizeBox*) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tif (ptr->flags & 1) {\n\t\tgf_bs_write_u32(bs, ptr->aux_info_type);\n\t\tgf_bs_write_u32(bs, ptr->aux_info_type_parameter);\n\t}\n\tgf_bs_write_u8(bs, ptr->default_sample_info_size);\n\tgf_bs_write_u32(bs, ptr->sample_count);\n\tif (!ptr->default_sample_info_size) {\n\t\tif (!ptr->sample_info_size)\n\t\t\tgf_bs_write_u8(bs, 0);\n\t\telse\n\t\t\tgf_bs_write_data(bs, (char *) ptr->sample_info_size, ptr->sample_count);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":338108,"func":"void WasmBinaryBuilder::visitLoop(Loop* curr) {\n  BYN_TRACE(\"zz node: Loop\\n\");\n  startControlFlow(curr);\n  curr->type = getType();\n  curr->name = getNextLabel();\n  breakStack.push_back({curr->name, Type::none});\n  \/\/ find the expressions in the block, and create the body\n  \/\/ a loop may have a list of instructions in wasm, much like\n  \/\/ a block, but it only has a label at the top of the loop,\n  \/\/ so even if we need a block (if there is more than 1\n  \/\/ expression) we never need a label on the block.\n  auto start = expressionStack.size();\n  processExpressions();\n  size_t end = expressionStack.size();\n  if (start > end) {\n    throwError(\"block cannot pop from outside\");\n  }\n  if (end - start == 1) {\n    curr->body = popExpression();\n  } else {\n    auto* block = allocator.alloc<Block>();\n    pushBlockElements(block, curr->type, start);\n    block->finalize(curr->type);\n    curr->body = block;\n  }\n  breakStack.pop_back();\n  breakTargetNames.erase(curr->name);\n  curr->finalize(curr->type);\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":391659,"func":"static bool has_delete_on_close(struct share_mode_lock *lck,\n\t\t\t\tuint32_t name_hash)\n{\n\tstruct share_mode_data *d = lck->data;\n\tuint32_t i;\n\n\tif (d->num_share_modes == 0) {\n\t\treturn false;\n\t}\n\tif (!is_delete_on_close_set(lck, name_hash)) {\n\t\treturn false;\n\t}\n\tfor (i=0; i<d->num_share_modes; i++) {\n\t\tif (!share_mode_stale_pid(d, i)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":254070,"func":"        query_string(const query_string& qs):\n          url_(qs.url_)\n        {\n            for (auto p : qs.key_value_pairs_)\n            {\n                key_value_pairs_.push_back((char*)(p - qs.url_.c_str() + url_.c_str()));\n            }\n        }","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":445998,"func":"get_dir_list_from_file_data (FrWindow *window,\n\t\t\t     FileData *fdata)\n{\n\tchar  *dirname;\n\tGList *list;\n\n\tdirname = g_strconcat (fr_window_get_current_location (window),\n\t\t\t       fdata->list_name,\n\t\t\t       NULL);\n\tlist = get_dir_list_from_path (window, dirname);\n\tg_free (dirname);\n\n\treturn list;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":139252,"func":"void OverlayWindowViews::UpdateLayerBoundsWithLetterboxing(\n    gfx::Size window_size) {\n  if (window_bounds_.size().IsEmpty() || natural_size_.IsEmpty())\n    return;\n\n  gfx::Rect letterbox_region = media::ComputeLetterboxRegion(\n      gfx::Rect(gfx::Point(0, 0), window_size), natural_size_);\n  if (letterbox_region.IsEmpty())\n    return;\n\n  gfx::Size letterbox_size = letterbox_region.size();\n  gfx::Point origin =\n      gfx::Point((window_size.width() - letterbox_size.width()) \/ 2,\n                 (window_size.height() - letterbox_size.height()) \/ 2);\n\n  video_bounds_.set_origin(origin);\n  video_bounds_.set_size(letterbox_region.size());\n\n  UpdateControlsBounds();\n\n  controller_->UpdateLayerBounds();\n}\n","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":217559,"func":"MagickExport MagickBooleanType FormatImageProperty(Image *image,\n  const char *property,const char *format,...)\n{\n  char\n    value[MaxTextExtent];\n\n  ssize_t\n    n;\n\n  va_list\n    operands;\n\n  va_start(operands,format);\n  n=FormatLocaleStringList(value,MaxTextExtent,format,operands);\n  (void) n;\n  va_end(operands);\n  return(SetImageProperty(image,property,value));\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":245186,"func":"free_mysql_variables(mysql_variable *vars)\n{\n\tmysql_variable *var;\n\n\tfor (var = vars; var->name; var++) {\n\t\tfree(*(var->value));\n\t\t*var->value = NULL;\n\t}\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":337851,"func":"void sctp_chunk_assign_ssn(struct sctp_chunk *chunk)\n{\n\tstruct sctp_stream *stream;\n\tstruct sctp_chunk *lchunk;\n\tstruct sctp_datamsg *msg;\n\t__u16 ssn, sid;\n\n\tif (chunk->has_ssn)\n\t\treturn;\n\n\t\/* All fragments will be on the same stream *\/\n\tsid = ntohs(chunk->subh.data_hdr->stream);\n\tstream = &chunk->asoc->stream;\n\n\t\/* Now assign the sequence number to the entire message.\n\t * All fragments must have the same stream sequence number.\n\t *\/\n\tmsg = chunk->msg;\n\tlist_for_each_entry(lchunk, &msg->chunks, frag_list) {\n\t\tif (lchunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) {\n\t\t\tssn = 0;\n\t\t} else {\n\t\t\tif (lchunk->chunk_hdr->flags & SCTP_DATA_LAST_FRAG)\n\t\t\t\tssn = sctp_ssn_next(stream, out, sid);\n\t\t\telse\n\t\t\t\tssn = sctp_ssn_peek(stream, out, sid);\n\t\t}\n\n\t\tlchunk->subh.data_hdr->ssn = htons(ssn);\n\t\tlchunk->has_ssn = 1;\n\t}\n}","target":0,"code_token_length":258,"total_token_length":494,"max_tokens_setting":512}
+{"idx":220834,"func":"void optimized_ops_preload_l1_stream(const T* ptr) {\n#ifdef __GNUC__\n  \/\/ builtin offered by GCC-compatible compilers including clang\n  __builtin_prefetch(ptr, \/* 0 means read *\/ 0, \/* 0 means no locality *\/ 0);\n#else\n  (void)ptr;\n#endif\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":521461,"func":"int ZipFile::getIndexOfFileName (const String& fileName, bool ignoreCase) const noexcept\r\n{\r\n    for (int i = 0; i < entries.size(); ++i)\r\n    {\r\n        auto& entryFilename = entries.getUnchecked (i)->entry.filename;\r\n\r\n        if (ignoreCase ? entryFilename.equalsIgnoreCase (fileName)\r\n                       : entryFilename == fileName)\r\n            return i;\r\n    }\r\n\r\n    return -1;\r\n}\r","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":349876,"func":"int hw_atl_write_fwsettings_dwords(struct aq_hw_s *self, u32 offset, u32 *p,\n\t\t\t\t   u32 cnt)\n{\n\treturn hw_atl_utils_fw_upload_dwords(self, self->settings_addr + offset,\n\t\t\t\t\t     p, cnt, MCP_AREA_SETTINGS);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":326621,"func":"create_parent_dir(struct archive_write_disk *a, char *path)\n{\n\tchar *slash;\n\tint r;\n\n\t\/* Remove tail element to obtain parent name. *\/\n\tslash = strrchr(path, '\/');\n\tif (slash == NULL)\n\t\treturn (ARCHIVE_OK);\n\t*slash = '\\0';\n\tr = create_dir(a, path);\n\t*slash = '\/';\n\treturn (r);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":338240,"func":"void WasmBinaryBuilder::visitTableSet(TableSet* curr) {\n  BYN_TRACE(\"zz node: TableSet\\n\");\n  Index tableIdx = getU32LEB();\n  if (tableIdx >= tables.size()) {\n    throwError(\"bad table index\");\n  }\n  curr->value = popNonVoidExpression();\n  curr->index = popNonVoidExpression();\n  curr->finalize();\n  \/\/ Defer setting the table name for later, when we know it.\n  tableRefs[tableIdx].push_back(curr);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":446062,"func":"LZWCleanup(TIFF* tif)\n{\n\t(void)TIFFPredictorCleanup(tif);\n\n\tassert(tif->tif_data != 0);\n\n\tif (DecoderState(tif)->dec_codetab)\n\t\t_TIFFfree(DecoderState(tif)->dec_codetab);\n\n\tif (EncoderState(tif)->enc_hashtab)\n\t\t_TIFFfree(EncoderState(tif)->enc_hashtab);\n\n\t_TIFFfree(tif->tif_data);\n\ttif->tif_data = NULL;\n\n\t_TIFFSetDefaultCompressionState(tif);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":226441,"func":"    Status RestoreInternal(IteratorContext* ctx,\n                           IteratorStateReader* reader) override {\n      mutex_lock l(mu_);\n      TF_RETURN_IF_ERROR(reader->ReadScalar(Iterator::full_name(\"i\"), &i_));\n      int64_t iter_loc;\n      TF_RETURN_IF_ERROR(\n          reader->ReadScalar(Iterator::full_name(\"iter_loc\"), &iter_loc));\n      iter_ = group_iterable_.at(iter_loc);\n      TF_RETURN_IF_ERROR(reader->ReadScalar(\n          Iterator::full_name(\"next_non_empty_i_\"), &next_non_empty_i_));\n      if (i_ <= next_non_empty_i_) {\n        TF_RETURN_IF_ERROR(reader->ReadTensor(\n            Iterator::full_name(\"next_indices_\"), &next_indices_));\n        TF_RETURN_IF_ERROR(reader->ReadTensor(\n            Iterator::full_name(\"next_values_\"), &next_values_));\n      }\n      return Status::OK();\n    }","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":234237,"func":"free_all_abbrevs (void)\n{\n  abbrev_list *  list;\n\n  for (list = abbrev_lists; list != NULL;)\n    {\n      abbrev_list *   next = list->next;\n      abbrev_entry *  abbrv;\n\n      for (abbrv = list->first_abbrev; abbrv != NULL;)\n\t{\n\t  abbrev_entry *  next_abbrev = abbrv->next;\n\t  abbrev_attr *   attr;\n\n\t  for (attr = abbrv->first_attr; attr;)\n\t    {\n\t      abbrev_attr *next_attr = attr->next;\n\n\t      free (attr);\n\t      attr = next_attr;\n\t    }\n\n\t  free (abbrv);\n\t  abbrv = next_abbrev;\n\t}\n\n      free (list);\n      list = next;\n    }\n\n  abbrev_lists = NULL;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":512271,"func":"  Item_literal(THD *thd): Item_basic_constant(thd)\n  { }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":224994,"func":"PQrequestCancel(PGconn *conn)\n{\n\tint\t\t\tr;\n\n\t\/* Check we have an open connection *\/\n\tif (!conn)\n\t\treturn false;\n\n\tif (conn->sock == PGINVALID_SOCKET)\n\t{\n\t\tstrlcpy(conn->errorMessage.data,\n\t\t\t\t\"PQrequestCancel() -- connection is not open\\n\",\n\t\t\t\tconn->errorMessage.maxlen);\n\t\tconn->errorMessage.len = strlen(conn->errorMessage.data);\n\n\t\treturn false;\n\t}\n\n\tr = internal_cancel(&conn->raddr, conn->be_pid, conn->be_key,\n\t\t\t\t\t\tconn->errorMessage.data, conn->errorMessage.maxlen);\n\n\tif (!r)\n\t\tconn->errorMessage.len = strlen(conn->errorMessage.data);\n\n\treturn r;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":337810,"func":"void sctp_init_addrs(struct sctp_chunk *chunk, union sctp_addr *src,\n\t\t     union sctp_addr *dest)\n{\n\tmemcpy(&chunk->source, src, sizeof(union sctp_addr));\n\tmemcpy(&chunk->dest, dest, sizeof(union sctp_addr));\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":453008,"func":"static struct nft_flow_rule *nft_flow_rule_alloc(int num_actions)\n{\n\tstruct nft_flow_rule *flow;\n\n\tflow = kzalloc(sizeof(struct nft_flow_rule), GFP_KERNEL);\n\tif (!flow)\n\t\treturn NULL;\n\n\tflow->rule = flow_rule_alloc(num_actions);\n\tif (!flow->rule) {\n\t\tkfree(flow);\n\t\treturn NULL;\n\t}\n\n\tflow->rule->match.dissector\t= &flow->match.dissector;\n\tflow->rule->match.mask\t\t= &flow->match.mask;\n\tflow->rule->match.key\t\t= &flow->match.key;\n\n\treturn flow;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":242615,"func":"  explicit StageClearOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":404727,"func":"static struct fdtable *close_files(struct files_struct * files)\n{\n\t\/*\n\t * It is safe to dereference the fd table without RCU or\n\t * ->file_lock because this is the last reference to the\n\t * files structure.\n\t *\/\n\tstruct fdtable *fdt = rcu_dereference_raw(files->fdt);\n\tunsigned int i, j = 0;\n\n\tfor (;;) {\n\t\tunsigned long set;\n\t\ti = j * BITS_PER_LONG;\n\t\tif (i >= fdt->max_fds)\n\t\t\tbreak;\n\t\tset = fdt->open_fds[j++];\n\t\twhile (set) {\n\t\t\tif (set & 1) {\n\t\t\t\tstruct file * file = xchg(&fdt->fd[i], NULL);\n\t\t\t\tif (file) {\n\t\t\t\t\tfilp_close(file, files);\n\t\t\t\t\tcond_resched();\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t\tset >>= 1;\n\t\t}\n\t}\n\n\treturn fdt;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":462569,"func":"void controller::dump_config(const std::string& filename) {\n\tstd::vector<std::string> configlines;\n\tcfg.dump_config(configlines);\n\tif (v) {\n\t\tv->get_keys()->dump_config(configlines);\n\t}\n\tign.dump_config(configlines);\n\tfilters.dump_config(configlines);\n\tcolorman.dump_config(configlines);\n\trxman.dump_config(configlines);\n\tstd::fstream f;\n\tf.open(filename.c_str(), std::fstream::out);\n\tif (f.is_open()) {\n\t\tfor (auto line : configlines) {\n\t\t\tf << line << std::endl;\n\t\t}\n\t}\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":90828,"func":"  void set_db_disabled(bool db_disabled) {\n    db_disabled_ = db_disabled;\n  }\n","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":253520,"func":"smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,\n\t\tstruct cifs_fid *fid)\n{\n\treturn SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":417093,"func":"PlayerGeneric::~PlayerGeneric()\n{\n\n\tif (player)\n\t{\n\t\tif (mixer && mixer->isActive() && !mixer->isDeviceRemoved(player))\n\t\t\tmixer->removeDevice(player);\n\t\tdelete player;\n\t}\n\t\n\tif (mixer)\n\t\tdelete mixer;\n\n\tdelete[] audioDriverName;\n\t\n\tdelete listener;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":412142,"func":"respip_inform_print(struct respip_addr_info* respip_addr, uint8_t* qname,\n\tuint16_t qtype, uint16_t qclass, struct local_rrset* local_alias,\n\tstruct comm_reply* repinfo)\n{\n\tchar srcip[128], respip[128], txt[512];\n\tunsigned port;\n\n\tif(local_alias)\n\t\tqname = local_alias->rrset->rk.dname;\n\tport = (unsigned)((repinfo->addr.ss_family == AF_INET) ?\n\t\tntohs(((struct sockaddr_in*)&repinfo->addr)->sin_port) :\n\t\tntohs(((struct sockaddr_in6*)&repinfo->addr)->sin6_port));\n\taddr_to_str(&repinfo->addr, repinfo->addrlen, srcip, sizeof(srcip));\n\taddr_to_str(&respip_addr->addr, respip_addr->addrlen,\n\t\trespip, sizeof(respip));\n\tsnprintf(txt, sizeof(txt), \"%s\/%d inform %s@%u\", respip,\n\t\trespip_addr->net, srcip, port);\n\tlog_nametypeclass(0, txt, qname, qtype, qclass);\n}","target":0,"code_token_length":248,"total_token_length":484,"max_tokens_setting":512}
+{"idx":301442,"func":"static ssize_t vfswrap_recvfile(vfs_handle_struct *handle,\n\t\t\tint fromfd,\n\t\t\tfiles_struct *tofsp,\n\t\t\toff_t offset,\n\t\t\tsize_t n)\n{\n\tssize_t result;\n\n\tSTART_PROFILE_BYTES(syscall_recvfile, n);\n\tresult = sys_recvfile(fromfd, tofsp->fh->fd, offset, n);\n\tEND_PROFILE(syscall_recvfile);\n\treturn result;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":387772,"func":"void InstanceKlass::clean_weak_instanceklass_links() {\n  clean_implementors_list();\n  clean_method_data();\n\n  \/\/ Since GC iterates InstanceKlasses sequentially, it is safe to remove stale entries here.\n  DependencyContext dep_context(&_dep_context);\n  dep_context.expunge_stale_entries();\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":238595,"func":"static void sanitize_mark_insn_seen(struct bpf_verifier_env *env)\n{\n\tstruct bpf_verifier_state *vstate = env->cur_state;\n\n\t\/* If we simulate paths under speculation, we don't update the\n\t * insn as 'seen' such that when we verify unreachable paths in\n\t * the non-speculative domain, sanitize_dead_code() can still\n\t * rewrite\/sanitize them.\n\t *\/\n\tif (!vstate->speculative)\n\t\tenv->insn_aux_data[env->insn_idx].seen = env->pass_cnt;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":337813,"func":"static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc,\n\t\t\t\t\t   int length)\n{\n\tstruct sctp_reconf_chunk *reconf;\n\tstruct sctp_chunk *retval;\n\n\tretval = sctp_make_control(asoc, SCTP_CID_RECONF, 0, length,\n\t\t\t\t   GFP_ATOMIC);\n\tif (!retval)\n\t\treturn NULL;\n\n\treconf = (struct sctp_reconf_chunk *)retval->chunk_hdr;\n\tretval->param_hdr.v = reconf->params;\n\n\treturn retval;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":307838,"func":"ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor,\n                                        int index) {\n  ciConstantPoolCache* cache = accessor->field_cache();\n  if (cache == NULL) {\n    ciField* field = new (arena()) ciField(accessor, index);\n    return field;\n  } else {\n    ciField* field = (ciField*)cache->get(index);\n    if (field == NULL) {\n      field = new (arena()) ciField(accessor, index);\n      cache->insert(index, field);\n    }\n    return field;\n  }\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":387733,"func":"Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,\n                                                       Symbol* signature,\n                                                       DefaultsLookupMode defaults_mode) const {\n  Array<Klass*>* all_ifs = transitive_interfaces();\n  int num_ifs = all_ifs->length();\n  InstanceKlass *ik = NULL;\n  for (int i = 0; i < num_ifs; i++) {\n    ik = InstanceKlass::cast(all_ifs->at(i));\n    Method* m = ik->lookup_method(name, signature);\n    if (m != NULL && m->is_public() && !m->is_static() &&\n        ((defaults_mode != skip_defaults) || !m->is_default_method())) {\n      return m;\n    }\n  }\n  return NULL;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":436100,"func":"\/* when returns >0, the caller should retry *\/\nstatic inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,\n\t\t\t\t\t  struct io_wait_queue *iowq,\n\t\t\t\t\t  signed long *timeout)\n{\n\tint ret;\n\n\t\/* make sure we run task_work before checking for signals *\/\n\tret = io_run_task_work_sig();\n\tif (ret || io_should_wake(iowq))\n\t\treturn ret;\n\t\/* let the caller flush overflows, retry *\/\n\tif (test_bit(0, &ctx->check_cq_overflow))\n\t\treturn 1;\n\n\t*timeout = schedule_timeout(*timeout);\n\treturn !*timeout ? -ETIME : 1;","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":412131,"func":"dnsc_shared_secrets_sizefunc(void *k, void* ATTR_UNUSED(d))\n{\n    struct shared_secret_cache_key* ssk = (struct shared_secret_cache_key*)k;\n    size_t key_size = sizeof(struct shared_secret_cache_key)\n        + lock_get_mem(&ssk->entry.lock);\n    size_t data_size = crypto_box_BEFORENMBYTES;\n    (void)ssk; \/* otherwise ssk is unused if no threading, or fixed locksize *\/\n    return key_size + data_size;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":226011,"func":"void urn_box_del(GF_Box *s)\n{\n\tGF_DataEntryURNBox *ptr = (GF_DataEntryURNBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->location) gf_free(ptr->location);\n\tif (ptr->nameURN) gf_free(ptr->nameURN);\n\tgf_free(ptr);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":482486,"func":"allocateDisplayTable(const FileInfo *file, DisplayTableHeader **table) {\n\t\/* Allocate memory for the table and a guess on the number of rules *\/\n\tconst TranslationTableOffset startSize = 2 * sizeof(**table);\n\tif (*table) return 1;\n\tTranslationTableOffset bytesUsed =\n\t\t\tsizeof(**table) + OFFSETSIZE; \/* So no offset is ever zero *\/\n\tif (!(*table = malloc(startSize))) {\n\t\tcompileError(file, \"Not enough memory\");\n\t\tif (*table != NULL) free(*table);\n\t\t*table = NULL;\n\t\t_lou_outOfMemory();\n\t}\n\tmemset(*table, 0, startSize);\n\t(*table)->tableSize = startSize;\n\t(*table)->bytesUsed = bytesUsed;\n\treturn 1;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":261202,"func":"int MqttClient_WaitMessage(MqttClient *client, int timeout_ms)\n{\n    if (client == NULL)\n        return MQTT_CODE_ERROR_BAD_ARG;\n    return MqttClient_WaitMessage_ex(client, &client->msg, timeout_ms);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":90884,"func":"void ClientUsageTracker::AddCachedHost(const std::string& host) {\n  cached_hosts_.insert(host);\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":245704,"func":"static int pull_client_data_chunked (struct conn_s *connptr) {\n        char *buffer = 0;\n        ssize_t len;\n        long chunklen;\n\n        while(1) {\n                if (buffer) safefree(buffer);\n                len = readline (connptr->client_fd, &buffer);\n\n                if (len <= 0)\n                        goto ERROR_EXIT;\n\n                if (!connptr->error_variables) {\n                        if (safe_write (connptr->server_fd, buffer, len) < 0)\n                                goto ERROR_EXIT;\n                }\n\n                chunklen = strtol (buffer, (char**)0, 16);\n\n                if (pull_client_data (connptr, chunklen+2, 0) < 0)\n                        goto ERROR_EXIT;\n\n                if(!chunklen) break;\n        }\n\n        safefree (buffer);\n        return 0;\n\nERROR_EXIT:\n        safefree (buffer);\n        return -1;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":318977,"func":"f_test_null_list(typval_T *argvars UNUSED, typval_T *rettv)\n{\n    rettv_list_set(rettv, NULL);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":462556,"func":"void controller::write_item(std::shared_ptr<rss_item> item, const std::string& filename) {\n\tstd::fstream f;\n\tf.open(filename.c_str(),std::fstream::out);\n\tif (!f.is_open())\n\t\tthrow exception(errno);\n\n\twrite_item(item, f);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":512435,"func":"  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)\n  {\n    return get_date_from_string(thd, ltime, fuzzydate);\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":361745,"func":"static int em28xx_usb_resume(struct usb_interface *intf)\n{\n\tstruct em28xx *dev;\n\n\tdev = usb_get_intfdata(intf);\n\tif (!dev)\n\t\treturn 0;\n\tem28xx_resume_extension(dev);\n\treturn 0;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":454757,"func":"static int ismt_int_init(struct ismt_priv *priv)\n{\n\tint err;\n\n\t\/* Try using MSI interrupts *\/\n\terr = pci_enable_msi(priv->pci_dev);\n\tif (err)\n\t\tgoto intx;\n\n\terr = devm_request_irq(&priv->pci_dev->dev,\n\t\t\t       priv->pci_dev->irq,\n\t\t\t       ismt_do_msi_interrupt,\n\t\t\t       0,\n\t\t\t       \"ismt-msi\",\n\t\t\t       priv);\n\tif (err) {\n\t\tpci_disable_msi(priv->pci_dev);\n\t\tgoto intx;\n\t}\n\n\treturn 0;\n\n\t\/* Try using legacy interrupts *\/\nintx:\n\tdev_warn(&priv->pci_dev->dev,\n\t\t \"Unable to use MSI interrupts, falling back to legacy\\n\");\n\n\terr = devm_request_irq(&priv->pci_dev->dev,\n\t\t\t       priv->pci_dev->irq,\n\t\t\t       ismt_do_interrupt,\n\t\t\t       IRQF_SHARED,\n\t\t\t       \"ismt-intx\",\n\t\t\t       priv);\n\tif (err) {\n\t\tdev_err(&priv->pci_dev->dev, \"no usable interrupts\\n\");\n\t\treturn err;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":219996,"func":"int callback_glewlwyd_get_user_module (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  struct config_elements * config = (struct config_elements *)user_data;\n  json_t * j_module;\n  \n  j_module = get_user_module(config, u_map_get(request->map_url, \"name\"));\n  if (check_result_value(j_module, G_OK)) {\n    ulfius_set_json_body_response(response, 200, json_object_get(j_module, \"module\"));\n  } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) {\n    response->status = 404;\n  } else {\n    y_log_message(Y_LOG_LEVEL_ERROR, \"callback_glewlwyd_get_user_module - Error get_user_module\");\n    response->status = 500;\n  }\n  json_decref(j_module);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":221132,"func":"GF_AV1Config *gf_odf_av1_cfg_read_bs(GF_BitStream *bs)\n{\n\treturn gf_odf_av1_cfg_read_bs_size(bs, 0);\n\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":338138,"func":"void WasmBinaryBuilder::visitRefFunc(RefFunc* curr) {\n  BYN_TRACE(\"zz node: RefFunc\\n\");\n  Index index = getU32LEB();\n  \/\/ We don't know function names yet, so record this use to be updated later.\n  \/\/ Note that we do not need to check that 'index' is in bounds, as that will\n  \/\/ be verified in the next line. (Also, note that functionRefs[index] may\n  \/\/ write to an odd place in the functionRefs map if index is invalid, but that\n  \/\/ is harmless.)\n  functionRefs[index].push_back(curr);\n  \/\/ To support typed function refs, we give the reference not just a general\n  \/\/ funcref, but a specific subtype with the actual signature.\n  curr->finalize(Type(getTypeByFunctionIndex(index), NonNullable));\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":247734,"func":"  setExpectedRequestedServerName(const std::string& expected_requested_server_name) {\n    expected_requested_server_name_ = expected_requested_server_name;\n    return *this;\n  }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":309949,"func":"rewrite_sgr(char *s, char *attr)\n{\n    if (s != 0) {\n\tif (PRESENT(attr)) {\n\t    size_t len_s = strlen(s);\n\t    size_t len_a = strlen(attr);\n\n\t    if (len_s > len_a && !strncmp(attr, s, len_a)) {\n\t\tunsigned n;\n\t\tTR(TRACE_DATABASE, (\"rewrite:\\n\\t%s\", s));\n\t\tfor (n = 0; n < len_s - len_a; ++n) {\n\t\t    s[n] = s[n + len_a];\n\t\t}\n\t\t_nc_STRCPY(s + n, attr, strlen(s) + 1);\n\t\tTR(TRACE_DATABASE, (\"to:\\n\\t%s\", s));\n\t    }\n\t}\n\treturn TRUE;\n    }\n    return FALSE;\t\t\/* oops *\/\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":459172,"func":"tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp,\n\t\t\t u32 *cnt, u32 *flags)\n{\n\tlockdep_assert_held(&block->cb_lock);\n\n\tspin_lock(&tp->lock);\n\ttcf_block_offload_dec(block, flags);\n\t*cnt = 0;\n\tspin_unlock(&tp->lock);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":338081,"func":"void WasmBinaryBuilder::readHeader() {\n  BYN_TRACE(\"== readHeader\\n\");\n  verifyInt32(BinaryConsts::Magic);\n  verifyInt32(BinaryConsts::Version);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":244125,"func":"GF_Err mhac_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_MHAConfigBox *ptr = (GF_MHAConfigBox *) s;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u8(bs, ptr->configuration_version);\n\tgf_bs_write_u8(bs, ptr->mha_pl_indication);\n\tgf_bs_write_u8(bs, ptr->reference_channel_layout);\n\tgf_bs_write_u16(bs, ptr->mha_config ? ptr->mha_config_size : 0);\n\tif (ptr->mha_config && ptr->mha_config_size)\n\t\tgf_bs_write_data(bs, ptr->mha_config, ptr->mha_config_size);\n\n\treturn GF_OK;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":468372,"func":"connection_attempt_new (void)\n{\n  ConnectionAttempt *attempt = g_new0 (ConnectionAttempt, 1);\n  g_ref_count_init (&attempt->ref);\n  return attempt;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":512604,"func":"  String *val_str(String *to)\n  {\n    DBUG_ASSERT(sane());\n    return null_value ? NULL :\n           m_value.to_datetime(current_thd).to_string(to, decimals);\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":222918,"func":"  DisjointSet() {}","target":0,"code_token_length":6,"total_token_length":242,"max_tokens_setting":512}
+{"idx":492691,"func":"vte_sequence_handler_ic (VteTerminal *terminal, GValueArray *params)\n{\n\tVteVisualPosition save;\n\tVteScreen *screen;\n\n\tscreen = terminal->pvt->screen;\n\n\tsave = screen->cursor_current;\n\n\t_vte_terminal_insert_char(terminal, ' ', TRUE, TRUE);\n\n\tscreen->cursor_current = save;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":373520,"func":"ipf_is_v6_frag(ovs_be16 ip6f_offlg)\n{\n    if (ip6f_offlg & (IP6F_OFF_MASK | IP6F_MORE_FRAG)) {\n        return true;\n    }\n    return false;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":238494,"func":"static int insn_def_regno(const struct bpf_insn *insn)\n{\n\tswitch (BPF_CLASS(insn->code)) {\n\tcase BPF_JMP:\n\tcase BPF_JMP32:\n\tcase BPF_ST:\n\t\treturn -1;\n\tcase BPF_STX:\n\t\tif (BPF_MODE(insn->code) == BPF_ATOMIC &&\n\t\t    (insn->imm & BPF_FETCH)) {\n\t\t\tif (insn->imm == BPF_CMPXCHG)\n\t\t\t\treturn BPF_REG_0;\n\t\t\telse\n\t\t\t\treturn insn->src_reg;\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\tdefault:\n\t\treturn insn->dst_reg;\n\t}\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":401568,"func":"static void do_init_timer(struct timer_list *timer,\n\t\t\t  void (*func)(struct timer_list *),\n\t\t\t  unsigned int flags,\n\t\t\t  const char *name, struct lock_class_key *key)\n{\n\ttimer->entry.pprev = NULL;\n\ttimer->function = func;\n\ttimer->flags = flags | raw_smp_processor_id();\n\tlockdep_init_map(&timer->lockdep_map, name, key, 0);\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":436064,"func":"static void io_req_task_queue_fail(struct io_kiocb *req, int ret)\n{\n\treq->result = ret;\n\treq->io_task_work.func = io_req_task_cancel;\n\tio_req_task_work_add(req);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":424912,"func":"static u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg)\n{\n\tu32 mask = iwl_trans_pcie_prph_msk(trans);\n\n\tiwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_RADDR,\n\t\t\t       ((reg & mask) | (3 << 24)));\n\treturn iwl_trans_pcie_read32(trans, HBUS_TARG_PRPH_RDAT);\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":502693,"func":"long SSL_SESSION_set_time(SSL_SESSION *s, long t)\n{\n    if (s == NULL)\n        return (0);\n    s->time = t;\n    return (t);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":500065,"func":"krb5_decrypt_tkt_part(krb5_context con, krb5_const krb5_keyblock *keys,\n                krb5_ticket *ticket)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_decrypt_tkt_part )\n\t\treturn(p_krb5_decrypt_tkt_part(con,keys,ticket));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":238807,"func":"get_spat(int idx)\n{\n    return &spats[idx];\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":512861,"func":"bool Item_func_between::fix_length_and_dec_numeric(THD *thd)\n{\n  \/* See the comment about the similar block in Item_bool_func2 *\/\n  if (args[0]->real_item()->type() == FIELD_ITEM &&\n      !thd->lex->is_ps_or_view_context_analysis())\n  {\n    Item_field *field_item= (Item_field*) (args[0]->real_item());\n    if (field_item->field_type() ==  MYSQL_TYPE_LONGLONG ||\n        field_item->field_type() ==  MYSQL_TYPE_YEAR)\n    {\n      const bool cvt_arg1= convert_const_to_int(thd, field_item, &args[1]);\n      const bool cvt_arg2= convert_const_to_int(thd, field_item, &args[2]);\n      if (cvt_arg1 && cvt_arg2)\n      {\n        \/\/ Works for all types\n        m_comparator.set_handler(&type_handler_longlong);\n      }\n    }\n  }\n  return FALSE;\n}","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":398535,"func":"static void free_comp_unit(RzBinDwarfCompUnit *cu) {\n\tsize_t i;\n\tif (!cu) {\n\t\treturn;\n\t}\n\tfor (i = 0; i < cu->count; i++) {\n\t\tif (cu->dies) {\n\t\t\tfree_die(&cu->dies[i]);\n\t\t}\n\t}\n\tRZ_FREE(cu->dies);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":226151,"func":"\nGF_Err gitn_box_size(GF_Box *s)\n{\n\tu32 i;\n\tGroupIdToNameBox *ptr = (GroupIdToNameBox *)s;\n\tptr->size += 2;\n\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tptr->size += 5;\n\t\tif (ptr->entries[i].name) ptr->size += strlen(ptr->entries[i].name);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":225480,"func":"void MutableGraphView::UpdateMaxRegularOutputPortForRemovedFanin(\n    const OutputPort& fanin,\n    const absl::flat_hash_set<InputPort>& fanin_fanouts) {\n  int max_port = max_regular_output_port()[fanin.node];\n  if (!fanin_fanouts.empty() || max_port != fanin.port_id) {\n    return;\n  }\n  bool updated_max_port = false;\n  for (int i = fanin.port_id - 1; i >= 0; --i) {\n    OutputPort fanin_port(fanin.node, i);\n    if (!fanouts()[fanin_port].empty()) {\n      max_regular_output_port()[fanin.node] = i;\n      updated_max_port = true;\n      break;\n    }\n  }\n  if (!updated_max_port) {\n    max_regular_output_port().erase(fanin.node);\n  }\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":247752,"func":"bool RWFunction::Validate(RandomNumberGenerator &rng, unsigned int level) const\n{\n\tbool pass = true;\n\tpass = pass && m_n > Integer::One() && m_n%8 == 5;\n\treturn pass;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":264301,"func":"static void send_ext_audio_ack(VncState *vs)\n{\n    vnc_lock_output(vs);\n    vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);\n    vnc_write_u8(vs, 0);\n    vnc_write_u16(vs, 1);\n    vnc_framebuffer_update(vs, 0, 0,\n                           surface_width(vs->vd->ds),\n                           surface_height(vs->vd->ds),\n                           VNC_ENCODING_AUDIO);\n    vnc_unlock_output(vs);\n    vnc_flush(vs);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":430371,"func":"int seq_open(struct file *file, const struct seq_operations *op)\n{\n\tstruct seq_file *p;\n\n\tWARN_ON(file->private_data);\n\n\tp = kmem_cache_zalloc(seq_file_cache, GFP_KERNEL);\n\tif (!p)\n\t\treturn -ENOMEM;\n\n\tfile->private_data = p;\n\n\tmutex_init(&p->lock);\n\tp->op = op;\n\n\t\/\/ No refcounting: the lifetime of 'p' is constrained\n\t\/\/ to the lifetime of the file.\n\tp->file = file;\n\n\t\/*\n\t * seq_files support lseek() and pread().  They do not implement\n\t * write() at all, but we clear FMODE_PWRITE here for historical\n\t * reasons.\n\t *\n\t * If a client of seq_files a) implements file.write() and b) wishes to\n\t * support pwrite() then that client will need to implement its own\n\t * file.open() which calls seq_open() and then sets FMODE_PWRITE.\n\t *\/\n\tfile->f_mode &= ~FMODE_PWRITE;\n\treturn 0;\n}","target":0,"code_token_length":220,"total_token_length":456,"max_tokens_setting":512}
+{"idx":292210,"func":"inbound_make_idtext (server *serv, char *idtext, int max, int id)\n{\n\tidtext[0] = 0;\n\tif (serv->have_idmsg || serv->have_accnotify)\n\t{\n\t\tif (id)\n\t\t{\n\t\t\tsafe_strcpy (idtext, prefs.hex_irc_id_ytext, max);\n\t\t} else\n\t\t{\n\t\t\tsafe_strcpy (idtext, prefs.hex_irc_id_ntext, max);\n\t\t}\n\t\t\/* convert codes like %C,%U to the proper ones *\/\n\t\tcheck_special_chars (idtext, TRUE);\n\t}\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":231031,"func":"static BaseType_t prvIsQueueFull( const Queue_t * pxQueue )\r\n{\r\n    BaseType_t xReturn;\r\n\r\n    taskENTER_CRITICAL();\r\n    {\r\n        if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )\r\n        {\r\n            xReturn = pdTRUE;\r\n        }\r\n        else\r\n        {\r\n            xReturn = pdFALSE;\r\n        }\r\n    }\r\n    taskEXIT_CRITICAL();\r\n\r\n    return xReturn;\r\n}\r","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":383333,"func":"gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a)\n{\n  int i;\n  int ct = (-1);\n  if (im->trueColor)\n    {\n      return gdTrueColorAlpha (r, g, b, a);\n    }\n  for (i = 0; (i < (im->colorsTotal)); i++)\n    {\n      if (im->open[i])\n\t{\n\t  ct = i;\n\t  break;\n\t}\n    }\n  if (ct == (-1))\n    {\n      ct = im->colorsTotal;\n      if (ct == gdMaxColors)\n\t{\n\t  return -1;\n\t}\n      im->colorsTotal++;\n    }\n  im->red[ct] = r;\n  im->green[ct] = g;\n  im->blue[ct] = b;\n  im->alpha[ct] = a;\n  im->open[ct] = 0;\n  return ct;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":274699,"func":"callbacks_move_layer_down_menu_activate (GtkMenuItem *menuitem, gpointer user_data) {\n\tcallbacks_move_layer_down_button_clicked(NULL, NULL);\n\tgtk_widget_grab_focus (screen.win.layerTree);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":437696,"func":"static u32 filter_rx_s_min_width(struct cx23885_dev *dev, u32 min_width_ns)\n{\n\tu32 count = ns_to_lpf_count(min_width_ns);\n\tcx23888_ir_write4(dev, CX23888_IR_FILTR_REG, count);\n\treturn lpf_count_to_ns(count);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":292151,"func":"void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) {\n  switch (byte) {\n    case Bytecodes::_invokestatic   : resolve_invokestatic   (result,       pool, index, CHECK); break;\n    case Bytecodes::_invokespecial  : resolve_invokespecial  (result, recv, pool, index, CHECK); break;\n    case Bytecodes::_invokevirtual  : resolve_invokevirtual  (result, recv, pool, index, CHECK); break;\n    case Bytecodes::_invokehandle   : resolve_invokehandle   (result,       pool, index, CHECK); break;\n    case Bytecodes::_invokedynamic  : resolve_invokedynamic  (result,       pool, index, CHECK); break;\n    case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break;\n    default                         :                                                            break;\n  }\n  return;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":385826,"func":"follow_link(struct path *link, struct nameidata *nd, void **p)\n{\n\tstruct dentry *dentry = link->dentry;\n\tint error;\n\tchar *s;\n\n\tBUG_ON(nd->flags & LOOKUP_RCU);\n\n\tif (link->mnt == nd->path.mnt)\n\t\tmntget(link->mnt);\n\n\terror = -ELOOP;\n\tif (unlikely(current->total_link_count >= 40))\n\t\tgoto out_put_nd_path;\n\n\tcond_resched();\n\tcurrent->total_link_count++;\n\n\ttouch_atime(link);\n\tnd_set_link(nd, NULL);\n\n\terror = security_inode_follow_link(link->dentry, nd);\n\tif (error)\n\t\tgoto out_put_nd_path;\n\n\tnd->last_type = LAST_BIND;\n\t*p = dentry->d_inode->i_op->follow_link(dentry, nd);\n\terror = PTR_ERR(*p);\n\tif (IS_ERR(*p))\n\t\tgoto out_put_nd_path;\n\n\terror = 0;\n\ts = nd_get_link(nd);\n\tif (s) {\n\t\terror = __vfs_follow_link(nd, s);\n\t\tif (unlikely(error))\n\t\t\tput_link(nd, link, *p);\n\t}\n\n\treturn error;\n\nout_put_nd_path:\n\t*p = NULL;\n\tpath_put(&nd->path);\n\tpath_put(link);\n\treturn error;\n}","target":0,"code_token_length":267,"total_token_length":503,"max_tokens_setting":512}
+{"idx":453023,"func":"void nft_flow_rule_destroy(struct nft_flow_rule *flow)\n{\n\tstruct flow_action_entry *entry;\n\tint i;\n\n\tflow_action_for_each(i, entry, &flow->rule->action) {\n\t\tswitch (entry->id) {\n\t\tcase FLOW_ACTION_REDIRECT:\n\t\tcase FLOW_ACTION_MIRRED:\n\t\t\tdev_put(entry->dev);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\tkfree(flow->rule);\n\tkfree(flow);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":254872,"func":"    bool operator()(const GroupsMap::value_type* lhs, const GroupsMap::value_type* rhs) const {\n        return _valueComparator.evaluate(lhs->first < rhs->first);\n    }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":291843,"func":"static void rtrs_clt_info_req_done(struct ib_cq *cq, struct ib_wc *wc)\n{\n\tstruct rtrs_clt_con *con = to_clt_con(wc->qp->qp_context);\n\tstruct rtrs_clt_path *clt_path = to_clt_path(con->c.path);\n\tstruct rtrs_iu *iu;\n\n\tiu = container_of(wc->wr_cqe, struct rtrs_iu, cqe);\n\trtrs_iu_free(iu, clt_path->s.dev->ib_dev, 1);\n\n\tif (wc->status != IB_WC_SUCCESS) {\n\t\trtrs_err(clt_path->clt, \"Path info request send failed: %s\\n\",\n\t\t\t  ib_wc_status_msg(wc->status));\n\t\trtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING_ERR, NULL);\n\t\treturn;\n\t}\n\n\trtrs_clt_update_wc_stats(con);\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":474446,"func":"ObjectAllocateSlot(\n\t\t   TPMI_DH_OBJECT  *handle        \/\/ OUT: handle of allocated object\n\t\t   )\n{\n    OBJECT          *object = FindEmptyObjectSlot(handle);\n    if(object != NULL)\n\t{\n\t    \/\/ if found, mark as occupied\n\t    ObjectSetInUse(object);\n\t}\n    return object;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":512783,"func":"  const MYSQL_TIME *const_ptr_mysql_time() const\n  {\n    return cached_time.get_mysql_time();\n  }","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":269488,"func":"static CustomStreamInfo *TIFFAcquireCustomStreamForWriting(\n  PhotoshopProfile *profile,ExceptionInfo *exception)\n{\n  CustomStreamInfo\n    *custom_stream;\n\n  custom_stream=AcquireCustomStreamInfo(exception);\n  if (custom_stream == (CustomStreamInfo *) NULL)\n    return(custom_stream);\n  SetCustomStreamData(custom_stream,(void *) profile);\n  SetCustomStreamWriter(custom_stream,TIFFWriteCustomStream);\n  SetCustomStreamSeeker(custom_stream,TIFFSeekCustomStream);\n  SetCustomStreamTeller(custom_stream,TIFFTellCustomStream);\n  return(custom_stream);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":409406,"func":"limit_screen_size(void)\n{\n    if (Columns < MIN_COLUMNS)\n\tColumns = MIN_COLUMNS;\n    else if (Columns > 10000)\n\tColumns = 10000;\n    if (Rows > 1000)\n\tRows = 1000;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":313782,"func":"del_from_showcmd(int len)\n{\n    int\t    old_len;\n\n    if (!p_sc)\n\treturn;\n\n    old_len = (int)STRLEN(showcmd_buf);\n    if (len > old_len)\n\tlen = old_len;\n    showcmd_buf[old_len - len] = NUL;\n\n    if (!char_avail())\n\tdisplay_showcmd();\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":386516,"func":"void DL_Dxf::writeBlock(DL_WriterA& dw, const DL_BlockData& data) {\n    if (data.name.empty()) {\n        std::cerr << \"DL_Dxf::writeBlock: \"\n        << \"Block name must not be empty\\n\";\n        return;\n    }\n\n    std::string n = data.name;\n    std::transform(n.begin(), n.end(), n.begin(), ::toupper);\n\n    if (n==\"*PAPER_SPACE\") {\n        dw.sectionBlockEntry(0x1C);\n    } else if (n==\"*MODEL_SPACE\") {\n        dw.sectionBlockEntry(0x20);\n    } else if (n==\"*PAPER_SPACE0\") {\n        dw.sectionBlockEntry(0x24);\n    } else {\n        dw.sectionBlockEntry();\n    }\n    dw.dxfString(2, data.name);\n    dw.dxfInt(70, 0);\n    dw.coord(10, data.bpx, data.bpy, data.bpz);\n    dw.dxfString(3, data.name);\n    dw.dxfString(1, \"\");\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":405383,"func":"static void __xfrm_policy_inexact_prune_bin(struct xfrm_pol_inexact_bin *b, bool net_exit)\n{\n\twrite_seqcount_begin(&b->count);\n\txfrm_policy_inexact_gc_tree(&b->root_d, net_exit);\n\txfrm_policy_inexact_gc_tree(&b->root_s, net_exit);\n\twrite_seqcount_end(&b->count);\n\n\tif (!RB_EMPTY_ROOT(&b->root_d) || !RB_EMPTY_ROOT(&b->root_s) ||\n\t    !hlist_empty(&b->hhead)) {\n\t\tWARN_ON_ONCE(net_exit);\n\t\treturn;\n\t}\n\n\tif (rhashtable_remove_fast(&xfrm_policy_inexact_table, &b->head,\n\t\t\t\t   xfrm_pol_inexact_params) == 0) {\n\t\tlist_del(&b->inexact_bins);\n\t\tkfree_rcu(b, rcu);\n\t}\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":512583,"func":"  const Type_handler *type_handler() const\n  {\n    const Type_handler *handler= field->type_handler();\n    return handler->type_handler_for_item_field();\n  }","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":387620,"func":"static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol,\n\t\t\t\t struct snd_ctl_elem_value *ucontrol)\n{\n\tint change;\n\tstruct user_element *ue = kcontrol->private_data;\n\tunsigned int size = ue->elem_data_size;\n\tchar *dst = ue->elem_data +\n\t\t\tsnd_ctl_get_ioff(kcontrol, &ucontrol->id) * size;\n\n\tchange = memcmp(&ucontrol->value, dst, size) != 0;\n\tif (change)\n\t\tmemcpy(dst, &ucontrol->value, size);\n\treturn change;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":442570,"func":"static void test_memslot_invalid_slot_id(void)\n{\n    RedMemSlotInfo mem_info;\n    init_meminfo(&mem_info);\n\n    memslot_get_virt(&mem_info, 1 << mem_info.memslot_id_shift, 16, 0);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":255757,"func":"create_node(authz_rule_segment_t *segment,\n            apr_pool_t *result_pool)\n{\n  node_t *result = apr_pcalloc(result_pool, sizeof(*result));\n  if (segment)\n    result->segment = segment->pattern;\n  else\n    {\n      result->segment.data = \"\";\n      result->segment.len = 0;\n    }\n  result->rights.access.sequence_number = NO_SEQUENCE_NUMBER;\n  return result;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":262033,"func":"ProtoMakeErrorReplyInt(ServiceConnection *conn,\n                       int reqSeqno,\n                       VGAuthError err,\n                       const char *errMsg)\n{\n   gchar *packet;\n   gchar *escapedErrMsg = g_markup_escape_text(errMsg, -1);\n\n   \/*\n    * g_markup_printf_escaped() is broken when the printf format\n    * contains the Windows FMT64 format string %I64\n    *\/\n\n   packet = g_strdup_printf(VGAUTH_ERROR_FORMAT,\n                            reqSeqno,\n                            err,\n                            escapedErrMsg);\n   g_free(escapedErrMsg);\n\n   Log(\"Returning error message '%s'\\n\", packet);\n\n   return packet;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":282862,"func":"static int rsi_send_beacon(struct rsi_common *common)\n{\n\tstruct sk_buff *skb = NULL;\n\tu8 dword_align_bytes = 0;\n\n\tskb = dev_alloc_skb(MAX_MGMT_PKT_SIZE);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\n\tmemset(skb->data, 0, MAX_MGMT_PKT_SIZE);\n\n\tdword_align_bytes = ((unsigned long)skb->data & 0x3f);\n\tif (dword_align_bytes)\n\t\tskb_pull(skb, (64 - dword_align_bytes));\n\tif (rsi_prepare_beacon(common, skb)) {\n\t\trsi_dbg(ERR_ZONE, \"Failed to prepare beacon\\n\");\n\t\tdev_kfree_skb(skb);\n\t\treturn -EINVAL;\n\t}\n\tskb_queue_tail(&common->tx_queue[MGMT_BEACON_Q], skb);\n\trsi_set_event(&common->tx_thread.event);\n\trsi_dbg(DATA_TX_ZONE, \"%s: Added to beacon queue\\n\", __func__);\n\n\treturn 0;\n}","target":0,"code_token_length":203,"total_token_length":439,"max_tokens_setting":512}
+{"idx":293740,"func":"static bool check_buffer(RBinFile *bf, RBuffer *b) {\n\tif (r_buf_size (b) > 4) {\n\t\tut8 buf[4];\n\t\tr_buf_read_at (b, 0, buf, sizeof (buf));\n\t\tif (!memcmp (buf, \"\\xcf\\xfa\\xed\\xfe\", 4)) {\n\t\t\treturn is_kernelcache_buffer (b);\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":384810,"func":"vim_backtick(char_u *p)\n{\n    return (*p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`');\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":101681,"func":"static uint64_t generatePageID()\n{\n    static uint64_t uniquePageID = 1;\n    return uniquePageID++;\n}\n","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":506691,"func":"static int set_cn(X509 *crt, ...)\n{\n    int ret = 0;\n    X509_NAME *n = NULL;\n    va_list ap;\n\n    va_start(ap, crt);\n    n = X509_NAME_new();\n    if (n == NULL)\n        goto out;\n\n    while (1) {\n        int nid;\n        const char *name;\n\n        nid = va_arg(ap, int);\n        if (nid == 0)\n            break;\n        name = va_arg(ap, const char *);\n        if (!X509_NAME_add_entry_by_NID(n, nid, MBSTRING_ASC,\n                                        (unsigned char *)name, -1, -1, 1))\n            goto out;\n    }\n    if (!X509_set_subject_name(crt, n))\n        goto out;\n    ret = 1;\n out:\n    X509_NAME_free(n);\n    va_end(ap);\n    return ret;\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":318095,"func":"static int rsi_usb_master_reg_read(struct rsi_hw *adapter, u32 reg,\n\t\t\t\t   u32 *value, u16 len)\n{\n\tstruct usb_device *usbdev =\n\t\t((struct rsi_91x_usbdev *)adapter->rsi_dev)->usbdev;\n\tu16 temp;\n\tint ret;\n\n\tret = rsi_usb_reg_read(usbdev, reg, &temp, len);\n\tif (ret < 0)\n\t\treturn ret;\n\t*value = temp;\n\n\treturn 0;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":509473,"func":"int ha_maria::write_row(const uchar * buf)\n{\n  \/*\n     If we have an auto_increment column and we are writing a changed row\n     or a new row, then update the auto_increment value in the record.\n  *\/\n  if (table->next_number_field && buf == table->record[0])\n  {\n    int error;\n    if ((error= update_auto_increment()))\n      return error;\n  }\n  return maria_write(file, buf);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":234865,"func":"static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)\n{\n\tatomic_inc(&bbio->error);\n\tif (atomic_dec_and_test(&bbio->stripes_pending)) {\n\t\t\/* Should be the original bio. *\/\n\t\tWARN_ON(bio != bbio->orig_bio);\n\n\t\tbtrfs_io_bio(bio)->mirror_num = bbio->mirror_num;\n\t\tbio->bi_iter.bi_sector = logical >> 9;\n\t\tif (atomic_read(&bbio->error) > bbio->max_errors)\n\t\t\tbio->bi_status = BLK_STS_IOERR;\n\t\telse\n\t\t\tbio->bi_status = BLK_STS_OK;\n\t\tbtrfs_end_bbio(bbio, bio);\n\t}\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":230379,"func":"PJ_DEF(int) pj_xml_print(const pj_xml_node *node, char *buf, pj_size_t len,\n\t\t\t pj_bool_t include_prolog)\n{\n    int prolog_len = 0;\n    int printed;\n\n    if (!node || !buf || !len)\n\treturn 0;\n\n    if (include_prolog) {\n\tpj_str_t prolog = {\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\", 39};\n\tif ((int)len < prolog.slen)\n\t    return -1;\n\tpj_memcpy(buf, prolog.ptr, prolog.slen);\n\tprolog_len = (int)prolog.slen;\n    }\n\n    printed = xml_print_node(node, 0, buf+prolog_len, len-prolog_len) + prolog_len;\n    if (printed > 0 && len-printed >= 1) {\n\tbuf[printed++] = '\\n';\n    }\n    return printed;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":441830,"func":"SProcXkbPerClientFlags(ClientPtr client)\n{\n    REQUEST(xkbPerClientFlagsReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);\n    swaps(&stuff->deviceSpec);\n    swapl(&stuff->change);\n    swapl(&stuff->value);\n    swapl(&stuff->ctrlsToChange);\n    swapl(&stuff->autoCtrls);\n    swapl(&stuff->autoCtrlValues);\n    return ProcXkbPerClientFlags(client);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":223429,"func":"static SLJIT_INLINE void set_jumps(jump_list *list, struct sljit_label *label)\n{\nwhile (list)\n  {\n  \/* sljit_set_label is clever enough to do nothing\n  if either the jump or the label is NULL. *\/\n  SET_LABEL(list->jump, label);\n  list = list->next;\n  }\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":291780,"func":"static void free_clt(struct rtrs_clt_sess *clt)\n{\n\tfree_permits(clt);\n\tfree_percpu(clt->pcpu_path);\n\n\t\/*\n\t * release callback will free clt and destroy mutexes in last put\n\t *\/\n\tdevice_unregister(&clt->dev);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":309985,"func":"NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx\n\t\t\t    NCURSES_PAIRS_T pair,\n\t\t\t    NCURSES_COLOR_T f,\n\t\t\t    NCURSES_COLOR_T b)\n{\n    return _nc_init_pair(SP_PARM, pair, f, b);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":338104,"func":"bool WasmBinaryBuilder::maybeVisitRefCast(Expression*& out, uint32_t code) {\n  if (code == BinaryConsts::RefCast) {\n    auto* rtt = popNonVoidExpression();\n    auto* ref = popNonVoidExpression();\n    out = Builder(wasm).makeRefCast(ref, rtt);\n    return true;\n  } else if (code == BinaryConsts::RefCastStatic) {\n    auto intendedType = getIndexedHeapType();\n    auto* ref = popNonVoidExpression();\n    out = Builder(wasm).makeRefCast(ref, intendedType);\n    return true;\n  }\n  return false;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":386485,"func":"void DL_Dxf::writePolylineEnd(DL_WriterA& dw) {\n    if (version==DL_VERSION_2000) {\n    } else {\n        dw.entity(\"SEQEND\");\n    }\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":238771,"func":"fuzzy_match_func_sort(fuzmatch_str_T *fm, int sz)\n{\n    \/\/ Sort the list by the descending order of the match score\n    qsort((void *)fm, (size_t)sz, sizeof(fuzmatch_str_T),\n\t\tfuzzy_match_func_compare);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":270372,"func":"static uint32_t ok_png_get_height_for_pass(const ok_png_decoder *decoder) {\n    const uint32_t h = decoder->png->height;\n    if (decoder->interlace_method == 0) {\n        return h;\n    }\n\n    switch (decoder->interlace_pass) {\n        case 1: return (h + 7) \/ 8;\n        case 2: return (h + 7) \/ 8;\n        case 3: return (h + 3) \/ 8;\n        case 4: return (h + 3) \/ 4;\n        case 5: return (h + 1) \/ 4;\n        case 6: return (h + 1) \/ 2;\n        case 7: return h \/ 2;\n        default: return 0;\n    }\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":222858,"func":"Status GraphProperties::UpdateEnter(SymbolicShapeRefiner* shape_refiner,\n                                    const NodeDef* node, bool* new_shapes) {\n  InferenceContext* ic = shape_refiner->GetContext(node);\n  if (!ic) {\n    TF_RETURN_IF_ERROR(shape_refiner->UpdateNode(node, new_shapes));\n    ic = shape_refiner->GetContext(node);\n  }\n\n  GraphView::InputPort port(node, 0);\n  GraphView::OutputPort fanin = shape_refiner->graph().GetRegularFanin(port);\n\n  InferenceContext* src_ic = shape_refiner->GetContext(fanin.node);\n  ShapeHandle input = src_ic->output(fanin.port_id);\n  if (!ic->output(0).SameHandle(input)) {\n    ic->SetInput(0, input);\n    ic->set_output(0, input);\n    *new_shapes = true;\n  }\n  auto* outputs = src_ic->output_handle_shapes_and_types(fanin.port_id);\n  if (outputs) {\n    ic->set_input_handle_shapes_and_types(0, *outputs);\n    ic->set_output_handle_shapes_and_types(0, *outputs);\n    *new_shapes = true;\n  }\n  return Status::OK();\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":462243,"func":"static void PUTVAL16H(pj_uint8_t *buf, unsigned pos, pj_uint16_t hval)\n{\n    buf[pos+0] = (pj_uint8_t) ((hval & 0xFF00) >> 8);\n    buf[pos+1] = (pj_uint8_t) ((hval & 0x00FF) >> 0);\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":512735,"func":"bool Item_func_case::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)\n{\n  DBUG_ASSERT(fixed == 1);\n  Item *item= find_item();\n  if (!item)\n    return (null_value= true);\n  Datetime_truncation_not_needed dt(thd, item, fuzzydate);\n  return (null_value= dt.copy_to_mysql_time(ltime, mysql_timestamp_type()));\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":512411,"func":"  bool vcol_assignment_allowed_value() const { return vcol_assignment_ok; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":328921,"func":"R_API void r_bin_java_bootstrap_method_argument_free(void \/*RBinJavaBootStrapArgument*\/ *b) {\n\tRBinJavaBootStrapArgument *bsm_arg = b;\n\tif (bsm_arg) {\n\t\tRBinJavaCPTypeMetas *tm = (RBinJavaCPTypeMetas*)bsm_arg->argument_info_cp_obj;\n\t\tif (tm) {\n\t\t\tif (tm && (size_t)(tm->allocs) > 1024 && tm->allocs->delete_obj) {\n\t\t\t\ttm->allocs->delete_obj (tm);\n\t\t\t}\n\t\t\tbsm_arg->argument_info_cp_obj = NULL;\n\t\t}\n\t\tfree (bsm_arg);\n\t}\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":451882,"func":"static uint_fast32_t jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn)\n{\n\tint p;\n\tuint_fast32_t mant;\n\tuint_fast32_t expn;\n\tint n;\n\n\tif (absdelta < 0) {\n\t\treturn UINT_FAST32_MAX;\n\t}\n\n\tp = jpc_fix_firstone(absdelta) - JPC_FIX_FRACBITS;\n\tn = 11 - jpc_fix_firstone(absdelta);\n\tmant = ((n < 0) ? (absdelta >> (-n)) : (absdelta << n)) & 0x7ff;\n\texpn = scaleexpn - p;\n\tif (scaleexpn < p) {\n\t\treturn UINT_FAST32_MAX;\n\t}\n\tif (expn >= 0x1f)\n\t\treturn UINT_FAST32_MAX;\n\treturn JPC_QCX_EXPN(expn) | JPC_QCX_MANT(mant);\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":343325,"func":"static int safe_fd_isset(const int fd, const fd_set * const fds)\n{\n    if (fd == -1) {\n        return 0;\n    }\n    return FD_ISSET(fd, fds);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":226135,"func":"GF_Err dmax_box_size(GF_Box *s)\n{\n\ts->size += 4;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":253590,"func":"smb2_is_status_io_timeout(char *buf)\n{\n\tstruct smb2_hdr *shdr = (struct smb2_hdr *)buf;\n\n\tif (shdr->Status == STATUS_IO_TIMEOUT)\n\t\treturn true;\n\telse\n\t\treturn false;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":282882,"func":"int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word)\n{\n\tstruct rsi_mac_frame *cmd_frame;\n\tstruct sk_buff *skb;\n\n\trsi_dbg(MGMT_TX_ZONE, \"Sending RX filter frame\\n\");\n\n\tskb = dev_alloc_skb(FRAME_DESC_SZ);\n\tif (!skb) {\n\t\trsi_dbg(ERR_ZONE, \"%s: Failed in allocation of skb\\n\",\n\t\t\t__func__);\n\t\treturn -ENOMEM;\n\t}\n\n\tmemset(skb->data, 0, FRAME_DESC_SZ);\n\tcmd_frame = (struct rsi_mac_frame *)skb->data;\n\n\tcmd_frame->desc_word[0] = cpu_to_le16(RSI_WIFI_MGMT_Q << 12);\n\tcmd_frame->desc_word[1] = cpu_to_le16(SET_RX_FILTER);\n\tcmd_frame->desc_word[4] = cpu_to_le16(rx_filter_word);\n\n\tskb_put(skb, FRAME_DESC_SZ);\n\n\treturn rsi_send_internal_mgmt_frame(common, skb);\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":281135,"func":"__xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)\n{\n\tconst struct flowi4 *fl4 = &fl->u.ip4;\n\n\treturn  addr4_match(fl4->daddr, sel->daddr.a4, sel->prefixlen_d) &&\n\t\taddr4_match(fl4->saddr, sel->saddr.a4, sel->prefixlen_s) &&\n\t\t!((xfrm_flowi_dport(fl, &fl4->uli) ^ sel->dport) & sel->dport_mask) &&\n\t\t!((xfrm_flowi_sport(fl, &fl4->uli) ^ sel->sport) & sel->sport_mask) &&\n\t\t(fl4->flowi4_proto == sel->proto || !sel->proto) &&\n\t\t(fl4->flowi4_oif == sel->ifindex || !sel->ifindex);\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":336585,"func":"static red::shared_ptr<RedVDIReadBuf> vdi_read_buf_new(RedCharDeviceVDIPort *dev)\n{\n    auto buf = red::make_shared<RedVDIReadBuf>();\n    buf->dev = dev;\n    return buf;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":310177,"func":"drv_rescol(TERMINAL_CONTROL_BLOCK * TCB)\n{\n    bool result = FALSE;\n    SCREEN *sp;\n\n    AssertTCB();\n    SetSP();\n\n    if (orig_pair != 0) {\n\tNCURSES_PUTP2(\"orig_pair\", orig_pair);\n\tresult = TRUE;\n    }\n    return result;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":369422,"func":"static inline bool __io_fill_cqe_req(struct io_kiocb *req, s32 res, u32 cflags)\n{\n\ttrace_io_uring_complete(req->ctx, req, req->user_data, res, cflags);\n\treturn __io_fill_cqe(req->ctx, req->user_data, res, cflags);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":512763,"func":"  bool val_native_with_conversion_from_item(THD *thd, Item *item, Native *to,\n                                            const Type_handler *handler)\n  {\n    DBUG_ASSERT(is_fixed());\n    return null_value= item->val_native_with_conversion(thd, to, handler);\n  }","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":273931,"func":"static void handle_TYPE(ctrl_t *ctrl, char *argument)\n{\n\tchar type[24]  = \"200 Type set to I.\\r\\n\";\n\tchar unknown[] = \"501 Invalid argument to TYPE.\\r\\n\";\n\n\tif (!argument)\n\t\targument = \"Z\";\n\n\tswitch (argument[0]) {\n\tcase 'A':\n\t\tctrl->type = TYPE_A; \/* ASCII *\/\n\t\tbreak;\n\n\tcase 'I':\n\t\tctrl->type = TYPE_I; \/* IMAGE\/BINARY *\/\n\t\tbreak;\n\n\tdefault:\n\t\tsend_msg(ctrl->sd, unknown);\n\t\treturn;\n\t}\n\n\ttype[16] = argument[0];\n\tsend_msg(ctrl->sd, type);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":386562,"func":"void DL_Dxf::endSequence(DL_CreationInterface* creationInterface) {\n    creationInterface->endSequence();\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":389741,"func":"init_tv(typval_T *varp)\n{\n    if (varp != NULL)\n\tCLEAR_POINTER(varp);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":474070,"func":"koi8_u_is_code_ctype(OnigCodePoint code, unsigned int ctype,\n\t\t     OnigEncoding enc ARG_UNUSED)\n{\n  if (code < 256)\n    return ENC_IS_KOI8_U_CTYPE(code, ctype);\n  else\n    return FALSE;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":346417,"func":"ex_runtime(exarg_T *eap)\n{\n    char_u  *arg = eap->arg;\n    char_u  *p = skiptowhite(arg);\n    int\t    len = (int)(p - arg);\n    int\t    flags = eap->forceit ? DIP_ALL : 0;\n\n    if (STRNCMP(arg, \"START\", len) == 0)\n    {\n\tflags += DIP_START + DIP_NORTP;\n\targ = skipwhite(arg + len);\n    }\n    else if (STRNCMP(arg, \"OPT\", len) == 0)\n    {\n\tflags += DIP_OPT + DIP_NORTP;\n\targ = skipwhite(arg + len);\n    }\n    else if (STRNCMP(arg, \"PACK\", len) == 0)\n    {\n\tflags += DIP_START + DIP_OPT + DIP_NORTP;\n\targ = skipwhite(arg + len);\n    }\n    else if (STRNCMP(arg, \"ALL\", len) == 0)\n    {\n\tflags += DIP_START + DIP_OPT;\n\targ = skipwhite(arg + len);\n    }\n\n    source_runtime(arg, flags);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":512512,"func":"longlong Item_func_between::val_int_cmp_native()\n{\n  THD *thd= current_thd;\n  const Type_handler *h= m_comparator.type_handler();\n  NativeBuffer<STRING_BUFFER_USUAL_SIZE> value, a, b;\n  if (val_native_with_conversion_from_item(thd, args[0], &value, h))\n    return 0;\n  bool ra= args[1]->val_native_with_conversion(thd, &a, h);\n  bool rb= args[2]->val_native_with_conversion(thd, &b, h);\n  if (!ra && !rb)\n    return (longlong)\n      ((h->cmp_native(value, a) >= 0 &&\n        h->cmp_native(value, b) <= 0) != negated);\n  if (ra && rb)\n    null_value= true;\n  else if (ra)\n    null_value= h->cmp_native(value, b) <= 0;\n  else\n    null_value= h->cmp_native(value, a) >= 0;\n  return (longlong) (!null_value && negated);\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":259612,"func":"void HierarchicalBitmapRequester::ResetToStartOfImage(void)\n{\n#if ACCUSOFT_CODE\n  for(UBYTE i = 0;i < m_ucCount;i++) {\n    m_pulY[i] = 0;\n    m_pulReadyLines[i] = 0;\n  }\n  \/\/\n  assert(m_pLargestScale);\n  \/\/ Now iterate through the tree.\n  m_pLargestScale->ResetToStartOfImage();\n#endif\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":313772,"func":"nv_abbrev(cmdarg_T *cap)\n{\n    if (cap->cmdchar == K_DEL || cap->cmdchar == K_KDEL)\n\tcap->cmdchar = 'x';\t\t\/\/ DEL key behaves like 'x'\n\n    \/\/ in Visual mode these commands are operators\n    if (VIsual_active)\n\tv_visop(cap);\n    else\n\tnv_optrans(cap);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":225742,"func":"\nvoid stri_box_del(GF_Box *s)\n{\n\tGF_SubTrackInformationBox *ptr = (GF_SubTrackInformationBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->attribute_list) gf_free(ptr->attribute_list);\n\tgf_free(ptr);","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":477286,"func":"static inline void tipc_crypto_clone_msg(struct net *net, struct sk_buff *_skb,\n\t\t\t\t\t struct tipc_bearer *b,\n\t\t\t\t\t struct tipc_media_addr *dst,\n\t\t\t\t\t struct tipc_node *__dnode, u8 type)\n{\n\tstruct sk_buff *skb;\n\n\tskb = skb_clone(_skb, GFP_ATOMIC);\n\tif (skb) {\n\t\tTIPC_SKB_CB(skb)->xmit_type = type;\n\t\ttipc_crypto_xmit(net, &skb, b, dst, __dnode);\n\t\tif (skb)\n\t\t\tb->media->send_msg(net, skb, b, dst);\n\t}\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":246643,"func":"static GF_Err naludmx_initialize(GF_Filter *filter)\n{\n\tGF_NALUDmxCtx *ctx = gf_filter_get_udta(filter);\n\tctx->sps = gf_list_new();\n\tctx->pps = gf_list_new();\n\tswitch (ctx->nal_length) {\n\tcase 1:\n\t\tctx->max_nalu_size_allowed = 0xFF;\n\t\tbreak;\n\tcase 2:\n\t\tctx->max_nalu_size_allowed = 0xFFFF;\n\t\tbreak;\n\tcase 4:\n\t\tctx->max_nalu_size_allowed = 0xFFFFFFFF;\n\t\tbreak;\n\tcase 0:\n\t\tctx->max_nalu_size_allowed = 0xFFFFFFFF;\n\t\tctx->nal_length = 4;\n\t\tctx->nal_adjusted = GF_TRUE;\n\t\tbreak;\n\tdefault:\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_MEDIA, (\"[%s] NAL size length %d is not allowed, defaulting to 4 bytes\\n\", ctx->log_name));\n\t\tctx->max_nalu_size_allowed = 0xFFFFFFFF;\n\t\tctx->nal_length = 4;\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":512385,"func":"  double val_real()\n  {\n    return has_value() ? Time(this).to_double() : 0;\n  }","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":513362,"func":"bool open_tmp_table(TABLE *table)\n{\n  int error;\n  if ((error= table->file->ha_open(table, table->s->path.str, O_RDWR,\n                                   HA_OPEN_TMP_TABLE |\n                                   HA_OPEN_INTERNAL_TABLE)))\n  {\n    table->file->print_error(error, MYF(0)); \/* purecov: inspected *\/\n    table->db_stat= 0;\n    return 1;\n  }\n  table->db_stat= HA_OPEN_KEYFILE;\n  (void) table->file->extra(HA_EXTRA_QUICK); \/* Faster *\/\n  if (!table->is_created())\n  {\n    table->set_created();\n    table->in_use->inc_status_created_tmp_tables();\n  }\n\n  return 0;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":225870,"func":"GF_Box *ccst_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_CodingConstraintsBox, GF_ISOM_BOX_TYPE_CCST);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":349889,"func":"static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 addr, u32 *p,\n\t\t\t\t\t u32 cnt, enum mcp_area area)\n{\n\tint err = 0;\n\tu32 val;\n\n\terr = readx_poll_timeout_atomic(hw_atl_sem_ram_get, self,\n\t\t\t\t\tval, val == 1U,\n\t\t\t\t\t10U, 100000U);\n\tif (err < 0)\n\t\tgoto err_exit;\n\n\tif (ATL_HW_IS_CHIP_FEATURE(self, REVISION_B1))\n\t\terr = hw_atl_utils_write_b1_mbox(self, addr, p, cnt, area);\n\telse\n\t\terr = hw_atl_utils_write_b0_mbox(self, addr, p, cnt);\n\n\thw_atl_reg_glb_cpu_sem_set(self, 1U, HW_ATL_FW_SM_RAM);\n\n\tif (err < 0)\n\t\tgoto err_exit;\n\n\terr = aq_hw_err_from_flags(self);\n\nerr_exit:\n\treturn err;\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":101695,"func":"void WebProcessProxy::removeMessagePortChannel(uint64_t channelID)\n{\n    if (!isValid())\n        return;\n\n    send(Messages::WebProcess::RemoveMessagePortChannel(channelID), \/* destinationID *\/ 0);\n}\n","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":434085,"func":"alist_add(\n    alist_T\t*al,\n    char_u\t*fname,\n    int\t\tset_fnum)\t\/\/ 1: set buffer number; 2: re-use curbuf\n{\n    if (fname == NULL)\t\t\/\/ don't add NULL file names\n\treturn;\n    if (check_arglist_locked() == FAIL)\n\treturn;\n    arglist_locked = TRUE;\n\n#ifdef BACKSLASH_IN_FILENAME\n    slash_adjust(fname);\n#endif\n    AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname;\n    if (set_fnum > 0)\n\tAARGLIST(al)[al->al_ga.ga_len].ae_fnum =\n\t    buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0));\n    ++al->al_ga.ga_len;\n\n    arglist_locked = FALSE;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":512638,"func":"  With_sum_func_cache(const Item *a, const Item *b, const Item *c,\n                      const Item *d, const Item *e)\n   :m_with_sum_func(a->with_sum_func() || b->with_sum_func() ||\n                    c->with_sum_func() || d->with_sum_func() ||\n                    e->with_sum_func())\n  { }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":328997,"func":"R_API char *r_bin_java_get_utf8_from_cp_item_list(RList *cp_list, ut64 idx) {\n\t\/*\n\tSearch through the Constant Pool list for the given CP Index.\n\tIf the idx not found by directly going to the list index,\n\tthe list will be walked and then the IDX will be checked.\n\trvalue: new char* for caller to free.\n\t*\/\n\tchar *value = NULL;\n\tRListIter *iter;\n\tif (!cp_list) {\n\t\treturn NULL;\n\t}\n\tRBinJavaCPTypeObj *item = (RBinJavaCPTypeObj *) r_list_get_n (cp_list, idx);\n\tif (item && item->tag == R_BIN_JAVA_CP_UTF8 && item->metas->ord == idx) {\n\t\tvalue = convert_string ((const char *) item->info.cp_utf8.bytes, item->info.cp_utf8.length);\n\t}\n\tif (!value) {\n\t\tr_list_foreach (cp_list, iter, item) {\n\t\t\tif (item && (item->tag == R_BIN_JAVA_CP_UTF8) && item->metas->ord == idx) {\n\t\t\t\tvalue = convert_string ((const char *) item->info.cp_utf8.bytes, item->info.cp_utf8.length);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":383368,"func":"gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg)\n{\n  im->saveAlphaFlag = saveAlphaArg;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":430409,"func":"static size_t ovs_nsh_key_attr_size(void)\n{\n\t\/* Whenever adding new OVS_NSH_KEY_ FIELDS, we should consider\n\t * updating this function.\n\t *\/\n\treturn  nla_total_size(NSH_BASE_HDR_LEN) \/* OVS_NSH_KEY_ATTR_BASE *\/\n\t\t\/* OVS_NSH_KEY_ATTR_MD1 and OVS_NSH_KEY_ATTR_MD2 are\n\t\t * mutually exclusive, so the bigger one can cover\n\t\t * the small one.\n\t\t *\/\n\t\t+ nla_total_size(NSH_CTX_HDRS_MAX_LEN);\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":343303,"func":"void donoop(void)\n{\n#ifdef BORING_MODE\n    addreply_noformat(200, \"dc.w $4E71\");\n#else\n    addreply_noformat(200, MSG_SLEEPING);\n#endif\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":244300,"func":"void dfla_box_del(GF_Box *s)\n{\n\tGF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s;\n\tif (ptr->data) gf_free(ptr->data);\n\tgf_free(ptr);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":204495,"func":"static int __io_sync_cancel(struct io_uring_task *tctx,\n\t\t\t    struct io_cancel_data *cd, int fd)\n{\n\tstruct io_ring_ctx *ctx = cd->ctx;\n\n\t\/* fixed must be grabbed every time since we drop the uring_lock *\/\n\tif ((cd->flags & IORING_ASYNC_CANCEL_FD) &&\n\t    (cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {\n\t\tunsigned long file_ptr;\n\n\t\tif (unlikely(fd > ctx->nr_user_files))\n\t\t\treturn -EBADF;\n\t\tfd = array_index_nospec(fd, ctx->nr_user_files);\n\t\tfile_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;\n\t\tcd->file = (struct file *) (file_ptr & FFS_MASK);\n\t\tif (!cd->file)\n\t\t\treturn -EBADF;\n\t}\n\n\treturn __io_async_cancel(cd, tctx, 0);\n}","target":1,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":513156,"func":"bool sys_var_pluginvar::global_update(THD *thd, set_var *var)\n{\n  DBUG_ASSERT(!is_readonly());\n  mysql_mutex_assert_owner(&LOCK_global_system_variables);\n\n  void *tgt= real_value_ptr(thd, OPT_GLOBAL);\n  const void *src= &var->save_result;\n\n  if (!var->value)\n    src= var_def_ptr(plugin_var);\n\n  plugin_var->update(thd, plugin_var, tgt, src);\n  return false;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":387788,"func":"Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {\n  \/\/ search order according to newest JVM spec (5.4.3.2, p.167).\n  \/\/ 1) search for field in current klass\n  if (find_local_field(name, sig, fd)) {\n    return const_cast<InstanceKlass*>(this);\n  }\n  \/\/ 2) search for field recursively in direct superinterfaces\n  { Klass* intf = find_interface_field(name, sig, fd);\n    if (intf != NULL) return intf;\n  }\n  \/\/ 3) apply field lookup recursively if superclass exists\n  { Klass* supr = super();\n    if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, fd);\n  }\n  \/\/ 4) otherwise field lookup fails\n  return NULL;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":391652,"func":"static bool file_has_brlocks(files_struct *fsp)\n{\n\tstruct byte_range_lock *br_lck;\n\n\tbr_lck = brl_get_locks_readonly(fsp);\n\tif (!br_lck)\n\t\treturn false;\n\n\treturn (brl_num_locks(br_lck) > 0);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":272372,"func":"is_valid_cert(CERTCertificate *cert, void *data)\n{\n\tstruct validity_cbdata *cbd = (struct validity_cbdata *)data;\n\tPK11SlotInfo *slot = cbd->slot;\n\tSECKEYPrivateKey *privkey = NULL;\n\tint errnum;\n\n\terrnum = PORT_GetError();\n\tif (errnum == SEC_ERROR_EXTENSION_NOT_FOUND) {\n\t\tdprintf(\"Got SEC_ERROR_EXTENSION_NOT_FOUND; clearing\");\n\t\tPORT_SetError(0);\n\t\terrnum = 0;\n\t}\n\tif (cert == NULL) {\n\t\tif (!errnum)\n\t\t\tPORT_SetError(SEC_ERROR_UNKNOWN_CERT);\n\t\treturn SECFailure;\n\t}\n\n\tprivkey = PK11_FindPrivateKeyFromCert(slot, cert, cbd->cms);\n\tif (privkey != NULL) {\n\t\tif (cbd->cert)\n\t\t\tCERT_DestroyCertificate(cbd->cert);\n\t\tcbd->cert = CERT_DupCertificate(cert);\n\t\tCERT_DestroyCertificate(cert);\n\t\tSECKEY_DestroyPrivateKey(privkey);\n\t\tPORT_SetError(0);\n\t\treturn SECSuccess;\n\t}\n\treturn SECFailure;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":293547,"func":"PJ_DEF(void) pj_scan_restore_state( pj_scanner *scanner, \n\t\t\t\t    pj_scan_state *state)\n{\n    scanner->curptr = state->curptr;\n    scanner->line = state->line;\n    scanner->start_line = state->start_line;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":477802,"func":"static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr)\n{\n\tvoid *ext_hdrs[SADB_EXT_MAX];\n\tint err;\n\n\t\/* Non-zero return value of pfkey_broadcast() does not always signal\n\t * an error and even on an actual error we may still want to process\n\t * the message so rather ignore the return value.\n\t *\/\n\tpfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,\n\t\t\tBROADCAST_PROMISC_ONLY, NULL, sock_net(sk));\n\n\tmemset(ext_hdrs, 0, sizeof(ext_hdrs));\n\terr = parse_exthdrs(skb, hdr, ext_hdrs);\n\tif (!err) {\n\t\terr = -EOPNOTSUPP;\n\t\tif (pfkey_funcs[hdr->sadb_msg_type])\n\t\t\terr = pfkey_funcs[hdr->sadb_msg_type](sk, skb, hdr, ext_hdrs);\n\t}\n\treturn err;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":244338,"func":"GF_Err stsg_box_size(GF_Box *s)\n{\n\tGF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s;\n\tptr->size += 6 + 4 * ptr->nb_groups;\n\treturn GF_OK;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":273927,"func":"static void handle_MKD(ctrl_t *ctrl, char *arg)\n{\n\tchar *path;\n\n\tpath = compose_abspath(ctrl, arg);\n\tif (!path) {\n\t\tINFO(\"Invalid path for %s: %m\", arg);\n\t\tgoto fail;\n\t}\n\n\tif (mkdir(path, 0755)) {\n\t\tif (EPERM == errno)\n\t\tfail:\tsend_msg(ctrl->sd, \"550 Not allowed to create directory.\\r\\n\");\n\t\telse\n\t\t\tsend_msg(ctrl->sd, \"550 Unknown error.\\r\\n\");\n\t\treturn;\n\t}\n\n\tsend_msg(ctrl->sd, \"200 Command OK\\r\\n\");\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":508879,"func":"TABLE_LIST* st_select_lex::get_table_list()\n{\n  return table_list.first;\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":248237,"func":"DLLIMPORT char *cfg_opt_getnstr(cfg_opt_t *opt, unsigned int index)\n{\n\tif (!opt || opt->type != CFGT_STR) {\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tif (opt->values && index < opt->nvalues)\n\t\treturn opt->values[index]->string;\n\tif (opt->simple_value.string)\n\t\treturn *opt->simple_value.string;\n\n\treturn NULL;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":201384,"func":"ga_concat_shorten_esc(garray_T *gap, char_u *str)\n{\n    char_u  *p;\n    char_u  *s;\n    int\t    c;\n    int\t    clen;\n    char_u  buf[NUMBUFLEN];\n    int\t    same_len;\n\n    if (str == NULL)\n    {\n\tga_concat(gap, (char_u *)\"NULL\");\n\treturn;\n    }\n\n    for (p = str; *p != NUL; ++p)\n    {\n\tsame_len = 1;\n\ts = p;\n\tc = mb_ptr2char_adv(&s);\n\tclen = s - p;\n\twhile (*s != NUL && c == mb_ptr2char(s))\n\t{\n\t    ++same_len;\n\t    s += clen;\n\t}\n\tif (same_len > 20)\n\t{\n\t    ga_concat(gap, (char_u *)\"\\\\[\");\n\t    ga_concat_esc(gap, p, clen);\n\t    ga_concat(gap, (char_u *)\" occurs \");\n\t    vim_snprintf((char *)buf, NUMBUFLEN, \"%d\", same_len);\n\t    ga_concat(gap, buf);\n\t    ga_concat(gap, (char_u *)\" times]\");\n\t    p = s - 1;\n\t}\n\telse\n\t    ga_concat_esc(gap, p, clen);\n    }\n}","target":1,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":413691,"func":"static bool esilbreak_mem_write(RAnalEsil *esil, ut64 addr, const ut8 *buf, int len) {\n\thandle_var_stack_access (esil, addr, R_ANAL_VAR_ACCESS_TYPE_WRITE, len);\n\treturn true;\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":90189,"func":"static std::string ToHtmlTableRow(Network* network) {\n  std::string str;\n  if (network->type() == TYPE_WIFI || network->type() == TYPE_CELLULAR) {\n    WirelessNetwork* wireless = static_cast<WirelessNetwork*>(network);\n    str += WrapWithTD(wireless->name()) +\n        WrapWithTD(base::IntToString(wireless->auto_connect())) +\n        WrapWithTD(base::IntToString(wireless->strength()));\n    if (network->type() == TYPE_WIFI) {\n      WifiNetwork* wifi = static_cast<WifiNetwork*>(network);\n      str += WrapWithTD(wifi->GetEncryptionString()) +\n          WrapWithTD(std::string(wifi->passphrase().length(), '*')) +\n          WrapWithTD(wifi->identity()) + WrapWithTD(wifi->cert_path());\n    }\n  }\n  str += WrapWithTD(network->GetStateString()) +\n      WrapWithTD(network->failed() ? network->GetErrorString() : \"\") +\n      WrapWithTD(network->ip_address());\n  return str;\n}\n","target":0,"code_token_length":223,"total_token_length":459,"max_tokens_setting":512}
+{"idx":222920,"func":"DisjointSet<Handle>::GetMergedValue(Handle value) {\n  Rep* rep = Find(value);\n  if (!rep) {\n    \/\/ We don't know anything about this handle.\n    return HandleToObject<Handle>::Unknown();\n  }\n  return rep->value;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":261907,"func":"njs_string_truncate(njs_value_t *value, uint32_t size, uint32_t length)\n{\n    u_char    *dst, *src;\n    uint32_t  n;\n\n    if (size <= NJS_STRING_SHORT) {\n        if (value->short_string.size == NJS_STRING_LONG) {\n            dst = value->short_string.start;\n            src = value->long_string.data->start;\n\n            n = size;\n\n            while (n != 0) {\n                \/* The maximum size is just 14 bytes. *\/\n                njs_pragma_loop_disable_vectorization;\n\n                *dst++ = *src++;\n                n--;\n            }\n        }\n\n        value->short_string.size = size;\n        value->short_string.length = length;\n\n    } else {\n        value->long_string.size = size;\n        value->long_string.data->length = length;\n    }\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":462238,"func":"PJ_DEF(pj_status_t) pj_stun_uint64_attr_create(pj_pool_t *pool,\n\t\t\t\t\t       int attr_type,\n\t\t\t\t\t       const pj_timestamp *value,\n\t\t\t\t\t       pj_stun_uint64_attr **p_attr)\n{\n    pj_stun_uint64_attr *attr;\n\n    PJ_ASSERT_RETURN(pool && p_attr, PJ_EINVAL);\n\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_uint64_attr);\n    INIT_ATTR(attr, attr_type, 8);\n\n    if (value) {\n\tattr->value.u32.hi = value->u32.hi;\n\tattr->value.u32.lo = value->u32.lo;\n    }\n\n    *p_attr = attr;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":275965,"func":"static bitcount_t smax(bitcount_t a, bitcount_t b) {\n    return (a > b ? a : b);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":291789,"func":"static int rtrs_clt_failover_req(struct rtrs_clt_sess *clt,\n\t\t\t\t struct rtrs_clt_io_req *fail_req)\n{\n\tstruct rtrs_clt_path *alive_path;\n\tstruct rtrs_clt_io_req *req;\n\tint err = -ECONNABORTED;\n\tstruct path_it it;\n\n\trcu_read_lock();\n\tfor (path_it_init(&it, clt);\n\t     (alive_path = it.next_path(&it)) && it.i < it.clt->paths_num;\n\t     it.i++) {\n\t\tif (READ_ONCE(alive_path->state) != RTRS_CLT_CONNECTED)\n\t\t\tcontinue;\n\t\treq = rtrs_clt_get_copy_req(alive_path, fail_req);\n\t\tif (req->dir == DMA_TO_DEVICE)\n\t\t\terr = rtrs_clt_write_req(req);\n\t\telse\n\t\t\terr = rtrs_clt_read_req(req);\n\t\tif (err) {\n\t\t\treq->in_use = false;\n\t\t\tcontinue;\n\t\t}\n\t\t\/* Success path *\/\n\t\trtrs_clt_inc_failover_cnt(alive_path->stats);\n\t\tbreak;\n\t}\n\tpath_it_deinit(&it);\n\trcu_read_unlock();\n\n\treturn err;\n}","target":0,"code_token_length":245,"total_token_length":481,"max_tokens_setting":512}
+{"idx":512343,"func":"Item *Item_func_ge::negated_item(THD *thd) \/* a >= b  ->  a < b *\/\n{\n  return new (thd->mem_root) Item_func_lt(thd, args[0], args[1]);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":455319,"func":"split_ignorespec (s, ip)\n     char *s;\n     int *ip;\n{\n  char *t;\n  int n, i;\n\n  if (s == 0)\n    return 0;\n\n  i = *ip;\n  if (s[i] == 0)\n    return 0;\n\n  n = skip_to_delim (s, i, \":\", SD_NOJMP|SD_EXTGLOB|SD_GLOB);\n  t = substring (s, i, n);\n\n  if (s[n] == ':')\n    n++;  \n  *ip = n;  \n  return t;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":356691,"func":"template <class T> void Statement::Error(T* baton) {\n    Statement* stmt = baton->stmt;\n\n    Napi::Env env = stmt->Env();\n    Napi::HandleScope scope(env);\n\n    \/\/ Fail hard on logic errors.\n    assert(stmt->status != 0);\n    EXCEPTION(Napi::String::New(env, stmt->message.c_str()), stmt->status, exception);\n\n    Napi::Function cb = baton->callback.Value();\n\n    if (!cb.IsUndefined() && cb.IsFunction()) {\n        Napi::Value argv[] = { exception };\n        TRY_CATCH_CALL(stmt->Value(), cb, 1, argv);\n    }\n    else {\n        Napi::Value argv[] = { Napi::String::New(env, \"error\"), exception };\n        EMIT_EVENT(stmt->Value(), 2, argv);\n    }\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":512897,"func":"  const Type_handler *real_type_handler() const\n  {\n    if (field->is_created_from_null_item)\n      return &type_handler_null;\n    return field->type_handler();\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":513224,"func":"static void update_func_bool(THD *thd, struct st_mysql_sys_var *var,\n                             void *tgt, const void *save)\n{\n  *(my_bool *) tgt= *(my_bool *) save ? 1 : 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":369251,"func":"static inline bool io_alloc_async_data(struct io_kiocb *req)\n{\n\tWARN_ON_ONCE(!io_op_defs[req->opcode].async_size);\n\treq->async_data = kmalloc(io_op_defs[req->opcode].async_size, GFP_KERNEL);\n\tif (req->async_data) {\n\t\treq->flags |= REQ_F_ASYNC_DATA;\n\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":309833,"func":"failed(const char *msg)\n{\n    fprintf(stderr, \"%s\\n\", msg);\n    ExitProgram(EXIT_FAILURE);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":369144,"func":"\nstatic __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)\n{\n\tunsigned long index;\n\tstruct creds *creds;\n\n\tmutex_lock(&ctx->uring_lock);\n\tpercpu_ref_kill(&ctx->refs);\n\tif (ctx->rings)\n\t\t__io_cqring_overflow_flush(ctx, true);\n\txa_for_each(&ctx->personalities, index, creds)\n\t\tio_unregister_personality(ctx, index);\n\tmutex_unlock(&ctx->uring_lock);\n\n\tio_kill_timeouts(ctx, NULL, true);\n\tio_poll_remove_all(ctx, NULL, true);\n\n\t\/* if we failed setting up the ctx, we might not have any rings *\/\n\tio_iopoll_try_reap_events(ctx);\n\n\tINIT_WORK(&ctx->exit_work, io_ring_exit_work);\n\t\/*\n\t * Use system_unbound_wq to avoid spawning tons of event kworkers\n\t * if we're exiting a ton of rings at the same time. It just adds\n\t * noise and overhead, there's no discernable change in runtime\n\t * over using system_wq.\n\t *\/\n\tqueue_work(system_unbound_wq, &ctx->exit_work);","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":512600,"func":"int Arg_comparator::compare_e_json_str()\n{\n  return compare_e_json_str_basic(*a, *b);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":398503,"func":"static inline ut64 dwarf_read_address(size_t size, bool big_endian, const ut8 **buf, const ut8 *buf_end) {\n\tut64 result;\n\tswitch (size) {\n\tcase 2:\n\t\tresult = READ16(*buf);\n\t\tbreak;\n\tcase 4:\n\t\tresult = READ32(*buf);\n\t\tbreak;\n\tcase 8:\n\t\tresult = READ64(*buf);\n\t\tbreak;\n\tdefault:\n\t\tresult = 0;\n\t\t*buf += size;\n\t\teprintf(\"Weird dwarf address size: %zu.\", size);\n\t}\n\treturn result;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":246697,"func":"u32 parse_base_url(char *arg_val, u32 opt)\n{\n\tmpd_base_urls = gf_realloc(mpd_base_urls, (nb_mpd_base_urls + 1)*sizeof(char**));\n\tif (!mpd_base_urls) return 2;\n\tmpd_base_urls[nb_mpd_base_urls] = arg_val;\n\tnb_mpd_base_urls++;\n\treturn 0;\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":393490,"func":"static SQInteger array_slice(HSQUIRRELVM v)\n{\n    SQInteger sidx,eidx;\n    SQObjectPtr o;\n    if(get_slice_params(v,sidx,eidx,o)==-1)return -1;\n    SQInteger alen = _array(o)->Size();\n    if(sidx < 0)sidx = alen + sidx;\n    if(eidx < 0)eidx = alen + eidx;\n    if(eidx < sidx)return sq_throwerror(v,_SC(\"wrong indexes\"));\n    if(eidx > alen || sidx < 0)return sq_throwerror(v, _SC(\"slice out of range\"));\n    SQArray *arr=SQArray::Create(_ss(v),eidx-sidx);\n    SQObjectPtr t;\n    SQInteger count=0;\n    for(SQInteger i=sidx;i<eidx;i++){\n        _array(o)->Get(i,t);\n        arr->Set(count++,t);\n    }\n    v->Push(arr);\n    return 1;\n\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":512845,"func":"  Item *remove_item_direct_ref()\n  {\n    *ref= (*ref)->remove_item_direct_ref();\n    return this;\n  }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":512828,"func":"  bool save_in_param(THD *thd, Item_param *param)\n  {\n    \/\/ It should not be possible to have \"EXECUTE .. USING DEFAULT(a)\"\n    DBUG_ASSERT(0);\n    param->set_default();\n    return false;\n  }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":333092,"func":"copy_sub_off(regsub_T *to, regsub_T *from)\n{\n    if (to->in_use < from->in_use)\n\tto->in_use = from->in_use;\n    if (from->in_use > 1)\n    {\n\t\/\/ Copy the match start and end positions.\n\tif (REG_MULTI)\n\t    mch_memmove(&to->list.multi[1],\n\t\t\t&from->list.multi[1],\n\t\t\tsizeof(struct multipos) * (from->in_use - 1));\n\telse\n\t    mch_memmove(&to->list.line[1],\n\t\t\t&from->list.line[1],\n\t\t\tsizeof(struct linepos) * (from->in_use - 1));\n    }\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":452990,"func":"static int nft_flow_offload_rule(const struct nft_chain *chain,\n\t\t\t\t struct nft_rule *rule,\n\t\t\t\t struct nft_flow_rule *flow,\n\t\t\t\t enum flow_cls_command command)\n{\n\tstruct flow_cls_offload cls_flow;\n\n\treturn nft_flow_offload_cmd(chain, rule, flow, command, &cls_flow);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":369426,"func":"static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n{\n\tstruct io_sr_msg *sr = &req->sr_msg;\n\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (unlikely(sqe->addr2 || sqe->file_index))\n\t\treturn -EINVAL;\n\n\tsr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));\n\tsr->len = READ_ONCE(sqe->len);\n\tsr->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;\n\tif (sr->msg_flags & MSG_DONTWAIT)\n\t\treq->flags |= REQ_F_NOWAIT;\n\n#ifdef CONFIG_COMPAT\n\tif (req->ctx->compat)\n\t\tsr->msg_flags |= MSG_CMSG_COMPAT;\n#endif\n\treturn 0;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":364751,"func":"tag_full_fname(tagptrs_T *tagp)\n{\n    char_u\t*fullname;\n    int\t\tc;\n\n#ifdef FEAT_EMACS_TAGS\n    if (tagp->is_etag)\n\tc = 0;\t    \/\/ to shut up GCC\n    else\n#endif\n    {\n\tc = *tagp->fname_end;\n\t*tagp->fname_end = NUL;\n    }\n    fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE);\n\n#ifdef FEAT_EMACS_TAGS\n    if (!tagp->is_etag)\n#endif\n\t*tagp->fname_end = c;\n\n    return fullname;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":232302,"func":"u32 gf_isom_sample_get_subsamples_count(GF_ISOFile *movie, u32 track)\n{\n\tGF_TrackBox *trak = gf_isom_get_track_from_file(movie, track);\n\tif (!track) return 0;\n\tif (!trak->Media || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->sub_samples) return 0;\n\treturn gf_list_count(trak->Media->information->sampleTable->sub_samples);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":292186,"func":"void CallInfo::set_virtual(Klass* resolved_klass,\n                           Klass* selected_klass,\n                           const methodHandle& resolved_method,\n                           const methodHandle& selected_method,\n                           int vtable_index, TRAPS) {\n  assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, \"valid index\");\n  assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), \"\");\n  CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call);\n  set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK);\n  assert(!resolved_method->is_compiled_lambda_form(), \"these must be handled via an invokehandle call\");\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":459139,"func":"static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb,\n\t\t\t   u32 seq, u16 flags, int event, bool unicast)\n{\n\tu32 portid = oskb ? NETLINK_CB(oskb).portid : 0;\n\tstruct tcf_block *block = chain->block;\n\tstruct net *net = block->net;\n\tstruct sk_buff *skb;\n\tint err = 0;\n\n\tskb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);\n\tif (!skb)\n\t\treturn -ENOBUFS;\n\n\tif (tc_chain_fill_node(chain->tmplt_ops, chain->tmplt_priv,\n\t\t\t       chain->index, net, skb, block, portid,\n\t\t\t       seq, flags, event) <= 0) {\n\t\tkfree_skb(skb);\n\t\treturn -EINVAL;\n\t}\n\n\tif (unicast)\n\t\terr = rtnl_unicast(skb, net, portid);\n\telse\n\t\terr = rtnetlink_send(skb, net, portid, RTNLGRP_TC,\n\t\t\t\t     flags & NLM_F_ECHO);\n\n\treturn err;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":247601,"func":"TEST_P(SslReadBufferLimitTest, NoLimit) {\n  readBufferLimitTest(0, 256 * 1024, 256 * 1024, 1, false);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":256161,"func":"void wrapper_libxsmm_spmdm_compute_generic_thread(\n    empty_type_wrapper<float>, const libxsmm_spmdm_handle* handle, char transA,\n    char transB, const float* alpha, libxsmm_CSR_sparseslice* A_sparse,\n    const float* B, char transC, const float* beta, float* C, int block_id,\n    int tid, int nthreads) {\n  return libxsmm_spmdm_compute_fp32_thread(handle, transA, transB, alpha,\n                                           A_sparse, B, transC, beta, C,\n                                           block_id, tid, nthreads);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":317347,"func":"static int selinux_inode_symlink(struct inode *dir, struct dentry *dentry, const char *name)\n{\n\treturn may_create(dir, dentry, SECCLASS_LNK_FILE);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":242264,"func":"static int PamLocalCallback(int num_msg,\n#if defined(__sun)\n                            struct pam_message** msgm,\n#else\n                            const struct pam_message** msgm,\n#endif\n                            struct pam_response** response,\n                            void* appdata_ptr)\n{\n  struct pam_response* resp = static_cast<pam_response*>(\n      calloc(num_msg, sizeof(struct pam_response)));\n\n  PamData* pam_data = static_cast<PamData*>(appdata_ptr);\n\n  if (num_msg == 1) {\n    resp[0].resp = strdup(pam_data->passwd_.c_str());\n    resp[0].resp_retcode = 0;\n  }\n\n  *response = resp;\n  return PAM_SUCCESS;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":386488,"func":"void DL_Dxf::addImageDef(DL_CreationInterface* creationInterface) {\n    DL_ImageDefData id(\/\/ handle\n        getStringValue(5, \"\"),\n        getStringValue(1, \"\"));\n\n    creationInterface->linkImage(id);\n    creationInterface->endEntity();\n    currentObjectType = DL_UNKNOWN;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":430361,"func":"void seq_puts(struct seq_file *m, const char *s)\n{\n\tint len = strlen(s);\n\n\tif (m->count + len >= m->size) {\n\t\tseq_set_overflow(m);\n\t\treturn;\n\t}\n\tmemcpy(m->buf + m->count, s, len);\n\tm->count += len;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":220429,"func":"mrb_ary_index_m(mrb_state *mrb, mrb_value self)\n{\n  mrb_value obj = mrb_get_arg1(mrb);\n  mrb_int i;\n\n  for (i = 0; i < RARRAY_LEN(self); i++) {\n    if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {\n      return mrb_int_value(mrb, i);\n    }\n  }\n  return mrb_nil_value();\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":312568,"func":"qf_grow_linebuf(qfstate_T *state, int newsz)\n{\n    char_u\t*p;\n\n    \/\/ If the line exceeds LINE_MAXLEN exclude the last\n    \/\/ byte since it's not a NL character.\n    state->linelen = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz;\n    if (state->growbuf == NULL)\n    {\n\tstate->growbuf = alloc_id(state->linelen + 1, aid_qf_linebuf);\n\tif (state->growbuf == NULL)\n\t    return NULL;\n\tstate->growbufsiz = state->linelen;\n    }\n    else if (state->linelen > state->growbufsiz)\n    {\n\tif ((p = vim_realloc(state->growbuf, state->linelen + 1)) == NULL)\n\t    return NULL;\n\tstate->growbuf = p;\n\tstate->growbufsiz = state->linelen;\n    }\n    return state->growbuf;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":225871,"func":"void trak_box_del(GF_Box *s)\n{\n#ifndef GPAC_DISABLE_ISOM_WRITE\n\tGF_TrackBox *ptr = (GF_TrackBox *)s;\n\tif (ptr->chunk_cache)\n\t\tgf_bs_del(ptr->chunk_cache);\n#endif\n\tgf_free(s);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":336529,"func":"static void pthreads_locking_callback(int mode, int type, const char *file, int line)\n{\n    if (mode & CRYPTO_LOCK) {\n        pthread_mutex_lock(&(lock_cs[type]));\n    } else {\n        pthread_mutex_unlock(&(lock_cs[type]));\n    }\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":487630,"func":"asmlinkage long sys_setdomainname(char __user *name, int len)\n{\n\tint errno;\n\tchar tmp[__NEW_UTS_LEN];\n\n\tif (!capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\tif (len < 0 || len > __NEW_UTS_LEN)\n\t\treturn -EINVAL;\n\n\tdown_write(&uts_sem);\n\terrno = -EFAULT;\n\tif (!copy_from_user(tmp, name, len)) {\n\t\tmemcpy(utsname()->domainname, tmp, len);\n\t\tutsname()->domainname[len] = 0;\n\t\terrno = 0;\n\t}\n\tup_write(&uts_sem);\n\treturn errno;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":369123,"func":"static int io_add_buffers(struct io_ring_ctx *ctx, struct io_provide_buf *pbuf,\n\t\t\t  struct io_buffer_list *bl)\n{\n\tstruct io_buffer *buf;\n\tu64 addr = pbuf->addr;\n\tint i, bid = pbuf->bid;\n\n\tfor (i = 0; i < pbuf->nbufs; i++) {\n\t\tif (list_empty(&ctx->io_buffers_cache) &&\n\t\t    io_refill_buffer_cache(ctx))\n\t\t\tbreak;\n\t\tbuf = list_first_entry(&ctx->io_buffers_cache, struct io_buffer,\n\t\t\t\t\tlist);\n\t\tlist_move_tail(&buf->list, &bl->buf_list);\n\t\tbuf->addr = addr;\n\t\tbuf->len = min_t(__u32, pbuf->len, MAX_RW_COUNT);\n\t\tbuf->bid = bid;\n\t\tbuf->bgid = pbuf->bgid;\n\t\taddr += pbuf->len;\n\t\tbid++;\n\t\tcond_resched();\n\t}\n\n\treturn i ? 0 : -ENOMEM;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":401560,"func":"static void expire_timers(struct timer_base *base, struct hlist_head *head)\n{\n\t\/*\n\t * This value is required only for tracing. base->clk was\n\t * incremented directly before expire_timers was called. But expiry\n\t * is related to the old base->clk value.\n\t *\/\n\tunsigned long baseclk = base->clk - 1;\n\n\twhile (!hlist_empty(head)) {\n\t\tstruct timer_list *timer;\n\t\tvoid (*fn)(struct timer_list *);\n\n\t\ttimer = hlist_entry(head->first, struct timer_list, entry);\n\n\t\tbase->running_timer = timer;\n\t\tdetach_timer(timer, true);\n\n\t\tfn = timer->function;\n\n\t\tif (timer->flags & TIMER_IRQSAFE) {\n\t\t\traw_spin_unlock(&base->lock);\n\t\t\tcall_timer_fn(timer, fn, baseclk);\n\t\t\tbase->running_timer = NULL;\n\t\t\traw_spin_lock(&base->lock);\n\t\t} else {\n\t\t\traw_spin_unlock_irq(&base->lock);\n\t\t\tcall_timer_fn(timer, fn, baseclk);\n\t\t\tbase->running_timer = NULL;\n\t\t\ttimer_sync_wait_running(base);\n\t\t\traw_spin_lock_irq(&base->lock);\n\t\t}\n\t}\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":90787,"func":"void QuotaManager::LazyInitialize() {\n  DCHECK(io_thread_->BelongsToCurrentThread());\n  if (database_.get()) {\n    return;\n  }\n\n  database_.reset(new QuotaDatabase(is_incognito_ ? FilePath() :\n      profile_path_.AppendASCII(kDatabaseName)));\n\n  temporary_usage_tracker_.reset(\n      new UsageTracker(clients_, kStorageTypeTemporary,\n                       special_storage_policy_));\n  persistent_usage_tracker_.reset(\n      new UsageTracker(clients_, kStorageTypePersistent,\n                       special_storage_policy_));\n\n  scoped_refptr<InitializeTask> task(\n      new InitializeTask(this, profile_path_, is_incognito_));\n  task->Start();\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":226160,"func":"GF_Err dimm_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_DIMMBox *ptr = (GF_DIMMBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u64(bs, ptr->nbBytes);\n\treturn GF_OK;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":247745,"func":"  absl::string_view name() override { return \"envoy.tls.cert_validator.default\"; }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":457871,"func":"get_bounding_box (GeglOperation *operation)\n{\n  GeglRectangle result = {0,0,0,0};\n  GeglProperties   *o = GEGL_PROPERTIES (operation);\n  gint width, height;\n\n  load_cache (o);\n\n  g_object_get (o->user_data, \"width\", &width,\n                               \"height\", &height, NULL);\n  result.width  = width;\n  result.height = height;\n  return result;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":459118,"func":"static struct tcf_chain *__tcf_chain_get(struct tcf_block *block,\n\t\t\t\t\t u32 chain_index, bool create,\n\t\t\t\t\t bool by_act)\n{\n\tstruct tcf_chain *chain = NULL;\n\tbool is_first_reference;\n\n\tmutex_lock(&block->lock);\n\tchain = tcf_chain_lookup(block, chain_index);\n\tif (chain) {\n\t\ttcf_chain_hold(chain);\n\t} else {\n\t\tif (!create)\n\t\t\tgoto errout;\n\t\tchain = tcf_chain_create(block, chain_index);\n\t\tif (!chain)\n\t\t\tgoto errout;\n\t}\n\n\tif (by_act)\n\t\t++chain->action_refcnt;\n\tis_first_reference = chain->refcnt - chain->action_refcnt == 1;\n\tmutex_unlock(&block->lock);\n\n\t\/* Send notification only in case we got the first\n\t * non-action reference. Until then, the chain acts only as\n\t * a placeholder for actions pointing to it and user ought\n\t * not know about them.\n\t *\/\n\tif (is_first_reference && !by_act)\n\t\ttc_chain_notify(chain, NULL, 0, NLM_F_CREATE | NLM_F_EXCL,\n\t\t\t\tRTM_NEWCHAIN, false);\n\n\treturn chain;\n\nerrout:\n\tmutex_unlock(&block->lock);\n\treturn chain;\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":312462,"func":"qf_get_next_list_line(qfstate_T *state)\n{\n    listitem_T\t*p_li = state->p_li;\n    int\t\tlen;\n\n    while (p_li != NULL\n\t    && (p_li->li_tv.v_type != VAR_STRING\n\t\t|| p_li->li_tv.vval.v_string == NULL))\n\tp_li = p_li->li_next;\t\/\/ Skip non-string items\n\n    if (p_li == NULL)\t\t\/\/ End of the list\n    {\n\tstate->p_li = NULL;\n\treturn QF_END_OF_INPUT;\n    }\n\n    len = (int)STRLEN(p_li->li_tv.vval.v_string);\n    if (len > IOSIZE - 2)\n    {\n\tstate->linebuf = qf_grow_linebuf(state, len);\n\tif (state->linebuf == NULL)\n\t    return QF_NOMEM;\n    }\n    else\n    {\n\tstate->linebuf = IObuff;\n\tstate->linelen = len;\n    }\n\n    vim_strncpy(state->linebuf, p_li->li_tv.vval.v_string, state->linelen);\n\n    state->p_li = p_li->li_next;\t\/\/ next item\n    return QF_OK;\n}","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":233847,"func":"i64 fmtutil_hlp_get_cul_p(dbuf *f, i64 *ppos)\n{\n\ti64 x1, x2;\n\tx1 = dbuf_getu16le_p(f, ppos);\n\tif(x1%2 == 0) {\n\t\t\/\/ If it's even, divide by two.\n\t\treturn x1>>1;\n\t}\n\t\/\/ If it's odd, divide by two, and add 32768 times the value of\n\t\/\/ the next two bytes.\n\tx2 = dbuf_getu16le_p(f, ppos);\n\treturn (x1>>1) | (x2<<15);\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":427233,"func":"static UnOpr getunopr (int op) {\n  switch (op) {\n    case TK_NOT: return OPR_NOT;\n    case '-': return OPR_MINUS;\n    case '~': return OPR_BNOT;\n    case '#': return OPR_LEN;\n    default: return OPR_NOUNOPR;\n  }\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":238563,"func":"static bool may_be_acquire_function(enum bpf_func_id func_id)\n{\n\treturn func_id == BPF_FUNC_sk_lookup_tcp ||\n\t\tfunc_id == BPF_FUNC_sk_lookup_udp ||\n\t\tfunc_id == BPF_FUNC_skc_lookup_tcp ||\n\t\tfunc_id == BPF_FUNC_map_lookup_elem ||\n\t        func_id == BPF_FUNC_ringbuf_reserve;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":500061,"func":"kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text)\n        {\n\tchar\t**string;\n\n\tif (!kssl_ctx)  return KSSL_CTX_ERR;\n\n\tswitch (which)\n                {\n        case KSSL_SERVICE:\tstring = &kssl_ctx->service_name;\tbreak;\n        case KSSL_SERVER:\tstring = &kssl_ctx->service_host;\tbreak;\n        case KSSL_CLIENT:\tstring = &kssl_ctx->client_princ;\tbreak;\n        case KSSL_KEYTAB:\tstring = &kssl_ctx->keytab_file;\tbreak;\n        default:\t\treturn KSSL_CTX_ERR;\t\t\tbreak;\n\t\t}\n\tif (*string)  kssl_free(*string);\n\n\tif (!text)\n                {\n\t\t*string = '\\0';\n\t\treturn KSSL_CTX_OK;\n\t\t}\n\n\tif ((*string = kssl_calloc(1, strlen(text) + 1)) == NULL)\n\t\treturn KSSL_CTX_ERR;\n\telse\n\t\tstrcpy(*string, text);\n\n\treturn KSSL_CTX_OK;\n        }","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":275969,"func":"const uECC_word_t *uECC_curve_G(uECC_Curve curve) {\n    return curve->G;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":225372,"func":"static int vidioc_s_parm(struct file *file, void *priv,\n\t\t\t struct v4l2_streamparm *parm)\n{\n\tstruct v4l2_loopback_device *dev;\n\tint err = 0;\n\tMARK();\n\n\tdev = v4l2loopback_getdevice(file);\n\tdprintk(\"vidioc_s_parm called frate=%d\/%d\\n\",\n\t\tparm->parm.capture.timeperframe.numerator,\n\t\tparm->parm.capture.timeperframe.denominator);\n\n\tswitch (parm->type) {\n\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n\t\tif ((err = set_timeperframe(\n\t\t\t     dev, &parm->parm.capture.timeperframe)) < 0)\n\t\t\treturn err;\n\t\tbreak;\n\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n\t\tif ((err = set_timeperframe(\n\t\t\t     dev, &parm->parm.capture.timeperframe)) < 0)\n\t\t\treturn err;\n\t\tbreak;\n\tdefault:\n\t\treturn -1;\n\t}\n\n\tparm->parm.capture = dev->capture_param;\n\treturn 0;\n}","target":0,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":512525,"func":"  virtual bool with_subquery() const\n  {\n    return (*ref)->with_subquery();\n  }","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":484063,"func":"setup_secureChannel(void) {\n    TestingPolicy(&dummyPolicy, dummyCertificate, &fCalled, &keySizes);\n    UA_SecureChannel_init(&testChannel, &UA_ConnectionConfig_default);\n    UA_SecureChannel_setSecurityPolicy(&testChannel, &dummyPolicy, &dummyCertificate);\n\n    testingConnection =\n        createDummyConnection(UA_ConnectionConfig_default.sendBufferSize, &sentData);\n    UA_Connection_attachSecureChannel(&testingConnection, &testChannel);\n    testChannel.connection = &testingConnection;\n\n    testChannel.state = UA_SECURECHANNELSTATE_OPEN;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":512478,"func":"Item *and_expressions(THD *thd, Item *a, Item *b, Item **org_item)\n{\n  if (!a)\n    return (*org_item= (Item*) b);\n  if (a == *org_item)\n  {\n    Item_cond *res;\n    if ((res= new (thd->mem_root) Item_cond_and(thd, a, (Item*) b)))\n    {\n      res->used_tables_cache= a->used_tables() | b->used_tables();\n      res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables();\n    }\n    return res;\n  }\n  if (((Item_cond_and*) a)->add((Item*) b, thd->mem_root))\n    return 0;\n  ((Item_cond_and*) a)->used_tables_cache|= b->used_tables();\n  ((Item_cond_and*) a)->not_null_tables_cache|= b->not_null_tables();\n  return a;\n}","target":0,"code_token_length":201,"total_token_length":437,"max_tokens_setting":512}
+{"idx":226408,"func":"\nGF_Err segr_box_size(GF_Box *s)\n{\n\tu32 i;\n\tFDSessionGroupBox *ptr = (FDSessionGroupBox *)s;\n\n\tptr->size += 2;\n\n\tfor (i=0; i<ptr->num_session_groups; i++) {\n\t\tptr->size += 1 + 4*ptr->session_groups[i].nb_groups;\n\t\tptr->size += 2 + 4*ptr->session_groups[i].nb_channels;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":90850,"func":"  void DumpOriginInfoTable() {\n    origin_info_entries_.clear();\n    quota_manager_->DumpOriginInfoTable(\n        callback_factory_.NewCallback(\n             &QuotaManagerTest::DidDumpOriginInfoTable));\n   }\n","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":269306,"func":"static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){\n    if(get_rac(c, state+0))\n        return 0;\n    else{\n        int i, e, a;\n        e= 0;\n        while(get_rac(c, state+1 + FFMIN(e,9))){ \/\/1..10\n            e++;\n        }\n\n        a= 1;\n        for(i=e-1; i>=0; i--){\n            a += a + get_rac(c, state+22 + FFMIN(i,9)); \/\/22..31\n        }\n\n        e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); \/\/11..21\n        return (a^e)-e;\n    }\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":294497,"func":"jd_to_weeknum(VALUE jd, int f, double sg,\n\t      VALUE *nth, int *rjd,\n\t      int *ry, int *rw, int *rd)\n{\n    decode_jd(jd, nth, rjd);\n    c_jd_to_weeknum(*rjd, f, sg, ry, rw, rd);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":317266,"func":"static int selinux_kernel_load_data(enum kernel_load_data_id id, bool contents)\n{\n\tint rc = 0;\n\n\tswitch (id) {\n\tcase LOADING_MODULE:\n\t\trc = selinux_kernel_module_from_file(NULL);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":345220,"func":"static int con_do_clear_unimap(struct vc_data *vc)\n{\n\tstruct uni_pagedir *p, *q;\n\n\tp = *vc->vc_uni_pagedir_loc;\n\tif (!p || --p->refcount) {\n\t\tq = kzalloc(sizeof(*p), GFP_KERNEL);\n\t\tif (!q) {\n\t\t\tif (p)\n\t\t\t\tp->refcount++;\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tq->refcount=1;\n\t\t*vc->vc_uni_pagedir_loc = q;\n\t} else {\n\t\tif (p == dflt) dflt = NULL;\n\t\tp->refcount++;\n\t\tp->sum = 0;\n\t\tcon_release_unimap(p);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":225857,"func":"GF_Box *rely_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_RelyHintBox, GF_ISOM_BOX_TYPE_RELY);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":401520,"func":"static void enqueue_timer(struct timer_base *base, struct timer_list *timer,\n\t\t\t  unsigned int idx)\n{\n\thlist_add_head(&timer->entry, base->vectors + idx);\n\t__set_bit(idx, base->pending_map);\n\ttimer_set_idx(timer, idx);\n\n\ttrace_timer_start(timer, timer->expires, timer->flags);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":513079,"func":"  bool has_int_value() const\n  {\n    return state == SHORT_DATA_VALUE &&\n           value.type_handler()->cmp_type() == INT_RESULT;\n  }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":314532,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_media_remove_attr(pjmedia_sdp_media *m,\n\t\t\t      \t\t\t  pjmedia_sdp_attr *attr)\n{\n    return pjmedia_sdp_attr_remove(&m->attr_count, m->attr, attr);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":244334,"func":"GF_Err bloc_box_size(GF_Box *s)\n{\n\ts->size += 1024;\n\treturn GF_OK;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":254711,"func":"njs_typed_array_compare_f64(const void *a, const void *b, void *c)\n{\n    return njs_typed_array_compare(*(const double *) a, *(const double *) b);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":291822,"func":"static struct rtrs_clt_path *get_next_path_min_inflight(struct path_it *it)\n{\n\tstruct rtrs_clt_path *min_path = NULL;\n\tstruct rtrs_clt_sess *clt = it->clt;\n\tstruct rtrs_clt_path *clt_path;\n\tint min_inflight = INT_MAX;\n\tint inflight;\n\n\tlist_for_each_entry_rcu(clt_path, &clt->paths_list, s.entry) {\n\t\tif (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED)\n\t\t\tcontinue;\n\n\t\tif (!list_empty(raw_cpu_ptr(clt_path->mp_skip_entry)))\n\t\t\tcontinue;\n\n\t\tinflight = atomic_read(&clt_path->stats->inflight);\n\n\t\tif (inflight < min_inflight) {\n\t\t\tmin_inflight = inflight;\n\t\t\tmin_path = clt_path;\n\t\t}\n\t}\n\n\t\/*\n\t * add the path to the skip list, so that next time we can get\n\t * a different one\n\t *\/\n\tif (min_path)\n\t\tlist_add(raw_cpu_ptr(min_path->mp_skip_entry), &it->skip_list);\n\n\treturn min_path;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":353212,"func":"void SplashOutputDev::updateFlatness(GfxState *state) {\n#if 0 \/\/ Acrobat ignores the flatness setting, and always renders curves\n      \/\/ with a fairly small flatness value\n   splash->setFlatness(state->getFlatness());\n#endif\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":294485,"func":"m_cwyear(union DateData *x)\n{\n    int ry, rw, rd;\n\n    c_jd_to_commercial(m_local_jd(x), m_virtual_sg(x), \/* !=m_sg() *\/\n\t\t       &ry, &rw, &rd);\n    return ry;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":294723,"func":"d_lite_julian_p(VALUE self)\n{\n    get_d1(self);\n    return f_boolcast(m_julian_p(dat));\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":227006,"func":"irc_protocol_is_numeric_command (const char *str)\n{\n    while (str && str[0])\n    {\n        if (!isdigit ((unsigned char)str[0]))\n            return 0;\n        str++;\n    }\n    return 1;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":331764,"func":"void QPaintEngineEx::updateState(const QPaintEngineState &)\n{\n    \/\/ do nothing...\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":317349,"func":"static int selinux_socket_recvmsg(struct socket *sock, struct msghdr *msg,\n\t\t\t\t  int size, int flags)\n{\n\treturn sock_has_perm(sock->sk, SOCKET__READ);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":310115,"func":"uses_SGR_39_49(const char *value)\n{\n    return (strstr(value, \"39;49\") != 0\n\t    || strstr(value, \"49;39\") != 0);\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":238634,"func":"void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt,\n\t\t       va_list args)\n{\n\tunsigned int n;\n\n\tn = vscnprintf(log->kbuf, BPF_VERIFIER_TMP_LOG_SIZE, fmt, args);\n\n\tWARN_ONCE(n >= BPF_VERIFIER_TMP_LOG_SIZE - 1,\n\t\t  \"verifier log line truncated - local buffer too short\\n\");\n\n\tif (log->level == BPF_LOG_KERNEL) {\n\t\tbool newline = n > 0 && log->kbuf[n - 1] == '\\n';\n\n\t\tpr_err(\"BPF: %s%s\", log->kbuf, newline ? \"\" : \"\\n\");\n\t\treturn;\n\t}\n\n\tn = min(log->len_total - log->len_used - 1, n);\n\tlog->kbuf[n] = '\\0';\n\tif (!copy_to_user(log->ubuf + log->len_used, log->kbuf, n + 1))\n\t\tlog->len_used += n;\n\telse\n\t\tlog->ubuf = NULL;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":329911,"func":"_cairo_image_compositor_reset_static_data (void)\n{\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":328814,"func":"R_API bool sdb_iterate_build_list(void *user, const char *k, const char *v) {\n\tRList *bin_objs_list = (RList *) user;\n\tsize_t value = (size_t) sdb_atoi (v);\n\tRBinJavaObj *bin_obj = NULL;\n\tIFDBG eprintf (\"Found %s == %\"PFMT64x \" bin_objs db\\n\", k, (ut64) value);\n\tif (value != 0 && value != (size_t) -1) {\n\t\tbin_obj = (RBinJavaObj *) value;\n\t\tr_list_append (bin_objs_list, bin_obj);\n\t}\n\treturn true;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":450424,"func":"static void vnc_tight_start(VncState *vs)\n{\n    buffer_reset(&vs->tight->tight);\n\n    \/\/ make the output buffer be the zlib buffer, so we can compress it later\n    vs->tight->tmp = vs->output;\n    vs->output = vs->tight->tight;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":247580,"func":"  TestUtilOptions& setExpectedServerStats(const std::string& expected_server_stats) {\n    TestUtilOptionsBase::setExpectedServerStats(expected_server_stats);\n    return *this;\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":430466,"func":"gopherTimeout(const CommTimeoutCbParams &io)\n{\n    GopherStateData *gopherState = static_cast<GopherStateData *>(io.data);\n    debugs(10, 4, HERE << io.conn << \": '\" << gopherState->entry->url() << \"'\" );\n\n    gopherState->fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGatewayTimeout, gopherState->fwd->request));\n\n    if (Comm::IsConnOpen(io.conn))\n        io.conn->close();\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":380948,"func":"ins_pageup(void)\n{\n    pos_T\ttpos;\n\n    undisplay_dollar();\n\n    if (mod_mask & MOD_MASK_CTRL)\n    {\n\t\/\/ <C-PageUp>: tab page back\n\tif (first_tabpage->tp_next != NULL)\n\t{\n\t    start_arrow(&curwin->w_cursor);\n\t    goto_tabpage(-1);\n\t}\n\treturn;\n    }\n\n    tpos = curwin->w_cursor;\n    if (onepage(BACKWARD, 1L) == OK)\n    {\n\tstart_arrow(&tpos);\n\tcan_cindent = TRUE;\n    }\n    else\n\tvim_beep(BO_CRSR);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":277003,"func":"fiber_yield(mrb_state *mrb, mrb_value self)\n{\n  const mrb_value *a;\n  mrb_int len;\n\n  mrb_get_args(mrb, \"*!\", &a, &len);\n  return mrb_fiber_yield(mrb, len, a);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":353009,"func":"inValidate(\n\tSyntax *syntax,\n\tstruct berval *in )\n{\n\t\/* no value allowed *\/\n\treturn LDAP_INVALID_SYNTAX;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":405341,"func":"struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,\n\t\t\t      const struct flowi *fl, const struct sock *sk,\n\t\t\t      int flags)\n{\n\treturn xfrm_lookup_with_ifid(net, dst_orig, fl, sk, flags, 0);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":395065,"func":"showruler(int always)\n{\n    if (!always && !redrawing())\n\treturn;\n    if (pum_visible())\n    {\n\t\/\/ Don't redraw right now, do it later.\n\tcurwin->w_redr_status = TRUE;\n\treturn;\n    }\n#if defined(FEAT_STL_OPT)\n    if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)\n\tredraw_custom_statusline(curwin);\n    else\n#endif\n#ifdef FEAT_CMDL_INFO\n\twin_redr_ruler(curwin, always, FALSE);\n#endif\n\n#ifdef FEAT_TITLE\n    if (need_maketitle\n# ifdef FEAT_STL_OPT\n\t    || (p_icon && (stl_syntax & STL_IN_ICON))\n\t    || (p_title && (stl_syntax & STL_IN_TITLE))\n# endif\n       )\n\tmaketitle();\n#endif\n    \/\/ Redraw the tab pages line if needed.\n    if (redraw_tabline)\n\tdraw_tabline();\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":329897,"func":"line_exceeds_16_16 (const cairo_line_t *line)\n{\n    return\n\tline->p1.x <= CAIRO_FIXED_16_16_MIN ||\n\tline->p1.x >= CAIRO_FIXED_16_16_MAX ||\n\n\tline->p2.x <= CAIRO_FIXED_16_16_MIN ||\n\tline->p2.x >= CAIRO_FIXED_16_16_MAX ||\n\n\tline->p1.y <= CAIRO_FIXED_16_16_MIN ||\n\tline->p1.y >= CAIRO_FIXED_16_16_MAX ||\n\n\tline->p2.y <= CAIRO_FIXED_16_16_MIN ||\n\tline->p2.y >= CAIRO_FIXED_16_16_MAX;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":326094,"func":"reginsert_limits(\n    int\t\top,\n    long\tminval,\n    long\tmaxval,\n    char_u\t*opnd)\n{\n    char_u\t*src;\n    char_u\t*dst;\n    char_u\t*place;\n\n    if (regcode == JUST_CALC_SIZE)\n    {\n\tregsize += 11;\n\treturn;\n    }\n    src = regcode;\n    regcode += 11;\n    dst = regcode;\n    while (src > opnd)\n\t*--dst = *--src;\n\n    place = opnd;\t\t\/\/ Op node, where operand used to be.\n    *place++ = op;\n    *place++ = NUL;\n    *place++ = NUL;\n    place = re_put_long(place, (long_u)minval);\n    place = re_put_long(place, (long_u)maxval);\n    regtail(opnd, place);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":314526,"func":"PJ_DEF(pj_status_t) pjmedia_sdp_attr_remove( unsigned *count,\n\t\t\t\t\t     pjmedia_sdp_attr *attr_array[],\n\t\t\t\t\t     pjmedia_sdp_attr *attr )\n{\n    unsigned i, removed=0;\n\n    PJ_ASSERT_RETURN(count && attr_array && attr, PJ_EINVAL);\n    PJ_ASSERT_RETURN(*count <= PJMEDIA_MAX_SDP_ATTR, PJ_ETOOMANY);\n\n    for (i=0; i<*count; ) {\n\tif (attr_array[i] == attr) {\n\t    pj_array_erase(attr_array, sizeof(pjmedia_sdp_attr*),\n\t\t\t   *count, i);\n\t    --(*count);\n\t    ++removed;\n\t} else {\n\t    ++i;\n\t}\n    }\n\n    return removed ? PJ_SUCCESS : PJ_ENOTFOUND;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":230382,"func":"PJ_DEF(void) pj_xml_add_attr( pj_xml_node *node, pj_xml_attr *attr )\n{\n    pj_list_push_back(&node->attr_head, attr);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":230613,"func":"bool PBMotion::operator==(const PBMotion& b) const\n{\n  const PBMotion& a = *this;\n\n  \/\/ TODO: is this really correct? no check for predFlag? Standard says so... (p.127)\n\n  for (int i=0;i<2;i++) {\n    if (a.predFlag[i] != b.predFlag[i]) return false;\n\n    if (a.predFlag[i]) {\n      if (a.mv[i].x != b.mv[i].x) return false;\n      if (a.mv[i].y != b.mv[i].y) return false;\n      if (a.refIdx[i] != b.refIdx[i]) return false;\n    }\n  }\n\n  return true;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":432256,"func":"void address_space_remove_listeners(AddressSpace *as)\n{\n    while (!QTAILQ_EMPTY(&as->listeners)) {\n        memory_listener_unregister(QTAILQ_FIRST(&as->listeners));\n    }\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":441808,"func":"SProcXkbSetControls(ClientPtr client)\n{\n    REQUEST(xkbSetControlsReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbSetControlsReq);\n    swaps(&stuff->deviceSpec);\n    swaps(&stuff->affectInternalVMods);\n    swaps(&stuff->internalVMods);\n    swaps(&stuff->affectIgnoreLockVMods);\n    swaps(&stuff->ignoreLockVMods);\n    swaps(&stuff->axOptions);\n    swapl(&stuff->affectEnabledCtrls);\n    swapl(&stuff->enabledCtrls);\n    swapl(&stuff->changeCtrls);\n    swaps(&stuff->repeatDelay);\n    swaps(&stuff->repeatInterval);\n    swaps(&stuff->slowKeysDelay);\n    swaps(&stuff->debounceDelay);\n    swaps(&stuff->mkDelay);\n    swaps(&stuff->mkInterval);\n    swaps(&stuff->mkTimeToMax);\n    swaps(&stuff->mkMaxSpeed);\n    swaps(&stuff->mkCurve);\n    swaps(&stuff->axTimeout);\n    swapl(&stuff->axtCtrlsMask);\n    swapl(&stuff->axtCtrlsValues);\n    swaps(&stuff->axtOptsMask);\n    swaps(&stuff->axtOptsValues);\n    return ProcXkbSetControls(client);\n}","target":0,"code_token_length":260,"total_token_length":496,"max_tokens_setting":512}
+{"idx":344755,"func":"addargs(arglist *args, char *fmt, ...)\n{\n\tva_list ap;\n\tchar *cp;\n\tu_int nalloc;\n\tint r;\n\n\tva_start(ap, fmt);\n\tr = vasprintf(&cp, fmt, ap);\n\tva_end(ap);\n\tif (r == -1)\n\t\tfatal(\"addargs: argument too long\");\n\n\tnalloc = args->nalloc;\n\tif (args->list == NULL) {\n\t\tnalloc = 32;\n\t\targs->num = 0;\n\t} else if (args->num+2 >= nalloc)\n\t\tnalloc *= 2;\n\n\targs->list = xrecallocarray(args->list, args->nalloc, nalloc, sizeof(char *));\n\targs->nalloc = nalloc;\n\targs->list[args->num++] = cp;\n\targs->list[args->num] = NULL;\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":242619,"func":"  void Compute(OpKernelContext* ctx) override {\n    Buffer* buf = nullptr;\n    OP_REQUIRES_OK(ctx, GetBuffer(ctx, def(), &buf));\n    core::ScopedUnref scope(buf);\n    Buffer::Tuple tuple;\n\n    buf->Get(&tuple);\n\n    OP_REQUIRES(\n        ctx, tuple.size() == (size_t)ctx->num_outputs(),\n        errors::InvalidArgument(\"Mismatch stage\/unstage: \", tuple.size(),\n                                \" vs. \", ctx->num_outputs()));\n\n    for (size_t i = 0; i < tuple.size(); ++i) {\n      ctx->set_output(i, tuple[i]);\n    }\n  }","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":230297,"func":"njs_array_add(njs_vm_t *vm, njs_array_t *array, njs_value_t *value)\n{\n    njs_int_t  ret;\n\n    ret = njs_array_expand(vm, array, 0, 1);\n\n    if (njs_fast_path(ret == NJS_OK)) {\n        \/* GC: retain value. *\/\n        array->start[array->length++] = *value;\n    }\n\n    return ret;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":387863,"func":"JNIid::JNIid(Klass* holder, int offset, JNIid* next) {\n  _holder = holder;\n  _offset = offset;\n  _next = next;\n  debug_only(_is_static_field_id = false;)\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":474027,"func":"get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,\n\t\t     const OnigCodePoint* ranges[], OnigEncoding enc ARG_UNUSED)\n{\n  if (ctype <= ONIGENC_MAX_STD_CTYPE) {\n    return ONIG_NO_SUPPORT_CONFIG;\n  }\n  else {\n    *sb_out = 0x80;\n\n    PROPERTY_LIST_INIT_CHECK;\n\n    ctype -= (ONIGENC_MAX_STD_CTYPE + 1);\n    if (ctype >= (OnigCtype )PropertyListNum)\n      return ONIGERR_TYPE_BUG;\n\n    *ranges = PropertyList[ctype];\n    return 0;\n  }\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":512390,"func":"  int save_in_field(Field *field, bool no_conversions)\n  {\n    DBUG_ASSERT(sane());\n    if (null_value)\n      return set_field_to_null(field);\n    Timestamp_or_zero_datetime_native native(m_value, decimals);\n    return native.save_in_field(field, decimals);\n  }","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":328893,"func":"R_API void r_bin_java_print_local_variable_attr_summary(RBinJavaLocalVariableAttribute *lvattr) {\n\tif (!lvattr) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaLocalVariableAttribute *.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"  Local Variable Attribute offset: 0x%08\"PFMT64x \"\\n\", lvattr->file_offset);\n\tprintf (\"  Local Variable Attribute start_pc: %d\\n\", lvattr->start_pc);\n\tprintf (\"  Local Variable Attribute Length: %d\\n\", lvattr->length);\n\tprintf (\"  Local Variable Attribute name_idx: %d\\n\", lvattr->name_idx);\n\tprintf (\"  Local Variable Attribute name: %s\\n\", lvattr->name);\n\tprintf (\"  Local Variable Attribute descriptor_idx: %d\\n\", lvattr->descriptor_idx);\n\tprintf (\"  Local Variable Attribute descriptor: %s\\n\", lvattr->descriptor);\n\tprintf (\"  Local Variable Attribute index: %d\\n\", lvattr->index);\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":353229,"func":"void SplashOutputDev::updateStrokeOpacity(GfxState *state) {\n  splash->setStrokeAlpha((SplashCoord)state->getStrokeOpacity());\n  if (transpGroupStack != nullptr && (SplashCoord)state->getStrokeOpacity() < transpGroupStack->knockoutOpacity) {\n    transpGroupStack->knockoutOpacity = (SplashCoord)state->getStrokeOpacity();\n  }\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":247645,"func":"  Network::Address::IpVersion version() const { return version_; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":313542,"func":"static int rose_node_show(struct seq_file *seq, void *v)\n{\n\tchar rsbuf[11];\n\tint i;\n\n\tif (v == SEQ_START_TOKEN)\n\t\tseq_puts(seq, \"address    mask n neigh neigh neigh\\n\");\n\telse {\n\t\tconst struct rose_node *rose_node = v;\n\t\tseq_printf(seq, \"%-10s %04d %d\",\n\t\t\t   rose2asc(rsbuf, &rose_node->address),\n\t\t\t   rose_node->mask,\n\t\t\t   rose_node->count);\n\n\t\tfor (i = 0; i < rose_node->count; i++)\n\t\t\tseq_printf(seq, \" %05d\", rose_node->neighbour[i]->number);\n\n\t\tseq_puts(seq, \"\\n\");\n\t}\n\treturn 0;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":512634,"func":"  bool get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode)\n  {\n    return type_handler_year.Item_get_date_with_warn(thd, this, to, mode);\n  }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":310128,"func":"_nc_retrace_unsigned(unsigned code)\n{\n    T((T_RETURN(\"%#x\"), code));\n    return code;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":274685,"func":"callbacks_viewmenu_rendertype_changed (GtkCheckMenuItem *widget, gpointer user_data) {\n\tgerbv_render_types_t type = GPOINTER_TO_INT(user_data);\n\n\tif (type == screenRenderInfo.renderType)\n\t\treturn;\n\n\tdprintf (\"%s():  type = %d\\n\", __FUNCTION__, type);\n\n\tscreenRenderInfo.renderType = type;\n\tcallbacks_render_type_changed ();\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":500078,"func":"print_krb5_keyblock(char *label, krb5_keyblock *keyblk)\n        {\n\tint i;\n\n\tif (keyblk == NULL)\n                {\n\t\tprintf(\"%s, keyblk==0\\n\", label);\n\t\treturn;\n\t\t}\n#ifdef KRB5_HEIMDAL\n\tprintf(\"%s\\n\\t[et%d:%d]: \", label, keyblk->keytype,\n\t\t\t\t\t   keyblk->keyvalue->length);\n\tfor (i=0; i < (int)keyblk->keyvalue->length; i++)\n                {\n\t\tprintf(\"%02x\",(unsigned char *)(keyblk->keyvalue->contents)[i]);\n\t\t}\n\tprintf(\"\\n\");\n#else\n\tprintf(\"%s\\n\\t[et%d:%d]: \", label, keyblk->enctype, keyblk->length);\n\tfor (i=0; i < (int)keyblk->length; i++)\n                {\n\t\tprintf(\"%02x\",keyblk->contents[i]);\n\t\t}\n\tprintf(\"\\n\");\n#endif\n        }","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":366201,"func":"int path_umount(struct path *path, int flags)\n{\n\tstruct mount *mnt = real_mount(path->mnt);\n\tint ret;\n\n\tret = can_umount(path, flags);\n\tif (!ret)\n\t\tret = do_umount(mnt, flags);\n\n\t\/* we mustn't call path_put() as that would clear mnt_expiry_mark *\/\n\tdput(path->dentry);\n\tmntput_no_expire(mnt);\n\treturn ret;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":512705,"func":"  double val_real()\n  {\n    DBUG_ASSERT(0); \/\/ never should be called\n    null_value= true;\n    return 0.0;\n  }","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":261525,"func":"static bool check_buffer(RBinFile *bf, RBuffer *b) {\n\tif (r_buf_size (b) >= 0x20) {\n\t\tut8 magic[4] = {0};\n\t\tif (r_buf_read_at (b, 0, magic, sizeof (magic)) != 4) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !memcmp (magic, \"XALZ\", 4);\n\t}\n\treturn false;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":236129,"func":"GF_Box *tbox_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextBoxBox, GF_ISOM_BOX_TYPE_TBOX);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":246645,"func":"static void naludmx_reset_param_sets(GF_NALUDmxCtx *ctx, Bool do_free)\n{\n\tnaludmx_del_param_list(ctx->sps, do_free);\n\tnaludmx_del_param_list(ctx->pps, do_free);\n\tnaludmx_del_param_list(ctx->vps, do_free);\n\tnaludmx_del_param_list(ctx->sps_ext, do_free);\n\tnaludmx_del_param_list(ctx->pps_svc, do_free);\n\tnaludmx_del_param_list(ctx->vvc_aps_pre, do_free);\n\tnaludmx_del_param_list(ctx->vvc_dci, do_free);\n\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":289286,"func":"static int snd_pcm_hw_param_set(struct snd_pcm_substream *pcm,\n\t\t\t\tstruct snd_pcm_hw_params *params,\n\t\t\t\tsnd_pcm_hw_param_t var, unsigned int val,\n\t\t\t\tint dir)\n{\n\tint changed = _snd_pcm_hw_param_set(params, var, val, dir);\n\tif (changed < 0)\n\t\treturn changed;\n\tif (params->rmask) {\n\t\tint err = snd_pcm_hw_refine(pcm, params);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn snd_pcm_hw_param_value(params, var, NULL);\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":521485,"func":"int ZipFile::getNumEntries() const noexcept\r\n{\r\n    return entries.size();\r\n}\r","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":338098,"func":"void WasmBinaryWriter::writeUserSection(const UserSection& section) {\n  auto start = startSection(BinaryConsts::User);\n  writeInlineString(section.name.c_str());\n  for (size_t i = 0; i < section.data.size(); i++) {\n    o << uint8_t(section.data[i]);\n  }\n  finishSection(start);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":409455,"func":"ansi_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx)\n{\n    if (nr < 16)\n    {\n\t*r = ansi_table[nr][0];\n\t*g = ansi_table[nr][1];\n\t*b = ansi_table[nr][2];\n\t*ansi_idx = nr;\n    }\n    else\n    {\n\t*r = 0;\n\t*g = 0;\n\t*b = 0;\n\t*ansi_idx = ANSI_INDEX_NONE;\n    }\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":233946,"func":"MONGO_COMPILER_NOINLINE void DocumentSourceUnionWith::logShardedViewFound(\n    const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& e) {\n    LOGV2_DEBUG(4556300,\n                3,\n                \"$unionWith found view definition. ns: {ns}, pipeline: {pipeline}. New \"\n                \"$unionWith sub-pipeline: {new_pipe}\",\n                \"ns\"_attr = e->getNamespace(),\n                \"pipeline\"_attr = Value(e->getPipeline()),\n                \"new_pipe\"_attr = _pipeline->serializeToBson());\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":404706,"func":"static unsigned int count_open_files(struct fdtable *fdt)\n{\n\tunsigned int size = fdt->max_fds;\n\tunsigned int i;\n\n\t\/* Find the last open fd *\/\n\tfor (i = size \/ BITS_PER_LONG; i > 0; ) {\n\t\tif (fdt->open_fds[--i])\n\t\t\tbreak;\n\t}\n\ti = (i + 1) * BITS_PER_LONG;\n\treturn i;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":90775,"func":"void QuotaManager::GetLRUOrigin(\n    StorageType type,\n    GetLRUOriginCallback* callback) {\n  LazyInitialize();\n  DCHECK(!lru_origin_callback_.get());\n  lru_origin_callback_.reset(callback);\n  if (db_disabled_) {\n    lru_origin_callback_->Run(GURL());\n    lru_origin_callback_.reset();\n    return;\n  }\n  scoped_refptr<GetLRUOriginTask> task(new GetLRUOriginTask(\n      this, type, origins_in_use_,\n      origins_in_error_, callback_factory_.NewCallback(\n          &QuotaManager::DidGetDatabaseLRUOrigin)));\n  task->Start();\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":437367,"func":"is_left(int a)\n{\n  if (a == ANCHOR_END_BUF  || a == ANCHOR_SEMI_END_BUF ||\n      a == ANCHOR_END_LINE || a == ANCHOR_PREC_READ || a == ANCHOR_PREC_READ_NOT)\n    return 0;\n\n  return 1;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":310116,"func":"save_string(char *d, const char *const s)\n{\n    size_t have = (size_t) (d - my_string);\n    size_t need = have + strlen(s) + 2;\n    if (need > my_length) {\n\tmy_string = (char *) _nc_doalloc(my_string, my_length = (need + need));\n\tif (my_string == 0)\n\t    _nc_err_abort(MSG_NO_MEMORY);\n\td = my_string + have;\n    }\n    _nc_STRCPY(d, s, my_length - have);\n    return d + strlen(d);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":512625,"func":"  int save_in_field(Field *field, bool no_conversions)\n  { return save_date_in_field(field, no_conversions); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":401594,"func":"static void add_interrupt_bench(cycles_t start)\n{\n        long delta = random_get_entropy() - start;\n\n        \/* Use a weighted moving average *\/\n        delta = delta - ((avg_cycles + FIXED_1_2) >> AVG_SHIFT);\n        avg_cycles += delta;\n        \/* And average deviation *\/\n        delta = abs(delta) - ((avg_deviation + FIXED_1_2) >> AVG_SHIFT);\n        avg_deviation += delta;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":291774,"func":"static struct rtrs_clt_path *get_next_path_min_latency(struct path_it *it)\n{\n\tstruct rtrs_clt_path *min_path = NULL;\n\tstruct rtrs_clt_sess *clt = it->clt;\n\tstruct rtrs_clt_path *clt_path;\n\tktime_t min_latency = KTIME_MAX;\n\tktime_t latency;\n\n\tlist_for_each_entry_rcu(clt_path, &clt->paths_list, s.entry) {\n\t\tif (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED)\n\t\t\tcontinue;\n\n\t\tif (!list_empty(raw_cpu_ptr(clt_path->mp_skip_entry)))\n\t\t\tcontinue;\n\n\t\tlatency = clt_path->s.hb_cur_latency;\n\n\t\tif (latency < min_latency) {\n\t\t\tmin_latency = latency;\n\t\t\tmin_path = clt_path;\n\t\t}\n\t}\n\n\t\/*\n\t * add the path to the skip list, so that next time we can get\n\t * a different one\n\t *\/\n\tif (min_path)\n\t\tlist_add(raw_cpu_ptr(min_path->mp_skip_entry), &it->skip_list);\n\n\treturn min_path;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":259207,"func":"static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)\n{\n    MOVStreamContext *sc = st->priv_data;\n    FFStream *const sti = ffstream(st);\n    char buf[AV_TIMECODE_STR_SIZE];\n    int64_t cur_pos = avio_tell(sc->pb);\n    int hh, mm, ss, ff, drop;\n\n    if (!sti->nb_index_entries)\n        return -1;\n\n    avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET);\n    avio_skip(s->pb, 13);\n    hh = avio_r8(s->pb);\n    mm = avio_r8(s->pb);\n    ss = avio_r8(s->pb);\n    drop = avio_r8(s->pb);\n    ff = avio_r8(s->pb);\n    snprintf(buf, AV_TIMECODE_STR_SIZE, \"%02d:%02d:%02d%c%02d\",\n             hh, mm, ss, drop ? ';' : ':', ff);\n    av_dict_set(&st->metadata, \"timecode\", buf, 0);\n\n    avio_seek(sc->pb, cur_pos, SEEK_SET);\n    return 0;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":512711,"func":"bool Item_func_case::aggregate_then_and_else_arguments(THD *thd, uint start)\n{\n  if (aggregate_for_result(func_name(), args + start, arg_count - start, true))\n    return true;\n\n  if (fix_attributes(args + start, arg_count - start))\n    return true;\n\n  return false;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":244242,"func":"GF_Err dmlp_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_TrueHDConfigBox *ptr = (GF_TrueHDConfigBox *)s;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->format_info);\n\tgf_bs_write_int(bs, ptr->peak_data_rate, 15);\n\tgf_bs_write_int(bs, 0, 1);\n\tgf_bs_write_u32(bs, 0);\n\treturn GF_OK;\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":253629,"func":"smb2_is_status_pending(char *buf, struct TCP_Server_Info *server)\n{\n\tstruct smb2_hdr *shdr = (struct smb2_hdr *)buf;\n\tint scredits, in_flight;\n\n\tif (shdr->Status != STATUS_PENDING)\n\t\treturn false;\n\n\tif (shdr->CreditRequest) {\n\t\tspin_lock(&server->req_lock);\n\t\tserver->credits += le16_to_cpu(shdr->CreditRequest);\n\t\tscredits = server->credits;\n\t\tin_flight = server->in_flight;\n\t\tspin_unlock(&server->req_lock);\n\t\twake_up(&server->request_q);\n\n\t\ttrace_smb3_add_credits(server->CurrentMid,\n\t\t\t\tserver->conn_id, server->hostname, scredits,\n\t\t\t\tle16_to_cpu(shdr->CreditRequest), in_flight);\n\t\tcifs_dbg(FYI, \"%s: status pending add %u credits total=%d\\n\",\n\t\t\t\t__func__, le16_to_cpu(shdr->CreditRequest), scredits);\n\t}\n\n\treturn true;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":430365,"func":"static void *single_next(struct seq_file *p, void *v, loff_t *pos)\n{\n\t++*pos;\n\treturn NULL;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":175772,"func":"  explicit DatabaseTaskBase(QuotaManager* manager)\n      : QuotaThreadTask(manager, manager->db_thread_),\n        manager_(manager),\n        database_(manager->database_.get()),\n        db_disabled_(false) {\n    DCHECK(manager_);\n    DCHECK(database_);\n  }\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":512992,"func":"  virtual const longlong *const_ptr_longlong() const { return NULL; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":254026,"func":"static struct v4l2_loopback_device *v4l2loopback_getdevice(struct file *f)\n{\n\tstruct video_device *loopdev = video_devdata(f);\n\tstruct v4l2loopback_private *ptr =\n\t\t(struct v4l2loopback_private *)video_get_drvdata(loopdev);\n\tint nr = ptr->devicenr;\n\n\tif (nr < 0 || nr >= devices) {\n\t\tprintk(KERN_ERR \"v4l2-loopback: illegal device %d\\n\", nr);\n\t\treturn NULL;\n\t}\n\treturn devs[nr];\n}","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":242115,"func":"LuaSettings::LuaSettings(const std::string &filename, bool write_allowed) :\n\tm_filename(filename),\n\tm_is_own_settings(true),\n\tm_write_allowed(write_allowed)\n{\n\tm_settings = new Settings();\n\tm_settings->readConfigFile(filename.c_str());\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":90816,"func":"  CallbackList& callbacks() { return callbacks_; }\n","target":0,"code_token_length":11,"total_token_length":247,"max_tokens_setting":512}
+{"idx":474044,"func":"left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)\n{\n  const UChar *p;\n\n  if (s <= start) return (UChar* )s;\n  p = s;\n\n  while (!emacsmule_islead(*p) && p > start) p--;\n  return (UChar* )p;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":513152,"func":"my_bool mark_changed(int, const struct my_option *opt, char *)\n{\n  if (opt->app_type)\n  {\n    sys_var *var= (sys_var*) opt->app_type;\n    var->value_origin= sys_var::CONFIG;\n  }\n  return 0;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":308188,"func":"static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data,\n\t\t\t\t  int len, void *priv, u32 addr)\n{\n\tstruct fastrpc_channel_ctx *cctx = dev_get_drvdata(&rpdev->dev);\n\tstruct fastrpc_invoke_rsp *rsp = data;\n\tstruct fastrpc_invoke_ctx *ctx;\n\tunsigned long flags;\n\tunsigned long ctxid;\n\n\tif (len < sizeof(*rsp))\n\t\treturn -EINVAL;\n\n\tctxid = ((rsp->ctx & FASTRPC_CTXID_MASK) >> 4);\n\n\tspin_lock_irqsave(&cctx->lock, flags);\n\tctx = idr_find(&cctx->ctx_idr, ctxid);\n\tspin_unlock_irqrestore(&cctx->lock, flags);\n\n\tif (!ctx) {\n\t\tdev_err(&rpdev->dev, \"No context ID matches response\\n\");\n\t\treturn -ENOENT;\n\t}\n\n\tctx->retval = rsp->retval;\n\tcomplete(&ctx->work);\n\n\t\/*\n\t * The DMA buffer associated with the context cannot be freed in\n\t * interrupt context so schedule it through a worker thread to\n\t * avoid a kernel BUG.\n\t *\/\n\tschedule_work(&ctx->put_work);\n\n\treturn 0;\n}","target":0,"code_token_length":250,"total_token_length":486,"max_tokens_setting":512}
+{"idx":326103,"func":"regstack_push(regstate_T state, char_u *scan)\n{\n    regitem_T\t*rp;\n\n    if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)\n    {\n\temsg(_(e_pattern_uses_more_memory_than_maxmempattern));\n\treturn NULL;\n    }\n    if (ga_grow(®stack, sizeof(regitem_T)) == FAIL)\n\treturn NULL;\n\n    rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len);\n    rp->rs_state = state;\n    rp->rs_scan = scan;\n\n    regstack.ga_len += sizeof(regitem_T);\n    return rp;\n}","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":229294,"func":"std::unique_ptr<cql_server::response> cql_server::connection::make_function_failure_error(int16_t stream, exceptions::exception_code err, sstring msg, sstring ks_name, sstring func_name, std::vector<sstring> args, const tracing::trace_state_ptr& tr_state) const\n{\n    auto response = std::make_unique<cql_server::response>(stream, cql_binary_opcode::ERROR, tr_state);\n    response->write_int(static_cast<int32_t>(err));\n    response->write_string(msg);\n    response->write_string(ks_name);\n    response->write_string(func_name);\n    response->write_string_list(args);\n    return response;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":259301,"func":"static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    return mov_read_extradata(c, pb, atom, AV_CODEC_ID_SVQ3);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":512986,"func":"longlong Item_func_regex::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  if ((null_value= re.recompile(args[1])))\n    return 0;\n\n  if ((null_value= re.exec(args[0], 0, 0)))\n    return 0;\n\n  return re.match();\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":432167,"func":"static void listener_add_address_space(MemoryListener *listener,\n                                       AddressSpace *as)\n{\n    FlatView *view;\n    FlatRange *fr;\n\n    if (listener->begin) {\n        listener->begin(listener);\n    }\n\n    view = address_space_get_flatview(as);\n    FOR_EACH_FLAT_RANGE(fr, view) {\n        MemoryRegionSection section = section_from_flat_range(fr, view);\n\n        if (listener->region_add) {\n            listener->region_add(listener, §ion);\n        }\n    }\n    if (listener->commit) {\n        listener->commit(listener);\n    }\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":409474,"func":"tgoto(char *cm, int x, int y)\n{\n    static char buf[30];\n    char *p, *s, *e;\n\n    if (!cm)\n\treturn \"OOPS\";\n    e = buf + 29;\n    for (s = buf; s < e && *cm; cm++)\n    {\n\tif (*cm != '%')\n\t{\n\t    *s++ = *cm;\n\t    continue;\n\t}\n\tswitch (*++cm)\n\t{\n\tcase 'd':\n\t    p = (char *)tltoa((unsigned long)y);\n\t    y = x;\n\t    while (*p)\n\t\t*s++ = *p++;\n\t    break;\n\tcase 'i':\n\t    x++;\n\t    y++;\n\t    break;\n\tcase '+':\n\t    *s++ = (char)(*++cm + y);\n\t    y = x;\n\t    break;\n\tcase '%':\n\t    *s++ = *cm;\n\t    break;\n\tdefault:\n\t    return \"OOPS\";\n\t}\n    }\n    *s = '\\0';\n    return buf;\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":244169,"func":"GF_Box *tref_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackReferenceBox, GF_ISOM_BOX_TYPE_TREF);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":351174,"func":"static double length2d_polyline (int n, const double *x, const double *y) {\n  double length = 0.0;\n  for (int i = 1; i < n; i++) {\n    length += sqrt((x[i] - x[i-1])*(x[i] - x[i-1])\n\t\t   +\n\t\t   (y[i] - y[i-1])*(y[i] - y[i-1]));\n  }\n  return length;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":235645,"func":"static void copy_query(pj_pool_t *pool, pj_dns_parsed_query *dst,\n\t\t       const pj_dns_parsed_query *src,\n\t\t       unsigned *nametable_count,\n\t\t       pj_str_t nametable[])\n{\n    pj_memcpy(dst, src, sizeof(*src));\n    apply_name_table(nametable_count, nametable, &src->name, pool, &dst->name);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":217564,"func":"static inline signed int ReadPropertyMSBLong(const unsigned char **p,\n  size_t *length)\n{\n  union\n  {\n    unsigned int\n      unsigned_value;\n\n    signed int\n      signed_value;\n  } quantum;\n\n  int\n    c;\n\n  ssize_t\n    i;\n\n  unsigned char\n    buffer[4];\n\n  unsigned int\n    value;\n\n  if (*length < 4)\n    return(-1);\n  for (i=0; i < 4; i++)\n  {\n    c=(int) (*(*p)++);\n    (*length)--;\n    buffer[i]=(unsigned char) c;\n  }\n  value=(unsigned int) buffer[0] << 24;\n  value|=(unsigned int) buffer[1] << 16;\n  value|=(unsigned int) buffer[2] << 8;\n  value|=(unsigned int) buffer[3];\n  quantum.unsigned_value=value & 0xffffffff;\n  return(quantum.signed_value);\n}","target":0,"code_token_length":209,"total_token_length":445,"max_tokens_setting":512}
+{"idx":333497,"func":"static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)\n{\n\tconst gdFixed f_127 = gd_itofx(127);\n\tregister int c = src->tpixels[y][x];\n\tc = c | (( (int) (gd_fxtof(gd_mulfx(coverage, f_127)) + 50.5f)) << 24);\n\treturn _color_blend(bgColor, c);\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":498137,"func":"void cgit_print_error(const char *fmt, ...)\n{\n\tva_list ap;\n\tva_start(ap, fmt);\n\tcgit_vprint_error(fmt, ap);\n\tva_end(ap);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":252362,"func":"static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d,\n                                                mz_uint8 lit) {\n  d->m_total_lz_bytes++;\n  *d->m_pLZ_code_buf++ = lit;\n  *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1);\n  if (--d->m_num_flags_left == 0) {\n    d->m_num_flags_left = 8;\n    d->m_pLZ_flags = d->m_pLZ_code_buf++;\n  }\n  d->m_huff_count[0][lit]++;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":405702,"func":"static void xemaclite_adjust_link(struct net_device *ndev)\n{\n\tstruct net_local *lp = netdev_priv(ndev);\n\tstruct phy_device *phy = lp->phy_dev;\n\tint link_state;\n\n\t\/* hash together the state values to decide if something has changed *\/\n\tlink_state = phy->speed | (phy->duplex << 1) | phy->link;\n\n\tif (lp->last_link != link_state) {\n\t\tlp->last_link = link_state;\n\t\tphy_print_status(phy);\n\t}\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":90901,"func":"bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const {\n  return special_storage_policy_.get() &&\n         special_storage_policy_->IsStorageUnlimited(origin);\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":359276,"func":"DEFUN (no_neighbor_description,\n       no_neighbor_description_cmd,\n       NO_NEIGHBOR_CMD2 \"description\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Neighbor specific description\\n\")\n{\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, argv[0]);\n  if (! peer)\n    return CMD_WARNING;\n\n  peer_description_unset (peer);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":359439,"func":"DEFUN (ip_extcommunity_list_name_expanded,\n       ip_extcommunity_list_name_expanded_cmd,\n       \"ip extcommunity-list expanded WORD (deny|permit) .LINE\",\n       IP_STR\n       EXTCOMMUNITY_LIST_STR\n       \"Specify expanded extcommunity-list\\n\"\n       \"Extended Community list name\\n\"\n       \"Specify community to reject\\n\"\n       \"Specify community to accept\\n\"\n       \"An ordered list as a regular-expression\\n\")\n{\n  return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":473908,"func":"utf16le_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end,\n\t\t\t      OnigEncoding enc ARG_UNUSED)\n{\n  if (s <= start) return (UChar* )s;\n\n  if ((s - start) % 2 == 1) {\n    s--;\n  }\n\n  if (UTF16_IS_SURROGATE_SECOND(*(s+1)) && s > start + 1)\n    s -= 2;\n\n  return (UChar* )s;\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":338078,"func":"void WasmBinaryWriter::writeDebugLocation(const Function::DebugLocation& loc) {\n  if (loc == lastDebugLocation) {\n    return;\n  }\n  auto offset = o.size();\n  sourceMapLocations.emplace_back(offset, &loc);\n  lastDebugLocation = loc;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":373538,"func":"ipf_completed_list_add(struct ovs_list *frag_complete_list,\n                       struct ipf_list *ipf_list)\n    \/* OVS_REQUIRES(ipf_lock) *\/\n{\n    ovs_list_push_back(frag_complete_list, &ipf_list->list_node);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":220232,"func":"AttrSlice Node::attrs() const { return AttrSlice(def()); }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":417110,"func":"mp_sint32 PlayerGeneric::getCurrentSamplePosition() const\n{\n\tif (mixer && mixer->getAudioDriver())\n\t\treturn mixer->getAudioDriver()->getBufferPos();\n\t\n\treturn 0;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":224990,"func":"PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)\n{\n\tPQnoticeProcessor old;\n\n\tif (conn == NULL)\n\t\treturn NULL;\n\n\told = conn->noticeHooks.noticeProc;\n\tif (proc)\n\t{\n\t\tconn->noticeHooks.noticeProc = proc;\n\t\tconn->noticeHooks.noticeProcArg = arg;\n\t}\n\treturn old;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":289262,"func":"static const char *strip_task_path(const char *path)\n{\n\tconst char *ptr, *ptrl = NULL;\n\tfor (ptr = path; *ptr; ptr++) {\n\t\tif (*ptr == '\/')\n\t\t\tptrl = ptr + 1;\n\t}\n\treturn ptrl;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":294690,"func":"date_s_strptime(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, fmt, sg;\n\n    rb_scan_args(argc, argv, \"03\", &str, &fmt, &sg);\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"-4712-01-01\");\n      case 1:\n\tfmt = rb_str_new2(\"%F\");\n      case 2:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n\tVALUE argv2[2], hash;\n\n\targv2[0] = str;\n\targv2[1] = fmt;\n\thash = date_s__strptime(2, argv2, klass);\n\treturn d_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":263491,"func":"static int sco_sock_bind(struct socket *sock, struct sockaddr *addr,\n\t\t\t int addr_len)\n{\n\tstruct sockaddr_sco *sa = (struct sockaddr_sco *) addr;\n\tstruct sock *sk = sock->sk;\n\tint err = 0;\n\n\tif (!addr || addr_len < sizeof(struct sockaddr_sco) ||\n\t    addr->sa_family != AF_BLUETOOTH)\n\t\treturn -EINVAL;\n\n\tBT_DBG(\"sk %p %pMR\", sk, &sa->sco_bdaddr);\n\n\tlock_sock(sk);\n\n\tif (sk->sk_state != BT_OPEN) {\n\t\terr = -EBADFD;\n\t\tgoto done;\n\t}\n\n\tif (sk->sk_type != SOCK_SEQPACKET) {\n\t\terr = -EINVAL;\n\t\tgoto done;\n\t}\n\n\tbacpy(&sco_pi(sk)->src, &sa->sco_bdaddr);\n\n\tsk->sk_state = BT_BOUND;\n\ndone:\n\trelease_sock(sk);\n\treturn err;\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":404737,"func":"static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start)\n{\n\tunsigned int maxfd = fdt->max_fds;\n\tunsigned int maxbit = maxfd \/ BITS_PER_LONG;\n\tunsigned int bitbit = start \/ BITS_PER_LONG;\n\n\tbitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG;\n\tif (bitbit > maxfd)\n\t\treturn maxfd;\n\tif (bitbit > start)\n\t\tstart = bitbit;\n\treturn find_next_zero_bit(fdt->open_fds, maxfd, start);\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":409409,"func":"gather_termleader(void)\n{\n    int\t    i;\n    int\t    len = 0;\n\n#ifdef FEAT_GUI\n    if (gui.in_use)\n\ttermleader[len++] = CSI;    \/\/ the GUI codes are not in termcodes[]\n#endif\n#ifdef FEAT_TERMRESPONSE\n    if (check_for_codes || *T_CRS != NUL)\n\ttermleader[len++] = DCS;    \/\/ the termcode response starts with DCS\n\t\t\t\t    \/\/ in 8-bit mode\n#endif\n    termleader[len] = NUL;\n\n    for (i = 0; i < tc_len; ++i)\n\tif (vim_strchr(termleader, termcodes[i].code[0]) == NULL)\n\t{\n\t    termleader[len++] = termcodes[i].code[0];\n\t    termleader[len] = NUL;\n\t}\n\n    need_gather = FALSE;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":301388,"func":"NTSTATUS vfs_default_init(void)\n{\n\treturn smb_register_vfs(SMB_VFS_INTERFACE_VERSION,\n\t\t\t\tDEFAULT_VFS_MODULE_NAME, &vfs_default_fns);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":445901,"func":"open_files_data_ref (OpenFilesData *odata)\n{\n\tg_return_if_fail (odata != NULL);\n\todata->ref_count++;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":387584,"func":"int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)\n{\n\treturn snd_ctl_add_replace(card, kcontrol, CTL_ADD_EXCLUSIVE);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":459018,"func":"http_GetHdrField(const struct http *hp, hdr_t hdr,\n    const char *field, const char **ptr)\n{\n\tconst char *h;\n\tint i;\n\n\tif (ptr != NULL)\n\t\t*ptr = NULL;\n\n\th = NULL;\n\ti = http_GetHdrToken(hp, hdr, field, &h, NULL);\n\tif (!i)\n\t\treturn (i);\n\n\tif (ptr != NULL && h != NULL) {\n\t\t\/* Skip whitespace, looking for '=' *\/\n\t\twhile (*h && vct_issp(*h))\n\t\t\th++;\n\t\tif (*h == '=') {\n\t\t\th++;\n\t\t\twhile (*h && vct_issp(*h))\n\t\t\t\th++;\n\t\t\t*ptr = h;\n\t\t}\n\t}\n\treturn (i);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":450385,"func":"static int vnc_client_read(VncState *vs)\n{\n    size_t ret;\n\n#ifdef CONFIG_VNC_SASL\n    if (vs->sasl.conn && vs->sasl.runSSF)\n        ret = vnc_client_read_sasl(vs);\n    else\n#endif \/* CONFIG_VNC_SASL *\/\n        ret = vnc_client_read_plain(vs);\n    if (!ret) {\n        if (vs->disconnecting) {\n            vnc_disconnect_finish(vs);\n            return -1;\n        }\n        return 0;\n    }\n\n    while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {\n        size_t len = vs->read_handler_expect;\n        int ret;\n\n        ret = vs->read_handler(vs, vs->input.buffer, len);\n        if (vs->disconnecting) {\n            vnc_disconnect_finish(vs);\n            return -1;\n        }\n\n        if (!ret) {\n            buffer_advance(&vs->input, len);\n        } else {\n            vs->read_handler_expect = ret;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":364766,"func":"test_for_current(\n#ifdef FEAT_EMACS_TAGS\n    int\t    is_etag,\n#endif\n    char_u  *fname,\n    char_u  *fname_end,\n    char_u  *tag_fname,\n    char_u  *buf_ffname)\n{\n    int\t    c;\n    int\t    retval = FALSE;\n    char_u  *fullname;\n\n    if (buf_ffname != NULL)\t\/\/ if the buffer has a name\n    {\n#ifdef FEAT_EMACS_TAGS\n\tif (is_etag)\n\t    c = 0;\t    \/\/ to shut up GCC\n\telse\n#endif\n\t{\n\t    c = *fname_end;\n\t    *fname_end = NUL;\n\t}\n\tfullname = expand_tag_fname(fname, tag_fname, TRUE);\n\tif (fullname != NULL)\n\t{\n\t    retval = (fullpathcmp(fullname, buf_ffname, TRUE, TRUE) & FPC_SAME);\n\t    vim_free(fullname);\n\t}\n#ifdef FEAT_EMACS_TAGS\n\tif (!is_etag)\n#endif\n\t    *fname_end = c;\n    }\n\n    return retval;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":356677,"func":"void Statement::Work_BeginEach(Baton* baton) {\n    \/\/ Only create the Async object when we're actually going into\n    \/\/ the event loop. This prevents dangling events.\n    EachBaton* each_baton = static_cast<EachBaton*>(baton);\n    each_baton->async = new Async(each_baton->stmt, reinterpret_cast<uv_async_cb>(AsyncEach));\n    each_baton->async->item_cb.Reset(each_baton->callback.Value(), 1);\n    each_baton->async->completed_cb.Reset(each_baton->completed.Value(), 1);\n\n    STATEMENT_BEGIN(Each);\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":256136,"func":"inline void SparseMatMul<TL, TR>::SliceMatrix(\n    const MatrixR& mat, const int num_rows, const int num_slices,\n    std::vector<typename SparseMatMul<TL, TR>::ConstMatrixMapR*>* slices) {\n  slices->resize(num_slices);\n  DSizes d(num_rows, mat.dimension(1));\n  DCHECK_LE(num_rows * num_slices, mat.dimension(0));\n  for (int i = 0; i < num_slices; ++i) {\n    (*slices)[i] = new ConstMatrixMapR(&mat(i * num_rows, 0), d);\n  }\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":292202,"func":"inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, \n\t\t\t\t\t  char *banner, int rplcode, const message_tags_data *tags_data)\n{\n\tchar *time_str = ctime (&stamp);\n\tserver *serv = sess->server;\n\tchar *nl;\n\n\tif (stamp <= 0)\n\t{\n\t\ttime_str = \"\";\n\t}\n\telse\n\t{\n\t\tif ((nl = strchr (time_str, '\\n')))\n\t\t\t*nl = 0;\n\t}\n\n\tsess = find_channel (serv, chan);\n\tif (!sess)\n\t{\n\t\tsess = serv->front_session;\n\t\tgoto nowindow;\n\t}\n\n\tif (!fe_add_ban_list (sess, mask, banner, time_str, rplcode))\n\t{\nnowindow:\n\n\t\tEMIT_SIGNAL_TIMESTAMP (XP_TE_BANLIST, sess, chan, mask, banner, time_str,\n\t\t\t\t\t\t\t\t\t  0, tags_data->timestamp);\n\t\treturn TRUE;\n\t}\n\n\treturn TRUE;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":236203,"func":"GF_Box *twrp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextWrapBox, GF_ISOM_BOX_TYPE_TWRP);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":262020,"func":"ServiceProtoHandleConnection(ServiceConnection *conn,\n                             ProtoRequest *req)\n{\n   VGAuthError err = VGAUTH_E_OK;\n   VGAuthError err2;\n   gchar *packet;\n   char *event = NULL;\n\n#ifdef _WIN32\n   err = ServiceStartVerifyPid(conn, req->reqData.connect.pid, &event);\n#endif\n\n   if (err != VGAUTH_E_OK) {\n      \/* Value of err is always VGAUTH_E_OK on non-Windows platforms *\/\n      \/* coverity[dead_error_line] *\/\n      packet = Proto_MakeErrorReply(conn, req, err, \"connect failed\");\n   } else {\n      \/* Value of event is always NULL on non-Windows platforms *\/\n      \/* coverity[dead_error_line] *\/\n      packet = g_markup_printf_escaped(VGAUTH_CONNECT_REPLY_FORMAT,\n                                       req->sequenceNumber,\n                                       event ? event : \"\");\n   }\n\n   err2 = ServiceNetworkWriteData(conn, strlen(packet), packet);\n   if (err2 != VGAUTH_E_OK) {\n      Warning(\"%s: failed to send Connect reply\\n\", __FUNCTION__);\n      if (err == VGAUTH_E_OK) {\n         err = err2;\n      }\n   }\n   g_free(packet);\n   g_free(event);\n\n   return err;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":265048,"func":"set_default_colour_sequences(void)\n{\n    fg_bg_sequences[COL_SEQ_FG].start = ztrdup(TC_COL_FG_START);\n    fg_bg_sequences[COL_SEQ_FG].end = ztrdup(TC_COL_FG_END);\n    fg_bg_sequences[COL_SEQ_FG].def = ztrdup(TC_COL_FG_DEFAULT);\n\n    fg_bg_sequences[COL_SEQ_BG].start = ztrdup(TC_COL_BG_START);\n    fg_bg_sequences[COL_SEQ_BG].end = ztrdup(TC_COL_BG_END);\n    fg_bg_sequences[COL_SEQ_BG].def = ztrdup(TC_COL_BG_DEFAULT);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":232345,"func":"GF_TrackBox *gf_isom_get_track_from_file(GF_ISOFile *movie, u32 trackNumber)\n{\n\tGF_TrackBox *trak;\n\tif (!movie) return NULL;\n\ttrak = gf_isom_get_track(movie->moov, trackNumber);\n\tif (!trak) movie->LastError = GF_BAD_PARAM;\n\treturn trak;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":459119,"func":"static bool tcf_proto_cmp(const struct tcf_proto *tp1,\n\t\t\t  const struct tcf_proto *tp2)\n{\n\treturn tp1->chain->index == tp2->chain->index &&\n\t       tp1->prio == tp2->prio &&\n\t       tp1->protocol == tp2->protocol;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":225919,"func":"GF_Err name_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 length;\n\tGF_NameBox *ptr = (GF_NameBox *)s;\n\n\tlength = (u32) (ptr->size);\n\n\tif (length >= (u32)0xFFFFFFFF) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Invalid length %lu in name box\\n\", length));\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\n\tptr->string = (char*)gf_malloc(sizeof(char) * (length+1));\n\tif (! ptr->string) return GF_OUT_OF_MEM;\n\n\tgf_bs_read_data(bs, ptr->string, length);\n\tptr->string[length] = 0;\n\treturn GF_OK;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":359360,"func":"peer_aslist_set_vty (struct vty *vty, const char *ip_str, \n                     afi_t afi, safi_t safi,\n\t\t     const char *name_str, const char *direct_str)\n{\n  int ret;\n  struct peer *peer;\n  int direct = FILTER_IN;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  \/* Check filter direction. *\/\n  if (strncmp (direct_str, \"i\", 1) == 0)\n    direct = FILTER_IN;\n  else if (strncmp (direct_str, \"o\", 1) == 0)\n    direct = FILTER_OUT;\n\n  ret = peer_aslist_set (peer, afi, safi, direct, name_str);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":317206,"func":"static int selinux_secmark_relabel_packet(u32 sid)\n{\n\tconst struct task_security_struct *__tsec;\n\tu32 tsid;\n\n\t__tsec = selinux_cred(current_cred());\n\ttsid = __tsec->sid;\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    tsid, sid, SECCLASS_PACKET, PACKET__RELABELTO,\n\t\t\t    NULL);\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":231662,"func":"  bool getDisableMigration() override {\n    return false;\n  }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":220413,"func":"mrb_ary_reverse(mrb_state *mrb, mrb_value self)\n{\n  struct RArray *a = mrb_ary_ptr(self), *b = ary_new_capa(mrb, ARY_LEN(a));\n  mrb_int len = ARY_LEN(a);\n\n  if (len > 0) {\n    mrb_value *p1, *p2, *e;\n\n    p1 = ARY_PTR(a);\n    e  = p1 + len;\n    p2 = ARY_PTR(b) + len - 1;\n    while (p1 < e) {\n      *p2-- = *p1++;\n    }\n    ARY_SET_LEN(b, len);\n  }\n  return mrb_obj_value(b);\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":436140,"func":"static void io_flush_timeouts(struct io_ring_ctx *ctx)\n{\n\tu32 seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);\n\n\twhile (!list_empty(&ctx->timeout_list)) {\n\t\tu32 events_needed, events_got;\n\t\tstruct io_kiocb *req = list_first_entry(&ctx->timeout_list,\n\t\t\t\t\t\tstruct io_kiocb, timeout.list);\n\n\t\tif (io_is_timeout_noseq(req))\n\t\t\tbreak;\n\n\t\t\/*\n\t\t * Since seq can easily wrap around over time, subtract\n\t\t * the last seq at which timeouts were flushed before comparing.\n\t\t * Assuming not more than 2^31-1 events have happened since,\n\t\t * these subtractions won't have wrapped, so we can check if\n\t\t * target is in [last_seq, current_seq] by comparing the two.\n\t\t *\/\n\t\tevents_needed = req->timeout.target_seq - ctx->cq_last_tm_flush;\n\t\tevents_got = seq - ctx->cq_last_tm_flush;\n\t\tif (events_got < events_needed)\n\t\t\tbreak;\n\n\t\tlist_del_init(&req->timeout.list);\n\t\tio_kill_timeout(req, 0);\n\t}\n\tctx->cq_last_tm_flush = seq;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":222846,"func":"  bool AllOutputShapesKnown(NodeContext* c) {\n    InferenceContext* ic = c->inference_context.get();\n    \/\/ Checks if all the output shapes are fully defined.\n    for (int i = 0; i < ic->num_outputs(); i++) {\n      if (!ic->FullyDefined(ic->output(i))) {\n        return false;\n      }\n    }\n    return true;\n  }","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":220817,"func":"inline int LegacyHowManyThreads(int max_num_threads, int rows, int cols,\n                                int depth) {\n  \/\/ Early-exit in the default case where multi-threading is disabled.\n  if (max_num_threads == 1) {\n    return 1;\n  }\n\n  \/\/ Ensure that each thread has KernelRows rows to process, if at all possible.\n  int thread_count = std::min(max_num_threads, rows \/ KernelRows);\n\n  \/\/ Limit the number of threads according to the overall size of the problem.\n  if (thread_count > 1) {\n    \/\/ Empirically determined value.\n    static constexpr std::uint64_t min_cubic_size_per_thread = 64 * 1024;\n\n    \/\/ We can only multiply two out of three sizes without risking overflow\n    const std::uint64_t cubic_size =\n        std::uint64_t(rows) * std::uint64_t(cols) * std::uint64_t(depth);\n\n    thread_count = std::min(\n        thread_count, static_cast<int>(cubic_size \/ min_cubic_size_per_thread));\n  }\n\n  if (thread_count < 1) {\n    thread_count = 1;\n  }\n\n  assert(thread_count > 0 && thread_count <= max_num_threads);\n  return thread_count;\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":338195,"func":"bool WasmBinaryBuilder::getBasicHeapType(int64_t code, HeapType& out) {\n  switch (code) {\n    case BinaryConsts::EncodedHeapType::func:\n      out = HeapType::func;\n      return true;\n    case BinaryConsts::EncodedHeapType::extern_:\n      out = HeapType::ext;\n      return true;\n    case BinaryConsts::EncodedHeapType::any:\n      out = HeapType::any;\n      return true;\n    case BinaryConsts::EncodedHeapType::eq:\n      out = HeapType::eq;\n      return true;\n    case BinaryConsts::EncodedHeapType::i31:\n      out = HeapType::i31;\n      return true;\n    case BinaryConsts::EncodedHeapType::data:\n      out = HeapType::data;\n      return true;\n    default:\n      return false;\n  }\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":402617,"func":"get_password(FILE *input, FILE *output, char *prompt, PRBool (*ok)(char *))\n{\n\tint infd = fileno(input);\n\tchar phrase[200];\n\tsize_t size = sizeof(phrase);\n\n\tingress();\n\tmemset(phrase, 0, size);\n\n\twhile(true) {\n\t\tint rc;\n\n\t\tprint_prompt(input, output, prompt);\n\t\trc = read_password(input, output, phrase, size);\n\t\tif (rc < 0)\n\t\t\treturn NULL;\n\n\t\tif (!ok)\n\t\t\tbreak;\n\n\t\tif ((*ok)(phrase))\n\t\t\tbreak;\n\n\t\tif (!isatty(infd))\n\t\t\treturn NULL;\n\t\tfprintf(output, \"Password does not meet requirements.\\n\");\n\t\tfflush(output);\n\t}\n\n\tegress();\n\treturn (char *)PORT_Strdup(phrase);\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":270412,"func":"static inline uint32_t ok_inflater_peek_bits(ok_inflater *inflater, unsigned int num_bits) {\n    return inflater->input_buffer & ((1 << num_bits) - 1);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":436057,"func":"\nstatic void io_uring_clean_tctx(struct io_uring_task *tctx)\n{\n\tstruct io_wq *wq = tctx->io_wq;\n\tstruct io_tctx_node *node;\n\tunsigned long index;\n\n\txa_for_each(&tctx->xa, index, node)\n\t\tio_uring_del_tctx_node(index);\n\tif (wq) {\n\t\t\/*\n\t\t * Must be after io_uring_del_task_file() (removes nodes under\n\t\t * uring_lock) to avoid race with io_uring_try_cancel_iowq().\n\t\t *\/\n\t\ttctx->io_wq = NULL;\n\t\tio_wq_put_and_exit(wq);\n\t}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":521496,"func":"ZipFile::OpenStreamCounter::~OpenStreamCounter()\r\n{\r\n    \/* If you hit this assertion, it means you've created a stream to read one of the items in the\r\n       zipfile, but you've forgotten to delete that stream object before deleting the file..\r\n       Streams can't be kept open after the file is deleted because they need to share the input\r\n       stream that is managed by the ZipFile object.\r\n    *\/\r\n    jassert (numOpenStreams == 0);\r\n}\r","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":409417,"func":"check_for_codes_from_term(void)\n{\n    int\t\tc;\n\n    \/\/ If no codes requested or all are answered, no need to wait.\n    if (xt_index_out == 0 || xt_index_out == xt_index_in)\n\treturn;\n\n    \/\/ Vgetc() will check for and handle any response.\n    \/\/ Keep calling vpeekc() until we don't get any responses.\n    ++no_mapping;\n    ++allow_keys;\n    for (;;)\n    {\n\tc = vpeekc();\n\tif (c == NUL)\t    \/\/ nothing available\n\t    break;\n\n\t\/\/ If a response is recognized it's replaced with K_IGNORE, must read\n\t\/\/ it from the input stream.  If there is no K_IGNORE we can't do\n\t\/\/ anything, break here (there might be some responses further on, but\n\t\/\/ we don't want to throw away any typed chars).\n\tif (c != K_SPECIAL && c != K_IGNORE)\n\t    break;\n\tc = vgetc();\n\tif (c != K_IGNORE)\n\t{\n\t    vungetc(c);\n\t    break;\n\t}\n    }\n    --no_mapping;\n    --allow_keys;\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":291825,"func":"static void rtrs_clt_path_down(struct rtrs_clt_path *clt_path)\n{\n\tstruct rtrs_clt_sess *clt = clt_path->clt;\n\n\tif (!clt_path->established)\n\t\treturn;\n\n\tclt_path->established = false;\n\tmutex_lock(&clt->paths_ev_mutex);\n\tWARN_ON(!clt->paths_up);\n\tif (--clt->paths_up == 0)\n\t\tclt->link_ev(clt->priv, RTRS_CLT_LINK_EV_DISCONNECTED);\n\tmutex_unlock(&clt->paths_ev_mutex);\n}","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":293537,"func":"PJ_DEF(int) pj_scan_strcmp( pj_scanner *scanner, const char *s, int len)\n{\n    if (scanner->curptr + len > scanner->end) {\n\tpj_scan_syntax_err(scanner);\n\treturn -1;\n    }\n    return strncmp(scanner->curptr, s, len);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":313857,"func":"nv_normal(cmdarg_T *cap)\n{\n    if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G)\n    {\n\tclearop(cap->oap);\n\tif (restart_edit != 0 && mode_displayed)\n\t    clear_cmdline = TRUE;\t\t\/\/ unshow mode later\n\trestart_edit = 0;\n#ifdef FEAT_CMDWIN\n\tif (cmdwin_type != 0)\n\t    cmdwin_result = Ctrl_C;\n#endif\n\tif (VIsual_active)\n\t{\n\t    end_visual_mode();\t\t\/\/ stop Visual\n\t    redraw_curbuf_later(INVERTED);\n\t}\n\t\/\/ CTRL-\\ CTRL-G restarts Insert mode when 'insertmode' is set.\n\tif (cap->nchar == Ctrl_G && p_im)\n\t    restart_edit = 'a';\n    }\n    else\n\tclearopbeep(cap->oap);\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":436101,"func":"static inline bool __io_cqring_fill_event(struct io_ring_ctx *ctx, u64 user_data,\n\t\t\t\t\t  long res, unsigned int cflags)\n{\n\tstruct io_uring_cqe *cqe;\n\n\ttrace_io_uring_complete(ctx, user_data, res, cflags);\n\n\t\/*\n\t * If we can't get a cq entry, userspace overflowed the\n\t * submission (by quite a lot). Increment the overflow count in\n\t * the ring.\n\t *\/\n\tcqe = io_get_cqe(ctx);\n\tif (likely(cqe)) {\n\t\tWRITE_ONCE(cqe->user_data, user_data);\n\t\tWRITE_ONCE(cqe->res, res);\n\t\tWRITE_ONCE(cqe->flags, cflags);\n\t\treturn true;\n\t}\n\treturn io_cqring_event_overflow(ctx, user_data, res, cflags);\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":276440,"func":"  explicit BoostedTreesDeserializeEnsembleOp(OpKernelConstruction* context)\n      : OpKernel(context) {}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":512743,"func":"longlong Item_func_eq::val_int()\n{\n  DBUG_ASSERT(fixed == 1);\n  int value= cmp.compare();\n  return value == 0 ? 1 : 0;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":225089,"func":"string SummarizeArgs(const protobuf::RepeatedPtrField<OpDef::ArgDef>& args) {\n  string ret;\n  for (const OpDef::ArgDef& arg : args) {\n    if (!ret.empty()) strings::StrAppend(&ret, \", \");\n    strings::StrAppend(&ret, arg.name(), \":\");\n    if (arg.is_ref()) strings::StrAppend(&ret, \"Ref(\");\n    if (!arg.number_attr().empty()) {\n      strings::StrAppend(&ret, arg.number_attr(), \"*\");\n    }\n    if (arg.type() != DT_INVALID) {\n      strings::StrAppend(&ret, DataTypeString(arg.type()));\n    } else {\n      strings::StrAppend(&ret, arg.type_attr());\n    }\n    if (arg.is_ref()) strings::StrAppend(&ret, \")\");\n  }\n  return ret;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":385791,"func":"SYSCALL_DEFINE1(chdir, const char __user *, filename)\n{\n\tstruct path path;\n\tint error;\n\tunsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY;\nretry:\n\terror = user_path_at(AT_FDCWD, filename, lookup_flags, &path);\n\tif (error)\n\t\tgoto out;\n\n\terror = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);\n\tif (error)\n\t\tgoto dput_and_out;\n\n\tset_fs_pwd(current->fs, &path);\n\ndput_and_out:\n\tpath_put(&path);\n\tif (retry_estale(error, lookup_flags)) {\n\t\tlookup_flags |= LOOKUP_REVAL;\n\t\tgoto retry;\n\t}\nout:\n\treturn error;\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":513088,"func":"  bool is_double() const { return m_type == DYN_COL_DOUBLE; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":282985,"func":"LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg,\n\t\t\t\t\t    const char *msg)\n{\n  const char *fname = \"?\";\n  const char *ftype = lj_debug_funcname(L, L->base - 1, &fname);\n  if (narg < 0 && narg > LUA_REGISTRYINDEX)\n    narg = (int)(L->top - L->base) + narg + 1;\n  if (ftype && ftype[3] == 'h' && --narg == 0)  \/* Check for \"method\". *\/\n    msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg);\n  else\n    msg = lj_str_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg);\n  lj_err_callermsg(L, msg);\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":228446,"func":"String WddxPacket::getWddxEncoded(const String& varType,\n                                  const String& varValue,\n                                  const String& varName,\n                                  bool hasVarTag) {\n  if (varType.compare(\"NULL\") == 0 || varType.compare(\"null\") == 0) {\n    return wrapValue(\"<null\/>\", \"\", \"\", varName, hasVarTag);\n  }\n  if (varType.compare(\"boolean\") == 0) {\n    return wrapValue(\"<boolean value='\", \"'\/>\", varValue, varName, hasVarTag);\n  }\n  if (varType.compare(\"integer\") == 0 || varType.compare(\"double\") == 0) {\n    return wrapValue(\"<number>\", \"<\/number>\", varValue, varName, hasVarTag);\n  }\n  if (varType.compare(\"string\") == 0) {\n    return wrapValue(\"<string>\", \"<\/string>\", varValue, varName, hasVarTag);\n  }\n  return \"\";\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":246729,"func":"u32 parse_bs_switch(char *arg_val, u32 opt)\n{\n\tif (!stricmp(arg_val, \"no\") || !stricmp(arg_val, \"off\")) bitstream_switching_mode = GF_DASH_BSMODE_NONE;\n\telse if (!stricmp(arg_val, \"merge\"))  bitstream_switching_mode = GF_DASH_BSMODE_MERGED;\n\telse if (!stricmp(arg_val, \"multi\"))  bitstream_switching_mode = GF_DASH_BSMODE_MULTIPLE_ENTRIES;\n\telse if (!stricmp(arg_val, \"single\"))  bitstream_switching_mode = GF_DASH_BSMODE_SINGLE;\n\telse if (!stricmp(arg_val, \"inband\"))  bitstream_switching_mode = GF_DASH_BSMODE_INBAND;\n\telse {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Unrecognized bitstream switching mode \\\"%s\\\" - please check usage\\n\", arg_val));\n\t\treturn 2;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":404709,"func":"unsigned long __fdget(unsigned int fd)\n{\n\treturn __fget_light(fd, FMODE_PATH);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":353224,"func":"SplashFunctionPattern::~SplashFunctionPattern() {\n}","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":512983,"func":"Item_bool_rowready_func2* Eq_creator::create_swap(THD *thd, Item *a, Item *b) const\n{\n  return new(thd->mem_root) Item_func_eq(thd, b, a);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":273090,"func":"keyval_get(struct keyval *kv, const char *name)\n{\n  struct onekeyval *okv;\n\n  if (!kv)\n    return NULL;\n\n  for (okv = kv->head; okv; okv = okv->next)\n    {\n      if (strcasecmp(okv->name, name) == 0)\n        return okv->value;\n    }\n\n  return NULL;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":101661,"func":"bool WebProcessProxy::checkURLReceivedFromWebProcess(const KURL& url)\n{\n\n    if (!url.isLocalFile())\n        return true;\n\n    if (m_mayHaveUniversalFileReadSandboxExtension)\n        return true;\n\n    String path = url.fileSystemPath();\n    for (HashSet<String>::const_iterator iter = m_localPathsWithAssumedReadAccess.begin(); iter != m_localPathsWithAssumedReadAccess.end(); ++iter) {\n        if (path.startsWith(*iter))\n            return true;\n    }\n\n    for (WebBackForwardListItemMap::iterator iter = m_backForwardListItemMap.begin(), end = m_backForwardListItemMap.end(); iter != end; ++iter) {\n        if (KURL(KURL(), iter->value->url()).fileSystemPath() == path)\n            return true;\n        if (KURL(KURL(), iter->value->originalURL()).fileSystemPath() == path)\n            return true;\n    }\n\n    WTFLogAlways(\"Received an unexpected URL from the web process: '%s'\\n\", url.string().utf8().data());\n    return false;\n}\n","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":473825,"func":"gbk_is_mbc_ambiguous(OnigCaseFoldType flag,\n\t\t       const UChar** pp, const UChar* end, OnigEncoding enc)\n{\n  return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":215391,"func":"static sctp_disposition_t sctp_sf_violation_paramlen(\n\t\t\t\t     const struct sctp_endpoint *ep,\n\t\t\t\t     const struct sctp_association *asoc,\n\t\t\t\t     const sctp_subtype_t type,\n\t\t\t\t     void *arg,\n\t\t\t\t     sctp_cmd_seq_t *commands) {\n\tstatic const char err_str[] = \"The following parameter had invalid length:\";\n\n\treturn sctp_sf_abort_violation(ep, asoc, arg, commands, err_str,\n\t\t\t\t\tsizeof(err_str));\n}","target":1,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":270919,"func":"  ::tensorflow::Status WriteSplits(\n      const std::vector<std::vector<SPLITS_TYPE>>& out_splits,\n      OpKernelContext* context) {\n    OpOutputList splits_out;\n    TF_RETURN_IF_ERROR(\n        context->output_list(\"output_nested_splits\", &splits_out));\n    for (int i = 0; i < out_splits.size(); ++i) {\n      Tensor* splits;\n      SPLITS_TYPE num_splits = out_splits[i].size();\n      TF_RETURN_IF_ERROR(\n          splits_out.allocate(i, TensorShape({num_splits}), &splits));\n      auto splits_flat = splits->flat<SPLITS_TYPE>();\n      std::copy_n(out_splits[i].data(), out_splits[i].size(),\n                  splits_flat.data());\n    }\n    return ::tensorflow::Status::OK();\n  }","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":212152,"func":"disable_priv_mode ()\n{\n  int e;\n\n  if (setuid (current_user.uid) < 0)\n    {\n      e = errno;\n      sys_error (_(\"cannot set uid to %d: effective uid %d\"), current_user.uid, current_user.euid);\n#if defined (EXIT_ON_SETUID_FAILURE)\n      if (e == EAGAIN)\n\texit (e);\n#endif\n    }\n  if (setgid (current_user.gid) < 0)\n    sys_error (_(\"cannot set gid to %d: effective gid %d\"), current_user.gid, current_user.egid);\n\n  current_user.euid = current_user.uid;\n  current_user.egid = current_user.gid;\n}","target":1,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":274686,"func":"callbacks_show_cross_on_drill_holes (GtkMenuItem *menuitem, gpointer user_data)\n{\n\tscreenRenderInfo.show_cross_on_drill_holes = GTK_CHECK_MENU_ITEM(menuitem)->active;\n\trender_refresh_rendered_image_on_screen();\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":328896,"func":"R_API char *r_bin_java_get_item_name_from_bin_cp_list(RBinJavaObj *bin, RBinJavaCPTypeObj *obj) {\n\tchar *res = NULL;\n\t\/*\n\tGiven a constant pool object Class, FieldRef, MethodRef, or InterfaceMethodRef\n\treturn the actual descriptor string.\n\t@param cp_list: RList of RBinJavaCPTypeObj *\n\t@param obj object to look up the name for\n\t@rvalue char* (user frees) or NULL\n\t*\/\n\tif (bin && obj) {\n\t\tres = r_bin_java_get_item_name_from_cp_item_list (\n\t\t\tbin->cp_list, obj, MAX_CPITEMS);\n\t}\n\treturn res;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":230296,"func":"njs_array_length_redefine(njs_vm_t *vm, njs_value_t *value, uint32_t length)\n{\n    njs_object_prop_t  *prop;\n\n    static const njs_value_t  string_length = njs_string(\"length\");\n\n    if (njs_slow_path(!njs_is_array(value))) {\n        njs_internal_error(vm, \"njs_array_length_redefine() \"\n                           \"applied to non-array\");\n        return NJS_ERROR;\n    }\n\n    prop = njs_object_property_add(vm, value, njs_value_arg(&string_length), 1);\n    if (njs_slow_path(prop == NULL)) {\n        njs_internal_error(vm, \"njs_array_length_redefine() \"\n                           \"cannot redefine \\\"length\\\"\");\n        return NJS_ERROR;\n    }\n\n    prop->enumerable = 0;\n    prop->configurable = 0;\n\n    njs_value_number_set(&prop->value, length);\n\n    return NJS_OK;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":314764,"func":"_cdf_tole2(uint16_t sv)\n{\n\tuint16_t rv;\n\tuint8_t *s = (uint8_t *)(void *)&sv;\n\tuint8_t *d = (uint8_t *)(void *)&rv;\n\td[0] = s[1];\n\td[1] = s[0];\n\treturn rv;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":344797,"func":"atoi_err(const char *nptr, int *val)\n{\n\tconst char *errstr = NULL;\n\tlong long num;\n\n\tif (nptr == NULL || *nptr == '\\0')\n\t\treturn \"missing\";\n\tnum = strtonum(nptr, 0, INT_MAX, &errstr);\n\tif (errstr == NULL)\n\t\t*val = (int)num;\n\treturn errstr;\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":356702,"func":"Napi::Value Statement::Each(const Napi::CallbackInfo& info) {\n    Napi::Env env = info.Env();\n    Statement* stmt = this;\n\n    int last = info.Length();\n\n    Napi::Function completed;\n    if (last >= 2 && info[last - 1].IsFunction() && info[last - 2].IsFunction()) {\n        completed = info[--last].As<Napi::Function>();\n    }\n\n    EachBaton* baton = stmt->Bind<EachBaton>(info, 0, last);\n    if (baton == NULL) {\n        Napi::Error::New(env, \"Data type is not supported\").ThrowAsJavaScriptException();\n        return env.Null();\n    }\n    else {\n        baton->completed.Reset(completed, 1);\n        stmt->Schedule(Work_BeginEach, baton);\n        return info.This();\n    }\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":246209,"func":"Status RaggedCountSparseOutputShapeFn(InferenceContext *c) {\n  int32_t rank = c->Rank(c->input(1));\n  if (rank != c->kUnknownRank) {\n    ++rank;  \/\/ Add the ragged dimension\n  }\n  auto nvals = c->UnknownDim();\n  c->set_output(0, c->Matrix(nvals, rank));  \/\/ out.indices\n  c->set_output(1, c->Vector(nvals));        \/\/ out.values\n  c->set_output(2, c->Vector(rank));         \/\/ out.dense_shape\n  return Status::OK();\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":328935,"func":"R_API ut8 *r_bin_java_get_attr_buf(RBinJavaObj *bin, ut64 sz, const ut64 offset, const ut8 *buf, const ut64 len) {\n\t\/\/ XXX this pending is wrong and too expensive\n\tint pending = len - offset;\n\tconst ut8 *a_buf = offset + buf;\n\tut8 *attr_buf = (ut8 *) calloc (pending + 1, 1);\n\tif (!attr_buf) {\n\t\teprintf (\"Unable to allocate enough bytes (0x%04\"PFMT64x\n\t\t\t\") to read in the attribute.\\n\", sz);\n\t\treturn attr_buf;\n\t}\n\tmemcpy (attr_buf, a_buf, pending); \/\/ sz+1);\n\treturn attr_buf;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":512485,"func":"bool Item_func_truth::val_bool()\n{\n  bool val= args[0]->val_bool();\n  if (args[0]->null_value)\n  {\n    \/*\n      NULL val IS {TRUE, FALSE} --> FALSE\n      NULL val IS NOT {TRUE, FALSE} --> TRUE\n    *\/\n    return (! affirmative);\n  }\n\n  if (affirmative)\n  {\n    \/* {TRUE, FALSE} val IS {TRUE, FALSE} value *\/\n    return (val == value);\n  }\n\n  \/* {TRUE, FALSE} val IS NOT {TRUE, FALSE} value *\/\n  return (val != value);\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":474081,"func":"st_strncasecmp(const char *s1, const char *s2, size_t n)\n{\n    unsigned int c1, c2;\n\n    while (n--) {\n        c1 = (unsigned char)*s1++;\n        c2 = (unsigned char)*s2++;\n        if (c1 == '\\0' || c2 == '\\0') {\n            if (c1 != '\\0') return 1;\n            if (c2 != '\\0') return -1;\n            return 0;\n        }\n        if ((unsigned int)(c1 - 'A') <= ('Z' - 'A')) c1 += 'a' - 'A';\n        if ((unsigned int)(c2 - 'A') <= ('Z' - 'A')) c2 += 'a' - 'A';\n        if (c1 != c2) {\n            if (c1 > c2)\n                return 1;\n            else\n                return -1;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":300803,"func":"static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,\n\t\t\tint peer)\n{\n\tstruct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;\n\tstruct sock *sk = sock->sk;\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\n\tmemset(addr, 0, sizeof(*addr));\n\tif (peer) {\n\t\tif ((!tipc_sk_connected(sk)) &&\n\t\t    ((peer != 2) || (sk->sk_state != TIPC_DISCONNECTING)))\n\t\t\treturn -ENOTCONN;\n\t\taddr->addr.id.ref = tsk_peer_port(tsk);\n\t\taddr->addr.id.node = tsk_peer_node(tsk);\n\t} else {\n\t\taddr->addr.id.ref = tsk->portid;\n\t\taddr->addr.id.node = tipc_own_addr(sock_net(sk));\n\t}\n\n\taddr->addrtype = TIPC_SOCKET_ADDR;\n\taddr->family = AF_TIPC;\n\taddr->scope = 0;\n\taddr->addr.name.domain = 0;\n\n\treturn sizeof(*addr);\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":312584,"func":"qf_find_last_entry_on_line(qfline_T *entry, int *errornr)\n{\n    while (!got_int &&\n\t    entry->qf_next != NULL\n\t    && entry->qf_fnum == entry->qf_next->qf_fnum\n\t    && entry->qf_lnum == entry->qf_next->qf_lnum)\n    {\n\tentry = entry->qf_next;\n\t++*errornr;\n    }\n\n    return entry;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":294407,"func":"date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vy, vd, vsg;\n    VALUE argv2[3];\n\n    rb_scan_args(argc, argv, \"21\", &vy, &vd, &vsg);\n\n    argv2[0] = vy;\n    argv2[1] = vd;\n    if (argc < 3)\n\targv2[2] = DBL2NUM(GREGORIAN);\n    else\n\targv2[2] = vsg;\n\n    return valid_ordinal_sub(3, argv2, klass, 1);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":468369,"func":"g_socket_client_new (void)\n{\n  return g_object_new (G_TYPE_SOCKET_CLIENT, NULL);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":294585,"func":"d_lite_monday_p(VALUE self)\n{\n    get_d1(self);\n    return f_boolcast(m_wday(dat) == 1);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":512737,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_hex_hybrid>(thd, this); }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":353173,"func":"void SplashOutputDev::clip(GfxState *state) {\n  SplashPath path = convertPath(state, state->getPath(), true);\n  splash->clipToPath(&path, false);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":364243,"func":"void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn,\n\t\t  __be32 saddr)\n{\n\tatomic_set(&inc->i_refcount, 1);\n\tINIT_LIST_HEAD(&inc->i_item);\n\tinc->i_conn = conn;\n\tinc->i_saddr = saddr;\n\tinc->i_rdma_cookie = 0;\n\tinc->i_rx_tstamp.tv_sec = 0;\n\tinc->i_rx_tstamp.tv_usec = 0;\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":90104,"func":"std::string CellularNetwork::ActivationStateToString(\n    ActivationState activation_state) {\n  switch (activation_state) {\n    case ACTIVATION_STATE_ACTIVATED:\n      return l10n_util::GetStringUTF8(\n          IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED);\n      break;\n    case ACTIVATION_STATE_ACTIVATING:\n      return l10n_util::GetStringUTF8(\n          IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING);\n      break;\n    case ACTIVATION_STATE_NOT_ACTIVATED:\n      return l10n_util::GetStringUTF8(\n          IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED);\n      break;\n    case ACTIVATION_STATE_PARTIALLY_ACTIVATED:\n      return l10n_util::GetStringUTF8(\n          IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED);\n      break;\n    default:\n      return l10n_util::GetStringUTF8(\n          IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_UNKNOWN);\n      break;\n  }\n}\n","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":491902,"func":"static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)\n{\n\tint i;\n\tsize_t count = req->misc.read.in.size;\n\tsize_t num_read = req->out.args[0].size;\n\tstruct inode *inode = req->pages[0]->mapping->host;\n\n\t\/*\n\t * Short read means EOF.  If file size is larger, truncate it\n\t *\/\n\tif (!req->out.h.error && num_read < count) {\n\t\tloff_t pos = page_offset(req->pages[0]) + num_read;\n\t\tfuse_read_update_size(inode, pos, req->misc.read.attr_ver);\n\t}\n\n\tfuse_invalidate_attr(inode); \/* atime changed *\/\n\n\tfor (i = 0; i < req->num_pages; i++) {\n\t\tstruct page *page = req->pages[i];\n\t\tif (!req->out.h.error)\n\t\t\tSetPageUptodate(page);\n\t\telse\n\t\t\tSetPageError(page);\n\t\tunlock_page(page);\n\t}\n\tif (req->ff)\n\t\tfuse_file_put(req->ff);\n}","target":0,"code_token_length":224,"total_token_length":460,"max_tokens_setting":512}
+{"idx":389756,"func":"int addopt(char *optstr, int maxlen, const char *s)\n{\n\tsize_t n;\n\tsize_t m;\n\n\tn = strlen(optstr);\n\tm = n + strlen(s) + 1;\n\tif (m > JAS_CAST(size_t, maxlen)) {\n\t\treturn 1;\n\t}\n\tif (n > 0) {\n\t\tstrcat(optstr, \"\\n\");\n\t}\n\tstrcat(optstr, s);\n\treturn 0;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":359292,"func":"DEFUN_DEPRECATED (neighbor_version,\n\t\t  neighbor_version_cmd,\n\t\t  NEIGHBOR_CMD \"version (4|4-)\",\n\t\t  NEIGHBOR_STR\n\t\t  NEIGHBOR_ADDR_STR\n\t\t  \"Set the BGP version to match a neighbor\\n\"\n\t\t  \"Neighbor's BGP version\\n\")\n{\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":249955,"func":"__canonicalize_file_name (const char *name)\n{\n  return __realpath (name, NULL);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":255780,"func":"compare_node_rule_segment(const void *void_lhs,\n                          const void *void_rhs)\n{\n  const sorted_pattern_t *element = void_lhs;\n  const authz_rule_segment_t *segment = void_rhs;\n\n  return strcmp(element->node->segment.data, segment->pattern.data);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":512935,"func":"Item *Item_cond::transform(THD *thd, Item_transformer transformer, uchar *arg)\n{\n  DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare());\n\n  List_iterator<Item> li(list);\n  Item *item;\n  while ((item= li++))\n  {\n    Item *new_item= item->transform(thd, transformer, arg);\n    if (!new_item)\n      return 0;\n\n    \/*\n      THD::change_item_tree() should be called only if the tree was\n      really transformed, i.e. when a new item has been created.\n      Otherwise we'll be allocating a lot of unnecessary memory for\n      change records at each execution.\n    *\/\n    if (new_item != item)\n      thd->change_item_tree(li.ref(), new_item);\n  }\n  return Item_func::transform(thd, transformer, arg);\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":294408,"func":"m_virtual_sg(union DateData *x)\n{\n    if (simple_dat_p(x))\n\treturn s_virtual_sg(x);\n    else\n\treturn c_virtual_sg(x);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512981,"func":"  uint time_precision(THD *thd)\n  {\n    return const_item() ? type_handler()->Item_time_precision(thd, this) :\n                          MY_MIN(decimals, TIME_SECOND_PART_DIGITS);\n  }","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":229141,"func":"static VirtIOSerialPort *find_port_by_name(char *name)\n{\n    VirtIOSerial *vser;\n\n    QLIST_FOREACH(vser, &vserdevices.devices, next) {\n        VirtIOSerialPort *port;\n\n        QTAILQ_FOREACH(port, &vser->ports, next) {\n            if (port->name && !strcmp(port->name, name)) {\n                return port;\n            }\n        }\n    }\n    return NULL;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":335419,"func":"trigger_DirChangedPre(char_u *acmd_fname, char_u *new_dir)\n{\n#ifdef FEAT_EVAL\n    dict_T\t    *v_event;\n    save_v_event_T  save_v_event;\n\n    v_event = get_v_event(&save_v_event);\n    (void)dict_add_string(v_event, \"directory\", new_dir);\n    dict_set_items_ro(v_event);\n#endif\n    apply_autocmds(EVENT_DIRCHANGEDPRE, acmd_fname, new_dir, FALSE, curbuf);\n#ifdef FEAT_EVAL\n    restore_v_event(v_event, &save_v_event);\n#endif\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":336646,"func":"static void reds_mig_target_client_free(RedsState *reds, RedsMigTargetClient *mig_client)\n{\n    reds->mig_target_clients = g_list_remove(reds->mig_target_clients, mig_client);\n    g_list_free_full(mig_client->pending_links, g_free);\n    g_free(mig_client);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":402622,"func":"generate_validity(cms_context *cms, SECItem *der, time_t start, time_t end)\n{\n\tValidity validity;\n\tint rc;\n\n\trc = generate_time(cms, &validity.start, start);\n\tif (rc < 0)\n\t\treturn rc;\n\n\trc = generate_time(cms, &validity.end, end);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tvoid *ret;\n\tret = SEC_ASN1EncodeItem(cms->arena, der, &validity, ValidityTemplate);\n\tif (ret == NULL)\n\t\tcmsreterr(-1, cms, \"could not encode validity\");\n\treturn 0;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":404705,"func":"unsigned long __fdget_raw(unsigned int fd)\n{\n\treturn __fget_light(fd, 0);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":312515,"func":"f_setqflist(typval_T *argvars, typval_T *rettv)\n{\n    if (in_vim9script()\n\t    && (check_for_list_arg(argvars, 0) == FAIL\n\t\t|| check_for_opt_string_arg(argvars, 1) == FAIL\n\t\t|| (argvars[1].v_type != VAR_UNKNOWN\n\t\t    && check_for_opt_dict_arg(argvars, 2) == FAIL)))\n\treturn;\n\n    set_qf_ll_list(NULL, &argvars[0], &argvars[1], &argvars[2], rettv);\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":274855,"func":"TEST(ComparisonsTest, GreaterQuantized) {\n  const float kMin = -1.f;\n  const float kMax = 128.f;\n  ComparisonOpModel model({TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax},\n                          {TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax},\n                          TensorType_UINT8, BuiltinOperator_GREATER);\n  model.QuantizeAndPopulate<uint8_t>(model.input1(), {1, 9, 7, 3});\n  model.QuantizeAndPopulate<uint8_t>(model.input2(), {1, 2, 6, 5});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(), ElementsAre(false, true, true, false));\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":299983,"func":"static void elo_process_data(struct input_dev *input, const u8 *data, int size)\n{\n\tint press;\n\n\tinput_report_abs(input, ABS_X, (data[3] << 8) | data[2]);\n\tinput_report_abs(input, ABS_Y, (data[5] << 8) | data[4]);\n\n\tpress = 0;\n\tif (data[1] & 0x80)\n\t\tpress = (data[7] << 8) | data[6];\n\tinput_report_abs(input, ABS_PRESSURE, press);\n\n\tif (data[1] & 0x03) {\n\t\tinput_report_key(input, BTN_TOUCH, 1);\n\t\tinput_sync(input);\n\t}\n\n\tif (data[1] & 0x04)\n\t\tinput_report_key(input, BTN_TOUCH, 0);\n\n\tinput_sync(input);\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":246717,"func":"static u32 do_raw_cat()\n{\n\tchar chunk[4096];\n\tFILE *fin, *fout;\n\ts64 to_copy, done;\n\tfin = gf_fopen(raw_cat, \"rb\");\n\tif (!fin) return mp4box_cleanup(1);\n\n\tfout = gf_fopen(inName, \"a+b\");\n\tif (!fout) {\n\t\tgf_fclose(fin);\n\t\treturn mp4box_cleanup(1);\n\t}\n\tgf_fseek(fin, 0, SEEK_END);\n\tto_copy = gf_ftell(fin);\n\tgf_fseek(fin, 0, SEEK_SET);\n\tdone = 0;\n\twhile (1) {\n\t\tu32 nb_bytes = (u32) gf_fread(chunk, 4096, fin);\n\t\tgf_fwrite(chunk, nb_bytes, fout);\n\t\tdone += nb_bytes;\n\t\tfprintf(stderr, \"Appending file %s - %02.2f done\\r\", raw_cat, 100.0*done\/to_copy);\n\t\tif (done >= to_copy) break;\n\t}\n\tgf_fclose(fin);\n\tgf_fclose(fout);\n\treturn mp4box_cleanup(0);\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":248312,"func":"DLLIMPORT const char *cfg_name(cfg_t *cfg)\n{\n\tif (cfg)\n\t\treturn cfg->name;\n\treturn NULL;\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":336576,"func":"static const char *get_index_name(const EnumNames names[], uint32_t index)\n{\n    while (names->name != NULL && names->id != index) {\n        names++;\n    }\n\n    return names->name;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":462571,"func":"std::string controller::get_hostname_from_url(const std::string& url) {\n\txmlURIPtr uri = xmlParseURI(url.c_str());\n\tstd::string hostname;\n\tif (uri) {\n\t\thostname = uri->server;\n\t\txmlFreeURI(uri);\n\t}\n\treturn hostname;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":272358,"func":"find_named_certificate(cms_context *cms, char *name, CERTCertificate **cert)\n{\n\tif (!name)\n\t\tcnreterr(-1, cms, \"no subject name specified\");\n\n\treturn find_certificate_by_callback(cms, match_subject, name, cert);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":450330,"func":"static void tight_send_compact_size(VncState *vs, size_t len)\n{\n    int lpc = 0;\n    int bytes = 0;\n    char buf[3] = {0, 0, 0};\n\n    buf[bytes++] = len & 0x7F;\n    if (len > 0x7F) {\n        buf[bytes-1] |= 0x80;\n        buf[bytes++] = (len >> 7) & 0x7F;\n        if (len > 0x3FFF) {\n            buf[bytes-1] |= 0x80;\n            buf[bytes++] = (len >> 14) & 0xFF;\n        }\n    }\n    for (lpc = 0; lpc < bytes; lpc++) {\n        vnc_write_u8(vs, buf[lpc]);\n    }\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":96947,"func":"bool decode(ArgumentDecoder* decoder, RetainPtr<CFNumberRef>& result)\n{\n    CFNumberType numberType;\n    if (!decoder->decodeEnum(numberType))\n        return false;\n\n    CoreIPC::DataReference dataReference;\n    if (!decoder->decode(dataReference))\n        return false;\n\n    size_t neededBufferSize = sizeForNumberType(numberType);\n    if (!neededBufferSize || dataReference.size() != neededBufferSize)\n        return false;\n\n    ASSERT(dataReference.data());\n    CFNumberRef number = CFNumberCreate(0, numberType, dataReference.data());\n    result.adoptCF(number);\n\n    return true;\n}\n","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":264717,"func":"bool MaybeReplaceSizeOp(const Node* n,\n                        const std::vector<PartialTensorShape>& input_shapes,\n                        std::unordered_map<const Node*, std::vector<Tensor>>*\n                            shape_replacement_map) {\n  CHECK_EQ(input_shapes.size(), 1);\n  if (!input_shapes[0].IsFullyDefined()) {\n    return false;\n  }\n  DataType op_type = n->output_type(0);\n  Tensor t(op_type, TensorShape({}));\n  int64_t size = input_shapes[0].num_elements();\n  if (op_type == DT_INT64) {\n    t.scalar<int64_t>()() = size;\n  } else {\n    CHECK(op_type == DT_INT32);\n    if (size > INT_MAX) {\n      VLOG(1) << \"Node \" << n->name() << \" has input shape size \" << size\n              << \" but type INT32 \"\n              << \" so not replacing as constant: this will trigger a runtime \"\n                 \"error later.\";\n      return false;\n    }\n    t.scalar<int32>()() = static_cast<int32>(size);\n  }\n  shape_replacement_map->insert({n, {t}});\n  return true;\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":216637,"func":"SCM_DEFINE (scm_mkdir, \"mkdir\", 1, 1, 0,\n            (SCM path, SCM mode),\n\t    \"Create a new directory named by @var{path}.  If @var{mode} is omitted\\n\"\n\t    \"then the permissions of the directory file are set using the current\\n\"\n\t    \"umask.  Otherwise they are set to the decimal value specified with\\n\"\n\t    \"@var{mode}.  The return value is unspecified.\")\n#define FUNC_NAME s_scm_mkdir\n{\n  int rv;\n  mode_t mask;\n\n  if (SCM_UNBNDP (mode))\n    {\n      mask = umask (0);\n      umask (mask);\n      STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));\n    }\n  else\n    {\n      STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));\n    }\n  if (rv != 0)\n    SCM_SYSERROR;\n  return SCM_UNSPECIFIED;\n}","target":1,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":384193,"func":"int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set,\n\t\t\t    struct nft_expr *expr_array[])\n{\n\tstruct nft_expr *expr;\n\tint err, i, k;\n\n\tfor (i = 0; i < set->num_exprs; i++) {\n\t\texpr = kzalloc(set->exprs[i]->ops->size, GFP_KERNEL_ACCOUNT);\n\t\tif (!expr)\n\t\t\tgoto err_expr;\n\n\t\terr = nft_expr_clone(expr, set->exprs[i]);\n\t\tif (err < 0) {\n\t\t\tkfree(expr);\n\t\t\tgoto err_expr;\n\t\t}\n\t\texpr_array[i] = expr;\n\t}\n\n\treturn 0;\n\nerr_expr:\n\tfor (k = i - 1; k >= 0; k--)\n\t\tnft_expr_destroy(ctx, expr_array[k]);\n\n\treturn -ENOMEM;\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":229158,"func":"static void add_port(VirtIOSerial *vser, uint32_t port_id)\n{\n    mark_port_added(vser, port_id);\n    send_control_event(vser, port_id, VIRTIO_CONSOLE_PORT_ADD, 1);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":222832,"func":"  const NodeDef* pop() {\n    CHECK(!empty());\n    auto it = queue_.begin();\n    const NodeDef* n = it->first;\n    queue_.erase(it);\n    return n;\n  }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":438682,"func":"static int virtio_rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src,\n\t\t\t\t\tu32 dst, void *data, int len)\n{\n\tstruct rpmsg_device *rpdev = ept->rpdev;\n\n\treturn rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true);\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":436036,"func":"\nstatic void __io_rsrc_put_work(struct io_rsrc_node *ref_node)\n{\n\tstruct io_rsrc_data *rsrc_data = ref_node->rsrc_data;\n\tstruct io_ring_ctx *ctx = rsrc_data->ctx;\n\tstruct io_rsrc_put *prsrc, *tmp;\n\n\tlist_for_each_entry_safe(prsrc, tmp, &ref_node->rsrc_list, list) {\n\t\tlist_del(&prsrc->list);\n\n\t\tif (prsrc->tag) {\n\t\t\tbool lock_ring = ctx->flags & IORING_SETUP_IOPOLL;\n\n\t\t\tio_ring_submit_lock(ctx, lock_ring);\n\t\t\tspin_lock_irq(&ctx->completion_lock);\n\t\t\tio_cqring_fill_event(ctx, prsrc->tag, 0, 0);\n\t\t\tctx->cq_extra++;\n\t\t\tio_commit_cqring(ctx);\n\t\t\tspin_unlock_irq(&ctx->completion_lock);\n\t\t\tio_cqring_ev_posted(ctx);\n\t\t\tio_ring_submit_unlock(ctx, lock_ring);\n\t\t}\n\n\t\trsrc_data->do_put(ctx, prsrc);\n\t\tkfree(prsrc);\n\t}\n\n\tio_rsrc_node_destroy(ref_node);\n\tif (atomic_dec_and_test(&rsrc_data->refs))\n\t\tcomplete(&rsrc_data->done);","target":0,"code_token_length":254,"total_token_length":490,"max_tokens_setting":512}
+{"idx":275988,"func":"uECC_VLI_API void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words) {\n    wordcount_t i;\n    for (i = 0; i < num_words; ++i) {\n        vli[i] = 0;\n    }\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":385919,"func":"SYSCALL_DEFINE3(chown, const char __user *, filename, uid_t, user, gid_t, group)\n{\n\treturn sys_fchownat(AT_FDCWD, filename, user, group, 0);\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":502726,"func":"void SSL_CTX_set_info_callback(SSL_CTX *ctx,\n                               void (*cb) (const SSL *ssl, int type, int val))\n{\n    ctx->info_callback = cb;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":512819,"func":"  virtual const my_decimal *const_ptr_my_decimal() const { return NULL; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":300818,"func":"static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct tipc_sock *tsk = tipc_sk(sk);\n\tstruct tipc_msg *hdr = buf_msg(skb);\n\n\tif (unlikely(msg_in_group(hdr)))\n\t\treturn READ_ONCE(sk->sk_rcvbuf);\n\n\tif (unlikely(!msg_connected(hdr)))\n\t\treturn READ_ONCE(sk->sk_rcvbuf) << msg_importance(hdr);\n\n\tif (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL))\n\t\treturn READ_ONCE(sk->sk_rcvbuf);\n\n\treturn FLOWCTL_MSG_LIM;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":246454,"func":"static size_t consume_init_expr_r(RBuffer *b, ut64 bound, ut8 eoc, void *out) {\n\tif (!b || bound >= r_buf_size (b) || r_buf_tell (b) > bound) {\n\t\treturn 0;\n\t}\n\tsize_t res = 0;\n\tut8 cur = r_buf_read8 (b);\n\twhile (r_buf_tell (b) <= bound && cur != eoc) {\n\t\tcur = r_buf_read8 (b);\n\t\tres++;\n\t}\n\tif (cur != eoc) {\n\t\treturn 0;\n\t}\n\treturn res + 1;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":256388,"func":"static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data,\n\t\t\t\t\t       gfp_t gfp_mask)\n{\n\tstruct bio_map_data *bmd;\n\n\tif (data->nr_segs > UIO_MAXIOV)\n\t\treturn NULL;\n\n\tbmd = kmalloc(struct_size(bmd, iov, data->nr_segs), gfp_mask);\n\tif (!bmd)\n\t\treturn NULL;\n\tmemcpy(bmd->iov, data->iov, sizeof(struct iovec) * data->nr_segs);\n\tbmd->iter = *data;\n\tbmd->iter.iov = bmd->iov;\n\treturn bmd;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":488426,"func":"static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,\n\t\t\t\t     unsigned long addr, unsigned long end,\n\t\t\t\t     pte_fn_t fn, void *data)\n{\n\tpte_t *pte;\n\tint err;\n\tpgtable_t token;\n\tspinlock_t *uninitialized_var(ptl);\n\n\tpte = (mm == &init_mm) ?\n\t\tpte_alloc_kernel(pmd, addr) :\n\t\tpte_alloc_map_lock(mm, pmd, addr, &ptl);\n\tif (!pte)\n\t\treturn -ENOMEM;\n\n\tBUG_ON(pmd_huge(*pmd));\n\n\ttoken = pmd_pgtable(*pmd);\n\n\tdo {\n\t\terr = fn(pte, token, addr, data);\n\t\tif (err)\n\t\t\tbreak;\n\t} while (pte++, addr += PAGE_SIZE, addr != end);\n\n\tif (mm != &init_mm)\n\t\tpte_unmap_unlock(pte-1, ptl);\n\treturn err;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":278253,"func":"get_indent_lnum(linenr_T lnum)\n{\n#ifdef FEAT_VARTABS\n    return get_indent_str_vtab(ml_get(lnum), (int)curbuf->b_p_ts,\n\t\t\t\t\t\t curbuf->b_p_vts_array, FALSE);\n#else\n    return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts, FALSE);\n#endif\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":443154,"func":"static int jfs_writepages(struct address_space *mapping,\n\t\t\tstruct writeback_control *wbc)\n{\n\treturn mpage_writepages(mapping, wbc, jfs_get_block);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":483052,"func":"static void cgroup_pidlist_stop(struct seq_file *s, void *v)\n{\n\tstruct kernfs_open_file *of = s->private;\n\tstruct cgroup_file_ctx *ctx = of->priv;\n\tstruct cgroup_pidlist *l = ctx->procs1.pidlist;\n\n\tif (l)\n\t\tmod_delayed_work(cgroup_pidlist_destroy_wq, &l->destroy_dwork,\n\t\t\t\t CGROUP_PIDLIST_DESTROY_DELAY);\n\tmutex_unlock(&seq_css(s)->cgroup->pidlist_mutex);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":309999,"func":"init_xterm_mouse(SCREEN *sp)\n{\n    sp->_mouse_type = M_XTERM;\n    sp->_mouse_xtermcap = NCURSES_SP_NAME(tigetstr) (NCURSES_SP_ARGx \"XM\");\n    if (!VALID_STRING(sp->_mouse_xtermcap))\n\tsp->_mouse_xtermcap = \"\\033[?1000%?%p1%{1}%=%th%el%;\";\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":101700,"func":"void WebProcessProxy::updateTextCheckerState()\n{\n    if (canSendMessage())\n        send(Messages::WebProcess::SetTextCheckerState(TextChecker::state()), 0);\n}\n","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":222886,"func":"  DimensionHandle GetUnknownOutputDim(const NodeDef* node, int index,\n                                      int dim_id) {\n    DimId id{node, index, dim_id};\n    auto it = unknown_dims_.find(id);\n    if (it != unknown_dims_.end()) {\n      return it->second;\n    }\n    InferenceContext* c = GetContext(node);\n    DimensionHandle dim = c->UnknownDim();\n    unknown_dims_[id] = dim;\n    return dim;\n  }","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":313738,"func":"nv_help(cmdarg_T *cap)\n{\n    if (!checkclearopq(cap->oap))\n\tex_help(NULL);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":441823,"func":"SProcXkbGetGeometry(ClientPtr client)\n{\n    REQUEST(xkbGetGeometryReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbGetGeometryReq);\n    swaps(&stuff->deviceSpec);\n    swapl(&stuff->name);\n    return ProcXkbGetGeometry(client);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":289316,"func":"snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tint ret;\n\twhile (1) {\n\t\tif (runtime->status->state == SNDRV_PCM_STATE_XRUN ||\n\t\t    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {\n#ifdef OSS_DEBUG\n\t\t\tpcm_dbg(substream->pcm,\n\t\t\t\t\"pcm_oss: readv: recovering from %s\\n\",\n\t\t\t\truntime->status->state == SNDRV_PCM_STATE_XRUN ?\n\t\t\t\t\"XRUN\" : \"SUSPEND\");\n#endif\n\t\t\tret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);\n\t\t\tif (ret < 0)\n\t\t\t\tbreak;\n\t\t} else if (runtime->status->state == SNDRV_PCM_STATE_SETUP) {\n\t\t\tret = snd_pcm_oss_prepare(substream);\n\t\t\tif (ret < 0)\n\t\t\t\tbreak;\n\t\t}\n\t\tret = snd_pcm_kernel_readv(substream, bufs, frames);\n\t\tif (ret != -EPIPE && ret != -ESTRPIPE)\n\t\t\tbreak;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":508397,"func":"void setup_defaults(THD *thd, List<Item> &fields, List<Item> &values)\n{\n  List_iterator<Item> fit(fields);\n  List_iterator<Item> vit(values);\n\n  for (Item *value= vit++, *f_item= fit++; value; value= vit++, f_item= fit++)\n  {\n    value->walk(&Item::enchant_default_with_arg_processor, false, f_item);\n  }\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":310314,"func":"dirserv_router_has_valid_address(routerinfo_t *ri)\n{\n  struct in_addr iaddr;\n  if (get_options()->DirAllowPrivateAddresses)\n    return 0; \/* whatever it is, we're fine with it *\/\n  if (!tor_inet_aton(ri->address, &iaddr)) {\n    log_info(LD_DIRSERV,\"Router %s published non-IP address '%s'. Refusing.\",\n             router_describe(ri),\n             ri->address);\n    return -1;\n  }\n  if (is_internal_IP(ntohl(iaddr.s_addr), 0)) {\n    log_info(LD_DIRSERV,\n             \"Router %s published internal IP address '%s'. Refusing.\",\n             router_describe(ri), ri->address);\n    return -1; \/* it's a private IP, we should reject it *\/\n  }\n  return 0;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":259599,"func":"void HierarchicalBitmapRequester::Pull8Lines(UBYTE c)\n{ \n int cnt;\n  ULONG y = m_pulY[c];\n  \/\/\n  \/\/ Allocate a line block from the encoding line adapter.\n  for(cnt = 0;cnt < 8 && y < m_pulHeight[c];cnt++) {\n    assert(m_ppDecodingMCU[cnt | (c << 3)] == NULL);\n    m_ppDecodingMCU[cnt | (c << 3)] = m_pLargestScale->GetNextLine(c);\n    y++;\n  }\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":463161,"func":"EXPORTED int annotate_rename_mailbox(struct mailbox *oldmailbox,\n                            struct mailbox *newmailbox)\n{\n    \/* rename one mailbox *\/\n    char *olduserid = mboxname_to_userid(oldmailbox->name);\n    char *newuserid = mboxname_to_userid(newmailbox->name);\n    annotate_db_t *d = NULL;\n    int r = 0;\n\n    init_internal();\n\n    \/* rewrite any per-folder annotations from the global db *\/\n    r = _annotate_getdb(NULL, 0, \/*don't create*\/0, &d);\n    if (r == CYRUSDB_NOTFOUND) {\n        \/* no global database, must not be anything to rename *\/\n        r = 0;\n        goto done;\n    }\n    if (r) goto done;\n\n    annotate_begin(d);\n\n    \/* copy here - delete will dispose of old records later *\/\n    r = _annotate_rewrite(oldmailbox, 0, olduserid,\n                          newmailbox, 0, newuserid,\n                         \/*copy*\/1);\n    if (r) goto done;\n\n    r = annotate_commit(d);\n    if (r) goto done;\n\n    \/*\n     * The per-folder database got moved or linked by mailbox_copy_files().\n     *\/\n\n done:\n    annotate_putdb(&d);\n    free(olduserid);\n    free(newuserid);\n\n    return r;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":226124,"func":"\nvoid vwid_box_del(GF_Box *s)\n{\n\tu32 i;\n\tGF_ViewIdentifierBox *ptr = (GF_ViewIdentifierBox *) s;\n\tif (ptr->views) {\n\t\tfor (i=0; i<ptr->num_views; i++) {\n\t\t\tif (ptr->views[i].view_refs)\n\t\t\t\tgf_free(ptr->views[i].view_refs);\n\t\t}\n\t\tgf_free(ptr->views);\n\t}\n\tgf_free(ptr);","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":513098,"func":"  Field *create_field_for_create_select(TABLE *table)\n  { return create_table_field_from_handler(table); }","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":289300,"func":"static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file)\n{\n\tstruct snd_pcm_substream *substream;\n\tint err;\n\t\n\terr = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);\n\tif (err < 0)\n\t\treturn err;\n\treturn substream->runtime->oss.format;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":272344,"func":"generate_spc_string(cms_context *cms, SECItem *ssp, char *str, int len)\n{\n\tSpcString ss;\n\tmemset(&ss, '\\0', sizeof (ss));\n\n\tSECITEM_AllocItem(cms->arena, &ss.unicode, len);\n\tif (len != 0) {\n\t\tif (!ss.unicode.data)\n\t\t\tcnreterr(-1, cms, \"could not allocate memory\");\n\n\t\tmemcpy(ss.unicode.data, str, len);\n\t}\n\tss.unicode.type = siBMPString;\n\n\tif (SEC_ASN1EncodeItem(cms->arena, ssp, &ss, SpcStringTemplate) == NULL)\n\t\tcnreterr(-1, cms, \"could not encode SpcString\");\n\n\treturn 0;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":313830,"func":"nv_exmode(cmdarg_T *cap)\n{\n    \/\/ Ignore 'Q' in Visual mode, just give a beep.\n    if (VIsual_active)\n\tvim_beep(BO_EX);\n    else if (!checkclearop(cap->oap))\n\tdo_exmode(FALSE);\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":261944,"func":"njs_decode_hex_length(const njs_str_t *src, size_t *out_size)\n{\n    if (out_size != NULL) {\n        *out_size = src->length \/ 2;\n    }\n\n    return 0;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":273877,"func":"static void handle_NOOP(ctrl_t *ctrl, char *arg)\n{\n\tsend_msg(ctrl->sd, \"200 NOOP OK.\\r\\n\");\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":274661,"func":"callbacks_zoom_in_activate                    (GtkMenuItem     *menuitem,\n                                        gpointer         user_data)\n{\n\trender_zoom_display (ZOOM_IN, 0, 0, 0);\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":427228,"func":"static void mainfunc (LexState *ls, FuncState *fs) {\n  BlockCnt bl;\n  Upvaldesc *env;\n  open_func(ls, fs, &bl);\n  setvararg(fs, 0);  \/* main function is always declared vararg *\/\n  env = allocupvalue(fs);  \/* ...set environment upvalue *\/\n  env->instack = 1;\n  env->idx = 0;\n  env->kind = VDKREG;\n  env->name = ls->envn;\n  luaC_objbarrier(ls->L, fs->f, env->name);\n  luaX_next(ls);  \/* read first token *\/\n  statlist(ls);  \/* parse main body *\/\n  check(ls, TK_EOS);\n  close_func(ls);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":238785,"func":"save_re_pat(int idx, char_u *pat, int magic)\n{\n    if (spats[idx].pat != pat)\n    {\n\tvim_free(spats[idx].pat);\n\tspats[idx].pat = vim_strsave(pat);\n\tspats[idx].magic = magic;\n\tspats[idx].no_scs = no_smartcase;\n\tlast_idx = idx;\n#ifdef FEAT_SEARCH_EXTRA\n\t\/\/ If 'hlsearch' set and search pat changed: need redraw.\n\tif (p_hls)\n\t    redraw_all_later(SOME_VALID);\n\tset_no_hlsearch(FALSE);\n#endif\n    }\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":225649,"func":"GF_Err mdia_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MediaBox *ptr = (GF_MediaBox *)s;\n\tswitch(a->type) {\n\tcase GF_ISOM_BOX_TYPE_MDHD:\n\t\tBOX_FIELD_ASSIGN(mediaHeader, GF_MediaHeaderBox)\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_HDLR:\n\t\tBOX_FIELD_ASSIGN(handler, GF_HandlerBox)\n\t\treturn GF_OK;\n\n\tcase GF_ISOM_BOX_TYPE_MINF:\n\t\tBOX_FIELD_ASSIGN(information, GF_MediaInformationBox)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":482540,"func":"findRuleName(const CharsString *name, const TranslationTableHeader *table) {\n\tconst RuleName *ruleName = table->ruleNames;\n\twhile (ruleName) {\n\t\tif ((name->length == ruleName->length) &&\n\t\t\t\t(memcmp(&name->chars[0], ruleName->name, CHARSIZE * name->length) == 0))\n\t\t\treturn ruleName->ruleOffset;\n\t\truleName = ruleName->next;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":489149,"func":"static sctp_disposition_t sctp_sf_violation_chunk(\n\t\t\t\t     const struct sctp_endpoint *ep,\n\t\t\t\t     const struct sctp_association *asoc,\n\t\t\t\t     const sctp_subtype_t type,\n\t\t\t\t     void *arg,\n\t\t\t\t     sctp_cmd_seq_t *commands)\n{\n\tstatic const char err_str[]=\"The following chunk violates protocol:\";\n\n\tif (!asoc)\n\t\treturn sctp_sf_violation(ep, asoc, type, arg, commands);\n\n\treturn sctp_sf_abort_violation(ep, asoc, arg, commands, err_str,\n\t\t\t\t\tsizeof(err_str));\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":225680,"func":"void dmed_box_del(GF_Box *s)\n{\n\tgf_free((GF_DMEDBox *)s);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":359211,"func":"static size_t bpf_ringbuf_rec_pg_off(struct bpf_ringbuf *rb,\n\t\t\t\t     struct bpf_ringbuf_hdr *hdr)\n{\n\treturn ((void *)hdr - (void *)rb) >> PAGE_SHIFT;\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":218826,"func":"static void XSetMatteColor(Display *display,const XWindowInfo *window_info,\n  const MagickStatusType raised)\n{\n  if (window_info->depth == 1)\n    {\n      \/*\n        Monochrome window.\n      *\/\n      if (raised)\n        (void) XSetForeground(display,window_info->widget_context,\n          XWhitePixel(display,window_info->screen));\n      else\n        (void) XSetForeground(display,window_info->widget_context,\n          XBlackPixel(display,window_info->screen));\n    }\n  else\n    if (raised)\n      (void) XSetForeground(display,window_info->widget_context,\n        window_info->pixel_info->matte_color.pixel);\n    else\n      (void) XSetForeground(display,window_info->widget_context,\n        window_info->pixel_info->depth_color.pixel);\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":204138,"func":"static void write_response(ESPState *s)\n{\n    uint32_t n;\n\n    trace_esp_write_response(s->status);\n\n    fifo8_reset(&s->fifo);\n    esp_fifo_push(s, s->status);\n    esp_fifo_push(s, 0);\n\n    if (s->dma) {\n        if (s->dma_memory_write) {\n            s->dma_memory_write(s->dma_opaque,\n                                (uint8_t *)fifo8_pop_buf(&s->fifo, 2, &n), 2);\n            s->rregs[ESP_RSTAT] = STAT_TC | STAT_ST;\n            s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC;\n            s->rregs[ESP_RSEQ] = SEQ_CD;\n        } else {\n            s->pdma_cb = write_response_pdma_cb;\n            esp_raise_drq(s);\n            return;\n        }\n    } else {\n        s->ti_size = 2;\n        s->rregs[ESP_RFLAGS] = 2;\n    }\n    esp_raise_irq(s);\n}","target":1,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":473933,"func":"onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,\n                             const UChar** pp ARG_UNUSED, const UChar* end ARG_UNUSED)\n{\n  const UChar* p = *pp;\n\n  if (ONIGENC_IS_MBC_ASCII(p)) {\n    (*pp)++;\n    return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);\n  }\n\n  (*pp) += enclen(enc, p);\n  return FALSE;\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":436111,"func":"static bool io_flush_cached_reqs(struct io_ring_ctx *ctx)\n{\n\tstruct io_submit_state *state = &ctx->submit_state;\n\tstruct io_comp_state *cs = &state->comp;\n\tint nr;\n\n\t\/*\n\t * If we have more than a batch's worth of requests in our IRQ side\n\t * locked cache, grab the lock and move them over to our submission\n\t * side cache.\n\t *\/\n\tif (READ_ONCE(ctx->locked_free_nr) > IO_COMPL_BATCH)\n\t\tio_flush_cached_locked_reqs(ctx, cs);\n\n\tnr = state->free_reqs;\n\twhile (!list_empty(&cs->free_list)) {\n\t\tstruct io_kiocb *req = list_first_entry(&cs->free_list,\n\t\t\t\t\t\tstruct io_kiocb, compl.list);\n\n\t\tlist_del(&req->compl.list);\n\t\tstate->reqs[nr++] = req;\n\t\tif (nr == ARRAY_SIZE(state->reqs))\n\t\t\tbreak;\n\t}\n\n\tstate->free_reqs = nr;\n\treturn nr != 0;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":393481,"func":"static SQInteger base_seterrorhandler(HSQUIRRELVM v)\n{\n    sq_seterrorhandler(v);\n    return 0;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":226142,"func":"void rely_box_del(GF_Box *s)\n{\n\tGF_RelyHintBox *rely = (GF_RelyHintBox *)s;\n\tgf_free(rely);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":261431,"func":"static int decode_merge_idx(thread_context* tctx)\n{\n  logtrace(LogSlice,\"# merge_idx\\n\");\n\n  if (tctx->shdr->MaxNumMergeCand <= 1) {\n    logtrace(LogSymbols,\"$1 merge_idx=%d\\n\",0);\n    return 0;\n  }\n\n  \/\/ TU coding, first bin is CABAC, remaining are bypass.\n  \/\/ cMax = MaxNumMergeCand-1\n\n  int idx = decode_CABAC_bit(&tctx->cabac_decoder,\n                             &tctx->ctx_model[CONTEXT_MODEL_MERGE_IDX]);\n\n  if (idx==0) {\n    \/\/ nothing\n  }\n  else {\n    idx=1;\n\n    while (idx<tctx->shdr->MaxNumMergeCand-1) {\n      if (decode_CABAC_bypass(&tctx->cabac_decoder)) {\n        idx++;\n      }\n      else {\n        break;\n      }\n    }\n  }\n\n  logtrace(LogSlice,\"> merge_idx = %d\\n\",idx);\n  logtrace(LogSymbols,\"$1 merge_idx=%d\\n\",idx);\n\n  return idx;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":313742,"func":"check_visual_highlight(void)\n{\n    static int\t    did_check = FALSE;\n\n    if (full_screen)\n    {\n\tif (!did_check && HL_ATTR(HLF_V) == 0)\n\t    msg(_(\"Warning: terminal cannot highlight\"));\n\tdid_check = TRUE;\n    }\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":417054,"func":"\tPeakAutoAdjustFilter() : \n\t\tmixerShift(0),\n\t\tmasterVolume(256),\n\t\tlastPeakValue(0)\n\t{\n\t}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":486790,"func":"static inline uint64_t rx_desc_get_buffer(CadenceGEMState *s, uint32_t *desc)\n{\n    uint64_t ret = desc[0] & ~0x3UL;\n\n    if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) {\n        ret |= (uint64_t)desc[2] << 32;\n    }\n    return ret;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":343320,"func":"static int checkvalidaddr(const struct sockaddr_storage * const addr)\n{\n    if (addr == NULL) {\n        return 0;\n    }\n    \/* Some versions of MacOS X have broken IN* macros *\/\n#ifdef __APPLE_CC__\n    return 1;\n#endif\n    if (STORAGE_FAMILY(*addr) == AF_INET6) {\n        if (IN6_IS_ADDR_MULTICAST(&STORAGE_SIN_ADDR6_NF_CONST(*addr)) ||\n            IN6_IS_ADDR_UNSPECIFIED(&STORAGE_SIN_ADDR6_NF_CONST(*addr))) {\n            return 0;\n        }\n        return 1;\n    } else if (STORAGE_FAMILY(*addr) == AF_INET) {\n        if (ntohl(STORAGE_SIN_ADDR_CONST(*addr)) == INADDR_ANY ||\n            ntohl(STORAGE_SIN_ADDR_CONST(*addr)) == INADDR_NONE ||\n            ntohl(STORAGE_SIN_ADDR_CONST(*addr)) == INADDR_BROADCAST ||\n            IN_MULTICAST(ntohl(STORAGE_SIN_ADDR_CONST(*addr)))) {\n            return 0;\n        }\n        return 1;\n    }\n    return 0;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":301370,"func":"static int vfswrap_rename(vfs_handle_struct *handle,\n\t\t\t  const struct smb_filename *smb_fname_src,\n\t\t\t  const struct smb_filename *smb_fname_dst)\n{\n\tint result = -1;\n\n\tSTART_PROFILE(syscall_rename);\n\n\tif (smb_fname_src->stream_name || smb_fname_dst->stream_name) {\n\t\terrno = ENOENT;\n\t\tgoto out;\n\t}\n\n\tresult = rename(smb_fname_src->base_name, smb_fname_dst->base_name);\n\n out:\n\tEND_PROFILE(syscall_rename);\n\treturn result;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":238487,"func":"static inline u32 vlog_alignment(u32 pos)\n{\n\treturn round_up(max(pos + BPF_LOG_MIN_ALIGNMENT \/ 2, BPF_LOG_ALIGNMENT),\n\t\t\tBPF_LOG_MIN_ALIGNMENT) - pos - 1;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":387582,"func":"int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,\n\t\t      unsigned int items, const char *const names[])\n{\n\tinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;\n\tinfo->count = channels;\n\tinfo->value.enumerated.items = items;\n\tif (!items)\n\t\treturn 0;\n\tif (info->value.enumerated.item >= items)\n\t\tinfo->value.enumerated.item = items - 1;\n\tWARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name),\n\t     \"ALSA: too long item name '%s'\\n\",\n\t     names[info->value.enumerated.item]);\n\tstrscpy(info->value.enumerated.name,\n\t\tnames[info->value.enumerated.item],\n\t\tsizeof(info->value.enumerated.name));\n\treturn 0;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":234132,"func":"fetch_indirect_string (dwarf_vma offset)\n{\n  struct dwarf_section *section = &debug_displays [str].section;\n  const unsigned char * ret;\n\n  if (section->start == NULL)\n    return (const unsigned char *) _(\"<no .debug_str section>\");\n\n  if (offset >= section->size)\n    {\n      warn (_(\"DW_FORM_strp offset too big: 0x%s\\n\"),\n\t    dwarf_vmatoa (\"x\", offset));\n      return (const unsigned char *) _(\"<offset is too big>\");\n    }\n\n  ret = section->start + offset;\n  \/* Unfortunately we cannot rely upon the .debug_str section ending with a\n     NUL byte.  Since our caller is expecting to receive a well formed C\n     string we test for the lack of a terminating byte here.  *\/\n  if (strnlen ((const char *) ret, section->size - offset)\n      == section->size - offset)\n    ret = (const unsigned char *)\n      _(\"<no NUL byte at end of .debug_str section>\");\n\n  return ret;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":90205,"func":"  virtual bool cellular_connecting() const {\n    return cellular_ ? cellular_->connecting() : false;\n  }\n","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":261758,"func":"string RtmpProtocol::get_C1_digest(const uint8_t *ptr,char **digestPos){\n    \/* 764bytes digest\u7ed3\u6784\n    offset: 4bytes\n    random-data: (offset)bytes\n    digest-data: 32bytes\n    random-data: (764-4-offset-32)bytes\n     *\/\n    int offset = 0;\n    for (int i = 0; i < C1_OFFSET_SIZE; ++i) {\n        offset += ptr[i];\n    }\n    offset %= (C1_SCHEMA_SIZE - C1_DIGEST_SIZE - C1_OFFSET_SIZE);\n    *digestPos = (char *) ptr + C1_OFFSET_SIZE + offset;\n    string digest(*digestPos, C1_DIGEST_SIZE);\n    \/\/DebugL << \"digest offset:\" << offset << \",digest:\" << hexdump(digest.data(),digest.size());\n    return digest;\n}","target":0,"code_token_length":187,"total_token_length":423,"max_tokens_setting":512}
+{"idx":222523,"func":"string FunctionLibraryDefinition::FindGradientHelper(const string& func) const {\n  return gtl::FindWithDefault(func_grad_, func, \"\");\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":234157,"func":"check_uvalue (const unsigned char * start,\n\t      dwarf_vma             uvalue,\n\t      const unsigned char * end)\n{\n  dwarf_vma max_uvalue = end - start;\n\n  \/* See PR 17512: file: 008-103549-0.001:0.1.\n     and PR 24829 for examples of where these tests are triggered.  *\/\n  if (uvalue > max_uvalue)\n    {\n      warn (_(\"Corrupt attribute block length: %lx\\n\"), (long) uvalue);\n      uvalue = max_uvalue;\n    }\n\n  return uvalue;\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":462563,"func":"void controller::save_feed(std::shared_ptr<rss_feed> feed, unsigned int pos) {\n\tif (!feed->is_empty()) {\n\t\tLOG(level::DEBUG, \"controller::save_feed: feed is nonempty, saving\");\n\t\trsscache->externalize_rssfeed(feed, ign.matches_resetunread(feed->rssurl()));\n\t\tLOG(level::DEBUG, \"controller::save_feed: after externalize_rssfeed\");\n\n\t\tbool ignore_disp = (cfg.get_configvalue(\"ignore-mode\") == \"display\");\n\t\tfeed = rsscache->internalize_rssfeed(feed->rssurl(), ignore_disp ? &ign : nullptr);\n\t\tLOG(level::DEBUG, \"controller::save_feed: after internalize_rssfeed\");\n\t\tfeed->set_tags(urlcfg->get_tags(feed->rssurl()));\n\t\t{\n\t\t\tunsigned int order = feeds[pos]->get_order();\n\t\t\tstd::lock_guard<std::mutex> itemlock(feeds[pos]->item_mutex);\n\t\t\tfeeds[pos]->clear_items();\n\t\t\tfeed->set_order(order);\n\t\t}\n\t\tfeeds[pos] = feed;\n\t\tv->notify_itemlist_change(feeds[pos]);\n\t} else {\n\t\tLOG(level::DEBUG, \"controller::save_feed: feed is empty, not saving\");\n\t}\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":247706,"func":"TEST_P(SslSocketTest, FailedClientCertificateDefaultExpirationVerification) {\n  envoy::config::listener::v3::Listener listener;\n  envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client;\n\n  configureServerAndExpiredClientCertificate(listener, client, \/*server_config=*\/{});\n\n  TestUtilOptionsV2 test_options(listener, client, false, GetParam());\n  testUtilV2(test_options.setExpectedClientCertUri(\"spiffe:\/\/lyft.com\/test-team\")\n                 .setExpectedTransportFailureReasonContains(\"SSLV3_ALERT_CERTIFICATE_EXPIRED\"));\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":231790,"func":"TEST_F(QuicServerTransportTest, TestClientAddressChanges) {\n  auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);\n  server->getNonConstConn().qLogger = qLogger;\n  StreamId streamId = 4;\n  clientAddr = folly::SocketAddress(\"127.0.0.1\", 2000);\n  auto data = IOBuf::copyBuffer(\"data\");\n  EXPECT_THROW(\n      recvEncryptedStream(streamId, *data, 0, true), std::runtime_error);\n  EXPECT_TRUE(verifyFramePresent(\n      serverWrites,\n      *makeClientEncryptedCodec(),\n      QuicFrame::Type::ConnectionCloseFrame));\n\n  std::vector<int> indices =\n      getQLogEventIndices(QLogEventType::PacketDrop, qLogger);\n  EXPECT_EQ(indices.size(), 1);\n  auto tmp = std::move(qLogger->logs[indices[0]]);\n  auto event = dynamic_cast<QLogPacketDropEvent*>(tmp.get());\n  EXPECT_EQ(event->packetSize, 29);\n  EXPECT_EQ(\n      event->dropReason,\n      QuicTransportStatsCallback::toString(\n          PacketDropReason::PEER_ADDRESS_CHANGE));\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":366335,"func":"static void mnt_free_id(struct mount *mnt)\n{\n\tida_free(&mnt_id_ida, mnt->mnt_id);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":355634,"func":"typval2string(typval_T *tv, int convert)\n{\n    garray_T\tga;\n    char_u\t*retval;\n#ifdef FEAT_FLOAT\n    char_u\tnumbuf[NUMBUFLEN];\n#endif\n\n    if (convert && tv->v_type == VAR_LIST)\n    {\n\tga_init2(&ga, sizeof(char), 80);\n\tif (tv->vval.v_list != NULL)\n\t{\n\t    list_join(&ga, tv->vval.v_list, (char_u *)\"\\n\", TRUE, FALSE, 0);\n\t    if (tv->vval.v_list->lv_len > 0)\n\t\tga_append(&ga, NL);\n\t}\n\tga_append(&ga, NUL);\n\tretval = (char_u *)ga.ga_data;\n    }\n#ifdef FEAT_FLOAT\n    else if (convert && tv->v_type == VAR_FLOAT)\n    {\n\tvim_snprintf((char *)numbuf, NUMBUFLEN, \"%g\", tv->vval.v_float);\n\tretval = vim_strsave(numbuf);\n    }\n#endif\n    else\n\tretval = vim_strsave(tv_get_string(tv));\n    return retval;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":463122,"func":"static void annotation_get_freespace_percent_most(annotate_state_t *state,\n                     struct annotate_entry_list *entry)\n{\n    uint64_t avail = 0;\n    uint64_t total = 0;\n    struct buf value = BUF_INITIALIZER;\n\n    (void) partlist_local_find_freespace_most(1, &avail, &total, NULL, NULL);\n    buf_printf(&value, \"%\" PRIuMAX \";%\" PRIuMAX, (uintmax_t)avail, (uintmax_t)total);\n    output_entryatt(state, entry->name, \"\", &value);\n    buf_free(&value);\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":247710,"func":"  const std::vector<std::string>& expectedLocalUri() const { return expected_local_uri_; }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":238643,"func":"static void do_refine_retval_range(struct bpf_reg_state *regs, int ret_type,\n\t\t\t\t   int func_id,\n\t\t\t\t   struct bpf_call_arg_meta *meta)\n{\n\tstruct bpf_reg_state *ret_reg = ®s[BPF_REG_0];\n\n\tif (ret_type != RET_INTEGER ||\n\t    (func_id != BPF_FUNC_get_stack &&\n\t     func_id != BPF_FUNC_get_task_stack &&\n\t     func_id != BPF_FUNC_probe_read_str &&\n\t     func_id != BPF_FUNC_probe_read_kernel_str &&\n\t     func_id != BPF_FUNC_probe_read_user_str))\n\t\treturn;\n\n\tret_reg->smax_value = meta->msize_max_value;\n\tret_reg->s32_max_value = meta->msize_max_value;\n\tret_reg->smin_value = -MAX_ERRNO;\n\tret_reg->s32_min_value = -MAX_ERRNO;\n\t__reg_deduce_bounds(ret_reg);\n\t__reg_bound_offset(ret_reg);\n\t__update_reg_bounds(ret_reg);\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":450826,"func":"void st21nfca_se_init(struct nfc_hci_dev *hdev)\n{\n\tstruct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);\n\n\tinit_completion(&info->se_info.req_completion);\n\t\/* initialize timers *\/\n\ttimer_setup(&info->se_info.bwi_timer, st21nfca_se_wt_timeout, 0);\n\tinfo->se_info.bwi_active = false;\n\n\ttimer_setup(&info->se_info.se_active_timer,\n\t\t    st21nfca_se_activation_timeout, 0);\n\tinfo->se_info.se_active = false;\n\n\tinfo->se_info.count_pipes = 0;\n\tinfo->se_info.expected_pipes = 0;\n\n\tinfo->se_info.xch_error = false;\n\n\tinfo->se_info.wt_timeout =\n\t\t\tST21NFCA_BWI_TO_TIMEOUT(ST21NFCA_ATR_DEFAULT_BWI);\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":238328,"func":"static struct digest_algo *digest_algo_get_by_algo(enum hash_algo algo)\n{\n\tstruct digest_algo *d = NULL;\n\tstruct digest_algo *tmp;\n\tint priority = -1;\n\n\tlist_for_each_entry(tmp, &digests, list) {\n\t\tif (tmp->base.algo != algo)\n\t\t\tcontinue;\n\n\t\tif (tmp->base.priority <= priority)\n\t\t\tcontinue;\n\n\t\td = tmp;\n\t\tpriority = tmp->base.priority;\n\t}\n\n\treturn d;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":436069,"func":"\nstatic int io_register_iowq_aff(struct io_ring_ctx *ctx, void __user *arg,\n\t\t\t\tunsigned len)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\tcpumask_var_t new_mask;\n\tint ret;\n\n\tif (!tctx || !tctx->io_wq)\n\t\treturn -EINVAL;\n\n\tif (!alloc_cpumask_var(&new_mask, GFP_KERNEL))\n\t\treturn -ENOMEM;\n\n\tcpumask_clear(new_mask);\n\tif (len > cpumask_size())\n\t\tlen = cpumask_size();\n\n\tif (copy_from_user(new_mask, arg, len)) {\n\t\tfree_cpumask_var(new_mask);\n\t\treturn -EFAULT;\n\t}\n\n\tret = io_wq_cpu_affinity(tctx->io_wq, new_mask);\n\tfree_cpumask_var(new_mask);\n\treturn ret;","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":445956,"func":"fr_window_unmap (GtkWidget *widget)\n{\n\tFrWindow    *window = FR_WINDOW (widget);\n\tGtkSortType  order;\n\tint          column_id;\n\n\tif (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store),\n\t\t\t\t\t\t  &column_id,\n\t\t\t\t\t\t  &order))\n\t{\n\t\tg_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD, column_id);\n\t\tg_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE, order);\n\t}\n\n\tGTK_WIDGET_CLASS (fr_window_parent_class)->unmap (widget);\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":498155,"func":"const char *cgit_loginurl(void)\n{\n\tstatic const char *login_url;\n\tif (!login_url)\n\t\tlogin_url = fmtalloc(\"%s?p=login\", cgit_rooturl());\n\treturn login_url;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":229177,"func":"static void virtio_serial_class_init(ObjectClass *klass, void *data)\n{\n    DeviceClass *dc = DEVICE_CLASS(klass);\n    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);\n    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);\n\n    QLIST_INIT(&vserdevices.devices);\n\n    dc->props = virtio_serial_properties;\n    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);\n    vdc->realize = virtio_serial_device_realize;\n    vdc->unrealize = virtio_serial_device_unrealize;\n    vdc->get_features = get_features;\n    vdc->get_config = get_config;\n    vdc->set_status = set_status;\n    vdc->reset = vser_reset;\n    vdc->save = virtio_serial_save_device;\n    vdc->load = virtio_serial_load_device;\n    hc->plug = virtser_port_device_plug;\n    hc->unplug = qdev_simple_device_unplug_cb;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":294697,"func":"test_unit_v2v(VALUE i,\n\t      VALUE (* conv1)(VALUE),\n\t      VALUE (* conv2)(VALUE))\n{\n    VALUE c, o;\n    c = (*conv1)(i);\n    o = (*conv2)(c);\n    return f_eqeq_p(o, i);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":336659,"func":"static void reds_late_initialization(RedsState *reds)\n{\n    \/\/ do only once\n    if (reds->late_initialization_done) {\n        return;\n    }\n\n    \/\/ create stream channels for streaming devices\n    for (auto dev: reds->char_devices) {\n        auto stream_dev = dynamic_cast<StreamDevice*>(dev.get());\n        if (stream_dev) {\n            stream_dev->create_channel();\n        }\n    }\n    reds->late_initialization_done = true;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":244145,"func":"GF_Box *jp2h_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_J2KHeaderBox, GF_ISOM_BOX_TYPE_JP2H);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":366267,"func":"static void __touch_mnt_namespace(struct mnt_namespace *ns)\n{\n\tif (ns && ns->event != event) {\n\t\tns->event = event;\n\t\twake_up_interruptible(&ns->poll);\n\t}\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":226042,"func":"void dref_box_del(GF_Box *s)\n{\n\tGF_DataReferenceBox *ptr = (GF_DataReferenceBox *) s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":274870,"func":"TEST(ComparisonsTest, GreaterBroadcastTwoD) {\n  ComparisonOpModel model({1, 1, 2, 4}, {1, 1, 1, 4}, TensorType_INT32,\n                          BuiltinOperator_GREATER);\n  model.PopulateTensor<int>(model.input1(), {-1, 9, 7, 3, 2, 4, 2, 8});\n  model.PopulateTensor<int>(model.input2(), {7, 1, 2, 4});\n  model.Invoke();\n\n  EXPECT_THAT(model.GetOutput(),\n              ElementsAre(false, true, true, false, false, true, false, true));\n  EXPECT_THAT(model.GetOutputShape(), ElementsAre(1, 1, 2, 4));\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":459207,"func":"tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp)\n{\n\tstruct tcf_proto *tp_next = __tcf_get_next_proto(chain, tp);\n\n\tif (tp)\n\t\ttcf_proto_put(tp, true, NULL);\n\n\treturn tp_next;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":313745,"func":"nv_home(cmdarg_T *cap)\n{\n    \/\/ CTRL-HOME is like \"gg\"\n    if (mod_mask & MOD_MASK_CTRL)\n\tnv_goto(cap);\n    else\n    {\n\tcap->count0 = 1;\n\tnv_pipe(cap);\n    }\n    ins_at_eol = FALSE;\t    \/\/ Don't move cursor past eol (only necessary in a\n\t\t\t    \/\/ one-character line).\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":488376,"func":"static inline unsigned long zap_pud_range(struct mmu_gather *tlb,\n\t\t\t\tstruct vm_area_struct *vma, pgd_t *pgd,\n\t\t\t\tunsigned long addr, unsigned long end,\n\t\t\t\tlong *zap_work, struct zap_details *details)\n{\n\tpud_t *pud;\n\tunsigned long next;\n\n\tpud = pud_offset(pgd, addr);\n\tdo {\n\t\tnext = pud_addr_end(addr, end);\n\t\tif (pud_none_or_clear_bad(pud)) {\n\t\t\t(*zap_work)--;\n\t\t\tcontinue;\n\t\t}\n\t\tnext = zap_pmd_range(tlb, vma, pud, addr, next,\n\t\t\t\t\t\tzap_work, details);\n\t} while (pud++, addr = next, (addr != end && *zap_work > 0));\n\n\treturn addr;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":231526,"func":"update_map (char * const mapping, const char * const map_file)\n{\n  const size_t map_len = strlen (mapping);\n\n  const int fd = xopen (map_file, O_WRONLY, 0);\n  xwrite (fd, mapping, map_len);\n  xclose (fd);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":261963,"func":"njs_decode_utf8(njs_str_t *dst, const njs_str_t *src)\n{\n    njs_unicode_decode_t  ctx;\n\n    njs_utf8_decode_init(&ctx);\n\n    (void) njs_utf8_stream_encode(&ctx, src->start, src->start + src->length,\n                                  dst->start, 1, 0);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":226436,"func":"  const DataTypeVector& output_dtypes() const override { return dtypes_; }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":242667,"func":"dissect_header_lens_v1(tvbuff_t *tvb, int offset, proto_tree *tree, int encoding, int * const *hf_indexes)\n{\n    int param_count;\n    proto_item *ti;\n    proto_tree *len_tree;\n\n    for (param_count = 0; hf_indexes[param_count]; param_count++);\n\n    ti = proto_tree_add_item(tree, hf_se_param_lens, tvb, offset, param_count * SYSDIG_PARAM_SIZE, ENC_NA);\n    len_tree = proto_item_add_subtree(ti, ett_sysdig_parm_lens);\n\n    for (param_count = 0; hf_indexes[param_count]; param_count++) {\n        proto_tree_add_item(len_tree, hf_se_param_len, tvb, offset + (param_count * SYSDIG_PARAM_SIZE), SYSDIG_PARAM_SIZE, encoding);\n    }\n\n    proto_item_set_len(ti, param_count * SYSDIG_PARAM_SIZE);\n    return param_count * SYSDIG_PARAM_SIZE;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":386578,"func":"void DL_Dxf::writeVertex(DL_WriterA& dw,\n                         const DL_VertexData& data) {\n\n\n    if (version==DL_VERSION_2000) {\n        dw.dxfReal(10, data.x);\n        dw.dxfReal(20, data.y);\n        if (fabs(data.bulge)>1.0e-10) {\n            dw.dxfReal(42, data.bulge);\n        }\n    } else {\n        dw.entity(\"VERTEX\");\n        \/\/dw.entityAttributes(attrib);\n        dw.dxfString(8, polylineLayer);\n        dw.coord(DL_VERTEX_COORD_CODE, data.x, data.y, data.z);\n        if (fabs(data.bulge)>1.0e-10) {\n            dw.dxfReal(42, data.bulge);\n        }\n    }\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":512843,"func":"void Item_equal::merge_into_list(THD *thd, List<Item_equal> *list,\n                                 bool save_merged,\n                                 bool only_intersected)\n{\n  Item_equal *item;\n  List_iterator<Item_equal> it(*list);\n  Item_equal *merge_into= NULL;\n  while((item= it++))\n  {\n    if (!merge_into)\n    {\n      if (item->merge_with_check(thd, this, save_merged))\n        merge_into= item;\n    }\n    else\n    {\n      if (merge_into->merge_with_check(thd, item, false))\n        it.remove();\n    }\n  }\n  if (!only_intersected && !merge_into)\n    list->push_back(this, thd->mem_root);\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":462275,"func":"PJ_DEF(pj_status_t)  pj_stun_msg_add_uint64_attr(pj_pool_t *pool,\n\t\t\t\t\t         pj_stun_msg *msg,\n\t\t\t\t\t         int attr_type,\n\t\t\t\t\t         const pj_timestamp *value)\n{\n    pj_stun_uint64_attr *attr = NULL;\n    pj_status_t status;\n\n    status = pj_stun_uint64_attr_create(pool, attr_type, value, &attr);\n    if (status != PJ_SUCCESS)\n\treturn status;\n\n    return pj_stun_msg_add_attr(msg, &attr->hdr);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":326121,"func":"regmbc(int c)\n{\n    if (!has_mbyte && c > 0xff)\n\treturn;\n    if (regcode == JUST_CALC_SIZE)\n\tregsize += (*mb_char2len)(c);\n    else\n\tregcode += (*mb_char2bytes)(c, regcode);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":413837,"func":"static void print_nest_host_error_on(stringStream* ss, Klass* ref_klass, Klass* sel_klass) {\n  assert(ref_klass->is_instance_klass(), \"must be\");\n  assert(sel_klass->is_instance_klass(), \"must be\");\n  InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);\n  InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);\n  const char* nest_host_error_1 = ref_ik->nest_host_error();\n  const char* nest_host_error_2 = sel_ik->nest_host_error();\n  if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {\n    ss->print(\", (%s%s%s)\",\n              (nest_host_error_1 != NULL) ? nest_host_error_1 : \"\",\n              (nest_host_error_1 != NULL && nest_host_error_2 != NULL) ? \", \" : \"\",\n              (nest_host_error_2 != NULL) ? nest_host_error_2 : \"\");\n  }\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":387840,"func":"oop InstanceKlass::init_lock() const {\n  \/\/ return the init lock from the mirror\n  oop lock = java_lang_Class::init_lock(java_mirror());\n  \/\/ Prevent reordering with any access of initialization state\n  OrderAccess::loadload();\n  assert((oop)lock != NULL || !is_not_initialized(), \/\/ initialized or in_error state\n         \"only fully initialized state can have a null lock\");\n  return lock;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":346470,"func":"ex_scriptencoding(exarg_T *eap)\n{\n    source_cookie_T\t*sp;\n    char_u\t\t*name;\n\n    if (!sourcing_a_script(eap))\n    {\n\temsg(_(e_scriptencoding_used_outside_of_sourced_file));\n\treturn;\n    }\n\n    if (*eap->arg != NUL)\n    {\n\tname = enc_canonize(eap->arg);\n\tif (name == NULL)\t\/\/ out of memory\n\t    return;\n    }\n    else\n\tname = eap->arg;\n\n    \/\/ Setup for conversion from the specified encoding to 'encoding'.\n    sp = (source_cookie_T *)getline_cookie(eap->getline, eap->cookie);\n    convert_setup(&sp->conv, name, p_enc);\n\n    if (name != eap->arg)\n\tvim_free(name);\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":225487,"func":"Status CheckFaninIsRegular(const TensorId& fanin, ErrorHandler handler) {\n  if (!IsTensorIdRegular(fanin)) {\n    return handler(absl::Substitute(\"fanin '$0' must be a regular tensor id\",\n                                    fanin.ToString()));\n  }\n  return Status::OK();\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":417064,"func":"void PlayerGeneric::lastPattern()\n{\n\tif (player)\n\t\tplayer->lastPattern();\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":513094,"func":"Item_func_nullif::int_op()\n{\n  DBUG_ASSERT(fixed == 1);\n  longlong value;\n  if (!compare())\n  {\n    null_value=1;\n    return 0;\n  }\n  value= args[2]->val_int();\n  null_value= args[2]->null_value;\n  return value;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":234143,"func":"reset_state_machine (int is_stmt)\n{\n  state_machine_regs.address = 0;\n  state_machine_regs.view = 0;\n  state_machine_regs.op_index = 0;\n  state_machine_regs.file = 1;\n  state_machine_regs.line = 1;\n  state_machine_regs.column = 0;\n  state_machine_regs.is_stmt = is_stmt;\n  state_machine_regs.basic_block = 0;\n  state_machine_regs.end_sequence = 0;\n  state_machine_regs.last_file_entry = 0;\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":359434,"func":"community_show_all_iterator (struct hash_backet *backet, struct vty *vty)\n{\n  struct community *com;\n\n  com = (struct community *) backet->data;\n  vty_out (vty, \"[%p] (%ld) %s%s\", backet, com->refcnt,\n\t   community_str (com), VTY_NEWLINE);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":462544,"func":"std::shared_ptr<rss_feed> controller::get_feed_by_url(const std::string& feedurl) {\n\tfor (auto feed : feeds) {\n\t\tif (feedurl == feed->rssurl())\n\t\t\treturn feed;\n\t}\n\tLOG(level::ERROR, \"controller:get_feed_by_url failed for %s\", feedurl);\n\treturn std::shared_ptr<rss_feed>();\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":336135,"func":"static void ip6gre_tnl_parm_from_user(struct __ip6_tnl_parm *p,\n\tconst struct ip6_tnl_parm2 *u)\n{\n\tp->laddr = u->laddr;\n\tp->raddr = u->raddr;\n\tp->flags = u->flags;\n\tp->hop_limit = u->hop_limit;\n\tp->encap_limit = u->encap_limit;\n\tp->flowinfo = u->flowinfo;\n\tp->link = u->link;\n\tp->i_key = u->i_key;\n\tp->o_key = u->o_key;\n\tp->i_flags = gre_flags_to_tnl_flags(u->i_flags);\n\tp->o_flags = gre_flags_to_tnl_flags(u->o_flags);\n\tmemcpy(p->name, u->name, sizeof(u->name));\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":417071,"func":"mp_uint32 PlayerGeneric::getSyncSampleCounter() const\n{\n\tif (player)\n\t\treturn player->getSyncSampleCounter();\n\t\t\n\treturn 0;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":513032,"func":"  TYPELIB *get_typelib() const\n  {\n    return ref ? (*ref)->get_typelib() : NULL;\n  }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":234832,"func":"static int balance_kthread(void *data)\n{\n\tstruct btrfs_fs_info *fs_info = data;\n\tint ret = 0;\n\n\tmutex_lock(&fs_info->balance_mutex);\n\tif (fs_info->balance_ctl)\n\t\tret = btrfs_balance(fs_info, fs_info->balance_ctl, NULL);\n\tmutex_unlock(&fs_info->balance_mutex);\n\n\treturn ret;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":459169,"func":"static void tc_block_indr_cleanup(struct flow_block_cb *block_cb)\n{\n\tstruct tcf_block *block = block_cb->indr.data;\n\tstruct net_device *dev = block_cb->indr.dev;\n\tstruct Qdisc *sch = block_cb->indr.sch;\n\tstruct netlink_ext_ack extack = {};\n\tstruct flow_block_offload bo = {};\n\n\ttcf_block_offload_init(&bo, dev, sch, FLOW_BLOCK_UNBIND,\n\t\t\t       block_cb->indr.binder_type,\n\t\t\t       &block->flow_block, tcf_block_shared(block),\n\t\t\t       &extack);\n\trtnl_lock();\n\tdown_write(&block->cb_lock);\n\tlist_del(&block_cb->driver_list);\n\tlist_move(&block_cb->list, &bo.cb_list);\n\ttcf_block_unbind(block, &bo);\n\tup_write(&block->cb_lock);\n\trtnl_unlock();\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":509574,"func":"void maria_end_backup()\n{\n  translog_enable_purge();\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":252349,"func":"mz_ulong mz_compressBound(mz_ulong source_len) {\n  return mz_deflateBound(NULL, source_len);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":231659,"func":"  explicit FakeServerHandshake(\n      QuicServerConnectionState& conn,\n      std::shared_ptr<FizzServerQuicHandshakeContext> fizzContext,\n      bool chloSync = false,\n      bool cfinSync = false,\n      folly::Optional<uint64_t> clientActiveConnectionIdLimit = folly::none)\n      : FizzServerHandshake(&conn, std::move(fizzContext)),\n        conn_(conn),\n        chloSync_(chloSync),\n        cfinSync_(cfinSync),\n        clientActiveConnectionIdLimit_(clientActiveConnectionIdLimit) {}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":254883,"func":"void DocumentSourceGroup::addAccumulator(AccumulationStatement accumulationStatement) {\n    _accumulatedFields.push_back(accumulationStatement);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":393467,"func":"static SQInteger closure_setroot(HSQUIRRELVM v)\n{\n    if(SQ_FAILED(sq_setclosureroot(v,-2)))\n        return SQ_ERROR;\n    return 1;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":512643,"func":"  Item_cache_year(THD *thd, const Type_handler *handler)\n   :Item_cache_int(thd, handler) { }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":317236,"func":"static int selinux_perf_event_open(struct perf_event_attr *attr, int type)\n{\n\tu32 requested, sid = current_sid();\n\n\tif (type == PERF_SECURITY_OPEN)\n\t\trequested = PERF_EVENT__OPEN;\n\telse if (type == PERF_SECURITY_CPU)\n\t\trequested = PERF_EVENT__CPU;\n\telse if (type == PERF_SECURITY_KERNEL)\n\t\trequested = PERF_EVENT__KERNEL;\n\telse if (type == PERF_SECURITY_TRACEPOINT)\n\t\trequested = PERF_EVENT__TRACEPOINT;\n\telse\n\t\treturn -EINVAL;\n\n\treturn avc_has_perm(&selinux_state, sid, sid, SECCLASS_PERF_EVENT,\n\t\t\t    requested, NULL);\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":234830,"func":"int btrfs_forget_devices(const char *path)\n{\n\tint ret;\n\n\tmutex_lock(&uuid_mutex);\n\tret = btrfs_free_stale_devices(strlen(path) ? path : NULL, NULL);\n\tmutex_unlock(&uuid_mutex);\n\n\treturn ret;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":512836,"func":"  Item_cache(THD *thd):\n    Item(thd),\n    Type_handler_hybrid_field_type(&type_handler_string),\n    example(0), cached_field(0),\n    value_cached(0),\n    used_table_map(0)\n  {\n    maybe_null= 1;\n    null_value= 1;\n    null_value_inside= true;\n  }","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":405374,"func":"static u32 xfrm_pol_bin_key(const void *data, u32 len, u32 seed)\n{\n\tconst struct xfrm_pol_inexact_key *k = data;\n\tu32 a = k->type << 24 | k->dir << 16 | k->family;\n\n\treturn jhash_3words(a, k->if_id, net_hash_mix(read_pnet(&k->net)),\n\t\t\t    seed);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":220235,"func":"Graph::Graph(const FunctionLibraryDefinition& flib_def)\n    : Graph(flib_def.default_registry()) {\n  \/\/ Need a new-enough consumer to support the functions we add to the graph.\n  if (flib_def.num_functions() > 0 && versions_->min_consumer() < 12) {\n    versions_->set_min_consumer(12);\n  }\n  Status s = ops_.AddLibrary(flib_def);\n  CHECK(s.ok()) << s.error_message();\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":270393,"func":"void ok_inflater_set_input(ok_inflater *inflater, const uint8_t *buffer, size_t buffer_length) {\n    if (inflater) {\n        if (inflater->input == inflater->input_end) {\n            inflater->input = buffer;\n            inflater->input_end = inflater->input + buffer_length;\n        } else {\n            ok_inflater_error(inflater, \"ok_inflater_set_input was called with unread input data.\");\n        }\n    }\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":244355,"func":"GF_Box *extr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ExtraDataBox, GF_ISOM_BOX_TYPE_EXTR);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":512303,"func":"  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)\n  {\n    bool res= m_value.to_TIME(thd, ltime, fuzzydate);\n    DBUG_ASSERT(!res);\n    return res;\n  }","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":405393,"func":"xfrm_policy_eval_candidates(struct xfrm_pol_inexact_candidates *cand,\n\t\t\t    struct xfrm_policy *prefer,\n\t\t\t    const struct flowi *fl,\n\t\t\t    u8 type, u16 family, int dir, u32 if_id)\n{\n\tstruct xfrm_policy *tmp;\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(cand->res); i++) {\n\t\ttmp = __xfrm_policy_eval_candidates(cand->res[i],\n\t\t\t\t\t\t    prefer,\n\t\t\t\t\t\t    fl, type, family, dir,\n\t\t\t\t\t\t    if_id);\n\t\tif (!tmp)\n\t\t\tcontinue;\n\n\t\tif (IS_ERR(tmp))\n\t\t\treturn tmp;\n\t\tprefer = tmp;\n\t}\n\n\treturn prefer;\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":437685,"func":"static inline u16 freq_to_clock_divider(unsigned int freq,\n\t\t\t\t\tunsigned int rollovers)\n{\n\treturn count_to_clock_divider(\n\t\t   DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, freq * rollovers));\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":328969,"func":"R_API RBinJavaAttrInfo *r_bin_java_constant_value_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tut64 offset = 6;\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (attr) {\n\t\tattr->type = R_BIN_JAVA_ATTR_TYPE_CONST_VALUE_ATTR;\n\t\tif (offset + 4 < sz) {\n\t\t\tattr->info.constant_value_attr.constantvalue_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\t}\n\t\toffset += 2;\n\t\tattr->size = offset;\n\t}\n\t\/\/ IFDBG r_bin_java_print_constant_value_attr_summary(attr);\n\treturn attr;\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":463151,"func":"static void annotation_get_usercounters(annotate_state_t *state,\n                                        struct annotate_entry_list *entry)\n{\n    struct buf value = BUF_INITIALIZER;\n    struct mboxname_counters counters;\n    char *mboxname = NULL;\n\n    assert(state);\n    assert(state->userid);\n\n    mboxname = mboxname_user_mbox(state->userid, NULL);\n    int r = mboxname_read_counters(mboxname, &counters);\n\n    if (!r) buf_printf(&value, \"%u %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %u\",\n                       counters.version, counters.highestmodseq,\n                       counters.mailmodseq, counters.caldavmodseq,\n                       counters.carddavmodseq, counters.notesmodseq,\n                       counters.mailfoldersmodseq, counters.caldavfoldersmodseq,\n                       counters.carddavfoldersmodseq, counters.notesfoldersmodseq,\n                       counters.quotamodseq, counters.raclmodseq,\n                       counters.uidvalidity);\n\n    output_entryatt(state, entry->name, state->userid, &value);\n    free(mboxname);\n    buf_free(&value);\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":231711,"func":"  void setOneRttKeys() {\n    \/\/ Mimic ServerHandshake behavior.\n    \/\/ oneRttWriteCipher would already be set during ReportEarlyHandshakeSuccess\n    if (!allowZeroRttKeys_) {\n      oneRttWriteCipher_ = createNoOpAead();\n      oneRttWriteHeaderCipher_ = createNoOpHeaderCipher();\n    }\n    oneRttReadCipher_ = createNoOpAead();\n    oneRttReadHeaderCipher_ = createNoOpHeaderCipher();\n  }","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":328872,"func":"R_API char *r_bin_java_print_string_cp_stringify(RBinJavaCPTypeObj *obj) {\n\tut32 size = 255, consumed = 0;\n\tchar *value = malloc (size);\n\tif (value) {\n\t\tmemset (value, 0, size);\n\t\tconsumed = snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tobj->info.cp_string.string_idx);\n\t\tif (consumed >= size - 1) {\n\t\t\tfree (value);\n\t\t\tsize += size >> 1;\n\t\t\tvalue = malloc (size);\n\t\t\tif (value) {\n\t\t\t\tmemset (value, 0, size);\n\t\t\t\t(void)snprintf (value, size, \"%d.0x%04\"PFMT64x \".%s.%d\",\n\t\t\t\t\tobj->metas->ord, obj->file_offset,\n\t\t\t\t\t((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\t\t\tobj->info.cp_string.string_idx);\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":231747,"func":"TEST_P(\n    QuicServerTransportHandshakeTest,\n    TestConnectionSetupWithoutSourceTokenInPsk) {\n  serverCtx->setSendNewSessionTicket(false);\n  expectedSourceToken_ = {clientAddr.getIPAddress()};\n  testSetupConnection();\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":333083,"func":"nfa_dump(nfa_regprog_T *prog)\n{\n    FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, \"a\");\n\n    if (debugf != NULL)\n    {\n\tnfa_print_state(debugf, prog->start);\n\n\tif (prog->reganch)\n\t    fprintf(debugf, \"reganch: %d\\n\", prog->reganch);\n\tif (prog->regstart != NUL)\n\t    fprintf(debugf, \"regstart: %c (decimal: %d)\\n\",\n\t\t\t\t\t      prog->regstart, prog->regstart);\n\tif (prog->match_text != NULL)\n\t    fprintf(debugf, \"match_text: \\\"%s\\\"\\n\", prog->match_text);\n\n\tfclose(debugf);\n    }\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":139246,"func":"void OverlayWindowViews::TogglePlayPause() {\n  bool is_active = controller_->TogglePlayPause();\n  play_pause_controls_view_->SetToggled(is_active);\n}\n","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":231055,"func":"UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue )\r\n{\r\n    UBaseType_t uxReturn;\r\n\r\n    configASSERT( xQueue );\r\n\r\n    taskENTER_CRITICAL();\r\n    {\r\n        uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;\r\n    }\r\n    taskEXIT_CRITICAL();\r\n\r\n    return uxReturn;\r\n} \/*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. *\/\r","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":248328,"func":"DLLIMPORT int cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp)\n{\n\tconst char *str;\n\n\tif (!opt || !fp) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\tswitch (opt->type) {\n\tcase CFGT_INT:\n\t\tfprintf(fp, \"%ld\", cfg_opt_getnint(opt, index));\n\t\tbreak;\n\n\tcase CFGT_FLOAT:\n\t\tfprintf(fp, \"%f\", cfg_opt_getnfloat(opt, index));\n\t\tbreak;\n\n\tcase CFGT_STR:\n\t\tstr = cfg_opt_getnstr(opt, index);\n\t\tfprintf(fp, \"\\\"\");\n\t\twhile (str && *str) {\n\t\t\tif (*str == '\"')\n\t\t\t\tfprintf(fp, \"\\\\\\\"\");\n\t\t\telse if (*str == '\\\\')\n\t\t\t\tfprintf(fp, \"\\\\\\\\\");\n\t\t\telse\n\t\t\t\tfprintf(fp, \"%c\", *str);\n\t\t\tstr++;\n\t\t}\n\t\tfprintf(fp, \"\\\"\");\n\t\tbreak;\n\n\tcase CFGT_BOOL:\n\t\tfprintf(fp, \"%s\", cfg_opt_getnbool(opt, index) ? \"true\" : \"false\");\n\t\tbreak;\n\n\tcase CFGT_NONE:\n\tcase CFGT_SEC:\n\tcase CFGT_FUNC:\n\tcase CFGT_PTR:\n\tcase CFGT_COMMENT:\n\t\tbreak;\n\t}\n\n\treturn CFG_SUCCESS;\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":225409,"func":"int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl,\n\t\t\t   unsigned nr_of_controls_hint)\n{\n\thdl->error = 0;\n\treturn 0;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":231050,"func":"    QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,\r\n                                           StaticQueue_t * pxStaticQueue )\r\n    {\r\n        QueueHandle_t xNewQueue;\r\n        const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;\r\n\r\n        \/* Prevent compiler warnings about unused parameters if\r\n         * configUSE_TRACE_FACILITY does not equal 1. *\/\r\n        ( void ) ucQueueType;\r\n\r\n        xNewQueue = xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );\r\n        prvInitialiseMutex( ( Queue_t * ) xNewQueue );\r\n\r\n        return xNewQueue;\r\n    }\r","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":225605,"func":"\nGF_Box *tfdt_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TFBaseMediaDecodeTimeBox, GF_ISOM_BOX_TYPE_TFDT);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":424957,"func":"static int iwl_dbgfs_monitor_data_open(struct inode *inode,\n\t\t\t\t       struct file *file)\n{\n\tstruct iwl_trans *trans = inode->i_private;\n\tstruct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);\n\n\tif (!trans->dbg.dest_tlv ||\n\t    trans->dbg.dest_tlv->monitor_mode != EXTERNAL_MODE) {\n\t\tIWL_ERR(trans, \"Debug destination is not set to DRAM\\n\");\n\t\treturn -ENOENT;\n\t}\n\n\tif (trans_pcie->fw_mon_data.state != IWL_FW_MON_DBGFS_STATE_CLOSED)\n\t\treturn -EBUSY;\n\n\ttrans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_OPEN;\n\treturn simple_open(inode, file);\n}","target":0,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":452259,"func":"\tPHP_FALIAS(getSecurityPrefs, xsl_xsltprocessor_get_security_prefs, arginfo_xsl_xsltprocessor_get_security_prefs)\n\t{NULL, NULL, NULL}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":508905,"func":"bool LEX::need_correct_ident()\n{\n  switch(sql_command)\n  {\n  case SQLCOM_SHOW_CREATE:\n  case SQLCOM_SHOW_TABLES:\n  case SQLCOM_CREATE_VIEW:\n    return TRUE;\n  default:\n    return FALSE;\n  }\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":336527,"func":"static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *client)\n{\n    auto &clients(reds->mig_wait_disconnect_clients);\n    g_warn_if_fail(std::find(clients.begin(), clients.end(), client) != clients.end());\n\n    clients.remove(client);\n    if (clients.empty()) {\n       reds_mig_cleanup(reds);\n    }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":312400,"func":"existing_swapfile(buf_T *buf)\n{\n    if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)\n    {\n\tchar_u *fname = buf->b_ml.ml_mfp->mf_fname;\n\tsize_t len = STRLEN(fname);\n\n\treturn fname[len - 1] != 'p' || fname[len - 2] != 'w';\n    }\n    return FALSE;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":328972,"func":"R_API void r_bin_java_get_interface_json_definitions(RBinJavaObj *bin, PJ *pj) {\n\tRList *the_list;\n\tRListIter *iter = NULL;\n\tchar *new_str;\n\n\tpj_ka (pj, \"interfaces\");\n\n\tif (!bin || !(the_list = r_bin_java_get_interface_names (bin))) {\n\t\tpj_end (pj);\n\t\treturn;\n\t}\n\n\tr_list_foreach (the_list, iter, new_str) {\n\t\tchar *tmp = new_str;\n\t\t\/\/ eprintf (\"Processing string: %s\\n\", new_str);\n\t\twhile (*tmp) {\n\t\t\tif (*tmp == '\/') {\n\t\t\t\t*tmp = '.';\n\t\t\t}\n\t\t\ttmp++;\n\t\t}\n\t\tpj_s (pj, new_str);\n\t}\n\tr_list_free (the_list);\n\tpj_end (pj);\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":393527,"func":"static SQInteger array_reverse(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_arrayreverse(v,-1)) ? 1 : SQ_ERROR;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":369182,"func":"\nstatic void io_poll_cancel_req(struct io_kiocb *req)\n{\n\tio_poll_mark_cancelled(req);\n\t\/* kick tw, which should complete the request *\/\n\tio_poll_execute(req, 0, 0);","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":225456,"func":"Status MutationError(absl::string_view function_name, absl::string_view params,\n                     absl::string_view msg) {\n  return errors::InvalidArgument(absl::Substitute(\n      \"MutableGraphView::$0($1) error: $2.\", function_name, params, msg));\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":220109,"func":"static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t len)\n{\n\tstruct inode *inode = file_inode(filep);\n\tlong ret;\n\n\tif (!S_ISREG(inode->i_mode))\n\t\treturn -EOPNOTSUPP;\n\n\tif ((mode != 0) && (mode != (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE)))\n\t\treturn -EOPNOTSUPP;\n\n\tret = inode_newsize_ok(inode, offset + len);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tif (mode & FALLOC_FL_PUNCH_HOLE)\n\t\treturn nfs42_proc_deallocate(filep, offset, len);\n\treturn nfs42_proc_allocate(filep, offset, len);\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":269509,"func":"static int TIFFReadPixels(TIFF *tiff,const tsample_t sample,\n  const ssize_t row,tdata_t scanline)\n{\n  int\n    status;\n\n  status=TIFFReadScanline(tiff,scanline,(uint32) row,sample);\n  return(status);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":463174,"func":"static void annotation_get_uniqueid(annotate_state_t *state,\n                                    struct annotate_entry_list *entry)\n{\n    struct buf value = BUF_INITIALIZER;\n\n    assert(state->mailbox);\n\n    if (state->mailbox->uniqueid)\n        buf_appendcstr(&value, state->mailbox->uniqueid);\n\n    output_entryatt(state, entry->name, \"\", &value);\n    buf_free(&value);\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":289309,"func":"static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)\n{\n\tsnd_pcm_oss_release_buffers(substream);\n\tsubstream->oss.oss = 0;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":387608,"func":"static void fill_remaining_elem_value(struct snd_ctl_elem_value *control,\n\t\t\t\t      struct snd_ctl_elem_info *info,\n\t\t\t\t      u32 pattern)\n{\n\tsize_t offset = value_sizes[info->type] * info->count;\n\n\toffset = DIV_ROUND_UP(offset, sizeof(u32));\n\tmemset32((u32 *)control->value.bytes.data + offset, pattern,\n\t\t sizeof(control->value) \/ sizeof(u32) - offset);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":310103,"func":"free_namelist(char **src)\n{\n    if (src != 0) {\n\tint n;\n\tfor (n = 0; src[n] != 0; ++n)\n\t    free(src[n]);\n\tfree(src);\n    }\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":500695,"func":"static inline uint32_t sftp_get_new_id(sftp_session session) {\n  return ++session->id_counter;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":308190,"func":"static void *fastrpc_vmap(struct dma_buf *dmabuf)\n{\n\tstruct fastrpc_buf *buf = dmabuf->priv;\n\n\treturn buf->virt;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":500699,"func":"int sftp_extension_supported(sftp_session sftp, const char *name,\n    const char *data) {\n  int i, n;\n\n  n = sftp_extensions_get_count(sftp);\n  for (i = 0; i < n; i++) {\n    if (strcmp(sftp_extensions_get_name(sftp, i), name) == 0 &&\n        strcmp(sftp_extensions_get_data(sftp, i), data) == 0) {\n      return 1;\n    }\n  }\n\n  return 0;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":373521,"func":"ipf_print_reass_packet(const char *es, const void *pkt)\n{\n    static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10);\n    if (!VLOG_DROP_WARN(&rl)) {\n        struct ds ds = DS_EMPTY_INITIALIZER;\n        ds_put_hex_dump(&ds, pkt, 128, 0, false);\n        VLOG_WARN(\"%s\\n%s\", es, ds_cstr(&ds));\n        ds_destroy(&ds);\n    }\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":364747,"func":"get_tag_details(taggy_T *tag, dict_T *retdict)\n{\n    list_T\t*pos;\n    fmark_T\t*fmark;\n\n    dict_add_string(retdict, \"tagname\", tag->tagname);\n    dict_add_number(retdict, \"matchnr\", tag->cur_match + 1);\n    dict_add_number(retdict, \"bufnr\", tag->cur_fnum);\n    if (tag->user_data)\n\tdict_add_string(retdict, \"user_data\", tag->user_data);\n\n    if ((pos = list_alloc_id(aid_tagstack_from)) == NULL)\n\treturn;\n    dict_add_list(retdict, \"from\", pos);\n\n    fmark = &tag->fmark;\n    list_append_number(pos,\n\t\t\t(varnumber_T)(fmark->fnum != -1 ? fmark->fnum : 0));\n    list_append_number(pos, (varnumber_T)fmark->mark.lnum);\n    list_append_number(pos, (varnumber_T)(fmark->mark.col == MAXCOL ?\n\t\t\t\t\tMAXCOL : fmark->mark.col + 1));\n    list_append_number(pos, (varnumber_T)fmark->mark.coladd);\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":252467,"func":"static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip,\n                                         mz_uint64 cur_file_ofs, mz_uint32 n) {\n  char buf[4096];\n  memset(buf, 0, MZ_MIN(sizeof(buf), n));\n  while (n) {\n    mz_uint32 s = MZ_MIN(sizeof(buf), n);\n    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s)\n      return MZ_FALSE;\n    cur_file_ofs += s;\n    n -= s;\n  }\n  return MZ_TRUE;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":313752,"func":"nv_csearch(cmdarg_T *cap)\n{\n    int\t\tt_cmd;\n\n    if (cap->cmdchar == 't' || cap->cmdchar == 'T')\n\tt_cmd = TRUE;\n    else\n\tt_cmd = FALSE;\n\n    cap->oap->motion_type = MCHAR;\n    if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)\n\tclearopbeep(cap->oap);\n    else\n    {\n\tcurwin->w_set_curswant = TRUE;\n\t\/\/ Include a Tab for \"tx\" and for \"dfx\".\n\tif (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD\n\t\t&& (t_cmd || cap->oap->op_type != OP_NOP))\n\t{\n\t    colnr_T\tscol, ecol;\n\n\t    getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);\n\t    curwin->w_cursor.coladd = ecol - scol;\n\t}\n\telse\n\t    curwin->w_cursor.coladd = 0;\n\tadjust_for_sel(cap);\n#ifdef FEAT_FOLDING\n\tif ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)\n\t    foldOpenCursor();\n#endif\n    }\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":231034,"func":"    QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )\r\n    {\r\n        QueueHandle_t xNewQueue;\r\n        const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;\r\n\r\n        xNewQueue = xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType );\r\n        prvInitialiseMutex( ( Queue_t * ) xNewQueue );\r\n\r\n        return xNewQueue;\r\n    }\r","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":317308,"func":"static void selinux_perf_event_free(struct perf_event *event)\n{\n\tstruct perf_event_security_struct *perfsec = event->security;\n\n\tevent->security = NULL;\n\tkfree(perfsec);\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":279947,"func":"free_old_sub(void)\n{\n    vim_free(old_sub);\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":210282,"func":"static int i2c_ddc_rx(I2CSlave *i2c)\n{\n    I2CDDCState *s = I2CDDC(i2c);\n\n    int value;\n    value = s->edid_blob[s->reg];\n    s->reg++;\n    return value;\n}","target":1,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":500660,"func":"void sftp_file_set_nonblocking(sftp_file handle){\n    handle->nonblocking=1;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":247612,"func":"  const std::string& clientCtxYaml() const { return client_ctx_yaml_; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":301395,"func":"static struct dirent *vfswrap_readdir(vfs_handle_struct *handle,\n\t\t\t\t          DIR *dirp,\n\t\t\t\t\t  SMB_STRUCT_STAT *sbuf)\n{\n\tstruct dirent *result;\n\n\tSTART_PROFILE(syscall_readdir);\n\tresult = readdir(dirp);\n\tEND_PROFILE(syscall_readdir);\n\tif (sbuf) {\n\t\t\/* Default Posix readdir() does not give us stat info.\n\t\t * Set to invalid to indicate we didn't return this info. *\/\n\t\tSET_STAT_INVALID(*sbuf);\n#if defined(HAVE_DIRFD) && defined(HAVE_FSTATAT)\n\t\tif (result != NULL) {\n\t\t\t\/* See if we can efficiently return this. *\/\n\t\t\tstruct stat st;\n\t\t\tint flags = (lp_posix_pathnames() ?\n\t\t\t\tAT_SYMLINK_NOFOLLOW : 0);\n\t\t\tint ret = fstatat(dirfd(dirp),\n\t\t\t\t\tresult->d_name,\n\t\t\t\t\t&st,\n\t\t\t\t\tflags);\n\t\t\tif (ret == 0) {\n\t\t\t\tinit_stat_ex_from_stat(sbuf,\n\t\t\t\t\t&st,\n\t\t\t\t\tlp_fake_dir_create_times(\n\t\t\t\t\t\tSNUM(handle->conn)));\n\t\t\t}\n\t\t}\n#endif\n\t}\n\treturn result;\n}","target":0,"code_token_length":244,"total_token_length":480,"max_tokens_setting":512}
+{"idx":244091,"func":"GF_Err lsr1_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox*)s;\n\n\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);\n\tif (e) return e;\n\n\tISOM_DECREASE_SIZE(ptr, 8);\n\n\treturn gf_isom_box_array_read(s, bs);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":231666,"func":"TEST_F(QuicServerTransportTest, SetCongestionControl) {\n  \/\/ Default: Cubic\n  auto cc = server->getConn().congestionController.get();\n  EXPECT_EQ(CongestionControlType::Cubic, cc->type());\n\n  \/\/ Change to Reno\n  server->setCongestionControl(CongestionControlType::NewReno);\n  cc = server->getConn().congestionController.get();\n  EXPECT_EQ(CongestionControlType::NewReno, cc->type());\n\n  \/\/ Change back to Cubic:\n  server->setCongestionControl(CongestionControlType::Cubic);\n  cc = server->getConn().congestionController.get();\n  EXPECT_EQ(CongestionControlType::Cubic, cc->type());\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":386563,"func":"void DL_Dxf::addDimDiametric(DL_CreationInterface* creationInterface) {\n    DL_DimensionData d = getDimData();\n\n    \/\/ diametric dimension:\n    DL_DimDiametricData dr(\n        \/\/ definition point\n        getRealValue(15, 0.0),\n        getRealValue(25, 0.0),\n        getRealValue(35, 0.0),\n        \/\/ leader length:\n        getRealValue(40, 0.0));\n    creationInterface->addDimDiametric(d, dr);\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":274732,"func":"callbacks_new_project_activate (GtkMenuItem *menuitem, gpointer user_data)\n{\n\tif (mainProject->last_loaded >= 0) {\n\t\tif (!interface_get_alert_dialog_response (\n\t\t\t_(\"Do you want to close any open layers \"\n\t\t\t\"and start a new project?\"),\n\t\t\t_(\"Starting a new project will cause all currently \"\n\t\t\t\"open layers to be closed. Any unsaved changes \"\n\t\t\t\"will be lost.\"),\n\t\t\tFALSE, NULL, GTK_STOCK_CLOSE, GTK_STOCK_CANCEL))\n\t\t\treturn;\n\t}\n\t\/* Unload all layers and then clear layer window *\/\n\tgerbv_unload_all_layers (mainProject);\n\tcallbacks_update_layer_tree ();\n\tselection_clear (&screen.selectionInfo);\n\tupdate_selected_object_message (FALSE);\n\t\n\t\/* Destroy project info *\/\n\tif (mainProject->project) {\n\t    g_free(mainProject->project);\n\t    mainProject->project = NULL;\n\t}\n\trender_refresh_rendered_image_on_screen();\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":385859,"func":"SYSCALL_DEFINE0(vhangup)\n{\n\tif (capable(CAP_SYS_TTY_CONFIG)) {\n\t\ttty_vhangup_self();\n\t\treturn 0;\n\t}\n\treturn -EPERM;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":226248,"func":"\nGF_Err clap_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_CleanApertureBox *ptr = (GF_CleanApertureBox *)s;\n\tGF_Err e = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->cleanApertureWidthN);\n\tgf_bs_write_u32(bs, ptr->cleanApertureWidthD);\n\tgf_bs_write_u32(bs, ptr->cleanApertureHeightN);\n\tgf_bs_write_u32(bs, ptr->cleanApertureHeightD);\n\tgf_bs_write_u32(bs, (u32) ptr->horizOffN);\n\tgf_bs_write_u32(bs, ptr->horizOffD);\n\tgf_bs_write_u32(bs, (u32) ptr->vertOffN);\n\tgf_bs_write_u32(bs, ptr->vertOffD);\n\treturn GF_OK;","target":0,"code_token_length":206,"total_token_length":442,"max_tokens_setting":512}
+{"idx":316953,"func":"static int selinux_kernel_create_files_as(struct cred *new, struct inode *inode)\n{\n\tstruct inode_security_struct *isec = inode_security(inode);\n\tstruct task_security_struct *tsec = selinux_cred(new);\n\tu32 sid = current_sid();\n\tint ret;\n\n\tret = avc_has_perm(&selinux_state,\n\t\t\t   sid, isec->sid,\n\t\t\t   SECCLASS_KERNEL_SERVICE,\n\t\t\t   KERNEL_SERVICE__CREATE_FILES_AS,\n\t\t\t   NULL);\n\n\tif (ret == 0)\n\t\ttsec->create_sid = isec->sid;\n\treturn ret;\n}","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":512693,"func":"int Arg_comparator::compare_e_real()\n{\n  double val1= (*a)->val_real();\n  double val2= (*b)->val_real();\n  if ((*a)->null_value || (*b)->null_value)\n    return MY_TEST((*a)->null_value && (*b)->null_value);\n  return MY_TEST(val1 == val2);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":409523,"func":"check_shellsize(void)\n{\n    if (Rows < min_rows())\t\/\/ need room for one window and command line\n\tRows = min_rows();\n    limit_screen_size();\n\n    \/\/ make sure these values are not invalid\n    if (cmdline_row >= Rows)\n\tcmdline_row = Rows - 1;\n    if (msg_row >= Rows)\n\tmsg_row = Rows - 1;\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":317037,"func":"static int selinux_kernel_act_as(struct cred *new, u32 secid)\n{\n\tstruct task_security_struct *tsec = selinux_cred(new);\n\tu32 sid = current_sid();\n\tint ret;\n\n\tret = avc_has_perm(&selinux_state,\n\t\t\t   sid, secid,\n\t\t\t   SECCLASS_KERNEL_SERVICE,\n\t\t\t   KERNEL_SERVICE__USE_AS_OVERRIDE,\n\t\t\t   NULL);\n\tif (ret == 0) {\n\t\ttsec->sid = secid;\n\t\ttsec->create_sid = 0;\n\t\ttsec->keycreate_sid = 0;\n\t\ttsec->sockcreate_sid = 0;\n\t}\n\treturn ret;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":300780,"func":"static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg)\n{\n\tstruct sock *sk = &tsk->sk;\n\tu32 self = tipc_own_addr(sock_net(sk));\n\tu32 peer_port = tsk_peer_port(tsk);\n\tu32 orig_node, peer_node;\n\n\tif (unlikely(!tipc_sk_connected(sk)))\n\t\treturn false;\n\n\tif (unlikely(msg_origport(msg) != peer_port))\n\t\treturn false;\n\n\torig_node = msg_orignode(msg);\n\tpeer_node = tsk_peer_node(tsk);\n\n\tif (likely(orig_node == peer_node))\n\t\treturn true;\n\n\tif (!orig_node && peer_node == self)\n\t\treturn true;\n\n\tif (!peer_node && orig_node == self)\n\t\treturn true;\n\n\treturn false;\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":446090,"func":"static int atusb_read_subreg(struct atusb *lp,\n\t\t\t     unsigned int addr, unsigned int mask,\n\t\t\t     unsigned int shift)\n{\n\tint rc;\n\n\trc = atusb_read_reg(lp, addr);\n\trc = (rc & mask) >> shift;\n\n\treturn rc;\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":273906,"func":"static void handle_PASV(ctrl_t *ctrl, char *arg)\n{\n\tstruct sockaddr_in data;\n\tsocklen_t len = sizeof(data);\n\tchar *msg, *p, buf[200];\n\tint port;\n\n\tif (do_PASV(ctrl, arg, (struct sockaddr *)&data, &len))\n\t\treturn;\n\n\t\/* Convert server IP address and port to comma separated list *\/\n\tmsg = strdup(ctrl->serveraddr);\n\tif (!msg) {\n\t\tsend_msg(ctrl->sd, \"426 Internal server error.\\r\\n\");\n\t\texit(1);\n\t}\n\tp = msg;\n\twhile ((p = strchr(p, '.')))\n\t\t*p++ = ',';\n\n\tport = ntohs(data.sin_port);\n\tsnprintf(buf, sizeof(buf), \"227 Entering Passive Mode (%s,%d,%d)\\r\\n\",\n\t\t msg, port \/ 256, port % 256);\n\tsend_msg(ctrl->sd, buf);\n\n\tfree(msg);\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":225846,"func":"\nGF_Err emsg_box_size(GF_Box *s)\n{\n\tGF_EventMessageBox *ptr = (GF_EventMessageBox*) s;\n\n\tptr->size += 4;\n\tif (ptr->version) {\n\t\tptr->size += 20;\n\t} else {\n\t\tptr->size += 16;\n\t}\n\tptr->size+=2; \/\/1 NULL-terminated strings\n\tif (ptr->scheme_id_uri) ptr->size += strlen(ptr->scheme_id_uri);\n\tif (ptr->value) ptr->size += strlen(ptr->value);\n\tif (ptr->message_data)\n\t\tptr->size += ptr->message_data_size;\n\n\treturn GF_OK;","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":473965,"func":"utf16le_code_to_mbclen(OnigCodePoint code,\n\t\t       OnigEncoding enc ARG_UNUSED)\n{\n  return (code > 0xffff ? 4 : 2);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":513268,"func":"join_read_system(JOIN_TAB *tab)\n{\n  TABLE *table= tab->table;\n  int error;\n  if (table->status & STATUS_GARBAGE)\t\t\/\/ If first read\n  {\n    if ((error= table->file->ha_read_first_row(table->record[0],\n                                               table->s->primary_key)))\n    {\n      if (error != HA_ERR_END_OF_FILE)\n\treturn report_error(table, error);\n      mark_as_null_row(tab->table);\n      empty_record(table);\t\t\t\/\/ Make empty record\n      return -1;\n    }\n    store_record(table,record[1]);\n  }\n  else if (!table->status)\t\t\t\/\/ Only happens with left join\n    restore_record(table,record[1]);\t\t\t\/\/ restore old record\n  table->null_row=0;\n  return table->status ? -1 : 0;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":207069,"func":"static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr,\n\t\t\t      const char *buf, size_t nbytes)\n{\n\tchar drc_name[MAX_DRC_NAME_LEN];\n\tchar *end;\n\tint rc;\n\n\tif (nbytes >= MAX_DRC_NAME_LEN)\n\t\treturn 0;\n\n\tmemcpy(drc_name, buf, nbytes);\n\n\tend = strchr(drc_name, '\\n');\n\tif (!end)\n\t\tend = &drc_name[nbytes];\n\t*end = '\\0';\n\n\trc = dlpar_add_slot(drc_name);\n\tif (rc)\n\t\treturn rc;\n\n\treturn nbytes;\n}","target":1,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":373542,"func":"ipf_reassembled_list_remove(struct reassembled_pkt *rp)\n    \/* OVS_REQUIRES(ipf_lock) *\/\n{\n    ovs_list_remove(&rp->rp_list_node);\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":377477,"func":"ut64 r_coresym_cache_element_pa2va(RCoreSymCacheElement *element, ut64 pa) {\n\tsize_t i;\n\tfor (i = 0; i < element->hdr->n_segments; i++) {\n\t\tRCoreSymCacheElementSegment *seg = &element->segments[i];\n\t\tif (seg->size == 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (seg->paddr < pa && pa < seg->paddr + seg->size) {\n\t\t\treturn pa - seg->paddr + seg->vaddr;\n\t\t}\n\t}\n\treturn pa;\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":437375,"func":"divide_look_behind_alternatives(Node* node)\n{\n  Node *head, *np, *insert_node;\n  AnchorNode* an = ANCHOR_(node);\n  int anc_type = an->type;\n\n  head = NODE_ANCHOR_BODY(an);\n  np = NODE_CAR(head);\n  swap_node(node, head);\n  NODE_CAR(node) = head;\n  NODE_BODY(head) = np;\n\n  np = node;\n  while (IS_NOT_NULL(np = NODE_CDR(np))) {\n    insert_node = onig_node_new_anchor(anc_type, an->ascii_mode);\n    CHECK_NULL_RETURN_MEMERR(insert_node);\n    NODE_BODY(insert_node) = NODE_CAR(np);\n    NODE_CAR(np) = insert_node;\n  }\n\n  if (anc_type == ANCHOR_LOOK_BEHIND_NOT) {\n    np = node;\n    do {\n      NODE_SET_TYPE(np, NODE_LIST);  \/* alt -> list *\/\n    } while (IS_NOT_NULL(np = NODE_CDR(np)));\n  }\n  return 0;\n}","target":0,"code_token_length":213,"total_token_length":449,"max_tokens_setting":512}
+{"idx":226073,"func":"\nGF_Err trgr_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_TrackGroupBox *ptr = (GF_TrackGroupBox *)s;\n\n\tBOX_FIELD_LIST_ASSIGN(groups)\n\treturn gf_list_add(ptr->groups, a);","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":293534,"func":"PJ_DEF(void) pj_cis_del_range( pj_cis_t *cis, int cstart, int cend)\n{\n    while (cstart != cend) {\n        PJ_CIS_CLR(cis, cstart);\n        cstart++;\n    }\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":317228,"func":"static int selinux_mount(const char *dev_name,\n\t\t\t const struct path *path,\n\t\t\t const char *type,\n\t\t\t unsigned long flags,\n\t\t\t void *data)\n{\n\tconst struct cred *cred = current_cred();\n\n\tif (flags & MS_REMOUNT)\n\t\treturn superblock_has_perm(cred, path->dentry->d_sb,\n\t\t\t\t\t   FILESYSTEM__REMOUNT, NULL);\n\telse\n\t\treturn path_has_perm(cred, path, FILE__MOUNTON);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":359275,"func":"DEFUN (clear_bgp_external_in_prefix_filter,\n       clear_bgp_external_in_prefix_filter_cmd,\n       \"clear bgp external in prefix-filter\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all external peers\\n\"\n       \"Soft reconfig inbound update\\n\"\n       \"Push out prefix-list ORF and do inbound soft reconfig\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,\n\t\t\tBGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":343149,"func":"static void esp_free_tcp_sk(struct rcu_head *head)\n{\n\tstruct esp_tcp_sk *esk = container_of(head, struct esp_tcp_sk, rcu);\n\n\tsock_put(esk->sk);\n\tkfree(esk);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":409416,"func":"report_term_error(char *error_msg, char_u *term)\n{\n    struct builtin_term *termp;\n    int\t\t\ti;\n\n    mch_errmsg(\"\\r\\n\");\n    if (error_msg != NULL)\n    {\n\tmch_errmsg(error_msg);\n\tmch_errmsg(\"\\r\\n\");\n    }\n    mch_errmsg(\"'\");\n    mch_errmsg((char *)term);\n    mch_errmsg(_(\"' not known. Available builtin terminals are:\"));\n    mch_errmsg(\"\\r\\n\");\n    for (termp = &(builtin_termcaps[0]); termp->bt_string != NULL; ++termp)\n    {\n\tif (termp->bt_entry == (int)KS_NAME\n\t\t&& STRCMP(termp->bt_string, \"gui\") != 0)\n\t{\n#ifdef HAVE_TGETENT\n\t    mch_errmsg(\"    builtin_\");\n#else\n\t    mch_errmsg(\"    \");\n#endif\n\t    mch_errmsg(termp->bt_string);\n\t    mch_errmsg(\"\\r\\n\");\n\t}\n    }\n    \/\/ Output extra 'cmdheight' line breaks to avoid that the following error\n    \/\/ message overwrites the last terminal name.\n    for (i = 1; i < p_ch; ++i)\n\tmch_errmsg(\"\\r\\n\");\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":90821,"func":"  std::string host() const { return host_; }\n","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":508344,"func":"Locked_tables_list::unlock_locked_table(THD *thd, MDL_ticket *mdl_ticket)\n{\n  \/*\n    Ensure we are in locked table mode.\n    As this function is only called on error condition it's better\n    to check this condition here than in the caller.\n  *\/\n  if (thd->locked_tables_mode != LTM_LOCK_TABLES)\n    return;\n\n  if (mdl_ticket)\n  {\n    \/*\n      Under LOCK TABLES we may have several instances of table open\n      and locked and therefore have to remove several metadata lock\n      requests associated with them.\n    *\/\n    thd->mdl_context.release_all_locks_for_name(mdl_ticket);\n  }\n\n  if (thd->lock->table_count == 0)\n    unlock_locked_tables(thd);\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":319418,"func":"ModuleExport size_t RegisterCINImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=SetMagickInfo(\"CIN\");\n  entry->decoder=(DecodeImageHandler *) ReadCINImage;\n  entry->encoder=(EncodeImageHandler *) WriteCINImage;\n  entry->magick=(IsImageFormatHandler *) IsCIN;\n  entry->adjoin=MagickFalse;\n  entry->seekable_stream=MagickTrue;\n  entry->description=ConstantString(\"Cineon Image File\");\n  entry->magick_module=ConstantString(\"CIN\");\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":141,"total_token_length":377,"max_tokens_setting":512}
+{"idx":393486,"func":"static SQInteger base_assert(HSQUIRRELVM v)\n{\n    if(SQVM::IsFalse(stack_get(v,2))){\n        SQInteger top = sq_gettop(v);\n        if (top>2 && SQ_SUCCEEDED(sq_tostring(v,3))) {\n            const SQChar *str = 0;\n            if (SQ_SUCCEEDED(sq_getstring(v,-1,&str))) {\n                return sq_throwerror(v, str);\n            }\n        }\n        return sq_throwerror(v, _SC(\"assertion failed\"));\n    }\n    return 0;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":459102,"func":"__tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp)\n{\n\tu32 prio = 0;\n\n\tASSERT_RTNL();\n\tmutex_lock(&chain->filter_chain_lock);\n\n\tif (!tp) {\n\t\ttp = tcf_chain_dereference(chain->filter_chain, chain);\n\t} else if (tcf_proto_is_deleting(tp)) {\n\t\t\/* 'deleting' flag is set and chain->filter_chain_lock was\n\t\t * unlocked, which means next pointer could be invalid. Restart\n\t\t * search.\n\t\t *\/\n\t\tprio = tp->prio + 1;\n\t\ttp = tcf_chain_dereference(chain->filter_chain, chain);\n\n\t\tfor (; tp; tp = tcf_chain_dereference(tp->next, chain))\n\t\t\tif (!tp->deleting && tp->prio >= prio)\n\t\t\t\tbreak;\n\t} else {\n\t\ttp = tcf_chain_dereference(tp->next, chain);\n\t}\n\n\tif (tp)\n\t\ttcf_proto_get(tp);\n\n\tmutex_unlock(&chain->filter_chain_lock);\n\n\treturn tp;\n}","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":369108,"func":"static int io_epoll_ctl(struct io_kiocb *req, unsigned int issue_flags)\n{\n#if defined(CONFIG_EPOLL)\n\tstruct io_epoll *ie = &req->epoll;\n\tint ret;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\n\tret = do_epoll_ctl(ie->epfd, ie->op, ie->fd, &ie->event, force_nonblock);\n\tif (force_nonblock && ret == -EAGAIN)\n\t\treturn -EAGAIN;\n\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":317095,"func":"static inline u32 file_mask_to_av(int mode, int mask)\n{\n\tu32 av = 0;\n\n\tif (!S_ISDIR(mode)) {\n\t\tif (mask & MAY_EXEC)\n\t\t\tav |= FILE__EXECUTE;\n\t\tif (mask & MAY_READ)\n\t\t\tav |= FILE__READ;\n\n\t\tif (mask & MAY_APPEND)\n\t\t\tav |= FILE__APPEND;\n\t\telse if (mask & MAY_WRITE)\n\t\t\tav |= FILE__WRITE;\n\n\t} else {\n\t\tif (mask & MAY_EXEC)\n\t\t\tav |= DIR__SEARCH;\n\t\tif (mask & MAY_WRITE)\n\t\t\tav |= DIR__WRITE;\n\t\tif (mask & MAY_READ)\n\t\t\tav |= DIR__READ;\n\t}\n\n\treturn av;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":446114,"func":"atusb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)\n{\n\tstruct atusb *atusb = hw->priv;\n\tint ret;\n\n\tif (on) {\n\t\tret = atusb_write_subreg(atusb, SR_AACK_DIS_ACK, 1);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\n\t\tret = atusb_write_subreg(atusb, SR_AACK_PROM_MODE, 1);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t} else {\n\t\tret = atusb_write_subreg(atusb, SR_AACK_PROM_MODE, 0);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\n\t\tret = atusb_write_subreg(atusb, SR_AACK_DIS_ACK, 0);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":186,"total_token_length":422,"max_tokens_setting":512}
+{"idx":238814,"func":"save_incsearch_state(void)\n{\n    saved_search_match_endcol = search_match_endcol;\n    saved_search_match_lines  = search_match_lines;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":261421,"func":"std::string thread_task_ctb_row::name() const {\n  char buf[100];\n  sprintf(buf,\"ctb-row-%d\",debug_startCtbRow);\n  return buf;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":244013,"func":"GF_Err pcmC_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_PCMConfigBox *ptr = (GF_PCMConfigBox *) s;\n\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u8(bs, ptr->format_flags);\n\tgf_bs_write_u8(bs, ptr->PCM_sample_size);\n\treturn GF_OK;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":261765,"func":"void RtmpProtocol::sendChunkSize(uint32_t size) {\n    uint32_t len = htonl(size);\n    std::string set_chunk((char *) &len, 4);\n    sendRequest(MSG_SET_CHUNK, set_chunk);\n    _chunk_size_out = size;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":262035,"func":"ProtoValidationTypeString(const ServiceValidationResultsType t)\n{\n   switch (t) {\n   case VALIDATION_RESULTS_TYPE_NAMEPASSWORD:\n      return VGAUTH_USERHANDLE_TYPE_NAMEPASSWORD;\n   case VALIDATION_RESULTS_TYPE_SSPI:\n      return VGAUTH_USERHANDLE_TYPE_SSPI;\n   case VALIDATION_RESULTS_TYPE_SAML:\n      return VGAUTH_USERHANDLE_TYPE_SAML;\n   case VALIDATION_RESULTS_TYPE_SAML_INFO_ONLY:\n      return VGAUTH_USERHANDLE_TYPE_SAML_INFO_ONLY;\n   case VALIDATION_RESULTS_TYPE_UNKNOWN:\n   default:\n      ASSERT(0);\n      Warning(\"%s: Tried to convert a validationType of %d to a string\\n\",\n              __FUNCTION__, t);\n      return \"<UNKNOWN>\";\n   }\n}","target":0,"code_token_length":147,"total_token_length":383,"max_tokens_setting":512}
+{"idx":463195,"func":"static int annotate_dbname_mbentry(const mbentry_t *mbentry,\n                                   char **fnamep)\n{\n    const char *conf_fname;\n\n    if (mbentry) {\n        \/* per-mbox database *\/\n        conf_fname = mbentry_metapath(mbentry, META_ANNOTATIONS, \/*isnew*\/0);\n        if (!conf_fname)\n            return IMAP_MAILBOX_BADNAME;\n        *fnamep = xstrdup(conf_fname);\n    }\n    else {\n        \/* global database *\/\n        conf_fname = config_getstring(IMAPOPT_ANNOTATION_DB_PATH);\n\n        if (conf_fname)\n            *fnamep = xstrdup(conf_fname);\n        else\n            *fnamep = strconcat(config_dir, FNAME_GLOBALANNOTATIONS, (char *)NULL);\n    }\n\n    return 0;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":336542,"func":"SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *reds)\n{\n    reds->vm_running = TRUE;\n    for (auto dev: reds->char_devices) {\n        dev->start();\n    }\n    reds_on_vm_start(reds);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":317231,"func":"static int selinux_is_sblabel_mnt(struct super_block *sb)\n{\n\tstruct superblock_security_struct *sbsec = selinux_superblock(sb);\n\n\t\/*\n\t * IMPORTANT: Double-check logic in this function when adding a new\n\t * SECURITY_FS_USE_* definition!\n\t *\/\n\tBUILD_BUG_ON(SECURITY_FS_USE_MAX != 7);\n\n\tswitch (sbsec->behavior) {\n\tcase SECURITY_FS_USE_XATTR:\n\tcase SECURITY_FS_USE_TRANS:\n\tcase SECURITY_FS_USE_TASK:\n\tcase SECURITY_FS_USE_NATIVE:\n\t\treturn 1;\n\n\tcase SECURITY_FS_USE_GENFS:\n\t\treturn selinux_is_genfs_special_handling(sb);\n\n\t\/* Never allow relabeling on context mounts *\/\n\tcase SECURITY_FS_USE_MNTPOINT:\n\tcase SECURITY_FS_USE_NONE:\n\tdefault:\n\t\treturn 0;\n\t}\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":386587,"func":"DL_Dxf::~DL_Dxf() {\n    if (vertices!=NULL) {\n        delete[] vertices;\n    }\n    if (knots!=NULL) {\n        delete[] knots;\n    }\n    if (controlPoints!=NULL) {\n        delete[] controlPoints;\n    }\n    if (fitPoints!=NULL) {\n        delete[] fitPoints;\n    }\n    if (weights!=NULL) {\n        delete[] weights;\n    }\n    if (leaderVertices!=NULL) {\n        delete[] leaderVertices;\n    }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":436124,"func":"static void io_flush_cached_locked_reqs(struct io_ring_ctx *ctx,\n\t\t\t\t\tstruct io_comp_state *cs)\n{\n\tspin_lock_irq(&ctx->completion_lock);\n\tlist_splice_init(&ctx->locked_free_list, &cs->free_list);\n\tctx->locked_free_nr = 0;\n\tspin_unlock_irq(&ctx->completion_lock);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":474072,"func":"st_numcmp(st_data_t x, st_data_t y)\n{\n    return x != y;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":512906,"func":"Item_func_in::eval_not_null_tables(void *opt_arg)\n{\n  Item **arg, **arg_end;\n\n  if (Item_func_opt_neg::eval_not_null_tables(NULL))\n    return 1;\n\n  \/* not_null_tables_cache == union(T1(e),union(T1(ei))) *\/\n  if (pred_level && negated)\n    return 0;\n\n  \/* not_null_tables_cache = union(T1(e),intersection(T1(ei))) *\/\n  not_null_tables_cache= ~(table_map) 0;\n  for (arg= args + 1, arg_end= args + arg_count; arg != arg_end; arg++)\n    not_null_tables_cache&= (*arg)->not_null_tables();\n  not_null_tables_cache|= (*args)->not_null_tables();\n  return 0;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":477973,"func":"void simplestring_init(simplestring* string) {\n   memset(string, 0, sizeof(simplestring));\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":412135,"func":"dnsc_nonce_cache_insert(struct slabhash *cache,\n                        const uint8_t nonce[crypto_box_HALF_NONCEBYTES],\n                        const uint8_t magic_query[DNSCRYPT_MAGIC_HEADER_LEN],\n                        const uint8_t pk[crypto_box_PUBLICKEYBYTES],\n                        uint32_t hash)\n{\n    struct nonce_cache_key* k =\n        (struct nonce_cache_key*)calloc(1, sizeof(*k));\n    if(!k) {\n        free(k);\n        return;\n    }\n    lock_rw_init(&k->entry.lock);\n    memcpy(k->nonce, nonce, crypto_box_HALF_NONCEBYTES);\n    memcpy(k->magic_query, magic_query, DNSCRYPT_MAGIC_HEADER_LEN);\n    memcpy(k->client_publickey, pk, crypto_box_PUBLICKEYBYTES);\n    k->entry.hash = hash;\n    k->entry.key = k;\n    k->entry.data = NULL;\n    slabhash_insert(cache,\n                    hash, &k->entry,\n                    NULL,\n                    NULL);\n}","target":0,"code_token_length":200,"total_token_length":436,"max_tokens_setting":512}
+{"idx":273073,"func":"keyval_alloc(void)\n{\n  struct keyval *kv;\n\n  kv = calloc(1, sizeof(struct keyval));\n  if (!kv)\n    {\n      DPRINTF(E_LOG, L_MISC, \"Out of memory for keyval alloc\\n\");\n\n      return NULL;\n    }\n\n  return kv;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":234211,"func":"display_trace_info (struct dwarf_section *section, void *file)\n{\n  return process_debug_info (section, file, section->abbrev_sec, false, true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":509557,"func":"int ha_maria::rnd_pos(uchar *buf, uchar *pos)\n{\n  register_handler(file);\n  int error= maria_rrnd(file, buf, my_get_ptr(pos, ref_length));\n  return error;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":220815,"func":"constexpr int lut_size() {\n  static_assert(std::is_same<LutInT, int8_t>::value ||\n                    std::is_same<LutInT, int16_t>::value,\n                \"Only LUTs with int8 or int16 inputs are supported.\");\n  return std::is_same<LutInT, int8_t>::value ? 256 : 513;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":316995,"func":"static int selinux_ib_alloc_security(void **ib_sec)\n{\n\tstruct ib_security_struct *sec;\n\n\tsec = kzalloc(sizeof(*sec), GFP_KERNEL);\n\tif (!sec)\n\t\treturn -ENOMEM;\n\tsec->sid = current_sid();\n\n\t*ib_sec = sec;\n\treturn 0;\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":270408,"func":"static bool ok_inflater_dynamic_block_header(ok_inflater *inflater) {\n    if (!ok_inflater_load_bits(inflater, 14)) {\n        return false;\n    } else {\n        inflater->num_literal_codes = (int)ok_inflater_read_bits(inflater, 5) + 257;\n        inflater->num_distance_codes = (int)ok_inflater_read_bits(inflater, 5) + 1;\n        inflater->num_code_length_codes = (int)ok_inflater_read_bits(inflater, 4) + 4;\n\n        for (int i = inflater->num_code_length_codes; i < OK_INFLATER_BIT_LENGTH_TABLE_LENGTH; i++) {\n            inflater->tree_codes[OK_INFLATER_BIT_LENGTH_TABLE[i]] = 0;\n        }\n\n        inflater->state = OK_INFLATER_STATE_READING_DYNAMIC_CODE_LENGTHS;\n        inflater->state_count = inflater->num_code_length_codes;\n        return true;\n    }\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":401588,"func":"urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)\n{\n\tunsigned long flags;\n\tstatic int maxwarn = 10;\n\n\tif (!crng_ready() && maxwarn > 0) {\n\t\tmaxwarn--;\n\t\tif (__ratelimit(&urandom_warning))\n\t\t\tpr_notice(\"%s: uninitialized urandom read (%zd bytes read)\\n\",\n\t\t\t\t  current->comm, nbytes);\n\t\tspin_lock_irqsave(&primary_crng.lock, flags);\n\t\tcrng_init_cnt = 0;\n\t\tspin_unlock_irqrestore(&primary_crng.lock, flags);\n\t}\n\n\treturn urandom_read_nowarn(file, buf, nbytes, ppos);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":445990,"func":"_archive_operation_started (FrWindow *window,\n\t\t\t    FrAction  action)\n{\n\tGFile *archive;\n\tchar  *message;\n\n\twindow->priv->action = action;\n\t_fr_window_start_activity_mode (window);\n\n#ifdef DEBUG\n\tdebug (DEBUG_INFO, \"%s [START] (FR::Window)\\n\", action_names[action]);\n#endif\n\n\tarchive = window->priv->pd_last_archive;\n\tif (archive == NULL)\n\t\tarchive =  window->priv->archive_file;\n\tmessage = get_action_description (window, action, archive);\n\tfr_window_push_message (window, message);\n\tg_free (message);\n\n\tswitch (action) {\n\tcase FR_ACTION_EXTRACTING_FILES:\n\t\topen_progress_dialog (window, ((window->priv->saving_file != NULL)\n\t\t\t\t\t       || window->priv->batch_mode));\n\t\tbreak;\n\tdefault:\n\t\topen_progress_dialog (window, window->priv->batch_mode);\n\t\tbreak;\n\t}\n\n\tfr_archive_progress_cb (NULL, -1.0, window);\n\tfr_archive_message_cb (NULL, _(\"Please wait\u2026\"), window);\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":336017,"func":"static int sr9700_get_eeprom_len(struct net_device *netdev)\n{\n\treturn SR_EEPROM_LEN;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":430460,"func":"int ovs_nla_put_key(const struct sw_flow_key *swkey,\n\t\t    const struct sw_flow_key *output, int attr, bool is_mask,\n\t\t    struct sk_buff *skb)\n{\n\tint err;\n\tstruct nlattr *nla;\n\n\tnla = nla_nest_start_noflag(skb, attr);\n\tif (!nla)\n\t\treturn -EMSGSIZE;\n\terr = __ovs_nla_put_key(swkey, output, is_mask, skb);\n\tif (err)\n\t\treturn err;\n\tnla_nest_end(skb, nla);\n\n\treturn 0;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":230979,"func":"mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep)\n{\n  const mrb_irep *irep = proc->body.irep;\n  mrb_value result;\n  struct mrb_context *c = mrb->c;\n  ptrdiff_t cioff = c->ci - c->cibase;\n  mrb_int nregs = irep->nregs;\n\n  if (!c->stbase) {\n    stack_init(mrb);\n  }\n  if (stack_keep > nregs)\n    nregs = stack_keep;\n  mrb_stack_extend(mrb, nregs);\n  stack_clear(c->ci->stack + stack_keep, nregs - stack_keep);\n  c->ci->stack[0] = self;\n  result = mrb_vm_exec(mrb, proc, irep->iseq);\n  if (mrb->c != c) {\n    if (mrb->c->fib) {\n      mrb_write_barrier(mrb, (struct RBasic*)mrb->c->fib);\n    }\n    mrb->c = c;\n  }\n  else if (c->ci - c->cibase > cioff) {\n    c->ci = c->cibase + cioff;\n  }\n  return result;\n}","target":0,"code_token_length":268,"total_token_length":504,"max_tokens_setting":512}
+{"idx":299901,"func":"readconf_readname(uschar *name, int len, uschar *s)\n{\nint p = 0;\nwhile (isspace(*s)) s++;\nif (isalpha(*s))\n  {\n  while (isalnum(*s) || *s == '_')\n    {\n    if (p < len-1) name[p++] = *s;\n    s++;\n    }\n  }\nname[p] = 0;\nwhile (isspace(*s)) s++;\nreturn s;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":225991,"func":"GF_Box *mfhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MovieFragmentHeaderBox, GF_ISOM_BOX_TYPE_MFHD);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":432309,"func":"void *qemu_map_ram_ptr(struct uc_struct *uc, RAMBlock *ram_block, ram_addr_t addr)\n{\n    RAMBlock *block = ram_block;\n\n    if (block == NULL) {\n        block = qemu_get_ram_block(uc, addr);\n        addr -= block->offset;\n    }\n\n    return ramblock_ptr(block, addr);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":512821,"func":"void Item_func_like::turboBM_compute_good_suffix_shifts(int *suff)\n{\n  turboBM_compute_suffixes(suff);\n\n  int *end = bmGs + pattern_len;\n  int *k;\n  for (k = bmGs; k < end; k++)\n    *k = pattern_len;\n\n  int tmp;\n  int i;\n  int j          = 0;\n  const int plm1 = pattern_len - 1;\n  for (i = plm1; i > -1; i--)\n  {\n    if (suff[i] == i + 1)\n    {\n      for (tmp = plm1 - i; j < tmp; j++)\n      {\n\tint *tmp2 = bmGs + j;\n\tif (*tmp2 == pattern_len)\n\t  *tmp2 = tmp;\n      }\n    }\n  }\n\n  int *tmp2;\n  for (tmp = plm1 - i; j < tmp; j++)\n  {\n    tmp2 = bmGs + j;\n    if (*tmp2 == pattern_len)\n      *tmp2 = tmp;\n  }\n\n  tmp2 = bmGs + plm1;\n  for (i = 0; i <= pattern_len - 2; i++)\n    *(tmp2 - suff[i]) = plm1 - i;\n}","target":0,"code_token_length":274,"total_token_length":510,"max_tokens_setting":512}
+{"idx":462419,"func":"closeSess(ptcpsess_t *pSess)\n{\n\tint sock;\n\tDEFiRet;\n\t\n\tif(pSess->compressionMode >= COMPRESS_STREAM_ALWAYS)\n\t\tdoZipFinish(pSess);\n\n\tsock = pSess->sock;\n\tCHKiRet(removeEPollSock(sock, pSess->epd));\n\tclose(sock);\n\n\tpthread_mutex_lock(&pSess->pLstn->pSrv->mutSessLst);\n\t\/* finally unlink session from structures *\/\n\tif(pSess->next != NULL)\n\t\tpSess->next->prev = pSess->prev;\n\tif(pSess->prev == NULL) {\n\t\t\/* need to update root! *\/\n\t\tpSess->pLstn->pSrv->pSess = pSess->next;\n\t} else {\n\t\tpSess->prev->next = pSess->next;\n\t}\n\tpthread_mutex_unlock(&pSess->pLstn->pSrv->mutSessLst);\n\n\t\/* unlinked, now remove structure *\/\n\tdestructSess(pSess);\n\nfinalize_it:\n\tDBGPRINTF(\"imptcp: session on socket %d closed with iRet %d.\\n\", sock, iRet);\n\tRETiRet;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":432171,"func":"static inline uint64_t memory_region_shift_write_access(uint64_t *value,\n                                                        signed shift,\n                                                        uint64_t mask)\n{\n    uint64_t tmp;\n\n    if (shift >= 0) {\n        tmp = (*value >> shift) & mask;\n    } else {\n        tmp = (*value << -shift) & mask;\n    }\n\n    return tmp;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":346438,"func":"source_callback(char_u *fname, void *cookie)\n{\n    (void)do_source(fname, FALSE, DOSO_NONE, cookie);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":90811,"func":"  UpdateModifiedTimeTask(\n      QuotaManager* manager,\n      const GURL& origin,\n      StorageType type,\n      base::Time modified_time)\n      : DatabaseTaskBase(manager),\n        origin_(origin),\n        type_(type),\n        modified_time_(modified_time) {}\n","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":440902,"func":"VAuditF(const char *f, va_list args)\n{\n    char *prefix;\n    char buf[1024];\n    int len;\n    static char oldbuf[1024];\n\n    prefix = AuditPrefix();\n    len = vsnprintf(buf, sizeof(buf), f, args);\n\n    if (len == oldlen && strcmp(buf, oldbuf) == 0) {\n        \/* Message already seen *\/\n        nrepeat++;\n    }\n    else {\n        \/* new message *\/\n        if (auditTimer != NULL)\n            TimerForce(auditTimer);\n        ErrorF(\"%s%s\", prefix != NULL ? prefix : \"\", buf);\n        strlcpy(oldbuf, buf, sizeof(oldbuf));\n        oldlen = len;\n        nrepeat = 0;\n        auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);\n    }\n    free(prefix);\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":249981,"func":"GF_Err WriteSample(MovieWriter *mw, u32 size, u64 offset, u8 isEdited, GF_BitStream *bs, u32 nb_samp)\n{\n\tGF_DataMap *map;\n\tu32 bytes;\n\n\tif (!size) return GF_OK;\n\n\tif (size>mw->alloc_size) {\n\t\tmw->buffer = (char*)gf_realloc(mw->buffer, size);\n\t\tmw->alloc_size = size;\n\t}\n\n\tif (!mw->buffer) return GF_OUT_OF_MEM;\n\n\tif (isEdited) {\n\t\tmap = mw->movie->editFileMap;\n\t} else {\n\t\tmap = mw->movie->movieFileMap;\n\t}\n\t\/\/get the payload...\n\tbytes = gf_isom_datamap_get_data(map, mw->buffer, size, offset);\n\tif (bytes != size)\n\t\treturn GF_IO_ERR;\n\t\/\/write it to our stream...\n\tbytes = gf_bs_write_data(bs, mw->buffer, size);\n\tif (bytes != size)\n\t\treturn GF_IO_ERR;\n\n\tmw->nb_done+=nb_samp;\n\tmuxer_report_progress(mw);\n\treturn GF_OK;\n}","target":0,"code_token_length":241,"total_token_length":477,"max_tokens_setting":512}
+{"idx":246685,"func":"u32 parse_dsap(char *arg_val, u32 opt)\n{\n\tdump_saps = atoi(arg_val);\n\tdump_saps_mode = opt;\n\treturn 0;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":294638,"func":"d_lite_to_s(VALUE self)\n{\n    return strftimev(\"%Y-%m-%d\", self, set_tmx);\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":389672,"func":"check_for_list_or_blob_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_LIST && args[idx].v_type != VAR_BLOB)\n    {\n\tsemsg(_(e_list_or_blob_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":292212,"func":"find_session_from_nick (char *nick, server *serv)\n{\n\tsession *sess;\n\tGSList *list = sess_list;\n\n\tsess = find_dialog (serv, nick);\n\tif (sess)\n\t\treturn sess;\n\n\tif (serv->front_session)\n\t{\n\t\tif (userlist_find (serv->front_session, nick))\n\t\t\treturn serv->front_session;\n\t}\n\n\tif (current_sess && current_sess->server == serv)\n\t{\n\t\tif (userlist_find (current_sess, nick))\n\t\t\treturn current_sess;\n\t}\n\n\twhile (list)\n\t{\n\t\tsess = list->data;\n\t\tif (sess->server == serv)\n\t\t{\n\t\t\tif (userlist_find (sess, nick))\n\t\t\t\treturn sess;\n\t\t}\n\t\tlist = list->next;\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":450340,"func":"static void png_flush_data(png_structp png_ptr)\n{\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":248251,"func":"DLLIMPORT int cfg_opt_setmulti(cfg_t *cfg, cfg_opt_t *opt, unsigned int nvalues, char **values)\n{\n\tcfg_opt_t old;\n\tunsigned int i;\n\n\tif (!opt || !nvalues) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\told = *opt;\n\topt->nvalues = 0;\n\topt->values = NULL;\n\n\tfor (i = 0; i < nvalues; i++) {\n\t\tif (cfg_setopt(cfg, opt, values[i]))\n\t\t\tcontinue;\n\n\t\t\/* ouch, revert *\/\n\t\tcfg_free_value(opt);\n\t\topt->nvalues = old.nvalues;\n\t\topt->values = old.values;\n\t\topt->flags &= ~(CFGF_RESET | CFGF_MODIFIED);\n\t\topt->flags |= old.flags & (CFGF_RESET | CFGF_MODIFIED);\n\n\t\treturn CFG_FAIL;\n\t}\n\n\tcfg_free_value(&old);\n\topt->flags |= CFGF_MODIFIED;\n\n\treturn CFG_SUCCESS;\n}","target":0,"code_token_length":197,"total_token_length":433,"max_tokens_setting":512}
+{"idx":476119,"func":"static void __composite_unbind(struct usb_gadget *gadget, bool unbind_driver)\n{\n\tstruct usb_composite_dev\t*cdev = get_gadget_data(gadget);\n\tstruct usb_gadget_strings\t*gstr = cdev->driver->strings[0];\n\tstruct usb_string\t\t*dev_str = gstr->strings;\n\n\t\/* composite_disconnect() must already have been called\n\t * by the underlying peripheral controller driver!\n\t * so there's no i\/o concurrency that could affect the\n\t * state protected by cdev->lock.\n\t *\/\n\tWARN_ON(cdev->config);\n\n\twhile (!list_empty(&cdev->configs)) {\n\t\tstruct usb_configuration\t*c;\n\t\tc = list_first_entry(&cdev->configs,\n\t\t\t\tstruct usb_configuration, list);\n\t\tremove_config(cdev, c);\n\t}\n\tif (cdev->driver->unbind && unbind_driver)\n\t\tcdev->driver->unbind(cdev);\n\n\tcomposite_dev_cleanup(cdev);\n\n\tif (dev_str[USB_GADGET_MANUFACTURER_IDX].s == cdev->def_manufacturer)\n\t\tdev_str[USB_GADGET_MANUFACTURER_IDX].s = \"\";\n\n\tkfree(cdev->def_manufacturer);\n\tkfree(cdev);\n\tset_gadget_data(gadget, NULL);\n}","target":0,"code_token_length":262,"total_token_length":498,"max_tokens_setting":512}
+{"idx":436158,"func":"static inline bool io_run_task_work(void)\n{\n\tif (current->task_works) {\n\t\t__set_current_state(TASK_RUNNING);\n\t\ttask_work_run();\n\t\treturn true;\n\t}\n\n\treturn false;\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":508913,"func":"void st_select_lex::print_limit(THD *thd,\n                                String *str,\n                                enum_query_type query_type)\n{\n  SELECT_LEX_UNIT *unit= master_unit();\n  Item_subselect *item= unit->item;\n\n  if (item && unit->global_parameters() == this)\n  {\n    Item_subselect::subs_type subs_type= item->substype();\n    if (subs_type == Item_subselect::IN_SUBS ||\n        subs_type == Item_subselect::ALL_SUBS)\n    {\n      return;\n    }\n  }\n  if (explicit_limit && select_limit)\n  {\n    str->append(STRING_WITH_LEN(\" limit \"));\n    if (offset_limit)\n    {\n      offset_limit->print(str, query_type);\n      str->append(',');\n    }\n    select_limit->print(str, query_type);\n  }\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":222871,"func":"  bool MaybeTensorProtoToShape(InferenceContext* ic,\n                               const TensorProto& tensor_proto,\n                               ShapeHandle* tensors_as_shapes) {\n    \/\/ Skip if dtype is not integer.\n    if (tensor_proto.dtype() != DT_INT32 && tensor_proto.dtype() != DT_INT64) {\n      return false;\n    }\n    \/\/ Skip if the const tensor is too large.\n    if (NumElementsFromTensorProto(tensor_proto) >\n        kThresholdToSkipConstTensorInstantiation) {\n      return false;\n    }\n    \/\/ Skip if shape is neither scalar nor vector.\n    if (tensor_proto.tensor_shape().unknown_rank() ||\n        tensor_proto.tensor_shape().dim_size() > 1) {\n      return false;\n    }\n    Tensor tensor;\n    if (!tensor.FromProto(tensor_proto)) {\n      return false;\n    }\n    return MaybeTensorValueToShape(ic, tensor, tensors_as_shapes);\n  }","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":234141,"func":"fetch_indexed_value (dwarf_vma idx,\n\t\t     enum dwarf_section_display_enum sec_enum,\n\t\t     dwarf_vma base_address)\n{\n  struct dwarf_section *section = &debug_displays [sec_enum].section;\n\n  if (section->start == NULL)\n    {\n      warn (_(\"Unable to locate %s section\\n\"), section->uncompressed_name);\n      return 0;\n    }\n\n  uint32_t pointer_size, bias;\n\n  if (byte_get (section->start, 4) == 0xffffffff)\n    {\n      pointer_size = 8;\n      bias = 20;\n    }\n  else\n    {\n      pointer_size = 4;\n      bias = 12;\n    }\n \n  dwarf_vma offset = idx * pointer_size;\n\n  \/* Offsets are biased by the size of the section header\n     or base address.  *\/\n  if (sec_enum == loclists)\n    offset += base_address;\n  else\n    offset += bias;\n\n  if (offset + pointer_size > section->size)\n    {\n      warn (_(\"Offset into section %s too big: 0x%s\\n\"),\n\t    section->name, dwarf_vmatoa (\"x\", offset));\n      return 0;\n    }\n\n  return byte_get (section->start + offset, pointer_size);\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":512767,"func":"  bool set_value(THD *thd, const Type_all_attributes *attr,\n                 const st_value *val, const Type_handler *h)\n  {\n    value.set_handler(h); \/\/ See comments in set_param_func()\n    return h->Item_param_set_from_value(thd, this, attr, val);\n  }","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":336645,"func":"static gboolean reds_use_client_monitors_config(RedsState *reds)\n{\n    if (reds->qxl_instances.empty()) {\n        return FALSE;\n    }\n\n    FOREACH_QXL_INSTANCE(reds, qxl) {\n        if (!red_qxl_client_monitors_config(qxl, NULL))\n            return FALSE;\n    }\n    return TRUE;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":386494,"func":"void DL_Dxf::addPoint(DL_CreationInterface* creationInterface) {\n    DL_PointData d(getRealValue(10, 0.0),\n                   getRealValue(20, 0.0),\n                   getRealValue(30, 0.0));\n    creationInterface->addPoint(d);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":513002,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_hex_string>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":455346,"func":"execute_env_file (env_file)\n      char *env_file;\n{\n  char *fn;\n\n  if (env_file && *env_file)\n    {\n      fn = expand_string_unsplit_to_string (env_file, Q_DOUBLE_QUOTES);\n      if (fn && *fn)\n\tmaybe_execute_file (fn, 1);\n      FREE (fn);\n    }\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":225889,"func":"\nGF_Err chnl_box_size(GF_Box *s)\n{\n\tGF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s;\n\ts->size += 1;\n\tif (ptr->layout.stream_structure & 1) {\n\t\ts->size += 1;\n\t\tif (ptr->layout.definedLayout==0) {\n\t\t\tu32 i;\n\t\t\tfor (i=0; i<ptr->layout.channels_count; i++) {\n\t\t\t\ts->size+=1;\n\t\t\t\tif (ptr->layout.layouts[i].position==126)\n\t\t\t\t\ts->size+=3;\n\t\t\t}\n\t\t} else {\n\t\t\ts->size += 8;\n\t\t}\n\t}\n\tif (ptr->layout.stream_structure & 2) {\n\t\ts->size += 1;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":233886,"func":" *\/\nint php_wddx_deserialize_ex(const char *value, size_t vallen, zval *return_value)\n{\n\twddx_stack stack;\n\tXML_Parser parser;\n\tst_entry *ent;\n\tint retval;\n\n\twddx_stack_init(&stack);\n\tparser = XML_ParserCreate((XML_Char *) \"UTF-8\");\n\n\tXML_SetUserData(parser, &stack);\n\tXML_SetElementHandler(parser, php_wddx_push_element, php_wddx_pop_element);\n\tXML_SetCharacterDataHandler(parser, php_wddx_process_data);\n\n\t\/* XXX value should be parsed in the loop to exhaust size_t *\/\n\tXML_Parse(parser, (const XML_Char *) value, (int)vallen, 1);\n\n\tXML_ParserFree(parser);\n\n\tif (stack.top == 1) {\n\t\twddx_stack_top(&stack, (void**)&ent);\n\t\tZVAL_COPY(return_value, &ent->data);\n\t\tretval = SUCCESS;\n\t} else {\n\t\tretval = FAILURE;\n\t}\n\n\twddx_stack_destroy(&stack);\n\n\treturn retval;","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":338206,"func":"static bool isIdChar(char ch) {\n  return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') ||\n         (ch >= 'a' && ch <= 'z') || ch == '!' || ch == '#' || ch == '$' ||\n         ch == '%' || ch == '&' || ch == '\\'' || ch == '*' || ch == '+' ||\n         ch == '-' || ch == '.' || ch == '\/' || ch == ':' || ch == '<' ||\n         ch == '=' || ch == '>' || ch == '?' || ch == '@' || ch == '^' ||\n         ch == '_' || ch == '`' || ch == '|' || ch == '~';\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":332363,"func":"get_op_char(int optype)\n{\n    return opchars[optype][0];\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":409479,"func":"may_req_termresponse(void)\n{\n    if (crv_status.tr_progress == STATUS_GET\n\t    && can_get_termresponse()\n\t    && starting == 0\n\t    && *T_CRV != NUL)\n    {\n\tMAY_WANT_TO_LOG_THIS;\n\tLOG_TR((\"Sending CRV request\"));\n\tout_str(T_CRV);\n\ttermrequest_sent(&crv_status);\n\t\/\/ check for the characters now, otherwise they might be eaten by\n\t\/\/ get_keystroke()\n\tout_flush();\n\t(void)vpeekc_nomap();\n    }\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":226357,"func":"\nGF_Box *csgp_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_CompactSampleGroupBox, GF_ISOM_BOX_TYPE_CSGP);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":243998,"func":"GF_Err gitn_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGroupIdToNameBox *ptr = (GroupIdToNameBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u16(bs, ptr->nb_entries);\n\tfor (i=0; i<ptr->nb_entries; i++) {\n\t\tgf_bs_write_u32(bs, ptr->entries[i].group_id);\n\t\tif (ptr->entries[i].name) gf_bs_write_data(bs, ptr->entries[i].name, (u32)strlen(ptr->entries[i].name) );\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":359393,"func":"DEFUN (clear_ip_bgp_as_ipv4_soft_in,\n       clear_ip_bgp_as_ipv4_soft_in_cmd,\n       \"clear ip bgp <1-65535> ipv4 (unicast|multicast) soft in\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear peers with the AS number\\n\"\n       \"Address family\\n\"\n       \"Address Family modifier\\n\"\n       \"Address Family modifier\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  if (strncmp (argv[1], \"m\", 1) == 0)\n    return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,\n\t\t\t  BGP_CLEAR_SOFT_IN, argv[0]);\n\n  return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,\n\t\t\tBGP_CLEAR_SOFT_IN, argv[0]);\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":445951,"func":"fr_window_set_password (FrWindow   *window,\n\t\t\tconst char *password)\n{\n\tg_return_if_fail (window != NULL);\n\n\tif (window->priv->password == password)\n\t\treturn;\n\n\tif (window->priv->password != NULL) {\n\t\tg_free (window->priv->password);\n\t\twindow->priv->password = NULL;\n\t}\n\n\tif ((password != NULL) && (password[0] != '\\0'))\n\t\twindow->priv->password = g_strdup (password);\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":379704,"func":"R_API R_BORROW RPVector *r_anal_function_get_vars_used_at(RAnalFunction *fcn, ut64 op_addr) {\n\tr_return_val_if_fail (fcn, NULL);\n\treturn ht_up_find (fcn->inst_vars, op_addr - fcn->addr, NULL);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":310259,"func":"list_single_server_status(routerinfo_t *desc, int is_live)\n{\n  char buf[MAX_NICKNAME_LEN+HEX_DIGEST_LEN+4]; \/* !nickname=$hexdigest\\0 *\/\n  char *cp;\n\n  tor_assert(desc);\n\n  cp = buf;\n  if (!is_live) {\n    *cp++ = '!';\n  }\n  if (desc->is_valid) {\n    strlcpy(cp, desc->nickname, sizeof(buf)-(cp-buf));\n    cp += strlen(cp);\n    *cp++ = '=';\n  }\n  *cp++ = '$';\n  base16_encode(cp, HEX_DIGEST_LEN+1, desc->cache_info.identity_digest,\n                DIGEST_LEN);\n  return tor_strdup(buf);\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":139214,"func":"void OverlayWindowViews::CreateCustomControl(\n    std::unique_ptr<views::ControlImageButton>& control_button,\n    const blink::PictureInPictureControlInfo& info,\n    ControlPosition position) {\n  control_button = std::make_unique<views::ControlImageButton>(this);\n  controls_parent_view_->AddChildView(control_button.get());\n  control_button->set_id(info.id);\n  control_button->set_owned_by_client();\n\n  control_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER,\n                                    views::ImageButton::ALIGN_MIDDLE);\n  UpdateCustomControlsSize(control_button.get());\n  UpdateControlsBounds();\n\n  base::string16 custom_button_label = base::UTF8ToUTF16(info.label);\n  control_button->SetAccessibleName(custom_button_label);\n  control_button->SetTooltipText(custom_button_label);\n  control_button->SetInstallFocusRingOnFocus(true);\n  control_button->SetFocusForPlatform();\n}\n","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":512529,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_cache_date>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":413846,"func":"static void trace_method_resolution(const char* prefix,\n                                    Klass* klass,\n                                    Klass* resolved_klass,\n                                    Method* method,\n                                    bool logitables,\n                                    int index = -1) {\n#ifndef PRODUCT\n  ResourceMark rm;\n  Log(itables) logi;\n  LogStream lsi(logi.trace());\n  Log(vtables) logv;\n  LogStream lsv(logv.trace());\n  outputStream* st;\n  if (logitables) {\n    st = &lsi;\n  } else {\n    st = &lsv;\n  }\n  st->print(\"%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: \",\n            prefix,\n            (klass == NULL ? \"<NULL>\" : klass->internal_name()),\n            (resolved_klass == NULL ? \"<NULL>\" : resolved_klass->internal_name()),\n            Method::name_and_sig_as_C_string(resolved_klass,\n                                             method->name(),\n                                             method->signature()),\n            method->method_holder()->internal_name());\n  method->print_linkage_flags(st);\n  if (index != -1) {\n    st->print(\"vtable_index:%d\", index);\n  }\n  st->cr();\n#endif \/\/ PRODUCT\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":500696,"func":"unsigned int sftp_extensions_get_count(sftp_session sftp) {\n  if (sftp == NULL || sftp->ext == NULL) {\n    return 0;\n  }\n\n  return sftp->ext->count;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":338066,"func":"void WasmBinaryBuilder::visitSwitch(Switch* curr) {\n  BYN_TRACE(\"zz node: Switch\\n\");\n  curr->condition = popNonVoidExpression();\n  auto numTargets = getU32LEB();\n  BYN_TRACE(\"targets: \" << numTargets << std::endl);\n  for (size_t i = 0; i < numTargets; i++) {\n    curr->targets.push_back(getBreakTarget(getU32LEB()).name);\n  }\n  auto defaultTarget = getBreakTarget(getU32LEB());\n  curr->default_ = defaultTarget.name;\n  BYN_TRACE(\"default: \" << curr->default_ << \"\\n\");\n  if (defaultTarget.type.isConcrete()) {\n    curr->value = popTypedExpression(defaultTarget.type);\n  }\n  curr->finalize();\n}","target":0,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":385858,"func":"struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,\n\t\tconst char *name, const struct open_flags *op)\n{\n\tstruct nameidata nd;\n\tstruct file *file;\n\tstruct filename filename = { .name = name };\n\tint flags = op->lookup_flags | LOOKUP_ROOT;\n\n\tnd.root.mnt = mnt;\n\tnd.root.dentry = dentry;\n\n\tif (dentry->d_inode->i_op->follow_link && op->intent & LOOKUP_OPEN)\n\t\treturn ERR_PTR(-ELOOP);\n\n\tfile = path_openat(-1, &filename, &nd, op, flags | LOOKUP_RCU);\n\tif (unlikely(file == ERR_PTR(-ECHILD)))\n\t\tfile = path_openat(-1, &filename, &nd, op, flags);\n\tif (unlikely(file == ERR_PTR(-ESTALE)))\n\t\tfile = path_openat(-1, &filename, &nd, op, flags | LOOKUP_REVAL);\n\treturn file;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":453107,"func":"XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) {\n  XML_Char tmp[2] = {nsSep, 0};\n  return XML_ParserCreate_MM(encodingName, NULL, tmp);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":226378,"func":"\nvoid jp2h_box_del(GF_Box *s)\n{\n\tgf_free(s);","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":313819,"func":"do_nv_ident(int c1, int c2)\n{\n    oparg_T\toa;\n    cmdarg_T\tca;\n\n    clear_oparg(&oa);\n    CLEAR_FIELD(ca);\n    ca.oap = &oa;\n    ca.cmdchar = c1;\n    ca.nchar = c2;\n    nv_ident(&ca);\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":395072,"func":"after_updating_screen(int may_resize_shell UNUSED)\n{\n    updating_screen = FALSE;\n#ifdef FEAT_GUI\n    if (may_resize_shell)\n\tgui_may_resize_shell();\n#endif\n#ifdef FEAT_TERMINAL\n    term_check_channel_closed_recently();\n#endif\n\n#ifdef HAVE_DROP_FILE\n    \/\/ If handle_drop() was called while updating_screen was TRUE need to\n    \/\/ handle the drop now.\n    handle_any_postponed_drop();\n#endif\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":430377,"func":"int seq_path_root(struct seq_file *m, const struct path *path,\n\t\t  const struct path *root, const char *esc)\n{\n\tchar *buf;\n\tsize_t size = seq_get_buf(m, &buf);\n\tint res = -ENAMETOOLONG;\n\n\tif (size) {\n\t\tchar *p;\n\n\t\tp = __d_path(path, root, buf, size);\n\t\tif (!p)\n\t\t\treturn SEQ_SKIP;\n\t\tres = PTR_ERR(p);\n\t\tif (!IS_ERR(p)) {\n\t\t\tchar *end = mangle_path(buf, p, esc);\n\t\t\tif (end)\n\t\t\t\tres = end - buf;\n\t\t\telse\n\t\t\t\tres = -ENAMETOOLONG;\n\t\t}\n\t}\n\tseq_commit(m, res);\n\n\treturn res < 0 && res != -ENAMETOOLONG ? res : 0;\n}","target":0,"code_token_length":175,"total_token_length":411,"max_tokens_setting":512}
+{"idx":276444,"func":"  void Compute(OpKernelContext* context) override {\n    core::RefCountPtr<BoostedTreesEnsembleResource> tree_ensemble_resource;\n    OP_REQUIRES_OK(context, LookupResource(context, HandleFromInput(context, 0),\n                                           &tree_ensemble_resource));\n    tf_shared_lock l(*tree_ensemble_resource->get_mutex());\n    Tensor* output_stamp_token_t = nullptr;\n    OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape(),\n                                                     &output_stamp_token_t));\n    output_stamp_token_t->scalar<int64>()() = tree_ensemble_resource->stamp();\n    Tensor* output_proto_t = nullptr;\n    OP_REQUIRES_OK(context,\n                   context->allocate_output(1, TensorShape(), &output_proto_t));\n    output_proto_t->scalar<tstring>()() =\n        tree_ensemble_resource->SerializeAsString();\n  }","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":448531,"func":"static void bgp_refresh_stalepath_timer_expire(struct thread *thread)\n{\n\tstruct peer_af *paf;\n\n\tpaf = THREAD_ARG(thread);\n\n\tafi_t afi = paf->afi;\n\tsafi_t safi = paf->safi;\n\tstruct peer *peer = paf->peer;\n\n\tpeer->t_refresh_stalepath = NULL;\n\n\tif (peer->nsf[afi][safi])\n\t\tbgp_clear_stale_route(peer, afi, safi);\n\n\tif (bgp_debug_neighbor_events(peer))\n\t\tzlog_debug(\n\t\t\t\"%pBP route-refresh (BoRR) timer expired for afi\/safi: %d\/%d\",\n\t\t\tpeer, afi, safi);\n\n\tbgp_timer_set(peer);\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":512838,"func":"Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,\n                                                Item **cache_item,\n                                                const Type_handler *handler)\n{\n  \/*\n    Don't need cache if doing context analysis only.\n  *\/\n  if (!thd_arg->lex->is_ps_or_view_context_analysis() &&\n      (*value)->const_item() &&\n      handler->type_handler_for_comparison() !=\n      (*value)->type_handler_for_comparison())\n  {\n    Item_cache *cache= handler->Item_get_cache(thd_arg, *value);\n    cache->setup(thd_arg, *value);\n    *cache_item= cache;\n    return cache_item;\n  }\n  return value;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":226166,"func":"\nGF_Err paen_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_array_read(s, bs);","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":312491,"func":"vgr_get_auname(cmdidx_T cmdidx)\n{\n    switch (cmdidx)\n    {\n\tcase CMD_vimgrep:     return (char_u *)\"vimgrep\";\n\tcase CMD_lvimgrep:    return (char_u *)\"lvimgrep\";\n\tcase CMD_vimgrepadd:  return (char_u *)\"vimgrepadd\";\n\tcase CMD_lvimgrepadd: return (char_u *)\"lvimgrepadd\";\n\tcase CMD_grep:\t      return (char_u *)\"grep\";\n\tcase CMD_lgrep:\t      return (char_u *)\"lgrep\";\n\tcase CMD_grepadd:     return (char_u *)\"grepadd\";\n\tcase CMD_lgrepadd:    return (char_u *)\"lgrepadd\";\n\tdefault: return NULL;\n    }\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":328828,"func":"R_API void r_bin_java_print_code_exceptions_attr_summary(RBinJavaExceptionEntry *exc_entry) {\n\tif (exc_entry == NULL) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaExceptionEntry *.\\n\");\n\t\treturn;\n\t}\n\tprintf (\"  Exception Table Entry Information\\n\");\n\tprintf (\"    offset:\t0x%08\"PFMT64x\"\\n\", exc_entry->file_offset);\n\tprintf (\"    catch_type: %d\\n\", exc_entry->catch_type);\n\tprintf (\"    start_pc:   0x%04x\\n\", exc_entry->start_pc);\n\tprintf (\"    end_pc:\t0x%04x\\n\", exc_entry->end_pc);\n\tprintf (\"    handler_pc: 0x%04x\\n\", exc_entry->handler_pc);\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":509541,"func":"int ha_maria::rnd_next(uchar *buf)\n{\n  register_handler(file);\n  return maria_scan(file, buf);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":275488,"func":"njs_async_context_free(njs_vm_t *vm, njs_async_ctx_t *ctx)\n{\n    njs_mp_free(vm->mem_pool, ctx->capability);\n    njs_mp_free(vm->mem_pool, ctx);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":309879,"func":"vid_puts(attr_t newmode,\n\t NCURSES_PAIRS_T pair_arg,\n\t void *opts GCC_UNUSED,\n\t NCURSES_OUTC outc)\n{\n    SetSafeOutcWrapper(outc);\n    return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN,\n\t\t\t\t      newmode,\n\t\t\t\t      pair_arg,\n\t\t\t\t      opts,\n\t\t\t\t      _nc_outc_wrapper);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":236189,"func":"GF_Err twrp_box_size(GF_Box *s)\n{\n\ts->size += 1;\n\treturn GF_OK;\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":336620,"func":"static void reds_adjust_agent_capabilities(RedsState *reds, VDAgentMessage *message)\n{\n    VDAgentAnnounceCapabilities *capabilities;\n\n    if (message->type != VD_AGENT_ANNOUNCE_CAPABILITIES) {\n        return;\n    }\n    capabilities = (VDAgentAnnounceCapabilities *) message->data;\n\n    if (!reds->config->agent_copypaste) {\n        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD);\n        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND);\n        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);\n    }\n\n    if (!reds->config->agent_file_xfer) {\n        VD_AGENT_SET_CAPABILITY(capabilities->caps, VD_AGENT_CAP_FILE_XFER_DISABLED);\n    }\n\n    size_t caps_size = VD_AGENT_CAPS_SIZE_FROM_MSG_SIZE(message->size);\n    reds->agent_dev->priv->agent_supports_graphics_device_info =\n        VD_AGENT_HAS_CAPABILITY(capabilities->caps, caps_size, VD_AGENT_CAP_GRAPHICS_DEVICE_INFO);\n    reds_send_device_display_info(reds);\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":379689,"func":"static void r_anal_var_proto_free(RAnalVarProt *vp) {\n\tif (vp) {\n\t\tfree (vp->name);\n\t\tfree (vp->type);\n\t\tfree (vp);\n\t}\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":317126,"func":"static int selinux_skb_peerlbl_sid(struct sk_buff *skb, u16 family, u32 *sid)\n{\n\tint err;\n\tu32 xfrm_sid;\n\tu32 nlbl_sid;\n\tu32 nlbl_type;\n\n\terr = selinux_xfrm_skb_sid(skb, &xfrm_sid);\n\tif (unlikely(err))\n\t\treturn -EACCES;\n\terr = selinux_netlbl_skbuff_getsid(skb, family, &nlbl_type, &nlbl_sid);\n\tif (unlikely(err))\n\t\treturn -EACCES;\n\n\terr = security_net_peersid_resolve(&selinux_state, nlbl_sid,\n\t\t\t\t\t   nlbl_type, xfrm_sid, sid);\n\tif (unlikely(err)) {\n\t\tpr_warn(\n\t\t       \"SELinux: failure in selinux_skb_peerlbl_sid(),\"\n\t\t       \" unable to determine packet's peer label\\n\");\n\t\treturn -EACCES;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":220403,"func":"ary_shrink_capa(mrb_state *mrb, struct RArray *a)\n{\n\n  mrb_int capa;\n\n  if (ARY_EMBED_P(a)) return;\n\n  capa = a->as.heap.aux.capa;\n  if (capa < ARY_DEFAULT_LEN * 2) return;\n  if (capa <= a->as.heap.len * ARY_SHRINK_RATIO) return;\n\n  do {\n    capa \/= 2;\n    if (capa < ARY_DEFAULT_LEN) {\n      capa = ARY_DEFAULT_LEN;\n      break;\n    }\n  } while (capa > a->as.heap.len * ARY_SHRINK_RATIO);\n\n  if (capa > a->as.heap.len && capa < a->as.heap.aux.capa) {\n    a->as.heap.aux.capa = capa;\n    a->as.heap.ptr = (mrb_value *)mrb_realloc(mrb, a->as.heap.ptr, sizeof(mrb_value)*capa);\n  }\n}","target":0,"code_token_length":216,"total_token_length":452,"max_tokens_setting":512}
+{"idx":487668,"func":"static void groups_sort(struct group_info *group_info)\n{\n\tint base, max, stride;\n\tint gidsetsize = group_info->ngroups;\n\n\tfor (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)\n\t\t; \/* nothing *\/\n\tstride \/= 3;\n\n\twhile (stride) {\n\t\tmax = gidsetsize - stride;\n\t\tfor (base = 0; base < max; base++) {\n\t\t\tint left = base;\n\t\t\tint right = left + stride;\n\t\t\tgid_t tmp = GROUP_AT(group_info, right);\n\n\t\t\twhile (left >= 0 && GROUP_AT(group_info, left) > tmp) {\n\t\t\t\tGROUP_AT(group_info, right) =\n\t\t\t\t    GROUP_AT(group_info, left);\n\t\t\t\tright = left;\n\t\t\t\tleft -= stride;\n\t\t\t}\n\t\t\tGROUP_AT(group_info, right) = tmp;\n\t\t}\n\t\tstride \/= 3;\n\t}\n}","target":0,"code_token_length":196,"total_token_length":432,"max_tokens_setting":512}
+{"idx":317320,"func":"static int smk_copy_rules(struct list_head *nhead, struct list_head *ohead,\n\t\t\t\tgfp_t gfp)\n{\n\tstruct smack_rule *nrp;\n\tstruct smack_rule *orp;\n\tint rc = 0;\n\n\tlist_for_each_entry_rcu(orp, ohead, list) {\n\t\tnrp = kmem_cache_zalloc(smack_rule_cache, gfp);\n\t\tif (nrp == NULL) {\n\t\t\trc = -ENOMEM;\n\t\t\tbreak;\n\t\t}\n\t\t*nrp = *orp;\n\t\tlist_add_rcu(&nrp->list, nhead);\n\t}\n\treturn rc;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":317306,"func":"static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr)\n{\n\tstruct smk_audit_info ad;\n\tint rc;\n\n\t\/*\n\t * Need to allow for clearing the setuid bit.\n\t *\/\n\tif (iattr->ia_valid & ATTR_FORCE)\n\t\treturn 0;\n\tsmk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);\n\tsmk_ad_setfield_u_fs_path_dentry(&ad, dentry);\n\n\trc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);\n\trc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);\n\treturn rc;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":413576,"func":"static bool isValidAddress(RCore *core, ut64 addr) {\n\t\/\/ check if address is mapped\n\tRIOMap* map = r_io_map_get_at (core->io, addr);\n\tif (!map) {\n\t\treturn false;\n\t}\n\tst64 fdsz = (st64)r_io_fd_size (core->io, map->fd);\n\tif (fdsz > 0 && map->delta > fdsz) {\n\t\treturn false;\n\t}\n\t\/\/ check if associated file is opened\n\tRIODesc *desc = r_io_desc_get (core->io, map->fd);\n\tif (!desc) {\n\t\treturn false;\n\t}\n\t\/\/ check if current map->fd is null:\/\/\n\tif (!strncmp (desc->name, \"null:\/\/\", 7)) {\n\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":299888,"func":"readconf_rewrites(void)\n{\nrewrite_rule **chain = &global_rewrite_rules;\nuschar *p;\n\nwhile ((p = get_config_line()) != NULL)\n  {\n  rewrite_rule *next = readconf_one_rewrite(p, &rewrite_existflags, TRUE);\n  *chain = next;\n  chain = &(next->next);\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":331766,"func":"QVectorPath::~QVectorPath()\n{\n    if (m_hints & ShouldUseCacheHint) {\n        CacheEntry *e = m_cache;\n        while (e) {\n            if (e->data)\n                e->cleanup(e->engine, e->data);\n            CacheEntry *n = e->next;\n            delete e;\n            e = n;\n        }\n    }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":436137,"func":"static void io_queue_deferred(struct io_ring_ctx *ctx)\n{\n\twhile (!list_empty(&ctx->defer_list)) {\n\t\tstruct io_defer_entry *de = list_first_entry(&ctx->defer_list,\n\t\t\t\t\t\tstruct io_defer_entry, list);\n\n\t\tif (req_need_defer(de->req, de->seq))\n\t\t\tbreak;\n\t\tlist_del_init(&de->list);\n\t\tio_req_task_queue(de->req);\n\t\tkfree(de);\n\t}\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":369341,"func":"\nstatic void io_destroy_buffers(struct io_ring_ctx *ctx)\n{\n\tint i;\n\n\tfor (i = 0; i < (1U << IO_BUFFERS_HASH_BITS); i++) {\n\t\tstruct list_head *list = &ctx->io_buffers[i];\n\n\t\twhile (!list_empty(list)) {\n\t\t\tstruct io_buffer_list *bl;\n\n\t\t\tbl = list_first_entry(list, struct io_buffer_list, list);\n\t\t\t__io_remove_buffers(ctx, bl, -1U);\n\t\t\tlist_del(&bl->list);\n\t\t\tkfree(bl);\n\t\t}\n\t}\n\n\twhile (!list_empty(&ctx->io_buffers_pages)) {\n\t\tstruct page *page;\n\n\t\tpage = list_first_entry(&ctx->io_buffers_pages, struct page, lru);\n\t\tlist_del_init(&page->lru);\n\t\t__free_page(page);\n\t}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":328980,"func":"R_API char *r_bin_java_print_interfacemethodref_cp_stringify(RBinJavaCPTypeObj *obj) {\n\treturn r_str_newf (\"%d.0x%04\"PFMT64x \".%s.%d.%d\",\n\t\t\tobj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,\n\t\t\tobj->info.cp_interface.class_idx, obj->info.cp_interface.name_and_type_idx);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":369336,"func":"static bool io_resubmit_prep(struct io_kiocb *req)\n{\n\tstruct io_async_rw *rw = req->async_data;\n\n\tif (!req_has_async_data(req))\n\t\treturn !io_req_prep_async(req);\n\tiov_iter_restore(&rw->s.iter, &rw->s.iter_state);\n\treturn true;\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":238603,"func":"static void mark_verifier_state_clean(struct bpf_verifier_env *env)\n{\n\tenv->scratched_regs = 0U;\n\tenv->scratched_stack_slots = 0ULL;\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":225733,"func":"#ifndef GPAC_DISABLE_ISOM_WRITE\nGF_Err prft_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_ProducerReferenceTimeBox *ptr = (GF_ProducerReferenceTimeBox *) s;\n\tif (!s) return GF_BAD_PARAM;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u32(bs, ptr->refTrackID);\n\tgf_bs_write_u64(bs, ptr->ntp);\n\tif (ptr->version==0) {\n\t\tgf_bs_write_u32(bs, (u32) ptr->timestamp);\n\t} else {\n\t\tgf_bs_write_u64(bs, ptr->timestamp);\n\t}\n\n\treturn GF_OK;","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":293531,"func":"PJ_DEF(void) pj_scan_init( pj_scanner *scanner, char *bufstart, \n\t\t\t   pj_size_t buflen, unsigned options, \n\t\t\t   pj_syn_err_func_ptr callback )\n{\n    PJ_CHECK_STACK();\n\n    scanner->begin = scanner->curptr = bufstart;\n    scanner->end = bufstart + buflen;\n    scanner->line = 1;\n    scanner->start_line = scanner->begin;\n    scanner->callback = callback;\n    scanner->skip_ws = options;\n\n    if (scanner->skip_ws) \n\tpj_scan_skip_whitespace(scanner);\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":498093,"func":"static char *convert_query_hexchar(char *txt)\n{\n\tint d1, d2, n;\n\tn = strlen(txt);\n\tif (n < 3) {\n\t\t*txt = '\\0';\n\t\treturn txt-1;\n\t}\n\td1 = hextoint(*(txt + 1));\n\td2 = hextoint(*(txt + 2));\n\tif (d1 < 0 || d2 < 0) {\n\t\tmemmove(txt, txt + 3, n - 2);\n\t\treturn txt-1;\n\t} else {\n\t\t*txt = d1 * 16 + d2;\n\t\tmemmove(txt + 1, txt + 3, n - 2);\n\t\treturn txt;\n\t}\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":459173,"func":"int tcf_block_get(struct tcf_block **p_block,\n\t\t  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,\n\t\t  struct netlink_ext_ack *extack)\n{\n\tstruct tcf_block_ext_info ei = {\n\t\t.chain_head_change = tcf_chain_head_change_dflt,\n\t\t.chain_head_change_priv = p_filter_chain,\n\t};\n\n\tWARN_ON(!p_filter_chain);\n\treturn tcf_block_get_ext(p_block, q, &ei, extack);\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":249515,"func":"int processing_data(png_structp png_ptr, png_infop info_ptr, unsigned char* p,\n                    unsigned int size) {\n  if (!png_ptr || !info_ptr) return 1;\n\n  if (setjmp(png_jmpbuf(png_ptr))) {\n    png_destroy_read_struct(&png_ptr, &info_ptr, 0);\n    return 1;\n  }\n\n  png_process_data(png_ptr, info_ptr, p, size);\n  return 0;\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":220929,"func":"const GF_FilterRegister *mpgviddmx_register(GF_FilterSession *session)\n{\n\treturn NULL;\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":229340,"func":"string EscapeOrigName(const string& orig_name) {\n  \/\/ Replace _ with __ in the original name to avoid name conflicts.\n  return absl::StrReplaceAll(orig_name, {{\"_\", \"__\"}});\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":359585,"func":"DEFUN (no_neighbor_distribute_list,\n       no_neighbor_distribute_list_cmd,\n       NO_NEIGHBOR_CMD2 \"distribute-list (<1-199>|<1300-2699>|WORD) (in|out)\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Filter updates to\/from this neighbor\\n\"\n       \"IP access-list number\\n\"\n       \"IP access-list number (expanded range)\\n\"\n       \"IP Access-list name\\n\"\n       \"Filter incoming updates\\n\"\n       \"Filter outgoing updates\\n\")\n{\n  return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t\t    bgp_node_safi (vty), argv[2]);\n}","target":0,"code_token_length":164,"total_token_length":400,"max_tokens_setting":512}
+{"idx":343214,"func":"void dositetime(void)\n{\n    char tmp[64];\n    const struct tm *tm;\n    time_t now;\n\n    if ((now = time(NULL)) == (time_t) -1 || (tm = localtime(&now)) == NULL) {\n        addreply_noformat(451, \"time()\");\n        return;\n    }\n    strftime(tmp, sizeof tmp, \"%Y-%m-%d %H:%M:%S\", tm);\n    addreply_noformat(211, tmp);\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":248281,"func":"DLLIMPORT cfg_validate_callback2_t cfg_set_validate_func2(cfg_t *cfg, const char *name, cfg_validate_callback2_t vf)\n{\n\tcfg_opt_t *opt;\n\tcfg_validate_callback2_t oldvf;\n\n\topt = cfg_getopt_array(cfg->opts, cfg->flags, name);\n\tif (!opt)\n\t\treturn NULL;\n\n\toldvf = opt->validcb2;\n\topt->validcb2 = vf;\n\n\treturn oldvf;\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":338087,"func":"void WasmBinaryWriter::writeMemory() {\n  if (!wasm->memory.exists || wasm->memory.imported()) {\n    return;\n  }\n  BYN_TRACE(\"== writeMemory\\n\");\n  auto start = startSection(BinaryConsts::Section::Memory);\n  o << U32LEB(1); \/\/ Define 1 memory\n  writeResizableLimits(wasm->memory.initial,\n                       wasm->memory.max,\n                       wasm->memory.hasMax(),\n                       wasm->memory.shared,\n                       wasm->memory.is64());\n  finishSection(start);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":516255,"func":"static DeviceState *failover_find_primary_device(VirtIONet *n)\n{\n    char *id = failover_find_primary_device_id(n);\n\n    if (!id) {\n        return NULL;\n    }\n\n    return qdev_find_recursive(sysbus_get_default(), id);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":317093,"func":"static int selinux_kernel_module_from_file(struct file *file)\n{\n\tstruct common_audit_data ad;\n\tstruct inode_security_struct *isec;\n\tstruct file_security_struct *fsec;\n\tu32 sid = current_sid();\n\tint rc;\n\n\t\/* init_module *\/\n\tif (file == NULL)\n\t\treturn avc_has_perm(&selinux_state,\n\t\t\t\t    sid, sid, SECCLASS_SYSTEM,\n\t\t\t\t\tSYSTEM__MODULE_LOAD, NULL);\n\n\t\/* finit_module *\/\n\n\tad.type = LSM_AUDIT_DATA_FILE;\n\tad.u.file = file;\n\n\tfsec = selinux_file(file);\n\tif (sid != fsec->sid) {\n\t\trc = avc_has_perm(&selinux_state,\n\t\t\t\t  sid, fsec->sid, SECCLASS_FD, FD__USE, &ad);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tisec = inode_security(file_inode(file));\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    sid, isec->sid, SECCLASS_SYSTEM,\n\t\t\t\tSYSTEM__MODULE_LOAD, &ad);\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":313841,"func":"nv_window(cmdarg_T *cap)\n{\n    if (cap->nchar == ':')\n    {\n\t\/\/ \"CTRL-W :\" is the same as typing \":\"; useful in a terminal window\n\tcap->cmdchar = ':';\n\tcap->nchar = NUL;\n\tnv_colon(cap);\n    }\n    else if (!checkclearop(cap->oap))\n\tdo_window(cap->nchar, cap->count0, NUL); \/\/ everything is in window.c\n}","target":0,"code_token_length":100,"total_token_length":336,"max_tokens_setting":512}
+{"idx":216906,"func":"void ha_maria::drop_table(const char *name)\n{\n  DBUG_ASSERT(file->s->temporary);\n  (void) ha_close();\n  (void) maria_delete_table_files(name, 1, MY_WME);\n}","target":1,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":379654,"func":"R_API RAnalVar *r_anal_function_get_var(RAnalFunction *fcn, char kind, int delta) {\n\tr_return_val_if_fail (fcn, NULL);\n\tvoid **it;\n\tr_pvector_foreach (&fcn->vars, it) {\n\t\tRAnalVar *var = *it;\n\t\tif (var->kind == kind && var->delta == delta) {\n\t\t\treturn var;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":389708,"func":"check_for_number_arg(typval_T *args, int idx)\n{\n    if (args[idx].v_type != VAR_NUMBER)\n    {\n\tsemsg(_(e_number_required_for_argument_nr), idx + 1);\n\treturn FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":521471,"func":"    bool isExhausted() override\r\n    {\r\n        return headerSize <= 0 || pos >= zipEntryHolder.compressedSize;\r\n    }\r","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":427192,"func":"static void codeclosure (LexState *ls, expdesc *v) {\n  FuncState *fs = ls->fs->prev;\n  init_exp(v, VRELOC, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1));\n  luaK_exp2nextreg(fs, v);  \/* fix it at the last register *\/\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":222836,"func":"  void ExtractValue(DimensionHandle d, int64_t* result) {\n    if (!InferenceContext::ValueKnown(d)) {\n      *result = -counter;\n      counter++;\n    } else {\n      int64_t val = InferenceContext::Value(d);\n      if (val >= 0) {\n        *result = val;\n      } else {\n        \/\/ A shape inference function generated an invalid dimension handle.\n        \/\/ Use a symbolic dimension to encode this.\n        *result = -counter;\n        counter++;\n      }\n    }\n  }","target":0,"code_token_length":114,"total_token_length":350,"max_tokens_setting":512}
+{"idx":387729,"func":"Method* InstanceKlass::method_with_orig_idnum(int idnum, int version) {\n  InstanceKlass* holder = get_klass_version(version);\n  if (holder == NULL) {\n    return NULL; \/\/ The version of klass is gone, no method is found\n  }\n  Method* method = holder->method_with_orig_idnum(idnum);\n  return method;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":259542,"func":"bool Curl_is_absolute_url(const char *url, char *buf, size_t buflen)\n{\n  int i;\n  DEBUGASSERT(!buf || (buflen > MAX_SCHEME_LEN));\n  (void)buflen; \/* only used in debug-builds *\/\n  if(buf)\n    buf[0] = 0; \/* always leave a defined value in buf *\/\n#ifdef WIN32\n  if(STARTS_WITH_DRIVE_PREFIX(url))\n    return FALSE;\n#endif\n  for(i = 0; i < MAX_SCHEME_LEN; ++i) {\n    char s = url[i];\n    if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.') )) {\n      \/* RFC 3986 3.1 explains:\n        scheme      = ALPHA *( ALPHA \/ DIGIT \/ \"+\" \/ \"-\" \/ \".\" )\n      *\/\n    }\n    else {\n      break;\n    }\n  }\n  if(i && (url[i] == ':') && (url[i + 1] == '\/')) {\n    if(buf) {\n      buf[i] = 0;\n      while(i--) {\n        buf[i] = (char)TOLOWER(url[i]);\n      }\n    }\n    return TRUE;\n  }\n  return FALSE;\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":270120,"func":"TfLiteStatus CalculateActivationRangeQuantized(TfLiteContext* context,\n                                               TfLiteFusedActivation activation,\n                                               TfLiteTensor* output,\n                                               int32_t* act_min,\n                                               int32_t* act_max) {\n  int32_t qmin = 0;\n  int32_t qmax = 0;\n  if (output->type == kTfLiteUInt8) {\n    qmin = std::numeric_limits<uint8_t>::min();\n    qmax = std::numeric_limits<uint8_t>::max();\n  } else if (output->type == kTfLiteInt8) {\n    qmin = std::numeric_limits<int8_t>::min();\n    qmax = std::numeric_limits<int8_t>::max();\n  } else if (output->type == kTfLiteInt16) {\n    qmin = std::numeric_limits<int16_t>::min();\n    qmax = std::numeric_limits<int16_t>::max();\n  } else {\n    TF_LITE_ENSURE(context, false);\n  }\n\n  return CalculateActivationRangeQuantizedImpl(context, activation, qmin, qmax,\n                                               output, act_min, act_max);\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":398487,"func":"RZ_API const char *rz_bin_dwarf_get_lang_name(ut64 lang) {\n\tif (lang >= RZ_ARRAY_SIZE(dwarf_langs)) {\n\t\treturn NULL;\n\t}\n\treturn dwarf_langs[lang];\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":309822,"func":"drv_initcolor(TERMINAL_CONTROL_BLOCK * TCB,\n\t      int color, int r, int g, int b)\n{\n    SCREEN *sp = TCB->csp;\n\n    AssertTCB();\n    if (initialize_color != NULL) {\n\tNCURSES_PUTP2(\"initialize_color\",\n\t\t      TIPARM_4(initialize_color, color, r, g, b));\n    }\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":316957,"func":"static int selinux_tun_dev_attach_queue(void *security)\n{\n\tstruct tun_security_struct *tunsec = security;\n\n\treturn avc_has_perm(&selinux_state,\n\t\t\t    current_sid(), tunsec->sid, SECCLASS_TUN_SOCKET,\n\t\t\t    TUN_SOCKET__ATTACH_QUEUE, NULL);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":233952,"func":"DocumentSourceUnionWith::~DocumentSourceUnionWith() {\n    if (_pipeline && _pipeline->getContext()->explain) {\n        _pipeline->dispose(pExpCtx->opCtx);\n        _pipeline.reset();\n    }\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":264255,"func":"static void vnc_dpy_update(DisplayChangeListener *dcl,\n                           int x, int y, int w, int h)\n{\n    VncDisplay *vd = container_of(dcl, VncDisplay, dcl);\n    struct VncSurface *s = &vd->guest;\n    int width = surface_width(vd->ds);\n    int height = surface_height(vd->ds);\n\n    \/* this is needed this to ensure we updated all affected\n     * blocks if x % VNC_DIRTY_PIXELS_PER_BIT != 0 *\/\n    w += (x % VNC_DIRTY_PIXELS_PER_BIT);\n    x -= (x % VNC_DIRTY_PIXELS_PER_BIT);\n\n    x = MIN(x, width);\n    y = MIN(y, height);\n    w = MIN(x + w, width) - x;\n    h = MIN(y + h, height);\n\n    for (; y < h; y++) {\n        bitmap_set(s->dirty[y], x \/ VNC_DIRTY_PIXELS_PER_BIT,\n                   DIV_ROUND_UP(w, VNC_DIRTY_PIXELS_PER_BIT));\n    }\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":317082,"func":"static int selinux_move_mount(const struct path *from_path,\n\t\t\t      const struct path *to_path)\n{\n\tconst struct cred *cred = current_cred();\n\n\treturn path_has_perm(cred, to_path, FILE__MOUNTON);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":344265,"func":"static const char *formatvarinfo (lua_State *L, const char *kind,\n                                                const char *name) {\n  if (kind == NULL)\n    return \"\";  \/* no information *\/\n  else\n    return luaO_pushfstring(L, \" (%s '%s')\", kind, name);\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":506433,"func":"static bool verify_credentials(struct rpa_auth_request *request,\n\t\t\t       const unsigned char *credentials, size_t size)\n{\n\tunsigned char response[MD5_RESULTLEN];\n\n\tif (size != sizeof(request->pwd_md5)) {\n                e_error(request->auth_request.mech_event,\n\t\t\t\"invalid credentials length\");\n\t\treturn FALSE;\n\t}\n\n\tmemcpy(request->pwd_md5, credentials, sizeof(request->pwd_md5));\n\trpa_user_response(request, response);\n\treturn mem_equals_timing_safe(response, request->user_response, sizeof(response));\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":482546,"func":"_lou_getTranslationTable(const char *tableList) {\n\tTranslationTableHeader *table;\n\tgetTable(tableList, NULL, &table, NULL);\n\tif (table)\n\t\tif (!finalizeTable(table)) table = NULL;\n\treturn table;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":455396,"func":"xfs_reinit_inode(\n\tstruct xfs_mount\t*mp,\n\tstruct inode\t\t*inode)\n{\n\tint\t\terror;\n\tuint32_t\tnlink = inode->i_nlink;\n\tuint32_t\tgeneration = inode->i_generation;\n\tuint64_t\tversion = inode_peek_iversion(inode);\n\tumode_t\t\tmode = inode->i_mode;\n\tdev_t\t\tdev = inode->i_rdev;\n\n\terror = inode_init_always(mp->m_super, inode);\n\n\tset_nlink(inode, nlink);\n\tinode->i_generation = generation;\n\tinode_set_iversion_queried(inode, version);\n\tinode->i_mode = mode;\n\tinode->i_rdev = dev;\n\treturn error;\n}","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":256939,"func":"  static void InsertBroadcastLabels(int num_bcast_dims, int num_named_labels,\n                                    int ellipsis_axis, Labels* labels,\n                                    LabelCounts* label_counts) {\n    labels->erase(labels->begin() + ellipsis_axis);\n    labels->insert(labels->begin() + ellipsis_axis, num_bcast_dims, 0);\n    std::iota(labels->begin() + ellipsis_axis,\n              labels->begin() + ellipsis_axis + num_bcast_dims,\n              num_named_labels);\n    \/\/ Increment label counts. Since these are new labels, the count is set\n    \/\/ to 1.\n    label_counts->resize(num_named_labels + num_bcast_dims, 1);\n  }","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":226058,"func":"GF_Err moof_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MovieFragmentBox *ptr = (GF_MovieFragmentBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_MFHD:\n\t\tBOX_FIELD_ASSIGN(mfhd, GF_MovieFragmentHeaderBox)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_TRAF:\n\t\tBOX_FIELD_LIST_ASSIGN(TrackList)\n\t\treturn GF_OK;\n\tcase GF_ISOM_BOX_TYPE_PSSH:\n\t\tBOX_FIELD_LIST_ASSIGN(PSSHs)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":312586,"func":"qf_parse_dir_pfx(int idx, qffields_T *fields, qf_list_T *qfl)\n{\n    if (idx == 'D')\t\t\t\t\/\/ enter directory\n    {\n\tif (*fields->namebuf == NUL)\n\t{\n\t    emsg(_(e_missing_or_empty_directory_name));\n\t    return QF_FAIL;\n\t}\n\tqfl->qf_directory =\n\t    qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE);\n\tif (qfl->qf_directory == NULL)\n\t    return QF_FAIL;\n    }\n    else if (idx == 'X')\t\t\t\/\/ leave directory\n\tqfl->qf_directory = qf_pop_dir(&qfl->qf_dir_stack);\n\n    return QF_OK;\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":369169,"func":"\nstatic __cold int io_register_iowq_aff(struct io_ring_ctx *ctx,\n\t\t\t\t       void __user *arg, unsigned len)\n{\n\tstruct io_uring_task *tctx = current->io_uring;\n\tcpumask_var_t new_mask;\n\tint ret;\n\n\tif (!tctx || !tctx->io_wq)\n\t\treturn -EINVAL;\n\n\tif (!alloc_cpumask_var(&new_mask, GFP_KERNEL))\n\t\treturn -ENOMEM;\n\n\tcpumask_clear(new_mask);\n\tif (len > cpumask_size())\n\t\tlen = cpumask_size();\n\n\tif (in_compat_syscall()) {\n\t\tret = compat_get_bitmap(cpumask_bits(new_mask),\n\t\t\t\t\t(const compat_ulong_t __user *)arg,\n\t\t\t\t\tlen * 8 \/* CHAR_BIT *\/);\n\t} else {\n\t\tret = copy_from_user(new_mask, arg, len);\n\t}\n\n\tif (ret) {\n\t\tfree_cpumask_var(new_mask);\n\t\treturn -EFAULT;\n\t}\n\n\tret = io_wq_cpu_affinity(tctx->io_wq, new_mask);\n\tfree_cpumask_var(new_mask);\n\treturn ret;","target":0,"code_token_length":227,"total_token_length":463,"max_tokens_setting":512}
+{"idx":465853,"func":"int nfcmrvl_parse_dt(struct device_node *node,\n\t\t     struct nfcmrvl_platform_data *pdata)\n{\n\tint reset_n_io;\n\n\treset_n_io = of_get_named_gpio(node, \"reset-n-io\", 0);\n\tif (reset_n_io < 0) {\n\t\tpr_info(\"no reset-n-io config\\n\");\n\t} else if (!gpio_is_valid(reset_n_io)) {\n\t\tpr_err(\"invalid reset-n-io GPIO\\n\");\n\t\treturn reset_n_io;\n\t}\n\tpdata->reset_n_io = reset_n_io;\n\n\tif (of_find_property(node, \"hci-muxed\", NULL))\n\t\tpdata->hci_muxed = 1;\n\telse\n\t\tpdata->hci_muxed = 0;\n\n\treturn 0;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":446419,"func":"static HtPU *create_path_to_index(RzBuffer *cache_buf, cache_img_t *img, cache_hdr_t *hdr) {\n\tHtPU *path_to_idx = ht_pu_new0();\n\tif (!path_to_idx) {\n\t\treturn NULL;\n\t}\n\tfor (size_t i = 0; i != hdr->imagesCount; i++) {\n\t\tchar file[256];\n\t\tif (rz_buf_read_at(cache_buf, img[i].pathFileOffset, (ut8 *)&file, sizeof(file)) != sizeof(file)) {\n\t\t\tcontinue;\n\t\t}\n\t\tfile[255] = 0;\n\t\tht_pu_insert(path_to_idx, file, (ut64)i);\n\t}\n\n\treturn path_to_idx;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":468368,"func":"g_socket_client_get_tls_validation_flags (GSocketClient *client)\n{\n  return client->priv->tls_validation_flags;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":384826,"func":"pstrcmp(const void *a, const void *b)\n{\n    return (pathcmp(*(char **)a, *(char **)b, -1));\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":497806,"func":"kwsexec (kwset_t kwset, char const *text, size_t size,\n         struct kwsmatch *kwsmatch)\n{\n  if (kwset->words == 1)\n    {\n      size_t ret = bmexec (kwset, text, size);\n      if (ret != (size_t) -1)\n        {\n          kwsmatch->index = 0;\n          kwsmatch->offset[0] = ret;\n          kwsmatch->size[0] = kwset->mind;\n        }\n      return ret;\n    }\n  else\n    return cwexec (kwset, text, size, kwsmatch);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":349899,"func":"static u32 hw_atl_utils_mpi_get_state(struct aq_hw_s *self)\n{\n\treturn aq_hw_read_reg(self, HW_ATL_MPI_STATE_ADR);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":513105,"func":"  Type_geometry_attributes(const Type_handler *handler,\n                           const Type_all_attributes *gattr)\n   :m_geometry_type(m_geometry_type_unknown)\n  {\n    copy(handler, gattr);\n  }","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":207826,"func":"inline int nci_request(struct nci_dev *ndev,\n\t\t       void (*req)(struct nci_dev *ndev,\n\t\t\t\t   const void *opt),\n\t\t       const void *opt, __u32 timeout)\n{\n\tint rc;\n\n\tif (!test_bit(NCI_UP, &ndev->flags))\n\t\treturn -ENETDOWN;\n\n\t\/* Serialize all requests *\/\n\tmutex_lock(&ndev->req_lock);\n\trc = __nci_request(ndev, req, opt, timeout);\n\tmutex_unlock(&ndev->req_lock);\n\n\treturn rc;\n}","target":1,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":254708,"func":"njs_typed_array_compare(double a, double b)\n{\n    if (njs_slow_path(isnan(a))) {\n        if (isnan(b)) {\n            return 0;\n        }\n\n        return 1;\n    }\n\n    if (njs_slow_path(isnan(b))) {\n        return -1;\n    }\n\n    if (a < b) {\n        return -1;\n    }\n\n    if (a > b) {\n        return 1;\n    }\n\n    return signbit(b) - signbit(a);\n}","target":0,"code_token_length":107,"total_token_length":343,"max_tokens_setting":512}
+{"idx":463121,"func":"static void annotate_closedb(annotate_db_t *d)\n{\n    annotate_db_t *dx, *prev = NULL;\n    int r;\n\n    \/* detach from the global list *\/\n    for (dx = all_dbs_head ; dx && dx != d ; prev = dx, dx = dx->next)\n        ;\n    assert(dx);\n    assert(d == dx);\n    detach_db(prev, d);\n\n#if DEBUG\n    syslog(LOG_ERR, \"Closing annotations db %s\\n\", d->filename);\n#endif\n\n    r = cyrusdb_close(d->db);\n    if (r)\n        syslog(LOG_ERR, \"DBERROR: error closing annotations %s: %s\",\n               d->filename, cyrusdb_strerror(r));\n\n    free(d->filename);\n    free(d->mboxname);\n    memset(d, 0, sizeof(*d));   \/* JIC *\/\n    free(d);\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":227035,"func":"IRC_PROTOCOL_CALLBACK(whois_nick_msg)\n{\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (\n            server, argv[3], command, \"whois\", NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s[%s%s%s] %s%s\",\n        weechat_prefix (\"network\"),\n        IRC_COLOR_CHAT_DELIMITERS,\n        irc_nick_color_for_msg (server, 1, NULL, argv[3]),\n        argv[3],\n        IRC_COLOR_CHAT_DELIMITERS,\n        IRC_COLOR_RESET,\n        (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":300729,"func":"static void tipc_write_space(struct sock *sk)\n{\n\tstruct socket_wq *wq;\n\n\trcu_read_lock();\n\twq = rcu_dereference(sk->sk_wq);\n\tif (skwq_has_sleeper(wq))\n\t\twake_up_interruptible_sync_poll(&wq->wait, EPOLLOUT |\n\t\t\t\t\t\tEPOLLWRNORM | EPOLLWRBAND);\n\trcu_read_unlock();\n}","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":274680,"func":"callbacks_get_selected_row_index (void)\n{\n\tGtkTreeSelection *selection;\n\tGtkTreeIter       iter;\n\tGtkListStore *list_store = (GtkListStore *) gtk_tree_view_get_model\n\t\t\t((GtkTreeView *) screen.win.layerTree);\n\tgint index=-1,i=0;\n\n\t\/* This will only work in single or browse selection mode! *\/\n\tselection = gtk_tree_view_get_selection((GtkTreeView *) screen.win.layerTree);\n\tif (gtk_tree_selection_get_selected(selection, NULL, &iter)) {\n\t\twhile (gtk_tree_model_iter_nth_child ((GtkTreeModel *)list_store,\n\t\t\t\t&iter, NULL, i)){\n\t\t\tif (gtk_tree_selection_iter_is_selected (selection, &iter)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t\ti++;\n     \t\t}\n\t}\n\treturn index;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":247531,"func":"  const std::string& expectedOcspResponse() const { return expected_ocsp_response_; }","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":424512,"func":"static UINT video_control_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* s)\n{\n\tVIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*)pChannelCallback;\n\tVIDEO_PLUGIN* video;\n\tVideoClientContext* context;\n\tUINT ret = CHANNEL_RC_OK;\n\tUINT32 cbSize, packetType;\n\n\tvideo = (VIDEO_PLUGIN*)callback->plugin;\n\tcontext = (VideoClientContext*)video->wtsPlugin.pInterface;\n\n\tif (Stream_GetRemainingLength(s) < 4)\n\t\treturn ERROR_INVALID_DATA;\n\n\tStream_Read_UINT32(s, cbSize);\n\tif (cbSize < 8 || Stream_GetRemainingLength(s) < (cbSize - 4))\n\t{\n\t\tWLog_ERR(TAG, \"invalid cbSize\");\n\t\treturn ERROR_INVALID_DATA;\n\t}\n\n\tStream_Read_UINT32(s, packetType);\n\tswitch (packetType)\n\t{\n\t\tcase TSMM_PACKET_TYPE_PRESENTATION_REQUEST:\n\t\t\tret = video_read_tsmm_presentation_req(context, s);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tWLog_ERR(TAG, \"not expecting packet type %\" PRIu32 \"\", packetType);\n\t\t\tret = ERROR_UNSUPPORTED_TYPE;\n\t\t\tbreak;\n\t}\n\n\treturn ret;\n}","target":0,"code_token_length":251,"total_token_length":487,"max_tokens_setting":512}
+{"idx":436157,"func":"\nstatic int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,\n\t\t\t    unsigned int size, unsigned int type)\n{\n\tstruct io_uring_rsrc_register rr;\n\n\t\/* keep it extendible *\/\n\tif (size != sizeof(rr))\n\t\treturn -EINVAL;\n\n\tmemset(&rr, 0, sizeof(rr));\n\tif (copy_from_user(&rr, arg, size))\n\t\treturn -EFAULT;\n\tif (!rr.nr || rr.resv || rr.resv2)\n\t\treturn -EINVAL;\n\n\tswitch (type) {\n\tcase IORING_RSRC_FILE:\n\t\treturn io_sqe_files_register(ctx, u64_to_user_ptr(rr.data),\n\t\t\t\t\t     rr.nr, u64_to_user_ptr(rr.tags));\n\tcase IORING_RSRC_BUFFER:\n\t\treturn io_sqe_buffers_register(ctx, u64_to_user_ptr(rr.data),\n\t\t\t\t\t       rr.nr, u64_to_user_ptr(rr.tags));\n\t}\n\treturn -EINVAL;","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":349267,"func":"int check_name(char *name, int size)\n{\n\tchar *start = name;\n\n\tif(name[0] == '.') {\n\t\tif(name[1] == '.')\n\t\t\tname++;\n\t\tif(name[1] == '\/' || name[1] == '\\0')\n\t\t\treturn FALSE;\n\t}\n\n\twhile(name[0] != '\/' && name[0] != '\\0')\n\t\tname ++;\n\n\tif(name[0] == '\/')\n\t\treturn FALSE;\n\n\tif((name - start) != size)\n\t\treturn FALSE;\n\n\treturn TRUE;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":343215,"func":"void dosize(const char *name)\n{\n    struct stat st;\n\n    if (!name || !*name) {\n        addreply_noformat(501, MSG_MISSING_ARG);\n    } else if (stat(name, &st)) {\n#ifdef DEBUG\n        if (debug != 0) {\n            addreply(0, \"arg: %s, wd: %s\", name, wd);\n        }\n#endif\n        addreply_noformat(550, MSG_STAT_FAILURE2);\n    } else if (!S_ISREG(st.st_mode)) {\n        addreply_noformat(550, MSG_NOT_REGULAR_FILE);\n    } else {\n        addreply(213, \"%llu\", (unsigned long long) st.st_size);\n    }\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":513206,"func":"static int item_is_unsigned(struct st_mysql_value *value)\n{\n  Item *item= ((st_item_value_holder*)value)->item;\n  return item->unsigned_flag;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":253547,"func":"smb2_find_mid(struct TCP_Server_Info *server, char *buf)\n{\n\treturn __smb2_find_mid(server, buf, false);\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":225071,"func":"PQconnectionNeedsPassword(const PGconn *conn)\n{\n\tchar\t   *password;\n\n\tif (!conn)\n\t\treturn false;\n\tpassword = PQpass(conn);\n\tif (conn->password_needed &&\n\t\t(password == NULL || password[0] == '\\0'))\n\t\treturn true;\n\telse\n\t\treturn false;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":508898,"func":"bool LEX::only_view_structure()\n{\n  switch (sql_command) {\n  case SQLCOM_SHOW_CREATE:\n  case SQLCOM_SHOW_TABLES:\n  case SQLCOM_SHOW_FIELDS:\n  case SQLCOM_REVOKE_ALL:\n  case SQLCOM_REVOKE:\n  case SQLCOM_GRANT:\n  case SQLCOM_CREATE_VIEW:\n    return TRUE;\n  default:\n    return FALSE;\n  }\n}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":441816,"func":"SProcXkbUseExtension(ClientPtr client)\n{\n    REQUEST(xkbUseExtensionReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbUseExtensionReq);\n    swaps(&stuff->wantedMajor);\n    swaps(&stuff->wantedMinor);\n    return ProcXkbUseExtension(client);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":225600,"func":"\nGF_Err subs_box_size(GF_Box *s)\n{\n\tGF_SubSampleInformationBox *ptr = (GF_SubSampleInformationBox *) s;\n\tu32 entry_count, i;\n\tu16 subsample_count;\n\n\t\/\/ add 4 byte for entry_count\n\tptr->size += 4;\n\tentry_count = gf_list_count(ptr->Samples);\n\tfor (i=0; i<entry_count; i++) {\n\t\tGF_SubSampleInfoEntry *pSamp = (GF_SubSampleInfoEntry*) gf_list_get(ptr->Samples, i);\n\t\tsubsample_count = gf_list_count(pSamp->SubSamples);\n\t\t\/\/ 4 byte for sample_delta, 2 byte for subsample_count\n\t\t\/\/ and 6 + (4 or 2) bytes for each subsample\n\t\tptr->size += 4 + 2 + subsample_count * (6 + (ptr->version==1 ? 4 : 2));\n\t}\n\treturn GF_OK;","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":317070,"func":"static int smack_task_setscheduler(struct task_struct *p)\n{\n\treturn smk_curacc_on_task(p, MAY_WRITE, __func__);\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":210904,"func":"static void warnf(struct Configurable *config, const char *fmt, ...)\n{\n  if(!(config->conf & CONF_MUTE)) {\n    va_list ap;\n    int len;\n    char *ptr;\n    char print_buffer[256];\n\n    va_start(ap, fmt);\n    va_start(ap, fmt);\n    len = vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);\n    va_end(ap);\n\n    ptr = print_buffer;\n    while(len > 0) {\n      fputs(WARN_PREFIX, config->errors);\n\n      if(len > (int)WARN_TEXTWIDTH) {\n        int cut = WARN_TEXTWIDTH-1;\n\n        while(!ISSPACE(ptr[cut]) && cut) {\n          cut--;\n        }\n\n        fwrite(ptr, cut + 1, 1, config->errors);\n        fputs(\"\\n\", config->errors);\n        ptr += cut+1; \/* skip the space too *\/\n        len -= cut;\n      }\n      else {\n        fputs(ptr, config->errors);\n        len = 0;\n      }\n    }\n  }\n}","target":1,"code_token_length":221,"total_token_length":457,"max_tokens_setting":512}
+{"idx":294718,"func":"c_gregorian_leap_p(int y)\n{\n    return (MOD(y, 4) == 0 && y % 100 != 0) || MOD(y, 400) == 0;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":512645,"func":"Item_func_ifnull::str_op(String *str)\n{\n  DBUG_ASSERT(fixed == 1);\n  String *res  =args[0]->val_str(str);\n  if (!args[0]->null_value)\n  {\n    null_value=0;\n    res->set_charset(collation.collation);\n    return res;\n  }\n  res=args[1]->val_str(str);\n  if ((null_value=args[1]->null_value))\n    return 0;\n  res->set_charset(collation.collation);\n  return res;\n}","target":0,"code_token_length":112,"total_token_length":348,"max_tokens_setting":512}
+{"idx":294722,"func":"local_df(union DateData *x)\n{\n    assert(complex_dat_p(x));\n    assert(have_df_p(x));\n    return df_utc_to_local(x->c.df, x->c.of);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":317316,"func":"static int smack_msg_queue_msgctl(struct kern_ipc_perm *isp, int cmd)\n{\n\tint may;\n\n\tswitch (cmd) {\n\tcase IPC_STAT:\n\tcase MSG_STAT:\n\tcase MSG_STAT_ANY:\n\t\tmay = MAY_READ;\n\t\tbreak;\n\tcase IPC_SET:\n\tcase IPC_RMID:\n\t\tmay = MAY_READWRITE;\n\t\tbreak;\n\tcase IPC_INFO:\n\tcase MSG_INFO:\n\t\t\/*\n\t\t * System level information\n\t\t *\/\n\t\treturn 0;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\treturn smk_curacc_msq(isp, may);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":484062,"func":"START_TEST(SecureChannel_sendSymmetricMessage_modeSignAndEncrypt)\n{\n    \/\/ initialize dummy message\n    UA_ReadRequest dummyMessage;\n    UA_ReadRequest_init(&dummyMessage);\n    UA_DataType dummyType = UA_TYPES[UA_TYPES_READREQUEST];\n\n    testChannel.securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;\n\n    UA_StatusCode retval = UA_SecureChannel_sendSymmetricMessage(&testChannel, 42, UA_MESSAGETYPE_MSG,\n                                                                 &dummyMessage, &dummyType);\n    ck_assert_msg(retval == UA_STATUSCODE_GOOD, \"Expected success\");\n    ck_assert_msg(fCalled.sym_sign, \"Expected message to have been signed\");\n    ck_assert_msg(fCalled.sym_enc, \"Expected message to have been encrypted\");\n} END_TEST","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":359213,"func":"static int ringbuf_map_get_next_key(struct bpf_map *map, void *key,\n\t\t\t\t    void *next_key)\n{\n\treturn -ENOTSUPP;\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":446056,"func":"codeLoop(TIFF* tif, const char* module)\n{\n\tTIFFErrorExt(tif->tif_clientdata, module,\n\t    \"Bogus encoding, loop in the code table; scanline %d\",\n\t    tif->tif_row);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":222555,"func":"  bool operator<(const AttrKeyAndValue& b) const {\n    if (key_name_ != b.key_name_) {\n      return key_name_ < b.key_name_;\n    } else if (key_suffix_ != b.key_suffix_) {\n      return key_suffix_ < b.key_suffix_;\n    } else {\n      return value_ < b.value_;\n    }\n  }","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":317101,"func":"static int smk_bu_note(char *note, struct smack_known *sskp,\n\t\t       struct smack_known *oskp, int mode, int rc)\n{\n\tchar acc[SMK_NUM_ACCESS_TYPE + 1];\n\n\tif (rc <= 0)\n\t\treturn rc;\n\tif (rc > SMACK_UNCONFINED_OBJECT)\n\t\trc = 0;\n\n\tsmk_bu_mode(mode, acc);\n\tpr_info(\"Smack %s: (%s %s %s) %s\\n\", smk_bu_mess[rc],\n\t\tsskp->smk_known, oskp->smk_known, acc, note);\n\treturn 0;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":486827,"func":"static uint16_t gem_phy_read(CadenceGEMState *s, unsigned reg_num)\n{\n    DB_PRINT(\"reg: %d value: 0x%04x\\n\", reg_num, s->phy_regs[reg_num]);\n    return s->phy_regs[reg_num];\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":225838,"func":"GF_Box *co64_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_ChunkLargeOffsetBox, GF_ISOM_BOX_TYPE_CO64);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":246654,"func":"static void naldmx_bs_log(void *udta, const char *field_name, u32 nb_bits, u64 field_val, s32 idx1, s32 idx2, s32 idx3)\n{\n\tGF_NALUDmxCtx *ctx = (GF_NALUDmxCtx *) udta;\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\" %s\", field_name));\n\tif (idx1>=0) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"_%d\", idx1));\n\t\tif (idx2>=0) {\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"_%d\", idx2));\n\t\t\tif (idx3>=0) {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"_%d\", idx3));\n\t\t\t}\n\t\t}\n\t}\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"=\\\"\"LLD, field_val));\n\tif ((ctx->bsdbg==2) && ((s32) nb_bits > 1) )\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"(%u)\", nb_bits));\n\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, (\"\\\" \"));\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":328991,"func":"R_API RBinJavaAttrInfo *r_bin_java_synthetic_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_SYNTHETIC_ATTR;\n\tattr->size = 6;\n\treturn attr;\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":246718,"func":"static Bool strstr_nocase(const char *text, const char *subtext, u32 subtext_len)\n{\n\tif (!*text || !subtext || !subtext_len)\n\t\treturn GF_FALSE;\n\n\twhile (*text) {\n\t\tif (tolower(*text) == *subtext) {\n\t\t\tif (!strnicmp(text, subtext, subtext_len))\n\t\t\t\treturn GF_TRUE;\n\n\t\t}\n\t\ttext++;\n\t}\n\treturn GF_FALSE;\n}","target":0,"code_token_length":95,"total_token_length":331,"max_tokens_setting":512}
+{"idx":512749,"func":"  bool get_date_from_item(THD *thd, Item *item,\n                          MYSQL_TIME *ltime, date_mode_t fuzzydate)\n  {\n    bool rc= item->get_date(thd, ltime, fuzzydate);\n    null_value= MY_TEST(rc || item->null_value);\n    return rc;\n  }","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":276916,"func":"static void decode_bits (u_char const b, char const *str[], int const do_once)\n{\n\tu_char mask;\n\n\tfor (mask = 0x80; mask != 0x00; mask >>= 1, ++str) {\n\t\tif (b & mask) {\n\t\t\tputs (*str);\n\t\t\tif (do_once)\n\t\t\t\treturn;\n\t\t}\n\t}\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":384845,"func":"backslash_halve_save(char_u *p)\n{\n    char_u\t*res;\n\n    res = vim_strsave(p);\n    if (res == NULL)\n\treturn p;\n    backslash_halve(res);\n    return res;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":487645,"func":"struct group_info *groups_alloc(int gidsetsize)\n{\n\tstruct group_info *group_info;\n\tint nblocks;\n\tint i;\n\n\tnblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) \/ NGROUPS_PER_BLOCK;\n\t\/* Make sure we always allocate at least one indirect block pointer *\/\n\tnblocks = nblocks ? : 1;\n\tgroup_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);\n\tif (!group_info)\n\t\treturn NULL;\n\tgroup_info->ngroups = gidsetsize;\n\tgroup_info->nblocks = nblocks;\n\tatomic_set(&group_info->usage, 1);\n\n\tif (gidsetsize <= NGROUPS_SMALL)\n\t\tgroup_info->blocks[0] = group_info->small_block;\n\telse {\n\t\tfor (i = 0; i < nblocks; i++) {\n\t\t\tgid_t *b;\n\t\t\tb = (void *)__get_free_page(GFP_USER);\n\t\t\tif (!b)\n\t\t\t\tgoto out_undo_partial_alloc;\n\t\t\tgroup_info->blocks[i] = b;\n\t\t}\n\t}\n\treturn group_info;\n\nout_undo_partial_alloc:\n\twhile (--i >= 0) {\n\t\tfree_page((unsigned long)group_info->blocks[i]);\n\t}\n\tkfree(group_info);\n\treturn NULL;\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":90780,"func":"void QuotaManager::GetStatistics(\n    std::map<std::string, std::string>* statistics) {\n  DCHECK(statistics);\n  if (temporary_storage_evictor_.get()) {\n    std::map<std::string, int64> stats;\n    temporary_storage_evictor_->GetStatistics(&stats);\n    for (std::map<std::string, int64>::iterator p = stats.begin();\n         p != stats.end();\n         ++p)\n      (*statistics)[p->first] = base::Int64ToString(p->second);\n  }\n}\n","target":0,"code_token_length":118,"total_token_length":354,"max_tokens_setting":512}
+{"idx":462220,"func":"static pj_status_t decode_uint_attr(pj_pool_t *pool, \n\t\t\t\t    const pj_uint8_t *buf, \n\t\t\t\t    const pj_stun_msg_hdr *msghdr, \n\t\t\t\t    void **p_attr)\n{\n    pj_stun_uint_attr *attr;\n\n    PJ_UNUSED_ARG(msghdr);\n\n    \/* Create the attribute *\/\n    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_uint_attr);\n    GETATTRHDR(buf, &attr->hdr);\n\n    attr->value = GETVAL32H(buf, 4);\n\n    \/* Check that the attribute length is valid *\/\n    if (attr->hdr.length != 4)\n\treturn PJNATH_ESTUNINATTRLEN;\n\n    \/* Done *\/\n    *p_attr = attr;\n\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":411934,"func":"check_s4u2self(krb5_context context,\n\t       krb5_kdc_configuration *config,\n\t       HDB *clientdb,\n\t       hdb_entry_ex *client,\n\t       krb5_const_principal server)\n{\n    krb5_error_code ret;\n\n    \/* if client does a s4u2self to itself, that ok *\/\n    if (krb5_principal_compare(context, client->entry.principal, server) == TRUE)\n\treturn 0;\n\n    if (clientdb->hdb_check_s4u2self) {\n\tret = clientdb->hdb_check_s4u2self(context, clientdb, client, server);\n\tif (ret == 0)\n\t    return 0;\n    } else {\n\tret = KRB5KDC_ERR_BADOPTION;\n    }\n    return ret;\n}","target":0,"code_token_length":166,"total_token_length":402,"max_tokens_setting":512}
+{"idx":430364,"func":"void seq_put_decimal_ull_width(struct seq_file *m, const char *delimiter,\n\t\t\t unsigned long long num, unsigned int width)\n{\n\tint len;\n\n\tif (m->count + 2 >= m->size) \/* we'll write 2 bytes at least *\/\n\t\tgoto overflow;\n\n\tif (delimiter && delimiter[0]) {\n\t\tif (delimiter[1] == 0)\n\t\t\tseq_putc(m, delimiter[0]);\n\t\telse\n\t\t\tseq_puts(m, delimiter);\n\t}\n\n\tif (!width)\n\t\twidth = 1;\n\n\tif (m->count + width >= m->size)\n\t\tgoto overflow;\n\n\tlen = num_to_str(m->buf + m->count, m->size - m->count, num, width);\n\tif (!len)\n\t\tgoto overflow;\n\n\tm->count += len;\n\treturn;\n\noverflow:\n\tseq_set_overflow(m);\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":369380,"func":"static void io_req_complete_fail_submit(struct io_kiocb *req)\n{\n\t\/*\n\t * We don't submit, fail them all, for that replace hardlinks with\n\t * normal links. Extra REQ_F_LINK is tolerated.\n\t *\/\n\treq->flags &= ~REQ_F_HARDLINK;\n\treq->flags |= REQ_F_LINK;\n\tio_req_complete_failed(req, req->result);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":254881,"func":"const std::vector<AccumulationStatement>& DocumentSourceGroup::getAccumulatedFields() const {\n    return _accumulatedFields;\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":387603,"func":"static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol,\n\t\t\t\t struct snd_ctl_elem_value *ucontrol)\n{\n\tstruct user_element *ue = kcontrol->private_data;\n\tunsigned int size = ue->elem_data_size;\n\tchar *src = ue->elem_data +\n\t\t\tsnd_ctl_get_ioff(kcontrol, &ucontrol->id) * size;\n\n\tmemcpy(&ucontrol->value, src, size);\n\treturn 0;\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":328929,"func":"R_API RBinJavaVerificationObj *r_bin_java_read_from_buffer_verification_info_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tut64 offset = 0;\n\tRBinJavaVerificationObj *se = R_NEW0 (RBinJavaVerificationObj);\n\tif (!se) {\n\t\treturn NULL;\n\t}\n\tse->file_offset = buf_offset;\n\tse->tag = buffer[offset];\n\toffset += 1;\n\tif (se->tag == R_BIN_JAVA_STACKMAP_OBJECT) {\n\t\tse->info.obj_val_cp_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t} else if (se->tag == R_BIN_JAVA_STACKMAP_UNINIT) {\n\t\tse->info.uninit_offset = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t}\n\tif (R_BIN_JAVA_STACKMAP_UNINIT < se->tag) {\n\t\tr_bin_java_verification_info_free (se);\n\t\treturn NULL;\n\t}\n\tse->size = offset;\n\treturn se;\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":292237,"func":"inbound_uback (server *serv, const message_tags_data *tags_data)\n{\n\tserv->is_away = FALSE;\n\tserv->reconnect_away = FALSE;\n\tfe_set_away (serv);\n\n\tinbound_set_all_away_status (serv, serv->nick, 0);\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":301357,"func":"static int vfswrap_sys_acl_set_file(vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)\n{\n\treturn sys_acl_set_file(handle, name, acltype, theacl);\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":261767,"func":"njs_function_frame_invoke(njs_vm_t *vm, njs_value_t *retval)\n{\n    njs_native_frame_t  *frame;\n\n    frame = vm->top_frame;\n    frame->retval = retval;\n\n    if (njs_function_object_type(vm, frame->function)\n        == NJS_OBJ_TYPE_ASYNC_FUNCTION)\n    {\n        return njs_async_function_frame_invoke(vm, retval);\n    }\n\n    if (frame->native) {\n        return njs_function_native_call(vm);\n\n    } else {\n        return njs_function_lambda_call(vm, NULL, NULL);\n    }\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":270396,"func":"static bool ok_inflater_distance_tree(ok_inflater *inflater) {\n    bool done = ok_inflater_inflate_huffman_tree(inflater, inflater->distance_huffman,\n                                                 inflater->code_length_huffman,\n                                                 inflater->num_distance_codes);\n    if (done) {\n        inflater->state = OK_INFLATER_STATE_READING_DYNAMIC_COMPRESSED_BLOCK;\n        inflater->huffman_code = -1;\n        return true;\n    } else {\n        return false;\n    }\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":476120,"func":"static int count_ext_prop(struct usb_configuration *c, int interface)\n{\n\tstruct usb_function *f;\n\tint j;\n\n\tf = c->interface[interface];\n\tfor (j = 0; j < f->os_desc_n; ++j) {\n\t\tstruct usb_os_desc *d;\n\n\t\tif (interface != f->os_desc_table[j].if_id)\n\t\t\tcontinue;\n\t\td = f->os_desc_table[j].os_desc;\n\t\tif (d && d->ext_compat_id)\n\t\t\treturn d->ext_prop_count;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":512733,"func":"  Item *build_clone(THD *thd) { return 0; }","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":486829,"func":"static hwaddr gem_get_desc_addr(CadenceGEMState *s, bool tx, int q)\n{\n    hwaddr desc_addr = 0;\n\n    if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) {\n        desc_addr = s->regs[tx ? GEM_TBQPH : GEM_RBQPH];\n    }\n    desc_addr <<= 32;\n    desc_addr |= tx ? s->tx_desc_addr[q] : s->rx_desc_addr[q];\n    return desc_addr;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":506688,"func":"static int set_altname_email(X509 *crt, const char *name)\n{\n    return set_altname(crt, GEN_EMAIL, name, 0);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":353236,"func":"bool SplashAxialPattern::getParameter(double xc, double yc, double *t) {\n  double s;\n\n  xc -= x0;\n  yc -= y0;\n\n  s = (xc * dx + yc * dy) * mul;\n  if (0 <= s && s <= 1) {\n    *t = t0 + dt * s;\n  } else if (s < 0 && shading->getExtend0()) {\n    *t = t0;\n  } else if (s > 1 && shading->getExtend1()) {\n    *t = t1;\n  } else {\n    return false;\n  }\n\n  return true;\n}","target":0,"code_token_length":136,"total_token_length":372,"max_tokens_setting":512}
+{"idx":359599,"func":"bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,\n               enum clear_sort sort, enum bgp_clear_type stype, \n               const char *arg)\n{\n  int ret;\n  struct bgp *bgp;\n\n  \/* BGP structure lookup. *\/\n  if (name)\n    {\n      bgp = bgp_lookup_by_name (name);\n      if (bgp == NULL)\n        {\n          vty_out (vty, \"Can't find BGP view %s%s\", name, VTY_NEWLINE);\n          return CMD_WARNING;\n        }\n    }\n  else\n    {\n      bgp = bgp_get_default ();\n      if (bgp == NULL)\n        {\n          vty_out (vty, \"No BGP process is configured%s\", VTY_NEWLINE);\n          return CMD_WARNING;\n        }\n    }\n\n  ret =  bgp_clear (vty, bgp, afi, safi, sort, stype, arg);\n  if (ret < 0)\n    return CMD_WARNING;\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":237,"total_token_length":473,"max_tokens_setting":512}
+{"idx":238542,"func":"static void coerce_reg_to_size(struct bpf_reg_state *reg, int size)\n{\n\tu64 mask;\n\n\t\/* clear high bits in bit representation *\/\n\treg->var_off = tnum_cast(reg->var_off, size);\n\n\t\/* fix arithmetic bounds *\/\n\tmask = ((u64)1 << (size * 8)) - 1;\n\tif ((reg->umin_value & ~mask) == (reg->umax_value & ~mask)) {\n\t\treg->umin_value &= mask;\n\t\treg->umax_value &= mask;\n\t} else {\n\t\treg->umin_value = 0;\n\t\treg->umax_value = mask;\n\t}\n\treg->smin_value = reg->umin_value;\n\treg->smax_value = reg->umax_value;\n\n\t\/* If size is smaller than 32bit register the 32bit register\n\t * values are also truncated so we push 64-bit bounds into\n\t * 32-bit bounds. Above were truncated < 32-bits already.\n\t *\/\n\tif (size >= 4)\n\t\treturn;\n\t__reg_combine_64_into_32(reg);\n}","target":0,"code_token_length":238,"total_token_length":474,"max_tokens_setting":512}
+{"idx":291840,"func":"static int __init rtrs_client_init(void)\n{\n\trtrs_rdma_dev_pd_init(0, &dev_pd);\n\n\trtrs_clt_dev_class = class_create(THIS_MODULE, \"rtrs-client\");\n\tif (IS_ERR(rtrs_clt_dev_class)) {\n\t\tpr_err(\"Failed to create rtrs-client dev class\\n\");\n\t\treturn PTR_ERR(rtrs_clt_dev_class);\n\t}\n\trtrs_wq = alloc_workqueue(\"rtrs_client_wq\", 0, 0);\n\tif (!rtrs_wq) {\n\t\tclass_destroy(rtrs_clt_dev_class);\n\t\treturn -ENOMEM;\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":384874,"func":"FreeWild(int count, char_u **files)\n{\n    if (count <= 0 || files == NULL)\n\treturn;\n    while (count--)\n\tvim_free(files[count]);\n    vim_free(files);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":359358,"func":"DEFUN (clear_bgp_external_soft_in,\n       clear_bgp_external_soft_in_cmd,\n       \"clear bgp external soft in\",\n       CLEAR_STR\n       BGP_STR\n       \"Clear all external peers\\n\"\n       \"Soft reconfig\\n\"\n       \"Soft reconfig inbound update\\n\")\n{\n  return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,\n\t\t\tBGP_CLEAR_SOFT_IN, NULL);\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":371226,"func":"static inline void fuse_make_bad(struct inode *inode)\n{\n\tremove_inode_hash(inode);\n\tset_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":474084,"func":"cp949_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)\n{\n  return onigenc_mb2_is_code_ctype(enc, code, ctype);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":498085,"func":"void cgit_tag_link(const char *name, const char *title, const char *class,\n\t\t   const char *tag)\n{\n\treporevlink(\"tag\", name, title, class, tag, NULL, NULL);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":439074,"func":"ModuleExport size_t RegisterRLEImage(void)\n{\n  MagickInfo\n    *entry;\n\n  entry=SetMagickInfo(\"RLE\");\n  entry->decoder=(DecodeImageHandler *) ReadRLEImage;\n  entry->magick=(IsImageFormatHandler *) IsRLE;\n  entry->seekable_stream=MagickTrue;\n  entry->adjoin=MagickFalse;\n  entry->description=ConstantString(\"Utah Run length encoded image\");\n  entry->module=ConstantString(\"RLE\");\n  (void) RegisterMagickInfo(entry);\n  return(MagickImageCoderSignature);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":234756,"func":"void btrfs_rm_dev_replace_free_srcdev(struct btrfs_device *srcdev)\n{\n\tstruct btrfs_fs_devices *fs_devices = srcdev->fs_devices;\n\n\tmutex_lock(&uuid_mutex);\n\n\tbtrfs_close_bdev(srcdev);\n\tsynchronize_rcu();\n\tbtrfs_free_device(srcdev);\n\n\t\/* if this is no devs we rather delete the fs_devices *\/\n\tif (!fs_devices->num_devices) {\n\t\t\/*\n\t\t * On a mounted FS, num_devices can't be zero unless it's a\n\t\t * seed. In case of a seed device being replaced, the replace\n\t\t * target added to the sprout FS, so there will be no more\n\t\t * device left under the seed FS.\n\t\t *\/\n\t\tASSERT(fs_devices->seeding);\n\n\t\tlist_del_init(&fs_devices->seed_list);\n\t\tclose_fs_devices(fs_devices);\n\t\tfree_fs_devices(fs_devices);\n\t}\n\tmutex_unlock(&uuid_mutex);\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":521481,"func":"    ZipInputStream (ZipFile& zf, const ZipFile::ZipEntryHolder& zei)\r\n        : file (zf),\r\n          zipEntryHolder (zei),\r\n          inputStream (zf.inputStream)\r\n    {\r\n        if (zf.inputSource != nullptr)\r\n        {\r\n            streamToDelete.reset (file.inputSource->createInputStream());\r\n            inputStream = streamToDelete.get();\r\n        }\r\n        else\r\n        {\r\n           #if JUCE_DEBUG\r\n            zf.streamCounter.numOpenStreams++;\r\n           #endif\r\n        }\r\n\r\n        char buffer[30];\r\n\r\n        if (inputStream != nullptr\r\n             && inputStream->setPosition (zei.streamOffset)\r\n             && inputStream->read (buffer, 30) == 30\r\n             && ByteOrder::littleEndianInt (buffer) == 0x04034b50)\r\n        {\r\n            headerSize = 30 + ByteOrder::littleEndianShort (buffer + 26)\r\n                            + ByteOrder::littleEndianShort (buffer + 28);\r\n        }\r\n    }\r","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":292217,"func":"is_hilight (char *from, char *text, session *sess, server *serv)\n{\n\tif (alert_match_word (from, prefs.hex_irc_no_hilight))\n\t\treturn 0;\n\n\ttext = strip_color (text, -1, STRIP_ALL);\n\n\tif (alert_match_text (text, serv->nick) ||\n\t\t alert_match_text (text, prefs.hex_irc_extra_hilight) ||\n\t\t alert_match_word (from, prefs.hex_irc_nick_hilight))\n\t{\n\t\tg_free (text);\n\t\tif (sess != current_tab)\n\t\t{\n\t\t\tsess->nick_said = TRUE;\n\t\t\tlastact_update (sess);\n\t\t}\n\t\tfe_set_hilight (sess);\n\t\treturn 1;\n\t}\n\n\tg_free (text);\n\treturn 0;\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":238607,"func":"static bool signed_sub32_overflows(s32 a, s32 b)\n{\n\t\/* Do the sub in u32, where overflow is well-defined *\/\n\ts32 res = (s32)((u32)a - (u32)b);\n\n\tif (b < 0)\n\t\treturn res < a;\n\treturn res > a;\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":90872,"func":"  int additional_callback_count() const { return additional_callback_count_; }\n","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":309882,"func":"spush(char *x)\n{\n    if (TPS(stack_ptr) < STACKSIZE) {\n\tTPS(stack)[TPS(stack_ptr)].num_type = FALSE;\n\tTPS(stack)[TPS(stack_ptr)].data.str = x;\n\tTPS(stack_ptr)++;\n    } else {\n\tDEBUG(2, (\"spush: stack overflow: %s\", _nc_visbuf(TPS(tparam_base))));\n\t_nc_tparm_err++;\n    }\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":364758,"func":"taglen_advance(int l)\n{\n    if (l == MAXCOL)\n    {\n\tmsg_putchar('\\n');\n\tmsg_advance(24);\n    }\n    else\n\tmsg_advance(13 + l);\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":281150,"func":"static inline int secpath_has_nontransport(const struct sec_path *sp, int k, int *idxp)\n{\n\tfor (; k < sp->len; k++) {\n\t\tif (sp->xvec[k]->props.mode != XFRM_MODE_TRANSPORT) {\n\t\t\t*idxp = k;\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":516258,"func":"static int peer_attach(VirtIONet *n, int index)\n{\n    NetClientState *nc = qemu_get_subqueue(n->nic, index);\n\n    if (!nc->peer) {\n        return 0;\n    }\n\n    if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) {\n        vhost_set_vring_enable(nc->peer, 1);\n    }\n\n    if (nc->peer->info->type != NET_CLIENT_DRIVER_TAP) {\n        return 0;\n    }\n\n    if (n->max_queues == 1) {\n        return 0;\n    }\n\n    return tap_enable(nc->peer);\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":256987,"func":"route4_reset_fastmap(struct route4_head *head)\n{\n\tspin_lock_bh(&fastmap_lock);\n\tmemset(head->fastmap, 0, sizeof(head->fastmap));\n\tspin_unlock_bh(&fastmap_lock);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":450771,"func":"re_mult_next(char *what)\n{\n    if (re_multi_type(peekchr()) == MULTI_MULT)\n    {\n       semsg(_(\"E888: (NFA regexp) cannot repeat %s\"), what);\n       rc_did_emsg = TRUE;\n       return FAIL;\n    }\n    return OK;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":317371,"func":"static int may_context_mount_inode_relabel(u32 sid,\n\t\t\tstruct superblock_security_struct *sbsec,\n\t\t\tconst struct cred *cred)\n{\n\tconst struct task_security_struct *tsec = selinux_cred(cred);\n\tint rc;\n\trc = avc_has_perm(&selinux_state,\n\t\t\t  tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM,\n\t\t\t  FILESYSTEM__RELABELFROM, NULL);\n\tif (rc)\n\t\treturn rc;\n\n\trc = avc_has_perm(&selinux_state,\n\t\t\t  sid, sbsec->sid, SECCLASS_FILESYSTEM,\n\t\t\t  FILESYSTEM__ASSOCIATE, NULL);\n\treturn rc;\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":262001,"func":"static void *conncache_add_bundle(struct conncache *connc,\n                                  char *key,\n                                  struct connectbundle *bundle)\n{\n  return Curl_hash_add(&connc->hash, key, strlen(key), bundle);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":343237,"func":"void die_mem(void)\n{\n    die(421, LOG_ERR, MSG_OUT_OF_MEMORY);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":195017,"func":"u32 GetHintFormat(GF_TrackBox *trak)\n{\n\tGF_HintMediaHeaderBox *hmhd = (GF_HintMediaHeaderBox *)trak->Media->information->InfoHeader;\n\tif (hmhd->type != GF_ISOM_BOX_TYPE_HMHD)\n\t\treturn 0;\n\t\t\n\tif (!hmhd || !hmhd->subType) {\n\t\tGF_Box *a = (GF_Box *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, 0);\n\t\tif (!hmhd) return a ? a->type : 0;\n\t\tif (a) hmhd->subType = a->type;\n\t\treturn hmhd->subType;\n\t}\n\treturn hmhd->subType;\n}","target":1,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":289299,"func":"static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_file, struct snd_pcm_substream **r_substream)\n{\n\tint idx, err;\n\tstruct snd_pcm_substream *asubstream = NULL, *substream;\n\n\tfor (idx = 0; idx < 2; idx++) {\n\t\tsubstream = pcm_oss_file->streams[idx];\n\t\tif (substream == NULL)\n\t\t\tcontinue;\n\t\tif (asubstream == NULL)\n\t\t\tasubstream = substream;\n\t\tif (substream->runtime->oss.params) {\n\t\t\terr = snd_pcm_oss_change_params(substream, false);\n\t\t\tif (err < 0)\n\t\t\t\treturn err;\n\t\t}\n\t}\n\tif (!asubstream)\n\t\treturn -EIO;\n\tif (r_substream)\n\t\t*r_substream = asubstream;\n\treturn 0;\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":244056,"func":"GF_Box *dfla_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_FLACConfigBox, GF_ISOM_BOX_TYPE_DFLA);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":229182,"func":"static void flush_queued_data_bh(void *opaque)\n{\n    VirtIOSerialPort *port = opaque;\n\n    flush_queued_data(port);\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":521454,"func":"inline uint32 readUnalignedLittleEndianInt (const void* buffer)\r\n{\r\n    auto data = readUnaligned<uint32> (buffer);\r\n    return ByteOrder::littleEndianInt (&data);\r\n}\r","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":432172,"func":"MemoryRegionSection *iotlb_to_section(CPUState *cpu,\n                                      hwaddr index, MemTxAttrs attrs)\n{\n#ifdef TARGET_ARM\n    struct uc_struct *uc = cpu->uc;\n#endif\n    int asidx = cpu_asidx_from_attrs(cpu, attrs);\n    CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx];\n    AddressSpaceDispatch *d = cpuas->memory_dispatch;\n    MemoryRegionSection *sections = d->map.sections;\n\n    return §ions[index & ~TARGET_PAGE_MASK];\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":225875,"func":"GF_Err audio_sample_entry_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_isom_audio_sample_entry_write((GF_AudioSampleEntryBox*)s, bs);\n\treturn GF_OK;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":413685,"func":"static bool opiscall(RCore *core, RAnalOp *aop, ut64 addr, const ut8* buf, int len, int arch) {\n\tswitch (arch) {\n\tcase R2_ARCH_ARM64:\n\t\taop->size = 4;\n\t\t\/\/addr should be aligned by 4 in aarch64\n\t\tif (addr % 4) {\n\t\t\tchar diff = addr % 4;\n\t\t\taddr = addr - diff;\n\t\t\tbuf = buf - diff;\n\t\t}\n\t\t\/\/if is not bl do not analyze\n\t\tif (buf[3] == 0x94) {\n\t\t\tif (r_anal_op (core->anal, aop, addr, buf, len, R_ANAL_OP_MASK_BASIC)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\taop->size = 1;\n\t\tif (r_anal_op (core->anal, aop, addr, buf, len, R_ANAL_OP_MASK_BASIC)) {\n\t\t\tswitch (aop->type & R_ANAL_OP_TYPE_MASK) {\n\t\t\tcase R_ANAL_OP_TYPE_CALL:\n\t\t\tcase R_ANAL_OP_TYPE_CCALL:\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\t}\n\treturn false;\n}","target":0,"code_token_length":265,"total_token_length":501,"max_tokens_setting":512}
+{"idx":404722,"func":"static unsigned long __fget_light(unsigned int fd, fmode_t mask)\n{\n\tstruct files_struct *files = current->files;\n\tstruct file *file;\n\n\tif (atomic_read(&files->count) == 1) {\n\t\tfile = files_lookup_fd_raw(files, fd);\n\t\tif (!file || unlikely(file->f_mode & mask))\n\t\t\treturn 0;\n\t\treturn (unsigned long)file;\n\t} else {\n\t\tfile = __fget(fd, mask, 1);\n\t\tif (!file)\n\t\t\treturn 0;\n\t\treturn FDPUT_FPUT | (unsigned long)file;\n\t}\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":244272,"func":"GF_Err pdin_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\tfor (i=0; i<ptr->count; i++) {\n\t\tgf_bs_write_u32(bs, ptr->rates[i]);\n\t\tgf_bs_write_u32(bs, ptr->times[i]);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":119,"total_token_length":355,"max_tokens_setting":512}
+{"idx":459024,"func":"http_Proto(struct http *to)\n{\n\tconst char *fm;\n\n\tfm = to->hd[HTTP_HDR_PROTO].b;\n\n\tif (fm != NULL &&\n\t    (fm[0] == 'H' || fm[0] == 'h') &&\n\t    (fm[1] == 'T' || fm[1] == 't') &&\n\t    (fm[2] == 'T' || fm[2] == 't') &&\n\t    (fm[3] == 'P' || fm[3] == 'p') &&\n\t    fm[4] == '\/' &&\n\t    vct_isdigit(fm[5]) &&\n\t    fm[6] == '.' &&\n\t    vct_isdigit(fm[7]) &&\n\t    fm[8] == '\\0') {\n\t\tto->protover = 10 * (fm[5] - '0') + (fm[7] - '0');\n\t} else {\n\t\tto->protover = 0;\n\t}\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":221174,"func":"GF_Err gf_odf_delete_descriptor_list(GF_List *descList)\n{\n\tGF_Err e;\n\tGF_Descriptor*tmp;\n\tu32 i;\n\t\/\/no error if NULL chain...\n\tif (! descList) return GF_OK;\n\ti=0;\n\twhile ((tmp = (GF_Descriptor*)gf_list_enum(descList, &i))) {\n\t\te = gf_odf_delete_descriptor(tmp);\n\t\tif (e) return e;\n\t}\n\tgf_list_del(descList);\n\treturn GF_OK;\n}","target":0,"code_token_length":105,"total_token_length":341,"max_tokens_setting":512}
+{"idx":307845,"func":"bool ciEnv::jvmti_state_changed() const {\n  if (!_jvmti_can_access_local_variables &&\n      JvmtiExport::can_access_local_variables()) {\n    return true;\n  }\n  if (!_jvmti_can_hotswap_or_post_breakpoint &&\n      JvmtiExport::can_hotswap_or_post_breakpoint()) {\n    return true;\n  }\n  if (!_jvmti_can_post_on_exceptions &&\n      JvmtiExport::can_post_on_exceptions()) {\n    return true;\n  }\n  if (!_jvmti_can_pop_frame &&\n      JvmtiExport::can_pop_frame()) {\n    return true;\n  }\n  return false;\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":234147,"func":"comp_addr_base (const void * v0, const void * v1)\n{\n  debug_info *info0 = *(debug_info **) v0;\n  debug_info *info1 = *(debug_info **) v1;\n  return info0->addr_base - info1->addr_base;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":275480,"func":"njs_vm_retval(njs_vm_t *vm)\n{\n    return &vm->retval;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":466154,"func":"static void decode_register_operand(struct x86_emulate_ctxt *ctxt,\n\t\t\t\t    struct operand *op,\n\t\t\t\t    int inhibit_bytereg)\n{\n\tunsigned reg = ctxt->modrm_reg;\n\tint highbyte_regs = ctxt->rex_prefix == 0;\n\n\tif (!(ctxt->d & ModRM))\n\t\treg = (ctxt->b & 7) | ((ctxt->rex_prefix & 1) << 3);\n\n\tif (ctxt->d & Sse) {\n\t\top->type = OP_XMM;\n\t\top->bytes = 16;\n\t\top->addr.xmm = reg;\n\t\tread_sse_reg(ctxt, &op->vec_val, reg);\n\t\treturn;\n\t}\n\n\top->type = OP_REG;\n\tif ((ctxt->d & ByteOp) && !inhibit_bytereg) {\n\t\top->addr.reg = decode_register(reg, ctxt->regs, highbyte_regs);\n\t\top->bytes = 1;\n\t} else {\n\t\top->addr.reg = decode_register(reg, ctxt->regs, 0);\n\t\top->bytes = ctxt->op_bytes;\n\t}\n\tfetch_register_operand(op);\n\top->orig_val = op->val;\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":309970,"func":"save_text(const char *fmt, const char *s, int len)\n{\n    size_t s_len = (size_t) len + strlen(s) + strlen(fmt);\n    get_space(s_len + 1);\n\n    _nc_SPRINTF(TPS(out_buff) + TPS(out_used),\n\t\t_nc_SLIMIT(TPS(out_size) - TPS(out_used))\n\t\tfmt, s);\n    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));\n}","target":0,"code_token_length":101,"total_token_length":337,"max_tokens_setting":512}
+{"idx":316991,"func":"static void smack_free_mnt_opts(void *mnt_opts)\n{\n\tstruct smack_mnt_opts *opts = mnt_opts;\n\tkfree(opts->fsdefault);\n\tkfree(opts->fsfloor);\n\tkfree(opts->fshat);\n\tkfree(opts->fsroot);\n\tkfree(opts->fstransmute);\n\tkfree(opts);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":474005,"func":"onig_free_shared_cclass_table(void)\n{\n  THREAD_ATOMIC_START;\n  if (IS_NOT_NULL(OnigTypeCClassTable)) {\n    onig_st_foreach(OnigTypeCClassTable, i_free_shared_class, 0);\n    onig_st_free_table(OnigTypeCClassTable);\n    OnigTypeCClassTable = NULL;\n  }\n  THREAD_ATOMIC_END;\n\n  return 0;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":317248,"func":"static void smk_bu_mode(int mode, char *s)\n{\n\tint i = 0;\n\n\tif (mode & MAY_READ)\n\t\ts[i++] = 'r';\n\tif (mode & MAY_WRITE)\n\t\ts[i++] = 'w';\n\tif (mode & MAY_EXEC)\n\t\ts[i++] = 'x';\n\tif (mode & MAY_APPEND)\n\t\ts[i++] = 'a';\n\tif (mode & MAY_TRANSMUTE)\n\t\ts[i++] = 't';\n\tif (mode & MAY_LOCK)\n\t\ts[i++] = 'l';\n\tif (i == 0)\n\t\ts[i++] = '-';\n\ts[i] = '\\0';\n}","target":0,"code_token_length":134,"total_token_length":370,"max_tokens_setting":512}
+{"idx":336566,"func":"static void reds_migrate_channels_seamless(RedsState *reds)\n{\n    RedClient *client;\n\n    \/* seamless migration is supported for only one client for now *\/\n    client = reds_get_client(reds);\n    client->migrate();\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":247519,"func":"  int expectedVerifyErrorCode() const { return expected_verify_error_code_; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":246746,"func":"static u32 do_write_udp()\n{\n\tGF_Err e;\n\tGF_Socket *sock = gf_sk_new(GF_SOCK_TYPE_UDP);\n\tu16 port = 2345;\n\tchar *sep = strrchr(udp_dest, ':');\n\tif (sep) {\n\t\tsep[0] = 0;\n\t\tport = atoi(sep+1);\n\t}\n\te = gf_sk_bind( sock, \"127.0.0.1\", 0, udp_dest, port, 0);\n\tif (sep) sep[0] = ':';\n\tif (e) {\n\t\tM4_LOG(GF_LOG_ERROR, (\"Failed to bind socket to %s: %s\\n\", udp_dest, gf_error_to_string(e) ));\n\t} else {\n\t\te = gf_sk_send(sock, (u8 *) inName, (u32)strlen(inName));\n\t\tif (e)\n\t\t\tM4_LOG(GF_LOG_ERROR, (\"Failed to send datagram: %s\\n\", gf_error_to_string(e) ));\n\t}\n\tgf_sk_del(sock);\n\treturn 0;\n}","target":0,"code_token_length":231,"total_token_length":467,"max_tokens_setting":512}
+{"idx":353008,"func":"hashIter(\n\tHASH_CONTEXT *HASHcontext,\n\tunsigned char *HASHdigest,\n\tunsigned char *value,\n\tint len)\n{\n\tHASH_CONTEXT ctx = *HASHcontext;\n\tHASH_Update( &ctx, value, len );\n\tHASH_Final( HASHdigest, &ctx );\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":317192,"func":"static int selinux_file_ioctl(struct file *file, unsigned int cmd,\n\t\t\t      unsigned long arg)\n{\n\tconst struct cred *cred = current_cred();\n\tint error = 0;\n\n\tswitch (cmd) {\n\tcase FIONREAD:\n\tcase FIBMAP:\n\tcase FIGETBSZ:\n\tcase FS_IOC_GETFLAGS:\n\tcase FS_IOC_GETVERSION:\n\t\terror = file_has_perm(cred, file, FILE__GETATTR);\n\t\tbreak;\n\n\tcase FS_IOC_SETFLAGS:\n\tcase FS_IOC_SETVERSION:\n\t\terror = file_has_perm(cred, file, FILE__SETATTR);\n\t\tbreak;\n\n\t\/* sys_ioctl() checks *\/\n\tcase FIONBIO:\n\tcase FIOASYNC:\n\t\terror = file_has_perm(cred, file, 0);\n\t\tbreak;\n\n\tcase KDSKBENT:\n\tcase KDSKBSENT:\n\t\terror = cred_has_capability(cred, CAP_SYS_TTY_CONFIG,\n\t\t\t\t\t    CAP_OPT_NONE, true);\n\t\tbreak;\n\n\t\/* default case assumes that the command will go\n\t * to the file's ioctl() function.\n\t *\/\n\tdefault:\n\t\terror = ioctl_has_perm(cred, file, FILE__IOCTL, (u16) cmd);\n\t}\n\treturn error;\n}","target":0,"code_token_length":246,"total_token_length":482,"max_tokens_setting":512}
+{"idx":359311,"func":"DEFUN (no_bgp_redistribute_ipv4_metric,\n       no_bgp_redistribute_ipv4_metric_cmd,\n       \"no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>\",\n       NO_STR\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPF)\\n\"\n       \"Routing Information Protocol (RIP)\\n\"\n       \"Static routes\\n\"\n       \"Metric for redistributed routes\\n\"\n       \"Default metric\\n\")\n{\n  int type;\n\n  type = bgp_str2route_type (AFI_IP, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  bgp_redistribute_metric_unset (vty->index, AFI_IP, type);\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":197057,"func":"int HttpFileImpl::save(const std::string &path) const\n{\n    assert(!path.empty());\n    if (fileName_.empty())\n        return -1;\n    filesystem::path fsPath(utils::toNativePath(path));\n    if (!fsPath.is_absolute() &&\n        (!fsPath.has_parent_path() ||\n         (fsPath.begin()->string() != \".\" && fsPath.begin()->string() != \"..\")))\n    {\n        filesystem::path fsUploadPath(utils::toNativePath(\n            HttpAppFrameworkImpl::instance().getUploadPath()));\n        fsPath = fsUploadPath \/ fsPath;\n    }\n    filesystem::path fsFileName(utils::toNativePath(fileName_));\n    if (!filesystem::exists(fsPath))\n    {\n        LOG_TRACE << \"create path:\" << fsPath;\n        drogon::error_code err;\n        filesystem::create_directories(fsPath, err);\n        if (err)\n        {\n            LOG_SYSERR;\n            return -1;\n        }\n    }\n    return saveTo(fsPath \/ fsFileName);\n}","target":1,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":444909,"func":"mtab_unusable(void)\n{\n\tstruct stat mstat;\n\n\tif(lstat(_PATH_MOUNTED, &mstat))\n\t\treturn errno;\n\telse if (S_ISLNK(mstat.st_mode))\n\t\treturn EMLINK;\n\treturn 0;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":180233,"func":"v8::Handle<v8::Value> V8ThrowException::createReferenceError(v8::Isolate* isolate, const String& message)\n{\n    return v8::Exception::ReferenceError(v8String(isolate, message.isNull() ? \"Reference error\" : message));\n}\n","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":430416,"func":"int ovs_nla_put_mask(const struct sw_flow *flow, struct sk_buff *skb)\n{\n\treturn ovs_nla_put_key(&flow->key, &flow->mask->key,\n\t\t\t\tOVS_FLOW_ATTR_MASK, true, skb);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":359318,"func":"DEFUN (neighbor_timers,\n       neighbor_timers_cmd,\n       NEIGHBOR_CMD2 \"timers <0-65535> <0-65535>\",\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"BGP per neighbor timers\\n\"\n       \"Keepalive interval\\n\"\n       \"Holdtime\\n\")\n{\n  return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":224542,"func":"Status DatasetIteratorShape(shape_inference::InferenceContext* c) {\n  shape_inference::ShapeHandle unused;\n  TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused));\n  std::vector<PartialTensorShape> output_shapes;\n  TF_RETURN_IF_ERROR(c->GetAttr(\"output_shapes\", &output_shapes));\n  const int output_shapes_size = output_shapes.size();\n  if (output_shapes_size != c->num_outputs()) {\n    return errors::InvalidArgument(\n        \"`output_shapes` must be the same length as `output_types` (\",\n        output_shapes.size(), \" vs. \", c->num_outputs());\n  }\n  for (size_t i = 0; i < output_shapes.size(); ++i) {\n    shape_inference::ShapeHandle output_shape_handle;\n    TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(\n        output_shapes[i], &output_shape_handle));\n    c->set_output(static_cast<int>(i), output_shape_handle);\n  }\n  return Status::OK();\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":468354,"func":"g_socket_client_set_tls_validation_flags (GSocketClient        *client,\n\t\t\t\t\t  GTlsCertificateFlags  flags)\n{\n  if (client->priv->tls_validation_flags != flags)\n    {\n      client->priv->tls_validation_flags = flags;\n      g_object_notify (G_OBJECT (client), \"tls-validation-flags\");\n    }\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":318097,"func":"static int usb_ulp_read_write(struct rsi_hw *adapter, u16 addr, u32 data,\n\t\t\t      u16 len_in_bits)\n{\n\tint ret;\n\n\tret = rsi_usb_master_reg_write\n\t\t\t(adapter, RSI_GSPI_DATA_REG1,\n\t\t\t ((addr << 6) | ((data >> 16) & 0xffff)), 2);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tret = rsi_usb_master_reg_write(adapter, RSI_GSPI_DATA_REG0,\n\t\t\t\t       (data & 0xffff), 2);\n\tif (ret < 0)\n\t\treturn ret;\n\n\t\/* Initializing GSPI for ULP read\/writes *\/\n\trsi_usb_master_reg_write(adapter, RSI_GSPI_CTRL_REG0,\n\t\t\t\t RSI_GSPI_CTRL_REG0_VALUE, 2);\n\n\tret = rsi_usb_master_reg_write(adapter, RSI_GSPI_CTRL_REG1,\n\t\t\t\t       ((len_in_bits - 1) | RSI_GSPI_TRIG), 2);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tmsleep(20);\n\n\treturn 0;\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":369284,"func":"static int io_madvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n{\n#if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU)\n\tif (sqe->ioprio || sqe->buf_index || sqe->off || sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\n\treq->madvise.addr = READ_ONCE(sqe->addr);\n\treq->madvise.len = READ_ONCE(sqe->len);\n\treq->madvise.advice = READ_ONCE(sqe->fadvise_advice);\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":366219,"func":"static void *copy_mount_options(const void __user * data)\n{\n\tchar *copy;\n\tunsigned left, offset;\n\n\tif (!data)\n\t\treturn NULL;\n\n\tcopy = kmalloc(PAGE_SIZE, GFP_KERNEL);\n\tif (!copy)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tleft = copy_from_user(copy, data, PAGE_SIZE);\n\n\t\/*\n\t * Not all architectures have an exact copy_from_user(). Resort to\n\t * byte at a time.\n\t *\/\n\toffset = PAGE_SIZE - left;\n\twhile (left) {\n\t\tchar c;\n\t\tif (get_user(c, (const char __user *)data + offset))\n\t\t\tbreak;\n\t\tcopy[offset] = c;\n\t\tleft--;\n\t\toffset++;\n\t}\n\n\tif (left == PAGE_SIZE) {\n\t\tkfree(copy);\n\t\treturn ERR_PTR(-EFAULT);\n\t}\n\n\treturn copy;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":508855,"func":"void LEX::restore_backup_query_tables_list(Query_tables_list *backup)\n{\n  this->destroy_query_tables_list();\n  this->set_query_tables_list(backup);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":263301,"func":"void test_urldecode(const char *v1, const char *v2)\n{\n    char *v = strdup(v1);\n    _q_urldecode(v);\n    ASSERT_EQUAL_STR(v, v2);\n    free(v);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":411907,"func":"router_add_exit_policy(routerinfo_t *router, directory_token_t *tok)\n{\n  addr_policy_t *newe;\n  newe = router_parse_addr_policy(tok);\n  if (!newe)\n    return -1;\n  if (! router->exit_policy)\n    router->exit_policy = smartlist_create();\n\n  if (((tok->tp == K_ACCEPT6 || tok->tp == K_REJECT6) &&\n       tor_addr_family(&newe->addr) == AF_INET)\n      ||\n      ((tok->tp == K_ACCEPT || tok->tp == K_REJECT) &&\n       tor_addr_family(&newe->addr) == AF_INET6)) {\n    log_warn(LD_DIR, \"Mismatch between field type and address type in exit \"\n             \"policy\");\n    addr_policy_free(newe);\n    return -1;\n  }\n\n  smartlist_add(router->exit_policy, newe);\n\n  return 0;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":281122,"func":"static int flow_to_policy_dir(int dir)\n{\n\tif (XFRM_POLICY_IN == FLOW_DIR_IN &&\n\t    XFRM_POLICY_OUT == FLOW_DIR_OUT &&\n\t    XFRM_POLICY_FWD == FLOW_DIR_FWD)\n\t\treturn dir;\n\n\tswitch (dir) {\n\tdefault:\n\tcase FLOW_DIR_IN:\n\t\treturn XFRM_POLICY_IN;\n\tcase FLOW_DIR_OUT:\n\t\treturn XFRM_POLICY_OUT;\n\tcase FLOW_DIR_FWD:\n\t\treturn XFRM_POLICY_FWD;\n\t}\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":310308,"func":"new_cached_dir(char *s, time_t published)\n{\n  cached_dir_t *d = tor_malloc_zero(sizeof(cached_dir_t));\n  d->refcnt = 1;\n  d->dir = s;\n  d->dir_len = strlen(s);\n  d->published = published;\n  if (tor_gzip_compress(&(d->dir_z), &(d->dir_z_len), d->dir, d->dir_len,\n                        ZLIB_METHOD)) {\n    log_warn(LD_BUG, \"Error compressing directory\");\n  }\n  return d;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":484799,"func":"static int netfront_tx_slot_available(struct netfront_queue *queue)\n{\n\treturn (queue->tx.req_prod_pvt - queue->tx.rsp_cons) <\n\t\t(NET_TX_RING_SIZE - XEN_NETIF_NR_SLOTS_MIN - 1);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":336126,"func":"static int __init ip6gre_init(void)\n{\n\tint err;\n\n\tpr_info(\"GRE over IPv6 tunneling driver\\n\");\n\n\terr = register_pernet_device(&ip6gre_net_ops);\n\tif (err < 0)\n\t\treturn err;\n\n\terr = inet6_add_protocol(&ip6gre_protocol, IPPROTO_GRE);\n\tif (err < 0) {\n\t\tpr_info(\"%s: can't add protocol\\n\", __func__);\n\t\tgoto add_proto_failed;\n\t}\n\n\terr = rtnl_link_register(&ip6gre_link_ops);\n\tif (err < 0)\n\t\tgoto rtnl_link_failed;\n\n\terr = rtnl_link_register(&ip6gre_tap_ops);\n\tif (err < 0)\n\t\tgoto tap_ops_failed;\n\nout:\n\treturn err;\n\ntap_ops_failed:\n\trtnl_link_unregister(&ip6gre_link_ops);\nrtnl_link_failed:\n\tinet6_del_protocol(&ip6gre_protocol, IPPROTO_GRE);\nadd_proto_failed:\n\tunregister_pernet_device(&ip6gre_net_ops);\n\tgoto out;\n}","target":0,"code_token_length":211,"total_token_length":447,"max_tokens_setting":512}
+{"idx":508774,"func":"bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,\n                          bool print_error, uint idx, bool reverse)\n{\n  int error= 0;\n  DBUG_ENTER(\"init_read_record_idx\");\n\n  empty_record(table);\n  bzero((char*) info,sizeof(*info));\n  info->thd= thd;\n  info->table= table;\n  info->record= table->record[0];\n  info->print_error= print_error;\n  info->unlock_row= rr_unlock_row;\n\n  table->status=0;\t\t\t\/* And it's always found *\/\n  if (!table->file->inited &&\n      (error= table->file->ha_index_init(idx, 1)))\n  {\n    if (print_error)\n      table->file->print_error(error, MYF(0));\n  }\n\n  \/* read_record will be changed to rr_index in rr_index_first *\/\n  info->read_record= reverse ? rr_index_last : rr_index_first;\n  DBUG_RETURN(error != 0);\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":221075,"func":"OpTypeConstructor UnaryGeneric(FullTypeId t) {\n  return [t](OpDef* op_def) {\n    FullTypeDef* tdef =\n        op_def->mutable_output_arg(0)->mutable_experimental_full_type();\n    tdef->set_type_id(t);\n\n    FullTypeDef* arg = tdef->add_args();\n    arg->set_type_id(TFT_ANY);\n\n    return Status::OK();\n  };\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":206025,"func":"gpg_ctx_add_recipient (struct _GpgCtx *gpg,\n                       const gchar *keyid)\n{\n\tif (gpg->mode != GPG_CTX_MODE_ENCRYPT && gpg->mode != GPG_CTX_MODE_EXPORT)\n\t\treturn;\n\n\tif (!gpg->recipients)\n\t\tgpg->recipients = g_ptr_array_new ();\n\n\tg_ptr_array_add (gpg->recipients, g_strdup (keyid));\n}","target":1,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":244253,"func":"GF_Err lsr1_box_size(GF_Box *s)\n{\n\tu32 pos=0;\n\tGF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox *)s;\n\ts->size += 8;\n\tgf_isom_check_position(s, (GF_Box *)ptr->lsr_config, &pos);\n\treturn GF_OK;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":90856,"func":"  void GetLRUOrigin(StorageType type) {\n    lru_origin_ = GURL();\n    quota_manager_->GetLRUOrigin(type,\n        callback_factory_.NewCallback(&QuotaManagerTest::DidGetLRUOrigin));\n  }\n","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":175784,"func":"  const QuotaTableEntries& quota_entries() const { return quota_entries_; }\n","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":359269,"func":"DEFUN (no_router_bgp,\n       no_router_bgp_cmd,\n       \"no router bgp <1-65535>\",\n       NO_STR\n       ROUTER_STR\n       BGP_STR\n       AS_STR)\n{\n  as_t as;\n  struct bgp *bgp;\n  const char *name = NULL;\n\n  VTY_GET_INTEGER_RANGE (\"AS\", as, argv[0], 1, 65535);\n\n  if (argc == 2)\n    name = argv[1];\n\n  \/* Lookup bgp structure. *\/\n  bgp = bgp_lookup (as, name);\n  if (! bgp)\n    {\n      vty_out (vty, \"%% Can't find BGP instance%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  bgp_delete (bgp);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":182,"total_token_length":418,"max_tokens_setting":512}
+{"idx":248314,"func":"DLLIMPORT const char *cfg_opt_getstr(cfg_opt_t *opt)\n{\n\treturn cfg_opt_getnstr(opt, 0);\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":225087,"func":"Status CheckOpDeprecation(const OpDef& op_def, int graph_def_version) {\n  if (op_def.has_deprecation()) {\n    const OpDeprecation& dep = op_def.deprecation();\n    if (graph_def_version >= dep.version()) {\n      return errors::Unimplemented(\n          \"Op \", op_def.name(), \" is not available in GraphDef version \",\n          graph_def_version, \". It has been removed in version \", dep.version(),\n          \". \", dep.explanation(), \".\");\n    } else {\n      \/\/ Warn only once for each op name, and do it in a threadsafe manner.\n      static mutex mu(LINKER_INITIALIZED);\n      static std::unordered_set<string> warned;\n      bool warn;\n      {\n        mutex_lock lock(mu);\n        warn = warned.insert(op_def.name()).second;\n      }\n      if (warn) {\n        LOG(WARNING) << \"Op \" << op_def.name() << \" is deprecated.\"\n                     << \" It will cease to work in GraphDef version \"\n                     << dep.version() << \". \" << dep.explanation() << \".\";\n      }\n    }\n  }\n  return Status::OK();\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":289266,"func":"static int _snd_pcm_hw_param_setinteger(struct snd_pcm_hw_params *params,\n\t\t\t\t\tsnd_pcm_hw_param_t var)\n{\n\tint changed;\n\tchanged = snd_interval_setinteger(hw_param_interval(params, var));\n\tif (changed > 0) {\n\t\tparams->cmask |= 1 << var;\n\t\tparams->rmask |= 1 << var;\n\t}\n\treturn changed;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":294655,"func":"dt_lite_jisx0301(int argc, VALUE *argv, VALUE self)\n{\n    long n = 0;\n\n    rb_check_arity(argc, 0, 1);\n    if (argc >= 1)\n\tn = NUM2LONG(argv[0]);\n\n    return rb_str_append(d_lite_jisx0301(self),\n\t\t\t iso8601_timediv(self, n));\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":232319,"func":"\nstatic GF_Err gf_isom_full_box_read(GF_Box *ptr, GF_BitStream *bs)\n{\n\tif (ptr->registry->max_version_plus_one) {\n\t\tGF_FullBox *self = (GF_FullBox *) ptr;\n\t\tISOM_DECREASE_SIZE(ptr, 4)\n\t\tself->version = gf_bs_read_u8(bs);\n\t\tself->flags = gf_bs_read_u24(bs);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":369109,"func":"\nstatic int io_async_cancel_prep(struct io_kiocb *req,\n\t\t\t\tconst struct io_uring_sqe *sqe)\n{\n\tif (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))\n\t\treturn -EINVAL;\n\tif (unlikely(req->flags & (REQ_F_FIXED_FILE | REQ_F_BUFFER_SELECT)))\n\t\treturn -EINVAL;\n\tif (sqe->ioprio || sqe->off || sqe->len || sqe->cancel_flags ||\n\t    sqe->splice_fd_in)\n\t\treturn -EINVAL;\n\n\treq->cancel.addr = READ_ONCE(sqe->addr);\n\treturn 0;","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":293550,"func":"PJ_DEF(void) pj_cis_add_alpha(pj_cis_t *cis)\n{\n    pj_cis_add_range( cis, 'a', 'z'+1);\n    pj_cis_add_range( cis, 'A', 'Z'+1);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":309916,"func":"lookup_user_capability(const char *name)\n{\n    struct user_table_entry const *result = 0;\n    if (*name != 'k') {\n\tresult = _nc_find_user_entry(name);\n    }\n    return result;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":231015,"func":"    BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,\r\n                                    QueueSetHandle_t xQueueSet )\r\n    {\r\n        BaseType_t xReturn;\r\n        Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore;\r\n\r\n        if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r\n        {\r\n            \/* The queue was not a member of the set. *\/\r\n            xReturn = pdFAIL;\r\n        }\r\n        else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 )\r\n        {\r\n            \/* It is dangerous to remove a queue from a set when the queue is\r\n             * not empty because the queue set will still hold pending events for\r\n             * the queue. *\/\r\n            xReturn = pdFAIL;\r\n        }\r\n        else\r\n        {\r\n            taskENTER_CRITICAL();\r\n            {\r\n                \/* The queue is no longer contained in the set. *\/\r\n                pxQueueOrSemaphore->pxQueueSetContainer = NULL;\r\n            }\r\n            taskEXIT_CRITICAL();\r\n            xReturn = pdPASS;\r\n        }\r\n\r\n        return xReturn;\r\n    } \/*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. *\/\r","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":234199,"func":"init_dwarf_regnames_riscv (void)\n{\n  dwarf_regnames = NULL;\n  dwarf_regnames_count = 8192;\n  dwarf_regnames_lookup_func = regname_internal_riscv;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":225768,"func":"\nGF_Err mhap_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_Err e;\n\tGF_MHACompatibleProfilesBox *ptr = (GF_MHACompatibleProfilesBox *) s;\n\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u8(bs, ptr->num_profiles);\n\tfor (i=0; i<ptr->num_profiles; i++) {\n\t\tgf_bs_write_u8(bs, ptr->compat_profiles[i]);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":120,"total_token_length":356,"max_tokens_setting":512}
+{"idx":318973,"func":"test_gui_tabmenu_event(dict_T *args UNUSED)\n{\n#  ifdef FEAT_GUI_TABLINE\n    int\ttabnr;\n    int\titem;\n\n    if (dict_find(args, (char_u *)\"tabnr\", -1) == NULL\n\t    || dict_find(args, (char_u *)\"item\", -1) == NULL)\n\treturn FALSE;\n\n    tabnr = (int)dict_get_number(args, (char_u *)\"tabnr\");\n    item = (int)dict_get_number(args, (char_u *)\"item\");\n\n    send_tabline_menu_event(tabnr, item);\n#  endif\n    return TRUE;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":139231,"func":"bool OverlayWindowViews::IsActive() const {\n  return views::Widget::IsActive();\n}\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":508803,"func":"void LEX::free_arena_for_set_stmt()\n{\n  DBUG_ENTER(\"LEX::free_arena_for_set_stmt\");\n  if (!arena_for_set_stmt)\n    return;\n  DBUG_PRINT(\"info\", (\"mem_root: %p  arena: %p\",\n                      arena_for_set_stmt->mem_root,\n                      arena_for_set_stmt));\n  arena_for_set_stmt->free_items();\n  delete(arena_for_set_stmt);\n  free_root(mem_root_for_set_stmt, MYF(MY_KEEP_PREALLOC));\n  arena_for_set_stmt= 0;\n  DBUG_VOID_RETURN;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":220857,"func":"inline int SubscriptToIndex(const NdArrayDesc<8>& desc, int indexes[8]) {\n  return indexes[0] * desc.strides[0] + indexes[1] * desc.strides[1] +\n         indexes[2] * desc.strides[2] + indexes[3] * desc.strides[3] +\n         indexes[4] * desc.strides[4] + indexes[5] * desc.strides[5] +\n         indexes[6] * desc.strides[6] + indexes[7] * desc.strides[7];\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":430394,"func":"void ovs_match_init(struct sw_flow_match *match,\n\t\t    struct sw_flow_key *key,\n\t\t    bool reset_key,\n\t\t    struct sw_flow_mask *mask)\n{\n\tmemset(match, 0, sizeof(*match));\n\tmatch->key = key;\n\tmatch->mask = mask;\n\n\tif (reset_key)\n\t\tmemset(key, 0, sizeof(*key));\n\n\tif (mask) {\n\t\tmemset(&mask->key, 0, sizeof(mask->key));\n\t\tmask->range.start = mask->range.end = 0;\n\t}\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":512242,"func":"  Item_cache_str(THD *thd, const Item *item):\n    Item_cache(thd, item->type_handler()), value(0),\n    is_varbinary(item->type() == FIELD_ITEM &&\n                 Item_cache_str::field_type() == MYSQL_TYPE_VARCHAR &&\n                 !((const Item_field *) item)->field->has_charset())\n  {\n    collation.set(const_cast<DTCollation&>(item->collation));\n  }","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":409424,"func":"set_color_count(int nr)\n{\n    char_u\tnr_colors[20];\t\t\/\/ string for number of colors\n\n    t_colors = nr;\n    if (t_colors > 1)\n\tsprintf((char *)nr_colors, \"%d\", t_colors);\n    else\n\t*nr_colors = NUL;\n    set_string_option_direct((char_u *)\"t_Co\", -1, nr_colors, OPT_FREE, 0);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":474452,"func":"ObjectGetNameAlg(\n\t\t OBJECT          *object         \/\/ IN: handle of the object\n\t\t )\n{\n    return object->publicArea.nameAlg;\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":231533,"func":"send_fd (const int sock, const int fd)\n{\n  struct msghdr msg = {0};\n  union\n    {\n      struct cmsghdr hdr;\n      char buf[CMSG_SPACE (sizeof (int))];\n    } cmsgbuf = {0};\n  struct cmsghdr *cmsg;\n  struct iovec vec;\n  char ch = 'A';\n  ssize_t n;\n\n  msg.msg_control = &cmsgbuf.buf;\n  msg.msg_controllen = sizeof (cmsgbuf.buf);\n\n  cmsg = CMSG_FIRSTHDR (&msg);\n  cmsg->cmsg_len = CMSG_LEN (sizeof (int));\n  cmsg->cmsg_level = SOL_SOCKET;\n  cmsg->cmsg_type = SCM_RIGHTS;\n  memcpy (CMSG_DATA (cmsg), &fd, sizeof (fd));\n\n  vec.iov_base = &ch;\n  vec.iov_len = 1;\n  msg.msg_iov = &vec;\n  msg.msg_iovlen = 1;\n\n  while ((n = sendmsg (sock, &msg, 0)) == -1 && errno == EINTR);\n\n  TEST_VERIFY_EXIT (n == 1);\n}","target":0,"code_token_length":247,"total_token_length":483,"max_tokens_setting":512}
+{"idx":275972,"func":"int uECC_sign(const uint8_t *private_key,\n              const uint8_t *message_hash,\n              unsigned hash_size,\n              uint8_t *signature,\n              uECC_Curve curve) {\n    uECC_word_t k[uECC_MAX_WORDS];\n    uECC_word_t tries;\n\n    for (tries = 0; tries < uECC_RNG_MAX_TRIES; ++tries) {\n        if (!uECC_generate_random_int(k, curve->n, BITS_TO_WORDS(curve->num_n_bits))) {\n            return 0;\n        }\n\n        if (uECC_sign_with_k(private_key, message_hash, hash_size, k, signature, curve)) {\n            return 1;\n        }\n    }\n    return 0;\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":273874,"func":"static void handle_NLST(ctrl_t *ctrl, char *arg)\n{\n\tlist(ctrl, arg, 1);\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":512788,"func":"  longlong val_int()\n  {\n    return longlong_from_hex_hybrid(str_value.ptr(), str_value.length());\n  }","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":261958,"func":"njs_string_base64(njs_vm_t *vm, njs_value_t *value, const njs_str_t *src)\n{\n    size_t     length;\n    njs_str_t  dst;\n\n    length = njs_encode_base64_length(src, &dst.length);\n\n    if (njs_slow_path(dst.length == 0)) {\n        vm->retval = njs_string_empty;\n        return NJS_OK;\n    }\n\n    dst.start = njs_string_alloc(vm, value, dst.length, length);\n    if (njs_slow_path(dst.start == NULL)) {\n        return NJS_ERROR;\n    }\n\n    njs_encode_base64(&dst, src);\n\n    return NJS_OK;\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":393479,"func":"static SQInteger base_setroottable(HSQUIRRELVM v)\n{\n    SQObjectPtr o = v->_roottable;\n    if(SQ_FAILED(sq_setroottable(v))) return SQ_ERROR;\n    v->Push(o);\n    return 1;\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":294665,"func":"date_s_test_all(VALUE klass)\n{\n    if (date_s_test_civil(klass) == Qfalse)\n\treturn Qfalse;\n    if (date_s_test_ordinal(klass) == Qfalse)\n\treturn Qfalse;\n    if (date_s_test_commercial(klass) == Qfalse)\n\treturn Qfalse;\n    if (date_s_test_weeknum(klass) == Qfalse)\n\treturn Qfalse;\n    if (date_s_test_nth_kday(klass) == Qfalse)\n\treturn Qfalse;\n    if (date_s_test_unit_conv(klass) == Qfalse)\n\treturn Qfalse;\n    return Qtrue;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":273411,"func":"  Tensor UnalignedSlice(const Tensor& t, int pos) const {\n    Tensor res;\n    \/\/ CHECK should never fail here, since the number of elements must match\n    CHECK(res.CopyFrom(t.Slice(pos, pos + 1), {t.dim_size(1), t.dim_size(2)}));\n    return res;\n  }","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":359287,"func":"zebra_route_char(u_int zroute)\n{\n  return zroute_lookup(zroute)->chr;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":383375,"func":"gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a)\n{\n  int i;\n  if (im->trueColor)\n    {\n      return gdTrueColorAlpha (r, g, b, a);\n    }\n  for (i = 0; (i < (im->colorsTotal)); i++)\n    {\n      if (im->open[i])\n\t{\n\t  continue;\n\t}\n      if ((im->red[i] == r) &&\n\t  (im->green[i] == g) &&\n\t  (im->blue[i] == b) &&\n\t  (im->alpha[i] == a))\n\t{\n\t  return i;\n\t}\n    }\n  return -1;\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":221481,"func":"add_exports (GPtrArray        *env_array,\n             const ExportData *exports,\n             gsize             n_exports)\n{\n  int i;\n\n  for (i = 0; i < n_exports; i++)\n    {\n      if (exports[i].val)\n        g_ptr_array_add (env_array, g_strdup_printf (\"%s=%s\", exports[i].env, exports[i].val));\n    }\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":294494,"func":"valid_civil_p(VALUE y, int m, int d, double sg,\n\t      VALUE *nth, int *ry,\n\t      int *rm, int *rd, int *rjd,\n\t      int *ns)\n{\n    double style = guess_style(y, sg);\n    int r;\n\n    if (style == 0) {\n\tint jd;\n\n\tr = c_valid_civil_p(FIX2INT(y), m, d, sg, rm, rd, &jd, ns);\n\tif (!r)\n\t    return 0;\n\tdecode_jd(INT2FIX(jd), nth, rjd);\n\tif (f_zero_p(*nth))\n\t    *ry = FIX2INT(y);\n\telse {\n\t    VALUE nth2;\n\t    decode_year(y, *ns ? -1 : +1, &nth2, ry);\n\t}\n    }\n    else {\n\tdecode_year(y, style, nth, ry);\n\tif (style < 0)\n\t    r = c_valid_gregorian_p(*ry, m, d, rm, rd);\n\telse\n\t    r = c_valid_julian_p(*ry, m, d, rm, rd);\n\tif (!r)\n\t    return 0;\n\tc_civil_to_jd(*ry, *rm, *rd, style, rjd, ns);\n    }\n    return r;\n}","target":0,"code_token_length":272,"total_token_length":508,"max_tokens_setting":512}
+{"idx":301431,"func":"static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)\n{\n\treturn fgetxattr(fsp->fh->fd, name, value, size);\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":221654,"func":"bool Socket::readyForOutput()\n{\n    \/\/if (!isssl) {\n        return BaseSocket::readyForOutput();\n    \/\/}\n\n    \/\/cant do this on a blocking ssl socket as far as i can work out\n\n    \/\/return true;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":317225,"func":"static int smack_watch_key(struct key *key)\n{\n\tstruct smk_audit_info ad;\n\tstruct smack_known *tkp = smk_of_current();\n\tint rc;\n\n\tif (key == NULL)\n\t\treturn -EINVAL;\n\t\/*\n\t * If the key hasn't been initialized give it access so that\n\t * it may do so.\n\t *\/\n\tif (key->security == NULL)\n\t\treturn 0;\n\t\/*\n\t * This should not occur\n\t *\/\n\tif (tkp == NULL)\n\t\treturn -EACCES;\n\n\tif (smack_privileged_cred(CAP_MAC_OVERRIDE, current_cred()))\n\t\treturn 0;\n\n#ifdef CONFIG_AUDIT\n\tsmk_ad_init(&ad, __func__, LSM_AUDIT_DATA_KEY);\n\tad.a.u.key_struct.key = key->serial;\n\tad.a.u.key_struct.key_desc = key->description;\n#endif\n\trc = smk_access(tkp, key->security, MAY_READ, &ad);\n\trc = smk_bu_note(\"key watch\", tkp, key->security, MAY_READ, rc);\n\treturn rc;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":369240,"func":"static void io_req_complete_failed(struct io_kiocb *req, s32 res)\n{\n\treq_set_fail(req);\n\tio_req_complete_post(req, res, io_put_kbuf(req, IO_URING_F_UNLOCKED));\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":344803,"func":"strcmp_maybe_null(const char *a, const char *b)\n{\n\tif ((a == NULL && b != NULL) || (a != NULL && b == NULL))\n\t\treturn 0;\n\tif (a != NULL && strcmp(a, b) != 0)\n\t\treturn 0;\n\treturn 1;\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":226040,"func":"\nGF_Err fpar_box_size(GF_Box *s)\n{\n\tFilePartitionBox *ptr = (FilePartitionBox *)s;\n\n\tptr->size += 13 + (ptr->version ? 8 : 4);\n\tif (ptr->scheme_specific_info)\n\t\tptr->size += strlen(ptr->scheme_specific_info);\n\n\tptr->size+= ptr->nb_entries * 6;\n\treturn GF_OK;","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":458920,"func":"find_start_comment(int ind_maxcomment)\t\/\/ XXX\n{\n    pos_T\t*pos;\n    char_u\t*line;\n    char_u\t*p;\n    int\t\tcur_maxcomment = ind_maxcomment;\n\n    for (;;)\n    {\n\tpos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment);\n\tif (pos == NULL)\n\t    break;\n\n\t\/\/ Check if the comment start we found is inside a string.\n\t\/\/ If it is then restrict the search to below this line and try again.\n\tline = ml_get(pos->lnum);\n\tfor (p = line; *p && (colnr_T)(p - line) < pos->col; ++p)\n\t    p = skip_string(p);\n\tif ((colnr_T)(p - line) <= pos->col)\n\t    break;\n\tcur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1;\n\tif (cur_maxcomment <= 0)\n\t{\n\t    pos = NULL;\n\t    break;\n\t}\n    }\n    return pos;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":486806,"func":"static inline uint64_t tx_desc_get_buffer(CadenceGEMState *s, uint32_t *desc)\n{\n    uint64_t ret = desc[0];\n\n    if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) {\n        ret |= (uint64_t)desc[2] << 32;\n    }\n    return ret;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":430400,"func":"static struct sw_flow_actions *nla_alloc_flow_actions(int size)\n{\n\tstruct sw_flow_actions *sfa;\n\n\tWARN_ON_ONCE(size > MAX_ACTIONS_BUFSIZE);\n\n\tsfa = kmalloc(sizeof(*sfa) + size, GFP_KERNEL);\n\tif (!sfa)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tsfa->actions_len = 0;\n\treturn sfa;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":247352,"func":"unsigned int pgpDigParamsAlgo(pgpDigParams digp, unsigned int algotype)\n{\n    unsigned int algo = 0; \/* assume failure *\/\n    if (digp) {\n\tswitch (algotype) {\n\tcase PGPVAL_PUBKEYALGO:\n\t    algo = digp->pubkey_algo;\n\t    break;\n\tcase PGPVAL_HASHALGO:\n\t    algo = digp->hash_algo;\n\t    break;\n\t}\n    }\n    return algo;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":301407,"func":"static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence)\n{\n\toff_t result = 0;\n\n\tSTART_PROFILE(syscall_lseek);\n\n\t\/* Cope with 'stat' file opens. *\/\n\tif (fsp->fh->fd != -1)\n\t\tresult = lseek(fsp->fh->fd, offset, whence);\n\n\t\/*\n\t * We want to maintain the fiction that we can seek\n\t * on a fifo for file system purposes. This allows\n\t * people to set up UNIX fifo's that feed data to Windows\n\t * applications. JRA.\n\t *\/\n\n\tif((result == -1) && (errno == ESPIPE)) {\n\t\tresult = 0;\n\t\terrno = 0;\n\t}\n\n\tEND_PROFILE(syscall_lseek);\n\treturn result;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":234782,"func":"static int chunk_usage_filter(struct btrfs_fs_info *fs_info,\n\t\tu64 chunk_offset, struct btrfs_balance_args *bargs)\n{\n\tstruct btrfs_block_group *cache;\n\tu64 chunk_used, user_thresh;\n\tint ret = 1;\n\n\tcache = btrfs_lookup_block_group(fs_info, chunk_offset);\n\tchunk_used = cache->used;\n\n\tif (bargs->usage_min == 0)\n\t\tuser_thresh = 1;\n\telse if (bargs->usage > 100)\n\t\tuser_thresh = cache->length;\n\telse\n\t\tuser_thresh = div_factor_fine(cache->length, bargs->usage);\n\n\tif (chunk_used < user_thresh)\n\t\tret = 0;\n\n\tbtrfs_put_block_group(cache);\n\treturn ret;\n}","target":0,"code_token_length":158,"total_token_length":394,"max_tokens_setting":512}
+{"idx":256421,"func":"PJ_DEF(pj_status_t) pjmedia_rtcp_enable_xr( pjmedia_rtcp_session *sess, \n\t\t\t\t\t    pj_bool_t enable)\n{\n#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)\n\n    \/* Check if request won't change anything *\/\n    if (!(enable ^ sess->xr_enabled))\n\treturn PJ_SUCCESS;\n\n    if (!enable) {\n\tsess->xr_enabled = PJ_FALSE;\n\treturn PJ_SUCCESS;\n    }\n\n    pjmedia_rtcp_xr_init(&sess->xr_session, sess, 0, 1);\n    sess->xr_enabled = PJ_TRUE;\n\n    return PJ_SUCCESS;\n\n#else\n\n    PJ_UNUSED_ARG(sess);\n    PJ_UNUSED_ARG(enable);\n    return PJ_ENOTSUP;\n\n#endif\n}","target":0,"code_token_length":160,"total_token_length":396,"max_tokens_setting":512}
+{"idx":317238,"func":"static int parse_sid(struct super_block *sb, const char *s, u32 *sid)\n{\n\tint rc = security_context_str_to_sid(&selinux_state, s,\n\t\t\t\t\t     sid, GFP_KERNEL);\n\tif (rc)\n\t\tpr_warn(\"SELinux: security_context_str_to_sid\"\n\t\t       \"(%s) failed for (dev %s, type %s) errno=%d\\n\",\n\t\t       s, sb->s_id, sb->s_type->name, rc);\n\treturn rc;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":500657,"func":"int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload){\n  int size;\n\n  if (buffer_prepend_data(payload, &type, sizeof(uint8_t)) < 0) {\n    ssh_set_error_oom(sftp->session);\n    return -1;\n  }\n\n  size = htonl(buffer_get_rest_len(payload));\n  if (buffer_prepend_data(payload, &size, sizeof(uint32_t)) < 0) {\n    ssh_set_error_oom(sftp->session);\n    return -1;\n  }\n\n  size = ssh_channel_write(sftp->channel, buffer_get_rest(payload),\n      buffer_get_rest_len(payload));\n  if (size < 0) {\n    return -1;\n  } else if((uint32_t) size != buffer_get_rest_len(payload)) {\n    ssh_log(sftp->session, SSH_LOG_PACKET,\n        \"Had to write %d bytes, wrote only %d\",\n        buffer_get_rest_len(payload),\n        size);\n  }\n\n  return size;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":90158,"func":"bool WifiNetwork::IsCertificateLoaded() const {\n  static const std::string settings_string(\"SETTINGS:\");\n  static const std::string pkcs11_key(\"key_id\");\n  if (cert_path_.find(settings_string) == 0) {\n    std::string::size_type idx = cert_path_.find(pkcs11_key);\n    if (idx != std::string::npos)\n      idx = cert_path_.find_first_not_of(kWhitespaceASCII,\n                                         idx + pkcs11_key.length());\n    if (idx != std::string::npos && cert_path_[idx] == '=')\n      return true;\n  }\n  return false;\n}\n","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":390610,"func":"XkbClientGone(pointer data,XID id)\n{\n    DevicePtr\tpXDev = (DevicePtr)data;\n\n    if (!XkbRemoveResourceClient(pXDev,id)) {\n\tErrorF(\"[xkb] Internal Error! bad RemoveResourceClient in XkbClientGone\\n\");\n    }\n    return 1;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":349279,"func":"static void read_block_list(unsigned int *block_list, long long start,\n\t\t\t\t\tunsigned int offset, int blocks)\n{\n\tint res;\n\n\tTRACE(\"read_block_list: blocks %d\\n\", blocks);\n\n\tres = read_inode_data(block_list, &start, &offset, blocks * sizeof(unsigned int));\n\tif(res == FALSE)\n\t\tEXIT_UNSQUASH(\"read_block_list: failed to read \"\n\t\t\t\"inode index %lld:%d\\n\", start, offset);\n\n\tSQUASHFS_INSWAP_INTS(block_list, blocks);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":267964,"func":"R_API RBinField *r_bin_file_add_field(RBinFile *binfile, const char *classname, const char *name) {\n\t\/\/TODO: add_field into class\n\t\/\/eprintf (\"TODO add field: %s \\n\", name);\n\treturn NULL;\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":503853,"func":"SCM_DEFINE (scm_system_file_name_convention,\n            \"system-file-name-convention\", 0, 0, 0, (void),\n\t    \"Return either @code{posix} or @code{windows}, depending on\\n\"\n            \"what kind of system this Guile is running on.\")\n#define FUNC_NAME s_scm_system_file_name_convention\n{\n  return sym_file_name_convention;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":436148,"func":"static int io_accept(struct io_kiocb *req, unsigned int issue_flags)\n{\n\tstruct io_accept *accept = &req->accept;\n\tbool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;\n\tunsigned int file_flags = force_nonblock ? O_NONBLOCK : 0;\n\tint ret;\n\n\tif (req->file->f_flags & O_NONBLOCK)\n\t\treq->flags |= REQ_F_NOWAIT;\n\n\tret = __sys_accept4_file(req->file, file_flags, accept->addr,\n\t\t\t\t\taccept->addr_len, accept->flags,\n\t\t\t\t\taccept->nofile);\n\tif (ret == -EAGAIN && force_nonblock)\n\t\treturn -EAGAIN;\n\tif (ret < 0) {\n\t\tif (ret == -ERESTARTSYS)\n\t\t\tret = -EINTR;\n\t\treq_set_fail(req);\n\t}\n\t__io_req_complete(req, issue_flags, ret, 0);\n\treturn 0;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":343213,"func":"static int generic_aton(const char *src, struct sockaddr_storage *a)\n{\n    if (inet_pton(AF_INET6, src, &STORAGE_SIN_ADDR6(*a)) > 0) {\n        STORAGE_FAMILY(*a) = AF_INET6;\n        return 0;\n    }\n    if (inet_pton(AF_INET, src, &STORAGE_SIN_ADDR(*a)) > 0) {\n        STORAGE_FAMILY(*a) = AF_INET;\n        return 0;\n    }\n    memset(a, 0, sizeof *a);\n\n    return -1;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":225672,"func":"GF_Err gnra_box_size(GF_Box *s)\n{\n\tGF_GenericAudioSampleEntryBox *ptr = (GF_GenericAudioSampleEntryBox *)s;\n\ts->type = GF_ISOM_BOX_TYPE_GNRA;\n\tgf_isom_audio_sample_entry_size((GF_AudioSampleEntryBox *)s);\n\tptr->size += ptr->data_size;\n\treturn GF_OK;\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":402661,"func":"handle_sign_detached(context *ctx, struct pollfd *pollfd, socklen_t size)\n{\n\thandle_sign_helper(ctx, pollfd, size, 0, false);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":317333,"func":"static int __init enforcing_setup(char *str)\n{\n\tunsigned long enforcing;\n\tif (!kstrtoul(str, 0, &enforcing))\n\t\tselinux_enforcing_boot = enforcing ? 1 : 0;\n\treturn 1;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":202600,"func":"append_command(char_u *cmd)\n{\n    char_u *s = cmd;\n    char_u *d;\n\n    STRCAT(IObuff, \": \");\n    d = IObuff + STRLEN(IObuff);\n    while (*s != NUL && d - IObuff < IOSIZE - 7)\n    {\n\tif (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0)\n\t{\n\t    s += enc_utf8 ? 2 : 1;\n\t    STRCPY(d, \"<a0>\");\n\t    d += 4;\n\t}\n\telse\n\t    MB_COPY_CHAR(s, d);\n    }\n    *d = NUL;\n}","target":1,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":228449,"func":"String WddxPacket::wrapValue(const String& start,\n                             const String& end,\n                             const String& varValue,\n                             const String& varName,\n                             bool hasVarTag) {\n  StringBuffer valueStr;\n\n  if (hasVarTag) {\n    valueStr.append(\"<var name='\");\n    valueStr.append(varName);\n    valueStr.append(\"'>\");\n  }\n\n  valueStr.append(start);\n  valueStr.append(varValue);\n  valueStr.append(end);\n\n  if (hasVarTag) {\n    valueStr.append(\"<\/var>\");\n  }\n\n  return valueStr.detach();\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":400730,"func":"void iov_iter_kvec(struct iov_iter *i, unsigned int direction,\n\t\t\tconst struct kvec *kvec, unsigned long nr_segs,\n\t\t\tsize_t count)\n{\n\tWARN_ON(direction & ~(READ | WRITE));\n\t*i = (struct iov_iter){\n\t\t.iter_type = ITER_KVEC,\n\t\t.data_source = direction,\n\t\t.kvec = kvec,\n\t\t.nr_segs = nr_segs,\n\t\t.iov_offset = 0,\n\t\t.count = count\n\t};\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":376344,"func":"gpg_ctx_set_userid (struct _GpgCtx *gpg,\n                    const gchar *userid)\n{\n\tg_slist_free_full (gpg->userids, g_free);\n\tgpg->userids = NULL;\n\n\tif (userid && *userid) {\n\t\tgchar **uids = g_strsplit (userid, \" \", -1);\n\n\t\tif (!uids) {\n\t\t\tgpg->userids = g_slist_append (gpg->userids, g_strdup (userid));\n\t\t} else {\n\t\t\tgint ii;\n\n\t\t\tfor (ii = 0; uids[ii]; ii++) {\n\t\t\t\tconst gchar *uid = uids[ii];\n\n\t\t\t\tif (*uid) {\n\t\t\t\t\tgpg->userids = g_slist_append (gpg->userids, g_strdup (uid));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tg_strfreev (uids);\n\t\t}\n\t}\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":90758,"func":"  void DidGetGlobalUsage(StorageType type, int64 usage,\n                         int64 unlimited_usage) {\n    DCHECK_EQ(type_, type);\n    DCHECK_GE(usage, unlimited_usage);\n    global_usage_ = usage;\n    global_unlimited_usage_ = unlimited_usage;\n    CheckCompleted();\n  }\n","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":249518,"func":"int processing_finish(png_structp png_ptr, png_infop info_ptr) {\n  unsigned char footer[12] = {0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130};\n\n  if (!png_ptr || !info_ptr) return 1;\n\n  if (setjmp(png_jmpbuf(png_ptr))) {\n    png_destroy_read_struct(&png_ptr, &info_ptr, 0);\n    return 1;\n  }\n\n  png_process_data(png_ptr, info_ptr, footer, 12);\n  png_destroy_read_struct(&png_ptr, &info_ptr, 0);\n\n  return 0;\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":338183,"func":"bool WasmBinaryBuilder::maybeVisitTableSize(Expression*& out, uint32_t code) {\n  if (code != BinaryConsts::TableSize) {\n    return false;\n  }\n  Index tableIdx = getU32LEB();\n  if (tableIdx >= tables.size()) {\n    throwError(\"bad table index\");\n  }\n  auto* curr = allocator.alloc<TableSize>();\n  curr->finalize();\n  \/\/ Defer setting the table name for later, when we know it.\n  tableRefs[tableIdx].push_back(curr);\n  out = curr;\n  return true;\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":385812,"func":"static long do_sys_truncate(const char __user *pathname, loff_t length)\n{\n\tunsigned int lookup_flags = LOOKUP_FOLLOW;\n\tstruct path path;\n\tint error;\n\n\tif (length < 0)\t\/* sorry, but loff_t says... *\/\n\t\treturn -EINVAL;\n\nretry:\n\terror = user_path_at(AT_FDCWD, pathname, lookup_flags, &path);\n\tif (!error) {\n\t\terror = vfs_truncate(&path, length);\n\t\tpath_put(&path);\n\t}\n\tif (retry_estale(error, lookup_flags)) {\n\t\tlookup_flags |= LOOKUP_REVAL;\n\t\tgoto retry;\n\t}\n\treturn error;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":513222,"func":"bool sys_var_pluginvar::session_update(THD *thd, set_var *var)\n{\n  DBUG_ASSERT(!is_readonly());\n  DBUG_ASSERT(plugin_var->flags & PLUGIN_VAR_THDLOCAL);\n  DBUG_ASSERT(thd == current_thd);\n\n  mysql_mutex_lock(&LOCK_global_system_variables);\n  void *tgt= real_value_ptr(thd, OPT_SESSION);\n  const void *src= var->value ? (void*)&var->save_result\n                              : (void*)real_value_ptr(thd, OPT_GLOBAL);\n  mysql_mutex_unlock(&LOCK_global_system_variables);\n\n  plugin_var->update(thd, plugin_var, tgt, src);\n\n  return false;\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":328820,"func":"R_API ut32 r_bin_java_get_utf8_len_from_cp_item_list(RList *cp_list, ut64 idx) {\n\t\/*\n\tSearch through the Constant Pool list for the given CP Index.\n\tIf the idx not found by directly going to the list index,\n\tthe list will be walked and then the IDX will be checked.\n\trvalue: new ut32 .\n\t*\/\n\tut32 value = -1;\n\tRListIter *iter;\n\tif (!cp_list) {\n\t\treturn 0;\n\t}\n\tRBinJavaCPTypeObj *item = (RBinJavaCPTypeObj *) r_list_get_n (cp_list, idx);\n\tif (item && (item->tag == R_BIN_JAVA_CP_UTF8) && item->metas->ord == idx) {\n\t\tvalue = item->info.cp_utf8.length;\n\t}\n\tif (value == -1) {\n\t\tr_list_foreach (cp_list, iter, item) {\n\t\t\tif (item && (item->tag == R_BIN_JAVA_CP_UTF8) && item->metas->ord == idx) {\n\t\t\t\tvalue = item->info.cp_utf8.length;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":344796,"func":"strdelim(char **s)\n{\n\treturn strdelim_internal(s, 1);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":221484,"func":"flatpak_run_extend_ld_path (FlatpakBwrap *bwrap,\n                            const char *prepend,\n                            const char *append)\n{\n  g_autoptr(GString) ld_library_path = g_string_new (g_environ_getenv (bwrap->envp, \"LD_LIBRARY_PATH\"));\n\n  if (prepend != NULL && *prepend != '\\0')\n    {\n      if (ld_library_path->len > 0)\n        g_string_prepend (ld_library_path, \":\");\n\n      g_string_prepend (ld_library_path, prepend);\n    }\n\n  if (append != NULL && *append != '\\0')\n    {\n      if (ld_library_path->len > 0)\n        g_string_append (ld_library_path, \":\");\n\n      g_string_append (ld_library_path, append);\n    }\n\n  flatpak_bwrap_set_env (bwrap, \"LD_LIBRARY_PATH\", ld_library_path->str, TRUE);\n}","target":0,"code_token_length":190,"total_token_length":426,"max_tokens_setting":512}
+{"idx":246444,"func":"RPVector *r_bin_wasm_get_datas(RBinWasmObj *bin) {\n\tr_return_val_if_fail (bin && bin->g_sections, NULL);\n\treturn bin->g_datas? bin->g_datas: parse_unique_subsec_vec_by_id (bin, R_BIN_WASM_SECTION_DATA);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":232949,"func":"char *Curl_all_content_encodings(void)\n{\n  size_t len = 0;\n  const struct content_encoding * const *cep;\n  const struct content_encoding *ce;\n  char *ace;\n\n  for(cep = encodings; *cep; cep++) {\n    ce = *cep;\n    if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT))\n      len += strlen(ce->name) + 2;\n  }\n\n  if(!len)\n    return strdup(CONTENT_ENCODING_DEFAULT);\n\n  ace = malloc(len);\n  if(ace) {\n    char *p = ace;\n    for(cep = encodings; *cep; cep++) {\n      ce = *cep;\n      if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) {\n        strcpy(p, ce->name);\n        p += strlen(p);\n        *p++ = ',';\n        *p++ = ' ';\n      }\n    }\n    p[-2] = '\\0';\n  }\n\n  return ace;\n}","target":0,"code_token_length":208,"total_token_length":444,"max_tokens_setting":512}
+{"idx":353221,"func":"void SplashOutputDev::updateStrokeAdjust(GfxState * \/*state*\/) {\n#if 0 \/\/ the SA parameter supposedly defaults to false, but Acrobat\n      \/\/ apparently hardwires it to true\n  splash->setStrokeAdjust(state->getStrokeAdjust());\n#endif\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":488407,"func":"static void remove_migration_ptes(struct page *old, struct page *new)\n{\n\tif (PageAnon(new))\n\t\tremove_anon_migration_ptes(old, new);\n\telse\n\t\tremove_file_migration_ptes(old, new);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":393506,"func":"static SQInteger array_pop(HSQUIRRELVM v)\n{\n    return SQ_SUCCEEDED(sq_arraypop(v,1,SQTrue))?1:SQ_ERROR;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":309978,"func":"can_change_color(void)\n{\n    return NCURSES_SP_NAME(can_change_color) (CURRENT_SCREEN);\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":231059,"func":"    void vQueueUnregisterQueue( QueueHandle_t xQueue )\r\n    {\r\n        UBaseType_t ux;\r\n\r\n        \/* See if the handle of the queue being unregistered in actually in the\r\n         * registry. *\/\r\n        for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )\r\n        {\r\n            if( xQueueRegistry[ ux ].xHandle == xQueue )\r\n            {\r\n                \/* Set the name to NULL to show that this slot if free again. *\/\r\n                xQueueRegistry[ ux ].pcQueueName = NULL;\r\n\r\n                \/* Set the handle to NULL to ensure the same queue handle cannot\r\n                 * appear in the registry twice if it is added, removed, then\r\n                 * added again. *\/\r\n                xQueueRegistry[ ux ].xHandle = ( QueueHandle_t ) 0;\r\n                break;\r\n            }\r\n            else\r\n            {\r\n                mtCOVERAGE_TEST_MARKER();\r\n            }\r\n        }\r\n    } \/*lint !e818 xQueue could not be pointer to const because it is a typedef. *\/\r","target":0,"code_token_length":226,"total_token_length":462,"max_tokens_setting":512}
+{"idx":231762,"func":"TEST_F(\n    QuicServerTransportForciblySetUDUPayloadSizeTest,\n    TestHandleTransportKnobParamForciblySetUDPPayloadSize) {\n  EXPECT_LT(server->getConn().udpSendPacketLen, 1452);\n  server->handleKnobParams(\n      {{static_cast<uint64_t>(\n            TransportKnobParamId::FORCIBLY_SET_UDP_PAYLOAD_SIZE),\n        1}});\n  EXPECT_EQ(server->getConn().udpSendPacketLen, 1452);\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":483498,"func":"static int __init fdt_find_uefi_params(unsigned long node, const char *uname,\n\t\t\t\t       int depth, void *data)\n{\n\tstruct param_info *info = data;\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(dt_params); i++) {\n\t\tconst char *subnode = dt_params[i].subnode;\n\n\t\tif (depth != 1 || strcmp(uname, dt_params[i].uname) != 0) {\n\t\t\tinfo->missing = dt_params[i].params[0].name;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (subnode) {\n\t\t\tint err = of_get_flat_dt_subnode_by_name(node, subnode);\n\n\t\t\tif (err < 0)\n\t\t\t\treturn 0;\n\n\t\t\tnode = err;\n\t\t}\n\n\t\treturn __find_uefi_params(node, info, dt_params[i].params);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":333499,"func":"gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsigned int src_height, const gdImagePtr dst, const unsigned int new_width, const unsigned int new_height)\n{\n\tgdImagePtr tmp_im;\n\n\tif (new_width == 0 || new_height == 0) {\n\t\treturn NULL;\n\t}\n\n\ttmp_im = gdImageCreateTrueColor(new_width, src_height);\n\tif (tmp_im == NULL) {\n\t\treturn NULL;\n\t}\n\tgdImageSetInterpolationMethod(tmp_im, src->interpolation_id);\n\n\t_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);\n\t_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);\n\n\tgdImageDestroy(tmp_im);\n\treturn dst;\n}","target":0,"code_token_length":169,"total_token_length":405,"max_tokens_setting":512}
+{"idx":238464,"func":"static const char *disasm_kfunc_name(void *data, const struct bpf_insn *insn)\n{\n\tconst struct btf_type *func;\n\tstruct btf *desc_btf;\n\n\tif (insn->src_reg != BPF_PSEUDO_KFUNC_CALL)\n\t\treturn NULL;\n\n\tdesc_btf = find_kfunc_desc_btf(data, insn->imm, insn->off, NULL);\n\tif (IS_ERR(desc_btf))\n\t\treturn \"<error>\";\n\n\tfunc = btf_type_by_id(desc_btf, insn->imm);\n\treturn btf_name_by_offset(desc_btf, func->name_off);\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":225858,"func":"\nGF_Box *reftype_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackReferenceTypeBox, GF_ISOM_BOX_TYPE_REFT);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":309935,"func":"stripped(char *src)\n{\n    char *dst = 0;\n\n    while (isspace(UChar(*src)))\n\tsrc++;\n\n    if (*src != '\\0') {\n\tsize_t len;\n\n\tif ((dst = strdup(src)) == NULL) {\n\t    failed(\"strdup\");\n\t} else {\n\t    len = strlen(dst);\n\t    while (--len != 0 && isspace(UChar(dst[len])))\n\t\tdst[len] = '\\0';\n\t}\n    }\n    return dst;\n}","target":0,"code_token_length":98,"total_token_length":334,"max_tokens_setting":512}
+{"idx":514308,"func":"void multi_update::prepare_to_read_rows()\n{\n  \/*\n    update column maps now. it cannot be done in ::prepare() before the\n    optimizer, because the optimize might reset them (in\n    SELECT_LEX::update_used_tables()), it cannot be done in\n    ::initialize_tables() after the optimizer, because the optimizer\n    might read rows from const tables\n  *\/\n\n  for (TABLE_LIST *tl= update_tables; tl; tl= tl->next_local)\n    tl->table->mark_columns_needed_for_update();\n}","target":0,"code_token_length":111,"total_token_length":347,"max_tokens_setting":512}
+{"idx":234819,"func":"static struct btrfs_device * btrfs_find_next_active_device(\n\t\tstruct btrfs_fs_devices *fs_devs, struct btrfs_device *device)\n{\n\tstruct btrfs_device *next_device;\n\n\tlist_for_each_entry(next_device, &fs_devs->devices, dev_list) {\n\t\tif (next_device != device &&\n\t\t    !test_bit(BTRFS_DEV_STATE_MISSING, &next_device->dev_state)\n\t\t    && next_device->bdev)\n\t\t\treturn next_device;\n\t}\n\n\treturn NULL;\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":226430,"func":"  Status AsGraphDefInternal(SerializationContext* ctx,\n                            DatasetGraphDefBuilder* b,\n                            Node** output) const override {\n    Node* indices_node;\n    TF_RETURN_IF_ERROR(b->AddTensor(sparse_tensor_.indices(), &indices_node));\n    Node* value_node;\n    TF_RETURN_IF_ERROR(b->AddTensor(sparse_tensor_.values(), &value_node));\n    Node* dense_shape_node;\n    std::vector<int64_t> dense_shape;\n    dense_shape.reserve(sparse_tensor_.shape().size());\n    for (int i = 0; i < sparse_tensor_.shape().size(); i++)\n      dense_shape.emplace_back(sparse_tensor_.shape()[i]);\n    TF_RETURN_IF_ERROR(b->AddVector(dense_shape, &dense_shape_node));\n    AttrValue val_dtype;\n    b->BuildAttrValue(sparse_tensor_.dtype(), &val_dtype);\n    TF_RETURN_IF_ERROR(\n        b->AddDataset(this, {indices_node, value_node, dense_shape_node},\n                      {{\"Tvalues\", val_dtype}}, output));\n    return Status::OK();\n  }","target":0,"code_token_length":225,"total_token_length":461,"max_tokens_setting":512}
+{"idx":301354,"func":"static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)\n{\n#ifdef HAVE_FCHOWN\n\tint result;\n\n\tSTART_PROFILE(syscall_fchown);\n\tresult = fchown(fsp->fh->fd, uid, gid);\n\tEND_PROFILE(syscall_fchown);\n\treturn result;\n#else\n\terrno = ENOSYS;\n\treturn -1;\n#endif\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":445972,"func":"fr_window_set_dialog (FrWindow   *window,\n\t\t      const char *dialog_name,\n\t\t      GtkWidget  *dialog)\n{\n\tg_object_set_data (G_OBJECT (dialog), DIALOG_NAME_KEY, (gpointer) _g_str_get_static (dialog_name));\n\tg_hash_table_insert (window->priv->named_dialogs, (gpointer) dialog_name, dialog);\n\tg_signal_connect (dialog,\n\t\t\t  \"destroy\",\n\t\t\t  G_CALLBACK (unset_dialog),\n\t\t\t  window);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":301436,"func":"static int vfswrap_chflags(vfs_handle_struct *handle, const char *path,\n\t\t\t   unsigned int flags)\n{\n#ifdef HAVE_CHFLAGS\n\treturn chflags(path, flags);\n#else\n\terrno = ENOSYS;\n\treturn -1;\n#endif\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":401519,"func":"bool rng_is_initialized(void)\n{\n\treturn crng_ready();\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":248247,"func":"DLLIMPORT int cfg_opt_rmtsec(cfg_opt_t *opt, const char *title)\n{\n\tunsigned int i, n;\n\n\tif (!opt || !title) {\n\t\terrno = EINVAL;\n\t\treturn CFG_FAIL;\n\t}\n\n\tif (!is_set(CFGF_TITLE, opt->flags))\n\t\treturn CFG_FAIL;\n\n\tn = cfg_opt_size(opt);\n\tfor (i = 0; i < n; i++) {\n\t\tcfg_t *sec = cfg_opt_getnsec(opt, i);\n\n\t\tif (!sec || !sec->title)\n\t\t\treturn CFG_FAIL;\n\n\t\tif (is_set(CFGF_NOCASE, opt->flags)) {\n\t\t\tif (strcasecmp(title, sec->title) == 0)\n\t\t\t\tbreak;\n\t\t} else {\n\t\t\tif (strcmp(title, sec->title) == 0)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tif (i == n)\n\t\treturn CFG_FAIL;\n\n\treturn cfg_opt_rmnsec(opt, i);\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":101694,"func":"void WebProcessProxy::registerNewWebBackForwardListItem(WebBackForwardListItem* item)\n{\n    ASSERT(!m_backForwardListItemMap.contains(item->itemID()));\n\n    m_backForwardListItemMap.set(item->itemID(), item);\n}\n","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":415189,"func":"reset_notify (assuan_context_t ctx, char *line)\n{\n  ctrl_t ctrl = assuan_get_pointer (ctx);\n\n  (void) line;\n\n  do_reset (ctrl, 1);\n  return 0;\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":413600,"func":"static bool myvalid(RIO *io, ut64 addr) {\n\tif (addr < 0x100) {\n\t\treturn false;\n\t}\n\tif (addr == UT32_MAX || addr == UT64_MAX) {\t\/\/the best of the best of the best :(\n\t\treturn false;\n\t}\n\tif (!r_io_is_valid_offset (io, addr, 0)) {\n\t\treturn false;\n\t}\n\treturn true;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":246740,"func":"Bool print_version(char *arg_val, u32 param)\n{\n\tfprintf(stderr, \"MP4Box - GPAC version %s\\n\"\n\t        \"%s\\n\"\n\t        \"GPAC Configuration: \" GPAC_CONFIGURATION \"\\n\"\n\t        \"Features: %s %s\\n\", gf_gpac_version(), gf_gpac_copyright_cite(), gf_sys_features(GF_FALSE), gf_sys_features(GF_TRUE));\n\treturn GF_TRUE;\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":512994,"func":"Item *Item_cond_or::copy_andor_structure(THD *thd)\n{\n  Item_cond_or *item;\n  if ((item= new (thd->mem_root) Item_cond_or(thd, this)))\n    item->copy_andor_arguments(thd, this);\n  return item;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":442584,"func":"static void init_qxl_surface(QXLSurfaceCmd *qxl)\n{\n    void *surface_mem;\n\n    memset(qxl, 0, sizeof(*qxl));\n\n    qxl->surface_id = 123;\n\n    qxl->u.surface_create.format = SPICE_SURFACE_FMT_32_xRGB;\n    qxl->u.surface_create.width = 128;\n    qxl->u.surface_create.stride = 512;\n    qxl->u.surface_create.height = 128;\n    surface_mem = g_malloc(0x10000);\n    qxl->u.surface_create.data = to_physical(surface_mem);\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":374042,"func":"static const char *typeString(ut32 n, int *bits) {\n\t*bits = 32;\n\tif (n == 12) { \/\/ CPU_SUBTYPE_ARM_V7) {\n\t\treturn \"arm\";\n\t}\n\tif (n == 0x0100000c) { \/\/ arm64\n\t\t*bits = 64;\n\t\treturn \"arm\";\n\t}\n\tif (n == 0x0200000c) { \/\/ arm64-32\n\t\t\/\/  TODO: must change bits\n\t\t*bits = 64;\n\t\treturn \"arm\";\n\t}\n\treturn \"x86\";\n}","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":310107,"func":"vid_attr(attr_t newmode, NCURSES_PAIRS_T pair_arg, void *opts)\n{\n    return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair_arg, opts);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":369885,"func":"static int proc_map_files_get_link(struct dentry *dentry, struct path *path)\n{\n\tunsigned long vm_start, vm_end;\n\tstruct vm_area_struct *vma;\n\tstruct task_struct *task;\n\tstruct mm_struct *mm;\n\tint rc;\n\n\trc = -ENOENT;\n\ttask = get_proc_task(dentry->d_inode);\n\tif (!task)\n\t\tgoto out;\n\n\tmm = get_task_mm(task);\n\tput_task_struct(task);\n\tif (!mm)\n\t\tgoto out;\n\n\trc = dname_to_vma_addr(dentry, &vm_start, &vm_end);\n\tif (rc)\n\t\tgoto out_mmput;\n\n\tdown_read(&mm->mmap_sem);\n\tvma = find_exact_vma(mm, vm_start, vm_end);\n\tif (vma && vma->vm_file) {\n\t\t*path = vma->vm_file->f_path;\n\t\tpath_get(path);\n\t\trc = 0;\n\t}\n\tup_read(&mm->mmap_sem);\n\nout_mmput:\n\tmmput(mm);\nout:\n\treturn rc;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":263381,"func":"Status ScatterNdTensorShape(InferenceContext* c) {\n  ShapeHandle output_shape;\n  TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 1, &output_shape));\n  ShapeHandle indices_shape;\n  TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(1), 1, &indices_shape));\n  ShapeHandle updates_shape;\n  TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(2), 1, &updates_shape));\n  return shape_inference::ScatterNdShapeHelper(c, indices_shape, updates_shape,\n                                               output_shape);\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":498112,"func":"int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const char *value))\n{\n\tchar *o, *t, *txt, *value = NULL, c;\n\n\tif (!txt_)\n\t\treturn 0;\n\n\to = t = txt = xstrdup(txt_);\n\twhile ((c=*t) != '\\0') {\n\t\tif (c == '=') {\n\t\t\t*t = '\\0';\n\t\t\tvalue = t + 1;\n\t\t} else if (c == '+') {\n\t\t\t*t = ' ';\n\t\t} else if (c == '%') {\n\t\t\tt = convert_query_hexchar(t);\n\t\t} else if (c == '&') {\n\t\t\t*t = '\\0';\n\t\t\t(*fn)(txt, value);\n\t\t\ttxt = t + 1;\n\t\t\tvalue = NULL;\n\t\t}\n\t\tt++;\n\t}\n\tif (t != txt)\n\t\t(*fn)(txt, value);\n\tfree(o);\n\treturn 0;\n}","target":0,"code_token_length":204,"total_token_length":440,"max_tokens_setting":512}
+{"idx":225777,"func":"GF_Err rely_box_size(GF_Box *s)\n{\n\ts->size += 1;\n\treturn GF_OK;\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":522338,"func":"static int64_t GetFilPos(GmfMshSct *msh)\n{\n#ifdef WITH_GMF_AIO\n   if(msh->typ & Bin)\n      return(lseek(msh->FilDes, 0, 1));\n   else\n      return(MYFTELL(msh->hdl));\n#else\n   return(MYFTELL(msh->hdl));\n#endif\n}","target":0,"code_token_length":83,"total_token_length":319,"max_tokens_setting":512}
+{"idx":343226,"func":"static int dlmap_exit(DLHandler * const dlhandler)\n{\n    if (dlhandler->map != NULL) {\n        free(dlhandler->map);\n        dlhandler->map = NULL;\n        dlhandler->sizeof_map = (size_t) 0U;\n        dlhandler->dlmap_size = (size_t) 0U;\n    }\n    return 0;\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":216946,"func":"static void fix_dl_name(MEM_ROOT *root, LEX_STRING *dl)\n{\n  const size_t so_ext_len= sizeof(SO_EXT) - 1;\n  if (my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len,\n                    SO_EXT))\n  {\n    char *s= (char*)alloc_root(root, dl->length + so_ext_len + 1);\n    memcpy(s, dl->str, dl->length);\n    strcpy(s + dl->length, SO_EXT);\n    dl->str= s;\n    dl->length+= so_ext_len;\n  }\n}","target":1,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":459002,"func":"http_linkh(const struct http *to, const struct http *fm, unsigned n)\n{\n\n\tassert(n < HTTP_HDR_FIRST);\n\tTcheck(fm->hd[n]);\n\tto->hd[n] = fm->hd[n];\n\tto->hdf[n] = fm->hdf[n];\n\thttp_VSLH(to, n);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":359548,"func":"DEFUN (address_family_ipv4,\n       address_family_ipv4_cmd,\n       \"address-family ipv4\",\n       \"Enter Address Family command mode\\n\"\n       \"Address family\\n\")\n{\n  vty->node = BGP_IPV4_NODE;\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":366301,"func":"static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how)\n{\n\t\/* Leaving mounts connected is only valid for lazy umounts *\/\n\tif (how & UMOUNT_SYNC)\n\t\treturn true;\n\n\t\/* A mount without a parent has nothing to be connected to *\/\n\tif (!mnt_has_parent(mnt))\n\t\treturn true;\n\n\t\/* Because the reference counting rules change when mounts are\n\t * unmounted and connected, umounted mounts may not be\n\t * connected to mounted mounts.\n\t *\/\n\tif (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT))\n\t\treturn true;\n\n\t\/* Has it been requested that the mount remain connected? *\/\n\tif (how & UMOUNT_CONNECTED)\n\t\treturn false;\n\n\t\/* Is the mount locked such that it needs to remain connected? *\/\n\tif (IS_MNT_LOCKED(mnt))\n\t\treturn false;\n\n\t\/* By default disconnect the mount *\/\n\treturn true;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":242657,"func":"static GFINLINE Bool isor_is_local(const char *url)\n{\n\tif (!strnicmp(url, \"file:\/\/\", 7)) return GF_TRUE;\n\tif (!strnicmp(url, \"gmem:\/\/\", 7)) return GF_TRUE;\n\tif (!strnicmp(url, \"gfio:\/\/\", 7)) return GF_TRUE;\n\tif (!strnicmp(url, \"isobmff:\/\/\", 10)) return GF_TRUE;\n\tif (strstr(url, \":\/\/\")) return GF_FALSE;\n\t\/*the rest is local (mounted on FS)*\/\n\treturn GF_TRUE;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":413836,"func":"LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {\n   \/\/ resolve klass\n  _resolved_klass = pool->klass_ref_at(index, CHECK);\n\n  \/\/ Get name, signature, and static klass\n  _name          = pool->name_ref_at(index);\n  _signature     = pool->signature_ref_at(index);\n  _tag           = pool->tag_ref_at(index);\n  _current_klass = pool->pool_holder();\n  _current_method = methodHandle();\n\n  \/\/ Coming from the constant pool always checks access\n  _check_access  = true;\n  _check_loader_constraints = true;\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":343220,"func":"static void keepalive(const int fd, int keep)\n{\n#ifdef SO_KEEPALIVE\n    {\n        setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &keep, sizeof keep);\n    }\n#endif\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":312585,"func":"set_errorlist(\n\twin_T\t*wp,\n\tlist_T\t*list,\n\tint\taction,\n\tchar_u\t*title,\n\tdict_T\t*what)\n{\n    qf_info_T\t*qi = &ql_info;\n    int\t\tretval = OK;\n\n    if (wp != NULL)\n    {\n\tqi = ll_get_or_alloc_list(wp);\n\tif (qi == NULL)\n\t    return FAIL;\n    }\n\n    if (action == 'f')\n    {\n\t\/\/ Free the entire quickfix or location list stack\n\tqf_free_stack(wp, qi);\n\treturn OK;\n    }\n\n    \/\/ A dict argument cannot be specified with a non-empty list argument\n    if (list->lv_len != 0 && what != NULL)\n    {\n\tsemsg(_(e_invalid_argument_str),\n\t\t\t _(\"cannot have both a list and a \\\"what\\\" argument\"));\n\treturn FAIL;\n    }\n\n    incr_quickfix_busy();\n\n    if (what != NULL)\n\tretval = qf_set_properties(qi, what, action, title);\n    else\n    {\n\tretval = qf_add_entries(qi, qi->qf_curlist, list, title, action);\n\tif (retval == OK)\n\t    qf_list_changed(qf_get_curlist(qi));\n    }\n\n    decr_quickfix_busy();\n\n    return retval;\n}","target":0,"code_token_length":269,"total_token_length":505,"max_tokens_setting":512}
+{"idx":448532,"func":"void bgp_update_restarted_peers(struct peer *peer)\n{\n\tif (!bgp_update_delay_active(peer->bgp))\n\t\treturn; \/* BGP update delay has ended *\/\n\tif (peer->update_delay_over)\n\t\treturn; \/* This peer has already been considered *\/\n\n\tif (bgp_debug_neighbor_events(peer))\n\t\tzlog_debug(\"Peer %s: Checking restarted\", peer->host);\n\n\tif (peer_established(peer)) {\n\t\tpeer->update_delay_over = 1;\n\t\tpeer->bgp->restarted_peers++;\n\t\tbgp_check_update_delay(peer->bgp);\n\t}\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":220404,"func":"ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals)\n{\n  struct RArray *a = ary_new_capa(mrb, size);\n\n  array_copy(ARY_PTR(a), vals, size);\n  ARY_SET_LEN(a, size);\n\n  return a;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":294716,"func":"m_yday(union DateData *x)\n{\n    int jd, ry, rd;\n    double sg;\n\n    jd = m_local_jd(x);\n    sg = m_virtual_sg(x); \/* !=m_sg() *\/\n\n    if (m_proleptic_gregorian_p(x) ||\n\t(jd - sg) > 366)\n\treturn c_gregorian_to_yday(m_year(x), m_mon(x), m_mday(x));\n    if (m_proleptic_julian_p(x))\n\treturn c_julian_to_yday(m_year(x), m_mon(x), m_mday(x));\n    c_jd_to_ordinal(jd, sg, &ry, &rd);\n    return rd;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":224549,"func":"Status QuantizedConcatV2Shape(InferenceContext* c, int num_inputs_to_concat) {\n  return ConcatShapeHelper(c, 0 \/* start_value_index *\/,\n                           num_inputs_to_concat \/* end_value_index *\/,\n                           num_inputs_to_concat \/* dim_index *\/);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":313766,"func":"nv_mark(cmdarg_T *cap)\n{\n    if (!checkclearop(cap->oap))\n    {\n\tif (setmark(cap->nchar) == FAIL)\n\t    clearopbeep(cap->oap);\n    }\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":492693,"func":"vte_sequence_handler_set_scrolling_region_from_start (VteTerminal *terminal, GValueArray *params)\n{\n\tGValue value = {0};\n\n\tg_value_init (&value, G_TYPE_LONG);\n\tg_value_set_long (&value, 0); \/* Out of range means start\/end *\/\n\n\tg_value_array_insert (params, 0, &value);\n\n\tvte_sequence_handler_offset(terminal, params, -1, vte_sequence_handler_cs);\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":343238,"func":"void disablesignals(void)\n{\n    sigset_t sigs;\n\n    sigfillset(&sigs);\n    if (sigprocmask(SIG_BLOCK, &sigs, &old_sigmask) < 0) {\n        _EXIT(EXIT_FAILURE);\n    }\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":447041,"func":"    long SshIo::SshImpl::getFileLength()\n    {\n        long length = 0;\n        if (protocol_ == pSftp) { \/\/ sftp\n            sftp_attributes attributes = sftp_fstat(fileHandler_);\n            length = (long)attributes->size;\n        } else { \/\/ ssh\n            std::string response;\n            \/\/std::string cmd = \"stat -c %s \" + hostInfo_.Path;\n            std::string cmd = \"declare -a x=($(ls -alt \" + hostInfo_.Path + \")); echo ${x[4]}\";\n            if (ssh_->runCommand(cmd, &response) != 0) {\n                throw Error(1, \"Unable to get file length.\");\n            } else {\n                length = atol(response.c_str());\n                if (length == 0) {\n                    throw Error(1, \"File is empty or not found.\");\n                }\n            }\n        }\n        return length;\n    }","target":0,"code_token_length":202,"total_token_length":438,"max_tokens_setting":512}
+{"idx":387639,"func":"void snd_ctl_disconnect_layer(struct snd_ctl_layer_ops *lops)\n{\n\tstruct snd_ctl_layer_ops *lops2, *prev_lops2;\n\n\tdown_write(&snd_ctl_layer_rwsem);\n\tfor (lops2 = snd_ctl_layer, prev_lops2 = NULL; lops2; lops2 = lops2->next) {\n\t\tif (lops2 == lops) {\n\t\t\tif (!prev_lops2)\n\t\t\t\tsnd_ctl_layer = lops->next;\n\t\t\telse\n\t\t\t\tprev_lops2->next = lops->next;\n\t\t\tbreak;\n\t\t}\n\t\tprev_lops2 = lops2;\n\t}\n\tup_write(&snd_ctl_layer_rwsem);\n}","target":0,"code_token_length":143,"total_token_length":379,"max_tokens_setting":512}
+{"idx":247128,"func":"void gf_fs_run_step(GF_FilterSession *fsess)\n{\n\tgf_fs_thread_proc(&fsess->main_th);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":248294,"func":"DLLIMPORT int cfg_setnint(cfg_t *cfg, const char *name, long int value, unsigned int index)\n{\n\tcfg_opt_t *opt;\n\n\topt = cfg_getopt(cfg, name);\n\tif (opt && opt->validcb2 && (*opt->validcb2)(cfg, opt, (void *)&value) != 0)\n\t\treturn CFG_FAIL;\n\n\treturn cfg_opt_setnint(opt, value, index);\n}","target":0,"code_token_length":89,"total_token_length":325,"max_tokens_setting":512}
+{"idx":244153,"func":"GF_Err pdin_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i;\n\tGF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox*)s;\n\n\tptr->count = (u32) (ptr->size) \/ 8;\n\tptr->rates = (u32*)gf_malloc(sizeof(u32)*ptr->count);\n\tif (!ptr->rates) return GF_OUT_OF_MEM;\n\tptr->times = (u32*)gf_malloc(sizeof(u32)*ptr->count);\n\tif (!ptr->times) return GF_OUT_OF_MEM;\n\tfor (i=0; i<ptr->count; i++) {\n\t\tptr->rates[i] = gf_bs_read_u32(bs);\n\t\tptr->times[i] = gf_bs_read_u32(bs);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":402655,"func":"hide_stolen_goods_from_cms(cms_context *new,\n\t\t\t   cms_context *old UNUSED)\n{\n\tnew->tokenname = NULL;\n\tnew->certname = NULL;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":498100,"func":"void html_link_open(const char *url, const char *title, const char *class)\n{\n\thtml(\"<a href='\");\n\thtml_attr(url);\n\tif (title) {\n\t\thtml(\"' title='\");\n\t\thtml_attr(title);\n\t}\n\tif (class) {\n\t\thtml(\"' class='\");\n\t\thtml_attr(class);\n\t}\n\thtml(\"'>\");\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":336020,"func":"static int sr_mdio_read(struct net_device *netdev, int phy_id, int loc)\n{\n\tstruct usbnet *dev = netdev_priv(netdev);\n\t__le16 res;\n\tint rc = 0;\n\n\tif (phy_id) {\n\t\tnetdev_dbg(netdev, \"Only internal phy supported\\n\");\n\t\treturn 0;\n\t}\n\n\t\/* Access NSR_LINKST bit for link status instead of MII_BMSR *\/\n\tif (loc == MII_BMSR) {\n\t\tu8 value;\n\n\t\tsr_read_reg(dev, SR_NSR, &value);\n\t\tif (value & NSR_LINKST)\n\t\t\trc = 1;\n\t}\n\tsr_share_read_word(dev, 1, loc, &res);\n\tif (rc == 1)\n\t\tres = le16_to_cpu(res) | BMSR_LSTATUS;\n\telse\n\t\tres = le16_to_cpu(res) & ~BMSR_LSTATUS;\n\n\tnetdev_dbg(netdev, \"sr_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\\n\",\n\t\t   phy_id, loc, res);\n\n\treturn res;\n}","target":0,"code_token_length":252,"total_token_length":488,"max_tokens_setting":512}
+{"idx":259268,"func":"static MOVFragmentStreamInfo *get_frag_stream_info_from_pkt(MOVFragmentIndex *frag_index, AVPacket *pkt, int id)\n{\n    int current = frag_index->current;\n\n    if (!frag_index->nb_items)\n        return NULL;\n\n    \/\/ Check frag_index->current is the right one for pkt. It can out of sync.\n    if (current >= 0 && current < frag_index->nb_items) {\n        if (frag_index->item[current].moof_offset < pkt->pos &&\n            (current + 1 == frag_index->nb_items ||\n             frag_index->item[current + 1].moof_offset > pkt->pos))\n            return get_frag_stream_info(frag_index, current, id);\n    }\n\n\n    for (int i = 0; i < frag_index->nb_items; i++) {\n        if (frag_index->item[i].moof_offset > pkt->pos)\n            break;\n        current = i;\n    }\n    frag_index->current = current;\n    return get_frag_stream_info(frag_index, current, id);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":434109,"func":"alist_name(aentry_T *aep)\n{\n    buf_T\t*bp;\n\n    \/\/ Use the name from the associated buffer if it exists.\n    bp = buflist_findnr(aep->ae_fnum);\n    if (bp == NULL || bp->b_fname == NULL)\n\treturn aep->ae_fname;\n    return bp->b_fname;\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":244139,"func":"void st3d_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":512723,"func":"  Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a,\n                     bool vcol_assignment_arg)\n    :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,\n                &null_clex_str), vcol_assignment_ok(vcol_assignment_arg),\n     arg(a), cached_field(NULL) {}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":398541,"func":"RzBinSection *getsection(RzBinFile *binfile, const char *sn) {\n\trz_return_val_if_fail(binfile && sn, NULL);\n\tRzListIter *iter;\n\tRzBinSection *section = NULL;\n\tRzBinObject *o = binfile->o;\n\tif (!o || !o->sections) {\n\t\treturn NULL;\n\t}\n\trz_list_foreach (o->sections, iter, section) {\n\t\tif (!section->name) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (strstr(section->name, sn)) {\n\t\t\treturn section;\n\t\t}\n\t}\n\treturn NULL;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":512717,"func":"bool Regexp_processor_pcre::exec(String *str, int offset,\n                                  uint n_result_offsets_to_convert)\n{\n  if (!(str= convert_if_needed(str, &subject_converter)))\n    return true;\n  m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra,\n                                      str->c_ptr_safe(), str->length(),\n                                      offset, 0,\n                                      m_SubStrVec, array_elements(m_SubStrVec));\n  if (m_pcre_exec_rc > 0)\n  {\n    uint i;\n    for (i= 0; i < n_result_offsets_to_convert; i++)\n    {\n      \/*\n        Convert byte offset into character offset.\n      *\/\n      m_SubStrVec[i]= (int) str->charset()->cset->numchars(str->charset(),\n                                                           str->ptr(),\n                                                           str->ptr() +\n                                                           m_SubStrVec[i]);\n    }\n  }\n  return false;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":522332,"func":"int    my_aio_write (      struct aiocb *aiocbp){return(aio_write (aiocbp));}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":313833,"func":"nv_end(cmdarg_T *cap)\n{\n    if (cap->arg || (mod_mask & MOD_MASK_CTRL))\t\/\/ CTRL-END = goto last line\n    {\n\tcap->arg = TRUE;\n\tnv_goto(cap);\n\tcap->count1 = 1;\t\t\/\/ to end of current line\n    }\n    nv_dollar(cap);\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":462252,"func":"static pj_status_t encode_binary_attr(const void *a, pj_uint8_t *buf, \n\t\t\t\t      unsigned len, \n\t\t\t\t      const pj_stun_msg_hdr *msghdr,\n\t\t\t\t      unsigned *printed)\n{\n    const pj_stun_binary_attr *ca = (const pj_stun_binary_attr*)a;\n\n    PJ_CHECK_STACK();\n    \n    PJ_UNUSED_ARG(msghdr);\n\n    \/* Calculated total attr_len (add padding if necessary) *\/\n    *printed = (ca->length + ATTR_HDR_LEN + 3) & (~3);\n    if (len < *printed)\n\treturn PJ_ETOOSMALL;\n\n    PUTVAL16H(buf, 0, ca->hdr.type);\n    PUTVAL16H(buf, 2, (pj_uint16_t) ca->length);\n\n    \/* Copy the data *\/\n    pj_memcpy(buf+ATTR_HDR_LEN, ca->data, ca->length);\n\n    \/* Done *\/\n    return PJ_SUCCESS;\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":364770,"func":"findtags_string_convert(findtags_state_T *st)\n{\n    char_u\t*conv_line;\n    int\t\tlen;\n\n    conv_line = string_convert(&st->vimconv, st->lbuf, NULL);\n    if (conv_line == NULL)\n\treturn;\n\n    \/\/ Copy or swap lbuf and conv_line.\n    len = (int)STRLEN(conv_line) + 1;\n    if (len > st->lbuf_size)\n    {\n\tvim_free(st->lbuf);\n\tst->lbuf = conv_line;\n\tst->lbuf_size = len;\n    }\n    else\n    {\n\tSTRCPY(st->lbuf, conv_line);\n\tvim_free(conv_line);\n    }\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":512367,"func":"bool Item_func_between::fix_length_and_dec()\n{\n  max_length= 1;\n\n  \/*\n    As some compare functions are generated after sql_yacc,\n    we have to check for out of memory conditions here\n  *\/\n  if (!args[0] || !args[1] || !args[2])\n    return TRUE;\n  if (m_comparator.aggregate_for_comparison(Item_func_between::func_name(),\n                                            args, 3, false))\n  {\n    DBUG_ASSERT(current_thd->is_error());\n    return TRUE;\n  }\n\n  return m_comparator.type_handler()->\n    Item_func_between_fix_length_and_dec(this);\n}","target":0,"code_token_length":132,"total_token_length":368,"max_tokens_setting":512}
+{"idx":500085,"func":"kssl_krb5_sname_to_principal(krb5_context CO,\n                            krb5_const char  * pC1,\n                            krb5_const char  * pC2,\n                            krb5_int32 I,\n                            krb5_principal  * pPR)\n\t{\n\tif (!krb5_loaded)\n\t\tload_krb5_dll();\n\n\tif ( p_krb5_sname_to_principal )\n\t\treturn(p_krb5_sname_to_principal(CO,pC1,pC2,I,pPR));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n\t}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":230459,"func":"uip_nd6_init()\n{\n#if UIP_ND6_SEND_NA\n  \/* Only handle NSs if we are prepared to send out NAs *\/\n  uip_icmp6_register_input_handler(&ns_input_handler);\n#endif\n\n#if UIP_ND6_SEND_NS\n  \/*\n   * Only handle NAs if we are prepared to send out NSs. *\/\n  uip_icmp6_register_input_handler(&na_input_handler);\n#endif\n\n#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA\n  \/* Only accept RS if we are a router and happy to send out RAs *\/\n  uip_icmp6_register_input_handler(&rs_input_handler);\n#endif\n\n#if !UIP_CONF_ROUTER\n  \/* Only process RAs if we are not a router *\/\n  uip_icmp6_register_input_handler(&ra_input_handler);\n#endif\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":401541,"func":"int __init rand_initialize(void)\n{\n\tinit_std_data(&input_pool);\n\tcrng_initialize_primary(&primary_crng);\n\tcrng_global_init_time = jiffies;\n\tif (ratelimit_disable) {\n\t\turandom_warning.interval = 0;\n\t\tunseeded_warning.interval = 0;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":353196,"func":"static int getSat(int r, int g, int b) {\n  int rgbMin, rgbMax;\n\n  rgbMin = rgbMax = r;\n  if (g < rgbMin) {\n    rgbMin = g;\n  } else if (g > rgbMax) {\n    rgbMax = g;\n  }\n  if (b < rgbMin) {\n    rgbMin = b;\n  } else if (b > rgbMax) {\n    rgbMax = b;\n  }\n  return rgbMax - rgbMin;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":353142,"func":"void SplashOutputDev::updateOverprintMode(GfxState *state) {\n  splash->setOverprintMode(state->getOverprintMode());\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":301485,"func":"add_banned(\n    suginfo_T\t*su,\n    char_u\t*word)\n{\n    char_u\t*s;\n    hash_T\thash;\n    hashitem_T\t*hi;\n\n    hash = hash_hash(word);\n    hi = hash_lookup(&su->su_banned, word, hash);\n    if (HASHITEM_EMPTY(hi))\n    {\n\ts = vim_strsave(word);\n\tif (s != NULL)\n\t    hash_add_item(&su->su_banned, hi, s, hash);\n    }\n}","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":359512,"func":"DEFUN (neighbor_peer_group,\n       neighbor_peer_group_cmd,\n       \"neighbor WORD peer-group\",\n       NEIGHBOR_STR\n       \"Neighbor tag\\n\"\n       \"Configure peer-group\\n\")\n{\n  struct bgp *bgp;\n  struct peer_group *group;\n\n  bgp = vty->index;\n\n  group = peer_group_get (bgp, argv[0]);\n  if (! group)\n    return CMD_WARNING;\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":94,"total_token_length":330,"max_tokens_setting":512}
+{"idx":223458,"func":"static void delayed_mem_copy_init(delayed_mem_copy_status *status, compiler_common *common)\n{\nint i;\n\nfor (i = 0; i < RECURSE_TMP_REG_COUNT; i++)\n  {\n  SLJIT_ASSERT(status->tmp_regs[i] >= 0);\n  SLJIT_ASSERT(sljit_get_register_index(status->saved_tmp_regs[i]) < 0 || status->tmp_regs[i] == status->saved_tmp_regs[i]);\n\n  status->store_bases[i] = -1;\n  }\nstatus->next_tmp_reg = 0;\nstatus->compiler = common->compiler;\n}","target":0,"code_token_length":125,"total_token_length":361,"max_tokens_setting":512}
+{"idx":512926,"func":"  String *val_str(String *to)\n  {\n    return has_value() ? Datetime(this).to_string(to, decimals) : NULL;\n  }","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":255082,"func":"ompl::geometric::VFRRT::Motion *ompl::geometric::VFRRT::extendTree(Motion *m, base::State *rstate,\n                                                                   const Eigen::VectorXd &v)\n{\n    base::State *newState = si_->allocState();\n    si_->copyState(newState, m->state);\n\n    double d = si_->distance(m->state, rstate);\n    if (d > maxDistance_)\n        d = maxDistance_;\n\n    const base::StateSpacePtr &space = si_->getStateSpace();\n    for (unsigned int i = 0; i < vfdim_; i++)\n        *space->getValueAddressAtIndex(newState, i) += d * v[i];\n    if (!v.hasNaN() && si_->checkMotion(m->state, newState))\n    {\n        auto *motion = new Motion();\n        motion->state = newState;\n        motion->parent = m;\n        updateExplorationEfficiency(motion);\n        nn_->add(motion);\n        return motion;\n    }\n    else\n    {\n        si_->freeState(newState);\n        inefficientCount_++;\n        return nullptr;\n    }\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":401598,"func":"u64 get_random_u64(void)\n{\n\tu64 ret;\n\tunsigned long flags;\n\tstruct batched_entropy *batch;\n\tstatic void *previous;\n\n\twarn_unseeded_randomness(&previous);\n\n\tbatch = raw_cpu_ptr(&batched_entropy_u64);\n\tspin_lock_irqsave(&batch->batch_lock, flags);\n\tif (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) {\n\t\textract_crng((u8 *)batch->entropy_u64);\n\t\tbatch->position = 0;\n\t}\n\tret = batch->entropy_u64[batch->position++];\n\tspin_unlock_irqrestore(&batch->batch_lock, flags);\n\treturn ret;\n}","target":0,"code_token_length":144,"total_token_length":380,"max_tokens_setting":512}
+{"idx":247366,"func":"char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)\n{\n    char *buf = NULL, *val = NULL;\n    char *enc = rpmBase64Encode(s, ns, -1);\n    char *crc = rpmBase64CRC(s, ns);\n    const char *valstr = pgpValStr(pgpArmorTbl, atype);\n\n    if (crc != NULL && enc != NULL) {\n\trasprintf(&buf, \"%s=%s\", enc, crc);\n    }\n    free(crc);\n    free(enc);\n\n    rasprintf(&val, \"-----BEGIN PGP %s-----\\nVersion: rpm-\" VERSION \" (NSS-3)\\n\\n\"\n\t\t    \"%s\\n-----END PGP %s-----\\n\",\n\t\t    valstr, buf != NULL ? buf : \"\", valstr);\n\n    free(buf);\n    return val;\n}","target":0,"code_token_length":188,"total_token_length":424,"max_tokens_setting":512}
+{"idx":409502,"func":"term_delete_lines(int line_count)\n{\n    OUT_STR(tgoto((char *)T_CDL, 0, line_count));\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":382796,"func":"static void gdFreeDynamicCtx (struct gdIOCtx *ctx)\n{\n\tdynamicPtr *dp;\n\tdpIOCtx *dctx;\n\n\tdctx = (dpIOCtx *) ctx;\n\tdp = dctx->dp;\n\n\tgdFree(ctx);\n\n\tdp->realSize = 0;\n\tdp->logicalSize = 0;\n\n\tgdFree(dp);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":279912,"func":"not_writing(void)\n{\n    if (p_write)\n\treturn FALSE;\n    emsg(_(e_file_not_written_writing_is_disabled_by_write_option));\n    return TRUE;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":439172,"func":"static inline double GetFITSPixel(Image *image,int bits_per_pixel)\n{\n  switch (image->depth >> 3)\n  {\n    case 1:\n      return((double) ReadBlobByte(image));\n    case 2:\n      return((double) ((short) ReadBlobShort(image)));\n    case 4:\n    {\n      if (bits_per_pixel > 0)\n        return((double) ReadBlobSignedLong(image));\n      return((double) ReadBlobFloat(image));\n    }\n    case 8:\n    {\n      if (bits_per_pixel > 0)\n        return((double) ((MagickOffsetType) ReadBlobLongLong(image)));\n    }\n    default:\n      break;\n  }\n  return(ReadBlobDouble(image));\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":223094,"func":"static MagickBooleanType IsPCL(const unsigned char *magick,const size_t length)\n{\n  if (length < 4)\n    return(MagickFalse);\n  if (memcmp(magick,\"\\033E\\033&\",4) == 0)\n    return(MagickFalse);\n  if (memcmp(magick,\"\\033E\\033\",3) == 0)\n    return(MagickTrue);\n  return(MagickFalse);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":346423,"func":"ex_options(\n    exarg_T\t*eap UNUSED)\n{\n    char_u  buf[500];\n    int\t    multi_mods = 0;\n\n    buf[0] = NUL;\n    (void)add_win_cmd_modifers(buf, &cmdmod, &multi_mods);\n\n    vim_setenv((char_u *)\"OPTWIN_CMD\", buf);\n    cmd_source((char_u *)SYS_OPTWIN_FILE, NULL);\n}","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":512319,"func":"  longlong val_datetime_packed(THD *thd)\n  {\n    if (check_null_ref())\n      return 0;\n    else\n      return Item_direct_ref::val_datetime_packed(thd);\n  }","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":411917,"func":"_compare_tor_version_str_ptr(const void **_a, const void **_b)\n{\n  const char *a = *_a, *b = *_b;\n  int ca, cb;\n  tor_version_t va, vb;\n  ca = tor_version_parse(a, &va);\n  cb = tor_version_parse(b, &vb);\n  \/* If they both parse, compare them. *\/\n  if (!ca && !cb)\n    return tor_version_compare(&va,&vb);\n  \/* If one parses, it comes first. *\/\n  if (!ca && cb)\n    return -1;\n  if (ca && !cb)\n    return 1;\n  \/* If neither parses, compare strings.  Also, the directory server admin\n  ** needs to be smacked upside the head.  But Tor is tolerant and gentle. *\/\n  return strcmp(a,b);\n}","target":0,"code_token_length":179,"total_token_length":415,"max_tokens_setting":512}
+{"idx":289334,"func":"static int lock_params(struct snd_pcm_runtime *runtime)\n{\n\tif (mutex_lock_interruptible(&runtime->oss.params_lock))\n\t\treturn -ERESTARTSYS;\n\tif (atomic_read(&runtime->oss.rw_ref)) {\n\t\tmutex_unlock(&runtime->oss.params_lock);\n\t\treturn -EBUSY;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":505646,"func":"bool smtp_command_parser_pending_data(struct smtp_command_parser *parser)\n{\n\tif (parser->data == NULL)\n\t\treturn FALSE;\n\treturn i_stream_have_bytes_left(parser->data);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":289313,"func":"snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params,\n\t\t\t   snd_pcm_hw_param_t var, int *dir)\n{\n\tif (hw_is_mask(var)) {\n\t\tif (dir)\n\t\t\t*dir = 0;\n\t\treturn snd_mask_max(hw_param_mask_c(params, var));\n\t}\n\tif (hw_is_interval(var)) {\n\t\tconst struct snd_interval *i = hw_param_interval_c(params, var);\n\t\tif (dir)\n\t\t\t*dir = - (int) i->openmax;\n\t\treturn snd_interval_max(i);\n\t}\n\treturn -EINVAL;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":379685,"func":"static const char *get_regname(RAnal *anal, RAnalValue *value) {\n\tconst char *name = NULL;\n\tif (value && value->reg && value->reg->name) {\n\t\tname = value->reg->name;\n\t\tRRegItem *ri = r_reg_get (anal->reg, value->reg->name, -1);\n\t\tif (ri && (ri->size == 32) && (anal->bits == 64)) {\n\t\t\tname = r_reg_32_to_64 (anal->reg, value->reg->name);\n\t\t}\n\t}\n\treturn name;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":406208,"func":"static void success_message(struct libmnt_context *cxt)\n{\n\tunsigned long mflags = 0;\n\tconst char *tgt, *src;\n\n\tif (mnt_context_helper_executed(cxt)\n\t    || mnt_context_get_status(cxt) != 1)\n\t\treturn;\n\n\tmnt_context_get_mflags(cxt, &mflags);\n\ttgt = mnt_context_get_target(cxt);\n\tsrc = mnt_context_get_source(cxt);\n\n\tif (mflags & MS_MOVE)\n\t\twarnx(_(\"%s moved to %s\"), src, tgt);\n\telse if (mflags & MS_BIND)\n\t\twarnx(_(\"%s binded on %s\"), src, tgt);\n\telse if (mflags & MS_PROPAGATION)\n\t\twarnx(_(\"%s propagation flags changed\"), tgt);\n\telse\n\t\twarnx(_(\"%s mounted on %s\"), src, tgt);\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":261248,"func":"    int wm_SemFree(wm_Sem *s) {\n        vSemaphoreDelete(*s);\n        *s = NULL;\n        return 0;\n    }","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":234864,"func":"static void reset_balance_state(struct btrfs_fs_info *fs_info)\n{\n\tstruct btrfs_balance_control *bctl = fs_info->balance_ctl;\n\tint ret;\n\n\tBUG_ON(!fs_info->balance_ctl);\n\n\tspin_lock(&fs_info->balance_lock);\n\tfs_info->balance_ctl = NULL;\n\tspin_unlock(&fs_info->balance_lock);\n\n\tkfree(bctl);\n\tret = del_balance_item(fs_info);\n\tif (ret)\n\t\tbtrfs_handle_fs_error(fs_info, ret, NULL);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":473846,"func":"onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,\n                                      const OnigCodePoint* ranges[],\n\t\t\t\t      struct OnigEncodingTypeST* enc ARG_UNUSED)\n{\n  *sb_out = 0x00;\n  return onigenc_unicode_ctype_code_range(ctype, ranges);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":293776,"func":"static bool on_rebase_pointer(ut64 offset, ut64 decorated_addr, RRebaseCtx *ctx) {\n\tif (offset < ctx->off) {\n\t\treturn true;\n\t}\n\tif (offset >= ctx->eob) {\n\t\treturn false;\n\t}\n\tut64 in_buf = offset - ctx->off;\n\tif (in_buf >= ctx->count || (in_buf + 8) > ctx->count) {\n\t\treturn false;\n\t}\n\n\tRParsedPointer ptr;\n\tr_parse_pointer (&ptr, decorated_addr, ctx->obj);\n\n\tr_write_le64 (&ctx->buf[in_buf], ptr.address);\n\n\treturn true;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":226204,"func":"\nvoid leva_box_del(GF_Box *s)\n{\n\tGF_LevelAssignmentBox *ptr = (GF_LevelAssignmentBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->levels) gf_free(ptr->levels);\n\tgf_free(ptr);","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":384837,"func":"transchar_buf(buf_T *buf, int c)\n{\n    int\t\t\ti;\n\n    i = 0;\n    if (IS_SPECIAL(c))\t    \/\/ special key code, display as ~@ char\n    {\n\ttranschar_charbuf[0] = '~';\n\ttranschar_charbuf[1] = '@';\n\ti = 2;\n\tc = K_SECOND(c);\n    }\n\n    if ((!chartab_initialized && ((c >= ' ' && c <= '~')))\n\t\t\t\t\t|| (c < 256 && vim_isprintc_strict(c)))\n    {\n\t\/\/ printable character\n\ttranschar_charbuf[i] = c;\n\ttranschar_charbuf[i + 1] = NUL;\n    }\n    else\n\ttranschar_nonprint(buf, transchar_charbuf + i, c);\n    return transchar_charbuf;\n}","target":0,"code_token_length":170,"total_token_length":406,"max_tokens_setting":512}
+{"idx":224736,"func":"GF_Err ipro_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s;\n\tif (a->type == GF_ISOM_BOX_TYPE_SINF) {\n\t\tBOX_FIELD_LIST_ASSIGN(protection_information)\n\t\treturn GF_OK;\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":76,"total_token_length":312,"max_tokens_setting":512}
+{"idx":227009,"func":"IRC_PROTOCOL_CALLBACK(438)\n{\n    struct t_gui_buffer *ptr_buffer;\n\n    IRC_PROTOCOL_MIN_ARGS(4);\n\n    ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,\n                                                  command, NULL, NULL);\n\n    if (argc >= 5)\n    {\n        weechat_printf_date_tags (\n            ptr_buffer,\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s (%s => %s)\",\n            weechat_prefix (\"network\"),\n            (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4],\n            argv[2],\n            argv[3]);\n    }\n    else\n    {\n        weechat_printf_date_tags (\n            ptr_buffer,\n            date,\n            irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n            \"%s%s %s\",\n            weechat_prefix (\"network\"),\n            argv[2],\n            argv[3]);\n    }\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":219,"total_token_length":455,"max_tokens_setting":512}
+{"idx":343231,"func":"static void sigterm_client(int sig)\n{\n    (void) sig;\n\n    disablesignals();\n    _EXIT(EXIT_SUCCESS);\n}","target":0,"code_token_length":27,"total_token_length":263,"max_tokens_setting":512}
+{"idx":385796,"func":"static inline int should_follow_link(struct inode *inode, int follow)\n{\n\tif (unlikely(!(inode->i_opflags & IOP_NOFOLLOW))) {\n\t\tif (likely(inode->i_op->follow_link))\n\t\t\treturn follow;\n\n\t\t\/* This gets set once for the inode lifetime *\/\n\t\tspin_lock(&inode->i_lock);\n\t\tinode->i_opflags |= IOP_NOFOLLOW;\n\t\tspin_unlock(&inode->i_lock);\n\t}\n\treturn 0;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":448916,"func":"local int inflateStateCheck(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n    if (strm == Z_NULL ||\n        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)\n        return 1;\n    state = (struct inflate_state FAR *)strm->state;\n    if (state == Z_NULL || state->strm != strm ||\n        state->mode < HEAD || state->mode > SYNC)\n        return 1;\n    return 0;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":446106,"func":"static int atusb_ed(struct ieee802154_hw *hw, u8 *level)\n{\n\tWARN_ON(!level);\n\t*level = 0xbe;\n\treturn 0;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":300757,"func":"static int __tipc_nl_add_sk_info(struct sk_buff *skb, struct tipc_sock\n\t\t\t  *tsk)\n{\n\tstruct net *net = sock_net(skb->sk);\n\tstruct sock *sk = &tsk->sk;\n\n\tif (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) ||\n\t    nla_put_u32(skb, TIPC_NLA_SOCK_ADDR, tipc_own_addr(net)))\n\t\treturn -EMSGSIZE;\n\n\tif (tipc_sk_connected(sk)) {\n\t\tif (__tipc_nl_add_sk_con(skb, tsk))\n\t\t\treturn -EMSGSIZE;\n\t} else if (!list_empty(&tsk->publications)) {\n\t\tif (nla_put_flag(skb, TIPC_NLA_SOCK_HAS_PUBL))\n\t\t\treturn -EMSGSIZE;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":328976,"func":"R_API RBinJavaStackMapFrameMetas *r_bin_java_determine_stack_frame_type(ut8 tag) {\n\tut8 type_value = 0;\n\tif (tag < 64) {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_SAME;\n\t} else if (tag < 128) {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_SAME_LOCALS_1;\n\t} else if (247 < tag && tag < 251) {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_CHOP;\n\t} else if (tag == 251) {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_SAME_FRAME_EXTENDED;\n\t} else if (251 < tag && tag < 255) {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_APPEND;\n\t} else if (tag == 255) {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_FULL_FRAME;\n\t} else {\n\t\ttype_value = R_BIN_JAVA_STACK_FRAME_RESERVED;\n\t}\n\treturn &R_BIN_JAVA_STACK_MAP_FRAME_METAS[type_value];\n}","target":0,"code_token_length":236,"total_token_length":472,"max_tokens_setting":512}
+{"idx":244361,"func":"GF_Box *ihdr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_J2KImageHeaderBox, GF_ISOM_BOX_TYPE_IHDR);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":328861,"func":"R_API void r_bin_java_print_fieldref_cp_summary(RBinJavaCPTypeObj *obj) {\n\tif (!obj) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaCPTypeObj*  FieldRef.\\n\");\n\t\treturn;\n\t}\n\teprintf (\"FieldRef ConstantPool Type (%d) \", obj->metas->ord);\n\teprintf (\"\tOffset: 0x%08\"PFMT64x\"\", obj->file_offset);\n\teprintf (\"\tClass Index = %d\\n\", obj->info.cp_field.class_idx);\n\teprintf (\"\tName and type Index = %d\\n\", obj->info.cp_field.name_and_type_idx);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":317223,"func":"static void selinux_inode_invalidate_secctx(struct inode *inode)\n{\n\tstruct inode_security_struct *isec = selinux_inode(inode);\n\n\tspin_lock(&isec->lock);\n\tisec->initialized = LABEL_INVALID;\n\tspin_unlock(&isec->lock);\n}","target":0,"code_token_length":53,"total_token_length":289,"max_tokens_setting":512}
+{"idx":474062,"func":"gb18030_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)\n{\n  return onigenc_mb4_is_code_ctype(enc, code, ctype);\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":226129,"func":"\nGF_Err stri_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 i;\n\tGF_SubTrackInformationBox *ptr = (GF_SubTrackInformationBox *)s;\n\te = gf_isom_full_box_write(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u16(bs, ptr->switch_group);\n\tgf_bs_write_u16(bs, ptr->alternate_group);\n\tgf_bs_write_u32(bs, ptr->sub_track_id);\n\tfor (i = 0; i < ptr->attribute_count; i++) {\n\t\tgf_bs_write_u32(bs, ptr->attribute_list[i]);\n\t}\n\treturn GF_OK;","target":0,"code_token_length":149,"total_token_length":385,"max_tokens_setting":512}
+{"idx":225113,"func":"void RemoveDescriptionsFromOpList(OpList* op_list) {\n  for (int i = 0; i < op_list->op_size(); ++i) {\n    OpDef* op_def = op_list->mutable_op(i);\n    RemoveDescriptionsFromOpDef(op_def);\n  }\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":514312,"func":"multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,\n                           List<TABLE_LIST> *leaves_list,\n\t\t\t   List<Item> *field_list, List<Item> *value_list,\n\t\t\t   enum enum_duplicates handle_duplicates_arg,\n                           bool ignore_arg):\n   select_result_interceptor(thd_arg),\n   all_tables(table_list), leaves(leaves_list), update_tables(0),\n   tmp_tables(0), updated(0), found(0), fields(field_list),\n   values(value_list), table_count(0), copy_field(0),\n   handle_duplicates(handle_duplicates_arg), do_update(1), trans_safe(1),\n   transactional_tables(0), ignore(ignore_arg), error_handled(0), prepared(0),\n   updated_sys_ver(0)\n{\n}","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":222852,"func":"bool GraphProperties::HasOutputProperties(const string& node_name) const {\n  return output_properties_.find(node_name) != output_properties_.end();\n}","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":395067,"func":"redraw_buf_later(buf_T *buf, int type)\n{\n    win_T\t*wp;\n\n    FOR_ALL_WINDOWS(wp)\n    {\n\tif (wp->w_buffer == buf)\n\t    redraw_win_later(wp, type);\n    }\n#if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP)\n    \/\/ terminal in popup window is not in list of windows\n    if (curwin->w_buffer == buf)\n\tredraw_win_later(curwin, type);\n#endif\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":384889,"func":"f_fnamemodify(typval_T *argvars, typval_T *rettv)\n{\n    char_u\t*fname;\n    char_u\t*mods;\n    int\t\tusedlen = 0;\n    int\t\tlen = 0;\n    char_u\t*fbuf = NULL;\n    char_u\tbuf[NUMBUFLEN];\n\n    if (in_vim9script()\n\t    && (check_for_string_arg(argvars, 0) == FAIL\n\t\t|| check_for_string_arg(argvars, 1) == FAIL))\n\treturn;\n\n    fname = tv_get_string_chk(&argvars[0]);\n    mods = tv_get_string_buf_chk(&argvars[1], buf);\n    if (mods == NULL || fname == NULL)\n\tfname = NULL;\n    else\n    {\n\tlen = (int)STRLEN(fname);\n\tif (mods != NULL && *mods != NUL)\n\t    (void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len);\n    }\n\n    rettv->v_type = VAR_STRING;\n    if (fname == NULL)\n\trettv->vval.v_string = NULL;\n    else\n\trettv->vval.v_string = vim_strnsave(fname, len);\n    vim_free(fbuf);\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":226230,"func":"\nGF_Err prhd_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_ProjectionHeaderBox *ptr = (GF_ProjectionHeaderBox *)s;\n\tISOM_DECREASE_SIZE(ptr, 12)\n\tptr->yaw = (s32) gf_bs_read_u32(bs);\n\tptr->pitch = (s32) gf_bs_read_u32(bs);\n\tptr->roll = (s32) gf_bs_read_u32(bs);\n\treturn GF_OK;","target":0,"code_token_length":106,"total_token_length":342,"max_tokens_setting":512}
+{"idx":463124,"func":"static void annotation_get_usermodseq(annotate_state_t *state,\n                                      struct annotate_entry_list *entry)\n{\n    struct buf value = BUF_INITIALIZER;\n    struct mboxname_counters counters;\n    char *mboxname = NULL;\n\n    memset(&counters, 0, sizeof(struct mboxname_counters));\n\n    assert(state);\n    assert(state->userid);\n\n    mboxname = mboxname_user_mbox(state->userid, NULL);\n    mboxname_read_counters(mboxname, &counters);\n\n    buf_printf(&value, \"%llu\", counters.highestmodseq);\n\n    output_entryatt(state, entry->name, state->userid, &value);\n    free(mboxname);\n    buf_free(&value);\n}","target":0,"code_token_length":145,"total_token_length":381,"max_tokens_setting":512}
+{"idx":233837,"func":"void fmtutil_read_iff_format(deark *c, struct de_iffctx *ictx,\n\ti64 pos, i64 len)\n{\n\tif(!ictx->f || !ictx->handle_chunk_fn) return; \/\/ Internal error\n\n\tictx->level = 0;\n\tfourcc_clear(&ictx->main_fmt4cc);\n\tfourcc_clear(&ictx->main_contentstype4cc);\n\tfourcc_clear(&ictx->curr_container_fmt4cc);\n\tfourcc_clear(&ictx->curr_container_contentstype4cc);\n\tif(ictx->alignment==0) {\n\t\tictx->alignment = 2;\n\t}\n\tif(ictx->sizeof_len==0) {\n\t\tictx->sizeof_len = 4;\n\t}\n\n\tif(ictx->input_encoding==DE_ENCODING_UNKNOWN) {\n\t\tictx->input_encoding = DE_ENCODING_ASCII;\n\t}\n\n\tdo_iff_chunk_sequence(c, ictx, pos, len, 0);\n}","target":0,"code_token_length":207,"total_token_length":443,"max_tokens_setting":512}
+{"idx":498627,"func":"apply_colormap (guchar       *dest,\n                const guchar *src,\n                guint         width,\n                const guchar *cmap,\n                gboolean      alpha,\n                guint16       index)\n{\n  guint x;\n\n  if (alpha)\n    {\n      for (x = 0; x < width; x++)\n        {\n          *(dest++) = cmap[(*src - index) * 4];\n          *(dest++) = cmap[(*src - index) * 4 + 1];\n          *(dest++) = cmap[(*src - index) * 4 + 2];\n          *(dest++) = cmap[(*src - index) * 4 + 3];\n\n          src++;\n        }\n    }\n  else\n    {\n      for (x = 0; x < width; x++)\n        {\n          *(dest++) = cmap[(*src - index) * 3];\n          *(dest++) = cmap[(*src - index) * 3 + 1];\n          *(dest++) = cmap[(*src - index) * 3 + 2];\n\n          src++;\n        }\n    }\n}","target":0,"code_token_length":233,"total_token_length":469,"max_tokens_setting":512}
+{"idx":224592,"func":"Status MaxPoolShape(shape_inference::InferenceContext* c) {\n  return MaxPoolShapeImpl(c, \/*supports_explicit_padding=*\/false);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":369338,"func":"static int io_shutdown(struct io_kiocb *req, unsigned int issue_flags)\n{\n#if defined(CONFIG_NET)\n\tstruct socket *sock;\n\tint ret;\n\n\tif (issue_flags & IO_URING_F_NONBLOCK)\n\t\treturn -EAGAIN;\n\n\tsock = sock_from_file(req->file);\n\tif (unlikely(!sock))\n\t\treturn -ENOTSOCK;\n\n\tret = __sys_shutdown_sock(sock, req->shutdown.how);\n\tif (ret < 0)\n\t\treq_set_fail(req);\n\tio_req_complete(req, ret);\n\treturn 0;\n#else\n\treturn -EOPNOTSUPP;\n#endif\n}","target":0,"code_token_length":123,"total_token_length":359,"max_tokens_setting":512}
+{"idx":384820,"func":"skiptobin(char_u *q)\n{\n    char_u\t*p = q;\n\n    while (*p != NUL && !vim_isbdigit(*p))\t\/\/ skip to next digit\n\t++p;\n    return p;\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":269319,"func":"static av_always_inline void snow_horizontal_compose_liftS_lead_out(int i, IDWTELEM * dst, IDWTELEM * src, IDWTELEM * ref, int width, int w){\n        for(; i<w; i++){\n            dst[i] = src[i] + ((ref[i] + ref[(i+1)]+W_BO + 4 * src[i]) >> W_BS);\n        }\n\n        if(width&1){\n            dst[w] = src[w] + ((2 * ref[w] + W_BO + 4 * src[w]) >> W_BS);\n        }\n}","target":0,"code_token_length":126,"total_token_length":362,"max_tokens_setting":512}
+{"idx":310127,"func":"quit(int status, const char *fmt, ...)\n{\n    va_list argp;\n\n    va_start(argp, fmt);\n    fprintf(stderr, \"%s: \", prg_name);\n    vfprintf(stderr, fmt, argp);\n    fprintf(stderr, \"\\n\");\n    va_end(argp);\n    ExitProgram(status);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":430456,"func":"static size_t get_ufid_len(const struct nlattr *attr, bool log)\n{\n\tsize_t len;\n\n\tif (!attr)\n\t\treturn 0;\n\n\tlen = nla_len(attr);\n\tif (len < 1 || len > MAX_UFID_LENGTH) {\n\t\tOVS_NLERR(log, \"ufid size %u bytes exceeds the range (1, %d)\",\n\t\t\t  nla_len(attr), MAX_UFID_LENGTH);\n\t\treturn 0;\n\t}\n\n\treturn len;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":477281,"func":"static void tipc_aead_users_dec(struct tipc_aead __rcu *aead, int lim)\n{\n\tstruct tipc_aead *tmp;\n\n\trcu_read_lock();\n\ttmp = rcu_dereference(aead);\n\tif (tmp)\n\t\tatomic_add_unless(&rcu_dereference(aead)->users, -1, lim);\n\trcu_read_unlock();\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":210887,"func":"e1000_send_packet(E1000State *s, const uint8_t *buf, int size)\n{\n    static const int PTCregs[6] = { PTC64, PTC127, PTC255, PTC511,\n                                    PTC1023, PTC1522 };\n\n    NetClientState *nc = qemu_get_queue(s->nic);\n    if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) {\n        nc->info->receive(nc, buf, size);\n    } else {\n        qemu_send_packet(nc, buf, size);\n    }\n    inc_tx_bcast_or_mcast_count(s, buf);\n    e1000x_increase_size_stats(s->mac_reg, PTCregs, size);\n}","target":1,"code_token_length":173,"total_token_length":409,"max_tokens_setting":512}
+{"idx":442571,"func":"static void test_memslot_invalid_group_id(void)\n{\n    RedMemSlotInfo mem_info;\n    init_meminfo(&mem_info);\n\n    memslot_get_virt(&mem_info, 0, 16, 1);\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":336629,"func":"void stat_remove_counter(SpiceServer *reds, RedStatCounter *counter)\n{\n    if (counter->counter) {\n        stat_file_remove_counter(reds->stat_file, counter->counter);\n        counter->counter = NULL;\n    }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":232298,"func":"\nGF_Box *gf_isom_box_find_child(GF_List *children, u32 code)\n{\n\tu32 i, count;\n\tif (!children) return NULL;\n\tcount = gf_list_count(children);\n\tfor (i=0; i<count; i++) {\n\t\tGF_Box *c = gf_list_get(children, i);\n\t\tif (c->type==code) return c;\n\n\t\tif (c->type==GF_ISOM_BOX_TYPE_UNKNOWN) {\n\t\t\tif (((GF_UnknownBox*)c)->original_4cc==code)\n\t\t\t\treturn c;\n\t\t}\n\t\tif (c->type==GF_ISOM_BOX_TYPE_UUID) {\n\t\t\tif (((GF_UUIDBox*)c)->internal_4cc==code)\n\t\t\t\treturn c;\n\t\t}\n\t}\n\treturn NULL;","target":0,"code_token_length":163,"total_token_length":399,"max_tokens_setting":512}
+{"idx":338091,"func":"Signature WasmBinaryBuilder::getSignatureByFunctionIndex(Index index) {\n  auto heapType = getTypeByFunctionIndex(index);\n  if (!heapType.isSignature()) {\n    throwError(\"invalid signature type \" + heapType.toString());\n  }\n  return heapType.getSignature();\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":220237,"func":"Status Node::input_node(int idx, const Node** const_n) const {\n  Node* n;\n  TF_RETURN_IF_ERROR(input_node(idx, &n));\n  *const_n = n;\n  return Status::OK();\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":508395,"func":"  MDL_deadlock_handler(Open_table_context *ot_ctx_arg)\n    : m_ot_ctx(ot_ctx_arg), m_is_active(FALSE)\n  {}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":231663,"func":"  std::unique_ptr<QuicReadCodec> makeClientEncryptedCodec(\n      bool handshakeCipher = false) {\n    FizzCryptoFactory cryptoFactory;\n    auto readCodec = std::make_unique<QuicReadCodec>(QuicNodeType::Client);\n    readCodec->setOneRttReadCipher(test::createNoOpAead());\n    readCodec->setOneRttHeaderCipher(test::createNoOpHeaderCipher());\n    readCodec->setHandshakeReadCipher(test::createNoOpAead());\n    readCodec->setHandshakeHeaderCipher(test::createNoOpHeaderCipher());\n    readCodec->setClientConnectionId(*clientConnectionId);\n    readCodec->setCodecParameters(\n        CodecParameters(kDefaultAckDelayExponent, QuicVersion::MVFST));\n    if (handshakeCipher) {\n      readCodec->setInitialReadCipher(cryptoFactory.getServerInitialCipher(\n          *initialDestinationConnectionId, QuicVersion::MVFST));\n      readCodec->setInitialHeaderCipher(\n          cryptoFactory.makeServerInitialHeaderCipher(\n              *initialDestinationConnectionId, QuicVersion::MVFST));\n    }\n    return readCodec;\n  }","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":317059,"func":"static void selinux_ib_free_security(void *ib_sec)\n{\n\tkfree(ib_sec);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":267954,"func":"static RBinClass *__getClass(RBinFile *bf, const char *name) {\n\tr_return_val_if_fail (bf && bf->o && bf->o->classes_ht && name, NULL);\n\treturn ht_pp_find (bf->o->classes_ht, name, NULL);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":386501,"func":"void DL_Dxf::writeSpline(DL_WriterA& dw,\n                         const DL_SplineData& data,\n                         const DL_Attributes& attrib) {\n\n    dw.entity(\"SPLINE\");\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbEntity\");\n    }\n    dw.entityAttributes(attrib);\n    if (version==DL_VERSION_2000) {\n        dw.dxfString(100, \"AcDbSpline\");\n    }\n    dw.dxfInt(70, data.flags);\n    dw.dxfInt(71, data.degree);\n    dw.dxfInt(72, data.nKnots);            \/\/ number of knots\n    dw.dxfInt(73, data.nControl);          \/\/ number of control points\n    dw.dxfInt(74, data.nFit);              \/\/ number of fit points\n}","target":0,"code_token_length":198,"total_token_length":434,"max_tokens_setting":512}
+{"idx":450433,"func":"int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)\n{\n    vs->zrle->type = VNC_ENCODING_ZRLE;\n    return zrle_send_framebuffer_update(vs, x, y, w, h);\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":432710,"func":"static void draw_fill_color_rgb( wmfAPI* API, const wmfRGB* rgb )\n{\n  PixelWand\n    *fill_color;\n\n  fill_color=NewPixelWand();\n  PixelSetRedQuantum(fill_color,ScaleCharToQuantum(rgb->r));\n  PixelSetGreenQuantum(fill_color,ScaleCharToQuantum(rgb->g));\n  PixelSetBlueQuantum(fill_color,ScaleCharToQuantum(rgb->b));\n  PixelSetAlphaQuantum(fill_color,OpaqueAlpha);\n  DrawSetFillColor(WmfDrawingWand,fill_color);\n  fill_color=DestroyPixelWand(fill_color);\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":387741,"func":"jint InstanceKlass::compute_modifier_flags(TRAPS) const {\n  jint access = access_flags().as_int();\n\n  \/\/ But check if it happens to be member class.\n  InnerClassesIterator iter(this);\n  for (; !iter.done(); iter.next()) {\n    int ioff = iter.inner_class_info_index();\n    \/\/ Inner class attribute can be zero, skip it.\n    \/\/ Strange but true:  JVM spec. allows null inner class refs.\n    if (ioff == 0) continue;\n\n    \/\/ only look at classes that are already loaded\n    \/\/ since we are looking for the flags for our self.\n    Symbol* inner_name = constants()->klass_name_at(ioff);\n    if (name() == inner_name) {\n      \/\/ This is really a member class.\n      access = iter.inner_access_flags();\n      break;\n    }\n  }\n  \/\/ Remember to strip ACC_SUPER bit\n  return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS;\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":101702,"func":"WebProcessProxy::~WebProcessProxy()\n{\n    if (m_webConnection)\n        m_webConnection->invalidate();\n}\n","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":256418,"func":"PJ_DEF(void) pjmedia_rtcp_fb_setting_dup( pj_pool_t *pool,\n\t\t\t\t\t  pjmedia_rtcp_fb_setting *dst,\n\t\t\t\t\t  const pjmedia_rtcp_fb_setting *src)\n{\n    unsigned i;\n\n    pj_assert(pool && dst && src);\n\n    pj_memcpy(dst, src, sizeof(pjmedia_rtcp_fb_setting));\n    for (i = 0; i < src->cap_count; ++i) {\n\tpjmedia_rtcp_fb_cap_dup(pool, &dst->caps[i], &src->caps[i]);\n    }\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":417092,"func":"bool PlayerGeneric::isIdle() const\n{\n\tif (player)\n\t\treturn player->isIdle();\n\t\t\n\treturn idle;\n}","target":0,"code_token_length":26,"total_token_length":262,"max_tokens_setting":512}
+{"idx":389546,"func":"xmlInitParser(void) {\n    if (xmlParserInitialized != 0)\n\treturn;\n\n#ifdef LIBXML_THREAD_ENABLED\n    __xmlGlobalInitMutexLock();\n    if (xmlParserInitialized == 0) {\n#endif\n\txmlInitThreads();\n\txmlInitGlobals();\n\tif ((xmlGenericError == xmlGenericErrorDefaultFunc) ||\n\t    (xmlGenericError == NULL))\n\t    initGenericErrorDefaultFunc(NULL);\n\txmlInitMemory();\n\txmlInitCharEncodingHandlers();\n\txmlDefaultSAXHandlerInit();\n\txmlRegisterDefaultInputCallbacks();\n#ifdef LIBXML_OUTPUT_ENABLED\n\txmlRegisterDefaultOutputCallbacks();\n#endif \/* LIBXML_OUTPUT_ENABLED *\/\n#ifdef LIBXML_HTML_ENABLED\n\thtmlInitAutoClose();\n\thtmlDefaultSAXHandlerInit();\n#endif\n#ifdef LIBXML_XPATH_ENABLED\n\txmlXPathInit();\n#endif\n\txmlParserInitialized = 1;\n#ifdef LIBXML_THREAD_ENABLED\n    }\n    __xmlGlobalInitMutexUnlock();\n#endif\n}","target":0,"code_token_length":183,"total_token_length":419,"max_tokens_setting":512}
+{"idx":473934,"func":"big5_is_mbc_ambiguous(OnigCaseFoldType flag,\n\t\t      const UChar** pp, const UChar* end, OnigEncoding enc)\n{\n  return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end);\n}","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":482466,"func":"appendInstructionChar(\n\t\tconst FileInfo *file, widechar *passInstructions, int *passIC, widechar ch) {\n\tif (*passIC >= MAXSTRING) {\n\t\tcompileError(file, \"multipass operand too long\");\n\t\treturn 0;\n\t}\n\tpassInstructions[(*passIC)++] = ch;\n\treturn 1;\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":513035,"func":"  Item_ref(THD *thd, Name_resolution_context *context_arg,\n           const char *db_arg, const char *table_name_arg,\n           const LEX_CSTRING *field_name_arg):\n    Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg),\n    set_properties_only(0), ref(0), reference_trough_name(1) {}","target":0,"code_token_length":81,"total_token_length":317,"max_tokens_setting":512}
+{"idx":253523,"func":"smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,\n\t\t    struct cifs_fid *fid, __u16 search_flags,\n\t\t    struct cifs_search_info *srch_inf)\n{\n\treturn SMB2_query_directory(xid, tcon, fid->persistent_fid,\n\t\t\t\t    fid->volatile_fid, 0, srch_inf);\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":312578,"func":"qf_parse_fmt_r(regmatch_T *rmp, int midx, char_u **tail)\n{\n    if (rmp->startp[midx] == NULL)\n\treturn QF_FAIL;\n    *tail = rmp->startp[midx];\n    return QF_OK;\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":312538,"func":"qf_setprop_context(qf_list_T *qfl, dictitem_T *di)\n{\n    typval_T\t*ctx;\n\n    free_tv(qfl->qf_ctx);\n    ctx =  alloc_tv();\n    if (ctx != NULL)\n\tcopy_tv(&di->di_tv, ctx);\n    qfl->qf_ctx = ctx;\n\n    return OK;\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":359314,"func":"peer_port_vty (struct vty *vty, const char *ip_str, int afi, \n               const char *port_str)\n{\n  struct peer *peer;\n  u_int16_t port;\n  struct servent *sp;\n\n  peer = peer_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  if (! port_str)\n    { \n      sp = getservbyname (\"bgp\", \"tcp\");\n      port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);\n    }\n  else\n    {\n      VTY_GET_INTEGER(\"port\", port, port_str);\n    }\n\n  peer_port_set (peer, port);\n\n  return CMD_SUCCESS;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":400769,"func":"size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes,\n\t\t\t struct iov_iter *i)\n{\n\tif (unlikely(!page_copy_sane(page, offset, bytes)))\n\t\treturn 0;\n\tif (likely(iter_is_iovec(i)))\n\t\treturn copy_page_from_iter_iovec(page, offset, bytes, i);\n\tif (iov_iter_is_bvec(i) || iov_iter_is_kvec(i) || iov_iter_is_xarray(i)) {\n\t\tvoid *kaddr = kmap_local_page(page);\n\t\tsize_t wanted = _copy_from_iter(kaddr + offset, bytes, i);\n\t\tkunmap_local(kaddr);\n\t\treturn wanted;\n\t}\n\tWARN_ON(1);\n\treturn 0;\n}","target":0,"code_token_length":152,"total_token_length":388,"max_tokens_setting":512}
+{"idx":276973,"func":"ReadSample(SampleReader&   reader, \n           AP4_Track&      track,\n           AP4_Sample&     sample,\n           AP4_DataBuffer& sample_data, \n           double&         ts,\n           double&         duration,\n           bool&           eos)\n{\n    AP4_Result result = reader.ReadSample(sample, sample_data);\n    if (AP4_FAILED(result)) {\n        if (result == AP4_ERROR_EOS) {\n            \/\/ advance the timestamp by the last sample's duration\n            ts += duration;\n            eos = true;\n            return AP4_SUCCESS;\n        } else {\n            return result;\n        }\n    }\n    ts = (double)sample.GetDts()\/(double)track.GetMediaTimeScale();\n    duration = sample.GetDuration()\/(double)track.GetMediaTimeScale();\n    \n    return AP4_SUCCESS;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":309943,"func":"onsig(int n GCC_UNUSED)\n{\n    interrupted = TRUE;\n}","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":508799,"func":"bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)\n{\n  return index_hints->push_front(new (thd->mem_root) \n                                 Index_hint(current_index_hint_type,\n                                            current_index_hint_clause,\n                                            str, length), thd->mem_root);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":225901,"func":"\nvoid fecr_box_del(GF_Box *s)\n{\n\tFECReservoirBox *ptr = (FECReservoirBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->entries) gf_free(ptr->entries);\n\tgf_free(ptr);","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":307864,"func":"void ciEnv::dump_replay_data_unsafe(outputStream* out) {\n  ResourceMark rm;\n#if INCLUDE_JVMTI\n  out->print_cr(\"JvmtiExport can_access_local_variables %d\",     _jvmti_can_access_local_variables);\n  out->print_cr(\"JvmtiExport can_hotswap_or_post_breakpoint %d\", _jvmti_can_hotswap_or_post_breakpoint);\n  out->print_cr(\"JvmtiExport can_post_on_exceptions %d\",         _jvmti_can_post_on_exceptions);\n#endif \/\/ INCLUDE_JVMTI\n\n  GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata();\n  out->print_cr(\"# %d ciObject found\", objects->length());\n  for (int i = 0; i < objects->length(); i++) {\n    objects->at(i)->dump_replay_data(out);\n  }\n  dump_compile_data(out);\n  out->flush();\n}","target":0,"code_token_length":205,"total_token_length":441,"max_tokens_setting":512}
+{"idx":223397,"func":"static SLJIT_INLINE void add_prefix_char(PCRE2_UCHAR chr, fast_forward_char_data *chars, BOOL last)\n{\nsljit_u32 i, count = chars->count;\n\nif (count == 255)\n  return;\n\nif (count == 0)\n  {\n  chars->count = 1;\n  chars->chars[0] = chr;\n\n  if (last)\n    chars->last_count = 1;\n  return;\n  }\n\nfor (i = 0; i < count; i++)\n  if (chars->chars[i] == chr)\n    return;\n\nif (count >= MAX_DIFF_CHARS)\n  {\n  chars->count = 255;\n  return;\n  }\n\nchars->chars[count] = chr;\nchars->count = count + 1;\n\nif (last)\n  chars->last_count++;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":265450,"func":"static int sqfs_count_metablks(void *table, u32 offset, int table_size)\n{\n\tint count = 0, cur_size = 0, ret;\n\tu32 data_size;\n\tbool comp;\n\n\tdo {\n\t\tret = sqfs_read_metablock(table, offset + cur_size, &comp,\n\t\t\t\t\t  &data_size);\n\t\tif (ret)\n\t\t\treturn -EINVAL;\n\t\tcur_size += data_size + SQFS_HEADER_SIZE;\n\t\tcount++;\n\t} while (cur_size < table_size);\n\n\treturn count;\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":387587,"func":"static size_t compute_user_elem_size(size_t size, unsigned int count)\n{\n\treturn sizeof(struct user_element) + size * count;\n}","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":219952,"func":"int callback_default (const struct _u_request * request, struct _u_response * response, void * user_data) {\n  UNUSED(request);\n  UNUSED(user_data);\n  json_t * json_body = json_pack(\"{ssss}\", \"error\", \"resource not found\", \"message\", \"no resource available at this address\");\n  ulfius_set_json_body_response(response, 404, json_body);\n  json_decref(json_body);\n  return U_CALLBACK_CONTINUE;\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":338040,"func":"void WasmBinaryBuilder::verifyInt8(int8_t x) {\n  int8_t y = getInt8();\n  if (x != y) {\n    throwError(\"surprising value\");\n  }\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":446409,"func":"RZ_API ut64 rz_dyldcache_va2pa(RzDyldCache *cache, uint64_t vaddr, ut32 *offset, ut32 *left) {\n\trz_return_val_if_fail(cache, UT64_MAX);\n\tut64 slide = rz_dyldcache_get_slide(cache);\n\tut64 res = va2pa(vaddr, cache->n_maps, cache->maps, cache->buf, slide, offset, left);\n\tif (res == UT64_MAX) {\n\t\tres = 0;\n\t}\n\treturn res;\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":229227,"func":"event::event_type parse_event_type(const sstring& value)\n{\n    if (value == \"TOPOLOGY_CHANGE\") {\n        return event::event_type::TOPOLOGY_CHANGE;\n    } else if (value == \"STATUS_CHANGE\") {\n        return event::event_type::STATUS_CHANGE;\n    } else if (value == \"SCHEMA_CHANGE\") {\n        return event::event_type::SCHEMA_CHANGE;\n    } else {\n        throw exceptions::protocol_exception(format(\"Invalid value '{}' for Event.Type\", value));\n    }\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":247623,"func":"TEST_P(SslSocketTest, X509ExtensionsCertificateSerialNumber) {\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/extensions_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/extensions_key.pem\"\n)EOF\";\n\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/extensions_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/extensions_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n  require_client_certificate: true\n)EOF\";\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam());\n  testUtil(test_options.setExpectedSerialNumber(TEST_EXTENSIONS_CERT_SERIAL));\n}","target":0,"code_token_length":249,"total_token_length":485,"max_tokens_setting":512}
+{"idx":253984,"func":"static int vidioc_g_std(struct file *file, void *private_data, v4l2_std_id *norm)\n{\n\tif (norm)\n\t\t*norm = V4L2_STD_ALL;\n\treturn 0;\n}","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":90895,"func":" void ClientUsageTracker::GetCachedOrigins(std::set<GURL>* origins) const {\n   DCHECK(origins);\n   for (HostUsageMap::const_iterator host_iter = cached_usage_.begin();\n       host_iter != cached_usage_.end(); host_iter++) {\n    const UsageMap& origin_map = host_iter->second;\n    for (UsageMap::const_iterator origin_iter = origin_map.begin();\n         origin_iter != origin_map.end(); origin_iter++) {\n      origins->insert(origin_iter->first);\n    }\n  }\n}\n","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":220108,"func":"static void __nfs42_ssc_close(struct file *filep)\n{\n\tstruct nfs_open_context *ctx = nfs_file_open_context(filep);\n\n\tctx->state->flags = 0;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":294686,"func":"date_s_jd(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE vjd, vsg, jd, fr, fr2, ret;\n    double sg;\n\n    rb_scan_args(argc, argv, \"02\", &vjd, &vsg);\n\n    jd = INT2FIX(0);\n    fr2 = INT2FIX(0);\n    sg = DEFAULT_SG;\n\n    switch (argc) {\n      case 2:\n\tval2sg(vsg, sg);\n      case 1:\n        check_numeric(vjd, \"jd\");\n\tnum2num_with_frac(jd, positive_inf);\n    }\n\n    {\n\tVALUE nth;\n\tint rjd;\n\n\tdecode_jd(jd, &nth, &rjd);\n\tret = d_simple_new_internal(klass,\n\t\t\t\t    nth, rjd,\n\t\t\t\t    sg,\n\t\t\t\t    0, 0, 0,\n\t\t\t\t    HAVE_JD);\n    }\n    add_frac();\n    return ret;\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":365619,"func":"_asn1_delete_list_and_nodes (void)\n{\n  list_type *listElement;\n\n  while (firstElement)\n    {\n      listElement = firstElement;\n      firstElement = firstElement->next;\n      _asn1_remove_node (listElement->node, 0);\n      free (listElement);\n    }\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":411786,"func":"handle_method_call (GDBusConnection       *connection,\n                    const gchar           *sender,\n                    const gchar           *object_path,\n                    const gchar           *interface_name,\n                    const gchar           *method_name,\n                    GVariant              *parameters,\n                    GDBusMethodInvocation *invocation,\n                    gpointer               user_data)\n{\n  A11yBusLauncher *app = user_data;\n\n  if (g_strcmp0 (method_name, \"GetAddress\") == 0)\n    {\n      ensure_a11y_bus (app);\n      if (app->a11y_bus_pid > 0)\n        g_dbus_method_invocation_return_value (invocation,\n                                               g_variant_new (\"(s)\", app->a11y_bus_address));\n      else\n        g_dbus_method_invocation_return_dbus_error (invocation,\n                                                    \"org.a11y.Bus.Error\",\n                                                    app->a11y_launch_error_message);\n    }\n}","target":0,"code_token_length":195,"total_token_length":431,"max_tokens_setting":512}
+{"idx":453029,"func":"int nft_flow_rule_stats(const struct nft_chain *chain,\n\t\t\tconst struct nft_rule *rule)\n{\n\tstruct flow_cls_offload cls_flow = {};\n\tstruct nft_expr *expr, *next;\n\tint err;\n\n\terr = nft_flow_offload_cmd(chain, rule, NULL, FLOW_CLS_STATS,\n\t\t\t\t   &cls_flow);\n\tif (err < 0)\n\t\treturn err;\n\n\tnft_rule_for_each_expr(expr, next, rule) {\n\t\tif (expr->ops->offload_stats)\n\t\t\texpr->ops->offload_stats(expr, &cls_flow.stats);\n\t}\n\n\treturn 0;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":294508,"func":"decode_jd(VALUE jd, VALUE *nth, int *rjd)\n{\n    *nth = f_idiv(jd, INT2FIX(CM_PERIOD));\n    if (f_zero_p(*nth)) {\n\t*rjd = FIX2INT(jd);\n\treturn;\n    }\n    *rjd = FIX2INT(f_mod(jd, INT2FIX(CM_PERIOD)));\n}","target":0,"code_token_length":78,"total_token_length":314,"max_tokens_setting":512}
+{"idx":236156,"func":"GF_Err href_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 len;\n\tGF_Err e;\n\tGF_TextHyperTextBox*ptr = (GF_TextHyperTextBox*)s;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\n\tgf_bs_write_u16(bs, ptr->startcharoffset);\n\tgf_bs_write_u16(bs, ptr->endcharoffset);\n\tif (ptr->URL) {\n\t\tlen = (u32) strlen(ptr->URL);\n\t\tgf_bs_write_u8(bs, len);\n\t\tgf_bs_write_data(bs, ptr->URL, len);\n\t} else {\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\tif (ptr->URL_hint) {\n\t\tlen = (u32) strlen(ptr->URL_hint);\n\t\tgf_bs_write_u8(bs, len);\n\t\tgf_bs_write_data(bs, ptr->URL_hint, len);\n\t} else {\n\t\tgf_bs_write_u8(bs, 0);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":228,"total_token_length":464,"max_tokens_setting":512}
+{"idx":384899,"func":"getnextcomp(char_u *fname)\n{\n    while (*fname && !vim_ispathsep(*fname))\n\tMB_PTR_ADV(fname);\n    if (*fname)\n\t++fname;\n    return fname;\n}","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":404700,"func":"int __close_fd_get_file(unsigned int fd, struct file **res)\n{\n\tstruct files_struct *files = current->files;\n\tstruct file *file;\n\tstruct fdtable *fdt;\n\n\tfdt = files_fdtable(files);\n\tif (fd >= fdt->max_fds)\n\t\tgoto out_err;\n\tfile = fdt->fd[fd];\n\tif (!file)\n\t\tgoto out_err;\n\trcu_assign_pointer(fdt->fd[fd], NULL);\n\t__put_unused_fd(files, fd);\n\tget_file(file);\n\t*res = file;\n\treturn 0;\nout_err:\n\t*res = NULL;\n\treturn -ENOENT;\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":261230,"func":"int MqttClient_NetConnect(MqttClient *client, const char* host,\n    word16 port, int timeout_ms, int use_tls, MqttTlsCb cb)\n{\n    return MqttSocket_Connect(client, host, port, timeout_ms, use_tls, cb);\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":352980,"func":"booleanMatch(\n\tint *matchp,\n\tslap_mask_t flags,\n\tSyntax *syntax,\n\tMatchingRule *mr,\n\tstruct berval *value,\n\tvoid *assertedValue )\n{\n\t\/* simplistic matching allowed by rigid validation *\/\n\tstruct berval *asserted = (struct berval *) assertedValue;\n\t*matchp = (int) asserted->bv_len - (int) value->bv_len;\n\treturn LDAP_SUCCESS;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":386500,"func":"void DL_Dxf::addVertex(DL_CreationInterface* creationInterface) {\n\n    \/\/ vertex defines a face of the mesh if its vertex flags group has the\n    \/\/ 128 bit set but not the 64 bit. 10, 20, 30 are irrelevant and set to\n    \/\/ 0 in this case\n    if ((getIntValue(70, 0)&128) && !(getIntValue(70, 0)&64)) {\n        return;\n    }\n\n    DL_VertexData d(getRealValue(10, 0.0),\n                    getRealValue(20, 0.0),\n                    getRealValue(30, 0.0),\n                    getRealValue(42, 0.0));\n\n    creationInterface->addVertex(d);\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":270401,"func":"static inline void ok_png_unpremultiply(uint8_t *dst) {\n    const uint8_t a = dst[3];\n    if (a > 0 && a < 255) {\n        dst[0] = 255 * dst[0] \/ a;\n        dst[1] = 255 * dst[1] \/ a;\n        dst[2] = 255 * dst[2] \/ a;\n    }\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":313804,"func":"nv_kundo(cmdarg_T *cap)\n{\n    if (!checkclearopq(cap->oap))\n    {\n#ifdef FEAT_JOB_CHANNEL\n\tif (bt_prompt(curbuf))\n\t{\n\t    clearopbeep(cap->oap);\n\t    return;\n\t}\n#endif\n\tu_undo((int)cap->count1);\n\tcurwin->w_set_curswant = TRUE;\n    }\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":250679,"func":"int HttpFile::save(const std::string &path) const\n{\n    return implPtr_->save(path);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":279926,"func":"check_restricted(void)\n{\n    if (restricted)\n    {\n\temsg(_(e_shell_commands_and_some_functionality_not_allowed_in_rvim));\n\treturn TRUE;\n    }\n    return FALSE;\n}","target":0,"code_token_length":40,"total_token_length":276,"max_tokens_setting":512}
+{"idx":357672,"func":"SQInstance::SQInstance(SQSharedState *ss, SQClass *c, SQInteger memsize)\n{\n    _memsize = memsize;\n    _class = c;\n    SQUnsignedInteger nvalues = _class->_defaultvalues.size();\n    for(SQUnsignedInteger n = 0; n < nvalues; n++) {\n        new (&_values[n]) SQObjectPtr(_class->_defaultvalues[n].val);\n    }\n    Init(ss);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":455394,"func":"xfs_eofblocks_worker(\n\tstruct work_struct *work)\n{\n\tstruct xfs_mount *mp = container_of(to_delayed_work(work),\n\t\t\t\tstruct xfs_mount, m_eofblocks_work);\n\txfs_icache_free_eofblocks(mp, NULL);\n\txfs_queue_eofblocks(mp);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":218932,"func":"Status GetAssetFileDefs(const MetaGraphDef& meta_graph_def,\n                        std::vector<AssetFileDef>* asset_file_defs) {\n  \/\/ With SavedModel v2, we write asset file def into metagraph instead of\n  \/\/ collection, so read from metagraph first.\n  if (meta_graph_def.asset_file_def_size() > 0) {\n    for (const auto& asset : meta_graph_def.asset_file_def()) {\n      asset_file_defs->push_back(asset);\n    }\n    return Status::OK();\n  }\n  \/\/ Fall back to read from collection to be backward compatible with v1.\n  const auto& collection_def_map = meta_graph_def.collection_def();\n  const auto assets_it = collection_def_map.find(kSavedModelAssetsKey);\n  if (assets_it == collection_def_map.end()) {\n    return Status::OK();\n  }\n  const auto& any_assets = assets_it->second.any_list().value();\n  for (const auto& any_asset : any_assets) {\n    AssetFileDef asset_file_def;\n    TF_RETURN_IF_ERROR(\n        ParseAny(any_asset, &asset_file_def, \"tensorflow.AssetFileDef\"));\n    asset_file_defs->push_back(asset_file_def);\n  }\n  return Status::OK();\n}","target":0,"code_token_length":255,"total_token_length":491,"max_tokens_setting":512}
+{"idx":442791,"func":"static ParameterError add2list(struct curl_slist **list,\n                               char *ptr)\n{\n  struct curl_slist *newlist = curl_slist_append(*list, ptr);\n  if(newlist)\n    *list = newlist;\n  else\n    return PARAM_NO_MEM;\n\n  return PARAM_OK;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":224747,"func":"void pitm_box_del(GF_Box *s)\n{\n\tGF_PrimaryItemBox *ptr = (GF_PrimaryItemBox *)s;\n\tif (ptr == NULL) return;\n\tgf_free(ptr);\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":236132,"func":"GF_Box *href_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TextHyperTextBox, GF_ISOM_BOX_TYPE_HREF);\n\treturn (GF_Box *) tmp;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":474039,"func":"cp949_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED, OnigEncoding enc ARG_UNUSED)\n{\n  const UChar c = *s;\n  return (CP949_ISMB_TRAIL(c) ? FALSE : TRUE);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":232958,"func":"static void client_close_writer(struct Curl_easy *data,\n                                struct contenc_writer *writer)\n{\n  (void) data;\n  (void) writer;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":259546,"func":"static size_t strlen_url(const char *url, bool relative)\n{\n  const unsigned char *ptr;\n  size_t newlen = 0;\n  bool left = TRUE; \/* left side of the ? *\/\n  const unsigned char *host_sep = (const unsigned char *) url;\n\n  if(!relative)\n    host_sep = (const unsigned char *) find_host_sep(url);\n\n  for(ptr = (unsigned char *)url; *ptr; ptr++) {\n\n    if(ptr < host_sep) {\n      ++newlen;\n      continue;\n    }\n\n    if(*ptr == ' ') {\n      if(left)\n        newlen += 3;\n      else\n        newlen++;\n      continue;\n    }\n\n    if (*ptr == '?')\n      left = FALSE;\n\n    if(urlchar_needs_escaping(*ptr))\n      newlen += 2;\n\n    newlen++;\n  }\n\n  return newlen;\n}","target":0,"code_token_length":184,"total_token_length":420,"max_tokens_setting":512}
+{"idx":521452,"func":"InputStream* ZipFile::createStreamForEntry (const int index)\r\n{\r\n    InputStream* stream = nullptr;\r\n\r\n    if (auto* zei = entries[index])\r\n    {\r\n        stream = new ZipInputStream (*this, *zei);\r\n\r\n        if (zei->isCompressed)\r\n        {\r\n            stream = new GZIPDecompressorInputStream (stream, true,\r\n                                                      GZIPDecompressorInputStream::deflateFormat,\r\n                                                      zei->entry.uncompressedSize);\r\n\r\n            \/\/ (much faster to unzip in big blocks using a buffer..)\r\n            stream = new BufferedInputStream (stream, 32768, true);\r\n        }\r\n    }\r\n\r\n    return stream;\r\n}\r","target":0,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":344815,"func":"get_sock_af(int fd)\n{\n\tstruct sockaddr_storage to;\n\tsocklen_t tolen = sizeof(to);\n\n\tmemset(&to, 0, sizeof(to));\n\tif (getsockname(fd, (struct sockaddr *)&to, &tolen) == -1)\n\t\treturn -1;\n#ifdef IPV4_IN_IPV6\n\tif (to.ss_family == AF_INET6 &&\n\t    IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr))\n\t\treturn AF_INET;\n#endif\n\treturn to.ss_family;\n}","target":0,"code_token_length":109,"total_token_length":345,"max_tokens_setting":512}
+{"idx":248753,"func":"static struct curl_slist *cookie_list(struct Curl_easy *data)\n{\n  struct curl_slist *list = NULL;\n  struct curl_slist *beg;\n  struct Cookie *c;\n  char *line;\n  unsigned int i;\n\n  if(!data->cookies || (data->cookies->numcookies == 0))\n    return NULL;\n\n  for(i = 0; i < COOKIE_HASH_SIZE; i++) {\n    for(c = data->cookies->cookies[i]; c; c = c->next) {\n      if(!c->domain)\n        continue;\n      line = get_netscape_format(c);\n      if(!line) {\n        curl_slist_free_all(list);\n        return NULL;\n      }\n      beg = Curl_slist_append_nodup(list, line);\n      if(!beg) {\n        free(line);\n        curl_slist_free_all(list);\n        return NULL;\n      }\n      list = beg;\n    }\n  }\n\n  return list;\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":509569,"func":"int maria_checkpoint_state(handlerton *hton, bool disabled)\n{\n  maria_checkpoint_disabled= (my_bool) disabled;\n  return 0;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":455410,"func":"xfs_queue_cowblocks(\n\tstruct xfs_mount *mp)\n{\n\trcu_read_lock();\n\tif (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_COWBLOCKS_TAG))\n\t\tqueue_delayed_work(mp->m_eofblocks_workqueue,\n\t\t\t\t   &mp->m_cowblocks_work,\n\t\t\t\t   msecs_to_jiffies(xfs_cowb_secs * 1000));\n\trcu_read_unlock();\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":500702,"func":"const char *sftp_extensions_get_data(sftp_session sftp, unsigned int idx) {\n  if (sftp == NULL)\n    return NULL;\n  if (sftp->ext == NULL || sftp->ext->name == NULL) {\n    ssh_set_error_invalid(sftp->session, __FUNCTION__);\n    return NULL;\n  }\n\n  if (idx > sftp->ext->count) {\n    ssh_set_error_invalid(sftp->session, __FUNCTION__);\n    return NULL;\n  }\n\n  return sftp->ext->data[idx];\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":430441,"func":"static int parse_flow_mask_nlattrs(const struct nlattr *attr,\n\t\t\t\t   const struct nlattr *a[], u64 *attrsp,\n\t\t\t\t   bool log)\n{\n\treturn __parse_flow_nlattrs(attr, a, attrsp, log, true);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":252279,"func":"static void tdefl_huffman_enforce_max_code_size(int *pNum_codes,\n                                                int code_list_len,\n                                                int max_code_size) {\n  int i;\n  mz_uint32 total = 0;\n  if (code_list_len <= 1) return;\n  for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++)\n    pNum_codes[max_code_size] += pNum_codes[i];\n  for (i = max_code_size; i > 0; i--)\n    total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i));\n  while (total != (1UL << max_code_size)) {\n    pNum_codes[max_code_size]--;\n    for (i = max_code_size - 1; i > 0; i--)\n      if (pNum_codes[i]) {\n        pNum_codes[i]--;\n        pNum_codes[i + 1] += 2;\n        break;\n      }\n    total--;\n  }\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":222576,"func":"Status FunctionLibraryDefinition::RemoveFunction(const string& func) {\n  mutex_lock l(mu_);\n  TF_RETURN_IF_ERROR(RemoveFunctionHelper(func));\n  return Status::OK();\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":389698,"func":"free_tv(typval_T *varp)\n{\n    if (varp != NULL)\n    {\n\tswitch (varp->v_type)\n\t{\n\t    case VAR_FUNC:\n\t\tfunc_unref(varp->vval.v_string);\n\t\t\/\/ FALLTHROUGH\n\t    case VAR_STRING:\n\t\tvim_free(varp->vval.v_string);\n\t\tbreak;\n\t    case VAR_PARTIAL:\n\t\tpartial_unref(varp->vval.v_partial);\n\t\tbreak;\n\t    case VAR_BLOB:\n\t\tblob_unref(varp->vval.v_blob);\n\t\tbreak;\n\t    case VAR_LIST:\n\t\tlist_unref(varp->vval.v_list);\n\t\tbreak;\n\t    case VAR_DICT:\n\t\tdict_unref(varp->vval.v_dict);\n\t\tbreak;\n\t    case VAR_JOB:\n#ifdef FEAT_JOB_CHANNEL\n\t\tjob_unref(varp->vval.v_job);\n\t\tbreak;\n#endif\n\t    case VAR_CHANNEL:\n#ifdef FEAT_JOB_CHANNEL\n\t\tchannel_unref(varp->vval.v_channel);\n\t\tbreak;\n#endif\n\t    case VAR_NUMBER:\n\t    case VAR_FLOAT:\n\t    case VAR_ANY:\n\t    case VAR_UNKNOWN:\n\t    case VAR_VOID:\n\t    case VAR_BOOL:\n\t    case VAR_SPECIAL:\n\t    case VAR_INSTR:\n\t\tbreak;\n\t}\n\tvim_free(varp);\n    }\n}","target":0,"code_token_length":263,"total_token_length":499,"max_tokens_setting":512}
+{"idx":441815,"func":"SProcXkbGetIndicatorState(ClientPtr client)\n{\n    REQUEST(xkbGetIndicatorStateReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq);\n    swaps(&stuff->deviceSpec);\n    return ProcXkbGetIndicatorState(client);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":307842,"func":"int ciEnv::num_inlined_bytecodes() const {\n  return _num_inlined_bytecodes;\n}","target":0,"code_token_length":22,"total_token_length":258,"max_tokens_setting":512}
+{"idx":220935,"func":"static GF_Err mpgviddmx_initialize(GF_Filter *filter)\n{\n\tGF_MPGVidDmxCtx *ctx = gf_filter_get_udta(filter);\n\tctx->hdr_store_size = 0;\n\tctx->hdr_store_alloc = 8;\n\tctx->hdr_store = gf_malloc(sizeof(char)*8);\n\treturn GF_OK;\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":253589,"func":"smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key)\n{\n\tstruct cifs_ses *ses;\n\tu8 *ses_enc_key;\n\n\tspin_lock(&cifs_tcp_ses_lock);\n\tlist_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {\n\t\tlist_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {\n\t\t\tif (ses->Suid == ses_id) {\n\t\t\t\tses_enc_key = enc ? ses->smb3encryptionkey :\n\t\t\t\t\tses->smb3decryptionkey;\n\t\t\t\tmemcpy(key, ses_enc_key, SMB3_ENC_DEC_KEY_SIZE);\n\t\t\t\tspin_unlock(&cifs_tcp_ses_lock);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tspin_unlock(&cifs_tcp_ses_lock);\n\n\treturn -EAGAIN;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":402627,"func":"get_str(Pe *pe, char *strnum)\n{\n\tsize_t sz;\n\tunsigned long num;\n\tchar *strtab;\n\tuint32_t strtabsz;\n\n\t\/* no idea what the real max size for these is, so... we're not going\n\t * to have 4B strings, and this can't be the end of the binary, so\n\t * this is big enough. *\/\n\tsz = strnlen(strnum, 11);\n\tif (sz == 11)\n\t\treturn NULL;\n\n\terrno = 0;\n\tnum = strtoul(strnum, NULL, 10);\n\tif (errno != 0)\n\t\treturn NULL;\n\n\tstrtab = get_strtab(pe);\n\tif (!strtab)\n\t\treturn NULL;\n\n\tstrtabsz = *(uint32_t *)strtab;\n\tif (num >= strtabsz)\n\t\treturn NULL;\n\n\tif (strnlen(&strtab[num], strtabsz - num) > strtabsz - num - 1)\n\t\treturn NULL;\n\n\treturn &strtab[num];\n}","target":0,"code_token_length":218,"total_token_length":454,"max_tokens_setting":512}
+{"idx":240608,"func":"void VarHandleOp::Compute(OpKernelContext* ctx) {\n  if (is_anonymous_) {\n    AllocatorAttributes attr;\n    attr.set_on_host(true);\n    Tensor handle;\n    OP_REQUIRES_OK(\n        ctx, ctx->allocate_temp(DT_RESOURCE, TensorShape({}), &handle, attr));\n    handle.scalar<ResourceHandle>()() = MakeResourceHandle<Var>(\n        ctx, container_, name_,\n        std::vector<DtypeAndPartialTensorShape>{dtype_and_shape_},\n        ctx->stack_trace());\n    ctx->set_output(0, handle);\n  } else {\n    ctx->set_output(0, resource_);\n  }\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":462545,"func":"void controller::import_read_information(const std::string& readinfofile) {\n\tstd::vector<std::string> guids;\n\n\tstd::ifstream f(readinfofile.c_str());\n\tstd::string line;\n\tgetline(f,line);\n\tif (!f.is_open()) {\n\t\treturn;\n\t}\n\twhile (f.is_open() && !f.eof()) {\n\t\tguids.push_back(line);\n\t\tgetline(f, line);\n\t}\n\trsscache->mark_items_read_by_guid(guids);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":359581,"func":"peer_default_originate_set_vty (struct vty *vty, const char *peer_str, \n                                afi_t afi, safi_t safi, \n                                const char *rmap, int set)\n{\n  int ret;\n  struct peer *peer;\n\n  peer = peer_and_group_lookup_vty (vty, peer_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  if (set)\n    ret = peer_default_originate_set (peer, afi, safi, rmap);\n  else\n    ret = peer_default_originate_unset (peer, afi, safi);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":142,"total_token_length":378,"max_tokens_setting":512}
+{"idx":242571,"func":"\tif (datasize > SumOfBytesHashed) {\n\t\thashbase = data + SumOfBytesHashed;\n\t\thashsize = datasize - SumOfBytesHashed;\n\n\t\tcheck_size(data, datasize, hashbase, hashsize);\n\n\t\tif (!(Sha256Update(sha256ctx, hashbase, hashsize)) ||\n\t\t    !(Sha1Update(sha1ctx, hashbase, hashsize))) {\n\t\t\tperror(L\"Unable to generate hash\\n\");\n\t\t\tefi_status = EFI_OUT_OF_RESOURCES;\n\t\t\tgoto done;\n\t\t}\n\n\t\tSumOfBytesHashed += hashsize;\n\t}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":310273,"func":"dirserv_set_cached_consensus_networkstatus(const char *networkstatus,\n                                           const char *flavor_name,\n                                           const digests_t *digests,\n                                           time_t published)\n{\n  cached_dir_t *new_networkstatus;\n  cached_dir_t *old_networkstatus;\n  if (!cached_consensuses)\n    cached_consensuses = strmap_new();\n\n  new_networkstatus = new_cached_dir(tor_strdup(networkstatus), published);\n  memcpy(&new_networkstatus->digests, digests, sizeof(digests_t));\n  old_networkstatus = strmap_set(cached_consensuses, flavor_name,\n                                 new_networkstatus);\n  if (old_networkstatus)\n    cached_dir_decref(old_networkstatus);\n}","target":0,"code_token_length":148,"total_token_length":384,"max_tokens_setting":512}
+{"idx":256168,"func":"inline DSizes dsizes_10() { return DSizes(1, 0); }","target":0,"code_token_length":20,"total_token_length":256,"max_tokens_setting":512}
+{"idx":328983,"func":"R_API void r_bin_java_print_rtv_annotations_attr_summary(RBinJavaAttrInfo *attr) {\n\tif (attr && attr->type == R_BIN_JAVA_ATTR_TYPE_RUNTIME_VISIBLE_ANNOTATION_ATTR) {\n\t\tprintf (\"Runtime Visible Annotations Attribute Information:\\n\");\n\t\tprintf (\"   Attribute Offset: 0x%08\"PFMT64x \"\\n\", attr->file_offset);\n\t\tprintf (\"   Attribute Name Index: %d (%s)\\n\", attr->name_idx, attr->name);\n\t\tprintf (\"   Attribute Length: %d\\n\", attr->length);\n\t\tr_bin_java_print_annotation_array_summary (&attr->info.annotation_array);\n\t}\n}","target":0,"code_token_length":138,"total_token_length":374,"max_tokens_setting":512}
+{"idx":513159,"func":"static char **mysql_sys_var_str(THD* thd, int offset)\n{\n  return (char **) intern_sys_var_ptr(thd, offset, true);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":413688,"func":"static void loganal(ut64 from, ut64 to, int depth) {\n\tr_cons_clear_line (1);\n\teprintf (\"0x%08\"PFMT64x\" > 0x%08\"PFMT64x\" %d\\r\", from, to, depth);\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":220228,"func":"const VersionDef& Graph::versions() const { return *versions_; }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":307856,"func":"ciInstance* ciEnv::the_null_string() {\n  if (_the_null_string == NULL) {\n    VM_ENTRY_MARK;\n    _the_null_string = get_object(Universe::the_null_string())->as_instance();\n  }\n  return _the_null_string;\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":437710,"func":"static inline void control_tx_irq_watermark(struct cx23885_dev *dev,\n\t\t\t\t\t    enum tx_fifo_watermark level)\n{\n\tcx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~CNTRL_TIC, level);\n}","target":0,"code_token_length":61,"total_token_length":297,"max_tokens_setting":512}
+{"idx":225975,"func":"\nGF_Err metx_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox *)s;\n\tswitch (a->type) {\n\tcase GF_ISOM_BOX_TYPE_TXTC:\n\t\t\/\/we allow the config box on metx\n\t\tBOX_FIELD_ASSIGN(config, GF_TextConfigBox)\n\t\tbreak;\n\t}\n\treturn GF_OK;","target":0,"code_token_length":91,"total_token_length":327,"max_tokens_setting":512}
+{"idx":427169,"func":"static int explist (LexState *ls, expdesc *v) {\n  \/* explist -> expr { ',' expr } *\/\n  int n = 1;  \/* at least one expression *\/\n  expr(ls, v);\n  while (testnext(ls, ',')) {\n    luaK_exp2nextreg(ls->fs, v);\n    expr(ls, v);\n    n++;\n  }\n  return n;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":430454,"func":"static inline void add_nested_action_end(struct sw_flow_actions *sfa,\n\t\t\t\t\t int st_offset)\n{\n\tstruct nlattr *a = (struct nlattr *) ((unsigned char *)sfa->actions +\n\t\t\t\t\t\t\t       st_offset);\n\n\ta->nla_len = sfa->actions_len - st_offset;\n}","target":0,"code_token_length":62,"total_token_length":298,"max_tokens_setting":512}
+{"idx":353204,"func":"SplashAxialPattern::~SplashAxialPattern() {\n}","target":0,"code_token_length":12,"total_token_length":248,"max_tokens_setting":512}
+{"idx":310134,"func":"trace_normalized_cost(NCURSES_SP_DCLx const char *capname, const char *cap, int affcnt)\n{\n    int result = normalized_cost(NCURSES_SP_ARGx cap, affcnt);\n    TR(TRACE_CHARPUT | TRACE_MOVE,\n       (\"NormalizedCost %s %d %s\", capname, result, _nc_visbuf(cap)));\n    return result;\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":246730,"func":"static void PrintHelp(char *arg_name, Bool search_desc, Bool no_match)\n{\n\tGF_FilterSession *fs;\n\tBool res;\n\n\tfs = gf_fs_new_defaults(0);\n\n\tif (arg_name[0]=='-')\n\t\targ_name++;\n\n\tif (search_desc) {\n\t\tchar *_arg_name = gf_strdup(arg_name);\n\t\tstrlwr(_arg_name);\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"Possible options mentionning `%s`:\\n\", arg_name));\n\t\tPrintHelpArg(_arg_name, SEARCH_DESC, fs);\n\t\tgf_free(_arg_name);\n\t} else {\n\t\tres = no_match ? GF_FALSE : PrintHelpArg(arg_name, SEARCH_ARG_EXACT, fs);\n\t\tif (!res) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_APP, (\"Option -%s unknown, please check usage.\\n\", arg_name));\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_APP, (\"Possible options are:\\n\"));\n\n\t\t\tPrintHelpArg(arg_name, SEARCH_ARG_CLOSE, fs);\n\t\t}\n\t}\n\tif (fs)\n\t\tgf_fs_del(fs);\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":484796,"func":"static void add_id_to_list(unsigned *head, unsigned short *list,\n\t\t\t   unsigned short id)\n{\n\tlist[id] = *head;\n\t*head = id;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":221499,"func":"flatpak_run_add_ssh_args (FlatpakBwrap *bwrap)\n{\n  static const char sandbox_auth_socket[] = \"\/run\/flatpak\/ssh-auth\";\n  const char * auth_socket;\n\n  auth_socket = g_getenv (\"SSH_AUTH_SOCK\");\n\n  if (!auth_socket)\n    return; \/* ssh agent not present *\/\n\n  if (!g_file_test (auth_socket, G_FILE_TEST_EXISTS))\n    {\n      \/* Let's clean it up, so that the application will not try to connect *\/\n      flatpak_bwrap_unset_env (bwrap, \"SSH_AUTH_SOCK\");\n      return;\n    }\n\n  flatpak_bwrap_add_args (bwrap,\n                          \"--ro-bind\", auth_socket, sandbox_auth_socket,\n                          NULL);\n  flatpak_bwrap_set_env (bwrap, \"SSH_AUTH_SOCK\", sandbox_auth_socket, TRUE);\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":366200,"func":"static void __put_mountpoint(struct mountpoint *mp, struct list_head *list)\n{\n\tif (!--mp->m_count) {\n\t\tstruct dentry *dentry = mp->m_dentry;\n\t\tBUG_ON(!hlist_empty(&mp->m_list));\n\t\tspin_lock(&dentry->d_lock);\n\t\tdentry->d_flags &= ~DCACHE_MOUNTED;\n\t\tspin_unlock(&dentry->d_lock);\n\t\tdput_to_list(dentry, list);\n\t\thlist_del(&mp->m_hash);\n\t\tkfree(mp);\n\t}\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":484731,"func":"void mobi_buffer_setpos(MOBIBuffer *buf, const size_t pos) {\n    if (pos <= buf->maxlen) {\n        buf->offset = pos;\n        return;\n    }\n    buf->error = MOBI_BUFFER_END;\n    debug_print(\"%s\", \"End of buffer\\n\");\n}","target":0,"code_token_length":65,"total_token_length":301,"max_tokens_setting":512}
+{"idx":219899,"func":"Bool IsHintTrack(GF_TrackBox *trak)\n{\n\tif (trak->Media->handler->handlerType != GF_ISOM_MEDIA_HINT) return GF_FALSE;\n\t\/\/QT doesn't specify any InfoHeader on HintTracks\n\tif (trak->Media->information->InfoHeader\n\t        && (trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_HMHD)\n\t        && (trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_NMHD)\n\t\t)\n\t\treturn GF_FALSE;\n\n\treturn GF_TRUE;\n}","target":0,"code_token_length":116,"total_token_length":352,"max_tokens_setting":512}
+{"idx":267958,"func":"R_API ut64 r_bin_file_delete_all(RBin *bin) {\n\tif (bin) {\n\t\tut64 counter = r_list_length (bin->binfiles);\n\t\tr_list_purge (bin->binfiles);\n\t\tbin->cur = NULL;\n\t\treturn counter;\n\t}\n\treturn 0;\n}","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":512513,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_name_const>(thd, this); }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":365616,"func":"_asn1_remove_node (asn1_node node, unsigned int flags)\n{\n  if (node == NULL)\n    return;\n\n  if (node->value != NULL)\n    {\n      if (flags & ASN1_DELETE_FLAG_ZEROIZE)\n        {\n          safe_memset(node->value, 0, node->value_len);\n        }\n\n      if (node->value != node->small_value)\n        free (node->value);\n    }\n  free (node);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":356705,"func":"void Statement::Finalize_(Baton* b) {\n    std::unique_ptr<Baton> baton(b);\n    Napi::Env env = baton->stmt->Env();\n    Napi::HandleScope scope(env);\n\n    baton->stmt->Finalize_();\n\n    \/\/ Fire callback in case there was one.\n    Napi::Function cb = baton->callback.Value();\n    if (!cb.IsUndefined() && cb.IsFunction()) {\n        TRY_CATCH_CALL(baton->stmt->Value(), cb, 0, NULL);\n    }\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":374047,"func":"static RBinSymbol *bin_symbol_from_symbol(RCoreSymCacheElement *element, RCoreSymCacheElementSymbol *s) {\n\tif (!s->name && !s->mangled_name) {\n\t\treturn NULL;\n\t}\n\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\tif (sym) {\n\t\tif (s->name && s->mangled_name) {\n\t\t\tsym->dname = strdup (s->name);\n\t\t\tsym->name = strdup (s->mangled_name);\n\t\t} else if (s->name) {\n\t\t\tsym->name = strdup (s->name);\n\t\t} else if (s->mangled_name) {\n\t\t\tsym->name = s->mangled_name;\n\t\t}\n\t\tsym->paddr = s->paddr;\n\t\tsym->vaddr = r_coresym_cache_element_pa2va (element, s->paddr);\n\t\tsym->size = s->size;\n\t\tsym->type = R_BIN_TYPE_FUNC_STR;\n\t\tsym->bind = \"NONE\";\n\t}\n\treturn sym;\n}","target":0,"code_token_length":230,"total_token_length":466,"max_tokens_setting":512}
+{"idx":436050,"func":"\nstatic enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)\n{\n\tstruct io_timeout_data *data = container_of(timer,\n\t\t\t\t\t\tstruct io_timeout_data, timer);\n\tstruct io_kiocb *req = data->req;\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&ctx->completion_lock, flags);\n\tlist_del_init(&req->timeout.list);\n\tatomic_set(&req->ctx->cq_timeouts,\n\t\tatomic_read(&req->ctx->cq_timeouts) + 1);\n\n\tio_cqring_fill_event(ctx, req->user_data, -ETIME, 0);\n\tio_commit_cqring(ctx);\n\tspin_unlock_irqrestore(&ctx->completion_lock, flags);\n\n\tio_cqring_ev_posted(ctx);\n\treq_set_fail(req);\n\tio_put_req(req);\n\treturn HRTIMER_NORESTART;","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":343133,"func":"static struct ip_esp_hdr *esp_output_udp_encap(struct sk_buff *skb,\n\t\t\t\t\t       int encap_type,\n\t\t\t\t\t       struct esp_info *esp,\n\t\t\t\t\t       __be16 sport,\n\t\t\t\t\t       __be16 dport)\n{\n\tstruct udphdr *uh;\n\t__be32 *udpdata32;\n\tunsigned int len;\n\n\tlen = skb->len + esp->tailen - skb_transport_offset(skb);\n\tif (len + sizeof(struct iphdr) > IP_MAX_MTU)\n\t\treturn ERR_PTR(-EMSGSIZE);\n\n\tuh = (struct udphdr *)esp->esph;\n\tuh->source = sport;\n\tuh->dest = dport;\n\tuh->len = htons(len);\n\tuh->check = 0;\n\n\t*skb_mac_header(skb) = IPPROTO_UDP;\n\n\tif (encap_type == UDP_ENCAP_ESPINUDP_NON_IKE) {\n\t\tudpdata32 = (__be32 *)(uh + 1);\n\t\tudpdata32[0] = udpdata32[1] = 0;\n\t\treturn (struct ip_esp_hdr *)(udpdata32 + 2);\n\t}\n\n\treturn (struct ip_esp_hdr *)(uh + 1);\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":359283,"func":"DEFUN (clear_ip_bgp_as,\n       clear_ip_bgp_as_cmd,\n       \"clear ip bgp <1-65535>\",\n       CLEAR_STR\n       IP_STR\n       BGP_STR\n       \"Clear peers with the AS number\\n\")\n{\n  return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);\n}       ","target":0,"code_token_length":90,"total_token_length":326,"max_tokens_setting":512}
+{"idx":310323,"func":"real_uptime(routerinfo_t *router, time_t now)\n{\n  if (now < router->cache_info.published_on)\n    return router->uptime;\n  else\n    return router->uptime + (now - router->cache_info.published_on);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":513229,"func":"static inline char plugin_var_bookmark_key(uint flags)\n{\n  return (flags & PLUGIN_VAR_TYPEMASK) |\n         (flags & PLUGIN_VAR_MEMALLOC ? BOOKMARK_MEMALLOC : 0);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":508327,"func":"bool No_such_table_error_handler::safely_trapped_errors()\n{\n  \/*\n    If m_unhandled_errors != 0, something else, unanticipated, happened,\n    so the error is not trapped but returned to the caller.\n    Multiple ER_NO_SUCH_TABLE can be raised in case of views.\n  *\/\n  return ((m_handled_errors > 0) && (m_unhandled_errors == 0));\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":247573,"func":"TEST_P(SslSocketTest, ClientSessionResumptionDisabledTls12) {\n  const std::string server_ctx_yaml = R\"EOF(\n  common_tls_context:\n    tls_params:\n      tls_minimum_protocol_version: TLSv1_0\n      tls_maximum_protocol_version: TLSv1_2\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n)EOF\";\n\n  const std::string client_ctx_yaml = R\"EOF(\n  common_tls_context:\n  max_session_keys: 0\n)EOF\";\n\n  testClientSessionResumption(server_ctx_yaml, client_ctx_yaml, false, GetParam());\n}","target":0,"code_token_length":177,"total_token_length":413,"max_tokens_setting":512}
+{"idx":293521,"func":"PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner,\n\t\t\t\tint begin_quote, int end_quote, \n\t\t\t\tpj_str_t *out)\n{\n    char beg = (char)begin_quote;\n    char end = (char)end_quote;\n    pj_scan_get_quotes(scanner, &beg, &end, 1, out);\n}","target":0,"code_token_length":73,"total_token_length":309,"max_tokens_setting":512}
+{"idx":316966,"func":"static void selinux_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)\n{\n\tstruct ipc_security_struct *isec = selinux_ipc(ipcp);\n\t*secid = isec->sid;\n}","target":0,"code_token_length":49,"total_token_length":285,"max_tokens_setting":512}
+{"idx":383369,"func":"gdImageColorAllocate (gdImagePtr im, int r, int g, int b)\n{\n  return gdImageColorAllocateAlpha (im, r, g, b, gdAlphaOpaque);\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":200695,"func":"static int fastrpc_dma_buf_attach(struct dma_buf *dmabuf,\n\t\t\t\t  struct dma_buf_attachment *attachment)\n{\n\tstruct fastrpc_dma_buf_attachment *a;\n\tstruct fastrpc_buf *buffer = dmabuf->priv;\n\tint ret;\n\n\ta = kzalloc(sizeof(*a), GFP_KERNEL);\n\tif (!a)\n\t\treturn -ENOMEM;\n\n\tret = dma_get_sgtable(buffer->dev, &a->sgt, buffer->virt,\n\t\t\t      FASTRPC_PHYS(buffer->phys), buffer->size);\n\tif (ret < 0) {\n\t\tdev_err(buffer->dev, \"failed to get scatterlist from DMA API\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\ta->dev = attachment->dev;\n\tINIT_LIST_HEAD(&a->node);\n\tattachment->priv = a;\n\n\tmutex_lock(&buffer->lock);\n\tlist_add(&a->node, &buffer->attachments);\n\tmutex_unlock(&buffer->lock);\n\n\treturn 0;\n}","target":1,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":261946,"func":"njs_reserved(const uint32_t *reserve, uint32_t byte)\n{\n    return ((reserve[byte >> 5] & ((uint32_t) 1 << (byte & 0x1f))) != 0);\n}","target":0,"code_token_length":52,"total_token_length":288,"max_tokens_setting":512}
+{"idx":224226,"func":"R_API RIOBank *r_io_bank_new(const char *name) {\n\tr_return_val_if_fail (name, NULL);\n\tRIOBank *bank = R_NEW0 (RIOBank);\n\tif (!bank) {\n\t\treturn NULL;\n\t}\n\tbank->name = strdup (name);\n\tbank->submaps = r_crbtree_new (free);\n\tif (!bank->submaps) {\n\t\tfree (bank);\n\t\treturn NULL;\n\t}\n\tbank->maprefs = r_list_newf (free);\n\tif (!bank->maprefs) {\n\t\tr_crbtree_free (bank->submaps);\n\t\tfree (bank);\n\t\treturn NULL;\n\t}\n\tbank->todo = r_queue_new (8);\n\tif (!bank->todo) {\n\t\tr_list_free (bank->maprefs);\n\t\tr_crbtree_free (bank->submaps);\n\t\tfree (bank);\n\t\treturn NULL;\n\t}\n\treturn bank;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":453015,"func":"int nft_offload_init(void)\n{\n\treturn register_netdevice_notifier(&nft_offload_netdev_notifier);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":359391,"func":"peer_timers_set_vty (struct vty *vty, const char *ip_str, \n                     const char *keep_str, const char *hold_str)\n{\n  int ret;\n  struct peer *peer;\n  u_int32_t keepalive;\n  u_int32_t holdtime;\n\n  peer = peer_and_group_lookup_vty (vty, ip_str);\n  if (! peer)\n    return CMD_WARNING;\n\n  VTY_GET_INTEGER_RANGE (\"Keepalive\", keepalive, keep_str, 0, 65535);\n  VTY_GET_INTEGER_RANGE (\"Holdtime\", holdtime, hold_str, 0, 65535);\n\n  ret = peer_timers_set (peer, keepalive, holdtime);\n\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":318964,"func":"f_assert_equal(typval_T *argvars, typval_T *rettv)\n{\n    rettv->vval.v_number = assert_equal_common(argvars, ASSERT_EQUAL);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":413657,"func":"static bool printAnalPaths(RCoreAnalPaths *p, PJ *pj) {\n\tRListIter *iter;\n\tRAnalBlock *path;\n\tif (pj) {\n\t\tpj_a (pj);\n\t} else {\n\t\tr_cons_printf (\"pdb @@= \");\n\t}\n\n\tr_list_foreach (p->path, iter, path) {\n\t\tif (pj) {\n\t\t\tpj_n (pj, path->addr);\n\t\t} else {\n\t\t\tr_cons_printf (\"0x%08\"PFMT64x\" \", path->addr);\n\t\t}\n\t}\n\n\tif(pj) {\n\t\tpj_end (pj);\n\t} else {\n\t\tr_cons_printf (\"\\n\");\n\t}\n\treturn (p->count < 1 || --p->count > 0);\n}","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":432330,"func":"void flatview_unref(FlatView *view)\n{\n    view->ref--;\n    if (view->ref <= 0) {\n        flatview_destroy(view);\n    }\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":300737,"func":"int tipc_dump_start(struct netlink_callback *cb)\n{\n\treturn __tipc_dump_start(cb, sock_net(cb->skb->sk));\n}","target":0,"code_token_length":30,"total_token_length":266,"max_tokens_setting":512}
+{"idx":369170,"func":"\nstatic void io_apoll_task_func(struct io_kiocb *req, bool *locked)\n{\n\tstruct io_ring_ctx *ctx = req->ctx;\n\tint ret;\n\n\tret = io_poll_check_events(req, *locked);\n\tif (ret > 0)\n\t\treturn;\n\n\tio_poll_remove_entries(req);\n\tspin_lock(&ctx->completion_lock);\n\thash_del(&req->hash_node);\n\tspin_unlock(&ctx->completion_lock);\n\n\tif (!ret)\n\t\tio_req_task_submit(req, locked);\n\telse\n\t\tio_req_complete_failed(req, ret);","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":436075,"func":"static bool __io_file_supports_async(struct file *file, int rw)\n{\n\tumode_t mode = file_inode(file)->i_mode;\n\n\tif (S_ISBLK(mode)) {\n\t\tif (IS_ENABLED(CONFIG_BLOCK) &&\n\t\t    io_bdev_nowait(I_BDEV(file->f_mapping->host)))\n\t\t\treturn true;\n\t\treturn false;\n\t}\n\tif (S_ISSOCK(mode))\n\t\treturn true;\n\tif (S_ISREG(mode)) {\n\t\tif (IS_ENABLED(CONFIG_BLOCK) &&\n\t\t    io_bdev_nowait(file->f_inode->i_sb->s_bdev) &&\n\t\t    file->f_op != &io_uring_fops)\n\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\t\/* any ->read\/write should understand O_NONBLOCK *\/\n\tif (file->f_flags & O_NONBLOCK)\n\t\treturn true;\n\n\tif (!(file->f_mode & FMODE_NOWAIT))\n\t\treturn false;\n\n\tif (rw == READ)\n\t\treturn file->f_op->read_iter != NULL;\n\n\treturn file->f_op->write_iter != NULL;\n}","target":0,"code_token_length":217,"total_token_length":453,"max_tokens_setting":512}
+{"idx":281166,"func":"static void xfrm_bundle_flo_delete(struct flow_cache_object *flo)\n{\n\tstruct xfrm_dst *xdst = container_of(flo, struct xfrm_dst, flo);\n\tstruct dst_entry *dst = &xdst->u.dst;\n\n\t\/* Mark DST_OBSOLETE_DEAD to fail the next xfrm_dst_check() *\/\n\tdst->obsolete = DST_OBSOLETE_DEAD;\n\tdst_release_immediate(dst);\n}","target":0,"code_token_length":84,"total_token_length":320,"max_tokens_setting":512}
+{"idx":424517,"func":"static void PresentationContext_unref(PresentationContext* presentation)\n{\n\tVideoClientContextPriv* priv;\n\tMAPPED_GEOMETRY* geometry;\n\n\tif (!presentation)\n\t\treturn;\n\n\tif (InterlockedDecrement(&presentation->refCounter) != 0)\n\t\treturn;\n\n\tgeometry = presentation->geometry;\n\tif (geometry)\n\t{\n\t\tgeometry->MappedGeometryUpdate = NULL;\n\t\tgeometry->MappedGeometryClear = NULL;\n\t\tgeometry->custom = NULL;\n\t\tmappedGeometryUnref(geometry);\n\t}\n\n\tpriv = presentation->video->priv;\n\n\th264_context_free(presentation->h264);\n\tStream_Free(presentation->currentSample, TRUE);\n\tpresentation->video->deleteSurface(presentation->video, presentation->surface);\n\tBufferPool_Return(priv->surfacePool, presentation->surfaceData);\n\tyuv_context_free(presentation->yuv);\n\tfree(presentation);\n}","target":0,"code_token_length":181,"total_token_length":417,"max_tokens_setting":512}
+{"idx":512997,"func":"  Item_direct_ref(THD *thd, TABLE_LIST *view_arg, Item **item,\n                  const LEX_CSTRING *field_name_arg,\n                  bool alias_name_used_arg= FALSE):\n    Item_ref(thd, view_arg, item, field_name_arg,\n             alias_name_used_arg)\n  {}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":371426,"func":"PHP_FUNCTION( msgfmt_format )\n{\n\tzval *args;\n\tMSG_FORMAT_METHOD_INIT_VARS;\n\n\n\t\/* Parse parameters. *\/\n\tif( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), \"Oa\",\n\t\t&object, MessageFormatter_ce_ptr,  &args ) == FAILURE )\n\t{\n\t\tintl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,\n\t\t\t\"msgfmt_format: unable to parse input params\", 0 TSRMLS_CC );\n\n\t\tRETURN_FALSE;\n\t}\n\n\t\/* Fetch the object. *\/\n\tMSG_FORMAT_METHOD_FETCH_OBJECT;\n\n\tmsgfmt_do_format(mfo, args, return_value TSRMLS_CC);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":413643,"func":"static bool is_fcn_traced(RDebugTrace *traced, RAnalFunction *fcn) {\n\tint tag = traced->tag;\n\tRListIter *iter;\n\tRDebugTracepoint *trace;\n\n\tr_list_foreach (traced->traces, iter, trace) {\n\t\tif (!trace->tag || (tag & trace->tag)) {\n\t\t\tif (r_anal_function_contains (fcn, trace->addr)) {\n\t\t\t\tr_cons_printf (\"\\ntraced: %d\\n\", trace->times);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":242612,"func":"  void Compute(OpKernelContext* ctx) override {\n    Buffer* buf = nullptr;\n    OP_REQUIRES_OK(ctx, GetBuffer(ctx, def(), &buf));\n    core::ScopedUnref scope(buf);\n\n    buf->Clear();\n  }","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":309923,"func":"npush(int x)\n{\n    if (TPS(stack_ptr) < STACKSIZE) {\n\tTPS(stack)[TPS(stack_ptr)].num_type = TRUE;\n\tTPS(stack)[TPS(stack_ptr)].data.num = x;\n\tTPS(stack_ptr)++;\n    } else {\n\tDEBUG(2, (\"npush: stack overflow: %s\", _nc_visbuf(TPS(tparam_base))));\n\t_nc_tparm_err++;\n    }\n}","target":0,"code_token_length":92,"total_token_length":328,"max_tokens_setting":512}
+{"idx":312514,"func":"unload_dummy_buffer(buf_T *buf, char_u *dirname_start)\n{\n    if (curbuf != buf)\t\t\/\/ safety check\n    {\n\tclose_buffer(NULL, buf, DOBUF_UNLOAD, FALSE, TRUE);\n\n\t\/\/ When autocommands\/'autochdir' option changed directory: go back.\n\trestore_start_dir(dirname_start);\n    }\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":244224,"func":"GF_Box *fdsa_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_HintSample, GF_ISOM_BOX_TYPE_FDSA);\n\tif (!tmp) return NULL;\n\ttmp->packetTable = gf_list_new();\n\ttmp->hint_subtype = GF_ISOM_BOX_TYPE_FDP_STSD;\n\treturn (GF_Box*)tmp;\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":244006,"func":"GF_Err dfla_box_size(GF_Box *s)\n{\n\tGF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s;\n\tptr->size += ptr->dataSize;\n\treturn GF_OK;\n}","target":0,"code_token_length":46,"total_token_length":282,"max_tokens_setting":512}
+{"idx":508906,"func":"TABLE_LIST* st_select_lex_node::get_table_list()     { return 0; }","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":512968,"func":"  Item_string(THD *thd, const char *name_par, const char *str, size_t length,\n              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)\n   :Item_literal(thd)\n  {\n    str_value.set_or_copy_aligned(str, length, cs);\n    fix_from_value(dv, Metadata(&str_value));\n    set_name(thd, name_par,safe_strlen(name_par), system_charset_info);\n  }","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":387764,"func":"static void print_vtable(intptr_t* start, int len, outputStream* st) {\n  for (int i = 0; i < len; i++) {\n    intptr_t e = start[i];\n    st->print(\"%d : \" INTPTR_FORMAT, i, e);\n    if (MetaspaceObj::is_valid((Metadata*)e)) {\n      st->print(\" \");\n      ((Metadata*)e)->print_value_on(st);\n    }\n    st->cr();\n  }\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":338111,"func":"void WasmBinaryBuilder::readTags() {\n  BYN_TRACE(\"== readTags\\n\");\n  size_t numTags = getU32LEB();\n  BYN_TRACE(\"num: \" << numTags << std::endl);\n  for (size_t i = 0; i < numTags; i++) {\n    BYN_TRACE(\"read one\\n\");\n    getInt8(); \/\/ Reserved 'attribute' field\n    auto typeIndex = getU32LEB();\n    wasm.addTag(Builder::makeTag(\"tag$\" + std::to_string(i),\n                                 getSignatureByTypeIndex(typeIndex)));\n  }\n}","target":0,"code_token_length":130,"total_token_length":366,"max_tokens_setting":512}
+{"idx":196578,"func":"yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space)\n{\n    char_u\t*pnew;\n\n    if (exclude_trailing_space)\n\tbd->endspaces = 0;\n    if ((pnew = alloc(bd->startspaces + bd->endspaces + bd->textlen + 1))\n\t\t\t\t\t\t\t\t      == NULL)\n\treturn FAIL;\n    y_current->y_array[y_idx] = pnew;\n    vim_memset(pnew, ' ', (size_t)bd->startspaces);\n    pnew += bd->startspaces;\n    mch_memmove(pnew, bd->textstart, (size_t)bd->textlen);\n    pnew += bd->textlen;\n    vim_memset(pnew, ' ', (size_t)bd->endspaces);\n    pnew += bd->endspaces;\n    if (exclude_trailing_space)\n    {\n\tint s = bd->textlen + bd->endspaces;\n\n\twhile (VIM_ISWHITE(*(bd->textstart + s - 1)) && s > 0)\n\t{\n\t    s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1;\n\t    pnew--;\n\t}\n    }\n    *pnew = NUL;\n    return OK;\n}","target":1,"code_token_length":275,"total_token_length":511,"max_tokens_setting":512}
+{"idx":265053,"func":"promptpath(char *p, int npath, int tilde)\n{\n    char *modp = p;\n    Nameddir nd;\n\n    if (tilde && ((nd = finddir(p))))\n\tmodp = tricat(\"~\", nd->node.nam, p + strlen(nd->dir));\n\n    if (npath) {\n\tchar *sptr;\n\tif (npath > 0) {\n\t    for (sptr = modp + strlen(modp); sptr > modp; sptr--) {\n\t\tif (*sptr == '\/' && !--npath) {\n\t\t    sptr++;\n\t\t    break;\n\t\t}\n\t    }\n\t    if (*sptr == '\/' && sptr[1] && sptr != modp)\n\t\tsptr++;\n\t    stradd(sptr);\n\t} else {\n\t    char cbu;\n\t    for (sptr = modp+1; *sptr; sptr++)\n\t\tif (*sptr == '\/' && !++npath)\n\t\t    break;\n\t    cbu = *sptr;\n\t    *sptr = 0;\n\t    stradd(modp);\n\t    *sptr = cbu;\n\t}\n    } else\n\tstradd(modp);\n\n    if (p != modp)\n\tzsfree(modp);\n}","target":0,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":383319,"func":"gdLayerOverlay (int dst, int src)\n{\n\tint a1, a2;\n\ta1 = gdAlphaMax - gdTrueColorGetAlpha(dst);\n\ta2 = gdAlphaMax - gdTrueColorGetAlpha(src);\n\treturn ( ((gdAlphaMax - a1*a2\/gdAlphaMax) << 24) +\n\t\t(gdAlphaOverlayColor( gdTrueColorGetRed(src), gdTrueColorGetRed(dst), gdRedMax ) << 16) +\n\t\t(gdAlphaOverlayColor( gdTrueColorGetGreen(src), gdTrueColorGetGreen(dst), gdGreenMax ) << 8) +\n\t\t(gdAlphaOverlayColor( gdTrueColorGetBlue(src), gdTrueColorGetBlue(dst), gdBlueMax ))\n\t\t);\n}","target":0,"code_token_length":161,"total_token_length":397,"max_tokens_setting":512}
+{"idx":508892,"func":"bool st_select_lex::handle_derived(LEX *lex, uint phases)\n{\n  return lex->handle_list_of_derived(table_list.first, phases);\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":384680,"func":"send_newstyle_option_reply_info_str (uint32_t option, uint32_t reply,\n                                     uint16_t info, const char *str,\n                                     size_t len)\n{\n  GET_CONN;\n  struct nbd_fixed_new_option_reply fixed_new_option_reply;\n  struct nbd_fixed_new_option_reply_info_name_or_desc name;\n\n  if (len == -1)\n    len = strlen (str);\n  assert (len <= NBD_MAX_STRING);\n\n  fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC);\n  fixed_new_option_reply.option = htobe32 (option);\n  fixed_new_option_reply.reply = htobe32 (reply);\n  fixed_new_option_reply.replylen = htobe32 (sizeof info + len);\n  name.info = htobe16 (info);\n\n  if (conn->send (&fixed_new_option_reply,\n                  sizeof fixed_new_option_reply, SEND_MORE) == -1 ||\n      conn->send (&name, sizeof name, SEND_MORE) == -1 ||\n      conn->send (str, len, 0) == -1) {\n    nbdkit_error (\"write: %s: %m\", name_of_nbd_opt (option));\n    return -1;\n  }\n\n  return 0;\n}","target":0,"code_token_length":264,"total_token_length":500,"max_tokens_setting":512}
+{"idx":276983,"func":"    virtual AP4_Result GetSize(AP4_LargeSize& size) { size = m_Size;     return AP4_SUCCESS; }","target":0,"code_token_length":28,"total_token_length":264,"max_tokens_setting":512}
+{"idx":474430,"func":"ObjectGetHierarchy(\n\t\t   OBJECT          *object         \/\/ IN :object\n\t\t   )\n{\n    if(object->attributes.spsHierarchy)\n\t{\n\t    return TPM_RH_OWNER;\n\t}\n    else if(object->attributes.epsHierarchy)\n\t{\n\t    return TPM_RH_ENDORSEMENT;\n\t}\n    else if(object->attributes.ppsHierarchy)\n\t{\n\t    return TPM_RH_PLATFORM;\n\t}\n    else\n\t{\n\t    return TPM_RH_NULL;\n\t}\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":226403,"func":"void traf_box_del(GF_Box *s)\n{\n\tGF_TrackFragmentBox *ptr = (GF_TrackFragmentBox *)s;\n\tif (ptr == NULL) return;\n\tif (ptr->sub_samples) gf_list_del(ptr->sub_samples);\n\tgf_list_del(ptr->TrackRuns);\n\tif (ptr->sampleGroups) gf_list_del(ptr->sampleGroups);\n\tif (ptr->sampleGroupsDescription) gf_list_del(ptr->sampleGroupsDescription);\n\tif (ptr->sai_sizes) gf_list_del(ptr->sai_sizes);\n\tif (ptr->sai_offsets) gf_list_del(ptr->sai_offsets);\n\tgf_free(ptr);\n}","target":0,"code_token_length":133,"total_token_length":369,"max_tokens_setting":512}
+{"idx":264229,"func":"static void framebuffer_update_request(VncState *vs, int incremental,\n                                       int x_position, int y_position,\n                                       int w, int h)\n{\n    int i;\n    const size_t width = surface_width(vs->vd->ds) \/ VNC_DIRTY_PIXELS_PER_BIT;\n    const size_t height = surface_height(vs->vd->ds);\n\n    if (y_position > height) {\n        y_position = height;\n    }\n    if (y_position + h >= height) {\n        h = height - y_position;\n    }\n\n    vs->need_update = 1;\n    if (!incremental) {\n        vs->force_update = 1;\n        for (i = 0; i < h; i++) {\n            bitmap_set(vs->dirty[y_position + i], 0, width);\n            bitmap_clear(vs->dirty[y_position + i], width,\n                         VNC_DIRTY_BITS - width);\n        }\n    }\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":226096,"func":"GF_Box *mvhd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MovieHeaderBox, GF_ISOM_BOX_TYPE_MVHD);\n\n\ttmp->preferredRate = (1<<16);\n\ttmp->preferredVolume = (1<<8);\n\n\ttmp->matrixA = (1<<16);\n\ttmp->matrixD = (1<<16);\n\ttmp->matrixW = (1<<30);\n\n\ttmp->nextTrackID = 1;\n\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":369266,"func":"\nstatic __cold void io_sqd_update_thread_idle(struct io_sq_data *sqd)\n{\n\tstruct io_ring_ctx *ctx;\n\tunsigned sq_thread_idle = 0;\n\n\tlist_for_each_entry(ctx, &sqd->ctx_list, sqd_list)\n\t\tsq_thread_idle = max(sq_thread_idle, ctx->sq_thread_idle);\n\tsqd->sq_thread_idle = sq_thread_idle;","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":450428,"func":"static bool vnc_check_pageflip(DisplaySurface *s1,\n                               DisplaySurface *s2)\n{\n    return (s1 != NULL &&\n            s2 != NULL &&\n            surface_width(s1) == surface_width(s2) &&\n            surface_height(s1) == surface_height(s2) &&\n            surface_format(s1) == surface_format(s2));\n\n}","target":0,"code_token_length":74,"total_token_length":310,"max_tokens_setting":512}
+{"idx":273400,"func":"  explicit LSTMBlockCellGradOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n    OP_REQUIRES_OK(ctx, ctx->GetAttr(\"use_peephole\", &use_peephole_));\n  }","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":487628,"func":"void groups_free(struct group_info *group_info)\n{\n\tif (group_info->blocks[0] != group_info->small_block) {\n\t\tint i;\n\t\tfor (i = 0; i < group_info->nblocks; i++)\n\t\t\tfree_page((unsigned long)group_info->blocks[i]);\n\t}\n\tkfree(group_info);\n}","target":0,"code_token_length":70,"total_token_length":306,"max_tokens_setting":512}
+{"idx":90234,"func":"  ~NetworkLibraryImpl() {\n    network_manager_observers_.Clear();\n    if (network_manager_monitor_)\n      DisconnectPropertyChangeMonitor(network_manager_monitor_);\n    data_plan_observers_.Clear();\n    if (data_plan_monitor_)\n      DisconnectDataPlanUpdateMonitor(data_plan_monitor_);\n    STLDeleteValues(&network_observers_);\n    ClearNetworks();\n  }\n","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":482691,"func":"gst_flxdec_sink_event_handler (GstPad * pad, GstObject * parent,\n    GstEvent * event)\n{\n  GstFlxDec *flxdec;\n  gboolean ret;\n\n  flxdec = GST_FLXDEC (parent);\n\n  switch (GST_EVENT_TYPE (event)) {\n    case GST_EVENT_SEGMENT:\n    {\n      GstSegment segment;\n\n      gst_event_copy_segment (event, &segment);\n      if (segment.format != GST_FORMAT_TIME) {\n        GST_DEBUG_OBJECT (flxdec, \"generating TIME segment\");\n        gst_segment_init (&segment, GST_FORMAT_TIME);\n        gst_event_unref (event);\n        event = gst_event_new_segment (&segment);\n      }\n      \/* fall-through *\/\n    }\n    default:\n      ret = gst_pad_event_default (pad, parent, event);\n      break;\n  }\n\n  return ret;\n}","target":0,"code_token_length":176,"total_token_length":412,"max_tokens_setting":512}
+{"idx":202943,"func":"l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {\n  CallInfo *ci = L->ci;\n  const char *msg;\n  va_list argp;\n  luaC_checkGC(L);  \/* error message uses memory *\/\n  va_start(argp, fmt);\n  msg = luaO_pushvfstring(L, fmt, argp);  \/* format message *\/\n  va_end(argp);\n  if (isLua(ci))  \/* if Lua function, add source:line information *\/\n    luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));\n  luaG_errormsg(L);\n}","target":1,"code_token_length":139,"total_token_length":375,"max_tokens_setting":512}
+{"idx":252335,"func":"static void cpy4(float *dst_val, const float *src_val) {\n  unsigned char *dst = reinterpret_cast<unsigned char *>(dst_val);\n  const unsigned char *src = reinterpret_cast<const unsigned char *>(src_val);\n\n  dst[0] = src[0];\n  dst[1] = src[1];\n  dst[2] = src[2];\n  dst[3] = src[3];\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":259249,"func":"static void mov_free_encryption_index(MOVEncryptionIndex **index) {\n    int i;\n    if (!index || !*index) return;\n    for (i = 0; i < (*index)->nb_encrypted_samples; i++) {\n        av_encryption_info_free((*index)->encrypted_samples[i]);\n    }\n    av_freep(&(*index)->encrypted_samples);\n    av_freep(&(*index)->auxiliary_info_sizes);\n    av_freep(&(*index)->auxiliary_offsets);\n    av_freep(index);\n}","target":0,"code_token_length":110,"total_token_length":346,"max_tokens_setting":512}
+{"idx":462562,"func":"std::string controller::write_temporary_item(std::shared_ptr<rss_item> item) {\n\tchar filename[_POSIX_PATH_MAX];\n\tsnprintf(filename, sizeof(filename), \"\/tmp\/newsbeuter-article.XXXXXX\");\n\tint fd = mkstemp(filename);\n\tif (fd != -1) {\n\t\twrite_item(item, filename);\n\t\tclose(fd);\n\t\treturn std::string(filename);\n\t} else {\n\t\treturn \"\";\n\t}\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":312579,"func":"vgr_init_regmatch(regmmatch_T *regmatch, char_u *s)\n{\n    \/\/ Get the search pattern: either white-separated or enclosed in \/\/\n    regmatch->regprog = NULL;\n\n    if (s == NULL || *s == NUL)\n    {\n\t\/\/ Pattern is empty, use last search pattern.\n\tif (last_search_pat() == NULL)\n\t{\n\t    emsg(_(e_no_previous_regular_expression));\n\t    return;\n\t}\n\tregmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC);\n    }\n    else\n\tregmatch->regprog = vim_regcomp(s, RE_MAGIC);\n\n    regmatch->rmm_ic = p_ic;\n    regmatch->rmm_maxcol = 0;\n}","target":0,"code_token_length":154,"total_token_length":390,"max_tokens_setting":512}
+{"idx":317202,"func":"static int smack_add_opt(int token, const char *s, void **mnt_opts)\n{\n\tstruct smack_mnt_opts *opts = *mnt_opts;\n\n\tif (!opts) {\n\t\topts = kzalloc(sizeof(struct smack_mnt_opts), GFP_KERNEL);\n\t\tif (!opts)\n\t\t\treturn -ENOMEM;\n\t\t*mnt_opts = opts;\n\t}\n\tif (!s)\n\t\treturn -ENOMEM;\n\n\tswitch (token) {\n\tcase Opt_fsdefault:\n\t\tif (opts->fsdefault)\n\t\t\tgoto out_opt_err;\n\t\topts->fsdefault = s;\n\t\tbreak;\n\tcase Opt_fsfloor:\n\t\tif (opts->fsfloor)\n\t\t\tgoto out_opt_err;\n\t\topts->fsfloor = s;\n\t\tbreak;\n\tcase Opt_fshat:\n\t\tif (opts->fshat)\n\t\t\tgoto out_opt_err;\n\t\topts->fshat = s;\n\t\tbreak;\n\tcase Opt_fsroot:\n\t\tif (opts->fsroot)\n\t\t\tgoto out_opt_err;\n\t\topts->fsroot = s;\n\t\tbreak;\n\tcase Opt_fstransmute:\n\t\tif (opts->fstransmute)\n\t\t\tgoto out_opt_err;\n\t\topts->fstransmute = s;\n\t\tbreak;\n\t}\n\treturn 0;\n\nout_opt_err:\n\tpr_warn(\"Smack: duplicate mount options\\n\");\n\treturn -EINVAL;\n}","target":0,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":289269,"func":"static int snd_pcm_oss_set_fragment(struct snd_pcm_oss_file *pcm_oss_file, unsigned int val)\n{\n\tint err = -EINVAL, idx;\n\n\tfor (idx = 1; idx >= 0; --idx) {\n\t\tstruct snd_pcm_substream *substream = pcm_oss_file->streams[idx];\n\t\tstruct snd_pcm_runtime *runtime;\n\n\t\tif (substream == NULL)\n\t\t\tcontinue;\n\t\truntime = substream->runtime;\n\t\terr = lock_params(runtime);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t\terr = snd_pcm_oss_set_fragment1(substream, val);\n\t\tunlock_params(runtime);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\treturn err;\n}","target":0,"code_token_length":153,"total_token_length":389,"max_tokens_setting":512}
+{"idx":175698,"func":"WifiNetwork::WifiNetwork(const ServiceInfo* service)\n    : WirelessNetwork(service) {\n  encryption_ = service->security;\n  passphrase_ = SafeString(service->passphrase);\n  identity_ = SafeString(service->identity);\n  cert_path_ = SafeString(service->cert_path);\n  type_ = TYPE_WIFI;\n}\n","target":0,"code_token_length":67,"total_token_length":303,"max_tokens_setting":512}
+{"idx":310331,"func":"directory_caches_dir_info(or_options_t *options)\n{\n  if (options->BridgeRelay || options->DirPort)\n    return 1;\n  if (!server_mode(options) || !advertised_server_mode())\n    return 0;\n  \/* We need an up-to-date view of network info if we're going to try to\n   * block exit attempts from unknown relays. *\/\n  return ! router_my_exit_policy_is_reject_star() &&\n    should_refuse_unknown_exits(options);\n}","target":0,"code_token_length":104,"total_token_length":340,"max_tokens_setting":512}
+{"idx":455427,"func":"xfs_reclaim_inodes_nr(\n\tstruct xfs_mount\t*mp,\n\tint\t\t\tnr_to_scan)\n{\n\t\/* kick background reclaimer and push the AIL *\/\n\txfs_reclaim_work_queue(mp);\n\txfs_ail_push_all(mp->m_ail);\n\n\treturn xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan);\n}","target":0,"code_token_length":79,"total_token_length":315,"max_tokens_setting":512}
+{"idx":512616,"func":"  longlong val_int()\n  {\n    DBUG_ASSERT(sane());\n    return null_value ? 0 :\n           m_value.to_datetime(current_thd).to_longlong();\n  }","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":175690,"func":"  virtual CellularNetwork* FindCellularNetworkByPath(\n      const std::string& path) {\n    return GetWirelessNetworkByPath(cellular_networks_, path);\n  }\n","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":90819,"func":"  int64 global_unlimited_usage() const { return global_unlimited_usage_; }\n","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":225559,"func":"void TfLiteIntArrayFree(TfLiteIntArray* a) { free(a); }","target":0,"code_token_length":17,"total_token_length":253,"max_tokens_setting":512}
+{"idx":385877,"func":"SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,\n\t\tumode_t, mode)\n{\n\tif (force_o_largefile())\n\t\tflags |= O_LARGEFILE;\n\n\treturn do_sys_open(dfd, filename, flags, mode);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":244257,"func":"void segr_box_del(GF_Box *s)\n{\n\tu32 i;\n\tFDSessionGroupBox *ptr = (FDSessionGroupBox *)s;\n\tif (ptr == NULL) return;\n\tfor (i=0; i<ptr->num_session_groups; i++) {\n\t\tif (ptr->session_groups[i].group_ids) gf_free(ptr->session_groups[i].group_ids);\n\t\tif (ptr->session_groups[i].channels) gf_free(ptr->session_groups[i].channels);\n\t}\n\tif (ptr->session_groups) gf_free(ptr->session_groups);\n\tgf_free(ptr);\n}","target":0,"code_token_length":122,"total_token_length":358,"max_tokens_setting":512}
+{"idx":226014,"func":"GF_Box *mdia_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MediaBox, GF_ISOM_BOX_TYPE_MDIA);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":261739,"func":"    size_t size() const override{\n        return _size;\n    }","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":221682,"func":"void Socket::resetChunk() {\n    chunk_to_read = 0;\n    chunked_trailer = \"\";\n    ieof = false;\n}","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":294449,"func":"d_lite_rfc2822(VALUE self)\n{\n    return strftimev(\"%a, %-d %b %Y %T %z\", self, set_tmx);\n}","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":512462,"func":"  Item *get_copy(THD *thd)\n  { return get_item_copy<Item_ref_null_helper>(thd, this); }","target":0,"code_token_length":29,"total_token_length":265,"max_tokens_setting":512}
+{"idx":391630,"func":"int dlpar_sysfs_init(void)\n{\n\tint error;\n\n\tdlpar_kobj = kobject_create_and_add(DLPAR_KOBJ_NAME,\n\t\t\t\t\t    &pci_slots_kset->kobj);\n\tif (!dlpar_kobj)\n\t\treturn -EINVAL;\n\n\terror = sysfs_create_group(dlpar_kobj, &dlpar_attr_group);\n\tif (error)\n\t\tkobject_put(dlpar_kobj);\n\treturn error;\n}","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":272352,"func":"generate_octet_string(cms_context *cms, SECItem *encoded, SECItem *original)\n{\n\tif (content_is_empty(original->data, original->len)) {\n\t\tcms->log(cms, LOG_ERR, \"content is empty, not encoding\");\n\t\treturn -1;\n\t}\n\tif (SEC_ASN1EncodeItem(cms->arena, encoded, original,\n\t\t\tSEC_OctetStringTemplate) == NULL)\n\t\tcnreterr(-1, cms, \"could not encode octet string\");\n\n\treturn 0;\n}","target":0,"code_token_length":113,"total_token_length":349,"max_tokens_setting":512}
+{"idx":294495,"func":"datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)\n{\n    VALUE str, sg, opt;\n\n    rb_scan_args(argc, argv, \"02:\", &str, &sg, &opt);\n    if (!NIL_P(opt)) argc--;\n\n    switch (argc) {\n      case 0:\n\tstr = rb_str_new2(\"-4712-01-01T00:00:00+00:00\");\n      case 1:\n\tsg = INT2FIX(DEFAULT_SG);\n    }\n\n    {\n        int argc2 = 1;\n        VALUE argv2[2];\n        argv2[0] = str;\n        argv2[1] = opt;\n        if (!NIL_P(opt)) argc2++;\n\tVALUE hash = date_s__rfc3339(argc2, argv2, klass);\n\treturn dt_new_by_frags(klass, hash, sg);\n    }\n}","target":0,"code_token_length":199,"total_token_length":435,"max_tokens_setting":512}
+{"idx":221669,"func":"std::string Socket::getPeerIP() {\n    char res[INET_ADDRSTRLEN];\n    return inet_ntop(AF_INET,&peer_adr.sin_addr, res, sizeof(res));\n}","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":286721,"func":"SWTPM_NVRAM_GetDecryptedData(const encryptionkey *key,\n                             unsigned char **decrypt_data,\n                             uint32_t *decrypt_length,\n                             const unsigned char *data,\n                             uint32_t length,\n                             uint16_t tag_encrypted_data,\n                             uint16_t tag_data,\n                             uint8_t hdrversion,\n                             uint16_t tag_ivec,\n                             uint16_t hdrflags,\n                             uint16_t flag_256bitkey)\n{\n    if (key && key->symkey.userKeyLength > 0) {\n        \/* we assume the data are encrypted when there's a key given *\/\n        return SWTPM_NVRAM_DecryptData(key, decrypt_data, decrypt_length,\n                                       data, length, tag_encrypted_data,\n                                       hdrversion, tag_ivec, hdrflags,\n                                       flag_256bitkey);\n    }\n    return SWTPM_NVRAM_GetPlainData(decrypt_data, decrypt_length,\n                                    data, length, tag_data, hdrversion);\n}","target":0,"code_token_length":215,"total_token_length":451,"max_tokens_setting":512}
+{"idx":500655,"func":"int sftp_closedir(sftp_dir dir){\n  int err = SSH_NO_ERROR;\n\n  SAFE_FREE(dir->name);\n  if (dir->handle) {\n    err = sftp_handle_close(dir->sftp, dir->handle);\n    ssh_string_free(dir->handle);\n  }\n  \/* FIXME: check server response and implement errno *\/\n  ssh_buffer_free(dir->buffer);\n  SAFE_FREE(dir);\n\n  return err;\n}","target":0,"code_token_length":88,"total_token_length":324,"max_tokens_setting":512}
+{"idx":283751,"func":"static uint64_t zynq_slcr_compute_pll(uint64_t input, uint32_t ctrl_reg)\n{\n    uint32_t mult = ((ctrl_reg & R_xxx_PLL_CTRL_PLL_FPDIV_MASK) >>\n            R_xxx_PLL_CTRL_PLL_FPDIV_SHIFT);\n\n    \/* first, check if pll is bypassed *\/\n    if (ctrl_reg & R_xxx_PLL_CTRL_PLL_BYPASS_FORCE_MASK) {\n        return input;\n    }\n\n    \/* is pll disabled ? *\/\n    if (ctrl_reg & (R_xxx_PLL_CTRL_PLL_RESET_MASK |\n                    R_xxx_PLL_CTRL_PLL_PWRDWN_MASK)) {\n        return 0;\n    }\n\n    \/* Consider zero feedback as maximum divide ratio possible *\/\n    if (!mult) {\n        mult = 1 << R_xxx_PLL_CTRL_PLL_FPDIV_LENGTH;\n    }\n\n    \/* frequency multiplier -> period division *\/\n    return input \/ mult;\n}","target":0,"code_token_length":192,"total_token_length":428,"max_tokens_setting":512}
+{"idx":317224,"func":"static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,\n\t\t\t\t      const void *value, size_t size, int flags)\n{\n\tstruct smack_known *skp;\n\tstruct inode_smack *isp = smack_inode(d_backing_inode(dentry));\n\n\tif (strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0) {\n\t\tisp->smk_flags |= SMK_INODE_TRANSMUTE;\n\t\treturn;\n\t}\n\n\tif (strcmp(name, XATTR_NAME_SMACK) == 0) {\n\t\tskp = smk_import_entry(value, size);\n\t\tif (!IS_ERR(skp))\n\t\t\tisp->smk_inode = skp;\n\t} else if (strcmp(name, XATTR_NAME_SMACKEXEC) == 0) {\n\t\tskp = smk_import_entry(value, size);\n\t\tif (!IS_ERR(skp))\n\t\t\tisp->smk_task = skp;\n\t} else if (strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {\n\t\tskp = smk_import_entry(value, size);\n\t\tif (!IS_ERR(skp))\n\t\t\tisp->smk_mmap = skp;\n\t}\n\n\treturn;\n}","target":0,"code_token_length":253,"total_token_length":489,"max_tokens_setting":512}
+{"idx":90852,"func":"  void GetAvailableSpace() {\n    quota_status_ = kQuotaStatusUnknown;\n    available_space_ = -1;\n    quota_manager_->GetAvailableSpace(\n        callback_factory_.NewCallback(\n            &QuotaManagerTest::DidGetAvailableSpace));\n  }\n","target":0,"code_token_length":55,"total_token_length":291,"max_tokens_setting":512}
+{"idx":482644,"func":"static inline unsigned int xt_write_recseq_begin(void)\n{\n\tunsigned int addend;\n\n\t\/*\n\t * Low order bit of sequence is set if we already\n\t * called xt_write_recseq_begin().\n\t *\/\n\taddend = (__this_cpu_read(xt_recseq.sequence) + 1) & 1;\n\n\t\/*\n\t * This is kind of a write_seqcount_begin(), but addend is 0 or 1\n\t * We dont check addend value to avoid a test and conditional jump,\n\t * since addend is most likely 1\n\t *\/\n\t__this_cpu_add(xt_recseq.sequence, addend);\n\tsmp_mb();\n\n\treturn addend;\n}","target":0,"code_token_length":140,"total_token_length":376,"max_tokens_setting":512}
+{"idx":512936,"func":"in_string::~in_string()\n{\n  if (base)\n  {\n    \/\/ base was allocated on THD::mem_root => following is OK\n    for (uint i=0 ; i < count ; i++)\n      ((String*) base)[i].free();\n  }\n}","target":0,"code_token_length":57,"total_token_length":293,"max_tokens_setting":512}
+{"idx":346446,"func":"get_scriptname(scid_T id)\n{\n    if (id == SID_MODELINE)\n\treturn (char_u *)_(\"modeline\");\n    if (id == SID_CMDARG)\n\treturn (char_u *)_(\"--cmd argument\");\n    if (id == SID_CARG)\n\treturn (char_u *)_(\"-c argument\");\n    if (id == SID_ENV)\n\treturn (char_u *)_(\"environment variable\");\n    if (id == SID_ERROR)\n\treturn (char_u *)_(\"error handler\");\n    if (id == SID_WINLAYOUT)\n\treturn (char_u *)_(\"changed window size\");\n    return SCRIPT_ITEM(id)->sn_name;\n}","target":0,"code_token_length":129,"total_token_length":365,"max_tokens_setting":512}
+{"idx":198983,"func":"SWTPM_NVRAM_CheckHeader(unsigned char *data, uint32_t length,\n                        uint32_t *dataoffset, uint16_t *hdrflags,\n                        uint8_t *hdrversion, bool quiet)\n{\n    blobheader *bh = (blobheader *)data;\n\n    if (length < sizeof(bh)) {\n        if (!quiet)\n            logprintf(STDERR_FILENO,\n                      \"not enough bytes for header: %u\\n\", length);\n        return TPM_BAD_PARAMETER;\n    }\n\n    if (ntohl(bh->totlen) != length) {\n        if (!quiet)\n            logprintf(STDERR_FILENO,\n                      \"broken header: bh->totlen %u != %u\\n\",\n                      htonl(bh->totlen), length);\n        return TPM_BAD_PARAMETER;\n    }\n\n    if (bh->min_version > BLOB_HEADER_VERSION) {\n        if (!quiet)\n            logprintf(STDERR_FILENO,\n                      \"Minimum required version for the blob is %d, we \"\n                      \"only support version %d\\n\", bh->min_version,\n                      BLOB_HEADER_VERSION);\n        return TPM_BAD_VERSION;\n    }\n\n    *hdrversion = bh->version;\n    *dataoffset = ntohs(bh->hdrsize);\n    *hdrflags = ntohs(bh->flags);\n\n    return TPM_SUCCESS;\n}","target":1,"code_token_length":271,"total_token_length":507,"max_tokens_setting":512}
+{"idx":477302,"func":"void tipc_crypto_stop(struct tipc_crypto **crypto)\n{\n\tstruct tipc_crypto *c = *crypto;\n\tu8 k;\n\n\tif (!c)\n\t\treturn;\n\n\t\/* Flush any queued works & destroy wq *\/\n\tif (is_tx(c)) {\n\t\tc->rekeying_intv = 0;\n\t\tcancel_delayed_work_sync(&c->work);\n\t\tdestroy_workqueue(c->wq);\n\t}\n\n\t\/* Release AEAD keys *\/\n\trcu_read_lock();\n\tfor (k = KEY_MIN; k <= KEY_MAX; k++)\n\t\ttipc_aead_put(rcu_dereference(c->aead[k]));\n\trcu_read_unlock();\n\tpr_debug(\"%s: has been stopped\\n\", c->name);\n\n\t\/* Free this crypto statistics *\/\n\tfree_percpu(c->stats);\n\n\t*crypto = NULL;\n\tkfree_sensitive(c);\n}","target":0,"code_token_length":174,"total_token_length":410,"max_tokens_setting":512}
+{"idx":477265,"func":"static void tipc_aead_users_inc(struct tipc_aead __rcu *aead, int lim)\n{\n\tstruct tipc_aead *tmp;\n\n\trcu_read_lock();\n\ttmp = rcu_dereference(aead);\n\tif (tmp)\n\t\tatomic_add_unless(&tmp->users, 1, lim);\n\trcu_read_unlock();\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":252327,"func":"mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip,\n                                               const char *pFilename,\n                                               mz_file_write_func pCallback,\n                                               void *pOpaque, mz_uint flags) {\n  int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);\n  if (file_index < 0) return MZ_FALSE;\n  return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque,\n                                           flags);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":259183,"func":"static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)\n{\n    AVStream *st;\n    uint8_t profile_level;\n    int ret;\n\n    if (c->fc->nb_streams < 1)\n        return 0;\n    st = c->fc->streams[c->fc->nb_streams-1];\n\n    if (atom.size >= (1<<28) || atom.size < 7)\n        return AVERROR_INVALIDDATA;\n\n    profile_level = avio_r8(pb);\n    if ((profile_level & 0xf0) != 0xc0)\n        return 0;\n\n    avio_seek(pb, 6, SEEK_CUR);\n    ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 7);\n    if (ret < 0)\n        return ret;\n\n    return 0;\n}","target":0,"code_token_length":189,"total_token_length":425,"max_tokens_setting":512}
+{"idx":440880,"func":"LogPrintMarkers(void)\n{\n    \/* Show what the message marker symbols mean. *\/\n    LogWrite(0, \"Markers: \");\n    LogMessageVerb(X_PROBED, 0, \"probed, \");\n    LogMessageVerb(X_CONFIG, 0, \"from config file, \");\n    LogMessageVerb(X_DEFAULT, 0, \"default setting,\\n\\t\");\n    LogMessageVerb(X_CMDLINE, 0, \"from command line, \");\n    LogMessageVerb(X_NOTICE, 0, \"notice, \");\n    LogMessageVerb(X_INFO, 0, \"informational,\\n\\t\");\n    LogMessageVerb(X_WARNING, 0, \"warning, \");\n    LogMessageVerb(X_ERROR, 0, \"error, \");\n    LogMessageVerb(X_NOT_IMPLEMENTED, 0, \"not implemented, \");\n    LogMessageVerb(X_UNKNOWN, 0, \"unknown.\\n\");\n}","target":0,"code_token_length":185,"total_token_length":421,"max_tokens_setting":512}
+{"idx":285159,"func":"static char *__get_target_os(r_bin_ne_obj_t *bin) {\n\tswitch (bin->ne_header->targOS) {\n\tcase 1:\n\t\treturn \"OS\/2\";\n\tcase 2:\n\t\treturn \"Windows\";\n\tcase 3:\n\t\treturn \"European MS-DOS 4.x\";\n\tcase 4:\n\t\treturn \"Windows 386\";\n\tcase 5:\n\t\treturn \"BOSS (Borland Operating System Services)\";\n\tdefault:\n\t\treturn \"Unknown\";\n\t}\n}","target":0,"code_token_length":102,"total_token_length":338,"max_tokens_setting":512}
+{"idx":224218,"func":"R_API void r_io_bank_fini(RIO *io) {\n\tr_return_if_fail (io);\n\tif (io->banks) {\n\t\tr_id_storage_foreach (io->banks, _bank_free_cb, NULL);\n\t\tr_id_storage_free (io->banks);\n\t\tio->banks = NULL;\n\t}\n}","target":0,"code_token_length":66,"total_token_length":302,"max_tokens_setting":512}
+{"idx":359364,"func":"DEFUN (ip_extcommunity_list_name_standard,\n       ip_extcommunity_list_name_standard_cmd,\n       \"ip extcommunity-list standard WORD (deny|permit) .AA:NN\",\n       IP_STR\n       EXTCOMMUNITY_LIST_STR\n       \"Specify standard extcommunity-list\\n\"\n       \"Extended Community list name\\n\"\n       \"Specify community to reject\\n\"\n       \"Specify community to accept\\n\"\n       EXTCOMMUNITY_VAL_STR)\n{\n  return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":413824,"func":"Method* LinkResolver::linktime_resolve_virtual_method_or_null(\n                                                 const LinkInfo& link_info) {\n  EXCEPTION_MARK;\n  Method* method_result = linktime_resolve_virtual_method(link_info, THREAD);\n  if (HAS_PENDING_EXCEPTION) {\n    CLEAR_PENDING_EXCEPTION;\n    return NULL;\n  } else {\n    return method_result;\n  }\n}","target":0,"code_token_length":71,"total_token_length":307,"max_tokens_setting":512}
+{"idx":229256,"func":"sstring to_string(const event::status_change::status_type t) {\n    using type = event::status_change::status_type;\n    switch (t) {\n    case type::UP:   return \"UP\";\n    case type::DOWN: return \"DOWN\";\n    }\n    throw std::invalid_argument(\"unknown change type\");\n}","target":0,"code_token_length":68,"total_token_length":304,"max_tokens_setting":512}
+{"idx":226057,"func":"\nGF_Box *dec3_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_AC3ConfigBox, GF_ISOM_BOX_TYPE_DAC3);\n\ttmp->cfg.is_ec3 = 1;\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":48,"total_token_length":284,"max_tokens_setting":512}
+{"idx":225679,"func":"GF_Err dinf_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_DataInformationBox *dinf;\n\tGF_Err e = gf_isom_box_array_read(s, bs);\n\tif (e) {\n\t\treturn e;\n\t}\n\tdinf = (GF_DataInformationBox *)s;\n\tif (!dinf->dref) {\n\t\tif (! (gf_bs_get_cookie(bs) & GF_ISOM_BS_COOKIE_NO_LOGS) ) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[iso file] Missing dref box in dinf\\n\"));\n\t\t}\n\t\tdinf->dref = (GF_DataReferenceBox *) gf_isom_box_new_parent(&dinf->child_boxes, GF_ISOM_BOX_TYPE_DREF);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":168,"total_token_length":404,"max_tokens_setting":512}
+{"idx":232328,"func":"GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode)\n{\n\tGF_Err e;\n\tGF_Blob *blob = NULL;\n\n\t\/\/if associated file is a blob, lock blob before parsing !\n\tif (mov->movieFileMap && ((mov->movieFileMap->type == GF_ISOM_DATA_MEM) || (mov->movieFileMap->type == GF_ISOM_DATA_FILE))) {\n\t\tblob = ((GF_FileDataMap *)mov->movieFileMap)->blob;\n\t}\n\n\tif (blob)\n\t\tgf_mx_p(blob->mx);\n\n\tunused_bytes = 0;\n\te = gf_isom_parse_movie_boxes_internal(mov, boxType, bytesMissing, progressive_mode);\n\n\tif (blob)\n\t\tgf_mx_v(blob->mx);\n\treturn e;\n\n}","target":0,"code_token_length":180,"total_token_length":416,"max_tokens_setting":512}
+{"idx":406210,"func":"static struct libmnt_table *append_fstab(struct libmnt_context *cxt,\n\t\t\t\t\t struct libmnt_table *fstab,\n\t\t\t\t\t const char *path)\n{\n\n\tif (!fstab) {\n\t\tfstab = mnt_new_table();\n\t\tif (!fstab)\n\t\t\terr(MOUNT_EX_SYSERR, _(\"failed to initialize libmount table\"));\n\n\t\tmnt_table_set_parser_errcb(fstab, table_parser_errcb);\n\t\tmnt_context_set_fstab(cxt, fstab);\n\t}\n\n\tif (mnt_table_parse_fstab(fstab, path))\n\t\terrx(MOUNT_EX_USAGE,_(\"%s: failed to parse\"), path);\n\n\treturn fstab;\n}","target":0,"code_token_length":135,"total_token_length":371,"max_tokens_setting":512}
+{"idx":233857,"func":"static void do_box_sequence(deark *c, struct de_boxesctx *bctx,\n\ti64 pos1, i64 len, i64 max_nboxes, int level)\n{\n\ti64 pos;\n\ti64 box_len;\n\ti64 endpos;\n\tint ret;\n\ti64 box_count = 0;\n\n\tif(level >= 32) { \/\/ An arbitrary recursion limit.\n\t\treturn;\n\t}\n\n\tpos = pos1;\n\tendpos = pos1 + len;\n\n\twhile(pos < endpos) {\n\t\tif(max_nboxes>=0 && box_count>=max_nboxes) break;\n\t\tret = do_box(c, bctx, pos, endpos-pos, level, &box_len);\n\t\tif(!ret) break;\n\t\tbox_count++;\n\t\tpos += box_len;\n\t}\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":274656,"func":"callbacks_reload_layer_clicked (GtkButton *button, gpointer user_data)\n{\n\tgint index = callbacks_get_selected_row_index ();\n\n\tif (index < 0) {\n\t\tshow_no_layers_warning ();\n\t\treturn;\n\t}\n\n\trender_remove_selected_objects_belonging_to_layer (\n\t\t\t&screen.selectionInfo, mainProject->file[index]->image);\n\tupdate_selected_object_message (FALSE);\n\n\tgerbv_revert_file (mainProject, index);\n\trender_refresh_rendered_image_on_screen ();\n\tcallbacks_update_layer_tree();\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":336670,"func":"void reds_handle_channel_event(RedsState *reds, int event, SpiceChannelEventInfo *info)\n{\n    reds->core.channel_event(&reds->core, event, info);\n\n    if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {\n        g_free(info);\n    }\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":90748,"func":"void CountOriginType(const std::set<GURL>& origins,\n                     SpecialStoragePolicy* policy,\n                     size_t* protected_origins,\n                     size_t* unlimited_origins) {\n  DCHECK(protected_origins);\n  DCHECK(unlimited_origins);\n  *protected_origins = 0;\n  *unlimited_origins = 0;\n  if (!policy)\n    return;\n  for (std::set<GURL>::const_iterator itr = origins.begin();\n       itr != origins.end();\n       ++itr) {\n    if (policy->IsStorageProtected(*itr))\n      ++*protected_origins;\n    if (policy->IsStorageUnlimited(*itr))\n      ++*unlimited_origins;\n  }\n}\n","target":0,"code_token_length":146,"total_token_length":382,"max_tokens_setting":512}
+{"idx":331774,"func":"void QPaintEngineEx::fillRect(const QRectF &r, const QBrush &brush)\n{\n    qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(),\n                    r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() };\n    QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint);\n    fill(vp, brush);\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":477977,"func":"void simplestring_add(simplestring* target, const char* source) {\n   if(target && source) {\n      simplestring_addn(target, source, strlen(source));\n   }\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":226963,"func":"IRC_PROTOCOL_CALLBACK(734)\n{\n    char *pos_args;\n\n    IRC_PROTOCOL_MIN_ARGS(5);\n\n    pos_args = (argc > 5) ?\n        ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL;\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (\n            server, NULL, command, \"monitor\", NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s (%s)\",\n        weechat_prefix (\"error\"),\n        (pos_args && pos_args[0]) ? pos_args : \"\",\n        argv[3]);\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":157,"total_token_length":393,"max_tokens_setting":512}
+{"idx":506698,"func":"static int set_cn2(X509 *crt, const char *name)\n{\n    return set_cn(crt, NID_commonName, \"dummy value\",\n                  NID_commonName, name, 0);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":441819,"func":"SProcXkbGetDeviceInfo(ClientPtr client)\n{\n    REQUEST(xkbGetDeviceInfoReq);\n\n    swaps(&stuff->length);\n    REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);\n    swaps(&stuff->deviceSpec);\n    swaps(&stuff->wanted);\n    swaps(&stuff->ledClass);\n    swaps(&stuff->ledID);\n    return ProcXkbGetDeviceInfo(client);\n}","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":477368,"func":"R_API void r_bin_java_print_element_pair_summary(RBinJavaElementValuePair *evp) {\n\tif (!evp) {\n\t\teprintf (\"Attempting to print an invalid RBinJavaElementValuePair *pair.\\n\");\n\t\treturn;\n\t}\n\tEprintf (\"Element Value Pair information:\\n\");\n\tEprintf (\"  EV Pair File Offset: 0x%08\"PFMT64x \"\\n\", evp->file_offset);\n\tEprintf (\"  EV Pair Element Name index: 0x%02x\\n\", evp->element_name_idx);\n\tEprintf (\"  EV Pair Element Name: %s\\n\", evp->name);\n\tEprintf (\"  EV Pair Element Value:\\n\");\n\tr_bin_java_print_element_value_summary (evp->value);\n}","target":0,"code_token_length":159,"total_token_length":395,"max_tokens_setting":512}
+{"idx":237877,"func":"qeh_in_on_close (struct lsquic_stream *stream, lsquic_stream_ctx_t *ctx)\n{\n    struct qpack_enc_hdl *const qeh = (void *) ctx;\n    LSQ_DEBUG(\"closed incoming decoder stream\");\n    qeh->qeh_dec_sm_in = NULL;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":328843,"func":"R_API void r_bin_java_get_method_json_definition(RBinJavaObj *bin, RBinJavaField *fm_type, PJ *pj) {\n\tr_bin_java_get_fm_type_definition_json (bin, fm_type, pj, 1);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":382793,"func":"static dynamicPtr * newDynamic (int initialSize, void *data, int freeOKFlag)\n{\n\tdynamicPtr *dp;\n\tdp = (dynamicPtr *) gdMalloc (sizeof (dynamicPtr));\n\n\tallocDynamic (dp, initialSize, data);\n\n\tdp->pos = 0;\n\tdp->freeOK = freeOKFlag;\n\n\treturn dp;\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":513172,"func":"sys_var_pluginvar::sys_var_pluginvar(sys_var_chain *chain, const char *name_arg,\n        st_plugin_int *p, st_mysql_sys_var *pv)\n    : sys_var(chain, name_arg, pv->comment, pluginvar_sysvar_flags(pv),\n              0, pv->flags & PLUGIN_VAR_NOCMDOPT ? -1 : 0, NO_ARG,\n              pluginvar_show_type(pv), 0,\n              NULL, VARIABLE_NOT_IN_BINLOG, NULL, NULL, NULL),\n    plugin(p), plugin_var(pv)\n{\n  plugin_var->name= name_arg;\n  plugin_opt_set_limits(&option, pv);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":384782,"func":"linetabsize(char_u *s)\n{\n    return linetabsize_col(0, s);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":468352,"func":"g_socket_client_get_proxy_resolver (GSocketClient *client)\n{\n  if (client->priv->proxy_resolver)\n    return client->priv->proxy_resolver;\n  else\n    return g_proxy_resolver_get_default ();\n}","target":0,"code_token_length":45,"total_token_length":281,"max_tokens_setting":512}
+{"idx":500072,"func":"kssl_krb5_get_server_rcache(krb5_context con, krb5_const krb5_data * data,\n                            krb5_rcache * rcache) \n        {\n\tif ( p_krb5_get_server_rcache )\n\t\treturn(p_krb5_get_server_rcache(con,data,rcache));\n\telse\n\t\treturn KRB5KRB_ERR_GENERIC;\n        }","target":0,"code_token_length":77,"total_token_length":313,"max_tokens_setting":512}
+{"idx":301375,"func":"static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,\n\t\t\t       uint64_t *dfree, uint64_t *dsize)\n{\n\tuint64_t result;\n\n\tresult = sys_disk_free(handle->conn, path, small_query, bsize, dfree, dsize);\n\treturn result;\n}","target":0,"code_token_length":85,"total_token_length":321,"max_tokens_setting":512}
+{"idx":238652,"func":"static int set_loop_callback_state(struct bpf_verifier_env *env,\n\t\t\t\t   struct bpf_func_state *caller,\n\t\t\t\t   struct bpf_func_state *callee,\n\t\t\t\t   int insn_idx)\n{\n\t\/* bpf_loop(u32 nr_loops, void *callback_fn, void *callback_ctx,\n\t *\t    u64 flags);\n\t * callback_fn(u32 index, void *callback_ctx);\n\t *\/\n\tcallee->regs[BPF_REG_1].type = SCALAR_VALUE;\n\tcallee->regs[BPF_REG_2] = caller->regs[BPF_REG_3];\n\n\t\/* unused *\/\n\t__mark_reg_not_init(env, &callee->regs[BPF_REG_3]);\n\t__mark_reg_not_init(env, &callee->regs[BPF_REG_4]);\n\t__mark_reg_not_init(env, &callee->regs[BPF_REG_5]);\n\n\tcallee->in_callback_fn = true;\n\treturn 0;\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":226024,"func":"GF_Err dinf_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\treturn gf_isom_box_write_header(s, bs);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":267950,"func":"R_API RBinPlugin *r_bin_file_cur_plugin(RBinFile *bf) {\n\treturn (bf && bf->o)? bf->o->plugin: NULL;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512774,"func":"Item_bool_rowready_func2* Ne_creator::create_swap(THD *thd, Item *a, Item *b) const\n{\n  return new(thd->mem_root) Item_func_ne(thd, b, a);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":236208,"func":"void hclr_box_del(GF_Box *s)\n{\n\tgf_free(s);\n}","target":0,"code_token_length":18,"total_token_length":254,"max_tokens_setting":512}
+{"idx":474076,"func":"euckr_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED, OnigEncoding enc ARG_UNUSED)\n{\n  const UChar c = *s;\n  if (c <= 0x7e) return TRUE;\n  else           return FALSE;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":224709,"func":"GF_Err iinf_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem)\n{\n\tGF_ItemInfoBox *ptr = (GF_ItemInfoBox *)s;\n\n\tif (a->type == GF_ISOM_BOX_TYPE_INFE) {\n\t\tBOX_FIELD_LIST_ASSIGN(item_infos)\n\t\treturn GF_OK;\n\t} else {\n\t\treturn GF_OK;\n\t}\n}","target":0,"code_token_length":80,"total_token_length":316,"max_tokens_setting":512}
+{"idx":402639,"func":"cmpstringp(const void *p1, const void *p2)\n{\n\treturn strcmp(*(char * const *)p1, *(char * const *)p2);\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":226259,"func":"GF_Err rtp_hnti_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tGF_RTPBox *ptr = (GF_RTPBox *)s;\n\tif (ptr == NULL) return GF_BAD_PARAM;\n\te = gf_isom_box_write_header(s, bs);\n\tif (e) return e;\n\tgf_bs_write_u32(bs, ptr->subType);\n\t\/\/don't write the NULL char!!!\n\tgf_bs_write_data(bs, ptr->sdpText, (u32) strlen(ptr->sdpText));\n\treturn GF_OK;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":459101,"func":"static void tc_chain_tmplt_del(const struct tcf_proto_ops *tmplt_ops,\n\t\t\t       void *tmplt_priv)\n{\n\t\/* If template ops are set, no work to do for us. *\/\n\tif (!tmplt_ops)\n\t\treturn;\n\n\ttmplt_ops->tmplt_destroy(tmplt_priv);\n\tmodule_put(tmplt_ops->owner);\n}","target":0,"code_token_length":72,"total_token_length":308,"max_tokens_setting":512}
+{"idx":477276,"func":"int tipc_crypto_key_init(struct tipc_crypto *c, struct tipc_aead_key *ukey,\n\t\t\t u8 mode, bool master_key)\n{\n\tstruct tipc_aead *aead = NULL;\n\tint rc = 0;\n\n\t\/* Initiate with the new user key *\/\n\trc = tipc_aead_init(&aead, ukey, mode);\n\n\t\/* Attach it to the crypto *\/\n\tif (likely(!rc)) {\n\t\trc = tipc_crypto_key_attach(c, aead, 0, master_key);\n\t\tif (rc < 0)\n\t\t\ttipc_aead_free(&aead->rcu);\n\t}\n\n\treturn rc;\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":317270,"func":"static int smk_curacc_on_task(struct task_struct *p, int access,\n\t\t\t\tconst char *caller)\n{\n\tstruct smk_audit_info ad;\n\tstruct smack_known *skp = smk_of_task_struct_obj(p);\n\tint rc;\n\n\tsmk_ad_init(&ad, caller, LSM_AUDIT_DATA_TASK);\n\tsmk_ad_setfield_u_tsk(&ad, p);\n\trc = smk_curacc(skp, access, &ad);\n\trc = smk_bu_task(p, access, rc);\n\treturn rc;\n}","target":0,"code_token_length":108,"total_token_length":344,"max_tokens_setting":512}
+{"idx":376338,"func":"gpg_context_set_property (GObject *object,\n                          guint property_id,\n                          const GValue *value,\n                          GParamSpec *pspec)\n{\n\tswitch (property_id) {\n\t\tcase PROP_ALWAYS_TRUST:\n\t\t\tcamel_gpg_context_set_always_trust (\n\t\t\t\tCAMEL_GPG_CONTEXT (object),\n\t\t\t\tg_value_get_boolean (value));\n\t\t\treturn;\n\t}\n\n\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);\n}","target":0,"code_token_length":96,"total_token_length":332,"max_tokens_setting":512}
+{"idx":247719,"func":"  TestUtilOptionsV2& setExpectedServerCertDigest(const std::string& expected_server_cert_digest) {\n    expected_server_cert_digest_ = expected_server_cert_digest;\n    return *this;\n  }","target":0,"code_token_length":42,"total_token_length":278,"max_tokens_setting":512}
+{"idx":369889,"func":"static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)\n{\n\tstruct inode *inode = dentry->d_inode;\n\tint error = -EACCES;\n\n\t\/* We don't need a base pointer in the \/proc filesystem *\/\n\tpath_put(&nd->path);\n\n\t\/* Are we allowed to snoop on the tasks file descriptors? *\/\n\tif (!proc_fd_access_allowed(inode))\n\t\tgoto out;\n\n\terror = PROC_I(inode)->op.proc_get_link(dentry, &nd->path);\nout:\n\treturn ERR_PTR(error);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":432193,"func":"void cpu_exec_unrealizefn(CPUState *cpu)\n{\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":359376,"func":"DEFUN (no_neighbor_attr_unchanged4,\n       no_neighbor_attr_unchanged4_cmd,\n       NO_NEIGHBOR_CMD2 \"attribute-unchanged med (as-path|next-hop)\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"BGP attribute is propagated unchanged to this neighbor\\n\"\n       \"Med attribute\\n\"\n       \"As-path attribute\\n\"\n       \"Nexthop attribute\\n\")\n{\n  u_int16_t flags = PEER_FLAG_MED_UNCHANGED;\n\n  if (strncmp (argv[1], \"as-path\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);\n  else if (strncmp (argv[1], \"next-hop\", 1) == 0)\n    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);\n\n  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),\n\t\t\t       bgp_node_safi (vty), flags);\n}","target":0,"code_token_length":222,"total_token_length":458,"max_tokens_setting":512}
+{"idx":221691,"func":"int Socket::getPeerSourcePort() {\n    return ntohs(peer_adr.sin_port);\n}","target":0,"code_token_length":19,"total_token_length":255,"max_tokens_setting":512}
+{"idx":317309,"func":"static void smack_task_to_inode(struct task_struct *p, struct inode *inode)\n{\n\tstruct inode_smack *isp = smack_inode(inode);\n\tstruct smack_known *skp = smk_of_task_struct_obj(p);\n\n\tisp->smk_inode = skp;\n\tisp->smk_flags |= SMK_INODE_INSTANT;\n}","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":387789,"func":"bool InstanceKlass::is_same_class_package(oop other_class_loader,\n                                          const Symbol* other_class_name) const {\n  if (class_loader() != other_class_loader) {\n    return false;\n  }\n  if (name()->fast_compare(other_class_name) == 0) {\n     return true;\n  }\n\n  {\n    ResourceMark rm;\n\n    bool bad_class_name = false;\n    const char* other_pkg =\n      ClassLoader::package_from_name((const char*) other_class_name->as_C_string(), &bad_class_name);\n    if (bad_class_name) {\n      return false;\n    }\n    \/\/ Check that package_from_name() returns NULL, not \"\", if there is no package.\n    assert(other_pkg == NULL || strlen(other_pkg) > 0, \"package name is empty string\");\n\n    const Symbol* const this_package_name =\n      this->package() != NULL ? this->package()->name() : NULL;\n\n    if (this_package_name == NULL || other_pkg == NULL) {\n      \/\/ One of the two doesn't have a package.  Only return true if the other\n      \/\/ one also doesn't have a package.\n      return (const char*)this_package_name == other_pkg;\n    }\n\n    \/\/ Check if package is identical\n    return this_package_name->equals(other_pkg);\n  }\n}","target":0,"code_token_length":273,"total_token_length":509,"max_tokens_setting":512}
+{"idx":221461,"func":"flatpak_context_load_for_deploy (FlatpakDeploy *deploy,\n                                 GError       **error)\n{\n  g_autoptr(FlatpakContext) context = NULL;\n  g_autoptr(FlatpakContext) overrides = NULL;\n  g_autoptr(GKeyFile) metakey = NULL;\n\n  metakey = flatpak_deploy_get_metadata (deploy);\n  context = flatpak_app_compute_permissions (metakey, NULL, error);\n  if (context == NULL)\n    return NULL;\n\n  overrides = flatpak_deploy_get_overrides (deploy);\n  flatpak_context_merge (context, overrides);\n\n  return g_steal_pointer (&context);\n}","target":0,"code_token_length":137,"total_token_length":373,"max_tokens_setting":512}
+{"idx":417096,"func":"void PlayerGeneric::setAllowFilters(bool b)\n{\n\tallowFilters = b;\n\n\tif (player)\n\t\tplayer->setAllowFilters(allowFilters);\n}","target":0,"code_token_length":32,"total_token_length":268,"max_tokens_setting":512}
+{"idx":427191,"func":"static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) {\n  Proto *f = fs->f;\n  fs->prev = ls->fs;  \/* linked list of funcstates *\/\n  fs->ls = ls;\n  ls->fs = fs;\n  fs->pc = 0;\n  fs->previousline = f->linedefined;\n  fs->iwthabs = 0;\n  fs->lasttarget = 0;\n  fs->freereg = 0;\n  fs->nk = 0;\n  fs->nabslineinfo = 0;\n  fs->np = 0;\n  fs->nups = 0;\n  fs->ndebugvars = 0;\n  fs->nactvar = 0;\n  fs->needclose = 0;\n  fs->firstlocal = ls->dyd->actvar.n;\n  fs->firstlabel = ls->dyd->label.n;\n  fs->bl = NULL;\n  f->source = ls->source;\n  luaC_objbarrier(ls->L, f, f->source);\n  f->maxstacksize = 2;  \/* registers 0\/1 are always valid *\/\n  enterblock(fs, bl, 0);\n}","target":0,"code_token_length":266,"total_token_length":502,"max_tokens_setting":512}
+{"idx":333084,"func":"frag(nfa_state_T *start, Ptrlist *out)\n{\n    Frag_T n;\n\n    n.start = start;\n    n.out = out;\n    return n;\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":90153,"func":"  template<typename T> const T GetWirelessNetworkByPath(\n      const std::vector<T>& networks, const std::string& path) const {\n    typedef typename std::vector<T>::const_iterator iter_t;\n    iter_t iter = std::find_if(networks.begin(), networks.end(),\n                               WirelessNetwork::ServicePathEq(path));\n    return (iter != networks.end()) ? *iter : NULL;\n  }\n","target":0,"code_token_length":86,"total_token_length":322,"max_tokens_setting":512}
+{"idx":276920,"func":"static int do_i2c_flags(struct cmd_tbl *cmdtp, int flag, int argc,\n\t\t\tchar *const argv[])\n{\n\tstruct udevice *dev;\n\tuint flags;\n\tint chip;\n\tint ret;\n\n\tif (argc < 2)\n\t\treturn CMD_RET_USAGE;\n\n\tchip = hextoul(argv[1], NULL);\n\tret = i2c_get_cur_bus_chip(chip, &dev);\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n\n\tif (argc > 2) {\n\t\tflags = hextoul(argv[2], NULL);\n\t\tret = i2c_set_chip_flags(dev, flags);\n\t} else  {\n\t\tret = i2c_get_chip_flags(dev, &flags);\n\t\tif (!ret)\n\t\t\tprintf(\"%x\\n\", flags);\n\t}\n\tif (ret)\n\t\treturn i2c_report_err(ret, I2C_ERR_READ);\n\n\treturn 0;\n}","target":0,"code_token_length":191,"total_token_length":427,"max_tokens_setting":512}
+{"idx":446420,"func":"static cache_hdr_t *read_cache_header(RzBuffer *cache_buf, ut64 offset) {\n\tif (!cache_buf) {\n\t\treturn NULL;\n\t}\n\n\tcache_hdr_t *hdr = RZ_NEW0(cache_hdr_t);\n\tif (!hdr) {\n\t\treturn NULL;\n\t}\n\n\tut64 size = sizeof(cache_hdr_t);\n\tif (rz_buf_fread_at(cache_buf, offset, (ut8 *)hdr, \"16c4i7l16clii4l\", 1) != size) {\n\t\tfree(hdr);\n\t\treturn NULL;\n\t}\n\tif (!rz_dyldcache_check_magic(hdr->magic)) {\n\t\tfree(hdr);\n\t\treturn NULL;\n\t}\n\n\tif (!hdr->imagesCount && !hdr->imagesOffset) {\n\t\tif (!rz_buf_read_le32_at(cache_buf, 0x1c0 + offset, &hdr->imagesOffset) || !rz_buf_read_le32_at(cache_buf, 0x1c4 + offset, &hdr->imagesCount)) {\n\t\t\tfree(hdr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\treturn hdr;\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":220904,"func":"void LongestPathsLowerBounds(\n    int source, const std::pair<int, int>& target_range,\n    const std::vector<std::vector<int>>& outputs,\n    std::vector<DistanceFromSource>* longest_distance) {\n  std::deque<int> queue;\n  queue.emplace_front(source);\n  while (!queue.empty()) {\n    int node = queue.front();\n    queue.pop_front();\n    for (int fanout : outputs[node]) {\n      \/\/ 1) Only nodes in the target range can be on paths from source to one of\n      \/\/    its control outputs.\n      \/\/ 2) Since we only need a lower bound on the longest distance, we can\n      \/\/    skip nodes for which we have already proven have a path of\n      \/\/    length > 1 from the source.\n      if (fanout >= target_range.first && fanout <= target_range.second &&\n          (*longest_distance)[fanout] != TWO_OR_GREATER) {\n        (*longest_distance)[fanout] =\n            (*longest_distance)[fanout] == ZERO ? ONE : TWO_OR_GREATER;\n        queue.emplace_front(fanout);\n      }\n    }\n  }\n}","target":0,"code_token_length":243,"total_token_length":479,"max_tokens_setting":512}
+{"idx":247134,"func":"u32 gf_fs_get_max_resolution_chain_length(GF_FilterSession *session)\n{\n\tif (!session) return 0;\n\treturn session->max_resolve_chain_len;\n}","target":0,"code_token_length":35,"total_token_length":271,"max_tokens_setting":512}
+{"idx":512619,"func":"int Regexp_processor_pcre::default_regex_flags()\n{\n  return default_regex_flags_pcre(current_thd);\n}","target":0,"code_token_length":24,"total_token_length":260,"max_tokens_setting":512}
+{"idx":401578,"func":"static int random_fasync(int fd, struct file *filp, int on)\n{\n\treturn fasync_helper(fd, filp, on, &fasync);\n}","target":0,"code_token_length":34,"total_token_length":270,"max_tokens_setting":512}
+{"idx":253701,"func":"ccp_run_ecc_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)\n{\n\tstruct ccp_ecc_engine *ecc = &cmd->u.ecc;\n\n\tecc->ecc_result = 0;\n\n\tif (!ecc->mod ||\n\t    (ecc->mod_len > CCP_ECC_MODULUS_BYTES))\n\t\treturn -EINVAL;\n\n\tswitch (ecc->function) {\n\tcase CCP_ECC_FUNCTION_MMUL_384BIT:\n\tcase CCP_ECC_FUNCTION_MADD_384BIT:\n\tcase CCP_ECC_FUNCTION_MINV_384BIT:\n\t\treturn ccp_run_ecc_mm_cmd(cmd_q, cmd);\n\n\tcase CCP_ECC_FUNCTION_PADD_384BIT:\n\tcase CCP_ECC_FUNCTION_PMUL_384BIT:\n\tcase CCP_ECC_FUNCTION_PDBL_384BIT:\n\t\treturn ccp_run_ecc_pm_cmd(cmd_q, cmd);\n\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}","target":0,"code_token_length":193,"total_token_length":429,"max_tokens_setting":512}
+{"idx":385836,"func":"SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode)\n{\n\tstruct path path;\n\tint error;\n\tunsigned int lookup_flags = LOOKUP_FOLLOW;\nretry:\n\terror = user_path_at(dfd, filename, lookup_flags, &path);\n\tif (!error) {\n\t\terror = chmod_common(&path, mode);\n\t\tpath_put(&path);\n\t\tif (retry_estale(error, lookup_flags)) {\n\t\t\tlookup_flags |= LOOKUP_REVAL;\n\t\t\tgoto retry;\n\t\t}\n\t}\n\treturn error;\n}","target":0,"code_token_length":117,"total_token_length":353,"max_tokens_setting":512}
+{"idx":344792,"func":"get_u32_le(const void *vp)\n{\n\tconst u_char *p = (const u_char *)vp;\n\tu_int32_t v;\n\n\tv  = (u_int32_t)p[0];\n\tv |= (u_int32_t)p[1] << 8;\n\tv |= (u_int32_t)p[2] << 16;\n\tv |= (u_int32_t)p[3] << 24;\n\n\treturn (v);\n}","target":0,"code_token_length":99,"total_token_length":335,"max_tokens_setting":512}
+{"idx":252448,"func":"static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip,\n                                                       mz_zip_array *pArray,\n                                                       size_t n) {\n  return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE);\n}","target":0,"code_token_length":60,"total_token_length":296,"max_tokens_setting":512}
+{"idx":225006,"func":"defaultNoticeProcessor(void *arg, const char *message)\n{\n\t(void) arg;\t\t\t\t\t\/* not used *\/\n\t\/* Note: we expect the supplied string to end with a newline already. *\/\n\tfprintf(stderr, \"%s\", message);\n}","target":0,"code_token_length":50,"total_token_length":286,"max_tokens_setting":512}
+{"idx":445875,"func":"fr_window_init (FrWindow *window)\n{\n\twindow->priv = g_new0 (FrWindowPrivate, 1);\n\twindow->priv->update_dropped_files = FALSE;\n\twindow->priv->filter_mode = FALSE;\n\twindow->priv->use_progress_dialog = TRUE;\n\twindow->priv->batch_title = NULL;\n\twindow->priv->cancellable = g_cancellable_new ();\n\twindow->priv->compression = FR_COMPRESSION_NORMAL;\n\twindow->priv->window_group = gtk_window_group_new ();\n\twindow->priv->populating_file_list = FALSE;\n\twindow->priv->named_dialogs = g_hash_table_new (g_str_hash, g_str_equal);\n\tgtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));\n\n\twindow->archive = NULL;\n}","target":0,"code_token_length":156,"total_token_length":392,"max_tokens_setting":512}
+{"idx":222843,"func":"Status GraphProperties::InferDynamically(Cluster* cluster) {\n  TF_RETURN_IF_ERROR(cluster->Initialize(item_));\n\n  \/\/ Runs the model once to collect the shapes in the cost model.\n  RunMetadata metadata;\n  TF_RETURN_IF_ERROR(\n      cluster->Run(item_.graph, item_.feed, item_.fetch, &metadata));\n\n  return InferFromCostGraph(metadata.cost_graph());\n}","target":0,"code_token_length":82,"total_token_length":318,"max_tokens_setting":512}
+{"idx":261750,"func":"RtmpProtocol::~RtmpProtocol() {\n    reset();\n}","target":0,"code_token_length":13,"total_token_length":249,"max_tokens_setting":512}
+{"idx":310156,"func":"NCURSES_SP_NAME(_nc_mvcur) (NCURSES_SP_DCLx\n\t\t\t    int yold, int xold,\n\t\t\t    int ynew, int xnew)\n{\n    int rc;\n    rc = _nc_real_mvcur(NCURSES_SP_ARGx yold, xold, ynew, xnew,\n\t\t\tNCURSES_SP_NAME(_nc_outch),\n\t\t\tTRUE);\n    \/*\n     * With the terminal-driver, we cannot distinguish between internal and\n     * external calls.  Flush the output if the screen has not been\n     * initialized, e.g., when used from low-level terminfo programs.\n     *\/\n    if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))\n\tNCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);\n    return rc;\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":387860,"func":"bool InstanceKlass::supers_have_passed_fingerprint_checks() {\n  if (java_super() != NULL && !java_super()->has_passed_fingerprint_check()) {\n    ResourceMark rm;\n    log_trace(class, fingerprint)(\"%s : super %s not fingerprinted\", external_name(), java_super()->external_name());\n    return false;\n  }\n\n  Array<Klass*>* local_interfaces = this->local_interfaces();\n  if (local_interfaces != NULL) {\n    int length = local_interfaces->length();\n    for (int i = 0; i < length; i++) {\n      InstanceKlass* intf = InstanceKlass::cast(local_interfaces->at(i));\n      if (!intf->has_passed_fingerprint_check()) {\n        ResourceMark rm;\n        log_trace(class, fingerprint)(\"%s : interface %s not fingerprinted\", external_name(), intf->external_name());\n        return false;\n      }\n    }\n  }\n\n  return true;\n}","target":0,"code_token_length":194,"total_token_length":430,"max_tokens_setting":512}
+{"idx":220196,"func":"void Graph::RecycleEdge(const Edge* e) {\n  free_edges_.push_back(const_cast<Edge*>(e));\n}","target":0,"code_token_length":25,"total_token_length":261,"max_tokens_setting":512}
+{"idx":90902,"func":"void ClientUsageTracker::NoopHostUsageCallback(\n    const std::string& host,  StorageType type, int64 usage) {\n}\n","target":0,"code_token_length":31,"total_token_length":267,"max_tokens_setting":512}
+{"idx":222507,"func":"  void AppendTo(bool first, string* s) const {\n    absl::string_view v;\n    bool add_escaped = false;\n    if ((value_op_ == kCEscape) && NeedsEscaping(value_)) {\n      \/\/ Use CEscape call below\n      add_escaped = true;\n    } else {\n      \/\/ Add raw value contents directly\n      v = value_;\n    }\n    if (key_suffix_ >= 0) {\n      strings::StrAppend(s, first ? \"\" : \",\", key_name_, key_suffix_, \"=\", v);\n    } else {\n      strings::StrAppend(s, first ? \"\" : \",\", key_name_, \"=\", v);\n    }\n    if (add_escaped) {\n      strings::StrAppend(s, absl::CEscape(value_));\n    }\n  }","target":0,"code_token_length":162,"total_token_length":398,"max_tokens_setting":512}
+{"idx":90911,"func":"  virtual ~GatherGlobalUsageTask() {}\n","target":0,"code_token_length":10,"total_token_length":246,"max_tokens_setting":512}
+{"idx":235256,"func":"static void setup_buffer(uint8_t *buf, unsigned int seed, int len)\n{\n\tint i;\n\tsrandom(seed);\n\tfor (i=0;i<len;i++) buf[i] = random();\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":459087,"func":"int tcf_qevent_dump(struct sk_buff *skb, int attr_name, struct tcf_qevent *qe)\n{\n\tif (!qe->info.block_index)\n\t\treturn 0;\n\treturn nla_put_u32(skb, attr_name, qe->info.block_index);\n}","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":90751,"func":"void QuotaManager::DeleteOriginData(\n    const GURL& origin, StorageType type, StatusCallback* callback) {\n  LazyInitialize();\n\n  if (origin.is_empty() || clients_.empty()) {\n    callback->Run(kQuotaStatusOk);\n    delete callback;\n    return;\n  }\n\n  OriginDataDeleter* deleter =\n      new OriginDataDeleter(this, origin, type, callback);\n  deleter->Start();\n}\n","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":281051,"func":"static inline int xfrm_bydst_should_resize(struct net *net, int dir, int *total)\n{\n\tunsigned int cnt = net->xfrm.policy_count[dir];\n\tunsigned int hmask = net->xfrm.policy_bydst[dir].hmask;\n\n\tif (total)\n\t\t*total += cnt;\n\n\tif ((hmask + 1) < xfrm_policy_hashmax &&\n\t    cnt > hmask)\n\t\treturn 1;\n\n\treturn 0;\n}","target":0,"code_token_length":93,"total_token_length":329,"max_tokens_setting":512}
+{"idx":275515,"func":"njs_vm_start(njs_vm_t *vm)\n{\n    njs_int_t  ret;\n\n    ret = njs_module_load(vm);\n    if (njs_slow_path(ret != NJS_OK)) {\n        return ret;\n    }\n\n    ret = njs_vmcode_interpreter(vm, vm->start, NULL, NULL);\n\n    return (ret == NJS_ERROR) ? NJS_ERROR : NJS_OK;\n}","target":0,"code_token_length":87,"total_token_length":323,"max_tokens_setting":512}
+{"idx":247149,"func":"void gf_fs_print_unused_args(GF_FilterSession *fsess, const char *ignore_args)\n{\n\tu32 idx = 0;\n\tchar *argname;\n\tu32 argtype;\n\n\twhile (1) {\n\t\tBool found = GF_FALSE;\n\t\tconst char *loc_arg;\n\t\tif (gf_fs_enum_unmapped_options(fsess, &idx, &argname, &argtype)==GF_FALSE)\n\t\t\tbreak;\n\n\t\tloc_arg = ignore_args;\n\t\twhile (loc_arg) {\n\t\t\tu32 len;\n\t\t\tchar *sep;\n\t\t\tchar *match = strstr(loc_arg, argname);\n\t\t\tif (!match) break;\n\t\t\tlen = (u32) strlen(argname);\n\t\t\tif (!match[len] || (match[len]==',')) {\n\t\t\t\tfound = GF_TRUE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsep = strchr(loc_arg, ',');\n\t\t\tif (!sep) break;\n\t\t\tloc_arg = sep+1;\n\t\t}\n\t\tif (found) continue;\n\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_APP, (\"Arg %s set but not used\\n\", argname));\n\t}\n}","target":0,"code_token_length":235,"total_token_length":471,"max_tokens_setting":512}
+{"idx":256423,"func":"static void pjmedia_rtcp_fb_cap_dup(pj_pool_t *pool,\n\t\t\t\t    pjmedia_rtcp_fb_cap *dst,\n\t\t\t\t    const pjmedia_rtcp_fb_cap *src)\n{\n    pj_strdup(pool, &dst->codec_id, &src->codec_id);\n    dst->type = src->type;\n    pj_strdup(pool, &dst->type_name, &src->type_name);\n    pj_strdup(pool, &dst->param, &src->param);\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":225694,"func":"\nGF_Box *lsrc_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_LASERConfigurationBox, GF_ISOM_BOX_TYPE_LSRC);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":39,"total_token_length":275,"max_tokens_setting":512}
+{"idx":346453,"func":"estack_top_is_ufunc(ufunc_T *ufunc, long lnum)\n{\n    estack_T *entry;\n\n    if (exestack.ga_len == 0)\n\treturn FALSE;\n    entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;\n    return entry->es_type == ETYPE_UFUNC\n\t&& STRCMP( entry->es_name, ufunc->uf_name_exp != NULL\n\t\t\t\t    ? ufunc->uf_name_exp : ufunc->uf_name) == 0\n\t&& entry->es_lnum == lnum;\n}","target":0,"code_token_length":128,"total_token_length":364,"max_tokens_setting":512}
+{"idx":226994,"func":"IRC_PROTOCOL_CALLBACK(733)\n{\n    char *pos_args;\n\n    IRC_PROTOCOL_MIN_ARGS(3);\n\n    pos_args = (argc > 3) ?\n        ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;\n\n    weechat_printf_date_tags (\n        irc_msgbuffer_get_target_buffer (\n            server, NULL, command, \"monitor\", NULL),\n        date,\n        irc_protocol_tags (command, \"irc_numeric\", NULL, NULL),\n        \"%s%s\",\n        weechat_prefix (\"network\"),\n        (pos_args && pos_args[0]) ? pos_args : \"\");\n\n    return WEECHAT_RC_OK;\n}","target":0,"code_token_length":150,"total_token_length":386,"max_tokens_setting":512}
+{"idx":424954,"func":"void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans, u8 max_power)\n{\n\tif (!max_power) {\n\t\t\/* default max_power is maximum *\/\n\t\tmax_power = 26;\n\t} else {\n\t\tmax_power += 11;\n\t}\n\n\tif (WARN(max_power > 26,\n\t\t \"External buffer size for monitor is too big %d, check the FW TLV\\n\",\n\t\t max_power))\n\t\treturn;\n\n\t\/*\n\t * This function allocats the default fw monitor.\n\t * The optional additional ones will be allocated in runtime\n\t *\/\n\tif (trans->dbg.num_blocks)\n\t\treturn;\n\n\tiwl_pcie_alloc_fw_monitor_block(trans, max_power, 11);\n}","target":0,"code_token_length":151,"total_token_length":387,"max_tokens_setting":512}
+{"idx":225037,"func":"PQsetClientEncoding(PGconn *conn, const char *encoding)\n{\n\tchar\t\tqbuf[128];\n\tstatic const char query[] = \"set client_encoding to '%s'\";\n\tPGresult   *res;\n\tint\t\t\tstatus;\n\n\tif (!conn || conn->status != CONNECTION_OK)\n\t\treturn -1;\n\n\tif (!encoding)\n\t\treturn -1;\n\n\t\/* Resolve special \"auto\" value from the locale *\/\n\tif (strcmp(encoding, \"auto\") == 0)\n\t\tencoding = pg_encoding_to_char(pg_get_encoding_from_locale(NULL, true));\n\n\t\/* check query buffer overflow *\/\n\tif (sizeof(qbuf) < (sizeof(query) + strlen(encoding)))\n\t\treturn -1;\n\n\t\/* ok, now send a query *\/\n\tsprintf(qbuf, query, encoding);\n\tres = PQexec(conn, qbuf);\n\n\tif (res == NULL)\n\t\treturn -1;\n\tif (res->resultStatus != PGRES_COMMAND_OK)\n\t\tstatus = -1;\n\telse\n\t{\n\t\t\/*\n\t\t * We rely on the backend to report the parameter value, and we'll\n\t\t * change state at that time.\n\t\t *\/\n\t\tstatus = 0;\t\t\t\t\/* everything is ok *\/\n\t}\n\tPQclear(res);\n\treturn status;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":253567,"func":"smb21_is_read_op(__u32 oplock)\n{\n\treturn (oplock & SMB2_LEASE_READ_CACHING_HE) &&\n\t       !(oplock & SMB2_LEASE_WRITE_CACHING_HE);\n}","target":0,"code_token_length":47,"total_token_length":283,"max_tokens_setting":512}
+{"idx":412104,"func":"dnsc_key_to_fingerprint(char fingerprint[80U], const uint8_t * const key)\n{\n    const size_t fingerprint_size = 80U;\n    size_t       fingerprint_pos = (size_t) 0U;\n    size_t       key_pos = (size_t) 0U;\n\n    for (;;) {\n        assert(fingerprint_size > fingerprint_pos);\n        snprintf(&fingerprint[fingerprint_pos],\n                        fingerprint_size - fingerprint_pos, \"%02X%02X\",\n                        key[key_pos], key[key_pos + 1U]);\n        key_pos += 2U;\n        if (key_pos >= crypto_box_PUBLICKEYBYTES) {\n            break;\n        }\n        fingerprint[fingerprint_pos + 4U] = ':';\n        fingerprint_pos += 5U;\n    }\n}","target":0,"code_token_length":165,"total_token_length":401,"max_tokens_setting":512}
+{"idx":369913,"func":"proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,\n\t\t\t   struct task_struct *task, const void *ptr)\n{\n\tconst struct file *file = ptr;\n\tstruct proc_inode *ei;\n\tstruct inode *inode;\n\n\tif (!file)\n\t\treturn ERR_PTR(-ENOENT);\n\n\tinode = proc_pid_make_inode(dir->i_sb, task);\n\tif (!inode)\n\t\treturn ERR_PTR(-ENOENT);\n\n\tei = PROC_I(inode);\n\tei->op.proc_get_link = proc_map_files_get_link;\n\n\tinode->i_op = &proc_pid_link_inode_operations;\n\tinode->i_size = 64;\n\tinode->i_mode = S_IFLNK;\n\n\tif (file->f_mode & FMODE_READ)\n\t\tinode->i_mode |= S_IRUSR;\n\tif (file->f_mode & FMODE_WRITE)\n\t\tinode->i_mode |= S_IWUSR;\n\n\td_set_d_op(dentry, &tid_map_files_dentry_operations);\n\td_add(dentry, inode);\n\n\treturn NULL;\n}","target":0,"code_token_length":212,"total_token_length":448,"max_tokens_setting":512}
+{"idx":281147,"func":"static unsigned int xfrm_mtu(const struct dst_entry *dst)\n{\n\tunsigned int mtu = dst_metric_raw(dst, RTAX_MTU);\n\n\treturn mtu ? : dst_mtu(dst->path);\n}","target":0,"code_token_length":43,"total_token_length":279,"max_tokens_setting":512}
+{"idx":513198,"func":"void wsrep_plugins_post_init()\n{\n  THD *thd;\n  I_List_iterator<THD> it(threads);\n\n  while ((thd= it++))\n  {\n    if (IF_WSREP(thd->wsrep_applier,1))\n    {\n      \/\/ Save options_bits as it will get overwritten in plugin_thdvar_init()\n      ulonglong option_bits_saved= thd->variables.option_bits;\n\n      plugin_thdvar_init(thd);\n\n      \/\/ Restore option_bits\n      thd->variables.option_bits= option_bits_saved;\n    }\n  }\n\n  return;\n}","target":0,"code_token_length":121,"total_token_length":357,"max_tokens_setting":512}
+{"idx":487657,"func":"asmlinkage long sys_setuid(uid_t uid)\n{\n\tint old_euid = current->euid;\n\tint old_ruid, old_suid, new_suid;\n\tint retval;\n\n\tretval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);\n\tif (retval)\n\t\treturn retval;\n\n\told_ruid = current->uid;\n\told_suid = current->suid;\n\tnew_suid = old_suid;\n\t\n\tif (capable(CAP_SETUID)) {\n\t\tif (uid != old_ruid && set_user(uid, old_euid != uid) < 0)\n\t\t\treturn -EAGAIN;\n\t\tnew_suid = uid;\n\t} else if ((uid != current->uid) && (uid != new_suid))\n\t\treturn -EPERM;\n\n\tif (old_euid != uid) {\n\t\tcurrent->mm->dumpable = suid_dumpable;\n\t\tsmp_wmb();\n\t}\n\tcurrent->fsuid = current->euid = uid;\n\tcurrent->suid = new_suid;\n\n\tkey_fsuid_changed(current);\n\tproc_id_connector(current, PROC_EVENT_UID);\n\n\treturn security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);\n}","target":0,"code_token_length":259,"total_token_length":495,"max_tokens_setting":512}
+{"idx":309818,"func":"__nc_putp_flush(SCREEN *sp, const char *name, const char *value)\n{\n    int rc = __nc_putp(sp, name, value);\n    if (rc != ERR) {\n\tNCURSES_SP_NAME(_nc_flush) (sp);\n    }\n    return rc;\n}","target":0,"code_token_length":63,"total_token_length":299,"max_tokens_setting":512}
+{"idx":333097,"func":"pim_info(nfa_pim_T *pim)\n{\n    static char buf[30];\n\n    if (pim == NULL || pim->result == NFA_PIM_UNUSED)\n\tbuf[0] = NUL;\n    else\n    {\n\tsprintf(buf, \" PIM col %d\", REG_MULTI ? (int)pim->end.pos.col\n\t\t: (int)(pim->end.ptr - rex.input));\n    }\n    return buf;\n}","target":0,"code_token_length":97,"total_token_length":333,"max_tokens_setting":512}
+{"idx":238616,"func":"static void sort_kfunc_descs_by_imm(struct bpf_prog *prog)\n{\n\tstruct bpf_kfunc_desc_tab *tab;\n\n\ttab = prog->aux->kfunc_tab;\n\tif (!tab)\n\t\treturn;\n\n\tsort(tab->descs, tab->nr_descs, sizeof(tab->descs[0]),\n\t     kfunc_desc_cmp_by_imm, NULL);\n}","target":0,"code_token_length":75,"total_token_length":311,"max_tokens_setting":512}
+{"idx":244343,"func":"GF_Err ainf_box_size(GF_Box *s)\n{\n\tGF_AssetInformationBox *ptr = (GF_AssetInformationBox *) s;\n    s->size += 4 + (ptr->APID ? strlen(ptr->APID) : 0 ) + 1;\n\treturn GF_OK;\n}","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":376350,"func":"gpg_ctx_add_recipient (struct _GpgCtx *gpg,\n                       const gchar *keyid)\n{\n\tgchar *safe_keyid;\n\n\tif (gpg->mode != GPG_CTX_MODE_ENCRYPT && gpg->mode != GPG_CTX_MODE_EXPORT)\n\t\treturn;\n\n\tif (!gpg->recipients)\n\t\tgpg->recipients = g_ptr_array_new ();\n\n\tg_return_if_fail (keyid != NULL);\n\n\t\/* If the recipient looks like an email address,\n\t * enclose it in brackets to ensure an exact match. *\/\n\tif (strchr (keyid, '@') != NULL) {\n\t\tsafe_keyid = g_strdup_printf (\"<%s>\", keyid);\n\t} else {\n\t\tsafe_keyid = g_strdup (keyid);\n\t}\n\n\tg_ptr_array_add (gpg->recipients, safe_keyid);\n}","target":0,"code_token_length":178,"total_token_length":414,"max_tokens_setting":512}
+{"idx":242119,"func":"int LuaSettings::l_to_table(lua_State* L)\n{\n\tNO_MAP_LOCK_REQUIRED;\n\tLuaSettings* o = checkobject(L, 1);\n\n\tMutexAutoLock(o->m_settings->m_mutex);\n\tpush_settings_table(L, o->m_settings);\n\treturn 1;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":234244,"func":"is_max_address (dwarf_vma addr, unsigned int pointer_size)\n{\n  dwarf_vma mask = ~(~(dwarf_vma) 1 << (pointer_size * 8 - 1));\n  return ((addr & mask) == mask);\n}","target":0,"code_token_length":54,"total_token_length":290,"max_tokens_setting":512}
+{"idx":417132,"func":"mp_sint32 PlayerGeneric::getCurrentBeatIndex()\n{\n\tif (player)\n\t\treturn player->getBeatIndexFromSamplePos(getCurrentSamplePosition());\n\t\n\treturn 0;\n}","target":0,"code_token_length":38,"total_token_length":274,"max_tokens_setting":512}
+{"idx":359556,"func":"DEFUN (no_bgp_redistribute_ipv4,\n       no_bgp_redistribute_ipv4_cmd,\n       \"no redistribute (connected|kernel|ospf|rip|static)\",\n       NO_STR\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPF)\\n\"\n       \"Routing Information Protocol (RIP)\\n\"\n       \"Static routes\\n\")\n{\n  int type;\n\n  type = bgp_str2route_type (AFI_IP, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  return bgp_redistribute_unset (vty->index, AFI_IP, type);\n}","target":0,"code_token_length":171,"total_token_length":407,"max_tokens_setting":512}
+{"idx":244105,"func":"GF_Err stvi_box_size(GF_Box *s)\n{\n\tGF_StereoVideoBox *ptr = (GF_StereoVideoBox *)s;\n\n\tptr->size+= 12 + ptr->sit_len;\n\treturn GF_OK;\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":253730,"func":"static void ccp_sg_free(struct ccp_sg_workarea *wa)\n{\n\tif (wa->dma_count)\n\t\tdma_unmap_sg(wa->dma_dev, wa->dma_sg_head, wa->nents, wa->dma_dir);\n\n\twa->dma_count = 0;\n}","target":0,"code_token_length":59,"total_token_length":295,"max_tokens_setting":512}
+{"idx":233885,"func":" *\/\nstatic int wddx_stack_init(wddx_stack *stack)\n{\n\tstack->top = 0;\n\tstack->elements = (void **) safe_emalloc(sizeof(void **), STACK_BLOCK_SIZE, 0);\n\tstack->max = STACK_BLOCK_SIZE;\n\tstack->varname = NULL;\n\tstack->done = 0;\n\n\treturn SUCCESS;","target":0,"code_token_length":69,"total_token_length":305,"max_tokens_setting":512}
+{"idx":90187,"func":"bool CellularNetwork::StartActivation() const {\n  if (!EnsureCrosLoaded())\n    return false;\n  return ActivateCellularModem(service_path_.c_str(), NULL);\n}\n","target":0,"code_token_length":37,"total_token_length":273,"max_tokens_setting":512}
+{"idx":247140,"func":"const GF_FilterRegister * gf_fs_get_filter_register(GF_FilterSession *fsess, u32 idx)\n{\n\treturn gf_list_get(fsess->registry, idx);\n}","target":0,"code_token_length":36,"total_token_length":272,"max_tokens_setting":512}
+{"idx":226104,"func":"GF_Box *mehd_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_MovieExtendsHeaderBox, GF_ISOM_BOX_TYPE_MEHD);\n\treturn (GF_Box *)tmp;\n}","target":0,"code_token_length":41,"total_token_length":277,"max_tokens_setting":512}
+{"idx":338187,"func":"void WasmBinaryBuilder::visitIf(If* curr) {\n  BYN_TRACE(\"zz node: If\\n\");\n  startControlFlow(curr);\n  curr->type = getType();\n  curr->condition = popNonVoidExpression();\n  curr->ifTrue = getBlockOrSingleton(curr->type);\n  if (lastSeparator == BinaryConsts::Else) {\n    curr->ifFalse = getBlockOrSingleton(curr->type);\n  }\n  curr->finalize(curr->type);\n  if (lastSeparator != BinaryConsts::End) {\n    throwError(\"if should end with End\");\n  }\n}","target":0,"code_token_length":124,"total_token_length":360,"max_tokens_setting":512}
+{"idx":317133,"func":"static int match_opt_prefix(char *s, int l, char **arg)\n{\n\tint i;\n\n\tfor (i = 0; i < ARRAY_SIZE(tokens); i++) {\n\t\tsize_t len = tokens[i].len;\n\t\tif (len > l || memcmp(s, tokens[i].name, len))\n\t\t\tcontinue;\n\t\tif (tokens[i].has_arg) {\n\t\t\tif (len == l || s[len] != '=')\n\t\t\t\tcontinue;\n\t\t\t*arg = s + len + 1;\n\t\t} else if (len != l)\n\t\t\tcontinue;\n\t\treturn tokens[i].opt;\n\t}\n\treturn Opt_error;\n}","target":0,"code_token_length":131,"total_token_length":367,"max_tokens_setting":512}
+{"idx":256162,"func":"ALWAYS_INLINE bool IsZero(bfloat16 v) {\n  return !static_cast<bool>(v);\n}","target":0,"code_token_length":23,"total_token_length":259,"max_tokens_setting":512}
+{"idx":312444,"func":"qf_history(exarg_T *eap)\n{\n    qf_info_T\t*qi = qf_cmd_get_stack(eap, FALSE);\n    int\t\ti;\n\n    if (eap->addr_count > 0)\n    {\n\tif (qi == NULL)\n\t{\n\t    emsg(_(e_no_location_list));\n\t    return;\n\t}\n\n\t\/\/ Jump to the specified quickfix list\n\tif (eap->line2 > 0 && eap->line2 <= qi->qf_listcount)\n\t{\n\t    qi->qf_curlist = eap->line2 - 1;\n\t    qf_msg(qi, qi->qf_curlist, \"\");\n\t    qf_update_buffer(qi, NULL);\n\t}\n\telse\n\t    emsg(_(e_invalid_range));\n\n\treturn;\n    }\n\n    if (qf_stack_empty(qi))\n\tmsg(_(\"No entries\"));\n    else\n\tfor (i = 0; i < qi->qf_listcount; ++i)\n\t    qf_msg(qi, i, i == qi->qf_curlist ? \"> \" : \"  \");\n}","target":0,"code_token_length":232,"total_token_length":468,"max_tokens_setting":512}
+{"idx":373641,"func":"find_script_callback(char_u *fname, void *cookie)\n{\n    int sid;\n    int error = OK;\n    int *ret_sid = cookie;\n\n    sid = find_script_by_name(fname);\n    if (sid < 0)\n    {\n\t\/\/ script does not exist yet, create a new scriptitem\n\tsid = get_new_scriptitem(&error);\n\tif (error == OK)\n\t{\n\t    scriptitem_T *si = SCRIPT_ITEM(sid);\n\n\t    si->sn_name = vim_strsave(fname);\n\t    si->sn_state = SN_STATE_NOT_LOADED;\n\t}\n    }\n    *ret_sid = sid;\n}","target":0,"code_token_length":127,"total_token_length":363,"max_tokens_setting":512}
+{"idx":225864,"func":"\nGF_Box *lsr1_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_LASeRSampleEntryBox, GF_ISOM_BOX_TYPE_LSR1);\n\tgf_isom_sample_entry_init((GF_SampleEntryBox*)tmp);\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":58,"total_token_length":294,"max_tokens_setting":512}
+{"idx":198523,"func":"  void Compute(OpKernelContext* context) override {\n    \/\/ Get the stamp token.\n    const Tensor* stamp_token_t;\n    OP_REQUIRES_OK(context, context->input(\"stamp_token\", &stamp_token_t));\n    int64_t stamp_token = stamp_token_t->scalar<int64>()();\n\n    \/\/ Get the tree ensemble proto.\n    const Tensor* tree_ensemble_serialized_t;\n    OP_REQUIRES_OK(context, context->input(\"tree_ensemble_serialized\",\n                                           &tree_ensemble_serialized_t));\n    std::unique_ptr<BoostedTreesEnsembleResource> result(\n        new BoostedTreesEnsembleResource());\n    if (!result->InitFromSerialized(\n            tree_ensemble_serialized_t->scalar<tstring>()(), stamp_token)) {\n      result->Unref();\n      OP_REQUIRES(\n          context, false,\n          errors::InvalidArgument(\"Unable to parse tree ensemble proto.\"));\n    }\n\n    \/\/ Only create one, if one does not exist already. Report status for all\n    \/\/ other exceptions.\n    auto status =\n        CreateResource(context, HandleFromInput(context, 0), result.release());\n    if (status.code() != tensorflow::error::ALREADY_EXISTS) {\n      OP_REQUIRES_OK(context, status);\n    }\n  }","target":1,"code_token_length":261,"total_token_length":497,"max_tokens_setting":512}
+{"idx":353154,"func":"void SplashOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {\n  double bbox[4] = {0,0,1,1}; \/\/ dummy\n\n  \/* transfer mask to alpha channel! *\/\n  \/\/ memcpy(maskBitmap->getAlphaPtr(), maskBitmap->getDataPtr(), bitmap->getRowSize() * bitmap->getHeight());\n  \/\/ memset(maskBitmap->getDataPtr(), 0, bitmap->getRowSize() * bitmap->getHeight());\n  if (transpGroupStack->softmask != nullptr) {\n    unsigned char *dest = bitmap->getAlphaPtr();\n    unsigned char *src = transpGroupStack->softmask->getDataPtr();\n    for (int c= 0; c < transpGroupStack->softmask->getRowSize() * transpGroupStack->softmask->getHeight(); c++) {\n      dest[c] = src[c];\n    }\n    delete transpGroupStack->softmask;\n    transpGroupStack->softmask = nullptr;\n  }\n  endTransparencyGroup(state);\n  baseMatrix[4] += transpGroupStack->tx;\n  baseMatrix[5] += transpGroupStack->ty;\n  paintTransparencyGroup(state, bbox);\n}","target":0,"code_token_length":256,"total_token_length":492,"max_tokens_setting":512}
+{"idx":238800,"func":"set_search_direction(int cdir)\n{\n    spats[0].off.dir = cdir;\n}","target":0,"code_token_length":21,"total_token_length":257,"max_tokens_setting":512}
+{"idx":508398,"func":"check_and_update_table_version(THD *thd,\n                               TABLE_LIST *tables, TABLE_SHARE *table_share)\n{\n  if (! tables->is_table_ref_id_equal(table_share))\n  {\n    if (thd->m_reprepare_observer &&\n        thd->m_reprepare_observer->report_error(thd))\n    {\n      \/*\n        Version of the table share is different from the\n        previous execution of the prepared statement, and it is\n        unacceptable for this SQLCOM. Error has been reported.\n      *\/\n      DBUG_ASSERT(thd->is_error());\n      return TRUE;\n    }\n    \/* Always maintain the latest version and type *\/\n    tables->set_table_ref_id(table_share);\n  }\n\n  DBUG_EXECUTE_IF(\"reprepare_each_statement\", return inject_reprepare(thd););\n  return FALSE;\n}","target":0,"code_token_length":167,"total_token_length":403,"max_tokens_setting":512}
+{"idx":513179,"func":"static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,\n                               void *save, st_mysql_value *value)\n{\n  my_bool fixed1, fixed2;\n  long long orig, val;\n  struct my_option options;\n  value->val_int(value, &orig);\n  val= orig;\n  plugin_opt_set_limits(&options, var);\n\n  if (var->flags & PLUGIN_VAR_UNSIGNED)\n  {\n    if ((fixed1= (!value->is_unsigned(value) && val < 0)))\n      val=0;\n    *(ulonglong *)save= getopt_ull_limit_value((ulonglong) val, &options,\n                                               &fixed2);\n  }\n  else\n  {\n    if ((fixed1= (value->is_unsigned(value) && val < 0)))\n      val=LONGLONG_MAX;\n    *(longlong *)save= getopt_ll_limit_value(val, &options, &fixed2);\n  }\n\n  return throw_bounds_warning(thd, var->name, fixed1 || fixed2,\n                              value->is_unsigned(value), (longlong) orig);\n}","target":0,"code_token_length":229,"total_token_length":465,"max_tokens_setting":512}
+{"idx":359493,"func":"DEFUN (no_neighbor_local_as,\n       no_neighbor_local_as_cmd,\n       NO_NEIGHBOR_CMD2 \"local-as\",\n       NO_STR\n       NEIGHBOR_STR\n       NEIGHBOR_ADDR_STR2\n       \"Specify a local-as number\\n\")\n{\n  struct peer *peer;\n  int ret;\n\n  peer = peer_and_group_lookup_vty (vty, argv[0]);\n  if (! peer)\n    return CMD_WARNING;\n\n  ret = peer_local_as_unset (peer);\n  return bgp_vty_return (vty, ret);\n}","target":0,"code_token_length":115,"total_token_length":351,"max_tokens_setting":512}
+{"idx":482530,"func":"hexValue(const FileInfo *file, const widechar *digits, int length) {\n\tint k;\n\tunsigned int binaryValue = 0;\n\tfor (k = 0; k < length; k++) {\n\t\tunsigned int hexDigit = 0;\n\t\tif (digits[k] >= '0' && digits[k] <= '9')\n\t\t\thexDigit = digits[k] - '0';\n\t\telse if (digits[k] >= 'a' && digits[k] <= 'f')\n\t\t\thexDigit = digits[k] - 'a' + 10;\n\t\telse if (digits[k] >= 'A' && digits[k] <= 'F')\n\t\t\thexDigit = digits[k] - 'A' + 10;\n\t\telse {\n\t\t\tcompileError(file, \"invalid %d-digit hexadecimal number\", length);\n\t\t\treturn (widechar)0xffffffff;\n\t\t}\n\t\tbinaryValue |= hexDigit << (4 * (length - 1 - k));\n\t}\n\treturn (widechar)binaryValue;\n}","target":0,"code_token_length":214,"total_token_length":450,"max_tokens_setting":512}
+{"idx":247595,"func":"TEST_P(SslSocketTest, FailedClientCertificateHashVerificationNoClientCertificate) {\n  const std::string client_ctx_yaml = R\"EOF(\n    common_tls_context:\n  )EOF\";\n\n  const std::string server_ctx_yaml = absl::StrCat(R\"EOF(\n  common_tls_context:\n    tls_certificates:\n      certificate_chain:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_cert.pem\"\n      private_key:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/unittest_key.pem\"\n    validation_context:\n      trusted_ca:\n        filename: \"{{ test_rundir }}\/test\/extensions\/transport_sockets\/tls\/test_data\/ca_cert.pem\"\n      verify_certificate_hash: \")EOF\",\n                                                   TEST_SAN_URI_CERT_256_HASH, \"\\\"\");\n\n  TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());\n  testUtil(test_options.setExpectedServerStats(\"ssl.fail_verify_no_cert\"));\n}","target":0,"code_token_length":210,"total_token_length":446,"max_tokens_setting":512}
+{"idx":226107,"func":"\nGF_Box *trgr_box_new()\n{\n\tISOM_DECL_BOX_ALLOC(GF_TrackGroupBox, GF_ISOM_BOX_TYPE_TRGR);\n\ttmp->groups = gf_list_new();\n\tif (!tmp->groups) {\n\t\tgf_free(tmp);\n\t\treturn NULL;\n\t}\n\treturn (GF_Box *)tmp;","target":0,"code_token_length":64,"total_token_length":300,"max_tokens_setting":512}
+{"idx":96959,"func":"void encode(ArgumentEncoder* encoder, SecCertificateRef certificate)\n{\n    RetainPtr<CFDataRef> data(AdoptCF, SecCertificateCopyData(certificate));\n    encode(encoder, data.get());\n}\n","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
+{"idx":409436,"func":"cursor_is_sleeping(void)\n{\n    return cursor_is_asleep;\n}","target":0,"code_token_length":15,"total_token_length":251,"max_tokens_setting":512}
+{"idx":386554,"func":"void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, double value) {\n    dw.dxfString(  0, \"XRECORD\");\n    dw.dxfHex(5, handle);\n    dw.dxfHex(330, appDictionaryHandle);\n    dw.dxfString(100, \"AcDbXrecord\");\n    dw.dxfInt(280, 1);\n    dw.dxfReal(40, value);\n}","target":0,"code_token_length":103,"total_token_length":339,"max_tokens_setting":512}
+{"idx":380951,"func":"ins_scroll(void)\n{\n    pos_T\ttpos;\n\n    undisplay_dollar();\n    tpos = curwin->w_cursor;\n    if (gui_do_scroll())\n    {\n\tstart_arrow(&tpos);\n\tcan_cindent = TRUE;\n    }\n}","target":0,"code_token_length":51,"total_token_length":287,"max_tokens_setting":512}
+{"idx":359552,"func":"DEFUN (bgp_redistribute_ipv6,\n       bgp_redistribute_ipv6_cmd,\n       \"redistribute (connected|kernel|ospf6|ripng|static)\",\n       \"Redistribute information from another routing protocol\\n\"\n       \"Connected\\n\"\n       \"Kernel routes\\n\"\n       \"Open Shurtest Path First (OSPFv3)\\n\"\n       \"Routing Information Protocol (RIPng)\\n\"\n       \"Static routes\\n\")\n{\n  int type;\n\n  type = bgp_str2route_type (AFI_IP6, argv[0]);\n  if (! type)\n    {\n      vty_out (vty, \"%% Invalid route type%s\", VTY_NEWLINE);\n      return CMD_WARNING;\n    }\n\n  return bgp_redistribute_set (vty->index, AFI_IP6, type);\n}","target":0,"code_token_length":172,"total_token_length":408,"max_tokens_setting":512}
+{"idx":244234,"func":"GF_Err unkn_box_write(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu32 type;\n\tGF_UnknownBox *ptr = (GF_UnknownBox *)s;\n\tif (!s) return GF_BAD_PARAM;\n\ttype = s->type;\n\tptr->type = ptr->original_4cc;\n\te = gf_isom_box_write_header(s, bs);\n\tptr->type = type;\n\tif (e) return e;\n\n\tif (ptr->sai_type) {\n\t\tif (ptr->saio_box) {\n\t\t\tu64 pos = gf_bs_get_position(bs);\n\t\t\tgf_bs_seek(bs, ptr->saio_box->offset_first_offset_field);\n\t\t\tif (ptr->saio_box->version)\n\t\t\t\tgf_bs_write_u64(bs, pos);\n\t\t\telse\n\t\t\t\tgf_bs_write_u32(bs, (u32) pos);\n\t\t\tgf_bs_seek(bs, pos);\n\t\t} else {\n\t\t\tptr->sai_offset = gf_bs_get_position(bs);\n\t\t}\n\t}\n\n\tif (ptr->dataSize && ptr->data) {\n\t\tgf_bs_write_data(bs, ptr->data, ptr->dataSize);\n\t}\n\treturn GF_OK;\n}","target":0,"code_token_length":257,"total_token_length":493,"max_tokens_setting":512}
+{"idx":512587,"func":"  String *val_str(String*) { return &str_value; }","target":0,"code_token_length":14,"total_token_length":250,"max_tokens_setting":512}
+{"idx":212436,"func":"static int prealloc_elems_and_freelist(struct bpf_stack_map *smap)\n{\n\tu32 elem_size = sizeof(struct stack_map_bucket) + smap->map.value_size;\n\tint err;\n\n\tsmap->elems = bpf_map_area_alloc(elem_size * smap->map.max_entries,\n\t\t\t\t\t smap->map.numa_node);\n\tif (!smap->elems)\n\t\treturn -ENOMEM;\n\n\terr = pcpu_freelist_init(&smap->freelist);\n\tif (err)\n\t\tgoto free_elems;\n\n\tpcpu_freelist_populate(&smap->freelist, smap->elems, elem_size,\n\t\t\t       smap->map.max_entries);\n\treturn 0;\n\nfree_elems:\n\tbpf_map_area_free(smap->elems);\n\treturn err;\n}","target":1,"code_token_length":155,"total_token_length":391,"max_tokens_setting":512}
+{"idx":222553,"func":"const FunctionDef* FunctionLibraryDefinition::Find(const string& func) const {\n  tf_shared_lock l(mu_);\n  auto result = FindHelper(func);\n  if (result) {\n    return &result->fdef;\n  } else {\n    return nullptr;\n  }\n}","target":0,"code_token_length":56,"total_token_length":292,"max_tokens_setting":512}
+{"idx":232948,"func":"static void identity_close_writer(struct Curl_easy *data,\n                                  struct contenc_writer *writer)\n{\n  (void) data;\n  (void) writer;\n}","target":0,"code_token_length":33,"total_token_length":269,"max_tokens_setting":512}
+{"idx":514314,"func":"void multi_update::update_used_tables()\n{\n  Item *item;\n  List_iterator_fast<Item> it(*values);\n  while ((item= it++))\n  {\n    item->update_used_tables();\n  }\n}","target":0,"code_token_length":44,"total_token_length":280,"max_tokens_setting":512}
diff --git a/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.pkl b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..655b5cf3a155b8d906351784503e99dba5d4b4a3
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.pkl
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:db6296b56bfc7096c4eba06464a94579aa131a4164f08ba9fabf8b87771fadec
+size 2813308
diff --git a/categorized_datasets_for_Qwen1M/categorization_results.json b/categorized_datasets_for_Qwen1M/categorization_results.json
new file mode 100644
index 0000000000000000000000000000000000000000..d43383e7562effaf8c46638aa15034d16ed9a618
--- /dev/null
+++ b/categorized_datasets_for_Qwen1M/categorization_results.json
@@ -0,0 +1,206 @@
+{
+  "BigVul_Sample": {
+    "stats": {
+      "total": 10000,
+      "processed": 9999,
+      "skipped": 1,
+      "categories": {
+        "under_512": {
+          "count": 7588,
+          "percentage": 75.88,
+          "max_tokens_setting": 512
+        },
+        "512_to_1024": {
+          "count": 1727,
+          "percentage": 17.27,
+          "max_tokens_setting": 1024
+        },
+        "1024_to_2048": {
+          "count": 490,
+          "percentage": 4.9,
+          "max_tokens_setting": 2048
+        },
+        "2048_to_4096": {
+          "count": 134,
+          "percentage": 1.34,
+          "max_tokens_setting": 4096
+        },
+        "4096_to_6144": {
+          "count": 40,
+          "percentage": 0.4,
+          "max_tokens_setting": 6144
+        },
+        "6144_to_8192": {
+          "count": 10,
+          "percentage": 0.1,
+          "max_tokens_setting": 8192
+        },
+        "8192_to_11000": {
+          "count": 7,
+          "percentage": 0.07,
+          "max_tokens_setting": 11000
+        },
+        "11000_to_28000": {
+          "count": 3,
+          "percentage": 0.03,
+          "max_tokens_setting": 28000
+        }
+      }
+    },
+    "files": {
+      "stats": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_stats.json",
+      "under_512_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.pkl",
+      "under_512_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_under_512.csv",
+      "512_to_1024_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.pkl",
+      "512_to_1024_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_512_to_1024.csv",
+      "1024_to_2048_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.pkl",
+      "1024_to_2048_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_1024_to_2048.csv",
+      "2048_to_4096_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.pkl",
+      "2048_to_4096_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_2048_to_4096.csv",
+      "4096_to_6144_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.pkl",
+      "4096_to_6144_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_4096_to_6144.csv",
+      "6144_to_8192_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.pkl",
+      "6144_to_8192_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_6144_to_8192.csv",
+      "8192_to_11000_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.pkl",
+      "8192_to_11000_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_8192_to_11000.csv",
+      "11000_to_28000_pkl": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.pkl",
+      "11000_to_28000_file": "categorized_datasets_for_Qwen1M/BigVul_Sample/BigVul_Sample_11000_to_28000.csv"
+    }
+  },
+  "DiverseVul_Sample": {
+    "stats": {
+      "total": 10000,
+      "processed": 9999,
+      "skipped": 1,
+      "categories": {
+        "under_512": {
+          "count": 7000,
+          "percentage": 70.0,
+          "max_tokens_setting": 512
+        },
+        "512_to_1024": {
+          "count": 2089,
+          "percentage": 20.89,
+          "max_tokens_setting": 1024
+        },
+        "1024_to_2048": {
+          "count": 639,
+          "percentage": 6.39,
+          "max_tokens_setting": 2048
+        },
+        "2048_to_4096": {
+          "count": 183,
+          "percentage": 1.83,
+          "max_tokens_setting": 4096
+        },
+        "4096_to_6144": {
+          "count": 45,
+          "percentage": 0.45,
+          "max_tokens_setting": 6144
+        },
+        "6144_to_8192": {
+          "count": 25,
+          "percentage": 0.25,
+          "max_tokens_setting": 8192
+        },
+        "8192_to_11000": {
+          "count": 8,
+          "percentage": 0.08,
+          "max_tokens_setting": 11000
+        },
+        "11000_to_28000": {
+          "count": 10,
+          "percentage": 0.1,
+          "max_tokens_setting": 28000
+        }
+      }
+    },
+    "files": {
+      "stats": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_stats.json",
+      "under_512_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.pkl",
+      "under_512_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_under_512.jsonl",
+      "512_to_1024_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.pkl",
+      "512_to_1024_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_512_to_1024.jsonl",
+      "1024_to_2048_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.pkl",
+      "1024_to_2048_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_1024_to_2048.jsonl",
+      "2048_to_4096_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.pkl",
+      "2048_to_4096_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_2048_to_4096.jsonl",
+      "4096_to_6144_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.pkl",
+      "4096_to_6144_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_4096_to_6144.jsonl",
+      "6144_to_8192_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.pkl",
+      "6144_to_8192_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_6144_to_8192.jsonl",
+      "8192_to_11000_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.pkl",
+      "8192_to_11000_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_8192_to_11000.jsonl",
+      "11000_to_28000_pkl": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.pkl",
+      "11000_to_28000_file": "categorized_datasets_for_Qwen1M/DiverseVul_Sample/DiverseVul_Sample_11000_to_28000.jsonl"
+    }
+  },
+  "PrimeVul_Sample": {
+    "stats": {
+      "total": 10000,
+      "processed": 10000,
+      "skipped": 0,
+      "categories": {
+        "under_512": {
+          "count": 6747,
+          "percentage": 67.47,
+          "max_tokens_setting": 512
+        },
+        "512_to_1024": {
+          "count": 2129,
+          "percentage": 21.29,
+          "max_tokens_setting": 1024
+        },
+        "1024_to_2048": {
+          "count": 768,
+          "percentage": 7.68,
+          "max_tokens_setting": 2048
+        },
+        "2048_to_4096": {
+          "count": 241,
+          "percentage": 2.41,
+          "max_tokens_setting": 4096
+        },
+        "4096_to_6144": {
+          "count": 50,
+          "percentage": 0.5,
+          "max_tokens_setting": 6144
+        },
+        "6144_to_8192": {
+          "count": 21,
+          "percentage": 0.21,
+          "max_tokens_setting": 8192
+        },
+        "8192_to_11000": {
+          "count": 24,
+          "percentage": 0.24,
+          "max_tokens_setting": 11000
+        },
+        "11000_to_28000": {
+          "count": 20,
+          "percentage": 0.2,
+          "max_tokens_setting": 28000
+        }
+      }
+    },
+    "files": {
+      "stats": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_stats.json",
+      "under_512_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.pkl",
+      "under_512_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_under_512.jsonl",
+      "512_to_1024_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.pkl",
+      "512_to_1024_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_512_to_1024.jsonl",
+      "1024_to_2048_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.pkl",
+      "1024_to_2048_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_1024_to_2048.jsonl",
+      "2048_to_4096_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.pkl",
+      "2048_to_4096_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_2048_to_4096.jsonl",
+      "4096_to_6144_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.pkl",
+      "4096_to_6144_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_4096_to_6144.jsonl",
+      "6144_to_8192_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.pkl",
+      "6144_to_8192_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_6144_to_8192.jsonl",
+      "8192_to_11000_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.pkl",
+      "8192_to_11000_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_8192_to_11000.jsonl",
+      "11000_to_28000_pkl": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.pkl",
+      "11000_to_28000_file": "categorized_datasets_for_Qwen1M/PrimeVul_Sample/PrimeVul_Sample_11000_to_28000.jsonl"
+    }
+  }
+}
\ No newline at end of file